diff --git a/README.md b/README.md index 2a4810f8..c1c1062f 100644 --- a/README.md +++ b/README.md @@ -62,5 +62,9 @@ FreeBSD: - Run ./refresh-freebsd-sysroot.sh +illumos: + +- Run ./refresh-illumos-sysroot.sh on an illumos host. + TODO: - simplify directory structure even more. diff --git a/illumos-x86_64/lib/amd64/c_synonyms.so.1 b/illumos-x86_64/lib/amd64/c_synonyms.so.1 new file mode 100755 index 00000000..0666c223 Binary files /dev/null and b/illumos-x86_64/lib/amd64/c_synonyms.so.1 differ diff --git a/illumos-x86_64/lib/amd64/ld.so.1 b/illumos-x86_64/lib/amd64/ld.so.1 new file mode 100755 index 00000000..e77ade34 Binary files /dev/null and b/illumos-x86_64/lib/amd64/ld.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libMPAPI.so b/illumos-x86_64/lib/amd64/libMPAPI.so new file mode 120000 index 00000000..b38b23ee --- /dev/null +++ b/illumos-x86_64/lib/amd64/libMPAPI.so @@ -0,0 +1 @@ +libMPAPI.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libMPAPI.so.1 b/illumos-x86_64/lib/amd64/libMPAPI.so.1 new file mode 100755 index 00000000..4e39c9b8 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libMPAPI.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libadm.so b/illumos-x86_64/lib/amd64/libadm.so new file mode 120000 index 00000000..01c83607 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libadm.so @@ -0,0 +1 @@ +libadm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libadm.so.1 b/illumos-x86_64/lib/amd64/libadm.so.1 new file mode 100755 index 00000000..8a67e805 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libadm.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libaio.so b/illumos-x86_64/lib/amd64/libaio.so new file mode 120000 index 00000000..4471ff94 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libaio.so @@ -0,0 +1 @@ +libaio.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libaio.so.1 b/illumos-x86_64/lib/amd64/libaio.so.1 new file mode 100755 index 00000000..88af5728 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libaio.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libavl.so b/illumos-x86_64/lib/amd64/libavl.so new file mode 120000 index 00000000..bed4d765 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libavl.so @@ -0,0 +1 @@ +libavl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libavl.so.1 b/illumos-x86_64/lib/amd64/libavl.so.1 new file mode 100755 index 00000000..8b634a6f Binary files /dev/null and b/illumos-x86_64/lib/amd64/libavl.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libbsm.so b/illumos-x86_64/lib/amd64/libbsm.so new file mode 120000 index 00000000..1b5ea1da --- /dev/null +++ b/illumos-x86_64/lib/amd64/libbsm.so @@ -0,0 +1 @@ +libbsm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libbsm.so.1 b/illumos-x86_64/lib/amd64/libbsm.so.1 new file mode 100755 index 00000000..be854b1b Binary files /dev/null and b/illumos-x86_64/lib/amd64/libbsm.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libc.so b/illumos-x86_64/lib/amd64/libc.so new file mode 120000 index 00000000..519ef4a1 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libc.so @@ -0,0 +1 @@ +libc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libc.so.1 b/illumos-x86_64/lib/amd64/libc.so.1 new file mode 100755 index 00000000..5fc4b782 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libc.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libc_db.so b/illumos-x86_64/lib/amd64/libc_db.so new file mode 120000 index 00000000..28e47bea --- /dev/null +++ b/illumos-x86_64/lib/amd64/libc_db.so @@ -0,0 +1 @@ +libc_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libc_db.so.1 b/illumos-x86_64/lib/amd64/libc_db.so.1 new file mode 100755 index 00000000..17930239 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libc_db.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libcmdutils.so.1 b/illumos-x86_64/lib/amd64/libcmdutils.so.1 new file mode 100755 index 00000000..3ff4de4b Binary files /dev/null and b/illumos-x86_64/lib/amd64/libcmdutils.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libcontract.so b/illumos-x86_64/lib/amd64/libcontract.so new file mode 120000 index 00000000..ac562b62 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libcontract.so @@ -0,0 +1 @@ +libcontract.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libcontract.so.1 b/illumos-x86_64/lib/amd64/libcontract.so.1 new file mode 100755 index 00000000..20aeb234 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libcontract.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libcrypto.so b/illumos-x86_64/lib/amd64/libcrypto.so new file mode 120000 index 00000000..e6d0d802 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libcrypto.so @@ -0,0 +1 @@ +libcrypto.so.3 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libcrypto.so.3 b/illumos-x86_64/lib/amd64/libcrypto.so.3 new file mode 100755 index 00000000..163e14a6 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libcrypto.so.3 differ diff --git a/illumos-x86_64/lib/amd64/libcryptoutil.so b/illumos-x86_64/lib/amd64/libcryptoutil.so new file mode 120000 index 00000000..970b6273 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libcryptoutil.so @@ -0,0 +1 @@ +libcryptoutil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libcryptoutil.so.1 b/illumos-x86_64/lib/amd64/libcryptoutil.so.1 new file mode 100755 index 00000000..27f5a721 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libcryptoutil.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libctf.so b/illumos-x86_64/lib/amd64/libctf.so new file mode 120000 index 00000000..5526e63b --- /dev/null +++ b/illumos-x86_64/lib/amd64/libctf.so @@ -0,0 +1 @@ +libctf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libctf.so.1 b/illumos-x86_64/lib/amd64/libctf.so.1 new file mode 100755 index 00000000..21b1320e Binary files /dev/null and b/illumos-x86_64/lib/amd64/libctf.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libcurses.so b/illumos-x86_64/lib/amd64/libcurses.so new file mode 120000 index 00000000..bda2fe46 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libcurses.so @@ -0,0 +1 @@ +libcurses.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libcurses.so.1 b/illumos-x86_64/lib/amd64/libcurses.so.1 new file mode 100755 index 00000000..e2055549 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libcurses.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libcustr.so.1 b/illumos-x86_64/lib/amd64/libcustr.so.1 new file mode 100755 index 00000000..7c9adc30 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libcustr.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdevice.so b/illumos-x86_64/lib/amd64/libdevice.so new file mode 120000 index 00000000..cd1335c5 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libdevice.so @@ -0,0 +1 @@ +libdevice.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libdevice.so.1 b/illumos-x86_64/lib/amd64/libdevice.so.1 new file mode 100755 index 00000000..ee59c3dc Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdevice.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdevid.so b/illumos-x86_64/lib/amd64/libdevid.so new file mode 120000 index 00000000..070d154e --- /dev/null +++ b/illumos-x86_64/lib/amd64/libdevid.so @@ -0,0 +1 @@ +libdevid.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libdevid.so.1 b/illumos-x86_64/lib/amd64/libdevid.so.1 new file mode 100755 index 00000000..2cad65ff Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdevid.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdevinfo.so b/illumos-x86_64/lib/amd64/libdevinfo.so new file mode 120000 index 00000000..f0123611 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libdevinfo.so @@ -0,0 +1 @@ +libdevinfo.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libdevinfo.so.1 b/illumos-x86_64/lib/amd64/libdevinfo.so.1 new file mode 100755 index 00000000..d2325603 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdevinfo.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdhcpagent.so.1 b/illumos-x86_64/lib/amd64/libdhcpagent.so.1 new file mode 100755 index 00000000..5474cb18 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdhcpagent.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdhcputil.so.1 b/illumos-x86_64/lib/amd64/libdhcputil.so.1 new file mode 100755 index 00000000..eba489b9 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdhcputil.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdl.so b/illumos-x86_64/lib/amd64/libdl.so new file mode 120000 index 00000000..54eac6b5 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libdl.so @@ -0,0 +1 @@ +libdl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libdl.so.1 b/illumos-x86_64/lib/amd64/libdl.so.1 new file mode 100755 index 00000000..69b11968 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdl.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdladm.so b/illumos-x86_64/lib/amd64/libdladm.so new file mode 120000 index 00000000..c5a91bb2 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libdladm.so @@ -0,0 +1 @@ +libdladm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libdladm.so.1 b/illumos-x86_64/lib/amd64/libdladm.so.1 new file mode 100755 index 00000000..681d5cd0 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdladm.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdlpi.so b/illumos-x86_64/lib/amd64/libdlpi.so new file mode 120000 index 00000000..f4c6362f --- /dev/null +++ b/illumos-x86_64/lib/amd64/libdlpi.so @@ -0,0 +1 @@ +libdlpi.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libdlpi.so.1 b/illumos-x86_64/lib/amd64/libdlpi.so.1 new file mode 100755 index 00000000..4b38240a Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdlpi.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdoor.so b/illumos-x86_64/lib/amd64/libdoor.so new file mode 120000 index 00000000..9f55c720 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libdoor.so @@ -0,0 +1 @@ +libdoor.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libdoor.so.1 b/illumos-x86_64/lib/amd64/libdoor.so.1 new file mode 100755 index 00000000..95d0ef43 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdoor.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libdwarf.so.1 b/illumos-x86_64/lib/amd64/libdwarf.so.1 new file mode 100755 index 00000000..58ec428d Binary files /dev/null and b/illumos-x86_64/lib/amd64/libdwarf.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libefi.so b/illumos-x86_64/lib/amd64/libefi.so new file mode 120000 index 00000000..16f82bf1 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libefi.so @@ -0,0 +1 @@ +libefi.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libefi.so.1 b/illumos-x86_64/lib/amd64/libefi.so.1 new file mode 100755 index 00000000..5fe68652 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libefi.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libelf.so b/illumos-x86_64/lib/amd64/libelf.so new file mode 120000 index 00000000..92cba5b2 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libelf.so @@ -0,0 +1 @@ +libelf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libelf.so.1 b/illumos-x86_64/lib/amd64/libelf.so.1 new file mode 100755 index 00000000..42d7c964 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libelf.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libfakekernel.so.1 b/illumos-x86_64/lib/amd64/libfakekernel.so.1 new file mode 100755 index 00000000..8710a6c2 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libfakekernel.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libfdisk.so b/illumos-x86_64/lib/amd64/libfdisk.so new file mode 120000 index 00000000..1e579f31 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libfdisk.so @@ -0,0 +1 @@ +libfdisk.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libfdisk.so.1 b/illumos-x86_64/lib/amd64/libfdisk.so.1 new file mode 100755 index 00000000..fb3df808 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libfdisk.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libgen.so b/illumos-x86_64/lib/amd64/libgen.so new file mode 120000 index 00000000..7e248bc4 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libgen.so @@ -0,0 +1 @@ +libgen.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libgen.so.1 b/illumos-x86_64/lib/amd64/libgen.so.1 new file mode 100755 index 00000000..e0aae44c Binary files /dev/null and b/illumos-x86_64/lib/amd64/libgen.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libinetutil.so.1 b/illumos-x86_64/lib/amd64/libinetutil.so.1 new file mode 100755 index 00000000..422fddfa Binary files /dev/null and b/illumos-x86_64/lib/amd64/libinetutil.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libintl.so b/illumos-x86_64/lib/amd64/libintl.so new file mode 120000 index 00000000..ea58372d --- /dev/null +++ b/illumos-x86_64/lib/amd64/libintl.so @@ -0,0 +1 @@ +libintl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libintl.so.1 b/illumos-x86_64/lib/amd64/libintl.so.1 new file mode 100755 index 00000000..7bc48e4b Binary files /dev/null and b/illumos-x86_64/lib/amd64/libintl.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libipadm.so.1 b/illumos-x86_64/lib/amd64/libipadm.so.1 new file mode 100755 index 00000000..a43da018 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libipadm.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libipmp.so b/illumos-x86_64/lib/amd64/libipmp.so new file mode 120000 index 00000000..c9f5675d --- /dev/null +++ b/illumos-x86_64/lib/amd64/libipmp.so @@ -0,0 +1 @@ +libipmp.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libipmp.so.1 b/illumos-x86_64/lib/amd64/libipmp.so.1 new file mode 100755 index 00000000..9a252ca3 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libipmp.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libkmf.so b/illumos-x86_64/lib/amd64/libkmf.so new file mode 120000 index 00000000..9a73f6bf --- /dev/null +++ b/illumos-x86_64/lib/amd64/libkmf.so @@ -0,0 +1 @@ +libkmf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libkmf.so.1 b/illumos-x86_64/lib/amd64/libkmf.so.1 new file mode 100755 index 00000000..4fff78c0 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libkmf.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libkmfberder.so b/illumos-x86_64/lib/amd64/libkmfberder.so new file mode 120000 index 00000000..9838f27f --- /dev/null +++ b/illumos-x86_64/lib/amd64/libkmfberder.so @@ -0,0 +1 @@ +libkmfberder.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libkmfberder.so.1 b/illumos-x86_64/lib/amd64/libkmfberder.so.1 new file mode 100755 index 00000000..9c19472a Binary files /dev/null and b/illumos-x86_64/lib/amd64/libkmfberder.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libkstat.so b/illumos-x86_64/lib/amd64/libkstat.so new file mode 120000 index 00000000..36855d96 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libkstat.so @@ -0,0 +1 @@ +libkstat.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libkstat.so.1 b/illumos-x86_64/lib/amd64/libkstat.so.1 new file mode 100755 index 00000000..55f1a705 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libkstat.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libld.so.4 b/illumos-x86_64/lib/amd64/libld.so.4 new file mode 100755 index 00000000..388f90a1 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libld.so.4 differ diff --git a/illumos-x86_64/lib/amd64/liblddbg.so.4 b/illumos-x86_64/lib/amd64/liblddbg.so.4 new file mode 100755 index 00000000..5a902759 Binary files /dev/null and b/illumos-x86_64/lib/amd64/liblddbg.so.4 differ diff --git a/illumos-x86_64/lib/amd64/libm.so b/illumos-x86_64/lib/amd64/libm.so new file mode 120000 index 00000000..40ade70c --- /dev/null +++ b/illumos-x86_64/lib/amd64/libm.so @@ -0,0 +1 @@ +libm.so.2 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libm.so.1 b/illumos-x86_64/lib/amd64/libm.so.1 new file mode 100755 index 00000000..4456240e Binary files /dev/null and b/illumos-x86_64/lib/amd64/libm.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libm.so.2 b/illumos-x86_64/lib/amd64/libm.so.2 new file mode 100755 index 00000000..b78ea771 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libm.so.2 differ diff --git a/illumos-x86_64/lib/amd64/libmd.so b/illumos-x86_64/lib/amd64/libmd.so new file mode 120000 index 00000000..11d2b179 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libmd.so @@ -0,0 +1 @@ +libmd.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libmd.so.1 b/illumos-x86_64/lib/amd64/libmd.so.1 new file mode 100755 index 00000000..43f1c8ea Binary files /dev/null and b/illumos-x86_64/lib/amd64/libmd.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libmd5.so b/illumos-x86_64/lib/amd64/libmd5.so new file mode 120000 index 00000000..b08f2d4f --- /dev/null +++ b/illumos-x86_64/lib/amd64/libmd5.so @@ -0,0 +1 @@ +libmd5.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libmd5.so.1 b/illumos-x86_64/lib/amd64/libmd5.so.1 new file mode 100755 index 00000000..9f93c21a Binary files /dev/null and b/illumos-x86_64/lib/amd64/libmd5.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libmp.so b/illumos-x86_64/lib/amd64/libmp.so new file mode 120000 index 00000000..7bc61f6e --- /dev/null +++ b/illumos-x86_64/lib/amd64/libmp.so @@ -0,0 +1 @@ +libmp.so.2 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libmp.so.2 b/illumos-x86_64/lib/amd64/libmp.so.2 new file mode 100755 index 00000000..f4ffec97 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libmp.so.2 differ diff --git a/illumos-x86_64/lib/amd64/libmpscsi_vhci.so b/illumos-x86_64/lib/amd64/libmpscsi_vhci.so new file mode 120000 index 00000000..bc5f3e0b --- /dev/null +++ b/illumos-x86_64/lib/amd64/libmpscsi_vhci.so @@ -0,0 +1 @@ +libmpscsi_vhci.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libmpscsi_vhci.so.1 b/illumos-x86_64/lib/amd64/libmpscsi_vhci.so.1 new file mode 100755 index 00000000..1c8bf5f3 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libmpscsi_vhci.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libmtsk.so.1 b/illumos-x86_64/lib/amd64/libmtsk.so.1 new file mode 100755 index 00000000..a55da754 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libmtsk.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libmtsk_db.so.1 b/illumos-x86_64/lib/amd64/libmtsk_db.so.1 new file mode 100755 index 00000000..c60edd02 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libmtsk_db.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libmvec.so b/illumos-x86_64/lib/amd64/libmvec.so new file mode 120000 index 00000000..fad6191b --- /dev/null +++ b/illumos-x86_64/lib/amd64/libmvec.so @@ -0,0 +1 @@ +libmvec.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libmvec.so.1 b/illumos-x86_64/lib/amd64/libmvec.so.1 new file mode 100755 index 00000000..29477aea Binary files /dev/null and b/illumos-x86_64/lib/amd64/libmvec.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libnsl.so b/illumos-x86_64/lib/amd64/libnsl.so new file mode 120000 index 00000000..28d16d92 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libnsl.so @@ -0,0 +1 @@ +libnsl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libnsl.so.1 b/illumos-x86_64/lib/amd64/libnsl.so.1 new file mode 100755 index 00000000..5077fa92 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libnsl.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libnvpair.so b/illumos-x86_64/lib/amd64/libnvpair.so new file mode 120000 index 00000000..4de84a27 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libnvpair.so @@ -0,0 +1 @@ +libnvpair.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libnvpair.so.1 b/illumos-x86_64/lib/amd64/libnvpair.so.1 new file mode 100755 index 00000000..bf401e7f Binary files /dev/null and b/illumos-x86_64/lib/amd64/libnvpair.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libnwam.so b/illumos-x86_64/lib/amd64/libnwam.so new file mode 120000 index 00000000..05cf0cd8 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libnwam.so @@ -0,0 +1 @@ +libnwam.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libnwam.so.1 b/illumos-x86_64/lib/amd64/libnwam.so.1 new file mode 100755 index 00000000..94348e94 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libnwam.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libofmt.so b/illumos-x86_64/lib/amd64/libofmt.so new file mode 120000 index 00000000..00be295f --- /dev/null +++ b/illumos-x86_64/lib/amd64/libofmt.so @@ -0,0 +1 @@ +libofmt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libofmt.so.1 b/illumos-x86_64/lib/amd64/libofmt.so.1 new file mode 100755 index 00000000..7af9215c Binary files /dev/null and b/illumos-x86_64/lib/amd64/libofmt.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libpam.so b/illumos-x86_64/lib/amd64/libpam.so new file mode 120000 index 00000000..a4a23d88 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libpam.so @@ -0,0 +1 @@ +libpam.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libpam.so.1 b/illumos-x86_64/lib/amd64/libpam.so.1 new file mode 100755 index 00000000..9cdc44b1 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libpam.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libposix4.so b/illumos-x86_64/lib/amd64/libposix4.so new file mode 120000 index 00000000..7585e3a8 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libposix4.so @@ -0,0 +1 @@ +libposix4.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libposix4.so.1 b/illumos-x86_64/lib/amd64/libposix4.so.1 new file mode 120000 index 00000000..0820df44 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libposix4.so.1 @@ -0,0 +1 @@ +librt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libproc.so b/illumos-x86_64/lib/amd64/libproc.so new file mode 120000 index 00000000..4a909b0c --- /dev/null +++ b/illumos-x86_64/lib/amd64/libproc.so @@ -0,0 +1 @@ +libproc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libproc.so.1 b/illumos-x86_64/lib/amd64/libproc.so.1 new file mode 100755 index 00000000..f469eb89 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libproc.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libpthread.so b/illumos-x86_64/lib/amd64/libpthread.so new file mode 120000 index 00000000..d5b7f141 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libpthread.so @@ -0,0 +1 @@ +libpthread.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libpthread.so.1 b/illumos-x86_64/lib/amd64/libpthread.so.1 new file mode 100755 index 00000000..11fcaa2b Binary files /dev/null and b/illumos-x86_64/lib/amd64/libpthread.so.1 differ diff --git a/illumos-x86_64/lib/amd64/librcm.so b/illumos-x86_64/lib/amd64/librcm.so new file mode 120000 index 00000000..7b43fe10 --- /dev/null +++ b/illumos-x86_64/lib/amd64/librcm.so @@ -0,0 +1 @@ +librcm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/librcm.so.1 b/illumos-x86_64/lib/amd64/librcm.so.1 new file mode 100755 index 00000000..ca2b3f7e Binary files /dev/null and b/illumos-x86_64/lib/amd64/librcm.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libresolv.so b/illumos-x86_64/lib/amd64/libresolv.so new file mode 120000 index 00000000..bf6c17fd --- /dev/null +++ b/illumos-x86_64/lib/amd64/libresolv.so @@ -0,0 +1 @@ +libresolv.so.2 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libresolv.so.2 b/illumos-x86_64/lib/amd64/libresolv.so.2 new file mode 100755 index 00000000..38d0b9bd Binary files /dev/null and b/illumos-x86_64/lib/amd64/libresolv.so.2 differ diff --git a/illumos-x86_64/lib/amd64/librestart.so b/illumos-x86_64/lib/amd64/librestart.so new file mode 120000 index 00000000..0be030a6 --- /dev/null +++ b/illumos-x86_64/lib/amd64/librestart.so @@ -0,0 +1 @@ +librestart.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/librestart.so.1 b/illumos-x86_64/lib/amd64/librestart.so.1 new file mode 100755 index 00000000..94170c1a Binary files /dev/null and b/illumos-x86_64/lib/amd64/librestart.so.1 differ diff --git a/illumos-x86_64/lib/amd64/librpcsvc.so b/illumos-x86_64/lib/amd64/librpcsvc.so new file mode 120000 index 00000000..e4cc4166 --- /dev/null +++ b/illumos-x86_64/lib/amd64/librpcsvc.so @@ -0,0 +1 @@ +librpcsvc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/librpcsvc.so.1 b/illumos-x86_64/lib/amd64/librpcsvc.so.1 new file mode 100755 index 00000000..8887ea34 Binary files /dev/null and b/illumos-x86_64/lib/amd64/librpcsvc.so.1 differ diff --git a/illumos-x86_64/lib/amd64/librt.so b/illumos-x86_64/lib/amd64/librt.so new file mode 120000 index 00000000..0820df44 --- /dev/null +++ b/illumos-x86_64/lib/amd64/librt.so @@ -0,0 +1 @@ +librt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/librt.so.1 b/illumos-x86_64/lib/amd64/librt.so.1 new file mode 100755 index 00000000..76e697e9 Binary files /dev/null and b/illumos-x86_64/lib/amd64/librt.so.1 differ diff --git a/illumos-x86_64/lib/amd64/librtld.so.1 b/illumos-x86_64/lib/amd64/librtld.so.1 new file mode 100755 index 00000000..9ab52fca Binary files /dev/null and b/illumos-x86_64/lib/amd64/librtld.so.1 differ diff --git a/illumos-x86_64/lib/amd64/librtld_db.so b/illumos-x86_64/lib/amd64/librtld_db.so new file mode 120000 index 00000000..9a12d822 --- /dev/null +++ b/illumos-x86_64/lib/amd64/librtld_db.so @@ -0,0 +1 @@ +librtld_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/librtld_db.so.1 b/illumos-x86_64/lib/amd64/librtld_db.so.1 new file mode 100755 index 00000000..8e481c48 Binary files /dev/null and b/illumos-x86_64/lib/amd64/librtld_db.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libscf.so b/illumos-x86_64/lib/amd64/libscf.so new file mode 120000 index 00000000..84098e00 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libscf.so @@ -0,0 +1 @@ +libscf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libscf.so.1 b/illumos-x86_64/lib/amd64/libscf.so.1 new file mode 100755 index 00000000..da88d1e0 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libscf.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libsec.so b/illumos-x86_64/lib/amd64/libsec.so new file mode 120000 index 00000000..2705e6be --- /dev/null +++ b/illumos-x86_64/lib/amd64/libsec.so @@ -0,0 +1 @@ +libsec.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libsec.so.1 b/illumos-x86_64/lib/amd64/libsec.so.1 new file mode 100755 index 00000000..ea8ea051 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libsec.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libsecdb.so b/illumos-x86_64/lib/amd64/libsecdb.so new file mode 120000 index 00000000..1e6a363f --- /dev/null +++ b/illumos-x86_64/lib/amd64/libsecdb.so @@ -0,0 +1 @@ +libsecdb.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libsecdb.so.1 b/illumos-x86_64/lib/amd64/libsecdb.so.1 new file mode 100755 index 00000000..ba842a2c Binary files /dev/null and b/illumos-x86_64/lib/amd64/libsecdb.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libsendfile.so b/illumos-x86_64/lib/amd64/libsendfile.so new file mode 120000 index 00000000..10ef167e --- /dev/null +++ b/illumos-x86_64/lib/amd64/libsendfile.so @@ -0,0 +1 @@ +libsendfile.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libsendfile.so.1 b/illumos-x86_64/lib/amd64/libsendfile.so.1 new file mode 100755 index 00000000..037481d7 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libsendfile.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libsocket.so b/illumos-x86_64/lib/amd64/libsocket.so new file mode 120000 index 00000000..fb40adce --- /dev/null +++ b/illumos-x86_64/lib/amd64/libsocket.so @@ -0,0 +1 @@ +libsocket.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libsocket.so.1 b/illumos-x86_64/lib/amd64/libsocket.so.1 new file mode 100755 index 00000000..b5d51db6 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libsocket.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libssl.so b/illumos-x86_64/lib/amd64/libssl.so new file mode 120000 index 00000000..7481049b --- /dev/null +++ b/illumos-x86_64/lib/amd64/libssl.so @@ -0,0 +1 @@ +libssl.so.3 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libssl.so.3 b/illumos-x86_64/lib/amd64/libssl.so.3 new file mode 100755 index 00000000..d01cc5d3 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libssl.so.3 differ diff --git a/illumos-x86_64/lib/amd64/libsysevent.so b/illumos-x86_64/lib/amd64/libsysevent.so new file mode 120000 index 00000000..e5338353 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libsysevent.so @@ -0,0 +1 @@ +libsysevent.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libsysevent.so.1 b/illumos-x86_64/lib/amd64/libsysevent.so.1 new file mode 100755 index 00000000..16132cff Binary files /dev/null and b/illumos-x86_64/lib/amd64/libsysevent.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libtermcap.so b/illumos-x86_64/lib/amd64/libtermcap.so new file mode 120000 index 00000000..f14cd8d2 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libtermcap.so @@ -0,0 +1 @@ +libtermcap.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libtermcap.so.1 b/illumos-x86_64/lib/amd64/libtermcap.so.1 new file mode 100755 index 00000000..923d599d Binary files /dev/null and b/illumos-x86_64/lib/amd64/libtermcap.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libtermlib.so b/illumos-x86_64/lib/amd64/libtermlib.so new file mode 120000 index 00000000..de6d7c74 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libtermlib.so @@ -0,0 +1 @@ +libtermlib.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libtermlib.so.1 b/illumos-x86_64/lib/amd64/libtermlib.so.1 new file mode 120000 index 00000000..bda2fe46 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libtermlib.so.1 @@ -0,0 +1 @@ +libcurses.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libthread.so b/illumos-x86_64/lib/amd64/libthread.so new file mode 120000 index 00000000..cd375a1b --- /dev/null +++ b/illumos-x86_64/lib/amd64/libthread.so @@ -0,0 +1 @@ +libthread.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libthread.so.1 b/illumos-x86_64/lib/amd64/libthread.so.1 new file mode 100755 index 00000000..2fa02928 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libthread.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libthread_db.so b/illumos-x86_64/lib/amd64/libthread_db.so new file mode 120000 index 00000000..28e47bea --- /dev/null +++ b/illumos-x86_64/lib/amd64/libthread_db.so @@ -0,0 +1 @@ +libc_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libthread_db.so.1 b/illumos-x86_64/lib/amd64/libthread_db.so.1 new file mode 120000 index 00000000..28e47bea --- /dev/null +++ b/illumos-x86_64/lib/amd64/libthread_db.so.1 @@ -0,0 +1 @@ +libc_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libtsnet.so b/illumos-x86_64/lib/amd64/libtsnet.so new file mode 120000 index 00000000..7400a4c3 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libtsnet.so @@ -0,0 +1 @@ +libtsnet.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libtsnet.so.1 b/illumos-x86_64/lib/amd64/libtsnet.so.1 new file mode 100755 index 00000000..fa5085c3 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libtsnet.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libtsol.so b/illumos-x86_64/lib/amd64/libtsol.so new file mode 120000 index 00000000..bfc5f79d --- /dev/null +++ b/illumos-x86_64/lib/amd64/libtsol.so @@ -0,0 +1 @@ +libtsol.so.2 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libtsol.so.2 b/illumos-x86_64/lib/amd64/libtsol.so.2 new file mode 100755 index 00000000..addaba87 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libtsol.so.2 differ diff --git a/illumos-x86_64/lib/amd64/libumem.so b/illumos-x86_64/lib/amd64/libumem.so new file mode 120000 index 00000000..ac7c2eef --- /dev/null +++ b/illumos-x86_64/lib/amd64/libumem.so @@ -0,0 +1 @@ +libumem.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libumem.so.1 b/illumos-x86_64/lib/amd64/libumem.so.1 new file mode 100755 index 00000000..0b22552a Binary files /dev/null and b/illumos-x86_64/lib/amd64/libumem.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libuuid.so b/illumos-x86_64/lib/amd64/libuuid.so new file mode 120000 index 00000000..f82fa216 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libuuid.so @@ -0,0 +1 @@ +libuuid.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libuuid.so.1 b/illumos-x86_64/lib/amd64/libuuid.so.1 new file mode 100755 index 00000000..8c4c3f44 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libuuid.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libuutil.so b/illumos-x86_64/lib/amd64/libuutil.so new file mode 120000 index 00000000..5d04f8bc --- /dev/null +++ b/illumos-x86_64/lib/amd64/libuutil.so @@ -0,0 +1 @@ +libuutil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libuutil.so.1 b/illumos-x86_64/lib/amd64/libuutil.so.1 new file mode 100755 index 00000000..93e07e30 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libuutil.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libvarpd.so.1 b/illumos-x86_64/lib/amd64/libvarpd.so.1 new file mode 100755 index 00000000..361ddd32 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libvarpd.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libvmm.so.1 b/illumos-x86_64/lib/amd64/libvmm.so.1 new file mode 100755 index 00000000..2c1779fb Binary files /dev/null and b/illumos-x86_64/lib/amd64/libvmm.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libvmmapi.so.1 b/illumos-x86_64/lib/amd64/libvmmapi.so.1 new file mode 100755 index 00000000..4aaeb478 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libvmmapi.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libw.so b/illumos-x86_64/lib/amd64/libw.so new file mode 120000 index 00000000..cdecc07d --- /dev/null +++ b/illumos-x86_64/lib/amd64/libw.so @@ -0,0 +1 @@ +libw.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libw.so.1 b/illumos-x86_64/lib/amd64/libw.so.1 new file mode 100755 index 00000000..b45dc0e1 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libw.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libxml2.so b/illumos-x86_64/lib/amd64/libxml2.so new file mode 120000 index 00000000..8510fdcb --- /dev/null +++ b/illumos-x86_64/lib/amd64/libxml2.so @@ -0,0 +1 @@ +libxml2.so.16.0.6 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libxml2.so.16 b/illumos-x86_64/lib/amd64/libxml2.so.16 new file mode 120000 index 00000000..8510fdcb --- /dev/null +++ b/illumos-x86_64/lib/amd64/libxml2.so.16 @@ -0,0 +1 @@ +libxml2.so.16.0.6 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libxml2.so.16.0.6 b/illumos-x86_64/lib/amd64/libxml2.so.16.0.6 new file mode 100755 index 00000000..d775502f Binary files /dev/null and b/illumos-x86_64/lib/amd64/libxml2.so.16.0.6 differ diff --git a/illumos-x86_64/lib/amd64/libxml2.so.2 b/illumos-x86_64/lib/amd64/libxml2.so.2 new file mode 120000 index 00000000..227da14b --- /dev/null +++ b/illumos-x86_64/lib/amd64/libxml2.so.2 @@ -0,0 +1 @@ +libxml2.so.2.13.8 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libxml2.so.2.13.8 b/illumos-x86_64/lib/amd64/libxml2.so.2.13.8 new file mode 100755 index 00000000..c0bf528f Binary files /dev/null and b/illumos-x86_64/lib/amd64/libxml2.so.2.13.8 differ diff --git a/illumos-x86_64/lib/amd64/libxnet.so b/illumos-x86_64/lib/amd64/libxnet.so new file mode 120000 index 00000000..7bb40abd --- /dev/null +++ b/illumos-x86_64/lib/amd64/libxnet.so @@ -0,0 +1 @@ +libxnet.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libxnet.so.1 b/illumos-x86_64/lib/amd64/libxnet.so.1 new file mode 100755 index 00000000..5dcf14b4 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libxnet.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libz.so b/illumos-x86_64/lib/amd64/libz.so new file mode 120000 index 00000000..1468e125 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libz.so @@ -0,0 +1 @@ +libz.so.1.3.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libz.so.1 b/illumos-x86_64/lib/amd64/libz.so.1 new file mode 120000 index 00000000..1468e125 --- /dev/null +++ b/illumos-x86_64/lib/amd64/libz.so.1 @@ -0,0 +1 @@ +libz.so.1.3.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libz.so.1.3.1 b/illumos-x86_64/lib/amd64/libz.so.1.3.1 new file mode 100755 index 00000000..f1a4a9e2 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libz.so.1.3.1 differ diff --git a/illumos-x86_64/lib/amd64/libzfs.so b/illumos-x86_64/lib/amd64/libzfs.so new file mode 120000 index 00000000..26620b0c --- /dev/null +++ b/illumos-x86_64/lib/amd64/libzfs.so @@ -0,0 +1 @@ +libzfs.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libzfs.so.1 b/illumos-x86_64/lib/amd64/libzfs.so.1 new file mode 100755 index 00000000..a3e91c11 Binary files /dev/null and b/illumos-x86_64/lib/amd64/libzfs.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libzfs_core.so b/illumos-x86_64/lib/amd64/libzfs_core.so new file mode 120000 index 00000000..2127718e --- /dev/null +++ b/illumos-x86_64/lib/amd64/libzfs_core.so @@ -0,0 +1 @@ +libzfs_core.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libzfs_core.so.1 b/illumos-x86_64/lib/amd64/libzfs_core.so.1 new file mode 100755 index 00000000..2d09164a Binary files /dev/null and b/illumos-x86_64/lib/amd64/libzfs_core.so.1 differ diff --git a/illumos-x86_64/lib/amd64/libzutil.so b/illumos-x86_64/lib/amd64/libzutil.so new file mode 120000 index 00000000..d8b1f81c --- /dev/null +++ b/illumos-x86_64/lib/amd64/libzutil.so @@ -0,0 +1 @@ +libzutil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/lib/amd64/libzutil.so.1 b/illumos-x86_64/lib/amd64/libzutil.so.1 new file mode 100755 index 00000000..154937ae Binary files /dev/null and b/illumos-x86_64/lib/amd64/libzutil.so.1 differ diff --git a/illumos-x86_64/lib/amd64/nss_compat.so.1 b/illumos-x86_64/lib/amd64/nss_compat.so.1 new file mode 100755 index 00000000..70a1867b Binary files /dev/null and b/illumos-x86_64/lib/amd64/nss_compat.so.1 differ diff --git a/illumos-x86_64/lib/amd64/nss_dns.so.1 b/illumos-x86_64/lib/amd64/nss_dns.so.1 new file mode 100755 index 00000000..63038f2d Binary files /dev/null and b/illumos-x86_64/lib/amd64/nss_dns.so.1 differ diff --git a/illumos-x86_64/lib/amd64/nss_files.so.1 b/illumos-x86_64/lib/amd64/nss_files.so.1 new file mode 100755 index 00000000..f9e37c83 Binary files /dev/null and b/illumos-x86_64/lib/amd64/nss_files.so.1 differ diff --git a/illumos-x86_64/lib/amd64/nss_nis.so.1 b/illumos-x86_64/lib/amd64/nss_nis.so.1 new file mode 100755 index 00000000..8eaa58f6 Binary files /dev/null and b/illumos-x86_64/lib/amd64/nss_nis.so.1 differ diff --git a/illumos-x86_64/lib/amd64/nss_user.so.1 b/illumos-x86_64/lib/amd64/nss_user.so.1 new file mode 100755 index 00000000..de4ec5cf Binary files /dev/null and b/illumos-x86_64/lib/amd64/nss_user.so.1 differ diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so b/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so new file mode 120000 index 00000000..fbb347a4 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so @@ -0,0 +1 @@ +libatomic.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so.1 b/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so.1 new file mode 120000 index 00000000..5841e4bc --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so.1 @@ -0,0 +1 @@ +libatomic.so.1.2.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so.1.2.0 b/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so.1.2.0 new file mode 100755 index 00000000..433f1704 Binary files /dev/null and b/illumos-x86_64/usr/gcc/7/lib/amd64/libatomic.so.1.2.0 differ diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libgcc_s.so b/illumos-x86_64/usr/gcc/7/lib/amd64/libgcc_s.so new file mode 120000 index 00000000..83033f74 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libgcc_s.so @@ -0,0 +1 @@ +libgcc_s.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libgcc_s.so.1 b/illumos-x86_64/usr/gcc/7/lib/amd64/libgcc_s.so.1 new file mode 100644 index 00000000..6b3cc30c Binary files /dev/null and b/illumos-x86_64/usr/gcc/7/lib/amd64/libgcc_s.so.1 differ diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so b/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so new file mode 120000 index 00000000..d3d3a1ae --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so @@ -0,0 +1 @@ +libgfortran.so.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so.4 b/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so.4 new file mode 120000 index 00000000..a61a9da4 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so.4 @@ -0,0 +1 @@ +libgfortran.so.4.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so.4.0.0 b/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so.4.0.0 new file mode 100755 index 00000000..a05d39be Binary files /dev/null and b/illumos-x86_64/usr/gcc/7/lib/amd64/libgfortran.so.4.0.0 differ diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so b/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so new file mode 120000 index 00000000..82b51064 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so @@ -0,0 +1 @@ +libgomp.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so.1 b/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so.1 new file mode 120000 index 00000000..c5be39e6 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so.1 @@ -0,0 +1 @@ +libgomp.so.1.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so.1.0.0 b/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so.1.0.0 new file mode 100755 index 00000000..39ec5183 Binary files /dev/null and b/illumos-x86_64/usr/gcc/7/lib/amd64/libgomp.so.1.0.0 differ diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so b/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so new file mode 120000 index 00000000..bf5541ea --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so @@ -0,0 +1 @@ +libquadmath.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so.0 b/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so.0 new file mode 120000 index 00000000..7932e984 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so.0 @@ -0,0 +1 @@ +libquadmath.so.0.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so.0.0.0 b/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so.0.0.0 new file mode 100755 index 00000000..f033c619 Binary files /dev/null and b/illumos-x86_64/usr/gcc/7/lib/amd64/libquadmath.so.0.0.0 differ diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so b/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so new file mode 120000 index 00000000..1919598c --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so @@ -0,0 +1 @@ +libssp.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so.0 b/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so.0 new file mode 120000 index 00000000..67650848 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so.0 @@ -0,0 +1 @@ +libssp.so.0.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so.0.0.0 b/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so.0.0.0 new file mode 100755 index 00000000..ca6ba30b Binary files /dev/null and b/illumos-x86_64/usr/gcc/7/lib/amd64/libssp.so.0.0.0 differ diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so b/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so new file mode 120000 index 00000000..87ceb047 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so @@ -0,0 +1 @@ +libstdc++.so.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so.6 b/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so.6 new file mode 120000 index 00000000..a6d5db95 --- /dev/null +++ b/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so.6 @@ -0,0 +1 @@ +libstdc++.so.6.0.24 \ No newline at end of file diff --git a/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so.6.0.24 b/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so.6.0.24 new file mode 100755 index 00000000..85e448ce Binary files /dev/null and b/illumos-x86_64/usr/gcc/7/lib/amd64/libstdc++.so.6.0.24 differ diff --git a/illumos-x86_64/usr/include/FlexLexer.h b/illumos-x86_64/usr/include/FlexLexer.h new file mode 100644 index 00000000..c4dad2b1 --- /dev/null +++ b/illumos-x86_64/usr/include/FlexLexer.h @@ -0,0 +1,220 @@ +// -*-C++-*- +// FlexLexer.h -- define interfaces for lexical analyzer classes generated +// by flex + +// Copyright (c) 1993 The Regents of the University of California. +// All rights reserved. +// +// This code is derived from software contributed to Berkeley by +// Kent Williams and Tom Epperly. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: + +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. + +// Neither the name of the University nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE. + +// This file defines FlexLexer, an abstract class which specifies the +// external interface provided to flex C++ lexer objects, and yyFlexLexer, +// which defines a particular lexer class. +// +// If you want to create multiple lexer classes, you use the -P flag +// to rename each yyFlexLexer to some other xxFlexLexer. You then +// include in your other sources once per lexer class: +// +// #undef yyFlexLexer +// #define yyFlexLexer xxFlexLexer +// #include +// +// #undef yyFlexLexer +// #define yyFlexLexer zzFlexLexer +// #include +// ... + +#ifndef __FLEX_LEXER_H +// Never included before - need to define base class. +#define __FLEX_LEXER_H + +#include + +extern "C++" { + +struct yy_buffer_state; +typedef int yy_state_type; + +class FlexLexer +{ +public: + virtual ~FlexLexer() { } + + const char* YYText() const { return yytext; } + int YYLeng() const { return yyleng; } + + virtual void + yy_switch_to_buffer( yy_buffer_state* new_buffer ) = 0; + virtual yy_buffer_state* yy_create_buffer( std::istream* s, int size ) = 0; + virtual yy_buffer_state* yy_create_buffer( std::istream& s, int size ) = 0; + virtual void yy_delete_buffer( yy_buffer_state* b ) = 0; + virtual void yyrestart( std::istream* s ) = 0; + virtual void yyrestart( std::istream& s ) = 0; + + virtual int yylex() = 0; + + // Call yylex with new input/output sources. + int yylex( std::istream& new_in, std::ostream& new_out ) + { + switch_streams( new_in, new_out ); + return yylex(); + } + + int yylex( std::istream* new_in, std::ostream* new_out = 0) + { + switch_streams( new_in, new_out ); + return yylex(); + } + + // Switch to new input/output streams. A nil stream pointer + // indicates "keep the current one". + virtual void switch_streams( std::istream* new_in, + std::ostream* new_out ) = 0; + virtual void switch_streams( std::istream& new_in, + std::ostream& new_out ) = 0; + + int lineno() const { return yylineno; } + + int debug() const { return yy_flex_debug; } + void set_debug( int flag ) { yy_flex_debug = flag; } + +protected: + char* yytext; + int yyleng; + int yylineno; // only maintained if you use %option yylineno + int yy_flex_debug; // only has effect with -d or "%option debug" +}; + +} +#endif // FLEXLEXER_H + +#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) +// Either this is the first time through (yyFlexLexerOnce not defined), +// or this is a repeated include to define a different flavor of +// yyFlexLexer, as discussed in the flex manual. +# define yyFlexLexerOnce + +extern "C++" { + +class yyFlexLexer : public FlexLexer { +public: + // arg_yyin and arg_yyout default to the cin and cout, but we + // only make that assignment when initializing in yylex(). + yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ); + yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 ); +private: + void ctor_common(); + +public: + + virtual ~yyFlexLexer(); + + void yy_switch_to_buffer( yy_buffer_state* new_buffer ); + yy_buffer_state* yy_create_buffer( std::istream* s, int size ); + yy_buffer_state* yy_create_buffer( std::istream& s, int size ); + void yy_delete_buffer( yy_buffer_state* b ); + void yyrestart( std::istream* s ); + void yyrestart( std::istream& s ); + + void yypush_buffer_state( yy_buffer_state* new_buffer ); + void yypop_buffer_state(); + + virtual int yylex(); + virtual void switch_streams( std::istream& new_in, std::ostream& new_out ); + virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 ); + virtual int yywrap(); + +protected: + virtual int LexerInput( char* buf, int max_size ); + virtual void LexerOutput( const char* buf, int size ); + virtual void LexerError( const char* msg ); + + void yyunput( int c, char* buf_ptr ); + int yyinput(); + + void yy_load_buffer_state(); + void yy_init_buffer( yy_buffer_state* b, std::istream& s ); + void yy_flush_buffer( yy_buffer_state* b ); + + int yy_start_stack_ptr; + int yy_start_stack_depth; + int* yy_start_stack; + + void yy_push_state( int new_state ); + void yy_pop_state(); + int yy_top_state(); + + yy_state_type yy_get_previous_state(); + yy_state_type yy_try_NUL_trans( yy_state_type current_state ); + int yy_get_next_buffer(); + + std::istream yyin; // input source for default LexerInput + std::ostream yyout; // output sink for default LexerOutput + + // yy_hold_char holds the character lost when yytext is formed. + char yy_hold_char; + + // Number of characters read into yy_ch_buf. + int yy_n_chars; + + // Points to current character in buffer. + char* yy_c_buf_p; + + int yy_init; // whether we need to initialize + int yy_start; // start state number + + // Flag which is used to allow yywrap()'s to do buffer switches + // instead of setting up a fresh yyin. A bit of a hack ... + int yy_did_buffer_switch_on_eof; + + + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ + void yyensure_buffer_stack(void); + + // The following are not always needed, but may be depending + // on use of certain flex features (like REJECT or yymore()). + + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + yy_state_type* yy_state_buf; + yy_state_type* yy_state_ptr; + + char* yy_full_match; + int* yy_full_state; + int yy_full_lp; + + int yy_lp; + int yy_looking_for_trail_begin; + + int yy_more_flag; + int yy_more_len; + int yy_more_offset; + int yy_prev_more_offset; +}; + +} + +#endif // yyFlexLexer || ! yyFlexLexerOnce diff --git a/illumos-x86_64/usr/include/ads/dsgetdc.h b/illumos-x86_64/usr/include/ads/dsgetdc.h new file mode 100644 index 00000000..175b2cce --- /dev/null +++ b/illumos-x86_64/usr/include/ads/dsgetdc.h @@ -0,0 +1,161 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ + +/* + * Declarations intentionally similar to the MSDN SDK file + * winsdk/Include/DsGetDC.h + */ + + +#ifndef _ADS_DSGETDC_H +#define _ADS_DSGETDC_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flags to passed to DsGetDcName + */ + +#define DS_FORCE_REDISCOVERY 0x00000001 + +#define DS_DIRECTORY_SERVICE_REQUIRED 0x00000010 +#define DS_DIRECTORY_SERVICE_PREFERRED 0x00000020 +#define DS_GC_SERVER_REQUIRED 0x00000040 +#define DS_PDC_REQUIRED 0x00000080 +#define DS_BACKGROUND_ONLY 0x00000100 +#define DS_IP_REQUIRED 0x00000200 +#define DS_KDC_REQUIRED 0x00000400 +#define DS_TIMESERV_REQUIRED 0x00000800 +#define DS_WRITABLE_REQUIRED 0x00001000 +#define DS_GOOD_TIMESERV_PREFERRED 0x00002000 +#define DS_AVOID_SELF 0x00004000 +#define DS_ONLY_LDAP_NEEDED 0x00008000 + + +#define DS_IS_FLAT_NAME 0x00010000 +#define DS_IS_DNS_NAME 0x00020000 + +#define DS_RETURN_DNS_NAME 0x40000000 +#define DS_RETURN_FLAT_NAME 0x80000000 + +/* + * Structure returned from DsGetDcName + * NB: Keep same as adspriv_dcinfo + */ + +typedef struct _DOMAIN_CONTROLLER_INFO { + char *DomainControllerName; + char *DomainControllerAddress; + uint32_t DomainControllerAddressType; + uuid_t DomainGuid; + char *DomainName; + char *DnsForestName; + uint32_t Flags; + char *DcSiteName; + char *ClientSiteName; + uint8_t _sockaddr[256]; +} DOMAIN_CONTROLLER_INFO, *PDOMAIN_CONTROLLER_INFO; + +/* + * Values for DomainControllerAddressType + */ + +#define DS_INET_ADDRESS 1 +#define DS_NETBIOS_ADDRESS 2 + +/* + * Values for returned Flags + */ + +#define DS_PDC_FLAG 0x00000001 /* DC is PDC of Domain */ +#define DS_GC_FLAG 0x00000004 /* DC is a GC of forest */ +#define DS_LDAP_FLAG 0x00000008 /* supports an LDAP server */ +#define DS_DS_FLAG 0x00000010 /* supports a DS and is a */ + /* Domain Controller */ +#define DS_KDC_FLAG 0x00000020 /* is running KDC service */ +#define DS_TIMESERV_FLAG 0x00000040 /* is running time service */ +#define DS_CLOSEST_FLAG 0x00000080 /* DC is in closest site */ + /* to the client */ +#define DS_WRITABLE_FLAG 0x00000100 /* DC has a writable DS */ +#define DS_GOOD_TIMESERV_FLAG 0x00000200 /* is running time service */ + /* (and has clock hardware) */ +#define DS_NDNC_FLAG 0x00000400 /* DomainName is non-domain */ + /* NC serviced by the */ + /* LDAP server */ +#define DS_PING_FLAGS 0x0000FFFF /* Flags returned on ping */ + +#define DS_DNS_CONTROLLER_FLAG 0x20000000 /* DC Name is a DNS name */ +#define DS_DNS_DOMAIN_FLAG 0x40000000 /* DomainName is a DNS name */ +#define DS_DNS_FOREST_FLAG 0x80000000 /* ForestName is a DNS name */ + + +/* + * Function Prototypes + */ + +/* Offial API. Returns an NT error number. */ +extern int +DsGetDcName(const char *ComputerName, + const char *DomainName, const struct uuid *DomainGuid, + const char *SiteName, uint32_t Flags, + DOMAIN_CONTROLLER_INFO **dcinfo); + +/* internal version of above - returns a detailed NT status */ +extern uint32_t +_DsGetDcName(const char *ComputerName, + const char *DomainName, const struct uuid *DomainGuid, + const char *SiteName, uint32_t Flags, + DOMAIN_CONTROLLER_INFO **dcinfo); + +extern int +DsGetSiteName( + const char *ComputerName, + char **SiteName); + +/* + * XXX: Others from DsGetDc.h we may want later: + * DsValidateSubnetName() + * DsAddressToSiteNames() + * DsAddressToSiteNamesEx() + * DsEnumerateDomainTrusts() + * DsGetForestTrustInformation() + * DsGetDcSiteCoverage() + * DsDeregisterDnsHostRecords() + * DsGetDcOpen(), DsGetDcNext(), DsGetDcClose() + */ + +/* + * Until we can easily allocate a DC Info as one big hunk. + * This will free a DC Info returned by DsGetDcName(). + */ +extern void +DsFreeDcInfo(DOMAIN_CONTROLLER_INFO *); + +/* + * Internal function to force DC Rediscovery. + */ +extern int +_DsForceRediscovery(char *domain, int flags); + +#ifdef __cplusplus +} +#endif + +#endif /* _ADS_DSGETDC_H */ diff --git a/illumos-x86_64/usr/include/aio.h b/illumos-x86_64/usr/include/aio.h new file mode 100644 index 00000000..ee2fb776 --- /dev/null +++ b/illumos-x86_64/usr/include/aio.h @@ -0,0 +1,143 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _AIO_H +#define _AIO_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if (_POSIX_C_SOURCE - 0 > 0) && (_POSIX_C_SOURCE - 0 <= 2) +#error "POSIX Asynchronous I/O is not supported in POSIX.1-1990" +#endif + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname aio_read aio_read64 +#pragma redefine_extname aio_write aio_write64 +#pragma redefine_extname lio_listio lio_listio64 +#pragma redefine_extname aio_error aio_error64 +#pragma redefine_extname aio_return aio_return64 +#pragma redefine_extname aio_cancel aio_cancel64 +#pragma redefine_extname aio_suspend aio_suspend64 +#pragma redefine_extname aio_fsync aio_fsync64 +#pragma redefine_extname aio_waitn aio_waitn64 +#else +#define aiocb aiocb64 +#define aiocb_t aiocb64_t +#define aio_read aio_read64 +#define aio_write aio_write64 +#define lio_listio lio_listio64 +#define aio_error aio_error64 +#define aio_return aio_return64 +#define aio_cancel aio_cancel64 +#define aio_suspend aio_suspend64 +#define aio_fsync aio_fsync64 +#define aio_waitn aio_waitn64 +#endif +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +/* + * In the LP64 compilation environment, map the 64-bit-explicit versions + * back to the generic versions: all i/o operations are already "large file" + */ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname aio_read64 aio_read +#pragma redefine_extname aio_write64 aio_write +#pragma redefine_extname lio_listio64 lio_listio +#pragma redefine_extname aio_error64 aio_error +#pragma redefine_extname aio_return64 aio_return +#pragma redefine_extname aio_cancel64 aio_cancel +#pragma redefine_extname aio_suspend64 aio_suspend +#pragma redefine_extname aio_fsync64 aio_fsync +#pragma redefine_extname aio_waitn64 aio_waitn +#else +#define aiocb64 aiocb +#define aiocb64_t aiocb_t +#define aio_read64 aio_read +#define aio_write64 aio_write +#define lio_listio64 lio_listio +#define aio_error64 aio_error +#define aio_return64 aio_return +#define aio_cancel64 aio_cancel +#define aio_suspend64 aio_suspend +#define aio_fsync64 aio_fsync +#define aio_waitn64 aio_waitn +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +/* + * function prototypes + */ +extern int aio_read(aiocb_t *); +extern int aio_write(aiocb_t *); +extern int lio_listio(int, + aiocb_t *_RESTRICT_KYWD const *_RESTRICT_KYWD, + int, struct sigevent *_RESTRICT_KYWD); +extern int aio_error(const aiocb_t *); +extern ssize_t aio_return(aiocb_t *); +extern int aio_cancel(int, aiocb_t *); +extern int aio_suspend(const aiocb_t *const[], int, + const struct timespec *); +extern int aio_fsync(int, aiocb_t *); +extern int aio_waitn(aiocb_t *[], uint_t, uint_t *, + const struct timespec *); + + +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int aio_read64(aiocb64_t *); +extern int aio_write64(aiocb64_t *); +extern int lio_listio64(int, + aiocb64_t *_RESTRICT_KYWD const *_RESTRICT_KYWD, + int, struct sigevent *_RESTRICT_KYWD); +extern int aio_error64(const aiocb64_t *); +extern ssize_t aio_return64(aiocb64_t *); +extern int aio_cancel64(int, aiocb64_t *); +extern int aio_suspend64(const aiocb64_t *const[], int, + const struct timespec *); +extern int aio_fsync64(int, aiocb64_t *); +extern int aio_waitn64(aiocb64_t *[], uint_t, uint_t *, + const struct timespec *); +#endif /* _LARGEFILE64_SOURCE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _AIO_H */ diff --git a/illumos-x86_64/usr/include/alloca.h b/illumos-x86_64/usr/include/alloca.h new file mode 100644 index 00000000..23e890d8 --- /dev/null +++ b/illumos-x86_64/usr/include/alloca.h @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ALLOCA_H +#define _ALLOCA_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Many compilation systems depend upon the use of special functions + * built into the the compilation system to handle variable argument + * lists and stack allocations. The method to obtain this in SunOS + * is to define the feature test macro "__BUILTIN_VA_ARG_INCR" which + * enables the following special built-in functions: + * __builtin_alloca + * __builtin_va_alist + * __builtin_va_arg_incr + * It is intended that the compilation system define this feature test + * macro, not the user of the system. + * + * The tests on the processor type are to provide a transitional period + * for existing compilation systems, and may be removed in a future + * release. + */ + +#if defined(__BUILTIN_VA_ARG_INCR) || \ + defined(__sparc) || defined(__i386) || defined(__amd64) +#define alloca(x) __builtin_alloca(x) + +extern void *__builtin_alloca(size_t); + +#else + +extern void *alloca(size_t); + +#endif /* defined(__BUILTIN_VA_ARG_INCR) || defined(__sparc) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ALLOCA_H */ diff --git a/illumos-x86_64/usr/include/amd64/sys/kdi_regs.h b/illumos-x86_64/usr/include/amd64/sys/kdi_regs.h new file mode 100644 index 00000000..80cfbd51 --- /dev/null +++ b/illumos-x86_64/usr/include/amd64/sys/kdi_regs.h @@ -0,0 +1,133 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _AMD64_SYS_KDI_REGS_H +#define _AMD64_SYS_KDI_REGS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A modified version of struct regs layout. + */ + +#define KDIREG_SAVFP 0 +#define KDIREG_SAVPC 1 +#define KDIREG_RDI 2 +#define KDIREG_RSI 3 +#define KDIREG_RDX 4 +#define KDIREG_RCX 5 +#define KDIREG_R8 6 +#define KDIREG_R9 7 +#define KDIREG_RAX 8 +#define KDIREG_RBX 9 +#define KDIREG_RBP 10 +#define KDIREG_R10 11 +#define KDIREG_R11 12 +#define KDIREG_R12 13 +#define KDIREG_R13 14 +#define KDIREG_R14 15 +#define KDIREG_R15 16 +#define KDIREG_FSBASE 17 +#define KDIREG_GSBASE 18 +#define KDIREG_KGSBASE 19 +#define KDIREG_CR2 20 +#define KDIREG_CR3 21 +#define KDIREG_DS 22 +#define KDIREG_ES 23 +#define KDIREG_FS 24 +#define KDIREG_GS 25 +#define KDIREG_TRAPNO 26 +#define KDIREG_ERR 27 +#define KDIREG_RIP 28 +#define KDIREG_CS 29 +#define KDIREG_RFLAGS 30 +#define KDIREG_RSP 31 +#define KDIREG_SS 32 + +#define KDIREG_NGREG (KDIREG_SS + 1) + +#define KDIREG_PC KDIREG_RIP +#define KDIREG_SP KDIREG_RSP +#define KDIREG_FP KDIREG_RBP + +#if !defined(_ASM) + +/* + * Handy for debugging krs_gregs; keep in sync with the KDIREG_* above. + */ +typedef struct { + greg_t kr_savfp; + greg_t kr_savpc; + greg_t kr_rdi; + greg_t kr_rsi; + greg_t kr_rdx; + greg_t kr_rcx; + greg_t kr_r8; + greg_t kr_r9; + greg_t kr_rax; + greg_t kr_rbx; + greg_t kr_rbp; + greg_t r_r10; + greg_t r_r11; + greg_t r_r12; + greg_t r_r13; + greg_t r_r14; + greg_t r_r15; + greg_t kr_fsbase; + greg_t kr_gsbase; + greg_t kr_kgsbase; + greg_t kr_cr2; + greg_t kr_cr3; + greg_t kr_ds; + greg_t kr_es; + greg_t kr_fs; + greg_t kr_gs; + greg_t kr_trapno; + greg_t kr_err; + greg_t kr_rip; + greg_t kr_cs; + greg_t kr_rflags; + greg_t kr_rsp; + greg_t kr_ss; +} kdiregs_t; + +#if defined(_KERNEL) +CTASSERT(offsetof(kdiregs_t, kr_ss) == ((KDIREG_NGREG - 1) * sizeof (greg_t))); +#endif + +#endif /* !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _AMD64_SYS_KDI_REGS_H */ diff --git a/illumos-x86_64/usr/include/amd64/sys/privmregs.h b/illumos-x86_64/usr/include/amd64/sys/privmregs.h new file mode 100644 index 00000000..a3c00add --- /dev/null +++ b/illumos-x86_64/usr/include/amd64/sys/privmregs.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _AMD64_SYS_PRIVMREGS_H +#define _AMD64_SYS_PRIVMREGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__amd64) +#error "non-amd64 code depends on amd64 privileged header!" +#endif + +#ifndef _ASM + +#define PM_GREGS (1 << 0) +#define PM_CRREGS (1 << 1) +#define PM_DRREGS (1 << 2) + +/* + * This structure is intended to represent a complete machine state for a CPU, + * when that information is available. It is only for use internally between + * KMDB and the kernel, or within MDB. Note that this isn't yet finished. + */ +typedef struct privmregs { + ulong_t pm_flags; + /* general registers */ + struct regs pm_gregs; + /* cr0-8 */ + ulong_t pm_cr[8]; + /* dr0-8 */ + ulong_t pm_dr[8]; +} privmregs_t; + +#endif /* !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_AMD64_SYS_PRIVMREGS_H */ diff --git a/illumos-x86_64/usr/include/amd64/sys/privregs.h b/illumos-x86_64/usr/include/amd64/sys/privregs.h new file mode 100644 index 00000000..7e5f7cd3 --- /dev/null +++ b/illumos-x86_64/usr/include/amd64/sys/privregs.h @@ -0,0 +1,340 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _AMD64_SYS_PRIVREGS_H +#define _AMD64_SYS_PRIVREGS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file describes the cpu's privileged register set, and + * how the machine state is saved on the stack when a trap occurs. + */ + +#if !defined(__amd64) +#error "non-amd64 code depends on amd64 privileged header!" +#endif + +#ifndef _ASM + +/* + * This is NOT the structure to use for general purpose debugging; + * see /proc for that. This is NOT the structure to use to decode + * the ucontext or grovel about in a core file; see . + */ + +struct regs { + /* + * Extra frame for mdb to follow through high level interrupts and + * system traps. Set them to 0 to terminate stacktrace. + */ + greg_t r_savfp; /* a copy of %rbp */ + greg_t r_savpc; /* a copy of %rip */ + + greg_t r_rdi; /* 1st arg to function */ + greg_t r_rsi; /* 2nd arg to function */ + greg_t r_rdx; /* 3rd arg to function, 2nd return register */ + greg_t r_rcx; /* 4th arg to function */ + + greg_t r_r8; /* 5th arg to function */ + greg_t r_r9; /* 6th arg to function */ + greg_t r_rax; /* 1st return register, # SSE registers */ + greg_t r_rbx; /* callee-saved, optional base pointer */ + + greg_t r_rbp; /* callee-saved, optional frame pointer */ + greg_t r_r10; /* temporary register, static chain pointer */ + greg_t r_r11; /* temporary register */ + greg_t r_r12; /* callee-saved */ + + greg_t r_r13; /* callee-saved */ + greg_t r_r14; /* callee-saved */ + greg_t r_r15; /* callee-saved */ + + /* + * fsbase and gsbase are sampled on every exception in DEBUG kernels + * only. They remain in the non-DEBUG kernel to avoid any flag days. + */ + greg_t __r_fsbase; /* no longer used in non-DEBUG builds */ + greg_t __r_gsbase; /* no longer used in non-DEBUG builds */ + greg_t r_ds; + greg_t r_es; + greg_t r_fs; /* %fs is *never* used by the kernel */ + greg_t r_gs; + + greg_t r_trapno; + + /* + * (the rest of these are defined by the hardware) + */ + greg_t r_err; + greg_t r_rip; + greg_t r_cs; + greg_t r_rfl; + greg_t r_rsp; + greg_t r_ss; +}; + +#define r_r0 r_rax /* r0 for portability */ +#define r_r1 r_rdx /* r1 for portability */ +#define r_fp r_rbp /* kernel frame pointer */ +#define r_sp r_rsp /* user stack pointer */ +#define r_pc r_rip /* user's instruction pointer */ +#define r_ps r_rfl /* user's RFLAGS */ + +#ifdef _KERNEL +#define lwptoregs(lwp) ((struct regs *)((lwp)->lwp_regs)) +#endif /* _KERNEL */ + +#else /* !_ASM */ + +#if defined(_MACHDEP) + +#include +#include + +/* + * We can not safely sample {fs,gs}base on the hypervisor. The rdmsr + * instruction triggers a #gp fault which is emulated in the hypervisor + * on behalf of the guest. This is normally ok but if the guest is in + * the special failsafe handler it must not fault again or the hypervisor + * will kill the domain. We could use something different than INTR_PUSH + * in xen_failsafe_callback but for now we will not sample them. + */ +#if defined(DEBUG) && !defined(__xpv) +#define __SAVE_BASES \ + movl $MSR_AMD_FSBASE, %ecx; \ + rdmsr; \ + movl %eax, REGOFF_FSBASE(%rsp); \ + movl %edx, REGOFF_FSBASE+4(%rsp); \ + movl $MSR_AMD_GSBASE, %ecx; \ + rdmsr; \ + movl %eax, REGOFF_GSBASE(%rsp); \ + movl %edx, REGOFF_GSBASE+4(%rsp) +#else +#define __SAVE_BASES +#endif + +/* + * Create a struct regs on the stack suitable for an + * interrupt trap. + * + * Assumes that the trap handler has already pushed an + * appropriate r_err and r_trapno + */ +#define __SAVE_REGS \ + movq %r15, REGOFF_R15(%rsp); \ + movq %r14, REGOFF_R14(%rsp); \ + movq %r13, REGOFF_R13(%rsp); \ + movq %r12, REGOFF_R12(%rsp); \ + movq %r11, REGOFF_R11(%rsp); \ + movq %r10, REGOFF_R10(%rsp); \ + movq %rbp, REGOFF_RBP(%rsp); \ + movq %rbx, REGOFF_RBX(%rsp); \ + movq %rax, REGOFF_RAX(%rsp); \ + movq %r9, REGOFF_R9(%rsp); \ + movq %r8, REGOFF_R8(%rsp); \ + movq %rcx, REGOFF_RCX(%rsp); \ + movq %rdx, REGOFF_RDX(%rsp); \ + movq %rsi, REGOFF_RSI(%rsp); \ + movq %rdi, REGOFF_RDI(%rsp); \ + movq %rbp, REGOFF_SAVFP(%rsp); \ + movq REGOFF_RIP(%rsp), %rcx; \ + movq %rcx, REGOFF_SAVPC(%rsp); \ + xorl %ecx, %ecx; \ + movw %gs, %cx; \ + movq %rcx, REGOFF_GS(%rsp); \ + movw %fs, %cx; \ + movq %rcx, REGOFF_FS(%rsp); \ + movw %es, %cx; \ + movq %rcx, REGOFF_ES(%rsp); \ + movw %ds, %cx; \ + movq %rcx, REGOFF_DS(%rsp); \ + __SAVE_BASES + +#define __RESTORE_REGS \ + movq REGOFF_RDI(%rsp), %rdi; \ + movq REGOFF_RSI(%rsp), %rsi; \ + movq REGOFF_RDX(%rsp), %rdx; \ + movq REGOFF_RCX(%rsp), %rcx; \ + movq REGOFF_R8(%rsp), %r8; \ + movq REGOFF_R9(%rsp), %r9; \ + movq REGOFF_RAX(%rsp), %rax; \ + movq REGOFF_RBX(%rsp), %rbx; \ + movq REGOFF_RBP(%rsp), %rbp; \ + movq REGOFF_R10(%rsp), %r10; \ + movq REGOFF_R11(%rsp), %r11; \ + movq REGOFF_R12(%rsp), %r12; \ + movq REGOFF_R13(%rsp), %r13; \ + movq REGOFF_R14(%rsp), %r14; \ + movq REGOFF_R15(%rsp), %r15 + +/* + * Push register state onto the stack. If we've + * interrupted userland, do a swapgs as well. + */ +#define INTR_PUSH \ + subq $REGOFF_TRAPNO, %rsp; \ + __SAVE_REGS; \ + cmpw $KCS_SEL, REGOFF_CS(%rsp); \ + je 6f; \ + movq $0, REGOFF_SAVFP(%rsp); \ + SWAPGS; \ +6: lfence; /* swapgs mitigation */ \ + CLEAN_CS + +#define INTR_POP \ + leaq sys_lcall32(%rip), %r11;\ + cmpq %r11, REGOFF_RIP(%rsp); \ + __RESTORE_REGS; \ + je 5f; \ + cmpw $KCS_SEL, REGOFF_CS(%rsp);\ + je 8f; \ +5: SWAPGS; \ +8: lfence; /* swapgs mitigation */ \ + addq $REGOFF_RIP, %rsp + +/* + * No need for swapgs mitigation: it's unconditional, and we're heading + * back to userspace. + */ +#define USER_POP \ + __RESTORE_REGS; \ + SWAPGS; \ + addq $REGOFF_RIP, %rsp /* Adjust %rsp to prepare for iretq */ + +#define USER32_POP \ + movl REGOFF_RDI(%rsp), %edi; \ + movl REGOFF_RSI(%rsp), %esi; \ + movl REGOFF_RDX(%rsp), %edx; \ + movl REGOFF_RCX(%rsp), %ecx; \ + movl REGOFF_RAX(%rsp), %eax; \ + movl REGOFF_RBX(%rsp), %ebx; \ + movl REGOFF_RBP(%rsp), %ebp; \ + SWAPGS; \ + addq $REGOFF_RIP, %rsp /* Adjust %rsp to prepare for iretq */ + +#define DFTRAP_PUSH \ + subq $REGOFF_TRAPNO, %rsp; \ + __SAVE_REGS + +#endif /* _MACHDEP */ + +/* + * Used to set rflags to known values at the head of an + * interrupt gate handler, i.e. interrupts are -already- disabled. + */ +#define INTGATE_INIT_KERNEL_FLAGS \ + pushq $F_OFF; \ + popfq + +#endif /* !_ASM */ + +#include + +#if defined(_KERNEL) && !defined(_ASM) +#if !defined(__lint) && defined(__GNUC__) + +extern __GNU_INLINE ulong_t +getcr8(void) +{ + uint64_t value; + + __asm__ __volatile__( + "movq %%cr8, %0" + : "=r" (value)); + return (value); +} + +extern __GNU_INLINE void +setcr8(ulong_t value) +{ + __asm__ __volatile__( + "movq %0, %%cr8" + : /* no output */ + : "r" (value)); +} + +#else + +extern ulong_t getcr8(void); +extern void setcr8(ulong_t); + +#endif /* !defined(__lint) && defined(__GNUC__) */ +#endif /* _KERNEL && !_ASM */ + +/* Control register layout for panic dump */ + +#define CREGSZ 0x68 +#define CREG_GDT 0 +#define CREG_IDT 0x10 +#define CREG_LDT 0x20 +#define CREG_TASKR 0x28 +#define CREG_CR0 0x30 +#define CREG_CR2 0x38 +#define CREG_CR3 0x40 +#define CREG_CR4 0x48 +#define CREG_CR8 0x50 +#define CREG_KGSBASE 0x58 +#define CREG_EFER 0x60 + +#if !defined(_ASM) && defined(_INT64_TYPE) + +typedef uint64_t creg64_t; +typedef upad128_t creg128_t; + +struct cregs { + creg128_t cr_gdt; + creg128_t cr_idt; + creg64_t cr_ldt; + creg64_t cr_task; + creg64_t cr_cr0; + creg64_t cr_cr2; + creg64_t cr_cr3; + creg64_t cr_cr4; + creg64_t cr_cr8; + creg64_t cr_kgsbase; + creg64_t cr_efer; +}; + +#if defined(_KERNEL) +extern void getcregs(struct cregs *); +#endif /* _KERNEL */ + +#endif /* !_ASM && _INT64_TYPE */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_AMD64_SYS_PRIVREGS_H */ diff --git a/illumos-x86_64/usr/include/ansidecl.h b/illumos-x86_64/usr/include/ansidecl.h new file mode 100644 index 00000000..645bce56 --- /dev/null +++ b/illumos-x86_64/usr/include/ansidecl.h @@ -0,0 +1,354 @@ +/* Compiler compatibility macros + Copyright (C) 1991-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* For ease of writing code which uses GCC extensions but needs to be + portable to other compilers, we provide the GCC_VERSION macro that + simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various + wrappers around __attribute__. Also, __extension__ will be #defined + to nothing if it doesn't work. See below. */ + +#ifndef _ANSIDECL_H +#define _ANSIDECL_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Every source file includes this file, + so they will all get the switch for lint. */ +/* LINTLIBRARY */ + +/* Using MACRO(x,y) in cpp #if conditionals does not work with some + older preprocessors. Thus we can't define something like this: + +#define HAVE_GCC_VERSION(MAJOR, MINOR) \ + (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR))) + +and then test "#if HAVE_GCC_VERSION(2,7)". + +So instead we use the macro below and test it against specific values. */ + +/* This macro simplifies testing whether we are using gcc, and if it + is of a particular minimum version. (Both major & minor numbers are + significant.) This macro will evaluate to 0 if we are not using + gcc at all. */ +#ifndef GCC_VERSION +#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +#endif /* GCC_VERSION */ + +/* inline requires special treatment; it's in C99, and GCC >=2.7 supports + it too, but it's not in C89. */ +#undef inline +#if (!defined(__cplusplus) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +/* it's a keyword */ +#else +# if GCC_VERSION >= 2007 +# define inline __inline__ /* __inline__ prevents -pedantic warnings */ +# else +# define inline /* nothing */ +# endif +#endif + +/* Define macros for some gcc attributes. This permits us to use the + macros freely, and know that they will come into play for the + version of gcc in which they are supported. */ + +#if (GCC_VERSION < 2007) +# define __attribute__(x) +#endif + +/* Attribute __malloc__ on functions was valid as of gcc 2.96. */ +#ifndef ATTRIBUTE_MALLOC +# if (GCC_VERSION >= 2096) +# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define ATTRIBUTE_MALLOC +# endif /* GNUC >= 2.96 */ +#endif /* ATTRIBUTE_MALLOC */ + +/* Attributes on labels were valid as of gcc 2.93 and g++ 4.5. For + g++ an attribute on a label must be followed by a semicolon. */ +#ifndef ATTRIBUTE_UNUSED_LABEL +# ifndef __cplusplus +# if GCC_VERSION >= 2093 +# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED +# else +# define ATTRIBUTE_UNUSED_LABEL +# endif +# else +# if GCC_VERSION >= 4005 +# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ; +# else +# define ATTRIBUTE_UNUSED_LABEL +# endif +# endif +#endif + +/* Similarly to ARG_UNUSED below. Prior to GCC 3.4, the C++ frontend + couldn't parse attributes placed after the identifier name, and now + the entire compiler is built with C++. */ +#ifndef ATTRIBUTE_UNUSED +#if GCC_VERSION >= 3004 +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#else +#define ATTRIBUTE_UNUSED +#endif +#endif /* ATTRIBUTE_UNUSED */ + +/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the + identifier name. */ +#if ! defined(__cplusplus) || (GCC_VERSION >= 3004) +# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED +#else /* !__cplusplus || GNUC >= 3.4 */ +# define ARG_UNUSED(NAME) NAME +#endif /* !__cplusplus || GNUC >= 3.4 */ + +#ifndef ATTRIBUTE_NORETURN +#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#endif /* ATTRIBUTE_NORETURN */ + +/* Attribute `nonnull' was valid as of gcc 3.3. */ +#ifndef ATTRIBUTE_NONNULL +# if (GCC_VERSION >= 3003) +# define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m))) +# else +# define ATTRIBUTE_NONNULL(m) +# endif /* GNUC >= 3.3 */ +#endif /* ATTRIBUTE_NONNULL */ + +/* Attribute `returns_nonnull' was valid as of gcc 4.9. */ +#ifndef ATTRIBUTE_RETURNS_NONNULL +# if (GCC_VERSION >= 4009) +# define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) +# else +# define ATTRIBUTE_RETURNS_NONNULL +# endif /* GNUC >= 4.9 */ +#endif /* ATTRIBUTE_RETURNS_NONNULL */ + +/* Attribute `pure' was valid as of gcc 3.0. */ +#ifndef ATTRIBUTE_PURE +# if (GCC_VERSION >= 3000) +# define ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define ATTRIBUTE_PURE +# endif /* GNUC >= 3.0 */ +#endif /* ATTRIBUTE_PURE */ + +/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL. + This was the case for the `printf' format attribute by itself + before GCC 3.3, but as of 3.3 we need to add the `nonnull' + attribute to retain this behavior. */ +#ifndef ATTRIBUTE_PRINTF +#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m) +#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2) +#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3) +#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4) +#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5) +#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6) +#endif /* ATTRIBUTE_PRINTF */ + +/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on + a function pointer. Format attributes were allowed on function + pointers as of gcc 3.1. */ +#ifndef ATTRIBUTE_FPTR_PRINTF +# if (GCC_VERSION >= 3001) +# define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n) +# else +# define ATTRIBUTE_FPTR_PRINTF(m, n) +# endif /* GNUC >= 3.1 */ +# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2) +# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3) +# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4) +# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5) +# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6) +#endif /* ATTRIBUTE_FPTR_PRINTF */ + +/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL. A + NULL format specifier was allowed as of gcc 3.3. */ +#ifndef ATTRIBUTE_NULL_PRINTF +# if (GCC_VERSION >= 3003) +# define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) +# else +# define ATTRIBUTE_NULL_PRINTF(m, n) +# endif /* GNUC >= 3.3 */ +# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2) +# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3) +# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4) +# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5) +# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6) +#endif /* ATTRIBUTE_NULL_PRINTF */ + +/* Attribute `sentinel' was valid as of gcc 3.5. */ +#ifndef ATTRIBUTE_SENTINEL +# if (GCC_VERSION >= 3005) +# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) +# else +# define ATTRIBUTE_SENTINEL +# endif /* GNUC >= 3.5 */ +#endif /* ATTRIBUTE_SENTINEL */ + + +#ifndef ATTRIBUTE_ALIGNED_ALIGNOF +# if (GCC_VERSION >= 3000) +# define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m)))) +# else +# define ATTRIBUTE_ALIGNED_ALIGNOF(m) +# endif /* GNUC >= 3.0 */ +#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */ + +/* Useful for structures whose layout must match some binary specification + regardless of the alignment and padding qualities of the compiler. */ +#ifndef ATTRIBUTE_PACKED +# define ATTRIBUTE_PACKED __attribute__ ((packed)) +#endif + +/* Attribute `hot' and `cold' was valid as of gcc 4.3. */ +#ifndef ATTRIBUTE_COLD +# if (GCC_VERSION >= 4003) +# define ATTRIBUTE_COLD __attribute__ ((__cold__)) +# else +# define ATTRIBUTE_COLD +# endif /* GNUC >= 4.3 */ +#endif /* ATTRIBUTE_COLD */ +#ifndef ATTRIBUTE_HOT +# if (GCC_VERSION >= 4003) +# define ATTRIBUTE_HOT __attribute__ ((__hot__)) +# else +# define ATTRIBUTE_HOT +# endif /* GNUC >= 4.3 */ +#endif /* ATTRIBUTE_HOT */ + +/* Attribute 'no_sanitize_undefined' was valid as of gcc 4.9. */ +#ifndef ATTRIBUTE_NO_SANITIZE_UNDEFINED +# if (GCC_VERSION >= 4009) +# define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined)) +# else +# define ATTRIBUTE_NO_SANITIZE_UNDEFINED +# endif /* GNUC >= 4.9 */ +#endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */ + +/* Attribute 'nonstring' was valid as of gcc 8. */ +#ifndef ATTRIBUTE_NONSTRING +# if GCC_VERSION >= 8000 +# define ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) +# else +# define ATTRIBUTE_NONSTRING +# endif +#endif + +/* Attribute `alloc_size' was valid as of gcc 4.3. */ +#ifndef ATTRIBUTE_RESULT_SIZE_1 +# if (GCC_VERSION >= 4003) +# define ATTRIBUTE_RESULT_SIZE_1 __attribute__ ((alloc_size (1))) +# else +# define ATTRIBUTE_RESULT_SIZE_1 +#endif +#endif + +#ifndef ATTRIBUTE_RESULT_SIZE_2 +# if (GCC_VERSION >= 4003) +# define ATTRIBUTE_RESULT_SIZE_2 __attribute__ ((alloc_size (2))) +# else +# define ATTRIBUTE_RESULT_SIZE_2 +#endif +#endif + +#ifndef ATTRIBUTE_RESULT_SIZE_1_2 +# if (GCC_VERSION >= 4003) +# define ATTRIBUTE_RESULT_SIZE_1_2 __attribute__ ((alloc_size (1, 2))) +# else +# define ATTRIBUTE_RESULT_SIZE_1_2 +#endif +#endif + +/* Attribute `warn_unused_result' was valid as of gcc 3.3. */ +#ifndef ATTRIBUTE_WARN_UNUSED_RESULT +# if GCC_VERSION >= 3003 +# define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) +# else +# define ATTRIBUTE_WARN_UNUSED_RESULT +# endif +#endif + +/* We use __extension__ in some places to suppress -pedantic warnings + about GCC extensions. This feature didn't work properly before + gcc 2.8. */ +#if GCC_VERSION < 2008 +#define __extension__ +#endif + +/* This is used to declare a const variable which should be visible + outside of the current compilation unit. Use it as + EXPORTED_CONST int i = 1; + This is because the semantics of const are different in C and C++. + "extern const" is permitted in C but it looks strange, and gcc + warns about it when -Wc++-compat is not used. */ +#ifdef __cplusplus +#define EXPORTED_CONST extern const +#else +#define EXPORTED_CONST const +#endif + +/* Be conservative and only use enum bitfields with C++ or GCC. + FIXME: provide a complete autoconf test for buggy enum bitfields. */ + +#ifdef __cplusplus +#define ENUM_BITFIELD(TYPE) enum TYPE +#elif (GCC_VERSION > 2000) +#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE +#else +#define ENUM_BITFIELD(TYPE) unsigned int +#endif + +#if defined(__cplusplus) && __cpp_constexpr >= 200704 +#define CONSTEXPR constexpr +#else +#define CONSTEXPR +#endif + +/* A macro to disable the copy constructor and assignment operator. + When building with C++11 and above, the methods are explicitly + deleted, causing a compile-time error if something tries to copy. + For C++03, this just declares the methods, causing a link-time + error if the methods end up called (assuming you don't + define them). For C++03, for best results, place the macro + under the private: access specifier, like this, + + class name_lookup + { + private: + DISABLE_COPY_AND_ASSIGN (name_lookup); + }; + + so that most attempts at copy are caught at compile-time. */ + +#if defined(__cplusplus) && __cplusplus >= 201103 +#define DISABLE_COPY_AND_ASSIGN(TYPE) \ + TYPE (const TYPE&) = delete; \ + void operator= (const TYPE &) = delete + #else +#define DISABLE_COPY_AND_ASSIGN(TYPE) \ + TYPE (const TYPE&); \ + void operator= (const TYPE &) +#endif /* __cplusplus >= 201103 */ + +#ifdef __cplusplus +} +#endif + +#endif /* ansidecl.h */ diff --git a/illumos-x86_64/usr/include/apptrace.h b/illumos-x86_64/usr/include/apptrace.h new file mode 100644 index 00000000..19b3fda4 --- /dev/null +++ b/illumos-x86_64/usr/include/apptrace.h @@ -0,0 +1,120 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998-2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _APPTRACE_H +#define _APPTRACE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Extract the verbosity flag. + */ +#define ABI_VFLAG(lib, symbol) \ + __abi_ ## lib ## _ ## symbol ## _sym.a_vflag + +/* + * Extract the function pointer to the real ABI function. + */ +#define ABI_REAL(lib, symbol) \ + __abi_ ## lib ## _ ## symbol ## _sym.a_real + +/* + * Macro to create the part of a function call prior + * to the arg list. + * cast is a full cast expression for a _pointer_ to + * the ABI function being called. + * + * e.g. ABI_CALL_REAL(libc, getpid, (pid_t (*)(void))) (); + */ +#define ABI_CALL_REAL(lib, sym, cast) \ + (cast __abi_ ## lib ## _ ## sym ## _sym.a_real) + +#define ABISTREAM __abi_outfile +#define ABIPUTS(x) (void) fputs((x), ABISTREAM) + +/* + * The following declarations and macros are needed for + * anybody needing the vprintf family of calls where they + * MUST come from the BASE link map instead of the auditing + * link map. + */ +#define ABI_VSNPRINTF __abi_real_vsnprintf +#define ABI_VSWPRINTF __abi_real_vswprintf +#define ABI_VWPRINTF __abi_real_vwprintf +#define ABI_VFPRINTF __abi_real_vfprintf +#define ABI_VFWPRINTF __abi_real_vfwprintf +#define ABI_VPRINTF __abi_real_vprintf +#define ABI_VSPRINTF __abi_real_vsprintf +#define ABI_ERRNO (*(__abi_real_errno())) + +/* From libstabspf */ +typedef enum { + STAB_SUCCESS = 0, /* All is well. */ + STAB_FAIL = -1, /* Parsing error. */ + STAB_NA = -2, /* Information is Not Applicable. */ + STAB_NOMEM = -3 /* Out of Memory! */ +} stabsret_t; + +extern int (*ABI_VFPRINTF)(FILE *, const char *, va_list); +extern int (*ABI_VFWPRINTF)(FILE *, const wchar_t *, va_list); +extern int (*ABI_VPRINTF)(const char *, va_list); +extern int (*ABI_VSNPRINTF)(char *, size_t, const char *, va_list); +extern int (*ABI_VSPRINTF)(char *, const char *, va_list); +extern int (*ABI_VSWPRINTF)(wchar_t *, size_t, const wchar_t *, va_list); +extern int (*ABI_VWPRINTF)(const wchar_t *, va_list); +extern int *(*__abi_real_errno)(void); + +extern void *abi_malloc(size_t); +extern void *abi_calloc(size_t, size_t); +extern void *abi_realloc(void *, size_t); +extern int abi_putc(int, FILE *); +extern int abi_fputs(const char *, FILE *); +extern void abi_free(void *); + +/* From libstabspf */ +extern stabsret_t spf_load_stabs(const char *); +extern int spf_prtype(FILE *, char const *, int, void const *); + +extern int abi_strpsz; /* size constraint for string printing */ + +#ifdef __cplusplus +} +#endif + +#endif /* _APPTRACE_H */ diff --git a/illumos-x86_64/usr/include/apptrace_impl.h b/illumos-x86_64/usr/include/apptrace_impl.h new file mode 100644 index 00000000..e39c71b9 --- /dev/null +++ b/illumos-x86_64/usr/include/apptrace_impl.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _APPTRACE_IMPL_H +#define _APPTRACE_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct abisym { + void *a_real; + int a_vflag; + int a_tflag; +} abisym_t; + +/* + * From the apptrace auditing object + */ +extern FILE *__abi_outfile; +extern struct liblist *__abi_pflib_list; + +extern sigset_t abisigset; + +extern void abilock(sigset_t *); +extern void abiunlock(sigset_t *); + +extern int is_empty_string(char const *); + +extern int (*abi_thr_main)(void); +extern thread_t (*abi_thr_self)(void); +extern int (*abi_sigsetmask)(int, const sigset_t *, sigset_t *); +extern int (*abi_sigaction)(int, const struct sigaction *, struct sigaction *); +extern int (*abi_mutex_lock)(mutex_t *); +extern int (*abi_mutex_unlock)(mutex_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _APPTRACE_IMPL_H */ diff --git a/illumos-x86_64/usr/include/ar.h b/illumos-x86_64/usr/include/ar.h new file mode 100644 index 00000000..67d4f864 --- /dev/null +++ b/illumos-x86_64/usr/include/ar.h @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _AR_H +#define _AR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * COMMON ARCHIVE FORMAT + * + * ARCHIVE File Organization: + * _________________________________________________ + * |__________ARCHIVE_MAGIC_STRING_________________| + * |__________ARCHIVE_FILE_MEMBER_1________________| + * | | + * | Archive File Header "ar_hdr" | + * |...............................................| + * | Member Contents | + * | 1. External symbol directory | + * | 2. Text file | + * |_______________________________________________| + * |________ARCHIVE_FILE_MEMBER_2__________________| + * | "ar_hdr" | + * |...............................................| + * | Member Contents (.o or text file) | + * |_______________________________________________| + * | . . . | + * | . . . | + * | . . . | + * |_______________________________________________| + * |________ARCHIVE_FILE_MEMBER_n__________________| + * | "ar_hdr" | + * |...............................................| + * | Member Contents | + * |_______________________________________________| + * + */ + +#define ARMAG "!\n" +#define SARMAG 8 +#define ARFMAG "`\n" + +struct ar_hdr /* archive file member header - printable ascii */ +{ + char ar_name[16]; /* file member name - `/' terminated */ + char ar_date[12]; /* file member date - decimal */ + char ar_uid[6]; /* file member user id - decimal */ + char ar_gid[6]; /* file member group id - decimal */ + char ar_mode[8]; /* file member mode - octal */ + char ar_size[10]; /* file member size - decimal */ + char ar_fmag[2]; /* ARFMAG - string to end header */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _AR_H */ diff --git a/illumos-x86_64/usr/include/archives.h b/illumos-x86_64/usr/include/archives.h new file mode 100644 index 00000000..89555f97 --- /dev/null +++ b/illumos-x86_64/usr/include/archives.h @@ -0,0 +1,285 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1988,1997-1998,2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _ARCHIVES_H +#define _ARCHIVES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Magic numbers */ + +#define CMN_ASC 0x070701 /* Cpio Magic Number for ASCii header */ +#define CMN_BIN 070707 /* Cpio Magic Number for Binary header */ +#define CMN_BBS 0143561 /* Cpio Magic Number for Byte-Swap header */ +#define CMN_CRC 0x070702 /* Cpio Magic Number for CRC header */ +#define CMS_ASC "070701" /* Cpio Magic String for ASCii header */ +#define CMS_CHR "070707" /* Cpio Magic String for CHR (-c) header */ +#define CMS_CRC "070702" /* Cpio Magic String for CRC header */ +#define CMS_LEN 6 /* Cpio Magic String LENgth */ + +/* Various header and field lengths */ + +#define CHRSZ 76 /* -c hdr size minus filename field */ +#define ASCSZ 110 /* ASC and CRC hdr size minus filename field */ +#define TARSZ 512 /* TAR hdr size */ + +#define HNAMLEN 256 /* maximum filename length for binary and -c headers */ +#define EXPNLEN 1024 /* maximum filename length for ASC and CRC headers */ +#define HTIMLEN 2 /* length of modification time field */ +#define HSIZLEN 2 /* length of file size field */ + +/* cpio binary header definition */ + +struct hdr_cpio { + short h_magic, /* magic number field */ + h_dev; /* file system of file */ + ushort_t h_ino, /* inode of file */ + h_mode, /* modes of file */ + h_uid, /* uid of file */ + h_gid; /* gid of file */ + short h_nlink, /* number of links to file */ + h_rdev, /* maj/min numbers for special files */ + h_mtime[HTIMLEN], /* modification time of file */ + h_namesize, /* length of filename */ + h_filesize[HSIZLEN]; /* size of file */ + char h_name[HNAMLEN]; /* filename */ +}; + +/* cpio ODC header format */ + +struct c_hdr { + char c_magic[CMS_LEN], + c_dev[6], + c_ino[6], + c_mode[6], + c_uid[6], + c_gid[6], + c_nlink[6], + c_rdev[6], + c_mtime[11], + c_namesz[6], + c_filesz[11], + c_name[HNAMLEN]; +}; + +/* -c and CRC header format */ + +struct Exp_cpio_hdr { + char E_magic[CMS_LEN], + E_ino[8], + E_mode[8], + E_uid[8], + E_gid[8], + E_nlink[8], + E_mtime[8], + E_filesize[8], + E_maj[8], + E_min[8], + E_rmaj[8], + E_rmin[8], + E_namesize[8], + E_chksum[8], + E_name[EXPNLEN]; +}; + +/* Tar header structure and format */ + +#define TBLOCK 512 /* length of tar header and data blocks */ +#define TNAMLEN 100 /* maximum length for tar file names */ +#define TMODLEN 8 /* length of mode field */ +#define TUIDLEN 8 /* length of uid field */ +#define TGIDLEN 8 /* length of gid field */ +#define TSIZLEN 12 /* length of size field */ +#define TTIMLEN 12 /* length of modification time field */ +#define TCRCLEN 8 /* length of header checksum field */ + +/* tar header definition */ + +union tblock { + char dummy[TBLOCK]; + struct tar_hdr { + char t_name[TNAMLEN], /* name of file */ + t_mode[TMODLEN], /* mode of file */ + t_uid[TUIDLEN], /* uid of file */ + t_gid[TGIDLEN], /* gid of file */ + t_size[TSIZLEN], /* size of file in bytes */ + t_mtime[TTIMLEN], /* modification time of file */ + t_cksum[TCRCLEN], /* checksum of header */ + t_typeflag, + t_linkname[TNAMLEN], /* file this file linked with */ + t_magic[TMAGLEN], + t_version[TVERSLEN], + t_uname[32], + t_gname[32], + t_devmajor[8], + t_devminor[8], + t_prefix[155]; + } tbuf; +}; + +/* volcopy tape label format and structure */ + +#define VMAGLEN 8 +#define VVOLLEN 6 +#define VFILLEN 464 + +struct volcopy_label { + char v_magic[VMAGLEN], + v_volume[VVOLLEN], + v_reels, + v_reel; + int v_time, + v_length, + v_dens, + v_reelblks, /* u370 added field */ + v_blksize, /* u370 added field */ + v_nblocks; /* u370 added field */ + char v_fill[VFILLEN]; + int v_offset; /* used with -e and -reel options */ + int v_type; /* does tape have nblocks field? */ +}; + +/* + * Define archive formats for extended attributes. + * + * Extended attributes are stored in two pieces. + * 1. An attribute header which has information about + * what file the attribute is for and what the attribute + * is named. + * 2. The attribute record itself. Stored as a normal file type + * of entry. + * Both the header and attribute record have special modes/typeflags + * associated with them. + * + * The names of the header in the archive look like: + * /dev/null/attr.hdr + * + * The name of the attribute looks like: + * /dev/null/attr. + * + * This is done so that an archiver that doesn't understand these formats + * can just dispose of the attribute records unless the user chooses to + * rename them via cpio -r or pax -i + * + * The format is composed of a fixed size header followed + * by a variable sized xattr_buf. If the attribute is a hard link + * to another attribute, then another xattr_buf section is included + * for the link. + * + * The xattr_buf is used to define the necessary "pathing" steps + * to get to the extended attribute. This is necessary to support + * a fully recursive attribute model where an attribute may itself + * have an attribute. + * + * The basic layout looks like this. + * + * -------------------------------- + * | | + * | xattr_hdr | + * | | + * -------------------------------- + * -------------------------------- + * | | + * | xattr_buf | + * | | + * -------------------------------- + * -------------------------------- + * | | + * | (optional link info) | + * | | + * -------------------------------- + * -------------------------------- + * | | + * | attribute itself | + * | stored as normal tar | + * | or cpio data with | + * | special mode or | + * | typeflag | + * | | + * -------------------------------- + * + */ +#define XATTR_ARCH_VERS "1.0" + +/* + * extended attribute fixed header + * + * h_version format version. + * h_size size of header + variable sized data sections. + * h_component_len Length of entire pathing section. + * h_link_component_len Length of link component section. Again same definition + * as h_component_len. + */ +struct xattr_hdr { + char h_version[7]; + char h_size[10]; + char h_component_len[10]; /* total length of path component */ + char h_link_component_len[10]; +}; + +/* + * The name is encoded like this: + * filepathNULattrpathNUL[attrpathNULL]... + */ +struct xattr_buf { + char h_namesz[7]; /* length of h_names */ + char h_typeflag; /* actual typeflag of file being archived */ + char h_names[1]; /* filepathNULattrpathNUL... */ +}; + +/* + * Special values for tar archives + */ + +/* + * typeflag for tar archives. + */ + +/* + * Attribute hdr and attribute files have the following typeflag + */ +#define _XATTR_HDRTYPE 'E' + +/* + * For cpio archives the header and attribute have + * _XATTR_CPIO_MODE ORED into the mode field in both + * character and binary versions of the archive format + */ +#define _XATTR_CPIO_MODE 0xB000 + +#ifdef __cplusplus +} +#endif + +#endif /* _ARCHIVES_H */ diff --git a/illumos-x86_64/usr/include/arpa/ftp.h b/illumos-x86_64/usr/include/arpa/ftp.h new file mode 100644 index 00000000..684b51a0 --- /dev/null +++ b/illumos-x86_64/usr/include/arpa/ftp.h @@ -0,0 +1,146 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _ARPA_FTP_H +#define _ARPA_FTP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for FTP + * See RFC-765 + */ + +/* + * Reply codes. + */ +#define PRELIM 1 /* positive preliminary */ +#define COMPLETE 2 /* positive completion */ +#define CONTINUE 3 /* positive intermediate */ +#define TRANSIENT 4 /* transient negative completion */ +#define ERROR 5 /* permanent negative completion */ + +/* + * Type codes + */ +#define TYPE_A 1 /* ASCII */ +#define TYPE_E 2 /* EBCDIC */ +#define TYPE_I 3 /* image */ +#define TYPE_L 4 /* local byte size */ +#ifdef FTP_NAMES +char *typenames[] = +{"0", "ASCII", "EBCDIC", "Image", "Local"}; +#endif + +/* + * Form codes + */ +#define FORM_N 1 /* non-print */ +#define FORM_T 2 /* telnet format effectors */ +#define FORM_C 3 /* carriage control (ASA) */ +#ifdef FTP_NAMES +char *formnames[] = +{"0", "Nonprint", "Telnet", "Carriage-control"}; +#endif + +/* + * Structure codes + */ +#define STRU_F 1 /* file (no record structure) */ +#define STRU_R 2 /* record structure */ +#define STRU_P 3 /* page structure */ +#ifdef FTP_NAMES +char *strunames[] = +{"0", "File", "Record", "Page"}; +#endif + +/* + * Mode types + */ +#define MODE_S 1 /* stream */ +#define MODE_B 2 /* block */ +#define MODE_C 3 /* compressed */ +#ifdef FTP_NAMES +char *modenames[] = +{"0", "Stream", "Block", "Compressed"}; +#endif + +/* + * Authentication types + */ +#define AUTHTYPE_NONE 0 +#define AUTHTYPE_GSSAPI 1 +#ifdef FTP_NAMES +char *authtypenames[] = { + "NONE", "GSSAPI", 0 +}; +#define GSS_AUTHTYPE_NAME(x) authtypenames[x] +#endif + +/* + * Protection levels + */ +#define PROT_C 1 /* no integrity; no encryption */ +#define PROT_S 2 /* integrity; no encryption */ +#define PROT_P 3 /* integrity; encryption */ +#define PROT_E 4 /* no integrity; encryption */ +#ifdef FTP_NAMES +char *protnames[] = + {"0", "Clear", "Safe", "Private", "Confidential"}; +#endif + +/* + * Record Tokens + */ +#define REC_ESC '\377' /* Record-mode Escape */ +#define REC_EOR '\001' /* Record-mode End-of-Record */ +#define REC_EOF '\002' /* Record-mode End-of-File */ + +/* + * Block Header + */ +#define BLK_EOR 0x80 /* Block is End-of-Record */ +#define BLK_EOF 0x40 /* Block is End-of-File */ +#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ +#define BLK_RESTART 0x10 /* Block is Restart Marker */ + +#define BLK_BYTECOUNT 2 /* Bytes in this block */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ARPA_FTP_H */ diff --git a/illumos-x86_64/usr/include/arpa/inet.h b/illumos-x86_64/usr/include/arpa/inet.h new file mode 100644 index 00000000..03a8e9c3 --- /dev/null +++ b/illumos-x86_64/usr/include/arpa/inet.h @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _ARPA_INET_H +#define _ARPA_INET_H + +#include + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +#include +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +#include +#if defined(_XPG4_2) && !defined(__EXTENSIONS__) +#include +#endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * External definitions for + * functions in inet(3C) + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int inet_net_pton(int, const char *, void *, size_t); +extern int inet_matchaddr(const void *, const char *); +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +extern int inet_pton(int, const char *_RESTRICT_KYWD, void *_RESTRICT_KYWD); +extern const char *inet_ntop(int, const void *_RESTRICT_KYWD, + char *_RESTRICT_KYWD, socklen_t); +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +extern in_addr_t inet_addr(const char *); +/* + * With the introduction of CIDR the + * following 4 routines are now considered to be Obsolete + */ +extern in_addr_t inet_lnaof(struct in_addr); +extern struct in_addr inet_makeaddr(in_addr_t, in_addr_t); +extern in_addr_t inet_netof(struct in_addr); +extern in_addr_t inet_network(const char *); + + +extern char *inet_neta(ulong_t, char *, size_t); +extern char *inet_net_ntop(int, const void *, int, char *, size_t); + +extern char *inet_cidr_ntop(int, const void *, int, char *, size_t); +extern int inet_cidr_pton(int, const char *, void *, int *); +extern char *inet_ntoa(struct in_addr); +extern int inet_aton(const char *, struct in_addr *); + +extern uint_t inet_nsap_addr(const char *, uchar_t *, int); +extern char *inet_nsap_ntoa(int, const uchar_t *, char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _ARPA_INET_H */ diff --git a/illumos-x86_64/usr/include/arpa/nameser.h b/illumos-x86_64/usr/include/arpa/nameser.h new file mode 100644 index 00000000..0359a5cd --- /dev/null +++ b/illumos-x86_64/usr/include/arpa/nameser.h @@ -0,0 +1,711 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2016, Chris Fraire . + */ + +/* + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Portions Copyright (C) 2004, 2005, 2008, 2009 + * Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 1996-2003 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * $Id: nameser.h,v 8.50 2003/05/27 23:36:52 marka Exp $ + */ + +#ifndef _ARPA_NAMESER_H +#define _ARPA_NAMESER_H + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#define BIND_4_COMPAT + +/* + * Revision information. This is the release date in YYYYMMDD format. + * It can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not + * compare for equality; rather, use it to determine whether your libresolv + * contains a new enough lib/nameser/ to support the feature you need. + */ + +#define __NAMESER 20090302 /* New interface version stamp. */ + +/* + * Define constants based on RFC 883, RFC 1034, RFC 1035 + */ +#define NS_PACKETSZ 512 /* default UDP packet size */ +#define NS_MAXDNAME 1025 /* maximum domain name */ +#define NS_MAXMSG 65535 /* maximum message size */ +#define NS_MAXCDNAME 255 /* maximum compressed domain name */ +#define NS_MAXLABEL 63 /* maximum length of domain label */ +#define NS_MAXLABELS 128 /* theoretical max #/labels per domain name */ +#define NS_MAXNNAME 256 /* maximum uncompressed (binary) domain name */ +#define NS_MAXPADDR (sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")) +#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ +#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ +#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ +#define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */ +#define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */ +#define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */ +#define NS_INADDRSZ 4 /* IPv4 T_A */ +#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */ +#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ +#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ + +/* + * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord() + * in synch with it. + */ +typedef enum __ns_sect { + ns_s_qd = 0, /* Query: Question. */ + ns_s_zn = 0, /* Update: Zone. */ + ns_s_an = 1, /* Query: Answer. */ + ns_s_pr = 1, /* Update: Prerequisites. */ + ns_s_ns = 2, /* Query: Name servers. */ + ns_s_ud = 2, /* Update: Update. */ + ns_s_ar = 3, /* Query|Update: Additional records. */ + ns_s_max = 4 +} ns_sect; + +/* + * Network name (compressed or not) type. Equivalent to a pointer when used + * in a function prototype. Can be const'd. + */ +typedef uchar_t ns_nname[NS_MAXNNAME]; +typedef const uchar_t *ns_nname_ct; +typedef uchar_t *ns_nname_t; + +struct ns_namemap { ns_nname_ct base; int len; }; +typedef struct ns_namemap *ns_namemap_t; +typedef const struct ns_namemap *ns_namemap_ct; + +/* + * This is a message handle. It is caller allocated and has no dynamic data. + * This structure is intended to be opaque to all but ns_parse.c, thus the + * leading _'s on the member names. Use the accessor functions, not the _'s. + */ +typedef struct __ns_msg { + const uchar_t *_msg, *_eom; + uint16_t _id, _flags, _counts[ns_s_max]; + const uchar_t *_sections[ns_s_max]; + ns_sect _sect; + int _rrnum; + const uchar_t *_msg_ptr; +} ns_msg; + +/* + * This is a newmsg handle, used when constructing new messages with + * ns_newmsg_init, et al. + */ +struct ns_newmsg { + ns_msg msg; + const uchar_t *dnptrs[25]; + const uchar_t **lastdnptr; +}; +typedef struct ns_newmsg ns_newmsg; + +/* Private data structure - do not use from outside library. */ +struct _ns_flagdata { int mask, shift; }; +extern struct _ns_flagdata _ns_flagdata[]; + +/* Accessor macros - this is part of the public interface. */ +#define ns_msg_id(handle) ((handle)._id + 0) +#define ns_msg_base(handle) ((handle)._msg + 0) +#define ns_msg_end(handle) ((handle)._eom + 0) +#define ns_msg_size(handle) ((handle)._eom - (handle)._msg) +#define ns_msg_count(handle, section) ((handle)._counts[section] + 0) + +/* + * This is a parsed record. It is caller allocated and has no dynamic data. + */ +typedef struct __ns_rr { + char name[NS_MAXDNAME]; + uint16_t type; + uint16_t rr_class; + uint32_t ttl; + uint16_t rdlength; + const uchar_t *rdata; +} ns_rr; + +/* + * Same thing, but using uncompressed network binary names, and real C types. + */ +typedef struct __ns_rr2 { + ns_nname nname; + size_t nnamel; + int type; + int rr_class; + uint_t ttl; + int rdlength; + const uchar_t *rdata; +} ns_rr2; + +/* Accessor macros - this is part of the public interface. */ +#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") +#define ns_rr_nname(rr) ((const ns_nname_t)(rr).nname) +#define ns_rr_nnamel(rr) ((rr).nnamel + 0) +#define ns_rr_type(rr) ((ns_type)((rr).type + 0)) +#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) +#define ns_rr_ttl(rr) ((rr).ttl + 0) +#define ns_rr_rdlen(rr) ((rr).rdlength + 0) +#define ns_rr_rdata(rr) ((rr).rdata + 0) + +/* + * These don't have to be in the same order as in the packet flags word, + * and they can even overlap in some cases, but they will need to be kept + * in synch with ns_parse.c:ns_flagdata[]. + */ +typedef enum __ns_flag { + ns_f_qr, /* Question/Response. */ + ns_f_opcode, /* Operation code. */ + ns_f_aa, /* Authoritative Answer. */ + ns_f_tc, /* Truncation occurred. */ + ns_f_rd, /* Recursion Desired. */ + ns_f_ra, /* Recursion Available. */ + ns_f_z, /* MBZ. */ + ns_f_ad, /* Authentic Data (DNSSEC). */ + ns_f_cd, /* Checking Disabled (DNSSEC). */ + ns_f_rcode, /* Response code. */ + ns_f_max +} ns_flag; + +/* + * Currently defined opcodes. + */ +typedef enum __ns_opcode { + ns_o_query = 0, /* Standard query. */ + ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */ + ns_o_status = 2, /* Name server status query (unsupported). */ + /* Opcode 3 is undefined/reserved. */ + ns_o_notify = 4, /* Zone change notification. */ + ns_o_update = 5, /* Zone update message. */ + ns_o_max = 6 +} ns_opcode; + +/* + * Currently defined response codes. + */ +typedef enum __ns_rcode { + ns_r_noerror = 0, /* No error occurred. */ + ns_r_formerr = 1, /* Format error. */ + ns_r_servfail = 2, /* Server failure. */ + ns_r_nxdomain = 3, /* Name error. */ + ns_r_notimpl = 4, /* Unimplemented. */ + ns_r_refused = 5, /* Operation refused. */ + /* these are for BIND_UPDATE */ + ns_r_yxdomain = 6, /* Name exists */ + ns_r_yxrrset = 7, /* RRset exists */ + ns_r_nxrrset = 8, /* RRset does not exist */ + ns_r_notauth = 9, /* Not authoritative for zone */ + ns_r_notzone = 10, /* Zone of record different from zone section */ + ns_r_max = 11, + /* The following are EDNS extended rcodes */ + ns_r_badvers = 16, + /* The following are TSIG errors */ + ns_r_badsig = 16, + ns_r_badkey = 17, + ns_r_badtime = 18 +} ns_rcode; + +/* BIND_UPDATE */ +typedef enum __ns_update_operation { + ns_uop_delete = 0, + ns_uop_add = 1, + ns_uop_max = 2 +} ns_update_operation; + +/* + * This RR-like structure is particular to UPDATE. + */ +struct ns_updrec { + struct ns_updrec *r_prev; /* prev record */ + struct ns_updrec *r_next; /* next record */ + uint8_t r_section; /* ZONE/PREREQUISITE/UPDATE */ + char *r_dname; /* owner of the RR */ + uint16_t r_class; /* class number */ + uint16_t r_type; /* type number */ + uint32_t r_ttl; /* time to live */ + uchar_t *r_data; /* rdata fields as text string */ + uint16_t r_size; /* size of r_data field */ + int r_opcode; /* type of operation */ + /* following fields for private use by the resolver/server routines */ + struct ns_updrec *r_grpnext; /* next record when grouped */ + struct databuf *r_dp; /* databuf to process */ + struct databuf *r_deldp; /* databuf's deleted/overwritten */ + uint16_t r_zone; /* zone number on server */ +}; +typedef struct ns_updrec ns_updrec; + +/* + * This structure is used for TSIG authenticated messages + */ +struct ns_tsig_key { + char name[NS_MAXDNAME], alg[NS_MAXDNAME]; + unsigned char *data; + int len; +}; +typedef struct ns_tsig_key ns_tsig_key; + +/* + * This structure is used for TSIG authenticated TCP messages + */ +struct ns_tcp_tsig_state { + int counter; + struct dst_key *key; + void *ctx; + unsigned char sig[NS_PACKETSZ]; + int siglen; +}; +typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; + +#define NS_TSIG_FUDGE 300 +#define NS_TSIG_TCP_COUNT 100 +#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" + +#define NS_TSIG_ERROR_NO_TSIG -10 +#define NS_TSIG_ERROR_NO_SPACE -11 +#define NS_TSIG_ERROR_FORMERR -12 + +/* + * Currently defined type values for resources and queries. + */ +typedef enum __ns_type { + ns_t_invalid = 0, /* Cookie. */ + ns_t_a = 1, /* Host address. */ + ns_t_ns = 2, /* Authoritative server. */ + ns_t_md = 3, /* Mail destination. */ + ns_t_mf = 4, /* Mail forwarder. */ + ns_t_cname = 5, /* Canonical name. */ + ns_t_soa = 6, /* Start of authority zone. */ + ns_t_mb = 7, /* Mailbox domain name. */ + ns_t_mg = 8, /* Mail group member. */ + ns_t_mr = 9, /* Mail rename name. */ + ns_t_null = 10, /* Null resource record. */ + ns_t_wks = 11, /* Well known service. */ + ns_t_ptr = 12, /* Domain name pointer. */ + ns_t_hinfo = 13, /* Host information. */ + ns_t_minfo = 14, /* Mailbox information. */ + ns_t_mx = 15, /* Mail routing information. */ + ns_t_txt = 16, /* Text strings. */ + ns_t_rp = 17, /* Responsible person. */ + ns_t_afsdb = 18, /* AFS cell database. */ + ns_t_x25 = 19, /* X_25 calling address. */ + ns_t_isdn = 20, /* ISDN calling address. */ + ns_t_rt = 21, /* Router. */ + ns_t_nsap = 22, /* NSAP address. */ + ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ + ns_t_sig = 24, /* Security signature. */ + ns_t_key = 25, /* Security key. */ + ns_t_px = 26, /* X.400 mail mapping. */ + ns_t_gpos = 27, /* Geographical position (withdrawn). */ + ns_t_aaaa = 28, /* IPv6 Address. */ + ns_t_loc = 29, /* Location Information. */ + ns_t_nxt = 30, /* Next domain (security). */ + ns_t_eid = 31, /* Endpoint identifier. */ + ns_t_nimloc = 32, /* Nimrod Locator. */ + ns_t_srv = 33, /* Server Selection. */ + ns_t_atma = 34, /* ATM Address */ + ns_t_naptr = 35, /* Naming Authority PoinTeR */ + ns_t_kx = 36, /* Key Exchange */ + ns_t_cert = 37, /* Certification record */ + ns_t_a6 = 38, /* IPv6 address (deprecated) */ + ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ + ns_t_sink = 40, /* Kitchen sink (experimentatl) */ + ns_t_opt = 41, /* EDNS0 option (meta-RR) */ + ns_t_apl = 42, /* Address prefix list (RFC 3123) */ + ns_t_ds = 43, /* Delegation Signer */ + ns_t_sshfp = 44, /* SSH Fingerprint */ + ns_t_ipseckey = 45, /* IPSEC Key */ + ns_t_rrsig = 46, /* RRset Signature */ + ns_t_nsec = 47, /* Negative security */ + ns_t_dnskey = 48, /* DNS Key */ + ns_t_dhcid = 49, /* Dynamic host configuratin identifier */ + ns_t_nsec3 = 50, /* Negative security type 3 */ + ns_t_nsec3param = 51, /* Negative security type 3 parameters */ + ns_t_tlsa = 52, /* TLSA (RFC 6698) */ + ns_t_smimea = 53, /* S/MIME cert association (RFC 8162) */ + ns_t_hip = 55, /* Host Identity Protocol */ + ns_t_cds = 59, /* Child DS (RFC 7344) */ + ns_t_cdnskey = 60, /* DNSKEY(s) the Child wants reflected in DS */ + ns_t_openpgpkey = 61, /* OpenPGP Key (RFC 7929) */ + ns_t_csync = 62, /* Child-To-Parent Synchronization (RFC 7477) */ + ns_t_spf = 99, /* Sender Policy Framework */ + ns_t_tkey = 249, /* Transaction key */ + ns_t_tsig = 250, /* Transaction signature. */ + ns_t_ixfr = 251, /* Incremental zone transfer. */ + ns_t_axfr = 252, /* Transfer zone of authority. */ + ns_t_mailb = 253, /* Transfer mailbox records. */ + ns_t_maila = 254, /* Transfer mail agent records. */ + ns_t_any = 255, /* Wildcard match. */ + ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ + ns_t_caa = 257, /* Certification Authority Restriction */ + ns_t_dlv = 32769, /* DNSSEC look-aside validatation. */ + ns_t_max = 65536 +} ns_type; + +/* Exclusively a QTYPE? (not also an RTYPE) */ +#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ + (t) == ns_t_mailb || (t) == ns_t_maila) +/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */ +#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) +/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */ +#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) +#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) +#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ + (t) == ns_t_zxfr) + +/* + * Values for class field + */ +typedef enum __ns_class { + ns_c_invalid = 0, /* Cookie. */ + ns_c_in = 1, /* Internet. */ + ns_c_2 = 2, /* unallocated/unsupported. */ + ns_c_chaos = 3, /* MIT Chaos-net. */ + ns_c_hs = 4, /* MIT Hesiod. */ + /* Query class values which do not appear in resource records */ + ns_c_none = 254, /* for prereq. sections in update requests */ + ns_c_any = 255, /* Wildcard match. */ + ns_c_max = 65536 +} ns_class; + +/* DNSSEC constants. */ + +typedef enum __ns_key_types { + ns_kt_rsa = 1, /* key type RSA/MD5 */ + ns_kt_dh = 2, /* Diffie Hellman */ + ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */ + ns_kt_private = 254 /* Private key type starts with OID */ +} ns_key_types; + +typedef enum __ns_cert_types { + cert_t_pkix = 1, /* PKIX (X.509v3) */ + cert_t_spki = 2, /* SPKI */ + cert_t_pgp = 3, /* PGP */ + cert_t_url = 253, /* URL private type */ + cert_t_oid = 254 /* OID private type */ +} ns_cert_types; + +/* Flags field of the KEY RR rdata. */ +#define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */ +#define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ +#define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ +#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ +#define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ +/* The type bits can also be interpreted independently, as single bits: */ +#define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */ +#define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */ +#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */ +#define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */ +#define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */ +#define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */ +#define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */ +#define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */ +#define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */ +#define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */ +#define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */ +#define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */ +#define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */ +#define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */ +#define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */ +#define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */ +#define NS_KEY_RESERVED_BITMASK (NS_KEY_RESERVED2 | \ + NS_KEY_RESERVED4 | \ + NS_KEY_RESERVED5 | \ + NS_KEY_RESERVED8 | \ + NS_KEY_RESERVED9 | \ + NS_KEY_RESERVED10 | \ + NS_KEY_RESERVED11) +#define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */ + +/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ +#define NS_ALG_MD5RSA 1 /* MD5 with RSA */ +#define NS_ALG_DH 2 /* Diffie Hellman KEY */ +#define NS_ALG_DSA 3 /* DSA KEY */ +#define NS_ALG_DSS NS_ALG_DSA +#define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */ +#define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */ + +/* Protocol values */ +/* value 0 is reserved */ +#define NS_KEY_PROT_TLS 1 +#define NS_KEY_PROT_EMAIL 2 +#define NS_KEY_PROT_DNSSEC 3 +#define NS_KEY_PROT_IPSEC 4 +#define NS_KEY_PROT_ANY 255 + +/* Signatures */ +#define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */ +#define NS_MD5RSA_MAX_BITS 4096 + /* Total of binary mod and exp */ +#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) + /* Max length of text sig block */ +#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) +#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) +#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) + +#define NS_DSA_SIG_SIZE 41 +#define NS_DSA_MIN_SIZE 213 +#define NS_DSA_MAX_BYTES 405 + +/* Offsets into SIG record rdata to find various values */ +#define NS_SIG_TYPE 0 /* Type flags */ +#define NS_SIG_ALG 2 /* Algorithm */ +#define NS_SIG_LABELS 3 /* How many labels in name */ +#define NS_SIG_OTTL 4 /* Original TTL */ +#define NS_SIG_EXPIR 8 /* Expiration time */ +#define NS_SIG_SIGNED 12 /* Signature time */ +#define NS_SIG_FOOT 16 /* Key footprint */ +#define NS_SIG_SIGNER 18 /* Domain name of who signed it */ + +/* How RR types are represented as bit-flags in NXT records */ +#define NS_NXT_BITS 8 +#define NS_NXT_BIT_SET(n, p) \ + (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_CLEAR(n, p) \ + (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_ISSET(n, p) \ + (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_MAX 127 + +/* + * EDNS0 extended flags, host order. + */ +#define NS_OPT_DNSSEC_OK 0x8000U +#define NS_OPT_NSID 3 + +/* + * Inline versions of get/put short/long. Pointer is advanced. + */ +#define NS_GET16(s, cp) do { \ + register const uchar_t *t_cp = (const uchar_t *)(cp); \ + (s) = ((uint16_t)t_cp[0] << 8) \ + | ((uint16_t)t_cp[1]) \ + ; \ + (cp) += NS_INT16SZ; \ +} while (0) + +#define NS_GET32(l, cp) do { \ + register const uchar_t *t_cp = (const uchar_t *)(cp); \ + (l) = ((uint32_t)t_cp[0] << 24) \ + | ((uint32_t)t_cp[1] << 16) \ + | ((uint32_t)t_cp[2] << 8) \ + | ((uint32_t)t_cp[3]) \ + ; \ + (cp) += NS_INT32SZ; \ +} while (0) + +#define NS_PUT16(s, cp) do { \ + register uint16_t t_s = (uint16_t)(s); \ + register uchar_t *t_cp = (uchar_t *)(cp); \ + *t_cp++ = t_s >> 8; \ + *t_cp = t_s; \ + (cp) += NS_INT16SZ; \ +} while (0) + +#define NS_PUT32(l, cp) do { \ + register uint32_t t_l = (uint32_t)(l); \ + register uchar_t *t_cp = (uchar_t *)(cp); \ + *t_cp++ = t_l >> 24; \ + *t_cp++ = t_l >> 16; \ + *t_cp++ = t_l >> 8; \ + *t_cp = t_l; \ + (cp) += NS_INT32SZ; \ +} while (0) + +/* + * ANSI C identifier hiding. + */ +#define ns_msg_getflag __ns_msg_getflag +#define ns_get16 __ns_get16 +#define ns_get32 __ns_get32 +#define ns_put16 __ns_put16 +#define ns_put32 __ns_put32 +#define ns_initparse __ns_initparse +#define ns_skiprr __ns_skiprr +#define ns_parserr __ns_parserr +#define ns_parserr2 __ns_parserr2 +#define ns_sprintrr __ns_sprintrr +#define ns_sprintrrf __ns_sprintrrf +#define ns_format_ttl __ns_format_ttl +#define ns_parse_ttl __ns_parse_ttl +#define ns_datetosecs __ns_datetosecs +#define ns_name_ntol __ns_name_ntol +#define ns_name_ntop __ns_name_ntop +#define ns_name_pton __ns_name_pton +#define ns_name_pton2 __ns_name_pton2 +#define ns_name_unpack __ns_name_unpack +#define ns_name_pack __ns_name_pack +#define ns_name_compress __ns_name_compress +#define ns_name_uncompress __ns_name_uncompress +#define ns_name_skip __ns_name_skip +#define ns_name_rollback __ns_name_rollback +#define ns_name_length __ns_name_length +#define ns_name_eq __ns_name_eq +#define ns_name_owned __ns_name_owned +#define ns_name_map __ns_name_map +#define ns_name_labels __ns_name_labels +#define ns_sign __ns_sign +#define ns_sign2 __ns_sign2 +#define ns_sign_tcp __ns_sign_tcp +#define ns_sign_tcp2 __ns_sign_tcp2 +#define ns_sign_tcp_init __ns_sign_tcp_init +#define ns_find_tsig __ns_find_tsig +#define ns_verify __ns_verify +#define ns_verify_tcp __ns_verify_tcp +#define ns_verify_tcp_init __ns_verify_tcp_init +#define ns_samedomain __ns_samedomain +#define ns_subdomain __ns_subdomain +#define ns_makecanon __ns_makecanon +#define ns_samename __ns_samename +#define ns_newmsg_init __ns_newmsg_init +#define ns_newmsg_copy __ns_newmsg_copy +#define ns_newmsg_id __ns_newmsg_id +#define ns_newmsg_flag __ns_newmsg_flag +#define ns_newmsg_q __ns_newmsg_q +#define ns_newmsg_rr __ns_newmsg_rr +#define ns_newmsg_done __ns_newmsg_done +#define ns_rdata_unpack __ns_rdata_unpack +#define ns_rdata_equal __ns_rdata_equal +#define ns_rdata_refers __ns_rdata_refers + +int ns_msg_getflag(ns_msg, int); +uint_t ns_get16(const uchar_t *); +ulong_t ns_get32(const uchar_t *); +void ns_put16(uint_t, uchar_t *); +void ns_put32(ulong_t, uchar_t *); +int ns_initparse(const uchar_t *, int, ns_msg *); +int ns_skiprr(const uchar_t *, const uchar_t *, ns_sect, int); +int ns_parserr(ns_msg *, ns_sect, int, ns_rr *); +int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *); +int ns_sprintrr(const ns_msg *, const ns_rr *, + const char *, const char *, char *, size_t); +int ns_sprintrrf(const uchar_t *, size_t, const char *, + ns_class, ns_type, ulong_t, const uchar_t *, + size_t, const char *, const char *, + char *, size_t); +int ns_format_ttl(ulong_t, char *, size_t); +int ns_parse_ttl(const char *, ulong_t *); +uint32_t ns_datetosecs(const char *cp, int *errp); +int ns_name_ntol(const uchar_t *, uchar_t *, size_t); +int ns_name_ntop(const uchar_t *, char *, size_t); +int ns_name_pton(const char *, uchar_t *, size_t); +int ns_name_pton2(const char *, uchar_t *, size_t, size_t *); +int ns_name_unpack(const uchar_t *, const uchar_t *, + const uchar_t *, uchar_t *, size_t); +int ns_name_pack(const uchar_t *, uchar_t *, int, + const uchar_t **, const uchar_t **); +int ns_name_uncompress(const uchar_t *, const uchar_t *, + const uchar_t *, char *, size_t); +int ns_name_compress(const char *, uchar_t *, size_t, + const uchar_t **, const uchar_t **); +int ns_name_skip(const uchar_t **, const uchar_t *); +void ns_name_rollback(const uchar_t *, const uchar_t **, + const uchar_t **); +ssize_t ns_name_length(ns_nname_ct, size_t); +int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t); +int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int); +int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int); +int ns_name_labels(ns_nname_ct, size_t); +int ns_sign(uchar_t *, int *, int, int, void *, + const uchar_t *, int, uchar_t *, int *, time_t); +int ns_sign2(uchar_t *, int *, int, int, void *, + const uchar_t *, int, uchar_t *, int *, time_t, + uchar_t **, uchar_t **); +int ns_sign_tcp(uchar_t *, int *, int, int, + ns_tcp_tsig_state *, int); +int ns_sign_tcp2(uchar_t *, int *, int, int, + ns_tcp_tsig_state *, int, + uchar_t **, uchar_t **); +int ns_sign_tcp_init(void *, const uchar_t *, int, + ns_tcp_tsig_state *); +uchar_t *ns_find_tsig(uchar_t *, uchar_t *); +int ns_verify(uchar_t *, int *, void *, + const uchar_t *, int, uchar_t *, int *, + time_t *, int); +int ns_verify_tcp(uchar_t *, int *, ns_tcp_tsig_state *, int); +int ns_verify_tcp_init(void *, const uchar_t *, int, + ns_tcp_tsig_state *); +int ns_samedomain(const char *, const char *); +int ns_subdomain(const char *, const char *); +int ns_makecanon(const char *, char *, size_t); +int ns_samename(const char *, const char *); +int ns_newmsg_init(uchar_t *buffer, size_t bufsiz, ns_newmsg *); +int ns_newmsg_copy(ns_newmsg *, ns_msg *); +void ns_newmsg_id(ns_newmsg *handle, uint16_t id); +void ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, uint_t value); +int ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname, + ns_type qtype, ns_class qclass); +int ns_newmsg_rr(ns_newmsg *handle, ns_sect sect, + ns_nname_ct name, ns_type type, + ns_class rr_class, uint32_t ttl, + uint16_t rdlen, const uchar_t *rdata); +size_t ns_newmsg_done(ns_newmsg *handle); +ssize_t ns_rdata_unpack(const uchar_t *, const uchar_t *, ns_type, + const uchar_t *, size_t, uchar_t *, size_t); +int ns_rdata_equal(ns_type, const uchar_t *, size_t, + const uchar_t *, size_t); +int ns_rdata_refers(ns_type, + const uchar_t *, size_t, + const uchar_t *); + +#ifdef BIND_4_COMPAT +#include +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !_ARPA_NAMESER_H */ diff --git a/illumos-x86_64/usr/include/arpa/nameser_compat.h b/illumos-x86_64/usr/include/arpa/nameser_compat.h new file mode 100644 index 00000000..d948d8e7 --- /dev/null +++ b/illumos-x86_64/usr/include/arpa/nameser_compat.h @@ -0,0 +1,271 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright(c) 1983, 1989 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * from nameser.h 8.1 (Berkeley) 6/2/93 + * $Id: nameser_compat.h,v 8.15 2002/07/17 07:01:02 marka Exp $ + */ + +#ifndef _ARPA_NAMESER_COMPAT_H +#define _ARPA_NAMESER_COMPAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define __BIND 19950621 /* (DEAD) interface version stamp. */ + +#ifndef BYTE_ORDER +#if (BSD >= 199103) +#include +#else +#ifdef linux +#include +#else +#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */ +#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ + +#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \ + defined(__i386) || defined(__amd64) || \ + defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \ + defined(__alpha__) || defined(__alpha) || \ + (defined(__Lynx__) && defined(__x86__)) +#define BYTE_ORDER LITTLE_ENDIAN +#endif + +#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ + defined(__sparc) || \ + defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ + defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\ + defined(apollo) || defined(__convex__) || defined(_CRAY) || \ + defined(__hppa) || defined(__hp9000) || \ + defined(__hp9000s300) || defined(__hp9000s700) || \ + defined(__hp3000s900) || defined(MPE) || \ + defined(BIT_ZERO_ON_LEFT) || defined(m68k) || \ + (defined(__Lynx__) && \ + (defined(__68k__) || defined(__sparc__) || defined(__powerpc__))) +#define BYTE_ORDER BIG_ENDIAN +#endif +#endif /* linux */ +#endif /* BSD */ +#endif /* BYTE_ORDER */ + +#if !defined(BYTE_ORDER) || \ + ((BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN) && \ + (BYTE_ORDER != PDP_ENDIAN)) +/* + * you must determine what the correct bit order is for + * your compiler - the next line is an intentional error + * which will force your compiles to bomb until you fix + * the above macros. + */ +#error "Undefined or invalid BYTE_ORDER"; +#endif + +/* + * Structure for query header. The order of the fields is machine- and + * compiler-dependent, depending on the byte/bit order and the layout + * of bit fields. We use bit fields only in int variables, as this + * is all ANSI requires. This requires a somewhat confusing rearrangement. + */ + +typedef struct { + unsigned id :16; /* query identification number */ +#if BYTE_ORDER == BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /* response flag */ + unsigned opcode: 4; /* purpose of message */ + unsigned aa: 1; /* authoritive answer */ + unsigned tc: 1; /* truncated message */ + unsigned rd: 1; /* recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /* recursion available */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ad: 1; /* authentic data from named */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned rcode :4; /* response code */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /* recursion desired */ + unsigned tc :1; /* truncated message */ + unsigned aa :1; /* authoritive answer */ + unsigned opcode :4; /* purpose of message */ + unsigned qr :1; /* response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /* response code */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned ad: 1; /* authentic data from named */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ra :1; /* recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /* number of question entries */ + unsigned ancount :16; /* number of answer entries */ + unsigned nscount :16; /* number of authority entries */ + unsigned arcount :16; /* number of resource entries */ +} HEADER; + +#define PACKETSZ NS_PACKETSZ +#define MAXDNAME NS_MAXDNAME +#define MAXCDNAME NS_MAXCDNAME +#define MAXLABEL NS_MAXLABEL +#define HFIXEDSZ NS_HFIXEDSZ +#define QFIXEDSZ NS_QFIXEDSZ +#define RRFIXEDSZ NS_RRFIXEDSZ +#define INT32SZ NS_INT32SZ +#define INT16SZ NS_INT16SZ +#define INT8SZ NS_INT8SZ +#define INADDRSZ NS_INADDRSZ +#define IN6ADDRSZ NS_IN6ADDRSZ +#define INDIR_MASK NS_CMPRSFLGS +#define NAMESERVER_PORT NS_DEFAULTPORT + +#define S_ZONE ns_s_zn +#define S_PREREQ ns_s_pr +#define S_UPDATE ns_s_ud +#define S_ADDT ns_s_ar + +#define QUERY ns_o_query +#define IQUERY ns_o_iquery +#define STATUS ns_o_status +#define NS_NOTIFY_OP ns_o_notify +#define NS_UPDATE_OP ns_o_update + +#define NOERROR ns_r_noerror +#define FORMERR ns_r_formerr +#define SERVFAIL ns_r_servfail +#define NXDOMAIN ns_r_nxdomain +#define NOTIMP ns_r_notimpl +#define REFUSED ns_r_refused +#define YXDOMAIN ns_r_yxdomain +#define YXRRSET ns_r_yxrrset +#define NXRRSET ns_r_nxrrset +#define NOTAUTH ns_r_notauth +#define NOTZONE ns_r_notzone +/* #define BADSIG ns_r_badsig */ +/* #define BADKEY ns_r_badkey */ +/* #define BADTIME ns_r_badtime */ + +#define DELETE ns_uop_delete +#ifndef ADD +#define ADD ns_uop_add +#endif + +#define T_A ns_t_a +#define T_NS ns_t_ns +#define T_MD ns_t_md +#define T_MF ns_t_mf +#define T_CNAME ns_t_cname +#define T_SOA ns_t_soa +#define T_MB ns_t_mb +#define T_MG ns_t_mg +#define T_MR ns_t_mr +#define T_NULL ns_t_null +#define T_WKS ns_t_wks +#define T_PTR ns_t_ptr +#define T_HINFO ns_t_hinfo +#define T_MINFO ns_t_minfo +#define T_MX ns_t_mx +#define T_TXT ns_t_txt +#define T_RP ns_t_rp +#define T_AFSDB ns_t_afsdb +#define T_X25 ns_t_x25 +#define T_ISDN ns_t_isdn +#define T_RT ns_t_rt +#define T_NSAP ns_t_nsap +#define T_NSAP_PTR ns_t_nsap_ptr +#define T_SIG ns_t_sig +#define T_KEY ns_t_key +#define T_PX ns_t_px +#define T_GPOS ns_t_gpos +#define T_AAAA ns_t_aaaa +#define T_LOC ns_t_loc +#define T_NXT ns_t_nxt +#define T_EID ns_t_eid +#define T_NIMLOC ns_t_nimloc +#define T_SRV ns_t_srv +#define T_ATMA ns_t_atma +#define T_NAPTR ns_t_naptr +#define T_A6 ns_t_a6 +#define T_TSIG ns_t_tsig +#define T_IXFR ns_t_ixfr +#define T_AXFR ns_t_axfr +#define T_MAILB ns_t_mailb +#define T_MAILA ns_t_maila +#define T_ANY ns_t_any + +#define C_IN ns_c_in +#define C_CHAOS ns_c_chaos +#define C_HS ns_c_hs +/* BIND_UPDATE */ +#define C_NONE ns_c_none +#define C_ANY ns_c_any + +#define GETSHORT NS_GET16 +#define GETLONG NS_GET32 +#define PUTSHORT NS_PUT16 +#define PUTLONG NS_PUT32 + +#ifdef __cplusplus +} +#endif + +#endif /* _ARPA_NAMESER_COMPAT_H */ diff --git a/illumos-x86_64/usr/include/arpa/telnet.h b/illumos-x86_64/usr/include/arpa/telnet.h new file mode 100644 index 00000000..71b374c5 --- /dev/null +++ b/illumos-x86_64/usr/include/arpa/telnet.h @@ -0,0 +1,431 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2016 by Delphix. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _ARPA_TELNET_H +#define _ARPA_TELNET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for the TELNET protocol. + */ +#define IAC 255 /* interpret as command: */ +#define DONT 254 /* you are not to use option */ +#define DO 253 /* please, you use option */ +#define WONT 252 /* I won't use option */ +#define WILL 251 /* I will use option */ +#define SB 250 /* interpret as subnegotiation */ +#define GA 249 /* you may reverse the line */ +#define EL 248 /* erase the current line */ +#define EC 247 /* erase the current character */ +#define AYT 246 /* are you there */ +#define AO 245 /* abort output--but let prog finish */ +#define IP 244 /* interrupt process--permanently */ +#define BREAK 243 /* break */ +#define DM 242 /* data mark--for connect. cleaning */ +#define NOP 241 /* nop */ +#define SE 240 /* end sub negotiation */ +#define EOR 239 /* end of record (transparent mode) */ +#define ABORT 238 /* Abort process */ +#define SUSP 237 /* Suspend process */ +#define xEOF 236 /* End of file: EOF is already used... */ + +#define SYNCH 242 /* for telfunc calls */ + +#ifdef TELCMDS +char *telcmds[] = { + "EOF", "SUSP", "ABORT", "EOR", + "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 +}; +#endif + +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] + +/* telnet options */ +#define TELOPT_BINARY 0 /* 8-bit data path */ +#define TELOPT_ECHO 1 /* echo */ +#define TELOPT_RCP 2 /* prepare to reconnect */ +#define TELOPT_SGA 3 /* suppress go ahead */ +#define TELOPT_NAMS 4 /* approximate message size */ +#define TELOPT_STATUS 5 /* give status */ +#define TELOPT_TM 6 /* timing mark */ +#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ +#define TELOPT_NAOL 8 /* negotiate about output line width */ +#define TELOPT_NAOP 9 /* negotiate about output page size */ +#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ +#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ +#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ +#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ +#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ +#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ +#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ +#define TELOPT_XASCII 17 /* extended ascic character set */ +#define TELOPT_LOGOUT 18 /* force logout */ +#define TELOPT_BM 19 /* byte macro */ +#define TELOPT_DET 20 /* data entry terminal */ +#define TELOPT_SUPDUP 21 /* supdup protocol */ +#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ +#define TELOPT_SNDLOC 23 /* send location */ +#define TELOPT_TTYPE 24 /* terminal type */ +#define TELOPT_EOR 25 /* end or record */ +#define TELOPT_TUID 26 /* TACACS user identification */ +#define TELOPT_OUTMRK 27 /* output marking */ +#define TELOPT_TTYLOC 28 /* terminal location number */ +#define TELOPT_3270REGIME 29 /* 3270 regime */ +#define TELOPT_X3PAD 30 /* X.3 PAD */ +#define TELOPT_NAWS 31 /* window size */ +#define TELOPT_TSPEED 32 /* terminal speed */ +#define TELOPT_LFLOW 33 /* remote flow control */ +#define TELOPT_LINEMODE 34 /* Linemode option */ +#define TELOPT_XDISPLOC 35 /* X Display Location */ +#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ +#define TELOPT_AUTHENTICATION 37 /* Authenticate */ +#define TELOPT_ENCRYPT 38 /* Encryption option */ +#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ +#define TELOPT_EXOPL 255 /* extended-options-list */ + +#ifdef TELOPTS +#define NTELOPTS (1+TELOPT_NEW_ENVIRON) +char *telopts[NTELOPTS+1] = { + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", + "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", + "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", + "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", + 0, +}; +#endif /* TELOPTS */ +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_NEW_ENVIRON +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] + +/* sub-option qualifiers */ +#define TELQUAL_IS 0 /* option is... */ +#define TELQUAL_SEND 1 /* send option */ +#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ +#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ +#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ + +#define LFLOW_OFF 0 /* Disable remote flow control */ +#define LFLOW_ON 1 /* Enable remote flow control */ +#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ +#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ + +/* + * LINEMODE suboptions + */ + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 +#define MODE_SOFT_TAB 0x08 +#define MODE_LIT_ECHO 0x10 + +#define MODE_MASK 0x1f + +/* Not part of protocol, but needed to simplify things... */ +#define MODE_FLOW 0x0100 +#define MODE_ECHO 0x0200 +#define MODE_INBIN 0x0400 +#define MODE_OUTBIN 0x0800 +#define MODE_FORCE 0x1000 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 + +#define NSLC 18 + +/* + * For backwards compatability, we define SLC_NAMES to be the + * list of names if SLC_NAMES is not defined. + */ +#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, +#ifdef SLC_NAMES +char *slc_names[] = { + SLC_NAMELIST +}; +#else +extern char *slc_names[]; +#define SLC_NAMES SLC_NAMELIST +#endif + +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) +#define SLC_NAME(x) slc_names[x] + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 + +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 +#define ENV_ESC 2 +#define ENV_USERVAR 3 + +/* + * AUTHENTICATION suboptions + */ +#define AUTH_REJECT 0 /* Rejected */ +#define AUTH_UNKNOWN 1 /* We don't know who it is, but it's okay */ +#define AUTH_OTHER 2 /* We know it, but not its name */ +#define AUTH_USER 3 /* We know its name */ +#define AUTH_VALID 4 /* We know it, and it needs no password */ + +/* + * Who is authenticating who ... + */ +#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ +#define AUTH_WHO_SERVER 1 /* Server authenticating client */ +#define AUTH_WHO_MASK 1 + +#ifdef AUTHWHO_STR +char *authwho_str[] = { + "CLIENT", "SERVER" }; +#define AUTHWHO_NAME(x) authwho_str[x] +#endif /* AUTHWHO_STR */ + +/* + * amount of authentication done + */ +#define AUTH_HOW_ONE_WAY 0 +#define AUTH_HOW_MUTUAL 2 +#define AUTH_HOW_MASK 2 + +/* + * should we be encrypting? (not yet formally standardized) + */ +#define AUTH_ENCRYPT_OFF 0 +#define AUTH_ENCRYPT_ON 4 +#define AUTH_ENCRYPT_MASK 4 + +#define AUTHTYPE_NULL 0 +#define AUTHTYPE_KERBEROS_V4 1 /* not supported */ +#define AUTHTYPE_KERBEROS_V5 2 +#define AUTHTYPE_CNT 3 + +#define OPTS_FORWARD_CREDS 0x00000002 +#define OPTS_FORWARDABLE_CREDS 0x00000001 + +#ifdef AUTHTYPE_NAMES +char *authtype_names[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", 0, +}; +#else +extern char *authtype_names[]; +#endif /* AUTHTYPE_NAMES */ + +#define AUTHTYPE_NAME(x) authtype_names[x] +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) + +#ifdef AUTHHOW_NAMES +char *authhow_names[] = { + "ONE-WAY", "[undefined]", "MUTUAL" }; +#endif /* AUTHHOW_NAMES */ + +#define AUTHHOW_NAME(x) authhow_names[x] + +#define KRB_AUTH 0 /* Authentication data follows */ +#define KRB_REJECT 1 /* Rejected (reason might follow) */ +#define KRB_ACCEPT 2 /* Accepted */ +#define KRB_RESPONSE 3 /* Response for mutual auth. */ +#define KRB_FORWARD 4 /* Forwarded credentials follow */ +#define KRB_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */ +#define KRB_FORWARD_REJECT 6 /* Forwarded credentials rejected */ + +#ifdef AUTHRSP_NAMES +char *authrsp_names[] = { + "AUTH", "REJECT", "ACCEPT", "RESPONSE", "FORWARD", + "FORWARD_ACCEPT", "FORWARD_REJECT" }; +#define AUTHRSP_NAME(x) authrsp_names[x] +#endif /* AUTHRSP_NAMES */ + +#define AUTH_MODE_REQUIRE 0 +#define AUTH_MODE_PROMPT 1 +#define AUTH_MODE_WARN 2 +#define AUTH_MODE_REJECT 3 + + +/* + * Encryption suboptions. See RFC 2946. + */ +#define ENCRYPT_IS 0 /* I pick encryption type ... */ +#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ +#define ENCRYPT_REPLY 2 /* Initial setup response */ +#define ENCRYPT_START 3 /* Starting encrypting output */ +#define ENCRYPT_END 4 /* End encrypting output */ +#define ENCRYPT_REQSTART 5 /* Request to start encrypting output */ +#define ENCRYPT_REQEND 6 /* Request to stop encrypting output */ +#define ENCRYPT_ENC_KEYID 7 /* Negotiate encryption key */ +#define ENCRYPT_DEC_KEYID 8 /* Negotiate decryption key */ +#define ENCRYPT_CNT 9 /* marks the maximum ENCRYPT value */ + +#define TELOPT_ENCTYPE_NULL 0 +#define TELOPT_ENCTYPE_DES_CFB64 1 /* 64-bit Cipher Feedback Mode */ +#define TELOPT_ENCTYPE_CNT 2 + +#define CFB64_IV 1 +#define CFB64_IV_OK 2 +#define CFB64_IV_BAD 3 + +#define FB64_IV CFB64_IV +#define FB64_IV_OK CFB64_IV_OK +#define FB64_IV_BAD CFB64_IV_BAD + +#ifdef ENCRYPT_NAMES +char *encrypt_names[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", + 0, +}; + +char *enctype_names[] = { + "ANY", "DES_CFB64", 0, +}; +#else +extern char *encrypt_names[]; +extern char *enctype_names[]; +#endif /* ENCRYPT_NAMES */ + +#define ENCRYPT_NAME(x) encrypt_names[x] +#define ENCTYPE_NAME(x) enctype_names[x] + +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < TELOPT_ENCTYPE_CNT) + +#define SK_DES 1 /* Matched Kerberos v5 ENCTYPE_DES */ + +#ifndef DES_BLOCKSIZE +#define DES_BLOCKSIZE 8 +#endif /* DES_BLOCKSIZE */ + +#define TELNET_MAXNUMKEYS 64 +#define TELNET_MAXKEYIDLEN 16 + +#define CFB 0 + +#define ENCR_STATE_FAILED -1 +#define ENCR_STATE_OK 0x00 +#define ENCR_STATE_NO_SEND_IV 0x01 +#define ENCR_STATE_NO_RECV_IV 0x02 +#define ENCR_STATE_NO_KEYID 0x04 +#define ENCR_STATE_NOT_READY 0x08 +#define ENCR_STATE_IN_PROGRESS \ + (ENCR_STATE_NO_SEND_IV|ENCR_STATE_NO_RECV_IV|ENCR_STATE_NO_KEYID) +#define TELNET_DIR_ENCRYPT 0 +#define TELNET_DIR_DECRYPT 1 + +typedef unsigned char Block[DES_BLOCKSIZE]; +typedef unsigned char *BlockT; +typedef struct { Block _; } Schedule[16]; + +typedef struct { + short type; + int length; + unsigned char *data; +} Session_Key; + +typedef struct { + unsigned char need_start; + unsigned char autoflag; /* automatically start operation */ + unsigned char setup; + unsigned char type; + unsigned int state; + unsigned char keyid[TELNET_MAXNUMKEYS]; + int keyidlen; + Block ivec; + Block krbdes_key; +} cipher_info_t; + +typedef struct { + cipher_info_t encrypt; + cipher_info_t decrypt; +} telnet_enc_data_t; + +/* A valid key has no "0" bytes */ +#define VALIDKEY(key) (key[0] | key[1] | key[2] | key[3] | \ + key[4] | key[5] | key[6] | key[7]) + + +#ifdef __cplusplus +} +#endif + +#endif /* _ARPA_TELNET_H */ diff --git a/illumos-x86_64/usr/include/arpa/tftp.h b/illumos-x86_64/usr/include/arpa/tftp.h new file mode 100644 index 00000000..8ee12ff2 --- /dev/null +++ b/illumos-x86_64/usr/include/arpa/tftp.h @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _ARPA_TFTP_H +#define _ARPA_TFTP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Trivial File Transfer Protocol (RFC 1350, RFC 2347) + */ +#define SEGSIZE 512 /* data segment size */ + +/* + * Packet types. + */ +#define RRQ 01 /* read request */ +#define WRQ 02 /* write request */ +#define DATA 03 /* data packet */ +#define ACK 04 /* acknowledgement */ +#define ERROR 05 /* error code */ +#define OACK 06 /* option acknowledgement */ + +struct tftphdr { + short th_opcode; /* packet type */ + ushort_t th_block; /* block # */ + char th_data[1]; /* data or error string */ +}; + +#define th_code th_block /* error code overlay on tu_block */ +#define th_stuff th_block /* ditto */ + +#define th_msg th_data + +/* + * Error codes. + */ +#define EUNDEF 0 /* not defined */ +#define ENOTFOUND 1 /* file not found */ +#define EACCESS 2 /* access violation */ +#define ENOSPACE 3 /* disk full or allocation exceeded */ +#define EBADOP 4 /* illegal TFTP operation */ +#define EBADID 5 /* unknown transfer ID */ +#define EEXISTS 6 /* file already exists */ +#define ENOUSER 7 /* no such user */ +#define EOPTNEG 8 /* option negotiation error */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ARPA_TFTP_H */ diff --git a/illumos-x86_64/usr/include/asm/atomic.h b/illumos-x86_64/usr/include/asm/atomic.h new file mode 100644 index 00000000..edbfad9c --- /dev/null +++ b/illumos-x86_64/usr/include/asm/atomic.h @@ -0,0 +1,271 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2015 Josef 'Jeff' Sipek + */ + +#ifndef _ASM_ATOMIC_H +#define _ASM_ATOMIC_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +/* BEGIN CSTYLED */ +/* + * This file contains a number of static inline functions implementing + * various atomic variable functions. Note that these are *not* all of the + * atomic_* functions as defined in usr/src/uts/common/sys/atomic.h. All + * possible atomic_* functions are implemented in usr/src/common/atomic in + * pure assembly. In the absence of an identically named function in this + * header file, any use of the function will result in the compiler emitting + * a function call as usual. On the other hand, if an identically named + * function exists in this header as a static inline, the compiler will + * inline its contents and the linker never sees the symbol reference. We + * use this to avoid implementing some of the more complex and less used + * functions and instead falling back to function calls. Note that in some + * cases (e.g., atomic_inc_64) we implement a static inline only on AMD64 + * but not i386. + */ + +/* + * Instruction suffixes for various operand sizes (assuming AMD64) + */ +#define SUF_8 "b" +#define SUF_16 "w" +#define SUF_32 "l" +#define SUF_64 "q" + +#if defined(__amd64) +#define SUF_LONG SUF_64 +#define SUF_PTR SUF_64 +#define __ATOMIC_OP64(...) __ATOMIC_OPXX(__VA_ARGS__) +#elif defined(__i386) +#define SUF_LONG SUF_32 +#define SUF_PTR SUF_32 +#define __ATOMIC_OP64(...) +#else +#error "port me" +#endif + +#if defined(__amd64) || defined(__i386) + +#define __ATOMIC_OPXX(fxn, type, op) \ +extern __GNU_INLINE void \ +fxn(volatile type *target) \ +{ \ + __asm__ __volatile__( \ + "lock; " op " %0" \ + : "+m" (*target) \ + : /* no inputs */ \ + : "cc"); \ +} + +__ATOMIC_OPXX(atomic_inc_8, uint8_t, "inc" SUF_8) +__ATOMIC_OPXX(atomic_inc_16, uint16_t, "inc" SUF_16) +__ATOMIC_OPXX(atomic_inc_32, uint32_t, "inc" SUF_32) +__ATOMIC_OP64(atomic_inc_64, uint64_t, "inc" SUF_64) +__ATOMIC_OPXX(atomic_inc_uchar, uchar_t, "inc" SUF_8) +__ATOMIC_OPXX(atomic_inc_ushort, ushort_t, "inc" SUF_16) +__ATOMIC_OPXX(atomic_inc_uint, uint_t, "inc" SUF_32) +__ATOMIC_OPXX(atomic_inc_ulong, ulong_t, "inc" SUF_LONG) + +__ATOMIC_OPXX(atomic_dec_8, uint8_t, "dec" SUF_8) +__ATOMIC_OPXX(atomic_dec_16, uint16_t, "dec" SUF_16) +__ATOMIC_OPXX(atomic_dec_32, uint32_t, "dec" SUF_32) +__ATOMIC_OP64(atomic_dec_64, uint64_t, "dec" SUF_64) +__ATOMIC_OPXX(atomic_dec_uchar, uchar_t, "dec" SUF_8) +__ATOMIC_OPXX(atomic_dec_ushort, ushort_t, "dec" SUF_16) +__ATOMIC_OPXX(atomic_dec_uint, uint_t, "dec" SUF_32) +__ATOMIC_OPXX(atomic_dec_ulong, ulong_t, "dec" SUF_LONG) + +#undef __ATOMIC_OPXX + +#define __ATOMIC_OPXX(fxn, type1, type2, op, reg) \ +extern __GNU_INLINE void \ +fxn(volatile type1 *target, type2 delta) \ +{ \ + __asm__ __volatile__( \ + "lock; " op " %1,%0" \ + : "+m" (*target) \ + : "i" reg (delta) \ + : "cc"); \ +} + +__ATOMIC_OPXX(atomic_add_8, uint8_t, int8_t, "add" SUF_8, "q") +__ATOMIC_OPXX(atomic_add_16, uint16_t, int16_t, "add" SUF_16, "r") +__ATOMIC_OPXX(atomic_add_32, uint32_t, int32_t, "add" SUF_32, "r") +__ATOMIC_OP64(atomic_add_64, uint64_t, int64_t, "add" SUF_64, "r") +__ATOMIC_OPXX(atomic_add_char, uchar_t, signed char, "add" SUF_8, "q") +__ATOMIC_OPXX(atomic_add_short, ushort_t, short, "add" SUF_16, "r") +__ATOMIC_OPXX(atomic_add_int, uint_t, int, "add" SUF_32, "r") +__ATOMIC_OPXX(atomic_add_long, ulong_t, long, "add" SUF_LONG, "r") + +/* + * We don't use the above macro here because atomic_add_ptr has an + * inconsistent type. The first argument should really be a 'volatile void + * **'. + */ +extern __GNU_INLINE void +atomic_add_ptr(volatile void *target, ssize_t delta) +{ + volatile void **tmp = (volatile void **)target; + + __asm__ __volatile__( + "lock; add" SUF_PTR " %1,%0" + : "+m" (*tmp) + : "ir" (delta) + : "cc"); +} + +__ATOMIC_OPXX(atomic_or_8, uint8_t, uint8_t, "or" SUF_8, "q") +__ATOMIC_OPXX(atomic_or_16, uint16_t, uint16_t, "or" SUF_16, "r") +__ATOMIC_OPXX(atomic_or_32, uint32_t, uint32_t, "or" SUF_32, "r") +__ATOMIC_OP64(atomic_or_64, uint64_t, uint64_t, "or" SUF_64, "r") +__ATOMIC_OPXX(atomic_or_uchar, uchar_t, uchar_t, "or" SUF_8, "q") +__ATOMIC_OPXX(atomic_or_ushort, ushort_t, ushort_t, "or" SUF_16, "r") +__ATOMIC_OPXX(atomic_or_uint, uint_t, uint_t, "or" SUF_32, "r") +__ATOMIC_OPXX(atomic_or_ulong, ulong_t, ulong_t, "or" SUF_LONG, "r") + +__ATOMIC_OPXX(atomic_and_8, uint8_t, uint8_t, "and" SUF_8, "q") +__ATOMIC_OPXX(atomic_and_16, uint16_t, uint16_t, "and" SUF_16, "r") +__ATOMIC_OPXX(atomic_and_32, uint32_t, uint32_t, "and" SUF_32, "r") +__ATOMIC_OP64(atomic_and_64, uint64_t, uint64_t, "and" SUF_64, "r") +__ATOMIC_OPXX(atomic_and_uchar, uchar_t, uchar_t, "and" SUF_8, "q") +__ATOMIC_OPXX(atomic_and_ushort, ushort_t, ushort_t, "and" SUF_16, "r") +__ATOMIC_OPXX(atomic_and_uint, uint_t, uint_t, "and" SUF_32, "r") +__ATOMIC_OPXX(atomic_and_ulong, ulong_t, ulong_t, "and" SUF_LONG, "r") + +#undef __ATOMIC_OPXX + +#define __ATOMIC_OPXX(fxn, type, op, reg) \ +extern __GNU_INLINE type \ +fxn(volatile type *target, type cmp, type new) \ +{ \ + type ret; \ + __asm__ __volatile__( \ + "lock; " op " %2,%0" \ + : "+m" (*target), "=a" (ret) \ + : reg (new), "1" (cmp) \ + : "cc"); \ + return (ret); \ +} + +__ATOMIC_OPXX(atomic_cas_8, uint8_t, "cmpxchg" SUF_8, "q") +__ATOMIC_OPXX(atomic_cas_16, uint16_t, "cmpxchg" SUF_16, "r") +__ATOMIC_OPXX(atomic_cas_32, uint32_t, "cmpxchg" SUF_32, "r") +__ATOMIC_OP64(atomic_cas_64, uint64_t, "cmpxchg" SUF_64, "r") +__ATOMIC_OPXX(atomic_cas_uchar, uchar_t, "cmpxchg" SUF_8, "q") +__ATOMIC_OPXX(atomic_cas_ushort, ushort_t, "cmpxchg" SUF_16, "r") +__ATOMIC_OPXX(atomic_cas_uint, uint_t, "cmpxchg" SUF_32, "r") +__ATOMIC_OPXX(atomic_cas_ulong, ulong_t, "cmpxchg" SUF_LONG, "r") + +#undef __ATOMIC_OPXX + +/* + * We don't use the above macro here because atomic_cas_ptr has an + * inconsistent type. The first argument should really be a 'volatile void + * **'. + */ +extern __GNU_INLINE void * +atomic_cas_ptr(volatile void *target, void *cmp, void *new) +{ + volatile void **tmp = (volatile void **)target; + void *ret; + + __asm__ __volatile__( + "lock; cmpxchg" SUF_PTR " %2,%0" + : "+m" (*tmp), "=a" (ret) + : "r" (new), "1" (cmp) + : "cc"); + + return (ret); +} + +#define __ATOMIC_OPXX(fxn, type, op, reg) \ +extern __GNU_INLINE type \ +fxn(volatile type *target, type val) \ +{ \ + __asm__ __volatile__( \ + op " %1,%0" \ + : "+m" (*target), "+" reg (val)); \ + return (val); \ +} + +__ATOMIC_OPXX(atomic_swap_8, uint8_t, "xchg" SUF_8, "q") +__ATOMIC_OPXX(atomic_swap_16, uint16_t, "xchg" SUF_16, "r") +__ATOMIC_OPXX(atomic_swap_32, uint32_t, "xchg" SUF_32, "r") +__ATOMIC_OP64(atomic_swap_64, uint64_t, "xchg" SUF_64, "r") +__ATOMIC_OPXX(atomic_swap_uchar, uchar_t, "xchg" SUF_8, "q") +__ATOMIC_OPXX(atomic_swap_ushort, ushort_t, "xchg" SUF_16, "r") +__ATOMIC_OPXX(atomic_swap_uint, uint_t, "xchg" SUF_32, "r") +__ATOMIC_OPXX(atomic_swap_ulong, ulong_t, "xchg" SUF_LONG, "r") + +#undef __ATOMIC_OPXX + +/* + * We don't use the above macro here because atomic_swap_ptr has an + * inconsistent type. The first argument should really be a 'volatile void + * **'. + */ +extern __GNU_INLINE void * +atomic_swap_ptr(volatile void *target, void *val) +{ + volatile void **tmp = (volatile void **)target; + + __asm__ __volatile__( + "xchg" SUF_PTR " %1,%0" + : "+m" (*tmp), "+r" (val)); + + return (val); +} + +#else +#error "port me" +#endif + +#undef SUF_8 +#undef SUF_16 +#undef SUF_32 +#undef SUF_64 +#undef SUF_LONG +#undef SUF_PTR + +#undef __ATOMIC_OP64 + +/* END CSTYLED */ + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_ATOMIC_H */ diff --git a/illumos-x86_64/usr/include/asm/bitmap.h b/illumos-x86_64/usr/include/asm/bitmap.h new file mode 100644 index 00000000..92020e39 --- /dev/null +++ b/illumos-x86_64/usr/include/asm/bitmap.h @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _ASM_BITMAP_H +#define _ASM_BITMAP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +#if defined(__amd64) +#define __SUF "q" +#elif defined(__i386) +#define __SUF "l" +#else +#error "port me" +#endif + +extern __GNU_INLINE int +highbit(ulong_t i) +{ + long value; + uint8_t zf; + + __asm__( + "bsr" __SUF " %2,%0;" + "setz %1" + : "=r" (value), "=q" (zf) + : "mr" (i) + : "cc"); + + return (zf ? 0 : (value + 1)); +} + +extern __GNU_INLINE int +lowbit(ulong_t i) +{ + long value; + uint8_t zf; + + __asm__( + "bsf" __SUF " %2,%0;" + "setz %1" + : "=r" (value), "=q" (zf) + : "mr" (i) + : "cc"); + + return (zf ? 0 : (value + 1)); +} + +extern __GNU_INLINE uint_t +atomic_btr32(uint32_t *memory, uint_t bitnum) +{ + uint8_t value; + + __asm__ __volatile__( + "lock;" + "btrl %2,%0;" + "setc %1" + : "+m" (*memory), "=r" (value) + : "ir" (bitnum) + : "cc"); + + return ((uint_t)value); +} + +#undef __SUF + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_BITMAP_H */ diff --git a/illumos-x86_64/usr/include/asm/byteorder.h b/illumos-x86_64/usr/include/asm/byteorder.h new file mode 100644 index 00000000..3797d4f3 --- /dev/null +++ b/illumos-x86_64/usr/include/asm/byteorder.h @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ASM_BYTEORDER_H +#define _ASM_BYTEORDER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +/* + * htonll(), ntohll(), htonl(), ntohl(), htons(), ntohs() + * These functions reverse the byte order of the input parameter and returns + * the result. This is to convert the byte order from host byte order + * (little endian) to network byte order (big endian), or vice versa. + */ + + +#if defined(__i386) || defined(__amd64) + +extern __GNU_INLINE uint16_t +htons(uint16_t value) +{ +#if defined(__amd64) + __asm__("xchgb %h0, %b0" : "+Q" (value)); +#elif defined(__i386) + __asm__("xchgb %h0, %b0" : "+q" (value)); +#endif + return (value); +} + +extern __GNU_INLINE uint16_t +ntohs(uint16_t value) +{ +#if defined(__amd64) + __asm__("xchgb %h0, %b0" : "+Q" (value)); +#elif defined(__i386) + __asm__("xchgb %h0, %b0" : "+q" (value)); +#endif + return (value); +} + +extern __GNU_INLINE uint32_t +htonl(uint32_t value) +{ + __asm__("bswap %0" : "+r" (value)); + return (value); +} + +extern __GNU_INLINE uint32_t +ntohl(uint32_t value) +{ + __asm__("bswap %0" : "+r" (value)); + return (value); +} + +#if defined(__amd64) +extern __GNU_INLINE uint64_t +htonll(uint64_t value) +{ + __asm__("bswapq %0" : "+r" (value)); + return (value); +} + +extern __GNU_INLINE uint64_t +ntohll(uint64_t value) +{ + __asm__("bswapq %0" : "+r" (value)); + return (value); +} + +#elif defined(__i386) +/* Use the htonl() and ntohl() inline functions defined above */ +extern __GNU_INLINE uint64_t +htonll(uint64_t value) +{ + return (htonl(value >> 32) | ((uint64_t)htonl(value) << 32)); +} + +extern __GNU_INLINE uint64_t +ntohll(uint64_t value) +{ + return (ntohl(value >> 32) | (uint64_t)ntohl(value) << 32); +} +#endif /* __amd64 */ + +#endif /* __i386 || __amd64 */ + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_BYTEORDER_H */ diff --git a/illumos-x86_64/usr/include/asm/clock.h b/illumos-x86_64/usr/include/asm/clock.h new file mode 100644 index 00000000..26e33d0b --- /dev/null +++ b/illumos-x86_64/usr/include/asm/clock.h @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ASM_CLOCK_H +#define _ASM_CLOCK_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +#include + +extern __GNU_INLINE void +unlock_hres_lock(void) +{ + __asm__ __volatile__( + "lock; incl %0" + : /* no output */ + : "m" (hres_lock) + : "cc"); +} + +#if defined(__xpv) + +extern __GNU_INLINE hrtime_t +__rdtsc_insn(void) +{ +#if defined(__amd64) + uint32_t lobits, hibits; + + __asm__ __volatile__( + "rdtsc" + : "=a" (lobits), "=d" (hibits)); + return (lobits | ((hrtime_t)hibits << 32)); +#elif defined(__i386) + hrtime_t __value; + + __asm__ __volatile__( + "rdtsc" + : "=A" (__value)); + return (__value); +#else +#error "port me" +#endif +} + +#endif /* __xpv */ + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_CLOCK_H */ diff --git a/illumos-x86_64/usr/include/asm/cpu.h b/illumos-x86_64/usr/include/asm/cpu.h new file mode 100644 index 00000000..95e88260 --- /dev/null +++ b/illumos-x86_64/usr/include/asm/cpu.h @@ -0,0 +1,183 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _ASM_CPU_H +#define _ASM_CPU_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +#if defined(__i386) || defined(__amd64) + +extern __GNU_INLINE void +ht_pause(void) +{ + __asm__ __volatile__( + "pause"); +} + +/* + * prefetch 64 bytes + * + * prefetch is an SSE extension which is not supported on + * older 32-bit processors, so define this as a no-op for now + */ + +extern __GNU_INLINE void +prefetch_read_many(void *addr) +{ +#if defined(__amd64) + __asm__( + "prefetcht0 (%0);" + "prefetcht0 32(%0);" + : /* no output */ + : "r" (addr)); +#endif /* __amd64 */ +} + +extern __GNU_INLINE void +prefetch_read_once(void *addr) +{ +#if defined(__amd64) + __asm__( + "prefetchnta (%0);" + "prefetchnta 32(%0);" + : /* no output */ + : "r" (addr)); +#endif /* __amd64 */ +} + +extern __GNU_INLINE void +prefetch_write_many(void *addr) +{ +#if defined(__amd64) + __asm__( + "prefetcht0 (%0);" + "prefetcht0 32(%0);" + : /* no output */ + : "r" (addr)); +#endif /* __amd64 */ +} + +extern __GNU_INLINE void +prefetch_write_once(void *addr) +{ +#if defined(__amd64) + __asm__( + "prefetcht0 (%0);" + "prefetcht0 32(%0);" + : /* no output */ + : "r" (addr)); +#endif /* __amd64 */ +} + +#if !defined(__xpv) + +extern __GNU_INLINE void +cli(void) +{ + __asm__ __volatile__( + "cli" : : : "memory"); +} + +extern __GNU_INLINE void +sti(void) +{ + __asm__ __volatile__( + "sti"); +} + +/* + * Any newer callers of halt need to make sure that they consider calling + * x86_md_clear() before calling this to deal with any potential issues with + * MDS. Because this version of hlt is also used in panic context, we do not + * unconditionally call x86_md_clear() here and require callers to do so. + */ +extern __GNU_INLINE void +i86_halt(void) +{ + __asm__ __volatile__( + "sti; hlt"); +} + +#endif /* !__xpv */ + +#endif /* __i386 || defined(__amd64) */ + +#if defined(__amd64) + +extern __GNU_INLINE void +__set_ds(selector_t value) +{ + __asm__ __volatile__( + "movw %0, %%ds" + : /* no output */ + : "r" (value)); +} + +extern __GNU_INLINE void +__set_es(selector_t value) +{ + __asm__ __volatile__( + "movw %0, %%es" + : /* no output */ + : "r" (value)); +} + +extern __GNU_INLINE void +__set_fs(selector_t value) +{ + __asm__ __volatile__( + "movw %0, %%fs" + : /* no output */ + : "r" (value)); +} + +extern __GNU_INLINE void +__set_gs(selector_t value) +{ + __asm__ __volatile__( + "movw %0, %%gs" + : /* no output */ + : "r" (value)); +} + +#endif /* __amd64 */ + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_CPU_H */ diff --git a/illumos-x86_64/usr/include/asm/cpuvar.h b/illumos-x86_64/usr/include/asm/cpuvar.h new file mode 100644 index 00000000..efb09d66 --- /dev/null +++ b/illumos-x86_64/usr/include/asm/cpuvar.h @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ASM_CPUVAR_H +#define _ASM_CPUVAR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +struct cpu; + +extern __GNU_INLINE struct cpu * +curcpup(void) +{ + struct cpu *__value; + +#if defined(__amd64) + __asm__ __volatile__( + "movq %%gs:0x10,%0" /* CPU_SELF */ + : "=r" (__value)); +#elif defined(__i386) + __asm__ __volatile__( + "movl %%gs:0xc,%0" /* CPU_SELF */ + : "=r" (__value)); +#else +#error "port me" +#endif + return (__value); +} + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_CPUVAR_H */ diff --git a/illumos-x86_64/usr/include/asm/htable.h b/illumos-x86_64/usr/include/asm/htable.h new file mode 100644 index 00000000..2601111c --- /dev/null +++ b/illumos-x86_64/usr/include/asm/htable.h @@ -0,0 +1,92 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _ASM_HTABLE_H +#define _ASM_HTABLE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +/* + * This set of atomic operations are designed primarily + * for some ia32 hat layer operations. + */ + +extern __GNU_INLINE void +atomic_orb(uint8_t *addr, uint8_t value) +{ + __asm__ __volatile__( + "lock; orb %%dl,%0" + : "=m" (*addr) + : "d" (value), "m" (*addr) + : "cc"); +} + +extern __GNU_INLINE void +atomic_andb(uint8_t *addr, uint8_t value) +{ + __asm__ __volatile__( + "lock; andb %%dl,%0" + : "=m" (*addr) + : "d" (value), "m" (*addr) + : "cc"); +} + +extern __GNU_INLINE void +atomic_inc16(uint16_t *addr) +{ + __asm__ __volatile__( + "lock; incw %0" + : "=m" (*addr) + : "m" (*addr) + : "cc"); +} + +extern __GNU_INLINE void +atomic_dec16(uint16_t *addr) +{ + __asm__ __volatile__( + "lock; decw %0" + : "=m" (*addr) + : "m" (*addr) + : "cc"); +} + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_HTABLE_H */ diff --git a/illumos-x86_64/usr/include/asm/mmu.h b/illumos-x86_64/usr/include/asm/mmu.h new file mode 100644 index 00000000..bd3e69a9 --- /dev/null +++ b/illumos-x86_64/usr/include/asm/mmu.h @@ -0,0 +1,120 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _ASM_MMU_H +#define _ASM_MMU_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__GNUC__) + +#if !defined(__xpv) + +extern __GNU_INLINE ulong_t +getcr3(void) +{ + uint64_t value; + + __asm__ __volatile__( + "movq %%cr3, %0" + : "=r" (value)); + return (value); +} + +extern __GNU_INLINE void +setcr3(ulong_t value) +{ + __asm__ __volatile__( + "movq %0, %%cr3" + : /* no output */ + : "r" (value)); +} + +extern __GNU_INLINE ulong_t +getcr4(void) +{ + uint64_t value; + + __asm__ __volatile__( + "movq %%cr4, %0" + : "=r" (value)); + return (value); +} + +extern __GNU_INLINE void +setcr4(ulong_t value) +{ + __asm__ __volatile__( + "movq %0, %%cr4" + : /* no output */ + : "r" (value)); +} + +extern __GNU_INLINE void +reload_cr3(void) +{ + setcr3(getcr3()); +} + +/* + * We clobber memory: we're not writing anything, but we don't want to + * potentially get re-ordered beyond the TLB flush. + */ +extern __GNU_INLINE void +invpcid_insn(uint64_t type, uint64_t pcid, uintptr_t addr) +{ + uint64_t pcid_desc[2] = { pcid, addr }; + __asm__ __volatile__( + "invpcid %0, %1" + : /* no output */ + : "m" (*pcid_desc), "r" (type) + : "memory"); +} + +#endif /* !__xpv */ + +extern __GNU_INLINE void +mmu_invlpg(caddr_t addr) +{ + __asm__ __volatile__( + "invlpg %0" + : "=m" (*addr) + : "m" (*addr)); +} + +#endif /* __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_MMU_H */ diff --git a/illumos-x86_64/usr/include/asm/sunddi.h b/illumos-x86_64/usr/include/asm/sunddi.h new file mode 100644 index 00000000..0b7025a6 --- /dev/null +++ b/illumos-x86_64/usr/include/asm/sunddi.h @@ -0,0 +1,131 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ASM_SUNDDI_H +#define _ASM_SUNDDI_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +#if defined(__i386) || defined(__amd64) + +extern __GNU_INLINE uint8_t +inb(int port) +{ + uint16_t port16 = (uint16_t)port; + uint8_t value; + + __asm__ __volatile__( + "inb (%1)" /* value in %al */ + : "=a" (value) + : "d" (port16)); + return (value); +} + +extern __GNU_INLINE uint16_t +inw(int port) +{ + uint16_t port16 = (uint16_t)port; + uint16_t value; + + __asm__ __volatile__( + "inw (%1)" /* value in %ax */ + : "=a" (value) + : "d" (port16)); + return (value); +} + +extern __GNU_INLINE uint32_t +inl(int port) +{ + uint16_t port16 = (uint16_t)port; + uint32_t value; + + __asm__ __volatile__( + "inl (%1)" /* value in %eax */ + : "=a" (value) + : "d" (port16)); + return (value); +} + +extern __GNU_INLINE void +outb(int port, uint8_t value) +{ + uint16_t port16 = (uint16_t)port; + + __asm__ __volatile__( + "outb (%1)" + : /* no output */ + : "a" (value), "d" (port16)); +} + +extern __GNU_INLINE void +outw(int port, uint16_t value) +{ + uint16_t port16 = (uint16_t)port; + + __asm__ __volatile__( + "outw (%1)" + : /* no output */ + : "a" (value), "d" (port16)); +} + +extern __GNU_INLINE void +outl(int port, uint32_t value) +{ + uint16_t port16 = (uint16_t)port; + + __asm__ __volatile__( + "outl (%1)" + : /* no output */ + : "a" (value), "d" (port16)); +} + +#if defined(_BOOT) + +extern __GNU_INLINE void +sync_instruction_memory(caddr_t v, size_t len) +{ + __asm__ __volatile__("nop"); +} + +#endif /* _BOOT */ + +#endif /* __i386 || __amd64 */ + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_SUNDDI_H */ diff --git a/illumos-x86_64/usr/include/asm/thread.h b/illumos-x86_64/usr/include/asm/thread.h new file mode 100644 index 00000000..620c2c3c --- /dev/null +++ b/illumos-x86_64/usr/include/asm/thread.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _ASM_THREAD_H +#define _ASM_THREAD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__lint) && defined(__GNUC__) + +struct _kthread; + +/* + * 0x10 is offsetof(struct cpu, cpu_thread) + * 0x18 is the same thing for the _LP64 version. + * (It's also the value of CPU_THREAD in assym.h) + * Yuck. + */ + +extern __GNU_INLINE struct _kthread +*threadp(void) +{ + struct _kthread *__value; + +#if defined(__amd64) + __asm__ __volatile__( + "movq %%gs:0x18,%0" /* CPU_THREAD */ + : "=r" (__value)); +#elif defined(__i386) + __asm__ __volatile__( + "movl %%gs:0x10,%0" /* CPU_THREAD */ + : "=r" (__value)); +#else +#error "port me" +#endif + return (__value); +} + +#endif /* !__lint && __GNUC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM_THREAD_H */ diff --git a/illumos-x86_64/usr/include/assert.h b/illumos-x86_64/usr/include/assert.h new file mode 100644 index 00000000..516f6ebd --- /dev/null +++ b/illumos-x86_64/usr/include/assert.h @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2016 Joyent, Inc. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2023 Oxide Computer Company + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Note that the ANSI C Standard requires all headers to be idempotent except + * which is explicitly required not to be idempotent (section 4.1.2). + * We split up the idempotent sections into and leave the + * rest of this that should be impacted by NDEBUG here. There is no header + * guard. This is intentional. For more information on the split, see + * . + */ + +#include + +#undef assert + +#ifdef NDEBUG + +#define assert(EX) ((void)0) + +#else + +#if __STDC_VERSION__ - 0 >= 199901L +#define assert(EX) (void)((EX) || \ + (__assert_c99(#EX, __FILE__, __LINE__, __func__), 0)) +#else +#define assert(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0)) +#endif /* __STDC_VERSION__ - 0 >= 199901L */ + +#endif /* NDEBUG */ diff --git a/illumos-x86_64/usr/include/ast/align.h b/illumos-x86_64/usr/include/ast/align.h new file mode 100644 index 00000000..199548d3 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/align.h @@ -0,0 +1,68 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/align.c by iffe version 2012-07-17 : : */ +#ifndef _def_align_ast +#define _def_align_ast 1 +#define _sys_types 1 /* #include ok */ + +#define ALIGN_CHUNK 8192 +#define ALIGN_INTEGRAL uintptr_t +#define ALIGN_INTEGER(x) ((char*)(x)-(char*)0) +#define ALIGN_POINTER(x) ((char*)(x)) +#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1)) + +#define ALIGN_BOUND ALIGN_BOUND2 +#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x) +#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x) + +#define ALIGN_BIT1 0x1 +#define ALIGN_BOUND1 ALIGN_BOUND2 +#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x) +#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x) +#ifndef __amd64 +#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffe) +#else /* __amd64 */ +#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffe) +#endif /* __amd64 */ +#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1) +#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1) + +#define ALIGN_BIT2 0x2 +#ifndef __amd64 +#define ALIGN_BOUND2 4 +#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+3) +#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffc) +#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffd) +#else /* __amd64 */ +#define ALIGN_BOUND2 16 +#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+15) +#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffff0) +#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffd) +#endif /* __amd64 */ +#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2) +#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2) + +#endif diff --git a/illumos-x86_64/usr/include/ast/aso.h b/illumos-x86_64/usr/include/ast/aso.h new file mode 100644 index 00000000..dac18f46 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/aso.h @@ -0,0 +1,189 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +#ifndef _ASO_H +#define _ASO_H 1 + +#define ASO_VERSION 20111111L + +#include + +/* + * ast atomic scalar operations interface definitions + */ + +/* asometh() types (ordered mutually exclusive flags) */ +#define ASO_NEXT (-1) +#define ASO_SIGNAL 1 +#define ASO_THREAD 2 +#define ASO_PROCESS 4 +#define ASO_INTRINSIC 8 + +/* asolock() operations */ +#define ASO_UNLOCK 0 /* unlock if key matches */ +#define ASO_TRYLOCK 1 /* matched key means successful attempt */ +#define ASO_LOCK 2 /* matched key first, then spin-lock */ +#define ASO_SPINLOCK 3 /* no matching of key before locking */ + +/* Asoerror_f types */ +#define ASO_EMETHOD 0 /* method specific error */ +#define ASO_EHUNG 1 /* asoloop() possibly hung */ + +/* for internal use, but standardized for libs such as CDT and Vmalloc */ +#define ASO_RELAX ((1<<2)-1) /* cycles between spin-loop yield */ +#define ASOLOOP(k) asoloop(++(k)) + +#define ASODISC(d,e) (memset(d,0,sizeof(*(d))),(d)->version=ASO_VERSION,(d)->errorf=(e)) + +typedef int (*Asoerror_f)(int, const char*); +typedef void* (*Asoinit_f)(void*, const char*); +typedef ssize_t (*Asolock_f)(void*, ssize_t, void volatile*); + +typedef struct Asodisc_s +{ + uint32_t version; + unsigned int hung; + Asoerror_f errorf; +} Asodisc_t; + +typedef struct Asometh_s +{ + const char* name; + int type; + Asoinit_f initf; + Asolock_f lockf; + const char* details; +} Asometh_t; + +#if (_BLD_aso || _BLD_taso) && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !(_BLD_aso || _BLD_taso) && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Asometh_t* asometh(int, void*); + +#undef extern + +#if _BLD_aso && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_aso && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Asometh_t* _asometh(int, void*); +extern int asoinit(const char*, Asometh_t*, Asodisc_t*); +extern int asolock(unsigned int volatile*, unsigned int, int); +extern int asoloop(uintmax_t); +extern int asorelax(long); + +extern uint8_t asocas8(uint8_t volatile*, int, int); +extern uint8_t asoget8(uint8_t volatile*); +extern uint8_t asoinc8(uint8_t volatile*); +extern uint8_t asodec8(uint8_t volatile*); + +#define asocaschar(p,o,n) asocas8(p,o,n) +#define asogetchar(p) asoget8(p) +#define asoincchar(p) asoinc8(p) +#define asodecchar(p) asodec8(p) + +extern uint16_t asocas16(uint16_t volatile*, uint16_t, uint16_t); +extern uint16_t asoget16(uint16_t volatile*); +extern uint16_t asoinc16(uint16_t volatile*); +extern uint16_t asodec16(uint16_t volatile*); + +#define asocasshort(p,o,n) asocas16(p,o,n) +#define asogetshort(p) asoget16(p) +#define asoincshort(p) asoinc16(p) +#define asodecshort(p) asodec16(p) + +extern uint32_t asocas32(uint32_t volatile*, uint32_t, uint32_t); +extern uint32_t asoget32(uint32_t volatile*); +extern uint32_t asoinc32(uint32_t volatile*); +extern uint32_t asodec32(uint32_t volatile*); + +#if _ast_sizeof_int == 4 +#define asocasint(p,o,n) asocas32((uint32_t volatile*)p,o,n) +#define asogetint(p) asoget32((uint32_t volatile*)p) +#define asoincint(p) asoinc32((uint32_t volatile*)p) +#define asodecint(p) asodec32((uint32_t volatile*)p) +#endif + +#if _ast_sizeof_long == 4 +#define asocaslong(p,o,n) asocas32((uint32_t volatile*)p,o,n) +#define asogetlong(p) asoget32((uint32_t volatile*)p) +#define asoinclong(p) asoinc32((uint32_t volatile*)p) +#define asodeclong(p) asodec32((uint32_t volatile*)p) +#endif + +#if _ast_sizeof_size_t == 4 +#define asocassize(p,o,n) asocas32((uint32_t volatile*)p,o,n) +#define asogetsize(p) asoget32((uint32_t volatile*)p) +#define asoincsize(p) asoinc32((uint32_t volatile*)p) +#define asodecsize(p) asodec32((uint32_t volatile*)p) +#endif + +#ifdef _ast_int8_t + +extern uint64_t asocas64(uint64_t volatile*, uint64_t, uint64_t); +extern uint64_t asoget64(uint64_t volatile*); +extern uint64_t asoinc64(uint64_t volatile*); +extern uint64_t asodec64(uint64_t volatile*); + +#if _ast_sizeof_int == 8 +#define asocasint(p,o,n) asocas64((uint64_t volatile*)p,o,n) +#define asogetint(p) asoget64((uint64_t volatile*)p) +#define asoincint(p) asoinc64((uint64_t volatile*)p) +#define asodecint(p) asodec64((uint64_t volatile*)p) +#endif + +#if _ast_sizeof_long == 8 +#define asocaslong(p,o,n) asocas64((uint64_t volatile*)p,o,n) +#define asogetlong(p) asoget64((uint64_t volatile*)p) +#define asoinclong(p) asoinc64((uint64_t volatile*)p) +#define asodeclong(p) asodec64((uint64_t volatile*)p) +#endif + +#if _ast_sizeof_size_t == 8 +#define asocassize(p,o,n) asocas64((uint64_t volatile*)p,o,n) +#define asogetsize(p) asoget64((uint64_t volatile*)p) +#define asoincsize(p) asoinc64((uint64_t volatile*)p) +#define asodecsize(p) asodec64((uint64_t volatile*)p) +#endif + +#endif + +extern void* asocasptr(void volatile*, void*, void*); +extern void* asogetptr(void volatile*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast.h b/illumos-x86_64/usr/include/ast/ast.h new file mode 100644 index 00000000..07197517 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast.h @@ -0,0 +1,412 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Advanced Software Technology Library + * AT&T Research + * + * std + posix + ast + */ + +#ifndef _AST_H +#define _AST_H + +#ifndef _AST_STD_H +#include +#endif + +#ifndef _SFIO_H +#include +#endif + +#ifndef ast +#define ast _ast_info +#endif + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +/* + * workaround botched headers that assume + */ + +#ifndef FILE +#ifndef _SFIO_H +struct _sfio_s; +#endif +#define FILE struct _sfio_s +#ifndef __FILE_typedef +#define __FILE_typedef 1 +#endif +#ifndef _FILEDEFED +#define _FILEDEFED 1 +#endif +#endif + +/* + * exit() support -- this matches shell exit codes + */ + +#define EXIT_BITS 8 /* # exit status bits */ + +#define EXIT_USAGE 2 /* usage exit code */ +#define EXIT_QUIT ((1<<(EXIT_BITS))-1) /* parent should quit */ +#define EXIT_NOTFOUND ((1<<(EXIT_BITS-1))-1) /* command not found */ +#define EXIT_NOEXEC ((1<<(EXIT_BITS-1))-2) /* other exec error */ + +#define EXIT_CODE(x) ((x)&((1<>EXIT_BITS)) + +#define EXITED_CORE(x) (((x)&((1<1) + +#define mb2wc(w,p,n) (*ast.mb_towc)(&w,(char*)p,n) +#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p+=ast.mb_sync+1,ast.tmp_int)):(*(unsigned char*)(p++))) +#define mbnchar(p,n) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),n))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p+=ast.mb_sync+1,ast.tmp_int)):(*(unsigned char*)(p++))) +#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0) +#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1)) +#define mbnsize(p,n) (mbwide()?(*ast.mb_len)((char*)(p),n):((p),1)) +#define mbconv(s,w) (ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1)) +#define mbwidth(w) (ast.mb_width?(*ast.mb_width)(w):1) +#define mbxfrm(t,f,n) (mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0) +#define mbalpha(w) (ast.mb_alpha?(*ast.mb_alpha)(w):isalpha((w)&0xff)) + +/* + * common macros + */ + +#define elementsof(x) (sizeof(x)/sizeof(x[0])) +#define integralof(x) (((char*)(x))-((char*)0)) +#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x))) +#define oldof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)malloc(sizeof(t)*(n)+(x))) +#define pointerof(x) ((void*)((char*)0+(x))) +#define roundof(x,y) (((x)+(y)-1)&~((y)-1)) +#define ssizeof(x) ((int)sizeof(x)) + +#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b)) +#define strneq(a,b,n) (*(a)==*(b)&&!strncmp(a,b,n)) +#define strsignal(s) fmtsignal(s) + +#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) +#define NiL 0 +#define NoP(x) (void)(x) +#else +#define NiL ((char*)0) +#define NoP(x) (&x,1) +#endif + +#if !defined(NoF) +#define NoF(x) void _DATA_ ## x () {} +#if !defined(_DATA_) +#define _DATA_ +#endif +#endif + +#if !defined(NoN) +#define NoN(x) void _STUB_ ## x () {} +#if !defined(_STUB_) +#define _STUB_ +#endif +#endif + +#define NOT_USED(x) NoP(x) + +typedef int (*Error_f)(void*, void*, int, ...); + +typedef int (*Ast_confdisc_f)(const char*, const char*, const char*); +typedef int (*Strcmp_context_f)(const char*, const char*, void*); +typedef int (*Strcmp_f)(const char*, const char*); + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* astgetconf(const char*, const char*, const char*, int, Error_f); +extern char* astconf(const char*, const char*, const char*); +extern Ast_confdisc_f astconfdisc(Ast_confdisc_f); +extern void astconflist(Sfio_t*, const char*, int, const char*); +extern off_t astcopy(int, int, off_t); +extern int astlicense(char*, int, char*, char*, int, int, int); +extern int astquery(int, const char*, ...); +extern void astwinsize(int, int*, int*); + +extern ssize_t base64encode(const void*, size_t, void**, void*, size_t, void**); +extern ssize_t base64decode(const void*, size_t, void**, void*, size_t, void**); +extern int chresc(const char*, char**); +extern int chrexp(const char*, char**, int*, int); +extern int chrtoi(const char*); +extern char* conformance(const char*, size_t); +extern int eaccess(const char*, int); +extern char* fmtbase(intmax_t, int, int); +#define fmtbasell(a,b,c) fmtbase(a,b,c) /* until 2014-01-01 */ +extern char* fmtbuf(size_t); +extern char* fmtclock(Sfulong_t); +extern char* fmtelapsed(unsigned long, int); +extern char* fmterror(int); +extern char* fmtesc(const char*); +extern char* fmtesq(const char*, const char*); +extern char* fmtident(const char*); +extern char* fmtip4(uint32_t, int); +extern char* fmtfmt(const char*); +extern char* fmtgid(int); +extern char* fmtint(intmax_t, int); +extern char* fmtmatch(const char*); +extern char* fmtmode(int, int); +extern char* fmtnesq(const char*, const char*, size_t); +extern char* fmtnum(unsigned long, int); +extern char* fmtperm(int); +extern char* fmtquote(const char*, const char*, const char*, size_t, int); +extern char* fmtre(const char*); +extern char* fmtscale(Sfulong_t, int); +extern char* fmtsignal(int); +extern char* fmttime(const char*, time_t); +extern char* fmtuid(int); +extern char* fmtversion(unsigned long); +extern void* memdup(const void*, size_t); +extern void memfatal(void); +extern unsigned int memhash(const void*, int); +extern unsigned long memsum(const void*, int, unsigned long); +extern char* pathaccess(char*, const char*, const char*, const char*, int); +extern char* pathaccess_20100601(const char*, const char*, const char*, int, char*, size_t); +extern char* pathbin(void); +extern char* pathcanon(char*, int); +extern char* pathcanon_20100601(char*, size_t, int); +extern char* pathcat(char*, const char*, int, const char*, const char*); +extern char* pathcat_20100601(const char*, int, const char*, const char*, char*, size_t); +extern int pathcd(const char*, const char*); +extern int pathcheck(const char*, const char*, Pathcheck_t*); +extern int pathexists(char*, int); +extern char* pathfind(const char*, const char*, const char*, char*, size_t); +extern int pathgetlink(const char*, char*, int); +extern int pathinclude(const char*); +extern char* pathkey(char*, char*, const char*, const char*, const char*); +extern char* pathkey_20100601(const char*, const char*, const char*, char*, size_t, char*, size_t); +extern size_t pathnative(const char*, char*, size_t); +extern char* pathpath(char*, const char*, const char*, int); +extern char* pathpath_20100601(const char*, const char*, int, char*, size_t); +extern size_t pathposix(const char*, char*, size_t); +extern char* pathprobe(char*, char*, const char*, const char*, const char*, int); +extern char* pathprobe_20100601(const char*, const char*, const char*, int, char*, size_t, char*, size_t); +extern size_t pathprog(const char*, char*, size_t); +extern char* pathrepl(char*, const char*, const char*); +extern char* pathrepl_20100601(char*, size_t, const char*, const char*); +extern int pathsetlink(const char*, const char*); +extern char* pathshell(void); +extern char* pathtemp(char*, size_t, const char*, const char*, int*); +extern char* pathtmp(char*, const char*, const char*, int*); +extern char* setenviron(const char*); +extern int stracmp(const char*, const char*); +extern char* strcopy(char*, const char*); +extern unsigned long strelapsed(const char*, char**, int); +extern int stresc(char*); +extern int strexp(char*, int); +extern long streval(const char*, char**, long(*)(const char*, char**)); +extern long strexpr(const char*, char**, long(*)(const char*, char**, void*), void*); +extern int strgid(const char*); +extern int strgrpmatch(const char*, const char*, int*, int, int); +extern int strgrpmatch_20120528(const char*, const char*, ssize_t*, int, int); +extern unsigned int strhash(const char*); +extern void* strlook(const void*, size_t, const char*); +extern int strmatch(const char*, const char*); +extern int strmode(const char*); +extern int strnacmp(const char*, const char*, size_t); +extern char* strncopy(char*, const char*, size_t); +extern int strnpcmp(const char*, const char*, size_t); +extern double strntod(const char*, size_t, char**); +extern _ast_fltmax_t strntold(const char*, size_t, char**); +extern long strntol(const char*, size_t, char**, int); +extern intmax_t strntoll(const char*, size_t, char**, int); +extern long strnton(const char*, size_t, char**, char*, int); +extern unsigned long strntoul(const char*, size_t, char**, int); +extern intmax_t strntonll(const char*, size_t, char**, char*, int); +extern uintmax_t strntoull(const char*, size_t, char**, int); +extern int strnvcmp(const char*, const char*, size_t); +extern int stropt(const char*, const void*, int, int(*)(void*, const void*, int, const char*), void*); +extern int strpcmp(const char*, const char*); +extern int strperm(const char*, char**, int); +extern void* strpsearch(const void*, size_t, size_t, const char*, char**); +extern void* strsearch(const void*, size_t, size_t, Strcmp_f, const char*, void*); +extern void strsort(char**, int, int(*)(const char*, const char*)); +extern char* strsubmatch(const char*, const char*, int); +extern unsigned long strsum(const char*, unsigned long); +extern char* strtape(const char*, char**); +extern int strtoip4(const char*, char**, uint32_t*, unsigned char*); +extern long strton(const char*, char**, char*, int); +extern intmax_t strtonll(const char*, char**, char*, int); +extern int struid(const char*); +extern int struniq(char**, int); +extern int strvcmp(const char*, const char*); +extern int wc2utf8(char*, uint32_t); + +#undef extern + +/* + * C library global data symbols not prototyped by + */ + +#if !defined(environ) && defined(__DYNAMIC__) +#define environ __DYNAMIC__(environ) +#else +extern char** environ; +#endif + +/* + * really handy malloc()/free() (__FILE__,__LINE__,__FUNCTION__) tracing + * make with VMDEBUG==1 or debug=1 or CCFLAGS=$(CC.DEBUG) + * VMDEBUG==0 disables + * at runtime export VMALLOC_OPTIONS per vmalloc.3 + * to list originating call locations + */ + +#if !_std_malloc && !defined(VMFL) && !defined(_VMHDR_H) && \ + (VMDEBUG || !defined(VMDEBUG) && _BLD_DEBUG) + +#define VMFL 1 +#include + +#endif + +#include + +#undef AST_PLUGIN_VERSION +#define AST_PLUGIN_VERSION(v) ((v)>AST_VERSION?(v):AST_VERSION) + +#if defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern unsigned long plugin_version(void); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_api.h b/illumos-x86_64/usr/include/ast/ast_api.h new file mode 100644 index 00000000..ccf246ed --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_api.h @@ -0,0 +1,114 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/api by iffe version 2012-07-17 : : */ +#ifndef _AST_API_H +#define _AST_API_H 1 +#define _sys_types 1 /* #include ok */ +#define _AST_VERSION AST_VERSION /* pre-20100601 compatibility */ + +#define AST_VERSION 20111111 +#define ASTAPI(rel) ( _BLD_ast || !_API_ast || _API_ast >= rel ) + +#if !defined(_API_ast) && defined(_API_DEFAULT) +#define _API_ast _API_DEFAULT +#endif + +#if ASTAPI(20120411) +#undef cmdopen +#define cmdopen cmdopen_20120411 +#elif _API_ast >= 20110505 +#undef cmdopen +#define cmdopen cmdopen_20110505 +#endif + +#if ASTAPI(20100601) +#undef pathaccess +#define pathaccess pathaccess_20100601 +#endif + +#if ASTAPI(20100601) +#undef pathcanon +#define pathcanon pathcanon_20100601 +#endif + +#if ASTAPI(20100601) +#undef pathcat +#define pathcat pathcat_20100601 +#endif + +#if ASTAPI(20100601) +#undef pathkey +#define pathkey pathkey_20100601 +#endif + +#if ASTAPI(20100601) +#undef pathpath +#define pathpath pathpath_20100601 +#endif + +#if ASTAPI(20100601) +#undef pathprobe +#define pathprobe pathprobe_20100601 +#endif + +#if ASTAPI(20100601) +#undef pathrepl +#define pathrepl pathrepl_20100601 +#endif + +#if ASTAPI(20120528) +#undef regexec +#define regexec regexec_20120528 +#endif + +#if ASTAPI(20120528) +#undef regnexec +#define regnexec regnexec_20120528 +#endif + +#if ASTAPI(20120528) +#undef regrexec +#define regrexec regrexec_20120528 +#endif + +#if ASTAPI(20120528) +#undef regsubexec +#define regsubexec regsubexec_20120528 +#endif + +#if ASTAPI(20000308) +#undef sfkeyprintf +#define sfkeyprintf sfkeyprintf_20000308 +#endif + +#if ASTAPI(20120528) +#undef strgrpmatch +#define strgrpmatch strgrpmatch_20120528 +#endif + +#define _API_ast_MAP "cmdopen_20120411 cmdopen_20110505 pathaccess_20100601 pathcanon_20100601 pathcat_20100601 pathkey_20100601 pathpath_20100601 pathprobe_20100601 pathrepl_20100601 regexec_20120528 regnexec_20120528 regrexec_20120528 regsubexec_20120528 sfkeyprintf_20000308 strgrpmatch_20120528" + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_botch.h b/illumos-x86_64/usr/include/ast/ast_botch.h new file mode 100644 index 00000000..ac3d2c9c --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_botch.h @@ -0,0 +1,30 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/botch.c by iffe version 2012-07-17 : : */ +#ifndef _def_botch_ast +#define _def_botch_ast 1 +#define _sys_types 1 /* #include ok */ +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_ccode.h b/illumos-x86_64/usr/include/ast/ast_ccode.h new file mode 100644 index 00000000..c42f776b --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_ccode.h @@ -0,0 +1,54 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/ccode by iffe version 2012-07-17 : : */ +#ifndef _def_ccode_ast +#define _def_ccode_ast 1 +#define _sys_types 1 /* #include ok */ + +#define CC_ASCII 1 /* ISO-8859-1 */ +#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */ +#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */ +#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */ +#define CC_EBCDIC_S 5 /* Siemens posix-bc */ +#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */ +#define CC_EBCDIC_M 7 /* IBM mvs cobol */ +#define CC_EBCDIC_U 8 /* microfocus cobol */ + +#define CC_MAPS 8 /* number of code maps */ + +#define CC_EBCDIC CC_EBCDIC_E +#define CC_EBCDIC1 CC_EBCDIC_E +#define CC_EBCDIC2 CC_EBCDIC_I +#define CC_EBCDIC3 CC_EBCDIC_O + +#define CC_NATIVE CC_ASCII /* native character code */ +#define CC_ALIEN CC_EBCDIC /* alien character code */ + +#define CC_bel 0007 /* bel character */ +#define CC_esc 0033 /* esc character */ +#define CC_sub 0032 /* sub character */ +#define CC_vt 0013 /* vt character */ +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_common.h b/illumos-x86_64/usr/include/ast/ast_common.h new file mode 100644 index 00000000..8a8e9e61 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_common.h @@ -0,0 +1,263 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/common by iffe version 2012-07-17 : : */ +#ifndef _AST_COMMON_H +#define _AST_COMMON_H 1 +#define _sys_types 1 /* #include ok */ +#define _hdr_pthread 1 /* #include ok */ +#define _hdr_stdarg 1 /* #include ok */ +#define _hdr_stddef 1 /* #include ok */ +#define _hdr_stdint 1 /* #include ok */ +#define _hdr_inttypes 1 /* #include ok */ +#define _hdr_unistd 1 /* #include ok */ +#define _hdr_time 1 /* #include ok */ +#define _sys_time 1 /* #include ok */ +#define _sys_times 1 /* #include ok */ +#define _hdr_stdlib 1 /* #include ok */ +#define _typ_long_double 1 /* long double is a type */ +#define _typ_size_t 1 /* size_t is a type */ +#define _typ_ssize_t 1 /* ssize_t is a type */ +#define _hdr_stdio 1 /* #include ok */ +#define _typ___va_list 1 /* __va_list is a type */ +#define _sys_stat 1 /* #include ok */ +#define _sys_socket 1 /* #include ok */ +#define _std_proto 1 /* standard C prototypes ok */ +#define _ptr_void 1 /* standard C void* ok */ +/* disable non-standard linux/gnu inlines */ +#ifdef __GNUC__ +# undef __OPTIMIZE_SIZE__ +# define __OPTIMIZE_SIZE__ 1 +#endif + +/* __STD_C indicates that the language is ANSI-C or C++ */ +#if !defined(__STD_C) && __STDC__ +# define __STD_C 1 +#endif +#if !defined(__STD_C) && (__cplusplus || c_plusplus) +# define __STD_C 1 +#endif +#if !defined(__STD_C) && _std_proto +# define __STD_C 1 +#endif +#if !defined(__STD_C) +# define __STD_C 0 +#endif + +/* extern symbols must be protected against C++ name mangling */ +#ifndef _BEGIN_EXTERNS_ +# if __cplusplus || c_plusplus +# define _BEGIN_EXTERNS_ extern "C" { +# define _END_EXTERNS_ } +# else +# define _BEGIN_EXTERNS_ +# define _END_EXTERNS_ +# endif +#endif + +/* _ARG_ simplifies function prototyping among flavors of C */ +#ifndef _ARG_ +# if __STD_C +# define _ARG_(x) x +# else +# define _ARG_(x) () +# endif +#endif + +/* _NIL_ simplifies defining nil pointers to a given type */ +#ifndef _NIL_ +# define _NIL_(x) ((x)0) +#endif + +/* __INLINE__, if defined, is the inline keyword */ +#if !defined(__INLINE__) && defined(__cplusplus) +# define __INLINE__ inline +#endif +#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +#endif + +/* Void_t is defined so that Void_t* can address any type */ +#ifndef Void_t +# if __STD_C +# define Void_t void +# else +# define Void_t char +# endif +#endif + +/* windows variants and veneers */ +#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__) +# define _WINIX 1 +#endif + +/* dynamic linked library external scope handling */ +#ifdef __DYNAMIC__ +# undef __DYNAMIC__ +# ifndef _DLL +# define _DLL 1 +# endif +#endif +#if _dll_import +# if _BLD_STATIC && !_BLD_DLL +# undef _DLL +# else +# if !_UWIN && !defined(_DLL) +# define _DLL 1 +# endif +# endif +# if !defined(__EXPORT__) && _BLD_DLL +# define __EXPORT__ __declspec(dllexport) +# endif +# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) ) +# define __IMPORT__ __declspec(dllimport) +# endif +# if _BLD_DLL && _UWIN +# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v) +# endif +#endif +#if !defined(_astimport) +# if defined(__IMPORT__) && defined(_DLL) +# define _astimport __IMPORT__ +# else +# define _astimport extern +# endif +#endif +#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN ) +# ifdef __STDC__ +# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj +# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj +# else +# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj +# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj +# endif +#else +# define __EXTERN__(T,obj) extern T obj +# define __DEFINE__(T,obj,val) T obj = val +#endif + +#define _ast_LL 1 /* LL numeric suffix supported */ +#define _ast_int1_t char +#define _ast_int2_t short +#define _ast_int4_t int +#ifndef __amd64 +#define _ast_int8_t long long +#else /* __amd64 */ +#define _ast_int8_t long +#endif /* __amd64 */ +#define _ast_intmax_t _ast_int8_t +#ifdef __amd64 +#define _ast_intmax_long 1 +#endif /* __amd64 */ +#define _ast_intswap 7 + +#define _ast_sizeof_short 2 /* sizeof(short) */ +#define _ast_sizeof_int 4 /* sizeof(int) */ +#ifndef __amd64 +#define _ast_sizeof_long 4 /* sizeof(long) */ +#define _ast_sizeof_size_t 4 /* sizeof(size_t) */ +#define _ast_sizeof_pointer 4 /* sizeof(pointer) */ +#else /* __amd64 */ +#define _ast_sizeof_long 8 /* sizeof(long) */ +#define _ast_sizeof_size_t 8 /* sizeof(size_t) */ +#define _ast_sizeof_pointer 8 /* sizeof(pointer) */ +#endif /* __amd64 */ +#define _ast_sizeof_float 4 /* sizeof(float) */ +#define _ast_sizeof_double 8 /* sizeof(double) */ +#ifndef __amd64 +#define _ast_sizeof_long_double 12 /* sizeof(long_double) */ +#else /* __amd64 */ +#define _ast_sizeof_long_double 16 /* sizeof(long_double) */ +#endif /* __amd64 */ + +#define _ast_flt4_t float +#define _ast_flt8_t double +#ifndef __amd64 +#define _ast_flt12_t long double +#define _ast_fltmax_t _ast_flt12_t +#else /* __amd64 */ +#define _ast_flt16_t long double +#define _ast_fltmax_t _ast_flt16_t +#endif /* __amd64 */ +#define _typ_int8_t 1 /* int8_t is a type */ +#define _typ_uint8_t 1 /* uint8_t is a type */ +#define _typ_int16_t 1 /* int16_t is a type */ +#define _typ_uint16_t 1 /* uint16_t is a type */ +#define _typ_int32_t 1 /* int32_t is a type */ +#define _typ_uint32_t 1 /* uint32_t is a type */ +#define _typ_int64_t 1 /* int64_t is a type */ +#define _typ_uint64_t 1 /* uint64_t is a type */ +#define _typ_intmax_t 1 /* intmax_t is a type */ +#define _typ_uintmax_t 1 /* uintmax_t is a type */ +#define _typ_uintptr_t 1 /* uintptr_t is a type */ + +#ifndef va_listref +#ifndef va_start +#if __STD_C +#include +#else +#include +#endif +#endif +#ifndef __amd64 +#define va_listref(p) (p) /* pass va_list to varargs function */ +#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */ +#define va_listarg va_list /* va_arg() va_list type */ +#else /* __amd64 */ +#define va_listref(p) (&(p)) /* pass va_list to varargs function */ +#define va_listval(p) (*(p)) /* retrieve va_list from va_arg(ap,va_listarg) */ +#define va_listarg va_list* /* va_arg() va_list type */ +#endif /* __amd64 */ +#endif +#ifndef _AST_STD_H +# if __STD_C && _hdr_stddef +# include +# endif +# if _sys_types +# include +# endif +# if _hdr_stdint +# include +# else +# if _hdr_inttypes +# include +# endif +# endif +#endif +#if !_typ_size_t +# define _typ_size_t 1 + typedef int size_t; +#endif +#if !_typ_ssize_t +# define _typ_ssize_t 1 + typedef int ssize_t; +#endif +#ifndef _AST_STD_H +# if !_def_map_ast +# include +# endif +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_dir.h b/illumos-x86_64/usr/include/ast/ast_dir.h new file mode 100644 index 00000000..aba4402f --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_dir.h @@ -0,0 +1,83 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * AT&T Research + * + * common dirent maintenance interface + */ + +#ifndef _AST_DIR_H +#define _AST_DIR_H + +#include + +#if _mem_d_fileno_dirent || _mem_d_ino_dirent +#if !_mem_d_fileno_dirent +#undef _mem_d_fileno_dirent +#define _mem_d_fileno_dirent 1 +#define d_fileno d_ino +#endif +#endif + +#if _BLD_ast +#include "dirlib.h" +#else +#include +#endif + +#if _mem_d_fileno_dirent +#define D_FILENO(d) ((d)->d_fileno) +#endif + +#if _mem_d_namlen_dirent +#define D_NAMLEN(d) ((d)->d_namlen) +#else +#define D_NAMLEN(d) (strlen((d)->d_name)) +#endif + +#if _mem_d_reclen_dirent +#define D_RECLEN(d) ((d)->d_reclen) +#else +#define D_RECLEN(d) D_RECSIZ(d,D_NAMLEN(d)) +#endif + +#define D_RECSIZ(d,n) (sizeof(*(d))-sizeof((d)->d_name)+((n)+sizeof(char*))&~(sizeof(char*)-1)) + +/* + * NOTE: 2003-03-27 mac osx bug symlink==DT_REG bug discovered; + * the kernel *and* all directories must be fixed, so d_type + * is summarily disabled until we see that happen + */ + +#if _mem_d_type_dirent && defined(DT_UNKNOWN) && defined(DT_REG) && defined(DT_DIR) && defined(DT_LNK) && ! ( __APPLE__ || __MACH__ ) +#define D_TYPE(d) ((d)->d_type) +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_dirent.h b/illumos-x86_64/usr/include/ast/ast_dirent.h new file mode 100644 index 00000000..3909a2a2 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_dirent.h @@ -0,0 +1,235 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +#ifndef __amd64 +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/dirent by iffe version 2012-07-17 : : */ + +#ifndef _def_dirent_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_dirent_ast 1 +#define _lib_opendir 1 /* opendir() in default lib(s) */ +#define _hdr_dirent 1 /* #include ok */ +#define _nxt_dirent <../include/dirent.h> /* include path for the native */ +#define _nxt_dirent_str "../include/dirent.h" /* include string for the native */ +/* + * for [fl]stat64 and off64_t + */ + +#ifndef _AST_STD_H + +#include <../include/dirent.h> /* the native */ + +#else + +#ifndef _DIR64_H +#define _DIR64_H + +#include + +#if _typ_off64_t +#undef off_t +#endif + +#include <../include/dirent.h> /* the native */ + +#if _typ_off64_t +#define off_t off64_t +#endif + +#if _lib_readdir64 && _typ_struct_dirent64 +#ifndef dirent +#define dirent dirent64 +#endif +#ifndef readdir +#define readdir readdir64 +#endif +#endif + +#endif + +#endif +#endif +#else /* __amd64 */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/dirent by iffe version 2012-07-17 : : */ + +#ifndef _def_dirent_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_dirent_ast 1 +#define _lib_opendir 1 /* opendir() in default lib(s) */ +#define _hdr_dirent 1 /* #include ok */ +#define _nxt_dirent <../include/dirent.h> /* include path for the native */ +#define _nxt_dirent_str "../include/dirent.h" /* include string for the native */ +/* + * for systems with ok + */ + +#ifndef _DIRENT_H + +#include <../include/dirent.h> /* the native */ + +#ifndef _DIRENT_H +#define _DIRENT_H +#endif + +#endif +#endif +#endif /* __amd64 */ diff --git a/illumos-x86_64/usr/include/ast/ast_fcntl.h b/illumos-x86_64/usr/include/ast/ast_fcntl.h new file mode 100644 index 00000000..a04e2113 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_fcntl.h @@ -0,0 +1,141 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/fcntl.c by iffe version 2012-07-17 : : */ +#ifndef _def_fcntl_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_fcntl_ast 1 +#define _sys_types 1 /* #include ok */ + + +#if _typ_off64_t +#undef off_t +#ifdef __STDC__ +#define off_t off_t +#endif +#endif + +#include + +#if _typ_off64_t +#undef off_t +#ifdef __STDC__ +#define off_t off_t +#endif +#endif + +#include +#include + +#define F_dupfd_cloexec F_DUPFD_CLOEXEC +#define O_BINARY 0 +#define O_cloexec O_CLOEXEC +#define O_TEMPORARY 0 +#define O_TEXT 0 + +#include +#if _typ_off64_t +#undef off_t +#define off_t off64_t +#endif +#if _lib_fstat64 +#define fstat fstat64 +#endif +#if _lib_lstat64 +#define lstat lstat64 +#endif +#if _lib_stat64 +#define stat stat64 +#endif +#if _lib_creat64 +#define creat creat64 +#endif +#if _lib_mmap64 +#define mmap mmap64 +#endif +#if _lib_open64 +#undef open +#define open open64 +#endif +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_float.h b/illumos-x86_64/usr/include/ast/ast_float.h new file mode 100644 index 00000000..da35ac66 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_float.h @@ -0,0 +1,292 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/float by iffe version 2012-07-17 : : */ + +#ifndef _def_float_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_float_ast 1 +#define _sys_types 1 /* #include ok */ +#define _hdr_float 1 /* #include ok */ +#define _hdr_limits 1 /* #include ok */ +#define _hdr_math 1 /* #include ok */ +#define _hdr_values 1 /* #include ok */ +#define _LIB_m 1 /* -lm is a library */ +#define _lib_frexp 1 /* frexp() in default lib(s) */ +#define _lib_frexpl 1 /* frexpl() in default lib(s) */ +#define _lib_ldexp 1 /* ldexp() in default lib(s) */ +#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */ +#define _lib_finite 1 /* finite() in default lib(s) */ +#define _lib_isnanl 1 /* isnanl() in default lib(s) */ +#define _lib_copysign 1 /* copysign() in default lib(s) */ +#define _lib_copysignl 1 /* copysignl() in default lib(s) */ +#define _npt_finite 1 /* finite() needs a prototype */ +#define _npt_finitel 1 /* finitel() needs a prototype */ +#define _npt_isinfl 1 /* isinfl() needs a prototype */ +#define _lib_fpclassify 1 /* fpclassify present and works */ +#define _lib_isinf 1 /* isinf present and works */ +#define _lib_isnan 1 /* isnan present and works */ +#define _lib_signbit 1 /* signbit present and works */ +#include +#include +#include +#ifndef FLT_DIG +#define FLT_DIG 6 +#endif +#ifndef FLT_MAX +#define FLT_MAX 3.4028234663852885981170E+38F +#endif +#ifndef FLT_MAX_10_EXP +#define FLT_MAX_10_EXP (+38) +#endif +#ifndef FLT_MAX_EXP +#define FLT_MAX_EXP (+128) +#endif +#ifndef FLT_MIN +#define FLT_MIN 1.1754943508222875079688E-38F +#endif +#ifndef FLT_MIN_10_EXP +#define FLT_MIN_10_EXP (-37) +#endif +#ifndef FLT_MIN_EXP +#define FLT_MIN_EXP (-125) +#endif +#ifndef DBL_DIG +#define DBL_DIG 15 +#endif +#ifndef DBL_MAX +#define DBL_MAX 1.7976931348623157081452E+308 +#endif +#ifndef DBL_MAX_10_EXP +#define DBL_MAX_10_EXP (+308) +#endif +#ifndef DBL_MAX_EXP +#define DBL_MAX_EXP (+1024) +#endif +#ifndef DBL_MIN +#define DBL_MIN 2.2250738585072013830903E-308 +#endif +#ifndef DBL_MIN_10_EXP +#define DBL_MIN_10_EXP (-307) +#endif +#ifndef DBL_MIN_EXP +#define DBL_MIN_EXP (-1021) +#endif +#ifndef LDBL_DIG +#define LDBL_DIG 18 +#endif +#ifndef LDBL_MAX +#define LDBL_MAX 1.1897314953572317650213E+4932L +#endif +#ifndef LDBL_MAX_10_EXP +#define LDBL_MAX_10_EXP (+4932) +#endif +#ifndef LDBL_MAX_EXP +#define LDBL_MAX_EXP (+16384) +#endif +#ifndef LDBL_MIN +#define LDBL_MIN 3.3621031431120935062627E-4932L +#endif +#ifndef LDBL_MIN_10_EXP +#define LDBL_MIN_10_EXP (-4931) +#endif +#ifndef LDBL_MIN_EXP +#define LDBL_MIN_EXP (-16381) +#endif + + +#define USHRT_DIG 4 +#define UINT_DIG 9 +#ifndef __amd64 +#define ULONG_DIG 9 +#define ULLONG_DIG 19 +#define UINTMAX_DIG ULLONG_DIG +#else /* __amd64 */ +#define ULONG_DIG 19 +#define UINTMAX_DIG ULONG_DIG +#endif /* __amd64 */ + +#ifndef __amd64 +#define FLT_ULONG_MAX 4294967295.0F +#define FLT_ULLONG_MAX 18446744073709551615.0F +#define FLT_UINTMAX_MAX FLT_ULLONG_MAX +#define FLT_LONG_MAX 2147483647.0F +#define FLT_LLONG_MAX 9223372036854775807.0F +#define FLT_INTMAX_MAX FLT_LLONG_MAX +#define FLT_LONG_MIN (-2147483648.0F) +#define FLT_LLONG_MIN (-9223372036854775808.0F) +#define FLT_INTMAX_MIN FLT_LLONG_MIN +#else /* __amd64 */ +#define FLT_ULONG_MAX 18446744073709551615.0F +#define FLT_ULLONG_MAX FLT_ULONG_MAX +#define FLT_UINTMAX_MAX FLT_ULONG_MAX +#define FLT_LONG_MAX 9223372036854775807.0F +#define FLT_LLONG_MAX FLT_LONG_MAX +#define FLT_INTMAX_MAX FLT_LONG_MAX +#define FLT_LONG_MIN (-9223372036854775808.0F) +#define FLT_LLONG_MIN FLT_LONG_MIN +#define FLT_INTMAX_MIN FLT_LONG_MIN +#endif /* __amd64 */ + +#ifndef __amd64 +#define DBL_ULONG_MAX 4294967295.0 +#define DBL_ULLONG_MAX 18446744073709551615.0 +#define DBL_UINTMAX_MAX DBL_ULLONG_MAX +#define DBL_LONG_MAX 2147483647.0 +#define DBL_LLONG_MAX 9223372036854775807.0 +#define DBL_INTMAX_MAX DBL_LLONG_MAX +#define DBL_LONG_MIN (-2147483648.0) +#define DBL_LLONG_MIN (-9223372036854775808.0) +#define DBL_INTMAX_MIN DBL_LLONG_MIN +#else /* __amd64 */ +#define DBL_ULONG_MAX 18446744073709551615.0 +#define DBL_ULLONG_MAX DBL_ULONG_MAX +#define DBL_UINTMAX_MAX DBL_ULONG_MAX +#define DBL_LONG_MAX 9223372036854775807.0 +#define DBL_LLONG_MAX DBL_LONG_MAX +#define DBL_INTMAX_MAX DBL_LONG_MAX +#define DBL_LONG_MIN (-9223372036854775808.0) +#define DBL_LLONG_MIN DBL_LONG_MIN +#define DBL_INTMAX_MIN DBL_LONG_MIN +#endif /* __amd64 */ + +#ifndef __amd64 +#define LDBL_ULONG_MAX 4294967295.0L +#define LDBL_ULLONG_MAX 18446744073709551615.0L +#define LDBL_UINTMAX_MAX LDBL_ULLONG_MAX +#define LDBL_LONG_MAX 2147483647.0L +#define LDBL_LLONG_MAX 9223372036854775807.0L +#define LDBL_INTMAX_MAX LDBL_LLONG_MAX +#define LDBL_LONG_MIN (-2147483648.0L) +#define LDBL_LLONG_MIN (-9223372036854775808.0L) +#define LDBL_INTMAX_MIN LDBL_LLONG_MIN +#else /* __amd64 */ +#define LDBL_ULONG_MAX 18446744073709551615.0L +#define LDBL_ULLONG_MAX LDBL_ULONG_MAX +#define LDBL_UINTMAX_MAX LDBL_ULONG_MAX +#define LDBL_LONG_MAX 9223372036854775807.0L +#define LDBL_LLONG_MAX LDBL_LONG_MAX +#define LDBL_INTMAX_MAX LDBL_LONG_MAX +#define LDBL_LONG_MIN (-9223372036854775808.0L) +#define LDBL_LLONG_MIN LDBL_LONG_MIN +#define LDBL_INTMAX_MIN LDBL_LONG_MIN +#endif /* __amd64 */ + +#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX +#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX +#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN + +typedef union _ast_dbl_exp_u +{ + uint32_t e[sizeof(double)/4]; + double f; +} _ast_dbl_exp_t; + +#define _ast_dbl_exp_index 1 +#define _ast_dbl_exp_shift 20 + +#ifndef __amd64 +typedef union _fltmax_exp_u +{ + uint32_t e[sizeof(_ast_fltmax_t)/4]; + _ast_fltmax_t f; +} _ast_fltmax_exp_t; + +#define _ast_fltmax_exp_index 2 +#define _ast_fltmax_exp_shift 0 + +#endif /* __amd64 */ +#define _ast_flt_unsigned_max_t unsigned long long +#define _ast_flt_nan_init 0xff,0xff,0xff,0x7f +#define _ast_flt_inf_init 0x00,0x00,0x80,0x7f +#define _ast_dbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f +#define _ast_dbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f +#ifndef __amd64 +#define _ast_ldbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00 +#define _ast_ldbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x00,0x00 +#else /* __amd64 */ +#define _ast_ldbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00 +#define _ast_ldbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00 +#endif /* __amd64 */ +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_fs.h b/illumos-x86_64/usr/include/ast/ast_fs.h new file mode 100644 index 00000000..dac8b66c --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_fs.h @@ -0,0 +1,177 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/fs by iffe version 2012-07-17 : : */ + +#ifndef _def_fs_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_fs_ast 1 +#define _sys_types 1 /* #include ok */ +#define _sys_stat 1 /* #include ok */ +#ifndef __amd64 +#define _lib__fxstat 1 /* _fxstat() in default lib(s) */ +#define _lib__lxstat 1 /* _lxstat() in default lib(s) */ +#define _lib__xmknod 1 /* _xmknod() in default lib(s) */ +#define _lib__xstat 1 /* _xstat() in default lib(s) */ +#endif /* __amd64 */ +#define _lib_lstat 1 /* lstat() in default lib(s) */ +#define _lib_mknod 1 /* mknod() in default lib(s) */ +#define _lib_sync 1 /* sync() in default lib(s) */ +#include +#include +#define FS_default "ufs" +#if defined(__STDPP__directive) && defined(__STDPP__initial) +__STDPP__directive pragma pp:noinitial +#endif +#define _hdr_stdio 1 /* #include ok */ +#define _sys_mntent 1 /* #include ok */ +#define _sys_mnttab 1 /* #include ok */ +#define _sys_param 1 /* #include ok */ +#define _sys_ucred 1 /* #include ok */ +#define _sys_mount 1 /* #include ok */ +#define _sys_statfs 1 /* #include ok */ +#define _sys_statvfs 1 /* #include ok */ +#define _sys_vfs 1 /* #include ok */ +#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */ +#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */ +#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */ +#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */ +#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */ +#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */ +#define _lib_getmntent 1 /* getmntent() in default lib(s) */ +#define _lib_statfs 1 /* statfs() in default lib(s) */ +#define _lib_statvfs 1 /* statvfs() in default lib(s) */ +#define _lib_statfs4 1 /* compile{\ passed */ +#if _sys_statvfs +#include +#if !_mem_statvfs_f_basetype +#if _ary_f_reserved7 +#define f_basetype f_reserved7 +#endif +#endif +#else +#define _mem_f_basetype_statvfs 1 +#define _mem_f_frsize_statvfs 1 +struct statvfs +{ +unsigned long f_bsize; /* fundamental file system block size */ +unsigned long f_frsize; /* fragment size */ +unsigned long f_blocks; /* total # of blocks of f_frsize on fs */ +unsigned long f_bfree; /* total # of free blocks of f_frsize */ +unsigned long f_bavail; /* # of free blocks avail to non-superuser */ +unsigned long f_files; /* total # of file nodes (inodes) */ +unsigned long f_ffree; /* total # of free file nodes */ +unsigned long f_favail; /* # of free nodes avail to non-superuser */ +unsigned long f_fsid; /* file system id (dev for now) */ +char f_basetype[16]; /* target fs type name, null-terminated */ +unsigned long f_flag; /* bit-mask of flags */ +unsigned long f_namemax; /* maximum file name length */ +char f_fstr[32]; /* filesystem-specific string */ +unsigned long f_filler[16]; /* reserved for future expansion */ +}; +extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*)); +extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*)); +#endif +#if _typ_off64_t +#undef off_t +#define off_t off64_t +#endif +#if _lib_statvfs64 && !defined(statvfs) +#define statvfs statvfs64 +#if !defined(__USE_LARGEFILE64) +extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*)); +#endif +#endif +#if _lib_fstatvfs64 && !defined(fstatvfs) +#define fstatvfs fstatvfs64 +#if !defined(__USE_LARGEFILE64) +extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*)); +#endif +#endif + +#define _str_st_fstype 1 /* stat.st_fstype is a string */ +#ifndef __amd64 +#define _ary_st_pad4 1 /* stat.st_pad4 is an array */ +#endif /* __amd64 */ +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_getopt.h b/illumos-x86_64/usr/include/ast/ast_getopt.h new file mode 100644 index 00000000..04e284ab --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_getopt.h @@ -0,0 +1,48 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * legacy standard getopt interface + */ + +#ifdef _AST_STD_I +#undef _AST_GETOPT_H +#define _AST_GETOPT_H -1 +#endif +#ifndef _AST_GETOPT_H +#define _AST_GETOPT_H 1 + +extern int opterr; +extern int optind; +extern int optopt; +extern char* optarg; + +extern int getopt(int, char* const*, const char*); +extern int getsubopt(char**, char* const*, char**); + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_iconv.h b/illumos-x86_64/usr/include/ast/ast_iconv.h new file mode 100644 index 00000000..08071be7 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_iconv.h @@ -0,0 +1,175 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/iconv by iffe version 2012-07-17 : : */ + +#ifndef _def_iconv_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_iconv_ast 1 +#define _sys_types 1 /* #include ok */ +#define _hdr_iconv 1 /* #include ok */ +#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */ +#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */ +#define _lib_iconv 1 /* iconv() in default lib(s) */ +#define _nxt_iconv <../include/iconv.h> /* include path for the native */ +#define _nxt_iconv_str "../include/iconv.h" /* include string for the native */ +#include +#include +#include <../include/iconv.h> /* the native iconv.h */ + +#define ICONV_VERSION 20110111L + +#define ICONV_FATAL 0x02 +#define ICONV_OMIT 0x04 + +#define CC_ICONV (-1) +#define CC_UCS (-2) +#define CC_SCU (-3) +#define CC_UTF (-4) +#define CC_UME (-5) + +#ifndef _ICONV_LIST_PRIVATE_ +#undef iconv_t +#define iconv_t _ast_iconv_t +#undef iconv_f +#define iconv_f _ast_iconv_f +#undef iconv_list_t +#define iconv_list_t _ast_iconv_list_t +#undef iconv_open +#define iconv_open _ast_iconv_open +#undef iconv +#define iconv _ast_iconv +#undef iconv_close +#define iconv_close _ast_iconv_close +#undef iconv_list +#define iconv_list _ast_iconv_list +#undef iconv_move +#define iconv_move _ast_iconv_move +#undef iconv_name +#define iconv_name _ast_iconv_name +#undef iconv_write +#define iconv_write _ast_iconv_write +#endif + +typedef int (*Iconv_error_f) __PROTO__((__V_*, __V_*, int, ...)); + +typedef struct Iconv_disc_s +{ + uint32_t version; + Iconv_error_f errorf; + size_t errors; + uint32_t flags; + int fill; +} Iconv_disc_t; + +typedef Ccmap_t _ast_iconv_list_t; +typedef __V_* _ast_iconv_t; +typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*)); + +#define iconv_init(d,e) (memset(d,0,sizeof(*(d))),(d)->version=ICONV_VERSION,(d)->errorf=(Iconv_error_f)(e),(d)->fill=(-1)) + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*)); +extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*)); +extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t)); +extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*)); +extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t)); +#if _SFIO_H +extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, Iconv_disc_t*)); +extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, Iconv_disc_t*)); +#else +#if _SFSTDIO_H +extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, Iconv_disc_t*)); +extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, Iconv_disc_t*)); +#endif +#endif + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_lib.h b/illumos-x86_64/usr/include/ast/ast_lib.h new file mode 100644 index 00000000..f370ccb4 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_lib.h @@ -0,0 +1,204 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/lib by iffe version 2012-07-17 : : */ +#ifndef _def_lib_ast +#define _def_lib_ast 1 +#define _sys_types 1 /* #include ok */ +#define _hdr_dirent 1 /* #include ok */ +#define _hdr_fmtmsg 1 /* #include ok */ +#define _hdr_fnmatch 1 /* #include ok */ +#define _hdr_libgen 1 /* #include ok */ +#define _hdr_limits 1 /* #include ok */ +#define _hdr_locale 1 /* #include ok */ +#define _hdr_nl_types 1 /* #include ok */ +#define _hdr_spawn 1 /* #include ok */ +#define _hdr_syslog 1 /* #include ok */ +#define _hdr_utime 1 /* #include ok */ +#define _hdr_wchar 1 /* and isw*() really work */ +#define _hdr_wchar 1 /* #include ok */ +#define _hdr_wctype 1 /* #include ok */ +#define _dat__tzname 1 /* _tzname in default lib(s) */ +#define _dat_tzname 1 /* tzname in default lib(s) */ +#define _lib__cleanup 1 /* _cleanup() in default lib(s) */ +#define _lib_atexit 1 /* atexit() in default lib(s) */ +#define _lib_bcopy 1 /* bcopy() in default lib(s) */ +#define _lib_bzero 1 /* bzero() in default lib(s) */ +#define _lib_catclose 1 /* catclose() in default lib(s) */ +#define _lib_catgets 1 /* catgets() in default lib(s) */ +#define _lib_catopen 1 /* catopen() in default lib(s) */ +#define _lib_confstr 1 /* confstr() in default lib(s) */ +#define _lib_dup2 1 /* dup2() in default lib(s) */ +#define _lib_execlp 1 /* execlp() in default lib(s) */ +#define _lib_execve 1 /* execve() in default lib(s) */ +#define _lib_execvp 1 /* execvp() in default lib(s) */ +#define _lib_execvpe 1 /* execvpe() in default lib(s) */ +#define _lib_fchmod 1 /* fchmod() in default lib(s) */ +#define _lib_fcntl 1 /* fcntl() in default lib(s) */ +#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */ +#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */ +#define _lib_fork 1 /* fork() in default lib(s) */ +#define _lib_fsync 1 /* fsync() in default lib(s) */ +#define _lib_getdents 1 /* getdents() in default lib(s) */ +#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */ +#define _lib_getdate 1 /* getdate() in default lib(s) */ +#define _lib_getgroups 1 /* getgroups() in default lib(s) */ +#define _lib_gethostname 1 /* gethostname() in default lib(s) */ +#define _lib_getlogin 1 /* getlogin() in default lib(s) */ +#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */ +#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */ +#define _lib_getopt 1 /* getopt() in default lib(s) */ +#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */ +#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */ +#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */ +#define _lib_glob 1 /* glob() in default lib(s) */ +#define _lib_index 1 /* index() in default lib(s) */ +#define _lib_iswblank 1 /* iswblank() in default lib(s) */ +#define _lib_iswctype 1 /* iswctype() in default lib(s) */ +#define _lib_killpg 1 /* killpg() in default lib(s) */ +#define _lib_link 1 /* link() in default lib(s) */ +#define _lib_localeconv 1 /* localeconv() in default lib(s) */ +#define _lib_madvise 1 /* madvise() in default lib(s) */ +#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */ +#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */ +#define _lib_memalign 1 /* memalign() in default lib(s) */ +#define _lib_memchr 1 /* memchr() in default lib(s) */ +#define _lib_memcpy 1 /* memcpy() in default lib(s) */ +#define _lib_memmove 1 /* memmove() in default lib(s) */ +#define _lib_memset 1 /* memset() in default lib(s) */ +#define _lib_mkdir 1 /* mkdir() in default lib(s) */ +#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */ +#define _lib_mktemp 1 /* mktemp() in default lib(s) */ +#define _lib_mktime 1 /* mktime() in default lib(s) */ +#define _lib_mount 1 /* mount() in default lib(s) */ +#define _lib_opendir 1 /* opendir() in default lib(s) */ +#define _lib_pathconf 1 /* pathconf() in default lib(s) */ +#define _lib_readlink 1 /* readlink() in default lib(s) */ +#define _lib_remove 1 /* remove() in default lib(s) */ +#define _lib_rename 1 /* rename() in default lib(s) */ +#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */ +#define _lib_rindex 1 /* rindex() in default lib(s) */ +#define _lib_rmdir 1 /* rmdir() in default lib(s) */ +#define _lib_setlocale 1 /* setlocale() in default lib(s) */ +#define _lib_setpgid 1 /* setpgid() in default lib(s) */ +#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */ +#define _lib_setreuid 1 /* setreuid() in default lib(s) */ +#define _lib_setsid 1 /* setsid() in default lib(s) */ +#define _lib_setuid 1 /* setuid() in default lib(s) */ +#define _lib_sigaction 1 /* sigaction() in default lib(s) */ +#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */ +#define _lib_socketpair 1 /* socketpair() in default lib(s) */ +#define _lib_strchr 1 /* strchr() in default lib(s) */ +#define _lib_strcoll 1 /* strcoll() in default lib(s) */ +#define _lib_strdup 1 /* strdup() in default lib(s) */ +#define _lib_strerror 1 /* strerror() in default lib(s) */ +#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */ +#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */ +#define _lib_strrchr 1 /* strrchr() in default lib(s) */ +#define _lib_strstr 1 /* strstr() in default lib(s) */ +#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */ +#define _lib_strftime 1 /* strftime() in default lib(s) */ +#define _lib_swab 1 /* swab() in default lib(s) */ +#define _lib_symlink 1 /* symlink() in default lib(s) */ +#define _lib_sysconf 1 /* sysconf() in default lib(s) */ +#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */ +#define _lib_syslog 1 /* syslog() in default lib(s) */ +#define _lib_telldir 1 /* telldir() in default lib(s) */ +#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */ +#define _lib_tzset 1 /* tzset() in default lib(s) */ +#define _lib_unlink 1 /* unlink() in default lib(s) */ +#define _lib_utime 1 /* utime() in default lib(s) */ +#define _lib_wctype 1 /* wctype() in default lib(s) */ +#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */ +#define _lib_truncate 1 /* truncate() in default lib(s) */ +#ifndef __amd64 +#define _lib_creat64 1 /* creat64() in default lib(s) */ +#define _lib_fstat64 1 /* fstat64() in default lib(s) */ +#define _lib_fstatvfs64 1 /* fstatvfs64() in default lib(s) */ +#define _lib_ftruncate64 1 /* ftruncate64() in default lib(s) */ +#define _lib_lseek64 1 /* lseek64() in default lib(s) */ +#define _lib_lstat64 1 /* lstat64() in default lib(s) */ +#define _lib_open64 1 /* open64() in default lib(s) */ +#define _lib_readdir64 1 /* readdir64() in default lib(s) */ +#define _lib_stat64 1 /* stat64() in default lib(s) */ +#define _lib_statvfs64 1 /* statvfs64() in default lib(s) */ +#define _lib_truncate64 1 /* truncate64() in default lib(s) */ +#endif /* __amd64 */ +#define _hdr_stdlib 1 /* #include ok */ +#define _lib_strtod 1 /* strtod() in default lib(s) */ +#define _lib_strtold 1 /* strtold() in default lib(s) */ +#define _lib_strtol 1 /* strtol() in default lib(s) */ +#define _lib_strtoll 1 /* strtoll() in default lib(s) */ +#define _lib_strtoul 1 /* strtoul() in default lib(s) */ +#define _lib_strtoull 1 /* strtoull() in default lib(s) */ +#define _hdr_signal 1 /* #include ok */ +#define _lib_sigflag 1 /* sigflag() in default lib(s) */ +#define _npt_sigflag 1 /* sigflag() needs a prototype */ +#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */ +#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */ +#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */ +#define _mem_DIR 1 /* DIR is a non-opaque struct */ +#define _mem_dd_fd_DIR 1 /* dd_fd is a member of DIR */ +#define _sys_filio 1 /* #include ok */ +#define _sys_jioctl 1 /* #include ok */ +#define _sys_resource 1 /* #include ok */ +#define _sys_socket 1 /* #include ok */ +#define _sys_stream 1 /* #include ok */ +#define _sys_systeminfo 1 /* #include ok */ +#define _hdr_time 1 /* #include ok */ +#define _sys_time 1 /* #include ok */ +#define _sys_times 1 /* #include ok */ +#define _hdr_stddef 1 /* #include ok */ +#define _typ_ino64_t 1 /* ino64_t is a type */ +#define _typ_off64_t 1 /* off64_t is a type */ +#define _typ_struct_dirent64 1 /* struct dirent64 is a type */ +#define _tst_errno 1 /* errno can be assigned */ +#define _lib_poll_fd_1 1 /* fd is first arg to poll() */ +#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */ +#define _sys_select 1 /* #include ok */ +#define _lib_select 1 /* select() has standard 5 arg interface */ +#define _sys_select 1 /* select() requires */ +#define _pipe_rw 1 /* full duplex pipes */ +#define _hdr_unistd 1 /* #include ok */ +#define _lib_vfork 1 /* vfork exists and it works */ +#define _real_vfork 1 /* vfork child shares data with parent */ +#define _lib_posix_spawn 2 /* posix_spawn exists and it works and its worth using */ +#define _stream_peek 1 /* ioctl(I_PEEK) works on pipe() */ +#define _socket_peek 1 /* recv(MSG_PEEK) works on socketpair() */ +#define _hdr_string 1 /* #include ok */ +#define _lib_memcmp 1 /* standard memcmp interface that works */ +#define _hdr_fcntl 1 /* #include ok */ +#define _sys_stat 1 /* #include ok */ +#define _sys_mman 1 /* #include ok */ +#define _lib_memccpy 1 /* standard memccpy interface that works */ +#define _lib_utime_now 1 /* utime works with 0 time vector */ +#define _UNIV_DEFAULT "att" /* default universe name */ +#define _std_cleanup 1 /* stuck with standard _cleanup */ +#define _std_strcoll 1 /* standard strcoll works */ +#if !_AST_no_spawnveg +#define _use_spawnveg 1 +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_limits.h b/illumos-x86_64/usr/include/ast/ast_limits.h new file mode 100644 index 00000000..519f7a55 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_limits.h @@ -0,0 +1,261 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +#ifndef __amd64 +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/limits.c by iffe version 2012-07-17 : : */ +#ifndef _def_limits_ast +#define _def_limits_ast 1 +#define _sys_types 1 /* #include ok */ + + +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif +#ifndef CHAR_MAX +#define CHAR_MAX 127 +#endif +#ifndef CHAR_MIN +#define CHAR_MIN -128 +#endif +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 1000000 +#endif +#ifndef INT_MIN +#define INT_MIN -2147483648 +#endif +#ifndef LLONG_MAX +#define LLONG_MAX 9223372036854775807 +#endif +#ifndef LLONG_MIN +#define LLONG_MIN -9223372036854775808 +#endif +#ifndef LONG_MAX +#define LONG_MAX 2147483647 +#endif +#ifndef LONG_MIN +#define LONG_MIN -2147483648 +#endif +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 5 +#endif +#ifndef OPEN_MAX_CEIL +#ifndef OPEN_MAX +#define OPEN_MAX 256 +#endif +#define OPEN_MAX_CEIL OPEN_MAX +#endif +#ifndef PTHREAD_STACK_MIN +#define PTHREAD_STACK_MIN 4096 +#endif +#ifndef PTRDIFF_MAX +#define PTRDIFF_MAX 2147483647 +#endif +#ifndef PTRDIFF_MIN +#define PTRDIFF_MIN -2147483648 +#endif +#ifndef SCHAR_MAX +#define SCHAR_MAX 127 +#endif +#ifndef SCHAR_MIN +#define SCHAR_MIN -128 +#endif +#ifndef SHRT_MIN +#define SHRT_MIN -32768 +#endif +#ifndef SIG_ATOMIC_MAX +#define SIG_ATOMIC_MAX 2147483647 +#endif +#ifndef SIG_ATOMIC_MIN +#define SIG_ATOMIC_MIN -2147483648 +#endif +#ifndef SIZE_MAX +#ifndef UINT_MAX +#define UINT_MAX 4294967295 +#endif +#define SIZE_MAX UINT_MAX +#endif +#ifndef SSIZE_MAX +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif +#define SSIZE_MAX INT_MAX +#endif +#ifndef TMP_MAX +#define TMP_MAX 17576 +#endif +#ifndef UCHAR_MAX +#define UCHAR_MAX 255 +#endif +#ifndef ULLONG_MAX +#define ULLONG_MAX 18446744073709551615 +#endif +#ifndef ULONG_MAX +#define ULONG_MAX 4294967295 +#endif +#ifndef USHRT_MAX +#define USHRT_MAX 65535 +#endif +#ifndef WCHAR_MAX +#define WCHAR_MAX 2147483647 +#endif +#ifndef WCHAR_MIN +#define WCHAR_MIN -2147483648 +#endif +#ifndef WINT_MAX +#define WINT_MAX 2147483647 +#endif +#ifndef WINT_MIN +#define WINT_MIN -2147483648 +#endif + +#endif +#else /* __amd64 */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/limits.c by iffe version 2012-07-17 : : */ +#ifndef _def_limits_ast +#define _def_limits_ast 1 +#define _sys_types 1 /* #include ok */ + + +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif +#ifndef CHAR_MAX +#define CHAR_MAX 127 +#endif +#ifndef CHAR_MIN +#define CHAR_MIN -128 +#endif +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 1000000 +#endif +#ifndef INT_MIN +#define INT_MIN -2147483648 +#endif +#ifndef LLONG_MAX +#define LLONG_MAX 9223372036854775807 +#endif +#ifndef LLONG_MIN +#define LLONG_MIN -9223372036854775808 +#endif +#ifndef LONG_MAX +#define LONG_MAX 2147483647 +#endif +#ifndef LONG_MIN +#define LONG_MIN -2147483648 +#endif +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 5 +#endif +#ifndef OPEN_MAX_CEIL +#ifndef OPEN_MAX +#define OPEN_MAX 256 +#endif +#define OPEN_MAX_CEIL OPEN_MAX +#endif +#ifndef PTHREAD_STACK_MIN +#define PTHREAD_STACK_MIN 4096 +#endif +#ifndef PTRDIFF_MAX +#define PTRDIFF_MAX 9223372036854775807 +#endif +#ifndef PTRDIFF_MIN +#define PTRDIFF_MIN -9223372036854775808 +#endif +#ifndef SCHAR_MAX +#define SCHAR_MAX 127 +#endif +#ifndef SCHAR_MIN +#define SCHAR_MIN -128 +#endif +#ifndef SHRT_MIN +#define SHRT_MIN -32768 +#endif +#ifndef SIG_ATOMIC_MAX +#define SIG_ATOMIC_MAX 2147483647 +#endif +#ifndef SIG_ATOMIC_MIN +#define SIG_ATOMIC_MIN -2147483648 +#endif +#ifndef SIZE_MAX +#ifndef UINT_MAX +#define UINT_MAX 4294967295 +#endif +#define SIZE_MAX UINT_MAX +#endif +#ifndef SSIZE_MAX +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif +#define SSIZE_MAX INT_MAX +#endif +#ifndef TMP_MAX +#define TMP_MAX 17576 +#endif +#ifndef UCHAR_MAX +#define UCHAR_MAX 255 +#endif +#ifndef ULLONG_MAX +#define ULLONG_MAX 18446744073709551615 +#endif +#ifndef ULONG_MAX +#define ULONG_MAX 4294967295 +#endif +#ifndef USHRT_MAX +#define USHRT_MAX 65535 +#endif +#ifndef WCHAR_MAX +#define WCHAR_MAX 2147483647 +#endif +#ifndef WCHAR_MIN +#define WCHAR_MIN -2147483648 +#endif +#ifndef WINT_MAX +#define WINT_MAX 2147483647 +#endif +#ifndef WINT_MIN +#define WINT_MIN -2147483648 +#endif + +#endif +#endif /* __amd64 */ diff --git a/illumos-x86_64/usr/include/ast/ast_map.h b/illumos-x86_64/usr/include/ast/ast_map.h new file mode 100644 index 00000000..bf9242de --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_map.h @@ -0,0 +1,488 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/map.c by iffe version 2012-07-17 : : */ +#ifndef _def_map_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_map_ast 1 +#define _sys_types 1 /* #include ok */ + + +/* + * prototypes provided for standard interfaces hijacked + * by ast and mapped to _ast_* but already prototyped + * unmapped in native headers included by + */ + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + + +#define _map_libc 1 +#undef basename +#define basename _ast_basename +#undef dirname +#define dirname _ast_dirname +#undef eaccess +#define eaccess _ast_eaccess +#undef fnmatch +#define fnmatch _ast_fnmatch +#undef fts_children +#define fts_children _ast_fts_children +#undef fts_close +#define fts_close _ast_fts_close +#undef fts_flags +#define fts_flags _ast_fts_flags +#undef fts_notify +#define fts_notify _ast_fts_notify +#undef fts_open +#define fts_open _ast_fts_open +#undef fts_read +#define fts_read _ast_fts_read +#undef fts_set +#define fts_set _ast_fts_set +#undef ftw +#define ftw _ast_ftw +#undef ftwalk +#define ftwalk _ast_ftwalk +#undef ftwflags +#define ftwflags _ast_ftwflags +#undef getcwd +#define getcwd _ast_getcwd +extern __MANGLE__ char* getcwd __PROTO__((char*, size_t)); +#undef getdate +#define getdate _ast_getdate +#undef getopt +#define getopt _ast_getopt +#undef getsubopt +#define getsubopt _ast_getsubopt +#undef getopt_long +#define getopt_long _ast_getopt_long +#undef getopt_long_only +#define getopt_long_only _ast_getopt_long_only +#undef optopt +#define optopt _ast_optopt +#undef optarg +#define optarg _ast_optarg +#undef optind +#define optind _ast_optind +#undef opterr +#define opterr _ast_opterr +#undef getwd +#define getwd _ast_getwd +extern __MANGLE__ char* getwd __PROTO__((char*)); +#undef glob +#define glob _ast_glob +#undef globfree +#define globfree _ast_globfree +#undef memdup +#define memdup _ast_memdup +#undef memfatal +#define memfatal _ast_memfatal +#undef memhash +#define memhash _ast_memhash +#undef memsum +#define memsum _ast_memsum +#undef mkstemp +#define mkstemp _ast_mkstemp +extern __MANGLE__ int mkstemp __PROTO__((char*)); +#undef mktemp +#define mktemp _ast_mktemp +extern __MANGLE__ char* mktemp __PROTO__((char*)); +#undef mktime +#define mktime _ast_mktime +#undef nftw +#define nftw _ast_nftw +#undef optctx +#define optctx _ast_optctx +#undef optesc +#define optesc _ast_optesc +#undef optget +#define optget _ast_optget +#undef opthelp +#define opthelp _ast_opthelp +#undef optjoin +#define optjoin _ast_optjoin +#undef optstr +#define optstr _ast_optstr +#undef optusage +#define optusage _ast_optusage +#undef pathaccess +#define pathaccess _ast_pathaccess +#undef pathbin +#define pathbin _ast_pathbin +#undef pathcanon +#define pathcanon _ast_pathcanon +#undef pathcat +#define pathcat _ast_pathcat +#undef pathcd +#define pathcd _ast_pathcd +#undef pathcheck +#define pathcheck _ast_pathcheck +#undef pathexists +#define pathexists _ast_pathexists +#undef pathfind +#define pathfind _ast_pathfind +#undef pathgetlink +#define pathgetlink _ast_pathgetlink +#undef pathinclude +#define pathinclude _ast_pathinclude +#undef pathkey +#define pathkey _ast_pathkey +#undef pathnative +#define pathnative _ast_pathnative +#undef pathpath +#define pathpath _ast_pathpath +#undef pathposix +#define pathposix _ast_pathposix +#undef pathprobe +#define pathprobe _ast_pathprobe +#undef pathprog +#define pathprog _ast_pathprog +#undef pathrepl +#define pathrepl _ast_pathrepl +#undef pathsetlink +#define pathsetlink _ast_pathsetlink +#undef pathshell +#define pathshell _ast_pathshell +#undef pathstat +#define pathstat _ast_pathstat +#undef pathtemp +#define pathtemp _ast_pathtemp +#undef pathtmp +#define pathtmp _ast_pathtmp +#undef procclose +#define procclose _ast_procclose +#undef procfree +#define procfree _ast_procfree +#undef procopen +#define procopen _ast_procopen +#undef procrun +#define procrun _ast_procrun +#undef putenv +#define putenv _ast_putenv +#undef re_comp +#define re_comp _ast_re_comp +#undef re_exec +#define re_exec _ast_re_exec +#undef realpath +#define realpath _ast_realpath +extern __MANGLE__ char* realpath __PROTO__((const char*, char*)); +#undef regaddclass +#define regaddclass _ast_regaddclass +#undef regalloc +#define regalloc _ast_regalloc +#undef regcache +#define regcache _ast_regcache +#undef regclass +#define regclass _ast_regclass +#undef regcmp +#define regcmp _ast_regcmp +#undef regcollate +#define regcollate _ast_regcollate +#undef regcomb +#define regcomb _ast_regcomb +#undef regcomp +#define regcomp _ast_regcomp +#undef regdecomp +#define regdecomp _ast_regdecomp +#undef regdup +#define regdup _ast_regdup +#undef regerror +#define regerror _ast_regerror +#undef regex +#define regex _ast_regex +#undef regexec +#define regexec _ast_regexec +#undef regfatal +#define regfatal _ast_regfatal +#undef regfatalpat +#define regfatalpat _ast_regfatalpat +#undef regfree +#define regfree _ast_regfree +#undef regncomp +#define regncomp _ast_regncomp +#undef regnexec +#define regnexec _ast_regnexec +#undef regrecord +#define regrecord _ast_regrecord +#undef regrexec +#define regrexec _ast_regrexec +#undef regstat +#define regstat _ast_regstat +#undef regsub +#define regsub _ast_regsub +#undef regsubcomp +#define regsubcomp _ast_regsubcomp +#undef regsubexec +#define regsubexec _ast_regsubexec +#undef regsubflags +#define regsubflags _ast_regsubflags +#undef regsubfree +#define regsubfree _ast_regsubfree +#undef remove +#define remove _ast_remove +extern __MANGLE__ int remove __PROTO__((const char*)); +#undef resolvepath +#define resolvepath _ast_resolvepath +extern __MANGLE__ int resolvepath __PROTO__((const char*, char*, size_t)); +#undef setenv +#define setenv _ast_setenv +extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int)); +#undef setenviron +#define setenviron _ast_setenviron +#undef sigcritical +#define sigcritical _ast_sigcritical +#undef signal +#define signal _ast_signal +#undef sigunblock +#define sigunblock _ast_sigunblock +#undef stracmp +#define stracmp _ast_stracmp +#undef strcopy +#define strcopy _ast_strcopy +#undef strelapsed +#define strelapsed _ast_strelapsed +#undef stresc +#define stresc _ast_stresc +#undef streval +#define streval _ast_streval +#undef strexpr +#define strexpr _ast_strexpr +#undef strftime +#define strftime _ast_strftime +#undef strgid +#define strgid _ast_strgid +#undef strgrpmatch +#define strgrpmatch _ast_strgrpmatch +#undef strhash +#define strhash _ast_strhash +#undef strkey +#define strkey _ast_strkey +#undef strlcat +#define strlcat _ast_strlcat +extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t)); +#undef strlcpy +#define strlcpy _ast_strlcpy +extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t)); +#undef strlook +#define strlook _ast_strlook +#undef strmatch +#define strmatch _ast_strmatch +#undef strmode +#define strmode _ast_strmode +#undef strnacmp +#define strnacmp _ast_strnacmp +#undef strncopy +#define strncopy _ast_strncopy +#undef strntod +#define strntod _ast_strntod +#undef strntol +#define strntol _ast_strntol +#undef strntold +#define strntold _ast_strntold +#undef strntoll +#define strntoll _ast_strntoll +#undef strntoul +#define strntoul _ast_strntoul +#undef strntoull +#define strntoull _ast_strntoull +#undef stropt +#define stropt _ast_stropt +#undef strperm +#define strperm _ast_strperm +#undef strpsearch +#define strpsearch _ast_strpsearch +#undef strptime +#define strptime _ast_strptime +#undef strsearch +#define strsearch _ast_strsearch +#undef strsort +#define strsort _ast_strsort +#undef strsubmatch +#define strsubmatch _ast_strsubmatch +#undef strsum +#define strsum _ast_strsum +#undef strtape +#define strtape _ast_strtape +#undef strtoip4 +#define strtoip4 _ast_strtoip4 +#undef strton +#define strton _ast_strton +#undef strtonll +#define strtonll _ast_strtonll +#undef struid +#define struid _ast_struid +#undef struniq +#define struniq _ast_struniq +#undef system +#define system _ast_system +extern __MANGLE__ int system __PROTO__((const char*)); +#undef tempnam +#define tempnam _ast_tempnam +extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*)); +#undef tmpnam +#define tmpnam _ast_tmpnam +extern __MANGLE__ char* tmpnam __PROTO__((char*)); +#undef touch +#define touch _ast_touch +#undef wordexp +#define wordexp _ast_wordexp +#undef wordfree +#define wordfree _ast_wordfree +#undef unsetenv +#define unsetenv _ast_unsetenv + +/* cannot override local malloc */ +#define _map_malloc 1 +#undef calloc +#define calloc _ast_calloc +extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t)); +#undef cfree +#define cfree _ast_cfree +extern __MANGLE__ void cfree __PROTO__((__V_*)); +#undef free +#define free _ast_free +extern __MANGLE__ void free __PROTO__((__V_*)); +#undef malloc +#define malloc _ast_malloc +extern __MANGLE__ __V_* malloc __PROTO__((size_t)); +#undef memalign +#define memalign _ast_memalign +extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t)); +#undef realloc +#define realloc _ast_realloc +extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t)); +#undef strdup +#define strdup _ast_strdup +extern __MANGLE__ char* strdup __PROTO__((const char*)); +#undef valloc +#define valloc _ast_valloc +extern __MANGLE__ __V_* valloc __PROTO__((size_t)); +#undef strtol +#define strtol _ast_strtol +#undef strtoul +#define strtoul _ast_strtoul +#undef strtoll +#define strtoll _ast_strtoll +#undef strtoull +#define strtoull _ast_strtoull +#undef strtod +#define strtod _ast_strtod +#undef strtold +#define strtold _ast_strtold +extern __MANGLE__ long strtol __PROTO__((const char*, char**, int)); +extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int)); +extern __MANGLE__ double strtod __PROTO__((const char*, char**)); +#if !_UWIN +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ +#endif +extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**)); +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ +extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int)); +extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int)); + +#define cmdopen_20120411 _ast_cmdopen_20120411 +#define cmdopen_20110505 _ast_cmdopen_20110505 +#define pathaccess_20100601 _ast_pathaccess_20100601 +#define pathcanon_20100601 _ast_pathcanon_20100601 +#define pathcat_20100601 _ast_pathcat_20100601 +#define pathkey_20100601 _ast_pathkey_20100601 +#define pathpath_20100601 _ast_pathpath_20100601 +#define pathprobe_20100601 _ast_pathprobe_20100601 +#define pathrepl_20100601 _ast_pathrepl_20100601 +#define regexec_20120528 _ast_regexec_20120528 +#define regnexec_20120528 _ast_regnexec_20120528 +#define regrexec_20120528 _ast_regrexec_20120528 +#define regsubexec_20120528 _ast_regsubexec_20120528 +#define sfkeyprintf_20000308 _ast_sfkeyprintf_20000308 +#define strgrpmatch_20120528 _ast_strgrpmatch_20120528 + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_mmap.h b/illumos-x86_64/usr/include/ast/ast_mmap.h new file mode 100644 index 00000000..c4f2a47e --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_mmap.h @@ -0,0 +1,51 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/mmap by iffe version 2012-07-17 : : */ +#ifndef _def_mmap_ast +#define _def_mmap_ast 1 +#define _sys_types 1 /* #include ok */ +#define _sys_mman 1 /* #include ok */ +#define _lib_mmap 1 /* standard mmap interface that works */ +#define _lib_mmap64 1 /* mmap64 interface and implementation work */ +#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */ +#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */ + +/* some systems get it wrong but escape concise detection */ +#ifndef _NO_MMAP +#if __CYGWIN__ +#define _NO_MMAP 1 +#endif +#endif + +#if _NO_MMAP +#undef _lib_mmap +#undef _lib_mmap64 +#undef _mmap_anon +#undef _mmap_devzero +#undef _mmap_worthy +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_mode.h b/illumos-x86_64/usr/include/ast/ast_mode.h new file mode 100644 index 00000000..55d0cae0 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_mode.h @@ -0,0 +1,39 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/mode.c by iffe version 2012-07-17 : : */ +#ifndef _def_mode_ast +#define _def_mode_ast 1 +#define _sys_types 1 /* #include ok */ +#define S_ITYPE(m) ((m)&S_IFMT) + +#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) + +#define _S_IDPERM 1 +#define _S_IDTYPE 1 + +#define BUFFERSIZE 8192 + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_namval.h b/illumos-x86_64/usr/include/ast/ast_namval.h new file mode 100644 index 00000000..20e7fa49 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_namval.h @@ -0,0 +1,48 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * common name-value struct support + */ + +#ifndef _NAMVAL_H +#define _NAMVAL_H + +typedef struct +{ + char* name; + int value; +#ifdef _NAMVAL_PRIVATE_ + _NAMVAL_PRIVATE_ +#endif +} Namval_t; + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_ndbm.h b/illumos-x86_64/usr/include/ast/ast_ndbm.h new file mode 100644 index 00000000..fb354bcd --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_ndbm.h @@ -0,0 +1,34 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/ndbm by iffe version 2012-07-17 : : */ +#ifndef _def_ndbm_ast +#define _def_ndbm_ast 1 +#define _sys_types 1 /* #include ok */ +#define _hdr_ndbm 1 /* #include ok */ +#include +#define _use_ndbm 1 + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_nl_types.h b/illumos-x86_64/usr/include/ast/ast_nl_types.h new file mode 100644 index 00000000..c02792b0 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_nl_types.h @@ -0,0 +1,127 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/nl_types by iffe version 2012-07-17 : : */ + +#ifndef _def_nl_types_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_nl_types_ast 1 +#define _sys_types 1 /* #include ok */ +#define _lib_catopen 1 /* catopen() in default lib(s) */ +#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */ +#define _hdr_nl_types 1 /* #include ok */ +#define _hdr_langinfo 1 /* #include ok */ +#define _nxt_nl_types <../include/nl_types.h> /* include path for the native */ +#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native */ +#include +#include <../include/nl_types.h> /* the native nl_types.h */ + +#undef NL_SETMAX +#define NL_SETMAX 1023 +#undef NL_MSGMAX +#define NL_MSGMAX 32767 +#undef nl_catd +#define nl_catd _ast_nl_catd +#undef catopen +#define catopen _ast_catopen +#undef catgets +#define catgets _ast_catgets +#undef catclose +#define catclose _ast_catclose + +typedef __V_* nl_catd; + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int)); +extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*)); +extern __MANGLE__ int catclose __PROTO__((nl_catd)); + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_param.h b/illumos-x86_64/usr/include/ast/ast_param.h new file mode 100644 index 00000000..727fa879 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_param.h @@ -0,0 +1,34 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/param.sh by iffe version 2012-07-17 : : */ +#ifndef _def_param_ast +#define _def_param_ast 1 +#define _sys_types 1 /* #include ok */ +#include +#ifndef S_IFDIR +#include +#endif +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_sizeof.h b/illumos-x86_64/usr/include/ast/ast_sizeof.h new file mode 100644 index 00000000..7e3b3706 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_sizeof.h @@ -0,0 +1,39 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/sizeof by iffe version 2012-07-17 : : */ +#ifndef _def_sizeof_ast +#define _def_sizeof_ast 1 +#define _sys_types 1 /* #include ok */ +#define _ast_sizeof_char 1 +#define _ast_sizeof_short 2 +#define _ast_sizeof_int 4 +#ifndef __amd64 +#define _ast_sizeof_long 4 +#else /* __amd64 */ +#define _ast_sizeof_long 8 +#endif /* __amd64 */ +#define _ast_sizeof_intmax_t 8 +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_standards.h b/illumos-x86_64/usr/include/ast/ast_standards.h new file mode 100644 index 00000000..d9e727c0 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_standards.h @@ -0,0 +1,70 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/standards by iffe version 2012-07-17 : : */ +#ifndef _def_standards_ast +#define _def_standards_ast 1 +#define _sys_types 1 /* #include ok */ +/* _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */ +#ifndef _ALL_SOURCE +#define _ALL_SOURCE 1 +#endif +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE 1 +#endif +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 21000101L +#endif +#ifndef _XOPEN_SOURCE +#define _XOPEN_SOURCE 9900 +#endif +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif +#ifndef __EXTENSIONS__ +#define __EXTENSIONS__ 1 +#endif + +#define _LIB_m 1 /* -lm is a library */ +/* _ISOC99_SOURCE plays nice */ +#ifndef _ISOC99_SOURCE +#define _ISOC99_SOURCE 1 +#endif + + +/* +* this is a nasty game we all play to honor standards symbol visibility +* it would help if all implementations had +* _KITCHEN_SINK_SOURCE +* that enabled all symbols from the latest implemented standards +* that's probably the most useful but least portable request +*/ + +#if __MACH__ +#undef _POSIX_SOURCE +#endif + + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_std.h b/illumos-x86_64/usr/include/ast/ast_std.h new file mode 100644 index 00000000..f72ac351 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_std.h @@ -0,0 +1,372 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Advanced Software Technology Library + * AT&T Research + * + * a union of standard headers that works + * with local extensions enabled + * and local omission compensation + */ + +#ifndef _AST_STD_H +#define _AST_STD_H 1 +#define _AST_STD_I 1 + +#include + +#if _BLD_ast +#define _BLD_aso 1 +#define _BLD_cdt 1 +#define _BLD_sfio 1 +#if !_UWIN +#define _BLD_vmalloc 1 +#endif +#endif + +#ifdef _SFSTDIO_H +#define _SKIP_SFSTDIO_H +#else +#define _SFSTDIO_H +#ifndef FILE +#ifndef _SFIO_H +struct _sfio_s; +#endif +#define FILE struct _sfio_s +#ifndef __FILE_typedef +#define __FILE_typedef 1 +#endif +#ifndef _FILEDEFED +#define _FILEDEFED 1 +#endif +#endif +#endif + +#include +#include +#include /* does this */ +#include +#include +#include + +#ifdef _SKIP_SFSTDIO_H +#undef _SKIP_SFSTDIO_H +#else +#undef _SFSTDIO_H +#undef FILE +#endif + +/* locale stuff */ + +#if !_hdr_locale + +struct lconv +{ + char* decimal_point; + char* thousands_sep; + char* grouping; + char* int_curr_symbol; + char* currency_symbol; + char* mon_decimal_point; + char* mon_thousands_sep; + char* mon_grouping; + char* positive_sign; + char* negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; + +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#if !_UWIN /* for ast54 compatibility */ + +#undef getenv +#define getenv _ast_getenv + +#undef setenviron +#define setenviron _ast_setenviron + +extern char* getenv(const char*); + +#endif + +#undef localeconv +#define localeconv _ast_localeconv + +#undef setlocale +#define setlocale _ast_setlocale + +#undef strerror +#define strerror _ast_strerror + +extern struct lconv* localeconv(void); +extern char* setenviron(const char*); +extern char* setlocale(int, const char*); +extern char* strerror(int); + +#define AST_MESSAGE_SET 3 /* see mcindex() */ + +/* + * maintain this order when adding categories + */ + +#define AST_LC_ALL 0 +#define AST_LC_COLLATE 1 +#define AST_LC_CTYPE 2 +#define AST_LC_MESSAGES 3 +#define AST_LC_MONETARY 4 +#define AST_LC_NUMERIC 5 +#define AST_LC_TIME 6 +#define AST_LC_IDENTIFICATION 7 +#define AST_LC_ADDRESS 8 +#define AST_LC_NAME 9 +#define AST_LC_TELEPHONE 10 +#define AST_LC_XLITERATE 11 +#define AST_LC_MEASUREMENT 12 +#define AST_LC_PAPER 13 +#define AST_LC_COUNT 14 +#define AST_LC_LANG 255 + +#define AST_LC_internal 1 +#define AST_LC_test (1L<<26) +#define AST_LC_setenv (1L<<27) +#define AST_LC_find (1L<<28) +#define AST_LC_debug (1L<<29) +#define AST_LC_setlocale (1L<<30) +#define AST_LC_translate (1L<<31) + +#ifndef LC_ALL +#define LC_ALL (-AST_LC_ALL) +#endif +#ifndef LC_COLLATE +#define LC_COLLATE (-AST_LC_COLLATE) +#endif +#ifndef LC_CTYPE +#define LC_CTYPE (-AST_LC_CTYPE) +#endif +#ifndef LC_MESSAGES +#define LC_MESSAGES (-AST_LC_MESSAGES) +#endif +#ifndef LC_MONETARY +#define LC_MONETARY (-AST_LC_MONETARY) +#endif +#ifndef LC_NUMERIC +#define LC_NUMERIC (-AST_LC_NUMERIC) +#endif +#ifndef LC_TIME +#define LC_TIME (-AST_LC_TIME) +#endif +#ifndef LC_ADDRESS +#define LC_ADDRESS (-AST_LC_ADDRESS) +#endif +#ifndef LC_IDENTIFICATION +#define LC_IDENTIFICATION (-AST_LC_IDENTIFICATION) +#endif +#ifndef LC_NAME +#define LC_NAME (-AST_LC_NAME) +#endif +#ifndef LC_TELEPHONE +#define LC_TELEPHONE (-AST_LC_TELEPHONE) +#endif +#ifndef LC_XLITERATE +#define LC_XLITERATE (-AST_LC_XLITERATE) +#endif +#ifndef LC_MEASUREMENT +#define LC_MEASUREMENT (-AST_LC_MEASUREMENT) +#endif +#ifndef LC_PAPER +#define LC_PAPER (-AST_LC_PAPER) +#endif +#ifndef LC_LANG +#define LC_LANG (-AST_LC_LANG) +#endif + +#undef extern + +#undef strcoll +#if _std_strcoll +#define strcoll _ast_info.collate +#else +#define strcoll strcmp +#endif + +typedef struct +{ + + char* id; + + struct + { + uint32_t serial; + uint32_t set; + } locale; + + long tmp_long; + size_t tmp_size; + short tmp_short; + char tmp_char; + wchar_t tmp_wchar; + + int (*collate)(const char*, const char*); + + int tmp_int; + void* tmp_pointer; + + int mb_cur_max; + int (*mb_len)(const char*, size_t); + int (*mb_towc)(wchar_t*, const char*, size_t); + size_t (*mb_xfrm)(char*, const char*, size_t); + int (*mb_width)(wchar_t); + int (*mb_conv)(char*, wchar_t); + + uint32_t env_serial; + uint32_t mb_sync; + uint32_t version; + + int (*mb_alpha)(wchar_t); + + char pad[936 - sizeof(void*)]; + +} _Ast_info_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern _Ast_info_t _ast_info; + +#undef extern + +/* largefile hackery -- ast uses the large versions by default */ + +#if _typ_ino64_t +#undef ino_t +#define ino_t ino64_t +#endif +#if _typ_off64_t +#undef off_t +#define off_t off64_t +#endif +#if !defined(ftruncate) && _lib_ftruncate64 +#define ftruncate ftruncate64 +extern int ftruncate64(int, off64_t); +#endif +#if !defined(lseek) && _lib_lseek64 +#define lseek lseek64 +extern off64_t lseek64(int, off64_t, int); +#endif +#if !defined(truncate) && _lib_truncate64 +#define truncate truncate64 +extern int truncate64(const char*, off64_t); +#endif + +/* direct macro access for bsd crossover */ + +#if !defined(__cplusplus) + +#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy) +#define memcpy(t,f,n) (bcopy(f,t,n),(t)) +#endif + +#if !defined(memzero) && !defined(_lib_memzero) +#if defined(_lib_memset) || !defined(_lib_bzero) +#define memzero(b,n) memset(b,0,n) +#else +#define memzero(b,n) (bzero(b,n),(b)) +#endif +#endif + +#endif + +#if !defined(remove) +extern int remove(const char*); +#endif + +#if !defined(rename) +extern int rename(const char*, const char*); +#endif + +#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index) +#define strchr(s,c) index(s,c) +#endif + +#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex) +#define strrchr(s,c) rindex(s,c) +#endif + +/* and now introducing prototypes botched by the standard(s) */ + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#undef getpgrp +#define getpgrp() _ast_getpgrp() +extern int _ast_getpgrp(void); + +#undef extern + +/* + * and finally, standard interfaces hijacked by ast + * _AST_STD_I delays headers that require + */ + +#include + +#undef _AST_STD_I + +#if _AST_GETOPT_H < 0 +#undef _AST_GETOPT_H +#include +#endif + +#if _GETOPT_H < 0 +#undef _GETOPT_H +#include +#endif + +#if _REGEX_H < 0 +#undef _REGEX_H +#include +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_stdio.h b/illumos-x86_64/usr/include/ast/ast_stdio.h new file mode 100644 index 00000000..c66f97c9 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_stdio.h @@ -0,0 +1,616 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/stdio by iffe version 2012-07-17 : : */ + +#ifndef _SFSTDIO_H +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _SFSTDIO_H 1 +#define _sys_types 1 /* #include ok */ +#define __FILE_typedef 1 +#define _FILE_DEFINED 1 +#define _FILE_defined 1 +#define _FILEDEFED 1 + +#ifndef __FILE_TAG +#define __FILE_TAG _sfio_s +#endif + +#undef FILE +#undef _FILE +#undef fpos_t +#undef fpos64_t + +typedef struct _sfio_s _sfio_FILE; + +#define FILE _sfio_FILE +#define _FILE FILE + +#if !defined(__FILE) && !__CYGWIN__ +#undef __FILE +#define __FILE FILE +#endif + +#if defined(_AST_H) || defined(_SFIO_H) + +#define BUFSIZ SF_BUFSIZE + +#else + +#ifndef BUFSIZ +#define BUFSIZ 8192 +#endif + +#ifndef EOF +#define EOF (-1) +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#include + +#include + +#if __cplusplus +#define _sf_(f) (f) +#else +#define _sf_(f) ((struct _sfio_s*)(f)) +#endif + +#define _SF_EOF 0000200 +#define _SF_ERROR 0000400 + +#endif + +#ifdef _NO_LARGEFILE64_SOURCE +#undef _LARGEFILE64_SOURCE +#endif + +#ifdef _LARGEFILE64_SOURCE +#undef off_t +#endif + +#define fpos_t _ast_fpos_t +#if _typ_int64_t +#define fpos64_t _ast_fpos_t +#endif + +typedef struct _ast_fpos_s +{ + intmax_t _sf_offset; + unsigned char _sf_state[64 - sizeof(intmax_t)]; +} _ast_fpos_t; + +#define _base _data +#define _ptr _next +#define _IOFBF 0 +#define _IONBF 1 +#define _IOLBF 2 + +#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN) + +#undef FILE +#define FILE FILE +typedef struct _sfio_s FILE; + +#undef strerror +extern __MANGLE__ char* strerror(int) __THROW; + +extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*)); +extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list)); +extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...)); +extern __MANGLE__ int clearerr __PROTO__((FILE*)); +extern __MANGLE__ int fclose __PROTO__((FILE*)); +extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*)); +extern __MANGLE__ int feof __PROTO__((FILE*)); +extern __MANGLE__ int ferror __PROTO__((FILE*)); +extern __MANGLE__ int fflush __PROTO__((FILE*)); +extern __MANGLE__ int fgetc __PROTO__((FILE*)); +extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*)); +extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*)); +extern __MANGLE__ int fileno __PROTO__((FILE*)); +extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*)); +extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...)); +extern __MANGLE__ int fpurge __PROTO__((FILE*)); +extern __MANGLE__ int fputc __PROTO__((int, FILE*)); +extern __MANGLE__ int fputs __PROTO__((const char*, FILE*)); +extern __MANGLE__ size_t fread __PROTO__((__V_*, size_t, size_t, FILE*)); +extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*)); +extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...)); +extern __MANGLE__ int fseek __PROTO__((FILE*, long, int)); +extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int)); +extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*)); +extern __MANGLE__ long ftell __PROTO__((FILE*)); +extern __MANGLE__ off_t ftello __PROTO__((FILE*)); +extern __MANGLE__ size_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*)); +extern __MANGLE__ int getc __PROTO__((FILE*)); +extern __MANGLE__ int getchar __PROTO__((void)); +extern __MANGLE__ char* gets __PROTO__((char*)); +extern __MANGLE__ int getw __PROTO__((FILE*)); +extern __MANGLE__ int pclose __PROTO__((FILE*)); +extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*)); +extern __MANGLE__ int printf __PROTO__((const char*, ...)); +extern __MANGLE__ int putc __PROTO__((int, FILE*)); +extern __MANGLE__ int putchar __PROTO__((int)); +extern __MANGLE__ int puts __PROTO__((const char*)); +extern __MANGLE__ int putw __PROTO__((int, FILE*)); +extern __MANGLE__ void rewind __PROTO__((FILE*)); +extern __MANGLE__ int scanf __PROTO__((const char*, ...)); +extern __MANGLE__ void setbuf __PROTO__((FILE*, char*)); +extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int)); +extern __MANGLE__ int setlinebuf __PROTO__((FILE*)); +extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t)); +extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...)); +extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...)); +extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...)); +extern __MANGLE__ FILE* tmpfile __PROTO__((void)); +extern __MANGLE__ int ungetc __PROTO__((int, FILE*)); +extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list)); +extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list)); +extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list)); +extern __MANGLE__ int vprintf __PROTO__((const char*, va_list)); +extern __MANGLE__ int vscanf __PROTO__((const char*, va_list)); +extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list)); +extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list)); +extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list)); + +#if _typ_int64_t + +extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*)); +extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*)); +extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int)); +extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int)); +extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*)); +extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*)); + +#endif + +extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int feof_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*)); +extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*)); +extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*)); +extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*)); +extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*)); +extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*)); +extern __MANGLE__ int getc_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int getchar_unlocked __PROTO__((void)); +extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*)); +extern __MANGLE__ int putchar_unlocked __PROTO__((int)); + +extern __MANGLE__ void flockfile __PROTO__((FILE*)); +extern __MANGLE__ int ftrylockfile __PROTO__((FILE*)); +extern __MANGLE__ void funlockfile __PROTO__((FILE*)); + +#ifdef _USE_GNU + +extern __MANGLE__ int fcloseall __PROTO__((void)); +extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*)); +extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*)); +extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*)); +extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*)); + +#endif + +#endif + +#ifndef FILENAME_MAX +#define FILENAME_MAX 1024 +#endif +#ifndef FOPEN_MAX +#ifndef __amd64 +#define FOPEN_MAX 60 +#else /* __amd64 */ +#define FOPEN_MAX 20 +#endif /* __amd64 */ +#endif +#ifndef TMP_MAX +#define TMP_MAX 17576 +#endif + +#define _doprnt _ast_doprnt +#define _doscan _ast_doscan +#define asprintf _ast_asprintf +#define clearerr _ast_clearerr +#define fclose _ast_fclose +#define fdopen _ast_fdopen +#define fflush _ast_fflush +#define fgetc _ast_fgetc +#define fgetpos _ast_fgetpos +#define fgetpos64 _ast_fgetpos64 +#define fgets _ast_fgets +#define fopen _ast_fopen +#define fprintf _ast_fprintf +#define fpurge _ast_fpurge +#define fputs _ast_fputs +#define fread _ast_fread +#define freopen _ast_freopen +#define fscanf _ast_fscanf +#define fseek _ast_fseek +#define fseek64 _ast_fseek64 +#define fseeko _ast_fseeko +#define fseeko64 _ast_fseeko64 +#define fsetpos _ast_fsetpos +#define fsetpos64 _ast_fsetpos64 +#define ftell _ast_ftell +#define ftell64 _ast_ftell64 +#define ftello _ast_ftello +#define ftello64 _ast_ftello64 +#define fwrite _ast_fwrite +#define gets _ast_gets +#define getw _ast_getw +#define pclose _ast_pclose +#define popen _ast_popen +#define printf _ast_printf +#define puts _ast_puts +#define putw _ast_putw +#define rewind _ast_rewind +#define scanf _ast_scanf +#define setbuf _ast_setbuf +#undef setbuffer +#define setbuffer _ast_setbuffer +#define setlinebuf _ast_setlinebuf +#define setvbuf _ast_setvbuf +#define snprintf _ast_snprintf +#define sprintf _ast_sprintf +#define sscanf _ast_sscanf +#define tmpfile _ast_tmpfile +#define ungetc _ast_ungetc +#define vasprintf _ast_vasprintf +#define vfprintf _ast_vfprintf +#define vfscanf _ast_vfscanf +#define vprintf _ast_vprintf +#define vscanf _ast_vscanf +#define vsnprintf _ast_vsnprintf +#define vsprintf _ast_vsprintf +#define vsscanf _ast_vsscanf +#define fcloseall _ast_fcloseall +#define _filbuf _ast__filbuf +#define fmemopen _ast_fmemopen +#define __getdelim _ast___getdelim +#define getdelim _ast_getdelim +#define getline _ast_getline +#define clearerr_unlocked _ast_clearerr_unlocked +#define feof_unlocked _ast_feof_unlocked +#define ferror_unlocked _ast_ferror_unlocked +#define fflush_unlocked _ast_fflush_unlocked +#define fgetc_unlocked _ast_fgetc_unlocked +#define fgets_unlocked _ast_fgets_unlocked +#define fileno_unlocked _ast_fileno_unlocked +#define fputc_unlocked _ast_fputc_unlocked +#define fputs_unlocked _ast_fputs_unlocked +#define fread_unlocked _ast_fread_unlocked +#define fwrite_unlocked _ast_fwrite_unlocked +#define getc_unlocked _ast_getc_unlocked +#define getchar_unlocked _ast_getchar_unlocked +#define putc_unlocked _ast_putc_unlocked +#define putchar_unlocked _ast_putchar_unlocked +#define flockfile _ast_flockfile +#define ftrylockfile _ast_ftrylockfile +#define funlockfile _ast_funlockfile + +#if defined(__STDPP__directive) && defined(__STDPP__initial) +__STDPP__directive pragma pp:initial +#endif +#ifndef P_tmpdir +#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/ +#endif +#ifndef L_ctermid +#define L_ctermid 9 +#endif +#ifndef L_tmpnam +#define L_tmpnam 25 +#endif +#if defined(__STDPP__directive) && defined(__STDPP__initial) +__STDPP__directive pragma pp:noinitial +#endif +#if defined(__cplusplus) && defined(__THROW) +extern __MANGLE__ char* ctermid(char*) __THROW; +#else +extern __MANGLE__ char* ctermid __PROTO__((char*)); +#endif +extern __MANGLE__ char* tmpnam __PROTO__((char*)); +extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*)); +extern __MANGLE__ void perror __PROTO__((const char*)); +#ifndef _AST_STD_H +#ifndef remove +extern __MANGLE__ int remove __PROTO__((const char*)); +#endif +#ifndef rename +extern __MANGLE__ int rename __PROTO__((const char*, const char*)); +#endif +#endif + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*)); +extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list)); +extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...)); +extern __MANGLE__ int clearerr __PROTO__((FILE*)); +extern __MANGLE__ int fclose __PROTO__((FILE*)); +extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*)); +extern __MANGLE__ int feof __PROTO__((FILE*)); +extern __MANGLE__ int ferror __PROTO__((FILE*)); +extern __MANGLE__ int fflush __PROTO__((FILE*)); +extern __MANGLE__ int fgetc __PROTO__((FILE*)); +extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*)); +extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*)); +extern __MANGLE__ int fileno __PROTO__((FILE*)); +extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*)); +extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...)); +extern __MANGLE__ int fpurge __PROTO__((FILE*)); +extern __MANGLE__ int fputc __PROTO__((int, FILE*)); +extern __MANGLE__ int fputs __PROTO__((const char*, FILE*)); +extern __MANGLE__ size_t fread __PROTO__((__V_*, size_t, size_t, FILE*)); +extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*)); +extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...)); +extern __MANGLE__ int fseek __PROTO__((FILE*, long, int)); +extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int)); +extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*)); +extern __MANGLE__ long ftell __PROTO__((FILE*)); +extern __MANGLE__ off_t ftello __PROTO__((FILE*)); +extern __MANGLE__ size_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*)); +extern __MANGLE__ int getc __PROTO__((FILE*)); +extern __MANGLE__ int getchar __PROTO__((void)); +extern __MANGLE__ char* gets __PROTO__((char*)); +extern __MANGLE__ int getw __PROTO__((FILE*)); +extern __MANGLE__ int pclose __PROTO__((FILE*)); +extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*)); +extern __MANGLE__ int printf __PROTO__((const char*, ...)); +extern __MANGLE__ int putc __PROTO__((int, FILE*)); +extern __MANGLE__ int putchar __PROTO__((int)); +extern __MANGLE__ int puts __PROTO__((const char*)); +extern __MANGLE__ int putw __PROTO__((int, FILE*)); +extern __MANGLE__ void rewind __PROTO__((FILE*)); +extern __MANGLE__ int scanf __PROTO__((const char*, ...)); +extern __MANGLE__ void setbuf __PROTO__((FILE*, char*)); +extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int)); +extern __MANGLE__ int setlinebuf __PROTO__((FILE*)); +extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t)); +extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...)); +extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...)); +extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...)); +extern __MANGLE__ FILE* tmpfile __PROTO__((void)); +extern __MANGLE__ int ungetc __PROTO__((int, FILE*)); +extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list)); +extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list)); +extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list)); +extern __MANGLE__ int vprintf __PROTO__((const char*, va_list)); +extern __MANGLE__ int vscanf __PROTO__((const char*, va_list)); +extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list)); +extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list)); +extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list)); + +#if _typ_int64_t + +extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*)); +extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*)); +extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int)); +extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int)); +extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*)); +extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*)); + +#ifdef _LARGEFILE64_SOURCE + +#undef fpos_t +#undef off_t +#undef fgetpos +#undef fsetpos +#undef fseek +#undef fseeko +#undef ftell +#undef ftello + +#define fpos_t fpos64_t +#if _typ_off64_t +#define off_t off64_t +#else +#define off_t int64_t +#endif + +#define fgetpos fgetpos64 +#define fsetpos fsetpos64 +#define fseek fseek64 +#define fseeko fseeko64 +#define ftell ftell64 +#define ftello ftello64 + +#endif + +#endif + +extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int feof_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*)); +extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*)); +extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*)); +extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*)); +extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*)); +extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*)); +extern __MANGLE__ int getc_unlocked __PROTO__((FILE*)); +extern __MANGLE__ int getchar_unlocked __PROTO__((void)); +extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*)); +extern __MANGLE__ int putchar_unlocked __PROTO__((int)); + +#ifdef _USE_GNU + +extern __MANGLE__ int fcloseall __PROTO__((void)); +extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*)); +extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*)); +extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*)); +extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*)); + +#endif + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#if _BLD_DLL && _DLL_INDIRECT_DATA + +#define stdin ((FILE*)_ast_dll->_ast_stdin) +#define stdout ((FILE*)_ast_dll->_ast_stdout) +#define stderr ((FILE*)_ast_dll->_ast_stderr) + +#else + +#define stdin (&_Sfstdin) +#define stdout (&_Sfstdout) +#define stderr (&_Sfstderr) + +#endif + +#if defined(_AST_H) || defined(_SFIO_H) + +#define feof(f) sfeof(f) +#define ferror(f) sferror(f) +#define fileno(f) sffileno(f) +#define fputc(c,f) sfputc(f,c) +#define getc(f) sfgetc(f) +#define getchar() sfgetc(sfstdin) +#define putc(c,f) sfputc(f,c) +#define putchar(c) sfputc(sfstdout,c) + +#else + +#if !_UWIN +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __IMPORT__ +#endif +#endif + +extern __MANGLE__ FILE _Sfstdin; +extern __MANGLE__ FILE _Sfstdout; +extern __MANGLE__ FILE _Sfstderr; + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#define feof(f) (_sf_(f)->_flags&_SF_EOF) +#define ferror(f) (_sf_(f)->_flags&_SF_ERROR) +#define fileno(f) (_sf_(f)->_file) +#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c))) +#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++)) +#define getchar() getc(stdin) +#define putc(c,f) fputc(c,f) +#define putchar(c) fputc(c,stdout) + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int)); +extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int)); + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_sys.h b/illumos-x86_64/usr/include/ast/ast_sys.h new file mode 100644 index 00000000..2da663c2 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_sys.h @@ -0,0 +1,183 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/sys by iffe version 2012-07-17 : : */ + +#ifndef _AST_SYS_H +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _AST_SYS_H 1 +#define _sys_types 1 /* #include ok */ +#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE) +#define _NO_LARGEFILE64_SOURCE 1 +#endif +#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64 +#if !defined(_LARGEFILE64_SOURCE) +#define _LARGEFILE64_SOURCE 1 +#endif +#if !defined(_LARGEFILE_SOURCE) +#define _LARGEFILE_SOURCE 1 +#endif +#if !defined(_LARGE_FILE_API) +#define _LARGE_FILE_API 1 +#endif +#else +#undef _LARGEFILE64_SOURCE +#undef _LARGEFILE_SOURCE +#undef _LARGE_FILE_API +#undef _typ_ino64_t +#undef _typ_off64_t +#undef _typ_struct_dirent64 +#undef _lib_creat64 +#undef _lib_fstat64 +#undef _lib_fstatvfs64 +#undef _lib_ftruncate64 +#undef _lib_lseek64 +#undef _lib_lstat64 +#undef _lib_mmap64 +#undef _lib_open64 +#undef _lib_readdir64 +#undef _lib_stat64 +#undef _lib_statvfs64 +#undef _lib_truncate64 +#endif +#if !_lib_readdir64 +#undef _typ_ino64_t +#endif +#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__) +#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */ +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define _hdr_time 1 /* #include ok */ +#define _sys_time 1 /* #include ok */ +#define _sys_times 1 /* #include ok */ +#define _typ_dev_t 1 /* dev_t is a type */ +#define _typ_nlink_t 1 /* nlink_t is a type */ +#define _typ_gid_t 1 /* gid_t is a type */ +#define _typ_mode_t 1 /* mode_t is a type */ +#define _typ_uid_t 1 /* uid_t is a type */ +#define _hdr_stdio 1 /* #include ok */ +#define _hdr_wchar 1 /* #include ok */ +#define _typ_wchar_t 1 /* wchar_t is a type */ +#define _typ_pid_t 1 /* pid_t is a type */ +#define _typ_ssize_t 1 /* ssize_t is a type */ +#define _typ_wint_t 1 /* wint_t is a type */ +#define _sys_socket 1 /* #include ok */ +#define _typ_socklen_t 1 /* socklen_t is a type */ +#define _typ_size_t 1 /* size_t is a type */ +#define _typ_clock_t 1 /* clock_t is a type */ +#define _typ_ino_t 1 /* ino_t is a type */ +#define _typ_off_t 1 /* off_t is a type */ +#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */ +#define _typ_time_t 1 /* time_t is a type */ +#define _typ_div_t 1 /* div_t is a type */ +#define _typ_ldiv_t 1 /* ldiv_t is a type */ +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif +extern __MANGLE__ void cfree __PROTO__((__V_*)); +extern __MANGLE__ size_t confstr __PROTO__((int, char*, size_t)); +extern __MANGLE__ int eaccess __PROTO__((const char*, int)); +extern __MANGLE__ __V_* pvalloc __PROTO__((size_t)); +extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t)); +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ +#if !defined(va_start) +#if defined(__STDARG__) +#include +#else +#include +#endif +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_time.h b/illumos-x86_64/usr/include/ast/ast_time.h new file mode 100644 index 00000000..8c56ba68 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_time.h @@ -0,0 +1,108 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/time by iffe version 2012-07-17 : : */ + +#ifndef _def_time_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_time_ast 1 +#define _sys_types 1 /* #include ok */ +#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */ +#define _lib_usleep 1 /* usleep() in default lib(s) */ +#define _hdr_time 1 /* #include ok */ +#define _sys_time 1 /* #include ok */ +#define _sys_times 1 /* #include ok */ +#define _hdr_stddef 1 /* #include ok */ +#define _hdr_stdlib 1 /* #include ok */ +#define _typ_clock_t 1 /* clock_t is a type */ +#define _typ_time_t 1 /* time_t is a type */ +#include + +#include + +#if !defined(CLOCKS_PER_SEC) && defined(CLK_TCK) +#define CLOCKS_PER_SEC CLK_TCK +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_tty.h b/illumos-x86_64/usr/include/ast/ast_tty.h new file mode 100644 index 00000000..70088614 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_tty.h @@ -0,0 +1,159 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/tty by iffe version 2012-07-17 : : */ +#ifndef _def_tty_ast +#define _def_tty_ast 1 +#define _sys_types 1 /* #include ok */ +#define _hdr_termios 1 /* #include ok */ +#define _hdr_termio 1 /* #include ok */ +#define _hdr_sgtty 1 /* #include ok */ +#define _sys_termios 1 /* #include ok */ +#define _sys_termio 1 /* #include ok */ +#define _sys_ioctl 1 /* #include ok */ +#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */ +#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */ +#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */ + +#ifdef _hdr_termios +# if _mac__POSIX_VDISABLE +# undef _POSIX_VDISABLE +# endif +# include +#else +# if defined(_sys_termios) && defined(_lib_tcgetattr) +# include +# define _hdr_termios 1 +# else +# undef _sys_termios +# endif /* _sys_termios */ +#endif /* _hdr_termios */ + +#ifdef _hdr_termios +# undef _hdr_sgtty +# undef tcgetattr +# undef tcsetattr +# undef tcgetpgrp +# undef tcsetpgrp +# undef cfgetospeed +# ifndef TCSANOW +# define TCSANOW TCSETS +# define TCSADRAIN TCSETSW +# define TCSAFLUSH TCSETSF +# endif /* TCSANOW */ + /* The following corrects bugs in some implementations */ +# if defined(TCSADFLUSH) && !defined(TCSAFLUSH) +# define TCSAFLUSH TCSADFLUSH +# endif /* TCSADFLUSH */ +# ifndef _lib_tcgetattr +# undef tcgetattr +# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty) +# undef tcsetattr +# define tcsetattr(fd,action,tty) ioctl(fd, action, tty) +# undef cfgetospeed +# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD) +# endif /* _lib_tcgetattr */ +# undef TIOCGETC +#else +# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD) +# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD) +# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val)) +# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val)) +# ifdef _hdr_termio +# include +# else +# ifdef _sys_termio +# include +# define _hdr_termio 1 +# endif /* _sys_termio */ +# endif /* _hdr_termio */ +# ifdef _hdr_termio +# define termios termio +# undef TIOCGETC +# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty) +# define tcsetattr(fd,action,tty) ioctl(fd, action, tty) + +# ifdef _sys_bsdtty +# include +# endif /* _sys_bsdtty */ +# else +# ifdef _hdr_sgtty +# include +# ifndef LPENDIN +# ifdef _sys_nttyio +# include +# endif /* _sys_nttyio */ +# endif /* LPENDIN */ +# define termios sgttyb +# ifdef TIOCSETN +# undef TCSETAW +# endif /* TIOCSETN */ +# ifdef TIOCGETP +# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty) +# define tcsetattr(fd,action,tty) ioctl(fd, action, tty) +# else +# define tcgetattr(fd,tty) gtty(fd, tty) +# define tcsetattr(fd,action,tty) stty(fd, tty) +# endif /* TIOCGETP */ +# else +# ifdef _sys_ttyio +# include +# endif +# endif /* _hdr_sgtty */ +# endif /* hdr_termio */ + +# ifndef TCSANOW +# ifdef TCSETAW +# define TCSANOW TCSETA +# define TCSAFLUSH TCSETAF +# else +# ifdef TIOCSETN +# define TCSANOW TIOCSETN +# define TCSADRAIN TIOCSETN +# define TCSAFLUSH TIOCSETP +# endif /* TIOCSETN */ +# endif /* TCSETAW */ +# endif /* TCSANOW */ +#endif /* _hdr_termios */ + +/* set ECHOCTL if driver can echo control charaters as ^c */ +#ifdef LCTLECH +# ifndef ECHOCTL +# define ECHOCTL LCTLECH +# endif /* !ECHOCTL */ +#endif /* LCTLECH */ +#ifdef LNEW_CTLECH +# ifndef ECHOCTL +# define ECHOCTL LNEW_CTLECH +# endif /* !ECHOCTL */ +#endif /* LNEW_CTLECH */ +#ifdef LNEW_PENDIN +# ifndef PENDIN +# define PENDIN LNEW_PENDIN +# endif /* !PENDIN */ +#endif /* LNEW_PENDIN */ + + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_vfork.h b/illumos-x86_64/usr/include/ast/ast_vfork.h new file mode 100644 index 00000000..dc1ab9de --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_vfork.h @@ -0,0 +1,93 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/vfork by iffe version 2012-07-17 : : */ + +#ifndef _def_vfork_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_vfork_ast 1 +#define _sys_types 1 /* #include ok */ +extern __MANGLE__ pid_t vfork(void) __attribute__((__returns_twice__)); +#pragma unknown_control_flow(vfork) +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_wait.h b/illumos-x86_64/usr/include/ast/ast_wait.h new file mode 100644 index 00000000..013158d2 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_wait.h @@ -0,0 +1,36 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/wait by iffe version 2012-07-17 : : */ +#ifndef _def_wait_ast +#define _def_wait_ast 1 +#define _sys_types 1 /* #include ok */ +#define _lib_wait 1 /* wait() in default lib(s) */ +#define _lib_wait3 1 /* wait3() in default lib(s) */ +#define _lib_wait4 1 /* wait4() in default lib(s) */ +#define _lib_waitpid 1 /* waitpid() in default lib(s) */ +#define _sys_wait 1 /* #include ok */ +#define _ok_wif 1 /* posix wait macros ok */ +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_wchar.h b/illumos-x86_64/usr/include/ast/ast_wchar.h new file mode 100644 index 00000000..d2e243c2 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_wchar.h @@ -0,0 +1,223 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/wchar by iffe version 2012-07-17 : : */ + + +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif +#define _sys_types 1 /* #include ok */ +#ifndef _AST_WCHAR_H +#define _AST_WCHAR_H 1 + +#define _hdr_stdlib 1 /* #include ok */ +#define _hdr_stdio 1 /* #include ok */ +#define _hdr_wchar 1 /* #include ok */ +#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */ +#define _lib_wctomb 1 /* wctomb() in default lib(s) */ +#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */ +#define _lib_wcslen 1 /* wcslen() in default lib(s) */ +#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */ +#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */ +#define _lib_towlower 1 /* towlower() in default lib(s) */ +#define _lib_towupper 1 /* towupper() in default lib(s) */ +#define _hdr_time 1 /* #include ok */ +#define _sys_time 1 /* #include ok */ +#define _sys_times 1 /* #include ok */ +#define _hdr_stddef 1 /* #include ok */ +#define _typ_mbstate_t 1 /* mbstate_t is a type */ +#define _nxt_wchar <../include/wchar.h> /* include path for the native */ +#define _nxt_wchar_str "../include/wchar.h" /* include string for the native */ +#ifndef _SFSTDIO_H +#include +#include +#endif + +#define _hdr_unistd 1 /* #include ok */ +#include /* includes */ + +#if _hdr_wchar && defined(_nxt_wchar) +#include <../include/wchar.h> /* the native wchar.h */ +#endif + +#ifndef WEOF +#define WEOF (-1) +#endif + +#undef fgetwc +#undef fgetws +#undef fputwc +#undef fputws +#undef getwc +#undef getwchar +#undef getws +#undef putwc +#undef putwchar +#undef ungetwc + +#define fgetwc _ast_fgetwc +#define fgetws _ast_fgetws +#define fputwc _ast_fputwc +#define fputws _ast_fputws +#define fwide _ast_fwide +#define fwprintf _ast_fwprintf +#define fwscanf _ast_fwscanf +#define getwc _ast_getwc +#define getwchar _ast_getwchar +#define getws _ast_getws +#define putwc _ast_putwc +#define putwchar _ast_putwchar +#define swprintf _ast_swprintf +#define swscanf _ast_swscanf +#define ungetwc _ast_ungetwc +#define vfwprintf _ast_vfwprintf +#define vfwscanf _ast_vfwscanf +#define vswprintf _ast_vswprintf +#define vswscanf _ast_vswscanf +#define vwprintf _ast_vwprintf +#define vwscanf _ast_vwscanf +#define wprintf _ast_wprintf +#define wscanf _ast_wscanf + +#if !_typ_mbstate_t +#undef _typ_mbstate_t +#define _typ_mbstate_t 1 +typedef char mbstate_t; +#endif + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +#if !_lib_mbstowcs +extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t)); +#endif +#if !_lib_wctomb +extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t)); +#endif +#if !_lib_wcrtomb +extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*)); +#endif +#if !_lib_wcslen +extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*)); +#endif +#if !_lib_wcstombs +extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t)); +#endif + +extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...)); +extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...)); +extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*)); +extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*)); +extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*)); +extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*)); +extern __MANGLE__ int fwide __PROTO__((FILE*, int)); +extern __MANGLE__ wint_t getwc __PROTO__((FILE*)); +extern __MANGLE__ wint_t getwchar __PROTO__((void)); +extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*)); +extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*)); +extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t)); +extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...)); +extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...)); +extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*)); +extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list)); +extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list)); +extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list)); +extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list)); +extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list)); +extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list)); +extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...)); +extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...)); + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#else + +/* on some systems is included multiple times with multiple effects */ + +#if _hdr_wchar && defined(_nxt_wchar) +#include <../include/wchar.h> /* the native wchar.h */ +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_wctype.h b/illumos-x86_64/usr/include/ast/ast_wctype.h new file mode 100644 index 00000000..73bd1a62 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_wctype.h @@ -0,0 +1,100 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/wctype by iffe version 2012-07-17 : : */ + +#ifndef _def_wctype_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_wctype_ast 1 +#define _sys_types 1 /* #include ok */ +#define _nxt_wctype <../include/wctype.h> /* include path for the native */ +#define _nxt_wctype_str "../include/wctype.h" /* include string for the native */ +#if _hdr_wctype && defined(_nxt_wctype) +#include <../include/wctype.h> /* the native wctype.h */ +#endif + +#undef iswalpha + +#define iswalpha(w) (ast.mb_alpha?(*ast.mb_alpha)(w):isalpha(w)) +#endif diff --git a/illumos-x86_64/usr/include/ast/ast_windows.h b/illumos-x86_64/usr/include/ast/ast_windows.h new file mode 100644 index 00000000..ccee4c19 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ast_windows.h @@ -0,0 +1,45 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * AT&T Research + * + * ast wrapper + * for libast only + * include after ast headers + */ + +#ifndef _AST_WINDOWS_H +#define _AST_WINDOWS_H 1 + +#undef SF_ERROR /* clash in */ + +#include + +#endif diff --git a/illumos-x86_64/usr/include/ast/bytesex.h b/illumos-x86_64/usr/include/ast/bytesex.h new file mode 100644 index 00000000..869a20cd --- /dev/null +++ b/illumos-x86_64/usr/include/ast/bytesex.h @@ -0,0 +1,49 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* + * linux/gnu compatibility + */ + +#ifndef _BYTESEX_H +#define _BYTESEX_H + +#include + +#undef __BYTE_ORDER + +#if ( _ast_intswap & 3 ) == 3 +#define __BYTE_ORDER __LITTLE_ENDIAN +#else +#if ( _ast_intswap & 3 ) == 1 +#define __BYTE_ORDER __PDP_ENDIAN +#else +#define __BYTE_ORDER __BIG_ENDIAN +#endif +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/ccode.h b/illumos-x86_64/usr/include/ast/ccode.h new file mode 100644 index 00000000..0859277d --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ccode.h @@ -0,0 +1,96 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * Glenn Fowler + * AT&T Research + * + * character code map interface + * + * NOTE: used for mapping between 8-bit character encodings + * ISO character sets are handled by sfio + */ + +#ifndef _CHARCODE_H +#define _CHARCODE_H 1 + +#include +#include + +typedef struct Ccmap_s +{ + const char* name; /* code set name */ + const char* match; /* strmatch() pattern */ + const char* desc; /* code set description */ + const char* canon; /* canonical name format */ + const char* index; /* default index */ + int ccode; /* code index */ + void* data; /* map specific data */ +} Ccmap_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern unsigned char* _ccmap(int, int); +extern void* _ccmapcpy(unsigned char*, void*, const void*, size_t); +extern void* _ccmapstr(unsigned char*, void*, size_t); + +extern int ccmapid(const char*); +extern char* ccmapname(int); +extern void* ccnative(void*, const void*, size_t); +extern Ccmap_t* ccmaplist(Ccmap_t*); + +#undef extern + +#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i))) +#define CCIN(x) ((x)&0xFF) +#define CCOUT(x) (((x)>>8)&0xFF) +#define CCCONVERT(x) ((x)&0xFF00) + +#define CCCVT(x) CCMAP(x,0) +#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o)) +#define CCMAPCHR(m,c) ((m)?(m)[c]:(c)) +#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n)) +#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(void*)(s)) + +#define ccmap(i,o) CCMAP(i,o) +#define ccmapchr(m,c) CCMAPCHR(m,c) +#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n) +#define ccmapstr(m,s,n) CCMAPSTR(m,s,n) + +#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c]) +#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n)) +#define CCMAPS(s,n,i,o) ((i)==(o)?(void*)(s):_ccmapstr(CCMAP(i,o),s,n)) + +#define ccmapc(c,i,o) CCMAPC(c,i,o) +#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o) +#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o) + +#endif diff --git a/illumos-x86_64/usr/include/ast/cdt.h b/illumos-x86_64/usr/include/ast/cdt.h new file mode 100644 index 00000000..3af80549 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/cdt.h @@ -0,0 +1,360 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#ifndef _CDT_H +#define _CDT_H 1 + +/* Public interface for the dictionary library +** +** Written by Kiem-Phong Vo +*/ + +#ifndef CDT_VERSION +#ifdef _API_ast +#define CDT_VERSION _API_ast +#else +#define CDT_VERSION 20111111L +#endif /*_AST_api*/ +#endif /*CDT_VERSION*/ +#ifndef AST_PLUGIN_VERSION +#define AST_PLUGIN_VERSION(v) (v) +#endif +#define CDT_PLUGIN_VERSION AST_PLUGIN_VERSION(20111111L) + +#if _PACKAGE_ast +#include +#else +#include +#include +#endif + +/* commonly used integers */ +#define DT_ZERO ((unsigned int)0) /* all zero bits */ +#define DT_ONES (~DT_ZERO) /* all one bits */ +#define DT_HIBIT (~(DT_ONES >> 1) ) /* highest 1 bit */ +#define DT_LOBIT ((unsigned int)1) /* lowest 1 bit */ +#define DT_NBITS (sizeof(unsigned int)*8) /* #bits */ + +/* type of an integer with the same size as a pointer */ +#define Dtuint_t uintptr_t + +/* various types used by CDT */ +typedef struct _dtlink_s Dtlink_t; +typedef struct _dthold_s Dthold_t; +typedef struct _dtdisc_s Dtdisc_t; +typedef struct _dtmethod_s Dtmethod_t; +typedef struct _dtdata_s Dtdata_t; +typedef struct _dtuser_s Dtuser_t; +typedef struct _dt_s Dt_t; +typedef struct _dtstat_s Dtstat_t; +typedef Void_t* (*Dtsearch_f)_ARG_((Dt_t*,Void_t*,int)); +typedef Void_t* (*Dtmake_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*)); +typedef void (*Dtfree_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*)); +typedef int (*Dtcompar_f)_ARG_((Dt_t*,Void_t*,Void_t*,Dtdisc_t*)); +typedef unsigned int (*Dthash_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*)); +typedef Void_t* (*Dtmemory_f)_ARG_((Dt_t*,Void_t*,size_t,Dtdisc_t*)); +typedef int (*Dtevent_f)_ARG_((Dt_t*,int,Void_t*,Dtdisc_t*)); +typedef int (*Dttype_f)_ARG_((Dt_t*,int)); + +struct _dtuser_s /* for application to access and use */ +{ unsigned int lock; /* used by dtapplock */ + Void_t* data; /* for whatever data */ +}; + +struct _dtlink_s +{ +#if CDT_VERSION < 20111111L + Dtlink_t* right; /* right child */ + union + { unsigned int _hash; /* hash value */ + Dtlink_t* _left; /* left child */ + } hl; +#else + union + { Dtlink_t* __rght; /* right child or next */ + Dtlink_t* __ptbl; /* Dtrehash parent tbl */ + } rh; + union + { Dtlink_t* __left; /* left child or prev */ + unsigned int __hash; /* hash value of object */ + } lh; +#endif +}; + +/* private structure to hold an object */ +struct _dthold_s +{ Dtlink_t hdr; /* header to hold obj */ + Void_t* obj; /* application object */ +}; + +/* method to manipulate dictionary structure */ +struct _dtmethod_s +{ Dtsearch_f searchf; /* search function */ + unsigned int type; /* type of operation */ + int (*eventf)_ARG_((Dt_t*, int, Void_t*)); + char* name; /* name of method */ + char* description; /* description */ +}; + +/* structure to hold methods that manipulate an object */ +struct _dtdisc_s +{ int key; /* where the key resides */ + int size; /* key size and type */ + int link; /* offset to Dtlink_t field */ + Dtmake_f makef; /* object constructor */ + Dtfree_f freef; /* object destructor */ + Dtcompar_f comparf;/* to compare two objects */ + Dthash_f hashf; /* to compute hash value */ + Dtmemory_f memoryf;/* to allocate/free memory */ + Dtevent_f eventf; /* to process events */ +}; + +#define DTDISC(dc,ky,sz,lk,mkf,frf,cmpf,hshf,memf,evf) \ + ( (dc)->key = (int)(ky), (dc)->size = (int)(sz), (dc)->link = (int)(lk), \ + (dc)->makef = (mkf), (dc)->freef = (frf), \ + (dc)->comparf = (cmpf), (dc)->hashf = (hshf), \ + (dc)->memoryf = (memf), (dc)->eventf = (evf) ) + +#ifdef offsetof +#define DTOFFSET(struct_s, member) offsetof(struct_s, member) +#else +#define DTOFFSET(struct_s, member) ((int)(&((struct_s*)0)->member)) +#endif + +/* the dictionary structure itself */ +struct _dt_s +{ Dtsearch_f searchf;/* search function */ + Dtdisc_t* disc; /* object type definitition */ + Dtdata_t* data; /* sharable data */ + Dtmemory_f memoryf;/* for memory allocation */ + Dtmethod_t* meth; /* storage method */ + ssize_t nview; /* #parent view dictionaries */ + Dt_t* view; /* next on viewpath */ + Dt_t* walk; /* dictionary being walked */ + Dtuser_t* user; /* for user's usage */ + Dttype_f typef; /* for binary compatibility */ +}; + +/* structure to get status of a dictionary */ +#define DT_MAXRECURSE 1024 /* limit to avoid stack overflow */ +#define DT_MAXSIZE 256 /* limit for size of below arrays */ +struct _dtstat_s +{ unsigned int meth; /* method type */ + ssize_t size; /* total # of elements in dictionary */ + ssize_t space; /* memory usage of data structure */ + ssize_t mlev; /* max #levels in tree or hash table */ + ssize_t msize; /* max #defined elts in below arrays */ + ssize_t lsize[DT_MAXSIZE]; /* #objects by level */ + ssize_t tsize[DT_MAXSIZE]; /* #tables by level */ +}; + +/* supported storage methods */ +#define DT_SET 0000000001 /* unordered set, unique elements */ +#define DT_BAG 0000000002 /* unordered set, repeated elements */ +#define DT_OSET 0000000004 /* ordered set */ +#define DT_OBAG 0000000010 /* ordered multiset */ +#define DT_LIST 0000000020 /* linked list */ +#define DT_STACK 0000000040 /* stack: insert/delete at top */ +#define DT_QUEUE 0000000100 /* queue: insert top, delete at tail */ +#define DT_DEQUE 0000000200 /* deque: insert top, append at tail */ +#define DT_RHSET 0000000400 /* rhset: sharable unique objects */ +#define DT_RHBAG 0000001000 /* rhbag: sharable repeated objects */ +#define DT_METHODS 0000001777 /* all currently supported methods */ +#define DT_ORDERED (DT_OSET|DT_OBAG) + +/* asserts to dtdisc() to improve performance when changing disciplines */ +#define DT_SAMECMP 0000000001 /* compare functions are equivalent */ +#define DT_SAMEHASH 0000000002 /* hash functions are equivalent */ + +/* operation types */ +#define DT_INSERT 0000000001 /* insert object if not found */ +#define DT_DELETE 0000000002 /* delete a matching object if any */ +#define DT_SEARCH 0000000004 /* look for an object */ +#define DT_NEXT 0000000010 /* look for next element */ +#define DT_PREV 0000000020 /* find previous element */ +#define DT_FIRST 0000000200 /* get first object */ +#define DT_LAST 0000000400 /* get last object */ +#define DT_MATCH 0000001000 /* find object matching key */ +#define DT_ATTACH 0000004000 /* attach an object to dictionary */ +#define DT_DETACH 0000010000 /* detach an object from dictionary */ +#define DT_APPEND 0000020000 /* append an object */ +#define DT_ATLEAST 0000040000 /* find the least elt >= object */ +#define DT_ATMOST 0000100000 /* find the biggest elt <= object */ +#define DT_REMOVE 0002000000 /* remove a specific object */ +#define DT_TOANNOUNCE (DT_INSERT|DT_DELETE|DT_SEARCH|DT_NEXT|DT_PREV|DT_FIRST|DT_LAST|DT_MATCH|DT_ATTACH|DT_DETACH|DT_APPEND|DT_ATLEAST|DT_ATMOST|DT_REMOVE) + +#define DT_RELINK 0000002000 /* re-inserting (dtdisc,dtmethod...) */ +#define DT_FLATTEN 0000000040 /* flatten objects into a list */ +#define DT_CLEAR 0000000100 /* clearing all objects */ +#define DT_EXTRACT 0000200000 /* FLATTEN and clear dictionary */ +#define DT_RESTORE 0000400000 /* reinsert a list of elements */ +#define DT_STAT 0001000000 /* get statistics of dictionary */ +#define DT_OPERATIONS (DT_TOANNOUNCE|DT_RELINK|DT_FLATTEN|DT_CLEAR|DT_EXTRACT|DT_RESTORE|DT_STAT) + +/* these bits may combine with the DT_METHODS and DT_OPERATIONS bits */ +#define DT_INDATA 0010000000 /* Dt_t was allocated with Dtdata_t */ +#define DT_SHARE 0020000000 /* concurrent access mode */ +#define DT_ANNOUNCE 0040000000 /* announcing a successful operation */ + /* the actual event will be this bit */ + /* combined with the operation bit */ +#define DT_OPTIMIZE 0100000000 /* optimizing data structure */ + +/* events for discipline and method event-handling functions */ +#define DT_OPEN 1 /* a dictionary is being opened */ +#define DT_ENDOPEN 5 /* end of dictionary opening */ +#define DT_CLOSE 2 /* a dictionary is being closed */ +#define DT_ENDCLOSE 6 /* end of dictionary closing */ +#define DT_DISC 3 /* discipline is about to be changed */ +#define DT_METH 4 /* method is about to be changed */ +#define DT_HASHSIZE 7 /* initialize hash table size */ +#define DT_ERROR 0xbad /* announcing an error */ + +_BEGIN_EXTERNS_ /* data structures and functions */ +#if _BLD_cdt && defined(__EXPORT__) +#define extern __EXPORT__ +#endif +#if !_BLD_cdt && defined(__IMPORT__) +#define extern __IMPORT__ +#endif + +extern Dtmethod_t* Dtset; +extern Dtmethod_t* Dtbag; +extern Dtmethod_t* Dtoset; +extern Dtmethod_t* Dtobag; +extern Dtmethod_t* Dtlist; +extern Dtmethod_t* Dtstack; +extern Dtmethod_t* Dtqueue; +extern Dtmethod_t* Dtdeque; + +#if _PACKAGE_ast /* dtplugin() for proprietary and non-standard methods -- requires -ldll */ + +#define dtplugin(name) ((Dtmethod_t*)dllmeth("cdt", name, CDT_PLUGIN_VERSION)) + +#define Dtrhbag dtplugin("rehash:Dtrhbag") +#define Dtrhset dtplugin("rehash:Dtrhset") + +#else + +#if CDTPROPRIETARY + +extern Dtmethod_t* Dtrhset; +extern Dtmethod_t* Dtrhbag; + +#endif /*CDTPROPRIETARY*/ + +#endif /*_PACKAGE_ast*/ + +#undef extern + +#if _BLD_cdt && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Dt_t* dtopen _ARG_((Dtdisc_t*, Dtmethod_t*)); +extern int dtclose _ARG_((Dt_t*)); +extern Dt_t* dtview _ARG_((Dt_t*, Dt_t*)); +extern Dtdisc_t* dtdisc _ARG_((Dt_t* dt, Dtdisc_t*, int)); +extern Dtmethod_t* dtmethod _ARG_((Dt_t*, Dtmethod_t*)); +extern int dtwalk _ARG_((Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*)); +extern int dtcustomize _ARG_((Dt_t*, int, int)); +extern unsigned int dtstrhash _ARG_((unsigned int, Void_t*, ssize_t)); +extern int dtuserlock _ARG_((Dt_t*, unsigned int, int)); +extern Void_t* dtuserdata _ARG_((Dt_t*, Void_t*, unsigned int)); + +/* deal with upward binary compatibility (operation bit translation, etc.) */ +extern Dt_t* _dtopen _ARG_((Dtdisc_t*, Dtmethod_t*, unsigned long)); +#define dtopen(dc,mt) _dtopen((dc), (mt), CDT_VERSION) + +#undef extern + +#if _PACKAGE_ast && !defined(_CDTLIB_H) + +#if _BLD_dll && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void* dllmeth(const char*, const char*, unsigned long); + +#undef extern + +#endif + +_END_EXTERNS_ + +/* internal functions for translating among holder, object and key */ +#define _DT(dt) ((Dt_t*)(dt)) + +#define _DTLNK(dc,o) ((Dtlink_t*)((char*)(o) + (dc)->link) ) /* get link from obj */ + +#define _DTO(dc,l) (Void_t*)((char*)(l) - (dc)->link) /* get object from link */ +#define _DTOBJ(dc,l) ((dc)->link >= 0 ? _DTO(dc,l) : ((Dthold_t*)(l))->obj ) + +#define _DTK(dc,o) ((char*)(o) + (dc)->key) /* get key from object */ +#define _DTKEY(dc,o) (Void_t*)((dc)->size >= 0 ? _DTK(dc,o) : *((char**)_DTK(dc,o)) ) + +#define _DTCMP(dt,k1,k2,dc) \ + ((dc)->comparf ? (*(dc)->comparf)((dt), (k1), (k2), (dc)) : \ + (dc)->size > 0 ? memcmp((Void_t*)(k1), ((Void_t*)k2), (dc)->size) : \ + strcmp((char*)(k1), ((char*)k2)) ) + +#define _DTHSH(dt,ky,dc) ((dc)->hashf ? (*(dc)->hashf)((dt), (ky), (dc)) : \ + dtstrhash(0, (ky), (dc)->size) ) + +#define dtvnext(d) (_DT(d)->view) +#define dtvcount(d) (_DT(d)->nview) +#define dtvhere(d) (_DT(d)->walk) + +#define dtlink(d,e) (((Dtlink_t*)(e))->rh.__rght) +#define dtobj(d,e) _DTOBJ(_DT(d)->disc, (e)) + +#define dtfirst(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FIRST) +#define dtnext(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_NEXT) +#define dtatleast(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATLEAST) +#define dtlast(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_LAST) +#define dtprev(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_PREV) +#define dtatmost(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATMOST) +#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH) +#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH) +#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT) +#define dtappend(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_APPEND) +#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE) +#define dtremove(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_REMOVE) +#define dtattach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATTACH) +#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DETACH) +#define dtclear(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_CLEAR) + +#define dtflatten(d) (Dtlink_t*)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FLATTEN) +#define dtextract(d) (Dtlink_t*)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_EXTRACT) +#define dtrestore(d,l) (Dtlink_t*)(*(_DT(d)->searchf))((d),(Void_t*)(l),DT_RESTORE) + +#define dtstat(d,s) (ssize_t)(*(_DT(d)->searchf))((d),(Void_t*)(s),DT_STAT) +#define dtsize(d) (ssize_t)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_STAT) + +#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */ +#define dtcharhash(h,c) (((unsigned int)(h) + (unsigned int)(c)) * DT_PRIME ) + +#endif /* _CDT_H */ diff --git a/illumos-x86_64/usr/include/ast/cdtlib.h b/illumos-x86_64/usr/include/ast/cdtlib.h new file mode 100644 index 00000000..b486fb60 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/cdtlib.h @@ -0,0 +1,189 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#ifndef _CDTLIB_H +#define _CDTLIB_H 1 + +/* cdt library/method implementation header +** this header is exported to the method libraries +** Written by Kiem-Phong Vo (5/25/96) +*/ + +#if _PACKAGE_ast +#include +#if !_BLD_cdt +#include +#endif +#endif + +#include +#include +#include + +#include "debug.h" + +/* short-hand notations */ +#define NIL(t) ((t)0) +#define reg register + +/* min #bits for a hash table. (1<name + n)) \ + return cdt_lib_##m.methods[i]; \ + return 0; \ + } \ + unsigned long plugin_version(void) { return CDT_PLUGIN_VERSION; } +#else +#define CDTLIB(m) \ + void* cdt_lib(name, disc, type) const char* name; Dtdisc_t* disc; const char* type; \ + { \ + int i; \ + int n; \ + if (!type) \ + return &cdt_lib_/**/m; \ + n = strlen(cdt_lib_/**/m.prefix); \ + if (!strncmp(type, cdt_lib_/**/m.prefix, n)) \ + type += n; \ + for (i = 0; cdt_lib_/**/m.methods[i]; i++) \ + if (!strcmp(type, cdt_lib_/**/m.methods[i]->name + n)) \ + return cdt_lib_/**/m.methods[i]; \ + return 0; \ + } \ + unsigned long plugin_version() { return CDT_PLUGIN_VERSION; } +#endif + +#endif /* _BLD_cdt */ + +/* these macros lock/unlock dictionaries. DTRETURN substitutes for "return" */ +#define DTSETLOCK(dt) (((dt)->data->type&DT_SHARE) ? asolock(&(dt)->data->lock,1,ASO_SPINLOCK) : 0 ) +#define DTCLRLOCK(dt) (((dt)->data->type&DT_SHARE) ? asolock(&(dt)->data->lock,1,ASO_UNLOCK) : 0 ) +#define DTRETURN(ob,rv) do { (ob) = (rv); goto dt_return; } while(0) +#define DTERROR(dt, mesg) (!((dt)->disc && (dt)->disc->eventf) ? 0 : \ + (*(dt)->disc->eventf)((dt),DT_ERROR,(Void_t*)(mesg),(dt)->disc) ) + +/* announce completion of an operation of type (ty) on some object (ob) in dictionary (dt) */ +#define DTANNOUNCE(dt,ob,ty) ( ((ob) && ((ty)&DT_TOANNOUNCE) && ((dt)->data->type&DT_ANNOUNCE) && \ + (dt)->disc && (dt)->disc->eventf ) ? \ + (*(dt)->disc->eventf)((dt), DT_ANNOUNCE|(ty), (ob), (dt)->disc) : 0 ) + +/* map bits for upward compabitibility */ +#define DTTYPE(dt,ty) ((dt)->typef ? (*(dt)->typef)((dt), (ty)) : (ty) ) + +/* short-hands for fields in Dtlink_t. +** note that __hash is used as a hash value +** or as the position in the parent table. +*/ +#define _left lh.__left +#define _hash lh.__hash +#define _ppos lh.__hash + +#define _rght rh.__rght +#define _ptbl rh.__ptbl + +/* tree rotation/linking functions */ +#define rrotate(x,y) ((x)->_left = (y)->_rght, (y)->_rght = (x)) +#define lrotate(x,y) ((x)->_rght = (y)->_left, (y)->_left = (x)) +#define rlink(r,x) ((r) = (r)->_left = (x) ) +#define llink(l,x) ((l) = (l)->_rght = (x) ) + +#define RROTATE(x,y) (rrotate(x,y), (x) = (y)) +#define LROTATE(x,y) (lrotate(x,y), (x) = (y)) +#define RRSHIFT(x,t) ((t) = (x)->_left->_left, (x)->_left->_left = (t)->_rght, \ + (t)->_rght = (x), (x) = (t) ) +#define LLSHIFT(x,t) ((t) = (x)->_rght->_rght, (x)->_rght->_rght = (t)->_left, \ + (t)->_left = (x), (x) = (t) ) + +_BEGIN_EXTERNS_ + +#if _BLD_cdt && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Dtlink_t* _dtmake _ARG_((Dt_t*, Void_t*, int)); +extern void _dtfree _ARG_((Dt_t*, Dtlink_t*, int)); +extern int _dtlock _ARG_((Dt_t*, int)); + +#undef extern + +#if !_PACKAGE_ast +extern Void_t* malloc _ARG_((size_t)); +extern Void_t* realloc _ARG_((Void_t*, size_t)); +extern void free _ARG_((Void_t*)); +#endif +_END_EXTERNS_ + +#endif /* _CDTLIB_H */ diff --git a/illumos-x86_64/usr/include/ast/cmd.h b/illumos-x86_64/usr/include/ast/cmd.h new file mode 100644 index 00000000..d635df37 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/cmd.h @@ -0,0 +1,169 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1992-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* * +***********************************************************************/ +#pragma prototyped +/* + * AT&T Research + * + * builtin cmd definitions + */ + +#ifndef _CMD_H +#define _CMD_H + +#include +#include +#include +#include + +#define cmdinit _cmd_init + +#define ERROR_CALLBACK ERROR_SET + +#if _BLD_cmd && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#include + +#undef extern + +#if defined(CMD_BUILTIN) && !defined(CMD_STANDALONE) +#define CMD_STANDALONE CMD_BUILTIN +#endif + +#ifdef CMD_STANDALONE + +#define CMD_CONTEXT(c) ((Shbltin_t*)0) + +#if CMD_DYNAMIC + +#include + +#else + +extern int CMD_STANDALONE(int, char**, Shbltin_t*); + +#endif + +#ifndef CMD_BUILTIN + +/* + * command initialization + */ + +static int +cmdinit(int argc, register char** argv, Shbltin_t* context, const char* catalog, int flags) +{ + register char* cp; + register char* pp; + + if (cp = strrchr(argv[0], '/')) + cp++; + else + cp = argv[0]; + if (pp = strrchr(cp, '_')) + cp = pp + 1; + error_info.id = cp; + if (!error_info.catalog) + error_info.catalog = (char*)catalog; + opt_info.index = 0; + if (context) + error_info.flags |= flags & ~(ERROR_CALLBACK|ERROR_NOTIFY); + return 0; +} + +#endif + +int +main(int argc, char** argv) +{ +#if CMD_DYNAMIC + register char* s; + register char* t; + void* dll; + Shbltin_f fun; + char buf[64]; + + if (s = strrchr(argv[0], '/')) + s++; + else if (!(s = argv[0])) + return 127; + if ((t = strrchr(s, '_')) && *++t) + s = t; + buf[0] = '_'; + buf[1] = 'b'; + buf[2] = '_'; + strncpy(buf + 3, s, sizeof(buf) - 4); + buf[sizeof(buf) - 1] = 0; + if (t = strchr(buf, '.')) + *t = 0; + for (;;) + { + if (dll = dlopen(NiL, RTLD_LAZY)) + { + if (fun = (Shbltin_f)dlsym(dll, buf + 1)) + break; + if (fun = (Shbltin_f)dlsym(dll, buf)) + break; + } + if (dll = dllplug(NiL, "cmd", NiL, RTLD_LAZY, NiL, 0)) + { + if (fun = (Shbltin_f)dlsym(dll, buf + 1)) + break; + if (fun = (Shbltin_f)dlsym(dll, buf)) + break; + } + return 127; + } + return (*fun)(argc, argv, NiL); +#else + return CMD_STANDALONE(argc, argv, NiL); +#endif +} + +#else + +#undef cmdinit +#ifdef _MSC_VER +#define CMD_CONTEXT(p) ((Shbltin_t*)(p)) +#define cmdinit(a,b,c,d,e) do{if(_cmd_init(a,b,c,d,e))return -1;}while(0) +#else +#define CMD_CONTEXT(p) (((p)&&((Shbltin_t*)(p))->version>=20071012&&((Shbltin_t*)(p))->version<20350101)?((Shbltin_t*)(p)):0) +#define cmdinit(a,b,c,d,e) do{if((c)&&!CMD_CONTEXT(c))c=0;if(_cmd_init(a,b,c,d,e))return -1;}while(0) +#endif + +#if _BLD_cmd && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif + +extern int _cmd_init(int, char**, Shbltin_t*, const char*, int); + +#undef extern + +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/cmdarg.h b/illumos-x86_64/usr/include/ast/cmdarg.h new file mode 100644 index 00000000..996f6b8b --- /dev/null +++ b/illumos-x86_64/usr/include/ast/cmdarg.h @@ -0,0 +1,98 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * xargs/tw command arg list interface definitions + */ + +#ifndef _CMDARG_H +#define _CMDARG_H 1 + +#include + +#define CMD_VERSION 20120411L + +#define CMD_CHECKED (1<<9) /* cmdopen() argv[0] ok */ +#define CMD_EMPTY (1<<0) /* run once, even if no args */ +#define CMD_EXACT (1<<1) /* last command must have argmax*/ +#define CMD_EXIT (1<<11) /* fatal error_info.exit() */ +#define CMD_IGNORE (1<<2) /* ignore EXIT_QUIT exit */ +#define CMD_INSERT (1<<3) /* argpat for insertion */ +#define CMD_MINIMUM (1<<4) /* argmax is a minimum */ +#define CMD_NEWLINE (1<<5) /* echo separator is newline */ +#define CMD_POST (1<<6) /* argpat is post arg position */ +#define CMD_QUERY (1<<7) /* trace and query each command */ +#define CMD_SILENT (1<<10) /* no error messages */ +#define CMD_TRACE (1<<8) /* trace each command */ + +#define CMD_USER (1<<12) + +#define CMDDISC(d,f,e) (memset(d,0,sizeof(*(d))),(d)->version=CMD_VERSION,(d)->flags=(f),(d)->errorf=(e)) + +struct Cmddisc_s; +typedef struct Cmddisc_s Cmddisc_t; + +typedef int (*Cmdrun_f)(int, char**, Cmddisc_t*); + +struct Cmddisc_s +{ + uint32_t version; /* CMD_VERSION */ + uint32_t flags; /* CMD_* flags */ + Error_f errorf; /* optional error function */ + Cmdrun_f runf; /* optional exec function */ +}; + +typedef struct Cmdarg_s /* cmdopen() handle */ +{ + const char* id; /* library id string */ + +#ifdef _CMDARG_PRIVATE_ + _CMDARG_PRIVATE_ +#endif + +} Cmdarg_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#ifndef cmdopen +extern Cmdarg_t* cmdopen(char**, int, int, const char*, int); +#endif +extern Cmdarg_t* cmdopen_20110505(char**, int, int, const char*, int, Error_f); +extern Cmdarg_t* cmdopen_20120411(char**, int, int, const char*, Cmddisc_t*); +extern int cmdflush(Cmdarg_t*); +extern int cmdarg(Cmdarg_t*, const char*, int); +extern int cmdclose(Cmdarg_t*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/cmdext.h b/illumos-x86_64/usr/include/ast/cmdext.h new file mode 100644 index 00000000..25fe9f92 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/cmdext.h @@ -0,0 +1,79 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1992-2025 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* * +***********************************************************************/ + +/* : : generated by proto : : */ + +#if !defined(__PROTO__) +#include +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif +#include +extern __MANGLE__ int b_basename __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_cat __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_chgrp __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_chmod __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_chown __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_cksum __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_cmp __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_comm __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_cp __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_cut __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_date __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_dirname __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_expr __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_fds __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_fmt __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_fold __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_getconf __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_head __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_id __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_join __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_ln __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_logname __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_md5sum __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_mkdir __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_mkfifo __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_mktemp __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_mv __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_paste __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_pathchk __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_pids __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_rev __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_rm __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_rmdir __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_stty __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_sum __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_sync __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_tail __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_tee __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_tty __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_uname __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_uniq __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_vmstate __PROTO__((int, char**, Shbltin_t*)); +extern __MANGLE__ int b_wc __PROTO__((int, char**, Shbltin_t*)); diff --git a/illumos-x86_64/usr/include/ast/debug.h b/illumos-x86_64/usr/include/ast/debug.h new file mode 100644 index 00000000..39e9abe1 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/debug.h @@ -0,0 +1,115 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * common ast debug definitions + * include after the ast headers + */ + +#ifndef _DEBUG_H +#define _DEBUG_H + +#include +#include + +#if !defined(DEBUG) && _BLD_DEBUG +#define DEBUG _BLD_DEBUG +#endif + +#if DEBUG || _BLD_DEBUG + +#define debug(x) x +#define message(x) do if (error_info.trace < 0) { error x; } while (0) +#define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0) + +#define DEBUG_BEGTIME() debug_elapsed(1) +#define DEBUG_GETTIME() debug_elapsed(0) +#define DEBUG_ASSERT(p) ((p) ? 0 : (debug_fatal(__FILE__, __LINE__),0)) +#define DEBUG_COUNT(n) ((n) += 1) +#define DEBUG_TALLY(c,n,v) ((c) ? ((n) += (v)) : (n)) +#define DEBUG_INCREASE(n) ((n) += 1) +#define DEBUG_DECREASE(n) ((n) -= 1) +#define DEBUG_DECLARE(t,v) t v +#define DEBUG_SET(n,v) ((n) = (v)) +#define DEBUG_PRINT(fd,s,v) do {char _b[1024];write(fd,_b,sfsprintf(_b,sizeof(_b),s,v));} while(0) +#define DEBUG_WRITE(fd,d,n) write((fd),(d),(n)) +#define DEBUG_TEMP(temp) (temp) /* debugging stuff that should be removed */ +#define DEBUG_BREAK break +#define DEBUG_CONTINUE continue +#define DEBUG_GOTO(label) do { debug_fatal(__FILE__, __LINE__); goto label; } while(0) +#define DEBUG_RETURN(x) do { debug_fatal(__FILE__, __LINE__); return(x); } while(0) + +#else + +#define debug(x) +#define message(x) +#define messagef(x) + +#define DEBUG_BEGTIME() +#define DEBUG_GETTIME() +#define DEBUG_ASSERT(p) +#define DEBUG_COUNT(n) +#define DEBUG_TALLY(c,n,v) +#define DEBUG_INCREASE(n) +#define DEBUG_DECREASE(n) +#define DEBUG_DECLARE(t,v) +#define DEBUG_SET(n,v) +#define DEBUG_PRINT(fd,s,v) +#define DEBUG_WRITE(fd,d,n) +#define DEBUG_TEMP(x) +#define DEBUG_BREAK break +#define DEBUG_CONTINUE continue +#define DEBUG_GOTO(label) goto label +#define DEBUG_RETURN(x) return(x) + +#endif + +#ifndef BREAK +#define BREAK DEBUG_BREAK +#endif +#ifndef CONTINUE +#define CONTINUE DEBUG_CONTINUE +#endif +#ifndef GOTO +#define GOTO(label) DEBUG_GOTO(label) +#endif +#ifndef RETURN +#define RETURN(x) DEBUG_RETURN(x) +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern double debug_elapsed(int); +extern void debug_fatal(const char*, int); +extern void systrace(const char*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/dirent.h b/illumos-x86_64/usr/include/ast/dirent.h new file mode 100644 index 00000000..de5f2ac6 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/dirent.h @@ -0,0 +1,28 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#include diff --git a/illumos-x86_64/usr/include/ast/dlldefs.h b/illumos-x86_64/usr/include/ast/dlldefs.h new file mode 100644 index 00000000..04a6b54f --- /dev/null +++ b/illumos-x86_64/usr/include/ast/dlldefs.h @@ -0,0 +1,173 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1997-2025 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libdll/features/dll by iffe version 2012-07-17 : : */ + +#ifndef _def_dll_dll +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_dll_dll 1 +#define _sys_types 1 /* #include ok */ +#define _hdr_dlfcn 1 /* #include ok */ +#define _LIB_dl 1 /* -ldl is a library */ +#define _lib_dlopen 1 /* dlopen() in default lib(s) */ +#define _DLL_NEXT_PATH "/usr/lib/libc.so.1" + +#if defined(__MVS__) && !defined(__SUSV3) +#define __SUSV3 1 +#endif +#include + +#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */ +#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */ + +typedef unsigned long (*Dll_plugin_version_f) __PROTO__((void)); +typedef int (*Dllerror_f) __PROTO__((__V_*, __V_*, int, ...)); + +typedef struct Dllinfo_s +{ + char** sibling; /* sibling dirs on $PATH */ + char* prefix; /* library name prefix */ + char* suffix; /* library name suffix */ + char* env; /* library path env var */ + int flags; /* DLL_INFO_* flags */ +#ifdef _DLLINFO_PRIVATE_ + _DLLINFO_PRIVATE_ +#endif +} Dllinfo_t; + +typedef struct Dllnames_s +{ + char* id; + char* name; + char* base; + char* type; + char* opts; + char* path; + char data[1024]; +} Dllnames_t; + +typedef struct Dllent_s +{ + char* path; + char* name; +#ifdef _DLLENT_PRIVATE_ + _DLLENT_PRIVATE_ +#endif +} Dllent_t; + +typedef struct Dllscan_s +{ + __V_* pad; +#ifdef _DLLSCAN_PRIVATE_ + _DLLSCAN_PRIVATE_ +#endif +} Dllscan_t; + +#if _BLD_dll && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void)); +extern __MANGLE__ __V_* dllplugin __PROTO__((const char*, const char*, const char*, unsigned long, unsigned long*, int, char*, size_t)); +extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t)); +extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t)); +extern __MANGLE__ Dllnames_t* dllnames __PROTO__((const char*, const char*, Dllnames_t*)); +extern __MANGLE__ __V_* dll_lib __PROTO__((Dllnames_t*, unsigned long, Dllerror_f, __V_*)); +extern __MANGLE__ __V_* dllmeth __PROTO__((const char*, const char*, unsigned long)); +extern __MANGLE__ __V_* dllopen __PROTO__((const char*, int)); +extern __MANGLE__ __V_* dllnext __PROTO__((int)); +extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*)); +extern __MANGLE__ int dllcheck __PROTO__((__V_*, const char*, unsigned long, unsigned long*)); +extern __MANGLE__ unsigned long dllversion __PROTO__((__V_*, const char*)); +extern __MANGLE__ char* dllerror __PROTO__((int)); + +extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*)); +extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*)); +extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*)); + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#endif diff --git a/illumos-x86_64/usr/include/ast/dt.h b/illumos-x86_64/usr/include/ast/dt.h new file mode 100644 index 00000000..b308d853 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/dt.h @@ -0,0 +1,47 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +#ifndef _DT_H +#define _DT_H 1 + +#include +#include + +#if _BLD_cdt && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Dt_t* dtnew(Vmalloc_t*, Dtdisc_t*, Dtmethod_t*); +extern Dt_t* _dtnew(Vmalloc_t*, Dtdisc_t*, Dtmethod_t*, unsigned long); + +#undef extern + +#define dtnew(v,d,m) _dtnew(v,d,m,CDT_VERSION) + +#endif diff --git a/illumos-x86_64/usr/include/ast/endian.h b/illumos-x86_64/usr/include/ast/endian.h new file mode 100644 index 00000000..4103ecdc --- /dev/null +++ b/illumos-x86_64/usr/include/ast/endian.h @@ -0,0 +1,60 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* + * linux/gnu compatibility + */ + +#ifndef _ENDIAN_H +#define _ENDIAN_H + +#include + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __PDP_ENDIAN 3412 + +#if defined (__USE_BSD) && !defined(__STRICT_ANSI__) + +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN __LITTLE_ENDIAN +#endif + +#ifndef BIG_ENDIAN +#define BIG_ENDIAN __BIG_ENDIAN +#endif + +#ifndef PDP_ENDIAN +#define PDP_ENDIAN __PDP_ENDIAN +#endif + +#undef BYTE_ORDER +#define BYTE_ORDER __BYTE_ORDER + +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/error.h b/illumos-x86_64/usr/include/ast/error.h new file mode 100644 index 00000000..7df95575 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/error.h @@ -0,0 +1,194 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * option, error and message formatter external definitions + */ + +#ifndef _ERROR_H +#define _ERROR_H + +#include +#include +#include + +#define ERROR_VERSION 20070319L + +#if !defined(errno) && defined(__DYNAMIC__) +#define errno __DYNAMIC__(errno) +#endif + +#define ERROR_debug(n) (-(n)) +#define ERROR_exit(n) ((n)+ERROR_ERROR) +#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM) +#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE) +#define ERROR_warn(n) (ERROR_WARNING) + +#ifndef ERROR_catalog +#define ERROR_catalog(t) t +#endif +#ifndef ERROR_dictionary +#define ERROR_dictionary(t) t +#endif + +#ifndef ERROR_translate +#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<= ERROR_ERROR count */ \ + int flags; /* context flags */ \ + int line; /* input|output line number */ \ + int warnings; /* ERROR_WARNING count */ \ + char* file; /* input|output file name */ \ + char* id; /* command id */ + +struct Error_context_s /* context stack element */ +{ + ERROR_CONTEXT +}; + +struct Error_info_s /* error state */ +{ + int fd; /* write(2) fd */ + + void (*exit)(int); /* error exit */ + ssize_t (*write)(int, const void*, size_t); /* error output */ + + /* the rest are implicitly initialized */ + + int clear; /* default clear ERROR_* flags */ + int core; /* level>=core -> core dump */ + int indent; /* debug trace indent level */ + int init; /* initialized */ + int last_errno; /* last reported errno */ + int mask; /* multi level debug trace mask */ + int set; /* default set ERROR_* flags */ + int trace; /* debug trace level */ + + char* version; /* ERROR_SOURCE command version */ + + int (*auxilliary)(Sfio_t*, int, int); /* aux info to append */ + + ERROR_CONTEXT /* top of context stack */ + + Error_context_t empty; /* empty context stack element */ + + unsigned long time; /* debug time trace */ + + char* (*translate)(const char*, const char*, const char*, const char*); /* format translator */ + + const char* catalog; /* message catalog */ +}; + +#ifndef errno +extern int errno; /* system call error status */ +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Error_info_t* _error_infop_; + +#define error_info (*_error_infop_) + +#undef extern + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void error(int, ...); +extern int errormsg(const char*, int, ...); +extern int errorf(void*, void*, int, ...); +extern void errorv(const char*, int, va_list); +#ifndef errorx +extern char* errorx(const char*, const char*, const char*, const char*); +#endif +extern Error_info_t* errorctx(Error_info_t*, int, int); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/find.h b/illumos-x86_64/usr/include/ast/find.h new file mode 100644 index 00000000..8383d91a --- /dev/null +++ b/illumos-x86_64/usr/include/ast/find.h @@ -0,0 +1,92 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * fast find interface definitions + */ + +#ifndef _FIND_H +#define _FIND_H + +#define FIND_VERSION 19980301L + +#ifndef FIND_CODES +#define FIND_CODES "lib/find/codes" +#endif + +#define FIND_CODES_ENV "FINDCODES" + +#define FIND_GENERATE (1<<0) /* generate new codes */ +#define FIND_ICASE (1<<1) /* ignore case in match */ +#define FIND_GNU (1<<2) /* generate gnu format codes */ +#define FIND_OLD (1<<3) /* generate old format codes */ +#define FIND_TYPE (1<<4) /* generate type with codes */ +#define FIND_VERIFY (1<<5) /* verify the dir hierarchy */ + +#define FIND_USER (1L<<16) /* first user flag bit */ + +struct Find_s; +struct Finddisc_s; + +typedef int (*Findverify_f)(struct Find_s*, const char*, size_t, struct Finddisc_s*); + +typedef struct Finddisc_s +{ + unsigned long version; /* interface version */ + unsigned long flags; /* FIND_* flags */ + Error_f errorf; /* error function */ + Findverify_f verifyf; /* dir verify function */ + char** dirs; /* dir prefixes to search */ +} Finddisc_t; + +typedef struct Find_s +{ + const char* id; /* library id string */ + unsigned long stamp; /* codes time stamp */ + +#ifdef _FIND_PRIVATE_ + _FIND_PRIVATE_ +#endif + +} Find_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Find_t* findopen(const char*, const char*, const char*, Finddisc_t*); +extern char* findread(Find_t*); +extern int findwrite(Find_t*, const char*, size_t, const char*); +extern int findclose(Find_t*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/fnmatch.h b/illumos-x86_64/usr/include/ast/fnmatch.h new file mode 100644 index 00000000..8668be6d --- /dev/null +++ b/illumos-x86_64/usr/include/ast/fnmatch.h @@ -0,0 +1,67 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * posix fnmatch interface definitions + */ + +#ifndef _FNMATCH_H +#define _FNMATCH_H + +#include + +/* fnmatch flags */ + +#define FNM_NOESCAPE 0x0001 /* \ is literal */ +#define FNM_PATHNAME 0x0002 /* explicit match for / */ +#define FNM_PERIOD 0x0004 /* explicit match for leading . */ +#define FNM_NOSYS 0x0010 /* not implemented */ + +/* nonstandard fnmatch() flags */ + +#define FNM_AUGMENTED 0x0008 /* enable ! & ( | ) */ +#define FNM_ICASE 0x0020 /* ignore case in match */ +#define FNM_LEADING_DIR 0x0040 /* match up to implicit / */ + +#define FNM_CASEFOLD FNM_ICASE /* gnu/bsd compatibility */ +#define FNM_IGNORECASE FNM_ICASE /* gnu/bsd compatibility */ +#define FNM_FILE_NAME FNM_PATHNAME /* gnu compatibility */ + +/* fnmatch error codes -- other non-zero values from */ + +#define FNM_NOMATCH 1 /* == REG_NOMATCH */ + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int fnmatch(const char*, const char*, int); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/fnv.h b/illumos-x86_64/usr/include/ast/fnv.h new file mode 100644 index 00000000..b3a311a2 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/fnv.h @@ -0,0 +1,78 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * Landon Kurt Knoll + * Phong Vo + * + * FNV-1 linear congruent checksum/hash/PRNG + * see http://www.isthe.com/chongo/tech/comp/fnv/ + */ + +#ifndef _FNV_H +#define _FNV_H + +#include + +#define FNV_INIT 0x811c9dc5L +#define FNV_MULT 0x01000193L + +#define FNVINIT(h) (h = FNV_INIT) +#define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c)) +#define FNVSUM(h,s,n) do { \ + register size_t _i_ = 0; \ + while (_i_ < n) \ + FNVPART(h, ((unsigned char*)s)[_i_++]); \ + } while (0) + +#if _typ_int64_t + +#ifdef _ast_LL + +#define FNV_INIT64 0xcbf29ce484222325LL +#define FNV_MULT64 0x00000100000001b3LL + +#else + +#define FNV_INIT64 ((int64_t)0xcbf29ce484222325) +#define FNV_MULT64 ((int64_t)0x00000100000001b3) + +#endif + +#define FNVINIT64(h) (h = FNV_INIT64) +#define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c)) +#define FNVSUM64(h,s,n) do { \ + register int _i_ = 0; \ + while (_i_ < n) \ + FNVPART64(h, ((unsigned char*)s)[_i_++]); \ + } while (0) + +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/fs3d.h b/illumos-x86_64/usr/include/ast/fs3d.h new file mode 100644 index 00000000..3dc694d7 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/fs3d.h @@ -0,0 +1,123 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * 3d fs interface definitions + */ + +#ifndef _FS3D_H +#define _FS3D_H + +#include + +#if _int_st_spare1 +#define iview(p) ((p)->st_spare1) +#define IVIEW(p,v) ((p)->st_spare1=(v)) +#else +#if _ary_st_spare4 +#define iview(p) ((p)->st_spare4[0]) +#define IVIEW(p,v) ((p)->st_spare4[0]=(v)) +#else +#if _ary_st_extra +#define iview(p) ((p)->st_extra[0]) +#define IVIEW(p,v) ((p)->st_extra[0]=(v)) +#else +#if _ary_st_pad4 +#define iview(p) ((p)->st_pad4[0]) +#define IVIEW(p,v) ((p)->st_pad4[0]=(v)) +#else +#if _mem_st_rdev_stat +#define iview(p) ((S_ISBLK((p)->st_mode)||S_ISCHR((p)->st_mode))?0:(p)->st_rdev) +#define IVIEW(p,v) do{if(!S_ISBLK((p)->st_mode)&&!S_ISCHR((p)->st_mode))(p)->st_rdev=(v);}while(0) +#else +#define iview(p) 0 +#define IVIEW(p,v) +#endif +#endif +#endif +#endif +#endif + +/* + * special options + */ + +#define FS3D_init "/#option/init" +#define FS3D_on "/#option/3d" +#define FS3D_off "/#option/2d" + +/* + * fs3d(3) ops + */ + +#define FS3D_OP(o,a) (((a)<<3)|(o)) + +#define FS3D_INIT FS3D_OP_INIT /* re-initialize tables */ +#define FS3D_OFF FS3D_OP_OFF +#define FS3D_ON FS3D_OP_ON +#define FS3D_TEST FS3D_OP_TEST +#define FS3D_LIMIT(n) FS3D_OP(FS3D_OP_LIMIT,n) + +#define FS3D_op(x) ((x)&07) +#define FS3D_arg(x) (((x)>>3)&07777) + +#define FS3D_OP_OFF 0 +#define FS3D_OP_ON 1 +#define FS3D_OP_TEST 2 +#define FS3D_OP_LIMIT 3 +#define FS3D_OP_INIT 7 + +/* + * mount(2) ops + */ + +#define FS3D_ALL (FS3D_VIEW|FS3D_VERSION) +#define FS3D_VIEW 002 +#define FS3D_VERSION 004 +#define FS3D_GET 010 +#define FS3D_SIZE(n) ((n)<<4) +#define FS3D_SIZEOF(n) ((n)>>4) + +#if !_BLD_3d +#define mount(s,t,f,d) fs3d_mount(s,t,f,d) +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int fs3d(int); +extern int fs3d_mount(const char*, char*, int, void*); +extern char* pathnext(char*, char*, long*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/fts.h b/illumos-x86_64/usr/include/ast/fts.h new file mode 100644 index 00000000..49bb92e7 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/fts.h @@ -0,0 +1,168 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * David Korn + * Phong Vo + * AT&T Research + * + * fts interface definitions + */ + +#ifndef _FTS_H +#define _FTS_H + +#include +#include +#include + +/* + * fts_open flags + */ + +#define FTS_LOGICAL 0 /* logical traversal, follow symlinks */ +#define FTS_META (1<<0) /* follow top dir symlinks even if phys */ +#define FTS_NOCHDIR (1<<1) /* don't chdir */ +#define FTS_NOPOSTORDER (1<<2) /* no postorder visits */ +#define FTS_NOPREORDER (1<<3) /* no preorder visits */ +#define FTS_NOSEEDOTDIR (1<<11) /* never retain leading . dir */ +#define FTS_NOSTAT (1<<4) /* don't stat children */ +#define FTS_ONEPATH (1<<5) /* pathnames arg is one const char* */ +#define FTS_PHYSICAL (1<<6) /* physical traversal, don't follow */ +#define FTS_SEEDOT (1<<7) /* return . and .. */ +#define FTS_SEEDOTDIR (1<<10) /* always retain leading . dir */ +#define FTS_TOP (1<<8) /* don't traverse subdirectories */ +#define FTS_XDEV (1<<9) /* don't cross mount points */ + +#define FTS_USER (1<<12) /* first user flag bit */ + +#define FTS_COMFOLLOW FTS_META + +/* + * fts_info flags + */ + +#define FTS_DEFAULT 0 /* ok, someone must have wanted this */ + +#define FTS_NS (1<<0) /* stat failed */ +#define FTS_F (1<<1) /* file - not directory or symbolic link*/ +#define FTS_SL (1<<2) /* symbolic link */ +#define FTS_D (1<<3) /* directory - pre-order visit */ + +#define FTS_C (1<<4) /* causes cycle */ +#define FTS_ERR (1<<5) /* some other error */ +#define FTS_DD (1<<6) /* . or .. */ +#define FTS_NR (1<<7) /* cannot read */ +#define FTS_NX (1<<8) /* cannot search */ +#define FTS_OK (1<<9) /* no info but otherwise ok */ +#define FTS_P (1<<10) /* post-order visit */ + +#define FTS_DC (FTS_D|FTS_C) /* dir - would cause cycle */ +#define FTS_DNR (FTS_D|FTS_NR) /* dir - no read permission */ +#define FTS_DNX (FTS_D|FTS_NX) /* dir - no search permission */ +#define FTS_DOT (FTS_D|FTS_DD) /* . or .. */ +#define FTS_DP (FTS_D|FTS_P) /* dir - post-order visit */ +#define FTS_NSOK (FTS_NS|FTS_OK) /* no stat (because you asked) */ +#define FTS_SLNONE (FTS_SL|FTS_NS) /* symlink - to nowhere */ + +/* + * fts_set flags + */ + +#define FTS_AGAIN FTS_TOP /* process entry again */ +#define FTS_FOLLOW FTS_META /* follow FTS_SL symlink */ +#define FTS_SKIP FTS_NOSTAT /* skip FTS_D directory */ +#define FTS_STAT FTS_PHYSICAL /* stat() done by user */ + +typedef struct Fts FTS; +typedef struct Ftsent FTSENT; + +struct Ftsent +{ + char* fts_accpath; /* path relative to . */ + char* fts_name; /* file name */ + char* fts_path; /* path relative to top dir */ + FTSENT* fts_cycle; /* offender if cycle */ + FTSENT* fts_link; /* next child */ + FTSENT* fts_parent; /* parent directory */ + struct stat* fts_statp; /* stat info */ +#ifdef _FTSENT_LOCAL_PRIVATE_ + _FTSENT_LOCAL_PRIVATE_ +#else + void* fts_pointer; /* local pointer value */ +#endif + long fts_number; /* local numeric value */ + int fts_errno; /* errno for this entry */ + unsigned short fts_info; /* info flags */ + + unsigned short _fts_namelen; /* old fts_namelen */ + unsigned short _fts_pathlen; /* old fts_pathlen */ + short _fts_level; /* old fts_level */ + + short _fts_status; /* compatibility */ + struct stat _fts_statb; /* compatibility */ + + FTS* fts; /* fts_open() handle */ + size_t fts_namelen; /* strlen(fts_name) */ + size_t fts_pathlen; /* strlen(fts_path) */ + ssize_t fts_level; /* file tree depth, 0 at top */ + +#ifdef _FTSENT_PRIVATE_ + _FTSENT_PRIVATE_ +#endif + +}; + +struct Fts +{ + int fts_errno; /* last errno */ + void* fts_handle; /* user defined handle */ + +#ifdef _FTS_PRIVATE_ + _FTS_PRIVATE_ +#endif + +}; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern FTSENT* fts_children(FTS*, int); +extern int fts_close(FTS*); +extern int fts_flags(void); +extern int fts_local(FTSENT*); +extern int fts_notify(int(*)(FTS*, FTSENT*, void*), void*); +extern FTS* fts_open(char* const*, int, int(*)(FTSENT* const*, FTSENT* const*)); +extern FTSENT* fts_read(FTS*); +extern int fts_set(FTS*, FTSENT*, int); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/ftw.h b/illumos-x86_64/usr/include/ast/ftw.h new file mode 100644 index 00000000..3412ef48 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ftw.h @@ -0,0 +1,66 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * ftw,nftw over ftwalk + */ + +#ifndef _FTW_H +#define _FTW_H + +#define FTW FTWALK +#include +#undef FTW + +#define FTW_SLN (FTW_SL|FTW_NR) + +#define FTW_PHYS (FTW_PHYSICAL) +#define FTW_CHDIR (FTW_DOT) +#define FTW_DEPTH (FTW_POST) +#define FTW_OPEN (0) + +struct FTW +{ + int quit; + int base; + int level; +}; + +#define FTW_SKD FTW_SKIP +#define FTW_PRUNE FTW_SKIP + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int ftw(const char*, int(*)(const char*, const struct stat*, int), int); +extern int nftw(const char*, int(*)(const char*, const struct stat*, int, struct FTW*), int, int); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/ftwalk.h b/illumos-x86_64/usr/include/ast/ftwalk.h new file mode 100644 index 00000000..0aa4a0af --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ftwalk.h @@ -0,0 +1,130 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Phong Vo + * Glenn Fowler + * AT&T Research + * + * ast ftwalk interface definitions + * ftwalk was the initial improvement on ftw and nftw + * which formed the basis for the POSIX fts proposal + * + * NOTE: this file is in cahoots with the fts implementation + */ + +#ifndef _FTWALK_H +#define _FTWALK_H + +#define fts_info info +#define fts_level level +#define fts_link link +#define fts_name name +#define fts_namelen namelen +#define fts_parent parent +#define fts_path path +#define fts_pathlen pathlen +#define _fts_status status +#define _fts_statb statb + +#define FTSENT Ftw_t /* internal */ +#define Ftsent FTW /* internal */ + +#define _FTSENT_LOCAL_PRIVATE_ /* internal */ \ + union \ + { \ + long number; /* local numeric value */ \ + void* pointer; /* local pointer value */ \ + } local; + +#include + +/* + * ftwalk() argument flags + */ + +#define FTW_CANON FTS_CANON +#define FTW_CHILDREN (FTS_USER<<0) +#define FTW_DELAY FTS_NOSTAT +#define FTW_DOT FTS_NOCHDIR +#define FTW_META FTS_META +#define FTW_MOUNT FTS_XDEV +#define FTW_MULTIPLE FTS_ONEPATH +#define FTW_NOSEEDOTDIR FTS_NOSEEDOTDIR +#define FTW_PHYSICAL FTS_PHYSICAL +#define FTW_POST (FTS_USER<<1) +#define FTW_SEEDOTDIR FTS_SEEDOTDIR +#define FTW_TOP FTS_TOP +#define FTW_TWICE (FTS_USER<<2) +#define FTW_USER (FTS_USER<<3) + +/* + * Ftw_t.info type bits + */ + +#define FTW_C FTS_C +#define FTW_D FTS_D +#define FTW_DC FTS_DC +#define FTW_DNR FTS_DNR +#define FTW_DNX FTS_DNX +#define FTW_DP FTS_DP +#define FTW_F FTS_F +#define FTW_NR FTS_NR +#define FTW_NS FTS_NS +#define FTW_NSOK FTS_NSOK +#define FTW_NX FTS_NX +#define FTW_P FTS_P +#define FTW_SL FTS_SL + +/* + * Ftw_t.status entry values + */ + +#define FTW_NAME FTS_DOT /* access by Ftw_t.name */ +#define FTW_PATH FTS_NOCHDIR /* access by Ftw_t.path */ + +/* + * Ftw_t.status return values + */ + +#define FTW_AGAIN FTS_AGAIN +#define FTW_FOLLOW FTS_FOLLOW +#define FTW_NOPOST FTS_NOPOSTORDER +#define FTW_SKIP FTS_SKIP +#define FTW_STAT FTS_STAT + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int ftwalk(const char*, int(*)(Ftw_t*), int, int(*)(Ftw_t*, Ftw_t*)); +extern int ftwflags(void); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/getopt.h b/illumos-x86_64/usr/include/ast/getopt.h new file mode 100644 index 00000000..9054e54b --- /dev/null +++ b/illumos-x86_64/usr/include/ast/getopt.h @@ -0,0 +1,57 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * gnu getopt interface + */ + +#ifndef _GETOPT_H +#ifdef _AST_STD_I +#define _GETOPT_H -1 +#else +#define _GETOPT_H 1 + +#include + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +struct option +{ + const char* name; + int has_arg; + int* flag; + int val; +}; + +extern int getopt_long(int, char* const*, const char*, const struct option*, int*); +extern int getopt_long_only(int, char* const*, const char*, const struct option*, int*); + +#endif +#endif diff --git a/illumos-x86_64/usr/include/ast/glob.h b/illumos-x86_64/usr/include/ast/glob.h new file mode 100644 index 00000000..6f0964e0 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/glob.h @@ -0,0 +1,152 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * posix glob interface definitions with gnu extensions + */ + +#ifndef _GLOB_H +#define _GLOB_H + +#define GLOB_VERSION 20060717L + +#include + +struct dirent; +struct stat; + +struct _glob_; +struct _globlist_; + +typedef struct _glob_ glob_t; +typedef struct _globlist_ globlist_t; + +struct _globlist_ +{ + globlist_t* gl_next; + char* gl_begin; + unsigned char gl_flags; + char gl_path[1]; +}; + +struct _glob_ +{ + size_t gl_pathc; + char** gl_pathv; + size_t gl_offs; + globlist_t* gl_list; + int gl_flags; + + /* GLOB_DISC data -- memset(&gl,0,sizeof(gl)) before using! */ + + const char* gl_fignore; + const char* gl_suffix; + unsigned char* gl_intr; + + int gl_delim; + + void* gl_handle; + void* (*gl_diropen)(glob_t*, const char*); + char* (*gl_dirnext)(glob_t*, void*); + void (*gl_dirclose)(glob_t*, void*); + int (*gl_type)(glob_t*, const char*, int); + int (*gl_attr)(glob_t*, const char*, int); + + /* gnu extensions -- but how do you synthesize dirent and stat? */ + + void* (*gl_opendir)(const char*); + struct dirent* (*gl_readdir)(void*); + void (*gl_closedir)(void*); + int (*gl_stat)(const char*, struct stat*); + int (*gl_lstat)(const char*, struct stat*); + + /* ast additions */ + + char* (*gl_nextdir)(glob_t*, char*); + unsigned long gl_status; + unsigned long gl_version; + unsigned short gl_extra; + +#ifdef _GLOB_PRIVATE_ + _GLOB_PRIVATE_ +#else + char* gl_pad[23]; +#endif + +}; + +/* standard interface */ +#define GLOB_APPEND 0x0001 /* append to previous */ +#define GLOB_DOOFFS 0x0002 /* gl_offs defines argv offset */ +#define GLOB_ERR 0x0004 /* abort on error */ +#define GLOB_MARK 0x0008 /* append / to directories */ +#define GLOB_NOCHECK 0x0010 /* nomatch is original pattern */ +#define GLOB_NOESCAPE 0x0020 /* don't treat \ specially */ +#define GLOB_NOSORT 0x0040 /* don't sort the list */ + +/* extended interface */ +#define GLOB_STARSTAR 0x0080 /* enable [/]**[/] expansion */ +#define GLOB_BRACE 0x0100 /* enable {...} expansion */ +#define GLOB_ICASE 0x0200 /* ignore case on match */ +#define GLOB_COMPLETE 0x0400 /* shell file completeion */ +#define GLOB_AUGMENTED 0x0800 /* augmented shell patterns */ +#define GLOB_STACK 0x1000 /* allocate on current stack */ +#define GLOB_LIST 0x2000 /* just create gl_list */ +#define GLOB_ALTDIRFUNC 0x4000 /* gnu discipline functions */ +#define GLOB_DISC 0x8000 /* discipline initialized */ + +#define GLOB_GROUP 0x10000 /* REG_SHELL_GROUP */ + +/* gl_status */ +#define GLOB_NOTDIR 0x0001 /* last gl_dirnext() not a dir */ + +/* gl_type return */ +#define GLOB_NOTFOUND 0 /* does not exist */ +#define GLOB_DEV 1 /* exists but not DIR EXE REG */ +#define GLOB_DIR 2 /* directory */ +#define GLOB_EXE 3 /* executable regular file */ +#define GLOB_REG 4 /* regular file */ + +/* error return values */ +#define GLOB_ABORTED 1 +#define GLOB_NOMATCH 2 +#define GLOB_NOSPACE 3 +#define GLOB_INTR 4 +#define GLOB_APPERR 5 +#define GLOB_NOSYS 6 + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int glob(const char*, int, int(*)(const char*,int), glob_t*); +extern void globfree(glob_t*); + +#undef extern + +#endif /* _GLOB_H */ diff --git a/illumos-x86_64/usr/include/ast/hash.h b/illumos-x86_64/usr/include/ast/hash.h new file mode 100644 index 00000000..b0855149 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/hash.h @@ -0,0 +1,208 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * hash table library interface definitions + * + * NOTE: new code should use the more general + */ + +#ifndef _HASH_H +#define _HASH_H + +#define HASH_ALLOCATE (1L<<0) /* allocate new key names */ +#define HASH_FIXED (1L<<1) /* fixed table size */ +#define HASH_HASHED (1L<<6) /* key names already hashed */ +#define HASH_RESIZE (1L<<2) /* table has been resized */ +#define HASH_SCANNING (1L<<3) /* currently scanning scope */ +#define HASH_SCOPE (1L<<4) /* push scope / create in bot */ +#define HASH_STATIC (1L<<5) /* static table allocation */ + +#define HASH_CREATE (1L<<8) /* create bucket if not found */ +#define HASH_DELETE (1L<<9) /* delete bucket if found */ +#define HASH_LOOKUP 0 /* default op */ +#define HASH_RENAME (1L<<7) /* rename bucket if found */ + +#define HASH_BUCKET (1L<<11) /* name is installed bucket */ +#define HASH_INSTALL (1L<<12) /* install allocated bucket */ +#define HASH_NOSCOPE (1L<<13) /* top scope only */ +#define HASH_OPAQUE (1L<<14) /* opaque bucket */ +#define HASH_VALUE (1L<<15) /* value bucket field used */ + +#define HASH_SIZE(n) (((long)(n))<<16) /* fixed bucket size */ +#define HASH_SIZEOF(f) ((((long)(f))>>16)&0xffff) /* extract size */ + +#define HASH_DELETED ((unsigned long)1<<(8*sizeof(int)-1)) /* deleted placeholder */ +#define HASH_KEEP (1L<<(8*sizeof(int)-2)) /* no free on bucket */ +#define HASH_HIDDEN (1L<<(8*sizeof(int)-3)) /* hidden by scope */ +#define HASH_HIDES (1L<<(8*sizeof(int)-4)) /* hides lower scope */ +#define HASH_OPAQUED (1L<<(8*sizeof(int)-5)) /* opaqued placeholder */ +#define HASH_FREENAME (1L<<(8*sizeof(int)-6)) /* free bucket name */ + +#define HASH_RESET (HASH_RESIZE|HASH_SCOPE|HASH_STATIC|HASH_VALUE) +#define HASH_INTERNAL (HASH_BUCKET|HASH_RESIZE|HASH_SCANNING|HASH_STATIC) +#define HASH_FLAGS (HASH_DELETED|HASH_FREENAME|HASH_HIDDEN|HASH_HIDES|HASH_KEEP|HASH_OPAQUED) + +#define HASH_alloc 1 +#define HASH_clear 2 +#define HASH_compare 3 +#define HASH_free 4 +#define HASH_hash 5 +#define HASH_meanchain 6 +#define HASH_name 7 +#define HASH_namesize 8 +#define HASH_set 9 +#define HASH_size 10 +#define HASH_table 11 +#define HASH_va_list 12 + +#define HASH_bucketsize 13 + +#define HASH_region 14 + +#include + +#define hashclear(t,f) ((t)->flags &= ~((f) & ~HASH_INTERNAL)) +#define hashcover(b) (((b)->hash&HASH_HIDES)?(Hash_bucket_t*)((b)->name):(Hash_bucket_t*)0) +#define hashdel(t,n) hashlook(t, (char*)(n), HASH_DELETE, (char*)0) +#define hashget(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_VALUE, (char*)0) +#define hashgetbucket(s) ((Hash_bucket_t*)((s)-((sizeof(Hash_bucket_t)+sizeof(char*)-1)/sizeof(char*))*sizeof(char*))) +#define hashkeep(b) ((b)->hash|=HASH_KEEP) +#define hashname(b) ((((b)->hash&HASH_HIDES)?((Hash_bucket_t*)((b)->name)):(b))->name) +#define hashput(t,n,v) hashlook(t, (char*)(n), HASH_CREATE|HASH_VALUE, (char*)(v)) +#define hashref(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_INTERNAL|HASH_VALUE, (char*)0) +#define hashscope(t) ((t)->scope) +#define hashset(t,f) ((t)->flags |= ((f) & ~HASH_INTERNAL)) + +/* + * DEPRECATED renames for compatibility + */ + +#define Hashbin_t Hash_bucket_t +#define HASHBUCKET Hash_bucket_t +#define Hashhdr_t Hash_header_t +#define HASHHEADER Hash_header_t +#define Hashpos_t Hash_position_t +#define HASHPOSITION Hash_position_t +#define Hashtab_t Hash_table_t +#define HASHTABLE Hash_table_t + +#define vhashalloc hashvalloc +#define hashvalloc(t,a) hashalloc(t,HASH_va_list,a,0) + +/* + * the #define's avoid union tags + */ + +typedef struct Hash_bucket Hash_bucket_t; +typedef struct Hash_root Hash_root_t; +typedef struct Hash_table Hash_table_t; + +#define HASH_HEADER /* common bucket header */ \ + Hash_bucket_t* next; /* next in collision chain */ \ + unsigned int hash; /* hash flags and value */ \ + char* name /* key name */ + +#define HASH_DEFAULT /* HASH_VALUE bucket elements */ \ + char* value /* key value */ + +typedef struct /* bucket header */ +{ + HASH_HEADER; +} Hash_header_t; + +struct Hash_bucket /* prototype bucket */ +{ + HASH_HEADER; + HASH_DEFAULT; +}; + +typedef struct /* hash scan bucket position */ +{ + Hash_bucket_t* bucket; /* bucket */ +#ifdef _HASH_POSITION_PRIVATE_ + _HASH_POSITION_PRIVATE_ +#endif +} Hash_position_t; + +typedef struct /* last lookup cache */ +{ + Hash_table_t* table; /* last lookup table */ + Hash_bucket_t* bucket; /* last lookup bucket */ +#ifdef _HASH_LAST_PRIVATE_ + _HASH_LAST_PRIVATE_ +#endif +} Hash_last_t; + +struct Hash_root /* root hash table information */ +{ + int accesses; /* number of accesses */ + int collisions; /* number of collisions */ + int flags; /* flags: see HASH_[A-Z]* */ + Hash_last_t last; /* last lookup cache */ + void* context; /* user defined context */ +#ifdef _HASH_ROOT_PRIVATE_ + _HASH_ROOT_PRIVATE_ +#endif +}; + +struct Hash_table /* hash table information */ +{ + Hash_root_t* root; /* root hash table information */ + int size; /* table size */ + int buckets; /* active bucket count */ + char* name; /* table name */ + Hash_table_t* scope; /* scope covered table */ + short flags; /* flags: see HASH_[A-Z]* */ +#ifdef _HASH_TABLE_PRIVATE_ + _HASH_TABLE_PRIVATE_ +#endif +}; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Hash_table_t* hashalloc(Hash_table_t*, ...); +extern void hashdone(Hash_position_t*); +extern void hashdump(Hash_table_t*, int); +extern Hash_table_t* hashfree(Hash_table_t*); +extern Hash_bucket_t* hashlast(Hash_table_t*); +extern char* hashlook(Hash_table_t*, const char*, long, const char*); +extern Hash_bucket_t* hashnext(Hash_position_t*); +extern Hash_position_t* hashscan(Hash_table_t*, int); +extern void hashsize(Hash_table_t*, int); +extern Hash_table_t* hashview(Hash_table_t*, Hash_table_t*); +extern int hashwalk(Hash_table_t*, int, int (*)(const char*, char*, void*), void*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/hashkey.h b/illumos-x86_64/usr/include/ast/hashkey.h new file mode 100644 index 00000000..1def6dda --- /dev/null +++ b/illumos-x86_64/usr/include/ast/hashkey.h @@ -0,0 +1,68 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * 1-6 char lower-case keyword -> long hash + * digit args passed as HASHKEYN('2') + */ + +#ifndef _HASHKEY_H +#define _HASHKEY_H + +#define HASHKEYMAX 6 +#define HASHKEYBIT 5 +#define HASHKEYOFF ('a'-1) +#define HASHKEYPART(h,c) (((h)< * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * K. P. Vo + * G. S. Fowler + * AT&T Research + * + * ``the best'' combined linear congruent checksum/hash/PRNG + */ + +#ifndef _HASHPART_H +#define _HASHPART_H + +#define HASH_ADD(h) (0x9c39c33dL) + +#if __sparc__ || __sparc || sparc + +#define HASH_A(h,n) ((((h) << 2) - (h)) << (n)) +#define HASH_B(h,n) ((((h) << 4) - (h)) << (n)) +#define HASH_C(h,n) ((HASH_A(h,7) + HASH_B(h,0)) << (n)) +#define HASH_MPY(h) (HASH_C(h,22)+HASH_C(h,10)+HASH_A(h,6)+HASH_A(h,3)+(h)) + +#else + +#define HASH_MPY(h) ((h)*0x63c63cd9L) + +#endif + +#define HASHPART(h,c) (h = HASH_MPY(h) + HASH_ADD(h) + (c)) + +#endif diff --git a/illumos-x86_64/usr/include/ast/history.h b/illumos-x86_64/usr/include/ast/history.h new file mode 100644 index 00000000..73d9c643 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/history.h @@ -0,0 +1,81 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1982-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* David Korn * +* * +***********************************************************************/ +#pragma prototyped +#ifndef HIST_VERSION +/* + * Interface for history mechanism + * written by David Korn + * + */ + +#include + +#define HIST_CHAR '!' +#define HIST_VERSION 1 /* history file format version no. */ + +typedef struct +{ + Sfdisc_t histdisc; /* discipline for history */ + Sfio_t *histfp; /* history file stream pointer */ + char *histname; /* name of history file */ + int32_t histind; /* current command number index */ + int histsize; /* number of accessible history lines */ +#ifdef _HIST_PRIVATE + _HIST_PRIVATE +#endif /* _HIST_PRIVATE */ +} History_t; + +typedef struct +{ + int hist_command; + int hist_line; + int hist_char; +} Histloc_t; + +/* the following are readonly */ +extern const char hist_fname[]; + +extern int _Hist; +#define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0) +#define hist_max(hp) ((int)((hp)->histind)) +/* these are the history interface routines */ +extern int sh_histinit(void *); +extern void hist_cancel(History_t*); +extern void hist_close(History_t*); +extern int hist_copy(char*, int, int, int); +extern void hist_eof(History_t*); +extern Histloc_t hist_find(History_t*,char*,int, int, int); +extern void hist_flush(History_t*); +extern void hist_list(History_t*,Sfio_t*, off_t, int, char*); +extern int hist_match(History_t*,off_t, char*, int*); +extern off_t hist_tell(History_t*,int); +extern off_t hist_seek(History_t*,int); +extern char *hist_word(char*, int, int); +#if SHOPT_ESH + extern Histloc_t hist_locate(History_t*,int, int, int); +#endif /* SHOPT_ESH */ + +#endif /* HIST_VERSION */ diff --git a/illumos-x86_64/usr/include/ast/iconv.h b/illumos-x86_64/usr/include/ast/iconv.h new file mode 100644 index 00000000..15ad39d6 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/iconv.h @@ -0,0 +1,28 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#include diff --git a/illumos-x86_64/usr/include/ast/ip6.h b/illumos-x86_64/usr/include/ast/ip6.h new file mode 100644 index 00000000..dc0b2411 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ip6.h @@ -0,0 +1,46 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +#ifndef _IP6_H +#define _IP6_H 1 + +#define IP6ADDR 16 +#define IP6BITS IP6ADDR +#define IP6PREFIX (IP6ADDR+1) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* fmtip6(const unsigned char*, int); +extern int strtoip6(const char*, char**, unsigned char*, unsigned char*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/lc.h b/illumos-x86_64/usr/include/ast/lc.h new file mode 100644 index 00000000..aac40d9f --- /dev/null +++ b/illumos-x86_64/usr/include/ast/lc.h @@ -0,0 +1,167 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated by cmd/ast/tools/lcgen : : */ + + +#ifndef _LC_H +#if !defined(__PROTO__) +#include +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _LC_H 1 + +#include + +#define LC_abbreviated 0x00001 +#define LC_checked 0x00002 +#define LC_debug 0x00004 +#define LC_default 0x00008 +#define LC_defined 0x00010 +#define LC_local 0x00020 +#define LC_primary 0x00040 +#define LC_qualified 0x00080 +#define LC_undefined 0x00100 +#define LC_utf8 0x00200 +#define LC_verbose 0x00400 +#define LC_setlocale 0x10000 +#define LC_setenv 0x20000 +#define LC_user 0x40000 + +#define LC_language_attribute_max 2 +#define LC_territory_language_max 4 + +struct Lc_s; + +typedef struct Lc_info_s +{ + const struct Lc_s* lc; + unsigned long number; + __V_* data; +} Lc_info_t; + +typedef struct Lc_attribute_s +{ + const char* name; + unsigned long flags; + unsigned long index; +} Lc_attribute_t; + +typedef struct Lc_charset_s +{ + const char* code; + const char* alternates; + const char* ms; + unsigned long index; +} Lc_charset_t; + +typedef struct Lc_language_s +{ + const char* code; + const char* name; + const char* alternates; + const Lc_charset_t* charset; + unsigned long flags; + unsigned long index; + const Lc_attribute_t* attributes[LC_language_attribute_max]; +} Lc_language_t; + +typedef struct Lc_territory_s +{ + const char* code; + const char* name; + unsigned long flags; + unsigned long index; + const Lc_language_t* languages[LC_territory_language_max]; +#ifdef _LC_TERRITORY_PRIVATE_ + _LC_TERRITORY_PRIVATE_ +#endif +} Lc_territory_t; + +typedef struct Lc_map_s +{ + const char* code; + const Lc_language_t* language; + const Lc_territory_t* territory; + const Lc_charset_t* charset; + const Lc_attribute_t* attribute; +} Lc_map_t; + +typedef struct Lc_attribute_list_s +{ + struct Lc_attribute_list_s* next; + const Lc_attribute_t* attribute; +} Lc_attribute_list_t; + +typedef struct Lc_s +{ + const char* name; + const char* code; + const Lc_language_t* language; + const Lc_territory_t* territory; + const Lc_charset_t* charset; + const Lc_attribute_list_t* attributes; + unsigned long flags; + unsigned long index; +#ifdef _LC_PRIVATE_ + _LC_PRIVATE_ +#endif +} Lc_t; + +struct Lc_category_s; + +typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*)); + +typedef struct Lc_category_s +{ + const char* name; + int external; + int internal; + Lc_category_set_f setf; + Lc_t* prev; + unsigned int flags; +} Lc_category_t; + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t)); +extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void)); +extern __MANGLE__ int lcindex __PROTO__((int, int)); +extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int)); +extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*)); +extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*)); + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#endif diff --git a/illumos-x86_64/usr/include/ast/ls.h b/illumos-x86_64/usr/include/ast/ls.h new file mode 100644 index 00000000..6402ab57 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/ls.h @@ -0,0 +1,94 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * ls formatter interface definitions + */ + +#ifndef _LS_H +#define _LS_H + +#include +#include +#include + +/* + * some systems (could it beee AIX) pollute the std name space + */ + +#undef fileid +#define fileid fileID + +#define LS_BLOCKSIZE 512 + +#define iblocks(p) _iblocks(p) + +#if _mem_st_rdev_stat +#define idevice(p) ((p)->st_rdev) +#define IDEVICE(p,v) ((p)->st_rdev=(v)) +#else +#define idevice(p) 0 +#define IDEVICE(p,v) +#endif + +#define LS_ATIME (1<<0) /* list st_atime */ +#define LS_BLOCKS (1<<1) /* list blocks used by file */ +#define LS_CTIME (1<<2) /* list st_ctime */ +#define LS_EXTERNAL (1<<3) /* st_mode is modex canonical */ +#define LS_INUMBER (1<<4) /* list st_ino */ +#define LS_LONG (1<<5) /* long listing */ +#define LS_MARK (1<<6) /* append file name marks */ +#define LS_NOGROUP (1<<7) /* omit group name for LS_LONG */ +#define LS_NOUSER (1<<8) /* omit user name for LS_LONG */ +#define LS_NUMBER (1<<9) /* number instead of name */ + +#define LS_USER (1<<10) /* first user flag bit */ + +#define LS_W_BLOCKS 6 /* LS_BLOCKS field width */ +#define LS_W_INUMBER 9 /* LS_INUMBER field width */ +#define LS_W_LONG 57 /* LS_LONG width (w/o names) */ +#define LS_W_LINK 4 /* link text width (w/o names) */ +#define LS_W_MARK 1 /* LS_MARK field width */ +#define LS_W_NAME 9 /* group|user name field width */ + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern off_t _iblocks(struct stat*); +extern char* fmtdev(struct stat*); +extern char* fmtfs(struct stat*); +extern char* fmtls(char*, const char*, struct stat*, const char*, const char*, int); +extern int pathstat(const char*, struct stat*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/magic.h b/illumos-x86_64/usr/include/ast/magic.h new file mode 100644 index 00000000..e5163ec4 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/magic.h @@ -0,0 +1,92 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * magic interface definitions + */ + +#ifndef _MAGIC_H +#define _MAGIC_H + +#include +#include + +#define MAGIC_VERSION 19961031L + +#ifndef MAGIC_FILE +#define MAGIC_FILE "lib/file/magic" +#endif + +#ifndef MAGIC_DIR +#define MAGIC_DIR "lib/file" +#endif + +#define MAGIC_FILE_ENV "MAGICFILE" + +#define MAGIC_MIME (1<<0) /* magictype returns MIME type */ +#define MAGIC_VERBOSE (1<<1) /* verbose magic file errors */ +#define MAGIC_ALL (1<<2) /* list all table matches */ + +#define MAGIC_USER (1L<<16) /* first user flag bit */ + +struct Magic_s; +struct Magicdisc_s; + +typedef struct Magicdisc_s +{ + unsigned long version; /* interface version */ + unsigned long flags; /* MAGIC_* flags */ + Error_f errorf; /* error function */ +} Magicdisc_t; + +typedef struct Magic_s +{ + const char* id; /* library id string */ + +#ifdef _MAGIC_PRIVATE_ + _MAGIC_PRIVATE_ +#endif + +} Magic_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Magic_t* magicopen(Magicdisc_t*); +extern int magicload(Magic_t*, const char*, unsigned long); +extern int magiclist(Magic_t*, Sfio_t*); +extern char* magictype(Magic_t*, Sfio_t*, const char*, struct stat*); +extern int magicclose(Magic_t*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/magicid.h b/illumos-x86_64/usr/include/ast/magicid.h new file mode 100644 index 00000000..6b0e7adf --- /dev/null +++ b/illumos-x86_64/usr/include/ast/magicid.h @@ -0,0 +1,52 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * generic binary magic id definitions + */ + +#ifndef _MAGICID_H +#define _MAGICID_H 1 + +#include + +#define MAGICID 0x00010203 + +typedef uint32_t Magicid_data_t; + +typedef struct Magicid_s +{ + Magicid_data_t magic; /* magic number */ + char name[8]; /* generic data/application name*/ + char type[12]; /* specific data type */ + Magicid_data_t version; /* YYYYMMDD or 0xWWXXYYZZ */ + Magicid_data_t size; +} Magicid_t; + +#endif diff --git a/illumos-x86_64/usr/include/ast/mc.h b/illumos-x86_64/usr/include/ast/mc.h new file mode 100644 index 00000000..fe9d6d92 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/mc.h @@ -0,0 +1,102 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * machine independent binary message catalog interface + * + * file layout + * all numbers are sfputu() format + * + * 4 char magic (^M^S^G0) + * \0 + * (\0)* + * \0 + * string table size + * #msgs total + * #max set number + * #set-id 1 + * #msgs in set 1 + * ... + * #set-id #sets + * #msgs in set #sets + * end of sets (0) + * msg(1,1) size + * ... + * msg(#sets,#msgs) size + * string table + */ + +#ifndef _MC_H +#define _MC_H + +#include + +#define MC_MAGIC "\015\023\007\000" +#define MC_MAGIC_SIZE 4 + +#define MC_SET_MAX 1023 +#define MC_NUM_MAX 32767 + +#define MC_NLS (1<<10) + +#define MC_MESSAGE_SET(s) mcindex(s,NiL,NiL,NiL) + +typedef struct Mcset_s +{ + char** msg; + int num; + int gen; +} Mcset_t; + +typedef struct Mc_s +{ + Mcset_t* set; + int num; + int gen; + char* translation; +#ifdef _MC_PRIVATE_ + _MC_PRIVATE_ +#endif +} Mc_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* mcfind(const char*, const char*, int, int, char*, size_t); +extern Mc_t* mcopen(Sfio_t*); +extern char* mcget(Mc_t*, int, int, const char*); +extern int mcput(Mc_t*, int, int, const char*); +extern int mcdump(Mc_t*, Sfio_t*); +extern int mcindex(const char*, char**, int*, int*); +extern int mcclose(Mc_t*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/mime.h b/illumos-x86_64/usr/include/ast/mime.h new file mode 100644 index 00000000..14a9ef70 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/mime.h @@ -0,0 +1,97 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * mime/mailcap interface + */ + +#ifndef _MIMETYPE_H +#define _MIMETYPE_H 1 + +#include +#include + +#define MIME_VERSION 19970717L + +#ifndef MIME_FILES +#define MIME_FILES "~/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap" +#endif + +#define MIME_FILES_ENV "MAILCAP" + +#define MIME_LIST (1<<0) /* mimeload arg is : list */ +#define MIME_NOMAGIC (1<<1) /* no magic for mimetype() */ +#define MIME_PIPE (1<<2) /* mimeview() io is piped */ +#define MIME_REPLACE (1<<3) /* replace existing definition */ + +#define MIME_USER (1L<<16) /* first user flag bit */ + +struct Mime_s; +typedef struct Mime_s Mime_t; + +struct Mimedisc_s; +typedef struct Mimedisc_s Mimedisc_t; + +typedef int (*Mimevalue_f)(Mime_t*, void*, char*, size_t, Mimedisc_t*); + +struct Mimedisc_s +{ + unsigned long version; /* interface version */ + unsigned long flags; /* MIME_* flags */ + Error_f errorf; /* error function */ + Mimevalue_f valuef; /* value extraction function */ +}; + +struct Mime_s +{ + const char* id; /* library id string */ + +#ifdef _MIME_PRIVATE_ + _MIME_PRIVATE_ +#endif + +}; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Mime_t* mimeopen(Mimedisc_t*); +extern int mimeload(Mime_t*, const char*, unsigned long); +extern int mimelist(Mime_t*, Sfio_t*, const char*); +extern int mimeclose(Mime_t*); +extern int mimeset(Mime_t*, char*, unsigned long); +extern char* mimetype(Mime_t*, Sfio_t*, const char*, struct stat*); +extern char* mimeview(Mime_t*, const char*, const char*, const char*, const char*); +extern int mimehead(Mime_t*, void*, size_t, size_t, char*); +extern int mimecmp(const char*, const char*, char**); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/mnt.h b/illumos-x86_64/usr/include/ast/mnt.h new file mode 100644 index 00000000..655acc78 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/mnt.h @@ -0,0 +1,64 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * mounted filesystem scan interface + */ + +#ifndef _MNT_H +#define _MNT_H 1 + +#undef MNT_REMOTE /* aix clash */ +#define MNT_REMOTE (1<<0) /* remote mount */ + +typedef struct +{ + char* fs; /* filesystem name */ + char* dir; /* mounted dir */ + char* type; /* filesystem type */ + char* options; /* options */ + int freq; /* backup frequency */ + int npass; /* number of parallel passes */ + int flags; /* MNT_* flags */ +} Mnt_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void* mntopen(const char*, const char*); +extern Mnt_t* mntread(void*); +extern int mntwrite(void*, const Mnt_t*); +extern int mntclose(void*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/modecanon.h b/illumos-x86_64/usr/include/ast/modecanon.h new file mode 100644 index 00000000..3266ff61 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/modecanon.h @@ -0,0 +1,71 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * canonical mode_t representation + */ + +#ifndef _MODECANON_H +#define _MODECANON_H + +#define X_ITYPE(m) ((m)&X_IFMT) + +#define X_IFMT 0170000 +#define X_IFWHT 0160000 +#define X_IFDOOR 0150000 +#define X_IFSOCK 0140000 +#define X_IFLNK 0120000 +#define X_IFCTG 0110000 +#define X_IFREG 0100000 +#define X_IFBLK 0060000 +#define X_IFDIR 0040000 +#define X_IFCHR 0020000 +#define X_IFIFO 0010000 + +#define X_IPERM 0007777 +#define X_ISUID 0004000 +#define X_ISGID 0002000 +#define X_ISVTX 0001000 +#define X_IRUSR 0000400 +#define X_IWUSR 0000200 +#define X_IXUSR 0000100 +#define X_IRGRP 0000040 +#define X_IWGRP 0000020 +#define X_IXGRP 0000010 +#define X_IROTH 0000004 +#define X_IWOTH 0000002 +#define X_IXOTH 0000001 + +#define X_IRWXU (X_IRUSR|X_IWUSR|X_IXUSR) +#define X_IRWXG (X_IRGRP|X_IWGRP|X_IXGRP) +#define X_IRWXO (X_IROTH|X_IWOTH|X_IXOTH) + +#endif diff --git a/illumos-x86_64/usr/include/ast/modex.h b/illumos-x86_64/usr/include/ast/modex.h new file mode 100644 index 00000000..290d68bc --- /dev/null +++ b/illumos-x86_64/usr/include/ast/modex.h @@ -0,0 +1,57 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * AT&T Research + * + * external mode_t representation support + */ + +#ifndef _MODEX_H +#define _MODEX_H + +#include +#include + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int modei(int); +extern int modex(int); + +#undef extern + +#if _S_IDPERM +#define modei(m) ((m)&X_IPERM) +#if _S_IDTYPE +#define modex(m) (m) +#endif +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/namval.h b/illumos-x86_64/usr/include/ast/namval.h new file mode 100644 index 00000000..20e7fa49 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/namval.h @@ -0,0 +1,48 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * common name-value struct support + */ + +#ifndef _NAMVAL_H +#define _NAMVAL_H + +typedef struct +{ + char* name; + int value; +#ifdef _NAMVAL_PRIVATE_ + _NAMVAL_PRIVATE_ +#endif +} Namval_t; + +#endif diff --git a/illumos-x86_64/usr/include/ast/nl_types.h b/illumos-x86_64/usr/include/ast/nl_types.h new file mode 100644 index 00000000..5c257256 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/nl_types.h @@ -0,0 +1,28 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#include diff --git a/illumos-x86_64/usr/include/ast/nval.h b/illumos-x86_64/usr/include/ast/nval.h new file mode 100644 index 00000000..3d3534f9 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/nval.h @@ -0,0 +1,328 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1982-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* David Korn * +* * +***********************************************************************/ +#pragma prototyped +#ifndef NV_DEFAULT +/* + * David Korn + * AT&T Labs + * + * Interface definitions of structures for name-value pairs + * These structures are used for named variables, functions and aliases + * + */ + + +#include +#include +#include + +/* for compatibility with old hash library */ +#define Hashtab_t Dt_t +#define HASH_BUCKET 1 +#define HASH_NOSCOPE 2 +#define HASH_SCOPE 4 +#define hashscope(x) dtvnext(x) + +typedef struct Namval Namval_t; +typedef struct Namfun Namfun_t; +typedef struct Namdisc Namdisc_t; +typedef struct Nambfun Nambfun_t; +typedef struct Namarray Namarr_t; +typedef struct Namdecl Namdecl_t; + +/* + * This defines the template for nodes that have their own assignment + * and or lookup functions + */ +struct Namdisc +{ + size_t dsize; + void (*putval)(Namval_t*, const char*, int, Namfun_t*); + char *(*getval)(Namval_t*, Namfun_t*); + Sfdouble_t (*getnum)(Namval_t*, Namfun_t*); + char *(*setdisc)(Namval_t*, const char*, Namval_t*, Namfun_t*); + Namval_t *(*createf)(Namval_t*, const char*, int, Namfun_t*); + Namfun_t *(*clonef)(Namval_t*, Namval_t*, int, Namfun_t*); + char *(*namef)(Namval_t*, Namfun_t*); + Namval_t *(*nextf)(Namval_t*, Dt_t*, Namfun_t*); + Namval_t *(*typef)(Namval_t*, Namfun_t*); + int (*readf)(Namval_t*, Sfio_t*, int, Namfun_t*); + int (*writef)(Namval_t*, Sfio_t*, int, Namfun_t*); +}; + +struct Namfun +{ + const Namdisc_t *disc; + char nofree; + unsigned char subshell; + uint32_t dsize; + Namfun_t *next; + char *last; + Namval_t *type; +}; + +struct Nambfun +{ + Namfun_t fun; + int num; + const char **bnames; + Namval_t *bltins[1]; +}; + +/* This is an array template header */ +struct Namarray +{ + Namfun_t hdr; + long nelem; /* number of elements */ + void *(*fun)(Namval_t*,const char*,int); /* associative arrays */ + void *fixed; /* for fixed sized arrays */ + Dt_t *table; /* for subscripts */ + void *scope; /* non-zerp when scoped */ +}; + +/* The context pointer for declaration command */ +struct Namdecl +{ + Namval_t *tp; /* point to type */ + const char *optstring; + void *optinfof; +}; + +/* attributes of name-value node attribute flags */ + +#define NV_DEFAULT 0 +/* This defines the attributes for an attributed name-value pair node */ +struct Namval +{ + Dtlink_t nvlink; /* space for cdt links */ + char *nvname; /* pointer to name of the node */ +#if _ast_sizeof_pointer == 8 +# if _ast_intswap > 0 + unsigned short nvflag; /* attributes */ + unsigned short pad1; +# else + unsigned short pad1; + unsigned short nvflag; /* attributes */ +# endif + uint32_t nvsize; /* size or base */ +#else + unsigned short nvflag; /* attributes */ + unsigned short nvsize; /* size or base */ +#endif +#ifdef _NV_PRIVATE + _NV_PRIVATE +#else + Namfun_t *nvfun; + char *nvalue; + char *nvprivate; +#endif /* _NV_PRIVATE */ +}; + +#define NV_CLASS ".sh.type" +#define NV_DATA "_" /* special class or instance variable */ +#define NV_MINSZ (sizeof(struct Namval)-sizeof(Dtlink_t)-sizeof(char*)) +#define nv_namptr(p,n) ((Namval_t*)((char*)(p)+(n)*NV_MINSZ-sizeof(Dtlink_t))) + +/* The following attributes are for internal use */ +#define NV_NOFREE 0x200 /* don't free the space when releasing value */ +#define NV_ARRAY 0x400 /* node is an array */ +#define NV_REF 0x4000 /* reference bit */ +#define NV_TABLE 0x800 /* node is a dictionary table */ +#define NV_IMPORT 0x1000 /* value imported from environment */ +#define NV_MINIMAL NV_IMPORT /* node does not contain all fields */ + +#define NV_INTEGER 0x2 /* integer attribute */ +/* The following attributes are valid only when NV_INTEGER is off */ +#define NV_LTOU 0x4 /* convert to uppercase */ +#define NV_UTOL 0x8 /* convert to lowercase */ +#define NV_ZFILL 0x10 /* right justify and fill with leading zeros */ +#define NV_RJUST 0x20 /* right justify and blank fill */ +#define NV_LJUST 0x40 /* left justify and blank fill */ +#define NV_BINARY 0x100 /* fixed size data buffer */ +#define NV_RAW NV_LJUST /* used only with NV_BINARY */ +#define NV_HOST (NV_RJUST|NV_LJUST) /* map to host filename */ + +/* The following attributes do not effect the value */ +#define NV_RDONLY 0x1 /* readonly bit */ +#define NV_EXPORT 0x2000 /* export bit */ +#define NV_TAGGED 0x8000 /* user define tag bit */ + +/* The following are used with NV_INTEGER */ +#define NV_SHORT (NV_RJUST) /* when integers are not long */ +#define NV_LONG (NV_UTOL) /* for long long and long double */ +#define NV_UNSIGN (NV_LTOU) /* for unsigned quantities */ +#define NV_DOUBLE (NV_INTEGER|NV_ZFILL) /* for floating point */ +#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */ +#define NV_HEXFLOAT (NV_LTOU) /* for C99 base16 float notation */ + +/* options for nv_open */ + +#define NV_APPEND 0x10000 /* append value */ +#define NV_MOVE 0x8000000 /* for use with nv_clone */ +#define NV_ADD 8 + /* add node if not found */ +#define NV_ASSIGN NV_NOFREE /* assignment is possible */ +#define NV_NOASSIGN 0 /* backward compatibility */ +#define NV_NOARRAY 0x200000 /* array name not possible */ +#define NV_IARRAY 0x400000 /* for indexed array */ +#define NV_NOREF NV_REF /* don't follow reference */ +#define NV_IDENT 0x80 /* name must be identifier */ +#define NV_VARNAME 0x20000 /* name must be ?(.)id*(.id) */ +#define NV_NOADD 0x40000 /* do not add node */ +#define NV_NOSCOPE 0x80000 /* look only in current scope */ +#define NV_NOFAIL 0x100000 /* return 0 on failure, no msg */ +#define NV_NODISC NV_IDENT /* ignore disciplines */ + +#define NV_FUNCT NV_IDENT /* option for nv_create */ +#define NV_BLTINOPT NV_ZFILL /* mark builtins in libcmd */ + +#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD)) + +/* numeric types */ +#define NV_INT16P (NV_LJUST|NV_SHORT|NV_INTEGER) +#define NV_INT16 (NV_SHORT|NV_INTEGER) +#define NV_UINT16 (NV_UNSIGN|NV_SHORT|NV_INTEGER) +#define NV_UINT16P (NV_LJUSTNV_UNSIGN|NV_SHORT|NV_INTEGER) +#define NV_INT32 (NV_INTEGER) +#define NV_UNT32 (NV_UNSIGN|NV_INTEGER) +#define NV_INT64 (NV_LONG|NV_INTEGER) +#define NV_UINT64 (NV_UNSIGN|NV_LONG|NV_INTEGER) +#define NV_FLOAT (NV_SHORT|NV_DOUBLE) +#define NV_LDOUBLE (NV_LONG|NV_DOUBLE) + +/* name-value pair macros */ +#define nv_isattr(np,f) ((np)->nvflag & (f)) +#define nv_onattr(n,f) ((n)->nvflag |= (f)) +#define nv_offattr(n,f) ((n)->nvflag &= ~(f)) +#define nv_isarray(np) (nv_isattr((np),NV_ARRAY)) + +/* The following are operations for associative arrays */ +#define NV_AINIT 1 /* initialize */ +#define NV_AFREE 2 /* free array */ +#define NV_ANEXT 3 /* advance to next subscript */ +#define NV_ANAME 4 /* return subscript name */ +#define NV_ADELETE 5 /* delete current subscript */ +#define NV_AADD 6 /* add subscript if not found */ +#define NV_ACURRENT 7 /* return current subscript Namval_t* */ +#define NV_ASETSUB 8 /* set current subscript */ + +/* The following are for nv_disc */ +#define NV_FIRST 1 +#define NV_LAST 2 +#define NV_POP 3 +#define NV_CLONE 4 + +/* The following are operations for nv_putsub() */ +#define ARRAY_BITS 22 +#define ARRAY_ADD (1L< * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * command line option parse interface + */ + +#ifndef _OPTION_H +#define _OPTION_H + +#include + +#define OPT_VERSION 20070319L + +#define OPT_USER (1L<<16) /* first user flag bit */ + +struct Opt_s; +struct Optdisc_s; + +typedef int (*Optinfo_f)(struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*); + +typedef struct Optdisc_s +{ + unsigned long version; /* OPT_VERSION */ + unsigned long flags; /* OPT_* flags */ + char* catalog; /* error catalog id */ + Optinfo_f infof; /* runtime info function */ +} Optdisc_t; + +/* NOTE: Opt_t member order fixed by a previous binary release */ + +#ifndef _OPT_PRIVATE_ +#define _OPT_PRIVATE_ \ + char pad[3*sizeof(void*)]; +#endif + +typedef struct Opt_s +{ + int again; /* see optjoin() */ + char* arg; /* {:,#} string argument */ + char** argv; /* most recent argv */ + int index; /* argv index */ + char* msg; /* error/usage message buffer */ + long num; /* OBSOLETE -- use number */ + int offset; /* char offset in argv[index] */ + char option[8]; /* current flag {-,+} + option */ + char name[64]; /* current long name or flag */ + Optdisc_t* disc; /* user discipline */ + intmax_t number; /* # numeric argument */ + unsigned char assignment; /* option arg assigment op */ + unsigned char pads[sizeof(void*)-1]; + _OPT_PRIVATE_ +} Opt_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Opt_t* _opt_infop_; + +#define opt_info (*_opt_infop_) + +#undef extern + +#define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d)) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int optget(char**, const char*); +extern int optjoin(char**, ...); +extern char* opthelp(const char*, const char*); +extern char* optusage(const char*); +extern int optstr(const char*, const char*); +extern int optesc(Sfio_t*, const char*, int); +extern Opt_t* optctx(Opt_t*, Opt_t*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/preroot.h b/illumos-x86_64/usr/include/ast/preroot.h new file mode 100644 index 00000000..87959da8 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/preroot.h @@ -0,0 +1,31 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* : : generated from contrib/ast/src/lib/libast/features/preroot.sh by iffe version 2012-07-17 : : */ +#ifndef _def_preroot_ast +#define _def_preroot_ast 1 +#define _sys_types 1 /* #include ok */ +/* preroot not enabled */ +#endif diff --git a/illumos-x86_64/usr/include/ast/proc.h b/illumos-x86_64/usr/include/ast/proc.h new file mode 100644 index 00000000..add8c5c4 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/proc.h @@ -0,0 +1,114 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * process library interface + */ + +#ifndef _PROC_H +#define _PROC_H + +#include + +#define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */ +#define PROC_BACKGROUND (1<<1) /* shell background (&) setup */ +#define PROC_CHECK (1<<17) /* check that command exists */ +#define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */ +#define PROC_DAEMON (1<<3) /* daemon setup */ +#define PROC_ENVCLEAR (1<<4) /* clear environment */ +#define PROC_FOREGROUND (1<<14) /* system(3) setup */ +#define PROC_GID (1<<5) /* setgid(getgid()) */ +#define PROC_IGNORE (1<<6) /* ignore parent pipe errors */ +#define PROC_IGNOREPATH (1<<16) /* procrun() intercept to ignore path */ +#define PROC_ORPHAN (1<<18) /* create orphaned process */ +#define PROC_OVERLAY (1<<7) /* overlay current process if possible */ +#define PROC_PARANOID (1<<8) /* restrict everything */ +#define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */ +#define PROC_READ (1<<10) /* proc pipe fd 1 returned */ +#define PROC_SESSION (1<<11) /* session leader */ +#define PROC_UID (1<<12) /* setuid(getuid()) */ +#define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */ +#define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */ + +#define PROC_ARG_BIT 14 /* bits per op arg */ +#define PROC_OP_BIT 4 /* bits per op */ + +#define PROC_ARG_NULL ((1<>(2*PROC_ARG_BIT))&((1<>(((n)-1)*PROC_ARG_BIT))&PROC_ARG_NULL):(((x)&~((1<<(2*PROC_ARG_BIT))-1))==~((1<<(2*PROC_ARG_BIT))-1))?(-1):((x)&~((1<<(2*PROC_ARG_BIT))-1))) + +typedef struct +{ + pid_t pid; /* process id */ + pid_t pgrp; /* process group id */ + int rfd; /* read fd if applicable */ + int wfd; /* write fd if applicable */ + +#ifdef _PROC_PRIVATE_ +_PROC_PRIVATE_ +#endif + +} Proc_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int procclose(Proc_t*); +extern int procfree(Proc_t*); +extern Proc_t* procopen(const char*, char**, char**, long*, int); +extern int procrun(const char*, char**, int); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/prototyped.h b/illumos-x86_64/usr/include/ast/prototyped.h new file mode 100644 index 00000000..ae164225 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/prototyped.h @@ -0,0 +1,65 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/* : : generated by proto : : */ + +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif diff --git a/illumos-x86_64/usr/include/ast/re_comp.h b/illumos-x86_64/usr/include/ast/re_comp.h new file mode 100644 index 00000000..fe878961 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/re_comp.h @@ -0,0 +1,47 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * re_comp interface definitions + * + * OBSOLETE: use + */ + +#ifndef _RE_COMP_H +#define _RE_COMP_H + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* re_comp(const char*); +extern int re_exec(const char*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/recfmt.h b/illumos-x86_64/usr/include/ast/recfmt.h new file mode 100644 index 00000000..3dd4c43a --- /dev/null +++ b/illumos-x86_64/usr/include/ast/recfmt.h @@ -0,0 +1,89 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * record format interface + */ + +#ifndef _RECFMT_H +#define _RECFMT_H 1 + +#include + +typedef uint32_t Recfmt_t; + +#define REC_delimited 0 +#define REC_fixed 1 +#define REC_variable 2 +#define REC_method 14 +#define REC_none 15 + +#define REC_M_path 0 +#define REC_M_data 1 + +#define RECTYPE(f) (((f)>>28)&((1<<4)-1)) + +#define REC_D_TYPE(d) ((REC_delimited<<28)|((d)&((1<<8)-1))) +#define REC_D_DELIMITER(f) ((f)&((1<<8)-1)) + +#define REC_F_TYPE(s) ((REC_fixed<<28)|((s)&((1<<28)-1))) +#define REC_F_SIZE(f) ((f)&((1<<28)-1)) + +#define REC_U_TYPE(t,a) (((t)<<28)|((a)&((1<<28)-1))) +#define REC_U_ATTRIBUTES(f) ((f)&~((1<<28)-1)) + +#define REC_V_TYPE(h,o,z,l,i) ((REC_variable<<28)|((h)<<23)|((o)<<19)|(((z)-1)<<18)|((l)<<17)|((i)<<16)) +#define REC_V_RECORD(f,s) (((f)&(((1<<16)-1)<<16))|(s)) +#define REC_V_HEADER(f) (((f)>>23)&((1<<5)-1)) +#define REC_V_OFFSET(f) (((f)>>19)&((1<<4)-1)) +#define REC_V_LENGTH(f) ((((f)>>18)&1)+1) +#define REC_V_LITTLE(f) (((f)>>17)&1) +#define REC_V_INCLUSIVE(f) (((f)>>16)&1) +#define REC_V_SIZE(f) ((f)&((1<<16)-1)) +#define REC_V_ATTRIBUTES(f) ((f)&~((1<<16)-1)) + +#define REC_M_TYPE(i) ((REC_method<<28)|(i)) +#define REC_M_INDEX(f) ((f)&((1<<28)-1)) + +#define REC_N_TYPE() 0xffffffff + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern char* fmtrec(Recfmt_t, int); +extern Recfmt_t recfmt(const void*, size_t, off_t); +extern Recfmt_t recstr(const char*, char**); +extern ssize_t reclen(Recfmt_t, const void*, size_t); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/regex.h b/illumos-x86_64/usr/include/ast/regex.h new file mode 100644 index 00000000..bc40fa84 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/regex.h @@ -0,0 +1,260 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * regex library interface + */ + +#ifdef _AST_STD_I +#define _REGEX_H -1 +#define regex_t int +#define regmatch_t int +#endif +#ifndef _REGEX_H +#define _REGEX_H 1 +#undef regex_t +#undef regmatch_t + +#include +#include +#include + +#define REG_VERSION 20100930L + +/* regcomp flags */ + +#define REG_AUGMENTED 0x00000001 /* enable ! & < > */ +#define REG_EXTENDED 0x00000002 /* enable ( | ) */ +#define REG_ICASE 0x00000004 /* ignore case in match */ +#define REG_NEWLINE 0x00000008 /* ^/$ match embedded \n */ +#define REG_NOSUB 0x00000010 /* don't report subexp matches */ +#define REG_SHELL 0x00000020 /* shell pattern syntax */ + +/* nonstandard regcomp flags */ + +#define REG_LEFT 0x00000100 /* implicit ^... */ +#define REG_LITERAL 0x00000200 /* no operators */ +#define REG_MINIMAL 0x00000400 /* minimal match */ +#define REG_NULL 0x00000800 /* allow null patterns */ +#define REG_RIGHT 0x00001000 /* implicit ...$ */ +#define REG_LENIENT 0x00002000 /* look the other way */ +#define REG_ESCAPE 0x00004000 /* \ escapes delimiter in [...] */ +#define REG_FIRST 0x00008000 /* first match found will do */ +#define REG_MULTIPLE 0x00010000 /* multiple \n sep patterns */ +#define REG_DISCIPLINE 0x00020000 /* regex_t.re_disc is valid */ +#define REG_SPAN 0x00040000 /* . matches \n */ +#define REG_COMMENT 0x00080000 /* ignore pattern space & #...\n*/ +#define REG_MULTIREF 0x00100000 /* multiple digit backrefs */ +#define REG_MUSTDELIM 0x08000000 /* all delimiters required */ +#define REG_DELIMITED 0x10000000 /* pattern[0] is delimiter */ +#define REG_CLASS_ESCAPE 0x80000000 /* \ escapes in [...] */ + +#define REG_SHELL_DOT 0x00200000 /* explicit leading . match */ +#define REG_SHELL_ESCAPED 0x00400000 /* \ not special */ +#define REG_SHELL_GROUP 0x20000000 /* (|&) inside [@|&](...) only */ +#define REG_SHELL_PATH 0x00800000 /* explicit / match */ + +#define REG_REGEXP 0x40000000 /* compatibility */ + +/* regexec flags */ + +#define REG_NOTBOL 0x00000040 /* ^ is not a special char */ +#define REG_NOTEOL 0x00000080 /* $ is not a special char */ + +/* nonstandard regexec flags */ + +#define REG_INVERT 0x01000000 /* invert regrexec match sense */ +#define REG_STARTEND 0x02000000 /* subject==match[0].rm_{so,eo} */ +#define REG_ADVANCE 0x04000000 /* advance match[0].rm_{so,eo} */ + +/* regalloc flags */ + +#define REG_NOFREE 0x00000001 /* don't free */ + +/* regsub flags */ + +#define REG_SUB_ALL 0x00000001 /* substitute all occurrences */ +#define REG_SUB_LOWER 0x00000002 /* substitute to lower case */ +#define REG_SUB_UPPER 0x00000004 /* substitute to upper case */ +#define REG_SUB_PRINT 0x00000010 /* internal no-op */ +#define REG_SUB_NUMBER 0x00000020 /* internal no-op */ +#define REG_SUB_STOP 0x00000040 /* internal no-op */ +#define REG_SUB_WRITE 0x00000080 /* internal no-op */ +#define REG_SUB_LAST 0x00000100 /* last substitution option */ +#define REG_SUB_FULL 0x00000200 /* fully delimited */ +#define REG_SUB_USER 0x00001000 /* first user flag bit */ + +/* regex error codes */ + +#define REG_ENOSYS (-1) /* not supported */ +#define REG_NOMATCH 1 /* regexec didn't match */ +#define REG_BADPAT 2 /* invalid regular expression */ +#define REG_ECOLLATE 3 /* invalid collation element */ +#define REG_ECTYPE 4 /* invalid character class */ +#define REG_EESCAPE 5 /* trailing \ in pattern */ +#define REG_ESUBREG 6 /* invalid \digit backreference */ +#define REG_EBRACK 7 /* [...] imbalance */ +#define REG_EPAREN 8 /* \(...\) or (...) imbalance */ +#define REG_EBRACE 9 /* \{...\} or {...} imbalance */ +#define REG_BADBR 10 /* invalid {...} digits */ +#define REG_ERANGE 11 /* invalid [...] range endpoint */ +#define REG_ESPACE 12 /* out of space */ +#define REG_BADRPT 13 /* unary op not preceded by re */ +#define REG_ENULL 14 /* empty subexpr in pattern */ +#define REG_ECOUNT 15 /* re component count overflow */ +#define REG_BADESC 16 /* invalid \char escape */ +#define REG_VERSIONID 17 /* version id (pseudo error) */ +#define REG_EFLAGS 18 /* flags conflict */ +#define REG_EDELIM 19 /* invalid or omitted delimiter */ +#define REG_PANIC 20 /* unrecoverable internal error */ + +struct regex_s; typedef struct regex_s regex_t; +struct regdisc_s; typedef struct regdisc_s regdisc_t; + +typedef int (*regclass_t)(int); +typedef uint32_t regflags_t; +typedef int (*regerror_t)(const regex_t*, regdisc_t*, int, ...); +typedef void* (*regcomp_t)(const regex_t*, const char*, size_t, regdisc_t*); +typedef int (*regexec_t)(const regex_t*, void*, const char*, size_t, const char*, size_t, char**, regdisc_t*); +typedef void* (*regresize_t)(void*, void*, size_t); +typedef int (*regrecord_t)(void*, const char*, size_t); + +#if ASTAPI(20120528) +typedef ssize_t regoff_t; +#else +typedef int regoff_t; +#endif + +typedef struct regmatch_s +{ + regoff_t rm_so; /* offset of start */ + regoff_t rm_eo; /* offset of end */ +} regmatch_t; + +typedef struct regsub_s +{ + regflags_t re_flags; /* regsubcomp() flags */ + char* re_buf; /* regsubexec() output buffer */ + size_t re_len; /* re_buf length */ + int re_min; /* regsubcomp() min matches */ +#ifdef _REG_SUB_PRIVATE_ + _REG_SUB_PRIVATE_ +#endif +} regsub_t; + +struct regdisc_s +{ + unsigned long re_version; /* discipline version */ + regflags_t re_flags; /* discipline flags */ + regerror_t re_errorf; /* error function */ + int re_errorlevel; /* errorf level */ + regresize_t re_resizef; /* alloc/free function */ + void* re_resizehandle;/* resizef handle */ + regcomp_t re_compf; /* (?{...}) compile function */ + regexec_t re_execf; /* (?{...}) execute function */ + unsigned char* re_map; /* external to native ccode map */ +}; + +typedef struct regstat_s +{ + regflags_t re_flags; /* REG_* */ + ssize_t re_min; /* min anchored match length */ + ssize_t re_max; /* max anchored match length */ + ssize_t re_record; /* regrexec() match length */ + regflags_t re_info; /* REG_* info */ +} regstat_t; + +struct regex_s +{ + size_t re_nsub; /* number of subexpressions */ + struct reglib_s*re_info; /* library private info */ + size_t re_npat; /* number of pattern chars used */ + regdisc_t* re_disc; /* REG_DISCIPLINE discipline */ + regsub_t* re_sub; /* regsubcomp() data */ +}; + +#define reginit(disc) (memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int regcomp(regex_t*, const char*, regflags_t); +extern size_t regerror(int, const regex_t*, char*, size_t); +extern int regexec(const regex_t*, const char*, size_t, regmatch_t*, regflags_t); +extern void regfree(regex_t*); + +/* nonstandard hooks */ + +#define _REG_cache 1 /* have regcache() */ +#define _REG_class 1 /* have regclass() */ +#define _REG_collate 1 /* have regcollate(), regclass() */ +#define _REG_comb 1 /* have regcomb() */ +#define _REG_decomp 1 /* have regdecomp() */ +#define _REG_dup 1 /* have regdup() */ +#define _REG_fatal 1 /* have regfatal(), regfatalpat() */ +#define _REG_ncomp 1 /* have regncomp() */ +#define _REG_nexec 1 /* have regnexec() */ +#define _REG_rexec 1 /* have regrexec(), regrecord() */ +#define _REG_stat 1 /* have regstat() */ +#define _REG_subcomp 1 /* have regsubcomp(), regsubexec() */ + +extern regclass_t regclass(const char*, char**); +extern int regaddclass(const char*, regclass_t); +extern int regcollate(const char*, char**, char*, size_t, wchar_t*); +extern int regcomb(regex_t*, regex_t*); +extern size_t regdecomp(regex_t*, regflags_t, char*, size_t); +extern int regdup(regex_t*, regex_t*); +extern int regncomp(regex_t*, const char*, size_t, regflags_t); +extern int regnexec(const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t); +extern void regfatal(regex_t*, int, int); +extern void regfatalpat(regex_t*, int, int, const char*); +extern int regrecord(const regex_t*); +extern int regrexec(const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, void*, regrecord_t); +extern regstat_t* regstat(const regex_t*); + +extern regex_t* regcache(const char*, regflags_t, int*); + +extern int regsubcomp(regex_t*, const char*, const regflags_t*, int, regflags_t); +extern int regsubexec(const regex_t*, const char*, size_t, regmatch_t*); +extern int regsubflags(regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*); +extern void regsubfree(regex_t*); + +/* obsolete hooks */ + +#ifndef _SFIO_H +struct _sfio_s; +#endif + +extern void regalloc(void*, regresize_t, regflags_t); +extern int regsub(const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/regexp.h b/illumos-x86_64/usr/include/ast/regexp.h new file mode 100644 index 00000000..dd7a2af4 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/regexp.h @@ -0,0 +1,135 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * regexp interface and partial implementation + * what a novel approach + * don't do it again + * + * OBSOLETE: use + */ + +#ifndef _REGEXP_H +#define _REGEXP_H + +#define NBRA 9 + +typedef struct +{ + char* re_braslist[NBRA]; + char* re_braelist[NBRA]; + char* re_loc1; + char* re_loc2; + char* re_locs; + int re_circf; + int re_nbra; + int re_nodelim; + int re_sed; +} regexp_t; + +#define braslist _re_info.re_braslist +#define braelist _re_info.re_braelist +#define circf _re_info.re_circf +#define loc1 _re_info.re_loc1 +#define loc2 _re_info.re_loc2 +#define locs _re_info.re_locs +#define nbra _re_info.re_nbra +#define nodelim _re_info.re_nodelim +#define sed _re_info.re_sed + +#define advance(a,b) _re_exec(&_re_info,a,b,1) +#define compile(a,b,c,d) _re_read(&_re_info,a,b,c,d) +#define step(a,b) _re_exec(&_re_info,a,b,0) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int _re_comp(regexp_t*, const char*, char*, unsigned int); +extern int _re_exec(regexp_t*, const char*, const char*, int); +extern char* _re_putc(int); +extern char* _re_read(regexp_t*, const char*, char*, const char*, int); + +#undef extern + +#ifndef _REGEXP_DECLARE + +regexp_t _re_info; + +char* +_re_read(register regexp_t* re, const char* instring, char* ep, const char* endbuf, int seof) +{ + register int c; + + static const char* prev; + +#ifdef INIT + INIT; +#endif + + re->re_nodelim = 0; + if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0) + { + if (c != seof) + { + UNGETC(c); + re->re_nodelim = 1; + } + if (!re->re_sed && !prev) + { ERROR(41); } + RETURN((char*)endbuf); + } + UNGETC(c); + prev = 0; + for (;;) + { + if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0) + { + if (re->re_sed) + { ERROR(36); } + UNGETC(c); + re->re_nodelim = 1; + break; + } + if (c == '\\') + { + _re_putc(c); + if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0) + { ERROR(36); } + } + _re_putc(c); + } + if (c = _re_comp(re, _re_putc(0), ep, (char*)endbuf - ep)) + { ERROR(c); } + prev = endbuf; + RETURN((char*)prev); +} + +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/sfdisc.h b/illumos-x86_64/usr/include/ast/sfdisc.h new file mode 100644 index 00000000..d5d03c56 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/sfdisc.h @@ -0,0 +1,76 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * AT&T Research + * + * sfio discipline interface definitions + */ + +#ifndef _SFDISC_H +#define _SFDISC_H + +#include + +#define SFDCEVENT(a,b,n) ((((a)-'A'+1)<<11)^(((b)-'A'+1)<<6)^(n)) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +#define SFSK_DISCARD SFDCEVENT('S','K',1) + +/* + * %(...) printf support + */ + +typedef int (*Sf_key_lookup_t)(void*, Sffmt_t*, const char*, char**, Sflong_t*); +typedef char* (*Sf_key_convert_t)(void*, Sffmt_t*, const char*, char*, Sflong_t); + +extern int sfkeyprintf(Sfio_t*, void*, const char*, Sf_key_lookup_t, Sf_key_convert_t); +extern int sfkeyprintf_20000308(Sfio_t*, void*, const char*, Sf_key_lookup_t, Sf_key_convert_t); + +/* + * pure sfio read and/or write disciplines + */ + +extern int sfdcdio(Sfio_t*, size_t); +extern int sfdcdos(Sfio_t*); +extern int sfdcfilter(Sfio_t*, const char*); +extern int sfdcmore(Sfio_t*, const char*, int, int); +extern int sfdcprefix(Sfio_t*, const char*); +extern int sfdcseekable(Sfio_t*); +extern int sfdcslow(Sfio_t*); +extern int sfdctee(Sfio_t*, Sfio_t*); +extern int sfdcunion(Sfio_t*, Sfio_t**, int); + +extern Sfio_t* sfdcsubstream(Sfio_t*, Sfio_t*, Sfoff_t, Sfoff_t); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/sfio.h b/illumos-x86_64/usr/include/ast/sfio.h new file mode 100644 index 00000000..ce7776d5 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/sfio.h @@ -0,0 +1,463 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#ifndef _SFIO_H +#define _SFIO_H 1 + +#define SFIO_VERSION 20090915L + +/* Public header file for the sfio library +** +** Written by Kiem-Phong Vo +*/ + +typedef struct _sfio_s Sfio_t; +typedef struct _sfdisc_s Sfdisc_t; + +#if defined(_AST_STD_H) || defined(_PACKAGE_ast) && defined(_SFIO_PRIVATE) +#include +#else +#include +#endif /* _PACKAGE_ast */ + +/* Sfoff_t should be large enough for largest file address */ +#define Sfoff_t intmax_t +#define Sflong_t intmax_t +#define Sfulong_t uintmax_t +#define Sfdouble_t _ast_fltmax_t + +typedef ssize_t (*Sfread_f)_ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*)); +typedef ssize_t (*Sfwrite_f)_ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*)); +typedef Sfoff_t (*Sfseek_f)_ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*)); +typedef int (*Sfexcept_f)_ARG_((Sfio_t*, int, Void_t*, Sfdisc_t*)); +typedef int (*Sfwalk_f)_ARG_((Sfio_t*, Void_t*)); + +/* discipline structure */ +struct _sfdisc_s +{ Sfread_f readf; /* read function */ + Sfwrite_f writef; /* write function */ + Sfseek_f seekf; /* seek function */ + Sfexcept_f exceptf; /* to handle exceptions */ + Sfdisc_t* disc; /* the continuing discipline */ +}; + +#include + +/* formatting environment */ +typedef struct _sffmt_s Sffmt_t; +typedef int (*Sffmtext_f)_ARG_((Sfio_t*, Void_t*, Sffmt_t*)); +typedef int (*Sffmtevent_f)_ARG_((Sfio_t*, int, Void_t*, Sffmt_t*)); +struct _sffmt_s +{ long version;/* version of this structure */ + Sffmtext_f extf; /* function to process arguments */ + Sffmtevent_f eventf; /* process events */ + + char* form; /* format string to stack */ + va_list args; /* corresponding arg list */ + + int fmt; /* format character */ + ssize_t size; /* object size */ + int flags; /* formatting flags */ + int width; /* width of field */ + int precis; /* precision required */ + int base; /* conversion base */ + + char* t_str; /* type string */ + ssize_t n_str; /* length of t_str */ + + Void_t* mbs; /* multibyte state for format string */ + + Void_t* none; /* unused for now */ +}; +#define sffmtversion(fe,type) \ + ((type) ? ((fe)->version = SFIO_VERSION) : (fe)->version) + +#define SFFMT_SSHORT 000000010 /* 'hh' flag, char */ +#define SFFMT_TFLAG 000000020 /* 't' flag, ptrdiff_t */ +#define SFFMT_ZFLAG 000000040 /* 'z' flag, size_t */ + +#define SFFMT_LEFT 000000100 /* left-justification */ +#define SFFMT_SIGN 000000200 /* must have a sign */ +#define SFFMT_BLANK 000000400 /* if not signed, prepend a blank */ +#define SFFMT_ZERO 000001000 /* zero-padding on the left */ +#define SFFMT_ALTER 000002000 /* alternate formatting */ +#define SFFMT_THOUSAND 000004000 /* thousand grouping */ +#define SFFMT_SKIP 000010000 /* skip assignment in scanf() */ +#define SFFMT_SHORT 000020000 /* 'h' flag */ +#define SFFMT_LONG 000040000 /* 'l' flag */ +#define SFFMT_LLONG 000100000 /* 'll' flag */ +#define SFFMT_LDOUBLE 000200000 /* 'L' flag */ +#define SFFMT_VALUE 000400000 /* value is returned */ +#define SFFMT_ARGPOS 001000000 /* getting arg for $ patterns */ +#define SFFMT_IFLAG 002000000 /* 'I' flag */ +#define SFFMT_JFLAG 004000000 /* 'j' flag, intmax_t */ +#define SFFMT_CENTER 010000000 /* '=' flag, center justification */ +#define SFFMT_CHOP 020000000 /* chop long string values from left */ +#define SFFMT_SET 037777770 /* flags settable on calling extf */ + +/* for sfmutex() call */ +#define SFMTX_LOCK 0 /* up mutex count */ +#define SFMTX_TRYLOCK 1 /* try to up mutex count */ +#define SFMTX_UNLOCK 2 /* down mutex count */ +#define SFMTX_CLRLOCK 3 /* clear mutex count */ + +/* various constants */ +#ifndef NULL +#define NULL 0 +#endif +#ifndef EOF +#define EOF (-1) +#endif +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +/* bits for various types of files */ +#define SF_READ 0000001 /* open for reading */ +#define SF_WRITE 0000002 /* open for writing */ +#define SF_STRING 0000004 /* a string stream */ +#define SF_APPENDWR 0000010 /* file is in append mode only */ +#define SF_MALLOC 0000020 /* buffer is malloc-ed */ +#define SF_LINE 0000040 /* line buffering */ +#define SF_SHARE 0000100 /* stream with shared file descriptor */ +#define SF_EOF 0000200 /* eof was detected */ +#define SF_ERROR 0000400 /* an error happened */ +#define SF_STATIC 0001000 /* a stream that cannot be freed */ +#define SF_IOCHECK 0002000 /* call exceptf before doing IO */ +#define SF_PUBLIC 0004000 /* SF_SHARE and follow physical seek */ +#define SF_MTSAFE 0010000 /* need thread safety */ +#define SF_WHOLE 0020000 /* preserve wholeness of sfwrite/sfputr */ +#define SF_IOINTR 0040000 /* return on interrupts */ +#define SF_WCWIDTH 0100000 /* wcwidth display stream */ + +#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */ +#define SF_SETS 0177163 /* flags passable to sfset() */ + +#ifndef _SF_NO_OBSOLETE +#define SF_BUFCONST 0400000 /* unused flag - for compatibility only */ +#endif + +/* for sfgetr/sfreserve to hold a record */ +#define SF_LOCKR 0000010 /* lock record, stop access to stream */ +#define SF_LASTR 0000020 /* get the last incomplete record */ + +/* exception events: SF_NEW(0), SF_READ(1), SF_WRITE(2) and the below */ +#define SF_SEEK 3 /* seek error */ +#define SF_CLOSING 4 /* when stream is about to be closed */ +#define SF_DPUSH 5 /* when discipline is being pushed */ +#define SF_DPOP 6 /* when discipline is being popped */ +#define SF_DPOLL 7 /* see if stream is ready for I/O */ +#define SF_DBUFFER 8 /* buffer not empty during push or pop */ +#define SF_SYNC 9 /* announcing start/end synchronization */ +#define SF_PURGE 10 /* a sfpurge() call was issued */ +#define SF_FINAL 11 /* closing is done except stream free */ +#define SF_READY 12 /* a polled stream is ready */ +#define SF_LOCKED 13 /* stream is in a locked state */ +#define SF_ATEXIT 14 /* process is exiting */ +#define SF_EVENT 100 /* start of user-defined events */ + +/* for stack and disciplines */ +#define SF_POPSTACK ((Sfio_t*)0) /* pop the stream stack */ +#define SF_POPDISC ((Sfdisc_t*)0) /* pop the discipline stack */ + +/* for the notify function and discipline exception */ +#define SF_NEW 0 /* new stream */ +#define SF_SETFD (-1) /* about to set the file descriptor */ +#define SF_MTACCESS (-2) /* starting a multi-threaded stream */ + +#define SF_BUFSIZE 8192 /* default buffer size */ +#define SF_UNBOUND (-1) /* unbounded buffer size */ + +/* namespace incursion workarounds -- migrate to the new names */ +#if !_mac_SF_APPEND +#define SF_APPEND SF_APPENDWR /* BSDI sys/stat.h */ +#endif +#if !_mac_SF_CLOSE +#define SF_CLOSE SF_CLOSING /* AIX sys/socket.h */ +#endif + +_BEGIN_EXTERNS_ + +#if _BLD_sfio && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_sfio && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern ssize_t _Sfi; +extern ssize_t _Sfmaxr; + +/* standard in/out/err streams */ +extern Sfio_t* sfstdin; +extern Sfio_t* sfstdout; +extern Sfio_t* sfstderr; + +#if _UWIN +#undef extern +#endif + +extern Sfio_t _Sfstdin; +extern Sfio_t _Sfstdout; +extern Sfio_t _Sfstderr; + +#undef extern + +#if _BLD_sfio && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Sfio_t* sfnew _ARG_((Sfio_t*, Void_t*, size_t, int, int)); +extern Sfio_t* sfopen _ARG_((Sfio_t*, const char*, const char*)); +extern Sfio_t* sfpopen _ARG_((Sfio_t*, const char*, const char*)); +extern Sfio_t* sfstack _ARG_((Sfio_t*, Sfio_t*)); +extern Sfio_t* sfswap _ARG_((Sfio_t*, Sfio_t*)); +extern Sfio_t* sftmp _ARG_((size_t)); +extern int sfwalk _ARG_((Sfwalk_f, Void_t*, int)); +extern int sfpurge _ARG_((Sfio_t*)); +extern int sfpoll _ARG_((Sfio_t**, int, int)); +extern Void_t* sfreserve _ARG_((Sfio_t*, ssize_t, int)); +extern int sfresize _ARG_((Sfio_t*, Sfoff_t)); +extern int sfsync _ARG_((Sfio_t*)); +extern int sfclrlock _ARG_((Sfio_t*)); +extern Void_t* sfsetbuf _ARG_((Sfio_t*, Void_t*, size_t)); +extern Sfdisc_t* sfdisc _ARG_((Sfio_t*,Sfdisc_t*)); +extern int sfraise _ARG_((Sfio_t*, int, Void_t*)); +extern int sfnotify _ARG_((void(*)(Sfio_t*, int, void*))); +extern int sfset _ARG_((Sfio_t*, int, int)); +extern int sfsetfd _ARG_((Sfio_t*, int)); +extern Sfio_t* sfpool _ARG_((Sfio_t*, Sfio_t*, int)); +extern ssize_t sfread _ARG_((Sfio_t*, Void_t*, size_t)); +extern ssize_t sfwrite _ARG_((Sfio_t*, const Void_t*, size_t)); +extern Sfoff_t sfmove _ARG_((Sfio_t*, Sfio_t*, Sfoff_t, int)); +extern int sfclose _ARG_((Sfio_t*)); +extern Sfoff_t sftell _ARG_((Sfio_t*)); +extern Sfoff_t sfseek _ARG_((Sfio_t*, Sfoff_t, int)); +extern ssize_t sfputr _ARG_((Sfio_t*, const char*, int)); +extern char* sfgetr _ARG_((Sfio_t*, int, int)); +extern ssize_t sfnputc _ARG_((Sfio_t*, int, size_t)); +extern int sfungetc _ARG_((Sfio_t*, int)); +extern int sfprintf _ARG_((Sfio_t*, const char*, ...)); +extern char* sfprints _ARG_((const char*, ...)); +extern ssize_t sfaprints _ARG_((char**, const char*, ...)); +extern ssize_t sfsprintf _ARG_((char*, size_t, const char*, ...)); +extern ssize_t sfvsprintf _ARG_((char*, size_t, const char*, va_list)); +extern ssize_t sfvasprints _ARG_((char**, const char*, va_list)); +extern int sfvprintf _ARG_((Sfio_t*, const char*, va_list)); +extern int sfscanf _ARG_((Sfio_t*, const char*, ...)); +extern int sfsscanf _ARG_((const char*, const char*, ...)); +extern int sfvsscanf _ARG_((const char*, const char*, va_list)); +extern int sfvscanf _ARG_((Sfio_t*, const char*, va_list)); + +/* mutex locking for thread-safety */ +extern int sfmutex _ARG_((Sfio_t*, int)); + +/* io functions with discipline continuation */ +extern ssize_t sfrd _ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*)); +extern ssize_t sfwr _ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*)); +extern Sfoff_t sfsk _ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*)); +extern ssize_t sfpkrd _ARG_((int, Void_t*, size_t, int, long, int)); + +/* portable handling of primitive types */ +extern int sfdlen _ARG_((Sfdouble_t)); +extern int sfllen _ARG_((Sflong_t)); +extern int sfulen _ARG_((Sfulong_t)); + +extern int sfputd _ARG_((Sfio_t*, Sfdouble_t)); +extern int sfputl _ARG_((Sfio_t*, Sflong_t)); +extern int sfputu _ARG_((Sfio_t*, Sfulong_t)); +extern int sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t)); +extern int sfputc _ARG_((Sfio_t*, int)); + +extern Sfdouble_t sfgetd _ARG_((Sfio_t*)); +extern Sflong_t sfgetl _ARG_((Sfio_t*)); +extern Sfulong_t sfgetu _ARG_((Sfio_t*)); +extern Sfulong_t sfgetm _ARG_((Sfio_t*, Sfulong_t)); +extern int sfgetc _ARG_((Sfio_t*)); + +extern int _sfputd _ARG_((Sfio_t*, Sfdouble_t)); +extern int _sfputl _ARG_((Sfio_t*, Sflong_t)); +extern int _sfputu _ARG_((Sfio_t*, Sfulong_t)); +extern int _sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t)); +extern int _sfflsbuf _ARG_((Sfio_t*, int)); + +extern int _sffilbuf _ARG_((Sfio_t*, int)); + +extern int _sfdlen _ARG_((Sfdouble_t)); +extern int _sfllen _ARG_((Sflong_t)); +extern int _sfulen _ARG_((Sfulong_t)); + +/* miscellaneous function analogues of fast in-line functions */ +extern Sfoff_t sfsize _ARG_((Sfio_t*)); +extern int sfclrerr _ARG_((Sfio_t*)); +extern int sfeof _ARG_((Sfio_t*)); +extern int sferror _ARG_((Sfio_t*)); +extern int sffileno _ARG_((Sfio_t*)); +extern int sfstacked _ARG_((Sfio_t*)); +extern ssize_t sfvalue _ARG_((Sfio_t*)); +extern ssize_t sfslen _ARG_((void)); +extern ssize_t sfmaxr _ARG_((ssize_t, int)); + +#undef extern +_END_EXTERNS_ + +/* coding long integers in a portable and compact fashion */ +#define SF_SBITS 6 +#define SF_UBITS 7 +#define SF_BBITS 8 +#define SF_SIGN (1 << SF_SBITS) +#define SF_MORE (1 << SF_UBITS) +#define SF_BYTE (1 << SF_BBITS) +#define SF_U1 SF_MORE +#define SF_U2 (SF_U1*SF_U1) +#define SF_U3 (SF_U2*SF_U1) +#define SF_U4 (SF_U3*SF_U1) + +#if __cplusplus +#define _SF_(f) (f) +#else +#define _SF_(f) ((Sfio_t*)(f)) +#endif + +#define __sf_putd(f,v) (_sfputd(_SF_(f),(Sfdouble_t)(v))) +#define __sf_putl(f,v) (_sfputl(_SF_(f),(Sflong_t)(v))) +#define __sf_putu(f,v) (_sfputu(_SF_(f),(Sfulong_t)(v))) +#define __sf_putm(f,v,m) (_sfputm(_SF_(f),(Sfulong_t)(v),(Sfulong_t)(m))) + +#define __sf_putc(f,c) (_SF_(f)->_next >= _SF_(f)->_endw ? \ + _sfflsbuf(_SF_(f),(int)((unsigned char)(c))) : \ + (int)(*_SF_(f)->_next++ = (unsigned char)(c)) ) +#define __sf_getc(f) (_SF_(f)->_next >= _SF_(f)->_endr ? _sffilbuf(_SF_(f),0) : \ + (int)(*_SF_(f)->_next++) ) + +#define __sf_dlen(v) (_sfdlen((Sfdouble_t)(v)) ) +#define __sf_llen(v) (_sfllen((Sflong_t)(v)) ) +#define __sf_ulen(v) ((Sfulong_t)(v) < SF_U1 ? 1 : (Sfulong_t)(v) < SF_U2 ? 2 : \ + (Sfulong_t)(v) < SF_U3 ? 3 : (Sfulong_t)(v) < SF_U4 ? 4 : 5) + +#define __sf_fileno(f) (_SF_(f)->_file) +#define __sf_eof(f) (_SF_(f)->_flags&SF_EOF) +#define __sf_error(f) (_SF_(f)->_flags&SF_ERROR) +#define __sf_clrerr(f) (_SF_(f)->_flags &= ~(SF_ERROR|SF_EOF)) +#define __sf_stacked(f) (_SF_(f)->_push != (Sfio_t*)0) +#define __sf_value(f) (_SF_(f)->_val) +#define __sf_slen() (_Sfi) +#define __sf_maxr(n,s) ((s)?((_Sfi=_Sfmaxr),(_Sfmaxr=(n)),_Sfi):_Sfmaxr) + +#if defined(__INLINE__) && !_BLD_sfio + +__INLINE__ int sfputd(Sfio_t* f, Sfdouble_t v) { return __sf_putd(f,v); } +__INLINE__ int sfputl(Sfio_t* f, Sflong_t v) { return __sf_putl(f,v); } +__INLINE__ int sfputu(Sfio_t* f, Sfulong_t v) { return __sf_putu(f,v); } +__INLINE__ int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t m) + { return __sf_putm(f,v,m); } + +__INLINE__ int sfputc(Sfio_t* f, int c) { return __sf_putc(f,c); } +__INLINE__ int sfgetc(Sfio_t* f) { return __sf_getc(f); } + +__INLINE__ int sfdlen(Sfdouble_t v) { return __sf_dlen(v); } +__INLINE__ int sfllen(Sflong_t v) { return __sf_llen(v); } +__INLINE__ int sfulen(Sfulong_t v) { return __sf_ulen(v); } + +__INLINE__ int sffileno(Sfio_t* f) { return __sf_fileno(f); } +__INLINE__ int sfeof(Sfio_t* f) { return __sf_eof(f); } +__INLINE__ int sferror(Sfio_t* f) { return __sf_error(f); } +__INLINE__ int sfclrerr(Sfio_t* f) { return __sf_clrerr(f); } +__INLINE__ int sfstacked(Sfio_t* f) { return __sf_stacked(f); } +__INLINE__ ssize_t sfvalue(Sfio_t* f) { return __sf_value(f); } +__INLINE__ ssize_t sfslen() { return __sf_slen(); } +__INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); } + +#else + +#define sfputd(f,v) ( __sf_putd((f),(v)) ) +#define sfputl(f,v) ( __sf_putl((f),(v)) ) +#define sfputu(f,v) ( __sf_putu((f),(v)) ) +#define sfputm(f,v,m) ( __sf_putm((f),(v),(m)) ) + +#define sfputc(f,c) ( __sf_putc((f),(c)) ) +#define sfgetc(f) ( __sf_getc(f) ) + +#define sfdlen(v) ( __sf_dlen(v) ) +#define sfllen(v) ( __sf_llen(v) ) +#define sfulen(v) ( __sf_ulen(v) ) + +#define sffileno(f) ( __sf_fileno(f) ) +#define sfeof(f) ( __sf_eof(f) ) +#define sferror(f) ( __sf_error(f) ) +#define sfclrerr(f) ( __sf_clrerr(f) ) +#define sfstacked(f) ( __sf_stacked(f) ) +#define sfvalue(f) ( __sf_value(f) ) +#define sfslen() ( __sf_slen() ) +#define sfmaxr(n,s) ( __sf_maxr(n,s) ) + +#endif /*__INLINE__*/ + +#ifndef _SFSTR_H /* GSF's string manipulation stuff */ +#define _SFSTR_H 1 + +#define sfstropen() sfnew(0, 0, -1, -1, SF_READ|SF_WRITE|SF_STRING) +#define sfstrclose(f) sfclose(f) + +#define sfstrseek(f,p,m) \ + ( (m) == SEEK_SET ? \ + (((p) < 0 || (p) > (f)->_size) ? (char*)0 : \ + (char*)((f)->_next = (f)->_data+(p)) ) \ + : (m) == SEEK_CUR ? \ + ((f)->_next += (p), \ + (((f)->_next < (f)->_data || (f)->_next > (f)->_data+(f)->_size) ? \ + ((f)->_next -= (p), (char*)0) : (char*)(f)->_next ) ) \ + : (m) == SEEK_END ? \ + ( ((p) > 0 || (f)->_size < -(p)) ? (char*)0 : \ + (char*)((f)->_next = (f)->_data+(f)->_size+(p)) ) \ + : (char*)0 \ + ) + +#define sfstrsize(f) ((f)->_size) +#define sfstrtell(f) ((f)->_next - (f)->_data) +#define sfstrpend(f) ((f)->_size - sfstrtell()) +#define sfstrbase(f) ((char*)(f)->_data) + +#define sfstruse(f) \ + (sfputc((f),0) < 0 ? (char*)0 : (char*)((f)->_next = (f)->_data) \ + ) + +#define sfstrrsrv(f,n) \ + (sfreserve((f),(n),SF_WRITE|SF_LOCKR), sfwrite((f),(f)->_next,0), \ + ((f)->_next+(n) <= (f)->_data+(f)->_size ? (char*)(f)->_next : (char*)0) \ + ) + +#define sfstrbuf(f,b,n,m) \ + (sfsetbuf((f),(b),(n)), ((f)->_flags |= (m) ? SF_MALLOC : 0), \ + ((f)->_data == (unsigned char*)(b) ? 0 : -1) \ + ) + +#endif /* _SFSTR_H */ + +#endif /* _SFIO_H */ diff --git a/illumos-x86_64/usr/include/ast/sfio_s.h b/illumos-x86_64/usr/include/ast/sfio_s.h new file mode 100644 index 00000000..021c711c --- /dev/null +++ b/illumos-x86_64/usr/include/ast/sfio_s.h @@ -0,0 +1,57 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#ifndef _SFIO_S_H +#define _SFIO_S_H 1 + +/* + * sfio file structure used by sfio and the stdio source compatibility library + */ + +#if !defined(_SFHDR_H) && defined(_SFIO_H) && SFIO_VERSION < 20020214L +#define _data data +#define _endb endb +#define _next next +#endif + +struct _sfio_s +{ unsigned char* _next; /* next position to read/write from */ + unsigned char* _endw; /* end of write buffer */ + unsigned char* _endr; /* end of read buffer */ + unsigned char* _endb; /* end of buffer */ + struct _sfio_s* _push; /* the stream that was pushed on */ + unsigned short _flags; /* type of stream */ + short _file; /* file descriptor */ + unsigned char* _data; /* base of data buffer */ + ssize_t _size; /* buffer size */ + ssize_t _val; /* values or string lengths */ +#ifdef _SFIO_PRIVATE + _SFIO_PRIVATE +#endif +}; + +#endif diff --git a/illumos-x86_64/usr/include/ast/sfio_t.h b/illumos-x86_64/usr/include/ast/sfio_t.h new file mode 100644 index 00000000..b8d11b16 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/sfio_t.h @@ -0,0 +1,139 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#ifndef _SFIO_T_H +#define _SFIO_T_H 1 + +/* This header file is for library writers who need to know certain +** internal info concerning the full Sfio_t structure. Including this +** file means that you agree to track closely with sfio development +** in case its internal architecture is changed. +** +** Written by Kiem-Phong Vo +*/ + +/* the parts of Sfio_t private to sfio functions */ +#define _SFIO_PRIVATE \ + Sfoff_t extent; /* current file size */ \ + Sfoff_t here; /* current physical location */ \ + unsigned char unused_1;/* unused #1 */ \ + unsigned char tiny[1];/* for unbuffered read stream */ \ + unsigned short bits; /* private flags */ \ + unsigned int mode; /* current io mode */ \ + struct _sfdisc_s* disc; /* discipline */ \ + struct _sfpool_s* pool; /* the pool containing this */ \ + struct _sfrsrv_s* rsrv; /* reserved buffer */ \ + struct _sfproc_s* proc; /* coprocess id, etc. */ \ + Void_t* mutex; /* mutex for thread-safety */ \ + Void_t* stdio; /* stdio FILE if any */ \ + Sfoff_t lpos; /* last seek position */ \ + size_t iosz; /* preferred size for I/O */ \ + size_t blksz; /* preferred block size */ \ + int getr; /* the last sfgetr separator */ \ + _SFIO_PRIVATE_PAD + +#if _ast_sizeof_pointer == 8 +#define _SFIO_PRIVATE_PAD int pad; +#else +#define _SFIO_PRIVATE_PAD +#endif + +#include "sfio.h" + +/* mode bit to indicate that the structure hasn't been initialized */ +#define SF_INIT 0000004 +#define SF_DCDOWN 00010000 + +/* short-hand for common stream types */ +#define SF_RDWR (SF_READ|SF_WRITE) +#define SF_RDSTR (SF_READ|SF_STRING) +#define SF_WRSTR (SF_WRITE|SF_STRING) +#define SF_RDWRSTR (SF_RDWR|SF_STRING) + +/* for static initialization of an Sfio_t structure */ +#define SFNEW(data,size,file,type,disc,mutex) \ + { (unsigned char*)(data), /* next */ \ + (unsigned char*)(data), /* endw */ \ + (unsigned char*)(data), /* endr */ \ + (unsigned char*)(data), /* endb */ \ + (Sfio_t*)0, /* push */ \ + (unsigned short)((type)&SF_FLAGS), /* flags */ \ + (short)(file), /* file */ \ + (unsigned char*)(data), /* data */ \ + (ssize_t)(size), /* size */ \ + (ssize_t)(-1), /* val */ \ + (Sfoff_t)0, /* extent */ \ + (Sfoff_t)0, /* here */ \ + 0, /* getr */ \ + {0}, /* tiny */ \ + 0, /* bits */ \ + (unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \ + (struct _sfdisc_s*)(disc), /* disc */ \ + (struct _sfpool_s*)0, /* pool */ \ + (struct _sfrsrv_s*)0, /* rsrv */ \ + (struct _sfproc_s*)0, /* proc */ \ + (mutex), /* mutex */ \ + (Void_t*)0, /* stdio */ \ + (Sfoff_t)0, /* lpos */ \ + (size_t)0 /* iosz */ \ + } + +/* function to clear an Sfio_t structure */ +#define SFCLEAR(f,mtx) \ + ( (f)->next = (unsigned char*)0, /* next */ \ + (f)->endw = (unsigned char*)0, /* endw */ \ + (f)->endr = (unsigned char*)0, /* endr */ \ + (f)->endb = (unsigned char*)0, /* endb */ \ + (f)->push = (Sfio_t*)0, /* push */ \ + (f)->flags = (unsigned short)0, /* flags */ \ + (f)->file = -1, /* file */ \ + (f)->data = (unsigned char*)0, /* data */ \ + (f)->size = (ssize_t)(-1), /* size */ \ + (f)->val = (ssize_t)(-1), /* val */ \ + (f)->extent = (Sfoff_t)(-1), /* extent */ \ + (f)->here = (Sfoff_t)0, /* here */ \ + (f)->getr = 0, /* getr */ \ + (f)->tiny[0] = 0, /* tiny */ \ + (f)->bits = 0, /* bits */ \ + (f)->mode = 0, /* mode */ \ + (f)->disc = (struct _sfdisc_s*)0, /* disc */ \ + (f)->pool = (struct _sfpool_s*)0, /* pool */ \ + (f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \ + (f)->proc = (struct _sfproc_s*)0, /* proc */ \ + (f)->mutex = (mtx), /* mutex */ \ + (f)->stdio = (Void_t*)0, /* stdio */ \ + (f)->lpos = (Sfoff_t)0, /* lpos */ \ + (f)->iosz = (size_t)0 /* iosz */ \ + ) + +/* expose next stream inside discipline function; state saved in int f */ +#define SFDCNEXT(sp,f) (((f)=(sp)->bits&SF_DCDOWN),(sp)->bits|=SF_DCDOWN) + +/* restore SFDCNEXT() state from int f */ +#define SFDCPREV(sp,f) ((f)?(0):((sp)->bits&=~SF_DCDOWN)) + +#endif /* _SFIO_T_H */ diff --git a/illumos-x86_64/usr/include/ast/shcmd.h b/illumos-x86_64/usr/include/ast/shcmd.h new file mode 100644 index 00000000..04320bcb --- /dev/null +++ b/illumos-x86_64/usr/include/ast/shcmd.h @@ -0,0 +1,118 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped + +/* + * ksh builtin command api + */ + +#ifndef _SHCMD_H +#define _SHCMD_H 1 + +#ifndef AST_PLUGIN_VERSION +#define AST_PLUGIN_VERSION(v) (v) +#endif +#define SH_PLUGIN_VERSION AST_PLUGIN_VERSION(20111111L) + +#if __STDC__ +#define SHLIB(m) unsigned long plugin_version(void) { return SH_PLUGIN_VERSION; } +#else +#define SHLIB(m) unsigned long plugin_version() { return SH_PLUGIN_VERSION; } +#endif + +#ifndef SH_VERSION +# define Shell_t void +#endif +#ifndef NV_DEFAULT +# define Namval_t void +#endif + +#undef Shbltin_t +struct Shbltin_s; +typedef struct Shbltin_s Shbltin_t; + +#ifdef _SHTABLE_H /* pre-ksh93u+ -- obsolete */ +typedef int (*Shbltin_f)(int, char**, void*); +#else +typedef int (*Shbltin_f)(int, char**, Shbltin_t*); +#endif /* _SHTABLE_H */ + +struct Shbltin_s +{ + Shell_t* shp; + void* ptr; + int version; + int (*shrun)(int, char**); + int (*shtrap)(const char*, int); + void (*shexit)(int); + Namval_t* (*shbltin)(const char*, Shbltin_f, void*); + unsigned char notify; + unsigned char sigset; + unsigned char nosfio; + Namval_t* bnode; + Namval_t* vnode; + char* data; + int flags; + char* (*shgetenv)(const char*); + char* (*shsetenv)(const char*); + int invariant; +}; + +#if defined(SH_VERSION) || defined(_SH_PRIVATE) +# undef Shell_t +# undef Namval_t +#else +# define sh_context(c) ((Shbltin_t*)(c)) +# define sh_run(c, ac, av) ((c)?(*sh_context(c)->shrun)(ac,av):-1) +# define sh_system(c,str) ((c)?(*sh_context(c)->shtrap)(str,0):system(str)) +# define sh_exit(c,n) ((c)?(*sh_context(c)->shexit)(n):exit(n)) +# define sh_checksig(c) ((c) && sh_context(c)->sigset) +# define sh_builtin(c,n,f,p) ((c)?(*sh_context(c)->shbltin)(n,(Shbltin_f)(f),sh_context(p)):0) +# if defined(SFIO_VERSION) || defined(_AST_H) +# define LIB_INIT(c) +# else +# define LIB_INIT(c) ((c) && (sh_context(c)->nosfio = 1)) +# endif +# ifndef _CMD_H +# ifndef ERROR_NOTIFY +# define ERROR_NOTIFY 1 +# endif +# define cmdinit(ac,av,c,cat,flg) do { if((ac)<=0) return(0); \ + (sh_context(c)->notify = ((flg)&ERROR_NOTIFY)?1:0);} while(0) +# endif +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int astintercept(Shbltin_t*, int); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/shell.h b/illumos-x86_64/usr/include/ast/shell.h new file mode 100644 index 00000000..4b5d5acf --- /dev/null +++ b/illumos-x86_64/usr/include/ast/shell.h @@ -0,0 +1,265 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1982-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* David Korn * +* * +***********************************************************************/ +#pragma prototyped +#ifndef SH_INTERACTIVE +/* + * David Korn + * AT&T Labs + * + * Interface definitions for shell command language + * + */ + +#define SH_VERSION 20071012 + +#include +#include +#ifdef _SH_PRIVATE +# include "name.h" +#else +# include +#endif /* _SH_PRIVATE */ + +#undef NOT_USED +#define NOT_USED(x) (&x,1) + +/* options */ +typedef struct +{ + unsigned long v[4]; +} +Shopt_t; + +typedef struct Shell_s Shell_t; + +#include + +typedef void (*Shinit_f)(Shell_t*, int); +#ifndef SH_wait_f_defined + typedef int (*Shwait_f)(int, long, int); +# define SH_wait_f_defined +#endif + +union Shnode_u; +typedef union Shnode_u Shnode_t; + +#define SH_CFLAG 0 +#define SH_HISTORY 1 /* used also as a state */ +#define SH_ERREXIT 2 /* used also as a state */ +#define SH_VERBOSE 3 /* used also as a state */ +#define SH_MONITOR 4 /* used also as a state */ +#define SH_INTERACTIVE 5 /* used also as a state */ +#define SH_RESTRICTED 6 +#define SH_XTRACE 7 +#define SH_KEYWORD 8 +#define SH_NOUNSET 9 +#define SH_NOGLOB 10 +#define SH_ALLEXPORT 11 +#define SH_PFSH 12 +#define SH_IGNOREEOF 13 +#define SH_NOCLOBBER 14 +#define SH_MARKDIRS 15 +#define SH_BGNICE 16 +#define SH_VI 17 +#define SH_VIRAW 18 +#define SH_TFLAG 19 +#define SH_TRACKALL 20 +#define SH_SFLAG 21 +#define SH_NOEXEC 22 +#define SH_GMACS 24 +#define SH_EMACS 25 +#define SH_PRIVILEGED 26 +#define SH_SUBSHARE 27 /* subshell shares state with parent */ +#define SH_NOLOG 28 +#define SH_NOTIFY 29 +#define SH_DICTIONARY 30 +#define SH_PIPEFAIL 32 +#define SH_GLOBSTARS 33 +#define SH_XARGS 34 +#define SH_RC 35 +#define SH_SHOWME 36 +#define SH_LETOCTAL 37 + +/* + * passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on + */ +#define SH_BEGIN_OPTIM 0x1 +#define SH_END_OPTIM 0x2 + +/* The following type is used for error messages */ + +/* error messages */ +extern const char e_defpath[]; +extern const char e_found[]; +extern const char e_nospace[]; +extern const char e_format[]; +extern const char e_number[]; +extern const char e_restricted[]; +extern const char e_recursive[]; +extern char e_version[]; + +typedef struct sh_scope +{ + struct sh_scope *par_scope; + int argc; + char **argv; + char *cmdname; + char *filename; + char *funname; + int lineno; + Dt_t *var_tree; + struct sh_scope *self; +} Shscope_t; + +/* + * Saves the state of the shell + */ + +struct Shell_s +{ + Shopt_t options; /* set -o options */ + Dt_t *var_tree; /* for shell variables */ + Dt_t *fun_tree; /* for shell functions */ + Dt_t *alias_tree; /* for alias names */ + Dt_t *bltin_tree; /* for builtin commands */ + Shscope_t *topscope; /* pointer to top-level scope */ + int inlineno; /* line number of current input file */ + int exitval; /* most recent exit value */ + unsigned char trapnote; /* set when trap/signal is pending */ + char shcomp; /* set when runing shcomp */ + short subshell; /* set for virtual subshell */ +#ifdef _SH_PRIVATE + _SH_PRIVATE +#endif /* _SH_PRIVATE */ +}; + +/* flags for sh_parse */ +#define SH_NL 1 /* Treat new-lines as ; */ +#define SH_EOF 2 /* EOF causes syntax error */ + +/* symbolic values for sh_iogetiop */ +#define SH_IOCOPROCESS (-2) +#define SH_IOHISTFILE (-3) + +#include + +/* symbolic value for sh_fdnotify */ +#define SH_FDCLOSE (-1) + +#undef getenv /* -lshell provides its own */ + +#if defined(__EXPORT__) && defined(_DLL) +# ifdef _BLD_shell +# define extern __EXPORT__ +# endif /* _BLD_shell */ +#endif /* _DLL */ + +extern Dt_t *sh_bltin_tree(void); +extern void sh_subfork(void); +extern Shell_t *sh_init(int,char*[],Shinit_f); +extern int sh_reinit(char*[]); +extern int sh_eval(Sfio_t*,int); +extern void sh_delay(double); +extern void *sh_parse(Shell_t*, Sfio_t*,int); +extern int sh_trap(const char*,int); +extern int sh_fun(Namval_t*,Namval_t*, char*[]); +extern int sh_funscope(int,char*[],int(*)(void*),void*,int); +extern Sfio_t *sh_iogetiop(int,int); +extern int sh_main(int, char*[], Shinit_f); +extern int sh_run(int, char*[]); +extern void sh_menu(Sfio_t*, int, char*[]); +extern Namval_t *sh_addbuiltin(const char*, int(*)(int, char*[],Shbltin_t*), void*); +extern char *sh_fmtq(const char*); +extern char *sh_fmtqf(const char*, int, int); +extern Sfdouble_t sh_strnum(const char*, char**, int); +extern int sh_access(const char*,int); +extern int sh_close(int); +extern int sh_chdir(const char*); +extern int sh_dup(int); +extern void sh_exit(int); +extern int sh_fchdir(int); +extern int sh_fcntl(int, int, ...); +extern Sfio_t *sh_fd2sfio(int); +extern int (*sh_fdnotify(int(*)(int,int)))(int,int); +extern Shell_t *sh_getinterp(void); +extern int sh_open(const char*, int, ...); +extern int sh_openmax(void); +extern Sfio_t *sh_pathopen(const char*); +extern ssize_t sh_read(int, void*, size_t); +extern ssize_t sh_write(int, const void*, size_t); +extern off_t sh_seek(int, off_t, int); +extern int sh_pipe(int[]); +extern mode_t sh_umask(mode_t); +extern void *sh_waitnotify(Shwait_f); +extern Shscope_t *sh_getscope(int,int); +extern Shscope_t *sh_setscope(Shscope_t*); +extern void sh_sigcheck(Shell_t*); +extern unsigned long sh_isoption(int); +extern unsigned long sh_onoption(int); +extern unsigned long sh_offoption(int); +extern int sh_waitsafe(void); +extern int sh_exec(const Shnode_t*,int); + +/* + * direct access to sh is obsolete, use sh_getinterp() instead + */ +#if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell) + extern __IMPORT__ Shell_t sh; +#else + extern Shell_t sh; +#endif + +#ifdef _DLL +# undef extern +#endif /* _DLL */ + +#define chdir(a) sh_chdir(a) +#define fchdir(a) sh_fchdir(a) +#ifndef _SH_PRIVATE +# define access(a,b) sh_access(a,b) +# define close(a) sh_close(a) +# define exit(a) sh_exit(a) +# define fcntl(a,b,c) sh_fcntl(a,b,c) +# define pipe(a) sh_pipe(a) +# define read(a,b,c) sh_read(a,b,c) +# define write(a,b,c) sh_write(a,b,c) +# define umask(a) sh_umask(a) +# define dup sh_dup +# if _lib_lseek64 +# define open64 sh_open +# define lseek64 sh_seek +# else +# define open sh_open +# define lseek sh_seek +# endif +#endif /* !_SH_PRIVATE */ + +#define SH_SIGSET 4 +#define SH_EXITSIG 0400 /* signal exit bit */ +#define SH_EXITMASK (SH_EXITSIG-1) /* normal exit status bits */ +#define SH_RUNPROG -1022 /* needs to be negative and < 256 */ + +#endif /* SH_INTERACTIVE */ diff --git a/illumos-x86_64/usr/include/ast/sig.h b/illumos-x86_64/usr/include/ast/sig.h new file mode 100644 index 00000000..50a2aecf --- /dev/null +++ b/illumos-x86_64/usr/include/ast/sig.h @@ -0,0 +1,163 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/sig.sh by iffe version 2012-07-17 : : */ +#ifndef _def_sig_ast +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _def_sig_ast 1 +#define _sys_types 1 /* #include ok */ + +#define sig_info _sig_info_ + +#if defined(__STDPP__directive) && defined(__STDPP__hide) +__STDPP__directive pragma pp:hide kill killpg +#else +#define kill ______kill +#define killpg ______killpg +#endif +#include +#if defined(__STDPP__directive) && defined(__STDPP__hide) +__STDPP__directive pragma pp:nohide kill killpg +#else +#undef kill +#undef killpg +#endif +#ifndef sigmask +#define sigmask(s) (1<<((s)-1)) +#endif +typedef void (*Sig_handler_t) __PROTO__((int)); + + +#define Handler_t Sig_handler_t + +#define SIG_REG_PENDING (-1) +#define SIG_REG_POP 0 +#define SIG_REG_EXEC 00001 +#define SIG_REG_PROC 00002 +#define SIG_REG_TERM 00004 +#define SIG_REG_ALL 00777 +#define SIG_REG_SET 01000 + +typedef struct +{ + char** name; + char** text; + int sigmax; +} Sig_info_t; + +extern __MANGLE__ int kill __PROTO__((pid_t, int)); +extern __MANGLE__ int killpg __PROTO__((pid_t, int)); + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __IMPORT__ +#endif + +extern __MANGLE__ Sig_info_t sig_info; + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#if _lib_sigflag && _npt_sigflag +extern __MANGLE__ int sigflag __PROTO__((int, int, int)); +#endif + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +#if !_lib_sigflag +extern __MANGLE__ int sigflag __PROTO__((int, int, int)); +#endif +extern __MANGLE__ int sigcritical __PROTO__((int)); +extern __MANGLE__ int sigunblock __PROTO__((int)); + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ +#endif diff --git a/illumos-x86_64/usr/include/ast/stack.h b/illumos-x86_64/usr/include/ast/stack.h new file mode 100644 index 00000000..c134db76 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/stack.h @@ -0,0 +1,89 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * homogenous stack routine definitions + */ + +#ifndef _STACK_H +#define _STACK_H + +typedef struct stacktable* STACK; /* stack pointer */ +typedef struct stackposition STACKPOS; /* stack position */ + +struct stackblock /* stack block cell */ +{ + void** stack; /* actual stack */ + struct stackblock* prev; /* previous block in list */ + struct stackblock* next; /* next block in list */ +}; + +struct stackposition /* stack position */ +{ + struct stackblock* block; /* current block pointer */ + int index; /* index within current block */ +}; + +struct stacktable /* stack information */ +{ + struct stackblock* blocks; /* stack table blocks */ + void* error; /* error return value */ + int size; /* size of each block */ + STACKPOS position; /* current stack position */ +}; + +/* + * map old names to new + */ + +#define mkstack stackalloc +#define rmstack stackfree +#define clrstack stackclear +#define getstack stackget +#define pushstack stackpush +#define popstack stackpop +#define posstack stacktell + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern STACK stackalloc(int, void*); +extern void stackfree(STACK); +extern void stackclear(STACK); +extern void* stackget(STACK); +extern int stackpush(STACK, void*); +extern int stackpop(STACK); +extern void stacktell(STACK, int, STACKPOS*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/stak.h b/illumos-x86_64/usr/include/ast/stak.h new file mode 100644 index 00000000..fdd99b2d --- /dev/null +++ b/illumos-x86_64/usr/include/ast/stak.h @@ -0,0 +1,61 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * David Korn + * AT&T Research + * + * Interface definitions for a stack-like storage library + * + */ + +#ifndef _STAK_H +#define _STAK_H + +#include + +#define Stak_t Sfio_t +#define staksp stkstd +#define STAK_SMALL STK_SMALL + +#define stakptr(n) stkptr(stkstd,n) +#define staktell() stktell(stkstd) +#define stakputc(c) sfputc(stkstd,(c)) +#define stakwrite(b,n) sfwrite(stkstd,(b),(n)) +#define stakputs(s) (sfputr(stkstd,(s),0),--stkstd->_next) +#define stakseek(n) stkseek(stkstd,n) +#define stakcreate(n) stkopen(n) +#define stakinstall(s,f) stkinstall(s,f) +#define stakdelete(s) stkclose(s) +#define staklink(s) stklink(s) +#define stakalloc(n) stkalloc(stkstd,n) +#define stakcopy(s) stkcopy(stkstd,s) +#define stakset(c,n) stkset(stkstd,c,n) +#define stakfreeze(n) stkfreeze(stkstd,n) + +#endif diff --git a/illumos-x86_64/usr/include/ast/stdio.h b/illumos-x86_64/usr/include/ast/stdio.h new file mode 100644 index 00000000..72f31737 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/stdio.h @@ -0,0 +1,28 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#include diff --git a/illumos-x86_64/usr/include/ast/stk.h b/illumos-x86_64/usr/include/ast/stk.h new file mode 100644 index 00000000..9de70dbd --- /dev/null +++ b/illumos-x86_64/usr/include/ast/stk.h @@ -0,0 +1,84 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * David Korn + * AT&T Research + * + * Interface definitions for a stack-like storage library + * + */ + +#ifndef _STK_H +#define _STK_H + +#include + +#define _Stk_data _Stak_data + +#define stkstd (&_Stk_data) + +#define Stk_t Sfio_t + +#define STK_SMALL 1 /* small stkopen stack */ +#define STK_NULL 2 /* return NULL on overflow */ + +#define stkptr(sp,n) ((char*)((sp)->_data)+(n)) +#define stktop(sp) ((char*)(sp)->_next) +#define stktell(sp) ((sp)->_next-(sp)->_data) +#define stkseek(sp,n) ((n)==0?(char*)((sp)->_next=(sp)->_data):_stkseek(sp,n)) + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Sfio_t _Stk_data; + +#undef extern + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Stk_t* stkopen(int); +extern Stk_t* stkinstall(Stk_t*, char*(*)(int)); +extern int stkclose(Stk_t*); +extern int stklink(Stk_t*); +extern char* stkalloc(Stk_t*, size_t); +extern char* stkcopy(Stk_t*, const char*); +extern char* stkset(Stk_t*, char*, size_t); +extern char* _stkseek(Stk_t*, ssize_t); +extern char* stkfreeze(Stk_t*, size_t); +extern int stkon(Stk_t*, char*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/sum.h b/illumos-x86_64/usr/include/ast/sum.h new file mode 100644 index 00000000..bd544215 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/sum.h @@ -0,0 +1,71 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1996-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* * +***********************************************************************/ +#pragma prototyped + +/* + * Glenn Fowler + * AT&T Research + * + * checksum library interface + */ + +#ifndef _SUM_H +#define _SUM_H + +#include + +#define SUM_SIZE (1<<0) /* print size too */ +#define SUM_SCALE (1<<1) /* traditional size scale */ +#define SUM_TOTAL (1<<2) /* print totals since sumopen */ +#define SUM_LEGACY (1<<3) /* legacy field widths */ + +#define _SUM_PUBLIC_ const char* name; + +typedef struct Sumdata_s +{ + uint32_t size; + uint32_t num; + void* buf; +} Sumdata_t; + +typedef struct Sum_s +{ + _SUM_PUBLIC_ +#ifdef _SUM_PRIVATE_ + _SUM_PRIVATE_ +#endif +} Sum_t; + +extern Sum_t* sumopen(const char*); +extern int suminit(Sum_t*); +extern int sumblock(Sum_t*, const void*, size_t); +extern int sumdone(Sum_t*); +extern int sumdata(Sum_t*, Sumdata_t*); +extern int sumprint(Sum_t*, Sfio_t*, int, size_t); +extern int sumusage(Sfio_t*); +extern int sumclose(Sum_t*); + +#endif diff --git a/illumos-x86_64/usr/include/ast/swap.h b/illumos-x86_64/usr/include/ast/swap.h new file mode 100644 index 00000000..304edfc1 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/swap.h @@ -0,0 +1,59 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * integral representation conversion support definitions + * supports sizeof(integral_type)<=sizeof(intmax_t) + */ + +#ifndef _SWAP_H +#define _SWAP_H + +#include + +#define int_swap _ast_intswap + +#define SWAP_MAX 8 + +#define SWAPOP(n) (((n)&int_swap)^(n)) + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void* swapmem(int, const void*, void*, size_t); +extern intmax_t swapget(int, const void*, int); +extern void* swapput(int, void*, int, intmax_t); +extern int swapop(const void*, const void*, int); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/tar.h b/illumos-x86_64/usr/include/ast/tar.h new file mode 100644 index 00000000..3837a9d9 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/tar.h @@ -0,0 +1,124 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Standard Archive Format + * USTAR - Uniform Standard Tape ARchive + */ + +#ifndef _TAR_H +#define _TAR_H + +#define TBLOCK 512 +#define NAMSIZ 100 +#define PFXSIZ 155 + +#define TMODLEN 8 +#define TUIDLEN 8 +#define TGIDLEN 8 +#define TSIZLEN 12 +#define TMTMLEN 12 +#define TCKSLEN 8 + +#define TMAGIC "ustar" /* ustar and a null */ +#define TMAGLEN 6 +#define TVERSION "00" /* 00 and no null */ +#define TVERSLEN 2 +#define TUNMLEN 32 +#define TGNMLEN 32 +#define TDEVLEN 8 + +/* + * values used in typeflag field + */ + +#define REGTYPE '0' /* regular file */ +#define AREGTYPE 0 /* alternate REGTYPE */ +#define LNKTYPE '1' /* hard link */ +#define SYMTYPE '2' /* soft link */ +#define CHRTYPE '3' /* character special */ +#define BLKTYPE '4' /* block special */ +#define DIRTYPE '5' /* directory */ +#define FIFOTYPE '6' /* FIFO special */ +#define CONTTYPE '7' /* reserved */ +#define SOKTYPE '8' /* socket */ +#define EXTTYPE 'x' /* extended header */ +#define GLBTYPE 'g' /* global extended header */ +#define LLNKTYPE 'K' /* long link path */ +#define LREGTYPE 'L' /* long file path */ +#define VERTYPE 'V' /* version */ + +/* + * bits used in mode field + */ + +#define TSUID 04000 /* set uid on exec */ +#define TSGID 02000 /* set gid on exec */ +#define TSVTX 01000 /* sticky bit -- reserved */ + +/* + * file permissions + */ + +#define TUREAD 00400 /* read by owner */ +#define TUWRITE 00200 /* write by owner */ +#define TUEXEC 00100 /* execute by owner */ +#define TGREAD 00040 /* read by group */ +#define TGWRITE 00020 /* execute by group */ +#define TGEXEC 00010 /* write by group */ +#define TOREAD 00004 /* read by other */ +#define TOWRITE 00002 /* write by other */ +#define TOEXEC 00001 /* execute by other */ + +struct header +{ + char name[NAMSIZ]; + char mode[TMODLEN]; + char uid[TUIDLEN]; + char gid[TGIDLEN]; + char size[TSIZLEN]; + char mtime[TMTMLEN]; + char chksum[TCKSLEN]; + char typeflag; + char linkname[NAMSIZ]; + char magic[TMAGLEN]; + char version[TVERSLEN]; + char uname[TUNMLEN]; + char gname[TGNMLEN]; + char devmajor[TDEVLEN]; + char devminor[TDEVLEN]; + char prefix[PFXSIZ]; +}; + +union hblock +{ + char dummy[TBLOCK]; + struct header dbuf; +}; + +#endif diff --git a/illumos-x86_64/usr/include/ast/times.h b/illumos-x86_64/usr/include/ast/times.h new file mode 100644 index 00000000..95e53385 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/times.h @@ -0,0 +1,60 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * -last clock_t,time_t interface definitions plus + * + * + * + * + * + */ + +#ifndef _TIMES_H +#define _TIMES_H + +#include + +#undef _TIMES_H +#include +#ifndef _TIMES_H +#define _TIMES_H +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int touch(const char*, time_t, time_t, int); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/tm.h b/illumos-x86_64/usr/include/ast/tm.h new file mode 100644 index 00000000..bfa7ac69 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/tm.h @@ -0,0 +1,198 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * time conversion support definitions + */ + +#ifndef _TM_H +#define _TM_H + +#define TM_VERSION 20070319L + +#include +#include + +#undef daylight + +#define tmset(z) tminit(z) +#define tmisleapyear(y) (!((y)%4)&&(((y)%100)||!((((y)<1900)?((y)+1900):(y))%400))) + +#define TM_ADJUST (1<<0) /* local doesn't do leap secs */ +#define TM_LEAP (1<<1) /* do leap seconds */ +#define TM_UTC (1<<2) /* universal coordinated ref */ + +#define TM_PEDANTIC (1<<3) /* pedantic date parse */ +#define TM_DATESTYLE (1<<4) /* date(1) style mmddHHMMccyy */ +#define TM_SUBSECOND (1<<5) /* %S => ...%S.%P */ + +#define TM_DST (-60) /* default minutes for DST */ +#define TM_LOCALZONE (25 * 60) /* use local time zone offset */ +#define TM_UTCZONE (26 * 60) /* UTC "time zone" */ +#define TM_MAXLEAP 1 /* max leap secs per leap */ +#define TM_WINDOW 69 /* century windowing guard year */ + +/* + * these indices must agree with tm_dform[] + */ + +#define TM_MONTH_ABBREV 0 +#define TM_MONTH 12 +#define TM_DAY_ABBREV 24 +#define TM_DAY 31 +#define TM_TIME 38 +#define TM_DATE 39 +#define TM_DEFAULT 40 +#define TM_MERIDIAN 41 + +#define TM_UT 43 +#define TM_DT 47 +#define TM_SUFFIXES 51 +#define TM_PARTS 55 +#define TM_HOURS 62 +#define TM_DAYS 66 +#define TM_LAST 69 +#define TM_THIS 72 +#define TM_NEXT 75 +#define TM_EXACT 78 +#define TM_NOISE 81 +#define TM_ORDINAL 85 +#define TM_DIGITS 95 +#define TM_CTIME 105 +#define TM_DATE_1 106 +#define TM_INTERNATIONAL 107 +#define TM_RECENT 108 +#define TM_DISTANT 109 +#define TM_MERIDIAN_TIME 110 +#define TM_ERA 111 +#define TM_ERA_DATE 112 +#define TM_ERA_TIME 113 +#define TM_ERA_DEFAULT 114 +#define TM_ERA_YEAR 115 +#define TM_ORDINALS 116 +#define TM_FINAL 126 +#define TM_WORK 129 + +#define TM_NFORM 132 + +typedef struct /* leap second info */ +{ + time_t time; /* the leap second event */ + int total; /* inclusive total since epoch */ +} Tm_leap_t; + +typedef struct /* time zone info */ +{ + char* type; /* type name */ + char* standard; /* standard time name */ + char* daylight; /* daylight or summertime name */ + short west; /* minutes west of GMT */ + short dst; /* add to tz.west for DST */ +} Tm_zone_t; + +typedef struct /* tm library readonly data */ +{ + char** format; /* default TM_* format strings */ + unsigned char* lex; /* format lex type classes */ + char* digit; /* output digits */ + short* days; /* days in month i */ + short* sum; /* days in months before i */ + Tm_leap_t* leap; /* leap second table */ + Tm_zone_t* zone; /* alternate timezone table */ +} Tm_data_t; + +typedef struct /* tm library global info */ +{ + char* deformat; /* TM_DEFAULT override */ + int flags; /* flags */ + char** format; /* current format strings */ + Tm_zone_t* date; /* timezone from last tmdate() */ + Tm_zone_t* local; /* local timezone */ + Tm_zone_t* zone; /* current timezone */ +} Tm_info_t; + +typedef struct Tm_s +{ + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + uint32_t tm_nsec; + Tm_zone_t* tm_zone; +} Tm_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Tm_data_t* _tm_datap_; +extern Tm_info_t* _tm_infop_; + +#define tm_data (*_tm_datap_) +#define tm_info (*_tm_infop_) + +#undef extern + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern time_t tmdate(const char*, char**, time_t*); +extern int tmequiv(Tm_t*); +extern Tm_t* tmfix(Tm_t*); +extern char* tmfmt(char*, size_t, const char*, time_t*); +extern char* tmform(char*, const char*, time_t*); +extern int tmgoff(const char*, char**, int); +extern void tminit(Tm_zone_t*); +extern time_t tmleap(time_t*); +extern int tmlex(const char*, char**, char**, int, char**, int); +extern char** tmlocale(void); +extern Tm_t* tmmake(time_t*); +extern char* tmpoff(char*, size_t, const char*, int, int); +extern time_t tmscan(const char*, char**, const char*, char**, time_t*, long); +extern int tmsleep(time_t, time_t); +extern time_t tmtime(Tm_t*, int); +extern Tm_zone_t* tmtype(const char*, char**); +extern int tmweek(Tm_t*, int, int, int); +extern int tmword(const char*, char**, const char*, char**, int); +extern Tm_zone_t* tmzone(const char*, char**, const char*, int*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/tmx.h b/illumos-x86_64/usr/include/ast/tmx.h new file mode 100644 index 00000000..938e16cc --- /dev/null +++ b/illumos-x86_64/usr/include/ast/tmx.h @@ -0,0 +1,155 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/tmx by iffe version 2012-07-17 : : */ + +#ifndef _TMX_H +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _TMX_H 1 +/* + * AT&T Research + * + * high resolution Time_t support + */ + +#include +#include + +#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC" +#define TMX_MAXYEAR 2554 +#define TMX_MAXSEC ((Time_t)18446744073) +#define TMX_MAXNSEC 709551614 +#define TMX_RESOLUTION 1000000000 + +typedef uint64_t Time_t; +typedef uint64_t Tmxsec_t; +typedef uint32_t Tmxnsec_t; + +#define tmxsec(t) ((Tmxsec_t)((t)/1000000000)) +#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000)) +#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n))) + +#define TMX_NOTIME ((Time_t)(-1)) +#define TMX_NOW tmxgettime() +#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC) + +#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t)) +#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec) + +#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0) + +#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s)) +#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s)) +#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s)) + +#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t))) +#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t))) +#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t))) + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t)); +extern __MANGLE__ Time_t tmxduration __PROTO__((const char*, char**)); +extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t)); +extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t)); +extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t)); +extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long)); +extern __MANGLE__ int tmxsleep __PROTO__((Time_t)); +extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int)); +extern __MANGLE__ Tm_t* tmxtm __PROTO__((Tm_t*, Time_t, Tm_zone_t*)); + +extern __MANGLE__ Time_t tmxgettime __PROTO__((void)); +extern __MANGLE__ int tmxsettime __PROTO__((Time_t)); + +extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int)); + +extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t)); + +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ + +#endif diff --git a/illumos-x86_64/usr/include/ast/tok.h b/illumos-x86_64/usr/include/ast/tok.h new file mode 100644 index 00000000..b18ec9a2 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/tok.h @@ -0,0 +1,53 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * token stream interface definitions + */ + +#ifndef _TOK_H +#define _TOK_H + +#include + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Sfio_t* tokline(const char*, int, int*); +extern int tokscan(char*, char**, const char*, ...); +extern char* tokopen(char*, int); +extern void tokclose(char*); +extern char* tokread(char*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/tv.h b/illumos-x86_64/usr/include/ast/tv.h new file mode 100644 index 00000000..c1a3b0a6 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/tv.h @@ -0,0 +1,136 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2025 AT&T Intellectual Property * +* All Rights Reserved * +* This software is licensed by AT&T Intellectual Property * +* under the terms and conditions of the license in * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with an md5 checksum of b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ + +/* : : generated by proto : : */ +/* : : generated from contrib/ast/src/lib/libast/features/tv by iffe version 2012-07-17 : : */ + +#ifndef _TV_H +#if !defined(__PROTO__) +# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) +# if defined(__cplusplus) +# define __LINKAGE__ "C" +# else +# define __LINKAGE__ +# endif +# define __STDARG__ +# define __PROTO__(x) x +# define __OTORP__(x) +# define __PARAM__(n,o) n +# if !defined(__STDC__) && !defined(__cplusplus) +# if !defined(c_plusplus) +# define const +# endif +# define signed +# define void int +# define volatile +# define __V_ char +# else +# define __V_ void +# endif +# else +# define __PROTO__(x) () +# define __OTORP__(x) x +# define __PARAM__(n,o) o +# define __LINKAGE__ +# define __V_ char +# define const +# define signed +# define void int +# define volatile +# endif +# define __MANGLE__ __LINKAGE__ +# if defined(__cplusplus) || defined(c_plusplus) +# define __VARARG__ ... +# else +# define __VARARG__ +# endif +# if defined(__STDARG__) +# define __VA_START__(p,a) va_start(p,a) +# else +# define __VA_START__(p,a) va_start(p) +# endif +# if !defined(__INLINE__) +# if defined(__cplusplus) +# define __INLINE__ extern __MANGLE__ inline +# else +# if defined(_WIN32) && !defined(__GNUC__) +# define __INLINE__ __inline +# endif +# endif +# endif +#endif +#if !defined(__LINKAGE__) +#define __LINKAGE__ /* 2004-08-11 transition */ +#endif + +#define _TV_H 1 +/* + * AT&T Research + * + * high resolution Tv_t interface definitions + */ + +#include + +#define TV_NSEC_IGNORE (1000000000L) +#define TV_TOUCH_RETAIN ((Tv_t*)1) + +typedef struct Tv_s +{ + uint32_t tv_sec; + uint32_t tv_nsec; +} Tv_t; + +#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec) +#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec) +#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec) + +#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n)) +#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n)) +#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n)) + +#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime) +#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime) +#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime) + +#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec) +#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec) +#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec) + +#if _BLD_ast && defined(__EXPORT__) +#undef __MANGLE__ +#define __MANGLE__ __LINKAGE__ __EXPORT__ +#endif + +extern __MANGLE__ int tvgettime __PROTO__((Tv_t*)); +extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*)); +extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*)); +extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int)); +extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*)); + +extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*)); + +#endif diff --git a/illumos-x86_64/usr/include/ast/usage.h b/illumos-x86_64/usr/include/ast/usage.h new file mode 100644 index 00000000..c730e8bb --- /dev/null +++ b/illumos-x86_64/usr/include/ast/usage.h @@ -0,0 +1,43 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +/* + * error catalog and usage defaults + */ + +#ifndef _USAGE_H +#define _USAGE_H + +#ifndef ERROR_CATALOG +#define ERROR_CATALOG 0 +#endif + +#ifndef USAGE_LICENSE +#define USAGE_LICENSE "[-license?THIS IS AN UNLICENSED COPY]" +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ast/vdb.h b/illumos-x86_64/usr/include/ast/vdb.h new file mode 100644 index 00000000..9ed39ec5 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/vdb.h @@ -0,0 +1,52 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * virtual db file directory entry constants + */ + +#ifndef VDB_MAGIC + +#define VDB_MAGIC "vdb" + +#define VDB_DIRECTORY "DIRECTORY" +#define VDB_UNION "UNION" +#define VDB_DATE "DATE" +#define VDB_MODE "MODE" + +#define VDB_DELIMITER ';' +#define VDB_IGNORE '_' +#define VDB_FIXED 10 +#define VDB_LENGTH ((int)sizeof(VDB_DIRECTORY)+2*(VDB_FIXED+1)) +#define VDB_OFFSET ((int)sizeof(VDB_DIRECTORY)) +#define VDB_SIZE (VDB_OFFSET+VDB_FIXED+1) + +#endif diff --git a/illumos-x86_64/usr/include/ast/vecargs.h b/illumos-x86_64/usr/include/ast/vecargs.h new file mode 100644 index 00000000..ffcc96db --- /dev/null +++ b/illumos-x86_64/usr/include/ast/vecargs.h @@ -0,0 +1,51 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * vector argument interface definitions + */ + +#ifndef _VECARGS_H +#define _VECARGS_H + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int vecargs(char**, int*, char***); +extern char** vecfile(const char*); +extern void vecfree(char**, int); +extern char** vecload(char*); +extern char** vecstring(const char*); + +#undef extern + +#endif diff --git a/illumos-x86_64/usr/include/ast/vmalloc.h b/illumos-x86_64/usr/include/ast/vmalloc.h new file mode 100644 index 00000000..d5ef5844 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/vmalloc.h @@ -0,0 +1,341 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2012 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#ifndef _VMALLOC_H +#define _VMALLOC_H 1 + +/* Public header file for the virtual malloc package. +** +** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/1994. +*/ + +#define VMALLOC_VERSION 20110808L + +#if _PACKAGE_ast +#include +#else +#include +#endif + +typedef struct _vmalloc_s Vmalloc_t; +typedef struct _vmstat_s Vmstat_t; +typedef struct _vmdisc_s Vmdisc_t; +typedef struct _vmethod_s Vmethod_t; +typedef struct _vmdata_s Vmdata_t; +typedef Void_t* (*Vmemory_f)_ARG_((Vmalloc_t*, Void_t*, size_t, size_t, Vmdisc_t*)); +typedef int (*Vmexcept_f)_ARG_((Vmalloc_t*, int, Void_t*, Vmdisc_t*)); + +struct _vmstat_s +{ int n_busy; /* number of busy blocks */ + int n_free; /* number of free blocks */ + size_t s_busy; /* total amount of busy space */ + size_t s_free; /* total amount of free space */ + size_t m_busy; /* largest busy piece */ + size_t m_free; /* largest free piece */ + int n_seg; /* number of segments */ + size_t extent; /* total size of region */ + int n_region; /* #parallel regions (Vmregion) */ + int n_open; /* #calls that finds open reg */ + int n_lock; /* #calls where reg was locked */ + int n_probe; /* #probes to find a region */ + int mode; /* region mode bits */ +}; + +struct _vmdisc_s +{ Vmemory_f memoryf; /* memory manipulator */ + Vmexcept_f exceptf; /* exception handler */ + size_t round; /* rounding requirement */ + size_t size; /* actual size of discipline */ +}; + +struct _vmethod_s +{ Void_t* (*allocf)_ARG_((Vmalloc_t*,size_t,int)); + Void_t* (*resizef)_ARG_((Vmalloc_t*,Void_t*,size_t,int,int)); + int (*freef)_ARG_((Vmalloc_t*,Void_t*,int)); + long (*addrf)_ARG_((Vmalloc_t*,Void_t*,int)); + long (*sizef)_ARG_((Vmalloc_t*,Void_t*,int)); + int (*compactf)_ARG_((Vmalloc_t*,int)); + Void_t* (*alignf)_ARG_((Vmalloc_t*,size_t,size_t,int)); + unsigned short meth; +}; + +struct _vmalloc_s +{ Vmethod_t meth; /* method for allocation */ + char* file; /* file name */ + int line; /* line number */ + char* func; /* calling function */ + Vmdisc_t* disc; /* discipline to get space */ + Vmdata_t* data; /* the real region data */ + Vmalloc_t* next; /* linked list of regions */ +}; + +#define VM_TRUST 0000000 /* obsolete */ +#define VM_TRACE 0000001 /* generate traces of calls */ +#define VM_DBCHECK 0000002 /* check for boundary overwrite */ +#define VM_DBABORT 0000004 /* abort on any warning */ +#define VM_SHARE 0000010 /* sharable across processes */ +#define VM_MEMORYF 0000020 /* vm was allocated by memoryf */ +#define VM_FLAGS 0000017 /* user-settable flags */ + +#define VM_MTBEST 0000100 /* Vmbest method */ +#define VM_MTPOOL 0000200 /* Vmpool method */ +#define VM_MTLAST 0000400 /* Vmlast method */ +#define VM_MTDEBUG 0001000 /* Vmdebug method */ +#define VM_MTPROFILE 0002000 /* Vmdebug method */ +#define VM_METHODS 0003700 /* available allocation methods */ + +#define VM_RSCOPY 0000001 /* copy old contents */ +#define VM_RSMOVE 0000002 /* old contents is moveable */ +#define VM_RSZERO 0000004 /* clear new space */ + +/* exception types */ +#define VM_OPEN 1 /* region being opened */ +#define VM_ENDOPEN 2 /* end of region opening */ +#define VM_CLOSE 3 /* announce being closed */ +#define VM_ENDCLOSE 4 /* end of region closing */ +#define VM_DISC 5 /* discipline being changed */ +#define VM_NOMEM 6 /* can't obtain memory */ +#define VM_BADADDR (-1) /* currently a no-op */ + +/* for application-specific data in shared/persistent regions */ +#define VM_MMGET 0 /* get data value (void*) */ +#define VM_MMSET 1 /* set data value (void*) */ +#define VM_MMADD 2 /* add data value (long) */ + +_BEGIN_EXTERNS_ /* public data */ +#if _BLD_vmalloc && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_vmalloc && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Vmethod_t* Vmbest; /* best allocation */ +extern Vmethod_t* Vmlast; /* last-block allocation */ +extern Vmethod_t* Vmpool; /* pool allocation */ +extern Vmethod_t* Vmdebug; /* allocation with debugging */ +extern Vmethod_t* Vmprofile; /* profiling memory usage */ + +extern Vmdisc_t* Vmdcsystem; /* get memory from the OS */ +extern Vmdisc_t* Vmdcheap; /* get memory from Vmheap */ +extern Vmdisc_t* Vmdcsbrk; /* like Vmdcsystem - legacy use */ + +extern Vmalloc_t _Vmheap; /* heap region - use with care! */ +extern Vmalloc_t* Vmheap; /* = &_Vmheap - safe to use */ +extern Vmalloc_t* Vmregion; /* malloc region */ + +#undef extern +_END_EXTERNS_ + +_BEGIN_EXTERNS_ /* public functions */ +#if _BLD_vmalloc && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern Vmalloc_t* vmopen _ARG_(( Vmdisc_t*, Vmethod_t*, int )); +extern int vmclose _ARG_(( Vmalloc_t* )); +extern int vmclear _ARG_(( Vmalloc_t* )); +extern int vmcompact _ARG_(( Vmalloc_t* )); + +extern Vmdisc_t* vmdisc _ARG_(( Vmalloc_t*, Vmdisc_t* )); + +extern Vmalloc_t* vmmopen _ARG_(( char*, int, ssize_t )); +extern Void_t* vmmvalue _ARG_(( Vmalloc_t*, int, Void_t*, int )); +extern void vmmrelease _ARG_(( Vmalloc_t*, int )); +extern Void_t* vmmaddress _ARG_(( size_t )); + +extern Void_t* vmalloc _ARG_(( Vmalloc_t*, size_t )); +extern Void_t* vmalign _ARG_(( Vmalloc_t*, size_t, size_t )); +extern Void_t* vmresize _ARG_(( Vmalloc_t*, Void_t*, size_t, int )); +extern Void_t* vmgetmem _ARG_(( Vmalloc_t*, Void_t*, size_t )); +extern int vmfree _ARG_(( Vmalloc_t*, Void_t* )); + +extern long vmaddr _ARG_(( Vmalloc_t*, Void_t* )); +extern long vmsize _ARG_(( Vmalloc_t*, Void_t* )); + +extern Vmalloc_t* vmregion _ARG_(( Void_t* )); +extern Void_t* vmsegment _ARG_(( Vmalloc_t*, Void_t* )); +extern int vmset _ARG_(( Vmalloc_t*, int, int )); + +extern Void_t* vmdbwatch _ARG_(( Void_t* )); +extern int vmdbcheck _ARG_(( Vmalloc_t* )); +extern int vmdebug _ARG_(( int )); + +extern int vmprofile _ARG_(( Vmalloc_t*, int )); + +extern int vmtrace _ARG_(( int )); +extern int vmtrbusy _ARG_((Vmalloc_t*)); + +extern int vmstat _ARG_((Vmalloc_t*, Vmstat_t*)); + +extern int vmwalk _ARG_((Vmalloc_t*, + int(*)(Vmalloc_t*,Void_t*,size_t,Vmdisc_t*,Void_t*), Void_t*)); +extern char* vmstrdup _ARG_((Vmalloc_t*, const char*)); + +#if !defined(_BLD_vmalloc) && !defined(_AST_STD_H) && \ + !defined(__stdlib_h) && !defined(__STDLIB_H) && \ + !defined(_STDLIB_INCLUDED) && !defined(_INC_STDLIB) +extern Void_t* malloc _ARG_(( size_t )); +extern Void_t* realloc _ARG_(( Void_t*, size_t )); +extern void free _ARG_(( Void_t* )); +extern void cfree _ARG_(( Void_t* )); +extern Void_t* calloc _ARG_(( size_t, size_t )); +extern Void_t* memalign _ARG_(( size_t, size_t )); +extern Void_t* valloc _ARG_(( size_t )); +#endif +extern int setregmax _ARG_(( int )); + +#undef extern +_END_EXTERNS_ + +/* to coerce any value to a Vmalloc_t*, make ANSI happy */ +#define _VM_(vm) ((Vmalloc_t*)(vm)) + +/* enable recording of where a call originates from */ +#ifdef VMFL + +#if defined(__FILE__) +#define _VMFILE_(vm) (_VM_(vm)->file = (char*)__FILE__) +#else +#define _VMFILE_(vm) (_VM_(vm)->file = (char*)0) +#endif + +#if defined(__LINE__) +#define _VMLINE_(vm) (_VM_(vm)->line = __LINE__) +#else +#define _VMLINE_(vm) (_VM_(vm)->line = 0) +#endif + +#if defined(__FUNCTION__) +#define _VMFUNC_(vm) (_VM_(vm)->func = (char*)__FUNCTION__) +#else +#define _VMFUNC_(vm) (_VM_(vm)->func = (char*)0) +#endif + +#define _VMFL_(vm) (_VMFILE_(vm), _VMLINE_(vm), _VMFUNC_(vm)) + +#define vmalloc(vm,sz) (_VMFL_(vm), \ + (*(_VM_(vm)->meth.allocf))((vm),(sz),0) ) +#define vmresize(vm,d,sz,type) (_VMFL_(vm), \ + (*(_VM_(vm)->meth.resizef))\ + ((vm),(Void_t*)(d),(sz),(type),0) ) +#define vmfree(vm,d) (_VMFL_(vm), \ + (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d),0) ) +#define vmalign(vm,sz,align) (_VMFL_(vm), \ + (*(_VM_(vm)->meth.alignf))((vm),(sz),(align),0) ) + +#undef malloc +#undef realloc +#undef calloc +#undef free +#undef memalign +#undef valloc + +#if _map_malloc + +#define malloc(s) (_VMFL_(Vmregion), _ast_malloc((size_t)(s)) ) +#define realloc(d,s) (_VMFL_(Vmregion), _ast_realloc((Void_t*)(d),(size_t)(s)) ) +#define calloc(n,s) (_VMFL_(Vmregion), _ast_calloc((size_t)n, (size_t)(s)) ) +#define free(d) (_VMFL_(Vmregion), _ast_free((Void_t*)(d)) ) +#define memalign(a,s) (_VMFL_(Vmregion), _ast_memalign((size_t)(a),(size_t)(s)) ) +#define valloc(s) (_VMFL_(Vmregion), _ast_valloc((size_t)(s) ) + +#else + +#if !_std_malloc + +#if __STD_C || defined(__STDPP__) || defined(__GNUC__) + +#define malloc(s) (_VMFL_(Vmregion), malloc((size_t)(s)) ) +#define realloc(d,s) (_VMFL_(Vmregion), realloc((Void_t*)(d),(size_t)(s)) ) +#define calloc(n,s) (_VMFL_(Vmregion), calloc((size_t)n, (size_t)(s)) ) +#define free(d) (_VMFL_(Vmregion), free((Void_t*)(d)) ) +#define memalign(a,s) (_VMFL_(Vmregion), memalign((size_t)(a),(size_t)(s)) ) +#define valloc(s) (_VMFL_(Vmregion), valloc((size_t)(s) ) +#ifndef strdup +#define strdup(s) ( _VMFL_(Vmregion), (strdup)((char*)(s)) ) +#endif + +#else + +#define _VMNM_(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f +#define malloc(s) (_VMFL_(Vmregion), _VMNM_(mallo,/,*,*,/,c)\ + ((size_t)(s)) ) +#define realloc(d,s) (_VMFL_(Vmregion), _VMNM_(reallo,/,*,*,/,c)\ + ((Void_t*)(d),(size_t)(s)) ) +#define calloc(n,s) (_VMFL_(Vmregion), _VMNM_(callo,/,*,*,/,c)\ + ((size_t)n, (size_t)(s)) ) +#define free(d) (_VMFL_(Vmregion), _VMNM_(fre,/,*,*,/,e)((Void_t*)(d)) ) +#define memalign(a,s) (_VMFL_(Vmregion), _VMNM_(memalig,/,*,*,/,n)\ + ((size_t)(a),(size_t)(s)) ) +#define valloc(s) (_VMFL_(Vmregion), _VMNM_(vallo,/,*,*,/,c)\ + ((size_t)(s) ) +#ifndef strdup +#define strdup(s) ( _VMFL_(Vmregion), _VMNM_(strdu,/,*,*,/,p)\ + ((char*)(s)) ) +#endif + +#endif /*__STD_C || defined(__STDPP__) || defined(__GNUC__)*/ + +#define cfree(d) free(d) + +#endif /*!_std_malloc*/ + +#endif /*_map_malloc*/ + +#endif /*VMFL*/ + +/* non-debugging/profiling allocation calls */ +#ifndef vmalloc +#define vmalloc(vm,sz) (*(_VM_(vm)->meth.allocf))((vm),(sz),0) +#endif + +#ifndef vmresize +#define vmresize(vm,d,sz,type) (*(_VM_(vm)->meth.resizef))\ + ((vm),(Void_t*)(d),(sz),(type),0) +#endif + +#ifndef vmfree +#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d),0) +#endif + +#ifndef vmalign +#define vmalign(vm,sz,align) (*(_VM_(vm)->meth.alignf))((vm),(sz),(align),0) +#endif + +#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(Void_t*)(addr),0) +#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(Void_t*)(addr),0) +#define vmcompact(vm) (*(_VM_(vm)->meth.compactf))((vm),0) +#define vmoldof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \ + (VM_RSMOVE) ) +#define vmnewof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \ + (VM_RSMOVE|VM_RSCOPY|VM_RSZERO) ) + +#define vmdata(vm) ((Void_t*)(_VM_(vm)->data) ) +#define vmlocked(vm) (*((unsigned int*)(_VM_(vm)->data)) ) + +#endif /* _VMALLOC_H */ diff --git a/illumos-x86_64/usr/include/ast/wait.h b/illumos-x86_64/usr/include/ast/wait.h new file mode 100644 index 00000000..0b884570 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/wait.h @@ -0,0 +1,104 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * ast POSIX wait/exit support + */ + +#ifndef _WAIT_H +#define _WAIT_H + +#include +#include + +#if _sys_wait +#if defined(__STDPP__directive) && defined(__STDPP__hide) +__STDPP__directive pragma pp:hide wait waitpid +#else +#define wait ______wait +#define waitpid ______waitpid +#endif +#include +#if defined(__STDPP__directive) && defined(__STDPP__hide) +__STDPP__directive pragma pp:nohide wait waitpid +#else +#undef wait +#undef waitpid +#endif +#endif + +#ifndef WNOHANG +#define WNOHANG 1 +#endif + +#ifndef WUNTRACED +#define WUNTRACED 2 +#endif + +#if !_ok_wif +#undef WIFEXITED +#undef WEXITSTATUS +#undef WIFSIGNALED +#undef WTERMSIG +#undef WIFSTOPPED +#undef WSTOPSIG +#undef WTERMCORE +#endif + +#ifndef WIFEXITED +#define WIFEXITED(x) (!((x)&((1<<(EXIT_BITS-1))-1))) +#endif + +#ifndef WEXITSTATUS +#define WEXITSTATUS(x) (((x)>>EXIT_BITS)&((1< * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#include diff --git a/illumos-x86_64/usr/include/ast/wctype.h b/illumos-x86_64/usr/include/ast/wctype.h new file mode 100644 index 00000000..928ee27c --- /dev/null +++ b/illumos-x86_64/usr/include/ast/wctype.h @@ -0,0 +1,28 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#include diff --git a/illumos-x86_64/usr/include/ast/wordexp.h b/illumos-x86_64/usr/include/ast/wordexp.h new file mode 100644 index 00000000..a7af2063 --- /dev/null +++ b/illumos-x86_64/usr/include/ast/wordexp.h @@ -0,0 +1,69 @@ +/* + * BEGIN illumos section + * This is an unstable interface; changes may be made + * without notice. + * END illumos section + */ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * posix wordexp interface definitions + */ + +#ifndef _WORDEXP_H +#define _WORDEXP_H + +#include + +#define WRDE_APPEND 01 +#define WRDE_DOOFFS 02 +#define WRDE_NOCMD 04 +#define WRDE_NOSYS 0100 +#define WRDE_REUSE 010 +#define WRDE_SHOWERR 020 +#define WRDE_UNDEF 040 + +#define WRDE_BADCHAR 1 +#define WRDE_BADVAL 2 +#define WRDE_CMDSUB 3 +#define WRDE_NOSPACE 4 +#define WRDE_SYNTAX 5 +#define WRDE_NOSHELL 6 + +typedef struct _wdarg +{ + size_t we_wordc; + char **we_wordv; + size_t we_offs; +} wordexp_t; + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int wordexp(const char*, wordexp_t*, int); +extern int wordfree(wordexp_t*); + +#undef extern + +#endif /* _WORDEXP_H */ diff --git a/illumos-x86_64/usr/include/atomic.h b/illumos-x86_64/usr/include/atomic.h new file mode 100644 index 00000000..14709e45 --- /dev/null +++ b/illumos-x86_64/usr/include/atomic.h @@ -0,0 +1,32 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ATOMIC_H +#define _ATOMIC_H + +#include + +#endif /* _ATOMIC_H */ diff --git a/illumos-x86_64/usr/include/attr.h b/illumos-x86_64/usr/include/attr.h new file mode 100644 index 00000000..bca7fbcb --- /dev/null +++ b/illumos-x86_64/usr/include/attr.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ATTR_H +#define _ATTR_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int getattrat(int, xattr_view_t, const char *, nvlist_t **); +extern int fgetattr(int, xattr_view_t, nvlist_t **); +extern int setattrat(int, xattr_view_t, const char *, nvlist_t *); +extern int fsetattr(int, xattr_view_t, nvlist_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _ATTR_H */ diff --git a/illumos-x86_64/usr/include/auth_attr.h b/illumos-x86_64/usr/include/auth_attr.h new file mode 100644 index 00000000..32be62f9 --- /dev/null +++ b/illumos-x86_64/usr/include/auth_attr.h @@ -0,0 +1,103 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1999 by Sun Microsystems, Inc. All rights reserved. + */ + +#ifndef _AUTH_ATTR_H +#define _AUTH_ATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Some macros used internally by the nsswitch code + */ +#define AUTH_MMAPLEN 1024 +#define AUTH_POLICY "/etc/security/policy.conf" +#define DEF_AUTH "AUTHS_GRANTED=" +#define AUTHATTR_FILENAME "/etc/security/auth_attr" +#define AUTHATTR_DB_NAME "auth_attr.org_dir" +#define AUTHATTR_DB_NCOL 6 /* total columns */ +#define AUTHATTR_DB_NKEYCOL 1 /* total searchable columns */ +#define AUTHATTR_DB_TBLT "auth_attr_tbl" +#define AUTHATTR_NAME_DEFAULT_KW "nobody" + +#define AUTHATTR_COL0_KW "name" +#define AUTHATTR_COL1_KW "res1" +#define AUTHATTR_COL2_KW "res2" +#define AUTHATTR_COL3_KW "short_desc" +#define AUTHATTR_COL4_KW "long_desc" +#define AUTHATTR_COL5_KW "attr" + +/* + * indices of searchable columns + */ +#define AUTHATTR_KEYCOL0 0 /* name */ + + +/* + * Key words used in the auth_attr database + */ +#define AUTHATTR_HELP_KW "help" + +/* + * Nsswitch internal representation of authorization attributes. + */ +typedef struct authstr_s { + char *name; /* authorization name */ + char *res1; /* reserved for future use */ + char *res2; /* reserved for future use */ + char *short_desc; /* short description */ + char *long_desc; /* long description */ + char *attr; /* string of key-value pair attributes */ +} authstr_t; + +/* + * API representation of authorization attributes. + */ +typedef struct authattr_s { + char *name; /* authorization name */ + char *res1; /* reserved for future use */ + char *res2; /* reserved for future use */ + char *short_desc; /* short description */ + char *long_desc; /* long description */ + kva_t *attr; /* array of key-value pair attributes */ +} authattr_t; + +extern authattr_t *getauthnam(const char *); +extern authattr_t *getauthattr(void); +extern void setauthattr(void); +extern void endauthattr(void); +extern void free_authattr(authattr_t *); +extern int chkauthattr(const char *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _AUTH_ATTR_H */ diff --git a/illumos-x86_64/usr/include/bfd.h b/illumos-x86_64/usr/include/bfd.h new file mode 100644 index 00000000..3e1f8801 --- /dev/null +++ b/illumos-x86_64/usr/include/bfd.h @@ -0,0 +1,8045 @@ +/* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically + generated from "bfd-in.h", "libbfd.c", "hash.c", "section.c", + "syms.c", "archive.c", "archures.c", "bfd.c", "bfdio.c", "cache.c", + "compress.c", "corefile.c", "format.c", "linker.c", "opncls.c", + "reloc.c", "simple.c", "stab-syms.c", "stabs.c" and "targets.c". + Run "make headers" in your build bfd/ to regenerate. */ + +/* Main header file for the bfd library -- portable access to object files. + + Copyright (C) 1990-2025 Free Software Foundation, Inc. + + Contributed by Cygnus Support. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef __BFD_H_SEEN__ +#define __BFD_H_SEEN__ + +/* PR 14072: Ensure that config.h is included first. */ +#if !defined PACKAGE && !defined PACKAGE_VERSION +#error config.h must be included before this header +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ansidecl.h" +#include "symcat.h" +#include +#include +#include +#include "diagnostics.h" +#include +#include +#include + +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#ifndef SABER +/* This hack is to avoid a problem with some strict ANSI C preprocessors. + The problem is, "32_" is not a valid preprocessing token, and we don't + want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will + cause the inner CONCAT2 macros to be evaluated first, producing + still-valid pp-tokens. Then the final concatenation can be done. */ +#undef CONCAT4 +#define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d)) +#endif +#endif + +/* This is a utility macro to handle the situation where the code + wants to place a constant string into the code, followed by a + comma and then the length of the string. Doing this by hand + is error prone, so using this macro is safer. */ +#define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1) + +#define BFD_SUPPORTS_PLUGINS 1 + +/* The word size used by BFD on the host. This may be 64 with a 32 + bit target if the host is 64 bit, or if other 64 bit targets have + been selected with --enable-targets, or if --enable-64-bit-bfd. */ +#define BFD_ARCH_SIZE 64 + +/* The word size of the default bfd target. */ +#define BFD_DEFAULT_TARGET_SIZE 32 + +#include + +#if BFD_ARCH_SIZE >= 64 +#define BFD64 +#endif + +/* Boolean type used in bfd. + General rule: Functions which are bfd_boolean return TRUE on + success and FALSE on failure (unless they're a predicate). */ + +#ifdef POISON_BFD_BOOLEAN +# pragma GCC poison bfd_boolean +#else +# define bfd_boolean bool +# undef FALSE +# undef TRUE +# define FALSE 0 +# define TRUE 1 +#endif + +/* Silence "applying zero offset to null pointer" UBSAN warnings. */ +#define PTR_ADD(P,A) ((A) != 0 ? (P) + (A) : (P)) +/* Also prevent non-zero offsets from being applied to a null pointer. */ +#define NPTR_ADD(P,A) ((P) != NULL ? (P) + (A) : (P)) + +#ifdef BFD64 + +/* Represent a target address. Also used as a generic unsigned type + which is guaranteed to be big enough to hold any arithmetic types + we need to deal with. */ +typedef uint64_t bfd_vma; + +/* A generic signed type which is guaranteed to be big enough to hold any + arithmetic types we need to deal with. Can be assumed to be compatible + with bfd_vma in the same way that signed and unsigned ints are compatible + (as parameters, in assignment, etc). */ +typedef int64_t bfd_signed_vma; + +typedef uint64_t bfd_size_type; +typedef uint64_t symvalue; + +#else /* not BFD64 */ + +typedef uint32_t bfd_vma; +typedef int32_t bfd_signed_vma; +typedef uint32_t bfd_size_type; +typedef uint32_t symvalue; + +#endif /* not BFD64 */ + +#define HALF_BFD_SIZE_TYPE \ + (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2)) + +/* An offset into a file. BFD always uses the largest possible offset + based on the build time availability of fseek, fseeko, or fseeko64. */ +typedef int64_t file_ptr; +typedef uint64_t ufile_ptr; + +typedef uint32_t flagword; /* 32 bits of flags */ +typedef uint8_t bfd_byte; + +/* Forward declarations. */ +typedef struct bfd bfd; +struct bfd_link_info; +struct bfd_link_hash_entry; +typedef struct bfd_section *sec_ptr; +typedef struct reloc_cache_entry arelent; +struct orl; + +#define align_power(addr, align) \ + (((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align)))) + +/* Align an address upward to a boundary, expressed as a number of bytes. + E.g. align to an 8-byte boundary with argument of 8. Take care never + to wrap around if the address is within boundary-1 of the end of the + address space. */ +#define BFD_ALIGN(this, boundary) \ + ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \ + ? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \ + : ~ (bfd_vma) 0) + +/* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */ + +static inline bool +startswith (const char *str, const char *prefix) +{ + return strncmp (str, prefix, strlen (prefix)) == 0; +} + +/* Extracted from libbfd.c. */ +void *bfd_alloc (bfd *abfd, bfd_size_type wanted); + +void *bfd_zalloc (bfd *abfd, bfd_size_type wanted); + +void bfd_release (bfd *, void *); + + +/* Byte swapping macros for user section data. */ + +#define bfd_put_8(abfd, val, ptr) \ + ((void) (*((bfd_byte *) (ptr)) = (val) & 0xff)) +#define bfd_put_signed_8 \ + bfd_put_8 +#define bfd_get_8(abfd, ptr) \ + ((bfd_vma) *(const bfd_byte *) (ptr) & 0xff) +#define bfd_get_signed_8(abfd, ptr) \ + ((((bfd_signed_vma) *(const bfd_byte *) (ptr) & 0xff) ^ 0x80) - 0x80) + +#define bfd_put_16(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_putx16, ((val),(ptr))) +#define bfd_put_signed_16 \ + bfd_put_16 +#define bfd_get_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx16, (ptr)) +#define bfd_get_signed_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) + +#define bfd_put_24(abfd, val, ptr) \ + do \ + if (bfd_big_endian (abfd)) \ + bfd_putb24 ((val), (ptr)); \ + else \ + bfd_putl24 ((val), (ptr)); \ + while (0) + +bfd_vma bfd_getb24 (const void *p); +bfd_vma bfd_getl24 (const void *p); + +#define bfd_get_24(abfd, ptr) \ + (bfd_big_endian (abfd) ? bfd_getb24 (ptr) : bfd_getl24 (ptr)) + +#define bfd_put_32(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_putx32, ((val),(ptr))) +#define bfd_put_signed_32 \ + bfd_put_32 +#define bfd_get_32(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx32, (ptr)) +#define bfd_get_signed_32(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_32, (ptr)) + +#define bfd_put_64(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_putx64, ((val), (ptr))) +#define bfd_put_signed_64 \ + bfd_put_64 +#define bfd_get_64(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx64, (ptr)) +#define bfd_get_signed_64(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_64, (ptr)) + +#define bfd_get(bits, abfd, ptr) \ + ((bits) == 8 ? bfd_get_8 (abfd, ptr) \ + : (bits) == 16 ? bfd_get_16 (abfd, ptr) \ + : (bits) == 32 ? bfd_get_32 (abfd, ptr) \ + : (bits) == 64 ? bfd_get_64 (abfd, ptr) \ + : (abort (), (bfd_vma) - 1)) + +#define bfd_put(bits, abfd, val, ptr) \ + ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \ + : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \ + : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \ + : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \ + : (abort (), (void) 0)) + + +/* Byte swapping macros for file header data. */ + +#define bfd_h_put_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) +#define bfd_h_put_signed_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) +#define bfd_h_get_8(abfd, ptr) \ + bfd_get_8 (abfd, ptr) +#define bfd_h_get_signed_8(abfd, ptr) \ + bfd_get_signed_8 (abfd, ptr) + +#define bfd_h_put_16(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_h_putx16, (val, ptr)) +#define bfd_h_put_signed_16 \ + bfd_h_put_16 +#define bfd_h_get_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx16, (ptr)) +#define bfd_h_get_signed_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr)) + +#define bfd_h_put_32(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_h_putx32, (val, ptr)) +#define bfd_h_put_signed_32 \ + bfd_h_put_32 +#define bfd_h_get_32(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx32, (ptr)) +#define bfd_h_get_signed_32(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr)) + +#define bfd_h_put_64(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_h_putx64, (val, ptr)) +#define bfd_h_put_signed_64 \ + bfd_h_put_64 +#define bfd_h_get_64(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx64, (ptr)) +#define bfd_h_get_signed_64(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr)) + +/* Aliases for the above, which should eventually go away. */ + +#define H_PUT_64 bfd_h_put_64 +#define H_PUT_32 bfd_h_put_32 +#define H_PUT_16 bfd_h_put_16 +#define H_PUT_8 bfd_h_put_8 +#define H_PUT_S64 bfd_h_put_signed_64 +#define H_PUT_S32 bfd_h_put_signed_32 +#define H_PUT_S16 bfd_h_put_signed_16 +#define H_PUT_S8 bfd_h_put_signed_8 +#define H_GET_64 bfd_h_get_64 +#define H_GET_32 bfd_h_get_32 +#define H_GET_16 bfd_h_get_16 +#define H_GET_8 bfd_h_get_8 +#define H_GET_S64 bfd_h_get_signed_64 +#define H_GET_S32 bfd_h_get_signed_32 +#define H_GET_S16 bfd_h_get_signed_16 +#define H_GET_S8 bfd_h_get_signed_8 + + +uint64_t bfd_getb64 (const void *); +uint64_t bfd_getl64 (const void *); +int64_t bfd_getb_signed_64 (const void *); +int64_t bfd_getl_signed_64 (const void *); +bfd_vma bfd_getb32 (const void *); +bfd_vma bfd_getl32 (const void *); +bfd_signed_vma bfd_getb_signed_32 (const void *); +bfd_signed_vma bfd_getl_signed_32 (const void *); +bfd_vma bfd_getb16 (const void *); +bfd_vma bfd_getl16 (const void *); +bfd_signed_vma bfd_getb_signed_16 (const void *); +bfd_signed_vma bfd_getl_signed_16 (const void *); +void bfd_putb64 (uint64_t, void *); +void bfd_putl64 (uint64_t, void *); +void bfd_putb32 (bfd_vma, void *); +void bfd_putl32 (bfd_vma, void *); +void bfd_putb24 (bfd_vma, void *); +void bfd_putl24 (bfd_vma, void *); +void bfd_putb16 (bfd_vma, void *); +void bfd_putl16 (bfd_vma, void *); +uint64_t bfd_get_bits (const void *, int, bool); +void bfd_put_bits (uint64_t, void *, int, bool); + +/* Extracted from hash.c. */ +/* An element in the hash table. Most uses will actually use a larger + structure, and an instance of this will be the first field. */ + +struct bfd_hash_entry +{ + /* Next entry for this hash code. */ + struct bfd_hash_entry *next; + /* String being hashed. */ + const char *string; + /* Hash code. This is the full hash code, not the index into the + table. */ + unsigned long hash; +}; + +/* A hash table. */ + +struct bfd_hash_table +{ + /* The hash array. */ + struct bfd_hash_entry **table; + /* A function used to create new elements in the hash table. The + first entry is itself a pointer to an element. When this + function is first invoked, this pointer will be NULL. However, + having the pointer permits a hierarchy of method functions to be + built each of which calls the function in the superclass. Thus + each function should be written to allocate a new block of memory + only if the argument is NULL. */ + struct bfd_hash_entry *(*newfunc) + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); + /* An objalloc for this hash table. This is a struct objalloc *, + but we use void * to avoid requiring the inclusion of objalloc.h. */ + void *memory; + /* The number of slots in the hash table. */ + unsigned int size; + /* The number of entries in the hash table. */ + unsigned int count; + /* The size of elements. */ + unsigned int entsize; + /* If non-zero, don't grow the hash table. */ + unsigned int frozen:1; +}; + +bool bfd_hash_table_init_n + (struct bfd_hash_table *, + struct bfd_hash_entry *(* /*newfunc*/) + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), + unsigned int /*entsize*/, unsigned int /*size*/); + +bool bfd_hash_table_init + (struct bfd_hash_table *, + struct bfd_hash_entry *(* /*newfunc*/) + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), + unsigned int /*entsize*/); + +void bfd_hash_table_free (struct bfd_hash_table *); + +struct bfd_hash_entry *bfd_hash_lookup + (struct bfd_hash_table *, const char *, + bool /*create*/, bool /*copy*/); + +struct bfd_hash_entry *bfd_hash_insert + (struct bfd_hash_table *, + const char *, + unsigned long /*hash*/); + +void bfd_hash_rename (struct bfd_hash_table *, + const char *, + struct bfd_hash_entry *); + +void bfd_hash_replace (struct bfd_hash_table *, + struct bfd_hash_entry * /*old*/, + struct bfd_hash_entry * /*new*/); + +void *bfd_hash_allocate (struct bfd_hash_table *, + unsigned int /*size*/); + +struct bfd_hash_entry *bfd_hash_newfunc + (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *); + +void bfd_hash_traverse + (struct bfd_hash_table *, + bool (*) (struct bfd_hash_entry *, void *), + void *); + +unsigned int bfd_hash_set_default_size (unsigned int); + +/* Extracted from section.c. */ +/* Linenumber stuff. */ +typedef struct lineno_cache_entry +{ + unsigned int line_number; /* Linenumber from start of function. */ + union + { + struct bfd_symbol *sym; /* Function name. */ + bfd_vma offset; /* Offset into section. */ + } u; +} +alent; + +typedef struct bfd_section +{ + /* The name of the section; the name isn't a copy, the pointer is + the same as that passed to bfd_make_section. */ + const char *name; + + /* The next section in the list belonging to the BFD, or NULL. */ + struct bfd_section *next; + + /* The previous section in the list belonging to the BFD, or NULL. */ + struct bfd_section *prev; + + /* A unique sequence number. */ + unsigned int id; + + /* A unique section number which can be used by assembler to + distinguish different sections with the same section name. */ + unsigned int section_id; + + /* Which section in the bfd; 0..n-1 as sections are created in a bfd. */ + unsigned int index; + + /* The field flags contains attributes of the section. Some + flags are read in from the object file, and some are + synthesized from other information. */ + flagword flags; + +#define SEC_NO_FLAGS 0x0 + + /* Tells the OS to allocate space for this section when loading. + This is clear for a section containing debug information only. */ +#define SEC_ALLOC 0x1 + + /* Tells the OS to load the section from the file when loading. + This is clear for a .bss section. */ +#define SEC_LOAD 0x2 + + /* The section contains data still to be relocated, so there is + some relocation information too. */ +#define SEC_RELOC 0x4 + + /* A signal to the OS that the section contains read only data. */ +#define SEC_READONLY 0x8 + + /* The section contains code only. */ +#define SEC_CODE 0x10 + + /* The section contains data only. */ +#define SEC_DATA 0x20 + + /* The section will reside in ROM. */ +#define SEC_ROM 0x40 + + /* The section contains constructor information. This section + type is used by the linker to create lists of constructors and + destructors used by <>. When a back end sees a symbol + which should be used in a constructor list, it creates a new + section for the type of name (e.g., <<__CTOR_LIST__>>), attaches + the symbol to it, and builds a relocation. To build the lists + of constructors, all the linker has to do is catenate all the + sections called <<__CTOR_LIST__>> and relocate the data + contained within - exactly the operations it would peform on + standard data. */ +#define SEC_CONSTRUCTOR 0x80 + + /* The section has contents - a data section could be + <> | <>; a debug section could be + <> */ +#define SEC_HAS_CONTENTS 0x100 + + /* An instruction to the linker to not output the section + even if it has information which would normally be written. */ +#define SEC_NEVER_LOAD 0x200 + + /* The section contains thread local data. */ +#define SEC_THREAD_LOCAL 0x400 + + /* The section's size is fixed. Generic linker code will not + recalculate it and it is up to whoever has set this flag to + get the size right. */ +#define SEC_FIXED_SIZE 0x800 + + /* The section contains common symbols (symbols may be defined + multiple times, the value of a symbol is the amount of + space it requires, and the largest symbol value is the one + used). Most targets have exactly one of these (which we + translate to bfd_com_section_ptr), but ECOFF has two. */ +#define SEC_IS_COMMON 0x1000 + + /* The section contains only debugging information. For + example, this is set for ELF .debug and .stab sections. + strip tests this flag to see if a section can be + discarded. */ +#define SEC_DEBUGGING 0x2000 + + /* The contents of this section are held in memory pointed to + by the contents field. This is checked by bfd_get_section_contents, + and the data is retrieved from memory if appropriate. */ +#define SEC_IN_MEMORY 0x4000 + + /* The contents of this section are to be excluded by the + linker for executable and shared objects unless those + objects are to be further relocated. */ +#define SEC_EXCLUDE 0x8000 + + /* The contents of this section are to be sorted based on the sum of + the symbol and addend values specified by the associated relocation + entries. Entries without associated relocation entries will be + appended to the end of the section in an unspecified order. */ +#define SEC_SORT_ENTRIES 0x10000 + + /* When linking, duplicate sections of the same name should be + discarded, rather than being combined into a single section as + is usually done. This is similar to how common symbols are + handled. See SEC_LINK_DUPLICATES below. */ +#define SEC_LINK_ONCE 0x20000 + + /* If SEC_LINK_ONCE is set, this bitfield describes how the linker + should handle duplicate sections. */ +#define SEC_LINK_DUPLICATES 0xc0000 + + /* This value for SEC_LINK_DUPLICATES means that duplicate + sections with the same name should simply be discarded. */ +#define SEC_LINK_DUPLICATES_DISCARD 0x0 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if there are any duplicate sections, although + it should still only link one copy. */ +#define SEC_LINK_DUPLICATES_ONE_ONLY 0x40000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections are a different size. */ +#define SEC_LINK_DUPLICATES_SAME_SIZE 0x80000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections contain different + contents. */ +#define SEC_LINK_DUPLICATES_SAME_CONTENTS \ + (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE) + + /* This section was created by the linker as part of dynamic + relocation or other arcane processing. It is skipped when + going through the first-pass output, trusting that someone + else up the line will take care of it later. */ +#define SEC_LINKER_CREATED 0x100000 + + /* This section contains a section ID to distinguish different + sections with the same section name. */ +#define SEC_ASSEMBLER_SECTION_ID 0x100000 + + /* This section should not be subject to garbage collection. + Also set to inform the linker that this section should not be + listed in the link map as discarded. */ +#define SEC_KEEP 0x200000 + + /* This section contains "short" data, and should be placed + "near" the GP. */ +#define SEC_SMALL_DATA 0x400000 + + /* Attempt to merge identical entities in the section. + Entity size is given in the entsize field. */ +#define SEC_MERGE 0x800000 + + /* If given with SEC_MERGE, entities to merge are zero terminated + strings where entsize specifies character size instead of fixed + size entries. */ +#define SEC_STRINGS 0x1000000 + + /* This section contains data about section groups. */ +#define SEC_GROUP 0x2000000 + + /* The section is a COFF shared library section. This flag is + only for the linker. If this type of section appears in + the input file, the linker must copy it to the output file + without changing the vma or size. FIXME: Although this + was originally intended to be general, it really is COFF + specific (and the flag was renamed to indicate this). It + might be cleaner to have some more general mechanism to + allow the back end to control what the linker does with + sections. */ +#define SEC_COFF_SHARED_LIBRARY 0x4000000 + + /* This input section should be copied to output in reverse order + as an array of pointers. This is for ELF linker internal use + only. */ +#define SEC_ELF_REVERSE_COPY 0x4000000 + + /* This section contains data which may be shared with other + executables or shared objects. This is for COFF only. */ +#define SEC_COFF_SHARED 0x8000000 + + /* Indicate that section has the purecode flag set. */ +#define SEC_ELF_PURECODE 0x8000000 + + /* When a section with this flag is being linked, then if the size of + the input section is less than a page, it should not cross a page + boundary. If the size of the input section is one page or more, + it should be aligned on a page boundary. This is for TI + TMS320C54X only. */ +#define SEC_TIC54X_BLOCK 0x10000000 + + /* This section has the SHF_X86_64_LARGE flag. This is ELF x86-64 only. */ +#define SEC_ELF_LARGE 0x10000000 + + /* Conditionally link this section; do not link if there are no + references found to any symbol in the section. This is for TI + TMS320C54X only. */ +#define SEC_TIC54X_CLINK 0x20000000 + + /* This section contains vliw code. This is for Toshiba MeP only. */ +#define SEC_MEP_VLIW 0x20000000 + + /* All symbols, sizes and relocations in this section are octets + instead of bytes. Required for DWARF debug sections as DWARF + information is organized in octets, not bytes. */ +#define SEC_ELF_OCTETS 0x40000000 + + /* Indicate that section has the no read flag set. This happens + when memory read flag isn't set. */ +#define SEC_COFF_NOREAD 0x40000000 + + /* End of section flags. */ + + /* Some internal packed boolean fields. */ + + /* See the vma field. */ + unsigned int user_set_vma : 1; + + /* A mark flag used by some of the linker backends. */ + unsigned int linker_mark : 1; + + /* Another mark flag used by some of the linker backends. Set for + output sections that have an input section. */ + unsigned int linker_has_input : 1; + + /* Mark flag used by some linker backends for garbage collection. */ + unsigned int gc_mark : 1; + + /* Section compression status. */ + unsigned int compress_status : 2; +#define COMPRESS_SECTION_NONE 0 +#define COMPRESS_SECTION_DONE 1 +#define DECOMPRESS_SECTION_ZLIB 2 +#define DECOMPRESS_SECTION_ZSTD 3 + + /* The following flags are used by the ELF linker. */ + + /* Mark sections which have been allocated to segments. */ + unsigned int segment_mark : 1; + + /* Type of sec_info information. */ + unsigned int sec_info_type:3; +#define SEC_INFO_TYPE_NONE 0 +#define SEC_INFO_TYPE_STABS 1 +#define SEC_INFO_TYPE_MERGE 2 +#define SEC_INFO_TYPE_EH_FRAME 3 +#define SEC_INFO_TYPE_JUST_SYMS 4 +#define SEC_INFO_TYPE_TARGET 5 +#define SEC_INFO_TYPE_EH_FRAME_ENTRY 6 +#define SEC_INFO_TYPE_SFRAME 7 + + /* Nonzero if this section uses RELA relocations, rather than REL. */ + unsigned int use_rela_p:1; + + /* Nonzero if section contents are mmapped. */ + unsigned int mmapped_p:1; + + /* Nonzero if section contents should not be freed. */ + unsigned int alloced:1; + + /* Bits used by various backends. The generic code doesn't touch + these fields. */ + + unsigned int sec_flg0:1; + unsigned int sec_flg1:1; + unsigned int sec_flg2:1; + unsigned int sec_flg3:1; + unsigned int sec_flg4:1; + unsigned int sec_flg5:1; + + /* End of internal packed boolean fields. */ + + /* The virtual memory address of the section - where it will be + at run time. The symbols are relocated against this. The + user_set_vma flag is maintained by bfd; if it's not set, the + backend can assign addresses (for example, in <>, where + the default address for <<.data>> is dependent on the specific + target and various flags). */ + bfd_vma vma; + + /* The load address of the section - where it would be in a + rom image; really only used for writing section header + information. */ + bfd_vma lma; + + /* The size of the section in *octets*, as it will be output. + Contains a value even if the section has no contents (e.g., the + size of <<.bss>>). */ + bfd_size_type size; + + /* For input sections, the original size on disk of the section, in + octets. This field should be set for any section whose size is + changed by linker relaxation. It is required for sections where + the linker relaxation scheme doesn't cache altered section and + reloc contents (stabs, eh_frame, SEC_MERGE, some coff relaxing + targets), and thus the original size needs to be kept to read the + section multiple times. For output sections, rawsize holds the + section size calculated on a previous linker relaxation pass. */ + bfd_size_type rawsize; + + /* The compressed size of the section in octets. */ + bfd_size_type compressed_size; + + /* If this section is going to be output, then this value is the + offset in *bytes* into the output section of the first byte in the + input section (byte ==> smallest addressable unit on the + target). In most cases, if this was going to start at the + 100th octet (8-bit quantity) in the output section, this value + would be 100. However, if the target byte size is 16 bits + (bfd_octets_per_byte is "2"), this value would be 50. */ + bfd_vma output_offset; + + /* The output section through which to map on output. */ + struct bfd_section *output_section; + + /* If an input section, a pointer to a vector of relocation + records for the data in this section. */ + struct reloc_cache_entry *relocation; + + /* If an output section, a pointer to a vector of pointers to + relocation records for the data in this section. */ + struct reloc_cache_entry **orelocation; + + /* The number of relocation records in one of the above. */ + unsigned reloc_count; + + /* The alignment requirement of the section, as an exponent of 2 - + e.g., 3 aligns to 2^3 (or 8). */ + unsigned int alignment_power; + + /* Information below is back end specific - and not always used + or updated. */ + + /* File position of section data. */ + file_ptr filepos; + + /* File position of relocation info. */ + file_ptr rel_filepos; + + /* File position of line data. */ + file_ptr line_filepos; + + /* Pointer to data for applications. */ + void *userdata; + + /* If the SEC_IN_MEMORY flag is set, this points to the actual + contents. */ + bfd_byte *contents; + + /* Attached line number information. */ + alent *lineno; + + /* Number of line number records. */ + unsigned int lineno_count; + + /* Entity size for merging purposes. */ + unsigned int entsize; + + /* Points to the kept section if this section is a link-once section, + and is discarded. */ + struct bfd_section *kept_section; + + /* When a section is being output, this value changes as more + linenumbers are written out. */ + file_ptr moving_line_filepos; + + /* What the section number is in the target world. */ + int target_index; + + void *used_by_bfd; + + /* If this is a constructor section then here is a list of the + relocations created to relocate items within it. */ + struct relent_chain *constructor_chain; + + /* The BFD which owns the section. */ + bfd *owner; + + /* A symbol which points at this section only. */ + struct bfd_symbol *symbol; + + /* Early in the link process, map_head and map_tail are used to build + a list of input sections attached to an output section. Later, + output sections use these fields for a list of bfd_link_order + structs. The linked_to_symbol_name field is for ELF assembler + internal use. */ + union { + struct bfd_link_order *link_order; + struct bfd_section *s; + const char *linked_to_symbol_name; + } map_head, map_tail; + + /* Points to the output section this section is already assigned to, + if any. This is used when support for non-contiguous memory + regions is enabled. */ + struct bfd_section *already_assigned; + + /* Explicitly specified section type, if non-zero. */ + unsigned int type; + +} asection; + +static inline const char * +bfd_section_name (const asection *sec) +{ + return sec->name; +} + +static inline bfd_size_type +bfd_section_size (const asection *sec) +{ + return sec->size; +} + +static inline bfd_vma +bfd_section_vma (const asection *sec) +{ + return sec->vma; +} + +static inline bfd_vma +bfd_section_lma (const asection *sec) +{ + return sec->lma; +} + +static inline unsigned int +bfd_section_alignment (const asection *sec) +{ + return sec->alignment_power; +} + +static inline flagword +bfd_section_flags (const asection *sec) +{ + return sec->flags; +} + +static inline void * +bfd_section_userdata (const asection *sec) +{ + return sec->userdata; +} +static inline bool +bfd_is_com_section (const asection *sec) +{ + return (sec->flags & SEC_IS_COMMON) != 0; +} + +/* Note: the following are provided as inline functions rather than macros + because not all callers use the return value. A macro implementation + would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some + compilers will complain about comma expressions that have no effect. */ +static inline bool +bfd_set_section_userdata (asection *sec, void *val) +{ + sec->userdata = val; + return true; +} + +static inline bool +bfd_set_section_vma (asection *sec, bfd_vma val) +{ + sec->vma = sec->lma = val; + sec->user_set_vma = true; + return true; +} + +static inline bool +bfd_set_section_lma (asection *sec, bfd_vma val) +{ + sec->lma = val; + return true; +} + +static inline bool +bfd_set_section_alignment (asection *sec, unsigned int val) +{ + if (val >= sizeof (bfd_vma) * 8 - 1) + return false; + sec->alignment_power = val; + return true; +} + +/* These sections are global, and are managed by BFD. The application + and target back end are not permitted to change the values in + these sections. */ +extern asection _bfd_std_section[4]; + +#define BFD_ABS_SECTION_NAME "*ABS*" +#define BFD_UND_SECTION_NAME "*UND*" +#define BFD_COM_SECTION_NAME "*COM*" +#define BFD_IND_SECTION_NAME "*IND*" + +/* GNU object-only section name. */ +#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" + +/* Pointer to the common section. */ +#define bfd_com_section_ptr (&_bfd_std_section[0]) +/* Pointer to the undefined section. */ +#define bfd_und_section_ptr (&_bfd_std_section[1]) +/* Pointer to the absolute section. */ +#define bfd_abs_section_ptr (&_bfd_std_section[2]) +/* Pointer to the indirect section. */ +#define bfd_ind_section_ptr (&_bfd_std_section[3]) + +static inline bool +bfd_is_und_section (const asection *sec) +{ + return sec == bfd_und_section_ptr; +} + +static inline bool +bfd_is_abs_section (const asection *sec) +{ + return sec == bfd_abs_section_ptr; +} + +static inline bool +bfd_is_ind_section (const asection *sec) +{ + return sec == bfd_ind_section_ptr; +} + +static inline bool +bfd_is_const_section (const asection *sec) +{ + return (sec >= _bfd_std_section + && sec < _bfd_std_section + (sizeof (_bfd_std_section) + / sizeof (_bfd_std_section[0]))); +} + +/* Return TRUE if input section SEC has been discarded. */ +static inline bool +discarded_section (const asection *sec) +{ + return (!bfd_is_abs_section (sec) + && bfd_is_abs_section (sec->output_section) + && sec->sec_info_type != SEC_INFO_TYPE_MERGE + && sec->sec_info_type != SEC_INFO_TYPE_JUST_SYMS); +} + +void bfd_section_list_clear (bfd *); + +asection *bfd_get_section_by_name (bfd *abfd, const char *name); + +asection *bfd_get_next_section_by_name (bfd *ibfd, asection *sec); + +asection *bfd_get_linker_section (bfd *abfd, const char *name); + +asection *bfd_get_section_by_name_if + (bfd *abfd, + const char *name, + bool (*func) (bfd *abfd, asection *sect, void *obj), + void *obj); + +char *bfd_get_unique_section_name + (bfd *abfd, const char *templat, int *count); + +asection *bfd_make_section_old_way (bfd *abfd, const char *name); + +asection *bfd_make_section_anyway_with_flags + (bfd *abfd, const char *name, flagword flags); + +asection *bfd_make_section_anyway (bfd *abfd, const char *name); + +asection *bfd_make_section_with_flags + (bfd *, const char *name, flagword flags); + +asection *bfd_make_section (bfd *, const char *name); + +bool bfd_set_section_flags (asection *sec, flagword flags); + +void bfd_rename_section + (asection *sec, const char *newname); + +void bfd_map_over_sections + (bfd *abfd, + void (*func) (bfd *abfd, asection *sect, void *obj), + void *obj); + +asection *bfd_sections_find_if + (bfd *abfd, + bool (*operation) (bfd *abfd, asection *sect, void *obj), + void *obj); + +bool bfd_set_section_size (asection *sec, bfd_size_type val); + +bool bfd_set_section_contents + (bfd *abfd, asection *section, const void *data, + file_ptr offset, bfd_size_type count); + +bool bfd_get_section_contents + (bfd *abfd, asection *section, void *location, file_ptr offset, + bfd_size_type count); + +bool bfd_malloc_and_get_section + (bfd *abfd, asection *section, bfd_byte **buf); + +bool bfd_copy_private_section_data + (bfd *ibfd, asection *isec, bfd *obfd, asection *osec, + struct bfd_link_info *link_info); + +#define bfd_copy_private_section_data(ibfd, isec, obfd, osec, link_info) \ + BFD_SEND (obfd, _bfd_copy_private_section_data, \ + (ibfd, isec, obfd, osec, link_info)) +bool bfd_generic_is_group_section (bfd *, const asection *sec); + +const char *bfd_generic_group_name (bfd *, const asection *sec); + +bool bfd_generic_discard_group (bfd *abfd, asection *group); + +bool bfd_section_size_insane (bfd *abfd, asection *sec); + +/* Extracted from syms.c. */ +typedef struct bfd_symbol +{ + /* A pointer to the BFD which owns the symbol. This information + is necessary so that a back end can work out what additional + information (invisible to the application writer) is carried + with the symbol. + + This field is *almost* redundant, since you can use section->owner + instead, except that some symbols point to the global sections + bfd_{abs,com,und}_section. This could be fixed by making + these globals be per-bfd (or per-target-flavor). FIXME. */ + struct bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ + + /* The text of the symbol. The name is left alone, and not copied; the + application may not alter it. */ + const char *name; + + /* The value of the symbol. This really should be a union of a + numeric value with a pointer, since some flags indicate that + a pointer to another symbol is stored here. */ + symvalue value; + + /* Attributes of a symbol. */ +#define BSF_NO_FLAGS 0 + + /* The symbol has local scope; <> in <>. The value + is the offset into the section of the data. */ +#define BSF_LOCAL (1 << 0) + + /* The symbol has global scope; initialized data in <>. The + value is the offset into the section of the data. */ +#define BSF_GLOBAL (1 << 1) + + /* The symbol has global scope and is exported. The value is + the offset into the section of the data. */ +#define BSF_EXPORT BSF_GLOBAL /* No real difference. */ + + /* A normal C symbol would be one of: + <>, <> or <>. */ + + /* The symbol is a debugging record. The value has an arbitrary + meaning, unless BSF_DEBUGGING_RELOC is also set. */ +#define BSF_DEBUGGING (1 << 2) + + /* The symbol denotes a function entry point. Used in ELF, + perhaps others someday. */ +#define BSF_FUNCTION (1 << 3) + + /* Used by the linker. */ +#define BSF_KEEP (1 << 5) + + /* An ELF common symbol. */ +#define BSF_ELF_COMMON (1 << 6) + + /* A weak global symbol, overridable without warnings by + a regular global symbol of the same name. */ +#define BSF_WEAK (1 << 7) + + /* This symbol was created to point to a section, e.g. ELF's + STT_SECTION symbols. */ +#define BSF_SECTION_SYM (1 << 8) + + /* The symbol used to be a common symbol, but now it is + allocated. */ +#define BSF_OLD_COMMON (1 << 9) + + /* In some files the type of a symbol sometimes alters its + location in an output file - ie in coff a <> symbol + which is also <> symbol appears where it was + declared and not at the end of a section. This bit is set + by the target BFD part to convey this information. */ +#define BSF_NOT_AT_END (1 << 10) + + /* Signal that the symbol is the label of constructor section. */ +#define BSF_CONSTRUCTOR (1 << 11) + + /* Signal that the symbol is a warning symbol. The name is a + warning. The name of the next symbol is the one to warn about; + if a reference is made to a symbol with the same name as the next + symbol, a warning is issued by the linker. */ +#define BSF_WARNING (1 << 12) + + /* Signal that the symbol is indirect. This symbol is an indirect + pointer to the symbol with the same name as the next symbol. */ +#define BSF_INDIRECT (1 << 13) + + /* BSF_FILE marks symbols that contain a file name. This is used + for ELF STT_FILE symbols. */ +#define BSF_FILE (1 << 14) + + /* Symbol is from dynamic linking information. */ +#define BSF_DYNAMIC (1 << 15) + + /* The symbol denotes a data object. Used in ELF, and perhaps + others someday. */ +#define BSF_OBJECT (1 << 16) + + /* This symbol is a debugging symbol. The value is the offset + into the section of the data. BSF_DEBUGGING should be set + as well. */ +#define BSF_DEBUGGING_RELOC (1 << 17) + + /* This symbol is thread local. Used in ELF. */ +#define BSF_THREAD_LOCAL (1 << 18) + + /* This symbol represents a complex relocation expression, + with the expression tree serialized in the symbol name. */ +#define BSF_RELC (1 << 19) + + /* This symbol represents a signed complex relocation expression, + with the expression tree serialized in the symbol name. */ +#define BSF_SRELC (1 << 20) + + /* This symbol was created by bfd_get_synthetic_symtab. */ +#define BSF_SYNTHETIC (1 << 21) + + /* This symbol is an indirect code object. Unrelated to BSF_INDIRECT. + The dynamic linker will compute the value of this symbol by + calling the function that it points to. BSF_FUNCTION must + also be also set. */ +#define BSF_GNU_INDIRECT_FUNCTION (1 << 22) + /* This symbol is a globally unique data object. The dynamic linker + will make sure that in the entire process there is just one symbol + with this name and type in use. BSF_OBJECT must also be set. */ +#define BSF_GNU_UNIQUE (1 << 23) + + /* This section symbol should be included in the symbol table. */ +#define BSF_SECTION_SYM_USED (1 << 24) + + flagword flags; + + /* A pointer to the section to which this symbol is + relative. This will always be non NULL, there are special + sections for undefined and absolute symbols. */ + struct bfd_section *section; + + /* Back end special data. */ + union + { + void *p; + bfd_vma i; + } + udata; +} +asymbol; + +typedef enum bfd_print_symbol +{ + bfd_print_symbol_name, + bfd_print_symbol_more, + bfd_print_symbol_all +} bfd_print_symbol_type; + +/* Information about a symbol that nm needs. */ + +typedef struct _symbol_info +{ + symvalue value; + char type; + const char *name; /* Symbol name. */ + unsigned char stab_type; /* Stab type. */ + char stab_other; /* Stab other. */ + short stab_desc; /* Stab desc. */ + const char *stab_name; /* String for stab type. */ +} symbol_info; + +/* An empty string that will not match the address of any other + symbol name, even unnamed local symbols which will also have empty + string names. This can be used to flag a symbol as corrupt if its + name uses an out of range string table index. */ +extern const char bfd_symbol_error_name[]; +#define bfd_get_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) + +bool bfd_is_local_label (bfd *abfd, asymbol *sym); + +bool bfd_is_local_label_name (bfd *abfd, const char *name); + +#define bfd_is_local_label_name(abfd, name) \ + BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) + +bool bfd_is_target_special_symbol (bfd *abfd, asymbol *sym); + +#define bfd_is_target_special_symbol(abfd, sym) \ + BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym)) + +#define bfd_canonicalize_symtab(abfd, location) \ + BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location)) + +bool bfd_set_symtab + (bfd *abfd, asymbol **location, unsigned int count); + +void bfd_print_symbol_vandf (bfd *abfd, void *file, asymbol *symbol); + +#define bfd_make_empty_symbol(abfd) \ + BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) + +asymbol *_bfd_generic_make_empty_symbol (bfd *); + +#define bfd_make_debug_symbol(abfd) \ + BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd)) + +int bfd_decode_symclass (asymbol *symbol); + +bool bfd_is_undefined_symclass (int symclass); + +void bfd_symbol_info (asymbol *symbol, symbol_info *ret); + +bool bfd_copy_private_symbol_data + (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); + +#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ + BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ + (ibfd, isymbol, obfd, osymbol)) + +/* Extracted from archive.c. */ +/* A canonical archive symbol. */ +/* This is a type pun with struct symdef/struct ranlib on purpose! */ +typedef struct carsym +{ + const char *name; + file_ptr file_offset; /* Look here to find the file. */ +} +carsym; + +/* A count of carsyms (canonical archive symbols). */ + typedef unsigned long symindex; +#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) + +symindex bfd_get_next_mapent + (bfd *abfd, symindex previous, carsym **sym); + +bool bfd_set_archive_head (bfd *output, bfd *new_head); + +bfd *bfd_openr_next_archived_file (bfd *archive, bfd *previous); + +/* Extracted from archures.c. */ +enum bfd_architecture +{ + bfd_arch_unknown, /* File arch not known. */ + bfd_arch_obscure, /* Arch known, not one of these. */ + bfd_arch_m68k, /* Motorola 68xxx. */ +#define bfd_mach_m68000 1 +#define bfd_mach_m68008 2 +#define bfd_mach_m68010 3 +#define bfd_mach_m68020 4 +#define bfd_mach_m68030 5 +#define bfd_mach_m68040 6 +#define bfd_mach_m68060 7 +#define bfd_mach_cpu32 8 +#define bfd_mach_fido 9 +#define bfd_mach_mcf_isa_a_nodiv 10 +#define bfd_mach_mcf_isa_a 11 +#define bfd_mach_mcf_isa_a_mac 12 +#define bfd_mach_mcf_isa_a_emac 13 +#define bfd_mach_mcf_isa_aplus 14 +#define bfd_mach_mcf_isa_aplus_mac 15 +#define bfd_mach_mcf_isa_aplus_emac 16 +#define bfd_mach_mcf_isa_b_nousp 17 +#define bfd_mach_mcf_isa_b_nousp_mac 18 +#define bfd_mach_mcf_isa_b_nousp_emac 19 +#define bfd_mach_mcf_isa_b 20 +#define bfd_mach_mcf_isa_b_mac 21 +#define bfd_mach_mcf_isa_b_emac 22 +#define bfd_mach_mcf_isa_b_float 23 +#define bfd_mach_mcf_isa_b_float_mac 24 +#define bfd_mach_mcf_isa_b_float_emac 25 +#define bfd_mach_mcf_isa_c 26 +#define bfd_mach_mcf_isa_c_mac 27 +#define bfd_mach_mcf_isa_c_emac 28 +#define bfd_mach_mcf_isa_c_nodiv 29 +#define bfd_mach_mcf_isa_c_nodiv_mac 30 +#define bfd_mach_mcf_isa_c_nodiv_emac 31 + bfd_arch_vax, /* DEC Vax. */ + + bfd_arch_or1k, /* OpenRISC 1000. */ +#define bfd_mach_or1k 1 +#define bfd_mach_or1knd 2 + + bfd_arch_sparc, /* SPARC. */ +#define bfd_mach_sparc 1 +/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ +#define bfd_mach_sparc_sparclet 2 +#define bfd_mach_sparc_sparclite 3 +#define bfd_mach_sparc_v8plus 4 +#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns. */ +#define bfd_mach_sparc_sparclite_le 6 +#define bfd_mach_sparc_v9 7 +#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns. */ +#define bfd_mach_sparc_v8plusb 9 /* with cheetah add'ns. */ +#define bfd_mach_sparc_v9b 10 /* with cheetah add'ns. */ +#define bfd_mach_sparc_v8plusc 11 /* with UA2005 and T1 add'ns. */ +#define bfd_mach_sparc_v9c 12 /* with UA2005 and T1 add'ns. */ +#define bfd_mach_sparc_v8plusd 13 /* with UA2007 and T3 add'ns. */ +#define bfd_mach_sparc_v9d 14 /* with UA2007 and T3 add'ns. */ +#define bfd_mach_sparc_v8pluse 15 /* with OSA2001 and T4 add'ns (no IMA). */ +#define bfd_mach_sparc_v9e 16 /* with OSA2001 and T4 add'ns (no IMA). */ +#define bfd_mach_sparc_v8plusv 17 /* with OSA2011 and T4 and IMA and FJMAU add'ns. */ +#define bfd_mach_sparc_v9v 18 /* with OSA2011 and T4 and IMA and FJMAU add'ns. */ +#define bfd_mach_sparc_v8plusm 19 /* with OSA2015 and M7 add'ns. */ +#define bfd_mach_sparc_v9m 20 /* with OSA2015 and M7 add'ns. */ +#define bfd_mach_sparc_v8plusm8 21 /* with OSA2017 and M8 add'ns. */ +#define bfd_mach_sparc_v9m8 22 /* with OSA2017 and M8 add'ns. */ +/* Nonzero if MACH has the v9 instruction set. */ +#define bfd_mach_sparc_v9_p(mach) \ + ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9m8 \ + && (mach) != bfd_mach_sparc_sparclite_le) +/* Nonzero if MACH is a 64 bit sparc architecture. */ +#define bfd_mach_sparc_64bit_p(mach) \ + ((mach) >= bfd_mach_sparc_v9 \ + && (mach) != bfd_mach_sparc_v8plusb \ + && (mach) != bfd_mach_sparc_v8plusc \ + && (mach) != bfd_mach_sparc_v8plusd \ + && (mach) != bfd_mach_sparc_v8pluse \ + && (mach) != bfd_mach_sparc_v8plusv \ + && (mach) != bfd_mach_sparc_v8plusm \ + && (mach) != bfd_mach_sparc_v8plusm8) + bfd_arch_spu, /* PowerPC SPU. */ +#define bfd_mach_spu 256 + bfd_arch_mips, /* MIPS Rxxxx. */ +#define bfd_mach_mips3000 3000 +#define bfd_mach_mips3900 3900 +#define bfd_mach_mips4000 4000 +#define bfd_mach_mips4010 4010 +#define bfd_mach_mips4100 4100 +#define bfd_mach_mips4111 4111 +#define bfd_mach_mips4120 4120 +#define bfd_mach_mips4300 4300 +#define bfd_mach_mips4400 4400 +#define bfd_mach_mips4600 4600 +#define bfd_mach_mips4650 4650 +#define bfd_mach_mips5000 5000 +#define bfd_mach_mips5400 5400 +#define bfd_mach_mips5500 5500 +#define bfd_mach_mips5900 5900 +#define bfd_mach_mips6000 6000 +#define bfd_mach_mips7000 7000 +#define bfd_mach_mips8000 8000 +#define bfd_mach_mips9000 9000 +#define bfd_mach_mips10000 10000 +#define bfd_mach_mips12000 12000 +#define bfd_mach_mips14000 14000 +#define bfd_mach_mips16000 16000 +#define bfd_mach_mips16 16 +#define bfd_mach_mips5 5 +#define bfd_mach_mips_allegrex 10111431 /* octal 'AL', 31. */ +#define bfd_mach_mips_loongson_2e 3001 +#define bfd_mach_mips_loongson_2f 3002 +#define bfd_mach_mips_gs464 3003 +#define bfd_mach_mips_gs464e 3004 +#define bfd_mach_mips_gs264e 3005 +#define bfd_mach_mips_sb1 12310201 /* octal 'SB', 01. */ +#define bfd_mach_mips_octeon 6501 +#define bfd_mach_mips_octeonp 6601 +#define bfd_mach_mips_octeon2 6502 +#define bfd_mach_mips_octeon3 6503 +#define bfd_mach_mips_xlr 887682 /* decimal 'XLR'. */ +#define bfd_mach_mips_interaptiv_mr2 736550 /* decimal 'IA2'. */ +#define bfd_mach_mipsisa32 32 +#define bfd_mach_mipsisa32r2 33 +#define bfd_mach_mipsisa32r3 34 +#define bfd_mach_mipsisa32r5 36 +#define bfd_mach_mipsisa32r6 37 +#define bfd_mach_mipsisa64 64 +#define bfd_mach_mipsisa64r2 65 +#define bfd_mach_mipsisa64r3 66 +#define bfd_mach_mipsisa64r5 68 +#define bfd_mach_mipsisa64r6 69 +#define bfd_mach_mips_micromips 96 + bfd_arch_i386, /* Intel 386. */ +#define bfd_mach_i386_intel_syntax (1 << 0) +#define bfd_mach_i386_i8086 (1 << 1) +#define bfd_mach_i386_i386 (1 << 2) +#define bfd_mach_x86_64 (1 << 3) +#define bfd_mach_x64_32 (1 << 4) +#define bfd_mach_i386_i386_intel_syntax (bfd_mach_i386_i386 | bfd_mach_i386_intel_syntax) +#define bfd_mach_x86_64_intel_syntax (bfd_mach_x86_64 | bfd_mach_i386_intel_syntax) +#define bfd_mach_x64_32_intel_syntax (bfd_mach_x64_32 | bfd_mach_i386_intel_syntax) + bfd_arch_iamcu, /* Intel MCU. */ +#define bfd_mach_iamcu (1 << 8) +#define bfd_mach_i386_iamcu (bfd_mach_i386_i386 | bfd_mach_iamcu) +#define bfd_mach_i386_iamcu_intel_syntax (bfd_mach_i386_iamcu | bfd_mach_i386_intel_syntax) + bfd_arch_romp, /* IBM ROMP PC/RT. */ + bfd_arch_convex, /* Convex. */ + bfd_arch_m98k, /* Motorola 98xxx. */ + bfd_arch_pyramid, /* Pyramid Technology. */ + bfd_arch_h8300, /* Renesas H8/300 (formerly Hitachi H8/300). */ +#define bfd_mach_h8300 1 +#define bfd_mach_h8300h 2 +#define bfd_mach_h8300s 3 +#define bfd_mach_h8300hn 4 +#define bfd_mach_h8300sn 5 +#define bfd_mach_h8300sx 6 +#define bfd_mach_h8300sxn 7 + bfd_arch_pdp11, /* DEC PDP-11. */ + bfd_arch_powerpc, /* PowerPC. */ +#define bfd_mach_ppc 32 +#define bfd_mach_ppc64 64 +#define bfd_mach_ppc_403 403 +#define bfd_mach_ppc_403gc 4030 +#define bfd_mach_ppc_405 405 +#define bfd_mach_ppc_505 505 +#define bfd_mach_ppc_601 601 +#define bfd_mach_ppc_602 602 +#define bfd_mach_ppc_603 603 +#define bfd_mach_ppc_ec603e 6031 +#define bfd_mach_ppc_604 604 +#define bfd_mach_ppc_620 620 +#define bfd_mach_ppc_630 630 +#define bfd_mach_ppc_750 750 +#define bfd_mach_ppc_860 860 +#define bfd_mach_ppc_a35 35 +#define bfd_mach_ppc_rs64ii 642 +#define bfd_mach_ppc_rs64iii 643 +#define bfd_mach_ppc_7400 7400 +#define bfd_mach_ppc_e500 500 +#define bfd_mach_ppc_e500mc 5001 +#define bfd_mach_ppc_e500mc64 5005 +#define bfd_mach_ppc_e5500 5006 +#define bfd_mach_ppc_e6500 5007 +#define bfd_mach_ppc_titan 83 +#define bfd_mach_ppc_vle 84 + bfd_arch_rs6000, /* IBM RS/6000. */ +#define bfd_mach_rs6k 6000 +#define bfd_mach_rs6k_rs1 6001 +#define bfd_mach_rs6k_rsc 6003 +#define bfd_mach_rs6k_rs2 6002 + bfd_arch_hppa, /* HP PA RISC. */ +#define bfd_mach_hppa10 10 +#define bfd_mach_hppa11 11 +#define bfd_mach_hppa20 20 +#define bfd_mach_hppa20w 25 + bfd_arch_d10v, /* Mitsubishi D10V. */ +#define bfd_mach_d10v 1 +#define bfd_mach_d10v_ts2 2 +#define bfd_mach_d10v_ts3 3 + bfd_arch_d30v, /* Mitsubishi D30V. */ + bfd_arch_dlx, /* DLX. */ + bfd_arch_m68hc11, /* Motorola 68HC11. */ + bfd_arch_m68hc12, /* Motorola 68HC12. */ +#define bfd_mach_m6812_default 0 +#define bfd_mach_m6812 1 +#define bfd_mach_m6812s 2 + bfd_arch_m9s12x, /* Freescale S12X. */ + bfd_arch_m9s12xg, /* Freescale XGATE. */ + bfd_arch_s12z, /* Freescale S12Z. */ +#define bfd_mach_s12z_default 0 + bfd_arch_z8k, /* Zilog Z8000. */ +#define bfd_mach_z8001 1 +#define bfd_mach_z8002 2 + bfd_arch_sh, /* Renesas / SuperH SH (formerly Hitachi SH). */ +#define bfd_mach_sh 1 +#define bfd_mach_sh2 0x20 +#define bfd_mach_sh_dsp 0x2d +#define bfd_mach_sh2a 0x2a +#define bfd_mach_sh2a_nofpu 0x2b +#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1 +#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2 +#define bfd_mach_sh2a_or_sh4 0x2a3 +#define bfd_mach_sh2a_or_sh3e 0x2a4 +#define bfd_mach_sh2e 0x2e +#define bfd_mach_sh3 0x30 +#define bfd_mach_sh3_nommu 0x31 +#define bfd_mach_sh3_dsp 0x3d +#define bfd_mach_sh3e 0x3e +#define bfd_mach_sh4 0x40 +#define bfd_mach_sh4_nofpu 0x41 +#define bfd_mach_sh4_nommu_nofpu 0x42 +#define bfd_mach_sh4a 0x4a +#define bfd_mach_sh4a_nofpu 0x4b +#define bfd_mach_sh4al_dsp 0x4d + bfd_arch_alpha, /* Dec Alpha. */ +#define bfd_mach_alpha_ev4 0x10 +#define bfd_mach_alpha_ev5 0x20 +#define bfd_mach_alpha_ev6 0x30 + bfd_arch_arm, /* Advanced Risc Machines ARM. */ +#define bfd_mach_arm_unknown 0 +#define bfd_mach_arm_2 1 +#define bfd_mach_arm_2a 2 +#define bfd_mach_arm_3 3 +#define bfd_mach_arm_3M 4 +#define bfd_mach_arm_4 5 +#define bfd_mach_arm_4T 6 +#define bfd_mach_arm_5 7 +#define bfd_mach_arm_5T 8 +#define bfd_mach_arm_5TE 9 +#define bfd_mach_arm_XScale 10 +#define bfd_mach_arm_ep9312 11 +#define bfd_mach_arm_iWMMXt 12 +#define bfd_mach_arm_iWMMXt2 13 +#define bfd_mach_arm_5TEJ 14 +#define bfd_mach_arm_6 15 +#define bfd_mach_arm_6KZ 16 +#define bfd_mach_arm_6T2 17 +#define bfd_mach_arm_6K 18 +#define bfd_mach_arm_7 19 +#define bfd_mach_arm_6M 20 +#define bfd_mach_arm_6SM 21 +#define bfd_mach_arm_7EM 22 +#define bfd_mach_arm_8 23 +#define bfd_mach_arm_8R 24 +#define bfd_mach_arm_8M_BASE 25 +#define bfd_mach_arm_8M_MAIN 26 +#define bfd_mach_arm_8_1M_MAIN 27 +#define bfd_mach_arm_9 28 + bfd_arch_nds32, /* Andes NDS32. */ +#define bfd_mach_n1 1 +#define bfd_mach_n1h 2 +#define bfd_mach_n1h_v2 3 +#define bfd_mach_n1h_v3 4 +#define bfd_mach_n1h_v3m 5 + bfd_arch_ns32k, /* National Semiconductors ns32000. */ + bfd_arch_tic30, /* Texas Instruments TMS320C30. */ + bfd_arch_tic4x, /* Texas Instruments TMS320C3X/4X. */ +#define bfd_mach_tic3x 30 +#define bfd_mach_tic4x 40 + bfd_arch_tic54x, /* Texas Instruments TMS320C54X. */ + bfd_arch_tic6x, /* Texas Instruments TMS320C6X. */ + bfd_arch_v850, /* NEC V850. */ + bfd_arch_v850_rh850,/* NEC V850 (using RH850 ABI). */ +#define bfd_mach_v850 1 +#define bfd_mach_v850e 'E' +#define bfd_mach_v850e1 '1' +#define bfd_mach_v850e2 0x4532 +#define bfd_mach_v850e2v3 0x45325633 +#define bfd_mach_v850e3v5 0x45335635 /* ('E'|'3'|'V'|'5'). */ + bfd_arch_arc, /* ARC Cores. */ +#define bfd_mach_arc_a4 0 +#define bfd_mach_arc_a5 1 +#define bfd_mach_arc_arc600 2 +#define bfd_mach_arc_arc601 4 +#define bfd_mach_arc_arc700 3 +#define bfd_mach_arc_arcv2 5 + bfd_arch_m32c, /* Renesas M16C/M32C. */ +#define bfd_mach_m16c 0x75 +#define bfd_mach_m32c 0x78 + bfd_arch_m32r, /* Renesas M32R (formerly Mitsubishi M32R/D). */ +#define bfd_mach_m32r 1 /* For backwards compatibility. */ +#define bfd_mach_m32rx 'x' +#define bfd_mach_m32r2 '2' + bfd_arch_mn10200, /* Matsushita MN10200. */ + bfd_arch_mn10300, /* Matsushita MN10300. */ +#define bfd_mach_mn10300 300 +#define bfd_mach_am33 330 +#define bfd_mach_am33_2 332 + bfd_arch_fr30, +#define bfd_mach_fr30 0x46523330 + bfd_arch_frv, +#define bfd_mach_frv 1 +#define bfd_mach_frvsimple 2 +#define bfd_mach_fr300 300 +#define bfd_mach_fr400 400 +#define bfd_mach_fr450 450 +#define bfd_mach_frvtomcat 499 /* fr500 prototype. */ +#define bfd_mach_fr500 500 +#define bfd_mach_fr550 550 + bfd_arch_moxie, /* The moxie processor. */ +#define bfd_mach_moxie 1 + bfd_arch_ft32, /* The ft32 processor. */ +#define bfd_mach_ft32 1 +#define bfd_mach_ft32b 2 + bfd_arch_mcore, + bfd_arch_mep, +#define bfd_mach_mep 1 +#define bfd_mach_mep_h1 0x6831 +#define bfd_mach_mep_c5 0x6335 + bfd_arch_metag, +#define bfd_mach_metag 1 + bfd_arch_ia64, /* HP/Intel ia64. */ +#define bfd_mach_ia64_elf64 64 +#define bfd_mach_ia64_elf32 32 + bfd_arch_ip2k, /* Ubicom IP2K microcontrollers. */ +#define bfd_mach_ip2022 1 +#define bfd_mach_ip2022ext 2 + bfd_arch_iq2000, /* Vitesse IQ2000. */ +#define bfd_mach_iq2000 1 +#define bfd_mach_iq10 2 + bfd_arch_bpf, /* Linux eBPF. */ +#define bfd_mach_bpf 1 +#define bfd_mach_xbpf 2 + bfd_arch_epiphany, /* Adapteva EPIPHANY. */ +#define bfd_mach_epiphany16 1 +#define bfd_mach_epiphany32 2 + bfd_arch_mt, +#define bfd_mach_ms1 1 +#define bfd_mach_mrisc2 2 +#define bfd_mach_ms2 3 + bfd_arch_pj, + bfd_arch_avr, /* Atmel AVR microcontrollers. */ +#define bfd_mach_avr1 1 +#define bfd_mach_avr2 2 +#define bfd_mach_avr25 25 +#define bfd_mach_avr3 3 +#define bfd_mach_avr31 31 +#define bfd_mach_avr35 35 +#define bfd_mach_avr4 4 +#define bfd_mach_avr5 5 +#define bfd_mach_avr51 51 +#define bfd_mach_avr6 6 +#define bfd_mach_avrtiny 100 +#define bfd_mach_avrxmega1 101 +#define bfd_mach_avrxmega2 102 +#define bfd_mach_avrxmega3 103 +#define bfd_mach_avrxmega4 104 +#define bfd_mach_avrxmega5 105 +#define bfd_mach_avrxmega6 106 +#define bfd_mach_avrxmega7 107 + bfd_arch_bfin, /* ADI Blackfin. */ +#define bfd_mach_bfin 1 + bfd_arch_cr16, /* National Semiconductor CompactRISC (ie CR16). */ +#define bfd_mach_cr16 1 + bfd_arch_crx, /* National Semiconductor CRX. */ +#define bfd_mach_crx 1 + bfd_arch_cris, /* Axis CRIS. */ +#define bfd_mach_cris_v0_v10 255 +#define bfd_mach_cris_v32 32 +#define bfd_mach_cris_v10_v32 1032 + bfd_arch_riscv, +#define bfd_mach_riscv32 132 +#define bfd_mach_riscv64 164 + bfd_arch_rl78, +#define bfd_mach_rl78 0x75 + bfd_arch_rx, /* Renesas RX. */ +#define bfd_mach_rx 0x75 +#define bfd_mach_rx_v2 0x76 +#define bfd_mach_rx_v3 0x77 + bfd_arch_s390, /* IBM s390. */ +#define bfd_mach_s390_31 31 +#define bfd_mach_s390_64 64 + bfd_arch_score, /* Sunplus score. */ +#define bfd_mach_score3 3 +#define bfd_mach_score7 7 + bfd_arch_mmix, /* Donald Knuth's educational processor. */ + bfd_arch_xstormy16, +#define bfd_mach_xstormy16 1 + bfd_arch_msp430, /* Texas Instruments MSP430 architecture. */ +#define bfd_mach_msp11 11 +#define bfd_mach_msp110 110 +#define bfd_mach_msp12 12 +#define bfd_mach_msp13 13 +#define bfd_mach_msp14 14 +#define bfd_mach_msp15 15 +#define bfd_mach_msp16 16 +#define bfd_mach_msp20 20 +#define bfd_mach_msp21 21 +#define bfd_mach_msp22 22 +#define bfd_mach_msp23 23 +#define bfd_mach_msp24 24 +#define bfd_mach_msp26 26 +#define bfd_mach_msp31 31 +#define bfd_mach_msp32 32 +#define bfd_mach_msp33 33 +#define bfd_mach_msp41 41 +#define bfd_mach_msp42 42 +#define bfd_mach_msp43 43 +#define bfd_mach_msp44 44 +#define bfd_mach_msp430x 45 +#define bfd_mach_msp46 46 +#define bfd_mach_msp47 47 +#define bfd_mach_msp54 54 + bfd_arch_xgate, /* Freescale XGATE. */ +#define bfd_mach_xgate 1 + bfd_arch_xtensa, /* Tensilica's Xtensa cores. */ +#define bfd_mach_xtensa 1 + bfd_arch_z80, +/* Zilog Z80 without undocumented opcodes. */ +#define bfd_mach_z80strict 1 +/* Zilog Z180: successor with additional instructions, but without + halves of ix and iy. */ +#define bfd_mach_z180 2 +/* Zilog Z80 with ixl, ixh, iyl, and iyh. */ +#define bfd_mach_z80 3 +/* Zilog eZ80 (successor of Z80 & Z180) in Z80 (16-bit address) mode. */ +#define bfd_mach_ez80_z80 4 +/* Zilog eZ80 (successor of Z80 & Z180) in ADL (24-bit address) mode. */ +#define bfd_mach_ez80_adl 5 +/* Z80N */ +#define bfd_mach_z80n 6 +/* Zilog Z80 with all undocumented instructions. */ +#define bfd_mach_z80full 7 +/* GameBoy Z80 (reduced instruction set). */ +#define bfd_mach_gbz80 8 +/* ASCII R800: successor with multiplication. */ +#define bfd_mach_r800 11 + bfd_arch_lm32, /* Lattice Mico32. */ +#define bfd_mach_lm32 1 + bfd_arch_microblaze,/* Xilinx MicroBlaze. */ + bfd_arch_kvx, /* Kalray VLIW core of the MPPA processor family */ +#define bfd_mach_kv3_unknown 0 +#define bfd_mach_kv3_1 1 +#define bfd_mach_kv3_1_64 2 +#define bfd_mach_kv3_1_usr 3 +#define bfd_mach_kv3_2 4 +#define bfd_mach_kv3_2_64 5 +#define bfd_mach_kv3_2_usr 6 +#define bfd_mach_kv4_1 7 +#define bfd_mach_kv4_1_64 8 +#define bfd_mach_kv4_1_usr 9 + bfd_arch_tilepro, /* Tilera TILEPro. */ + bfd_arch_tilegx, /* Tilera TILE-Gx. */ +#define bfd_mach_tilepro 1 +#define bfd_mach_tilegx 1 +#define bfd_mach_tilegx32 2 + bfd_arch_aarch64, /* AArch64. */ +#define bfd_mach_aarch64 0 +#define bfd_mach_aarch64_8R 1 +#define bfd_mach_aarch64_ilp32 32 +#define bfd_mach_aarch64_llp64 64 + bfd_arch_visium, /* Visium. */ +#define bfd_mach_visium 1 + bfd_arch_wasm32, /* WebAssembly. */ +#define bfd_mach_wasm32 1 + bfd_arch_pru, /* PRU. */ +#define bfd_mach_pru 0 + bfd_arch_nfp, /* Netronome Flow Processor */ +#define bfd_mach_nfp3200 0x3200 +#define bfd_mach_nfp6000 0x6000 + bfd_arch_csky, /* C-SKY. */ +#define bfd_mach_ck_unknown 0 +#define bfd_mach_ck510 1 +#define bfd_mach_ck610 2 +#define bfd_mach_ck801 3 +#define bfd_mach_ck802 4 +#define bfd_mach_ck803 5 +#define bfd_mach_ck807 6 +#define bfd_mach_ck810 7 +#define bfd_mach_ck860 8 + bfd_arch_loongarch, /* LoongArch */ +#define bfd_mach_loongarch32 1 +#define bfd_mach_loongarch64 2 + bfd_arch_amdgcn, /* AMDGCN */ +#define bfd_mach_amdgcn_unknown 0x000 +#define bfd_mach_amdgcn_gfx900 0x02c +#define bfd_mach_amdgcn_gfx904 0x02e +#define bfd_mach_amdgcn_gfx906 0x02f +#define bfd_mach_amdgcn_gfx908 0x030 +#define bfd_mach_amdgcn_gfx90a 0x03f +#define bfd_mach_amdgcn_gfx1010 0x033 +#define bfd_mach_amdgcn_gfx1011 0x034 +#define bfd_mach_amdgcn_gfx1012 0x035 +#define bfd_mach_amdgcn_gfx1030 0x036 +#define bfd_mach_amdgcn_gfx1031 0x037 +#define bfd_mach_amdgcn_gfx1032 0x038 +#define bfd_mach_amdgcn_gfx1100 0x041 +#define bfd_mach_amdgcn_gfx1101 0x046 +#define bfd_mach_amdgcn_gfx1102 0x047 + bfd_arch_last + }; + +typedef struct bfd_arch_info +{ + int bits_per_word; + int bits_per_address; + int bits_per_byte; + enum bfd_architecture arch; + unsigned long mach; + const char *arch_name; + const char *printable_name; + unsigned int section_align_power; + /* TRUE if this is the default machine for the architecture. + The default arch should be the first entry for an arch so that + all the entries for that arch can be accessed via <>. */ + bool the_default; + const struct bfd_arch_info * (*compatible) (const struct bfd_arch_info *, + const struct bfd_arch_info *); + + bool (*scan) (const struct bfd_arch_info *, const char *); + + /* Allocate via bfd_malloc and return a fill buffer of size COUNT. If + IS_BIGENDIAN is TRUE, the order of bytes is big endian. If CODE is + TRUE, the buffer contains code. */ + void *(*fill) (bfd_size_type count, bool is_bigendian, bool code); + + const struct bfd_arch_info *next; + + /* On some architectures the offset for a relocation can point into + the middle of an instruction. This field specifies the maximum + offset such a relocation can have (in octets). This affects the + behaviour of the disassembler, since a value greater than zero + means that it may need to disassemble an instruction twice, once + to get its length and then a second time to display it. If the + value is negative then this has to be done for every single + instruction, regardless of the offset of the reloc. */ + signed int max_reloc_offset_into_insn; +} +bfd_arch_info_type; + +const char *bfd_printable_name (bfd *abfd); + +const bfd_arch_info_type *bfd_scan_arch (const char *string); + +const char **bfd_arch_list (void); + +const bfd_arch_info_type *bfd_arch_get_compatible + (const bfd *abfd, const bfd *bbfd, bool accept_unknowns); + +void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg); + +bool bfd_default_set_arch_mach + (bfd *abfd, enum bfd_architecture arch, unsigned long mach); + +enum bfd_architecture bfd_get_arch (const bfd *abfd); + +unsigned long bfd_get_mach (const bfd *abfd); + +unsigned int bfd_arch_bits_per_byte (const bfd *abfd); + +unsigned int bfd_arch_bits_per_address (const bfd *abfd); + +const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd); + +const bfd_arch_info_type *bfd_lookup_arch + (enum bfd_architecture arch, unsigned long machine); + +const char *bfd_printable_arch_mach + (enum bfd_architecture arch, unsigned long machine); + +unsigned int bfd_octets_per_byte (const bfd *abfd, + const asection *sec); + +unsigned int bfd_arch_mach_octets_per_byte + (enum bfd_architecture arch, unsigned long machine); + +/* Extracted from bfd.c. */ +typedef enum bfd_format + { + bfd_unknown = 0, /* File format is unknown. */ + bfd_object, /* Linker/assembler/compiler output. */ + bfd_archive, /* Object archive file. */ + bfd_core, /* Core dump. */ + bfd_type_end /* Marks the end; don't use it! */ + } +bfd_format; + +enum bfd_direction + { + no_direction = 0, + read_direction = 1, + write_direction = 2, + both_direction = 3 + }; + +enum bfd_last_io + { + bfd_io_seek = 0, + bfd_io_read = 1, + bfd_io_write = 2, + bfd_io_force = 3 + }; + +enum bfd_plugin_format + { + bfd_plugin_unknown = 0, + bfd_plugin_yes = 1, + bfd_plugin_yes_unused = 2, + bfd_plugin_no = 3 + }; + +struct bfd_build_id + { + bfd_size_type size; + bfd_byte data[1]; + }; + +enum bfd_lto_object_type + { + lto_non_object, /* Not an LTO object. */ + lto_non_ir_object, /* An object without LTO IR. */ + lto_slim_ir_object, /* A slim LTO IR object. */ + lto_fat_ir_object, /* A fat LTO IR object. */ + lto_mixed_object /* A mixed LTO IR object. */ + }; + +struct bfd_mmapped_entry + { + void *addr; + size_t size; + }; + +struct bfd_mmapped + { + struct bfd_mmapped *next; + unsigned int max_entry; + unsigned int next_entry; + struct bfd_mmapped_entry entries[1]; + }; + +struct bfd +{ + /* The filename the application opened the BFD with. */ + const char *filename; + + /* A pointer to the target jump table. */ + const struct bfd_target *xvec; + + /* The IOSTREAM, and corresponding IO vector that provide access + to the file backing the BFD. */ + void *iostream; + const struct bfd_iovec *iovec; + + /* The caching routines use these to maintain a + least-recently-used list of BFDs. */ + struct bfd *lru_prev, *lru_next; + + /* Track current file position (or current buffer offset for + in-memory BFDs). When a file is closed by the caching routines, + BFD retains state information on the file here. */ + ufile_ptr where; + + /* File modified time, if mtime_set is TRUE. */ + long mtime; + + /* A unique identifier of the BFD */ + unsigned int id; + + /* Format_specific flags. */ + flagword flags; + + /* Values that may appear in the flags field of a BFD. These also + appear in the object_flags field of the bfd_target structure, where + they indicate the set of flags used by that backend (not all flags + are meaningful for all object file formats) (FIXME: at the moment, + the object_flags values have mostly just been copied from backend + to another, and are not necessarily correct). */ + +#define BFD_NO_FLAGS 0x0 + + /* BFD contains relocation entries. */ +#define HAS_RELOC 0x1 + + /* BFD is directly executable. */ +#define EXEC_P 0x2 + + /* BFD has line number information (basically used for F_LNNO in a + COFF header). */ +#define HAS_LINENO 0x4 + + /* BFD has debugging information. */ +#define HAS_DEBUG 0x08 + + /* BFD has symbols. */ +#define HAS_SYMS 0x10 + + /* BFD has local symbols (basically used for F_LSYMS in a COFF + header). */ +#define HAS_LOCALS 0x20 + + /* BFD is a dynamic object. */ +#define DYNAMIC 0x40 + + /* Text section is write protected (if D_PAGED is not set, this is + like an a.out NMAGIC file) (the linker sets this by default, but + clears it for -r or -N). */ +#define WP_TEXT 0x80 + + /* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the + linker sets this by default, but clears it for -r or -n or -N). */ +#define D_PAGED 0x100 + + /* BFD is relaxable (this means that bfd_relax_section may be able to + do something) (sometimes bfd_relax_section can do something even if + this is not set). */ +#define BFD_IS_RELAXABLE 0x200 + + /* This may be set before writing out a BFD to request using a + traditional format. For example, this is used to request that when + writing out an a.out object the symbols not be hashed to eliminate + duplicates. */ +#define BFD_TRADITIONAL_FORMAT 0x400 + + /* This flag indicates that the BFD contents are actually cached + in memory. If this is set, iostream points to a malloc'd + bfd_in_memory struct. */ +#define BFD_IN_MEMORY 0x800 + + /* This BFD has been created by the linker and doesn't correspond + to any input file. */ +#define BFD_LINKER_CREATED 0x1000 + + /* This may be set before writing out a BFD to request that it + be written using values for UIDs, GIDs, timestamps, etc. that + will be consistent from run to run. */ +#define BFD_DETERMINISTIC_OUTPUT 0x2000 + + /* Compress sections in this BFD. */ +#define BFD_COMPRESS 0x4000 + + /* Decompress sections in this BFD. */ +#define BFD_DECOMPRESS 0x8000 + + /* BFD is a dummy, for plugins. */ +#define BFD_PLUGIN 0x10000 + + /* Compress sections in this BFD with SHF_COMPRESSED from gABI. */ +#define BFD_COMPRESS_GABI 0x20000 + + /* Convert ELF common symbol type to STT_COMMON or STT_OBJECT in this + BFD. */ +#define BFD_CONVERT_ELF_COMMON 0x40000 + + /* Use the ELF STT_COMMON type in this BFD. */ +#define BFD_USE_ELF_STT_COMMON 0x80000 + + /* Put pathnames into archives (non-POSIX). */ +#define BFD_ARCHIVE_FULL_PATH 0x100000 + +#define BFD_CLOSED_BY_CACHE 0x200000 + /* Compress sections in this BFD with SHF_COMPRESSED zstd. */ +#define BFD_COMPRESS_ZSTD 0x400000 + + /* Don't generate ELF section header. */ +#define BFD_NO_SECTION_HEADER 0x800000 + + /* Flags bits which are for BFD use only. */ +#define BFD_FLAGS_FOR_BFD_USE_MASK \ + (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \ + | BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT \ + | BFD_COMPRESS_GABI | BFD_CONVERT_ELF_COMMON | BFD_USE_ELF_STT_COMMON \ + | BFD_NO_SECTION_HEADER) + + /* The format which belongs to the BFD. (object, core, etc.) */ + ENUM_BITFIELD (bfd_format) format : 3; + + /* The direction with which the BFD was opened. */ + ENUM_BITFIELD (bfd_direction) direction : 2; + + /* POSIX.1-2017 (IEEE Std 1003.1) says of fopen : "When a file is + opened with update mode ('+' as the second or third character in + the mode argument), both input and output may be performed on + the associated stream. However, the application shall ensure + that output is not directly followed by input without an + intervening call to fflush() or to a file positioning function + (fseek(), fsetpos(), or rewind()), and input is not directly + followed by output without an intervening call to a file + positioning function, unless the input operation encounters + end-of-file." + This field tracks the last IO operation, so that bfd can insert + a seek when IO direction changes. */ + ENUM_BITFIELD (bfd_last_io) last_io : 2; + + /* Is the file descriptor being cached? That is, can it be closed as + needed, and re-opened when accessed later? */ + unsigned int cacheable : 1; + + /* Marks whether there was a default target specified when the + BFD was opened. This is used to select which matching algorithm + to use to choose the back end. */ + unsigned int target_defaulted : 1; + + /* ... and here: (``once'' means at least once). */ + unsigned int opened_once : 1; + + /* Set if we have a locally maintained mtime value, rather than + getting it from the file each time. */ + unsigned int mtime_set : 1; + + /* Flag set if symbols from this BFD should not be exported. */ + unsigned int no_export : 1; + + /* Remember when output has begun, to stop strange things + from happening. */ + unsigned int output_has_begun : 1; + + /* Have archive map. */ + unsigned int has_armap : 1; + + /* Set if this is a thin archive. */ + unsigned int is_thin_archive : 1; + + /* Set if this archive should not cache element positions. */ + unsigned int no_element_cache : 1; + + /* Set if only required symbols should be added in the link hash table for + this object. Used by VMS linkers. */ + unsigned int selective_search : 1; + + /* Set if this is the linker output BFD. */ + unsigned int is_linker_output : 1; + + /* Set if this is the linker input BFD. */ + unsigned int is_linker_input : 1; + + /* If this is an input for a compiler plug-in library. */ + ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2; + + /* Set if this is a plugin output file. */ + unsigned int lto_output : 1; + + /* Do not attempt to modify this file. Set when detecting errors + that BFD is not prepared to handle for objcopy/strip. */ + unsigned int read_only : 1; + + /* LTO object type. */ + ENUM_BITFIELD (bfd_lto_object_type) lto_type : 3; + + /* Set if this BFD is currently being processed by + bfd_check_format_matches. This is checked by the cache to + avoid closing the BFD in this case. This should only be + examined or modified while the BFD lock is held. */ + unsigned int in_format_matches : 1; + + /* Set to dummy BFD created when claimed by a compiler plug-in + library. */ + bfd *plugin_dummy_bfd; + + /* The offset of this bfd in the file, typically 0 if it is not + contained in an archive. */ + ufile_ptr origin; + + /* The origin in the archive of the proxy entry. This will + normally be the same as origin, except for thin archives, + when it will contain the current offset of the proxy in the + thin archive rather than the offset of the bfd in its actual + container. */ + ufile_ptr proxy_origin; + + /* A hash table for section names. */ + struct bfd_hash_table section_htab; + + /* Pointer to linked list of sections. */ + struct bfd_section *sections; + + /* The last section on the section list. */ + struct bfd_section *section_last; + + /* The object-only section on the section list. */ + struct bfd_section *object_only_section; + + /* The number of sections. */ + unsigned int section_count; + + /* The archive plugin file descriptor. */ + int archive_plugin_fd; + + /* The number of opens on the archive plugin file descriptor. */ + unsigned int archive_plugin_fd_open_count; + + /* A field used by _bfd_generic_link_add_archive_symbols. This will + be used only for archive elements. */ + int archive_pass; + + /* The total size of memory from bfd_alloc. */ + bfd_size_type alloc_size; + + /* Stuff only useful for object files: + The start address. */ + bfd_vma start_address; + + /* Symbol table for output BFD (with symcount entries). + Also used by the linker to cache input BFD symbols. */ + struct bfd_symbol **outsymbols; + + /* Used for input and output. */ + unsigned int symcount; + + /* Used for slurped dynamic symbol tables. */ + unsigned int dynsymcount; + + /* Pointer to structure which contains architecture information. */ + const struct bfd_arch_info *arch_info; + + /* Cached length of file for bfd_get_size. 0 until bfd_get_size is + called, 1 if stat returns an error or the file size is too large to + return in ufile_ptr. Both 0 and 1 should be treated as "unknown". */ + ufile_ptr size; + + /* Stuff only useful for archives. */ + void *arelt_data; + struct bfd *my_archive; /* The containing archive BFD. */ + struct bfd *archive_next; /* The next BFD in the archive. */ + struct bfd *archive_head; /* The first BFD in the archive. */ + struct bfd *nested_archives; /* List of nested archive in a flattened + thin archive. */ + + union { + /* For input BFDs, a chain of BFDs involved in a link. */ + struct bfd *next; + /* For output BFD, the linker hash table. */ + struct bfd_link_hash_table *hash; + } link; + + /* Used by the back end to hold private data. */ + union + { + struct aout_data_struct *aout_data; + struct artdata *aout_ar_data; + struct coff_tdata *coff_obj_data; + struct pe_tdata *pe_obj_data; + struct xcoff_tdata *xcoff_obj_data; + struct ecoff_tdata *ecoff_obj_data; + struct srec_data_struct *srec_data; + struct verilog_data_struct *verilog_data; + struct ihex_data_struct *ihex_data; + struct tekhex_data_struct *tekhex_data; + struct elf_obj_tdata *elf_obj_data; + struct mmo_data_struct *mmo_data; + struct trad_core_struct *trad_core_data; + struct som_data_struct *som_data; + struct hpux_core_struct *hpux_core_data; + struct hppabsd_core_struct *hppabsd_core_data; + struct sgi_core_struct *sgi_core_data; + struct lynx_core_struct *lynx_core_data; + struct osf_core_struct *osf_core_data; + struct cisco_core_struct *cisco_core_data; + struct netbsd_core_struct *netbsd_core_data; + struct mach_o_data_struct *mach_o_data; + struct mach_o_fat_data_struct *mach_o_fat_data; + struct plugin_data_struct *plugin_data; + struct bfd_pef_data_struct *pef_data; + struct bfd_pef_xlib_data_struct *pef_xlib_data; + struct bfd_sym_data_struct *sym_data; + void *any; + } + tdata; + + /* Used by the application to hold private data. */ + void *usrdata; + + /* Where all the allocated stuff under this BFD goes. This is a + struct objalloc *, but we use void * to avoid requiring the inclusion + of objalloc.h. */ + void *memory; + + /* For input BFDs, the build ID, if the object has one. */ + const struct bfd_build_id *build_id; + + /* For input BFDs, mmapped entries. */ + struct bfd_mmapped *mmapped; +}; + +static inline const char * +bfd_get_filename (const bfd *abfd) +{ + return abfd->filename; +} + +static inline bool +bfd_get_cacheable (const bfd *abfd) +{ + return abfd->cacheable; +} + +static inline enum bfd_format +bfd_get_format (const bfd *abfd) +{ + return abfd->format; +} + +static inline enum bfd_lto_object_type +bfd_get_lto_type (const bfd *abfd) +{ + return abfd->lto_type; +} + +static inline bool +bfd_lto_slim_symbol_p (const bfd *abfd, const char *name) +{ + return (bfd_get_lto_type (abfd) != lto_non_ir_object + && name != NULL + && name[0] == '_' + && name[1] == '_' + && strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0); +} + +static inline flagword +bfd_get_file_flags (const bfd *abfd) +{ + return abfd->flags; +} + +static inline bfd_vma +bfd_get_start_address (const bfd *abfd) +{ + return abfd->start_address; +} + +static inline unsigned int +bfd_get_symcount (const bfd *abfd) +{ + return abfd->symcount; +} + +static inline unsigned int +bfd_get_dynamic_symcount (const bfd *abfd) +{ + return abfd->dynsymcount; +} + +static inline struct bfd_symbol ** +bfd_get_outsymbols (const bfd *abfd) +{ + return abfd->outsymbols; +} + +static inline unsigned int +bfd_count_sections (const bfd *abfd) +{ + return abfd->section_count; +} + +static inline bool +bfd_has_map (const bfd *abfd) +{ + return abfd->has_armap; +} + +static inline bool +bfd_is_thin_archive (const bfd *abfd) +{ + return abfd->is_thin_archive; +} + +static inline void * +bfd_usrdata (const bfd *abfd) +{ + return abfd->usrdata; +} + +/* See note beside bfd_set_section_userdata. */ +static inline bool +bfd_set_cacheable (bfd * abfd, bool val) +{ + abfd->cacheable = val; + return true; +} + +static inline void +bfd_set_thin_archive (bfd *abfd, bool val) +{ + abfd->is_thin_archive = val; +} + +static inline void +bfd_set_usrdata (bfd *abfd, void *val) +{ + abfd->usrdata = val; +} + +static inline asection * +bfd_asymbol_section (const asymbol *sy) +{ + return sy->section; +} + +static inline bfd_vma +bfd_asymbol_value (const asymbol *sy) +{ + return sy->section->vma + sy->value; +} + +static inline const char * +bfd_asymbol_name (const asymbol *sy) +{ + return sy->name; +} + +static inline struct bfd * +bfd_asymbol_bfd (const asymbol *sy) +{ + return sy->the_bfd; +} + +static inline void +bfd_set_asymbol_name (asymbol *sy, const char *name) +{ + sy->name = name; +} + +/* For input sections return the original size on disk of the + section. For output sections return the current size. */ +static inline bfd_size_type +bfd_get_section_limit_octets (const bfd *abfd, const asection *sec) +{ + if (abfd->direction != write_direction && sec->rawsize != 0) + return sec->rawsize; + return sec->size; +} + +/* Find the address one past the end of SEC. */ +static inline bfd_size_type +bfd_get_section_limit (const bfd *abfd, const asection *sec) +{ + return (bfd_get_section_limit_octets (abfd, sec) + / bfd_octets_per_byte (abfd, sec)); +} + +/* For input sections return the larger of the current size and the + original size on disk of the section. For output sections return + the current size. */ +static inline bfd_size_type +bfd_get_section_alloc_size (const bfd *abfd, const asection *sec) +{ + if (abfd->direction != write_direction && sec->rawsize > sec->size) + return sec->rawsize; + return sec->size; +} + +/* Functions to handle insertion and deletion of a bfd's sections. These + only handle the list pointers, ie. do not adjust section_count, + target_index etc. */ +static inline void +bfd_section_list_remove (bfd *abfd, asection *s) +{ + asection *next = s->next; + asection *prev = s->prev; + if (prev) + prev->next = next; + else + abfd->sections = next; + if (next) + next->prev = prev; + else + abfd->section_last = prev; +} + +static inline void +bfd_section_list_append (bfd *abfd, asection *s) +{ + s->next = 0; + if (abfd->section_last) + { + s->prev = abfd->section_last; + abfd->section_last->next = s; + } + else + { + s->prev = 0; + abfd->sections = s; + } + abfd->section_last = s; +} + +static inline void +bfd_section_list_prepend (bfd *abfd, asection *s) +{ + s->prev = 0; + if (abfd->sections) + { + s->next = abfd->sections; + abfd->sections->prev = s; + } + else + { + s->next = 0; + abfd->section_last = s; + } + abfd->sections = s; +} + +static inline void +bfd_section_list_insert_after (bfd *abfd, asection *a, asection *s) +{ + asection *next = a->next; + s->next = next; + s->prev = a; + a->next = s; + if (next) + next->prev = s; + else + abfd->section_last = s; +} + +static inline void +bfd_section_list_insert_before (bfd *abfd, asection *b, asection *s) +{ + asection *prev = b->prev; + s->prev = prev; + s->next = b; + b->prev = s; + if (prev) + prev->next = s; + else + abfd->sections = s; +} + +static inline bool +bfd_section_removed_from_list (const bfd *abfd, const asection *s) +{ + return s->next ? s->next->prev != s : abfd->section_last != s; +} + +typedef enum bfd_error +{ + bfd_error_no_error = 0, + bfd_error_system_call, + bfd_error_invalid_target, + bfd_error_wrong_format, + bfd_error_wrong_object_format, + bfd_error_invalid_operation, + bfd_error_no_memory, + bfd_error_no_symbols, + bfd_error_no_armap, + bfd_error_no_more_archived_files, + bfd_error_malformed_archive, + bfd_error_missing_dso, + bfd_error_file_not_recognized, + bfd_error_file_ambiguously_recognized, + bfd_error_no_contents, + bfd_error_nonrepresentable_section, + bfd_error_no_debug_section, + bfd_error_bad_value, + bfd_error_file_truncated, + bfd_error_file_too_big, + bfd_error_sorry, + bfd_error_on_input, + bfd_error_invalid_error_code +} +bfd_error_type; + +bfd_error_type bfd_get_error (void); + +void bfd_set_error (bfd_error_type error_tag); + +void bfd_set_input_error (bfd *input, bfd_error_type error_tag); + +const char *bfd_errmsg (bfd_error_type error_tag); + +void bfd_perror (const char *message); + +typedef void (*bfd_error_handler_type) (const char *, va_list); + +typedef int (*bfd_print_callback) (void *, const char *, ...); +void bfd_print_error (bfd_print_callback print_func, + void *stream, const char *fmt, va_list ap); + +void _bfd_error_handler (const char *fmt, ...) ATTRIBUTE_PRINTF_1; + +bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); + +void bfd_set_error_program_name (const char *); + +typedef void (*bfd_assert_handler_type) (const char *bfd_formatmsg, + const char *bfd_version, + const char *bfd_file, + int bfd_line); + +bfd_assert_handler_type bfd_set_assert_handler (bfd_assert_handler_type); + +unsigned int bfd_init (void); + +/* Value returned by bfd_init. */ +#define BFD_INIT_MAGIC (sizeof (struct bfd_section)) + +typedef bool (*bfd_lock_unlock_fn_type) (void *); +bool bfd_thread_init + (bfd_lock_unlock_fn_type lock, + bfd_lock_unlock_fn_type unlock, + void *data); + +void bfd_thread_cleanup (void); + +long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect); + +long bfd_canonicalize_reloc + (bfd *abfd, asection *sec, arelent **loc, asymbol **syms); + +void bfd_set_reloc + (bfd *abfd, asection *sec, arelent **rel, unsigned int count); + +#define bfd_set_reloc(abfd, asect, location, count) \ + BFD_SEND (abfd, _bfd_set_reloc, (abfd, asect, location, count)) +bool bfd_set_file_flags (bfd *abfd, flagword flags); + +int bfd_get_arch_size (bfd *abfd); + +int bfd_get_sign_extend_vma (bfd *abfd); + +bool bfd_set_start_address (bfd *abfd, bfd_vma vma); + +unsigned int bfd_get_gp_size (bfd *abfd); + +void bfd_set_gp_size (bfd *abfd, unsigned int i); + +void bfd_set_gp_value (bfd *abfd, bfd_vma v); + +bfd_vma bfd_scan_vma (const char *string, const char **end, int base); + +bool bfd_copy_private_header_data (bfd *ibfd, bfd *obfd); + +#define bfd_copy_private_header_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_copy_private_header_data, \ + (ibfd, obfd)) +bool bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd); + +#define bfd_copy_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ + (ibfd, obfd)) +bool bfd_set_private_flags (bfd *abfd, flagword flags); + +#define bfd_set_private_flags(abfd, flags) \ + BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags)) +#define bfd_sizeof_headers(abfd, info) \ + BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, info)) + +#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ + BFD_SEND (abfd, _bfd_find_nearest_line, \ + (abfd, syms, sec, off, file, func, line, NULL)) + +#define bfd_find_nearest_line_with_alt(abfd, alt_filename, sec, syms, off, \ + file, func, line, disc) \ + BFD_SEND (abfd, _bfd_find_nearest_line_with_alt, \ + (abfd, alt_filename, syms, sec, off, file, func, line, disc)) + +#define bfd_find_nearest_line_discriminator(abfd, sec, syms, off, file, func, \ + line, disc) \ + BFD_SEND (abfd, _bfd_find_nearest_line, \ + (abfd, syms, sec, off, file, func, line, disc)) + +#define bfd_find_line(abfd, syms, sym, file, line) \ + BFD_SEND (abfd, _bfd_find_line, \ + (abfd, syms, sym, file, line)) + +#define bfd_find_inliner_info(abfd, file, func, line) \ + BFD_SEND (abfd, _bfd_find_inliner_info, \ + (abfd, file, func, line)) + +#define bfd_debug_info_start(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) + +#define bfd_debug_info_end(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) + +#define bfd_debug_info_accumulate(abfd, section) \ + BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) + +#define bfd_stat_arch_elt(abfd, stat) \ + BFD_SEND (abfd->my_archive ? abfd->my_archive : abfd, \ + _bfd_stat_arch_elt, (abfd, stat)) + +#define bfd_update_armap_timestamp(abfd) \ + BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) + +#define bfd_set_arch_mach(abfd, arch, mach)\ + BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) + +#define bfd_relax_section(abfd, section, link_info, again) \ + BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) + +#define bfd_gc_sections(abfd, link_info) \ + BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info)) + +#define bfd_lookup_section_flags(link_info, flag_info, section) \ + BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info, section)) + +#define bfd_merge_sections(abfd, link_info) \ + BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) + +#define bfd_is_group_section(abfd, sec) \ + BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec)) + +#define bfd_group_name(abfd, sec) \ + BFD_SEND (abfd, _bfd_group_name, (abfd, sec)) + +#define bfd_discard_group(abfd, sec) \ + BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) + +#define bfd_link_hash_table_create(abfd) \ + BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) + +#define bfd_link_add_symbols(abfd, info) \ + BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) + +#define bfd_link_just_syms(abfd, sec, info) \ + BFD_SEND (abfd, _bfd_link_just_syms, (sec, info)) + +#define bfd_final_link(abfd, info) \ + BFD_SEND (abfd, _bfd_final_link, (abfd, info)) + +#define bfd_free_cached_info(abfd) \ + BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) + +#define bfd_get_dynamic_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) + +#define bfd_print_private_bfd_data(abfd, file)\ + BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) + +#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) + +#define bfd_get_synthetic_symtab(abfd, count, syms, dyncount, dynsyms, ret) \ + BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, count, syms, \ + dyncount, dynsyms, ret)) + +#define bfd_get_dynamic_reloc_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) + +#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) + +bfd_byte *bfd_get_relocated_section_contents + (bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *, + bool, asymbol **); + +bool bfd_record_phdr + (bfd *, unsigned long, bool, flagword, bool, bfd_vma, + bool, bool, unsigned int, struct bfd_section **); + +void bfd_sprintf_vma (bfd *, char *, bfd_vma); +void bfd_fprintf_vma (bfd *, void *, bfd_vma); + +#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd, stdout, x) + +bool bfd_alt_mach_code (bfd *abfd, int alternative); + +bfd_vma bfd_emul_get_maxpagesize (const char *); + +bfd_vma bfd_emul_get_commonpagesize (const char *); + +char *bfd_demangle (bfd *, const char *, int); + +asymbol *bfd_group_signature (asection *group, asymbol **isympp); + +/* Extracted from bfdio.c. */ +bfd_size_type bfd_read (void *, bfd_size_type, bfd *) +ATTRIBUTE_WARN_UNUSED_RESULT; + +bfd_size_type bfd_write (const void *, bfd_size_type, bfd *) +ATTRIBUTE_WARN_UNUSED_RESULT; + +file_ptr bfd_tell (bfd *) ATTRIBUTE_WARN_UNUSED_RESULT; + +int bfd_flush (bfd *); + +int bfd_stat (bfd *, struct stat *) ATTRIBUTE_WARN_UNUSED_RESULT; + +int bfd_seek (bfd *, file_ptr, int) ATTRIBUTE_WARN_UNUSED_RESULT; + +long bfd_get_mtime (bfd *abfd); + +ufile_ptr bfd_get_size (bfd *abfd); + +ufile_ptr bfd_get_file_size (bfd *abfd); + +void *bfd_mmap (bfd *abfd, void *addr, size_t len, + int prot, int flags, file_ptr offset, + void **map_addr, size_t *map_len) +ATTRIBUTE_WARN_UNUSED_RESULT; + +time_t bfd_get_current_time (time_t now); + +/* Extracted from cache.c. */ +bool bfd_cache_close (bfd *abfd); + +bool bfd_cache_close_all (void); + +unsigned bfd_cache_size (void); + +/* Extracted from compress.c. */ +/* Types of compressed DWARF debug sections. */ +enum compressed_debug_section_type +{ + COMPRESS_DEBUG_NONE = 0, + COMPRESS_DEBUG_GNU_ZLIB = 1 << 1, + COMPRESS_DEBUG_GABI_ZLIB = 1 << 2, + COMPRESS_DEBUG_ZSTD = 1 << 3, + COMPRESS_UNKNOWN = 1 << 4 +}; + +/* Tuple for compressed_debug_section_type and their name. */ +struct compressed_type_tuple +{ + enum compressed_debug_section_type type; + const char *name; +}; + +/* Compression header ch_type values. */ +enum compression_type +{ + ch_none = 0, + ch_compress_zlib = 1 , /* Compressed with zlib. */ + ch_compress_zstd = 2 /* Compressed with zstd (www.zstandard.org). */ +}; + +static inline char * +bfd_debug_name_to_zdebug (bfd *abfd, const char *name) +{ + size_t len = strlen (name); + char *new_name = (char *) bfd_alloc (abfd, len + 2); + if (new_name == NULL) + return NULL; + new_name[0] = '.'; + new_name[1] = 'z'; + memcpy (new_name + 2, name + 1, len); + return new_name; +} + +static inline char * +bfd_zdebug_name_to_debug (bfd *abfd, const char *name) +{ + size_t len = strlen (name); + char *new_name = (char *) bfd_alloc (abfd, len); + if (new_name == NULL) + return NULL; + new_name[0] = '.'; + memcpy (new_name + 1, name + 2, len - 1); + return new_name; +} + +enum compressed_debug_section_type +bfd_get_compression_algorithm (const char *name); + +const char *bfd_get_compression_algorithm_name + (enum compressed_debug_section_type type); + +void bfd_update_compression_header + (bfd *abfd, bfd_byte *contents, asection *sec); + +int bfd_get_compression_header_size (bfd *abfd, asection *sec); + +bool bfd_convert_section_setup + (bfd *ibfd, asection *isec, bfd *obfd, + const char **new_name, bfd_size_type *new_size); + +bool bfd_convert_section_contents + (bfd *ibfd, asection *isec, bfd *obfd, + bfd_byte **ptr, bfd_size_type *ptr_size); + +bool bfd_get_full_section_contents + (bfd *abfd, asection *section, bfd_byte **ptr); + +bool bfd_is_section_compressed_info + (bfd *abfd, asection *section, + int *compression_header_size_p, + bfd_size_type *uncompressed_size_p, + unsigned int *uncompressed_alignment_power_p, + enum compression_type *ch_type); + +bool bfd_is_section_compressed + (bfd *abfd, asection *section); + +bool bfd_init_section_decompress_status + (bfd *abfd, asection *section); + +bool bfd_init_section_compress_status + (bfd *abfd, asection *section); + +bool bfd_compress_section + (bfd *abfd, asection *section, bfd_byte *uncompressed_buffer); + +/* Extracted from corefile.c. */ +const char *bfd_core_file_failing_command (bfd *abfd); + +int bfd_core_file_failing_signal (bfd *abfd); + +int bfd_core_file_pid (bfd *abfd); + +bool core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd); + +bool generic_core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd); + +/* Extracted from format.c. */ +bool bfd_check_format_lto (bfd *abfd, bfd_format format, + bool lto_sections_removed); + +bool bfd_check_format (bfd *abfd, bfd_format format); + +bool bfd_check_format_matches_lto + (bfd *abfd, bfd_format format, char ***matching, + bool lto_sections_removed); + +bool bfd_check_format_matches + (bfd *abfd, bfd_format format, char ***matching); + +bool bfd_set_format (bfd *abfd, bfd_format format); + +const char *bfd_format_string (bfd_format format); + +/* Extracted from linker.c. */ +/* Return TRUE if the symbol described by a linker hash entry H + is going to be absolute. Linker-script defined symbols can be + converted from absolute to section-relative ones late in the + link. Use this macro to correctly determine whether the symbol + will actually end up absolute in output. */ +#define bfd_is_abs_symbol(H) \ + (((H)->type == bfd_link_hash_defined \ + || (H)->type == bfd_link_hash_defweak) \ + && bfd_is_abs_section ((H)->u.def.section) \ + && !(H)->rel_from_abs) + +bool _bfd_generic_link_add_one_symbol + (struct bfd_link_info *info, + bfd *abfd, + const char *name, + flagword flags, + asection *section, + bfd_vma value, + const char *string, + bool copy, + bool collect, + struct bfd_link_hash_entry **hashp); + +bool bfd_link_align_section (asection *, unsigned int); + +bool bfd_link_split_section (bfd *abfd, asection *sec); + +#define bfd_link_split_section(abfd, sec) \ + BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec)) + +bool bfd_section_already_linked (bfd *abfd, + asection *sec, + struct bfd_link_info *info); + +#define bfd_section_already_linked(abfd, sec, info) \ + BFD_SEND (abfd, _section_already_linked, (abfd, sec, info)) + +bool bfd_generic_define_common_symbol + (bfd *output_bfd, struct bfd_link_info *info, + struct bfd_link_hash_entry *h); + +#define bfd_define_common_symbol(output_bfd, info, h) \ + BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h)) + +void _bfd_generic_link_hide_symbol + (bfd *output_bfd, struct bfd_link_info *info, + struct bfd_link_hash_entry *h); + +#define bfd_link_hide_symbol(output_bfd, info, h) \ + BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h)) + +struct bfd_link_hash_entry *bfd_generic_define_start_stop + (struct bfd_link_info *info, + const char *symbol, asection *sec); + +#define bfd_define_start_stop(output_bfd, info, symbol, sec) \ + BFD_SEND (output_bfd, _bfd_define_start_stop, (info, symbol, sec)) + +struct bfd_elf_version_tree * bfd_find_version_for_sym + (struct bfd_elf_version_tree *verdefs, + const char *sym_name, bool *hide); + +bool bfd_hide_sym_by_version + (struct bfd_elf_version_tree *verdefs, const char *sym_name); + +bool bfd_link_check_relocs + (bfd *abfd, struct bfd_link_info *info); + +bool _bfd_generic_link_check_relocs + (bfd *abfd, struct bfd_link_info *info); + +bool bfd_merge_private_bfd_data + (bfd *ibfd, struct bfd_link_info *info); + +#define bfd_merge_private_bfd_data(ibfd, info) \ + BFD_SEND ((info)->output_bfd, _bfd_merge_private_bfd_data, \ + (ibfd, info)) + +/* Extracted from opncls.c. */ +bfd *bfd_fopen (const char *filename, const char *target, + const char *mode, int fd); + +bfd *bfd_openr (const char *filename, const char *target); + +bfd *bfd_fdopenr (const char *filename, const char *target, int fd); + +bfd *bfd_fdopenw (const char *filename, const char *target, int fd); + +bfd *bfd_openstreamr (const char * filename, const char * target, + void * stream); + +bfd *bfd_openr_iovec (const char *filename, const char *target, + void *(*open_func) (struct bfd *nbfd, + void *open_closure), + void *open_closure, + file_ptr (*pread_func) (struct bfd *nbfd, + void *stream, + void *buf, + file_ptr nbytes, + file_ptr offset), + int (*close_func) (struct bfd *nbfd, + void *stream), + int (*stat_func) (struct bfd *abfd, + void *stream, + struct stat *sb)); + +bfd *bfd_openw (const char *filename, const char *target); + +bfd *bfd_elf_bfd_from_remote_memory + (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep, + int (*target_read_memory) + (bfd_vma vma, bfd_byte *myaddr, bfd_size_type len)); + +bool bfd_close (bfd *abfd); + +bool bfd_close_all_done (bfd *); + +bfd *bfd_create (const char *filename, bfd *templ); + +bool bfd_make_writable (bfd *abfd); + +bool bfd_make_readable (bfd *abfd); + +uint32_t bfd_calc_gnu_debuglink_crc32 + (uint32_t crc, const bfd_byte *buf, bfd_size_type len); + +char *bfd_get_debug_link_info (bfd *abfd, uint32_t *crc32_out); + +char *bfd_get_alt_debug_link_info (bfd * abfd, + bfd_size_type *buildid_len, + bfd_byte **buildid_out); + +char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir); + +char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir); + +struct bfd_section *bfd_create_gnu_debuglink_section + (bfd *abfd, const char *filename); + +bool bfd_fill_in_gnu_debuglink_section + (bfd *abfd, struct bfd_section *sect, const char *filename); + +char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir); + +const char *bfd_set_filename (bfd *abfd, const char *filename); + +const char *bfd_extract_object_only_section + (bfd *abfd); + +/* Extracted from reloc.c. */ +typedef enum bfd_reloc_status +{ + /* No errors detected. Note - the value 2 is used so that it + will not be mistaken for the boolean TRUE or FALSE values. */ + bfd_reloc_ok = 2, + + /* The relocation was performed, but there was an overflow. */ + bfd_reloc_overflow, + + /* The address to relocate was not within the section supplied. */ + bfd_reloc_outofrange, + + /* Used by special functions. */ + bfd_reloc_continue, + + /* Unsupported relocation size requested. */ + bfd_reloc_notsupported, + + /* Target specific meaning. */ + bfd_reloc_other, + + /* The symbol to relocate against was undefined. */ + bfd_reloc_undefined, + + /* The relocation was performed, but may not be ok. If this type is + returned, the error_message argument to bfd_perform_relocation + will be set. */ + bfd_reloc_dangerous + } + bfd_reloc_status_type; + +typedef const struct reloc_howto_struct reloc_howto_type; + +struct reloc_cache_entry +{ + /* A pointer into the canonical table of pointers. */ + struct bfd_symbol **sym_ptr_ptr; + + /* offset in section. */ + bfd_size_type address; + + /* addend for relocation value. */ + bfd_vma addend; + + /* Pointer to how to perform the required relocation. */ + reloc_howto_type *howto; + +}; + +enum complain_overflow +{ + /* Do not complain on overflow. */ + complain_overflow_dont, + + /* Complain if the value overflows when considered as a signed + number one bit larger than the field. ie. A bitfield of N bits + is allowed to represent -2**n to 2**n-1. */ + complain_overflow_bitfield, + + /* Complain if the value overflows when considered as a signed + number. */ + complain_overflow_signed, + + /* Complain if the value overflows when considered as an + unsigned number. */ + complain_overflow_unsigned +}; + +struct reloc_howto_struct +{ + /* The type field has mainly a documentary use - the back end can + do what it wants with it, though normally the back end's idea of + an external reloc number is stored in this field. */ + unsigned int type; + + /* The size of the item to be relocated in bytes. */ + unsigned int size:4; + + /* The number of bits in the field to be relocated. This is used + when doing overflow checking. */ + unsigned int bitsize:7; + + /* The value the final relocation is shifted right by. This drops + unwanted data from the relocation. */ + unsigned int rightshift:6; + + /* The bit position of the reloc value in the destination. + The relocated value is left shifted by this amount. */ + unsigned int bitpos:6; + + /* What type of overflow error should be checked for when + relocating. */ + ENUM_BITFIELD (complain_overflow) complain_on_overflow:2; + + /* The relocation value should be negated before applying. */ + unsigned int negate:1; + + /* The relocation is relative to the item being relocated. */ + unsigned int pc_relative:1; + + /* Some formats record a relocation addend in the section contents + rather than with the relocation. For ELF formats this is the + distinction between USE_REL and USE_RELA (though the code checks + for USE_REL == 1/0). The value of this field is TRUE if the + addend is recorded with the section contents; when performing a + partial link (ld -r) the section contents (the data) will be + modified. The value of this field is FALSE if addends are + recorded with the relocation (in arelent.addend); when performing + a partial link the relocation will be modified. + All relocations for all ELF USE_RELA targets should set this field + to FALSE (values of TRUE should be looked on with suspicion). + However, the converse is not true: not all relocations of all ELF + USE_REL targets set this field to TRUE. Why this is so is peculiar + to each particular target. For relocs that aren't used in partial + links (e.g. GOT stuff) it doesn't matter what this is set to. */ + unsigned int partial_inplace:1; + + /* When some formats create PC relative instructions, they leave + the value of the pc of the place being relocated in the offset + slot of the instruction, so that a PC relative relocation can + be made just by adding in an ordinary offset (e.g., sun3 a.out). + Some formats leave the displacement part of an instruction + empty (e.g., ELF); this flag signals the fact. */ + unsigned int pcrel_offset:1; + + /* Whether bfd_install_relocation should just install the addend, + or should follow the practice of some older object formats and + install a value including the symbol. */ + unsigned int install_addend:1; + + /* src_mask selects the part of the instruction (or data) to be used + in the relocation sum. If the target relocations don't have an + addend in the reloc, eg. ELF USE_REL, src_mask will normally equal + dst_mask to extract the addend from the section contents. If + relocations do have an addend in the reloc, eg. ELF USE_RELA, this + field should normally be zero. Non-zero values for ELF USE_RELA + targets should be viewed with suspicion as normally the value in + the dst_mask part of the section contents should be ignored. */ + bfd_vma src_mask; + + /* dst_mask selects which parts of the instruction (or data) are + replaced with a relocated value. */ + bfd_vma dst_mask; + + /* If this field is non null, then the supplied function is + called rather than the normal function. This allows really + strange relocation methods to be accommodated. */ + bfd_reloc_status_type (*special_function) + (bfd *, arelent *, struct bfd_symbol *, void *, asection *, + bfd *, char **); + + /* The textual name of the relocation type. */ + const char *name; +}; + +#define HOWTO_INSTALL_ADDEND 0 +#define HOWTO_RSIZE(sz) ((sz) < 0 ? -(sz) : (sz)) +#define HOWTO(type, right, size, bits, pcrel, left, ovf, func, name, \ + inplace, src_mask, dst_mask, pcrel_off) \ + { (unsigned) type, HOWTO_RSIZE (size), bits, right, left, ovf, \ + size < 0, pcrel, inplace, pcrel_off, HOWTO_INSTALL_ADDEND, \ + src_mask, dst_mask, func, name } +#define EMPTY_HOWTO(C) \ + HOWTO ((C), 0, 1, 0, false, 0, complain_overflow_dont, NULL, \ + NULL, false, 0, 0, false) + +static inline unsigned int +bfd_get_reloc_size (reloc_howto_type *howto) +{ + return howto->size; +} + +typedef struct relent_chain +{ + arelent relent; + struct relent_chain *next; +} +arelent_chain; + +bfd_reloc_status_type bfd_check_overflow + (enum complain_overflow how, + unsigned int bitsize, + unsigned int rightshift, + unsigned int addrsize, + bfd_vma relocation); + +bool bfd_reloc_offset_in_range + (reloc_howto_type *howto, + bfd *abfd, + asection *section, + bfd_size_type offset); + +bfd_reloc_status_type bfd_perform_relocation + (bfd *abfd, + arelent *reloc_entry, + void *data, + asection *input_section, + bfd *output_bfd, + char **error_message); + +bfd_reloc_status_type bfd_install_relocation + (bfd *abfd, + arelent *reloc_entry, + void *data, bfd_vma data_start, + asection *input_section, + char **error_message); + +enum bfd_reloc_code_real +{ + _dummy_first_bfd_reloc_code_real, + + + /* Basic absolute relocations of N bits. */ + BFD_RELOC_64, + BFD_RELOC_32, + BFD_RELOC_26, + BFD_RELOC_24, + BFD_RELOC_16, + BFD_RELOC_14, + BFD_RELOC_8, + + /* PC-relative relocations. Sometimes these are relative to the + address of the relocation itself; sometimes they are relative to the + start of the section containing the relocation. It depends on the + specific target. */ + BFD_RELOC_64_PCREL, + BFD_RELOC_32_PCREL, + BFD_RELOC_24_PCREL, + BFD_RELOC_16_PCREL, + BFD_RELOC_12_PCREL, + BFD_RELOC_8_PCREL, + + /* Section relative relocations. Some targets need this for DWARF2. */ + BFD_RELOC_32_SECREL, + BFD_RELOC_16_SECIDX, + + /* For ELF. */ + BFD_RELOC_32_GOT_PCREL, + BFD_RELOC_16_GOT_PCREL, + BFD_RELOC_8_GOT_PCREL, + BFD_RELOC_32_GOTOFF, + BFD_RELOC_16_GOTOFF, + BFD_RELOC_LO16_GOTOFF, + BFD_RELOC_HI16_GOTOFF, + BFD_RELOC_HI16_S_GOTOFF, + BFD_RELOC_8_GOTOFF, + BFD_RELOC_64_PLT_PCREL, + BFD_RELOC_32_PLT_PCREL, + BFD_RELOC_24_PLT_PCREL, + BFD_RELOC_16_PLT_PCREL, + BFD_RELOC_8_PLT_PCREL, + BFD_RELOC_64_PLTOFF, + BFD_RELOC_32_PLTOFF, + BFD_RELOC_16_PLTOFF, + BFD_RELOC_LO16_PLTOFF, + BFD_RELOC_HI16_PLTOFF, + BFD_RELOC_HI16_S_PLTOFF, + BFD_RELOC_8_PLTOFF, + + /* Size relocations. */ + BFD_RELOC_SIZE32, + BFD_RELOC_SIZE64, + + /* Relocations used by 68K ELF. */ + BFD_RELOC_68K_GLOB_DAT, + BFD_RELOC_68K_JMP_SLOT, + BFD_RELOC_68K_RELATIVE, + BFD_RELOC_68K_TLS_GD32, + BFD_RELOC_68K_TLS_GD16, + BFD_RELOC_68K_TLS_GD8, + BFD_RELOC_68K_TLS_LDM32, + BFD_RELOC_68K_TLS_LDM16, + BFD_RELOC_68K_TLS_LDM8, + BFD_RELOC_68K_TLS_LDO32, + BFD_RELOC_68K_TLS_LDO16, + BFD_RELOC_68K_TLS_LDO8, + BFD_RELOC_68K_TLS_IE32, + BFD_RELOC_68K_TLS_IE16, + BFD_RELOC_68K_TLS_IE8, + BFD_RELOC_68K_TLS_LE32, + BFD_RELOC_68K_TLS_LE16, + BFD_RELOC_68K_TLS_LE8, + + /* Linkage-table relative. */ + BFD_RELOC_32_BASEREL, + BFD_RELOC_16_BASEREL, + BFD_RELOC_LO16_BASEREL, + BFD_RELOC_HI16_BASEREL, + BFD_RELOC_HI16_S_BASEREL, + BFD_RELOC_8_BASEREL, + BFD_RELOC_RVA, + + /* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */ + BFD_RELOC_8_FFnn, + + /* These PC-relative relocations are stored as word displacements -- + i.e., byte displacements shifted right two bits. The 30-bit word + displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the + SPARC. (SPARC tools generally refer to this as <>.) The + signed 16-bit displacement is used on the MIPS, and the 23-bit + displacement is used on the Alpha. */ + BFD_RELOC_32_PCREL_S2, + BFD_RELOC_16_PCREL_S2, + BFD_RELOC_23_PCREL_S2, + + /* High 22 bits and low 10 bits of 32-bit value, placed into lower bits + of the target word. These are used on the SPARC. */ + BFD_RELOC_HI22, + BFD_RELOC_LO10, + + /* For systems that allocate a Global Pointer register, these are + displacements off that register. These relocation types are + handled specially, because the value the register will have is + decided relatively late. */ + BFD_RELOC_GPREL16, + BFD_RELOC_GPREL32, + + /* SPARC ELF relocations. There is probably some overlap with other + relocation types already defined. */ + BFD_RELOC_NONE, + BFD_RELOC_SPARC_WDISP22, + BFD_RELOC_SPARC22, + BFD_RELOC_SPARC13, + BFD_RELOC_SPARC_GOT10, + BFD_RELOC_SPARC_GOT13, + BFD_RELOC_SPARC_GOT22, + BFD_RELOC_SPARC_PC10, + BFD_RELOC_SPARC_PC22, + BFD_RELOC_SPARC_WPLT30, + BFD_RELOC_SPARC_COPY, + BFD_RELOC_SPARC_GLOB_DAT, + BFD_RELOC_SPARC_JMP_SLOT, + BFD_RELOC_SPARC_RELATIVE, + BFD_RELOC_SPARC_UA16, + BFD_RELOC_SPARC_UA32, + BFD_RELOC_SPARC_UA64, + BFD_RELOC_SPARC_GOTDATA_HIX22, + BFD_RELOC_SPARC_GOTDATA_LOX10, + BFD_RELOC_SPARC_GOTDATA_OP_HIX22, + BFD_RELOC_SPARC_GOTDATA_OP_LOX10, + BFD_RELOC_SPARC_GOTDATA_OP, + BFD_RELOC_SPARC_JMP_IREL, + BFD_RELOC_SPARC_IRELATIVE, + + /* I think these are specific to SPARC a.out (e.g., Sun 4). */ + BFD_RELOC_SPARC_BASE13, + BFD_RELOC_SPARC_BASE22, + + /* SPARC64 relocations. */ +#define BFD_RELOC_SPARC_64 BFD_RELOC_64 + BFD_RELOC_SPARC_10, + BFD_RELOC_SPARC_11, + BFD_RELOC_SPARC_OLO10, + BFD_RELOC_SPARC_HH22, + BFD_RELOC_SPARC_HM10, + BFD_RELOC_SPARC_LM22, + BFD_RELOC_SPARC_PC_HH22, + BFD_RELOC_SPARC_PC_HM10, + BFD_RELOC_SPARC_PC_LM22, + BFD_RELOC_SPARC_WDISP16, + BFD_RELOC_SPARC_WDISP19, + BFD_RELOC_SPARC_7, + BFD_RELOC_SPARC_6, + BFD_RELOC_SPARC_5, +#define BFD_RELOC_SPARC_DISP64 BFD_RELOC_64_PCREL + BFD_RELOC_SPARC_PLT32, + BFD_RELOC_SPARC_PLT64, + BFD_RELOC_SPARC_HIX22, + BFD_RELOC_SPARC_LOX10, + BFD_RELOC_SPARC_H44, + BFD_RELOC_SPARC_M44, + BFD_RELOC_SPARC_L44, + BFD_RELOC_SPARC_REGISTER, + BFD_RELOC_SPARC_H34, + BFD_RELOC_SPARC_SIZE32, + BFD_RELOC_SPARC_SIZE64, + BFD_RELOC_SPARC_WDISP10, + + /* SPARC little endian relocation. */ + BFD_RELOC_SPARC_REV32, + + /* SPARC TLS relocations. */ + BFD_RELOC_SPARC_TLS_GD_HI22, + BFD_RELOC_SPARC_TLS_GD_LO10, + BFD_RELOC_SPARC_TLS_GD_ADD, + BFD_RELOC_SPARC_TLS_GD_CALL, + BFD_RELOC_SPARC_TLS_LDM_HI22, + BFD_RELOC_SPARC_TLS_LDM_LO10, + BFD_RELOC_SPARC_TLS_LDM_ADD, + BFD_RELOC_SPARC_TLS_LDM_CALL, + BFD_RELOC_SPARC_TLS_LDO_HIX22, + BFD_RELOC_SPARC_TLS_LDO_LOX10, + BFD_RELOC_SPARC_TLS_LDO_ADD, + BFD_RELOC_SPARC_TLS_IE_HI22, + BFD_RELOC_SPARC_TLS_IE_LO10, + BFD_RELOC_SPARC_TLS_IE_LD, + BFD_RELOC_SPARC_TLS_IE_LDX, + BFD_RELOC_SPARC_TLS_IE_ADD, + BFD_RELOC_SPARC_TLS_LE_HIX22, + BFD_RELOC_SPARC_TLS_LE_LOX10, + BFD_RELOC_SPARC_TLS_DTPMOD32, + BFD_RELOC_SPARC_TLS_DTPMOD64, + BFD_RELOC_SPARC_TLS_DTPOFF32, + BFD_RELOC_SPARC_TLS_DTPOFF64, + BFD_RELOC_SPARC_TLS_TPOFF32, + BFD_RELOC_SPARC_TLS_TPOFF64, + + /* SPU Relocations. */ + BFD_RELOC_SPU_IMM7, + BFD_RELOC_SPU_IMM8, + BFD_RELOC_SPU_IMM10, + BFD_RELOC_SPU_IMM10W, + BFD_RELOC_SPU_IMM16, + BFD_RELOC_SPU_IMM16W, + BFD_RELOC_SPU_IMM18, + BFD_RELOC_SPU_PCREL9a, + BFD_RELOC_SPU_PCREL9b, + BFD_RELOC_SPU_PCREL16, + BFD_RELOC_SPU_LO16, + BFD_RELOC_SPU_HI16, + BFD_RELOC_SPU_PPU32, + BFD_RELOC_SPU_PPU64, + BFD_RELOC_SPU_ADD_PIC, + + /* Alpha ECOFF and ELF relocations. Some of these treat the symbol or + "addend" in some special way. + For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when + writing; when reading, it will be the absolute section symbol. The + addend is the displacement in bytes of the "lda" instruction from + the "ldah" instruction (which is at the address of this reloc). */ + BFD_RELOC_ALPHA_GPDISP_HI16, + + /* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as + with GPDISP_HI16 relocs. The addend is ignored when writing the + relocations out, and is filled in with the file's GP value on + reading, for convenience. */ + BFD_RELOC_ALPHA_GPDISP_LO16, + + /* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 + relocation except that there is no accompanying GPDISP_LO16 + relocation. */ + BFD_RELOC_ALPHA_GPDISP, + + /* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; + the assembler turns it into a LDQ instruction to load the address of + the symbol, and then fills in a register in the real instruction. + + The LITERAL reloc, at the LDQ instruction, refers to the .lita + section symbol. The addend is ignored when writing, but is filled + in with the file's GP value on reading, for convenience, as with the + GPDISP_LO16 reloc. + + The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. + It should refer to the symbol to be referenced, as with 16_GOTOFF, + but it generates output not based on the position within the .got + section, but relative to the GP value chosen for the file during the + final link stage. + + The LITUSE reloc, on the instruction using the loaded address, gives + information to the linker that it might be able to use to optimize + away some literal section references. The symbol is ignored (read + as the absolute section symbol), and the "addend" indicates the type + of instruction using the register: + 1 - "memory" fmt insn + 2 - byte-manipulation (byte offset reg) + 3 - jsr (target of branch) */ + BFD_RELOC_ALPHA_LITERAL, + BFD_RELOC_ALPHA_ELF_LITERAL, + BFD_RELOC_ALPHA_LITUSE, + + /* The HINT relocation indicates a value that should be filled into the + "hint" field of a jmp/jsr/ret instruction, for possible branch- + prediction logic which may be provided on some processors. */ + BFD_RELOC_ALPHA_HINT, + + /* The LINKAGE relocation outputs a linkage pair in the object file, + which is filled by the linker. */ + BFD_RELOC_ALPHA_LINKAGE, + + /* The CODEADDR relocation outputs a STO_CA in the object file, + which is filled by the linker. */ + BFD_RELOC_ALPHA_CODEADDR, + + /* The GPREL_HI/LO relocations together form a 32-bit offset from the + GP register. */ + BFD_RELOC_ALPHA_GPREL_HI16, + BFD_RELOC_ALPHA_GPREL_LO16, + + /* Like BFD_RELOC_23_PCREL_S2, except that the source and target must + share a common GP, and the target address is adjusted for + STO_ALPHA_STD_GPLOAD. */ + BFD_RELOC_ALPHA_BRSGP, + + /* The NOP relocation outputs a NOP if the longword displacement + between two procedure entry points is < 2^21. */ + BFD_RELOC_ALPHA_NOP, + + /* The BSR relocation outputs a BSR if the longword displacement + between two procedure entry points is < 2^21. */ + BFD_RELOC_ALPHA_BSR, + + /* The LDA relocation outputs a LDA if the longword displacement + between two procedure entry points is < 2^16. */ + BFD_RELOC_ALPHA_LDA, + + /* The BOH relocation outputs a BSR if the longword displacement + between two procedure entry points is < 2^21, or else a hint. */ + BFD_RELOC_ALPHA_BOH, + + /* Alpha thread-local storage relocations. */ + BFD_RELOC_ALPHA_TLSGD, + BFD_RELOC_ALPHA_TLSLDM, + BFD_RELOC_ALPHA_DTPMOD64, + BFD_RELOC_ALPHA_GOTDTPREL16, + BFD_RELOC_ALPHA_DTPREL64, + BFD_RELOC_ALPHA_DTPREL_HI16, + BFD_RELOC_ALPHA_DTPREL_LO16, + BFD_RELOC_ALPHA_DTPREL16, + BFD_RELOC_ALPHA_GOTTPREL16, + BFD_RELOC_ALPHA_TPREL64, + BFD_RELOC_ALPHA_TPREL_HI16, + BFD_RELOC_ALPHA_TPREL_LO16, + BFD_RELOC_ALPHA_TPREL16, + + /* The MIPS jump instruction. */ + BFD_RELOC_MIPS_JMP, + BFD_RELOC_MICROMIPS_JMP, + + /* The MIPS16 jump instruction. */ + BFD_RELOC_MIPS16_JMP, + + /* MIPS16 GP relative reloc. */ + BFD_RELOC_MIPS16_GPREL, + + /* High 16 bits of 32-bit value; simple reloc. */ + BFD_RELOC_HI16, + + /* High 16 bits of 32-bit value but the low 16 bits will be sign + extended and added to form the final result. If the low 16 + bits form a negative number, we need to add one to the high value + to compensate for the borrow when the low bits are added. */ + BFD_RELOC_HI16_S, + + /* Low 16 bits. */ + BFD_RELOC_LO16, + + /* High 16 bits of 32-bit pc-relative value. */ + BFD_RELOC_HI16_PCREL, + + /* High 16 bits of 32-bit pc-relative value, adjusted. */ + BFD_RELOC_HI16_S_PCREL, + + /* Low 16 bits of pc-relative value. */ + BFD_RELOC_LO16_PCREL, + + /* Equivalent of BFD_RELOC_MIPS_*, but with the MIPS16 layout of + 16-bit immediate fields. */ + BFD_RELOC_MIPS16_GOT16, + BFD_RELOC_MIPS16_CALL16, + + /* MIPS16 high 16 bits of 32-bit value. */ + BFD_RELOC_MIPS16_HI16, + + /* MIPS16 high 16 bits of 32-bit value but the low 16 bits will be sign + extended and added to form the final result. If the low 16 + bits form a negative number, we need to add one to the high value + to compensate for the borrow when the low bits are added. */ + BFD_RELOC_MIPS16_HI16_S, + + /* MIPS16 low 16 bits. */ + BFD_RELOC_MIPS16_LO16, + + /* MIPS16 TLS relocations. */ + BFD_RELOC_MIPS16_TLS_GD, + BFD_RELOC_MIPS16_TLS_LDM, + BFD_RELOC_MIPS16_TLS_DTPREL_HI16, + BFD_RELOC_MIPS16_TLS_DTPREL_LO16, + BFD_RELOC_MIPS16_TLS_GOTTPREL, + BFD_RELOC_MIPS16_TLS_TPREL_HI16, + BFD_RELOC_MIPS16_TLS_TPREL_LO16, + + /* Relocation against a MIPS literal section. */ + BFD_RELOC_MIPS_LITERAL, + BFD_RELOC_MICROMIPS_LITERAL, + + /* microMIPS PC-relative relocations. */ + BFD_RELOC_MICROMIPS_7_PCREL_S1, + BFD_RELOC_MICROMIPS_10_PCREL_S1, + BFD_RELOC_MICROMIPS_16_PCREL_S1, + + /* MIPS16 PC-relative relocation. */ + BFD_RELOC_MIPS16_16_PCREL_S1, + + /* MIPS PC-relative relocations. */ + BFD_RELOC_MIPS_21_PCREL_S2, + BFD_RELOC_MIPS_26_PCREL_S2, + BFD_RELOC_MIPS_18_PCREL_S3, + BFD_RELOC_MIPS_19_PCREL_S2, + + /* microMIPS versions of generic BFD relocs. */ + BFD_RELOC_MICROMIPS_GPREL16, + BFD_RELOC_MICROMIPS_HI16, + BFD_RELOC_MICROMIPS_HI16_S, + BFD_RELOC_MICROMIPS_LO16, + + /* MIPS ELF relocations. */ + BFD_RELOC_MIPS_GOT16, + BFD_RELOC_MICROMIPS_GOT16, + BFD_RELOC_MIPS_CALL16, + BFD_RELOC_MICROMIPS_CALL16, + BFD_RELOC_MIPS_GOT_HI16, + BFD_RELOC_MICROMIPS_GOT_HI16, + BFD_RELOC_MIPS_GOT_LO16, + BFD_RELOC_MICROMIPS_GOT_LO16, + BFD_RELOC_MIPS_CALL_HI16, + BFD_RELOC_MICROMIPS_CALL_HI16, + BFD_RELOC_MIPS_CALL_LO16, + BFD_RELOC_MICROMIPS_CALL_LO16, + BFD_RELOC_MIPS_SUB, + BFD_RELOC_MICROMIPS_SUB, + BFD_RELOC_MIPS_GOT_PAGE, + BFD_RELOC_MICROMIPS_GOT_PAGE, + BFD_RELOC_MIPS_GOT_OFST, + BFD_RELOC_MICROMIPS_GOT_OFST, + BFD_RELOC_MIPS_GOT_DISP, + BFD_RELOC_MICROMIPS_GOT_DISP, + BFD_RELOC_MIPS_SHIFT5, + BFD_RELOC_MIPS_SHIFT6, + BFD_RELOC_MIPS_INSERT_A, + BFD_RELOC_MIPS_INSERT_B, + BFD_RELOC_MIPS_DELETE, + BFD_RELOC_MIPS_HIGHEST, + BFD_RELOC_MICROMIPS_HIGHEST, + BFD_RELOC_MIPS_HIGHER, + BFD_RELOC_MICROMIPS_HIGHER, + BFD_RELOC_MIPS_SCN_DISP, + BFD_RELOC_MICROMIPS_SCN_DISP, + BFD_RELOC_MIPS_16, + BFD_RELOC_MIPS_RELGOT, + BFD_RELOC_MIPS_JALR, + BFD_RELOC_MICROMIPS_JALR, + BFD_RELOC_MIPS_TLS_DTPMOD32, + BFD_RELOC_MIPS_TLS_DTPREL32, + BFD_RELOC_MIPS_TLS_DTPMOD64, + BFD_RELOC_MIPS_TLS_DTPREL64, + BFD_RELOC_MIPS_TLS_GD, + BFD_RELOC_MICROMIPS_TLS_GD, + BFD_RELOC_MIPS_TLS_LDM, + BFD_RELOC_MICROMIPS_TLS_LDM, + BFD_RELOC_MIPS_TLS_DTPREL_HI16, + BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16, + BFD_RELOC_MIPS_TLS_DTPREL_LO16, + BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16, + BFD_RELOC_MIPS_TLS_GOTTPREL, + BFD_RELOC_MICROMIPS_TLS_GOTTPREL, + BFD_RELOC_MIPS_TLS_TPREL32, + BFD_RELOC_MIPS_TLS_TPREL64, + BFD_RELOC_MIPS_TLS_TPREL_HI16, + BFD_RELOC_MICROMIPS_TLS_TPREL_HI16, + BFD_RELOC_MIPS_TLS_TPREL_LO16, + BFD_RELOC_MICROMIPS_TLS_TPREL_LO16, + BFD_RELOC_MIPS_EH, + + /* MIPS ELF relocations (VxWorks and PLT extensions). */ + BFD_RELOC_MIPS_COPY, + BFD_RELOC_MIPS_JUMP_SLOT, + + /* Moxie ELF relocations. */ + BFD_RELOC_MOXIE_10_PCREL, + + /* FT32 ELF relocations. */ + BFD_RELOC_FT32_10, + BFD_RELOC_FT32_20, + BFD_RELOC_FT32_17, + BFD_RELOC_FT32_18, + BFD_RELOC_FT32_RELAX, + BFD_RELOC_FT32_SC0, + BFD_RELOC_FT32_SC1, + BFD_RELOC_FT32_15, + BFD_RELOC_FT32_DIFF32, + + /* Fujitsu Frv Relocations. */ + BFD_RELOC_FRV_LABEL16, + BFD_RELOC_FRV_LABEL24, + BFD_RELOC_FRV_LO16, + BFD_RELOC_FRV_HI16, + BFD_RELOC_FRV_GPREL12, + BFD_RELOC_FRV_GPRELU12, + BFD_RELOC_FRV_GPREL32, + BFD_RELOC_FRV_GPRELHI, + BFD_RELOC_FRV_GPRELLO, + BFD_RELOC_FRV_GOT12, + BFD_RELOC_FRV_GOTHI, + BFD_RELOC_FRV_GOTLO, + BFD_RELOC_FRV_FUNCDESC, + BFD_RELOC_FRV_FUNCDESC_GOT12, + BFD_RELOC_FRV_FUNCDESC_GOTHI, + BFD_RELOC_FRV_FUNCDESC_GOTLO, + BFD_RELOC_FRV_FUNCDESC_VALUE, + BFD_RELOC_FRV_FUNCDESC_GOTOFF12, + BFD_RELOC_FRV_FUNCDESC_GOTOFFHI, + BFD_RELOC_FRV_FUNCDESC_GOTOFFLO, + BFD_RELOC_FRV_GOTOFF12, + BFD_RELOC_FRV_GOTOFFHI, + BFD_RELOC_FRV_GOTOFFLO, + BFD_RELOC_FRV_GETTLSOFF, + BFD_RELOC_FRV_TLSDESC_VALUE, + BFD_RELOC_FRV_GOTTLSDESC12, + BFD_RELOC_FRV_GOTTLSDESCHI, + BFD_RELOC_FRV_GOTTLSDESCLO, + BFD_RELOC_FRV_TLSMOFF12, + BFD_RELOC_FRV_TLSMOFFHI, + BFD_RELOC_FRV_TLSMOFFLO, + BFD_RELOC_FRV_GOTTLSOFF12, + BFD_RELOC_FRV_GOTTLSOFFHI, + BFD_RELOC_FRV_GOTTLSOFFLO, + BFD_RELOC_FRV_TLSOFF, + BFD_RELOC_FRV_TLSDESC_RELAX, + BFD_RELOC_FRV_GETTLSOFF_RELAX, + BFD_RELOC_FRV_TLSOFF_RELAX, + BFD_RELOC_FRV_TLSMOFF, + + /* This is a 24bit GOT-relative reloc for the mn10300. */ + BFD_RELOC_MN10300_GOTOFF24, + + /* This is a 32bit GOT-relative reloc for the mn10300, offset by two + bytes in the instruction. */ + BFD_RELOC_MN10300_GOT32, + + /* This is a 24bit GOT-relative reloc for the mn10300, offset by two + bytes in the instruction. */ + BFD_RELOC_MN10300_GOT24, + + /* This is a 16bit GOT-relative reloc for the mn10300, offset by two + bytes in the instruction. */ + BFD_RELOC_MN10300_GOT16, + + /* Copy symbol at runtime. */ + BFD_RELOC_MN10300_COPY, + + /* Create GOT entry. */ + BFD_RELOC_MN10300_GLOB_DAT, + + /* Create PLT entry. */ + BFD_RELOC_MN10300_JMP_SLOT, + + /* Adjust by program base. */ + BFD_RELOC_MN10300_RELATIVE, + + /* Together with another reloc targeted at the same location, allows + for a value that is the difference of two symbols in the same + section. */ + BFD_RELOC_MN10300_SYM_DIFF, + + /* The addend of this reloc is an alignment power that must be honoured + at the offset's location, regardless of linker relaxation. */ + BFD_RELOC_MN10300_ALIGN, + + /* Various TLS-related relocations. */ + BFD_RELOC_MN10300_TLS_GD, + BFD_RELOC_MN10300_TLS_LD, + BFD_RELOC_MN10300_TLS_LDO, + BFD_RELOC_MN10300_TLS_GOTIE, + BFD_RELOC_MN10300_TLS_IE, + BFD_RELOC_MN10300_TLS_LE, + BFD_RELOC_MN10300_TLS_DTPMOD, + BFD_RELOC_MN10300_TLS_DTPOFF, + BFD_RELOC_MN10300_TLS_TPOFF, + + /* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in + the instruction. */ + BFD_RELOC_MN10300_32_PCREL, + + /* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in + the instruction. */ + BFD_RELOC_MN10300_16_PCREL, + + /* i386/elf relocations. */ + BFD_RELOC_386_GOT32, + BFD_RELOC_386_PLT32, + BFD_RELOC_386_COPY, + BFD_RELOC_386_GLOB_DAT, + BFD_RELOC_386_JUMP_SLOT, + BFD_RELOC_386_RELATIVE, + BFD_RELOC_386_GOTOFF, + BFD_RELOC_386_GOTPC, + BFD_RELOC_386_TLS_TPOFF, + BFD_RELOC_386_TLS_IE, + BFD_RELOC_386_TLS_GOTIE, + BFD_RELOC_386_TLS_LE, + BFD_RELOC_386_TLS_GD, + BFD_RELOC_386_TLS_LDM, + BFD_RELOC_386_TLS_LDO_32, + BFD_RELOC_386_TLS_IE_32, + BFD_RELOC_386_TLS_LE_32, + BFD_RELOC_386_TLS_DTPMOD32, + BFD_RELOC_386_TLS_DTPOFF32, + BFD_RELOC_386_TLS_TPOFF32, + BFD_RELOC_386_TLS_GOTDESC, + BFD_RELOC_386_TLS_DESC_CALL, + BFD_RELOC_386_TLS_DESC, + BFD_RELOC_386_IRELATIVE, + BFD_RELOC_386_GOT32X, + + /* x86-64/elf relocations. */ + BFD_RELOC_X86_64_GOT32, + BFD_RELOC_X86_64_PLT32, + BFD_RELOC_X86_64_COPY, + BFD_RELOC_X86_64_GLOB_DAT, + BFD_RELOC_X86_64_JUMP_SLOT, + BFD_RELOC_X86_64_RELATIVE, + BFD_RELOC_X86_64_GOTPCREL, + BFD_RELOC_X86_64_32S, + BFD_RELOC_X86_64_DTPMOD64, + BFD_RELOC_X86_64_DTPOFF64, + BFD_RELOC_X86_64_TPOFF64, + BFD_RELOC_X86_64_TLSGD, + BFD_RELOC_X86_64_TLSLD, + BFD_RELOC_X86_64_DTPOFF32, + BFD_RELOC_X86_64_GOTTPOFF, + BFD_RELOC_X86_64_TPOFF32, + BFD_RELOC_X86_64_GOTOFF64, + BFD_RELOC_X86_64_GOTPC32, + BFD_RELOC_X86_64_GOT64, + BFD_RELOC_X86_64_GOTPCREL64, + BFD_RELOC_X86_64_GOTPC64, + BFD_RELOC_X86_64_GOTPLT64, + BFD_RELOC_X86_64_PLTOFF64, + BFD_RELOC_X86_64_GOTPC32_TLSDESC, + BFD_RELOC_X86_64_TLSDESC_CALL, + BFD_RELOC_X86_64_TLSDESC, + BFD_RELOC_X86_64_IRELATIVE, + BFD_RELOC_X86_64_PC32_BND, + BFD_RELOC_X86_64_PLT32_BND, + BFD_RELOC_X86_64_GOTPCRELX, + BFD_RELOC_X86_64_REX_GOTPCRELX, + BFD_RELOC_X86_64_CODE_4_GOTPCRELX, + BFD_RELOC_X86_64_CODE_4_GOTTPOFF, + BFD_RELOC_X86_64_CODE_4_GOTPC32_TLSDESC, + BFD_RELOC_X86_64_CODE_5_GOTPCRELX, + BFD_RELOC_X86_64_CODE_5_GOTTPOFF, + BFD_RELOC_X86_64_CODE_5_GOTPC32_TLSDESC, + BFD_RELOC_X86_64_CODE_6_GOTPCRELX, + BFD_RELOC_X86_64_CODE_6_GOTTPOFF, + BFD_RELOC_X86_64_CODE_6_GOTPC32_TLSDESC, + + /* ns32k relocations. */ + BFD_RELOC_NS32K_IMM_8, + BFD_RELOC_NS32K_IMM_16, + BFD_RELOC_NS32K_IMM_32, + BFD_RELOC_NS32K_IMM_8_PCREL, + BFD_RELOC_NS32K_IMM_16_PCREL, + BFD_RELOC_NS32K_IMM_32_PCREL, + BFD_RELOC_NS32K_DISP_8, + BFD_RELOC_NS32K_DISP_16, + BFD_RELOC_NS32K_DISP_32, + BFD_RELOC_NS32K_DISP_8_PCREL, + BFD_RELOC_NS32K_DISP_16_PCREL, + BFD_RELOC_NS32K_DISP_32_PCREL, + + /* PDP11 relocations. */ + BFD_RELOC_PDP11_DISP_8_PCREL, + BFD_RELOC_PDP11_DISP_6_PCREL, + + /* Picojava relocs. Not all of these appear in object files. */ + BFD_RELOC_PJ_CODE_HI16, + BFD_RELOC_PJ_CODE_LO16, + BFD_RELOC_PJ_CODE_DIR16, + BFD_RELOC_PJ_CODE_DIR32, + BFD_RELOC_PJ_CODE_REL16, + BFD_RELOC_PJ_CODE_REL32, + + /* Power(rs6000) and PowerPC relocations. */ + BFD_RELOC_PPC_B26, + BFD_RELOC_PPC_BA26, + BFD_RELOC_PPC_TOC16, + BFD_RELOC_PPC_TOC16_LO, + BFD_RELOC_PPC_TOC16_HI, + BFD_RELOC_PPC_B16, + BFD_RELOC_PPC_B16_BRTAKEN, + BFD_RELOC_PPC_B16_BRNTAKEN, + BFD_RELOC_PPC_BA16, + BFD_RELOC_PPC_BA16_BRTAKEN, + BFD_RELOC_PPC_BA16_BRNTAKEN, + BFD_RELOC_PPC_COPY, + BFD_RELOC_PPC_GLOB_DAT, + BFD_RELOC_PPC_JMP_SLOT, + BFD_RELOC_PPC_RELATIVE, + BFD_RELOC_PPC_LOCAL24PC, + BFD_RELOC_PPC_EMB_NADDR32, + BFD_RELOC_PPC_EMB_NADDR16, + BFD_RELOC_PPC_EMB_NADDR16_LO, + BFD_RELOC_PPC_EMB_NADDR16_HI, + BFD_RELOC_PPC_EMB_NADDR16_HA, + BFD_RELOC_PPC_EMB_SDAI16, + BFD_RELOC_PPC_EMB_SDA2I16, + BFD_RELOC_PPC_EMB_SDA2REL, + BFD_RELOC_PPC_EMB_SDA21, + BFD_RELOC_PPC_EMB_MRKREF, + BFD_RELOC_PPC_EMB_RELSEC16, + BFD_RELOC_PPC_EMB_RELST_LO, + BFD_RELOC_PPC_EMB_RELST_HI, + BFD_RELOC_PPC_EMB_RELST_HA, + BFD_RELOC_PPC_EMB_BIT_FLD, + BFD_RELOC_PPC_EMB_RELSDA, + BFD_RELOC_PPC_VLE_REL8, + BFD_RELOC_PPC_VLE_REL15, + BFD_RELOC_PPC_VLE_REL24, + BFD_RELOC_PPC_VLE_LO16A, + BFD_RELOC_PPC_VLE_LO16D, + BFD_RELOC_PPC_VLE_HI16A, + BFD_RELOC_PPC_VLE_HI16D, + BFD_RELOC_PPC_VLE_HA16A, + BFD_RELOC_PPC_VLE_HA16D, + BFD_RELOC_PPC_VLE_SDA21, + BFD_RELOC_PPC_VLE_SDA21_LO, + BFD_RELOC_PPC_VLE_SDAREL_LO16A, + BFD_RELOC_PPC_VLE_SDAREL_LO16D, + BFD_RELOC_PPC_VLE_SDAREL_HI16A, + BFD_RELOC_PPC_VLE_SDAREL_HI16D, + BFD_RELOC_PPC_VLE_SDAREL_HA16A, + BFD_RELOC_PPC_VLE_SDAREL_HA16D, + BFD_RELOC_PPC_16DX_HA, + BFD_RELOC_PPC_REL16DX_HA, + BFD_RELOC_PPC_NEG, + BFD_RELOC_PPC64_HIGHER, + BFD_RELOC_PPC64_HIGHER_S, + BFD_RELOC_PPC64_HIGHEST, + BFD_RELOC_PPC64_HIGHEST_S, + BFD_RELOC_PPC64_TOC16_LO, + BFD_RELOC_PPC64_TOC16_HI, + BFD_RELOC_PPC64_TOC16_HA, + BFD_RELOC_PPC64_TOC, + BFD_RELOC_PPC64_PLTGOT16, + BFD_RELOC_PPC64_PLTGOT16_LO, + BFD_RELOC_PPC64_PLTGOT16_HI, + BFD_RELOC_PPC64_PLTGOT16_HA, + BFD_RELOC_PPC64_ADDR16_DS, + BFD_RELOC_PPC64_ADDR16_LO_DS, + BFD_RELOC_PPC64_GOT16_DS, + BFD_RELOC_PPC64_GOT16_LO_DS, + BFD_RELOC_PPC64_PLT16_LO_DS, + BFD_RELOC_PPC64_SECTOFF_DS, + BFD_RELOC_PPC64_SECTOFF_LO_DS, + BFD_RELOC_PPC64_TOC16_DS, + BFD_RELOC_PPC64_TOC16_LO_DS, + BFD_RELOC_PPC64_PLTGOT16_DS, + BFD_RELOC_PPC64_PLTGOT16_LO_DS, + BFD_RELOC_PPC64_ADDR16_HIGH, + BFD_RELOC_PPC64_ADDR16_HIGHA, + BFD_RELOC_PPC64_REL16_HIGH, + BFD_RELOC_PPC64_REL16_HIGHA, + BFD_RELOC_PPC64_REL16_HIGHER, + BFD_RELOC_PPC64_REL16_HIGHERA, + BFD_RELOC_PPC64_REL16_HIGHEST, + BFD_RELOC_PPC64_REL16_HIGHESTA, + BFD_RELOC_PPC64_ADDR64_LOCAL, + BFD_RELOC_PPC64_ENTRY, + BFD_RELOC_PPC64_REL24_NOTOC, + BFD_RELOC_PPC64_REL24_P9NOTOC, + BFD_RELOC_PPC64_D34, + BFD_RELOC_PPC64_D34_LO, + BFD_RELOC_PPC64_D34_HI30, + BFD_RELOC_PPC64_D34_HA30, + BFD_RELOC_PPC64_PCREL34, + BFD_RELOC_PPC64_GOT_PCREL34, + BFD_RELOC_PPC64_PLT_PCREL34, + BFD_RELOC_PPC64_ADDR16_HIGHER34, + BFD_RELOC_PPC64_ADDR16_HIGHERA34, + BFD_RELOC_PPC64_ADDR16_HIGHEST34, + BFD_RELOC_PPC64_ADDR16_HIGHESTA34, + BFD_RELOC_PPC64_REL16_HIGHER34, + BFD_RELOC_PPC64_REL16_HIGHERA34, + BFD_RELOC_PPC64_REL16_HIGHEST34, + BFD_RELOC_PPC64_REL16_HIGHESTA34, + BFD_RELOC_PPC64_D28, + BFD_RELOC_PPC64_PCREL28, + + /* PowerPC and PowerPC64 thread-local storage relocations. */ + BFD_RELOC_PPC_TLS, + BFD_RELOC_PPC_TLSGD, + BFD_RELOC_PPC_TLSLD, + BFD_RELOC_PPC_TLSLE, + BFD_RELOC_PPC_TLSIE, + BFD_RELOC_PPC_TLSM, + BFD_RELOC_PPC_TLSML, + BFD_RELOC_PPC_DTPMOD, + BFD_RELOC_PPC_TPREL16, + BFD_RELOC_PPC_TPREL16_LO, + BFD_RELOC_PPC_TPREL16_HI, + BFD_RELOC_PPC_TPREL16_HA, + BFD_RELOC_PPC_TPREL, + BFD_RELOC_PPC_DTPREL16, + BFD_RELOC_PPC_DTPREL16_LO, + BFD_RELOC_PPC_DTPREL16_HI, + BFD_RELOC_PPC_DTPREL16_HA, + BFD_RELOC_PPC_DTPREL, + BFD_RELOC_PPC_GOT_TLSGD16, + BFD_RELOC_PPC_GOT_TLSGD16_LO, + BFD_RELOC_PPC_GOT_TLSGD16_HI, + BFD_RELOC_PPC_GOT_TLSGD16_HA, + BFD_RELOC_PPC_GOT_TLSLD16, + BFD_RELOC_PPC_GOT_TLSLD16_LO, + BFD_RELOC_PPC_GOT_TLSLD16_HI, + BFD_RELOC_PPC_GOT_TLSLD16_HA, + BFD_RELOC_PPC_GOT_TPREL16, + BFD_RELOC_PPC_GOT_TPREL16_LO, + BFD_RELOC_PPC_GOT_TPREL16_HI, + BFD_RELOC_PPC_GOT_TPREL16_HA, + BFD_RELOC_PPC_GOT_DTPREL16, + BFD_RELOC_PPC_GOT_DTPREL16_LO, + BFD_RELOC_PPC_GOT_DTPREL16_HI, + BFD_RELOC_PPC_GOT_DTPREL16_HA, + BFD_RELOC_PPC64_TLSGD, + BFD_RELOC_PPC64_TLSLD, + BFD_RELOC_PPC64_TLSLE, + BFD_RELOC_PPC64_TLSIE, + BFD_RELOC_PPC64_TLSM, + BFD_RELOC_PPC64_TLSML, + BFD_RELOC_PPC64_TPREL16_DS, + BFD_RELOC_PPC64_TPREL16_LO_DS, + BFD_RELOC_PPC64_TPREL16_HIGH, + BFD_RELOC_PPC64_TPREL16_HIGHA, + BFD_RELOC_PPC64_TPREL16_HIGHER, + BFD_RELOC_PPC64_TPREL16_HIGHERA, + BFD_RELOC_PPC64_TPREL16_HIGHEST, + BFD_RELOC_PPC64_TPREL16_HIGHESTA, + BFD_RELOC_PPC64_DTPREL16_DS, + BFD_RELOC_PPC64_DTPREL16_LO_DS, + BFD_RELOC_PPC64_DTPREL16_HIGH, + BFD_RELOC_PPC64_DTPREL16_HIGHA, + BFD_RELOC_PPC64_DTPREL16_HIGHER, + BFD_RELOC_PPC64_DTPREL16_HIGHERA, + BFD_RELOC_PPC64_DTPREL16_HIGHEST, + BFD_RELOC_PPC64_DTPREL16_HIGHESTA, + BFD_RELOC_PPC64_TPREL34, + BFD_RELOC_PPC64_DTPREL34, + BFD_RELOC_PPC64_GOT_TLSGD_PCREL34, + BFD_RELOC_PPC64_GOT_TLSLD_PCREL34, + BFD_RELOC_PPC64_GOT_TPREL_PCREL34, + BFD_RELOC_PPC64_GOT_DTPREL_PCREL34, + BFD_RELOC_PPC64_TLS_PCREL, + + /* IBM 370/390 relocations. */ + BFD_RELOC_I370_D12, + + /* The type of reloc used to build a constructor table - at the moment + probably a 32 bit wide absolute relocation, but the target can choose. + It generally does map to one of the other relocation types. */ + BFD_RELOC_CTOR, + + /* ARM 26 bit pc-relative branch. The lowest two bits must be zero and + are not stored in the instruction. */ + BFD_RELOC_ARM_PCREL_BRANCH, + + /* ARM 26 bit pc-relative branch. The lowest bit must be zero and is + not stored in the instruction. The 2nd lowest bit comes from a 1 bit + field in the instruction. */ + BFD_RELOC_ARM_PCREL_BLX, + + /* Thumb 22 bit pc-relative branch. The lowest bit must be zero and is + not stored in the instruction. The 2nd lowest bit comes from a 1 bit + field in the instruction. */ + BFD_RELOC_THUMB_PCREL_BLX, + + /* ARM 26-bit pc-relative branch for an unconditional BL or BLX + instruction. */ + BFD_RELOC_ARM_PCREL_CALL, + + /* ARM 26-bit pc-relative branch for B or conditional BL instruction. */ + BFD_RELOC_ARM_PCREL_JUMP, + + /* ARM 5-bit pc-relative branch for Branch Future instructions. */ + BFD_RELOC_THUMB_PCREL_BRANCH5, + + /* ARM 6-bit pc-relative branch for BFCSEL instruction. */ + BFD_RELOC_THUMB_PCREL_BFCSEL, + + /* ARM 17-bit pc-relative branch for Branch Future instructions. */ + BFD_RELOC_ARM_THUMB_BF17, + + /* ARM 13-bit pc-relative branch for BFCSEL instruction. */ + BFD_RELOC_ARM_THUMB_BF13, + + /* ARM 19-bit pc-relative branch for Branch Future Link instruction. */ + BFD_RELOC_ARM_THUMB_BF19, + + /* ARM 12-bit pc-relative branch for Low Overhead Loop instructions. */ + BFD_RELOC_ARM_THUMB_LOOP12, + + /* Thumb 7-, 9-, 12-, 20-, 23-, and 25-bit pc-relative branches. + The lowest bit must be zero and is not stored in the instruction. + Note that the corresponding ELF R_ARM_THM_JUMPnn constant has an + "nn" one smaller in all cases. Note further that BRANCH23 + corresponds to R_ARM_THM_CALL. */ + BFD_RELOC_THUMB_PCREL_BRANCH7, + BFD_RELOC_THUMB_PCREL_BRANCH9, + BFD_RELOC_THUMB_PCREL_BRANCH12, + BFD_RELOC_THUMB_PCREL_BRANCH20, + BFD_RELOC_THUMB_PCREL_BRANCH23, + BFD_RELOC_THUMB_PCREL_BRANCH25, + + /* 12-bit immediate offset, used in ARM-format ldr and str instructions. */ + BFD_RELOC_ARM_OFFSET_IMM, + + /* 5-bit immediate offset, used in Thumb-format ldr and str instructions. */ + BFD_RELOC_ARM_THUMB_OFFSET, + + /* Pc-relative or absolute relocation depending on target. Used for + entries in .init_array sections. */ + BFD_RELOC_ARM_TARGET1, + + /* Read-only segment base relative address. */ + BFD_RELOC_ARM_ROSEGREL32, + + /* Data segment base relative address. */ + BFD_RELOC_ARM_SBREL32, + + /* This reloc is used for references to RTTI data from exception + handling tables. The actual definition depends on the target. It + may be a pc-relative or some form of GOT-indirect relocation. */ + BFD_RELOC_ARM_TARGET2, + + /* 31-bit PC relative address. */ + BFD_RELOC_ARM_PREL31, + + /* Low and High halfword relocations for MOVW and MOVT instructions. */ + BFD_RELOC_ARM_MOVW, + BFD_RELOC_ARM_MOVT, + BFD_RELOC_ARM_MOVW_PCREL, + BFD_RELOC_ARM_MOVT_PCREL, + BFD_RELOC_ARM_THUMB_MOVW, + BFD_RELOC_ARM_THUMB_MOVT, + BFD_RELOC_ARM_THUMB_MOVW_PCREL, + BFD_RELOC_ARM_THUMB_MOVT_PCREL, + + /* ARM FDPIC specific relocations. */ + BFD_RELOC_ARM_GOTFUNCDESC, + BFD_RELOC_ARM_GOTOFFFUNCDESC, + BFD_RELOC_ARM_FUNCDESC, + BFD_RELOC_ARM_FUNCDESC_VALUE, + BFD_RELOC_ARM_TLS_GD32_FDPIC, + BFD_RELOC_ARM_TLS_LDM32_FDPIC, + BFD_RELOC_ARM_TLS_IE32_FDPIC, + + /* Relocations for setting up GOTs and PLTs for shared libraries. */ + BFD_RELOC_ARM_JUMP_SLOT, + BFD_RELOC_ARM_GLOB_DAT, + BFD_RELOC_ARM_GOT32, + BFD_RELOC_ARM_PLT32, + BFD_RELOC_ARM_RELATIVE, + BFD_RELOC_ARM_GOTOFF, + BFD_RELOC_ARM_GOTPC, + BFD_RELOC_ARM_GOT_PREL, + + /* ARM thread-local storage relocations. */ + BFD_RELOC_ARM_TLS_GD32, + BFD_RELOC_ARM_TLS_LDO32, + BFD_RELOC_ARM_TLS_LDM32, + BFD_RELOC_ARM_TLS_DTPOFF32, + BFD_RELOC_ARM_TLS_DTPMOD32, + BFD_RELOC_ARM_TLS_TPOFF32, + BFD_RELOC_ARM_TLS_IE32, + BFD_RELOC_ARM_TLS_LE32, + BFD_RELOC_ARM_TLS_GOTDESC, + BFD_RELOC_ARM_TLS_CALL, + BFD_RELOC_ARM_THM_TLS_CALL, + BFD_RELOC_ARM_TLS_DESCSEQ, + BFD_RELOC_ARM_THM_TLS_DESCSEQ, + BFD_RELOC_ARM_TLS_DESC, + + /* ARM group relocations. */ + BFD_RELOC_ARM_ALU_PC_G0_NC, + BFD_RELOC_ARM_ALU_PC_G0, + BFD_RELOC_ARM_ALU_PC_G1_NC, + BFD_RELOC_ARM_ALU_PC_G1, + BFD_RELOC_ARM_ALU_PC_G2, + BFD_RELOC_ARM_LDR_PC_G0, + BFD_RELOC_ARM_LDR_PC_G1, + BFD_RELOC_ARM_LDR_PC_G2, + BFD_RELOC_ARM_LDRS_PC_G0, + BFD_RELOC_ARM_LDRS_PC_G1, + BFD_RELOC_ARM_LDRS_PC_G2, + BFD_RELOC_ARM_LDC_PC_G0, + BFD_RELOC_ARM_LDC_PC_G1, + BFD_RELOC_ARM_LDC_PC_G2, + BFD_RELOC_ARM_ALU_SB_G0_NC, + BFD_RELOC_ARM_ALU_SB_G0, + BFD_RELOC_ARM_ALU_SB_G1_NC, + BFD_RELOC_ARM_ALU_SB_G1, + BFD_RELOC_ARM_ALU_SB_G2, + BFD_RELOC_ARM_LDR_SB_G0, + BFD_RELOC_ARM_LDR_SB_G1, + BFD_RELOC_ARM_LDR_SB_G2, + BFD_RELOC_ARM_LDRS_SB_G0, + BFD_RELOC_ARM_LDRS_SB_G1, + BFD_RELOC_ARM_LDRS_SB_G2, + BFD_RELOC_ARM_LDC_SB_G0, + BFD_RELOC_ARM_LDC_SB_G1, + BFD_RELOC_ARM_LDC_SB_G2, + + /* Annotation of BX instructions. */ + BFD_RELOC_ARM_V4BX, + + /* ARM support for STT_GNU_IFUNC. */ + BFD_RELOC_ARM_IRELATIVE, + + /* Thumb1 relocations to support execute-only code. */ + BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC, + BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC, + BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC, + BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC, + + /* These relocs are only used within the ARM assembler. They are not + (at present) written to any object files. */ + BFD_RELOC_ARM_IMMEDIATE, + BFD_RELOC_ARM_ADRL_IMMEDIATE, + BFD_RELOC_ARM_T32_IMMEDIATE, + BFD_RELOC_ARM_T32_ADD_IMM, + BFD_RELOC_ARM_T32_IMM12, + BFD_RELOC_ARM_T32_ADD_PC12, + BFD_RELOC_ARM_SHIFT_IMM, + BFD_RELOC_ARM_SMC, + BFD_RELOC_ARM_HVC, + BFD_RELOC_ARM_SWI, + BFD_RELOC_ARM_MULTI, + BFD_RELOC_ARM_CP_OFF_IMM, + BFD_RELOC_ARM_CP_OFF_IMM_S2, + BFD_RELOC_ARM_T32_CP_OFF_IMM, + BFD_RELOC_ARM_T32_CP_OFF_IMM_S2, + BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM, + BFD_RELOC_ARM_ADR_IMM, + BFD_RELOC_ARM_LDR_IMM, + BFD_RELOC_ARM_LITERAL, + BFD_RELOC_ARM_IN_POOL, + BFD_RELOC_ARM_OFFSET_IMM8, + BFD_RELOC_ARM_T32_OFFSET_U8, + BFD_RELOC_ARM_T32_OFFSET_IMM, + BFD_RELOC_ARM_HWLITERAL, + BFD_RELOC_ARM_THUMB_ADD, + BFD_RELOC_ARM_THUMB_IMM, + BFD_RELOC_ARM_THUMB_SHIFT, + + /* Renesas / SuperH SH relocs. Not all of these appear in object files. */ + BFD_RELOC_SH_PCDISP8BY2, + BFD_RELOC_SH_PCDISP12BY2, + BFD_RELOC_SH_IMM3, + BFD_RELOC_SH_IMM3U, + BFD_RELOC_SH_DISP12, + BFD_RELOC_SH_DISP12BY2, + BFD_RELOC_SH_DISP12BY4, + BFD_RELOC_SH_DISP12BY8, + BFD_RELOC_SH_DISP20, + BFD_RELOC_SH_DISP20BY8, + BFD_RELOC_SH_IMM4, + BFD_RELOC_SH_IMM4BY2, + BFD_RELOC_SH_IMM4BY4, + BFD_RELOC_SH_IMM8, + BFD_RELOC_SH_IMM8BY2, + BFD_RELOC_SH_IMM8BY4, + BFD_RELOC_SH_PCRELIMM8BY2, + BFD_RELOC_SH_PCRELIMM8BY4, + BFD_RELOC_SH_SWITCH16, + BFD_RELOC_SH_SWITCH32, + BFD_RELOC_SH_USES, + BFD_RELOC_SH_COUNT, + BFD_RELOC_SH_ALIGN, + BFD_RELOC_SH_CODE, + BFD_RELOC_SH_DATA, + BFD_RELOC_SH_LABEL, + BFD_RELOC_SH_LOOP_START, + BFD_RELOC_SH_LOOP_END, + BFD_RELOC_SH_COPY, + BFD_RELOC_SH_GLOB_DAT, + BFD_RELOC_SH_JMP_SLOT, + BFD_RELOC_SH_RELATIVE, + BFD_RELOC_SH_GOTPC, + BFD_RELOC_SH_GOT_LOW16, + BFD_RELOC_SH_GOT_MEDLOW16, + BFD_RELOC_SH_GOT_MEDHI16, + BFD_RELOC_SH_GOT_HI16, + BFD_RELOC_SH_GOTPLT_LOW16, + BFD_RELOC_SH_GOTPLT_MEDLOW16, + BFD_RELOC_SH_GOTPLT_MEDHI16, + BFD_RELOC_SH_GOTPLT_HI16, + BFD_RELOC_SH_PLT_LOW16, + BFD_RELOC_SH_PLT_MEDLOW16, + BFD_RELOC_SH_PLT_MEDHI16, + BFD_RELOC_SH_PLT_HI16, + BFD_RELOC_SH_GOTOFF_LOW16, + BFD_RELOC_SH_GOTOFF_MEDLOW16, + BFD_RELOC_SH_GOTOFF_MEDHI16, + BFD_RELOC_SH_GOTOFF_HI16, + BFD_RELOC_SH_GOTPC_LOW16, + BFD_RELOC_SH_GOTPC_MEDLOW16, + BFD_RELOC_SH_GOTPC_MEDHI16, + BFD_RELOC_SH_GOTPC_HI16, + BFD_RELOC_SH_COPY64, + BFD_RELOC_SH_GLOB_DAT64, + BFD_RELOC_SH_JMP_SLOT64, + BFD_RELOC_SH_RELATIVE64, + BFD_RELOC_SH_GOT10BY4, + BFD_RELOC_SH_GOT10BY8, + BFD_RELOC_SH_GOTPLT10BY4, + BFD_RELOC_SH_GOTPLT10BY8, + BFD_RELOC_SH_GOTPLT32, + BFD_RELOC_SH_SHMEDIA_CODE, + BFD_RELOC_SH_IMMU5, + BFD_RELOC_SH_IMMS6, + BFD_RELOC_SH_IMMS6BY32, + BFD_RELOC_SH_IMMU6, + BFD_RELOC_SH_IMMS10, + BFD_RELOC_SH_IMMS10BY2, + BFD_RELOC_SH_IMMS10BY4, + BFD_RELOC_SH_IMMS10BY8, + BFD_RELOC_SH_IMMS16, + BFD_RELOC_SH_IMMU16, + BFD_RELOC_SH_IMM_LOW16, + BFD_RELOC_SH_IMM_LOW16_PCREL, + BFD_RELOC_SH_IMM_MEDLOW16, + BFD_RELOC_SH_IMM_MEDLOW16_PCREL, + BFD_RELOC_SH_IMM_MEDHI16, + BFD_RELOC_SH_IMM_MEDHI16_PCREL, + BFD_RELOC_SH_IMM_HI16, + BFD_RELOC_SH_IMM_HI16_PCREL, + BFD_RELOC_SH_PT_16, + BFD_RELOC_SH_TLS_GD_32, + BFD_RELOC_SH_TLS_LD_32, + BFD_RELOC_SH_TLS_LDO_32, + BFD_RELOC_SH_TLS_IE_32, + BFD_RELOC_SH_TLS_LE_32, + BFD_RELOC_SH_TLS_DTPMOD32, + BFD_RELOC_SH_TLS_DTPOFF32, + BFD_RELOC_SH_TLS_TPOFF32, + BFD_RELOC_SH_GOT20, + BFD_RELOC_SH_GOTOFF20, + BFD_RELOC_SH_GOTFUNCDESC, + BFD_RELOC_SH_GOTFUNCDESC20, + BFD_RELOC_SH_GOTOFFFUNCDESC, + BFD_RELOC_SH_GOTOFFFUNCDESC20, + BFD_RELOC_SH_FUNCDESC, + + /* ARC relocs. */ + BFD_RELOC_ARC_NONE, + BFD_RELOC_ARC_8, + BFD_RELOC_ARC_16, + BFD_RELOC_ARC_24, + BFD_RELOC_ARC_32, + BFD_RELOC_ARC_N8, + BFD_RELOC_ARC_N16, + BFD_RELOC_ARC_N24, + BFD_RELOC_ARC_N32, + BFD_RELOC_ARC_SDA, + BFD_RELOC_ARC_SECTOFF, + BFD_RELOC_ARC_S21H_PCREL, + BFD_RELOC_ARC_S21W_PCREL, + BFD_RELOC_ARC_S25H_PCREL, + BFD_RELOC_ARC_S25W_PCREL, + BFD_RELOC_ARC_SDA32, + BFD_RELOC_ARC_SDA_LDST, + BFD_RELOC_ARC_SDA_LDST1, + BFD_RELOC_ARC_SDA_LDST2, + BFD_RELOC_ARC_SDA16_LD, + BFD_RELOC_ARC_SDA16_LD1, + BFD_RELOC_ARC_SDA16_LD2, + BFD_RELOC_ARC_S13_PCREL, + BFD_RELOC_ARC_W, + BFD_RELOC_ARC_32_ME, + BFD_RELOC_ARC_32_ME_S, + BFD_RELOC_ARC_N32_ME, + BFD_RELOC_ARC_SECTOFF_ME, + BFD_RELOC_ARC_SDA32_ME, + BFD_RELOC_ARC_W_ME, + BFD_RELOC_AC_SECTOFF_U8, + BFD_RELOC_AC_SECTOFF_U8_1, + BFD_RELOC_AC_SECTOFF_U8_2, + BFD_RELOC_AC_SECTOFF_S9, + BFD_RELOC_AC_SECTOFF_S9_1, + BFD_RELOC_AC_SECTOFF_S9_2, + BFD_RELOC_ARC_SECTOFF_ME_1, + BFD_RELOC_ARC_SECTOFF_ME_2, + BFD_RELOC_ARC_SECTOFF_1, + BFD_RELOC_ARC_SECTOFF_2, + BFD_RELOC_ARC_SDA_12, + BFD_RELOC_ARC_SDA16_ST2, + BFD_RELOC_ARC_32_PCREL, + BFD_RELOC_ARC_PC32, + BFD_RELOC_ARC_GOT32, + BFD_RELOC_ARC_GOTPC32, + BFD_RELOC_ARC_PLT32, + BFD_RELOC_ARC_COPY, + BFD_RELOC_ARC_GLOB_DAT, + BFD_RELOC_ARC_JMP_SLOT, + BFD_RELOC_ARC_RELATIVE, + BFD_RELOC_ARC_GOTOFF, + BFD_RELOC_ARC_GOTPC, + BFD_RELOC_ARC_S21W_PCREL_PLT, + BFD_RELOC_ARC_S25H_PCREL_PLT, + BFD_RELOC_ARC_TLS_DTPMOD, + BFD_RELOC_ARC_TLS_TPOFF, + BFD_RELOC_ARC_TLS_GD_GOT, + BFD_RELOC_ARC_TLS_GD_LD, + BFD_RELOC_ARC_TLS_GD_CALL, + BFD_RELOC_ARC_TLS_IE_GOT, + BFD_RELOC_ARC_TLS_DTPOFF, + BFD_RELOC_ARC_TLS_DTPOFF_S9, + BFD_RELOC_ARC_TLS_LE_S9, + BFD_RELOC_ARC_TLS_LE_32, + BFD_RELOC_ARC_S25W_PCREL_PLT, + BFD_RELOC_ARC_S21H_PCREL_PLT, + BFD_RELOC_ARC_NPS_CMEM16, + BFD_RELOC_ARC_JLI_SECTOFF, + + /* ADI Blackfin 16 bit immediate absolute reloc. */ + BFD_RELOC_BFIN_16_IMM, + + /* ADI Blackfin 16 bit immediate absolute reloc higher 16 bits. */ + BFD_RELOC_BFIN_16_HIGH, + + /* ADI Blackfin 'a' part of LSETUP. */ + BFD_RELOC_BFIN_4_PCREL, + + /* ADI Blackfin. */ + BFD_RELOC_BFIN_5_PCREL, + + /* ADI Blackfin 16 bit immediate absolute reloc lower 16 bits. */ + BFD_RELOC_BFIN_16_LOW, + + /* ADI Blackfin. */ + BFD_RELOC_BFIN_10_PCREL, + + /* ADI Blackfin 'b' part of LSETUP. */ + BFD_RELOC_BFIN_11_PCREL, + + /* ADI Blackfin. */ + BFD_RELOC_BFIN_12_PCREL_JUMP, + + /* ADI Blackfin Short jump, pcrel. */ + BFD_RELOC_BFIN_12_PCREL_JUMP_S, + + /* ADI Blackfin Call.x not implemented. */ + BFD_RELOC_BFIN_24_PCREL_CALL_X, + + /* ADI Blackfin Long Jump pcrel. */ + BFD_RELOC_BFIN_24_PCREL_JUMP_L, + + /* ADI Blackfin FD-PIC relocations. */ + BFD_RELOC_BFIN_GOT17M4, + BFD_RELOC_BFIN_GOTHI, + BFD_RELOC_BFIN_GOTLO, + BFD_RELOC_BFIN_FUNCDESC, + BFD_RELOC_BFIN_FUNCDESC_GOT17M4, + BFD_RELOC_BFIN_FUNCDESC_GOTHI, + BFD_RELOC_BFIN_FUNCDESC_GOTLO, + BFD_RELOC_BFIN_FUNCDESC_VALUE, + BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4, + BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI, + BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO, + BFD_RELOC_BFIN_GOTOFF17M4, + BFD_RELOC_BFIN_GOTOFFHI, + BFD_RELOC_BFIN_GOTOFFLO, + + /* ADI Blackfin GOT relocation. */ + BFD_RELOC_BFIN_GOT, + + /* ADI Blackfin PLTPC relocation. */ + BFD_RELOC_BFIN_PLTPC, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_PUSH, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_CONST, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_ADD, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_SUB, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_MULT, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_DIV, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_MOD, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_LSHIFT, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_RSHIFT, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_AND, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_OR, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_XOR, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_LAND, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_LOR, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_LEN, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_NEG, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_COMP, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_PAGE, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_HWPAGE, + + /* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_ADDR, + + /* Mitsubishi D10V relocs. + This is a 10-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_D10V_10_PCREL_R, + + /* Mitsubishi D10V relocs. + This is a 10-bit reloc with the right 2 bits assumed to be 0. This + is the same as the previous reloc except it is in the left + container, i.e., shifted left 15 bits. */ + BFD_RELOC_D10V_10_PCREL_L, + + /* This is an 18-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_D10V_18, + + /* This is an 18-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_D10V_18_PCREL, + + /* Mitsubishi D30V relocs. + This is a 6-bit absolute reloc. */ + BFD_RELOC_D30V_6, + + /* This is a 6-bit pc-relative reloc with the right 3 bits assumed to + be 0. */ + BFD_RELOC_D30V_9_PCREL, + + /* This is a 6-bit pc-relative reloc with the right 3 bits assumed to + be 0. Same as the previous reloc but on the right side of the + container. */ + BFD_RELOC_D30V_9_PCREL_R, + + /* This is a 12-bit absolute reloc with the right 3 bitsassumed to + be 0. */ + BFD_RELOC_D30V_15, + + /* This is a 12-bit pc-relative reloc with the right 3 bits assumed to + be 0. */ + BFD_RELOC_D30V_15_PCREL, + + /* This is a 12-bit pc-relative reloc with the right 3 bits assumed to + be 0. Same as the previous reloc but on the right side of the + container. */ + BFD_RELOC_D30V_15_PCREL_R, + + /* This is an 18-bit absolute reloc with the right 3 bits assumed to + be 0. */ + BFD_RELOC_D30V_21, + + /* This is an 18-bit pc-relative reloc with the right 3 bits assumed to + be 0. */ + BFD_RELOC_D30V_21_PCREL, + + /* This is an 18-bit pc-relative reloc with the right 3 bits assumed to + be 0. Same as the previous reloc but on the right side of the + container. */ + BFD_RELOC_D30V_21_PCREL_R, + + /* This is a 32-bit absolute reloc. */ + BFD_RELOC_D30V_32, + + /* This is a 32-bit pc-relative reloc. */ + BFD_RELOC_D30V_32_PCREL, + + /* DLX relocs. */ + BFD_RELOC_DLX_HI16_S, + BFD_RELOC_DLX_LO16, + BFD_RELOC_DLX_JMP26, + + /* Renesas M16C/M32C Relocations. */ + BFD_RELOC_M32C_HI8, + BFD_RELOC_M32C_RL_JUMP, + BFD_RELOC_M32C_RL_1ADDR, + BFD_RELOC_M32C_RL_2ADDR, + + /* Renesas M32R (formerly Mitsubishi M32R) relocs. + This is a 24 bit absolute address. */ + BFD_RELOC_M32R_24, + + /* This is a 10-bit pc-relative reloc with the right 2 bits assumed to + be 0. */ + BFD_RELOC_M32R_10_PCREL, + + /* This is an 18-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_18_PCREL, + + /* This is a 26-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_26_PCREL, + + /* This is a 16-bit reloc containing the high 16 bits of an address + used when the lower 16 bits are treated as unsigned. */ + BFD_RELOC_M32R_HI16_ULO, + + /* This is a 16-bit reloc containing the high 16 bits of an address + used when the lower 16 bits are treated as signed. */ + BFD_RELOC_M32R_HI16_SLO, + + /* This is a 16-bit reloc containing the lower 16 bits of an address. */ + BFD_RELOC_M32R_LO16, + + /* This is a 16-bit reloc containing the small data area offset for use + in add3, load, and store instructions. */ + BFD_RELOC_M32R_SDA16, + + /* For PIC. */ + BFD_RELOC_M32R_GOT24, + BFD_RELOC_M32R_26_PLTREL, + BFD_RELOC_M32R_COPY, + BFD_RELOC_M32R_GLOB_DAT, + BFD_RELOC_M32R_JMP_SLOT, + BFD_RELOC_M32R_RELATIVE, + BFD_RELOC_M32R_GOTOFF, + BFD_RELOC_M32R_GOTOFF_HI_ULO, + BFD_RELOC_M32R_GOTOFF_HI_SLO, + BFD_RELOC_M32R_GOTOFF_LO, + BFD_RELOC_M32R_GOTPC24, + BFD_RELOC_M32R_GOT16_HI_ULO, + BFD_RELOC_M32R_GOT16_HI_SLO, + BFD_RELOC_M32R_GOT16_LO, + BFD_RELOC_M32R_GOTPC_HI_ULO, + BFD_RELOC_M32R_GOTPC_HI_SLO, + BFD_RELOC_M32R_GOTPC_LO, + + /* NDS32 relocs. + This is a 20 bit absolute address. */ + BFD_RELOC_NDS32_20, + + /* This is a 9-bit pc-relative reloc with the right 1 bit assumed to + be 0. */ + BFD_RELOC_NDS32_9_PCREL, + + /* This is a 9-bit pc-relative reloc with the right 1 bit assumed to + be 0. */ + BFD_RELOC_NDS32_WORD_9_PCREL, + + /* This is an 15-bit reloc with the right 1 bit assumed to be 0. */ + BFD_RELOC_NDS32_15_PCREL, + + /* This is an 17-bit reloc with the right 1 bit assumed to be 0. */ + BFD_RELOC_NDS32_17_PCREL, + + /* This is a 25-bit reloc with the right 1 bit assumed to be 0. */ + BFD_RELOC_NDS32_25_PCREL, + + /* This is a 20-bit reloc containing the high 20 bits of an address + used with the lower 12 bits. */ + BFD_RELOC_NDS32_HI20, + + /* This is a 12-bit reloc containing the lower 12 bits of an address + then shift right by 3. This is used with ldi,sdi. */ + BFD_RELOC_NDS32_LO12S3, + + /* This is a 12-bit reloc containing the lower 12 bits of an address + then shift left by 2. This is used with lwi,swi. */ + BFD_RELOC_NDS32_LO12S2, + + /* This is a 12-bit reloc containing the lower 12 bits of an address + then shift left by 1. This is used with lhi,shi. */ + BFD_RELOC_NDS32_LO12S1, + + /* This is a 12-bit reloc containing the lower 12 bits of an address + then shift left by 0. This is used with lbisbi. */ + BFD_RELOC_NDS32_LO12S0, + + /* This is a 12-bit reloc containing the lower 12 bits of an address + then shift left by 0. This is only used with branch relaxations. */ + BFD_RELOC_NDS32_LO12S0_ORI, + + /* This is a 15-bit reloc containing the small data area 18-bit signed + offset and shift left by 3 for use in ldi, sdi. */ + BFD_RELOC_NDS32_SDA15S3, + + /* This is a 15-bit reloc containing the small data area 17-bit signed + offset and shift left by 2 for use in lwi, swi. */ + BFD_RELOC_NDS32_SDA15S2, + + /* This is a 15-bit reloc containing the small data area 16-bit signed + offset and shift left by 1 for use in lhi, shi. */ + BFD_RELOC_NDS32_SDA15S1, + + /* This is a 15-bit reloc containing the small data area 15-bit signed + offset and shift left by 0 for use in lbi, sbi. */ + BFD_RELOC_NDS32_SDA15S0, + + /* This is a 16-bit reloc containing the small data area 16-bit signed + offset and shift left by 3. */ + BFD_RELOC_NDS32_SDA16S3, + + /* This is a 17-bit reloc containing the small data area 17-bit signed + offset and shift left by 2 for use in lwi.gp, swi.gp. */ + BFD_RELOC_NDS32_SDA17S2, + + /* This is a 18-bit reloc containing the small data area 18-bit signed + offset and shift left by 1 for use in lhi.gp, shi.gp. */ + BFD_RELOC_NDS32_SDA18S1, + + /* This is a 19-bit reloc containing the small data area 19-bit signed + offset and shift left by 0 for use in lbi.gp, sbi.gp. */ + BFD_RELOC_NDS32_SDA19S0, + + /* For PIC. */ + BFD_RELOC_NDS32_GOT20, + BFD_RELOC_NDS32_9_PLTREL, + BFD_RELOC_NDS32_25_PLTREL, + BFD_RELOC_NDS32_COPY, + BFD_RELOC_NDS32_GLOB_DAT, + BFD_RELOC_NDS32_JMP_SLOT, + BFD_RELOC_NDS32_RELATIVE, + BFD_RELOC_NDS32_GOTOFF, + BFD_RELOC_NDS32_GOTOFF_HI20, + BFD_RELOC_NDS32_GOTOFF_LO12, + BFD_RELOC_NDS32_GOTPC20, + BFD_RELOC_NDS32_GOT_HI20, + BFD_RELOC_NDS32_GOT_LO12, + BFD_RELOC_NDS32_GOTPC_HI20, + BFD_RELOC_NDS32_GOTPC_LO12, + + /* For relax. */ + BFD_RELOC_NDS32_INSN16, + BFD_RELOC_NDS32_LABEL, + BFD_RELOC_NDS32_LONGCALL1, + BFD_RELOC_NDS32_LONGCALL2, + BFD_RELOC_NDS32_LONGCALL3, + BFD_RELOC_NDS32_LONGJUMP1, + BFD_RELOC_NDS32_LONGJUMP2, + BFD_RELOC_NDS32_LONGJUMP3, + BFD_RELOC_NDS32_LOADSTORE, + BFD_RELOC_NDS32_9_FIXED, + BFD_RELOC_NDS32_15_FIXED, + BFD_RELOC_NDS32_17_FIXED, + BFD_RELOC_NDS32_25_FIXED, + BFD_RELOC_NDS32_LONGCALL4, + BFD_RELOC_NDS32_LONGCALL5, + BFD_RELOC_NDS32_LONGCALL6, + BFD_RELOC_NDS32_LONGJUMP4, + BFD_RELOC_NDS32_LONGJUMP5, + BFD_RELOC_NDS32_LONGJUMP6, + BFD_RELOC_NDS32_LONGJUMP7, + + /* For PIC. */ + BFD_RELOC_NDS32_PLTREL_HI20, + BFD_RELOC_NDS32_PLTREL_LO12, + BFD_RELOC_NDS32_PLT_GOTREL_HI20, + BFD_RELOC_NDS32_PLT_GOTREL_LO12, + + /* For floating point. */ + BFD_RELOC_NDS32_SDA12S2_DP, + BFD_RELOC_NDS32_SDA12S2_SP, + BFD_RELOC_NDS32_LO12S2_DP, + BFD_RELOC_NDS32_LO12S2_SP, + + /* For dwarf2 debug_line. */ + BFD_RELOC_NDS32_DWARF2_OP1, + BFD_RELOC_NDS32_DWARF2_OP2, + BFD_RELOC_NDS32_DWARF2_LEB, + + /* For eliminating 16-bit instructions. */ + BFD_RELOC_NDS32_UPDATE_TA, + + /* For PIC object relaxation. */ + BFD_RELOC_NDS32_PLT_GOTREL_LO20, + BFD_RELOC_NDS32_PLT_GOTREL_LO15, + BFD_RELOC_NDS32_PLT_GOTREL_LO19, + BFD_RELOC_NDS32_GOT_LO15, + BFD_RELOC_NDS32_GOT_LO19, + BFD_RELOC_NDS32_GOTOFF_LO15, + BFD_RELOC_NDS32_GOTOFF_LO19, + BFD_RELOC_NDS32_GOT15S2, + BFD_RELOC_NDS32_GOT17S2, + + /* NDS32 relocs. + This is a 5 bit absolute address. */ + BFD_RELOC_NDS32_5, + + /* This is a 10-bit unsigned pc-relative reloc with the right 1 bit + assumed to be 0. */ + BFD_RELOC_NDS32_10_UPCREL, + + /* If fp were omitted, fp can used as another gp. */ + BFD_RELOC_NDS32_SDA_FP7U2_RELA, + + /* Relaxation relative relocation types. */ + BFD_RELOC_NDS32_RELAX_ENTRY, + BFD_RELOC_NDS32_GOT_SUFF, + BFD_RELOC_NDS32_GOTOFF_SUFF, + BFD_RELOC_NDS32_PLT_GOT_SUFF, + BFD_RELOC_NDS32_MULCALL_SUFF, + BFD_RELOC_NDS32_PTR, + BFD_RELOC_NDS32_PTR_COUNT, + BFD_RELOC_NDS32_PTR_RESOLVED, + BFD_RELOC_NDS32_PLTBLOCK, + BFD_RELOC_NDS32_RELAX_REGION_BEGIN, + BFD_RELOC_NDS32_RELAX_REGION_END, + BFD_RELOC_NDS32_MINUEND, + BFD_RELOC_NDS32_SUBTRAHEND, + BFD_RELOC_NDS32_DIFF8, + BFD_RELOC_NDS32_DIFF16, + BFD_RELOC_NDS32_DIFF32, + BFD_RELOC_NDS32_DIFF_ULEB128, + BFD_RELOC_NDS32_EMPTY, + + /* This is a 25 bit absolute address. */ + BFD_RELOC_NDS32_25_ABS, + + /* For ex9 and ifc using. */ + BFD_RELOC_NDS32_DATA, + BFD_RELOC_NDS32_TRAN, + BFD_RELOC_NDS32_17IFC_PCREL, + BFD_RELOC_NDS32_10IFCU_PCREL, + + /* For TLS. */ + BFD_RELOC_NDS32_TPOFF, + BFD_RELOC_NDS32_GOTTPOFF, + BFD_RELOC_NDS32_TLS_LE_HI20, + BFD_RELOC_NDS32_TLS_LE_LO12, + BFD_RELOC_NDS32_TLS_LE_20, + BFD_RELOC_NDS32_TLS_LE_15S0, + BFD_RELOC_NDS32_TLS_LE_15S1, + BFD_RELOC_NDS32_TLS_LE_15S2, + BFD_RELOC_NDS32_TLS_LE_ADD, + BFD_RELOC_NDS32_TLS_LE_LS, + BFD_RELOC_NDS32_TLS_IE_HI20, + BFD_RELOC_NDS32_TLS_IE_LO12, + BFD_RELOC_NDS32_TLS_IE_LO12S2, + BFD_RELOC_NDS32_TLS_IEGP_HI20, + BFD_RELOC_NDS32_TLS_IEGP_LO12, + BFD_RELOC_NDS32_TLS_IEGP_LO12S2, + BFD_RELOC_NDS32_TLS_IEGP_LW, + BFD_RELOC_NDS32_TLS_DESC, + BFD_RELOC_NDS32_TLS_DESC_HI20, + BFD_RELOC_NDS32_TLS_DESC_LO12, + BFD_RELOC_NDS32_TLS_DESC_20, + BFD_RELOC_NDS32_TLS_DESC_SDA17S2, + BFD_RELOC_NDS32_TLS_DESC_ADD, + BFD_RELOC_NDS32_TLS_DESC_FUNC, + BFD_RELOC_NDS32_TLS_DESC_CALL, + BFD_RELOC_NDS32_TLS_DESC_MEM, + BFD_RELOC_NDS32_REMOVE, + BFD_RELOC_NDS32_GROUP, + + /* For floating load store relaxation. */ + BFD_RELOC_NDS32_LSI, + + /* This is a 9-bit reloc. */ + BFD_RELOC_V850_9_PCREL, + + /* This is a 22-bit reloc. */ + BFD_RELOC_V850_22_PCREL, + + /* This is a 16 bit offset from the short data area pointer. */ + BFD_RELOC_V850_SDA_16_16_OFFSET, + + /* This is a 16 bit offset (of which only 15 bits are used) from the + short data area pointer. */ + BFD_RELOC_V850_SDA_15_16_OFFSET, + + /* This is a 16 bit offset from the zero data area pointer. */ + BFD_RELOC_V850_ZDA_16_16_OFFSET, + + /* This is a 16 bit offset (of which only 15 bits are used) from the + zero data area pointer. */ + BFD_RELOC_V850_ZDA_15_16_OFFSET, + + /* This is an 8 bit offset (of which only 6 bits are used) from the + tiny data area pointer. */ + BFD_RELOC_V850_TDA_6_8_OFFSET, + + /* This is an 8bit offset (of which only 7 bits are used) from the tiny + data area pointer. */ + BFD_RELOC_V850_TDA_7_8_OFFSET, + + /* This is a 7 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_7_7_OFFSET, + + /* This is a 16 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_16_16_OFFSET, + + /* This is a 5 bit offset (of which only 4 bits are used) from the tiny + data area pointer. */ + BFD_RELOC_V850_TDA_4_5_OFFSET, + + /* This is a 4 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_4_4_OFFSET, + + /* This is a 16 bit offset from the short data area pointer, with the + bits placed non-contiguously in the instruction. */ + BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET, + + /* This is a 16 bit offset from the zero data area pointer, with the + bits placed non-contiguously in the instruction. */ + BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET, + + /* This is a 6 bit offset from the call table base pointer. */ + BFD_RELOC_V850_CALLT_6_7_OFFSET, + + /* This is a 16 bit offset from the call table base pointer. */ + BFD_RELOC_V850_CALLT_16_16_OFFSET, + + /* Used for relaxing indirect function calls. */ + BFD_RELOC_V850_LONGCALL, + + /* Used for relaxing indirect jumps. */ + BFD_RELOC_V850_LONGJUMP, + + /* Used to maintain alignment whilst relaxing. */ + BFD_RELOC_V850_ALIGN, + + /* This is a variation of BFD_RELOC_LO16 that can be used in v850e + ld.bu instructions. */ + BFD_RELOC_V850_LO16_SPLIT_OFFSET, + + /* This is a 16-bit reloc. */ + BFD_RELOC_V850_16_PCREL, + + /* This is a 17-bit reloc. */ + BFD_RELOC_V850_17_PCREL, + + /* This is a 23-bit reloc. */ + BFD_RELOC_V850_23, + + /* This is a 32-bit reloc. */ + BFD_RELOC_V850_32_PCREL, + + /* This is a 32-bit reloc. */ + BFD_RELOC_V850_32_ABS, + + /* This is a 16-bit reloc. */ + BFD_RELOC_V850_16_SPLIT_OFFSET, + + /* This is a 16-bit reloc. */ + BFD_RELOC_V850_16_S1, + + /* Low 16 bits. 16 bit shifted by 1. */ + BFD_RELOC_V850_LO16_S1, + + /* This is a 16 bit offset from the call table base pointer. */ + BFD_RELOC_V850_CALLT_15_16_OFFSET, + + /* DSO relocations. */ + BFD_RELOC_V850_32_GOTPCREL, + BFD_RELOC_V850_16_GOT, + BFD_RELOC_V850_32_GOT, + BFD_RELOC_V850_22_PLT_PCREL, + BFD_RELOC_V850_32_PLT_PCREL, + BFD_RELOC_V850_COPY, + BFD_RELOC_V850_GLOB_DAT, + BFD_RELOC_V850_JMP_SLOT, + BFD_RELOC_V850_RELATIVE, + BFD_RELOC_V850_16_GOTOFF, + BFD_RELOC_V850_32_GOTOFF, + + /* Start code. */ + BFD_RELOC_V850_CODE, + + /* Start data in text. */ + BFD_RELOC_V850_DATA, + + /* This is a 8bit DP reloc for the tms320c30, where the most + significant 8 bits of a 24 bit word are placed into the least + significant 8 bits of the opcode. */ + BFD_RELOC_TIC30_LDP, + + /* This is a 7bit reloc for the tms320c54x, where the least + significant 7 bits of a 16 bit word are placed into the least + significant 7 bits of the opcode. */ + BFD_RELOC_TIC54X_PARTLS7, + + /* This is a 9bit DP reloc for the tms320c54x, where the most + significant 9 bits of a 16 bit word are placed into the least + significant 9 bits of the opcode. */ + BFD_RELOC_TIC54X_PARTMS9, + + /* This is an extended address 23-bit reloc for the tms320c54x. */ + BFD_RELOC_TIC54X_23, + + /* This is a 16-bit reloc for the tms320c54x, where the least + significant 16 bits of a 23-bit extended address are placed into + the opcode. */ + BFD_RELOC_TIC54X_16_OF_23, + + /* This is a reloc for the tms320c54x, where the most + significant 7 bits of a 23-bit extended address are placed into + the opcode. */ + BFD_RELOC_TIC54X_MS7_OF_23, + + /* TMS320C6000 relocations. */ + BFD_RELOC_C6000_PCR_S21, + BFD_RELOC_C6000_PCR_S12, + BFD_RELOC_C6000_PCR_S10, + BFD_RELOC_C6000_PCR_S7, + BFD_RELOC_C6000_ABS_S16, + BFD_RELOC_C6000_ABS_L16, + BFD_RELOC_C6000_ABS_H16, + BFD_RELOC_C6000_SBR_U15_B, + BFD_RELOC_C6000_SBR_U15_H, + BFD_RELOC_C6000_SBR_U15_W, + BFD_RELOC_C6000_SBR_S16, + BFD_RELOC_C6000_SBR_L16_B, + BFD_RELOC_C6000_SBR_L16_H, + BFD_RELOC_C6000_SBR_L16_W, + BFD_RELOC_C6000_SBR_H16_B, + BFD_RELOC_C6000_SBR_H16_H, + BFD_RELOC_C6000_SBR_H16_W, + BFD_RELOC_C6000_SBR_GOT_U15_W, + BFD_RELOC_C6000_SBR_GOT_L16_W, + BFD_RELOC_C6000_SBR_GOT_H16_W, + BFD_RELOC_C6000_DSBT_INDEX, + BFD_RELOC_C6000_PREL31, + BFD_RELOC_C6000_COPY, + BFD_RELOC_C6000_JUMP_SLOT, + BFD_RELOC_C6000_EHTYPE, + BFD_RELOC_C6000_PCR_H16, + BFD_RELOC_C6000_PCR_L16, + BFD_RELOC_C6000_ALIGN, + BFD_RELOC_C6000_FPHEAD, + BFD_RELOC_C6000_NOCMP, + + /* This is a 48 bit reloc for the FR30 that stores 32 bits. */ + BFD_RELOC_FR30_48, + + /* This is a 32 bit reloc for the FR30 that stores 20 bits split up + into two sections. */ + BFD_RELOC_FR30_20, + + /* This is a 16 bit reloc for the FR30 that stores a 6 bit word offset + in 4 bits. */ + BFD_RELOC_FR30_6_IN_4, + + /* This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset + into 8 bits. */ + BFD_RELOC_FR30_8_IN_8, + + /* This is a 16 bit reloc for the FR30 that stores a 9 bit short offset + into 8 bits. */ + BFD_RELOC_FR30_9_IN_8, + + /* This is a 16 bit reloc for the FR30 that stores a 10 bit word offset + into 8 bits. */ + BFD_RELOC_FR30_10_IN_8, + + /* This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative + short offset into 8 bits. */ + BFD_RELOC_FR30_9_PCREL, + + /* This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative + short offset into 11 bits. */ + BFD_RELOC_FR30_12_PCREL, + + /* Motorola Mcore relocations. */ + BFD_RELOC_MCORE_PCREL_IMM8BY4, + BFD_RELOC_MCORE_PCREL_IMM11BY2, + BFD_RELOC_MCORE_PCREL_IMM4BY2, + BFD_RELOC_MCORE_PCREL_32, + BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, + BFD_RELOC_MCORE_RVA, + + /* Toshiba Media Processor Relocations. */ + BFD_RELOC_MEP_8, + BFD_RELOC_MEP_16, + BFD_RELOC_MEP_32, + BFD_RELOC_MEP_PCREL8A2, + BFD_RELOC_MEP_PCREL12A2, + BFD_RELOC_MEP_PCREL17A2, + BFD_RELOC_MEP_PCREL24A2, + BFD_RELOC_MEP_PCABS24A2, + BFD_RELOC_MEP_LOW16, + BFD_RELOC_MEP_HI16U, + BFD_RELOC_MEP_HI16S, + BFD_RELOC_MEP_GPREL, + BFD_RELOC_MEP_TPREL, + BFD_RELOC_MEP_TPREL7, + BFD_RELOC_MEP_TPREL7A2, + BFD_RELOC_MEP_TPREL7A4, + BFD_RELOC_MEP_UIMM24, + BFD_RELOC_MEP_ADDR24A4, + BFD_RELOC_MEP_GNU_VTINHERIT, + BFD_RELOC_MEP_GNU_VTENTRY, + + /* Imagination Technologies Meta relocations. */ + BFD_RELOC_METAG_HIADDR16, + BFD_RELOC_METAG_LOADDR16, + BFD_RELOC_METAG_RELBRANCH, + BFD_RELOC_METAG_GETSETOFF, + BFD_RELOC_METAG_HIOG, + BFD_RELOC_METAG_LOOG, + BFD_RELOC_METAG_REL8, + BFD_RELOC_METAG_REL16, + BFD_RELOC_METAG_HI16_GOTOFF, + BFD_RELOC_METAG_LO16_GOTOFF, + BFD_RELOC_METAG_GETSET_GOTOFF, + BFD_RELOC_METAG_GETSET_GOT, + BFD_RELOC_METAG_HI16_GOTPC, + BFD_RELOC_METAG_LO16_GOTPC, + BFD_RELOC_METAG_HI16_PLT, + BFD_RELOC_METAG_LO16_PLT, + BFD_RELOC_METAG_RELBRANCH_PLT, + BFD_RELOC_METAG_GOTOFF, + BFD_RELOC_METAG_PLT, + BFD_RELOC_METAG_COPY, + BFD_RELOC_METAG_JMP_SLOT, + BFD_RELOC_METAG_RELATIVE, + BFD_RELOC_METAG_GLOB_DAT, + BFD_RELOC_METAG_TLS_GD, + BFD_RELOC_METAG_TLS_LDM, + BFD_RELOC_METAG_TLS_LDO_HI16, + BFD_RELOC_METAG_TLS_LDO_LO16, + BFD_RELOC_METAG_TLS_LDO, + BFD_RELOC_METAG_TLS_IE, + BFD_RELOC_METAG_TLS_IENONPIC, + BFD_RELOC_METAG_TLS_IENONPIC_HI16, + BFD_RELOC_METAG_TLS_IENONPIC_LO16, + BFD_RELOC_METAG_TLS_TPOFF, + BFD_RELOC_METAG_TLS_DTPMOD, + BFD_RELOC_METAG_TLS_DTPOFF, + BFD_RELOC_METAG_TLS_LE, + BFD_RELOC_METAG_TLS_LE_HI16, + BFD_RELOC_METAG_TLS_LE_LO16, + + /* These are relocations for the GETA instruction. */ + BFD_RELOC_MMIX_GETA, + BFD_RELOC_MMIX_GETA_1, + BFD_RELOC_MMIX_GETA_2, + BFD_RELOC_MMIX_GETA_3, + + /* These are relocations for a conditional branch instruction. */ + BFD_RELOC_MMIX_CBRANCH, + BFD_RELOC_MMIX_CBRANCH_J, + BFD_RELOC_MMIX_CBRANCH_1, + BFD_RELOC_MMIX_CBRANCH_2, + BFD_RELOC_MMIX_CBRANCH_3, + + /* These are relocations for the PUSHJ instruction. */ + BFD_RELOC_MMIX_PUSHJ, + BFD_RELOC_MMIX_PUSHJ_1, + BFD_RELOC_MMIX_PUSHJ_2, + BFD_RELOC_MMIX_PUSHJ_3, + BFD_RELOC_MMIX_PUSHJ_STUBBABLE, + + /* These are relocations for the JMP instruction. */ + BFD_RELOC_MMIX_JMP, + BFD_RELOC_MMIX_JMP_1, + BFD_RELOC_MMIX_JMP_2, + BFD_RELOC_MMIX_JMP_3, + + /* This is a relocation for a relative address as in a GETA instruction + or a branch. */ + BFD_RELOC_MMIX_ADDR19, + + /* This is a relocation for a relative address as in a JMP instruction. */ + BFD_RELOC_MMIX_ADDR27, + + /* This is a relocation for an instruction field that may be a general + register or a value 0..255. */ + BFD_RELOC_MMIX_REG_OR_BYTE, + + /* This is a relocation for an instruction field that may be a general + register. */ + BFD_RELOC_MMIX_REG, + + /* This is a relocation for two instruction fields holding a register + and an offset, the equivalent of the relocation. */ + BFD_RELOC_MMIX_BASE_PLUS_OFFSET, + + /* This relocation is an assertion that the expression is not allocated + as a global register. It does not modify contents. */ + BFD_RELOC_MMIX_LOCAL, + + /* This is a 16 bit reloc for the AVR that stores 8 bit pc relative + short offset into 7 bits. */ + BFD_RELOC_AVR_7_PCREL, + + /* This is a 16 bit reloc for the AVR that stores 13 bit pc relative + short offset into 12 bits. */ + BFD_RELOC_AVR_13_PCREL, + + /* This is a 16 bit reloc for the AVR that stores 17 bit value (usually + program memory address) into 16 bits. */ + BFD_RELOC_AVR_16_PM, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value (usually + data memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_LO8_LDI, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit + of data memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HI8_LDI, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value (most + high 8 bit of program memory address) into 8 bit immediate value of + LDI insn. */ + BFD_RELOC_AVR_HH8_LDI, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value (most + high 8 bit of 32 bit value) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_MS8_LDI, + + /* This is a 16 bit reloc for the AVR that stores negated 8 bit value + (usually data memory address) into 8 bit immediate value of SUBI insn. */ + BFD_RELOC_AVR_LO8_LDI_NEG, + + /* This is a 16 bit reloc for the AVR that stores negated 8 bit value + (high 8 bit of data memory address) into 8 bit immediate value of + SUBI insn. */ + BFD_RELOC_AVR_HI8_LDI_NEG, + + /* This is a 16 bit reloc for the AVR that stores negated 8 bit value + (most high 8 bit of program memory address) into 8 bit immediate + value of LDI or SUBI insn. */ + BFD_RELOC_AVR_HH8_LDI_NEG, + + /* This is a 16 bit reloc for the AVR that stores negated 8 bit value + (msb of 32 bit value) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_MS8_LDI_NEG, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value (usually + command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_LO8_LDI_PM, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value + (command address) into 8 bit immediate value of LDI insn. If the + address is beyond the 128k boundary, the linker inserts a jump stub + for this reloc in the lower 128k. */ + BFD_RELOC_AVR_LO8_LDI_GS, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit + of command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HI8_LDI_PM, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit + of command address) into 8 bit immediate value of LDI insn. If the + address is beyond the 128k boundary, the linker inserts a jump stub + for this reloc below 128k. */ + BFD_RELOC_AVR_HI8_LDI_GS, + + /* This is a 16 bit reloc for the AVR that stores 8 bit value (most + high 8 bit of command address) into 8 bit immediate value of LDI + insn. */ + BFD_RELOC_AVR_HH8_LDI_PM, + + /* This is a 16 bit reloc for the AVR that stores negated 8 bit value + (usually command address) into 8 bit immediate value of SUBI insn. */ + BFD_RELOC_AVR_LO8_LDI_PM_NEG, + + /* This is a 16 bit reloc for the AVR that stores negated 8 bit value + (high 8 bit of 16 bit command address) into 8 bit immediate value + of SUBI insn. */ + BFD_RELOC_AVR_HI8_LDI_PM_NEG, + + /* This is a 16 bit reloc for the AVR that stores negated 8 bit value + (high 6 bit of 22 bit command address) into 8 bit immediate + value of SUBI insn. */ + BFD_RELOC_AVR_HH8_LDI_PM_NEG, + + /* This is a 32 bit reloc for the AVR that stores 23 bit value + into 22 bits. */ + BFD_RELOC_AVR_CALL, + + /* This is a 16 bit reloc for the AVR that stores all needed bits + for absolute addressing with ldi with overflow check to linktime. */ + BFD_RELOC_AVR_LDI, + + /* This is a 6 bit reloc for the AVR that stores offset for ldd/std + instructions. */ + BFD_RELOC_AVR_6, + + /* This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw + instructions. */ + BFD_RELOC_AVR_6_ADIW, + + /* This is a 8 bit reloc for the AVR that stores bits 0..7 of a symbol + in .byte lo8(symbol). */ + BFD_RELOC_AVR_8_LO, + + /* This is a 8 bit reloc for the AVR that stores bits 8..15 of a symbol + in .byte hi8(symbol). */ + BFD_RELOC_AVR_8_HI, + + /* This is a 8 bit reloc for the AVR that stores bits 16..23 of a symbol + in .byte hlo8(symbol). */ + BFD_RELOC_AVR_8_HLO, + + /* AVR relocations to mark the difference of two local symbols. + These are only needed to support linker relaxation and can be ignored + when not relaxing. The field is set to the value of the difference + assuming no relaxation. The relocation encodes the position of the + second symbol so the linker can determine whether to adjust the field + value. */ + BFD_RELOC_AVR_DIFF8, + BFD_RELOC_AVR_DIFF16, + BFD_RELOC_AVR_DIFF32, + + /* This is a 7 bit reloc for the AVR that stores SRAM address for 16bit + lds and sts instructions supported only tiny core. */ + BFD_RELOC_AVR_LDS_STS_16, + + /* This is a 6 bit reloc for the AVR that stores an I/O register + number for the IN and OUT instructions. */ + BFD_RELOC_AVR_PORT6, + + /* This is a 5 bit reloc for the AVR that stores an I/O register + number for the SBIC, SBIS, SBI and CBI instructions. */ + BFD_RELOC_AVR_PORT5, + + /* RISC-V relocations. */ + BFD_RELOC_RISCV_HI20, + BFD_RELOC_RISCV_PCREL_HI20, + BFD_RELOC_RISCV_PCREL_LO12_I, + BFD_RELOC_RISCV_PCREL_LO12_S, + BFD_RELOC_RISCV_LO12_I, + BFD_RELOC_RISCV_LO12_S, + BFD_RELOC_RISCV_GPREL12_I, + BFD_RELOC_RISCV_GPREL12_S, + BFD_RELOC_RISCV_TPREL_HI20, + BFD_RELOC_RISCV_TPREL_LO12_I, + BFD_RELOC_RISCV_TPREL_LO12_S, + BFD_RELOC_RISCV_TPREL_ADD, + BFD_RELOC_RISCV_CALL, + BFD_RELOC_RISCV_CALL_PLT, + BFD_RELOC_RISCV_ADD8, + BFD_RELOC_RISCV_ADD16, + BFD_RELOC_RISCV_ADD32, + BFD_RELOC_RISCV_ADD64, + BFD_RELOC_RISCV_SUB8, + BFD_RELOC_RISCV_SUB16, + BFD_RELOC_RISCV_SUB32, + BFD_RELOC_RISCV_SUB64, + BFD_RELOC_RISCV_GOT_HI20, + BFD_RELOC_RISCV_TLS_GOT_HI20, + BFD_RELOC_RISCV_TLS_GD_HI20, + BFD_RELOC_RISCV_JMP, + BFD_RELOC_RISCV_TLS_DTPMOD32, + BFD_RELOC_RISCV_TLS_DTPREL32, + BFD_RELOC_RISCV_TLS_DTPMOD64, + BFD_RELOC_RISCV_TLS_DTPREL64, + BFD_RELOC_RISCV_TLS_TPREL32, + BFD_RELOC_RISCV_TLS_TPREL64, + BFD_RELOC_RISCV_TLSDESC_HI20, + BFD_RELOC_RISCV_TLSDESC_LOAD_LO12, + BFD_RELOC_RISCV_TLSDESC_ADD_LO12, + BFD_RELOC_RISCV_TLSDESC_CALL, + BFD_RELOC_RISCV_ALIGN, + BFD_RELOC_RISCV_RVC_BRANCH, + BFD_RELOC_RISCV_RVC_JUMP, + BFD_RELOC_RISCV_RELAX, + BFD_RELOC_RISCV_CFA, + BFD_RELOC_RISCV_SUB6, + BFD_RELOC_RISCV_SET6, + BFD_RELOC_RISCV_SET8, + BFD_RELOC_RISCV_SET16, + BFD_RELOC_RISCV_SET32, + BFD_RELOC_RISCV_32_PCREL, + BFD_RELOC_RISCV_SET_ULEB128, + BFD_RELOC_RISCV_SUB_ULEB128, + + /* Renesas RL78 Relocations. */ + BFD_RELOC_RL78_NEG8, + BFD_RELOC_RL78_NEG16, + BFD_RELOC_RL78_NEG24, + BFD_RELOC_RL78_NEG32, + BFD_RELOC_RL78_16_OP, + BFD_RELOC_RL78_24_OP, + BFD_RELOC_RL78_32_OP, + BFD_RELOC_RL78_8U, + BFD_RELOC_RL78_16U, + BFD_RELOC_RL78_24U, + BFD_RELOC_RL78_DIR3U_PCREL, + BFD_RELOC_RL78_DIFF, + BFD_RELOC_RL78_GPRELB, + BFD_RELOC_RL78_GPRELW, + BFD_RELOC_RL78_GPRELL, + BFD_RELOC_RL78_SYM, + BFD_RELOC_RL78_OP_SUBTRACT, + BFD_RELOC_RL78_OP_NEG, + BFD_RELOC_RL78_OP_AND, + BFD_RELOC_RL78_OP_SHRA, + BFD_RELOC_RL78_ABS8, + BFD_RELOC_RL78_ABS16, + BFD_RELOC_RL78_ABS16_REV, + BFD_RELOC_RL78_ABS32, + BFD_RELOC_RL78_ABS32_REV, + BFD_RELOC_RL78_ABS16U, + BFD_RELOC_RL78_ABS16UW, + BFD_RELOC_RL78_ABS16UL, + BFD_RELOC_RL78_RELAX, + BFD_RELOC_RL78_HI16, + BFD_RELOC_RL78_HI8, + BFD_RELOC_RL78_LO16, + BFD_RELOC_RL78_CODE, + BFD_RELOC_RL78_SADDR, + + /* Renesas RX Relocations. */ + BFD_RELOC_RX_NEG8, + BFD_RELOC_RX_NEG16, + BFD_RELOC_RX_NEG24, + BFD_RELOC_RX_NEG32, + BFD_RELOC_RX_16_OP, + BFD_RELOC_RX_24_OP, + BFD_RELOC_RX_32_OP, + BFD_RELOC_RX_8U, + BFD_RELOC_RX_16U, + BFD_RELOC_RX_24U, + BFD_RELOC_RX_DIR3U_PCREL, + BFD_RELOC_RX_DIFF, + BFD_RELOC_RX_GPRELB, + BFD_RELOC_RX_GPRELW, + BFD_RELOC_RX_GPRELL, + BFD_RELOC_RX_SYM, + BFD_RELOC_RX_OP_SUBTRACT, + BFD_RELOC_RX_OP_NEG, + BFD_RELOC_RX_ABS8, + BFD_RELOC_RX_ABS16, + BFD_RELOC_RX_ABS16_REV, + BFD_RELOC_RX_ABS32, + BFD_RELOC_RX_ABS32_REV, + BFD_RELOC_RX_ABS16U, + BFD_RELOC_RX_ABS16UW, + BFD_RELOC_RX_ABS16UL, + BFD_RELOC_RX_RELAX, + + /* Direct 12 bit. */ + BFD_RELOC_390_12, + + /* 12 bit GOT offset. */ + BFD_RELOC_390_GOT12, + + /* 32 bit PC relative PLT address. */ + BFD_RELOC_390_PLT32, + + /* Copy symbol at runtime. */ + BFD_RELOC_390_COPY, + + /* Create GOT entry. */ + BFD_RELOC_390_GLOB_DAT, + + /* Create PLT entry. */ + BFD_RELOC_390_JMP_SLOT, + + /* Adjust by program base. */ + BFD_RELOC_390_RELATIVE, + + /* 32 bit PC relative offset to GOT. */ + BFD_RELOC_390_GOTPC, + + /* 16 bit GOT offset. */ + BFD_RELOC_390_GOT16, + + /* PC relative 12 bit shifted by 1. */ + BFD_RELOC_390_PC12DBL, + + /* 12 bit PC rel. PLT shifted by 1. */ + BFD_RELOC_390_PLT12DBL, + + /* PC relative 16 bit shifted by 1. */ + BFD_RELOC_390_PC16DBL, + + /* 16 bit PC rel. PLT shifted by 1. */ + BFD_RELOC_390_PLT16DBL, + + /* PC relative 24 bit shifted by 1. */ + BFD_RELOC_390_PC24DBL, + + /* 24 bit PC rel. PLT shifted by 1. */ + BFD_RELOC_390_PLT24DBL, + + /* PC relative 32 bit shifted by 1. */ + BFD_RELOC_390_PC32DBL, + + /* 32 bit PC rel. PLT shifted by 1. */ + BFD_RELOC_390_PLT32DBL, + + /* 32 bit PC rel. GOT shifted by 1. */ + BFD_RELOC_390_GOTPCDBL, + + /* 64 bit GOT offset. */ + BFD_RELOC_390_GOT64, + + /* 64 bit PC relative PLT address. */ + BFD_RELOC_390_PLT64, + + /* 32 bit rel. offset to GOT entry. */ + BFD_RELOC_390_GOTENT, + + /* 64 bit offset to GOT. */ + BFD_RELOC_390_GOTOFF64, + + /* 12-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLT12, + + /* 16-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLT16, + + /* 32-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLT32, + + /* 64-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLT64, + + /* 32-bit rel. offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLTENT, + + /* 16-bit rel. offset from the GOT to a PLT entry. */ + BFD_RELOC_390_PLTOFF16, + + /* 32-bit rel. offset from the GOT to a PLT entry. */ + BFD_RELOC_390_PLTOFF32, + + /* 64-bit rel. offset from the GOT to a PLT entry. */ + BFD_RELOC_390_PLTOFF64, + + /* s390 tls relocations. */ + BFD_RELOC_390_TLS_LOAD, + BFD_RELOC_390_TLS_GDCALL, + BFD_RELOC_390_TLS_LDCALL, + BFD_RELOC_390_TLS_GD32, + BFD_RELOC_390_TLS_GD64, + BFD_RELOC_390_TLS_GOTIE12, + BFD_RELOC_390_TLS_GOTIE32, + BFD_RELOC_390_TLS_GOTIE64, + BFD_RELOC_390_TLS_LDM32, + BFD_RELOC_390_TLS_LDM64, + BFD_RELOC_390_TLS_IE32, + BFD_RELOC_390_TLS_IE64, + BFD_RELOC_390_TLS_IEENT, + BFD_RELOC_390_TLS_LE32, + BFD_RELOC_390_TLS_LE64, + BFD_RELOC_390_TLS_LDO32, + BFD_RELOC_390_TLS_LDO64, + BFD_RELOC_390_TLS_DTPMOD, + BFD_RELOC_390_TLS_DTPOFF, + BFD_RELOC_390_TLS_TPOFF, + + /* Long displacement extension. */ + BFD_RELOC_390_20, + BFD_RELOC_390_GOT20, + BFD_RELOC_390_GOTPLT20, + BFD_RELOC_390_TLS_GOTIE20, + + /* STT_GNU_IFUNC relocation. */ + BFD_RELOC_390_IRELATIVE, + + /* Score relocations. + Low 16 bit for load/store. */ + BFD_RELOC_SCORE_GPREL15, + + /* This is a 24-bit reloc with the right 1 bit assumed to be 0. */ + BFD_RELOC_SCORE_DUMMY2, + BFD_RELOC_SCORE_JMP, + + /* This is a 19-bit reloc with the right 1 bit assumed to be 0. */ + BFD_RELOC_SCORE_BRANCH, + + /* This is a 32-bit reloc for 48-bit instructions. */ + BFD_RELOC_SCORE_IMM30, + + /* This is a 32-bit reloc for 48-bit instructions. */ + BFD_RELOC_SCORE_IMM32, + + /* This is a 11-bit reloc with the right 1 bit assumed to be 0. */ + BFD_RELOC_SCORE16_JMP, + + /* This is a 8-bit reloc with the right 1 bit assumed to be 0. */ + BFD_RELOC_SCORE16_BRANCH, + + /* This is a 9-bit reloc with the right 1 bit assumed to be 0. */ + BFD_RELOC_SCORE_BCMP, + + /* Undocumented Score relocs. */ + BFD_RELOC_SCORE_GOT15, + BFD_RELOC_SCORE_GOT_LO16, + BFD_RELOC_SCORE_CALL15, + BFD_RELOC_SCORE_DUMMY_HI16, + + /* Scenix IP2K - 9-bit register number / data address. */ + BFD_RELOC_IP2K_FR9, + + /* Scenix IP2K - 4-bit register/data bank number. */ + BFD_RELOC_IP2K_BANK, + + /* Scenix IP2K - low 13 bits of instruction word address. */ + BFD_RELOC_IP2K_ADDR16CJP, + + /* Scenix IP2K - high 3 bits of instruction word address. */ + BFD_RELOC_IP2K_PAGE3, + + /* Scenix IP2K - ext/low/high 8 bits of data address. */ + BFD_RELOC_IP2K_LO8DATA, + BFD_RELOC_IP2K_HI8DATA, + BFD_RELOC_IP2K_EX8DATA, + + /* Scenix IP2K - low/high 8 bits of instruction word address. */ + BFD_RELOC_IP2K_LO8INSN, + BFD_RELOC_IP2K_HI8INSN, + + /* Scenix IP2K - even/odd PC modifier to modify snb pcl.0. */ + BFD_RELOC_IP2K_PC_SKIP, + + /* Scenix IP2K - 16 bit word address in text section. */ + BFD_RELOC_IP2K_TEXT, + + /* Scenix IP2K - 7-bit sp or dp offset. */ + BFD_RELOC_IP2K_FR_OFFSET, + + /* Scenix VPE4K coprocessor - data/insn-space addressing. */ + BFD_RELOC_VPE4KMATH_DATA, + BFD_RELOC_VPE4KMATH_INSN, + + /* These two relocations are used by the linker to determine which of + the entries in a C++ virtual function table are actually used. When + the --gc-sections option is given, the linker will zero out the + entries that are not used, so that the code for those functions need + not be included in the output. + + VTABLE_INHERIT is a zero-space relocation used to describe to the + linker the inheritance tree of a C++ virtual function table. The + relocation's symbol should be the parent class' vtable, and the + relocation should be located at the child vtable. + + VTABLE_ENTRY is a zero-space relocation that describes the use of a + virtual function table entry. The reloc's symbol should refer to + the table of the class mentioned in the code. Off of that base, an + offset describes the entry that is being used. For Rela hosts, this + offset is stored in the reloc's addend. For Rel hosts, we are + forced to put this offset in the reloc's section offset. */ + BFD_RELOC_VTABLE_INHERIT, + BFD_RELOC_VTABLE_ENTRY, + + /* Intel IA64 Relocations. */ + BFD_RELOC_IA64_IMM14, + BFD_RELOC_IA64_IMM22, + BFD_RELOC_IA64_IMM64, + BFD_RELOC_IA64_DIR32MSB, + BFD_RELOC_IA64_DIR32LSB, + BFD_RELOC_IA64_DIR64MSB, + BFD_RELOC_IA64_DIR64LSB, + BFD_RELOC_IA64_GPREL22, + BFD_RELOC_IA64_GPREL64I, + BFD_RELOC_IA64_GPREL32MSB, + BFD_RELOC_IA64_GPREL32LSB, + BFD_RELOC_IA64_GPREL64MSB, + BFD_RELOC_IA64_GPREL64LSB, + BFD_RELOC_IA64_LTOFF22, + BFD_RELOC_IA64_LTOFF64I, + BFD_RELOC_IA64_PLTOFF22, + BFD_RELOC_IA64_PLTOFF64I, + BFD_RELOC_IA64_PLTOFF64MSB, + BFD_RELOC_IA64_PLTOFF64LSB, + BFD_RELOC_IA64_FPTR64I, + BFD_RELOC_IA64_FPTR32MSB, + BFD_RELOC_IA64_FPTR32LSB, + BFD_RELOC_IA64_FPTR64MSB, + BFD_RELOC_IA64_FPTR64LSB, + BFD_RELOC_IA64_PCREL21B, + BFD_RELOC_IA64_PCREL21BI, + BFD_RELOC_IA64_PCREL21M, + BFD_RELOC_IA64_PCREL21F, + BFD_RELOC_IA64_PCREL22, + BFD_RELOC_IA64_PCREL60B, + BFD_RELOC_IA64_PCREL64I, + BFD_RELOC_IA64_PCREL32MSB, + BFD_RELOC_IA64_PCREL32LSB, + BFD_RELOC_IA64_PCREL64MSB, + BFD_RELOC_IA64_PCREL64LSB, + BFD_RELOC_IA64_LTOFF_FPTR22, + BFD_RELOC_IA64_LTOFF_FPTR64I, + BFD_RELOC_IA64_LTOFF_FPTR32MSB, + BFD_RELOC_IA64_LTOFF_FPTR32LSB, + BFD_RELOC_IA64_LTOFF_FPTR64MSB, + BFD_RELOC_IA64_LTOFF_FPTR64LSB, + BFD_RELOC_IA64_SEGREL32MSB, + BFD_RELOC_IA64_SEGREL32LSB, + BFD_RELOC_IA64_SEGREL64MSB, + BFD_RELOC_IA64_SEGREL64LSB, + BFD_RELOC_IA64_SECREL32MSB, + BFD_RELOC_IA64_SECREL32LSB, + BFD_RELOC_IA64_SECREL64MSB, + BFD_RELOC_IA64_SECREL64LSB, + BFD_RELOC_IA64_REL32MSB, + BFD_RELOC_IA64_REL32LSB, + BFD_RELOC_IA64_REL64MSB, + BFD_RELOC_IA64_REL64LSB, + BFD_RELOC_IA64_LTV32MSB, + BFD_RELOC_IA64_LTV32LSB, + BFD_RELOC_IA64_LTV64MSB, + BFD_RELOC_IA64_LTV64LSB, + BFD_RELOC_IA64_IPLTMSB, + BFD_RELOC_IA64_IPLTLSB, + BFD_RELOC_IA64_COPY, + BFD_RELOC_IA64_LTOFF22X, + BFD_RELOC_IA64_LDXMOV, + BFD_RELOC_IA64_TPREL14, + BFD_RELOC_IA64_TPREL22, + BFD_RELOC_IA64_TPREL64I, + BFD_RELOC_IA64_TPREL64MSB, + BFD_RELOC_IA64_TPREL64LSB, + BFD_RELOC_IA64_LTOFF_TPREL22, + BFD_RELOC_IA64_DTPMOD64MSB, + BFD_RELOC_IA64_DTPMOD64LSB, + BFD_RELOC_IA64_LTOFF_DTPMOD22, + BFD_RELOC_IA64_DTPREL14, + BFD_RELOC_IA64_DTPREL22, + BFD_RELOC_IA64_DTPREL64I, + BFD_RELOC_IA64_DTPREL32MSB, + BFD_RELOC_IA64_DTPREL32LSB, + BFD_RELOC_IA64_DTPREL64MSB, + BFD_RELOC_IA64_DTPREL64LSB, + BFD_RELOC_IA64_LTOFF_DTPREL22, + + /* Motorola 68HC11 reloc. + This is the 8 bit high part of an absolute address. */ + BFD_RELOC_M68HC11_HI8, + + /* Motorola 68HC11 reloc. + This is the 8 bit low part of an absolute address. */ + BFD_RELOC_M68HC11_LO8, + + /* Motorola 68HC11 reloc. + This is the 3 bit of a value. */ + BFD_RELOC_M68HC11_3B, + + /* Motorola 68HC11 reloc. + This reloc marks the beginning of a jump/call instruction. + It is used for linker relaxation to correctly identify beginning + of instruction and change some branches to use PC-relative + addressing mode. */ + BFD_RELOC_M68HC11_RL_JUMP, + + /* Motorola 68HC11 reloc. + This reloc marks a group of several instructions that gcc generates + and for which the linker relaxation pass can modify and/or remove + some of them. */ + BFD_RELOC_M68HC11_RL_GROUP, + + /* Motorola 68HC11 reloc. + This is the 16-bit lower part of an address. It is used for 'call' + instruction to specify the symbol address without any special + transformation (due to memory bank window). */ + BFD_RELOC_M68HC11_LO16, + + /* Motorola 68HC11 reloc. + This is a 8-bit reloc that specifies the page number of an address. + It is used by 'call' instruction to specify the page number of + the symbol. */ + BFD_RELOC_M68HC11_PAGE, + + /* Motorola 68HC11 reloc. + This is a 24-bit reloc that represents the address with a 16-bit + value and a 8-bit page number. The symbol address is transformed + to follow the 16K memory bank of 68HC12 (seen as mapped in the + window). */ + BFD_RELOC_M68HC11_24, + + /* Motorola 68HC12 reloc. + This is the 5 bits of a value. */ + BFD_RELOC_M68HC12_5B, + + /* Freescale XGATE reloc. + This reloc marks the beginning of a bra/jal instruction. */ + BFD_RELOC_XGATE_RL_JUMP, + + /* Freescale XGATE reloc. + This reloc marks a group of several instructions that gcc generates + and for which the linker relaxation pass can modify and/or remove + some of them. */ + BFD_RELOC_XGATE_RL_GROUP, + + /* Freescale XGATE reloc. + This is the 16-bit lower part of an address. It is used for the + '16-bit' instructions. */ + BFD_RELOC_XGATE_LO16, + + /* Freescale XGATE reloc. */ + BFD_RELOC_XGATE_GPAGE, + + /* Freescale XGATE reloc. */ + BFD_RELOC_XGATE_24, + + /* Freescale XGATE reloc. + This is a 9-bit pc-relative reloc. */ + BFD_RELOC_XGATE_PCREL_9, + + /* Freescale XGATE reloc. + This is a 10-bit pc-relative reloc. */ + BFD_RELOC_XGATE_PCREL_10, + + /* Freescale XGATE reloc. + This is the 16-bit lower part of an address. It is used for the + '16-bit' instructions. */ + BFD_RELOC_XGATE_IMM8_LO, + + /* Freescale XGATE reloc. + This is the 16-bit higher part of an address. It is used for the + '16-bit' instructions. */ + BFD_RELOC_XGATE_IMM8_HI, + + /* Freescale XGATE reloc. + This is a 3-bit pc-relative reloc. */ + BFD_RELOC_XGATE_IMM3, + + /* Freescale XGATE reloc. + This is a 4-bit pc-relative reloc. */ + BFD_RELOC_XGATE_IMM4, + + /* Freescale XGATE reloc. + This is a 5-bit pc-relative reloc. */ + BFD_RELOC_XGATE_IMM5, + + /* Motorola 68HC12 reloc. + This is the 9 bits of a value. */ + BFD_RELOC_M68HC12_9B, + + /* Motorola 68HC12 reloc. + This is the 16 bits of a value. */ + BFD_RELOC_M68HC12_16B, + + /* Motorola 68HC12/XGATE reloc. + This is a PCREL9 branch. */ + BFD_RELOC_M68HC12_9_PCREL, + + /* Motorola 68HC12/XGATE reloc. + This is a PCREL10 branch. */ + BFD_RELOC_M68HC12_10_PCREL, + + /* Motorola 68HC12/XGATE reloc. + This is the 8 bit low part of an absolute address and immediately + precedes a matching HI8XG part. */ + BFD_RELOC_M68HC12_LO8XG, + + /* Motorola 68HC12/XGATE reloc. + This is the 8 bit high part of an absolute address and immediately + follows a matching LO8XG part. */ + BFD_RELOC_M68HC12_HI8XG, + + /* Freescale S12Z reloc. + This is a 15 bit relative address. If the most significant bits are + all zero then it may be truncated to 8 bits. */ + BFD_RELOC_S12Z_15_PCREL, + + /* NS CR16 Relocations. */ + BFD_RELOC_CR16_NUM8, + BFD_RELOC_CR16_NUM16, + BFD_RELOC_CR16_NUM32, + BFD_RELOC_CR16_NUM32a, + BFD_RELOC_CR16_REGREL0, + BFD_RELOC_CR16_REGREL4, + BFD_RELOC_CR16_REGREL4a, + BFD_RELOC_CR16_REGREL14, + BFD_RELOC_CR16_REGREL14a, + BFD_RELOC_CR16_REGREL16, + BFD_RELOC_CR16_REGREL20, + BFD_RELOC_CR16_REGREL20a, + BFD_RELOC_CR16_ABS20, + BFD_RELOC_CR16_ABS24, + BFD_RELOC_CR16_IMM4, + BFD_RELOC_CR16_IMM8, + BFD_RELOC_CR16_IMM16, + BFD_RELOC_CR16_IMM20, + BFD_RELOC_CR16_IMM24, + BFD_RELOC_CR16_IMM32, + BFD_RELOC_CR16_IMM32a, + BFD_RELOC_CR16_DISP4, + BFD_RELOC_CR16_DISP8, + BFD_RELOC_CR16_DISP16, + BFD_RELOC_CR16_DISP20, + BFD_RELOC_CR16_DISP24, + BFD_RELOC_CR16_DISP24a, + BFD_RELOC_CR16_SWITCH8, + BFD_RELOC_CR16_SWITCH16, + BFD_RELOC_CR16_SWITCH32, + BFD_RELOC_CR16_GOT_REGREL20, + BFD_RELOC_CR16_GOTC_REGREL20, + BFD_RELOC_CR16_GLOB_DAT, + + /* NS CRX Relocations. */ + BFD_RELOC_CRX_REL4, + BFD_RELOC_CRX_REL8, + BFD_RELOC_CRX_REL8_CMP, + BFD_RELOC_CRX_REL16, + BFD_RELOC_CRX_REL24, + BFD_RELOC_CRX_REL32, + BFD_RELOC_CRX_REGREL12, + BFD_RELOC_CRX_REGREL22, + BFD_RELOC_CRX_REGREL28, + BFD_RELOC_CRX_REGREL32, + BFD_RELOC_CRX_ABS16, + BFD_RELOC_CRX_ABS32, + BFD_RELOC_CRX_NUM8, + BFD_RELOC_CRX_NUM16, + BFD_RELOC_CRX_NUM32, + BFD_RELOC_CRX_IMM16, + BFD_RELOC_CRX_IMM32, + BFD_RELOC_CRX_SWITCH8, + BFD_RELOC_CRX_SWITCH16, + BFD_RELOC_CRX_SWITCH32, + + /* These relocs are only used within the CRIS assembler. They are not + (at present) written to any object files. */ + BFD_RELOC_CRIS_BDISP8, + BFD_RELOC_CRIS_UNSIGNED_5, + BFD_RELOC_CRIS_SIGNED_6, + BFD_RELOC_CRIS_UNSIGNED_6, + BFD_RELOC_CRIS_SIGNED_8, + BFD_RELOC_CRIS_UNSIGNED_8, + BFD_RELOC_CRIS_SIGNED_16, + BFD_RELOC_CRIS_UNSIGNED_16, + BFD_RELOC_CRIS_LAPCQ_OFFSET, + BFD_RELOC_CRIS_UNSIGNED_4, + + /* Relocs used in ELF shared libraries for CRIS. */ + BFD_RELOC_CRIS_COPY, + BFD_RELOC_CRIS_GLOB_DAT, + BFD_RELOC_CRIS_JUMP_SLOT, + BFD_RELOC_CRIS_RELATIVE, + + /* 32-bit offset to symbol-entry within GOT. */ + BFD_RELOC_CRIS_32_GOT, + + /* 16-bit offset to symbol-entry within GOT. */ + BFD_RELOC_CRIS_16_GOT, + + /* 32-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_CRIS_32_GOTPLT, + + /* 16-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_CRIS_16_GOTPLT, + + /* 32-bit offset to symbol, relative to GOT. */ + BFD_RELOC_CRIS_32_GOTREL, + + /* 32-bit offset to symbol with PLT entry, relative to GOT. */ + BFD_RELOC_CRIS_32_PLT_GOTREL, + + /* 32-bit offset to symbol with PLT entry, relative to this + relocation. */ + BFD_RELOC_CRIS_32_PLT_PCREL, + + /* Relocs used in TLS code for CRIS. */ + BFD_RELOC_CRIS_32_GOT_GD, + BFD_RELOC_CRIS_16_GOT_GD, + BFD_RELOC_CRIS_32_GD, + BFD_RELOC_CRIS_DTP, + BFD_RELOC_CRIS_32_DTPREL, + BFD_RELOC_CRIS_16_DTPREL, + BFD_RELOC_CRIS_32_GOT_TPREL, + BFD_RELOC_CRIS_16_GOT_TPREL, + BFD_RELOC_CRIS_32_TPREL, + BFD_RELOC_CRIS_16_TPREL, + BFD_RELOC_CRIS_DTPMOD, + BFD_RELOC_CRIS_32_IE, + + /* OpenRISC 1000 Relocations. */ + BFD_RELOC_OR1K_REL_26, + BFD_RELOC_OR1K_SLO16, + BFD_RELOC_OR1K_PCREL_PG21, + BFD_RELOC_OR1K_LO13, + BFD_RELOC_OR1K_SLO13, + BFD_RELOC_OR1K_GOTPC_HI16, + BFD_RELOC_OR1K_GOTPC_LO16, + BFD_RELOC_OR1K_GOT_AHI16, + BFD_RELOC_OR1K_GOT16, + BFD_RELOC_OR1K_GOT_PG21, + BFD_RELOC_OR1K_GOT_LO13, + BFD_RELOC_OR1K_PLT26, + BFD_RELOC_OR1K_PLTA26, + BFD_RELOC_OR1K_GOTOFF_SLO16, + BFD_RELOC_OR1K_COPY, + BFD_RELOC_OR1K_GLOB_DAT, + BFD_RELOC_OR1K_JMP_SLOT, + BFD_RELOC_OR1K_RELATIVE, + BFD_RELOC_OR1K_TLS_GD_HI16, + BFD_RELOC_OR1K_TLS_GD_LO16, + BFD_RELOC_OR1K_TLS_GD_PG21, + BFD_RELOC_OR1K_TLS_GD_LO13, + BFD_RELOC_OR1K_TLS_LDM_HI16, + BFD_RELOC_OR1K_TLS_LDM_LO16, + BFD_RELOC_OR1K_TLS_LDM_PG21, + BFD_RELOC_OR1K_TLS_LDM_LO13, + BFD_RELOC_OR1K_TLS_LDO_HI16, + BFD_RELOC_OR1K_TLS_LDO_LO16, + BFD_RELOC_OR1K_TLS_IE_HI16, + BFD_RELOC_OR1K_TLS_IE_AHI16, + BFD_RELOC_OR1K_TLS_IE_LO16, + BFD_RELOC_OR1K_TLS_IE_PG21, + BFD_RELOC_OR1K_TLS_IE_LO13, + BFD_RELOC_OR1K_TLS_LE_HI16, + BFD_RELOC_OR1K_TLS_LE_AHI16, + BFD_RELOC_OR1K_TLS_LE_LO16, + BFD_RELOC_OR1K_TLS_LE_SLO16, + BFD_RELOC_OR1K_TLS_TPOFF, + BFD_RELOC_OR1K_TLS_DTPOFF, + BFD_RELOC_OR1K_TLS_DTPMOD, + + /* H8 elf Relocations. */ + BFD_RELOC_H8_DIR16A8, + BFD_RELOC_H8_DIR16R8, + BFD_RELOC_H8_DIR24A8, + BFD_RELOC_H8_DIR24R8, + BFD_RELOC_H8_DIR32A16, + BFD_RELOC_H8_DISP32A16, + + /* Sony Xstormy16 Relocations. */ + BFD_RELOC_XSTORMY16_REL_12, + BFD_RELOC_XSTORMY16_12, + BFD_RELOC_XSTORMY16_24, + BFD_RELOC_XSTORMY16_FPTR16, + + /* Self-describing complex relocations. */ + BFD_RELOC_RELC, + + /* Relocations used by VAX ELF. */ + BFD_RELOC_VAX_GLOB_DAT, + BFD_RELOC_VAX_JMP_SLOT, + BFD_RELOC_VAX_RELATIVE, + + /* Morpho MT - 16 bit immediate relocation. */ + BFD_RELOC_MT_PC16, + + /* Morpho MT - Hi 16 bits of an address. */ + BFD_RELOC_MT_HI16, + + /* Morpho MT - Low 16 bits of an address. */ + BFD_RELOC_MT_LO16, + + /* Morpho MT - Used to tell the linker which vtable entries are used. */ + BFD_RELOC_MT_GNU_VTINHERIT, + + /* Morpho MT - Used to tell the linker which vtable entries are used. */ + BFD_RELOC_MT_GNU_VTENTRY, + + /* Morpho MT - 8 bit immediate relocation. */ + BFD_RELOC_MT_PCINSN8, + + /* msp430 specific relocation codes. */ + BFD_RELOC_MSP430_10_PCREL, + BFD_RELOC_MSP430_16_PCREL, + BFD_RELOC_MSP430_16, + BFD_RELOC_MSP430_16_PCREL_BYTE, + BFD_RELOC_MSP430_16_BYTE, + BFD_RELOC_MSP430_2X_PCREL, + BFD_RELOC_MSP430_RL_PCREL, + BFD_RELOC_MSP430_ABS8, + BFD_RELOC_MSP430X_PCR20_EXT_SRC, + BFD_RELOC_MSP430X_PCR20_EXT_DST, + BFD_RELOC_MSP430X_PCR20_EXT_ODST, + BFD_RELOC_MSP430X_ABS20_EXT_SRC, + BFD_RELOC_MSP430X_ABS20_EXT_DST, + BFD_RELOC_MSP430X_ABS20_EXT_ODST, + BFD_RELOC_MSP430X_ABS20_ADR_SRC, + BFD_RELOC_MSP430X_ABS20_ADR_DST, + BFD_RELOC_MSP430X_PCR16, + BFD_RELOC_MSP430X_PCR20_CALL, + BFD_RELOC_MSP430X_ABS16, + BFD_RELOC_MSP430_ABS_HI16, + BFD_RELOC_MSP430_PREL31, + BFD_RELOC_MSP430_SYM_DIFF, + BFD_RELOC_MSP430_SET_ULEB128, + BFD_RELOC_MSP430_SUB_ULEB128, + + /* PRU LDI 16-bit unsigned data-memory relocation. */ + BFD_RELOC_PRU_U16, + + /* PRU LDI 16-bit unsigned instruction-memory relocation. */ + BFD_RELOC_PRU_U16_PMEMIMM, + + /* PRU relocation for two consecutive LDI load instructions that load a + 32 bit value into a register. If the higher bits are all zero, then + the second instruction may be relaxed. */ + BFD_RELOC_PRU_LDI32, + + /* PRU QBBx 10-bit signed PC-relative relocation. */ + BFD_RELOC_PRU_S10_PCREL, + + /* PRU 8-bit unsigned relocation used for the LOOP instruction. */ + BFD_RELOC_PRU_U8_PCREL, + + /* PRU Program Memory relocations. Used to convert from byte + addressing to 32-bit word addressing. */ + BFD_RELOC_PRU_32_PMEM, + BFD_RELOC_PRU_16_PMEM, + + /* PRU relocations to mark the difference of two local symbols. + These are only needed to support linker relaxation and can be + ignored when not relaxing. The field is set to the value of the + difference assuming no relaxation. The relocation encodes the + position of the second symbol so the linker can determine whether to + adjust the field value. The PMEM variants encode the word + difference, instead of byte difference between symbols. */ + BFD_RELOC_PRU_GNU_DIFF8, + BFD_RELOC_PRU_GNU_DIFF16, + BFD_RELOC_PRU_GNU_DIFF32, + BFD_RELOC_PRU_GNU_DIFF16_PMEM, + BFD_RELOC_PRU_GNU_DIFF32_PMEM, + + /* IQ2000 Relocations. */ + BFD_RELOC_IQ2000_OFFSET_16, + BFD_RELOC_IQ2000_OFFSET_21, + BFD_RELOC_IQ2000_UHI16, + + /* Special Xtensa relocation used only by PLT entries in ELF shared + objects to indicate that the runtime linker should set the value + to one of its own internal functions or data structures. */ + BFD_RELOC_XTENSA_RTLD, + + /* Xtensa relocations for ELF shared objects. */ + BFD_RELOC_XTENSA_GLOB_DAT, + BFD_RELOC_XTENSA_JMP_SLOT, + BFD_RELOC_XTENSA_RELATIVE, + + /* Xtensa relocation used in ELF object files for symbols that may + require PLT entries. Otherwise, this is just a generic 32-bit + relocation. */ + BFD_RELOC_XTENSA_PLT, + + /* Xtensa relocations for backward compatibility. These have been + replaced by BFD_RELOC_XTENSA_PDIFF and BFD_RELOC_XTENSA_NDIFF. + Xtensa relocations to mark the difference of two local symbols. + These are only needed to support linker relaxation and can be + ignored when not relaxing. The field is set to the value of the + difference assuming no relaxation. The relocation encodes the + position of the first symbol so the linker can determine whether to + adjust the field value. */ + BFD_RELOC_XTENSA_DIFF8, + BFD_RELOC_XTENSA_DIFF16, + BFD_RELOC_XTENSA_DIFF32, + + /* Generic Xtensa relocations for instruction operands. Only the slot + number is encoded in the relocation. The relocation applies to the + last PC-relative immediate operand, or if there are no PC-relative + immediates, to the last immediate operand. */ + BFD_RELOC_XTENSA_SLOT0_OP, + BFD_RELOC_XTENSA_SLOT1_OP, + BFD_RELOC_XTENSA_SLOT2_OP, + BFD_RELOC_XTENSA_SLOT3_OP, + BFD_RELOC_XTENSA_SLOT4_OP, + BFD_RELOC_XTENSA_SLOT5_OP, + BFD_RELOC_XTENSA_SLOT6_OP, + BFD_RELOC_XTENSA_SLOT7_OP, + BFD_RELOC_XTENSA_SLOT8_OP, + BFD_RELOC_XTENSA_SLOT9_OP, + BFD_RELOC_XTENSA_SLOT10_OP, + BFD_RELOC_XTENSA_SLOT11_OP, + BFD_RELOC_XTENSA_SLOT12_OP, + BFD_RELOC_XTENSA_SLOT13_OP, + BFD_RELOC_XTENSA_SLOT14_OP, + + /* Alternate Xtensa relocations. Only the slot is encoded in the + relocation. The meaning of these relocations is opcode-specific. */ + BFD_RELOC_XTENSA_SLOT0_ALT, + BFD_RELOC_XTENSA_SLOT1_ALT, + BFD_RELOC_XTENSA_SLOT2_ALT, + BFD_RELOC_XTENSA_SLOT3_ALT, + BFD_RELOC_XTENSA_SLOT4_ALT, + BFD_RELOC_XTENSA_SLOT5_ALT, + BFD_RELOC_XTENSA_SLOT6_ALT, + BFD_RELOC_XTENSA_SLOT7_ALT, + BFD_RELOC_XTENSA_SLOT8_ALT, + BFD_RELOC_XTENSA_SLOT9_ALT, + BFD_RELOC_XTENSA_SLOT10_ALT, + BFD_RELOC_XTENSA_SLOT11_ALT, + BFD_RELOC_XTENSA_SLOT12_ALT, + BFD_RELOC_XTENSA_SLOT13_ALT, + BFD_RELOC_XTENSA_SLOT14_ALT, + + /* Xtensa relocations for backward compatibility. These have all been + replaced by BFD_RELOC_XTENSA_SLOT0_OP. */ + BFD_RELOC_XTENSA_OP0, + BFD_RELOC_XTENSA_OP1, + BFD_RELOC_XTENSA_OP2, + + /* Xtensa relocation to mark that the assembler expanded the + instructions from an original target. The expansion size is + encoded in the reloc size. */ + BFD_RELOC_XTENSA_ASM_EXPAND, + + /* Xtensa relocation to mark that the linker should simplify + assembler-expanded instructions. This is commonly used + internally by the linker after analysis of a + BFD_RELOC_XTENSA_ASM_EXPAND. */ + BFD_RELOC_XTENSA_ASM_SIMPLIFY, + + /* Xtensa TLS relocations. */ + BFD_RELOC_XTENSA_TLSDESC_FN, + BFD_RELOC_XTENSA_TLSDESC_ARG, + BFD_RELOC_XTENSA_TLS_DTPOFF, + BFD_RELOC_XTENSA_TLS_TPOFF, + BFD_RELOC_XTENSA_TLS_FUNC, + BFD_RELOC_XTENSA_TLS_ARG, + BFD_RELOC_XTENSA_TLS_CALL, + + /* Xtensa relocations to mark the difference of two local symbols. + These are only needed to support linker relaxation and can be + ignored when not relaxing. The field is set to the value of the + difference assuming no relaxation. The relocation encodes the + position of the subtracted symbol so the linker can determine + whether to adjust the field value. PDIFF relocations are used for + positive differences, NDIFF relocations are used for negative + differences. The difference value is treated as unsigned with these + relocation types, giving full 8/16 value ranges. */ + BFD_RELOC_XTENSA_PDIFF8, + BFD_RELOC_XTENSA_PDIFF16, + BFD_RELOC_XTENSA_PDIFF32, + BFD_RELOC_XTENSA_NDIFF8, + BFD_RELOC_XTENSA_NDIFF16, + BFD_RELOC_XTENSA_NDIFF32, + + /* 8 bit signed offset in (ix+d) or (iy+d). */ + BFD_RELOC_Z80_DISP8, + + /* First 8 bits of multibyte (32, 24 or 16 bit) value. */ + BFD_RELOC_Z80_BYTE0, + + /* Second 8 bits of multibyte (32, 24 or 16 bit) value. */ + BFD_RELOC_Z80_BYTE1, + + /* Third 8 bits of multibyte (32 or 24 bit) value. */ + BFD_RELOC_Z80_BYTE2, + + /* Fourth 8 bits of multibyte (32 bit) value. */ + BFD_RELOC_Z80_BYTE3, + + /* Lowest 16 bits of multibyte (32 or 24 bit) value. */ + BFD_RELOC_Z80_WORD0, + + /* Highest 16 bits of multibyte (32 or 24 bit) value. */ + BFD_RELOC_Z80_WORD1, + + /* Like BFD_RELOC_16 but big-endian. */ + BFD_RELOC_Z80_16_BE, + + /* DJNZ offset. */ + BFD_RELOC_Z8K_DISP7, + + /* CALR offset. */ + BFD_RELOC_Z8K_CALLR, + + /* 4 bit value. */ + BFD_RELOC_Z8K_IMM4L, + + /* Lattice Mico32 relocations. */ + BFD_RELOC_LM32_CALL, + BFD_RELOC_LM32_BRANCH, + BFD_RELOC_LM32_16_GOT, + BFD_RELOC_LM32_GOTOFF_HI16, + BFD_RELOC_LM32_GOTOFF_LO16, + BFD_RELOC_LM32_COPY, + BFD_RELOC_LM32_GLOB_DAT, + BFD_RELOC_LM32_JMP_SLOT, + BFD_RELOC_LM32_RELATIVE, + + /* Difference between two section addreses. Must be followed by a + BFD_RELOC_MACH_O_PAIR. */ + BFD_RELOC_MACH_O_SECTDIFF, + + /* Like BFD_RELOC_MACH_O_SECTDIFF but with a local symbol. */ + BFD_RELOC_MACH_O_LOCAL_SECTDIFF, + + /* Pair of relocation. Contains the first symbol. */ + BFD_RELOC_MACH_O_PAIR, + + /* Symbol will be substracted. Must be followed by a BFD_RELOC_32. */ + BFD_RELOC_MACH_O_SUBTRACTOR32, + + /* Symbol will be substracted. Must be followed by a BFD_RELOC_64. */ + BFD_RELOC_MACH_O_SUBTRACTOR64, + + /* PCREL relocations. They are marked as branch to create PLT entry if + required. */ + BFD_RELOC_MACH_O_X86_64_BRANCH32, + BFD_RELOC_MACH_O_X86_64_BRANCH8, + + /* Used when referencing a GOT entry. */ + BFD_RELOC_MACH_O_X86_64_GOT, + + /* Used when loading a GOT entry with movq. It is specially marked so + that the linker could optimize the movq to a leaq if possible. */ + BFD_RELOC_MACH_O_X86_64_GOT_LOAD, + + /* Same as BFD_RELOC_32_PCREL but with an implicit -1 addend. */ + BFD_RELOC_MACH_O_X86_64_PCREL32_1, + + /* Same as BFD_RELOC_32_PCREL but with an implicit -2 addend. */ + BFD_RELOC_MACH_O_X86_64_PCREL32_2, + + /* Same as BFD_RELOC_32_PCREL but with an implicit -4 addend. */ + BFD_RELOC_MACH_O_X86_64_PCREL32_4, + + /* Used when referencing a TLV entry. */ + BFD_RELOC_MACH_O_X86_64_TLV, + + /* Addend for PAGE or PAGEOFF. */ + BFD_RELOC_MACH_O_ARM64_ADDEND, + + /* Relative offset to page of GOT slot. */ + BFD_RELOC_MACH_O_ARM64_GOT_LOAD_PAGE21, + + /* Relative offset within page of GOT slot. */ + BFD_RELOC_MACH_O_ARM64_GOT_LOAD_PAGEOFF12, + + /* Address of a GOT entry. */ + BFD_RELOC_MACH_O_ARM64_POINTER_TO_GOT, + + /* This is a 32 bit reloc for the microblaze that stores the low 16 + bits of a value. */ + BFD_RELOC_MICROBLAZE_32_LO, + + /* This is a 32 bit pc-relative reloc for the microblaze that stores + the low 16 bits of a value. */ + BFD_RELOC_MICROBLAZE_32_LO_PCREL, + + /* This is a 32 bit reloc for the microblaze that stores a value + relative to the read-only small data area anchor. */ + BFD_RELOC_MICROBLAZE_32_ROSDA, + + /* This is a 32 bit reloc for the microblaze that stores a value + relative to the read-write small data area anchor. */ + BFD_RELOC_MICROBLAZE_32_RWSDA, + + /* This is a 32 bit reloc for the microblaze to handle expressions of + the form "Symbol Op Symbol". */ + BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM, + + /* This is a 32 bit reloc that stores the 32 bit pc relative value in + two words (with an imm instruction). No relocation is done here - + only used for relaxing. */ + BFD_RELOC_MICROBLAZE_32_NONE, + + /* This is a 64 bit reloc that stores the 32 bit pc relative value in + two words (with an imm instruction). No relocation is done here - + only used for relaxing. */ + BFD_RELOC_MICROBLAZE_64_NONE, + + /* This is a 64 bit reloc that stores the 32 bit pc relative value in + two words (with an imm instruction). The relocation is PC-relative + GOT offset. */ + BFD_RELOC_MICROBLAZE_64_GOTPC, + + /* This is a 64 bit reloc that stores the 32 bit pc relative value in + two words (with an imm instruction). The relocation is GOT offset. */ + BFD_RELOC_MICROBLAZE_64_GOT, + + /* This is a 64 bit reloc that stores the 32 bit pc relative value in + two words (with an imm instruction). The relocation is PC-relative + offset into PLT. */ + BFD_RELOC_MICROBLAZE_64_PLT, + + /* This is a 64 bit reloc that stores the 32 bit GOT relative value in + two words (with an imm instruction). The relocation is relative + offset from _GLOBAL_OFFSET_TABLE_. */ + BFD_RELOC_MICROBLAZE_64_GOTOFF, + + /* This is a 32 bit reloc that stores the 32 bit GOT relative value in + a word. The relocation is relative offset from + _GLOBAL_OFFSET_TABLE_. */ + BFD_RELOC_MICROBLAZE_32_GOTOFF, + + /* This is used to tell the dynamic linker to copy the value out of + the dynamic object into the runtime process image. */ + BFD_RELOC_MICROBLAZE_COPY, + + /* Unused Reloc. */ + BFD_RELOC_MICROBLAZE_64_TLS, + + /* This is a 64 bit reloc that stores the 32 bit GOT relative value + of the GOT TLS GD info entry in two words (with an imm instruction). + The relocation is GOT offset. */ + BFD_RELOC_MICROBLAZE_64_TLSGD, + + /* This is a 64 bit reloc that stores the 32 bit GOT relative value + of the GOT TLS LD info entry in two words (with an imm instruction). + The relocation is GOT offset. */ + BFD_RELOC_MICROBLAZE_64_TLSLD, + + /* This is a 32 bit reloc that stores the Module ID to GOT(n). */ + BFD_RELOC_MICROBLAZE_32_TLSDTPMOD, + + /* This is a 32 bit reloc that stores TLS offset to GOT(n+1). */ + BFD_RELOC_MICROBLAZE_32_TLSDTPREL, + + /* This is a 32 bit reloc for storing TLS offset to two words (uses imm + instruction). */ + BFD_RELOC_MICROBLAZE_64_TLSDTPREL, + + /* This is a 64 bit reloc that stores 32-bit thread pointer relative + offset to two words (uses imm instruction). */ + BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL, + + /* This is a 64 bit reloc that stores 32-bit thread pointer relative + offset to two words (uses imm instruction). */ + BFD_RELOC_MICROBLAZE_64_TLSTPREL, + + /* This is a 64 bit reloc that stores the 32 bit pc relative value in + two words (with an imm instruction). The relocation is PC-relative + offset from start of TEXT. */ + BFD_RELOC_MICROBLAZE_64_TEXTPCREL, + + /* This is a 64 bit reloc that stores the 32 bit offset value in two + words (with an imm instruction). The relocation is relative offset + from start of TEXT. */ + BFD_RELOC_MICROBLAZE_64_TEXTREL, + + /* KVX pseudo relocation code to mark the start of the KVX relocation + enumerators. N.B. the order of the enumerators is important as + several tables in the KVX bfd backend are indexed by these + enumerators; make sure they are all synced. */ + BFD_RELOC_KVX_RELOC_START, + + /* KVX null relocation code. */ + BFD_RELOC_KVX_NONE, + + /* KVX Relocations. */ + BFD_RELOC_KVX_16, + BFD_RELOC_KVX_32, + BFD_RELOC_KVX_64, + BFD_RELOC_KVX_S16_PCREL, + BFD_RELOC_KVX_PCREL17, + BFD_RELOC_KVX_PCREL27, + BFD_RELOC_KVX_32_PCREL, + BFD_RELOC_KVX_S37_PCREL_LO10, + BFD_RELOC_KVX_S37_PCREL_UP27, + BFD_RELOC_KVX_S43_PCREL_LO10, + BFD_RELOC_KVX_S43_PCREL_UP27, + BFD_RELOC_KVX_S43_PCREL_EX6, + BFD_RELOC_KVX_S64_PCREL_LO10, + BFD_RELOC_KVX_S64_PCREL_UP27, + BFD_RELOC_KVX_S64_PCREL_EX27, + BFD_RELOC_KVX_64_PCREL, + BFD_RELOC_KVX_S16, + BFD_RELOC_KVX_S32_LO5, + BFD_RELOC_KVX_S32_UP27, + BFD_RELOC_KVX_S37_LO10, + BFD_RELOC_KVX_S37_UP27, + BFD_RELOC_KVX_S37_GOTOFF_LO10, + BFD_RELOC_KVX_S37_GOTOFF_UP27, + BFD_RELOC_KVX_S43_GOTOFF_LO10, + BFD_RELOC_KVX_S43_GOTOFF_UP27, + BFD_RELOC_KVX_S43_GOTOFF_EX6, + BFD_RELOC_KVX_32_GOTOFF, + BFD_RELOC_KVX_64_GOTOFF, + BFD_RELOC_KVX_32_GOT, + BFD_RELOC_KVX_S37_GOT_LO10, + BFD_RELOC_KVX_S37_GOT_UP27, + BFD_RELOC_KVX_S43_GOT_LO10, + BFD_RELOC_KVX_S43_GOT_UP27, + BFD_RELOC_KVX_S43_GOT_EX6, + BFD_RELOC_KVX_64_GOT, + BFD_RELOC_KVX_GLOB_DAT, + BFD_RELOC_KVX_COPY, + BFD_RELOC_KVX_JMP_SLOT, + BFD_RELOC_KVX_RELATIVE, + BFD_RELOC_KVX_S43_LO10, + BFD_RELOC_KVX_S43_UP27, + BFD_RELOC_KVX_S43_EX6, + BFD_RELOC_KVX_S64_LO10, + BFD_RELOC_KVX_S64_UP27, + BFD_RELOC_KVX_S64_EX27, + BFD_RELOC_KVX_S37_GOTADDR_LO10, + BFD_RELOC_KVX_S37_GOTADDR_UP27, + BFD_RELOC_KVX_S43_GOTADDR_LO10, + BFD_RELOC_KVX_S43_GOTADDR_UP27, + BFD_RELOC_KVX_S43_GOTADDR_EX6, + BFD_RELOC_KVX_S64_GOTADDR_LO10, + BFD_RELOC_KVX_S64_GOTADDR_UP27, + BFD_RELOC_KVX_S64_GOTADDR_EX27, + BFD_RELOC_KVX_64_DTPMOD, + BFD_RELOC_KVX_64_DTPOFF, + BFD_RELOC_KVX_S37_TLS_DTPOFF_LO10, + BFD_RELOC_KVX_S37_TLS_DTPOFF_UP27, + BFD_RELOC_KVX_S43_TLS_DTPOFF_LO10, + BFD_RELOC_KVX_S43_TLS_DTPOFF_UP27, + BFD_RELOC_KVX_S43_TLS_DTPOFF_EX6, + BFD_RELOC_KVX_S37_TLS_GD_LO10, + BFD_RELOC_KVX_S37_TLS_GD_UP27, + BFD_RELOC_KVX_S43_TLS_GD_LO10, + BFD_RELOC_KVX_S43_TLS_GD_UP27, + BFD_RELOC_KVX_S43_TLS_GD_EX6, + BFD_RELOC_KVX_S37_TLS_LD_LO10, + BFD_RELOC_KVX_S37_TLS_LD_UP27, + BFD_RELOC_KVX_S43_TLS_LD_LO10, + BFD_RELOC_KVX_S43_TLS_LD_UP27, + BFD_RELOC_KVX_S43_TLS_LD_EX6, + BFD_RELOC_KVX_64_TPOFF, + BFD_RELOC_KVX_S37_TLS_IE_LO10, + BFD_RELOC_KVX_S37_TLS_IE_UP27, + BFD_RELOC_KVX_S43_TLS_IE_LO10, + BFD_RELOC_KVX_S43_TLS_IE_UP27, + BFD_RELOC_KVX_S43_TLS_IE_EX6, + BFD_RELOC_KVX_S37_TLS_LE_LO10, + BFD_RELOC_KVX_S37_TLS_LE_UP27, + BFD_RELOC_KVX_S43_TLS_LE_LO10, + BFD_RELOC_KVX_S43_TLS_LE_UP27, + BFD_RELOC_KVX_S43_TLS_LE_EX6, + BFD_RELOC_KVX_8, + + /* KVX pseudo relocation code to mark the end of the KVX relocation + enumerators that have direct mapping to ELF reloc codes. There are + a few more enumerators after this one; those are mainly used by the + KVX assembler for the internal fixup or to select one of the above + enumerators. */ + BFD_RELOC_KVX_RELOC_END, + + /* AArch64 pseudo relocation code to mark the start of the AArch64 + relocation enumerators. N.B. the order of the enumerators is + important as several tables in the AArch64 bfd backend are indexed + by these enumerators; make sure they are all synced. */ + BFD_RELOC_AARCH64_RELOC_START, + + /* Deprecated AArch64 null relocation code. */ + BFD_RELOC_AARCH64_NULL, + + /* AArch64 null relocation code. */ + BFD_RELOC_AARCH64_NONE, + + /* Basic absolute relocations of N bits. These are equivalent to + BFD_RELOC_N and they were added to assist the indexing of the howto + table. */ + BFD_RELOC_AARCH64_64, + BFD_RELOC_AARCH64_32, + BFD_RELOC_AARCH64_16, + + /* PC-relative relocations. These are equivalent to BFD_RELOC_N_PCREL + and they were added to assist the indexing of the howto table. */ + BFD_RELOC_AARCH64_64_PCREL, + BFD_RELOC_AARCH64_32_PCREL, + BFD_RELOC_AARCH64_16_PCREL, + + /* AArch64 MOV[NZK] instruction with most significant bits 0 to 15 of + an unsigned address/value. */ + BFD_RELOC_AARCH64_MOVW_G0, + + /* AArch64 MOV[NZK] instruction with less significant bits 0 to 15 of + an address/value. No overflow checking. */ + BFD_RELOC_AARCH64_MOVW_G0_NC, + + /* AArch64 MOV[NZK] instruction with most significant bits 16 to 31 of + an unsigned address/value. */ + BFD_RELOC_AARCH64_MOVW_G1, + + /* AArch64 MOV[NZK] instruction with less significant bits 16 to 31 of + an address/value. No overflow checking. */ + BFD_RELOC_AARCH64_MOVW_G1_NC, + + /* AArch64 MOV[NZK] instruction with most significant bits 32 to 47 of + an unsigned address/value. */ + BFD_RELOC_AARCH64_MOVW_G2, + + /* AArch64 MOV[NZK] instruction with less significant bits 32 to 47 of + an address/value. No overflow checking. */ + BFD_RELOC_AARCH64_MOVW_G2_NC, + + /* AArch64 MOV[NZK] instruction with most signficant bits 48 to 64 of a + signed or unsigned address/value. */ + BFD_RELOC_AARCH64_MOVW_G3, + + /* AArch64 MOV[NZ] instruction with most significant bits 0 to 15 of a + signed value. Changes instruction to MOVZ or MOVN depending on the + value's sign. */ + BFD_RELOC_AARCH64_MOVW_G0_S, + + /* AArch64 MOV[NZ] instruction with most significant bits 16 to 31 of a + signed value. Changes instruction to MOVZ or MOVN depending on the + value's sign. */ + BFD_RELOC_AARCH64_MOVW_G1_S, + + /* AArch64 MOV[NZ] instruction with most significant bits 32 to 47 of a + signed value. Changes instruction to MOVZ or MOVN depending on the + value's sign. */ + BFD_RELOC_AARCH64_MOVW_G2_S, + + /* AArch64 MOV[NZ] instruction with most significant bits 0 to 15 of a + signed value. Changes instruction to MOVZ or MOVN depending on the + value's sign. */ + BFD_RELOC_AARCH64_MOVW_PREL_G0, + + /* AArch64 MOV[NZ] instruction with most significant bits 0 to 15 of a + signed value. Changes instruction to MOVZ or MOVN depending on the + value's sign. */ + BFD_RELOC_AARCH64_MOVW_PREL_G0_NC, + + /* AArch64 MOVK instruction with most significant bits 16 to 31 of a + signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G1, + + /* AArch64 MOVK instruction with most significant bits 16 to 31 of a + signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G1_NC, + + /* AArch64 MOVK instruction with most significant bits 32 to 47 of a + signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G2, + + /* AArch64 MOVK instruction with most significant bits 32 to 47 of a + signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G2_NC, + + /* AArch64 MOVK instruction with most significant bits 47 to 63 of a + signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G3, + + /* AArch64 Load Literal instruction, holding a 19 bit pc-relative word + offset. The lowest two bits must be zero and are not stored in the + instruction, giving a 21 bit signed byte offset. */ + BFD_RELOC_AARCH64_LD_LO19_PCREL, + + /* AArch64 ADR instruction, holding a simple 21 bit pc-relative byte + offset. */ + BFD_RELOC_AARCH64_ADR_LO21_PCREL, + + /* AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page + offset, giving a 4KB aligned page base address. */ + BFD_RELOC_AARCH64_ADR_HI21_PCREL, + + /* AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page + offset, giving a 4KB aligned page base address, but with no overflow + checking. */ + BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL, + + /* AArch64 ADD immediate instruction, holding bits 0 to 11 of the + address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ + BFD_RELOC_AARCH64_ADD_LO12, + + /* AArch64 8-bit load/store instruction, holding bits 0 to 11 of the + address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ + BFD_RELOC_AARCH64_LDST8_LO12, + + /* AArch64 14 bit pc-relative test bit and branch. + The lowest two bits must be zero and are not stored in the + instruction, giving a 16 bit signed byte offset. */ + BFD_RELOC_AARCH64_TSTBR14, + + /* AArch64 19 bit pc-relative conditional branch and compare & branch. + The lowest two bits must be zero and are not stored in the + instruction, giving a 21 bit signed byte offset. */ + BFD_RELOC_AARCH64_BRANCH19, + + /* AArch64 26 bit pc-relative unconditional branch. + The lowest two bits must be zero and are not stored in the + instruction, giving a 28 bit signed byte offset. */ + BFD_RELOC_AARCH64_JUMP26, + + /* AArch64 26 bit pc-relative unconditional branch and link. + The lowest two bits must be zero and are not stored in the + instruction, giving a 28 bit signed byte offset. */ + BFD_RELOC_AARCH64_CALL26, + + /* AArch64 16-bit load/store instruction, holding bits 0 to 11 of the + address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ + BFD_RELOC_AARCH64_LDST16_LO12, + + /* AArch64 32-bit load/store instruction, holding bits 0 to 11 of the + address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ + BFD_RELOC_AARCH64_LDST32_LO12, + + /* AArch64 64-bit load/store instruction, holding bits 0 to 11 of the + address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ + BFD_RELOC_AARCH64_LDST64_LO12, + + /* AArch64 128-bit load/store instruction, holding bits 0 to 11 of the + address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ + BFD_RELOC_AARCH64_LDST128_LO12, + + /* AArch64 Load Literal instruction, holding a 19 bit PC relative word + offset of the global offset table entry for a symbol. The lowest + two bits must be zero and are not stored in the instruction, giving + a 21 bit signed byte offset. This relocation type requires signed + overflow checking. */ + BFD_RELOC_AARCH64_GOT_LD_PREL19, + + /* Get to the page base of the global offset table entry for a symbol + as part of an ADRP instruction using a 21 bit PC relative value. + Used in conjunction with BFD_RELOC_AARCH64_LD64_GOT_LO12_NC. */ + BFD_RELOC_AARCH64_ADR_GOT_PAGE, + + /* Unsigned 12 bit byte offset for 64 bit load/store from the page of + the GOT entry for this symbol. Used in conjunction with + BFD_RELOC_AARCH64_ADR_GOT_PAGE. Valid in LP64 ABI only. */ + BFD_RELOC_AARCH64_LD64_GOT_LO12_NC, + + /* Unsigned 12 bit byte offset for 32 bit load/store from the page of + the GOT entry for this symbol. Used in conjunction with + BFD_RELOC_AARCH64_ADR_GOT_PAGE. Valid in ILP32 ABI only. */ + BFD_RELOC_AARCH64_LD32_GOT_LO12_NC, + + /* Unsigned 16 bit byte offset for 64 bit load/store from the GOT entry + for this symbol. Valid in LP64 ABI only. */ + BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC, + + /* Unsigned 16 bit byte higher offset for 64 bit load/store from the + GOT entry for this symbol. Valid in LP64 ABI only. */ + BFD_RELOC_AARCH64_MOVW_GOTOFF_G1, + + /* Unsigned 15 bit byte offset for 64 bit load/store from the page of + the GOT entry for this symbol. Valid in LP64 ABI only. */ + BFD_RELOC_AARCH64_LD64_GOTOFF_LO15, + + /* Scaled 14 bit byte offset to the page base of the global offset + table. */ + BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14, + + /* Scaled 15 bit byte offset to the page base of the global offset + table. */ + BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15, + + /* Get to the page base of the global offset table entry for a symbols + tls_index structure as part of an adrp instruction using a 21 bit PC + relative value. Used in conjunction with + BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC. */ + BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21, + + /* AArch64 TLS General Dynamic. */ + BFD_RELOC_AARCH64_TLSGD_ADR_PREL21, + + /* Unsigned 12 bit byte offset to global offset table entry for a + symbol's tls_index structure. Used in conjunction with + BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21. */ + BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC, + + /* AArch64 TLS General Dynamic relocation. */ + BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC, + + /* AArch64 TLS General Dynamic relocation. */ + BFD_RELOC_AARCH64_TLSGD_MOVW_G1, + + /* AArch64 TLS INITIAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, + + /* AArch64 TLS INITIAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC, + + /* AArch64 TLS INITIAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC, + + /* AArch64 TLS INITIAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19, + + /* AArch64 TLS INITIAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, + + /* AArch64 TLS INITIAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1, + + /* bit[23:12] of byte offset to module TLS base address. */ + BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12, + + /* Unsigned 12 bit byte offset to module TLS base address. */ + BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12, + + /* No overflow check version of + BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12. */ + BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC, + + /* Unsigned 12 bit byte offset to global offset table entry for a + symbol's tls_index structure. Used in conjunction with + BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21. */ + BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC, + + /* GOT entry page address for AArch64 TLS Local Dynamic, used with ADRP + instruction. */ + BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21, + + /* GOT entry address for AArch64 TLS Local Dynamic, used with ADR + instruction. */ + BFD_RELOC_AARCH64_TLSLD_ADR_PREL21, + + /* bit[11:1] of byte offset to module TLS base address, encoded in ldst + instructions. */ + BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, but no + overflow check. */ + BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC, + + /* bit[11:2] of byte offset to module TLS base address, encoded in ldst + instructions. */ + BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, but no + overflow check. */ + BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC, + + /* bit[11:3] of byte offset to module TLS base address, encoded in ldst + instructions. */ + BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, but no + overflow check. */ + BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC, + + /* bit[11:0] of byte offset to module TLS base address, encoded in ldst + instructions. */ + BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, but no + overflow check. */ + BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC, + + /* bit[15:0] of byte offset to module TLS base address. */ + BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0, + + /* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0. */ + BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC, + + /* bit[31:16] of byte offset to module TLS base address. */ + BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1, + + /* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1. */ + BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC, + + /* bit[47:32] of byte offset to module TLS base address. */ + BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2, + + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2, + + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1, + + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC, + + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0, + + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC, + + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12, + + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12, + + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC, + + /* bit[11:1] of byte offset to module TLS base address, encoded in ldst + instructions. */ + BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12, but no + overflow check. */ + BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC, + + /* bit[11:2] of byte offset to module TLS base address, encoded in ldst + instructions. */ + BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12, but no + overflow check. */ + BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC, + + /* bit[11:3] of byte offset to module TLS base address, encoded in ldst + instructions. */ + BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12, but no + overflow check. */ + BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC, + + /* bit[11:0] of byte offset to module TLS base address, encoded in ldst + instructions. */ + BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12, but no overflow + check. */ + BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC, + + /* AArch64 TLS DESC relocations. */ + BFD_RELOC_AARCH64_TLSDESC_LD_PREL19, + BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21, + BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21, + BFD_RELOC_AARCH64_TLSDESC_LD64_LO12, + BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC, + BFD_RELOC_AARCH64_TLSDESC_ADD_LO12, + BFD_RELOC_AARCH64_TLSDESC_OFF_G1, + BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC, + BFD_RELOC_AARCH64_TLSDESC_LDR, + BFD_RELOC_AARCH64_TLSDESC_ADD, + BFD_RELOC_AARCH64_TLSDESC_CALL, + + /* AArch64 DSO relocations. */ + BFD_RELOC_AARCH64_COPY, + BFD_RELOC_AARCH64_GLOB_DAT, + BFD_RELOC_AARCH64_JUMP_SLOT, + BFD_RELOC_AARCH64_RELATIVE, + + /* AArch64 TLS relocations. */ + BFD_RELOC_AARCH64_TLS_DTPMOD, + BFD_RELOC_AARCH64_TLS_DTPREL, + BFD_RELOC_AARCH64_TLS_TPREL, + BFD_RELOC_AARCH64_TLSDESC, + + /* AArch64 support for STT_GNU_IFUNC. */ + BFD_RELOC_AARCH64_IRELATIVE, + + /* AArch64 pseudo relocation code to mark the end of the AArch64 + relocation enumerators that have direct mapping to ELF reloc codes. + There are a few more enumerators after this one; those are mainly + used by the AArch64 assembler for the internal fixup or to select + one of the above enumerators. */ + BFD_RELOC_AARCH64_RELOC_END, + + /* AArch64 pseudo relocation code to be used internally by the AArch64 + assembler and not (currently) written to any object files. */ + BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP, + + /* AArch64 unspecified load/store instruction, holding bits 0 to 11 of the + address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ + BFD_RELOC_AARCH64_LDST_LO12, + + /* AArch64 pseudo relocation code for TLS local dynamic mode. It's to + be used internally by the AArch64 assembler and not (currently) + written to any object files. */ + BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, but no overflow + check. */ + BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC, + + /* AArch64 pseudo relocation code for TLS local exec mode. It's to be + used internally by the AArch64 assembler and not (currently) written + to any object files. */ + BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12, + + /* Similar to BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12, but no overflow + check. */ + BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC, + + /* AArch64 pseudo relocation code to be used internally by the AArch64 + assembler and not (currently) written to any object files. */ + BFD_RELOC_AARCH64_LD_GOT_LO12_NC, + + /* AArch64 pseudo relocation code to be used internally by the AArch64 + assembler and not (currently) written to any object files. */ + BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC, + + /* AArch64 pseudo relocation code to be used internally by the AArch64 + assembler and not (currently) written to any object files. */ + BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC, + + /* AArch64 9 bit pc-relative conditional branch and compare & branch. + The lowest two bits must be zero and are not stored in the + instruction, giving an 11 bit signed byte offset. */ + BFD_RELOC_AARCH64_BRANCH9, + + /* Tilera TILEPro Relocations. */ + BFD_RELOC_TILEPRO_COPY, + BFD_RELOC_TILEPRO_GLOB_DAT, + BFD_RELOC_TILEPRO_JMP_SLOT, + BFD_RELOC_TILEPRO_RELATIVE, + BFD_RELOC_TILEPRO_BROFF_X1, + BFD_RELOC_TILEPRO_JOFFLONG_X1, + BFD_RELOC_TILEPRO_JOFFLONG_X1_PLT, + BFD_RELOC_TILEPRO_IMM8_X0, + BFD_RELOC_TILEPRO_IMM8_Y0, + BFD_RELOC_TILEPRO_IMM8_X1, + BFD_RELOC_TILEPRO_IMM8_Y1, + BFD_RELOC_TILEPRO_DEST_IMM8_X1, + BFD_RELOC_TILEPRO_MT_IMM15_X1, + BFD_RELOC_TILEPRO_MF_IMM15_X1, + BFD_RELOC_TILEPRO_IMM16_X0, + BFD_RELOC_TILEPRO_IMM16_X1, + BFD_RELOC_TILEPRO_IMM16_X0_LO, + BFD_RELOC_TILEPRO_IMM16_X1_LO, + BFD_RELOC_TILEPRO_IMM16_X0_HI, + BFD_RELOC_TILEPRO_IMM16_X1_HI, + BFD_RELOC_TILEPRO_IMM16_X0_HA, + BFD_RELOC_TILEPRO_IMM16_X1_HA, + BFD_RELOC_TILEPRO_IMM16_X0_PCREL, + BFD_RELOC_TILEPRO_IMM16_X1_PCREL, + BFD_RELOC_TILEPRO_IMM16_X0_LO_PCREL, + BFD_RELOC_TILEPRO_IMM16_X1_LO_PCREL, + BFD_RELOC_TILEPRO_IMM16_X0_HI_PCREL, + BFD_RELOC_TILEPRO_IMM16_X1_HI_PCREL, + BFD_RELOC_TILEPRO_IMM16_X0_HA_PCREL, + BFD_RELOC_TILEPRO_IMM16_X1_HA_PCREL, + BFD_RELOC_TILEPRO_IMM16_X0_GOT, + BFD_RELOC_TILEPRO_IMM16_X1_GOT, + BFD_RELOC_TILEPRO_IMM16_X0_GOT_LO, + BFD_RELOC_TILEPRO_IMM16_X1_GOT_LO, + BFD_RELOC_TILEPRO_IMM16_X0_GOT_HI, + BFD_RELOC_TILEPRO_IMM16_X1_GOT_HI, + BFD_RELOC_TILEPRO_IMM16_X0_GOT_HA, + BFD_RELOC_TILEPRO_IMM16_X1_GOT_HA, + BFD_RELOC_TILEPRO_MMSTART_X0, + BFD_RELOC_TILEPRO_MMEND_X0, + BFD_RELOC_TILEPRO_MMSTART_X1, + BFD_RELOC_TILEPRO_MMEND_X1, + BFD_RELOC_TILEPRO_SHAMT_X0, + BFD_RELOC_TILEPRO_SHAMT_X1, + BFD_RELOC_TILEPRO_SHAMT_Y0, + BFD_RELOC_TILEPRO_SHAMT_Y1, + BFD_RELOC_TILEPRO_TLS_GD_CALL, + BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD, + BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD, + BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD, + BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD, + BFD_RELOC_TILEPRO_TLS_IE_LOAD, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_LO, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_LO, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_HI, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_HI, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_HA, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_HA, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_LO, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_LO, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_HI, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_HI, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_HA, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_HA, + BFD_RELOC_TILEPRO_TLS_DTPMOD32, + BFD_RELOC_TILEPRO_TLS_DTPOFF32, + BFD_RELOC_TILEPRO_TLS_TPOFF32, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI, + BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA, + BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA, + + /* Tilera TILE-Gx Relocations. */ + BFD_RELOC_TILEGX_HW0, + BFD_RELOC_TILEGX_HW1, + BFD_RELOC_TILEGX_HW2, + BFD_RELOC_TILEGX_HW3, + BFD_RELOC_TILEGX_HW0_LAST, + BFD_RELOC_TILEGX_HW1_LAST, + BFD_RELOC_TILEGX_HW2_LAST, + BFD_RELOC_TILEGX_COPY, + BFD_RELOC_TILEGX_GLOB_DAT, + BFD_RELOC_TILEGX_JMP_SLOT, + BFD_RELOC_TILEGX_RELATIVE, + BFD_RELOC_TILEGX_BROFF_X1, + BFD_RELOC_TILEGX_JUMPOFF_X1, + BFD_RELOC_TILEGX_JUMPOFF_X1_PLT, + BFD_RELOC_TILEGX_IMM8_X0, + BFD_RELOC_TILEGX_IMM8_Y0, + BFD_RELOC_TILEGX_IMM8_X1, + BFD_RELOC_TILEGX_IMM8_Y1, + BFD_RELOC_TILEGX_DEST_IMM8_X1, + BFD_RELOC_TILEGX_MT_IMM14_X1, + BFD_RELOC_TILEGX_MF_IMM14_X1, + BFD_RELOC_TILEGX_MMSTART_X0, + BFD_RELOC_TILEGX_MMEND_X0, + BFD_RELOC_TILEGX_SHAMT_X0, + BFD_RELOC_TILEGX_SHAMT_X1, + BFD_RELOC_TILEGX_SHAMT_Y0, + BFD_RELOC_TILEGX_SHAMT_Y1, + BFD_RELOC_TILEGX_IMM16_X0_HW0, + BFD_RELOC_TILEGX_IMM16_X1_HW0, + BFD_RELOC_TILEGX_IMM16_X0_HW1, + BFD_RELOC_TILEGX_IMM16_X1_HW1, + BFD_RELOC_TILEGX_IMM16_X0_HW2, + BFD_RELOC_TILEGX_IMM16_X1_HW2, + BFD_RELOC_TILEGX_IMM16_X0_HW3, + BFD_RELOC_TILEGX_IMM16_X1_HW3, + BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST, + BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST, + BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST, + BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST, + BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST, + BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST, + BFD_RELOC_TILEGX_IMM16_X0_HW0_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW0_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW1_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW1_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW2_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW2_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW3_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW3_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW0_GOT, + BFD_RELOC_TILEGX_IMM16_X1_HW0_GOT, + BFD_RELOC_TILEGX_IMM16_X0_HW0_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW0_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW1_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW1_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW2_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW2_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_GOT, + BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_GOT, + BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_GOT, + BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_GOT, + BFD_RELOC_TILEGX_IMM16_X0_HW3_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW3_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_GD, + BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_GD, + BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_LE, + BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_LE, + BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_LE, + BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_LE, + BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_LE, + BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_LE, + BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_GD, + BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_GD, + BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_GD, + BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_GD, + BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_IE, + BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_IE, + BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL, + BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_IE, + BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_IE, + BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_IE, + BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_IE, + BFD_RELOC_TILEGX_TLS_DTPMOD64, + BFD_RELOC_TILEGX_TLS_DTPOFF64, + BFD_RELOC_TILEGX_TLS_TPOFF64, + BFD_RELOC_TILEGX_TLS_DTPMOD32, + BFD_RELOC_TILEGX_TLS_DTPOFF32, + BFD_RELOC_TILEGX_TLS_TPOFF32, + BFD_RELOC_TILEGX_TLS_GD_CALL, + BFD_RELOC_TILEGX_IMM8_X0_TLS_GD_ADD, + BFD_RELOC_TILEGX_IMM8_X1_TLS_GD_ADD, + BFD_RELOC_TILEGX_IMM8_Y0_TLS_GD_ADD, + BFD_RELOC_TILEGX_IMM8_Y1_TLS_GD_ADD, + BFD_RELOC_TILEGX_TLS_IE_LOAD, + BFD_RELOC_TILEGX_IMM8_X0_TLS_ADD, + BFD_RELOC_TILEGX_IMM8_X1_TLS_ADD, + BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD, + BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD, + + /* Linux eBPF relocations. */ + BFD_RELOC_BPF_64, + BFD_RELOC_BPF_DISP32, + BFD_RELOC_BPF_DISPCALL32, + BFD_RELOC_BPF_DISP16, + + /* Adapteva EPIPHANY - 8 bit signed pc-relative displacement. */ + BFD_RELOC_EPIPHANY_SIMM8, + + /* Adapteva EPIPHANY - 24 bit signed pc-relative displacement. */ + BFD_RELOC_EPIPHANY_SIMM24, + + /* Adapteva EPIPHANY - 16 most-significant bits of absolute address. */ + BFD_RELOC_EPIPHANY_HIGH, + + /* Adapteva EPIPHANY - 16 least-significant bits of absolute address. */ + BFD_RELOC_EPIPHANY_LOW, + + /* Adapteva EPIPHANY - 11 bit signed number - add/sub immediate. */ + BFD_RELOC_EPIPHANY_SIMM11, + + /* Adapteva EPIPHANY - 11 bit sign-magnitude number (ld/st + displacement). */ + BFD_RELOC_EPIPHANY_IMM11, + + /* Adapteva EPIPHANY - 8 bit immediate for 16 bit mov instruction. */ + BFD_RELOC_EPIPHANY_IMM8, + + /* Visium Relocations. */ + BFD_RELOC_VISIUM_HI16, + BFD_RELOC_VISIUM_LO16, + BFD_RELOC_VISIUM_IM16, + BFD_RELOC_VISIUM_REL16, + BFD_RELOC_VISIUM_HI16_PCREL, + BFD_RELOC_VISIUM_LO16_PCREL, + BFD_RELOC_VISIUM_IM16_PCREL, + + /* WebAssembly relocations. */ + BFD_RELOC_WASM32_LEB128, + BFD_RELOC_WASM32_LEB128_GOT, + BFD_RELOC_WASM32_LEB128_GOT_CODE, + BFD_RELOC_WASM32_LEB128_PLT, + BFD_RELOC_WASM32_PLT_INDEX, + BFD_RELOC_WASM32_ABS32_CODE, + BFD_RELOC_WASM32_COPY, + BFD_RELOC_WASM32_CODE_POINTER, + BFD_RELOC_WASM32_INDEX, + BFD_RELOC_WASM32_PLT_SIG, + + /* C-SKY relocations. */ + BFD_RELOC_CKCORE_NONE, + BFD_RELOC_CKCORE_ADDR32, + BFD_RELOC_CKCORE_PCREL_IMM8BY4, + BFD_RELOC_CKCORE_PCREL_IMM11BY2, + BFD_RELOC_CKCORE_PCREL_IMM4BY2, + BFD_RELOC_CKCORE_PCREL32, + BFD_RELOC_CKCORE_PCREL_JSR_IMM11BY2, + BFD_RELOC_CKCORE_GNU_VTINHERIT, + BFD_RELOC_CKCORE_GNU_VTENTRY, + BFD_RELOC_CKCORE_RELATIVE, + BFD_RELOC_CKCORE_COPY, + BFD_RELOC_CKCORE_GLOB_DAT, + BFD_RELOC_CKCORE_JUMP_SLOT, + BFD_RELOC_CKCORE_GOTOFF, + BFD_RELOC_CKCORE_GOTPC, + BFD_RELOC_CKCORE_GOT32, + BFD_RELOC_CKCORE_PLT32, + BFD_RELOC_CKCORE_ADDRGOT, + BFD_RELOC_CKCORE_ADDRPLT, + BFD_RELOC_CKCORE_PCREL_IMM26BY2, + BFD_RELOC_CKCORE_PCREL_IMM16BY2, + BFD_RELOC_CKCORE_PCREL_IMM16BY4, + BFD_RELOC_CKCORE_PCREL_IMM10BY2, + BFD_RELOC_CKCORE_PCREL_IMM10BY4, + BFD_RELOC_CKCORE_ADDR_HI16, + BFD_RELOC_CKCORE_ADDR_LO16, + BFD_RELOC_CKCORE_GOTPC_HI16, + BFD_RELOC_CKCORE_GOTPC_LO16, + BFD_RELOC_CKCORE_GOTOFF_HI16, + BFD_RELOC_CKCORE_GOTOFF_LO16, + BFD_RELOC_CKCORE_GOT12, + BFD_RELOC_CKCORE_GOT_HI16, + BFD_RELOC_CKCORE_GOT_LO16, + BFD_RELOC_CKCORE_PLT12, + BFD_RELOC_CKCORE_PLT_HI16, + BFD_RELOC_CKCORE_PLT_LO16, + BFD_RELOC_CKCORE_ADDRGOT_HI16, + BFD_RELOC_CKCORE_ADDRGOT_LO16, + BFD_RELOC_CKCORE_ADDRPLT_HI16, + BFD_RELOC_CKCORE_ADDRPLT_LO16, + BFD_RELOC_CKCORE_PCREL_JSR_IMM26BY2, + BFD_RELOC_CKCORE_TOFFSET_LO16, + BFD_RELOC_CKCORE_DOFFSET_LO16, + BFD_RELOC_CKCORE_PCREL_IMM18BY2, + BFD_RELOC_CKCORE_DOFFSET_IMM18, + BFD_RELOC_CKCORE_DOFFSET_IMM18BY2, + BFD_RELOC_CKCORE_DOFFSET_IMM18BY4, + BFD_RELOC_CKCORE_GOTOFF_IMM18, + BFD_RELOC_CKCORE_GOT_IMM18BY4, + BFD_RELOC_CKCORE_PLT_IMM18BY4, + BFD_RELOC_CKCORE_PCREL_IMM7BY4, + BFD_RELOC_CKCORE_TLS_LE32, + BFD_RELOC_CKCORE_TLS_IE32, + BFD_RELOC_CKCORE_TLS_GD32, + BFD_RELOC_CKCORE_TLS_LDM32, + BFD_RELOC_CKCORE_TLS_LDO32, + BFD_RELOC_CKCORE_TLS_DTPMOD32, + BFD_RELOC_CKCORE_TLS_DTPOFF32, + BFD_RELOC_CKCORE_TLS_TPOFF32, + BFD_RELOC_CKCORE_PCREL_FLRW_IMM8BY4, + BFD_RELOC_CKCORE_NOJSRI, + BFD_RELOC_CKCORE_CALLGRAPH, + BFD_RELOC_CKCORE_IRELATIVE, + BFD_RELOC_CKCORE_PCREL_BLOOP_IMM4BY4, + BFD_RELOC_CKCORE_PCREL_BLOOP_IMM12BY4, + + /* S12Z relocations. */ + BFD_RELOC_S12Z_OPR, + + /* LARCH relocations. */ + BFD_RELOC_LARCH_TLS_DTPMOD32, + BFD_RELOC_LARCH_TLS_DTPREL32, + BFD_RELOC_LARCH_TLS_DTPMOD64, + BFD_RELOC_LARCH_TLS_DTPREL64, + BFD_RELOC_LARCH_TLS_TPREL32, + BFD_RELOC_LARCH_TLS_TPREL64, + BFD_RELOC_LARCH_TLS_DESC32, + BFD_RELOC_LARCH_TLS_DESC64, + BFD_RELOC_LARCH_MARK_LA, + BFD_RELOC_LARCH_MARK_PCREL, + BFD_RELOC_LARCH_SOP_PUSH_PCREL, + BFD_RELOC_LARCH_SOP_PUSH_ABSOLUTE, + BFD_RELOC_LARCH_SOP_PUSH_DUP, + BFD_RELOC_LARCH_SOP_PUSH_GPREL, + BFD_RELOC_LARCH_SOP_PUSH_TLS_TPREL, + BFD_RELOC_LARCH_SOP_PUSH_TLS_GOT, + BFD_RELOC_LARCH_SOP_PUSH_TLS_GD, + BFD_RELOC_LARCH_SOP_PUSH_PLT_PCREL, + BFD_RELOC_LARCH_SOP_ASSERT, + BFD_RELOC_LARCH_SOP_NOT, + BFD_RELOC_LARCH_SOP_SUB, + BFD_RELOC_LARCH_SOP_SL, + BFD_RELOC_LARCH_SOP_SR, + BFD_RELOC_LARCH_SOP_ADD, + BFD_RELOC_LARCH_SOP_AND, + BFD_RELOC_LARCH_SOP_IF_ELSE, + BFD_RELOC_LARCH_SOP_POP_32_S_10_5, + BFD_RELOC_LARCH_SOP_POP_32_U_10_12, + BFD_RELOC_LARCH_SOP_POP_32_S_10_12, + BFD_RELOC_LARCH_SOP_POP_32_S_10_16, + BFD_RELOC_LARCH_SOP_POP_32_S_10_16_S2, + BFD_RELOC_LARCH_SOP_POP_32_S_5_20, + BFD_RELOC_LARCH_SOP_POP_32_S_0_5_10_16_S2, + BFD_RELOC_LARCH_SOP_POP_32_S_0_10_10_16_S2, + BFD_RELOC_LARCH_SOP_POP_32_U, + BFD_RELOC_LARCH_ADD8, + BFD_RELOC_LARCH_ADD16, + BFD_RELOC_LARCH_ADD24, + BFD_RELOC_LARCH_ADD32, + BFD_RELOC_LARCH_ADD64, + BFD_RELOC_LARCH_SUB8, + BFD_RELOC_LARCH_SUB16, + BFD_RELOC_LARCH_SUB24, + BFD_RELOC_LARCH_SUB32, + BFD_RELOC_LARCH_SUB64, + BFD_RELOC_LARCH_B16, + BFD_RELOC_LARCH_B21, + BFD_RELOC_LARCH_B26, + BFD_RELOC_LARCH_ABS_HI20, + BFD_RELOC_LARCH_ABS_LO12, + BFD_RELOC_LARCH_ABS64_LO20, + BFD_RELOC_LARCH_ABS64_HI12, + BFD_RELOC_LARCH_PCALA_HI20, + BFD_RELOC_LARCH_PCALA_LO12, + BFD_RELOC_LARCH_PCALA64_LO20, + BFD_RELOC_LARCH_PCALA64_HI12, + BFD_RELOC_LARCH_GOT_PC_HI20, + BFD_RELOC_LARCH_GOT_PC_LO12, + BFD_RELOC_LARCH_GOT64_PC_LO20, + BFD_RELOC_LARCH_GOT64_PC_HI12, + BFD_RELOC_LARCH_GOT_HI20, + BFD_RELOC_LARCH_GOT_LO12, + BFD_RELOC_LARCH_GOT64_LO20, + BFD_RELOC_LARCH_GOT64_HI12, + BFD_RELOC_LARCH_TLS_LE_HI20, + BFD_RELOC_LARCH_TLS_LE_LO12, + BFD_RELOC_LARCH_TLS_LE64_LO20, + BFD_RELOC_LARCH_TLS_LE64_HI12, + BFD_RELOC_LARCH_TLS_IE_PC_HI20, + BFD_RELOC_LARCH_TLS_IE_PC_LO12, + BFD_RELOC_LARCH_TLS_IE64_PC_LO20, + BFD_RELOC_LARCH_TLS_IE64_PC_HI12, + BFD_RELOC_LARCH_TLS_IE_HI20, + BFD_RELOC_LARCH_TLS_IE_LO12, + BFD_RELOC_LARCH_TLS_IE64_LO20, + BFD_RELOC_LARCH_TLS_IE64_HI12, + BFD_RELOC_LARCH_TLS_LD_PC_HI20, + BFD_RELOC_LARCH_TLS_LD_HI20, + BFD_RELOC_LARCH_TLS_GD_PC_HI20, + BFD_RELOC_LARCH_TLS_GD_HI20, + BFD_RELOC_LARCH_32_PCREL, + BFD_RELOC_LARCH_RELAX, + BFD_RELOC_LARCH_DELETE, + BFD_RELOC_LARCH_ALIGN, + BFD_RELOC_LARCH_PCREL20_S2, + BFD_RELOC_LARCH_CFA, + BFD_RELOC_LARCH_ADD6, + BFD_RELOC_LARCH_SUB6, + BFD_RELOC_LARCH_ADD_ULEB128, + BFD_RELOC_LARCH_SUB_ULEB128, + BFD_RELOC_LARCH_64_PCREL, + BFD_RELOC_LARCH_CALL36, + BFD_RELOC_LARCH_TLS_DESC_PC_HI20, + BFD_RELOC_LARCH_TLS_DESC_PC_LO12, + BFD_RELOC_LARCH_TLS_DESC64_PC_LO20, + BFD_RELOC_LARCH_TLS_DESC64_PC_HI12, + BFD_RELOC_LARCH_TLS_DESC_HI20, + BFD_RELOC_LARCH_TLS_DESC_LO12, + BFD_RELOC_LARCH_TLS_DESC64_LO20, + BFD_RELOC_LARCH_TLS_DESC64_HI12, + BFD_RELOC_LARCH_TLS_DESC_LD, + BFD_RELOC_LARCH_TLS_DESC_CALL, + BFD_RELOC_LARCH_TLS_LE_HI20_R, + BFD_RELOC_LARCH_TLS_LE_ADD_R, + BFD_RELOC_LARCH_TLS_LE_LO12_R, + BFD_RELOC_LARCH_TLS_LD_PCREL20_S2, + BFD_RELOC_LARCH_TLS_GD_PCREL20_S2, + BFD_RELOC_LARCH_TLS_DESC_PCREL20_S2, + BFD_RELOC_UNUSED +}; +typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; + +reloc_howto_type *bfd_reloc_type_lookup + (bfd *abfd, bfd_reloc_code_real_type code); +reloc_howto_type *bfd_reloc_name_lookup + (bfd *abfd, const char *reloc_name); + +const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); + +/* Extracted from simple.c. */ +bfd_byte *bfd_simple_get_relocated_section_contents + (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table); + +/* Extracted from stab-syms.c. */ +const char *bfd_get_stab_name (int); + +/* Extracted from stabs.c. */ +/* This structure is used to keep track of stabs in sections + information while linking. */ + +struct stab_info +{ + /* A hash table used to hold stabs strings. */ + struct bfd_strtab_hash *strings; + /* The header file hash table. */ + struct bfd_hash_table includes; + /* The first .stabstr section. */ + struct bfd_section *stabstr; +}; + +/* Extracted from targets.c. */ +#define BFD_SEND(bfd, message, arglist) \ + ((*((bfd)->xvec->message)) arglist) + +#ifdef DEBUG_BFD_SEND +#undef BFD_SEND +#define BFD_SEND(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + ((*((bfd)->xvec->message)) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) +#endif +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) + +#ifdef DEBUG_BFD_SEND +#undef BFD_SEND_FMT +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) +#endif + +/* Defined to TRUE if unused section symbol should be kept. */ +#ifndef TARGET_KEEP_UNUSED_SECTION_SYMBOLS +#define TARGET_KEEP_UNUSED_SECTION_SYMBOLS true +#endif + +enum bfd_flavour +{ + /* N.B. Update bfd_flavour_name if you change this. */ + bfd_target_unknown_flavour, + bfd_target_aout_flavour, + bfd_target_coff_flavour, + bfd_target_ecoff_flavour, + bfd_target_xcoff_flavour, + bfd_target_elf_flavour, + bfd_target_tekhex_flavour, + bfd_target_srec_flavour, + bfd_target_verilog_flavour, + bfd_target_ihex_flavour, + bfd_target_som_flavour, + bfd_target_msdos_flavour, + bfd_target_evax_flavour, + bfd_target_mmo_flavour, + bfd_target_mach_o_flavour, + bfd_target_pef_flavour, + bfd_target_pef_xlib_flavour, + bfd_target_sym_flavour +}; + +enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN }; + +/* Forward declarations. */ +struct flag_info; +typedef void (*bfd_cleanup) (bfd *); + +typedef struct bfd_target +{ + /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. */ + const char *name; + + /* The "flavour" of a back end is a general indication about + the contents of a file. */ + enum bfd_flavour flavour; + + /* The order of bytes within the data area of a file. */ + enum bfd_endian byteorder; + + /* The order of bytes within the header parts of a file. */ + enum bfd_endian header_byteorder; + + /* A mask of all the flags which an executable may have set - + from the set <>, <>, ...<>. */ + flagword object_flags; + + /* A mask of all the flags which a section may have set - from + the set <>, <>, ...<>. */ + flagword section_flags; + + /* The character normally found at the front of a symbol. + (if any), perhaps `_'. */ + char symbol_leading_char; + + /* The pad character for file names within an archive header. */ + char ar_pad_char; + + /* The maximum number of characters in an archive header. */ + unsigned char ar_max_namelen; + + /* How well this target matches, used to select between various + possible targets when more than one target matches. */ + unsigned char match_priority; + + /* TRUE if unused section symbols should be kept. */ + bool keep_unused_section_symbols; + + /* Entries for byte swapping for data. These are different from the + other entry points, since they don't take a BFD as the first argument. + Certain other handlers could do the same. */ + uint64_t (*bfd_getx64) (const void *); + int64_t (*bfd_getx_signed_64) (const void *); + void (*bfd_putx64) (uint64_t, void *); + bfd_vma (*bfd_getx32) (const void *); + bfd_signed_vma (*bfd_getx_signed_32) (const void *); + void (*bfd_putx32) (bfd_vma, void *); + bfd_vma (*bfd_getx16) (const void *); + bfd_signed_vma (*bfd_getx_signed_16) (const void *); + void (*bfd_putx16) (bfd_vma, void *); + + /* Byte swapping for the headers. */ + uint64_t (*bfd_h_getx64) (const void *); + int64_t (*bfd_h_getx_signed_64) (const void *); + void (*bfd_h_putx64) (uint64_t, void *); + bfd_vma (*bfd_h_getx32) (const void *); + bfd_signed_vma (*bfd_h_getx_signed_32) (const void *); + void (*bfd_h_putx32) (bfd_vma, void *); + bfd_vma (*bfd_h_getx16) (const void *); + bfd_signed_vma (*bfd_h_getx_signed_16) (const void *); + void (*bfd_h_putx16) (bfd_vma, void *); + + /* Format dependent routines: these are vectors of entry points + within the target vector structure, one for each format to check. */ + + /* Check the format of a file being read. Return a <> on + success or zero on failure. */ + bfd_cleanup (*_bfd_check_format[bfd_type_end]) (bfd *); + + /* Set the format of a file being written. */ + bool (*_bfd_set_format[bfd_type_end]) (bfd *); + + /* Write cached information into a file being written, at <>. */ + bool (*_bfd_write_contents[bfd_type_end]) (bfd *); + + /* Generic entry points. */ +#define BFD_JUMP_TABLE_GENERIC(NAME) \ + NAME##_close_and_cleanup, \ + NAME##_bfd_free_cached_info, \ + NAME##_new_section_hook, \ + NAME##_get_section_contents + + /* Called when the BFD is being closed to do any necessary cleanup. */ + bool (*_close_and_cleanup) (bfd *); + /* Ask the BFD to free all cached information. */ + bool (*_bfd_free_cached_info) (bfd *); + /* Called when a new section is created. */ + bool (*_new_section_hook) (bfd *, sec_ptr); + /* Read the contents of a section. */ + bool (*_bfd_get_section_contents) (bfd *, sec_ptr, void *, file_ptr, + bfd_size_type); + + /* Entry points to copy private data. */ +#define BFD_JUMP_TABLE_COPY(NAME) \ + NAME##_bfd_copy_private_bfd_data, \ + NAME##_bfd_merge_private_bfd_data, \ + NAME##_bfd_copy_private_section_data, \ + NAME##_bfd_copy_private_symbol_data, \ + NAME##_bfd_copy_private_header_data, \ + NAME##_bfd_set_private_flags, \ + NAME##_bfd_print_private_bfd_data + + /* Called to copy BFD general private data from one object file + to another. */ + bool (*_bfd_copy_private_bfd_data) (bfd *, bfd *); + /* Called to merge BFD general private data from one object file + to a common output file when linking. */ + bool (*_bfd_merge_private_bfd_data) (bfd *, struct bfd_link_info *); + /* Called to copy BFD private section data from one object file + to another. */ + bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, + struct bfd_link_info *); + /* Called to copy BFD private symbol data from one symbol + to another. */ + bool (*_bfd_copy_private_symbol_data) (bfd *, asymbol *, + bfd *, asymbol *); + /* Called to copy BFD private header data from one object file + to another. */ + bool (*_bfd_copy_private_header_data) (bfd *, bfd *); + /* Called to set private backend flags. */ + bool (*_bfd_set_private_flags) (bfd *, flagword); + + /* Called to print private BFD data. */ + bool (*_bfd_print_private_bfd_data) (bfd *, void *); + + /* Core file entry points. */ +#define BFD_JUMP_TABLE_CORE(NAME) \ + NAME##_core_file_failing_command, \ + NAME##_core_file_failing_signal, \ + NAME##_core_file_matches_executable_p, \ + NAME##_core_file_pid + + char *(*_core_file_failing_command) (bfd *); + int (*_core_file_failing_signal) (bfd *); + bool (*_core_file_matches_executable_p) (bfd *, bfd *); + int (*_core_file_pid) (bfd *); + + /* Archive entry points. */ +#define BFD_JUMP_TABLE_ARCHIVE(NAME) \ + NAME##_slurp_armap, \ + NAME##_slurp_extended_name_table, \ + NAME##_construct_extended_name_table, \ + NAME##_truncate_arname, \ + NAME##_write_armap, \ + NAME##_read_ar_hdr, \ + NAME##_write_ar_hdr, \ + NAME##_openr_next_archived_file, \ + NAME##_get_elt_at_index, \ + NAME##_generic_stat_arch_elt, \ + NAME##_update_armap_timestamp + + bool (*_bfd_slurp_armap) (bfd *); + bool (*_bfd_slurp_extended_name_table) (bfd *); + bool (*_bfd_construct_extended_name_table) (bfd *, char **, + bfd_size_type *, + const char **); + void (*_bfd_truncate_arname) (bfd *, const char *, char *); + bool (*write_armap) (bfd *, unsigned, struct orl *, unsigned, int); + void *(*_bfd_read_ar_hdr_fn) (bfd *); + bool (*_bfd_write_ar_hdr_fn) (bfd *, bfd *); + bfd *(*openr_next_archived_file) (bfd *, bfd *); +#define bfd_get_elt_at_index(b,i) \ + BFD_SEND (b, _bfd_get_elt_at_index, (b,i)) + bfd *(*_bfd_get_elt_at_index) (bfd *, symindex); + int (*_bfd_stat_arch_elt) (bfd *, struct stat *); + bool (*_bfd_update_armap_timestamp) (bfd *); + + /* Entry points used for symbols. */ +#define BFD_JUMP_TABLE_SYMBOLS(NAME) \ + NAME##_get_symtab_upper_bound, \ + NAME##_canonicalize_symtab, \ + NAME##_make_empty_symbol, \ + NAME##_print_symbol, \ + NAME##_get_symbol_info, \ + NAME##_get_symbol_version_string, \ + NAME##_bfd_is_local_label_name, \ + NAME##_bfd_is_target_special_symbol, \ + NAME##_get_lineno, \ + NAME##_find_nearest_line, \ + NAME##_find_nearest_line_with_alt, \ + NAME##_find_line, \ + NAME##_find_inliner_info, \ + NAME##_bfd_make_debug_symbol, \ + NAME##_read_minisymbols, \ + NAME##_minisymbol_to_symbol + + long (*_bfd_get_symtab_upper_bound) (bfd *); + long (*_bfd_canonicalize_symtab) (bfd *, struct bfd_symbol **); + struct bfd_symbol * + (*_bfd_make_empty_symbol) (bfd *); + void (*_bfd_print_symbol) (bfd *, void *, struct bfd_symbol *, + bfd_print_symbol_type); +#define bfd_print_symbol(b,p,s,e) \ + BFD_SEND (b, _bfd_print_symbol, (b,p,s,e)) + void (*_bfd_get_symbol_info) (bfd *, struct bfd_symbol *, symbol_info *); +#define bfd_get_symbol_info(b,p,e) \ + BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) + const char * + (*_bfd_get_symbol_version_string) (bfd *, struct bfd_symbol *, + bool, bool *); +#define bfd_get_symbol_version_string(b,s,p,h) \ + BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,p,h)) + bool (*_bfd_is_local_label_name) (bfd *, const char *); + bool (*_bfd_is_target_special_symbol) (bfd *, asymbol *); + alent * + (*_get_lineno) (bfd *, struct bfd_symbol *); + bool (*_bfd_find_nearest_line) (bfd *, struct bfd_symbol **, + struct bfd_section *, bfd_vma, + const char **, const char **, + unsigned int *, unsigned int *); + bool (*_bfd_find_nearest_line_with_alt) (bfd *, const char *, + struct bfd_symbol **, + struct bfd_section *, bfd_vma, + const char **, const char **, + unsigned int *, unsigned int *); + bool (*_bfd_find_line) (bfd *, struct bfd_symbol **, + struct bfd_symbol *, const char **, + unsigned int *); + bool (*_bfd_find_inliner_info) + (bfd *, const char **, const char **, unsigned int *); + /* Back-door to allow format-aware applications to create debug symbols + while using BFD for everything else. Currently used by the assembler + when creating COFF files. */ + asymbol * + (*_bfd_make_debug_symbol) (bfd *); +#define bfd_read_minisymbols(b, d, m, s) \ + BFD_SEND (b, _read_minisymbols, (b, d, m, s)) + long (*_read_minisymbols) (bfd *, bool, void **, unsigned int *); +#define bfd_minisymbol_to_symbol(b, d, m, f) \ + BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f)) + asymbol * + (*_minisymbol_to_symbol) (bfd *, bool, const void *, asymbol *); + + /* Routines for relocs. */ +#define BFD_JUMP_TABLE_RELOCS(NAME) \ + NAME##_get_reloc_upper_bound, \ + NAME##_canonicalize_reloc, \ + NAME##_set_reloc, \ + NAME##_bfd_reloc_type_lookup, \ + NAME##_bfd_reloc_name_lookup + + long (*_get_reloc_upper_bound) (bfd *, sec_ptr); + long (*_bfd_canonicalize_reloc) (bfd *, sec_ptr, arelent **, + struct bfd_symbol **); + void (*_bfd_set_reloc) (bfd *, sec_ptr, arelent **, unsigned int); + /* See documentation on reloc types. */ + reloc_howto_type * + (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type); + reloc_howto_type * + (*reloc_name_lookup) (bfd *, const char *); + + /* Routines used when writing an object file. */ +#define BFD_JUMP_TABLE_WRITE(NAME) \ + NAME##_set_arch_mach, \ + NAME##_set_section_contents + + bool (*_bfd_set_arch_mach) (bfd *, enum bfd_architecture, + unsigned long); + bool (*_bfd_set_section_contents) (bfd *, sec_ptr, const void *, + file_ptr, bfd_size_type); + + /* Routines used by the linker. */ +#define BFD_JUMP_TABLE_LINK(NAME) \ + NAME##_sizeof_headers, \ + NAME##_bfd_get_relocated_section_contents, \ + NAME##_bfd_relax_section, \ + NAME##_bfd_link_hash_table_create, \ + NAME##_bfd_link_add_symbols, \ + NAME##_bfd_link_just_syms, \ + NAME##_bfd_copy_link_hash_symbol_type, \ + NAME##_bfd_final_link, \ + NAME##_bfd_link_split_section, \ + NAME##_bfd_link_check_relocs, \ + NAME##_bfd_gc_sections, \ + NAME##_bfd_lookup_section_flags, \ + NAME##_bfd_merge_sections, \ + NAME##_bfd_is_group_section, \ + NAME##_bfd_group_name, \ + NAME##_bfd_discard_group, \ + NAME##_section_already_linked, \ + NAME##_bfd_define_common_symbol, \ + NAME##_bfd_link_hide_symbol, \ + NAME##_bfd_define_start_stop + + int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *); + bfd_byte * + (*_bfd_get_relocated_section_contents) (bfd *, + struct bfd_link_info *, + struct bfd_link_order *, + bfd_byte *, bool, + struct bfd_symbol **); + + bool (*_bfd_relax_section) (bfd *, struct bfd_section *, + struct bfd_link_info *, bool *); + + /* Create a hash table for the linker. Different backends store + different information in this table. */ + struct bfd_link_hash_table * + (*_bfd_link_hash_table_create) (bfd *); + + /* Add symbols from this object file into the hash table. */ + bool (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *); + + /* Indicate that we are only retrieving symbol values from this section. */ + void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); + + /* Copy the symbol type and other attributes for a linker script + assignment of one symbol to another. */ +#define bfd_copy_link_hash_symbol_type(b, t, f) \ + BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f)) + void (*_bfd_copy_link_hash_symbol_type) (bfd *, + struct bfd_link_hash_entry *, + struct bfd_link_hash_entry *); + + /* Do a link based on the link_order structures attached to each + section of the BFD. */ + bool (*_bfd_final_link) (bfd *, struct bfd_link_info *); + + /* Should this section be split up into smaller pieces during linking. */ + bool (*_bfd_link_split_section) (bfd *, struct bfd_section *); + + /* Check the relocations in the bfd for validity. */ + bool (* _bfd_link_check_relocs)(bfd *, struct bfd_link_info *); + + /* Remove sections that are not referenced from the output. */ + bool (*_bfd_gc_sections) (bfd *, struct bfd_link_info *); + + /* Sets the bitmask of allowed and disallowed section flags. */ + bool (*_bfd_lookup_section_flags) (struct bfd_link_info *, + struct flag_info *, asection *); + + /* Attempt to merge SEC_MERGE sections. */ + bool (*_bfd_merge_sections) (bfd *, struct bfd_link_info *); + + /* Is this section a member of a group? */ + bool (*_bfd_is_group_section) (bfd *, const struct bfd_section *); + + /* The group name, if section is a member of a group. */ + const char *(*_bfd_group_name) (bfd *, const struct bfd_section *); + + /* Discard members of a group. */ + bool (*_bfd_discard_group) (bfd *, struct bfd_section *); + + /* Check if SEC has been already linked during a reloceatable or + final link. */ + bool (*_section_already_linked) (bfd *, asection *, + struct bfd_link_info *); + + /* Define a common symbol. */ + bool (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *, + struct bfd_link_hash_entry *); + + /* Hide a symbol. */ + void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *, + struct bfd_link_hash_entry *); + + /* Define a __start, __stop, .startof. or .sizeof. symbol. */ + struct bfd_link_hash_entry * + (*_bfd_define_start_stop) (struct bfd_link_info *, const char *, + asection *); + + /* Routines to handle dynamic symbols and relocs. */ +#define BFD_JUMP_TABLE_DYNAMIC(NAME) \ + NAME##_get_dynamic_symtab_upper_bound, \ + NAME##_canonicalize_dynamic_symtab, \ + NAME##_get_synthetic_symtab, \ + NAME##_get_dynamic_reloc_upper_bound, \ + NAME##_canonicalize_dynamic_reloc + + /* Get the amount of memory required to hold the dynamic symbols. */ + long (*_bfd_get_dynamic_symtab_upper_bound) (bfd *); + /* Read in the dynamic symbols. */ + long (*_bfd_canonicalize_dynamic_symtab) (bfd *, struct bfd_symbol **); + /* Create synthetized symbols. */ + long (*_bfd_get_synthetic_symtab) (bfd *, long, struct bfd_symbol **, + long, struct bfd_symbol **, + struct bfd_symbol **); + /* Get the amount of memory required to hold the dynamic relocs. */ + long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *); + /* Read in the dynamic relocs. */ + long (*_bfd_canonicalize_dynamic_reloc) (bfd *, arelent **, + struct bfd_symbol **); + + /* Opposite endian version of this target. */ + const struct bfd_target *alternative_target; + + /* Data for use by back-end routines, which isn't + generic enough to belong in this structure. */ + const void *backend_data; + +} bfd_target; + +static inline const char * +bfd_get_target (const bfd *abfd) +{ + return abfd->xvec->name; +} + +static inline enum bfd_flavour +bfd_get_flavour (const bfd *abfd) +{ + return abfd->xvec->flavour; +} + +static inline flagword +bfd_applicable_file_flags (const bfd *abfd) +{ + return abfd->xvec->object_flags; +} + +static inline bool +bfd_family_coff (const bfd *abfd) +{ + return (bfd_get_flavour (abfd) == bfd_target_coff_flavour + || bfd_get_flavour (abfd) == bfd_target_xcoff_flavour); +} + +static inline bool +bfd_big_endian (const bfd *abfd) +{ + return abfd->xvec->byteorder == BFD_ENDIAN_BIG; +} +static inline bool +bfd_little_endian (const bfd *abfd) +{ + return abfd->xvec->byteorder == BFD_ENDIAN_LITTLE; +} + +static inline bool +bfd_header_big_endian (const bfd *abfd) +{ + return abfd->xvec->header_byteorder == BFD_ENDIAN_BIG; +} + +static inline bool +bfd_header_little_endian (const bfd *abfd) +{ + return abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE; +} + +static inline flagword +bfd_applicable_section_flags (const bfd *abfd) +{ + return abfd->xvec->section_flags; +} + +static inline char +bfd_get_symbol_leading_char (const bfd *abfd) +{ + return abfd->xvec->symbol_leading_char; +} + +static inline enum bfd_flavour +bfd_asymbol_flavour (const asymbol *sy) +{ + if ((sy->flags & BSF_SYNTHETIC) != 0) + return bfd_target_unknown_flavour; + return sy->the_bfd->xvec->flavour; +} + +static inline bool +bfd_keep_unused_section_symbols (const bfd *abfd) +{ + return abfd->xvec->keep_unused_section_symbols; +} + +static inline bool +bfd_target_supports_archives (const bfd *abfd) +{ + return (abfd->xvec->_bfd_check_format[bfd_archive] + != abfd->xvec->_bfd_check_format[bfd_unknown]); +} + +bool bfd_set_default_target (const char *name); + +const bfd_target *bfd_find_target (const char *target_name, bfd *abfd); + +const bfd_target *bfd_get_target_info (const char *target_name, + bfd *abfd, + bool *is_bigendian, + int *underscoring, + const char **def_target_arch); + +const char ** bfd_target_list (void); + +const bfd_target *bfd_iterate_over_targets + (int (*func) (const bfd_target *, void *), + void *data); + +const char *bfd_flavour_name (enum bfd_flavour flavour); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/bfdlink.h b/illumos-x86_64/usr/include/bfdlink.h new file mode 100644 index 00000000..3d4d71b3 --- /dev/null +++ b/illumos-x86_64/usr/include/bfdlink.h @@ -0,0 +1,1112 @@ +/* bfdlink.h -- header file for BFD link routines + Copyright (C) 1993-2025 Free Software Foundation, Inc. + Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#ifndef BFDLINK_H +#define BFDLINK_H + +/* Which symbols to strip during a link. */ +enum bfd_link_strip +{ + strip_none, /* Don't strip any symbols. */ + strip_debugger, /* Strip debugging symbols. */ + strip_some, /* keep_hash is the list of symbols to keep. */ + strip_all /* Strip all symbols. */ +}; + +/* Which local symbols to discard during a link. This is irrelevant + if strip_all is used. */ +enum bfd_link_discard +{ + discard_sec_merge, /* Discard local temporary symbols in SEC_MERGE + sections. */ + discard_none, /* Don't discard any locals. */ + discard_l, /* Discard local temporary symbols. */ + discard_all /* Discard all locals. */ +}; + +enum notice_asneeded_action { + notice_as_needed, + notice_not_needed, + notice_needed +}; + +/* Whether to generate ELF common symbols with the STT_COMMON type + during a relocatable link. */ +enum bfd_link_elf_stt_common +{ + unchanged, + elf_stt_common, + no_elf_stt_common +}; + +/* Describes the type of hash table entry structure being used. + Different hash table structure have different fields and so + support different linking features. */ +enum bfd_link_hash_table_type + { + bfd_link_generic_hash_table, + bfd_link_elf_hash_table + }; + +/* These are the possible types of an entry in the BFD link hash + table. */ + +enum bfd_link_hash_type +{ + bfd_link_hash_new, /* Symbol is new. */ + bfd_link_hash_undefined, /* Symbol seen before, but undefined. */ + bfd_link_hash_undefweak, /* Symbol is weak and undefined. */ + bfd_link_hash_defined, /* Symbol is defined. */ + bfd_link_hash_defweak, /* Symbol is weak and defined. */ + bfd_link_hash_common, /* Symbol is common. */ + bfd_link_hash_indirect, /* Symbol is an indirect link. */ + bfd_link_hash_warning /* Like indirect, but warn if referenced. */ +}; + +enum bfd_link_common_skip_ar_symbols +{ + bfd_link_common_skip_none, + bfd_link_common_skip_text, + bfd_link_common_skip_data, + bfd_link_common_skip_all +}; + +struct bfd_link_hash_common_entry + { + unsigned int alignment_power; /* Alignment. */ + asection *section; /* Symbol section. */ + }; + +/* The linking routines use a hash table which uses this structure for + its elements. */ + +struct bfd_link_hash_entry +{ + /* Base hash table entry structure. */ + struct bfd_hash_entry root; + + /* Type of this entry. */ + ENUM_BITFIELD (bfd_link_hash_type) type : 8; + + /* Symbol is referenced in a normal regular object file, + as distinct from a LTO IR object file. */ + unsigned int non_ir_ref_regular : 1; + + /* Symbol is referenced in a normal dynamic object file, + as distinct from a LTO IR object file. */ + unsigned int non_ir_ref_dynamic : 1; + + /* The symbol, SYM, is referenced by __real_SYM in an object file. */ + unsigned int ref_real : 1; + + /* The symbol is a wrapper symbol, __wrap_SYM. */ + unsigned int wrapper_symbol : 1; + + /* Symbol is a built-in define. These will be overridden by PROVIDE + in a linker script. */ + unsigned int linker_def : 1; + + /* Symbol defined in a linker script. */ + unsigned int ldscript_def : 1; + + /* Symbol will be converted from absolute to section-relative. Set for + symbols defined by a script from "dot" (also SEGMENT_START or ORIGIN) + outside of an output section statement. */ + unsigned int rel_from_abs : 1; + + /* A union of information depending upon the type. */ + union + { + /* Nothing is kept for bfd_hash_new. */ + /* bfd_link_hash_undefined, bfd_link_hash_undefweak. */ + struct + { + /* Undefined and common symbols are kept in a linked list through + this field. This field is present in all of the union element + so that we don't need to remove entries from the list when we + change their type. Removing entries would either require the + list to be doubly linked, which would waste more memory, or + require a traversal. When an undefined or common symbol is + created, it should be added to this list, the head of which is in + the link hash table itself. As symbols are defined, they need + not be removed from the list; anything which reads the list must + doublecheck the symbol type. + + Weak symbols are not kept on this list. + + Defined and defweak symbols use this field as a reference marker. + If the field is not NULL, or this structure is the tail of the + undefined symbol list, the symbol has been referenced. If the + symbol is undefined and becomes defined, this field will + automatically be non-NULL since the symbol will have been on the + undefined symbol list. */ + struct bfd_link_hash_entry *next; + /* BFD symbol was found in. */ + bfd *abfd; + } undef; + /* bfd_link_hash_defined, bfd_link_hash_defweak. */ + struct + { + struct bfd_link_hash_entry *next; + /* Symbol section. */ + asection *section; + /* Symbol value. */ + bfd_vma value; + } def; + /* bfd_link_hash_indirect, bfd_link_hash_warning. */ + struct + { + struct bfd_link_hash_entry *next; + /* Real symbol. */ + struct bfd_link_hash_entry *link; + /* Warning message (bfd_link_hash_warning only). */ + const char *warning; + } i; + /* bfd_link_hash_common. */ + struct + { + struct bfd_link_hash_entry *next; + /* The linker needs to know three things about common + symbols: the size, the alignment, and the section in + which the symbol should be placed. We store the size + here, and we allocate a small structure to hold the + section and the alignment. The alignment is stored as a + power of two. We don't store all the information + directly because we don't want to increase the size of + the union; this structure is a major space user in the + linker. */ + struct bfd_link_hash_common_entry *p; + /* Common symbol size. */ + bfd_size_type size; + } c; + } u; +}; + +/* This is the link hash table. It is a derived class of + bfd_hash_table. */ + +struct bfd_link_hash_table +{ + /* The hash table itself. */ + struct bfd_hash_table table; + /* A linked list of undefined and common symbols, linked through the + next field in the bfd_link_hash_entry structure. */ + struct bfd_link_hash_entry *undefs; + /* Entries are added to the tail of the undefs list. */ + struct bfd_link_hash_entry *undefs_tail; + /* Function to free the hash table on closing BFD. */ + void (*hash_table_free) (bfd *); + /* The type of the link hash table. */ + enum bfd_link_hash_table_type type; +}; + +/* Look up an entry in a link hash table. If FOLLOW is TRUE, this + follows bfd_link_hash_indirect and bfd_link_hash_warning links to + the real symbol. */ +extern struct bfd_link_hash_entry *bfd_link_hash_lookup + (struct bfd_link_hash_table *, const char *, bool create, + bool copy, bool follow); + +/* Look up an entry in the main linker hash table if the symbol might + be wrapped. This should only be used for references to an + undefined symbol, not for definitions of a symbol. */ + +extern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup + (bfd *, struct bfd_link_info *, const char *, bool, bool, bool); + +/* If H is a wrapped symbol, ie. the symbol name starts with "__wrap_" + and the remainder is found in wrap_hash, return the real symbol. */ + +extern struct bfd_link_hash_entry *unwrap_hash_lookup + (struct bfd_link_info *, bfd *, struct bfd_link_hash_entry *); + +/* Traverse a link hash table. */ +extern void bfd_link_hash_traverse + (struct bfd_link_hash_table *, + bool (*) (struct bfd_link_hash_entry *, void *), + void *); + +/* Add an entry to the undefs list. */ +extern void bfd_link_add_undef + (struct bfd_link_hash_table *, struct bfd_link_hash_entry *); + +/* Remove symbols from the undefs list that don't belong there. */ +extern void bfd_link_repair_undef_list + (struct bfd_link_hash_table *table); + +/* Read symbols and cache symbol pointer array in outsymbols. */ +extern bool bfd_generic_link_read_symbols (bfd *); + +/* Check the relocs in the BFD. Called after all the input + files have been loaded, and garbage collection has tagged + any unneeded sections. */ +extern bool bfd_link_check_relocs (bfd *,struct bfd_link_info *); + +struct bfd_sym_chain +{ + struct bfd_sym_chain *next; + const char *name; +}; + +/* How to handle unresolved symbols. + There are four possibilities which are enumerated below: */ +enum report_method +{ + /* This is the initial value when then link_info structure is created. + It allows the various stages of the linker to determine whether they + allowed to set the value. */ + RM_NOT_YET_SET = 0, + RM_IGNORE, + RM_DIAGNOSE, +}; + +/* How to handle DT_TEXTREL. */ + +enum textrel_check_method +{ + textrel_check_none, + textrel_check_warning, + textrel_check_error +}; + +#define bfd_link_textrel_check(info) \ + (info->textrel_check != textrel_check_none) + +typedef enum {with_flags, without_flags} flag_type; + +/* A section flag list. */ +struct flag_info_list +{ + flag_type with; + const char *name; + bool valid; + struct flag_info_list *next; +}; + +/* Section flag info. */ +struct flag_info +{ + flagword only_with_flags; + flagword not_with_flags; + struct flag_info_list *flag_list; + bool flags_initialized; +}; + +struct bfd_elf_dynamic_list; +struct bfd_elf_version_tree; + +/* Types of output. */ + +enum output_type +{ + type_pde, + type_pie, + type_relocatable, + type_dll, +}; + +#define bfd_link_pde(info) ((info)->type == type_pde) +#define bfd_link_dll(info) ((info)->type == type_dll) +#define bfd_link_relocatable(info) ((info)->type == type_relocatable) +#define bfd_link_pie(info) ((info)->type == type_pie) +#define bfd_link_executable(info) (bfd_link_pde (info) || bfd_link_pie (info)) +#define bfd_link_pic(info) (bfd_link_dll (info) || bfd_link_pie (info)) + +/* This structure holds all the information needed to communicate + between BFD and the linker when doing a link. */ + +struct bfd_link_info +{ + /* Output type. */ + ENUM_BITFIELD (output_type) type : 2; + + /* TRUE if BFD should pre-bind symbols in a shared object. */ + unsigned int symbolic: 1; + + /* TRUE if BFD should export all symbols in the dynamic symbol table + of an executable, rather than only those used. */ + unsigned int export_dynamic: 1; + + /* TRUE if a default symbol version should be created and used for + exported symbols. */ + unsigned int create_default_symver: 1; + + /* TRUE if unreferenced sections should be removed. */ + unsigned int gc_sections: 1; + + /* TRUE if exported symbols should be kept during section gc. */ + unsigned int gc_keep_exported: 1; + + /* TRUE if every symbol should be reported back via the notice + callback. */ + unsigned int notice_all: 1; + + /* TRUE if the LTO plugin is active. */ + unsigned int lto_plugin_active: 1; + + /* TRUE if all LTO IR symbols have been read. */ + unsigned int lto_all_symbols_read : 1; + + /* TRUE if global symbols in discarded sections should be stripped. */ + unsigned int strip_discarded: 1; + + /* TRUE if all data symbols should be dynamic. */ + unsigned int dynamic_data: 1; + + /* TRUE if section groups should be resolved. */ + unsigned int resolve_section_groups: 1; + + /* Set if output file is big-endian, or if that is unknown, from + the command line or first input file endianness. */ + unsigned int big_endian : 1; + + /* Which symbols to strip. */ + ENUM_BITFIELD (bfd_link_strip) strip : 2; + + /* Which local symbols to discard. */ + ENUM_BITFIELD (bfd_link_discard) discard : 2; + + /* Whether to generate ELF common symbols with the STT_COMMON type. */ + ENUM_BITFIELD (bfd_link_elf_stt_common) elf_stt_common : 2; + + /* Criteria for skipping symbols when determining + whether to include an object from an archive. */ + ENUM_BITFIELD (bfd_link_common_skip_ar_symbols) common_skip_ar_symbols : 2; + + /* What to do with unresolved symbols in an object file. + When producing executables the default is GENERATE_ERROR. + When producing shared libraries the default is IGNORE. The + assumption with shared libraries is that the reference will be + resolved at load/execution time. */ + ENUM_BITFIELD (report_method) unresolved_syms_in_objects : 2; + + /* What to do with unresolved symbols in a shared library. + The same defaults apply. */ + ENUM_BITFIELD (report_method) unresolved_syms_in_shared_libs : 2; + + /* TRUE if unresolved symbols are to be warned, rather than errored. */ + unsigned int warn_unresolved_syms: 1; + + /* TRUE if shared objects should be linked directly, not shared. */ + unsigned int static_link: 1; + + /* TRUE if symbols should be retained in memory, FALSE if they + should be freed and reread. */ + unsigned int keep_memory: 1; + + /* TRUE if BFD should generate relocation information in the final + executable. */ + unsigned int emitrelocations: 1; + + /* TRUE if PT_GNU_RELRO segment should be created. */ + unsigned int relro: 1; + + /* TRUE if DT_RELR should be enabled for compact relative + relocations. */ + unsigned int enable_dt_relr: 1; + + /* TRUE if separate code segment should be created. */ + unsigned int separate_code: 1; + + /* TRUE if only one read-only, non-code segment should be created. */ + unsigned int one_rosegment: 1; + + /* TRUE if GNU_PROPERTY_MEMORY_SEAL should be generated. */ + unsigned int memory_seal: 1; + + /* Nonzero if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment + should be created. 1 for DWARF2 tables, 2 for compact tables. */ + unsigned int eh_frame_hdr_type: 2; + + /* What to do with DT_TEXTREL in output. */ + ENUM_BITFIELD (textrel_check_method) textrel_check: 2; + + /* TRUE if .hash section should be created. */ + unsigned int emit_hash: 1; + + /* TRUE if .gnu.hash section should be created. */ + unsigned int emit_gnu_hash: 1; + + /* If TRUE reduce memory overheads, at the expense of speed. This will + cause map file generation to use an O(N^2) algorithm and disable + caching ELF symbol buffer. */ + unsigned int reduce_memory_overheads: 1; + + /* TRUE if the output file should be in a traditional format. This + is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag + on the output file, but may be checked when reading the input + files. */ + unsigned int traditional_format: 1; + + /* TRUE if non-PLT relocs should be merged into one reloc section + and sorted so that relocs against the same symbol come together. */ + unsigned int combreloc: 1; + + /* TRUE if a default symbol version should be created and used for + imported symbols. */ + unsigned int default_imported_symver: 1; + + /* TRUE if the new ELF dynamic tags are enabled. */ + unsigned int new_dtags: 1; + + /* FALSE if .eh_frame unwind info should be generated for PLT and other + linker created sections, TRUE if it should be omitted. */ + unsigned int no_ld_generated_unwind_info: 1; + + /* TRUE if BFD should generate a "task linked" object file, + similar to relocatable but also with globals converted to + statics. */ + unsigned int task_link: 1; + + /* TRUE if ok to have multiple definitions, without warning. */ + unsigned int allow_multiple_definition: 1; + + /* TRUE if multiple definition of absolute symbols (eg. from -R) should + be reported. */ + unsigned int prohibit_multiple_definition_absolute: 1; + + /* TRUE if multiple definitions should only warn. */ + unsigned int warn_multiple_definition: 1; + + /* TRUE if ok to have version with no definition. */ + unsigned int allow_undefined_version: 1; + + /* TRUE if some symbols have to be dynamic, controlled by + --dynamic-list command line options. */ + unsigned int dynamic: 1; + + /* Set if the "-z execstack" option has been used to request that a + PT_GNU_STACK segment should be created with PF_R, PF_W and PF_X + flags set. + + Note - if performing a relocatable link then a .note.GNU-stack + section will be created instead, if one does not exist already. + The section will have the SHF_EXECINSTR flag bit set. */ + unsigned int execstack: 1; + + /* Set if the "-z noexecstack" option has been used to request that a + PT_GNU_STACK segment should be created with PF_R and PF_W flags. Or + a non-executable .note.GNU-stack section for relocateable links. + + Note - this flag is not quite orthogonal to execstack, since both + of these flags can be 0. In this case a stack segment can still + be created, but it will only have the PF_X flag bit set if one or + more of the input files contains a .note.GNU-stack section with the + SHF_EXECINSTR flag bit set, or if the default behaviour for the + architecture is to create executable stacks. + + The execstack and noexecstack flags should never both be 1. */ + unsigned int noexecstack: 1; + + /* Tri-state variable: + 0 => do not warn when creating an executable stack. + 1 => always warn when creating an executable stack (for any reason). + 2 => only warn when an executable stack has been requested an object + file and execstack is 0 or noexecstack is 1. + 3 => not used. */ + unsigned int warn_execstack: 2; + /* TRUE if a warning generated because of warn_execstack should be instead + be treated as an error. */ + unsigned int error_execstack: 1; + + /* TRUE if warnings should NOT be generated for TLS segments with eXecute + permission or LOAD segments with RWX permissions. */ + unsigned int no_warn_rwx_segments: 1; + /* TRUE if the user gave either --warn-rwx-segments or + --no-warn-rwx-segments on the linker command line. */ + unsigned int user_warn_rwx_segments: 1; + /* TRUE if warnings generated when no_warn_rwx_segements is 0 should + instead be treated as errors. */ + unsigned int warn_is_error_for_rwx_segments: 1; + + /* TRUE if the stack can be made executable because of the absence of a + .note.GNU-stack section in an input file. Note - even if this field + is set, some targets may choose to ignore the setting and not create + an executable stack. */ + unsigned int default_execstack : 1; + + /* TRUE if we want to produced optimized output files. This might + need much more time and therefore must be explicitly selected. */ + unsigned int optimize: 1; + + /* TRUE if user should be informed of removed unreferenced sections. */ + unsigned int print_gc_sections: 1; + + /* TRUE if we should warn alternate ELF machine code. */ + unsigned int warn_alternate_em: 1; + + /* TRUE if the linker script contained an explicit PHDRS command. */ + unsigned int user_phdrs: 1; + + /* TRUE if program headers ought to be loaded. */ + unsigned int load_phdrs: 1; + + /* TRUE if we should check relocations after all input files have + been opened. */ + unsigned int check_relocs_after_open_input: 1; + + /* TRUE if generation of .interp/PT_INTERP should be suppressed. */ + unsigned int nointerp: 1; + + /* TRUE if common symbols should be treated as undefined. */ + unsigned int inhibit_common_definition : 1; + + /* TRUE if "-Map map" is passed to linker. */ + unsigned int has_map_file : 1; + + /* TRUE if "--enable-non-contiguous-regions" is passed to the + linker. */ + unsigned int non_contiguous_regions : 1; + + /* TRUE if "--enable-non-contiguous-regions-warnings" is passed to + the linker. */ + unsigned int non_contiguous_regions_warnings : 1; + + /* TRUE if all symbol names should be unique. */ + unsigned int unique_symbol : 1; + + /* TRUE if maxpagesize is set on command-line. */ + unsigned int maxpagesize_is_set : 1; + + /* TRUE if commonpagesize is set on command-line. */ + unsigned int commonpagesize_is_set : 1; + + /* Char that may appear as the first char of a symbol, but should be + skipped (like symbol_leading_char) when looking up symbols in + wrap_hash. Used by PowerPC Linux for 'dot' symbols. */ + char wrap_char; + + /* Separator between archive and filename in linker script filespecs. */ + char path_separator; + + /* Default stack size. Zero means default (often zero itself), -1 + means explicitly zero-sized. */ + bfd_signed_vma stacksize; + + /* Enable or disable target specific optimizations. + + Not all targets have optimizations to enable. + + Normally these optimizations are disabled by default but some targets + prefer to enable them by default. So this field is a tri-state variable. + The values are: + + zero: Enable the optimizations (either from --relax being specified on + the command line or the backend's before_allocation emulation function. + + positive: The user has requested that these optimizations be disabled. + (Via the --no-relax command line option). + + negative: The optimizations are disabled. (Set when initializing the + args_type structure in ldmain.c:main. */ + signed int disable_target_specific_optimizations; + + /* Function callbacks. */ + const struct bfd_link_callbacks *callbacks; + + /* Hash table handled by BFD. */ + struct bfd_link_hash_table *hash; + + /* Hash table of symbols to keep. This is NULL unless strip is + strip_some. */ + struct bfd_hash_table *keep_hash; + + /* Hash table of symbols to report back via the notice callback. If + this is NULL, and notice_all is FALSE, then no symbols are + reported back. */ + struct bfd_hash_table *notice_hash; + + /* Hash table of symbols which are being wrapped (the --wrap linker + option). If this is NULL, no symbols are being wrapped. */ + struct bfd_hash_table *wrap_hash; + + /* Hash table of symbols which may be left unresolved during + a link. If this is NULL, no symbols can be left unresolved. */ + struct bfd_hash_table *ignore_hash; + + /* The output BFD. */ + bfd *output_bfd; + + /* The import library generated. */ + bfd *out_implib_bfd; + + /* The list of input BFD's involved in the link. These are chained + together via the link.next field. */ + bfd *input_bfds; + bfd **input_bfds_tail; + + /* If a symbol should be created for each input BFD, this is section + where those symbols should be placed. It must be a section in + the output BFD. It may be NULL, in which case no such symbols + will be created. This is to support CREATE_OBJECT_SYMBOLS in the + linker command language. */ + asection *create_object_symbols_section; + + /* List of global symbol names that are starting points for marking + sections against garbage collection. */ + struct bfd_sym_chain *gc_sym_list; + + /* If a base output file is wanted, then this points to it */ + void *base_file; + + /* The function to call when the executable or shared object is + loaded. */ + const char *init_function; + + /* The function to call when the executable or shared object is + unloaded. */ + const char *fini_function; + + /* Number of relaxation passes. Usually only one relaxation pass + is needed. But a backend can have as many relaxation passes as + necessary. During bfd_relax_section call, it is set to the + current pass, starting from 0. */ + int relax_pass; + + /* Number of relaxation trips. This number is incremented every + time the relaxation pass is restarted due to a previous + relaxation returning true in *AGAIN. */ + int relax_trip; + + /* > 0 to treat protected data defined in the shared library as + reference external. 0 to treat it as internal. -1 to let + backend to decide. */ + int extern_protected_data; + + /* 1 to make undefined weak symbols dynamic when building a dynamic + object. 0 to resolve undefined weak symbols to zero. -1 to let + the backend decide. */ + int dynamic_undefined_weak; + + /* Non-zero if auto-import thunks for DATA items in pei386 DLLs + should be generated/linked against. Set to 1 if this feature + is explicitly requested by the user, -1 if enabled by default. */ + int pei386_auto_import; + + /* Non-zero if runtime relocs for DATA items with non-zero addends + in pei386 DLLs should be generated. Set to 1 if this feature + is explicitly requested by the user, -1 if enabled by default. */ + int pei386_runtime_pseudo_reloc; + + /* How many spare .dynamic DT_NULL entries should be added? */ + unsigned int spare_dynamic_tags; + + /* GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS control: + > 1: Turn on by -z indirect-extern-access or by backend. + == 1: Turn on by an input. + 0: Turn off. + < 0: Turn on if it is set on any inputs or let backend to + decide. */ + int indirect_extern_access; + + /* Non-zero if executable should not contain copy relocs. + > 1: Implied by indirect_extern_access. + == 1: Turn on by -z nocopyreloc. + 0: Turn off. + Setting this to non-zero may result in a non-sharable text + segment. */ + int nocopyreloc; + + /* Pointer to the GNU_PROPERTY_1_NEEDED property in memory. */ + bfd_byte *needed_1_p; + + /* May be used to set DT_FLAGS for ELF. */ + bfd_vma flags; + + /* May be used to set DT_FLAGS_1 for ELF. */ + bfd_vma flags_1; + + /* May be used to set DT_GNU_FLAGS_1 for ELF. */ + bfd_vma gnu_flags_1; + + /* TRUE if references to __start_/__stop_ synthesized symbols do not + specially retain C identifier named sections. */ + int start_stop_gc; + + /* May be used to set ELF visibility for __start_* / __stop_. */ + unsigned int start_stop_visibility; + + /* The maximum page size for ELF. */ + bfd_vma maxpagesize; + + /* The common page size for ELF. */ + bfd_vma commonpagesize; + + /* Start and end of RELRO region. */ + bfd_vma relro_start, relro_end; + + /* List of symbols should be dynamic. */ + struct bfd_elf_dynamic_list *dynamic_list; + + /* The version information. */ + struct bfd_elf_version_tree *version_info; + + /* Size of cache. Backend can use it to keep strace cache size. */ + bfd_size_type cache_size; + + /* The maximum cache size. Backend can use cache_size and and + max_cache_size to decide if keep_memory should be honored. */ + bfd_size_type max_cache_size; +}; + +/* Some forward-definitions used by some callbacks. */ + +struct elf_strtab_hash; +struct elf_internal_sym; + +/* This structures holds a set of callback functions. These are called + by the BFD linker routines. */ + +struct bfd_link_callbacks +{ + /* A function which is called when an object is added from an + archive. ABFD is the archive element being added. NAME is the + name of the symbol which caused the archive element to be pulled + in. This function may set *SUBSBFD to point to an alternative + BFD from which symbols should in fact be added in place of the + original BFD's symbols. Returns TRUE if the object should be + added, FALSE if it should be skipped. */ + bool (*add_archive_element) + (struct bfd_link_info *, bfd *abfd, const char *name, bfd **subsbfd); + /* A function which is called when a symbol is found with multiple + definitions. H is the symbol which is defined multiple times. + NBFD is the new BFD, NSEC is the new section, and NVAL is the new + value. NSEC may be bfd_com_section or bfd_ind_section. */ + void (*multiple_definition) + (struct bfd_link_info *, struct bfd_link_hash_entry *h, + bfd *nbfd, asection *nsec, bfd_vma nval); + /* A function which is called when a common symbol is defined + multiple times. H is the symbol appearing multiple times. + NBFD is the BFD of the new symbol. NTYPE is the type of the new + symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or + bfd_link_hash_indirect. If NTYPE is bfd_link_hash_common, NSIZE + is the size of the new symbol. */ + void (*multiple_common) + (struct bfd_link_info *, struct bfd_link_hash_entry *h, + bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize); + /* A function which is called to add a symbol to a set. ENTRY is + the link hash table entry for the set itself (e.g., + __CTOR_LIST__). RELOC is the relocation to use for an entry in + the set when generating a relocatable file, and is also used to + get the size of the entry when generating an executable file. + ABFD, SEC and VALUE identify the value to add to the set. */ + void (*add_to_set) + (struct bfd_link_info *, struct bfd_link_hash_entry *entry, + bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value); + /* A function which is called when the name of a g++ constructor or + destructor is found. This is only called by some object file + formats. CONSTRUCTOR is TRUE for a constructor, FALSE for a + destructor. This will use BFD_RELOC_CTOR when generating a + relocatable file. NAME is the name of the symbol found. ABFD, + SECTION and VALUE are the value of the symbol. */ + void (*constructor) + (struct bfd_link_info *, bool constructor, const char *name, + bfd *abfd, asection *sec, bfd_vma value); + /* A function which is called to issue a linker warning. For + example, this is called when there is a reference to a warning + symbol. WARNING is the warning to be issued. SYMBOL is the name + of the symbol which triggered the warning; it may be NULL if + there is none. ABFD, SECTION and ADDRESS identify the location + which trigerred the warning; either ABFD or SECTION or both may + be NULL if the location is not known. */ + void (*warning) + (struct bfd_link_info *, const char *warning, const char *symbol, + bfd *abfd, asection *section, bfd_vma address); + /* A function which is called when a relocation is attempted against + an undefined symbol. NAME is the symbol which is undefined. + ABFD, SECTION and ADDRESS identify the location from which the + reference is made. IS_FATAL indicates whether an undefined symbol is + a fatal error or not. In some cases SECTION may be NULL. */ + void (*undefined_symbol) + (struct bfd_link_info *, const char *name, bfd *abfd, + asection *section, bfd_vma address, bool is_fatal); + /* A function which is called when a reloc overflow occurs. ENTRY is + the link hash table entry for the symbol the reloc is against. + NAME is the name of the local symbol or section the reloc is + against, RELOC_NAME is the name of the relocation, and ADDEND is + any addend that is used. ABFD, SECTION and ADDRESS identify the + location at which the overflow occurs; if this is the result of a + bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then + ABFD will be NULL. */ + void (*reloc_overflow) + (struct bfd_link_info *, struct bfd_link_hash_entry *entry, + const char *name, const char *reloc_name, bfd_vma addend, + bfd *abfd, asection *section, bfd_vma address); + /* A function which is called when a dangerous reloc is performed. + MESSAGE is an appropriate message. + ABFD, SECTION and ADDRESS identify the location at which the + problem occurred; if this is the result of a + bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then + ABFD will be NULL. */ + void (*reloc_dangerous) + (struct bfd_link_info *, const char *message, + bfd *abfd, asection *section, bfd_vma address); + /* A function which is called when a reloc is found to be attached + to a symbol which is not being written out. NAME is the name of + the symbol. ABFD, SECTION and ADDRESS identify the location of + the reloc; if this is the result of a + bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then + ABFD will be NULL. */ + void (*unattached_reloc) + (struct bfd_link_info *, const char *name, + bfd *abfd, asection *section, bfd_vma address); + /* A function which is called when a symbol in notice_hash is + defined or referenced. H is the symbol, INH the indirect symbol + if applicable. ABFD, SECTION and ADDRESS are the (new) value of + the symbol. If SECTION is bfd_und_section, this is a reference. + FLAGS are the symbol BSF_* flags. */ + bool (*notice) + (struct bfd_link_info *, struct bfd_link_hash_entry *h, + struct bfd_link_hash_entry *inh, + bfd *abfd, asection *section, bfd_vma address, flagword flags); + /* Fatal error. */ + void (*fatal) + (const char *fmt, ...) ATTRIBUTE_NORETURN; + /* Error or warning link info message. */ + void (*einfo) + (const char *fmt, ...); + /* General link info message. */ + void (*info) + (const char *fmt, ...); + /* Message to be printed in linker map file. */ + void (*minfo) + (const char *fmt, ...); + /* This callback provides a chance for users of the BFD library to + override its decision about whether to place two adjacent sections + into the same segment. */ + bool (*override_segment_assignment) + (struct bfd_link_info *, bfd * abfd, + asection * current_section, asection * previous_section, + bool new_segment); + /* This callback provides a chance for callers of the BFD to examine the + ELF (dynamic) string table once it is complete. */ + void (*examine_strtab) + (struct elf_strtab_hash *symstrtab); + /* This callback is called just before a symbol is swapped out, so that the + CTF machinery can look up symbols during construction. The name is + already an external strtab offset at this point. */ + void (*ctf_new_symbol) + (int symidx, struct elf_internal_sym *sym); + /* Likewise, for dynamic symbols. */ + void (*ctf_new_dynsym) + (int symidx, struct elf_internal_sym *sym); + /* This callback should emit the CTF section into a non-loadable section in + the output BFD named .ctf or a name beginning with ".ctf.". */ + void (*emit_ctf) + (void); +}; + +/* The linker builds link_order structures which tell the code how to + include input data in the output file. */ + +/* These are the types of link_order structures. */ + +enum bfd_link_order_type +{ + bfd_undefined_link_order, /* Undefined. */ + bfd_indirect_link_order, /* Built from a section. */ + bfd_data_link_order, /* Set to explicit data. */ + bfd_section_reloc_link_order, /* Relocate against a section. */ + bfd_symbol_reloc_link_order /* Relocate against a symbol. */ +}; + +/* This is the link_order structure itself. These form a chain + attached to the output section whose contents they are describing. */ + +struct bfd_link_order +{ + /* Next link_order in chain. */ + struct bfd_link_order *next; + /* Type of link_order. */ + enum bfd_link_order_type type; + /* Offset within output section in bytes. */ + bfd_vma offset; + /* Size within output section in octets. */ + bfd_size_type size; + /* Type specific information. */ + union + { + struct + { + /* Section to include. If this is used, then + section->output_section must be the section the + link_order is attached to, section->output_offset must + equal the link_order offset field, and section->size + must equal the link_order size field. Maybe these + restrictions should be relaxed someday. */ + asection *section; + } indirect; + struct + { + /* Size of contents, or zero when contents should be filled by + the architecture-dependent fill function. + A non-zero value allows filling of the output section + with an arbitrary repeated pattern. */ + unsigned int size; + /* Data to put into file. */ + bfd_byte *contents; + } data; + struct + { + /* Description of reloc to generate. Used for + bfd_section_reloc_link_order and + bfd_symbol_reloc_link_order. */ + struct bfd_link_order_reloc *p; + } reloc; + } u; +}; + +/* A linker order of type bfd_section_reloc_link_order or + bfd_symbol_reloc_link_order means to create a reloc against a + section or symbol, respectively. This is used to implement -Ur to + generate relocs for the constructor tables. The + bfd_link_order_reloc structure describes the reloc that BFD should + create. It is similar to a arelent, but I didn't use arelent + because the linker does not know anything about most symbols, and + any asymbol structure it creates will be partially meaningless. + This information could logically be in the bfd_link_order struct, + but I didn't want to waste the space since these types of relocs + are relatively rare. */ + +struct bfd_link_order_reloc +{ + /* Reloc type. */ + bfd_reloc_code_real_type reloc; + + union + { + /* For type bfd_section_reloc_link_order, this is the section + the reloc should be against. This must be a section in the + output BFD, not any of the input BFDs. */ + asection *section; + /* For type bfd_symbol_reloc_link_order, this is the name of the + symbol the reloc should be against. */ + const char *name; + } u; + + /* Addend to use. The object file should contain zero. The BFD + backend is responsible for filling in the contents of the object + file correctly. For some object file formats (e.g., COFF) the + addend must be stored into in the object file, and for some + (e.g., SPARC a.out) it is kept in the reloc. */ + bfd_vma addend; +}; + +/* Allocate a new link_order for a section. */ +extern struct bfd_link_order *bfd_new_link_order (bfd *, asection *); + +struct bfd_section_already_linked; + +extern bool bfd_section_already_linked_table_init (void); +extern void bfd_section_already_linked_table_free (void); +extern bool _bfd_handle_already_linked + (struct bfd_section *, struct bfd_section_already_linked *, + struct bfd_link_info *); + +extern struct bfd_section *_bfd_nearby_section + (bfd *, struct bfd_section *, bfd_vma); + +extern void _bfd_fix_excluded_sec_syms + (bfd *, struct bfd_link_info *); + +/* These structures are used to describe version information for the + ELF linker. These structures could be manipulated entirely inside + BFD, but it would be a pain. Instead, the regular linker sets up + these structures, and then passes them into BFD. */ + +/* Glob pattern for a version. */ + +struct bfd_elf_version_expr +{ + /* Next glob pattern for this version. */ + struct bfd_elf_version_expr *next; + /* Glob pattern. */ + const char *pattern; + /* Set if pattern is not a glob. */ + unsigned int literal : 1; + /* Defined by ".symver". */ + unsigned int symver : 1; + /* Defined by version script. */ + unsigned int script : 1; + /* Pattern type. */ +#define BFD_ELF_VERSION_C_TYPE 1 +#define BFD_ELF_VERSION_CXX_TYPE 2 +#define BFD_ELF_VERSION_JAVA_TYPE 4 + unsigned int mask : 3; +}; + +struct bfd_elf_version_expr_head +{ + /* List of all patterns, both wildcards and non-wildcards. */ + struct bfd_elf_version_expr *list; + /* Hash table for non-wildcards. */ + void *htab; + /* Remaining patterns. */ + struct bfd_elf_version_expr *remaining; + /* What kind of pattern types are present in list (bitmask). */ + unsigned int mask; +}; + +/* Version dependencies. */ + +struct bfd_elf_version_deps +{ + /* Next dependency for this version. */ + struct bfd_elf_version_deps *next; + /* The version which this version depends upon. */ + struct bfd_elf_version_tree *version_needed; +}; + +/* A node in the version tree. */ + +struct bfd_elf_version_tree +{ + /* Next version. */ + struct bfd_elf_version_tree *next; + /* Name of this version. */ + const char *name; + /* Version number. */ + unsigned int vernum; + /* Regular expressions for global symbols in this version. */ + struct bfd_elf_version_expr_head globals; + /* Regular expressions for local symbols in this version. */ + struct bfd_elf_version_expr_head locals; + /* List of versions which this version depends upon. */ + struct bfd_elf_version_deps *deps; + /* Index of the version name. This is used within BFD. */ + unsigned int name_indx; + /* Whether this version tree was used. This is used within BFD. */ + int used; + /* Matching hook. */ + struct bfd_elf_version_expr *(*match) + (struct bfd_elf_version_expr_head *head, + struct bfd_elf_version_expr *prev, const char *sym); +}; + +struct bfd_elf_dynamic_list +{ + struct bfd_elf_version_expr_head head; + struct bfd_elf_version_expr *(*match) + (struct bfd_elf_version_expr_head *head, + struct bfd_elf_version_expr *prev, const char *sym); +}; + +#endif diff --git a/illumos-x86_64/usr/include/brotli/decode.h b/illumos-x86_64/usr/include/brotli/decode.h new file mode 100644 index 00000000..af1aa23f --- /dev/null +++ b/illumos-x86_64/usr/include/brotli/decode.h @@ -0,0 +1,409 @@ +/* Copyright 2013 Google Inc. All Rights Reserved. + + Distributed under MIT license. + See file LICENSE for detail or copy at https://opensource.org/licenses/MIT +*/ + +/** + * @file + * API for Brotli decompression. + */ + +#ifndef BROTLI_DEC_DECODE_H_ +#define BROTLI_DEC_DECODE_H_ + +#include +#include +#include + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +/** + * Opaque structure that holds decoder state. + * + * Allocated and initialized with ::BrotliDecoderCreateInstance. + * Cleaned up and deallocated with ::BrotliDecoderDestroyInstance. + */ +typedef struct BrotliDecoderStateStruct BrotliDecoderState; + +/** + * Result type for ::BrotliDecoderDecompress and + * ::BrotliDecoderDecompressStream functions. + */ +typedef enum { + /** Decoding error, e.g. corrupted input or memory allocation problem. */ + BROTLI_DECODER_RESULT_ERROR = 0, + /** Decoding successfully completed. */ + BROTLI_DECODER_RESULT_SUCCESS = 1, + /** Partially done; should be called again with more input. */ + BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT = 2, + /** Partially done; should be called again with more output. */ + BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT = 3 +} BrotliDecoderResult; + +/** + * Template that evaluates items of ::BrotliDecoderErrorCode. + * + * Example: @code {.cpp} + * // Log Brotli error code. + * switch (brotliDecoderErrorCode) { + * #define CASE_(PREFIX, NAME, CODE) \ + * case BROTLI_DECODER ## PREFIX ## NAME: \ + * LOG(INFO) << "error code:" << #NAME; \ + * break; + * #define NEWLINE_ + * BROTLI_DECODER_ERROR_CODES_LIST(CASE_, NEWLINE_) + * #undef CASE_ + * #undef NEWLINE_ + * default: LOG(FATAL) << "unknown brotli error code"; + * } + * @endcode + */ +#define BROTLI_DECODER_ERROR_CODES_LIST(BROTLI_ERROR_CODE, SEPARATOR) \ + BROTLI_ERROR_CODE(_, NO_ERROR, 0) SEPARATOR \ + /* Same as BrotliDecoderResult values */ \ + BROTLI_ERROR_CODE(_, SUCCESS, 1) SEPARATOR \ + BROTLI_ERROR_CODE(_, NEEDS_MORE_INPUT, 2) SEPARATOR \ + BROTLI_ERROR_CODE(_, NEEDS_MORE_OUTPUT, 3) SEPARATOR \ + \ + /* Errors caused by invalid input */ \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, EXUBERANT_NIBBLE, -1) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, RESERVED, -2) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, EXUBERANT_META_NIBBLE, -3) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, SIMPLE_HUFFMAN_ALPHABET, -4) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, SIMPLE_HUFFMAN_SAME, -5) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, CL_SPACE, -6) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, HUFFMAN_SPACE, -7) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, CONTEXT_MAP_REPEAT, -8) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, BLOCK_LENGTH_1, -9) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, BLOCK_LENGTH_2, -10) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, TRANSFORM, -11) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, DICTIONARY, -12) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, WINDOW_BITS, -13) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_1, -14) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_2, -15) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_FORMAT_, DISTANCE, -16) SEPARATOR \ + \ + /* -17 code is reserved */ \ + \ + BROTLI_ERROR_CODE(_ERROR_, COMPOUND_DICTIONARY, -18) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_, DICTIONARY_NOT_SET, -19) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_, INVALID_ARGUMENTS, -20) SEPARATOR \ + \ + /* Memory allocation problems */ \ + BROTLI_ERROR_CODE(_ERROR_ALLOC_, CONTEXT_MODES, -21) SEPARATOR \ + /* Literal, insert and distance trees together */ \ + BROTLI_ERROR_CODE(_ERROR_ALLOC_, TREE_GROUPS, -22) SEPARATOR \ + /* -23..-24 codes are reserved for distinct tree groups */ \ + BROTLI_ERROR_CODE(_ERROR_ALLOC_, CONTEXT_MAP, -25) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_ALLOC_, RING_BUFFER_1, -26) SEPARATOR \ + BROTLI_ERROR_CODE(_ERROR_ALLOC_, RING_BUFFER_2, -27) SEPARATOR \ + /* -28..-29 codes are reserved for dynamic ring-buffer allocation */ \ + BROTLI_ERROR_CODE(_ERROR_ALLOC_, BLOCK_TYPE_TREES, -30) SEPARATOR \ + \ + /* "Impossible" states */ \ + BROTLI_ERROR_CODE(_ERROR_, UNREACHABLE, -31) + +/** + * Error code for detailed logging / production debugging. + * + * See ::BrotliDecoderGetErrorCode and ::BROTLI_LAST_ERROR_CODE. + */ +typedef enum { +#define BROTLI_COMMA_ , +#define BROTLI_ERROR_CODE_ENUM_ITEM_(PREFIX, NAME, CODE) \ + BROTLI_DECODER ## PREFIX ## NAME = CODE + BROTLI_DECODER_ERROR_CODES_LIST(BROTLI_ERROR_CODE_ENUM_ITEM_, BROTLI_COMMA_) +} BrotliDecoderErrorCode; +#undef BROTLI_ERROR_CODE_ENUM_ITEM_ +#undef BROTLI_COMMA_ + +/** + * The value of the last error code, negative integer. + * + * All other error code values are in the range from ::BROTLI_LAST_ERROR_CODE + * to @c -1. There are also 4 other possible non-error codes @c 0 .. @c 3 in + * ::BrotliDecoderErrorCode enumeration. + */ +#define BROTLI_LAST_ERROR_CODE BROTLI_DECODER_ERROR_UNREACHABLE + +/** Options to be used with ::BrotliDecoderSetParameter. */ +typedef enum BrotliDecoderParameter { + /** + * Disable "canny" ring buffer allocation strategy. + * + * Ring buffer is allocated according to window size, despite the real size of + * the content. + */ + BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION = 0, + /** + * Flag that determines if "Large Window Brotli" is used. + */ + BROTLI_DECODER_PARAM_LARGE_WINDOW = 1 +} BrotliDecoderParameter; + +/** + * Sets the specified parameter to the given decoder instance. + * + * @param state decoder instance + * @param param parameter to set + * @param value new parameter value + * @returns ::BROTLI_FALSE if parameter is unrecognized, or value is invalid + * @returns ::BROTLI_TRUE if value is accepted + */ +BROTLI_DEC_API BROTLI_BOOL BrotliDecoderSetParameter( + BrotliDecoderState* state, BrotliDecoderParameter param, uint32_t value); + +/** + * Adds LZ77 prefix dictionary, adds or replaces built-in static dictionary and + * transforms. + * + * Attached dictionary ownership is not transferred. + * Data provided to this method should be kept accessible until + * decoding is finished and decoder instance is destroyed. + * + * @note Dictionaries can NOT be attached after actual decoding is started. + * + * @param state decoder instance + * @param type dictionary data format + * @param data_size length of memory region pointed by @p data + * @param data dictionary data in format corresponding to @p type + * @returns ::BROTLI_FALSE if dictionary is corrupted, + * or dictionary count limit is reached + * @returns ::BROTLI_TRUE if dictionary is accepted / attached + */ +BROTLI_DEC_API BROTLI_BOOL BrotliDecoderAttachDictionary( + BrotliDecoderState* state, BrotliSharedDictionaryType type, + size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)]); + +/** + * Creates an instance of ::BrotliDecoderState and initializes it. + * + * The instance can be used once for decoding and should then be destroyed with + * ::BrotliDecoderDestroyInstance, it cannot be reused for a new decoding + * session. + * + * @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the + * case they are both zero, default memory allocators are used. @p opaque is + * passed to @p alloc_func and @p free_func when they are called. @p free_func + * has to return without doing anything when asked to free a NULL pointer. + * + * @param alloc_func custom memory allocation function + * @param free_func custom memory free function + * @param opaque custom memory manager handle + * @returns @c 0 if instance can not be allocated or initialized + * @returns pointer to initialized ::BrotliDecoderState otherwise + */ +BROTLI_DEC_API BrotliDecoderState* BrotliDecoderCreateInstance( + brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque); + +/** + * Deinitializes and frees ::BrotliDecoderState instance. + * + * @param state decoder instance to be cleaned up and deallocated + */ +BROTLI_DEC_API void BrotliDecoderDestroyInstance(BrotliDecoderState* state); + +/** + * Performs one-shot memory-to-memory decompression. + * + * Decompresses the data in @p encoded_buffer into @p decoded_buffer, and sets + * @p *decoded_size to the decompressed length. + * + * @param encoded_size size of @p encoded_buffer + * @param encoded_buffer compressed data buffer with at least @p encoded_size + * addressable bytes + * @param[in, out] decoded_size @b in: size of @p decoded_buffer; \n + * @b out: length of decompressed data written to + * @p decoded_buffer + * @param decoded_buffer decompressed data destination buffer + * @returns ::BROTLI_DECODER_RESULT_ERROR if input is corrupted, memory + * allocation failed, or @p decoded_buffer is not large enough; + * @returns ::BROTLI_DECODER_RESULT_SUCCESS otherwise + */ +BROTLI_DEC_API BrotliDecoderResult BrotliDecoderDecompress( + size_t encoded_size, + const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)], + size_t* decoded_size, + uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)]); + +/** + * Decompresses the input stream to the output stream. + * + * The values @p *available_in and @p *available_out must specify the number of + * bytes addressable at @p *next_in and @p *next_out respectively. + * When @p *available_out is @c 0, @p next_out is allowed to be @c NULL. + * + * After each call, @p *available_in will be decremented by the amount of input + * bytes consumed, and the @p *next_in pointer will be incremented by that + * amount. Similarly, @p *available_out will be decremented by the amount of + * output bytes written, and the @p *next_out pointer will be incremented by + * that amount. + * + * @p total_out, if it is not a null-pointer, will be set to the number + * of bytes decompressed since the last @p state initialization. + * + * @note Input is never overconsumed, so @p next_in and @p available_in could be + * passed to the next consumer after decoding is complete. + * + * @param state decoder instance + * @param[in, out] available_in @b in: amount of available input; \n + * @b out: amount of unused input + * @param[in, out] next_in pointer to the next compressed byte + * @param[in, out] available_out @b in: length of output buffer; \n + * @b out: remaining size of output buffer + * @param[in, out] next_out output buffer cursor; + * can be @c NULL if @p available_out is @c 0 + * @param[out] total_out number of bytes decompressed so far; can be @c NULL + * @returns ::BROTLI_DECODER_RESULT_ERROR if input is corrupted, memory + * allocation failed, arguments were invalid, etc.; + * use ::BrotliDecoderGetErrorCode to get detailed error code + * @returns ::BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT decoding is blocked until + * more input data is provided + * @returns ::BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT decoding is blocked until + * more output space is provided + * @returns ::BROTLI_DECODER_RESULT_SUCCESS decoding is finished, no more + * input might be consumed and no more output will be produced + */ +BROTLI_DEC_API BrotliDecoderResult BrotliDecoderDecompressStream( + BrotliDecoderState* state, size_t* available_in, const uint8_t** next_in, + size_t* available_out, uint8_t** next_out, size_t* total_out); + +/** + * Checks if decoder has more output. + * + * @param state decoder instance + * @returns ::BROTLI_TRUE, if decoder has some unconsumed output + * @returns ::BROTLI_FALSE otherwise + */ +BROTLI_DEC_API BROTLI_BOOL BrotliDecoderHasMoreOutput( + const BrotliDecoderState* state); + +/** + * Acquires pointer to internal output buffer. + * + * This method is used to make language bindings easier and more efficient: + * -# push data to ::BrotliDecoderDecompressStream, + * until ::BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT is reported + * -# use ::BrotliDecoderTakeOutput to peek bytes and copy to language-specific + * entity + * + * Also this could be useful if there is an output stream that is able to + * consume all the provided data (e.g. when data is saved to file system). + * + * @attention After every call to ::BrotliDecoderTakeOutput @p *size bytes of + * output are considered consumed for all consecutive calls to the + * instance methods; returned pointer becomes invalidated as well. + * + * @note Decoder output is not guaranteed to be contiguous. This means that + * after the size-unrestricted call to ::BrotliDecoderTakeOutput, + * immediate next call to ::BrotliDecoderTakeOutput may return more data. + * + * @param state decoder instance + * @param[in, out] size @b in: number of bytes caller is ready to take, @c 0 if + * any amount could be handled; \n + * @b out: amount of data pointed by returned pointer and + * considered consumed; \n + * out value is never greater than in value, unless it is @c 0 + * @returns pointer to output data + */ +BROTLI_DEC_API const uint8_t* BrotliDecoderTakeOutput( + BrotliDecoderState* state, size_t* size); + +/** + * Checks if instance has already consumed input. + * + * Instance that returns ::BROTLI_FALSE is considered "fresh" and could be + * reused. + * + * @param state decoder instance + * @returns ::BROTLI_TRUE if decoder has already used some input bytes + * @returns ::BROTLI_FALSE otherwise + */ +BROTLI_DEC_API BROTLI_BOOL BrotliDecoderIsUsed(const BrotliDecoderState* state); + +/** + * Checks if decoder instance reached the final state. + * + * @param state decoder instance + * @returns ::BROTLI_TRUE if decoder is in a state where it reached the end of + * the input and produced all of the output + * @returns ::BROTLI_FALSE otherwise + */ +BROTLI_DEC_API BROTLI_BOOL BrotliDecoderIsFinished( + const BrotliDecoderState* state); + +/** + * Acquires a detailed error code. + * + * Should be used only after ::BrotliDecoderDecompressStream returns + * ::BROTLI_DECODER_RESULT_ERROR. + * + * See also ::BrotliDecoderErrorString + * + * @param state decoder instance + * @returns last saved error code + */ +BROTLI_DEC_API BrotliDecoderErrorCode BrotliDecoderGetErrorCode( + const BrotliDecoderState* state); + +/** + * Converts error code to a c-string. + */ +BROTLI_DEC_API const char* BrotliDecoderErrorString(BrotliDecoderErrorCode c); + +/** + * Gets a decoder library version. + * + * Look at BROTLI_MAKE_HEX_VERSION for more information. + */ +BROTLI_DEC_API uint32_t BrotliDecoderVersion(void); + +/** + * Callback to fire on metadata block start. + * + * After this callback is fired, if @p size is not @c 0, it is followed by + * ::brotli_decoder_metadata_chunk_func as more metadata block contents become + * accessible. + * + * @param opaque callback handle + * @param size size of metadata block + */ +typedef void (*brotli_decoder_metadata_start_func)(void* opaque, size_t size); + +/** + * Callback to fire on metadata block chunk becomes available. + * + * This function can be invoked multiple times per metadata block; block should + * be considered finished when sum of @p size matches the announced metadata + * block size. Chunks contents pointed by @p data are transient and shouln not + * be accessed after leaving the callback. + * + * @param opaque callback handle + * @param data pointer to metadata contents + * @param size size of metadata block chunk, at least @c 1 + */ +typedef void (*brotli_decoder_metadata_chunk_func)(void* opaque, + const uint8_t* data, + size_t size); + +/** + * Sets callback for receiving metadata blocks. + * + * @param state decoder instance + * @param start_func callback on metadata block start + * @param chunk_func callback on metadata block chunk + * @param opaque callback handle + */ +BROTLI_DEC_API void BrotliDecoderSetMetadataCallbacks( + BrotliDecoderState* state, + brotli_decoder_metadata_start_func start_func, + brotli_decoder_metadata_chunk_func chunk_func, void* opaque); + +#if defined(__cplusplus) || defined(c_plusplus) +} /* extern "C" */ +#endif + +#endif /* BROTLI_DEC_DECODE_H_ */ diff --git a/illumos-x86_64/usr/include/brotli/encode.h b/illumos-x86_64/usr/include/brotli/encode.h new file mode 100644 index 00000000..dea9931e --- /dev/null +++ b/illumos-x86_64/usr/include/brotli/encode.h @@ -0,0 +1,501 @@ +/* Copyright 2013 Google Inc. All Rights Reserved. + + Distributed under MIT license. + See file LICENSE for detail or copy at https://opensource.org/licenses/MIT +*/ + +/** + * @file + * API for Brotli compression. + */ + +#ifndef BROTLI_ENC_ENCODE_H_ +#define BROTLI_ENC_ENCODE_H_ + +#include +#include +#include + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +/** Minimal value for ::BROTLI_PARAM_LGWIN parameter. */ +#define BROTLI_MIN_WINDOW_BITS 10 +/** + * Maximal value for ::BROTLI_PARAM_LGWIN parameter. + * + * @note equal to @c BROTLI_MAX_DISTANCE_BITS constant. + */ +#define BROTLI_MAX_WINDOW_BITS 24 +/** + * Maximal value for ::BROTLI_PARAM_LGWIN parameter + * in "Large Window Brotli" (32-bit). + */ +#define BROTLI_LARGE_MAX_WINDOW_BITS 30 +/** Minimal value for ::BROTLI_PARAM_LGBLOCK parameter. */ +#define BROTLI_MIN_INPUT_BLOCK_BITS 16 +/** Maximal value for ::BROTLI_PARAM_LGBLOCK parameter. */ +#define BROTLI_MAX_INPUT_BLOCK_BITS 24 +/** Minimal value for ::BROTLI_PARAM_QUALITY parameter. */ +#define BROTLI_MIN_QUALITY 0 +/** Maximal value for ::BROTLI_PARAM_QUALITY parameter. */ +#define BROTLI_MAX_QUALITY 11 + +/** Options for ::BROTLI_PARAM_MODE parameter. */ +typedef enum BrotliEncoderMode { + /** + * Default compression mode. + * + * In this mode compressor does not know anything in advance about the + * properties of the input. + */ + BROTLI_MODE_GENERIC = 0, + /** Compression mode for UTF-8 formatted text input. */ + BROTLI_MODE_TEXT = 1, + /** Compression mode used in WOFF 2.0. */ + BROTLI_MODE_FONT = 2 +} BrotliEncoderMode; + +/** Default value for ::BROTLI_PARAM_QUALITY parameter. */ +#define BROTLI_DEFAULT_QUALITY 11 +/** Default value for ::BROTLI_PARAM_LGWIN parameter. */ +#define BROTLI_DEFAULT_WINDOW 22 +/** Default value for ::BROTLI_PARAM_MODE parameter. */ +#define BROTLI_DEFAULT_MODE BROTLI_MODE_GENERIC + +/** Operations that can be performed by streaming encoder. */ +typedef enum BrotliEncoderOperation { + /** + * Process input. + * + * Encoder may postpone producing output, until it has processed enough input. + */ + BROTLI_OPERATION_PROCESS = 0, + /** + * Produce output for all processed input. + * + * Actual flush is performed when input stream is depleted and there is enough + * space in output stream. This means that client should repeat + * ::BROTLI_OPERATION_FLUSH operation until @p available_in becomes @c 0, and + * ::BrotliEncoderHasMoreOutput returns ::BROTLI_FALSE. If output is acquired + * via ::BrotliEncoderTakeOutput, then operation should be repeated after + * output buffer is drained. + * + * @warning Until flush is complete, client @b SHOULD @b NOT swap, + * reduce or extend input stream. + * + * When flush is complete, output data will be sufficient for decoder to + * reproduce all the given input. + */ + BROTLI_OPERATION_FLUSH = 1, + /** + * Finalize the stream. + * + * Actual finalization is performed when input stream is depleted and there is + * enough space in output stream. This means that client should repeat + * ::BROTLI_OPERATION_FINISH operation until @p available_in becomes @c 0, and + * ::BrotliEncoderHasMoreOutput returns ::BROTLI_FALSE. If output is acquired + * via ::BrotliEncoderTakeOutput, then operation should be repeated after + * output buffer is drained. + * + * @warning Until finalization is complete, client @b SHOULD @b NOT swap, + * reduce or extend input stream. + * + * Helper function ::BrotliEncoderIsFinished checks if stream is finalized and + * output fully dumped. + * + * Adding more input data to finalized stream is impossible. + */ + BROTLI_OPERATION_FINISH = 2, + /** + * Emit metadata block to stream. + * + * Metadata is opaque to Brotli: neither encoder, nor decoder processes this + * data or relies on it. It may be used to pass some extra information from + * encoder client to decoder client without interfering with main data stream. + * + * @note Encoder may emit empty metadata blocks internally, to pad encoded + * stream to byte boundary. + * + * @warning Until emitting metadata is complete client @b SHOULD @b NOT swap, + * reduce or extend input stream. + * + * @warning The whole content of input buffer is considered to be the content + * of metadata block. Do @b NOT @e append metadata to input stream, + * before it is depleted with other operations. + * + * Stream is soft-flushed before metadata block is emitted. Metadata block + * @b MUST be no longer than than 16MiB. + */ + BROTLI_OPERATION_EMIT_METADATA = 3 +} BrotliEncoderOperation; + +/** Options to be used with ::BrotliEncoderSetParameter. */ +typedef enum BrotliEncoderParameter { + /** + * Tune encoder for specific input. + * + * ::BrotliEncoderMode enumerates all available values. + */ + BROTLI_PARAM_MODE = 0, + /** + * The main compression speed-density lever. + * + * The higher the quality, the slower the compression. Range is + * from ::BROTLI_MIN_QUALITY to ::BROTLI_MAX_QUALITY. + */ + BROTLI_PARAM_QUALITY = 1, + /** + * Recommended sliding LZ77 window size. + * + * Encoder may reduce this value, e.g. if input is much smaller than + * window size. + * + * Window size is `(1 << value) - 16`. + * + * Range is from ::BROTLI_MIN_WINDOW_BITS to ::BROTLI_MAX_WINDOW_BITS. + */ + BROTLI_PARAM_LGWIN = 2, + /** + * Recommended input block size. + * + * Encoder may reduce this value, e.g. if input is much smaller than input + * block size. + * + * Range is from ::BROTLI_MIN_INPUT_BLOCK_BITS to + * ::BROTLI_MAX_INPUT_BLOCK_BITS. + * + * @note Bigger input block size allows better compression, but consumes more + * memory. \n The rough formula of memory used for temporary input + * storage is `3 << lgBlock`. + */ + BROTLI_PARAM_LGBLOCK = 3, + /** + * Flag that affects usage of "literal context modeling" format feature. + * + * This flag is a "decoding-speed vs compression ratio" trade-off. + */ + BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING = 4, + /** + * Estimated total input size for all ::BrotliEncoderCompressStream calls. + * + * The default value is 0, which means that the total input size is unknown. + */ + BROTLI_PARAM_SIZE_HINT = 5, + /** + * Flag that determines if "Large Window Brotli" is used. + */ + BROTLI_PARAM_LARGE_WINDOW = 6, + /** + * Recommended number of postfix bits (NPOSTFIX). + * + * Encoder may change this value. + * + * Range is from 0 to ::BROTLI_MAX_NPOSTFIX. + */ + BROTLI_PARAM_NPOSTFIX = 7, + /** + * Recommended number of direct distance codes (NDIRECT). + * + * Encoder may change this value. + * + * Range is from 0 to (15 << NPOSTFIX) in steps of (1 << NPOSTFIX). + */ + BROTLI_PARAM_NDIRECT = 8, + /** + * Number of bytes of input stream already processed by a different instance. + * + * @note It is important to configure all the encoder instances with same + * parameters (except this one) in order to allow all the encoded parts + * obey the same restrictions implied by header. + * + * If offset is not 0, then stream header is omitted. + * In any case output start is byte aligned, so for proper streams stitching + * "predecessor" stream must be flushed. + * + * Range is not artificially limited, but all the values greater or equal to + * maximal window size have the same effect. Values greater than 2**30 are not + * allowed. + */ + BROTLI_PARAM_STREAM_OFFSET = 9 +} BrotliEncoderParameter; + +/** + * Opaque structure that holds encoder state. + * + * Allocated and initialized with ::BrotliEncoderCreateInstance. + * Cleaned up and deallocated with ::BrotliEncoderDestroyInstance. + */ +typedef struct BrotliEncoderStateStruct BrotliEncoderState; + +/** + * Sets the specified parameter to the given encoder instance. + * + * @param state encoder instance + * @param param parameter to set + * @param value new parameter value + * @returns ::BROTLI_FALSE if parameter is unrecognized, or value is invalid + * @returns ::BROTLI_FALSE if value of parameter can not be changed at current + * encoder state (e.g. when encoding is started, window size might be + * already encoded and therefore it is impossible to change it) + * @returns ::BROTLI_TRUE if value is accepted + * @warning invalid values might be accepted in case they would not break + * encoding process. + */ +BROTLI_ENC_API BROTLI_BOOL BrotliEncoderSetParameter( + BrotliEncoderState* state, BrotliEncoderParameter param, uint32_t value); + +/** + * Creates an instance of ::BrotliEncoderState and initializes it. + * + * @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the + * case they are both zero, default memory allocators are used. @p opaque is + * passed to @p alloc_func and @p free_func when they are called. @p free_func + * has to return without doing anything when asked to free a NULL pointer. + * + * @param alloc_func custom memory allocation function + * @param free_func custom memory free function + * @param opaque custom memory manager handle + * @returns @c 0 if instance can not be allocated or initialized + * @returns pointer to initialized ::BrotliEncoderState otherwise + */ +BROTLI_ENC_API BrotliEncoderState* BrotliEncoderCreateInstance( + brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque); + +/** + * Deinitializes and frees ::BrotliEncoderState instance. + * + * @param state decoder instance to be cleaned up and deallocated + */ +BROTLI_ENC_API void BrotliEncoderDestroyInstance(BrotliEncoderState* state); + +/* Opaque type for pointer to different possible internal structures containing + dictionary prepared for the encoder */ +typedef struct BrotliEncoderPreparedDictionaryStruct + BrotliEncoderPreparedDictionary; + +/** + * Prepares a shared dictionary from the given file format for the encoder. + * + * @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the + * case they are both zero, default memory allocators are used. @p opaque is + * passed to @p alloc_func and @p free_func when they are called. @p free_func + * has to return without doing anything when asked to free a NULL pointer. + * + * @param type type of dictionary stored in data + * @param data_size size of @p data buffer + * @param data pointer to the dictionary data + * @param quality the maximum Brotli quality to prepare the dictionary for, + * use BROTLI_MAX_QUALITY by default + * @param alloc_func custom memory allocation function + * @param free_func custom memory free function + * @param opaque custom memory manager handle + */ +BROTLI_ENC_API BrotliEncoderPreparedDictionary* +BrotliEncoderPrepareDictionary(BrotliSharedDictionaryType type, + size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)], + int quality, + brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque); + +BROTLI_ENC_API void BrotliEncoderDestroyPreparedDictionary( + BrotliEncoderPreparedDictionary* dictionary); + +/** + * Attaches a prepared dictionary of any type to the encoder. Can be used + * multiple times to attach multiple dictionaries. The dictionary type was + * determined by BrotliEncoderPrepareDictionary. Multiple raw prefix + * dictionaries and/or max 1 serialized dictionary with custom words can be + * attached. + * + * @returns ::BROTLI_FALSE in case of error + * @returns ::BROTLI_TRUE otherwise + */ +BROTLI_ENC_API BROTLI_BOOL BrotliEncoderAttachPreparedDictionary( + BrotliEncoderState* state, + const BrotliEncoderPreparedDictionary* dictionary); + +/** + * Calculates the output size bound for the given @p input_size. + * + * @warning Result is only valid if quality is at least @c 2 and, in + * case ::BrotliEncoderCompressStream was used, no flushes + * (::BROTLI_OPERATION_FLUSH) were performed. + * + * @param input_size size of projected input + * @returns @c 0 if result does not fit @c size_t + */ +BROTLI_ENC_API size_t BrotliEncoderMaxCompressedSize(size_t input_size); + +/** + * Performs one-shot memory-to-memory compression. + * + * Compresses the data in @p input_buffer into @p encoded_buffer, and sets + * @p *encoded_size to the compressed length. + * + * @note If ::BrotliEncoderMaxCompressedSize(@p input_size) returns non-zero + * value, then output is guaranteed to be no longer than that. + * + * @note If @p lgwin is greater than ::BROTLI_MAX_WINDOW_BITS then resulting + * stream might be incompatible with RFC 7932; to decode such streams, + * decoder should be configured with + * ::BROTLI_DECODER_PARAM_LARGE_WINDOW = @c 1 + * + * @param quality quality parameter value, e.g. ::BROTLI_DEFAULT_QUALITY + * @param lgwin lgwin parameter value, e.g. ::BROTLI_DEFAULT_WINDOW + * @param mode mode parameter value, e.g. ::BROTLI_DEFAULT_MODE + * @param input_size size of @p input_buffer + * @param input_buffer input data buffer with at least @p input_size + * addressable bytes + * @param[in, out] encoded_size @b in: size of @p encoded_buffer; \n + * @b out: length of compressed data written to + * @p encoded_buffer, or @c 0 if compression fails + * @param encoded_buffer compressed data destination buffer + * @returns ::BROTLI_FALSE in case of compression error + * @returns ::BROTLI_FALSE if output buffer is too small + * @returns ::BROTLI_TRUE otherwise + */ +BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompress( + int quality, int lgwin, BrotliEncoderMode mode, size_t input_size, + const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)], + size_t* encoded_size, + uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)]); + +/** + * Compresses input stream to output stream. + * + * The values @p *available_in and @p *available_out must specify the number of + * bytes addressable at @p *next_in and @p *next_out respectively. + * When @p *available_out is @c 0, @p next_out is allowed to be @c NULL. + * + * After each call, @p *available_in will be decremented by the amount of input + * bytes consumed, and the @p *next_in pointer will be incremented by that + * amount. Similarly, @p *available_out will be decremented by the amount of + * output bytes written, and the @p *next_out pointer will be incremented by + * that amount. + * + * @p total_out, if it is not a null-pointer, will be set to the number + * of bytes compressed since the last @p state initialization. + * + * + * + * Internally workflow consists of 3 tasks: + * -# (optionally) copy input data to internal buffer + * -# actually compress data and (optionally) store it to internal buffer + * -# (optionally) copy compressed bytes from internal buffer to output stream + * + * Whenever all 3 tasks can't move forward anymore, or error occurs, this + * method returns the control flow to caller. + * + * @p op is used to perform flush, finish the stream, or inject metadata block. + * See ::BrotliEncoderOperation for more information. + * + * Flushing the stream means forcing encoding of all input passed to encoder and + * completing the current output block, so it could be fully decoded by stream + * decoder. To perform flush set @p op to ::BROTLI_OPERATION_FLUSH. + * Under some circumstances (e.g. lack of output stream capacity) this operation + * would require several calls to ::BrotliEncoderCompressStream. The method must + * be called again until both input stream is depleted and encoder has no more + * output (see ::BrotliEncoderHasMoreOutput) after the method is called. + * + * Finishing the stream means encoding of all input passed to encoder and + * adding specific "final" marks, so stream decoder could determine that stream + * is complete. To perform finish set @p op to ::BROTLI_OPERATION_FINISH. + * Under some circumstances (e.g. lack of output stream capacity) this operation + * would require several calls to ::BrotliEncoderCompressStream. The method must + * be called again until both input stream is depleted and encoder has no more + * output (see ::BrotliEncoderHasMoreOutput) after the method is called. + * + * @warning When flushing and finishing, @p op should not change until operation + * is complete; input stream should not be swapped, reduced or + * extended as well. + * + * @param state encoder instance + * @param op requested operation + * @param[in, out] available_in @b in: amount of available input; \n + * @b out: amount of unused input + * @param[in, out] next_in pointer to the next input byte + * @param[in, out] available_out @b in: length of output buffer; \n + * @b out: remaining size of output buffer + * @param[in, out] next_out compressed output buffer cursor; + * can be @c NULL if @p available_out is @c 0 + * @param[out] total_out number of bytes produced so far; can be @c NULL + * @returns ::BROTLI_FALSE if there was an error + * @returns ::BROTLI_TRUE otherwise + */ +BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompressStream( + BrotliEncoderState* state, BrotliEncoderOperation op, size_t* available_in, + const uint8_t** next_in, size_t* available_out, uint8_t** next_out, + size_t* total_out); + +/** + * Checks if encoder instance reached the final state. + * + * @param state encoder instance + * @returns ::BROTLI_TRUE if encoder is in a state where it reached the end of + * the input and produced all of the output + * @returns ::BROTLI_FALSE otherwise + */ +BROTLI_ENC_API BROTLI_BOOL BrotliEncoderIsFinished(BrotliEncoderState* state); + +/** + * Checks if encoder has more output. + * + * @param state encoder instance + * @returns ::BROTLI_TRUE, if encoder has some unconsumed output + * @returns ::BROTLI_FALSE otherwise + */ +BROTLI_ENC_API BROTLI_BOOL BrotliEncoderHasMoreOutput( + BrotliEncoderState* state); + +/** + * Acquires pointer to internal output buffer. + * + * This method is used to make language bindings easier and more efficient: + * -# push data to ::BrotliEncoderCompressStream, + * until ::BrotliEncoderHasMoreOutput returns BROTLI_TRUE + * -# use ::BrotliEncoderTakeOutput to peek bytes and copy to language-specific + * entity + * + * Also this could be useful if there is an output stream that is able to + * consume all the provided data (e.g. when data is saved to file system). + * + * @attention After every call to ::BrotliEncoderTakeOutput @p *size bytes of + * output are considered consumed for all consecutive calls to the + * instance methods; returned pointer becomes invalidated as well. + * + * @note Encoder output is not guaranteed to be contiguous. This means that + * after the size-unrestricted call to ::BrotliEncoderTakeOutput, + * immediate next call to ::BrotliEncoderTakeOutput may return more data. + * + * @param state encoder instance + * @param[in, out] size @b in: number of bytes caller is ready to take, @c 0 if + * any amount could be handled; \n + * @b out: amount of data pointed by returned pointer and + * considered consumed; \n + * out value is never greater than in value, unless it is @c 0 + * @returns pointer to output data + */ +BROTLI_ENC_API const uint8_t* BrotliEncoderTakeOutput( + BrotliEncoderState* state, size_t* size); + +/* Returns the estimated peak memory usage (in bytes) of the BrotliCompress() + function, not counting the memory needed for the input and output. */ +BROTLI_ENC_EXTRA_API size_t BrotliEncoderEstimatePeakMemoryUsage( + int quality, int lgwin, size_t input_size); +/* Returns 0 if dictionary is not valid; otherwise returns allocation size. */ +BROTLI_ENC_EXTRA_API size_t BrotliEncoderGetPreparedDictionarySize( + const BrotliEncoderPreparedDictionary* dictionary); + +/** + * Gets an encoder library version. + * + * Look at BROTLI_MAKE_HEX_VERSION for more information. + */ +BROTLI_ENC_API uint32_t BrotliEncoderVersion(void); + +#if defined(__cplusplus) || defined(c_plusplus) +} /* extern "C" */ +#endif + +#endif /* BROTLI_ENC_ENCODE_H_ */ diff --git a/illumos-x86_64/usr/include/brotli/port.h b/illumos-x86_64/usr/include/brotli/port.h new file mode 100644 index 00000000..0d500190 --- /dev/null +++ b/illumos-x86_64/usr/include/brotli/port.h @@ -0,0 +1,305 @@ +/* Copyright 2016 Google Inc. All Rights Reserved. + + Distributed under MIT license. + See file LICENSE for detail or copy at https://opensource.org/licenses/MIT +*/ + +/* Macros for compiler / platform specific API declarations. */ + +#ifndef BROTLI_COMMON_PORT_H_ +#define BROTLI_COMMON_PORT_H_ + +/* The following macros were borrowed from https://github.com/nemequ/hedley + * with permission of original author - Evan Nemerson */ + +/* >>> >>> >>> hedley macros */ + +#define BROTLI_MAKE_VERSION(major, minor, revision) \ + (((major) * 1000000) + ((minor) * 1000) + (revision)) + +#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) +#define BROTLI_GNUC_VERSION \ + BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#elif defined(__GNUC__) +#define BROTLI_GNUC_VERSION BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, 0) +#endif + +#if defined(BROTLI_GNUC_VERSION) +#define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) \ + (BROTLI_GNUC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) +#define BROTLI_MSVC_VERSION \ + BROTLI_MAKE_VERSION((_MSC_FULL_VER / 10000000), \ + (_MSC_FULL_VER % 10000000) / 100000, \ + (_MSC_FULL_VER % 100000) / 100) +#elif defined(_MSC_FULL_VER) +#define BROTLI_MSVC_VERSION \ + BROTLI_MAKE_VERSION((_MSC_FULL_VER / 1000000), \ + (_MSC_FULL_VER % 1000000) / 10000, \ + (_MSC_FULL_VER % 10000) / 10) +#elif defined(_MSC_VER) +#define BROTLI_MSVC_VERSION \ + BROTLI_MAKE_VERSION(_MSC_VER / 100, _MSC_VER % 100, 0) +#endif + +#if !defined(_MSC_VER) +#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) (0) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) +#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \ + (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) +#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \ + (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) +#else +#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \ + (_MSC_VER >= ((major * 100) + (minor))) +#endif + +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) +#define BROTLI_INTEL_VERSION \ + BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, \ + __INTEL_COMPILER % 100, \ + __INTEL_COMPILER_UPDATE) +#elif defined(__INTEL_COMPILER) +#define BROTLI_INTEL_VERSION \ + BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif + +#if defined(BROTLI_INTEL_VERSION) +#define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) \ + (BROTLI_INTEL_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(__PGI) && \ + defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) +#define BROTLI_PGI_VERSION \ + BROTLI_MAKE_VERSION(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) +#endif + +#if defined(BROTLI_PGI_VERSION) +#define BROTLI_PGI_VERSION_CHECK(major, minor, patch) \ + (BROTLI_PGI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_PGI_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) +#define BROTLI_SUNPRO_VERSION \ + BROTLI_MAKE_VERSION( \ + (((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), \ + (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), \ + (__SUNPRO_C & 0xf) * 10) +#elif defined(__SUNPRO_C) +#define BROTLI_SUNPRO_VERSION \ + BROTLI_MAKE_VERSION((__SUNPRO_C >> 8) & 0xf, \ + (__SUNPRO_C >> 4) & 0xf, \ + (__SUNPRO_C) & 0xf) +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) +#define BROTLI_SUNPRO_VERSION \ + BROTLI_MAKE_VERSION( \ + (((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), \ + (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), \ + (__SUNPRO_CC & 0xf) * 10) +#elif defined(__SUNPRO_CC) +#define BROTLI_SUNPRO_VERSION \ + BROTLI_MAKE_VERSION((__SUNPRO_CC >> 8) & 0xf, \ + (__SUNPRO_CC >> 4) & 0xf, \ + (__SUNPRO_CC) & 0xf) +#endif + +#if defined(BROTLI_SUNPRO_VERSION) +#define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) \ + (BROTLI_SUNPRO_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) +#define BROTLI_ARM_VERSION \ + BROTLI_MAKE_VERSION((__ARMCOMPILER_VERSION / 1000000), \ + (__ARMCOMPILER_VERSION % 1000000) / 10000, \ + (__ARMCOMPILER_VERSION % 10000) / 100) +#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) +#define BROTLI_ARM_VERSION \ + BROTLI_MAKE_VERSION((__ARMCC_VERSION / 1000000), \ + (__ARMCC_VERSION % 1000000) / 10000, \ + (__ARMCC_VERSION % 10000) / 100) +#endif + +#if defined(BROTLI_ARM_VERSION) +#define BROTLI_ARM_VERSION_CHECK(major, minor, patch) \ + (BROTLI_ARM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_ARM_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(__ibmxl__) +#define BROTLI_IBM_VERSION \ + BROTLI_MAKE_VERSION(__ibmxl_version__, \ + __ibmxl_release__, \ + __ibmxl_modification__) +#elif defined(__xlC__) && defined(__xlC_ver__) +#define BROTLI_IBM_VERSION \ + BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) +#elif defined(__xlC__) +#define BROTLI_IBM_VERSION BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, 0) +#endif + +#if defined(BROTLI_IBM_VERSION) +#define BROTLI_IBM_VERSION_CHECK(major, minor, patch) \ + (BROTLI_IBM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_IBM_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(__TI_COMPILER_VERSION__) +#define BROTLI_TI_VERSION \ + BROTLI_MAKE_VERSION((__TI_COMPILER_VERSION__ / 1000000), \ + (__TI_COMPILER_VERSION__ % 1000000) / 1000, \ + (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(BROTLI_TI_VERSION) +#define BROTLI_TI_VERSION_CHECK(major, minor, patch) \ + (BROTLI_TI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_TI_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(__IAR_SYSTEMS_ICC__) +#if __VER__ > 1000 +#define BROTLI_IAR_VERSION \ + BROTLI_MAKE_VERSION((__VER__ / 1000000), \ + (__VER__ / 1000) % 1000, \ + (__VER__ % 1000)) +#else +#define BROTLI_IAR_VERSION BROTLI_MAKE_VERSION(VER / 100, __VER__ % 100, 0) +#endif +#endif + +#if defined(BROTLI_IAR_VERSION) +#define BROTLI_IAR_VERSION_CHECK(major, minor, patch) \ + (BROTLI_IAR_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_IAR_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(__TINYC__) +#define BROTLI_TINYC_VERSION \ + BROTLI_MAKE_VERSION(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) +#endif + +#if defined(BROTLI_TINYC_VERSION) +#define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) \ + (BROTLI_TINYC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) +#else +#define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) (0) +#endif + +#if defined(__has_attribute) +#define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \ + __has_attribute(attribute) +#else +#define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \ + BROTLI_GNUC_VERSION_CHECK(major, minor, patch) +#endif + +#if defined(__has_builtin) +#define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \ + __has_builtin(builtin) +#else +#define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \ + BROTLI_GNUC_VERSION_CHECK(major, minor, patch) +#endif + +#if defined(__has_feature) +#define BROTLI_HAS_FEATURE(feature) __has_feature(feature) +#else +#define BROTLI_HAS_FEATURE(feature) (0) +#endif + +#if defined(_WIN32) || defined(__CYGWIN__) +#define BROTLI_PUBLIC +#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) || \ + BROTLI_TI_VERSION_CHECK(8, 0, 0) || \ + BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \ + BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \ + BROTLI_IBM_VERSION_CHECK(13, 1, 0) || \ + BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \ + (BROTLI_TI_VERSION_CHECK(7, 3, 0) && \ + defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__)) +#define BROTLI_PUBLIC __attribute__ ((visibility ("default"))) +#else +#define BROTLI_PUBLIC +#endif + +/* BROTLI_INTERNAL could be defined to override visibility, e.g. for tests. */ +#if !defined(BROTLI_INTERNAL) +#if defined(_WIN32) || defined(__CYGWIN__) +#define BROTLI_INTERNAL +#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) || \ + BROTLI_TI_VERSION_CHECK(8, 0, 0) || \ + BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \ + BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \ + BROTLI_IBM_VERSION_CHECK(13, 1, 0) || \ + BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \ + (BROTLI_TI_VERSION_CHECK(7, 3, 0) && \ + defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__)) +#define BROTLI_INTERNAL __attribute__ ((visibility ("hidden"))) +#else +#define BROTLI_INTERNAL +#endif +#endif + +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \ + !defined(__PGI) && !defined(__PGIC__) && !defined(__TINYC__) && \ + !defined(__clang__) +#define BROTLI_ARRAY_PARAM(name) (name) +#else +#define BROTLI_ARRAY_PARAM(name) +#endif + +/* <<< <<< <<< end of hedley macros. */ + +#if defined(BROTLI_SHARED_COMPILATION) +#if defined(_WIN32) +#if defined(BROTLICOMMON_SHARED_COMPILATION) +#define BROTLI_COMMON_API __declspec(dllexport) +#else +#define BROTLI_COMMON_API __declspec(dllimport) +#endif /* BROTLICOMMON_SHARED_COMPILATION */ +#if defined(BROTLIDEC_SHARED_COMPILATION) +#define BROTLI_DEC_API __declspec(dllexport) +#else +#define BROTLI_DEC_API __declspec(dllimport) +#endif /* BROTLIDEC_SHARED_COMPILATION */ +#if defined(BROTLIENC_SHARED_COMPILATION) +#define BROTLI_ENC_API __declspec(dllexport) +#else +#define BROTLI_ENC_API __declspec(dllimport) +#endif /* BROTLIENC_SHARED_COMPILATION */ +#else /* _WIN32 */ +#define BROTLI_COMMON_API BROTLI_PUBLIC +#define BROTLI_DEC_API BROTLI_PUBLIC +#define BROTLI_ENC_API BROTLI_PUBLIC +#endif /* _WIN32 */ +#else /* BROTLI_SHARED_COMPILATION */ +#define BROTLI_COMMON_API +#define BROTLI_DEC_API +#define BROTLI_ENC_API +#endif + +#if defined(BROTLI_BUILD_ENC_EXTRA_API) +#define BROTLI_ENC_EXTRA_API BROTLI_ENC_API +#else +#define BROTLI_ENC_EXTRA_API BROTLI_INTERNAL +#endif + +#endif /* BROTLI_COMMON_PORT_H_ */ diff --git a/illumos-x86_64/usr/include/brotli/shared_dictionary.h b/illumos-x86_64/usr/include/brotli/shared_dictionary.h new file mode 100644 index 00000000..2970c2dc --- /dev/null +++ b/illumos-x86_64/usr/include/brotli/shared_dictionary.h @@ -0,0 +1,100 @@ +/* Copyright 2017 Google Inc. All Rights Reserved. + + Distributed under MIT license. + See file LICENSE for detail or copy at https://opensource.org/licenses/MIT +*/ + +/* (Opaque) Shared Dictionary definition and utilities. */ + +#ifndef BROTLI_COMMON_SHARED_DICTIONARY_H_ +#define BROTLI_COMMON_SHARED_DICTIONARY_H_ + +#include +#include + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +#define SHARED_BROTLI_MIN_DICTIONARY_WORD_LENGTH 4 +#define SHARED_BROTLI_MAX_DICTIONARY_WORD_LENGTH 31 +#define SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS 64 +#define SHARED_BROTLI_MAX_COMPOUND_DICTS 15 + +/** + * Opaque structure that holds shared dictionary data. + * + * Allocated and initialized with ::BrotliSharedDictionaryCreateInstance. + * Cleaned up and deallocated with ::BrotliSharedDictionaryDestroyInstance. + */ +typedef struct BrotliSharedDictionaryStruct BrotliSharedDictionary; + +/** + * Input data type for ::BrotliSharedDictionaryAttach. + */ +typedef enum BrotliSharedDictionaryType { + /** Raw LZ77 prefix dictionary. */ + BROTLI_SHARED_DICTIONARY_RAW = 0, + /** Serialized shared dictionary. + * + * DO NOT USE: methods accepting this value will fail. + */ + BROTLI_SHARED_DICTIONARY_SERIALIZED = 1 +} BrotliSharedDictionaryType; + +/** + * Creates an instance of ::BrotliSharedDictionary. + * + * Fresh instance has default word dictionary and transforms + * and no LZ77 prefix dictionary. + * + * @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the + * case they are both zero, default memory allocators are used. @p opaque is + * passed to @p alloc_func and @p free_func when they are called. @p free_func + * has to return without doing anything when asked to free a NULL pointer. + * + * @param alloc_func custom memory allocation function + * @param free_func custom memory free function + * @param opaque custom memory manager handle + * @returns @c 0 if instance can not be allocated or initialized + * @returns pointer to initialized ::BrotliSharedDictionary otherwise + */ +BROTLI_COMMON_API BrotliSharedDictionary* BrotliSharedDictionaryCreateInstance( + brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque); + +/** + * Deinitializes and frees ::BrotliSharedDictionary instance. + * + * @param dict shared dictionary instance to be cleaned up and deallocated + */ +BROTLI_COMMON_API void BrotliSharedDictionaryDestroyInstance( + BrotliSharedDictionary* dict); + +/** + * Attaches dictionary to a given instance of ::BrotliSharedDictionary. + * + * Dictionary to be attached is represented in a serialized format as a region + * of memory. + * + * Provided data it partially referenced by a resulting (compound) dictionary, + * and should be kept untouched, while at least one compound dictionary uses it. + * This way memory overhead is kept minimal by the cost of additional resource + * management. + * + * @param dict dictionary to extend + * @param type type of dictionary to attach + * @param data_size size of @p data + * @param data serialized dictionary of type @p type, with at least @p data_size + * addressable bytes + * @returns ::BROTLI_TRUE if provided dictionary is successfully attached + * @returns ::BROTLI_FALSE otherwise + */ +BROTLI_COMMON_API BROTLI_BOOL BrotliSharedDictionaryAttach( + BrotliSharedDictionary* dict, BrotliSharedDictionaryType type, + size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)]); + +#if defined(__cplusplus) || defined(c_plusplus) +} /* extern "C" */ +#endif + +#endif /* BROTLI_COMMON_SHARED_DICTIONARY_H_ */ diff --git a/illumos-x86_64/usr/include/brotli/types.h b/illumos-x86_64/usr/include/brotli/types.h new file mode 100644 index 00000000..eff1a3cd --- /dev/null +++ b/illumos-x86_64/usr/include/brotli/types.h @@ -0,0 +1,83 @@ +/* Copyright 2013 Google Inc. All Rights Reserved. + + Distributed under MIT license. + See file LICENSE for detail or copy at https://opensource.org/licenses/MIT +*/ + +/** + * @file + * Common types used in decoder and encoder API. + */ + +#ifndef BROTLI_COMMON_TYPES_H_ +#define BROTLI_COMMON_TYPES_H_ + +#include /* for size_t */ + +#if defined(_MSC_VER) && (_MSC_VER < 1600) +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +typedef __int64 int64_t; +#else +#include +#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */ + +/** + * A portable @c bool replacement. + * + * ::BROTLI_BOOL is a "documentation" type: actually it is @c int, but in API it + * denotes a type, whose only values are ::BROTLI_TRUE and ::BROTLI_FALSE. + * + * ::BROTLI_BOOL values passed to Brotli should either be ::BROTLI_TRUE or + * ::BROTLI_FALSE, or be a result of ::TO_BROTLI_BOOL macros. + * + * ::BROTLI_BOOL values returned by Brotli should not be tested for equality + * with @c true, @c false, ::BROTLI_TRUE, ::BROTLI_FALSE, but rather should be + * evaluated, for example: @code{.cpp} + * if (SomeBrotliFunction(encoder, BROTLI_TRUE) && + * !OtherBrotliFunction(decoder, BROTLI_FALSE)) { + * bool x = !!YetAnotherBrotliFunction(encoder, TO_BROLTI_BOOL(2 * 2 == 4)); + * DoSomething(x); + * } + * @endcode + */ +#define BROTLI_BOOL int +/** Portable @c true replacement. */ +#define BROTLI_TRUE 1 +/** Portable @c false replacement. */ +#define BROTLI_FALSE 0 +/** @c bool to ::BROTLI_BOOL conversion macros. */ +#define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE) + +#define BROTLI_MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low) + +#define BROTLI_UINT32_MAX (~((uint32_t)0)) +#define BROTLI_SIZE_MAX (~((size_t)0)) + +/** + * Allocating function pointer type. + * + * @param opaque custom memory manager handle provided by client + * @param size requested memory region size; can not be @c 0 + * @returns @c 0 in the case of failure + * @returns a valid pointer to a memory region of at least @p size bytes + * long otherwise + */ +typedef void* (*brotli_alloc_func)(void* opaque, size_t size); + +/** + * Deallocating function pointer type. + * + * This function @b SHOULD do nothing if @p address is @c 0. + * + * @param opaque custom memory manager handle provided by client + * @param address memory region pointer returned by ::brotli_alloc_func, or @c 0 + */ +typedef void (*brotli_free_func)(void* opaque, void* address); + +#endif /* BROTLI_COMMON_TYPES_H_ */ diff --git a/illumos-x86_64/usr/include/bsm/adt.h b/illumos-x86_64/usr/include/bsm/adt.h new file mode 100644 index 00000000..5aed66d5 --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/adt.h @@ -0,0 +1,130 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * adt.h + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * This is a contract private interface and is subject to change + */ + +#ifndef _ADT_H +#define _ADT_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define ADT_STRING_MAX 511 /* max non-null characters */ +#define ADT_NO_ATTRIB (uid_t)-1 /* unattributed user */ +#define ADT_NO_CHANGE (uid_t)-2 /* no update for this parameter */ +#define ADT_NO_AUDIT (uid_t)-3 /* unaudited user */ + +/* + * terminal id types + */ +#define ADT_IPv4 1 +#define ADT_IPv6 2 + +/* + * for adt_set_user(): ADT_NEW if creating a session for a newly + * authenticated user -- login -- and ADT_UPDATE if an authenticated + * user is changing uid/gid -- e.g., su. ADT_USER changes only the + * ruid / euid / rgid / egid values and is appropriate for login-like + * operations where PAM has already set the audit context in the cred. + * ADT_SETTID is for the special case where it is necessary to store + * the terminal id in the credential before forking to the login or + * login-like process. + */ +enum adt_user_context {ADT_NEW, ADT_UPDATE, ADT_USER, ADT_SETTID}; + +typedef ulong_t adt_session_flags_t; +typedef struct adt_session_data adt_session_data_t; +typedef struct adt_export_data adt_export_data_t; +typedef union adt_event_data adt_event_data_t; +typedef struct adt_termid adt_termid_t; +typedef struct translation adt_translation_t; + +/* + * flag defs for the flags argument of adt_start_session() + */ + +#define ADT_BUFFER_RECORDS 0x2 /* server buffering */ +#define ADT_USE_PROC_DATA 0x1 /* copy audit char's from proc */ + /* | all of above = ADT_FLAGS_ALL */ +#define ADT_FLAGS_ALL ADT_BUFFER_RECORDS | \ + ADT_USE_PROC_DATA + +/* + * Functions + */ + +extern int adt_start_session(adt_session_data_t **, + const adt_export_data_t *, + adt_session_flags_t); +extern int adt_end_session(adt_session_data_t *); +extern int adt_dup_session(const adt_session_data_t *, + adt_session_data_t **); + +extern int adt_set_proc(const adt_session_data_t *); +extern int adt_set_user(const adt_session_data_t *, uid_t, gid_t, + uid_t, gid_t, const adt_termid_t *, + enum adt_user_context); +extern int adt_set_from_ucred(const adt_session_data_t *, + const ucred_t *, + enum adt_user_context); + +extern size_t adt_get_session_id(const adt_session_data_t *, char **); + +extern size_t adt_export_session_data(const adt_session_data_t *, + adt_export_data_t **); + +extern adt_event_data_t + *adt_alloc_event(const adt_session_data_t *, au_event_t); + +extern int adt_put_event(const adt_event_data_t *, int, int); +extern void adt_free_event(adt_event_data_t *); + +extern int adt_load_termid(int, adt_termid_t **); +extern int adt_load_hostname(const char *, adt_termid_t **); +extern int adt_load_ttyname(const char *, adt_termid_t **); + +extern boolean_t adt_audit_enabled(void); +extern boolean_t adt_audit_state(int); + +/* + * Special typedefs for translations. + */ + +typedef int fd_t; /* file descriptor */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ADT_H */ diff --git a/illumos-x86_64/usr/include/bsm/adt_event.h b/illumos-x86_64/usr/include/bsm/adt_event.h new file mode 100644 index 00000000..50617b73 --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/adt_event.h @@ -0,0 +1,1399 @@ +/* + * DO NOT EDIT. This file is auto generated by the Solaris Audit + * system from adt.xml. + * + * See http://opensolaris.org/os/project/audit/ + */ + +#ifndef _ADT_EVENT_H +#define _ADT_EVENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * adt_put_event() status values. Positive values are for kernel-generated + * failure, -1 for user-space. For ADT_SUCCESS, the adt_put_event() return_val + * is not used; the convention is to set it to ADT_SUCCESS. + */ +#define ADT_SUCCESS 0 +#define ADT_FAILURE -1 + +#define ADT_FAIL_PAM 2000 +#define ADT_FAIL_VALUE 1000 +enum adt_fail_value { + ADT_FAIL_VALUE_PW_ATTR = 1000, /* Attribute update */ + ADT_FAIL_VALUE_PW, /* Password update */ + ADT_FAIL_VALUE_USERNAME, /* bad username */ + ADT_FAIL_VALUE_AUTH, /* authorization failed */ + ADT_FAIL_VALUE_UID, /* bad uid */ + ADT_FAIL_VALUE_UNKNOWN, /* unknown failure */ + ADT_FAIL_VALUE_EXPIRED, /* password expired */ + ADT_FAIL_VALUE_ACCOUNT_LOCKED, /* Account is locked */ + ADT_FAIL_VALUE_BAD_DIALUP, /* Bad dial up */ + ADT_FAIL_VALUE_BAD_ID, /* Invalid ID */ + ADT_FAIL_VALUE_BAD_PW, /* Invalid password */ + ADT_FAIL_VALUE_CONSOLE, /* Not on console */ + ADT_FAIL_VALUE_MAX_TRIES, /* Too many failed attempts */ + ADT_FAIL_VALUE_PROTOCOL_FAILURE, /* Protocol failure */ + ADT_FAIL_VALUE_EXCLUDED_USER, /* Excluded user */ + ADT_FAIL_VALUE_ANON_USER, /* No anonymous */ + ADT_FAIL_VALUE_BAD_CMD, /* Invalid command */ + ADT_FAIL_VALUE_BAD_TTY, /* Standard input not a tty line */ + ADT_FAIL_VALUE_PROGRAM, /* Program failure */ + ADT_FAIL_VALUE_CHDIR_FAILED, /* chdir to home directory */ + ADT_FAIL_VALUE_INPUT_OVERFLOW, /* Input line too long. */ + ADT_FAIL_VALUE_DEVICE_PERM, /* login device override */ + ADT_FAIL_VALUE_AUTH_BYPASS, /* authorization bypass */ + ADT_FAIL_VALUE_LOGIN_DISABLED /* login disabled */ +}; +/* Deprecated message list */ +enum adt_login_text { + ADT_LOGIN_NO_MSG, /* (no token will be generated) */ + ADT_LOGIN_ACCOUNT_LOCKED, /* Account is locked */ + ADT_LOGIN_BAD_DIALUP, /* Bad dial up */ + ADT_LOGIN_BAD_ID, /* Invalid ID */ + ADT_LOGIN_BAD_PW, /* Invalid password */ + ADT_LOGIN_CONSOLE, /* Not on console */ + ADT_LOGIN_MAX_TRIES, /* Too many failed attempts */ + ADT_LOGIN_PROTOCOL_FAILURE, /* Protocol failure */ + ADT_LOGIN_EXCLUDED_USER, /* Excluded user */ + ADT_LOGIN_ANON_USER /* No anonymous */ +}; +#define ADT_TPM_E 4000 +enum adt_tpm_e { + ADT_TPM_E_AUTHFAIL = 4000, /* Authentication failed */ + ADT_TPM_E_BADINDEX, /* The index to a PCR, DIR or other ... */ + ADT_TPM_E_BAD_PARAMETER, /* One or more parameter is bad */ + ADT_TPM_E_AUDITFAILURE, /* auditing of the operation failed. */ + ADT_TPM_E_CLEAR_DISABLED, /* clear operations now physical ... */ + ADT_TPM_E_DEACTIVATED, /* The TPM is deactivated */ + ADT_TPM_E_DISABLED, /* The TPM is disabled */ + ADT_TPM_E_DISABLED_CMD, /* The target command has been disabled */ + ADT_TPM_E_FAIL, /* The operation failed */ + ADT_TPM_E_BAD_ORDINAL, /* The ordinal was unknown or inconsistent */ + ADT_TPM_E_INSTALL_DISABLED, /* The ability to install an ... */ + ADT_TPM_E_INVALID_KEYHANDLE, /* The key handle can not be ... */ + ADT_TPM_E_KEYNOTFOUND, /* The key handle points to an invalid key */ + ADT_TPM_E_INAPPROPRIATE_ENC, /* Unacceptable encryption scheme */ + ADT_TPM_E_MIGRATEFAIL, /* Migration authorization failed */ + ADT_TPM_E_INVALID_PCR_INFO, /* PCR information could not be ... */ + ADT_TPM_E_NOSPACE, /* No room to load key. */ + ADT_TPM_E_NOSRK, /* There is no SRK set */ + ADT_TPM_E_NOTSEALED_BLOB, /* An encrypted blob is invalid ... */ + ADT_TPM_E_OWNER_SET, /* There is already an Owner */ + ADT_TPM_E_RESOURCES, /* The TPM has insufficient internal ... */ + ADT_TPM_E_SHORTRANDOM, /* A random string was too short */ + ADT_TPM_E_SIZE, /* The TPM does not have the space to perform the ... */ + ADT_TPM_E_WRONGPCRVAL, /* The named PCR value does not match the ... */ + ADT_TPM_E_BAD_PARAM_SIZE, /* The paramSize argument has the ... */ + ADT_TPM_E_SHA_THREAD, /* There is no existing SHA-1 thread. */ + ADT_TPM_E_SHA_ERROR, /* SHA-1 thread encountered an error. */ + ADT_TPM_E_FAILEDSELFTEST, /* Self-test has failed and the ... */ + ADT_TPM_E_AUTH2FAIL, /* The auth for the second key failed ... */ + ADT_TPM_E_BADTAG, /* The tag value sent to for a command is ... */ + ADT_TPM_E_IOERROR, /* An IO error occurred transmitting ... */ + ADT_TPM_E_ENCRYPT_ERROR, /* The encryption process had a ... */ + ADT_TPM_E_DECRYPT_ERROR, /* The decryption process did not ... */ + ADT_TPM_E_INVALID_AUTHHANDLE, /* An invalid handle was used. */ + ADT_TPM_E_NO_ENDORSEMENT, /* The TPM does not a EK installed */ + ADT_TPM_E_INVALID_KEYUSAGE, /* The usage of a key is not allowed */ + ADT_TPM_E_WRONG_ENTITYTYPE, /* The submitted entity type is ... */ + ADT_TPM_E_INVALID_POSTINIT, /* The command was received in ... */ + ADT_TPM_E_INAPPROPRIATE_SIG, /* Signed data cannot include ... */ + ADT_TPM_E_BAD_KEY_PROPERTY, /* The key properties are not ... */ + ADT_TPM_E_BAD_MIGRATION, /* The migration properties of ... */ + ADT_TPM_E_BAD_SCHEME, /* Incorrect signature or encryption scheme */ + ADT_TPM_E_BAD_DATASIZE, /* The size of the data parameter is bad */ + ADT_TPM_E_BAD_MODE, /* A mode parameter is bad */ + ADT_TPM_E_BAD_PRESENCE, /* physicalPresence or ... */ + ADT_TPM_E_BAD_VERSION, /* The TPM cannot perform this version of ... */ + ADT_TPM_E_NO_WRAP_TRANSPORT, /* The TPM does not allow for ... */ + ADT_TPM_E_AUDITFAIL_UNSUCCESSFUL, /* TPM audit construction ... */ + ADT_TPM_E_AUDITFAIL_SUCCESSFUL, /* TPM audit construction failed ... */ + ADT_TPM_E_NOTRESETABLE, /* PCR register does not have the ... */ + ADT_TPM_E_NOTLOCAL, /* PCR register requires locality */ + ADT_TPM_E_BAD_TYPE, /* Make identity blob not properly typed */ + ADT_TPM_E_INVALID_RESOURCE, /* Resource type does not match ... */ + ADT_TPM_E_NOTFIPS, /* Command only available when TPM is in ... */ + ADT_TPM_E_INVALID_FAMILY, /* The command is attempting to ... */ + ADT_TPM_E_NO_NV_PERMISSION, /* The permission to manipulate ... */ + ADT_TPM_E_REQUIRES_SIGN, /* The operation requires a ... */ + ADT_TPM_E_KEY_NOTSUPPORTED, /* Wrong operation to load an NV key */ + ADT_TPM_E_AUTH_CONFLICT, /* NV_LoadKey blob requires both ... */ + ADT_TPM_E_AREA_LOCKED, /* The NV area is locked and not writable */ + ADT_TPM_E_BAD_LOCALITY, /* The locality is incorrect for the ... */ + ADT_TPM_E_READ_ONLY, /* The NV area is read only and can't be ... */ + ADT_TPM_E_PER_NOWRITE, /* There is no protection on the write to ... */ + ADT_TPM_E_FAMILYCOUNT, /* The family count value does not match */ + ADT_TPM_E_WRITE_LOCKED, /* The NV area has already been written to */ + ADT_TPM_E_BAD_ATTRIBUTES, /* The NV area attributes conflict */ + ADT_TPM_E_INVALID_STRUCTURE, /* The tag and version are ... */ + ADT_TPM_E_KEY_OWNER_CONTROL, /* The key evicted by the TPM Owner. */ + ADT_TPM_E_BAD_COUNTER, /* The counter handle is incorrect */ + ADT_TPM_E_NOT_FULLWRITE, /* The write is not a complete ... */ + ADT_TPM_E_CONTEXT_GAP, /* The gap between saved context counts ... */ + ADT_TPM_E_MAXNVWRITES, /* Max number of NV writes without owner ... */ + ADT_TPM_E_NOOPERATOR, /* No operator AuthData value is set */ + ADT_TPM_E_RESOURCEMISSING, /* The resource pointed to by ... */ + ADT_TPM_E_DELEGATE_LOCK, /* The delegate administration is ... */ + ADT_TPM_E_DELEGATE_FAMILY, /* Attempt to manage a family ... */ + ADT_TPM_E_DELEGATE_ADMIN, /* Delegation table management ... */ + ADT_TPM_E_TRANSPORT_NOTEXCLUSIVE, /* Command executed ... */ + ADT_TPM_E_OWNER_CONTROL, /* Attempt to context save a ... */ + ADT_TPM_E_DAA_RESOURCES, /* DAA command has no resources ... */ + ADT_TPM_E_DAA_INPUT_DATA0, /* The consistency check on DAA ... */ + ADT_TPM_E_DAA_INPUT_DATA1, /* The consistency check on DAA ... */ + ADT_TPM_E_DAA_ISSUER_SETTINGS, /* The consistency check on ... */ + ADT_TPM_E_DAA_TPM_SETTINGS, /* The consistency check on ... */ + ADT_TPM_E_DAA_STAGE, /* Atomic process indicated by DAA ... */ + ADT_TPM_E_DAA_ISSUER_VALIDITY, /* Inconsistent issuer validity */ + ADT_TPM_E_DAA_WRONG_W, /* The consistency check on w has failed. */ + ADT_TPM_E_BAD_HANDLE, /* The handle is incorrect */ + ADT_TPM_E_BAD_DELEGATE, /* Delegation is not correct */ + ADT_TPM_E_BADCONTEXT, /* The context blob is invalid */ + ADT_TPM_E_TOOMANYCONTEXTS, /* Too many contexts held by the TPM */ + ADT_TPM_E_MA_TICKET_SIGNATURE, /* Migration authority signature ... */ + ADT_TPM_E_MA_DESTINATION, /* Migration destination not ... */ + ADT_TPM_E_MA_SOURCE, /* Migration source incorrect */ + ADT_TPM_E_MA_AUTHORITY, /* Incorrect migration authority */ + ADT_TPM_E_PERMANENTEK, /* Attempt to revoke the EK and the EK is ... */ + ADT_TPM_E_BAD_SIGNATURE, /* Bad signature of CMK ticket */ + ADT_TPM_E_NOCONTEXTSPACE, /* There is no room in the ... */ + ADT_TPM_E_RETRY, /* The TPM is too busy to respond to the ... */ + ADT_TPM_E_NEEDS_SELFTEST, /* SelfTestFull has not been run */ + ADT_TPM_E_DOING_SELFTEST, /* The TPM is currently executing ... */ + ADT_TPM_E_DEFEND_LOCK_RUNNING, /* TPM is defending against ... */ + ADT_TPM_E_NO_MSG /* (no token will be generated) */ +}; +#define ADT_UADMIN_FCN 3000 +enum adt_uadmin_fcn { + ADT_UADMIN_FCN_AD_HALT = 3000, /* Halt the processor(s) */ + ADT_UADMIN_FCN_AD_POWEROFF, /* Halt the processor(s) and turn ... */ + ADT_UADMIN_FCN_AD_BOOT, /* Reboot the system using the kernel file */ + ADT_UADMIN_FCN_AD_IBOOT, /* Interactive reboot */ + ADT_UADMIN_FCN_AD_SUSPEND_TO_DISK, /* Save the system state ... */ + ADT_UADMIN_FCN_AD_CHECK_SUSPEND_TO_DISK, /* Check if ... */ + ADT_UADMIN_FCN_AD_FORCE, /* Force suspend to disk even ... */ + ADT_UADMIN_FCN_AD_SUSPEND_TO_RAM, /* Save the system state ... */ + ADT_UADMIN_FCN_AD_CHECK_SUSPEND_TO_RAM, /* Check if system ... */ + ADT_UADMIN_FCN_AD_SBOOT, /* Single-user reboot */ + ADT_UADMIN_FCN_AD_SIBOOT, /* Single-user interactive reboot */ + ADT_UADMIN_FCN_AD_NOSYNC, /* Do not sync filesystems on ... */ + ADT_UADMIN_FCN_AD_FASTREBOOT, /* Reboot bypassing BIOS and boot ... */ + ADT_UADMIN_FCN_AD_FASTREBOOT_DRYRUN, /* Check if system ... */ + ADT_UADMIN_FCN_AD_UPDATE_BOOT_CONFIG, /* Update boot ... */ + ADT_UADMIN_FCN_AD_REUSEINIT, /* Prepare for AD_REUSABLE */ + ADT_UADMIN_FCN_AD_REUSABLE, /* Create reusable statefile */ + ADT_UADMIN_FCN_AD_REUSEFINI, /* Revert to normal CPR mode (not ... */ + ADT_UADMIN_FCN_AD_FTRACE_START, /* ftrace start */ + ADT_UADMIN_FCN_AD_FTRACE_STOP /* ftrace stop */ +}; +#define ADT_admin_authenticate 3 +#define ADT_attach 42 +#define ADT_cpu_ondemand 93 +#define ADT_cpu_performance 94 +#define ADT_cpu_threshold 95 +#define ADT_detach 43 +#define ADT_dladm_create_secobj 47 +#define ADT_dladm_delete_secobj 48 +#define ADT_file_copy 50 +#define ADT_file_relabel 49 +#define ADT_filesystem_add 4 +#define ADT_filesystem_delete 5 +#define ADT_filesystem_modify 6 +#define ADT_hotplug_set 118 +#define ADT_hotplug_state 117 +#define ADT_ilb_add_server 126 +#define ADT_ilb_create_healthcheck 120 +#define ADT_ilb_create_rule 122 +#define ADT_ilb_create_servergroup 130 +#define ADT_ilb_delete_healthcheck 121 +#define ADT_ilb_delete_rule 123 +#define ADT_ilb_delete_servergroup 131 +#define ADT_ilb_disable_rule 124 +#define ADT_ilb_disable_server 127 +#define ADT_ilb_enable_rule 125 +#define ADT_ilb_enable_server 128 +#define ADT_ilb_remove_server 129 +#define ADT_inetd_connect 34 +#define ADT_inetd_copylimit 36 +#define ADT_inetd_failrate 37 +#define ADT_inetd_ratelimit 35 +#define ADT_init_solaris 32 +#define ADT_login 25 +#define ADT_logout 1 +#define ADT_ndmp_backup 63 +#define ADT_ndmp_connect 61 +#define ADT_ndmp_disconnect 62 +#define ADT_ndmp_restore 64 +#define ADT_netcfg_remove 135 +#define ADT_netcfg_update 134 +#define ADT_network_add 7 +#define ADT_network_delete 8 +#define ADT_network_modify 9 +#define ADT_newgrp_login 41 +#define ADT_nwam_disable 133 +#define ADT_nwam_enable 132 +#define ADT_passwd 27 +#define ADT_pool_export 46 +#define ADT_pool_import 45 +#define ADT_printer_add 10 +#define ADT_printer_delete 11 +#define ADT_printer_modify 12 +#define ADT_prof_cmd 24 +#define ADT_remove 44 +#define ADT_rlogin 28 +#define ADT_role_login 13 +#define ADT_role_logout 40 +#define ADT_scheduledjob_add 14 +#define ADT_scheduledjob_delete 15 +#define ADT_scheduledjob_modify 16 +#define ADT_screenlock 26 +#define ADT_screenunlock 31 +#define ADT_serialport_add 17 +#define ADT_serialport_delete 18 +#define ADT_serialport_modify 19 +#define ADT_smbd_logoff 59 +#define ADT_smbd_session 58 +#define ADT_smf_annotation 88 +#define ADT_smf_attach_snap 87 +#define ADT_smf_change_prop 90 +#define ADT_smf_clear 71 +#define ADT_smf_create 79 +#define ADT_smf_create_npg 82 +#define ADT_smf_create_pg 81 +#define ADT_smf_create_prop 89 +#define ADT_smf_create_snap 85 +#define ADT_smf_degrade 72 +#define ADT_smf_delete 80 +#define ADT_smf_delete_npg 84 +#define ADT_smf_delete_pg 83 +#define ADT_smf_delete_prop 91 +#define ADT_smf_delete_snap 86 +#define ADT_smf_disable 67 +#define ADT_smf_enable 65 +#define ADT_smf_immediate_degrade 73 +#define ADT_smf_immediate_maintenance 75 +#define ADT_smf_immtmp_maintenance 76 +#define ADT_smf_maintenance 74 +#define ADT_smf_milestone 78 +#define ADT_smf_read_prop 92 +#define ADT_smf_refresh 70 +#define ADT_smf_restart 69 +#define ADT_smf_tmp_disable 68 +#define ADT_smf_tmp_enable 66 +#define ADT_smf_tmp_maintenance 77 +#define ADT_ssh 2 +#define ADT_su 30 +#define ADT_su_logout 39 +#define ADT_telnet 29 +#define ADT_tpm_certifyselftest 103 +#define ADT_tpm_continueselftest 104 +#define ADT_tpm_disableforceclear 109 +#define ADT_tpm_disableownerclear 107 +#define ADT_tpm_fieldupgrade 115 +#define ADT_tpm_forceclear 108 +#define ADT_tpm_ownerclear 106 +#define ADT_tpm_ownersetdisable 105 +#define ADT_tpm_physicaldeactivate 112 +#define ADT_tpm_physicaldisable 110 +#define ADT_tpm_physicalenable 111 +#define ADT_tpm_physicalpresence 114 +#define ADT_tpm_resetlockvalue 116 +#define ADT_tpm_selftestfull 102 +#define ADT_tpm_setoperatorauth 100 +#define ADT_tpm_setownerinstall 101 +#define ADT_tpm_settempdeactivated 113 +#define ADT_tpm_takeownership 99 +#define ADT_uadmin_config 119 +#define ADT_uadmin_dump 53 +#define ADT_uadmin_freeze 54 +#define ADT_uadmin_ftrace 56 +#define ADT_uadmin_reboot 52 +#define ADT_uadmin_remount 55 +#define ADT_uadmin_shutdown 51 +#define ADT_uadmin_swapctl 57 +#define ADT_uadmin_thaw 96 +#define ADT_uauth 20 +#define ADT_usermgr_add 21 +#define ADT_usermgr_delete 22 +#define ADT_usermgr_modify 23 +#define ADT_vscan_quarantine 60 +#define ADT_zlogin 38 +#define ADT_zone_state 33 + +struct adt_admin_authenticate { /* ADT_admin_authenticate */ + enum adt_login_text message; /* optional */ +}; +typedef struct adt_admin_authenticate adt_admin_authenticate_t; + +struct adt_attach { /* ADT_attach */ + char *auth_used; /* required */ + char *mount_point; /* required */ + char *device; /* required */ + char *options; /* optional */ +}; +typedef struct adt_attach adt_attach_t; + +struct adt_cpu_ondemand { /* ADT_cpu_ondemand */ + char *auth_used; /* required */ +}; +typedef struct adt_cpu_ondemand adt_cpu_ondemand_t; + +struct adt_cpu_performance { /* ADT_cpu_performance */ + char *auth_used; /* required */ +}; +typedef struct adt_cpu_performance adt_cpu_performance_t; + +struct adt_cpu_threshold { /* ADT_cpu_threshold */ + char *auth_used; /* required */ + int threshold; /* required */ +}; +typedef struct adt_cpu_threshold adt_cpu_threshold_t; + +struct adt_detach { /* ADT_detach */ + char *auth_used; /* required */ + char *mount_point; /* required */ + char *device; /* required */ + char *options; /* optional */ +}; +typedef struct adt_detach adt_detach_t; + +struct adt_dladm_create_secobj { /* ADT_dladm_create_secobj */ + char *auth_used; /* required */ + char *obj_class; /* required */ + char *obj_name; /* required */ +}; +typedef struct adt_dladm_create_secobj adt_dladm_create_secobj_t; + +struct adt_dladm_delete_secobj { /* ADT_dladm_delete_secobj */ + char *auth_used; /* required */ + char *obj_class; /* required */ + char *obj_name; /* required */ +}; +typedef struct adt_dladm_delete_secobj adt_dladm_delete_secobj_t; + +struct adt_file_copy { /* ADT_file_copy */ + char *auth_used; /* required */ + char *src_file; /* required */ + m_label_t *src_label; /* required */ + char *dst_file; /* required */ + m_label_t *dst_label; /* required */ +}; +typedef struct adt_file_copy adt_file_copy_t; + +struct adt_file_relabel { /* ADT_file_relabel */ + char *auth_used; /* required */ + char *file; /* required */ + m_label_t *src_label; /* required */ + m_label_t *dst_label; /* required */ +}; +typedef struct adt_file_relabel adt_file_relabel_t; + +struct adt_filesystem_add { /* ADT_filesystem_add */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *initial_values; /* required */ +}; +typedef struct adt_filesystem_add adt_filesystem_add_t; + +struct adt_filesystem_delete { /* ADT_filesystem_delete */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *delete_values; /* required */ +}; +typedef struct adt_filesystem_delete adt_filesystem_delete_t; + +struct adt_filesystem_modify { /* ADT_filesystem_modify */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *changed_values; /* required */ +}; +typedef struct adt_filesystem_modify adt_filesystem_modify_t; + +struct adt_hotplug_set { /* ADT_hotplug_set */ + char *auth_used; /* required */ + char *device_path; /* required */ + char *connection; /* required */ + char *options; /* required */ +}; +typedef struct adt_hotplug_set adt_hotplug_set_t; + +struct adt_hotplug_state { /* ADT_hotplug_state */ + char *auth_used; /* required */ + char *device_path; /* required */ + char *connection; /* required */ + char *new_state; /* required */ + char *old_state; /* required */ +}; +typedef struct adt_hotplug_state adt_hotplug_state_t; + +struct adt_ilb_add_server { /* ADT_ilb_add_server */ + char *auth_used; /* required */ + int32_t server_ipaddress_type; /* required */ + uint32_t server_ipaddress[4]; /* required */ + char *server_id; /* optional */ + char *server_group; /* required */ + uint16_t server_minport; /* optional */ + uint16_t server_maxport; /* optional */ +}; +typedef struct adt_ilb_add_server adt_ilb_add_server_t; + +struct adt_ilb_create_healthcheck { /* ADT_ilb_create_healthcheck */ + char *auth_used; /* required */ + char *hc_test; /* required */ + char *hc_name; /* required */ + int32_t hc_timeout; /* required */ + int hc_count; /* required */ + int32_t hc_interval; /* required */ +}; +typedef struct adt_ilb_create_healthcheck adt_ilb_create_healthcheck_t; + +struct adt_ilb_create_rule { /* ADT_ilb_create_rule */ + char *auth_used; /* required */ + int32_t virtual_ipaddress_type; /* required */ + uint32_t virtual_ipaddress[4]; /* required */ + uint16_t min_port; /* required */ + uint16_t max_port; /* required */ + char *protocol; /* required */ + char *algo_optype; /* required */ + int32_t proxy_src_min_type; /* optional */ + uint32_t proxy_src_min[4]; /* optional */ + int32_t proxy_src_max_type; /* optional */ + uint32_t proxy_src_max[4]; /* optional */ + char *persist_mask; /* required */ + char *hcname; /* optional */ + char *hcport; /* optional */ + uint32_t conndrain_timeout; /* required */ + uint32_t nat_timeout; /* required */ + uint32_t persist_timeout; /* required */ + char *server_group; /* required */ + char *rule_name; /* required */ +}; +typedef struct adt_ilb_create_rule adt_ilb_create_rule_t; + +struct adt_ilb_create_servergroup { /* ADT_ilb_create_servergroup */ + char *auth_used; /* required */ + char *server_group; /* required */ +}; +typedef struct adt_ilb_create_servergroup adt_ilb_create_servergroup_t; + +struct adt_ilb_delete_healthcheck { /* ADT_ilb_delete_healthcheck */ + char *auth_used; /* required */ + char *hc_name; /* required */ +}; +typedef struct adt_ilb_delete_healthcheck adt_ilb_delete_healthcheck_t; + +struct adt_ilb_delete_rule { /* ADT_ilb_delete_rule */ + char *auth_used; /* required */ + char *rule_name; /* required */ +}; +typedef struct adt_ilb_delete_rule adt_ilb_delete_rule_t; + +struct adt_ilb_delete_servergroup { /* ADT_ilb_delete_servergroup */ + char *auth_used; /* required */ + char *server_group; /* required */ +}; +typedef struct adt_ilb_delete_servergroup adt_ilb_delete_servergroup_t; + +struct adt_ilb_disable_rule { /* ADT_ilb_disable_rule */ + char *auth_used; /* required */ + char *rule_name; /* required */ +}; +typedef struct adt_ilb_disable_rule adt_ilb_disable_rule_t; + +struct adt_ilb_disable_server { /* ADT_ilb_disable_server */ + char *auth_used; /* required */ + char *server_id; /* required */ + int32_t server_ipaddress_type; /* optional */ + uint32_t server_ipaddress[4]; /* optional */ +}; +typedef struct adt_ilb_disable_server adt_ilb_disable_server_t; + +struct adt_ilb_enable_rule { /* ADT_ilb_enable_rule */ + char *auth_used; /* required */ + char *rule_name; /* required */ +}; +typedef struct adt_ilb_enable_rule adt_ilb_enable_rule_t; + +struct adt_ilb_enable_server { /* ADT_ilb_enable_server */ + char *auth_used; /* required */ + char *server_id; /* required */ + int32_t server_ipaddress_type; /* optional */ + uint32_t server_ipaddress[4]; /* optional */ +}; +typedef struct adt_ilb_enable_server adt_ilb_enable_server_t; + +struct adt_ilb_remove_server { /* ADT_ilb_remove_server */ + char *auth_used; /* required */ + char *server_id; /* required */ + char *server_group; /* required */ + int32_t server_ipaddress_type; /* optional */ + uint32_t server_ipaddress[4]; /* optional */ +}; +typedef struct adt_ilb_remove_server adt_ilb_remove_server_t; + +struct adt_inetd_connect { /* ADT_inetd_connect */ + char *service_name; /* optional */ + uint32_t ip_type; /* required */ + uint16_t ip_remote_port; /* required */ + uint16_t ip_local_port; /* required */ + uint32_t ip_adr[4]; /* required */ + char *cmd; /* required */ + priv_set_t *privileges; /* required */ +}; +typedef struct adt_inetd_connect adt_inetd_connect_t; + +struct adt_inetd_copylimit { /* ADT_inetd_copylimit */ + char *service_name; /* optional */ + char *limit; /* required */ +}; +typedef struct adt_inetd_copylimit adt_inetd_copylimit_t; + +struct adt_inetd_failrate { /* ADT_inetd_failrate */ + char *service_name; /* optional */ + char *values; /* required */ +}; +typedef struct adt_inetd_failrate adt_inetd_failrate_t; + +struct adt_inetd_ratelimit { /* ADT_inetd_ratelimit */ + char *service_name; /* optional */ + char *limit; /* required */ +}; +typedef struct adt_inetd_ratelimit adt_inetd_ratelimit_t; + +struct adt_init_solaris { /* ADT_init_solaris */ + char *info; /* optional */ +}; +typedef struct adt_init_solaris adt_init_solaris_t; + +struct adt_login { /* ADT_login */ + enum adt_login_text message; /* optional */ +}; +typedef struct adt_login adt_login_t; + +struct adt_logout { /* ADT_logout */ + char *user_name; /* optional (format: logout %s) */ +}; +typedef struct adt_logout adt_logout_t; + +struct adt_ndmp_backup { /* ADT_ndmp_backup */ + char *source; /* required */ + char *local_dest; /* optional */ + fd_t remote_dest; /* optional */ +}; +typedef struct adt_ndmp_backup adt_ndmp_backup_t; + +struct adt_ndmp_connect { /* ADT_ndmp_connect */ + int dummy; /* not used */ +}; +typedef struct adt_ndmp_connect adt_ndmp_connect_t; + +struct adt_ndmp_disconnect { /* ADT_ndmp_disconnect */ + int dummy; /* not used */ +}; +typedef struct adt_ndmp_disconnect adt_ndmp_disconnect_t; + +struct adt_ndmp_restore { /* ADT_ndmp_restore */ + char *destination; /* required */ + char *local_source; /* optional */ + fd_t remote_source; /* optional */ +}; +typedef struct adt_ndmp_restore adt_ndmp_restore_t; + +struct adt_netcfg_remove { /* ADT_netcfg_remove */ + char *parent_file; /* required */ + char *object_name; /* required */ +}; +typedef struct adt_netcfg_remove adt_netcfg_remove_t; + +struct adt_netcfg_update { /* ADT_netcfg_update */ + char *parent_file; /* required */ + char *object_name; /* required */ +}; +typedef struct adt_netcfg_update adt_netcfg_update_t; + +struct adt_network_add { /* ADT_network_add */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *initial_values; /* required */ +}; +typedef struct adt_network_add adt_network_add_t; + +struct adt_network_delete { /* ADT_network_delete */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *delete_values; /* required */ +}; +typedef struct adt_network_delete adt_network_delete_t; + +struct adt_network_modify { /* ADT_network_modify */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *changed_values; /* required */ +}; +typedef struct adt_network_modify adt_network_modify_t; + +struct adt_newgrp_login { /* ADT_newgrp_login */ + char *groupname; /* required */ +}; +typedef struct adt_newgrp_login adt_newgrp_login_t; + +struct adt_nwam_disable { /* ADT_nwam_disable */ + char *profile_type; /* required */ + char *profile_name; /* required */ +}; +typedef struct adt_nwam_disable adt_nwam_disable_t; + +struct adt_nwam_enable { /* ADT_nwam_enable */ + char *profile_type; /* required */ + char *profile_name; /* required */ +}; +typedef struct adt_nwam_enable adt_nwam_enable_t; + +struct adt_passwd { /* ADT_passwd */ + uid_t uid; /* optional */ + char *username; /* optional */ +}; +typedef struct adt_passwd adt_passwd_t; + +struct adt_pool_export { /* ADT_pool_export */ + char *auth_used; /* required */ + char *pool; /* required */ + char *device; /* required */ +}; +typedef struct adt_pool_export adt_pool_export_t; + +struct adt_pool_import { /* ADT_pool_import */ + char *auth_used; /* required */ + char *pool; /* required */ + char *device; /* required */ +}; +typedef struct adt_pool_import adt_pool_import_t; + +struct adt_printer_add { /* ADT_printer_add */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *initial_values; /* required */ +}; +typedef struct adt_printer_add adt_printer_add_t; + +struct adt_printer_delete { /* ADT_printer_delete */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *delete_values; /* required */ +}; +typedef struct adt_printer_delete adt_printer_delete_t; + +struct adt_printer_modify { /* ADT_printer_modify */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *changed_values; /* required */ +}; +typedef struct adt_printer_modify adt_printer_modify_t; + +struct adt_prof_cmd { /* ADT_prof_cmd */ + char *cwdpath; /* required */ + char *cmdpath; /* required */ + int argc; /* required */ + char **argv; /* required */ + char **envp; /* required */ + uid_t proc_auid; /* required */ + uid_t proc_euid; /* required */ + gid_t proc_egid; /* required */ + uid_t proc_ruid; /* required */ + gid_t proc_rgid; /* required */ + pid_t proc_pid; /* required */ + au_asid_t proc_sid; /* required */ + adt_termid_t *proc_termid; /* required */ + priv_set_t *limit_set; /* optional */ + priv_set_t *inherit_set; /* optional */ +}; +typedef struct adt_prof_cmd adt_prof_cmd_t; + +struct adt_remove { /* ADT_remove */ + char *auth_used; /* required */ + char *mount_point; /* optional */ + char *device; /* required */ +}; +typedef struct adt_remove adt_remove_t; + +struct adt_rlogin { /* ADT_rlogin */ + enum adt_login_text message; /* optional */ +}; +typedef struct adt_rlogin adt_rlogin_t; + +struct adt_role_login { /* ADT_role_login */ + enum adt_login_text message; /* optional */ +}; +typedef struct adt_role_login adt_role_login_t; + +struct adt_role_logout { /* ADT_role_logout */ + int dummy; /* not used */ +}; +typedef struct adt_role_logout adt_role_logout_t; + +struct adt_scheduledjob_add { /* ADT_scheduledjob_add */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *initial_values; /* required */ +}; +typedef struct adt_scheduledjob_add adt_scheduledjob_add_t; + +struct adt_scheduledjob_delete { /* ADT_scheduledjob_delete */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *delete_values; /* required */ +}; +typedef struct adt_scheduledjob_delete adt_scheduledjob_delete_t; + +struct adt_scheduledjob_modify { /* ADT_scheduledjob_modify */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *changed_values; /* required */ +}; +typedef struct adt_scheduledjob_modify adt_scheduledjob_modify_t; + +struct adt_screenlock { /* ADT_screenlock */ + int dummy; /* not used */ +}; +typedef struct adt_screenlock adt_screenlock_t; + +struct adt_screenunlock { /* ADT_screenunlock */ + int dummy; /* not used */ +}; +typedef struct adt_screenunlock adt_screenunlock_t; + +struct adt_serialport_add { /* ADT_serialport_add */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *initial_values; /* required */ +}; +typedef struct adt_serialport_add adt_serialport_add_t; + +struct adt_serialport_delete { /* ADT_serialport_delete */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *delete_values; /* required */ +}; +typedef struct adt_serialport_delete adt_serialport_delete_t; + +struct adt_serialport_modify { /* ADT_serialport_modify */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *changed_values; /* required */ +}; +typedef struct adt_serialport_modify adt_serialport_modify_t; + +struct adt_smbd_logoff { /* ADT_smbd_logoff */ + char *domain; /* required */ + char *username; /* required */ +}; +typedef struct adt_smbd_logoff adt_smbd_logoff_t; + +struct adt_smbd_session { /* ADT_smbd_session */ + char *domain; /* required */ + char *username; /* required */ + char *sid; /* optional */ +}; +typedef struct adt_smbd_session adt_smbd_session_t; + +struct adt_smf_annotation { /* ADT_smf_annotation */ + char *operation; /* required */ + char *file; /* required */ +}; +typedef struct adt_smf_annotation adt_smf_annotation_t; + +struct adt_smf_attach_snap { /* ADT_smf_attach_snap */ + char *auth_used; /* required */ + char *old_fmri; /* required */ + char *old_name; /* required */ + char *new_fmri; /* required */ + char *new_name; /* required */ +}; +typedef struct adt_smf_attach_snap adt_smf_attach_snap_t; + +struct adt_smf_change_prop { /* ADT_smf_change_prop */ + char *auth_used; /* required */ + char *fmri; /* required */ + char *type; /* required */ + char *value; /* optional */ +}; +typedef struct adt_smf_change_prop adt_smf_change_prop_t; + +struct adt_smf_clear { /* ADT_smf_clear */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_clear adt_smf_clear_t; + +struct adt_smf_create { /* ADT_smf_create */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_create adt_smf_create_t; + +struct adt_smf_create_npg { /* ADT_smf_create_npg */ + char *auth_used; /* required */ + char *fmri; /* required */ + char *type; /* required */ +}; +typedef struct adt_smf_create_npg adt_smf_create_npg_t; + +struct adt_smf_create_pg { /* ADT_smf_create_pg */ + char *auth_used; /* required */ + char *fmri; /* required */ + char *type; /* required */ +}; +typedef struct adt_smf_create_pg adt_smf_create_pg_t; + +struct adt_smf_create_prop { /* ADT_smf_create_prop */ + char *auth_used; /* required */ + char *fmri; /* required */ + char *type; /* required */ + char *value; /* optional */ +}; +typedef struct adt_smf_create_prop adt_smf_create_prop_t; + +struct adt_smf_create_snap { /* ADT_smf_create_snap */ + char *auth_used; /* required */ + char *fmri; /* required */ + char *name; /* required */ +}; +typedef struct adt_smf_create_snap adt_smf_create_snap_t; + +struct adt_smf_degrade { /* ADT_smf_degrade */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_degrade adt_smf_degrade_t; + +struct adt_smf_delete { /* ADT_smf_delete */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_delete adt_smf_delete_t; + +struct adt_smf_delete_npg { /* ADT_smf_delete_npg */ + char *auth_used; /* required */ + char *fmri; /* required */ + char *type; /* required */ +}; +typedef struct adt_smf_delete_npg adt_smf_delete_npg_t; + +struct adt_smf_delete_pg { /* ADT_smf_delete_pg */ + char *auth_used; /* required */ + char *fmri; /* required */ + char *type; /* required */ +}; +typedef struct adt_smf_delete_pg adt_smf_delete_pg_t; + +struct adt_smf_delete_prop { /* ADT_smf_delete_prop */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_delete_prop adt_smf_delete_prop_t; + +struct adt_smf_delete_snap { /* ADT_smf_delete_snap */ + char *auth_used; /* required */ + char *fmri; /* required */ + char *name; /* required */ +}; +typedef struct adt_smf_delete_snap adt_smf_delete_snap_t; + +struct adt_smf_disable { /* ADT_smf_disable */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_disable adt_smf_disable_t; + +struct adt_smf_enable { /* ADT_smf_enable */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_enable adt_smf_enable_t; + +struct adt_smf_immediate_degrade { /* ADT_smf_immediate_degrade */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_immediate_degrade adt_smf_immediate_degrade_t; + +struct adt_smf_immediate_maintenance { /* ADT_smf_immediate_maintenance */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_immediate_maintenance adt_smf_immediate_maintenance_t; + +struct adt_smf_immtmp_maintenance { /* ADT_smf_immtmp_maintenance */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_immtmp_maintenance adt_smf_immtmp_maintenance_t; + +struct adt_smf_maintenance { /* ADT_smf_maintenance */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_maintenance adt_smf_maintenance_t; + +struct adt_smf_milestone { /* ADT_smf_milestone */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_milestone adt_smf_milestone_t; + +struct adt_smf_read_prop { /* ADT_smf_read_prop */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_read_prop adt_smf_read_prop_t; + +struct adt_smf_refresh { /* ADT_smf_refresh */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_refresh adt_smf_refresh_t; + +struct adt_smf_restart { /* ADT_smf_restart */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_restart adt_smf_restart_t; + +struct adt_smf_tmp_disable { /* ADT_smf_tmp_disable */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_tmp_disable adt_smf_tmp_disable_t; + +struct adt_smf_tmp_enable { /* ADT_smf_tmp_enable */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_tmp_enable adt_smf_tmp_enable_t; + +struct adt_smf_tmp_maintenance { /* ADT_smf_tmp_maintenance */ + char *auth_used; /* required */ + char *fmri; /* required */ +}; +typedef struct adt_smf_tmp_maintenance adt_smf_tmp_maintenance_t; + +struct adt_ssh { /* ADT_ssh */ + enum adt_login_text message; /* optional */ +}; +typedef struct adt_ssh adt_ssh_t; + +struct adt_su { /* ADT_su */ + char *message; /* optional */ +}; +typedef struct adt_su adt_su_t; + +struct adt_su_logout { /* ADT_su_logout */ + int dummy; /* not used */ +}; +typedef struct adt_su_logout adt_su_logout_t; + +struct adt_telnet { /* ADT_telnet */ + enum adt_login_text message; /* optional */ +}; +typedef struct adt_telnet adt_telnet_t; + +struct adt_tpm_certifyselftest { /* ADT_tpm_certifyselftest */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_certifyselftest adt_tpm_certifyselftest_t; + +struct adt_tpm_continueselftest { /* ADT_tpm_continueselftest */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_continueselftest adt_tpm_continueselftest_t; + +struct adt_tpm_disableforceclear { /* ADT_tpm_disableforceclear */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_disableforceclear adt_tpm_disableforceclear_t; + +struct adt_tpm_disableownerclear { /* ADT_tpm_disableownerclear */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_disableownerclear adt_tpm_disableownerclear_t; + +struct adt_tpm_fieldupgrade { /* ADT_tpm_fieldupgrade */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_fieldupgrade adt_tpm_fieldupgrade_t; + +struct adt_tpm_forceclear { /* ADT_tpm_forceclear */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_forceclear adt_tpm_forceclear_t; + +struct adt_tpm_ownerclear { /* ADT_tpm_ownerclear */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_ownerclear adt_tpm_ownerclear_t; + +struct adt_tpm_ownersetdisable { /* ADT_tpm_ownersetdisable */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_ownersetdisable adt_tpm_ownersetdisable_t; + +struct adt_tpm_physicaldeactivate { /* ADT_tpm_physicaldeactivate */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_physicaldeactivate adt_tpm_physicaldeactivate_t; + +struct adt_tpm_physicaldisable { /* ADT_tpm_physicaldisable */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_physicaldisable adt_tpm_physicaldisable_t; + +struct adt_tpm_physicalenable { /* ADT_tpm_physicalenable */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_physicalenable adt_tpm_physicalenable_t; + +struct adt_tpm_physicalpresence { /* ADT_tpm_physicalpresence */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_physicalpresence adt_tpm_physicalpresence_t; + +struct adt_tpm_resetlockvalue { /* ADT_tpm_resetlockvalue */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_resetlockvalue adt_tpm_resetlockvalue_t; + +struct adt_tpm_selftestfull { /* ADT_tpm_selftestfull */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_selftestfull adt_tpm_selftestfull_t; + +struct adt_tpm_setoperatorauth { /* ADT_tpm_setoperatorauth */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_setoperatorauth adt_tpm_setoperatorauth_t; + +struct adt_tpm_setownerinstall { /* ADT_tpm_setownerinstall */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_setownerinstall adt_tpm_setownerinstall_t; + +struct adt_tpm_settempdeactivated { /* ADT_tpm_settempdeactivated */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_settempdeactivated adt_tpm_settempdeactivated_t; + +struct adt_tpm_takeownership { /* ADT_tpm_takeownership */ + enum adt_tpm_e message; /* optional */ +}; +typedef struct adt_tpm_takeownership adt_tpm_takeownership_t; + +struct adt_uadmin_config { /* ADT_uadmin_config */ + enum adt_uadmin_fcn fcn; /* required */ + char *mdep; /* optional */ +}; +typedef struct adt_uadmin_config adt_uadmin_config_t; + +struct adt_uadmin_dump { /* ADT_uadmin_dump */ + enum adt_uadmin_fcn fcn; /* required */ + char *mdep; /* optional */ +}; +typedef struct adt_uadmin_dump adt_uadmin_dump_t; + +struct adt_uadmin_freeze { /* ADT_uadmin_freeze */ + enum adt_uadmin_fcn fcn; /* required */ + char *mdep; /* optional */ +}; +typedef struct adt_uadmin_freeze adt_uadmin_freeze_t; + +struct adt_uadmin_ftrace { /* ADT_uadmin_ftrace */ + enum adt_uadmin_fcn fcn; /* required */ + char *mdep; /* optional */ +}; +typedef struct adt_uadmin_ftrace adt_uadmin_ftrace_t; + +struct adt_uadmin_reboot { /* ADT_uadmin_reboot */ + enum adt_uadmin_fcn fcn; /* required */ + char *mdep; /* optional */ +}; +typedef struct adt_uadmin_reboot adt_uadmin_reboot_t; + +struct adt_uadmin_remount { /* ADT_uadmin_remount */ + int dummy; /* not used */ +}; +typedef struct adt_uadmin_remount adt_uadmin_remount_t; + +struct adt_uadmin_shutdown { /* ADT_uadmin_shutdown */ + enum adt_uadmin_fcn fcn; /* required */ + char *mdep; /* optional */ +}; +typedef struct adt_uadmin_shutdown adt_uadmin_shutdown_t; + +struct adt_uadmin_swapctl { /* ADT_uadmin_swapctl */ + enum adt_uadmin_fcn fcn; /* required */ +}; +typedef struct adt_uadmin_swapctl adt_uadmin_swapctl_t; + +struct adt_uadmin_thaw { /* ADT_uadmin_thaw */ + enum adt_uadmin_fcn fcn; /* required */ +}; +typedef struct adt_uadmin_thaw adt_uadmin_thaw_t; + +struct adt_uauth { /* ADT_uauth */ + char *auth_used; /* required */ + char *objectname; /* required */ +}; +typedef struct adt_uauth adt_uauth_t; + +struct adt_usermgr_add { /* ADT_usermgr_add */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *initial_values; /* required */ +}; +typedef struct adt_usermgr_add adt_usermgr_add_t; + +struct adt_usermgr_delete { /* ADT_usermgr_delete */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *delete_values; /* required */ +}; +typedef struct adt_usermgr_delete adt_usermgr_delete_t; + +struct adt_usermgr_modify { /* ADT_usermgr_modify */ + char *object_name; /* required */ + char *domain; /* optional */ + char *name_service; /* required */ + char *auth_used; /* optional */ + char *changed_values; /* required */ +}; +typedef struct adt_usermgr_modify adt_usermgr_modify_t; + +struct adt_vscan_quarantine { /* ADT_vscan_quarantine */ + char *file; /* required */ + char **violations; /* optional */ + int nviolations; /* optional */ +}; +typedef struct adt_vscan_quarantine adt_vscan_quarantine_t; + +struct adt_zlogin { /* ADT_zlogin */ + char *message; /* optional */ +}; +typedef struct adt_zlogin adt_zlogin_t; + +struct adt_zone_state { /* ADT_zone_state */ + char *new_state; /* required */ + char *zonename; /* required */ +}; +typedef struct adt_zone_state adt_zone_state_t; + +union adt_event_data { + adt_admin_authenticate_t adt_admin_authenticate; + adt_attach_t adt_attach; + adt_cpu_ondemand_t adt_cpu_ondemand; + adt_cpu_performance_t adt_cpu_performance; + adt_cpu_threshold_t adt_cpu_threshold; + adt_detach_t adt_detach; + adt_dladm_create_secobj_t adt_dladm_create_secobj; + adt_dladm_delete_secobj_t adt_dladm_delete_secobj; + adt_file_copy_t adt_file_copy; + adt_file_relabel_t adt_file_relabel; + adt_filesystem_add_t adt_filesystem_add; + adt_filesystem_delete_t adt_filesystem_delete; + adt_filesystem_modify_t adt_filesystem_modify; + adt_hotplug_set_t adt_hotplug_set; + adt_hotplug_state_t adt_hotplug_state; + adt_ilb_add_server_t adt_ilb_add_server; + adt_ilb_create_healthcheck_t adt_ilb_create_healthcheck; + adt_ilb_create_rule_t adt_ilb_create_rule; + adt_ilb_create_servergroup_t adt_ilb_create_servergroup; + adt_ilb_delete_healthcheck_t adt_ilb_delete_healthcheck; + adt_ilb_delete_rule_t adt_ilb_delete_rule; + adt_ilb_delete_servergroup_t adt_ilb_delete_servergroup; + adt_ilb_disable_rule_t adt_ilb_disable_rule; + adt_ilb_disable_server_t adt_ilb_disable_server; + adt_ilb_enable_rule_t adt_ilb_enable_rule; + adt_ilb_enable_server_t adt_ilb_enable_server; + adt_ilb_remove_server_t adt_ilb_remove_server; + adt_inetd_connect_t adt_inetd_connect; + adt_inetd_copylimit_t adt_inetd_copylimit; + adt_inetd_failrate_t adt_inetd_failrate; + adt_inetd_ratelimit_t adt_inetd_ratelimit; + adt_init_solaris_t adt_init_solaris; + adt_login_t adt_login; + adt_logout_t adt_logout; + adt_ndmp_backup_t adt_ndmp_backup; + adt_ndmp_connect_t adt_ndmp_connect; + adt_ndmp_disconnect_t adt_ndmp_disconnect; + adt_ndmp_restore_t adt_ndmp_restore; + adt_netcfg_remove_t adt_netcfg_remove; + adt_netcfg_update_t adt_netcfg_update; + adt_network_add_t adt_network_add; + adt_network_delete_t adt_network_delete; + adt_network_modify_t adt_network_modify; + adt_newgrp_login_t adt_newgrp_login; + adt_nwam_disable_t adt_nwam_disable; + adt_nwam_enable_t adt_nwam_enable; + adt_passwd_t adt_passwd; + adt_pool_export_t adt_pool_export; + adt_pool_import_t adt_pool_import; + adt_printer_add_t adt_printer_add; + adt_printer_delete_t adt_printer_delete; + adt_printer_modify_t adt_printer_modify; + adt_prof_cmd_t adt_prof_cmd; + adt_remove_t adt_remove; + adt_rlogin_t adt_rlogin; + adt_role_login_t adt_role_login; + adt_role_logout_t adt_role_logout; + adt_scheduledjob_add_t adt_scheduledjob_add; + adt_scheduledjob_delete_t adt_scheduledjob_delete; + adt_scheduledjob_modify_t adt_scheduledjob_modify; + adt_screenlock_t adt_screenlock; + adt_screenunlock_t adt_screenunlock; + adt_serialport_add_t adt_serialport_add; + adt_serialport_delete_t adt_serialport_delete; + adt_serialport_modify_t adt_serialport_modify; + adt_smbd_logoff_t adt_smbd_logoff; + adt_smbd_session_t adt_smbd_session; + adt_smf_annotation_t adt_smf_annotation; + adt_smf_attach_snap_t adt_smf_attach_snap; + adt_smf_change_prop_t adt_smf_change_prop; + adt_smf_clear_t adt_smf_clear; + adt_smf_create_t adt_smf_create; + adt_smf_create_npg_t adt_smf_create_npg; + adt_smf_create_pg_t adt_smf_create_pg; + adt_smf_create_prop_t adt_smf_create_prop; + adt_smf_create_snap_t adt_smf_create_snap; + adt_smf_degrade_t adt_smf_degrade; + adt_smf_delete_t adt_smf_delete; + adt_smf_delete_npg_t adt_smf_delete_npg; + adt_smf_delete_pg_t adt_smf_delete_pg; + adt_smf_delete_prop_t adt_smf_delete_prop; + adt_smf_delete_snap_t adt_smf_delete_snap; + adt_smf_disable_t adt_smf_disable; + adt_smf_enable_t adt_smf_enable; + adt_smf_immediate_degrade_t adt_smf_immediate_degrade; + adt_smf_immediate_maintenance_t adt_smf_immediate_maintenance; + adt_smf_immtmp_maintenance_t adt_smf_immtmp_maintenance; + adt_smf_maintenance_t adt_smf_maintenance; + adt_smf_milestone_t adt_smf_milestone; + adt_smf_read_prop_t adt_smf_read_prop; + adt_smf_refresh_t adt_smf_refresh; + adt_smf_restart_t adt_smf_restart; + adt_smf_tmp_disable_t adt_smf_tmp_disable; + adt_smf_tmp_enable_t adt_smf_tmp_enable; + adt_smf_tmp_maintenance_t adt_smf_tmp_maintenance; + adt_ssh_t adt_ssh; + adt_su_t adt_su; + adt_su_logout_t adt_su_logout; + adt_telnet_t adt_telnet; + adt_tpm_certifyselftest_t adt_tpm_certifyselftest; + adt_tpm_continueselftest_t adt_tpm_continueselftest; + adt_tpm_disableforceclear_t adt_tpm_disableforceclear; + adt_tpm_disableownerclear_t adt_tpm_disableownerclear; + adt_tpm_fieldupgrade_t adt_tpm_fieldupgrade; + adt_tpm_forceclear_t adt_tpm_forceclear; + adt_tpm_ownerclear_t adt_tpm_ownerclear; + adt_tpm_ownersetdisable_t adt_tpm_ownersetdisable; + adt_tpm_physicaldeactivate_t adt_tpm_physicaldeactivate; + adt_tpm_physicaldisable_t adt_tpm_physicaldisable; + adt_tpm_physicalenable_t adt_tpm_physicalenable; + adt_tpm_physicalpresence_t adt_tpm_physicalpresence; + adt_tpm_resetlockvalue_t adt_tpm_resetlockvalue; + adt_tpm_selftestfull_t adt_tpm_selftestfull; + adt_tpm_setoperatorauth_t adt_tpm_setoperatorauth; + adt_tpm_setownerinstall_t adt_tpm_setownerinstall; + adt_tpm_settempdeactivated_t adt_tpm_settempdeactivated; + adt_tpm_takeownership_t adt_tpm_takeownership; + adt_uadmin_config_t adt_uadmin_config; + adt_uadmin_dump_t adt_uadmin_dump; + adt_uadmin_freeze_t adt_uadmin_freeze; + adt_uadmin_ftrace_t adt_uadmin_ftrace; + adt_uadmin_reboot_t adt_uadmin_reboot; + adt_uadmin_remount_t adt_uadmin_remount; + adt_uadmin_shutdown_t adt_uadmin_shutdown; + adt_uadmin_swapctl_t adt_uadmin_swapctl; + adt_uadmin_thaw_t adt_uadmin_thaw; + adt_uauth_t adt_uauth; + adt_usermgr_add_t adt_usermgr_add; + adt_usermgr_delete_t adt_usermgr_delete; + adt_usermgr_modify_t adt_usermgr_modify; + adt_vscan_quarantine_t adt_vscan_quarantine; + adt_zlogin_t adt_zlogin; + adt_zone_state_t adt_zone_state; +}; + + +#ifndef ADT_PRIVATE +#define ADT_PRIVATE + +/* + * These interfaces are project private and will change without + * notice as needed for the Solaris Audit project. + */ + +extern void adt_get_auid(const adt_session_data_t *, au_id_t *); +extern void adt_set_auid(const adt_session_data_t *, const au_id_t); + +extern void adt_get_mask(const adt_session_data_t *, au_mask_t *); +extern void adt_set_mask(const adt_session_data_t *, const au_mask_t *); + +extern void adt_get_termid(const adt_session_data_t *, au_tid_addr_t *); +extern void adt_set_termid(const adt_session_data_t *, + const au_tid_addr_t *); + +extern void adt_get_asid(const adt_session_data_t *, au_asid_t *); +extern void adt_set_asid(const adt_session_data_t *, const au_asid_t); +extern au_asid_t adt_get_unique_id(au_id_t); +extern void adt_load_table(const adt_session_data_t *, adt_translation_t **, + void (*preload)(au_event_t, adt_event_data_t *)); + +extern void adt_preload(au_event_t, adt_event_data_t *); + +extern adt_translation_t *adt_xlate_table[]; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _ADT_EVENT_H */ diff --git a/illumos-x86_64/usr/include/bsm/audit.h b/illumos-x86_64/usr/include/bsm/audit.h new file mode 100644 index 00000000..66539662 --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/audit.h @@ -0,0 +1,609 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2022 Garrett D'Amore + */ + +/* + * This file contains the declarations of the various data structures + * used by the auditing module(s). + */ + +#ifndef _BSM_AUDIT_H +#define _BSM_AUDIT_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include /* for shmid_ds structure */ +#include /* for semid_ds structure */ +#include /* for msqid_ds structure */ +#include /* using atomics */ +#include + +/* + * Audit conditions, statements reguarding what's to be done with + * audit records. None of the "global state" is returned by an + * auditconfig -getcond call. AUC_NOSPACE no longer seems used. + */ +/* global state */ +#define AUC_UNSET 0 /* on/off hasn't been decided */ +#define AUC_ENABLED 1 /* loaded and enabled */ +/* pseudo state used in libbsm */ +#define AUC_DISABLED 0x100 /* c2audit module is excluded */ +/* local zone state */ +#define AUC_AUDITING 0x1 /* audit daemon is active */ +#define AUC_NOAUDIT 0x2 /* audit daemon is not active */ +#define AUC_INIT_AUDIT 0x4 /* audit ready but auditd has not run */ +#define AUC_NOSPACE 0x8 /* audit enabled, no space for audit records */ + +/* + * The user id -2 is never audited - in fact, a setauid(AU_NOAUDITID) + * will turn off auditing. + */ +#define AU_NOAUDITID ((au_id_t)-2) + +/* + * success/failure bits for asynchronous events + */ + +#define AUM_SUCC 1 /* use the system success preselection mask */ +#define AUM_FAIL 2 /* use the system failure preselection mask */ + + +/* + * Defines for event modifier field + */ +#define PAD_READ 0x0001 /* object read */ +#define PAD_WRITE 0x0002 /* object write */ +#define PAD_NONATTR 0x4000 /* non-attributable event */ +#define PAD_FAILURE 0x8000 /* fail audit event */ +#define PAD_SPRIVUSE 0x0080 /* successfully used privileged */ +#define PAD_FPRIVUSE 0x0100 /* failed use of privileged */ + +/* + * Some typedefs for the fundamentals + */ +typedef uint_t au_asid_t; +typedef uint_t au_class_t; +typedef ushort_t au_event_t; +typedef ushort_t au_emod_t; +typedef uid_t au_id_t; + +/* + * An audit event mask. + */ +#define AU_MASK_ALL 0xFFFFFFFF /* all bits on for unsigned int */ +#define AU_MASK_NONE 0x0 /* all bits off = no:invalid class */ + +struct au_mask { + unsigned int am_success; /* success bits */ + unsigned int am_failure; /* failure bits */ +}; +typedef struct au_mask au_mask_t; +#define as_success am_success +#define as_failure am_failure + +/* + * The structure of the terminal ID (ipv4) + */ +struct au_tid { + dev_t port; + uint_t machine; +}; + +#if defined(_SYSCALL32) +struct au_tid32 { + uint_t port; + uint_t machine; +}; + +typedef struct au_tid32 au_tid32_t; +#endif + +typedef struct au_tid au_tid_t; + +/* + * The structure of the terminal ID (ipv6) + */ +struct au_tid_addr { + dev_t at_port; + uint_t at_type; + uint_t at_addr[4]; +}; + +struct au_port_s { + uint32_t at_major; /* major # */ + uint32_t at_minor; /* minor # */ +}; +typedef struct au_port_s au_port_t; + +struct au_tid_addr64 { + au_port_t at_port; + uint_t at_type; + uint_t at_addr[4]; +}; +typedef struct au_tid_addr64 au_tid64_addr_t; + +#if defined(_SYSCALL32) +struct au_tid_addr32 { + uint_t at_port; + uint_t at_type; + uint_t at_addr[4]; +}; + +typedef struct au_tid_addr32 au_tid32_addr_t; +#endif + +typedef struct au_tid_addr au_tid_addr_t; + +struct au_ip { + uint16_t at_r_port; /* remote port */ + uint16_t at_l_port; /* local port */ + uint32_t at_type; /* AU_IPv4,... */ + uint32_t at_addr[4]; /* remote IP */ +}; +typedef struct au_ip au_ip_t; + +/* + * Generic network address structure + */ +struct au_generic_tid { + uchar_t gt_type; /* AU_IPADR, AU_DEVICE,... */ + union { + au_ip_t at_ip; + au_port_t at_dev; + } gt_adr; +}; +typedef struct au_generic_tid au_generic_tid_t; + +/* + * au_generic_tid_t gt_type values + * 0 is reserved for uninitialized data + */ +#define AU_IPADR 1 +#define AU_ETHER 2 +#define AU_DEVICE 3 + +/* + * at_type values - address length used to identify address type + */ +#define AU_IPv4 4 /* ipv4 type IP address */ +#define AU_IPv6 16 /* ipv6 type IP address */ + +/* + * Compatability with SunOS 4.x BSM module + * + * New code should not contain audit_state_t, + * au_state_t, nor au_termid as these types + * may go away in future releases. + * + * typedef new-5.x-bsm-name old-4.x-bsm-name + */ + +typedef au_class_t au_state_t; +typedef au_mask_t audit_state_t; +typedef au_id_t auid_t; +#define ai_state ai_mask; + +/* + * Opcodes for bsm system calls + */ + +#define BSM_GETAUID 19 +#define BSM_SETAUID 20 +#define BSM_GETAUDIT 21 +#define BSM_SETAUDIT 22 +/* 23 OBSOLETE */ +/* 24 OBSOLETE */ +#define BSM_AUDIT 25 +/* 26 OBSOLETE */ +/* 27 EOL announced for Sol 10 */ +/* 28 OBSOLETE */ +#define BSM_AUDITCTL 29 +/* 30 OBSOLETE */ +/* 31 OBSOLETE */ +/* 32 OBSOLETE */ +/* 33 OBSOLETE */ +/* 34 OBSOLETE */ +#define BSM_GETAUDIT_ADDR 35 +#define BSM_SETAUDIT_ADDR 36 +#define BSM_AUDITDOOR 37 + +/* + * auditon(2) commands + */ +#define A_GETPOLICY 2 /* get audit policy */ +#define A_SETPOLICY 3 /* set audit policy */ +#define A_GETKMASK 4 /* get non-attributable event audit mask */ +#define A_SETKMASK 5 /* set non-attributable event audit mask */ +#define A_GETQCTRL 6 /* get kernel audit queue ctrl parameters */ +#define A_SETQCTRL 7 /* set kernel audit queue ctrl parameters */ +#define A_GETCWD 8 /* get process current working directory */ +#define A_GETCAR 9 /* get process current active root */ +#define A_GETSTAT 12 /* get audit statistics */ +#define A_SETSTAT 13 /* (re)set audit statistics */ +#define A_SETUMASK 14 /* set preselection mask for procs with auid */ +#define A_SETSMASK 15 /* set preselection mask for procs with asid */ +#define A_GETCOND 20 /* get audit system on/off condition */ +#define A_SETCOND 21 /* set audit system on/off condition */ +#define A_GETCLASS 22 /* get audit event to class mapping */ +#define A_SETCLASS 23 /* set audit event to class mapping */ +#define A_GETPINFO 24 /* get audit info for an arbitrary pid */ +#define A_SETPMASK 25 /* set preselection mask for an given pid */ +#define A_GETPINFO_ADDR 28 /* get audit info for an arbitrary pid */ +#define A_GETKAUDIT 29 /* get kernel audit characteristics */ +#define A_SETKAUDIT 30 /* set kernel audit characteristics */ +#define A_GETAMASK 31 /* set user default audit event mask */ +#define A_SETAMASK 32 /* get user default audit event mask */ + +/* + * Audit Policy parameters (32 bits) + */ +#define AUDIT_CNT 0x0001 /* do NOT sleep undelivered synch events */ +#define AUDIT_AHLT 0x0002 /* HALT machine on undelivered async event */ +#define AUDIT_ARGV 0x0004 /* include argv with execv system call events */ +#define AUDIT_ARGE 0x0008 /* include arge with execv system call events */ +#define AUDIT_SEQ 0x0010 /* include sequence attribute */ +#define AUDIT_GROUP 0x0040 /* include group attribute with each record */ +#define AUDIT_TRAIL 0x0080 /* include trailer token */ +#define AUDIT_PATH 0x0100 /* allow multiple paths per event */ +#define AUDIT_SCNT 0x0200 /* sleep user events but not kernel events */ +#define AUDIT_PUBLIC 0x0400 /* audit even "public" files */ +#define AUDIT_ZONENAME 0x0800 /* emit zonename token */ +#define AUDIT_PERZONE 0x1000 /* auditd and audit queue for each zone */ +#define AUDIT_WINDATA_DOWN 0x2000 /* include paste downgraded data */ +#define AUDIT_WINDATA_UP 0x4000 /* include paste upgraded data */ + +/* + * If AUDIT_GLOBAL changes, corresponding changes are required in + * audit_syscalls.c's setpolicy(). + */ +#define AUDIT_GLOBAL (AUDIT_AHLT | AUDIT_PERZONE) +#define AUDIT_LOCAL (AUDIT_CNT | AUDIT_ARGV | AUDIT_ARGE |\ + AUDIT_SEQ | AUDIT_GROUP | AUDIT_TRAIL | AUDIT_PATH |\ + AUDIT_PUBLIC | AUDIT_SCNT | AUDIT_ZONENAME |\ + AUDIT_WINDATA_DOWN | AUDIT_WINDATA_UP) + +/* + * Kernel audit queue control parameters + * + * audit record recording blocks at hiwater # undelived records + * audit record recording resumes at lowwater # undelivered audit records + * bufsz determines how big the data xfers will be to the audit trail + */ +struct au_qctrl { + size_t aq_hiwater; /* kernel audit queue, high water mark */ + size_t aq_lowater; /* kernel audit queue, low water mark */ + size_t aq_bufsz; /* kernel audit queue, write size to trail */ + clock_t aq_delay; /* delay before flushing audit queue */ +}; + +#if defined(_SYSCALL32) +struct au_qctrl32 { + size32_t aq_hiwater; + size32_t aq_lowater; + size32_t aq_bufsz; + clock32_t aq_delay; +}; +#endif + + +/* + * default values of hiwater and lowater (note hi > lo) + */ +#define AQ_HIWATER 100 +#define AQ_MAXHIGH 100000 +#define AQ_LOWATER 10 +#define AQ_BUFSZ 8192 +#define AQ_MAXBUFSZ 1048576 +#define AQ_DELAY 20 +#define AQ_MAXDELAY 20000 + +struct auditinfo { + au_id_t ai_auid; + au_mask_t ai_mask; + au_tid_t ai_termid; + au_asid_t ai_asid; +}; + +#if defined(_SYSCALL32) +struct auditinfo32 { + au_id_t ai_auid; + au_mask_t ai_mask; + au_tid32_t ai_termid; + au_asid_t ai_asid; +}; + +typedef struct auditinfo32 auditinfo32_t; +#endif + +typedef struct auditinfo auditinfo_t; + +struct k_auditinfo_addr { + au_id_t ai_auid; + au_mask_t ai_amask; /* user default preselection mask */ + au_mask_t ai_namask; /* non-attributable mask */ + au_tid_addr_t ai_termid; + au_asid_t ai_asid; +}; +typedef struct k_auditinfo_addr k_auditinfo_addr_t; + +struct auditinfo_addr { + au_id_t ai_auid; + au_mask_t ai_mask; + au_tid_addr_t ai_termid; + au_asid_t ai_asid; +}; + +struct auditinfo_addr64 { + au_id_t ai_auid; + au_mask_t ai_mask; + au_tid64_addr_t ai_termid; + au_asid_t ai_asid; +}; +typedef struct auditinfo_addr64 auditinfo64_addr_t; + +#if defined(_SYSCALL32) +struct auditinfo_addr32 { + au_id_t ai_auid; + au_mask_t ai_mask; + au_tid32_addr_t ai_termid; + au_asid_t ai_asid; +}; + +typedef struct auditinfo_addr32 auditinfo32_addr_t; +#endif + +typedef struct auditinfo_addr auditinfo_addr_t; + +struct auditpinfo { + pid_t ap_pid; + au_id_t ap_auid; + au_mask_t ap_mask; + au_tid_t ap_termid; + au_asid_t ap_asid; +}; + +#if defined(_SYSCALL32) +struct auditpinfo32 { + pid_t ap_pid; + au_id_t ap_auid; + au_mask_t ap_mask; + au_tid32_t ap_termid; + au_asid_t ap_asid; +}; +#endif + + +struct auditpinfo_addr { + pid_t ap_pid; + au_id_t ap_auid; + au_mask_t ap_mask; + au_tid_addr_t ap_termid; + au_asid_t ap_asid; +}; + +#if defined(_SYSCALL32) +struct auditpinfo_addr32 { + pid_t ap_pid; + au_id_t ap_auid; + au_mask_t ap_mask; + au_tid32_addr_t ap_termid; + au_asid_t ap_asid; +}; +#endif + + +struct au_evclass_map { + au_event_t ec_number; + au_class_t ec_class; +}; +typedef struct au_evclass_map au_evclass_map_t; + +/* + * Audit stat structures (used to be in audit_stat.h + */ + +struct audit_stat { + unsigned int as_version; /* version of kernel audit code */ + unsigned int as_numevent; /* number of kernel audit events */ + uint32_t as_generated; /* # records processed */ + uint32_t as_nonattrib; /* # non-attributed records produced */ + uint32_t as_kernel; /* # records produced by kernel */ + uint32_t as_audit; /* # records processed by audit(2) */ + uint32_t as_auditctl; /* # records processed by auditctl(2) */ + uint32_t as_enqueue; /* # records put onto audit queue */ + uint32_t as_written; /* # records written to audit trail */ + uint32_t as_wblocked; /* # times write blked on audit queue */ + uint32_t as_rblocked; /* # times read blked on audit queue */ + uint32_t as_dropped; /* # of dropped audit records */ + uint32_t as_totalsize; /* total number bytes of audit data */ + uint32_t as_memused; /* no longer used */ +}; +typedef struct audit_stat au_stat_t; + +/* get kernel audit context dependent on AUDIT_PERZONE policy */ +#define GET_KCTX_PZ (audit_policy & AUDIT_PERZONE) ?\ + curproc->p_zone->zone_audit_kctxt :\ + global_zone->zone_audit_kctxt +/* get kernel audit context of global zone */ +#define GET_KCTX_GZ global_zone->zone_audit_kctxt +/* get kernel audit context of non-global zone */ +#define GET_KCTX_NGZ curproc->p_zone->zone_audit_kctxt + +#define AS_INC(a, b, c) atomic_add_32(&(c->auk_statistics.a), (b)) +#define AS_DEC(a, b, c) atomic_add_32(&(c->auk_statistics.a), -(b)) + +/* + * audit token IPC types (shm, sem, msg) [for ipc attribute] + */ + +#define AT_IPC_MSG ((char)1) /* message IPC id */ +#define AT_IPC_SEM ((char)2) /* semaphore IPC id */ +#define AT_IPC_SHM ((char)3) /* shared memory IPC id */ + +#if defined(_KERNEL) + +#ifdef __cplusplus +} +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct fcntla; +struct t_audit_data; +struct audit_path; +struct priv_set; +struct devplcysys; + +struct auditcalls { + long code; + long a1; + long a2; + long a3; + long a4; + long a5; +}; + +int audit(caddr_t, int); +int auditsys(struct auditcalls *, union rval *); /* fake stub */ +void audit_cryptoadm(int, char *, crypto_mech_name_t *, + uint_t, uint_t, uint32_t, int); +void audit_init(void); +void audit_init_module(void); +void audit_newproc(struct proc *); +void audit_pfree(struct proc *); +void audit_thread_create(kthread_id_t); +void audit_thread_free(kthread_id_t); +int audit_savepath(struct pathname *, struct vnode *, struct vnode *, + int, cred_t *); +void audit_anchorpath(struct pathname *, int); +void audit_symlink(struct pathname *, struct pathname *); +void audit_symlink_create(struct vnode *, char *, char *, int); +int object_is_public(struct vattr *); +void audit_attributes(struct vnode *); +void audit_falloc(struct file *); +void audit_unfalloc(struct file *); +void audit_exit(int, int); +void audit_core_start(int); +void audit_core_finish(int); +void audit_strgetmsg(struct vnode *, struct strbuf *, struct strbuf *, + unsigned char *, int *, int); +void audit_strputmsg(struct vnode *, struct strbuf *, struct strbuf *, + unsigned char, int, int); +void audit_closef(struct file *); +void audit_setf(struct file *, int); +void audit_reboot(void); +void audit_vncreate_start(void); +void audit_setfsat_path(int argnum); +void audit_vncreate_finish(struct vnode *, int); +void audit_exec(const char *, const char *, ssize_t, ssize_t, cred_t *); +void audit_enterprom(int); +void audit_exitprom(int); +void audit_chdirec(struct vnode *, struct vnode **); +void audit_sock(int, struct queue *, struct msgb *, int); +int audit_start(unsigned int, unsigned int, uint32_t, int, klwp_t *); +void audit_finish(unsigned int, unsigned int, int, union rval *); +int audit_async_start(label_t *, au_event_t, int); +void audit_async_finish(caddr_t *, au_event_t, au_emod_t, timestruc_t *); +void audit_async_discard_backend(void *); +void audit_async_done(caddr_t *, int); +void audit_async_drop(caddr_t *, int); + +#ifndef AUK_CONTEXT_T +#define AUK_CONTEXT_T +typedef struct au_kcontext au_kcontext_t; +#endif + +/* Zone audit context setup routine */ +void au_zone_setup(void); + +/* + * c2audit module states + */ +#define C2AUDIT_DISABLED 0 /* c2audit module excluded in /etc/system */ +#define C2AUDIT_UNLOADED 1 /* c2audit module not loaded */ +#define C2AUDIT_LOADED 2 /* c2audit module loaded */ + +uint32_t audit_getstate(void); +int au_zone_getstate(const au_kcontext_t *); + +/* The audit mask defining in which case is auditing enabled */ +#define AU_AUDIT_MASK (AUC_AUDITING | AUC_NOSPACE) + +/* + * Get the given zone audit status. zcontext != NULL serves + * as a protection when c2audit module is not loaded. + */ +#define AU_ZONE_AUDITING(zcontext) \ + (audit_active == C2AUDIT_LOADED && \ + ((AU_AUDIT_MASK) & au_zone_getstate((zcontext)))) + +/* + * Get auditing status + */ +#define AU_AUDITING() (audit_getstate()) + +int audit_success(au_kcontext_t *, struct t_audit_data *, int, cred_t *); +int auditme(au_kcontext_t *, struct t_audit_data *, au_state_t); +void audit_fixpath(struct audit_path *, int); +void audit_ipc(int, int, void *); +void audit_ipcget(int, void *); +void audit_fdsend(int, struct file *, int); +void audit_fdrecv(int, struct file *); +void audit_priv(int, const struct priv_set *, int); +void audit_setppriv(int, int, const struct priv_set *, const cred_t *); +void audit_psecflags(proc_t *, psecflagwhich_t, + const secflagdelta_t *); +void audit_devpolicy(int, const struct devplcysys *); +void audit_update_context(proc_t *, cred_t *); +void audit_pf_policy(int, cred_t *, netstack_t *, char *, boolean_t, int, + pid_t); +void audit_sec_attributes(caddr_t *, struct vnode *); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _BSM_AUDIT_H */ diff --git a/illumos-x86_64/usr/include/bsm/audit_kernel.h b/illumos-x86_64/usr/include/bsm/audit_kernel.h new file mode 100644 index 00000000..87dc3d75 --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/audit_kernel.h @@ -0,0 +1,436 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _BSM_AUDIT_KERNEL_H +#define _BSM_AUDIT_KERNEL_H + + +/* + * This file contains the basic auditing control structure definitions. + */ + +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This table contains the mapping from the system call ID to a corresponding + * audit event. + * + * au_init() is a function called at the beginning of the system call that + * performs any necessary setup/processing. It maps the call into the + * appropriate event, depending on the system call arguments. It is called + * by audit_start() from trap.c . + * + * au_event is the audit event associated with the system call. Most of the + * time it will map directly from the system call i.e. There is one system + * call associated with the event. In some cases, such as shmsys, or open, + * the au_start() function will map the system call to more than one event, + * depending on the system call arguments. + * + * au_start() is a function that provides per system call processing at the + * beginning of a system call. It is mainly concerned with preseving the + * audit record components that may be altered so that we can determine + * what the original paramater was before as well as after the system call. + * It is possible that au_start() may be taken away. It might be cleaner to + * define flags in au_ctrl to save a designated argument. For the moment we + * support both mechanisms, however the use of au_start() will be reviewed + * for 4.1.1 and CMW and ZEUS to see if such a general method is justified. + * + * au_finish() is a function that provides per system call processing at the + * completion of a system call. In certain circumstances, the type of audit + * event depends on intermidiate results during the processing of the system + * call. It is called in audit_finish() from trap.c . + * + * au_ctrl is a control vector that indicates what processing might have to + * be performed, even if there is no auditing for this system call. At + * present this is mostly for path processing for chmod, chroot. We need to + * process the path information in vfs_lookup, even when we are not auditing + * the system call in the case of chdir and chroot. + */ +/* + * Defines for au_ctrl + */ +#define S2E_SP TAD_SAVPATH /* save path for later use */ +#define S2E_MLD TAD_MLD /* only one lookup per system call */ +#define S2E_NPT TAD_NOPATH /* force no path in audit record */ +#define S2E_PUB TAD_PUBLIC_EV /* syscall is defined as a public op */ + +/* + * At present, we are using the audit classes imbedded with in the kernel. Each + * event has a bit mask determining which classes the event is associated. + * The table audit_e2s maps the audit event ID to the audit state. + * + * Note that this may change radically. If we use a bit vector for the audit + * class, we can allow granularity at the event ID for each user. In this + * case, the vector would be determined at user level and passed to the kernel + * via the setaudit system call. + */ + +/* + * The audit_pad structure holds paths for the current root and directory + * for the process, as well as for open files and directly manipulated objects. + * The reference count minimizes data copies since the process's current + * directory changes very seldom. + */ +struct audit_path { + uint_t audp_ref; /* reference count */ + uint_t audp_size; /* allocated size of this structure */ + uint_t audp_cnt; /* number of path sections */ + char *audp_sect[1]; /* path section pointers */ + /* audp_sect[0] is the path name */ + /* audp_sect[1+] are attribute paths */ +}; + +/* + * The structure of the terminal ID within the kernel is different from the + * terminal ID in user space. It is a combination of port and IP address. + */ + +struct au_termid { + dev_t at_port; + uint_t at_type; + uint_t at_addr[4]; +}; +typedef struct au_termid au_termid_t; + +/* + * Attributes for deferring the queuing of an event. + */ +typedef struct au_defer_info { + struct au_defer_info *audi_next; /* next on linked list */ + void *audi_ad; /* audit record */ + au_event_t audi_e_type; /* audit event id */ + au_emod_t audi_e_mod; /* audit event modifier */ + int audi_flag; /* au_close*() flags */ + timestruc_t audi_atime; /* audit event timestamp */ +} au_defer_info_t; + +/* + * The structure p_audit_data hangs off of the process structure. It contains + * all of the audit information necessary to manage the audit record generation + * for each process. + * + * The pad_lock is constructed in the kmem_cache; the rest is combined + * in a sub structure so it can be copied/zeroed in one statement. + * + * The members have been reordered for maximum packing on 64 bit Solaris. + */ +struct p_audit_data { + kmutex_t pad_lock; /* lock pad data during changes */ + struct _pad_data { + struct audit_path *pad_root; /* process root path */ + struct audit_path *pad_cwd; /* process cwd path */ + au_mask_t pad_newmask; /* pending new mask */ + int pad_flags; + } pad_data; +}; +typedef struct p_audit_data p_audit_data_t; + +#define pad_root pad_data.pad_root +#define pad_cwd pad_data.pad_cwd +#define pad_newmask pad_data.pad_newmask +#define pad_flags pad_data.pad_flags + +/* + * Defines for process audit flags (pad_flags) + */ +#define PAD_SETMASK 0x00000001 /* need to complete pending setmask */ + +extern kmem_cache_t *au_pad_cache; + +/* + * Defines for thread audit control/status flags (tad_ctrl) + */ +#define TAD_ABSPATH 0x00000001 /* path from lookup is absolute */ +#define TAD_ATCALL 0x00000002 /* *at() syscall, like openat() */ +#define TAD_ATTPATH 0x00000004 /* attribute file lookup */ +#define TAD_CORE 0x00000008 /* save attribute during core dump */ +#define TAD_ERRJMP 0x00000010 /* abort record generation on error */ +#define TAD_MLD 0x00000020 /* system call involves MLD */ +#define TAD_NOATTRB 0x00000040 /* do not automatically add attribute */ +#define TAD_NOAUDIT 0x00000080 /* discard audit record */ +#define TAD_NOPATH 0x00000100 /* force no paths in audit record */ +#define TAD_PATHFND 0x00000200 /* found path, don't retry lookup */ +#define TAD_PUBLIC_EV 0x00000400 /* syscall is defined as a public op */ +#define TAD_SAVPATH 0x00000800 /* save path for further processing */ +#define TAD_TRUE_CREATE 0x00001000 /* true create, file not found */ + +/* + * The structure t_audit_data hangs off of the thread structure. It contains + * all of the audit information necessary to manage the audit record generation + * for each thread. + * + */ + +struct t_audit_data { + kthread_id_t tad_thread; /* DEBUG pointer to parent thread */ + unsigned int tad_scid; /* system call ID for finish */ + au_event_t tad_event; /* event for audit record */ + au_emod_t tad_evmod; /* event modifier for audit record */ + int tad_ctrl; /* audit control/status flags */ + void *tad_errjmp; /* error longjmp (audit record aborted) */ + int tad_flag; /* to audit or not to audit */ + uint32_t tad_audit; /* auditing enabled/disabled */ + struct audit_path *tad_aupath; /* captured at vfs_lookup */ + struct audit_path *tad_atpath; /* openat prefix, path of fd */ + caddr_t tad_ad; /* base of accumulated audit data */ + au_defer_info_t *tad_defer_head; /* queue of records to defer */ + /* until syscall end: */ + au_defer_info_t *tad_defer_tail; /* tail of defer queue */ + priv_set_t tad_sprivs; /* saved (success) used privs */ + priv_set_t tad_fprivs; /* saved (failed) used privs */ +}; +typedef struct t_audit_data t_audit_data_t; + +/* + * The f_audit_data structure hangs off of the file structure. It contains + * three fields of data. The audit ID, the audit state, and a path name. + */ + +struct f_audit_data { + kthread_id_t fad_thread; /* DEBUG creating thread */ + int fad_flags; /* audit control flags */ + struct audit_path *fad_aupath; /* path from vfs_lookup */ +}; +typedef struct f_audit_data f_audit_data_t; + +#define FAD_READ 0x0001 /* read system call seen */ +#define FAD_WRITE 0x0002 /* write system call seen */ + +#define P2A(p) (p->p_audit_data) +#define T2A(t) (t->t_audit_data) +#define U2A(u) (curthread->t_audit_data) +#define F2A(f) (f->f_audit_data) + +#define u_ad ((U2A(u))->tad_ad) +#define ad_ctrl ((U2A(u))->tad_ctrl) +#define ad_flag ((U2A(u))->tad_flag) + +#define AU_BUFSIZE 128 /* buffer size for the buffer pool */ + +struct au_buff { + char buf[AU_BUFSIZE]; + struct au_buff *next_buf; + struct au_buff *next_rec; + ushort_t rec_len; + uchar_t len; + uchar_t flag; +}; + +typedef struct au_buff au_buff_t; + +/* + * Kernel audit queue structure. + */ +struct audit_queue { + au_buff_t *head; /* head of queue */ + au_buff_t *tail; /* tail of queue */ + ssize_t cnt; /* number elements on queue */ + size_t hiwater; /* high water mark to block */ + size_t lowater; /* low water mark to restart */ + size_t bufsz; /* audit trail write buffer size */ + size_t buflen; /* audit trail buffer length in use */ + clock_t delay; /* delay before flushing queue */ + int wt_block; /* writer is blocked (1) */ + int rd_block; /* reader is blocked (1) */ + kmutex_t lock; /* mutex lock for queue modification */ + kcondvar_t write_cv; /* sleep structure for write block */ + kcondvar_t read_cv; /* sleep structure for read block */ +}; + + +union rval; +struct audit_s2e { + au_event_t (*au_init)(au_event_t); + /* convert au_event to real audit event ID */ + + int au_event; /* default audit event for this system call */ + void (*au_start)(struct t_audit_data *); + /* pre-system call audit processing */ + void (*au_finish)(struct t_audit_data *, int, union rval *); + /* post-system call audit processing */ + int au_ctrl; /* control flags for auditing actions */ +}; + +extern struct audit_s2e audit_s2e[]; + +#define AUK_VALID 0x5A5A5A5A +#define AUK_INVALID 0 +/* + * per zone audit context + */ +struct au_kcontext { + uint32_t auk_valid; + zoneid_t auk_zid; + + boolean_t auk_hostaddr_valid; + int auk_sequence; + int auk_auditstate; + int auk_output_active; + struct vnode *auk_current_vp; + uint32_t auk_policy; + + struct audit_queue auk_queue; + + au_dbuf_t *auk_dbuffer; /* auditdoor output */ + + au_stat_t auk_statistics; + + k_auditinfo_addr_t auk_info; + kmutex_t auk_eagain_mutex; /* door call retry */ + kcondvar_t auk_eagain_cv; + + taskq_t *auk_taskq; /* output thread */ + + /* Only one audit svc per zone at a time */ + /* With the elimination of auditsvc, can this also go? see 6648414 */ + kmutex_t auk_svc_lock; + + au_state_t auk_ets[MAX_KEVENTS + 1]; +}; +#ifndef AUK_CONTEXT_T +#define AUK_CONTEXT_T +typedef struct au_kcontext au_kcontext_t; +#endif + +extern zone_key_t au_zone_key; + +/* + * Kernel auditing external variables + */ +extern uint32_t audit_policy; +extern int audit_active; + +extern struct audit_queue au_queue; +extern struct p_audit_data *pad0; +extern struct t_audit_data *tad0; + +/* + * audit_path support routines + */ +void au_pathhold(struct audit_path *); +void au_pathrele(struct audit_path *); +struct audit_path *au_pathdup(const struct audit_path *, int, int); + +void au_pad_init(void); + +int auditctl(int cmd, caddr_t data, int length); +int auditdoor(int fd); +int getauid(caddr_t); +int setauid(caddr_t); +int getaudit(caddr_t); +int getaudit_addr(caddr_t, int); +int setaudit(caddr_t); +int setaudit_addr(caddr_t, int); + +/* + * Macros to hide asynchronous, non-blocking audit record start and finish + * processing. + * + * NOTE: must be used in (void) funcction () { ... } + */ + +#define AUDIT_ASYNC_START(rp, audit_event, sorf) \ +{ \ + label_t jb; \ + if (setjmp(&jb)) { \ + /* cleanup any residual audit data */ \ + audit_async_drop((caddr_t *)&(rp), 0); \ + return; \ + } \ + /* auditing enabled and we're preselected for this event? */ \ + if (audit_async_start(&jb, audit_event, sorf)) { \ + return; \ + } \ +} + +#define AUDIT_ASYNC_FINISH(rp, audit_event, event_modifier, event_time) \ + audit_async_finish((caddr_t *)&(rp), audit_event, event_modifier, \ + event_time); + + +#ifdef _KERNEL +au_buff_t *au_get_buff(void), *au_free_buff(au_buff_t *); +#endif + +/* + * Macro for uniform "subject" token(s) generation + */ +#define AUDIT_SETSUBJ_GENERIC(u, c, a, k, p) \ + (au_write((u), au_to_subject(crgetuid(c), \ + crgetgid(c), crgetruid(c), crgetrgid(c), \ + p, (a)->ai_auid, (a)->ai_asid, \ + &((a)->ai_termid)))); \ + ((is_system_labeled()) ? au_write((u), \ + au_to_label(CR_SL((c)))) : (void) 0); \ + (((k)->auk_policy & AUDIT_GROUP) ? au_write((u),\ + au_to_groups(crgetgroups(c), \ + crgetngroups(c))) : (void) 0) + +#define AUDIT_SETSUBJ(u, c, a, k) \ + AUDIT_SETSUBJ_GENERIC(u, c, a, k, curproc->p_pid) + +#define AUDIT_SETPROC_GENERIC(u, c, a, p) \ + (au_write((u), au_to_process(crgetuid(c), \ + crgetgid(c), crgetruid(c), crgetrgid(c), \ + p, (a)->ai_auid, (a)->ai_asid, \ + &((a)->ai_termid)))); + +#define AUDIT_SETPROC(u, c, a) \ + AUDIT_SETPROC_GENERIC(u, c, a, curproc->p_pid) + +/* + * Macros for type conversion + */ + +/* au_membuf head, to typed data */ +#define memtod(x, t) ((t)x->buf) + +/* au_membuf types */ +#define MT_FREE 0 /* should be on free list */ +#define MT_DATA 1 /* dynamic (data) allocation */ + +/* flags to au_memget */ +#define DONTWAIT 0 +#define WAIT 1 + +#define AU_PACK 1 /* pack data in au_append_rec() */ +#define AU_LINK 0 /* link data in au_append_rec() */ + +/* flags to async routines */ +#define AU_BACKEND 1 /* called from softcall backend */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BSM_AUDIT_KERNEL_H */ diff --git a/illumos-x86_64/usr/include/bsm/audit_kevents.h b/illumos-x86_64/usr/include/bsm/audit_kevents.h new file mode 100644 index 00000000..a7771eed --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/audit_kevents.h @@ -0,0 +1,366 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _BSM_AUDIT_KEVENTS_H +#define _BSM_AUDIT_KEVENTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Audit event numbers. + * + * 0 Reserved as an invalid event number. + * 1 - 511 Allocated for Solaris kernel + * 512 - 2047 (reserved but not allocated) + * 2048 - 32767 Reserved for the Solaris TCB application. + * 32768 - 65535 Available for third party applications. + * + * NOTE: libbsm/audit_event.txt must be updated elsewhere when changes + * are made to kernel events. + */ + +#define AUE_NULL 0 /* =no indir system call */ +#define AUE_EXIT 1 /* =ps exit(2) */ +#define AUE_FORKALL 2 /* =ps forkall(2) */ +#define AUE_OPEN 3 /* =no open(2): place holder */ +#define AUE_CREAT 4 /* =no obsolete */ +#define AUE_LINK 5 /* =fc link(2) */ +#define AUE_UNLINK 6 /* =fd unlink(2) */ +#define AUE_EXEC 7 /* =no obsolete */ +#define AUE_CHDIR 8 /* =pm chdir(2) */ +#define AUE_MKNOD 9 /* =fc mknod(2) */ +#define AUE_CHMOD 10 /* =fm chmod(2) */ +#define AUE_CHOWN 11 /* =fm chown(2) */ +#define AUE_UMOUNT 12 /* =as umount(2): old version */ +#define AUE_JUNK 13 /* =no non existant event */ +#define AUE_ACCESS 14 /* =fa access(2) */ +#define AUE_KILL 15 /* =pm kill(2) */ +#define AUE_STAT 16 /* =fa stat(2) */ +#define AUE_LSTAT 17 /* =fa lstat(2) */ +#define AUE_ACCT 18 /* =as acct(2) */ +#define AUE_MCTL 19 /* =no mctl(2) */ +#define AUE_REBOOT 20 /* =no reboot(2) */ +#define AUE_SYMLINK 21 /* =fc symlink(2) */ +#define AUE_READLINK 22 /* =fr readlink(2) */ +#define AUE_EXECVE 23 /* =ps,ex execve(2) */ +#define AUE_CHROOT 24 /* =pm chroot(2) */ +#define AUE_VFORK 25 /* =ps vfork(2) */ +#define AUE_SETGROUPS 26 /* =pm setgroups(2) */ +#define AUE_SETPGRP 27 /* =pm setpgrp(2) */ +#define AUE_SWAPON 28 /* =no swapon(2) */ +#define AUE_SETHOSTNAME 29 /* =no sethostname(2) */ +#define AUE_FCNTL 30 /* =fm fcntl(2) */ +#define AUE_SETPRIORITY 31 /* =no setpriority(2) */ +#define AUE_CONNECT 32 /* =nt connect(2) */ +#define AUE_ACCEPT 33 /* =nt accept(2) */ +#define AUE_BIND 34 /* =nt bind(2) */ +#define AUE_SETSOCKOPT 35 /* =nt setsockopt(2) */ +#define AUE_VTRACE 36 /* =no vtrace(2) */ +#define AUE_SETTIMEOFDAY 37 /* =no settimeofday(2) */ +#define AUE_FCHOWN 38 /* =fm fchown(2) */ +#define AUE_FCHMOD 39 /* =fm fchmod(2) */ +#define AUE_SETREUID 40 /* =pm setreuid(2) */ +#define AUE_SETREGID 41 /* =pm setregid(2) */ +#define AUE_RENAME 42 /* =fc,fd rename(2) */ +#define AUE_TRUNCATE 43 /* =no truncate(2) */ +#define AUE_FTRUNCATE 44 /* =no ftruncate(2) */ +#define AUE_FLOCK 45 /* =no flock(2) */ +#define AUE_SHUTDOWN 46 /* =nt shutdown(2) */ +#define AUE_MKDIR 47 /* =fc mkdir(2) */ +#define AUE_RMDIR 48 /* =fd rmdir(2) */ +#define AUE_UTIMES 49 /* =fm futimens(2), utimensat(2) */ +#define AUE_ADJTIME 50 /* =as adjtime(2) */ +#define AUE_SETRLIMIT 51 /* =ua setrlimit(2) */ +#define AUE_KILLPG 52 /* =no killpg(2) */ +#define AUE_NFS_SVC 53 /* =no nfs_svc(2) */ +#define AUE_STATFS 54 /* =fa statfs(2) */ +#define AUE_FSTATFS 55 /* =fa fstatfs(2) */ +#define AUE_UNMOUNT 56 /* =no unmount(2) */ +#define AUE_ASYNC_DAEMON 57 /* =no async_daemon(2) */ +#define AUE_NFS_GETFH 58 /* =no nfs_getfh(2) */ +#define AUE_SETDOMAINNAME 59 /* =no setdomainname(2) */ +#define AUE_QUOTACTL 60 /* =no quotactl(2) */ +#define AUE_EXPORTFS 61 /* =no exportfs(2) */ +#define AUE_MOUNT 62 /* =as mount(2) */ +#define AUE_SEMSYS 63 /* =no semsys(2): place holder */ +#define AUE_MSGSYS 64 /* =no msgsys(2): place holder */ +#define AUE_SHMSYS 65 /* =no shmsys(2): place holder */ +#define AUE_BSMSYS 66 /* =no bsmsys(2): place holder */ +#define AUE_RFSSYS 67 /* =no rfssys(2): place holder */ +#define AUE_FCHDIR 68 /* =pm fchdir(2) */ +#define AUE_FCHROOT 69 /* =pm fchroot(2) */ +#define AUE_VPIXSYS 70 /* =no obsolete */ +#define AUE_PATHCONF 71 /* =fa pathconf(2) */ +#define AUE_OPEN_R 72 /* =fr open(2): read */ +#define AUE_OPEN_RC 73 /* =fc,fr open(2): read,creat */ +#define AUE_OPEN_RT 74 /* =fd,fr open(2): read,trunc */ +#define AUE_OPEN_RTC 75 /* =fc,fd,fr open(2): rd,cr,tr */ +#define AUE_OPEN_W 76 /* =fw open(2): write */ +#define AUE_OPEN_WC 77 /* =fc,fw open(2): write,creat */ +#define AUE_OPEN_WT 78 /* =fd,fw open(2): write,trunc */ +#define AUE_OPEN_WTC 79 /* =fc,fd,fw open(2): wr,cr,tr */ +#define AUE_OPEN_RW 80 /* =fr,fw open(2): read,write */ +#define AUE_OPEN_RWC 81 /* =fc,fw,fr open(2): rd,wr,cr */ +#define AUE_OPEN_RWT 82 /* =fd,fr,fw open(2): rd,wr,tr */ +#define AUE_OPEN_RWTC 83 /* =fc,fd,fw,fr open(2): rd,wr,cr,tr */ +#define AUE_MSGCTL 84 /* =ip msgctl(2): illegal command */ +#define AUE_MSGCTL_RMID 85 /* =ip msgctl(2): IPC_RMID command */ +#define AUE_MSGCTL_SET 86 /* =ip msgctl(2): IPC_SET command */ +#define AUE_MSGCTL_STAT 87 /* =ip msgctl(2): IPC_STAT command */ +#define AUE_MSGGET 88 /* =ip msgget(2) */ +#define AUE_MSGRCV 89 /* =ip msgrcv(2) */ +#define AUE_MSGSND 90 /* =ip msgsnd(2) */ +#define AUE_SHMCTL 91 /* =ip shmctl(2): Illegal command */ +#define AUE_SHMCTL_RMID 92 /* =ip shmctl(2): IPC_RMID command */ +#define AUE_SHMCTL_SET 93 /* =ip shmctl(2): IPC_SET command */ +#define AUE_SHMCTL_STAT 94 /* =ip shmctl(2): IPC_STAT command */ +#define AUE_SHMGET 95 /* =ip shmget(2) */ +#define AUE_SHMAT 96 /* =ip shmat(2) */ +#define AUE_SHMDT 97 /* =ip shmdt(2) */ +#define AUE_SEMCTL 98 /* =ip semctl(2): illegal command */ +#define AUE_SEMCTL_RMID 99 /* =ip semctl(2): IPC_RMID command */ +#define AUE_SEMCTL_SET 100 /* =ip semctl(2): IPC_SET command */ +#define AUE_SEMCTL_STAT 101 /* =ip semctl(2): IPC_STAT command */ +#define AUE_SEMCTL_GETNCNT 102 /* =ip semctl(2): GETNCNT command */ +#define AUE_SEMCTL_GETPID 103 /* =ip semctl(2): GETPID command */ +#define AUE_SEMCTL_GETVAL 104 /* =ip semctl(2): GETVAL command */ +#define AUE_SEMCTL_GETALL 105 /* =ip semctl(2): GETALL command */ +#define AUE_SEMCTL_GETZCNT 106 /* =ip semctl(2): GETZCNT command */ +#define AUE_SEMCTL_SETVAL 107 /* =ip semctl(2): SETVAL command */ +#define AUE_SEMCTL_SETALL 108 /* =ip semctl(2): SETALL command */ +#define AUE_SEMGET 109 /* =ip semget(2) */ +#define AUE_SEMOP 110 /* =ip semop(2) */ +#define AUE_CORE 111 /* =fc process dumped core */ +#define AUE_CLOSE 112 /* =cl close(2) */ +#define AUE_SYSTEMBOOT 113 /* =na system booted */ +#define AUE_ASYNC_DAEMON_EXIT 114 /* =no async_daemon(2) exited */ +#define AUE_NFSSVC_EXIT 115 /* =no nfssvc(2) exited */ +#define AUE_PFEXEC 116 /* =ps,ex,ua,as execve(2) w/ pfexec */ +#define AUE_OPEN_S 117 /* =fr open(2): search */ +#define AUE_OPEN_E 118 /* =fr open(2): exec */ +/* + * 119 - 129 are available for future growth (old SunOS_CMW events + * that had no libbsm or praudit support or references) + */ +#define AUE_GETAUID 130 /* =aa getauid(2) */ +#define AUE_SETAUID 131 /* =aa setauid(2) */ +#define AUE_GETAUDIT 132 /* =aa getaudit(2) */ +#define AUE_SETAUDIT 133 /* =aa setaudit(2) */ +/* 134 OBSOLETE */ +/* 135 OBSOLETE */ +#define AUE_AUDITSVC 136 /* =no obsolete */ +/* 137 OBSOLETE */ +#define AUE_AUDITON 138 /* =no auditon(2) */ +#define AUE_AUDITON_GTERMID 139 /* =no auditctl(2): GETTERMID */ +#define AUE_AUDITON_STERMID 140 /* =no auditctl(2): SETTERMID */ +#define AUE_AUDITON_GPOLICY 141 /* =aa auditctl(2): GETPOLICY */ +#define AUE_AUDITON_SPOLICY 142 /* =as auditctl(2): SETPOLICY */ +#define AUE_AUDITON_GESTATE 143 /* =no auditctl(2): GETESTATE */ +#define AUE_AUDITON_SESTATE 144 /* =no auditctl(2): SETESTATE */ +#define AUE_AUDITON_GQCTRL 145 /* =as auditctl(2): GETQCTRL */ +#define AUE_AUDITON_SQCTRL 146 /* =as auditctl(2): SETQCTRL */ +/* 147 OBSOLETE */ +/* 148 OBSOLETE */ +/* 149 OBSOLETE */ +/* 150 OBSOLETE */ +/* 151 OBSOLETE */ +/* 152 OBSOLETE */ +#define AUE_ENTERPROM 153 /* =na enter prom */ +#define AUE_EXITPROM 154 /* =na exit prom */ +/* 155 OBSOLETE */ +/* 156 OBSOLETE */ +/* 157 OBSOLETE */ +#define AUE_IOCTL 158 /* =io ioctl(2) */ +/* 159 OBSOLETE */ +/* 160 OBSOLETE */ +/* 161 OBSOLETE */ +/* 162 OBSOLETE */ +/* 163 OBSOLETE */ +/* 164 OBSOLETE */ +/* 165 OBSOLETE */ +/* 166 OBSOLETE */ +/* 167 OBSOLETE */ +/* 168 OBSOLETE */ +/* 169 OBSOLETE */ +/* 170 OBSOLETE */ +/* 171 OBSOLETE */ +/* 172 OBSOLETE */ +#define AUE_ONESIDE 173 /* =no one-sided session record */ +#define AUE_MSGGETL 174 /* =no msggetl(2) */ +#define AUE_MSGRCVL 175 /* =no msgrcvl(2) */ +#define AUE_MSGSNDL 176 /* =no msgsndl(2) */ +#define AUE_SEMGETL 177 /* =no semgetl(2) */ +#define AUE_SHMGETL 178 /* =no shmgetl(2) */ +/* 179 OBSOLETE */ +/* 180 OBSOLETE */ +/* 181 OBSOLETE */ +/* 182 OBSOLETE */ +#define AUE_SOCKET 183 /* =nt socket(2) */ +#define AUE_SENDTO 184 /* =nt sendto(2) */ +#define AUE_PIPE 185 /* =no pipe(2) */ +#define AUE_SOCKETPAIR 186 /* =no socketpair(2) */ +#define AUE_SEND 187 /* =no send(2) */ +#define AUE_SENDMSG 188 /* =nt sendmsg(2) */ +#define AUE_RECV 189 /* =no recv(2) */ +#define AUE_RECVMSG 190 /* =nt recvmsg(2) */ +#define AUE_RECVFROM 191 /* =nt recvfrom(2) */ +#define AUE_READ 192 /* =no read(2) */ +#define AUE_GETDENTS 193 /* =no getdents(2) */ +#define AUE_LSEEK 194 /* =no lseek(2) */ +#define AUE_WRITE 195 /* =no write(2) */ +#define AUE_WRITEV 196 /* =no writev(2) */ +#define AUE_NFS 197 /* =no NFS server */ +#define AUE_READV 198 /* =no readv(2) */ +#define AUE_OSTAT 199 /* =no obsolete */ +#define AUE_SETUID 200 /* =pm old setuid(2) */ +#define AUE_STIME 201 /* =as old stime(2) */ +#define AUE_UTIME 202 /* =no obsolete */ +#define AUE_NICE 203 /* =pm old nice(2) */ +#define AUE_OSETPGRP 204 /* =no old setpgrp(2) */ +#define AUE_SETGID 205 /* =pm old setgid(2) */ +#define AUE_READL 206 /* =no readl(2) */ +#define AUE_READVL 207 /* =no readvl(2) */ +#define AUE_FSTAT 208 /* =no fstat(2) */ +#define AUE_DUP2 209 /* =no obsolete */ +#define AUE_MMAP 210 /* =no mmap(2) u-o-p */ +#define AUE_AUDIT 211 /* =no audit(2) u-o-p */ +#define AUE_PRIOCNTLSYS 212 /* =pm priocntlsys */ +#define AUE_MUNMAP 213 /* =cl munmap(2) u-o-p */ +#define AUE_SETEGID 214 /* =pm setegid(2) */ +#define AUE_SETEUID 215 /* =pm seteuid(2) */ +#define AUE_PUTMSG 216 /* =nt */ +#define AUE_GETMSG 217 /* =nt */ +#define AUE_PUTPMSG 218 /* =nt */ +#define AUE_GETPMSG 219 /* =nt */ +#define AUE_AUDITSYS 220 /* =no place holder */ +#define AUE_AUDITON_GETKMASK 221 /* =aa */ +#define AUE_AUDITON_SETKMASK 222 /* =as */ +#define AUE_AUDITON_GETCWD 223 /* =aa,as */ +#define AUE_AUDITON_GETCAR 224 /* =aa,as */ +#define AUE_AUDITON_GETSTAT 225 /* =as */ +#define AUE_AUDITON_SETSTAT 226 /* =as */ +#define AUE_AUDITON_SETUMASK 227 /* =as */ +#define AUE_AUDITON_SETSMASK 228 /* =as */ +#define AUE_AUDITON_GETCOND 229 /* =aa */ +#define AUE_AUDITON_SETCOND 230 /* =as */ +#define AUE_AUDITON_GETCLASS 231 /* =aa,as */ +#define AUE_AUDITON_SETCLASS 232 /* =as */ +#define AUE_FUSERS 233 /* =fa */ +#define AUE_STATVFS 234 /* =fa */ +#define AUE_XSTAT 235 /* =no obsolete */ +#define AUE_LXSTAT 236 /* =no obsolete */ +#define AUE_LCHOWN 237 /* =fm */ +#define AUE_MEMCNTL 238 /* =ot */ +#define AUE_SYSINFO 239 /* =as */ +#define AUE_XMKNOD 240 /* =no obsolete */ +#define AUE_FORK1 241 /* =ps */ +#define AUE_MODCTL 242 /* =no */ +#define AUE_MODLOAD 243 /* =as */ +#define AUE_MODUNLOAD 244 /* =as */ +#define AUE_MODCONFIG 245 /* =no obsolete */ +#define AUE_MODADDMAJ 246 /* =as */ +#define AUE_SOCKACCEPT 247 /* =nt */ +#define AUE_SOCKCONNECT 248 /* =nt */ +#define AUE_SOCKSEND 249 /* =nt */ +#define AUE_SOCKRECEIVE 250 /* =nt */ +#define AUE_ACLSET 251 /* =fm */ +#define AUE_FACLSET 252 /* =fm */ +#define AUE_DOORFS 253 /* =no */ +#define AUE_DOORFS_DOOR_CALL 254 /* =ip */ +#define AUE_DOORFS_DOOR_RETURN 255 /* =ip */ +#define AUE_DOORFS_DOOR_CREATE 256 /* =ip */ +#define AUE_DOORFS_DOOR_REVOKE 257 /* =ip */ +#define AUE_DOORFS_DOOR_INFO 258 /* =ip */ +#define AUE_DOORFS_DOOR_CRED 259 /* =ip */ +#define AUE_DOORFS_DOOR_BIND 260 /* =ip */ +#define AUE_DOORFS_DOOR_UNBIND 261 /* =ip */ +#define AUE_P_ONLINE 262 /* =as */ +#define AUE_PROCESSOR_BIND 263 /* =as */ +#define AUE_INST_SYNC 264 /* =as */ +#define AUE_SOCKCONFIG 265 /* =nt */ +#define AUE_SETAUDIT_ADDR 266 /* =aa setaudit_addr(2) */ +#define AUE_GETAUDIT_ADDR 267 /* =aa getaudit_addr(2) */ +#define AUE_UMOUNT2 268 /* =as umount2(2) */ +#define AUE_FSAT 269 /* =no obsolete */ +#define AUE_OPENAT_R 270 /* =no obsolete */ +#define AUE_OPENAT_RC 271 /* =no obsolete */ +#define AUE_OPENAT_RT 272 /* =no obsolete */ +#define AUE_OPENAT_RTC 273 /* =no obsolete */ +#define AUE_OPENAT_W 274 /* =no obsolete */ +#define AUE_OPENAT_WC 275 /* =no obsolete */ +#define AUE_OPENAT_WT 276 /* =no obsolete */ +#define AUE_OPENAT_WTC 277 /* =no obsolete */ +#define AUE_OPENAT_RW 278 /* =no obsolete */ +#define AUE_OPENAT_RWC 279 /* =no obsolete */ +#define AUE_OPENAT_RWT 280 /* =no obsolete */ +#define AUE_OPENAT_RWTC 281 /* =no obsolete */ +#define AUE_RENAMEAT 282 /* =no obsolete */ +#define AUE_FSTATAT 283 /* =no obsolete */ +#define AUE_FCHOWNAT 284 /* =no obsolete */ +#define AUE_FUTIMESAT 285 /* =no obsolete */ +#define AUE_UNLINKAT 286 /* =no obsolete */ +#define AUE_CLOCK_SETTIME 287 /* =as clock_settime(3C) */ +#define AUE_NTP_ADJTIME 288 /* =as ntp_adjtime(2) */ +#define AUE_SETPPRIV 289 /* =pm setppriv(2) */ +#define AUE_MODDEVPLCY 290 /* =as modctl(2) */ +#define AUE_MODADDPRIV 291 /* =as modctl(2) */ +#define AUE_CRYPTOADM 292 /* =as kernel cryptographic framework */ +#define AUE_CONFIGKSSL 293 /* =as kernel SSL */ +#define AUE_BRANDSYS 294 /* =ot */ +#define AUE_PF_POLICY_ADDRULE 295 /* =as Add IPsec policy rule */ +#define AUE_PF_POLICY_DELRULE 296 /* =as Delete IPsec policy rule */ +#define AUE_PF_POLICY_CLONE 297 /* =as Clone IPsec policy */ +#define AUE_PF_POLICY_FLIP 298 /* =as Flip IPsec policy */ +#define AUE_PF_POLICY_FLUSH 299 /* =as Flush IPsec policy rules */ +#define AUE_PF_POLICY_ALGS 300 /* =as Update IPsec algorithms */ +#define AUE_PORTFS 301 /* =no portfs(2) - place holder */ +#define AUE_LABELSYS_TNRH 302 /* =as tnrh(2) */ +#define AUE_LABELSYS_TNRHTP 303 /* =as tnrhtp(2) */ +#define AUE_LABELSYS_TNMLP 304 /* =as tnmlp(2) */ +#define AUE_PORTFS_ASSOCIATE 305 /* =fa portfs(2) - port associate */ +#define AUE_PORTFS_DISSOCIATE 306 /* =fa portfs(2) - port disassociate */ +#define AUE_SETSID 307 /* =pm setsid(2) */ +#define AUE_SETPGID 308 /* =pm setpgid(2) */ +#define AUE_FACCESSAT 309 /* =no obsolete */ +#define AUE_AUDITON_GETAMASK 310 /* =aa */ +#define AUE_AUDITON_SETAMASK 311 /* =as */ +#define AUE_PSECFLAGS 312 /* =pm psecflags */ +#define AUE_SACL 313 /* =sa SACL auditing (reserved) */ +#define AUE_AUDITON_GETPINFO 314 /* =aa */ +#define AUE_AUDITON_SETPMASK 315 /* =as */ +#define AUE_AUDITON_GETKAUDIT 316 /* =aa */ +#define AUE_AUDITON_SETKAUDIT 317 /* =as */ +#define AUE_AUDITON_OTHER 318 /* =aa */ + +/* NOTE: update MAX_KEVENTS below if events are added. */ +#define MAX_KEVENTS 318 + +#ifdef __cplusplus +} +#endif + +#endif /* _BSM_AUDIT_KEVENTS_H */ diff --git a/illumos-x86_64/usr/include/bsm/audit_record.h b/illumos-x86_64/usr/include/bsm/audit_record.h new file mode 100644 index 00000000..3a57c3b8 --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/audit_record.h @@ -0,0 +1,483 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _BSM_AUDIT_RECORD_H +#define _BSM_AUDIT_RECORD_H + + +#ifdef _KERNEL +#include +#else +#include +#endif +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Version of audit attributes + * + * OS Release Version Number Comments + * ========== ============== ======== + * SunOS 5.1 2 Unbundled Package + * SunOS 5.3 2 Bundled into the base OS + * SunOS 5.4-5.x 2 + * Trusted Solaris 2.5 3 To distinguish potential new tokens + * Trusted Solaris 7-8 4 Redefine X tokens that overlap with + * SunOS 5.7 + */ + +#define TOKEN_VERSION 2 + +/* + * Audit record token type codes + */ + +/* + * Control token types + */ + +#define AUT_INVALID ((char)0x00) +#define AUT_OTHER_FILE ((char)0x11) +#define AUT_OTHER_FILE32 AUT_OTHER_FILE +#define AUT_OHEADER ((char)0x12) +#define AUT_TRAILER ((char)0x13) +#define AUT_HEADER ((char)0x14) +#define AUT_HEADER32 AUT_HEADER +#define AUT_HEADER32_EX ((char)0x15) +#define AUT_TRAILER_MAGIC ((short)0xB105) + +/* + * Data token types + */ + +#define AUT_FMRI ((char)0x20) +#define AUT_DATA ((char)0x21) +#define AUT_IPC ((char)0x22) +#define AUT_PATH ((char)0x23) +#define AUT_SUBJECT ((char)0x24) +#define AUT_SUBJECT32 AUT_SUBJECT +#define AUT_XATPATH ((char)0x25) +#define AUT_PROCESS ((char)0x26) +#define AUT_PROCESS32 AUT_PROCESS +#define AUT_RETURN ((char)0x27) +#define AUT_RETURN32 AUT_RETURN +#define AUT_TEXT ((char)0x28) +#define AUT_OPAQUE ((char)0x29) +#define AUT_IN_ADDR ((char)0x2A) +#define AUT_IP ((char)0x2B) +#define AUT_IPORT ((char)0x2C) +#define AUT_ARG ((char)0x2D) +#define AUT_ARG32 AUT_ARG +#define AUT_SOCKET ((char)0x2E) +#define AUT_SEQ ((char)0x2F) +#define AUT_USER ((char)0x36) /* out of order */ +#define AUT_TID ((char)0x61) /* out of order */ + +/* + * Modifier token types + */ + +#define AUT_ACL ((char)0x30) +#define AUT_ATTR ((char)0x31) +#define AUT_IPC_PERM ((char)0x32) +#define AUT_LABEL ((char)0x33) +#define AUT_GROUPS ((char)0x34) +#define AUT_ACE ((char)0x35) + /* 0x37 unused */ +#define AUT_PRIV ((char)0x38) +#define AUT_UPRIV ((char)0x39) +#define AUT_LIAISON ((char)0x3A) +#define AUT_NEWGROUPS ((char)0x3B) +#define AUT_EXEC_ARGS ((char)0x3C) +#define AUT_EXEC_ENV ((char)0x3D) +#define AUT_ATTR32 ((char)0x3E) +#define AUT_UAUTH ((char)0x3F) +#define AUT_ZONENAME ((char)0x60) /* out of order */ +#define AUT_SECFLAGS ((char)0x62) /* out of order */ + +/* + * X windows token types + */ + +#define AUT_XATOM ((char)0x40) +#define AUT_XOBJ ((char)0x41) +#define AUT_XPROTO ((char)0x42) +#define AUT_XSELECT ((char)0x43) + +#if TOKEN_VERSION != 3 +#define AUT_XCOLORMAP ((char)0x44) +#define AUT_XCURSOR ((char)0x45) +#define AUT_XFONT ((char)0x46) +#define AUT_XGC ((char)0x47) +#define AUT_XPIXMAP ((char)0x48) +#define AUT_XPROPERTY ((char)0x49) +#define AUT_XWINDOW ((char)0x4A) +#define AUT_XCLIENT ((char)0x4B) +#else /* TOKEN_VERSION == 3 */ +#define AUT_XCOLORMAP ((char)0x74) +#define AUT_XCURSOR ((char)0x75) +#define AUT_XFONT ((char)0x76) +#define AUT_XGC ((char)0x77) +#define AUT_XPIXMAP ((char)0x78) +#define AUT_XPROPERTY ((char)0x79) +#define AUT_XWINDOW ((char)0x7A) +#define AUT_XCLIENT ((char)0x7B) +#endif /* TOKEN_VERSION != 3 */ + +/* + * Command token types + */ + +#define AUT_CMD ((char)0x51) +#define AUT_EXIT ((char)0x52) + +/* + * Miscellaneous token types + */ + +#define AUT_HOST ((char)0x70) + +/* + * Solaris64 token types + */ + +#define AUT_ARG64 ((char)0x71) +#define AUT_RETURN64 ((char)0x72) +#define AUT_ATTR64 ((char)0x73) +#define AUT_HEADER64 ((char)0x74) +#define AUT_SUBJECT64 ((char)0x75) +#define AUT_PROCESS64 ((char)0x77) +#define AUT_OTHER_FILE64 ((char)0x78) + +/* + * Extended network address token types + */ + +#define AUT_HEADER64_EX ((char)0x79) +#define AUT_SUBJECT32_EX ((char)0x7a) +#define AUT_PROCESS32_EX ((char)0x7b) +#define AUT_SUBJECT64_EX ((char)0x7c) +#define AUT_PROCESS64_EX ((char)0x7d) +#define AUT_IN_ADDR_EX ((char)0x7e) +#define AUT_SOCKET_EX ((char)0x7f) + +/* + * Can't do >= 0x80 because these are chars. 0x16/0x17 seem to be free here, + * but who knows if they have historical uses + */ +#define AUT_ACCESS_MASK ((char)0x16) +#define AUT_WSID ((char)0x17) + +/* + * Audit print suggestion types. + */ + +#define AUP_BINARY ((char)0) +#define AUP_OCTAL ((char)1) +#define AUP_DECIMAL ((char)2) +#define AUP_HEX ((char)3) +#define AUP_STRING ((char)4) + +/* + * Audit data member types. + */ + +#define AUR_BYTE ((char)0) +#define AUR_CHAR ((char)0) +#define AUR_SHORT ((char)1) +#define AUR_INT ((char)2) +#define AUR_INT32 ((char)2) +#define AUR_INT64 ((char)3) + +/* + * Adr structures + */ + +struct adr_s { + char *adr_stream; /* The base of the stream */ + char *adr_now; /* The location within the stream */ +}; + +typedef struct adr_s adr_t; + + +#ifdef _KERNEL + +#include +#include /* for rval */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * au_close flag arguments + */ + +#define AU_OK 0x1 /* Good audit record */ +#define AU_DONTBLOCK 0x2 /* Don't block or discard if queue full */ +#define AU_DEFER 0x4 /* Defer record queueing to syscall end */ + +/* + * Audit token type is really an au_membuf pointer + */ +typedef au_buff_t token_t; +/* + * token generation functions + */ +token_t *au_append_token(token_t *, token_t *); +token_t *au_set(caddr_t, uint_t); + +void au_free_rec(au_buff_t *); + +#define au_getclr() ((token_t *)au_get_buff()) +#define au_toss_token(tok) (au_free_rec((au_buff_t *)(tok))) + +token_t *au_to_acl(); +token_t *au_to_ace(); +token_t *au_to_attr(struct vattr *); +token_t *au_to_data(char, char, char, char *); +token_t *au_to_header(int, au_event_t, au_emod_t); +token_t *au_to_header_ex(int, au_event_t, au_emod_t); +token_t *au_to_ipc(char, int); +token_t *au_to_ipc_perm(kipc_perm_t *); +token_t *au_to_iport(ushort_t); +token_t *au_to_in_addr(struct in_addr *); +token_t *au_to_in_addr_ex(int32_t *); +token_t *au_to_ip(struct ip *); +token_t *au_to_groups(const gid_t *, uint_t); +token_t *au_to_path(struct audit_path *); +token_t *au_to_seq(); +token_t *au_to_process(uid_t, gid_t, uid_t, gid_t, pid_t, + au_id_t, au_asid_t, const au_tid_addr_t *); +token_t *au_to_subject(uid_t, gid_t, uid_t, gid_t, pid_t, + au_id_t, au_asid_t, const au_tid_addr_t *); +token_t *au_to_return32(int, int32_t); +token_t *au_to_return64(int, int64_t); +token_t *au_to_text(const char *); +/* token_t *au_to_tid(au_generic_tid_t *); no kernel implementation */ +token_t *au_to_trailer(int); +token_t *au_to_uauth(char *); +size_t au_zonename_length(zone_t *); +token_t *au_to_zonename(size_t, zone_t *); +token_t *au_to_arg32(char, char *, uint32_t); +token_t *au_to_arg64(char, char *, uint64_t); +token_t *au_to_socket_ex(short, short, char *, char *); +token_t *au_to_sock_inet(struct sockaddr_in *); +token_t *au_to_exec_args(const char *, ssize_t); +token_t *au_to_exec_env(const char *, ssize_t); +token_t *au_to_label(bslabel_t *); +token_t *au_to_privset(const char *, const priv_set_t *, char, int); +token_t *au_to_secflags(const char *, secflagset_t); + +void au_uwrite(); +void au_close(au_kcontext_t *, caddr_t *, int, au_event_t, au_emod_t, + timestruc_t *); +void au_close_defer(token_t *, int, au_event_t, au_emod_t, timestruc_t *); +void au_close_time(au_kcontext_t *, token_t *, int, au_event_t, au_emod_t, + timestruc_t *); +void au_free_rec(au_buff_t *); +void au_write(caddr_t *, token_t *); +void au_mem_init(void); +void au_zone_setup(); +void au_enqueue(au_kcontext_t *, au_buff_t *, adr_t *, adr_t *, int, int); +int au_doorio(au_kcontext_t *); +int au_doormsg(au_kcontext_t *, uint32_t, void *); +int au_token_size(token_t *); +int au_append_rec(au_buff_t *, au_buff_t *, int); +int au_append_buf(const char *, int, au_buff_t *); + +#else /* !_KERNEL */ + +#include +#include +#include +#include +#include +#include +#include + +struct token_s { + struct token_s *tt_next; /* Next in the list */ + short tt_size; /* Size of data */ + char *tt_data; /* The data */ +}; +typedef struct token_s token_t; + +/* + * Old socket structure definition, formerly in + */ +struct oldsocket { + short so_type; /* generic type, see socket.h */ + short so_options; /* from socket call, see socket.h */ + short so_linger; /* time to linger while closing */ + short so_state; /* internal state flags SS_*, below */ + struct inpcb *so_pcb; /* protocol control block */ + struct protosw *so_proto; /* protocol handle */ +/* + * Variables for connection queueing. + * Socket where accepts occur is so_head in all subsidiary sockets. + * If so_head is 0, socket is not related to an accept. + * For head socket so_q0 queues partially completed connections, + * while so_q is a queue of connections ready to be accepted. + * If a connection is aborted and it has so_head set, then + * it has to be pulled out of either so_q0 or so_q. + * We allow connections to queue up based on current queue lengths + * and limit on number of queued connections for this socket. + */ + struct oldsocket *so_head; /* back pointer to accept socket */ + struct oldsocket *so_q0; /* queue of partial connections */ + struct oldsocket *so_q; /* queue of incoming connections */ + short so_q0len; /* partials on so_q0 */ + short so_qlen; /* number of connections on so_q */ + short so_qlimit; /* max number queued connections */ + short so_timeo; /* connection timeout */ + ushort_t so_error; /* error affecting connection */ + short so_pgrp; /* pgrp for signals */ + ulong_t so_oobmark; /* chars to oob mark */ +/* + * Variables for socket buffering. + */ + struct sockbuf { + ulong_t sb_cc; /* actual chars in buffer */ + ulong_t sb_hiwat; /* max actual char count */ + ulong_t sb_mbcnt; /* chars of mbufs used */ + ulong_t sb_mbmax; /* max chars of mbufs to use */ + ulong_t sb_lowat; /* low water mark (not used yet) */ + struct mbuf *sb_mb; /* the mbuf chain */ + struct proc *sb_sel; /* process selecting read/write */ + short sb_timeo; /* timeout (not used yet) */ + short sb_flags; /* flags, see below */ + } so_rcv, so_snd; +/* + * Hooks for alternative wakeup strategies. + * These are used by kernel subsystems wishing to access the socket + * abstraction. If so_wupfunc is nonnull, it is called in place of + * wakeup any time that wakeup would otherwise be called with an + * argument whose value is an address lying within a socket structure. + */ + struct wupalt *so_wupalt; +}; +extern token_t *au_to_arg32(char, char *, uint32_t); +extern token_t *au_to_arg64(char, char *, uint64_t); +extern token_t *au_to_acl(struct acl *); +extern token_t *au_to_attr(struct vattr *); +extern token_t *au_to_cmd(uint_t, char **, char **); +extern token_t *au_to_data(char, char, char, char *); +extern token_t *au_to_exec_args(char **); +extern token_t *au_to_exec_env(char **); +extern token_t *au_to_exit(int, int); +extern token_t *au_to_fmri(char *); +extern token_t *au_to_groups(int *); +extern token_t *au_to_newgroups(int, gid_t *); +extern token_t *au_to_header(au_event_t, au_emod_t); +extern token_t *au_to_header_ex(au_event_t, au_emod_t); +extern token_t *au_to_in_addr(struct in_addr *); +extern token_t *au_to_in_addr_ex(struct in6_addr *); +extern token_t *au_to_ipc(char, int); +extern token_t *au_to_ipc_perm(struct ipc_perm *); +extern token_t *au_to_iport(ushort_t); +extern token_t *au_to_me(void); +extern token_t *au_to_mylabel(void); +extern token_t *au_to_opaque(char *, short); +extern token_t *au_to_path(char *); +extern token_t *au_to_privset(const char *, const priv_set_t *); +extern token_t *au_to_process(au_id_t, uid_t, gid_t, uid_t, gid_t, + pid_t, au_asid_t, au_tid_t *); +extern token_t *au_to_process_ex(au_id_t, uid_t, gid_t, uid_t, gid_t, + pid_t, au_asid_t, au_tid_addr_t *); +extern token_t *au_to_return32(char, uint32_t); +extern token_t *au_to_return64(char, uint64_t); +extern token_t *au_to_seq(int); +extern token_t *au_to_label(m_label_t *); +extern token_t *au_to_socket(struct oldsocket *); +extern token_t *au_to_subject(au_id_t, uid_t, gid_t, uid_t, gid_t, + pid_t, au_asid_t, au_tid_t *); +extern token_t *au_to_subject_ex(au_id_t, uid_t, gid_t, uid_t, gid_t, + pid_t, au_asid_t, au_tid_addr_t *); +extern token_t *au_to_text(char *); +extern token_t *au_to_tid(au_generic_tid_t *); +extern token_t *au_to_trailer(void); +extern token_t *au_to_uauth(char *); +extern token_t *au_to_upriv(char, char *); +extern token_t *au_to_user(uid_t, char *); +extern token_t *au_to_xatom(char *); +extern token_t *au_to_xselect(char *, char *, char *); +extern token_t *au_to_xcolormap(int32_t, uid_t); +extern token_t *au_to_xcursor(int32_t, uid_t); +extern token_t *au_to_xfont(int32_t, uid_t); +extern token_t *au_to_xgc(int32_t, uid_t); +extern token_t *au_to_xpixmap(int32_t, uid_t); +extern token_t *au_to_xwindow(int32_t, uid_t); +extern token_t *au_to_xproperty(int32_t, uid_t, char *); +extern token_t *au_to_xclient(uint32_t); +extern token_t *au_to_zonename(char *); +#endif /* _KERNEL */ + +#ifdef _KERNEL + +void adr_char(adr_t *, char *, int); +void adr_int32(adr_t *, int32_t *, int); +void adr_uint32(adr_t *, uint32_t *, int); +void adr_int64(adr_t *, int64_t *, int); +void adr_uint64(adr_t *, uint64_t *, int); +void adr_short(adr_t *, short *, int); +void adr_ushort(adr_t *, ushort_t *, int); +void adr_start(adr_t *, char *); + +char *adr_getchar(adr_t *, char *); +char *adr_getshort(adr_t *, short *); +char *adr_getushort(adr_t *, ushort_t *); +char *adr_getint32(adr_t *, int32_t *); +char *adr_getuint32(adr_t *, uint32_t *); +char *adr_getint64(adr_t *, int64_t *); +char *adr_getuint64(adr_t *, uint64_t *); + +int adr_count(adr_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BSM_AUDIT_RECORD_H */ diff --git a/illumos-x86_64/usr/include/bsm/audit_uevents.h b/illumos-x86_64/usr/include/bsm/audit_uevents.h new file mode 100644 index 00000000..e13da0f5 --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/audit_uevents.h @@ -0,0 +1,327 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992, 2025, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _BSM_AUDIT_UEVENTS_H +#define _BSM_AUDIT_UEVENTS_H + + +/* + * User level audit event numbers. + * + * 0 Reserved as an invalid event number. + * 1 - 2047 Reserved for the Solaris Kernel events. + * 2048 - 32767 Reserved for the Solaris TCB programs. + * 32768 - 65535 Available for third party TCB applications. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define AUE_at_create 6144 +#define AUE_at_delete 6145 +#define AUE_at_perm 6146 +#define AUE_cron_invoke 6147 +#define AUE_crontab_create 6148 +#define AUE_crontab_delete 6149 +#define AUE_crontab_perm 6150 +#define AUE_inetd_connect 6151 +#define AUE_login 6152 +#define AUE_logout 6153 +#define AUE_telnet 6154 +#define AUE_rlogin 6155 +#define AUE_mountd_mount 6156 +#define AUE_mountd_umount 6157 +#define AUE_rshd 6158 +#define AUE_su 6159 +#define AUE_halt_solaris 6160 +#define AUE_reboot_solaris 6161 +#define AUE_rexecd 6162 +#define AUE_passwd 6163 +#define AUE_rexd 6164 +#define AUE_ftpd 6165 +#define AUE_init_solaris 6166 +#define AUE_uadmin_solaris 6167 +#define AUE_shutdown_solaris 6168 +#define AUE_poweroff_solaris 6169 +#define AUE_crontab_mod 6170 +#define AUE_ftpd_logout 6171 +#define AUE_ssh 6172 +#define AUE_role_login 6173 +#define AUE_prof_cmd 6180 +#define AUE_filesystem_add 6181 +#define AUE_filesystem_delete 6182 +#define AUE_filesystem_modify 6183 +#define AUE_network_add 6184 +#define AUE_network_delete 6185 +#define AUE_network_modify 6186 +#define AUE_printer_add 6187 +#define AUE_printer_delete 6188 +#define AUE_printer_modify 6189 +#define AUE_scheduledjob_add 6190 +#define AUE_scheduledjob_delete 6191 +#define AUE_scheduledjob_modify 6192 +#define AUE_serialport_add 6193 +#define AUE_serialport_delete 6194 +#define AUE_serialport_modify 6195 +#define AUE_usermgr_add 6196 +#define AUE_usermgr_delete 6197 +#define AUE_usermgr_modify 6198 +#define AUE_uauth 6199 +#define AUE_allocate_succ 6200 +#define AUE_allocate_fail 6201 +#define AUE_deallocate_succ 6202 +#define AUE_deallocate_fail 6203 +#define AUE_listdevice_succ 6205 +#define AUE_listdevice_fail 6206 +#define AUE_create_user 6207 +#define AUE_modify_user 6208 +#define AUE_delete_user 6209 +#define AUE_disable_user 6210 +#define AUE_enable_user 6211 +#define AUE_newgrp_login 6212 +#define AUE_admin_authenticate 6213 +#define AUE_kadmind_auth 6214 +#define AUE_kadmind_unauth 6215 +#define AUE_krb5kdc_as_req 6216 +#define AUE_krb5kdc_tgs_req 6217 +#define AUE_krb5kdc_tgs_req_2ndtktmm 6218 +#define AUE_krb5kdc_tgs_req_alt_tgt 6219 +#define AUE_smserverd 6220 +#define AUE_screenlock 6221 +#define AUE_screenunlock 6222 +#define AUE_zone_state 6223 +#define AUE_inetd_copylimit 6224 +#define AUE_inetd_failrate 6225 +#define AUE_inetd_ratelimit 6226 +#define AUE_zlogin 6227 +#define AUE_su_logout 6228 +#define AUE_role_logout 6229 +#define AUE_attach 6230 +#define AUE_detach 6231 +#define AUE_remove 6232 +#define AUE_pool_import 6233 +#define AUE_pool_export 6234 +#define AUE_dladm_create_secobj 6235 +#define AUE_dladm_delete_secobj 6236 +#define AUE_uadmin_shutdown 6237 +#define AUE_uadmin_reboot 6238 +#define AUE_uadmin_dump 6239 +#define AUE_uadmin_freeze 6240 +#define AUE_uadmin_remount 6241 +#define AUE_uadmin_ftrace 6242 +#define AUE_uadmin_swapctl 6243 +#define AUE_smbd_session 6244 +#define AUE_smbd_logoff 6245 +#define AUE_vscan_quarantine 6246 +#define AUE_ndmp_connect 6247 +#define AUE_ndmp_disconnect 6248 +#define AUE_ndmp_backup 6249 +#define AUE_ndmp_restore 6250 +#define AUE_cpu_ondemand 6251 +#define AUE_cpu_performance 6252 +#define AUE_cpu_threshold 6253 +#define AUE_uadmin_thaw 6254 +#define AUE_uadmin_config 6255 +#define AUE_smf_enable 6260 +#define AUE_smf_tmp_enable 6261 +#define AUE_smf_disable 6262 +#define AUE_smf_tmp_disable 6263 +#define AUE_smf_restart 6264 +#define AUE_smf_refresh 6265 +#define AUE_smf_clear 6266 +#define AUE_smf_degrade 6267 +#define AUE_smf_immediate_degrade 6268 +#define AUE_smf_maintenance 6269 +#define AUE_smf_immediate_maintenance 6270 +#define AUE_smf_immtmp_maintenance 6271 +#define AUE_smf_tmp_maintenance 6272 +#define AUE_smf_milestone 6273 +#define AUE_smf_read_prop 6275 +#define AUE_smf_create 6280 +#define AUE_smf_delete 6281 +#define AUE_smf_create_pg 6282 +#define AUE_smf_create_npg 6283 +#define AUE_smf_delete_pg 6284 +#define AUE_smf_delete_npg 6285 +#define AUE_smf_create_snap 6286 +#define AUE_smf_delete_snap 6287 +#define AUE_smf_attach_snap 6288 +#define AUE_smf_annotation 6289 +#define AUE_smf_create_prop 6290 +#define AUE_smf_change_prop 6291 +#define AUE_smf_delete_prop 6292 +#define AUE_nwam_enable 6300 +#define AUE_nwam_disable 6301 +#define AUE_ilb_create_healthcheck 6310 +#define AUE_ilb_delete_healthcheck 6311 +#define AUE_ilb_create_rule 6312 +#define AUE_ilb_delete_rule 6313 +#define AUE_ilb_disable_rule 6314 +#define AUE_ilb_enable_rule 6315 +#define AUE_ilb_add_server 6316 +#define AUE_ilb_disable_server 6317 +#define AUE_ilb_enable_server 6318 +#define AUE_ilb_remove_server 6319 +#define AUE_ilb_create_servergroup 6320 +#define AUE_ilb_delete_servergroup 6321 +#define AUE_netcfg_update 6330 +#define AUE_netcfg_remove 6331 +#define AUE_tpm_takeownership 6400 +#define AUE_tpm_clearowner 6401 +#define AUE_tpm_setoperatorauth 6402 +#define AUE_tpm_setownerinstall 6403 +#define AUE_tpm_selftestfull 6404 +#define AUE_tpm_certifyselftest 6405 +#define AUE_tpm_continueselftest 6406 +#define AUE_tpm_ownersetdisable 6407 +#define AUE_tpm_ownerclear 6408 +#define AUE_tpm_disableownerclear 6409 +#define AUE_tpm_forceclear 6410 +#define AUE_tpm_disableforceclear 6411 +#define AUE_tpm_physicaldisable 6412 +#define AUE_tpm_physicalenable 6413 +#define AUE_tpm_physicaldeactivate 6414 +#define AUE_tpm_settempdeactivated 6415 +#define AUE_tpm_settempdeactivated2 6416 +#define AUE_tpm_physicalpresence 6417 +#define AUE_tpm_fieldupgrade 6418 +#define AUE_tpm_resetlockvalue 6419 +#define AUE_hotplug_state 6500 +#define AUE_hotplug_set 6501 +#define AUE_sudo 6650 +#define AUE_sl_change 9035 +#define AUE_file_relabel 9036 +#define AUE_file_copy 9037 +#define AUE_file_move 9038 +#define AUE_sel_mgr_xfer 9039 +#define AUE_ClientConnect 9101 +#define AUE_ClientDisconnect 9102 +#define AUE_ChangeProperty 9120 +#define AUE_DeleteProperty 9121 +#define AUE_GrabServer 9137 +#define AUE_UngrabServer 9138 +#define AUE_SetFontPath 9146 +#define AUE_InstallColormap 9173 +#define AUE_UninstallColormap 9174 +#define AUE_SetScreenSaver 9193 +#define AUE_ChangeHosts 9194 +#define AUE_SetAccessControl 9195 +#define AUE_SetCloseDownMode 9196 +#define AUE_KillClient 9197 +#define AUE_XExtensions 9202 +#define AUE_CreateWindow 9103 +#define AUE_ChangeWindowAttributes 9104 +#define AUE_GetWindowAttributes 9105 +#define AUE_DestroyWindow 9106 +#define AUE_DestroySubwindows 9107 +#define AUE_ChangeSaveSet 9108 +#define AUE_ReparentWindow 9109 +#define AUE_MapWindow 9110 +#define AUE_MapSubwindows 9111 +#define AUE_UnmapWindow 9112 +#define AUE_UnmapSubwindows 9113 +#define AUE_ConfigureWindow 9114 +#define AUE_CirculateWindow 9115 +#define AUE_GetGeometry 9116 +#define AUE_QueryTree 9117 +#define AUE_InternAtom 9118 +#define AUE_GetAtomName 9119 +#define AUE_GetProperty 9122 +#define AUE_ListProperties 9123 +#define AUE_SetSelectionOwner 9124 +#define AUE_GetSelectionOwner 9125 +#define AUE_ConvertSelection 9126 +#define AUE_SendEvent 9127 +#define AUE_GrabPointer 9128 +#define AUE_UngrabPointer 9129 +#define AUE_GrabButton 9130 +#define AUE_UngrabButton 9131 +#define AUE_ChangeActivePointerGrab 9132 +#define AUE_GrabKeyboard 9133 +#define AUE_UngrabKeyboard 9134 +#define AUE_GrabKey 9135 +#define AUE_UngrabKey 9136 +#define AUE_QueryPointer 9139 +#define AUE_GetMotionEvents 9140 +#define AUE_TranslateCoords 9141 +#define AUE_WarpPointer 9142 +#define AUE_SetInputFocus 9143 +#define AUE_GetInputFocus 9144 +#define AUE_QueryKeymap 9145 +#define AUE_FreePixmap 9147 +#define AUE_ChangeGC 9148 +#define AUE_CopyGC 9149 +#define AUE_SetDashes 9150 +#define AUE_SetClipRectangles 9151 +#define AUE_FreeGC 9152 +#define AUE_ClearArea 9153 +#define AUE_CopyArea 9154 +#define AUE_CopyPlane 9155 +#define AUE_PolyPoint 9156 +#define AUE_PolyLine 9157 +#define AUE_PolySegment 9158 +#define AUE_PolyRectangle 9159 +#define AUE_PolyArc 9160 +#define AUE_FillPolygon 9161 +#define AUE_PolyFillRectangle 9162 +#define AUE_PolyFillArc 9163 +#define AUE_PutImage 9164 +#define AUE_GetImage 9165 +#define AUE_PolyText8 9166 +#define AUE_PolyText16 9167 +#define AUE_ImageText8 9168 +#define AUE_ImageText16 9169 +#define AUE_CreateColormap 9170 +#define AUE_FreeColormap 9171 +#define AUE_CopyColormapAndFree 9172 +#define AUE_ListInstalledColormaps 9175 +#define AUE_AllocColor 9176 +#define AUE_AllocNamedColor 9177 +#define AUE_AllocColorCells 9178 +#define AUE_AllocColorPlanes 9179 +#define AUE_FreeColors 9180 +#define AUE_StoreColors 9181 +#define AUE_StoreNamedColor 9182 +#define AUE_QueryColors 9183 +#define AUE_LookupColor 9184 +#define AUE_CreateCursor 9185 +#define AUE_CreateGlyphCursor 9186 +#define AUE_FreeCursor 9187 +#define AUE_RecolorCursor 9188 +#define AUE_ChangeKeyboardMapping 9189 +#define AUE_ChangeKeyboardControl 9190 +#define AUE_Bell 9191 +#define AUE_ChangePointerControl 9192 +#define AUE_RotateProperties 9198 +#define AUE_ForceScreenSaver 9199 +#define AUE_SetPointerMapping 9200 +#define AUE_SetModifierMapping 9201 + +#ifdef __cplusplus +} +#endif + +#endif /* _BSM_AUDIT_UEVENTS_H */ diff --git a/illumos-x86_64/usr/include/bsm/devices.h b/illumos-x86_64/usr/include/bsm/devices.h new file mode 100644 index 00000000..48d8770d --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/devices.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _BSM_DEVICES_H +#define _BSM_DEVICES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +#define DAOPT_AUTHS "auths" +#define DAOPT_CLASS "class" +#define DAOPT_CSCRIPT "cleanscript" +#define DAOPT_MINLABEL "minlabel" +#define DAOPT_MAXLABEL "maxlabel" +#define DAOPT_XDISPLAY "xdpy" +#define DAOPT_ZONE "zone" +#define DA_RESERVED "reserved" + +/* + * These are unsupported, SUN-private interfaces. + */ + +typedef struct { + char *da_devname; + char *da_devtype; + char *da_devauth; + char *da_devexec; + kva_t *da_devopts; +} devalloc_t; + +typedef struct { + char *dmap_devname; + char *dmap_devtype; + char *dmap_devlist; + char **dmap_devarray; +} devmap_t; + +int getdadmline(char *, int, FILE *); + +devalloc_t *getdaent(void); +devalloc_t *getdatype(char *); +devalloc_t *getdanam(char *); +void setdaent(void); +void enddaent(void); +void freedaent(devalloc_t *); +void setdafile(char *); + +devmap_t *getdmapent(void); +devmap_t *getdmaptype(char *); +devmap_t *getdmapnam(char *); +devmap_t *getdmapdev(char *); +void setdmapent(void); +void enddmapent(void); +void freedmapent(devmap_t *); +void setdmapfile(char *); +char *getdmapfield(char *); +char *getdmapdfield(char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _BSM_DEVICES_H */ diff --git a/illumos-x86_64/usr/include/bsm/libbsm.h b/illumos-x86_64/usr/include/bsm/libbsm.h new file mode 100644 index 00000000..23cef801 --- /dev/null +++ b/illumos-x86_64/usr/include/bsm/libbsm.h @@ -0,0 +1,256 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _BSM_LIBBSM_H +#define _BSM_LIBBSM_H + + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TEXT_DOMAIN +#define TEXT_DOMAIN "SUNW_OST_OSLIB" +#endif + +extern const char *bsm_dom; + +/* + * For audit_event(5) + */ +struct au_event_ent { + au_event_t ae_number; + char *ae_name; + char *ae_desc; + au_class_t ae_class; +}; +typedef struct au_event_ent au_event_ent_t; + +/* + * For audit_class(5) + */ +struct au_class_ent { + char *ac_name; + au_class_t ac_class; + char *ac_desc; +}; +typedef struct au_class_ent au_class_ent_t; + +/* + * For audit_user(5) + */ +struct au_user_ent { + char *au_name; + au_mask_t au_always; + au_mask_t au_never; +}; +typedef struct au_user_ent au_user_ent_t; + +/* + * Internal representation of audit user in libnsl + */ +typedef struct au_user_str_s { + char *au_name; + char *au_always; + char *au_never; +} au_user_str_t; + +/* + * adrf's version of adr_t + */ +typedef struct adrf_s { + adr_t *adrf_adr; + FILE *adrf_fp; +} adrf_t; + +/* + * Functions that manipulate bytes from an audit file + */ + +extern void adr_char(adr_t *, char *, int); +extern int adr_count(adr_t *); +extern void adr_int32(adr_t *, int32_t *, int); +extern void adr_uid(adr_t *, uid_t *, int); +extern void adr_int64(adr_t *, int64_t *, int); +extern void adr_short(adr_t *, short *, int); +extern void adr_ushort(adr_t *, ushort_t *, int); +extern void adr_start(adr_t *, char *); + +extern int adrf_char(adrf_t *, char *, int); +extern int adrf_int32(adrf_t *, int32_t *, int); +extern int adrf_int64(adrf_t *, int64_t *, int); +extern int adrf_short(adrf_t *, short *, int); +extern void adrf_start(adrf_t *, adr_t *, FILE *); +extern int adrf_u_char(adrf_t *, uchar_t *, int); +extern int adrf_u_int32(adrf_t *, uint32_t *, int); +extern int adrf_u_int64(adrf_t *, uint64_t *, int); +extern int adrf_u_short(adrf_t *, ushort_t *, int); + +/* + * Functions that manipulate bytes from an audit character stream. + */ + +extern void adrm_start(adr_t *, char *); +extern void adrm_char(adr_t *, char *, int); +extern void adrm_short(adr_t *, short *, int); +extern void adrm_int64(adr_t *, int64_t *, int); +extern void adrm_int32(adr_t *, int32_t *, int); +extern void adrm_uid(adr_t *, uid_t *, int); +extern void adrm_u_int32(adr_t *, uint32_t *, int); +extern void adrm_u_char(adr_t *, uchar_t *, int); +extern void adrm_u_int64(adr_t *, uint64_t *, int); +extern void adrm_u_short(adr_t *, ushort_t *, int); +extern void adrm_putint32(adr_t *, int32_t *, int); + +/* + * Functions that do I/O for audit files + */ + +extern int au_close(int, int, au_event_t); +extern int au_open(void); +extern int au_write(int, token_t *); + +/* + * Functions than manipulate audit events + */ + +extern void setauevent(void); +extern void endauevent(void); + +extern au_event_ent_t *getauevent(void); +extern au_event_ent_t *getauevent_r(au_event_ent_t *); +extern au_event_ent_t *getauevnam(char *); +extern au_event_ent_t *getauevnam_r(au_event_ent_t *, char *); +extern au_event_ent_t *getauevnum(au_event_t); +extern au_event_ent_t *getauevnum_r(au_event_ent_t *, au_event_t); +extern au_event_t getauevnonam(char *); +extern int au_preselect(au_event_t, au_mask_t *, int, int); +extern int cacheauevent(au_event_ent_t **, au_event_t); + +/* + * Functions that manipulate audit classes + */ + +extern void setauclass(void); +extern void endauclass(void); + +extern int cacheauclass(au_class_ent_t **, au_class_t); +extern int cacheauclassnam(au_class_ent_t **, char *); +extern au_class_ent_t *getauclassent(void); +extern au_class_ent_t *getauclassent_r(au_class_ent_t *); +extern au_class_ent_t *getauclassnam(char *); +extern au_class_ent_t *getauclassnam_r(au_class_ent_t *, char *); + +/* + * Functions that manipulate audit masks + */ + +extern int au_user_mask(char *, au_mask_t *); +extern int getauditflagsbin(char *, au_mask_t *); +extern int getauditflagschar(char *, au_mask_t *, int); +extern int getfauditflags(au_mask_t *, au_mask_t *, au_mask_t *); +extern boolean_t __chkflags(char *, au_mask_t *, boolean_t, char **); + +/* + * Functions that do system calls + */ + +extern int audit(char *, int); +extern int auditon(int, caddr_t, int); +extern int auditdoor(int); +extern int getaudit(auditinfo_t *); +extern int getaudit_addr(auditinfo_addr_t *, int); +extern int getauid(au_id_t *); +extern int setaudit(auditinfo_t *); +extern int setaudit_addr(auditinfo_addr_t *, int); +extern int setauid(au_id_t *); + +/* + * Defines for au_preselect(3) + */ +#define AU_PRS_SUCCESS 1 +#define AU_PRS_FAILURE 2 +#define AU_PRS_BOTH (AU_PRS_SUCCESS|AU_PRS_FAILURE) + +#define AU_PRS_USECACHE 0 +#define AU_PRS_REREAD 1 + +/* + * Defines for cacheauclass and cacheauevent + */ +#define AU_CACHE_FREE 0x0000 +#define AU_CACHE_NAME 0x0001 +#define AU_CACHE_NUMBER 0x0002 + +/* Flags for user-level audit routines: au_open, au_close, au_to_ */ +#define AU_TO_NO_WRITE 0 +#define AU_TO_WRITE 1 + +/* system audit files for auditd */ +#define AUDITCLASSFILE "/etc/security/audit_class" +#define AUDITEVENTFILE "/etc/security/audit_event" +#define AUDITUSERFILE "/etc/security/audit_user" + +/* array sizes for audit library structures */ +#define AU_CLASS_NAME_MAX 8 +#define AU_CLASS_DESC_MAX 72 +#define AU_EVENT_NAME_MAX 30 +#define AU_EVENT_DESC_MAX 50 +#define AU_EVENT_LINE_MAX 256 + +/* + * Some macros used internally by the nsswitch code + */ +#define AUDITUSER_FILENAME "/etc/security/audit_user" +#define AUDITUSER_DB_NAME "audit_user.org_dir" +#define AUDITUSER_DB_NCOL 3 /* total columns */ +#define AUDITUSER_DB_NKEYCOL 1 /* total searchable columns */ +#define AUDITUSER_DB_TBLT "audit_user_tbl" +#define AUDITUSER_SUCCESS 0 +#define AUDITUSER_PARSE_ERANGE 1 +#define AUDITUSER_NOT_FOUND 2 + +#define AUDITUSER_COL0_KW "name" +#define AUDITUSER_COL1_KW "always" +#define AUDITUSER_COL2_KW "never" + +/* + * indices of searchable columns + */ +#define AUDITUSER_KEYCOL0 0 /* name */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _BSM_LIBBSM_H */ diff --git a/illumos-x86_64/usr/include/bzlib.h b/illumos-x86_64/usr/include/bzlib.h new file mode 100644 index 00000000..8966a6c5 --- /dev/null +++ b/illumos-x86_64/usr/include/bzlib.h @@ -0,0 +1,282 @@ + +/*-------------------------------------------------------------*/ +/*--- Public header file for the library. ---*/ +/*--- bzlib.h ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.8 of 13 July 2019 + Copyright (C) 1996-2019 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#ifndef _BZLIB_H +#define _BZLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define BZ_RUN 0 +#define BZ_FLUSH 1 +#define BZ_FINISH 2 + +#define BZ_OK 0 +#define BZ_RUN_OK 1 +#define BZ_FLUSH_OK 2 +#define BZ_FINISH_OK 3 +#define BZ_STREAM_END 4 +#define BZ_SEQUENCE_ERROR (-1) +#define BZ_PARAM_ERROR (-2) +#define BZ_MEM_ERROR (-3) +#define BZ_DATA_ERROR (-4) +#define BZ_DATA_ERROR_MAGIC (-5) +#define BZ_IO_ERROR (-6) +#define BZ_UNEXPECTED_EOF (-7) +#define BZ_OUTBUFF_FULL (-8) +#define BZ_CONFIG_ERROR (-9) + +typedef + struct { + char *next_in; + unsigned int avail_in; + unsigned int total_in_lo32; + unsigned int total_in_hi32; + + char *next_out; + unsigned int avail_out; + unsigned int total_out_lo32; + unsigned int total_out_hi32; + + void *state; + + void *(*bzalloc)(void *,int,int); + void (*bzfree)(void *,void *); + void *opaque; + } + bz_stream; + + +#ifndef BZ_IMPORT +#define BZ_EXPORT +#endif + +#ifndef BZ_NO_STDIO +/* Need a definitition for FILE */ +#include +#endif + +#ifdef _WIN32 +# include +# ifdef small + /* windows.h define small to char */ +# undef small +# endif +# ifdef BZ_EXPORT +# define BZ_API(func) WINAPI func +# define BZ_EXTERN extern +# else + /* import windows dll dynamically */ +# define BZ_API(func) (WINAPI * func) +# define BZ_EXTERN +# endif +#else +# define BZ_API(func) func +# define BZ_EXTERN extern +#endif + + +/*-- Core (low-level) library functions --*/ + +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( + bz_stream* strm, + int action + ); + +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( + bz_stream* strm + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + bz_stream *strm, + int verbosity, + int small + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + bz_stream* strm + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( + bz_stream *strm + ); + + + +/*-- High(er) level library functions --*/ + +#ifndef BZ_NO_STDIO +#define BZ_MAX_UNUSED 5000 + +typedef void BZFILE; + +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( + int* bzerror, + FILE* f, + int verbosity, + int small, + void* unused, + int nUnused + ); + +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( + int* bzerror, + BZFILE* b + ); + +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( + int* bzerror, + BZFILE* b, + void** unused, + int* nUnused + ); + +BZ_EXTERN int BZ_API(BZ2_bzRead) ( + int* bzerror, + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( + int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( + int* bzerror, + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out + ); + +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, + unsigned int* nbytes_out_hi32 + ); +#endif + + +/*-- Utility functions --*/ + +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( + char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( + char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int small, + int verbosity + ); + + +/*-- + Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) + to support better zlib compatibility. + This code is not _officially_ part of libbzip2 (yet); + I haven't tested it, documented it, or considered the + threading-safeness of it. + If this code breaks, please contact both Yoshioka and me. +--*/ + +BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( + void + ); + +#ifndef BZ_NO_STDIO +BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( + const char *path, + const char *mode + ); + +BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( + int fd, + const char *mode + ); + +BZ_EXTERN int BZ_API(BZ2_bzread) ( + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN int BZ_API(BZ2_bzwrite) ( + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN int BZ_API(BZ2_bzflush) ( + BZFILE* b + ); + +BZ_EXTERN void BZ_API(BZ2_bzclose) ( + BZFILE* b + ); + +BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( + BZFILE *b, + int *errnum + ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +/*-------------------------------------------------------------*/ +/*--- end bzlib.h ---*/ +/*-------------------------------------------------------------*/ diff --git a/illumos-x86_64/usr/include/complex.h b/illumos-x86_64/usr/include/complex.h new file mode 100644 index 00000000..73ac22dd --- /dev/null +++ b/illumos-x86_64/usr/include/complex.h @@ -0,0 +1,130 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _COMPLEX_H +#define _COMPLEX_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Compilation environments for Solaris must provide the _Imaginary datatype + * and the compiler intrinsics _Complex_I and _Imaginary_I + */ +#if defined(__SUNPRO_C) +#define _Complex_I _Complex_I +#define _Imaginary_I _Imaginary_I +#else +#define _Complex_I 1.0fi +#define _Imaginary_I 1.0fi +#endif +#define complex _Complex +#define imaginary _Imaginary +#undef I +#define I _Imaginary_I + +extern float cabsf(float complex); +extern float cargf(float complex); +extern float cimagf(float complex); +extern float crealf(float complex); +extern float complex cacosf(float complex); +extern float complex cacoshf(float complex); +extern float complex casinf(float complex); +extern float complex casinhf(float complex); +extern float complex catanf(float complex); +extern float complex catanhf(float complex); +extern float complex ccosf(float complex); +extern float complex ccoshf(float complex); +extern float complex cexpf(float complex); +extern float complex clogf(float complex); +extern float complex conjf(float complex); +extern float complex cpowf(float complex, float complex); +extern float complex cprojf(float complex); +extern float complex csinf(float complex); +extern float complex csinhf(float complex); +extern float complex csqrtf(float complex); +extern float complex ctanf(float complex); +extern float complex ctanhf(float complex); + +extern double cabs(double complex); +extern double carg(double complex); +extern double cimag(double complex); +extern double creal(double complex); +extern double complex cacos(double complex); +extern double complex cacosh(double complex); +extern double complex casin(double complex); +extern double complex casinh(double complex); +extern double complex catan(double complex); +extern double complex catanh(double complex); +extern double complex ccos(double complex); +extern double complex ccosh(double complex); +extern double complex cexp(double complex); +#if defined(__PRAGMA_REDEFINE_EXTNAME) +#pragma redefine_extname clog __clog +#else +#undef clog +#define clog __clog +#endif +extern double complex clog(double complex); +extern double complex conj(double complex); +extern double complex cpow(double complex, double complex); +extern double complex cproj(double complex); +extern double complex csin(double complex); +extern double complex csinh(double complex); +extern double complex csqrt(double complex); +extern double complex ctan(double complex); +extern double complex ctanh(double complex); + +extern long double cabsl(long double complex); +extern long double cargl(long double complex); +extern long double cimagl(long double complex); +extern long double creall(long double complex); +extern long double complex cacoshl(long double complex); +extern long double complex cacosl(long double complex); +extern long double complex casinhl(long double complex); +extern long double complex casinl(long double complex); +extern long double complex catanhl(long double complex); +extern long double complex catanl(long double complex); +extern long double complex ccoshl(long double complex); +extern long double complex ccosl(long double complex); +extern long double complex cexpl(long double complex); +extern long double complex clogl(long double complex); +extern long double complex conjl(long double complex); +extern long double complex cpowl(long double complex, long double complex); +extern long double complex cprojl(long double complex); +extern long double complex csinhl(long double complex); +extern long double complex csinl(long double complex); +extern long double complex csqrtl(long double complex); +extern long double complex ctanhl(long double complex); +extern long double complex ctanl(long double complex); + +#ifdef __cplusplus +} +#endif +#endif /* _COMPLEX_H */ diff --git a/illumos-x86_64/usr/include/config_admin.h b/illumos-x86_64/usr/include/config_admin.h new file mode 100644 index 00000000..4d5b71f1 --- /dev/null +++ b/illumos-x86_64/usr/include/config_admin.h @@ -0,0 +1,261 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONFIG_ADMIN_H +#define _SYS_CONFIG_ADMIN_H + +/* + * config_admin.h + * + * this file supports usage of the interfaces defined in + * config_admin.3x. which are contained in /usr/lib/libcfgadm.so.1 + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Defined constants + */ +#define CFGA_AP_LOG_ID_LEN 20 +#define CFGA_AP_PHYS_ID_LEN MAXPATHLEN +#define CFGA_INFO_LEN 4096 +#define CFGA_TYPE_LEN 12 + +#define CFGA_CLASS_LEN 12 +#define CFGA_LOG_EXT_LEN 30 + +#define CFGA_DYN_SEP "::" +#define CFGA_PHYS_EXT_LEN (CFGA_AP_PHYS_ID_LEN + CFGA_LOG_EXT_LEN) + + +/* + * Configuration change state commands + */ +typedef enum { + CFGA_CMD_NONE = 0, + CFGA_CMD_LOAD, + CFGA_CMD_UNLOAD, + CFGA_CMD_CONNECT, + CFGA_CMD_DISCONNECT, + CFGA_CMD_CONFIGURE, + CFGA_CMD_UNCONFIGURE +} cfga_cmd_t; + +/* + * Configuration states + */ +typedef enum { + CFGA_STAT_NONE = 0, + CFGA_STAT_EMPTY, + CFGA_STAT_DISCONNECTED, + CFGA_STAT_CONNECTED, + CFGA_STAT_UNCONFIGURED, + CFGA_STAT_CONFIGURED +} cfga_stat_t; + +/* + * Configuration conditions + */ +typedef enum { + CFGA_COND_UNKNOWN = 0, + CFGA_COND_OK, + CFGA_COND_FAILING, + CFGA_COND_FAILED, + CFGA_COND_UNUSABLE +} cfga_cond_t; + +/* + * Flags + */ +#define CFGA_FLAG_FORCE 1 +#define CFGA_FLAG_VERBOSE 2 +#define CFGA_FLAG_LIST_ALL 4 + +typedef char cfga_ap_log_id_t[CFGA_AP_LOG_ID_LEN]; +typedef char cfga_ap_phys_id_t[CFGA_AP_PHYS_ID_LEN]; +typedef char cfga_info_t[CFGA_INFO_LEN]; +typedef char cfga_type_t[CFGA_TYPE_LEN]; +typedef int cfga_flags_t; +typedef int cfga_busy_t; + + +typedef char cfga_log_ext_t[CFGA_LOG_EXT_LEN]; +typedef char cfga_phys_ext_t[CFGA_PHYS_EXT_LEN]; +typedef char cfga_class_t[CFGA_CLASS_LEN]; + +typedef struct cfga_list_data { + cfga_log_ext_t ap_log_id; /* Attachment point logical id */ + cfga_phys_ext_t ap_phys_id; /* Attachment point physical id */ + cfga_class_t ap_class; /* Attachment point class */ + cfga_stat_t ap_r_state; /* Receptacle state */ + cfga_stat_t ap_o_state; /* Occupant state */ + cfga_cond_t ap_cond; /* Attachment point condition */ + cfga_busy_t ap_busy; /* Busy indicators */ + time_t ap_status_time; /* Attachment point last change */ + cfga_info_t ap_info; /* Miscellaneous information */ + cfga_type_t ap_type; /* Occupant type */ +} cfga_list_data_t; + +/* + * The following structure is retained for backward compatibility + */ +typedef struct cfga_stat_data { + cfga_ap_log_id_t ap_log_id; /* Attachment point logical id */ + cfga_ap_phys_id_t ap_phys_id; /* Attachment point physical id */ + cfga_stat_t ap_r_state; /* Receptacle state */ + cfga_stat_t ap_o_state; /* Occupant state */ + cfga_cond_t ap_cond; /* Attachment point condition */ + cfga_busy_t ap_busy; /* Busy indicators */ + time_t ap_status_time; /* Attachment point last change */ + cfga_info_t ap_info; /* Miscellaneous information */ + cfga_type_t ap_type; /* Occupant type */ +} cfga_stat_data_t; + + +struct cfga_confirm { + int (*confirm)(void *appdata_ptr, const char *message); + void *appdata_ptr; +}; + +struct cfga_msg { + int (*message_routine)(void *appdata_ptr, const char *message); + void *appdata_ptr; +}; + +/* + * Library function error codes returned by all functions below + * except config_strerror which is used to decode the error + * codes. + */ +typedef enum { + CFGA_OK = 0, + CFGA_NACK, + CFGA_NOTSUPP, + CFGA_OPNOTSUPP, + CFGA_PRIV, + CFGA_BUSY, + CFGA_SYSTEM_BUSY, + CFGA_DATA_ERROR, + CFGA_LIB_ERROR, + CFGA_NO_LIB, + CFGA_INSUFFICENT_CONDITION, + CFGA_INVAL, + CFGA_ERROR, + CFGA_APID_NOEXIST, + CFGA_ATTR_INVAL +} cfga_err_t; + + +/* + * config_admin.3x library interfaces + */ + +cfga_err_t config_change_state(cfga_cmd_t state_change_cmd, int num_ap_ids, + char *const *ap_ids, const char *options, struct cfga_confirm *confp, + struct cfga_msg *msgp, char **errstring, cfga_flags_t flags); + +cfga_err_t config_private_func(const char *function, int num_ap_ids, + char *const *ap_ids, const char *options, struct cfga_confirm *confp, + struct cfga_msg *msgp, char **errstring, cfga_flags_t flags); + +cfga_err_t config_test(int num_ap_ids, char *const *ap_ids, + const char *options, struct cfga_msg *msgp, char **errstring, + cfga_flags_t flags); + +cfga_err_t config_list_ext(int num_ap_ids, char *const *ap_ids, + struct cfga_list_data **ap_id_list, int *nlist, const char *options, + const char *listopts, char **errstring, cfga_flags_t flags); + +cfga_err_t config_help(int num_ap_ids, char *const *ap_ids, + struct cfga_msg *msgp, const char *options, cfga_flags_t flags); + +const char *config_strerror(cfga_err_t cfgerrnum); + +int config_ap_id_cmp(const cfga_ap_log_id_t ap_id1, + const cfga_ap_log_id_t ap_id2); + +void config_unload_libs(); + +/* + * The following two routines are retained only for backward compatibility + */ +cfga_err_t config_stat(int num_ap_ids, char *const *ap_ids, + struct cfga_stat_data *buf, const char *options, char **errstring); + +cfga_err_t config_list(struct cfga_stat_data **ap_di_list, int *nlist, + const char *options, char **errstring); + + +#ifdef CFGA_PLUGIN_LIB +/* + * Plugin library routine hooks - only to be used by the generic + * library and plugin libraries (who must define CFGA_PLUGIN_LIB + * prior to the inclusion of this header). + */ + +cfga_err_t cfga_change_state(cfga_cmd_t, const char *, const char *, + struct cfga_confirm *, struct cfga_msg *, char **, cfga_flags_t); +cfga_err_t cfga_private_func(const char *, const char *, const char *, + struct cfga_confirm *, struct cfga_msg *, char **, cfga_flags_t); +cfga_err_t cfga_test(const char *, const char *, struct cfga_msg *, + char **, cfga_flags_t); +cfga_err_t cfga_list_ext(const char *, struct cfga_list_data **, int *, + const char *, const char *, char **, cfga_flags_t); +cfga_err_t cfga_help(struct cfga_msg *, const char *, cfga_flags_t); +int cfga_ap_id_cmp(const cfga_ap_log_id_t, + const cfga_ap_log_id_t); + + +/* + * Plugin version information. + */ +#define CFGA_HSL_V1 1 +#define CFGA_HSL_V2 2 +#define CFGA_HSL_VERS CFGA_HSL_V2 + +/* + * The following two routines are retained only for backward compatibility. + */ +cfga_err_t cfga_stat(const char *, struct cfga_stat_data *, + const char *, char **); +cfga_err_t cfga_list(const char *, struct cfga_stat_data **, int *, + const char *, char **); + + +#endif /* CFGA_PLUGIN_LIB */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONFIG_ADMIN_H */ diff --git a/illumos-x86_64/usr/include/cpio.h b/illumos-x86_64/usr/include/cpio.h new file mode 100644 index 00000000..ca007915 --- /dev/null +++ b/illumos-x86_64/usr/include/cpio.h @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _CPIO_H +#define _CPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following are values used by c_mode field of the cpio archive. + */ + +#define C_IRUSR 0000400 +#define C_IWUSR 0000200 +#define C_IXUSR 0000100 +#define C_IRGRP 0000040 +#define C_IWGRP 0000020 +#define C_IXGRP 0000010 +#define C_IROTH 0000004 +#define C_IWOTH 0000002 +#define C_IXOTH 0000001 +#define C_ISUID 0004000 +#define C_ISGID 0002000 +#define C_ISVTX 0001000 +#define C_ISDIR 0040000 +#define C_ISFIFO 0010000 +#define C_ISREG 0100000 +#define C_ISBLK 0060000 +#define C_ISCHR 0020000 +#define C_ISCTG 0110000 +#define C_ISLNK 0120000 +#define C_ISSOCK 0140000 + +#define MAGIC "070707" + +#ifdef __cplusplus +} +#endif + +#endif /* _CPIO_H */ diff --git a/illumos-x86_64/usr/include/crypt.h b/illumos-x86_64/usr/include/crypt.h new file mode 100644 index 00000000..45a6fc84 --- /dev/null +++ b/illumos-x86_64/usr/include/crypt.h @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _CRYPT_H +#define _CRYPT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Password and file encryption functions */ + +#define CRYPT_MAXCIPHERTEXTLEN 512 + +extern char *crypt(const char *, const char *); +extern char *crypt_gensalt(const char *, const struct passwd *); +extern char *crypt_genhash_impl(char *, size_t, const char *, + const char *, const char **); +extern char *crypt_gensalt_impl(char *, size_t, const char *, + const struct passwd *, const char **); +extern int crypt_close(int *); +extern char *des_crypt(const char *, const char *); +extern void des_encrypt(char *, int); +extern void des_setkey(const char *); +extern void encrypt(char *, int); +extern int run_crypt(long, char *, unsigned, int *); +extern int run_setkey(int *, const char *); +extern void setkey(const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _CRYPT_H */ diff --git a/illumos-x86_64/usr/include/cryptoutil.h b/illumos-x86_64/usr/include/cryptoutil.h new file mode 100644 index 00000000..71420555 --- /dev/null +++ b/illumos-x86_64/usr/include/cryptoutil.h @@ -0,0 +1,237 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved. + * Copyright 2018, Joyent, Inc. + */ + +#ifndef _CRYPTOUTIL_H +#define _CRYPTOUTIL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#define LOG_STDERR -1 +#define SUCCESS 0 +#define FAILURE 1 +#define MECH_ID_HEX_LEN 11 /* length of mechanism id in hex form */ + +#define _PATH_PKCS11_CONF "/etc/crypto/pkcs11.conf" +#define _PATH_KCF_CONF "/etc/crypto/kcf.conf" +#define _PATH_KCFD_LOCK "/var/run/kcfd.lock" + +/* $ISA substitution for parsing pkcs11.conf data */ +#define PKCS11_ISA "/$ISA/" +#if defined(_LP64) +#define PKCS11_ISA_DIR "/64/" +#else /* !_LP64 */ +#define PKCS11_ISA_DIR "/" +#endif + +/* keywords and delimiters for parsing configuration files */ +#define SEP_COLON ":" +#define SEP_SEMICOLON ";" +#define SEP_EQUAL "=" +#define SEP_COMMA "," +#define METASLOT_KEYWORD "metaslot" +#define FIPS_KEYWORD "fips-140" +#define EF_DISABLED "disabledlist=" +#define EF_ENABLED "enabledlist=" +#define EF_NORANDOM "NO_RANDOM" +#define METASLOT_TOKEN "metaslot_token=" +#define METASLOT_SLOT "metaslot_slot=" +#define METASLOT_STATUS "metaslot_status=" +#define EF_FIPS_STATUS "fips_status=" +#define METASLOT_AUTO_KEY_MIGRATE "metaslot_auto_key_migrate=" +#define ENABLED_KEYWORD "enabled" +#define DISABLED_KEYWORD "disabled" +#define SLOT_DESCRIPTION_SIZE 64 +#define TOKEN_LABEL_SIZE 32 +#define TOKEN_MANUFACTURER_SIZE 32 +#define TOKEN_SERIAL_SIZE 16 +#define CRYPTO_FIPS_MODE_DISABLED 0 +#define CRYPTO_FIPS_MODE_ENABLED 1 + +/* + * Define the following softtoken values that are used by softtoken + * library, cryptoadm and pktool command. + */ +#define SOFT_SLOT_DESCRIPTION \ + "Sun Crypto Softtoken " \ + " " +#define SOFT_TOKEN_LABEL "Sun Software PKCS#11 softtoken " +#define SOFT_TOKEN_SERIAL " " +#define SOFT_MANUFACTURER_ID "Sun Microsystems, Inc. " +#define SOFT_DEFAULT_PIN "changeme" + +typedef char libname_t[MAXPATHLEN]; +typedef char midstr_t[MECH_ID_HEX_LEN]; + +typedef struct umechlist { + midstr_t name; /* mechanism name in hex form */ + struct umechlist *next; +} umechlist_t; + +typedef struct uentry { + libname_t name; + boolean_t flag_norandom; /* TRUE if random is disabled */ + boolean_t flag_enabledlist; /* TRUE if an enabledlist */ + umechlist_t *policylist; /* disabledlist or enabledlist */ + boolean_t flag_metaslot_enabled; /* TRUE if metaslot's enabled */ + boolean_t flag_metaslot_auto_key_migrate; + CK_UTF8CHAR metaslot_ks_slot[SLOT_DESCRIPTION_SIZE + 1]; + CK_UTF8CHAR metaslot_ks_token[TOKEN_LABEL_SIZE + 1]; + int count; + boolean_t flag_fips_enabled; +} uentry_t; + +typedef struct uentrylist { + uentry_t *puent; + struct uentrylist *next; +} uentrylist_t; + +/* Return codes for pkcs11_parse_uri() */ +#define PK11_URI_OK 0 +#define PK11_URI_INVALID 1 +#define PK11_MALLOC_ERROR 2 +#define PK11_URI_VALUE_OVERFLOW 3 +#define PK11_NOT_PKCS11_URI 4 + +/* + * There is no limit for the attribute length in the spec. 256 bytes should be + * enough for the object name. + */ +#define PK11_MAX_OBJECT_LEN 256 +/* + * CKA_ID is of type "byte array" which can be of arbitrary length. 256 bytes + * should be sufficient though. + */ +#define PK11_MAX_ID_LEN 256 + +/* Structure for the PKCS#11 URI. */ +typedef struct pkcs11_uri_t { + /* CKA_LABEL attribute to the C_FindObjectsInit function. */ + CK_UTF8CHAR_PTR object; + /* + * CKA_CLASS attribute to the C_FindObjectsInit function. The + * "objecttype" URI attribute can have a value one of "private", + * "public", "cert", "secretkey", and "data". The "objecttype" field can + * have a value of CKO_PUBLIC_KEY, CKO_PRIVATE_KEY, CKO_CERTIFICATE, + * CKO_SECRET_KEY, and CKO_DATA. This attribute cannot be empty in the + * URI. + */ + CK_ULONG objecttype; + /* CKO_DATA is 0 so we need this flag. Not part of the URI itself. */ + boolean_t objecttype_present; + /* + * Token, manufufacturer, serial and model are of fixed size length in + * the specification. We allocate memory on the fly to distinguish + * between an attribute not present and an empty value. We check for + * overflows. We always terminate the string with '\0' even when that is + * not used in the PKCS#11's CK_TOKEN_INFO structure (fields are padded + * with spaces). + */ + /* Token label from CK_TOKEN_INFO. */ + CK_UTF8CHAR_PTR token; + /* ManufacturerID from CK_TOKEN_INFO. */ + CK_UTF8CHAR_PTR manuf; + /* SerialNumber from CK_TOKEN_INFO. */ + CK_CHAR_PTR serial; + /* Model from CK_TOKEN_INFO. */ + CK_UTF8CHAR_PTR model; + /* This is a byte array, we need a length parameter as well. */ + CK_BYTE_PTR id; + int id_len; + /* + * Location of the file with a token PIN. Application can overload this, + * eg. "/bin/askpass|" may mean to read the PIN from a command. However, + * the pkcs11_parse_uri() function does not interpret this field in any + * way. + */ + char *pinfile; +} pkcs11_uri_t; + +extern void cryptodebug(const char *fmt, ...); +extern void cryptoerror(int priority, const char *fmt, ...); +extern void cryptodebug_init(const char *prefix); +extern void cryptoerror_off(); +extern void cryptoerror_on(); + +extern const char *pkcs11_mech2str(CK_MECHANISM_TYPE mech); +extern CK_RV pkcs11_str2mech(char *mech_str, CK_MECHANISM_TYPE_PTR mech); + +extern int get_pkcs11conf_info(uentrylist_t **); +extern umechlist_t *create_umech(char *); +extern void free_umechlist(umechlist_t *); +extern void free_uentrylist(uentrylist_t *); +extern void free_uentry(uentry_t *); +extern uentry_t *getent_uef(char *); + +extern void tohexstr(uchar_t *bytes, size_t blen, char *hexstr, size_t hexlen); +extern int hexstr_to_bytes(char *hexstr, size_t hexlen, uchar_t **bytes, + size_t *blen); +extern CK_RV pkcs11_mech2keytype(CK_MECHANISM_TYPE mech_type, + CK_KEY_TYPE *ktype); +extern CK_RV pkcs11_mech2keygen(CK_MECHANISM_TYPE mech_type, + CK_MECHANISM_TYPE *gen_mech); +extern char *pkcs11_strerror(CK_RV rv); + +extern int +get_metaslot_info(boolean_t *status_enabled, boolean_t *migrate_enabled, + char **objectstore_slot_info, char **objectstore_token_info); + +extern char *get_fullpath(char *dir, char *filepath); +extern int str2lifetime(char *ltimestr, uint32_t *ltime); + +extern char *pkcs11_default_token(void); +extern int pkcs11_get_pass(char *token_name, char **pdata, size_t *psize, + size_t min_psize, boolean_t with_confirmation); + +extern int pkcs11_seed_urandom(void *sbuf, size_t slen); +extern int pkcs11_get_random(void *dbuf, size_t dlen); +extern int pkcs11_get_urandom(void *dbuf, size_t dlen); +extern int pkcs11_get_nzero_urandom(void *dbuf, size_t dlen); +extern int pkcs11_read_data(char *filename, void **dbuf, size_t *dlen); + +extern int open_nointr(const char *path, int oflag, ...); +extern ssize_t readn_nointr(int fd, void *dbuf, size_t dlen); +extern ssize_t writen_nointr(int fd, void *dbuf, size_t dlen); +extern int update_conf(char *conf_file, char *entry); + +extern int pkcs11_parse_uri(const char *str, pkcs11_uri_t *uri); +extern void pkcs11_free_uri(pkcs11_uri_t *uri); + +extern CK_RV crypto2pkcs11_error_number(uint_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _CRYPTOUTIL_H */ diff --git a/illumos-x86_64/usr/include/ctf-api.h b/illumos-x86_64/usr/include/ctf-api.h new file mode 100644 index 00000000..2bffd52b --- /dev/null +++ b/illumos-x86_64/usr/include/ctf-api.h @@ -0,0 +1,1026 @@ +/* Public API to libctf. + Copyright (C) 2019-2025 Free Software Foundation, Inc. + + This file is part of libctf. + + libctf is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not see + . */ + +/* This header file defines the interfaces available from the CTF debugger + library, libctf. This API can be used by a debugger to operate on data in + the Compact ANSI-C Type Format (CTF). */ + +#ifndef _CTF_API_H +#define _CTF_API_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Clients can open one or more CTF containers and obtain a pointer to an + opaque ctf_dict_t. Types are identified by an opaque ctf_id_t token. + They can also open or create read-only archives of CTF containers in a + ctf_archive_t. + + These opaque definitions allow libctf to evolve without breaking clients. */ + +typedef struct ctf_dict ctf_dict_t; +typedef struct ctf_archive_internal ctf_archive_t; +typedef unsigned long ctf_id_t; + +/* This opaque definition allows libctf to accept BFD data structures without + importing all the BFD noise into users' namespaces. */ + +struct bfd; + +/* If the debugger needs to provide the CTF library with a set of raw buffers + for use as the CTF data, symbol table, and string table, it can do so by + filling in ctf_sect_t structures and passing them to ctf_bufopen. + + The contents of this structure must always be in native endianness. At read + time, the symbol table endianness is derived from the BFD target (if BFD is + in use): if a BFD target is not in use, please call ctf_symsect_endianness or + ctf_arc_symsect_endianness. */ + +typedef struct ctf_sect +{ + const char *cts_name; /* Section name (if any). */ + const void *cts_data; /* Pointer to section data. */ + size_t cts_size; /* Size of data in bytes. */ + size_t cts_entsize; /* Size of each section entry (symtab only). */ +} ctf_sect_t; + +/* A minimal symbol extracted from a linker's internal symbol table + representation. The symbol name can be given either via st_name or via a + strtab offset in st_nameidx, which corresponds to one of the string offsets + communicated via the ctf_link_add_strtab callback. */ + +typedef struct ctf_link_sym +{ + /* The st_name and st_nameidx will not be accessed outside the call to + ctf_link_shuffle_syms. If you set st_nameidx to offset zero, make sure + to set st_nameidx_set as well. */ + + const char *st_name; + size_t st_nameidx; + int st_nameidx_set; + uint32_t st_symidx; + uint32_t st_shndx; + uint32_t st_type; + uint32_t st_value; +} ctf_link_sym_t; + +/* Flags applying to this specific link. */ + +/* Share all types that are not in conflict. The default. */ +#define CTF_LINK_SHARE_UNCONFLICTED 0x0 + +/* Share only types that are used by multiple inputs. */ +#define CTF_LINK_SHARE_DUPLICATED 0x1 + +/* Do a nondeduplicating link, or otherwise deduplicate "less hard", trading off + CTF output size for link time. */ +#define CTF_LINK_NONDEDUP 0x2 + +/* Create empty outputs for all registered CU mappings even if no types are + emitted into them. */ +#define CTF_LINK_EMPTY_CU_MAPPINGS 0x4 + +/* Omit the content of the variables section. */ +#define CTF_LINK_OMIT_VARIABLES_SECTION 0x8 + +/* If *unset*, filter out entries corresponding to linker-reported symbols + from the variable section, and filter out all entries with no linker-reported + symbols from the data object and function info sections: if set, do no + filtering and leave all entries in place. (This is a negative-sense flag + because it is rare to want symbols the linker has not reported as present to + stick around in the symtypetab sections nonetheless: relocatable links are + the only likely case.) */ +#define CTF_LINK_NO_FILTER_REPORTED_SYMS 0x10 + +/* Symbolic names for CTF sections. */ + +typedef enum ctf_sect_names + { + CTF_SECT_HEADER, + CTF_SECT_LABEL, + CTF_SECT_OBJT, + CTF_SECT_OBJTIDX = CTF_SECT_OBJT, + CTF_SECT_FUNC, + CTF_SECT_FUNCIDX = CTF_SECT_FUNC, + CTF_SECT_VAR, + CTF_SECT_TYPE, + CTF_SECT_STR + } ctf_sect_names_t; + +/* Encoding information for integers, floating-point values, and certain other + intrinsics can be obtained by calling ctf_type_encoding, below. The flags + field will contain values appropriate for the type defined in . */ + +typedef struct ctf_encoding +{ + uint32_t cte_format; /* Data format (CTF_INT_* or CTF_FP_* flags). */ + uint32_t cte_offset; /* Offset of value in bits. */ + uint32_t cte_bits; /* Size of storage in bits. */ +} ctf_encoding_t; + +typedef struct ctf_membinfo +{ + ctf_id_t ctm_type; /* Type of struct or union member. */ + unsigned long ctm_offset; /* Offset of member in bits. */ +} ctf_membinfo_t; + +typedef struct ctf_arinfo +{ + ctf_id_t ctr_contents; /* Type of array contents. */ + ctf_id_t ctr_index; /* Type of array index. */ + uint32_t ctr_nelems; /* Number of elements. */ +} ctf_arinfo_t; + +typedef struct ctf_funcinfo +{ + ctf_id_t ctc_return; /* Function return type. */ + uint32_t ctc_argc; /* Number of typed arguments to function. */ + uint32_t ctc_flags; /* Function attributes (see below). */ +} ctf_funcinfo_t; + +typedef struct ctf_lblinfo +{ + ctf_id_t ctb_type; /* Last type associated with the label. */ +} ctf_lblinfo_t; + +typedef struct ctf_snapshot_id +{ + unsigned long dtd_id; /* Highest DTD ID at time of snapshot. */ + unsigned long snapshot_id; /* Snapshot id at time of snapshot. */ +} ctf_snapshot_id_t; + +#define CTF_FUNC_VARARG 0x1 /* Function arguments end with varargs. */ + +/* Functions that return a ctf_id_t use the following value to indicate failure. + ctf_errno can be used to obtain an error code. Functions that return + a straight integral -1 also use ctf_errno. */ +#define CTF_ERR ((ctf_id_t) -1L) + +/* This macro holds information about all the available ctf errors. + It is used to form both an enum holding all the error constants, + and also the error strings themselves. To use, define _CTF_FIRST + and _CTF_ITEM to expand as you like, then mention the macro name. + See the enum after this for an example. */ +#define _CTF_ERRORS \ + _CTF_FIRST (ECTF_FMT, "File is not in CTF or ELF format.") \ + _CTF_ITEM (ECTF_BFDERR, "BFD error.") \ + _CTF_ITEM (ECTF_CTFVERS, "CTF dict version is too new for libctf.") \ + _CTF_ITEM (ECTF_BFD_AMBIGUOUS, "Ambiguous BFD target.") \ + _CTF_ITEM (ECTF_SYMTAB, "Symbol table uses invalid entry size.") \ + _CTF_ITEM (ECTF_SYMBAD, "Symbol table data buffer is not valid.") \ + _CTF_ITEM (ECTF_STRBAD, "String table data buffer is not valid.") \ + _CTF_ITEM (ECTF_CORRUPT, "File data structure corruption detected.") \ + _CTF_ITEM (ECTF_NOCTFDATA, "File does not contain CTF data.") \ + _CTF_ITEM (ECTF_NOCTFBUF, "Buffer does not contain CTF data.") \ + _CTF_ITEM (ECTF_NOSYMTAB, "Symbol table information is not available.") \ + _CTF_ITEM (ECTF_NOPARENT, "The parent CTF dictionary is needed but unavailable.") \ + _CTF_ITEM (ECTF_DMODEL, "Data model mismatch.") \ + _CTF_ITEM (ECTF_LINKADDEDLATE, "File added to link too late.") \ + _CTF_ITEM (ECTF_ZALLOC, "Failed to allocate (de)compression buffer.") \ + _CTF_ITEM (ECTF_DECOMPRESS, "Failed to decompress CTF data.") \ + _CTF_ITEM (ECTF_STRTAB, "External string table is not available.") \ + _CTF_ITEM (ECTF_BADNAME, "String name offset is corrupt.") \ + _CTF_ITEM (ECTF_BADID, "Invalid type identifier.") \ + _CTF_ITEM (ECTF_NOTSOU, "Type is not a struct or union.") \ + _CTF_ITEM (ECTF_NOTENUM, "Type is not an enum.") \ + _CTF_ITEM (ECTF_NOTSUE, "Type is not a struct, union, or enum.") \ + _CTF_ITEM (ECTF_NOTINTFP, "Type is not an integer, float, or enum.") \ + _CTF_ITEM (ECTF_NOTARRAY, "Type is not an array.") \ + _CTF_ITEM (ECTF_NOTREF, "Type does not reference another type.") \ + _CTF_ITEM (ECTF_NAMELEN, "Buffer is too small to hold type name.") \ + _CTF_ITEM (ECTF_NOTYPE, "No type found corresponding to name.") \ + _CTF_ITEM (ECTF_SYNTAX, "Syntax error in type name.") \ + _CTF_ITEM (ECTF_NOTFUNC, "Symbol table entry or type is not a function.") \ + _CTF_ITEM (ECTF_NOFUNCDAT, "No function information available for function.") \ + _CTF_ITEM (ECTF_NOTDATA, "Symbol table entry does not refer to a data object.") \ + _CTF_ITEM (ECTF_NOTYPEDAT, "No type information available for symbol.") \ + _CTF_ITEM (ECTF_NOLABEL, "No label found corresponding to name.") \ + _CTF_ITEM (ECTF_NOLABELDATA, "File does not contain any labels.") \ + _CTF_ITEM (ECTF_NOTSUP, "Feature not supported.") \ + _CTF_ITEM (ECTF_NOENUMNAM, "Enumerator name not found.") \ + _CTF_ITEM (ECTF_NOMEMBNAM, "Member name not found.") \ + _CTF_ITEM (ECTF_RDONLY, "CTF container is read-only.") \ + _CTF_ITEM (ECTF_DTFULL, "CTF type is full (no more members allowed).") \ + _CTF_ITEM (ECTF_FULL, "CTF container is full.") \ + _CTF_ITEM (ECTF_DUPLICATE, "Duplicate member, enumerator, or variable name.") \ + _CTF_ITEM (ECTF_CONFLICT, "Conflicting type is already defined.") \ + _CTF_ITEM (ECTF_OVERROLLBACK, "Attempt to roll back past a ctf_update.") \ + _CTF_ITEM (ECTF_COMPRESS, "Failed to compress CTF data.") \ + _CTF_ITEM (ECTF_ARCREATE, "Error creating CTF archive.") \ + _CTF_ITEM (ECTF_ARNNAME, "Name not found in CTF archive.") \ + _CTF_ITEM (ECTF_SLICEOVERFLOW, "Overflow of type bitness or offset in slice.") \ + _CTF_ITEM (ECTF_DUMPSECTUNKNOWN, "Unknown section number in dump.") \ + _CTF_ITEM (ECTF_DUMPSECTCHANGED, "Section changed in middle of dump.") \ + _CTF_ITEM (ECTF_NOTYET, "Feature not yet implemented.") \ + _CTF_ITEM (ECTF_INTERNAL, "Internal error: assertion failure.") \ + _CTF_ITEM (ECTF_NONREPRESENTABLE, "Type not representable in CTF.") \ + _CTF_ITEM (ECTF_NEXT_END, "End of iteration.") \ + _CTF_ITEM (ECTF_NEXT_WRONGFUN, "Wrong iteration function called.") \ + _CTF_ITEM (ECTF_NEXT_WRONGFP, "Iteration entity changed in mid-iterate.") \ + _CTF_ITEM (ECTF_FLAGS, "CTF header contains flags unknown to libctf.") \ + _CTF_ITEM (ECTF_NEEDSBFD, "This feature needs a libctf with BFD support.") \ + _CTF_ITEM (ECTF_INCOMPLETE, "Type is not a complete type.") \ + _CTF_ITEM (ECTF_NONAME, "Type name must not be empty.") \ + _CTF_ITEM (ECTF_BADFLAG, "Invalid CTF dict flag specified.") + +#define ECTF_BASE 1000 /* Base value for libctf errnos. */ + +enum + { +#define _CTF_FIRST(NAME, STR) NAME = ECTF_BASE +#define _CTF_ITEM(NAME, STR) , NAME +_CTF_ERRORS +#undef _CTF_ITEM +#undef _CTF_FIRST + }; + +#define ECTF_NERR (ECTF_BADFLAG - ECTF_BASE + 1) /* Count of CTF errors. */ + +/* The CTF data model is inferred to be the caller's data model or the data + model of the given object, unless ctf_setmodel is explicitly called. */ +#define CTF_MODEL_ILP32 1 /* Object data model is ILP32. */ +#define CTF_MODEL_LP64 2 /* Object data model is LP64. */ +#ifdef _LP64 +# define CTF_MODEL_NATIVE CTF_MODEL_LP64 +#else +# define CTF_MODEL_NATIVE CTF_MODEL_ILP32 +#endif + +/* Dynamic CTF containers can be created using ctf_create. The ctf_add_* + routines can be used to add new definitions to the dynamic container. New + types are labeled as root or non-root to determine whether they are visible + at the top-level program scope when subsequently doing a lookup. + (Identifiers contained within non-root types, like enumeration constants, are + also not visible.) */ + +#define CTF_ADD_NONROOT 0 /* Type only visible in nested scope. */ +#define CTF_ADD_ROOT 1 /* Type visible at top-level scope. */ + +/* Flags for ctf_member_next. */ + +#define CTF_MN_RECURSE 0x1 /* Recurse into unnamed members. */ + +/* Flags for ctf_dict_set_flag. */ + +/* If set, duplicate enumerators in a single dict fail with ECTF_DUPLICATE. */ + +#define CTF_STRICT_NO_DUP_ENUMERATORS 0x1 + +/* These typedefs are used to define the signature for callback functions that + can be used with the iteration and visit functions below. There is also a + family of iteration functions that do not require callbacks. */ + +typedef int ctf_visit_f (const char *name, ctf_id_t type, unsigned long offset, + int depth, void *arg); +typedef int ctf_member_f (const char *name, ctf_id_t membtype, + unsigned long offset, void *arg); +typedef int ctf_enum_f (const char *name, int val, void *arg); +typedef int ctf_variable_f (const char *name, ctf_id_t type, void *arg); +typedef int ctf_type_f (ctf_id_t type, void *arg); +typedef int ctf_type_all_f (ctf_id_t type, int flag, void *arg); +typedef int ctf_label_f (const char *name, const ctf_lblinfo_t *info, + void *arg); +typedef int ctf_archive_member_f (ctf_dict_t *fp, const char *name, void *arg); +typedef int ctf_archive_raw_member_f (const char *name, const void *content, + size_t len, void *arg); +typedef char *ctf_dump_decorate_f (ctf_sect_names_t sect, + char *line, void *arg); + +typedef struct ctf_dump_state ctf_dump_state_t; + +/* Iteration state for the _next functions, and allocators/copiers/freers for + it. (None of these are needed for the simple case of iterating to the end: + the _next functions allocate and free the iterators for you.) + + The _next iterators all work in similar ways: they take things to query (a + dict, a name, a type ID, something like that), then a ctf_next_t iterator + arg which must be the address of a variable whose value is NULL on first + call, and will be set to NULL again once iteration has completed. + + They return something important about the thing being iterated over (often a + type ID or a name); on end of iteration they instead return return CTF_ERR, + -1, or NULL and set the error ECTF_NEXT_END on the dict. They can often + provide more information too: this is done via pointer parameters (e.g. the + membname and membtype in ctf_member_next()). These parameters are always + optional and can be set to NULL if not needed. + + Errors other than end-of-iteration will return CTF_ERR/-1/NULL and set the + error to something other than ECTF_NEXT_END, and *not* destroy the iterator: + you should either recover somehow and continue iterating, or call + ctf_next_destroy() on it. (You can call ctf_next_destroy() on a NULL + iterator, so it's safe to just unconditionally do it after iteration has + completed.) */ + +typedef struct ctf_next ctf_next_t; +extern ctf_next_t *ctf_next_create (void); +extern void ctf_next_destroy (ctf_next_t *); +extern ctf_next_t *ctf_next_copy (ctf_next_t *); + +/* Opening. These mostly return an abstraction over both CTF files and CTF + archives: so they can be used to open both. CTF files will appear to be an + archive with one member named '.ctf'. + + All these functions except for ctf_close use BFD and can open anything BFD + can open, hunting down the .ctf section for you, so are not available in the + libctf-nobfd flavour of the library. If you want to provide the CTF section + yourself, you can do that with ctf_bfdopen_ctfsect. */ + +extern ctf_archive_t *ctf_bfdopen (struct bfd *, int *); +extern ctf_archive_t *ctf_bfdopen_ctfsect (struct bfd *, const ctf_sect_t *, + int *); +extern ctf_archive_t *ctf_fdopen (int fd, const char *filename, + const char *target, int *errp); +extern ctf_archive_t *ctf_open (const char *filename, + const char *target, int *errp); +extern void ctf_close (ctf_archive_t *); + +/* Set or unset dict-wide boolean flags, and get the value of these flags. */ + +extern int ctf_dict_set_flag (ctf_dict_t *, uint64_t flag, int set); +extern int ctf_dict_get_flag (ctf_dict_t *, uint64_t flag); + +/* Return the data, symbol, or string sections used by a given CTF dict. */ +extern ctf_sect_t ctf_getdatasect (const ctf_dict_t *); +extern ctf_sect_t ctf_getsymsect (const ctf_dict_t *); +extern ctf_sect_t ctf_getstrsect (const ctf_dict_t *); + +/* Set the endianness of the symbol section, which may be different from + the endianness of the CTF dict. Done for you by ctf_open and ctf_fdopen, + but direct calls to ctf_bufopen etc with symbol sections provided must + do so explicitly. */ + +extern void ctf_symsect_endianness (ctf_dict_t *, int little_endian); +extern void ctf_arc_symsect_endianness (ctf_archive_t *, int little_endian); + +/* Open CTF archives from files or raw section data, and close them again. + Closing may munmap() the data making up the archive, so should not be + done until all dicts are finished with and closed themselves. + + Almost all functions that open archives will also open raw CTF dicts, which + are treated as if they were archives with only one member. + + Some of these functions take optional raw symtab and strtab section content + in the form of ctf_sect_t structures. For CTF in ELF files, the more + convenient opening functions above extract these .dynsym and its associated + string table (usually .dynsym) whenever the CTF_F_DYNSTR flag is set in the + CTF preamble (which it almost always will be for linked objects, but not for + .o files). If you use ctf_arc_bufopen and do not specify symbol/string + tables, the ctf_*_lookuup_symbol functions will fail with ECTF_NOSYMTAB. + + Like many other convenient opening functions, ctf_arc_open needs BFD and is + not available in libctf-nobfd. */ + +extern ctf_archive_t *ctf_arc_open (const char *, int *); +extern ctf_archive_t *ctf_arc_bufopen (const ctf_sect_t *ctfsect, + const ctf_sect_t *symsect, + const ctf_sect_t *strsect, + int *); +extern void ctf_arc_close (ctf_archive_t *); + +/* Get the archive a given dictionary came from (if any). */ + +extern ctf_archive_t *ctf_get_arc (const ctf_dict_t *); + +/* Return the number of members in an archive. */ + +extern size_t ctf_archive_count (const ctf_archive_t *); + +/* Open a dictionary with a given name, given a CTF archive and + optionally symbol and string table sections to accompany it (if the + archive was oriiginally opened from an ELF file via ctf_open*, or + if string or symbol tables were explicitly passed when the archive + was opened, this can be used to override that choice). The dict + should be closed with ctf_dict_close() when done. + + (The low-level functions ctf_simple_open and ctf_bufopen return + ctf_dict_t's directly, and cannot be used on CTF archives: use these + functions instead.) */ + +extern ctf_dict_t *ctf_dict_open (const ctf_archive_t *, + const char *, int *); +extern ctf_dict_t *ctf_dict_open_sections (const ctf_archive_t *, + const ctf_sect_t *symsect, + const ctf_sect_t *strsect, + const char *, int *); + +/* Look up symbols' types in archives by index or name, returning the dict + and optionally type ID in which the type is found. Lookup results are + cached so future lookups are faster. Needs symbol tables and (for name + lookups) string tables to be known for this CTF archive. */ + +extern ctf_dict_t *ctf_arc_lookup_symbol (ctf_archive_t *, + unsigned long symidx, + ctf_id_t *, int *errp); +extern ctf_dict_t *ctf_arc_lookup_symbol_name (ctf_archive_t *, + const char *name, + ctf_id_t *, int *errp); +extern void ctf_arc_flush_caches (ctf_archive_t *); + +/* The next functions return or close real CTF files, or write out CTF + archives, not archives or ELF files containing CTF content. As with + ctf_dict_open_sections, they can be passed symbol and string table + sections. */ + +extern ctf_dict_t *ctf_simple_open (const char *ctfsect, size_t ctfsect_size, + const char *symsect, size_t symsect_size, + size_t symsect_entsize, + const char *strsect, size_t strsect_size, + int *errp); +extern ctf_dict_t *ctf_bufopen (const ctf_sect_t *ctfsect, + const ctf_sect_t *symsect, + const ctf_sect_t *strsect, int *); +extern void ctf_ref (ctf_dict_t *); +extern void ctf_dict_close (ctf_dict_t *); + +/* CTF dicts may be in a parent/child relationship, where the child dicts + contain the name of their originating compilation unit and the name of + their parent. Dicts opened from CTF archives have this relationship set + up already, but if opening via raw low-level calls, you need to figure + out which dict is the parent and set it on the child via ctf_import(). */ + +extern const char *ctf_cuname (ctf_dict_t *); +extern ctf_dict_t *ctf_parent_dict (ctf_dict_t *); +extern const char *ctf_parent_name (ctf_dict_t *); +extern int ctf_type_isparent (ctf_dict_t *, ctf_id_t); +extern int ctf_type_ischild (ctf_dict_t *, ctf_id_t); +extern int ctf_import (ctf_dict_t *, ctf_dict_t *); + +/* Set these names (used when creating dicts). */ + +extern int ctf_cuname_set (ctf_dict_t *, const char *); +extern int ctf_parent_name_set (ctf_dict_t *, const char *); + +/* Set and get the CTF data model (see above). */ + +extern int ctf_setmodel (ctf_dict_t *, int); +extern int ctf_getmodel (ctf_dict_t *); + +/* CTF dicts can carry a single (in-memory-only) non-persistent pointer to + arbitrary data. No meaning is attached to this data and the dict does + not own it: nothing is done to it when the dict is closed. */ + +extern void ctf_setspecific (ctf_dict_t *, void *); +extern void *ctf_getspecific (ctf_dict_t *); + +/* Error handling. ctf dicts carry a system errno value or one of the + CTF_ERRORS above, which are returned via ctf_errno. The return value of + ctf_errno is only meaningful when the immediately preceding CTF function + call returns an error code. + + There are four possible sorts of error return: + + - From opening functions, a return value of NULL and the error returned + via an errp instead of via ctf_errno; all other functions return return + errors via ctf_errno. + + - Functions returning a ctf_id_t are in error if the return value == CTF_ERR + - Functions returning an int are in error if their return value < 0 + - Functions returning a pointer are in error if their return value == + NULL. */ + +extern int ctf_errno (ctf_dict_t *); +extern const char *ctf_errmsg (int); + +/* Return the version of CTF dicts written by writeout functions. The + argument must currently be zero. All dicts with versions below the value + returned by this function can be read by the library. CTF dicts written + by other non-GNU CTF libraries (e.g. that in FreeBSD) are not compatible + and cannot be read by this library. */ + +extern int ctf_version (int); + +/* Given a symbol table index corresponding to a function symbol, return info on + the type of a given function's arguments or return value. Vararg functions + have a final arg with CTF_FUNC_VARARG on in ctc_flags. */ + +extern int ctf_func_info (ctf_dict_t *, unsigned long, ctf_funcinfo_t *); +extern int ctf_func_args (ctf_dict_t *, unsigned long, uint32_t, ctf_id_t *); + +/* As above, but for CTF_K_FUNCTION types in CTF dicts. */ + +extern int ctf_func_type_info (ctf_dict_t *, ctf_id_t, ctf_funcinfo_t *); +extern int ctf_func_type_args (ctf_dict_t *, ctf_id_t, uint32_t, ctf_id_t *); + +/* Look up function or data symbols by name and return their CTF type ID, + if any. (For both function symbols and data symbols that are function + pointers, the types are of kind CTF_K_FUNCTION.) */ + +extern ctf_id_t ctf_lookup_by_symbol (ctf_dict_t *, unsigned long); +extern ctf_id_t ctf_lookup_by_symbol_name (ctf_dict_t *, const char *); + +/* Traverse all (function or data) symbols in a dict, one by one, and return the + type of each and (if NAME is non-NULL) optionally its name. */ + +extern ctf_id_t ctf_symbol_next (ctf_dict_t *, ctf_next_t **, + const char **name, int functions); + +/* Look up a type by name: some simple C type parsing is done, but this is by no + means comprehensive. Structures, unions and enums need "struct ", "union " + or "enum " on the front, as usual in C. */ + +extern ctf_id_t ctf_lookup_by_name (ctf_dict_t *, const char *); + +/* Look up a variable, which is a name -> type mapping with no specific + relationship to a symbol table. Before linking, everything with types in the + symbol table will be in the variable table as well; after linking, only those + typed functions and data objects that are not asssigned to symbols by the + linker are left in the variable table here. */ + +extern ctf_id_t ctf_lookup_variable (ctf_dict_t *, const char *); + +/* Look up a single enumerator by enumeration constant name. Returns the ID of + the enum it is contained within and optionally its value. Error out with + ECTF_DUPLICATE if multiple exist (which can happen in some older dicts). See + ctf_lookup_enumerator_next in that case. Enumeration constants in non-root + types are not returned, but constants in parents are, if not overridden by + an enum in the child. */ + +extern ctf_id_t ctf_lookup_enumerator (ctf_dict_t *, const char *, + int64_t *enum_value); + +/* Type lookup functions. */ + +/* Strip qualifiers and typedefs off a type, returning the base type. + + Stripping also stops when we hit slices (see ctf_add_slice below), so it is + possible (given a chain looking like const -> slice -> typedef -> int) to + still have a typedef after you're done with this, but in that case it is a + typedef of a type with a *different width* (because this slice has not been + applied to it). + + Most of the time you don't need to call this: the type-querying functions + will do it for you (as noted below). */ + +extern ctf_id_t ctf_type_resolve (ctf_dict_t *, ctf_id_t); + +/* Get the name of a type, including any const/volatile/restrict qualifiers + (cvr-quals), and return it as a new dynamically-allocated string. + (The 'a' stands for 'a'llocated.) */ + +extern char *ctf_type_aname (ctf_dict_t *, ctf_id_t); + +/* As above, but with no cvr-quals. */ + +extern char *ctf_type_aname_raw (ctf_dict_t *, ctf_id_t); + +/* A raw name that is owned by the ctf_dict_t and will live as long as it + does. Do not change the value this function returns! */ + +extern const char *ctf_type_name_raw (ctf_dict_t *, ctf_id_t); + +/* Like ctf_type_aname, but print the string into the passed buffer, truncating + if necessary and setting ECTF_NAMELEN on the errno: return the actual number + of bytes needed (not including the trailing \0). Consider using + ctf_type_aname instead. */ + +extern ssize_t ctf_type_lname (ctf_dict_t *, ctf_id_t, char *, size_t); + +/* Like ctf_type_lname, but return the string, or NULL if truncated. + Consider using ctf_type_aname instead. */ + +extern char *ctf_type_name (ctf_dict_t *, ctf_id_t, char *, size_t); + +/* Return the size or alignment of a type. Types with no meaningful size, like + function types, return 0 as their size; incomplete types set ECTF_INCOMPLETE. + The type is resolved for you, so cvr-quals and typedefs can be passsed in. */ + +extern ssize_t ctf_type_size (ctf_dict_t *, ctf_id_t); +extern ssize_t ctf_type_align (ctf_dict_t *, ctf_id_t); + +/* Return the kind of a type (CTF_K_* constant). Slices are considered to be + the kind they are a slice of. Forwards to incomplete structs, etc, return + CTF_K_FORWARD (but deduplication resolves most forwards to their concrete + types). */ + +extern int ctf_type_kind (ctf_dict_t *, ctf_id_t); + +/* Return the kind of a type (CTF_K_* constant). Slices are considered to be + the kind they are a slice of; forwards are considered to be the kind they are + a forward of. */ + +extern int ctf_type_kind_forwarded (ctf_dict_t *, ctf_id_t); + +/* Return the type a pointer, typedef, cvr-qual, or slice refers to, or return + an ECTF_NOTREF error otherwise. ctf_type_kind pretends that slices are + actually the type they are a slice of: this is usually want you want, but if + you want to find out if a type was actually a slice of some (usually-wider) + base type, you can call ctf_type_reference on it: a non-error return means + it was a slice. */ + +extern ctf_id_t ctf_type_reference (ctf_dict_t *, ctf_id_t); + +/* Return the encoding of a given type. No attempt is made to resolve the + type first, so passing in typedefs etc will yield an error. */ + +extern int ctf_type_encoding (ctf_dict_t *, ctf_id_t, ctf_encoding_t *); + +/* Given a type, return some other type that is a pointer to this type (if any + exists), or return ECTF_NOTYPE otherwise. If non exists, try resolving away + typedefs and cvr-quals and check again (so if you call this on foo_t, you + might get back foo *). No attempt is made to hunt for pointers to qualified + versions of the type passed in. */ + +extern ctf_id_t ctf_type_pointer (ctf_dict_t *, ctf_id_t); + +/* Return 1 if two types are assignment-compatible. */ + +extern int ctf_type_compat (ctf_dict_t *, ctf_id_t, ctf_dict_t *, ctf_id_t); + +/* Recursively visit the members of any type, calling the ctf_visit_f for each. */ + +extern int ctf_type_visit (ctf_dict_t *, ctf_id_t, ctf_visit_f *, void *); + +/* Comparison function that defines an ordering over types. If the types are in + different dicts, the ordering may vary between different openings of the same + dicts. */ + +extern int ctf_type_cmp (ctf_dict_t *, ctf_id_t, ctf_dict_t *, ctf_id_t); + +/* Get the name of an enumerator given its value, or vice versa. If many + enumerators have the same value, the first with that value is returned. */ + +extern const char *ctf_enum_name (ctf_dict_t *, ctf_id_t, int); +extern int ctf_enum_value (ctf_dict_t *, ctf_id_t, const char *, int *); + +/* Get the size and member type of an array. */ + +extern int ctf_array_info (ctf_dict_t *, ctf_id_t, ctf_arinfo_t *); + +/* Get info on specific named members of structs or unions, and count the number + of members in a struct, union, or enum. */ + +extern int ctf_member_info (ctf_dict_t *, ctf_id_t, const char *, + ctf_membinfo_t *); +extern int ctf_member_count (ctf_dict_t *, ctf_id_t); + +/* Iterators. */ + +/* ctf_member_next is a _next-style iterator that can additionally traverse into + the members of unnamed structs nested within this struct as if they were + direct members, if CTF_MN_RECURSE is passed in the flags. */ + +extern int ctf_member_iter (ctf_dict_t *, ctf_id_t, ctf_member_f *, void *); +extern ssize_t ctf_member_next (ctf_dict_t *, ctf_id_t, ctf_next_t **, + const char **name, ctf_id_t *membtype, + int flags); + +/* Return all enumeration constants in a given enum type. */ +extern int ctf_enum_iter (ctf_dict_t *, ctf_id_t, ctf_enum_f *, void *); +extern const char *ctf_enum_next (ctf_dict_t *, ctf_id_t, ctf_next_t **, + int *); + +/* Return all enumeration constants with a given name in a given dict, similar + to ctf_lookup_enumerator above but capable of returning multiple values. + Enumerators in parent dictionaries are not returned: enumerators in non-root + types *are* returned. This operation internally iterates over all types in + the dict, so is relatively expensive in large dictionaries. + + There is nothing preventing NAME from being changed by the caller in the + middle of iteration: the results might be slightly confusing, but they are + well-defined. */ + +extern ctf_id_t ctf_lookup_enumerator_next (ctf_dict_t *, const char *name, + ctf_next_t **, int64_t *enum_value); + +/* Likewise, across all dicts in an archive (parent first). The DICT and ERRP + arguments are not optional: without the forer you can't tell which dict the + returned type is in, and without the latter you can't distinguish real errors + from end-of-iteration. DICT should be NULL before the first call and is set + to NULL after the last and on error: on successful call it is set to the dict + containing the returned enum, and it is the caller's responsibility to + ctf_dict_close() it. The caller should otherwise pass it back in unchanged + (do not reassign it during iteration, just as with the ctf_next_t iterator + itself). */ + +extern ctf_id_t ctf_arc_lookup_enumerator_next (ctf_archive_t *, const char *name, + ctf_next_t **, int64_t *enum_value, + ctf_dict_t **dict, int *errp); + +/* Iterate over all types in a dict. ctf_type_iter_all recurses over all types: + ctf_type_iter recurses only over types with user-visible names (for which + CTF_ADD_ROOT was passed). All such types are returned, even if they are + things like pointers that intrinsically have no name: this is the only effect + of CTF_ADD_ROOT for such types. ctf_type_next allows you to choose whether + to see non-root types or not with the want_hidden arg: if set, the flag (if + passed) returns the non-root state of each type in turn. Types in parent + dictionaries are not returned. */ + +extern int ctf_type_iter (ctf_dict_t *, ctf_type_f *, void *); +extern int ctf_type_iter_all (ctf_dict_t *, ctf_type_all_f *, void *); +extern ctf_id_t ctf_type_next (ctf_dict_t *, ctf_next_t **, + int *flag, int want_hidden); + +extern int ctf_variable_iter (ctf_dict_t *, ctf_variable_f *, void *); +extern ctf_id_t ctf_variable_next (ctf_dict_t *, ctf_next_t **, + const char **); + +/* ctf_archive_iter and ctf_archive_next open each member dict for you, + automatically importing any parent dict as usual: ctf_archive_iter closes the + dict on return from ctf_archive_member_f, but for ctf_archive_next the caller + must close each dict returned. If skip_parent is set, the parent dict is + skipped on the basis that it's already been seen in every child dict (but if + no child dicts exist, this will lead to nothing being returned). + + If an open fails, ctf_archive_iter returns -1 early (losing the error), but + ctf_archive_next both passes back the error in the passed errp and allows you + to iterate past errors (until the usual ECTF_NEXT_END is returned). */ + +extern int ctf_archive_iter (const ctf_archive_t *, ctf_archive_member_f *, + void *); +extern ctf_dict_t *ctf_archive_next (const ctf_archive_t *, ctf_next_t **, + const char **, int skip_parent, int *errp); + +/* Pass the raw content of each archive member in turn to + ctf_archive_raw_member_f. + + This function alone does not currently operate on CTF files masquerading as + archives, and returns -EINVAL: the raw data is no longer available. It is + expected to be used only by archiving tools, in any case, which have no need + to deal with non-archives at all. (There is currently no _next analogue of + this function.) */ + +extern int ctf_archive_raw_iter (const ctf_archive_t *, + ctf_archive_raw_member_f *, void *); + +/* Dump the contents of a section in a CTF dict. STATE is an + iterator which should be a pointer to a variable set to NULL. The decorator + is called with each line in turn and can modify it or allocate and return a + new one. ctf_dump accumulates all the results and returns a single giant + multiline string. */ + +extern char *ctf_dump (ctf_dict_t *, ctf_dump_state_t **state, + ctf_sect_names_t sect, ctf_dump_decorate_f *, + void *arg); + +/* Error-warning reporting: an 'iterator' that returns errors and warnings from + the error/warning list, in order of emission. Errors and warnings are popped + after return: the caller must free the returned error-text pointer. */ +extern char *ctf_errwarning_next (ctf_dict_t *, ctf_next_t **, + int *is_warning, int *errp); + +/* Creation. */ + +/* Create a new, empty dict. If creation fails, return NULL and put a CTF error + code in the passed-in int (if set). */ +extern ctf_dict_t *ctf_create (int *); + +/* Add specific types to a dict. You can add new types to any dict, but you can + only add members to types that have been added since this dict was read in + (you cannot read in a dict, look up a type in it, then add members to + it). All adding functions take a uint32_t CTF_ADD_ROOT / CTF_ADD_NONROOT + flag to indicate whether this type should be visible to name lookups via + ctf_lookup_by_name et al. */ + +extern ctf_id_t ctf_add_array (ctf_dict_t *, uint32_t, + const ctf_arinfo_t *); +extern ctf_id_t ctf_add_const (ctf_dict_t *, uint32_t, ctf_id_t); +extern ctf_id_t ctf_add_enum_encoded (ctf_dict_t *, uint32_t, const char *, + const ctf_encoding_t *); +extern ctf_id_t ctf_add_enum (ctf_dict_t *, uint32_t, const char *); +extern ctf_id_t ctf_add_float (ctf_dict_t *, uint32_t, + const char *, const ctf_encoding_t *); +extern ctf_id_t ctf_add_forward (ctf_dict_t *, uint32_t, const char *, + uint32_t); +extern ctf_id_t ctf_add_function (ctf_dict_t *, uint32_t, + const ctf_funcinfo_t *, const ctf_id_t *); +extern ctf_id_t ctf_add_integer (ctf_dict_t *, uint32_t, const char *, + const ctf_encoding_t *); + +/* Add a "slice", which wraps some integral type and changes its encoding + (useful for bitfields, etc). In most respects slices are treated the same + kind as the type they wrap: only ctf_type_reference can see the difference, + returning the wrapped type. */ + +extern ctf_id_t ctf_add_slice (ctf_dict_t *, uint32_t, ctf_id_t, const ctf_encoding_t *); +extern ctf_id_t ctf_add_pointer (ctf_dict_t *, uint32_t, ctf_id_t); +extern ctf_id_t ctf_add_type (ctf_dict_t *, ctf_dict_t *, ctf_id_t); +extern ctf_id_t ctf_add_typedef (ctf_dict_t *, uint32_t, const char *, + ctf_id_t); +extern ctf_id_t ctf_add_restrict (ctf_dict_t *, uint32_t, ctf_id_t); + +/* Struct and union addition. Straight addition uses possibly-confusing rules + to guess the final size of the struct/union given its members: to explicitly + state the size of the struct or union (to report compiler-generated padding, + etc) use the _sized variants. */ + +extern ctf_id_t ctf_add_struct (ctf_dict_t *, uint32_t, const char *); +extern ctf_id_t ctf_add_union (ctf_dict_t *, uint32_t, const char *); +extern ctf_id_t ctf_add_struct_sized (ctf_dict_t *, uint32_t, const char *, + size_t); +extern ctf_id_t ctf_add_union_sized (ctf_dict_t *, uint32_t, const char *, + size_t); + +/* Note that CTF cannot encode a given type. This usually returns an + ECTF_NONREPRESENTABLE error when queried. Mostly useful for struct members, + variables, etc, to point to. */ + +extern ctf_id_t ctf_add_unknown (ctf_dict_t *, uint32_t, const char *); +extern ctf_id_t ctf_add_volatile (ctf_dict_t *, uint32_t, ctf_id_t); + +/* Add an enumerator to an enum. If the enum is non-root, so are all the + constants added to it by ctf_add_enumerator. */ + +extern int ctf_add_enumerator (ctf_dict_t *, ctf_id_t, const char *, int); + +/* Add a member to a struct or union, either at the next available offset (with + suitable padding for the alignment) or at a specific offset, and possibly + with a specific encoding (creating a slice for you). Offsets need not be + unique, and need not be added in ascending order. */ + +extern int ctf_add_member (ctf_dict_t *, ctf_id_t, const char *, ctf_id_t); +extern int ctf_add_member_offset (ctf_dict_t *, ctf_id_t, const char *, + ctf_id_t, unsigned long); +extern int ctf_add_member_encoded (ctf_dict_t *, ctf_id_t, const char *, + ctf_id_t, unsigned long, + const ctf_encoding_t); + +extern int ctf_add_variable (ctf_dict_t *, const char *, ctf_id_t); + +/* Set the size and member and index types of an array. */ + +extern int ctf_set_array (ctf_dict_t *, ctf_id_t, const ctf_arinfo_t *); + +/* Add a function oor object symbol type with a particular name, without saying + anything about the actual symbol index. (The linker will then associate them + with actual symbol indexes using the ctf_link functions below.) */ + +extern int ctf_add_objt_sym (ctf_dict_t *, const char *, ctf_id_t); +extern int ctf_add_func_sym (ctf_dict_t *, const char *, ctf_id_t); + +/* Snapshot/rollback. Call ctf_update to snapshot the state of a dict: + a later call to ctf_discard then deletes all types added since (but not new + members, enumerands etc). Call ctf_snapshot to return a snapshot ID: pass + one of these IDs to ctf_rollback to discard all types added since the + corresponding call to ctf_snapshot. */ + +extern int ctf_update (ctf_dict_t *); +extern ctf_snapshot_id_t ctf_snapshot (ctf_dict_t *); +extern int ctf_rollback (ctf_dict_t *, ctf_snapshot_id_t); +extern int ctf_discard (ctf_dict_t *); + +/* Dict writeout. + + ctf_write: write out an uncompressed dict to an fd. + ctf_compress_write: write out a compressed dict to an fd (currently always + gzip, but this may change in future). + ctf_write_mem: write out a dict to a buffer and return it and its size, + compressing it if its uncompressed size is over THRESHOLD. */ + +extern int ctf_write (ctf_dict_t *, int); +extern int ctf_compress_write (ctf_dict_t * fp, int fd); +extern unsigned char *ctf_write_mem (ctf_dict_t *, size_t *, size_t threshold); + +/* Create a CTF archive named FILE from CTF_DICTS inputs with NAMES (or write it + to the passed-in fd). */ + +extern int ctf_arc_write (const char *file, ctf_dict_t **ctf_dicts, size_t, + const char **names, size_t); +extern int ctf_arc_write_fd (int, ctf_dict_t **, size_t, const char **, + size_t); + +/* Linking. These functions are used by ld to link .ctf sections in input + object files into a single .ctf section which is an archive possibly + containing members containing types whose names collide across multiple + compilation units, but they are usable by other programs as well and are not + private to the linker. */ + +/* Add a CTF archive to the link with a given NAME (usually the name of the + containing object file). The dict added to is usually a new dict created + with ctf_create which will be filled with types corresponding to the shared + dict in the output (conflicting types in child dicts in the output archive + are stored in internal space inside this dict, but are not easily visible + until after ctf_link_write below). + + The NAME need not be unique (but usually is). */ + +extern int ctf_link_add_ctf (ctf_dict_t *, ctf_archive_t *, const char *name); + +/* Do the deduplicating link, filling the dict with types. The FLAGS are the + CTF_LINK_* flags above. */ + +extern int ctf_link (ctf_dict_t *, int flags); + +/* Symtab linker handling, called after ctf_link to set up the symbol type + information used by ctf_*_lookup_symbol. */ + +/* Add strings to the link from the ELF string table, repeatedly calling + ADD_STRING to add each string and its corresponding offset in turn. */ + +typedef const char *ctf_link_strtab_string_f (uint32_t *offset, void *arg); +extern int ctf_link_add_strtab (ctf_dict_t *, + ctf_link_strtab_string_f *add_string, void *); + +/* Note that a given symbol will be public with a given set of properties. + If the symbol has been added with that name via ctf_add_{func,objt}_sym, + this symbol type will end up in the symtypetabs and can be looked up via + ctf_*_lookup_symbol after the dict is read back in. */ + +extern int ctf_link_add_linker_symbol (ctf_dict_t *, ctf_link_sym_t *); + +/* Impose an ordering on symbols, as defined by the strtab and symbol + added by earlier calls to the above two functions. */ + +extern int ctf_link_shuffle_syms (ctf_dict_t *); + +/* Return the serialized form of this ctf_linked dict as a new + dynamically-allocated string, compressed if size over THRESHOLD. + + May be a CTF dict or a CTF archive (this library mostly papers over the + differences so you can open both the same way, treat both as ctf_archive_t + and so on). */ + +extern unsigned char *ctf_link_write (ctf_dict_t *, size_t *size, + size_t threshold); + +/* Specialist linker functions. These functions are not used by ld, but can be + used by other programs making use of the linker machinery for other purposes + to customize its output. Must be called befoore ctf_link. */ + +/* Add an entry to rename a given compilation unit to some other name. This + is only used if conflicting types are found in that compilation unit: they + will instead be placed in the child dict named TO. Many FROMs can map to one + TO: all the types are placed together in that dict, with any whose names + collide as a result being marked as non-root types. */ + +extern int ctf_link_add_cu_mapping (ctf_dict_t *, const char *from, + const char *to); + +/* Allow CTF archive names to be tweaked at the last minute before writeout. + Unlike cu-mappings, this cannot transform names so that they collide: it's + meant for unusual use cases that use names for archive members that are not + exactly the same as CU names but are modified in some systematic way. */ +typedef char *ctf_link_memb_name_changer_f (ctf_dict_t *, + const char *, void *); +extern void ctf_link_set_memb_name_changer + (ctf_dict_t *, ctf_link_memb_name_changer_f *, void *); + +/* Filter out unwanted variables, which can be very voluminous, and (unlike + symbols) cause the CTF string table to grow to hold their names. The + variable filter should return nonzero if a variable should not appear in the + output. */ +typedef int ctf_link_variable_filter_f (ctf_dict_t *, const char *, ctf_id_t, + void *); +extern int ctf_link_set_variable_filter (ctf_dict_t *, + ctf_link_variable_filter_f *, void *); + +/* Turn debugging off and on, and get its value. This is the same as setting + LIBCTF_DEBUG in the environment. */ +extern void ctf_setdebug (int debug); +extern int ctf_getdebug (void); + +/* Deprecated aliases for existing functions and types. */ + +struct ctf_file; +typedef struct ctf_dict ctf_file_t; +extern void ctf_file_close (ctf_file_t *); +extern ctf_dict_t *ctf_parent_file (ctf_dict_t *); +extern ctf_dict_t *ctf_arc_open_by_name (const ctf_archive_t *, + const char *, int *); +extern ctf_dict_t *ctf_arc_open_by_name_sections (const ctf_archive_t *arc, + const ctf_sect_t *symsect, + const ctf_sect_t *strsect, + const char *name, int *errp); + +/* Deprecated witeout function to write out a gzip-compressed dict. Unlike all + the other writeout functions, this even compresses the header (it has to, + since it's passed a gzFile), so the caller must also decompress it, since + ctf_open() etc cannot tell it is a CTF dict or how large it is before + decompression. */ + +extern int ctf_gzwrite (ctf_dict_t *fp, gzFile fd); + +/* Deprecated functions with no current use. */ + +extern const char *ctf_label_topmost (ctf_dict_t *); +extern int ctf_label_info (ctf_dict_t *, const char *, ctf_lblinfo_t *); +extern int ctf_label_iter (ctf_dict_t *, ctf_label_f *, void *); +extern int ctf_label_next (ctf_dict_t *, ctf_next_t **, const char **); /* TBD */ + +#ifdef __cplusplus +} +#endif + +#endif /* _CTF_API_H */ diff --git a/illumos-x86_64/usr/include/ctf.h b/illumos-x86_64/usr/include/ctf.h new file mode 100644 index 00000000..72a639ac --- /dev/null +++ b/illumos-x86_64/usr/include/ctf.h @@ -0,0 +1,621 @@ +/* CTF format description. + Copyright (C) 2019-2025 Free Software Foundation, Inc. + + This file is part of libctf. + + libctf is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not see + . */ + +#ifndef _CTF_H +#define _CTF_H + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* CTF - Compact ANSI-C Type Format + + This file format can be used to compactly represent the information needed + by a debugger to interpret the ANSI-C types used by a given program. + Traditionally, this kind of information is generated by the compiler when + invoked with the -g flag and is stored in "stabs" strings or in the more + modern DWARF format. CTF provides a representation of only the information + that is relevant to debugging a complex, optimized C program such as the + operating system kernel in a form that is significantly more compact than + the equivalent stabs or DWARF representation. The format is data-model + independent, so consumers do not need different code depending on whether + they are 32-bit or 64-bit programs; libctf automatically compensates for + endianness variations. CTF assumes that a standard ELF symbol table is + available for use in the debugger, and uses the structure and data of the + symbol table to avoid storing redundant information. The CTF data may be + compressed on disk or in memory, indicated by a bit in the header. CTF may + be interpreted in a raw disk file, or it may be stored in an ELF section, + typically named .ctf. Data structures are aligned so that a raw CTF file or + CTF ELF section may be manipulated using mmap(2). + + The CTF file or section itself has the following structure: + + +--------+--------+---------+----------+--------+----------+... + | file | type | data | function | object | function |... + | header | labels | objects | info | index | index |... + +--------+--------+---------+----------+--------+----------+... + + ...+----------+-------+--------+ + ...| variable | data | string | + ...| info | types | table | + +----------+-------+--------+ + + The file header stores a magic number and version information, encoding + flags, and the byte offset of each of the sections relative to the end of the + header itself. If the CTF data has been uniquified against another set of + CTF data, a reference to that data also appears in the the header. This + reference is the name of the label corresponding to the types uniquified + against. + + Following the header is a list of labels, used to group the types included in + the data types section. Each label is accompanied by a type ID i. A given + label refers to the group of types whose IDs are in the range [0, i]. + + Data object and function records (collectively, "symtypetabs") are stored in + the same order as they appear in the corresponding symbol table, except that + symbols marked SHN_UNDEF are not stored and symbols that have no type data + are padded out with zeroes. For each entry in these tables, the type ID (a + small integer) is recorded. (Functions get CTF_K_FUNCTION types, just like + data objects that are function pointers.) + + For situations in which the order of the symbols in the symtab is not known, + or most symbols have no type in this dict and most entries would be + zero-pads, a pair of optional indexes follow the data object and function + info sections: each of these is an array of strtab indexes, mapped 1:1 to the + corresponding data object / function info section, giving each entry in those + sections a name so that the linker can correlate them with final symtab + entries and reorder them accordingly (dropping the indexes in the process). + + Variable records (as distinct from data objects) provide a modicum of support + for non-ELF systems, mapping a variable or function name to a CTF type ID. + The names are sorted into ASCIIbetical order, permitting binary searching. + We do not define how the consumer maps these variable names to addresses or + anything else, or indeed what these names represent: they might be names + looked up at runtime via dlsym() or names extracted at runtime by a debugger + or anything else the consumer likes. Variable records with identically- + named entries in the data object or function index section are removed. + + The data types section is a list of variable size records that represent each + type, in order by their ID. The types themselves form a directed graph, + where each node may contain one or more outgoing edges to other type nodes, + denoted by their ID. Most type nodes are standalone or point backwards to + earlier nodes, but this is not required: nodes can point to later nodes, + particularly structure and union members. + + Strings are recorded as a string table ID (0 or 1) and a byte offset into the + string table. String table 0 is the internal CTF string table. String table + 1 is the external string table, which is the string table associated with the + ELF dynamic symbol table for this object. CTF does not record any strings + that are already in the symbol table, and the CTF string table does not + contain any duplicated strings. + + If the CTF data has been merged with another parent CTF object, some outgoing + edges may refer to type nodes that exist in another CTF object. The debugger + and libctf library are responsible for connecting the appropriate objects + together so that the full set of types can be explored and manipulated. + + This connection is done purely using the ctf_import() function. The + ctf_archive machinery (and thus ctf_open et al) automatically imports archive + members named ".ctf" into child dicts if available in the same archive, to + match the relationship set up by the linker, but callers can call ctf_import + themselves as well if need be, if they know a different relationship is in + force. */ + +#define CTF_MAX_TYPE 0xfffffffe /* Max type identifier value. */ +#define CTF_MAX_PTYPE 0x7fffffff /* Max parent type identifier value. */ +#define CTF_MAX_NAME 0x7fffffff /* Max offset into a string table. */ +#define CTF_MAX_VLEN 0xffffff /* Max struct, union, enum members or args. */ + +/* See ctf_type_t */ +#define CTF_MAX_SIZE 0xfffffffe /* Max size of a v2 type in bytes. */ +#define CTF_LSIZE_SENT 0xffffffff /* Sentinel for v2 ctt_size. */ + +# define CTF_MAX_TYPE_V1 0xffff /* Max type identifier value. */ +# define CTF_MAX_PTYPE_V1 0x7fff /* Max parent type identifier value. */ +# define CTF_MAX_VLEN_V1 0x3ff /* Max struct, union, enums or args. */ +# define CTF_MAX_SIZE_V1 0xfffe /* Max size of a type in bytes. */ +# define CTF_LSIZE_SENT_V1 0xffff /* Sentinel for v1 ctt_size. */ + + /* Start of actual data structure definitions. + + Every field in these structures must have corresponding code in the + endianness-swapping machinery in libctf/ctf-open.c. */ + +typedef struct ctf_preamble +{ + unsigned short ctp_magic; /* Magic number (CTF_MAGIC). */ + unsigned char ctp_version; /* Data format version number (CTF_VERSION). */ + unsigned char ctp_flags; /* Flags (see below). */ +} ctf_preamble_t; + +typedef struct ctf_header_v2 +{ + ctf_preamble_t cth_preamble; + uint32_t cth_parlabel; /* Ref to name of parent lbl uniq'd against. */ + uint32_t cth_parname; /* Ref to basename of parent. */ + uint32_t cth_lbloff; /* Offset of label section. */ + uint32_t cth_objtoff; /* Offset of object section. */ + uint32_t cth_funcoff; /* Offset of function section. */ + uint32_t cth_varoff; /* Offset of variable section. */ + uint32_t cth_typeoff; /* Offset of type section. */ + uint32_t cth_stroff; /* Offset of string section. */ + uint32_t cth_strlen; /* Length of string section in bytes. */ +} ctf_header_v2_t; + +typedef struct ctf_header +{ + ctf_preamble_t cth_preamble; + uint32_t cth_parlabel; /* Ref to name of parent lbl uniq'd against. */ + uint32_t cth_parname; /* Ref to basename of parent. */ + uint32_t cth_cuname; /* Ref to CU name (may be 0). */ + uint32_t cth_lbloff; /* Offset of label section. */ + uint32_t cth_objtoff; /* Offset of object section. */ + uint32_t cth_funcoff; /* Offset of function section. */ + uint32_t cth_objtidxoff; /* Offset of object index section. */ + uint32_t cth_funcidxoff; /* Offset of function index section. */ + uint32_t cth_varoff; /* Offset of variable section. */ + uint32_t cth_typeoff; /* Offset of type section. */ + uint32_t cth_stroff; /* Offset of string section. */ + uint32_t cth_strlen; /* Length of string section in bytes. */ +} ctf_header_t; + +#define cth_magic cth_preamble.ctp_magic +#define cth_version cth_preamble.ctp_version +#define cth_flags cth_preamble.ctp_flags + +#define CTF_MAGIC 0xdff2 /* Magic number identifying header. */ + +/* Data format version number. */ + +/* v1 upgraded to a later version is not quite the same as the native form, + because the boundary between parent and child types is different but not + recorded anywhere, and you can write it out again via ctf_compress_write(), + so we must track whether the thing was originally v1 or not. If we were + writing the header from scratch, we would add a *pair* of version number + fields to allow for this, but this will do for now. (A flag will not do, + because we need to encode both the version we came from and the version we + went to, not just "we were upgraded".) */ + +# define CTF_VERSION_1 1 +# define CTF_VERSION_1_UPGRADED_3 2 +# define CTF_VERSION_2 3 + +#define CTF_VERSION_3 4 +#define CTF_VERSION CTF_VERSION_3 /* Current version. */ + +/* All of these flags bar CTF_F_COMPRESS and CTF_F_IDXSORTED are bug-workaround + flags and are valid only in format v3: in v2 and below they cannot occur and + in v4 and later, they will be recycled for other purposes. */ + +#define CTF_F_COMPRESS 0x1 /* Data buffer is compressed by libctf. */ +#define CTF_F_NEWFUNCINFO 0x2 /* New v3 func info section format. */ +#define CTF_F_IDXSORTED 0x4 /* Index sections already sorted. */ +#define CTF_F_DYNSTR 0x8 /* Strings come from .dynstr. */ +#define CTF_F_MAX (CTF_F_COMPRESS | CTF_F_NEWFUNCINFO | CTF_F_IDXSORTED \ + | CTF_F_DYNSTR) + +typedef struct ctf_lblent +{ + uint32_t ctl_label; /* Ref to name of label. */ + uint32_t ctl_type; /* Last type associated with this label. */ +} ctf_lblent_t; + +typedef struct ctf_varent +{ + uint32_t ctv_name; /* Reference to name in string table. */ + uint32_t ctv_type; /* Index of type of this variable. */ +} ctf_varent_t; + +/* In format v2, type sizes, measured in bytes, come in two flavours. Nearly + all of them fit into a (UINT_MAX - 1), and thus can be stored in the ctt_size + member of a ctf_stype_t. The maximum value for these sizes is CTF_MAX_SIZE. + Types larger than this must be stored in the ctf_lsize member of a + ctf_type_t. Use of this member is indicated by the presence of + CTF_LSIZE_SENT in ctt_size. */ + +/* In v1, the same applies, only the limit is (USHRT_MAX - 1) and + CTF_MAX_SIZE_V1, and CTF_LSIZE_SENT_V1 is the sentinel. */ + +typedef struct ctf_stype_v1 +{ + uint32_t ctt_name; /* Reference to name in string table. */ + unsigned short ctt_info; /* Encoded kind, variant length (see below). */ +#ifndef __GNUC__ + union + { + unsigned short _size; /* Size of entire type in bytes. */ + unsigned short _type; /* Reference to another type. */ + } _u; +#else + __extension__ + union + { + unsigned short ctt_size; /* Size of entire type in bytes. */ + unsigned short ctt_type; /* Reference to another type. */ + }; +#endif +} ctf_stype_v1_t; + +typedef struct ctf_type_v1 +{ + uint32_t ctt_name; /* Reference to name in string table. */ + unsigned short ctt_info; /* Encoded kind, variant length (see below). */ +#ifndef __GNUC__ + union + { + unsigned short _size; /* Always CTF_LSIZE_SENT_V1. */ + unsigned short _type; /* Do not use. */ + } _u; +#else + __extension__ + union + { + unsigned short ctt_size; /* Always CTF_LSIZE_SENT_V1. */ + unsigned short ctt_type; /* Do not use. */ + }; +#endif + uint32_t ctt_lsizehi; /* High 32 bits of type size in bytes. */ + uint32_t ctt_lsizelo; /* Low 32 bits of type size in bytes. */ +} ctf_type_v1_t; + + +typedef struct ctf_stype +{ + uint32_t ctt_name; /* Reference to name in string table. */ + uint32_t ctt_info; /* Encoded kind, variant length (see below). */ +#ifndef __GNUC__ + union + { + uint32_t _size; /* Size of entire type in bytes. */ + uint32_t _type; /* Reference to another type. */ + } _u; +#else + __extension__ + union + { + uint32_t ctt_size; /* Size of entire type in bytes. */ + uint32_t ctt_type; /* Reference to another type. */ + }; +#endif +} ctf_stype_t; + +typedef struct ctf_type +{ + uint32_t ctt_name; /* Reference to name in string table. */ + uint32_t ctt_info; /* Encoded kind, variant length (see below). */ +#ifndef __GNUC__ +union + { + uint32_t _size; /* Always CTF_LSIZE_SENT. */ + uint32_t _type; /* Do not use. */ + } _u; +#else + __extension__ + union + { + uint32_t ctt_size; /* Always CTF_LSIZE_SENT. */ + uint32_t ctt_type; /* Do not use. */ + }; +#endif + uint32_t ctt_lsizehi; /* High 32 bits of type size in bytes. */ + uint32_t ctt_lsizelo; /* Low 32 bits of type size in bytes. */ +} ctf_type_t; + +#ifndef __GNUC__ +#define ctt_size _u._size /* For fundamental types that have a size. */ +#define ctt_type _u._type /* For types that reference another type. */ +#endif + +/* The following macros and inline functions compose and decompose values for + ctt_info and ctt_name, as well as other structures that contain name + references. Use outside libdtrace-ctf itself is explicitly for access to CTF + files directly: types returned from the library will always appear to be + CTF_V2. + + v1: (transparently upgraded to v2 at open time: may be compiled out of the + library) + ------------------------ + ctt_info: | kind | isroot | vlen | + ------------------------ + 15 11 10 9 0 + + v2: + ------------------------ + ctt_info: | kind | isroot | vlen | + ------------------------ + 31 26 25 24 0 + + CTF_V1 and V2 _INFO_VLEN have the same interface: + + kind = CTF_*_INFO_KIND(c.ctt_info); <-- CTF_K_* value (see below) + vlen = CTF_*_INFO_VLEN(fp, c.ctt_info); <-- length of variable data list + + stid = CTF_NAME_STID(c.ctt_name); <-- string table id number (0 or 1) + offset = CTF_NAME_OFFSET(c.ctt_name); <-- string table byte offset + + c.ctt_info = CTF_TYPE_INFO(kind, vlen); + c.ctt_name = CTF_TYPE_NAME(stid, offset); */ + +#define CTF_V1_INFO_KIND(info) (((info) & 0xf800) >> 11) +#define CTF_V1_INFO_ISROOT(info) (((info) & 0x0400) >> 10) +#define CTF_V1_INFO_VLEN(info) (((info) & CTF_MAX_VLEN_V1)) + +#define CTF_V2_INFO_KIND(info) (((info) & 0xfc000000) >> 26) +#define CTF_V2_INFO_ISROOT(info) (((info) & 0x2000000) >> 25) +#define CTF_V2_INFO_VLEN(info) (((info) & CTF_MAX_VLEN)) + +#define CTF_NAME_STID(name) ((name) >> 31) +#define CTF_NAME_OFFSET(name) ((name) & CTF_MAX_NAME) +#define CTF_SET_STID(name, stid) ((name) | ((unsigned int) stid) << 31) + +/* V2 only. */ +#define CTF_TYPE_INFO(kind, isroot, vlen) \ + (((kind) << 26) | (((isroot) ? 1 : 0) << 25) | ((vlen) & CTF_MAX_VLEN)) + +#define CTF_TYPE_NAME(stid, offset) \ + (((stid) << 31) | ((offset) & CTF_MAX_NAME)) + +/* The next set of macros are for public consumption only. Not used internally, + since the relevant type boundary is dependent upon the version of the file at + *opening* time, not the version after transparent upgrade. Use + ctf_type_isparent() / ctf_type_ischild() for that. */ + +#define CTF_V2_TYPE_ISPARENT(fp, id) ((id) <= CTF_MAX_PTYPE) +#define CTF_V2_TYPE_ISCHILD(fp, id) ((id) > CTF_MAX_PTYPE) +#define CTF_V2_TYPE_TO_INDEX(id) ((id) & CTF_MAX_PTYPE) +#define CTF_V2_INDEX_TO_TYPE(id, child) ((child) ? ((id) | (CTF_MAX_PTYPE+1)) : (id)) + +#define CTF_V1_TYPE_ISPARENT(fp, id) ((id) <= CTF_MAX_PTYPE_V1) +#define CTF_V1_TYPE_ISCHILD(fp, id) ((id) > CTF_MAX_PTYPE_V1) +#define CTF_V1_TYPE_TO_INDEX(id) ((id) & CTF_MAX_PTYPE_V1) +#define CTF_V1_INDEX_TO_TYPE(id, child) ((child) ? ((id) | (CTF_MAX_PTYPE_V1+1)) : (id)) + +/* Valid for both V1 and V2. */ +#define CTF_TYPE_LSIZE(cttp) \ + (((uint64_t)(cttp)->ctt_lsizehi) << 32 | (cttp)->ctt_lsizelo) +#define CTF_SIZE_TO_LSIZE_HI(size) ((uint32_t)((uint64_t)(size) >> 32)) +#define CTF_SIZE_TO_LSIZE_LO(size) ((uint32_t)(size)) + +#define CTF_STRTAB_0 0 /* String table id 0 (in-CTF). */ +#define CTF_STRTAB_1 1 /* String table id 1 (ELF strtab). */ + +/* Values for CTF_TYPE_KIND(). If the kind has an associated data list, + CTF_INFO_VLEN() will extract the number of elements in the list, and + the type of each element is shown in the comments below. */ + +#define CTF_K_UNKNOWN 0 /* Unknown type (used for padding and + unrepresentable types). */ +#define CTF_K_INTEGER 1 /* Variant data is CTF_INT_DATA (see below). */ +#define CTF_K_FLOAT 2 /* Variant data is CTF_FP_DATA (see below). */ +#define CTF_K_POINTER 3 /* ctt_type is referenced type. */ +#define CTF_K_ARRAY 4 /* Variant data is single ctf_array_t. */ +#define CTF_K_FUNCTION 5 /* ctt_type is return type, variant data is + list of argument types (unsigned short's for v1, + uint32_t's for v2). */ +#define CTF_K_STRUCT 6 /* Variant data is list of ctf_member_t's. */ +#define CTF_K_UNION 7 /* Variant data is list of ctf_member_t's. */ +#define CTF_K_ENUM 8 /* Variant data is list of ctf_enum_t's. */ +#define CTF_K_FORWARD 9 /* No additional data; ctt_name is tag. */ +#define CTF_K_TYPEDEF 10 /* ctt_type is referenced type. */ +#define CTF_K_VOLATILE 11 /* ctt_type is base type. */ +#define CTF_K_CONST 12 /* ctt_type is base type. */ +#define CTF_K_RESTRICT 13 /* ctt_type is base type. */ +#define CTF_K_SLICE 14 /* Variant data is a ctf_slice_t. */ + +#define CTF_K_MAX 63 /* Maximum possible (V2) CTF_K_* value. */ + +/* Values for ctt_type when kind is CTF_K_INTEGER. The flags, offset in bits, + and size in bits are encoded as a single word using the following macros. + (However, you can also encode the offset and bitness in a slice.) */ + +#define CTF_INT_ENCODING(data) (((data) & 0xff000000) >> 24) +#define CTF_INT_OFFSET(data) (((data) & 0x00ff0000) >> 16) +#define CTF_INT_BITS(data) (((data) & 0x0000ffff)) + +#define CTF_INT_DATA(encoding, offset, bits) \ + (((encoding) << 24) | ((offset) << 16) | (bits)) + +#define CTF_INT_SIGNED 0x01 /* Integer is signed (otherwise unsigned). */ +#define CTF_INT_CHAR 0x02 /* Character display format. */ +#define CTF_INT_BOOL 0x04 /* Boolean display format. */ +#define CTF_INT_VARARGS 0x08 /* Varargs display format. */ + +/* Use CTF_CHAR to produce a char that agrees with the system's native + char signedness. */ +#if CHAR_MIN == 0 +# define CTF_CHAR (CTF_INT_CHAR) +#else +# define CTF_CHAR (CTF_INT_CHAR | CTF_INT_SIGNED) +#endif + +/* Values for ctt_type when kind is CTF_K_FLOAT. The encoding, offset in bits, + and size in bits are encoded as a single word using the following macros. + (However, you can also encode the offset and bitness in a slice.) */ + +#define CTF_FP_ENCODING(data) (((data) & 0xff000000) >> 24) +#define CTF_FP_OFFSET(data) (((data) & 0x00ff0000) >> 16) +#define CTF_FP_BITS(data) (((data) & 0x0000ffff)) + +#define CTF_FP_DATA(encoding, offset, bits) \ + (((encoding) << 24) | ((offset) << 16) | (bits)) + +/* Variant data when kind is CTF_K_FLOAT is an encoding in the top eight bits. */ +#define CTF_FP_ENCODING(data) (((data) & 0xff000000) >> 24) + +#define CTF_FP_SINGLE 1 /* IEEE 32-bit float encoding. */ +#define CTF_FP_DOUBLE 2 /* IEEE 64-bit float encoding. */ +#define CTF_FP_CPLX 3 /* Complex encoding. */ +#define CTF_FP_DCPLX 4 /* Double complex encoding. */ +#define CTF_FP_LDCPLX 5 /* Long double complex encoding. */ +#define CTF_FP_LDOUBLE 6 /* Long double encoding. */ +#define CTF_FP_INTRVL 7 /* Interval (2x32-bit) encoding. */ +#define CTF_FP_DINTRVL 8 /* Double interval (2x64-bit) encoding. */ +#define CTF_FP_LDINTRVL 9 /* Long double interval (2x128-bit) encoding. */ +#define CTF_FP_IMAGRY 10 /* Imaginary (32-bit) encoding. */ +#define CTF_FP_DIMAGRY 11 /* Long imaginary (64-bit) encoding. */ +#define CTF_FP_LDIMAGRY 12 /* Long double imaginary (128-bit) encoding. */ + +#define CTF_FP_MAX 12 /* Maximum possible CTF_FP_* value */ + +/* A slice increases the offset and reduces the bitness of the referenced + ctt_type, which must be a type which has an encoding (fp, int, or enum). We + also store the referenced type in here, because it is easier to keep the + ctt_size correct for the slice than to shuffle the size into here and keep + the ctt_type where it is for other types. + + In a future version, where we loosen requirements on alignment in the CTF + file, the cts_offset and cts_bits will be chars: but for now they must be + shorts or everything after a slice will become unaligned. */ + +typedef struct ctf_slice +{ + uint32_t cts_type; + unsigned short cts_offset; + unsigned short cts_bits; +} ctf_slice_t; + +typedef struct ctf_array_v1 +{ + unsigned short cta_contents; /* Reference to type of array contents. */ + unsigned short cta_index; /* Reference to type of array index. */ + uint32_t cta_nelems; /* Number of elements. */ +} ctf_array_v1_t; + +typedef struct ctf_array +{ + uint32_t cta_contents; /* Reference to type of array contents. */ + uint32_t cta_index; /* Reference to type of array index. */ + uint32_t cta_nelems; /* Number of elements. */ +} ctf_array_t; + +/* Most structure members have bit offsets that can be expressed using a short. + Some don't. ctf_member_t is used for structs which cannot contain any of + these large offsets, whereas ctf_lmember_t is used in the latter case. If + any member of a given struct has an offset that cannot be expressed using a + uint32_t, all members will be stored as type ctf_lmember_t. This is expected + to be very rare (but nonetheless possible). */ + +#define CTF_LSTRUCT_THRESH 536870912 + +/* In v1, the same is true, except that lmembers are used for structs >= 8192 + bytes in size. (The ordering of members in the ctf_member_* structures is + different to improve padding.) */ + +#define CTF_LSTRUCT_THRESH_V1 8192 + +typedef struct ctf_member_v1 +{ + uint32_t ctm_name; /* Reference to name in string table. */ + unsigned short ctm_type; /* Reference to type of member. */ + unsigned short ctm_offset; /* Offset of this member in bits. */ +} ctf_member_v1_t; + +typedef struct ctf_lmember_v1 +{ + uint32_t ctlm_name; /* Reference to name in string table. */ + unsigned short ctlm_type; /* Reference to type of member. */ + unsigned short ctlm_pad; /* Padding. */ + uint32_t ctlm_offsethi; /* High 32 bits of member offset in bits. */ + uint32_t ctlm_offsetlo; /* Low 32 bits of member offset in bits. */ +} ctf_lmember_v1_t; + +typedef struct ctf_member_v2 +{ + uint32_t ctm_name; /* Reference to name in string table. */ + uint32_t ctm_offset; /* Offset of this member in bits. */ + uint32_t ctm_type; /* Reference to type of member. */ +} ctf_member_t; + +typedef struct ctf_lmember_v2 +{ + uint32_t ctlm_name; /* Reference to name in string table. */ + uint32_t ctlm_offsethi; /* High 32 bits of member offset in bits. */ + uint32_t ctlm_type; /* Reference to type of member. */ + uint32_t ctlm_offsetlo; /* Low 32 bits of member offset in bits. */ +} ctf_lmember_t; + +#define CTF_LMEM_OFFSET(ctlmp) \ + (((uint64_t)(ctlmp)->ctlm_offsethi) << 32 | (ctlmp)->ctlm_offsetlo) +#define CTF_OFFSET_TO_LMEMHI(offset) ((uint32_t)((uint64_t)(offset) >> 32)) +#define CTF_OFFSET_TO_LMEMLO(offset) ((uint32_t)(offset)) + +typedef struct ctf_enum +{ + uint32_t cte_name; /* Reference to name in string table. */ + int32_t cte_value; /* Value associated with this name. */ +} ctf_enum_t; + +/* The ctf_archive is a collection of ctf_dict_t's stored together. The format + is suitable for mmap()ing: this control structure merely describes the + mmap()ed archive (and overlaps the first few bytes of it), hence the + greater care taken with integral types. All CTF files in an archive + must have the same data model. (This is not validated.) + + All integers in this structure are stored in little-endian byte order. + + The code relies on the fact that everything in this header is a uint64_t + and thus the header needs no padding (in particular, that no padding is + needed between ctfa_ctfs and the unnamed ctfa_archive_modent array + that follows it). + + This is *not* the same as the data structure returned by the ctf_arc_*() + functions: this is the low-level on-disk representation. */ + +#define CTFA_MAGIC 0x8b47f2a4d7623eeb /* Random. */ +struct ctf_archive +{ + /* Magic number. (In loaded files, overwritten with the file size + so ctf_arc_close() knows how much to munmap()). */ + uint64_t ctfa_magic; + + /* CTF data model. */ + uint64_t ctfa_model; + + /* Number of CTF dicts in the archive. */ + uint64_t ctfa_ndicts; + + /* Offset of the name table. */ + uint64_t ctfa_names; + + /* Offset of the CTF table. Each element starts with a size (a little- + endian uint64_t) then a ctf_dict_t of that size. */ + uint64_t ctfa_ctfs; +}; + +/* An array of ctfa_ndicts of this structure lies at + ctf_archive[sizeof(struct ctf_archive)] and gives the ctfa_ctfs or + ctfa_names-relative offsets of each name or ctf_dict_t. */ + +typedef struct ctf_archive_modent +{ + uint64_t name_offset; + uint64_t ctf_offset; +} ctf_archive_modent_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _CTF_H */ diff --git a/illumos-x86_64/usr/include/ctype.h b/illumos-x86_64/usr/include/ctype.h new file mode 100644 index 00000000..6e237a99 --- /dev/null +++ b/illumos-x86_64/usr/include/ctype.h @@ -0,0 +1,119 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _CTYPE_H +#define _CTYPE_H + +#include + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::isalnum; +using std::isalpha; +using std::iscntrl; +using std::isdigit; +using std::isgraph; +using std::islower; +using std::isprint; +using std::ispunct; +using std::isspace; +using std::isupper; +using std::isxdigit; +using std::tolower; +using std::toupper; +#if (__cplusplus >= 201103L) || defined(_STDC_C99) || defined(_XPG6) || \ + !defined(_STRICT_SYMBOLS) +using std::isblank; +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || \ + ((!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \ + defined(_XOPEN_SOURCE)) + +extern int isascii(int); +extern int toascii(int); +extern int _tolower(int); +extern int _toupper(int); + +#endif /* defined(__EXTENSIONS__) || ((!defined(_STRICT_STDC) ... */ + +#if !defined(__lint) + +#if defined(__EXTENSIONS__) || \ + ((!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \ + defined(_XOPEN_SOURCE)) || defined(__XPG4_CHAR_CLASS__) +#define isascii(c) (!(((int)(c)) & ~0177)) +#define toascii(c) (((int)(c)) & 0177) +#define _toupper(c) (toupper(c)) +#define _tolower(c) (tolower(c)) + +#endif /* defined(__EXTENSIONS__) || ((!defined(_STRICT_STDC) ... */ + +#endif /* !defined(__lint) */ + +#if defined(_XPG7) || !defined(_STRICT_SYMBOLS) + +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +extern int isalnum_l(int, locale_t); +extern int isalpha_l(int, locale_t); +extern int isblank_l(int, locale_t); +extern int iscntrl_l(int, locale_t); +extern int isdigit_l(int, locale_t); +extern int isgraph_l(int, locale_t); +extern int islower_l(int, locale_t); +extern int isprint_l(int, locale_t); +extern int ispunct_l(int, locale_t); +extern int isspace_l(int, locale_t); +extern int isupper_l(int, locale_t); +extern int isxdigit_l(int, locale_t); +extern int tolower_l(int, locale_t); +extern int toupper_l(int, locale_t); + +#endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _CTYPE_H */ diff --git a/illumos-x86_64/usr/include/curl/curl.h b/illumos-x86_64/usr/include/curl/curl.h new file mode 100644 index 00000000..e755f098 --- /dev/null +++ b/illumos-x86_64/usr/include/curl/curl.h @@ -0,0 +1,3334 @@ +#ifndef CURLINC_CURL_H +#define CURLINC_CURL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +/* + * If you have libcurl problems, all docs and details are found here: + * https://curl.se/libcurl/ + */ + +#ifdef CURL_NO_OLDIES +#define CURL_STRICTER /* not used since 8.11.0 */ +#endif + +/* Compile-time deprecation macros. */ +#if (defined(__GNUC__) && \ + ((__GNUC__ > 12) || ((__GNUC__ == 12) && (__GNUC_MINOR__ >= 1))) || \ + (defined(__clang__) && __clang_major__ >= 3) || \ + defined(__IAR_SYSTEMS_ICC__)) && \ + !defined(__INTEL_COMPILER) && \ + !defined(CURL_DISABLE_DEPRECATION) && !defined(BUILDING_LIBCURL) +#define CURL_DEPRECATED(version, message) \ + __attribute__((deprecated("since " # version ". " message))) +#ifdef __IAR_SYSTEMS_ICC__ +#define CURL_IGNORE_DEPRECATION(statements) \ + _Pragma("diag_suppress=Pe1444") \ + statements \ + _Pragma("diag_default=Pe1444") +#else +#define CURL_IGNORE_DEPRECATION(statements) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ + statements \ + _Pragma("GCC diagnostic pop") +#endif +#else +#define CURL_DEPRECATED(version, message) +#define CURL_IGNORE_DEPRECATION(statements) statements +#endif + +#include "curlver.h" /* libcurl version defines */ +#include "system.h" /* determine things runtime */ + +#include +#include + +#if defined(__FreeBSD__) || defined(__MidnightBSD__) +/* Needed for __FreeBSD_version or __MidnightBSD_version symbol definition */ +#include +#endif + +/* The include stuff here below is mainly for time_t! */ +#include +#include + +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) +#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || \ + defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)) +/* The check above prevents the winsock2.h inclusion if winsock.h already was + included, since they cannot co-exist without problems */ +#include +#include +#endif +#endif + +/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish + libc5-based Linux systems. Only include it on systems that are known to + require it! */ +#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ + defined(__minix) || defined(__INTEGRITY) || \ + defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \ + defined(__CYGWIN__) || defined(AMIGA) || defined(__NuttX__) || \ + (defined(__FreeBSD_version) && (__FreeBSD_version < 800000)) || \ + (defined(__MidnightBSD_version) && (__MidnightBSD_version < 100000)) || \ + defined(__sun__) || defined(__serenity__) || defined(__vxworks__) +#include +#endif + +#ifndef _WIN32 +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void CURL; +typedef void CURLSH; + +/* + * libcurl external API function linkage decorations. + */ + +#ifdef __has_declspec_attribute +#define CURL_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x) +#else +#define CURL_HAS_DECLSPEC_ATTRIBUTE(x) 0 +#endif + +#ifdef CURL_STATICLIB +# define CURL_EXTERN +#elif defined(_WIN32) || \ + (CURL_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \ + CURL_HAS_DECLSPEC_ATTRIBUTE(dllimport)) +# ifdef BUILDING_LIBCURL +# define CURL_EXTERN __declspec(dllexport) +# else +# define CURL_EXTERN __declspec(dllimport) +# endif +#elif defined(BUILDING_LIBCURL) && defined(CURL_HIDDEN_SYMBOLS) +# define CURL_EXTERN CURL_EXTERN_SYMBOL +#else +# define CURL_EXTERN +#endif + +#ifndef curl_socket_typedef +/* socket typedef */ +#if defined(_WIN32) && !defined(__LWIP_OPT_H__) && !defined(LWIP_HDR_OPT_H) +typedef SOCKET curl_socket_t; +#define CURL_SOCKET_BAD INVALID_SOCKET +#else +typedef int curl_socket_t; +#define CURL_SOCKET_BAD -1 +#endif +#define curl_socket_typedef +#endif /* curl_socket_typedef */ + +/* enum for the different supported SSL backends */ +typedef enum { + CURLSSLBACKEND_NONE = 0, + CURLSSLBACKEND_OPENSSL = 1, + CURLSSLBACKEND_GNUTLS = 2, + CURLSSLBACKEND_NSS CURL_DEPRECATED(8.3.0, "") = 3, + CURLSSLBACKEND_OBSOLETE4 = 4, /* Was QSOSSL. */ + CURLSSLBACKEND_GSKIT CURL_DEPRECATED(8.3.0, "") = 5, + CURLSSLBACKEND_POLARSSL CURL_DEPRECATED(7.69.0, "") = 6, + CURLSSLBACKEND_WOLFSSL = 7, + CURLSSLBACKEND_SCHANNEL = 8, + CURLSSLBACKEND_SECURETRANSPORT CURL_DEPRECATED(8.15.0, "") = 9, + CURLSSLBACKEND_AXTLS CURL_DEPRECATED(7.61.0, "") = 10, + CURLSSLBACKEND_MBEDTLS = 11, + CURLSSLBACKEND_MESALINK CURL_DEPRECATED(7.82.0, "") = 12, + CURLSSLBACKEND_BEARSSL CURL_DEPRECATED(8.15.0, "") = 13, + CURLSSLBACKEND_RUSTLS = 14 +} curl_sslbackend; + +/* aliases for library clones and renames */ +#define CURLSSLBACKEND_AWSLC CURLSSLBACKEND_OPENSSL +#define CURLSSLBACKEND_BORINGSSL CURLSSLBACKEND_OPENSSL +#define CURLSSLBACKEND_LIBRESSL CURLSSLBACKEND_OPENSSL + +/* deprecated names: */ +#define CURLSSLBACKEND_CYASSL CURLSSLBACKEND_WOLFSSL +#define CURLSSLBACKEND_DARWINSSL CURLSSLBACKEND_SECURETRANSPORT + +/* bits for the CURLOPT_FOLLOWLOCATION option */ +#define CURLFOLLOW_ALL 1L /* generic follow redirects */ + +/* Do not use the custom method in the follow-up request if the HTTP code + instructs so (301, 302, 303). */ +#define CURLFOLLOW_OBEYCODE 2L + +/* Only use the custom method in the first request, always reset in the next */ +#define CURLFOLLOW_FIRSTONLY 3L + +struct curl_httppost { + struct curl_httppost *next; /* next entry in the list */ + char *name; /* pointer to allocated name */ + long namelength; /* length of name length */ + char *contents; /* pointer to allocated data contents */ + long contentslength; /* length of contents field, see also + CURL_HTTPPOST_LARGE */ + char *buffer; /* pointer to allocated buffer contents */ + long bufferlength; /* length of buffer field */ + char *contenttype; /* Content-Type */ + struct curl_slist *contentheader; /* list of extra headers for this form */ + struct curl_httppost *more; /* if one field name has more than one + file, this link should link to following + files */ + long flags; /* as defined below */ + +/* specified content is a filename */ +#define CURL_HTTPPOST_FILENAME (1 << 0) +/* specified content is a filename */ +#define CURL_HTTPPOST_READFILE (1 << 1) +/* name is only stored pointer do not free in formfree */ +#define CURL_HTTPPOST_PTRNAME (1 << 2) +/* contents is only stored pointer do not free in formfree */ +#define CURL_HTTPPOST_PTRCONTENTS (1 << 3) +/* upload file from buffer */ +#define CURL_HTTPPOST_BUFFER (1 << 4) +/* upload file from pointer contents */ +#define CURL_HTTPPOST_PTRBUFFER (1 << 5) +/* upload file contents by using the regular read callback to get the data and + pass the given pointer as custom pointer */ +#define CURL_HTTPPOST_CALLBACK (1 << 6) +/* use size in 'contentlen', added in 7.46.0 */ +#define CURL_HTTPPOST_LARGE (1 << 7) + + char *showfilename; /* The filename to show. If not set, the + actual filename will be used (if this + is a file part) */ + void *userp; /* custom pointer used for + HTTPPOST_CALLBACK posts */ + curl_off_t contentlen; /* alternative length of contents + field. Used if CURL_HTTPPOST_LARGE is + set. Added in 7.46.0 */ +}; + +/* This is a return code for the progress callback that, when returned, will + signal libcurl to continue executing the default progress function */ +#define CURL_PROGRESSFUNC_CONTINUE 0x10000001 + +/* This is the CURLOPT_PROGRESSFUNCTION callback prototype. It is now + considered deprecated but was the only choice up until 7.31.0 */ +typedef int (*curl_progress_callback)(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow); + +/* This is the CURLOPT_XFERINFOFUNCTION callback prototype. It was introduced + in 7.32.0, avoids the use of floating point numbers and provides more + detailed information. */ +typedef int (*curl_xferinfo_callback)(void *clientp, + curl_off_t dltotal, + curl_off_t dlnow, + curl_off_t ultotal, + curl_off_t ulnow); + +#ifndef CURL_MAX_READ_SIZE + /* The maximum receive buffer size configurable via CURLOPT_BUFFERSIZE. */ +#define CURL_MAX_READ_SIZE (10*1024*1024) +#endif + +#ifndef CURL_MAX_WRITE_SIZE + /* Tests have proven that 20K is a bad buffer size for uploads on Windows, + while 16K for some odd reason performed a lot better. We do the ifndef + check to allow this value to easier be changed at build time for those + who feel adventurous. The practical minimum is about 400 bytes since + libcurl uses a buffer of this size as a scratch area (unrelated to + network send operations). */ +#define CURL_MAX_WRITE_SIZE 16384 +#endif + +#ifndef CURL_MAX_HTTP_HEADER +/* The only reason to have a max limit for this is to avoid the risk of a bad + server feeding libcurl with a never-ending header that will cause reallocs + infinitely */ +#define CURL_MAX_HTTP_HEADER (100*1024) +#endif + +/* This is a magic return code for the write callback that, when returned, + will signal libcurl to pause receiving on the current transfer. */ +#define CURL_WRITEFUNC_PAUSE 0x10000001 + +/* This is a magic return code for the write callback that, when returned, + will signal an error from the callback. */ +#define CURL_WRITEFUNC_ERROR 0xFFFFFFFF + +typedef size_t (*curl_write_callback)(char *buffer, + size_t size, + size_t nitems, + void *outstream); + +/* This callback will be called when a new resolver request is made */ +typedef int (*curl_resolver_start_callback)(void *resolver_state, + void *reserved, void *userdata); + +/* enumeration of file types */ +typedef enum { + CURLFILETYPE_FILE = 0, + CURLFILETYPE_DIRECTORY, + CURLFILETYPE_SYMLINK, + CURLFILETYPE_DEVICE_BLOCK, + CURLFILETYPE_DEVICE_CHAR, + CURLFILETYPE_NAMEDPIPE, + CURLFILETYPE_SOCKET, + CURLFILETYPE_DOOR, /* is possible only on Sun Solaris now */ + + CURLFILETYPE_UNKNOWN /* should never occur */ +} curlfiletype; + +#define CURLFINFOFLAG_KNOWN_FILENAME (1 << 0) +#define CURLFINFOFLAG_KNOWN_FILETYPE (1 << 1) +#define CURLFINFOFLAG_KNOWN_TIME (1 << 2) +#define CURLFINFOFLAG_KNOWN_PERM (1 << 3) +#define CURLFINFOFLAG_KNOWN_UID (1 << 4) +#define CURLFINFOFLAG_KNOWN_GID (1 << 5) +#define CURLFINFOFLAG_KNOWN_SIZE (1 << 6) +#define CURLFINFOFLAG_KNOWN_HLINKCOUNT (1 << 7) + +/* Information about a single file, used when doing FTP wildcard matching */ +struct curl_fileinfo { + char *filename; + curlfiletype filetype; + time_t time; /* always zero! */ + unsigned int perm; + int uid; + int gid; + curl_off_t size; + long int hardlinks; + + struct { + /* If some of these fields is not NULL, it is a pointer to b_data. */ + char *time; + char *perm; + char *user; + char *group; + char *target; /* pointer to the target filename of a symlink */ + } strings; + + unsigned int flags; + + /* These are libcurl private struct fields. Previously used by libcurl, so + they must never be interfered with. */ + char *b_data; + size_t b_size; + size_t b_used; +}; + +/* return codes for CURLOPT_CHUNK_BGN_FUNCTION */ +#define CURL_CHUNK_BGN_FUNC_OK 0 +#define CURL_CHUNK_BGN_FUNC_FAIL 1 /* tell the lib to end the task */ +#define CURL_CHUNK_BGN_FUNC_SKIP 2 /* skip this chunk over */ + +/* if splitting of data transfer is enabled, this callback is called before + download of an individual chunk started. Note that parameter "remains" works + only for FTP wildcard downloading (for now), otherwise is not used */ +typedef long (*curl_chunk_bgn_callback)(const void *transfer_info, + void *ptr, + int remains); + +/* return codes for CURLOPT_CHUNK_END_FUNCTION */ +#define CURL_CHUNK_END_FUNC_OK 0 +#define CURL_CHUNK_END_FUNC_FAIL 1 /* tell the lib to end the task */ + +/* If splitting of data transfer is enabled this callback is called after + download of an individual chunk finished. + Note! After this callback was set then it have to be called FOR ALL chunks. + Even if downloading of this chunk was skipped in CHUNK_BGN_FUNC. + This is the reason why we do not need "transfer_info" parameter in this + callback and we are not interested in "remains" parameter too. */ +typedef long (*curl_chunk_end_callback)(void *ptr); + +/* return codes for FNMATCHFUNCTION */ +#define CURL_FNMATCHFUNC_MATCH 0 /* string corresponds to the pattern */ +#define CURL_FNMATCHFUNC_NOMATCH 1 /* pattern does not match the string */ +#define CURL_FNMATCHFUNC_FAIL 2 /* an error occurred */ + +/* callback type for wildcard downloading pattern matching. If the + string matches the pattern, return CURL_FNMATCHFUNC_MATCH value, etc. */ +typedef int (*curl_fnmatch_callback)(void *ptr, + const char *pattern, + const char *string); + +/* These are the return codes for the seek callbacks */ +#define CURL_SEEKFUNC_OK 0 +#define CURL_SEEKFUNC_FAIL 1 /* fail the entire transfer */ +#define CURL_SEEKFUNC_CANTSEEK 2 /* tell libcurl seeking cannot be done, so + libcurl might try other means instead */ +typedef int (*curl_seek_callback)(void *instream, + curl_off_t offset, + int origin); /* 'whence' */ + +/* This is a return code for the read callback that, when returned, will + signal libcurl to immediately abort the current transfer. */ +#define CURL_READFUNC_ABORT 0x10000000 +/* This is a return code for the read callback that, when returned, will + signal libcurl to pause sending data on the current transfer. */ +#define CURL_READFUNC_PAUSE 0x10000001 + +/* Return code for when the trailing headers' callback has terminated + without any errors */ +#define CURL_TRAILERFUNC_OK 0 +/* Return code for when was an error in the trailing header's list and we + want to abort the request */ +#define CURL_TRAILERFUNC_ABORT 1 + +typedef size_t (*curl_read_callback)(char *buffer, + size_t size, + size_t nitems, + void *instream); + +typedef int (*curl_trailer_callback)(struct curl_slist **list, + void *userdata); + +typedef enum { + CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ + CURLSOCKTYPE_ACCEPT, /* socket created by accept() call */ + CURLSOCKTYPE_LAST /* never use */ +} curlsocktype; + +/* The return code from the sockopt_callback can signal information back + to libcurl: */ +#define CURL_SOCKOPT_OK 0 +#define CURL_SOCKOPT_ERROR 1 /* causes libcurl to abort and return + CURLE_ABORTED_BY_CALLBACK */ +#define CURL_SOCKOPT_ALREADY_CONNECTED 2 + +typedef int (*curl_sockopt_callback)(void *clientp, + curl_socket_t curlfd, + curlsocktype purpose); + +struct curl_sockaddr { + int family; + int socktype; + int protocol; + unsigned int addrlen; /* addrlen was a socklen_t type before 7.18.0 but it + turned really ugly and painful on the systems that + lack this type */ + struct sockaddr addr; +}; + +typedef curl_socket_t +(*curl_opensocket_callback)(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *address); + +typedef int +(*curl_closesocket_callback)(void *clientp, curl_socket_t item); + +typedef enum { + CURLIOE_OK, /* I/O operation successful */ + CURLIOE_UNKNOWNCMD, /* command was unknown to callback */ + CURLIOE_FAILRESTART, /* failed to restart the read */ + CURLIOE_LAST /* never use */ +} curlioerr; + +typedef enum { + CURLIOCMD_NOP, /* no operation */ + CURLIOCMD_RESTARTREAD, /* restart the read stream from start */ + CURLIOCMD_LAST /* never use */ +} curliocmd; + +typedef curlioerr (*curl_ioctl_callback)(CURL *handle, + int cmd, + void *clientp); + +#ifndef CURL_DID_MEMORY_FUNC_TYPEDEFS +/* + * The following typedef's are signatures of malloc, free, realloc, strdup and + * calloc respectively. Function pointers of these types can be passed to the + * curl_global_init_mem() function to set user defined memory management + * callback routines. + */ +typedef void *(*curl_malloc_callback)(size_t size); +typedef void (*curl_free_callback)(void *ptr); +typedef void *(*curl_realloc_callback)(void *ptr, size_t size); +typedef char *(*curl_strdup_callback)(const char *str); +typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size); + +#define CURL_DID_MEMORY_FUNC_TYPEDEFS +#endif + +/* the kind of data that is passed to information_callback */ +typedef enum { + CURLINFO_TEXT = 0, + CURLINFO_HEADER_IN, /* 1 */ + CURLINFO_HEADER_OUT, /* 2 */ + CURLINFO_DATA_IN, /* 3 */ + CURLINFO_DATA_OUT, /* 4 */ + CURLINFO_SSL_DATA_IN, /* 5 */ + CURLINFO_SSL_DATA_OUT, /* 6 */ + CURLINFO_END +} curl_infotype; + +typedef int (*curl_debug_callback) + (CURL *handle, /* the handle/transfer this concerns */ + curl_infotype type, /* what kind of data */ + char *data, /* points to the data */ + size_t size, /* size of the data pointed to */ + void *userptr); /* whatever the user please */ + +/* This is the CURLOPT_PREREQFUNCTION callback prototype. */ +typedef int (*curl_prereq_callback)(void *clientp, + char *conn_primary_ip, + char *conn_local_ip, + int conn_primary_port, + int conn_local_port); + +/* Return code for when the pre-request callback has terminated without + any errors */ +#define CURL_PREREQFUNC_OK 0 +/* Return code for when the pre-request callback wants to abort the + request */ +#define CURL_PREREQFUNC_ABORT 1 + +/* All possible error codes from all sorts of curl functions. Future versions + may return other values, stay prepared. + + Always add new return codes last. Never *EVER* remove any. The return + codes must remain the same! + */ + +typedef enum { + CURLE_OK = 0, + CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ + CURLE_FAILED_INIT, /* 2 */ + CURLE_URL_MALFORMAT, /* 3 */ + CURLE_NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for + 7.17.0, reused in April 2011 for 7.21.5] */ + CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ + CURLE_COULDNT_RESOLVE_HOST, /* 6 */ + CURLE_COULDNT_CONNECT, /* 7 */ + CURLE_WEIRD_SERVER_REPLY, /* 8 */ + CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server + due to lack of access - when login fails + this is not returned. */ + CURLE_FTP_ACCEPT_FAILED, /* 10 - [was obsoleted in April 2006 for + 7.15.4, reused in Dec 2011 for 7.24.0]*/ + CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ + CURLE_FTP_ACCEPT_TIMEOUT, /* 12 - timeout occurred accepting server + [was obsoleted in August 2007 for 7.17.0, + reused in Dec 2011 for 7.24.0]*/ + CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ + CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ + CURLE_FTP_CANT_GET_HOST, /* 15 */ + CURLE_HTTP2, /* 16 - A problem in the http2 framing layer. + [was obsoleted in August 2007 for 7.17.0, + reused in July 2014 for 7.38.0] */ + CURLE_FTP_COULDNT_SET_TYPE, /* 17 */ + CURLE_PARTIAL_FILE, /* 18 */ + CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ + CURLE_OBSOLETE20, /* 20 - NOT USED */ + CURLE_QUOTE_ERROR, /* 21 - quote command failure */ + CURLE_HTTP_RETURNED_ERROR, /* 22 */ + CURLE_WRITE_ERROR, /* 23 */ + CURLE_OBSOLETE24, /* 24 - NOT USED */ + CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */ + CURLE_READ_ERROR, /* 26 - could not open/read from file */ + CURLE_OUT_OF_MEMORY, /* 27 */ + CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ + CURLE_OBSOLETE29, /* 29 - NOT USED */ + CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ + CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ + CURLE_OBSOLETE32, /* 32 - NOT USED */ + CURLE_RANGE_ERROR, /* 33 - RANGE "command" did not work */ + CURLE_OBSOLETE34, /* 34 */ + CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ + CURLE_BAD_DOWNLOAD_RESUME, /* 36 - could not resume download */ + CURLE_FILE_COULDNT_READ_FILE, /* 37 */ + CURLE_LDAP_CANNOT_BIND, /* 38 */ + CURLE_LDAP_SEARCH_FAILED, /* 39 */ + CURLE_OBSOLETE40, /* 40 - NOT USED */ + CURLE_OBSOLETE41, /* 41 - NOT USED starting with 7.53.0 */ + CURLE_ABORTED_BY_CALLBACK, /* 42 */ + CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ + CURLE_OBSOLETE44, /* 44 - NOT USED */ + CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ + CURLE_OBSOLETE46, /* 46 - NOT USED */ + CURLE_TOO_MANY_REDIRECTS, /* 47 - catch endless re-direct loops */ + CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */ + CURLE_SETOPT_OPTION_SYNTAX, /* 49 - Malformed setopt option */ + CURLE_OBSOLETE50, /* 50 - NOT USED */ + CURLE_OBSOLETE51, /* 51 - NOT USED */ + CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ + CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ + CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as + default */ + CURLE_SEND_ERROR, /* 55 - failed sending network data */ + CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ + CURLE_OBSOLETE57, /* 57 - NOT IN USE */ + CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ + CURLE_SSL_CIPHER, /* 59 - could not use specified cipher */ + CURLE_PEER_FAILED_VERIFICATION, /* 60 - peer's certificate or fingerprint + was not verified fine */ + CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */ + CURLE_OBSOLETE62, /* 62 - NOT IN USE since 7.82.0 */ + CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ + CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ + CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind + that failed */ + CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ + CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not + accepted and we failed to login */ + CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */ + CURLE_TFTP_PERM, /* 69 - permission problem on server */ + CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */ + CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ + CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ + CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */ + CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */ + CURLE_OBSOLETE75, /* 75 - NOT IN USE since 7.82.0 */ + CURLE_OBSOLETE76, /* 76 - NOT IN USE since 7.82.0 */ + CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing + or wrong format */ + CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ + CURLE_SSH, /* 79 - error from the SSH layer, somewhat + generic so the error message will be of + interest when this has happened */ + + CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL + connection */ + CURLE_AGAIN, /* 81 - socket is not ready for send/recv, + wait till it is ready and try again (Added + in 7.18.2) */ + CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or + wrong format (Added in 7.19.0) */ + CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in + 7.19.0) */ + CURLE_FTP_PRET_FAILED, /* 84 - a PRET command failed */ + CURLE_RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */ + CURLE_RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Ids */ + CURLE_FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */ + CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */ + CURLE_NO_CONNECTION_AVAILABLE, /* 89 - No connection available, the + session will be queued */ + CURLE_SSL_PINNEDPUBKEYNOTMATCH, /* 90 - specified pinned public key did not + match */ + CURLE_SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */ + CURLE_HTTP2_STREAM, /* 92 - stream error in HTTP/2 framing layer + */ + CURLE_RECURSIVE_API_CALL, /* 93 - an api function was called from + inside a callback */ + CURLE_AUTH_ERROR, /* 94 - an authentication function returned an + error */ + CURLE_HTTP3, /* 95 - An HTTP/3 layer problem */ + CURLE_QUIC_CONNECT_ERROR, /* 96 - QUIC connection error */ + CURLE_PROXY, /* 97 - proxy handshake error */ + CURLE_SSL_CLIENTCERT, /* 98 - client-side certificate required */ + CURLE_UNRECOVERABLE_POLL, /* 99 - poll/select returned fatal error */ + CURLE_TOO_LARGE, /* 100 - a value/data met its maximum */ + CURLE_ECH_REQUIRED, /* 101 - ECH tried but failed */ + CURL_LAST /* never use! */ +} CURLcode; + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* removed in 7.53.0 */ +#define CURLE_FUNCTION_NOT_FOUND CURLE_OBSOLETE41 + +/* removed in 7.56.0 */ +#define CURLE_HTTP_POST_ERROR CURLE_OBSOLETE34 + +/* Previously obsolete error code reused in 7.38.0 */ +#define CURLE_OBSOLETE16 CURLE_HTTP2 + +/* Previously obsolete error codes reused in 7.24.0 */ +#define CURLE_OBSOLETE10 CURLE_FTP_ACCEPT_FAILED +#define CURLE_OBSOLETE12 CURLE_FTP_ACCEPT_TIMEOUT + +/* compatibility with older names */ +#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING +#define CURLE_FTP_WEIRD_SERVER_REPLY CURLE_WEIRD_SERVER_REPLY + +/* The following were added in 7.62.0 */ +#define CURLE_SSL_CACERT CURLE_PEER_FAILED_VERIFICATION + +/* The following were added in 7.21.5, April 2011 */ +#define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION + +/* Added for 7.78.0 */ +#define CURLE_TELNET_OPTION_SYNTAX CURLE_SETOPT_OPTION_SYNTAX + +/* The following were added in 7.17.1 */ +/* These are scheduled to disappear by 2009 */ +#define CURLE_SSL_PEER_CERTIFICATE CURLE_PEER_FAILED_VERIFICATION + +/* The following were added in 7.17.0 */ +/* These are scheduled to disappear by 2009 */ +#define CURLE_OBSOLETE CURLE_OBSOLETE50 /* no one should be using this! */ +#define CURLE_BAD_PASSWORD_ENTERED CURLE_OBSOLETE46 +#define CURLE_BAD_CALLING_ORDER CURLE_OBSOLETE44 +#define CURLE_FTP_USER_PASSWORD_INCORRECT CURLE_OBSOLETE10 +#define CURLE_FTP_CANT_RECONNECT CURLE_OBSOLETE16 +#define CURLE_FTP_COULDNT_GET_SIZE CURLE_OBSOLETE32 +#define CURLE_FTP_COULDNT_SET_ASCII CURLE_OBSOLETE29 +#define CURLE_FTP_WEIRD_USER_REPLY CURLE_OBSOLETE12 +#define CURLE_FTP_WRITE_ERROR CURLE_OBSOLETE20 +#define CURLE_LIBRARY_NOT_FOUND CURLE_OBSOLETE40 +#define CURLE_MALFORMAT_USER CURLE_OBSOLETE24 +#define CURLE_SHARE_IN_USE CURLE_OBSOLETE57 +#define CURLE_URL_MALFORMAT_USER CURLE_NOT_BUILT_IN + +#define CURLE_FTP_ACCESS_DENIED CURLE_REMOTE_ACCESS_DENIED +#define CURLE_FTP_COULDNT_SET_BINARY CURLE_FTP_COULDNT_SET_TYPE +#define CURLE_FTP_QUOTE_ERROR CURLE_QUOTE_ERROR +#define CURLE_TFTP_DISKFULL CURLE_REMOTE_DISK_FULL +#define CURLE_TFTP_EXISTS CURLE_REMOTE_FILE_EXISTS +#define CURLE_HTTP_RANGE_ERROR CURLE_RANGE_ERROR +#define CURLE_FTP_SSL_FAILED CURLE_USE_SSL_FAILED + +/* The following were added earlier */ + +#define CURLE_OPERATION_TIMEOUTED CURLE_OPERATION_TIMEDOUT +#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR +#define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED +#define CURLE_FTP_COULDNT_STOR_FILE CURLE_UPLOAD_FAILED +#define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE +#define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME +#define CURLE_LDAP_INVALID_URL CURLE_OBSOLETE62 +#define CURLE_CONV_REQD CURLE_OBSOLETE76 +#define CURLE_CONV_FAILED CURLE_OBSOLETE75 + +/* This was the error code 50 in 7.7.3 and a few earlier versions, this + is no longer used by libcurl but is instead #defined here only to not + make programs break */ +#define CURLE_ALREADY_COMPLETE 99999 + +/* Provide defines for really old option names */ +#define CURLOPT_FILE CURLOPT_WRITEDATA /* name changed in 7.9.7 */ +#define CURLOPT_INFILE CURLOPT_READDATA /* name changed in 7.9.7 */ +#define CURLOPT_WRITEHEADER CURLOPT_HEADERDATA + +/* Since long deprecated options with no code in the lib that does anything + with them. */ +#define CURLOPT_WRITEINFO CURLOPT_OBSOLETE40 +#define CURLOPT_CLOSEPOLICY CURLOPT_OBSOLETE72 +#define CURLOPT_OBSOLETE72 9999 +#define CURLOPT_OBSOLETE40 9999 + +#endif /* !CURL_NO_OLDIES */ + +/* + * Proxy error codes. Returned in CURLINFO_PROXY_ERROR if CURLE_PROXY was + * return for the transfers. + */ +typedef enum { + CURLPX_OK, + CURLPX_BAD_ADDRESS_TYPE, + CURLPX_BAD_VERSION, + CURLPX_CLOSED, + CURLPX_GSSAPI, + CURLPX_GSSAPI_PERMSG, + CURLPX_GSSAPI_PROTECTION, + CURLPX_IDENTD, + CURLPX_IDENTD_DIFFER, + CURLPX_LONG_HOSTNAME, + CURLPX_LONG_PASSWD, + CURLPX_LONG_USER, + CURLPX_NO_AUTH, + CURLPX_RECV_ADDRESS, + CURLPX_RECV_AUTH, + CURLPX_RECV_CONNECT, + CURLPX_RECV_REQACK, + CURLPX_REPLY_ADDRESS_TYPE_NOT_SUPPORTED, + CURLPX_REPLY_COMMAND_NOT_SUPPORTED, + CURLPX_REPLY_CONNECTION_REFUSED, + CURLPX_REPLY_GENERAL_SERVER_FAILURE, + CURLPX_REPLY_HOST_UNREACHABLE, + CURLPX_REPLY_NETWORK_UNREACHABLE, + CURLPX_REPLY_NOT_ALLOWED, + CURLPX_REPLY_TTL_EXPIRED, + CURLPX_REPLY_UNASSIGNED, + CURLPX_REQUEST_FAILED, + CURLPX_RESOLVE_HOST, + CURLPX_SEND_AUTH, + CURLPX_SEND_CONNECT, + CURLPX_SEND_REQUEST, + CURLPX_UNKNOWN_FAIL, + CURLPX_UNKNOWN_MODE, + CURLPX_USER_REJECTED, + CURLPX_LAST /* never use */ +} CURLproxycode; + +/* This prototype applies to all conversion callbacks */ +typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length); + +typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl, /* easy handle */ + void *ssl_ctx, /* actually an OpenSSL + or wolfSSL SSL_CTX, + or an mbedTLS + mbedtls_ssl_config */ + void *userptr); + +#define CURLPROXY_HTTP 0L /* added in 7.10, new in 7.19.4 default is + to use CONNECT HTTP/1.1 */ +#define CURLPROXY_HTTP_1_0 1L /* force to use CONNECT HTTP/1.0 + added in 7.19.4 */ +#define CURLPROXY_HTTPS 2L /* HTTPS but stick to HTTP/1 + added in 7.52.0 */ +#define CURLPROXY_HTTPS2 3L /* HTTPS and attempt HTTP/2 + added in 8.2.0 */ +#define CURLPROXY_SOCKS4 4L /* support added in 7.15.2, enum existed + already in 7.10 */ +#define CURLPROXY_SOCKS5 5L /* added in 7.10 */ +#define CURLPROXY_SOCKS4A 6L /* added in 7.18.0 */ +#define CURLPROXY_SOCKS5_HOSTNAME 7L /* Use the SOCKS5 protocol but pass along + the hostname rather than the IP + address. added in 7.18.0 */ + +typedef enum { + CURLPROXY_LAST = 8 /* never use */ +} curl_proxytype; /* this enum was added in 7.10 */ + +/* + * Bitmasks for CURLOPT_HTTPAUTH and CURLOPT_PROXYAUTH options: + * + * CURLAUTH_NONE - No HTTP authentication + * CURLAUTH_BASIC - HTTP Basic authentication (default) + * CURLAUTH_DIGEST - HTTP Digest authentication + * CURLAUTH_NEGOTIATE - HTTP Negotiate (SPNEGO) authentication + * CURLAUTH_GSSNEGOTIATE - Alias for CURLAUTH_NEGOTIATE (deprecated) + * CURLAUTH_NTLM - HTTP NTLM authentication + * CURLAUTH_DIGEST_IE - HTTP Digest authentication with IE flavour + * CURLAUTH_NTLM_WB - HTTP NTLM authentication delegated to winbind helper + * CURLAUTH_BEARER - HTTP Bearer token authentication + * CURLAUTH_ONLY - Use together with a single other type to force no + * authentication or just that single type + * CURLAUTH_ANY - All fine types set + * CURLAUTH_ANYSAFE - All fine types except Basic + */ + +#define CURLAUTH_NONE ((unsigned long)0) +#define CURLAUTH_BASIC (((unsigned long)1) << 0) +#define CURLAUTH_DIGEST (((unsigned long)1) << 1) +#define CURLAUTH_NEGOTIATE (((unsigned long)1) << 2) +/* Deprecated since the advent of CURLAUTH_NEGOTIATE */ +#define CURLAUTH_GSSNEGOTIATE CURLAUTH_NEGOTIATE +/* Used for CURLOPT_SOCKS5_AUTH to stay terminologically correct */ +#define CURLAUTH_GSSAPI CURLAUTH_NEGOTIATE +#define CURLAUTH_NTLM (((unsigned long)1) << 3) +#define CURLAUTH_DIGEST_IE (((unsigned long)1) << 4) +#ifndef CURL_NO_OLDIES + /* functionality removed since 8.8.0 */ +#define CURLAUTH_NTLM_WB (((unsigned long)1) << 5) +#endif +#define CURLAUTH_BEARER (((unsigned long)1) << 6) +#define CURLAUTH_AWS_SIGV4 (((unsigned long)1) << 7) +#define CURLAUTH_ONLY (((unsigned long)1) << 31) +#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE) +#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE)) + +#define CURLSSH_AUTH_ANY ~0L /* all types supported by server */ +#define CURLSSH_AUTH_NONE 0L /* none allowed, silly but complete */ +#define CURLSSH_AUTH_PUBLICKEY (1L << 0) /* public/private key files */ +#define CURLSSH_AUTH_PASSWORD (1L << 1) /* password */ +#define CURLSSH_AUTH_HOST (1L << 2) /* host key files */ +#define CURLSSH_AUTH_KEYBOARD (1L << 3) /* keyboard interactive */ +#define CURLSSH_AUTH_AGENT (1L << 4) /* agent (ssh-agent, pageant...) */ +#define CURLSSH_AUTH_GSSAPI (1L << 5) /* gssapi (kerberos, ...) */ +#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY + +#define CURLGSSAPI_DELEGATION_NONE 0L /* no delegation (default) */ +#define CURLGSSAPI_DELEGATION_POLICY_FLAG (1L<<0) /* if permitted by policy */ +#define CURLGSSAPI_DELEGATION_FLAG (1L<<1) /* delegate always */ + +#define CURL_ERROR_SIZE 256 + +enum curl_khtype { + CURLKHTYPE_UNKNOWN, + CURLKHTYPE_RSA1, + CURLKHTYPE_RSA, + CURLKHTYPE_DSS, + CURLKHTYPE_ECDSA, + CURLKHTYPE_ED25519 +}; + +struct curl_khkey { + const char *key; /* points to a null-terminated string encoded with base64 + if len is zero, otherwise to the "raw" data */ + size_t len; + enum curl_khtype keytype; +}; + +/* this is the set of return values expected from the curl_sshkeycallback + callback */ +enum curl_khstat { + CURLKHSTAT_FINE_ADD_TO_FILE, + CURLKHSTAT_FINE, + CURLKHSTAT_REJECT, /* reject the connection, return an error */ + CURLKHSTAT_DEFER, /* do not accept it, but we cannot answer right now. + Causes a CURLE_PEER_FAILED_VERIFICATION error but the + connection will be left intact etc */ + CURLKHSTAT_FINE_REPLACE, /* accept and replace the wrong key */ + CURLKHSTAT_LAST /* not for use, only a marker for last-in-list */ +}; + +/* this is the set of status codes pass in to the callback */ +enum curl_khmatch { + CURLKHMATCH_OK, /* match */ + CURLKHMATCH_MISMATCH, /* host found, key mismatch! */ + CURLKHMATCH_MISSING, /* no matching host/key found */ + CURLKHMATCH_LAST /* not for use, only a marker for last-in-list */ +}; + +typedef int + (*curl_sshkeycallback) (CURL *easy, /* easy handle */ + const struct curl_khkey *knownkey, /* known */ + const struct curl_khkey *foundkey, /* found */ + enum curl_khmatch, /* libcurl's view on the keys */ + void *clientp); /* custom pointer passed with */ + /* CURLOPT_SSH_KEYDATA */ + +typedef int + (*curl_sshhostkeycallback) (void *clientp,/* custom pointer passed */ + /* with CURLOPT_SSH_HOSTKEYDATA */ + int keytype, /* CURLKHTYPE */ + const char *key, /* hostkey to check */ + size_t keylen); /* length of the key */ + /* return CURLE_OK to accept */ + /* or something else to refuse */ + +/* parameter for the CURLOPT_USE_SSL option */ +#define CURLUSESSL_NONE 0L /* do not attempt to use SSL */ +#define CURLUSESSL_TRY 1L /* try using SSL, proceed anyway otherwise */ +#define CURLUSESSL_CONTROL 2L /* SSL for the control connection or fail */ +#define CURLUSESSL_ALL 3L /* SSL for all communication or fail */ + +typedef enum { + CURLUSESSL_LAST = 4 /* not an option, never use */ +} curl_usessl; + +/* Definition of bits for the CURLOPT_SSL_OPTIONS argument: */ + +/* - ALLOW_BEAST tells libcurl to allow the BEAST SSL vulnerability in the + name of improving interoperability with older servers. Some SSL libraries + have introduced work-arounds for this flaw but those work-arounds sometimes + make the SSL communication fail. To regain functionality with those broken + servers, a user can this way allow the vulnerability back. */ +#define CURLSSLOPT_ALLOW_BEAST (1L << 0) + +/* - NO_REVOKE tells libcurl to disable certificate revocation checks for those + SSL backends where such behavior is present. */ +#define CURLSSLOPT_NO_REVOKE (1L << 1) + +/* - NO_PARTIALCHAIN tells libcurl to *NOT* accept a partial certificate chain + if possible. The OpenSSL backend has this ability. */ +#define CURLSSLOPT_NO_PARTIALCHAIN (1L << 2) + +/* - REVOKE_BEST_EFFORT tells libcurl to ignore certificate revocation offline + checks and ignore missing revocation list for those SSL backends where such + behavior is present. */ +#define CURLSSLOPT_REVOKE_BEST_EFFORT (1L << 3) + +/* - CURLSSLOPT_NATIVE_CA tells libcurl to use standard certificate store of + operating system. Currently implemented under MS-Windows. */ +#define CURLSSLOPT_NATIVE_CA (1L << 4) + +/* - CURLSSLOPT_AUTO_CLIENT_CERT tells libcurl to automatically locate and use + a client certificate for authentication. (Schannel) */ +#define CURLSSLOPT_AUTO_CLIENT_CERT (1L << 5) + +/* If possible, send data using TLS 1.3 early data */ +#define CURLSSLOPT_EARLYDATA (1L << 6) + +/* The default connection attempt delay in milliseconds for happy eyeballs. + CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.3 and happy-eyeballs-timeout-ms.d document + this value, keep them in sync. */ +#define CURL_HET_DEFAULT 200L + +/* The default connection upkeep interval in milliseconds. */ +#define CURL_UPKEEP_INTERVAL_DEFAULT 60000L + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* Backwards compatibility with older names */ +/* These are scheduled to disappear by 2009 */ + +#define CURLFTPSSL_NONE CURLUSESSL_NONE +#define CURLFTPSSL_TRY CURLUSESSL_TRY +#define CURLFTPSSL_CONTROL CURLUSESSL_CONTROL +#define CURLFTPSSL_ALL CURLUSESSL_ALL +#define CURLFTPSSL_LAST CURLUSESSL_LAST +#define curl_ftpssl curl_usessl +#endif /* !CURL_NO_OLDIES */ + +/* parameter for the CURLOPT_FTP_SSL_CCC option */ +#define CURLFTPSSL_CCC_NONE 0L /* do not send CCC */ +#define CURLFTPSSL_CCC_PASSIVE 1L /* Let the server initiate the shutdown */ +#define CURLFTPSSL_CCC_ACTIVE 2L /* Initiate the shutdown */ + +typedef enum { + CURLFTPSSL_CCC_LAST = 3 /* not an option, never use */ +} curl_ftpccc; + +/* parameter for the CURLOPT_FTPSSLAUTH option */ +#define CURLFTPAUTH_DEFAULT 0L /* let libcurl decide */ +#define CURLFTPAUTH_SSL 1L /* use "AUTH SSL" */ +#define CURLFTPAUTH_TLS 2L /* use "AUTH TLS" */ + +typedef enum { + CURLFTPAUTH_LAST = 3 /* not an option, never use */ +} curl_ftpauth; + +/* parameter for the CURLOPT_FTP_CREATE_MISSING_DIRS option */ +#define CURLFTP_CREATE_DIR_NONE 0L /* do NOT create missing dirs! */ +#define CURLFTP_CREATE_DIR 1L /* (FTP/SFTP) if CWD fails, try MKD and + then CWD again if MKD succeeded, for + SFTP this does similar magic */ +#define CURLFTP_CREATE_DIR_RETRY 2L /* (FTP only) if CWD fails, try MKD and + then CWD again even if MKD failed! */ + +typedef enum { + CURLFTP_CREATE_DIR_LAST = 3 /* not an option, never use */ +} curl_ftpcreatedir; + +/* parameter for the CURLOPT_FTP_FILEMETHOD option */ +#define CURLFTPMETHOD_DEFAULT 0L /* let libcurl pick */ +#define CURLFTPMETHOD_MULTICWD 1L /* single CWD operation for each path + part */ +#define CURLFTPMETHOD_NOCWD 2L /* no CWD at all */ +#define CURLFTPMETHOD_SINGLECWD 3L /* one CWD to full dir, then work on file */ + +typedef enum { + CURLFTPMETHOD_LAST = 4 /* not an option, never use */ +} curl_ftpmethod; + +/* bitmask defines for CURLOPT_HEADEROPT */ +#define CURLHEADER_UNIFIED 0L +#define CURLHEADER_SEPARATE (1L << 0) + +/* CURLALTSVC_* are bits for the CURLOPT_ALTSVC_CTRL option */ +#define CURLALTSVC_READONLYFILE (1L << 2) +#define CURLALTSVC_H1 (1L << 3) +#define CURLALTSVC_H2 (1L << 4) +#define CURLALTSVC_H3 (1L << 5) + +/* bitmask values for CURLOPT_UPLOAD_FLAGS */ +#define CURLULFLAG_ANSWERED (1L << 0) +#define CURLULFLAG_DELETED (1L << 1) +#define CURLULFLAG_DRAFT (1L << 2) +#define CURLULFLAG_FLAGGED (1L << 3) +#define CURLULFLAG_SEEN (1L << 4) + +struct curl_hstsentry { + char *name; + size_t namelen; + unsigned int includeSubDomains:1; + char expire[18]; /* YYYYMMDD HH:MM:SS [null-terminated] */ +}; + +struct curl_index { + size_t index; /* the provided entry's "index" or count */ + size_t total; /* total number of entries to save */ +}; + +typedef enum { + CURLSTS_OK, + CURLSTS_DONE, + CURLSTS_FAIL +} CURLSTScode; + +typedef CURLSTScode (*curl_hstsread_callback)(CURL *easy, + struct curl_hstsentry *e, + void *userp); +typedef CURLSTScode (*curl_hstswrite_callback)(CURL *easy, + struct curl_hstsentry *e, + struct curl_index *i, + void *userp); + +/* CURLHSTS_* are bits for the CURLOPT_HSTS option */ +#define CURLHSTS_ENABLE (1L << 0) +#define CURLHSTS_READONLYFILE (1L << 1) + +/* The CURLPROTO_ defines below are for the **deprecated** CURLOPT_*PROTOCOLS + options. Do not use. */ +#define CURLPROTO_HTTP (1L << 0) +#define CURLPROTO_HTTPS (1L << 1) +#define CURLPROTO_FTP (1L << 2) +#define CURLPROTO_FTPS (1L << 3) +#define CURLPROTO_SCP (1L << 4) +#define CURLPROTO_SFTP (1L << 5) +#define CURLPROTO_TELNET (1L << 6) +#define CURLPROTO_LDAP (1L << 7) +#define CURLPROTO_LDAPS (1L << 8) +#define CURLPROTO_DICT (1L << 9) +#define CURLPROTO_FILE (1L << 10) +#define CURLPROTO_TFTP (1L << 11) +#define CURLPROTO_IMAP (1L << 12) +#define CURLPROTO_IMAPS (1L << 13) +#define CURLPROTO_POP3 (1L << 14) +#define CURLPROTO_POP3S (1L << 15) +#define CURLPROTO_SMTP (1L << 16) +#define CURLPROTO_SMTPS (1L << 17) +#define CURLPROTO_RTSP (1L << 18) +#define CURLPROTO_RTMP (1L << 19) +#define CURLPROTO_RTMPT (1L << 20) +#define CURLPROTO_RTMPE (1L << 21) +#define CURLPROTO_RTMPTE (1L << 22) +#define CURLPROTO_RTMPS (1L << 23) +#define CURLPROTO_RTMPTS (1L << 24) +#define CURLPROTO_GOPHER (1L << 25) +#define CURLPROTO_SMB (1L << 26) +#define CURLPROTO_SMBS (1L << 27) +#define CURLPROTO_MQTT (1L << 28) +#define CURLPROTO_GOPHERS (1L << 29) +#define CURLPROTO_ALL (~0L) /* enable everything */ + +/* long may be 32 or 64 bits, but we should never depend on anything else + but 32 */ +#define CURLOPTTYPE_LONG 0 +#define CURLOPTTYPE_OBJECTPOINT 10000 +#define CURLOPTTYPE_FUNCTIONPOINT 20000 +#define CURLOPTTYPE_OFF_T 30000 +#define CURLOPTTYPE_BLOB 40000 + +/* *STRINGPOINT is an alias for OBJECTPOINT to allow tools to extract the + string options from the header file */ + +#define CURLOPT(na,t,nu) na = t + nu +#define CURLOPTDEPRECATED(na,t,nu,v,m) na CURL_DEPRECATED(v,m) = t + nu + +/* CURLOPT aliases that make no runtime difference */ + +/* 'char *' argument to a string with a trailing zero */ +#define CURLOPTTYPE_STRINGPOINT CURLOPTTYPE_OBJECTPOINT + +/* 'struct curl_slist *' argument */ +#define CURLOPTTYPE_SLISTPOINT CURLOPTTYPE_OBJECTPOINT + +/* 'void *' argument passed untouched to callback */ +#define CURLOPTTYPE_CBPOINT CURLOPTTYPE_OBJECTPOINT + +/* 'long' argument with a set of values/bitmask */ +#define CURLOPTTYPE_VALUES CURLOPTTYPE_LONG + +/* + * All CURLOPT_* values. + */ + +typedef enum { + /* This is the FILE * or void * the regular output should be written to. */ + CURLOPT(CURLOPT_WRITEDATA, CURLOPTTYPE_CBPOINT, 1), + + /* The full URL to get/put */ + CURLOPT(CURLOPT_URL, CURLOPTTYPE_STRINGPOINT, 2), + + /* Port number to connect to, if other than default. */ + CURLOPT(CURLOPT_PORT, CURLOPTTYPE_LONG, 3), + + /* Name of proxy to use. */ + CURLOPT(CURLOPT_PROXY, CURLOPTTYPE_STRINGPOINT, 4), + + /* "user:password;options" to use when fetching. */ + CURLOPT(CURLOPT_USERPWD, CURLOPTTYPE_STRINGPOINT, 5), + + /* "user:password" to use with proxy. */ + CURLOPT(CURLOPT_PROXYUSERPWD, CURLOPTTYPE_STRINGPOINT, 6), + + /* Range to get, specified as an ASCII string. */ + CURLOPT(CURLOPT_RANGE, CURLOPTTYPE_STRINGPOINT, 7), + + /* not used */ + + /* Specified file stream to upload from (use as input): */ + CURLOPT(CURLOPT_READDATA, CURLOPTTYPE_CBPOINT, 9), + + /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE + * bytes big. */ + CURLOPT(CURLOPT_ERRORBUFFER, CURLOPTTYPE_OBJECTPOINT, 10), + + /* Function that will be called to store the output (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CURLOPT(CURLOPT_WRITEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 11), + + /* Function that will be called to read the input (instead of fread). The + * parameters will use fread() syntax, make sure to follow them. */ + CURLOPT(CURLOPT_READFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 12), + + /* Time-out the read operation after this amount of seconds */ + CURLOPT(CURLOPT_TIMEOUT, CURLOPTTYPE_LONG, 13), + + /* If CURLOPT_READDATA is used, this can be used to inform libcurl about + * how large the file being sent really is. That allows better error + * checking and better verifies that the upload was successful. -1 means + * unknown size. + * + * For large file support, there is also a _LARGE version of the key + * which takes an off_t type, allowing platforms with larger off_t + * sizes to handle larger files. See below for INFILESIZE_LARGE. + */ + CURLOPT(CURLOPT_INFILESIZE, CURLOPTTYPE_LONG, 14), + + /* POST static input fields. */ + CURLOPT(CURLOPT_POSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 15), + + /* Set the referrer page (needed by some CGIs) */ + CURLOPT(CURLOPT_REFERER, CURLOPTTYPE_STRINGPOINT, 16), + + /* Set the FTP PORT string (interface name, named or numerical IP address) + Use i.e '-' to use default address. */ + CURLOPT(CURLOPT_FTPPORT, CURLOPTTYPE_STRINGPOINT, 17), + + /* Set the User-Agent string (examined by some CGIs) */ + CURLOPT(CURLOPT_USERAGENT, CURLOPTTYPE_STRINGPOINT, 18), + + /* If the download receives less than "low speed limit" bytes/second + * during "low speed time" seconds, the operations is aborted. + * You could i.e if you have a pretty high speed connection, abort if + * it is less than 2000 bytes/sec during 20 seconds. + */ + + /* Set the "low speed limit" */ + CURLOPT(CURLOPT_LOW_SPEED_LIMIT, CURLOPTTYPE_LONG, 19), + + /* Set the "low speed time" */ + CURLOPT(CURLOPT_LOW_SPEED_TIME, CURLOPTTYPE_LONG, 20), + + /* Set the continuation offset. + * + * Note there is also a _LARGE version of this key which uses + * off_t types, allowing for large file offsets on platforms which + * use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE. + */ + CURLOPT(CURLOPT_RESUME_FROM, CURLOPTTYPE_LONG, 21), + + /* Set cookie in request: */ + CURLOPT(CURLOPT_COOKIE, CURLOPTTYPE_STRINGPOINT, 22), + + /* This points to a linked list of headers, struct curl_slist kind. This + list is also used for RTSP (in spite of its name) */ + CURLOPT(CURLOPT_HTTPHEADER, CURLOPTTYPE_SLISTPOINT, 23), + + /* This points to a linked list of post entries, struct curl_httppost */ + CURLOPTDEPRECATED(CURLOPT_HTTPPOST, CURLOPTTYPE_OBJECTPOINT, 24, + 7.56.0, "Use CURLOPT_MIMEPOST"), + + /* name of the file keeping your private SSL-certificate */ + CURLOPT(CURLOPT_SSLCERT, CURLOPTTYPE_STRINGPOINT, 25), + + /* password for the SSL or SSH private key */ + CURLOPT(CURLOPT_KEYPASSWD, CURLOPTTYPE_STRINGPOINT, 26), + + /* send TYPE parameter? */ + CURLOPT(CURLOPT_CRLF, CURLOPTTYPE_LONG, 27), + + /* send linked-list of QUOTE commands */ + CURLOPT(CURLOPT_QUOTE, CURLOPTTYPE_SLISTPOINT, 28), + + /* send FILE * or void * to store headers to, if you use a callback it + is simply passed to the callback unmodified */ + CURLOPT(CURLOPT_HEADERDATA, CURLOPTTYPE_CBPOINT, 29), + + /* point to a file to read the initial cookies from, also enables + "cookie awareness" */ + CURLOPT(CURLOPT_COOKIEFILE, CURLOPTTYPE_STRINGPOINT, 31), + + /* What version to specifically try to use. + See CURL_SSLVERSION defines below. */ + CURLOPT(CURLOPT_SSLVERSION, CURLOPTTYPE_VALUES, 32), + + /* What kind of HTTP time condition to use, see defines */ + CURLOPT(CURLOPT_TIMECONDITION, CURLOPTTYPE_VALUES, 33), + + /* Time to use with the above condition. Specified in number of seconds + since 1 Jan 1970 */ + CURLOPT(CURLOPT_TIMEVALUE, CURLOPTTYPE_LONG, 34), + + /* 35 = OBSOLETE */ + + /* Custom request, for customizing the get command like + HTTP: DELETE, TRACE and others + FTP: to use a different list command + */ + CURLOPT(CURLOPT_CUSTOMREQUEST, CURLOPTTYPE_STRINGPOINT, 36), + + /* FILE handle to use instead of stderr */ + CURLOPT(CURLOPT_STDERR, CURLOPTTYPE_OBJECTPOINT, 37), + + /* 38 is not used */ + + /* send linked-list of post-transfer QUOTE commands */ + CURLOPT(CURLOPT_POSTQUOTE, CURLOPTTYPE_SLISTPOINT, 39), + + /* 40 is not used */ + + /* talk a lot */ + CURLOPT(CURLOPT_VERBOSE, CURLOPTTYPE_LONG, 41), + + /* throw the header out too */ + CURLOPT(CURLOPT_HEADER, CURLOPTTYPE_LONG, 42), + + /* shut off the progress meter */ + CURLOPT(CURLOPT_NOPROGRESS, CURLOPTTYPE_LONG, 43), + + /* use HEAD to get http document */ + CURLOPT(CURLOPT_NOBODY, CURLOPTTYPE_LONG, 44), + + /* no output on http error codes >= 400 */ + CURLOPT(CURLOPT_FAILONERROR, CURLOPTTYPE_LONG, 45), + + /* this is an upload */ + CURLOPT(CURLOPT_UPLOAD, CURLOPTTYPE_LONG, 46), + + /* HTTP POST method */ + CURLOPT(CURLOPT_POST, CURLOPTTYPE_LONG, 47), + + /* bare names when listing directories */ + CURLOPT(CURLOPT_DIRLISTONLY, CURLOPTTYPE_LONG, 48), + + /* Append instead of overwrite on upload! */ + CURLOPT(CURLOPT_APPEND, CURLOPTTYPE_LONG, 50), + + /* Specify whether to read the user+password from the .netrc or the URL. + * This must be one of the CURL_NETRC_* enums below. */ + CURLOPT(CURLOPT_NETRC, CURLOPTTYPE_VALUES, 51), + + /* use Location: Luke! */ + CURLOPT(CURLOPT_FOLLOWLOCATION, CURLOPTTYPE_LONG, 52), + + /* transfer data in text/ASCII format */ + CURLOPT(CURLOPT_TRANSFERTEXT, CURLOPTTYPE_LONG, 53), + + /* HTTP PUT */ + CURLOPTDEPRECATED(CURLOPT_PUT, CURLOPTTYPE_LONG, 54, + 7.12.1, "Use CURLOPT_UPLOAD"), + + /* 55 = OBSOLETE */ + + /* DEPRECATED + * Function that will be called instead of the internal progress display + * function. This function should be defined as the curl_progress_callback + * prototype defines. */ + CURLOPTDEPRECATED(CURLOPT_PROGRESSFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 56, + 7.32.0, "Use CURLOPT_XFERINFOFUNCTION"), + + /* Data passed to the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION + callbacks */ + CURLOPT(CURLOPT_XFERINFODATA, CURLOPTTYPE_CBPOINT, 57), +#define CURLOPT_PROGRESSDATA CURLOPT_XFERINFODATA + + /* We want the referrer field set automatically when following locations */ + CURLOPT(CURLOPT_AUTOREFERER, CURLOPTTYPE_LONG, 58), + + /* Port of the proxy, can be set in the proxy string as well with: + "[host]:[port]" */ + CURLOPT(CURLOPT_PROXYPORT, CURLOPTTYPE_LONG, 59), + + /* size of the POST input data, if strlen() is not good to use */ + CURLOPT(CURLOPT_POSTFIELDSIZE, CURLOPTTYPE_LONG, 60), + + /* tunnel non-http operations through an HTTP proxy */ + CURLOPT(CURLOPT_HTTPPROXYTUNNEL, CURLOPTTYPE_LONG, 61), + + /* Set the interface string to use as outgoing network interface */ + CURLOPT(CURLOPT_INTERFACE, CURLOPTTYPE_STRINGPOINT, 62), + + /* Set the krb4/5 security level, this also enables krb4/5 awareness. This + * is a string, 'clear', 'safe', 'confidential' or 'private'. If the string + * is set but does not match one of these, 'private' will be used. */ + CURLOPTDEPRECATED(CURLOPT_KRBLEVEL, CURLOPTTYPE_STRINGPOINT, 63, + 8.17.0, "removed"), + + /* Set if we should verify the peer in ssl handshake, set 1 to verify. */ + CURLOPT(CURLOPT_SSL_VERIFYPEER, CURLOPTTYPE_LONG, 64), + + /* The CApath or CAfile used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CURLOPT(CURLOPT_CAINFO, CURLOPTTYPE_STRINGPOINT, 65), + + /* 66 = OBSOLETE */ + /* 67 = OBSOLETE */ + + /* Maximum number of http redirects to follow */ + CURLOPT(CURLOPT_MAXREDIRS, CURLOPTTYPE_LONG, 68), + + /* Pass a long set to 1 to get the date of the requested document (if + possible)! Pass a zero to shut it off. */ + CURLOPT(CURLOPT_FILETIME, CURLOPTTYPE_LONG, 69), + + /* This points to a linked list of telnet options */ + CURLOPT(CURLOPT_TELNETOPTIONS, CURLOPTTYPE_SLISTPOINT, 70), + + /* Max amount of cached alive connections */ + CURLOPT(CURLOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 71), + + /* 72 = OBSOLETE */ + /* 73 = OBSOLETE */ + + /* Set to explicitly use a new connection for the upcoming transfer. + Do not use this unless you are absolutely sure of this, as it makes the + operation slower and is less friendly for the network. */ + CURLOPT(CURLOPT_FRESH_CONNECT, CURLOPTTYPE_LONG, 74), + + /* Set to explicitly forbid the upcoming transfer's connection to be reused + when done. Do not use this unless you are absolutely sure of this, as it + makes the operation slower and is less friendly for the network. */ + CURLOPT(CURLOPT_FORBID_REUSE, CURLOPTTYPE_LONG, 75), + + /* Set to a filename that contains random data for libcurl to use to + seed the random engine when doing SSL connects. */ + CURLOPTDEPRECATED(CURLOPT_RANDOM_FILE, CURLOPTTYPE_STRINGPOINT, 76, + 7.84.0, "Serves no purpose anymore"), + + /* Set to the Entropy Gathering Daemon socket pathname */ + CURLOPTDEPRECATED(CURLOPT_EGDSOCKET, CURLOPTTYPE_STRINGPOINT, 77, + 7.84.0, "Serves no purpose anymore"), + + /* Time-out connect operations after this amount of seconds, if connects are + OK within this time, then fine... This only aborts the connect phase. */ + CURLOPT(CURLOPT_CONNECTTIMEOUT, CURLOPTTYPE_LONG, 78), + + /* Function that will be called to store headers (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CURLOPT(CURLOPT_HEADERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 79), + + /* Set this to force the HTTP request to get back to GET. Only really usable + if POST, PUT or a custom request have been used first. + */ + CURLOPT(CURLOPT_HTTPGET, CURLOPTTYPE_LONG, 80), + + /* Set if we should verify the Common name from the peer certificate in ssl + * handshake, set 1 to check existence, 2 to ensure that it matches the + * provided hostname. */ + CURLOPT(CURLOPT_SSL_VERIFYHOST, CURLOPTTYPE_LONG, 81), + + /* Specify which filename to write all known cookies in after completed + operation. Set filename to "-" (dash) to make it go to stdout. */ + CURLOPT(CURLOPT_COOKIEJAR, CURLOPTTYPE_STRINGPOINT, 82), + + /* Specify which TLS 1.2 (1.1, 1.0) ciphers to use */ + CURLOPT(CURLOPT_SSL_CIPHER_LIST, CURLOPTTYPE_STRINGPOINT, 83), + + /* Specify which HTTP version to use! This must be set to one of the + CURL_HTTP_VERSION* enums set below. */ + CURLOPT(CURLOPT_HTTP_VERSION, CURLOPTTYPE_VALUES, 84), + + /* Specifically switch on or off the FTP engine's use of the EPSV command. By + default, that one will always be attempted before the more traditional + PASV command. */ + CURLOPT(CURLOPT_FTP_USE_EPSV, CURLOPTTYPE_LONG, 85), + + /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */ + CURLOPT(CURLOPT_SSLCERTTYPE, CURLOPTTYPE_STRINGPOINT, 86), + + /* name of the file keeping your private SSL-key */ + CURLOPT(CURLOPT_SSLKEY, CURLOPTTYPE_STRINGPOINT, 87), + + /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */ + CURLOPT(CURLOPT_SSLKEYTYPE, CURLOPTTYPE_STRINGPOINT, 88), + + /* crypto engine for the SSL-sub system */ + CURLOPT(CURLOPT_SSLENGINE, CURLOPTTYPE_STRINGPOINT, 89), + + /* set the crypto engine for the SSL-sub system as default + the param has no meaning... + */ + CURLOPT(CURLOPT_SSLENGINE_DEFAULT, CURLOPTTYPE_LONG, 90), + + /* Non-zero value means to use the global dns cache */ + /* DEPRECATED, do not use! */ + CURLOPTDEPRECATED(CURLOPT_DNS_USE_GLOBAL_CACHE, CURLOPTTYPE_LONG, 91, + 7.11.1, "Use CURLOPT_SHARE"), + + /* DNS cache timeout */ + CURLOPT(CURLOPT_DNS_CACHE_TIMEOUT, CURLOPTTYPE_LONG, 92), + + /* send linked-list of pre-transfer QUOTE commands */ + CURLOPT(CURLOPT_PREQUOTE, CURLOPTTYPE_SLISTPOINT, 93), + + /* set the debug function */ + CURLOPT(CURLOPT_DEBUGFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 94), + + /* set the data for the debug function */ + CURLOPT(CURLOPT_DEBUGDATA, CURLOPTTYPE_CBPOINT, 95), + + /* mark this as start of a cookie session */ + CURLOPT(CURLOPT_COOKIESESSION, CURLOPTTYPE_LONG, 96), + + /* The CApath directory used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CURLOPT(CURLOPT_CAPATH, CURLOPTTYPE_STRINGPOINT, 97), + + /* Instruct libcurl to use a smaller receive buffer */ + CURLOPT(CURLOPT_BUFFERSIZE, CURLOPTTYPE_LONG, 98), + + /* Instruct libcurl to not use any signal/alarm handlers, even when using + timeouts. This option is useful for multi-threaded applications. + See libcurl-the-guide for more background information. */ + CURLOPT(CURLOPT_NOSIGNAL, CURLOPTTYPE_LONG, 99), + + /* Provide a CURLShare for mutexing non-ts data */ + CURLOPT(CURLOPT_SHARE, CURLOPTTYPE_OBJECTPOINT, 100), + + /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default), + CURLPROXY_HTTPS, CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and + CURLPROXY_SOCKS5. */ + CURLOPT(CURLOPT_PROXYTYPE, CURLOPTTYPE_VALUES, 101), + + /* Set the Accept-Encoding string. Use this to tell a server you would like + the response to be compressed. Before 7.21.6, this was known as + CURLOPT_ENCODING */ + CURLOPT(CURLOPT_ACCEPT_ENCODING, CURLOPTTYPE_STRINGPOINT, 102), + + /* Set pointer to private data */ + CURLOPT(CURLOPT_PRIVATE, CURLOPTTYPE_OBJECTPOINT, 103), + + /* Set aliases for HTTP 200 in the HTTP Response header */ + CURLOPT(CURLOPT_HTTP200ALIASES, CURLOPTTYPE_SLISTPOINT, 104), + + /* Continue to send authentication (user+password) when following locations, + even when hostname changed. This can potentially send off the name + and password to whatever host the server decides. */ + CURLOPT(CURLOPT_UNRESTRICTED_AUTH, CURLOPTTYPE_LONG, 105), + + /* Specifically switch on or off the FTP engine's use of the EPRT command ( + it also disables the LPRT attempt). By default, those ones will always be + attempted before the good old traditional PORT command. */ + CURLOPT(CURLOPT_FTP_USE_EPRT, CURLOPTTYPE_LONG, 106), + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_USERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + CURLOPT(CURLOPT_HTTPAUTH, CURLOPTTYPE_VALUES, 107), + + /* Set the ssl context callback function, currently only for OpenSSL or + wolfSSL ssl_ctx, or mbedTLS mbedtls_ssl_config in the second argument. + The function must match the curl_ssl_ctx_callback prototype. */ + CURLOPT(CURLOPT_SSL_CTX_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 108), + + /* Set the userdata for the ssl context callback function's third + argument */ + CURLOPT(CURLOPT_SSL_CTX_DATA, CURLOPTTYPE_CBPOINT, 109), + + /* FTP Option that causes missing dirs to be created on the remote server. + In 7.19.4 we introduced the convenience enums for this option using the + CURLFTP_CREATE_DIR prefix. + */ + CURLOPT(CURLOPT_FTP_CREATE_MISSING_DIRS, CURLOPTTYPE_LONG, 110), + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_PROXYUSERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + CURLOPT(CURLOPT_PROXYAUTH, CURLOPTTYPE_VALUES, 111), + + /* Option that changes the timeout, in seconds, associated with getting a + response. This is different from transfer timeout time and essentially + places a demand on the server to acknowledge commands in a timely + manner. For FTP, SMTP, IMAP and POP3. */ + CURLOPT(CURLOPT_SERVER_RESPONSE_TIMEOUT, CURLOPTTYPE_LONG, 112), + + /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to + tell libcurl to use those IP versions only. This only has effect on + systems with support for more than one, i.e IPv4 _and_ IPv6. */ + CURLOPT(CURLOPT_IPRESOLVE, CURLOPTTYPE_VALUES, 113), + + /* Set this option to limit the size of a file that will be downloaded from + an HTTP or FTP server. + + Note there is also _LARGE version which adds large file support for + platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */ + CURLOPT(CURLOPT_MAXFILESIZE, CURLOPTTYPE_LONG, 114), + + /* See the comment for INFILESIZE above, but in short, specifies + * the size of the file being uploaded. -1 means unknown. + */ + CURLOPT(CURLOPT_INFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 115), + + /* Sets the continuation offset. There is also a CURLOPTTYPE_LONG version + * of this; look above for RESUME_FROM. + */ + CURLOPT(CURLOPT_RESUME_FROM_LARGE, CURLOPTTYPE_OFF_T, 116), + + /* Sets the maximum size of data that will be downloaded from + * an HTTP or FTP server. See MAXFILESIZE above for the LONG version. + */ + CURLOPT(CURLOPT_MAXFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 117), + + /* Set this option to the filename of your .netrc file you want libcurl + to parse (using the CURLOPT_NETRC option). If not set, libcurl will do + a poor attempt to find the user's home directory and check for a .netrc + file in there. */ + CURLOPT(CURLOPT_NETRC_FILE, CURLOPTTYPE_STRINGPOINT, 118), + + /* Enable SSL/TLS for FTP, pick one of: + CURLUSESSL_TRY - try using SSL, proceed anyway otherwise + CURLUSESSL_CONTROL - SSL for the control connection or fail + CURLUSESSL_ALL - SSL for all communication or fail + */ + CURLOPT(CURLOPT_USE_SSL, CURLOPTTYPE_VALUES, 119), + + /* The _LARGE version of the standard POSTFIELDSIZE option */ + CURLOPT(CURLOPT_POSTFIELDSIZE_LARGE, CURLOPTTYPE_OFF_T, 120), + + /* Enable/disable the TCP Nagle algorithm */ + CURLOPT(CURLOPT_TCP_NODELAY, CURLOPTTYPE_LONG, 121), + + /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 123 OBSOLETE. Gone in 7.16.0 */ + /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 127 OBSOLETE. Gone in 7.16.0 */ + /* 128 OBSOLETE. Gone in 7.16.0 */ + + /* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL), this option + can be used to change libcurl's default action which is to first try + "AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK + response has been received. + + Available parameters are: + CURLFTPAUTH_DEFAULT - let libcurl decide + CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS + CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL + */ + CURLOPT(CURLOPT_FTPSSLAUTH, CURLOPTTYPE_VALUES, 129), + + CURLOPTDEPRECATED(CURLOPT_IOCTLFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 130, + 7.18.0, "Use CURLOPT_SEEKFUNCTION"), + CURLOPTDEPRECATED(CURLOPT_IOCTLDATA, CURLOPTTYPE_CBPOINT, 131, + 7.18.0, "Use CURLOPT_SEEKDATA"), + + /* 132 OBSOLETE. Gone in 7.16.0 */ + /* 133 OBSOLETE. Gone in 7.16.0 */ + + /* null-terminated string for pass on to the FTP server when asked for + "account" info */ + CURLOPT(CURLOPT_FTP_ACCOUNT, CURLOPTTYPE_STRINGPOINT, 134), + + /* feed cookie into cookie engine */ + CURLOPT(CURLOPT_COOKIELIST, CURLOPTTYPE_STRINGPOINT, 135), + + /* ignore Content-Length */ + CURLOPT(CURLOPT_IGNORE_CONTENT_LENGTH, CURLOPTTYPE_LONG, 136), + + /* Set to non-zero to skip the IP address received in a 227 PASV FTP server + response. Typically used for FTP-SSL purposes but is not restricted to + that. libcurl will then instead use the same IP address it used for the + control connection. */ + CURLOPT(CURLOPT_FTP_SKIP_PASV_IP, CURLOPTTYPE_LONG, 137), + + /* Select "file method" to use when doing FTP, see the curl_ftpmethod + above. */ + CURLOPT(CURLOPT_FTP_FILEMETHOD, CURLOPTTYPE_VALUES, 138), + + /* Local port number to bind the socket to */ + CURLOPT(CURLOPT_LOCALPORT, CURLOPTTYPE_LONG, 139), + + /* Number of ports to try, including the first one set with LOCALPORT. + Thus, setting it to 1 will make no additional attempts but the first. + */ + CURLOPT(CURLOPT_LOCALPORTRANGE, CURLOPTTYPE_LONG, 140), + + /* no transfer, set up connection and let application use the socket by + extracting it with CURLINFO_LASTSOCKET */ + CURLOPT(CURLOPT_CONNECT_ONLY, CURLOPTTYPE_LONG, 141), + + /* Function that will be called to convert from the + network encoding (instead of using the iconv calls in libcurl) */ + CURLOPTDEPRECATED(CURLOPT_CONV_FROM_NETWORK_FUNCTION, + CURLOPTTYPE_FUNCTIONPOINT, 142, + 7.82.0, "Serves no purpose anymore"), + + /* Function that will be called to convert to the + network encoding (instead of using the iconv calls in libcurl) */ + CURLOPTDEPRECATED(CURLOPT_CONV_TO_NETWORK_FUNCTION, + CURLOPTTYPE_FUNCTIONPOINT, 143, + 7.82.0, "Serves no purpose anymore"), + + /* Function that will be called to convert from UTF8 + (instead of using the iconv calls in libcurl) + Note that this is used only for SSL certificate processing */ + CURLOPTDEPRECATED(CURLOPT_CONV_FROM_UTF8_FUNCTION, + CURLOPTTYPE_FUNCTIONPOINT, 144, + 7.82.0, "Serves no purpose anymore"), + + /* if the connection proceeds too quickly then need to slow it down */ + /* limit-rate: maximum number of bytes per second to send or receive */ + CURLOPT(CURLOPT_MAX_SEND_SPEED_LARGE, CURLOPTTYPE_OFF_T, 145), + CURLOPT(CURLOPT_MAX_RECV_SPEED_LARGE, CURLOPTTYPE_OFF_T, 146), + + /* Pointer to command string to send if USER/PASS fails. */ + CURLOPT(CURLOPT_FTP_ALTERNATIVE_TO_USER, CURLOPTTYPE_STRINGPOINT, 147), + + /* callback function for setting socket options */ + CURLOPT(CURLOPT_SOCKOPTFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 148), + CURLOPT(CURLOPT_SOCKOPTDATA, CURLOPTTYPE_CBPOINT, 149), + + /* set to 0 to disable session ID reuse for this transfer, default is + enabled (== 1) */ + CURLOPT(CURLOPT_SSL_SESSIONID_CACHE, CURLOPTTYPE_LONG, 150), + + /* allowed SSH authentication methods */ + CURLOPT(CURLOPT_SSH_AUTH_TYPES, CURLOPTTYPE_VALUES, 151), + + /* Used by scp/sftp to do public/private key authentication */ + CURLOPT(CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPTTYPE_STRINGPOINT, 152), + CURLOPT(CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPTTYPE_STRINGPOINT, 153), + + /* Send CCC (Clear Command Channel) after authentication */ + CURLOPT(CURLOPT_FTP_SSL_CCC, CURLOPTTYPE_LONG, 154), + + /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */ + CURLOPT(CURLOPT_TIMEOUT_MS, CURLOPTTYPE_LONG, 155), + CURLOPT(CURLOPT_CONNECTTIMEOUT_MS, CURLOPTTYPE_LONG, 156), + + /* set to zero to disable the libcurl's decoding and thus pass the raw body + data to the application even when it is encoded/compressed */ + CURLOPT(CURLOPT_HTTP_TRANSFER_DECODING, CURLOPTTYPE_LONG, 157), + CURLOPT(CURLOPT_HTTP_CONTENT_DECODING, CURLOPTTYPE_LONG, 158), + + /* Permission used when creating new files and directories on the remote + server for protocols that support it, SFTP/SCP/FILE */ + CURLOPT(CURLOPT_NEW_FILE_PERMS, CURLOPTTYPE_LONG, 159), + CURLOPT(CURLOPT_NEW_DIRECTORY_PERMS, CURLOPTTYPE_LONG, 160), + + /* Set the behavior of POST when redirecting. Values must be set to one + of CURL_REDIR* defines below. This used to be called CURLOPT_POST301 */ + CURLOPT(CURLOPT_POSTREDIR, CURLOPTTYPE_VALUES, 161), + + /* used by scp/sftp to verify the host's public key */ + CURLOPT(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, CURLOPTTYPE_STRINGPOINT, 162), + + /* Callback function for opening socket (instead of socket(2)). Optionally, + callback is able change the address or refuse to connect returning + CURL_SOCKET_BAD. The callback should have type + curl_opensocket_callback */ + CURLOPT(CURLOPT_OPENSOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 163), + CURLOPT(CURLOPT_OPENSOCKETDATA, CURLOPTTYPE_CBPOINT, 164), + + /* POST volatile input fields. */ + CURLOPT(CURLOPT_COPYPOSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 165), + + /* set transfer mode (;type=) when doing FTP via an HTTP proxy */ + CURLOPT(CURLOPT_PROXY_TRANSFER_MODE, CURLOPTTYPE_LONG, 166), + + /* Callback function for seeking in the input stream */ + CURLOPT(CURLOPT_SEEKFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 167), + CURLOPT(CURLOPT_SEEKDATA, CURLOPTTYPE_CBPOINT, 168), + + /* CRL file */ + CURLOPT(CURLOPT_CRLFILE, CURLOPTTYPE_STRINGPOINT, 169), + + /* Issuer certificate */ + CURLOPT(CURLOPT_ISSUERCERT, CURLOPTTYPE_STRINGPOINT, 170), + + /* (IPv6) Address scope */ + CURLOPT(CURLOPT_ADDRESS_SCOPE, CURLOPTTYPE_LONG, 171), + + /* Collect certificate chain info and allow it to get retrievable with + CURLINFO_CERTINFO after the transfer is complete. */ + CURLOPT(CURLOPT_CERTINFO, CURLOPTTYPE_LONG, 172), + + /* "name" and "pwd" to use when fetching. */ + CURLOPT(CURLOPT_USERNAME, CURLOPTTYPE_STRINGPOINT, 173), + CURLOPT(CURLOPT_PASSWORD, CURLOPTTYPE_STRINGPOINT, 174), + + /* "name" and "pwd" to use with Proxy when fetching. */ + CURLOPT(CURLOPT_PROXYUSERNAME, CURLOPTTYPE_STRINGPOINT, 175), + CURLOPT(CURLOPT_PROXYPASSWORD, CURLOPTTYPE_STRINGPOINT, 176), + + /* Comma separated list of hostnames defining no-proxy zones. These should + match both hostnames directly, and hostnames within a domain. For + example, local.com will match local.com and www.local.com, but NOT + notlocal.com or www.notlocal.com. For compatibility with other + implementations of this, .local.com will be considered to be the same as + local.com. A single * is the only valid wildcard, and effectively + disables the use of proxy. */ + CURLOPT(CURLOPT_NOPROXY, CURLOPTTYPE_STRINGPOINT, 177), + + /* block size for TFTP transfers */ + CURLOPT(CURLOPT_TFTP_BLKSIZE, CURLOPTTYPE_LONG, 178), + + /* Socks Service */ + /* DEPRECATED, do not use! */ + CURLOPTDEPRECATED(CURLOPT_SOCKS5_GSSAPI_SERVICE, + CURLOPTTYPE_STRINGPOINT, 179, + 7.49.0, "Use CURLOPT_PROXY_SERVICE_NAME"), + + /* Socks Service */ + CURLOPT(CURLOPT_SOCKS5_GSSAPI_NEC, CURLOPTTYPE_LONG, 180), + + /* set the bitmask for the protocols that are allowed to be used for the + transfer, which thus helps the app which takes URLs from users or other + external inputs and want to restrict what protocol(s) to deal + with. Defaults to CURLPROTO_ALL. */ + CURLOPTDEPRECATED(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181, + 7.85.0, "Use CURLOPT_PROTOCOLS_STR"), + + /* set the bitmask for the protocols that libcurl is allowed to follow to, + as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs + to be set in both bitmasks to be allowed to get redirected to. */ + CURLOPTDEPRECATED(CURLOPT_REDIR_PROTOCOLS, CURLOPTTYPE_LONG, 182, + 7.85.0, "Use CURLOPT_REDIR_PROTOCOLS_STR"), + + /* set the SSH knownhost filename to use */ + CURLOPT(CURLOPT_SSH_KNOWNHOSTS, CURLOPTTYPE_STRINGPOINT, 183), + + /* set the SSH host key callback, must point to a curl_sshkeycallback + function */ + CURLOPT(CURLOPT_SSH_KEYFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 184), + + /* set the SSH host key callback custom pointer */ + CURLOPT(CURLOPT_SSH_KEYDATA, CURLOPTTYPE_CBPOINT, 185), + + /* set the SMTP mail originator */ + CURLOPT(CURLOPT_MAIL_FROM, CURLOPTTYPE_STRINGPOINT, 186), + + /* set the list of SMTP mail receiver(s) */ + CURLOPT(CURLOPT_MAIL_RCPT, CURLOPTTYPE_SLISTPOINT, 187), + + /* FTP: send PRET before PASV */ + CURLOPT(CURLOPT_FTP_USE_PRET, CURLOPTTYPE_LONG, 188), + + /* RTSP request method (OPTIONS, SETUP, PLAY, etc...) */ + CURLOPT(CURLOPT_RTSP_REQUEST, CURLOPTTYPE_VALUES, 189), + + /* The RTSP session identifier */ + CURLOPT(CURLOPT_RTSP_SESSION_ID, CURLOPTTYPE_STRINGPOINT, 190), + + /* The RTSP stream URI */ + CURLOPT(CURLOPT_RTSP_STREAM_URI, CURLOPTTYPE_STRINGPOINT, 191), + + /* The Transport: header to use in RTSP requests */ + CURLOPT(CURLOPT_RTSP_TRANSPORT, CURLOPTTYPE_STRINGPOINT, 192), + + /* Manually initialize the client RTSP CSeq for this handle */ + CURLOPT(CURLOPT_RTSP_CLIENT_CSEQ, CURLOPTTYPE_LONG, 193), + + /* Manually initialize the server RTSP CSeq for this handle */ + CURLOPT(CURLOPT_RTSP_SERVER_CSEQ, CURLOPTTYPE_LONG, 194), + + /* The stream to pass to INTERLEAVEFUNCTION. */ + CURLOPT(CURLOPT_INTERLEAVEDATA, CURLOPTTYPE_CBPOINT, 195), + + /* Let the application define a custom write method for RTP data */ + CURLOPT(CURLOPT_INTERLEAVEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 196), + + /* Turn on wildcard matching */ + CURLOPT(CURLOPT_WILDCARDMATCH, CURLOPTTYPE_LONG, 197), + + /* Directory matching callback called before downloading of an + individual file (chunk) started */ + CURLOPT(CURLOPT_CHUNK_BGN_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 198), + + /* Directory matching callback called after the file (chunk) + was downloaded, or skipped */ + CURLOPT(CURLOPT_CHUNK_END_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 199), + + /* Change match (fnmatch-like) callback for wildcard matching */ + CURLOPT(CURLOPT_FNMATCH_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 200), + + /* Let the application define custom chunk data pointer */ + CURLOPT(CURLOPT_CHUNK_DATA, CURLOPTTYPE_CBPOINT, 201), + + /* FNMATCH_FUNCTION user pointer */ + CURLOPT(CURLOPT_FNMATCH_DATA, CURLOPTTYPE_CBPOINT, 202), + + /* send linked-list of name:port:address sets */ + CURLOPT(CURLOPT_RESOLVE, CURLOPTTYPE_SLISTPOINT, 203), + + /* Set a username for authenticated TLS */ + CURLOPT(CURLOPT_TLSAUTH_USERNAME, CURLOPTTYPE_STRINGPOINT, 204), + + /* Set a password for authenticated TLS */ + CURLOPT(CURLOPT_TLSAUTH_PASSWORD, CURLOPTTYPE_STRINGPOINT, 205), + + /* Set authentication type for authenticated TLS */ + CURLOPT(CURLOPT_TLSAUTH_TYPE, CURLOPTTYPE_STRINGPOINT, 206), + + /* Set to 1 to enable the "TE:" header in HTTP requests to ask for + compressed transfer-encoded responses. Set to 0 to disable the use of TE: + in outgoing requests. The current default is 0, but it might change in a + future libcurl release. + + libcurl will ask for the compressed methods it knows of, and if that + is not any, it will not ask for transfer-encoding at all even if this + option is set to 1. */ + CURLOPT(CURLOPT_TRANSFER_ENCODING, CURLOPTTYPE_LONG, 207), + + /* Callback function for closing socket (instead of close(2)). The callback + should have type curl_closesocket_callback */ + CURLOPT(CURLOPT_CLOSESOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 208), + CURLOPT(CURLOPT_CLOSESOCKETDATA, CURLOPTTYPE_CBPOINT, 209), + + /* allow GSSAPI credential delegation */ + CURLOPT(CURLOPT_GSSAPI_DELEGATION, CURLOPTTYPE_VALUES, 210), + + /* Set the name servers to use for DNS resolution. + * Only supported by the c-ares DNS backend */ + CURLOPT(CURLOPT_DNS_SERVERS, CURLOPTTYPE_STRINGPOINT, 211), + + /* Time-out accept operations (currently for FTP only) after this amount + of milliseconds. */ + CURLOPT(CURLOPT_ACCEPTTIMEOUT_MS, CURLOPTTYPE_LONG, 212), + + /* Set TCP keepalive */ + CURLOPT(CURLOPT_TCP_KEEPALIVE, CURLOPTTYPE_LONG, 213), + + /* non-universal keepalive knobs (Linux, AIX, HP-UX, more) */ + CURLOPT(CURLOPT_TCP_KEEPIDLE, CURLOPTTYPE_LONG, 214), + CURLOPT(CURLOPT_TCP_KEEPINTVL, CURLOPTTYPE_LONG, 215), + + /* Enable/disable specific SSL features with a bitmask, see CURLSSLOPT_* */ + CURLOPT(CURLOPT_SSL_OPTIONS, CURLOPTTYPE_VALUES, 216), + + /* Set the SMTP auth originator */ + CURLOPT(CURLOPT_MAIL_AUTH, CURLOPTTYPE_STRINGPOINT, 217), + + /* Enable/disable SASL initial response */ + CURLOPT(CURLOPT_SASL_IR, CURLOPTTYPE_LONG, 218), + + /* Function that will be called instead of the internal progress display + * function. This function should be defined as the curl_xferinfo_callback + * prototype defines. (Deprecates CURLOPT_PROGRESSFUNCTION) */ + CURLOPT(CURLOPT_XFERINFOFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 219), + + /* The XOAUTH2 bearer token */ + CURLOPT(CURLOPT_XOAUTH2_BEARER, CURLOPTTYPE_STRINGPOINT, 220), + + /* Set the interface string to use as outgoing network + * interface for DNS requests. + * Only supported by the c-ares DNS backend */ + CURLOPT(CURLOPT_DNS_INTERFACE, CURLOPTTYPE_STRINGPOINT, 221), + + /* Set the local IPv4 address to use for outgoing DNS requests. + * Only supported by the c-ares DNS backend */ + CURLOPT(CURLOPT_DNS_LOCAL_IP4, CURLOPTTYPE_STRINGPOINT, 222), + + /* Set the local IPv6 address to use for outgoing DNS requests. + * Only supported by the c-ares DNS backend */ + CURLOPT(CURLOPT_DNS_LOCAL_IP6, CURLOPTTYPE_STRINGPOINT, 223), + + /* Set authentication options directly */ + CURLOPT(CURLOPT_LOGIN_OPTIONS, CURLOPTTYPE_STRINGPOINT, 224), + + /* Enable/disable TLS NPN extension (http2 over ssl might fail without) */ + CURLOPTDEPRECATED(CURLOPT_SSL_ENABLE_NPN, CURLOPTTYPE_LONG, 225, + 7.86.0, "Has no function"), + + /* Enable/disable TLS ALPN extension (http2 over ssl might fail without) */ + CURLOPT(CURLOPT_SSL_ENABLE_ALPN, CURLOPTTYPE_LONG, 226), + + /* Time to wait for a response to an HTTP request containing an + * Expect: 100-continue header before sending the data anyway. */ + CURLOPT(CURLOPT_EXPECT_100_TIMEOUT_MS, CURLOPTTYPE_LONG, 227), + + /* This points to a linked list of headers used for proxy requests only, + struct curl_slist kind */ + CURLOPT(CURLOPT_PROXYHEADER, CURLOPTTYPE_SLISTPOINT, 228), + + /* Pass in a bitmask of "header options" */ + CURLOPT(CURLOPT_HEADEROPT, CURLOPTTYPE_VALUES, 229), + + /* The public key used to validate the peer public key */ + CURLOPT(CURLOPT_PINNEDPUBLICKEY, CURLOPTTYPE_STRINGPOINT, 230), + + /* Path to Unix domain socket */ + CURLOPT(CURLOPT_UNIX_SOCKET_PATH, CURLOPTTYPE_STRINGPOINT, 231), + + /* Set if we should verify the certificate status. */ + CURLOPT(CURLOPT_SSL_VERIFYSTATUS, CURLOPTTYPE_LONG, 232), + + /* Set if we should enable TLS false start. */ + CURLOPTDEPRECATED(CURLOPT_SSL_FALSESTART, CURLOPTTYPE_LONG, 233, + 8.15.0, "Has no function"), + + /* Do not squash dot-dot sequences */ + CURLOPT(CURLOPT_PATH_AS_IS, CURLOPTTYPE_LONG, 234), + + /* Proxy Service Name */ + CURLOPT(CURLOPT_PROXY_SERVICE_NAME, CURLOPTTYPE_STRINGPOINT, 235), + + /* Service Name */ + CURLOPT(CURLOPT_SERVICE_NAME, CURLOPTTYPE_STRINGPOINT, 236), + + /* Wait/do not wait for pipe/mutex to clarify */ + CURLOPT(CURLOPT_PIPEWAIT, CURLOPTTYPE_LONG, 237), + + /* Set the protocol used when curl is given a URL without a protocol */ + CURLOPT(CURLOPT_DEFAULT_PROTOCOL, CURLOPTTYPE_STRINGPOINT, 238), + + /* Set stream weight, 1 - 256 (default is 16) */ + CURLOPT(CURLOPT_STREAM_WEIGHT, CURLOPTTYPE_LONG, 239), + + /* Set stream dependency on another curl handle */ + CURLOPT(CURLOPT_STREAM_DEPENDS, CURLOPTTYPE_OBJECTPOINT, 240), + + /* Set E-xclusive stream dependency on another curl handle */ + CURLOPT(CURLOPT_STREAM_DEPENDS_E, CURLOPTTYPE_OBJECTPOINT, 241), + + /* Do not send any tftp option requests to the server */ + CURLOPT(CURLOPT_TFTP_NO_OPTIONS, CURLOPTTYPE_LONG, 242), + + /* Linked-list of host:port:connect-to-host:connect-to-port, + overrides the URL's host:port (only for the network layer) */ + CURLOPT(CURLOPT_CONNECT_TO, CURLOPTTYPE_SLISTPOINT, 243), + + /* Set TCP Fast Open */ + CURLOPT(CURLOPT_TCP_FASTOPEN, CURLOPTTYPE_LONG, 244), + + /* Continue to send data if the server responds early with an + * HTTP status code >= 300 */ + CURLOPT(CURLOPT_KEEP_SENDING_ON_ERROR, CURLOPTTYPE_LONG, 245), + + /* The CApath or CAfile used to validate the proxy certificate + this option is used only if PROXY_SSL_VERIFYPEER is true */ + CURLOPT(CURLOPT_PROXY_CAINFO, CURLOPTTYPE_STRINGPOINT, 246), + + /* The CApath directory used to validate the proxy certificate + this option is used only if PROXY_SSL_VERIFYPEER is true */ + CURLOPT(CURLOPT_PROXY_CAPATH, CURLOPTTYPE_STRINGPOINT, 247), + + /* Set if we should verify the proxy in ssl handshake, + set 1 to verify. */ + CURLOPT(CURLOPT_PROXY_SSL_VERIFYPEER, CURLOPTTYPE_LONG, 248), + + /* Set if we should verify the Common name from the proxy certificate in ssl + * handshake, set 1 to check existence, 2 to ensure that it matches + * the provided hostname. */ + CURLOPT(CURLOPT_PROXY_SSL_VERIFYHOST, CURLOPTTYPE_LONG, 249), + + /* What version to specifically try to use for proxy. + See CURL_SSLVERSION defines below. */ + CURLOPT(CURLOPT_PROXY_SSLVERSION, CURLOPTTYPE_VALUES, 250), + + /* Set a username for authenticated TLS for proxy */ + CURLOPT(CURLOPT_PROXY_TLSAUTH_USERNAME, CURLOPTTYPE_STRINGPOINT, 251), + + /* Set a password for authenticated TLS for proxy */ + CURLOPT(CURLOPT_PROXY_TLSAUTH_PASSWORD, CURLOPTTYPE_STRINGPOINT, 252), + + /* Set authentication type for authenticated TLS for proxy */ + CURLOPT(CURLOPT_PROXY_TLSAUTH_TYPE, CURLOPTTYPE_STRINGPOINT, 253), + + /* name of the file keeping your private SSL-certificate for proxy */ + CURLOPT(CURLOPT_PROXY_SSLCERT, CURLOPTTYPE_STRINGPOINT, 254), + + /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") for + proxy */ + CURLOPT(CURLOPT_PROXY_SSLCERTTYPE, CURLOPTTYPE_STRINGPOINT, 255), + + /* name of the file keeping your private SSL-key for proxy */ + CURLOPT(CURLOPT_PROXY_SSLKEY, CURLOPTTYPE_STRINGPOINT, 256), + + /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") for + proxy */ + CURLOPT(CURLOPT_PROXY_SSLKEYTYPE, CURLOPTTYPE_STRINGPOINT, 257), + + /* password for the SSL private key for proxy */ + CURLOPT(CURLOPT_PROXY_KEYPASSWD, CURLOPTTYPE_STRINGPOINT, 258), + + /* Specify which TLS 1.2 (1.1, 1.0) ciphers to use for proxy */ + CURLOPT(CURLOPT_PROXY_SSL_CIPHER_LIST, CURLOPTTYPE_STRINGPOINT, 259), + + /* CRL file for proxy */ + CURLOPT(CURLOPT_PROXY_CRLFILE, CURLOPTTYPE_STRINGPOINT, 260), + + /* Enable/disable specific SSL features with a bitmask for proxy, see + CURLSSLOPT_* */ + CURLOPT(CURLOPT_PROXY_SSL_OPTIONS, CURLOPTTYPE_LONG, 261), + + /* Name of pre proxy to use. */ + CURLOPT(CURLOPT_PRE_PROXY, CURLOPTTYPE_STRINGPOINT, 262), + + /* The public key in DER form used to validate the proxy public key + this option is used only if PROXY_SSL_VERIFYPEER is true */ + CURLOPT(CURLOPT_PROXY_PINNEDPUBLICKEY, CURLOPTTYPE_STRINGPOINT, 263), + + /* Path to an abstract Unix domain socket */ + CURLOPT(CURLOPT_ABSTRACT_UNIX_SOCKET, CURLOPTTYPE_STRINGPOINT, 264), + + /* Suppress proxy CONNECT response headers from user callbacks */ + CURLOPT(CURLOPT_SUPPRESS_CONNECT_HEADERS, CURLOPTTYPE_LONG, 265), + + /* The request target, instead of extracted from the URL */ + CURLOPT(CURLOPT_REQUEST_TARGET, CURLOPTTYPE_STRINGPOINT, 266), + + /* bitmask of allowed auth methods for connections to SOCKS5 proxies */ + CURLOPT(CURLOPT_SOCKS5_AUTH, CURLOPTTYPE_LONG, 267), + + /* Enable/disable SSH compression */ + CURLOPT(CURLOPT_SSH_COMPRESSION, CURLOPTTYPE_LONG, 268), + + /* Post MIME data. */ + CURLOPT(CURLOPT_MIMEPOST, CURLOPTTYPE_OBJECTPOINT, 269), + + /* Time to use with the CURLOPT_TIMECONDITION. Specified in number of + seconds since 1 Jan 1970. */ + CURLOPT(CURLOPT_TIMEVALUE_LARGE, CURLOPTTYPE_OFF_T, 270), + + /* Head start in milliseconds to give happy eyeballs. */ + CURLOPT(CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, CURLOPTTYPE_LONG, 271), + + /* Function that will be called before a resolver request is made */ + CURLOPT(CURLOPT_RESOLVER_START_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 272), + + /* User data to pass to the resolver start callback. */ + CURLOPT(CURLOPT_RESOLVER_START_DATA, CURLOPTTYPE_CBPOINT, 273), + + /* send HAProxy PROXY protocol header? */ + CURLOPT(CURLOPT_HAPROXYPROTOCOL, CURLOPTTYPE_LONG, 274), + + /* shuffle addresses before use when DNS returns multiple */ + CURLOPT(CURLOPT_DNS_SHUFFLE_ADDRESSES, CURLOPTTYPE_LONG, 275), + + /* Specify which TLS 1.3 ciphers suites to use */ + CURLOPT(CURLOPT_TLS13_CIPHERS, CURLOPTTYPE_STRINGPOINT, 276), + CURLOPT(CURLOPT_PROXY_TLS13_CIPHERS, CURLOPTTYPE_STRINGPOINT, 277), + + /* Disallow specifying username/login in URL. */ + CURLOPT(CURLOPT_DISALLOW_USERNAME_IN_URL, CURLOPTTYPE_LONG, 278), + + /* DNS-over-HTTPS URL */ + CURLOPT(CURLOPT_DOH_URL, CURLOPTTYPE_STRINGPOINT, 279), + + /* Preferred buffer size to use for uploads */ + CURLOPT(CURLOPT_UPLOAD_BUFFERSIZE, CURLOPTTYPE_LONG, 280), + + /* Time in ms between connection upkeep calls for long-lived connections. */ + CURLOPT(CURLOPT_UPKEEP_INTERVAL_MS, CURLOPTTYPE_LONG, 281), + + /* Specify URL using CURL URL API. */ + CURLOPT(CURLOPT_CURLU, CURLOPTTYPE_OBJECTPOINT, 282), + + /* add trailing data just after no more data is available */ + CURLOPT(CURLOPT_TRAILERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 283), + + /* pointer to be passed to HTTP_TRAILER_FUNCTION */ + CURLOPT(CURLOPT_TRAILERDATA, CURLOPTTYPE_CBPOINT, 284), + + /* set this to 1L to allow HTTP/0.9 responses or 0L to disallow */ + CURLOPT(CURLOPT_HTTP09_ALLOWED, CURLOPTTYPE_LONG, 285), + + /* alt-svc control bitmask */ + CURLOPT(CURLOPT_ALTSVC_CTRL, CURLOPTTYPE_LONG, 286), + + /* alt-svc cache filename to possibly read from/write to */ + CURLOPT(CURLOPT_ALTSVC, CURLOPTTYPE_STRINGPOINT, 287), + + /* maximum age (idle time) of a connection to consider it for reuse + * (in seconds) */ + CURLOPT(CURLOPT_MAXAGE_CONN, CURLOPTTYPE_LONG, 288), + + /* SASL authorization identity */ + CURLOPT(CURLOPT_SASL_AUTHZID, CURLOPTTYPE_STRINGPOINT, 289), + + /* allow RCPT TO command to fail for some recipients */ + CURLOPT(CURLOPT_MAIL_RCPT_ALLOWFAILS, CURLOPTTYPE_LONG, 290), + + /* the private SSL-certificate as a "blob" */ + CURLOPT(CURLOPT_SSLCERT_BLOB, CURLOPTTYPE_BLOB, 291), + CURLOPT(CURLOPT_SSLKEY_BLOB, CURLOPTTYPE_BLOB, 292), + CURLOPT(CURLOPT_PROXY_SSLCERT_BLOB, CURLOPTTYPE_BLOB, 293), + CURLOPT(CURLOPT_PROXY_SSLKEY_BLOB, CURLOPTTYPE_BLOB, 294), + CURLOPT(CURLOPT_ISSUERCERT_BLOB, CURLOPTTYPE_BLOB, 295), + + /* Issuer certificate for proxy */ + CURLOPT(CURLOPT_PROXY_ISSUERCERT, CURLOPTTYPE_STRINGPOINT, 296), + CURLOPT(CURLOPT_PROXY_ISSUERCERT_BLOB, CURLOPTTYPE_BLOB, 297), + + /* the EC curves requested by the TLS client (RFC 8422, 5.1); + * OpenSSL support via 'set_groups'/'set_curves': + * https://docs.openssl.org/master/man3/SSL_CTX_set1_curves/ + */ + CURLOPT(CURLOPT_SSL_EC_CURVES, CURLOPTTYPE_STRINGPOINT, 298), + + /* HSTS bitmask */ + CURLOPT(CURLOPT_HSTS_CTRL, CURLOPTTYPE_LONG, 299), + /* HSTS filename */ + CURLOPT(CURLOPT_HSTS, CURLOPTTYPE_STRINGPOINT, 300), + + /* HSTS read callback */ + CURLOPT(CURLOPT_HSTSREADFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 301), + CURLOPT(CURLOPT_HSTSREADDATA, CURLOPTTYPE_CBPOINT, 302), + + /* HSTS write callback */ + CURLOPT(CURLOPT_HSTSWRITEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 303), + CURLOPT(CURLOPT_HSTSWRITEDATA, CURLOPTTYPE_CBPOINT, 304), + + /* Parameters for V4 signature */ + CURLOPT(CURLOPT_AWS_SIGV4, CURLOPTTYPE_STRINGPOINT, 305), + + /* Same as CURLOPT_SSL_VERIFYPEER but for DoH (DNS-over-HTTPS) servers. */ + CURLOPT(CURLOPT_DOH_SSL_VERIFYPEER, CURLOPTTYPE_LONG, 306), + + /* Same as CURLOPT_SSL_VERIFYHOST but for DoH (DNS-over-HTTPS) servers. */ + CURLOPT(CURLOPT_DOH_SSL_VERIFYHOST, CURLOPTTYPE_LONG, 307), + + /* Same as CURLOPT_SSL_VERIFYSTATUS but for DoH (DNS-over-HTTPS) servers. */ + CURLOPT(CURLOPT_DOH_SSL_VERIFYSTATUS, CURLOPTTYPE_LONG, 308), + + /* The CA certificates as "blob" used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CURLOPT(CURLOPT_CAINFO_BLOB, CURLOPTTYPE_BLOB, 309), + + /* The CA certificates as "blob" used to validate the proxy certificate + this option is used only if PROXY_SSL_VERIFYPEER is true */ + CURLOPT(CURLOPT_PROXY_CAINFO_BLOB, CURLOPTTYPE_BLOB, 310), + + /* used by scp/sftp to verify the host's public key */ + CURLOPT(CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, CURLOPTTYPE_STRINGPOINT, 311), + + /* Function that will be called immediately before the initial request + is made on a connection (after any protocol negotiation step). */ + CURLOPT(CURLOPT_PREREQFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 312), + + /* Data passed to the CURLOPT_PREREQFUNCTION callback */ + CURLOPT(CURLOPT_PREREQDATA, CURLOPTTYPE_CBPOINT, 313), + + /* maximum age (since creation) of a connection to consider it for reuse + * (in seconds) */ + CURLOPT(CURLOPT_MAXLIFETIME_CONN, CURLOPTTYPE_LONG, 314), + + /* Set MIME option flags. */ + CURLOPT(CURLOPT_MIME_OPTIONS, CURLOPTTYPE_LONG, 315), + + /* set the SSH host key callback, must point to a curl_sshkeycallback + function */ + CURLOPT(CURLOPT_SSH_HOSTKEYFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 316), + + /* set the SSH host key callback custom pointer */ + CURLOPT(CURLOPT_SSH_HOSTKEYDATA, CURLOPTTYPE_CBPOINT, 317), + + /* specify which protocols that are allowed to be used for the transfer, + which thus helps the app which takes URLs from users or other external + inputs and want to restrict what protocol(s) to deal with. Defaults to + all built-in protocols. */ + CURLOPT(CURLOPT_PROTOCOLS_STR, CURLOPTTYPE_STRINGPOINT, 318), + + /* specify which protocols that libcurl is allowed to follow directs to */ + CURLOPT(CURLOPT_REDIR_PROTOCOLS_STR, CURLOPTTYPE_STRINGPOINT, 319), + + /* WebSockets options */ + CURLOPT(CURLOPT_WS_OPTIONS, CURLOPTTYPE_LONG, 320), + + /* CA cache timeout */ + CURLOPT(CURLOPT_CA_CACHE_TIMEOUT, CURLOPTTYPE_LONG, 321), + + /* Can leak things, gonna exit() soon */ + CURLOPT(CURLOPT_QUICK_EXIT, CURLOPTTYPE_LONG, 322), + + /* set a specific client IP for HAProxy PROXY protocol header? */ + CURLOPT(CURLOPT_HAPROXY_CLIENT_IP, CURLOPTTYPE_STRINGPOINT, 323), + + /* millisecond version */ + CURLOPT(CURLOPT_SERVER_RESPONSE_TIMEOUT_MS, CURLOPTTYPE_LONG, 324), + + /* set ECH configuration */ + CURLOPT(CURLOPT_ECH, CURLOPTTYPE_STRINGPOINT, 325), + + /* maximum number of keepalive probes (Linux, *BSD, macOS, etc.) */ + CURLOPT(CURLOPT_TCP_KEEPCNT, CURLOPTTYPE_LONG, 326), + + CURLOPT(CURLOPT_UPLOAD_FLAGS, CURLOPTTYPE_LONG, 327), + + /* set TLS supported signature algorithms */ + CURLOPT(CURLOPT_SSL_SIGNATURE_ALGORITHMS, CURLOPTTYPE_STRINGPOINT, 328), + + CURLOPT_LASTENTRY /* the last unused */ +} CURLoption; + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* Backwards compatibility with older names */ +/* These are scheduled to disappear by 2011 */ + +/* This was added in version 7.19.1 */ +#define CURLOPT_POST301 CURLOPT_POSTREDIR + +/* These are scheduled to disappear by 2009 */ + +/* The following were added in 7.17.0 */ +#define CURLOPT_SSLKEYPASSWD CURLOPT_KEYPASSWD +#define CURLOPT_FTPAPPEND CURLOPT_APPEND +#define CURLOPT_FTPLISTONLY CURLOPT_DIRLISTONLY +#define CURLOPT_FTP_SSL CURLOPT_USE_SSL + +/* The following were added earlier */ + +#define CURLOPT_SSLCERTPASSWD CURLOPT_KEYPASSWD +#define CURLOPT_KRB4LEVEL CURLOPT_KRBLEVEL + +/* */ +#define CURLOPT_FTP_RESPONSE_TIMEOUT CURLOPT_SERVER_RESPONSE_TIMEOUT + +/* Added in 8.2.0 */ +#define CURLOPT_MAIL_RCPT_ALLLOWFAILS CURLOPT_MAIL_RCPT_ALLOWFAILS + +#else +/* This is set if CURL_NO_OLDIES is defined at compile-time */ +#undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */ +#endif + +/* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host + name resolves addresses using more than one IP protocol version, this + option might be handy to force libcurl to use a specific IP version. */ +#define CURL_IPRESOLVE_WHATEVER 0L /* default, uses addresses to all IP + versions that your system allows */ +#define CURL_IPRESOLVE_V4 1L /* uses only IPv4 addresses/connections */ +#define CURL_IPRESOLVE_V6 2L /* uses only IPv6 addresses/connections */ + + /* Convenient "aliases" */ +#define CURLOPT_RTSPHEADER CURLOPT_HTTPHEADER + +/* These constants are for use with the CURLOPT_HTTP_VERSION option. */ +#define CURL_HTTP_VERSION_NONE 0L /* setting this means we do not care, and + that we would like the library to choose + the best possible for us! */ +#define CURL_HTTP_VERSION_1_0 1L /* please use HTTP 1.0 in the request */ +#define CURL_HTTP_VERSION_1_1 2L /* please use HTTP 1.1 in the request */ +#define CURL_HTTP_VERSION_2_0 3L /* please use HTTP 2 in the request */ +#define CURL_HTTP_VERSION_2TLS 4L /* use version 2 for HTTPS, version 1.1 for + HTTP */ +#define CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE 5L /* please use HTTP 2 without + HTTP/1.1 Upgrade */ +#define CURL_HTTP_VERSION_3 30L /* Use HTTP/3, fallback to HTTP/2 or + HTTP/1 if needed. For HTTPS only. For + HTTP, this option makes libcurl + return error. */ +#define CURL_HTTP_VERSION_3ONLY 31L /* Use HTTP/3 without fallback. For + HTTPS only. For HTTP, this makes + libcurl return error. */ +#define CURL_HTTP_VERSION_LAST 32L /* *ILLEGAL* http version */ + +/* Convenience definition simple because the name of the version is HTTP/2 and + not 2.0. The 2_0 version of the enum name was set while the version was + still planned to be 2.0 and we stick to it for compatibility. */ +#define CURL_HTTP_VERSION_2 CURL_HTTP_VERSION_2_0 + +/* + * Public API enums for RTSP requests + */ + +#define CURL_RTSPREQ_NONE 0L +#define CURL_RTSPREQ_OPTIONS 1L +#define CURL_RTSPREQ_DESCRIBE 2L +#define CURL_RTSPREQ_ANNOUNCE 3L +#define CURL_RTSPREQ_SETUP 4L +#define CURL_RTSPREQ_PLAY 5L +#define CURL_RTSPREQ_PAUSE 6L +#define CURL_RTSPREQ_TEARDOWN 7L +#define CURL_RTSPREQ_GET_PARAMETER 8L +#define CURL_RTSPREQ_SET_PARAMETER 9L +#define CURL_RTSPREQ_RECORD 10L +#define CURL_RTSPREQ_RECEIVE 11L +#define CURL_RTSPREQ_LAST 12L /* not used */ + + /* These enums are for use with the CURLOPT_NETRC option. */ +#define CURL_NETRC_IGNORED 0L /* The .netrc will never be read. + This is the default. */ +#define CURL_NETRC_OPTIONAL 1L /* A user:password in the URL will be preferred + to one in the .netrc. */ +#define CURL_NETRC_REQUIRED 2L /* A user:password in the URL will be ignored. + Unless one is set programmatically, the + .netrc will be queried. */ +enum CURL_NETRC_OPTION { + /* we set a single member here, just to make sure we still provide the enum, + but the values to use are defined above with L suffixes */ + CURL_NETRC_LAST = 3 +}; + +#define CURL_SSLVERSION_DEFAULT 0L +#define CURL_SSLVERSION_TLSv1 1L /* TLS 1.x */ +#define CURL_SSLVERSION_SSLv2 2L +#define CURL_SSLVERSION_SSLv3 3L +#define CURL_SSLVERSION_TLSv1_0 4L +#define CURL_SSLVERSION_TLSv1_1 5L +#define CURL_SSLVERSION_TLSv1_2 6L +#define CURL_SSLVERSION_TLSv1_3 7L + +#define CURL_SSLVERSION_LAST 8L /* never use, keep last */ + +#define CURL_SSLVERSION_MAX_NONE 0L +#define CURL_SSLVERSION_MAX_DEFAULT (CURL_SSLVERSION_TLSv1 << 16) +#define CURL_SSLVERSION_MAX_TLSv1_0 (CURL_SSLVERSION_TLSv1_0 << 16) +#define CURL_SSLVERSION_MAX_TLSv1_1 (CURL_SSLVERSION_TLSv1_1 << 16) +#define CURL_SSLVERSION_MAX_TLSv1_2 (CURL_SSLVERSION_TLSv1_2 << 16) +#define CURL_SSLVERSION_MAX_TLSv1_3 (CURL_SSLVERSION_TLSv1_3 << 16) + +/* never use, keep last */ +#define CURL_SSLVERSION_MAX_LAST (CURL_SSLVERSION_LAST << 16) + +#define CURL_TLSAUTH_NONE 0L +#define CURL_TLSAUTH_SRP 1L + +enum CURL_TLSAUTH { + /* we set a single member here, just to make sure we still provide the enum, + but the values to use are defined above with L suffixes */ + CURL_TLSAUTH_LAST = 2 +}; + +/* symbols to use with CURLOPT_POSTREDIR. + CURL_REDIR_POST_301, CURL_REDIR_POST_302 and CURL_REDIR_POST_303 + can be bitwise ORed so that CURL_REDIR_POST_301 | CURL_REDIR_POST_302 + | CURL_REDIR_POST_303 == CURL_REDIR_POST_ALL */ + +#define CURL_REDIR_GET_ALL 0L +#define CURL_REDIR_POST_301 1L +#define CURL_REDIR_POST_302 2L +#define CURL_REDIR_POST_303 4L +#define CURL_REDIR_POST_ALL \ + (CURL_REDIR_POST_301 | CURL_REDIR_POST_302 | CURL_REDIR_POST_303) + +#define CURL_TIMECOND_NONE 0L +#define CURL_TIMECOND_IFMODSINCE 1L +#define CURL_TIMECOND_IFUNMODSINCE 2L +#define CURL_TIMECOND_LASTMOD 3L + +typedef enum { + /* we set a single member here, just to make sure we still provide + the enum typedef, but the values to use are defined above with L + suffixes */ + CURL_TIMECOND_LAST = 4 +} curl_TimeCond; + +/* Special size_t value signaling a null-terminated string. */ +#define CURL_ZERO_TERMINATED ((size_t)-1) + +/* curl_strequal() and curl_strnequal() are subject for removal in a future + release */ +CURL_EXTERN int curl_strequal(const char *s1, const char *s2); +CURL_EXTERN int curl_strnequal(const char *s1, const char *s2, size_t n); + +/* Mime/form handling support. */ +typedef struct curl_mime curl_mime; /* Mime context. */ +typedef struct curl_mimepart curl_mimepart; /* Mime part context. */ + +/* CURLMIMEOPT_ defines are for the CURLOPT_MIME_OPTIONS option. */ +#define CURLMIMEOPT_FORMESCAPE (1L << 0) /* Use backslash-escaping for forms */ + +/* + * NAME curl_mime_init() + * + * DESCRIPTION + * + * Create a mime context and return its handle. The easy parameter is the + * target handle. + */ +CURL_EXTERN curl_mime *curl_mime_init(CURL *easy); + +/* + * NAME curl_mime_free() + * + * DESCRIPTION + * + * release a mime handle and its substructures. + */ +CURL_EXTERN void curl_mime_free(curl_mime *mime); + +/* + * NAME curl_mime_addpart() + * + * DESCRIPTION + * + * Append a new empty part to the given mime context and return a handle to + * the created part. + */ +CURL_EXTERN curl_mimepart *curl_mime_addpart(curl_mime *mime); + +/* + * NAME curl_mime_name() + * + * DESCRIPTION + * + * Set mime/form part name. + */ +CURL_EXTERN CURLcode curl_mime_name(curl_mimepart *part, const char *name); + +/* + * NAME curl_mime_filename() + * + * DESCRIPTION + * + * Set mime part remote filename. + */ +CURL_EXTERN CURLcode curl_mime_filename(curl_mimepart *part, + const char *filename); + +/* + * NAME curl_mime_type() + * + * DESCRIPTION + * + * Set mime part type. + */ +CURL_EXTERN CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype); + +/* + * NAME curl_mime_encoder() + * + * DESCRIPTION + * + * Set mime data transfer encoder. + */ +CURL_EXTERN CURLcode curl_mime_encoder(curl_mimepart *part, + const char *encoding); + +/* + * NAME curl_mime_data() + * + * DESCRIPTION + * + * Set mime part data source from memory data, + */ +CURL_EXTERN CURLcode curl_mime_data(curl_mimepart *part, + const char *data, size_t datasize); + +/* + * NAME curl_mime_filedata() + * + * DESCRIPTION + * + * Set mime part data source from named file. + */ +CURL_EXTERN CURLcode curl_mime_filedata(curl_mimepart *part, + const char *filename); + +/* + * NAME curl_mime_data_cb() + * + * DESCRIPTION + * + * Set mime part data source from callback function. + */ +CURL_EXTERN CURLcode curl_mime_data_cb(curl_mimepart *part, + curl_off_t datasize, + curl_read_callback readfunc, + curl_seek_callback seekfunc, + curl_free_callback freefunc, + void *arg); + +/* + * NAME curl_mime_subparts() + * + * DESCRIPTION + * + * Set mime part data source from subparts. + */ +CURL_EXTERN CURLcode curl_mime_subparts(curl_mimepart *part, + curl_mime *subparts); +/* + * NAME curl_mime_headers() + * + * DESCRIPTION + * + * Set mime part headers. + */ +CURL_EXTERN CURLcode curl_mime_headers(curl_mimepart *part, + struct curl_slist *headers, + int take_ownership); + +typedef enum { + /********* the first one is unused ************/ + CURLFORM_NOTHING CURL_DEPRECATED(7.56.0, ""), + CURLFORM_COPYNAME CURL_DEPRECATED(7.56.0, "Use curl_mime_name()"), + CURLFORM_PTRNAME CURL_DEPRECATED(7.56.0, "Use curl_mime_name()"), + CURLFORM_NAMELENGTH CURL_DEPRECATED(7.56.0, ""), + CURLFORM_COPYCONTENTS CURL_DEPRECATED(7.56.0, "Use curl_mime_data()"), + CURLFORM_PTRCONTENTS CURL_DEPRECATED(7.56.0, "Use curl_mime_data()"), + CURLFORM_CONTENTSLENGTH CURL_DEPRECATED(7.56.0, "Use curl_mime_data()"), + CURLFORM_FILECONTENT CURL_DEPRECATED(7.56.0, "Use curl_mime_data_cb()"), + CURLFORM_ARRAY CURL_DEPRECATED(7.56.0, ""), + CURLFORM_OBSOLETE, + CURLFORM_FILE CURL_DEPRECATED(7.56.0, "Use curl_mime_filedata()"), + + CURLFORM_BUFFER CURL_DEPRECATED(7.56.0, "Use curl_mime_filename()"), + CURLFORM_BUFFERPTR CURL_DEPRECATED(7.56.0, "Use curl_mime_data()"), + CURLFORM_BUFFERLENGTH CURL_DEPRECATED(7.56.0, "Use curl_mime_data()"), + + CURLFORM_CONTENTTYPE CURL_DEPRECATED(7.56.0, "Use curl_mime_type()"), + CURLFORM_CONTENTHEADER CURL_DEPRECATED(7.56.0, "Use curl_mime_headers()"), + CURLFORM_FILENAME CURL_DEPRECATED(7.56.0, "Use curl_mime_filename()"), + CURLFORM_END, + CURLFORM_OBSOLETE2, + + CURLFORM_STREAM CURL_DEPRECATED(7.56.0, "Use curl_mime_data_cb()"), + CURLFORM_CONTENTLEN /* added in 7.46.0, provide a curl_off_t length */ + CURL_DEPRECATED(7.56.0, "Use curl_mime_data()"), + + CURLFORM_LASTENTRY /* the last unused */ +} CURLformoption; + +/* structure to be used as parameter for CURLFORM_ARRAY */ +struct curl_forms { + CURLformoption option; + const char *value; +}; + +/* use this for multipart formpost building */ +/* Returns code for curl_formadd() + * + * Returns: + * CURL_FORMADD_OK on success + * CURL_FORMADD_MEMORY if the FormInfo allocation fails + * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form + * CURL_FORMADD_NULL if a null pointer was given for a char + * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed + * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used + * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error) + * CURL_FORMADD_MEMORY if a curl_httppost struct cannot be allocated + * CURL_FORMADD_MEMORY if some allocation for string copying failed. + * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array + * + ***************************************************************************/ +typedef enum { + CURL_FORMADD_OK CURL_DEPRECATED(7.56.0, ""), /* 1st, no error */ + + CURL_FORMADD_MEMORY CURL_DEPRECATED(7.56.0, ""), + CURL_FORMADD_OPTION_TWICE CURL_DEPRECATED(7.56.0, ""), + CURL_FORMADD_NULL CURL_DEPRECATED(7.56.0, ""), + CURL_FORMADD_UNKNOWN_OPTION CURL_DEPRECATED(7.56.0, ""), + CURL_FORMADD_INCOMPLETE CURL_DEPRECATED(7.56.0, ""), + CURL_FORMADD_ILLEGAL_ARRAY CURL_DEPRECATED(7.56.0, ""), + /* libcurl was built with form api disabled */ + CURL_FORMADD_DISABLED CURL_DEPRECATED(7.56.0, ""), + + CURL_FORMADD_LAST /* last */ +} CURLFORMcode; + +/* + * NAME curl_formadd() + * + * DESCRIPTION + * + * Pretty advanced function for building multi-part formposts. Each invoke + * adds one part that together construct a full post. Then use + * CURLOPT_HTTPPOST to send it off to libcurl. + */ +CURL_EXTERN CURLFORMcode CURL_DEPRECATED(7.56.0, "Use curl_mime_init()") +curl_formadd(struct curl_httppost **httppost, + struct curl_httppost **last_post, + ...); + +/* + * callback function for curl_formget() + * The void *arg pointer will be the one passed as second argument to + * curl_formget(). + * The character buffer passed to it must not be freed. + * Should return the buffer length passed to it as the argument "len" on + * success. + */ +typedef size_t (*curl_formget_callback)(void *arg, const char *buf, + size_t len); + +/* + * NAME curl_formget() + * + * DESCRIPTION + * + * Serialize a curl_httppost struct built with curl_formadd(). + * Accepts a void pointer as second argument which will be passed to + * the curl_formget_callback function. + * Returns 0 on success. + */ +CURL_EXTERN int CURL_DEPRECATED(7.56.0, "") +curl_formget(struct curl_httppost *form, void *arg, + curl_formget_callback append); +/* + * NAME curl_formfree() + * + * DESCRIPTION + * + * Free a multipart formpost previously built with curl_formadd(). + */ +CURL_EXTERN void CURL_DEPRECATED(7.56.0, "Use curl_mime_free()") +curl_formfree(struct curl_httppost *form); + +/* + * NAME curl_getenv() + * + * DESCRIPTION + * + * Returns a malloc()'ed string that MUST be curl_free()ed after usage is + * complete. DEPRECATED - see lib/README.curlx + */ +CURL_EXTERN char *curl_getenv(const char *variable); + +/* + * NAME curl_version() + * + * DESCRIPTION + * + * Returns a static ASCII string of the libcurl version. + */ +CURL_EXTERN char *curl_version(void); + +/* + * NAME curl_easy_escape() + * + * DESCRIPTION + * + * Escapes URL strings (converts all letters consider illegal in URLs to their + * %XX versions). This function returns a new allocated string or NULL if an + * error occurred. + */ +CURL_EXTERN char *curl_easy_escape(CURL *handle, + const char *string, + int length); + +/* the previous version: */ +CURL_EXTERN char *curl_escape(const char *string, + int length); + +/* + * NAME curl_easy_unescape() + * + * DESCRIPTION + * + * Unescapes URL encoding in strings (converts all %XX codes to their 8bit + * versions). This function returns a new allocated string or NULL if an error + * occurred. + * Conversion Note: On non-ASCII platforms the ASCII %XX codes are + * converted into the host encoding. + */ +CURL_EXTERN char *curl_easy_unescape(CURL *handle, + const char *string, + int length, + int *outlength); + +/* the previous version */ +CURL_EXTERN char *curl_unescape(const char *string, + int length); + +/* + * NAME curl_free() + * + * DESCRIPTION + * + * Provided for de-allocation in the same translation unit that did the + * allocation. Added in libcurl 7.10 + */ +CURL_EXTERN void curl_free(void *p); + +/* + * NAME curl_global_init() + * + * DESCRIPTION + * + * curl_global_init() should be invoked exactly once for each application that + * uses libcurl and before any call of other libcurl functions. + * + * This function is thread-safe if CURL_VERSION_THREADSAFE is set in the + * curl_version_info_data.features flag (fetch by curl_version_info()). + */ +CURL_EXTERN CURLcode curl_global_init(long flags); + +/* + * NAME curl_global_init_mem() + * + * DESCRIPTION + * + * curl_global_init() or curl_global_init_mem() should be invoked exactly once + * for each application that uses libcurl. This function can be used to + * initialize libcurl and set user defined memory management callback + * functions. Users can implement memory management routines to check for + * memory leaks, check for misuse of the curl library etc. User registered + * callback routines will be invoked by this library instead of the system + * memory management routines like malloc, free etc. + */ +CURL_EXTERN CURLcode curl_global_init_mem(long flags, + curl_malloc_callback m, + curl_free_callback f, + curl_realloc_callback r, + curl_strdup_callback s, + curl_calloc_callback c); + +/* + * NAME curl_global_cleanup() + * + * DESCRIPTION + * + * curl_global_cleanup() should be invoked exactly once for each application + * that uses libcurl + */ +CURL_EXTERN void curl_global_cleanup(void); + +/* + * NAME curl_global_trace() + * + * DESCRIPTION + * + * curl_global_trace() can be invoked at application start to + * configure which components in curl should participate in tracing. + * + * This function is thread-safe if CURL_VERSION_THREADSAFE is set in the + * curl_version_info_data.features flag (fetch by curl_version_info()). + */ +CURL_EXTERN CURLcode curl_global_trace(const char *config); + +/* linked-list structure for the CURLOPT_QUOTE option (and other) */ +struct curl_slist { + char *data; + struct curl_slist *next; +}; + +/* + * NAME curl_global_sslset() + * + * DESCRIPTION + * + * When built with multiple SSL backends, curl_global_sslset() allows to + * choose one. This function can only be called once, and it must be called + * *before* curl_global_init(). + * + * The backend can be identified by the id (e.g. CURLSSLBACKEND_OPENSSL). The + * backend can also be specified via the name parameter (passing -1 as id). If + * both id and name are specified, the name will be ignored. If neither id nor + * name are specified, the function will fail with CURLSSLSET_UNKNOWN_BACKEND + * and set the "avail" pointer to the NULL-terminated list of available + * backends. + * + * Upon success, the function returns CURLSSLSET_OK. + * + * If the specified SSL backend is not available, the function returns + * CURLSSLSET_UNKNOWN_BACKEND and sets the "avail" pointer to a + * NULL-terminated list of available SSL backends. + * + * The SSL backend can be set only once. If it has already been set, a + * subsequent attempt to change it will result in a CURLSSLSET_TOO_LATE. + */ + +struct curl_ssl_backend { + curl_sslbackend id; + const char *name; +}; +typedef struct curl_ssl_backend curl_ssl_backend; + +typedef enum { + CURLSSLSET_OK = 0, + CURLSSLSET_UNKNOWN_BACKEND, + CURLSSLSET_TOO_LATE, + CURLSSLSET_NO_BACKENDS /* libcurl was built without any SSL support */ +} CURLsslset; + +CURL_EXTERN CURLsslset curl_global_sslset(curl_sslbackend id, const char *name, + const curl_ssl_backend ***avail); + +/* + * NAME curl_slist_append() + * + * DESCRIPTION + * + * Appends a string to a linked list. If no list exists, it will be created + * first. Returns the new list, after appending. + */ +CURL_EXTERN struct curl_slist *curl_slist_append(struct curl_slist *list, + const char *data); + +/* + * NAME curl_slist_free_all() + * + * DESCRIPTION + * + * free a previously built curl_slist. + */ +CURL_EXTERN void curl_slist_free_all(struct curl_slist *list); + +/* + * NAME curl_getdate() + * + * DESCRIPTION + * + * Returns the time, in seconds since 1 Jan 1970 of the time string given in + * the first argument. The time argument in the second parameter is unused + * and should be set to NULL. + */ +CURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused); + +/* info about the certificate chain, for SSL backends that support it. Asked + for with CURLOPT_CERTINFO / CURLINFO_CERTINFO */ +struct curl_certinfo { + int num_of_certs; /* number of certificates with information */ + struct curl_slist **certinfo; /* for each index in this array, there is a + linked list with textual information for a + certificate in the format "name:content". + eg "Subject:foo", "Issuer:bar", etc. */ +}; + +/* Information about the SSL library used and the respective internal SSL + handle, which can be used to obtain further information regarding the + connection. Asked for with CURLINFO_TLS_SSL_PTR or CURLINFO_TLS_SESSION. */ +struct curl_tlssessioninfo { + curl_sslbackend backend; + void *internals; +}; + +#define CURLINFO_STRING 0x100000 +#define CURLINFO_LONG 0x200000 +#define CURLINFO_DOUBLE 0x300000 +#define CURLINFO_SLIST 0x400000 +#define CURLINFO_PTR 0x400000 /* same as SLIST */ +#define CURLINFO_SOCKET 0x500000 +#define CURLINFO_OFF_T 0x600000 +#define CURLINFO_MASK 0x0fffff +#define CURLINFO_TYPEMASK 0xf00000 + +typedef enum { + CURLINFO_NONE, /* first, never use this */ + CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1, + CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2, + CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3, + CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4, + CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5, + CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6, + CURLINFO_SIZE_UPLOAD CURL_DEPRECATED(7.55.0, "Use CURLINFO_SIZE_UPLOAD_T") + = CURLINFO_DOUBLE + 7, + CURLINFO_SIZE_UPLOAD_T = CURLINFO_OFF_T + 7, + CURLINFO_SIZE_DOWNLOAD + CURL_DEPRECATED(7.55.0, "Use CURLINFO_SIZE_DOWNLOAD_T") + = CURLINFO_DOUBLE + 8, + CURLINFO_SIZE_DOWNLOAD_T = CURLINFO_OFF_T + 8, + CURLINFO_SPEED_DOWNLOAD + CURL_DEPRECATED(7.55.0, "Use CURLINFO_SPEED_DOWNLOAD_T") + = CURLINFO_DOUBLE + 9, + CURLINFO_SPEED_DOWNLOAD_T = CURLINFO_OFF_T + 9, + CURLINFO_SPEED_UPLOAD + CURL_DEPRECATED(7.55.0, "Use CURLINFO_SPEED_UPLOAD_T") + = CURLINFO_DOUBLE + 10, + CURLINFO_SPEED_UPLOAD_T = CURLINFO_OFF_T + 10, + CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11, + CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12, + CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13, + CURLINFO_FILETIME = CURLINFO_LONG + 14, + CURLINFO_FILETIME_T = CURLINFO_OFF_T + 14, + CURLINFO_CONTENT_LENGTH_DOWNLOAD + CURL_DEPRECATED(7.55.0, + "Use CURLINFO_CONTENT_LENGTH_DOWNLOAD_T") + = CURLINFO_DOUBLE + 15, + CURLINFO_CONTENT_LENGTH_DOWNLOAD_T = CURLINFO_OFF_T + 15, + CURLINFO_CONTENT_LENGTH_UPLOAD + CURL_DEPRECATED(7.55.0, + "Use CURLINFO_CONTENT_LENGTH_UPLOAD_T") + = CURLINFO_DOUBLE + 16, + CURLINFO_CONTENT_LENGTH_UPLOAD_T = CURLINFO_OFF_T + 16, + CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17, + CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18, + CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19, + CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20, + CURLINFO_PRIVATE = CURLINFO_STRING + 21, + CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22, + CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23, + CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, + CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, + CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26, + CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27, + CURLINFO_COOKIELIST = CURLINFO_SLIST + 28, + CURLINFO_LASTSOCKET CURL_DEPRECATED(7.45.0, "Use CURLINFO_ACTIVESOCKET") + = CURLINFO_LONG + 29, + CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30, + CURLINFO_REDIRECT_URL = CURLINFO_STRING + 31, + CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32, + CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33, + CURLINFO_CERTINFO = CURLINFO_PTR + 34, + CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35, + CURLINFO_RTSP_SESSION_ID = CURLINFO_STRING + 36, + CURLINFO_RTSP_CLIENT_CSEQ = CURLINFO_LONG + 37, + CURLINFO_RTSP_SERVER_CSEQ = CURLINFO_LONG + 38, + CURLINFO_RTSP_CSEQ_RECV = CURLINFO_LONG + 39, + CURLINFO_PRIMARY_PORT = CURLINFO_LONG + 40, + CURLINFO_LOCAL_IP = CURLINFO_STRING + 41, + CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42, + CURLINFO_TLS_SESSION CURL_DEPRECATED(7.48.0, "Use CURLINFO_TLS_SSL_PTR") + = CURLINFO_PTR + 43, + CURLINFO_ACTIVESOCKET = CURLINFO_SOCKET + 44, + CURLINFO_TLS_SSL_PTR = CURLINFO_PTR + 45, + CURLINFO_HTTP_VERSION = CURLINFO_LONG + 46, + CURLINFO_PROXY_SSL_VERIFYRESULT = CURLINFO_LONG + 47, + CURLINFO_PROTOCOL CURL_DEPRECATED(7.85.0, "Use CURLINFO_SCHEME") + = CURLINFO_LONG + 48, + CURLINFO_SCHEME = CURLINFO_STRING + 49, + CURLINFO_TOTAL_TIME_T = CURLINFO_OFF_T + 50, + CURLINFO_NAMELOOKUP_TIME_T = CURLINFO_OFF_T + 51, + CURLINFO_CONNECT_TIME_T = CURLINFO_OFF_T + 52, + CURLINFO_PRETRANSFER_TIME_T = CURLINFO_OFF_T + 53, + CURLINFO_STARTTRANSFER_TIME_T = CURLINFO_OFF_T + 54, + CURLINFO_REDIRECT_TIME_T = CURLINFO_OFF_T + 55, + CURLINFO_APPCONNECT_TIME_T = CURLINFO_OFF_T + 56, + CURLINFO_RETRY_AFTER = CURLINFO_OFF_T + 57, + CURLINFO_EFFECTIVE_METHOD = CURLINFO_STRING + 58, + CURLINFO_PROXY_ERROR = CURLINFO_LONG + 59, + CURLINFO_REFERER = CURLINFO_STRING + 60, + CURLINFO_CAINFO = CURLINFO_STRING + 61, + CURLINFO_CAPATH = CURLINFO_STRING + 62, + CURLINFO_XFER_ID = CURLINFO_OFF_T + 63, + CURLINFO_CONN_ID = CURLINFO_OFF_T + 64, + CURLINFO_QUEUE_TIME_T = CURLINFO_OFF_T + 65, + CURLINFO_USED_PROXY = CURLINFO_LONG + 66, + CURLINFO_POSTTRANSFER_TIME_T = CURLINFO_OFF_T + 67, + CURLINFO_EARLYDATA_SENT_T = CURLINFO_OFF_T + 68, + CURLINFO_HTTPAUTH_USED = CURLINFO_LONG + 69, + CURLINFO_PROXYAUTH_USED = CURLINFO_LONG + 70, + CURLINFO_LASTONE = 70 +} CURLINFO; + +/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as + CURLINFO_HTTP_CODE */ +#define CURLINFO_HTTP_CODE CURLINFO_RESPONSE_CODE + +typedef enum { + CURLCLOSEPOLICY_NONE, /* first, never use this */ + + CURLCLOSEPOLICY_OLDEST, + CURLCLOSEPOLICY_LEAST_RECENTLY_USED, + CURLCLOSEPOLICY_LEAST_TRAFFIC, + CURLCLOSEPOLICY_SLOWEST, + CURLCLOSEPOLICY_CALLBACK, + + CURLCLOSEPOLICY_LAST /* last, never use this */ +} curl_closepolicy; + +#define CURL_GLOBAL_SSL (1 << 0) /* no purpose since 7.57.0 */ +#define CURL_GLOBAL_WIN32 (1 << 1) +#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32) +#define CURL_GLOBAL_NOTHING 0 +#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL +#define CURL_GLOBAL_ACK_EINTR (1 << 2) + +/***************************************************************************** + * Setup defines, protos etc for the sharing stuff. + */ + +/* Different data locks for a single share */ +typedef enum { + CURL_LOCK_DATA_NONE = 0, + /* CURL_LOCK_DATA_SHARE is used internally to say that + * the locking is just made to change the internal state of the share + * itself. + */ + CURL_LOCK_DATA_SHARE, + CURL_LOCK_DATA_COOKIE, + CURL_LOCK_DATA_DNS, + CURL_LOCK_DATA_SSL_SESSION, + CURL_LOCK_DATA_CONNECT, + CURL_LOCK_DATA_PSL, + CURL_LOCK_DATA_HSTS, + CURL_LOCK_DATA_LAST +} curl_lock_data; + +/* Different lock access types */ +typedef enum { + CURL_LOCK_ACCESS_NONE = 0, /* unspecified action */ + CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */ + CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */ + CURL_LOCK_ACCESS_LAST /* never use */ +} curl_lock_access; + +typedef void (*curl_lock_function)(CURL *handle, + curl_lock_data data, + curl_lock_access locktype, + void *userptr); +typedef void (*curl_unlock_function)(CURL *handle, + curl_lock_data data, + void *userptr); + +typedef enum { + CURLSHE_OK, /* all is fine */ + CURLSHE_BAD_OPTION, /* 1 */ + CURLSHE_IN_USE, /* 2 */ + CURLSHE_INVALID, /* 3 */ + CURLSHE_NOMEM, /* 4 out of memory */ + CURLSHE_NOT_BUILT_IN, /* 5 feature not present in lib */ + CURLSHE_LAST /* never use */ +} CURLSHcode; + +typedef enum { + CURLSHOPT_NONE, /* do not use */ + CURLSHOPT_SHARE, /* specify a data type to share */ + CURLSHOPT_UNSHARE, /* specify which data type to stop sharing */ + CURLSHOPT_LOCKFUNC, /* pass in a 'curl_lock_function' pointer */ + CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */ + CURLSHOPT_USERDATA, /* pass in a user data pointer used in the lock/unlock + callback functions */ + CURLSHOPT_LAST /* never use */ +} CURLSHoption; + +CURL_EXTERN CURLSH *curl_share_init(void); +CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *share, CURLSHoption option, + ...); +CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *share); + +/**************************************************************************** + * Structures for querying information about the curl library at runtime. + */ + +typedef enum { + CURLVERSION_FIRST, /* 7.10 */ + CURLVERSION_SECOND, /* 7.11.1 */ + CURLVERSION_THIRD, /* 7.12.0 */ + CURLVERSION_FOURTH, /* 7.16.1 */ + CURLVERSION_FIFTH, /* 7.57.0 */ + CURLVERSION_SIXTH, /* 7.66.0 */ + CURLVERSION_SEVENTH, /* 7.70.0 */ + CURLVERSION_EIGHTH, /* 7.72.0 */ + CURLVERSION_NINTH, /* 7.75.0 */ + CURLVERSION_TENTH, /* 7.77.0 */ + CURLVERSION_ELEVENTH, /* 7.87.0 */ + CURLVERSION_TWELFTH, /* 8.8.0 */ + CURLVERSION_LAST /* never actually use this */ +} CURLversion; + +/* The 'CURLVERSION_NOW' is the symbolic name meant to be used by + basically all programs ever that want to get version information. It is + meant to be a built-in version number for what kind of struct the caller + expects. If the struct ever changes, we redefine the NOW to another enum + from above. */ +#define CURLVERSION_NOW CURLVERSION_TWELFTH + +struct curl_version_info_data { + CURLversion age; /* age of the returned struct */ + const char *version; /* LIBCURL_VERSION */ + unsigned int version_num; /* LIBCURL_VERSION_NUM */ + const char *host; /* OS/host/cpu/machine when configured */ + int features; /* bitmask, see defines below */ + const char *ssl_version; /* human readable string */ + long ssl_version_num; /* not used anymore, always 0 */ + const char *libz_version; /* human readable string */ + /* protocols is terminated by an entry with a NULL protoname */ + const char * const *protocols; + + /* The fields below this were added in CURLVERSION_SECOND */ + const char *ares; + int ares_num; + + /* This field was added in CURLVERSION_THIRD */ + const char *libidn; + + /* These field were added in CURLVERSION_FOURTH */ + + /* Same as '_libiconv_version' if built with HAVE_ICONV */ + int iconv_ver_num; + + const char *libssh_version; /* human readable string */ + + /* These fields were added in CURLVERSION_FIFTH */ + unsigned int brotli_ver_num; /* Numeric Brotli version + (MAJOR << 24) | (MINOR << 12) | PATCH */ + const char *brotli_version; /* human readable string. */ + + /* These fields were added in CURLVERSION_SIXTH */ + unsigned int nghttp2_ver_num; /* Numeric nghttp2 version + (MAJOR << 16) | (MINOR << 8) | PATCH */ + const char *nghttp2_version; /* human readable string. */ + const char *quic_version; /* human readable quic (+ HTTP/3) library + + version or NULL */ + + /* These fields were added in CURLVERSION_SEVENTH */ + const char *cainfo; /* the built-in default CURLOPT_CAINFO, might + be NULL */ + const char *capath; /* the built-in default CURLOPT_CAPATH, might + be NULL */ + + /* These fields were added in CURLVERSION_EIGHTH */ + unsigned int zstd_ver_num; /* Numeric Zstd version + (MAJOR << 24) | (MINOR << 12) | PATCH */ + const char *zstd_version; /* human readable string. */ + + /* These fields were added in CURLVERSION_NINTH */ + const char *hyper_version; /* human readable string. */ + + /* These fields were added in CURLVERSION_TENTH */ + const char *gsasl_version; /* human readable string. */ + + /* These fields were added in CURLVERSION_ELEVENTH */ + /* feature_names is terminated by an entry with a NULL feature name */ + const char * const *feature_names; + + /* These fields were added in CURLVERSION_TWELFTH */ + const char *rtmp_version; /* human readable string. */ +}; +typedef struct curl_version_info_data curl_version_info_data; + +#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ +#define CURL_VERSION_KERBEROS4 (1<<1) /* Kerberos V4 auth is supported + (deprecated) */ +#define CURL_VERSION_SSL (1<<2) /* SSL options are present */ +#define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ +#define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ +#define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth is supported + (deprecated) */ +#define CURL_VERSION_DEBUG (1<<6) /* Built with debug capabilities */ +#define CURL_VERSION_ASYNCHDNS (1<<7) /* Asynchronous DNS resolves */ +#define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth is supported */ +#define CURL_VERSION_LARGEFILE (1<<9) /* Supports files larger than 2GB */ +#define CURL_VERSION_IDN (1<<10) /* Internationized Domain Names are + supported */ +#define CURL_VERSION_SSPI (1<<11) /* Built against Windows SSPI */ +#define CURL_VERSION_CONV (1<<12) /* Character conversions supported */ +#define CURL_VERSION_CURLDEBUG (1<<13) /* Debug memory tracking supported */ +#define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */ +#define CURL_VERSION_NTLM_WB (1<<15) /* NTLM delegation to winbind helper + is supported */ +#define CURL_VERSION_HTTP2 (1<<16) /* HTTP2 support built-in */ +#define CURL_VERSION_GSSAPI (1<<17) /* Built against a GSS-API library */ +#define CURL_VERSION_KERBEROS5 (1<<18) /* Kerberos V5 auth is supported */ +#define CURL_VERSION_UNIX_SOCKETS (1<<19) /* Unix domain sockets support */ +#define CURL_VERSION_PSL (1<<20) /* Mozilla's Public Suffix List, used + for cookie domain verification */ +#define CURL_VERSION_HTTPS_PROXY (1<<21) /* HTTPS-proxy support built-in */ +#define CURL_VERSION_MULTI_SSL (1<<22) /* Multiple SSL backends available */ +#define CURL_VERSION_BROTLI (1<<23) /* Brotli features are present. */ +#define CURL_VERSION_ALTSVC (1<<24) /* Alt-Svc handling built-in */ +#define CURL_VERSION_HTTP3 (1<<25) /* HTTP3 support built-in */ +#define CURL_VERSION_ZSTD (1<<26) /* zstd features are present */ +#define CURL_VERSION_UNICODE (1<<27) /* Unicode support on Windows */ +#define CURL_VERSION_HSTS (1<<28) /* HSTS is supported */ +#define CURL_VERSION_GSASL (1<<29) /* libgsasl is supported */ +#define CURL_VERSION_THREADSAFE (1<<30) /* libcurl API is thread-safe */ + +/* + * NAME curl_version_info() + * + * DESCRIPTION + * + * This function returns a pointer to a static copy of the version info + * struct. See above. + */ +CURL_EXTERN curl_version_info_data *curl_version_info(CURLversion); + +/* + * NAME curl_easy_strerror() + * + * DESCRIPTION + * + * The curl_easy_strerror function may be used to turn a CURLcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +CURL_EXTERN const char *curl_easy_strerror(CURLcode); + +/* + * NAME curl_share_strerror() + * + * DESCRIPTION + * + * The curl_share_strerror function may be used to turn a CURLSHcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +CURL_EXTERN const char *curl_share_strerror(CURLSHcode); + +/* + * NAME curl_easy_pause() + * + * DESCRIPTION + * + * The curl_easy_pause function pauses or unpauses transfers. Select the new + * state by setting the bitmask, use the convenience defines below. + * + */ +CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask); + +#define CURLPAUSE_RECV (1 << 0) +#define CURLPAUSE_RECV_CONT (0) + +#define CURLPAUSE_SEND (1 << 2) +#define CURLPAUSE_SEND_CONT (0) + +#define CURLPAUSE_ALL (CURLPAUSE_RECV | CURLPAUSE_SEND) +#define CURLPAUSE_CONT (CURLPAUSE_RECV_CONT | CURLPAUSE_SEND_CONT) + +/* + * NAME curl_easy_ssls_import() + * + * DESCRIPTION + * + * The curl_easy_ssls_import function adds a previously exported SSL session + * to the SSL session cache of the easy handle (or the underlying share). + */ +CURL_EXTERN CURLcode curl_easy_ssls_import(CURL *handle, + const char *session_key, + const unsigned char *shmac, + size_t shmac_len, + const unsigned char *sdata, + size_t sdata_len); + +/* This is the curl_ssls_export_cb callback prototype. It + * is passed to curl_easy_ssls_export() to extract SSL sessions/tickets. */ +typedef CURLcode curl_ssls_export_cb(CURL *handle, + void *userptr, + const char *session_key, + const unsigned char *shmac, + size_t shmac_len, + const unsigned char *sdata, + size_t sdata_len, + curl_off_t valid_until, + int ietf_tls_id, + const char *alpn, + size_t earlydata_max); + +/* + * NAME curl_easy_ssls_export() + * + * DESCRIPTION + * + * The curl_easy_ssls_export function iterates over all SSL sessions stored + * in the easy handle (or underlying share) and invokes the passed + * callback. + * + */ +CURL_EXTERN CURLcode curl_easy_ssls_export(CURL *handle, + curl_ssls_export_cb *export_fn, + void *userptr); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +/* unfortunately, the easy.h and multi.h include files need options and info + stuff before they can be included! */ +#include "easy.h" /* nothing in curl is fun without the easy stuff */ +#include "multi.h" +#include "urlapi.h" +#include "options.h" +#include "header.h" +#include "websockets.h" +#include "mprintf.h" + +/* the typechecker does not work in C++ (yet) */ +#if ((defined(__GNUC__) && defined(__GNUC_MINOR__) && \ + ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ + (defined(__clang__) && __clang_major__ >= 14)) && \ + !defined(__cplusplus) && !defined(CURL_DISABLE_TYPECHECK) +#include "typecheck-gcc.h" +#else +#if defined(__STDC__) && (__STDC__ >= 1) +/* This preprocessor magic that replaces a call with the exact same call is + only done to make sure application authors pass exactly three arguments + to these functions. */ +#define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param) +#define curl_easy_getinfo(handle,info,arg) curl_easy_getinfo(handle,info,arg) +#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) +#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) +#endif /* __STDC__ >= 1 */ +#endif /* gcc >= 4.3 && !__cplusplus && !CURL_DISABLE_TYPECHECK */ + +#endif /* CURLINC_CURL_H */ diff --git a/illumos-x86_64/usr/include/curl/curlver.h b/illumos-x86_64/usr/include/curl/curlver.h new file mode 100644 index 00000000..d1608c9c --- /dev/null +++ b/illumos-x86_64/usr/include/curl/curlver.h @@ -0,0 +1,78 @@ +#ifndef CURLINC_CURLVER_H +#define CURLINC_CURLVER_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +/* This header file contains nothing but libcurl version info, generated by + a script at release-time. This was made its own header file in 7.11.2 */ + +/* This is the global package copyright */ +#define LIBCURL_COPYRIGHT "Daniel Stenberg, ." + +/* This is the version number of the libcurl package from which this header + file origins: */ +#define LIBCURL_VERSION "8.18.0" + +/* The numeric version number is also available "in parts" by using these + defines: */ +#define LIBCURL_VERSION_MAJOR 8 +#define LIBCURL_VERSION_MINOR 18 +#define LIBCURL_VERSION_PATCH 0 +/* This is the numeric version of the libcurl version number, meant for easier + parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will + always follow this syntax: + + 0xXXYYZZ + + Where XX, YY and ZZ are the main version, release and patch numbers in + hexadecimal (using 8 bits each). All three numbers are always represented + using two digits. 1.2 would appear as "0x010200" while version 9.11.7 + appears as "0x090b07". + + This 6-digit (24 bits) hexadecimal number does not show pre-release number, + and it is always a greater number in a more recent release. It makes + comparisons with greater than and less than work. + + Note: This define is the full hex number and _does not_ use the + CURL_VERSION_BITS() macro since curl's own configure script greps for it + and needs it to contain the full number. +*/ +#define LIBCURL_VERSION_NUM 0x081200 + +/* + * This is the date and time when the full source package was created. The + * timestamp is not stored in git, as the timestamp is properly set in the + * tarballs by the maketgz script. + * + * The format of the date follows this template: + * + * "2007-11-23" + */ +#define LIBCURL_TIMESTAMP "2026-01-07" + +#define CURL_VERSION_BITS(x, y, z) ((x) << 16 | (y) << 8 | (z)) +#define CURL_AT_LEAST_VERSION(x, y, z) \ + (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) + +#endif /* CURLINC_CURLVER_H */ diff --git a/illumos-x86_64/usr/include/curl/easy.h b/illumos-x86_64/usr/include/curl/easy.h new file mode 100644 index 00000000..5b3cdbd6 --- /dev/null +++ b/illumos-x86_64/usr/include/curl/easy.h @@ -0,0 +1,123 @@ +#ifndef CURLINC_EASY_H +#define CURLINC_EASY_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +/* Flag bits in the curl_blob struct: */ +#define CURL_BLOB_COPY 1 /* tell libcurl to copy the data */ +#define CURL_BLOB_NOCOPY 0 /* tell libcurl to NOT copy the data */ + +struct curl_blob { + void *data; + size_t len; + unsigned int flags; /* bit 0 is defined, the rest are reserved and should be + left zeroes */ +}; + +CURL_EXTERN CURL *curl_easy_init(void); +CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); +CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); +CURL_EXTERN void curl_easy_cleanup(CURL *curl); + +/* + * NAME curl_easy_getinfo() + * + * DESCRIPTION + * + * Request internal information from the curl session with this function. + * The third argument MUST be pointing to the specific type of the used option + * which is documented in each man page of the option. The data pointed to + * will be filled in accordingly and can be relied upon only if the function + * returns CURLE_OK. This function is intended to get used *AFTER* a performed + * transfer, all results from this function are undefined until the transfer + * is completed. + */ +CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); + +/* + * NAME curl_easy_duphandle() + * + * DESCRIPTION + * + * Creates a new curl session handle with the same options set for the handle + * passed in. Duplicating a handle could only be a matter of cloning data and + * options, internal state info and things like persistent connections cannot + * be transferred. It is useful in multi-threaded applications when you can run + * curl_easy_duphandle() for each new thread to avoid a series of identical + * curl_easy_setopt() invokes in every thread. + */ +CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl); + +/* + * NAME curl_easy_reset() + * + * DESCRIPTION + * + * Re-initializes a curl handle to the default values. This puts back the + * handle to the same state as it was in when it was just created. + * + * It does keep: live connections, the Session ID cache, the DNS cache and the + * cookies. + */ +CURL_EXTERN void curl_easy_reset(CURL *curl); + +/* + * NAME curl_easy_recv() + * + * DESCRIPTION + * + * Receives data from the connected socket. Use after successful + * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. + */ +CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, + size_t *n); + +/* + * NAME curl_easy_send() + * + * DESCRIPTION + * + * Sends data over the connected socket. Use after successful + * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. + */ +CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, + size_t buflen, size_t *n); + +/* + * NAME curl_easy_upkeep() + * + * DESCRIPTION + * + * Performs connection upkeep for the given session handle. + */ +CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif diff --git a/illumos-x86_64/usr/include/curl/header.h b/illumos-x86_64/usr/include/curl/header.h new file mode 100644 index 00000000..e7334b5a --- /dev/null +++ b/illumos-x86_64/usr/include/curl/header.h @@ -0,0 +1,74 @@ +#ifndef CURLINC_HEADER_H +#define CURLINC_HEADER_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct curl_header { + char *name; /* this might not use the same case */ + char *value; + size_t amount; /* number of headers using this name */ + size_t index; /* ... of this instance, 0 or higher */ + unsigned int origin; /* see bits below */ + void *anchor; /* handle privately used by libcurl */ +}; + +/* 'origin' bits */ +#define CURLH_HEADER (1 << 0) /* plain server header */ +#define CURLH_TRAILER (1 << 1) /* trailers */ +#define CURLH_CONNECT (1 << 2) /* CONNECT headers */ +#define CURLH_1XX (1 << 3) /* 1xx headers */ +#define CURLH_PSEUDO (1 << 4) /* pseudo headers */ + +typedef enum { + CURLHE_OK, + CURLHE_BADINDEX, /* header exists but not with this index */ + CURLHE_MISSING, /* no such header exists */ + CURLHE_NOHEADERS, /* no headers at all exist (yet) */ + CURLHE_NOREQUEST, /* no request with this number was used */ + CURLHE_OUT_OF_MEMORY, /* out of memory while processing */ + CURLHE_BAD_ARGUMENT, /* a function argument was not okay */ + CURLHE_NOT_BUILT_IN /* if API was disabled in the build */ +} CURLHcode; + +CURL_EXTERN CURLHcode curl_easy_header(CURL *easy, + const char *name, + size_t index, + unsigned int origin, + int request, + struct curl_header **hout); + +CURL_EXTERN struct curl_header *curl_easy_nextheader(CURL *easy, + unsigned int origin, + int request, + struct curl_header *prev); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif /* CURLINC_HEADER_H */ diff --git a/illumos-x86_64/usr/include/curl/mprintf.h b/illumos-x86_64/usr/include/curl/mprintf.h new file mode 100644 index 00000000..9272e748 --- /dev/null +++ b/illumos-x86_64/usr/include/curl/mprintf.h @@ -0,0 +1,85 @@ +#ifndef CURLINC_MPRINTF_H +#define CURLINC_MPRINTF_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#include +#include /* needed for FILE */ +#include "curl.h" /* for CURL_EXTERN */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CURL_TEMP_PRINTF +#if (defined(__GNUC__) || defined(__clang__) || \ + defined(__IAR_SYSTEMS_ICC__)) && \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(CURL_NO_FMT_CHECKS) +#if defined(__MINGW32__) && !defined(__clang__) +#ifdef __MINGW_PRINTF_FORMAT /* mingw-w64 3.0.0+. Needs stdio.h. */ +#define CURL_TEMP_PRINTF(fmt, arg) \ + __attribute__((format(__MINGW_PRINTF_FORMAT, fmt, arg))) +#else +#define CURL_TEMP_PRINTF(fmt, arg) +#endif +#else +#define CURL_TEMP_PRINTF(fmt, arg) \ + __attribute__((format(printf, fmt, arg))) +#endif +#else +#define CURL_TEMP_PRINTF(fmt, arg) +#endif +#endif + +CURL_EXTERN int curl_mprintf(const char *format, ...) + CURL_TEMP_PRINTF(1, 2); +CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...) + CURL_TEMP_PRINTF(2, 3); +CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...) + CURL_TEMP_PRINTF(2, 3); +CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, + const char *format, ...) + CURL_TEMP_PRINTF(3, 4); +CURL_EXTERN int curl_mvprintf(const char *format, va_list args) + CURL_TEMP_PRINTF(1, 0); +CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args) + CURL_TEMP_PRINTF(2, 0); +CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args) + CURL_TEMP_PRINTF(2, 0); +CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, + const char *format, va_list args) + CURL_TEMP_PRINTF(3, 0); +CURL_EXTERN char *curl_maprintf(const char *format, ...) + CURL_TEMP_PRINTF(1, 2); +CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args) + CURL_TEMP_PRINTF(1, 0); + +#undef CURL_TEMP_PRINTF + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif /* CURLINC_MPRINTF_H */ diff --git a/illumos-x86_64/usr/include/curl/multi.h b/illumos-x86_64/usr/include/curl/multi.h new file mode 100644 index 00000000..531c1a95 --- /dev/null +++ b/illumos-x86_64/usr/include/curl/multi.h @@ -0,0 +1,551 @@ +#ifndef CURLINC_MULTI_H +#define CURLINC_MULTI_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +/* + This is an "external" header file. Do not give away any internals here! + + GOALS + + o Enable a "pull" interface. The application that uses libcurl decides where + and when to ask libcurl to get/send data. + + o Enable multiple simultaneous transfers in the same thread without making it + complicated for the application. + + o Enable the application to select() on its own file descriptors and curl's + file descriptors simultaneous easily. + +*/ + +/* + * This header file should not really need to include "curl.h" since curl.h + * itself includes this file and we expect user applications to do #include + * without the need for especially including multi.h. + * + * For some reason we added this include here at one point, and rather than to + * break existing (wrongly written) libcurl applications, we leave it as-is + * but with this warning attached. + */ +#include "curl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void CURLM; + +typedef enum { + CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or + curl_multi_socket*() soon */ + CURLM_OK, + CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ + CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ + CURLM_OUT_OF_MEMORY, /* if you ever get this, you are in deep sh*t */ + CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ + CURLM_BAD_SOCKET, /* the passed in socket argument did not match */ + CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */ + CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was + attempted to get added - again */ + CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a + callback */ + CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */ + CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */ + CURLM_ABORTED_BY_CALLBACK, + CURLM_UNRECOVERABLE_POLL, + CURLM_LAST +} CURLMcode; + +/* just to make code nicer when using curl_multi_socket() you can now check + for CURLM_CALL_MULTI_SOCKET too in the same style it works for + curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ +#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM + +/* bitmask bits for CURLMOPT_PIPELINING */ +#define CURLPIPE_NOTHING 0L +#define CURLPIPE_HTTP1 1L +#define CURLPIPE_MULTIPLEX 2L + +typedef enum { + CURLMSG_NONE, /* first, not used */ + CURLMSG_DONE, /* This easy handle has completed. 'result' contains + the CURLcode of the transfer */ + CURLMSG_LAST /* last, not used */ +} CURLMSG; + +struct CURLMsg { + CURLMSG msg; /* what this message means */ + CURL *easy_handle; /* the handle it concerns */ + union { + void *whatever; /* message-specific data */ + CURLcode result; /* return code for transfer */ + } data; +}; +typedef struct CURLMsg CURLMsg; + +/* Based on poll(2) structure and values. + * We do not use pollfd and POLL* constants explicitly + * to cover platforms without poll(). */ +#define CURL_WAIT_POLLIN 0x0001 +#define CURL_WAIT_POLLPRI 0x0002 +#define CURL_WAIT_POLLOUT 0x0004 + +struct curl_waitfd { + curl_socket_t fd; + short events; + short revents; +}; + +/* + * Name: curl_multi_init() + * + * Desc: initialize multi-style curl usage + * + * Returns: a new CURLM handle to use in all 'curl_multi' functions. + */ +CURL_EXTERN CURLM *curl_multi_init(void); + +/* + * Name: curl_multi_add_handle() + * + * Desc: add a standard curl handle to the multi stack + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, + CURL *curl_handle); + +/* + * Name: curl_multi_remove_handle() + * + * Desc: removes a curl handle from the multi stack again + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, + CURL *curl_handle); + +/* + * Name: curl_multi_fdset() + * + * Desc: Ask curl for its fd_set sets. The app can use these to select() or + * poll() on. We want curl_multi_perform() called as soon as one of + * them are ready. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *exc_fd_set, + int *max_fd); + +/* + * Name: curl_multi_wait() + * + * Desc: Poll on all fds within a CURLM set as well as any + * additional fds passed to the function. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle, + struct curl_waitfd extra_fds[], + unsigned int extra_nfds, + int timeout_ms, + int *ret); + +/* + * Name: curl_multi_poll() + * + * Desc: Poll on all fds within a CURLM set as well as any + * additional fds passed to the function. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle, + struct curl_waitfd extra_fds[], + unsigned int extra_nfds, + int timeout_ms, + int *ret); + +/* + * Name: curl_multi_wakeup() + * + * Desc: wakes up a sleeping curl_multi_poll call. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle); + +/* + * Name: curl_multi_perform() + * + * Desc: When the app thinks there is data available for curl it calls this + * function to read/write whatever there is right now. This returns + * as soon as the reads and writes are done. This function does not + * require that there actually is data available for reading or that + * data can be written, it can be called just in case. It returns + * the number of handles that still transfer data in the second + * argument's integer-pointer. + * + * Returns: CURLMcode type, general multi error code. *NOTE* that this only + * returns errors etc regarding the whole multi stack. There might + * still have occurred problems on individual transfers even when + * this returns OK. + */ +CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, + int *running_handles); + +/* + * Name: curl_multi_cleanup() + * + * Desc: Cleans up and removes a whole multi stack. It does not free or + * touch any individual easy handles in any way. We need to define + * in what state those handles will be if this function is called + * in the middle of a transfer. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); + +/* + * Name: curl_multi_info_read() + * + * Desc: Ask the multi handle if there is any messages/informationals from + * the individual transfers. Messages include informationals such as + * error code from the transfer or just the fact that a transfer is + * completed. More details on these should be written down as well. + * + * Repeated calls to this function will return a new struct each + * time, until a special "end of msgs" struct is returned as a signal + * that there is no more to get at this point. + * + * The data the returned pointer points to will not survive calling + * curl_multi_cleanup(). + * + * The 'CURLMsg' struct is meant to be simple and only contain basic + * information. If more involved information is wanted, we will + * provide the particular "transfer handle" in that struct and that + * should/could/would be used in subsequent curl_easy_getinfo() calls + * (or similar). The point being that we must never expose complex + * structs to applications, as then we will undoubtably get backwards + * compatibility problems in the future. + * + * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out + * of structs. It also writes the number of messages left in the + * queue (after this read) in the integer the second argument points + * to. + */ +CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle, + int *msgs_in_queue); + +/* + * Name: curl_multi_strerror() + * + * Desc: The curl_multi_strerror function may be used to turn a CURLMcode + * value into the equivalent human readable error string. This is + * useful for printing meaningful error messages. + * + * Returns: A pointer to a null-terminated error message. + */ +CURL_EXTERN const char *curl_multi_strerror(CURLMcode); + +/* + * Name: curl_multi_socket() and + * curl_multi_socket_all() + * + * Desc: An alternative version of curl_multi_perform() that allows the + * application to pass in one of the file descriptors that have been + * detected to have "action" on them and let libcurl perform. + * See man page for details. + */ +#define CURL_POLL_NONE 0 +#define CURL_POLL_IN 1 +#define CURL_POLL_OUT 2 +#define CURL_POLL_INOUT 3 +#define CURL_POLL_REMOVE 4 + +#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD + +#define CURL_CSELECT_IN 0x01 +#define CURL_CSELECT_OUT 0x02 +#define CURL_CSELECT_ERR 0x04 + +typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */ + curl_socket_t s, /* socket */ + int what, /* see above */ + void *userp, /* private callback + pointer */ + void *socketp); /* private socket + pointer */ +/* + * Name: curl_multi_timer_callback + * + * Desc: Called by libcurl whenever the library detects a change in the + * maximum number of milliseconds the app is allowed to wait before + * curl_multi_socket() or curl_multi_perform() must be called + * (to allow libcurl's timed events to take place). + * + * Returns: The callback should return zero. + */ +typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */ + long timeout_ms, /* see above */ + void *userp); /* private callback + pointer */ + +CURL_EXTERN CURLMcode CURL_DEPRECATED(7.19.5, "Use curl_multi_socket_action()") +curl_multi_socket(CURLM *multi_handle, curl_socket_t s, int *running_handles); + +CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle, + curl_socket_t s, + int ev_bitmask, + int *running_handles); + +CURL_EXTERN CURLMcode CURL_DEPRECATED(7.19.5, "Use curl_multi_socket_action()") +curl_multi_socket_all(CURLM *multi_handle, int *running_handles); + +#ifndef CURL_ALLOW_OLD_MULTI_SOCKET +/* This macro below was added in 7.16.3 to push users who recompile to use + * the new curl_multi_socket_action() instead of the old curl_multi_socket() + */ +#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) +#endif + +/* + * Name: curl_multi_timeout() + * + * Desc: Returns the maximum number of milliseconds the app is allowed to + * wait before curl_multi_socket() or curl_multi_perform() must be + * called (to allow libcurl's timed events to take place). + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle, + long *milliseconds); + +typedef enum { + /* This is the socket callback function pointer */ + CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1), + + /* This is the argument passed to the socket callback */ + CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2), + + /* set to 1 to enable pipelining for this multi handle */ + CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3), + + /* This is the timer callback function pointer */ + CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4), + + /* This is the argument passed to the timer callback */ + CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5), + + /* maximum number of entries in the connection cache */ + CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6), + + /* maximum number of (pipelining) connections to one host */ + CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7), + + /* maximum number of requests in a pipeline */ + CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8), + + /* a connection with a content-length longer than this + will not be considered for pipelining */ + CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9), + + /* a connection with a chunk length longer than this + will not be considered for pipelining */ + CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10), + + /* a list of site names(+port) that are blocked from pipelining */ + CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11), + + /* a list of server types that are blocked from pipelining */ + CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12), + + /* maximum number of open connections in total */ + CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13), + + /* This is the server push callback function pointer */ + CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14), + + /* This is the argument passed to the server push callback */ + CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15), + + /* maximum number of concurrent streams to support on a connection */ + CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16), + + /* network has changed, adjust caches/connection reuse */ + CURLOPT(CURLMOPT_NETWORK_CHANGED, CURLOPTTYPE_LONG, 17), + + /* This is the notify callback function pointer */ + CURLOPT(CURLMOPT_NOTIFYFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 18), + + /* This is the argument passed to the notify callback */ + CURLOPT(CURLMOPT_NOTIFYDATA, CURLOPTTYPE_OBJECTPOINT, 19), + + CURLMOPT_LASTENTRY /* the last unused */ +} CURLMoption; + +/* Definition of bits for the CURLMOPT_NETWORK_CHANGED argument: */ + +/* - CURLMNWC_CLEAR_CONNS tells libcurl to prevent further reuse of existing + connections. Connections that are idle will be closed. Ongoing transfers + will continue with the connection they have. */ +#define CURLMNWC_CLEAR_CONNS (1L << 0) + +/* - CURLMNWC_CLEAR_DNS tells libcurl to prevent further reuse of existing + connections. Connections that are idle will be closed. Ongoing transfers + will continue with the connection they have. */ +#define CURLMNWC_CLEAR_DNS (1L << 0) + +/* + * Name: curl_multi_setopt() + * + * Desc: Sets options for the multi handle. + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, + CURLMoption option, ...); + +/* + * Name: curl_multi_assign() + * + * Desc: This function sets an association in the multi handle between the + * given socket and a private pointer of the application. This is + * (only) useful for curl_multi_socket uses. + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, + curl_socket_t sockfd, void *sockp); + +/* + * Name: curl_multi_get_handles() + * + * Desc: Returns an allocated array holding all handles currently added to + * the multi handle. Marks the final entry with a NULL pointer. If + * there is no easy handle added to the multi handle, this function + * returns an array with the first entry as a NULL pointer. + * + * Returns: NULL on failure, otherwise a CURL **array pointer + */ +CURL_EXTERN CURL **curl_multi_get_handles(CURLM *multi_handle); + +typedef enum { + CURLMINFO_NONE, /* first, never use this */ + /* The number of easy handles currently managed by the multi handle, + * e.g. have been added but not yet removed. */ + CURLMINFO_XFERS_CURRENT = 1, + /* The number of easy handles running, e.g. not done and not queueing. */ + CURLMINFO_XFERS_RUNNING = 2, + /* The number of easy handles waiting to start, e.g. for a connection + * to become available due to limits on parallelism, max connections + * or other factors. */ + CURLMINFO_XFERS_PENDING = 3, + /* The number of easy handles finished, waiting for their results to + * be read via `curl_multi_info_read()`. */ + CURLMINFO_XFERS_DONE = 4, + /* The total number of easy handles added to the multi handle, ever. */ + CURLMINFO_XFERS_ADDED = 5, + + CURLMINFO_LASTENTRY /* the last unused */ +} CURLMinfo_offt; + +/* + * Name: curl_multi_get_offt() + * + * Desc: Retrieves a numeric value for the `CURLMINFO_*` enums. + * + * Returns: CULRM_OK or error when value could not be obtained. + */ +CURL_EXTERN CURLMcode curl_multi_get_offt(CURLM *multi_handle, + CURLMinfo_offt info, + curl_off_t *pvalue); + +/* + * Name: curl_push_callback + * + * Desc: This callback gets called when a new stream is being pushed by the + * server. It approves or denies the new stream. It can also decide + * to completely fail the connection. + * + * Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT + */ +#define CURL_PUSH_OK 0 +#define CURL_PUSH_DENY 1 +#define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */ + +struct curl_pushheaders; /* forward declaration only */ + +CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h, + size_t num); +CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h, + const char *name); + +typedef int (*curl_push_callback)(CURL *parent, + CURL *easy, + size_t num_headers, + struct curl_pushheaders *headers, + void *userp); + +/* + * Name: curl_multi_waitfds() + * + * Desc: Ask curl for fds for polling. The app can use these to poll on. + * We want curl_multi_perform() called as soon as one of them are + * ready. Passing zero size allows to get just a number of fds. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_waitfds(CURLM *multi, + struct curl_waitfd *ufds, + unsigned int size, + unsigned int *fd_count); + +/* + * Notifications dispatched by a multi handle, when enabled. + */ +#define CURLMNOTIFY_INFO_READ 0 +#define CURLMNOTIFY_EASY_DONE 1 + +/* + * Callback to install via CURLMOPT_NOTIFYFUNCTION. + */ +typedef void (*curl_notify_callback)(CURLM *multi, + unsigned int notification, + CURL *easy, + void *user_data); + +CURL_EXTERN CURLMcode curl_multi_notify_disable(CURLM *multi, + unsigned int notification); + +CURL_EXTERN CURLMcode curl_multi_notify_enable(CURLM *multi, + unsigned int notification); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif diff --git a/illumos-x86_64/usr/include/curl/options.h b/illumos-x86_64/usr/include/curl/options.h new file mode 100644 index 00000000..835a722e --- /dev/null +++ b/illumos-x86_64/usr/include/curl/options.h @@ -0,0 +1,70 @@ +#ifndef CURLINC_OPTIONS_H +#define CURLINC_OPTIONS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + CURLOT_LONG, /* long (a range of values) */ + CURLOT_VALUES, /* (a defined set or bitmask) */ + CURLOT_OFF_T, /* curl_off_t (a range of values) */ + CURLOT_OBJECT, /* pointer (void *) */ + CURLOT_STRING, /* (char * to null-terminated buffer) */ + CURLOT_SLIST, /* (struct curl_slist *) */ + CURLOT_CBPTR, /* (void * passed as-is to a callback) */ + CURLOT_BLOB, /* blob (struct curl_blob *) */ + CURLOT_FUNCTION /* function pointer */ +} curl_easytype; + +/* Flag bits */ + +/* "alias" means it is provided for old programs to remain functional, + we prefer another name */ +#define CURLOT_FLAG_ALIAS (1 << 0) + +/* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size + to use for curl_easy_setopt() for the given id */ +struct curl_easyoption { + const char *name; + CURLoption id; + curl_easytype type; + unsigned int flags; +}; + +CURL_EXTERN const struct curl_easyoption * +curl_easy_option_by_name(const char *name); + +CURL_EXTERN const struct curl_easyoption * +curl_easy_option_by_id(CURLoption id); + +CURL_EXTERN const struct curl_easyoption * +curl_easy_option_next(const struct curl_easyoption *prev); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif +#endif /* CURLINC_OPTIONS_H */ diff --git a/illumos-x86_64/usr/include/curl/stdcheaders.h b/illumos-x86_64/usr/include/curl/stdcheaders.h new file mode 100644 index 00000000..7451aa30 --- /dev/null +++ b/illumos-x86_64/usr/include/curl/stdcheaders.h @@ -0,0 +1,35 @@ +#ifndef CURLINC_STDCHEADERS_H +#define CURLINC_STDCHEADERS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#include + +size_t fread(void *, size_t, size_t, FILE *); +size_t fwrite(const void *, size_t, size_t, FILE *); + +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); + +#endif /* CURLINC_STDCHEADERS_H */ diff --git a/illumos-x86_64/usr/include/curl/system.h b/illumos-x86_64/usr/include/curl/system.h new file mode 100644 index 00000000..a5b3e9eb --- /dev/null +++ b/illumos-x86_64/usr/include/curl/system.h @@ -0,0 +1,399 @@ +#ifndef CURLINC_SYSTEM_H +#define CURLINC_SYSTEM_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +/* + * Try to keep one section per platform, compiler and architecture, otherwise, + * if an existing section is reused for a different one and later on the + * original is adjusted, probably the piggybacking one can be adversely + * changed. + * + * In order to differentiate between platforms/compilers/architectures use + * only compiler built-in predefined preprocessor symbols. + * + * curl_off_t + * ---------- + * + * For any given platform/compiler curl_off_t MUST be typedef'ed to a 64-bit + * wide signed integral data type. The width of this data type must remain + * constant and independent of any possible large file support settings. + * + * As a general rule, curl_off_t shall not be mapped to off_t. This rule shall + * only be violated if off_t is the only 64-bit data type available and the + * size of off_t is independent of large file support settings. Keep your + * build on the safe side avoiding an off_t gating. If you have a 64-bit + * off_t then take for sure that another 64-bit data type exists, dig deeper + * and you will find it. + * + */ + +#ifdef __DJGPP__ +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__BORLANDC__) +# define CURL_TYPEOF_CURL_OFF_T __int64 +# define CURL_FORMAT_CURL_OFF_T "I64d" +# define CURL_FORMAT_CURL_OFF_TU "I64u" +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__POCC__) +# ifdef _MSC_VER +# define CURL_TYPEOF_CURL_OFF_T __int64 +# define CURL_FORMAT_CURL_OFF_T "I64d" +# define CURL_FORMAT_CURL_OFF_TU "I64u" +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# else +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__LCC__) +# ifdef __MCST__ /* MCST eLbrus Compiler Collection */ +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 +# else /* Local (or Little) C Compiler */ +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +# endif + +#elif defined(macintosh) +# include +# if TYPE_LONGLONG +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int + +#elif defined(__TANDEM) +# ifndef __LP64 +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int +# endif + +#elif defined(UNDER_CE) +# define CURL_TYPEOF_CURL_OFF_T __int64 +# define CURL_FORMAT_CURL_OFF_T "I64d" +# define CURL_FORMAT_CURL_OFF_TU "I64u" +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__MINGW32__) +# include +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T PRId64 +# define CURL_FORMAT_CURL_OFF_TU PRIu64 +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +# define CURL_PULL_SYS_TYPES_H 1 + +#elif defined(__VMS) +# ifdef __VAX +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# else +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int + +#elif defined(__OS400__) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__MVS__) +# ifdef _LONG_LONG +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else /* _LP64 and default */ +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__370__) +# if defined(__IBMC__) || defined(__IBMCPP__) +# ifdef _LONG_LONG +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else /* _LP64 and default */ +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 +# endif + +#elif defined(TPF) +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__TINYC__) /* also known as tcc */ +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */ +# if !defined(__LP64) && (defined(__ILP32) || \ + defined(__i386) || \ + defined(__sparcv8) || \ + defined(__sparcv8plus)) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# elif defined(__LP64) || \ + defined(__amd64) || defined(__sparcv9) +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__xlc__) /* IBM xlc compiler */ +# ifndef _LP64 +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__hpux) /* HP aCC compiler */ +# ifndef _LP64 +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +/* ===================================== */ +/* KEEP MSVC THE PENULTIMATE ENTRY */ +/* ===================================== */ + +#elif defined(_MSC_VER) +# if (_MSC_VER >= 1800) +# include +# define CURL_FORMAT_CURL_OFF_T PRId64 +# define CURL_FORMAT_CURL_OFF_TU PRIu64 +# else +# define CURL_FORMAT_CURL_OFF_T "I64d" +# define CURL_FORMAT_CURL_OFF_TU "I64u" +# endif +# define CURL_TYPEOF_CURL_OFF_T __int64 +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +/* ===================================== */ +/* KEEP GENERIC GCC THE LAST ENTRY */ +/* ===================================== */ + +#elif defined(__GNUC__) && !defined(_SCO_DS) +# if !defined(__LP64__) && \ + (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \ + defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \ + defined(__sparc__) || defined(__mips__) || defined(__sh__) || \ + defined(__XTENSA__) || \ + (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \ + (defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L)) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# if (__GNUC__ >= 4) || \ + ((__GNUC__ == 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 4)) +# define CURL_POPCOUNT64(x) __builtin_popcountll(x) +# define CURL_CTZ64(x) __builtin_ctzll(x) +# endif +# elif defined(__LP64__) || \ + defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \ + defined(__e2k__) || \ + (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \ + (defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L) +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# if (__GNUC__ >= 4) || \ + ((__GNUC__ == 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 4)) +# define CURL_POPCOUNT64(x) __builtin_popcountl(x) +# define CURL_CTZ64(x) __builtin_ctzl(x) +# endif +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#else +/* generic "safe guess" on old 32-bit style */ +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +#endif + +#ifdef _AIX +/* AIX needs */ +#define CURL_PULL_SYS_POLL_H +#endif + +/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */ +/* sys/types.h is required here to properly make type definitions below. */ +#ifdef CURL_PULL_SYS_TYPES_H +# include +#endif + +/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ +/* sys/socket.h is required here to properly make type definitions below. */ +#ifdef CURL_PULL_SYS_SOCKET_H +# include +#endif + +/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */ +/* sys/poll.h is required here to properly make type definitions below. */ +#ifdef CURL_PULL_SYS_POLL_H +# include +#endif + +/* Data type definition of curl_socklen_t. */ +#ifdef CURL_TYPEOF_CURL_SOCKLEN_T + typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; +#endif + +/* Data type definition of curl_off_t. */ + +#ifdef CURL_TYPEOF_CURL_OFF_T + typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; +#endif + +#endif /* CURLINC_SYSTEM_H */ diff --git a/illumos-x86_64/usr/include/curl/typecheck-gcc.h b/illumos-x86_64/usr/include/curl/typecheck-gcc.h new file mode 100644 index 00000000..0642afd9 --- /dev/null +++ b/illumos-x86_64/usr/include/curl/typecheck-gcc.h @@ -0,0 +1,957 @@ +#ifndef CURLINC_TYPECHECK_GCC_H +#define CURLINC_TYPECHECK_GCC_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +/* wraps curl_easy_setopt() with type checking */ + +/* To add a new kind of warning, add an + * if(curlcheck_sometype_option(_curl_opt)) + * if(!curlcheck_sometype(value)) + * Wcurl_easy_setopt_err_sometype(); + * block and define curlcheck_sometype_option, curlcheck_sometype and + * Wcurl_easy_setopt_err_sometype below + * + * NOTE: We use two nested 'if' statements here instead of the && operator, in + * order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x + * when compiling with -Wlogical-op. + * + * To add an option that uses the same type as an existing option, you will + * just need to extend the appropriate _curl_*_option macro + */ + +#define curl_easy_setopt(handle, option, value) \ + __extension__({ \ + if(__builtin_constant_p(option)) { \ + CURL_IGNORE_DEPRECATION( \ + if(curlcheck_long_option(option)) \ + if(!curlcheck_long(value)) \ + Wcurl_easy_setopt_err_long(); \ + if(curlcheck_off_t_option(option)) \ + if(!curlcheck_off_t(value)) \ + Wcurl_easy_setopt_err_curl_off_t(); \ + if(curlcheck_string_option(option)) \ + if(!curlcheck_string(value)) \ + Wcurl_easy_setopt_err_string(); \ + if((option) == CURLOPT_PRIVATE) { } \ + if(curlcheck_write_cb_option(option)) \ + if(!curlcheck_write_cb(value)) \ + Wcurl_easy_setopt_err_write_callback(); \ + if(curlcheck_curl_option(option)) \ + if(!curlcheck_curl(value)) \ + Wcurl_easy_setopt_err_curl(); \ + if((option) == CURLOPT_RESOLVER_START_FUNCTION) \ + if(!curlcheck_resolver_start_callback(value)) \ + Wcurl_easy_setopt_err_resolver_start_callback(); \ + if((option) == CURLOPT_READFUNCTION) \ + if(!curlcheck_read_cb(value)) \ + Wcurl_easy_setopt_err_read_cb(); \ + if((option) == CURLOPT_IOCTLFUNCTION) \ + if(!curlcheck_ioctl_cb(value)) \ + Wcurl_easy_setopt_err_ioctl_cb(); \ + if((option) == CURLOPT_SOCKOPTFUNCTION) \ + if(!curlcheck_sockopt_cb(value)) \ + Wcurl_easy_setopt_err_sockopt_cb(); \ + if((option) == CURLOPT_OPENSOCKETFUNCTION) \ + if(!curlcheck_opensocket_cb(value)) \ + Wcurl_easy_setopt_err_opensocket_cb(); \ + if((option) == CURLOPT_PROGRESSFUNCTION) \ + if(!curlcheck_progress_cb(value)) \ + Wcurl_easy_setopt_err_progress_cb(); \ + if((option) == CURLOPT_XFERINFOFUNCTION) \ + if(!curlcheck_xferinfo_cb(value)) \ + Wcurl_easy_setopt_err_xferinfo_cb(); \ + if((option) == CURLOPT_DEBUGFUNCTION) \ + if(!curlcheck_debug_cb(value)) \ + Wcurl_easy_setopt_err_debug_cb(); \ + if((option) == CURLOPT_SSL_CTX_FUNCTION) \ + if(!curlcheck_ssl_ctx_cb(value)) \ + Wcurl_easy_setopt_err_ssl_ctx_cb(); \ + if(curlcheck_conv_cb_option(option)) \ + if(!curlcheck_conv_cb(value)) \ + Wcurl_easy_setopt_err_conv_cb(); \ + if((option) == CURLOPT_SEEKFUNCTION) \ + if(!curlcheck_seek_cb(value)) \ + Wcurl_easy_setopt_err_seek_cb(); \ + if((option) == CURLOPT_CHUNK_BGN_FUNCTION) \ + if(!curlcheck_chunk_bgn_cb(value)) \ + Wcurl_easy_setopt_err_chunk_bgn_cb(); \ + if((option) == CURLOPT_CHUNK_END_FUNCTION) \ + if(!curlcheck_chunk_end_cb(value)) \ + Wcurl_easy_setopt_err_chunk_end_cb(); \ + if((option) == CURLOPT_CLOSESOCKETFUNCTION) \ + if(!curlcheck_close_socket_cb(value)) \ + Wcurl_easy_setopt_err_close_socket_cb(); \ + if((option) == CURLOPT_FNMATCH_FUNCTION) \ + if(!curlcheck_fnmatch_cb(value)) \ + Wcurl_easy_setopt_err_fnmatch_cb(); \ + if((option) == CURLOPT_HSTSREADFUNCTION) \ + if(!curlcheck_hstsread_cb(value)) \ + Wcurl_easy_setopt_err_hstsread_cb(); \ + if((option) == CURLOPT_HSTSWRITEFUNCTION) \ + if(!curlcheck_hstswrite_cb(value)) \ + Wcurl_easy_setopt_err_hstswrite_cb(); \ + if((option) == CURLOPT_SSH_HOSTKEYFUNCTION) \ + if(!curlcheck_ssh_hostkey_cb(value)) \ + Wcurl_easy_setopt_err_ssh_hostkey_cb(); \ + if((option) == CURLOPT_SSH_KEYFUNCTION) \ + if(!curlcheck_ssh_key_cb(value)) \ + Wcurl_easy_setopt_err_ssh_key_cb(); \ + if((option) == CURLOPT_INTERLEAVEFUNCTION) \ + if(!curlcheck_interleave_cb(value)) \ + Wcurl_easy_setopt_err_interleave_cb(); \ + if((option) == CURLOPT_PREREQFUNCTION) \ + if(!curlcheck_prereq_cb(value)) \ + Wcurl_easy_setopt_err_prereq_cb(); \ + if((option) == CURLOPT_TRAILERFUNCTION) \ + if(!curlcheck_trailer_cb(value)) \ + Wcurl_easy_setopt_err_trailer_cb(); \ + if(curlcheck_cb_data_option(option)) \ + if(!curlcheck_cb_data(value)) \ + Wcurl_easy_setopt_err_cb_data(); \ + if((option) == CURLOPT_ERRORBUFFER) \ + if(!curlcheck_error_buffer(value)) \ + Wcurl_easy_setopt_err_error_buffer(); \ + if((option) == CURLOPT_CURLU) \ + if(!curlcheck_ptr((value), CURLU)) \ + Wcurl_easy_setopt_err_curlu(); \ + if((option) == CURLOPT_STDERR) \ + if(!curlcheck_FILE(value)) \ + Wcurl_easy_setopt_err_FILE(); \ + if(curlcheck_postfields_option(option)) \ + if(!curlcheck_postfields(value)) \ + Wcurl_easy_setopt_err_postfields(); \ + if((option) == CURLOPT_HTTPPOST) \ + if(!curlcheck_arr((value), struct curl_httppost)) \ + Wcurl_easy_setopt_err_curl_httpost(); \ + if((option) == CURLOPT_MIMEPOST) \ + if(!curlcheck_ptr((value), curl_mime)) \ + Wcurl_easy_setopt_err_curl_mimepost(); \ + if(curlcheck_slist_option(option)) \ + if(!curlcheck_arr((value), struct curl_slist)) \ + Wcurl_easy_setopt_err_curl_slist(); \ + if((option) == CURLOPT_SHARE) \ + if(!curlcheck_ptr((value), CURLSH)) \ + Wcurl_easy_setopt_err_CURLSH(); \ + ) \ + } \ + curl_easy_setopt(handle, option, value); \ + }) + +/* wraps curl_easy_getinfo() with type checking */ +#define curl_easy_getinfo(handle, info, arg) \ + __extension__({ \ + if(__builtin_constant_p(info)) { \ + CURL_IGNORE_DEPRECATION( \ + if(curlcheck_string_info(info)) \ + if(!curlcheck_arr((arg), char *)) \ + Wcurl_easy_getinfo_err_string(); \ + if(curlcheck_long_info(info)) \ + if(!curlcheck_arr((arg), long)) \ + Wcurl_easy_getinfo_err_long(); \ + if(curlcheck_double_info(info)) \ + if(!curlcheck_arr((arg), double)) \ + Wcurl_easy_getinfo_err_double(); \ + if(curlcheck_slist_info(info)) \ + if(!curlcheck_arr((arg), struct curl_slist *)) \ + Wcurl_easy_getinfo_err_curl_slist(); \ + if(curlcheck_tlssessioninfo_info(info)) \ + if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \ + Wcurl_easy_getinfo_err_curl_tlssessioninfo(); \ + if(curlcheck_certinfo_info(info)) \ + if(!curlcheck_arr((arg), struct curl_certinfo *)) \ + Wcurl_easy_getinfo_err_curl_certinfo(); \ + if(curlcheck_socket_info(info)) \ + if(!curlcheck_arr((arg), curl_socket_t)) \ + Wcurl_easy_getinfo_err_curl_socket(); \ + if(curlcheck_off_t_info(info)) \ + if(!curlcheck_arr((arg), curl_off_t)) \ + Wcurl_easy_getinfo_err_curl_off_t(); \ + ) \ + } \ + curl_easy_getinfo(handle, info, arg); \ + }) + +#define curl_multi_setopt(handle, option, value) \ + __extension__({ \ + if(__builtin_constant_p(option)) { \ + if(curlcheck_long_option(option)) \ + if(!curlcheck_long(value)) \ + Wcurl_multi_setopt_err_long(); \ + if(curlcheck_off_t_option(option)) \ + if(!curlcheck_off_t(value)) \ + Wcurl_multi_setopt_err_curl_off_t(); \ + if(curlcheck_multicb_data_option(option)) \ + if(!curlcheck_cb_data(value)) \ + Wcurl_multi_setopt_err_cb_data(); \ + if(curlcheck_charpp_option(option)) \ + if(!curlcheck_ptrptr(value, char)) \ + Wcurl_multi_setopt_err_charpp(); \ + if((option) == CURLMOPT_NOTIFYFUNCTION) \ + if(!curlcheck_multinotify_cb(value)) \ + Wcurl_multi_setopt_err_notifycb(); \ + if((option) == CURLMOPT_PUSHFUNCTION) \ + if(!curlcheck_multipush_cb(value)) \ + Wcurl_multi_setopt_err_pushcb(); \ + if((option) == CURLMOPT_SOCKETFUNCTION) \ + if(!curlcheck_multisocket_cb(value)) \ + Wcurl_multi_setopt_err_socketcb(); \ + if((option) == CURLMOPT_TIMERFUNCTION) \ + if(!curlcheck_multitimer_cb(value)) \ + Wcurl_multi_setopt_err_timercb(); \ + } \ + curl_multi_setopt(handle, option, value); \ + }) + +/* evaluates to true if the option takes a data argument to pass to a + callback */ +#define curlcheck_multicb_data_option(option) \ + ((option) == CURLMOPT_NOTIFYDATA || \ + (option) == CURLMOPT_PUSHDATA || \ + (option) == CURLMOPT_SOCKETDATA || \ + (option) == CURLMOPT_TIMERDATA || \ + 0) + +/* evaluates to true if the option takes a char ** argument */ +#define curlcheck_charpp_option(option) \ + ((option) == CURLMOPT_PIPELINING_SERVER_BL || \ + (option) == CURLMOPT_PIPELINING_SITE_BL || \ + 0) + +/* evaluates to true if expr is of type curl_multi_timer_callback */ +#define curlcheck_multitimer_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_multi_timer_callback)) + +/* evaluates to true if expr is of type curl_socket_callback */ +#define curlcheck_multisocket_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_socket_callback)) + +/* evaluates to true if expr is of type curl_push_callback */ +#define curlcheck_multipush_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_push_callback)) + +/* evaluates to true if expr is of type curl_push_callback */ +#define curlcheck_multinotify_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_notify_callback)) + +/* + * For now, just make sure that the functions are called with three arguments + */ +#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) + +/* the actual warnings, triggered by calling the Wcurl_easy_setopt_err* + * functions */ + +/* To define a new warning, use _CURL_WARNING(identifier, "message") */ +#define CURLWARNING(id, message) \ + static void __attribute__((__warning__(message))) \ + __attribute__((__unused__)) __attribute__((__noinline__)) \ + id(void) { __asm__(""); } + +CURLWARNING(Wcurl_multi_setopt_err_long, + "curl_multi_setopt expects a long argument") +CURLWARNING(Wcurl_multi_setopt_err_curl_off_t, + "curl_multi_setopt expects a curl_off_t argument") +CURLWARNING(Wcurl_multi_setopt_err_cb_data, + "curl_multi_setopt expects a 'void *' argument") +CURLWARNING(Wcurl_multi_setopt_err_charpp, + "curl_multi_setopt expects a 'char **' argument") +CURLWARNING(Wcurl_multi_setopt_err_pushcb, + "curl_multi_setopt expects a curl_push_callback argument") +CURLWARNING(Wcurl_multi_setopt_err_notifycb, + "curl_multi_setopt expects a curl_notify_callback argument") +CURLWARNING(Wcurl_multi_setopt_err_socketcb, + "curl_multi_setopt expects a curl_socket_callback argument") +CURLWARNING(Wcurl_multi_setopt_err_timercb, + "curl_multi_setopt expects a curl_multi_timer_callback argument") + +CURLWARNING(Wcurl_easy_setopt_err_long, + "curl_easy_setopt expects a long argument") +CURLWARNING(Wcurl_easy_setopt_err_curl_off_t, + "curl_easy_setopt expects a curl_off_t argument") +CURLWARNING(Wcurl_easy_setopt_err_string, + "curl_easy_setopt expects a " + "string ('char *' or char[]) argument") +CURLWARNING(Wcurl_easy_setopt_err_write_callback, + "curl_easy_setopt expects a curl_write_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_resolver_start_callback, + "curl_easy_setopt expects a " + "curl_resolver_start_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_read_cb, + "curl_easy_setopt expects a curl_read_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_ioctl_cb, + "curl_easy_setopt expects a curl_ioctl_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_sockopt_cb, + "curl_easy_setopt expects a curl_sockopt_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_opensocket_cb, + "curl_easy_setopt expects a " + "curl_opensocket_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_progress_cb, + "curl_easy_setopt expects a curl_progress_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_xferinfo_cb, + "curl_easy_setopt expects a curl_xferinfo_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_debug_cb, + "curl_easy_setopt expects a curl_debug_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_ssl_ctx_cb, + "curl_easy_setopt expects a curl_ssl_ctx_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_conv_cb, + "curl_easy_setopt expects a curl_conv_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_seek_cb, + "curl_easy_setopt expects a curl_seek_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_cb_data, + "curl_easy_setopt expects a " + "private data pointer as argument") +CURLWARNING(Wcurl_easy_setopt_err_chunk_bgn_cb, + "curl_easy_setopt expects a curl_chunk_bgn_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_chunk_end_cb, + "curl_easy_setopt expects a curl_chunk_end_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_close_socket_cb, + "curl_easy_setopt expects a curl_closesocket_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_fnmatch_cb, + "curl_easy_setopt expects a curl_fnmatch_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_hstsread_cb, + "curl_easy_setopt expects a curl_hstsread_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_hstswrite_cb, + "curl_easy_setopt expects a curl_hstswrite_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_ssh_key_cb, + "curl_easy_setopt expects a curl_sshkeycallback argument") +CURLWARNING(Wcurl_easy_setopt_err_ssh_hostkey_cb, + "curl_easy_setopt expects a curl_sshhostkeycallback argument") +CURLWARNING(Wcurl_easy_setopt_err_interleave_cb, + "curl_easy_setopt expects a curl_interleave_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_prereq_cb, + "curl_easy_setopt expects a curl_prereq_callback argument") +CURLWARNING(Wcurl_easy_setopt_err_trailer_cb, + "curl_easy_setopt expects a curl_trailerfunc_ok argument") +CURLWARNING(Wcurl_easy_setopt_err_error_buffer, + "curl_easy_setopt expects a " + "char buffer of CURL_ERROR_SIZE as argument") +CURLWARNING(Wcurl_easy_setopt_err_curlu, + "curl_easy_setopt expects a 'CURLU *' argument") +CURLWARNING(Wcurl_easy_setopt_err_curl, + "curl_easy_setopt expects a 'CURL *' argument") +CURLWARNING(Wcurl_easy_setopt_err_FILE, + "curl_easy_setopt expects a 'FILE *' argument") +CURLWARNING(Wcurl_easy_setopt_err_postfields, + "curl_easy_setopt expects a 'void *' or 'char *' argument") +CURLWARNING(Wcurl_easy_setopt_err_curl_httpost, + "curl_easy_setopt expects a 'struct curl_httppost *' " + "argument") +CURLWARNING(Wcurl_easy_setopt_err_curl_mimepost, + "curl_easy_setopt expects a 'curl_mime *' " + "argument") +CURLWARNING(Wcurl_easy_setopt_err_curl_slist, + "curl_easy_setopt expects a 'struct curl_slist *' argument") +CURLWARNING(Wcurl_easy_setopt_err_CURLSH, + "curl_easy_setopt expects a CURLSH* argument") +CURLWARNING(Wcurl_easy_getinfo_err_string, + "curl_easy_getinfo expects a pointer to 'char *'") +CURLWARNING(Wcurl_easy_getinfo_err_long, + "curl_easy_getinfo expects a pointer to long") +CURLWARNING(Wcurl_easy_getinfo_err_double, + "curl_easy_getinfo expects a pointer to double") +CURLWARNING(Wcurl_easy_getinfo_err_curl_slist, + "curl_easy_getinfo expects a pointer to 'struct curl_slist *'") +CURLWARNING(Wcurl_easy_getinfo_err_curl_tlssessioninfo, + "curl_easy_getinfo expects a pointer to " + "'struct curl_tlssessioninfo *'") +CURLWARNING(Wcurl_easy_getinfo_err_curl_certinfo, + "curl_easy_getinfo expects a pointer to " + "'struct curl_certinfo *'") +CURLWARNING(Wcurl_easy_getinfo_err_curl_socket, + "curl_easy_getinfo expects a pointer to curl_socket_t") +CURLWARNING(Wcurl_easy_getinfo_err_curl_off_t, + "curl_easy_getinfo expects a pointer to curl_off_t") + +/* groups of curl_easy_setops options that take the same type of argument */ + +/* evaluates to true if option takes a long argument */ +#define curlcheck_long_option(option) \ + (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT) + +#define curlcheck_off_t_option(option) \ + (((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB)) + +/* option takes a CURL * argument */ +#define curlcheck_curl_option(option) \ + ((option) == CURLOPT_STREAM_DEPENDS || \ + (option) == CURLOPT_STREAM_DEPENDS_E || \ + 0) + +/* evaluates to true if option takes a char* argument */ +#define curlcheck_string_option(option) \ + ((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \ + (option) == CURLOPT_ACCEPT_ENCODING || \ + (option) == CURLOPT_ALTSVC || \ + (option) == CURLOPT_CAINFO || \ + (option) == CURLOPT_CAPATH || \ + (option) == CURLOPT_COOKIE || \ + (option) == CURLOPT_COOKIEFILE || \ + (option) == CURLOPT_COOKIEJAR || \ + (option) == CURLOPT_COOKIELIST || \ + (option) == CURLOPT_CRLFILE || \ + (option) == CURLOPT_CUSTOMREQUEST || \ + (option) == CURLOPT_DEFAULT_PROTOCOL || \ + (option) == CURLOPT_DNS_INTERFACE || \ + (option) == CURLOPT_DNS_LOCAL_IP4 || \ + (option) == CURLOPT_DNS_LOCAL_IP6 || \ + (option) == CURLOPT_DNS_SERVERS || \ + (option) == CURLOPT_DOH_URL || \ + (option) == CURLOPT_ECH || \ + (option) == CURLOPT_EGDSOCKET || \ + (option) == CURLOPT_FTP_ACCOUNT || \ + (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \ + (option) == CURLOPT_FTPPORT || \ + (option) == CURLOPT_HAPROXY_CLIENT_IP || \ + (option) == CURLOPT_HSTS || \ + (option) == CURLOPT_INTERFACE || \ + (option) == CURLOPT_ISSUERCERT || \ + (option) == CURLOPT_KEYPASSWD || \ + (option) == CURLOPT_KRBLEVEL || \ + (option) == CURLOPT_LOGIN_OPTIONS || \ + (option) == CURLOPT_MAIL_AUTH || \ + (option) == CURLOPT_MAIL_FROM || \ + (option) == CURLOPT_NETRC_FILE || \ + (option) == CURLOPT_NOPROXY || \ + (option) == CURLOPT_PASSWORD || \ + (option) == CURLOPT_PINNEDPUBLICKEY || \ + (option) == CURLOPT_PRE_PROXY || \ + (option) == CURLOPT_PROTOCOLS_STR || \ + (option) == CURLOPT_PROXY || \ + (option) == CURLOPT_PROXY_CAINFO || \ + (option) == CURLOPT_PROXY_CAPATH || \ + (option) == CURLOPT_PROXY_CRLFILE || \ + (option) == CURLOPT_PROXY_ISSUERCERT || \ + (option) == CURLOPT_PROXY_KEYPASSWD || \ + (option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \ + (option) == CURLOPT_PROXY_SERVICE_NAME || \ + (option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \ + (option) == CURLOPT_PROXY_SSLCERT || \ + (option) == CURLOPT_PROXY_SSLCERTTYPE || \ + (option) == CURLOPT_PROXY_SSLKEY || \ + (option) == CURLOPT_PROXY_SSLKEYTYPE || \ + (option) == CURLOPT_PROXY_TLS13_CIPHERS || \ + (option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \ + (option) == CURLOPT_PROXY_TLSAUTH_TYPE || \ + (option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \ + (option) == CURLOPT_PROXYPASSWORD || \ + (option) == CURLOPT_PROXYUSERNAME || \ + (option) == CURLOPT_PROXYUSERPWD || \ + (option) == CURLOPT_RANDOM_FILE || \ + (option) == CURLOPT_RANGE || \ + (option) == CURLOPT_REDIR_PROTOCOLS_STR || \ + (option) == CURLOPT_REFERER || \ + (option) == CURLOPT_REQUEST_TARGET || \ + (option) == CURLOPT_RTSP_SESSION_ID || \ + (option) == CURLOPT_RTSP_STREAM_URI || \ + (option) == CURLOPT_RTSP_TRANSPORT || \ + (option) == CURLOPT_SASL_AUTHZID || \ + (option) == CURLOPT_SERVICE_NAME || \ + (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ + (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \ + (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 || \ + (option) == CURLOPT_SSH_KNOWNHOSTS || \ + (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \ + (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \ + (option) == CURLOPT_SSLCERT || \ + (option) == CURLOPT_SSLCERTTYPE || \ + (option) == CURLOPT_SSLENGINE || \ + (option) == CURLOPT_SSLKEY || \ + (option) == CURLOPT_SSLKEYTYPE || \ + (option) == CURLOPT_SSL_CIPHER_LIST || \ + (option) == CURLOPT_SSL_EC_CURVES || \ + (option) == CURLOPT_SSL_SIGNATURE_ALGORITHMS || \ + (option) == CURLOPT_TLS13_CIPHERS || \ + (option) == CURLOPT_TLSAUTH_PASSWORD || \ + (option) == CURLOPT_TLSAUTH_TYPE || \ + (option) == CURLOPT_TLSAUTH_USERNAME || \ + (option) == CURLOPT_UNIX_SOCKET_PATH || \ + (option) == CURLOPT_URL || \ + (option) == CURLOPT_USERAGENT || \ + (option) == CURLOPT_USERNAME || \ + (option) == CURLOPT_AWS_SIGV4 || \ + (option) == CURLOPT_USERPWD || \ + (option) == CURLOPT_XOAUTH2_BEARER || \ + 0) + +/* evaluates to true if option takes a curl_write_callback argument */ +#define curlcheck_write_cb_option(option) \ + ((option) == CURLOPT_HEADERFUNCTION || \ + (option) == CURLOPT_WRITEFUNCTION) + +/* evaluates to true if option takes a curl_conv_callback argument */ +#define curlcheck_conv_cb_option(option) \ + ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \ + (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \ + (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION) + +/* evaluates to true if option takes a data argument to pass to a callback */ +#define curlcheck_cb_data_option(option) \ + ((option) == CURLOPT_CHUNK_DATA || \ + (option) == CURLOPT_CLOSESOCKETDATA || \ + (option) == CURLOPT_DEBUGDATA || \ + (option) == CURLOPT_FNMATCH_DATA || \ + (option) == CURLOPT_HEADERDATA || \ + (option) == CURLOPT_HSTSREADDATA || \ + (option) == CURLOPT_HSTSWRITEDATA || \ + (option) == CURLOPT_INTERLEAVEDATA || \ + (option) == CURLOPT_IOCTLDATA || \ + (option) == CURLOPT_OPENSOCKETDATA || \ + (option) == CURLOPT_PREREQDATA || \ + (option) == CURLOPT_XFERINFODATA || \ + (option) == CURLOPT_READDATA || \ + (option) == CURLOPT_SEEKDATA || \ + (option) == CURLOPT_SOCKOPTDATA || \ + (option) == CURLOPT_SSH_KEYDATA || \ + (option) == CURLOPT_SSL_CTX_DATA || \ + (option) == CURLOPT_WRITEDATA || \ + (option) == CURLOPT_RESOLVER_START_DATA || \ + (option) == CURLOPT_TRAILERDATA || \ + (option) == CURLOPT_SSH_HOSTKEYDATA || \ + 0) + +/* evaluates to true if option takes a POST data argument (void* or char*) */ +#define curlcheck_postfields_option(option) \ + ((option) == CURLOPT_POSTFIELDS || \ + (option) == CURLOPT_COPYPOSTFIELDS || \ + 0) + +/* evaluates to true if option takes a struct curl_slist * argument */ +#define curlcheck_slist_option(option) \ + ((option) == CURLOPT_HTTP200ALIASES || \ + (option) == CURLOPT_HTTPHEADER || \ + (option) == CURLOPT_MAIL_RCPT || \ + (option) == CURLOPT_POSTQUOTE || \ + (option) == CURLOPT_PREQUOTE || \ + (option) == CURLOPT_PROXYHEADER || \ + (option) == CURLOPT_QUOTE || \ + (option) == CURLOPT_RESOLVE || \ + (option) == CURLOPT_TELNETOPTIONS || \ + (option) == CURLOPT_CONNECT_TO || \ + 0) + +/* groups of curl_easy_getinfo infos that take the same type of argument */ + +/* evaluates to true if info expects a pointer to char * argument */ +#define curlcheck_string_info(info) \ + (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \ + (info) != CURLINFO_PRIVATE) + +/* evaluates to true if info expects a pointer to long argument */ +#define curlcheck_long_info(info) \ + (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE) + +/* evaluates to true if info expects a pointer to double argument */ +#define curlcheck_double_info(info) \ + (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST) + +/* true if info expects a pointer to struct curl_slist * argument */ +#define curlcheck_slist_info(info) \ + (((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST)) + +/* true if info expects a pointer to struct curl_tlssessioninfo * argument */ +#define curlcheck_tlssessioninfo_info(info) \ + (((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION)) + +/* true if info expects a pointer to struct curl_certinfo * argument */ +#define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO) + +/* true if info expects a pointer to struct curl_socket_t argument */ +#define curlcheck_socket_info(info) \ + (CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T) + +/* true if info expects a pointer to curl_off_t argument */ +#define curlcheck_off_t_info(info) \ + (CURLINFO_OFF_T < (info)) + +/* + * typecheck helpers -- check whether given expression has requested type + */ + +/* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros, + * otherwise define a new macro. Search for __builtin_types_compatible_p + * in the GCC manual. + * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is + * the actual expression passed to the curl_easy_setopt macro. This + * means that you can only apply the sizeof and __typeof__ operators, no + * == or whatsoever. + */ + +/* XXX: should evaluate to true if expr is a pointer */ +#define curlcheck_any_ptr(expr) \ + (sizeof(expr) == sizeof(void *)) + +/* evaluates to true if expr is NULL */ +/* XXX: must not evaluate expr, so this check is not accurate */ +#define curlcheck_NULL(expr) \ + (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL))) + +/* evaluates to true if expr is type*, const type* or NULL */ +#define curlcheck_ptr(expr, type) \ + (curlcheck_NULL(expr) || \ + __builtin_types_compatible_p(__typeof__(expr), type *) || \ + __builtin_types_compatible_p(__typeof__(expr), const type *)) + +/* evaluates to true if expr is type**, const type** or NULL */ +#define curlcheck_ptrptr(expr, type) \ + (curlcheck_NULL(expr) || \ + __builtin_types_compatible_p(__typeof__(expr), type **) || \ + __builtin_types_compatible_p(__typeof__(expr), type *[]) || \ + __builtin_types_compatible_p(__typeof__(expr), const type *[]) || \ + __builtin_types_compatible_p(__typeof__(expr), const type **)) + +/* evaluates to true if expr is one of type[], type*, NULL or const type* */ +#define curlcheck_arr(expr, type) \ + (curlcheck_ptr((expr), type) || \ + __builtin_types_compatible_p(__typeof__(expr), type [])) + +/* evaluates to true if expr is a string */ +#define curlcheck_string(expr) \ + (curlcheck_arr((expr), char) || \ + curlcheck_arr((expr), signed char) || \ + curlcheck_arr((expr), unsigned char)) + +/* evaluates to true if expr is a CURL * */ +#define curlcheck_curl(expr) \ + (curlcheck_NULL(expr) || \ + __builtin_types_compatible_p(__typeof__(expr), CURL *)) + +/* evaluates to true if expr is a long (no matter the signedness) + * XXX: for now, int is also accepted (and therefore short and char, which + * are promoted to int when passed to a variadic function) */ +#define curlcheck_long(expr) \ + ( \ + ((sizeof(long) != sizeof(int)) && \ + (__builtin_types_compatible_p(__typeof__(expr), long) || \ + __builtin_types_compatible_p(__typeof__(expr), signed long) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned long))) \ + || \ + ((sizeof(long) == sizeof(int)) && \ + (__builtin_types_compatible_p(__typeof__(expr), long) || \ + __builtin_types_compatible_p(__typeof__(expr), signed long) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \ + __builtin_types_compatible_p(__typeof__(expr), int) || \ + __builtin_types_compatible_p(__typeof__(expr), signed int) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \ + __builtin_types_compatible_p(__typeof__(expr), short) || \ + __builtin_types_compatible_p(__typeof__(expr), signed short) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \ + __builtin_types_compatible_p(__typeof__(expr), char) || \ + __builtin_types_compatible_p(__typeof__(expr), signed char) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned char))) \ + ) + +/* evaluates to true if expr is of type curl_off_t */ +#define curlcheck_off_t(expr) \ + (__builtin_types_compatible_p(__typeof__(expr), curl_off_t)) + +/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */ +/* XXX: also check size of an char[] array? */ +#define curlcheck_error_buffer(expr) \ + (curlcheck_NULL(expr) || \ + __builtin_types_compatible_p(__typeof__(expr), char *) || \ + __builtin_types_compatible_p(__typeof__(expr), char[])) + +/* evaluates to true if expr is of type (const) void* or (const) FILE* */ +#if 0 +#define curlcheck_cb_data(expr) \ + (curlcheck_ptr((expr), void) || \ + curlcheck_ptr((expr), FILE)) +#else /* be less strict */ +#define curlcheck_cb_data(expr) \ + curlcheck_any_ptr(expr) +#endif + +/* evaluates to true if expr is of type FILE* */ +#define curlcheck_FILE(expr) \ + (curlcheck_NULL(expr) || \ + (__builtin_types_compatible_p(__typeof__(expr), FILE *))) + +/* evaluates to true if expr can be passed as POST data (void* or char*) */ +#define curlcheck_postfields(expr) \ + (curlcheck_ptr((expr), void) || \ + curlcheck_arr((expr), char) || \ + curlcheck_arr((expr), unsigned char)) + +/* helper: __builtin_types_compatible_p distinguishes between functions and + * function pointers, hide it */ +#define curlcheck_cb_compatible(func, type) \ + (__builtin_types_compatible_p(__typeof__(func), type) || \ + __builtin_types_compatible_p(__typeof__(func) *, type)) + +/* evaluates to true if expr is of type curl_resolver_start_callback */ +#define curlcheck_resolver_start_callback(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_resolver_start_callback)) + +/* evaluates to true if expr is of type curl_read_callback or "similar" */ +#define curlcheck_read_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), __typeof__(fread) *) || \ + curlcheck_cb_compatible((expr), curl_read_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_read_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_read_callback2) || \ + curlcheck_cb_compatible((expr), Wcurl_read_callback3) || \ + curlcheck_cb_compatible((expr), Wcurl_read_callback4) || \ + curlcheck_cb_compatible((expr), Wcurl_read_callback5) || \ + curlcheck_cb_compatible((expr), Wcurl_read_callback6)) +typedef size_t (*Wcurl_read_callback1)(char *, size_t, size_t, void *); +typedef size_t (*Wcurl_read_callback2)(char *, size_t, size_t, const void *); +typedef size_t (*Wcurl_read_callback3)(char *, size_t, size_t, FILE *); +typedef size_t (*Wcurl_read_callback4)(void *, size_t, size_t, void *); +typedef size_t (*Wcurl_read_callback5)(void *, size_t, size_t, const void *); +typedef size_t (*Wcurl_read_callback6)(void *, size_t, size_t, FILE *); + +/* evaluates to true if expr is of type curl_write_callback or "similar" */ +#define curlcheck_write_cb(expr) \ + (curlcheck_read_cb(expr) || \ + curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \ + curlcheck_cb_compatible((expr), curl_write_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_write_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_write_callback2) || \ + curlcheck_cb_compatible((expr), Wcurl_write_callback3) || \ + curlcheck_cb_compatible((expr), Wcurl_write_callback4) || \ + curlcheck_cb_compatible((expr), Wcurl_write_callback5) || \ + curlcheck_cb_compatible((expr), Wcurl_write_callback6)) +typedef size_t (*Wcurl_write_callback1)(const char *, size_t, size_t, void *); +typedef size_t (*Wcurl_write_callback2)(const char *, size_t, size_t, + const void *); +typedef size_t (*Wcurl_write_callback3)(const char *, size_t, size_t, FILE *); +typedef size_t (*Wcurl_write_callback4)(const void *, size_t, size_t, void *); +typedef size_t (*Wcurl_write_callback5)(const void *, size_t, size_t, + const void *); +typedef size_t (*Wcurl_write_callback6)(const void *, size_t, size_t, FILE *); + +/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */ +#define curlcheck_ioctl_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_ioctl_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_ioctl_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_ioctl_callback2) || \ + curlcheck_cb_compatible((expr), Wcurl_ioctl_callback3) || \ + curlcheck_cb_compatible((expr), Wcurl_ioctl_callback4)) +typedef curlioerr (*Wcurl_ioctl_callback1)(CURL *, int, void *); +typedef curlioerr (*Wcurl_ioctl_callback2)(CURL *, int, const void *); +typedef curlioerr (*Wcurl_ioctl_callback3)(CURL *, curliocmd, void *); +typedef curlioerr (*Wcurl_ioctl_callback4)(CURL *, curliocmd, const void *); + +/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */ +#define curlcheck_sockopt_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_sockopt_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_sockopt_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_sockopt_callback2)) +typedef int (*Wcurl_sockopt_callback1)(void *, curl_socket_t, curlsocktype); +typedef int (*Wcurl_sockopt_callback2)(const void *, curl_socket_t, + curlsocktype); + +/* evaluates to true if expr is of type curl_opensocket_callback or + "similar" */ +#define curlcheck_opensocket_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_opensocket_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_opensocket_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_opensocket_callback2) || \ + curlcheck_cb_compatible((expr), Wcurl_opensocket_callback3) || \ + curlcheck_cb_compatible((expr), Wcurl_opensocket_callback4)) +typedef curl_socket_t (*Wcurl_opensocket_callback1) + (void *, curlsocktype, struct curl_sockaddr *); +typedef curl_socket_t (*Wcurl_opensocket_callback2) + (void *, curlsocktype, const struct curl_sockaddr *); +typedef curl_socket_t (*Wcurl_opensocket_callback3) + (const void *, curlsocktype, struct curl_sockaddr *); +typedef curl_socket_t (*Wcurl_opensocket_callback4) + (const void *, curlsocktype, const struct curl_sockaddr *); + +/* evaluates to true if expr is of type curl_progress_callback or "similar" */ +#define curlcheck_progress_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_progress_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_progress_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_progress_callback2)) +typedef int (*Wcurl_progress_callback1)(void *, + double, double, double, double); +typedef int (*Wcurl_progress_callback2)(const void *, + double, double, double, double); + +/* evaluates to true if expr is of type curl_xferinfo_callback */ +#define curlcheck_xferinfo_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_xferinfo_callback)) + +/* evaluates to true if expr is of type curl_debug_callback or "similar" */ +#define curlcheck_debug_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_debug_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_debug_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_debug_callback2) || \ + curlcheck_cb_compatible((expr), Wcurl_debug_callback3) || \ + curlcheck_cb_compatible((expr), Wcurl_debug_callback4) || \ + curlcheck_cb_compatible((expr), Wcurl_debug_callback5) || \ + curlcheck_cb_compatible((expr), Wcurl_debug_callback6) || \ + curlcheck_cb_compatible((expr), Wcurl_debug_callback7) || \ + curlcheck_cb_compatible((expr), Wcurl_debug_callback8)) +typedef int (*Wcurl_debug_callback1) (CURL *, + curl_infotype, char *, size_t, void *); +typedef int (*Wcurl_debug_callback2) (CURL *, + curl_infotype, char *, size_t, const void *); +typedef int (*Wcurl_debug_callback3) (CURL *, + curl_infotype, const char *, size_t, void *); +typedef int (*Wcurl_debug_callback4) (CURL *, + curl_infotype, const char *, size_t, const void *); +typedef int (*Wcurl_debug_callback5) (CURL *, + curl_infotype, unsigned char *, size_t, void *); +typedef int (*Wcurl_debug_callback6) (CURL *, + curl_infotype, unsigned char *, size_t, const void *); +typedef int (*Wcurl_debug_callback7) (CURL *, + curl_infotype, const unsigned char *, size_t, void *); +typedef int (*Wcurl_debug_callback8) (CURL *, + curl_infotype, const unsigned char *, size_t, const void *); + +/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */ +/* this is getting even messier... */ +#define curlcheck_ssl_ctx_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback2) || \ + curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback3) || \ + curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback4) || \ + curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback5) || \ + curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback6) || \ + curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback7) || \ + curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback8)) +typedef CURLcode (*Wcurl_ssl_ctx_callback1)(CURL *, void *, void *); +typedef CURLcode (*Wcurl_ssl_ctx_callback2)(CURL *, void *, const void *); +typedef CURLcode (*Wcurl_ssl_ctx_callback3)(CURL *, const void *, void *); +typedef CURLcode (*Wcurl_ssl_ctx_callback4)(CURL *, const void *, + const void *); +#ifdef HEADER_SSL_H +/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX + * this will of course break if we are included before OpenSSL headers... + */ +typedef CURLcode (*Wcurl_ssl_ctx_callback5)(CURL *, SSL_CTX *, void *); +typedef CURLcode (*Wcurl_ssl_ctx_callback6)(CURL *, SSL_CTX *, const void *); +typedef CURLcode (*Wcurl_ssl_ctx_callback7)(CURL *, const SSL_CTX *, void *); +typedef CURLcode (*Wcurl_ssl_ctx_callback8)(CURL *, const SSL_CTX *, + const void *); +#else +typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback5; +typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback6; +typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback7; +typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback8; +#endif + +/* evaluates to true if expr is of type curl_conv_callback or "similar" */ +#define curlcheck_conv_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_conv_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_conv_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_conv_callback2) || \ + curlcheck_cb_compatible((expr), Wcurl_conv_callback3) || \ + curlcheck_cb_compatible((expr), Wcurl_conv_callback4)) +typedef CURLcode (*Wcurl_conv_callback1)(char *, size_t length); +typedef CURLcode (*Wcurl_conv_callback2)(const char *, size_t length); +typedef CURLcode (*Wcurl_conv_callback3)(void *, size_t length); +typedef CURLcode (*Wcurl_conv_callback4)(const void *, size_t length); + +/* evaluates to true if expr is of type curl_seek_callback or "similar" */ +#define curlcheck_seek_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_seek_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_seek_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_seek_callback2)) +typedef CURLcode (*Wcurl_seek_callback1)(void *, curl_off_t, int); +typedef CURLcode (*Wcurl_seek_callback2)(const void *, curl_off_t, int); + +/* evaluates to true if expr is of type curl_chunk_bgn_callback */ +#define curlcheck_chunk_bgn_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_chunk_bgn_callback) || \ + curlcheck_cb_compatible((expr), Wcurl_chunk_bgn_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_chunk_bgn_callback2)) +typedef long (*Wcurl_chunk_bgn_callback1)(struct curl_fileinfo *, + void *, int); +typedef long (*Wcurl_chunk_bgn_callback2)(void *, void *, int); + +/* evaluates to true if expr is of type curl_chunk_end_callback */ +#define curlcheck_chunk_end_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_chunk_end_callback)) + +/* evaluates to true if expr is of type curl_closesocket_callback */ +#define curlcheck_close_socket_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_closesocket_callback)) + +/* evaluates to true if expr is of type curl_fnmatch_callback */ +#define curlcheck_fnmatch_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_fnmatch_callback)) + +/* evaluates to true if expr is of type curl_hstsread_callback */ +#define curlcheck_hstsread_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_hstsread_callback)) + +/* evaluates to true if expr is of type curl_hstswrite_callback */ +#define curlcheck_hstswrite_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_hstswrite_callback)) + +/* evaluates to true if expr is of type curl_sshhostkeycallback */ +#define curlcheck_ssh_hostkey_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_sshhostkeycallback)) + +/* evaluates to true if expr is of type curl_sshkeycallback */ +#define curlcheck_ssh_key_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_sshkeycallback)) + +/* evaluates to true if expr is of type curl_interleave_callback */ +#define curlcheck_interleave_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), Wcurl_interleave_callback1) || \ + curlcheck_cb_compatible((expr), Wcurl_interleave_callback2)) +typedef size_t (*Wcurl_interleave_callback1)(void *p, size_t s, + size_t n, void *u); +typedef size_t (*Wcurl_interleave_callback2)(char *p, size_t s, + size_t n, void *u); + +/* evaluates to true if expr is of type curl_prereq_callback */ +#define curlcheck_prereq_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_prereq_callback)) + +/* evaluates to true if expr is of type curl_trailer_callback */ +#define curlcheck_trailer_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_trailer_callback)) + +#endif /* CURLINC_TYPECHECK_GCC_H */ diff --git a/illumos-x86_64/usr/include/curl/urlapi.h b/illumos-x86_64/usr/include/curl/urlapi.h new file mode 100644 index 00000000..dabe44a4 --- /dev/null +++ b/illumos-x86_64/usr/include/curl/urlapi.h @@ -0,0 +1,155 @@ +#ifndef CURLINC_URLAPI_H +#define CURLINC_URLAPI_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#include "curl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* the error codes for the URL API */ +typedef enum { + CURLUE_OK, + CURLUE_BAD_HANDLE, /* 1 */ + CURLUE_BAD_PARTPOINTER, /* 2 */ + CURLUE_MALFORMED_INPUT, /* 3 */ + CURLUE_BAD_PORT_NUMBER, /* 4 */ + CURLUE_UNSUPPORTED_SCHEME, /* 5 */ + CURLUE_URLDECODE, /* 6 */ + CURLUE_OUT_OF_MEMORY, /* 7 */ + CURLUE_USER_NOT_ALLOWED, /* 8 */ + CURLUE_UNKNOWN_PART, /* 9 */ + CURLUE_NO_SCHEME, /* 10 */ + CURLUE_NO_USER, /* 11 */ + CURLUE_NO_PASSWORD, /* 12 */ + CURLUE_NO_OPTIONS, /* 13 */ + CURLUE_NO_HOST, /* 14 */ + CURLUE_NO_PORT, /* 15 */ + CURLUE_NO_QUERY, /* 16 */ + CURLUE_NO_FRAGMENT, /* 17 */ + CURLUE_NO_ZONEID, /* 18 */ + CURLUE_BAD_FILE_URL, /* 19 */ + CURLUE_BAD_FRAGMENT, /* 20 */ + CURLUE_BAD_HOSTNAME, /* 21 */ + CURLUE_BAD_IPV6, /* 22 */ + CURLUE_BAD_LOGIN, /* 23 */ + CURLUE_BAD_PASSWORD, /* 24 */ + CURLUE_BAD_PATH, /* 25 */ + CURLUE_BAD_QUERY, /* 26 */ + CURLUE_BAD_SCHEME, /* 27 */ + CURLUE_BAD_SLASHES, /* 28 */ + CURLUE_BAD_USER, /* 29 */ + CURLUE_LACKS_IDN, /* 30 */ + CURLUE_TOO_LARGE, /* 31 */ + CURLUE_LAST +} CURLUcode; + +typedef enum { + CURLUPART_URL, + CURLUPART_SCHEME, + CURLUPART_USER, + CURLUPART_PASSWORD, + CURLUPART_OPTIONS, + CURLUPART_HOST, + CURLUPART_PORT, + CURLUPART_PATH, + CURLUPART_QUERY, + CURLUPART_FRAGMENT, + CURLUPART_ZONEID /* added in 7.65.0 */ +} CURLUPart; + +#define CURLU_DEFAULT_PORT (1 << 0) /* return default port number */ +#define CURLU_NO_DEFAULT_PORT (1 << 1) /* act as if no port number was set, + if the port number matches the + default for the scheme */ +#define CURLU_DEFAULT_SCHEME (1 << 2) /* return default scheme if + missing */ +#define CURLU_NON_SUPPORT_SCHEME (1 << 3) /* allow non-supported scheme */ +#define CURLU_PATH_AS_IS (1 << 4) /* leave dot sequences */ +#define CURLU_DISALLOW_USER (1 << 5) /* no user+password allowed */ +#define CURLU_URLDECODE (1 << 6) /* URL decode on get */ +#define CURLU_URLENCODE (1 << 7) /* URL encode on set */ +#define CURLU_APPENDQUERY (1 << 8) /* append a form style part */ +#define CURLU_GUESS_SCHEME (1 << 9) /* legacy curl-style guessing */ +#define CURLU_NO_AUTHORITY (1 << 10) /* Allow empty authority when the + scheme is unknown. */ +#define CURLU_ALLOW_SPACE (1 << 11) /* Allow spaces in the URL */ +#define CURLU_PUNYCODE (1 << 12) /* get the hostname in punycode */ +#define CURLU_PUNY2IDN (1 << 13) /* punycode => IDN conversion */ +#define CURLU_GET_EMPTY (1 << 14) /* allow empty queries and fragments + when extracting the URL or the + components */ +#define CURLU_NO_GUESS_SCHEME (1 << 15) /* for get, do not accept a guess */ + +typedef struct Curl_URL CURLU; + +/* + * curl_url() creates a new CURLU handle and returns a pointer to it. + * Must be freed with curl_url_cleanup(). + */ +CURL_EXTERN CURLU *curl_url(void); + +/* + * curl_url_cleanup() frees the CURLU handle and related resources used for + * the URL parsing. It will not free strings previously returned with the URL + * API. + */ +CURL_EXTERN void curl_url_cleanup(CURLU *handle); + +/* + * curl_url_dup() duplicates a CURLU handle and returns a new copy. The new + * handle must also be freed with curl_url_cleanup(). + */ +CURL_EXTERN CURLU *curl_url_dup(const CURLU *in); + +/* + * curl_url_get() extracts a specific part of the URL from a CURLU + * handle. Returns error code. The returned pointer MUST be freed with + * curl_free() afterwards. + */ +CURL_EXTERN CURLUcode curl_url_get(const CURLU *handle, CURLUPart what, + char **part, unsigned int flags); + +/* + * curl_url_set() sets a specific part of the URL in a CURLU handle. Returns + * error code. The passed in string will be copied. Passing a NULL instead of + * a part string, clears that part. + */ +CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what, + const char *part, unsigned int flags); + +/* + * curl_url_strerror() turns a CURLUcode value into the equivalent human + * readable error string. This is useful for printing meaningful error + * messages. + */ +CURL_EXTERN const char *curl_url_strerror(CURLUcode); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif /* CURLINC_URLAPI_H */ diff --git a/illumos-x86_64/usr/include/curl/websockets.h b/illumos-x86_64/usr/include/curl/websockets.h new file mode 100644 index 00000000..402a2ca0 --- /dev/null +++ b/illumos-x86_64/usr/include/curl/websockets.h @@ -0,0 +1,98 @@ +#ifndef CURLINC_WEBSOCKETS_H +#define CURLINC_WEBSOCKETS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct curl_ws_frame { + int age; /* zero */ + int flags; /* See the CURLWS_* defines */ + curl_off_t offset; /* the offset of this data into the frame */ + curl_off_t bytesleft; /* number of pending bytes left of the payload */ + size_t len; /* size of the current data chunk */ +}; + +/* flag bits */ +#define CURLWS_TEXT (1 << 0) +#define CURLWS_BINARY (1 << 1) +#define CURLWS_CONT (1 << 2) +#define CURLWS_CLOSE (1 << 3) +#define CURLWS_PING (1 << 4) +#define CURLWS_OFFSET (1 << 5) + +/* + * NAME curl_ws_recv() + * + * DESCRIPTION + * + * Receives data from the websocket connection. Use after successful + * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. + */ +CURL_EXTERN CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen, + size_t *recv, + const struct curl_ws_frame **metap); + +/* flags for curl_ws_send() */ +#define CURLWS_PONG (1 << 6) + +/* + * NAME curl_ws_send() + * + * DESCRIPTION + * + * Sends data over the websocket connection. Use after successful + * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. + */ +CURL_EXTERN CURLcode curl_ws_send(CURL *curl, const void *buffer, + size_t buflen, size_t *sent, + curl_off_t fragsize, + unsigned int flags); + +/* + * NAME curl_ws_start_frame() + * + * DESCRIPTION + * + * Buffers a websocket frame header with the given flags and length. + * Errors when a previous frame is not complete, e.g. not all its + * payload has been added. + */ +CURL_EXTERN CURLcode curl_ws_start_frame(CURL *curl, + unsigned int flags, + curl_off_t frame_len); + +/* bits for the CURLOPT_WS_OPTIONS bitmask: */ +#define CURLWS_RAW_MODE (1L << 0) +#define CURLWS_NOAUTOPONG (1L << 1) + +CURL_EXTERN const struct curl_ws_frame *curl_ws_meta(CURL *curl); + +#ifdef __cplusplus +} +#endif + +#endif /* CURLINC_WEBSOCKETS_H */ diff --git a/illumos-x86_64/usr/include/curses.h b/illumos-x86_64/usr/include/curses.h new file mode 100644 index 00000000..b683b97b --- /dev/null +++ b/illumos-x86_64/usr/include/curses.h @@ -0,0 +1,1528 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ +#ifndef _CURSES_H +#define _CURSES_H + +/* + * curses.h - this file is automatically made from caps and + * curses.ed. Don't make changes directly to curses.h! + */ + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CSMAX 4 + +/* + * This trick is used to distinguish between SYSV and V7 systems. + * We assume that L_ctermid is only defined in stdio.h in SYSV + * systems, but not in V7 or Berkeley UNIX. + */ +#ifdef L_ctermid +#ifdef SYSV +#undef SYSV +#endif +#define SYSV +#endif +/* Some V7 systems define L_ctermid - we list those here */ +#ifdef BSD +#undef SYSV +#endif + +#ifdef SYSV + +#include +typedef struct termio SGTTY; +typedef struct termios SGTTYS; + +#else /* !SYSV */ + +#ifndef _SGTTYB_ +#include +#endif /* _SGTTYB_ */ +typedef struct sgttyb SGTTY; + +#endif /* SYSV */ + +/* + * bool is a built-in type in standard C++ and as such is not + * defined here when using standard C++. However, the GNU compiler + * fixincludes utility nonetheless creates it's own version of this + * header for use by gcc and g++. In that version it adds a redundant + * guard for __cplusplus. To avoid the creation of a gcc/g++ specific + * header we need to include the following magic comment: + * + * we must use the C++ compiler's type + * + * The above comment should not be removed or changed until GNU + * gcc/fixinc/inclhack.def is updated to bypass this header. + */ +#if !defined(__cplusplus) && !defined(_BOOL) +typedef char bool; +#endif /* !defined(__cplusplus) && !defined(_BOOL) */ + +#define _VR3_COMPAT_CODE +/* + * chtype is the type used to store a character together with attributes. + * It can be set to "char" to save space, or "long" to get more attributes. + */ +#ifdef CHTYPE +typedef CHTYPE chtype; +#else +#ifdef _LP64 +typedef unsigned int chtype; +#else +typedef unsigned long chtype; +#endif /* _LP64 */ +#endif /* CHTYPE */ + +/* + * Define for the 'old' definition of chtype is required + * when we are running in compatibility mode + */ +#ifdef _VR3_COMPAT_CODE +typedef unsigned short _ochtype; +#endif + +/* TRUE and FALSE get defined so many times, */ +/* let's not get in the way of other definitions. */ +#if !defined(TRUE) || ((TRUE) != 1) +#define TRUE (1) +#endif +#if !defined(FALSE) || ((FALSE) != 0) +#define FALSE (0) +#endif +#if !defined(ERR) || ((ERR) != -1) +#define ERR (-1) +#endif +#if !defined(OK) || ((OK) != 0) +#define OK (0) +#endif + +/* short-hand notations */ +typedef struct _win_st WINDOW; +typedef struct screen SCREEN; +typedef struct _Mouse MOUSE_STATUS; + +struct _win_st +{ + short _cury, _curx; /* current coordinates */ + short _maxy, _maxx; /* max coordinates */ + short _begy, _begx; /* (0,0) screen coordinates */ + char _flags; + short _yoffset; /* actual begy is _begy+_yoffset */ + bool _clear, /* clearok() info */ + _leave, /* leaveok() info */ + _immed, /* window in immediate mode */ + _sync; /* auto syncup of parent */ + WINDOW *_padwin; /* "pad" area for current window */ +#ifdef _VR3_COMPAT_CODE + _ochtype **_y16; /* MUST stay at this offset in WINDOW */ +#endif + short *_firstch; /* first change in line */ + short *_lastch; /* last change in line */ + short _tmarg, _bmarg; /* scrolling region bounds */ + /* MUST stay at this offset in WINDOW */ + unsigned _scroll : 1; /* scrollok() info */ + unsigned _use_idl : 1; + unsigned _use_keypad : 1; + unsigned _notimeout : 1; + unsigned _use_idc : 1; + chtype _attrs; /* current window attributes */ + chtype _bkgd; /* background, normally blank */ + int _delay; /* delay period on wgetch */ + /* 0: for nodelay */ + /* <0: for infinite delay */ + /* >0: delay time in millisec */ + short _ndescs; /* number of descendants */ + short _parx, _pary; /* coords relative to parent (0,0) */ + WINDOW *_parent; /* the parent if this is a subwin */ + chtype **_y; /* lines of data */ + short _nbyte; /* number of bytes to come */ + short _index; /* index to hold coming char */ + char _waitc[CSMAX]; /* array to hold partial m-width char */ + bool _insmode; /* TRUE for inserting, */ + /* FALSE for adding */ +}; + +/* _lastch is initially set to this, _firstch is set to win->_maxx */ +#define _NOCHANGE -1 +#define _INFINITY 16000 /* no line can be longer than this */ + +/* values for win->_flags */ +#define _ISPAD 001 +#define _WINCHANGED 002 +#define _WINMOVED 004 +#define _WINSDEL 010 +#define _CANT_BE_IMMED 020 +#define _WIN_ADD_ONE 040 +#define _WIN_INS_ONE 100 + +struct _Mouse { + int x, y; + short button[3]; + int changes; +}; + +#define CURS_STUPID 0 +#define CURS_UNKNOWN 1 +#define CURS_BAD_MALLOC 2 + +/* + * Various tricks to shut up lint about things that are perfectly fine. + */ +#if defined(__lint) && !defined(CURSES) /* if not internal to curses source */ +struct screen { + int _nobody_; +}; +#endif /* __lint */ + +/* common external variables */ + +extern int LINES, COLS, TABSIZE, COLORS, COLOR_PAIRS; + +extern short curs_errno; + +extern WINDOW *stdscr, *curscr; + +extern MOUSE_STATUS Mouse_status; + +extern char ttytype[]; + +extern char curs_parm_err[], + *curs_err_strings[]; + +/* Function declarations */ + +#ifdef _VR3_COMPAT_CODE + +extern _ochtype *acs_map; +extern chtype *acs32map; + +/* definitions for Vr3 source compatibility */ + +#define initscr initscr32 +#define newterm newterm32 +#define waddch w32addch +#define wechochar w32echochar +#define pechochar p32echochar +#define winsch w32insch +#define vidputs vid32puts +#define vidattr vid32attr +#define wattroff w32attroff +#define wattron w32attron +#define wattrset w32attrset +#define acs_map acs32map +#define box box32 + +#ifdef __STDC__ +extern WINDOW *initscr(void); +extern SCREEN *newterm(char *, FILE *, FILE *); +#else +extern WINDOW *initscr(); +extern SCREEN *newterm(); +#endif + +/* declarations for mini-curses */ + +#ifdef __STDC__ +extern WINDOW *m_initscr(void); + +extern SCREEN *m_newterm(char *, FILE *, FILE *); + +extern int m_addch(int), m_addstr(char *), m_clear(void), m_erase(void), + m_move(int, int), m_refresh(void); + +#else /* __STDC__ */ +extern WINDOW *m_initscr(); + +extern SCREEN *m_newterm(); + +extern int m_addch(), m_addstr(), m_clear(), m_erase(), + m_move(), m_refresh(); + +#endif /* __STDC__ */ + +#else /* _VR3_COMPAT_CODE */ + +extern chtype *acs_map; + +#endif /* _VR3_COMPAT_CODE */ + +#ifdef __STDC__ + +extern SCREEN *newscreen(char *, int, int, int, FILE *, FILE *); +extern SCREEN *setcurscreen(SCREEN *); + +extern WINDOW *initscr(void); +extern WINDOW *newwin(int, int, int, int); +extern WINDOW *newpad(int, int); +extern WINDOW *derwin(WINDOW *, int, int, int, int); +extern WINDOW *dupwin(WINDOW *); +extern WINDOW *getwin(FILE *); + +extern int wgetch(WINDOW *); /* it can return KEY_*, for instance. */ + +extern char *longname(void); /* long name of terminal */ +extern char *termname(void); /* effective terminal name */ +extern char *keyname(int); /* name of token returned by wgetch() */ +extern char *slk_label(int); +extern char erasechar(void); +extern char killchar(void); +extern char *unctrl(int); + +extern chtype termattrs(void); + +extern void vidupdate(chtype, chtype, int (*)(char)); +extern void wsyncup(WINDOW *); +extern void wsyncdown(WINDOW *); +extern void delscreen(SCREEN *); +extern void curserr(void); +extern void _setqiflush(int); +extern void wcursyncup(WINDOW *); + +extern int cbreak(void); +extern int nocbreak(void); +extern int reset_prog_mode(void); +extern int reset_shell_mode(void); +extern int def_prog_mode(void); +extern int _setecho(int); +extern int _setnonl(int); +extern int def_shell_mode(void); +extern int raw(void); +extern int savetty(void); +extern int traceon(void); +extern int _meta(int); +extern int traceoff(void); +extern int noraw(void); +extern int flushinp(void); +extern int _getsyx(int *, int *); +extern int _ring(bool); +extern int resetty(void); +extern int ripoffline(int, int (*)(WINDOW *, int)); +extern int setsyx(int, int); +extern int slk_refresh(void); +extern int slk_restore(void); +extern int wstandend(WINDOW *); +extern int wstandout(WINDOW *); +extern int wattroff(WINDOW *, chtype); +extern int wattron(WINDOW *, chtype); +extern int wattrset(WINDOW *, chtype); +extern int wrefresh(WINDOW *); + +extern int copywin(WINDOW *, WINDOW *, int, int, int, int, int, int, int); +extern int curs_set(int); +extern int delay_output(int); +extern int delwin(WINDOW *); +extern int doupdate(void); +extern int drainio(int); +extern int endwin(void); +extern int isendwin(void); +extern int baudrate(void); +extern int has_ic(void); +extern int has_il(void); +extern int keypad(WINDOW *, bool); +extern int mvcur(int, int, int, int); + +extern int mvprintw(int, int, ...); +extern int mvscanw(int, int, ...); +extern int mvwprintw(WINDOW *, int, int, ...); +extern int mvwscanw(WINDOW *, int, int, ...); +extern int printw(char *, ...); +extern int scanw(char *, ...); +extern int wprintw(WINDOW *, ...); +extern int wscanw(WINDOW *, ...); + + /* __va_list is the ANSI-C safe definition of the */ + /* va_list type as allowed to be defined in stdlib.h. */ + /* provides the nested include of */ + /* which provides this namespace safe definition. */ + /* Either or must be included to */ + /* use these interfaces. */ + +extern int vwprintw(WINDOW *, char *, __va_list); +extern int vwscanw(WINDOW *, char *, __va_list); + +extern int mvwin(WINDOW *, int, int); +extern int mvderwin(WINDOW *, int, int); +extern int napms(int); +extern int newkey(char *, short, bool); +extern int filter(void); +extern int pechochar(WINDOW *, chtype); +extern int pnoutrefresh(WINDOW *, int, int, int, int, int, int); +extern int prefresh(WINDOW *, int, int, int, int, int, int); + +extern int putwin(WINDOW *, FILE *); +extern int wredrawln(WINDOW *, int, int); +extern int scr_dump(char *); +extern int setupterm(char *, int, int *); + +extern int slk_attron(chtype); +extern int slk_attroff(chtype); +extern int slk_attrset(chtype); +extern int slk_clear(void); +extern int slk_noutrefresh(void); +extern int slk_set(int, char *, int); +extern int slk_start(int, int *); +extern int slk_touch(void); +extern int start_color(void); +extern int typeahead(int); + +extern bool can_change_color(void); +extern bool has_colors(void); + +extern int waddch(WINDOW *, chtype); +extern int waddchnstr(WINDOW *, chtype *, int); +extern int waddnstr(WINDOW *, char *, int); +extern int wbkgd(WINDOW *, chtype); +extern int wborder(WINDOW *, chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +extern int wclrtobot(WINDOW *); +extern int wclrtoeol(WINDOW *); +extern int wdelch(WINDOW *); +extern int wechochar(WINDOW *, chtype); +extern int wgetstr(WINDOW *, char *); +extern int wgetnstr(WINDOW *, char *, int); +extern int whline(WINDOW *, chtype, int); +extern int wvline(WINDOW *, chtype, int); +extern int winchnstr(WINDOW *, chtype *, int); +extern int winchstr(WINDOW *, chtype *); +extern int winnstr(WINDOW *, char *, int); +extern int winsch(WINDOW *, chtype); +extern int winsdelln(WINDOW *, int); /* internal */ +extern int winsnstr(WINDOW *, char *, int); +extern int winstr(WINDOW *, char *); +extern int wmove(WINDOW *, int, int); +extern int wnoutrefresh(WINDOW *); +extern int wredrawln(WINDOW *, int, int); +extern int wscrl(WINDOW *, int); +extern int wsetscrreg(WINDOW *, int, int); +extern int wtouchln(WINDOW *, int, int, int); + +extern int crmode(void); +extern int nocrmode(void); +extern int ungetch(int); + +extern int mouse_set(long int); +extern int mouse_on(long int); +extern int mouse_off(long int); +extern int request_mouse_pos(void); +extern int map_button(unsigned long); + +extern void wmouse_position(WINDOW *, int *, int *); + +extern unsigned long getmouse(void), getbmap(void); + + /* the following declarations take integers as arguments */ + /* to keep the CI5 compiler happy. what we really want */ + /* to pass is given in comments. (by the way, we don't */ + /* save anything by passing short or bool, since compiler */ + /* expands them to integers any way */ + +extern int pair_content(short, short *, short *); +extern int color_content(short, short *, short *, short *); /* as above */ +extern int init_color(short, short, short, short); +extern int init_pair(short, short, short); +extern int idlok(WINDOW *, bool); + +extern void immedok(WINDOW *, bool); + +extern chtype winwch(WINDOW *); + +extern int pechowchar(WINDOW *, chtype); +extern int ungetwch(const wchar_t); +extern int waddnwstr(WINDOW *, wchar_t *, int); +extern int waddwch(WINDOW *, chtype); +extern int waddwchnstr(WINDOW *, chtype *, int); +extern int wechowchar(WINDOW *, chtype); +extern int wgetnwstr(WINDOW *, wchar_t *, int); +extern int wgetwch(WINDOW *); +extern int wgetwstr(WINDOW *, wchar_t *); +extern int winnwstr(WINDOW *, wchar_t *, int); +extern int winsnwstr(WINDOW *, wchar_t *, int); +extern int winswch(WINDOW *, chtype); +extern int winwchnstr(WINDOW *, chtype *, int); +extern int winwstr(WINDOW *, wchar_t *); + +#else /* __STDC__ */ + +extern SCREEN *newscreen(), /* termname, lines, cols, tabsiz, fout, fin */ + *setcurscreen(); /* screenptr */ + +extern WINDOW *initscr(), + *newwin(), /* nlines, ncols, begy, begx */ + *newpad(), /* nlines, ncols */ + *derwin(), /* orig, nlines, ncols, begy, begx */ + *dupwin(), /* orig */ + *getwin(); /* file */ + +extern int wgetch(); /* because it can return KEY_*, for instance. */ + +extern char *longname(), /* long name of terminal */ + *termname(), /* effective terminal name */ + *keyname(), /* (int) name of token returned by wgetch() */ + *slk_label(), /* index */ + erasechar(), + killchar(), + *unctrl(); + +extern chtype termattrs(); + +extern void vidupdate(), wsyncup(), wsyncdown(), + delkeymap(), + delscreen(), curserr(), + _setqiflush(), + immedok(), + wcursyncup(); + +extern int cbreak(), nocbreak(), + reset_prog_mode(), reset_shell_mode(), def_prog_mode(), + _setecho(), _setnonl(), + def_shell_mode(), raw(), + savetty(), traceon(), _meta(), + traceoff(), noraw(), flushinp(), _getsyx(), + _ring(), resetty(), ripoffline(), setsyx(), slk_refresh(), + slk_restore(), wstandend(), wstandout(), + wattroff(), wattron(), wattrset(), wrefresh(); + +extern int color_cont(), copywin(), curs_set(), delay_output(), delwin(), + doupdate(), drainio(), endwin(), isendwin(), + baudrate(), has_ic(), has_il(), idlok(), + init_color(), init_pair(), keypad(), mvcur(); + +extern int mvprintw(), mvscanw(), mvwprintw(), mvwscanw(), + printw(), scanw(), wprintw(), wscanw(), vwprintw(), vwscanw(); + +extern int mvwin(), mvderwin(), napms(), newkey(), filter(), + pair_content(), pechochar(), pnoutrefresh(), prefresh(); + +extern int putwin(), wredrawln(), scr_dump(), setupterm(); + +extern int slk_attrof(), slk_attrof(), slk_attrset(), + slk_clear(), slk_noutrefresh(), slk_set(), + slk_start(), slk_touch(), start_color(), + typeahead(); + +extern bool can_change_color(), has_colors(); + +extern int waddch(), waddchnstr(), waddnstr(), wbkgd(), + wborder(), wclrtobot(), wclrtoeol(), wdelch(), wechochar(), + wgetstr(), wgetnstr(), whline(), wvline(), winchnstr(), + winchstr(), winnstr(), winsch(), + winsdelln(), /* internal */ + winsnstr(), winstr(), wmove(), wnoutrefresh(), wredrawln(), + wscrl(), wsetscrreg(), wtouchln(); + +extern int crmode(), nocrmode(), ungetch(); + +extern int mouse_set(), mouse_on(), mouse_off(), + request_mouse_pos(), map_button(); + +extern void wmouse_position(); + +extern unsigned long getmouse(), getbmap(); + +extern chtype winwch(); + +extern int pechowchar(), ungetwch(), waddnwstr(), waddwch(), + waddwchnstr(), wechowchar(), wgetnwstr(), wgetwch(), + wgetwstr(), winnwstr(), winsnwstr(), winswch(), + winwchnstr(), winwstr(); + +#endif /* __STDC__ */ + +#define getsyx(y, x) _getsyx(&(y), &(x)) + +/* + * Functions to get at the window structure. + */ + +#define getyx(win, y, x) ((y) = getcury(win), (x) = getcurx(win)) +#define getbegyx(win, y, x) ((y) = getbegy(win), (x) = getbegx(win)) +#define getmaxyx(win, y, x) ((y) = getmaxy(win), (x) = getmaxx(win)) +#define getparyx(win, y, x) ((y) = getpary(win), (x) = getparx(win)) + +#if defined(CURS_PERFORMANCE) && !defined(__lint) +#define getcury(win) ((win)->_cury) +#define getcurx(win) ((win)->_curx) +#define getbegy(win) ((win)->_begy) +#define getbegx(win) ((win)->_begx) +#define getmaxy(win) ((win)->_maxy) +#define getmaxx(win) ((win)->_maxx) +#define getpary(win) ((win)->_pary) +#define getparx(win) ((win)->_parx) +#define getbkgd(win) ((win)->_bkgd) +#define getattrs(win) ((win)->_attrs) +#else /* defined(CURS_PERFORMANCE) && !defined(__lint) */ + +#ifdef __STDC__ +extern int getcury(WINDOW *); +extern int getcurx(WINDOW *); +extern int getbegy(WINDOW *); +extern int getbegx(WINDOW *); +extern int getmaxy(WINDOW *); +extern int getmaxx(WINDOW *); +extern int getpary(WINDOW *); +extern int getparx(WINDOW *); + +extern chtype getbkgd(WINDOW *); +extern chtype getattrs(WINDOW *); + +#else /* __STDC__ */ +extern int getcury(), getcurx(), getbegy(), getbegx(), + getmaxy(), getmaxx(), getpary(), getparx(); + +extern chtype getbkgd(), getattrs(); + +#endif /* __STDC__ */ +#endif /* defined(CURS_PERFORMANCE) && !defined(__lint) */ + +#if defined(NOMACROS) || defined(__lint) + +#ifdef __STDC__ + +extern SCREEN *newterm(char *, FILE *, FILE *); +extern SCREEN *set_term(SCREEN *); + +extern WINDOW *subpad(WINDOW *, int, int, int, int); +extern WINDOW *subwin(WINDOW *, int, int, int, int); + +extern char *unctrl(int); + +extern chtype inch(void); +extern chtype winch(WINDOW *); +extern chtype mvinch(int, int); +extern chtype mvwinch(WINDOW *, int, int); + +extern int addch(chtype); +extern int addchnstr(chtype *, int); +extern int addchstr(chtype *); +extern int addnstr(char *, int); +extern int addstr(char *); +extern int attroff(chtype); +extern int attron(chtype); +extern int attrset(chtype); +extern int beep(void); +extern int bkgd(chtype); +extern int border(chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +extern int box(WINDOW *, chtype, chtype); +extern int clear(void); +extern int clearok(WINDOW *, bool); +extern int clrtobot(void); +extern int clrtoeol(void); +extern int crmode(void); +extern int delch(void); +extern int deleteln(void); +extern int echo(void); +extern int echochar(chtype); +extern int erase(void); +extern int fixterm(void); +extern int flash(void); +extern int garbagedlines(WINDOW *, int, int); +extern int garbagedwin(WINDOW *); +extern int getch(void); +extern int getstr(char *); +extern int gettmode(void); +extern int halfdelay(int); +extern int hline(chtype, int); +extern int inchnstr(chtype *, int); +extern int inchstr(chtype *); +extern int innstr(char *, int); +extern int insch(chtype); +extern int insdelln(int); +extern int insertln(void); +extern int insnstr(char *, int); +extern int insstr(char *); +extern int instr(char *); +extern int intrflush(WINDOW *, int); +extern int is_linetouched(WINDOW *, int); +extern int is_wintouched(WINDOW *); +extern int leaveok(WINDOW *, bool); +extern int meta(WINDOW *, int); +extern int move(int, int); +extern int mvaddch(int, int, chtype); +extern int mvaddchnstr(int, int, chtype *, int); +extern int mvaddchstr(int, int, chtype *); +extern int mvaddnstr(int, int, char *, int); +extern int mvaddstr(int, int, char *); +extern int mvdelch(int, int); +extern int mvgetch(int, int); +extern int mvgetstr(int, int, char *); +extern int mvhline(int, int, chtype, int); +extern int mvinchnstr(int, int, chtype *, int); +extern int mvinchstr(int, int, chtype *); +extern int mvinnstr(int, int, char *, int); +extern int mvinsch(int, int, chtype); +extern int mvinsnstr(int, int, char *, int); +extern int mvinsstr(int, int, char *); +extern int mvinstr(int, int, char *); +extern int mvvline(int, int, chtype, int); +extern int mvwaddch(WINDOW *, int, int, chtype); +extern int mvwaddchnstr(WINDOW *, int, int, chtype *, int); +extern int mvwaddchstr(WINDOW *, int, int, chtype *); +extern int mvwaddnstr(WINDOW *, int, int, char *, int); +extern int mvwaddstr(WINDOW *, int, int, char *); +extern int mvwdelch(WINDOW *, int, int); +extern int mvwgetch(WINDOW *, int, int); +extern int mvwgetstr(WINDOW *, int, int, char *); +extern int mvwhline(WINDOW *, int, int, chtype, int); +extern int mvwinchnstr(WINDOW *, int, int, chtype *, int); +extern int mvwinchstr(WINDOW *, int, int, chtype *); +extern int mvwinnstr(WINDOW *, int, int, char *, int); +extern int mvwinsch(WINDOW *, int, int, chtype); +extern int mvwinsnstr(WINDOW *, int, int, char *, int); +extern int mvwinsstr(WINDOW *, int, int, char *); +extern int mvwinstr(WINDOW *, int, int, char *); +extern int mvwvline(WINDOW *, int, int, chtype, int); +extern int nl(void); +extern int nocrmode(void); +extern int nodelay(WINDOW *, bool); +extern int noecho(void); +extern int nonl(void); +extern int notimeout(WINDOW *, bool); +extern int overlay(WINDOW *, WINDOW *); +extern int overwrite(WINDOW *, WINDOW *); +extern int redrawwin(WINDOW *); +extern int refresh(void); +extern int resetterm(void); +extern int saveterm(void); +extern int scr_init(char *); +extern int scr_restore(char *); +extern int scr_set(char *); +extern int scrl(int); +extern int scroll(WINDOW *); +extern int scrollok(WINDOW *, bool); +extern int setscrreg(int, int); +extern int setterm(char *); +extern int slk_init(int); +extern int standend(void); +extern int standout(void); +extern int syncok(WINDOW *, bool); +extern int touchline(WINDOW *, int, int); +extern int touchwin(WINDOW *); +extern int untouchwin(WINDOW *); +extern int vline(chtype, int); +extern int waddchstr(WINDOW *, chtype *); +extern int waddstr(WINDOW *, char *); +extern int wclear(WINDOW *); +extern int wdeleteln(WINDOW *); +extern int werase(WINDOW *); +extern int winchstr(WINDOW *, chtype *); +extern int winsertln(WINDOW *); +extern int winsstr(WINDOW *, char *); +extern int winstr(WINDOW *, char *); +extern int wstandend(WINDOW *); +extern int wstandout(WINDOW *); + +extern void bkgdset(chtype); +extern void idcok(WINDOW *, bool); +extern void noqiflush(void); +extern void wbkgdset(WINDOW *, chtype); +extern void qiflush(void); +extern void timeout(int); +extern void wtimeout(WINDOW *, int); +extern void use_env(int); /* int sb. char */ + +extern chtype inwch(void); +extern chtype mvinwch(int, int); +extern chtype mvwinwch(WINDOW *, int, int); + +extern int addnwstr(wchar_t *, int); +extern int addwch(chtype); +extern int addwchnstr(chtype *, int); +extern int addwchstr(chtype *); +extern int addwstr(wchar_t *); +extern int echowchar(chtype); +extern int getnwstr(wchar_t *, int); +extern int getwch(void); +extern int getwstr(wchar_t *); +extern int innwstr(wchar_t *, int); +extern int insnwstr(wchar_t *, int); +extern int inswch(chtype); +extern int inswstr(wchar_t *); +extern int inwchnstr(chtype *, int); +extern int inwchstr(chtype *); +extern int inwstr(wchar_t *); +extern int mvaddnwstr(int, int, wchar_t *, int); +extern int mvaddwch(int, int, chtype); +extern int mvaddwchnstr(int, int, chtype *, int); +extern int mvaddwchstr(int, int, chtype *); +extern int mvaddwstr(int, int, wchar_t *); +extern int mvgetnwstr(int, int, wchar_t *, int); +extern int mvgetwch(int, int); +extern int mvgetwstr(int, int, wchar_t *); +extern int mvinnwstr(int, int, wchar_t *, int); +extern int mvinsnwstr(int, int, wchar_t *, int); +extern int mvinswch(int, int, chtype); +extern int mvinswstr(int, int, wchar_t *); +extern int mvinwchnstr(int, int, chtype *, int); +extern int mvinwchstr(int, int, chtype *); +extern int mvinwstr(int, int, wchar_t *); +extern int mvwaddnwstr(WINDOW *, int, int, wchar_t *, int); +extern int mvwaddwch(WINDOW *, int, int, chtype); +extern int mvwaddwchnstr(WINDOW *, int, int, chtype *, int); +extern int mvwaddwchstr(WINDOW *, int, int, chtype *); +extern int mvwaddwstr(WINDOW *, int, int, wchar_t *); +extern int mvwgetnwstr(WINDOW *, int, int, wchar_t *, int); +extern int mvwgetwch(WINDOW *, int, int); +extern int mvwgetwstr(WINDOW *, int, int, wchar_t *); +extern int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); +extern int mvwinsnwstr(WINDOW *, int, int, wchar_t *, int); +extern int mvwinswch(WINDOW *, int, int, chtype); +extern int mvwinswstr(WINDOW *, int, int, wchar_t *); +extern int mvwinwchnstr(WINDOW *, int, int, chtype *, int); +extern int mvwinwchstr(WINDOW *, int, int, chtype *); +extern int mvwinwstr(WINDOW *, int, int, wchar_t *); +extern int waddwchstr(WINDOW *, chtype *); +extern int waddwstr(WINDOW *, wchar_t *); +extern int winswstr(WINDOW *, wchar_t *); +extern int winwchstr(WINDOW *, chtype *); + +#else /* __STDC__ */ + +extern SCREEN *newterm(), /* termname, fout, fin */ +extern SCREEN *set_term(); /* screenptr */ + +extern WINDOW *subpad(), +extern WINDOW *subwin(); + +extern chtype inch(), winch(), mvinch(), mvwinch(); + +extern char *unctrl(); + +extern int addch(), addchnstr(), addchstr(), addnstr(), addstr(), + attroff(), attron(), attrset(), beep(), bkgd(), + border(), box(), clear(), clearok(), clrtobot(), clrtoeol(), + crmode(), delch(), deleteln(), echo(), echochar(), + erase(), +/* MORE */ fixterm(), + flash(), garbagedlines(), garbagedwin(), + getch(), getstr(), gettmode(), halfdelay(), hline(), + inchnstr(), inchstr(), innstr(), insch(), + insdelln(), insertln(), insnstr(), insstr(), instr(), + intrflush(), + is_linetouched(), is_wintouched(), leaveok(), meta(), + move(), mvaddch(), mvaddchnstr(), mvaddchstr(), mvaddnstr(), + mvaddstr(), mvdelch(), mvgetch(), mvgetstr(), mvhline(), + mvinchnstr(), mvinchstr(), mvinnstr(), mvinsch(), mvinsnstr(), + mvinsstr(), mvinstr(), mvvline(), mvwaddch(), mvwaddchnstr(), + mvwaddchstr(), mvwaddnstr(), mvwaddstr(), mvwdelch(), + mvwgetch(), mvwgetstr(), mvwhline(), mvwinchnstr(), + mvwinchstr(), mvwinnstr(), mvwinsch(), mvwinsnstr(), + mvwinsstr(), mvwinstr(), mvwvline(), + nl(), nocrmode(), nodelay(), + noecho(), nonl(), notimeout(), + overlay(), overwrite(), redrawwin(), refresh(), + resetterm(), saveterm(), scr_init(), + scr_restore(), scr_set(), scrl(), + scroll(), scrollok(), setscrreg(), setterm(), + slk_init(), standend(), standout(), + syncok(), touchline(), touchwin(), untouchwin(), vline(), + waddchstr(), waddstr(), wclear(), + wdeleteln(), werase(), winchstr(), winsertln(), + winsstr(), winstr(), wstandend(), wstandout(); + +extern void bkgdset(), wbkgdset(), idcok(), noqiflush(), + qiflush(), timeout(), wtimeout(), use_env(); + +extern unsigned long getmouse(), getbmap(); + +extern chtype inwch(), mvinwch(), mvwinwch(); + +extern int addnwstr(), addwch(), addwchnstr(), addwchstr(), + addwstr(), echowchar(), getnwstr(), getwch(), + getwstr(), innwstr(), insnwstr(), inswch(), + inswstr(), inwchnstr(), inwchstr(), inwstr(), + mvaddnwstr(), mvaddwch(), mvaddwchnstr(), mvaddwchstr(), + mvaddwstr(), mvgetnwstr(), mvgetwch(), mvgetwstr(), + mvinnwstr(), mvinsnwstr(), mvinswch(), mvinswstr(), + mvinwchnstr(), mvinwchstr(), mvinwstr(), mvwaddnwstr(), + mvwaddwch(), mvwaddwchnstr(), mvwaddwchstr(), mvwaddwstr(), + mvwgetnwstr(), mvwgetwch(), mvwgetwstr(), mvwinnwstr(), + mvwinsnwstr(), mvwinswch(), mvwinswstr(), mvwinwchnstr(), + mvwinwchstr(), mvwinwstr(), waddwchstr(), waddwstr(), + winswstr(), winwchstr(); + +#endif /* __STDC__ */ + +#else /* NOMACROS || __lint */ + +/* + * The defines from here down to the #endif for NOMACROS + * define macros, which may be more efficient than their + * function versions. The functions may be accessed by defining + * NOMACROS in C code. This is useful for debugging purposes. + */ + +#include + +/* pseudo functions for stdscr */ +#define addch(ch) waddch(stdscr, ch) +#define addnstr(s, n) waddnstr(stdscr, s, n) +#define addstr(str) waddstr(stdscr, str) +#define attroff(at) wattroff(stdscr, at) +#define attron(at) wattron(stdscr, at) +#define attrset(at) wattrset(stdscr, at) +#define bkgd(c) wbkgd(stdscr, c) +#define border(ls, rs, ts, bs, tl, tr, bl, br) \ + wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br) +#define clear() wclear(stdscr) +#define clrtobot() wclrtobot(stdscr) +#define clrtoeol() wclrtoeol(stdscr) +#define delch() wdelch(stdscr) +#define deleteln() wdeleteln(stdscr) +#define echochar(ch) wechochar(stdscr, ch) +#define erase() werase(stdscr) +#define getch() wgetch(stdscr) +#define getstr(str) wgetstr(stdscr, str) +#define inch() winch(stdscr) +#define insch(c) winsch(stdscr, c) +#define insdelln(id) winsdelln(stdscr, id) +#define insertln() winsertln(stdscr) +#define insnstr(s, n) winsnstr(stdscr, s, n) +#define insstr(s) winsstr(stdscr, s) +#define move(y, x) wmove(stdscr, y, x) +#define refresh() wrefresh(stdscr) +#define scrl(n) wscrl(stdscr, n) +#define setscrreg(t, b) wsetscrreg(stdscr, t, b) +#define standend() wstandend(stdscr) +#define standout() wstandout(stdscr) +#define timeout(tm) wtimeout(stdscr, tm) +#define hline(c, num) whline(stdscr, c, num) +#define vline(c, num) wvline(stdscr, c, num) +#define addchstr(str) waddchstr(stdscr, str) +#define addchnstr(str, n) waddchnstr(stdscr, str, n) +#define instr(str) winstr(stdscr, (str)) +#define innstr(str, n) winnstr(stdscr, (str), (n)) +#define inchstr(str) winchstr(stdscr, str) +#define inchnstr(str, n) winchnstr(stdscr, str, n) +#define bkgdset(c) wbkgdset(stdscr, c) + +#define addnwstr(ws, n) waddnwstr(stdscr, ws, n) +#define addwch(ch) waddwch(stdscr, ch) +#define addwchnstr(str, n) waddwchnstr(stdscr, str, n) +#define addwchstr(str) waddwchstr(stdscr, str) +#define addwstr(ws) waddwstr(stdscr, ws) +#define echowchar(ch) wechowchar(stdscr, ch) +#define getnwstr(ws, n) wgetnwstr(stdscr, ws, n) +#define getwch() wgetwch(stdscr) +#define getwstr(ws) wgetwstr(stdscr, ws) +#define innwstr(ws, n) winnwstr(stdscr, ws, n) +#define insnwstr(ws, n) winsnwstr(stdscr, ws, n) +#define inswch(c) winswch(stdscr, c) +#define inswstr(ws) winswstr(stdscr, ws) +#define inwch() winwch(stdscr) +#define inwchnstr(str, n) winwchnstr(stdscr, str, n) +#define inwchstr(str) winwchstr(stdscr, str) +#define inwstr(ws) winwstr(stdscr, ws) + +#define adjcurspos() wadjcurspos(stdscr) +#define movenextch() wmovenextch(stdscr) +#define moveprevch() wmoveprevch(stdscr) + +/* functions to define environment flags of a window */ +#ifdef CURS_PERFORMANCE +#define wbkgdset(win, c) \ + (((win)->_attrs = (((win)->_attrs & ~((win)->_bkgd & A_ATTRIBUTES)) | \ + (c & A_ATTRIBUTES))), ((win)->_bkgd = (c))) +#define syncok(win, bf) ((win)->_parent ? (win)->_sync = (bf) : ERR) +#define notimeout(win, bf) \ + (((win)->_notimeout = ((bf) ? TRUE : FALSE)), OK) +#define clearok(win, bf) (((win)->_clear = (bf)), OK) +#define leaveok(win, bf) (((win)->_leave = (bf)), OK) +#define scrollok(win, bf) (((win)->_scroll = ((bf) ? TRUE : FALSE)), OK) +#define idcok(win, bf) ((win)->_use_idc = ((bf) ? TRUE : FALSE)) +#define nodelay(win, bf) (((win)->_delay = (bf) ? 0 : -1), OK) +#define is_wintouched(win) ((win)->_flags & _WINCHANGED) +#define is_linetouched(win, line) \ + ((((line) >= (win)->_maxy) || ((line) < 0)) ? ERR : \ + (((win)->_firstch[(line)] == _INFINITY) ? FALSE : TRUE)) + +#define subwin(win, nl, nc, by, bx) \ + derwin((win), (nl), (nc), (by-win->_begy), (bx-win->_begx)) +#define touchwin(win) wtouchln((win), 0, (win)->_maxy, TRUE) +#define redrawwin(win) wredrawln((win), 0, (win)->_maxy) +#define winchstr(win, str) \ + winchnstr((win), str, ((win)->_maxx - (win)->_curx)) +#define winstr(win, str) \ + winnstr((win), str, ((win)->_maxx - (win)->_curx)) +#define untouchwin(win) wtouchln((win), 0, ((win)->_maxy), FALSE) +#define winch(win) ((win)->_y[(win)->_cury][(win)->_curx]) + +#define wtimeout(win, tm) ((win)->_delay = (tm)) +#define use_env(bf) (_use_env = (bf)) + +#else /* CURS_PERFORMANCE */ + +#ifdef __STDC__ + +extern void wbkgdset(WINDOW *, chtype); +extern void idcok(WINDOW *, bool); +extern void wtimeout(WINDOW *, int); +extern void use_env(int); /* int sb. char */ + +extern int syncok(WINDOW *, bool); +extern int notimeout(WINDOW *, bool); +extern int clearok(WINDOW *, bool); +extern int leaveok(WINDOW *, bool); +extern int scrollok(WINDOW *, bool); +extern int nodelay(WINDOW *, bool); +extern int is_linetouched(WINDOW *, int); +extern int is_wintouched(WINDOW *); +extern int touchwin(WINDOW *); +extern int redrawwin(WINDOW *); +extern int winchstr(WINDOW *, chtype *); +extern int winstr(WINDOW *, char *); +extern int untouchwin(WINDOW *); + +extern chtype winch(WINDOW *); + +extern WINDOW *subwin(WINDOW *, int, int, int, int); + +#else /* __STDC__ */ + +extern void wbkgdset(), idcok(), wtimeout(), use_env(); + +extern int syncok(), notimeout(), clearok(), leaveok(), + scrollok(), nodelay(), is_linetouched(), is_wintouched(), + touchwin(), redrawwin(), winchstr(), winstr(), + untouchwin(); + +extern chtype winch(); + +extern WINDOW *subwin(); + +#endif /* __STDC__ */ + +#endif /* CURS_PERFORMANCE */ + +/* functions for move and update */ +#define mvaddch(y, x, ch) \ + mvwaddch(stdscr, y, x, ch) +#define mvaddnstr(y, x, s, n) \ + mvwaddnstr(stdscr, y, x, s, n) +#define mvaddstr(y, x, str) \ + mvwaddstr(stdscr, y, x, str) +#define mvdelch(y, x) \ + mvwdelch(stdscr, y, x) +#define mvgetch(y, x) \ + mvwgetch(stdscr, y, x) +#define mvgetstr(y, x, str) \ + mvwgetstr(stdscr, y, x, str) +#define mvinch(y, x) \ + mvwinch(stdscr, y, x) +#define mvinsch(y, x, c) \ + mvwinsch(stdscr, y, x, c) +#define mvinsnstr(y, x, s, n) \ + mvwinsnstr(stdscr, y, x, s, n) +#define mvinsstr(y, x, s) \ + mvwinsstr(stdscr, y, x, s) +#define mvaddchstr(y, x, str) \ + mvwaddchstr(stdscr, y, x, str) +#define mvaddchnstr(y, x, str, n) \ + mvwaddchnstr(stdscr, y, x, str, n) +#define mvinstr(y, x, str) \ + mvwinstr(stdscr, y, x, (str)) +#define mvinnstr(y, x, str, n) \ + mvwinnstr(stdscr, y, x, (str), (n)) +#define mvinchstr(y, x, str) \ + mvwinchstr(stdscr, y, x, str) +#define mvinchnstr(y, x, str, n) \ + mvwinchnstr(stdscr, y, x, str, n) +#define mvhline(y, x, c, num) \ + mvwhline(stdscr, y, x, c, num) +#define mvvline(y, x, c, num) \ + mvwvline(stdscr, y, x, c, num) + +#define mvaddnwstr(y, x, ws, n) \ + mvwaddnwstr(stdscr, y, x, ws, n) +#define mvaddwch(y, x, ch) \ + mvwaddwch(stdscr, y, x, ch) +#define mvaddwchnstr(y, x, str, n) \ + mvwaddwchnstr(stdscr, y, x, str, n) +#define mvaddwchstr(y, x, str) \ + mvwaddwchstr(stdscr, y, x, str) +#define mvaddwstr(y, x, ws) \ + mvwaddwstr(stdscr, y, x, ws) +#define mvgetnwstr(y, x, ws, n) \ + mvwgetnwstr(stdscr, y, x, ws, n) +#define mvgetwch(y, x) \ + mvwgetwch(stdscr, y, x) +#define mvgetwstr(y, x, ws) \ + mvwgetwstr(stdscr, y, x, ws) +#define mvinnwstr(y, x, ws, n) \ + mvwinnwstr(stdscr, y, x, ws, n) +#define mvinsnwstr(y, x, ws, n) \ + mvwinsnwstr(stdscr, y, x, ws, n) +#define mvinswch(y, x, c) \ + mvwinswch(stdscr, y, x, c) +#define mvinswstr(y, x, ws) \ + mvwinswstr(stdscr, y, x, ws) +#define mvinwch(y, x) \ + mvwinwch(stdscr, y, x) +#define mvinwchnstr(y, x, str, n) \ + mvwinwchnstr(stdscr, y, x, str, n) +#define mvinwchstr(y, x, str) \ + mvwinwchstr(stdscr, y, x, str) +#define mvinwstr(y, x, ws) \ + mvwinwstr(stdscr, y, x, ws) + +#define mvwaddch(win, y, x, ch) \ + (wmove(win, y, x) == ERR ? ERR : waddch(win, ch)) +#define mvwaddnstr(win, y, x, s, n) \ + (wmove(win, y, x) == ERR ? ERR : waddnstr(win, s, n)) +#define mvwaddstr(win, y, x, str) \ + (wmove(win, y, x) == ERR ? ERR : waddstr(win, str)) +#define mvwdelch(win, y, x) \ + (wmove(win, y, x) == ERR ? ERR : wdelch(win)) +#define mvwgetch(win, y, x) \ + (wmove(win, y, x) == ERR ? ERR : wgetch(win)) +#define mvwgetstr(win, y, x, str) \ + (wmove(win, y, x) == ERR ? ERR : wgetstr(win, str)) +#define mvwinch(win, y, x) \ + (wmove(win, y, x) == ERR ? (chtype)ERR : winch(win)) +#define mvwinsch(win, y, x, c) \ + (wmove(win, y, x) == ERR ? ERR : winsch(win, c)) +#define mvwinsnstr(win, y, x, s, n) \ + (wmove(win, y, x) == ERR ? ERR : winsnstr(win, s, n)) +#define mvwinsstr(win, y, x, s) \ + (wmove(win, y, x) == ERR ? ERR : winsstr(win, s)) +#define mvwhline(win, y, x, c, num) \ + (wmove(win, y, x) == ERR ? ERR : whline(win, c, num)) +#define mvwvline(win, y, x, c, num) \ + (wmove(win, y, x) == ERR ? ERR : wvline(win, c, num)) +#define mvwaddchstr(win, y, x, str) \ + (wmove(win, y, x) == ERR ? ERR : waddchstr(win, str)) +#define mvwaddchnstr(win, y, x, str, n) \ + (wmove(win, y, x) == ERR ? ERR : waddchnstr(win, str, n)) +#define mvwinstr(win, y, x, str) \ + (wmove(win, y, x) == ERR ? ERR : winstr(win, str)) +#define mvwinnstr(win, y, x, str, n) \ + (wmove(win, y, x) == ERR ? ERR : winnstr(win, str, n)) +#define mvwinchstr(win, y, x, str) \ + (wmove(win, y, x) == ERR ? ERR : winchstr(win, str)) +#define mvwinchnstr(win, y, x, str, n) \ + (wmove(win, y, x) == ERR ? ERR : winchnstr(win, str, n)) +#define mvwaddnwstr(win, y, x, ws, n) \ + (wmove(win, y, x) == ERR ? ERR : waddnwstr(win, ws, n)) +#define mvwaddwch(win, y, x, ch) \ + (wmove(win, y, x) == ERR ? ERR : waddwch(win, ch)) +#define mvwaddwchnstr(win, y, x, str, n) \ + (wmove(win, y, x) == ERR ? ERR : waddwchnstr(win, str, n)) +#define mvwaddwchstr(win, y, x, str) \ + (wmove(win, y, x) == ERR ? ERR : waddwchstr(win, str)) +#define mvwaddwstr(win, y, x, ws) \ + (wmove(win, y, x) == ERR ? ERR : waddwstr(win, ws)) +#define mvwgetnwstr(win, y, x, ws, n) \ + (wmove(win, y, x) == ERR ? ERR : wgetnwstr(win, ws, n)) +#define mvwgetwch(win, y, x) \ + (wmove(win, y, x) == ERR ? ERR : wgetwch(win)) +#define mvwgetwstr(win, y, x, ws) \ + (wmove(win, y, x) == ERR ? ERR : wgetwstr(win, ws)) +#define mvwinnwstr(win, y, x, ws, n) \ + (wmove(win, y, x) == ERR ? ERR : winnwstr(win, ws, n)) +#define mvwinsnwstr(win, y, x, ws, n) \ + (wmove(win, y, x) == ERR ? ERR : winsnwstr(win, ws, n)) +#define mvwinswch(win, y, x, c) \ + (wmove(win, y, x) == ERR ? ERR : winswch(win, c)) +#define mvwinswstr(win, y, x, ws) \ + (wmove(win, y, x) == ERR ? ERR : winswstr(win, ws)) +#define mvwinwch(win, y, x) \ + (wmove(win, y, x) == ERR ?(chtype) ERR : winwch(win)) +#define mvwinwchnstr(win, y, x, str, n) \ + (wmove(win, y, x) == ERR ? ERR : winwchnstr(win, str, n)) +#define mvwinwchstr(win, y, x, str) \ + (wmove(win, y, x) == ERR ? ERR : winwchstr(win, str)) +#define mvwinwstr(win, y, x, ws) \ + (wmove(win, y, x) == ERR ? ERR : winwstr(win, ws)) + +#define waddwchstr(win, str) waddwchnstr(win, str, -1) +#define winwchstr(win, str) winwchnstr(win, str, -1) +#define waddwstr(win, ws) waddnwstr(win, ws, -1) +#define winswstr(win, ws) winsnwstr(win, ws, -1) + +#ifdef CURS_MACROS +#define overlay(src, dst) _overlap((src), (dst), TRUE) +#define overwrite(src, dst) _overlap((src), (dst), FALSE) +#define wdeleteln(win) winsdelln((win), -1) +#define winsertln(win) winsdelln((win), 1) +#define wstandend(win) wattrset((win), A_NORMAL) +#define wstandout(win) wattron((win), A_STANDOUT) +#define beep() _ring(TRUE) +#define flash() _ring(FALSE) +#define scroll(win) wscrl((win), 1) +#define slk_init(f) slk_start(((f == 0) ? 3 : 2), NULL) +#define scr_init(file) _scr_all(file, 0) +#define scr_restore(file) _scr_all(file, 1) +#define scr_set(file) _scr_all(file, 2) +#define subpad(win, nl, nc, by, bx) derwin((win), (nl), (nc), (by), (bx)) +#define box(win, v, h) wborder((win), (v), (v), (h), (h), 0, 0, 0, 0) +#define newterm(type, fout, fin) newscreen((type), 0, 0, 0, (fout), (fin)) +#define touchline(win, y, n) wtouchln((win), (y), (n), TRUE) + +#define waddstr(win, str) waddnstr((win), (str), -1) +#define werase(win) (wmove((win), 0, 0), wclrtobot(win)) +#define wclear(win) (clearok((win), TRUE), werase(win)) +#define intrflush(win, flag) _setqiflush(flag) +#define meta(win, flag) _meta(flag) + +#define setterm(name) setupterm((name), 1, (char *)NULL) +#define gettmode() (OK) +#define halfdelay(tens) ttimeout((tens)*100) + +#define echo() _setecho(TRUE) +#define noecho() _setecho(FALSE) +#define nl() _setnonl(FALSE) +#define nonl() _setnonl(TRUE) + +#else /* CURS_MACROS */ + +#ifdef __STDC__ + +extern int overlay(WINDOW *, WINDOW *); +extern int overwrite(WINDOW *, WINDOW *); +extern int wdeleteln(WINDOW *); +extern int winsertln(WINDOW *); +extern int wstandend(WINDOW *); +extern int wstandout(WINDOW *); +extern int beep(void); +extern int flash(void); +extern int scroll(WINDOW *); +extern int slk_init(int); +extern int scr_init(char *); +extern int scr_restore(char *); +extern int box(WINDOW *, chtype, chtype); +extern int touchline(WINDOW *, int, int); +extern int waddstr(WINDOW *, char *); +extern int werase(WINDOW *); +extern int wclear(WINDOW *); +extern int intrflush(WINDOW *, int); +extern int meta(WINDOW *, int); +extern int setterm(char *); +extern int gettmode(void); +extern int halfdelay(int); +extern int echo(void); +extern int noecho(void); +extern int nl(void); +extern int nonl(void); + +extern WINDOW *subpad(WINDOW *, int, int, int, int); + +extern SCREEN *newterm(char *, FILE *, FILE *); + +#else /* __STDC__ */ + +extern int overlay(), overwrite(), wdeleteln(), winsertln(), + wstandend(), wstandout(), beep(), flash(), + scroll(), slk_init(), scr_init(), scr_restore(), + box(), touchline(), waddstr(), werase(), + wclear(), intrflush(), meta(), setterm(), gettmode(), + halfdelay(), echo(), noecho(), nl(), nonl(); + +extern WINDOW *subpad(); + +extern SCREEN *newterm(); + +#endif /* __STDC__ */ +#endif /* CURS_MACROS */ + +#define garbagedlines wredrawln +#define garbagedwin redrawwin + +#define crmode cbreak +#define nocrmode nocbreak +#define saveterm def_prog_mode +#define fixterm reset_prog_mode +#define resetterm reset_shell_mode + +#define waddchstr(win, str) waddchnstr((win), (str), -1) +#define winsstr(win, str) winsnstr((win), (str), -1) + +/* iocontrol functions */ +#define qiflush() _setqiflush(TRUE) +#define noqiflush() _setqiflush(FALSE) + +#define set_term setcurscreen + +#endif /* NOMACROS || __lint */ + +/* + * Standard alternate character set. The current ACS world is evolving, + * so we support only a widely available subset: the line drawing characters + * from the VT100, plus a few from the Teletype 5410v1. Eventually there + * may be support of more sophisticated ACS line drawing, such as that + * in the Teletype 5410, the HP line drawing set, and the like. There may + * be support for some non line oriented characters as well. + * + * Line drawing ACS names are of the form ACS_trbl, where t is the top, r + * is the right, b is the bottom, and l is the left. t, r, b, and l might + * be B (blank), S (single), D (double), or T (thick). The subset defined + * here only uses B and S. + */ + +#define ACS_BSSB (acs_map['l']) +#define ACS_SSBB (acs_map['m']) +#define ACS_BBSS (acs_map['k']) +#define ACS_SBBS (acs_map['j']) +#define ACS_SBSS (acs_map['u']) +#define ACS_SSSB (acs_map['t']) +#define ACS_SSBS (acs_map['v']) +#define ACS_BSSS (acs_map['w']) +#define ACS_BSBS (acs_map['q']) +#define ACS_SBSB (acs_map['x']) +#define ACS_SSSS (acs_map['n']) + +/* + * Human readable names for the most commonly used characters. + * "Upper", "right", etc. are chosen to be consistent with the vt100 manual. + */ + +#define ACS_ULCORNER ACS_BSSB +#define ACS_LLCORNER ACS_SSBB +#define ACS_URCORNER ACS_BBSS +#define ACS_LRCORNER ACS_SBBS +#define ACS_RTEE ACS_SBSS +#define ACS_LTEE ACS_SSSB +#define ACS_BTEE ACS_SSBS +#define ACS_TTEE ACS_BSSS +#define ACS_HLINE ACS_BSBS +#define ACS_VLINE ACS_SBSB +#define ACS_PLUS ACS_SSSS +#define ACS_S1 (acs_map['o']) /* scan line 1 */ +#define ACS_S9 (acs_map['s']) /* scan line 9 */ +#define ACS_DIAMOND (acs_map['`']) /* diamond */ +#define ACS_CKBOARD (acs_map['a']) /* checker board (stipple) */ +#define ACS_DEGREE (acs_map['f']) /* degree symbol */ +#define ACS_PLMINUS (acs_map['g']) /* plus/minus */ +#define ACS_BULLET (acs_map['~']) /* bullet */ + /* Teletype 5410v1 symbols */ +#define ACS_LARROW (acs_map[',']) /* arrow pointing left */ +#define ACS_RARROW (acs_map['+']) /* arrow pointing right */ +#define ACS_DARROW (acs_map['.']) /* arrow pointing down */ +#define ACS_UARROW (acs_map['-']) /* arrow pointing up */ +#define ACS_BOARD (acs_map['h']) /* board of squares */ +#define ACS_LANTERN (acs_map['i']) /* lantern symbol */ +#define ACS_BLOCK (acs_map['0']) /* solid square block */ + +/* Funny "characters" enabled for various special function keys for input */ +/* This list is created from caps and curses.ed. Do not edit it! */ +#define KEY_MIN 0401 /* Minimum curses key */ +#define KEY_BREAK 0401 /* break key (unreliable) */ +#define KEY_DOWN 0402 /* Sent by terminal down arrow key */ +#define KEY_UP 0403 /* Sent by terminal up arrow key */ +#define KEY_LEFT 0404 /* Sent by terminal left arrow key */ +#define KEY_RIGHT 0405 /* Sent by terminal right arrow key */ +#define KEY_HOME 0406 /* Sent by home key. */ +#define KEY_BACKSPACE 0407 /* Sent by backspace key */ +#define KEY_F0 0410 /* function key f0. */ +#define KEY_F(n) (KEY_F0+(n)) /* Space for 64 function keys */ + /* is reserved. */ +#define KEY_DL 0510 /* Sent by delete line key. */ +#define KEY_IL 0511 /* Sent by insert line. */ +#define KEY_DC 0512 /* Sent by delete character key. */ +#define KEY_IC 0513 /* Sent by ins char/enter mode key. */ +#define KEY_EIC 0514 /* Sent by rmir or smir in ins mode. */ +#define KEY_CLEAR 0515 /* Sent by clear screen or erase key. */ +#define KEY_EOS 0516 /* Sent by clear-to-end-of-screen. */ +#define KEY_EOL 0517 /* Sent by clear-to-end-of-line key. */ +#define KEY_SF 0520 /* Sent by scroll-forward/down key */ +#define KEY_SR 0521 /* Sent by scroll-backward/up key */ +#define KEY_NPAGE 0522 /* Sent by next-page key */ +#define KEY_PPAGE 0523 /* Sent by previous-page key */ +#define KEY_STAB 0524 /* Sent by set-tab key */ +#define KEY_CTAB 0525 /* Sent by clear-tab key */ +#define KEY_CATAB 0526 /* Sent by clear-all-tabs key. */ +#define KEY_ENTER 0527 /* Enter/send (unreliable) */ +#define KEY_SRESET 0530 /* soft (partial) reset (unreliable) */ +#define KEY_RESET 0531 /* reset or hard reset (unreliable) */ +#define KEY_PRINT 0532 /* print or copy */ +#define KEY_LL 0533 /* Sent by home-down key */ + /* The keypad is arranged like this: */ + /* a1 up a3 */ + /* left b2 right */ + /* c1 down c3 */ +#define KEY_A1 0534 /* Upper left of keypad */ +#define KEY_A3 0535 /* Upper right of keypad */ +#define KEY_B2 0536 /* Center of keypad */ +#define KEY_C1 0537 /* Lower left of keypad */ +#define KEY_C3 0540 /* Lower right of keypad */ +#define KEY_BTAB 0541 /* Back tab key */ +#define KEY_BEG 0542 /* beg(inning) key */ +#define KEY_CANCEL 0543 /* cancel key */ +#define KEY_CLOSE 0544 /* close key */ +#define KEY_COMMAND 0545 /* cmd (command) key */ +#define KEY_COPY 0546 /* copy key */ +#define KEY_CREATE 0547 /* create key */ +#define KEY_END 0550 /* end key */ +#define KEY_EXIT 0551 /* exit key */ +#define KEY_FIND 0552 /* find key */ +#define KEY_HELP 0553 /* help key */ +#define KEY_MARK 0554 /* mark key */ +#define KEY_MESSAGE 0555 /* message key */ +#define KEY_MOVE 0556 /* move key */ +#define KEY_NEXT 0557 /* next object key */ +#define KEY_OPEN 0560 /* open key */ +#define KEY_OPTIONS 0561 /* options key */ +#define KEY_PREVIOUS 0562 /* previous object key */ +#define KEY_REDO 0563 /* redo key */ +#define KEY_REFERENCE 0564 /* ref(erence) key */ +#define KEY_REFRESH 0565 /* refresh key */ +#define KEY_REPLACE 0566 /* replace key */ +#define KEY_RESTART 0567 /* restart key */ +#define KEY_RESUME 0570 /* resume key */ +#define KEY_SAVE 0571 /* save key */ +#define KEY_SBEG 0572 /* shifted beginning key */ +#define KEY_SCANCEL 0573 /* shifted cancel key */ +#define KEY_SCOMMAND 0574 /* shifted command key */ +#define KEY_SCOPY 0575 /* shifted copy key */ +#define KEY_SCREATE 0576 /* shifted create key */ +#define KEY_SDC 0577 /* shifted delete char key */ +#define KEY_SDL 0600 /* shifted delete line key */ +#define KEY_SELECT 0601 /* select key */ +#define KEY_SEND 0602 /* shifted end key */ +#define KEY_SEOL 0603 /* shifted clear line key */ +#define KEY_SEXIT 0604 /* shifted exit key */ +#define KEY_SFIND 0605 /* shifted find key */ +#define KEY_SHELP 0606 /* shifted help key */ +#define KEY_SHOME 0607 /* shifted home key */ +#define KEY_SIC 0610 /* shifted input key */ +#define KEY_SLEFT 0611 /* shifted left arrow key */ +#define KEY_SMESSAGE 0612 /* shifted message key */ +#define KEY_SMOVE 0613 /* shifted move key */ +#define KEY_SNEXT 0614 /* shifted next key */ +#define KEY_SOPTIONS 0615 /* shifted options key */ +#define KEY_SPREVIOUS 0616 /* shifted prev key */ +#define KEY_SPRINT 0617 /* shifted print key */ +#define KEY_SREDO 0620 /* shifted redo key */ +#define KEY_SREPLACE 0621 /* shifted replace key */ +#define KEY_SRIGHT 0622 /* shifted right arrow */ +#define KEY_SRSUME 0623 /* shifted resume key */ +#define KEY_SSAVE 0624 /* shifted save key */ +#define KEY_SSUSPEND 0625 /* shifted suspend key */ +#define KEY_SUNDO 0626 /* shifted undo key */ +#define KEY_SUSPEND 0627 /* suspend key */ +#define KEY_UNDO 0630 /* undo key */ +#define KEY_MOUSE 0631 /* Mouse event has occured */ +#define KEY_MAX 0777 /* Maximum curses key */ + +/* + * The definition for 'reg' is not standard, and is provided for + * compatibility reasons. User's are discouraged from using this. + */ +#define reg register + +/* Various video attributes */ +#define A_STANDOUT 000010000000 +#define _STANDOUT A_STANDOUT /* for compatability with old curses */ +#define A_UNDERLINE 000020000000 +#define A_REVERSE 000040000000 +#define A_BLINK 000100000000 +#define A_DIM 000200000000 +#define A_BOLD 000400000000 +#define A_ALTCHARSET 001000000000 + +/* The next two are subject to change so don't depend on them */ +#define A_INVIS 010000000000 +#define A_PROTECT 020000000000U + +#define A_NORMAL 000000000000 +#define A_ATTRIBUTES 031777700000U /* 0xCFFF8000 */ +#define A_CHARTEXT 006000077777 /* 0x30007FFF */ +#define A_COLOR 000007700000 + +#define A_WATTRIBUTES 031770000000U /* 0xCFE00000 */ +#define A_WCHARTEXT 006007777777 /* 0x301FFFFF */ + +#define COLOR_PAIR(n) ((n) << 15) +#define PAIR_NUMBER(n) (((n) & A_COLOR) >> 15) + +/* definition of 8 basic color */ +#define COLOR_BLACK 0 +#define COLOR_RED 1 +#define COLOR_GREEN 2 +#define COLOR_YELLOW 3 +#define COLOR_BLUE 4 +#define COLOR_MAGENTA 5 +#define COLOR_CYAN 6 +#define COLOR_WHITE 7 + +/* mouse related macros: don't change these definitions or bit-masks. */ +/* they are interdependent (used by _map_button() in tgetch() */ +#define BUTTON_RELEASED 0 +#define BUTTON_PRESSED 1 +#define BUTTON_CLICKED 2 +#define BUTTON_DOUBLE_CLICKED 3 +#define BUTTON_TRIPLE_CLICKED 4 + +#define MOUSE_X_POS (Mouse_status.x) +#define MOUSE_Y_POS (Mouse_status.y) +#define A_BUTTON_CHANGED (Mouse_status.changes & 7) +#define MOUSE_MOVED (Mouse_status.changes & 8) +#define MOUSE_POS_REPORT (Mouse_status.changes & 16) +#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - 1))) +#define BUTTON_STATUS(x) (Mouse_status.button[(x)-1]) + +/* definition of mouse bit-masks */ +#define BUTTON1_RELEASED 000000000001 +#define BUTTON1_PRESSED 000000000002 +#define BUTTON1_CLICKED 000000000004 +#define BUTTON1_DOUBLE_CLICKED 000000000010 +#define BUTTON1_TRIPLE_CLICKED 000000000020 +#define BUTTON2_RELEASED 000000000040 +#define BUTTON2_PRESSED 000000000100 +#define BUTTON2_CLICKED 000000000200 +#define BUTTON2_DOUBLE_CLICKED 000000000400 +#define BUTTON2_TRIPLE_CLICKED 000000001000 +#define BUTTON3_RELEASED 000000002000 +#define BUTTON3_PRESSED 000000004000 +#define BUTTON3_CLICKED 000000010000 +#define BUTTON3_DOUBLE_CLICKED 000000020000 +#define BUTTON3_TRIPLE_CLICKED 000000040000 +#define ALL_MOUSE_EVENTS 000000077777 +#define REPORT_MOUSE_POSITION 000000100000 + +#ifdef __cplusplus +} +#endif + +#endif /* _CURSES_H */ diff --git a/illumos-x86_64/usr/include/dat/dat.h b/illumos-x86_64/usr/include/dat/dat.h new file mode 100644 index 00000000..71e1220f --- /dev/null +++ b/illumos-x86_64/usr/include/dat/dat.h @@ -0,0 +1,1243 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DAT_H_ +#define _DAT_H_ + +/* + * + * HEADER: dat.h + * + * PURPOSE: defines the common DAT API for uDAPL and kDAPL. + * + * Description: Header file for "uDAPL: User Direct Access Programming + * Library, Version: 1.2" + * + * Mapping rules: + * All global symbols are prepended with "DAT_" or "dat_" + * All DAT objects have an 'api' tag which, such as 'ep' or 'lmr' + * The method table is in the provider definition structure. + * + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Generic DAT types */ + +typedef char *DAT_NAME_PTR; /* Format for ia_name and attributes */ +#define DAT_NAME_MAX_LENGTH 256 + +/* + * Used for provider, vendor, transport, hardware specific attributes + * definitions. + */ + +typedef struct dat_named_attr { + const char *name; /* Name of attribute */ + const char *value; /* Value of attribute */ +} DAT_NAMED_ATTR; + +typedef enum dat_boolean { + DAT_FALSE = 0, + DAT_TRUE = 1 +} DAT_BOOLEAN; + +typedef union dat_context { + DAT_PVOID as_ptr; + DAT_UINT64 as_64; + DAT_UVERYLONG as_index; +} DAT_CONTEXT; + +typedef DAT_CONTEXT DAT_DTO_COOKIE; +typedef DAT_CONTEXT DAT_RMR_COOKIE; + +typedef enum dat_completion_flags { + /* Completes with notification */ + DAT_COMPLETION_DEFAULT_FLAG = 0x00, + + /* Completions suppressed if successful */ + DAT_COMPLETION_SUPPRESS_FLAG = 0x01, + + /* Sender controlled notification for recv completion */ + DAT_COMPLETION_SOLICITED_WAIT_FLAG = 0x02, + + /* Completions with unsignaled notifications */ + DAT_COMPLETION_UNSIGNALLED_FLAG = 0x04, + + /* Do not start processing until all previous RDMA reads complete. */ + DAT_COMPLETION_BARRIER_FENCE_FLAG = 0x08, + + /* + * Only valid for uDAPL as EP attribute for Recv Completion flags. + * Waiter unblocking is controlled by Threshold value of dat_evd_wait. + * UNSIGNALLED for RECV not allowed when EP has this attribute + */ + DAT_COMPLETION_EVD_THRESHOLD_FLAG = 0x10 + +} DAT_COMPLETION_FLAGS; + + +typedef DAT_UINT32 DAT_TIMEOUT; /* microseconds */ + +/* timeout = infinity */ +#define DAT_TIMEOUT_INFINITE ((DAT_TIMEOUT) ~0) + +/* dat handles */ +typedef DAT_PVOID DAT_HANDLE; +typedef DAT_HANDLE DAT_CR_HANDLE; +typedef DAT_HANDLE DAT_EP_HANDLE; +typedef DAT_HANDLE DAT_EVD_HANDLE; +typedef DAT_HANDLE DAT_IA_HANDLE; +typedef DAT_HANDLE DAT_LMR_HANDLE; +typedef DAT_HANDLE DAT_PSP_HANDLE; +typedef DAT_HANDLE DAT_PZ_HANDLE; +typedef DAT_HANDLE DAT_RMR_HANDLE; +typedef DAT_HANDLE DAT_RSP_HANDLE; +typedef DAT_HANDLE DAT_SRQ_HANDLE; + + +/* dat NULL handles */ +#define DAT_HANDLE_NULL ((DAT_HANDLE)NULL) + +typedef DAT_SOCK_ADDR *DAT_IA_ADDRESS_PTR; + +typedef DAT_UINT64 DAT_CONN_QUAL; +typedef DAT_UINT64 DAT_PORT_QUAL; + +/* QOS definitions */ +typedef enum dat_qos { + DAT_QOS_BEST_EFFORT = 0x00, + DAT_QOS_HIGH_THROUGHPUT = 0x01, + DAT_QOS_LOW_LATENCY = 0x02, + /* not low latency, nor high throughput */ + DAT_QOS_ECONOMY = 0x04, + /* both low latency and high throughput */ + DAT_QOS_PREMIUM = 0x08 +} DAT_QOS; + +/* + * FLAGS + */ + +typedef enum dat_connect_flags { + DAT_CONNECT_DEFAULT_FLAG = 0x00, + DAT_CONNECT_MULTIPATH_FLAG = 0x01 +} DAT_CONNECT_FLAGS; + +typedef enum dat_close_flags { + DAT_CLOSE_ABRUPT_FLAG = 0x00, + DAT_CLOSE_GRACEFUL_FLAG = 0x01 +} DAT_CLOSE_FLAGS; + +#define DAT_CLOSE_DEFAULT DAT_CLOSE_ABRUPT_FLAG + +typedef enum dat_evd_flags { + DAT_EVD_SOFTWARE_FLAG = 0x001, + DAT_EVD_CR_FLAG = 0x010, + DAT_EVD_DTO_FLAG = 0x020, + DAT_EVD_CONNECTION_FLAG = 0x040, + DAT_EVD_RMR_BIND_FLAG = 0x080, + DAT_EVD_ASYNC_FLAG = 0x100, + /* DAT events only, no software events */ + DAT_EVD_DEFAULT_FLAG = 0x1F0 +} DAT_EVD_FLAGS; + +typedef enum dat_psp_flags { + DAT_PSP_CONSUMER_FLAG = 0x00, /* Consumer creates an endpoint */ + DAT_PSP_PROVIDER_FLAG = 0x01 /* Provider creates an endpoint */ +} DAT_PSP_FLAGS; + +/* + * Memory Buffers + * + * Both LMR and RMR triplets specify 64-bit addresses in the local host's byte + * order, even when that exceeds the size of a DAT_PVOID for the host + * architecture. + */ + +/* + * Both LMR and RMR Triplets specify 64-bit addresses in the local host + * order, even when that exceeds the size of a void pointer for the host + * architecture. The DAT_VADDR type that represents addresses is in the + * native byte-order of the local host. Helper macros that allow Consumers + * to convert DAT_VADDR into various orders that might be useful for + * inclusion of RMR Triplets into a payload of a message follow. + * + * DAT defines the following macros to convert the fields on an RMR Triplet + * to defined byte orders to allow their export by the Consumer over wire + * protocols. DAT does not define how the two peers decide which byte should be + * used. + * + * DAT_LMRC_TO_LSB(lmrc) returns the supplied LMR Context in ls-byte + * order. + * DAT_LMRC_TO_MSB(lmrc) returns the supplied LMR Context in ms-byte + * order. + * DAT_RMRC_TO_LSB(rmrc) returns the supplied RMR Context in ls-byte + * order. + * DAT_RMRC_TO_MSB(rmrc) returns the supplied RMR Context in ms-byte + * order. + * DAT_VADDR_TO_LSB(vaddr) returns the supplied Virtual Address in ls-byte + * order. + * DAT_VADDR_TO_MSB(vaddr) returns the supplied Virtual Address in + * ms-byte order. + * DAT_VLEN_TO_LSB(vlen) returns the supplied length in ls-byte order. + * DAT_VLEN_TO_MSB(vlen) returns the supplied length in ms-byte order. + * + * Consumers are free to use 64-bit or 32-bit arithmetic for local or remote + * memory address and length manipulation in their preferred byte-order. Only + * the LMR and RMR Triplets passed to a Provider as part of a Posted DTO are + * required to be in 64-bit address and local host order formats. Providers + * shall convert RMR_Triplets to a Transport-required wire format. + * + * For the best performance, Consumers should align each buffer segment to + * the boundary specified by the dat_optimal_alignment. + */ +typedef DAT_UINT32 DAT_LMR_CONTEXT; +typedef DAT_UINT32 DAT_RMR_CONTEXT; + +typedef DAT_UINT64 DAT_VLEN; +typedef DAT_UINT64 DAT_VADDR; + +typedef struct dat_provider_attr DAT_PROVIDER_ATTR; +typedef struct dat_evd_param DAT_EVD_PARAM; +typedef struct dat_lmr_param DAT_LMR_PARAM; + +/* + * It is legal for Consumer to specify zero for segment_length + * of the dat_lmr_triplet. When 0 is specified for the + * segment_length then the other two elements of the + * dat_lmr_triplet are irrelevant and can be invalid. + */ + +typedef struct dat_lmr_triplet { + DAT_LMR_CONTEXT lmr_context; + DAT_UINT32 pad; + DAT_VADDR virtual_address; + DAT_VLEN segment_length; +} DAT_LMR_TRIPLET; + +typedef struct dat_rmr_triplet { + DAT_RMR_CONTEXT rmr_context; + DAT_UINT32 pad; + DAT_VADDR target_address; + DAT_VLEN segment_length; +} DAT_RMR_TRIPLET; + +/* + * The extra padding ensures that context, address, and length parameters are + * aligned on 64-bit boundaries. + */ + +/* Memory privileges */ + +typedef enum dat_mem_priv_flags { + DAT_MEM_PRIV_NONE_FLAG = 0x00, + DAT_MEM_PRIV_LOCAL_READ_FLAG = 0x01, + DAT_MEM_PRIV_REMOTE_READ_FLAG = 0x02, + DAT_MEM_PRIV_LOCAL_WRITE_FLAG = 0x10, + DAT_MEM_PRIV_REMOTE_WRITE_FLAG = 0x20, + DAT_MEM_PRIV_ALL_FLAG = 0x33, + DAT_MEM_PRIV_RO_DISABLE_FLAG = 0x100 +} DAT_MEM_PRIV_FLAGS; + +/* + * For backwards compatibility with DAT-1.0 memory privileges values + * are supported + */ +#define DAT_MEM_PRIV_READ_FLAG (DAT_MEM_PRIV_LOCAL_READ_FLAG | \ + DAT_MEM_PRIV_REMOTE_READ_FLAG) +#define DAT_MEM_PRIV_WRITE_FLAG (DAT_MEM_PRIV_LOCAL_WRITE_FLAG | \ + DAT_MEM_PRIV_REMOTE_WRITE_FLAG) + +/* LMR Arguments Mask */ + +typedef enum dat_lmr_param_mask { + DAT_LMR_FIELD_IA_HANDLE = 0x001, + DAT_LMR_FIELD_MEM_TYPE = 0x002, + DAT_LMR_FIELD_REGION_DESC = 0x004, + DAT_LMR_FIELD_LENGTH = 0x008, + DAT_LMR_FIELD_PZ_HANDLE = 0x010, + DAT_LMR_FIELD_MEM_PRIV = 0x020, + DAT_LMR_FIELD_LMR_CONTEXT = 0x040, + DAT_LMR_FIELD_RMR_CONTEXT = 0x080, + DAT_LMR_FIELD_REGISTERED_SIZE = 0x100, + DAT_LMR_FIELD_REGISTERED_ADDRESS = 0x200, + + DAT_LMR_FIELD_ALL = 0x3FF +} DAT_LMR_PARAM_MASK; + +/* RMR Argumments & RMR Arguments Mask */ + +typedef struct dat_rmr_param { + DAT_IA_HANDLE ia_handle; + DAT_PZ_HANDLE pz_handle; + DAT_LMR_TRIPLET lmr_triplet; + DAT_MEM_PRIV_FLAGS mem_priv; + DAT_RMR_CONTEXT rmr_context; +} DAT_RMR_PARAM; + +typedef enum dat_rmr_param_mask { + DAT_RMR_FIELD_IA_HANDLE = 0x01, + DAT_RMR_FIELD_PZ_HANDLE = 0x02, + DAT_RMR_FIELD_LMR_TRIPLET = 0x04, + DAT_RMR_FIELD_MEM_PRIV = 0x08, + DAT_RMR_FIELD_RMR_CONTEXT = 0x10, + + DAT_RMR_FIELD_ALL = 0x1F +} DAT_RMR_PARAM_MASK; + +/* Provider attributes */ + +typedef enum dat_iov_ownership { + /* Not modification by provider, consumer can use anytime. */ + DAT_IOV_CONSUMER = 0x0, + + /* Provider does not modify returned IOV DTO on completion. */ + DAT_IOV_PROVIDER_NOMOD = 0x1, + + /* Provider may modify IOV DTO on completion, can't trust it. */ + DAT_IOV_PROVIDER_MOD = 0x2 + +} DAT_IOV_OWNERSHIP; + +typedef enum dat_ep_creator_for_psp { + DAT_PSP_CREATES_EP_NEVER, /* provider never creates endpoint */ + DAT_PSP_CREATES_EP_IFASKED, /* provider creates endpoint if asked */ + DAT_PSP_CREATES_EP_ALWAYS /* provider always creates endpoint */ +} DAT_EP_CREATOR_FOR_PSP; + +/* General Interface Adapter attributes. These apply to both udat and kdat. */ + +/* To support backwards compatibility for DAPL-1.0 */ +#define max_rdma_read_per_ep max_rdma_read_per_ep_in +#define DAT_IA_FIELD_IA_MAX_DTO_PER_OP DAT_IA_FIELD_IA_ MAX_DTO_PER_EP_IN + +/* to support backwards compatibility for DAPL-1.0 & DAPL-1.1 */ +#define max_mtu_size max_message_size + +typedef struct dat_ia_attr +{ + char adapter_name[DAT_NAME_MAX_LENGTH]; + char vendor_name[DAT_NAME_MAX_LENGTH]; + DAT_UINT32 hardware_version_major; + DAT_UINT32 hardware_version_minor; + DAT_UINT32 firmware_version_major; + DAT_UINT32 firmware_version_minor; + DAT_IA_ADDRESS_PTR ia_address_ptr; + DAT_COUNT max_eps; + DAT_COUNT max_dto_per_ep; + DAT_COUNT max_rdma_read_per_ep_in; + DAT_COUNT max_rdma_read_per_ep_out; + DAT_COUNT max_evds; + DAT_COUNT max_evd_qlen; + DAT_COUNT max_iov_segments_per_dto; + DAT_COUNT max_lmrs; + DAT_VLEN max_lmr_block_size; + DAT_VADDR max_lmr_virtual_address; + DAT_COUNT max_pzs; + DAT_VLEN max_message_size; + DAT_VLEN max_rdma_size; + DAT_COUNT max_rmrs; + DAT_VADDR max_rmr_target_address; + DAT_COUNT max_srqs; + DAT_COUNT max_ep_per_srq; + DAT_COUNT max_recv_per_srq; + DAT_COUNT max_iov_segments_per_rdma_read; + DAT_COUNT max_iov_segments_per_rdma_write; + DAT_COUNT max_rdma_read_in; + DAT_COUNT max_rdma_read_out; + DAT_BOOLEAN max_rdma_read_per_ep_in_guaranteed; + DAT_BOOLEAN max_rdma_read_per_ep_out_guaranteed; + DAT_COUNT num_transport_attr; + DAT_NAMED_ATTR *transport_attr; + DAT_COUNT num_vendor_attr; + DAT_NAMED_ATTR *vendor_attr; +} DAT_IA_ATTR; + +/* To support backwards compatibility for DAPL-1.0 & DAPL-1.1 */ +#define DAT_IA_FIELD_IA_MAX_MTU_SIZE DAT_IA_FIELD_IA_MAX_MESSAGE_SIZE + +typedef DAT_UINT64 DAT_IA_ATTR_MASK; + +#define DAT_IA_FIELD_IA_ADAPTER_NAME UINT64_C(0x000000001) +#define DAT_IA_FIELD_IA_VENDOR_NAME UINT64_C(0x000000002) +#define DAT_IA_FIELD_IA_HARDWARE_MAJOR_VERSION UINT64_C(0x000000004) +#define DAT_IA_FIELD_IA_HARDWARE_MINOR_VERSION UINT64_C(0x000000008) +#define DAT_IA_FIELD_IA_FIRMWARE_MAJOR_VERSION UINT64_C(0x000000010) +#define DAT_IA_FIELD_IA_FIRMWARE_MINOR_VERSION UINT64_C(0x000000020) +#define DAT_IA_FIELD_IA_ADDRESS_PTR UINT64_C(0x000000040) +#define DAT_IA_FIELD_IA_MAX_EPS UINT64_C(0x000000080) +#define DAT_IA_FIELD_IA_MAX_DTO_PER_EP UINT64_C(0x000000100) +#define DAT_IA_FIELD_IA_MAX_RDMA_READ_PER_EP_IN UINT64_C(0x000000200) +#define DAT_IA_FIELD_IA_MAX_RDMA_READ_PER_EP_OUT UINT64_C(0x000000400) +#define DAT_IA_FIELD_IA_MAX_EVDS UINT64_C(0x000000800) +#define DAT_IA_FIELD_IA_MAX_EVD_QLEN UINT64_C(0x000001000) +#define DAT_IA_FIELD_IA_MAX_IOV_SEGMENTS_PER_DTO UINT64_C(0x000002000) +#define DAT_IA_FIELD_IA_MAX_LMRS UINT64_C(0x000004000) +#define DAT_IA_FIELD_IA_MAX_LMR_BLOCK_SIZE UINT64_C(0x000008000) +#define DAT_IA_FIELD_IA_MAX_LMR_VIRTUAL_ADDRESS UINT64_C(0x000010000) +#define DAT_IA_FIELD_IA_MAX_PZS UINT64_C(0x000020000) +#define DAT_IA_FIELD_IA_MAX_MESSAGE_SIZE UINT64_C(0x000040000) +#define DAT_IA_FIELD_IA_MAX_RDMA_SIZE UINT64_C(0x000080000) +#define DAT_IA_FIELD_IA_MAX_RMRS UINT64_C(0x000100000) +#define DAT_IA_FIELD_IA_MAX_RMR_TARGET_ADDRESS UINT64_C(0x000200000) +#define DAT_IA_FIELD_IA_MAX_SRQS UINT64_C(0x000400000) +#define DAT_IA_FIELD_IA_MAX_EP_PER_SRQ UINT64_C(0x000800000) +#define DAT_IA_FIELD_IA_MAX_RECV_PER_SRQ UINT64_C(0x001000000) +#define DAT_IA_FIELD_IA_MAX_IOV_SEGMENTS_PER_RDMA_READ UINT64_C(0x002000000) +#define DAT_IA_FIELD_IA_MAX_IOV_SEGMENTS_PER_RDMA_WRITE UINT64_C(0x004000000) +#define DAT_IA_FIELD_IA_MAX_RDMA_READ_IN UINT64_C(0x008000000) +#define DAT_IA_FIELD_IA_MAX_RDMA_READ_OUT UINT64_C(0x010000000) +#define DAT_IA_FIELD_IA_MAX_RDMA_READ_PER_EP_IN_GUARANTEED \ + UINT64_C(0x020000000) +#define DAT_IA_FIELD_IA_MAX_RDMA_READ_PER_EP_OUT_GUARANTEED \ + UINT64_C(0x040000000) +#define DAT_IA_FIELD_IA_NUM_TRANSPORT_ATTR UINT64_C(0x080000000) +#define DAT_IA_FIELD_IA_TRANSPORT_ATTR UINT64_C(0x100000000) +#define DAT_IA_FIELD_IA_NUM_VENDOR_ATTR UINT64_C(0x200000000) +#define DAT_IA_FIELD_IA_VENDOR_ATTR UINT64_C(0x400000000) + +/* To support backwards compatibility for DAPL-1.0 & DAPL-1.1 */ +#define DAT_IA_ALL DAT_IA_FIELD_ALL +#define DAT_IA_FIELD_ALL UINT64_C(0x7FFFFFFFF) +#define DAT_IA_FIELD_NONE UINT64_C(0x0) + +/* Endpoint attributes */ + +typedef enum dat_service_type { + DAT_SERVICE_TYPE_RC /* reliable connections */ +} DAT_SERVICE_TYPE; + +typedef struct dat_ep_attr { + DAT_SERVICE_TYPE service_type; + DAT_VLEN max_message_size; + DAT_VLEN max_rdma_size; + DAT_QOS qos; + DAT_COMPLETION_FLAGS recv_completion_flags; + DAT_COMPLETION_FLAGS request_completion_flags; + DAT_COUNT max_recv_dtos; + DAT_COUNT max_request_dtos; + DAT_COUNT max_recv_iov; + DAT_COUNT max_request_iov; + DAT_COUNT max_rdma_read_in; + DAT_COUNT max_rdma_read_out; + DAT_COUNT srq_soft_hw; + DAT_COUNT max_rdma_read_iov; + DAT_COUNT max_rdma_write_iov; + DAT_COUNT ep_transport_specific_count; + DAT_NAMED_ATTR * ep_transport_specific; + DAT_COUNT ep_provider_specific_count; + DAT_NAMED_ATTR * ep_provider_specific; +} DAT_EP_ATTR; + +/* Endpoint Parameters */ + +/* For backwards compatability */ +#define DAT_EP_STATE_ERROR DAT_EP_STATE_DISCONNECTED + +typedef enum dat_ep_state { + DAT_EP_STATE_UNCONNECTED, /* quiescent state */ + DAT_EP_STATE_UNCONFIGURED_UNCONNECTED, + DAT_EP_STATE_RESERVED, + DAT_EP_STATE_UNCONFIGURED_RESERVED, + DAT_EP_STATE_PASSIVE_CONNECTION_PENDING, + DAT_EP_STATE_UNCONFIGURED_PASSIVE, + DAT_EP_STATE_ACTIVE_CONNECTION_PENDING, + DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING, + DAT_EP_STATE_UNCONFIGURED_TENTATIVE, + DAT_EP_STATE_CONNECTED, + DAT_EP_STATE_DISCONNECT_PENDING, + DAT_EP_STATE_DISCONNECTED, + DAT_EP_STATE_COMPLETION_PENDING +} DAT_EP_STATE; + +typedef struct dat_ep_param { + DAT_IA_HANDLE ia_handle; + DAT_EP_STATE ep_state; + DAT_IA_ADDRESS_PTR local_ia_address_ptr; + DAT_PORT_QUAL local_port_qual; + DAT_IA_ADDRESS_PTR remote_ia_address_ptr; + DAT_PORT_QUAL remote_port_qual; + DAT_PZ_HANDLE pz_handle; + DAT_EVD_HANDLE recv_evd_handle; + DAT_EVD_HANDLE request_evd_handle; + DAT_EVD_HANDLE connect_evd_handle; + DAT_SRQ_HANDLE srq_handle; + DAT_EP_ATTR ep_attr; +} DAT_EP_PARAM; + +typedef DAT_UINT64 DAT_EP_PARAM_MASK; +#define DAT_EP_FIELD_IA_HANDLE UINT64_C(0x00000001) +#define DAT_EP_FIELD_EP_STATE UINT64_C(0x00000002) +#define DAT_EP_FIELD_LOCAL_IA_ADDRESS_PTR UINT64_C(0x00000004) +#define DAT_EP_FIELD_LOCAL_PORT_QUAL UINT64_C(0x00000008) +#define DAT_EP_FIELD_REMOTE_IA_ADDRESS_PTR UINT64_C(0x00000010) +#define DAT_EP_FIELD_REMOTE_PORT_QUAL UINT64_C(0x00000020) +#define DAT_EP_FIELD_PZ_HANDLE UINT64_C(0x00000040) +#define DAT_EP_FIELD_RECV_EVD_HANDLE UINT64_C(0x00000080) +#define DAT_EP_FIELD_REQUEST_EVD_HANDLE UINT64_C(0x00000100) +#define DAT_EP_FIELD_CONNECT_EVD_HANDLE UINT64_C(0x00000200) +#define DAT_EP_FIELD_SRQ_HANDLE UINT64_C(0x00000400) + + /* Remainder of values from EP_ATTR, 0x00001000 and up */ + +#define DAT_EP_FIELD_EP_ATTR_SERVICE_TYPE UINT64_C(0x00001000) +#define DAT_EP_FIELD_EP_ATTR_MAX_MESSAGE_SIZE UINT64_C(0x00002000) +#define DAT_EP_FIELD_EP_ATTR_MAX_RDMA_SIZE UINT64_C(0x00004000) +#define DAT_EP_FIELD_EP_ATTR_QOS UINT64_C(0x00008000) + +#define DAT_EP_FIELD_EP_ATTR_RECV_COMPLETION_FLAGS UINT64_C(0x00010000) +#define DAT_EP_FIELD_EP_ATTR_REQUEST_COMPLETION_FLAGS UINT64_C(0x00020000) +#define DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS UINT64_C(0x00040000) +#define DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS UINT64_C(0x00080000) + +#define DAT_EP_FIELD_EP_ATTR_MAX_RECV_IOV UINT64_C(0x00100000) +#define DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_IOV UINT64_C(0x00200000) + +#define DAT_EP_FIELD_EP_ATTR_MAX_RDMA_READ_IN UINT64_C(0x00400000) +#define DAT_EP_FIELD_EP_ATTR_MAX_RDMA_READ_OUT UINT64_C(0x00800000) + +#define DAT_EP_FIELD_EP_ATTR_SRQ_SOFT_HW UINT64_C(0x01000000) + +#define DAT_EP_FIELD_EP_ATTR_MAX_RDMA_READ_IOV UINT64_C(0x02000000) +#define DAT_EP_FIELD_EP_ATTR_MAX_RDMA_WRITE_IOV UINT64_C(0x04000000) + +#define DAT_EP_FIELD_EP_ATTR_NUM_TRANSPORT_ATTR UINT64_C(0x08000000) +#define DAT_EP_FIELD_EP_ATTR_TRANSPORT_SPECIFIC_ATTR UINT64_C(0x10000000) + +#define DAT_EP_FIELD_EP_ATTR_NUM_PROVIDER_ATTR UINT64_C(0x20000000) +#define DAT_EP_FIELD_EP_ATTR_PROVIDER_SPECIFIC_ATTR UINT64_C(0x40000000) + +#define DAT_EP_FIELD_EP_ATTR_ALL UINT64_C(0x7FFFF000) +#define DAT_EP_FIELD_ALL UINT64_C(0x7FFFF7FF) + +#define DAT_WATERMARK_INFINITE ((DAT_COUNT)~0) + +#define DAT_HW_DEFAULT DAT_WATERMARK_INFINITE + +#define DAT_SRQ_LW_DEFAULT 0x0 + +typedef enum dat_srq_state { + DAT_SRQ_STATE_OPERATIONAL, + DAT_SRQ_STATE_ERROR +} DAT_SRQ_STATE; + +#define DAT_VALUE_UNKNOWN (((DAT_COUNT) ~0)-1) + +typedef struct dat_srq_attr { + DAT_COUNT max_recv_dtos; + DAT_COUNT max_recv_iov; + DAT_COUNT low_watermark; +} DAT_SRQ_ATTR; + +typedef struct dat_srq_param { + DAT_IA_HANDLE ia_handle; + DAT_SRQ_STATE srq_state; + DAT_PZ_HANDLE pz_handle; + DAT_COUNT max_recv_dtos; + DAT_COUNT max_recv_iov; + DAT_COUNT low_watermark; + DAT_COUNT available_dto_count; + DAT_COUNT outstanding_dto_count; +} DAT_SRQ_PARAM; + +typedef enum dat_srq_param_mask { + DAT_SRQ_FIELD_IA_HANDLE = 0x001, + DAT_SRQ_FIELD_SRQ_STATE = 0x002, + DAT_SRQ_FIELD_PZ_HANDLE = 0x004, + DAT_SRQ_FIELD_MAX_RECV_DTO = 0x008, + DAT_SRQ_FIELD_MAX_RECV_IOV = 0x010, + DAT_SRQ_FIELD_LOW_WATERMARK = 0x020, + DAT_SRQ_FIELD_AVAILABLE_DTO_COUNT = 0x040, + DAT_SRQ_FIELD_OUTSTANDING_DTO_COUNT = 0x080, + + DAT_SRQ_FIELD_ALL = 0x0FF +} DAT_SRQ_PARAM_MASK; + +/* PZ Parameters */ + +typedef struct dat_pz_param { + DAT_IA_HANDLE ia_handle; +} DAT_PZ_PARAM; + +typedef enum dat_pz_param_mask { + DAT_PZ_FIELD_IA_HANDLE = 0x01, + + DAT_PZ_FIELD_ALL = 0x01 +} DAT_PZ_PARAM_MASK; + +/* PSP Parameters */ + +typedef struct dat_psp_param { + DAT_IA_HANDLE ia_handle; + DAT_CONN_QUAL conn_qual; + DAT_EVD_HANDLE evd_handle; + DAT_PSP_FLAGS psp_flags; +} DAT_PSP_PARAM; + +typedef enum dat_psp_param_mask { + DAT_PSP_FIELD_IA_HANDLE = 0x01, + DAT_PSP_FIELD_CONN_QUAL = 0x02, + DAT_PSP_FIELD_EVD_HANDLE = 0x04, + DAT_PSP_FIELD_PSP_FLAGS = 0x08, + + DAT_PSP_FIELD_ALL = 0x0F +} DAT_PSP_PARAM_MASK; + +/* RSP Parameters */ + +typedef struct dat_rsp_param { + DAT_IA_HANDLE ia_handle; + DAT_CONN_QUAL conn_qual; + DAT_EVD_HANDLE evd_handle; + DAT_EP_HANDLE ep_handle; +} DAT_RSP_PARAM; + +typedef enum dat_rsp_param_mask { + DAT_RSP_FIELD_IA_HANDLE = 0x01, + DAT_RSP_FIELD_CONN_QUAL = 0x02, + DAT_RSP_FIELD_EVD_HANDLE = 0x04, + DAT_RSP_FIELD_EP_HANDLE = 0x08, + + DAT_RSP_FIELD_ALL = 0x0F +} DAT_RSP_PARAM_MASK; + +/* + * Connection Request Parameters. + * + * The Connection Request does not provide Remote Endpoint attributes. + * If a local Consumer needs this information, the remote Consumer should + * encode it into Private Data. + */ + +typedef struct dat_cr_param { + /* Remote IA whose Endpoint requested the connection. */ + DAT_IA_ADDRESS_PTR remote_ia_address_ptr; + + /* Port qualifier of the remote Endpoint of the requested connection. */ + DAT_PORT_QUAL remote_port_qual; + + /* Size of the Private Data. */ + DAT_COUNT private_data_size; + + /* + * Pointer to the Private Data passed by remote side in the Connection + * Request. + */ + DAT_PVOID private_data; + + /* + * The local Endpoint provided by the Service Point for the requested + * connection. It is the only Endpoint that can accept a Connection + * Request on this Service Point. The value DAT_HANDLE_NULL represents + * that there is no associated local Endpoint for the requested + * connection. + */ + DAT_EP_HANDLE local_ep_handle; + +} DAT_CR_PARAM; + +typedef enum dat_cr_param_mask { + DAT_CR_FIELD_REMOTE_IA_ADDRESS_PTR = 0x01, + DAT_CR_FIELD_REMOTE_PORT_QUAL = 0x02, + DAT_CR_FIELD_PRIVATE_DATA_SIZE = 0x04, + DAT_CR_FIELD_PRIVATE_DATA = 0x08, + DAT_CR_FIELD_LOCAL_EP_HANDLE = 0x10, + + DAT_CR_FIELD_ALL = 0x1F +} DAT_CR_PARAM_MASK; + +/* + * *********************** Events ***************************************** + */ + +/* Completion status flags */ + +/* dto completion status */ + +/* For backwards compatability */ +#define DAT_DTO_LENGTH_ERROR DAT_DTO_ERR_LOCAL_LENGTH +#define DAT_DTO_FAILURE DAT_DTO_ERR_FLUSHED + +typedef enum dat_dto_completion_status { + DAT_DTO_SUCCESS = 0, + DAT_DTO_ERR_FLUSHED = 1, + DAT_DTO_ERR_LOCAL_LENGTH = 2, + DAT_DTO_ERR_LOCAL_EP = 3, + DAT_DTO_ERR_LOCAL_PROTECTION = 4, + DAT_DTO_ERR_BAD_RESPONSE = 5, + DAT_DTO_ERR_REMOTE_ACCESS = 6, + DAT_DTO_ERR_REMOTE_RESPONDER = 7, + DAT_DTO_ERR_TRANSPORT = 8, + DAT_DTO_ERR_RECEIVER_NOT_READY = 9, + DAT_DTO_ERR_PARTIAL_PACKET = 10, + DAT_RMR_OPERATION_FAILED = 11 +} DAT_DTO_COMPLETION_STATUS; + +/* RMR completion status */ + +/* For backwards compatability */ +#define DAT_RMR_BIND_SUCCESS DAT_DTO_SUCCESS +#define DAT_RMR_BIND_FAILURE DAT_DTO_ERR_FLUSHED + +#define DAT_RMR_BIND_COMPLETION_STATUS DAT_DTO_COMPLETION_STATUS + +/* Completion group structs (six total) */ + +/* DTO completion event data */ +/* transferred_length is not defined if status is not DAT_SUCCESS */ +typedef struct dat_dto_completion_event_data { + DAT_EP_HANDLE ep_handle; + DAT_DTO_COOKIE user_cookie; + DAT_DTO_COMPLETION_STATUS status; + DAT_VLEN transfered_length; +} DAT_DTO_COMPLETION_EVENT_DATA; + +/* RMR bind completion event data */ +typedef struct dat_rmr_bind_completion_event_data { + DAT_RMR_HANDLE rmr_handle; + DAT_RMR_COOKIE user_cookie; + DAT_RMR_BIND_COMPLETION_STATUS status; +} DAT_RMR_BIND_COMPLETION_EVENT_DATA; + +typedef union dat_sp_handle { + DAT_RSP_HANDLE rsp_handle; + DAT_PSP_HANDLE psp_handle; +} DAT_SP_HANDLE; + +/* Connection Request Arrival event data */ +typedef struct dat_cr_arrival_event_data { + /* + * Handle to the Service Point that received the Connection Request + * from the remote side. If the Service Point was Reserved, sp is + * DAT_HANDLE_NULL because the reserved Service Point is automatically + * destroyed upon generating this event. Can be PSP or RSP. + */ + DAT_SP_HANDLE sp_handle; + + /* Address of the IA on which the Connection Request arrived. */ + DAT_IA_ADDRESS_PTR local_ia_address_ptr; + + /* + * Connection Qualifier of the IA on which the Service Point received a + * Connection Request. + */ + DAT_CONN_QUAL conn_qual; + + /* + * The Connection Request instance created by a Provider for the + * arrived Connection Request. Consumers can find out private_data + * passed by a remote Consumer from cr_handle. It is up to a Consumer + * to dat_cr_accept or dat_cr_reject of the Connection Request. + */ + DAT_CR_HANDLE cr_handle; + +} DAT_CR_ARRIVAL_EVENT_DATA; + + +/* Connection event data */ +typedef struct dat_connection_event_data { + DAT_EP_HANDLE ep_handle; + DAT_COUNT private_data_size; + DAT_PVOID private_data; +} DAT_CONNECTION_EVENT_DATA; + +/* Async Error event data */ +/* + * For unaffiliated asynchronous event dat_handle is ia_handle. For Endpoint + * affiliated asynchronous event dat_handle is ep_handle. For EVD affiliated + * asynchronous event dat_handle is evd_handle. For SRQ affiliated asynchronous + * event dat_handle is srq_handle. For Memory affiliated asynchronous event + * dat_handle is either lmr_handle, rmr_handle or pz_handle. + */ +typedef struct dat_asynch_error_event_data { + DAT_HANDLE dat_handle; /* either IA, EP, EVD, SRQ */ + /* LMR, RMR, or PZ handle */ + DAT_COUNT reason; /* object specific */ +} DAT_ASYNCH_ERROR_EVENT_DATA; + +/* The reason is object type specific and its values are defined below */ +typedef enum ia_async_error_reason { + DAT_IA_CATASTROPHIC_ERROR, + DAT_IA_OTHER_ERROR +} DAT_IA_ASYNC_ERROR_REASON; + +typedef enum ep_async_error_reason { + DAT_EP_TRANSFER_TO_ERROR, + DAT_EP_OTHER_ERROR, + DAT_SRQ_SOFT_HIGH_WATERMARK_EVENT +} DAT_EP_ASYNC_ERROR_REASON; + +typedef enum ep_evd_error_reason { + DAT_EVD_OVERFLOW_ERROR, + DAT_EVD_OTHER_ERROR +} DAT_EVD_ASYNC_ERROR_REASON; + +typedef enum ep_srq_error_reason { + DAT_SRQ_TRANSFER_TO_ERROR, + DAT_SRQ_OTHER_ERROR, + DAT_SRQ_LOW_WATERMARK_EVENT +} DAT_SRQ_ASYNC_ERROR_REASON; + +typedef enum lmr_async_error_reason { + DAT_LMR_OTHER_ERROR +} DAT_LMR_ASYNC_ERROR_REASON; + +typedef enum rmr_async_error_reason { + DAT_RMR_OTHER_ERROR +} DAT_RMR_ASYNC_ERROR_REASON; + +typedef enum pz_async_error_reason { + DAT_PZ_OTHER_ERROR +} DAT_PZ_ASYNC_ERROR_REASON; + + +/* Software event data */ +typedef struct dat_software_event_data { + DAT_PVOID pointer; +} DAT_SOFTWARE_EVENT_DATA; + +typedef enum dat_event_number { + DAT_DTO_COMPLETION_EVENT = 0x00001, + + DAT_RMR_BIND_COMPLETION_EVENT = 0x01001, + + DAT_CONNECTION_REQUEST_EVENT = 0x02001, + + DAT_CONNECTION_EVENT_ESTABLISHED = 0x04001, + DAT_CONNECTION_EVENT_PEER_REJECTED = 0x04002, + DAT_CONNECTION_EVENT_NON_PEER_REJECTED = 0x04003, + DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR = 0x04004, + DAT_CONNECTION_EVENT_DISCONNECTED = 0x04005, + DAT_CONNECTION_EVENT_BROKEN = 0x04006, + DAT_CONNECTION_EVENT_TIMED_OUT = 0x04007, + DAT_CONNECTION_EVENT_UNREACHABLE = 0x04008, + + DAT_ASYNC_ERROR_EVD_OVERFLOW = 0x08001, + DAT_ASYNC_ERROR_IA_CATASTROPHIC = 0x08002, + DAT_ASYNC_ERROR_EP_BROKEN = 0x08003, + DAT_ASYNC_ERROR_TIMED_OUT = 0x08004, + DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR = 0x08005, + + DAT_SOFTWARE_EVENT = 0x10001 +} DAT_EVENT_NUMBER; + +/* Union for event Data */ + +typedef union dat_event_data { + DAT_DTO_COMPLETION_EVENT_DATA dto_completion_event_data; + DAT_RMR_BIND_COMPLETION_EVENT_DATA rmr_completion_event_data; + DAT_CR_ARRIVAL_EVENT_DATA cr_arrival_event_data; + DAT_CONNECTION_EVENT_DATA connect_event_data; + DAT_ASYNCH_ERROR_EVENT_DATA asynch_error_event_data; + DAT_SOFTWARE_EVENT_DATA software_event_data; +} DAT_EVENT_DATA; + +/* Event struct that holds all event information */ + +typedef struct dat_event { + DAT_EVENT_NUMBER event_number; + DAT_EVD_HANDLE evd_handle; + DAT_EVENT_DATA event_data; +} DAT_EVENT; + +/* Provider/registration info */ + +typedef struct dat_provider_info { + char ia_name[DAT_NAME_MAX_LENGTH]; + DAT_UINT32 dapl_version_major; + DAT_UINT32 dapl_version_minor; + DAT_BOOLEAN is_thread_safe; +} DAT_PROVIDER_INFO; + +/* + * FUNCTION PROTOTYPES + */ +/* + * IA functions + * + * Note that there are actual 'dat_ia_open' and 'dat_ia_close' + * functions, it is not just a re-directing #define. That is + * because the functions may have to ensure that the provider + * library is loaded before it can call it, and may choose to + * unload the library after the last close. + */ + +extern DAT_RETURN dat_ia_openv( + IN const DAT_NAME_PTR, /* provider */ + IN DAT_COUNT, /* asynch_evd_min_qlen */ + INOUT DAT_EVD_HANDLE *, /* asynch_evd_handle */ + OUT DAT_IA_HANDLE *, /* ia_handle */ + IN DAT_UINT32, /* dat major version number */ + IN DAT_UINT32, /* dat minor version number */ + IN DAT_BOOLEAN); /* dat thread safety */ + +#define dat_ia_open(name, qlen, async_evd, ia) \ + dat_ia_openv((name), (qlen), (async_evd), (ia), \ + DAT_VERSION_MAJOR, DAT_VERSION_MINOR, \ + DAT_THREADSAFE) + +extern DAT_RETURN dat_ia_query( + IN DAT_IA_HANDLE, /* ia handle */ + OUT DAT_EVD_HANDLE *, /* async_evd_handle */ + IN DAT_IA_ATTR_MASK, /* ia_attr_mask */ + OUT DAT_IA_ATTR *, /* ia_attr */ + IN DAT_PROVIDER_ATTR_MASK, /* provider_attr_mask */ + OUT DAT_PROVIDER_ATTR *); /* provider_attr */ + +extern DAT_RETURN dat_ia_close( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_CLOSE_FLAGS); /* close_flags */ + +/* helper functions */ + +extern DAT_RETURN dat_set_consumer_context( + IN DAT_HANDLE, /* dat handle */ + IN DAT_CONTEXT); /* context */ + +extern DAT_RETURN dat_get_consumer_context( + IN DAT_HANDLE, /* dat handle */ + OUT DAT_CONTEXT *); /* context */ + +extern DAT_RETURN dat_get_handle_type( + IN DAT_HANDLE, /* dat_handle */ + OUT DAT_HANDLE_TYPE *); /* handle_type */ + +/* CR Functions */ + +extern DAT_RETURN dat_cr_query( + IN DAT_CR_HANDLE, /* cr_handle */ + IN DAT_CR_PARAM_MASK, /* cr_param_mask */ + OUT DAT_CR_PARAM *); /* cr_param */ + +extern DAT_RETURN dat_cr_accept( + IN DAT_CR_HANDLE, /* cr_handle */ + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* private_data_size */ + IN const DAT_PVOID); /* private_data */ + +extern DAT_RETURN dat_cr_reject( + IN DAT_CR_HANDLE); + +/* + * For DAT-1.1 and above, this function is defined for both uDAPL and kDAPL. + * For DAT-1.0 it was only defined for uDAPL. + */ +extern DAT_RETURN dat_cr_handoff( + IN DAT_CR_HANDLE, /* cr_handle */ + IN DAT_CONN_QUAL); /* handoff */ + +/* EVD Functions */ + +extern DAT_RETURN dat_evd_resize( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_COUNT); /* evd_min_qlen */ + +extern DAT_RETURN dat_evd_post_se( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN const DAT_EVENT *); /* event */ + +extern DAT_RETURN dat_evd_dequeue( + IN DAT_EVD_HANDLE, /* evd_handle */ + OUT DAT_EVENT *); /* event */ + +extern DAT_RETURN dat_evd_query( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_EVD_PARAM_MASK, /* evd_param_mask */ + OUT DAT_EVD_PARAM *); /* evd_param */ + +extern DAT_RETURN dat_evd_free( + IN DAT_EVD_HANDLE); /* evd_handle */ + +/* EP functions */ + +extern DAT_RETURN dat_ep_create( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_EVD_HANDLE, /* recv_completion_evd_handle */ + IN DAT_EVD_HANDLE, /* request_completion_evd_handle */ + IN DAT_EVD_HANDLE, /* connect_evd_handle */ + IN const DAT_EP_ATTR *, /* ep_attributes */ + OUT DAT_EP_HANDLE *); /* ep_handle */ + +extern DAT_RETURN dat_ep_query( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_EP_PARAM_MASK, /* ep_param_mask */ + OUT DAT_EP_PARAM *); /* ep_param */ + +extern DAT_RETURN dat_ep_modify( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_EP_PARAM_MASK, /* ep_param_mask */ + IN const DAT_EP_PARAM *); /* ep_param */ + +extern DAT_RETURN dat_ep_connect( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_IA_ADDRESS_PTR, /* remote_ia_address */ + IN DAT_CONN_QUAL, /* remote_conn_qual */ + IN DAT_TIMEOUT, /* timeout */ + IN DAT_COUNT, /* private_data_size */ + IN const DAT_PVOID, /* private_data */ + IN DAT_QOS, /* quality_of_service */ + IN DAT_CONNECT_FLAGS); /* connect_flags */ + +extern DAT_RETURN dat_ep_dup_connect( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_EP_HANDLE, /* ep_dup_handle */ + IN DAT_TIMEOUT, /* timeout */ + IN DAT_COUNT, /* private_data_size */ + IN const DAT_PVOID, /* private_data */ + IN DAT_QOS); /* quality_of_service */ + +extern DAT_RETURN dat_ep_disconnect( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_CLOSE_FLAGS); /* close_flags */ + +extern DAT_RETURN dat_ep_post_send( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE, /* user_cookie */ + IN DAT_COMPLETION_FLAGS); /* completion_flags */ + +extern DAT_RETURN dat_ep_post_recv( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE, /* user_cookie */ + IN DAT_COMPLETION_FLAGS); /* completion_flags */ + +extern DAT_RETURN dat_ep_post_rdma_read( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE, /* user_cookie */ + IN const DAT_RMR_TRIPLET *, /* remote_iov */ + IN DAT_COMPLETION_FLAGS); /* completion_flags */ + +extern DAT_RETURN dat_ep_post_rdma_write( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE, /* user_cookie */ + IN const DAT_RMR_TRIPLET *, /* remote_iov */ + IN DAT_COMPLETION_FLAGS); /* completion_flags */ + +extern DAT_RETURN dat_ep_get_status( + IN DAT_EP_HANDLE, /* ep_handle */ + OUT DAT_EP_STATE *, /* ep_state */ + OUT DAT_BOOLEAN *, /* recv_idle */ + OUT DAT_BOOLEAN *); /* request_idle */ + +extern DAT_RETURN dat_ep_free( + IN DAT_EP_HANDLE); /* ep_handle */ + +extern DAT_RETURN dat_ep_reset( + IN DAT_EP_HANDLE); /* ep_handle */ + +/* LMR functions */ + +extern DAT_RETURN dat_lmr_query( + IN DAT_LMR_HANDLE, /* lmr_handle */ + IN DAT_LMR_PARAM_MASK, /* lmr_param_mask */ + OUT DAT_LMR_PARAM *); /* lmr_param */ + +extern DAT_RETURN dat_lmr_free( + IN DAT_LMR_HANDLE); /* lmr_handle */ + +/* Non-coherent memory functions */ + +extern DAT_RETURN dat_lmr_sync_rdma_read( + IN DAT_IA_HANDLE, /* ia_handle */ + IN const DAT_LMR_TRIPLET *, /* local_segments */ + IN DAT_VLEN); /* num_segments */ + +extern DAT_RETURN dat_lmr_sync_rdma_write( + IN DAT_IA_HANDLE, /* ia_handle */ + IN const DAT_LMR_TRIPLET *, /* local_segments */ + IN DAT_VLEN); /* num_segments */ + +/* RMR Functions */ + +extern DAT_RETURN dat_rmr_create( + IN DAT_PZ_HANDLE, /* pz_handle */ + OUT DAT_RMR_HANDLE *); /* rmr_handle */ + +extern DAT_RETURN dat_rmr_query( + IN DAT_RMR_HANDLE, /* rmr_handle */ + IN DAT_RMR_PARAM_MASK, /* rmr_param_mask */ + OUT DAT_RMR_PARAM *); /* rmr_param */ + +extern DAT_RETURN dat_rmr_bind( + IN DAT_RMR_HANDLE, /* rmr_handle */ + IN const DAT_LMR_TRIPLET *, /* lmr_triplet */ + IN DAT_MEM_PRIV_FLAGS, /* mem_priv */ + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_RMR_COOKIE, /* user_cookie */ + IN DAT_COMPLETION_FLAGS, /* completion_flags */ + OUT DAT_RMR_CONTEXT *); /* context */ + +extern DAT_RETURN dat_rmr_free( + IN DAT_RMR_HANDLE); /* rmr_handle */ + +/* PSP Functions */ + +extern DAT_RETURN dat_psp_create( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_CONN_QUAL, /* conn_qual */ + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_PSP_FLAGS, /* psp_flags */ + OUT DAT_PSP_HANDLE *); /* psp_handle */ + +extern DAT_RETURN dat_psp_create_any( + IN DAT_IA_HANDLE, /* ia_handle */ + OUT DAT_CONN_QUAL *, /* conn_qual */ + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_PSP_FLAGS, /* psp_flags */ + OUT DAT_PSP_HANDLE *); /* psp_handle */ + +extern DAT_RETURN dat_psp_query( + IN DAT_PSP_HANDLE, /* psp_handle */ + IN DAT_PSP_PARAM_MASK, /* psp_param_mask */ + OUT DAT_PSP_PARAM *); /* psp_param */ + +extern DAT_RETURN dat_psp_free( + IN DAT_PSP_HANDLE); /* psp_handle */ + +/* RSP Functions */ + +extern DAT_RETURN dat_rsp_create( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_CONN_QUAL, /* conn_qual */ + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_EVD_HANDLE, /* evd_handle */ + OUT DAT_RSP_HANDLE *); /* rsp_handle */ + +extern DAT_RETURN dat_rsp_query( + IN DAT_RSP_HANDLE, /* rsp_handle */ + IN DAT_RSP_PARAM_MASK, /* rsp_param_mask */ + OUT DAT_RSP_PARAM *); /* rsp_param */ + +extern DAT_RETURN dat_rsp_free( + IN DAT_RSP_HANDLE); /* rsp_handle */ + +/* PZ Functions */ + +extern DAT_RETURN dat_pz_create( + IN DAT_IA_HANDLE, /* ia_handle */ + OUT DAT_PZ_HANDLE *); /* pz_handle */ + +extern DAT_RETURN dat_pz_query( + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_PZ_PARAM_MASK, /* pz_param_mask */ + OUT DAT_PZ_PARAM *); /* pz_param */ + +extern DAT_RETURN dat_pz_free( + IN DAT_PZ_HANDLE); /* pz_handle */ + +/* + * SRQ functions + */ +extern DAT_RETURN dat_ep_create_with_srq( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_EVD_HANDLE, /* recv_evd_handle */ + IN DAT_EVD_HANDLE, /* request_evd_handle */ + IN DAT_EVD_HANDLE, /* connect_evd_handle */ + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN const DAT_EP_ATTR *, /* ep_attributes */ + OUT DAT_EP_HANDLE *); /* ep_handle */ + +extern DAT_RETURN dat_ep_recv_query( + IN DAT_EP_HANDLE, /* ep_handle */ + OUT DAT_COUNT *, /* nbufs_allocated */ + OUT DAT_COUNT *); /* bufs_alloc_span */ + +extern DAT_RETURN dat_ep_set_watermark( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* soft_high_watermark */ + IN DAT_COUNT); /* hard_high_watermark */ + +extern DAT_RETURN dat_srq_create( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_SRQ_ATTR *, /* srq_attr */ + OUT DAT_SRQ_HANDLE *); /* srq_handle */ + +extern DAT_RETURN dat_srq_free( + IN DAT_SRQ_HANDLE); /* srq_handle */ + +extern DAT_RETURN dat_srq_post_recv( + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE); /* user_cookie */ + +extern DAT_RETURN dat_srq_query( + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN DAT_SRQ_PARAM_MASK, /* srq_param_mask */ + OUT DAT_SRQ_PARAM *); /* srq_param */ + +extern DAT_RETURN dat_srq_resize( + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN DAT_COUNT); /* srq_max_recv_dto */ + +extern DAT_RETURN dat_srq_set_lw( + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN DAT_COUNT); /* low_watermark */ + +/* + * DAT registry functions. + * + * Note the dat_ia_open and dat_ia_close functions are linked to + * registration code which "redirects" to the appropriate provider. + */ +extern DAT_RETURN dat_registry_list_providers( + IN DAT_COUNT, /* max_to_return */ + OUT DAT_COUNT *, /* entries_returned */ + /* dat_provider_list */ + OUT DAT_PROVIDER_INFO *(dat_provider_list[])); +/* + * DAT error functions. + */ +extern DAT_RETURN dat_strerror( + IN DAT_RETURN, /* dat function return */ + OUT const char **, /* major message string */ + OUT const char **); /* minor message string */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _DAT_H_ */ diff --git a/illumos-x86_64/usr/include/dat/dat_error.h b/illumos-x86_64/usr/include/dat/dat_error.h new file mode 100644 index 00000000..4746c201 --- /dev/null +++ b/illumos-x86_64/usr/include/dat/dat_error.h @@ -0,0 +1,388 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DAT_ERROR_H_ +#define _DAT_ERROR_H_ + +/* + * + * HEADER: dat_error.h + * + * PURPOSE: DAT return codes + * + * Description: Header file for "uDAPL: User Direct Access Programming + * Library, Version: 1.2" + * + * Mapping rules: + * Error types are compound types, as mapped out below. + * + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * All return codes are actually a 3-way tuple: + * + * type: DAT_RETURN_CLASS DAT_RETURN_TYPE DAT_RETURN_SUBTYPE + * bits: 31-30 29-16 15-0 + * + * +----------------------------------------------------------------------+ + * |3130 | 29282726252423222120191817 | 1615141312111009080706054003020100| + * |CLAS | DAT_TYPE_STATUS | SUBTYPE_STATUS | + * +----------------------------------------------------------------------+ + */ + +/* + * Class Bits + */ +#define DAT_CLASS_ERROR 0x80000000 +#define DAT_CLASS_WARNING 0x40000000 +#define DAT_CLASS_SUCCESS 0x00000000 + +/* + * DAT Error bits + */ +#define DAT_TYPE_MASK 0x3fff0000 /* mask for DAT_TYPE_STATUS bits */ +#define DAT_SUBTYPE_MASK 0x0000FFFF /* mask for DAT_SUBTYPE_STATUS bits */ + +/* + * Determining the success of an operation is best done with a macro; + * each of these returns a boolean value. + */ +#define DAT_IS_WARNING(status) ((DAT_UINT32)(status) & DAT_CLASS_WARNING) + +#define DAT_GET_TYPE(status) ((DAT_UINT32)(status) & DAT_TYPE_MASK) +#define DAT_GET_SUBTYPE(status) ((DAT_UINT32)(status) & DAT_SUBTYPE_MASK) + +/* + * DAT return types. The ERROR bit is enabled for these definitions + */ +typedef enum dat_return_type +{ + /* The operation was successful. */ + DAT_SUCCESS = 0x000000, + + /* + * The operation was aborted because IA was closed or EVD was + * destroyed. + */ + DAT_ABORT = 0x00010000, + + /* The specified Connection Qualifier was in use. */ + DAT_CONN_QUAL_IN_USE = 0x00020000, + + /* The operation failed due to resource limitations. */ + DAT_INSUFFICIENT_RESOURCES = 0x00030000, + + /* + * Provider internal error. This error can be returned by any + * operation when the Provider have detected an internal error. + * This error does no mask any error causes by Consumer. + */ + DAT_INTERNAL_ERROR = 0x00040000, + + /* One of the DAT handles was invalid. */ + DAT_INVALID_HANDLE = 0x00050000, + + /* One of the parameters was invalid. */ + DAT_INVALID_PARAMETER = 0x00060000, + + /* + * One of the parameters was invalid for this operation. There + * are Event Streams associated with the Event Dispatcher feeding + * it. + */ + DAT_INVALID_STATE = 0x00070000, + + /* + * The size of the receiving buffer is too small for sending + * buffer data. The size of the local buffer is too small for + * the data of the remote buffer. + */ + DAT_LENGTH_ERROR = 0x00080000, + + /* The requested Model was not supported by the Provider. */ + DAT_MODEL_NOT_SUPPORTED = 0x00090000, + + /* + * The provider name or specified attributes are not found in + * the registry. + */ + + DAT_PROVIDER_NOT_FOUND = 0x000A0000, + + /* + * Protection violation for local or remote memory + * access. Protection Zone mismatch between an LMR of one of the + * local_iov segments and the local Endpoint. + */ + DAT_PRIVILEGES_VIOLATION = 0x000B0000, + + /* + * Privileges violation for local or re-mote memory access. One + * of the LMRs used in local_iov was either invalid or did not + * have the local read privileges. + */ + DAT_PROTECTION_VIOLATION = 0x000C0000, + + /* The operation timed out without a notification. */ + DAT_QUEUE_EMPTY = 0x000D0000, + + /* The Event Dispatcher queue is full. */ + DAT_QUEUE_FULL = 0x000E0000, + + /* The operation timed out. UDAPL ONLY */ + DAT_TIMEOUT_EXPIRED = 0x000F0000, + + /* The provider name was already registered */ + DAT_PROVIDER_ALREADY_REGISTERED = 0x00100000, + + /* The provider is "in-use" and cannot be closed at this time */ + DAT_PROVIDER_IN_USE = 0x00110000, + + /* The requested remote address is not valid or not reachable */ + DAT_INVALID_ADDRESS = 0x00120000, + + /* [Unix only] dat_evd_wait or dat_cno_wait has been interrupted. */ + DAT_INTERRUPTED_CALL = 0x00130000, + + /* No Connection Qualifiers are available */ + DAT_CONN_QUAL_UNAVAILABLE = 0x00140000, + + /* Provider does not support the operation yet. */ + DAT_NOT_IMPLEMENTED = 0x0FFF0000 + +} DAT_RETURN_TYPE; + +typedef DAT_UINT32 DAT_RETURN; + +/* Backwared compatibility with DAT 1.0 */ +#define DAT_NAME_NOT_FOUND DAT_PROVIDER_NOT_FOUND + +/* + * DAT_RETURN_SUBTYPE listing + */ + +typedef enum dat_return_subtype +{ + /* First element is no subtype */ + DAT_NO_SUBTYPE, + /* ABORT sub types */ + /* call was interrupted by a signal, or otherwise */ + DAT_SUB_INTERRUPTED, + + /* DAT_CONN_QUAL_IN_USE has no subtypes */ + + /* INSUFFICIENT_RESOURCES subtypes */ + DAT_RESOURCE_MEMORY, + DAT_RESOURCE_DEVICE, + DAT_RESOURCE_TEP, /* transport endpoint, e.g. QP */ + DAT_RESOURCE_TEVD, /* transport EVD, e.g. CQ */ + DAT_RESOURCE_PROTECTION_DOMAIN, + DAT_RESOURCE_MEMORY_REGION, /* HCA memory for LMR or RMR */ + DAT_RESOURCE_ERROR_HANDLER, + DAT_RESOURCE_CREDITS, /* e.g outstanding RDMA Read credit as target */ + DAT_RESOURCE_SRQ, + + /* DAT_INTERNAL_ERROR has no subtypes */ + + /* INVALID_HANDLE subtypes */ + DAT_INVALID_HANDLE_IA, + DAT_INVALID_HANDLE_EP, + DAT_INVALID_HANDLE_LMR, + DAT_INVALID_HANDLE_RMR, + DAT_INVALID_HANDLE_PZ, + DAT_INVALID_HANDLE_PSP, + DAT_INVALID_HANDLE_RSP, + DAT_INVALID_HANDLE_CR, + DAT_INVALID_HANDLE_CNO, + DAT_INVALID_HANDLE_EVD_CR, + DAT_INVALID_HANDLE_EVD_REQUEST, + DAT_INVALID_HANDLE_EVD_RECV, + DAT_INVALID_HANDLE_EVD_CONN, + DAT_INVALID_HANDLE_EVD_ASYNC, + DAT_INVALID_HANDLE_SRQ, + DAT_INVALID_HANDLE1, + DAT_INVALID_HANDLE2, + DAT_INVALID_HANDLE3, + DAT_INVALID_HANDLE4, + DAT_INVALID_HANDLE5, + DAT_INVALID_HANDLE6, + DAT_INVALID_HANDLE7, + DAT_INVALID_HANDLE8, + DAT_INVALID_HANDLE9, + DAT_INVALID_HANDLE10, + + /* DAT_INVALID_PARAMETER subtypes */ + DAT_INVALID_ARG1, + DAT_INVALID_ARG2, + DAT_INVALID_ARG3, + DAT_INVALID_ARG4, + DAT_INVALID_ARG5, + DAT_INVALID_ARG6, + DAT_INVALID_ARG7, + DAT_INVALID_ARG8, + DAT_INVALID_ARG9, + DAT_INVALID_ARG10, + + /* DAT_INVALID_EP_STATE subtypes */ + DAT_INVALID_STATE_EP_UNCONNECTED, + DAT_INVALID_STATE_EP_ACTCONNPENDING, + DAT_INVALID_STATE_EP_PASSCONNPENDING, + DAT_INVALID_STATE_EP_TENTCONNPENDING, + DAT_INVALID_STATE_EP_CONNECTED, + DAT_INVALID_STATE_EP_DISCONNECTED, + DAT_INVALID_STATE_EP_RESERVED, + DAT_INVALID_STATE_EP_COMPLPENDING, + DAT_INVALID_STATE_EP_DISCPENDING, + DAT_INVALID_STATE_EP_PROVIDERCONTROL, + DAT_INVALID_STATE_EP_NOTREADY, + DAT_INVALID_STATE_EP_RECV_WATERMARK, + DAT_INVALID_STATE_EP_PZ, + DAT_INVALID_STATE_EP_EVD_REQUEST, + DAT_INVALID_STATE_EP_EVD_RECV, + DAT_INVALID_STATE_EP_EVD_CONNECT, + DAT_INVALID_STATE_EP_UNCONFIGURED, + DAT_INVALID_STATE_EP_UNCONFRESERVED, + DAT_INVALID_STATE_EP_UNCONFPASSIVE, + DAT_INVALID_STATE_EP_UNCONFTENTATIVE, + + DAT_INVALID_STATE_CNO_IN_USE, + DAT_INVALID_STATE_CNO_DEAD, + + /* + * EVD states. Enabled/Disabled, Waitable/Unwaitable, + * and Notify/Solicited/Threshold are 3 orthogonal + * bands of EVD state.The Threshold one is uDAPL specific. + */ + DAT_INVALID_STATE_EVD_OPEN, + /* + * EVD can be either in enabled or disabled but not both + * or neither at the same time + */ + DAT_INVALID_STATE_EVD_ENABLED, + DAT_INVALID_STATE_EVD_DISABLED, + /* + * EVD can be either in waitable or unwaitable but not + * both or neither at the same time + */ + DAT_INVALID_STATE_EVD_WAITABLE, + DAT_INVALID_STATE_EVD_UNWAITABLE, + /* Do not release an EVD if it is in use */ + DAT_INVALID_STATE_EVD_IN_USE, + + /* + * EVD can be either in notify or solicited or threshold + * but not any pair, or all, or none at the same time. + * The threshold one is for uDAPL only + */ + DAT_INVALID_STATE_EVD_CONFIG_NOTIFY, + DAT_INVALID_STATE_EVD_CONFIG_SOLICITED, + DAT_INVALID_STATE_EVD_CONFIG_THRESHOLD, + DAT_INVALID_STATE_EVD_WAITER, + DAT_INVALID_STATE_EVD_ASYNC, /* Async EVD required */ + DAT_INVALID_STATE_IA_IN_USE, + DAT_INVALID_STATE_LMR_IN_USE, + DAT_INVALID_STATE_LMR_FREE, + DAT_INVALID_STATE_PZ_IN_USE, + DAT_INVALID_STATE_PZ_FREE, + + /* DAT_INVALID_STATE_SRQ subtypes */ + DAT_INVALID_STATE_SRQ_OPERATIONAL, + DAT_INVALID_STATE_SRQ_ERROR, + DAT_INVALID_STATE_SRQ_IN_USE, + + /* DAT_LENGTH_ERROR has no subtypes */ + /* DAT_MODEL_NOT_SUPPORTED has no subtypes */ + + /* DAT_PRIVILEGES_VIOLATION subtypes */ + DAT_PRIVILEGES_READ, + DAT_PRIVILEGES_WRITE, + DAT_PRIVILEGES_RDMA_READ, + DAT_PRIVILEGES_RDMA_WRITE, + + /* DAT_PROTECTION_VIOLATION subtypes */ + DAT_PROTECTION_READ, + DAT_PROTECTION_WRITE, + DAT_PROTECTION_RDMA_READ, + DAT_PROTECTION_RDMA_WRITE, + + /* DAT_QUEUE_EMPTY has no subtypes */ + /* DAT_QUEUE_FULL has no subtypes */ + /* DAT_TIMEOUT_EXPIRED has no subtypes */ + /* DAT_PROVIDER_ALREADY_REGISTERED has no subtypes */ + /* DAT_PROVIDER_IN_USE has no subtypes */ + + /* DAT_INVALID_ADDRESS subtypes */ + /* + * Unsupported addresses - those that are not Malformed, + * but are incorrect for use in DAT (regardless of local + * routing capabilities): IPv6 Multicast Addresses (ff/8) + * IPv4 Broadcast/Multicast Addresses + */ + DAT_INVALID_ADDRESS_UNSUPPORTED, + /* + * Unreachable addresses - A Provider may know that certain + * addresses are unreachable immediately. One examples would + * be an IPv6 addresses on an IPv4-only system. This may also + * be returned if it is known that there is no route to the + * host. A Provider is not obligated to check for this + * condition. + */ + DAT_INVALID_ADDRESS_UNREACHABLE, + /* + * Malformed addresses -- these cannot be valid in any context. + * Those listed in RFC1884 section 2.3 as "Reserved" or + * "Unassigned". + */ + DAT_INVALID_ADDRESS_MALFORMED, + + /* DAT_INTERRUPTED_CALL has no subtypes */ + /* DAT_CONN_QUAL_UNAVAILABLE has no subtypes */ + + /* DAT_PROVIDER_NOT_FOUND subtypes. Erratta to the 1.1 spec */ + DAT_NAME_NOT_REGISTERED, + DAT_MAJOR_NOT_FOUND, + DAT_MINOR_NOT_FOUND, + DAT_THREAD_SAFETY_NOT_FOUND, + + /* DAT_INVALID_PARAMETER Sun specific */ + DAT_INVALID_RO_COOKIE + +} DAT_RETURN_SUBTYPE; + +#ifdef __cplusplus +} +#endif + +#endif /* _DAT_ERROR_H_ */ diff --git a/illumos-x86_64/usr/include/dat/dat_platform_specific.h b/illumos-x86_64/usr/include/dat/dat_platform_specific.h new file mode 100644 index 00000000..8d4cb014 --- /dev/null +++ b/illumos-x86_64/usr/include/dat/dat_platform_specific.h @@ -0,0 +1,209 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DAT_PLATFORM_SPECIFIC_H_ +#define _DAT_PLATFORM_SPECIFIC_H_ + +/* + * + * HEADER: dat_platform_specific.h + * + * PURPOSE: defines Platform specific types. + * + * Description: Header file for "uDAPL: User Direct Access Programming + * Library, Version: 1.2" + * + * Mapping rules: + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* OS, processor, compiler type definitions. Add OS's as needed. */ + +/* + * This captures the alignment for the bus transfer from the HCA/IB chip + * to the main memory. + */ +#ifndef DAT_OPTIMAL_ALIGNMENT +#define DAT_OPTIMAL_ALIGNMENT 256 /* Performance optimal alignment */ +#endif /* DAT_OPTIMAL_ALIGNMENT */ + +/* + * Assume all O/Ss use sockaddr, for address family: IPv4 == AF_INET, + * IPv6 == AF_INET6. Use of "namelen" field indicated. + * + * The Interface Adaptor Address names an Interface Adaptor local or + * remote, that is used for connection management and Name + * Service. The format of the dat_ia_address_ptr follows the normal + * socket programming practice of struct sockaddr *. DAT supports both + * IPv4 and IPv6 address families. Allocation and initialization of + * DAT IA address structures must follow normal Sockets programming + * procedures. The underlying type of the DAT IA address is the native + * struct sockaddr for each target operating system. In all cases, + * storage appropriate for the address family in use by the target + * Provider must be allocated. For instance, when IPv6 addressing is + * in use, this should be allocated as struct sockaddr_net6. The + * sockaddr sa_family and, if present, sa_len fields must be + * initialized appropriately, as well as the address information. + * When passed across the DAPL API this storage is cast to the + * DAT_IA_ADDRESS_PTR type. It is the responsibility of the callee to + * verify that the sockaddr contains valid data for the requested + * operation. It is always the responsibility of the caller to manage + * the storage. + * + * Code example for Linux: + * + * #include + * #include + * #include + * #include + * + * struct sockaddr_in6 addr; + * DAT_IA_ADDRESS_PTR ia_addr; + * + * // Note: linux pton requires explicit encoding of IPv4 in IPv6 + * + * addr.sin6_family = AF_INET6; + * if (inet_pton(AF_INET6, "0:0:0:0:0:FFFF:192.168.0.1", + * &addr.sin6_addr) <= 0) + * return(-1); // Bad address or no address family support + * + * // initialize other necessary fields such as port, flow, etc + * + * ia_addr = (DAT_IA_ADDRESS_PTR) &addr; + * dat_ep_connect(ep_handle, ia_addr, conn_qual, timeout, 0, NULL, + * qos, DAT_CONNECT_DEFAULT_FLAG); + * + */ + +#if defined(sun) || defined(__sun) || defined(_sun_) || defined(__solaris__) +/* Solaris begins */ + +#include +#include /* needed for UINT64_C() macro */ + +typedef uint32_t DAT_UINT32; /* Unsigned host order, 32 bits */ +typedef uint64_t DAT_UINT64; /* Unsigned host order, 64 bits */ +typedef unsigned long long DAT_UVERYLONG; /* Unsigned longest native */ + /* to compiler */ + +typedef void *DAT_PVOID; +typedef int DAT_COUNT; + +#include +#include +typedef struct sockaddr DAT_SOCK_ADDR; /* Socket address header */ + /* native to OS */ +typedef struct sockaddr_in6 DAT_SOCK_ADDR6; /* Socket address header */ + /* native to OS */ + +#define DAT_AF_INET AF_INET +#define DAT_AF_INET6 AF_INET6 + +typedef DAT_UINT64 DAT_PADDR; + +/* Solaris ends */ + +#elif defined(__linux__) /* Linux */ +/* Linux begins */ + +#include + +typedef u_int32_t DAT_UINT32; /* unsigned host order, 32 bits */ +typedef u_int64_t DAT_UINT64; /* unsigned host order, 64 bits */ +typedef unsigned long long DAT_UVERYLONG; /* unsigned longest native */ + /* to compiler */ + +typedef void *DAT_PVOID; +typedef int DAT_COUNT; +typedef DAT_UINT64 DAT_PADDR; + +#ifndef UINT64_C +#define UINT64_C(c) c ## ULL +#endif /* UINT64_C */ + +#include +typedef struct sockaddr DAT_SOCK_ADDR; /* Socket address header */ + /* native to OS */ +typedef struct sockaddr_in6 DAT_SOCK_ADDR6; /* Socket address header */ + /* native to OS */ + +#define DAT_AF_INET AF_INET +#define DAT_AF_INET6 AF_INET6 + +/* Linux ends */ + +#elif defined(_MSC_VER) || defined(_WIN32) +/* NT. MSC compiler, Win32 platform */ +/* Win32 begins */ + +typedef unsigned __int32 DAT_UINT32; /* Unsigned host order, 32 bits */ +typedef unsigned __int64 DAT_UINT64; /* Unsigned host order, 64 bits */ +typedef unsigned long DAT_UVERYLONG; /* Unsigned longest native to */ + /* compiler */ + +typedef void *DAT_PVOID; +typedef long DAT_COUNT; + +typedef struct sockaddr DAT_SOCK_ADDR; /* Socket address header */ + /* native to OS */ +typedef struct sockaddr_in6 DAT_SOCK_ADDR6; /* Socket address header */ + /* native to OS */ +#ifndef UINT64_C +#define UINT64_C(c) c ## i64 +#endif /* UINT64_C */ + +#define DAT_AF_INET AF_INET +#define DAT_AF_INET6 AF_INET6 + +/* Win32 ends */ + +#else +#error dat_platform_specific.h : OS type not defined +#endif + +#ifndef IN +#define IN +#endif +#ifndef OUT +#define OUT +#endif +#ifndef INOUT +#define INOUT +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _DAT_PLATFORM_SPECIFIC_H_ */ diff --git a/illumos-x86_64/usr/include/dat/dat_redirection.h b/illumos-x86_64/usr/include/dat/dat_redirection.h new file mode 100644 index 00000000..938833c3 --- /dev/null +++ b/illumos-x86_64/usr/include/dat/dat_redirection.h @@ -0,0 +1,735 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _DAT_REDIRECTION_H_ +#define _DAT_REDIRECTION_H_ + +/* + * + * HEADER: dat_redirection.h + * + * PURPOSE: Defines the common redirection macros + * + * Description: Macros to invoke DAPL functions from the dat_registry + * + * Mapping rules: + * All global symbols are prepended with "DAT_" or "dat_" + * All DAT objects have an 'api' tag which, such as 'ep' or 'lmr' + * The method table is in the provider definition structure. + * + * + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct dat_provider DAT_PROVIDER; + +#ifndef DAT_HANDLE_TO_PROVIDER + +/* + * A utility macro to fetch the Provider Library for any object + * + * An alternate version could be defined for single library systems. + * it would look something like: + * extern const struct dat_ia my_single_ia_provider; + * #define DAT_HANDLE_TO_PROVIDER(ignore) &my_single_ia_provider + * + * This would allow a good compiler to avoid indirection overhead when + * making function calls. + */ + +#define DAT_HANDLE_TO_PROVIDER(handle) (*(DAT_PROVIDER **)(handle)) +#endif + +#define DAT_IA_QUERY(ia, evd, ia_msk, ia_ptr, p_msk, p_ptr) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->ia_query_func)(\ + (ia),\ + (evd),\ + (ia_msk),\ + (ia_ptr),\ + (p_msk),\ + (p_ptr)) + +#define DAT_SET_CONSUMER_CONTEXT(handle, context) \ + (*DAT_HANDLE_TO_PROVIDER(handle)->set_consumer_context_func)(\ + (handle),\ + (context)) + +#define DAT_GET_CONSUMER_CONTEXT(handle, context) \ + (*DAT_HANDLE_TO_PROVIDER(handle)->get_consumer_context_func)(\ + (handle),\ + (context)) + +#define DAT_GET_HANDLE_TYPE(handle, handle_type) \ + (*DAT_HANDLE_TO_PROVIDER(handle)->get_handle_type_func)(\ + (handle),\ + (handle_type)) + +#define DAT_CR_QUERY(cr, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(cr)->cr_query_func)(\ + (cr),\ + (mask),\ + (param)) + +#define DAT_CR_ACCEPT(cr, ep, size, pdata) \ + (*DAT_HANDLE_TO_PROVIDER(cr)->cr_accept_func)(\ + (cr),\ + (ep),\ + (size),\ + (pdata)) + +#define DAT_CR_REJECT(cr) \ + (*DAT_HANDLE_TO_PROVIDER(cr)->cr_reject_func)(\ + (cr)) + +#define DAT_CR_HANDOFF(cr, qual) \ + (*DAT_HANDLE_TO_PROVIDER(cr)->cr_handoff_func)(\ + (cr),\ + (qual)) + +#define DAT_EVD_QUERY(evd, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_query_func)(\ + (evd),\ + (mask),\ + (param)) + +#define DAT_EVD_RESIZE(evd, qsize) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_resize_func)(\ + (evd),\ + (qsize)) + +#define DAT_EVD_POST_SE(evd, event) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_post_se_func)(\ + (evd),\ + (event)) + +#define DAT_EVD_DEQUEUE(evd, event) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_dequeue_func)(\ + (evd),\ + (event)) + +#define DAT_EVD_FREE(evd)\ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_free_func)(\ + (evd)) + +#define DAT_EP_CREATE(ia, pz, in_evd, out_evd, connect_evd, attr, ep) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->ep_create_func)(\ + (ia),\ + (pz),\ + (in_evd),\ + (out_evd),\ + (connect_evd),\ + (attr),\ + (ep)) + +#define DAT_EP_CREATE_WITH_SRQ(ia, pz, in_evd, out_evd, connect_evd, srq,\ + attr, ep) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->ep_create_with_srq_func)(\ + (ia),\ + (pz),\ + (in_evd),\ + (out_evd),\ + (connect_evd),\ + (srq),\ + (attr),\ + (ep)) + +#define DAT_EP_QUERY(ep, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_query_func)(\ + (ep),\ + (mask),\ + (param)) + +#define DAT_EP_MODIFY(ep, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_modify_func)(\ + (ep),\ + (mask),\ + (param)) + +#define DAT_EP_CONNECT(ep, ia_addr, conn_qual, timeout, psize, pdata, \ + qos, flags) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_connect_func)(\ + (ep),\ + (ia_addr),\ + (conn_qual),\ + (timeout),\ + (psize),\ + (pdata),\ + (qos),\ + (flags)) + +#define DAT_EP_DUP_CONNECT(ep, dup, timeout, psize, pdata, qos) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_dup_connect_func)(\ + (ep),\ + (dup),\ + (timeout),\ + (psize),\ + (pdata),\ + (qos)) + +#define DAT_EP_DISCONNECT(ep, flags) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_disconnect_func)(\ + (ep),\ + (flags)) + +#define DAT_EP_POST_SEND(ep, size, lbuf, cookie, flags) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_post_send_func)(\ + (ep),\ + (size),\ + (lbuf),\ + (cookie),\ + (flags)) + +#define DAT_EP_POST_RECV(ep, size, lbuf, cookie, flags) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_post_recv_func)(\ + (ep),\ + (size),\ + (lbuf),\ + (cookie),\ + (flags)) + +#define DAT_EP_POST_RDMA_READ(ep, size, lbuf, cookie, rbuf, flags) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_post_rdma_read_func)(\ + (ep),\ + (size),\ + (lbuf),\ + (cookie),\ + (rbuf),\ + (flags)) + +#define DAT_EP_POST_RDMA_WRITE(ep, size, lbuf, cookie, rbuf, flags) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_post_rdma_write_func)(\ + (ep),\ + (size),\ + (lbuf),\ + (cookie),\ + (rbuf),\ + (flags)) + +#define DAT_EP_GET_STATUS(ep, ep_state, recv_idle, request_idle) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_get_status_func)(\ + (ep), \ + (ep_state),\ + (recv_idle),\ + (request_idle)) + +#define DAT_EP_FREE(ep)\ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_free_func)(\ + (ep)) + +#define DAT_EP_RESET(ep)\ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_reset_func)(\ + (ep)) + +#define DAT_EP_RECV_QUERY(ep, nbuf_alloc, buf_span) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_recv_query_func)(\ + (ep),\ + (nbuf_alloc),\ + (buf_span)) + +#define DAT_EP_SET_WATERMARK(ep, soft_wm, hard_wm) \ + (*DAT_HANDLE_TO_PROVIDER(ep)->ep_set_watermark_func)(\ + (ep),\ + (soft_wm),\ + (hard_wm)) + +#define DAT_LMR_QUERY(lmr, mask, param)\ + (*DAT_HANDLE_TO_PROVIDER(lmr)->lmr_query_func)(\ + (lmr),\ + (mask),\ + (param)) + +#define DAT_LMR_FREE(lmr)\ + (*DAT_HANDLE_TO_PROVIDER(lmr)->lmr_free_func)(\ + (lmr)) + +#define DAT_LMR_SYNC_RDMA_READ(ia, lbuf, size) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->lmr_sync_rdma_read_func)(\ + (ia), \ + (lbuf), \ + (size)) + +#define DAT_LMR_SYNC_RDMA_WRITE(ia, lbuf, size) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->lmr_sync_rdma_write_func)(\ + (ia), \ + (lbuf), \ + (size)) + +#define DAT_RMR_CREATE(pz, rmr) \ + (*DAT_HANDLE_TO_PROVIDER(pz)->rmr_create_func)(\ + (pz),\ + (rmr)) + +#define DAT_RMR_QUERY(rmr, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(rmr)->rmr_query_func)(\ + (rmr),\ + (mask),\ + (param)) + +#define DAT_RMR_BIND(rmr, lmr, mem_priv, ep, cookie, flags, context) \ + (*DAT_HANDLE_TO_PROVIDER(rmr)->rmr_bind_func)(\ + (rmr),\ + (lmr),\ + (mem_priv),\ + (ep),\ + (cookie),\ + (flags),\ + (context)) + +#define DAT_RMR_FREE(rmr)\ + (*DAT_HANDLE_TO_PROVIDER(rmr)->rmr_free_func)(\ + (rmr)) + +#define DAT_PSP_CREATE(ia, conn_qual, evd, flags, handle) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->psp_create_func)(\ + (ia),\ + (conn_qual),\ + (evd),\ + (flags),\ + (handle)) + +#define DAT_PSP_CREATE_ANY(ia, conn_qual, evd, flags, handle) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->psp_create_any_func)(\ + (ia), \ + (conn_qual), \ + (evd), \ + (flags), \ + (handle)) + +#define DAT_PSP_QUERY(psp, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(psp)->psp_query_func)(\ + (psp),\ + (mask),\ + (param)) + +#define DAT_PSP_FREE(psp)\ + (*DAT_HANDLE_TO_PROVIDER(psp)->psp_free_func)(\ + (psp)) + +#define DAT_RSP_CREATE(ia, conn_qual, ep, evd, handle) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->rsp_create_func)(\ + (ia),\ + (conn_qual),\ + (ep),\ + (evd),\ + (handle)) + +#define DAT_RSP_QUERY(rsp, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(rsp)->rsp_query_func)(\ + (rsp),\ + (mask),\ + (param)) + +#define DAT_RSP_FREE(rsp)\ + (*DAT_HANDLE_TO_PROVIDER(rsp)->rsp_free_func)(\ + (rsp)) + +#define DAT_PZ_CREATE(ia, pz) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->pz_create_func)(\ + (ia),\ + (pz)) + +#define DAT_PZ_QUERY(pz, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(pz)->pz_query_func)(\ + (pz),\ + (mask),\ + (param)) + +#define DAT_PZ_FREE(pz) \ + (*DAT_HANDLE_TO_PROVIDER(pz)->pz_free_func)(\ + (pz)) + +#define DAT_SRQ_CREATE(ia, pz, attr, srq) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->srq_create_func)(\ + (ia),\ + (pz),\ + (attr),\ + (srq)) + +#define DAT_SRQ_SET_LW(srq, lw) \ + (*DAT_HANDLE_TO_PROVIDER(srq)->srq_set_lw_func)(\ + (srq),\ + (lw)) + +#define DAT_SRQ_FREE(srq) \ + (*DAT_HANDLE_TO_PROVIDER(srq)->srq_free_func)(\ + (srq)) + +#define DAT_SRQ_QUERY(srq, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(srq)->srq_query_func)(\ + (srq),\ + (mask),\ + (param)) + +#define DAT_SRQ_RESIZE(srq, qsize) \ + (*DAT_HANDLE_TO_PROVIDER(srq)->srq_resize_func)(\ + (srq),\ + (qsize)) + +#define DAT_SRQ_POST_RECV(srq, size, lbuf, cookie) \ + (*DAT_HANDLE_TO_PROVIDER(srq)->srq_post_recv_func)(\ + (srq),\ + (size),\ + (lbuf),\ + (cookie)) + +/* + * FUNCTION PROTOTYPES + */ + +typedef DAT_RETURN (*DAT_IA_OPEN_FUNC)( + IN const DAT_NAME_PTR, /* provider */ + IN DAT_COUNT, /* asynch_evd_min_qlen */ + INOUT DAT_EVD_HANDLE *, /* asynch_evd_handle */ + OUT DAT_IA_HANDLE *, /* ia_handle */ + IN boolean_t); /* relaxed ordering aware */ + +typedef DAT_RETURN (*DAT_IA_OPENV_FUNC)( + IN const DAT_NAME_PTR, /* provider */ + IN DAT_COUNT, /* asynch_evd_min_qlen */ + INOUT DAT_EVD_HANDLE *, /* asynch_evd_handle */ + OUT DAT_IA_HANDLE *, /* ia_handle */ + IN DAT_UINT32, /* dat major version number */ + IN DAT_UINT32, /* dat minor version number */ + IN DAT_BOOLEAN); /* dat thread safety */ + +typedef DAT_RETURN (*DAT_IA_CLOSE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_CLOSE_FLAGS); /* close_flags */ + +typedef DAT_RETURN (*DAT_IA_QUERY_FUNC)( + IN DAT_IA_HANDLE, /* ia handle */ + OUT DAT_EVD_HANDLE *, /* async_evd_handle */ + IN DAT_IA_ATTR_MASK, /* ia_attr_mask */ + OUT DAT_IA_ATTR *, /* ia_attr */ + IN DAT_PROVIDER_ATTR_MASK, /* provider_attr_mask */ + OUT DAT_PROVIDER_ATTR *); /* provider_attr */ + +/* helper functions */ + +typedef DAT_RETURN (*DAT_SET_CONSUMER_CONTEXT_FUNC)( + IN DAT_HANDLE, /* dat handle */ + IN DAT_CONTEXT); /* context */ + +typedef DAT_RETURN (*DAT_GET_CONSUMER_CONTEXT_FUNC)( + IN DAT_HANDLE, /* dat handle */ + OUT DAT_CONTEXT *); /* context */ + +typedef DAT_RETURN (*DAT_GET_HANDLE_TYPE_FUNC)( + IN DAT_HANDLE, + OUT DAT_HANDLE_TYPE *); + +/* CR Functions */ + +typedef DAT_RETURN (*DAT_CR_QUERY_FUNC)( + IN DAT_CR_HANDLE, /* cr_handle */ + IN DAT_CR_PARAM_MASK, /* cr_param_mask */ + OUT DAT_CR_PARAM *); /* cr_param */ + +typedef DAT_RETURN (*DAT_CR_ACCEPT_FUNC)( + IN DAT_CR_HANDLE, /* cr_handle */ + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* private_data_size */ + IN const DAT_PVOID); /* private_data */ + +typedef DAT_RETURN (*DAT_CR_REJECT_FUNC)( + IN DAT_CR_HANDLE); + +/* + * For DAT-1.1 this function is defined for both uDAPL and kDAPL. + * For DAT-1.0 it was only defined for uDAPL. + */ +typedef DAT_RETURN (*DAT_CR_HANDOFF_FUNC)( + IN DAT_CR_HANDLE, /* cr_handle */ + IN DAT_CONN_QUAL); /* handoff */ + +/* EVD Functions */ + +typedef DAT_RETURN (*DAT_EVD_RESIZE_FUNC)( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_COUNT); /* evd_min_qlen */ + +typedef DAT_RETURN (*DAT_EVD_POST_SE_FUNC)( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN const DAT_EVENT *); /* event */ + +typedef DAT_RETURN (*DAT_EVD_DEQUEUE_FUNC)( + IN DAT_EVD_HANDLE, /* evd_handle */ + OUT DAT_EVENT *); /* event */ + +typedef DAT_RETURN (*DAT_EVD_FREE_FUNC)( + IN DAT_EVD_HANDLE); /* evd_handle */ + +typedef DAT_RETURN (*DAT_EVD_QUERY_FUNC)( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_EVD_PARAM_MASK, /* evd_param_mask */ + OUT DAT_EVD_PARAM *); /* evd_param */ + +/* EP functions */ + +typedef DAT_RETURN (*DAT_EP_CREATE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_EVD_HANDLE, /* recv_completion_evd_handle */ + IN DAT_EVD_HANDLE, /* request_completion_evd_handle */ + IN DAT_EVD_HANDLE, /* connect_evd_handle */ + IN const DAT_EP_ATTR *, /* ep_attributes */ + OUT DAT_EP_HANDLE *); /* ep_handle */ + +typedef DAT_RETURN (*DAT_EP_CREATE_WITH_SRQ_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_EVD_HANDLE, /* recv_evd_handle */ + IN DAT_EVD_HANDLE, /* request_evd_handle */ + IN DAT_EVD_HANDLE, /* connect_evd_handle */ + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN const DAT_EP_ATTR *, /* ep_attributes */ + OUT DAT_EP_HANDLE *); /* ep_handle */ + +typedef DAT_RETURN (*DAT_EP_QUERY_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_EP_PARAM_MASK, /* ep_param_mask */ + OUT DAT_EP_PARAM *); /* ep_param */ + +typedef DAT_RETURN (*DAT_EP_MODIFY_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_EP_PARAM_MASK, /* ep_param_mask */ + IN const DAT_EP_PARAM *); /* ep_param */ + +typedef DAT_RETURN (*DAT_EP_CONNECT_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_IA_ADDRESS_PTR, /* remote_ia_address */ + IN DAT_CONN_QUAL, /* remote_conn_qual */ + IN DAT_TIMEOUT, /* timeout */ + IN DAT_COUNT, /* private_data_size */ + IN const DAT_PVOID, /* private_data */ + IN DAT_QOS, /* quality_of_service */ + IN DAT_CONNECT_FLAGS); /* connect_flags */ + +typedef DAT_RETURN (*DAT_EP_DUP_CONNECT_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_EP_HANDLE, /* ep_dup_handle */ + IN DAT_TIMEOUT, /* timeout */ + IN DAT_COUNT, /* private_data_size */ + IN const DAT_PVOID, /* private_data */ + IN DAT_QOS); /* quality_of_service */ + +typedef DAT_RETURN (*DAT_EP_DISCONNECT_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_CLOSE_FLAGS); /* close_flags */ + +typedef DAT_RETURN (*DAT_EP_POST_SEND_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE, /* user_cookie */ + IN DAT_COMPLETION_FLAGS); /* completion_flags */ + +typedef DAT_RETURN (*DAT_EP_POST_RECV_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE, /* user_cookie */ + IN DAT_COMPLETION_FLAGS); /* completion_flags */ + +typedef DAT_RETURN (*DAT_EP_POST_RDMA_READ_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE, /* user_cookie */ + IN const DAT_RMR_TRIPLET *, /* remote_iov */ + IN DAT_COMPLETION_FLAGS); /* completion_flags */ + +typedef DAT_RETURN (*DAT_EP_POST_RDMA_WRITE_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE, /* user_cookie */ + IN const DAT_RMR_TRIPLET *, /* remote_iov */ + IN DAT_COMPLETION_FLAGS); /* completion_flags */ + +typedef DAT_RETURN (*DAT_EP_GET_STATUS_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + OUT DAT_EP_STATE *, /* ep_state */ + OUT DAT_BOOLEAN *, /* recv_idle */ + OUT DAT_BOOLEAN *); /* request_idle */ + +typedef DAT_RETURN (*DAT_EP_FREE_FUNC)( + IN DAT_EP_HANDLE); /* ep_handle */ + +typedef DAT_RETURN (*DAT_EP_RESET_FUNC)( + IN DAT_EP_HANDLE); /* ep_handle */ + +typedef DAT_RETURN (*DAT_EP_RECV_QUERY_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + OUT DAT_COUNT *, /* nbufs_allocated */ + OUT DAT_COUNT *); /* bufs_alloc_span */ + +typedef DAT_RETURN (*DAT_EP_SET_WATERMARK_FUNC)( + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_COUNT, /* soft_high_watermark */ + IN DAT_COUNT); /* hard_high_watermark */ + +/* LMR functions */ + +typedef DAT_RETURN (*DAT_LMR_FREE_FUNC)( + IN DAT_LMR_HANDLE); + +typedef DAT_RETURN (*DAT_LMR_QUERY_FUNC)( + IN DAT_LMR_HANDLE, /* lmr_handle */ + IN DAT_LMR_PARAM_MASK, /* lmr_param_mask */ + OUT DAT_LMR_PARAM *); /* lmr_param */ + +typedef DAT_RETURN (*DAT_LMR_SYNC_RDMA_READ_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN const DAT_LMR_TRIPLET *, /* local_segments */ + IN DAT_VLEN); /* num_segments */ + +typedef DAT_RETURN (*DAT_LMR_SYNC_RDMA_WRITE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN const DAT_LMR_TRIPLET *, /* local_segments */ + IN DAT_VLEN); /* num_segments */ + +/* RMR Functions */ + +typedef DAT_RETURN (*DAT_RMR_CREATE_FUNC)( + IN DAT_PZ_HANDLE, /* pz_handle */ + OUT DAT_RMR_HANDLE *); /* rmr_handle */ + +typedef DAT_RETURN (*DAT_RMR_QUERY_FUNC)( + IN DAT_RMR_HANDLE, /* rmr_handle */ + IN DAT_RMR_PARAM_MASK, /* rmr_param_mask */ + OUT DAT_RMR_PARAM *); /* rmr_param */ + +typedef DAT_RETURN (*DAT_RMR_BIND_FUNC)( + IN DAT_RMR_HANDLE, /* rmr_handle */ + IN const DAT_LMR_TRIPLET *, /* lmr_triplet */ + IN DAT_MEM_PRIV_FLAGS, /* mem_priv */ + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_RMR_COOKIE, /* user_cookie */ + IN DAT_COMPLETION_FLAGS, /* completion_flags */ + OUT DAT_RMR_CONTEXT *); /* context */ + +typedef DAT_RETURN (*DAT_RMR_FREE_FUNC)( + IN DAT_RMR_HANDLE); + +/* PSP Functions */ + +typedef DAT_RETURN (*DAT_PSP_CREATE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_CONN_QUAL, /* conn_qual */ + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_PSP_FLAGS, /* psp_flags */ + OUT DAT_PSP_HANDLE *); /* psp_handle */ + +typedef DAT_RETURN (*DAT_PSP_CREATE_ANY_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + OUT DAT_CONN_QUAL *, /* conn_qual */ + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_PSP_FLAGS, /* psp_flags */ + OUT DAT_PSP_HANDLE *); /* psp_handle */ + +typedef DAT_RETURN (*DAT_PSP_QUERY_FUNC)( + IN DAT_PSP_HANDLE, /* psp_handle */ + IN DAT_PSP_PARAM_MASK, /* psp_param_mask */ + OUT DAT_PSP_PARAM *); /* *psp_param */ + +typedef DAT_RETURN (*DAT_PSP_FREE_FUNC)( + IN DAT_PSP_HANDLE); /* psp_handle */ + +/* RSP Functions */ + +typedef DAT_RETURN (*DAT_RSP_CREATE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_CONN_QUAL, /* conn_qual */ + IN DAT_EP_HANDLE, /* ep_handle */ + IN DAT_EVD_HANDLE, /* evd_handle */ + OUT DAT_RSP_HANDLE *); /* rsp_handle */ + +typedef DAT_RETURN (*DAT_RSP_QUERY_FUNC) ( + IN DAT_RSP_HANDLE, /* rsp_handle */ + IN DAT_RSP_PARAM_MASK, /* rsp_param_mask */ + OUT DAT_RSP_PARAM *); /* *rsp_param */ + +typedef DAT_RETURN (*DAT_RSP_FREE_FUNC)( + IN DAT_RSP_HANDLE); /* rsp_handle */ + +/* PZ Functions */ + +typedef DAT_RETURN (*DAT_PZ_CREATE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + OUT DAT_PZ_HANDLE *); /* pz_handle */ + +typedef DAT_RETURN (*DAT_PZ_QUERY_FUNC)( + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_PZ_PARAM_MASK, /* pz_param_mask */ + OUT DAT_PZ_PARAM *); /* pz_param */ + +typedef DAT_RETURN (*DAT_PZ_FREE_FUNC)( + IN DAT_PZ_HANDLE); /* pz_handle */ + +/* SRQ Functions */ + +typedef DAT_RETURN (*DAT_SRQ_CREATE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_SRQ_ATTR *, /* srq_attr */ + OUT DAT_SRQ_HANDLE *); /* srq_handle */ + +typedef DAT_RETURN (*DAT_SRQ_SET_LW_FUNC)( + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN DAT_COUNT); /* low_watermark */ + +typedef DAT_RETURN (*DAT_SRQ_FREE_FUNC)( + IN DAT_SRQ_HANDLE); /* srq_handle */ + +typedef DAT_RETURN (*DAT_SRQ_QUERY_FUNC)( + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN DAT_SRQ_PARAM_MASK, /* srq_param_mask */ + OUT DAT_SRQ_PARAM *); /* srq_param */ + +typedef DAT_RETURN (*DAT_SRQ_RESIZE_FUNC)( + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN DAT_COUNT); /* srq_max_recv_dto */ + +typedef DAT_RETURN (*DAT_SRQ_POST_RECV_FUNC)( + IN DAT_SRQ_HANDLE, /* srq_handle */ + IN DAT_COUNT, /* num_segments */ + IN DAT_LMR_TRIPLET *, /* local_iov */ + IN DAT_DTO_COOKIE); /* user_cookie */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DAT_REDIRECTION_H_ */ diff --git a/illumos-x86_64/usr/include/dat/dat_registry.h b/illumos-x86_64/usr/include/dat/dat_registry.h new file mode 100644 index 00000000..ddd46bcc --- /dev/null +++ b/illumos-x86_64/usr/include/dat/dat_registry.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DAT_REGISTRY_H_ +#define _DAT_REGISTRY_H_ + +/* + * + * HEADER: dat_registry.h + * + * PURPOSE: DAT registration API signatures + * + * Description: Contains registration external reference signatures for + * dat registry functions. This file is *only* included by + * providers, not consumers. + * + * Header file for "uDAPL: User Direct Access Programming + * Library, Version: 1.2" + * + * Mapping rules: + * All global symbols are prepended with "DAT_" or "dat_" + * All DAT objects have an 'api' tag which, such as 'ep' or 'lmr' + * The method table is in the provider definition structure. + * + * + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_UDAT_H_) +#include +#elif defined(_KDAT_H_) +#include +#else +#error Must include udat.h or kdat.h +#endif + +/* + * dat registration API. + * + * Technically the dat_ia_open is part of the registration API. This + * is so the registration module can map the device name to a provider + * structure and then call the provider dat_ia_open function. + * dat_is_close is also part of the registration API so that the + * registration code can be aware when an ia is no longer in use. + * + */ + +extern DAT_RETURN dat_registry_add_provider( + IN DAT_PROVIDER*, /* provider */ + IN const DAT_PROVIDER_INFO*); /* provider info */ + +extern DAT_RETURN dat_registry_remove_provider( + IN DAT_PROVIDER*, /* provider */ + IN const DAT_PROVIDER_INFO*); /* provider info */ + +/* + * Provider initialization APIs. + * + * Providers that support being automatically loaded by the Registry must + * implement these APIs and export them as public symbols. + */ + +#define DAT_PROVIDER_INIT_FUNC_NAME dat_provider_init +#define DAT_PROVIDER_FINI_FUNC_NAME dat_provider_fini + +#define DAT_PROVIDER_INIT_FUNC_STR "dat_provider_init" +#define DAT_PROVIDER_FINI_FUNC_STR "dat_provider_fini" + +typedef void (*DAT_PROVIDER_INIT_FUNC)( + IN const DAT_PROVIDER_INFO *, + IN const char *); /* instance data */ + +typedef void (*DAT_PROVIDER_FINI_FUNC)( + IN const DAT_PROVIDER_INFO *); + +#ifdef __cplusplus +} +#endif + +#endif /* _DAT_REGISTRY_H_ */ diff --git a/illumos-x86_64/usr/include/dat/dat_vendor_specific.h b/illumos-x86_64/usr/include/dat/dat_vendor_specific.h new file mode 100644 index 00000000..cca49a17 --- /dev/null +++ b/illumos-x86_64/usr/include/dat/dat_vendor_specific.h @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DAT_VENDOR_SPECIFIC_H_ +#define _DAT_VENDOR_SPECIFIC_H_ + +/* + * + * HEADER: dat_vendor_specific.h + * + * PURPOSE: + * + * Description: Header file for "uDAPL: User Direct Access Programming + * Library, Version: 1.2" + * + * Mapping rules: + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Vendor Specific extensions */ + + +#if defined(_AMMASSO) + +#elif defined(_IBM) + +#elif defined(_INFINICON) + +#elif defined(_INTEL) + +#elif defined(_JNI) + +#elif defined(_MELLANOX) + +#elif defined(_MYRINET) + +#elif defined(_SILIQUENT) + +#elif defined(_TOPSPIN) + +#elif defined(_VOLTAIRE) + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _DAT_VENDOR_SPECIFIC_H_ */ diff --git a/illumos-x86_64/usr/include/dat/udat.h b/illumos-x86_64/usr/include/dat/udat.h new file mode 100644 index 00000000..978bc53b --- /dev/null +++ b/illumos-x86_64/usr/include/dat/udat.h @@ -0,0 +1,394 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _UDAT_H_ +#define _UDAT_H_ + +/* + * + * HEADER: udat.h + * + * PURPOSE: defines the user DAT API + * + * Description: Header file for "uDAPL: User Direct Access Programming + * Library, Version: 1.2" + * + * Mapping rules: + * All global symbols are prepended with "DAT_" or "dat_" + * All DAT objects have an 'api' tag which, such as 'ep' or 'lmr' + * The method table is in the provider definition structure. + * + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +typedef enum dat_mem_type +{ + /* Shared between udat and kdat */ + DAT_MEM_TYPE_VIRTUAL = 0x00, + DAT_MEM_TYPE_LMR = 0x01, + /* udat specific */ + DAT_MEM_TYPE_SHARED_VIRTUAL = 0x02, + DAT_MEM_TYPE_SO_VIRTUAL = 0x03 +} DAT_MEM_TYPE; + +/* dat handle types */ +typedef enum dat_handle_type +{ + DAT_HANDLE_TYPE_CR, + DAT_HANDLE_TYPE_EP, + DAT_HANDLE_TYPE_EVD, + DAT_HANDLE_TYPE_IA, + DAT_HANDLE_TYPE_LMR, + DAT_HANDLE_TYPE_PSP, + DAT_HANDLE_TYPE_PZ, + DAT_HANDLE_TYPE_RMR, + DAT_HANDLE_TYPE_RSP, + DAT_HANDLE_TYPE_CNO, + DAT_HANDLE_TYPE_SRQ +} DAT_HANDLE_TYPE; + +/* + * EVD state consists of 3 orthogonal substates. One for + * enabled/disabled, one for waitable/unwaitable, and one + * for configuration. Within each substates the values are + * mutually exclusive. + */ +typedef enum dat_evd_state +{ + DAT_EVD_STATE_ENABLED = 0x01, + DAT_EVD_STATE_DISABLED = 0x02, + DAT_EVD_STATE_WAITABLE = 0x04, + DAT_EVD_STATE_UNWAITABLE = 0x08, + DAT_EVD_STATE_CONFIG_NOTIFY = 0x10, + DAT_EVD_STATE_CONFIG_SOLICITED = 0x20, + DAT_EVD_STATE_CONFIG_THRESHOLD = 0x30 +} DAT_EVD_STATE; + +typedef enum dat_evd_param_mask +{ + DAT_EVD_FIELD_IA_HANDLE = 0x01, + DAT_EVD_FIELD_EVD_QLEN = 0x02, + DAT_EVD_FIELD_EVD_STATE = 0x04, + DAT_EVD_FIELD_CNO = 0x08, + DAT_EVD_FIELD_EVD_FLAGS = 0x10, + + DAT_EVD_FIELD_ALL = 0x1F +} DAT_EVD_PARAM_MASK; + +typedef DAT_UINT64 DAT_PROVIDER_ATTR_MASK; + +#include + +typedef DAT_HANDLE DAT_CNO_HANDLE; + +struct dat_evd_param +{ + DAT_IA_HANDLE ia_handle; + DAT_COUNT evd_qlen; + DAT_EVD_STATE evd_state; + DAT_CNO_HANDLE cno_handle; + DAT_EVD_FLAGS evd_flags; +}; + +#define DAT_LMR_COOKIE_SIZE 40 /* size of DAT_LMR_COOKIE in bytes */ +typedef char (* DAT_LMR_COOKIE)[DAT_LMR_COOKIE_SIZE]; + +/* Format for OS wait proxy agent function */ + +typedef void (*DAT_AGENT_FUNC)( + DAT_PVOID, /* instance data */ + DAT_EVD_HANDLE /* Event Dispatcher*/); + +/* Definition */ + +typedef struct dat_os_wait_proxy_agent +{ + DAT_PVOID instance_data; + DAT_AGENT_FUNC proxy_agent_func; +} DAT_OS_WAIT_PROXY_AGENT; + +/* Define NULL Proxy agent */ + +#define DAT_OS_WAIT_PROXY_AGENT_NULL \ + (DAT_OS_WAIT_PROXY_AGENT) { \ + (DAT_PVOID) NULL, \ + (DAT_AGENT_FUNC) NULL } + + +/* Flags */ + +/* + * The value specified by the uDAPL Consumer for dat_ia_open to indicate + * that not async EVD should be created for the opening instance of an IA. + * The same IA have been open before that has the only async EVD to + * handle async errors for all open instances of the IA. + */ + +#define DAT_EVD_ASYNC_EXISTS (DAT_EVD_HANDLE) 0x1 + +/* + * The value return by the dat_ia_query for the case when there is no + * async EVD for the IA instance. Consumer had specified the value of + * DAT_EVD_ASYNC_EXISTS for the async_evd_handle for dat_ia_open. + */ + +#define DAT_EVD_OUT_OF_SCOPE (DAT_EVD_HANDLE) 0x2 + +/* + * Memory types + * + * Specifing memory type for LMR create. A consumer must use a single + * value when registering memory. The union of any of these + * flags is used in the provider parameters to indicate what memory + * type provider supports for LMR memory creation. + */ + + + +/* For udapl only */ + +typedef struct dat_shared_memory +{ + DAT_PVOID virtual_address; + DAT_LMR_COOKIE shared_memory_id; +} DAT_SHARED_MEMORY; + +typedef union dat_region_description +{ + DAT_PVOID for_va; + DAT_LMR_HANDLE for_lmr_handle; + DAT_SHARED_MEMORY for_shared_memory; /* For udapl only */ +} DAT_REGION_DESCRIPTION; + +/* LMR Arguments */ + +struct dat_lmr_param +{ + DAT_IA_HANDLE ia_handle; + DAT_MEM_TYPE mem_type; + DAT_REGION_DESCRIPTION region_desc; + DAT_VLEN length; + DAT_PZ_HANDLE pz_handle; + DAT_MEM_PRIV_FLAGS mem_priv; + DAT_LMR_CONTEXT lmr_context; + DAT_RMR_CONTEXT rmr_context; + DAT_VLEN registered_size; + DAT_VADDR registered_address; +}; + + +typedef struct dat_cno_param +{ + DAT_IA_HANDLE ia_handle; + DAT_OS_WAIT_PROXY_AGENT agent; +} DAT_CNO_PARAM; + +typedef enum dat_cno_param_mask +{ + DAT_CNO_FIELD_IA_HANDLE = 0x1, + DAT_CNO_FIELD_AGENT = 0x2, + + DAT_CNO_FIELD_ALL = 0x3 +} DAT_CNO_PARAM_MASK; + + +/* General Provider attributes. udat specific. */ +typedef enum dat_pz_support +{ + DAT_PZ_UNIQUE, + DAT_PZ_SAME, + DAT_PZ_SHAREABLE +} DAT_PZ_SUPPORT; + +/* + * Provider should support merging of all event stream types. Provider + * attribute specify support for merging different event stream types. + * It is a 2D binary matrix where each row and column represents an event + * stream type. Each binary entry is 1 if the event streams of its raw + * and column can fed the same EVD, and 0 otherwise. The order of event + * streams in row and column is the same as in the definition of + * DAT_EVD_FLAGS: index 0 - Software Event, 1- Connection Request, + * 2 - DTO Completion, 3 - Connection event, 4 - RMR Bind Completion, + * 5 - Asynchronous event. By definition each diagonal entry is 1. + * Consumer allocates an array for it and passes it IN as a pointer + * for the array that Provider fills. Provider must fill the array + * that Consumer passes. + */ + +struct dat_provider_attr +{ + char provider_name[DAT_NAME_MAX_LENGTH]; + DAT_UINT32 provider_version_major; + DAT_UINT32 provider_version_minor; + DAT_UINT32 dapl_version_major; + DAT_UINT32 dapl_version_minor; + DAT_MEM_TYPE lmr_mem_types_supported; + DAT_IOV_OWNERSHIP iov_ownership_on_return; + DAT_QOS dat_qos_supported; + DAT_COMPLETION_FLAGS completion_flags_supported; + DAT_BOOLEAN is_thread_safe; + DAT_COUNT max_private_data_size; + DAT_BOOLEAN supports_multipath; + DAT_EP_CREATOR_FOR_PSP ep_creator; + DAT_PZ_SUPPORT pz_support; + DAT_UINT32 optimal_buffer_alignment; + const DAT_BOOLEAN evd_stream_merging_supported[6][6]; + DAT_BOOLEAN srq_supported; + DAT_COUNT srq_watermarks_supported; + DAT_BOOLEAN srq_ep_pz_difference_supported; + DAT_COUNT srq_info_supported; + DAT_COUNT ep_recv_info_supported; + DAT_BOOLEAN lmr_sync_req; + DAT_BOOLEAN dto_async_return_guaranteed; + DAT_BOOLEAN rdma_write_for_rdma_read_req; + DAT_COUNT num_provider_specific_attr; + DAT_NAMED_ATTR * provider_specific_attr; +}; + +#define DAT_PROVIDER_FIELD_PROVIDER_NAME UINT64_C(0x0000001) +#define DAT_PROVIDER_FIELD_PROVIDER_VERSION_MAJOR UINT64_C(0x0000002) +#define DAT_PROVIDER_FIELD_PROVIDER_VERSION_MINOR UINT64_C(0x0000004) +#define DAT_PROVIDER_FIELD_DAPL_VERSION_MAJOR UINT64_C(0x0000008) +#define DAT_PROVIDER_FIELD_DAPL_VERSION_MINOR UINT64_C(0x0000010) +#define DAT_PROVIDER_FIELD_LMR_MEM_TYPE_SUPPORTED UINT64_C(0x0000020) +#define DAT_PROVIDER_FIELD_IOV_OWNERSHIP UINT64_C(0x0000040) +#define DAT_PROVIDER_FIELD_DAT_QOS_SUPPORTED UINT64_C(0x0000080) +#define DAT_PROVIDER_FIELD_COMPLETION_FLAGS_SUPPORTED UINT64_C(0x0000100) +#define DAT_PROVIDER_FIELD_IS_THREAD_SAFE UINT64_C(0x0000200) +#define DAT_PROVIDER_FIELD_MAX_PRIVATE_DATA_SIZE UINT64_C(0x0000400) +#define DAT_PROVIDER_FIELD_SUPPORTS_MULTIPATH UINT64_C(0x0000800) +#define DAT_PROVIDER_FIELD_EP_CREATOR UINT64_C(0x0001000) +#define DAT_PROVIDER_FIELD_PZ_SUPPORT UINT64_C(0x0002000) +#define DAT_PROVIDER_FIELD_OPTIMAL_BUFFER_ALIGNMENT UINT64_C(0x0004000) +#define DAT_PROVIDER_FIELD_EVD_STREAM_MERGING_SUPPORTED UINT64_C(0x0008000) +#define DAT_PROVIDER_FIELD_SRQ_SUPPORTED UINT64_C(0x0010000) +#define DAT_PROVIDER_FIELD_SRQ_WATERMARKS_SUPPORTED UINT64_C(0x0020000) +#define DAT_PROVIDER_FIELD_SRQ_EP_PZ_DIFFERENCE_SUPPORTED \ + UINT64_C(0x0040000) +#define DAT_PROVIDER_FIELD_SRQ_INFO_SUPPORTED UINT64_C(0x0080000) +#define DAT_PROVIDER_FIELD_EP_RECV_INFO_SUPPORTED UINT64_C(0x0100000) +#define DAT_PROVIDER_FIELD_LMR_SYNC_REQ UINT64_C(0x0200000) +#define DAT_PROVIDER_FIELD_DTO_ASYNC_RETURN_GUARANTEED UINT64_C(0x0400000) +#define DAT_PROVIDER_FIELD_RDMA_WRITE_FOR_RDMA_READ_REQ UINT64_C(0x0800000) +#define DAT_PROVIDER_FIELD_NUM_PROVIDER_SPECIFIC_ATTR UINT64_C(0x1000000) +#define DAT_PROVIDER_FIELD_PROVIDER_SPECIFIC_ATTR UINT64_C(0x2000000) + +#define DAT_PROVIDER_FIELD_ALL UINT64_C(0x3FFFFFF) +#define DAT_PROVIDER_FIELD_NONE UINT64_C(0x0) + +#include + +/* ************************************************************************ */ + +/* + * User DAT functions definitions. + */ + + +extern DAT_RETURN dat_lmr_create( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_MEM_TYPE, /* mem_type */ + IN DAT_REGION_DESCRIPTION, /* region_description */ + IN DAT_VLEN, /* length */ + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_MEM_PRIV_FLAGS, /* privileges */ + OUT DAT_LMR_HANDLE *, /* lmr_handle */ + OUT DAT_LMR_CONTEXT *, /* lmr_context */ + OUT DAT_RMR_CONTEXT *, /* rmr_context */ + OUT DAT_VLEN *, /* registered_length */ + OUT DAT_VADDR *); /* registered_address */ + +/* Event Functions */ + +extern DAT_RETURN dat_evd_create( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_COUNT, /* evd_min_qlen */ + IN DAT_CNO_HANDLE, /* cno_handle */ + IN DAT_EVD_FLAGS, /* evd_flags */ + OUT DAT_EVD_HANDLE *); /* evd_handle */ + +extern DAT_RETURN dat_evd_modify_cno( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_CNO_HANDLE); /* cno_handle */ + +extern DAT_RETURN dat_cno_create( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_OS_WAIT_PROXY_AGENT, /* agent */ + OUT DAT_CNO_HANDLE *); /* cno_handle */ + +extern DAT_RETURN dat_cno_modify_agent( + IN DAT_CNO_HANDLE, /* cno_handle */ + IN DAT_OS_WAIT_PROXY_AGENT); /* agent */ + +extern DAT_RETURN dat_cno_query( + IN DAT_CNO_HANDLE, /* cno_handle */ + IN DAT_CNO_PARAM_MASK, /* cno_param_mask */ + OUT DAT_CNO_PARAM *); /* cno_param */ + +extern DAT_RETURN dat_cno_free( + IN DAT_CNO_HANDLE); /* cno_handle */ + +extern DAT_RETURN dat_cno_wait( + IN DAT_CNO_HANDLE, /* cno_handle */ + IN DAT_TIMEOUT, /* timeout */ + OUT DAT_EVD_HANDLE *); /* evd_handle */ + +extern DAT_RETURN dat_evd_enable( + IN DAT_EVD_HANDLE); /* evd_handle */ + +extern DAT_RETURN dat_evd_wait( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_TIMEOUT, /* Timeout */ + IN DAT_COUNT, /* Threshold */ + OUT DAT_EVENT *, /* event */ + OUT DAT_COUNT *); /* N more events */ + +extern DAT_RETURN dat_evd_disable( + IN DAT_EVD_HANDLE); /* evd_handle */ + +extern DAT_RETURN dat_evd_set_unwaitable( + IN DAT_EVD_HANDLE); /* evd_handle */ + +extern DAT_RETURN dat_evd_clear_unwaitable( + IN DAT_EVD_HANDLE); /* evd_handle */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UDAT_H_ */ diff --git a/illumos-x86_64/usr/include/dat/udat_config.h b/illumos-x86_64/usr/include/dat/udat_config.h new file mode 100644 index 00000000..399ecdbd --- /dev/null +++ b/illumos-x86_64/usr/include/dat/udat_config.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _UDAT_CONFIG_H_ +#define _UDAT_CONFIG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * HEADER: udat_config.h + * + * PURPOSE: provides uDAPL configuration information. + * + * Description: Header file for "uDAPL: User Direct Access Programming + * Library, Version: 1.2" + * + */ + + +#define DAT_VERSION_MAJOR 1 +#define DAT_VERSION_MINOR 2 + +/* + * The official header files will default DAT_THREADSAFE to DAT_TRUE. If + * your project does not wish to use this default, you must ensure that + * DAT_THREADSAFE will be set to DAT_FALSE. This may be done by an + * explicit #define in a common project header file that is included + * before any DAT header files, or through command line directives to the + * compiler (presumably controlled by the make environment). + */ + +/* + * A site, project or platform may consider setting an alternate default + * via their make rules, but are discouraged from doing so by editing + * the official header files. + */ + +/* + * The Reference Implementation is not Thread Safe. The Reference + * Implementation has chosen to go with the first method and define it + * explicitly in the header file. + */ + +#define DAT_THREADSAFE DAT_FALSE + +#ifndef DAT_THREADSAFE +#define DAT_THREADSAFE DAT_TRUE +#endif /* DAT_THREADSAFE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UDAT_CONFIG_H_ */ diff --git a/illumos-x86_64/usr/include/dat/udat_redirection.h b/illumos-x86_64/usr/include/dat/udat_redirection.h new file mode 100644 index 00000000..08b75894 --- /dev/null +++ b/illumos-x86_64/usr/include/dat/udat_redirection.h @@ -0,0 +1,310 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _UDAT_REDIRECTION_H_ +#define _UDAT_REDIRECTION_H_ + +/* + * + * HEADER: udat_redirection.h + * + * PURPOSE: User DAT macro definitions + * + * Description: Macros to invoke DAPL functions from the dat_registry + * + * Mapping rules: + * All global symbols are prepended with "DAT_" or "dat_" + * All DAT objects have an 'api' tag which, such as 'ep' or 'lmr' + * The method table is in the provider definition structure. + * + * + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define DAT_LMR_CREATE(ia, mem_type, reg_desc, len, pz, priv,\ + lmr, lmr_context, rmr_context, reg_len, reg_addr) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->lmr_create_func)(\ + (ia),\ + (mem_type),\ + (reg_desc),\ + (len),\ + (pz),\ + (priv),\ + (lmr),\ + (lmr_context),\ + (rmr_context),\ + (reg_len),\ + (reg_addr)) + +#define DAT_EVD_CREATE(ia, qlen, cno, flags, handle) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->evd_create_func)(\ + (ia),\ + (qlen),\ + (cno),\ + (flags),\ + (handle)) + +#define DAT_EVD_ENABLE(evd) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_enable_func)(\ + (evd)) + +#define DAT_EVD_WAIT(evd, timeout, threshold, event, nmore) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_wait_func)(\ + (evd),\ + (timeout),\ + (threshold),\ + (event),\ + (nmore)) + +#define DAT_EVD_DISABLE(evd) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_disable_func)(\ + (evd)) + +#define DAT_EVD_SET_UNWAITABLE(evd) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_set_unwaitable_func)(\ + (evd)) + +#define DAT_EVD_CLEAR_UNWAITABLE(evd) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_clear_unwaitable_func)(\ + (evd)) + +#define DAT_EVD_MODIFY_CNO(evd, cno) \ + (*DAT_HANDLE_TO_PROVIDER(evd)->evd_modify_cno_func)(\ + (evd),\ + (cno)) + +#define DAT_CNO_CREATE(ia, proxy, cno) \ + (*DAT_HANDLE_TO_PROVIDER(ia)->cno_create_func)(\ + (ia),\ + (proxy),\ + (cno)) + +#define DAT_CNO_MODIFY_AGENT(cno, proxy) \ + (*DAT_HANDLE_TO_PROVIDER(cno)->cno_modify_agent_func)(\ + (cno),\ + (proxy)) + +#define DAT_CNO_QUERY(cno, mask, param) \ + (*DAT_HANDLE_TO_PROVIDER(cno)->cno_query_func)(\ + (cno),\ + (mask),\ + (param)) + +#define DAT_CNO_FREE(cno) \ + (*DAT_HANDLE_TO_PROVIDER(cno)->cno_free_func)(\ + (cno)) + +#define DAT_CNO_WAIT(cno, timeout, evd) \ + (*DAT_HANDLE_TO_PROVIDER(cno)->cno_wait_func)(\ + (cno),\ + (timeout),\ + (evd)) +/* + * FUNCTION PROTOTYPES + * + * User DAT function call definitions + * + */ + +typedef DAT_RETURN (*DAT_LMR_CREATE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_MEM_TYPE, /* mem_type */ + IN DAT_REGION_DESCRIPTION, /* region_description */ + IN DAT_VLEN, /* length */ + IN DAT_PZ_HANDLE, /* pz_handle */ + IN DAT_MEM_PRIV_FLAGS, /* privileges */ + OUT DAT_LMR_HANDLE *, /* lmr_handle */ + OUT DAT_LMR_CONTEXT *, /* lmr_context */ + OUT DAT_RMR_CONTEXT *, /* rmr_context */ + OUT DAT_VLEN *, /* registered_length */ + OUT DAT_VADDR *); /* registered_address */ + +/* Event Functions */ + +typedef DAT_RETURN (*DAT_EVD_CREATE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_COUNT, /* evd_min_qlen */ + IN DAT_CNO_HANDLE, /* cno_handle */ + IN DAT_EVD_FLAGS, /* evd_flags */ + OUT DAT_EVD_HANDLE *); /* evd_handle */ + +typedef DAT_RETURN (*DAT_EVD_MODIFY_CNO_FUNC)( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_CNO_HANDLE); /* cno_handle */ + +typedef DAT_RETURN (*DAT_CNO_CREATE_FUNC)( + IN DAT_IA_HANDLE, /* ia_handle */ + IN DAT_OS_WAIT_PROXY_AGENT, /* agent */ + OUT DAT_CNO_HANDLE *); /* cno_handle */ + +typedef DAT_RETURN (*DAT_CNO_MODIFY_AGENT_FUNC)( + IN DAT_CNO_HANDLE, /* cno_handle */ + IN DAT_OS_WAIT_PROXY_AGENT); /* agent */ + +typedef DAT_RETURN (*DAT_CNO_QUERY_FUNC)( + IN DAT_CNO_HANDLE, /* cno_handle */ + IN DAT_CNO_PARAM_MASK, /* cno_param_mask */ + OUT DAT_CNO_PARAM *); /* cno_param */ + +typedef DAT_RETURN (*DAT_CNO_FREE_FUNC)( + IN DAT_CNO_HANDLE); /* cno_handle */ + +typedef DAT_RETURN(*DAT_CNO_WAIT_FUNC)( + IN DAT_CNO_HANDLE, /* cno_handle */ + IN DAT_TIMEOUT, /* timeout */ + OUT DAT_EVD_HANDLE *); /* evd_handle */ + +typedef DAT_RETURN (*DAT_EVD_ENABLE_FUNC)( + IN DAT_EVD_HANDLE); /* evd_handle */ + +typedef DAT_RETURN (*DAT_EVD_WAIT_FUNC)( + IN DAT_EVD_HANDLE, /* evd_handle */ + IN DAT_TIMEOUT, /* Timeout */ + IN DAT_COUNT, /* Threshold */ + OUT DAT_EVENT *, /* event */ + OUT DAT_COUNT *); /* N more events */ + +typedef DAT_RETURN (*DAT_EVD_DISABLE_FUNC)( + IN DAT_EVD_HANDLE); /* evd_handle */ + +typedef DAT_RETURN (*DAT_EVD_SET_UNWAITABLE_FUNC)( + IN DAT_EVD_HANDLE); /* evd_handle */ + +typedef DAT_RETURN (*DAT_EVD_CLEAR_UNWAITABLE_FUNC)( + IN DAT_EVD_HANDLE); /* evd_handle */ + + +#include + +struct dat_provider +{ + const char *device_name; + DAT_PVOID extension; + + DAT_IA_OPEN_FUNC ia_open_func; + DAT_IA_QUERY_FUNC ia_query_func; + DAT_IA_CLOSE_FUNC ia_close_func; + + DAT_SET_CONSUMER_CONTEXT_FUNC set_consumer_context_func; + DAT_GET_CONSUMER_CONTEXT_FUNC get_consumer_context_func; + DAT_GET_HANDLE_TYPE_FUNC get_handle_type_func; + + DAT_CNO_CREATE_FUNC cno_create_func; /* udat only */ + DAT_CNO_MODIFY_AGENT_FUNC cno_modify_agent_func; /* udat only */ + DAT_CNO_QUERY_FUNC cno_query_func; /* udat only */ + DAT_CNO_FREE_FUNC cno_free_func; /* udat only */ + DAT_CNO_WAIT_FUNC cno_wait_func; /* udat only */ + + DAT_CR_QUERY_FUNC cr_query_func; + DAT_CR_ACCEPT_FUNC cr_accept_func; + DAT_CR_REJECT_FUNC cr_reject_func; + DAT_CR_HANDOFF_FUNC cr_handoff_func; + + DAT_EVD_CREATE_FUNC evd_create_func; + DAT_EVD_QUERY_FUNC evd_query_func; + + DAT_EVD_MODIFY_CNO_FUNC evd_modify_cno_func; /* udat only */ + DAT_EVD_ENABLE_FUNC evd_enable_func; /* udat only */ + DAT_EVD_DISABLE_FUNC evd_disable_func; /* udat only */ + DAT_EVD_WAIT_FUNC evd_wait_func; /* udat only */ + + DAT_EVD_RESIZE_FUNC evd_resize_func; + DAT_EVD_POST_SE_FUNC evd_post_se_func; + DAT_EVD_DEQUEUE_FUNC evd_dequeue_func; + DAT_EVD_FREE_FUNC evd_free_func; + + DAT_EP_CREATE_FUNC ep_create_func; + DAT_EP_QUERY_FUNC ep_query_func; + DAT_EP_MODIFY_FUNC ep_modify_func; + DAT_EP_CONNECT_FUNC ep_connect_func; + DAT_EP_DUP_CONNECT_FUNC ep_dup_connect_func; + DAT_EP_DISCONNECT_FUNC ep_disconnect_func; + DAT_EP_POST_SEND_FUNC ep_post_send_func; + DAT_EP_POST_RECV_FUNC ep_post_recv_func; + DAT_EP_POST_RDMA_READ_FUNC ep_post_rdma_read_func; + DAT_EP_POST_RDMA_WRITE_FUNC ep_post_rdma_write_func; + DAT_EP_GET_STATUS_FUNC ep_get_status_func; + DAT_EP_FREE_FUNC ep_free_func; + + DAT_LMR_CREATE_FUNC lmr_create_func; + DAT_LMR_QUERY_FUNC lmr_query_func; + + DAT_LMR_FREE_FUNC lmr_free_func; + + DAT_RMR_CREATE_FUNC rmr_create_func; + DAT_RMR_QUERY_FUNC rmr_query_func; + DAT_RMR_BIND_FUNC rmr_bind_func; + DAT_RMR_FREE_FUNC rmr_free_func; + + DAT_PSP_CREATE_FUNC psp_create_func; + DAT_PSP_QUERY_FUNC psp_query_func; + DAT_PSP_FREE_FUNC psp_free_func; + + DAT_RSP_CREATE_FUNC rsp_create_func; + DAT_RSP_QUERY_FUNC rsp_query_func; + DAT_RSP_FREE_FUNC rsp_free_func; + + DAT_PZ_CREATE_FUNC pz_create_func; + DAT_PZ_QUERY_FUNC pz_query_func; + DAT_PZ_FREE_FUNC pz_free_func; + + /* dat-1.1 */ + DAT_PSP_CREATE_ANY_FUNC psp_create_any_func; + DAT_EP_RESET_FUNC ep_reset_func; + + /* udat-1.1 */ + DAT_EVD_SET_UNWAITABLE_FUNC evd_set_unwaitable_func; + DAT_EVD_CLEAR_UNWAITABLE_FUNC evd_clear_unwaitable_func; + + /* dat-1.2 */ + DAT_LMR_SYNC_RDMA_READ_FUNC lmr_sync_rdma_read_func; + DAT_LMR_SYNC_RDMA_WRITE_FUNC lmr_sync_rdma_write_func; + + DAT_EP_CREATE_WITH_SRQ_FUNC ep_create_with_srq_func; + DAT_EP_RECV_QUERY_FUNC ep_recv_query_func; + DAT_EP_SET_WATERMARK_FUNC ep_set_watermark_func; + DAT_SRQ_CREATE_FUNC srq_create_func; + DAT_SRQ_FREE_FUNC srq_free_func; + DAT_SRQ_POST_RECV_FUNC srq_post_recv_func; + DAT_SRQ_QUERY_FUNC srq_query_func; + DAT_SRQ_RESIZE_FUNC srq_resize_func; + DAT_SRQ_SET_LW_FUNC srq_set_lw_func; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _UDAT_REDIRECTION_H_ */ diff --git a/illumos-x86_64/usr/include/dat/udat_vendor_specific.h b/illumos-x86_64/usr/include/dat/udat_vendor_specific.h new file mode 100644 index 00000000..499eab42 --- /dev/null +++ b/illumos-x86_64/usr/include/dat/udat_vendor_specific.h @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved. + */ + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _UDAT_VENDOR_SPECIFIC_H_ +#define _UDAT_VENDOR_SPECIFIC_H_ + +/* + * + * HEADER: udat_vendor_specific.h + * + * PURPOSE: Vendor defined macros & support. + * + * Description: Header file for "uDAPL: User Direct Access Programming + * Library, Version: 1.2" + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if defined(_AMMASSO) + +#elif defined(_IBM) + +#elif defined(_INFINICON) + +#elif defined(_INTEL) + +#elif defined(_JNI) + +#elif defined(_MELLANOX) + +#elif defined(_MYRINET) + +#elif defined(_SILIQUENT) + +#elif defined(_TOPSPIN) + +#elif defined(_VOLTAIRE) + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _UDAT_VENDOR_SPECIFIC_H_ */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-address.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-address.h new file mode 100644 index 00000000..d41c7b5e --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-address.h @@ -0,0 +1,84 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-address.h Server address parser. + * + * Copyright (C) 2003 CodeFactory AB + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_ADDRESS_H +#define DBUS_ADDRESS_H + +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusAddress + * @{ + */ + +/** Opaque type representing one of the semicolon-separated items in an address */ +typedef struct DBusAddressEntry DBusAddressEntry; + +DBUS_EXPORT +dbus_bool_t dbus_parse_address (const char *address, + DBusAddressEntry ***entry_result, + int *array_len, + DBusError *error); +DBUS_EXPORT +const char *dbus_address_entry_get_value (DBusAddressEntry *entry, + const char *key); +DBUS_EXPORT +const char *dbus_address_entry_get_method (DBusAddressEntry *entry); +DBUS_EXPORT +void dbus_address_entries_free (DBusAddressEntry **entries); + +DBUS_EXPORT +char* dbus_address_escape_value (const char *value); +DBUS_EXPORT +char* dbus_address_unescape_value (const char *value, + DBusError *error); + +/** + * Clear a variable or struct member that contains an array of #DBusAddressEntry. + * If it does not contain #NULL, the entries that were previously + * there are freed with dbus_address_entries_free(). + * + * This is similar to dbus_clear_connection(): see that function + * for more details. + * + * @param pointer_to_entries A pointer to a variable or struct member. + * pointer_to_entries must not be #NULL, but *pointer_to_entries + * may be #NULL. + */ +#define dbus_clear_address_entries(pointer) \ + _dbus_clear_pointer_impl(DBusAddressEntry *, \ + (pointer), dbus_address_entries_free) + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_ADDRESS_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-bus.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-bus.h new file mode 100644 index 00000000..31ade9a6 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-bus.h @@ -0,0 +1,97 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-bus.h Convenience functions for communicating with the bus. + * + * Copyright (C) 2003 CodeFactory AB + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_BUS_H +#define DBUS_BUS_H + +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusBus + * @{ + */ + +DBUS_EXPORT +DBusConnection *dbus_bus_get (DBusBusType type, + DBusError *error); +DBUS_EXPORT +DBusConnection *dbus_bus_get_private (DBusBusType type, + DBusError *error); + +DBUS_EXPORT +dbus_bool_t dbus_bus_register (DBusConnection *connection, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_bus_set_unique_name (DBusConnection *connection, + const char *unique_name); +DBUS_EXPORT +const char* dbus_bus_get_unique_name (DBusConnection *connection); +DBUS_EXPORT +unsigned long dbus_bus_get_unix_user (DBusConnection *connection, + const char *name, + DBusError *error); +DBUS_EXPORT +char* dbus_bus_get_id (DBusConnection *connection, + DBusError *error); +DBUS_EXPORT +int dbus_bus_request_name (DBusConnection *connection, + const char *name, + unsigned int flags, + DBusError *error); +DBUS_EXPORT +int dbus_bus_release_name (DBusConnection *connection, + const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_bus_name_has_owner (DBusConnection *connection, + const char *name, + DBusError *error); + +DBUS_EXPORT +dbus_bool_t dbus_bus_start_service_by_name (DBusConnection *connection, + const char *name, + dbus_uint32_t flags, + dbus_uint32_t *reply, + DBusError *error); + +DBUS_EXPORT +void dbus_bus_add_match (DBusConnection *connection, + const char *rule, + DBusError *error); +DBUS_EXPORT +void dbus_bus_remove_match (DBusConnection *connection, + const char *rule, + DBusError *error); + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_BUS_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-connection.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-connection.h new file mode 100644 index 00000000..b6cf3e71 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-connection.h @@ -0,0 +1,528 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-connection.h DBusConnection object + * + * Copyright (C) 2002, 2003 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_CONNECTION_H +#define DBUS_CONNECTION_H + +#include +#include +#include +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusConnection + * @{ + */ + +/* documented in dbus-watch.c */ +typedef struct DBusWatch DBusWatch; +/* documented in dbus-timeout.c */ +typedef struct DBusTimeout DBusTimeout; +/** Opaque type representing preallocated resources so a message can be sent without further memory allocation. */ +typedef struct DBusPreallocatedSend DBusPreallocatedSend; +/** Opaque type representing a method call that has not yet received a reply. */ +typedef struct DBusPendingCall DBusPendingCall; +/** Opaque type representing a connection to a remote application and associated incoming/outgoing message queues. */ +typedef struct DBusConnection DBusConnection; +/** Set of functions that must be implemented to handle messages sent to a particular object path. */ +typedef struct DBusObjectPathVTable DBusObjectPathVTable; + +/** + * Indicates the status of a #DBusWatch. + */ +typedef enum +{ + DBUS_WATCH_READABLE = 1 << 0, /**< As in POLLIN */ + DBUS_WATCH_WRITABLE = 1 << 1, /**< As in POLLOUT */ + DBUS_WATCH_ERROR = 1 << 2, /**< As in POLLERR (can't watch for + * this, but can be present in + * current state passed to + * dbus_watch_handle()). + */ + DBUS_WATCH_HANGUP = 1 << 3 /**< As in POLLHUP (can't watch for + * it, but can be present in current + * state passed to + * dbus_watch_handle()). + */ + /* Internal to libdbus, there is also _DBUS_WATCH_NVAL in dbus-watch.h */ +} DBusWatchFlags; + +/** + * Indicates the status of incoming data on a #DBusConnection. This determines whether + * dbus_connection_dispatch() needs to be called. + */ +typedef enum +{ + DBUS_DISPATCH_DATA_REMAINS, /**< There is more data to potentially convert to messages. */ + DBUS_DISPATCH_COMPLETE, /**< All currently available data has been processed. */ + DBUS_DISPATCH_NEED_MEMORY /**< More memory is needed to continue. */ +} DBusDispatchStatus; + +/** Called when libdbus needs a new watch to be monitored by the main + * loop. Returns #FALSE if it lacks enough memory to add the + * watch. Set by dbus_connection_set_watch_functions() or + * dbus_server_set_watch_functions(). + */ +typedef dbus_bool_t (* DBusAddWatchFunction) (DBusWatch *watch, + void *data); +/** Called when dbus_watch_get_enabled() may return a different value + * than it did before. Set by dbus_connection_set_watch_functions() + * or dbus_server_set_watch_functions(). + */ +typedef void (* DBusWatchToggledFunction) (DBusWatch *watch, + void *data); +/** Called when libdbus no longer needs a watch to be monitored by the + * main loop. Set by dbus_connection_set_watch_functions() or + * dbus_server_set_watch_functions(). + */ +typedef void (* DBusRemoveWatchFunction) (DBusWatch *watch, + void *data); +/** Called when libdbus needs a new timeout to be monitored by the main + * loop. Returns #FALSE if it lacks enough memory to add the + * watch. Set by dbus_connection_set_timeout_functions() or + * dbus_server_set_timeout_functions(). + */ +typedef dbus_bool_t (* DBusAddTimeoutFunction) (DBusTimeout *timeout, + void *data); +/** Called when dbus_timeout_get_enabled() may return a different + * value than it did before. + * Set by dbus_connection_set_timeout_functions() or + * dbus_server_set_timeout_functions(). + */ +typedef void (* DBusTimeoutToggledFunction) (DBusTimeout *timeout, + void *data); +/** Called when libdbus no longer needs a timeout to be monitored by the + * main loop. Set by dbus_connection_set_timeout_functions() or + * dbus_server_set_timeout_functions(). + */ +typedef void (* DBusRemoveTimeoutFunction) (DBusTimeout *timeout, + void *data); +/** Called when the return value of dbus_connection_get_dispatch_status() + * may have changed. Set with dbus_connection_set_dispatch_status_function(). + */ +typedef void (* DBusDispatchStatusFunction) (DBusConnection *connection, + DBusDispatchStatus new_status, + void *data); +/** + * Called when the main loop's thread should be notified that there's now work + * to do. Set with dbus_connection_set_wakeup_main_function(). + */ +typedef void (* DBusWakeupMainFunction) (void *data); + +/** + * Called during authentication to check whether the given UNIX user + * ID is allowed to connect, if the client tried to auth as a UNIX + * user ID. Normally on Windows this would never happen. Set with + * dbus_connection_set_unix_user_function(). + */ +typedef dbus_bool_t (* DBusAllowUnixUserFunction) (DBusConnection *connection, + unsigned long uid, + void *data); + +/** + * Called during authentication to check whether the given Windows user + * ID is allowed to connect, if the client tried to auth as a Windows + * user ID. Normally on UNIX this would never happen. Set with + * dbus_connection_set_windows_user_function(). + */ +typedef dbus_bool_t (* DBusAllowWindowsUserFunction) (DBusConnection *connection, + const char *user_sid, + void *data); + + +/** + * Called when a pending call now has a reply available. Set with + * dbus_pending_call_set_notify(). + */ +typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending, + void *user_data); + +/** + * Called when a message needs to be handled. The result indicates whether or + * not more handlers should be run. Set with dbus_connection_add_filter(). + */ +typedef DBusHandlerResult (* DBusHandleMessageFunction) (DBusConnection *connection, + DBusMessage *message, + void *user_data); +DBUS_EXPORT +DBusConnection* dbus_connection_open (const char *address, + DBusError *error); +DBUS_EXPORT +DBusConnection* dbus_connection_open_private (const char *address, + DBusError *error); +DBUS_EXPORT +DBusConnection* dbus_connection_ref (DBusConnection *connection); +DBUS_EXPORT +void dbus_connection_unref (DBusConnection *connection); +DBUS_EXPORT +void dbus_connection_close (DBusConnection *connection); +DBUS_EXPORT +dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection); +DBUS_EXPORT +dbus_bool_t dbus_connection_get_is_authenticated (DBusConnection *connection); +DBUS_EXPORT +dbus_bool_t dbus_connection_get_is_anonymous (DBusConnection *connection); +DBUS_EXPORT +char* dbus_connection_get_server_id (DBusConnection *connection); +DBUS_EXPORT +dbus_bool_t dbus_connection_can_send_type (DBusConnection *connection, + int type); + +DBUS_EXPORT +void dbus_connection_set_exit_on_disconnect (DBusConnection *connection, + dbus_bool_t exit_on_disconnect); +DBUS_EXPORT +void dbus_connection_flush (DBusConnection *connection); +DBUS_EXPORT +dbus_bool_t dbus_connection_read_write_dispatch (DBusConnection *connection, + int timeout_milliseconds); +DBUS_EXPORT +dbus_bool_t dbus_connection_read_write (DBusConnection *connection, + int timeout_milliseconds); +DBUS_EXPORT +DBusMessage* dbus_connection_borrow_message (DBusConnection *connection); +DBUS_EXPORT +void dbus_connection_return_message (DBusConnection *connection, + DBusMessage *message); +DBUS_EXPORT +void dbus_connection_steal_borrowed_message (DBusConnection *connection, + DBusMessage *message); +DBUS_EXPORT +DBusMessage* dbus_connection_pop_message (DBusConnection *connection); +DBUS_EXPORT +DBusDispatchStatus dbus_connection_get_dispatch_status (DBusConnection *connection); +DBUS_EXPORT +DBusDispatchStatus dbus_connection_dispatch (DBusConnection *connection); +DBUS_EXPORT +dbus_bool_t dbus_connection_has_messages_to_send (DBusConnection *connection); +DBUS_EXPORT +dbus_bool_t dbus_connection_send (DBusConnection *connection, + DBusMessage *message, + dbus_uint32_t *client_serial); +DBUS_EXPORT +dbus_bool_t dbus_connection_send_with_reply (DBusConnection *connection, + DBusMessage *message, + DBusPendingCall **pending_return, + int timeout_milliseconds); +DBUS_EXPORT +DBusMessage * dbus_connection_send_with_reply_and_block (DBusConnection *connection, + DBusMessage *message, + int timeout_milliseconds, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_connection_set_watch_functions (DBusConnection *connection, + DBusAddWatchFunction add_function, + DBusRemoveWatchFunction remove_function, + DBusWatchToggledFunction toggled_function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +dbus_bool_t dbus_connection_set_timeout_functions (DBusConnection *connection, + DBusAddTimeoutFunction add_function, + DBusRemoveTimeoutFunction remove_function, + DBusTimeoutToggledFunction toggled_function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +void dbus_connection_set_wakeup_main_function (DBusConnection *connection, + DBusWakeupMainFunction wakeup_main_function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +void dbus_connection_set_dispatch_status_function (DBusConnection *connection, + DBusDispatchStatusFunction function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +dbus_bool_t dbus_connection_get_unix_user (DBusConnection *connection, + unsigned long *uid); +DBUS_EXPORT +dbus_bool_t dbus_connection_get_unix_process_id (DBusConnection *connection, + unsigned long *pid); +DBUS_EXPORT +dbus_bool_t dbus_connection_get_adt_audit_session_data (DBusConnection *connection, + void **data, + dbus_int32_t *data_size); +DBUS_EXPORT +void dbus_connection_set_unix_user_function (DBusConnection *connection, + DBusAllowUnixUserFunction function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +dbus_bool_t dbus_connection_get_windows_user (DBusConnection *connection, + char **windows_sid_p); +DBUS_EXPORT +void dbus_connection_set_windows_user_function (DBusConnection *connection, + DBusAllowWindowsUserFunction function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +void dbus_connection_set_allow_anonymous (DBusConnection *connection, + dbus_bool_t value); +DBUS_EXPORT +void dbus_connection_set_builtin_filters_enabled (DBusConnection *connection, + dbus_bool_t value); +DBUS_EXPORT +void dbus_connection_set_route_peer_messages (DBusConnection *connection, + dbus_bool_t value); + + +/* Filters */ + +DBUS_EXPORT +dbus_bool_t dbus_connection_add_filter (DBusConnection *connection, + DBusHandleMessageFunction function, + void *user_data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +void dbus_connection_remove_filter (DBusConnection *connection, + DBusHandleMessageFunction function, + void *user_data); + + +/* Other */ +DBUS_EXPORT +dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t *slot_p); +DBUS_EXPORT +void dbus_connection_free_data_slot (dbus_int32_t *slot_p); +DBUS_EXPORT +dbus_bool_t dbus_connection_set_data (DBusConnection *connection, + dbus_int32_t slot, + void *data, + DBusFreeFunction free_data_func); +DBUS_EXPORT +void* dbus_connection_get_data (DBusConnection *connection, + dbus_int32_t slot); + +DBUS_EXPORT +void dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe); + +DBUS_EXPORT +void dbus_connection_set_max_message_size (DBusConnection *connection, + long size); +DBUS_EXPORT +long dbus_connection_get_max_message_size (DBusConnection *connection); +DBUS_EXPORT +void dbus_connection_set_max_received_size (DBusConnection *connection, + long size); +DBUS_EXPORT +long dbus_connection_get_max_received_size (DBusConnection *connection); + +DBUS_EXPORT +void dbus_connection_set_max_message_unix_fds (DBusConnection *connection, + long n); +DBUS_EXPORT +long dbus_connection_get_max_message_unix_fds (DBusConnection *connection); +DBUS_EXPORT +void dbus_connection_set_max_received_unix_fds(DBusConnection *connection, + long n); +DBUS_EXPORT +long dbus_connection_get_max_received_unix_fds(DBusConnection *connection); + +DBUS_EXPORT +long dbus_connection_get_outgoing_size (DBusConnection *connection); +DBUS_EXPORT +long dbus_connection_get_outgoing_unix_fds (DBusConnection *connection); + +DBUS_EXPORT +DBusPreallocatedSend* dbus_connection_preallocate_send (DBusConnection *connection); +DBUS_EXPORT +void dbus_connection_free_preallocated_send (DBusConnection *connection, + DBusPreallocatedSend *preallocated); +DBUS_EXPORT +void dbus_connection_send_preallocated (DBusConnection *connection, + DBusPreallocatedSend *preallocated, + DBusMessage *message, + dbus_uint32_t *client_serial); + + +/* Object tree functionality */ + +/** + * Called when a #DBusObjectPathVTable is unregistered (or its connection is freed). + * Found in #DBusObjectPathVTable. + */ +typedef void (* DBusObjectPathUnregisterFunction) (DBusConnection *connection, + void *user_data); +/** + * Called when a message is sent to a registered object path. Found in + * #DBusObjectPathVTable which is registered with dbus_connection_register_object_path() + * or dbus_connection_register_fallback(). + */ +typedef DBusHandlerResult (* DBusObjectPathMessageFunction) (DBusConnection *connection, + DBusMessage *message, + void *user_data); + +/** + * Virtual table that must be implemented to handle a portion of the + * object path hierarchy. Attach the vtable to a particular path using + * dbus_connection_register_object_path() or + * dbus_connection_register_fallback(). + */ +struct DBusObjectPathVTable +{ + DBusObjectPathUnregisterFunction unregister_function; /**< Function to unregister this handler */ + DBusObjectPathMessageFunction message_function; /**< Function to handle messages */ + + void (* dbus_internal_pad1) (void *); /**< Reserved for future expansion */ + void (* dbus_internal_pad2) (void *); /**< Reserved for future expansion */ + void (* dbus_internal_pad3) (void *); /**< Reserved for future expansion */ + void (* dbus_internal_pad4) (void *); /**< Reserved for future expansion */ +}; + +DBUS_EXPORT +dbus_bool_t dbus_connection_try_register_object_path (DBusConnection *connection, + const char *path, + const DBusObjectPathVTable *vtable, + void *user_data, + DBusError *error); + +DBUS_EXPORT +dbus_bool_t dbus_connection_register_object_path (DBusConnection *connection, + const char *path, + const DBusObjectPathVTable *vtable, + void *user_data); + +DBUS_EXPORT +dbus_bool_t dbus_connection_try_register_fallback (DBusConnection *connection, + const char *path, + const DBusObjectPathVTable *vtable, + void *user_data, + DBusError *error); + +DBUS_EXPORT +dbus_bool_t dbus_connection_register_fallback (DBusConnection *connection, + const char *path, + const DBusObjectPathVTable *vtable, + void *user_data); +DBUS_EXPORT +dbus_bool_t dbus_connection_unregister_object_path (DBusConnection *connection, + const char *path); + +DBUS_EXPORT +dbus_bool_t dbus_connection_get_object_path_data (DBusConnection *connection, + const char *path, + void **data_p); + +DBUS_EXPORT +dbus_bool_t dbus_connection_list_registered (DBusConnection *connection, + const char *parent_path, + char ***child_entries); + +DBUS_EXPORT +dbus_bool_t dbus_connection_get_unix_fd (DBusConnection *connection, + int *fd); +DBUS_EXPORT +dbus_bool_t dbus_connection_get_socket (DBusConnection *connection, + int *fd); + +/** + * Clear a variable or struct member that contains a #DBusConnection. + * If it does not contain #NULL, the connection that was previously + * there is unreferenced with dbus_connection_unref(). + * + * For example, this function and the similar functions for + * other reference-counted types can be used in code like this: + * + * @code + * DBusConnection *conn = NULL; + * struct { ...; DBusMessage *m; ... } *larger_structure = ...; + * + * ... code that might set conn or m to be non-NULL ... + * + * dbus_clear_connection (&conn); + * dbus_clear_message (&larger_structure->m); + * @endcode + * + * @param pointer_to_connection A pointer to a variable or struct member. + * pointer_to_connection must not be #NULL, but *pointer_to_connection + * may be #NULL. + */ +#define dbus_clear_connection(pointer) \ + _dbus_clear_pointer_impl(DBusConnection, \ + (pointer), dbus_connection_unref) + +/** @} */ + + +/** + * @addtogroup DBusWatch + * @{ + */ + +#ifndef DBUS_DISABLE_DEPRECATED +DBUS_EXPORT +DBUS_DEPRECATED int dbus_watch_get_fd (DBusWatch *watch); +#endif + +DBUS_EXPORT +int dbus_watch_get_unix_fd (DBusWatch *watch); +DBUS_EXPORT +int dbus_watch_get_socket (DBusWatch *watch); +DBUS_EXPORT +unsigned int dbus_watch_get_flags (DBusWatch *watch); +DBUS_EXPORT +void* dbus_watch_get_data (DBusWatch *watch); +DBUS_EXPORT +void dbus_watch_set_data (DBusWatch *watch, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +dbus_bool_t dbus_watch_handle (DBusWatch *watch, + unsigned int flags); +DBUS_EXPORT +dbus_bool_t dbus_watch_get_enabled (DBusWatch *watch); + +/** @} */ + +/** + * @addtogroup DBusTimeout + * @{ + */ + +DBUS_EXPORT +int dbus_timeout_get_interval (DBusTimeout *timeout); +DBUS_EXPORT +void* dbus_timeout_get_data (DBusTimeout *timeout); +DBUS_EXPORT +void dbus_timeout_set_data (DBusTimeout *timeout, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +dbus_bool_t dbus_timeout_handle (DBusTimeout *timeout); +DBUS_EXPORT +dbus_bool_t dbus_timeout_get_enabled (DBusTimeout *timeout); + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_CONNECTION_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-errors.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-errors.h new file mode 100644 index 00000000..003f583b --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-errors.h @@ -0,0 +1,92 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-errors.h Error reporting + * + * Copyright (C) 2002 Red Hat Inc. + * Copyright (C) 2003 CodeFactory AB + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_ERROR_H +#define DBUS_ERROR_H + +#include +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusErrors + * @{ + */ + +/** Mostly-opaque type representing an error that occurred */ +typedef struct DBusError DBusError; + +/** + * Object representing an exception. + */ +struct DBusError +{ + const char *name; /**< public error name field */ + const char *message; /**< public error message field */ + + unsigned int dummy1 : 1; /**< placeholder */ + unsigned int dummy2 : 1; /**< placeholder */ + unsigned int dummy3 : 1; /**< placeholder */ + unsigned int dummy4 : 1; /**< placeholder */ + unsigned int dummy5 : 1; /**< placeholder */ + + void *padding1; /**< placeholder */ +}; + +#define DBUS_ERROR_INIT { NULL, NULL, TRUE, 0, 0, 0, 0, NULL } + +DBUS_EXPORT +void dbus_error_init (DBusError *error); +DBUS_EXPORT +void dbus_error_free (DBusError *error); +DBUS_EXPORT +void dbus_set_error (DBusError *error, + const char *name, + const char *message, + ...) _DBUS_GNUC_PRINTF (3, 4); +DBUS_EXPORT +void dbus_set_error_const (DBusError *error, + const char *name, + const char *message); +DBUS_EXPORT +void dbus_move_error (DBusError *src, + DBusError *dest); +DBUS_EXPORT +dbus_bool_t dbus_error_has_name (const DBusError *error, + const char *name); +DBUS_EXPORT +dbus_bool_t dbus_error_is_set (const DBusError *error); + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_ERROR_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib-bindings.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib-bindings.h new file mode 100644 index 00000000..5cdc6d06 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib-bindings.h @@ -0,0 +1,504 @@ +/* Generated by dbus-binding-tool; do not edit! */ + +#include +#include + +G_BEGIN_DECLS + +#ifndef _DBUS_GLIB_ASYNC_DATA_FREE +#define _DBUS_GLIB_ASYNC_DATA_FREE +static inline void +_dbus_glib_async_data_free (gpointer stuff) +{ + g_slice_free (DBusGAsyncData, stuff); +} +#endif + +#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Introspectable +#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Introspectable + +static inline gboolean +org_freedesktop_DBus_Introspectable_introspect (DBusGProxy *proxy, char ** OUT_data, GError **error) + +{ + return dbus_g_proxy_call (proxy, "Introspect", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_data, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_Introspectable_introspect_reply) (DBusGProxy *proxy, char * OUT_data, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_Introspectable_introspect_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + char * OUT_data; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_data, G_TYPE_INVALID); + (*(org_freedesktop_DBus_Introspectable_introspect_reply)data->cb) (proxy, OUT_data, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_Introspectable_introspect_async (DBusGProxy *proxy, org_freedesktop_DBus_Introspectable_introspect_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "Introspect", org_freedesktop_DBus_Introspectable_introspect_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Introspectable */ + +#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus +#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus + +static inline gboolean +org_freedesktop_DBus_request_name (DBusGProxy *proxy, const char * IN_arg0, const guint IN_arg1, guint* OUT_arg2, GError **error) + +{ + return dbus_g_proxy_call (proxy, "RequestName", error, G_TYPE_STRING, IN_arg0, G_TYPE_UINT, IN_arg1, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg2, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_request_name_reply) (DBusGProxy *proxy, guint OUT_arg2, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_request_name_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + guint OUT_arg2; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg2, G_TYPE_INVALID); + (*(org_freedesktop_DBus_request_name_reply)data->cb) (proxy, OUT_arg2, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_request_name_async (DBusGProxy *proxy, const char * IN_arg0, const guint IN_arg1, org_freedesktop_DBus_request_name_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "RequestName", org_freedesktop_DBus_request_name_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_UINT, IN_arg1, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_release_name (DBusGProxy *proxy, const char * IN_arg0, guint* OUT_arg1, GError **error) + +{ + return dbus_g_proxy_call (proxy, "ReleaseName", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg1, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_release_name_reply) (DBusGProxy *proxy, guint OUT_arg1, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_release_name_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + guint OUT_arg1; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg1, G_TYPE_INVALID); + (*(org_freedesktop_DBus_release_name_reply)data->cb) (proxy, OUT_arg1, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_release_name_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_release_name_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "ReleaseName", org_freedesktop_DBus_release_name_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_start_service_by_name (DBusGProxy *proxy, const char * IN_arg0, const guint IN_arg1, guint* OUT_arg2, GError **error) + +{ + return dbus_g_proxy_call (proxy, "StartServiceByName", error, G_TYPE_STRING, IN_arg0, G_TYPE_UINT, IN_arg1, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg2, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_start_service_by_name_reply) (DBusGProxy *proxy, guint OUT_arg2, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_start_service_by_name_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + guint OUT_arg2; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg2, G_TYPE_INVALID); + (*(org_freedesktop_DBus_start_service_by_name_reply)data->cb) (proxy, OUT_arg2, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_start_service_by_name_async (DBusGProxy *proxy, const char * IN_arg0, const guint IN_arg1, org_freedesktop_DBus_start_service_by_name_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "StartServiceByName", org_freedesktop_DBus_start_service_by_name_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_UINT, IN_arg1, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_hello (DBusGProxy *proxy, char ** OUT_arg0, GError **error) + +{ + return dbus_g_proxy_call (proxy, "Hello", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_arg0, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_hello_reply) (DBusGProxy *proxy, char * OUT_arg0, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_hello_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + char * OUT_arg0; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_arg0, G_TYPE_INVALID); + (*(org_freedesktop_DBus_hello_reply)data->cb) (proxy, OUT_arg0, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_hello_async (DBusGProxy *proxy, org_freedesktop_DBus_hello_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "Hello", org_freedesktop_DBus_hello_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_name_has_owner (DBusGProxy *proxy, const char * IN_arg0, gboolean* OUT_arg1, GError **error) + +{ + return dbus_g_proxy_call (proxy, "NameHasOwner", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_arg1, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_name_has_owner_reply) (DBusGProxy *proxy, gboolean OUT_arg1, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_name_has_owner_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + gboolean OUT_arg1; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_arg1, G_TYPE_INVALID); + (*(org_freedesktop_DBus_name_has_owner_reply)data->cb) (proxy, OUT_arg1, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_name_has_owner_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_name_has_owner_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "NameHasOwner", org_freedesktop_DBus_name_has_owner_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_list_names (DBusGProxy *proxy, char *** OUT_arg0, GError **error) + +{ + return dbus_g_proxy_call (proxy, "ListNames", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg0, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_list_names_reply) (DBusGProxy *proxy, char * *OUT_arg0, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_list_names_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + char ** OUT_arg0; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg0, G_TYPE_INVALID); + (*(org_freedesktop_DBus_list_names_reply)data->cb) (proxy, OUT_arg0, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_list_names_async (DBusGProxy *proxy, org_freedesktop_DBus_list_names_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "ListNames", org_freedesktop_DBus_list_names_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_list_activatable_names (DBusGProxy *proxy, char *** OUT_arg0, GError **error) + +{ + return dbus_g_proxy_call (proxy, "ListActivatableNames", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg0, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_list_activatable_names_reply) (DBusGProxy *proxy, char * *OUT_arg0, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_list_activatable_names_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + char ** OUT_arg0; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg0, G_TYPE_INVALID); + (*(org_freedesktop_DBus_list_activatable_names_reply)data->cb) (proxy, OUT_arg0, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_list_activatable_names_async (DBusGProxy *proxy, org_freedesktop_DBus_list_activatable_names_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "ListActivatableNames", org_freedesktop_DBus_list_activatable_names_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_add_match (DBusGProxy *proxy, const char * IN_arg0, GError **error) + +{ + return dbus_g_proxy_call (proxy, "AddMatch", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_add_match_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_add_match_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_freedesktop_DBus_add_match_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_add_match_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_add_match_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "AddMatch", org_freedesktop_DBus_add_match_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_remove_match (DBusGProxy *proxy, const char * IN_arg0, GError **error) + +{ + return dbus_g_proxy_call (proxy, "RemoveMatch", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_remove_match_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_remove_match_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_freedesktop_DBus_remove_match_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_remove_match_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_remove_match_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "RemoveMatch", org_freedesktop_DBus_remove_match_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_get_name_owner (DBusGProxy *proxy, const char * IN_arg0, char ** OUT_arg1, GError **error) + +{ + return dbus_g_proxy_call (proxy, "GetNameOwner", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, G_TYPE_STRING, OUT_arg1, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_get_name_owner_reply) (DBusGProxy *proxy, char * OUT_arg1, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_get_name_owner_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + char * OUT_arg1; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_arg1, G_TYPE_INVALID); + (*(org_freedesktop_DBus_get_name_owner_reply)data->cb) (proxy, OUT_arg1, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_get_name_owner_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_get_name_owner_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "GetNameOwner", org_freedesktop_DBus_get_name_owner_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_list_queued_owners (DBusGProxy *proxy, const char * IN_arg0, char *** OUT_arg1, GError **error) + +{ + return dbus_g_proxy_call (proxy, "ListQueuedOwners", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg1, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_list_queued_owners_reply) (DBusGProxy *proxy, char * *OUT_arg1, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_list_queued_owners_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + char ** OUT_arg1; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg1, G_TYPE_INVALID); + (*(org_freedesktop_DBus_list_queued_owners_reply)data->cb) (proxy, OUT_arg1, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_list_queued_owners_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_list_queued_owners_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "ListQueuedOwners", org_freedesktop_DBus_list_queued_owners_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_get_connection_unix_user (DBusGProxy *proxy, const char * IN_arg0, guint* OUT_arg1, GError **error) + +{ + return dbus_g_proxy_call (proxy, "GetConnectionUnixUser", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg1, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_get_connection_unix_user_reply) (DBusGProxy *proxy, guint OUT_arg1, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_get_connection_unix_user_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + guint OUT_arg1; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg1, G_TYPE_INVALID); + (*(org_freedesktop_DBus_get_connection_unix_user_reply)data->cb) (proxy, OUT_arg1, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_get_connection_unix_user_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_get_connection_unix_user_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "GetConnectionUnixUser", org_freedesktop_DBus_get_connection_unix_user_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_get_connection_unix_process_id (DBusGProxy *proxy, const char * IN_arg0, guint* OUT_arg1, GError **error) + +{ + return dbus_g_proxy_call (proxy, "GetConnectionUnixProcessID", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg1, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_get_connection_unix_process_id_reply) (DBusGProxy *proxy, guint OUT_arg1, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_get_connection_unix_process_id_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + guint OUT_arg1; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg1, G_TYPE_INVALID); + (*(org_freedesktop_DBus_get_connection_unix_process_id_reply)data->cb) (proxy, OUT_arg1, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_get_connection_unix_process_id_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_get_connection_unix_process_id_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "GetConnectionUnixProcessID", org_freedesktop_DBus_get_connection_unix_process_id_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_get_connection_se_linux_security_context (DBusGProxy *proxy, const char * IN_arg0, GArray** OUT_arg1, GError **error) + +{ + return dbus_g_proxy_call (proxy, "GetConnectionSELinuxSecurityContext", error, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), OUT_arg1, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_get_connection_se_linux_security_context_reply) (DBusGProxy *proxy, GArray *OUT_arg1, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_get_connection_se_linux_security_context_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + GArray* OUT_arg1; + dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), &OUT_arg1, G_TYPE_INVALID); + (*(org_freedesktop_DBus_get_connection_se_linux_security_context_reply)data->cb) (proxy, OUT_arg1, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_get_connection_se_linux_security_context_async (DBusGProxy *proxy, const char * IN_arg0, org_freedesktop_DBus_get_connection_se_linux_security_context_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "GetConnectionSELinuxSecurityContext", org_freedesktop_DBus_get_connection_se_linux_security_context_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_arg0, G_TYPE_INVALID); +} +static inline gboolean +org_freedesktop_DBus_reload_config (DBusGProxy *proxy, GError **error) + +{ + return dbus_g_proxy_call (proxy, "ReloadConfig", error, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*org_freedesktop_DBus_reload_config_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +org_freedesktop_DBus_reload_config_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_freedesktop_DBus_reload_config_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static inline DBusGProxyCall* +org_freedesktop_DBus_reload_config_async (DBusGProxy *proxy, org_freedesktop_DBus_reload_config_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "ReloadConfig", org_freedesktop_DBus_reload_config_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus */ + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib-lowlevel.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib-lowlevel.h new file mode 100644 index 00000000..6add4c63 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib-lowlevel.h @@ -0,0 +1,67 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-glib-lowlevel.h GLib integration details that require dbus/dbus.h + * + * Copyright (C) 2002, 2003 CodeFactory AB + * Copyright (C) 2003, 2004 Red Hat, Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef DBUS_GLIB_LOWLEVEL_H +#define DBUS_GLIB_LOWLEVEL_H + +#include +#include + +G_BEGIN_DECLS + +void dbus_set_g_error (GError **gerror, + DBusError *derror); + +#define DBUS_TYPE_CONNECTION (dbus_connection_get_g_type ()) +#define DBUS_TYPE_MESSAGE (dbus_message_get_g_type ()) +GType dbus_connection_get_g_type (void) G_GNUC_CONST; +GType dbus_message_get_g_type (void) G_GNUC_CONST; + +void dbus_connection_setup_with_g_main (DBusConnection *connection, + GMainContext *context); +void dbus_server_setup_with_g_main (DBusServer *server, + GMainContext *context); + +void dbus_g_proxy_send (DBusGProxy *proxy, + DBusMessage *message, + dbus_uint32_t *client_serial); + +DBusConnection* dbus_g_connection_get_connection (DBusGConnection *gconnection); +DBusGConnection* dbus_connection_get_g_connection (DBusConnection *connection); +DBusMessage* dbus_g_message_get_message (DBusGMessage *gmessage); + +gchar* dbus_g_method_get_sender (DBusGMethodInvocation *context); + +DBusMessage* dbus_g_method_get_reply (DBusGMethodInvocation *context); + +void dbus_g_method_send_reply (DBusGMethodInvocation *context, + DBusMessage *reply); + +G_END_DECLS + +#endif /* DBUS_GLIB_LOWLEVEL_H */ + + + diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib.h new file mode 100644 index 00000000..52225f18 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-glib.h @@ -0,0 +1,348 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-glib.h GLib integration + * + * Copyright (C) 2002, 2003 CodeFactory AB + * Copyright (C) 2003, 2004 Red Hat, Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef DBUS_GLIB_H +#define DBUS_GLIB_H + +#include +#include + +G_BEGIN_DECLS + +#define DBUS_INSIDE_DBUS_GLIB_H 1 + + +/* + * Convert to DBusConnection with dbus_g_connection_get_connection() in dbus-glib-lowlevel.h + */ +typedef struct _DBusGConnection DBusGConnection; +/* + * Convert to DBusMessage with dbus_g_message_get_message() in dbus-glib-lowlevel.h + */ +typedef struct _DBusGMessage DBusGMessage; + + +#define DBUS_TYPE_G_CONNECTION (dbus_g_connection_get_g_type ()) +#define DBUS_TYPE_G_MESSAGE (dbus_g_message_get_g_type ()) +GType dbus_g_connection_get_g_type (void) G_GNUC_CONST; +GType dbus_g_message_get_g_type (void) G_GNUC_CONST; + + +DBusGConnection* dbus_g_connection_ref (DBusGConnection *connection); +void dbus_g_connection_unref (DBusGConnection *connection); +DBusGMessage* dbus_g_message_ref (DBusGMessage *message); +void dbus_g_message_unref (DBusGMessage *message); + +void dbus_g_connection_flush (DBusGConnection *connection); + +GQuark dbus_g_error_quark (void); +#define DBUS_GERROR dbus_g_error_quark () + +typedef enum +{ +DBUS_GERROR_FAILED, +DBUS_GERROR_NO_MEMORY, +DBUS_GERROR_SERVICE_UNKNOWN, +DBUS_GERROR_NAME_HAS_NO_OWNER, +DBUS_GERROR_NO_REPLY, +DBUS_GERROR_IO_ERROR, +DBUS_GERROR_BAD_ADDRESS, +DBUS_GERROR_NOT_SUPPORTED, +DBUS_GERROR_LIMITS_EXCEEDED, +DBUS_GERROR_ACCESS_DENIED, +DBUS_GERROR_AUTH_FAILED, +DBUS_GERROR_NO_SERVER, +DBUS_GERROR_TIMEOUT, +DBUS_GERROR_NO_NETWORK, +DBUS_GERROR_ADDRESS_IN_USE, +DBUS_GERROR_DISCONNECTED, +DBUS_GERROR_INVALID_ARGS, +DBUS_GERROR_FILE_NOT_FOUND, +DBUS_GERROR_FILE_EXISTS, +DBUS_GERROR_UNKNOWN_METHOD, +DBUS_GERROR_TIMED_OUT, +DBUS_GERROR_MATCH_RULE_NOT_FOUND, +DBUS_GERROR_MATCH_RULE_INVALID, +DBUS_GERROR_SPAWN_EXEC_FAILED, +DBUS_GERROR_SPAWN_FORK_FAILED, +DBUS_GERROR_SPAWN_CHILD_EXITED, +DBUS_GERROR_SPAWN_CHILD_SIGNALED, +DBUS_GERROR_SPAWN_FAILED, +DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN, +DBUS_GERROR_INVALID_SIGNATURE, +DBUS_GERROR_INVALID_FILE_CONTENT, +DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN, +DBUS_GERROR_REMOTE_EXCEPTION +} DBusGError; + +gboolean dbus_g_error_has_name (GError *error, + const char *name); +const char * dbus_g_error_get_name (GError *error); + +void dbus_g_thread_init (void); + +DBusGConnection* dbus_g_connection_open (const gchar *address, + GError **error); +DBusGConnection* dbus_g_connection_open_private (const gchar *address, + GMainContext *context, + GError **error); +DBusGConnection* dbus_g_bus_get (DBusBusType type, + GError **error); +DBusGConnection* dbus_g_bus_get_private (DBusBusType type, + GMainContext *context, + GError **error); + + +typedef struct _DBusGObjectInfo DBusGObjectInfo; +typedef struct _DBusGMethodInfo DBusGMethodInfo; + +/** + * DBusGMethodInfo: + * @function: C method to invoke + * @marshaller: Marshaller to invoke method + * @data_offset: Offset into the introspection data + * + * Object typically generated by #dbus-binding-tool that + * stores a mapping from introspection data to a + * function pointer for a C method to be invoked. + */ +struct _DBusGMethodInfo +{ + GCallback function; + GClosureMarshal marshaller; + int data_offset; +}; + +/** + * DBusGObjectInfo: + * @format_version: Allows us to change the rest of this struct + * by adding DBusGObjectInfo2, DBusGObjectInfo3, etc. + * @method_infos: Array of method pointers + * @n_method_infos: Length of the infos array + * @data: Introspection data + * @exported_signals: Exported signals + * @exported_properties: Exported properties + * + * Introspection data for a #GObject, normally autogenerated by + * a tool such as #dbus-binding-tool. + */ +struct _DBusGObjectInfo +{ + int format_version; + + const DBusGMethodInfo *method_infos; + int n_method_infos; + const char *data; + const char *exported_signals; + const char *exported_properties; +}; + +void dbus_glib_global_set_disable_legacy_property_access (void); + +void dbus_g_object_type_install_info (GType object_type, + const DBusGObjectInfo *info); + +void dbus_g_object_type_register_shadow_property (GType iface_type, + const char *dbus_prop_name, + const char *shadow_prop_name); + +void dbus_g_error_domain_register (GQuark domain, + const char * default_iface, + GType code_enum); + +void dbus_g_connection_register_g_object (DBusGConnection *connection, + const char *at_path, + GObject *object); +void dbus_g_connection_unregister_g_object (DBusGConnection *connection, + GObject *object); +GObject * dbus_g_connection_lookup_g_object (DBusGConnection *connection, + const char *at_path); + +#ifdef DBUS_COMPILATION +#include "dbus/dbus-gtype-specialized.h" +#else +#include +#endif + +/* definitions for some basic array types */ +#define DBUS_TYPE_G_BOOLEAN_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN)) +#define DBUS_TYPE_G_UCHAR_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR)) +#define DBUS_TYPE_G_UINT_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UINT)) +#define DBUS_TYPE_G_INT_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_INT)) +#define DBUS_TYPE_G_UINT64_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UINT64)) +#define DBUS_TYPE_G_INT64_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_INT64)) +#define DBUS_TYPE_G_OBJECT_ARRAY (dbus_g_type_get_collection ("GPtrArray", G_TYPE_OBJECT)) + +#define DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)) + +typedef gchar DBusGObjectPath; +GType dbus_g_object_path_get_g_type (void) G_GNUC_CONST; +#define DBUS_TYPE_G_OBJECT_PATH (dbus_g_object_path_get_g_type ()) + +typedef gchar DBusGSignature; +GType dbus_g_signature_get_g_type (void) G_GNUC_CONST; +#define DBUS_TYPE_G_SIGNATURE (dbus_g_signature_get_g_type ()) + +void dbus_g_object_register_marshaller (GClosureMarshal marshaller, + GType rettype, + ...); +void dbus_g_object_register_marshaller_array(GClosureMarshal marshaller, + GType rettype, + guint n_types, + const GType* types); + +typedef struct _DBusGProxy DBusGProxy; +typedef struct _DBusGProxyClass DBusGProxyClass; + +#define DBUS_TYPE_G_PROXY (dbus_g_proxy_get_type ()) +#define DBUS_G_PROXY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_G_PROXY, DBusGProxy)) +#define DBUS_G_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_G_PROXY, DBusGProxyClass)) +#define DBUS_IS_G_PROXY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_G_PROXY)) +#define DBUS_IS_G_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_G_PROXY)) +#define DBUS_G_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_G_PROXY, DBusGProxyClass)) + +struct _DBusGProxy +{ + /*< private >*/ + GObject parent; +}; + +struct _DBusGProxyClass +{ + /*< private >*/ + GObjectClass parent_class; /**< Parent class */ +}; + +typedef struct _DBusGProxyCall DBusGProxyCall; +typedef void (* DBusGProxyCallNotify) (DBusGProxy *proxy, + DBusGProxyCall *call_id, + void *user_data); + +GType dbus_g_proxy_get_type (void) G_GNUC_CONST; +DBusGProxy* dbus_g_proxy_new_for_name (DBusGConnection *connection, + const char *name, + const char *path, + const char *iface); +DBusGProxy* dbus_g_proxy_new_for_name_owner (DBusGConnection *connection, + const char *name, + const char *path, + const char *iface, + GError **error); +DBusGProxy* dbus_g_proxy_new_from_proxy (DBusGProxy *proxy, + const char *iface, + const char *path); +DBusGProxy* dbus_g_proxy_new_for_peer (DBusGConnection *connection, + const char *path, + const char *iface); + +void dbus_g_proxy_set_interface (DBusGProxy *proxy, + const char *interface_name); +void dbus_g_proxy_add_signal (DBusGProxy *proxy, + const char *signal_name, + GType first_type, + ...); + +void dbus_g_proxy_connect_signal (DBusGProxy *proxy, + const char *signal_name, + GCallback handler, + void *data, + GClosureNotify free_data_func); +void dbus_g_proxy_disconnect_signal (DBusGProxy *proxy, + const char *signal_name, + GCallback handler, + void *data); + +gboolean dbus_g_proxy_call (DBusGProxy *proxy, + const char *method, + GError **error, + GType first_arg_type, + ...); + +gboolean dbus_g_proxy_call_with_timeout (DBusGProxy *proxy, + const char *method, + int timeout, + GError **error, + GType first_arg_type, + ...); + +void dbus_g_proxy_call_no_reply (DBusGProxy *proxy, + const char *method, + GType first_arg_type, + ...); + +DBusGProxyCall * dbus_g_proxy_begin_call (DBusGProxy *proxy, + const char *method, + DBusGProxyCallNotify notify, + gpointer user_data, + GDestroyNotify destroy, + GType first_arg_type, + ...); +DBusGProxyCall * dbus_g_proxy_begin_call_with_timeout (DBusGProxy *proxy, + const char *method, + DBusGProxyCallNotify notify, + gpointer user_data, + GDestroyNotify destroy, + int timeout, + GType first_arg_type, + ...); + +void dbus_g_proxy_set_default_timeout (DBusGProxy *proxy, + int timeout); + +gboolean dbus_g_proxy_end_call (DBusGProxy *proxy, + DBusGProxyCall *call, + GError **error, + GType first_arg_type, + ...); +void dbus_g_proxy_cancel_call (DBusGProxy *proxy, + DBusGProxyCall *call); + +const char* dbus_g_proxy_get_path (DBusGProxy *proxy); + +const char* dbus_g_proxy_get_bus_name (DBusGProxy *proxy); + +const char* dbus_g_proxy_get_interface (DBusGProxy *proxy); + +typedef struct _DBusGMethodInvocation DBusGMethodInvocation; + +void dbus_g_method_return (DBusGMethodInvocation *context, ...); + +void dbus_g_method_return_error (DBusGMethodInvocation *context, const GError *error); + +DBusGConnection * dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context); + +/* Probably possible to replace this with a closure */ +typedef struct { + GCallback cb; + gpointer userdata; +} DBusGAsyncData; + +#undef DBUS_INSIDE_DBUS_GLIB_H + +#include + +G_END_DECLS + +#endif /* DBUS_GLIB_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-gtype-specialized.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-gtype-specialized.h new file mode 100644 index 00000000..26b4e1f5 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-gtype-specialized.h @@ -0,0 +1,180 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-gtype-specialized.h: Non-DBus-specific functions for specialized GTypes + * + * Copyright (C) 2005 Red Hat, Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef DBUS_GOBJECT_TYPE_SPECIALIZED_H +#define DBUS_GOBJECT_TYPE_SPECIALIZED_H + +#include +#include + +G_BEGIN_DECLS + +GType dbus_g_type_get_collection (const char *container, + GType specialization); +GType dbus_g_type_get_map (const char *container, + GType key_specialization, + GType value_specialization); +GType dbus_g_type_get_structv (const char *container, + guint num_members, + GType *types); +GType dbus_g_type_get_struct (const char *container, + GType first_type, + ...); +gboolean dbus_g_type_is_collection (GType gtype); +gboolean dbus_g_type_is_map (GType gtype); +gboolean dbus_g_type_is_struct (GType gtype); +GType dbus_g_type_get_collection_specialization (GType gtype); +GType dbus_g_type_get_map_key_specialization (GType gtype); +GType dbus_g_type_get_map_value_specialization (GType gtype); +GType dbus_g_type_get_struct_member_type (GType gtype, + guint member); +guint dbus_g_type_get_struct_size (GType gtype); + +typedef void (*DBusGTypeSpecializedCollectionIterator) (const GValue *value, + gpointer user_data); +typedef void (*DBusGTypeSpecializedMapIterator) (const GValue *key_val, + const GValue *value_val, + gpointer user_data); + +gpointer dbus_g_type_specialized_construct (GType gtype); + +typedef struct { + /* public */ + GValue *val; + GType specialization_type; + /*< private >*/ + /* padding */ + gpointer b; + guint c; + gpointer d; +} DBusGTypeSpecializedAppendContext; + +void dbus_g_type_specialized_init_append (GValue *value, DBusGTypeSpecializedAppendContext *ctx); + +void dbus_g_type_specialized_collection_append (DBusGTypeSpecializedAppendContext *ctx, GValue *elt); + +void dbus_g_type_specialized_collection_end_append (DBusGTypeSpecializedAppendContext *ctx); + +void dbus_g_type_specialized_map_append (DBusGTypeSpecializedAppendContext *ctx, + GValue *key, + GValue *val); + + +gboolean dbus_g_type_collection_get_fixed (GValue *value, + gpointer *data_ret, + guint *len_ret); + +void dbus_g_type_collection_value_iterate (const GValue *value, + DBusGTypeSpecializedCollectionIterator iterator, + gpointer user_data); + +void dbus_g_type_map_value_iterate (const GValue *value, + DBusGTypeSpecializedMapIterator iterator, + gpointer user_data); + +gboolean dbus_g_type_struct_get_member (const GValue *value, + guint member, + GValue *dest); +gboolean dbus_g_type_struct_set_member (GValue *value, + guint member, + const GValue *src); + +gboolean dbus_g_type_struct_get (const GValue *value, + guint member, + ...); + +gboolean dbus_g_type_struct_set (GValue *value, + guint member, + ...); + +typedef gpointer (*DBusGTypeSpecializedConstructor) (GType type); +typedef void (*DBusGTypeSpecializedFreeFunc) (GType type, gpointer val); +typedef gpointer (*DBusGTypeSpecializedCopyFunc) (GType type, gpointer src); + +typedef struct { + DBusGTypeSpecializedConstructor constructor; + DBusGTypeSpecializedFreeFunc free_func; + DBusGTypeSpecializedCopyFunc copy_func; + GDestroyNotify simple_free_func; /* for type-independent freeing if possible */ + /**/ + gpointer padding2; + gpointer padding3; +} DBusGTypeSpecializedVtable; + +typedef gboolean (*DBusGTypeSpecializedCollectionFixedAccessorFunc) (GType type, gpointer instance, gpointer *values, guint *len); +typedef void (*DBusGTypeSpecializedCollectionIteratorFunc) (GType type, gpointer instance, DBusGTypeSpecializedCollectionIterator iterator, gpointer user_data); +typedef void (*DBusGTypeSpecializedCollectionAppendFunc) (DBusGTypeSpecializedAppendContext *ctx, GValue *val); +typedef void (*DBusGTypeSpecializedCollectionEndAppendFunc) (DBusGTypeSpecializedAppendContext *ctx); + +typedef struct { + DBusGTypeSpecializedVtable base_vtable; + DBusGTypeSpecializedCollectionFixedAccessorFunc fixed_accessor; + DBusGTypeSpecializedCollectionIteratorFunc iterator; + DBusGTypeSpecializedCollectionAppendFunc append_func; + DBusGTypeSpecializedCollectionEndAppendFunc end_append_func; +} DBusGTypeSpecializedCollectionVtable; + +typedef void (*DBusGTypeSpecializedMapIteratorFunc) (GType type, gpointer instance, DBusGTypeSpecializedMapIterator iterator, gpointer user_data); +typedef void (*DBusGTypeSpecializedMapAppendFunc) (DBusGTypeSpecializedAppendContext *ctx, GValue *key, GValue *val); + +typedef struct { + DBusGTypeSpecializedVtable base_vtable; + DBusGTypeSpecializedMapIteratorFunc iterator; + DBusGTypeSpecializedMapAppendFunc append_func; +} DBusGTypeSpecializedMapVtable; + +typedef gboolean (*DBusGTypeSpecializedStructGetMember) (GType type, gpointer instance, guint member, GValue *ret_value); +typedef gboolean (*DBusGTypeSpecializedStructSetMember) (GType type, gpointer instance, guint member, const GValue *new_value); + +typedef struct { + DBusGTypeSpecializedVtable base_vtable; + DBusGTypeSpecializedStructGetMember get_member; + DBusGTypeSpecializedStructSetMember set_member; +} DBusGTypeSpecializedStructVtable; + +void dbus_g_type_specialized_init (void); + +void dbus_g_type_register_collection (const char *name, + const DBusGTypeSpecializedCollectionVtable *vtable, + guint flags); + +void dbus_g_type_register_map (const char *name, + const DBusGTypeSpecializedMapVtable *vtable, + guint flags); + +void dbus_g_type_register_struct (const char *name, + const DBusGTypeSpecializedStructVtable *vtable, + guint flags); + +const DBusGTypeSpecializedMapVtable* dbus_g_type_map_peek_vtable (GType map_type); +const DBusGTypeSpecializedCollectionVtable* dbus_g_type_collection_peek_vtable (GType collection_type); + +const DBusGTypeSpecializedStructVtable* dbus_g_type_struct_peek_vtable (GType struct_type); + +GVariant *dbus_g_value_build_g_variant (const GValue *value); + +G_END_DECLS + +#endif diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-gvalue-parse-variant.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-gvalue-parse-variant.h new file mode 100644 index 00000000..22794a7a --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-gvalue-parse-variant.h @@ -0,0 +1,41 @@ +/* GVariant to dbus-glib escape hatch + * + * Copyright © 2010 Collabora Ltd. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later OR LGPL-2.1-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Alternatively, at your option, you can redistribute and/or modify + * this single file under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * that license, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __DBUS_GVALUE_PARSE_VARIANT_H__ +#define __DBUS_GVALUE_PARSE_VARIANT_H__ + +#include + +G_BEGIN_DECLS + +void dbus_g_value_parse_g_variant (GVariant *variant, GValue *value); + +G_END_DECLS + +#endif diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-macros.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-macros.h new file mode 100644 index 00000000..5ca7bf0a --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-macros.h @@ -0,0 +1,237 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-macros.h generic macros + * + * Copyright (C) 2002 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_MACROS_H +#define DBUS_MACROS_H + +#ifdef __cplusplus +# define DBUS_BEGIN_DECLS extern "C" { +# define DBUS_END_DECLS } +#else +# define DBUS_BEGIN_DECLS +# define DBUS_END_DECLS +#endif + +#ifndef TRUE +# define TRUE 1 +#endif +#ifndef FALSE +# define FALSE 0 +#endif + +#ifndef NULL +# ifdef __cplusplus +# define NULL (0L) +# else /* !__cplusplus */ +# define NULL ((void*) 0) +# endif /* !__cplusplus */ +#endif + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +# define DBUS_DEPRECATED __attribute__ ((__deprecated__)) +#elif defined(_MSC_VER) && (_MSC_VER >= 1300) +# define DBUS_DEPRECATED __declspec(deprecated) +#else +# define DBUS_DEPRECATED +#endif + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) +# define _DBUS_GNUC_EXTENSION __extension__ +#else +# define _DBUS_GNUC_EXTENSION +#endif + +#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)) || \ + defined(__clang__) +#define _DBUS_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#define _DBUS_GNUC_NORETURN \ + __attribute__((__noreturn__)) +#define _DBUS_GNUC_UNUSED \ + __attribute__((__unused__)) +#else /* !__GNUC__ */ +#define _DBUS_GNUC_PRINTF( format_idx, arg_idx ) +#define _DBUS_GNUC_NORETURN +#define _DBUS_GNUC_UNUSED +#endif /* !__GNUC__ */ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#define DBUS_MALLOC __attribute__((__malloc__)) +#else +#define DBUS_MALLOC +#endif + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#define DBUS_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) +#define DBUS_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y))) +#else +#define DBUS_ALLOC_SIZE(x) +#define DBUS_ALLOC_SIZE2(x,y) +#endif + +/** @def _DBUS_WARN_UNUSED_RESULT + * + * An attribute for functions whose result must be checked by the caller. + * + * This macro is used in function declarations. Unlike gcc-specific + * attributes, to avoid compilation failure with MSVC it must appear + * somewhere before the function name in the declaration. Our preferred + * coding style is to place it before the return type, for example: + * + * DBUS_PRIVATE_EXPORT _DBUS_WARN_UNUSED_RESULT + * dbus_bool_t _dbus_user_database_lock_system (void); + */ +#if defined(_MSC_VER) && (_MSC_VER >= 1700) +#define _DBUS_WARN_UNUSED_RESULT _Must_inspect_result_ +#elif (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +#define _DBUS_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define _DBUS_WARN_UNUSED_RESULT +#endif + +/** @def _DBUS_GNUC_PRINTF + * used to tell gcc about printf format strings + */ +/** @def _DBUS_GNUC_NORETURN + * used to tell gcc about functions that never return, such as _dbus_abort() + */ + +/* Normally docs are in .c files, but there isn't a .c file for this. */ +/** + * @defgroup DBusMacros Utility macros + * @ingroup DBus + * @brief #TRUE, #FALSE, #NULL, and so on + * + * Utility macros. + * + * @{ + */ + +/** + * @def DBUS_BEGIN_DECLS + * + * Macro used prior to declaring functions in the D-Bus header + * files. Expands to "extern "C"" when using a C++ compiler, + * and expands to nothing when using a C compiler. + * + * Please don't use this in your own code, consider it + * D-Bus internal. + */ +/** + * @def DBUS_END_DECLS + * + * Macro used after declaring functions in the D-Bus header + * files. Expands to "}" when using a C++ compiler, + * and expands to nothing when using a C compiler. + * + * Please don't use this in your own code, consider it + * D-Bus internal. + */ +/** + * @def TRUE + * + * Expands to "1" + */ +/** + * @def FALSE + * + * Expands to "0" + */ +/** + * @def NULL + * + * A null pointer, defined appropriately for C or C++. + */ +/** + * @def DBUS_DEPRECATED + * + * Tells the compiler to warn about a function or type if it's used. + * Code marked in this way should also be enclosed in + * @code + * #ifndef DBUS_DISABLE_DEPRECATED + * deprecated stuff here + * #endif + * @endcode + * + * Please don't use this in your own code, consider it + * D-Bus internal. + */ +/** + * @def _DBUS_GNUC_EXTENSION + * + * Tells gcc not to warn about extensions to the C standard in the + * following expression, even if compiling with -pedantic. Do not use + * this macro in your own code; please consider it to be internal to libdbus. + */ + +/* + * @def DBUS_EXPORT + * + * Declare the following symbol as public. This is currently a noop on + * platforms other than Windows. + */ + +#if defined(DBUS_EXPORT) + /* value forced by compiler command line, don't redefine */ +#elif defined(_WIN32) +# if defined(DBUS_STATIC_BUILD) +# define DBUS_EXPORT +# elif defined(dbus_1_EXPORTS) +# define DBUS_EXPORT __declspec(dllexport) +# else +# define DBUS_EXPORT __declspec(dllimport) +# endif +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define DBUS_EXPORT __attribute__ ((__visibility__ ("default"))) +#else +#define DBUS_EXPORT +#endif + +/* Implementation for dbus_clear_message() etc. This is not API, + * do not use it directly. + * + * We're using a specific type (T ** and T *) instead of void ** and + * void * partly for type-safety, partly to be strict-aliasing-compliant, + * and partly to keep C++ compilers happy. This code is inlined into + * users of libdbus, so we can't rely on it having dbus' own compiler + * settings. */ +#define _dbus_clear_pointer_impl(T, pointer_to_pointer, destroy) \ + do { \ + T **_pp = (pointer_to_pointer); \ + T *_value = *_pp; \ + \ + *_pp = NULL; \ + \ + if (_value != NULL) \ + destroy (_value); \ + } while (0) +/* Not (destroy) (_value) in case destroy() is a function-like macro */ + +/** @} */ + +#endif /* DBUS_MACROS_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-memory.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-memory.h new file mode 100644 index 00000000..5b5a41e1 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-memory.h @@ -0,0 +1,74 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-memory.h D-Bus memory handling + * + * Copyright (C) 2002 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_MEMORY_H +#define DBUS_MEMORY_H + +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusMemory + * @{ + */ + +DBUS_EXPORT +DBUS_MALLOC +DBUS_ALLOC_SIZE(1) +void* dbus_malloc (size_t bytes); + +DBUS_EXPORT +DBUS_MALLOC +DBUS_ALLOC_SIZE(1) +void* dbus_malloc0 (size_t bytes); + +DBUS_EXPORT +DBUS_ALLOC_SIZE(2) +void* dbus_realloc (void *memory, + size_t bytes); +DBUS_EXPORT +void dbus_free (void *memory); + +#define dbus_new(type, count) ((type*)dbus_malloc (sizeof (type) * (count))) +#define dbus_new0(type, count) ((type*)dbus_malloc0 (sizeof (type) * (count))) + +DBUS_EXPORT +void dbus_free_string_array (char **str_array); + +typedef void (* DBusFreeFunction) (void *memory); + +DBUS_EXPORT +void dbus_shutdown (void); + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_MEMORY_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-message.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-message.h new file mode 100644 index 00000000..dd2dcc63 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-message.h @@ -0,0 +1,397 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-message.h DBusMessage object + * + * Copyright (C) 2002, 2003, 2005 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_MESSAGE_H +#define DBUS_MESSAGE_H + +#include +#include +#include +#include +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusMessage + * @{ + */ + +typedef struct DBusMessage DBusMessage; +/** + * Opaque type representing a message iterator. Can be copied by value and + * allocated on the stack. + * + * A DBusMessageIter usually contains no allocated memory. However, there + * is one special case: after a successful call to + * dbus_message_iter_open_container(), the caller is responsible for calling + * either dbus_message_iter_close_container() or + * dbus_message_iter_abandon_container() exactly once, with the same pair + * of iterators. + */ +typedef struct DBusMessageIter DBusMessageIter; + +/** + * DBusMessageIter struct; contains no public fields. + */ +struct DBusMessageIter +{ +#if DBUS_SIZEOF_VOID_P > 8 + void *dummy[16]; /**< Don't use this */ +#else + void *dummy1; /**< Don't use this */ + void *dummy2; /**< Don't use this */ + dbus_uint32_t dummy3; /**< Don't use this */ + int dummy4; /**< Don't use this */ + int dummy5; /**< Don't use this */ + int dummy6; /**< Don't use this */ + int dummy7; /**< Don't use this */ + int dummy8; /**< Don't use this */ + int dummy9; /**< Don't use this */ + int dummy10; /**< Don't use this */ + int dummy11; /**< Don't use this */ + int pad1; /**< Don't use this */ + void *pad2; /**< Don't use this */ + void *pad3; /**< Don't use this */ +#endif +}; + +/** + * A message iterator for which dbus_message_iter_abandon_container_if_open() + * is the only valid operation. + */ +#if DBUS_SIZEOF_VOID_P > 8 +#define DBUS_MESSAGE_ITER_INIT_CLOSED \ +{ \ + { \ + NULL, NULL, NULL, NULL, \ + NULL, NULL, NULL, NULL, \ + NULL, NULL, NULL, NULL, \ + NULL, NULL, NULL, NULL \ + } \ +} +#else +#define DBUS_MESSAGE_ITER_INIT_CLOSED \ +{ \ + NULL, /* dummy1 */ \ + NULL, /* dummy2 */ \ + 0, /* dummy3 */ \ + 0, /* dummy4 */ \ + 0, /* dummy5 */ \ + 0, /* dummy6 */ \ + 0, /* dummy7 */ \ + 0, /* dummy8 */ \ + 0, /* dummy9 */ \ + 0, /* dummy10 */ \ + 0, /* dummy11 */ \ + 0, /* pad1 */ \ + NULL, /* pad2 */ \ + NULL /* pad3 */ \ +} +#endif + +DBUS_EXPORT +DBusMessage* dbus_message_new (int message_type); +DBUS_EXPORT +DBusMessage* dbus_message_new_method_call (const char *bus_name, + const char *path, + const char *iface, + const char *method); +DBUS_EXPORT +DBusMessage* dbus_message_new_method_return (DBusMessage *method_call); +DBUS_EXPORT +DBusMessage* dbus_message_new_signal (const char *path, + const char *iface, + const char *name); +DBUS_EXPORT +DBusMessage* dbus_message_new_error (DBusMessage *reply_to, + const char *error_name, + const char *error_message); +DBUS_EXPORT +DBusMessage* dbus_message_new_error_printf (DBusMessage *reply_to, + const char *error_name, + const char *error_format, + ...) _DBUS_GNUC_PRINTF (3, 4); + +DBUS_EXPORT +DBusMessage* dbus_message_copy (const DBusMessage *message); + +DBUS_EXPORT +DBusMessage* dbus_message_ref (DBusMessage *message); +DBUS_EXPORT +void dbus_message_unref (DBusMessage *message); +DBUS_EXPORT +int dbus_message_get_type (DBusMessage *message); +DBUS_EXPORT +dbus_bool_t dbus_message_set_path (DBusMessage *message, + const char *object_path); +DBUS_EXPORT +const char* dbus_message_get_path (DBusMessage *message); +DBUS_EXPORT +dbus_bool_t dbus_message_has_path (DBusMessage *message, + const char *object_path); +DBUS_EXPORT +dbus_bool_t dbus_message_set_interface (DBusMessage *message, + const char *iface); +DBUS_EXPORT +const char* dbus_message_get_interface (DBusMessage *message); +DBUS_EXPORT +dbus_bool_t dbus_message_has_interface (DBusMessage *message, + const char *iface); +DBUS_EXPORT +dbus_bool_t dbus_message_set_member (DBusMessage *message, + const char *member); +DBUS_EXPORT +const char* dbus_message_get_member (DBusMessage *message); +DBUS_EXPORT +dbus_bool_t dbus_message_has_member (DBusMessage *message, + const char *member); +DBUS_EXPORT +dbus_bool_t dbus_message_set_error_name (DBusMessage *message, + const char *name); +DBUS_EXPORT +const char* dbus_message_get_error_name (DBusMessage *message); +DBUS_EXPORT +dbus_bool_t dbus_message_set_destination (DBusMessage *message, + const char *destination); +DBUS_EXPORT +const char* dbus_message_get_destination (DBusMessage *message); +DBUS_EXPORT +dbus_bool_t dbus_message_set_sender (DBusMessage *message, + const char *sender); +DBUS_EXPORT +const char* dbus_message_get_sender (DBusMessage *message); +DBUS_EXPORT +const char* dbus_message_get_signature (DBusMessage *message); +DBUS_EXPORT +void dbus_message_set_no_reply (DBusMessage *message, + dbus_bool_t no_reply); +DBUS_EXPORT +dbus_bool_t dbus_message_get_no_reply (DBusMessage *message); +DBUS_EXPORT +dbus_bool_t dbus_message_is_method_call (DBusMessage *message, + const char *iface, + const char *method); +DBUS_EXPORT +dbus_bool_t dbus_message_is_signal (DBusMessage *message, + const char *iface, + const char *signal_name); +DBUS_EXPORT +dbus_bool_t dbus_message_is_error (DBusMessage *message, + const char *error_name); +DBUS_EXPORT +dbus_bool_t dbus_message_has_destination (DBusMessage *message, + const char *bus_name); +DBUS_EXPORT +dbus_bool_t dbus_message_has_sender (DBusMessage *message, + const char *unique_bus_name); +DBUS_EXPORT +dbus_bool_t dbus_message_has_signature (DBusMessage *message, + const char *signature); +DBUS_EXPORT +dbus_uint32_t dbus_message_get_serial (DBusMessage *message); +DBUS_EXPORT +void dbus_message_set_serial (DBusMessage *message, + dbus_uint32_t serial); +DBUS_EXPORT +dbus_bool_t dbus_message_set_reply_serial (DBusMessage *message, + dbus_uint32_t reply_serial); +DBUS_EXPORT +dbus_uint32_t dbus_message_get_reply_serial (DBusMessage *message); + +DBUS_EXPORT +void dbus_message_set_auto_start (DBusMessage *message, + dbus_bool_t auto_start); +DBUS_EXPORT +dbus_bool_t dbus_message_get_auto_start (DBusMessage *message); + +DBUS_EXPORT +dbus_bool_t dbus_message_get_path_decomposed (DBusMessage *message, + char ***path); + +DBUS_EXPORT +const char *dbus_message_get_container_instance (DBusMessage *message); +DBUS_EXPORT +dbus_bool_t dbus_message_set_container_instance (DBusMessage *message, + const char *object_path); + +DBUS_EXPORT +dbus_bool_t dbus_message_append_args (DBusMessage *message, + int first_arg_type, + ...); +DBUS_EXPORT +dbus_bool_t dbus_message_append_args_valist (DBusMessage *message, + int first_arg_type, + va_list var_args); +DBUS_EXPORT +dbus_bool_t dbus_message_get_args (DBusMessage *message, + DBusError *error, + int first_arg_type, + ...); +DBUS_EXPORT +dbus_bool_t dbus_message_get_args_valist (DBusMessage *message, + DBusError *error, + int first_arg_type, + va_list var_args); + +DBUS_EXPORT +dbus_bool_t dbus_message_contains_unix_fds (DBusMessage *message); + +DBUS_EXPORT +void dbus_message_iter_init_closed (DBusMessageIter *iter); +DBUS_EXPORT +dbus_bool_t dbus_message_iter_init (DBusMessage *message, + DBusMessageIter *iter); +DBUS_EXPORT +dbus_bool_t dbus_message_iter_has_next (DBusMessageIter *iter); +DBUS_EXPORT +dbus_bool_t dbus_message_iter_next (DBusMessageIter *iter); +DBUS_EXPORT +char* dbus_message_iter_get_signature (DBusMessageIter *iter); +DBUS_EXPORT +int dbus_message_iter_get_arg_type (DBusMessageIter *iter); +DBUS_EXPORT +int dbus_message_iter_get_element_type (DBusMessageIter *iter); +DBUS_EXPORT +void dbus_message_iter_recurse (DBusMessageIter *iter, + DBusMessageIter *sub); +DBUS_EXPORT +void dbus_message_iter_get_basic (DBusMessageIter *iter, + void *value); +DBUS_EXPORT +int dbus_message_iter_get_element_count(DBusMessageIter *iter); + +#ifndef DBUS_DISABLE_DEPRECATED +/* This function returns the wire protocol size of the array in bytes, + * you do not want to know that probably + */ +DBUS_EXPORT +DBUS_DEPRECATED int dbus_message_iter_get_array_len (DBusMessageIter *iter); +#endif +DBUS_EXPORT +void dbus_message_iter_get_fixed_array (DBusMessageIter *iter, + void *value, + int *n_elements); + + +DBUS_EXPORT +void dbus_message_iter_init_append (DBusMessage *message, + DBusMessageIter *iter); +DBUS_EXPORT +dbus_bool_t dbus_message_iter_append_basic (DBusMessageIter *iter, + int type, + const void *value); +DBUS_EXPORT +dbus_bool_t dbus_message_iter_append_fixed_array (DBusMessageIter *iter, + int element_type, + const void *value, + int n_elements); +DBUS_EXPORT +dbus_bool_t dbus_message_iter_open_container (DBusMessageIter *iter, + int type, + const char *contained_signature, + DBusMessageIter *sub); +DBUS_EXPORT +dbus_bool_t dbus_message_iter_close_container (DBusMessageIter *iter, + DBusMessageIter *sub); +DBUS_EXPORT +void dbus_message_iter_abandon_container (DBusMessageIter *iter, + DBusMessageIter *sub); + +DBUS_EXPORT +void dbus_message_iter_abandon_container_if_open (DBusMessageIter *iter, + DBusMessageIter *sub); + +DBUS_EXPORT +void dbus_message_lock (DBusMessage *message); + +DBUS_EXPORT +dbus_bool_t dbus_set_error_from_message (DBusError *error, + DBusMessage *message); + + +DBUS_EXPORT +dbus_bool_t dbus_message_allocate_data_slot (dbus_int32_t *slot_p); +DBUS_EXPORT +void dbus_message_free_data_slot (dbus_int32_t *slot_p); +DBUS_EXPORT +dbus_bool_t dbus_message_set_data (DBusMessage *message, + dbus_int32_t slot, + void *data, + DBusFreeFunction free_data_func); +DBUS_EXPORT +void* dbus_message_get_data (DBusMessage *message, + dbus_int32_t slot); + +DBUS_EXPORT +int dbus_message_type_from_string (const char *type_str); +DBUS_EXPORT +const char* dbus_message_type_to_string (int type); + +DBUS_EXPORT +dbus_bool_t dbus_message_marshal (DBusMessage *msg, + char **marshalled_data_p, + int *len_p); +DBUS_EXPORT +DBusMessage* dbus_message_demarshal (const char *str, + int len, + DBusError *error); + +DBUS_EXPORT +int dbus_message_demarshal_bytes_needed (const char *str, + int len); + +DBUS_EXPORT +void dbus_message_set_allow_interactive_authorization (DBusMessage *message, + dbus_bool_t allow); + +DBUS_EXPORT +dbus_bool_t dbus_message_get_allow_interactive_authorization ( + DBusMessage *message); + +/** + * Clear a variable or struct member that contains a #DBusMessage. + * If it does not contain #NULL, the message that was previously + * there is unreferenced with dbus_message_unref(). + * + * This is very similar to dbus_clear_connection(): see that function + * for more details. + * + * @param pointer_to_message A pointer to a variable or struct member. + * pointer_to_message must not be #NULL, but *pointer_to_message + * may be #NULL. + */ +#define dbus_clear_message(pointer) \ + _dbus_clear_pointer_impl(DBusMessage, (pointer), dbus_message_unref) + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_MESSAGE_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-misc.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-misc.h new file mode 100644 index 00000000..3442ab78 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-misc.h @@ -0,0 +1,60 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-misc.h A few assorted public functions that don't fit elsewhere + * + * Copyright (C) 2006 Red Hat, Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_MISC_H +#define DBUS_MISC_H + +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusMisc + * @{ + */ +DBUS_EXPORT +char* dbus_get_local_machine_id (void); + +DBUS_EXPORT +void dbus_get_version (int *major_version_p, + int *minor_version_p, + int *micro_version_p); + +DBUS_EXPORT +dbus_bool_t dbus_setenv (const char *variable, + const char *value); + +DBUS_EXPORT +char *dbus_try_get_local_machine_id (DBusError *error); + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_MISC_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-pending-call.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-pending-call.h new file mode 100644 index 00000000..4d4cd47b --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-pending-call.h @@ -0,0 +1,97 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-pending-call.h Object representing a call in progress. + * + * Copyright (C) 2002, 2003 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_PENDING_CALL_H +#define DBUS_PENDING_CALL_H + +#include +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusPendingCall + * @{ + */ + +#define DBUS_TIMEOUT_INFINITE ((int) 0x7fffffff) +#define DBUS_TIMEOUT_USE_DEFAULT (-1) + +DBUS_EXPORT +DBusPendingCall* dbus_pending_call_ref (DBusPendingCall *pending); +DBUS_EXPORT +void dbus_pending_call_unref (DBusPendingCall *pending); +DBUS_EXPORT +dbus_bool_t dbus_pending_call_set_notify (DBusPendingCall *pending, + DBusPendingCallNotifyFunction function, + void *user_data, + DBusFreeFunction free_user_data); +DBUS_EXPORT +void dbus_pending_call_cancel (DBusPendingCall *pending); +DBUS_EXPORT +dbus_bool_t dbus_pending_call_get_completed (DBusPendingCall *pending); +DBUS_EXPORT +DBusMessage* dbus_pending_call_steal_reply (DBusPendingCall *pending); +DBUS_EXPORT +void dbus_pending_call_block (DBusPendingCall *pending); + +DBUS_EXPORT +dbus_bool_t dbus_pending_call_allocate_data_slot (dbus_int32_t *slot_p); +DBUS_EXPORT +void dbus_pending_call_free_data_slot (dbus_int32_t *slot_p); +DBUS_EXPORT +dbus_bool_t dbus_pending_call_set_data (DBusPendingCall *pending, + dbus_int32_t slot, + void *data, + DBusFreeFunction free_data_func); +DBUS_EXPORT +void* dbus_pending_call_get_data (DBusPendingCall *pending, + dbus_int32_t slot); + +/** + * Clear a variable or struct member that contains a #DBusPendingCall. + * If it does not contain #NULL, the pending call that was previously + * there is unreferenced with dbus_pending_call_unref(). + * + * This is very similar to dbus_clear_connection(): see that function + * for more details. + * + * @param pointer_to_pending_call A pointer to a variable or struct member. + * pointer_to_pending_call must not be #NULL, but *pointer_to_pending_call + * may be #NULL. + */ +#define dbus_clear_pending_call(pointer) \ + _dbus_clear_pointer_impl(DBusPendingCall, (pointer), \ + dbus_pending_call_unref) + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_PENDING_CALL_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-protocol.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-protocol.h new file mode 100644 index 00000000..33e39df3 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-protocol.h @@ -0,0 +1,488 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-protocol.h D-Bus protocol constants + * + * Copyright (C) 2002, 2003 CodeFactory AB + * Copyright (C) 2004, 2005 Red Hat, Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef DBUS_PROTOCOL_H +#define DBUS_PROTOCOL_H + +/* Don't include anything in here from anywhere else. It's + * intended for use by any random library. + */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* avoids confusing emacs indentation */ +#endif +#endif + +/* Normally docs are in .c files, but there isn't a .c file for this. */ +/** + * @defgroup DBusProtocol Protocol constants + * @ingroup DBus + * + * @brief Defines constants which are part of the D-Bus protocol + * + * This header is intended for use by any library, not only libdbus. + * + * @{ + */ + + +/* Message byte order */ +#define DBUS_LITTLE_ENDIAN ('l') /**< Code marking LSB-first byte order in the wire protocol. */ +#define DBUS_BIG_ENDIAN ('B') /**< Code marking MSB-first byte order in the wire protocol. */ + +/** Protocol version. */ +#define DBUS_MAJOR_PROTOCOL_VERSION 1 + +/** Type code that is never equal to a legitimate type code */ +#define DBUS_TYPE_INVALID ((int) '\0') +/** #DBUS_TYPE_INVALID as a string literal instead of a int literal */ +#define DBUS_TYPE_INVALID_AS_STRING "\0" + +/* Primitive types */ +/** Type code marking an 8-bit unsigned integer */ +#define DBUS_TYPE_BYTE ((int) 'y') +/** #DBUS_TYPE_BYTE as a string literal instead of a int literal */ +#define DBUS_TYPE_BYTE_AS_STRING "y" +/** Type code marking a boolean */ +#define DBUS_TYPE_BOOLEAN ((int) 'b') +/** #DBUS_TYPE_BOOLEAN as a string literal instead of a int literal */ +#define DBUS_TYPE_BOOLEAN_AS_STRING "b" +/** Type code marking a 16-bit signed integer */ +#define DBUS_TYPE_INT16 ((int) 'n') +/** #DBUS_TYPE_INT16 as a string literal instead of a int literal */ +#define DBUS_TYPE_INT16_AS_STRING "n" +/** Type code marking a 16-bit unsigned integer */ +#define DBUS_TYPE_UINT16 ((int) 'q') +/** #DBUS_TYPE_UINT16 as a string literal instead of a int literal */ +#define DBUS_TYPE_UINT16_AS_STRING "q" +/** Type code marking a 32-bit signed integer */ +#define DBUS_TYPE_INT32 ((int) 'i') +/** #DBUS_TYPE_INT32 as a string literal instead of a int literal */ +#define DBUS_TYPE_INT32_AS_STRING "i" +/** Type code marking a 32-bit unsigned integer */ +#define DBUS_TYPE_UINT32 ((int) 'u') +/** #DBUS_TYPE_UINT32 as a string literal instead of a int literal */ +#define DBUS_TYPE_UINT32_AS_STRING "u" +/** Type code marking a 64-bit signed integer */ +#define DBUS_TYPE_INT64 ((int) 'x') +/** #DBUS_TYPE_INT64 as a string literal instead of a int literal */ +#define DBUS_TYPE_INT64_AS_STRING "x" +/** Type code marking a 64-bit unsigned integer */ +#define DBUS_TYPE_UINT64 ((int) 't') +/** #DBUS_TYPE_UINT64 as a string literal instead of a int literal */ +#define DBUS_TYPE_UINT64_AS_STRING "t" +/** Type code marking an 8-byte double in IEEE 754 format */ +#define DBUS_TYPE_DOUBLE ((int) 'd') +/** #DBUS_TYPE_DOUBLE as a string literal instead of a int literal */ +#define DBUS_TYPE_DOUBLE_AS_STRING "d" +/** Type code marking a UTF-8 encoded, nul-terminated Unicode string */ +#define DBUS_TYPE_STRING ((int) 's') +/** #DBUS_TYPE_STRING as a string literal instead of a int literal */ +#define DBUS_TYPE_STRING_AS_STRING "s" +/** Type code marking a D-Bus object path */ +#define DBUS_TYPE_OBJECT_PATH ((int) 'o') +/** #DBUS_TYPE_OBJECT_PATH as a string literal instead of a int literal */ +#define DBUS_TYPE_OBJECT_PATH_AS_STRING "o" +/** Type code marking a D-Bus type signature */ +#define DBUS_TYPE_SIGNATURE ((int) 'g') +/** #DBUS_TYPE_SIGNATURE as a string literal instead of a int literal */ +#define DBUS_TYPE_SIGNATURE_AS_STRING "g" +/** Type code marking a unix file descriptor */ +#define DBUS_TYPE_UNIX_FD ((int) 'h') +/** #DBUS_TYPE_UNIX_FD as a string literal instead of a int literal */ +#define DBUS_TYPE_UNIX_FD_AS_STRING "h" + +/* Compound types */ +/** Type code marking a D-Bus array type */ +#define DBUS_TYPE_ARRAY ((int) 'a') +/** #DBUS_TYPE_ARRAY as a string literal instead of a int literal */ +#define DBUS_TYPE_ARRAY_AS_STRING "a" +/** Type code marking a D-Bus variant type */ +#define DBUS_TYPE_VARIANT ((int) 'v') +/** #DBUS_TYPE_VARIANT as a string literal instead of a int literal */ +#define DBUS_TYPE_VARIANT_AS_STRING "v" + +/** STRUCT and DICT_ENTRY are sort of special since their codes can't + * appear in a type string, instead + * DBUS_STRUCT_BEGIN_CHAR/DBUS_DICT_ENTRY_BEGIN_CHAR have to appear + */ +/** Type code used to represent a struct; however, this type code does not appear + * in type signatures, instead #DBUS_STRUCT_BEGIN_CHAR and #DBUS_STRUCT_END_CHAR will + * appear in a signature. + */ +#define DBUS_TYPE_STRUCT ((int) 'r') +/** #DBUS_TYPE_STRUCT as a string literal instead of a int literal */ +#define DBUS_TYPE_STRUCT_AS_STRING "r" +/** Type code used to represent a dict entry; however, this type code does not appear + * in type signatures, instead #DBUS_DICT_ENTRY_BEGIN_CHAR and #DBUS_DICT_ENTRY_END_CHAR will + * appear in a signature. + */ +#define DBUS_TYPE_DICT_ENTRY ((int) 'e') +/** #DBUS_TYPE_DICT_ENTRY as a string literal instead of a int literal */ +#define DBUS_TYPE_DICT_ENTRY_AS_STRING "e" + +/** Does not include #DBUS_TYPE_INVALID, #DBUS_STRUCT_BEGIN_CHAR, #DBUS_STRUCT_END_CHAR, + * #DBUS_DICT_ENTRY_BEGIN_CHAR, or #DBUS_DICT_ENTRY_END_CHAR - i.e. it is the number of + * valid types, not the number of distinct characters that may appear in a type signature. + */ +#define DBUS_NUMBER_OF_TYPES (16) + +/* characters other than typecodes that appear in type signatures */ + +/** Code marking the start of a struct type in a type signature */ +#define DBUS_STRUCT_BEGIN_CHAR ((int) '(') +/** #DBUS_STRUCT_BEGIN_CHAR as a string literal instead of a int literal */ +#define DBUS_STRUCT_BEGIN_CHAR_AS_STRING "(" +/** Code marking the end of a struct type in a type signature */ +#define DBUS_STRUCT_END_CHAR ((int) ')') +/** #DBUS_STRUCT_END_CHAR a string literal instead of a int literal */ +#define DBUS_STRUCT_END_CHAR_AS_STRING ")" +/** Code marking the start of a dict entry type in a type signature */ +#define DBUS_DICT_ENTRY_BEGIN_CHAR ((int) '{') +/** #DBUS_DICT_ENTRY_BEGIN_CHAR as a string literal instead of a int literal */ +#define DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING "{" +/** Code marking the end of a dict entry type in a type signature */ +#define DBUS_DICT_ENTRY_END_CHAR ((int) '}') +/** #DBUS_DICT_ENTRY_END_CHAR as a string literal instead of a int literal */ +#define DBUS_DICT_ENTRY_END_CHAR_AS_STRING "}" + +/** Max length in bytes of a bus name, interface, or member (not object + * path, paths are unlimited). This is limited because lots of stuff + * is O(n) in this number, plus it would be obnoxious to type in a + * paragraph-long method name so most likely something like that would + * be an exploit. + */ +#define DBUS_MAXIMUM_NAME_LENGTH 255 + +/** This one is 255 so it fits in a byte */ +#define DBUS_MAXIMUM_SIGNATURE_LENGTH 255 + +/** Max length of a match rule string; to keep people from hosing the + * daemon with some huge rule + */ +#define DBUS_MAXIMUM_MATCH_RULE_LENGTH 1024 + +/** Max arg number you can match on in a match rule, e.g. + * arg0='hello' is OK, arg3489720987='hello' is not + */ +#define DBUS_MAXIMUM_MATCH_RULE_ARG_NUMBER 63 + +/** Max length of a marshaled array in bytes (64M, 2^26) We use signed + * int for lengths so must be INT_MAX or less. We need something a + * bit smaller than INT_MAX because the array is inside a message with + * header info, etc. so an INT_MAX array wouldn't allow the message + * overhead. The 64M number is an attempt at a larger number than + * we'd reasonably ever use, but small enough that your bus would chew + * through it fairly quickly without locking up forever. If you have + * data that's likely to be larger than this, you should probably be + * sending it in multiple incremental messages anyhow. + */ +#define DBUS_MAXIMUM_ARRAY_LENGTH (67108864) +/** Number of bits you need in an unsigned to store the max array size */ +#define DBUS_MAXIMUM_ARRAY_LENGTH_BITS 26 + +/** The maximum total message size including header and body; similar + * rationale to max array size. + */ +#define DBUS_MAXIMUM_MESSAGE_LENGTH (DBUS_MAXIMUM_ARRAY_LENGTH * 2) +/** Number of bits you need in an unsigned to store the max message size */ +#define DBUS_MAXIMUM_MESSAGE_LENGTH_BITS 27 + +/** The maximum total number of unix fds in a message. Similar + * rationale as DBUS_MAXIMUM_MESSAGE_LENGTH. However we divide by four + * given that one fd is an int and hence at least 32 bits. + */ +#define DBUS_MAXIMUM_MESSAGE_UNIX_FDS (DBUS_MAXIMUM_MESSAGE_LENGTH/4) +/** Number of bits you need in an unsigned to store the max message unix fds */ +#define DBUS_MAXIMUM_MESSAGE_UNIX_FDS_BITS (DBUS_MAXIMUM_MESSAGE_LENGTH_BITS-2) + +/** Depth of recursion in the type tree. This is automatically limited + * to DBUS_MAXIMUM_SIGNATURE_LENGTH since you could only have an array + * of array of array of ... that fit in the max signature. But that's + * probably a bit too large. + */ +#define DBUS_MAXIMUM_TYPE_RECURSION_DEPTH 32 + +/* Types of message */ + +/** This value is never a valid message type, see dbus_message_get_type() */ +#define DBUS_MESSAGE_TYPE_INVALID 0 +/** Message type of a method call message, see dbus_message_get_type() */ +#define DBUS_MESSAGE_TYPE_METHOD_CALL 1 +/** Message type of a method return message, see dbus_message_get_type() */ +#define DBUS_MESSAGE_TYPE_METHOD_RETURN 2 +/** Message type of an error reply message, see dbus_message_get_type() */ +#define DBUS_MESSAGE_TYPE_ERROR 3 +/** Message type of a signal message, see dbus_message_get_type() */ +#define DBUS_MESSAGE_TYPE_SIGNAL 4 + +#define DBUS_NUM_MESSAGE_TYPES 5 + +/* Header flags */ + +/** If set, this flag means that the sender of a message does not care about getting + * a reply, so the recipient need not send one. See dbus_message_set_no_reply(). + */ +#define DBUS_HEADER_FLAG_NO_REPLY_EXPECTED 0x1 +/** + * If set, this flag means that even if the message bus knows how to start an owner for + * the destination bus name (see dbus_message_set_destination()), it should not + * do so. If this flag is not set, the bus may launch a program to process the + * message. + */ +#define DBUS_HEADER_FLAG_NO_AUTO_START 0x2 +/** + * If set on a method call, this flag means that the caller is prepared to + * wait for interactive authorization. + */ +#define DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION 0x4 + +/* Header fields */ + +/** Not equal to any valid header field code */ +#define DBUS_HEADER_FIELD_INVALID 0 +/** Header field code for the path - the path is the object emitting a signal or the object receiving a method call. + * See dbus_message_set_path(). + */ +#define DBUS_HEADER_FIELD_PATH 1 +/** Header field code for the interface containing a member (method or signal). + * See dbus_message_set_interface(). + */ +#define DBUS_HEADER_FIELD_INTERFACE 2 +/** Header field code for a member (method or signal). See dbus_message_set_member(). */ +#define DBUS_HEADER_FIELD_MEMBER 3 +/** Header field code for an error name (found in #DBUS_MESSAGE_TYPE_ERROR messages). + * See dbus_message_set_error_name(). + */ +#define DBUS_HEADER_FIELD_ERROR_NAME 4 +/** Header field code for a reply serial, used to match a #DBUS_MESSAGE_TYPE_METHOD_RETURN message with the + * message that it's a reply to. See dbus_message_set_reply_serial(). + */ +#define DBUS_HEADER_FIELD_REPLY_SERIAL 5 +/** + * Header field code for the destination bus name of a message. See dbus_message_set_destination(). + */ +#define DBUS_HEADER_FIELD_DESTINATION 6 +/** + * Header field code for the sender of a message; usually initialized by the message bus. + * See dbus_message_set_sender(). + */ +#define DBUS_HEADER_FIELD_SENDER 7 +/** + * Header field code for the type signature of a message. + */ +#define DBUS_HEADER_FIELD_SIGNATURE 8 +/** + * Header field code for the number of unix file descriptors associated + * with this message. + */ +#define DBUS_HEADER_FIELD_UNIX_FDS 9 +/** + * Header field code for the container instance that sent this message. + */ +#define DBUS_HEADER_FIELD_CONTAINER_INSTANCE 10 + + +/** + * Value of the highest-numbered header field code, can be used to determine + * the size of an array indexed by header field code. Remember though + * that unknown codes must be ignored, so check for that before + * indexing the array. + */ +#define DBUS_HEADER_FIELD_LAST DBUS_HEADER_FIELD_CONTAINER_INSTANCE + +/** Header format is defined as a signature: + * byte byte order + * byte message type ID + * byte flags + * byte protocol version + * uint32 body length + * uint32 serial + * array of struct (byte,variant) (field name, value) + * + * The length of the header can be computed as the + * fixed size of the initial data, plus the length of + * the array at the end, plus padding to an 8-boundary. + */ +#define DBUS_HEADER_SIGNATURE \ + DBUS_TYPE_BYTE_AS_STRING \ + DBUS_TYPE_BYTE_AS_STRING \ + DBUS_TYPE_BYTE_AS_STRING \ + DBUS_TYPE_BYTE_AS_STRING \ + DBUS_TYPE_UINT32_AS_STRING \ + DBUS_TYPE_UINT32_AS_STRING \ + DBUS_TYPE_ARRAY_AS_STRING \ + DBUS_STRUCT_BEGIN_CHAR_AS_STRING \ + DBUS_TYPE_BYTE_AS_STRING \ + DBUS_TYPE_VARIANT_AS_STRING \ + DBUS_STRUCT_END_CHAR_AS_STRING + + +/** + * The smallest header size that can occur. (It won't be valid due to + * missing required header fields.) This is 4 bytes, two uint32, an + * array length. This isn't any kind of resource limit, just the + * necessary/logical outcome of the header signature. + */ +#define DBUS_MINIMUM_HEADER_SIZE 16 + +/* Errors */ +/* WARNING these get autoconverted to an enum in dbus-glib.h. Thus, + * if you change the order it breaks the ABI. Keep them in order. + * Also, don't change the formatting since that will break the sed + * script. + */ +/** A generic error; "something went wrong" - see the error message for more. */ +#define DBUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed" +/** There was not enough memory to complete an operation. */ +#define DBUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" +/** The bus doesn't know how to launch a service to supply the bus name you wanted. */ +#define DBUS_ERROR_SERVICE_UNKNOWN "org.freedesktop.DBus.Error.ServiceUnknown" +/** The bus name you referenced doesn't exist (i.e. no application owns it). */ +#define DBUS_ERROR_NAME_HAS_NO_OWNER "org.freedesktop.DBus.Error.NameHasNoOwner" +/** No reply to a message expecting one, usually means a timeout occurred. */ +#define DBUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply" +/** Something went wrong reading or writing to a socket, for example. */ +#define DBUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError" +/** A D-Bus bus address was malformed. */ +#define DBUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress" +/** Requested operation isn't supported (like ENOSYS on UNIX). */ +#define DBUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported" +/** Some limited resource is exhausted. */ +#define DBUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded" +/** Security restrictions don't allow doing what you're trying to do. */ +#define DBUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied" +/** Authentication didn't work. */ +#define DBUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed" +/** Unable to connect to server (probably caused by ECONNREFUSED on a socket). */ +#define DBUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer" +/** Certain timeout errors, possibly ETIMEDOUT on a socket. + * Note that #DBUS_ERROR_NO_REPLY is used for message reply timeouts. + * @warning this is confusingly-named given that #DBUS_ERROR_TIMED_OUT also exists. We can't fix + * it for compatibility reasons so just be careful. + */ +#define DBUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout" +/** No network access (probably ENETUNREACH on a socket). */ +#define DBUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork" +/** Can't bind a socket since its address is in use (i.e. EADDRINUSE). */ +#define DBUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse" +/** The connection is disconnected and you're trying to use it. */ +#define DBUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected" +/** Invalid arguments passed to a method call. */ +#define DBUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs" +/** Missing file. */ +#define DBUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound" +/** Existing file and the operation you're using does not silently overwrite. */ +#define DBUS_ERROR_FILE_EXISTS "org.freedesktop.DBus.Error.FileExists" +/** Method name you invoked isn't known by the object you invoked it on. */ +#define DBUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" +/** Object you invoked a method on isn't known. */ +#define DBUS_ERROR_UNKNOWN_OBJECT "org.freedesktop.DBus.Error.UnknownObject" +/** Interface you invoked a method on isn't known by the object. */ +#define DBUS_ERROR_UNKNOWN_INTERFACE "org.freedesktop.DBus.Error.UnknownInterface" +/** Property you tried to access isn't known by the object. */ +#define DBUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty" +/** Property you tried to set is read-only. */ +#define DBUS_ERROR_PROPERTY_READ_ONLY "org.freedesktop.DBus.Error.PropertyReadOnly" +/** Certain timeout errors, e.g. while starting a service. + * @warning this is confusingly-named given that #DBUS_ERROR_TIMEOUT also exists. We can't fix + * it for compatibility reasons so just be careful. + */ +#define DBUS_ERROR_TIMED_OUT "org.freedesktop.DBus.Error.TimedOut" +/** Tried to remove or modify a match rule that didn't exist. */ +#define DBUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound" +/** The match rule isn't syntactically valid. */ +#define DBUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid" +/** While starting a new process, the exec() call failed. */ +#define DBUS_ERROR_SPAWN_EXEC_FAILED "org.freedesktop.DBus.Error.Spawn.ExecFailed" +/** While starting a new process, the fork() call failed. */ +#define DBUS_ERROR_SPAWN_FORK_FAILED "org.freedesktop.DBus.Error.Spawn.ForkFailed" +/** While starting a new process, the child exited with a status code. */ +#define DBUS_ERROR_SPAWN_CHILD_EXITED "org.freedesktop.DBus.Error.Spawn.ChildExited" +/** While starting a new process, the child exited on a signal. */ +#define DBUS_ERROR_SPAWN_CHILD_SIGNALED "org.freedesktop.DBus.Error.Spawn.ChildSignaled" +/** While starting a new process, something went wrong. */ +#define DBUS_ERROR_SPAWN_FAILED "org.freedesktop.DBus.Error.Spawn.Failed" +/** We failed to setup the environment correctly. */ +#define DBUS_ERROR_SPAWN_SETUP_FAILED "org.freedesktop.DBus.Error.Spawn.FailedToSetup" +/** We failed to setup the config parser correctly. */ +#define DBUS_ERROR_SPAWN_CONFIG_INVALID "org.freedesktop.DBus.Error.Spawn.ConfigInvalid" +/** Bus name was not valid. */ +#define DBUS_ERROR_SPAWN_SERVICE_INVALID "org.freedesktop.DBus.Error.Spawn.ServiceNotValid" +/** Service file not found in system-services directory. */ +#define DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND "org.freedesktop.DBus.Error.Spawn.ServiceNotFound" +/** Permissions are incorrect on the setuid helper. */ +#define DBUS_ERROR_SPAWN_PERMISSIONS_INVALID "org.freedesktop.DBus.Error.Spawn.PermissionsInvalid" +/** Service file invalid (Name, User or Exec missing). */ +#define DBUS_ERROR_SPAWN_FILE_INVALID "org.freedesktop.DBus.Error.Spawn.FileInvalid" +/** There was not enough memory to complete the operation. */ +#define DBUS_ERROR_SPAWN_NO_MEMORY "org.freedesktop.DBus.Error.Spawn.NoMemory" +/** Tried to get a UNIX process ID and it wasn't available. */ +#define DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN "org.freedesktop.DBus.Error.UnixProcessIdUnknown" +/** A type signature is not valid. */ +#define DBUS_ERROR_INVALID_SIGNATURE "org.freedesktop.DBus.Error.InvalidSignature" +/** A file contains invalid syntax or is otherwise broken. */ +#define DBUS_ERROR_INVALID_FILE_CONTENT "org.freedesktop.DBus.Error.InvalidFileContent" +/** Asked for SELinux security context and it wasn't available. */ +#define DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown" +/** Asked for ADT audit data and it wasn't available. */ +#define DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN "org.freedesktop.DBus.Error.AdtAuditDataUnknown" +/** There's already an object with the requested object path. */ +#define DBUS_ERROR_OBJECT_PATH_IN_USE "org.freedesktop.DBus.Error.ObjectPathInUse" +/** The message meta data does not match the payload. e.g. expected + number of file descriptors were not sent over the socket this message was received on. */ +#define DBUS_ERROR_INCONSISTENT_MESSAGE "org.freedesktop.DBus.Error.InconsistentMessage" +/** The message is not allowed without performing interactive authorization, + * but could have succeeded if an interactive authorization step was + * allowed. */ +#define DBUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED "org.freedesktop.DBus.Error.InteractiveAuthorizationRequired" +/** The connection is not from a container, or the specified container instance + * does not exist. */ +#define DBUS_ERROR_NOT_CONTAINER "org.freedesktop.DBus.Error.NotContainer" + +/* XML introspection format */ + +/** XML namespace of the introspection format version 1.0 */ +#define DBUS_INTROSPECT_1_0_XML_NAMESPACE "http://www.freedesktop.org/standards/dbus" +/** XML public identifier of the introspection format version 1.0 */ +#define DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +/** XML system identifier of the introspection format version 1.0 */ +#define DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" +/** XML document type declaration of the introspection format version 1.0 */ +#define DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE "\n" + +/** @} */ + +#ifdef __cplusplus +#if 0 +{ /* avoids confusing emacs indentation */ +#endif +} +#endif + +#endif /* DBUS_PROTOCOL_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-server.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-server.h new file mode 100644 index 00000000..eb7d7862 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-server.h @@ -0,0 +1,124 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-server.h DBusServer object + * + * Copyright (C) 2002, 2003 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_SERVER_H +#define DBUS_SERVER_H + +#include +#include +#include +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusServer + * @{ + */ + +typedef struct DBusServer DBusServer; + +/** Called when a new connection to the server is available. Must reference and save the new + * connection, or close the new connection. Set with dbus_server_set_new_connection_function(). + */ +typedef void (* DBusNewConnectionFunction) (DBusServer *server, + DBusConnection *new_connection, + void *data); + +DBUS_EXPORT +DBusServer* dbus_server_listen (const char *address, + DBusError *error); +DBUS_EXPORT +DBusServer* dbus_server_ref (DBusServer *server); +DBUS_EXPORT +void dbus_server_unref (DBusServer *server); +DBUS_EXPORT +void dbus_server_disconnect (DBusServer *server); +DBUS_EXPORT +dbus_bool_t dbus_server_get_is_connected (DBusServer *server); +DBUS_EXPORT +char* dbus_server_get_address (DBusServer *server); +DBUS_EXPORT +char* dbus_server_get_id (DBusServer *server); +DBUS_EXPORT +void dbus_server_set_new_connection_function (DBusServer *server, + DBusNewConnectionFunction function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +dbus_bool_t dbus_server_set_watch_functions (DBusServer *server, + DBusAddWatchFunction add_function, + DBusRemoveWatchFunction remove_function, + DBusWatchToggledFunction toggled_function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +dbus_bool_t dbus_server_set_timeout_functions (DBusServer *server, + DBusAddTimeoutFunction add_function, + DBusRemoveTimeoutFunction remove_function, + DBusTimeoutToggledFunction toggled_function, + void *data, + DBusFreeFunction free_data_function); +DBUS_EXPORT +dbus_bool_t dbus_server_set_auth_mechanisms (DBusServer *server, + const char **mechanisms); + +DBUS_EXPORT +dbus_bool_t dbus_server_allocate_data_slot (dbus_int32_t *slot_p); +DBUS_EXPORT +void dbus_server_free_data_slot (dbus_int32_t *slot_p); +DBUS_EXPORT +dbus_bool_t dbus_server_set_data (DBusServer *server, + int slot, + void *data, + DBusFreeFunction free_data_func); +DBUS_EXPORT +void* dbus_server_get_data (DBusServer *server, + int slot); + +/** + * Clear a variable or struct member that contains a #DBusServer. + * If it does not contain #NULL, the server that was previously + * there is unreferenced with dbus_server_unref(). + * + * This is very similar to dbus_clear_connection(): see that function + * for more details. + * + * @param pointer_to_server A pointer to a variable or struct member. + * pointer_to_server must not be #NULL, but *pointer_to_server + * may be #NULL. + */ +#define dbus_clear_server(pointer) \ + _dbus_clear_pointer_impl(DBusServer, (pointer), dbus_server_unref) + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_SERVER_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-shared.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-shared.h new file mode 100644 index 00000000..87c0bd84 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-shared.h @@ -0,0 +1,138 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-shared.h Stuff used by both dbus/dbus.h low-level and C/C++ binding APIs + * + * Copyright (C) 2004 Red Hat, Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef DBUS_SHARED_H +#define DBUS_SHARED_H + +/* Don't include anything in here from anywhere else. It's + * intended for use by any random library. + */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* avoids confusing emacs indentation */ +#endif +#endif + +/* Normally docs are in .c files, but there isn't a .c file for this. */ +/** + * @defgroup DBusShared Shared constants + * @ingroup DBus + * + * @brief Shared header included by both libdbus and C/C++ bindings such as the GLib bindings. + * + * Usually a C/C++ binding such as the GLib or Qt binding won't want to include dbus.h in its + * public headers. However, a few constants and macros may be useful to include; those are + * found here and in dbus-protocol.h + * + * @{ + */ + + +/** + * Well-known bus types. See dbus_bus_get(). + */ +typedef enum +{ + DBUS_BUS_SESSION, /**< The login session bus */ + DBUS_BUS_SYSTEM, /**< The systemwide bus */ + DBUS_BUS_STARTER /**< The bus that started us, if any */ +} DBusBusType; + +/** + * Results that a message handler can return. + */ +typedef enum +{ + DBUS_HANDLER_RESULT_HANDLED, /**< Message has had its effect - no need to run more handlers. */ + DBUS_HANDLER_RESULT_NOT_YET_HANDLED, /**< Message has not had any effect - see if other handlers want it. */ + DBUS_HANDLER_RESULT_NEED_MEMORY /**< Need more memory in order to return #DBUS_HANDLER_RESULT_HANDLED or #DBUS_HANDLER_RESULT_NOT_YET_HANDLED. Please try again later with more memory. */ +} DBusHandlerResult; + +/* Bus names */ + +/** The bus name used to talk to the bus itself. */ +#define DBUS_SERVICE_DBUS "org.freedesktop.DBus" + +/* Paths */ +/** The object path used to talk to the bus itself. */ +#define DBUS_PATH_DBUS "/org/freedesktop/DBus" +/** The object path used in local/in-process-generated messages. */ +#define DBUS_PATH_LOCAL "/org/freedesktop/DBus/Local" + +/* Interfaces, these #define don't do much other than + * catch typos at compile time + */ +/** The interface exported by the object with #DBUS_SERVICE_DBUS and #DBUS_PATH_DBUS */ +#define DBUS_INTERFACE_DBUS "org.freedesktop.DBus" +/** The monitoring interface exported by the dbus-daemon */ +#define DBUS_INTERFACE_MONITORING "org.freedesktop.DBus.Monitoring" + +/** The verbose interface exported by the dbus-daemon */ +#define DBUS_INTERFACE_VERBOSE "org.freedesktop.DBus.Verbose" +/** The interface supported by introspectable objects */ +#define DBUS_INTERFACE_INTROSPECTABLE "org.freedesktop.DBus.Introspectable" +/** The interface supported by objects with properties */ +#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties" +/** The interface supported by most dbus peers */ +#define DBUS_INTERFACE_PEER "org.freedesktop.DBus.Peer" + +/** This is a special interface whose methods can only be invoked + * by the local implementation (messages from remote apps aren't + * allowed to specify this interface). + */ +#define DBUS_INTERFACE_LOCAL "org.freedesktop.DBus.Local" + +/* Owner flags */ +#define DBUS_NAME_FLAG_ALLOW_REPLACEMENT 0x1 /**< Allow another service to become the primary owner if requested */ +#define DBUS_NAME_FLAG_REPLACE_EXISTING 0x2 /**< Request to replace the current primary owner */ +#define DBUS_NAME_FLAG_DO_NOT_QUEUE 0x4 /**< If we can not become the primary owner do not place us in the queue */ + +/* Replies to request for a name */ +#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1 /**< Service has become the primary owner of the requested name */ +#define DBUS_REQUEST_NAME_REPLY_IN_QUEUE 2 /**< Service could not become the primary owner and has been placed in the queue */ +#define DBUS_REQUEST_NAME_REPLY_EXISTS 3 /**< Service is already in the queue */ +#define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4 /**< Service is already the primary owner */ + +/* Replies to releasing a name */ +#define DBUS_RELEASE_NAME_REPLY_RELEASED 1 /**< Service was released from the given name */ +#define DBUS_RELEASE_NAME_REPLY_NON_EXISTENT 2 /**< The given name does not exist on the bus */ +#define DBUS_RELEASE_NAME_REPLY_NOT_OWNER 3 /**< Service is not an owner of the given name */ + +/* Replies to service starts */ +#define DBUS_START_REPLY_SUCCESS 1 /**< Service was auto started */ +#define DBUS_START_REPLY_ALREADY_RUNNING 2 /**< Service was already running */ + +/** @} */ + +#ifdef __cplusplus +#if 0 +{ /* avoids confusing emacs indentation */ +#endif +} +#endif + +#endif /* DBUS_SHARED_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-signature.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-signature.h new file mode 100644 index 00000000..a8a0486b --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-signature.h @@ -0,0 +1,97 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-signatures.h utility functions for D-Bus types + * + * Copyright (C) 2005 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_SIGNATURES_H +#define DBUS_SIGNATURES_H + +#include +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusSignature + * @{ + */ + +/** + * DBusSignatureIter struct; contains no public fields + */ +typedef struct +{ + void *dummy1; /**< Don't use this */ + void *dummy2; /**< Don't use this */ + dbus_uint32_t dummy8; /**< Don't use this */ + int dummy12; /**< Don't use this */ + int dummy17; /**< Don't use this */ +} DBusSignatureIter; + +DBUS_EXPORT +void dbus_signature_iter_init (DBusSignatureIter *iter, + const char *signature); + +DBUS_EXPORT +int dbus_signature_iter_get_current_type (const DBusSignatureIter *iter); + +DBUS_EXPORT +char * dbus_signature_iter_get_signature (const DBusSignatureIter *iter); + +DBUS_EXPORT +int dbus_signature_iter_get_element_type (const DBusSignatureIter *iter); + +DBUS_EXPORT +dbus_bool_t dbus_signature_iter_next (DBusSignatureIter *iter); + +DBUS_EXPORT +void dbus_signature_iter_recurse (const DBusSignatureIter *iter, + DBusSignatureIter *subiter); + +DBUS_EXPORT +dbus_bool_t dbus_signature_validate (const char *signature, + DBusError *error); + +DBUS_EXPORT +dbus_bool_t dbus_signature_validate_single (const char *signature, + DBusError *error); + +DBUS_EXPORT +dbus_bool_t dbus_type_is_valid (int typecode); + +DBUS_EXPORT +dbus_bool_t dbus_type_is_basic (int typecode); +DBUS_EXPORT +dbus_bool_t dbus_type_is_container (int typecode); +DBUS_EXPORT +dbus_bool_t dbus_type_is_fixed (int typecode); + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_SIGNATURE_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-syntax.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-syntax.h new file mode 100644 index 00000000..57459b17 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-syntax.h @@ -0,0 +1,60 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-syntax.h - utility functions for strings with special syntax + * + * Author: Simon McVittie + * Copyright © 2011 Nokia Corporation + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_SYNTAX_H +#define DBUS_SYNTAX_H + +#include +#include +#include + +DBUS_BEGIN_DECLS + +DBUS_EXPORT +dbus_bool_t dbus_validate_path (const char *path, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_interface (const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_member (const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_error_name (const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_bus_name (const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_utf8 (const char *alleged_utf8, + DBusError *error); + +DBUS_END_DECLS + +#endif /* multiple-inclusion guard */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-threads.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-threads.h new file mode 100644 index 00000000..33e1e327 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-threads.h @@ -0,0 +1,191 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-threads.h D-Bus threads handling + * + * Copyright (C) 2002 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_THREADS_H +#define DBUS_THREADS_H + +#include +#include + +DBUS_BEGIN_DECLS + +/** + * @addtogroup DBusThreads + * @{ + */ + +/** An opaque mutex type provided by the #DBusThreadFunctions implementation installed by dbus_threads_init(). */ +typedef struct DBusMutex DBusMutex; +/** An opaque condition variable type provided by the #DBusThreadFunctions implementation installed by dbus_threads_init(). */ +typedef struct DBusCondVar DBusCondVar; + +/** Deprecated, provide DBusRecursiveMutexNewFunction instead. */ +typedef DBusMutex* (* DBusMutexNewFunction) (void); +/** Deprecated, provide DBusRecursiveMutexFreeFunction instead. */ +typedef void (* DBusMutexFreeFunction) (DBusMutex *mutex); +/** Deprecated, provide DBusRecursiveMutexLockFunction instead. Return value is lock success, but gets ignored in practice. */ +typedef dbus_bool_t (* DBusMutexLockFunction) (DBusMutex *mutex); +/** Deprecated, provide DBusRecursiveMutexUnlockFunction instead. Return value is unlock success, but gets ignored in practice. */ +typedef dbus_bool_t (* DBusMutexUnlockFunction) (DBusMutex *mutex); + +/** Creates a new recursively-lockable mutex, or returns #NULL if not + * enough memory. Can only fail due to lack of memory. Found in + * #DBusThreadFunctions. Do not just use PTHREAD_MUTEX_RECURSIVE for + * this, because it does not save/restore the recursion count when + * waiting on a condition. libdbus requires the Java-style behavior + * where the mutex is fully unlocked to wait on a condition. + */ +typedef DBusMutex* (* DBusRecursiveMutexNewFunction) (void); +/** Frees a recursively-lockable mutex. Found in #DBusThreadFunctions. + */ +typedef void (* DBusRecursiveMutexFreeFunction) (DBusMutex *mutex); +/** Locks a recursively-lockable mutex. Found in #DBusThreadFunctions. + * Can only fail due to lack of memory. + */ +typedef void (* DBusRecursiveMutexLockFunction) (DBusMutex *mutex); +/** Unlocks a recursively-lockable mutex. Found in #DBusThreadFunctions. + * Can only fail due to lack of memory. + */ +typedef void (* DBusRecursiveMutexUnlockFunction) (DBusMutex *mutex); + +/** Creates a new condition variable. Found in #DBusThreadFunctions. + * Can only fail (returning #NULL) due to lack of memory. + */ +typedef DBusCondVar* (* DBusCondVarNewFunction) (void); +/** Frees a condition variable. Found in #DBusThreadFunctions. + */ +typedef void (* DBusCondVarFreeFunction) (DBusCondVar *cond); + +/** Waits on a condition variable. Found in + * #DBusThreadFunctions. Must work with either a recursive or + * nonrecursive mutex, whichever the thread implementation + * provides. Note that PTHREAD_MUTEX_RECURSIVE does not work with + * condition variables (does not save/restore the recursion count) so + * don't try using simply pthread_cond_wait() and a + * PTHREAD_MUTEX_RECURSIVE to implement this, it won't work right. + * + * Has no error conditions. Must succeed if it returns. + */ +typedef void (* DBusCondVarWaitFunction) (DBusCondVar *cond, + DBusMutex *mutex); + +/** Waits on a condition variable with a timeout. Found in + * #DBusThreadFunctions. Returns #TRUE if the wait did not + * time out, and #FALSE if it did. + * + * Has no error conditions. Must succeed if it returns. + */ +typedef dbus_bool_t (* DBusCondVarWaitTimeoutFunction) (DBusCondVar *cond, + DBusMutex *mutex, + int timeout_milliseconds); +/** Wakes one waiting thread on a condition variable. Found in #DBusThreadFunctions. + * + * Has no error conditions. Must succeed if it returns. + */ +typedef void (* DBusCondVarWakeOneFunction) (DBusCondVar *cond); + +/** Wakes all waiting threads on a condition variable. Found in #DBusThreadFunctions. + * + * Has no error conditions. Must succeed if it returns. + */ +typedef void (* DBusCondVarWakeAllFunction) (DBusCondVar *cond); + +/** + * Flags indicating which functions are present in #DBusThreadFunctions. Used to allow + * the library to detect older callers of dbus_threads_init() if new possible functions + * are added to #DBusThreadFunctions. + */ +typedef enum +{ + DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK = 1 << 0, + DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK = 1 << 1, + DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK = 1 << 2, + DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK = 1 << 3, + DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK = 1 << 4, + DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK = 1 << 5, + DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK = 1 << 6, + DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK = 1 << 7, + DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK = 1 << 8, + DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK = 1 << 9, + DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK = 1 << 10, + DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK = 1 << 11, + DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK = 1 << 12, + DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK = 1 << 13, + DBUS_THREAD_FUNCTIONS_ALL_MASK = (1 << 14) - 1 +} DBusThreadFunctionsMask; + +/** + * Functions that must be implemented to make the D-Bus library + * thread-aware. + * + * If you supply both recursive and non-recursive mutexes, + * libdbus will use the non-recursive version for condition variables, + * and the recursive version in other contexts. + * + * The condition variable functions have to work with nonrecursive + * mutexes if you provide those, or with recursive mutexes if you + * don't. + */ +typedef struct +{ + unsigned int mask; /**< Mask indicating which functions are present. */ + + DBusMutexNewFunction mutex_new; /**< Function to create a mutex; optional and deprecated. */ + DBusMutexFreeFunction mutex_free; /**< Function to free a mutex; optional and deprecated. */ + DBusMutexLockFunction mutex_lock; /**< Function to lock a mutex; optional and deprecated. */ + DBusMutexUnlockFunction mutex_unlock; /**< Function to unlock a mutex; optional and deprecated. */ + + DBusCondVarNewFunction condvar_new; /**< Function to create a condition variable */ + DBusCondVarFreeFunction condvar_free; /**< Function to free a condition variable */ + DBusCondVarWaitFunction condvar_wait; /**< Function to wait on a condition */ + DBusCondVarWaitTimeoutFunction condvar_wait_timeout; /**< Function to wait on a condition with a timeout */ + DBusCondVarWakeOneFunction condvar_wake_one; /**< Function to wake one thread waiting on the condition */ + DBusCondVarWakeAllFunction condvar_wake_all; /**< Function to wake all threads waiting on the condition */ + + DBusRecursiveMutexNewFunction recursive_mutex_new; /**< Function to create a recursive mutex */ + DBusRecursiveMutexFreeFunction recursive_mutex_free; /**< Function to free a recursive mutex */ + DBusRecursiveMutexLockFunction recursive_mutex_lock; /**< Function to lock a recursive mutex */ + DBusRecursiveMutexUnlockFunction recursive_mutex_unlock; /**< Function to unlock a recursive mutex */ + + void (* padding1) (void); /**< Reserved for future expansion */ + void (* padding2) (void); /**< Reserved for future expansion */ + void (* padding3) (void); /**< Reserved for future expansion */ + void (* padding4) (void); /**< Reserved for future expansion */ + +} DBusThreadFunctions; + +DBUS_EXPORT +dbus_bool_t dbus_threads_init (const DBusThreadFunctions *functions); +DBUS_EXPORT +dbus_bool_t dbus_threads_init_default (void); + +/** @} */ + +DBUS_END_DECLS + +#endif /* DBUS_THREADS_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-types.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-types.h new file mode 100644 index 00000000..5ace2733 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus-types.h @@ -0,0 +1,179 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-types.h types such as dbus_bool_t + * + * Copyright (C) 2002 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_TYPES_H +#define DBUS_TYPES_H + +#include +#include + +typedef dbus_uint32_t dbus_unichar_t; +/* boolean size must be fixed at 4 bytes due to wire protocol! */ +typedef dbus_uint32_t dbus_bool_t; + +/* Normally docs are in .c files, but there isn't a .c file for this. */ +/** + * @defgroup DBusTypes Basic types + * @ingroup DBus + * @brief dbus_bool_t, dbus_int32_t, etc. + * + * Typedefs for common primitive types. + * + * @{ + */ + +/** + * @typedef dbus_bool_t + * + * A boolean, valid values are #TRUE and #FALSE. + */ + +/** + * @typedef dbus_uint32_t + * + * A 32-bit unsigned integer on all platforms. + */ + +/** + * @typedef dbus_int32_t + * + * A 32-bit signed integer on all platforms. + */ + +/** + * @typedef dbus_uint16_t + * + * A 16-bit unsigned integer on all platforms. + */ + +/** + * @typedef dbus_int16_t + * + * A 16-bit signed integer on all platforms. + */ + + +/** + * @typedef dbus_uint64_t + * + * A 64-bit unsigned integer. + */ + +/** + * @typedef dbus_int64_t + * + * A 64-bit signed integer. + */ + +/** + * @def DBUS_HAVE_INT64 + * + * Always defined. + * + * In older libdbus versions, this would be undefined if there was no + * 64-bit integer type on that platform. libdbus no longer supports + * such platforms. + */ + +/** + * @def DBUS_INT64_CONSTANT + * + * Declare a 64-bit signed integer constant. The macro + * adds the necessary "LL" or whatever after the integer, + * giving a literal such as "325145246765LL" + */ + +/** + * @def DBUS_UINT64_CONSTANT + * + * Declare a 64-bit unsigned integer constant. The macro + * adds the necessary "ULL" or whatever after the integer, + * giving a literal such as "325145246765ULL" + */ + +/** + * @def DBUS_INT64_MODIFIER + * + * A string literal for a length modifier that is appropriate to print + * the #dbus_int64_t and #dbus_uint64_t types. + * For example, it might be an empty string, "l", "ll", or "I64". + * + * This modifier needs to be concatenated with a literal "%" and a + * conversion specifier that can print signed or unsigned integers, + * for example: + * + * @code + * dbus_int64_t i = -123; + * dbus_uint64_t u = 456; + * + * printf ("signed: %" DBUS_INT64_MODIFIER "d\n", i); + * printf ("unsigned decimal: %" DBUS_INT64_MODIFIER "u\n", u); + * printf ("unsigned hex: 0x%" DBUS_INT64_MODIFIER "x\n", x); + * @endcode + */ + +/** + * An 8-byte struct you could use to access int64 without having + * int64 support. Use #dbus_int64_t or #dbus_uint64_t instead. + */ +typedef struct +{ + dbus_uint32_t first32; /**< first 32 bits in the 8 bytes (beware endian issues) */ + dbus_uint32_t second32; /**< second 32 bits in the 8 bytes (beware endian issues) */ +} DBus8ByteStruct; + +/** + * A simple value union that lets you access bytes as if they + * were various types; useful when dealing with basic types via + * void pointers and varargs. + * + * This union also contains a pointer member (which can be used + * to retrieve a string from dbus_message_iter_get_basic(), for + * instance), so on future platforms it could conceivably be larger + * than 8 bytes. + */ +typedef union +{ + unsigned char bytes[8]; /**< as 8 individual bytes */ + dbus_int16_t i16; /**< as int16 */ + dbus_uint16_t u16; /**< as int16 */ + dbus_int32_t i32; /**< as int32 */ + dbus_uint32_t u32; /**< as int32 */ + dbus_bool_t bool_val; /**< as boolean */ + dbus_int64_t i64; /**< as int64 */ + dbus_uint64_t u64; /**< as int64 */ + DBus8ByteStruct eight; /**< as 8-byte struct */ + double dbl; /**< as double */ + unsigned char byt; /**< as byte */ + char *str; /**< as char* (string, object path or signature) */ + int fd; /**< as Unix file descriptor */ +} DBusBasicValue; + +/** @} */ + +#endif /* DBUS_TYPES_H */ diff --git a/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus.h b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus.h new file mode 100644 index 00000000..53998c54 --- /dev/null +++ b/illumos-x86_64/usr/include/dbus-1.0/dbus/dbus.h @@ -0,0 +1,106 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus.h Convenience header including all other headers + * + * Copyright (C) 2002, 2003 Red Hat Inc. + * + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef DBUS_H +#define DBUS_H + +#define DBUS_INSIDE_DBUS_H 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#undef DBUS_INSIDE_DBUS_H + +/** + * @defgroup DBus D-Bus low-level public API + * @brief The low-level public API of the D-Bus library + * + * libdbus provides a low-level C API intended primarily for use by + * bindings to specific object systems and languages. D-Bus is most + * convenient when used with the GLib bindings, Python bindings, Qt + * bindings, Mono bindings, and so forth. This low-level API has a + * lot of complexity useful only for bindings. + * + * @{ + */ + +/** @} */ + +/** + * @mainpage + * + * This manual documents the low-level D-Bus C API. If you use + * this low-level API directly, you're signing up for some pain. + * + * Caveats aside, you might get started learning the low-level API by reading + * about @ref DBusConnection and @ref DBusMessage. + * + * There are several other places to look for D-Bus information, such + * as the tutorial and the specification; those can be found at the D-Bus + * website. If you're interested in a sysadmin or package + * maintainer's perspective on the dbus-daemon itself and its + * configuration, be sure to check out the man pages as well. + * + * The low-level API documented in this manual deliberately lacks + * most convenience functions - those are left up to higher-level libraries + * based on frameworks such as GLib, Qt, Python, Mono, Java, + * etc. These higher-level libraries (often called "D-Bus bindings") + * have features such as object systems and main loops that allow a + * much more convenient API. + * + * The low-level API also contains plenty of clutter to support + * integration with arbitrary object systems, languages, main loops, + * and so forth. These features add a lot of noise to the API that you + * probably don't care about unless you're coding a binding. + * + * This manual also contains docs for @ref DBusInternals "D-Bus internals", + * so you can use it to get oriented to the D-Bus source code if you're + * interested in patching the code. You should also read the + * file CONTRIBUTING.md which comes with the source code if you plan to + * contribute to D-Bus. + * + * As you read the code, you can identify internal D-Bus functions + * because they start with an underscore ('_') character. Also, any + * identifier or macro that lacks a DBus, dbus_, or DBUS_ namepace + * prefix is internal, with a couple of exceptions such as #NULL, + * #TRUE, and #FALSE. + */ + +#endif /* DBUS_H */ diff --git a/illumos-x86_64/usr/include/deflt.h b/illumos-x86_64/usr/include/deflt.h new file mode 100644 index 00000000..735da17b --- /dev/null +++ b/illumos-x86_64/usr/include/deflt.h @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* Copyright (c) 1987, 1988 Microsoft Corporation */ +/* All Rights Reserved */ + +#ifndef _DEFLT_H +#define _DEFLT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define DEFLT "/etc/default" + +/* + * Following for defcntl(3). + * If you add new args, make sure that the default is: + * OFF new-improved-feature-off, i.e. current state of affairs + * ON new-improved-feature-on + * or that you change the code for deflt(3) to have the old value as the + * default. (for compatibility). + */ + +/* ... cmds */ +#define DC_GETFLAGS 0 /* get current flags */ +#define DC_SETFLAGS 1 /* set flags */ + +/* ... args */ +#define DC_CASE 0001 /* ON: respect case; OFF: ignore case */ +#define DC_NOREWIND 0002 /* ON: don't rewind in defread */ + /* OFF: do rewind in defread */ +#define DC_STRIP_QUOTES 0004 /* ON: strip quotes; OFF: leave quotes */ + +#define DC_STD ((0) | (DC_CASE)) + +extern int defcntl(int, int); +extern int defopen(char *); +extern char *defread(char *); + +extern int defcntl_r(int, int, void *); +extern void *defopen_r(const char *); +extern char *defread_r(const char *, void *); +extern void defclose_r(void *); + +#define TURNON(flags, mask) ((flags) |= (mask)) +#define TURNOFF(flags, mask) ((flags) &= ~(mask)) +#define ISON(flags, mask) (((flags) & (mask)) == (mask)) +#define ISOFF(flags, mask) (((flags) & (mask)) != (mask)) + +#ifdef __cplusplus +} +#endif + +#endif /* _DEFLT_H */ diff --git a/illumos-x86_64/usr/include/demangle-sys.h b/illumos-x86_64/usr/include/demangle-sys.h new file mode 100644 index 00000000..21b2624c --- /dev/null +++ b/illumos-x86_64/usr/include/demangle-sys.h @@ -0,0 +1,44 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 Jason King + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _DEMANGLE_SYS_H +#define _DEMANGLE_SYS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum sysdem_lang_e { + SYSDEM_LANG_AUTO, + SYSDEM_LANG_CPP, + SYSDEM_LANG_RUST, +} sysdem_lang_t; + +typedef struct sysdem_alloc_s { + void *(*alloc)(size_t); + void (*free)(void *, size_t); +} sysdem_ops_t; + +boolean_t sysdem_parse_lang(const char *, sysdem_lang_t *); +char *sysdemangle(const char *, sysdem_lang_t, sysdem_ops_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _DEMANGLE_SYS_H */ diff --git a/illumos-x86_64/usr/include/des/des.h b/illumos-x86_64/usr/include/des/des.h new file mode 100644 index 00000000..002b9ab2 --- /dev/null +++ b/illumos-x86_64/usr/include/des/des.h @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_DES_H +#define _SYS_DES_H + +/* + * Generic DES driver interface + * Keep this file hardware independent! + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ +#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ + +enum desdir { ENCRYPT, DECRYPT }; +enum desmode { CBC, ECB }; + +/* + * parameters to ioctl call + */ +struct desparams { + uchar_t des_key[8]; /* key (with low bit parity) */ + enum desdir des_dir; /* direction */ + enum desmode des_mode; /* mode */ + uchar_t des_ivec[8]; /* input vector */ + unsigned int des_len; /* number of bytes to crypt */ + union { + uchar_t UDES_data[DES_QUICKLEN]; + uchar_t *UDES_buf; + } UDES; +#define des_data UDES.UDES_data /* direct data here if quick */ +#define des_buf UDES.UDES_buf /* otherwise, pointer to data */ +}; + +/* + * Encrypt an arbitrary sized buffer + */ +#define DESIOCBLOCK _IOWR('d', 6, struct desparams) + +/* + * Encrypt of small amount of data, quickly + */ +#define DESIOCQUICK _IOWR('d', 7, struct desparams) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DES_H */ diff --git a/illumos-x86_64/usr/include/des/desdata.h b/illumos-x86_64/usr/include/des/desdata.h new file mode 100644 index 00000000..d128481e --- /dev/null +++ b/illumos-x86_64/usr/include/des/desdata.h @@ -0,0 +1,1086 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_DESDATA_H +#define _SYS_DESDATA_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * softdesdata.c, Data for software implementation of DES + */ + +/* + * Lint can't handle static's in include files. + * Complains "defined but not used" and then "used but not defined" + */ +#ifdef __lint +#define static +#endif + +/* + * Permuted-choice 1 from the key bits + * to yield C and D. + * Note that bits 8,16... are left out: + * They are intended for a parity check. + * Table has been munged to be zero-origin + */ + +const short PC1_C[] = { + 57-1, 49-1, 41-1, 33-1, 25-1, 17-1, 9-1, + 1-1, 58-1, 50-1, 42-1, 34-1, 26-1, 18-1, + 10-1, 2-1, 59-1, 51-1, 43-1, 35-1, 27-1, + 19-1, 11-1, 3-1, 60-1, 52-1, 44-1, 36-1, +}; + +const short PC1_D[] = { + 63-1, 55-1, 47-1, 39-1, 31-1, 23-1, 15-1, + 7-1, 62-1, 54-1, 46-1, 38-1, 30-1, 22-1, + 14-1, 6-1, 61-1, 53-1, 45-1, 37-1, 29-1, + 21-1, 13-1, 5-1, 28-1, 20-1, 12-1, 4-1, +}; + +/* + * Sequence of shifts used for the key schedule. + */ +const char shifts[] = { + 1-1, 1-1, 2-1, 2-1, 2-1, 2-1, 2-1, 2-1, + 1-1, 2-1, 2-1, 2-1, 2-1, 2-1, 2-1, 1-1, +}; + +/* + * Permuted-choice 2, to pick out the bits from + * the CD array that generate the key schedule. + */ +const char PC2_C[] = { + 14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, +}; + +const char PC2_D[] = { + 41-28, 52-28, 31-28, 37-28, 47-28, 55-28, + 30-28, 40-28, 51-28, 45-28, 33-28, 48-28, + 44-28, 49-28, 39-28, 56-28, 34-28, 53-28, + 46-28, 42-28, 50-28, 36-28, 29-28, 32-28, +}; + +/* + * Initial permutation + */ +const short IPtab[64] = { + 40-1, 8-1, 48-1, 16-1, 56-1, 24-1, 64-1, 32-1, + 39-1, 7-1, 47-1, 15-1, 55-1, 23-1, 63-1, 31-1, + 38-1, 6-1, 46-1, 14-1, 54-1, 22-1, 62-1, 30-1, + 37-1, 5-1, 45-1, 13-1, 53-1, 21-1, 61-1, 29-1, + 36-1, 4-1, 44-1, 12-1, 52-1, 20-1, 60-1, 28-1, + 35-1, 3-1, 43-1, 11-1, 51-1, 19-1, 59-1, 27-1, + 34-1, 2-1, 42-1, 10-1, 50-1, 18-1, 58-1, 26-1, + 33-1, 1-1, 41-1, 9-1, 49-1, 17-1, 57-1, 25-1, +}; + +/* + * Final permutation + */ +const short FPtab[64] = { + 58-1, 50-1, 42-1, 34-1, 26-1, 18-1, 10-1, 2-1, + 60-1, 52-1, 44-1, 36-1, 28-1, 20-1, 12-1, 4-1, + 62-1, 54-1, 46-1, 38-1, 30-1, 22-1, 14-1, 6-1, + 64-1, 56-1, 48-1, 40-1, 32-1, 24-1, 16-1, 8-1, + 57-1, 49-1, 41-1, 33-1, 25-1, 17-1, 9-1, 1-1, + 59-1, 51-1, 43-1, 35-1, 27-1, 19-1, 11-1, 3-1, + 61-1, 53-1, 45-1, 37-1, 29-1, 21-1, 13-1, 5-1, + 63-1, 55-1, 47-1, 39-1, 31-1, 23-1, 15-1, 7-1, +}; + +/* + * Mask bit selection table + */ +const uint32_t longtab[32] = { + 0x80000000U, 0x40000000U, 0x20000000U, 0x10000000U, + 0x8000000U, 0x4000000U, 0x2000000U, 0x1000000U, + 0x800000U, 0x400000U, 0x200000U, 0x100000U, + 0x80000U, 0x40000U, 0x20000U, 0x10000U, + 0x8000U, 0x4000U, 0x2000U, 0x1000U, + 0x800U, 0x400U, 0x200U, 0x100U, + 0x80U, 0x40U, 0x20U, 0x10U, + 0x8U, 0x4U, 0x2U, 0x1U, +}; + +/* + * Table to expand 32 bit (4 bytes of 8 bits) R value + * to 48 bits (8 bytes of 6 bits) + */ +struct R_to_ER { + uint32_t l0, l1; +}; + +const struct R_to_ER R_to_ER_tab[4][256] = { + {{ 0x00000000, 0x00000000, }, { 0x00022000, 0x00000000, }, + { 0x00040000, 0x00000000, }, { 0x00062000, 0x00000000, }, + { 0x00080000, 0x00000000, }, { 0x000a2000, 0x00000000, }, + { 0x000c0000, 0x00000000, }, { 0x000e2000, 0x00000000, }, + { 0x01100000, 0x00000000, }, { 0x01122000, 0x00000000, }, + { 0x01140000, 0x00000000, }, { 0x01162000, 0x00000000, }, + { 0x01180000, 0x00000000, }, { 0x011a2000, 0x00000000, }, + { 0x011c0000, 0x00000000, }, { 0x011e2000, 0x00000000, }, + { 0x02200000, 0x00000000, }, { 0x02222000, 0x00000000, }, + { 0x02240000, 0x00000000, }, { 0x02262000, 0x00000000, }, + { 0x02280000, 0x00000000, }, { 0x022a2000, 0x00000000, }, + { 0x022c0000, 0x00000000, }, { 0x022e2000, 0x00000000, }, + { 0x03300000, 0x00000000, }, { 0x03322000, 0x00000000, }, + { 0x03340000, 0x00000000, }, { 0x03362000, 0x00000000, }, + { 0x03380000, 0x00000000, }, { 0x033a2000, 0x00000000, }, + { 0x033c0000, 0x00000000, }, { 0x033e2000, 0x00000000, }, + { 0x04000000, 0x00000000, }, { 0x04022000, 0x00000000, }, + { 0x04040000, 0x00000000, }, { 0x04062000, 0x00000000, }, + { 0x04080000, 0x00000000, }, { 0x040a2000, 0x00000000, }, + { 0x040c0000, 0x00000000, }, { 0x040e2000, 0x00000000, }, + { 0x05100000, 0x00000000, }, { 0x05122000, 0x00000000, }, + { 0x05140000, 0x00000000, }, { 0x05162000, 0x00000000, }, + { 0x05180000, 0x00000000, }, { 0x051a2000, 0x00000000, }, + { 0x051c0000, 0x00000000, }, { 0x051e2000, 0x00000000, }, + { 0x06200000, 0x00000000, }, { 0x06222000, 0x00000000, }, + { 0x06240000, 0x00000000, }, { 0x06262000, 0x00000000, }, + { 0x06280000, 0x00000000, }, { 0x062a2000, 0x00000000, }, + { 0x062c0000, 0x00000000, }, { 0x062e2000, 0x00000000, }, + { 0x07300000, 0x00000000, }, { 0x07322000, 0x00000000, }, + { 0x07340000, 0x00000000, }, { 0x07362000, 0x00000000, }, + { 0x07380000, 0x00000000, }, { 0x073a2000, 0x00000000, }, + { 0x073c0000, 0x00000000, }, { 0x073e2000, 0x00000000, }, + { 0x08000000, 0x00000000, }, { 0x08022000, 0x00000000, }, + { 0x08040000, 0x00000000, }, { 0x08062000, 0x00000000, }, + { 0x08080000, 0x00000000, }, { 0x080a2000, 0x00000000, }, + { 0x080c0000, 0x00000000, }, { 0x080e2000, 0x00000000, }, + { 0x09100000, 0x00000000, }, { 0x09122000, 0x00000000, }, + { 0x09140000, 0x00000000, }, { 0x09162000, 0x00000000, }, + { 0x09180000, 0x00000000, }, { 0x091a2000, 0x00000000, }, + { 0x091c0000, 0x00000000, }, { 0x091e2000, 0x00000000, }, + { 0x0a200000, 0x00000000, }, { 0x0a222000, 0x00000000, }, + { 0x0a240000, 0x00000000, }, { 0x0a262000, 0x00000000, }, + { 0x0a280000, 0x00000000, }, { 0x0a2a2000, 0x00000000, }, + { 0x0a2c0000, 0x00000000, }, { 0x0a2e2000, 0x00000000, }, + { 0x0b300000, 0x00000000, }, { 0x0b322000, 0x00000000, }, + { 0x0b340000, 0x00000000, }, { 0x0b362000, 0x00000000, }, + { 0x0b380000, 0x00000000, }, { 0x0b3a2000, 0x00000000, }, + { 0x0b3c0000, 0x00000000, }, { 0x0b3e2000, 0x00000000, }, + { 0x0c000000, 0x00000000, }, { 0x0c022000, 0x00000000, }, + { 0x0c040000, 0x00000000, }, { 0x0c062000, 0x00000000, }, + { 0x0c080000, 0x00000000, }, { 0x0c0a2000, 0x00000000, }, + { 0x0c0c0000, 0x00000000, }, { 0x0c0e2000, 0x00000000, }, + { 0x0d100000, 0x00000000, }, { 0x0d122000, 0x00000000, }, + { 0x0d140000, 0x00000000, }, { 0x0d162000, 0x00000000, }, + { 0x0d180000, 0x00000000, }, { 0x0d1a2000, 0x00000000, }, + { 0x0d1c0000, 0x00000000, }, { 0x0d1e2000, 0x00000000, }, + { 0x0e200000, 0x00000000, }, { 0x0e222000, 0x00000000, }, + { 0x0e240000, 0x00000000, }, { 0x0e262000, 0x00000000, }, + { 0x0e280000, 0x00000000, }, { 0x0e2a2000, 0x00000000, }, + { 0x0e2c0000, 0x00000000, }, { 0x0e2e2000, 0x00000000, }, + { 0x0f300000, 0x00000000, }, { 0x0f322000, 0x00000000, }, + { 0x0f340000, 0x00000000, }, { 0x0f362000, 0x00000000, }, + { 0x0f380000, 0x00000000, }, { 0x0f3a2000, 0x00000000, }, + { 0x0f3c0000, 0x00000000, }, { 0x0f3e2000, 0x00000000, }, + { 0x10000000, 0x00000001, }, { 0x10022000, 0x00000001, }, + { 0x10040000, 0x00000001, }, { 0x10062000, 0x00000001, }, + { 0x10080000, 0x00000001, }, { 0x100a2000, 0x00000001, }, + { 0x100c0000, 0x00000001, }, { 0x100e2000, 0x00000001, }, + { 0x11100000, 0x00000001, }, { 0x11122000, 0x00000001, }, + { 0x11140000, 0x00000001, }, { 0x11162000, 0x00000001, }, + { 0x11180000, 0x00000001, }, { 0x111a2000, 0x00000001, }, + { 0x111c0000, 0x00000001, }, { 0x111e2000, 0x00000001, }, + { 0x12200000, 0x00000001, }, { 0x12222000, 0x00000001, }, + { 0x12240000, 0x00000001, }, { 0x12262000, 0x00000001, }, + { 0x12280000, 0x00000001, }, { 0x122a2000, 0x00000001, }, + { 0x122c0000, 0x00000001, }, { 0x122e2000, 0x00000001, }, + { 0x13300000, 0x00000001, }, { 0x13322000, 0x00000001, }, + { 0x13340000, 0x00000001, }, { 0x13362000, 0x00000001, }, + { 0x13380000, 0x00000001, }, { 0x133a2000, 0x00000001, }, + { 0x133c0000, 0x00000001, }, { 0x133e2000, 0x00000001, }, + { 0x14000000, 0x00000001, }, { 0x14022000, 0x00000001, }, + { 0x14040000, 0x00000001, }, { 0x14062000, 0x00000001, }, + { 0x14080000, 0x00000001, }, { 0x140a2000, 0x00000001, }, + { 0x140c0000, 0x00000001, }, { 0x140e2000, 0x00000001, }, + { 0x15100000, 0x00000001, }, { 0x15122000, 0x00000001, }, + { 0x15140000, 0x00000001, }, { 0x15162000, 0x00000001, }, + { 0x15180000, 0x00000001, }, { 0x151a2000, 0x00000001, }, + { 0x151c0000, 0x00000001, }, { 0x151e2000, 0x00000001, }, + { 0x16200000, 0x00000001, }, { 0x16222000, 0x00000001, }, + { 0x16240000, 0x00000001, }, { 0x16262000, 0x00000001, }, + { 0x16280000, 0x00000001, }, { 0x162a2000, 0x00000001, }, + { 0x162c0000, 0x00000001, }, { 0x162e2000, 0x00000001, }, + { 0x17300000, 0x00000001, }, { 0x17322000, 0x00000001, }, + { 0x17340000, 0x00000001, }, { 0x17362000, 0x00000001, }, + { 0x17380000, 0x00000001, }, { 0x173a2000, 0x00000001, }, + { 0x173c0000, 0x00000001, }, { 0x173e2000, 0x00000001, }, + { 0x18000000, 0x00000001, }, { 0x18022000, 0x00000001, }, + { 0x18040000, 0x00000001, }, { 0x18062000, 0x00000001, }, + { 0x18080000, 0x00000001, }, { 0x180a2000, 0x00000001, }, + { 0x180c0000, 0x00000001, }, { 0x180e2000, 0x00000001, }, + { 0x19100000, 0x00000001, }, { 0x19122000, 0x00000001, }, + { 0x19140000, 0x00000001, }, { 0x19162000, 0x00000001, }, + { 0x19180000, 0x00000001, }, { 0x191a2000, 0x00000001, }, + { 0x191c0000, 0x00000001, }, { 0x191e2000, 0x00000001, }, + { 0x1a200000, 0x00000001, }, { 0x1a222000, 0x00000001, }, + { 0x1a240000, 0x00000001, }, { 0x1a262000, 0x00000001, }, + { 0x1a280000, 0x00000001, }, { 0x1a2a2000, 0x00000001, }, + { 0x1a2c0000, 0x00000001, }, { 0x1a2e2000, 0x00000001, }, + { 0x1b300000, 0x00000001, }, { 0x1b322000, 0x00000001, }, + { 0x1b340000, 0x00000001, }, { 0x1b362000, 0x00000001, }, + { 0x1b380000, 0x00000001, }, { 0x1b3a2000, 0x00000001, }, + { 0x1b3c0000, 0x00000001, }, { 0x1b3e2000, 0x00000001, }, + { 0x1c000000, 0x00000001, }, { 0x1c022000, 0x00000001, }, + { 0x1c040000, 0x00000001, }, { 0x1c062000, 0x00000001, }, + { 0x1c080000, 0x00000001, }, { 0x1c0a2000, 0x00000001, }, + { 0x1c0c0000, 0x00000001, }, { 0x1c0e2000, 0x00000001, }, + { 0x1d100000, 0x00000001, }, { 0x1d122000, 0x00000001, }, + { 0x1d140000, 0x00000001, }, { 0x1d162000, 0x00000001, }, + { 0x1d180000, 0x00000001, }, { 0x1d1a2000, 0x00000001, }, + { 0x1d1c0000, 0x00000001, }, { 0x1d1e2000, 0x00000001, }, + { 0x1e200000, 0x00000001, }, { 0x1e222000, 0x00000001, }, + { 0x1e240000, 0x00000001, }, { 0x1e262000, 0x00000001, }, + { 0x1e280000, 0x00000001, }, { 0x1e2a2000, 0x00000001, }, + { 0x1e2c0000, 0x00000001, }, { 0x1e2e2000, 0x00000001, }, + { 0x1f300000, 0x00000001, }, { 0x1f322000, 0x00000001, }, + { 0x1f340000, 0x00000001, }, { 0x1f362000, 0x00000001, }, + { 0x1f380000, 0x00000001, }, { 0x1f3a2000, 0x00000001, }, + { 0x1f3c0000, 0x00000001, }, { 0x1f3e2000, 0x00000001, }, }, + + {{ 0x00000000, 0x00000000, }, { 0x00000002, 0x20000000, }, + { 0x00000004, 0x00000000, }, { 0x00000006, 0x20000000, }, + { 0x00000008, 0x00000000, }, { 0x0000000a, 0x20000000, }, + { 0x0000000c, 0x00000000, }, { 0x0000000e, 0x20000000, }, + { 0x00000110, 0x00000000, }, { 0x00000112, 0x20000000, }, + { 0x00000114, 0x00000000, }, { 0x00000116, 0x20000000, }, + { 0x00000118, 0x00000000, }, { 0x0000011a, 0x20000000, }, + { 0x0000011c, 0x00000000, }, { 0x0000011e, 0x20000000, }, + { 0x00000220, 0x00000000, }, { 0x00000222, 0x20000000, }, + { 0x00000224, 0x00000000, }, { 0x00000226, 0x20000000, }, + { 0x00000228, 0x00000000, }, { 0x0000022a, 0x20000000, }, + { 0x0000022c, 0x00000000, }, { 0x0000022e, 0x20000000, }, + { 0x00000330, 0x00000000, }, { 0x00000332, 0x20000000, }, + { 0x00000334, 0x00000000, }, { 0x00000336, 0x20000000, }, + { 0x00000338, 0x00000000, }, { 0x0000033a, 0x20000000, }, + { 0x0000033c, 0x00000000, }, { 0x0000033e, 0x20000000, }, + { 0x00000400, 0x00000000, }, { 0x00000402, 0x20000000, }, + { 0x00000404, 0x00000000, }, { 0x00000406, 0x20000000, }, + { 0x00000408, 0x00000000, }, { 0x0000040a, 0x20000000, }, + { 0x0000040c, 0x00000000, }, { 0x0000040e, 0x20000000, }, + { 0x00000510, 0x00000000, }, { 0x00000512, 0x20000000, }, + { 0x00000514, 0x00000000, }, { 0x00000516, 0x20000000, }, + { 0x00000518, 0x00000000, }, { 0x0000051a, 0x20000000, }, + { 0x0000051c, 0x00000000, }, { 0x0000051e, 0x20000000, }, + { 0x00000620, 0x00000000, }, { 0x00000622, 0x20000000, }, + { 0x00000624, 0x00000000, }, { 0x00000626, 0x20000000, }, + { 0x00000628, 0x00000000, }, { 0x0000062a, 0x20000000, }, + { 0x0000062c, 0x00000000, }, { 0x0000062e, 0x20000000, }, + { 0x00000730, 0x00000000, }, { 0x00000732, 0x20000000, }, + { 0x00000734, 0x00000000, }, { 0x00000736, 0x20000000, }, + { 0x00000738, 0x00000000, }, { 0x0000073a, 0x20000000, }, + { 0x0000073c, 0x00000000, }, { 0x0000073e, 0x20000000, }, + { 0x00000800, 0x00000000, }, { 0x00000802, 0x20000000, }, + { 0x00000804, 0x00000000, }, { 0x00000806, 0x20000000, }, + { 0x00000808, 0x00000000, }, { 0x0000080a, 0x20000000, }, + { 0x0000080c, 0x00000000, }, { 0x0000080e, 0x20000000, }, + { 0x00000910, 0x00000000, }, { 0x00000912, 0x20000000, }, + { 0x00000914, 0x00000000, }, { 0x00000916, 0x20000000, }, + { 0x00000918, 0x00000000, }, { 0x0000091a, 0x20000000, }, + { 0x0000091c, 0x00000000, }, { 0x0000091e, 0x20000000, }, + { 0x00000a20, 0x00000000, }, { 0x00000a22, 0x20000000, }, + { 0x00000a24, 0x00000000, }, { 0x00000a26, 0x20000000, }, + { 0x00000a28, 0x00000000, }, { 0x00000a2a, 0x20000000, }, + { 0x00000a2c, 0x00000000, }, { 0x00000a2e, 0x20000000, }, + { 0x00000b30, 0x00000000, }, { 0x00000b32, 0x20000000, }, + { 0x00000b34, 0x00000000, }, { 0x00000b36, 0x20000000, }, + { 0x00000b38, 0x00000000, }, { 0x00000b3a, 0x20000000, }, + { 0x00000b3c, 0x00000000, }, { 0x00000b3e, 0x20000000, }, + { 0x00000c00, 0x00000000, }, { 0x00000c02, 0x20000000, }, + { 0x00000c04, 0x00000000, }, { 0x00000c06, 0x20000000, }, + { 0x00000c08, 0x00000000, }, { 0x00000c0a, 0x20000000, }, + { 0x00000c0c, 0x00000000, }, { 0x00000c0e, 0x20000000, }, + { 0x00000d10, 0x00000000, }, { 0x00000d12, 0x20000000, }, + { 0x00000d14, 0x00000000, }, { 0x00000d16, 0x20000000, }, + { 0x00000d18, 0x00000000, }, { 0x00000d1a, 0x20000000, }, + { 0x00000d1c, 0x00000000, }, { 0x00000d1e, 0x20000000, }, + { 0x00000e20, 0x00000000, }, { 0x00000e22, 0x20000000, }, + { 0x00000e24, 0x00000000, }, { 0x00000e26, 0x20000000, }, + { 0x00000e28, 0x00000000, }, { 0x00000e2a, 0x20000000, }, + { 0x00000e2c, 0x00000000, }, { 0x00000e2e, 0x20000000, }, + { 0x00000f30, 0x00000000, }, { 0x00000f32, 0x20000000, }, + { 0x00000f34, 0x00000000, }, { 0x00000f36, 0x20000000, }, + { 0x00000f38, 0x00000000, }, { 0x00000f3a, 0x20000000, }, + { 0x00000f3c, 0x00000000, }, { 0x00000f3e, 0x20000000, }, + { 0x00011000, 0x00000000, }, { 0x00011002, 0x20000000, }, + { 0x00011004, 0x00000000, }, { 0x00011006, 0x20000000, }, + { 0x00011008, 0x00000000, }, { 0x0001100a, 0x20000000, }, + { 0x0001100c, 0x00000000, }, { 0x0001100e, 0x20000000, }, + { 0x00011110, 0x00000000, }, { 0x00011112, 0x20000000, }, + { 0x00011114, 0x00000000, }, { 0x00011116, 0x20000000, }, + { 0x00011118, 0x00000000, }, { 0x0001111a, 0x20000000, }, + { 0x0001111c, 0x00000000, }, { 0x0001111e, 0x20000000, }, + { 0x00011220, 0x00000000, }, { 0x00011222, 0x20000000, }, + { 0x00011224, 0x00000000, }, { 0x00011226, 0x20000000, }, + { 0x00011228, 0x00000000, }, { 0x0001122a, 0x20000000, }, + { 0x0001122c, 0x00000000, }, { 0x0001122e, 0x20000000, }, + { 0x00011330, 0x00000000, }, { 0x00011332, 0x20000000, }, + { 0x00011334, 0x00000000, }, { 0x00011336, 0x20000000, }, + { 0x00011338, 0x00000000, }, { 0x0001133a, 0x20000000, }, + { 0x0001133c, 0x00000000, }, { 0x0001133e, 0x20000000, }, + { 0x00011400, 0x00000000, }, { 0x00011402, 0x20000000, }, + { 0x00011404, 0x00000000, }, { 0x00011406, 0x20000000, }, + { 0x00011408, 0x00000000, }, { 0x0001140a, 0x20000000, }, + { 0x0001140c, 0x00000000, }, { 0x0001140e, 0x20000000, }, + { 0x00011510, 0x00000000, }, { 0x00011512, 0x20000000, }, + { 0x00011514, 0x00000000, }, { 0x00011516, 0x20000000, }, + { 0x00011518, 0x00000000, }, { 0x0001151a, 0x20000000, }, + { 0x0001151c, 0x00000000, }, { 0x0001151e, 0x20000000, }, + { 0x00011620, 0x00000000, }, { 0x00011622, 0x20000000, }, + { 0x00011624, 0x00000000, }, { 0x00011626, 0x20000000, }, + { 0x00011628, 0x00000000, }, { 0x0001162a, 0x20000000, }, + { 0x0001162c, 0x00000000, }, { 0x0001162e, 0x20000000, }, + { 0x00011730, 0x00000000, }, { 0x00011732, 0x20000000, }, + { 0x00011734, 0x00000000, }, { 0x00011736, 0x20000000, }, + { 0x00011738, 0x00000000, }, { 0x0001173a, 0x20000000, }, + { 0x0001173c, 0x00000000, }, { 0x0001173e, 0x20000000, }, + { 0x00011800, 0x00000000, }, { 0x00011802, 0x20000000, }, + { 0x00011804, 0x00000000, }, { 0x00011806, 0x20000000, }, + { 0x00011808, 0x00000000, }, { 0x0001180a, 0x20000000, }, + { 0x0001180c, 0x00000000, }, { 0x0001180e, 0x20000000, }, + { 0x00011910, 0x00000000, }, { 0x00011912, 0x20000000, }, + { 0x00011914, 0x00000000, }, { 0x00011916, 0x20000000, }, + { 0x00011918, 0x00000000, }, { 0x0001191a, 0x20000000, }, + { 0x0001191c, 0x00000000, }, { 0x0001191e, 0x20000000, }, + { 0x00011a20, 0x00000000, }, { 0x00011a22, 0x20000000, }, + { 0x00011a24, 0x00000000, }, { 0x00011a26, 0x20000000, }, + { 0x00011a28, 0x00000000, }, { 0x00011a2a, 0x20000000, }, + { 0x00011a2c, 0x00000000, }, { 0x00011a2e, 0x20000000, }, + { 0x00011b30, 0x00000000, }, { 0x00011b32, 0x20000000, }, + { 0x00011b34, 0x00000000, }, { 0x00011b36, 0x20000000, }, + { 0x00011b38, 0x00000000, }, { 0x00011b3a, 0x20000000, }, + { 0x00011b3c, 0x00000000, }, { 0x00011b3e, 0x20000000, }, + { 0x00011c00, 0x00000000, }, { 0x00011c02, 0x20000000, }, + { 0x00011c04, 0x00000000, }, { 0x00011c06, 0x20000000, }, + { 0x00011c08, 0x00000000, }, { 0x00011c0a, 0x20000000, }, + { 0x00011c0c, 0x00000000, }, { 0x00011c0e, 0x20000000, }, + { 0x00011d10, 0x00000000, }, { 0x00011d12, 0x20000000, }, + { 0x00011d14, 0x00000000, }, { 0x00011d16, 0x20000000, }, + { 0x00011d18, 0x00000000, }, { 0x00011d1a, 0x20000000, }, + { 0x00011d1c, 0x00000000, }, { 0x00011d1e, 0x20000000, }, + { 0x00011e20, 0x00000000, }, { 0x00011e22, 0x20000000, }, + { 0x00011e24, 0x00000000, }, { 0x00011e26, 0x20000000, }, + { 0x00011e28, 0x00000000, }, { 0x00011e2a, 0x20000000, }, + { 0x00011e2c, 0x00000000, }, { 0x00011e2e, 0x20000000, }, + { 0x00011f30, 0x00000000, }, { 0x00011f32, 0x20000000, }, + { 0x00011f34, 0x00000000, }, { 0x00011f36, 0x20000000, }, + { 0x00011f38, 0x00000000, }, { 0x00011f3a, 0x20000000, }, + { 0x00011f3c, 0x00000000, }, { 0x00011f3e, 0x20000000, }, }, + + {{ 0x00000000, 0x00000000, }, { 0x00000000, 0x00022000, }, + { 0x00000000, 0x00040000, }, { 0x00000000, 0x00062000, }, + { 0x00000000, 0x00080000, }, { 0x00000000, 0x000a2000, }, + { 0x00000000, 0x000c0000, }, { 0x00000000, 0x000e2000, }, + { 0x00000000, 0x01100000, }, { 0x00000000, 0x01122000, }, + { 0x00000000, 0x01140000, }, { 0x00000000, 0x01162000, }, + { 0x00000000, 0x01180000, }, { 0x00000000, 0x011a2000, }, + { 0x00000000, 0x011c0000, }, { 0x00000000, 0x011e2000, }, + { 0x00000000, 0x02200000, }, { 0x00000000, 0x02222000, }, + { 0x00000000, 0x02240000, }, { 0x00000000, 0x02262000, }, + { 0x00000000, 0x02280000, }, { 0x00000000, 0x022a2000, }, + { 0x00000000, 0x022c0000, }, { 0x00000000, 0x022e2000, }, + { 0x00000000, 0x03300000, }, { 0x00000000, 0x03322000, }, + { 0x00000000, 0x03340000, }, { 0x00000000, 0x03362000, }, + { 0x00000000, 0x03380000, }, { 0x00000000, 0x033a2000, }, + { 0x00000000, 0x033c0000, }, { 0x00000000, 0x033e2000, }, + { 0x00000000, 0x04000000, }, { 0x00000000, 0x04022000, }, + { 0x00000000, 0x04040000, }, { 0x00000000, 0x04062000, }, + { 0x00000000, 0x04080000, }, { 0x00000000, 0x040a2000, }, + { 0x00000000, 0x040c0000, }, { 0x00000000, 0x040e2000, }, + { 0x00000000, 0x05100000, }, { 0x00000000, 0x05122000, }, + { 0x00000000, 0x05140000, }, { 0x00000000, 0x05162000, }, + { 0x00000000, 0x05180000, }, { 0x00000000, 0x051a2000, }, + { 0x00000000, 0x051c0000, }, { 0x00000000, 0x051e2000, }, + { 0x00000000, 0x06200000, }, { 0x00000000, 0x06222000, }, + { 0x00000000, 0x06240000, }, { 0x00000000, 0x06262000, }, + { 0x00000000, 0x06280000, }, { 0x00000000, 0x062a2000, }, + { 0x00000000, 0x062c0000, }, { 0x00000000, 0x062e2000, }, + { 0x00000000, 0x07300000, }, { 0x00000000, 0x07322000, }, + { 0x00000000, 0x07340000, }, { 0x00000000, 0x07362000, }, + { 0x00000000, 0x07380000, }, { 0x00000000, 0x073a2000, }, + { 0x00000000, 0x073c0000, }, { 0x00000000, 0x073e2000, }, + { 0x00000000, 0x08000000, }, { 0x00000000, 0x08022000, }, + { 0x00000000, 0x08040000, }, { 0x00000000, 0x08062000, }, + { 0x00000000, 0x08080000, }, { 0x00000000, 0x080a2000, }, + { 0x00000000, 0x080c0000, }, { 0x00000000, 0x080e2000, }, + { 0x00000000, 0x09100000, }, { 0x00000000, 0x09122000, }, + { 0x00000000, 0x09140000, }, { 0x00000000, 0x09162000, }, + { 0x00000000, 0x09180000, }, { 0x00000000, 0x091a2000, }, + { 0x00000000, 0x091c0000, }, { 0x00000000, 0x091e2000, }, + { 0x00000000, 0x0a200000, }, { 0x00000000, 0x0a222000, }, + { 0x00000000, 0x0a240000, }, { 0x00000000, 0x0a262000, }, + { 0x00000000, 0x0a280000, }, { 0x00000000, 0x0a2a2000, }, + { 0x00000000, 0x0a2c0000, }, { 0x00000000, 0x0a2e2000, }, + { 0x00000000, 0x0b300000, }, { 0x00000000, 0x0b322000, }, + { 0x00000000, 0x0b340000, }, { 0x00000000, 0x0b362000, }, + { 0x00000000, 0x0b380000, }, { 0x00000000, 0x0b3a2000, }, + { 0x00000000, 0x0b3c0000, }, { 0x00000000, 0x0b3e2000, }, + { 0x00000000, 0x0c000000, }, { 0x00000000, 0x0c022000, }, + { 0x00000000, 0x0c040000, }, { 0x00000000, 0x0c062000, }, + { 0x00000000, 0x0c080000, }, { 0x00000000, 0x0c0a2000, }, + { 0x00000000, 0x0c0c0000, }, { 0x00000000, 0x0c0e2000, }, + { 0x00000000, 0x0d100000, }, { 0x00000000, 0x0d122000, }, + { 0x00000000, 0x0d140000, }, { 0x00000000, 0x0d162000, }, + { 0x00000000, 0x0d180000, }, { 0x00000000, 0x0d1a2000, }, + { 0x00000000, 0x0d1c0000, }, { 0x00000000, 0x0d1e2000, }, + { 0x00000000, 0x0e200000, }, { 0x00000000, 0x0e222000, }, + { 0x00000000, 0x0e240000, }, { 0x00000000, 0x0e262000, }, + { 0x00000000, 0x0e280000, }, { 0x00000000, 0x0e2a2000, }, + { 0x00000000, 0x0e2c0000, }, { 0x00000000, 0x0e2e2000, }, + { 0x00000000, 0x0f300000, }, { 0x00000000, 0x0f322000, }, + { 0x00000000, 0x0f340000, }, { 0x00000000, 0x0f362000, }, + { 0x00000000, 0x0f380000, }, { 0x00000000, 0x0f3a2000, }, + { 0x00000000, 0x0f3c0000, }, { 0x00000000, 0x0f3e2000, }, + { 0x00000001, 0x10000000, }, { 0x00000001, 0x10022000, }, + { 0x00000001, 0x10040000, }, { 0x00000001, 0x10062000, }, + { 0x00000001, 0x10080000, }, { 0x00000001, 0x100a2000, }, + { 0x00000001, 0x100c0000, }, { 0x00000001, 0x100e2000, }, + { 0x00000001, 0x11100000, }, { 0x00000001, 0x11122000, }, + { 0x00000001, 0x11140000, }, { 0x00000001, 0x11162000, }, + { 0x00000001, 0x11180000, }, { 0x00000001, 0x111a2000, }, + { 0x00000001, 0x111c0000, }, { 0x00000001, 0x111e2000, }, + { 0x00000001, 0x12200000, }, { 0x00000001, 0x12222000, }, + { 0x00000001, 0x12240000, }, { 0x00000001, 0x12262000, }, + { 0x00000001, 0x12280000, }, { 0x00000001, 0x122a2000, }, + { 0x00000001, 0x122c0000, }, { 0x00000001, 0x122e2000, }, + { 0x00000001, 0x13300000, }, { 0x00000001, 0x13322000, }, + { 0x00000001, 0x13340000, }, { 0x00000001, 0x13362000, }, + { 0x00000001, 0x13380000, }, { 0x00000001, 0x133a2000, }, + { 0x00000001, 0x133c0000, }, { 0x00000001, 0x133e2000, }, + { 0x00000001, 0x14000000, }, { 0x00000001, 0x14022000, }, + { 0x00000001, 0x14040000, }, { 0x00000001, 0x14062000, }, + { 0x00000001, 0x14080000, }, { 0x00000001, 0x140a2000, }, + { 0x00000001, 0x140c0000, }, { 0x00000001, 0x140e2000, }, + { 0x00000001, 0x15100000, }, { 0x00000001, 0x15122000, }, + { 0x00000001, 0x15140000, }, { 0x00000001, 0x15162000, }, + { 0x00000001, 0x15180000, }, { 0x00000001, 0x151a2000, }, + { 0x00000001, 0x151c0000, }, { 0x00000001, 0x151e2000, }, + { 0x00000001, 0x16200000, }, { 0x00000001, 0x16222000, }, + { 0x00000001, 0x16240000, }, { 0x00000001, 0x16262000, }, + { 0x00000001, 0x16280000, }, { 0x00000001, 0x162a2000, }, + { 0x00000001, 0x162c0000, }, { 0x00000001, 0x162e2000, }, + { 0x00000001, 0x17300000, }, { 0x00000001, 0x17322000, }, + { 0x00000001, 0x17340000, }, { 0x00000001, 0x17362000, }, + { 0x00000001, 0x17380000, }, { 0x00000001, 0x173a2000, }, + { 0x00000001, 0x173c0000, }, { 0x00000001, 0x173e2000, }, + { 0x00000001, 0x18000000, }, { 0x00000001, 0x18022000, }, + { 0x00000001, 0x18040000, }, { 0x00000001, 0x18062000, }, + { 0x00000001, 0x18080000, }, { 0x00000001, 0x180a2000, }, + { 0x00000001, 0x180c0000, }, { 0x00000001, 0x180e2000, }, + { 0x00000001, 0x19100000, }, { 0x00000001, 0x19122000, }, + { 0x00000001, 0x19140000, }, { 0x00000001, 0x19162000, }, + { 0x00000001, 0x19180000, }, { 0x00000001, 0x191a2000, }, + { 0x00000001, 0x191c0000, }, { 0x00000001, 0x191e2000, }, + { 0x00000001, 0x1a200000, }, { 0x00000001, 0x1a222000, }, + { 0x00000001, 0x1a240000, }, { 0x00000001, 0x1a262000, }, + { 0x00000001, 0x1a280000, }, { 0x00000001, 0x1a2a2000, }, + { 0x00000001, 0x1a2c0000, }, { 0x00000001, 0x1a2e2000, }, + { 0x00000001, 0x1b300000, }, { 0x00000001, 0x1b322000, }, + { 0x00000001, 0x1b340000, }, { 0x00000001, 0x1b362000, }, + { 0x00000001, 0x1b380000, }, { 0x00000001, 0x1b3a2000, }, + { 0x00000001, 0x1b3c0000, }, { 0x00000001, 0x1b3e2000, }, + { 0x00000001, 0x1c000000, }, { 0x00000001, 0x1c022000, }, + { 0x00000001, 0x1c040000, }, { 0x00000001, 0x1c062000, }, + { 0x00000001, 0x1c080000, }, { 0x00000001, 0x1c0a2000, }, + { 0x00000001, 0x1c0c0000, }, { 0x00000001, 0x1c0e2000, }, + { 0x00000001, 0x1d100000, }, { 0x00000001, 0x1d122000, }, + { 0x00000001, 0x1d140000, }, { 0x00000001, 0x1d162000, }, + { 0x00000001, 0x1d180000, }, { 0x00000001, 0x1d1a2000, }, + { 0x00000001, 0x1d1c0000, }, { 0x00000001, 0x1d1e2000, }, + { 0x00000001, 0x1e200000, }, { 0x00000001, 0x1e222000, }, + { 0x00000001, 0x1e240000, }, { 0x00000001, 0x1e262000, }, + { 0x00000001, 0x1e280000, }, { 0x00000001, 0x1e2a2000, }, + { 0x00000001, 0x1e2c0000, }, { 0x00000001, 0x1e2e2000, }, + { 0x00000001, 0x1f300000, }, { 0x00000001, 0x1f322000, }, + { 0x00000001, 0x1f340000, }, { 0x00000001, 0x1f362000, }, + { 0x00000001, 0x1f380000, }, { 0x00000001, 0x1f3a2000, }, + { 0x00000001, 0x1f3c0000, }, { 0x00000001, 0x1f3e2000, }, }, + + {{ 0x00000000, 0x00000000, }, { 0x20000000, 0x00000002, }, + { 0x00000000, 0x00000004, }, { 0x20000000, 0x00000006, }, + { 0x00000000, 0x00000008, }, { 0x20000000, 0x0000000a, }, + { 0x00000000, 0x0000000c, }, { 0x20000000, 0x0000000e, }, + { 0x00000000, 0x00000110, }, { 0x20000000, 0x00000112, }, + { 0x00000000, 0x00000114, }, { 0x20000000, 0x00000116, }, + { 0x00000000, 0x00000118, }, { 0x20000000, 0x0000011a, }, + { 0x00000000, 0x0000011c, }, { 0x20000000, 0x0000011e, }, + { 0x00000000, 0x00000220, }, { 0x20000000, 0x00000222, }, + { 0x00000000, 0x00000224, }, { 0x20000000, 0x00000226, }, + { 0x00000000, 0x00000228, }, { 0x20000000, 0x0000022a, }, + { 0x00000000, 0x0000022c, }, { 0x20000000, 0x0000022e, }, + { 0x00000000, 0x00000330, }, { 0x20000000, 0x00000332, }, + { 0x00000000, 0x00000334, }, { 0x20000000, 0x00000336, }, + { 0x00000000, 0x00000338, }, { 0x20000000, 0x0000033a, }, + { 0x00000000, 0x0000033c, }, { 0x20000000, 0x0000033e, }, + { 0x00000000, 0x00000400, }, { 0x20000000, 0x00000402, }, + { 0x00000000, 0x00000404, }, { 0x20000000, 0x00000406, }, + { 0x00000000, 0x00000408, }, { 0x20000000, 0x0000040a, }, + { 0x00000000, 0x0000040c, }, { 0x20000000, 0x0000040e, }, + { 0x00000000, 0x00000510, }, { 0x20000000, 0x00000512, }, + { 0x00000000, 0x00000514, }, { 0x20000000, 0x00000516, }, + { 0x00000000, 0x00000518, }, { 0x20000000, 0x0000051a, }, + { 0x00000000, 0x0000051c, }, { 0x20000000, 0x0000051e, }, + { 0x00000000, 0x00000620, }, { 0x20000000, 0x00000622, }, + { 0x00000000, 0x00000624, }, { 0x20000000, 0x00000626, }, + { 0x00000000, 0x00000628, }, { 0x20000000, 0x0000062a, }, + { 0x00000000, 0x0000062c, }, { 0x20000000, 0x0000062e, }, + { 0x00000000, 0x00000730, }, { 0x20000000, 0x00000732, }, + { 0x00000000, 0x00000734, }, { 0x20000000, 0x00000736, }, + { 0x00000000, 0x00000738, }, { 0x20000000, 0x0000073a, }, + { 0x00000000, 0x0000073c, }, { 0x20000000, 0x0000073e, }, + { 0x00000000, 0x00000800, }, { 0x20000000, 0x00000802, }, + { 0x00000000, 0x00000804, }, { 0x20000000, 0x00000806, }, + { 0x00000000, 0x00000808, }, { 0x20000000, 0x0000080a, }, + { 0x00000000, 0x0000080c, }, { 0x20000000, 0x0000080e, }, + { 0x00000000, 0x00000910, }, { 0x20000000, 0x00000912, }, + { 0x00000000, 0x00000914, }, { 0x20000000, 0x00000916, }, + { 0x00000000, 0x00000918, }, { 0x20000000, 0x0000091a, }, + { 0x00000000, 0x0000091c, }, { 0x20000000, 0x0000091e, }, + { 0x00000000, 0x00000a20, }, { 0x20000000, 0x00000a22, }, + { 0x00000000, 0x00000a24, }, { 0x20000000, 0x00000a26, }, + { 0x00000000, 0x00000a28, }, { 0x20000000, 0x00000a2a, }, + { 0x00000000, 0x00000a2c, }, { 0x20000000, 0x00000a2e, }, + { 0x00000000, 0x00000b30, }, { 0x20000000, 0x00000b32, }, + { 0x00000000, 0x00000b34, }, { 0x20000000, 0x00000b36, }, + { 0x00000000, 0x00000b38, }, { 0x20000000, 0x00000b3a, }, + { 0x00000000, 0x00000b3c, }, { 0x20000000, 0x00000b3e, }, + { 0x00000000, 0x00000c00, }, { 0x20000000, 0x00000c02, }, + { 0x00000000, 0x00000c04, }, { 0x20000000, 0x00000c06, }, + { 0x00000000, 0x00000c08, }, { 0x20000000, 0x00000c0a, }, + { 0x00000000, 0x00000c0c, }, { 0x20000000, 0x00000c0e, }, + { 0x00000000, 0x00000d10, }, { 0x20000000, 0x00000d12, }, + { 0x00000000, 0x00000d14, }, { 0x20000000, 0x00000d16, }, + { 0x00000000, 0x00000d18, }, { 0x20000000, 0x00000d1a, }, + { 0x00000000, 0x00000d1c, }, { 0x20000000, 0x00000d1e, }, + { 0x00000000, 0x00000e20, }, { 0x20000000, 0x00000e22, }, + { 0x00000000, 0x00000e24, }, { 0x20000000, 0x00000e26, }, + { 0x00000000, 0x00000e28, }, { 0x20000000, 0x00000e2a, }, + { 0x00000000, 0x00000e2c, }, { 0x20000000, 0x00000e2e, }, + { 0x00000000, 0x00000f30, }, { 0x20000000, 0x00000f32, }, + { 0x00000000, 0x00000f34, }, { 0x20000000, 0x00000f36, }, + { 0x00000000, 0x00000f38, }, { 0x20000000, 0x00000f3a, }, + { 0x00000000, 0x00000f3c, }, { 0x20000000, 0x00000f3e, }, + { 0x00000000, 0x00011000, }, { 0x20000000, 0x00011002, }, + { 0x00000000, 0x00011004, }, { 0x20000000, 0x00011006, }, + { 0x00000000, 0x00011008, }, { 0x20000000, 0x0001100a, }, + { 0x00000000, 0x0001100c, }, { 0x20000000, 0x0001100e, }, + { 0x00000000, 0x00011110, }, { 0x20000000, 0x00011112, }, + { 0x00000000, 0x00011114, }, { 0x20000000, 0x00011116, }, + { 0x00000000, 0x00011118, }, { 0x20000000, 0x0001111a, }, + { 0x00000000, 0x0001111c, }, { 0x20000000, 0x0001111e, }, + { 0x00000000, 0x00011220, }, { 0x20000000, 0x00011222, }, + { 0x00000000, 0x00011224, }, { 0x20000000, 0x00011226, }, + { 0x00000000, 0x00011228, }, { 0x20000000, 0x0001122a, }, + { 0x00000000, 0x0001122c, }, { 0x20000000, 0x0001122e, }, + { 0x00000000, 0x00011330, }, { 0x20000000, 0x00011332, }, + { 0x00000000, 0x00011334, }, { 0x20000000, 0x00011336, }, + { 0x00000000, 0x00011338, }, { 0x20000000, 0x0001133a, }, + { 0x00000000, 0x0001133c, }, { 0x20000000, 0x0001133e, }, + { 0x00000000, 0x00011400, }, { 0x20000000, 0x00011402, }, + { 0x00000000, 0x00011404, }, { 0x20000000, 0x00011406, }, + { 0x00000000, 0x00011408, }, { 0x20000000, 0x0001140a, }, + { 0x00000000, 0x0001140c, }, { 0x20000000, 0x0001140e, }, + { 0x00000000, 0x00011510, }, { 0x20000000, 0x00011512, }, + { 0x00000000, 0x00011514, }, { 0x20000000, 0x00011516, }, + { 0x00000000, 0x00011518, }, { 0x20000000, 0x0001151a, }, + { 0x00000000, 0x0001151c, }, { 0x20000000, 0x0001151e, }, + { 0x00000000, 0x00011620, }, { 0x20000000, 0x00011622, }, + { 0x00000000, 0x00011624, }, { 0x20000000, 0x00011626, }, + { 0x00000000, 0x00011628, }, { 0x20000000, 0x0001162a, }, + { 0x00000000, 0x0001162c, }, { 0x20000000, 0x0001162e, }, + { 0x00000000, 0x00011730, }, { 0x20000000, 0x00011732, }, + { 0x00000000, 0x00011734, }, { 0x20000000, 0x00011736, }, + { 0x00000000, 0x00011738, }, { 0x20000000, 0x0001173a, }, + { 0x00000000, 0x0001173c, }, { 0x20000000, 0x0001173e, }, + { 0x00000000, 0x00011800, }, { 0x20000000, 0x00011802, }, + { 0x00000000, 0x00011804, }, { 0x20000000, 0x00011806, }, + { 0x00000000, 0x00011808, }, { 0x20000000, 0x0001180a, }, + { 0x00000000, 0x0001180c, }, { 0x20000000, 0x0001180e, }, + { 0x00000000, 0x00011910, }, { 0x20000000, 0x00011912, }, + { 0x00000000, 0x00011914, }, { 0x20000000, 0x00011916, }, + { 0x00000000, 0x00011918, }, { 0x20000000, 0x0001191a, }, + { 0x00000000, 0x0001191c, }, { 0x20000000, 0x0001191e, }, + { 0x00000000, 0x00011a20, }, { 0x20000000, 0x00011a22, }, + { 0x00000000, 0x00011a24, }, { 0x20000000, 0x00011a26, }, + { 0x00000000, 0x00011a28, }, { 0x20000000, 0x00011a2a, }, + { 0x00000000, 0x00011a2c, }, { 0x20000000, 0x00011a2e, }, + { 0x00000000, 0x00011b30, }, { 0x20000000, 0x00011b32, }, + { 0x00000000, 0x00011b34, }, { 0x20000000, 0x00011b36, }, + { 0x00000000, 0x00011b38, }, { 0x20000000, 0x00011b3a, }, + { 0x00000000, 0x00011b3c, }, { 0x20000000, 0x00011b3e, }, + { 0x00000000, 0x00011c00, }, { 0x20000000, 0x00011c02, }, + { 0x00000000, 0x00011c04, }, { 0x20000000, 0x00011c06, }, + { 0x00000000, 0x00011c08, }, { 0x20000000, 0x00011c0a, }, + { 0x00000000, 0x00011c0c, }, { 0x20000000, 0x00011c0e, }, + { 0x00000000, 0x00011d10, }, { 0x20000000, 0x00011d12, }, + { 0x00000000, 0x00011d14, }, { 0x20000000, 0x00011d16, }, + { 0x00000000, 0x00011d18, }, { 0x20000000, 0x00011d1a, }, + { 0x00000000, 0x00011d1c, }, { 0x20000000, 0x00011d1e, }, + { 0x00000000, 0x00011e20, }, { 0x20000000, 0x00011e22, }, + { 0x00000000, 0x00011e24, }, { 0x20000000, 0x00011e26, }, + { 0x00000000, 0x00011e28, }, { 0x20000000, 0x00011e2a, }, + { 0x00000000, 0x00011e2c, }, { 0x20000000, 0x00011e2e, }, + { 0x00000000, 0x00011f30, }, { 0x20000000, 0x00011f32, }, + { 0x00000000, 0x00011f34, }, { 0x20000000, 0x00011f36, }, + { 0x00000000, 0x00011f38, }, { 0x20000000, 0x00011f3a, }, + { 0x00000000, 0x00011f3c, }, { 0x20000000, 0x00011f3e, }, } +}; + +/* + * The 8 selection functions. + * 8 functions to map 6 bits to 64 bits + */ +const uint32_t S_tab[8][64] = { + { + 0xe0000000U, 0x00000000U, 0x40000000U, 0xf0000000U, + 0xd0000000U, 0x70000000U, 0x10000000U, 0x40000000U, + 0x20000000U, 0xe0000000U, 0xf0000000U, 0x20000000U, + 0xb0000000U, 0xd0000000U, 0x80000000U, 0x10000000U, + 0x30000000U, 0xa0000000U, 0xa0000000U, 0x60000000U, + 0x60000000U, 0xc0000000U, 0xc0000000U, 0xb0000000U, + 0x50000000U, 0x90000000U, 0x90000000U, 0x50000000U, + 0x00000000U, 0x30000000U, 0x70000000U, 0x80000000U, + 0x40000000U, 0xf0000000U, 0x10000000U, 0xc0000000U, + 0xe0000000U, 0x80000000U, 0x80000000U, 0x20000000U, + 0xd0000000U, 0x40000000U, 0x60000000U, 0x90000000U, + 0x20000000U, 0x10000000U, 0xb0000000U, 0x70000000U, + 0xf0000000U, 0x50000000U, 0xc0000000U, 0xb0000000U, + 0x90000000U, 0x30000000U, 0x70000000U, 0xe0000000U, + 0x30000000U, 0xa0000000U, 0xa0000000U, 0x00000000U, + 0x50000000U, 0x60000000U, 0x00000000U, 0xd0000000U, + }, + { + 0x0f000000U, 0x03000000U, 0x01000000U, 0x0d000000U, + 0x08000000U, 0x04000000U, 0x0e000000U, 0x07000000U, + 0x06000000U, 0x0f000000U, 0x0b000000U, 0x02000000U, + 0x03000000U, 0x08000000U, 0x04000000U, 0x0e000000U, + 0x09000000U, 0x0c000000U, 0x07000000U, 0x00000000U, + 0x02000000U, 0x01000000U, 0x0d000000U, 0x0a000000U, + 0x0c000000U, 0x06000000U, 0x00000000U, 0x09000000U, + 0x05000000U, 0x0b000000U, 0x0a000000U, 0x05000000U, + 0x00000000U, 0x0d000000U, 0x0e000000U, 0x08000000U, + 0x07000000U, 0x0a000000U, 0x0b000000U, 0x01000000U, + 0x0a000000U, 0x03000000U, 0x04000000U, 0x0f000000U, + 0x0d000000U, 0x04000000U, 0x01000000U, 0x02000000U, + 0x05000000U, 0x0b000000U, 0x08000000U, 0x06000000U, + 0x0c000000U, 0x07000000U, 0x06000000U, 0x0c000000U, + 0x09000000U, 0x00000000U, 0x03000000U, 0x05000000U, + 0x02000000U, 0x0e000000U, 0x0f000000U, 0x09000000U, + }, + { + 0x00a00000U, 0x00d00000U, 0x00000000U, 0x00700000U, + 0x00900000U, 0x00000000U, 0x00e00000U, 0x00900000U, + 0x00600000U, 0x00300000U, 0x00300000U, 0x00400000U, + 0x00f00000U, 0x00600000U, 0x00500000U, 0x00a00000U, + 0x00100000U, 0x00200000U, 0x00d00000U, 0x00800000U, + 0x00c00000U, 0x00500000U, 0x00700000U, 0x00e00000U, + 0x00b00000U, 0x00c00000U, 0x00400000U, 0x00b00000U, + 0x00200000U, 0x00f00000U, 0x00800000U, 0x00100000U, + 0x00d00000U, 0x00100000U, 0x00600000U, 0x00a00000U, + 0x00400000U, 0x00d00000U, 0x00900000U, 0x00000000U, + 0x00800000U, 0x00600000U, 0x00f00000U, 0x00900000U, + 0x00300000U, 0x00800000U, 0x00000000U, 0x00700000U, + 0x00b00000U, 0x00400000U, 0x00100000U, 0x00f00000U, + 0x00200000U, 0x00e00000U, 0x00c00000U, 0x00300000U, + 0x00500000U, 0x00b00000U, 0x00a00000U, 0x00500000U, + 0x00e00000U, 0x00200000U, 0x00700000U, 0x00c00000U, + }, + { + 0x00070000U, 0x000d0000U, 0x000d0000, 0x00080000U, + 0x000e0000U, 0x000b0000U, 0x00030000, 0x00050000U, + 0x00000000U, 0x00060000U, 0x00060000, 0x000f0000U, + 0x00090000U, 0x00000000U, 0x000a0000, 0x00030000U, + 0x00010000U, 0x00040000U, 0x00020000, 0x00070000U, + 0x00080000U, 0x00020000U, 0x00050000, 0x000c0000U, + 0x000b0000U, 0x00010000U, 0x000c0000, 0x000a0000U, + 0x00040000U, 0x000e0000U, 0x000f0000, 0x00090000U, + 0x000a0000U, 0x00030000U, 0x00060000, 0x000f0000U, + 0x00090000U, 0x00000000U, 0x00000000, 0x00060000U, + 0x000c0000U, 0x000a0000U, 0x000b0000, 0x00010000U, + 0x00070000U, 0x000d0000U, 0x000d0000, 0x00080000U, + 0x000f0000U, 0x00090000U, 0x00010000, 0x00040000U, + 0x00030000U, 0x00050000U, 0x000e0000, 0x000b0000U, + 0x00050000U, 0x000c0000U, 0x00020000, 0x00070000U, + 0x00080000U, 0x00020000U, 0x00040000, 0x000e0000U, + }, + { + 0x00002000U, 0x0000e000U, 0x0000c000U, 0x0000b000U, + 0x00004000U, 0x00002000U, 0x00001000U, 0x0000c000U, + 0x00007000U, 0x00004000U, 0x0000a000U, 0x00007000U, + 0x0000b000U, 0x0000d000U, 0x00006000U, 0x00001000U, + 0x00008000U, 0x00005000U, 0x00005000U, 0x00000000U, + 0x00003000U, 0x0000f000U, 0x0000f000U, 0x0000a000U, + 0x0000d000U, 0x00003000U, 0x00000000U, 0x00009000U, + 0x0000e000U, 0x00008000U, 0x00009000U, 0x00006000U, + 0x00004000U, 0x0000b000U, 0x00002000U, 0x00008000U, + 0x00001000U, 0x0000c000U, 0x0000b000U, 0x00007000U, + 0x0000a000U, 0x00001000U, 0x0000d000U, 0x0000e000U, + 0x00007000U, 0x00002000U, 0x00008000U, 0x0000d000U, + 0x0000f000U, 0x00006000U, 0x00009000U, 0x0000f000U, + 0x0000c000U, 0x00000000U, 0x00005000U, 0x00009000U, + 0x00006000U, 0x0000a000U, 0x00003000U, 0x00004000U, + 0x00000000U, 0x00005000U, 0x0000e000U, 0x00003000U, + }, + { + 0x00000c00U, 0x00000a00U, 0x00000100U, 0x00000f00U, + 0x00000a00U, 0x00000400U, 0x00000f00U, 0x00000200U, + 0x00000900U, 0x00000700U, 0x00000200U, 0x00000c00U, + 0x00000600U, 0x00000900U, 0x00000800U, 0x00000500U, + 0x00000000U, 0x00000600U, 0x00000d00U, 0x00000100U, + 0x00000300U, 0x00000d00U, 0x00000400U, 0x00000e00U, + 0x00000e00U, 0x00000000U, 0x00000700U, 0x00000b00U, + 0x00000500U, 0x00000300U, 0x00000b00U, 0x00000800U, + 0x00000900U, 0x00000400U, 0x00000e00U, 0x00000300U, + 0x00000f00U, 0x00000200U, 0x00000500U, 0x00000c00U, + 0x00000200U, 0x00000900U, 0x00000800U, 0x00000500U, + 0x00000c00U, 0x00000f00U, 0x00000300U, 0x00000a00U, + 0x00000700U, 0x00000b00U, 0x00000000U, 0x00000e00U, + 0x00000400U, 0x00000100U, 0x00000a00U, 0x00000700U, + 0x00000100U, 0x00000600U, 0x00000d00U, 0x00000000U, + 0x00000b00U, 0x00000800U, 0x00000600U, 0x00000d00U, + }, + { + 0x00000040U, 0x000000d0U, 0x000000b0U, 0x00000000U, + 0x00000020U, 0x000000b0U, 0x000000e0U, 0x00000070U, + 0x000000f0U, 0x00000040U, 0x00000000U, 0x00000090U, + 0x00000080U, 0x00000010U, 0x000000d0U, 0x000000a0U, + 0x00000030U, 0x000000e0U, 0x000000c0U, 0x00000030U, + 0x00000090U, 0x00000050U, 0x00000070U, 0x000000c0U, + 0x00000050U, 0x00000020U, 0x000000a0U, 0x000000f0U, + 0x00000060U, 0x00000080U, 0x00000010U, 0x00000060U, + 0x00000010U, 0x00000060U, 0x00000040U, 0x000000b0U, + 0x000000b0U, 0x000000d0U, 0x000000d0U, 0x00000080U, + 0x000000c0U, 0x00000010U, 0x00000030U, 0x00000040U, + 0x00000070U, 0x000000a0U, 0x000000e0U, 0x00000070U, + 0x000000a0U, 0x00000090U, 0x000000f0U, 0x00000050U, + 0x00000060U, 0x00000000U, 0x00000080U, 0x000000f0U, + 0x00000000U, 0x000000e0U, 0x00000050U, 0x00000020U, + 0x00000090U, 0x00000030U, 0x00000020U, 0x000000c0U, + }, + { + 0x0000000dU, 0x00000001U, 0x00000002U, 0x0000000fU, + 0x00000008U, 0x0000000dU, 0x00000004U, 0x00000008U, + 0x00000006U, 0x0000000aU, 0x0000000fU, 0x00000003U, + 0x0000000bU, 0x00000007U, 0x00000001U, 0x00000004U, + 0x0000000aU, 0x0000000cU, 0x00000009U, 0x00000005U, + 0x00000003U, 0x00000006U, 0x0000000eU, 0x0000000bU, + 0x00000005U, 0x00000000U, 0x00000000U, 0x0000000eU, + 0x0000000cU, 0x00000009U, 0x00000007U, 0x00000002U, + 0x00000007U, 0x00000002U, 0x0000000bU, 0x00000001U, + 0x00000004U, 0x0000000eU, 0x00000001U, 0x00000007U, + 0x00000009U, 0x00000004U, 0x0000000cU, 0x0000000aU, + 0x0000000eU, 0x00000008U, 0x00000002U, 0x0000000dU, + 0x00000000U, 0x0000000fU, 0x00000006U, 0x0000000cU, + 0x0000000aU, 0x00000009U, 0x0000000dU, 0x00000000U, + 0x0000000fU, 0x00000003U, 0x00000003U, 0x00000005U, + 0x00000005U, 0x00000006U, 0x00000008U, 0x0000000bU, + }, +}; + +/* + * Permute 32 bit output of S boxes + */ +const uint32_t P_tab[4][256] = { + 0x00000000U, 0x00004000U, 0x40000000U, 0x40004000U, + 0x00000010U, 0x00004010U, 0x40000010U, 0x40004010U, + 0x00080000U, 0x00084000U, 0x40080000U, 0x40084000U, + 0x00080010U, 0x00084010U, 0x40080010U, 0x40084010U, + 0x00000002U, 0x00004002U, 0x40000002U, 0x40004002U, + 0x00000012U, 0x00004012U, 0x40000012U, 0x40004012U, + 0x00080002U, 0x00084002U, 0x40080002U, 0x40084002U, + 0x00080012U, 0x00084012U, 0x40080012U, 0x40084012U, + 0x00000200U, 0x00004200U, 0x40000200U, 0x40004200U, + 0x00000210U, 0x00004210U, 0x40000210U, 0x40004210U, + 0x00080200U, 0x00084200U, 0x40080200U, 0x40084200U, + 0x00080210U, 0x00084210U, 0x40080210U, 0x40084210U, + 0x00000202U, 0x00004202U, 0x40000202U, 0x40004202U, + 0x00000212U, 0x00004212U, 0x40000212U, 0x40004212U, + 0x00080202U, 0x00084202U, 0x40080202U, 0x40084202U, + 0x00080212U, 0x00084212U, 0x40080212U, 0x40084212U, + 0x00008000U, 0x0000c000U, 0x40008000U, 0x4000c000U, + 0x00008010U, 0x0000c010U, 0x40008010U, 0x4000c010U, + 0x00088000U, 0x0008c000U, 0x40088000U, 0x4008c000U, + 0x00088010U, 0x0008c010U, 0x40088010U, 0x4008c010U, + 0x00008002U, 0x0000c002U, 0x40008002U, 0x4000c002U, + 0x00008012U, 0x0000c012U, 0x40008012U, 0x4000c012U, + 0x00088002U, 0x0008c002U, 0x40088002U, 0x4008c002U, + 0x00088012U, 0x0008c012U, 0x40088012U, 0x4008c012U, + 0x00008200U, 0x0000c200U, 0x40008200U, 0x4000c200U, + 0x00008210U, 0x0000c210U, 0x40008210U, 0x4000c210U, + 0x00088200U, 0x0008c200U, 0x40088200U, 0x4008c200U, + 0x00088210U, 0x0008c210U, 0x40088210U, 0x4008c210U, + 0x00008202U, 0x0000c202U, 0x40008202U, 0x4000c202U, + 0x00008212U, 0x0000c212U, 0x40008212U, 0x4000c212U, + 0x00088202U, 0x0008c202U, 0x40088202U, 0x4008c202U, + 0x00088212U, 0x0008c212U, 0x40088212U, 0x4008c212U, + 0x00800000U, 0x00804000U, 0x40800000U, 0x40804000U, + 0x00800010U, 0x00804010U, 0x40800010U, 0x40804010U, + 0x00880000U, 0x00884000U, 0x40880000U, 0x40884000U, + 0x00880010U, 0x00884010U, 0x40880010U, 0x40884010U, + 0x00800002U, 0x00804002U, 0x40800002U, 0x40804002U, + 0x00800012U, 0x00804012U, 0x40800012U, 0x40804012U, + 0x00880002U, 0x00884002U, 0x40880002U, 0x40884002U, + 0x00880012U, 0x00884012U, 0x40880012U, 0x40884012U, + 0x00800200U, 0x00804200U, 0x40800200U, 0x40804200U, + 0x00800210U, 0x00804210U, 0x40800210U, 0x40804210U, + 0x00880200U, 0x00884200U, 0x40880200U, 0x40884200U, + 0x00880210U, 0x00884210U, 0x40880210U, 0x40884210U, + 0x00800202U, 0x00804202U, 0x40800202U, 0x40804202U, + 0x00800212U, 0x00804212U, 0x40800212U, 0x40804212U, + 0x00880202U, 0x00884202U, 0x40880202U, 0x40884202U, + 0x00880212U, 0x00884212U, 0x40880212U, 0x40884212U, + 0x00808000U, 0x0080c000U, 0x40808000U, 0x4080c000U, + 0x00808010U, 0x0080c010U, 0x40808010U, 0x4080c010U, + 0x00888000U, 0x0088c000U, 0x40888000U, 0x4088c000U, + 0x00888010U, 0x0088c010U, 0x40888010U, 0x4088c010U, + 0x00808002U, 0x0080c002U, 0x40808002U, 0x4080c002U, + 0x00808012U, 0x0080c012U, 0x40808012U, 0x4080c012U, + 0x00888002U, 0x0088c002U, 0x40888002U, 0x4088c002U, + 0x00888012U, 0x0088c012U, 0x40888012U, 0x4088c012U, + 0x00808200U, 0x0080c200U, 0x40808200U, 0x4080c200U, + 0x00808210U, 0x0080c210U, 0x40808210U, 0x4080c210U, + 0x00888200U, 0x0088c200U, 0x40888200U, 0x4088c200U, + 0x00888210U, 0x0088c210U, 0x40888210U, 0x4088c210U, + 0x00808202U, 0x0080c202U, 0x40808202U, 0x4080c202U, + 0x00808212U, 0x0080c212U, 0x40808212U, 0x4080c212U, + 0x00888202U, 0x0088c202U, 0x40888202U, 0x4088c202U, + 0x00888212U, 0x0088c212U, 0x40888212U, 0x4088c212U, + 0x00000000U, 0x80000000U, 0x00400000U, 0x80400000U, + 0x00001000U, 0x80001000U, 0x00401000U, 0x80401000U, + 0x00000040U, 0x80000040U, 0x00400040U, 0x80400040U, + 0x00001040U, 0x80001040U, 0x00401040U, 0x80401040U, + 0x04000000U, 0x84000000U, 0x04400000U, 0x84400000U, + 0x04001000U, 0x84001000U, 0x04401000U, 0x84401000U, + 0x04000040U, 0x84000040U, 0x04400040U, 0x84400040U, + 0x04001040U, 0x84001040U, 0x04401040U, 0x84401040U, + 0x00000004U, 0x80000004U, 0x00400004U, 0x80400004U, + 0x00001004U, 0x80001004U, 0x00401004U, 0x80401004U, + 0x00000044U, 0x80000044U, 0x00400044U, 0x80400044U, + 0x00001044U, 0x80001044U, 0x00401044U, 0x80401044U, + 0x04000004U, 0x84000004U, 0x04400004U, 0x84400004U, + 0x04001004U, 0x84001004U, 0x04401004U, 0x84401004U, + 0x04000044U, 0x84000044U, 0x04400044U, 0x84400044U, + 0x04001044U, 0x84001044U, 0x04401044U, 0x84401044U, + 0x00010000U, 0x80010000U, 0x00410000U, 0x80410000U, + 0x00011000U, 0x80011000U, 0x00411000U, 0x80411000U, + 0x00010040U, 0x80010040U, 0x00410040U, 0x80410040U, + 0x00011040U, 0x80011040U, 0x00411040U, 0x80411040U, + 0x04010000U, 0x84010000U, 0x04410000U, 0x84410000U, + 0x04011000U, 0x84011000U, 0x04411000U, 0x84411000U, + 0x04010040U, 0x84010040U, 0x04410040U, 0x84410040U, + 0x04011040U, 0x84011040U, 0x04411040U, 0x84411040U, + 0x00010004U, 0x80010004U, 0x00410004U, 0x80410004U, + 0x00011004U, 0x80011004U, 0x00411004U, 0x80411004U, + 0x00010044U, 0x80010044U, 0x00410044U, 0x80410044U, + 0x00011044U, 0x80011044U, 0x00411044U, 0x80411044U, + 0x04010004U, 0x84010004U, 0x04410004U, 0x84410004U, + 0x04011004U, 0x84011004U, 0x04411004U, 0x84411004U, + 0x04010044U, 0x84010044U, 0x04410044U, 0x84410044U, + 0x04011044U, 0x84011044U, 0x04411044U, 0x84411044U, + 0x00000100U, 0x80000100U, 0x00400100U, 0x80400100U, + 0x00001100U, 0x80001100U, 0x00401100U, 0x80401100U, + 0x00000140U, 0x80000140U, 0x00400140U, 0x80400140U, + 0x00001140U, 0x80001140U, 0x00401140U, 0x80401140U, + 0x04000100U, 0x84000100U, 0x04400100U, 0x84400100U, + 0x04001100U, 0x84001100U, 0x04401100U, 0x84401100U, + 0x04000140U, 0x84000140U, 0x04400140U, 0x84400140U, + 0x04001140U, 0x84001140U, 0x04401140U, 0x84401140U, + 0x00000104U, 0x80000104U, 0x00400104U, 0x80400104U, + 0x00001104U, 0x80001104U, 0x00401104U, 0x80401104U, + 0x00000144U, 0x80000144U, 0x00400144U, 0x80400144U, + 0x00001144U, 0x80001144U, 0x00401144U, 0x80401144U, + 0x04000104U, 0x84000104U, 0x04400104U, 0x84400104U, + 0x04001104U, 0x84001104U, 0x04401104U, 0x84401104U, + 0x04000144U, 0x84000144U, 0x04400144U, 0x84400144U, + 0x04001144U, 0x84001144U, 0x04401144U, 0x84401144U, + 0x00010100U, 0x80010100U, 0x00410100U, 0x80410100U, + 0x00011100U, 0x80011100U, 0x00411100U, 0x80411100U, + 0x00010140U, 0x80010140U, 0x00410140U, 0x80410140U, + 0x00011140U, 0x80011140U, 0x00411140U, 0x80411140U, + 0x04010100U, 0x84010100U, 0x04410100U, 0x84410100U, + 0x04011100U, 0x84011100U, 0x04411100U, 0x84411100U, + 0x04010140U, 0x84010140U, 0x04410140U, 0x84410140U, + 0x04011140U, 0x84011140U, 0x04411140U, 0x84411140U, + 0x00010104U, 0x80010104U, 0x00410104U, 0x80410104U, + 0x00011104U, 0x80011104U, 0x00411104U, 0x80411104U, + 0x00010144U, 0x80010144U, 0x00410144U, 0x80410144U, + 0x00011144U, 0x80011144U, 0x00411144U, 0x80411144U, + 0x04010104U, 0x84010104U, 0x04410104U, 0x84410104U, + 0x04011104U, 0x84011104U, 0x04411104U, 0x84411104U, + 0x04010144U, 0x84010144U, 0x04410144U, 0x84410144U, + 0x04011144U, 0x84011144U, 0x04411144U, 0x84411144U, + 0x00000000U, 0x00002000U, 0x00200000U, 0x00202000U, + 0x00000008U, 0x00002008U, 0x00200008U, 0x00202008U, + 0x10000000U, 0x10002000U, 0x10200000U, 0x10202000U, + 0x10000008U, 0x10002008U, 0x10200008U, 0x10202008U, + 0x20000000U, 0x20002000U, 0x20200000U, 0x20202000U, + 0x20000008U, 0x20002008U, 0x20200008U, 0x20202008U, + 0x30000000U, 0x30002000U, 0x30200000U, 0x30202000U, + 0x30000008U, 0x30002008U, 0x30200008U, 0x30202008U, + 0x00000080U, 0x00002080U, 0x00200080U, 0x00202080U, + 0x00000088U, 0x00002088U, 0x00200088U, 0x00202088U, + 0x10000080U, 0x10002080U, 0x10200080U, 0x10202080U, + 0x10000088U, 0x10002088U, 0x10200088U, 0x10202088U, + 0x20000080U, 0x20002080U, 0x20200080U, 0x20202080U, + 0x20000088U, 0x20002088U, 0x20200088U, 0x20202088U, + 0x30000080U, 0x30002080U, 0x30200080U, 0x30202080U, + 0x30000088U, 0x30002088U, 0x30200088U, 0x30202088U, + 0x00040000U, 0x00042000U, 0x00240000U, 0x00242000U, + 0x00040008U, 0x00042008U, 0x00240008U, 0x00242008U, + 0x10040000U, 0x10042000U, 0x10240000U, 0x10242000U, + 0x10040008U, 0x10042008U, 0x10240008U, 0x10242008U, + 0x20040000U, 0x20042000U, 0x20240000U, 0x20242000U, + 0x20040008U, 0x20042008U, 0x20240008U, 0x20242008U, + 0x30040000U, 0x30042000U, 0x30240000U, 0x30242000U, + 0x30040008U, 0x30042008U, 0x30240008U, 0x30242008U, + 0x00040080U, 0x00042080U, 0x00240080U, 0x00242080U, + 0x00040088U, 0x00042088U, 0x00240088U, 0x00242088U, + 0x10040080U, 0x10042080U, 0x10240080U, 0x10242080U, + 0x10040088U, 0x10042088U, 0x10240088U, 0x10242088U, + 0x20040080U, 0x20042080U, 0x20240080U, 0x20242080U, + 0x20040088U, 0x20042088U, 0x20240088U, 0x20242088U, + 0x30040080U, 0x30042080U, 0x30240080U, 0x30242080U, + 0x30040088U, 0x30042088U, 0x30240088U, 0x30242088U, + 0x01000000U, 0x01002000U, 0x01200000U, 0x01202000U, + 0x01000008U, 0x01002008U, 0x01200008U, 0x01202008U, + 0x11000000U, 0x11002000U, 0x11200000U, 0x11202000U, + 0x11000008U, 0x11002008U, 0x11200008U, 0x11202008U, + 0x21000000U, 0x21002000U, 0x21200000U, 0x21202000U, + 0x21000008U, 0x21002008U, 0x21200008U, 0x21202008U, + 0x31000000U, 0x31002000U, 0x31200000U, 0x31202000U, + 0x31000008U, 0x31002008U, 0x31200008U, 0x31202008U, + 0x01000080U, 0x01002080U, 0x01200080U, 0x01202080U, + 0x01000088U, 0x01002088U, 0x01200088U, 0x01202088U, + 0x11000080U, 0x11002080U, 0x11200080U, 0x11202080U, + 0x11000088U, 0x11002088U, 0x11200088U, 0x11202088U, + 0x21000080U, 0x21002080U, 0x21200080U, 0x21202080U, + 0x21000088U, 0x21002088U, 0x21200088U, 0x21202088U, + 0x31000080U, 0x31002080U, 0x31200080U, 0x31202080U, + 0x31000088U, 0x31002088U, 0x31200088U, 0x31202088U, + 0x01040000U, 0x01042000U, 0x01240000U, 0x01242000U, + 0x01040008U, 0x01042008U, 0x01240008U, 0x01242008U, + 0x11040000U, 0x11042000U, 0x11240000U, 0x11242000U, + 0x11040008U, 0x11042008U, 0x11240008U, 0x11242008U, + 0x21040000U, 0x21042000U, 0x21240000U, 0x21242000U, + 0x21040008U, 0x21042008U, 0x21240008U, 0x21242008U, + 0x31040000U, 0x31042000U, 0x31240000U, 0x31242000U, + 0x31040008U, 0x31042008U, 0x31240008U, 0x31242008U, + 0x01040080U, 0x01042080U, 0x01240080U, 0x01242080U, + 0x01040088U, 0x01042088U, 0x01240088U, 0x01242088U, + 0x11040080U, 0x11042080U, 0x11240080U, 0x11242080U, + 0x11040088U, 0x11042088U, 0x11240088U, 0x11242088U, + 0x21040080U, 0x21042080U, 0x21240080U, 0x21242080U, + 0x21040088U, 0x21042088U, 0x21240088U, 0x21242088U, + 0x31040080U, 0x31042080U, 0x31240080U, 0x31242080U, + 0x31040088U, 0x31042088U, 0x31240088U, 0x31242088U, + 0x00000000U, 0x00000800U, 0x00020000U, 0x00020800U, + 0x00000020U, 0x00000820U, 0x00020020U, 0x00020820U, + 0x08000000U, 0x08000800U, 0x08020000U, 0x08020800U, + 0x08000020U, 0x08000820U, 0x08020020U, 0x08020820U, + 0x02000000U, 0x02000800U, 0x02020000U, 0x02020800U, + 0x02000020U, 0x02000820U, 0x02020020U, 0x02020820U, + 0x0a000000U, 0x0a000800U, 0x0a020000U, 0x0a020800U, + 0x0a000020U, 0x0a000820U, 0x0a020020U, 0x0a020820U, + 0x00000400U, 0x00000c00U, 0x00020400U, 0x00020c00U, + 0x00000420U, 0x00000c20U, 0x00020420U, 0x00020c20U, + 0x08000400U, 0x08000c00U, 0x08020400U, 0x08020c00U, + 0x08000420U, 0x08000c20U, 0x08020420U, 0x08020c20U, + 0x02000400U, 0x02000c00U, 0x02020400U, 0x02020c00U, + 0x02000420U, 0x02000c20U, 0x02020420U, 0x02020c20U, + 0x0a000400U, 0x0a000c00U, 0x0a020400U, 0x0a020c00U, + 0x0a000420U, 0x0a000c20U, 0x0a020420U, 0x0a020c20U, + 0x00100000U, 0x00100800U, 0x00120000U, 0x00120800U, + 0x00100020U, 0x00100820U, 0x00120020U, 0x00120820U, + 0x08100000U, 0x08100800U, 0x08120000U, 0x08120800U, + 0x08100020U, 0x08100820U, 0x08120020U, 0x08120820U, + 0x02100000U, 0x02100800U, 0x02120000U, 0x02120800U, + 0x02100020U, 0x02100820U, 0x02120020U, 0x02120820U, + 0x0a100000U, 0x0a100800U, 0x0a120000U, 0x0a120800U, + 0x0a100020U, 0x0a100820U, 0x0a120020U, 0x0a120820U, + 0x00100400U, 0x00100c00U, 0x00120400U, 0x00120c00U, + 0x00100420U, 0x00100c20U, 0x00120420U, 0x00120c20U, + 0x08100400U, 0x08100c00U, 0x08120400U, 0x08120c00U, + 0x08100420U, 0x08100c20U, 0x08120420U, 0x08120c20U, + 0x02100400U, 0x02100c00U, 0x02120400U, 0x02120c00U, + 0x02100420U, 0x02100c20U, 0x02120420U, 0x02120c20U, + 0x0a100400U, 0x0a100c00U, 0x0a120400U, 0x0a120c00U, + 0x0a100420U, 0x0a100c20U, 0x0a120420U, 0x0a120c20U, + 0x00000001U, 0x00000801U, 0x00020001U, 0x00020801U, + 0x00000021U, 0x00000821U, 0x00020021U, 0x00020821U, + 0x08000001U, 0x08000801U, 0x08020001U, 0x08020801U, + 0x08000021U, 0x08000821U, 0x08020021U, 0x08020821U, + 0x02000001U, 0x02000801U, 0x02020001U, 0x02020801U, + 0x02000021U, 0x02000821U, 0x02020021U, 0x02020821U, + 0x0a000001U, 0x0a000801U, 0x0a020001U, 0x0a020801U, + 0x0a000021U, 0x0a000821U, 0x0a020021U, 0x0a020821U, + 0x00000401U, 0x00000c01U, 0x00020401U, 0x00020c01U, + 0x00000421U, 0x00000c21U, 0x00020421U, 0x00020c21U, + 0x08000401U, 0x08000c01U, 0x08020401U, 0x08020c01U, + 0x08000421U, 0x08000c21U, 0x08020421U, 0x08020c21U, + 0x02000401U, 0x02000c01U, 0x02020401U, 0x02020c01U, + 0x02000421U, 0x02000c21U, 0x02020421U, 0x02020c21U, + 0x0a000401U, 0x0a000c01U, 0x0a020401U, 0x0a020c01U, + 0x0a000421U, 0x0a000c21U, 0x0a020421U, 0x0a020c21U, + 0x00100001U, 0x00100801U, 0x00120001U, 0x00120801U, + 0x00100021U, 0x00100821U, 0x00120021U, 0x00120821U, + 0x08100001U, 0x08100801U, 0x08120001U, 0x08120801U, + 0x08100021U, 0x08100821U, 0x08120021U, 0x08120821U, + 0x02100001U, 0x02100801U, 0x02120001U, 0x02120801U, + 0x02100021U, 0x02100821U, 0x02120021U, 0x02120821U, + 0x0a100001U, 0x0a100801U, 0x0a120001U, 0x0a120801U, + 0x0a100021U, 0x0a100821U, 0x0a120021U, 0x0a120821U, + 0x00100401U, 0x00100c01U, 0x00120401U, 0x00120c01U, + 0x00100421U, 0x00100c21U, 0x00120421U, 0x00120c21U, + 0x08100401U, 0x08100c01U, 0x08120401U, 0x08120c01U, + 0x08100421U, 0x08100c21U, 0x08120421U, 0x08120c21U, + 0x02100401U, 0x02100c01U, 0x02120401U, 0x02120c01U, + 0x02100421U, 0x02100c21U, 0x02120421U, 0x02120c21U, + 0x0a100401U, 0x0a100c01U, 0x0a120401U, 0x0a120c01U, + 0x0a100421U, 0x0a100c21U, 0x0a120421U, 0x0a120c21U, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DESDATA_H */ diff --git a/illumos-x86_64/usr/include/des/softdes.h b/illumos-x86_64/usr/include/des/softdes.h new file mode 100644 index 00000000..5f25bd30 --- /dev/null +++ b/illumos-x86_64/usr/include/des/softdes.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_SOFTDES_H +#define _SYS_SOFTDES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * softdes.h, Data types and definition for software DES + */ + +/* + * A chunk is an area of storage used in three different ways + * - As a 64 bit quantity (in high endian notation) + * - As a 48 bit quantity (6 low order bits per byte) + * - As a 32 bit quantity (first 4 bytes) + */ +typedef union { + struct { +/* + * This (and the one farther down) looks awfully backwards??? + */ +#ifdef _LONG_LONG_LTOH + uint32_t _long1; + uint32_t _long0; +#else + uint32_t _long0; + uint32_t _long1; +#endif + } _longs; + +#define long0 _longs._long0 +#define long1 _longs._long1 + struct { +#ifdef _LONG_LONG_LTOH + uchar_t _byte7; + uchar_t _byte6; + uchar_t _byte5; + uchar_t _byte4; + uchar_t _byte3; + uchar_t _byte2; + uchar_t _byte1; + uchar_t _byte0; +#else + uchar_t _byte0; + uchar_t _byte1; + uchar_t _byte2; + uchar_t _byte3; + uchar_t _byte4; + uchar_t _byte5; + uchar_t _byte6; + uchar_t _byte7; +#endif + } _bytes; +#define byte0 _bytes._byte0 +#define byte1 _bytes._byte1 +#define byte2 _bytes._byte2 +#define byte3 _bytes._byte3 +#define byte4 _bytes._byte4 +#define byte5 _bytes._byte5 +#define byte6 _bytes._byte6 +#define byte7 _bytes._byte7 +} chunk_t; + +/* + * Intermediate key storage + * Created by des_setkey, used by des_encrypt and des_decrypt + * 16 48 bit values + */ +struct deskeydata { + chunk_t keyval[16]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SOFTDES_H */ diff --git a/illumos-x86_64/usr/include/devfsadm.h b/illumos-x86_64/usr/include/devfsadm.h new file mode 100644 index 00000000..ae630496 --- /dev/null +++ b/illumos-x86_64/usr/include/devfsadm.h @@ -0,0 +1,257 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _DEVFSADM_H +#define _DEVFSADM_H + +#include +#include +#include +#include + +#undef DEBUG +#ifndef DEBUG +#define NDEBUG 1 +#else +#undef NDEBUG +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DEVFSADM_SUCCESS 0 +#define DEVFSADM_FAILURE -1 +#define DEVFSADM_MULTIPLE -2 +#define DEVFSADM_TRUE 0 +#define DEVFSADM_FALSE -1 + +#define ILEVEL_0 0 +#define ILEVEL_1 1 +#define ILEVEL_2 2 +#define ILEVEL_3 3 +#define ILEVEL_4 4 +#define ILEVEL_5 5 +#define ILEVEL_6 6 +#define ILEVEL_7 7 +#define ILEVEL_8 8 +#define ILEVEL_9 9 + +#define DEVFSADM_V0 0 +#define DEVFSADM_V1 1 + +#define DEVFSADM_CONTINUE 0 +#define DEVFSADM_TERMINATE 1 + +#define INTEGER 0 +#define CHARACTER 1 + +#define RM_HOT 0x01 +#define RM_PRE 0x02 +#define RM_POST 0x04 +#define RM_ALWAYS 0x08 +#define RM_NOINTERPOSE 0x10 + +#define TYPE_EXACT 0x01 +#define TYPE_RE 0x02 +#define TYPE_PARTIAL 0x04 +#define TYPE_MASK 0x07 +#define DRV_EXACT 0x10 +#define DRV_RE 0x20 +#define DRV_MASK 0x30 +#define CREATE_DEFER 0x100 +#define CREATE_MASK 0x100 + +/* command to start daemon */ +#define DEVFSADMD_START_PATH "/usr/lib/devfsadm/devfsadmd" +#define DEVFSADMD_START "devfsadmd" + +/* devfsadm event service door */ +#define DEVFSADM_SERVICE_DOOR "/etc/sysevent/devfsadm_event_channel" +#define DEVNAME_LOOKUP_DOOR ".devname_lookup_door" + +/* File of reserved devnames */ +#define ENUMERATE_RESERVED "/etc/dev/reserved_devnames" + +/* flags for devfsadm_mklink */ +#define DEV_SYNC 0x02 /* synchronous mklink */ + +#define INFO_MID NULL /* always prints */ +#define VERBOSE_MID "verbose" /* prints with -v */ +#define CHATTY_MID "chatty" /* prints with -V chatty */ + +typedef struct devfsadm_create { + char *device_class; /* eg "disk", "tape", "display" */ + char *node_type; /* eg DDI_NT_TAPE, DDI_NT_BLOCK, etc */ + char *drv_name; /* eg sd, ssd */ + int flags; /* TYPE_{EXACT,RE,PARTIAL}, DRV_{EXACT,RE} */ + int interpose_lvl; /* eg ILEVEL_0.. ILEVEL_10 */ + int (*callback_fcn)(di_minor_t minor, di_node_t node); +} devfsadm_create_t; + +typedef struct devfsadm_remove { + char *device_class; /* eg "disk", "tape", "display" */ + char *dev_dirs_re; /* dev dirs regex selector */ + int flags; /* eg POST, PRE, HOT, ALWAYS */ + int interpose_lvl; /* eg ILEVEL_0 .. ILEVEL_10 */ + void (*callback_fcn)(char *); +} devfsadm_remove_t; + +typedef struct devfsadm_remove_V1 { + char *device_class; /* eg "disk", "tape", "display" */ + char *dev_dirs_re; /* dev dirs regex selector */ + int flags; /* eg POST, PRE, HOT, ALWAYS */ + int interpose_lvl; /* eg ILEVEL_0 .. ILEVEL_10 */ + int (*callback_fcn)(char *); +} devfsadm_remove_V1_t; + +typedef struct _devfsadm_create_reg { + uint_t version; + uint_t count; /* number of node type registration */ + /* structures */ + devfsadm_create_t *tblp; +} _devfsadm_create_reg_t; + +typedef struct _devfsadm_remove_reg { + uint_t version; + uint_t count; /* number of node type registration */ + /* structures */ + devfsadm_remove_t *tblp; +} _devfsadm_remove_reg_t; + +typedef struct _devfsadm_remove_reg_V1 { + uint_t version; + uint_t count; /* number of node type registration */ + /* structures */ + devfsadm_remove_V1_t *tblp; +} _devfsadm_remove_reg_V1_t; +/* + * "flags" in the devfs_enumerate structure can take the following values. + * These values specify the substring of devfs path to be used for + * enumeration. Components (see MATCH_ADDR/MATCH_MINOR) may be specified + * by using the "match_arg" member in the devfsadm_enumerate structure. + */ +#define MATCH_ALL 0x001 /* Match entire devfs path */ +#define MATCH_PARENT 0x002 /* Match upto last '/' in devfs path */ +#define MATCH_ADDR 0x004 /* Match upto nth component of last address */ +#define MATCH_MINOR 0x008 /* Match upto nth component of minor name */ +#define MATCH_CALLBACK 0x010 /* Use callback to derive match string */ + +/* + * The following flags are private to devfsadm and the disks module. + * NOT to be used by other modules. + */ +#define MATCH_NODE 0x020 +#define MATCH_MASK 0x03F +#define MATCH_UNCACHED 0x040 /* retry flags for disks module */ + +typedef struct devfsadm_enumerate { + char *re; + int subexp; + uint_t flags; + char *match_arg; + char *(*sel_fcn)(const char *path, void *cb_arg); + void *cb_arg; +} devfsadm_enumerate_t; + +#define DEVFSADM_CREATE_INIT_V0(tbl) \ + _devfsadm_create_reg_t _devfsadm_create_reg = { \ + DEVFSADM_V0, \ + (sizeof (tbl) / sizeof (devfsadm_create_t)), \ + ((devfsadm_create_t *)(tbl)) } + +#define DEVFSADM_REMOVE_INIT_V0(tbl)\ + _devfsadm_remove_reg_t _devfsadm_remove_reg = {\ + DEVFSADM_V0, \ + (sizeof (tbl) / sizeof (devfsadm_remove_t)), \ + ((devfsadm_remove_t *)(tbl)) } + +#define DEVFSADM_REMOVE_INIT_V1(tbl)\ + _devfsadm_remove_reg_V1_t _devfsadm_remove_reg = {\ + DEVFSADM_V1, \ + (sizeof (tbl) / sizeof (devfsadm_remove_V1_t)), \ + ((devfsadm_remove_V1_t *)(tbl)) } + +/* reserved devname support */ +typedef struct devlink_re { + char *d_re; + int d_subexp; + regex_t d_rcomp; + regmatch_t *d_pmatch; +} devlink_re_t; + +typedef struct enumerate_file { + char *er_file; + char *er_id; + struct enumerate_file *er_next; +} enumerate_file_t; + +int devfsadm_noupdate(void); +const char *devfsadm_root_path(void); +int devfsadm_link_valid(di_node_t anynode, char *link); +int devfsadm_mklink(char *link, di_node_t node, di_minor_t minor, int flags); +int devfsadm_secondary_link(char *link, char *primary_link, int flags); +void devfsadm_rm_link(char *file); +void devfsadm_rm_all(char *file); +void devfsadm_rm_stale_links(char *dir_re, char *valid_link, di_node_t node, + di_minor_t minor); +void devfsadm_errprint(char *message, ...); +void devfsadm_print(char *mid, char *message, ...); +int devfsadm_enumerate_int(char *devfs_path, int index, char **buf, + devfsadm_enumerate_t rules[], int nrules); +int devfsadm_enumerate_char(char *devfs_path, int index, char **buf, + devfsadm_enumerate_t rules[], int nrules); +char **devfsadm_lookup_dev_names(char *phys_path, char *re, int *lenp); +void devfsadm_free_dev_names(char **dev_names, int len); + +/* devlink cache related */ +di_devlink_handle_t devfsadm_devlink_cache(void); + +/* + * Private enumerate interface for controllers, disks, and sgen modules + */ +int ctrl_enumerate_int(char *devfs_path, int index, char **buf, + devfsadm_enumerate_t rules[], int nrules, + int multiple, boolean_t scsi_vhci); +/* + * Private interfaces for ports module (port_link.c). + */ +int devfsadm_enumerate_char_start(char *devfs_path, int index, + char **buf, devfsadm_enumerate_t rules[], int nrules, char *start); +int devfsadm_read_link(di_node_t node, char *link, char **devfs_path); +char *s_strdup(const char *ptr); + +/* Private interface between reserve subsystm and disks link generator */ +int devfsadm_have_reserved(void); +int devfsadm_is_reserved(devlink_re_t re_array[], char *devlink); +int devfsadm_reserve_id_cache(devlink_re_t re_array[], enumerate_file_t *head); + +#ifdef __cplusplus +} +#endif + +#endif /* _DEVFSADM_H */ diff --git a/illumos-x86_64/usr/include/device_info.h b/illumos-x86_64/usr/include/device_info.h new file mode 100644 index 00000000..62087d1b --- /dev/null +++ b/illumos-x86_64/usr/include/device_info.h @@ -0,0 +1,196 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * WARNING: + * The interfaces defined in this header file are for Sun private use only. + * The contents of this file are subject to change without notice in + * future releases. + */ + +#ifndef _DEVICE_INFO_H +#define _DEVICE_INFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* error return values */ +#define DEVFS_ERR -1 /* operation not successful */ +#define DEVFS_INVAL -2 /* invalid argument */ +#define DEVFS_NOMEM -3 /* out of memory */ +#define DEVFS_PERM -4 /* permission denied - not root */ +#define DEVFS_NOTSUP -5 /* operation not supported */ +#define DEVFS_LIMIT -6 /* exceeded maximum size of property value */ +#define DEVFS_NOTFOUND -7 /* request not found */ + +/* + * for devfs_set_boot_dev() + * default behavior is to translate the input logical device name + * to most compact prom name(i.e. a prom alias, if one exists) + * as possible. And to prepend the new entry to the existing + * list. + */ + +/* perform no translation on the input device path */ +#define BOOTDEV_LITERAL 0x1 +/* convert the input device path only a prom device path; not an alias */ +#define BOOTDEV_PROMDEV 0x2 +/* overwrite the existing entry in boot-device - default is to prepend */ +#define BOOTDEV_OVERWRITE 0x4 + +/* + * for devfs_get_prom_names() + * returns a list of prom names for a given logical device name. + * the list is sorted first in order of exact aliases, inexact alias + * matches (where an option override was needed), and finally the + * equivalent prom device path. Each sublist is sorted in collating + * order. + */ +#define BOOTDEV_NO_PROM_PATH 0x1 +#define BOOTDEV_NO_INEXACT_ALIAS 0x2 +#define BOOTDEV_NO_EXACT_ALIAS 0x4 + +/* for devfs_get_boot_dev() */ +struct boot_dev { + char *bootdev_element; /* an entry from the boot-device variable */ + char **bootdev_trans; /* 0 or more logical dev translations */ +}; + +/* for devfs_get_all_prom_names() */ +struct devfs_prom_path { + char *obp_path; + char **alias_list; + struct devfs_prom_path *next; +}; + +/* prototypes */ + +/* return the driver for a given device path */ +extern int devfs_path_to_drv(char *devfs_path, char *drv_buf); + +/* convert a logical or physical device name to the equivalent prom path */ +extern int devfs_dev_to_prom_name(char *, char *); + +/* return the driver name after resolving any aliases */ +extern char *devfs_resolve_aliases(char *drv); + +/* set the boot-device configuration variable */ +extern int devfs_bootdev_set_list(const char *, const uint_t); + +/* is the boot-device variable modifiable on this platform? */ +extern int devfs_bootdev_modifiable(void); + +/* + * retrieve the boot-device config variable and corresponding logical + * device names + */ +extern int devfs_bootdev_get_list(const char *, struct boot_dev ***); +/* + * free a list of bootdev structs + */ +extern void devfs_bootdev_free_list(struct boot_dev **); +/* + * given a logical device name, return a list of equivalent + * prom names (aliases and device paths) + */ +extern int devfs_get_prom_names(const char *, uint_t, char ***); +/* + * like devfs_get_prom_names(), but deals with 1 to many mappings + * introduced by mpxio devices + */ +extern int devfs_get_all_prom_names(const char *, uint_t, + struct devfs_prom_path **); +/* + * free a list of devfs_prom_path structures + */ +extern void devfs_free_all_prom_names(struct devfs_prom_path *); + +/* + * Interpret a /dev link to its /devices path (does not require path to + * still exist, as long as the links exist) + */ +extern int devfs_resolve_link(char *, char **); + +/* + * map a device name from install OS environment to target OS environment or + * vice-versa. + */ +extern int devfs_target2install(const char *, const char *, char *, size_t); +extern int devfs_install2target(const char *, const char *, char *, size_t); + +/* + * Minor perm parsing library support for devfsadm, add_drv etc. + */ +#define MINOR_PERM_FILE "/etc/minor_perm" +#define MAX_MINOR_PERM_LINE 256 +#define DEFAULT_DEV_USER "root" +#define DEFAULT_DEV_GROUP "sys" + +/* + * Possible errors the callers of devfs_read_minor_perm() need + * to be prepared to deal with via callback. + */ +typedef enum { + MP_FOPEN_ERR, + MP_FCLOSE_ERR, + MP_IGNORING_LINE_ERR, + MP_ALLOC_ERR, + MP_NVLIST_ERR, + MP_CANT_FIND_USER_ERR, + MP_CANT_FIND_GROUP_ERR +} minorperm_err_t; + + +/* + * Create/free mperm list of minor perm entries + */ +extern struct mperm *devfs_read_minor_perm(void (*)(minorperm_err_t, int)); +extern void devfs_free_minor_perm(struct mperm *); + +/* + * Load all minor perm entries, and add/remove minor perm entry + */ +extern int devfs_load_minor_perm(struct mperm *, + void (*)(minorperm_err_t, int)); +extern int devfs_add_minor_perm(char *, void (*)(minorperm_err_t, int)); +extern int devfs_rm_minor_perm(char *, void (*)(minorperm_err_t, int)); + +/* devfsadm dca_flags values: some are used by libdevinfo devlink_create() */ +#define DCA_CREATE_LINK 0x000000001 +#define DCA_FREE_LIST 0x000000002 +#define DCA_LOAD_DRV 0x000000004 +#define DCA_CHECK_TYPE 0x000000010 +/* UNUSED was DCA_NOTIFY_RCM 0x000000020 (can be recycled) */ +#define DCA_FLUSH_PATHINST 0x000000040 +#define DCA_HOT_PLUG 0x000000080 +#define DCA_DEVLINK_SYNC 0x000000100 +#define DCA_DEVLINK_CACHE 0x000000200 + +#ifdef __cplusplus +} +#endif + +#endif /* _DEVICE_INFO_H */ diff --git a/illumos-x86_64/usr/include/devid.h b/illumos-x86_64/usr/include/devid.h new file mode 100644 index 00000000..e876c6bc --- /dev/null +++ b/illumos-x86_64/usr/include/devid.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Nexenta Systems, Inc. + */ + +#ifndef _DEVID_H +#define _DEVID_H + +#ifndef _KERNEL +#include +#endif /* _KERNEL */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct devid_nmlist { + char *devname; + dev_t dev; +} devid_nmlist_t; + +extern int devid_get(int fd, ddi_devid_t *retdevid); +extern void devid_free(ddi_devid_t devid); +extern int devid_get_minor_name(int fd, char **retminor_name); +extern size_t devid_sizeof(ddi_devid_t devid); +extern int devid_compare(ddi_devid_t devid1, ddi_devid_t devid2); +extern int devid_deviceid_to_nmlist(char *search_path, ddi_devid_t devid, + char *minor_name, devid_nmlist_t **retlist); +extern void devid_free_nmlist(devid_nmlist_t *list); +extern int devid_valid(ddi_devid_t devid); +extern char *devid_str_encode(ddi_devid_t devid, char *minor_name); +extern int devid_str_decode(char *devidstr, + ddi_devid_t *retdevid, char **retminor_name); +extern void devid_str_free(char *devidstr); +extern char *devid_str_from_path(const char *path); + +#ifdef __cplusplus +} +#endif + +#endif /* _DEVID_H */ diff --git a/illumos-x86_64/usr/include/devmgmt.h b/illumos-x86_64/usr/include/devmgmt.h new file mode 100644 index 00000000..4c37c216 --- /dev/null +++ b/illumos-x86_64/usr/include/devmgmt.h @@ -0,0 +1,176 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _DEVMGMT_H +#define _DEVMGMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * devmgmt.h + * + * Contents: + * - Device Management definitions, + * - getvol() definitions + */ + +/* + * Device management definitions + * - Default pathnames (relative to installation point) + * - Environment variable namess + * - Standard field names in the device table + * - Flags + * - Miscellaneous definitions + */ + + +/* + * Default pathnames (relative to the package installation + * point) to the files used by Device Management: + * + * DTAB_PATH Device table + * DGRP_PATH Device group table + * DVLK_PATH Device reservation table + */ + +#define DTAB_PATH "/etc/device.tab" +#define DGRP_PATH "/etc/dgroup.tab" +#define DVLK_PATH "/etc/devlkfile" + + +/* + * Names of environment variables + * + * OAM_DEVTAB Name of variable that defines the pathname to + * the device-table file + * OAM_DGROUP Name of variable that defines the pathname to + * the device-group table file + * OAM_DEVLKTAB Name of variable that defines the pathname to + * the device-reservation table file + */ + +#define OAM_DEVTAB "OAM_DEVTAB" +#define OAM_DGROUP "OAM_DGROUP" +#define OAM_DEVLKTAB "OAM_DEVLKTAB" + + +/* + * Standard field names in the device table + */ + +#define DTAB_ALIAS "alias" +#define DTAB_CDEVICE "cdevice" +#define DTAB_BDEVICE "bdevice" +#define DTAB_PATHNAME "pathname" + + +/* + * Flags: + * For getdev() and getdgrp(): + * DTAB_ANDCRITERIA Devices must meet all criteria + * instead of any of the criteria + * DTAB_EXCLUDEFLAG The list of devices or device groups + * is the list that is to be excluded, + * not those to select from. + * DTAB_LISTALL List all device groups, even those that + * have no valid members (getdgrp() only). + */ + +#define DTAB_ANDCRITERIA 0x01 +#define DTAB_EXCLUDEFLAG 0x02 +#define DTAB_LISTALL 0x04 + + +/* + * Miscellaneous Definitions + * + * DTAB_MXALIASLN Maximum alias length + */ + +#define DTAB_MXALIASLN 14 + +/* + * Device Management Structure definitions + * reservdev Reserved device description + */ + +/* + * struct reservdev + * + * Structure describes a reserved device. + * + * Elements: + * char *devname Alias of the reserved device + * pid_t key Key used to reserve the device + */ + +struct reservdev { + char *devname; + pid_t key; +}; + +/* + * Device Management Functions: + * + * devattr() Returns a device's attribute + * devreserv() Reserves a device + * devfree() Frees a reserved device + * reservdev() Return list of reserved devices + * getdev() Get devices that match criteria + * getdgrp() Get device-groups containing devices + * that match criteria + * listdev() List attributes defined for a device + * listdgrp() List members of a device-group + */ + + char *devattr(char *, char *); + int devfree(int, char *); + char **devreserv(int, char ***); + char **getdev(char **, char **, int); + char **getdgrp(char **, char **, int); + char **listdev(char *); + char **listdgrp(char *); + struct reservdev **reservdev(void); + +/* + * getvol() definitions + */ + +#define DM_BATCH 0x0001 +#define DM_ELABEL 0x0002 +#define DM_FORMAT 0x0004 +#define DM_FORMFS 0x0008 +#define DM_WLABEL 0x0010 +#define DM_OLABEL 0x0020 + + int getvol(char *, char *, int, char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _DEVMGMT_H */ diff --git a/illumos-x86_64/usr/include/devpoll.h b/illumos-x86_64/usr/include/devpoll.h new file mode 100644 index 00000000..f3cac790 --- /dev/null +++ b/illumos-x86_64/usr/include/devpoll.h @@ -0,0 +1,32 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _DEVPOLL_H +#define _DEVPOLL_H + +#include + +#endif /* _DEVPOLL_H */ diff --git a/illumos-x86_64/usr/include/diagnostics.h b/illumos-x86_64/usr/include/diagnostics.h new file mode 100644 index 00000000..acf5f50d --- /dev/null +++ b/illumos-x86_64/usr/include/diagnostics.h @@ -0,0 +1,157 @@ +/* Copyright (C) 2017-2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef DIAGNOSTICS_H +#define DIAGNOSTICS_H + +/* If at all possible, fix the source rather than using these macros + to silence warnings. If you do use these macros be aware that + you'll need to condition their use on particular compiler versions, + which can be done for gcc using ansidecl.h's GCC_VERSION macro. + + gcc versions between 4.2 and 4.6 do not allow pragma control of + diagnostics inside functions, giving a hard error if you try to use + the finer control available with later versions. + gcc prior to 4.2 warns about diagnostic push and pop. + + The other macros have restrictions too, for example gcc-5, gcc-6 + and gcc-7 warn that -Wstringop-truncation is unknown, unless you + also add DIAGNOSTIC_IGNORE ("-Wpragma"). */ + +#ifdef __GNUC__ +# define DIAGNOSTIC_PUSH _Pragma ("GCC diagnostic push") +# define DIAGNOSTIC_POP _Pragma ("GCC diagnostic pop") + +/* Stringification. */ +# define DIAGNOSTIC_STRINGIFY_1(x) #x +# define DIAGNOSTIC_STRINGIFY(x) DIAGNOSTIC_STRINGIFY_1 (x) + +# define DIAGNOSTIC_IGNORE(option) \ + _Pragma (DIAGNOSTIC_STRINGIFY (GCC diagnostic ignored option)) +# define DIAGNOSTIC_ERROR(option) \ + _Pragma (DIAGNOSTIC_STRINGIFY (GCC diagnostic error option)) +#else +# define DIAGNOSTIC_PUSH +# define DIAGNOSTIC_POP +# define DIAGNOSTIC_IGNORE(option) +#endif + +#if defined (__clang__) /* clang */ + +# define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move") +# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \ + DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations") +# define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister") + +# if __has_warning ("-Wenum-compare-switch") +# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES \ + DIAGNOSTIC_IGNORE ("-Wenum-compare-switch") +# endif + +# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ + DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") + +# if __has_warning ("-Wuser-defined-warnings") +# define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS \ + DIAGNOSTIC_IGNORE ("-Wuser-defined-warnings") +# endif + +# if __has_warning ("-Wunused-but-set-variable") +# define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE \ + DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable") +# endif + +# define DIAGNOSTIC_ERROR_SWITCH \ + DIAGNOSTIC_ERROR ("-Wswitch") + +#elif defined (__GNUC__) /* GCC */ + +# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \ + DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations") + +# if __GNUC__ >= 7 +# define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister") +# endif + +# define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \ + DIAGNOSTIC_IGNORE ("-Wstringop-truncation") + +# if __GNUC__ >= 11 +# define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD \ + DIAGNOSTIC_IGNORE ("-Wstringop-overread") +#endif + +# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ + DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") + +# if __GNUC__ >= 5 +# define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE \ + DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable") +# endif + +# if __GNUC__ >= 13 +# define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move") +# endif + +/* GCC 4.8's "diagnostic push/pop" seems broken when using this, -Wswitch + remains enabled at the error level even after a pop. Therefore, don't + use it for GCC < 5. */ +# if __GNUC__ >= 5 +# define DIAGNOSTIC_ERROR_SWITCH DIAGNOSTIC_ERROR ("-Wswitch") +# endif + +#endif + +#ifndef DIAGNOSTIC_IGNORE_SELF_MOVE +# define DIAGNOSTIC_IGNORE_SELF_MOVE +#endif + +#ifndef DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS +# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS +#endif + +#ifndef DIAGNOSTIC_IGNORE_REGISTER +# define DIAGNOSTIC_IGNORE_REGISTER +#endif + +#ifndef DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES +# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES +#endif + +#ifndef DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION +# define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION +#endif + +#ifndef DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD +# define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD +#endif + +#ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL +# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL +#endif + +#ifndef DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS +# define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS +#endif + +#ifndef DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE +# define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE +#endif + +#ifndef DIAGNOSTIC_ERROR_SWITCH +# define DIAGNOSTIC_ERROR_SWITCH +#endif + +#endif /* DIAGNOSTICS_H */ diff --git a/illumos-x86_64/usr/include/dial.h b/illumos-x86_64/usr/include/dial.h new file mode 100644 index 00000000..fc5c2bab --- /dev/null +++ b/illumos-x86_64/usr/include/dial.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _DIAL_H +#define _DIAL_H + +#ifndef IUCLC +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* uucico routines need these */ +#define DIAL + +/* The following are no longer used by dial() and may be out of date. */ +/* They are included here only to maintain source compatibility. */ +#define STANDALONE +#define DEVDIR "/dev/" /* device path */ +#define LOCK "/usr/spool/uucp/LCK.." /* lock file semaphore */ +#define DVC_LEN 80 /* max NO of chars in TTY-device path name */ +/* End of unused definitions */ + + /* error mnemonics */ + +#define TRUE 1 +#define FALSE 0 +#define INTRPT (-1) /* interrupt occured */ +#define D_HUNG (-2) /* dialer hung (no return from write) */ +#define NO_ANS (-3) /* no answer (caller script failed) */ +#define ILL_BD (-4) /* illegal baud-rate */ +#define A_PROB (-5) /* acu problem (open() failure) */ +#define L_PROB (-6) /* line problem (open() failure) */ +#define NO_Ldv (-7) /* can't open Devices file */ +#define DV_NT_A (-8) /* requested device not available */ +#define DV_NT_K (-9) /* requested device not known */ +#define NO_BD_A (-10) /* no device available at requested baud */ +#define NO_BD_K (-11) /* no device known at requested baud */ +#define DV_NT_E (-12) /* requested speed does not match */ +#define BAD_SYS (-13) /* system not in Systems file */ + +typedef struct { + struct termio *attr; /* ptr to termio attribute struct */ + int baud; /* unused */ + int speed; /* 212A modem: low=300, high=1200 */ + char *line; /* device name for out-going line */ + char *telno; /* ptr to tel-no/system name string */ + int modem; /* unused */ + char *device; /* unused */ + int dev_len; /* unused */ +} CALL; + +extern int dial(CALL); +extern void undial(int); + +#ifdef __cplusplus +} +#endif + +#endif /* _DIAL_H */ diff --git a/illumos-x86_64/usr/include/dirent.h b/illumos-x86_64/usr/include/dirent.h new file mode 100644 index 00000000..7fa0111b --- /dev/null +++ b/illumos-x86_64/usr/include/dirent.h @@ -0,0 +1,224 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _DIRENT_H +#define _DIRENT_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) + +#define MAXNAMLEN 512 /* maximum filename length */ +#define DIRBUF 8192 /* buffer size for fs-indep. dirs */ + +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */ + +#if !defined(__XOPEN_OR_POSIX) + +typedef struct { + int dd_fd; /* file descriptor */ + int dd_loc; /* offset in block */ + int dd_size; /* amount of valid data */ + char *dd_buf; /* directory block */ +} DIR; /* stream data from opendir() */ + + +#else + +typedef struct { + int d_fd; /* file descriptor */ + int d_loc; /* offset in block */ + int d_size; /* amount of valid data */ + char *d_buf; /* directory block */ +} DIR; /* stream data from opendir() */ + +#endif /* !defined(__XOPEN_OR_POSIX) */ + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname readdir readdir64 +#pragma redefine_extname scandir scandir64 +#pragma redefine_extname alphasort alphasort64 +#else +#define readdir readdir64 +#define scandir scandir64 +#define alphasort alphasort64 +#endif +#endif /* _FILE_OFFSET_BITS == 64 */ + +/* In the LP64 compilation environment, all APIs are already large file */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname readdir64 readdir +#pragma redefine_extname scandir64 scandir +#pragma redefine_extname alphasort64 alphasort +#else +#define readdir64 readdir +#define scandir64 scandir +#define alphsort64 alphasort +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern DIR *opendir(const char *); +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ + defined(_ATFILE_SOURCE) +extern DIR *fdopendir(int); +extern int dirfd(DIR *); +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +extern int scandir(const char *, struct dirent *(*[]), + int (*)(const struct dirent *), + int (*)(const struct dirent **, + const struct dirent **)); +extern int alphasort(const struct dirent **, + const struct dirent **); +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */ +extern struct dirent *readdir(DIR *); +#if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \ + defined(_XOPEN_SOURCE) +extern long telldir(DIR *); +extern void seekdir(DIR *, long); +#endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */ +extern void rewinddir(DIR *); +extern int closedir(DIR *); + +/* transitional large file interface */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern struct dirent64 *readdir64(DIR *); +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +extern int scandir64(const char *, struct dirent64 *(*[]), + int (*)(const struct dirent64 *), + int (*)(const struct dirent64 **, + const struct dirent64 **)); +extern int alphasort64(const struct dirent64 **, const struct dirent64 **); +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */ +#endif + +#if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \ + defined(_XOPEN_SOURCE) +#define rewinddir(dirp) seekdir(dirp, 0L) +#endif + +/* + * readdir_r() prototype is defined here. + * + * There are several variations, depending on whether compatibility with old + * POSIX draft specifications or the final specification is desired and on + * whether the large file compilation environment is active. To combat a + * combinatorial explosion, enabling large files implies using the final + * specification (since the definition of the large file environment + * considerably postdates that of the final readdir_r specification). + * + * In the LP64 compilation environment, all APIs are already large file, + * and since there are no 64-bit applications that can have seen the + * draft implementation, again, we use the final POSIX specification. + */ + +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ + !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \ + defined(_POSIX_PTHREAD_SEMANTICS) + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 32 + +#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname readdir_r __posix_readdir_r +extern int readdir_r(DIR *_RESTRICT_KYWD, struct dirent *_RESTRICT_KYWD, + struct dirent **_RESTRICT_KYWD); +#else /* __PRAGMA_REDEFINE_EXTNAME */ + +extern int __posix_readdir_r(DIR *_RESTRICT_KYWD, + struct dirent *_RESTRICT_KYWD, struct dirent **_RESTRICT_KYWD); + +#ifdef __lint +#define readdir_r __posix_readdir_r +#else /* !__lint */ + +static int +readdir_r(DIR *_RESTRICT_KYWD __dp, struct dirent *_RESTRICT_KYWD __ent, + struct dirent **_RESTRICT_KYWD __res) +{ + return (__posix_readdir_r(__dp, __ent, __res)); +} + +#endif /* !__lint */ +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +extern struct dirent *readdir_r(DIR *__dp, struct dirent *__ent); + +#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +#else /* !_LP64 && _FILE_OFFSET_BITS == 32 */ + +#if defined(_LP64) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname readdir64_r readdir_r +#else +#define readdir64_r readdir_r +#endif +#else /* _LP64 */ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname readdir_r readdir64_r +#else +#define readdir_r readdir64_r +#endif +#endif /* _LP64 */ +extern int readdir_r(DIR *_RESTRICT_KYWD, struct dirent *_RESTRICT_KYWD, + struct dirent **_RESTRICT_KYWD); + +#endif /* !_LP64 && _FILE_OFFSET_BITS == 32 */ + +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +/* transitional large file interface */ +extern int readdir64_r(DIR *_RESTRICT_KYWD, struct dirent64 *_RESTRICT_KYWD, + struct dirent64 **_RESTRICT_KYWD); +#endif + +#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DIRENT_H */ diff --git a/illumos-x86_64/usr/include/dis-asm.h b/illumos-x86_64/usr/include/dis-asm.h new file mode 100644 index 00000000..c3e01996 --- /dev/null +++ b/illumos-x86_64/usr/include/dis-asm.h @@ -0,0 +1,495 @@ +/* Interface between the opcode library and its callers. + + Copyright (C) 1999-2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, + Boston, MA 02110-1301, USA. + + Written by Cygnus Support, 1993. + + The opcode library (libopcodes.a) provides instruction decoders for + a large variety of instruction sets, callable with an identical + interface, for making instruction-processing programs more independent + of the instruction set being processed. */ + +#ifndef DIS_ASM_H +#define DIS_ASM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "bfd.h" + +enum dis_insn_type +{ + dis_noninsn, /* Not a valid instruction. */ + dis_nonbranch, /* Not a branch instruction. */ + dis_branch, /* Unconditional branch. */ + dis_condbranch, /* Conditional branch. */ + dis_jsr, /* Jump to subroutine. */ + dis_condjsr, /* Conditional jump to subroutine. */ + dis_dref, /* Data reference instruction. */ + dis_dref2 /* Two data references in instruction. */ +}; + +/* When printing styled disassembler output, this describes what style + should be used. */ + +enum disassembler_style +{ + /* This is the default style, use this for any additional syntax + (e.g. commas between operands, brackets, etc), or just as a default if + no other style seems appropriate. */ + dis_style_text, + + /* Use this for all instruction mnemonics, or aliases for mnemonics. + These should be things that correspond to real machine + instructions. */ + dis_style_mnemonic, + + /* Some architectures include additional mnemonic like fields within the + instruction operands, e.g. on aarch64 'add w16, w7, w1, lsl #2' where + the 'lsl' is an additional piece of text that describes how the + instruction should behave. This sub-mnemonic style can be used for + these pieces of text. */ + dis_style_sub_mnemonic, + + /* For things that aren't real machine instructions, but rather + assembler directives, e.g. .byte, etc. */ + dis_style_assembler_directive, + + /* Use this for any register names. This may or may-not include any + register prefix, e.g. '$', '%', at the discretion of the target, + though within each target the choice to include prefixes for not + should be kept consistent. If the prefix is not printed with this + style, then dis_style_text should be used. */ + dis_style_register, + + /* Use this for any constant values used within instructions or + directives, unless the value is an absolute address, or an offset + that will be added to an address (no matter where the address comes + from) before use. This style may, or may-not be used for any + prefix to the immediate value, e.g. '$', at the discretion of the + target, though within each target the choice to include these + prefixes should be kept consistent. */ + dis_style_immediate, + + /* The style for the numerical representation of an absolute address. + Anything that is an address offset should use the immediate style. + This style may, or may-not be used for any prefix to the immediate + value, e.g. '$', at the discretion of the target, though within + each target the choice to include these prefixes should be kept + consistent. */ + dis_style_address, + + /* The style for any constant value within an instruction or directive + that represents an offset that will be added to an address before + use. This style may, or may-not be used for any prefix to the + immediate value, e.g. '$', at the discretion of the target, though + within each target the choice to include these prefixes should be + kept consistent. */ + dis_style_address_offset, + + /* The style for a symbol's name. The numerical address of a symbol + should use the address style above, this style is reserved for the + name. */ + dis_style_symbol, + + /* The start of a comment that runs to the end of the line. Anything + printed after a comment start might be styled differently, + e.g. everything might be styled as a comment, regardless of the + actual style used. The disassembler itself should not try to adjust + the style emitted for comment content, e.g. an address emitted within + a comment should still be given dis_style_address, in this way it is + up to the user of the disassembler to decide how comments should be + styled. */ + dis_style_comment_start +}; + +typedef int (*fprintf_ftype) (void *, const char*, ...) ATTRIBUTE_FPTR_PRINTF_2; +typedef int (*fprintf_styled_ftype) (void *, enum disassembler_style, const char*, ...) ATTRIBUTE_FPTR_PRINTF_3; + +/* This struct is passed into the instruction decoding routine, + and is passed back out into each callback. The various fields are used + for conveying information from your main routine into your callbacks, + for passing information into the instruction decoders (such as the + addresses of the callback functions), or for passing information + back from the instruction decoders to their callers. + + It must be initialized before it is first passed; this can be done + by hand, or using one of the initialization macros below. */ + +typedef struct disassemble_info +{ + fprintf_ftype fprintf_func; + fprintf_styled_ftype fprintf_styled_func; + void *stream; + void *application_data; + + /* Target description. We could replace this with a pointer to the bfd, + but that would require one. There currently isn't any such requirement + so to avoid introducing one we record these explicitly. */ + /* The bfd_flavour. This can be bfd_target_unknown_flavour. */ + enum bfd_flavour flavour; + /* The bfd_arch value. */ + enum bfd_architecture arch; + /* The bfd_mach value. */ + unsigned long mach; + /* Endianness (for bi-endian cpus). Mono-endian cpus can ignore this. */ + enum bfd_endian endian; + /* Endianness of code, for mixed-endian situations such as ARM BE8. */ + enum bfd_endian endian_code; + + /* Some targets need information about the current section to accurately + display insns. If this is NULL, the target disassembler function + will have to make its best guess. */ + asection *section; + + /* An array of pointers to symbols either at the location being disassembled + or at the start of the function being disassembled. The array is sorted + so that the first symbol is intended to be the one used. The others are + present for any misc. purposes. This is not set reliably, but if it is + not NULL, it is correct. */ + asymbol **symbols; + /* Number of symbols in array. */ + int num_symbols; + + /* Symbol table provided for targets that want to look at it. This is + used on Arm to find mapping symbols and determine Arm/Thumb code. */ + asymbol **symtab; + int symtab_pos; + int symtab_size; + + /* For use by the disassembler. + The top 16 bits are reserved for public use (and are documented here). + The bottom 16 bits are for the internal use of the disassembler. */ + unsigned long flags; + /* Set if the disassembler has determined that there are one or more + relocations associated with the instruction being disassembled. */ +#define INSN_HAS_RELOC (1u << 31) + /* Set if the user has requested the disassembly of data as well as code. */ +#define DISASSEMBLE_DATA (1u << 30) + /* Set if the user has specifically set the machine type encoded in the + mach field of this structure. */ +#define USER_SPECIFIED_MACHINE_TYPE (1u << 29) + /* Set if the user has requested wide output. */ +#define WIDE_OUTPUT (1u << 28) + + /* Dynamic relocations, if they have been loaded. */ + arelent **dynrelbuf; + long dynrelcount; + + /* Use internally by the target specific disassembly code. */ + void *private_data; + + /* Function used to get bytes to disassemble. MEMADDR is the + address of the stuff to be disassembled, MYADDR is the address to + put the bytes in, and LENGTH is the number of bytes to read. + INFO is a pointer to this struct. + Returns an errno value or 0 for success. */ + int (*read_memory_func) + (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, + struct disassemble_info *dinfo); + + /* Function which should be called if we get an error that we can't + recover from. STATUS is the errno value from read_memory_func and + MEMADDR is the address that we were trying to read. INFO is a + pointer to this struct. */ + void (*memory_error_func) + (int status, bfd_vma memaddr, struct disassemble_info *dinfo); + + /* Function called to print ADDR. */ + void (*print_address_func) + (bfd_vma addr, struct disassemble_info *dinfo); + + /* Function called to determine if there is a symbol at the given ADDR. + If there is, the function returns 1, otherwise it returns 0. + This is used by ports which support an overlay manager where + the overlay number is held in the top part of an address. In + some circumstances we want to include the overlay number in the + address, (normally because there is a symbol associated with + that address), but sometimes we want to mask out the overlay bits. */ + asymbol * (*symbol_at_address_func) + (bfd_vma addr, struct disassemble_info *dinfo); + + /* Function called to check if a SYMBOL is can be displayed to the user. + This is used by some ports that want to hide special symbols when + displaying debugging outout. */ + bool (*symbol_is_valid) + (asymbol *, struct disassemble_info *dinfo); + + /* These are for buffer_read_memory. */ + bfd_byte *buffer; + bfd_vma buffer_vma; + size_t buffer_length; + + /* This variable may be set by the instruction decoder. It suggests + the number of bytes objdump should display on a single line. If + the instruction decoder sets this, it should always set it to + the same value in order to get reasonable looking output. */ + int bytes_per_line; + + /* The next two variables control the way objdump displays the raw data. */ + /* For example, if bytes_per_line is 8 and bytes_per_chunk is 4, the */ + /* output will look like this: + 00: 00000000 00000000 + with the chunks displayed according to "display_endian". */ + int bytes_per_chunk; + enum bfd_endian display_endian; + + /* Number of octets per incremented target address + Normally one, but some DSPs have byte sizes of 16 or 32 bits. */ + unsigned int octets_per_byte; + + /* The number of zeroes we want to see at the end of a section before we + start skipping them. */ + unsigned int skip_zeroes; + + /* The number of zeroes to skip at the end of a section. If the number + of zeroes at the end is between SKIP_ZEROES_AT_END and SKIP_ZEROES, + they will be disassembled. If there are fewer than + SKIP_ZEROES_AT_END, they will be skipped. This is a heuristic + attempt to avoid disassembling zeroes inserted by section + alignment. */ + unsigned int skip_zeroes_at_end; + + /* Whether the disassembler always needs the relocations. */ + bool disassembler_needs_relocs; + + /* Results from instruction decoders. Not all decoders yet support + this information. This info is set each time an instruction is + decoded, and is only valid for the last such instruction. + + To determine whether this decoder supports this information, set + insn_info_valid to 0, decode an instruction, then check it. */ + + char insn_info_valid; /* Branch info has been set. */ + char branch_delay_insns; /* How many sequential insn's will run before + a branch takes effect. (0 = normal) */ + char data_size; /* Size of data reference in insn, in bytes */ + enum dis_insn_type insn_type; /* Type of instruction */ + bfd_vma target; /* Target address of branch or dref, if known; + zero if unknown. */ + bfd_vma target2; /* Second target address for dref2 */ + + /* Command line options specific to the target disassembler. */ + const char *disassembler_options; + + /* If non-zero then try not disassemble beyond this address, even if + there are values left in the buffer. This address is the address + of the nearest symbol forwards from the start of the disassembly, + and it is assumed that it lies on the boundary between instructions. + If an instruction spans this address then this is an error in the + file being disassembled. */ + bfd_vma stop_vma; + + /* The end range of the current range being disassembled. This is required + in order to notify the disassembler when it's currently handling a + different range than it was before. This prevent unsafe optimizations when + disassembling such as the way mapping symbols are found on AArch64. */ + bfd_vma stop_offset; + + /* Set to true if the disassembler applied styling to the output, + otherwise, set to false. */ + bool created_styled_output; +} disassemble_info; + +/* This struct is used to pass information about valid disassembler + option arguments from the target to the generic GDB functions + that set and display them. */ + +typedef struct +{ + /* Option argument name to use in descriptions. */ + const char *name; + + /* Vector of acceptable option argument values, NULL-terminated. + NULL if any values are accepted. */ + const char **values; +} disasm_option_arg_t; + +/* This struct is used to pass information about valid disassembler + options, their descriptions and arguments from the target to the + generic GDB functions that set and display them. Options are + defined by tuples of vector entries at each index. */ + +typedef struct +{ + /* Vector of option names, NULL-terminated. */ + const char **name; + + /* Vector of option descriptions or NULL if none to be shown. */ + const char **description; + + /* Vector of option argument information pointers or NULL if no + option accepts an argument. NULL entries denote individual + options that accept no argument. */ + const disasm_option_arg_t **arg; +} disasm_options_t; + +/* This struct is used to pass information about valid disassembler + options and arguments from the target to the generic GDB functions + that set and display them. */ + +typedef struct +{ + /* Valid disassembler options. Individual options that support + an argument will refer to entries in the ARGS vector. */ + disasm_options_t options; + + /* Vector of acceptable option arguments, NULL-terminated. This + collects all possible option argument choices, some of which + may be shared by different options from the OPTIONS member. */ + disasm_option_arg_t *args; +} disasm_options_and_args_t; + +/* Standard disassemblers. Disassemble one instruction at the given + target address. Return number of octets processed. */ +typedef int (*disassembler_ftype) (bfd_vma, disassemble_info *); + +/* Disassemblers used out side of opcodes library. */ +extern int print_insn_m32c (bfd_vma, disassemble_info *); +extern int print_insn_mep (bfd_vma, disassemble_info *); +extern int print_insn_s12z (bfd_vma, disassemble_info *); +extern int print_insn_sh (bfd_vma, disassemble_info *); +extern int print_insn_sparc (bfd_vma, disassemble_info *); +extern int print_insn_rx (bfd_vma, disassemble_info *); +extern int print_insn_rl78 (bfd_vma, disassemble_info *); +extern int print_insn_rl78_g10 (bfd_vma, disassemble_info *); +extern int print_insn_rl78_g13 (bfd_vma, disassemble_info *); +extern int print_insn_rl78_g14 (bfd_vma, disassemble_info *); + +extern disassembler_ftype arc_get_disassembler (bfd *); +extern disassembler_ftype cris_get_disassembler (bfd *); + +extern void print_aarch64_disassembler_options (FILE *); +extern void print_i386_disassembler_options (FILE *); +extern void print_mips_disassembler_options (FILE *); +extern void print_nfp_disassembler_options (FILE *); +extern void print_ppc_disassembler_options (FILE *); +extern void print_riscv_disassembler_options (FILE *); +extern void print_arm_disassembler_options (FILE *); +extern void print_arc_disassembler_options (FILE *); +extern void print_kvx_disassembler_options(FILE *); +extern void print_s390_disassembler_options (FILE *); +extern void print_wasm32_disassembler_options (FILE *); +extern void print_loongarch_disassembler_options (FILE *); +extern void print_bpf_disassembler_options (FILE *); +extern bool aarch64_symbol_is_valid (asymbol *, struct disassemble_info *); +extern bool arm_symbol_is_valid (asymbol *, struct disassemble_info *); +extern bool csky_symbol_is_valid (asymbol *, struct disassemble_info *); +extern bool riscv_symbol_is_valid (asymbol *, struct disassemble_info *); +extern void disassemble_init_powerpc (struct disassemble_info *); +extern void disassemble_init_s390 (struct disassemble_info *); +extern void disassemble_init_wasm32 (struct disassemble_info *); +extern void disassemble_init_nds32 (struct disassemble_info *); +extern const disasm_options_and_args_t *disassembler_options_arc (void); +extern const disasm_options_and_args_t *disassembler_options_arm (void); +extern const disasm_options_and_args_t *disassembler_options_mips (void); +extern const disasm_options_and_args_t *disassembler_options_powerpc (void); +extern const disasm_options_and_args_t *disassembler_options_riscv (void); +extern const disasm_options_and_args_t *disassembler_options_s390 (void); + +/* Fetch the disassembler for a given architecture ARC, endianess (big + endian if BIG is true), bfd_mach value MACH, and ABFD, if that support + is available. ABFD may be NULL. */ +extern disassembler_ftype disassembler (enum bfd_architecture arc, + bool big, unsigned long mach, + bfd *abfd); + +/* Amend the disassemble_info structure as necessary for the target architecture. + Should only be called after initialising the info->arch field. */ +extern void disassemble_init_for_target (struct disassemble_info *); + +/* Tidy any memory allocated by targets, such as info->private_data. */ +extern void disassemble_free_target (struct disassemble_info *); + +/* Set the basic disassembler print functions. */ +extern void disassemble_set_printf (struct disassemble_info *, void *, + fprintf_ftype, fprintf_styled_ftype); + +/* Document any target specific options available from the disassembler. */ +extern void disassembler_usage (FILE *); + +/* Remove whitespace and consecutive commas. */ +extern char *remove_whitespace_and_extra_commas (char *); + +/* Like STRCMP, but treat ',' the same as '\0' so that we match + strings like "foobar" against "foobar,xxyyzz,...". */ +extern int disassembler_options_cmp (const char *, const char *); + +/* A helper function for FOR_EACH_DISASSEMBLER_OPTION. */ +static inline const char * +next_disassembler_option (const char *options) +{ + const char *opt = strchr (options, ','); + if (opt != NULL) + opt++; + return opt; +} + +/* A macro for iterating over each comma separated option in OPTIONS. */ +#define FOR_EACH_DISASSEMBLER_OPTION(OPT, OPTIONS) \ + for ((OPT) = (OPTIONS); \ + (OPT) != NULL; \ + (OPT) = next_disassembler_option (OPT)) + + +/* This block of definitions is for particular callers who read instructions + into a buffer before calling the instruction decoder. */ + +/* Here is a function which callers may wish to use for read_memory_func. + It gets bytes from a buffer. */ +extern int buffer_read_memory + (bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *); + +/* This function goes with buffer_read_memory. + It prints a message using info->fprintf_func and info->stream. */ +extern void perror_memory (int, bfd_vma, struct disassemble_info *); + + +/* Just print the address in hex. This is included for completeness even + though both GDB and objdump provide their own (to print symbolic + addresses). */ +extern void generic_print_address + (bfd_vma, struct disassemble_info *); + +/* Always NULL. */ +extern asymbol *generic_symbol_at_address + (bfd_vma, struct disassemble_info *); + +/* Always true. */ +extern bool generic_symbol_is_valid + (asymbol *, struct disassemble_info *); + +/* Method to initialize a disassemble_info struct. This should be + called by all applications creating such a struct. */ +extern void init_disassemble_info (struct disassemble_info *dinfo, void *stream, + fprintf_ftype fprintf_func, + fprintf_styled_ftype fprintf_styled_func); + +/* For compatibility with existing code. */ +#define INIT_DISASSEMBLE_INFO(INFO, STREAM, FPRINTF_FUNC, FPRINTF_STYLED_FUNC) \ + init_disassemble_info (&(INFO), (STREAM), (fprintf_ftype) (FPRINTF_FUNC), \ + (fprintf_styled_ftype) (FPRINTF_STYLED_FUNC)) + +#ifdef __cplusplus +} +#endif + +#endif /* ! defined (DIS_ASM_H) */ diff --git a/illumos-x86_64/usr/include/dlfcn.h b/illumos-x86_64/usr/include/dlfcn.h new file mode 100644 index 00000000..bc61ba06 --- /dev/null +++ b/illumos-x86_64/usr/include/dlfcn.h @@ -0,0 +1,236 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * + * Copyright (c) 1989 AT&T + * All Rights Reserved + * + */ + +#ifndef _DLFCN_H +#define _DLFCN_H + +#include +#include +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#include +#include +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Information structures for various dlinfo() requests. + */ +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +typedef struct dl_info { + const char *dli_fname; /* file containing address range */ + void *dli_fbase; /* base address of file image */ + const char *dli_sname; /* symbol name */ + void *dli_saddr; /* symbol address */ +} Dl_info; +typedef Dl_info Dl_info_t; + +typedef struct dl_serpath { + char *dls_name; /* library search path name */ + uint_t dls_flags; /* path information */ +} Dl_serpath; +typedef Dl_serpath Dl_serpath_t; + +typedef struct dl_serinfo { + size_t dls_size; /* total buffer size */ + uint_t dls_cnt; /* number of path entries */ + Dl_serpath dls_serpath[1]; /* there may be more than one */ +} Dl_serinfo; +typedef Dl_serinfo Dl_serinfo_t; + +typedef struct dl_argsinfo { + long dla_argc; /* process argument count */ + char **dla_argv; /* process arguments */ + char **dla_envp; /* process environment variables */ + auxv_t *dla_auxv; /* process auxv vectors */ +} Dl_argsinfo; +typedef Dl_argsinfo Dl_argsinfo_t; + +typedef struct { + mmapobj_result_t *dlm_maps; /* mapping information */ + uint_t dlm_acnt; /* number of dlm_maps mappings */ + uint_t dlm_rcnt; /* number of returned mappings */ +} Dl_mapinfo_t; + +typedef struct { + uint_t dlui_version; /* version # */ + uint_t dlui_flags; /* flags */ + char *dlui_objname; /* path to object */ + void *dlui_unwindstart; /* star of unwind hdr */ + void *dlui_unwindend; /* end of unwind hdr */ + void *dlui_segstart; /* start of segment described */ + /* by unwind block */ + void *dlui_segend; /* end of segment described */ + /* by unwind block */ +} Dl_amd64_unwindinfo; +typedef Dl_amd64_unwindinfo Dl_amd64_unwindinfo_t; + +typedef struct { + const char *dld_refname; /* reference name */ + const char *dld_depname; /* new dependency name */ +} Dl_definfo_t; + +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + + +typedef ulong_t Lmid_t; + +/* + * Declarations used for dynamic linking support routines. + */ +extern void *dlopen(const char *, int); +extern void *dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); +extern int dlclose(void *); +extern char *dlerror(void); +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +extern void *dlmopen(Lmid_t, const char *, int); +extern int dladdr(void *, Dl_info *); +extern int dladdr1(void *, Dl_info *, void **, int); +extern int dldump(const char *, const char *, int); +extern int dlinfo(void *, int, void *); +extern Dl_amd64_unwindinfo *dlamd64getunwind(void *, Dl_amd64_unwindinfo *); +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +#pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror) +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo) +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +/* + * Valid values for handle argument to dlsym(3C). + */ +#define RTLD_NEXT (void *)-1 /* look in `next' dependency */ +#define RTLD_DEFAULT (void *)-2 /* look up symbol from scope */ + /* of current object */ +#define RTLD_SELF (void *)-3 /* look in `ourself' */ +#define RTLD_PROBE (void *)-4 /* look up symbol from scope */ + /* of current object, */ + /* using currently */ + /* loaded objects only. */ +/* + * Valid values for mode argument to dlopen. + */ +#define RTLD_LAZY 0x00001 /* deferred function binding */ +#define RTLD_NOW 0x00002 /* immediate function binding */ +#define RTLD_NOLOAD 0x00004 /* don't load object */ + +#define RTLD_GLOBAL 0x00100 /* export symbols to others */ +#define RTLD_LOCAL 0x00000 /* symbols are only available */ + /* to group members */ +#define RTLD_PARENT 0x00200 /* add parent (caller) to */ + /* a group dependencies */ +#define RTLD_GROUP 0x00400 /* resolve symbols within */ + /* members of the group */ +#define RTLD_WORLD 0x00800 /* resolve symbols within */ + /* global objects */ +#define RTLD_NODELETE 0x01000 /* do not remove members */ +#define RTLD_FIRST 0x02000 /* only first object is */ + /* available for dlsym */ +#define RTLD_CONFGEN 0x10000 /* crle(1) config generation */ + /* internal use only */ + +/* + * Valid values for flag argument to dldump. + */ +#define RTLD_REL_RELATIVE 0x00001 /* apply relative relocs */ +#define RTLD_REL_EXEC 0x00002 /* apply symbolic relocs that */ + /* bind to main */ +#define RTLD_REL_DEPENDS 0x00004 /* apply symbolic relocs that */ + /* bind to dependencies */ +#define RTLD_REL_PRELOAD 0x00008 /* apply symbolic relocs that */ + /* bind to preload objs */ +#define RTLD_REL_SELF 0x00010 /* apply symbolic relocs that */ + /* bind to ourself */ +#define RTLD_REL_WEAK 0x00020 /* apply symbolic weak relocs */ + /* even if unresolved */ +#define RTLD_REL_ALL 0x00fff /* apply all relocs */ + +#define RTLD_MEMORY 0x01000 /* use memory sections */ +#define RTLD_STRIP 0x02000 /* retain allocable sections */ + /* only */ +#define RTLD_NOHEAP 0x04000 /* do no save any heap */ +#define RTLD_CONFSET 0x10000 /* crle(1) config generation */ + /* internal use only */ + +/* + * Valid values for dladdr1() flags. + */ +#define RTLD_DL_SYMENT 1 /* return symbol table entry */ +#define RTLD_DL_LINKMAP 2 /* return public link-map */ +#define RTLD_DL_MASK 0xffff + + +/* + * Arguments for dlinfo() + */ +#define RTLD_DI_LMID 1 /* obtain link-map id */ +#define RTLD_DI_LINKMAP 2 /* obtain link-map */ +#define RTLD_DI_CONFIGADDR 3 /* obtain config addr */ +#define RTLD_DI_SERINFO 4 /* obtain search path info or */ +#define RTLD_DI_SERINFOSIZE 5 /* associated info size */ +#define RTLD_DI_ORIGIN 6 /* obtain objects origin */ +#define RTLD_DI_PROFILENAME 7 /* obtain profile object name */ + /* internal use only */ +#define RTLD_DI_PROFILEOUT 8 /* obtain profile output name */ + /* internal use only */ +#define RTLD_DI_GETSIGNAL 9 /* get termination signal */ +#define RTLD_DI_SETSIGNAL 10 /* set termination signal */ +#define RTLD_DI_ARGSINFO 11 /* get process arguments */ + /* environment and auxv */ +#define RTLD_DI_MMAPS 12 /* obtain objects mappings or */ +#define RTLD_DI_MMAPCNT 13 /* mapping count */ +#define RTLD_DI_DEFERRED 14 /* assign new dependency to a */ + /* deferred dependency */ +#define RTLD_DI_DEFERRED_SYM 15 /* assign new dependency to a */ + /* deferred dependency */ + /* using a symbol name */ +#define RTLD_DI_MAX 15 + +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +/* + * Version information for Dl_amd64_unwindinfo.dlui_version + */ +#define DLUI_VERS_1 1 +#define DLUI_VERS_CURRENT DLUI_VERS_1 + +/* + * Valid flags for Dl_amd64_unwindinfo.dlfi_flags + */ +#define DLUI_FLG_NOUNWIND 0x0001 /* object has no Unwind info */ +#define DLUI_FLG_NOOBJ 0x0002 /* no object was found */ + /* matching the pc provided */ +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DLFCN_H */ diff --git a/illumos-x86_64/usr/include/dns_sd.h b/illumos-x86_64/usr/include/dns_sd.h new file mode 100644 index 00000000..690178ac --- /dev/null +++ b/illumos-x86_64/usr/include/dns_sd.h @@ -0,0 +1,2778 @@ +/* -*- Mode: C; tab-width: 4 -*- + * + * Copyright (c) 2003-2018 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +/*! @header DNS Service Discovery + * + * @discussion This section describes the functions, callbacks, and data structures + * that make up the DNS Service Discovery API. + * + * The DNS Service Discovery API is part of Bonjour, Apple's implementation + * of zero-configuration networking (ZEROCONF). + * + * Bonjour allows you to register a network service, such as a + * printer or file server, so that it can be found by name or browsed + * for by service type and domain. Using Bonjour, applications can + * discover what services are available on the network, along with + * all the information -- such as name, IP address, and port -- + * necessary to access a particular service. + * + * In effect, Bonjour combines the functions of a local DNS server and + * AppleTalk. Bonjour allows applications to provide user-friendly printer + * and server browsing, among other things, over standard IP networks. + * This behavior is a result of combining protocols such as multicast and + * DNS to add new functionality to the network (such as multicast DNS). + * + * Bonjour gives applications easy access to services over local IP + * networks without requiring the service or the application to support + * an AppleTalk or a Netbeui stack, and without requiring a DNS server + * for the local network. + */ + +/* _DNS_SD_H contains the API version number for this header file + * The API version defined in this header file symbol allows for compile-time + * checking, so that C code building with earlier versions of the header file + * can avoid compile errors trying to use functions that aren't even defined + * in those earlier versions. Similar checks may also be performed at run-time: + * => weak linking -- to avoid link failures if run with an earlier + * version of the library that's missing some desired symbol, or + * => DNSServiceGetProperty(DaemonVersion) -- to verify whether the running daemon + * ("system service" on Windows) meets some required minimum functionality level. + */ + +#ifndef _DNS_SD_H +#define _DNS_SD_H 13108001 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Set to 1 if libdispatch is supported + * Note: May also be set by project and/or Makefile + */ +#if defined(__APPLE__) +#define _DNS_SD_LIBDISPATCH 1 +#else +#define _DNS_SD_LIBDISPATCH 0 +#endif + +/* standard calling convention under Win32 is __stdcall */ +/* Note: When compiling Intel EFI (Extensible Firmware Interface) under MS Visual Studio, the */ +/* _WIN32 symbol is defined by the compiler even though it's NOT compiling code for Windows32 */ +#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64) +#define DNSSD_API __stdcall +#else +#define DNSSD_API +#endif + +#if (defined(__GNUC__) && (__GNUC__ >= 4)) +#define DNSSD_EXPORT __attribute__((visibility("default"))) +#else +#define DNSSD_EXPORT +#endif + +#if defined(_WIN32) +#include +typedef SOCKET dnssd_sock_t; +#else +typedef int dnssd_sock_t; +#endif + +/* stdint.h does not exist on FreeBSD 4.x; its types are defined in sys/types.h instead */ +#if defined(__FreeBSD__) && (__FreeBSD__ < 5) +#include + +/* Likewise, on Sun, standard integer types are in sys/types.h */ +#elif defined(__sun__) +#include + +/* EFI does not have stdint.h, or anything else equivalent */ +#elif defined(EFI32) || defined(EFI64) || defined(EFIX64) +#include "Tiano.h" +#if !defined(_STDINT_H_) +typedef UINT8 uint8_t; +typedef INT8 int8_t; +typedef UINT16 uint16_t; +typedef INT16 int16_t; +typedef UINT32 uint32_t; +typedef INT32 int32_t; +#endif +/* Windows has its own differences */ +#elif defined(_WIN32) +#include +#define _UNUSED +#ifndef _MSL_STDINT_H +typedef UINT8 uint8_t; +typedef INT8 int8_t; +typedef UINT16 uint16_t; +typedef INT16 int16_t; +typedef UINT32 uint32_t; +typedef INT32 int32_t; +#endif + +/* All other Posix platforms use stdint.h */ +#else +#include +#endif + +#if _DNS_SD_LIBDISPATCH +#include +#endif + +/* DNSServiceRef, DNSRecordRef + * + * Opaque internal data types. + * Note: client is responsible for serializing access to these structures if + * they are shared between concurrent threads. + */ + +typedef struct _DNSServiceRef_t *DNSServiceRef; +typedef struct _DNSRecordRef_t *DNSRecordRef; + +struct sockaddr; + +/*! @enum General flags + * Most DNS-SD API functions and callbacks include a DNSServiceFlags parameter. + * As a general rule, any given bit in the 32-bit flags field has a specific fixed meaning, + * regardless of the function or callback being used. For any given function or callback, + * typically only a subset of the possible flags are meaningful, and all others should be zero. + * The discussion section for each API call describes which flags are valid for that call + * and callback. In some cases, for a particular call, it may be that no flags are currently + * defined, in which case the DNSServiceFlags parameter exists purely to allow future expansion. + * In all cases, developers should expect that in future releases, it is possible that new flag + * values will be defined, and write code with this in mind. For example, code that tests + * if (flags == kDNSServiceFlagsAdd) ... + * will fail if, in a future release, another bit in the 32-bit flags field is also set. + * The reliable way to test whether a particular bit is set is not with an equality test, + * but with a bitwise mask: + * if (flags & kDNSServiceFlagsAdd) ... + * With the exception of kDNSServiceFlagsValidate, each flag can be valid(be set) + * EITHER only as an input to one of the DNSService*() APIs OR only as an output + * (provide status) through any of the callbacks used. For example, kDNSServiceFlagsAdd + * can be set only as an output in the callback, whereas the kDNSServiceFlagsIncludeP2P + * can be set only as an input to the DNSService*() APIs. See comments on kDNSServiceFlagsValidate + * defined in enum below. + */ +enum +{ + kDNSServiceFlagsMoreComing = 0x1, + /* MoreComing indicates to a callback that at least one more result is + * queued and will be delivered following immediately after this one. + * When the MoreComing flag is set, applications should not immediately + * update their UI, because this can result in a great deal of ugly flickering + * on the screen, and can waste a great deal of CPU time repeatedly updating + * the screen with content that is then immediately erased, over and over. + * Applications should wait until MoreComing is not set, and then + * update their UI when no more changes are imminent. + * When MoreComing is not set, that doesn't mean there will be no more + * answers EVER, just that there are no more answers immediately + * available right now at this instant. If more answers become available + * in the future they will be delivered as usual. + */ + + kDNSServiceFlagsAutoTrigger = 0x1, + /* Valid for browses using kDNSServiceInterfaceIndexAny. + * Will auto trigger the browse over AWDL as well once the service is discovered + * over BLE. + * This flag is an input value to DNSServiceBrowse(), which is why we can + * use the same value as kDNSServiceFlagsMoreComing, which is an output flag + * for various client callbacks. + */ + + kDNSServiceFlagsAdd = 0x2, + kDNSServiceFlagsDefault = 0x4, + /* Flags for domain enumeration and browse/query reply callbacks. + * "Default" applies only to enumeration and is only valid in + * conjunction with "Add". An enumeration callback with the "Add" + * flag NOT set indicates a "Remove", i.e. the domain is no longer + * valid. + */ + + kDNSServiceFlagsNoAutoRename = 0x8, + /* Flag for specifying renaming behavior on name conflict when registering + * non-shared records. By default, name conflicts are automatically handled + * by renaming the service. NoAutoRename overrides this behavior - with this + * flag set, name conflicts will result in a callback. The NoAutorename flag + * is only valid if a name is explicitly specified when registering a service + * (i.e. the default name is not used.) + */ + + kDNSServiceFlagsShared = 0x10, + kDNSServiceFlagsUnique = 0x20, + /* Flag for registering individual records on a connected + * DNSServiceRef. Shared indicates that there may be multiple records + * with this name on the network (e.g. PTR records). Unique indicates that the + * record's name is to be unique on the network (e.g. SRV records). + */ + + kDNSServiceFlagsBrowseDomains = 0x40, + kDNSServiceFlagsRegistrationDomains = 0x80, + /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomains. + * BrowseDomains enumerates domains recommended for browsing, RegistrationDomains + * enumerates domains recommended for registration. + */ + + kDNSServiceFlagsLongLivedQuery = 0x100, + /* Flag for creating a long-lived unicast query for the DNSServiceQueryRecord call. */ + + kDNSServiceFlagsAllowRemoteQuery = 0x200, + /* Flag for creating a record for which we will answer remote queries + * (queries from hosts more than one hop away; hosts not directly connected to the local link). + */ + + kDNSServiceFlagsForceMulticast = 0x400, + /* Flag for signifying that a query or registration should be performed exclusively via multicast + * DNS, even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS. + */ + + kDNSServiceFlagsForce = 0x800, // This flag is deprecated. + + kDNSServiceFlagsKnownUnique = 0x800, + /* + * Client guarantees that record names are unique, so we can skip sending out initial + * probe messages. Standard name conflict resolution is still done if a conflict is discovered. + */ + + kDNSServiceFlagsReturnIntermediates = 0x1000, + /* Flag for returning intermediate results. + * For example, if a query results in an authoritative NXDomain (name does not exist) + * then that result is returned to the client. However the query is not implicitly + * cancelled -- it remains active and if the answer subsequently changes + * (e.g. because a VPN tunnel is subsequently established) then that positive + * result will still be returned to the client. + * Similarly, if a query results in a CNAME record, then in addition to following + * the CNAME referral, the intermediate CNAME result is also returned to the client. + * When this flag is not set, NXDomain errors are not returned, and CNAME records + * are followed silently without informing the client of the intermediate steps. + * (In earlier builds this flag was briefly calledkDNSServiceFlagsReturnCNAME) + */ + + kDNSServiceFlagsShareConnection = 0x4000, + /* For efficiency, clients that perform many concurrent operations may want to use a + * single Unix Domain Socket connection with the background daemon, instead of having a + * separate connection for each independent operation. To use this mode, clients first + * call DNSServiceCreateConnection(&SharedRef) to initialize the main DNSServiceRef. + * For each subsequent operation that is to share that same connection, the client copies + * the SharedRef, and then passes the address of that copy, setting the ShareConnection flag + * to tell the library that this DNSServiceRef is not a typical uninitialized DNSServiceRef; + * it's a copy of an existing DNSServiceRef whose connection information should be reused. + * + * For example: + * + * DNSServiceErrorType error; + * DNSServiceRef SharedRef; + * error = DNSServiceCreateConnection(&SharedRef); + * if (error) ... + * DNSServiceRef BrowseRef = SharedRef; // Important: COPY the primary DNSServiceRef first... + * error = DNSServiceBrowse(&BrowseRef, kDNSServiceFlagsShareConnection, ...); // then use the copy + * if (error) ... + * ... + * DNSServiceRefDeallocate(BrowseRef); // Terminate the browse operation + * DNSServiceRefDeallocate(SharedRef); // Terminate the shared connection + * + * Notes: + * + * 1. Collective kDNSServiceFlagsMoreComing flag + * When callbacks are invoked using a shared DNSServiceRef, the + * kDNSServiceFlagsMoreComing flag applies collectively to *all* active + * operations sharing the same parent DNSServiceRef. If the MoreComing flag is + * set it means that there are more results queued on this parent DNSServiceRef, + * but not necessarily more results for this particular callback function. + * The implication of this for client programmers is that when a callback + * is invoked with the MoreComing flag set, the code should update its + * internal data structures with the new result, and set a variable indicating + * that its UI needs to be updated. Then, later when a callback is eventually + * invoked with the MoreComing flag not set, the code should update *all* + * stale UI elements related to that shared parent DNSServiceRef that need + * updating, not just the UI elements related to the particular callback + * that happened to be the last one to be invoked. + * + * 2. Canceling operations and kDNSServiceFlagsMoreComing + * Whenever you cancel any operation for which you had deferred UI updates + * waiting because of a kDNSServiceFlagsMoreComing flag, you should perform + * those deferred UI updates. This is because, after cancelling the operation, + * you can no longer wait for a callback *without* MoreComing set, to tell + * you do perform your deferred UI updates (the operation has been canceled, + * so there will be no more callbacks). An implication of the collective + * kDNSServiceFlagsMoreComing flag for shared connections is that this + * guideline applies more broadly -- any time you cancel an operation on + * a shared connection, you should perform all deferred UI updates for all + * operations sharing that connection. This is because the MoreComing flag + * might have been referring to events coming for the operation you canceled, + * which will now not be coming because the operation has been canceled. + * + * 3. Only share DNSServiceRef's created with DNSServiceCreateConnection + * Calling DNSServiceCreateConnection(&ref) creates a special shareable DNSServiceRef. + * DNSServiceRef's created by other calls like DNSServiceBrowse() or DNSServiceResolve() + * cannot be shared by copying them and using kDNSServiceFlagsShareConnection. + * + * 4. Don't Double-Deallocate + * Calling DNSServiceRefDeallocate(OpRef) for a particular operation's DNSServiceRef terminates + * just that operation. Calling DNSServiceRefDeallocate(SharedRef) for the main shared DNSServiceRef + * (the parent DNSServiceRef, originally created by DNSServiceCreateConnection(&SharedRef)) + * automatically terminates the shared connection *and* all operations that were still using it. + * After doing this, DO NOT then attempt to deallocate any remaining subordinate DNSServiceRef's. + * The memory used by those subordinate DNSServiceRef's has already been freed, so any attempt + * to do a DNSServiceRefDeallocate (or any other operation) on them will result in accesses + * to freed memory, leading to crashes or other equally undesirable results. + * You can deallocate individual operations first and then deallocate the parent DNSServiceRef last, + * but if you deallocate the parent DNSServiceRef first, then all of the subordinate DNSServiceRef's + * are implicitly deallocated, and explicitly deallocating them a second time will lead to crashes. + * + * 5. Thread Safety + * The dns_sd.h API does not presuppose any particular threading model, and consequently + * does no locking internally (which would require linking with a specific threading library). + * If the client concurrently, from multiple threads (or contexts), calls API routines using + * the same DNSServiceRef, it is the client's responsibility to provide mutual exclusion for + * that DNSServiceRef. + * + * For example, use of DNSServiceRefDeallocate requires caution. A common mistake is as follows: + * Thread B calls DNSServiceRefDeallocate to deallocate sdRef while Thread A is processing events + * using sdRef. Doing this will lead to intermittent crashes on thread A if the sdRef is used after + * it was deallocated. + * + * A telltale sign of this crash type is to see DNSServiceProcessResult on the stack preceding the + * actual crash location. + * + * To state this more explicitly, mDNSResponder does not queue DNSServiceRefDeallocate so + * that it occurs discretely before or after an event is handled. + */ + + kDNSServiceFlagsSuppressUnusable = 0x8000, + /* + * This flag is meaningful only in DNSServiceQueryRecord which suppresses unusable queries on the + * wire. If "hostname" is a wide-area unicast DNS hostname (i.e. not a ".local." name) + * but this host has no routable IPv6 address, then the call will not try to look up IPv6 addresses + * for "hostname", since any addresses it found would be unlikely to be of any use anyway. Similarly, + * if this host has no routable IPv4 address, the call will not try to look up IPv4 addresses for + * "hostname". + */ + + kDNSServiceFlagsTimeout = 0x10000, + /* + * When kDNServiceFlagsTimeout is passed to DNSServiceQueryRecord or DNSServiceGetAddrInfo, the query is + * stopped after a certain number of seconds have elapsed. The time at which the query will be stopped + * is determined by the system and cannot be configured by the user. The query will be stopped irrespective + * of whether a response was given earlier or not. When the query is stopped, the callback will be called + * with an error code of kDNSServiceErr_Timeout and a NULL sockaddr will be returned for DNSServiceGetAddrInfo + * and zero length rdata will be returned for DNSServiceQueryRecord. + */ + + kDNSServiceFlagsIncludeP2P = 0x20000, + /* + * Include P2P interfaces when kDNSServiceInterfaceIndexAny is specified. + * By default, specifying kDNSServiceInterfaceIndexAny does not include P2P interfaces. + */ + + kDNSServiceFlagsWakeOnResolve = 0x40000, + /* + * This flag is meaningful only in DNSServiceResolve. When set, it tries to send a magic packet + * to wake up the client. + */ + + kDNSServiceFlagsBackgroundTrafficClass = 0x80000, + /* + * This flag is meaningful for Unicast DNS queries. When set, it uses the background traffic + * class for packets that service the request. + */ + + kDNSServiceFlagsIncludeAWDL = 0x100000, + /* + * Include AWDL interface when kDNSServiceInterfaceIndexAny is specified. + */ + + kDNSServiceFlagsEnableDNSSEC = 0x200000, + /* + * Perform DNSSEC validation on the client request when kDNSServiceFlagsEnableDNSSEC is specified + * Since the client API has not been finalized, we will use it as a temporary flag to turn on the DNSSEC validation. + */ + + kDNSServiceFlagsValidate = 0x200000, + /* + * This flag is meaningful in DNSServiceGetAddrInfo and DNSServiceQueryRecord. This is the ONLY flag to be valid + * as an input to the APIs and also an output through the callbacks in the APIs. + * + * When this flag is passed to DNSServiceQueryRecord and DNSServiceGetAddrInfo to resolve unicast names, + * the response will be validated using DNSSEC. The validation results are delivered using the flags field in + * the callback and kDNSServiceFlagsValidate is marked in the flags to indicate that DNSSEC status is also available. + * When the callback is called to deliver the query results, the validation results may or may not be available. + * If it is not delivered along with the results, the validation status is delivered when the validation completes. + * + * When the validation results are delivered in the callback, it is indicated by marking the flags with + * kDNSServiceFlagsValidate and kDNSServiceFlagsAdd along with the DNSSEC status flags (described below) and a NULL + * sockaddr will be returned for DNSServiceGetAddrInfo and zero length rdata will be returned for DNSServiceQueryRecord. + * DNSSEC validation results are for the whole RRSet and not just individual records delivered in the callback. When + * kDNSServiceFlagsAdd is not set in the flags, applications should implicitly assume that the DNSSEC status of the + * RRSet that has been delivered up until that point is not valid anymore, till another callback is called with + * kDNSServiceFlagsAdd and kDNSServiceFlagsValidate. + * + * The following four flags indicate the status of the DNSSEC validation and marked in the flags field of the callback. + * When any of the four flags is set, kDNSServiceFlagsValidate will also be set. To check the validation status, the + * other applicable output flags should be masked. + */ + + kDNSServiceFlagsSecure = 0x200010, + /* + * The response has been validated by verifying all the signatures in the response and was able to + * build a successful authentication chain starting from a known trust anchor. + */ + + kDNSServiceFlagsInsecure = 0x200020, + /* + * A chain of trust cannot be built starting from a known trust anchor to the response. + */ + + kDNSServiceFlagsBogus = 0x200040, + /* + * If the response cannot be verified to be secure due to expired signatures, missing signatures etc., + * then the results are considered to be bogus. + */ + + kDNSServiceFlagsIndeterminate = 0x200080, + /* + * There is no valid trust anchor that can be used to determine whether a response is secure or not. + */ + + kDNSServiceFlagsUnicastResponse = 0x400000, + /* + * Request unicast response to query. + */ + kDNSServiceFlagsValidateOptional = 0x800000, + + /* + * This flag is identical to kDNSServiceFlagsValidate except for the case where the response + * cannot be validated. If this flag is set in DNSServiceQueryRecord or DNSServiceGetAddrInfo, + * the DNSSEC records will be requested for validation. If they cannot be received for some reason + * during the validation (e.g., zone is not signed, zone is signed but cannot be traced back to + * root, recursive server does not understand DNSSEC etc.), then this will fallback to the default + * behavior where the validation will not be performed and no DNSSEC results will be provided. + * + * If the zone is signed and there is a valid path to a known trust anchor configured in the system + * and the application requires DNSSEC validation irrespective of the DNSSEC awareness in the current + * network, then this option MUST not be used. This is only intended to be used during the transition + * period where the different nodes participating in the DNS resolution may not understand DNSSEC or + * managed properly (e.g. missing DS record) but still want to be able to resolve DNS successfully. + */ + + kDNSServiceFlagsWakeOnlyService = 0x1000000, + /* + * This flag is meaningful only in DNSServiceRegister. When set, the service will not be registered + * with sleep proxy server during sleep. + */ + + kDNSServiceFlagsThresholdOne = 0x2000000, + kDNSServiceFlagsThresholdFinder = 0x4000000, + kDNSServiceFlagsThresholdReached = kDNSServiceFlagsThresholdOne, + /* + * kDNSServiceFlagsThresholdOne is meaningful only in DNSServiceBrowse. When set, + * the system will stop issuing browse queries on the network once the number + * of answers returned is one or more. It will issue queries on the network + * again if the number of answers drops to zero. + * This flag is for Apple internal use only. Third party developers + * should not rely on this behavior being supported in any given software release. + * + * kDNSServiceFlagsThresholdFinder is meaningful only in DNSServiceBrowse. When set, + * the system will stop issuing browse queries on the network once the number + * of answers has reached the threshold set for Finder. + * It will issue queries on the network again if the number of answers drops below + * this threshold. + * This flag is for Apple internal use only. Third party developers + * should not rely on this behavior being supported in any given software release. + * + * When kDNSServiceFlagsThresholdReached is set in the client callback add or remove event, + * it indicates that the browse answer threshold has been reached and no + * browse requests will be generated on the network until the number of answers falls + * below the threshold value. Add and remove events can still occur based + * on incoming Bonjour traffic observed by the system. + * The set of services return to the client is not guaranteed to represent the + * entire set of services present on the network once the threshold has been reached. + * + * Note, while kDNSServiceFlagsThresholdReached and kDNSServiceFlagsThresholdOne + * have the same value, there isn't a conflict because kDNSServiceFlagsThresholdReached + * is only set in the callbacks and kDNSServiceFlagsThresholdOne is only set on + * input to a DNSServiceBrowse call. + */ + kDNSServiceFlagsPrivateOne = 0x2000, + /* + * This flag is private and should not be used. + */ + + kDNSServiceFlagsPrivateTwo = 0x8000000, + /* + * This flag is private and should not be used. + */ + + kDNSServiceFlagsPrivateThree = 0x10000000, + /* + * This flag is private and should not be used. + */ + + kDNSServiceFlagsPrivateFour = 0x20000000, + /* + * This flag is private and should not be used. + */ + + kDNSServiceFlagsPrivateFive = 0x40000000, + /* + * This flag is private and should not be used. + */ + + + kDNSServiceFlagAnsweredFromCache = 0x40000000, + /* + * When kDNSServiceFlagAnsweredFromCache is passed back in the flags parameter of DNSServiceQueryRecordReply or DNSServiceGetAddrInfoReply, + * an answer will have this flag set if it was answered from the cache. + */ + + kDNSServiceFlagsAllowExpiredAnswers = 0x80000000, + /* + * When kDNSServiceFlagsAllowExpiredAnswers is passed to DNSServiceQueryRecord or DNSServiceGetAddrInfo, + * if there are matching expired records still in the cache, then they are immediately returned to the + * client, and in parallel a network query for that name is issued. All returned records from the query will + * remain in the cache after expiration. + */ + + kDNSServiceFlagsExpiredAnswer = 0x80000000 + /* + * When kDNSServiceFlagsAllowExpiredAnswers is passed to DNSServiceQueryRecord or DNSServiceGetAddrInfo, + * an expired answer will have this flag set. + */ + +}; + +/* Possible protocol values */ +enum +{ + /* for DNSServiceGetAddrInfo() */ + kDNSServiceProtocol_IPv4 = 0x01, + kDNSServiceProtocol_IPv6 = 0x02, + /* 0x04 and 0x08 reserved for future internetwork protocols */ + + /* for DNSServiceNATPortMappingCreate() */ + kDNSServiceProtocol_UDP = 0x10, + kDNSServiceProtocol_TCP = 0x20 + /* 0x40 and 0x80 reserved for future transport protocols, e.g. SCTP [RFC 2960] + * or DCCP [RFC 4340]. If future NAT gateways are created that support port + * mappings for these protocols, new constants will be defined here. + */ +}; + +/* + * The values for DNS Classes and Types are listed in RFC 1035, and are available + * on every OS in its DNS header file. Unfortunately every OS does not have the + * same header file containing DNS Class and Type constants, and the names of + * the constants are not consistent. For example, BIND 8 uses "T_A", + * BIND 9 uses "ns_t_a", Windows uses "DNS_TYPE_A", etc. + * For this reason, these constants are also listed here, so that code using + * the DNS-SD programming APIs can use these constants, so that the same code + * can compile on all our supported platforms. + */ + +enum +{ + kDNSServiceClass_IN = 1 /* Internet */ +}; + +enum +{ + kDNSServiceType_A = 1, /* Host address. */ + kDNSServiceType_NS = 2, /* Authoritative server. */ + kDNSServiceType_MD = 3, /* Mail destination. */ + kDNSServiceType_MF = 4, /* Mail forwarder. */ + kDNSServiceType_CNAME = 5, /* Canonical name. */ + kDNSServiceType_SOA = 6, /* Start of authority zone. */ + kDNSServiceType_MB = 7, /* Mailbox domain name. */ + kDNSServiceType_MG = 8, /* Mail group member. */ + kDNSServiceType_MR = 9, /* Mail rename name. */ + kDNSServiceType_NULL = 10, /* Null resource record. */ + kDNSServiceType_WKS = 11, /* Well known service. */ + kDNSServiceType_PTR = 12, /* Domain name pointer. */ + kDNSServiceType_HINFO = 13, /* Host information. */ + kDNSServiceType_MINFO = 14, /* Mailbox information. */ + kDNSServiceType_MX = 15, /* Mail routing information. */ + kDNSServiceType_TXT = 16, /* One or more text strings (NOT "zero or more..."). */ + kDNSServiceType_RP = 17, /* Responsible person. */ + kDNSServiceType_AFSDB = 18, /* AFS cell database. */ + kDNSServiceType_X25 = 19, /* X_25 calling address. */ + kDNSServiceType_ISDN = 20, /* ISDN calling address. */ + kDNSServiceType_RT = 21, /* Router. */ + kDNSServiceType_NSAP = 22, /* NSAP address. */ + kDNSServiceType_NSAP_PTR = 23, /* Reverse NSAP lookup (deprecated). */ + kDNSServiceType_SIG = 24, /* Security signature. */ + kDNSServiceType_KEY = 25, /* Security key. */ + kDNSServiceType_PX = 26, /* X.400 mail mapping. */ + kDNSServiceType_GPOS = 27, /* Geographical position (withdrawn). */ + kDNSServiceType_AAAA = 28, /* IPv6 Address. */ + kDNSServiceType_LOC = 29, /* Location Information. */ + kDNSServiceType_NXT = 30, /* Next domain (security). */ + kDNSServiceType_EID = 31, /* Endpoint identifier. */ + kDNSServiceType_NIMLOC = 32, /* Nimrod Locator. */ + kDNSServiceType_SRV = 33, /* Server Selection. */ + kDNSServiceType_ATMA = 34, /* ATM Address */ + kDNSServiceType_NAPTR = 35, /* Naming Authority PoinTeR */ + kDNSServiceType_KX = 36, /* Key Exchange */ + kDNSServiceType_CERT = 37, /* Certification record */ + kDNSServiceType_A6 = 38, /* IPv6 Address (deprecated) */ + kDNSServiceType_DNAME = 39, /* Non-terminal DNAME (for IPv6) */ + kDNSServiceType_SINK = 40, /* Kitchen sink (experimental) */ + kDNSServiceType_OPT = 41, /* EDNS0 option (meta-RR) */ + kDNSServiceType_APL = 42, /* Address Prefix List */ + kDNSServiceType_DS = 43, /* Delegation Signer */ + kDNSServiceType_SSHFP = 44, /* SSH Key Fingerprint */ + kDNSServiceType_IPSECKEY = 45, /* IPSECKEY */ + kDNSServiceType_RRSIG = 46, /* RRSIG */ + kDNSServiceType_NSEC = 47, /* Denial of Existence */ + kDNSServiceType_DNSKEY = 48, /* DNSKEY */ + kDNSServiceType_DHCID = 49, /* DHCP Client Identifier */ + kDNSServiceType_NSEC3 = 50, /* Hashed Authenticated Denial of Existence */ + kDNSServiceType_NSEC3PARAM = 51, /* Hashed Authenticated Denial of Existence */ + + kDNSServiceType_HIP = 55, /* Host Identity Protocol */ + + kDNSServiceType_SVCB = 64, /* Service Binding. */ + kDNSServiceType_HTTPS = 65, /* HTTPS Service Binding. */ + + kDNSServiceType_SPF = 99, /* Sender Policy Framework for E-Mail */ + kDNSServiceType_UINFO = 100, /* IANA-Reserved */ + kDNSServiceType_UID = 101, /* IANA-Reserved */ + kDNSServiceType_GID = 102, /* IANA-Reserved */ + kDNSServiceType_UNSPEC = 103, /* IANA-Reserved */ + + kDNSServiceType_TKEY = 249, /* Transaction key */ + kDNSServiceType_TSIG = 250, /* Transaction signature. */ + kDNSServiceType_IXFR = 251, /* Incremental zone transfer. */ + kDNSServiceType_AXFR = 252, /* Transfer zone of authority. */ + kDNSServiceType_MAILB = 253, /* Transfer mailbox records. */ + kDNSServiceType_MAILA = 254, /* Transfer mail agent records. */ + kDNSServiceType_ANY = 255 /* Wildcard match. */ +}; + +/* possible error code values */ +enum +{ + kDNSServiceErr_NoError = 0, + kDNSServiceErr_Unknown = -65537, /* 0xFFFE FFFF */ + kDNSServiceErr_NoSuchName = -65538, + kDNSServiceErr_NoMemory = -65539, + kDNSServiceErr_BadParam = -65540, + kDNSServiceErr_BadReference = -65541, + kDNSServiceErr_BadState = -65542, + kDNSServiceErr_BadFlags = -65543, + kDNSServiceErr_Unsupported = -65544, + kDNSServiceErr_NotInitialized = -65545, + kDNSServiceErr_AlreadyRegistered = -65547, + kDNSServiceErr_NameConflict = -65548, + kDNSServiceErr_Invalid = -65549, + kDNSServiceErr_Firewall = -65550, + kDNSServiceErr_Incompatible = -65551, /* client library incompatible with daemon */ + kDNSServiceErr_BadInterfaceIndex = -65552, + kDNSServiceErr_Refused = -65553, + kDNSServiceErr_NoSuchRecord = -65554, + kDNSServiceErr_NoAuth = -65555, + kDNSServiceErr_NoSuchKey = -65556, + kDNSServiceErr_NATTraversal = -65557, + kDNSServiceErr_DoubleNAT = -65558, + kDNSServiceErr_BadTime = -65559, /* Codes up to here existed in Tiger */ + kDNSServiceErr_BadSig = -65560, + kDNSServiceErr_BadKey = -65561, + kDNSServiceErr_Transient = -65562, + kDNSServiceErr_ServiceNotRunning = -65563, /* Background daemon not running */ + kDNSServiceErr_NATPortMappingUnsupported = -65564, /* NAT doesn't support PCP, NAT-PMP or UPnP */ + kDNSServiceErr_NATPortMappingDisabled = -65565, /* NAT supports PCP, NAT-PMP or UPnP, but it's disabled by the administrator */ + kDNSServiceErr_NoRouter = -65566, /* No router currently configured (probably no network connectivity) */ + kDNSServiceErr_PollingMode = -65567, + kDNSServiceErr_Timeout = -65568, + kDNSServiceErr_DefunctConnection = -65569, /* Connection to daemon returned a SO_ISDEFUNCT error result */ + kDNSServiceErr_PolicyDenied = -65570 + + /* mDNS Error codes are in the range + * FFFE FF00 (-65792) to FFFE FFFF (-65537) */ +}; + +/* Maximum length, in bytes, of a service name represented as a */ +/* literal C-String, including the terminating NULL at the end. */ + +#define kDNSServiceMaxServiceName 64 + +/* Maximum length, in bytes, of a domain name represented as an *escaped* C-String */ +/* including the final trailing dot, and the C-String terminating NULL at the end. */ + +#define kDNSServiceMaxDomainName 1009 + +/* + * Notes on DNS Name Escaping + * -- or -- + * "Why is kDNSServiceMaxDomainName 1009, when the maximum legal domain name is 256 bytes?" + * + * All strings used in the DNS-SD APIs are UTF-8 strings. + * Apart from the exceptions noted below, the APIs expect the strings to be properly escaped, using the + * conventional DNS escaping rules, as used by the traditional DNS res_query() API, as described below: + * + * Generally all UTF-8 characters (which includes all US ASCII characters) represent themselves, + * with three exceptions: + * the dot ('.') character, which is the DNS label separator, + * the backslash ('\') character, which is the DNS escape character, and + * the ASCII NUL (0) byte value, which is the C-string terminator character. + * The escape character ('\') is interpreted as described below: + * + * '\ddd', where ddd is a three-digit decimal value from 000 to 255, + * represents a single literal byte with that value. Any byte value may be + * represented in '\ddd' format, even characters that don't strictly need to be escaped. + * For example, the ASCII code for 'w' is 119, and therefore '\119' is equivalent to 'w'. + * Thus the command "ping '\119\119\119.apple.com'" is the equivalent to the command "ping 'www.apple.com'". + * Nonprinting ASCII characters in the range 0-31 are often represented this way. + * In particular, the ASCII NUL character (0) cannot appear in a C-string because C uses it as the + * string terminator character, so ASCII NUL in a domain name has to be represented in a C-string as '\000'. + * Other characters like space (ASCII code 32) are sometimes represented as '\032' + * in contexts where having an actual space character in a C-string would be inconvenient. + * + * Otherwise, for all cases where a '\' is followed by anything other than a three-digit decimal value + * from 000 to 255, the character sequence '\x' represents a single literal occurrence of character 'x'. + * This is legal for any character, so, for example, '\w' is equivalent to 'w'. + * Thus the command "ping '\w\w\w.apple.com'" is the equivalent to the command "ping 'www.apple.com'". + * However, this encoding is most useful when representing the characters '.' and '\', + * which otherwise would have special meaning in DNS name strings. + * This means that the following encodings are particularly common: + * '\\' represents a single literal '\' in the name + * '\.' represents a single literal '.' in the name + * + * A lone escape character ('\') appearing at the end of a string is not allowed, since it is + * followed by neither a three-digit decimal value from 000 to 255 nor a single character. + * If a lone escape character ('\') does appear as the last character of a string, it is silently ignored. + * + * The worse-case length for an escaped domain name is calculated as follows: + * The longest legal domain name is 256 bytes in wire format (see RFC 6762, Appendix C, DNS Name Length). + * For our calculation of the longest *escaped* domain name, we use + * the longest legal domain name, with the most characters escaped. + * + * We consider a domain name of the form: "label63.label63.label63.label62." + * where "label63" is a 63-byte label and "label62" is a 62-byte label. + * Counting four label-length bytes, 251 bytes of label data, and the terminating zero, + * this makes a total of 256 bytes in wire format, the longest legal domain name. + * + * If each one of the 251 bytes of label data is represented using '\ddd', + * then it takes 251 * 4 = 1004 bytes to represent these in a C-string. + * Adding four '.' characters as shown above, plus the C-string terminating + * zero at the end, results in a maximum storage requirement of 1009 bytes. + * + * The exceptions, that do not use escaping, are the routines where the full + * DNS name of a resource is broken, for convenience, into servicename/regtype/domain. + * In these routines, the "servicename" is NOT escaped. It does not need to be, since + * it is, by definition, just a single literal string. Any characters in that string + * represent exactly what they are. The "regtype" portion is, technically speaking, + * escaped, but since legal regtypes are only allowed to contain US ASCII letters, + * digits, and hyphens, there is nothing to escape, so the issue is moot. + * The "domain" portion is also escaped, though most domains in use on the public + * Internet today, like regtypes, don't contain any characters that need to be escaped. + * As DNS-SD becomes more popular, rich-text domains for service discovery will + * become common, so software should be written to cope with domains with escaping. + * + * The servicename may be up to 63 bytes of UTF-8 text (not counting the C-String + * terminating NULL at the end). The regtype is of the form _service._tcp or + * _service._udp, where the "service" part is 1-15 characters, which may be + * letters, digits, or hyphens. The domain part of the three-part name may be + * any legal domain, providing that the resulting servicename+regtype+domain + * name does not exceed 256 bytes. + * + * For most software, these issues are transparent. When browsing, the discovered + * servicenames should simply be displayed as-is. When resolving, the discovered + * servicename/regtype/domain are simply passed unchanged to DNSServiceResolve(). + * When a DNSServiceResolve() succeeds, the returned fullname is already in + * the correct format to pass to standard system DNS APIs such as res_query(). + * For converting from servicename/regtype/domain to a single properly-escaped + * full DNS name, the helper function DNSServiceConstructFullName() is provided. + * + * The following (highly contrived) example illustrates the escaping process. + * Suppose you have a service called "Dr. Smith\Dr. Johnson", of type "_ftp._tcp" + * in subdomain "4th. Floor" of subdomain "Building 2" of domain "apple.com." + * The full (escaped) DNS name of this service's SRV record would be: + * Dr\.\032Smith\\Dr\.\032Johnson._ftp._tcp.4th\.\032Floor.Building\0322.apple.com. + */ + + +/* + * Constants for specifying an interface index + * + * Specific interface indexes are identified via a 32-bit unsigned integer returned + * by the if_nametoindex() family of calls. + * + * If the client passes 0 for interface index, that means "do the right thing", + * which (at present) means, "if the name is in an mDNS local multicast domain + * (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast + * on all applicable interfaces, otherwise send via unicast to the appropriate + * DNS server." Normally, most clients will use 0 for interface index to + * automatically get the default sensible behaviour. + * + * If the client passes a positive interface index, then that indicates to do the + * operation only on that one specified interface. + * + * If the client passes kDNSServiceInterfaceIndexLocalOnly when registering + * a service, then that service will be found *only* by other local clients + * on the same machine that are browsing using kDNSServiceInterfaceIndexLocalOnly + * or kDNSServiceInterfaceIndexAny. + * If a client has a 'private' service, accessible only to other processes + * running on the same machine, this allows the client to advertise that service + * in a way such that it does not inadvertently appear in service lists on + * all the other machines on the network. + * + * If the client passes kDNSServiceInterfaceIndexLocalOnly when querying or + * browsing, then the LocalOnly authoritative records and /etc/hosts caches + * are searched and will find *all* records registered or configured on that + * same local machine. + * + * If interested in getting negative answers to local questions while querying + * or browsing, then set both the kDNSServiceInterfaceIndexLocalOnly and the + * kDNSServiceFlagsReturnIntermediates flags. If no local answers exist at this + * moment in time, then the reply will return an immediate negative answer. If + * local records are subsequently created that answer the question, then those + * answers will be delivered, for as long as the question is still active. + * + * If the kDNSServiceFlagsTimeout and kDNSServiceInterfaceIndexLocalOnly flags + * are set simultaneously when either DNSServiceQueryRecord or DNSServiceGetAddrInfo + * is called then both flags take effect. However, if DNSServiceQueryRecord is called + * with both the kDNSServiceFlagsSuppressUnusable and kDNSServiceInterfaceIndexLocalOnly + * flags set, then the kDNSServiceFlagsSuppressUnusable flag is ignored. + * + * Clients explicitly wishing to discover *only* LocalOnly services during a + * browse may do this, without flags, by inspecting the interfaceIndex of each + * service reported to a DNSServiceBrowseReply() callback function, and + * discarding those answers where the interface index is not set to + * kDNSServiceInterfaceIndexLocalOnly. + * + * kDNSServiceInterfaceIndexP2P is meaningful only in Browse, QueryRecord, Register, + * and Resolve operations. It should not be used in other DNSService APIs. + * + * - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceBrowse or + * DNSServiceQueryRecord, it restricts the operation to P2P. + * + * - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceRegister, it is + * mapped internally to kDNSServiceInterfaceIndexAny with the kDNSServiceFlagsIncludeP2P + * set. + * + * - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceResolve, it is + * mapped internally to kDNSServiceInterfaceIndexAny with the kDNSServiceFlagsIncludeP2P + * set, because resolving a P2P service may create and/or enable an interface whose + * index is not known a priori. The resolve callback will indicate the index of the + * interface via which the service can be accessed. + * + * If applications pass kDNSServiceInterfaceIndexAny to DNSServiceBrowse + * or DNSServiceQueryRecord, they must set the kDNSServiceFlagsIncludeP2P flag + * to include P2P. In this case, if a service instance or the record being queried + * is found over P2P, the resulting ADD event will indicate kDNSServiceInterfaceIndexP2P + * as the interface index. + */ + +#define kDNSServiceInterfaceIndexAny 0 +#define kDNSServiceInterfaceIndexLocalOnly ((uint32_t)-1) +#define kDNSServiceInterfaceIndexUnicast ((uint32_t)-2) +#define kDNSServiceInterfaceIndexP2P ((uint32_t)-3) +#define kDNSServiceInterfaceIndexBLE ((uint32_t)-4) + +typedef uint32_t DNSServiceFlags; +typedef uint32_t DNSServiceProtocol; +typedef int32_t DNSServiceErrorType; + + +/********************************************************************************************* +* +* Version checking +* +*********************************************************************************************/ + +/* DNSServiceGetProperty() Parameters: + * + * property: The requested property. + * Currently the only property defined is kDNSServiceProperty_DaemonVersion. + * + * result: Place to store result. + * For retrieving DaemonVersion, this should be the address of a uint32_t. + * + * size: Pointer to uint32_t containing size of the result location. + * For retrieving DaemonVersion, this should be sizeof(uint32_t). + * On return the uint32_t is updated to the size of the data returned. + * For DaemonVersion, the returned size is always sizeof(uint32_t), but + * future properties could be defined which return variable-sized results. + * + * return value: Returns kDNSServiceErr_NoError on success, or kDNSServiceErr_ServiceNotRunning + * if the daemon (or "system service" on Windows) is not running. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceGetProperty +( + const char *property, /* Requested property (i.e. kDNSServiceProperty_DaemonVersion) */ + void *result, /* Pointer to place to store result */ + uint32_t *size /* size of result location */ +); + +/* + * When requesting kDNSServiceProperty_DaemonVersion, the result pointer must point + * to a 32-bit unsigned integer, and the size parameter must be set to sizeof(uint32_t). + * + * On return, the 32-bit unsigned integer contains the API version number + * + * For example, Mac OS X 10.4.9 has API version 1080400. + * This allows applications to do simple greater-than and less-than comparisons: + * e.g. an application that requires at least API version 1080400 can check: + * if (version >= 1080400) ... + * + * Example usage: + * uint32_t version; + * uint32_t size = sizeof(version); + * DNSServiceErrorType err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size); + * if (!err) printf("DNS_SD API version is %d.%d\n", version / 10000, version / 100 % 100); + */ + +#define kDNSServiceProperty_DaemonVersion "DaemonVersion" + +/********************************************************************************************* +* +* Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions +* +*********************************************************************************************/ + +/* DNSServiceRefSockFD() + * + * Access underlying Unix domain socket for an initialized DNSServiceRef. + * The DNS Service Discovery implementation uses this socket to communicate between the client and + * the daemon. The application MUST NOT directly read from or write to this socket. + * Access to the socket is provided so that it can be used as a kqueue event source, a CFRunLoop + * event source, in a select() loop, etc. When the underlying event management subsystem (kqueue/ + * select/CFRunLoop etc.) indicates to the client that data is available for reading on the + * socket, the client should call DNSServiceProcessResult(), which will extract the daemon's + * reply from the socket, and pass it to the appropriate application callback. By using a run + * loop or select(), results from the daemon can be processed asynchronously. Alternatively, + * a client can choose to fork a thread and have it loop calling "DNSServiceProcessResult(ref);" + * If DNSServiceProcessResult() is called when no data is available for reading on the socket, it + * will block until data does become available, and then process the data and return to the caller. + * The application is responsible for checking the return value of DNSServiceProcessResult() + * to determine if the socket is valid and if it should continue to process data on the socket. + * When data arrives on the socket, the client is responsible for calling DNSServiceProcessResult(ref) + * in a timely fashion -- if the client allows a large backlog of data to build up the daemon + * may terminate the connection. + * + * sdRef: A DNSServiceRef initialized by any of the DNSService calls. + * + * return value: The DNSServiceRef's underlying socket descriptor, or -1 on + * error. + */ + +DNSSD_EXPORT +dnssd_sock_t DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdRef); + + +/* DNSServiceProcessResult() + * + * Read a reply from the daemon, calling the appropriate application callback. This call will + * block until the daemon's response is received. Use DNSServiceRefSockFD() in + * conjunction with a run loop or select() to determine the presence of a response from the + * server before calling this function to process the reply without blocking. Call this function + * at any point if it is acceptable to block until the daemon's response arrives. Note that the + * client is responsible for ensuring that DNSServiceProcessResult() is called whenever there is + * a reply from the daemon - the daemon may terminate its connection with a client that does not + * process the daemon's responses. + * + * sdRef: A DNSServiceRef initialized by any of the DNSService calls + * that take a callback parameter. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns + * an error code indicating the specific failure that occurred. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdRef); + + +/* DNSServiceRefDeallocate() + * + * Terminate a connection with the daemon and free memory associated with the DNSServiceRef. + * Any services or records registered with this DNSServiceRef will be deregistered. Any + * Browse, Resolve, or Query operations called with this reference will be terminated. + * + * Note: If the reference's underlying socket is used in a run loop or select() call, it should + * be removed BEFORE DNSServiceRefDeallocate() is called, as this function closes the reference's + * socket. + * + * Note: If the reference was initialized with DNSServiceCreateConnection(), any DNSRecordRefs + * created via this reference will be invalidated by this call - the resource records are + * deregistered, and their DNSRecordRefs may not be used in subsequent functions. Similarly, + * if the reference was initialized with DNSServiceRegister, and an extra resource record was + * added to the service via DNSServiceAddRecord(), the DNSRecordRef created by the Add() call + * is invalidated when this function is called - the DNSRecordRef may not be used in subsequent + * functions. + * + * If the reference was passed to DNSServiceSetDispatchQueue(), DNSServiceRefDeallocate() must + * be called on the same queue originally passed as an argument to DNSServiceSetDispatchQueue(). + * + * Note: This call is to be used only with the DNSServiceRef defined by this API. + * + * sdRef: A DNSServiceRef initialized by any of the DNSService calls. + * + */ + +DNSSD_EXPORT +void DNSSD_API DNSServiceRefDeallocate(DNSServiceRef sdRef); + + +/********************************************************************************************* +* +* Domain Enumeration +* +*********************************************************************************************/ + +/* DNSServiceEnumerateDomains() + * + * Asynchronously enumerate domains available for browsing and registration. + * + * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains + * are to be found. + * + * Note that the names returned are (like all of DNS-SD) UTF-8 strings, + * and are escaped using standard DNS escaping rules. + * (See "Notes on DNS Name Escaping" earlier in this file for more details.) + * A graphical browser displaying a hierarchical tree-structured view should cut + * the names at the bare dots to yield individual labels, then de-escape each + * label according to the escaping rules, and then display the resulting UTF-8 text. + * + * DNSServiceDomainEnumReply Callback Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains(). + * + * flags: Possible values are: + * kDNSServiceFlagsMoreComing + * kDNSServiceFlagsAdd + * kDNSServiceFlagsDefault + * + * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given + * interface is determined via the if_nametoindex() family of calls.) + * + * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise indicates + * the failure that occurred (other parameters are undefined if errorCode is nonzero). + * + * replyDomain: The name of the domain. + * + * context: The context pointer passed to DNSServiceEnumerateDomains. + * + */ + +typedef void (DNSSD_API *DNSServiceDomainEnumReply) +( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *replyDomain, + void *context +); + + +/* DNSServiceEnumerateDomains() Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef + * (or, if the kDNSServiceFlagsShareConnection flag is used, + * a copy of the shared connection reference that is to be used). + * If the call succeeds then it initializes (or updates) the DNSServiceRef, + * returns kDNSServiceErr_NoError, and the enumeration operation + * will remain active indefinitely until the client terminates it + * by passing this DNSServiceRef to DNSServiceRefDeallocate() + * (or by closing the underlying shared connection, if used). + * + * flags: Possible values are: + * kDNSServiceFlagsShareConnection to use a shared connection. + * kDNSServiceFlagsBrowseDomains to enumerate domains recommended for browsing. + * kDNSServiceFlagsRegistrationDomains to enumerate domains recommended + * for registration. + * + * interfaceIndex: If non-zero, specifies the interface on which to look for domains. + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Most applications will pass 0 to enumerate domains on + * all interfaces. See "Constants for specifying an interface index" for more details. + * + * callBack: The function to be called when a domain is found or the call asynchronously + * fails. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is not invoked and the DNSServiceRef + * is not initialized). + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains +( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceDomainEnumReply callBack, + void *context /* may be NULL */ +); + + +/********************************************************************************************* +* +* Service Registration +* +*********************************************************************************************/ + +/* Register a service that is discovered via Browse() and Resolve() calls. + * + * DNSServiceRegisterReply() Callback Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceRegister(). + * + * flags: When a name is successfully registered, the callback will be + * invoked with the kDNSServiceFlagsAdd flag set. When Wide-Area + * DNS-SD is in use, it is possible for a single service to get + * more than one success callback (e.g. one in the "local" multicast + * DNS domain, and another in a wide-area unicast DNS domain). + * If a successfully-registered name later suffers a name conflict + * or similar problem and has to be deregistered, the callback will + * be invoked with the kDNSServiceFlagsAdd flag not set. The callback + * is *not* invoked in the case where the caller explicitly terminates + * the service registration by calling DNSServiceRefDeallocate(ref); + * + * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will + * indicate the failure that occurred (including name conflicts, + * if the kDNSServiceFlagsNoAutoRename flag was used when registering.) + * Other parameters are undefined if errorCode is nonzero. + * + * name: The service name registered (if the application did not specify a name in + * DNSServiceRegister(), this indicates what name was automatically chosen). + * + * regtype: The type of service registered, as it was passed to the callout. + * + * domain: The domain on which the service was registered (if the application did not + * specify a domain in DNSServiceRegister(), this indicates the default domain + * on which the service was registered). + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (DNSSD_API *DNSServiceRegisterReply) +( + DNSServiceRef sdRef, + DNSServiceFlags flags, + DNSServiceErrorType errorCode, + const char *name, + const char *regtype, + const char *domain, + void *context +); + + +/* DNSServiceRegister() Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef + * (or, if the kDNSServiceFlagsShareConnection flag is used, + * a copy of the shared connection reference that is to be used). + * If the call succeeds then it initializes (or updates) the DNSServiceRef, + * returns kDNSServiceErr_NoError, and the service registration + * will remain active indefinitely until the client terminates it + * by passing this DNSServiceRef to DNSServiceRefDeallocate() + * (or by closing the underlying shared connection, if used). + * + * flags: Possible values are: + * kDNSServiceFlagsShareConnection to use a shared connection. + * Other flags indicate the renaming behavior on name conflict + * (not required for most applications). + * See flag definitions above for details. + * + * interfaceIndex: If non-zero, specifies the interface on which to register the service + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Most applications will pass 0 to register on all + * available interfaces. See "Constants for specifying an interface index" for more details. + * + * name: If non-NULL, specifies the service name to be registered. + * Most applications will not specify a name, in which case the computer + * name is used (this name is communicated to the client via the callback). + * If a name is specified, it must be 1-63 bytes of UTF-8 text. + * If the name is longer than 63 bytes it will be automatically truncated + * to a legal length, unless the NoAutoRename flag is set, + * in which case kDNSServiceErr_BadParam will be returned. + * + * regtype: The service type followed by the protocol, separated by a dot + * (e.g. "_ftp._tcp"). The service type must be an underscore, followed + * by 1-15 characters, which may be letters, digits, or hyphens. + * The transport protocol must be "_tcp" or "_udp". New service types + * should be registered at . + * + * Additional subtypes of the primary service type (where a service + * type has defined subtypes) follow the primary service type in a + * comma-separated list, with no additional spaces, e.g. + * "_primarytype._tcp,_subtype1,_subtype2,_subtype3" + * Subtypes provide a mechanism for filtered browsing: A client browsing + * for "_primarytype._tcp" will discover all instances of this type; + * a client browsing for "_primarytype._tcp,_subtype2" will discover only + * those instances that were registered with "_subtype2" in their list of + * registered subtypes. + * + * The subtype mechanism can be illustrated with some examples using the + * dns-sd command-line tool: + * + * % dns-sd -R Simple _test._tcp "" 1001 & + * % dns-sd -R Better _test._tcp,HasFeatureA "" 1002 & + * % dns-sd -R Best _test._tcp,HasFeatureA,HasFeatureB "" 1003 & + * + * Now: + * % dns-sd -B _test._tcp # will find all three services + * % dns-sd -B _test._tcp,HasFeatureA # finds "Better" and "Best" + * % dns-sd -B _test._tcp,HasFeatureB # finds only "Best" + * + * Subtype labels may be up to 63 bytes long, and may contain any eight- + * bit byte values, including zero bytes. However, due to the nature of + * using a C-string-based API, conventional DNS escaping must be used for + * dots ('.'), commas (','), backslashes ('\') and zero bytes, as shown below: + * + * % dns-sd -R Test '_test._tcp,s\.one,s\,two,s\\three,s\000four' local 123 + * + * domain: If non-NULL, specifies the domain on which to advertise the service. + * Most applications will not specify a domain, instead automatically + * registering in the default domain(s). + * + * host: If non-NULL, specifies the SRV target host name. Most applications + * will not specify a host, instead automatically using the machine's + * default host name(s). Note that specifying a non-NULL host does NOT + * create an address record for that host - the application is responsible + * for ensuring that the appropriate address record exists, or creating it + * via DNSServiceRegisterRecord(). + * + * port: The port, in network byte order, on which the service accepts connections. + * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered + * by browsing, but will cause a name conflict if another client tries to + * register that same name). Most clients will not use placeholder services. + * + * txtLen: The length of the txtRecord, in bytes. Must be zero if the txtRecord is NULL. + * + * txtRecord: The TXT record rdata. A non-NULL txtRecord MUST be a properly formatted DNS + * TXT record, i.e. ... + * Passing NULL for the txtRecord is allowed as a synonym for txtLen=1, txtRecord="", + * i.e. it creates a TXT record of length one containing a single empty string. + * RFC 1035 doesn't allow a TXT record to contain *zero* strings, so a single empty + * string is the smallest legal DNS TXT record. + * As with the other parameters, the DNSServiceRegister call copies the txtRecord + * data; e.g. if you allocated the storage for the txtRecord parameter with malloc() + * then you can safely free that memory right after the DNSServiceRegister call returns. + * + * callBack: The function to be called when the registration completes or asynchronously + * fails. The client MAY pass NULL for the callback - The client will NOT be notified + * of the default values picked on its behalf, and the client will NOT be notified of any + * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration + * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL. + * The client may still deregister the service at any time via DNSServiceRefDeallocate(). + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is never invoked and the DNSServiceRef + * is not initialized). + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceRegister +( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *name, /* may be NULL */ + const char *regtype, + const char *domain, /* may be NULL */ + const char *host, /* may be NULL */ + uint16_t port, /* In network byte order */ + uint16_t txtLen, + const void *txtRecord, /* may be NULL */ + DNSServiceRegisterReply callBack, /* may be NULL */ + void *context /* may be NULL */ +); + + +/* DNSServiceAddRecord() + * + * Add a record to a registered service. The name of the record will be the same as the + * registered service's name. + * The record can later be updated or deregistered by passing the RecordRef initialized + * by this function to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). + * + * Note that the DNSServiceAddRecord/UpdateRecord/RemoveRecord are *NOT* thread-safe + * with respect to a single DNSServiceRef. If you plan to have multiple threads + * in your program simultaneously add, update, or remove records from the same + * DNSServiceRef, then it's the caller's responsibility to use a mutex lock + * or take similar appropriate precautions to serialize those calls. + * + * Parameters; + * + * sdRef: A DNSServiceRef initialized by DNSServiceRegister(). + * + * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this + * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). + * If the above DNSServiceRef is passed to DNSServiceRefDeallocate(), RecordRef is also + * invalidated and may not be used further. + * + * flags: Currently ignored, reserved for future use. + * + * rrtype: The type of the record (e.g. kDNSServiceType_TXT, kDNSServiceType_SRV, etc) + * + * rdlen: The length, in bytes, of the rdata. + * + * rdata: The raw rdata to be contained in the added resource record. + * + * ttl: The time to live of the resource record, in seconds. + * Most clients should pass 0 to indicate that the system should + * select a sensible default value. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an + * error code indicating the error that occurred (the RecordRef is not initialized). + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceAddRecord +( + DNSServiceRef sdRef, + DNSRecordRef *RecordRef, + DNSServiceFlags flags, + uint16_t rrtype, + uint16_t rdlen, + const void *rdata, + uint32_t ttl +); + + +/* DNSServiceUpdateRecord + * + * Update a registered resource record. The record must either be: + * - The primary txt record of a service registered via DNSServiceRegister() + * - A record added to a registered service via DNSServiceAddRecord() + * - An individual record registered by DNSServiceRegisterRecord() + * + * Parameters: + * + * sdRef: A DNSServiceRef that was initialized by DNSServiceRegister() + * or DNSServiceCreateConnection(). + * + * RecordRef: A DNSRecordRef initialized by DNSServiceAddRecord, or NULL to update the + * service's primary txt record. + * + * flags: Currently ignored, reserved for future use. + * + * rdlen: The length, in bytes, of the new rdata. + * + * rdata: The new rdata to be contained in the updated resource record. + * + * ttl: The time to live of the updated resource record, in seconds. + * Most clients should pass 0 to indicate that the system should + * select a sensible default value. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an + * error code indicating the error that occurred. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord +( + DNSServiceRef sdRef, + DNSRecordRef RecordRef, /* may be NULL */ + DNSServiceFlags flags, + uint16_t rdlen, + const void *rdata, + uint32_t ttl +); + + +/* DNSServiceRemoveRecord + * + * Remove a record previously added to a service record set via DNSServiceAddRecord(), or deregister + * a record registered individually via DNSServiceRegisterRecord(). + * + * Parameters: + * + * sdRef: A DNSServiceRef initialized by DNSServiceRegister() (if the + * record being removed was registered via DNSServiceAddRecord()) or by + * DNSServiceCreateConnection() (if the record being removed was registered via + * DNSServiceRegisterRecord()). + * + * recordRef: A DNSRecordRef initialized by a successful call to DNSServiceAddRecord() + * or DNSServiceRegisterRecord(). + * + * flags: Currently ignored, reserved for future use. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an + * error code indicating the error that occurred. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceRemoveRecord +( + DNSServiceRef sdRef, + DNSRecordRef RecordRef, + DNSServiceFlags flags +); + + +/********************************************************************************************* +* +* Service Discovery +* +*********************************************************************************************/ + +/* Browse for instances of a service. + * + * DNSServiceBrowseReply() Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceBrowse(). + * + * flags: Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd. + * See flag definitions for details. + * + * interfaceIndex: The interface on which the service is advertised. This index should + * be passed to DNSServiceResolve() when resolving the service. + * + * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will + * indicate the failure that occurred. Other parameters are undefined if + * the errorCode is nonzero. + * + * serviceName: The discovered service name. This name should be displayed to the user, + * and stored for subsequent use in the DNSServiceResolve() call. + * + * regtype: The service type, which is usually (but not always) the same as was passed + * to DNSServiceBrowse(). One case where the discovered service type may + * not be the same as the requested service type is when using subtypes: + * The client may want to browse for only those ftp servers that allow + * anonymous connections. The client will pass the string "_ftp._tcp,_anon" + * to DNSServiceBrowse(), but the type of the service that's discovered + * is simply "_ftp._tcp". The regtype for each discovered service instance + * should be stored along with the name, so that it can be passed to + * DNSServiceResolve() when the service is later resolved. + * + * domain: The domain of the discovered service instance. This may or may not be the + * same as the domain that was passed to DNSServiceBrowse(). The domain for each + * discovered service instance should be stored along with the name, so that + * it can be passed to DNSServiceResolve() when the service is later resolved. + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (DNSSD_API *DNSServiceBrowseReply) +( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *serviceName, + const char *regtype, + const char *replyDomain, + void *context +); + + +/* DNSServiceBrowse() Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef + * (or, if the kDNSServiceFlagsShareConnection flag is used, + * a copy of the shared connection reference that is to be used). + * If the call succeeds then it initializes (or updates) the DNSServiceRef, + * returns kDNSServiceErr_NoError, and the browse operation + * will remain active indefinitely until the client terminates it + * by passing this DNSServiceRef to DNSServiceRefDeallocate() + * (or by closing the underlying shared connection, if used). + * + * flags: Possible values are: + * kDNSServiceFlagsShareConnection to use a shared connection. + * + * interfaceIndex: If non-zero, specifies the interface on which to browse for services + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Most applications will pass 0 to browse on all available + * interfaces. See "Constants for specifying an interface index" for more details. + * + * regtype: The service type being browsed for followed by the protocol, separated by a + * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp". + * A client may optionally specify a single subtype to perform filtered browsing: + * e.g. browsing for "_primarytype._tcp,_subtype" will discover only those + * instances of "_primarytype._tcp" that were registered specifying "_subtype" + * in their list of registered subtypes. + * + * domain: If non-NULL, specifies the domain on which to browse for services. + * Most applications will not specify a domain, instead browsing on the + * default domain(s). + * + * callBack: The function to be called when an instance of the service being browsed for + * is found, or if the call asynchronously fails. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is not invoked and the DNSServiceRef + * is not initialized). + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceBrowse +( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *regtype, + const char *domain, /* may be NULL */ + DNSServiceBrowseReply callBack, + void *context /* may be NULL */ +); + + +/* DNSServiceResolve() + * + * Resolve a service name discovered via DNSServiceBrowse() to a target host name, port number, and + * txt record. + * + * Note: Applications should NOT use DNSServiceResolve() solely for txt record monitoring - use + * DNSServiceQueryRecord() instead, as it is more efficient for this task. + * + * Note: When the desired results have been returned, the client MUST terminate the resolve by calling + * DNSServiceRefDeallocate(). + * + * Note: DNSServiceResolve() behaves correctly for typical services that have a single SRV record + * and a single TXT record. To resolve non-standard services with multiple SRV or TXT records, + * DNSServiceQueryRecord() should be used. + * + * DNSServiceResolveReply Callback Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceResolve(). + * + * flags: Possible values: kDNSServiceFlagsMoreComing + * + * interfaceIndex: The interface on which the service was resolved. + * + * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will + * indicate the failure that occurred. Other parameters are undefined if + * the errorCode is nonzero. + * + * fullname: The full service domain name, in the form ... + * (This name is escaped following standard DNS rules, making it suitable for + * passing to standard system DNS APIs such as res_query(), or to the + * special-purpose functions included in this API that take fullname parameters. + * See "Notes on DNS Name Escaping" earlier in this file for more details.) + * + * hosttarget: The target hostname of the machine providing the service. This name can + * be passed to functions like gethostbyname() to identify the host's IP address. + * + * port: The port, in network byte order, on which connections are accepted for this service. + * + * txtLen: The length of the txt record, in bytes. + * + * txtRecord: The service's primary txt record, in standard txt record format. + * + * context: The context pointer that was passed to the callout. + * + * NOTE: In earlier versions of this header file, the txtRecord parameter was declared "const char *" + * This is incorrect, since it contains length bytes which are values in the range 0 to 255, not -128 to +127. + * Depending on your compiler settings, this change may cause signed/unsigned mismatch warnings. + * These should be fixed by updating your own callback function definition to match the corrected + * function signature using "const unsigned char *txtRecord". Making this change may also fix inadvertent + * bugs in your callback function, where it could have incorrectly interpreted a length byte with value 250 + * as being -6 instead, with various bad consequences ranging from incorrect operation to software crashes. + * If you need to maintain portable code that will compile cleanly with both the old and new versions of + * this header file, you should update your callback function definition to use the correct unsigned value, + * and then in the place where you pass your callback function to DNSServiceResolve(), use a cast to eliminate + * the compiler warning, e.g.: + * DNSServiceResolve(sd, flags, index, name, regtype, domain, (DNSServiceResolveReply)MyCallback, context); + * This will ensure that your code compiles cleanly without warnings (and more importantly, works correctly) + * with both the old header and with the new corrected version. + * + */ + +typedef void (DNSSD_API *DNSServiceResolveReply) +( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *fullname, + const char *hosttarget, + uint16_t port, /* In network byte order */ + uint16_t txtLen, + const unsigned char *txtRecord, + void *context +); + + +/* DNSServiceResolve() Parameters + * + * sdRef: A pointer to an uninitialized DNSServiceRef + * (or, if the kDNSServiceFlagsShareConnection flag is used, + * a copy of the shared connection reference that is to be used). + * If the call succeeds then it initializes (or updates) the DNSServiceRef, + * returns kDNSServiceErr_NoError, and the resolve operation + * will remain active indefinitely until the client terminates it + * by passing this DNSServiceRef to DNSServiceRefDeallocate() + * (or by closing the underlying shared connection, if used). + * + * flags: Possible values are: + * kDNSServiceFlagsShareConnection to use a shared connection. + * Specifying kDNSServiceFlagsForceMulticast will cause query to be + * performed with a link-local mDNS query, even if the name is an + * apparently non-local name (i.e. a name not ending in ".local.") + * + * interfaceIndex: The interface on which to resolve the service. If this resolve call is + * as a result of a currently active DNSServiceBrowse() operation, then the + * interfaceIndex should be the index reported in the DNSServiceBrowseReply + * callback. If this resolve call is using information previously saved + * (e.g. in a preference file) for later use, then use interfaceIndex 0, because + * the desired service may now be reachable via a different physical interface. + * See "Constants for specifying an interface index" for more details. + * + * name: The name of the service instance to be resolved, as reported to the + * DNSServiceBrowseReply() callback. + * + * regtype: The type of the service instance to be resolved, as reported to the + * DNSServiceBrowseReply() callback. + * + * domain: The domain of the service instance to be resolved, as reported to the + * DNSServiceBrowseReply() callback. + * + * callBack: The function to be called when a result is found, or if the call + * asynchronously fails. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is never invoked and the DNSServiceRef + * is not initialized). + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceResolve +( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *name, + const char *regtype, + const char *domain, + DNSServiceResolveReply callBack, + void *context /* may be NULL */ +); + + +/********************************************************************************************* +* +* Querying Individual Specific Records +* +*********************************************************************************************/ + +/* DNSServiceQueryRecord + * + * Query for an arbitrary DNS record. + * + * DNSServiceQueryRecordReply() Callback Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceQueryRecord(). + * + * flags: Possible values are kDNSServiceFlagsMoreComing and + * kDNSServiceFlagsAdd. The Add flag is NOT set for PTR records + * with a ttl of 0, i.e. "Remove" events. + * + * interfaceIndex: The interface on which the query was resolved (the index for a given + * interface is determined via the if_nametoindex() family of calls). + * See "Constants for specifying an interface index" for more details. + * + * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will + * indicate the failure that occurred. Other parameters are undefined if + * errorCode is nonzero. + * + * fullname: The resource record's full domain name. + * + * rrtype: The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc) + * + * rrclass: The class of the resource record (usually kDNSServiceClass_IN). + * + * rdlen: The length, in bytes, of the resource record rdata. + * + * rdata: The raw rdata of the resource record. + * + * ttl: If the client wishes to cache the result for performance reasons, + * the TTL indicates how long the client may legitimately hold onto + * this result, in seconds. After the TTL expires, the client should + * consider the result no longer valid, and if it requires this data + * again, it should be re-fetched with a new query. Of course, this + * only applies to clients that cancel the asynchronous operation when + * they get a result. Clients that leave the asynchronous operation + * running can safely assume that the data remains valid until they + * get another callback telling them otherwise. The ttl value is not + * updated when the daemon answers from the cache, hence relying on + * the accuracy of the ttl value is not recommended. + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (DNSSD_API *DNSServiceQueryRecordReply) +( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + uint16_t rdlen, + const void *rdata, + uint32_t ttl, + void *context +); + + +/* DNSServiceQueryRecord() Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef + * (or, if the kDNSServiceFlagsShareConnection flag is used, + * a copy of the shared connection reference that is to be used). + * If the call succeeds then it initializes (or updates) the DNSServiceRef, + * returns kDNSServiceErr_NoError, and the query operation + * will remain active indefinitely until the client terminates it + * by passing this DNSServiceRef to DNSServiceRefDeallocate() + * (or by closing the underlying shared connection, if used). + * + * flags: Possible values are: + * kDNSServiceFlagsShareConnection to use a shared connection. + * kDNSServiceFlagsForceMulticast or kDNSServiceFlagsLongLivedQuery. + * Pass kDNSServiceFlagsLongLivedQuery to create a "long-lived" unicast + * query to a unicast DNS server that implements the protocol. This flag + * has no effect on link-local multicast queries. + * + * interfaceIndex: If non-zero, specifies the interface on which to issue the query + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Passing 0 causes the name to be queried for on all + * interfaces. See "Constants for specifying an interface index" for more details. + * + * fullname: The full domain name of the resource record to be queried for. + * + * rrtype: The numerical type of the resource record to be queried for + * (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc) + * + * rrclass: The class of the resource record (usually kDNSServiceClass_IN). + * + * callBack: The function to be called when a result is found, or if the call + * asynchronously fails. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is never invoked and the DNSServiceRef + * is not initialized). + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceQueryRecord +( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + DNSServiceQueryRecordReply callBack, + void *context /* may be NULL */ +); + + +/********************************************************************************************* +* +* Unified lookup of both IPv4 and IPv6 addresses for a fully qualified hostname +* +*********************************************************************************************/ + +/* DNSServiceGetAddrInfo + * + * Queries for the IP address of a hostname by using either Multicast or Unicast DNS. + * + * DNSServiceGetAddrInfoReply() parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceGetAddrInfo(). + * + * flags: Possible values are kDNSServiceFlagsMoreComing and + * kDNSServiceFlagsAdd. + * + * interfaceIndex: The interface to which the answers pertain. + * + * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will + * indicate the failure that occurred. Other parameters are + * undefined if errorCode is nonzero. + * + * hostname: The fully qualified domain name of the host to be queried for. + * + * address: IPv4 or IPv6 address. + * + * ttl: If the client wishes to cache the result for performance reasons, + * the TTL indicates how long the client may legitimately hold onto + * this result, in seconds. After the TTL expires, the client should + * consider the result no longer valid, and if it requires this data + * again, it should be re-fetched with a new query. Of course, this + * only applies to clients that cancel the asynchronous operation when + * they get a result. Clients that leave the asynchronous operation + * running can safely assume that the data remains valid until they + * get another callback telling them otherwise. The ttl value is not + * updated when the daemon answers from the cache, hence relying on + * the accuracy of the ttl value is not recommended. + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (DNSSD_API *DNSServiceGetAddrInfoReply) +( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *hostname, + const struct sockaddr *address, + uint32_t ttl, + void *context +); + + +/* DNSServiceGetAddrInfo() Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef + * (or, if the kDNSServiceFlagsShareConnection flag is used, + * a copy of the shared connection reference that is to be used). + * If the call succeeds then it initializes (or updates) the DNSServiceRef, + * returns kDNSServiceErr_NoError, and the address query operation + * will remain active indefinitely until the client terminates it + * by passing this DNSServiceRef to DNSServiceRefDeallocate() + * (or by closing the underlying shared connection, if used). + * + * flags: Possible values are: + * kDNSServiceFlagsShareConnection to use a shared connection. + * kDNSServiceFlagsForceMulticast + * + * interfaceIndex: The interface on which to issue the query. Passing 0 causes the query to be + * sent on all active interfaces via Multicast or the primary interface via Unicast. + * + * protocol: Pass in kDNSServiceProtocol_IPv4 to look up IPv4 addresses, or kDNSServiceProtocol_IPv6 + * to look up IPv6 addresses, or both to look up both kinds. If neither flag is + * set, the system will apply an intelligent heuristic, which is (currently) + * that it will attempt to look up both, except: + * + * * If "hostname" is a wide-area unicast DNS hostname (i.e. not a ".local." name) + * but this host has no routable IPv6 address, then the call will not try to + * look up IPv6 addresses for "hostname", since any addresses it found would be + * unlikely to be of any use anyway. Similarly, if this host has no routable + * IPv4 address, the call will not try to look up IPv4 addresses for "hostname". + * + * hostname: The fully qualified domain name of the host to be queried for. + * + * callBack: The function to be called when the query succeeds or fails asynchronously. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceGetAddrInfo +( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceProtocol protocol, + const char *hostname, + DNSServiceGetAddrInfoReply callBack, + void *context /* may be NULL */ +); + + +/********************************************************************************************* +* +* Special Purpose Calls: +* DNSServiceCreateConnection(), DNSServiceRegisterRecord(), DNSServiceReconfirmRecord() +* (most applications will not use these) +* +*********************************************************************************************/ + +/* DNSServiceCreateConnection() + * + * Create a connection to the daemon allowing efficient registration of + * multiple individual records. + * + * Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef. + * Deallocating the reference (via DNSServiceRefDeallocate()) + * severs the connection and cancels all operations and + * deregisters all records registered on this connection. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns + * an error code indicating the specific failure that occurred + * (in which case the DNSServiceRef is not initialized). + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceCreateConnection(DNSServiceRef *sdRef); + +/* DNSServiceRegisterRecord + * + * Register an individual resource record on a connected DNSServiceRef. + * + * Note that name conflicts occurring for records registered via this call must be handled + * by the client in the callback. + * + * DNSServiceRegisterRecordReply() parameters: + * + * sdRef: The connected DNSServiceRef initialized by + * DNSServiceCreateConnection(). + * + * RecordRef: The DNSRecordRef initialized by DNSServiceRegisterRecord(). If the above + * DNSServiceRef is passed to DNSServiceRefDeallocate(), this DNSRecordRef is + * invalidated, and may not be used further. + * + * flags: Currently unused, reserved for future use. + * + * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will + * indicate the failure that occurred (including name conflicts.) + * Other parameters are undefined if errorCode is nonzero. + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (DNSSD_API *DNSServiceRegisterRecordReply) +( + DNSServiceRef sdRef, + DNSRecordRef RecordRef, + DNSServiceFlags flags, + DNSServiceErrorType errorCode, + void *context +); + + +/* DNSServiceRegisterRecord() Parameters: + * + * sdRef: A DNSServiceRef initialized by DNSServiceCreateConnection(). + * + * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this + * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). + * (To deregister ALL records registered on a single connected DNSServiceRef + * and deallocate each of their corresponding DNSServiceRecordRefs, call + * DNSServiceRefDeallocate()). + * + * flags: One of either kDNSServiceFlagsShared, kDNSServiceFlagsUnique or kDNSServiceFlagsKnownUnique must be set. + * + * interfaceIndex: If non-zero, specifies the interface on which to register the record + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Passing 0 causes the record to be registered on all interfaces. + * See "Constants for specifying an interface index" for more details. + * + * fullname: The full domain name of the resource record. + * + * rrtype: The numerical type of the resource record (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc) + * + * rrclass: The class of the resource record (usually kDNSServiceClass_IN) + * + * rdlen: Length, in bytes, of the rdata. + * + * rdata: A pointer to the raw rdata, as it is to appear in the DNS record. + * + * ttl: The time to live of the resource record, in seconds. + * Most clients should pass 0 to indicate that the system should + * select a sensible default value. + * + * callBack: The function to be called when a result is found, or if the call + * asynchronously fails (e.g. because of a name conflict.) + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is never invoked and the DNSRecordRef is + * not initialized). + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceRegisterRecord +( + DNSServiceRef sdRef, + DNSRecordRef *RecordRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + uint16_t rdlen, + const void *rdata, + uint32_t ttl, + DNSServiceRegisterRecordReply callBack, + void *context /* may be NULL */ +); + + +/* DNSServiceReconfirmRecord + * + * Instruct the daemon to verify the validity of a resource record that appears + * to be out of date (e.g. because TCP connection to a service's target failed.) + * Causes the record to be flushed from the daemon's cache (as well as all other + * daemons' caches on the network) if the record is determined to be invalid. + * Use this routine conservatively. Reconfirming a record necessarily consumes + * network bandwidth, so this should not be done indiscriminately. + * + * Parameters: + * + * flags: Not currently used. + * + * interfaceIndex: Specifies the interface of the record in question. + * The caller must specify the interface. + * This API (by design) causes increased network traffic, so it requires + * the caller to be precise about which record should be reconfirmed. + * It is not possible to pass zero for the interface index to perform + * a "wildcard" reconfirmation, where *all* matching records are reconfirmed. + * + * fullname: The resource record's full domain name. + * + * rrtype: The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc) + * + * rrclass: The class of the resource record (usually kDNSServiceClass_IN). + * + * rdlen: The length, in bytes, of the resource record rdata. + * + * rdata: The raw rdata of the resource record. + * + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord +( + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + uint16_t rdlen, + const void *rdata +); + + +/********************************************************************************************* +* +* NAT Port Mapping +* +*********************************************************************************************/ + +/* DNSServiceNATPortMappingCreate + * + * Request a port mapping in the NAT gateway, which maps a port on the local machine + * to an external port on the NAT. The NAT should support either PCP, NAT-PMP or the + * UPnP/IGD protocol for this API to create a successful mapping. Note that this API + * currently supports IPv4 addresses/mappings only. If the NAT gateway supports PCP and + * returns an IPv6 address (incorrectly, since this API specifically requests IPv4 + * addresses), the DNSServiceNATPortMappingReply callback will be invoked with errorCode + * kDNSServiceErr_NATPortMappingUnsupported. + * + * The port mapping will be renewed indefinitely until the client process exits, or + * explicitly terminates the port mapping request by calling DNSServiceRefDeallocate(). + * The client callback will be invoked, informing the client of the NAT gateway's + * external IP address and the external port that has been allocated for this client. + * The client should then record this external IP address and port using whatever + * directory service mechanism it is using to enable peers to connect to it. + * (Clients advertising services using Wide-Area DNS-SD DO NOT need to use this API + * -- when a client calls DNSServiceRegister() NAT mappings are automatically created + * and the external IP address and port for the service are recorded in the global DNS. + * Only clients using some directory mechanism other than Wide-Area DNS-SD need to use + * this API to explicitly map their own ports.) + * + * It's possible that the client callback could be called multiple times, for example + * if the NAT gateway's IP address changes, or if a configuration change results in a + * different external port being mapped for this client. Over the lifetime of any long-lived + * port mapping, the client should be prepared to handle these notifications of changes + * in the environment, and should update its recorded address and/or port as appropriate. + * + * NOTE: There are two unusual aspects of how the DNSServiceNATPortMappingCreate API works, + * which were intentionally designed to help simplify client code: + * + * 1. It's not an error to request a NAT mapping when the machine is not behind a NAT gateway. + * In other NAT mapping APIs, if you request a NAT mapping and the machine is not behind a NAT + * gateway, then the API returns an error code -- it can't get you a NAT mapping if there's no + * NAT gateway. The DNSServiceNATPortMappingCreate API takes a different view. Working out + * whether or not you need a NAT mapping can be tricky and non-obvious, particularly on + * a machine with multiple active network interfaces. Rather than make every client recreate + * this logic for deciding whether a NAT mapping is required, the PortMapping API does that + * work for you. If the client calls the PortMapping API when the machine already has a + * routable public IP address, then instead of complaining about it and giving an error, + * the PortMapping API just invokes your callback, giving the machine's public address + * and your own port number. This means you don't need to write code to work out whether + * your client needs to call the PortMapping API -- just call it anyway, and if it wasn't + * necessary, no harm is done: + * + * - If the machine already has a routable public IP address, then your callback + * will just be invoked giving your own address and port. + * - If a NAT mapping is required and obtained, then your callback will be invoked + * giving you the external address and port. + * - If a NAT mapping is required but not obtained from the local NAT gateway, + * or the machine has no network connectivity, then your callback will be + * invoked giving zero address and port. + * + * 2. In other NAT mapping APIs, if a laptop computer is put to sleep and woken up on a new + * network, it's the client's job to notice this, and work out whether a NAT mapping + * is required on the new network, and make a new NAT mapping request if necessary. + * The DNSServiceNATPortMappingCreate API does this for you, automatically. + * The client just needs to make one call to the PortMapping API, and its callback will + * be invoked any time the mapping state changes. This property complements point (1) above. + * If the client didn't make a NAT mapping request just because it determined that one was + * not required at that particular moment in time, the client would then have to monitor + * for network state changes to determine if a NAT port mapping later became necessary. + * By unconditionally making a NAT mapping request, even when a NAT mapping not to be + * necessary, the PortMapping API will then begin monitoring network state changes on behalf of + * the client, and if a NAT mapping later becomes necessary, it will automatically create a NAT + * mapping and inform the client with a new callback giving the new address and port information. + * + * DNSServiceNATPortMappingReply() parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceNATPortMappingCreate(). + * + * flags: Currently unused, reserved for future use. + * + * interfaceIndex: The interface through which the NAT gateway is reached. + * + * errorCode: Will be kDNSServiceErr_NoError on success. + * Will be kDNSServiceErr_DoubleNAT when the NAT gateway is itself behind one or + * more layers of NAT, in which case the other parameters have the defined values. + * For other failures, will indicate the failure that occurred, and the other + * parameters are undefined. + * + * externalAddress: Four byte IPv4 address in network byte order. + * + * protocol: Will be kDNSServiceProtocol_UDP or kDNSServiceProtocol_TCP or both. + * + * internalPort: The port on the local machine that was mapped. + * + * externalPort: The actual external port in the NAT gateway that was mapped. + * This is likely to be different than the requested external port. + * + * ttl: The lifetime of the NAT port mapping created on the gateway. + * This controls how quickly stale mappings will be garbage-collected + * if the client machine crashes, suffers a power failure, is disconnected + * from the network, or suffers some other unfortunate demise which + * causes it to vanish without explicitly removing its NAT port mapping. + * It's possible that the ttl value will differ from the requested ttl value. + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (DNSSD_API *DNSServiceNATPortMappingReply) +( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + uint32_t externalAddress, /* four byte IPv4 address in network byte order */ + DNSServiceProtocol protocol, + uint16_t internalPort, /* In network byte order */ + uint16_t externalPort, /* In network byte order and may be different than the requested port */ + uint32_t ttl, /* may be different than the requested ttl */ + void *context +); + + +/* DNSServiceNATPortMappingCreate() Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef + * (or, if the kDNSServiceFlagsShareConnection flag is used, + * a copy of the shared connection reference that is to be used). + * If the call succeeds then it initializes (or updates) the DNSServiceRef, + * returns kDNSServiceErr_NoError, and the NAT port mapping + * will remain active indefinitely until the client terminates it + * by passing this DNSServiceRef to DNSServiceRefDeallocate() + * (or by closing the underlying shared connection, if used). + * + * flags: Possible values are: + * kDNSServiceFlagsShareConnection to use a shared connection. + * + * interfaceIndex: The interface on which to create port mappings in a NAT gateway. + * Passing 0 causes the port mapping request to be sent on the primary interface. + * + * protocol: To request a port mapping, pass in kDNSServiceProtocol_UDP, or kDNSServiceProtocol_TCP, + * or (kDNSServiceProtocol_UDP | kDNSServiceProtocol_TCP) to map both. + * The local listening port number must also be specified in the internalPort parameter. + * To just discover the NAT gateway's external IP address, pass zero for protocol, + * internalPort, externalPort and ttl. + * + * internalPort: The port number in network byte order on the local machine which is listening for packets. + * + * externalPort: The requested external port in network byte order in the NAT gateway that you would + * like to map to the internal port. Pass 0 if you don't care which external port is chosen for you. + * + * ttl: The requested renewal period of the NAT port mapping, in seconds. + * If the client machine crashes, suffers a power failure, is disconnected from + * the network, or suffers some other unfortunate demise which causes it to vanish + * unexpectedly without explicitly removing its NAT port mappings, then the NAT gateway + * will garbage-collect old stale NAT port mappings when their lifetime expires. + * Requesting a short TTL causes such orphaned mappings to be garbage-collected + * more promptly, but consumes system resources and network bandwidth with + * frequent renewal packets to keep the mapping from expiring. + * Requesting a long TTL is more efficient on the network, but in the event of the + * client vanishing, stale NAT port mappings will not be garbage-collected as quickly. + * Most clients should pass 0 to use a system-wide default value. + * + * callBack: The function to be called when the port mapping request succeeds or fails asynchronously. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred. + * + * If you don't actually want a port mapped, and are just calling the API + * because you want to find out the NAT's external IP address (e.g. for UI + * display) then pass zero for protocol, internalPort, externalPort and ttl. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceNATPortMappingCreate +( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceProtocol protocol, /* TCP and/or UDP */ + uint16_t internalPort, /* network byte order */ + uint16_t externalPort, /* network byte order */ + uint32_t ttl, /* time to live in seconds */ + DNSServiceNATPortMappingReply callBack, + void *context /* may be NULL */ +); + + +/********************************************************************************************* +* +* General Utility Functions +* +*********************************************************************************************/ + +/* DNSServiceConstructFullName() + * + * Concatenate a three-part domain name (as returned by the above callbacks) into a + * properly-escaped full domain name. Note that callbacks in the above functions ALREADY ESCAPE + * strings where necessary. + * + * Parameters: + * + * fullName: A pointer to a buffer that where the resulting full domain name is to be written. + * The buffer must be kDNSServiceMaxDomainName (1009) bytes in length to + * accommodate the longest legal domain name without buffer overrun. + * + * service: The service name - any dots or backslashes must NOT be escaped. + * May be NULL (to construct a PTR record name, e.g. + * "_ftp._tcp.apple.com."). + * + * regtype: The service type followed by the protocol, separated by a dot + * (e.g. "_ftp._tcp"). + * + * domain: The domain name, e.g. "apple.com.". Literal dots or backslashes, + * if any, must be escaped, e.g. "1st\. Floor.apple.com." + * + * return value: Returns kDNSServiceErr_NoError (0) on success, kDNSServiceErr_BadParam on error. + * + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceConstructFullName +( + char * const fullName, + const char * const service, /* may be NULL */ + const char * const regtype, + const char * const domain +); + + +/********************************************************************************************* +* +* TXT Record Construction Functions +* +*********************************************************************************************/ + +/* + * A typical calling sequence for TXT record construction is something like: + * + * Client allocates storage for TXTRecord data (e.g. declare buffer on the stack) + * TXTRecordCreate(); + * TXTRecordSetValue(); + * TXTRecordSetValue(); + * TXTRecordSetValue(); + * ... + * DNSServiceRegister( ... TXTRecordGetLength(), TXTRecordGetBytesPtr() ... ); + * TXTRecordDeallocate(); + * Explicitly deallocate storage for TXTRecord data (if not allocated on the stack) + */ + + +/* TXTRecordRef + * + * Opaque internal data type. + * Note: Represents a DNS-SD TXT record. + */ + +typedef union _TXTRecordRef_t { char PrivateData[16]; char *ForceNaturalAlignment; } TXTRecordRef; + + +/* TXTRecordCreate() + * + * Creates a new empty TXTRecordRef referencing the specified storage. + * + * If the buffer parameter is NULL, or the specified storage size is not + * large enough to hold a key subsequently added using TXTRecordSetValue(), + * then additional memory will be added as needed using malloc(). Note that + * an existing TXT record buffer should not be passed to TXTRecordCreate + * to create a copy of another TXT Record. The correct way to copy TXTRecordRef + * is creating an empty TXTRecordRef with TXTRecordCreate() first, and using + * TXTRecordSetValue to set the same value. + * + * On some platforms, when memory is low, malloc() may fail. In this + * case, TXTRecordSetValue() will return kDNSServiceErr_NoMemory, and this + * error condition will need to be handled as appropriate by the caller. + * + * You can avoid the need to handle this error condition if you ensure + * that the storage you initially provide is large enough to hold all + * the key/value pairs that are to be added to the record. + * The caller can precompute the exact length required for all of the + * key/value pairs to be added, or simply provide a fixed-sized buffer + * known in advance to be large enough. + * A no-value (key-only) key requires (1 + key length) bytes. + * A key with empty value requires (1 + key length + 1) bytes. + * A key with non-empty value requires (1 + key length + 1 + value length). + * For most applications, DNS-SD TXT records are generally + * less than 100 bytes, so in most cases a simple fixed-sized + * 256-byte buffer will be more than sufficient. + * Recommended size limits for DNS-SD TXT Records are discussed in RFC 6763 + * + * + * Note: When passing parameters to and from these TXT record APIs, + * the key name does not include the '=' character. The '=' character + * is the separator between the key and value in the on-the-wire + * packet format; it is not part of either the key or the value. + * + * txtRecord: A pointer to an uninitialized TXTRecordRef. + * + * bufferLen: The size of the storage provided in the "buffer" parameter. + * + * buffer: Optional caller-supplied storage used to hold the TXTRecord data. + * This storage must remain valid for as long as + * the TXTRecordRef. + */ + +DNSSD_EXPORT +void DNSSD_API TXTRecordCreate +( + TXTRecordRef *txtRecord, + uint16_t bufferLen, + void *buffer +); + + +/* TXTRecordDeallocate() + * + * Releases any resources allocated in the course of preparing a TXT Record + * using TXTRecordCreate()/TXTRecordSetValue()/TXTRecordRemoveValue(). + * Ownership of the buffer provided in TXTRecordCreate() returns to the client. + * + * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). + * + */ + +DNSSD_EXPORT +void DNSSD_API TXTRecordDeallocate +( + TXTRecordRef *txtRecord +); + + +/* TXTRecordSetValue() + * + * Adds a key (optionally with value) to a TXTRecordRef. If the "key" already + * exists in the TXTRecordRef, then the current value will be replaced with + * the new value. + * Keys may exist in four states with respect to a given TXT record: + * - Absent (key does not appear at all) + * - Present with no value ("key" appears alone) + * - Present with empty value ("key=" appears in TXT record) + * - Present with non-empty value ("key=value" appears in TXT record) + * For more details refer to "Data Syntax for DNS-SD TXT Records" in RFC 6763 + * + * + * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). + * + * key: A null-terminated string which only contains printable ASCII + * values (0x20-0x7E), excluding '=' (0x3D). Keys should be + * 9 characters or fewer (not counting the terminating null). + * + * valueSize: The size of the value. + * + * value: Any binary value. For values that represent + * textual data, UTF-8 is STRONGLY recommended. + * For values that represent textual data, valueSize + * should NOT include the terminating null (if any) + * at the end of the string. + * If NULL, then "key" will be added with no value. + * If non-NULL but valueSize is zero, then "key=" will be + * added with empty value. + * + * return value: Returns kDNSServiceErr_NoError on success. + * Returns kDNSServiceErr_Invalid if the "key" string contains + * illegal characters. + * Returns kDNSServiceErr_NoMemory if adding this key would + * exceed the available storage. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API TXTRecordSetValue +( + TXTRecordRef *txtRecord, + const char *key, + uint8_t valueSize, /* may be zero */ + const void *value /* may be NULL */ +); + + +/* TXTRecordRemoveValue() + * + * Removes a key from a TXTRecordRef. The "key" must be an + * ASCII string which exists in the TXTRecordRef. + * + * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). + * + * key: A key name which exists in the TXTRecordRef. + * + * return value: Returns kDNSServiceErr_NoError on success. + * Returns kDNSServiceErr_NoSuchKey if the "key" does not + * exist in the TXTRecordRef. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API TXTRecordRemoveValue +( + TXTRecordRef *txtRecord, + const char *key +); + + +/* TXTRecordGetLength() + * + * Allows you to determine the length of the raw bytes within a TXTRecordRef. + * + * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). + * + * return value: Returns the size of the raw bytes inside a TXTRecordRef + * which you can pass directly to DNSServiceRegister() or + * to DNSServiceUpdateRecord(). + * Returns 0 if the TXTRecordRef is empty. + */ + +DNSSD_EXPORT +uint16_t DNSSD_API TXTRecordGetLength +( + const TXTRecordRef *txtRecord +); + + +/* TXTRecordGetBytesPtr() + * + * Allows you to retrieve a pointer to the raw bytes within a TXTRecordRef. + * + * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). + * + * return value: Returns a pointer to the raw bytes inside the TXTRecordRef + * which you can pass directly to DNSServiceRegister() or + * to DNSServiceUpdateRecord(). + */ + +DNSSD_EXPORT +const void * DNSSD_API TXTRecordGetBytesPtr +( + const TXTRecordRef *txtRecord +); + + +/********************************************************************************************* +* +* TXT Record Parsing Functions +* +*********************************************************************************************/ + +/* + * A typical calling sequence for TXT record parsing is something like: + * + * Receive TXT record data in DNSServiceResolve() callback + * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something + * val1ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key1", &len1); + * val2ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key2", &len2); + * ... + * memcpy(myval1, val1ptr, len1); + * memcpy(myval2, val2ptr, len2); + * ... + * return; + * + * If you wish to retain the values after return from the DNSServiceResolve() + * callback, then you need to copy the data to your own storage using memcpy() + * or similar, as shown in the example above. + * + * If for some reason you need to parse a TXT record you built yourself + * using the TXT record construction functions above, then you can do + * that using TXTRecordGetLength and TXTRecordGetBytesPtr calls: + * TXTRecordGetValue(TXTRecordGetLength(x), TXTRecordGetBytesPtr(x), key, &len); + * + * Most applications only fetch keys they know about from a TXT record and + * ignore the rest. + * However, some debugging tools wish to fetch and display all keys. + * To do that, use the TXTRecordGetCount() and TXTRecordGetItemAtIndex() calls. + */ + +/* TXTRecordContainsKey() + * + * Allows you to determine if a given TXT Record contains a specified key. + * + * txtLen: The size of the received TXT Record. + * + * txtRecord: Pointer to the received TXT Record bytes. + * + * key: A null-terminated ASCII string containing the key name. + * + * return value: Returns 1 if the TXT Record contains the specified key. + * Otherwise, it returns 0. + */ + +DNSSD_EXPORT +int DNSSD_API TXTRecordContainsKey +( + uint16_t txtLen, + const void *txtRecord, + const char *key +); + + +/* TXTRecordGetValuePtr() + * + * Allows you to retrieve the value for a given key from a TXT Record. + * + * txtLen: The size of the received TXT Record + * + * txtRecord: Pointer to the received TXT Record bytes. + * + * key: A null-terminated ASCII string containing the key name. + * + * valueLen: On output, will be set to the size of the "value" data. + * + * return value: Returns NULL if the key does not exist in this TXT record, + * or exists with no value (to differentiate between + * these two cases use TXTRecordContainsKey()). + * Returns pointer to location within TXT Record bytes + * if the key exists with empty or non-empty value. + * For empty value, valueLen will be zero. + * For non-empty value, valueLen will be length of value data. + */ + +DNSSD_EXPORT +const void * DNSSD_API TXTRecordGetValuePtr +( + uint16_t txtLen, + const void *txtRecord, + const char *key, + uint8_t *valueLen +); + + +/* TXTRecordGetCount() + * + * Returns the number of keys stored in the TXT Record. The count + * can be used with TXTRecordGetItemAtIndex() to iterate through the keys. + * + * txtLen: The size of the received TXT Record. + * + * txtRecord: Pointer to the received TXT Record bytes. + * + * return value: Returns the total number of keys in the TXT Record. + * + */ + +DNSSD_EXPORT +uint16_t DNSSD_API TXTRecordGetCount +( + uint16_t txtLen, + const void *txtRecord +); + + +/* TXTRecordGetItemAtIndex() + * + * Allows you to retrieve a key name and value pointer, given an index into + * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1. + * It's also possible to iterate through keys in a TXT record by simply + * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero + * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid. + * + * On return: + * For keys with no value, *value is set to NULL and *valueLen is zero. + * For keys with empty value, *value is non-NULL and *valueLen is zero. + * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero. + * + * txtLen: The size of the received TXT Record. + * + * txtRecord: Pointer to the received TXT Record bytes. + * + * itemIndex: An index into the TXT Record. + * + * keyBufLen: The size of the string buffer being supplied. + * + * key: A string buffer used to store the key name. + * On return, the buffer contains a null-terminated C-string + * giving the key name. DNS-SD TXT keys are usually + * 9 characters or fewer. To hold the maximum possible + * key name, the buffer should be 256 bytes long. + * + * valueLen: On output, will be set to the size of the "value" data. + * + * value: On output, *value is set to point to location within TXT + * Record bytes that holds the value data. + * + * return value: Returns kDNSServiceErr_NoError on success. + * Returns kDNSServiceErr_NoMemory if keyBufLen is too short. + * Returns kDNSServiceErr_Invalid if index is greater than + * TXTRecordGetCount()-1. + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex +( + uint16_t txtLen, + const void *txtRecord, + uint16_t itemIndex, + uint16_t keyBufLen, + char *key, + uint8_t *valueLen, + const void **value +); + +#if _DNS_SD_LIBDISPATCH +/* + * DNSServiceSetDispatchQueue + * + * Allows you to schedule a DNSServiceRef on a serial dispatch queue for receiving asynchronous + * callbacks. It's the clients responsibility to ensure that the provided dispatch queue is running. + * + * A typical application that uses CFRunLoopRun or dispatch_main on its main thread will + * usually schedule DNSServiceRefs on its main queue (which is always a serial queue) + * using "DNSServiceSetDispatchQueue(sdref, dispatch_get_main_queue());" + * + * If there is any error during the processing of events, the application callback will + * be called with an error code. For shared connections, each subordinate DNSServiceRef + * will get its own error callback. Currently these error callbacks only happen + * if the daemon is manually terminated or crashes, and the error + * code in this case is kDNSServiceErr_ServiceNotRunning. The application must call + * DNSServiceRefDeallocate to free the DNSServiceRef when it gets such an error code. + * These error callbacks are rare and should not normally happen on customer machines, + * but application code should be written defensively to handle such error callbacks + * gracefully if they occur. + * + * After using DNSServiceSetDispatchQueue on a DNSServiceRef, calling DNSServiceProcessResult + * on the same DNSServiceRef will result in undefined behavior and should be avoided. + * + * Once the application successfully schedules a DNSServiceRef on a serial dispatch queue using + * DNSServiceSetDispatchQueue, it cannot remove the DNSServiceRef from the dispatch queue, or use + * DNSServiceSetDispatchQueue a second time to schedule the DNSServiceRef onto a different serial dispatch + * queue. Once scheduled onto a dispatch queue a DNSServiceRef will deliver events to that queue until + * the application no longer requires that operation and terminates it using DNSServiceRefDeallocate. + * Note that the call to DNSServiceRefDeallocate() must be done on the same queue originally passed + * as an argument to DNSServiceSetDispatchQueue(). + * + * service: DNSServiceRef that was allocated and returned to the application, when the + * application calls one of the DNSService API. + * + * queue: dispatch queue where the application callback will be scheduled + * + * return value: Returns kDNSServiceErr_NoError on success. + * Returns kDNSServiceErr_NoMemory if it cannot create a dispatch source + * Returns kDNSServiceErr_BadParam if the service param is invalid or the + * queue param is invalid + */ + +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceSetDispatchQueue +( + DNSServiceRef service, + dispatch_queue_t queue +); +#endif //_DNS_SD_LIBDISPATCH + +#if !defined(_WIN32) +typedef void (DNSSD_API *DNSServiceSleepKeepaliveReply) +( + DNSServiceRef sdRef, + DNSServiceErrorType errorCode, + void *context +); +DNSSD_EXPORT +DNSServiceErrorType DNSSD_API DNSServiceSleepKeepalive +( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + int fd, + unsigned int timeout, + DNSServiceSleepKeepaliveReply callBack, + void *context +); +#endif + +/* Some C compiler cleverness. We can make the compiler check certain things for us, + * and report errors at compile-time if anything is wrong. The usual way to do this would + * be to use a run-time "if" statement or the conventional run-time "assert" mechanism, but + * then you don't find out what's wrong until you run the software. This way, if the assertion + * condition is false, the array size is negative, and the complier complains immediately. + */ + +struct CompileTimeAssertionChecks_DNS_SD +{ + char assert0[(sizeof(union _TXTRecordRef_t) == 16) ? 1 : -1]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _DNS_SD_H */ diff --git a/illumos-x86_64/usr/include/door.h b/illumos-x86_64/usr/include/door.h new file mode 100644 index 00000000..70d94f44 --- /dev/null +++ b/illumos-x86_64/usr/include/door.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DOOR_H +#define _DOOR_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* + * Doors API + */ + +typedef void door_server_procedure_t(void *, char *, size_t, door_desc_t *, + uint_t); + +int door_create(door_server_procedure_t *, void *, uint_t); +int door_revoke(int); +int door_info(int, door_info_t *); +int door_call(int, door_arg_t *); +int door_return(char *, size_t, door_desc_t *, uint_t); +int door_cred(door_cred_t *); +int door_ucred(ucred_t **); +int door_bind(int); +int door_unbind(void); +int door_getparam(int, int, size_t *); +int door_setparam(int, int, size_t); + +typedef void door_server_func_t(door_info_t *); +door_server_func_t *door_server_create(door_server_func_t *); + +typedef int door_xcreate_server_func_t(door_info_t *, + void *(*)(void *), void *, void *); +typedef void door_xcreate_thrsetup_func_t(void *); + +int door_xcreate(door_server_procedure_t *, void *, uint_t, + door_xcreate_server_func_t *, door_xcreate_thrsetup_func_t *, + void *, int); + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DOOR_H */ diff --git a/illumos-x86_64/usr/include/dtrace.h b/illumos-x86_64/usr/include/dtrace.h new file mode 100644 index 00000000..7d86cdc7 --- /dev/null +++ b/illumos-x86_64/usr/include/dtrace.h @@ -0,0 +1,605 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2014, 2016 by Delphix. All rights reserved. + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +#ifndef _DTRACE_H +#define _DTRACE_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DTrace Dynamic Tracing Software: Library Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and DTrace subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose except those expressly outlined in dtrace(4D) and libdtrace(3LIB). + * Please refer to the "Solaris Dynamic Tracing Guide" for more information. + */ + +#define DTRACE_VERSION 3 /* library ABI interface version */ + +struct ps_prochandle; +struct dt_node; +typedef struct dtrace_hdl dtrace_hdl_t; +typedef struct dtrace_prog dtrace_prog_t; +typedef struct dtrace_vector dtrace_vector_t; +typedef struct dtrace_aggdata dtrace_aggdata_t; + +#define DTRACE_O_NODEV 0x01 /* do not open dtrace(4D) device */ +#define DTRACE_O_NOSYS 0x02 /* do not load /system/object modules */ +#define DTRACE_O_LP64 0x04 /* force D compiler to be LP64 */ +#define DTRACE_O_ILP32 0x08 /* force D compiler to be ILP32 */ +#define DTRACE_O_MASK 0x0f /* mask of valid flags to dtrace_open */ + +extern dtrace_hdl_t *dtrace_open(int, int, int *); +extern dtrace_hdl_t *dtrace_vopen(int, int, int *, + const dtrace_vector_t *, void *); + +extern int dtrace_go(dtrace_hdl_t *); +extern int dtrace_stop(dtrace_hdl_t *); +extern void dtrace_sleep(dtrace_hdl_t *); +extern void dtrace_close(dtrace_hdl_t *); + +extern int dtrace_errno(dtrace_hdl_t *); +extern const char *dtrace_errmsg(dtrace_hdl_t *, int); +extern const char *dtrace_faultstr(dtrace_hdl_t *, int); +extern const char *dtrace_subrstr(dtrace_hdl_t *, int); + +extern int dtrace_setopt(dtrace_hdl_t *, const char *, const char *); +extern int dtrace_getopt(dtrace_hdl_t *, const char *, dtrace_optval_t *); + +extern void dtrace_update(dtrace_hdl_t *); +extern int dtrace_ctlfd(dtrace_hdl_t *); + +/* + * DTrace Program Interface + * + * DTrace programs can be created by compiling ASCII text files containing + * D programs or by compiling in-memory C strings that specify a D program. + * Once created, callers can examine the list of program statements and + * enable the probes and actions described by these statements. + */ + +typedef struct dtrace_proginfo { + dtrace_attribute_t dpi_descattr; /* minimum probedesc attributes */ + dtrace_attribute_t dpi_stmtattr; /* minimum statement attributes */ + uint_t dpi_aggregates; /* number of aggregates specified in program */ + uint_t dpi_recgens; /* number of record generating probes in prog */ + uint_t dpi_matches; /* number of probes matched by program */ + uint_t dpi_speculations; /* number of speculations specified in prog */ +} dtrace_proginfo_t; + +#define DTRACE_C_DIFV 0x0001 /* DIF verbose mode: show each compiled DIFO */ +#define DTRACE_C_EMPTY 0x0002 /* Permit compilation of empty D source files */ +#define DTRACE_C_ZDEFS 0x0004 /* Permit probe defs that match zero probes */ +#define DTRACE_C_EATTR 0x0008 /* Error if program attributes less than min */ +#define DTRACE_C_CPP 0x0010 /* Preprocess input file with cpp(1) utility */ +#define DTRACE_C_KNODEF 0x0020 /* Permit unresolved kernel symbols in DIFO */ +#define DTRACE_C_UNODEF 0x0040 /* Permit unresolved user symbols in DIFO */ +#define DTRACE_C_PSPEC 0x0080 /* Interpret ambiguous specifiers as probes */ +#define DTRACE_C_ETAGS 0x0100 /* Prefix error messages with error tags */ +#define DTRACE_C_ARGREF 0x0200 /* Do not require all macro args to be used */ +#define DTRACE_C_DEFARG 0x0800 /* Use 0/"" as value for unspecified args */ +#define DTRACE_C_NOLIBS 0x1000 /* Do not process D system libraries */ +#define DTRACE_C_CTL 0x2000 /* Only process control directives */ +#define DTRACE_C_MASK 0x3bff /* mask of all valid flags to dtrace_*compile */ + +extern dtrace_prog_t *dtrace_program_strcompile(dtrace_hdl_t *, + const char *, dtrace_probespec_t, uint_t, int, char *const []); + +extern dtrace_prog_t *dtrace_program_fcompile(dtrace_hdl_t *, + FILE *, uint_t, int, char *const []); + +extern int dtrace_program_exec(dtrace_hdl_t *, dtrace_prog_t *, + dtrace_proginfo_t *); +extern void dtrace_program_info(dtrace_hdl_t *, dtrace_prog_t *, + dtrace_proginfo_t *); + +#define DTRACE_D_STRIP 0x01 /* strip non-loadable sections from program */ +#define DTRACE_D_PROBES 0x02 /* include provider and probe definitions */ +#define DTRACE_D_MASK 0x03 /* mask of valid flags to dtrace_dof_create */ + +extern int dtrace_program_link(dtrace_hdl_t *, dtrace_prog_t *, + uint_t, const char *, int, char *const []); + +extern int dtrace_program_header(dtrace_hdl_t *, FILE *, const char *); + +extern void *dtrace_dof_create(dtrace_hdl_t *, dtrace_prog_t *, uint_t); +extern void dtrace_dof_destroy(dtrace_hdl_t *, void *); + +extern void *dtrace_getopt_dof(dtrace_hdl_t *); +extern void *dtrace_geterr_dof(dtrace_hdl_t *); + +typedef struct dtrace_stmtdesc { + dtrace_ecbdesc_t *dtsd_ecbdesc; /* ECB description */ + dtrace_actdesc_t *dtsd_action; /* action list */ + dtrace_actdesc_t *dtsd_action_last; /* last action in action list */ + void *dtsd_aggdata; /* aggregation data */ + void *dtsd_fmtdata; /* type-specific output data */ + void *dtsd_strdata; /* type-specific string data */ + void (*dtsd_callback)(); /* callback function for EPID */ + void *dtsd_data; /* callback data pointer */ + dtrace_attribute_t dtsd_descattr; /* probedesc attributes */ + dtrace_attribute_t dtsd_stmtattr; /* statement attributes */ +} dtrace_stmtdesc_t; + +typedef int dtrace_stmt_f(dtrace_hdl_t *, dtrace_prog_t *, + dtrace_stmtdesc_t *, void *); + +extern dtrace_stmtdesc_t *dtrace_stmt_create(dtrace_hdl_t *, + dtrace_ecbdesc_t *); +extern dtrace_actdesc_t *dtrace_stmt_action(dtrace_hdl_t *, + dtrace_stmtdesc_t *); +extern int dtrace_stmt_add(dtrace_hdl_t *, dtrace_prog_t *, + dtrace_stmtdesc_t *); +extern int dtrace_stmt_iter(dtrace_hdl_t *, dtrace_prog_t *, + dtrace_stmt_f *, void *); +extern void dtrace_stmt_destroy(dtrace_hdl_t *, dtrace_stmtdesc_t *); + +/* + * DTrace Data Consumption Interface + */ +typedef enum { + DTRACEFLOW_ENTRY, + DTRACEFLOW_RETURN, + DTRACEFLOW_NONE +} dtrace_flowkind_t; + +#define DTRACE_CONSUME_ERROR -1 /* error while processing */ +#define DTRACE_CONSUME_THIS 0 /* consume this probe/record */ +#define DTRACE_CONSUME_NEXT 1 /* advance to next probe/rec */ +#define DTRACE_CONSUME_ABORT 2 /* abort consumption */ + +typedef struct dtrace_probedata { + dtrace_hdl_t *dtpda_handle; /* handle to DTrace library */ + dtrace_eprobedesc_t *dtpda_edesc; /* enabled probe description */ + dtrace_probedesc_t *dtpda_pdesc; /* probe description */ + processorid_t dtpda_cpu; /* CPU for data */ + caddr_t dtpda_data; /* pointer to raw data */ + dtrace_flowkind_t dtpda_flow; /* flow kind */ + const char *dtpda_prefix; /* recommended flow prefix */ + int dtpda_indent; /* recommended flow indent */ +} dtrace_probedata_t; + +typedef int dtrace_consume_probe_f(const dtrace_probedata_t *, void *); +typedef int dtrace_consume_rec_f(const dtrace_probedata_t *, + const dtrace_recdesc_t *, void *); + +extern int dtrace_consume(dtrace_hdl_t *, FILE *, + dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *); + +#define DTRACE_STATUS_NONE 0 /* no status; not yet time */ +#define DTRACE_STATUS_OKAY 1 /* status okay */ +#define DTRACE_STATUS_EXITED 2 /* exit() was called; tracing stopped */ +#define DTRACE_STATUS_FILLED 3 /* fill buffer filled; tracing stoped */ +#define DTRACE_STATUS_STOPPED 4 /* tracing already stopped */ + +extern int dtrace_status(dtrace_hdl_t *); + +/* + * DTrace Formatted Output Interfaces + * + * To format output associated with a given dtrace_stmtdesc, the caller can + * invoke one of the following functions, passing the opaque dtsd_fmtdata and a + * list of record descriptions. These functions return either -1 to indicate + * an error, or a positive integer indicating the number of records consumed. + * For anonymous enablings, the consumer can use the dtrd_format member of + * the record description to obtain a format description. The dtfd_string + * member of the format description may be passed to dtrace_print{fa}_create() + * to create the opaque format data. + */ +extern void *dtrace_printf_create(dtrace_hdl_t *, const char *); +extern void *dtrace_printa_create(dtrace_hdl_t *, const char *); +extern size_t dtrace_printf_format(dtrace_hdl_t *, void *, char *, size_t); + +extern int dtrace_fprintf(dtrace_hdl_t *, FILE *, void *, + const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t, + const void *, size_t); + +extern int dtrace_fprinta(dtrace_hdl_t *, FILE *, void *, + const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t, + const void *, size_t); + +extern int dtrace_system(dtrace_hdl_t *, FILE *, void *, + const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t, + const void *, size_t); + +extern int dtrace_freopen(dtrace_hdl_t *, FILE *, void *, + const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t, + const void *, size_t); + +/* + * Type-specific output printing + * + * The print() action will associate a string data record that is actually the + * fully-qualified type name of the data traced by the DIFEXPR action. This is + * stored in the same 'format' record from the kernel, but we know by virtue of + * the fact that the action is still DIFEXPR that it is actually a reference to + * plain string data. + */ +extern int dtrace_print(dtrace_hdl_t *, FILE *, const char *, + caddr_t, size_t); + +/* + * DTrace Work Interface + */ +typedef enum { + DTRACE_WORKSTATUS_ERROR = -1, + DTRACE_WORKSTATUS_OKAY, + DTRACE_WORKSTATUS_DONE +} dtrace_workstatus_t; + +extern dtrace_workstatus_t dtrace_work(dtrace_hdl_t *, FILE *, + dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *); + +/* + * DTrace Handler Interface + */ +#define DTRACE_HANDLE_ABORT -1 /* abort current operation */ +#define DTRACE_HANDLE_OK 0 /* handled okay; continue */ + +typedef struct dtrace_errdata { + dtrace_hdl_t *dteda_handle; /* handle to DTrace library */ + dtrace_eprobedesc_t *dteda_edesc; /* enabled probe inducing err */ + dtrace_probedesc_t *dteda_pdesc; /* probe inducing error */ + processorid_t dteda_cpu; /* CPU of error */ + int dteda_action; /* action inducing error */ + int dteda_offset; /* offset in DIFO of error */ + int dteda_fault; /* specific fault */ + uint64_t dteda_addr; /* address of fault, if any */ + const char *dteda_msg; /* preconstructed message */ +} dtrace_errdata_t; + +typedef int dtrace_handle_err_f(const dtrace_errdata_t *, void *); +extern int dtrace_handle_err(dtrace_hdl_t *, dtrace_handle_err_f *, void *); + +typedef enum { + DTRACEDROP_PRINCIPAL, /* drop to principal buffer */ + DTRACEDROP_AGGREGATION, /* drop to aggregation buffer */ + DTRACEDROP_DYNAMIC, /* dynamic drop */ + DTRACEDROP_DYNRINSE, /* dyn drop due to rinsing */ + DTRACEDROP_DYNDIRTY, /* dyn drop due to dirty */ + DTRACEDROP_SPEC, /* speculative drop */ + DTRACEDROP_SPECBUSY, /* spec drop due to busy */ + DTRACEDROP_SPECUNAVAIL, /* spec drop due to unavail */ + DTRACEDROP_STKSTROVERFLOW, /* stack string tab overflow */ + DTRACEDROP_DBLERROR /* error in ERROR probe */ +} dtrace_dropkind_t; + +typedef struct dtrace_dropdata { + dtrace_hdl_t *dtdda_handle; /* handle to DTrace library */ + processorid_t dtdda_cpu; /* CPU, if any */ + dtrace_dropkind_t dtdda_kind; /* kind of drop */ + uint64_t dtdda_drops; /* number of drops */ + uint64_t dtdda_total; /* total drops */ + const char *dtdda_msg; /* preconstructed message */ +} dtrace_dropdata_t; + +typedef int dtrace_handle_drop_f(const dtrace_dropdata_t *, void *); +extern int dtrace_handle_drop(dtrace_hdl_t *, dtrace_handle_drop_f *, void *); + +typedef void dtrace_handle_proc_f(struct ps_prochandle *, const char *, void *); +extern int dtrace_handle_proc(dtrace_hdl_t *, dtrace_handle_proc_f *, void *); + +#define DTRACE_BUFDATA_AGGKEY 0x0001 /* aggregation key */ +#define DTRACE_BUFDATA_AGGVAL 0x0002 /* aggregation value */ +#define DTRACE_BUFDATA_AGGFORMAT 0x0004 /* aggregation format data */ +#define DTRACE_BUFDATA_AGGLAST 0x0008 /* last for this key/val */ + +typedef struct dtrace_bufdata { + dtrace_hdl_t *dtbda_handle; /* handle to DTrace library */ + const char *dtbda_buffered; /* buffered output */ + dtrace_probedata_t *dtbda_probe; /* probe data */ + const dtrace_recdesc_t *dtbda_recdesc; /* record description */ + const dtrace_aggdata_t *dtbda_aggdata; /* aggregation data, if agg. */ + uint32_t dtbda_flags; /* flags; see above */ +} dtrace_bufdata_t; + +typedef int dtrace_handle_buffered_f(const dtrace_bufdata_t *, void *); +extern int dtrace_handle_buffered(dtrace_hdl_t *, + dtrace_handle_buffered_f *, void *); + +typedef struct dtrace_setoptdata { + dtrace_hdl_t *dtsda_handle; /* handle to DTrace library */ + const dtrace_probedata_t *dtsda_probe; /* probe data */ + const char *dtsda_option; /* option that was set */ + dtrace_optval_t dtsda_oldval; /* old value */ + dtrace_optval_t dtsda_newval; /* new value */ +} dtrace_setoptdata_t; + +typedef int dtrace_handle_setopt_f(const dtrace_setoptdata_t *, void *); +extern int dtrace_handle_setopt(dtrace_hdl_t *, + dtrace_handle_setopt_f *, void *); + +/* + * DTrace Aggregate Interface + */ + +#define DTRACE_A_PERCPU 0x0001 +#define DTRACE_A_KEEPDELTA 0x0002 +#define DTRACE_A_ANONYMOUS 0x0004 +#define DTRACE_A_TOTAL 0x0008 +#define DTRACE_A_MINMAXBIN 0x0010 +#define DTRACE_A_HASNEGATIVES 0x0020 +#define DTRACE_A_HASPOSITIVES 0x0040 + +#define DTRACE_AGGZOOM_MAX 0.95 /* height of max bar */ + +#define DTRACE_AGGWALK_ERROR -1 /* error while processing */ +#define DTRACE_AGGWALK_NEXT 0 /* proceed to next element */ +#define DTRACE_AGGWALK_ABORT 1 /* abort aggregation walk */ +#define DTRACE_AGGWALK_CLEAR 2 /* clear this element */ +#define DTRACE_AGGWALK_NORMALIZE 3 /* normalize this element */ +#define DTRACE_AGGWALK_DENORMALIZE 4 /* denormalize this element */ +#define DTRACE_AGGWALK_REMOVE 5 /* remove this element */ + +struct dtrace_aggdata { + dtrace_hdl_t *dtada_handle; /* handle to DTrace library */ + dtrace_aggdesc_t *dtada_desc; /* aggregation description */ + dtrace_eprobedesc_t *dtada_edesc; /* enabled probe description */ + dtrace_probedesc_t *dtada_pdesc; /* probe description */ + caddr_t dtada_data; /* pointer to raw data */ + uint64_t dtada_normal; /* the normal -- 1 for denorm */ + size_t dtada_size; /* total size of the data */ + caddr_t dtada_delta; /* delta data, if available */ + caddr_t *dtada_percpu; /* per CPU data, if avail */ + caddr_t *dtada_percpu_delta; /* per CPU delta, if avail */ + int64_t dtada_total; /* per agg total, if avail */ + uint16_t dtada_minbin; /* minimum bin, if avail */ + uint16_t dtada_maxbin; /* maximum bin, if avail */ + uint32_t dtada_flags; /* flags */ +}; + +typedef int dtrace_aggregate_f(const dtrace_aggdata_t *, void *); +typedef int dtrace_aggregate_walk_f(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); +typedef int dtrace_aggregate_walk_joined_f(const dtrace_aggdata_t **, + const int, void *); + +extern void dtrace_aggregate_clear(dtrace_hdl_t *); +extern int dtrace_aggregate_snap(dtrace_hdl_t *); +extern int dtrace_aggregate_print(dtrace_hdl_t *, FILE *, + dtrace_aggregate_walk_f *); + +extern int dtrace_aggregate_walk(dtrace_hdl_t *, dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_joined(dtrace_hdl_t *, + dtrace_aggvarid_t *, int, dtrace_aggregate_walk_joined_f *, void *); + +extern int dtrace_aggregate_walk_sorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_keysorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_valsorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_keyvarsorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_valvarsorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_keyrevsorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_valrevsorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_keyvarrevsorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +extern int dtrace_aggregate_walk_valvarrevsorted(dtrace_hdl_t *, + dtrace_aggregate_f *, void *); + +#define DTRACE_AGD_PRINTED 0x1 /* aggregation printed in program */ + +/* + * DTrace Process Control Interface + * + * Library clients who wish to have libdtrace create or grab processes for + * monitoring of their symbol table changes may use these interfaces to + * request that libdtrace obtain control of the process using libproc. + */ + +extern struct ps_prochandle *dtrace_proc_create(dtrace_hdl_t *, + const char *, char *const *); + +extern struct ps_prochandle *dtrace_proc_grab(dtrace_hdl_t *, pid_t, int); +extern void dtrace_proc_release(dtrace_hdl_t *, struct ps_prochandle *); +extern void dtrace_proc_continue(dtrace_hdl_t *, struct ps_prochandle *); + +/* + * DTrace Object, Symbol, and Type Interfaces + * + * Library clients can use libdtrace to perform symbol and C type information + * lookups by symbol name, symbol address, or C type name, or to lookup meta- + * information cached for each of the program objects in use by DTrace. The + * resulting struct contain pointers to arbitrary-length strings, including + * object, symbol, and type names, that are persistent until the next call to + * dtrace_update(). Once dtrace_update() is called, any cached values must + * be flushed and not used subsequently by the client program. + */ + +#define DTRACE_OBJ_EXEC ((const char *)0L) /* primary executable file */ +#define DTRACE_OBJ_RTLD ((const char *)1L) /* run-time link-editor */ +#define DTRACE_OBJ_CDEFS ((const char *)2L) /* C include definitions */ +#define DTRACE_OBJ_DDEFS ((const char *)3L) /* D program definitions */ +#define DTRACE_OBJ_EVERY ((const char *)-1L) /* all known objects */ +#define DTRACE_OBJ_KMODS ((const char *)-2L) /* all kernel objects */ +#define DTRACE_OBJ_UMODS ((const char *)-3L) /* all user objects */ + +typedef struct dtrace_objinfo { + const char *dto_name; /* object file scope name */ + const char *dto_file; /* object file path (if any) */ + int dto_id; /* object file id (if any) */ + uint_t dto_flags; /* object flags (see below) */ + GElf_Addr dto_text_va; /* address of text section */ + GElf_Xword dto_text_size; /* size of text section */ + GElf_Addr dto_data_va; /* address of data section */ + GElf_Xword dto_data_size; /* size of data section */ + GElf_Addr dto_bss_va; /* address of BSS */ + GElf_Xword dto_bss_size; /* size of BSS */ +} dtrace_objinfo_t; + +#define DTRACE_OBJ_F_KERNEL 0x1 /* object is a kernel module */ +#define DTRACE_OBJ_F_PRIMARY 0x2 /* object is a primary module */ + +typedef int dtrace_obj_f(dtrace_hdl_t *, const dtrace_objinfo_t *, void *); + +extern int dtrace_object_iter(dtrace_hdl_t *, dtrace_obj_f *, void *); +extern int dtrace_object_info(dtrace_hdl_t *, const char *, dtrace_objinfo_t *); + +typedef struct dtrace_syminfo { + const char *dts_object; /* object name */ + const char *dts_name; /* symbol name */ + ulong_t dts_id; /* symbol id */ +} dtrace_syminfo_t; + +extern int dtrace_lookup_by_name(dtrace_hdl_t *, const char *, const char *, + GElf_Sym *, dtrace_syminfo_t *); + +extern int dtrace_lookup_by_addr(dtrace_hdl_t *, GElf_Addr addr, + GElf_Sym *, dtrace_syminfo_t *); + +typedef struct dtrace_typeinfo { + const char *dtt_object; /* object containing type */ + ctf_file_t *dtt_ctfp; /* CTF container handle */ + ctf_id_t dtt_type; /* CTF type identifier */ + uint_t dtt_flags; /* Misc. flags */ +} dtrace_typeinfo_t; + +#define DTT_FL_USER 0x1 /* user type */ + +extern int dtrace_lookup_by_type(dtrace_hdl_t *, const char *, const char *, + dtrace_typeinfo_t *); + +extern int dtrace_symbol_type(dtrace_hdl_t *, const GElf_Sym *, + const dtrace_syminfo_t *, dtrace_typeinfo_t *); + +extern int dtrace_type_strcompile(dtrace_hdl_t *, + const char *, dtrace_typeinfo_t *); + +extern int dtrace_type_fcompile(dtrace_hdl_t *, + FILE *, dtrace_typeinfo_t *); + +extern struct dt_node *dt_compile_sugar(dtrace_hdl_t *, + struct dt_node *); + + +/* + * DTrace Probe Interface + * + * Library clients can use these functions to iterate over the set of available + * probe definitions and inquire as to their attributes. The probe iteration + * interfaces report probes that are declared as well as those from dtrace(4D). + */ +typedef struct dtrace_probeinfo { + dtrace_attribute_t dtp_attr; /* name attributes */ + dtrace_attribute_t dtp_arga; /* arg attributes */ + const dtrace_typeinfo_t *dtp_argv; /* arg types */ + int dtp_argc; /* arg count */ +} dtrace_probeinfo_t; + +typedef int dtrace_probe_f(dtrace_hdl_t *, const dtrace_probedesc_t *, void *); + +extern int dtrace_probe_iter(dtrace_hdl_t *, + const dtrace_probedesc_t *pdp, dtrace_probe_f *, void *); + +extern int dtrace_probe_info(dtrace_hdl_t *, + const dtrace_probedesc_t *, dtrace_probeinfo_t *); + +/* + * DTrace Vector Interface + * + * The DTrace library normally speaks directly to dtrace(4D). However, + * this communication may be vectored elsewhere. Consumers who wish to + * perform a vectored open must fill in the vector, and use the dtrace_vopen() + * entry point to obtain a library handle. + */ +struct dtrace_vector { + int (*dtv_ioctl)(void *, int, void *); + int (*dtv_lookup_by_addr)(void *, GElf_Addr, GElf_Sym *, + dtrace_syminfo_t *); + int (*dtv_status)(void *, processorid_t); + long (*dtv_sysconf)(void *, int); +}; + +/* + * DTrace Utility Functions + * + * Library clients can use these functions to convert addresses strings, to + * convert between string and integer probe descriptions and the + * dtrace_probedesc_t representation, and to perform similar conversions on + * stability attributes. + */ +extern int dtrace_addr2str(dtrace_hdl_t *, uint64_t, char *, int); +extern int dtrace_uaddr2str(dtrace_hdl_t *, pid_t, uint64_t, char *, int); + +extern int dtrace_xstr2desc(dtrace_hdl_t *, dtrace_probespec_t, + const char *, int, char *const [], dtrace_probedesc_t *); + +extern int dtrace_str2desc(dtrace_hdl_t *, dtrace_probespec_t, + const char *, dtrace_probedesc_t *); + +extern int dtrace_id2desc(dtrace_hdl_t *, dtrace_id_t, dtrace_probedesc_t *); + +#define DTRACE_DESC2STR_MAX 1024 /* min buf size for dtrace_desc2str() */ + +extern char *dtrace_desc2str(const dtrace_probedesc_t *, char *, size_t); + +#define DTRACE_ATTR2STR_MAX 64 /* min buf size for dtrace_attr2str() */ + +extern char *dtrace_attr2str(dtrace_attribute_t, char *, size_t); +extern int dtrace_str2attr(const char *, dtrace_attribute_t *); + +extern const char *dtrace_stability_name(dtrace_stability_t); +extern const char *dtrace_class_name(dtrace_class_t); + +extern int dtrace_provider_modules(dtrace_hdl_t *, const char **, int); + +extern const char *const _dtrace_version; +extern int _dtrace_debug; + +#ifdef __cplusplus +} +#endif + +#endif /* _DTRACE_H */ diff --git a/illumos-x86_64/usr/include/editline/readline.h b/illumos-x86_64/usr/include/editline/readline.h new file mode 100644 index 00000000..03e2d2eb --- /dev/null +++ b/illumos-x86_64/usr/include/editline/readline.h @@ -0,0 +1,277 @@ +/* $NetBSD: readline.h,v 1.55 2023/04/25 17:51:32 christos Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jaromir Dolecek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _READLINE_H_ +#define _READLINE_H_ + +#include +#include + +/* list of readline stuff supported by editline library's readline wrapper */ + +/* typedefs */ +typedef int rl_linebuf_func_t(const char *, int); +typedef void rl_voidfunc_t(void); +typedef void rl_vintfunc_t(int); +typedef void rl_vcpfunc_t(char *); +typedef char **rl_completion_func_t(const char *, int, int); +typedef char *rl_compentry_func_t(const char *, int); +typedef void rl_compdisp_func_t(char **, int, int); +typedef int rl_command_func_t(int, int); +typedef int rl_hook_func_t(void); +typedef int rl_icppfunc_t(char **); + +/* only supports length */ +typedef struct { + int length; +} HISTORY_STATE; + +typedef void *histdata_t; + +typedef struct _hist_entry { + const char *line; + histdata_t data; +} HIST_ENTRY; + +typedef struct _keymap_entry { + char type; +#define ISFUNC 0 +#define ISKMAP 1 +#define ISMACR 2 + rl_linebuf_func_t *function; +} KEYMAP_ENTRY; + +#define KEYMAP_SIZE 256 + +typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; +typedef KEYMAP_ENTRY *Keymap; + +#define control_character_threshold 0x20 +#define control_character_bit 0x40 + +#ifndef CTRL +#include +#if !defined(__sun) && !defined(__hpux) && !defined(_AIX) +#include +#endif +#ifndef CTRL +#define CTRL(c) ((c) & 037) +#endif +#endif +#ifndef UNCTRL +#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit) +#endif + +#define RUBOUT 0x7f +#define ABORT_CHAR CTRL('G') +#define RL_READLINE_VERSION 0x0402 +#define RL_PROMPT_START_IGNORE '\1' +#define RL_PROMPT_END_IGNORE '\2' + +#define RL_STATE_NONE 0x000000 +#define RL_STATE_DONE 0x000001 + +#define RL_SETSTATE(x) (rl_readline_state |= ((unsigned long) x)) +#define RL_UNSETSTATE(x) (rl_readline_state &= ~((unsigned long) x)) +#define RL_ISSTATE(x) (rl_readline_state & ((unsigned long) x)) + +/* global variables used by readline enabled applications */ +#ifdef __cplusplus +extern "C" { +#endif +extern const char *rl_library_version; +extern int rl_readline_version; +extern const char *rl_readline_name; +extern FILE *rl_instream; +extern FILE *rl_outstream; +extern char *rl_line_buffer; +extern int rl_point, rl_end; +extern const char *rl_basic_quote_characters; +extern const char *rl_basic_word_break_characters; +extern char *rl_completer_word_break_characters; +extern const char *rl_completer_quote_characters; +extern rl_compentry_func_t *rl_completion_entry_function; +extern char *(*rl_completion_word_break_hook)(void); +extern rl_completion_func_t *rl_attempted_completion_function; +extern int rl_attempted_completion_over; +extern int rl_completion_type; +extern int rl_completion_query_items; +extern const char *rl_special_prefixes; +extern int rl_completion_append_character; +extern int rl_inhibit_completion; +extern rl_hook_func_t *rl_pre_input_hook; +extern rl_hook_func_t *rl_startup_hook; +extern char *rl_terminal_name; +extern int rl_already_prompted; +extern char *rl_prompt; +extern int rl_done; +extern rl_vcpfunc_t *rl_linefunc; +extern rl_hook_func_t *rl_startup1_hook; +extern char *rl_prompt_saved; +extern int history_base, history_length; +extern int history_offset; +extern char history_expansion_char; +extern char history_subst_char; +extern char *history_no_expand_chars; +extern rl_linebuf_func_t *history_inhibit_expansion_function; +extern int max_input_history; + +/* + * The following is not implemented + */ +extern unsigned long rl_readline_state; +extern int rl_catch_signals; +extern int rl_catch_sigwinch; +extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, + emacs_meta_keymap, + emacs_ctlx_keymap; +extern int rl_filename_completion_desired; +extern int rl_ignore_completion_duplicates; +extern int (*rl_getc_function)(FILE *); +extern rl_voidfunc_t *rl_redisplay_function; +extern rl_compdisp_func_t *rl_completion_display_matches_hook; +extern rl_vintfunc_t *rl_prep_term_function; +extern rl_voidfunc_t *rl_deprep_term_function; +extern rl_hook_func_t *rl_event_hook; +extern int readline_echoing_p; +extern int _rl_print_completions_horizontally; +extern int _rl_complete_mark_directories; +extern rl_icppfunc_t *rl_directory_completion_hook; +extern int rl_completion_suppress_append; +extern int rl_sort_completion_matches; +extern int _rl_completion_prefix_display_length; +extern int _rl_echoing_p; +extern int history_max_entries; +extern char *rl_display_prompt; +extern int rl_erase_empty_line; + +/* supported functions */ +char *readline(const char *); +int rl_initialize(void); + +void using_history(void); +int add_history(const char *); +void clear_history(void); +int append_history(int, const char *); +void stifle_history(int); +int unstifle_history(void); +int history_is_stifled(void); +int where_history(void); +HIST_ENTRY *current_history(void); +HIST_ENTRY *history_get(int); +HIST_ENTRY *remove_history(int); +HIST_ENTRY *replace_history_entry(int, const char *, histdata_t); +int history_total_bytes(void); +int history_set_pos(int); +HIST_ENTRY *previous_history(void); +HIST_ENTRY *next_history(void); +HIST_ENTRY **history_list(void); +int history_search(const char *, int); +int history_search_prefix(const char *, int); +int history_search_pos(const char *, int, int); +int read_history(const char *); +int write_history(const char *); +int history_truncate_file(const char *, int); +int history_expand(char *, char **); +char **history_tokenize(const char *); +const char *get_history_event(const char *, int *, int); +char *history_arg_extract(int, int, const char *); + +char *tilde_expand(char *); +char *filename_completion_function(const char *, int); +char *username_completion_function(const char *, int); +int rl_complete(int, int); +int rl_read_key(void); +char **completion_matches(/* const */ char *, rl_compentry_func_t *); +void rl_display_match_list(char **, int, int); + +int rl_insert(int, int); +int rl_insert_text(const char *); +int rl_reset_terminal(const char *); +void rl_resize_terminal(void); +int rl_bind_key(int, rl_command_func_t *); +int rl_newline(int, int); +void rl_callback_read_char(void); +void rl_callback_handler_install(const char *, rl_vcpfunc_t *); +void rl_callback_handler_remove(void); +void rl_redisplay(void); +int rl_get_previous_history(int, int); +void rl_prep_terminal(int); +void rl_deprep_terminal(void); +int rl_read_init_file(const char *); +int rl_parse_and_bind(const char *); +int rl_variable_bind(const char *, const char *); +int rl_stuff_char(int); +int rl_add_defun(const char *, rl_command_func_t *, int); +HISTORY_STATE *history_get_history_state(void); +void rl_get_screen_size(int *, int *); +void rl_set_screen_size(int, int); +char *rl_filename_completion_function(const char *, int); +int _rl_abort_internal(void); +int _rl_qsort_string_compare(char **, char **); +char **rl_completion_matches(const char *, rl_compentry_func_t *); +void rl_forced_update_display(void); +int rl_set_prompt(const char *); +int rl_on_new_line(void); +void rl_reset_after_signal(void); +void rl_echo_signal_char(int); +int rl_crlf(void); +int rl_ding(void); +char *rl_copy_text(int, int); +void rl_replace_line(const char *, int); +int rl_delete_text(int, int); +void rl_message(const char *format, ...) + __attribute__((__format__(__printf__, 1, 2))); +void rl_save_prompt(void); +void rl_restore_prompt(void); + +/* + * The following are not implemented + */ +int rl_kill_text(int, int); +Keymap rl_get_keymap(void); +void rl_set_keymap(Keymap); +Keymap rl_make_bare_keymap(void); +int rl_generic_bind(int, const char *, const char *, Keymap); +int rl_bind_key_in_map(int, rl_command_func_t *, Keymap); +int rl_set_key(const char *, rl_command_func_t *, Keymap); +void rl_cleanup_after_signal(void); +void rl_free_line_state(void); +int rl_set_keyboard_input_timeout(int); +int rl_abort(int, int); +int rl_set_keymap_name(const char *, Keymap); +histdata_t free_history_entry(HIST_ENTRY *); +void _rl_erase_entire_line(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _READLINE_H_ */ diff --git a/illumos-x86_64/usr/include/elf.h b/illumos-x86_64/usr/include/elf.h new file mode 100644 index 00000000..c6ff42d2 --- /dev/null +++ b/illumos-x86_64/usr/include/elf.h @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _ELF_H +#define _ELF_H + +#include + +#endif /* _ELF_H */ diff --git a/illumos-x86_64/usr/include/endian.h b/illumos-x86_64/usr/include/endian.h new file mode 100644 index 00000000..78ca13ce --- /dev/null +++ b/illumos-x86_64/usr/include/endian.h @@ -0,0 +1,74 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _ENDIAN_H +#define _ENDIAN_H + +/* + * Endian conversion routines, see endian(3C) + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __PDP_ENDIAN 3412 + +#if defined(_LITTLE_ENDIAN) +#define __BYTE_ORDER LITTLE_ENDIAN +#elif defined(_BIG_ENDIAN) +#define __BYTE_ORDER BIG_ENDIAN +#else +#error "Unknown byte order" +#endif /* _LITTLE_ENDIAN */ + +#define LITTLE_ENDIAN __LITTLE_ENDIAN +#define BIG_ENDIAN __BIG_ENDIAN +#define BYTE_ORDER __BYTE_ORDER + +extern uint16_t htobe16(uint16_t); +extern uint32_t htobe32(uint32_t); +extern uint64_t htobe64(uint64_t); + +extern uint16_t htole16(uint16_t); +extern uint32_t htole32(uint32_t); +extern uint64_t htole64(uint64_t); + +/* Supply both the old and new BSD names */ +extern uint16_t betoh16(uint16_t); +extern uint16_t letoh16(uint16_t); +extern uint16_t be16toh(uint16_t); +extern uint16_t le16toh(uint16_t); + +extern uint32_t betoh32(uint32_t); +extern uint32_t letoh32(uint32_t); +extern uint32_t be32toh(uint32_t); +extern uint32_t le32toh(uint32_t); + +extern uint64_t betoh64(uint64_t); +extern uint64_t letoh64(uint64_t); +extern uint64_t be64toh(uint64_t); +extern uint64_t le64toh(uint64_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _ENDIAN_H */ diff --git a/illumos-x86_64/usr/include/err.h b/illumos-x86_64/usr/include/err.h new file mode 100644 index 00000000..3650a059 --- /dev/null +++ b/illumos-x86_64/usr/include/err.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _ERR_H +#define _ERR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* Program exit and warning calls */ +void err(int, const char *, ...) __PRINTFLIKE(2) __NORETURN; +void verr(int, const char *, va_list) __VPRINTFLIKE(2) __NORETURN; +void errc(int, int, const char *, ...) __PRINTFLIKE(3) __NORETURN; +void verrc(int, int, const char *, va_list) __VPRINTFLIKE(3) __NORETURN; +void errx(int, const char *, ...) __PRINTFLIKE(2) __NORETURN; +void verrx(int, const char *, va_list) __VPRINTFLIKE(2) __NORETURN; +void warn(const char *, ...) __PRINTFLIKE(1); +void vwarn(const char *, va_list) __VPRINTFLIKE(1); +void warnc(int, const char *, ...) __PRINTFLIKE(2); +void vwarnc(int, const char *, va_list) __VPRINTFLIKE(2); +void warnx(const char *, ...) __PRINTFLIKE(1); +void vwarnx(const char *, va_list) __VPRINTFLIKE(1); + +#ifdef __cplusplus +} +#endif + +#endif /* _ERR_H */ diff --git a/illumos-x86_64/usr/include/errno.h b/illumos-x86_64/usr/include/errno.h new file mode 100644 index 00000000..f52fdeae --- /dev/null +++ b/illumos-x86_64/usr/include/errno.h @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _ERRNO_H +#define _ERRNO_H + +/* + * Error codes + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_LP64) +/* + * The symbols _sys_errlist and _sys_nerr are not visible in the + * LP64 libc. Use strerror(3C) instead. + */ +#endif /* _LP64 */ + +#if defined(_REENTRANT) || defined(_TS_ERRNO) || _POSIX_C_SOURCE - 0 >= 199506L +extern int *___errno(); +#define errno (*(___errno())) +#else +extern int errno; +/* ANSI C++ requires that errno be a macro */ +#if __cplusplus >= 199711L +#define errno errno +#endif +#endif /* defined(_REENTRANT) || defined(_TS_ERRNO) */ + +#if __EXT1_VISIBLE +/* ISO/IEC 9899:2011 K.3.2.2 */ +#ifndef _ERRNO_T_DEFINED +#define _ERRNO_T_DEFINED +typedef int errno_t; +#endif +#endif /* __EXT1_VISIBLE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ERRNO_H */ diff --git a/illumos-x86_64/usr/include/eti.h b/illumos-x86_64/usr/include/eti.h new file mode 100644 index 00000000..a72a4a40 --- /dev/null +++ b/illumos-x86_64/usr/include/eti.h @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _ETI_H +#define _ETI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_COMMAND (KEY_MAX + 512) + +typedef int OPTIONS; + +typedef char * (* PTF_charP) (); +typedef void (* PTF_void) (); +typedef int (* PTF_int) (); + +#define E_OK 0 +#define E_SYSTEM_ERROR -1 +#define E_BAD_ARGUMENT -2 +#define E_POSTED -3 +#define E_CONNECTED -4 +#define E_BAD_STATE -5 +#define E_NO_ROOM -6 +#define E_NOT_POSTED -7 +#define E_UNKNOWN_COMMAND -8 +#define E_NO_MATCH -9 +#define E_NOT_SELECTABLE -10 +#define E_NOT_CONNECTED -11 +#define E_REQUEST_DENIED -12 +#define E_INVALID_FIELD -13 +#define E_CURRENT -14 + +#ifdef __cplusplus +} +#endif + +#endif /* _ETI_H */ diff --git a/illumos-x86_64/usr/include/euc.h b/illumos-x86_64/usr/include/euc.h new file mode 100644 index 00000000..ae2f6883 --- /dev/null +++ b/illumos-x86_64/usr/include/euc.h @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _EUC_H +#define _EUC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int csetcol(int n); /* Returns # of columns for codeset n. */ +extern int csetlen(int n); /* Returns # of bytes excluding SSx. */ +extern int euclen(const unsigned char *s); +extern int euccol(const unsigned char *s); +extern int eucscol(const unsigned char *str); + +/* Returns code set number for the first byte of an EUC char. */ +#define csetno(c) \ + (((c)&0x80)?(((c)&0xff) == SS2)?2:((((c)&0xff) == SS3)?3:1):0) + +/* + * Copied from _wchar.h of SVR4 + */ +#define multibyte (__ctype[520] > 1) +#define eucw1 __ctype[514] +#define eucw2 __ctype[515] +#define eucw3 __ctype[516] +#define scrw1 __ctype[517] +#define scrw2 __ctype[518] +#define scrw3 __ctype[519] + +#ifdef __cplusplus +} +#endif + +#endif /* _EUC_H */ diff --git a/illumos-x86_64/usr/include/exacct.h b/illumos-x86_64/usr/include/exacct.h new file mode 100644 index 00000000..a208f7a1 --- /dev/null +++ b/illumos-x86_64/usr/include/exacct.h @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _EXACCT_H +#define _EXACCT_H + +/* + * exacct item, group, and object definitions as well as structure manipulation + * and conversion routines are given in sys/exacct.h. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ea_open positioning options: passed in via the aflags argument, these flags + * determine whether the newly opened file is positioned for reading prior to + * its first record, or after its last. + */ +#define EO_HEAD 0x0 /* open file positioned at first object */ +#define EO_TAIL 0x1 /* open file positioned at last object */ +#define EO_POSN_MSK 0x1 + +/* + * ea_open validation options: passed in via the aflags argument, these flags + * specify whether the open operation should validate the header on the input + * file. The EO_NO_VALID_HDR is useful in the case that no header is present on + * the file, but the version and file type checks are omitted, meaning that + * incompatibilities might not be caught immediately. + */ +#define EO_VALID_HDR 0x0 /* validate header on opening file */ +#define EO_NO_VALID_HDR 0x2 /* omit header validation */ +#define EO_VALIDATE_MSK 0x2 + +typedef struct _ea_file { + void *ef_opaque_ptr[8]; + offset_t ef_opaque_off[3]; + int ef_opaque_int[6]; +} ea_file_t; + +extern int ea_error(void); +extern int ea_open(ea_file_t *, const char *, const char *, int, int, mode_t); +extern int ea_fdopen(ea_file_t *, int, const char *, int, int); +extern void ea_clear(ea_file_t *); +extern int ea_close(ea_file_t *); +extern int ea_match_object_catalog(ea_object_t *, ea_catalog_t); +extern ea_object_type_t ea_next_object(ea_file_t *, ea_object_t *); +extern ea_object_type_t ea_previous_object(ea_file_t *, ea_object_t *); +extern ea_object_type_t ea_get_object(ea_file_t *, ea_object_t *); +extern ea_object_type_t ea_unpack_object(ea_object_t **, int, void *, size_t); +extern int ea_write_object(ea_file_t *, ea_object_t *); +extern const char *ea_get_creator(ea_file_t *); +extern const char *ea_get_hostname(ea_file_t *); +extern ea_object_t *ea_copy_object(const ea_object_t *); +extern ea_object_t *ea_copy_object_tree(const ea_object_t *); +extern ea_object_t *ea_get_object_tree(ea_file_t *, uint32_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _EXACCT_H */ diff --git a/illumos-x86_64/usr/include/exacct_impl.h b/illumos-x86_64/usr/include/exacct_impl.h new file mode 100644 index 00000000..9887de10 --- /dev/null +++ b/illumos-x86_64/usr/include/exacct_impl.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _EXACCT_IMPL_H +#define _EXACCT_IMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _ea_file_depth { + int efd_nobjs; /* number of objects in group */ + int efd_obj; /* index of curr object within group */ +} ea_file_depth_t; + +typedef struct _ea_file_impl { + char *ef_filename; /* file name */ + char *ef_creator; /* file creator */ + char *ef_hostname; /* file hostname */ + FILE *ef_fp; /* file stream pointer */ + ea_file_depth_t *ef_depth; /* pointer to depth stack */ + char *ef_buf; /* pointer for buffer consumption */ + ssize_t ef_bufsize; /* remaining bytes in buffer */ + void *ef_lpad[1]; + offset_t ef_advance; /* bytes to advance on next op */ + offset_t ef_opad[2]; + mode_t ef_oflags; /* flags to open(2) */ + int ef_fd; /* file descriptor */ + int ef_version; /* exacct file version */ + int ef_ndeep; /* current depth in allocated stack */ + int ef_mxdeep; /* maximum depth of allocated stack */ + int ef_ipad[1]; +} ea_file_impl_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _EXACCT_IMPL_H */ diff --git a/illumos-x86_64/usr/include/exec_attr.h b/illumos-x86_64/usr/include/exec_attr.h new file mode 100644 index 00000000..c3660de4 --- /dev/null +++ b/illumos-x86_64/usr/include/exec_attr.h @@ -0,0 +1,147 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _EXEC_ATTR_H +#define _EXEC_ATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include +#include + + +#define EXECATTR_FILENAME "/etc/security/exec_attr" +#define EXECATTR_DB_NAME "exec_attr.org_dir" +#define EXECATTR_DB_NCOL 7 /* total columns */ +#define EXECATTR_DB_NKEYCOL 3 /* total searchable columns */ +#define EXECATTR_DB_TBLT "exec_attr_tbl" +#define EXECATTR_NAME_DEFAULT_KW "nobody" + +#define EXECATTR_COL0_KW "name" +#define EXECATTR_COL1_KW "policy" +#define EXECATTR_COL2_KW "type" +#define EXECATTR_COL3_KW "res1" +#define EXECATTR_COL4_KW "res2" +#define EXECATTR_COL5_KW "id" +#define EXECATTR_COL6_KW "attr" + +/* + * indices of searchable columns + */ +#define EXECATTR_KEYCOL0 0 /* name */ +#define EXECATTR_KEYCOL1 1 /* policy */ +#define EXECATTR_KEYCOL2 5 /* id */ + + +/* + * Some macros used internally by the nsswitch code + */ + +/* + * These macros are bitmasks. GET_ONE and GET_ALL are bitfield 0 + * and thus mutually exclusive. __SEARCH_ALL_POLLS is bitfield + * 1 and can be logically ORed with GET_ALL if one wants to get + * all matching profiles from all policies, not just the ones from + * the currently active policy + * + * Testing for these values should be done using the IS_* macros + * defined below. + */ +#define GET_ONE 0 +#define GET_ALL 1 +#define __SEARCH_ALL_POLS 2 + +/* get only one exec_attr from list */ +#define IS_GET_ONE(f) (((f) & GET_ALL) == 0) +/* get all matching exec_attrs in list */ +#define IS_GET_ALL(f) (((f) & GET_ALL) == 1) +/* search all existing policies */ +#define IS_SEARCH_ALL(f) (((f) & __SEARCH_ALL_POLS) == __SEARCH_ALL_POLS) + +/* + * Key words used in the exec_attr database + */ +#define EXECATTR_EUID_KW "euid" +#define EXECATTR_EGID_KW "egid" +#define EXECATTR_UID_KW "uid" +#define EXECATTR_GID_KW "gid" +#define EXECATTR_LPRIV_KW "limitprivs" +#define EXECATTR_IPRIV_KW "privs" + +/* + * Nsswitch representation of execution attributes. + */ +typedef struct execstr_s { + char *name; /* profile name */ + char *policy; /* suser/rbac/tsol */ + char *type; /* cmd/act */ + char *res1; /* reserved for future use */ + char *res2; /* reserved for future use */ + char *id; /* unique ID */ + char *attr; /* string of key-value pair attributes */ + struct execstr_s *next; /* pointer to next entry */ +} execstr_t; + +typedef struct execattr_s { + char *name; /* profile name */ + char *policy; /* suser/rbac/tsol */ + char *type; /* cmd/act */ + char *res1; /* reserved for future use */ + char *res2; /* reserved for future use */ + char *id; /* unique ID */ + kva_t *attr; /* array of key-value pair attributes */ + struct execattr_s *next; /* pointer to next entry */ +} execattr_t; + +typedef struct __private_execattr { + const char *name; + const char *type; + const char *id; + const char *policy; + int search_flag; + execstr_t *head_exec; + execstr_t *prev_exec; +} _priv_execattr; /* Un-supported. For Sun internal use only */ + + +extern execattr_t *getexecattr(void); +extern execattr_t *getexecuser(const char *, const char *, const char *, int); +extern execattr_t *getexecprof(const char *, const char *, const char *, int); +extern execattr_t *match_execattr(execattr_t *, const char *, const char *, \ + const char *); +extern void free_execattr(execattr_t *); +extern void setexecattr(void); +extern void endexecattr(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _EXEC_ATTR_H */ diff --git a/illumos-x86_64/usr/include/execinfo.h b/illumos-x86_64/usr/include/execinfo.h new file mode 100644 index 00000000..c4e954b7 --- /dev/null +++ b/illumos-x86_64/usr/include/execinfo.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _EXECINFO_H +#define _EXECINFO_H + +/* + * These functions provide glibc-compatible backtrace functionality. + * Improved functionality is available using Solaris-specific APIs; + * see man page for walkcontext(), printstack() and addtosymstr(). + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern int backtrace(void **, int); +extern char **backtrace_symbols(void *const *, int); +extern void backtrace_symbols_fd(void *const *, int, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _EXECINFO_H */ diff --git a/illumos-x86_64/usr/include/expat.h b/illumos-x86_64/usr/include/expat.h new file mode 100644 index 00000000..bb9cdedb --- /dev/null +++ b/illumos-x86_64/usr/include/expat.h @@ -0,0 +1,1090 @@ +/* + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 1997-2000 Thai Open Source Software Center Ltd + Copyright (c) 2000 Clark Cooper + Copyright (c) 2000-2005 Fred L. Drake, Jr. + Copyright (c) 2001-2002 Greg Stein + Copyright (c) 2002-2016 Karl Waclawek + Copyright (c) 2016-2025 Sebastian Pipping + Copyright (c) 2016 Cristian Rodríguez + Copyright (c) 2016 Thomas Beutlich + Copyright (c) 2017 Rhodri James + Copyright (c) 2022 Thijs Schreijer + Copyright (c) 2023 Hanno Böck + Copyright (c) 2023 Sony Corporation / Snild Dolkow + Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp> + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef Expat_INCLUDED +# define Expat_INCLUDED 1 + +# include +# include "expat_external.h" + +# ifdef __cplusplus +extern "C" { +# endif + +struct XML_ParserStruct; +typedef struct XML_ParserStruct *XML_Parser; + +typedef unsigned char XML_Bool; +# define XML_TRUE ((XML_Bool)1) +# define XML_FALSE ((XML_Bool)0) + +/* The XML_Status enum gives the possible return values for several + API functions. The preprocessor #defines are included so this + stanza can be added to code that still needs to support older + versions of Expat 1.95.x: + + #ifndef XML_STATUS_OK + #define XML_STATUS_OK 1 + #define XML_STATUS_ERROR 0 + #endif + + Otherwise, the #define hackery is quite ugly and would have been + dropped. +*/ +enum XML_Status { + XML_STATUS_ERROR = 0, +# define XML_STATUS_ERROR XML_STATUS_ERROR + XML_STATUS_OK = 1, +# define XML_STATUS_OK XML_STATUS_OK + XML_STATUS_SUSPENDED = 2 +# define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED +}; + +enum XML_Error { + XML_ERROR_NONE, + XML_ERROR_NO_MEMORY, + XML_ERROR_SYNTAX, + XML_ERROR_NO_ELEMENTS, + XML_ERROR_INVALID_TOKEN, + XML_ERROR_UNCLOSED_TOKEN, + XML_ERROR_PARTIAL_CHAR, + XML_ERROR_TAG_MISMATCH, + XML_ERROR_DUPLICATE_ATTRIBUTE, + XML_ERROR_JUNK_AFTER_DOC_ELEMENT, + XML_ERROR_PARAM_ENTITY_REF, + XML_ERROR_UNDEFINED_ENTITY, + XML_ERROR_RECURSIVE_ENTITY_REF, + XML_ERROR_ASYNC_ENTITY, + XML_ERROR_BAD_CHAR_REF, + XML_ERROR_BINARY_ENTITY_REF, + XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, + XML_ERROR_MISPLACED_XML_PI, + XML_ERROR_UNKNOWN_ENCODING, + XML_ERROR_INCORRECT_ENCODING, + XML_ERROR_UNCLOSED_CDATA_SECTION, + XML_ERROR_EXTERNAL_ENTITY_HANDLING, + XML_ERROR_NOT_STANDALONE, + XML_ERROR_UNEXPECTED_STATE, + XML_ERROR_ENTITY_DECLARED_IN_PE, + XML_ERROR_FEATURE_REQUIRES_XML_DTD, + XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, + /* Added in 1.95.7. */ + XML_ERROR_UNBOUND_PREFIX, + /* Added in 1.95.8. */ + XML_ERROR_UNDECLARING_PREFIX, + XML_ERROR_INCOMPLETE_PE, + XML_ERROR_XML_DECL, + XML_ERROR_TEXT_DECL, + XML_ERROR_PUBLICID, + XML_ERROR_SUSPENDED, + XML_ERROR_NOT_SUSPENDED, + XML_ERROR_ABORTED, + XML_ERROR_FINISHED, + XML_ERROR_SUSPEND_PE, + /* Added in 2.0. */ + XML_ERROR_RESERVED_PREFIX_XML, + XML_ERROR_RESERVED_PREFIX_XMLNS, + XML_ERROR_RESERVED_NAMESPACE_URI, + /* Added in 2.2.1. */ + XML_ERROR_INVALID_ARGUMENT, + /* Added in 2.3.0. */ + XML_ERROR_NO_BUFFER, + /* Added in 2.4.0. */ + XML_ERROR_AMPLIFICATION_LIMIT_BREACH, + /* Added in 2.6.4. */ + XML_ERROR_NOT_STARTED, +}; + +enum XML_Content_Type { + XML_CTYPE_EMPTY = 1, + XML_CTYPE_ANY, + XML_CTYPE_MIXED, + XML_CTYPE_NAME, + XML_CTYPE_CHOICE, + XML_CTYPE_SEQ +}; + +enum XML_Content_Quant { + XML_CQUANT_NONE, + XML_CQUANT_OPT, + XML_CQUANT_REP, + XML_CQUANT_PLUS +}; + +/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be + XML_CQUANT_NONE, and the other fields will be zero or NULL. + If type == XML_CTYPE_MIXED, then quant will be NONE or REP and + numchildren will contain number of elements that may be mixed in + and children point to an array of XML_Content cells that will be + all of XML_CTYPE_NAME type with no quantification. + + If type == XML_CTYPE_NAME, then the name points to the name, and + the numchildren field will be zero and children will be NULL. The + quant fields indicates any quantifiers placed on the name. + + CHOICE and SEQ will have name NULL, the number of children in + numchildren and children will point, recursively, to an array + of XML_Content cells. + + The EMPTY, ANY, and MIXED types will only occur at top level. +*/ + +typedef struct XML_cp XML_Content; + +struct XML_cp { + enum XML_Content_Type type; + enum XML_Content_Quant quant; + XML_Char *name; + unsigned int numchildren; + XML_Content *children; +}; + +/* This is called for an element declaration. See above for + description of the model argument. It's the user code's responsibility + to free model when finished with it. See XML_FreeContentModel. + There is no need to free the model from the handler, it can be kept + around and freed at a later stage. +*/ +typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData, + const XML_Char *name, + XML_Content *model); + +XMLPARSEAPI(void) +XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl); + +/* The Attlist declaration handler is called for *each* attribute. So + a single Attlist declaration with multiple attributes declared will + generate multiple calls to this handler. The "default" parameter + may be NULL in the case of the "#IMPLIED" or "#REQUIRED" + keyword. The "isrequired" parameter will be true and the default + value will be NULL in the case of "#REQUIRED". If "isrequired" is + true and default is non-NULL, then this is a "#FIXED" default. +*/ +typedef void(XMLCALL *XML_AttlistDeclHandler)( + void *userData, const XML_Char *elname, const XML_Char *attname, + const XML_Char *att_type, const XML_Char *dflt, int isrequired); + +XMLPARSEAPI(void) +XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl); + +/* The XML declaration handler is called for *both* XML declarations + and text declarations. The way to distinguish is that the version + parameter will be NULL for text declarations. The encoding + parameter may be NULL for XML declarations. The standalone + parameter will be -1, 0, or 1 indicating respectively that there + was no standalone parameter in the declaration, that it was given + as no, or that it was given as yes. +*/ +typedef void(XMLCALL *XML_XmlDeclHandler)(void *userData, + const XML_Char *version, + const XML_Char *encoding, + int standalone); + +XMLPARSEAPI(void) +XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl); + +typedef struct { + void *(*malloc_fcn)(size_t size); + void *(*realloc_fcn)(void *ptr, size_t size); + void (*free_fcn)(void *ptr); +} XML_Memory_Handling_Suite; + +/* Constructs a new parser; encoding is the encoding specified by the + external protocol or NULL if there is none specified. +*/ +XMLPARSEAPI(XML_Parser) +XML_ParserCreate(const XML_Char *encoding); + +/* Constructs a new parser and namespace processor. Element type + names and attribute names that belong to a namespace will be + expanded; unprefixed attribute names are never expanded; unprefixed + element type names are expanded only if there is a default + namespace. The expanded name is the concatenation of the namespace + URI, the namespace separator character, and the local part of the + name. If the namespace separator is '\0' then the namespace URI + and the local part will be concatenated without any separator. + It is a programming error to use the separator '\0' with namespace + triplets (see XML_SetReturnNSTriplet). + If a namespace separator is chosen that can be part of a URI or + part of an XML name, splitting an expanded name back into its + 1, 2 or 3 original parts on application level in the element handler + may end up vulnerable, so these are advised against; sane choices for + a namespace separator are e.g. '\n' (line feed) and '|' (pipe). + + Note that Expat does not validate namespace URIs (beyond encoding) + against RFC 3986 today (and is not required to do so with regard to + the XML 1.0 namespaces specification) but it may start doing that + in future releases. Before that, an application using Expat must + be ready to receive namespace URIs containing non-URI characters. +*/ +XMLPARSEAPI(XML_Parser) +XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); + +/* Constructs a new parser using the memory management suite referred to + by memsuite. If memsuite is NULL, then use the standard library memory + suite. If namespaceSeparator is non-NULL it creates a parser with + namespace processing as described above. The character pointed at + will serve as the namespace separator. + + All further memory operations used for the created parser will come from + the given suite. +*/ +XMLPARSEAPI(XML_Parser) +XML_ParserCreate_MM(const XML_Char *encoding, + const XML_Memory_Handling_Suite *memsuite, + const XML_Char *namespaceSeparator); + +/* Prepare a parser object to be reused. This is particularly + valuable when memory allocation overhead is disproportionately high, + such as when a large number of small documnents need to be parsed. + All handlers are cleared from the parser, except for the + unknownEncodingHandler. The parser's external state is re-initialized + except for the values of ns and ns_triplets. + + Added in Expat 1.95.3. +*/ +XMLPARSEAPI(XML_Bool) +XML_ParserReset(XML_Parser parser, const XML_Char *encoding); + +/* atts is array of name/value pairs, terminated by 0; + names and values are 0 terminated. +*/ +typedef void(XMLCALL *XML_StartElementHandler)(void *userData, + const XML_Char *name, + const XML_Char **atts); + +typedef void(XMLCALL *XML_EndElementHandler)(void *userData, + const XML_Char *name); + +/* s is not 0 terminated. */ +typedef void(XMLCALL *XML_CharacterDataHandler)(void *userData, + const XML_Char *s, int len); + +/* target and data are 0 terminated */ +typedef void(XMLCALL *XML_ProcessingInstructionHandler)(void *userData, + const XML_Char *target, + const XML_Char *data); + +/* data is 0 terminated */ +typedef void(XMLCALL *XML_CommentHandler)(void *userData, const XML_Char *data); + +typedef void(XMLCALL *XML_StartCdataSectionHandler)(void *userData); +typedef void(XMLCALL *XML_EndCdataSectionHandler)(void *userData); + +/* This is called for any characters in the XML document for which + there is no applicable handler. This includes both characters that + are part of markup which is of a kind that is not reported + (comments, markup declarations), or characters that are part of a + construct which could be reported but for which no handler has been + supplied. The characters are passed exactly as they were in the XML + document except that they will be encoded in UTF-8 or UTF-16. + Line boundaries are not normalized. Note that a byte order mark + character is not passed to the default handler. There are no + guarantees about how characters are divided between calls to the + default handler: for example, a comment might be split between + multiple calls. +*/ +typedef void(XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s, + int len); + +/* This is called for the start of the DOCTYPE declaration, before + any DTD or internal subset is parsed. +*/ +typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData, + const XML_Char *doctypeName, + const XML_Char *sysid, + const XML_Char *pubid, + int has_internal_subset); + +/* This is called for the end of the DOCTYPE declaration when the + closing > is encountered, but after processing any external + subset. +*/ +typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); + +/* This is called for entity declarations. The is_parameter_entity + argument will be non-zero if the entity is a parameter entity, zero + otherwise. + + For internal entities (), value will + be non-NULL and systemId, publicID, and notationName will be NULL. + The value string is NOT null-terminated; the length is provided in + the value_length argument. Since it is legal to have zero-length + values, do not use this argument to test for internal entities. + + For external entities, value will be NULL and systemId will be + non-NULL. The publicId argument will be NULL unless a public + identifier was provided. The notationName argument will have a + non-NULL value only for unparsed entity declarations. + + Note that is_parameter_entity can't be changed to XML_Bool, since + that would break binary compatibility. +*/ +typedef void(XMLCALL *XML_EntityDeclHandler)( + void *userData, const XML_Char *entityName, int is_parameter_entity, + const XML_Char *value, int value_length, const XML_Char *base, + const XML_Char *systemId, const XML_Char *publicId, + const XML_Char *notationName); + +XMLPARSEAPI(void) +XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler); + +/* OBSOLETE -- OBSOLETE -- OBSOLETE + This handler has been superseded by the EntityDeclHandler above. + It is provided here for backward compatibility. + + This is called for a declaration of an unparsed (NDATA) entity. + The base argument is whatever was set by XML_SetBase. The + entityName, systemId and notationName arguments will never be + NULL. The other arguments may be. +*/ +typedef void(XMLCALL *XML_UnparsedEntityDeclHandler)( + void *userData, const XML_Char *entityName, const XML_Char *base, + const XML_Char *systemId, const XML_Char *publicId, + const XML_Char *notationName); + +/* This is called for a declaration of notation. The base argument is + whatever was set by XML_SetBase. The notationName will never be + NULL. The other arguments can be. +*/ +typedef void(XMLCALL *XML_NotationDeclHandler)(void *userData, + const XML_Char *notationName, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId); + +/* When namespace processing is enabled, these are called once for + each namespace declaration. The call to the start and end element + handlers occur between the calls to the start and end namespace + declaration handlers. For an xmlns attribute, prefix will be + NULL. For an xmlns="" attribute, uri will be NULL. +*/ +typedef void(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData, + const XML_Char *prefix, + const XML_Char *uri); + +typedef void(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData, + const XML_Char *prefix); + +/* This is called if the document is not standalone, that is, it has an + external subset or a reference to a parameter entity, but does not + have standalone="yes". If this handler returns XML_STATUS_ERROR, + then processing will not continue, and the parser will return a + XML_ERROR_NOT_STANDALONE error. + If parameter entity parsing is enabled, then in addition to the + conditions above this handler will only be called if the referenced + entity was actually read. +*/ +typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData); + +/* This is called for a reference to an external parsed general + entity. The referenced entity is not automatically parsed. The + application can parse it immediately or later using + XML_ExternalEntityParserCreate. + + The parser argument is the parser parsing the entity containing the + reference; it can be passed as the parser argument to + XML_ExternalEntityParserCreate. The systemId argument is the + system identifier as specified in the entity declaration; it will + not be NULL. + + The base argument is the system identifier that should be used as + the base for resolving systemId if systemId was relative; this is + set by XML_SetBase; it may be NULL. + + The publicId argument is the public identifier as specified in the + entity declaration, or NULL if none was specified; the whitespace + in the public identifier will have been normalized as required by + the XML spec. + + The context argument specifies the parsing context in the format + expected by the context argument to XML_ExternalEntityParserCreate; + context is valid only until the handler returns, so if the + referenced entity is to be parsed later, it must be copied. + context is NULL only when the entity is a parameter entity. + + The handler should return XML_STATUS_ERROR if processing should not + continue because of a fatal error in the handling of the external + entity. In this case the calling parser will return an + XML_ERROR_EXTERNAL_ENTITY_HANDLING error. + + Note that unlike other handlers the first argument is the parser, + not userData. +*/ +typedef int(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser parser, + const XML_Char *context, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId); + +/* This is called in two situations: + 1) An entity reference is encountered for which no declaration + has been read *and* this is not an error. + 2) An internal entity reference is read, but not expanded, because + XML_SetDefaultHandler has been called. + Note: skipped parameter entities in declarations and skipped general + entities in attribute values cannot be reported, because + the event would be out of sync with the reporting of the + declarations or attribute values +*/ +typedef void(XMLCALL *XML_SkippedEntityHandler)(void *userData, + const XML_Char *entityName, + int is_parameter_entity); + +/* This structure is filled in by the XML_UnknownEncodingHandler to + provide information to the parser about encodings that are unknown + to the parser. + + The map[b] member gives information about byte sequences whose + first byte is b. + + If map[b] is c where c is >= 0, then b by itself encodes the + Unicode scalar value c. + + If map[b] is -1, then the byte sequence is malformed. + + If map[b] is -n, where n >= 2, then b is the first byte of an + n-byte sequence that encodes a single Unicode scalar value. + + The data member will be passed as the first argument to the convert + function. + + The convert function is used to convert multibyte sequences; s will + point to a n-byte sequence where map[(unsigned char)*s] == -n. The + convert function must return the Unicode scalar value represented + by this byte sequence or -1 if the byte sequence is malformed. + + The convert function may be NULL if the encoding is a single-byte + encoding, that is if map[b] >= -1 for all bytes b. + + When the parser is finished with the encoding, then if release is + not NULL, it will call release passing it the data member; once + release has been called, the convert function will not be called + again. + + Expat places certain restrictions on the encodings that are supported + using this mechanism. + + 1. Every ASCII character that can appear in a well-formed XML document, + other than the characters + + $@\^`{}~ + + must be represented by a single byte, and that byte must be the + same byte that represents that character in ASCII. + + 2. No character may require more than 4 bytes to encode. + + 3. All characters encoded must have Unicode scalar values <= + 0xFFFF, (i.e., characters that would be encoded by surrogates in + UTF-16 are not allowed). Note that this restriction doesn't + apply to the built-in support for UTF-8 and UTF-16. + + 4. No Unicode character may be encoded by more than one distinct + sequence of bytes. +*/ +typedef struct { + int map[256]; + void *data; + int(XMLCALL *convert)(void *data, const char *s); + void(XMLCALL *release)(void *data); +} XML_Encoding; + +/* This is called for an encoding that is unknown to the parser. + + The encodingHandlerData argument is that which was passed as the + second argument to XML_SetUnknownEncodingHandler. + + The name argument gives the name of the encoding as specified in + the encoding declaration. + + If the callback can provide information about the encoding, it must + fill in the XML_Encoding structure, and return XML_STATUS_OK. + Otherwise it must return XML_STATUS_ERROR. + + If info does not describe a suitable encoding, then the parser will + return an XML_ERROR_UNKNOWN_ENCODING error. +*/ +typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData, + const XML_Char *name, + XML_Encoding *info); + +XMLPARSEAPI(void) +XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, + XML_EndElementHandler end); + +XMLPARSEAPI(void) +XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler handler); + +XMLPARSEAPI(void) +XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler handler); + +XMLPARSEAPI(void) +XML_SetCharacterDataHandler(XML_Parser parser, + XML_CharacterDataHandler handler); + +XMLPARSEAPI(void) +XML_SetProcessingInstructionHandler(XML_Parser parser, + XML_ProcessingInstructionHandler handler); +XMLPARSEAPI(void) +XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler); + +XMLPARSEAPI(void) +XML_SetCdataSectionHandler(XML_Parser parser, + XML_StartCdataSectionHandler start, + XML_EndCdataSectionHandler end); + +XMLPARSEAPI(void) +XML_SetStartCdataSectionHandler(XML_Parser parser, + XML_StartCdataSectionHandler start); + +XMLPARSEAPI(void) +XML_SetEndCdataSectionHandler(XML_Parser parser, + XML_EndCdataSectionHandler end); + +/* This sets the default handler and also inhibits expansion of + internal entities. These entity references will be passed to the + default handler, or to the skipped entity handler, if one is set. +*/ +XMLPARSEAPI(void) +XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler); + +/* This sets the default handler but does not inhibit expansion of + internal entities. The entity reference will not be passed to the + default handler. +*/ +XMLPARSEAPI(void) +XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler); + +XMLPARSEAPI(void) +XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start, + XML_EndDoctypeDeclHandler end); + +XMLPARSEAPI(void) +XML_SetStartDoctypeDeclHandler(XML_Parser parser, + XML_StartDoctypeDeclHandler start); + +XMLPARSEAPI(void) +XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end); + +XMLPARSEAPI(void) +XML_SetUnparsedEntityDeclHandler(XML_Parser parser, + XML_UnparsedEntityDeclHandler handler); + +XMLPARSEAPI(void) +XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler); + +XMLPARSEAPI(void) +XML_SetNamespaceDeclHandler(XML_Parser parser, + XML_StartNamespaceDeclHandler start, + XML_EndNamespaceDeclHandler end); + +XMLPARSEAPI(void) +XML_SetStartNamespaceDeclHandler(XML_Parser parser, + XML_StartNamespaceDeclHandler start); + +XMLPARSEAPI(void) +XML_SetEndNamespaceDeclHandler(XML_Parser parser, + XML_EndNamespaceDeclHandler end); + +XMLPARSEAPI(void) +XML_SetNotStandaloneHandler(XML_Parser parser, + XML_NotStandaloneHandler handler); + +XMLPARSEAPI(void) +XML_SetExternalEntityRefHandler(XML_Parser parser, + XML_ExternalEntityRefHandler handler); + +/* If a non-NULL value for arg is specified here, then it will be + passed as the first argument to the external entity ref handler + instead of the parser object. +*/ +XMLPARSEAPI(void) +XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg); + +XMLPARSEAPI(void) +XML_SetSkippedEntityHandler(XML_Parser parser, + XML_SkippedEntityHandler handler); + +XMLPARSEAPI(void) +XML_SetUnknownEncodingHandler(XML_Parser parser, + XML_UnknownEncodingHandler handler, + void *encodingHandlerData); + +/* This can be called within a handler for a start element, end + element, processing instruction or character data. It causes the + corresponding markup to be passed to the default handler. +*/ +XMLPARSEAPI(void) +XML_DefaultCurrent(XML_Parser parser); + +/* If do_nst is non-zero, and namespace processing is in effect, and + a name has a prefix (i.e. an explicit namespace qualifier) then + that name is returned as a triplet in a single string separated by + the separator character specified when the parser was created: URI + + sep + local_name + sep + prefix. + + If do_nst is zero, then namespace information is returned in the + default manner (URI + sep + local_name) whether or not the name + has a prefix. + + Note: Calling XML_SetReturnNSTriplet after XML_Parse or + XML_ParseBuffer has no effect. +*/ + +XMLPARSEAPI(void) +XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); + +/* This value is passed as the userData argument to callbacks. */ +XMLPARSEAPI(void) +XML_SetUserData(XML_Parser parser, void *userData); + +/* Returns the last value set by XML_SetUserData or NULL. */ +# define XML_GetUserData(parser) (*(void **)(parser)) + +/* This is equivalent to supplying an encoding argument to + XML_ParserCreate. On success XML_SetEncoding returns non-zero, + zero otherwise. + Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer + has no effect and returns XML_STATUS_ERROR. +*/ +XMLPARSEAPI(enum XML_Status) +XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); + +/* If this function is called, then the parser will be passed as the + first argument to callbacks instead of userData. The userData will + still be accessible using XML_GetUserData. +*/ +XMLPARSEAPI(void) +XML_UseParserAsHandlerArg(XML_Parser parser); + +/* If useDTD == XML_TRUE is passed to this function, then the parser + will assume that there is an external subset, even if none is + specified in the document. In such a case the parser will call the + externalEntityRefHandler with a value of NULL for the systemId + argument (the publicId and context arguments will be NULL as well). + Note: For the purpose of checking WFC: Entity Declared, passing + useDTD == XML_TRUE will make the parser behave as if the document + had a DTD with an external subset. + Note: If this function is called, then this must be done before + the first call to XML_Parse or XML_ParseBuffer, since it will + have no effect after that. Returns + XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING. + Note: If the document does not have a DOCTYPE declaration at all, + then startDoctypeDeclHandler and endDoctypeDeclHandler will not + be called, despite an external subset being parsed. + Note: If XML_DTD is not defined when Expat is compiled, returns + XML_ERROR_FEATURE_REQUIRES_XML_DTD. + Note: If parser == NULL, returns XML_ERROR_INVALID_ARGUMENT. +*/ +XMLPARSEAPI(enum XML_Error) +XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); + +/* Sets the base to be used for resolving relative URIs in system + identifiers in declarations. Resolving relative identifiers is + left to the application: this value will be passed through as the + base argument to the XML_ExternalEntityRefHandler, + XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base + argument will be copied. Returns XML_STATUS_ERROR if out of memory, + XML_STATUS_OK otherwise. +*/ +XMLPARSEAPI(enum XML_Status) +XML_SetBase(XML_Parser parser, const XML_Char *base); + +XMLPARSEAPI(const XML_Char *) +XML_GetBase(XML_Parser parser); + +/* Returns the number of the attribute/value pairs passed in last call + to the XML_StartElementHandler that were specified in the start-tag + rather than defaulted. Each attribute/value pair counts as 2; thus + this corresponds to an index into the atts array passed to the + XML_StartElementHandler. Returns -1 if parser == NULL. +*/ +XMLPARSEAPI(int) +XML_GetSpecifiedAttributeCount(XML_Parser parser); + +/* Returns the index of the ID attribute passed in the last call to + XML_StartElementHandler, or -1 if there is no ID attribute or + parser == NULL. Each attribute/value pair counts as 2; thus this + corresponds to an index into the atts array passed to the + XML_StartElementHandler. +*/ +XMLPARSEAPI(int) +XML_GetIdAttributeIndex(XML_Parser parser); + +# ifdef XML_ATTR_INFO +/* Source file byte offsets for the start and end of attribute names and values. + The value indices are exclusive of surrounding quotes; thus in a UTF-8 source + file an attribute value of "blah" will yield: + info->valueEnd - info->valueStart = 4 bytes. +*/ +typedef struct { + XML_Index nameStart; /* Offset to beginning of the attribute name. */ + XML_Index nameEnd; /* Offset after the attribute name's last byte. */ + XML_Index valueStart; /* Offset to beginning of the attribute value. */ + XML_Index valueEnd; /* Offset after the attribute value's last byte. */ +} XML_AttrInfo; + +/* Returns an array of XML_AttrInfo structures for the attribute/value pairs + passed in last call to the XML_StartElementHandler that were specified + in the start-tag rather than defaulted. Each attribute/value pair counts + as 1; thus the number of entries in the array is + XML_GetSpecifiedAttributeCount(parser) / 2. +*/ +XMLPARSEAPI(const XML_AttrInfo *) +XML_GetAttributeInfo(XML_Parser parser); +# endif + +/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is + detected. The last call to XML_Parse must have isFinal true; len + may be zero for this call (or any other). + + Though the return values for these functions has always been + described as a Boolean value, the implementation, at least for the + 1.95.x series, has always returned exactly one of the XML_Status + values. +*/ +XMLPARSEAPI(enum XML_Status) +XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); + +XMLPARSEAPI(void *) +XML_GetBuffer(XML_Parser parser, int len); + +XMLPARSEAPI(enum XML_Status) +XML_ParseBuffer(XML_Parser parser, int len, int isFinal); + +/* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. + Must be called from within a call-back handler, except when aborting + (resumable = 0) an already suspended parser. Some call-backs may + still follow because they would otherwise get lost. Examples: + - endElementHandler() for empty elements when stopped in + startElementHandler(), + - endNameSpaceDeclHandler() when stopped in endElementHandler(), + and possibly others. + + Can be called from most handlers, including DTD related call-backs, + except when parsing an external parameter entity and resumable != 0. + Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. + Possible error codes: + - XML_ERROR_SUSPENDED: when suspending an already suspended parser. + - XML_ERROR_FINISHED: when the parser has already finished. + - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. + + When resumable != 0 (true) then parsing is suspended, that is, + XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. + Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer() + return XML_STATUS_ERROR with error code XML_ERROR_ABORTED. + + *Note*: + This will be applied to the current parser instance only, that is, if + there is a parent parser then it will continue parsing when the + externalEntityRefHandler() returns. It is up to the implementation of + the externalEntityRefHandler() to call XML_StopParser() on the parent + parser (recursively), if one wants to stop parsing altogether. + + When suspended, parsing can be resumed by calling XML_ResumeParser(). +*/ +XMLPARSEAPI(enum XML_Status) +XML_StopParser(XML_Parser parser, XML_Bool resumable); + +/* Resumes parsing after it has been suspended with XML_StopParser(). + Must not be called from within a handler call-back. Returns same + status codes as XML_Parse() or XML_ParseBuffer(). + Additional error code XML_ERROR_NOT_SUSPENDED possible. + + *Note*: + This must be called on the most deeply nested child parser instance + first, and on its parent parser only after the child parser has finished, + to be applied recursively until the document entity's parser is restarted. + That is, the parent parser will not resume by itself and it is up to the + application to call XML_ResumeParser() on it at the appropriate moment. +*/ +XMLPARSEAPI(enum XML_Status) +XML_ResumeParser(XML_Parser parser); + +enum XML_Parsing { XML_INITIALIZED, XML_PARSING, XML_FINISHED, XML_SUSPENDED }; + +typedef struct { + enum XML_Parsing parsing; + XML_Bool finalBuffer; +} XML_ParsingStatus; + +/* Returns status of parser with respect to being initialized, parsing, + finished, or suspended and processing the final buffer. + XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus, + XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED +*/ +XMLPARSEAPI(void) +XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status); + +/* Creates an XML_Parser object that can parse an external general + entity; context is a '\0'-terminated string specifying the parse + context; encoding is a '\0'-terminated string giving the name of + the externally specified encoding, or NULL if there is no + externally specified encoding. The context string consists of a + sequence of tokens separated by formfeeds (\f); a token consisting + of a name specifies that the general entity of the name is open; a + token of the form prefix=uri specifies the namespace for a + particular prefix; a token of the form =uri specifies the default + namespace. This can be called at any point after the first call to + an ExternalEntityRefHandler so longer as the parser has not yet + been freed. The new parser is completely independent and may + safely be used in a separate thread. The handlers and userData are + initialized from the parser argument. Returns NULL if out of memory. + Otherwise returns a new XML_Parser object. +*/ +XMLPARSEAPI(XML_Parser) +XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char *context, + const XML_Char *encoding); + +enum XML_ParamEntityParsing { + XML_PARAM_ENTITY_PARSING_NEVER, + XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, + XML_PARAM_ENTITY_PARSING_ALWAYS +}; + +/* Controls parsing of parameter entities (including the external DTD + subset). If parsing of parameter entities is enabled, then + references to external parameter entities (including the external + DTD subset) will be passed to the handler set with + XML_SetExternalEntityRefHandler. The context passed will be 0. + + Unlike external general entities, external parameter entities can + only be parsed synchronously. If the external parameter entity is + to be parsed, it must be parsed during the call to the external + entity ref handler: the complete sequence of + XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and + XML_ParserFree calls must be made during this call. After + XML_ExternalEntityParserCreate has been called to create the parser + for the external parameter entity (context must be 0 for this + call), it is illegal to make any calls on the old parser until + XML_ParserFree has been called on the newly created parser. + If the library has been compiled without support for parameter + entity parsing (ie without XML_DTD being defined), then + XML_SetParamEntityParsing will return 0 if parsing of parameter + entities is requested; otherwise it will return non-zero. + Note: If XML_SetParamEntityParsing is called after XML_Parse or + XML_ParseBuffer, then it has no effect and will always return 0. + Note: If parser == NULL, the function will do nothing and return 0. +*/ +XMLPARSEAPI(int) +XML_SetParamEntityParsing(XML_Parser parser, + enum XML_ParamEntityParsing parsing); + +/* Sets the hash salt to use for internal hash calculations. + Helps in preventing DoS attacks based on predicting hash + function behavior. This must be called before parsing is started. + Returns 1 if successful, 0 when called after parsing has started. + Note: If parser == NULL, the function will do nothing and return 0. +*/ +XMLPARSEAPI(int) +XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt); + +/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then + XML_GetErrorCode returns information about the error. +*/ +XMLPARSEAPI(enum XML_Error) +XML_GetErrorCode(XML_Parser parser); + +/* These functions return information about the current parse + location. They may be called from any callback called to report + some parse event; in this case the location is the location of the + first of the sequence of characters that generated the event. When + called from callbacks generated by declarations in the document + prologue, the location identified isn't as neatly defined, but will + be within the relevant markup. When called outside of the callback + functions, the position indicated will be just past the last parse + event (regardless of whether there was an associated callback). + + They may also be called after returning from a call to XML_Parse + or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then + the location is the location of the character at which the error + was detected; otherwise the location is the location of the last + parse event, as described above. + + Note: XML_GetCurrentLineNumber and XML_GetCurrentColumnNumber + return 0 to indicate an error. + Note: XML_GetCurrentByteIndex returns -1 to indicate an error. +*/ +XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); +XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); +XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser); + +/* Return the number of bytes in the current event. + Returns 0 if the event is in an internal entity. +*/ +XMLPARSEAPI(int) +XML_GetCurrentByteCount(XML_Parser parser); + +/* If XML_CONTEXT_BYTES is >=1, returns the input buffer, sets + the integer pointed to by offset to the offset within this buffer + of the current parse position, and sets the integer pointed to by size + to the size of this buffer (the number of input bytes). Otherwise + returns a NULL pointer. Also returns a NULL pointer if a parse isn't + active. + + NOTE: The character pointer returned should not be used outside + the handler that makes the call. +*/ +XMLPARSEAPI(const char *) +XML_GetInputContext(XML_Parser parser, int *offset, int *size); + +/* For backwards compatibility with previous versions. */ +# define XML_GetErrorLineNumber XML_GetCurrentLineNumber +# define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber +# define XML_GetErrorByteIndex XML_GetCurrentByteIndex + +/* Frees the content model passed to the element declaration handler */ +XMLPARSEAPI(void) +XML_FreeContentModel(XML_Parser parser, XML_Content *model); + +/* Exposing the memory handling functions used in Expat */ +XMLPARSEAPI(void *) +XML_ATTR_MALLOC +XML_ATTR_ALLOC_SIZE(2) +XML_MemMalloc(XML_Parser parser, size_t size); + +XMLPARSEAPI(void *) +XML_ATTR_ALLOC_SIZE(3) +XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); + +XMLPARSEAPI(void) +XML_MemFree(XML_Parser parser, void *ptr); + +/* Frees memory used by the parser. */ +XMLPARSEAPI(void) +XML_ParserFree(XML_Parser parser); + +/* Returns a string describing the error. */ +XMLPARSEAPI(const XML_LChar *) +XML_ErrorString(enum XML_Error code); + +/* Return a string containing the version number of this expat */ +XMLPARSEAPI(const XML_LChar *) +XML_ExpatVersion(void); + +typedef struct { + int major; + int minor; + int micro; +} XML_Expat_Version; + +/* Return an XML_Expat_Version structure containing numeric version + number information for this version of expat. +*/ +XMLPARSEAPI(XML_Expat_Version) +XML_ExpatVersionInfo(void); + +/* Added in Expat 1.95.5. */ +enum XML_FeatureEnum { + XML_FEATURE_END = 0, + XML_FEATURE_UNICODE, + XML_FEATURE_UNICODE_WCHAR_T, + XML_FEATURE_DTD, + XML_FEATURE_CONTEXT_BYTES, + XML_FEATURE_MIN_SIZE, + XML_FEATURE_SIZEOF_XML_CHAR, + XML_FEATURE_SIZEOF_XML_LCHAR, + XML_FEATURE_NS, + XML_FEATURE_LARGE_SIZE, + XML_FEATURE_ATTR_INFO, + /* Added in Expat 2.4.0. */ + XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT, + XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT, + /* Added in Expat 2.6.0. */ + XML_FEATURE_GE, + /* Added in Expat 2.7.2. */ + XML_FEATURE_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT, + XML_FEATURE_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT, + /* Additional features must be added to the end of this enum. */ +}; + +typedef struct { + enum XML_FeatureEnum feature; + const XML_LChar *name; + long int value; +} XML_Feature; + +XMLPARSEAPI(const XML_Feature *) +XML_GetFeatureList(void); + +# if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1) +/* Added in Expat 2.4.0 for XML_DTD defined and + * added in Expat 2.6.0 for XML_GE == 1. */ +XMLPARSEAPI(XML_Bool) +XML_SetBillionLaughsAttackProtectionMaximumAmplification( + XML_Parser parser, float maximumAmplificationFactor); + +/* Added in Expat 2.4.0 for XML_DTD defined and + * added in Expat 2.6.0 for XML_GE == 1. */ +XMLPARSEAPI(XML_Bool) +XML_SetBillionLaughsAttackProtectionActivationThreshold( + XML_Parser parser, unsigned long long activationThresholdBytes); + +/* Added in Expat 2.7.2. */ +XMLPARSEAPI(XML_Bool) +XML_SetAllocTrackerMaximumAmplification(XML_Parser parser, + float maximumAmplificationFactor); + +/* Added in Expat 2.7.2. */ +XMLPARSEAPI(XML_Bool) +XML_SetAllocTrackerActivationThreshold( + XML_Parser parser, unsigned long long activationThresholdBytes); +# endif + +/* Added in Expat 2.6.0. */ +XMLPARSEAPI(XML_Bool) +XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled); + +/* Expat follows the semantic versioning convention. + See https://semver.org +*/ +# define XML_MAJOR_VERSION 2 +# define XML_MINOR_VERSION 7 +# define XML_MICRO_VERSION 2 + +# ifdef __cplusplus +} +# endif + +#endif /* not Expat_INCLUDED */ diff --git a/illumos-x86_64/usr/include/expat_config.h b/illumos-x86_64/usr/include/expat_config.h new file mode 100644 index 00000000..ac1ee7f9 --- /dev/null +++ b/illumos-x86_64/usr/include/expat_config.h @@ -0,0 +1,143 @@ +/* expat_config.h. Generated from expat_config.h.in by configure. */ +/* expat_config.h.in. Generated from configure.ac by autoheader. */ + +#ifndef EXPAT_CONFIG_H +#define EXPAT_CONFIG_H 1 + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* 1234 = LILENDIAN, 4321 = BIGENDIAN */ +#define BYTEORDER 1234 + +/* Define to 1 if you have the `arc4random' function. */ +/* #undef HAVE_ARC4RANDOM */ + +/* Define to 1 if you have the `arc4random_buf' function. */ +#define HAVE_ARC4RANDOM_BUF 1 + +/* define if the compiler supports basic C++11 syntax */ +#define HAVE_CXX11 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getrandom' function. */ +#define HAVE_GETRANDOM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the 'bsd' library (-lbsd). */ +/* #undef HAVE_LIBBSD */ + +/* Define to 1 if you have a working 'mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have `syscall' and `SYS_getrandom'. */ +#define HAVE_SYSCALL_GETRANDOM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "expat" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "https://github.com/libexpat/libexpat/issues" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "expat" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "expat 2.7.2" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "expat" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.7.2" + +/* Define to 1 if all of the C89 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "2.7.2" + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to allow retrieving the byte offsets for attribute names and values. + */ +/* #undef XML_ATTR_INFO */ + +/* Define to specify how much context to retain around the current parse + point, 0 to disable. */ +#define XML_CONTEXT_BYTES 1024 + +/* Define to include code reading entropy from `/dev/urandom'. */ +#define XML_DEV_URANDOM 1 + +/* Define to make parameter entity parsing functionality available. */ +#define XML_DTD 1 + +/* Define as 1/0 to enable/disable support for general entities. */ +#define XML_GE 1 + +/* Define to make XML Namespaces functionality available. */ +#define XML_NS 1 + +/* Define to empty if 'const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to 'long int' if does not define. */ +/* #undef off_t */ + +#endif // ndef EXPAT_CONFIG_H diff --git a/illumos-x86_64/usr/include/expat_external.h b/illumos-x86_64/usr/include/expat_external.h new file mode 100644 index 00000000..96f955ee --- /dev/null +++ b/illumos-x86_64/usr/include/expat_external.h @@ -0,0 +1,166 @@ +/* + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 1997-2000 Thai Open Source Software Center Ltd + Copyright (c) 2000 Clark Cooper + Copyright (c) 2000-2004 Fred L. Drake, Jr. + Copyright (c) 2001-2002 Greg Stein + Copyright (c) 2002-2006 Karl Waclawek + Copyright (c) 2016 Cristian Rodríguez + Copyright (c) 2016-2019 Sebastian Pipping + Copyright (c) 2017 Rhodri James + Copyright (c) 2018 Yury Gribov + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef Expat_External_INCLUDED +# define Expat_External_INCLUDED 1 + +/* External API definitions */ + +/* Expat tries very hard to make the API boundary very specifically + defined. There are two macros defined to control this boundary; + each of these can be defined before including this header to + achieve some different behavior, but doing so it not recommended or + tested frequently. + + XMLCALL - The calling convention to use for all calls across the + "library boundary." This will default to cdecl, and + try really hard to tell the compiler that's what we + want. + + XMLIMPORT - Whatever magic is needed to note that a function is + to be imported from a dynamically loaded library + (.dll, .so, or .sl, depending on your platform). + + The XMLCALL macro was added in Expat 1.95.7. The only one which is + expected to be directly useful in client code is XMLCALL. + + Note that on at least some Unix versions, the Expat library must be + compiled with the cdecl calling convention as the default since + system headers may assume the cdecl convention. +*/ +# ifndef XMLCALL +# if defined(_MSC_VER) +# define XMLCALL __cdecl +# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER) +# define XMLCALL __attribute__((cdecl)) +# else +/* For any platform which uses this definition and supports more than + one calling convention, we need to extend this definition to + declare the convention used on that platform, if it's possible to + do so. + + If this is the case for your platform, please file a bug report + with information on how to identify your platform via the C + pre-processor and how to specify the same calling convention as the + platform's malloc() implementation. +*/ +# define XMLCALL +# endif +# endif /* not defined XMLCALL */ + +# if ! defined(XML_STATIC) && ! defined(XMLIMPORT) +# ifndef XML_BUILDING_EXPAT +/* using Expat from an application */ + +# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) \ + && ! defined(__CYGWIN__) +# define XMLIMPORT __declspec(dllimport) +# endif + +# endif +# endif /* not defined XML_STATIC */ + +# ifndef XML_ENABLE_VISIBILITY +# define XML_ENABLE_VISIBILITY 0 +# endif + +# if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY +# define XMLIMPORT __attribute__((visibility("default"))) +# endif + +/* If we didn't define it above, define it away: */ +# ifndef XMLIMPORT +# define XMLIMPORT +# endif + +# if defined(__GNUC__) \ + && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) +# define XML_ATTR_MALLOC __attribute__((__malloc__)) +# else +# define XML_ATTR_MALLOC +# endif + +# if defined(__GNUC__) \ + && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) +# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) +# else +# define XML_ATTR_ALLOC_SIZE(x) +# endif + +# define XMLPARSEAPI(type) XMLIMPORT type XMLCALL + +# ifdef __cplusplus +extern "C" { +# endif + +# ifdef XML_UNICODE_WCHAR_T +# ifndef XML_UNICODE +# define XML_UNICODE +# endif +# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2) +# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc" +# endif +# endif + +# ifdef XML_UNICODE /* Information is UTF-16 encoded. */ +# ifdef XML_UNICODE_WCHAR_T +typedef wchar_t XML_Char; +typedef wchar_t XML_LChar; +# else +typedef unsigned short XML_Char; +typedef char XML_LChar; +# endif /* XML_UNICODE_WCHAR_T */ +# else /* Information is UTF-8 encoded. */ +typedef char XML_Char; +typedef char XML_LChar; +# endif /* XML_UNICODE */ + +# ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ +typedef long long XML_Index; +typedef unsigned long long XML_Size; +# else +typedef long XML_Index; +typedef unsigned long XML_Size; +# endif /* XML_LARGE_SIZE */ + +# ifdef __cplusplus +} +# endif + +#endif /* not Expat_External_INCLUDED */ diff --git a/illumos-x86_64/usr/include/fatal.h b/illumos-x86_64/usr/include/fatal.h new file mode 100644 index 00000000..09a6ee01 --- /dev/null +++ b/illumos-x86_64/usr/include/fatal.h @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _FATAL_H +#define _FATAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern int Fflags; +extern char *Ffile; +extern int Fvalue; +extern int (*Ffunc)(); +extern int Fjmp[10]; + +#define FTLMSG 0100000 +#define FTLCLN 0040000 +#define FTLFUNC 0020000 +#define FTLACT 0000077 +#define FTLJMP 0000002 +#define FTLEXIT 0000001 +#define FTLRET 0000000 + +#define FSAVE(val) SAVE(Fflags, old_Fflags); Fflags = val; +#define FRSTR() RSTR(Fflags, old_Fflags); + +#ifdef __cplusplus +} +#endif + +#endif /* _FATAL_H */ diff --git a/illumos-x86_64/usr/include/fcntl.h b/illumos-x86_64/usr/include/fcntl.h new file mode 100644 index 00000000..c9cf0ef7 --- /dev/null +++ b/illumos-x86_64/usr/include/fcntl.h @@ -0,0 +1,167 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _FCNTL_H +#define _FCNTL_H + +#include +#if defined(__EXTENSIONS__) || defined(_XPG4) +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || defined(_XPG4) + +/* Symbolic constants for the "lseek" routine. */ + +#ifndef SEEK_SET +#define SEEK_SET 0 /* Set file pointer to "offset" */ +#endif + +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* Set file pointer to current plus "offset" */ +#endif + +#ifndef SEEK_END +#define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#endif /* defined(__EXTENSIONS__) || defined(_XPG4) */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#ifndef SEEK_DATA +#define SEEK_DATA 3 /* Set file pointer to next data past offset */ +#endif + +#ifndef SEEK_HOLE +#define SEEK_HOLE 4 /* Set file pointer to next hole past offset */ +#endif +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname open open64 +#pragma redefine_extname creat creat64 +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +#pragma redefine_extname posix_fadvise posix_fadvise64 +#pragma redefine_extname posix_fallocate posix_fallocate64 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ + defined(_ATFILE_SOURCE) +#pragma redefine_extname openat openat64 +#pragma redefine_extname attropen attropen64 +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */ +#else +#define open open64 +#define creat creat64 +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +#define posix_fadvise posix_fadvise64 +#define posix_fallocate posix_fallocate64 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ + defined(_ATFILE_SOURCE) +#define openat openat64 +#define attropen attropen64 +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */ +#endif +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname open64 open +#pragma redefine_extname creat64 creat +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +#pragma redefine_extname posix_fadvise64 posix_fadvise +#pragma redefine_extname posix_fallocate64 posix_fallocate +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ + defined(_ATFILE_SOURCE) +#pragma redefine_extname openat64 openat +#pragma redefine_extname attropen64 attropen +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */ +#else +#define open64 open +#define creat64 creat +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +#define posix_fadvise64 posix_fadvise +#define posix_fallocate64 posix_fallocate +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ + defined(_ATFILE_SOURCE) +#define openat64 openat +#define attropen64 attropen +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */ +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern int fcntl(int, int, ...); +extern int open(const char *, int, ...); +extern int creat(const char *, mode_t); +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +extern int posix_fadvise(int, off_t, off_t, int); +extern int posix_fallocate(int, off_t, off_t); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ + defined(_ATFILE_SOURCE) +extern int openat(int, const char *, int, ...); +extern int attropen(const char *, const char *, int, ...); +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +extern int directio(int, int); +#endif + +/* transitional large file interface versions */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int open64(const char *, int, ...); +extern int creat64(const char *, mode_t); +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +extern int posix_fadvise64(int, off64_t, off64_t, int); +extern int posix_fallocate64(int, off64_t, off64_t); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ + defined(_ATFILE_SOURCE) +extern int openat64(int, const char *, int, ...); +extern int attropen64(const char *, const char *, int, ...); +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _FCNTL_H */ diff --git a/illumos-x86_64/usr/include/fenv.h b/illumos-x86_64/usr/include/fenv.h new file mode 100644 index 00000000..617143e7 --- /dev/null +++ b/illumos-x86_64/usr/include/fenv.h @@ -0,0 +1,239 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FENV_H +#define _FENV_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Rounding modes + */ +#if defined(__sparc) + +#define FE_TONEAREST 0 +#define FE_TOWARDZERO 1 +#define FE_UPWARD 2 +#define FE_DOWNWARD 3 + +#elif defined(__i386) || defined(__amd64) + +#define FE_TONEAREST 0 +#define FE_DOWNWARD 1 +#define FE_UPWARD 2 +#define FE_TOWARDZERO 3 + +#endif + +extern int fegetround(void); +extern int fesetround(int); + +#if (defined(__i386) || defined(__amd64)) && \ + (!defined(_STRICT_STDC) || defined(__EXTENSIONS__)) + +#define FE_FLTPREC 0 +#define FE_DBLPREC 2 +#define FE_LDBLPREC 3 + +extern int fegetprec(void); +extern int fesetprec(int); + +#endif + +/* + * Exception flags + */ +#if defined(__sparc) + +#define FE_INEXACT 0x01 +#define FE_DIVBYZERO 0x02 +#define FE_UNDERFLOW 0x04 +#define FE_OVERFLOW 0x08 +#define FE_INVALID 0x10 +#define FE_ALL_EXCEPT 0x1f + +#elif defined(__i386) || defined(__amd64) + +#define FE_INVALID 0x01 +#define FE_DIVBYZERO 0x04 +#define FE_OVERFLOW 0x08 +#define FE_UNDERFLOW 0x10 +#define FE_INEXACT 0x20 +#define FE_ALL_EXCEPT 0x3d + +#endif + +typedef int fexcept_t; + +extern int feclearexcept(int); +extern int feraiseexcept(int); +extern int fetestexcept(int); +extern int fegetexceptflag(fexcept_t *, int); +extern int fesetexceptflag(const fexcept_t *, int); + +#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) + +/* + * Exception handling extensions + */ +#define FEX_NOHANDLER -1 +#define FEX_NONSTOP 0 +#define FEX_ABORT 1 +#define FEX_SIGNAL 2 +#define FEX_CUSTOM 3 + +#define FEX_INEXACT 0x001 +#define FEX_DIVBYZERO 0x002 +#define FEX_UNDERFLOW 0x004 +#define FEX_OVERFLOW 0x008 +#define FEX_INV_ZDZ 0x010 +#define FEX_INV_IDI 0x020 +#define FEX_INV_ISI 0x040 +#define FEX_INV_ZMI 0x080 +#define FEX_INV_SQRT 0x100 +#define FEX_INV_SNAN 0x200 +#define FEX_INV_INT 0x400 +#define FEX_INV_CMP 0x800 +#define FEX_INVALID 0xff0 +#define FEX_COMMON (FEX_INVALID | FEX_DIVBYZERO | FEX_OVERFLOW) +#define FEX_ALL (FEX_COMMON | FEX_UNDERFLOW | FEX_INEXACT) +#define FEX_NONE 0 + +#define FEX_NUM_EXC 12 + +/* structure to hold a numeric value in any format used by the FPU */ +typedef struct { + enum fex_nt { + fex_nodata = 0, + fex_int = 1, + fex_llong = 2, + fex_float = 3, + fex_double = 4, + fex_ldouble = 5 + } type; + union { + int i; +#if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \ + defined(__C99FEATURES__) + long long l; +#else + struct { + int l[2]; + } l; +#endif + float f; + double d; + long double q; + } val; +} fex_numeric_t; + +/* structure to supply information about an exception to a custom handler */ +typedef struct { + enum fex_op { + fex_add = 0, + fex_sub = 1, + fex_mul = 2, + fex_div = 3, + fex_sqrt = 4, + fex_cnvt = 5, + fex_cmp = 6, + fex_other = 7 + } op; /* operation that caused the exception */ + int flags; /* flags to be set */ + fex_numeric_t op1, op2, res; /* operands and result */ +} fex_info_t; + +typedef struct fex_handler_data { + int __mode; + void (*__handler)(); +} fex_handler_t[FEX_NUM_EXC]; + +extern int fex_get_handling(int); +extern int fex_set_handling(int, int, void (*)()); + +extern void fex_getexcepthandler(fex_handler_t *, int); +extern void fex_setexcepthandler(const fex_handler_t *, int); + +#ifdef __STDC__ +#include +#ifndef _FILEDEFED +#define _FILEDEFED +typedef __FILE FILE; +#endif +#endif +extern FILE *fex_get_log(void); +extern int fex_set_log(FILE *); +extern int fex_get_log_depth(void); +extern int fex_set_log_depth(int); +extern void fex_log_entry(const char *); + +#define __fex_handler_t fex_handler_t + +#else + +typedef struct { + int __mode; + void (*__handler)(); +} __fex_handler_t[12]; + +#endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */ + +/* + * Environment as a whole + */ +typedef struct { + __fex_handler_t __handlers; + unsigned long __fsr; +} fenv_t; + +#ifdef __STDC__ +extern const fenv_t __fenv_dfl_env; +#else +extern fenv_t __fenv_dfl_env; +#endif + +#define FE_DFL_ENV (&__fenv_dfl_env) + +extern int fegetenv(fenv_t *); +extern int fesetenv(const fenv_t *); +extern int feholdexcept(fenv_t *); +extern int feupdateenv(const fenv_t *); + +#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) +extern void fex_merge_flags(const fenv_t *); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _FENV_H */ diff --git a/illumos-x86_64/usr/include/ffi.h b/illumos-x86_64/usr/include/ffi.h new file mode 100644 index 00000000..7770fa2f --- /dev/null +++ b/illumos-x86_64/usr/include/ffi.h @@ -0,0 +1,527 @@ +/* -----------------------------------------------------------------*-C-*- + libffi 3.4.5 + - Copyright (c) 2011, 2014, 2019, 2021, 2022 Anthony Green + - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the ``Software''), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + ----------------------------------------------------------------------- */ + +/* ------------------------------------------------------------------- + Most of the API is documented in doc/libffi.texi. + + The raw API is designed to bypass some of the argument packing and + unpacking on architectures for which it can be avoided. Routines + are provided to emulate the raw API if the underlying platform + doesn't allow faster implementation. + + More details on the raw API can be found in: + + http://gcc.gnu.org/ml/java/1999-q3/msg00138.html + + and + + http://gcc.gnu.org/ml/java/1999-q3/msg00174.html + -------------------------------------------------------------------- */ + +#ifndef LIBFFI_H +#define LIBFFI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Specify which architecture libffi is configured for. */ +#ifndef X86_64 +#define X86_64 +#endif + +/* ---- System configuration information --------------------------------- */ + +/* If these change, update src/mips/ffitarget.h. */ +#define FFI_TYPE_VOID 0 +#define FFI_TYPE_INT 1 +#define FFI_TYPE_FLOAT 2 +#define FFI_TYPE_DOUBLE 3 +#if 1 +#define FFI_TYPE_LONGDOUBLE 4 +#else +#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE +#endif +#define FFI_TYPE_UINT8 5 +#define FFI_TYPE_SINT8 6 +#define FFI_TYPE_UINT16 7 +#define FFI_TYPE_SINT16 8 +#define FFI_TYPE_UINT32 9 +#define FFI_TYPE_SINT32 10 +#define FFI_TYPE_UINT64 11 +#define FFI_TYPE_SINT64 12 +#define FFI_TYPE_STRUCT 13 +#define FFI_TYPE_POINTER 14 +#define FFI_TYPE_COMPLEX 15 + +/* This should always refer to the last type code (for sanity checks). */ +#define FFI_TYPE_LAST FFI_TYPE_COMPLEX + +#include + +#ifndef LIBFFI_ASM + +#if defined(_MSC_VER) && !defined(__clang__) +#define __attribute__(X) +#endif + +#include +#include + +/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). + But we can find it either under the correct ANSI name, or under GNU + C's internal name. */ + +#define FFI_64_BIT_MAX 9223372036854775807 + +#ifdef LONG_LONG_MAX +# define FFI_LONG_LONG_MAX LONG_LONG_MAX +#else +# ifdef LLONG_MAX +# define FFI_LONG_LONG_MAX LLONG_MAX +# ifdef _AIX52 /* or newer has C99 LLONG_MAX */ +# undef FFI_64_BIT_MAX +# define FFI_64_BIT_MAX 9223372036854775807LL +# endif /* _AIX52 or newer */ +# else +# ifdef __GNUC__ +# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ +# endif +# ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ +# ifndef __PPC64__ +# if defined (__IBMC__) || defined (__IBMCPP__) +# define FFI_LONG_LONG_MAX LONGLONG_MAX +# endif +# endif /* __PPC64__ */ +# undef FFI_64_BIT_MAX +# define FFI_64_BIT_MAX 9223372036854775807LL +# endif +# endif +#endif + +/* The closure code assumes that this works on pointers, i.e. a size_t + can hold a pointer. */ + +typedef struct _ffi_type +{ + size_t size; + unsigned short alignment; + unsigned short type; + struct _ffi_type **elements; +} ffi_type; + +/* Need minimal decorations for DLLs to work on Windows. GCC has + autoimport and autoexport. Always mark externally visible symbols + as dllimport for MSVC clients, even if it means an extra indirection + when using the static version of the library. + Besides, as a workaround, they can define FFI_BUILDING if they + *know* they are going to link with the static library. */ +#if defined _MSC_VER && !defined(FFI_STATIC_BUILD) +# if defined FFI_BUILDING_DLL /* Building libffi.DLL with msvcc.sh */ +# define FFI_API __declspec(dllexport) +# else /* Importing libffi.DLL */ +# define FFI_API __declspec(dllimport) +# endif +#else +# define FFI_API +#endif + +/* The externally visible type declarations also need the MSVC DLL + decorations, or they will not be exported from the object file. */ +#if defined LIBFFI_HIDE_BASIC_TYPES +# define FFI_EXTERN FFI_API +#else +# define FFI_EXTERN extern FFI_API +#endif + +#ifndef LIBFFI_HIDE_BASIC_TYPES +#if SCHAR_MAX == 127 +# define ffi_type_uchar ffi_type_uint8 +# define ffi_type_schar ffi_type_sint8 +#else + #error "char size not supported" +#endif + +#if SHRT_MAX == 32767 +# define ffi_type_ushort ffi_type_uint16 +# define ffi_type_sshort ffi_type_sint16 +#elif SHRT_MAX == 2147483647 +# define ffi_type_ushort ffi_type_uint32 +# define ffi_type_sshort ffi_type_sint32 +#else + #error "short size not supported" +#endif + +#if INT_MAX == 32767 +# define ffi_type_uint ffi_type_uint16 +# define ffi_type_sint ffi_type_sint16 +#elif INT_MAX == 2147483647 +# define ffi_type_uint ffi_type_uint32 +# define ffi_type_sint ffi_type_sint32 +#elif INT_MAX == 9223372036854775807 +# define ffi_type_uint ffi_type_uint64 +# define ffi_type_sint ffi_type_sint64 +#else + #error "int size not supported" +#endif + +#if LONG_MAX == 2147483647 +# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX + #error "no 64-bit data type supported" +# endif +#elif LONG_MAX != FFI_64_BIT_MAX + #error "long size not supported" +#endif + +#if LONG_MAX == 2147483647 +# define ffi_type_ulong ffi_type_uint32 +# define ffi_type_slong ffi_type_sint32 +#elif LONG_MAX == FFI_64_BIT_MAX +# define ffi_type_ulong ffi_type_uint64 +# define ffi_type_slong ffi_type_sint64 +#else + #error "long size not supported" +#endif + +/* These are defined in types.c. */ +FFI_EXTERN ffi_type ffi_type_void; +FFI_EXTERN ffi_type ffi_type_uint8; +FFI_EXTERN ffi_type ffi_type_sint8; +FFI_EXTERN ffi_type ffi_type_uint16; +FFI_EXTERN ffi_type ffi_type_sint16; +FFI_EXTERN ffi_type ffi_type_uint32; +FFI_EXTERN ffi_type ffi_type_sint32; +FFI_EXTERN ffi_type ffi_type_uint64; +FFI_EXTERN ffi_type ffi_type_sint64; +FFI_EXTERN ffi_type ffi_type_float; +FFI_EXTERN ffi_type ffi_type_double; +FFI_EXTERN ffi_type ffi_type_pointer; + +#if 1 +FFI_EXTERN ffi_type ffi_type_longdouble; +#else +#define ffi_type_longdouble ffi_type_double +#endif + +#ifdef FFI_TARGET_HAS_COMPLEX_TYPE +FFI_EXTERN ffi_type ffi_type_complex_float; +FFI_EXTERN ffi_type ffi_type_complex_double; +#if 1 +FFI_EXTERN ffi_type ffi_type_complex_longdouble; +#else +#define ffi_type_complex_longdouble ffi_type_complex_double +#endif +#endif +#endif /* LIBFFI_HIDE_BASIC_TYPES */ + +typedef enum { + FFI_OK = 0, + FFI_BAD_TYPEDEF, + FFI_BAD_ABI, + FFI_BAD_ARGTYPE +} ffi_status; + +typedef struct { + ffi_abi abi; + unsigned nargs; + ffi_type **arg_types; + ffi_type *rtype; + unsigned bytes; + unsigned flags; +#ifdef FFI_EXTRA_CIF_FIELDS + FFI_EXTRA_CIF_FIELDS; +#endif +} ffi_cif; + +/* ---- Definitions for the raw API -------------------------------------- */ + +#ifndef FFI_SIZEOF_ARG +# if LONG_MAX == 2147483647 +# define FFI_SIZEOF_ARG 4 +# elif LONG_MAX == FFI_64_BIT_MAX +# define FFI_SIZEOF_ARG 8 +# endif +#endif + +#ifndef FFI_SIZEOF_JAVA_RAW +# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG +#endif + +typedef union { + ffi_sarg sint; + ffi_arg uint; + float flt; + char data[FFI_SIZEOF_ARG]; + void* ptr; +} ffi_raw; + +#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 +/* This is a special case for mips64/n32 ABI (and perhaps others) where + sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ +typedef union { + signed int sint; + unsigned int uint; + float flt; + char data[FFI_SIZEOF_JAVA_RAW]; + void* ptr; +} ffi_java_raw; +#else +typedef ffi_raw ffi_java_raw; +#endif + + +FFI_API +void ffi_raw_call (ffi_cif *cif, + void (*fn)(void), + void *rvalue, + ffi_raw *avalue); + +FFI_API void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); +FFI_API void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); +FFI_API size_t ffi_raw_size (ffi_cif *cif); + +/* This is analogous to the raw API, except it uses Java parameter + packing, even on 64-bit machines. I.e. on 64-bit machines longs + and doubles are followed by an empty 64-bit word. */ + +#if !FFI_NATIVE_RAW_API +FFI_API +void ffi_java_raw_call (ffi_cif *cif, + void (*fn)(void), + void *rvalue, + ffi_java_raw *avalue) __attribute__((deprecated)); +#endif + +FFI_API +void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) __attribute__((deprecated)); +FFI_API +void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) __attribute__((deprecated)); +FFI_API +size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated)); + +/* ---- Definitions for closures ----------------------------------------- */ + +#if FFI_CLOSURES + +#ifdef _MSC_VER +__declspec(align(8)) +#endif +typedef struct { +#if 0 + void *trampoline_table; + void *trampoline_table_entry; +#else + union { + char tramp[FFI_TRAMPOLINE_SIZE]; + void *ftramp; + }; +#endif + ffi_cif *cif; + void (*fun)(ffi_cif*,void*,void**,void*); + void *user_data; +#if defined(_MSC_VER) && defined(_M_IX86) + void *padding; +#endif +} ffi_closure +#ifdef __GNUC__ + __attribute__((aligned (8))) +#endif + ; + +#ifndef __GNUC__ +# ifdef __sgi +# pragma pack 0 +# endif +#endif + +FFI_API void *ffi_closure_alloc (size_t size, void **code); +FFI_API void ffi_closure_free (void *); + +FFI_API ffi_status +ffi_prep_closure (ffi_closure*, + ffi_cif *, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data) +#if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 405) + __attribute__((deprecated ("use ffi_prep_closure_loc instead"))) +#elif defined(__GNUC__) && __GNUC__ >= 3 + __attribute__((deprecated)) +#endif + ; + +FFI_API ffi_status +ffi_prep_closure_loc (ffi_closure*, + ffi_cif *, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc); + +#ifdef __sgi +# pragma pack 8 +#endif +typedef struct { +#if 0 + void *trampoline_table; + void *trampoline_table_entry; +#else + char tramp[FFI_TRAMPOLINE_SIZE]; +#endif + ffi_cif *cif; + +#if !FFI_NATIVE_RAW_API + + /* If this is enabled, then a raw closure has the same layout + as a regular closure. We use this to install an intermediate + handler to do the translation, void** -> ffi_raw*. */ + + void (*translate_args)(ffi_cif*,void*,void**,void*); + void *this_closure; + +#endif + + void (*fun)(ffi_cif*,void*,ffi_raw*,void*); + void *user_data; + +} ffi_raw_closure; + +typedef struct { +#if 0 + void *trampoline_table; + void *trampoline_table_entry; +#else + char tramp[FFI_TRAMPOLINE_SIZE]; +#endif + + ffi_cif *cif; + +#if !FFI_NATIVE_RAW_API + + /* If this is enabled, then a raw closure has the same layout + as a regular closure. We use this to install an intermediate + handler to do the translation, void** -> ffi_raw*. */ + + void (*translate_args)(ffi_cif*,void*,void**,void*); + void *this_closure; + +#endif + + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); + void *user_data; + +} ffi_java_raw_closure; + +FFI_API ffi_status +ffi_prep_raw_closure (ffi_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data); + +FFI_API ffi_status +ffi_prep_raw_closure_loc (ffi_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data, + void *codeloc); + +#if !FFI_NATIVE_RAW_API +FFI_API ffi_status +ffi_prep_java_raw_closure (ffi_java_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), + void *user_data) __attribute__((deprecated)); + +FFI_API ffi_status +ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), + void *user_data, + void *codeloc) __attribute__((deprecated)); +#endif + +#endif /* FFI_CLOSURES */ + +#ifdef FFI_GO_CLOSURES + +typedef struct { + void *tramp; + ffi_cif *cif; + void (*fun)(ffi_cif*,void*,void**,void*); +} ffi_go_closure; + +FFI_API ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *, + void (*fun)(ffi_cif*,void*,void**,void*)); + +FFI_API void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, + void **avalue, void *closure); + +#endif /* FFI_GO_CLOSURES */ + +/* ---- Public interface definition -------------------------------------- */ + +FFI_API +ffi_status ffi_prep_cif(ffi_cif *cif, + ffi_abi abi, + unsigned int nargs, + ffi_type *rtype, + ffi_type **atypes); + +FFI_API +ffi_status ffi_prep_cif_var(ffi_cif *cif, + ffi_abi abi, + unsigned int nfixedargs, + unsigned int ntotalargs, + ffi_type *rtype, + ffi_type **atypes); + +FFI_API +void ffi_call(ffi_cif *cif, + void (*fn)(void), + void *rvalue, + void **avalue); + +FFI_API +ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, + size_t *offsets); + +/* Convert between closure and function pointers. */ +#if defined(PA_LINUX) || defined(PA_HPUX) +#define FFI_FN(f) ((void (*)(void))((unsigned int)(f) | 2)) +#define FFI_CL(f) ((void *)((unsigned int)(f) & ~3)) +#else +#define FFI_FN(f) ((void (*)(void))f) +#define FFI_CL(f) ((void *)(f)) +#endif + +/* ---- Definitions shared with assembly code ---------------------------- */ + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/ffitarget.h b/illumos-x86_64/usr/include/ffitarget.h new file mode 100644 index 00000000..5a3399d8 --- /dev/null +++ b/illumos-x86_64/usr/include/ffitarget.h @@ -0,0 +1,164 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012, 2014, 2018 Anthony Green + Copyright (c) 1996-2003, 2010 Red Hat, Inc. + Copyright (C) 2008 Free Software Foundation, Inc. + + Target configuration macros for x86 and x86-64. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + ----------------------------------------------------------------------- */ + +#ifndef LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- System specific configurations ----------------------------------- */ + +/* For code common to all platforms on x86 and x86_64. */ +#define X86_ANY + +#if defined (X86_64) && defined (__i386__) +#undef X86_64 +#warning ****************************************************** +#warning ********** X86 IS DEFINED **************************** +#warning ****************************************************** +#define X86 +#endif + +#ifdef X86_WIN64 +#define FFI_SIZEOF_ARG 8 +#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ +#endif + +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION +#ifndef _MSC_VER +#define FFI_TARGET_HAS_COMPLEX_TYPE +#endif + +/* ---- Generic type definitions ----------------------------------------- */ + +#ifndef LIBFFI_ASM +#ifdef X86_WIN64 +#ifdef _MSC_VER +typedef unsigned __int64 ffi_arg; +typedef __int64 ffi_sarg; +#else +typedef unsigned long long ffi_arg; +typedef long long ffi_sarg; +#endif +#else +#if defined __x86_64__ && defined __ILP32__ +#define FFI_SIZEOF_ARG 8 +#define FFI_SIZEOF_JAVA_RAW 4 +typedef unsigned long long ffi_arg; +typedef long long ffi_sarg; +#else +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; +#endif +#endif + +typedef enum ffi_abi { +#if defined(X86_WIN64) + FFI_FIRST_ABI = 0, + FFI_WIN64, /* sizeof(long double) == 8 - microsoft compilers */ + FFI_GNUW64, /* sizeof(long double) == 16 - GNU compilers */ + FFI_LAST_ABI, +#ifdef __GNUC__ + FFI_DEFAULT_ABI = FFI_GNUW64 +#else + FFI_DEFAULT_ABI = FFI_WIN64 +#endif + +#elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) + FFI_FIRST_ABI = 1, + FFI_UNIX64, + FFI_WIN64, + FFI_EFI64 = FFI_WIN64, + FFI_GNUW64, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_UNIX64 + +#elif defined(X86_WIN32) + FFI_FIRST_ABI = 0, + FFI_SYSV = 1, + FFI_STDCALL = 2, + FFI_THISCALL = 3, + FFI_FASTCALL = 4, + FFI_MS_CDECL = 5, + FFI_PASCAL = 6, + FFI_REGISTER = 7, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_MS_CDECL +#else + FFI_FIRST_ABI = 0, + FFI_SYSV = 1, + FFI_THISCALL = 3, + FFI_FASTCALL = 4, + FFI_STDCALL = 5, + FFI_PASCAL = 6, + FFI_REGISTER = 7, + FFI_MS_CDECL = 8, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +#endif +} ffi_abi; +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_GO_CLOSURES 1 + +#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) +#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) +#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) +#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4) + +#if defined (X86_64) || defined(X86_WIN64) \ + || (defined (__x86_64__) && defined (X86_DARWIN)) +/* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP + + 8 bytes of pointer. */ +# define FFI_TRAMPOLINE_SIZE 32 +# define FFI_NATIVE_RAW_API 0 +#else +/* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused + bytes. */ +# define FFI_TRAMPOLINE_SIZE 16 +# define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ +#endif + +#if !defined(GENERATE_LIBFFI_MAP) && defined(__CET__) +# include +# if (__CET__ & 1) != 0 +# define ENDBR_PRESENT +# endif +# define _CET_NOTRACK notrack +#else +# define _CET_ENDBR +# define _CET_NOTRACK +#endif + +#endif diff --git a/illumos-x86_64/usr/include/float.h b/illumos-x86_64/usr/include/float.h new file mode 100644 index 00000000..d435afed --- /dev/null +++ b/illumos-x86_64/usr/include/float.h @@ -0,0 +1,138 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FLOAT_H +#define _FLOAT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__sparc) + +extern int __flt_rounds(void); +#define FLT_ROUNDS __flt_rounds() + +#else /* defined(__sparc) */ + +extern int __fltrounds(void); + +#if defined(__amd64) +#define FLT_ROUNDS __fltrounds() +#else /* defined(__amd64) */ +extern int __flt_rounds; +#define FLT_ROUNDS __flt_rounds +#endif /* defined(__amd64) */ +#endif /* defined(__sparc) */ + +/* Introduced in ISO/IEC 9899:1999 standard */ +#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +#if defined(__FLT_EVAL_METHOD__) +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#else +#define FLT_EVAL_METHOD -1 +#endif /* defined(__FLT_EVAL_METHOD__) */ +#endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */ + +#define FLT_RADIX 2 +#define FLT_MANT_DIG 24 +#define FLT_EPSILON 1.1920928955078125000000E-07F +#define FLT_DIG 6 +#define FLT_MIN_EXP (-125) +#define FLT_MIN 1.1754943508222875079688E-38F +#define FLT_MIN_10_EXP (-37) +#define FLT_MAX_EXP (+128) +#define FLT_MAX 3.4028234663852885981170E+38F +#define FLT_MAX_10_EXP (+38) + +#define DBL_MANT_DIG 53 +#define DBL_EPSILON 2.2204460492503130808473E-16 +#define DBL_DIG 15 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN 2.2250738585072013830903E-308 +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_EXP (+1024) +#define DBL_MAX 1.7976931348623157081452E+308 +#define DBL_MAX_10_EXP (+308) + +/* Introduced in ISO/IEC 9899:1999 standard */ +#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +#if defined(__sparc) +#define DECIMAL_DIG 36 +#elif defined(__i386) || defined(__amd64) +#define DECIMAL_DIG 21 +#endif +#endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */ + + +#if defined(__i386) || defined(__amd64) + +/* Follows IEEE standards for 80-bit floating point */ +#define LDBL_MANT_DIG 64 +#define LDBL_EPSILON 1.0842021724855044340075E-19L +#define LDBL_DIG 18 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 3.3621031431120935062627E-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP (+16384) +#define LDBL_MAX 1.1897314953572317650213E+4932L +#define LDBL_MAX_10_EXP (+4932) + +#elif defined(__sparc) + +/* Follows IEEE standards for 128-bit floating point */ +#define LDBL_MANT_DIG 113 +#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L +#define LDBL_DIG 33 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP (+16384) +#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L +#define LDBL_MAX_10_EXP (+4932) + +#else + +#error "Unknown architecture!" + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _FLOAT_H */ diff --git a/illumos-x86_64/usr/include/floatingpoint.h b/illumos-x86_64/usr/include/floatingpoint.h new file mode 100644 index 00000000..b1f49174 --- /dev/null +++ b/illumos-x86_64/usr/include/floatingpoint.h @@ -0,0 +1,201 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (C) 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FLOATINGPOINT_H +#define _FLOATINGPOINT_H + +#ifdef __STDC__ +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * contains definitions for constants, types, variables, + * and functions for: + * IEEE floating-point arithmetic base conversion; + * IEEE floating-point arithmetic modes; + * IEEE floating-point arithmetic exception handling. + */ +#if defined(__STDC__) && !defined(_FILEDEFED) +#define _FILEDEFED +typedef __FILE FILE; +#endif + +typedef int sigfpe_code_type; /* Type of SIGFPE code. */ + +typedef void (*sigfpe_handler_type)(); /* Pointer to exception handler */ + +#define SIGFPE_DEFAULT (void (*)())0 /* default exception handling */ +#define SIGFPE_IGNORE (void (*)())1 /* ignore this exception or code */ +#define SIGFPE_ABORT (void (*)())2 /* force abort on exception */ + +extern sigfpe_handler_type sigfpe(sigfpe_code_type, sigfpe_handler_type); + +/* + * Types for IEEE floating point. + */ +typedef float single; + +#ifndef _EXTENDED +#define _EXTENDED +typedef unsigned extended[3]; +#endif + +typedef long double quadruple; /* Quadruple-precision type. */ + +typedef unsigned fp_exception_field_type; + /* + * A field containing fp_exceptions OR'ed + * together. + */ +/* + * Definitions for base conversion. + */ +#define DECIMAL_STRING_LENGTH 512 /* Size of buffer in decimal_record. */ + +typedef char decimal_string[DECIMAL_STRING_LENGTH]; + /* Decimal significand. */ + +typedef struct { + enum fp_class_type fpclass; + int sign; + int exponent; + decimal_string ds; /* Significand - each char contains an ascii */ + /* digit, except the string-terminating */ + /* ascii null. */ + int more; /* On conversion from decimal to binary, != 0 */ + /* indicates more non-zero digits following */ + /* ds. */ + int ndigits; /* On fixed_form conversion from binary to */ + /* decimal, contains number of digits */ + /* required for ds. */ +} decimal_record; + +enum decimal_form { + fixed_form, /* Fortran F format: ndigits specifies number */ + /* of digits after point; if negative, */ + /* specifies rounding to occur to left of */ + /* point. */ + floating_form /* Fortran E format: ndigits specifies number */ + /* of significant digits. */ +}; + +typedef struct { + enum fp_direction_type rd; + /* Rounding direction. */ + enum decimal_form df; /* Format for conversion from binary to */ + /* decimal. */ + int ndigits; /* Number of digits for conversion. */ +} decimal_mode; + +enum decimal_string_form { /* Valid decimal number string formats. */ + invalid_form, /* Not a valid decimal string format. */ + whitespace_form, /* All white space - valid in Fortran! */ + fixed_int_form, /* */ + fixed_intdot_form, /* . */ + fixed_dotfrac_form, /* . */ + fixed_intdotfrac_form, /* . */ + floating_int_form, /* */ + floating_intdot_form, /* . */ + floating_dotfrac_form, /* . */ + floating_intdotfrac_form, /* . */ + inf_form, /* inf */ + infinity_form, /* infinity */ + nan_form, /* nan */ + nanstring_form /* nan(string) */ +}; + +extern void single_to_decimal(single *, decimal_mode *, decimal_record *, + fp_exception_field_type *); +extern void double_to_decimal(double *, decimal_mode *, decimal_record *, + fp_exception_field_type *); +extern void extended_to_decimal(extended *, decimal_mode *, + decimal_record *, fp_exception_field_type *); +extern void quadruple_to_decimal(quadruple *, decimal_mode *, + decimal_record *, fp_exception_field_type *); + +extern void decimal_to_single(single *, decimal_mode *, decimal_record *, + fp_exception_field_type *); +extern void decimal_to_double(double *, decimal_mode *, decimal_record *, + fp_exception_field_type *); +extern void decimal_to_extended(extended *, decimal_mode *, + decimal_record *, fp_exception_field_type *); +extern void decimal_to_quadruple(quadruple *, decimal_mode *, + decimal_record *, fp_exception_field_type *); + +extern void string_to_decimal(char **, int, int, decimal_record *, + enum decimal_string_form *, char **); +extern void func_to_decimal(char **, int, int, decimal_record *, + enum decimal_string_form *, char **, + int (*)(void), int *, int (*)(int)); +extern void file_to_decimal(char **, int, int, decimal_record *, + enum decimal_string_form *, char **, + FILE *, int *); + +extern char *seconvert(single *, int, int *, int *, char *); +extern char *sfconvert(single *, int, int *, int *, char *); +extern char *sgconvert(single *, int, int, char *); +extern char *econvert(double, int, int *, int *, char *); +extern char *fconvert(double, int, int *, int *, char *); +extern char *gconvert(double, int, int, char *); +extern char *qeconvert(quadruple *, int, int *, int *, char *); +extern char *qfconvert(quadruple *, int, int *, int *, char *); +extern char *qgconvert(quadruple *, int, int, char *); + +extern char *ecvt(double, int, int *, int *); +extern char *fcvt(double, int, int *, int *); +extern char *gcvt(double, int, char *); + +#if __cplusplus >= 199711L +namespace std { +#endif +/* + * ANSI C Standard says the following entry points should be + * prototyped in . They are now, but weren't before. + */ +extern double atof(const char *); +extern double strtod(const char *, char **); +#if __cplusplus >= 199711L +} + +using std::atof; +using std::strtod; +#endif /* end of namespace std */ + +#ifdef __cplusplus +} +#endif + +#endif /* _FLOATINGPOINT_H */ diff --git a/illumos-x86_64/usr/include/fm/diagcode.h b/illumos-x86_64/usr/include/fm/diagcode.h new file mode 100644 index 00000000..b4e592a0 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/diagcode.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FM_DIAGCODE_H +#define _FM_DIAGCODE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following interfaces are private to Sun and should + * not be used by applications developed outside of Sun. + * They may change incompatibly or go away without notice. + */ + +#define FM_DC_VERSION 1 /* pass to fm_dc_opendict() */ + +typedef struct fm_dc_handle fm_dc_handle_t; + +/* open a dictionary, return opaque handle */ +fm_dc_handle_t *fm_dc_opendict(int version, const char *dirpath, + const char *dictname); + +/* close a dictionary */ +void fm_dc_closedict(fm_dc_handle_t *dhp); + +/* return maximum length (in bytes) of diagcodes for a given dictionary */ +size_t fm_dc_codelen(fm_dc_handle_t *dhp); + +/* return number of strings in key for a given dictionary, plus 1 for null */ +int fm_dc_maxkey(fm_dc_handle_t *dhp); + +/* given a key, construct a diagcode */ +int fm_dc_key2code(fm_dc_handle_t *dhp, + const char *key[], char *code, size_t maxcode); + +/* given a diagcode, return the key (array of strings) */ +int fm_dc_code2key(fm_dc_handle_t *dhp, const char *code, + char *key[], int maxkey); + +/* return the right-hand side of a names property from the dict header */ +const char *fm_dc_getprop(fm_dc_handle_t *dhp, const char *name); + +#ifdef __cplusplus +} +#endif + +#endif /* _FM_DIAGCODE_H */ diff --git a/illumos-x86_64/usr/include/fm/fmd_adm.h b/illumos-x86_64/usr/include/fm/fmd_adm.h new file mode 100644 index 00000000..c7f7e86c --- /dev/null +++ b/illumos-x86_64/usr/include/fm/fmd_adm.h @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2018, Joyent, Inc. + */ + +#ifndef _FMD_ADM_H +#define _FMD_ADM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fault Management Daemon Administrative Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and FMD subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose until they are publicly documented for use outside of Sun. + */ + +#define FMD_ADM_VERSION 1 /* library ABI interface version */ +#define FMD_ADM_PROGRAM 0 /* connect library to system fmd */ + +typedef struct fmd_adm fmd_adm_t; + +extern fmd_adm_t *fmd_adm_open(const char *, uint32_t, int); +extern void fmd_adm_close(fmd_adm_t *); +extern const char *fmd_adm_errmsg(fmd_adm_t *); + +typedef struct fmd_adm_stats { + fmd_stat_t *ams_buf; /* statistics data array */ + uint_t ams_len; /* length of data array */ +} fmd_adm_stats_t; + +extern int fmd_adm_stats_read(fmd_adm_t *, const char *, fmd_adm_stats_t *); +extern int fmd_adm_stats_free(fmd_adm_t *, fmd_adm_stats_t *); + +typedef struct fmd_adm_modinfo { + const char *ami_name; /* string name of module */ + const char *ami_desc; /* module description */ + const char *ami_vers; /* module version */ + uint_t ami_flags; /* flags (see below) */ +} fmd_adm_modinfo_t; + +#define FMD_ADM_MOD_FAILED 0x1 /* module has failed */ + +typedef int fmd_adm_module_f(const fmd_adm_modinfo_t *, void *); + +extern int fmd_adm_module_iter(fmd_adm_t *, fmd_adm_module_f *, void *); +extern int fmd_adm_module_load(fmd_adm_t *, const char *); +extern int fmd_adm_module_unload(fmd_adm_t *, const char *); +extern int fmd_adm_module_reset(fmd_adm_t *, const char *); +extern int fmd_adm_module_stats(fmd_adm_t *, const char *, fmd_adm_stats_t *); +extern int fmd_adm_module_gc(fmd_adm_t *, const char *); + +typedef struct fmd_adm_rsrcinfo { + const char *ari_fmri; /* fmri name of resource */ + const char *ari_uuid; /* uuid name of resource */ + const char *ari_case; /* uuid of case associated w/ state */ + uint_t ari_flags; /* flags (see below) */ +} fmd_adm_rsrcinfo_t; + +#define FMD_ADM_RSRC_FAULTY 0x1 /* resource is faulty */ +#define FMD_ADM_RSRC_UNUSABLE 0x2 /* resource is unusable */ +#define FMD_ADM_RSRC_INVISIBLE 0x4 /* resource is not directly visible */ + +typedef struct fmd_adm_caseinfo { + const char *aci_uuid; + const char *aci_code; + const char *aci_url; + nvlist_t *aci_event; +} fmd_adm_caseinfo_t; + +typedef int fmd_adm_rsrc_f(const fmd_adm_rsrcinfo_t *, void *); +typedef int fmd_adm_case_f(const fmd_adm_caseinfo_t *, void *); + +extern int fmd_adm_rsrc_count(fmd_adm_t *, int, uint32_t *); +extern int fmd_adm_rsrc_iter(fmd_adm_t *, int, fmd_adm_rsrc_f *, void *); +extern int fmd_adm_rsrc_flush(fmd_adm_t *, const char *); +extern int fmd_adm_rsrc_repaired(fmd_adm_t *, const char *); +extern int fmd_adm_rsrc_replaced(fmd_adm_t *, const char *); +extern int fmd_adm_rsrc_acquit(fmd_adm_t *, const char *, const char *); +extern int fmd_adm_case_repair(fmd_adm_t *, const char *); +extern int fmd_adm_case_acquit(fmd_adm_t *, const char *); +extern int fmd_adm_case_iter(fmd_adm_t *, const char *, fmd_adm_case_f *, + void *); + +typedef struct fmd_adm_serdinfo { + const char *asi_name; /* name of serd engine */ + uint64_t asi_delta; /* nsecs from oldest event to now */ + uint64_t asi_n; /* N parameter (event count) */ + uint64_t asi_t; /* T parameter (nanoseconds) */ + uint_t asi_count; /* number of events in engine */ + uint_t asi_flags; /* flags (see below) */ +} fmd_adm_serdinfo_t; + +#define FMD_ADM_SERD_FIRED 0x1 /* serd engine has fired */ + +typedef int fmd_adm_serd_f(const fmd_adm_serdinfo_t *, void *); + +extern int fmd_adm_serd_iter(fmd_adm_t *, const char *, + fmd_adm_serd_f *, void *); +extern int fmd_adm_serd_reset(fmd_adm_t *, const char *, const char *); + +typedef void fmd_adm_xprt_f(id_t, void *); + +extern int fmd_adm_xprt_iter(fmd_adm_t *, fmd_adm_xprt_f *, void *); +extern int fmd_adm_xprt_stats(fmd_adm_t *, id_t, fmd_adm_stats_t *); + +extern int fmd_adm_log_rotate(fmd_adm_t *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _FMD_ADM_H */ diff --git a/illumos-x86_64/usr/include/fm/fmd_agent.h b/illumos-x86_64/usr/include/fm/fmd_agent.h new file mode 100644 index 00000000..432849cd --- /dev/null +++ b/illumos-x86_64/usr/include/fm/fmd_agent.h @@ -0,0 +1,106 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _FMD_AGENT_H +#define _FMD_AGENT_H + +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * libfmd_agent Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and FMD subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose until they are publicly documented for use outside of Sun. + */ + +#define FMD_AGENT_VERSION 1 + +#define FMD_AGENT_RETIRE_DONE 0 /* synchronous success */ +#define FMD_AGENT_RETIRE_ASYNC 1 /* asynchronous complete */ +#define FMD_AGENT_RETIRE_FAIL 2 /* failure */ + +typedef struct fmd_agent_hdl fmd_agent_hdl_t; + +extern fmd_agent_hdl_t *fmd_agent_open(int); +extern void fmd_agent_close(fmd_agent_hdl_t *); +extern int fmd_agent_errno(fmd_agent_hdl_t *); +extern const char *fmd_agent_errmsg(fmd_agent_hdl_t *); +extern const char *fmd_agent_strerr(int); + +extern int fmd_agent_page_retire(fmd_agent_hdl_t *, nvlist_t *); +extern int fmd_agent_page_unretire(fmd_agent_hdl_t *, nvlist_t *); +extern int fmd_agent_page_isretired(fmd_agent_hdl_t *, nvlist_t *); + +#ifdef __x86 +extern int fmd_agent_physcpu_info(fmd_agent_hdl_t *, nvlist_t ***cpusp, + uint_t *ncpu); +extern int fmd_agent_cpu_retire(fmd_agent_hdl_t *, int, int, int); +extern int fmd_agent_cpu_unretire(fmd_agent_hdl_t *, int, int, int); +extern int fmd_agent_cpu_isretired(fmd_agent_hdl_t *, int, int, int); +#endif /* __x86 */ + +/* + * Get cache information for the CPUs in the system. Each CPU has multiple + * caches, each of which is an nvlist_t *. There is one of these for each + * logical CPU in the system. The returned nvlist structures should be treated + * as read only. + */ +typedef struct { + uint_t fmcc_ncaches; + nvlist_t **fmcc_caches; +} fmd_agent_cpu_cache_t; + +typedef struct { + uint_t fmc_ncpus; + fmd_agent_cpu_cache_t *fmc_cpus; +} fmd_agent_cpu_cache_list_t; + +extern int fmd_agent_cache_info(fmd_agent_hdl_t *, + fmd_agent_cpu_cache_list_t *); +extern void fmd_agent_cache_info_free(fmd_agent_hdl_t *, + fmd_agent_cpu_cache_list_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _FMD_AGENT_H */ diff --git a/illumos-x86_64/usr/include/fm/fmd_api.h b/illumos-x86_64/usr/include/fm/fmd_api.h new file mode 100644 index 00000000..b7464842 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/fmd_api.h @@ -0,0 +1,288 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _FMD_API_H +#define _FMD_API_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fault Management Daemon Client Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and FMD subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose until they are publicly documented for use outside of Sun. + */ + +#define FMD_API_VERSION_1 1 +#define FMD_API_VERSION_2 2 +#define FMD_API_VERSION_3 3 +#define FMD_API_VERSION_4 4 +#define FMD_API_VERSION_5 5 + +#define FMD_API_VERSION FMD_API_VERSION_5 + +typedef struct fmd_hdl fmd_hdl_t; +typedef struct fmd_event fmd_event_t; +typedef struct fmd_case fmd_case_t; +typedef struct fmd_xprt fmd_xprt_t; + +struct topo_hdl; + +#define FMD_B_FALSE 0 /* false value for booleans as int */ +#define FMD_B_TRUE 1 /* true value for booleans as int */ + +#ifndef MIN +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#endif + +#ifndef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#endif + +#define FMD_TYPE_BOOL 0 /* int */ +#define FMD_TYPE_INT32 1 /* int32_t */ +#define FMD_TYPE_UINT32 2 /* uint32_t */ +#define FMD_TYPE_INT64 3 /* int64_t */ +#define FMD_TYPE_UINT64 4 /* uint64_t */ +#define FMD_TYPE_STRING 5 /* const char* */ +#define FMD_TYPE_TIME 6 /* uint64_t */ +#define FMD_TYPE_SIZE 7 /* uint64_t */ + +typedef struct fmd_prop { + const char *fmdp_name; /* property name */ + uint_t fmdp_type; /* property type (see above) */ + const char *fmdp_defv; /* default value */ +} fmd_prop_t; + +typedef struct fmd_stat { + char fmds_name[32]; /* statistic name */ + uint_t fmds_type; /* statistic type (see above) */ + char fmds_desc[64]; /* statistic description */ + union { + int bool; /* FMD_TYPE_BOOL */ + int32_t i32; /* FMD_TYPE_INT32 */ + uint32_t ui32; /* FMD_TYPE_UINT32 */ + int64_t i64; /* FMD_TYPE_INT64 */ + uint64_t ui64; /* FMD_TYPE_UINT64, TIME, SIZE */ + char *str; /* FMD_TYPE_STRING */ + } fmds_value; +} fmd_stat_t; + +typedef struct fmd_hdl_ops { + void (*fmdo_recv)(fmd_hdl_t *, fmd_event_t *, nvlist_t *, const char *); + void (*fmdo_timeout)(fmd_hdl_t *, id_t, void *); + void (*fmdo_close)(fmd_hdl_t *, fmd_case_t *); + void (*fmdo_stats)(fmd_hdl_t *); + void (*fmdo_gc)(fmd_hdl_t *); + int (*fmdo_send)(fmd_hdl_t *, fmd_xprt_t *, fmd_event_t *, nvlist_t *); + void (*fmdo_topo)(fmd_hdl_t *, struct topo_hdl *); +} fmd_hdl_ops_t; + +#define FMD_SEND_SUCCESS 0 /* fmdo_send queued event */ +#define FMD_SEND_FAILED 1 /* fmdo_send unrecoverable error */ +#define FMD_SEND_RETRY 2 /* fmdo_send requests retry */ + +typedef struct fmd_hdl_info { + const char *fmdi_desc; /* fmd client description string */ + const char *fmdi_vers; /* fmd client version string */ + const fmd_hdl_ops_t *fmdi_ops; /* ops vector for client */ + const fmd_prop_t *fmdi_props; /* array of configuration props */ +} fmd_hdl_info_t; + +extern void _fmd_init(fmd_hdl_t *); +extern void _fmd_fini(fmd_hdl_t *); + +extern int fmd_hdl_register(fmd_hdl_t *, int, const fmd_hdl_info_t *); +extern void fmd_hdl_unregister(fmd_hdl_t *); + +extern void fmd_hdl_subscribe(fmd_hdl_t *, const char *); +extern void fmd_hdl_unsubscribe(fmd_hdl_t *, const char *); + +extern void fmd_hdl_setspecific(fmd_hdl_t *, void *); +extern void *fmd_hdl_getspecific(fmd_hdl_t *); + +extern void fmd_hdl_opendict(fmd_hdl_t *, const char *); +extern struct topo_hdl *fmd_hdl_topo_hold(fmd_hdl_t *, int); +extern void fmd_hdl_topo_rele(fmd_hdl_t *, struct topo_hdl *); + +#define FMD_NOSLEEP 0x0 /* do not sleep or retry on failure */ +#define FMD_SLEEP 0x1 /* sleep or retry if alloc fails */ + +extern void *fmd_hdl_alloc(fmd_hdl_t *, size_t, int); +extern void *fmd_hdl_zalloc(fmd_hdl_t *, size_t, int); +extern void fmd_hdl_free(fmd_hdl_t *, void *, size_t); + +extern char *fmd_hdl_strdup(fmd_hdl_t *, const char *, int); +extern void fmd_hdl_strfree(fmd_hdl_t *, char *); + +extern void fmd_hdl_vabort(fmd_hdl_t *, const char *, va_list) __NORETURN; +extern void fmd_hdl_abort(fmd_hdl_t *, const char *, ...) __NORETURN; + +extern void fmd_hdl_verror(fmd_hdl_t *, const char *, va_list); +extern void fmd_hdl_error(fmd_hdl_t *, const char *, ...); + +extern void fmd_hdl_vdebug(fmd_hdl_t *, const char *, va_list); +extern void fmd_hdl_debug(fmd_hdl_t *, const char *, ...); + +extern int32_t fmd_prop_get_int32(fmd_hdl_t *, const char *); +extern int64_t fmd_prop_get_int64(fmd_hdl_t *, const char *); +extern char *fmd_prop_get_string(fmd_hdl_t *, const char *); +extern void fmd_prop_free_string(fmd_hdl_t *, char *); + +#define FMD_STAT_NOALLOC 0x0 /* fmd should use caller's memory */ +#define FMD_STAT_ALLOC 0x1 /* fmd should allocate stats memory */ + +extern fmd_stat_t *fmd_stat_create(fmd_hdl_t *, uint_t, uint_t, fmd_stat_t *); +extern void fmd_stat_destroy(fmd_hdl_t *, uint_t, fmd_stat_t *); +extern void fmd_stat_setstr(fmd_hdl_t *, fmd_stat_t *, const char *); + +extern fmd_case_t *fmd_case_open(fmd_hdl_t *, void *); +extern fmd_case_t *fmd_case_open_uuid(fmd_hdl_t *, const char *, void *); +extern void fmd_case_reset(fmd_hdl_t *, fmd_case_t *); +extern void fmd_case_solve(fmd_hdl_t *, fmd_case_t *); +extern void fmd_case_close(fmd_hdl_t *, fmd_case_t *); + +extern const char *fmd_case_uuid(fmd_hdl_t *, fmd_case_t *); +extern fmd_case_t *fmd_case_uulookup(fmd_hdl_t *, const char *); +extern void fmd_case_uuclose(fmd_hdl_t *, const char *); +extern int fmd_case_uuclosed(fmd_hdl_t *, const char *); +extern int fmd_case_uuisresolved(fmd_hdl_t *, const char *); +extern void fmd_case_uuresolved(fmd_hdl_t *, const char *); + +extern int fmd_case_solved(fmd_hdl_t *, fmd_case_t *); +extern int fmd_case_closed(fmd_hdl_t *, fmd_case_t *); + +extern void fmd_case_add_ereport(fmd_hdl_t *, fmd_case_t *, fmd_event_t *); +extern void fmd_case_add_serd(fmd_hdl_t *, fmd_case_t *, const char *); +extern void fmd_case_add_suspect(fmd_hdl_t *, fmd_case_t *, nvlist_t *); + +extern void fmd_case_setspecific(fmd_hdl_t *, fmd_case_t *, void *); +extern void *fmd_case_getspecific(fmd_hdl_t *, fmd_case_t *); + +extern void fmd_case_setprincipal(fmd_hdl_t *, fmd_case_t *, fmd_event_t *); +extern fmd_event_t *fmd_case_getprincipal(fmd_hdl_t *, fmd_case_t *); + +extern fmd_case_t *fmd_case_next(fmd_hdl_t *, fmd_case_t *); +extern fmd_case_t *fmd_case_prev(fmd_hdl_t *, fmd_case_t *); + +extern void fmd_buf_create(fmd_hdl_t *, fmd_case_t *, const char *, size_t); +extern void fmd_buf_destroy(fmd_hdl_t *, fmd_case_t *, const char *); +extern void fmd_buf_read(fmd_hdl_t *, fmd_case_t *, + const char *, void *, size_t); +extern void fmd_buf_write(fmd_hdl_t *, fmd_case_t *, + const char *, const void *, size_t); +extern size_t fmd_buf_size(fmd_hdl_t *, fmd_case_t *, const char *); + +extern void fmd_serd_create(fmd_hdl_t *, const char *, uint_t, hrtime_t); +extern void fmd_serd_destroy(fmd_hdl_t *, const char *); +extern int fmd_serd_exists(fmd_hdl_t *, const char *); +extern void fmd_serd_reset(fmd_hdl_t *, const char *); +extern int fmd_serd_record(fmd_hdl_t *, const char *, fmd_event_t *); +extern int fmd_serd_fired(fmd_hdl_t *, const char *); +extern int fmd_serd_empty(fmd_hdl_t *, const char *); + +extern pthread_t fmd_thr_create(fmd_hdl_t *, void (*)(void *), void *); +extern void fmd_thr_destroy(fmd_hdl_t *, pthread_t); +extern void fmd_thr_signal(fmd_hdl_t *, pthread_t); +extern void fmd_thr_checkpoint(fmd_hdl_t *); + +extern door_xcreate_server_func_t fmd_doorthr_create; +extern door_xcreate_thrsetup_func_t fmd_doorthr_setup; + +extern id_t fmd_timer_install(fmd_hdl_t *, void *, fmd_event_t *, hrtime_t); +extern void fmd_timer_remove(fmd_hdl_t *, id_t); + +extern nvlist_t *fmd_nvl_create_defect(fmd_hdl_t *, + const char *, uint8_t, nvlist_t *, nvlist_t *, nvlist_t *); +extern nvlist_t *fmd_nvl_create_fault(fmd_hdl_t *, + const char *, uint8_t, nvlist_t *, nvlist_t *, nvlist_t *); + +extern const nvlist_t *fmd_hdl_fmauth(fmd_hdl_t *); +extern const nvlist_t *fmd_hdl_modauth(fmd_hdl_t *); + +extern int fmd_nvl_class_match(fmd_hdl_t *, nvlist_t *, const char *); +extern int fmd_nvl_fmri_expand(fmd_hdl_t *, nvlist_t *); +extern int fmd_nvl_fmri_present(fmd_hdl_t *, nvlist_t *); +extern int fmd_nvl_fmri_unusable(fmd_hdl_t *, nvlist_t *); +extern int fmd_nvl_fmri_retire(fmd_hdl_t *, nvlist_t *); +extern int fmd_nvl_fmri_unretire(fmd_hdl_t *, nvlist_t *); +extern int fmd_nvl_fmri_replaced(fmd_hdl_t *, nvlist_t *); +extern int fmd_nvl_fmri_service_state(fmd_hdl_t *, nvlist_t *); +extern int fmd_nvl_fmri_has_fault(fmd_hdl_t *, nvlist_t *, int, char *); + +#define FMD_HAS_FAULT_FRU 0 +#define FMD_HAS_FAULT_ASRU 1 +#define FMD_HAS_FAULT_RESOURCE 2 + +extern void fmd_repair_fru(fmd_hdl_t *, const char *); +extern int fmd_repair_asru(fmd_hdl_t *, const char *); + +extern int fmd_nvl_fmri_contains(fmd_hdl_t *, nvlist_t *, nvlist_t *); +extern nvlist_t *fmd_nvl_fmri_translate(fmd_hdl_t *, nvlist_t *, nvlist_t *); + +extern nvlist_t *fmd_nvl_alloc(fmd_hdl_t *, int); +extern nvlist_t *fmd_nvl_dup(fmd_hdl_t *, nvlist_t *, int); + +extern int fmd_event_local(fmd_hdl_t *, fmd_event_t *); +extern uint64_t fmd_event_ena_create(fmd_hdl_t *); + + +#define FMD_XPRT_RDONLY 0x1 /* transport is read-only */ +#define FMD_XPRT_RDWR 0x3 /* transport is read-write */ +#define FMD_XPRT_ACCEPT 0x4 /* transport is accepting connection */ +#define FMD_XPRT_SUSPENDED 0x8 /* transport starts suspended */ +#define FMD_XPRT_EXTERNAL 0x80 /* xprt is external to a chassis */ +#define FMD_XPRT_NO_REMOTE_REPAIR 0x100 /* xprt does not allow remote repair */ +#define FMD_XPRT_CACHE_AS_LOCAL 0x200 /* xprt caches fault as if local */ +#define FMD_XPRT_HCONLY 0x400 /* xprt only proxies hc-scheme faults */ +#define FMD_XPRT_HC_PRESENT_ONLY 0x800 /* only locally present hc faults */ + +extern fmd_xprt_t *fmd_xprt_open(fmd_hdl_t *, uint_t, nvlist_t *, void *); +extern void fmd_xprt_close(fmd_hdl_t *, fmd_xprt_t *); +extern void fmd_xprt_post(fmd_hdl_t *, fmd_xprt_t *, nvlist_t *, hrtime_t); +extern void fmd_xprt_log(fmd_hdl_t *, fmd_xprt_t *, nvlist_t *, hrtime_t); +extern void fmd_xprt_suspend(fmd_hdl_t *, fmd_xprt_t *); +extern void fmd_xprt_resume(fmd_hdl_t *, fmd_xprt_t *); +extern int fmd_xprt_error(fmd_hdl_t *, fmd_xprt_t *); +extern nvlist_t *fmd_xprt_translate(fmd_hdl_t *, fmd_xprt_t *, fmd_event_t *); +extern void fmd_xprt_add_domain(fmd_hdl_t *, nvlist_t *, char *); +extern void fmd_xprt_setspecific(fmd_hdl_t *, fmd_xprt_t *, void *); +extern void *fmd_xprt_getspecific(fmd_hdl_t *, fmd_xprt_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _FMD_API_H */ diff --git a/illumos-x86_64/usr/include/fm/fmd_fmri.h b/illumos-x86_64/usr/include/fm/fmd_fmri.h new file mode 100644 index 00000000..04e85394 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/fmd_fmri.h @@ -0,0 +1,118 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FMD_FMRI_H +#define _FMD_FMRI_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fault Management Daemon FMRI Scheme Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and FMD subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose until they are publicly documented for use outside of Sun. + */ + +/* + * The following utility functions (in addition to libnvpair) are provided by + * fmd to facilitate the implementation of each FMRI scheme library. + */ + +struct topo_hdl; + +#ifndef MIN +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#endif + +#ifndef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#endif + +extern void *fmd_fmri_alloc(size_t); +extern void *fmd_fmri_zalloc(size_t); +extern void fmd_fmri_free(void *, size_t); + +extern int fmd_fmri_set_errno(int); +extern void fmd_fmri_warn(const char *, ...); + +extern char *fmd_fmri_auth2str(nvlist_t *); +extern char *fmd_fmri_strescape(const char *); +extern char *fmd_fmri_strdup(const char *); +extern void fmd_fmri_strfree(char *); + +extern const char *fmd_fmri_get_rootdir(void); +extern const char *fmd_fmri_get_platform(void); + +extern uint64_t fmd_fmri_get_drgen(void); + +extern struct topo_hdl *fmd_fmri_topo_hold(int); +extern void fmd_fmri_topo_rele(struct topo_hdl *); + +/* + * The following entry points are to be implemented by each scheme: + */ +extern int fmd_fmri_init(void); +extern void fmd_fmri_fini(void); +extern ssize_t fmd_fmri_nvl2str(nvlist_t *, char *, size_t); +extern int fmd_fmri_expand(nvlist_t *); +extern int fmd_fmri_present(nvlist_t *); +extern int fmd_fmri_replaced(nvlist_t *); +extern int fmd_fmri_service_state(nvlist_t *); +extern int fmd_fmri_unusable(nvlist_t *); +extern int fmd_fmri_retire(nvlist_t *); +extern int fmd_fmri_unretire(nvlist_t *); +extern int fmd_fmri_contains(nvlist_t *, nvlist_t *); +extern nvlist_t *fmd_fmri_translate(nvlist_t *, nvlist_t *); + +#define FMD_OBJ_STATE_UNKNOWN 1 +#define FMD_OBJ_STATE_STILL_PRESENT 2 +#define FMD_OBJ_STATE_REPLACED 3 +#define FMD_OBJ_STATE_NOT_PRESENT 4 + +#define FMD_SERVICE_STATE_UNKNOWN 0 +#define FMD_SERVICE_STATE_OK 1 +#define FMD_SERVICE_STATE_DEGRADED 2 +#define FMD_SERVICE_STATE_UNUSABLE 3 +#define FMD_SERVICE_STATE_DEGRADED_PENDING_RESET 4 +#define FMD_SERVICE_STATE_UNUSABLE_PENDING_RESET 5 +#define FMD_SERVICE_STATE_UNUSABLE_UNTIL_REPLACED 6 +#define FMD_SERVICE_STATE_ISOLATE_PENDING 7 + +#ifdef __cplusplus +} +#endif + +#endif /* _FMD_FMRI_H */ diff --git a/illumos-x86_64/usr/include/fm/fmd_log.h b/illumos-x86_64/usr/include/fm/fmd_log.h new file mode 100644 index 00000000..e63266bb --- /dev/null +++ b/illumos-x86_64/usr/include/fm/fmd_log.h @@ -0,0 +1,137 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2024 Oxide Computer Co. + */ + +#ifndef _FMD_LOG_H +#define _FMD_LOG_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fault Management Daemon Log File Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and FMD subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose until they are publicly documented for use outside of Sun. + */ + +#define FMD_LOG_VERSION 3 /* library ABI interface version */ + +typedef struct fmd_log fmd_log_t; + +extern fmd_log_t *fmd_log_open(int, const char *, int *); +extern void fmd_log_close(fmd_log_t *); +extern const char *fmd_log_label(fmd_log_t *); + +extern const char *fmd_log_errmsg(fmd_log_t *, int); +extern int fmd_log_errno(fmd_log_t *); + +typedef struct fmd_log_header { + const char *log_creator; /* ea_get_creator(3EXACCT) string */ + const char *log_hostname; /* ea_get_hostname(3EXACCT) string */ + const char *log_label; /* fmd(8) log file label */ + const char *log_version; /* fmd(8) log file version */ + const char *log_osrelease; /* uname(1) -r value at creation time */ + const char *log_osversion; /* uname(1) -v value at creation time */ + const char *log_platform; /* uname(1) -i value at creation time */ + const char *log_uuid; /* fmd(8) log file uuid */ +} fmd_log_header_t; + +extern void fmd_log_header(fmd_log_t *, fmd_log_header_t *); + +typedef struct fmd_log_record { + ea_object_t *rec_grp; /* log file exacct record group */ + nvlist_t *rec_nvl; /* protocol name-value pair list */ + const char *rec_class; /* protocol event class */ + uint64_t rec_sec; /* time-of-day seconds */ + uint64_t rec_nsec; /* time-of-day nanoseconds */ + struct fmd_log_record *rec_xrefs; /* array of cross-references */ + uint32_t rec_nrefs; /* size of rec_xrefs array */ + off64_t rec_off; /* file offset (if requested) */ +} fmd_log_record_t; + +typedef int fmd_log_rec_f(fmd_log_t *, const fmd_log_record_t *, void *); +typedef int fmd_log_err_f(fmd_log_t *, void *); + +extern int fmd_log_rewind(fmd_log_t *); +extern int fmd_log_iter(fmd_log_t *, fmd_log_rec_f *, void *); +extern int fmd_log_seek(fmd_log_t *, off64_t); + +#define FMD_LOG_XITER_REFS 0x1 /* load event cross-references */ +#define FMD_LOG_XITER_OFFS 0x2 /* compute rec_off for each record */ +#define FMD_LOG_XITER_MASK 0x3 /* mask of all valid flag bits */ + +typedef struct fmd_log_filter { + fmd_log_rec_f *filt_func; /* filter function (see below) */ + void *filt_arg; /* filter argument (see below) */ +} fmd_log_filter_t; + +extern fmd_log_rec_f fmd_log_filter_class; /* char *name of event class */ +extern fmd_log_rec_f fmd_log_filter_uuid; /* char *uuid of list.suspect */ +extern fmd_log_rec_f fmd_log_filter_before; /* struct timeval * latest */ +extern fmd_log_rec_f fmd_log_filter_after; /* struct timeval * earliest */ +extern fmd_log_rec_f fmd_log_filter_nv; /* char *namevalue in event */ +extern fmd_log_rec_f fmd_log_filter_nv_multi; /* multiple name-value pairs */ + +extern int fmd_log_filter(fmd_log_t *, + uint_t, fmd_log_filter_t *, const fmd_log_record_t *); + +typedef struct fmd_log_filter_nvarg { + char *nvarg_name; + char *nvarg_value; + regex_t *nvarg_value_regex; + struct fmd_log_filter_nvarg *nvarg_next; +} fmd_log_filter_nvarg_t; + +/* + * fmd_log_xiter() can be used to perform sophisticated iteration over an fmd + * log file such as that required by fmdump(8). The arguments are as follows: + * + * fmd_log_t *lp - log to use for iteration from fmd_log_open() + * uint_t iflags - FMD_LOG_XITER_* flags (see above) + * uint_t filtc - count of number of filters (or zero for no filtering) + * fmd_log_filter_t *filtv - array of 'filtc' filter structures + * fmd_log_rec_f *rfunc - function to invoke for each record in log + * fmd_log_err_f *efunc - function to invoke for any errors in log + * void *private - argument to pass to 'rfunc' and 'efunc' callbacks + * ulong_t *cntp - pointer to storage for record count (or NULL) + */ +extern int fmd_log_xiter(fmd_log_t *, uint_t, uint_t, fmd_log_filter_t *, + fmd_log_rec_f *, fmd_log_err_f *, void *, ulong_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _FMD_LOG_H */ diff --git a/illumos-x86_64/usr/include/fm/fmd_msg.h b/illumos-x86_64/usr/include/fm/fmd_msg.h new file mode 100644 index 00000000..ebf25e0e --- /dev/null +++ b/illumos-x86_64/usr/include/fm/fmd_msg.h @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _FMD_MSG_H +#define _FMD_MSG_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fault Management Daemon msg File Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and FMD subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose until they are publicly documented for use outside of Sun. + */ + +#define FMD_MSG_VERSION 1 /* libary ABI interface version */ + +typedef struct fmd_msg_hdl fmd_msg_hdl_t; + +typedef enum { + FMD_MSG_ITEM_TYPE, + FMD_MSG_ITEM_SEVERITY, + FMD_MSG_ITEM_DESC, + FMD_MSG_ITEM_RESPONSE, + FMD_MSG_ITEM_IMPACT, + FMD_MSG_ITEM_ACTION, + FMD_MSG_ITEM_URL, + FMD_MSG_ITEM_MAX +} fmd_msg_item_t; + +extern void fmd_msg_lock(void); +extern void fmd_msg_unlock(void); + +fmd_msg_hdl_t *fmd_msg_init(const char *, int); +void fmd_msg_fini(fmd_msg_hdl_t *); + +extern int fmd_msg_locale_set(fmd_msg_hdl_t *, const char *); +extern const char *fmd_msg_locale_get(fmd_msg_hdl_t *); + +extern int fmd_msg_url_set(fmd_msg_hdl_t *, const char *); +extern const char *fmd_msg_url_get(fmd_msg_hdl_t *); + +extern char *fmd_msg_gettext_nv(fmd_msg_hdl_t *, const char *, nvlist_t *); +extern char *fmd_msg_gettext_id(fmd_msg_hdl_t *, const char *, const char *); +extern char *fmd_msg_gettext_key(fmd_msg_hdl_t *, const char *, const char *, + const char *); +extern char *fmd_msg_decode_tokens(nvlist_t *, const char *, const char *); +extern char *fmd_msg_getitem_nv(fmd_msg_hdl_t *, + const char *, nvlist_t *, fmd_msg_item_t); + +extern char *fmd_msg_getitem_id(fmd_msg_hdl_t *, + const char *, const char *, fmd_msg_item_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _FMD_MSG_H */ diff --git a/illumos-x86_64/usr/include/fm/fmd_snmp.h b/illumos-x86_64/usr/include/fm/fmd_snmp.h new file mode 100644 index 00000000..b6f3a488 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/fmd_snmp.h @@ -0,0 +1,140 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _FMD_SNMP_H +#define _FMD_SNMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These values are derived from, and must remain consistent with, the + * MIB definitions in SUN-FM-MIB. + */ +#define MODNAME_STR "sunFM" +#define SUNFM_OID 1, 3, 6, 1, 4, 1, 42, 2, 195, 1 + +#define SUNFMPROBLEMTABLE_OID SUNFM_OID, 1 + +#define SUNFMPROBLEM_COL_UUIDINDEX 1 +#define SUNFMPROBLEM_COL_UUID 2 +#define SUNFMPROBLEM_COL_CODE 3 +#define SUNFMPROBLEM_COL_URL 4 +#define SUNFMPROBLEM_COL_DIAGENGINE 5 +#define SUNFMPROBLEM_COL_DIAGTIME 6 +#define SUNFMPROBLEM_COL_SUSPECTCOUNT 7 + +#define SUNFMPROBLEM_COLMIN SUNFMPROBLEM_COL_UUID +#define SUNFMPROBLEM_COLMAX SUNFMPROBLEM_COL_SUSPECTCOUNT + +#define SUNFMFAULTEVENTTABLE_OID SUNFM_OID, 2 + +#define SUNFMFAULTEVENT_COL_UUIDINDEX 1 +#define SUNFMFAULTEVENT_COL_INDEX 2 +#define SUNFMFAULTEVENT_COL_PROBLEMUUID 3 +#define SUNFMFAULTEVENT_COL_CLASS 4 +#define SUNFMFAULTEVENT_COL_CERTAINTY 5 +#define SUNFMFAULTEVENT_COL_ASRU 6 +#define SUNFMFAULTEVENT_COL_FRU 7 +#define SUNFMFAULTEVENT_COL_RESOURCE 8 +#define SUNFMFAULTEVENT_COL_STATUS 9 +#define SUNFMFAULTEVENT_COL_LOCATION 10 + +#define SUNFMFAULTEVENT_COLMIN SUNFMFAULTEVENT_COL_PROBLEMUUID +#define SUNFMFAULTEVENT_COLMAX SUNFMFAULTEVENT_COL_LOCATION + +#define SUNFMFAULTEVENT_STATE_OTHER 1 +#define SUNFMFAULTEVENT_STATE_FAULTY 2 +#define SUNFMFAULTEVENT_STATE_REMOVED 3 +#define SUNFMFAULTEVENT_STATE_REPLACED 4 +#define SUNFMFAULTEVENT_STATE_REPAIRED 5 +#define SUNFMFAULTEVENT_STATE_ACQUITTED 6 + +#define SUNFMMODULETABLE_OID SUNFM_OID, 3 + +#define SUNFMMODULE_COL_INDEX 1 +#define SUNFMMODULE_COL_NAME 2 +#define SUNFMMODULE_COL_VERSION 3 +#define SUNFMMODULE_COL_STATUS 4 +#define SUNFMMODULE_COL_DESCRIPTION 5 + +#define SUNFMMODULE_COLMIN SUNFMMODULE_COL_NAME +#define SUNFMMODULE_COLMAX SUNFMMODULE_COL_DESCRIPTION + +#define SUNFMMODULE_STATE_OTHER 1 +#define SUNFMMODULE_STATE_ACTIVE 2 +#define SUNFMMODULE_STATE_FAILED 3 + +#define SUNFMRESOURCECOUNT_OID SUNFM_OID, 4 + +#define SUNFMRESOURCETABLE_OID SUNFM_OID, 5 + +#define SUNFMRESOURCE_COL_INDEX 1 +#define SUNFMRESOURCE_COL_FMRI 2 +#define SUNFMRESOURCE_COL_STATUS 3 +#define SUNFMRESOURCE_COL_DIAGNOSISUUID 4 + +#define SUNFMRESOURCE_COLMIN SUNFMRESOURCE_COL_FMRI +#define SUNFMRESOURCE_COLMAX SUNFMRESOURCE_COL_DIAGNOSISUUID + +#define SUNFMRESOURCE_STATE_OTHER 1 +#define SUNFMRESOURCE_STATE_OK 2 +#define SUNFMRESOURCE_STATE_DEGRADED 3 +#define SUNFMRESOURCE_STATE_UNKNOWN 4 +#define SUNFMRESOURCE_STATE_FAULTED 5 + +#define SUNFMTRAPS_OID SUNFM_OID, 7, 0 +#define SUNFMPROBLEMTRAP_OID SUNFMTRAPS_OID, 1 + +#define SNMP_URL_MSG "snmp-url" + +/* + * Definitions from SUN-IREPORT-MIB + */ +#define SUNIREPORT_OID 1, 3, 6, 1, 4, 1, 42, 2, 197, 1 + +#define SUNIREPORTNOTIFICATIONENTRY SUNIREPORT_OID, 1 + +#define SUNIREPORTHOSTNAME_OID SUNIREPORTNOTIFICATIONENTRY, 1 +#define SUNIREPORTMSGID_OID SUNIREPORTNOTIFICATIONENTRY, 2 +#define SUNIREPORTDESCRIPTION_OID SUNIREPORTNOTIFICATIONENTRY, 3 +#define SUNIREPORTTIME_OID SUNIREPORTNOTIFICATIONENTRY, 4 +#define SUNIREPORTSMFFMRI_OID SUNIREPORTNOTIFICATIONENTRY, 5 +#define SUNIREPORTSMFFROMSTATE_OID SUNIREPORTNOTIFICATIONENTRY, 6 +#define SUNIREPORTSMFTOSTATE_OID SUNIREPORTNOTIFICATIONENTRY, 7 +#define SUNIREPORTTRANSITIONREASON_OID SUNIREPORTNOTIFICATIONENTRY, 8 + +#define SUNIREPORTTRAPS_OID SUNIREPORT_OID, 2, 0 +#define SUNIREPORTTRAP_OID SUNIREPORTTRAPS_OID, 1 + + +extern int init_sunFM(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _FMD_SNMP_H */ diff --git a/illumos-x86_64/usr/include/fm/libdiskstatus.h b/illumos-x86_64/usr/include/fm/libdiskstatus.h new file mode 100644 index 00000000..19a8153d --- /dev/null +++ b/illumos-x86_64/usr/include/fm/libdiskstatus.h @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBDISKSTATUS_H +#define _LIBDISKSTATUS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct disk_status disk_status_t; + +/* + * Error definitions + */ +#define EDS_BASE 2000 + +enum { + EDS_NOMEM = EDS_BASE, /* memory allocation failure */ + EDS_CANT_OPEN, /* failed to open device */ + EDS_NO_TRANSPORT, /* no supported transport */ + EDS_NOT_SUPPORTED, /* status information not supported */ + EDS_NOT_SIMULATOR, /* not a valid simulator file */ + EDS_IO /* I/O error */ +}; + +/* + * Basic library functions + */ +extern disk_status_t *disk_status_open(const char *, int *); +extern void disk_status_close(disk_status_t *); +extern const char *disk_status_errmsg(int); +extern void disk_status_set_debug(boolean_t); +extern int disk_status_errno(disk_status_t *); + +/* + * Miscellaneous functions. + */ +extern const char *disk_status_path(disk_status_t *); + +/* + * Main entry point. + */ +extern nvlist_t *disk_status_get(disk_status_t *); + +/* + * Utility function to simulate predictive failure (device-specific). + */ +extern int disk_status_test_predfail(disk_status_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDISKSTATUS_H */ diff --git a/illumos-x86_64/usr/include/fm/libfmevent.h b/illumos-x86_64/usr/include/fm/libfmevent.h new file mode 100644 index 00000000..a90343b3 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/libfmevent.h @@ -0,0 +1,576 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBFMEVENT_H +#define _LIBFMEVENT_H + +/* + * FMA event library. + * + * A. Protocol event subscription interfaces (Committed). + * B. Raw event publication interfaces (Consolidation Private). + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include + +/* + * Library ABI interface version. Quote the version you are using + * to fmev_shdl_init. Only interfaces introduced in or prior to the + * quoted version will be available. Once introduced an interface + * only ever changes compatibly. + * + * Introduced in + * API Function LIBFMEVENT_VERSION_* + * ----------------------- -------------------- + * fmev_attr_list; 1 + * fmev_class; 1 + * fmev_dup; 1 + * fmev_ev2shdl 2 + * fmev_hold; 1 + * fmev_localtime; 1 + * fmev_rele; 1 + * fmev_shdl_alloc; 1 + * fmev_shdl_init; 1 + * fmev_shdl_fini; 1 + * fmev_shdl_free; 1 + * fmev_shdl_getauthority 2 + * fmev_shdl_nvl2str 2 + * fmev_shdl_strdup 2 + * fmev_shdl_strfree 2 + * fmev_shdl_subscribe; 1 + * fmev_shdl_unsubscribe; 1 + * fmev_shdl_zalloc; 1 + * fmev_shdlctl_serialize; 1 + * fmev_shdlctl_sigmask; 1 + * fmev_shdlctl_thrattr; 1 + * fmev_shdlctl_thrcreate; 1 + * fmev_shdlctl_thrsetup; 1 + * fmev_strerror; 1 + * fmev_timespec; 1 + * fmev_time_nsec; 1 + * fmev_time_sec; 1 + */ + +#define LIBFMEVENT_VERSION_1 1 +#define LIBFMEVENT_VERSION_2 2 + +#define LIBFMEVENT_VERSION_LATEST LIBFMEVENT_VERSION_2 + +/* + * Success and error return values. The descriptive comment for each + * FMEVERR_* becomes the string that is returned by fmev_strerror for that + * error type. + */ +typedef enum { + FMEV_SUCCESS = 0, + FMEV_OK = FMEV_SUCCESS, /* alias for FMEV_SUCCESS */ + FMEVERR_UNKNOWN = 0xe000, /* Error details unknown */ + FMEVERR_VERSION_MISMATCH, /* Library ABI version incompatible with caller */ + FMEVERR_API, /* Library API usage violation */ + FMEVERR_ALLOC, /* Failed to allocate additional resources */ + FMEVERR_MALFORMED_EVENT, /* Event contents are inconsistent or corrupt */ + FMEVERR_OVERFLOW, /* Operation would overflow result type */ + FMEVERR_INTERNAL, /* Internal library error */ + FMEVERR_NOPRIV, /* Insufficient permissions or privilege */ + FMEVERR_BUSY, /* Resource is busy */ + FMEVERR_DUPLICATE, /* Duplicate request */ + FMEVERR_BADCLASS, /* Bad event class or class pattern */ + FMEVERR_NOMATCH, /* No match to criteria provided */ + FMEVERR_MAX_SUBSCRIBERS, /* Exceeds maximum subscribers per handle */ + FMEVERR_INVALIDARG, /* Argument is invalid */ + FMEVERR_STRING2BIG, /* String argument exceeds maximum length */ + FMEVERR_VARARGS_MALFORMED, /* Varargs list bad or incorrectly terminated */ + FMEVERR_VARARGS_TOOLONG, /* Varargs list exceeds maximum length */ + FMEVERR_BADRULESET, /* Ruleset selected for publication is bad */ + FMEVERR_BADPRI, /* Priority selected for publication is bad */ + FMEVERR_TRANSPORT, /* Error in underlying event transport implementation */ + FMEVERR_NVLIST /* nvlist argument is not of type NV_UNIQUE_NAME */ +} fmev_err_t; + +/* + * Some interfaces return an fmev_err_t - FMEV_SUCCESS on success, otherwise + * failure of the indicated type. You can use fmev_strerror to render an + * fmev_err_t into a string. + * + * Other interfaces do not return an fmev_err_t directly. For example + * where we return a pointer an error is indicated by a NULL return. + * In these cases you can retrieve the fmev_err_t describing the reason + * for the failure using fmev_errno or get a string with + * fmev_strerr(fmev_errno). Note that fmev_errno is per-thread and holds + * the error value for any error that occured during the last libfmevent + * API call made by the current thread. Use fmev_errno as you would + * regular errno, but you should not assign to fmev_errno. + */ +extern const fmev_err_t *__fmev_errno(void); /* do not use this directly */ +#define fmev_errno (*(__fmev_errno())) +extern const char *fmev_strerror(fmev_err_t); + +/* + * Part A - Protocol Event Subscription + * ====== + * + * Subscribe to FMA protocol events published by the fault management + * daemon, receiving a callback for each matching event. + * + * This is a Committed interface (see attributes(7) for a definition). + */ + +/* + * Opaque subscription handle and event types. + */ +typedef struct fmev_shdl *fmev_shdl_t; +typedef struct fmev *fmev_t; + +/* + * Subscription callback function type for fmev_shdl_subscribe. + */ +typedef void fmev_cbfunc_t(fmev_t, const char *, nvlist_t *, void *); + +/* + * Initialize a new handle using fmev_shdl_init and quoting interface + * version number along with alloc, zalloc and free function pointers (all + * NULL to use the defaults. + * + * Close the handle and release resources with fmev_shdl_fini. + */ + +extern fmev_shdl_t fmev_shdl_init(uint32_t, + void *(*)(size_t), /* alloc */ + void *(*)(size_t), /* zalloc */ + void (*)(void *, size_t)); /* free */ + +extern fmev_err_t fmev_shdl_fini(fmev_shdl_t); + +/* + * Having created a handle you may optionally configure various properties + * for this handle using fmev_shdlctl_*. In most cases accepting the defaults + * (that are obtained through fmev_shdl_init alone) will provide adequate + * semantics - the controls below are provided for applications + * that require fine-grained control over event delivery semantics and, in + * particular, the service threads used to perform delivery callbacks. + * + * These controls may only be applied to a subscription handle + * that has no current subscriptions in place. You therefore cannot + * change the properties once subscriptions are established, and the + * handle properties apply uniformly to all subscriptions on that handle. + * If you require different properties per subscription then use multiple + * handles. + * + * fmev_shdlctl_serialize() will serialize all callbacks arising from all + * subscriptions on a handle. Event deliveries are normally single-threaded + * on a per-subscribtion bases, that is a call to fmev_shdl_subscribe + * will have deliveries arising from that subscription delivered + * in a serialized fashion on a single thread dedicated to the subscription. + * If multiple subscriptions are established then each has a dedicated + * delivery thread - fmev_shdlctl_serialize arranges that only one of these + * threads services a callback at any one time. + * + * fmev_shdlctl_thrattr() allows you to provide thread attributes for use + * in pthread_create() when server threads are created. The attributes + * are not copied - the pthread_attr_t object passed must exist for + * the duration of all subscriptions on the handle. These attributes only + * apply if fmev_shdlctl_thrcreate() is not in use on this handle. + * + * fmev_shdlctl_sigmask() allows you to provide a sigset_t signal mask + * of signals to block in server threads. The pthread_sigmask is set + * to this immediately before pthread_create, and restored immediately + * after pthread_create. This mask only applies if fmev_shdlctl_thrcreate() + * is not in use on this handle. + * + * fmev_shdlctl_thrsetup() allows you to install a custom door server thread + * setup function - see door_xcreate(3C). This will be used with the + * default thread creation semantics or with any custom thread creation + * function appointed with fmev_shdlctl_thrcreate(). + * + * fmev_shdlctl_thrcreate() allows you to install a custom door server thread + * creation function - see door_xcreate(3C). This option excludes + * fmev_shdlctl_{thrattr,sigmask} but the remaining options + * of fmev_shdlctl_{serialize,thrsetup} are still available. + */ + +extern fmev_err_t fmev_shdlctl_serialize(fmev_shdl_t); +extern fmev_err_t fmev_shdlctl_thrattr(fmev_shdl_t, pthread_attr_t *); +extern fmev_err_t fmev_shdlctl_sigmask(fmev_shdl_t, sigset_t *); +extern fmev_err_t fmev_shdlctl_thrsetup(fmev_shdl_t, + door_xcreate_thrsetup_func_t *, void *); +extern fmev_err_t fmev_shdlctl_thrcreate(fmev_shdl_t, + door_xcreate_server_func_t *, void *); + +/* + * Specify subscription choices on a handle using fmev_shdl_subscribe as + * many times as needed to describe the full event set. The event class + * pattern can be wildcarded using simple '*' wildcarding. When an event + * matching a subscription is received a callback is performed to the + * nominated function passing a fmev_t handle on the event and the + * requested cookie argument. + * + * See the fault management event protocol specification for a description + * of event classes. + * + * Drop a subscription using fmev_shdl_unsubscribe (which must match an + * earlier subscription). + */ + +#define FMEV_MAX_CLASS 64 /* Longest class string for subscription */ + +extern fmev_err_t fmev_shdl_subscribe(fmev_shdl_t, const char *, fmev_cbfunc_t, + void *); +extern fmev_err_t fmev_shdl_unsubscribe(fmev_shdl_t, const char *); + +/* + * Retrieve an authority nvlist for the fault manager that is forwarding + * events to us. This may be NULL if the fault manager has not yet + * started up and made the information available. The caller is + * responsible for freeing the nvlist returned. + */ +extern fmev_err_t fmev_shdl_getauthority(fmev_shdl_t, nvlist_t **); + +/* + * Event access. In the common case that the event is processed to + * completion in the context of the event callback you need only + * use fmev_attr_list to access the nvlist of event attributes, + * with no responsibility for freeing the event or the nvlist; for + * convenience, fmev_class and fmev_timestamp can both be used to + * look inside an event without having to work with the attribute list (and + * the callback receives the class as an argument). + * + * See libnvpair(3LIB) for interfaces to access an nvlist_t. + * + * The remaining interfaces apply in the case that event handling will + * continue beyond the context of the event callback in which it is received. + * + * The fmev_t handle received in a callback is reference-counted; + * the initial reference count on entry to the callback is 1, and the + * count is always decremented when the callback completes. To continue + * to operate on a received event outside of the context of the callback + * in which it is first received, take an fmev_hold during the callback + * and later fmev_rele to release your hold (and free the event if the count + * drops to 0). + * + * To access attributes of an event use fmev_attr_list to receive + * an nvlist_t pointer valid for the same lifetime as the event itself (i.e., + * until its reference count drops to zero). + * + * If changes are made to a received fmev_t (discouraged) then all who + * have a hold on the event share the change. To obtain an independent + * copy of an fmev_t, with a reference count of 1, use fmev_dup. When + * finished with the copy decrement the reference count + * using fmev_rele - the event will be freed if the count reaches 0. + * + * For convenience you can retrieve the class of an event using fmev_class + * (it's also available as an argument to a callback, and within the + * event attribute list). The string returned by fmev_class is valid for + * the same lifetime as the event itself. + * + * The time at which a protocol event was generated is available via + * fmev_timespec; tv_sec has seconds since the epoch, and tv_nsec nanoseconds + * past that second. This can fail with FMEVERR_OVERFLOW if the seconds + * value does not fit within a time_t; you can retrieve the 64-bit second + * and nanosecond values with fmev_time_sec and fmev_time_nsec. + * + * An FMRI in an event payload is typically in nvlist form, i.e + * DATA_TYPE_NVLIST. That form is useful for extracting individual + * component fields, but that requires knowledge of the FMRI scheme and + * Public commitment thereof. FMRIs are typically Private, but in some + * cases they can be descriptive such as in listing the ASRU(s) affected + * by a fault; so we offer an API member which will blindly render any + * FMRI in its string form. Use fmev_shdl_nvl2str to format an nvlist_t + * as a string (if it is recognized as an FMRI); the caller is responsible + * for freeing the returned string using fmev_shdl_strfree. If + * fmev_shdl_nvl2str fails it will return NULL with fmev_errno set - + * FMEVERR_INVALIDARG if the nvlist_t does not appear to be a valid/known FMRI, + * FMEVERR_ALLOC if an allocation for memory for the string failed. + * + * fmev_ev2shdl will return the fmev_shdl_t with which a received fmev_t + * is associated. It should only be used in an event delivery callback + * context and for the event received in that callback. + */ + +extern nvlist_t *fmev_attr_list(fmev_t); +extern const char *fmev_class(fmev_t); + +extern fmev_err_t fmev_timespec(fmev_t, struct timespec *); +extern uint64_t fmev_time_sec(fmev_t); +extern uint64_t fmev_time_nsec(fmev_t); +extern struct tm *fmev_localtime(fmev_t, struct tm *); + +extern void fmev_hold(fmev_t); +extern void fmev_rele(fmev_t); +extern fmev_t fmev_dup(fmev_t); + +extern char *fmev_shdl_nvl2str(fmev_shdl_t, nvlist_t *); + +extern fmev_shdl_t fmev_ev2shdl(fmev_t); + +/* + * The following will allocate and free memory based on the choices made + * at fmev_shdl_init. + */ +void *fmev_shdl_alloc(fmev_shdl_t, size_t); +void *fmev_shdl_zalloc(fmev_shdl_t, size_t); +void fmev_shdl_free(fmev_shdl_t, void *, size_t); +extern char *fmev_shdl_strdup(fmev_shdl_t, char *); +extern void fmev_shdl_strfree(fmev_shdl_t, char *); + +/* + * Part B - Raw Event Publication + * ====== + * + * The following interfaces are private to the Solaris system and are + * subject to change at any time without notice. Applications using + * these interfaces will fail to run on future releases. The interfaces + * should not be used for any purpose until they are publicly documented + * for use outside of Sun. These interface are *certain* to change + * incompatibly, as the current interface is very much purpose-built for + * a limited application. + * + * The interfaces below allow a process to publish a "raw" event + * which will be transmitted to the fault manager and post-processed + * into a full FMA protocol event. The post-processing to be applied + * is selected by a "ruleset" specified either implicitly or explicitly + * at publication. A ruleset will take the raw event (comprising + * class, subclass, priority, raw payload) and mark it up into a full + * protocol event; it may also augment the payload through looking up + * details that would have been costly to compute at publication time. + * + * In this first implementation event dispatch is synchronous and blocking, + * and not guaranteed to be re-entrant. This limits the call sites + * at which publication calls can be placed, and also means that careful + * thought is required before sprinkling event publication code throughout + * common system libraries. The dispatch mechanism amounts to some + * nvlist chicanery followed by a sysevent_evc_publish. A future revision + * will relax the context from which one may publish, and add more-powerful + * publication interfaces. + * + * Some publication interfaces (those ending in _nvl) accept a preconstructed + * nvlist as raw event payload. We require that such an nvlist be of type + * NV_UNIQUE_NAME. The publication interfaces all call nvlist_free on any + * nvlist that is passed for publication. + * + * Other publication interfaces allow you to build up the raw event payload + * by specifying the members in a varargs list terminated by FMEV_ARG_TERM. + * Again we require that payload member names are unique (that is, you cannot + * have two members with the same name but different datatype). See + * for the data_type_t enumeration of types supported - but + * note that DATA_TYPE_BOOLEAN is excluded (DATA_TYPE_BOOLEAN_VALUE is + * supported). A single-valued (non-array type) member is specified with 3 + * consecutive varargs as: + * + * (char *)name, DATA_TYPE_foo, (type)value + * + * An array-valued member is specified with 4 consecutive varargs as: + * + * (char *)name, DATA_TYPE_foo_ARRAY, (int)nelem, (type *)arrayptr + * + * The varargs list that specifies the nvlist must begin with an + * integer that specifies the number of members that follow. For example: + * + * uint32_t mode; + * char *clientname; + * uint32_t ins[NARGS]; + * + * fmev_publish("class", "subclass", FMEV_LOPRI, + * 3, + * "mode", DATA_TYPE_UINT32, mode, + * "client", DATA_TYPE_STRING, clientname, + * "ins", DATA_TYPE_UINT32_ARRAY, sizeof (ins) / sizeof (ins[0]), ins, + * FMEV_ARG_TERM); + * + * The following tables summarize the capabilities of the various + * publication interfaces. + * + * Detector + * Interface Ruleset? File/Line Func + * ---------------------------- -------- --------- ---- + * fmev_publish_nvl default Yes No + * fmev_publish_nvl (C99) default Yes Yes + * fmev_rspublish_nvl chosen Yes No + * fmev_rspublish_nvl (C99) chosen Yes Yes + * fmev_publish default No No + * fmev_publish (C99) default Yes Yes + * fmev_rspublish chosen No No + * fmev_rspublish (C99) chosen Yes Yes + * + * Summary: if not using C99 then try to use the _nvl variants as the + * varargs variants will not include file, line or function in the + * detector. + */ + +/* + * In publishing an event you must select a "ruleset" (or accept the + * defaults). Rulesets are listed in the following header. + */ +#include + +/* + * In publishing an event we can specify a class and subclass (which + * in post-processing combine in some way selected by the ruleset to + * form a full event protocol class). The maximum class and subclass + * string lengths are as follows. + */ +#define FMEV_PUB_MAXCLASSLEN 32 +#define FMEV_PUB_MAXSUBCLASSLEN 32 + +/* + * Events are either high-priority (try really hard not to lose) or + * low-priority (can drop, throttle etc). Convert a fmev_pri_t to + * a string with fmev_pri_string(). + */ +typedef enum fmev_pri { + FMEV_LOPRI = 0x1000, + FMEV_HIPRI +} fmev_pri_t; + +extern const char *fmev_pri_string(fmev_pri_t); + +/* + * The varargs event publication interfaces must terminate the list + * of nvpair specifications with FMEV_ARG_TERM. This is to guard + * against very easily-made mistakes in those arg lists. + */ +#define FMEV_ARG_TERM (void *)0xa4a3a2a1 + +/* + * The following are NOT for direct use. + */ +extern fmev_err_t _i_fmev_publish_nvl( + const char *, const char *, int64_t, + const char *, const char *, const char *, + fmev_pri_t, nvlist_t *); + +extern fmev_err_t _i_fmev_publish( + const char *, const char *, int64_t, + const char *, const char *, const char *, + fmev_pri_t, + uint_t, ...); + +/* + * Post-processing will always generate a "detector" payload member. In + * the case of the _nvl publishing variants the detector information + * includes file and line number, and - if your application is compiled + * with C99 enabled - function name. + */ +#if __STDC_VERSION__ - 0 >= 199901L +#define _FMEVFUNC __func__ +#else +#define _FMEVFUNC NULL +#endif + +/* + * All these definitions "return" an fmev_err_t. + * + * In the _nvl variants you pass a preconstructed event payload; otherwise + * you include an integer indicating the number of payload + * (name, type, value) tuples that follow, then all those tuples, finally + * terminated by FMEV_ARG_TERM. + * + * In the rspublish variants you select a ruleset from + * libfmevent_ruleset.h - just use the final suffix (as in + * DEFAULT, EREPORT, ISV). + * + * The primary classification must not be NULL or the empty string. + * + * arg type Description + * ------- --------------- ------------------------------------------- + * ruleset const char * Ruleset; can be NULL (implies default ruleset) + * cl1 const char * Primary classification string + * cl2 const char * Secondary classification string + * pri fmev_pri_t Priority + * nvl nvlist_t * Preconstructed attributes; caller must free + * ntuples int Number of tuples before FMEV_ARG_TERM + * suffix - See above. + */ + +/* + * fmev_publish_nvl - Default ruleset implied; class/subclass, pri and an nvl + */ +#define fmev_publish_nvl(cl1, cl2, pri, nvl) \ + _i_fmev_publish_nvl( \ + __FILE__, _FMEVFUNC, __LINE__, \ + FMEV_RULESET_DEFAULT, cl1, cl2, \ + pri, nvl) + +/* + * fmev_rspublish_nvl - As fmev_publish_nvl, but with a chosen ruleset. + */ +#define fmev_rspublish_nvl(ruleset, cl1, cl2, pri, nvl) \ + _i_fmev_publish_nvl( \ + __FILE__, _FMEVFUNC, __LINE__, \ + ruleset, cl1, cl2, \ + pri, nvl) + +#if __STDC_VERSION__ - 0 >= 199901L && !defined(__lint) + +/* + * fmev_publish (C99 version) - Default ruleset; class/subclass, pri, nvpairs + */ +#define fmev_publish(cl1, cl2, pri, ntuples, ...) \ + _i_fmev_publish( \ + __FILE__, __func__, __LINE__, \ + FMEV_RULESET_DEFAULT, cl1, cl2, \ + pri, \ + ntuples, __VA_ARGS__) + + +/* + * fmev_rspublish (C99 version) - As fmev_publish, but with a chosen ruleset. + */ +#define fmev_rspublish(ruleset, cl1, cl2, pri, ntuples, ...) \ + _i_fmev_publish( \ + __FILE__, __func__, __LINE__, \ + ruleset, cl1, cl2, \ + pri, \ + ntuples, __VA_ARGS__) + +#else + +/* + * fmev_publish (pre C99) + */ +extern fmev_err_t fmev_publish(const char *, const char *, + fmev_pri_t, uint_t, ...); + +/* + * fmev_rspublish (pre C99) + */ +extern fmev_err_t fmev_rspublish(const char *, const char *, const char *, + fmev_pri_t, uint_t, ...); + +#endif /* __STDC_VERSION__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBFMEVENT_H */ diff --git a/illumos-x86_64/usr/include/fm/libfmevent_ruleset.h b/illumos-x86_64/usr/include/fm/libfmevent_ruleset.h new file mode 100644 index 00000000..3fb1fb57 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/libfmevent_ruleset.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBFMEVENT_RULESET_H +#define _LIBFMEVENT_RULESET_H + +/* + * Event Rulesets. A ruleset is selected by a (namespace, subsystem) + * combination, which together we call a "ruleset" selection for that + * namespace. The strings can be any ascii string not including + * control characters or DEL. + * + * Selection of a ruleset determines how a "raw" event that we publish + * using the libfmevent publication interfaces is post-processed into + * a full protocol event. + * + * New rulesets must follow the FMA Event Registry and Portfolio Review + * process. At this time only FMEV_RULESET_SMF and FMEV_RULESET_ON_SUNOS + * rulesets are adopted by that process - the others listed here are + * experimental. + */ + +#define FMEV_MAX_RULESET_LEN 31 + +#define FMEV_RS_SEPARATOR "\012" +#define FMEV_MKRS(v, s) FMEV_V_##v FMEV_RS_SEPARATOR s + +/* + * Namespaces + */ +#define FMEV_V_ALL "*" +#define FMEV_V_SOLARIS_ON "solaris-osnet" /* Solaris ON Consolidation */ + +/* + * Generic and namespace-agnostic rulesets + */ +#define FMEV_RULESET_UNREGISTERED FMEV_MKRS(ALL, "unregistered") +#define FMEV_RULESET_DEFAULT FMEV_RULESET_UNREGISTERED +#define FMEV_RULESET_SMF FMEV_MKRS(ALL, "smf") + +/* + * Solaris ON rulesets + */ +#define FMEV_RULESET_ON_EREPORT FMEV_MKRS(SOLARIS_ON, "ereport") +#define FMEV_RULESET_ON_SUNOS FMEV_MKRS(SOLARIS_ON, "sunos") +#define FMEV_RULESET_ON_PRIVATE FMEV_MKRS(SOLARIS_ON, "private") + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBFMEVENT_RULESET_H */ diff --git a/illumos-x86_64/usr/include/fm/libseslog.h b/illumos-x86_64/usr/include/fm/libseslog.h new file mode 100644 index 00000000..0c893cd6 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/libseslog.h @@ -0,0 +1,157 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + + + +#ifndef _LIBSESLOG_H +#define _LIBSESLOG_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Error definitions + */ + +enum { + SES_LOG_FAILED_TO_OPEN_DEVICE = 1, /* Couldn't open dev path */ + SES_LOG_FAILED_TO_READ_DEVICE, /* Couldn't read the log data */ + SES_LOG_FAILED_NULL_TARGET_PATH, /* Empty target path */ + SES_LOG_FAILED_BAD_TARGET_PATH, /* Couldn't find valid target path */ + SES_LOG_FAILED_MODE_SENSE, /* Mode sense error returned */ + SES_LOG_FAILED_MODE_SENSE_OFFSET, /* Offset not correct */ + SES_LOG_FAILED_BAD_DATA_LEN, /* Data length not correct */ + SES_LOG_FAILED_BAD_CONTENT_LEN, /* Content length not correct */ + SES_LOG_FAILED_FORMAT_PAGE_ERR, /* Device doesn't support page */ + SES_LOG_FAILED_NV_UNIQUE, /* Couldn't add unique to nvlist */ + SES_LOG_FAILED_NV_LOG, /* Couldn't add log to nvlist */ + SES_LOG_FAILED_NV_CODE, /* Couldn't add code to nvlist */ + SES_LOG_FAILED_NV_SEV, /* Couldn't add sev to nvlist */ + SES_LOG_FAILED_NV_ENTRY, /* Couldn't add entry to nvlist */ + SES_LOG_FAILED_MODE_SELECT, /* Mode select failed */ + SES_LOG_FAILED_NVLIST_CREATE /* Couldn't create a nvlist */ +}; + +/* + * define different levels of log entries that could be returned + */ +#define SES_LOG_LEVEL_NOTICE 0 +#define SES_LOG_LEVEL_DEBUG 1 +#define SES_LOG_LEVEL_WARNING 2 +#define SES_LOG_LEVEL_NO_MASK 3 +#define SES_LOG_LEVEL_ERROR 4 +#define SES_LOG_LEVEL_FATAL 5 + +/* Valid size of log entry being returned by expander */ +#define SES_LOG_VALID_LOG_SIZE 71 + +/* The string log is made from 8 char entries */ +#define SES_LOG_SPECIFIC_ENTRY_SIZE 8 + +/* Index of where sequence number starts in returned string */ +#define SES_LOG_SEQ_NUM_START 27 +/* Index of where log code starts */ +#define SES_LOG_CODE_START 36 +/* Index of where log level starts in returned string */ +#define SES_LOG_LEVEL_START 40 + +/* Maximum size the each sub log entry can be */ +#define ENTRY_MAX_SIZE 10 +/* Maximum save buffer log entry size */ +#define MAX_LOG_ENTRY_SZ 256 + +#define MAX_ALLOC_LEN (0xfffc) +/* + * Sense return buffer length + * Arbitrary, could be larger + */ +#define SENSE_BUFF_LEN 32 +/* + * 60 seconds for SCSI timeout + */ +#define DEF_PT_TIMEOUT 60 + + +/* + * Defines for different SCSI cmd paramters + */ +#define MODE_SELECT10_CMDLEN 10 +#define MODE10_RESP_HDR_LEN 8 +#define MODE_SENSE10_CMDLEN 10 + + +/* + * Defines for nvlist entries + */ +#define ENTRY_PREFIX "entry" +#define ENTRY_SEVERITY "severity" +#define ENTRY_CODE "code" +#define ENTRY_LOG "log" + + + +/* + * Genesis specific log clear control struct + */ +struct log_clear_control_struct { + unsigned char pageControls; + uint8_t subpage_code; + uint8_t page_lengthUpper; + uint8_t page_lengthLower; + uint8_t host_id[16]; + uint8_t seq_clear[4]; + uint8_t timeout[2]; +}; + + + +/* + * Struct to contain information needed to read logs + */ +typedef struct ses_log_call_struct { + char target_path[MAXPATHLEN]; /* Path to device, passed in */ + char product_id[MAXNAMELEN]; /* product id of expander, passed in */ + hrtime_t poll_time; /* nanosecond poll time, passed in */ + char last_log_entry[MAXNAMELEN]; /* Last entry read, passed in/out */ + int number_log_entries; /* num of log entries read, passed back */ + int size_of_log_entries; /* Total size of all logs read passed back */ + nvlist_t *log_data; /* Log data being returned, passed back */ +} ses_log_call_t; + +/* + * Basic library functions + */ +extern int access_ses_log(struct ses_log_call_struct *); + + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSESLOG_H */ diff --git a/illumos-x86_64/usr/include/fm/libtopo.h b/illumos-x86_64/usr/include/fm/libtopo.h new file mode 100644 index 00000000..1cf5bfb3 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/libtopo.h @@ -0,0 +1,1126 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright 2020 Joyent, Inc. + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _LIBTOPO_H +#define _LIBTOPO_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TOPO_VERSION 1 /* Library ABI Interface Version */ + +typedef struct topo_hdl topo_hdl_t; +typedef struct topo_node tnode_t; +typedef struct topo_walk topo_walk_t; +typedef struct topo_schema_walk topo_schema_walk_t; +typedef uint64_t topo_instance_t; +typedef uint32_t topo_version_t; + +typedef struct topo_list { + struct topo_list *l_prev; + struct topo_list *l_next; +} topo_list_t; + +typedef struct topo_faclist { + topo_list_t tf_list; + tnode_t *tf_node; +} topo_faclist_t; + +typedef struct topo_digraph topo_digraph_t; +typedef struct topo_vertex topo_vertex_t; +typedef struct topo_edge topo_edge_t; + +typedef struct topo_path { + const char *tsp_fmristr; + nvlist_t *tsp_fmri; + topo_list_t tsp_components; +} topo_path_t; + +typedef struct topo_path_component { + topo_list_t tspc_link; + topo_vertex_t *tspc_vertex; +} topo_path_component_t; + +/* + * The following functions, error codes and data structures are private + * to libtopo snapshot consumers and enumerator modules. + */ +extern topo_hdl_t *topo_open(int, const char *, int *); +extern void topo_close(topo_hdl_t *); +extern char *topo_snap_hold(topo_hdl_t *, const char *, int *); +extern void topo_snap_release(topo_hdl_t *); + +/* + * Snapshot walker support + */ +typedef int (*topo_walk_cb_t)(topo_hdl_t *, tnode_t *, void *); + +extern topo_walk_t *topo_walk_init(topo_hdl_t *, const char *, topo_walk_cb_t, + void *, int *); +extern int topo_walk_step(topo_walk_t *, int); +extern void topo_walk_fini(topo_walk_t *); +extern di_node_t topo_hdl_devinfo(topo_hdl_t *); +extern di_prom_handle_t topo_hdl_prominfo(topo_hdl_t *); + +/* + * Walk status returned from walker + */ +#define TOPO_WALK_ERR -1 +#define TOPO_WALK_NEXT 0 +#define TOPO_WALK_TERMINATE 1 + +/* + * Types of walks: depth-first (child) or breadth-first (sibling) + */ +#define TOPO_WALK_CHILD 0x0001 +#define TOPO_WALK_SIBLING 0x0002 + +/* + * Snapshot scheme walker support. + */ + +typedef enum topo_scheme_type { + TOPO_SCHEME_TREE, + TOPO_SCHEME_DIGRAPH +} topo_scheme_type_t; + +/* + * Callers should not copy this structure. It should be assumed that it will + * grow in the future. + */ +typedef struct topo_scheme_info { + const char *tsi_scheme; + topo_scheme_type_t tsi_type; +} topo_scheme_info_t; + +typedef int (*topo_scheme_walk_cb_f)(topo_hdl_t *, const topo_scheme_info_t *, + void *); +extern int topo_scheme_walk(topo_hdl_t *, topo_scheme_walk_cb_f, void *); + +/* + * FMRI helper routines + */ +extern int topo_fmri_present(topo_hdl_t *, nvlist_t *, int *); +extern int topo_fmri_replaced(topo_hdl_t *, nvlist_t *, int *); +extern int topo_fmri_contains(topo_hdl_t *, nvlist_t *, nvlist_t *, int *); +extern int topo_fmri_expand(topo_hdl_t *, nvlist_t *, int *); +extern int topo_fmri_unusable(topo_hdl_t *, nvlist_t *, int *); +extern int topo_fmri_service_state(topo_hdl_t *, nvlist_t *, int *); +extern int topo_fmri_retire(topo_hdl_t *, nvlist_t *, int *); +extern int topo_fmri_unretire(topo_hdl_t *, nvlist_t *, int *); +extern int topo_fmri_nvl2str(topo_hdl_t *, nvlist_t *, char **, int *); +extern int topo_fmri_str2nvl(topo_hdl_t *, const char *, nvlist_t **, int *); +extern int topo_fmri_asru(topo_hdl_t *, nvlist_t *, nvlist_t **, int *); +extern int topo_fmri_fru(topo_hdl_t *, nvlist_t *, nvlist_t **, + int *); +extern int topo_fmri_label(topo_hdl_t *, nvlist_t *, char **, int *); +extern int topo_fmri_serial(topo_hdl_t *, nvlist_t *, char **, int *); +extern int topo_fmri_compare(topo_hdl_t *, nvlist_t *, nvlist_t *, int *); +extern int topo_fmri_facility(topo_hdl_t *, nvlist_t *, const char *, + uint32_t, topo_walk_cb_t, void *, int *); + +/* + * Consolidation private utility functions + */ +extern ulong_t topo_fmri_strhash(topo_hdl_t *, const char *); +extern ulong_t topo_fmri_strhash_noauth(topo_hdl_t *, const char *); +extern boolean_t topo_fmri_strcmp(topo_hdl_t *, const char *, const char *); +extern boolean_t topo_fmri_strcmp_noauth(topo_hdl_t *, const char *, + const char *); + +/* + * Topo node utilities: callable from topo_walk_step() callback or module + * enumeration, topo_mod_enumerate() + */ +extern char *topo_node_name(tnode_t *); +extern topo_instance_t topo_node_instance(tnode_t *); +extern tnode_t *topo_node_parent(tnode_t *); +extern void *topo_node_private(tnode_t *); +extern int topo_node_flags(tnode_t *); +extern int topo_node_asru(tnode_t *, nvlist_t **, nvlist_t *, int *); +extern int topo_node_fru(tnode_t *, nvlist_t **, nvlist_t *, int *); +extern int topo_node_resource(tnode_t *, nvlist_t **, int *); +extern int topo_node_label(tnode_t *, char **, int *); +extern tnode_t *topo_node_lookup(tnode_t *, const char *, topo_instance_t); +extern int topo_method_invoke(tnode_t *node, const char *, topo_version_t, + nvlist_t *, nvlist_t **, int *); +extern boolean_t topo_method_supported(tnode_t *, const char *, + topo_version_t); +extern int topo_node_facility(topo_hdl_t *, tnode_t *, const char *, + uint32_t, topo_faclist_t *, int *); +extern int topo_node_child_walk(topo_hdl_t *, tnode_t *, topo_walk_cb_t, + void *, int *); +extern int topo_node_occupied(tnode_t *, boolean_t *); + +/* + * Node flags: denotes type of node + */ +#define TOPO_NODE_DEFAULT 0 +#define TOPO_NODE_FACILITY 1 + +#define TOPO_FAC_TYPE_SENSOR "sensor" +#define TOPO_FAC_TYPE_INDICATOR "indicator" + +/* + * Topo property get functions + */ +extern int topo_prop_get_int32(tnode_t *, const char *, const char *, + int32_t *, int *); +extern int topo_prop_get_uint32(tnode_t *, const char *, const char *, + uint32_t *, int *); +extern int topo_prop_get_int64(tnode_t *, const char *, const char *, + int64_t *, int *); +extern int topo_prop_get_uint64(tnode_t *, const char *, const char *, + uint64_t *, int *); +extern int topo_prop_get_double(tnode_t *, const char *, const char *, + double *, int *); +extern int topo_prop_get_string(tnode_t *, const char *, const char *, + char **, int *); +extern int topo_prop_get_fmri(tnode_t *, const char *, const char *, + nvlist_t **, int *); +extern int topo_prop_get_int32_array(tnode_t *, const char *, const char *, + int32_t **, uint_t *, int *); +extern int topo_prop_get_uint32_array(tnode_t *, const char *, const char *, + uint32_t **, uint_t *, int *); +extern int topo_prop_get_int64_array(tnode_t *, const char *, const char *, + int64_t **, uint_t *, int *); +extern int topo_prop_get_uint64_array(tnode_t *, const char *, const char *, + uint64_t **, uint_t *, int *); +extern int topo_prop_get_string_array(tnode_t *, const char *, const char *, + char ***, uint_t *, int *); +extern int topo_prop_get_fmri_array(tnode_t *, const char *, const char *, + nvlist_t ***, uint_t *, int *); + +/* + * Topo property set functions + */ +extern int topo_prop_set_int32(tnode_t *, const char *, const char *, int, + int32_t, int *); +extern int topo_prop_set_uint32(tnode_t *, const char *, const char *, int, + uint32_t, int *); +extern int topo_prop_set_int64(tnode_t *, const char *, const char *, + int, int64_t, int *); +extern int topo_prop_set_uint64(tnode_t *, const char *, const char *, + int, uint64_t, int *); +extern int topo_prop_set_double(tnode_t *, const char *, const char *, + int, double, int *); +extern int topo_prop_set_string(tnode_t *, const char *, const char *, + int, const char *, int *); +extern int topo_prop_set_fmri(tnode_t *, const char *, const char *, + int, const nvlist_t *, int *); +extern int topo_prop_set_int32_array(tnode_t *, const char *, const char *, int, + int32_t *, uint_t, int *); +extern int topo_prop_set_uint32_array(tnode_t *, const char *, const char *, + int, uint32_t *, uint_t, int *); +extern int topo_prop_set_int64_array(tnode_t *, const char *, const char *, + int, int64_t *, uint_t, int *); +extern int topo_prop_set_uint64_array(tnode_t *, const char *, const char *, + int, uint64_t *, uint_t, int *); +extern int topo_prop_set_string_array(tnode_t *, const char *, const char *, + int, const char **, uint_t, int *); +extern int topo_prop_set_fmri_array(tnode_t *, const char *, const char *, + int, const nvlist_t **, uint_t, int *); + +#define TOPO_PROP_IMMUTABLE 0 +#define TOPO_PROP_MUTABLE 0x01 +#define TOPO_PROP_NONVOLATILE 0x02 + +/* Protocol property group and property names */ +#define TOPO_PGROUP_PROTOCOL "protocol" /* Required property group */ +#define TOPO_PROP_RESOURCE "resource" /* resource FMRI */ +#define TOPO_PROP_ASRU "ASRU" /* ASRU FMRI */ +#define TOPO_PROP_FRU "FRU" /* FRU FMRI */ +#define TOPO_PROP_MOD "module" /* software module FMRI */ +#define TOPO_PROP_PKG "package" /* software package FMRI */ +#define TOPO_PROP_LABEL "label" /* property LABEL */ + +#define TOPO_METH_FAC_ENUM "fac_enum" + +/* + * System property group + */ +#define TOPO_PGROUP_SYSTEM "system" +#define TOPO_PROP_ISA "isa" +#define TOPO_PROP_MACHINE "machine" + +#define TOPO_PGROUP_IPMI "ipmi" + +/* + * These enum definitions are used to define a set of error tags associated with + * libtopo error conditions occuring during the adminstration of + * properties, invocation of methods and fmri-based queries. The shell script + * mkerror.sh is used to parse this file and create a corresponding topo_error.c + * source file. + * + * If you do something other than add a new error tag here, you may need to + * update the mkerror shell script as it is based upon simple regexps. + */ +typedef enum topo_prop_errno { + ETOPO_PROP_UNKNOWN = 3000, /* unknown topo prop error */ + ETOPO_PROP_NOENT, /* undefined property or property group */ + ETOPO_PROP_DEFD, /* static property already defined */ + ETOPO_PROP_NOMEM, /* memory limit exceeded during property allocation */ + ETOPO_PROP_TYPE, /* invalid property type */ + ETOPO_PROP_NAME, /* invalid property name */ + ETOPO_PROP_NOINHERIT, /* can not inherit property */ + ETOPO_PROP_NVL, /* malformed property nvlist */ + ETOPO_PROP_METHOD, /* get property method failed */ + ETOPO_PROP_END /* end of prop errno list (to ease auto-merge) */ +} topo_prop_errno_t; + +typedef enum topo_method_errno { + ETOPO_METHOD_UNKNOWN = 3100, /* unknown topo method error */ + ETOPO_METHOD_INVAL, /* invalid method registration */ + ETOPO_METHOD_NOTSUP, /* method not supported */ + ETOPO_METHOD_FAIL, /* method failed */ + ETOPO_METHOD_VEROLD, /* app is compiled to use obsolete method */ + ETOPO_METHOD_VERNEW, /* app is compiled to use obsolete method */ + ETOPO_METHOD_NOMEM, /* memory limit exceeded during method op */ + ETOPO_METHOD_DEFD, /* method op already defined */ + ETOPO_METHOD_END /* end of method errno list */ +} topo_method_errno_t; + +typedef enum topo_fmri_errno { + ETOPO_FMRI_UNKNOWN = 3200, /* unknown topo fmri error */ + ETOPO_FMRI_NVL, /* nvlist allocation failure for FMRI */ + ETOPO_FMRI_VERSION, /* invalid FMRI scheme version */ + ETOPO_FMRI_MALFORM, /* malformed FMRI */ + ETOPO_FMRI_NOMEM, /* memory limit exceeded */ + ETOPO_FMRI_END /* end of fmri errno list */ +} topo_fmri_errno_t; + +typedef enum topo_hdl_errno { + ETOPO_HDL_UNKNOWN = 3300, /* unknown topo handle error */ + ETOPO_HDL_ABIVER, /* handle opened with invalid ABI version */ + ETOPO_HDL_SNAP, /* snapshot already taken */ + ETOPO_HDL_INVAL, /* invalid argument specified */ + ETOPO_HDL_UUID, /* uuid already set */ + ETOPO_HDL_NOMEM, /* memory limit exceeded */ + ETOPO_HDL_END /* end of handle errno list */ +} topo_hdl_errno_t; + +extern const char *topo_strerror(int); +extern void topo_hdl_strfree(topo_hdl_t *, char *); +extern void topo_hdl_strfreev(topo_hdl_t *, char **, uint_t); +extern void topo_debug_set(topo_hdl_t *, const char *, const char *); + +/* + * The following functions and data structures to support property + * observability are private to the fmtopo command. + */ + +/* + * Each topology node advertises the name and data stability of each of its + * modules and properties. (see attributes(7)). + */ + +/* + * Topo stability attributes + */ +typedef enum topo_stability { + TOPO_STABILITY_UNKNOWN = 0, /* private to libtopo */ + TOPO_STABILITY_INTERNAL, /* private to libtopo */ + TOPO_STABILITY_PRIVATE, /* private to Sun */ + TOPO_STABILITY_OBSOLETE, /* scheduled for removal */ + TOPO_STABILITY_EXTERNAL, /* not controlled by Sun */ + TOPO_STABILITY_UNSTABLE, /* new or rapidly changing */ + TOPO_STABILITY_EVOLVING, /* less rapidly changing */ + TOPO_STABILITY_STABLE, /* mature interface from Sun */ + TOPO_STABILITY_STANDARD /* industry standard */ +} topo_stability_t; + +#define TOPO_STABILITY_MAX TOPO_STABILITY_STANDARD /* max valid stab */ + +typedef struct topo_pgroup_info { + const char *tpi_name; /* property group name */ + topo_stability_t tpi_namestab; /* stability of group name */ + topo_stability_t tpi_datastab; /* stability of all property values */ + topo_version_t tpi_version; /* version of pgroup definition */ +} topo_pgroup_info_t; + +extern topo_stability_t topo_name2stability(const char *); +extern const char *topo_stability2name(topo_stability_t); +extern void topo_pgroup_destroy(tnode_t *, const char *); +extern topo_pgroup_info_t *topo_pgroup_info(tnode_t *, const char *, int *); + +typedef enum { + TOPO_TYPE_INVALID = 0, + TOPO_TYPE_BOOLEAN, /* boolean */ + TOPO_TYPE_INT32, /* int32_t */ + TOPO_TYPE_UINT32, /* uint32_t */ + TOPO_TYPE_INT64, /* int64_t */ + TOPO_TYPE_UINT64, /* uint64_t */ + TOPO_TYPE_STRING, /* const char* */ + TOPO_TYPE_TIME, /* uint64_t */ + TOPO_TYPE_SIZE, /* uint64_t */ + TOPO_TYPE_FMRI, /* nvlist_t */ + TOPO_TYPE_INT32_ARRAY, /* array of int32_t */ + TOPO_TYPE_UINT32_ARRAY, /* array of uint32_t */ + TOPO_TYPE_INT64_ARRAY, /* array of int64_t */ + TOPO_TYPE_UINT64_ARRAY, /* array of uint64_t */ + TOPO_TYPE_STRING_ARRAY, /* array of const char* */ + TOPO_TYPE_FMRI_ARRAY, /* array of nvlist_t */ + TOPO_TYPE_DOUBLE /* double */ +} topo_type_t; + +extern nvlist_t *topo_prop_getprops(tnode_t *, int *err); +extern int topo_prop_getprop(tnode_t *, const char *, const char *, + nvlist_t *, nvlist_t **, int *); +extern int topo_prop_getpgrp(tnode_t *, const char *, nvlist_t **, int *); +extern int topo_prop_setprop(tnode_t *, const char *, nvlist_t *, + int, nvlist_t *, int *); +extern int topo_fmri_getprop(topo_hdl_t *, nvlist_t *, const char *, + const char *, nvlist_t *, nvlist_t **, int *); +extern int topo_fmri_getpgrp(topo_hdl_t *, nvlist_t *, const char *, + nvlist_t **, int *); +extern int topo_fmri_setprop(topo_hdl_t *, nvlist_t *, const char *, + nvlist_t *, int, nvlist_t *, int *); +extern void topo_pgroup_hcset(tnode_t *, nvlist_t *); + +/* Property node NVL names used in topo_prop_getprops */ +#define TOPO_PROP_GROUP "property-group" +#define TOPO_PROP_GROUP_NAME "property-group-name" +#define TOPO_PROP_GROUP_DSTAB "property-group-data-stability" +#define TOPO_PROP_GROUP_NSTAB "property-group-name-stability" +#define TOPO_PROP_GROUP_VERSION "property-group-version" +#define TOPO_PROP_VAL "property" +#define TOPO_PROP_VAL_NAME "property-name" +#define TOPO_PROP_VAL_VAL "property-value" +#define TOPO_PROP_VAL_TYPE "property-type" +#define TOPO_PROP_FLAG "property-flag" + +/* + * ARGS list used in topo property methods + */ +#define TOPO_PROP_ARGS "args" +#define TOPO_PROP_PARGS "private-args" + +extern int topo_xml_print(topo_hdl_t *, FILE *, const char *scheme, int *); + +extern void *topo_hdl_alloc(topo_hdl_t *, size_t); +extern void *topo_hdl_zalloc(topo_hdl_t *, size_t); +extern void topo_hdl_free(topo_hdl_t *, void *, size_t); +extern int topo_hdl_nvalloc(topo_hdl_t *, nvlist_t **, uint_t); +extern int topo_hdl_nvdup(topo_hdl_t *, nvlist_t *, nvlist_t **); +extern char *topo_hdl_strdup(topo_hdl_t *, const char *); +extern int topo_hdl_vasprintf(topo_hdl_t *, char **, const char *, + va_list) __VPRINTFLIKE(3); +extern int topo_hdl_asprintf(topo_hdl_t *, char **, const char *, + ...) __PRINTFLIKE(3); + +/* + * Interfaces for interacting with directed graph topologies + */ +extern topo_digraph_t *topo_digraph_get(topo_hdl_t *, const char *); +extern int topo_vertex_iter(topo_hdl_t *, topo_digraph_t *, + int (*)(topo_hdl_t *, topo_vertex_t *, boolean_t, void *), void *); +extern tnode_t *topo_vertex_node(topo_vertex_t *); +extern int topo_edge_iter(topo_hdl_t *, topo_vertex_t *, + int (*)(topo_hdl_t *, topo_edge_t *, boolean_t, void *), void *); +extern int topo_digraph_paths(topo_hdl_t *, topo_digraph_t *, + topo_vertex_t *, topo_vertex_t *, topo_path_t ***, uint_t *); +extern void topo_path_destroy(topo_hdl_t *, topo_path_t *); +extern int topo_digraph_serialize(topo_hdl_t *, topo_digraph_t *, FILE *); +extern topo_digraph_t *topo_digraph_deserialize(topo_hdl_t *, const char *, + size_t); +extern topo_vertex_t *topo_node_vertex(tnode_t *); + +/* + * Interfaces for converting sensor/indicator types, units, states, etc to + * a string + */ +extern void topo_sensor_type_name(uint32_t, char *, size_t); +extern void topo_sensor_units_name(uint32_t, char *, size_t); +extern void topo_led_type_name(uint32_t, char *, size_t); +extern void topo_led_state_name(uint32_t, char *, size_t); +extern void topo_sensor_state_name(uint32_t, uint32_t, char *, + size_t len); + +/* + * Defines for standard properties for sensors and indicators + */ +#define TOPO_PGROUP_FACILITY "facility" + +#define TOPO_SENSOR_READING "reading" +#define TOPO_SENSOR_STATE "state" +#define TOPO_SENSOR_CLASS "sensor-class" +#define TOPO_FACILITY_TYPE "type" +#define TOPO_SENSOR_UNITS "units" +#define TOPO_LED_MODE "mode" + +#define TOPO_PROP_THRESHOLD_LNC "threshold-lower-non-critical" +#define TOPO_PROP_THRESHOLD_LCR "threshold-lower-critical" +#define TOPO_PROP_THRESHOLD_LNR "threshold-lower-non-recoverable" + +#define TOPO_PROP_THRESHOLD_UNC "threshold-upper-non-critical" +#define TOPO_PROP_THRESHOLD_UCR "threshold-upper-critical" +#define TOPO_PROP_THRESHOLD_UNR "threshold-upper-non-recoverable" + +/* + * Sensor Classes + * + * The "sensor-class" property in the "facility" propgroup on + * facility nodes of type "sensor" should be set to one of these + * two values. + * + * Threshold sensors provide an analog sensor reading via the + * "reading" property in the facility propgroup. They will also + * provide one or more discrete states via the "state" property + * in the facility propgroup. + * + * Discrete sensors will not provide an analog reading by will + * provide one or more discrete states via the "state" property + * in the facility propgroup. + */ +#define TOPO_SENSOR_CLASS_THRESHOLD "threshold" +#define TOPO_SENSOR_CLASS_DISCRETE "discrete" + +/* + * Sensor unit types. We're using the unit types and corresponding + * codes described in section 43.17 of the IPMI 2.0 as a reference as it seems + * to be a reasonably comprehensive list. This also simplifies the IPMI + * facility provider code since the unit type codes will map exactly to what + * libtopo uses (so no conversion necessary). To allow for future growth if + * new unit types are added to IPMI in the future, while still allowing unit + * types not supported by IPMI to be represented, we include a gap between + * the last IPMI unit type and the first non-IPMI unit type. + */ +typedef enum topo_sensor_unit { + TOPO_SENSOR_UNITS_UNSPECIFIED = 0, + TOPO_SENSOR_UNITS_DEGREES_C, + TOPO_SENSOR_UNITS_DEGREES_F, + TOPO_SENSOR_UNITS_DEGREES_K, + TOPO_SENSOR_UNITS_VOLTS, + TOPO_SENSOR_UNITS_AMPS, + TOPO_SENSOR_UNITS_WATTS, + TOPO_SENSOR_UNITS_JOULES, + TOPO_SENSOR_UNITS_COULOMBS, + TOPO_SENSOR_UNITS_VA, + TOPO_SENSOR_UNITS_NITS, + TOPO_SENSOR_UNITS_LUMEN, + TOPO_SENSOR_UNITS_LUX, + TOPO_SENSOR_UNITS_CANDELA, + TOPO_SENSOR_UNITS_KPA, + TOPO_SENSOR_UNITS_PSI, + + TOPO_SENSOR_UNITS_NEWTON, + TOPO_SENSOR_UNITS_CFM, + TOPO_SENSOR_UNITS_RPM, + TOPO_SENSOR_UNITS_HZ, + TOPO_SENSOR_UNITS_MICROSEC, + TOPO_SENSOR_UNITS_MILLISEC, + TOPO_SENSOR_UNITS_SECS, + TOPO_SENSOR_UNITS_MIN, + TOPO_SENSOR_UNITS_HOUR, + TOPO_SENSOR_UNITS_DAY, + TOPO_SENSOR_UNITS_WEEK, + TOPO_SENSOR_UNITS_MIL, + TOPO_SENSOR_UNITS_INCHES, + TOPO_SENSOR_UNITS_FEET, + TOPO_SENSOR_UNITS_CUB_INCH, + TOPO_SENSOR_UNITS_CUB_FEET, + + TOPO_SENSOR_UNITS_MM, + TOPO_SENSOR_UNITS_CM, + TOPO_SENSOR_UNITS_METERS, + TOPO_SENSOR_UNITS_CUB_CM, + TOPO_SENSOR_UNITS_CUB_METER, + TOPO_SENSOR_UNITS_LITERS, + TOPO_SENSOR_UNITS_FLUID_OUNCE, + TOPO_SENSOR_UNITS_RADIANS, + TOPO_SENSOR_UNITS_STERADIANS, + TOPO_SENSOR_UNITS_REVOLUTIONS, + TOPO_SENSOR_UNITS_CYCLES, + TOPO_SENSOR_UNITS_GRAVITIES, + TOPO_SENSOR_UNITS_OUNCE, + TOPO_SENSOR_UNITS_POUND, + TOPO_SENSOR_UNITS_FOOT_POUND, + TOPO_SENSOR_UNITS_OZ_INCH, + + TOPO_SENSOR_UNITS_GAUSS, + TOPO_SENSOR_UNITS_GILBERTS, + TOPO_SENSOR_UNITS_HENRY, + TOPO_SENSOR_UNITS_MILHENRY, + TOPO_SENSOR_UNITS_FARAD, + TOPO_SENSOR_UNITS_MICROFARAD, + TOPO_SENSOR_UNITS_OHMS, + TOPO_SENSOR_UNITS_SIEMENS, + TOPO_SENSOR_UNITS_MOLE, + TOPO_SENSOR_UNITS_BECQUEREL, + TOPO_SENSOR_UNITS_PPM, + TOPO_SENSOR_UNITS_RESERVED1, + TOPO_SENSOR_UNITS_DECIBELS, + TOPO_SENSOR_UNITS_DBA, + TOPO_SENSOR_UNITS_DBC, + TOPO_SENSOR_UNITS_GRAY, + + TOPO_SENSOR_UNITS_SIEVERT, + TOPO_SENSOR_UNITS_COLOR_TEMP_K, + TOPO_SENSOR_UNITS_BIT, + TOPO_SENSOR_UNITS_KILOBIT, + TOPO_SENSOR_UNITS_MEGABIT, + TOPO_SENSOR_UNITS_GIGABIT, + TOPO_SENSOR_UNITS_BYTE, + TOPO_SENSOR_UNITS_KILOBYTE, + TOPO_SENSOR_UNITS_MEGABYTE, + TOPO_SENSOR_UNITS_GIGABYTE, + TOPO_SENSOR_UNITS_WORD, + TOPO_SENSOR_UNITS_DWORD, + TOPO_SENSOR_UNITS_QWORD, + TOPO_SENSOR_UNITS_MEMLINE, + TOPO_SENSOR_UNITS_HIT, + TOPO_SENSOR_UNITS_MISS, + + TOPO_SENSOR_UNITS_RETRY, + TOPO_SENSOR_UNITS_RESET, + TOPO_SENSOR_UNITS_OVERFLOW, + TOPO_SENSOR_UNITS_UNDERRUN, + TOPO_SENSOR_UNITS_COLLISION, + TOPO_SENSOR_UNITS_PACKETS, + TOPO_SENSOR_UNITS_MESSAGES, + TOPO_SENSOR_UNITS_CHARACTERS, + TOPO_SENSOR_UNITS_ERROR, + TOPO_SENSOR_UNITS_CE, + TOPO_SENSOR_UNITS_UE, + TOPO_SENSOR_UNITS_FATAL_ERROR, + TOPO_SENSOR_UNITS_GRAMS, + + TOPO_SENSOR_UNITS_PERCENT = 512, + /* + * This is used for a unitless control type sensor. + */ + TOPO_SENSOR_UNITS_NONE +} topo_sensor_unit_t; + +/* + * These defines are used by the topo_method_sensor_failure to indicate + * whether the source of a sensor failure is believed to be the result of an + * internal failure, external condition or unknown + */ +#define TOPO_SENSOR_ERRSRC_UNKNOWN 0 +#define TOPO_SENSOR_ERRSRC_INTERNAL 1 +#define TOPO_SENSOR_ERRSRC_EXTERNAL 2 + +/* + * Sensor Types amd the associated sensor-type-specific states + * + * These are used to decode the type and state properties in the facility + * propgroup on facility nodes of type sensor. + * + * Again we're basically using the same defines as listed in the IPMI + * specification (see section 42) as it's serves as a good starting point and + * simplifies the IPMI provider code. Of course other facility providers will + * need to convert from their native codes to the topo code when they set the + * type and state properties. + */ +#define TOPO_SENSOR_TYPE_RESERVED 0x0000 +#define TOPO_SENSOR_TYPE_TEMP 0x0001 +#define TOPO_SENSOR_TYPE_VOLTAGE 0x0002 +#define TOPO_SENSOR_TYPE_CURRENT 0x0003 +#define TOPO_SENSOR_TYPE_FAN 0x0004 +#define TOPO_SENSOR_TYPE_PHYSICAL 0x0005 + +#define TOPO_SENSOR_STATE_PHYSICAL_GENERAL 0x0001 +#define TOPO_SENSOR_STATE_PHYSICAL_BAY 0x0002 +#define TOPO_SENSOR_STATE_PHYSICAL_CARD 0x0004 +#define TOPO_SENSOR_STATE_PHYSICAL_PROCESSOR 0x0008 +#define TOPO_SENSOR_STATE_PHYSICAL_LAN 0x0010 +#define TOPO_SENSOR_STATE_PHYSICAL_DOCK 0x0020 +#define TOPO_SENSOR_STATE_PHYSICAL_FAN 0x0040 + +#define TOPO_SENSOR_TYPE_PLATFORM 0x0006 + +#define TOPO_SENSOR_STATE_PLATFORM_SECURE 0x0001 +#define TOPO_SENSOR_STATE_PLATFORM_USER_PASS 0x0002 +#define TOPO_SENSOR_STATE_PLATFORM_SETUP_PASS 0x0004 +#define TOPO_SENSOR_STATE_PLATFORM_NETWORK_PASS 0x0008 +#define TOPO_SENSOR_STATE_PLATFORM_OTHER_PASS 0x0010 +#define TOPO_SENSOR_STATE_PLATFORM_OUT_OF_BAND 0x0020 + +#define TOPO_SENSOR_TYPE_PROCESSOR 0x0007 + +#define TOPO_SENSOR_STATE_PROCESSOR_IERR 0x0001 +#define TOPO_SENSOR_STATE_PROCESSOR_THERMAL 0x0002 +#define TOPO_SENSOR_STATE_PROCESSOR_FRB1 0x0004 +#define TOPO_SENSOR_STATE_PROCESSOR_FRB2 0x0008 +#define TOPO_SENSOR_STATE_PROCESSOR_FRB3 0x0010 +#define TOPO_SENSOR_STATE_PROCESSOR_CONFIG 0x0020 +#define TOPO_SENSOR_STATE_PROCESSOR_SMBIOS 0x0040 +#define TOPO_SENSOR_STATE_PROCESSOR_PRESENT 0x0080 +#define TOPO_SENSOR_STATE_PROCESSOR_DISABLED 0x0100 +#define TOPO_SENSOR_STATE_PROCESSOR_TERMINATOR 0x0200 +#define TOPO_SENSOR_STATE_PROCESSOR_THROTTLED 0x0400 + +#define TOPO_SENSOR_TYPE_POWER_SUPPLY 0x0008 + +#define TOPO_SENSOR_STATE_POWER_SUPPLY_PRESENT 0x0001 +#define TOPO_SENSOR_STATE_POWER_SUPPLY_FAILURE 0x0002 +#define TOPO_SENSOR_STATE_POWER_SUPPLY_PREDFAIL 0x0004 +#define TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_LOST 0x0008 +#define TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_RANGE 0x0010 +#define TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_RANGE_PRES 0x0020 +#define TOPO_SENSOR_STATE_POWER_SUPPLY_CONFIG_ERR 0x0040 + +#define TOPO_SENSOR_TYPE_POWER_UNIT 0x0009 + +#define TOPO_SENSOR_STATE_POWER_UNIT_OFF 0x0001 +#define TOPO_SENSOR_STATE_POWER_UNIT_CYCLE 0x0002 +#define TOPO_SENSOR_STATE_POWER_UNIT_240_DOWN 0x0004 +#define TOPO_SENSOR_STATE_POWER_UNIT_INTERLOCK_DOWN 0x0008 +#define TOPO_SENSOR_STATE_POWER_UNIT_AC_LOST 0x0010 +#define TOPO_SENSOR_STATE_POWER_UNIT_SOFT_FAILURE 0x0020 +#define TOPO_SENSOR_STATE_POWER_UNIT_FAIL 0x0040 +#define TOPO_SENSOR_STATE_POWER_UNIT_PREDFAIL 0x0080 + +#define TOPO_SENSOR_TYPE_COOLING 0x000A +#define TOPO_SENSOR_TYPE_OTHER 0x000B + +#define TOPO_SENSOR_TYPE_MEMORY 0x000C + +#define TOPO_SENSOR_STATE_MEMORY_CE 0x0001 +#define TOPO_SENSOR_STATE_MEMORY_UE 0x0002 +#define TOPO_SENSOR_STATE_MEMORY_PARITY 0x0004 +#define TOPO_SENSOR_STATE_MEMORY_SCRUB_FAIL 0x0008 +#define TOPO_SENSOR_STATE_MEMORY_DISABLED 0x0010 +#define TOPO_SENSOR_STATE_MEMORY_CE_LOG_LIMIT 0x0020 +#define TOPO_SENSOR_STATE_MEMORY_PRESENT 0x0040 +#define TOPO_SENSOR_STATE_MEMORY_CONFIG_ERR 0x0080 +#define TOPO_SENSOR_STATE_MEMORY_SPARE 0x0100 +#define TOPO_SENSOR_STATE_MEMORY_THROTTLED 0x0200 +#define TOPO_SENSOR_STATE_MEMORY_OVERTEMP 0x0400 + +#define TOPO_SENSOR_TYPE_BAY 0x000D + +#define TOPO_SENSOR_STATE_BAY_PRESENT 0x0001 +#define TOPO_SENSOR_STATE_BAY_FAULT 0x0002 +#define TOPO_SENSOR_STATE_BAY_PREDFAIL 0x0004 +#define TOPO_SENSOR_STATE_BAY_SPARE 0x0008 +#define TOPO_SENSOR_STATE_BAY_CHECK 0x0010 +#define TOPO_SENSOR_STATE_BAY_CRITICAL 0x0020 +#define TOPO_SENSOR_STATE_BAY_FAILED 0x0040 +#define TOPO_SENSOR_STATE_BAY_REBUILDING 0x0080 +#define TOPO_SENSOR_STATE_BAY_ABORTED 0x0100 + +#define TOPO_SENSOR_TYPE_POST_RESIZE 0x000E + +#define TOPO_SENSOR_TYPE_FIRMWARE 0x000F + +#define TOPO_SENSOR_STATE_FIRMWARE_ERROR 0x0001 +#define TOPO_SENSOR_STATE_FIRMWARE_HANG 0x0002 +#define TOPO_SENSOR_STATE_FIRMWARE_PROGRESS 0x0004 + +#define TOPO_SENSOR_TYPE_EVENT_LOG 0x0010 + +#define TOPO_SENSOR_STATE_EVENT_LOG_CE 0x0001 +#define TOPO_SENSOR_STATE_EVENT_LOG_TYPE 0x0002 +#define TOPO_SENSOR_STATE_EVENT_LOG_RESET 0x0004 +#define TOPO_SENSOR_STATE_EVENT_LOG_ALL 0x0008 +#define TOPO_SENSOR_STATE_EVENT_LOG_FULL 0x0010 +#define TOPO_SENSOR_STATE_EVENT_LOG_ALMOST_FULL 0x0020 + +#define TOPO_SENSOR_TYPE_WATCHDOG1 0x0011 + +#define TOPO_SENSOR_STATE_WATCHDOG_BIOS_RESET 0x0001 +#define TOPO_SENSOR_STATE_WATCHDOG_OS_RESET 0x0002 +#define TOPO_SENSOR_STATE_WATCHDOG_OS_SHUTDOWN 0x0004 +#define TOPO_SENSOR_STATE_WATCHDOG_OS_PWR_DOWN 0x0008 +#define TOPO_SENSOR_STATE_WATCHDOG_OS_PWR_CYCLE 0x0010 +#define TOPO_SENSOR_STATE_WATCHDOG_OS_NMI_DIAG 0x0020 +#define TOPO_SENSOR_STATE_WATCHDOG_EXPIRED 0x0040 +#define TOPO_SENSOR_STATE_WATCHDOG_PRE_TIMEOUT_INT 0x0080 + +#define TOPO_SENSOR_TYPE_SYSTEM 0x0012 + +#define TOPO_SENSOR_STATE_SYSTEM_RECONF 0x0001 +#define TOPO_SENSOR_STATE_SYSTEM_BOOT 0x0002 +#define TOPO_SENSOR_STATE_SYSTEM_UNKNOWN_HW_FAILURE 0x0004 +#define TOPO_SENSOR_STATE_SYSTEM_AUX_LOG_UPDATED 0x0008 +#define TOPO_SENSOR_STATE_SYSTEM_PEF_ACTION 0x0010 +#define TOPO_SENSOR_STATE_SYSTEM_TIMETAMP_CLOCKSYNC 0x0020 + +#define TOPO_SENSOR_TYPE_CRITICAL 0x0013 + +#define TOPO_SENSOR_STATE_CRITICAL_EXT_NMI 0x0001 +#define TOPO_SENSOR_STATE_CRITICAL_BUS_TIMEOUT 0x0002 +#define TOPO_SENSOR_STATE_CRITICAL_IO_NMI 0x0004 +#define TOPO_SENSOR_STATE_CRITICAL_SW_NMI 0x0008 +#define TOPO_SENSOR_STATE_CRITICAL_PCI_PERR 0x0010 +#define TOPO_SENSOR_STATE_CRITICAL_PCI_SERR 0x0020 +#define TOPO_SENSOR_STATE_CRITICAL_EISA_FAILSAFE 0x0040 +#define TOPO_SENSOR_STATE_CRITICAL_BUS_CE 0x0080 +#define TOPO_SENSOR_STATE_CRITICAL_BUS_UE 0x0100 +#define TOPO_SENSOR_STATE_CRITICAL_FATAL_NMI 0x0200 +#define TOPO_SENSOR_STATE_CRITICAL_BUS_FATAL_ERR 0x0400 +#define TOPO_SENSOR_STATE_CRITICAL_BUS_DEGRADED 0x0800 + +#define TOPO_SENSOR_TYPE_BUTTON 0x0014 + +#define TOPO_SENSOR_STATE_BUTTON_PWR 0x0001 +#define TOPO_SENSOR_STATE_BUTTON_SLEEP 0x0002 +#define TOPO_SENSOR_STATE_BUTTON_RESET 0x0004 +#define TOPO_SENSOR_STATE_BUTTON_FRU_LATCH 0x0008 +#define TOPO_SENSOR_STATE_BUTTON_FRU_SERVICE 0x0010 + +#define TOPO_SENSOR_TYPE_MODULE 0x0015 +#define TOPO_SENSOR_TYPE_MICROCONTROLLER 0x0016 +#define TOPO_SENSOR_TYPE_CARD 0x0017 +#define TOPO_SENSOR_TYPE_CHASSIS 0x0018 + +#define TOPO_SENSOR_TYPE_CHIPSET 0x0019 + +#define TOPO_SENSOR_STATE_CHIPSET_PWR_CTL_FAIL 0x0001 + +#define TOPO_SENSOR_TYPE_FRU 0x001A + +#define TOPO_SENSOR_TYPE_CABLE 0x001B + +#define TOPO_SENSOR_STATE_CABLE_CONNECTED 0x0001 +#define TOPO_SENSOR_STATE_CABLE_CONFIG_ERR 0x0002 + +#define TOPO_SENSOR_TYPE_TERMINATOR 0x001C + +#define TOPO_SENSOR_TYPE_BOOT_STATE 0x001D + +#define TOPO_SENSOR_STATE_BOOT_STATE_BIOS_PWR_UP 0x0001 +#define TOPO_SENSOR_STATE_BOOT_STATE_BIOS_HARD_RESET 0x0002 +#define TOPO_SENSOR_STATE_BOOT_STATE_BIOS_WARM_RESET 0x0004 +#define TOPO_SENSOR_STATE_BOOT_STATE_PXE_BOOT 0x0008 +#define TOPO_SENSOR_STATE_BOOT_STATE_DIAG_BOOT 0x0010 +#define TOPO_SENSOR_STATE_BOOT_STATE_OS_HARD_RESET 0x0020 +#define TOPO_SENSOR_STATE_BOOT_STATE_OS_WARM_RESET 0x0040 +#define TOPO_SENSOR_STATE_BOOT_STATE_SYS_RESTART 0x0080 + +#define TOPO_SENSOR_TYPE_BOOT_ERROR 0x001E + +#define TOPO_SENSOR_STATE_BOOT_ERROR_NOMEDIA 0x0001 +#define TOPO_SENSOR_STATE_BOOT_ERROR_NON_BOOTABLE_DISK 0x0002 +#define TOPO_SENSOR_STATE_BOOT_ERROR_NO_PXE_SERVER 0x0004 +#define TOPO_SENSOR_STATE_BOOT_ERROR_INV_BOOT_SECT 0x0008 +#define TOPO_SENSOR_STATE_BOOT_ERROR_USR_SELECT_TIMEOUT 0x0010 + +#define TOPO_SENSOR_TYPE_BOOT_OS 0x001F + +#define TOPO_SENSOR_STATE_BOOT_OS_A_DRV_BOOT_COMPLETE 0x0001 +#define TOPO_SENSOR_STATE_BOOT_OS_C_DRV_BOOT_COMPLETE 0x0002 +#define TOPO_SENSOR_STATE_BOOT_OS_PXE_BOOT_COMPLETE 0x0004 +#define TOPO_SENSOR_STATE_BOOT_OS_DIAG_BOOT_COMPLETE 0x0008 +#define TOPO_SENSOR_STATE_BOOT_OS_CDROM_BOOT_COMPLETE 0x0010 +#define TOPO_SENSOR_STATE_BOOT_OS_ROM_BOOT_COMPLETE 0x0020 +#define TOPO_SENSOR_STATE_BOOT_OS_UNSPEC_BOOT_COMPLETE 0x0040 + +#define TOPO_SENSOR_TYPE_OS_SHUTDOWN 0x0020 + +#define TOPO_SENSOR_STATE_OS_SHUTDOWN_LOADING 0x0001 +#define TOPO_SENSOR_STATE_OS_SHUTDOWN_CRASH 0x0002 +#define TOPO_SENSOR_STATE_OS_STOP_GRACEFUL 0x0004 +#define TOPO_SENSOR_STATE_OS_SHUTDOWN_GRACEFUL 0x0008 +#define TOPO_SENSOR_STATE_OS_SHUTDOWN_PEF 0x0010 +#define TOPO_SENSOR_STATE_OS_SHUTDOWN_BMC 0x0020 + +#define TOPO_SENSOR_TYPE_SLOT 0x0021 + +#define TOPO_SENSOR_STATE_SLOT_FAULT_ASSERTED 0x0001 +#define TOPO_SENSOR_STATE_SLOT_IDENTIFY_ASSERTED 0x0002 +#define TOPO_SENSOR_STATE_SLOT_CONNECTED 0x0004 +#define TOPO_SENSOR_STATE_SLOT_INSTALL_READY 0x0008 +#define TOPO_SENSOR_STATE_SLOT_REMOVE_READY 0x0010 +#define TOPO_SENSOR_STATE_SLOT_PWR_OFF 0x0020 +#define TOPO_SENSOR_STATE_SLOT_REMOVED 0x0040 +#define TOPO_SENSOR_STATE_SLOT_INTERLOCK_ASSERTED 0x0080 +#define TOPO_SENSOR_STATE_SLOT_DISABLED 0x0100 +#define TOPO_SENSOR_STATE_SLOT_SPARE_DEVICE 0x0200 + +#define TOPO_SENSOR_TYPE_ACPI 0x0022 + +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S0_G0 0x0001 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S1 0x0002 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S2 0x0004 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S3 0x0008 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S4 0x0010 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S5_G2_SOFT_OFF 0x0020 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S4_S5_SOFT_OFF 0x0040 +#define TOPO_SENSOR_STATE_ACPI_PSATTE_G3_MECH_OFF 0x0080 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S1_S2_S3_SLEEP 0x0100 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_G1_SLEEP 0x0200 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_S5_OVERRIDE 0x0400 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_LEGACY_ON 0x0800 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_LEGACY_OFF 0x1000 +#define TOPO_SENSOR_STATE_ACPI_PSTATE_UNKNOWN 0x2000 + +#define TOPO_SENSOR_TYPE_WATCHDOG2 0x0023 + +#define TOPO_SENSOR_STATE_WATCHDOG2_EXPIRED 0x0001 +#define TOPO_SENSOR_STATE_WATCHDOG2_HARD_RESET 0x0002 +#define TOPO_SENSOR_STATE_WATCHDOG2_PWR_DOWN 0x0004 +#define TOPO_SENSOR_STATE_WATCHDOG2_PWR_CYCLE 0x0008 +#define TOPO_SENSOR_STATE_WATCHDOG2_RESERVED1 0x0010 +#define TOPO_SENSOR_STATE_WATCHDOG2_RESERVED2 0x0020 +#define TOPO_SENSOR_STATE_WATCHDOG2_RESERVED3 0x0040 +#define TOPO_SENSOR_STATE_WATCHDOG2_RESERVED4 0x0080 +#define TOPO_SENSOR_STATE_WATCHDOG2_TIMEOUT_INT 0x0100 + +#define TOPO_SENSOR_TYPE_ALERT 0x0024 + +#define TOPO_SENSOR_STATE_ALERT_PLAT_PAGE 0x0001 +#define TOPO_SENSOR_STATE_ALERT_PLAT_LAN_ALERT 0x0002 +#define TOPO_SENSOR_STATE_ALERT_PLAT_EVT_TRAP 0x0004 +#define TOPO_SENSOR_STATE_ALERT_PLAT_SNMP_TRAP 0x0008 + +#define TOPO_SENSOR_TYPE_PRESENCE 0x0025 + +#define TOPO_SENSOR_STATE_PRESENCE_PRESENT 0x0001 +#define TOPO_SENSOR_STATE_PRESENCE_ABSENT 0x0002 +#define TOPO_SENSOR_STATE_PRESENCE_DISABLED 0x0004 + +#define TOPO_SENSOR_TYPE_ASIC 0x0026 + +#define TOPO_SENSOR_TYPE_LAN 0x0027 + +#define TOPO_SENSOR_STATE_LAN_HEARTBEAT_LOST 0x0001 +#define TOPO_SENSOR_STATE_LAN_HEARTBEAT 0x0002 + +#define TOPO_SENSOR_TYPE_HEALTH 0x0028 + +#define TOPO_SENSOR_STATE_HEALTH_SENSOR_ACC_DEGRADED 0x0001 +#define TOPO_SENSOR_STATE_HEALTH_CNTLR_ACC_DEGRADED 0x0002 +#define TOPO_SENSOR_STATE_HEALTH_CNTLR_OFFLINE 0x0004 +#define TOPO_SENSOR_STATE_HEALTH_CNTLR_UNAVAIL 0x0008 +#define TOPO_SENSOR_STATE_HEALTH_SENSOR_FAILURE 0x0010 +#define TOPO_SENSOR_STATE_HEALTH_FRU_FAILURE 0x0020 + +#define TOPO_SENSOR_TYPE_BATTERY 0x0029 + +#define TOPO_SENSOR_STATE_BATTERY_LOW 0x0001 +#define TOPO_SENSOR_STATE_BATTERY_FAILED 0x0002 +#define TOPO_SENSOR_STATE_BATTERY_PRESENCE 0x0004 + +#define TOPO_SENSOR_TYPE_AUDIT 0x002A + +#define TOPO_SENSOR_STATE_AUDIT_SESSION_ACTIVATED 0x0001 +#define TOPO_SENSOR_STATE_AUDIT_SESSION_DEACTIVATED 0x0002 + +#define TOPO_SENSOR_TYPE_VERSION 0x002B + +#define TOPO_SENSOR_STATE_VERSION_HW_CHANGE 0x0001 +#define TOPO_SENSOR_STATE_VERSION_SW_CHANGE 0x0002 +#define TOPO_SENSOR_STATE_VERSION_HW_INCOMPATIBLE 0x0004 +#define TOPO_SENSOR_STATE_VERSION_SW_INCOMPATIBLE 0x0008 +#define TOPO_SENSOR_STATE_VERSION_HW_INVAL 0x0010 +#define TOPO_SENSOR_STATE_VERSION_SW_INVAL 0x0020 +#define TOPO_SENSOR_STATE_VERSION_HW_CHANGE_SUCCESS 0x0040 +#define TOPO_SENSOR_STATE_VERSION_SW_CHANGE_SUCCESS 0x0080 + +#define TOPO_SENSOR_TYPE_FRU_STATE 0x002C + +#define TOPO_SENSOR_STATE_FRU_STATE_NOT_INSTALLED 0x0001 +#define TOPO_SENSOR_STATE_FRU_STATE_INACTIVE 0x0002 +#define TOPO_SENSOR_STATE_FRU_STATE_ACT_REQ 0x0004 +#define TOPO_SENSOR_STATE_FRU_STATE_ACT_INPROGRESS 0x0008 +#define TOPO_SENSOR_STATE_FRU_STATE_ACTIVE 0x0010 +#define TOPO_SENSOR_STATE_FRU_STATE_DEACT_REQ 0x0020 +#define TOPO_SENSOR_STATE_FRU_STATE_DEACT_INPROGRESS 0x0040 +#define TOPO_SENSOR_STATE_FRU_STATE_COMM_LOST 0x0080 + +/* + * We simplify the IPMI sensor type code defines by combining the generic + * and sensor-specific codes into a single range. Because there's overlap + * between the two ranges we offset the generic type codes by 0x0100 + * which allows ample room in the hole for future expansion of the table to + * accommodate either additions to the IPMI spec or to support new sensor types + * for alternate provider modules. + */ +#define TOPO_SENSOR_TYPE_THRESHOLD_STATE 0x0101 + +#define TOPO_SENSOR_STATE_THRESH_LOWER_NONCRIT 0x0001 +#define TOPO_SENSOR_STATE_THRESH_LOWER_CRIT 0x0002 +#define TOPO_SENSOR_STATE_THRESH_LOWER_NONREC 0x0004 +#define TOPO_SENSOR_STATE_THRESH_UPPER_NONCRIT 0x0008 +#define TOPO_SENSOR_STATE_THRESH_UPPER_CRIT 0x0010 +#define TOPO_SENSOR_STATE_THRESH_UPPER_NONREC 0x0020 + +#define TOPO_SENSOR_TYPE_GENERIC_USAGE 0x0102 + +#define TOPO_SENSOR_STATE_GENERIC_USAGE_IDLE 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_USAGE_ACTIVE 0x0002 +#define TOPO_SENSOR_STATE_GENERIC_USAGE_BUSY 0x0004 + +#define TOPO_SENSOR_TYPE_GENERIC_STATE 0x0103 + +#define TOPO_SENSOR_STATE_GENERIC_STATE_DEASSERTED 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_STATE_ASSERTED 0x0002 + +#define TOPO_SENSOR_TYPE_GENERIC_PREDFAIL 0x0104 + +#define TOPO_SENSOR_STATE_GENERIC_PREDFAIL_DEASSERTED 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_PREDFAIL_ASSERTED 0x0002 + +#define TOPO_SENSOR_TYPE_GENERIC_LIMIT 0x0105 + +#define TOPO_SENSOR_STATE_GENERIC_LIMIT_NOT_EXCEEDED 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_LIMIT_EXCEEDED 0x0002 + +#define TOPO_SENSOR_TYPE_GENERIC_PERFORMANCE 0x0106 + +#define TOPO_SENSOR_STATE_GENERIC_PERFORMANCE_MET 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_PERFORMANCE_LAGS 0x0002 + +#define TOPO_SENSOR_TYPE_SEVERITY 0x0107 + +#define TOPO_SENSOR_STATE_SEVERITY_OK 0x0001 +#define TOPO_SENSOR_STATE_SEVERITY_NONCRIT_GOING_HIGH 0x0002 +#define TOPO_SENSOR_STATE_SEVERITY_CRIT_GOING_HIGH 0x0004 +#define TOPO_SENSOR_STATE_SEVERITY_NONREC_GOING_HIGH 0x0008 +#define TOPO_SENSOR_STATE_SEVERITY_NONCRIT_GOING_LOW 0x0010 +#define TOPO_SENSOR_STATE_SEVERITY_CRIT_GOING_LOW 0x0020 +#define TOPO_SENSOR_STATE_SEVERITY_NONREC_GOING_LOW 0x0020 +#define TOPO_SENSOR_STATE_SEVERITY_MONITOR 0x0040 +#define TOPO_SENSOR_STATE_SEVERITY_INFORMATIONAL 0x0080 + +#define TOPO_SENSOR_TYPE_GENERIC_PRESENCE 0x0108 + +#define TOPO_SENSOR_STATE_GENERIC_PRESENCE_DEASSERTED 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_PRESENCE_ASSERTED 0x0002 + +#define TOPO_SENSOR_TYPE_GENERIC_AVAILABILITY 0x0109 + +#define TOPO_SENSOR_STATE_GENERIC_AVAIL_DEASSERTED 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_AVAIL_ASSERTED 0x0002 + +#define TOPO_SENSOR_TYPE_GENERIC_STATUS 0x010A + +#define TOPO_SENSOR_STATE_GENERIC_STATUS_RUNNING 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_STATUS_IN_TEST 0x0002 +#define TOPO_SENSOR_STATE_GENERIC_STATUS_POWER_OFF 0x0004 +#define TOPO_SENSOR_STATE_GENERIC_STATUS_ONLINE 0x0008 +#define TOPO_SENSOR_STATE_GENERIC_STATUS_OFFLINE 0x0010 +#define TOPO_SENSOR_STATE_GENERIC_STATUS_OFF_DUTY 0x0020 +#define TOPO_SENSOR_STATE_GENERIC_STATUS_DEGRADED 0x0040 +#define TOPO_SENSOR_STATE_GENERIC_STATUS_POWER_SAVE 0x0080 +#define TOPO_SENSOR_STATE_GENERIC_STATUS_INSTALL_ERR 0x0100 + +#define TOPO_SENSOR_TYPE_GENERIC_REDUNDANCY 0x010B + +/* + * ACPI power state + */ +#define TOPO_SENSOR_TYPE_GENERIC_ACPI 0x010C + +#define TOPO_SENSOR_STATE_GENERIC_ACPI_D0 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_ACPI_D1 0x0002 +#define TOPO_SENSOR_STATE_GENERIC_ACPI_D2 0x0004 +#define TOPO_SENSOR_STATE_GENERIC_ACPI_D3 0x0008 + +/* + * These sensor types don't exist in the IPMI spec, but allow consumers to + * associate discrete sensors with component failure. The 'ok' sensor is the + * inverse of the 'failure' sensor. Note that the values intentionally mimic + * TOPO_SENSOR_TYPE_GENERIC_STATE, so that you can use existing IPMI sensors + * but just change the type to get semantically meaningful behavior. + */ +#define TOPO_SENSOR_TYPE_GENERIC_FAILURE 0x010D + +#define TOPO_SENSOR_STATE_GENERIC_FAIL_DEASSERTED 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_FAIL_NONRECOV 0x0002 +#define TOPO_SENSOR_STATE_GENERIC_FAIL_CRITICAL 0x0004 + +#define TOPO_SENSOR_TYPE_GENERIC_OK 0x010E + +#define TOPO_SENSOR_STATE_GENERIC_OK_DEASSERTED 0x0001 +#define TOPO_SENSOR_STATE_GENERIC_OK_ASSERTED 0x0002 + +/* + * This represents a synthetic sensor that someone has created. That is, it has + * a value, but does not represent a true physical measurement of some kind. The + * most common example of this is a control-style measurement. + */ +#define TOPO_SENSOR_TYPE_SYNTHETIC 0x10F + +/* + * Indicator modes and types + */ +typedef enum topo_led_state { + TOPO_LED_STATE_OFF = 0, + TOPO_LED_STATE_ON +} topo_led_state_t; + +#define TOPO_FAC_TYPE_ANY 0xFFFFFFFF + +/* + * This list is limited to the set of LED's that we're likely to manage through + * FMA. Thus is does not include things like power or activity LED's + */ +typedef enum topo_led_type { + TOPO_LED_TYPE_SERVICE = 0, + TOPO_LED_TYPE_LOCATE, + TOPO_LED_TYPE_OK2RM, + TOPO_LED_TYPE_PRESENT +} topo_led_type_t; + +typedef enum topo_slot_type { + TOPO_SLOT_TYPE_DIMM = 1, + TOPO_SLOT_TYPE_UFM, + TOPO_SLOT_TYPE_M2 +} topo_slot_type_t; + +/* + * Read permission indicates that we can read the raw firmware image in this + * slot off of the device. + * + * Write permission indicates that we can write a firmware image into this + * slot. + * + * These permission are orthogonal to the ability to simply report information + * about the firmware image in a slot. + */ +typedef enum topo_ufm_slot_mode { + TOPO_UFM_SLOT_MODE_NONE = 1, + TOPO_UFM_SLOT_MODE_RO, + TOPO_UFM_SLOT_MODE_WO, + TOPO_UFM_SLOT_MODE_RW +} topo_ufm_slot_mode_t; + +typedef struct topo_ufm_slot_info { + uint32_t usi_slotid; + topo_ufm_slot_mode_t usi_mode; + const char *usi_version; + boolean_t usi_active; + nvlist_t *usi_extra; +} topo_ufm_slot_info_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBTOPO_H */ diff --git a/illumos-x86_64/usr/include/fm/topo_hc.h b/illumos-x86_64/usr/include/fm/topo_hc.h new file mode 100644 index 00000000..441669c3 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/topo_hc.h @@ -0,0 +1,362 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 Joyent, Inc. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _TOPO_HC_H +#define _TOPO_HC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Allowable hardware component names for hc FMRIs + */ +#define BANK "bank" +#define BAY "bay" +#define BLADE "blade" +#define BRANCH "branch" +#define CACHE "cache" +#define CCD "ccd" +#define CCX "ccx" +#define CMP "CMP" +#define CENTERPLANE "centerplane" +#define CHASSIS "chassis" +#define CHIP "chip" +#define CHIPSET "chipset" +#define CORE "core" +#define STRAND "strand" +#define CHIP_SELECT "chip-select" +#define CONTROLLER "controller" +#define CPU "cpu" +#define CPUBOARD "cpuboard" +#define DIMM "dimm" +#define DISK "disk" +#define DRAM "dram" +#define DRAMCHANNEL "dram-channel" +#define FAN "fan" +#define FANBOARD "fanboard" +#define FANMODULE "fanmodule" +#define HBA "hba" +#define HOSTBRIDGE "hostbridge" +#define INTERCONNECT "interconnect" +#define IOBOARD "ioboard" +#define IPORT "iport" +#define MEMBOARD "memboard" +#define MEMORYBUFFER "memory-buffer" +#define MEMORYCONTROL "memory-controller" +#define MICROCORE "micro-core" +#define MOTHERBOARD "motherboard" +#define NIU "niu" +#define NIUFN "niufn" +#define NVME "nvme" +#define PCI_BUS "pcibus" +#define PCI_DEVICE "pcidev" +#define PCI_FUNCTION "pcifn" +#define PCIEX_BUS "pciexbus" +#define PCIEX_DEVICE "pciexdev" +#define PCIEX_FUNCTION "pciexfn" +#define PCIEX_ROOT "pciexrc" +#define PCIEX_SWUP "pciexswu" +#define PCIEX_SWDWN "pciexswd" +#define PORT "port" +#define POWERBOARD "powerboard" +#define POWERMODULE "powermodule" +#define PSU "psu" +#define RANK "rank" +#define RECEPTACLE "receptacle" +#define RISER "riser" +#define SASEXPANDER "sas-expander" +#define SHELF "shelf" +#define SCSI_DEVICE "scsi-device" +#define SES_ENCLOSURE "ses-enclosure" +#define SLOT "slot" +#define SMP_DEVICE "smp-device" +#define SP "sp" +#define SUBCHASSIS "subchassis" +#define SYSTEMBOARD "systemboard" +#define TRANSCEIVER "transceiver" +#define UFM "ufm" +#define USB_DEVICE "usb-device" +#define XAUI "xaui" +#define XFP "xfp" + +/* + * Allowable hc node property group and property names + */ +#define TOPO_PGROUP_IO "io" +#define TOPO_IO_DEVTYPE "devtype" +#define TOPO_IO_DRIVER "driver" +#define TOPO_IO_INSTANCE "instance" +#define TOPO_IO_MODULE "module" +#define TOPO_IO_DEV "dev" +#define TOPO_IO_DEVID "devid" +#define TOPO_IO_DEV_PATH "devfs-path" +#define TOPO_IO_AP_PATH "ap-path" +#define TOPO_IO_PHYS_PATH "phys-path" + +#define TOPO_PGROUP_PCI "pci" +#define TOPO_PCI_VENDID "vendor-id" +#define TOPO_PCI_VENDNM "vendor-name" +#define TOPO_PCI_SUBSYSNM "subsystem-name" +#define TOPO_PCI_DEVID "device-id" +#define TOPO_PCI_DEVNM "device-name" +#define TOPO_PCI_EXCAP "extended-capabilities" +#define TOPO_PCI_BDF "BDF" +#define TOPO_PCI_CLASS "class-code" +#define TOPO_PCI_AADDR "assigned-addresses" + +#define TOPO_PCI_MAX_WIDTH "link-maximum-width" +#define TOPO_PCI_CUR_WIDTH "link-current-width" +#define TOPO_PCI_MAX_SPEED "link-maximum-speed" +#define TOPO_PCI_CUR_SPEED "link-current-speed" +#define TOPO_PCI_SUP_SPEED "link-supported-speeds" +#define TOPO_PCI_ADMIN_SPEED "link-admin-target-speed" + +#define TOPO_PGROUP_BINDING "binding" +#define TOPO_BINDING_OCCUPANT "occupant-path" +#define TOPO_BINDING_DRIVER "driver" +#define TOPO_BINDING_DEVCTL "devctl" +#define TOPO_BINDING_ENCLOSURE "enclosure" +#define TOPO_BINDING_SLOT "slot" +#define TOPO_BINDING_PORT "port" +#define TOPO_BINDING_PARENT_DEV "parent-device" + +#define TOPO_PGROUP_STORAGE "storage" +#define TOPO_STORAGE_INITIATOR_PORT "initiator-port" +#define TOPO_STORAGE_INITIATOR_PORT_PM "initiator-port-pm" +#define TOPO_STORAGE_TARGET_PORT "target-port" +#define TOPO_STORAGE_TARGET_PORT_L0ID "target-port-l0id" +#define TOPO_STORAGE_TARGET_PORT_L0IDS "target-port-l0ids" +#define TOPO_STORAGE_ATTACHED_PORT "attached-port" +#define TOPO_STORAGE_TARGET_PORT_PM "target-port-pm" +#define TOPO_STORAGE_ATTACHED_PORT_PM "attached-port-pm" +#define TOPO_STORAGE_DEVID "devid" +#define TOPO_STORAGE_LUN64 "lun64" +#define TOPO_STORAGE_DEVICE_TYPE "inquiry-device-type" +#define TOPO_STORAGE_MANUFACTURER "manufacturer" +#define TOPO_STORAGE_MODEL "model" +#define TOPO_STORAGE_FIRMWARE_REV "firmware-revision" +#define TOPO_STORAGE_SAS_PHY_MASK "receptacle-pm" +#define TOPO_STORAGE_SAS_CONNECTOR_TYPE "sas-connector-type" + +#define TOPO_PGROUP_SES "ses" +/* Applied any SES standard related topo node. */ +#define TOPO_PROP_NODE_ID "node-id" +#define TOPO_PROP_TARGET_PATH "target-path" +#define TOPO_PROP_SES_DEVID "ses-devid" +#define TOPO_PROP_SES_DEV_PATH "ses-devfs-path" +#define TOPO_PROP_SES_PHYS_PATH "ses-phys-path" +#define TOPO_PROP_SES_TARGET_PORT "ses-target-port" + +#define TOPO_PGROUP_SMP "smp" +/* host SMP target related info for an expander node. */ +#define TOPO_PROP_SMP_DEVID "smp-devid" +#define TOPO_PROP_SMP_DEV_PATH "smp-devfs-path" +#define TOPO_PROP_SMP_PHYS_PATH "smp-phys-path" +#define TOPO_PROP_SMP_TARGET_PORT "smp-target-port" +#define TOPO_PROP_SAS_ADDR "sas-address" +#define TOPO_PROP_PHY_COUNT "phy-count" +#define TOPO_PROP_PATHS "paths" +#define TOPO_PROP_CHASSIS_TYPE "chassis-type" +#define TOPO_PROP_SAS_PHY_MASK "phy-mask" +#define TOPO_PROP_SAS_CONNECTOR_TYPE "sas-connector-type" + +#define TOPO_PGROUP_PORT "port" +#define TOPO_PROP_PORT_TYPE "type" +#define TOPO_PROP_PORT_TYPE_SFF "sff" +#define TOPO_PROP_PORT_TYPE_USB "usb" +#define TOPO_PROP_PORT_TYPE_UNKNOWN "unknown" + +#define TOPO_PGROUP_TRANSCEIVER "transceiver" +#define TOPO_PROP_TRANSCEIVER_TYPE "type" +#define TOPO_PROP_TRANSCEIVER_USABLE "usable" + +#define TOPO_PGROUP_SFF_TRANSCEIVER "sff-transceiver" +#define TOPO_PORT_SFF_TRANSCEIVER_VENDOR "vendor" +#define TOPO_PORT_SFF_TRANSCEIVER_PN "part-number" +#define TOPO_PORT_SFF_TRANSCEIVER_REV "revision" +#define TOPO_PORT_SFF_TRANSCEIVER_SN "serial-number" + +#define TOPO_PGROUP_USB_PORT "usb-port" +#define TOPO_PROP_USB_PORT_LPORTS "logical-ports" +#define TOPO_PROP_USB_PORT_VERSIONS "usb-versions" +#define TOPO_PROP_USB_PORT_TYPE "port-type" +#define TOPO_PROP_USB_PORT_ATTRIBUTES "port-attributes" +#define TOPO_PROP_USB_PORT_A_VISIBLE "user-visible" +#define TOPO_PROP_USB_PORT_A_CONNECTED "port-connected" +#define TOPO_PROP_USB_PORT_A_DISCONNECTED "port-disconnected" +#define TOPO_PROP_USB_PORT_A_EXTERNAL "external-port" +#define TOPO_PROP_USB_PORT_A_INTERNAL "internal-port" +#define TOPO_PROP_USB_PORT_NATTRS 5 + +#define TOPO_PGROUP_USB_PROPS "usb-properties" +#define TOPO_PGROUP_USB_PROPS_VID "usb-vendor-id" +#define TOPO_PGROUP_USB_PROPS_PID "usb-product-id" +#define TOPO_PGROUP_USB_PROPS_REV "usb-revision-id" +#define TOPO_PGROUP_USB_PROPS_VNAME "usb-vendor-name" +#define TOPO_PGROUP_USB_PROPS_PNAME "usb-product-name" +#define TOPO_PGROUP_USB_PROPS_SN "usb-serialno" +#define TOPO_PGROUP_USB_PROPS_VERSION "usb-version" +#define TOPO_PGROUP_USB_PROPS_SPEED "usb-speed" +#define TOPO_PGROUP_USB_PROPS_PORT "usb-port" +#define TOPO_PGROUP_USB_PROPS_SUPPORTED_SPEEDS "usb-supported-speeds" +#define TOPO_PGROUP_USB_PROPS_MIN_SPEED "usb-minimum-speed" + + +/* + * These properties will exist on nodes enumerated by the ipmi module. They + * are consumed by the fac_prov_ipmi module + */ +#define TOPO_PROP_IPMI_ENTITY_ID "entity-id" +#define TOPO_PROP_IPMI_ENTITY_INST "entity-instance" + +/* + * This property can be statically set in a map file and is consumed by the + * fac_prov_ipmi module. + */ +#define TOPO_PROP_IPMI_ENTITY_LIST "entity-list" + +#define TOPO_PGROUP_SLOT "slot" +#define TOPO_PROP_SLOT_TYPE "slot-type" + +#define TOPO_PGROUP_DIMM_SLOT "dimm-slot" +#define TOPO_PROP_DIMM_SLOT_FORM "form-factor" +#define TOPO_DIMM_SLOT_FORM_DIMM "DIMM" +#define TOPO_DIMM_SLOT_FORM_SODIMM "SODIMM" +#define TOPO_DIMM_SLOT_FORM_FBDIMM "FBDIMM" + +#define TOPO_PGROUP_DIMM_PROPS "dimm-properties" +#define TOPO_PROP_DIMM_TYPE "dram-type" +#define TOPO_DIMM_TYPE_UNKNOWN "UNKNOWN" +#define TOPO_DIMM_TYPE_DDR "DDR" +#define TOPO_DIMM_TYPE_DDR2 "DDR2" +#define TOPO_DIMM_TYPE_DDR3 "DDR3" +#define TOPO_DIMM_TYPE_DDR4 "DDR4" +#define TOPO_DIMM_TYPE_DDR5 "DDR5" +#define TOPO_DIMM_TYPE_LPDDR "LPDDR" +#define TOPO_DIMM_TYPE_LPDDR2 "LPDDR2" +#define TOPO_DIMM_TYPE_LPDDR3 "LPDDR3" +#define TOPO_DIMM_TYPE_LPDDR4 "LPDDR4" +#define TOPO_DIMM_TYPE_LPDDR5 "LPDDR5" +#define TOPO_PROP_DIMM_MODULE_TYPE "module-type" +#define TOPO_PROP_DIMM_SIZE "size" +#define TOPO_PROP_DIMM_RANKS "ranks" +#define TOPO_PROP_DIMM_BANKS "banks" +#define TOPO_PROP_DIMM_BANK_GROUPS "bank-groups" +#define TOPO_PROP_DIMM_BANKS_PER_GROUP "banks-per-bank-group" +#define TOPO_PROP_DIMM_SUBCHANNELS "subchannels" +#define TOPO_PROP_DIMM_DATA_WIDTH "data-width" +#define TOPO_PROP_DIMM_ECC_WIDTH "ecc-width" +#define TOPO_PROP_DIMM_VDD "Vdd-mV" + +/* + * DIMM Component property group. Because it is hard to determine the number of + * each type of component that is present on a DIMM across the various SPD + * revisions without embedding part-specific knowledge and in some cases + * multiple logically different components are in the same physical part (such + * as the SPD and temperature sensor), we instead create a property group which + * contains this information about the components. For each class of component, + * there is information about manufacturer, revision, and device class type. + * There may be multiple instances of a given item. For example, DDR5 allows for + * 3 different PMIC manufacturers, etc. As such, for each item class, there will + * be an array where each entry corresponds to one another, as well as a + * top-level string array that describes what components one can look for. For + * each component there will potentially be the following properties: + * + * -revision: string[] + * -mfg-name: string[] + * -type: string[] + * -count: uint32 (Uncommon) + */ +#define TOPO_PGROUP_DIMM_COMPONENTS "dimm-components" +#define TOPO_PROP_DIMM_COMP "components" +#define TOPO_PROP_DIMM_COMP_DIE "dram-die" +#define TOPO_PROP_DIMM_COMP_SPD "spd" +#define TOPO_PROP_DIMM_COMP_TS "ts" +#define TOPO_PROP_DIMM_COMP_HS "hs" +#define TOPO_PROP_DIMM_COMP_PMIC "pmic" +#define TOPO_PROP_DIMM_COMP_CD "cd" +#define TOPO_PROP_DIMM_COMP_RCD "rcd" +#define TOPO_PROP_DIMM_COMP_DB "db" +#define TOPO_PROP_DIMM_COMP_MRCD "mrcd" +#define TOPO_PROP_DIMM_COMP_MDB "mdb" +#define TOPO_PROP_DIMM_COMP_DMB "dmb" + +#define TOPO_PGROUP_MOTHERBOARD "motherboard-properties" +#define TOPO_PROP_MB_MANUFACTURER "manufacturer" +#define TOPO_PROP_MB_PRODUCT "product-id" +#define TOPO_PROP_MB_ASSET "asset-tag" +#define TOPO_PROP_MB_FIRMWARE_VENDOR "firmware-vendor" +#define TOPO_PROP_MB_FIRMWARE_RELDATE "firmware-release-date" + +#define TOPO_PGROUP_UFM "ufm-properties" +#define TOPO_PROP_UFM_DESCR "ufm-description" + +#define TOPO_PGROUP_UFM_SLOT "ufm-slot-properties" +#define TOPO_PROP_UFM_SLOT_VERSION "ufm-slot-version" +#define TOPO_PROP_UFM_SLOT_MODE "ufm-slot-mode" +#define TOPO_PROP_UFM_SLOT_ACTIVE "ufm-slot-active" + +#define TOPO_PGROUP_DATALINK "datalink" +#define TOPO_PGROUP_DATALINK_PMAC "primary-mac-address" +#define TOPO_PGROUP_DATALINK_LINK_SPEED "link-speed" +#define TOPO_PGROUP_DATALINK_LINK_STATUS "link-status" +#define TOPO_PGROUP_DATALINK_LINK_STATUS_UP "up" +#define TOPO_PGROUP_DATALINK_LINK_STATUS_DOWN "down" +#define TOPO_PGROUP_DATALINK_LINK_STATUS_UNKNOWN "unknown" +#define TOPO_PGROUP_DATALINK_LINK_DUPLEX "link-duplex" +#define TOPO_PGROUP_DATALINK_LINK_DUPLEX_FULL "full" +#define TOPO_PGROUP_DATALINK_LINK_DUPLEX_HALF "half" +#define TOPO_PGROUP_DATALINK_LINK_DUPLEX_UNKNOWN "unknown" +#define TOPO_PGROUP_DATALINK_LINK_NAME "link-name" +#define TOPO_PGROUP_DATALINK_LINK_MEDIA "link-media" + +#define TOPO_PGROUP_NVME "nvme-properties" +#define TOPO_PROP_NVME_VER "nvme-version" + +/* + * Hardware cache properties. + */ +#define TOPO_PGROUP_CACHE "cache" +#define TOPO_PGROUP_CACHE_LEVEL "level" +#define TOPO_PGROUP_CACHE_WAYS "ways" +#define TOPO_PGROUP_CACHE_SETS "sets" +#define TOPO_PGROUP_CACHE_LINE_SIZE "line-size" +#define TOPO_PGROUP_CACHE_SIZE "size" +#define TOPO_PGROUP_CACHE_SYSTEM_ID "system-id" +#define TOPO_PGROUP_CACHE_TYPES "cache-types" +#define TOPO_PGROUP_CACHE_TYPES_DATA "data" +#define TOPO_PGROUP_CACHE_TYPES_INSTR "instruction" +#define TOPO_PGROUP_CACHE_FLAGS "cache-flags" +#define TOPO_PGROUP_CACHE_FLAGS_UNIFIED "unified" +#define TOPO_PGROUP_CACHE_FLAGS_FA "fully-associative" + +#ifdef __cplusplus +} +#endif + +#endif /* _TOPO_HC_H */ diff --git a/illumos-x86_64/usr/include/fm/topo_list.h b/illumos-x86_64/usr/include/fm/topo_list.h new file mode 100644 index 00000000..854d6e06 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/topo_list.h @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _TOPO_LIST_H +#define _TOPO_LIST_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define topo_list_prev(elem) ((void *)(((topo_list_t *)(elem))->l_prev)) +#define topo_list_next(elem) ((void *)(((topo_list_t *)(elem))->l_next)) + +extern void topo_list_append(topo_list_t *, void *); +extern void topo_list_prepend(topo_list_t *, void *); +extern void topo_list_insert_before(topo_list_t *, void *, void *); +extern void topo_list_insert_after(topo_list_t *, void *, void *); +extern void topo_list_delete(topo_list_t *, void *); +extern int topo_list_deepcopy(topo_hdl_t *, topo_list_t *, topo_list_t *, + size_t); + +/* Helpers for child/sibling lists */ +extern tnode_t *topo_child_first(tnode_t *); +extern tnode_t *topo_child_next(tnode_t *, tnode_t *); +extern topo_list_t *topo_sibling_list(tnode_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _TOPO_LIST_H */ diff --git a/illumos-x86_64/usr/include/fm/topo_method.h b/illumos-x86_64/usr/include/fm/topo_method.h new file mode 100644 index 00000000..1226e5e3 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/topo_method.h @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2020 Joyent, Inc. + */ +#ifndef _TOPO_METHOD_H +#define _TOPO_METHOD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct topo_imethod { + topo_list_t tim_list; /* next/prev pointers */ + pthread_mutex_t tim_lock; /* method entry lock */ + pthread_cond_t tim_cv; /* method entry cv */ + uint_t tim_busy; /* method entry busy indicator */ + char *tim_name; /* Method name */ + topo_version_t tim_version; /* Method version */ + topo_stability_t tim_stability; /* SMI stability of method */ + char *tim_desc; /* Method description */ + topo_method_f *tim_func; /* Method function */ + struct topo_mod *tim_mod; /* Ptr to controlling module */ +} topo_imethod_t; + +extern int topo_method_call(tnode_t *, const char *, topo_version_t, nvlist_t *, + nvlist_t **, int *); +extern topo_imethod_t *topo_method_lookup(tnode_t *, const char *); +extern int topo_prop_method_version_register(tnode_t *, const char *, + const char *, topo_type_t, const char *, topo_version_t, const nvlist_t *, + int *); + +/* + * These are for the private consumption of the sensor-transport fmd plugin + * and topo_method_sensor_failure() + */ +#define ST_SPOOF_FMRI "spoof_resource_fmri" +#define ST_SPOOF_SENSOR "spoof_sensor_name" +#define ST_SPOOF_STATE "spoof_sensor_state" + +/* + * FMRI methods + */ +#define TOPO_METH_ASRU_COMPUTE "topo_asru_compute" +#define TOPO_METH_FRU_COMPUTE "topo_fru_compute" +#define TOPO_METH_FMRI "topo_fmri" +#define TOPO_METH_NVL2STR "topo_nvl2str" +#define TOPO_METH_STR2NVL "topo_str2nvl" +#define TOPO_METH_COMPARE "topo_compare" +#define TOPO_METH_PROP_GET "topo_prop_get" +#define TOPO_METH_PGRP_GET "topo_pgrp_get" +#define TOPO_METH_PROP_SET "topo_prop_set" +#define TOPO_METH_FACILITY "topo_facility" +#define TOPO_METH_OCCUPIED "topo_occupied" +#define TOPO_METH_PATH_STR2NVL "topo_path_str2nvl" +#define TOPO_METH_PATH_NVL2STR "topo_path_nvl2str" + + +#define TOPO_METH_FMRI_VERSION 0 +#define TOPO_METH_FRU_COMPUTE_VERSION 0 +#define TOPO_METH_ASRU_COMPUTE_VERSION 0 +#define TOPO_METH_NVL2STR_VERSION 0 +#define TOPO_METH_STR2NVL_VERSION 0 +#define TOPO_METH_COMPARE_VERSION 0 +#define TOPO_METH_PROP_GET_VERSION 0 +#define TOPO_METH_PGRP_GET_VERSION 0 +#define TOPO_METH_PROP_SET_VERSION 0 +#define TOPO_METH_FACILITY_VERSION 0 +#define TOPO_METH_OCCUPIED_VERSION 0 + +#define TOPO_METH_ASRU_COMPUTE_DESC "Dynamic ASRU constructor" +#define TOPO_METH_FRU_COMPUTE_DESC "Dynamic FRU constructor" +#define TOPO_METH_FMRI_DESC "Dynamic FMRI constructor" +#define TOPO_METH_NVL2STR_DESC "FMRI to string" +#define TOPO_METH_STR2NVL_DESC "string to FMRI" +#define TOPO_METH_COMPARE_DESC "compare two FMRIs" +#define TOPO_METH_PROP_GET_DESC "get properties for FMRI" +#define TOPO_METH_PGRP_GET_DESC "get property group for FMRI" +#define TOPO_METH_PROP_SET_DESC "set properties for FMRI" +#define TOPO_METH_FACILITY_DESC "get facility for FMRI" +#define TOPO_METH_OCCUPIED_DESC "get occupant status" + +#define TOPO_METH_COMPARE_RET "compare-return" +#define TOPO_METH_OCCUPIED_RET "occupied-return" + +#define TOPO_METH_FMRI_ARG_NAME "child-name" +#define TOPO_METH_FMRI_ARG_INST "child-inst" +#define TOPO_METH_FMRI_ARG_NVL "args" +#define TOPO_METH_FMRI_ARG_PARENT "parent-fmri" +#define TOPO_METH_FMRI_ARG_AUTH "auth" +#define TOPO_METH_FMRI_ARG_PART "part" +#define TOPO_METH_FMRI_ARG_REV "rev" +#define TOPO_METH_FMRI_ARG_SER "serial" +#define TOPO_METH_FMRI_ARG_HCS "hc-specific" +#define TOPO_METH_FMRI_ARG_FMRI "fmri" +#define TOPO_METH_FMRI_ARG_SUBFMRI "sub-fmri" +#define TOPO_METH_FMRI_ARG_NV1 "nv1" +#define TOPO_METH_FMRI_ARG_NV2 "nv2" + +#ifdef __cplusplus +} +#endif + +#endif /* _TOPO_METHOD_H */ diff --git a/illumos-x86_64/usr/include/fm/topo_mod.h b/illumos-x86_64/usr/include/fm/topo_mod.h new file mode 100644 index 00000000..bb3796f8 --- /dev/null +++ b/illumos-x86_64/usr/include/fm/topo_mod.h @@ -0,0 +1,340 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright 2020 Joyent, Inc. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _TOPO_MOD_H +#define _TOPO_MOD_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Enumerator and method supplier module API + */ +typedef struct topo_mod topo_mod_t; + +typedef int topo_method_f(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *, + nvlist_t **); +typedef int topo_enum_f(topo_mod_t *, tnode_t *, const char *, topo_instance_t, + topo_instance_t, void *, void *); +typedef void topo_release_f(topo_mod_t *, tnode_t *); + +typedef struct topo_method { + const char *tm_name; /* Method name */ + const char *tm_desc; /* Method description */ + const topo_version_t tm_version; /* Method version */ + const topo_stability_t tm_stability; /* Attributes of method */ + topo_method_f *tm_func; /* Method function */ +} topo_method_t; + +typedef struct topo_modops { + topo_enum_f *tmo_enum; /* enumeration op */ + topo_release_f *tmo_release; /* resource release op */ +} topo_modops_t; + +typedef struct topo_mod_info { + const char *tmi_desc; /* module description */ + const char *tmi_scheme; /* enumeration scheme type */ + topo_version_t tmi_version; /* module version */ + const topo_modops_t *tmi_ops; /* module ops vector */ +} topo_modinfo_t; + +extern topo_mod_t *topo_mod_load(topo_mod_t *, const char *, topo_version_t); +extern void topo_mod_unload(topo_mod_t *); +extern int topo_mod_register(topo_mod_t *, const topo_modinfo_t *, + topo_version_t); +extern void topo_mod_unregister(topo_mod_t *); +extern int topo_mod_enumerate(topo_mod_t *, tnode_t *, const char *, + const char *, topo_instance_t, topo_instance_t, void *); +extern int topo_mod_enummap(topo_mod_t *mod, tnode_t *, const char *, + const char *); +extern char *topo_mod_product(topo_mod_t *); +extern void topo_mod_release(topo_mod_t *, tnode_t *); +extern void topo_mod_setspecific(topo_mod_t *, void *); +extern void *topo_mod_getspecific(topo_mod_t *); + +extern nvlist_t *topo_mod_cpufmri(topo_mod_t *, int, uint32_t, uint8_t, + const char *); +extern nvlist_t *topo_mod_devfmri(topo_mod_t *, int, const char *, + const char *); +extern nvlist_t *topo_mod_hcfmri(topo_mod_t *, tnode_t *, int, const char *, + topo_instance_t, nvlist_t *, nvlist_t *, const char *, const char *, + const char *); +extern nvlist_t *topo_mod_memfmri(topo_mod_t *, int, uint64_t, uint64_t, + const char *, int); +extern nvlist_t *topo_mod_modfmri(topo_mod_t *, int, const char *); +extern nvlist_t *topo_mod_pkgfmri(topo_mod_t *, int, const char *); +extern nvlist_t *topo_mod_swfmri(topo_mod_t *, int, + char *, char *, nvlist_t *, + char *, char *, char *, char *, int64_t, + char *, char *, int64_t, char *, int64_t, char **, uint_t); +extern int topo_mod_nvl2str(topo_mod_t *, nvlist_t *, char **); +extern int topo_mod_str2nvl(topo_mod_t *, const char *, nvlist_t **); +extern int topo_prop_setmutable(tnode_t *node, const char *pgname, + const char *pname, int *err); +extern int topo_prop_setnonvolatile(tnode_t *node, const char *pgname, + const char *pname, int *err); +/* + * Snapshot walker support + */ +typedef int (*topo_mod_walk_cb_t)(topo_mod_t *, tnode_t *, void *); + +extern topo_walk_t *topo_mod_walk_init(topo_mod_t *, tnode_t *, + topo_mod_walk_cb_t, void *, int *); + +/* + * Flags for topo_mod_memfmri + */ +#define TOPO_MEMFMRI_PA 0x0001 /* Valid physical address */ +#define TOPO_MEMFMRI_OFFSET 0x0002 /* Valid offset */ + +extern int topo_method_register(topo_mod_t *, tnode_t *, const topo_method_t *); +extern void topo_method_unregister(topo_mod_t *, tnode_t *, const char *); +extern void topo_method_unregister_all(topo_mod_t *, tnode_t *); + +extern di_node_t topo_mod_devinfo(topo_mod_t *); +extern ipmi_handle_t *topo_mod_ipmi_hold(topo_mod_t *); +extern void topo_mod_ipmi_rele(topo_mod_t *); +extern smbios_hdl_t *topo_mod_smbios(topo_mod_t *); +extern pcidb_hdl_t *topo_mod_pcidb(topo_mod_t *); +extern di_prom_handle_t topo_mod_prominfo(topo_mod_t *); +extern nvlist_t *topo_mod_auth(topo_mod_t *, tnode_t *); + +extern int topo_method_sensor_failure(topo_mod_t *, tnode_t *, topo_version_t, + nvlist_t *, nvlist_t **); + +/* + * FMRI methods + */ +#define TOPO_METH_LABEL "topo_label" +#define TOPO_METH_LABEL_DESC "label constructor" +#define TOPO_METH_LABEL_VERSION0 0 +#define TOPO_METH_LABEL_VERSION TOPO_METH_LABEL_VERSION0 +#define TOPO_METH_LABEL_ARG_NVL "label-specific" +#define TOPO_METH_LABEL_RET_STR "label-string" + +#define TOPO_METH_PRESENT "topo_present" +#define TOPO_METH_PRESENT_DESC "presence indicator" +#define TOPO_METH_PRESENT_VERSION0 0 +#define TOPO_METH_PRESENT_VERSION TOPO_METH_PRESENT_VERSION0 +#define TOPO_METH_PRESENT_RET "present-ret" + +#define TOPO_METH_REPLACED "topo_replaced" +#define TOPO_METH_REPLACED_DESC "replaced indicator" +#define TOPO_METH_REPLACED_VERSION0 0 +#define TOPO_METH_REPLACED_VERSION TOPO_METH_REPLACED_VERSION0 +#define TOPO_METH_REPLACED_RET "replaced-ret" + +#define TOPO_METH_UNUSABLE "topo_unusable" +#define TOPO_METH_UNUSABLE_DESC "unusable indicator" +#define TOPO_METH_UNUSABLE_VERSION0 0 +#define TOPO_METH_UNUSABLE_VERSION TOPO_METH_UNUSABLE_VERSION0 +#define TOPO_METH_UNUSABLE_RET "unusable-ret" + +#define TOPO_METH_SERVICE_STATE "topo_service_state" +#define TOPO_METH_SERVICE_STATE_DESC "service_state indicator" +#define TOPO_METH_SERVICE_STATE_VERSION0 0 +#define TOPO_METH_SERVICE_STATE_VERSION TOPO_METH_SERVICE_STATE_VERSION0 +#define TOPO_METH_SERVICE_STATE_RET "service_state-ret" + +#define TOPO_METH_RETIRE "topo_retire" +#define TOPO_METH_RETIRE_DESC "retire action" +#define TOPO_METH_RETIRE_VERSION0 0 +#define TOPO_METH_RETIRE_VERSION TOPO_METH_RETIRE_VERSION0 +#define TOPO_METH_RETIRE_RET "retire-ret" + +#define TOPO_METH_UNRETIRE "topo_unretire" +#define TOPO_METH_UNRETIRE_DESC "unretire action" +#define TOPO_METH_UNRETIRE_VERSION0 0 +#define TOPO_METH_UNRETIRE_VERSION TOPO_METH_UNRETIRE_VERSION0 +#define TOPO_METH_UNRETIRE_RET "unretire-ret" + +#define TOPO_METH_EXPAND "topo_expand" +#define TOPO_METH_EXPAND_DESC "expand FMRI" +#define TOPO_METH_EXPAND_VERSION0 0 +#define TOPO_METH_EXPAND_VERSION TOPO_METH_EXPAND_VERSION0 + +#define TOPO_METH_CONTAINS "topo_contains" +#define TOPO_METH_CONTAINS_DESC "FMRI contains sub-FMRI" +#define TOPO_METH_CONTAINS_VERSION0 0 +#define TOPO_METH_CONTAINS_VERSION TOPO_METH_CONTAINS_VERSION0 +#define TOPO_METH_CONTAINS_RET "contains-return" +#define TOPO_METH_FMRI_ARG_FMRI "fmri" +#define TOPO_METH_FMRI_ARG_SUBFMRI "sub-fmri" + +#define TOPO_METH_ASRU_COMPUTE "topo_asru_compute" +#define TOPO_METH_ASRU_COMPUTE_VERSION 0 +#define TOPO_METH_ASRU_COMPUTE_DESC "Dynamic ASRU constructor" + +#define TOPO_METH_FRU_COMPUTE "topo_fru_compute" +#define TOPO_METH_FRU_COMPUTE_VERSION 0 +#define TOPO_METH_FRU_COMPUTE_DESC "Dynamic FRU constructor" + +#define TOPO_METH_DISK_STATUS "topo_disk_status" +#define TOPO_METH_DISK_STATUS_VERSION 0 +#define TOPO_METH_DISK_STATUS_DESC "Disk status" + +#define TOPO_METH_SENSOR_FAILURE "topo_sensor_failure" +#define TOPO_METH_SENSOR_FAILURE_VERSION 0 +#define TOPO_METH_SENSOR_FAILURE_DESC "Sensor failure state" + +#define TOPO_PROP_METH_DESC "Dynamic Property method" + +#define TOPO_METH_IPMI_ENTITY "ipmi_entity" +#define TOPO_METH_FAC_ENUM_DESC "Facility Enumerator" + +extern void *topo_mod_alloc(topo_mod_t *, size_t); +extern void *topo_mod_zalloc(topo_mod_t *, size_t); +extern void topo_mod_free(topo_mod_t *, void *, size_t); +extern char *topo_mod_strdup(topo_mod_t *, const char *); +extern void topo_mod_strfree(topo_mod_t *, char *); +extern void topo_mod_strfreev(topo_mod_t *, char **, uint_t); +extern int topo_mod_nvalloc(topo_mod_t *, nvlist_t **, uint_t); +extern int topo_mod_nvdup(topo_mod_t *, nvlist_t *, nvlist_t **); +extern int topo_mod_vasprintf(topo_mod_t *, char **, const char *, + va_list) __VPRINTFLIKE(3); +extern int topo_mod_asprintf(topo_mod_t *, char **, const char *, + ...) __PRINTFLIKE(3); + +extern void topo_mod_clrdebug(topo_mod_t *); +extern void topo_mod_setdebug(topo_mod_t *); +extern void topo_mod_dprintf(topo_mod_t *, const char *, ...) __PRINTFLIKE(2); +extern const char *topo_mod_errmsg(topo_mod_t *); +extern int topo_mod_errno(topo_mod_t *); +extern char *topo_mod_clean_str(topo_mod_t *, const char *); +extern char *topo_mod_clean_strn(topo_mod_t *, const char *, size_t); + +/* + * Topo node utilities: callable from module enumeration, topo_mod_enumerate() + */ +extern int topo_node_range_create(topo_mod_t *, tnode_t *, const char *, + topo_instance_t, topo_instance_t); +extern void topo_node_range_destroy(tnode_t *, const char *); +extern tnode_t *topo_node_bind(topo_mod_t *, tnode_t *, const char *, + topo_instance_t, nvlist_t *); +extern tnode_t *topo_node_facbind(topo_mod_t *, tnode_t *, const char *, + const char *); +extern void topo_node_unbind(tnode_t *); +extern void topo_node_setspecific(tnode_t *, void *); +extern void *topo_node_getspecific(tnode_t *); +extern int topo_node_asru_set(tnode_t *node, nvlist_t *, int, int *); +extern int topo_node_fru_set(tnode_t *node, nvlist_t *, int, int *); +extern int topo_node_label_set(tnode_t *node, const char *, int *); + +#define TOPO_ASRU_COMPUTE 0x0001 /* Compute ASRU dynamically */ +#define TOPO_FRU_COMPUTE 0x0002 /* Compute FRU dynamically */ + +extern int topo_prop_inherit(tnode_t *, const char *, const char *, int *); +extern int topo_pgroup_create(tnode_t *, const topo_pgroup_info_t *, int *); + +/* + * Conveience property group and property creation. + */ +extern int topo_create_props(topo_mod_t *, tnode_t *, int, + const topo_pgroup_info_t *, ...); + +/* + * Topo property method registration + */ +extern int topo_prop_method_register(tnode_t *, const char *, const char *, + topo_type_t, const char *, const nvlist_t *, int *); +extern void topo_prop_method_unregister(tnode_t *, const char *, const char *); + +extern tnode_t *topo_mod_create_ufm(topo_mod_t *, tnode_t *, topo_instance_t, + const char *, topo_ufm_slot_info_t *); +extern tnode_t *topo_mod_create_ufm_slot(topo_mod_t *, tnode_t *, + topo_ufm_slot_info_t *); + +/* + * This enum definition is used to define a set of error tags associated with + * the module api error conditions. The shell script mkerror.sh is + * used to parse this file and create a corresponding topo_error.c source file. + * If you do something other than add a new error tag here, you may need to + * update the mkerror shell script as it is based upon simple regexps. + */ +typedef enum topo_mod_errno { + EMOD_UNKNOWN = 2000, /* unknown libtopo error */ + EMOD_NOMEM, /* module memory limit exceeded */ + EMOD_PARTIAL_ENUM, /* module completed partial enumeration */ + EMOD_METHOD_INVAL, /* method arguments invalid */ + EMOD_METHOD_NOTSUP, /* method not supported */ + EMOD_FMRI_NVL, /* nvlist allocation failure for FMRI */ + EMOD_FMRI_VERSION, /* invalid FMRI scheme version */ + EMOD_FMRI_MALFORM, /* malformed FMRI */ + EMOD_NODE_BOUND, /* node already bound */ + EMOD_NODE_DUP, /* duplicate node */ + EMOD_NODE_NOENT, /* node not found */ + EMOD_NODE_RANGE, /* invalid node range */ + EMOD_VER_ABI, /* registered with invalid ABI version */ + EMOD_VER_OLD, /* attempt to load obsolete module */ + EMOD_VER_NEW, /* attempt to load a newer module */ + EMOD_NVL_INVAL, /* invalid nvlist */ + EMOD_NONCANON, /* non-canonical component name requested */ + EMOD_MOD_NOENT, /* module lookup failed */ + EMOD_UKNOWN_ENUM, /* unknown enumeration error */ + EMOD_DIGRAPH_MAXSZ, /* max digraph size exceeded */ + EMOD_END /* end of mod errno list (to ease auto-merge) */ +} topo_mod_errno_t; + +extern int topo_mod_seterrno(topo_mod_t *, int); + +/* + * Function used by a module to try and open a file based on FM's search path. + */ +extern int topo_mod_file_search(topo_mod_t *, const char *file, int oflags); + +extern topo_method_f topo_mod_hc_occupied; + +/* + * Directed Graph topology interfaces + */ +extern topo_digraph_t *topo_digraph_new(topo_hdl_t *, topo_mod_t *, + const char *); +extern void topo_digraph_destroy(topo_digraph_t *); + +extern topo_vertex_t *topo_vertex_new(topo_mod_t *, const char *, + topo_instance_t); +extern void topo_vertex_destroy(topo_mod_t *mod, topo_vertex_t *vtx); + +extern int topo_edge_new(topo_mod_t *, topo_vertex_t *, topo_vertex_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _TOPO_MOD_H */ diff --git a/illumos-x86_64/usr/include/fmtmsg.h b/illumos-x86_64/usr/include/fmtmsg.h new file mode 100644 index 00000000..56958473 --- /dev/null +++ b/illumos-x86_64/usr/include/fmtmsg.h @@ -0,0 +1,194 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2014-2015 PALO, Richard. + * + * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FMTMSG_H +#define _FMTMSG_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * fmtmsg.h + * + * The header file contains the definitions needed + * to use the fmtmsg() function. This function writes messages + * in a standard format to the standard error stream (stderr) + * and to the system console. + */ + +/* + * Constraint definitions: + * MM_MXLABELLN Maximum size of a "label" in a message + * MM_MXTAGLN Maximum size of a "tag" in a message + * MM_MXTXTLN Maximum size of a text string + * MM_MXACTLN Maximum size of an action string + */ + +#define MM_MXLABELLN 25 +#define MM_MXTAGLN 32 +#define MM_MXTXTLN 512 +#define MM_MXACTLN 512 + +/* + * Environment variable names used by fmtmsg(): + * MSGVERB Tells fmtmsg() which components it is to write + * to the standard error stream + */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define MSGVERB "MSGVERB" +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Classification information + * - Definition of classifications + * - Definition of recoverability + * - Definition of source classifications + */ + +/* + * Definition of the "null" classification + * MM_NULL Indicates that the classification has been omitted + */ + +#define MM_NULL 0L + +/* + * Definitions of type classifications: + * MM_HARD Hardware + * MM_SOFT Software + * MM_FIRM Firmware + */ + +#define MM_HARD 0x00000001L +#define MM_SOFT 0x00000002L +#define MM_FIRM 0x00000004L + +/* + * Definitions of recoverability subclassification + * MM_RECOVER Recoverable + * MM_NRECOV Non-recoverable + */ + +#define MM_RECOVER 0x00000100L +#define MM_NRECOV 0x00000200L + +/* + * Definitions of source subclassification + * MM_APPL Application + * MM_UTIL Utility + * MM_OPSYS Kernel + */ + +#define MM_APPL 0x00000008L +#define MM_UTIL 0x00000010L +#define MM_OPSYS 0x00000020L + +/* + * Definitions for the action to take with the message: + * MM_PRINT Write to the standard error stream + * MM_CONSOLE Treat the message as a console message + */ + +#define MM_PRINT 0x00000040L +#define MM_CONSOLE 0x00000080L + +/* + * Constants for severity values + * + * SEV_LEVEL Names the env variable that defines severities + * + * MM_NOSEV Message has no severity + * MM_HALT Message describes a severe error condition + * MM_ERROR Message describes an error condition + * MM_WARNING Message tells of probable error condition + * MM_INFO Message informs, not in error + */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define SEV_LEVEL "SEV_LEVEL" +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#define MM_NOSEV 0 +#define MM_HALT 1 +#define MM_ERROR 2 +#define MM_WARNING 3 +#define MM_INFO 4 + +/* + * Null values for message components + * MM_NULLLBL Null value for the label-component + * MM_NULLSEV Null value for the severity-component + * MM_NULLMC Null value for the classification-component + * MM_NULLTXT Null value for the text-component + * MM_NULLACT Null value for the action-component + * MM_NULLTAG Null value for the tag-component + */ + +#define MM_NULLLBL ((char *)0) +#define MM_NULLSEV MM_NOSEV +#define MM_NULLMC MM_NULL +#define MM_NULLTXT ((char *)0) +#define MM_NULLACT ((char *)0) +#define MM_NULLTAG ((char *)0) + +/* + * Values returned by fmtmsg() + * + * MM_NOTOK None of the requested messages were generated + * MM_NOMSG No message was written to stderr + * MM_NOCON No console message was generated + */ + +#define MM_NOTOK -1 +#define MM_OK 0x00 +#define MM_NOMSG 0x01 +#define MM_NOCON 0x04 + +/* Function definition */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +int addseverity(int, const char *); +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +int fmtmsg(long, const char *, int, const char *, const char *, + const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _FMTMSG_H */ diff --git a/illumos-x86_64/usr/include/fnmatch.h b/illumos-x86_64/usr/include/fnmatch.h new file mode 100644 index 00000000..9602c18b --- /dev/null +++ b/illumos-x86_64/usr/include/fnmatch.h @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1994 by Sun Microsystems, Inc. + * Copyright 1985, 1994 by Mortice Kern Systems Inc. All rights reserved. + */ + +#ifndef _FNMATCH_H +#define _FNMATCH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define FNM_PATHNAME 0x01 /* Slash in str only matches slash in pattern */ +#define FNM_NOESCAPE 0x02 /* Disable '\'-quoting of metacharacters */ +#define FNM_PERIOD 0x04 /* Leading period in string must be exactly */ + /* matched by period in pattern */ +#define FNM_IGNORECASE 0x08 /* Ignore case when making comparisons */ +#define FNM_CASEFOLD 0x08 /* Ignore case when making comparisons */ + /* (for FreeBSD/Linux compatibility) */ +#define FNM_LEADING_DIR 0x10 /* Match if pattern matches initial segment */ + /* of str which is followed by a slash */ + +#define FNM_NOMATCH 1 /* string doesnt match the specified pattern */ +#define FNM_ERROR 2 /* error occured */ +#define FNM_NOSYS 3 /* Function (XPG4) not supported */ + +extern int fnmatch(const char *, const char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _FNMATCH_H */ diff --git a/illumos-x86_64/usr/include/form.h b/illumos-x86_64/usr/include/form.h new file mode 100644 index 00000000..c066603f --- /dev/null +++ b/illumos-x86_64/usr/include/form.h @@ -0,0 +1,437 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _FORM_H +#define _FORM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * FIELDTYPE + */ + +typedef struct typenode { + + int status; /* flags */ + int ref; /* reference count */ + struct typenode * left; /* ptr to operand for | */ + struct typenode * right; /* ptr to operand for | */ + PTF_charP makearg; /* make fieldtype arg */ + PTF_charP copyarg; /* copy fieldtype arg */ + PTF_void freearg; /* free fieldtype arg */ + PTF_int fcheck; /* field validation */ + PTF_int ccheck; /* character validation */ + PTF_int next; /* enumerate next value */ + PTF_int prev; /* enumerate prev value */ +} + FIELDTYPE; + +/* + * _PAGE + */ + +typedef struct { + + int pmin; /* first field on page */ + int pmax; /* last field on page */ + int smin; /* top leftmost field */ + int smax; /* bottom rightmost */ +} + _PAGE; + +/* + * FIELD + */ + +typedef struct fieldnode { + + int status; /* flags */ + int rows; /* size in rows */ + int cols; /* size in cols */ + int frow; /* first row */ + int fcol; /* first col */ + int drows; /* dynamic rows */ + int dcols; /* dynamic cols */ + int maxgrow; /* maximum field growth */ + int nrow; /* offscreen rows */ + int nbuf; /* additional buffers */ + int just; /* justification */ + int page; /* page on form */ + int index; /* into form -> field */ + int pad; /* pad character */ + chtype fore; /* foreground attribute */ + chtype back; /* background attribute */ + OPTIONS opts; /* options */ + struct fieldnode * snext; /* sorted order pointer */ + struct fieldnode * sprev; /* sorted order pointer */ + struct fieldnode * link; /* linked field chain */ + struct formnode * form; /* containing form */ + FIELDTYPE * type; /* field type */ + char * arg; /* argument for type */ + char * buf; /* field buffers */ + char * usrptr; /* user pointer */ +} + FIELD; + +/* + * FORM + */ + +typedef struct formnode { + + int status; /* flags */ + int rows; /* size in rows */ + int cols; /* size in cols */ + int currow; /* current row */ + int curcol; /* current col */ + int toprow; /* in vertically */ + /* scrollable field */ + int begincol; /* in horizontally */ + /* scrollable field */ + int maxfield; /* number of fields */ + int maxpage; /* number of pages */ + int curpage; /* index into page */ + OPTIONS opts; /* options */ + WINDOW * win; /* window */ + WINDOW * sub; /* subwindow */ + WINDOW * w; /* window */ + FIELD ** field; /* field [maxfield] */ + FIELD * current; /* current field */ + _PAGE * page; /* page [maxpage] */ + char * usrptr; /* user pointer */ + PTF_void forminit; /* user function */ + PTF_void formterm; /* user function */ + PTF_void fieldinit; /* user function */ + PTF_void fieldterm; /* user function */ +} + FORM; + +/* + * miscellaneous #defines + */ + +/* + * field justification + */ +#define NO_JUSTIFICATION 0 +#define JUSTIFY_LEFT 1 +#define JUSTIFY_CENTER 2 +#define JUSTIFY_RIGHT 3 +/* + * field options + */ +#define O_VISIBLE 0x0001 +#define O_ACTIVE 0x0002 +#define O_PUBLIC 0x0004 +#define O_EDIT 0x0008 +#define O_WRAP 0x0010 +#define O_BLANK 0x0020 +#define O_AUTOSKIP 0x0040 +#define O_NULLOK 0x0080 +#define O_PASSOK 0x0100 +#define O_STATIC 0x0200 +/* + * form options + */ +#define O_NL_OVERLOAD 0x0001 +#define O_BS_OVERLOAD 0x0002 +/* + * form driver commands + */ +#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */ +#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */ +#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */ +#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */ + +#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */ +#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */ +#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */ +#define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */ +#define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */ +#define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */ +#define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */ +#define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */ +#define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */ +#define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */ +#define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */ +#define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */ + +#define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */ +#define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */ +#define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */ +#define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */ +#define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */ +#define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */ +#define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */ +#define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */ +#define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */ +#define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */ +#define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */ +#define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */ +#define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */ +#define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */ + +#define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */ +#define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */ +#define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */ +#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */ +#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */ +#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */ +#define REQ_DEL_WORD (KEY_MAX + 37) /* delete line at cursor */ +#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */ +#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */ +#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */ +#define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */ +#define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */ + +#define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */ +#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */ +#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */ +#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */ +#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */ +#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */ + +#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */ +#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */ +#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */ +#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */ +#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */ +#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */ + +#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */ +#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */ +#define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */ + +#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */ +#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */ + +/* + * standard field types + */ + +extern FIELDTYPE * TYPE_ALPHA; +extern FIELDTYPE * TYPE_ALNUM; +extern FIELDTYPE * TYPE_ENUM; +extern FIELDTYPE * TYPE_INTEGER; +extern FIELDTYPE * TYPE_NUMERIC; +extern FIELDTYPE * TYPE_REGEXP; + +/* + * default objects + */ + +extern FORM * _DEFAULT_FORM; +extern FIELD * _DEFAULT_FIELD; + +#ifdef __STDC__ + +/* + * FIELDTYPE routines + */ + +extern FIELDTYPE * new_fieldtype(PTF_int, PTF_int); +extern FIELDTYPE * link_fieldtype(FIELDTYPE *, FIELDTYPE *); +extern int free_fieldtype(FIELDTYPE *); +extern int set_fieldtype_arg(FIELDTYPE *, PTF_charP, + PTF_charP, PTF_void); +extern int set_fieldtype_choice(FIELDTYPE *, PTF_int, PTF_int); + +/* + * FIELD routines + */ + +extern FIELD * new_field(int, int, int, int, int, int); +extern FIELD * dup_field(FIELD *, int, int); +extern FIELD * link_field(FIELD *, int, int); +extern int free_field(FIELD *); +extern int field_info(FIELD *, int *, int *, int *, int *, + int *, int *); +extern int dynamic_field_info(FIELD *, int *, int *, int *); +extern int set_max_field(FIELD *, int); +extern int move_field(FIELD *, int, int); +extern int set_field_type(FIELD *, FIELDTYPE *, ...); +extern FIELDTYPE * field_type(FIELD *); +extern char * field_arg(FIELD *); +extern int set_new_page(FIELD *, int); +extern int new_page(FIELD *); +extern int set_field_just(FIELD *, int); +extern int field_just(FIELD *); +extern int set_field_fore(FIELD *, chtype); +extern chtype field_fore(FIELD *); +extern int set_field_back(FIELD *, chtype); +extern chtype field_back(FIELD *); +extern int set_field_pad(FIELD *, int); +extern int field_pad(FIELD *); +extern int set_field_buffer(FIELD *, int, char *); +extern char * field_buffer(FIELD *, int); +extern int set_field_status(FIELD *, int); +extern int field_status(FIELD *); +extern int set_field_userptr(FIELD *, char *); +extern char * field_userptr(FIELD *); +extern int set_field_opts(FIELD *, OPTIONS); +extern OPTIONS field_opts(FIELD *); +extern int field_opts_on(FIELD *, OPTIONS); +extern int field_opts_off(FIELD *, OPTIONS); +extern int field_index(FIELD *); + +/* + * FORM routines + */ + +extern FORM * new_form(FIELD **); +extern int free_form(FORM *); +extern int set_form_fields(FORM *, FIELD **); +extern FIELD ** form_fields(FORM *); +extern int field_count(FORM *); +extern int set_form_win(FORM *, WINDOW *); +extern WINDOW * form_win(FORM *); +extern int set_form_sub(FORM *, WINDOW *); +extern WINDOW * form_sub(FORM *); +extern int set_current_field(FORM *, FIELD *); +extern FIELD * current_field(FORM *); +extern int set_form_page(FORM *, int); +extern int form_page(FORM *); +extern int scale_form(FORM *, int *, int *); +extern int set_form_init(FORM *, PTF_void); +extern PTF_void form_init(FORM *); +extern int set_form_term(FORM *, PTF_void); +extern PTF_void form_term(FORM *); +extern int set_field_init(FORM *, PTF_void); +extern PTF_void field_init(FORM *); +extern int set_field_term(FORM *, PTF_void); +extern PTF_void field_term(FORM *); +extern int post_form(FORM *); +extern int unpost_form(FORM *); +extern int pos_form_cursor(FORM *); +extern int form_driver(FORM *, int); +extern int set_form_userptr(FORM *, char *); +extern char * form_userptr(FORM *); +extern int set_form_opts(FORM *, OPTIONS); +extern OPTIONS form_opts(FORM *); +extern int form_opts_on(FORM *, OPTIONS); +extern int form_opts_off(FORM *, OPTIONS); +extern int data_ahead(FORM *); +extern int data_behind(FORM *); + +#else /* old style extern's */ + +/* + * FIELDTYPE routines + */ + +extern FIELDTYPE * new_fieldtype(); +extern FIELDTYPE * link_fieldtype(); +extern int free_fieldtype(); +extern int set_fieldtype_arg(); +extern int set_fieldtype_choice(); + +/* + * FIELD routines + */ + +extern FIELD * new_field(); +extern FIELD * dup_field(); +extern FIELD * link_field(); +extern int free_field(); +extern int field_info(); +extern int dynamic_field_info(); +extern int set_max_field(); +extern int move_field(); +extern int set_field_type(); +extern FIELDTYPE * field_type(); +extern char * field_arg(); +extern int set_new_page(); +extern int new_page(); +extern int set_field_just(); +extern int field_just(); +extern int set_field_fore(); +extern chtype field_fore(); +extern int set_field_back(); +extern chtype field_back(); +extern int set_field_pad(); +extern int field_pad(); +extern int set_field_buffer(); +extern char * field_buffer(); +extern int set_field_status(); +extern int field_status(); +extern int set_field_userptr(); +extern char * field_userptr(); +extern int set_field_opts(); +extern OPTIONS field_opts(); +extern int field_opts_on(); +extern int field_opts_off(); +extern int field_index(); + +/* + * FORM routines + */ + +extern FORM * new_form(); +extern int free_form(); +extern int set_form_fields(); +extern FIELD ** form_fields(); +extern int field_count(); +extern int set_form_win(); +extern WINDOW * form_win(); +extern int set_form_sub(); +extern WINDOW * form_sub(); +extern int set_current_field(); +extern FIELD * current_field(); +extern int set_form_page(); +extern int form_page(); +extern int scale_form(); +extern int set_form_init(); +extern PTF_void form_init(); +extern int set_form_term(); +extern PTF_void form_term(); +extern int set_field_init(); +extern PTF_void field_init(); +extern int set_field_term(); +extern PTF_void field_term(); +extern int post_form(); +extern int unpost_form(); +extern int pos_form_cursor(); +extern int form_driver(); +extern int set_form_userptr(); +extern char * form_userptr(); +extern int set_form_opts(); +extern OPTIONS form_opts(); +extern int form_opts_on(); +extern int form_opts_off(); +extern int data_ahead(); +extern int data_behind(); + +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _FORM_H */ diff --git a/illumos-x86_64/usr/include/fts.h b/illumos-x86_64/usr/include/fts.h new file mode 100644 index 00000000..0aad84a8 --- /dev/null +++ b/illumos-x86_64/usr/include/fts.h @@ -0,0 +1,142 @@ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _FTS_H +#define _FTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + struct _ftsent *fts_cur; /* current node */ + struct _ftsent *fts_child; /* linked list of children */ + struct _ftsent **fts_array; /* sort array */ + dev_t fts_dev; /* starting device # */ + char *fts_path; /* path for this descent */ + int fts_rfd; /* fd for root */ + size_t fts_pathlen; /* sizeof(path) */ + int fts_nitems; /* elements in the sort array */ + int (*fts_compar)(); /* compare function */ + +#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ +#define FTS_LOGICAL 0x0002 /* logical walk */ +#define FTS_NOCHDIR 0x0004 /* don't change directories */ +#define FTS_NOSTAT 0x0008 /* don't get stat info */ +#define FTS_PHYSICAL 0x0010 /* physical walk */ +#define FTS_SEEDOT 0x0020 /* return dot and dot-dot */ +#define FTS_XDEV 0x0040 /* don't cross devices */ +#define FTS_OPTIONMASK 0x00ff /* valid user option mask */ + +#define FTS_NAMEONLY 0x1000 /* (private) child names only */ +#define FTS_STOP 0x2000 /* (private) unrecoverable error */ + int fts_options; /* fts_open options, global flags */ +} FTS; + +typedef struct _ftsent { + struct _ftsent *fts_cycle; /* cycle node */ + struct _ftsent *fts_parent; /* parent directory */ + struct _ftsent *fts_link; /* next file in directory */ + long fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + char *fts_accpath; /* access path */ + char *fts_path; /* root path */ + int fts_errno; /* errno for this node */ + int fts_symfd; /* fd for symlink */ + size_t fts_pathlen; /* strlen(fts_path) */ + size_t fts_namelen; /* strlen(fts_name) */ + + ino_t fts_ino; /* inode */ + dev_t fts_dev; /* device */ + nlink_t fts_nlink; /* link count */ + +#define FTS_ROOTPARENTLEVEL -1 +#define FTS_ROOTLEVEL 0 +#define FTS_MAXLEVEL 0x7fffffff + int fts_level; /* depth (-1 to N) */ + +#define FTS_D 1 /* preorder directory */ +#define FTS_DC 2 /* directory that causes cycles */ +#define FTS_DEFAULT 3 /* none of the above */ +#define FTS_DNR 4 /* unreadable directory */ +#define FTS_DOT 5 /* dot or dot-dot */ +#define FTS_DP 6 /* postorder directory */ +#define FTS_ERR 7 /* error; errno is set */ +#define FTS_F 8 /* regular file */ +#define FTS_INIT 9 /* initialized only */ +#define FTS_NS 10 /* stat(2) failed */ +#define FTS_NSOK 11 /* no stat(2) requested */ +#define FTS_SL 12 /* symbolic link */ +#define FTS_SLNONE 13 /* symbolic link without target */ + unsigned short fts_info; /* user flags for FTSENT structure */ + +#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ +#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ + unsigned short fts_flags; /* private flags for FTSENT structure */ + +#define FTS_AGAIN 1 /* read node again */ +#define FTS_FOLLOW 2 /* follow symbolic link */ +#define FTS_NOINSTR 3 /* no instructions */ +#define FTS_SKIP 4 /* discard node */ + unsigned short fts_instr; /* fts_set() instructions */ + + unsigned short fts_spare; /* unused */ + + struct stat *fts_statp; /* stat(2) information */ + char fts_name[1]; /* file name */ +} FTSENT; + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname fts_children fts_children64 +#pragma redefine_extname fts_close fts_close64 +#pragma redefine_extname fts_open fts_open64 +#pragma redefine_extname fts_read fts_read64 +#pragma redefine_extname fts_set fts_set64 +#else +#define fts_children fts_children64 +#define fts_close fts_close64 +#define fts_open fts_open64 +#define fts_read fts_read64 +#define fts_set fts_set64 +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +FTSENT *fts_children(FTS *, int); +int fts_close(FTS *); +FTS *fts_open(char * const *, int, + int (*)(const FTSENT **, const FTSENT **)); +FTSENT *fts_read(FTS *); +int fts_set(FTS *, FTSENT *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* !_FTS_H */ diff --git a/illumos-x86_64/usr/include/ftw.h b/illumos-x86_64/usr/include/ftw.h new file mode 100644 index 00000000..a963854c --- /dev/null +++ b/illumos-x86_64/usr/include/ftw.h @@ -0,0 +1,164 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _FTW_H +#define _FTW_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Codes for the third argument to the user-supplied function. + */ + +#define FTW_F 0 /* file */ +#define FTW_D 1 /* directory */ +#define FTW_DNR 2 /* directory without read permission */ +#define FTW_NS 3 /* unknown type, stat failed */ +#define FTW_SL 4 /* symbolic link */ +#define FTW_DP 6 /* directory */ +#define FTW_SLN 7 /* symbolic link that points to nonexistent file */ +#define FTW_DL 8 /* private interface for find utility */ + +/* + * Codes for the fourth argument to nftw. You can specify the + * union of these flags. + */ + +#define FTW_PHYS 01 /* use lstat instead of stat */ +#define FTW_MOUNT 02 /* do not cross a mount point */ +#define FTW_CHDIR 04 /* chdir to each directory before reading */ +#define FTW_DEPTH 010 /* call descendents before calling the parent */ +#define FTW_ANYERR 020 /* return FTW_NS on any stat failure */ +#define FTW_HOPTION 040 /* private interface for find utility */ +#define FTW_NOLOOP 0100 /* private interface for find utility */ + +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2) +struct FTW +{ +#if defined(_XPG4_2) + int __quit; +#else + int quit; +#endif + int base; + int level; +}; +#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */ + +/* + * legal values for quit + */ + +#define FTW_SKD 1 +#define FTW_FOLLOW 2 +#define FTW_PRUNE 4 + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname _xftw _xftw64 +#pragma redefine_extname _ftw _ftw64 +#if !defined(_XOPEN_SOURCE) || defined(_XPG5) +#pragma redefine_extname nftw nftw64 +#endif +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define _xftw _xftw64 +#define _ftw _ftw64 +#if !defined(_XOPEN_SOURCE) || defined(_XPG5) +#define nftw nftw64 +#endif +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +/* In the LP64 compilation environment, all APIs are already large file */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname _xftw64 _xftw +#pragma redefine_extname _ftw64 _ftw +#if !defined(_XOPEN_SOURCE) || defined(_XPG5) +#pragma redefine_extname nftw64 nftw +#endif +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define _xftw64 _xftw +#define _ftw64 _ftw +#if !defined(_XOPEN_SOURCE) || defined(_XPG5) +#define nftw64 nftw +#endif +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern int ftw(const char *, + int (*)(const char *, const struct stat *, int), int); +extern int _xftw(int, const char *, + int (*)(const char *, const struct stat *, int), int); +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2) +extern int nftw(const char *, + int (*)(const char *, const struct stat *, int, struct FTW *), + int, int); +#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */ + +/* + * transitional large file interface versions + */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int ftw64(const char *, + int (*)(const char *, const struct stat64 *, int), int); +extern int _xftw64(int, const char *, + int (*)(const char *, const struct stat64 *, int), int); +#if !defined(_XOPEN_SOURCE) +extern int nftw64(const char *, + int (*)(const char *, const struct stat64 *, int, struct FTW *), + int, int); +#endif /* !defined(_XOPEN_SOURCE) */ +#endif /* _LARGEFILE64_SOURCE .. */ + +#define _XFTWVER 2 /* version of file tree walk */ + +#define ftw(path, fn, depth) _xftw(_XFTWVER, (path), (fn), (depth)) + +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +#define ftw64(path, fn, depth) _xftw64(_XFTWVER, (path), (fn), (depth)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _FTW_H */ diff --git a/illumos-x86_64/usr/include/fwflash/fwflash.h b/illumos-x86_64/usr/include/fwflash/fwflash.h new file mode 100644 index 00000000..d4ae6f19 --- /dev/null +++ b/illumos-x86_64/usr/include/fwflash/fwflash.h @@ -0,0 +1,385 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FWFLASH_H +#define _FWFLASH_H + +/* + * fwflash.h + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +#define MSG_INFO 0 +#define MSG_WARN 1 +#define MSG_ERROR 2 + +#define FWFLASH_SUCCESS 0 +#define FWFLASH_FAILURE 1 + +#define FWFLASH_FLASH_IMAGES 2 + +#define FWPLUGINDIR "/usr/lib/fwflash/identify" +#define FWVERIFYPLUGINDIR "/usr/lib/fwflash/verify" + +/* + * we search for a variable (fwplugin_version, type uint32_t) + * which should equal FWPLUGIN_VERSION_1 + */ + +#define FWPLUGIN_VERSION_1 1 +#define FWPLUGIN_VERSION_2 2 + +struct devicelist; + +struct fw_plugin { + /* + * An opaque handle for dlopen()/dlclose() to use. + */ + void *handle; + + /* + * fully-qualified filename in /usr/lib/fwflash/identify + * made up of [drivername].so + * + * eg /usr/lib/fwflash/identify/ses.so + * is the identification plugin for devices attached to + * the host using the ses(4D) driver. + */ + char *filename; + + /* + * The driver name that this plugin will search for in + * the device tree snapshot using di_drv_first_node(3DEVINFO) + * and di_drv_next_node(3DEVINFO). + */ + char *drvname; /* "ses" or "tavor" or .... */ + + /* + * Function entry point to support the command-line "-r" + * option - read image from device to persistent storage. + * + * Not all plugins and devices will support this operation. + */ + int (*fw_readfw)(struct devicelist *device, char *filename); + + /* + * Function entry point to support the command-line "-f" + * option - writes from persistent storage to device + * + * All identification plugins must support this operation. + */ + int (*fw_writefw)(struct devicelist *device, char *filename); + + /* + * Function entry point used to build the list of valid, flashable + * devices attached to the system using the loadable module drvname. + * (Not all devices attached using drvname will be valid for this + * plugin to report. + * + * start allows us to display flashable devices attached with + * different drivers and provide the user with a visual clue + * that these devices are different to others that are detected. + * + * All identification plugins must support this operation. + */ + int (*fw_identify)(int start); + + /* + * Function entry point to support the command-line "-l" + * option - list/report flashable devices attached to the system. + * + * All identification plugins must support this operation. + */ + int (*fw_devinfo)(struct devicelist *thisdev); + + /* + * Function entry point to allow the plugin to clean up its + * data structure use IF plugin_version == FWPLUGIN_VERSION_2. + * + * If this function is not defined in the plugin, that is not + * an error condition unless the plugin_version variable is + * defined. + */ + void (*fw_cleanup)(struct devicelist *thisdev); +}; + + +struct pluginlist { + /* + * fully qualified filename in /usr/lib/fwflash/identify + * made up of fwflash-[drivername].so + * + * eg /usr/lib/fwflash/identify/ses.so + * is the identification plugin for devices attached to + * the host using the ses(4D) driver. + */ + char *filename; + + /* + * The driver name that this plugin will search for in + * the device tree snapshot using di_drv_first_node(3DEVINFO) + * and di_drv_next_node(3DEVINFO). + */ + char *drvname; + + /* + * pointer to the actual plugin, so we can access its + * function entry points + */ + struct fw_plugin *plugin; + + /* pointer to the next element in the list */ + TAILQ_ENTRY(pluginlist) nextplugin; +}; + +struct vpr { + /* vendor ID, eg "HITACHI " */ + char *vid; + + /* product ID, eg "DK32EJ36NSUN36G " */ + char *pid; + + /* revision, eg "PQ08" */ + char *revid; + + /* + * Additional, encapsulated identifying information. + * This pointer allows us to add details such as the + * IB hba sector size, which command set should be + * used or a part number. + */ + void *encap_ident; +}; + +struct fwfile { + /* + * The fully qualified filename. No default location for + * the firmware image file is mandated. + */ + char *filename; + + /* Pointer to the identification plugin required */ + struct fw_plugin *plugin; + + /* pointer to the identification summary structure */ + struct vpr *ident; +}; + +struct devicelist { + /* + * fully qualified pathname, with /devices/.... prefix + */ + char *access_devname; + + /* + * Which drivername did we find this device attached with + * in our device tree walk? Eg, ses or tavor or sgen... + */ + char *drvname; + + /* + * What class of device is this? For tavor-attached devices, + * we set this to "IB". For other devices, unless there is + * a common name to use, just make this the same as the + * drvname field. + */ + char *classname; + + /* pointer to the VPR structure */ + struct vpr *ident; + + /* + * In the original fwflash(8), it was possible to select a + * device for flashing by using an index number called a + * dev_num. We retain that concept for pluggable fwflash, with + * the following change - whenever our identification plugin has + * finished and found at least one acceptable device, we bump the + * index number by 100. This provides the user with another key + * to distinguish the desired device from a potentially very large + * list of similar-looking devices. + */ + unsigned int index; + + /* + * Contains SAS or FC Port-WWNs, or IB GUIDS. Both SAS and FC only + * need one entry in this array since they really only have one + * address which we should track. IB devices can have 4 GUIDs + * (System Image, Node Image, Port 1 and Port 2). + */ + char *addresses[4]; + + /* + * Pointer to the plugin needed to flash this device, and + * to use for printing appropriate device-specific information + * as required by the "-l" option to fwflash(8). + */ + struct fw_plugin *plugin; + + /* Next entry in the list */ + TAILQ_ENTRY(devicelist) nextdev; +}; + + +/* + * this type of plugin is for the firmware image vendor-specific + * verification functions, which we load from FWVERIFYPLUGINDIR + */ + +struct vrfyplugin { + /* + * fully-qualified filename in /usr/lib/fwflash/verify, + * made up of [drivername]-[vendorname].so + * + * eg /usr/lib/fwflash/verify/ses-SUN.so + * is the verification plugin for ses-attached devices which + * have a vendorname of "SUN". + */ + char *filename; + + /* + * The vendor name, such as "SUN" or "MELLANOX" + */ + char *vendor; + + /* + * An opaque handle for dlopen()/dlclose() to use. + */ + void *handle; + + /* + * Firmware image size in bytes, as reported by + * stat(). + */ + unsigned int imgsize; + + /* + * Flashable devices frequently have different buffers + * to use for different image types. We track the buffer + * required for this particular image with this variable. + * + * Once the verifier has figured out what sort of image + * it's been passed, it will know what value to use for + * this variable. + */ + unsigned int flashbuf; + + /* + * Points to the entire firmware image in memory. + * We do this so we can avoid multiple open()/close() + * operations, and to make it easier for checksum + * calculations. + */ + int *fwimage; + + /* + * We also store the name of the firmware file that + * we point to with *fwimage. This is needed in cases + * where we need to key off the name of the file to + * determine whether a different buffer in the target + * device should be targeted. + * + * For example, our "standard" firmware image (file.fw) + * might require use of buffer id 0, but a boot image + * (boot.fw) might require use of buffer id 17. In each + * case, it is the verifier plugin that determines the + * specific bufferid that is needed by that firmware image. + */ + char *imgfile; + + /* + * The verification function entry point. The code + * in fwflash.c calls this function to verify that + * the nominated firmware image file is valid for + * the selected devicenode. + * + * Note that if the verification fails, the image + * does _not_ get force-flashed to the device. + */ + int (*vendorvrfy)(struct devicelist *devicenode); +}; + +/* Flags for argument parsing */ +#define FWFLASH_HELP_FLAG 0x01 +#define FWFLASH_VER_FLAG 0x02 +#define FWFLASH_YES_FLAG 0x04 +#define FWFLASH_LIST_FLAG 0x08 +#define FWFLASH_CLASS_FLAG 0x10 +#define FWFLASH_DEVICE_FLAG 0x20 +#define FWFLASH_FW_FLAG 0x40 +#define FWFLASH_READ_FLAG 0x80 + +/* global variables for fwflash */ +TAILQ_HEAD(PLUGINLIST, pluginlist); +TAILQ_HEAD(DEVICELIST, devicelist); + +/* exposed global args */ +extern di_node_t rootnode; +extern struct PLUGINLIST *fw_pluginlist; +extern struct DEVICELIST *fw_devices; +extern struct vrfyplugin *verifier; +extern struct fw_plugin *self; +extern int fwflash_debug; + +/* + * utility defines and macros, since the firmware image we get + * from LSI is ARM-format and that means byte- and short-swapping + * on sparc + */ + +#define HIGHBITS16 0xff00 +#define HIGHBITS32 0xffff0000 +#define HIGHBITS64 0xffffffff00000000ULL +#define LOWBITS16 0x00ff +#define LOWBITS32 0x0000ffff +#define LOWBITS64 0x00000000ffffffffULL + +#if defined(_LITTLE_ENDIAN) +#define ARMSWAPBITS(bs) (bs) +#define MLXSWAPBITS16(bs) ntohs(bs) +#define MLXSWAPBITS32(bs) ntohl(bs) +#define MLXSWAPBITS64(bs) \ + (BE_64(((bs) & LOWBITS64)) | BE_64(((bs) & HIGHBITS64))) +#else +#define ARMSWAPBITS(bs) (LE_32(((bs) & LOWBITS32)) | LE_32(((bs) & HIGHBITS32))) +#define MLXSWAPBITS16(bs) (bs) +#define MLXSWAPBITS32(bs) (bs) +#define MLXSWAPBITS64(bs) (bs) +#endif + +/* common functions for fwflash */ +void logmsg(int severity, const char *msg, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _FWFLASH_H */ diff --git a/illumos-x86_64/usr/include/gawkapi.h b/illumos-x86_64/usr/include/gawkapi.h new file mode 100644 index 00000000..fcf13532 --- /dev/null +++ b/illumos-x86_64/usr/include/gawkapi.h @@ -0,0 +1,1227 @@ +/* + * gawkapi.h -- Definitions for use by extension functions calling into gawk. + */ + +/* + * copyright (c) 2012-2019, 2021-2024, the free software foundation, inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* + * The following types and/or macros and/or functions are referenced + * in this file. For correct use, you must therefore include the + * corresponding standard header file BEFORE including this file. + * + * FILE - + * NULL - + * memset(), memcpy() - + * size_t - + * struct stat - + * + * Due to portability concerns, especially to systems that are not + * fully standards-compliant, it is your responsibility to include + * the correct files in the correct way. This requirement is necessary + * in order to keep this file clean, instead of becoming a portability + * hodge-podge as can be seen in the gawk source code. + * + * To pass reasonable integer values for ERRNO, you will also need to + * include . + */ + +#ifndef _GAWK_API_H +#define _GAWK_API_H + +/* + * General introduction: + * + * This API purposely restricts itself to ISO C 90 features. In particular, no + * bool, no // comments, no use of the restrict keyword, or anything else, + * in order to provide maximal portability. + * + * Exception: the "inline" keyword is used below in the "constructor" + * functions. If your compiler doesn't support it, you should either + * -Dinline='' on your command line, or use the autotools and include a + * config.h in your extensions. + * + * Additional important information: + * + * 1. ALL string values in awk_value_t objects need to come from api_malloc(). + * Gawk will handle releasing the storage if necessary. This is slightly + * awkward, in that you can't take an awk_value_t that you got from gawk + * and reuse it directly, even for something that is conceptually pass + * by value. + * + * 2. Due to gawk internals, after using sym_update() to install an array + * into gawk, you have to retrieve the array cookie from the value + * passed in to sym_update(). Like so: + * + * new_array = create_array(); + * val.val_type = AWK_ARRAY; + * val.array_cookie = new_array; + * sym_update("array", & val); // install array in the symbol table + * + * new_array = val.array_cookie; // MUST DO THIS + * + * // fill in new array with lots of subscripts and values + * + * Similarly, if installing a new array as a subarray of an existing + * array, you must add the new array to its parent before adding any + * elements to it. + * + * You must also retrieve the value of the array_cookie after the call + * to set_element(). + * + * Thus, the correct way to build an array is to work "top down". + * Create the array, and immediately install it in gawk's symbol table + * using sym_update(), or install it as an element in a previously + * existing array using set_element(). + * + * Thus the new array must ultimately be rooted in a global symbol. This is + * necessary before installing any subarrays in it, due to gawk's + * internal implementation. Strictly speaking, this is required only + * for arrays that will have subarrays as elements; however it is + * a good idea to always do this. This restriction may be relaxed + * in a subsequent revision of the API. + * + * 3. While each routine in the API has a few lines of summary for it + * in this header, said summaries are not standalone, adequate documentation. You + * should read the chapter in the gawk manual on writing extensions. Find it online + * at https://www.gnu.org/software/gawk/manual/html_node/Dynamic-Extensions.html, + * or in the Info files distributed with gawk. + */ + +/* Allow use in C++ code. */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is used to keep extensions from modifying certain fields in some structs. */ +#ifdef GAWK +#define awk_const +#else +#define awk_const const +#endif + +typedef enum awk_bool { + awk_false = 0, + awk_true +} awk_bool_t; /* we don't use on purpose */ + +/* + * If an input parser would like to specify the field positions in the input + * record, it may populate an awk_fieldwidth_info_t structure to indicate + * the location of each field. The use_chars boolean controls whether the + * field lengths are specified in terms of bytes or potentially multi-byte + * characters. Performance will be better if the values are supplied in + * terms of bytes. The fields[0].skip value indicates how many bytes (or + * characters) to skip before $1, and fields[0].len is the length of $1, etc. + */ + +typedef struct { + awk_bool_t use_chars; /* false ==> use bytes */ + size_t nf; + struct awk_field_info { + size_t skip; /* amount to skip before field starts */ + size_t len; /* length of field */ + } fields[1]; /* actual dimension should be nf */ +} awk_fieldwidth_info_t; + +/* + * This macro calculates the total struct size needed. This is useful when + * calling malloc or realloc. + */ +#define awk_fieldwidth_info_size(NF) (sizeof(awk_fieldwidth_info_t) + \ + (((NF)-1) * sizeof(struct awk_field_info))) + +/* The information about input files that input parsers need to know: */ +typedef struct awk_input { + const char *name; /* filename */ + int fd; /* file descriptor */ +#define INVALID_HANDLE (-1) + void *opaque; /* private data for input parsers */ + + /* + * The get_record function is called to read the next record of data. + * + * It should return the length of the input record or EOF, and it + * should set *out to point to the contents of $0. The rt_start + * and rt_len arguments should be used to return RT to gawk. + * If EOF is not returned, the parser must set *rt_len (and + * *rt_start if *rt_len is non-zero). + * + * Note that gawk will make a copy of the record in *out, so the + * parser is responsible for managing its own memory buffer. + * Similarly, gawk will make its own copy of RT, so the parser + * is also responsible for managing this memory. + * + * It is guaranteed that errcode is a valid pointer, so there is + * no need to test for a NULL value. Gawk sets *errcode to 0, + * so there is no need to set it unless an error occurs. + * + * If an error does occur, the function should return EOF and set + * *errcode to a positive value. In that case, if *errcode is greater + * than zero, gawk will automatically update the ERRNO variable based + * on the value of *errcode (e.g., setting *errcode = errno should do + * the right thing). + * + * If field_width is non-NULL, then *field_width will be initialized + * to NULL, and the function may set it to point to a structure + * supplying field width information to override the default + * gawk field parsing mechanism. Note that this structure will not + * be copied by gawk; it must persist at least until the next call + * to get_record or close_func. Note also that field_width will + * be NULL when getline is assigning the results to a variable, thus + * field parsing is not needed. + */ + int (*get_record)(char **out, struct awk_input *iobuf, int *errcode, + char **rt_start, size_t *rt_len, + const awk_fieldwidth_info_t **field_width); + + /* + * This replaces the POSIX read() system call. Use it if you want to + * manage reading raw bytes yourself, and let gawk parse the record. + */ + ssize_t (*read_func)(int, void *, size_t); + + /* + * The close_func is called to allow the parser to free private data. + * Gawk itself will close the fd unless close_func first sets it to + * INVALID_HANDLE. + */ + void (*close_func)(struct awk_input *iobuf); + + /* put last, for alignment. bleah */ + struct stat sbuf; /* stat buf */ + +} awk_input_buf_t; + +typedef struct awk_input_parser { + const char *name; /* name of parser */ + + /* + * The can_take_file function should return true if the parser + * would like to parse this file. It should not change any gawk + * state! + */ + awk_bool_t (*can_take_file)(const awk_input_buf_t *iobuf); + + /* + * If this parser is selected, then take_control_of will be called. + * It can assume that a previous call to can_take_file was successful, + * and no gawk state has changed since that call. It should populate + * the awk_input_buf_t's get_record, close_func, and opaque values as needed. + * It should return true if successful. + */ + awk_bool_t (*take_control_of)(awk_input_buf_t *iobuf); + + awk_const struct awk_input_parser *awk_const next; /* for use by gawk */ +} awk_input_parser_t; + +/* + * Similar for output wrapper. + */ + +/* First the data structure */ +typedef struct awk_output_buf { + const char *name; /* name of output file */ + const char *mode; /* mode argument to fopen */ + FILE *fp; /* stdio file pointer */ + awk_bool_t redirected; /* true if a wrapper is active */ + void *opaque; /* for use by output wrapper */ + + /* + * Replacement functions for I/O. Just like the regular + * versions but also take the opaque pointer argument. + */ + size_t (*gawk_fwrite)(const void *buf, size_t size, size_t count, + FILE *fp, void *opaque); + int (*gawk_fflush)(FILE *fp, void *opaque); + int (*gawk_ferror)(FILE *fp, void *opaque); + int (*gawk_fclose)(FILE *fp, void *opaque); +} awk_output_buf_t; + +/* Next the output wrapper registered with gawk */ +typedef struct awk_output_wrapper { + const char *name; /* name of the wrapper */ + + /* + * The can_take_file function should return true if the wrapper + * would like to process this file. It should not change any gawk + * state! + */ + awk_bool_t (*can_take_file)(const awk_output_buf_t *outbuf); + + /* + * If this wrapper is selected, then take_control_of will be called. + * It can assume that a previous call to can_take_file was successful, + * and no gawk state has changed since that call. It should populate + * the awk_output_buf_t function pointers and opaque pointer as needed. + * It should return true if successful. + */ + awk_bool_t (*take_control_of)(awk_output_buf_t *outbuf); + + awk_const struct awk_output_wrapper *awk_const next; /* for use by gawk */ +} awk_output_wrapper_t; + +/* A two-way processor combines an input parser and an output wrapper. */ +typedef struct awk_two_way_processor { + const char *name; /* name of the two-way processor */ + + /* + * The can_take_file function should return true if the two-way + * processor would like to parse this file. It should not change + * any gawk state! + */ + awk_bool_t (*can_take_two_way)(const char *name); + + /* + * If this processor is selected, then take_control_of will be called. + * It can assume that a previous call to can_take_file was successful, + * and no gawk state has changed since that call. It should populate + * the awk_input_buf_t and awk_otuput_buf_t structures as needed. + * It should return true if successful. + */ + awk_bool_t (*take_control_of)(const char *name, awk_input_buf_t *inbuf, + awk_output_buf_t *outbuf); + + awk_const struct awk_two_way_processor *awk_const next; /* for use by gawk */ +} awk_two_way_processor_t; + +#define gawk_api_major_version 4 +#define gawk_api_minor_version 0 + +/* Current version of the API. */ +enum { + GAWK_API_MAJOR_VERSION = gawk_api_major_version, + GAWK_API_MINOR_VERSION = gawk_api_minor_version +}; + +/* A number of typedefs related to different types of values. */ + +/* + * A mutable string. Gawk owns the memory pointed to if it supplied + * the value. Otherwise, it takes ownership of the memory pointed to. + * + * The API deals exclusively with regular chars; these strings may + * be multibyte encoded in the current locale's encoding and character + * set. Gawk will convert internally to wide characters if necessary. + * + * Note that a string provided by gawk will always be terminated + * with a '\0' character. + */ +typedef struct awk_string { + char *str; /* data */ + size_t len; /* length thereof, in chars */ +} awk_string_t; + +enum AWK_NUMBER_TYPE { + AWK_NUMBER_TYPE_DOUBLE, + AWK_NUMBER_TYPE_MPFR, + AWK_NUMBER_TYPE_MPZ +}; + +/* + * When type is AWK_NUMBER_MPFR or AWK_NUMBER_MPZ, the memory pointed to + * by the ptr member belongs to gawk if it came from gawk. Otherwise the + * memory belongs to the extension and gawk copies it when its received. + * See the manual for further discussion. + */ + +typedef struct awk_number { + double d; /* always populated in data received from gawk */ + enum AWK_NUMBER_TYPE type; + void *ptr; /* either NULL or mpfr_ptr or mpz_ptr */ +} awk_number_t; + +/* Arrays are represented as an opaque type. */ +typedef void *awk_array_t; + +/* Scalars can be represented as an opaque type. */ +typedef void *awk_scalar_t; + +/* Any value can be stored as a cookie. */ +typedef void *awk_value_cookie_t; + +/* + * This tag defines the type of a value. + * + * Values are associated with regular variables and with array elements. + * Since arrays can be multidimensional (as can regular variables) + * it's valid to have a "value" that is actually an array. + */ +typedef enum { + AWK_UNDEFINED, + AWK_NUMBER, + AWK_STRING, + AWK_REGEX, + AWK_STRNUM, + AWK_ARRAY, + AWK_SCALAR, /* opaque access to a variable */ + AWK_VALUE_COOKIE, /* for updating a previously created value */ + AWK_BOOL +} awk_valtype_t; + +/* + * An awk value. The val_type tag indicates what + * is in the union. + */ +typedef struct awk_value { + awk_valtype_t val_type; + union { + awk_string_t s; + awk_number_t n; + awk_array_t a; + awk_scalar_t scl; + awk_value_cookie_t vc; + awk_bool_t b; + } u; +#define str_value u.s +#define strnum_value str_value +#define regex_value str_value +#define num_value u.n.d +#define num_type u.n.type +#define num_ptr u.n.ptr +#define array_cookie u.a +#define scalar_cookie u.scl +#define value_cookie u.vc +#define bool_value u.b +} awk_value_t; + +/* + * A "flattened" array element. Gawk produces an array of these + * inside the awk_flat_array_t. + * ALL memory pointed to belongs to gawk. Individual elements may + * be marked for deletion. New elements must be added individually, + * one at a time, using the separate API for that purpose. + */ + +typedef struct awk_element { + /* convenience linked list pointer, not used by gawk */ + struct awk_element *next; + enum { + AWK_ELEMENT_DEFAULT = 0, /* set by gawk */ + AWK_ELEMENT_DELETE = 1 /* set by extension if + should be deleted */ + } flags; + awk_value_t index; + awk_value_t value; +} awk_element_t; + +/* + * A "flattened" array. See the description above for how + * to use the elements contained herein. + */ +typedef struct awk_flat_array { + awk_const void *awk_const opaque1; /* private data for use by gawk */ + awk_const void *awk_const opaque2; /* private data for use by gawk */ + awk_const size_t count; /* how many elements */ + awk_element_t elements[1]; /* will be extended */ +} awk_flat_array_t; + +/* + * A record describing an extension function. Upon being + * loaded, the extension should pass in one of these to gawk for + * each C function. + * + * Each called function must fill in the result with either a scalar + * (number, string, or regex). Gawk takes ownership of any string memory. + * + * The called function must return the value of `result'. + * This is for the convenience of the calling code inside gawk. + * + * Each extension function may decide what to do if the number of + * arguments isn't what it expected. Following awk functions, it + * is likely OK to ignore extra arguments. + * + * 'min_required_args' indicates how many arguments MUST be passed. + * The API will throw a fatal error if not enough are passed. + * + * 'max_expected_args' is more benign; if more than that are passed, + * the API prints a lint message (IFF lint is enabled, of course). + * + * In any case, the extension function itself need not compare the + * actual number of arguments passed to those two values if it does + * not want to. + */ +typedef struct awk_ext_func { + const char *name; + awk_value_t *(*const function)(int num_actual_args, + awk_value_t *result, + struct awk_ext_func *finfo); + const size_t max_expected_args; + const size_t min_required_args; + awk_bool_t suppress_lint; + void *data; /* opaque pointer to any extra state */ +} awk_ext_func_t; + +typedef void *awk_ext_id_t; /* opaque type for extension id */ + +/* + * The API into gawk. Lots of functions here. We hope that they are + * logically organized. + * + * !!! If you make any changes to this structure, please remember to bump !!! + * !!! gawk_api_major_version and/or gawk_api_minor_version. !!! + */ +typedef struct gawk_api { + /* First, data fields. */ + + /* These are what gawk thinks the API version is. */ + awk_const int major_version; + awk_const int minor_version; + + /* GMP/MPFR versions, if extended-precision is available */ + awk_const int gmp_major_version; + awk_const int gmp_minor_version; + awk_const int mpfr_major_version; + awk_const int mpfr_minor_version; + + /* + * These can change on the fly as things happen within gawk. + * Currently only do_lint is prone to change, but we reserve + * the right to allow the others to do so also. + * + * N.B. If we ever again need to add an additional do_flags value, + * it would be wise to convert this from an array to a bitmask. If + * we add a new do_flags value and bump DO_FLAGS_SIZE, then it requires + * us to increment the ABI version. If we use a bitmask instead, then + * we will be free to add new flags without breaking ABI compatibility. + */ +#define DO_FLAGS_SIZE 7 + awk_const int do_flags[DO_FLAGS_SIZE]; +/* Use these as indices into do_flags[] array to check the values */ +#define gawk_do_lint 0 +#define gawk_do_traditional 1 +#define gawk_do_profile 2 +#define gawk_do_sandbox 3 +#define gawk_do_debug 4 +#define gawk_do_mpfr 5 +#define gawk_do_csv 6 + + /* Next, registration functions: */ + + /* + * Add a function to the interpreter, returns true upon success. + * Gawk does not modify what func points to, but the extension + * function itself receives this pointer and can modify what it + * points to, thus it's not const. + */ + awk_bool_t (*api_add_ext_func)(awk_ext_id_t id, const char *name_space, + awk_ext_func_t *func); + + /* Register an input parser; for opening files read-only */ + void (*api_register_input_parser)(awk_ext_id_t id, + awk_input_parser_t *input_parser); + + /* Register an output wrapper, for writing files */ + void (*api_register_output_wrapper)(awk_ext_id_t id, + awk_output_wrapper_t *output_wrapper); + + /* Register a processor for two way I/O */ + void (*api_register_two_way_processor)(awk_ext_id_t id, + awk_two_way_processor_t *two_way_processor); + + /* + * Add an exit call back. + * + * arg0 is a private data pointer for use by the extension; + * gawk saves it and passes it into the function pointed + * to by funcp at exit. + * + * Exit callback functions are called in LIFO order. + */ + void (*api_awk_atexit)(awk_ext_id_t id, + void (*funcp)(void *data, int exit_status), + void *arg0); + + /* Register a version string for this extension with gawk. */ + void (*api_register_ext_version)(awk_ext_id_t id, const char *version); + + /* Functions to print messages */ + void (*api_fatal)(awk_ext_id_t id, const char *format, ...); + void (*api_warning)(awk_ext_id_t id, const char *format, ...); + void (*api_lintwarn)(awk_ext_id_t id, const char *format, ...); + void (*api_nonfatal)(awk_ext_id_t id, const char *format, ...); + + /* Functions to update ERRNO */ + void (*api_update_ERRNO_int)(awk_ext_id_t id, int errno_val); + void (*api_update_ERRNO_string)(awk_ext_id_t id, const char *string); + void (*api_unset_ERRNO)(awk_ext_id_t id); + + /* + * All of the functions that return a value from inside gawk + * (get a parameter, get a global variable, get an array element) + * behave in the same way. + * + * For a function parameter, the return is false if the argument + * count is out of range, or if the actual parameter does not match + * what is specified in wanted. In that case, result->val_type + * will hold the actual type of what was passed. + * + * Similarly for symbol table access to variables and array elements, + * the return is false if the actual variable or array element does + * not match what was requested, and result->val_type will hold + * the actual type. + + Table entry is type returned: + + + +----------------------------------------------------------------+ + | Type of Actual Value: | + +--------+--------+--------+--------+--------+-------+-----------+ + | String | Strnum | Number | Regex | Bool | Array | Undefined | + +-----------+-----------+--------+--------+--------+--------+--------+-------+-----------+ + | | String | String | String | String | String | String | false | false | + | +-----------+--------+--------+--------+--------+--------+-------+-----------+ + | | Strnum | false | Strnum | Strnum | false | false | false | false | + | +-----------+--------+--------+--------+--------+--------+-------+-----------+ + | | Number | Number | Number | Number | false | Number | false | false | + | +-----------+--------+--------+--------+--------+--------+-------+-----------+ + | | Regex | false | false | false | Regex | false | false | false | + | +-----------+--------+--------+--------+--------+--------+-------+-----------+ + | Type | Bool | false | false | false | false | Bool | false | false | + | Requested +-----------+--------+--------+--------+--------+--------+-------+-----------+ + | | Array | false | false | false | false | false | Array | false | + | +-----------+--------+--------+--------+--------+--------+-------+-----------+ + | | Scalar | Scalar | Scalar | Scalar | Scalar | Scalar | false | false | + | +-----------+--------+--------+--------+--------+--------+-------+-----------+ + | | Undefined | String | Strnum | Number | Regex | Bool | Array | Undefined | + | +-----------+--------+--------+--------+--------+--------+-------+-----------+ + | | Value | false | false | false | false | false | false | false | + | | Cookie | | | | | | | | + +-----------+-----------+--------+--------+--------+--------+--------+-------+-----------+ + */ + + /* Functions to handle parameters passed to the extension. */ + + /* + * Get the count'th parameter, zero-based. + * Returns false if count is out of range, or if actual parameter + * does not match what is specified in wanted. In that case, + * result->val_type is as described above. + */ + awk_bool_t (*api_get_argument)(awk_ext_id_t id, size_t count, + awk_valtype_t wanted, + awk_value_t *result); + + /* + * Convert a parameter that was undefined into an array + * (provide call-by-reference for arrays). Returns false + * if count is too big, or if the argument's type is + * not undefined. + */ + awk_bool_t (*api_set_argument)(awk_ext_id_t id, + size_t count, + awk_array_t array); + + /* + * Symbol table access: + * - Read-only access to special variables (NF, etc.) + * - One special exception: PROCINFO. + * - Use sym_update() to change a value, including from UNDEFINED + * to scalar or array. + */ + /* + * Lookup a variable, fill in value. No messing with the value + * returned. + * Returns false if the variable doesn't exist or if the wrong type + * was requested. In the latter case, vaule->val_type will have + * the real type, as described above. + * + * awk_value_t val; + * if (! api->sym_lookup(id, name, wanted, & val)) + * error_code_here(); + * else { + * // safe to use val + * } + */ + awk_bool_t (*api_sym_lookup)(awk_ext_id_t id, + const char *name_space, + const char *name, + awk_valtype_t wanted, + awk_value_t *result); + + /* + * Update a value. Adds it to the symbol table if not there. + * Changing types (scalar <--> array) is not allowed. + * In fact, using this to update an array is not allowed, either. + * Such an attempt returns false. + */ + awk_bool_t (*api_sym_update)(awk_ext_id_t id, + const char *name_space, + const char *name, + awk_value_t *value); + + /* + * A ``scalar cookie'' is an opaque handle that provide access + * to a global variable or array. It is an optimization that + * avoids looking up variables in gawk's symbol table every time + * access is needed. + * + * This function retrieves the current value of a scalar cookie. + * Once you have obtained a scalar_cookie using sym_lookup, you can + * use this function to get its value more efficiently. + * + * Return will be false if the value cannot be retrieved. + * + * Flow is thus + * awk_value_t val; + * awk_scalar_t cookie; + * api->sym_lookup(id, "variable", AWK_SCALAR, & val); // get the cookie + * cookie = val.scalar_cookie; + * ... + * api->sym_lookup_scalar(id, cookie, wanted, & val); // get the value + */ + awk_bool_t (*api_sym_lookup_scalar)(awk_ext_id_t id, + awk_scalar_t cookie, + awk_valtype_t wanted, + awk_value_t *result); + + /* + * Update the value associated with a scalar cookie. + * Flow is + * sym_lookup with wanted == AWK_SCALAR + * if returns false + * sym_update with real initial value to install it + * sym_lookup again with AWK_SCALAR + * else + * use the scalar cookie + * + * Return will be false if the new value is not one of + * AWK_STRING, AWK_NUMBER, AWK_REGEX. + * + * Here too, the built-in variables may not be updated. + */ + awk_bool_t (*api_sym_update_scalar)(awk_ext_id_t id, + awk_scalar_t cookie, awk_value_t *value); + + /* Cached values */ + + /* + * Create a cached string,regex, or numeric value for efficient later + * assignment. This improves performance when you want to assign + * the same value to one or more variables repeatedly. Only + * AWK_NUMBER, AWK_STRING, AWK_REGEX and AWK_STRNUM values are allowed. + * Any other type is rejected. We disallow AWK_UNDEFINED since that + * case would result in inferior performance. + */ + awk_bool_t (*api_create_value)(awk_ext_id_t id, awk_value_t *value, + awk_value_cookie_t *result); + + /* + * Release the memory associated with a cookie from api_create_value. + * Please call this to free memory when the value is no longer needed. + */ + awk_bool_t (*api_release_value)(awk_ext_id_t id, awk_value_cookie_t vc); + + /* Array management */ + + /* + * Retrieve total number of elements in array. + * Returns false if some kind of error. + */ + awk_bool_t (*api_get_element_count)(awk_ext_id_t id, + awk_array_t a_cookie, size_t *count); + + /* + * Return the value of an element - read only! + * Use set_array_element() to change it. + * Behavior for value and return is same as for api_get_argument + * and sym_lookup. + */ + awk_bool_t (*api_get_array_element)(awk_ext_id_t id, + awk_array_t a_cookie, + const awk_value_t *const index, + awk_valtype_t wanted, + awk_value_t *result); + + /* + * Change (or create) element in existing array with + * index and value. + * + * ARGV and ENVIRON may not be updated. + */ + awk_bool_t (*api_set_array_element)(awk_ext_id_t id, awk_array_t a_cookie, + const awk_value_t *const index, + const awk_value_t *const value); + + /* + * Remove the element with the given index. + * Returns true if removed or false if element did not exist. + */ + awk_bool_t (*api_del_array_element)(awk_ext_id_t id, + awk_array_t a_cookie, const awk_value_t* const index); + + /* Create a new array cookie to which elements may be added. */ + awk_array_t (*api_create_array)(awk_ext_id_t id); + + /* Clear out an array. */ + awk_bool_t (*api_clear_array)(awk_ext_id_t id, awk_array_t a_cookie); + + /* + * Flatten out an array with type conversions as requested. + * This supersedes the earlier api_flatten_array function that + * did not allow the caller to specify the requested types. + * (That API is still available as a macro, defined below.) + */ + awk_bool_t (*api_flatten_array_typed)(awk_ext_id_t id, + awk_array_t a_cookie, + awk_flat_array_t **data, + awk_valtype_t index_type, awk_valtype_t value_type); + + /* When done, delete any marked elements, release the memory. */ + awk_bool_t (*api_release_flattened_array)(awk_ext_id_t id, + awk_array_t a_cookie, + awk_flat_array_t *data); + + /* + * Hooks to provide access to gawk's memory allocation functions. + * This ensures that memory passed between gawk and the extension + * is allocated and released by the same library. + */ + void *(*api_malloc)(size_t size); + void *(*api_calloc)(size_t nmemb, size_t size); + void *(*api_realloc)(void *ptr, size_t size); + void (*api_free)(void *ptr); + + /* + * Obsolete function, should not be used. It remains only + * for binary compatibility. Any value it returns should be + * freed via api_free. + */ + void *(*api_get_mpfr)(awk_ext_id_t id); + + /* + * Obsolete function, should not be used. It remains only + * for binary compatibility. Any value it returns should be + * freed via api_free. + */ + void *(*api_get_mpz)(awk_ext_id_t id); + + /* + * Look up a file. If the name is NULL or name_len is 0, it returns + * data for the currently open input file corresponding to FILENAME + * (and it will not access the filetype argument, so that may be + * undefined). + * + * If the file is not already open, try to open it. + * + * The "filetype" argument should be one of: + * + * ">", ">>", "<", "|>", "|<", and "|&" + * + * If the file is not already open, and the fd argument is non-negative, + * gawk will use that file descriptor instead of opening the file + * in the usual way. + * + * If the fd is non-negative, but the file exists already, gawk + * ignores the fd and returns the existing file. It is the caller's + * responsibility to notice that the fd in the returned + * awk_input_buf_t does not match the requested value. + * + * Note that supplying a file descriptor is currently NOT supported + * for pipes. It should work for input, output, append, and two-way + * (coprocess) sockets. If the filetype is two-way, we assume that + * it is a socket! + * + * Note that in the two-way case, the input and output file descriptors + * may differ. To check for success, one must check that either of + * them matches. + * + * ibufp and obufp point at gawk's internal copies of the + * awk_input_buf_t and awk_output_t associated with the open + * file. Treat these data structures as read-only! + */ + awk_bool_t (*api_get_file)(awk_ext_id_t id, + const char *name, + size_t name_len, + const char *filetype, + int fd, + /* + * Return values (on success, one or both should + * be non-NULL): + */ + const awk_input_buf_t **ibufp, + const awk_output_buf_t **obufp); + + /* Destroy an array. */ + awk_bool_t (*api_destroy_array)(awk_ext_id_t id, awk_array_t a_cookie); +} gawk_api_t; + +#ifndef GAWK /* these are not for the gawk code itself! */ +/* + * Use these if you want to define "global" variables named api + * and ext_id to make the code a little easier to read. + * See the sample boilerplate code, below. + */ +#define do_lint (api->do_flags[gawk_do_lint]) +#define do_traditional (api->do_flags[gawk_do_traditional]) +#define do_profile (api->do_flags[gawk_do_profile]) +#define do_sandbox (api->do_flags[gawk_do_sandbox]) +#define do_debug (api->do_flags[gawk_do_debug]) +#define do_mpfr (api->do_flags[gawk_do_mpfr]) +#define do_csv (api->do_flags[gawk_do_csv]) + +#define get_argument(count, wanted, result) \ + (api->api_get_argument(ext_id, count, wanted, result)) +#define set_argument(count, new_array) \ + (api->api_set_argument(ext_id, count, new_array)) + +#define fatal api->api_fatal +#define nonfatal api->api_nonfatal +#define warning api->api_warning +#define lintwarn api->api_lintwarn + +#define register_input_parser(parser) (api->api_register_input_parser(ext_id, parser)) +#define register_output_wrapper(wrapper) (api->api_register_output_wrapper(ext_id, wrapper)) +#define register_two_way_processor(processor) \ + (api->api_register_two_way_processor(ext_id, processor)) + +#define update_ERRNO_int(e) (api->api_update_ERRNO_int(ext_id, e)) +#define update_ERRNO_string(str) \ + (api->api_update_ERRNO_string(ext_id, str)) +#define unset_ERRNO() (api->api_unset_ERRNO(ext_id)) + +#define add_ext_func(ns, func) (api->api_add_ext_func(ext_id, ns, func)) +#define awk_atexit(funcp, arg0) (api->api_awk_atexit(ext_id, funcp, arg0)) + +#define sym_lookup(name, wanted, result) \ + sym_lookup_ns("", name, wanted, result) +#define sym_update(name, value) \ + sym_update_ns("", name, value) + +#define sym_lookup_ns(name_space, name, wanted, result) \ + (api->api_sym_lookup(ext_id, name_space, name, wanted, result)) +#define sym_update_ns(name_space, name, value) \ + (api->api_sym_update(ext_id, name_space, name, value)) + +#define sym_lookup_scalar(scalar_cookie, wanted, result) \ + (api->api_sym_lookup_scalar(ext_id, scalar_cookie, wanted, result)) +#define sym_update_scalar(scalar_cookie, value) \ + (api->api_sym_update_scalar)(ext_id, scalar_cookie, value) + +#define get_array_element(array, index, wanted, result) \ + (api->api_get_array_element(ext_id, array, index, wanted, result)) + +#define set_array_element(array, index, value) \ + (api->api_set_array_element(ext_id, array, index, value)) + +#define set_array_element_by_elem(array, elem) \ + (api->api_set_array_element(ext_id, array, & (elem)->index, & (elem)->value)) + +#define del_array_element(array, index) \ + (api->api_del_array_element(ext_id, array, index)) + +#define get_element_count(array, count_p) \ + (api->api_get_element_count(ext_id, array, count_p)) + +#define create_array() (api->api_create_array(ext_id)) + +#define destroy_array(array) (api->api_destroy_array(ext_id, array)) + +#define clear_array(array) (api->api_clear_array(ext_id, array)) + +#define flatten_array_typed(array, data, index_type, value_type) \ + (api->api_flatten_array_typed(ext_id, array, data, index_type, value_type)) + +#define flatten_array(array, data) \ + flatten_array_typed(array, data, AWK_STRING, AWK_UNDEFINED) + +#define release_flattened_array(array, data) \ + (api->api_release_flattened_array(ext_id, array, data)) + +#define gawk_malloc(size) (api->api_malloc(size)) +#define gawk_calloc(nmemb, size) (api->api_calloc(nmemb, size)) +#define gawk_realloc(ptr, size) (api->api_realloc(ptr, size)) +#define gawk_free(ptr) (api->api_free(ptr)) + +#define create_value(value, result) \ + (api->api_create_value(ext_id, value,result)) + +#define release_value(value) \ + (api->api_release_value(ext_id, value)) + +#define get_file(name, namelen, filetype, fd, ibuf, obuf) \ + (api->api_get_file(ext_id, name, namelen, filetype, fd, ibuf, obuf)) + +/* These two are obsolete and should not be used. */ +#define get_mpfr_ptr() (api->api_get_mpfr(ext_id)) +#define get_mpz_ptr() (api->api_get_mpz(ext_id)) + +#define register_ext_version(version) \ + (api->api_register_ext_version(ext_id, version)) + +#define emalloc(pointer, type, size, message) \ + do { \ + if ((pointer = (type) gawk_malloc(size)) == 0) \ + fatal(ext_id, "%s: malloc of %d bytes failed", message, size); \ + } while(0) + +#define ezalloc(pointer, type, size, message) \ + do { \ + if ((pointer = (type) gawk_calloc(1, size)) == 0) \ + fatal(ext_id, "%s: calloc of %d bytes failed", message, size); \ + } while(0) + +#define erealloc(pointer, type, size, message) \ + do { \ + if ((pointer = (type) gawk_realloc(pointer, size)) == 0) \ + fatal(ext_id, "%s: realloc of %d bytes failed", message, size); \ + } while(0) + +/* Constructor functions */ + +/* r_make_string_type --- make a string or strnum or regexp value in result from the passed-in string */ + +static inline awk_value_t * +r_make_string_type(const gawk_api_t *api, /* needed for emalloc */ + awk_ext_id_t ext_id, /* ditto */ + const char *string, + size_t length, + awk_bool_t duplicate, + awk_value_t *result, + awk_valtype_t val_type) +{ + char *cp = NULL; + + memset(result, 0, sizeof(*result)); + + result->val_type = val_type; + result->str_value.len = length; + + if (duplicate) { + emalloc(cp, char *, length + 1, "r_make_string"); + memcpy(cp, string, length); + cp[length] = '\0'; + result->str_value.str = cp; + } else { + result->str_value.str = (char *) string; + } + + return result; +} + +/* r_make_string --- make a string value in result from the passed-in string */ + +static inline awk_value_t * +r_make_string(const gawk_api_t *api, /* needed for emalloc */ + awk_ext_id_t ext_id, /* ditto */ + const char *string, + size_t length, + awk_bool_t duplicate, + awk_value_t *result) +{ + return r_make_string_type(api, ext_id, string, length, duplicate, result, AWK_STRING); +} + +#define make_const_string(str, len, result) r_make_string(api, ext_id, str, len, awk_true, result) +#define make_malloced_string(str, len, result) r_make_string(api, ext_id, str, len, awk_false, result) + +#define make_const_regex(str, len, result) r_make_string_type(api, ext_id, str, len, awk_true, result, AWK_REGEX) +#define make_malloced_regex(str, len, result) r_make_string_type(api, ext_id, str, len, awk_false, result, AWK_REGEX) + +/* + * Note: The caller may not create a STRNUM, but it can create a string that is + * flagged as user input that MAY be a STRNUM. Gawk will decide whether it's a + * STRNUM or a string by checking whether the string is numeric. + */ +#define make_const_user_input(str, len, result) r_make_string_type(api, ext_id, str, len, 1, result, AWK_STRNUM) +#define make_malloced_user_input(str, len, result) r_make_string_type(api, ext_id, str, len, 0, result, AWK_STRNUM) + +/* make_null_string --- make a null string value */ + +static inline awk_value_t * +make_null_string(awk_value_t *result) +{ + memset(result, 0, sizeof(*result)); + result->val_type = AWK_UNDEFINED; + + return result; +} + +/* make_number --- make a number value in result */ + +static inline awk_value_t * +make_number(double num, awk_value_t *result) +{ + result->val_type = AWK_NUMBER; + result->num_value = num; + result->num_type = AWK_NUMBER_TYPE_DOUBLE; + return result; +} + +/* + * make_number_mpz --- make an mpz number value in result. + * The mpz_ptr must be from a call to get_mpz_ptr. + */ + +static inline awk_value_t * +make_number_mpz(void *mpz_ptr, awk_value_t *result) +{ + result->val_type = AWK_NUMBER; + result->num_type = AWK_NUMBER_TYPE_MPZ; + result->num_ptr = mpz_ptr; + return result; +} + +/* + * make_number_mpfr --- make an mpfr number value in result. + * The mpfr_ptr must be from a call to get_mpfr_ptr. + */ + +static inline awk_value_t * +make_number_mpfr(void *mpfr_ptr, awk_value_t *result) +{ + result->val_type = AWK_NUMBER; + result->num_type = AWK_NUMBER_TYPE_MPFR; + result->num_ptr = mpfr_ptr; + return result; +} + +/* make_bool --- make a bool value in result */ + +static inline awk_value_t * +make_bool(awk_bool_t boolval, awk_value_t *result) +{ + result->val_type = AWK_BOOL; + result->bool_value = boolval; + return result; +} + + +/* + * Each extension must define a function with this prototype: + * + * int dl_load(gawk_api_t *api_p, awk_ext_id_t id) + * + * The return value should be zero on failure and non-zero on success. + * + * For the macros to work, the function should save api_p in a global + * variable named 'api' and save id in a global variable named 'ext_id'. + * In addition, a global function pointer named 'init_func' should be + * defined and set to either NULL or an initialization function that + * returns non-zero on success and zero upon failure. + */ + +extern int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id); + +#if 0 +/* Boilerplate code: */ +int plugin_is_GPL_compatible; + +static gawk_api_t *const api; +static awk_ext_id_t ext_id; +static const char *ext_version = NULL; /* or ... = "some string" */ + +static awk_ext_func_t func_table[] = { + { "name", do_name, 1 }, + /* ... */ +}; + +/* EITHER: */ + +static awk_bool_t (*init_func)(void) = NULL; + +/* OR: */ + +static awk_bool_t +init_my_extension(void) +{ + ... +} + +static awk_bool_t (*init_func)(void) = init_my_extension; + +dl_load_func(func_table, some_name, "name_space_in_quotes") +#endif + +#define dl_load_func(func_table, extension, name_space) \ +int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id) \ +{ \ + size_t i, j; \ + int errors = 0; \ +\ + api = api_p; \ + ext_id = (void **) id; \ +\ + if (api->major_version != GAWK_API_MAJOR_VERSION \ + || api->minor_version < GAWK_API_MINOR_VERSION) { \ + fprintf(stderr, #extension ": version mismatch with gawk!\n"); \ + fprintf(stderr, "\tmy version (API %d.%d), gawk version (API %d.%d)\n", \ + GAWK_API_MAJOR_VERSION, GAWK_API_MINOR_VERSION, \ + api->major_version, api->minor_version); \ + exit(1); \ + } \ +\ + check_mpfr_version(extension); \ +\ + /* load functions */ \ + for (i = 0, j = sizeof(func_table) / sizeof(func_table[0]); i < j; i++) { \ + if (func_table[i].name == NULL) \ + break; \ + if (! add_ext_func(name_space, & func_table[i])) { \ + warning(ext_id, #extension ": could not add %s", \ + func_table[i].name); \ + errors++; \ + } \ + } \ +\ + if (init_func != NULL) { \ + if (! init_func()) { \ + warning(ext_id, #extension ": initialization function failed"); \ + errors++; \ + } \ + } \ +\ + if (ext_version != NULL) \ + register_ext_version(ext_version); \ +\ + return (errors == 0); \ +} + +#if defined __GNU_MP_VERSION && defined MPFR_VERSION_MAJOR +#define check_mpfr_version(extension) do { \ + if (api->gmp_major_version != __GNU_MP_VERSION \ + || api->gmp_minor_version < __GNU_MP_VERSION_MINOR) { \ + fprintf(stderr, #extension ": GMP version mismatch with gawk!\n"); \ + fprintf(stderr, "\tmy version (%d, %d), gawk version (%d, %d)\n", \ + __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, \ + api->gmp_major_version, api->gmp_minor_version); \ + exit(1); \ + } \ + if (api->mpfr_major_version != MPFR_VERSION_MAJOR \ + || api->mpfr_minor_version < MPFR_VERSION_MINOR) { \ + fprintf(stderr, #extension ": MPFR version mismatch with gawk!\n"); \ + fprintf(stderr, "\tmy version (%d, %d), gawk version (%d, %d)\n", \ + MPFR_VERSION_MAJOR, MPFR_VERSION_MINOR, \ + api->mpfr_major_version, api->mpfr_minor_version); \ + exit(1); \ + } \ +} while (0) +#else +#define check_mpfr_version(extension) /* nothing */ +#endif + +#endif /* GAWK */ + +#ifdef __cplusplus +} +#endif /* C++ */ + +#endif /* _GAWK_API_H */ diff --git a/illumos-x86_64/usr/include/gelf.h b/illumos-x86_64/usr/include/gelf.h new file mode 100644 index 00000000..bb96404e --- /dev/null +++ b/illumos-x86_64/usr/include/gelf.h @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _GELF_H +#define _GELF_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#if !defined(_INT64_TYPE) +#error "64-bit integer types are required by gelf." +#endif + +/* + * Class-independent ELF API for Elf utilities. This is + * for manipulating Elf32 and Elf64 specific information + * in a format common to both classes. + */ + +typedef Elf64_Addr GElf_Addr; +typedef Elf64_Half GElf_Half; +typedef Elf64_Off GElf_Off; +typedef Elf64_Sword GElf_Sword; +typedef Elf64_Sxword GElf_Sxword; +typedef Elf64_Word GElf_Word; +typedef Elf64_Xword GElf_Xword; + +typedef Elf64_Ehdr GElf_Ehdr; +typedef Elf64_Move GElf_Move; +typedef Elf64_Phdr GElf_Phdr; +typedef Elf64_Shdr GElf_Shdr; +typedef Elf64_Sym GElf_Sym; +typedef Elf64_Syminfo GElf_Syminfo; +typedef Elf64_Rela GElf_Rela; +typedef Elf64_Rel GElf_Rel; +typedef Elf64_Dyn GElf_Dyn; +typedef Elf64_Cap GElf_Cap; + +/* + * The processing of versioning information can stay the + * same because both the Elf32 and Elf64 structures are + * of equal sizes. + */ +typedef Elf64_Verdef GElf_Verdef; +typedef Elf64_Verdaux GElf_Verdaux; +typedef Elf64_Verneed GElf_Verneed; +typedef Elf64_Vernaux GElf_Vernaux; +typedef Elf64_Versym GElf_Versym; + +/* + * move.m_info is encoded using the 64bit fields in Gelf. + */ +#define GELF_M_SYM ELF64_M_SYM +#define GELF_M_SIZE ELF64_M_SIZE + +/* + * sym.st_info field is same size for Elf32 and Elf64. + */ +#define GELF_ST_BIND ELF64_ST_BIND +#define GELF_ST_TYPE ELF64_ST_TYPE +#define GELF_ST_INFO ELF64_ST_INFO + + +/* + * Elf64 r_info may have data field in type id's word, + * so GELF_R_TYPE is defined as ELF64_R_TYPE_ID in order + * to isolate the proper bits for the true type id. + */ +#define GELF_R_TYPE ELF64_R_TYPE_ID +#define GELF_R_SYM ELF64_R_SYM +#define GELF_R_INFO ELF64_R_INFO +#define GELF_R_TYPE_DATA ELF64_R_TYPE_DATA +#define GELF_R_TYPE_ID ELF64_R_TYPE_ID +#define GELF_R_TYPE_INFO ELF64_R_TYPE_INFO + + + +int gelf_getclass(Elf*); +size_t gelf_fsize(Elf *, Elf_Type, size_t, uint_t); +GElf_Ehdr * gelf_getehdr(Elf *, GElf_Ehdr *); +int gelf_update_ehdr(Elf *, GElf_Ehdr *); +unsigned long gelf_newehdr(Elf *, int); +GElf_Phdr * gelf_getphdr(Elf *, int, GElf_Phdr *); +int gelf_update_phdr(Elf *, int, GElf_Phdr *); +unsigned long gelf_newphdr(Elf *, size_t); +GElf_Shdr * gelf_getshdr(Elf_Scn *, GElf_Shdr *); +int gelf_update_shdr(Elf_Scn *, GElf_Shdr *); +Elf_Data * gelf_xlatetof(Elf *, Elf_Data *, const Elf_Data *, uint_t); +Elf_Data * gelf_xlatetom(Elf *, Elf_Data *, const Elf_Data *, uint_t); +GElf_Sym * gelf_getsym(Elf_Data *, int, GElf_Sym *); +int gelf_update_sym(Elf_Data *, int, GElf_Sym *); +GElf_Sym * gelf_getsymshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *, + Elf32_Word *); +int gelf_update_symshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *, + Elf32_Word); +GElf_Syminfo * gelf_getsyminfo(Elf_Data *, int, GElf_Syminfo *); +int gelf_update_syminfo(Elf_Data *, int, GElf_Syminfo *); +GElf_Move * gelf_getmove(Elf_Data *, int, GElf_Move *); +int gelf_update_move(Elf_Data *, int, GElf_Move *); +GElf_Dyn * gelf_getdyn(Elf_Data *, int, GElf_Dyn *); +int gelf_update_dyn(Elf_Data *, int, GElf_Dyn *); +GElf_Rela * gelf_getrela(Elf_Data *, int, GElf_Rela *); +int gelf_update_rela(Elf_Data *, int, GElf_Rela *); +GElf_Rel * gelf_getrel(Elf_Data *, int, GElf_Rel *); +int gelf_update_rel(Elf_Data *, int, GElf_Rel *); +long gelf_checksum(Elf *); +GElf_Cap * gelf_getcap(Elf_Data *, int, GElf_Cap *); +int gelf_update_cap(Elf_Data *, int, GElf_Cap *); + + +#ifdef __cplusplus +} +#endif + +#endif /* _GELF_H */ diff --git a/illumos-x86_64/usr/include/getopt.h b/illumos-x86_64/usr/include/getopt.h new file mode 100644 index 00000000..2b72c23d --- /dev/null +++ b/illumos-x86_64/usr/include/getopt.h @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2020 Joyent Inc. + */ + +/* + * GNU-like getopt_long(), getopt_long_only(). + * Solaris-specific getopt_clip(). + */ + +#ifndef _GETOPT_H +#define _GETOPT_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Values for has_arg field. + * + * optional_argument is not supported by getopt_clip() + */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +struct option { + const char *name; /* name of long option */ + int has_arg; /* whether option takes an argument */ + int *flag; /* if not NULL, set *flag to val when option */ + /* found */ + int val; /* if flag is not NULL, value to set *flag */ + /* to. */ + /* if flag is NULL, return value */ +}; + +/* + * External variables used by these routines. + */ +extern char *optarg; +extern int opterr; +extern int optind; +extern int optopt; + +/* + * The use of getopt_long_only in new development is strongly discouraged. + */ +extern int getopt_long(int, char * const *, const char *, + const struct option *, int *); +extern int getopt_long_only(int, char * const *, const char *, + const struct option *, int *); +extern int getopt_clip(int, char * const *, const char *, + const struct option *, int *); + +#ifdef __cplusplus +} +#endif + +#endif /* _GETOPT_H */ diff --git a/illumos-x86_64/usr/include/getwidth.h b/illumos-x86_64/usr/include/getwidth.h new file mode 100644 index 00000000..4dd332aa --- /dev/null +++ b/illumos-x86_64/usr/include/getwidth.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1989 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984 AT&T */ +/* All Rights Reserved */ + +#ifndef _GETWIDTH_H +#define _GETWIDTH_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern void getwidth(eucwidth_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _GETWIDTH_H */ diff --git a/illumos-x86_64/usr/include/gio-unix-2.0/gio/gdesktopappinfo.h b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gdesktopappinfo.h new file mode 100644 index 00000000..7981a026 --- /dev/null +++ b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gdesktopappinfo.h @@ -0,0 +1,200 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_DESKTOP_APP_INFO_H__ +#define __G_DESKTOP_APP_INFO_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DESKTOP_APP_INFO (g_desktop_app_info_get_type ()) +#define G_DESKTOP_APP_INFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DESKTOP_APP_INFO, GDesktopAppInfo)) +#define G_DESKTOP_APP_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DESKTOP_APP_INFO, GDesktopAppInfoClass)) +#define G_IS_DESKTOP_APP_INFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DESKTOP_APP_INFO)) +#define G_IS_DESKTOP_APP_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DESKTOP_APP_INFO)) +#define G_DESKTOP_APP_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DESKTOP_APP_INFO, GDesktopAppInfoClass)) + +typedef struct _GDesktopAppInfo GDesktopAppInfo; +typedef struct _GDesktopAppInfoClass GDesktopAppInfoClass; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDesktopAppInfo, g_object_unref) + +struct _GDesktopAppInfoClass +{ + GObjectClass parent_class; +}; + + +GIO_AVAILABLE_IN_ALL +GType g_desktop_app_info_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GDesktopAppInfo *g_desktop_app_info_new_from_filename (const char *filename); +GIO_AVAILABLE_IN_ALL +GDesktopAppInfo *g_desktop_app_info_new_from_keyfile (GKeyFile *key_file); + +GIO_AVAILABLE_IN_ALL +const char * g_desktop_app_info_get_filename (GDesktopAppInfo *info); + +GIO_AVAILABLE_IN_2_30 +const char * g_desktop_app_info_get_generic_name (GDesktopAppInfo *info); +GIO_AVAILABLE_IN_2_30 +const char * g_desktop_app_info_get_categories (GDesktopAppInfo *info); +GIO_AVAILABLE_IN_2_30 +const char * const *g_desktop_app_info_get_keywords (GDesktopAppInfo *info); +GIO_AVAILABLE_IN_2_30 +gboolean g_desktop_app_info_get_nodisplay (GDesktopAppInfo *info); +GIO_AVAILABLE_IN_2_30 +gboolean g_desktop_app_info_get_show_in (GDesktopAppInfo *info, + const gchar *desktop_env); +GIO_AVAILABLE_IN_2_34 +const char * g_desktop_app_info_get_startup_wm_class (GDesktopAppInfo *info); + +GIO_AVAILABLE_IN_ALL +GDesktopAppInfo *g_desktop_app_info_new (const char *desktop_id); +GIO_AVAILABLE_IN_ALL +gboolean g_desktop_app_info_get_is_hidden (GDesktopAppInfo *info); + +GIO_DEPRECATED_IN_2_42 +void g_desktop_app_info_set_desktop_env (const char *desktop_env); + +GIO_AVAILABLE_IN_2_36 +gboolean g_desktop_app_info_has_key (GDesktopAppInfo *info, + const char *key); +GIO_AVAILABLE_IN_2_36 +char * g_desktop_app_info_get_string (GDesktopAppInfo *info, + const char *key); +GIO_AVAILABLE_IN_2_56 +char * g_desktop_app_info_get_locale_string (GDesktopAppInfo *info, + const char *key); +GIO_AVAILABLE_IN_2_36 +gboolean g_desktop_app_info_get_boolean (GDesktopAppInfo *info, + const char *key); + +GIO_AVAILABLE_IN_2_60 +gchar ** g_desktop_app_info_get_string_list (GDesktopAppInfo *info, + const char *key, + gsize *length); + +GIO_AVAILABLE_IN_2_38 +const gchar * const * g_desktop_app_info_list_actions (GDesktopAppInfo *info); + +GIO_AVAILABLE_IN_2_38 +void g_desktop_app_info_launch_action (GDesktopAppInfo *info, + const gchar *action_name, + GAppLaunchContext *launch_context); + +GIO_AVAILABLE_IN_2_38 +gchar * g_desktop_app_info_get_action_name (GDesktopAppInfo *info, + const gchar *action_name); + +#define G_TYPE_DESKTOP_APP_INFO_LOOKUP (g_desktop_app_info_lookup_get_type ()) GIO_DEPRECATED_MACRO_IN_2_28 +#define G_DESKTOP_APP_INFO_LOOKUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DESKTOP_APP_INFO_LOOKUP, GDesktopAppInfoLookup)) GIO_DEPRECATED_MACRO_IN_2_28 +#define G_IS_DESKTOP_APP_INFO_LOOKUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DESKTOP_APP_INFO_LOOKUP)) GIO_DEPRECATED_MACRO_IN_2_28 +#define G_DESKTOP_APP_INFO_LOOKUP_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DESKTOP_APP_INFO_LOOKUP, GDesktopAppInfoLookupIface)) GIO_DEPRECATED_MACRO_IN_2_28 + +/** + * G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME: + * + * Extension point for default handler to URI association. See + * [Extending GIO](overview.html#extending-gio). + * + * Deprecated: 2.28: The #GDesktopAppInfoLookup interface is deprecated and + * unused by GIO. + */ +#define G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME "gio-desktop-app-info-lookup" GIO_DEPRECATED_MACRO_IN_2_28 + +/** + * GDesktopAppInfoLookupIface: + * @get_default_for_uri_scheme: Virtual method for + * g_desktop_app_info_lookup_get_default_for_uri_scheme(). + * + * Interface that is used by backends to associate default + * handlers with URI schemes. + */ +typedef struct _GDesktopAppInfoLookup GDesktopAppInfoLookup; +typedef struct _GDesktopAppInfoLookupIface GDesktopAppInfoLookupIface; + +struct _GDesktopAppInfoLookupIface +{ + GTypeInterface g_iface; + + GAppInfo * (* get_default_for_uri_scheme) (GDesktopAppInfoLookup *lookup, + const char *uri_scheme); +}; + +GIO_DEPRECATED +GType g_desktop_app_info_lookup_get_type (void) G_GNUC_CONST; + +GIO_DEPRECATED +GAppInfo *g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *lookup, + const char *uri_scheme); + +/** + * GDesktopAppLaunchCallback: + * @appinfo: a #GDesktopAppInfo + * @pid: Process identifier + * @user_data: User data + * + * During invocation, g_desktop_app_info_launch_uris_as_manager() may + * create one or more child processes. This callback is invoked once + * for each, providing the process ID. + */ +typedef void (*GDesktopAppLaunchCallback) (GDesktopAppInfo *appinfo, + GPid pid, + gpointer user_data); + +GIO_AVAILABLE_IN_2_28 +gboolean g_desktop_app_info_launch_uris_as_manager (GDesktopAppInfo *appinfo, + GList *uris, + GAppLaunchContext *launch_context, + GSpawnFlags spawn_flags, + GSpawnChildSetupFunc user_setup, + gpointer user_setup_data, + GDesktopAppLaunchCallback pid_callback, + gpointer pid_callback_data, + GError **error); + +GIO_AVAILABLE_IN_2_58 +gboolean g_desktop_app_info_launch_uris_as_manager_with_fds (GDesktopAppInfo *appinfo, + GList *uris, + GAppLaunchContext *launch_context, + GSpawnFlags spawn_flags, + GSpawnChildSetupFunc user_setup, + gpointer user_setup_data, + GDesktopAppLaunchCallback pid_callback, + gpointer pid_callback_data, + gint stdin_fd, + gint stdout_fd, + gint stderr_fd, + GError **error); + +GIO_AVAILABLE_IN_2_40 +gchar *** g_desktop_app_info_search (const gchar *search_string); + +GIO_AVAILABLE_IN_2_42 +GList *g_desktop_app_info_get_implementations (const gchar *interface); + +G_END_DECLS + +#endif /* __G_DESKTOP_APP_INFO_H__ */ diff --git a/illumos-x86_64/usr/include/gio-unix-2.0/gio/gfiledescriptorbased.h b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gfiledescriptorbased.h new file mode 100644 index 00000000..7c7c78af --- /dev/null +++ b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gfiledescriptorbased.h @@ -0,0 +1,63 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Christian Kellner + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Christian Kellner + */ + +#ifndef __G_FILE_DESCRIPTOR_BASED_H__ +#define __G_FILE_DESCRIPTOR_BASED_H__ + +#include + +G_BEGIN_DECLS + +typedef struct _GFileDescriptorBased GFileDescriptorBased; +typedef struct _GFileDescriptorBasedIface GFileDescriptorBasedIface; + +#define G_TYPE_FILE_DESCRIPTOR_BASED (g_file_descriptor_based_get_type ()) +#define G_FILE_DESCRIPTOR_BASED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_FILE_DESCRIPTOR_BASED, GFileDescriptorBased)) +#define G_IS_FILE_DESCRIPTOR_BASED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_FILE_DESCRIPTOR_BASED)) +#define G_FILE_DESCRIPTOR_BASED_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_FILE_DESCRIPTOR_BASED, GFileDescriptorBasedIface)) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileDescriptorBased, g_object_unref) + +/** + * GFileDescriptorBasedIface: + * @g_iface: The parent interface. + * @get_fd: Gets the underlying file descriptor. + * + * An interface for file descriptor based io objects. + **/ +struct _GFileDescriptorBasedIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + int (*get_fd) (GFileDescriptorBased *fd_based); +}; + +GIO_AVAILABLE_IN_ALL +GType g_file_descriptor_based_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +int g_file_descriptor_based_get_fd (GFileDescriptorBased *fd_based); + +G_END_DECLS + + +#endif /* __G_FILE_DESCRIPTOR_BASED_H__ */ diff --git a/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixfdmessage.h b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixfdmessage.h new file mode 100644 index 00000000..0424b115 --- /dev/null +++ b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixfdmessage.h @@ -0,0 +1,86 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2009 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_UNIX_FD_MESSAGE_H__ +#define __G_UNIX_FD_MESSAGE_H__ + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_UNIX_FD_MESSAGE (g_unix_fd_message_get_type ()) +#define G_UNIX_FD_MESSAGE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_UNIX_FD_MESSAGE, GUnixFDMessage)) +#define G_UNIX_FD_MESSAGE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_UNIX_FD_MESSAGE, GUnixFDMessageClass)) +#define G_IS_UNIX_FD_MESSAGE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_UNIX_FD_MESSAGE)) +#define G_IS_UNIX_FD_MESSAGE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_UNIX_FD_MESSAGE)) +#define G_UNIX_FD_MESSAGE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_UNIX_FD_MESSAGE, GUnixFDMessageClass)) + +typedef struct _GUnixFDMessagePrivate GUnixFDMessagePrivate; +typedef struct _GUnixFDMessageClass GUnixFDMessageClass; +typedef struct _GUnixFDMessage GUnixFDMessage; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixFDMessage, g_object_unref) + +struct _GUnixFDMessageClass +{ + GSocketControlMessageClass parent_class; + + /*< private >*/ + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); +}; + +struct _GUnixFDMessage +{ + GSocketControlMessage parent_instance; + GUnixFDMessagePrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_unix_fd_message_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GSocketControlMessage * g_unix_fd_message_new_with_fd_list (GUnixFDList *fd_list); +GIO_AVAILABLE_IN_ALL +GSocketControlMessage * g_unix_fd_message_new (void); + +GIO_AVAILABLE_IN_ALL +GUnixFDList * g_unix_fd_message_get_fd_list (GUnixFDMessage *message); + +GIO_AVAILABLE_IN_ALL +gint * g_unix_fd_message_steal_fds (GUnixFDMessage *message, + gint *length); +GIO_AVAILABLE_IN_ALL +gboolean g_unix_fd_message_append_fd (GUnixFDMessage *message, + gint fd, + GError **error); + +G_END_DECLS + +#endif /* __G_UNIX_FD_MESSAGE_H__ */ diff --git a/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixinputstream.h b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixinputstream.h new file mode 100644 index 00000000..0c2af4f0 --- /dev/null +++ b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixinputstream.h @@ -0,0 +1,80 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_UNIX_INPUT_STREAM_H__ +#define __G_UNIX_INPUT_STREAM_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_UNIX_INPUT_STREAM (g_unix_input_stream_get_type ()) +#define G_UNIX_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNIX_INPUT_STREAM, GUnixInputStream)) +#define G_UNIX_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNIX_INPUT_STREAM, GUnixInputStreamClass)) +#define G_IS_UNIX_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNIX_INPUT_STREAM)) +#define G_IS_UNIX_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNIX_INPUT_STREAM)) +#define G_UNIX_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_UNIX_INPUT_STREAM, GUnixInputStreamClass)) + +typedef struct _GUnixInputStream GUnixInputStream; +typedef struct _GUnixInputStreamClass GUnixInputStreamClass; +typedef struct _GUnixInputStreamPrivate GUnixInputStreamPrivate; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixInputStream, g_object_unref) + +struct _GUnixInputStream +{ + GInputStream parent_instance; + + /*< private >*/ + GUnixInputStreamPrivate *priv; +}; + +struct _GUnixInputStreamClass +{ + GInputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_unix_input_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GInputStream * g_unix_input_stream_new (gint fd, + gboolean close_fd); +GIO_AVAILABLE_IN_ALL +void g_unix_input_stream_set_close_fd (GUnixInputStream *stream, + gboolean close_fd); +GIO_AVAILABLE_IN_ALL +gboolean g_unix_input_stream_get_close_fd (GUnixInputStream *stream); +GIO_AVAILABLE_IN_ALL +gint g_unix_input_stream_get_fd (GUnixInputStream *stream); + +G_END_DECLS + +#endif /* __G_UNIX_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixmounts.h b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixmounts.h new file mode 100644 index 00000000..3c35fd34 --- /dev/null +++ b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixmounts.h @@ -0,0 +1,253 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_UNIX_MOUNTS_H__ +#define __G_UNIX_MOUNTS_H__ + +#include +#include + +G_BEGIN_DECLS + +/** + * GUnixMountEntry: + * + * Defines a Unix mount entry (e.g. `/media/cdrom`). + * This corresponds roughly to a mtab entry. + **/ +typedef struct _GUnixMountEntry GUnixMountEntry; + +#define G_TYPE_UNIX_MOUNT_ENTRY (g_unix_mount_entry_get_type ()) +GIO_AVAILABLE_IN_2_54 +GType g_unix_mount_entry_get_type (void) G_GNUC_CONST; + +/** + * GUnixMountPoint: + * + * Defines a Unix mount point (e.g. `/dev`). + * This corresponds roughly to a fstab entry. + **/ +typedef struct _GUnixMountPoint GUnixMountPoint; + +#define G_TYPE_UNIX_MOUNT_POINT (g_unix_mount_point_get_type ()) +GIO_AVAILABLE_IN_2_54 +GType g_unix_mount_point_get_type (void) G_GNUC_CONST; + +/** + * GUnixMountMonitor: + * + * Watches for changes to the set of mount entries and mount points in the + * system. + * + * Connect to the [signal@GioUnix.MountMonitor::mounts-changed] signal to be + * notified of changes to the [struct@GioUnix.MountEntry] list. + * + * Connect to the [signal@GioUnix.MountMonitor::mountpoints-changed] signal to + * be notified of changes to the [struct@GioUnix.MountPoint] list. + **/ +typedef struct _GUnixMountMonitor GUnixMountMonitor; +typedef struct _GUnixMountMonitorClass GUnixMountMonitorClass; + +#define G_TYPE_UNIX_MOUNT_MONITOR (g_unix_mount_monitor_get_type ()) +#define G_UNIX_MOUNT_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNIX_MOUNT_MONITOR, GUnixMountMonitor)) +#define G_UNIX_MOUNT_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNIX_MOUNT_MONITOR, GUnixMountMonitorClass)) +#define G_IS_UNIX_MOUNT_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNIX_MOUNT_MONITOR)) +#define G_IS_UNIX_MOUNT_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNIX_MOUNT_MONITOR)) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixMountMonitor, g_object_unref) + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_free) +void g_unix_mount_free (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +void g_unix_mount_entry_free (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_copy) +GUnixMountEntry *g_unix_mount_copy (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +GUnixMountEntry *g_unix_mount_entry_copy (GUnixMountEntry *mount_entry); + +GIO_AVAILABLE_IN_ALL +void g_unix_mount_point_free (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_2_54 +GUnixMountPoint *g_unix_mount_point_copy (GUnixMountPoint *mount_point); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_compare) +gint g_unix_mount_compare (GUnixMountEntry *mount1, + GUnixMountEntry *mount2); +GIO_AVAILABLE_IN_2_84 +gint g_unix_mount_entry_compare (GUnixMountEntry *mount1, + GUnixMountEntry *mount2); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_get_mount_path) +const char * g_unix_mount_get_mount_path (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +const char * g_unix_mount_entry_get_mount_path (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_get_device_path) +const char * g_unix_mount_get_device_path (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +const char * g_unix_mount_entry_get_device_path (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_get_root_path) +const char * g_unix_mount_get_root_path (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +const char * g_unix_mount_entry_get_root_path (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_get_fs_type) +const char * g_unix_mount_get_fs_type (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +const char * g_unix_mount_entry_get_fs_type (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_get_options) +const char * g_unix_mount_get_options (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +const char * g_unix_mount_entry_get_options (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_is_readonly) +gboolean g_unix_mount_is_readonly (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +gboolean g_unix_mount_entry_is_readonly (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_is_system_internal) +gboolean g_unix_mount_is_system_internal (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +gboolean g_unix_mount_entry_is_system_internal(GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_guess_can_eject) +gboolean g_unix_mount_guess_can_eject (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +gboolean g_unix_mount_entry_guess_can_eject (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_guess_should_display) +gboolean g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +gboolean g_unix_mount_entry_guess_should_display(GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_guess_name) +char * g_unix_mount_guess_name (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +char * g_unix_mount_entry_guess_name (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_guess_icon) +GIcon * g_unix_mount_guess_icon (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +GIcon * g_unix_mount_entry_guess_icon (GUnixMountEntry *mount_entry); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_guess_symbolic_icon) +GIcon * g_unix_mount_guess_symbolic_icon (GUnixMountEntry *mount_entry); +GIO_AVAILABLE_IN_2_84 +GIcon * g_unix_mount_entry_guess_symbolic_icon(GUnixMountEntry *mount_entry); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixMountEntry, g_unix_mount_entry_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixMountPoint, g_unix_mount_point_free) + +GIO_AVAILABLE_IN_ALL +gint g_unix_mount_point_compare (GUnixMountPoint *mount1, + GUnixMountPoint *mount2); +GIO_AVAILABLE_IN_ALL +const char * g_unix_mount_point_get_mount_path (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +const char * g_unix_mount_point_get_device_path (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +const char * g_unix_mount_point_get_fs_type (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_2_32 +const char * g_unix_mount_point_get_options (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +gboolean g_unix_mount_point_is_readonly (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +gboolean g_unix_mount_point_is_user_mountable (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +gboolean g_unix_mount_point_is_loopback (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +gboolean g_unix_mount_point_guess_can_eject (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +char * g_unix_mount_point_guess_name (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +GIcon * g_unix_mount_point_guess_icon (GUnixMountPoint *mount_point); +GIO_AVAILABLE_IN_ALL +GIcon * g_unix_mount_point_guess_symbolic_icon (GUnixMountPoint *mount_point); + + +GIO_AVAILABLE_IN_ALL +GList * g_unix_mount_points_get (guint64 *time_read); +GIO_AVAILABLE_IN_2_82 +GUnixMountPoint **g_unix_mount_points_get_from_file (const char *table_path, + uint64_t *time_read_out, + size_t *n_points_out); +GIO_AVAILABLE_IN_2_66 +GUnixMountPoint *g_unix_mount_point_at (const char *mount_path, + guint64 *time_read); +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entries_get) +GList * g_unix_mounts_get (guint64 *time_read); +GIO_AVAILABLE_IN_2_84 +GList * g_unix_mount_entries_get (guint64 *time_read); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entries_get_from_file) +GUnixMountEntry **g_unix_mounts_get_from_file (const char *table_path, + uint64_t *time_read_out, + size_t *n_entries_out); +GIO_AVAILABLE_IN_2_84 +GUnixMountEntry **g_unix_mount_entries_get_from_file(const char *table_path, + uint64_t *time_read_out, + size_t *n_entries_out); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_at) +GUnixMountEntry *g_unix_mount_at (const char *mount_path, + guint64 *time_read); +GIO_AVAILABLE_IN_2_84 +GUnixMountEntry *g_unix_mount_entry_at (const char *mount_path, + guint64 *time_read); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entry_for) +GUnixMountEntry *g_unix_mount_for (const char *file_path, + guint64 *time_read); +GIO_AVAILABLE_IN_2_84 +GUnixMountEntry *g_unix_mount_entry_for (const char *file_path, + guint64 *time_read); + +GIO_DEPRECATED_IN_2_84_FOR(g_unix_mount_entries_changed_since) +gboolean g_unix_mounts_changed_since (guint64 time); +GIO_AVAILABLE_IN_2_84 +gboolean g_unix_mount_entries_changed_since (guint64 time); + +GIO_AVAILABLE_IN_ALL +gboolean g_unix_mount_points_changed_since (guint64 time); + +GIO_AVAILABLE_IN_ALL +GType g_unix_mount_monitor_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_2_44 +GUnixMountMonitor *g_unix_mount_monitor_get (void); +GIO_DEPRECATED_IN_2_44_FOR(g_unix_mount_monitor_get) +GUnixMountMonitor *g_unix_mount_monitor_new (void); +GIO_DEPRECATED_IN_2_44 +void g_unix_mount_monitor_set_rate_limit (GUnixMountMonitor *mount_monitor, + int limit_msec); + +GIO_AVAILABLE_IN_ALL +gboolean g_unix_is_mount_path_system_internal (const char *mount_path); +GIO_AVAILABLE_IN_2_56 +gboolean g_unix_is_system_fs_type (const char *fs_type); +GIO_AVAILABLE_IN_2_56 +gboolean g_unix_is_system_device_path (const char *device_path); + +G_END_DECLS + +#endif /* __G_UNIX_MOUNTS_H__ */ diff --git a/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixoutputstream.h b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixoutputstream.h new file mode 100644 index 00000000..55e33f68 --- /dev/null +++ b/illumos-x86_64/usr/include/gio-unix-2.0/gio/gunixoutputstream.h @@ -0,0 +1,79 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_UNIX_OUTPUT_STREAM_H__ +#define __G_UNIX_OUTPUT_STREAM_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_UNIX_OUTPUT_STREAM (g_unix_output_stream_get_type ()) +#define G_UNIX_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNIX_OUTPUT_STREAM, GUnixOutputStream)) +#define G_UNIX_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNIX_OUTPUT_STREAM, GUnixOutputStreamClass)) +#define G_IS_UNIX_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNIX_OUTPUT_STREAM)) +#define G_IS_UNIX_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNIX_OUTPUT_STREAM)) +#define G_UNIX_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_UNIX_OUTPUT_STREAM, GUnixOutputStreamClass)) + +typedef struct _GUnixOutputStream GUnixOutputStream; +typedef struct _GUnixOutputStreamClass GUnixOutputStreamClass; +typedef struct _GUnixOutputStreamPrivate GUnixOutputStreamPrivate; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixOutputStream, g_object_unref) + +struct _GUnixOutputStream +{ + GOutputStream parent_instance; + + /*< private >*/ + GUnixOutputStreamPrivate *priv; +}; + +struct _GUnixOutputStreamClass +{ + GOutputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_unix_output_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GOutputStream * g_unix_output_stream_new (gint fd, + gboolean close_fd); +GIO_AVAILABLE_IN_ALL +void g_unix_output_stream_set_close_fd (GUnixOutputStream *stream, + gboolean close_fd); +GIO_AVAILABLE_IN_ALL +gboolean g_unix_output_stream_get_close_fd (GUnixOutputStream *stream); +GIO_AVAILABLE_IN_ALL +gint g_unix_output_stream_get_fd (GUnixOutputStream *stream); +G_END_DECLS + +#endif /* __G_UNIX_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gaction.h b/illumos-x86_64/usr/include/glib-2.0/gio/gaction.h new file mode 100644 index 00000000..c3666b49 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gaction.h @@ -0,0 +1,100 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_ACTION_H__ +#define __G_ACTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_ACTION (g_action_get_type ()) +#define G_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_ACTION, GAction)) +#define G_IS_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_ACTION)) +#define G_ACTION_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \ + G_TYPE_ACTION, GActionInterface)) + +typedef struct _GActionInterface GActionInterface; + +struct _GActionInterface +{ + GTypeInterface g_iface; + + /* virtual functions */ + const gchar * (* get_name) (GAction *action); + const GVariantType * (* get_parameter_type) (GAction *action); + const GVariantType * (* get_state_type) (GAction *action); + GVariant * (* get_state_hint) (GAction *action); + + gboolean (* get_enabled) (GAction *action); + GVariant * (* get_state) (GAction *action); + + void (* change_state) (GAction *action, + GVariant *value); + void (* activate) (GAction *action, + GVariant *parameter); +}; + +GIO_AVAILABLE_IN_2_30 +GType g_action_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +const gchar * g_action_get_name (GAction *action); +GIO_AVAILABLE_IN_ALL +const GVariantType * g_action_get_parameter_type (GAction *action); +GIO_AVAILABLE_IN_ALL +const GVariantType * g_action_get_state_type (GAction *action); +GIO_AVAILABLE_IN_ALL +GVariant * g_action_get_state_hint (GAction *action); + +GIO_AVAILABLE_IN_ALL +gboolean g_action_get_enabled (GAction *action); +GIO_AVAILABLE_IN_ALL +GVariant * g_action_get_state (GAction *action); + +GIO_AVAILABLE_IN_ALL +void g_action_change_state (GAction *action, + GVariant *value); +GIO_AVAILABLE_IN_ALL +void g_action_activate (GAction *action, + GVariant *parameter); + +GIO_AVAILABLE_IN_2_28 +gboolean g_action_name_is_valid (const gchar *action_name); + +GIO_AVAILABLE_IN_2_38 +gboolean g_action_parse_detailed_name (const gchar *detailed_name, + gchar **action_name, + GVariant **target_value, + GError **error); + +GIO_AVAILABLE_IN_2_38 +gchar * g_action_print_detailed_name (const gchar *action_name, + GVariant *target_value); + +G_END_DECLS + +#endif /* __G_ACTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gactiongroup.h b/illumos-x86_64/usr/include/glib-2.0/gio/gactiongroup.h new file mode 100644 index 00000000..06213df8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gactiongroup.h @@ -0,0 +1,163 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_ACTION_GROUP_H__ +#define __G_ACTION_GROUP_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + + +#define G_TYPE_ACTION_GROUP (g_action_group_get_type ()) +#define G_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_ACTION_GROUP, GActionGroup)) +#define G_IS_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_ACTION_GROUP)) +#define G_ACTION_GROUP_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \ + G_TYPE_ACTION_GROUP, GActionGroupInterface)) + +typedef struct _GActionGroupInterface GActionGroupInterface; + +struct _GActionGroupInterface +{ + GTypeInterface g_iface; + + /* virtual functions */ + gboolean (* has_action) (GActionGroup *action_group, + const gchar *action_name); + + gchar ** (* list_actions) (GActionGroup *action_group); + + gboolean (* get_action_enabled) (GActionGroup *action_group, + const gchar *action_name); + + const GVariantType * (* get_action_parameter_type) (GActionGroup *action_group, + const gchar *action_name); + + const GVariantType * (* get_action_state_type) (GActionGroup *action_group, + const gchar *action_name); + + GVariant * (* get_action_state_hint) (GActionGroup *action_group, + const gchar *action_name); + + GVariant * (* get_action_state) (GActionGroup *action_group, + const gchar *action_name); + + void (* change_action_state) (GActionGroup *action_group, + const gchar *action_name, + GVariant *value); + + void (* activate_action) (GActionGroup *action_group, + const gchar *action_name, + GVariant *parameter); + + /* signals */ + void (* action_added) (GActionGroup *action_group, + const gchar *action_name); + void (* action_removed) (GActionGroup *action_group, + const gchar *action_name); + void (* action_enabled_changed) (GActionGroup *action_group, + const gchar *action_name, + gboolean enabled); + void (* action_state_changed) (GActionGroup *action_group, + const gchar *action_name, + GVariant *state); + + /* more virtual functions */ + gboolean (* query_action) (GActionGroup *action_group, + const gchar *action_name, + gboolean *enabled, + const GVariantType **parameter_type, + const GVariantType **state_type, + GVariant **state_hint, + GVariant **state); +}; + +GIO_AVAILABLE_IN_ALL +GType g_action_group_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gboolean g_action_group_has_action (GActionGroup *action_group, + const gchar *action_name); +GIO_AVAILABLE_IN_ALL +gchar ** g_action_group_list_actions (GActionGroup *action_group); + +GIO_AVAILABLE_IN_ALL +const GVariantType * g_action_group_get_action_parameter_type (GActionGroup *action_group, + const gchar *action_name); +GIO_AVAILABLE_IN_ALL +const GVariantType * g_action_group_get_action_state_type (GActionGroup *action_group, + const gchar *action_name); +GIO_AVAILABLE_IN_ALL +GVariant * g_action_group_get_action_state_hint (GActionGroup *action_group, + const gchar *action_name); + +GIO_AVAILABLE_IN_ALL +gboolean g_action_group_get_action_enabled (GActionGroup *action_group, + const gchar *action_name); + +GIO_AVAILABLE_IN_ALL +GVariant * g_action_group_get_action_state (GActionGroup *action_group, + const gchar *action_name); +GIO_AVAILABLE_IN_ALL +void g_action_group_change_action_state (GActionGroup *action_group, + const gchar *action_name, + GVariant *value); + +GIO_AVAILABLE_IN_ALL +void g_action_group_activate_action (GActionGroup *action_group, + const gchar *action_name, + GVariant *parameter); + +/* signals */ +GIO_AVAILABLE_IN_ALL +void g_action_group_action_added (GActionGroup *action_group, + const gchar *action_name); +GIO_AVAILABLE_IN_ALL +void g_action_group_action_removed (GActionGroup *action_group, + const gchar *action_name); +GIO_AVAILABLE_IN_ALL +void g_action_group_action_enabled_changed (GActionGroup *action_group, + const gchar *action_name, + gboolean enabled); + +GIO_AVAILABLE_IN_ALL +void g_action_group_action_state_changed (GActionGroup *action_group, + const gchar *action_name, + GVariant *state); + +GIO_AVAILABLE_IN_2_32 +gboolean g_action_group_query_action (GActionGroup *action_group, + const gchar *action_name, + gboolean *enabled, + const GVariantType **parameter_type, + const GVariantType **state_type, + GVariant **state_hint, + GVariant **state) G_GNUC_WARN_UNUSED_RESULT; + +G_END_DECLS + +#endif /* __G_ACTION_GROUP_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gactiongroupexporter.h b/illumos-x86_64/usr/include/glib-2.0/gio/gactiongroupexporter.h new file mode 100644 index 00000000..52f40af2 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gactiongroupexporter.h @@ -0,0 +1,47 @@ +/* + * Copyright © 2010 Codethink Limited + * Copyright © 2011 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + + +#ifndef __G_ACTION_GROUP_EXPORTER_H__ +#define __G_ACTION_GROUP_EXPORTER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GIO_AVAILABLE_IN_2_32 +guint g_dbus_connection_export_action_group (GDBusConnection *connection, + const gchar *object_path, + GActionGroup *action_group, + GError **error); + +GIO_AVAILABLE_IN_2_32 +void g_dbus_connection_unexport_action_group (GDBusConnection *connection, + guint export_id); + +G_END_DECLS + +#endif /* __G_ACTION_GROUP_EXPORTER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gactionmap.h b/illumos-x86_64/usr/include/glib-2.0/gio/gactionmap.h new file mode 100644 index 00000000..4d5a816b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gactionmap.h @@ -0,0 +1,101 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_ACTION_MAP_H__ +#define __G_ACTION_MAP_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + + +#define G_TYPE_ACTION_MAP (g_action_map_get_type ()) +#define G_ACTION_MAP(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_ACTION_MAP, GActionMap)) +#define G_IS_ACTION_MAP(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_ACTION_MAP)) +#define G_ACTION_MAP_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \ + G_TYPE_ACTION_MAP, GActionMapInterface)) + +typedef struct _GActionMapInterface GActionMapInterface; +typedef struct _GActionEntry GActionEntry; + +struct _GActionMapInterface +{ + GTypeInterface g_iface; + + GAction * (* lookup_action) (GActionMap *action_map, + const gchar *action_name); + void (* add_action) (GActionMap *action_map, + GAction *action); + void (* remove_action) (GActionMap *action_map, + const gchar *action_name); +}; + +struct _GActionEntry +{ + const gchar *name; + + void (* activate) (GSimpleAction *action, + GVariant *parameter, + gpointer user_data); + + const gchar *parameter_type; + + const gchar *state; + + void (* change_state) (GSimpleAction *action, + GVariant *value, + gpointer user_data); + + /*< private >*/ + gsize padding[3]; +}; + +GIO_AVAILABLE_IN_2_32 +GType g_action_map_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +GAction * g_action_map_lookup_action (GActionMap *action_map, + const gchar *action_name); +GIO_AVAILABLE_IN_2_32 +void g_action_map_add_action (GActionMap *action_map, + GAction *action); +GIO_AVAILABLE_IN_2_32 +void g_action_map_remove_action (GActionMap *action_map, + const gchar *action_name); +GIO_AVAILABLE_IN_2_32 +void g_action_map_add_action_entries (GActionMap *action_map, + const GActionEntry *entries, + gint n_entries, + gpointer user_data); +GIO_AVAILABLE_IN_2_78 +void g_action_map_remove_action_entries (GActionMap *action_map, + const GActionEntry *entries, + gint n_entries); + +G_END_DECLS + +#endif /* __G_ACTION_MAP_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gappinfo.h b/illumos-x86_64/usr/include/glib-2.0/gio/gappinfo.h new file mode 100644 index 00000000..f42ebddd --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gappinfo.h @@ -0,0 +1,377 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_APP_INFO_H__ +#define __G_APP_INFO_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_APP_INFO (g_app_info_get_type ()) +#define G_APP_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_APP_INFO, GAppInfo)) +#define G_IS_APP_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_APP_INFO)) +#define G_APP_INFO_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_APP_INFO, GAppInfoIface)) + +#define G_TYPE_APP_LAUNCH_CONTEXT (g_app_launch_context_get_type ()) +#define G_APP_LAUNCH_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_APP_LAUNCH_CONTEXT, GAppLaunchContext)) +#define G_APP_LAUNCH_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_APP_LAUNCH_CONTEXT, GAppLaunchContextClass)) +#define G_IS_APP_LAUNCH_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_APP_LAUNCH_CONTEXT)) +#define G_IS_APP_LAUNCH_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_APP_LAUNCH_CONTEXT)) +#define G_APP_LAUNCH_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_APP_LAUNCH_CONTEXT, GAppLaunchContextClass)) + +typedef struct _GAppLaunchContextClass GAppLaunchContextClass; +typedef struct _GAppLaunchContextPrivate GAppLaunchContextPrivate; + +/** + * GAppInfoIface: + * @g_iface: The parent interface. + * @dup: Copies a [iface@Gio.AppInfo]. + * @equal: Checks two [iface@Gio.AppInfo]s for equality. + * @get_id: Gets a string identifier for a [iface@Gio.AppInfo]. + * @get_name: Gets the name of the application for a [iface@Gio.AppInfo]. + * @get_description: Gets a short description for the application described by + * the [iface@Gio.AppInfo]. + * @get_executable: Gets the executable name for the [iface@Gio.AppInfo]. + * @get_icon: Gets the [iface@Gio.Icon] for the [iface@Gio.AppInfo]. + * @launch: Launches an application specified by the [iface@Gio.AppInfo]. + * @supports_uris: Indicates whether the application specified supports + * launching URIs. + * @supports_files: Indicates whether the application specified accepts + * filename arguments. + * @launch_uris: Launches an application with a list of URIs. + * @should_show: Returns whether an application should be shown (e.g. when + * getting a list of installed applications). + * [FreeDesktop.Org Startup Notification Specification](http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt). + * @set_as_default_for_type: Sets an application as default for a given content + * type. + * @set_as_default_for_extension: Sets an application as default for a given + * file extension. + * @add_supports_type: Adds to the [iface@Gio.AppInfo] information about + * supported file types. + * @can_remove_supports_type: Checks for support for removing supported file + * types from a [iface@Gio.AppInfo]. + * @remove_supports_type: Removes a supported application type from a + * [iface@Gio.AppInfo]. + * @can_delete: Checks if a [iface@Gio.AppInfo] can be deleted. (Since 2.20) + * @do_delete: Deletes a [iface@Gio.AppInfo]. (Since 2.20) + * @get_commandline: Gets the commandline for the [iface@Gio.AppInfo]. + * (Since 2.20) + * @get_display_name: Gets the display name for the [iface@Gio.AppInfo]. + * (Since 2.24) + * @set_as_last_used_for_type: Sets the application as the last used. See + * [method@Gio.AppInfo.set_as_last_used_for_type]. + * @get_supported_types: Retrieves the list of content types that @app_info + * claims to support. + * @launch_uris_async: Asynchronously launches an application with a list of + * URIs. (Since: 2.60) + * @launch_uris_finish: Finishes an operation started with @launch_uris_async. + * (Since: 2.60) + + * Application Information interface, for operating system portability. + */ +typedef struct _GAppInfoIface GAppInfoIface; + +struct _GAppInfoIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + GAppInfo * (* dup) (GAppInfo *appinfo); + gboolean (* equal) (GAppInfo *appinfo1, + GAppInfo *appinfo2); + const char * (* get_id) (GAppInfo *appinfo); + const char * (* get_name) (GAppInfo *appinfo); + const char * (* get_description) (GAppInfo *appinfo); + const char * (* get_executable) (GAppInfo *appinfo); + GIcon * (* get_icon) (GAppInfo *appinfo); + gboolean (* launch) (GAppInfo *appinfo, + GList *files, + GAppLaunchContext *context, + GError **error); + gboolean (* supports_uris) (GAppInfo *appinfo); + gboolean (* supports_files) (GAppInfo *appinfo); + gboolean (* launch_uris) (GAppInfo *appinfo, + GList *uris, + GAppLaunchContext *context, + GError **error); + gboolean (* should_show) (GAppInfo *appinfo); + + /* For changing associations */ + gboolean (* set_as_default_for_type) (GAppInfo *appinfo, + const char *content_type, + GError **error); + gboolean (* set_as_default_for_extension) (GAppInfo *appinfo, + const char *extension, + GError **error); + gboolean (* add_supports_type) (GAppInfo *appinfo, + const char *content_type, + GError **error); + gboolean (* can_remove_supports_type) (GAppInfo *appinfo); + gboolean (* remove_supports_type) (GAppInfo *appinfo, + const char *content_type, + GError **error); + gboolean (* can_delete) (GAppInfo *appinfo); + gboolean (* do_delete) (GAppInfo *appinfo); + const char * (* get_commandline) (GAppInfo *appinfo); + const char * (* get_display_name) (GAppInfo *appinfo); + gboolean (* set_as_last_used_for_type) (GAppInfo *appinfo, + const char *content_type, + GError **error); + const char ** (* get_supported_types) (GAppInfo *appinfo); + void (* launch_uris_async) (GAppInfo *appinfo, + GList *uris, + GAppLaunchContext *context, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* launch_uris_finish) (GAppInfo *appinfo, + GAsyncResult *result, + GError **error); +}; + +GIO_AVAILABLE_IN_ALL +GType g_app_info_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GAppInfo * g_app_info_create_from_commandline (const char *commandline, + const char *application_name, + GAppInfoCreateFlags flags, + GError **error); +GIO_AVAILABLE_IN_ALL +GAppInfo * g_app_info_dup (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_equal (GAppInfo *appinfo1, + GAppInfo *appinfo2); +GIO_AVAILABLE_IN_ALL +const char *g_app_info_get_id (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +const char *g_app_info_get_name (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +const char *g_app_info_get_display_name (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +const char *g_app_info_get_description (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +const char *g_app_info_get_executable (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +const char *g_app_info_get_commandline (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +GIcon * g_app_info_get_icon (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_launch (GAppInfo *appinfo, + GList *files, + GAppLaunchContext *context, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_supports_uris (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_supports_files (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_launch_uris (GAppInfo *appinfo, + GList *uris, + GAppLaunchContext *context, + GError **error); +GIO_AVAILABLE_IN_2_60 +void g_app_info_launch_uris_async (GAppInfo *appinfo, + GList *uris, + GAppLaunchContext *context, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_60 +gboolean g_app_info_launch_uris_finish (GAppInfo *appinfo, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_should_show (GAppInfo *appinfo); + +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo, + const char *content_type, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_set_as_default_for_extension (GAppInfo *appinfo, + const char *extension, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_add_supports_type (GAppInfo *appinfo, + const char *content_type, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_remove_supports_type (GAppInfo *appinfo, + const char *content_type, + GError **error); +GIO_AVAILABLE_IN_2_34 +const char **g_app_info_get_supported_types (GAppInfo *appinfo); + +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_can_delete (GAppInfo *appinfo); +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_delete (GAppInfo *appinfo); + +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_set_as_last_used_for_type (GAppInfo *appinfo, + const char *content_type, + GError **error); + +GIO_AVAILABLE_IN_ALL +GList * g_app_info_get_all (void); +GIO_AVAILABLE_IN_ALL +GList * g_app_info_get_all_for_type (const char *content_type); +GIO_AVAILABLE_IN_ALL +GList * g_app_info_get_recommended_for_type (const gchar *content_type); +GIO_AVAILABLE_IN_ALL +GList * g_app_info_get_fallback_for_type (const gchar *content_type); + +GIO_AVAILABLE_IN_ALL +void g_app_info_reset_type_associations (const char *content_type); +GIO_AVAILABLE_IN_ALL +GAppInfo *g_app_info_get_default_for_type (const char *content_type, + gboolean must_support_uris); +GIO_AVAILABLE_IN_2_74 +void g_app_info_get_default_for_type_async (const char *content_type, + gboolean must_support_uris, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_74 +GAppInfo *g_app_info_get_default_for_type_finish (GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +GAppInfo *g_app_info_get_default_for_uri_scheme (const char *uri_scheme); + +GIO_AVAILABLE_IN_2_74 +void g_app_info_get_default_for_uri_scheme_async (const char *uri_scheme, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_74 +GAppInfo *g_app_info_get_default_for_uri_scheme_finish (GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_app_info_launch_default_for_uri (const char *uri, + GAppLaunchContext *context, + GError **error); + +GIO_AVAILABLE_IN_2_50 +void g_app_info_launch_default_for_uri_async (const char *uri, + GAppLaunchContext *context, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_50 +gboolean g_app_info_launch_default_for_uri_finish (GAsyncResult *result, + GError **error); + + +/** + * GAppLaunchContext: + * + * Integrating the launch with the launching application. This is used to + * handle for instance startup notification and launching the new application + * on the same screen as the launching window. + */ +struct _GAppLaunchContext +{ + GObject parent_instance; + + /*< private >*/ + GAppLaunchContextPrivate *priv; +}; + +struct _GAppLaunchContextClass +{ + GObjectClass parent_class; + + char * (* get_display) (GAppLaunchContext *context, + GAppInfo *info, + GList *files); + char * (* get_startup_notify_id) (GAppLaunchContext *context, + GAppInfo *info, + GList *files); + void (* launch_failed) (GAppLaunchContext *context, + const char *startup_notify_id); + void (* launched) (GAppLaunchContext *context, + GAppInfo *info, + GVariant *platform_data); + void (* launch_started) (GAppLaunchContext *context, + GAppInfo *info, + GVariant *platform_data); + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_app_launch_context_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GAppLaunchContext *g_app_launch_context_new (void); + +GIO_AVAILABLE_IN_2_32 +void g_app_launch_context_setenv (GAppLaunchContext *context, + const char *variable, + const char *value); +GIO_AVAILABLE_IN_2_32 +void g_app_launch_context_unsetenv (GAppLaunchContext *context, + const char *variable); +GIO_AVAILABLE_IN_2_32 +char ** g_app_launch_context_get_environment (GAppLaunchContext *context); + +GIO_AVAILABLE_IN_ALL +char * g_app_launch_context_get_display (GAppLaunchContext *context, + GAppInfo *info, + GList *files); +GIO_AVAILABLE_IN_ALL +char * g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context, + GAppInfo *info, + GList *files); +GIO_AVAILABLE_IN_ALL +void g_app_launch_context_launch_failed (GAppLaunchContext *context, + const char * startup_notify_id); + +#define G_TYPE_APP_INFO_MONITOR (g_app_info_monitor_get_type ()) +#define G_APP_INFO_MONITOR(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_APP_INFO_MONITOR, GAppInfoMonitor)) +#define G_IS_APP_INFO_MONITOR(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_APP_INFO_MONITOR)) + +typedef struct _GAppInfoMonitor GAppInfoMonitor; + +GIO_AVAILABLE_IN_2_40 +GType g_app_info_monitor_get_type (void); + +GIO_AVAILABLE_IN_2_40 +GAppInfoMonitor * g_app_info_monitor_get (void); + +G_END_DECLS + +#endif /* __G_APP_INFO_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gapplication.h b/illumos-x86_64/usr/include/glib-2.0/gio/gapplication.h new file mode 100644 index 00000000..6df0bb4f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gapplication.h @@ -0,0 +1,263 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_APPLICATION_H__ +#define __G_APPLICATION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_APPLICATION (g_application_get_type ()) +#define G_APPLICATION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_APPLICATION, GApplication)) +#define G_APPLICATION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_APPLICATION, GApplicationClass)) +#define G_IS_APPLICATION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_APPLICATION)) +#define G_IS_APPLICATION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_APPLICATION)) +#define G_APPLICATION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_APPLICATION, GApplicationClass)) + +typedef struct _GApplicationPrivate GApplicationPrivate; +typedef struct _GApplicationClass GApplicationClass; + +struct _GApplication +{ + /*< private >*/ + GObject parent_instance; + + GApplicationPrivate *priv; +}; + +struct _GApplicationClass +{ + /*< private >*/ + GObjectClass parent_class; + + /*< public >*/ + /* signals */ + void (* startup) (GApplication *application); + + void (* activate) (GApplication *application); + + void (* open) (GApplication *application, + GFile **files, + gint n_files, + const gchar *hint); + + int (* command_line) (GApplication *application, + GApplicationCommandLine *command_line); + + /* vfuncs */ + + /** + * GApplicationClass::local_command_line: + * @application: a #GApplication + * @arguments: (inout) (array zero-terminated=1): array of command line arguments + * @exit_status: (out): exit status to fill after processing the command line. + * + * This virtual function is always invoked in the local instance. It + * gets passed a pointer to a %NULL-terminated copy of @argv and is + * expected to remove arguments that it handled (shifting up remaining + * arguments). + * + * The last argument to local_command_line() is a pointer to the @status + * variable which can used to set the exit status that is returned from + * g_application_run(). + * + * See g_application_run() for more details on #GApplication startup. + * + * Returns: %TRUE if the commandline has been completely handled + */ + gboolean (* local_command_line) (GApplication *application, + gchar ***arguments, + int *exit_status); + + /* @platform_data comes from an external process and is untrusted. All value types + * must be validated before being used. */ + void (* before_emit) (GApplication *application, + GVariant *platform_data); + /* Same as for @before_emit. */ + void (* after_emit) (GApplication *application, + GVariant *platform_data); + void (* add_platform_data) (GApplication *application, + GVariantBuilder *builder); + void (* quit_mainloop) (GApplication *application); + void (* run_mainloop) (GApplication *application); + void (* shutdown) (GApplication *application); + + gboolean (* dbus_register) (GApplication *application, + GDBusConnection *connection, + const gchar *object_path, + GError **error); + void (* dbus_unregister) (GApplication *application, + GDBusConnection *connection, + const gchar *object_path); + gint (* handle_local_options)(GApplication *application, + GVariantDict *options); + gboolean (* name_lost) (GApplication *application); + + /*< private >*/ + gpointer padding[7]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_application_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gboolean g_application_id_is_valid (const gchar *application_id); + +GIO_AVAILABLE_IN_ALL +GApplication * g_application_new (const gchar *application_id, + GApplicationFlags flags); + +GIO_AVAILABLE_IN_ALL +const gchar * g_application_get_application_id (GApplication *application); +GIO_AVAILABLE_IN_ALL +void g_application_set_application_id (GApplication *application, + const gchar *application_id); + +GIO_AVAILABLE_IN_2_80 +const gchar * g_application_get_version (GApplication *application); +GIO_AVAILABLE_IN_2_80 +void g_application_set_version (GApplication *application, + const gchar *version); + +GIO_AVAILABLE_IN_2_34 +GDBusConnection * g_application_get_dbus_connection (GApplication *application); +GIO_AVAILABLE_IN_2_34 +const gchar * g_application_get_dbus_object_path (GApplication *application); + +GIO_AVAILABLE_IN_ALL +guint g_application_get_inactivity_timeout (GApplication *application); +GIO_AVAILABLE_IN_ALL +void g_application_set_inactivity_timeout (GApplication *application, + guint inactivity_timeout); + +GIO_AVAILABLE_IN_ALL +GApplicationFlags g_application_get_flags (GApplication *application); +GIO_AVAILABLE_IN_ALL +void g_application_set_flags (GApplication *application, + GApplicationFlags flags); + +GIO_AVAILABLE_IN_2_42 +const gchar * g_application_get_resource_base_path (GApplication *application); +GIO_AVAILABLE_IN_2_42 +void g_application_set_resource_base_path (GApplication *application, + const gchar *resource_path); + +GIO_DEPRECATED +void g_application_set_action_group (GApplication *application, + GActionGroup *action_group); + +GIO_AVAILABLE_IN_2_40 +void g_application_add_main_option_entries (GApplication *application, + const GOptionEntry *entries); + +GIO_AVAILABLE_IN_2_42 +void g_application_add_main_option (GApplication *application, + const char *long_name, + char short_name, + GOptionFlags flags, + GOptionArg arg, + const char *description, + const char *arg_description); +GIO_AVAILABLE_IN_2_40 +void g_application_add_option_group (GApplication *application, + GOptionGroup *group); +GIO_AVAILABLE_IN_2_56 +void g_application_set_option_context_parameter_string (GApplication *application, + const gchar *parameter_string); +GIO_AVAILABLE_IN_2_56 +void g_application_set_option_context_summary (GApplication *application, + const gchar *summary); +GIO_AVAILABLE_IN_2_56 +void g_application_set_option_context_description (GApplication *application, + const gchar *description); +GIO_AVAILABLE_IN_ALL +gboolean g_application_get_is_registered (GApplication *application); +GIO_AVAILABLE_IN_ALL +gboolean g_application_get_is_remote (GApplication *application); + +GIO_AVAILABLE_IN_ALL +gboolean g_application_register (GApplication *application, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_application_hold (GApplication *application); +GIO_AVAILABLE_IN_ALL +void g_application_release (GApplication *application); + +GIO_AVAILABLE_IN_ALL +void g_application_activate (GApplication *application); + +GIO_AVAILABLE_IN_ALL +void g_application_open (GApplication *application, + GFile **files, + gint n_files, + const gchar *hint); + +GIO_AVAILABLE_IN_ALL +int g_application_run (GApplication *application, + int argc, + char **argv); + +GIO_AVAILABLE_IN_2_32 +void g_application_quit (GApplication *application); + +GIO_AVAILABLE_IN_2_32 +GApplication * g_application_get_default (void); +GIO_AVAILABLE_IN_2_32 +void g_application_set_default (GApplication *application); + +GIO_AVAILABLE_IN_2_38 +void g_application_mark_busy (GApplication *application); +GIO_AVAILABLE_IN_2_38 +void g_application_unmark_busy (GApplication *application); +GIO_AVAILABLE_IN_2_44 +gboolean g_application_get_is_busy (GApplication *application); + +GIO_AVAILABLE_IN_2_40 +void g_application_send_notification (GApplication *application, + const gchar *id, + GNotification *notification); +GIO_AVAILABLE_IN_2_40 +void g_application_withdraw_notification (GApplication *application, + const gchar *id); + +GIO_AVAILABLE_IN_2_44 +void g_application_bind_busy_property (GApplication *application, + gpointer object, + const gchar *property); + +GIO_AVAILABLE_IN_2_44 +void g_application_unbind_busy_property (GApplication *application, + gpointer object, + const gchar *property); + +G_END_DECLS + +#endif /* __G_APPLICATION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gapplicationcommandline.h b/illumos-x86_64/usr/include/glib-2.0/gio/gapplicationcommandline.h new file mode 100644 index 00000000..51133c4e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gapplicationcommandline.h @@ -0,0 +1,135 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_APPLICATION_COMMAND_LINE_H__ +#define __G_APPLICATION_COMMAND_LINE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_APPLICATION_COMMAND_LINE (g_application_command_line_get_type ()) +#define G_APPLICATION_COMMAND_LINE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_APPLICATION_COMMAND_LINE, \ + GApplicationCommandLine)) +#define G_APPLICATION_COMMAND_LINE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_APPLICATION_COMMAND_LINE, \ + GApplicationCommandLineClass)) +#define G_IS_APPLICATION_COMMAND_LINE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_APPLICATION_COMMAND_LINE)) +#define G_IS_APPLICATION_COMMAND_LINE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_APPLICATION_COMMAND_LINE)) +#define G_APPLICATION_COMMAND_LINE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_APPLICATION_COMMAND_LINE, \ + GApplicationCommandLineClass)) + +typedef struct _GApplicationCommandLinePrivate GApplicationCommandLinePrivate; +typedef struct _GApplicationCommandLineClass GApplicationCommandLineClass; + +struct _GApplicationCommandLine +{ + /*< private >*/ + GObject parent_instance; + + GApplicationCommandLinePrivate *priv; +}; + +struct _GApplicationCommandLineClass +{ + /*< private >*/ + GObjectClass parent_class; + + void (* print_literal) (GApplicationCommandLine *cmdline, + const gchar *message); + void (* printerr_literal) (GApplicationCommandLine *cmdline, + const gchar *message); + GInputStream * (* get_stdin) (GApplicationCommandLine *cmdline); + void (* done) (GApplicationCommandLine *cmdline); + + gpointer padding[10]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_application_command_line_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gchar ** g_application_command_line_get_arguments (GApplicationCommandLine *cmdline, + int *argc); + +GIO_AVAILABLE_IN_2_40 +GVariantDict * g_application_command_line_get_options_dict (GApplicationCommandLine *cmdline); + +GIO_AVAILABLE_IN_2_36 +GInputStream * g_application_command_line_get_stdin (GApplicationCommandLine *cmdline); + +GIO_AVAILABLE_IN_ALL +const gchar * const * g_application_command_line_get_environ (GApplicationCommandLine *cmdline); + +GIO_AVAILABLE_IN_ALL +const gchar * g_application_command_line_getenv (GApplicationCommandLine *cmdline, + const gchar *name); + +GIO_AVAILABLE_IN_ALL +const gchar * g_application_command_line_get_cwd (GApplicationCommandLine *cmdline); + +GIO_AVAILABLE_IN_ALL +gboolean g_application_command_line_get_is_remote (GApplicationCommandLine *cmdline); + +GIO_AVAILABLE_IN_2_80 +void g_application_command_line_print_literal (GApplicationCommandLine *cmdline, + const gchar *message); +GIO_AVAILABLE_IN_2_80 +void g_application_command_line_printerr_literal (GApplicationCommandLine *cmdline, + const gchar *message); + +GIO_AVAILABLE_IN_ALL +void g_application_command_line_print (GApplicationCommandLine *cmdline, + const gchar *format, + ...) G_GNUC_PRINTF(2, 3); +GIO_AVAILABLE_IN_ALL +void g_application_command_line_printerr (GApplicationCommandLine *cmdline, + const gchar *format, + ...) G_GNUC_PRINTF(2, 3); + +GIO_AVAILABLE_IN_ALL +int g_application_command_line_get_exit_status (GApplicationCommandLine *cmdline); +GIO_AVAILABLE_IN_ALL +void g_application_command_line_set_exit_status (GApplicationCommandLine *cmdline, + int exit_status); + +GIO_AVAILABLE_IN_ALL +GVariant * g_application_command_line_get_platform_data (GApplicationCommandLine *cmdline); + +GIO_AVAILABLE_IN_2_36 +GFile * g_application_command_line_create_file_for_arg (GApplicationCommandLine *cmdline, + const gchar *arg); + +GIO_AVAILABLE_IN_2_80 +void g_application_command_line_done (GApplicationCommandLine *cmdline); + +G_END_DECLS + +#endif /* __G_APPLICATION_COMMAND_LINE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gasyncinitable.h b/illumos-x86_64/usr/include/glib-2.0/gio/gasyncinitable.h new file mode 100644 index 00000000..eb9b026f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gasyncinitable.h @@ -0,0 +1,125 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_ASYNC_INITABLE_H__ +#define __G_ASYNC_INITABLE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_ASYNC_INITABLE (g_async_initable_get_type ()) +#define G_ASYNC_INITABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ASYNC_INITABLE, GAsyncInitable)) +#define G_IS_ASYNC_INITABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ASYNC_INITABLE)) +#define G_ASYNC_INITABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ASYNC_INITABLE, GAsyncInitableIface)) +#define G_TYPE_IS_ASYNC_INITABLE(type) (g_type_is_a ((type), G_TYPE_ASYNC_INITABLE)) + +typedef struct _GAsyncInitableIface GAsyncInitableIface; + +/** + * GAsyncInitableIface: + * @g_iface: The parent interface. + * @init_async: Starts initialization of the object. + * @init_finish: Finishes initialization of the object. + * + * Provides an interface for asynchronous initializing object such that + * initialization may fail. + * + * Since: 2.22 + **/ +struct _GAsyncInitableIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + void (* init_async) (GAsyncInitable *initable, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* init_finish) (GAsyncInitable *initable, + GAsyncResult *res, + GError **error); +}; + +GIO_AVAILABLE_IN_ALL +GType g_async_initable_get_type (void) G_GNUC_CONST; + + +GIO_AVAILABLE_IN_ALL +void g_async_initable_init_async (GAsyncInitable *initable, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_async_initable_init_finish (GAsyncInitable *initable, + GAsyncResult *res, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_async_initable_new_async (GType object_type, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data, + const gchar *first_property_name, + ...); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +GIO_DEPRECATED_IN_2_54_FOR(g_object_new_with_properties and g_async_initable_init_async) +void g_async_initable_newv_async (GType object_type, + guint n_parameters, + GParameter *parameters, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +G_GNUC_END_IGNORE_DEPRECATIONS + +GIO_AVAILABLE_IN_ALL +void g_async_initable_new_valist_async (GType object_type, + const gchar *first_property_name, + va_list var_args, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GObject *g_async_initable_new_finish (GAsyncInitable *initable, + GAsyncResult *res, + GError **error); + + + +G_END_DECLS + + +#endif /* __G_ASYNC_INITABLE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gasyncresult.h b/illumos-x86_64/usr/include/glib-2.0/gio/gasyncresult.h new file mode 100644 index 00000000..8e96011a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gasyncresult.h @@ -0,0 +1,81 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_ASYNC_RESULT_H__ +#define __G_ASYNC_RESULT_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_ASYNC_RESULT (g_async_result_get_type ()) +#define G_ASYNC_RESULT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ASYNC_RESULT, GAsyncResult)) +#define G_IS_ASYNC_RESULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ASYNC_RESULT)) +#define G_ASYNC_RESULT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ASYNC_RESULT, GAsyncResultIface)) + +typedef struct _GAsyncResultIface GAsyncResultIface; + + +/** + * GAsyncResultIface: + * @g_iface: The parent interface. + * @get_user_data: Gets the user data passed to the callback. + * @get_source_object: Gets the source object that issued the asynchronous operation. + * @is_tagged: Checks if a result is tagged with a particular source. + * + * Interface definition for [iface@Gio.AsyncResult]. + **/ +struct _GAsyncResultIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + gpointer (* get_user_data) (GAsyncResult *res); + GObject * (* get_source_object) (GAsyncResult *res); + + gboolean (* is_tagged) (GAsyncResult *res, + gpointer source_tag); +}; + +GIO_AVAILABLE_IN_ALL +GType g_async_result_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gpointer g_async_result_get_user_data (GAsyncResult *res); +GIO_AVAILABLE_IN_ALL +GObject *g_async_result_get_source_object (GAsyncResult *res); + +GIO_AVAILABLE_IN_2_34 +gboolean g_async_result_legacy_propagate_error (GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_2_34 +gboolean g_async_result_is_tagged (GAsyncResult *res, + gpointer source_tag); + +G_END_DECLS + +#endif /* __G_ASYNC_RESULT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gbufferedinputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gbufferedinputstream.h new file mode 100644 index 00000000..eced51f5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gbufferedinputstream.h @@ -0,0 +1,130 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Christian Kellner + */ + +#ifndef __G_BUFFERED_INPUT_STREAM_H__ +#define __G_BUFFERED_INPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_BUFFERED_INPUT_STREAM (g_buffered_input_stream_get_type ()) +#define G_BUFFERED_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStream)) +#define G_BUFFERED_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStreamClass)) +#define G_IS_BUFFERED_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_BUFFERED_INPUT_STREAM)) +#define G_IS_BUFFERED_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_BUFFERED_INPUT_STREAM)) +#define G_BUFFERED_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStreamClass)) + +typedef struct _GBufferedInputStreamClass GBufferedInputStreamClass; +typedef struct _GBufferedInputStreamPrivate GBufferedInputStreamPrivate; + +struct _GBufferedInputStream +{ + GFilterInputStream parent_instance; + + /*< private >*/ + GBufferedInputStreamPrivate *priv; +}; + +struct _GBufferedInputStreamClass +{ + GFilterInputStreamClass parent_class; + + gssize (* fill) (GBufferedInputStream *stream, + gssize count, + GCancellable *cancellable, + GError **error); + + /* Async ops: (optional in derived classes) */ + void (* fill_async) (GBufferedInputStream *stream, + gssize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gssize (* fill_finish) (GBufferedInputStream *stream, + GAsyncResult *result, + GError **error); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + + +GIO_AVAILABLE_IN_ALL +GType g_buffered_input_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GInputStream* g_buffered_input_stream_new (GInputStream *base_stream); +GIO_AVAILABLE_IN_ALL +GInputStream* g_buffered_input_stream_new_sized (GInputStream *base_stream, + gsize size); + +GIO_AVAILABLE_IN_ALL +gsize g_buffered_input_stream_get_buffer_size (GBufferedInputStream *stream); +GIO_AVAILABLE_IN_ALL +void g_buffered_input_stream_set_buffer_size (GBufferedInputStream *stream, + gsize size); +GIO_AVAILABLE_IN_ALL +gsize g_buffered_input_stream_get_available (GBufferedInputStream *stream); +GIO_AVAILABLE_IN_ALL +gsize g_buffered_input_stream_peek (GBufferedInputStream *stream, + void *buffer, + gsize offset, + gsize count); +GIO_AVAILABLE_IN_ALL +const void* g_buffered_input_stream_peek_buffer (GBufferedInputStream *stream, + gsize *count); + +GIO_AVAILABLE_IN_ALL +gssize g_buffered_input_stream_fill (GBufferedInputStream *stream, + gssize count, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_buffered_input_stream_fill_async (GBufferedInputStream *stream, + gssize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gssize g_buffered_input_stream_fill_finish (GBufferedInputStream *stream, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +int g_buffered_input_stream_read_byte (GBufferedInputStream *stream, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* __G_BUFFERED_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gbufferedoutputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gbufferedoutputstream.h new file mode 100644 index 00000000..339b916f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gbufferedoutputstream.h @@ -0,0 +1,83 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Christian Kellner + */ + +#ifndef __G_BUFFERED_OUTPUT_STREAM_H__ +#define __G_BUFFERED_OUTPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_BUFFERED_OUTPUT_STREAM (g_buffered_output_stream_get_type ()) +#define G_BUFFERED_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_BUFFERED_OUTPUT_STREAM, GBufferedOutputStream)) +#define G_BUFFERED_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_BUFFERED_OUTPUT_STREAM, GBufferedOutputStreamClass)) +#define G_IS_BUFFERED_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_BUFFERED_OUTPUT_STREAM)) +#define G_IS_BUFFERED_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_BUFFERED_OUTPUT_STREAM)) +#define G_BUFFERED_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_BUFFERED_OUTPUT_STREAM, GBufferedOutputStreamClass)) + +typedef struct _GBufferedOutputStreamClass GBufferedOutputStreamClass; +typedef struct _GBufferedOutputStreamPrivate GBufferedOutputStreamPrivate; + +struct _GBufferedOutputStream +{ + GFilterOutputStream parent_instance; + + /*< protected >*/ + GBufferedOutputStreamPrivate *priv; +}; + +struct _GBufferedOutputStreamClass +{ + GFilterOutputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); +}; + + +GIO_AVAILABLE_IN_ALL +GType g_buffered_output_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GOutputStream* g_buffered_output_stream_new (GOutputStream *base_stream); +GIO_AVAILABLE_IN_ALL +GOutputStream* g_buffered_output_stream_new_sized (GOutputStream *base_stream, + gsize size); +GIO_AVAILABLE_IN_ALL +gsize g_buffered_output_stream_get_buffer_size (GBufferedOutputStream *stream); +GIO_AVAILABLE_IN_ALL +void g_buffered_output_stream_set_buffer_size (GBufferedOutputStream *stream, + gsize size); +GIO_AVAILABLE_IN_ALL +gboolean g_buffered_output_stream_get_auto_grow (GBufferedOutputStream *stream); +GIO_AVAILABLE_IN_ALL +void g_buffered_output_stream_set_auto_grow (GBufferedOutputStream *stream, + gboolean auto_grow); + +G_END_DECLS + +#endif /* __G_BUFFERED_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gbytesicon.h b/illumos-x86_64/usr/include/glib-2.0/gio/gbytesicon.h new file mode 100644 index 00000000..1d5ccd72 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gbytesicon.h @@ -0,0 +1,49 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_BYTES_ICON_H__ +#define __G_BYTES_ICON_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_BYTES_ICON (g_bytes_icon_get_type ()) +#define G_BYTES_ICON(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_BYTES_ICON, GBytesIcon)) +#define G_IS_BYTES_ICON(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_BYTES_ICON)) + +GIO_AVAILABLE_IN_2_38 +GType g_bytes_icon_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_38 +GIcon * g_bytes_icon_new (GBytes *bytes); + +GIO_AVAILABLE_IN_2_38 +GBytes * g_bytes_icon_get_bytes (GBytesIcon *icon); + +G_END_DECLS + +#endif /* __G_BYTES_ICON_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gcancellable.h b/illumos-x86_64/usr/include/glib-2.0/gio/gcancellable.h new file mode 100644 index 00000000..6a76b590 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gcancellable.h @@ -0,0 +1,115 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_CANCELLABLE_H__ +#define __G_CANCELLABLE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_CANCELLABLE (g_cancellable_get_type ()) +#define G_CANCELLABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_CANCELLABLE, GCancellable)) +#define G_CANCELLABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_CANCELLABLE, GCancellableClass)) +#define G_IS_CANCELLABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_CANCELLABLE)) +#define G_IS_CANCELLABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_CANCELLABLE)) +#define G_CANCELLABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_CANCELLABLE, GCancellableClass)) + +typedef struct _GCancellableClass GCancellableClass; +typedef struct _GCancellablePrivate GCancellablePrivate; + +struct _GCancellable +{ + GObject parent_instance; + + /*< private >*/ + GCancellablePrivate *priv; +}; + +struct _GCancellableClass +{ + GObjectClass parent_class; + + void (* cancelled) (GCancellable *cancellable); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_cancellable_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GCancellable *g_cancellable_new (void); + +/* These are only safe to call inside a cancellable op */ +GIO_AVAILABLE_IN_ALL +gboolean g_cancellable_is_cancelled (GCancellable *cancellable); +GIO_AVAILABLE_IN_ALL +gboolean g_cancellable_set_error_if_cancelled (GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +int g_cancellable_get_fd (GCancellable *cancellable); +GIO_AVAILABLE_IN_ALL +gboolean g_cancellable_make_pollfd (GCancellable *cancellable, + GPollFD *pollfd); +GIO_AVAILABLE_IN_ALL +void g_cancellable_release_fd (GCancellable *cancellable); + +GIO_AVAILABLE_IN_ALL +GSource * g_cancellable_source_new (GCancellable *cancellable); + +GIO_AVAILABLE_IN_ALL +GCancellable *g_cancellable_get_current (void); +GIO_AVAILABLE_IN_ALL +void g_cancellable_push_current (GCancellable *cancellable); +GIO_AVAILABLE_IN_ALL +void g_cancellable_pop_current (GCancellable *cancellable); +GIO_AVAILABLE_IN_ALL +void g_cancellable_reset (GCancellable *cancellable); +GIO_AVAILABLE_IN_ALL +gulong g_cancellable_connect (GCancellable *cancellable, + GCallback callback, + gpointer data, + GDestroyNotify data_destroy_func); +GIO_AVAILABLE_IN_ALL +void g_cancellable_disconnect (GCancellable *cancellable, + gulong handler_id); + + +/* This is safe to call from another thread */ +GIO_AVAILABLE_IN_ALL +void g_cancellable_cancel (GCancellable *cancellable); + +G_END_DECLS + +#endif /* __G_CANCELLABLE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gcharsetconverter.h b/illumos-x86_64/usr/include/glib-2.0/gio/gcharsetconverter.h new file mode 100644 index 00000000..455ca7cb --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gcharsetconverter.h @@ -0,0 +1,65 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_CHARSET_CONVERTER_H__ +#define __G_CHARSET_CONVERTER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_CHARSET_CONVERTER (g_charset_converter_get_type ()) +#define G_CHARSET_CONVERTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_CHARSET_CONVERTER, GCharsetConverter)) +#define G_CHARSET_CONVERTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_CHARSET_CONVERTER, GCharsetConverterClass)) +#define G_IS_CHARSET_CONVERTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_CHARSET_CONVERTER)) +#define G_IS_CHARSET_CONVERTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_CHARSET_CONVERTER)) +#define G_CHARSET_CONVERTER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_CHARSET_CONVERTER, GCharsetConverterClass)) + +typedef struct _GCharsetConverterClass GCharsetConverterClass; + +struct _GCharsetConverterClass +{ + GObjectClass parent_class; +}; + +GIO_AVAILABLE_IN_ALL +GType g_charset_converter_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GCharsetConverter *g_charset_converter_new (const gchar *to_charset, + const gchar *from_charset, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_charset_converter_set_use_fallback (GCharsetConverter *converter, + gboolean use_fallback); +GIO_AVAILABLE_IN_ALL +gboolean g_charset_converter_get_use_fallback (GCharsetConverter *converter); +GIO_AVAILABLE_IN_ALL +guint g_charset_converter_get_num_fallbacks (GCharsetConverter *converter); + +G_END_DECLS + +#endif /* __G_CHARSET_CONVERTER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gcontenttype.h b/illumos-x86_64/usr/include/glib-2.0/gio/gcontenttype.h new file mode 100644 index 00000000..910c2e24 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gcontenttype.h @@ -0,0 +1,84 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_CONTENT_TYPE_H__ +#define __G_CONTENT_TYPE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GIO_AVAILABLE_IN_ALL +gboolean g_content_type_equals (const gchar *type1, + const gchar *type2); +GIO_AVAILABLE_IN_ALL +gboolean g_content_type_is_a (const gchar *type, + const gchar *supertype); +GIO_AVAILABLE_IN_2_52 +gboolean g_content_type_is_mime_type (const gchar *type, + const gchar *mime_type); +GIO_AVAILABLE_IN_ALL +gboolean g_content_type_is_unknown (const gchar *type); +GIO_AVAILABLE_IN_ALL +gchar * g_content_type_get_description (const gchar *type); +GIO_AVAILABLE_IN_ALL +gchar * g_content_type_get_mime_type (const gchar *type); +GIO_AVAILABLE_IN_ALL +GIcon * g_content_type_get_icon (const gchar *type); +GIO_AVAILABLE_IN_2_34 +GIcon * g_content_type_get_symbolic_icon (const gchar *type); +GIO_AVAILABLE_IN_2_34 +gchar * g_content_type_get_generic_icon_name (const gchar *type); + +GIO_AVAILABLE_IN_ALL +gboolean g_content_type_can_be_executable (const gchar *type); + +GIO_AVAILABLE_IN_ALL +gchar * g_content_type_from_mime_type (const gchar *mime_type); + +GIO_AVAILABLE_IN_ALL +gchar * g_content_type_guess (const gchar *filename, + const guchar *data, + gsize data_size, + gboolean *result_uncertain); + +GIO_AVAILABLE_IN_ALL +gchar ** g_content_type_guess_for_tree (GFile *root); + +GIO_AVAILABLE_IN_ALL +GList * g_content_types_get_registered (void); + +/*< private >*/ +#ifndef __GTK_DOC_IGNORE__ +GIO_AVAILABLE_IN_2_60 +const gchar * const *g_content_type_get_mime_dirs (void); +GIO_AVAILABLE_IN_2_60 +void g_content_type_set_mime_dirs (const gchar * const *dirs); +#endif /* __GTK_DOC_IGNORE__ */ + +G_END_DECLS + +#endif /* __G_CONTENT_TYPE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gconverter.h b/illumos-x86_64/usr/include/glib-2.0/gio/gconverter.h new file mode 100644 index 00000000..2ec9440d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gconverter.h @@ -0,0 +1,96 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_CONVERTER_H__ +#define __G_CONVERTER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_CONVERTER (g_converter_get_type ()) +#define G_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_CONVERTER, GConverter)) +#define G_IS_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_CONVERTER)) +#define G_CONVERTER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_CONVERTER, GConverterIface)) + +typedef struct _GConverterIface GConverterIface; + +/** + * GConverterIface: + * @g_iface: The parent interface. + * @convert: Converts data. + * @reset: Reverts the internal state of the converter to its initial state. + * + * Provides an interface for converting data from one type + * to another type. The conversion can be stateful + * and may fail at any place. + * + * Since: 2.24 + **/ +struct _GConverterIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + GConverterResult (* convert) (GConverter *converter, + const void *inbuf, + gsize inbuf_size, + void *outbuf, + gsize outbuf_size, + GConverterFlags flags, + gsize *bytes_read, + gsize *bytes_written, + GError **error); + void (* reset) (GConverter *converter); +}; + +GIO_AVAILABLE_IN_ALL +GType g_converter_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GConverterResult g_converter_convert (GConverter *converter, + const void *inbuf, + gsize inbuf_size, + void *outbuf, + gsize outbuf_size, + GConverterFlags flags, + gsize *bytes_read, + gsize *bytes_written, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_converter_reset (GConverter *converter); + +GIO_AVAILABLE_IN_2_82 +GBytes * g_converter_convert_bytes (GConverter *converter, + GBytes *bytes, + GError **error); + + +G_END_DECLS + + +#endif /* __G_CONVERTER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gconverterinputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gconverterinputstream.h new file mode 100644 index 00000000..96f4dc07 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gconverterinputstream.h @@ -0,0 +1,76 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_CONVERTER_INPUT_STREAM_H__ +#define __G_CONVERTER_INPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_CONVERTER_INPUT_STREAM (g_converter_input_stream_get_type ()) +#define G_CONVERTER_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_CONVERTER_INPUT_STREAM, GConverterInputStream)) +#define G_CONVERTER_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_CONVERTER_INPUT_STREAM, GConverterInputStreamClass)) +#define G_IS_CONVERTER_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_CONVERTER_INPUT_STREAM)) +#define G_IS_CONVERTER_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_CONVERTER_INPUT_STREAM)) +#define G_CONVERTER_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_CONVERTER_INPUT_STREAM, GConverterInputStreamClass)) + +typedef struct _GConverterInputStreamClass GConverterInputStreamClass; +typedef struct _GConverterInputStreamPrivate GConverterInputStreamPrivate; + +struct _GConverterInputStream +{ + GFilterInputStream parent_instance; + + /*< private >*/ + GConverterInputStreamPrivate *priv; +}; + +struct _GConverterInputStreamClass +{ + GFilterInputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_converter_input_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GInputStream *g_converter_input_stream_new (GInputStream *base_stream, + GConverter *converter); +GIO_AVAILABLE_IN_ALL +GConverter *g_converter_input_stream_get_converter (GConverterInputStream *converter_stream); + +G_END_DECLS + +#endif /* __G_CONVERTER_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gconverteroutputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gconverteroutputstream.h new file mode 100644 index 00000000..e184500b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gconverteroutputstream.h @@ -0,0 +1,76 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_CONVERTER_OUTPUT_STREAM_H__ +#define __G_CONVERTER_OUTPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_CONVERTER_OUTPUT_STREAM (g_converter_output_stream_get_type ()) +#define G_CONVERTER_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_CONVERTER_OUTPUT_STREAM, GConverterOutputStream)) +#define G_CONVERTER_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_CONVERTER_OUTPUT_STREAM, GConverterOutputStreamClass)) +#define G_IS_CONVERTER_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_CONVERTER_OUTPUT_STREAM)) +#define G_IS_CONVERTER_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_CONVERTER_OUTPUT_STREAM)) +#define G_CONVERTER_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_CONVERTER_OUTPUT_STREAM, GConverterOutputStreamClass)) + +typedef struct _GConverterOutputStreamClass GConverterOutputStreamClass; +typedef struct _GConverterOutputStreamPrivate GConverterOutputStreamPrivate; + +struct _GConverterOutputStream +{ + GFilterOutputStream parent_instance; + + /*< private >*/ + GConverterOutputStreamPrivate *priv; +}; + +struct _GConverterOutputStreamClass +{ + GFilterOutputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_converter_output_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GOutputStream *g_converter_output_stream_new (GOutputStream *base_stream, + GConverter *converter); +GIO_AVAILABLE_IN_ALL +GConverter *g_converter_output_stream_get_converter (GConverterOutputStream *converter_stream); + +G_END_DECLS + +#endif /* __G_CONVERTER_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gcredentials.h b/illumos-x86_64/usr/include/glib-2.0/gio/gcredentials.h new file mode 100644 index 00000000..c30f31fc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gcredentials.h @@ -0,0 +1,87 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_CREDENTIALS_H__ +#define __G_CREDENTIALS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#ifdef G_OS_UNIX +/* To get the uid_t type */ +#include +#include +#endif + +G_BEGIN_DECLS + +#define G_TYPE_CREDENTIALS (g_credentials_get_type ()) +#define G_CREDENTIALS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_CREDENTIALS, GCredentials)) +#define G_CREDENTIALS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_CREDENTIALS, GCredentialsClass)) +#define G_CREDENTIALS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_CREDENTIALS, GCredentialsClass)) +#define G_IS_CREDENTIALS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_CREDENTIALS)) +#define G_IS_CREDENTIALS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_CREDENTIALS)) + +typedef struct _GCredentialsClass GCredentialsClass; + +GIO_AVAILABLE_IN_ALL +GType g_credentials_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GCredentials *g_credentials_new (void); + +GIO_AVAILABLE_IN_ALL +gchar *g_credentials_to_string (GCredentials *credentials); + +GIO_AVAILABLE_IN_ALL +gpointer g_credentials_get_native (GCredentials *credentials, + GCredentialsType native_type); + +GIO_AVAILABLE_IN_ALL +void g_credentials_set_native (GCredentials *credentials, + GCredentialsType native_type, + gpointer native); + +GIO_AVAILABLE_IN_ALL +gboolean g_credentials_is_same_user (GCredentials *credentials, + GCredentials *other_credentials, + GError **error); + +#ifdef G_OS_UNIX +GIO_AVAILABLE_IN_2_36 +pid_t g_credentials_get_unix_pid (GCredentials *credentials, + GError **error); +GIO_AVAILABLE_IN_ALL +uid_t g_credentials_get_unix_user (GCredentials *credentials, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_credentials_set_unix_user (GCredentials *credentials, + uid_t uid, + GError **error); +#endif + +G_END_DECLS + +#endif /* __G_CREDENTIALS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdatagrambased.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdatagrambased.h new file mode 100644 index 00000000..aa2a1f22 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdatagrambased.h @@ -0,0 +1,139 @@ +/* + * Copyright 2015 Collabora Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Philip Withnall + */ + +#ifndef __G_DATAGRAM_BASED_H__ +#define __G_DATAGRAM_BASED_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DATAGRAM_BASED (g_datagram_based_get_type ()) +#define G_DATAGRAM_BASED(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_DATAGRAM_BASED, GDatagramBased)) +#define G_IS_DATAGRAM_BASED(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_DATAGRAM_BASED)) +#define G_DATAGRAM_BASED_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \ + G_TYPE_DATAGRAM_BASED, \ + GDatagramBasedInterface)) +#define G_TYPE_IS_DATAGRAM_BASED(type) (g_type_is_a ((type), \ + G_TYPE_DATAGRAM_BASED)) + +typedef struct _GDatagramBasedInterface GDatagramBasedInterface; + +/** + * GDatagramBasedInterface: + * @g_iface: The parent interface. + * @receive_messages: Virtual method for g_datagram_based_receive_messages(). + * @send_messages: Virtual method for g_datagram_based_send_messages(). + * @create_source: Virtual method for g_datagram_based_create_source(). + * @condition_check: Virtual method for g_datagram_based_condition_check(). + * @condition_wait: Virtual method for + * g_datagram_based_condition_wait(). + * + * Provides an interface for socket-like objects which have datagram semantics, + * following the Berkeley sockets API. The interface methods are thin wrappers + * around the corresponding virtual methods, and no pre-processing of inputs is + * implemented — so implementations of this API must handle all functionality + * documented in the interface methods. + * + * Since: 2.48 + */ +struct _GDatagramBasedInterface +{ + GTypeInterface g_iface; + + /* Virtual table */ + gint (*receive_messages) (GDatagramBased *datagram_based, + GInputMessage *messages, + guint num_messages, + gint flags, + gint64 timeout, + GCancellable *cancellable, + GError **error); + gint (*send_messages) (GDatagramBased *datagram_based, + GOutputMessage *messages, + guint num_messages, + gint flags, + gint64 timeout, + GCancellable *cancellable, + GError **error); + + GSource *(*create_source) (GDatagramBased *datagram_based, + GIOCondition condition, + GCancellable *cancellable); + GIOCondition (*condition_check) (GDatagramBased *datagram_based, + GIOCondition condition); + gboolean (*condition_wait) (GDatagramBased *datagram_based, + GIOCondition condition, + gint64 timeout, + GCancellable *cancellable, + GError **error); +}; + +GIO_AVAILABLE_IN_2_48 +GType +g_datagram_based_get_type (void); + +GIO_AVAILABLE_IN_2_48 +gint +g_datagram_based_receive_messages (GDatagramBased *datagram_based, + GInputMessage *messages, + guint num_messages, + gint flags, + gint64 timeout, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_48 +gint +g_datagram_based_send_messages (GDatagramBased *datagram_based, + GOutputMessage *messages, + guint num_messages, + gint flags, + gint64 timeout, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_48 +GSource * +g_datagram_based_create_source (GDatagramBased *datagram_based, + GIOCondition condition, + GCancellable *cancellable); +GIO_AVAILABLE_IN_2_48 +GIOCondition +g_datagram_based_condition_check (GDatagramBased *datagram_based, + GIOCondition condition); +GIO_AVAILABLE_IN_2_48 +gboolean +g_datagram_based_condition_wait (GDatagramBased *datagram_based, + GIOCondition condition, + gint64 timeout, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* __G_DATAGRAM_BASED_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdatainputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdatainputstream.h new file mode 100644 index 00000000..2e14a551 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdatainputstream.h @@ -0,0 +1,176 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_DATA_INPUT_STREAM_H__ +#define __G_DATA_INPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DATA_INPUT_STREAM (g_data_input_stream_get_type ()) +#define G_DATA_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DATA_INPUT_STREAM, GDataInputStream)) +#define G_DATA_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DATA_INPUT_STREAM, GDataInputStreamClass)) +#define G_IS_DATA_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DATA_INPUT_STREAM)) +#define G_IS_DATA_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DATA_INPUT_STREAM)) +#define G_DATA_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DATA_INPUT_STREAM, GDataInputStreamClass)) + +typedef struct _GDataInputStreamClass GDataInputStreamClass; +typedef struct _GDataInputStreamPrivate GDataInputStreamPrivate; + +struct _GDataInputStream +{ + GBufferedInputStream parent_instance; + + /*< private >*/ + GDataInputStreamPrivate *priv; +}; + +struct _GDataInputStreamClass +{ + GBufferedInputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_data_input_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDataInputStream * g_data_input_stream_new (GInputStream *base_stream); + +GIO_AVAILABLE_IN_ALL +void g_data_input_stream_set_byte_order (GDataInputStream *stream, + GDataStreamByteOrder order); +GIO_AVAILABLE_IN_ALL +GDataStreamByteOrder g_data_input_stream_get_byte_order (GDataInputStream *stream); +GIO_AVAILABLE_IN_ALL +void g_data_input_stream_set_newline_type (GDataInputStream *stream, + GDataStreamNewlineType type); +GIO_AVAILABLE_IN_ALL +GDataStreamNewlineType g_data_input_stream_get_newline_type (GDataInputStream *stream); +GIO_AVAILABLE_IN_ALL +guchar g_data_input_stream_read_byte (GDataInputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gint16 g_data_input_stream_read_int16 (GDataInputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +guint16 g_data_input_stream_read_uint16 (GDataInputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gint32 g_data_input_stream_read_int32 (GDataInputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +guint32 g_data_input_stream_read_uint32 (GDataInputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gint64 g_data_input_stream_read_int64 (GDataInputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +guint64 g_data_input_stream_read_uint64 (GDataInputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +char * g_data_input_stream_read_line (GDataInputStream *stream, + gsize *length, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_30 +char * g_data_input_stream_read_line_utf8 (GDataInputStream *stream, + gsize *length, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_data_input_stream_read_line_async (GDataInputStream *stream, + gint io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +char * g_data_input_stream_read_line_finish (GDataInputStream *stream, + GAsyncResult *result, + gsize *length, + GError **error); +GIO_AVAILABLE_IN_2_30 +char * g_data_input_stream_read_line_finish_utf8(GDataInputStream *stream, + GAsyncResult *result, + gsize *length, + GError **error); +GIO_DEPRECATED_IN_2_56_FOR (g_data_input_stream_read_upto) +char * g_data_input_stream_read_until (GDataInputStream *stream, + const gchar *stop_chars, + gsize *length, + GCancellable *cancellable, + GError **error); +GIO_DEPRECATED_IN_2_56_FOR (g_data_input_stream_read_upto_async) +void g_data_input_stream_read_until_async (GDataInputStream *stream, + const gchar *stop_chars, + gint io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_DEPRECATED_IN_2_56_FOR (g_data_input_stream_read_upto_finish) +char * g_data_input_stream_read_until_finish (GDataInputStream *stream, + GAsyncResult *result, + gsize *length, + GError **error); + +GIO_AVAILABLE_IN_ALL +char * g_data_input_stream_read_upto (GDataInputStream *stream, + const gchar *stop_chars, + gssize stop_chars_len, + gsize *length, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_data_input_stream_read_upto_async (GDataInputStream *stream, + const gchar *stop_chars, + gssize stop_chars_len, + gint io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +char * g_data_input_stream_read_upto_finish (GDataInputStream *stream, + GAsyncResult *result, + gsize *length, + GError **error); + +G_END_DECLS + +#endif /* __G_DATA_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdataoutputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdataoutputstream.h new file mode 100644 index 00000000..9fad093e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdataoutputstream.h @@ -0,0 +1,121 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_DATA_OUTPUT_STREAM_H__ +#define __G_DATA_OUTPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DATA_OUTPUT_STREAM (g_data_output_stream_get_type ()) +#define G_DATA_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DATA_OUTPUT_STREAM, GDataOutputStream)) +#define G_DATA_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DATA_OUTPUT_STREAM, GDataOutputStreamClass)) +#define G_IS_DATA_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DATA_OUTPUT_STREAM)) +#define G_IS_DATA_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DATA_OUTPUT_STREAM)) +#define G_DATA_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DATA_OUTPUT_STREAM, GDataOutputStreamClass)) + +typedef struct _GDataOutputStream GDataOutputStream; +typedef struct _GDataOutputStreamClass GDataOutputStreamClass; +typedef struct _GDataOutputStreamPrivate GDataOutputStreamPrivate; + +struct _GDataOutputStream +{ + GFilterOutputStream parent_instance; + + /*< private >*/ + GDataOutputStreamPrivate *priv; +}; + +struct _GDataOutputStreamClass +{ + GFilterOutputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + + +GIO_AVAILABLE_IN_ALL +GType g_data_output_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDataOutputStream * g_data_output_stream_new (GOutputStream *base_stream); + +GIO_AVAILABLE_IN_ALL +void g_data_output_stream_set_byte_order (GDataOutputStream *stream, + GDataStreamByteOrder order); +GIO_AVAILABLE_IN_ALL +GDataStreamByteOrder g_data_output_stream_get_byte_order (GDataOutputStream *stream); + +GIO_AVAILABLE_IN_ALL +gboolean g_data_output_stream_put_byte (GDataOutputStream *stream, + guchar data, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_data_output_stream_put_int16 (GDataOutputStream *stream, + gint16 data, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_data_output_stream_put_uint16 (GDataOutputStream *stream, + guint16 data, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_data_output_stream_put_int32 (GDataOutputStream *stream, + gint32 data, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_data_output_stream_put_uint32 (GDataOutputStream *stream, + guint32 data, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_data_output_stream_put_int64 (GDataOutputStream *stream, + gint64 data, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_data_output_stream_put_uint64 (GDataOutputStream *stream, + guint64 data, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_data_output_stream_put_string (GDataOutputStream *stream, + const char *str, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* __G_DATA_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusactiongroup.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusactiongroup.h new file mode 100644 index 00000000..84868f07 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusactiongroup.h @@ -0,0 +1,56 @@ +/* + * Copyright © 2010 Codethink Limited + * Copyright © 2011 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_DBUS_ACTION_GROUP_H__ +#define __G_DBUS_ACTION_GROUP_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include "giotypes.h" + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_ACTION_GROUP (g_dbus_action_group_get_type ()) +#define G_DBUS_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_DBUS_ACTION_GROUP, GDBusActionGroup)) +#define G_DBUS_ACTION_GROUP_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_DBUS_ACTION_GROUP, GDBusActionGroupClass)) +#define G_IS_DBUS_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_DBUS_ACTION_GROUP)) +#define G_IS_DBUS_ACTION_GROUP_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_DBUS_ACTION_GROUP)) +#define G_DBUS_ACTION_GROUP_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_DBUS_ACTION_GROUP, GDBusActionGroupClass)) + +GIO_AVAILABLE_IN_ALL +GType g_dbus_action_group_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +GDBusActionGroup * g_dbus_action_group_get (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path); + +G_END_DECLS + +#endif /* __G_DBUS_ACTION_GROUP_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusaddress.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusaddress.h new file mode 100644 index 00000000..09734ade --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusaddress.h @@ -0,0 +1,67 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_ADDRESS_H__ +#define __G_DBUS_ADDRESS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GIO_AVAILABLE_IN_2_36 +gchar *g_dbus_address_escape_value (const gchar *string); + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_is_address (const gchar *string); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_is_supported_address (const gchar *string, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_dbus_address_get_stream (const gchar *address, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +GIOStream *g_dbus_address_get_stream_finish (GAsyncResult *res, + gchar **out_guid, + GError **error); + +GIO_AVAILABLE_IN_ALL +GIOStream *g_dbus_address_get_stream_sync (const gchar *address, + gchar **out_guid, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +gchar *g_dbus_address_get_for_bus_sync (GBusType bus_type, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* __G_DBUS_ADDRESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusauthobserver.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusauthobserver.h new file mode 100644 index 00000000..715095d4 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusauthobserver.h @@ -0,0 +1,53 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_AUTH_OBSERVER_H__ +#define __G_DBUS_AUTH_OBSERVER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_AUTH_OBSERVER (g_dbus_auth_observer_get_type ()) +#define G_DBUS_AUTH_OBSERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_AUTH_OBSERVER, GDBusAuthObserver)) +#define G_IS_DBUS_AUTH_OBSERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_AUTH_OBSERVER)) + +GIO_AVAILABLE_IN_ALL +GType g_dbus_auth_observer_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDBusAuthObserver *g_dbus_auth_observer_new (void); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_auth_observer_authorize_authenticated_peer (GDBusAuthObserver *observer, + GIOStream *stream, + GCredentials *credentials); + +GIO_AVAILABLE_IN_2_34 +gboolean g_dbus_auth_observer_allow_mechanism (GDBusAuthObserver *observer, + const gchar *mechanism); + +G_END_DECLS + +#endif /* _G_DBUS_AUTH_OBSERVER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusconnection.h new file mode 100644 index 00000000..6631748c --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusconnection.h @@ -0,0 +1,751 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_CONNECTION_H__ +#define __G_DBUS_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_CONNECTION (g_dbus_connection_get_type ()) +#define G_DBUS_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_CONNECTION, GDBusConnection)) +#define G_IS_DBUS_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_CONNECTION)) + +GIO_AVAILABLE_IN_ALL +GType g_dbus_connection_get_type (void) G_GNUC_CONST; + +/* ---------------------------------------------------------------------------------------------------- */ + +GIO_AVAILABLE_IN_ALL +void g_bus_get (GBusType bus_type, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_bus_get_finish (GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_bus_get_sync (GBusType bus_type, + GCancellable *cancellable, + GError **error); + +/* ---------------------------------------------------------------------------------------------------- */ + +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_new (GIOStream *stream, + const gchar *guid, + GDBusConnectionFlags flags, + GDBusAuthObserver *observer, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_connection_new_finish (GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_connection_new_sync (GIOStream *stream, + const gchar *guid, + GDBusConnectionFlags flags, + GDBusAuthObserver *observer, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_new_for_address (const gchar *address, + GDBusConnectionFlags flags, + GDBusAuthObserver *observer, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_connection_new_for_address_finish (GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_connection_new_for_address_sync (const gchar *address, + GDBusConnectionFlags flags, + GDBusAuthObserver *observer, + GCancellable *cancellable, + GError **error); + +/* ---------------------------------------------------------------------------------------------------- */ + +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_start_message_processing (GDBusConnection *connection); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_is_closed (GDBusConnection *connection); +GIO_AVAILABLE_IN_ALL +GIOStream *g_dbus_connection_get_stream (GDBusConnection *connection); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_connection_get_guid (GDBusConnection *connection); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_connection_get_unique_name (GDBusConnection *connection); +GIO_AVAILABLE_IN_ALL +GCredentials *g_dbus_connection_get_peer_credentials (GDBusConnection *connection); + +GIO_AVAILABLE_IN_2_34 +guint32 g_dbus_connection_get_last_serial (GDBusConnection *connection); + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_get_exit_on_close (GDBusConnection *connection); +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_set_exit_on_close (GDBusConnection *connection, + gboolean exit_on_close); +GIO_AVAILABLE_IN_ALL +GDBusCapabilityFlags g_dbus_connection_get_capabilities (GDBusConnection *connection); +GIO_AVAILABLE_IN_2_60 +GDBusConnectionFlags g_dbus_connection_get_flags (GDBusConnection *connection); + +/* ---------------------------------------------------------------------------------------------------- */ + +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_close (GDBusConnection *connection, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_close_finish (GDBusConnection *connection, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_close_sync (GDBusConnection *connection, + GCancellable *cancellable, + GError **error); + +/* ---------------------------------------------------------------------------------------------------- */ + +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_flush (GDBusConnection *connection, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_flush_finish (GDBusConnection *connection, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_flush_sync (GDBusConnection *connection, + GCancellable *cancellable, + GError **error); + +/* ---------------------------------------------------------------------------------------------------- */ + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_send_message (GDBusConnection *connection, + GDBusMessage *message, + GDBusSendMessageFlags flags, + volatile guint32 *out_serial, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_send_message_with_reply (GDBusConnection *connection, + GDBusMessage *message, + GDBusSendMessageFlags flags, + gint timeout_msec, + volatile guint32 *out_serial, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_connection_send_message_with_reply_finish (GDBusConnection *connection, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_connection_send_message_with_reply_sync (GDBusConnection *connection, + GDBusMessage *message, + GDBusSendMessageFlags flags, + gint timeout_msec, + volatile guint32 *out_serial, + GCancellable *cancellable, + GError **error); + +/* ---------------------------------------------------------------------------------------------------- */ + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_emit_signal (GDBusConnection *connection, + const gchar *destination_bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_call (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_connection_call_finish (GDBusConnection *connection, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_connection_call_sync (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GError **error); + +#ifdef G_OS_UNIX + +GIO_AVAILABLE_IN_2_30 +void g_dbus_connection_call_with_unix_fd_list (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GUnixFDList *fd_list, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_30 +GVariant *g_dbus_connection_call_with_unix_fd_list_finish (GDBusConnection *connection, + GUnixFDList **out_fd_list, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_2_30 +GVariant *g_dbus_connection_call_with_unix_fd_list_sync (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GUnixFDList *fd_list, + GUnixFDList **out_fd_list, + GCancellable *cancellable, + GError **error); + +#endif /* G_OS_UNIX */ + +/* ---------------------------------------------------------------------------------------------------- */ + + +/** + * GDBusInterfaceMethodCallFunc: + * @connection: A #GDBusConnection. + * @sender: (nullable): The unique bus name of the remote caller, or `NULL` if + * not specified by the caller, e.g. on peer-to-peer connections. + * @object_path: The object path that the method was invoked on. + * @interface_name: (nullable): The D-Bus interface name the method was invoked on, + * or `NULL` if not specified by the sender. + * @method_name: The name of the method that was invoked. + * @parameters: A #GVariant tuple with parameters. + * @invocation: (transfer full): A #GDBusMethodInvocation object that must be used to return a value or error. + * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_object(). + * + * The type of the @method_call function in #GDBusInterfaceVTable. + * + * @interface_name may be `NULL` if not specified by the sender, although it’s + * encouraged for the sender to set it. If unset, and the object has only one + * method (across all interfaces) matching @method_name, that method is invoked. + * Otherwise, behaviour is implementation defined. See the + * [D-Bus specification](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-types-method). + * It is recommended to return [error@Gio.DBusError.UNKNOWN_METHOD]. + * + * Since: 2.26 + */ +typedef void (*GDBusInterfaceMethodCallFunc) (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data); + +/** + * GDBusInterfaceGetPropertyFunc: + * @connection: A #GDBusConnection. + * @sender: (nullable): The unique bus name of the remote caller or %NULL if + * not specified by the caller, e.g. on peer-to-peer connections. + * @object_path: The object path that the method was invoked on. + * @interface_name: The D-Bus interface name for the property. + * @property_name: The name of the property to get the value of. + * @error: Return location for error. + * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_object(). + * + * The type of the @get_property function in #GDBusInterfaceVTable. + * + * Returns: A #GVariant with the value for @property_name or %NULL if + * @error is set. If the returned #GVariant is floating, it is + * consumed - otherwise its reference count is decreased by one. + * + * Since: 2.26 + */ +typedef GVariant *(*GDBusInterfaceGetPropertyFunc) (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GError **error, + gpointer user_data); + +/** + * GDBusInterfaceSetPropertyFunc: + * @connection: A #GDBusConnection. + * @sender: (nullable): The unique bus name of the remote caller or %NULL if + * not specified by the caller, e.g. on peer-to-peer connections. + * @object_path: The object path that the method was invoked on. + * @interface_name: The D-Bus interface name for the property. + * @property_name: The name of the property to get the value of. + * @value: The value to set the property to. + * @error: Return location for error. + * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_object(). + * + * The type of the @set_property function in #GDBusInterfaceVTable. + * + * Returns: %TRUE if the property was set to @value, %FALSE if @error is set. + * + * Since: 2.26 + */ +typedef gboolean (*GDBusInterfaceSetPropertyFunc) (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GVariant *value, + GError **error, + gpointer user_data); + +/** + * GDBusInterfaceVTable: + * @method_call: Function for handling incoming method calls. + * @get_property: Function for getting a property. + * @set_property: Function for setting a property. + * + * Virtual table for handling properties and method calls for a D-Bus + * interface. + * + * Since 2.38, if you want to handle getting/setting D-Bus properties + * asynchronously, give %NULL as your get_property() or set_property() + * function. The D-Bus call will be directed to your @method_call function, + * with the provided @interface_name set to "org.freedesktop.DBus.Properties". + * + * Ownership of the #GDBusMethodInvocation object passed to the + * method_call() function is transferred to your handler; you must + * call one of the methods of #GDBusMethodInvocation to return a reply + * (possibly empty), or an error. These functions also take ownership + * of the passed-in invocation object, so unless the invocation + * object has otherwise been referenced, it will be then be freed. + * Calling one of these functions may be done within your + * method_call() implementation but it also can be done at a later + * point to handle the method asynchronously. + * + * The usual checks on the validity of the calls is performed. For + * `Get` calls, an error is automatically returned if the property does + * not exist or the permissions do not allow access. The same checks are + * performed for `Set` calls, and the provided value is also checked for + * being the correct type. + * + * For both `Get` and `Set` calls, the #GDBusMethodInvocation + * passed to the @method_call handler can be queried with + * g_dbus_method_invocation_get_property_info() to get a pointer + * to the #GDBusPropertyInfo of the property. + * + * If you have readable properties specified in your interface info, + * you must ensure that you either provide a non-%NULL @get_property() + * function or provide implementations of both the `Get` and `GetAll` + * methods on org.freedesktop.DBus.Properties interface in your @method_call + * function. Note that the required return type of the `Get` call is + * `(v)`, not the type of the property. `GetAll` expects a return value + * of type `a{sv}`. + * + * If you have writable properties specified in your interface info, + * you must ensure that you either provide a non-%NULL @set_property() + * function or provide an implementation of the `Set` call. If implementing + * the call, you must return the value of type %G_VARIANT_TYPE_UNIT. + * + * Since: 2.26 + */ +struct _GDBusInterfaceVTable +{ + GDBusInterfaceMethodCallFunc method_call; + GDBusInterfaceGetPropertyFunc get_property; + GDBusInterfaceSetPropertyFunc set_property; + + /*< private >*/ + /* Padding for future expansion - also remember to update + * gdbusconnection.c:_g_dbus_interface_vtable_copy() when + * changing this. + */ + gpointer padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +guint g_dbus_connection_register_object (GDBusConnection *connection, + const gchar *object_path, + GDBusInterfaceInfo *interface_info, + const GDBusInterfaceVTable *vtable, + gpointer user_data, + GDestroyNotify user_data_free_func, + GError **error); +GIO_DEPRECATED_IN_2_84_FOR(g_dbus_connection_register_object_with_closures2) +guint g_dbus_connection_register_object_with_closures (GDBusConnection *connection, + const gchar *object_path, + GDBusInterfaceInfo *interface_info, + GClosure *method_call_closure, + GClosure *get_property_closure, + GClosure *set_property_closure, + GError **error); +GIO_AVAILABLE_IN_2_84 +guint g_dbus_connection_register_object_with_closures2 (GDBusConnection *connection, + const gchar *object_path, + GDBusInterfaceInfo *interface_info, + GClosure *method_call_closure, + GClosure *get_property_closure, + GClosure *set_property_closure, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_unregister_object (GDBusConnection *connection, + guint registration_id); + +/* ---------------------------------------------------------------------------------------------------- */ + +/** + * GDBusSubtreeEnumerateFunc: + * @connection: A #GDBusConnection. + * @sender: The unique bus name of the remote caller. + * @object_path: The object path that was registered with g_dbus_connection_register_subtree(). + * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree(). + * + * The type of the @enumerate function in #GDBusSubtreeVTable. + * + * This function is called when generating introspection data and also + * when preparing to dispatch incoming messages in the event that the + * %G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES flag is not + * specified (ie: to verify that the object path is valid). + * + * Hierarchies are not supported; the items that you return should not + * contain the `/` character. + * + * The return value will be freed with g_strfreev(). + * + * Returns: (array zero-terminated=1) (transfer full): A newly allocated array of strings for node names that are children of @object_path. + * + * Since: 2.26 + */ +typedef gchar** (*GDBusSubtreeEnumerateFunc) (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + gpointer user_data); + +/** + * GDBusSubtreeIntrospectFunc: + * @connection: A #GDBusConnection. + * @sender: The unique bus name of the remote caller. + * @object_path: The object path that was registered with g_dbus_connection_register_subtree(). + * @node: A node that is a child of @object_path (relative to @object_path) or %NULL for the root of the subtree. + * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree(). + * + * The type of the @introspect function in #GDBusSubtreeVTable. + * + * Subtrees are flat. @node, if non-%NULL, is always exactly one + * segment of the object path (ie: it never contains a slash). + * + * This function should return %NULL to indicate that there is no object + * at this node. + * + * If this function returns non-%NULL, the return value is expected to + * be a %NULL-terminated array of pointers to #GDBusInterfaceInfo + * structures describing the interfaces implemented by @node. This + * array will have g_dbus_interface_info_unref() called on each item + * before being freed with g_free(). + * + * The difference between returning %NULL and an array containing zero + * items is that the standard DBus interfaces will returned to the + * remote introspector in the empty array case, but not in the %NULL + * case. + * + * Returns: (array zero-terminated=1) (nullable) (transfer full): A %NULL-terminated array of pointers to #GDBusInterfaceInfo, or %NULL. + * + * Since: 2.26 + */ +typedef GDBusInterfaceInfo ** (*GDBusSubtreeIntrospectFunc) (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *node, + gpointer user_data); + +/** + * GDBusSubtreeDispatchFunc: + * @connection: A #GDBusConnection. + * @sender: The unique bus name of the remote caller. + * @object_path: The object path that was registered with g_dbus_connection_register_subtree(). + * @interface_name: The D-Bus interface name that the method call or property access is for. + * @node: A node that is a child of @object_path (relative to @object_path) or %NULL for the root of the subtree. + * @out_user_data: (nullable) (not optional): Return location for user data to pass to functions in the returned #GDBusInterfaceVTable. + * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree(). + * + * The type of the @dispatch function in #GDBusSubtreeVTable. + * + * Subtrees are flat. @node, if non-%NULL, is always exactly one + * segment of the object path (ie: it never contains a slash). + * + * Returns: (nullable): A #GDBusInterfaceVTable or %NULL if you don't want to handle the methods. + * + * Since: 2.26 + */ +typedef const GDBusInterfaceVTable * (*GDBusSubtreeDispatchFunc) (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *node, + gpointer *out_user_data, + gpointer user_data); + +/** + * GDBusSubtreeVTable: + * @enumerate: Function for enumerating child nodes. + * @introspect: Function for introspecting a child node. + * @dispatch: Function for dispatching a remote call on a child node. + * + * Virtual table for handling subtrees registered with g_dbus_connection_register_subtree(). + * + * Since: 2.26 + */ +struct _GDBusSubtreeVTable +{ + GDBusSubtreeEnumerateFunc enumerate; + GDBusSubtreeIntrospectFunc introspect; + GDBusSubtreeDispatchFunc dispatch; + + /*< private >*/ + /* Padding for future expansion - also remember to update + * gdbusconnection.c:_g_dbus_subtree_vtable_copy() when + * changing this. + */ + gpointer padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +guint g_dbus_connection_register_subtree (GDBusConnection *connection, + const gchar *object_path, + const GDBusSubtreeVTable *vtable, + GDBusSubtreeFlags flags, + gpointer user_data, + GDestroyNotify user_data_free_func, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_connection_unregister_subtree (GDBusConnection *connection, + guint registration_id); + +/* ---------------------------------------------------------------------------------------------------- */ + +/** + * GDBusSignalCallback: + * @connection: A #GDBusConnection. + * @sender_name: (nullable): The unique bus name of the sender of the signal, + or %NULL on a peer-to-peer D-Bus connection. + * @object_path: The object path that the signal was emitted on. + * @interface_name: The name of the interface. + * @signal_name: The name of the signal. + * @parameters: A #GVariant tuple with parameters for the signal. + * @user_data: User data passed when subscribing to the signal. + * + * Signature for callback function used in g_dbus_connection_signal_subscribe(). + * + * Since: 2.26 + */ +typedef void (*GDBusSignalCallback) (GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +guint g_dbus_connection_signal_subscribe (GDBusConnection *connection, + const gchar *sender, + const gchar *interface_name, + const gchar *member, + const gchar *object_path, + const gchar *arg0, + GDBusSignalFlags flags, + GDBusSignalCallback callback, + gpointer user_data, + GDestroyNotify user_data_free_func); +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_signal_unsubscribe (GDBusConnection *connection, + guint subscription_id); + +/** + * g_clear_dbus_signal_subscription: (skip) + * @subscription_id_pointer: (not optional) (inout): A pointer to either a + * subscription ID obtained from [method@Gio.DBusConnection.signal_subscribe], + * or zero. + * @connection: The connection from which the subscription ID was obtained. + * This pointer may be `NULL` or invalid, if the subscription ID is zero. + * + * If @subscription_id_pointer points to a nonzero subscription ID, + * unsubscribe from that D-Bus signal subscription as if via + * [method@Gio.DBusConnection.signal_unsubscribe]. + * + * Also set the value pointed to by @subscription_id_pointer to zero, + * which signifies it’s no longer a valid subscription ID. + * + * This convenience function for C code helps to ensure that each signal + * subscription is unsubscribed exactly once, similar to + * [func@GObject.clear_object] and [func@GObject.clear_signal_handler]. + * + * Since: 2.84 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_84 +static inline void g_clear_dbus_signal_subscription (guint *subscription_id_pointer, + GDBusConnection *connection); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_84 +static inline void +g_clear_dbus_signal_subscription (guint *subscription_id_pointer, + GDBusConnection *connection) +{ + guint subscription_id; + + /* Suppress "Not available before" warning */ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + subscription_id = g_steal_handle_id (subscription_id_pointer); + G_GNUC_END_IGNORE_DEPRECATIONS + + if (subscription_id > 0) + g_dbus_connection_signal_unsubscribe (connection, subscription_id); +} + +/* ---------------------------------------------------------------------------------------------------- */ + +/** + * GDBusMessageFilterFunction: + * @connection: (transfer none): A #GDBusConnection. + * @message: (transfer full): A locked #GDBusMessage that the filter function takes ownership of. + * @incoming: %TRUE if it is a message received from the other peer, %FALSE if it is + * a message to be sent to the other peer. + * @user_data: User data passed when adding the filter. + * + * Signature for function used in g_dbus_connection_add_filter(). + * + * A filter function is passed a #GDBusMessage and expected to return + * a #GDBusMessage too. Passive filter functions that don't modify the + * message can simply return the @message object: + * |[ + * static GDBusMessage * + * passive_filter (GDBusConnection *connection + * GDBusMessage *message, + * gboolean incoming, + * gpointer user_data) + * { + * // inspect @message + * return message; + * } + * ]| + * Filter functions that wants to drop a message can simply return %NULL: + * |[ + * static GDBusMessage * + * drop_filter (GDBusConnection *connection + * GDBusMessage *message, + * gboolean incoming, + * gpointer user_data) + * { + * if (should_drop_message) + * { + * g_object_unref (message); + * message = NULL; + * } + * return message; + * } + * ]| + * Finally, a filter function may modify a message by copying it: + * |[ + * static GDBusMessage * + * modifying_filter (GDBusConnection *connection + * GDBusMessage *message, + * gboolean incoming, + * gpointer user_data) + * { + * GDBusMessage *copy; + * GError *error; + * + * error = NULL; + * copy = g_dbus_message_copy (message, &error); + * // handle @error being set + * g_object_unref (message); + * + * // modify @copy + * + * return copy; + * } + * ]| + * If the returned #GDBusMessage is different from @message and cannot + * be sent on @connection (it could use features, such as file + * descriptors, not compatible with @connection), then a warning is + * logged to standard error. Applications can + * check this ahead of time using g_dbus_message_to_blob() passing a + * #GDBusCapabilityFlags value obtained from @connection. + * + * Returns: (transfer full) (nullable): A #GDBusMessage that will be freed with + * g_object_unref() or %NULL to drop the message. Passive filter + * functions can simply return the passed @message object. + * + * Since: 2.26 + */ +typedef GDBusMessage *(*GDBusMessageFilterFunction) (GDBusConnection *connection, + GDBusMessage *message, + gboolean incoming, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +guint g_dbus_connection_add_filter (GDBusConnection *connection, + GDBusMessageFilterFunction filter_function, + gpointer user_data, + GDestroyNotify user_data_free_func); + +GIO_AVAILABLE_IN_ALL +void g_dbus_connection_remove_filter (GDBusConnection *connection, + guint filter_id); + +/* ---------------------------------------------------------------------------------------------------- */ + + +G_END_DECLS + +#endif /* __G_DBUS_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbuserror.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbuserror.h new file mode 100644 index 00000000..6a849348 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbuserror.h @@ -0,0 +1,111 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_ERROR_H__ +#define __G_DBUS_ERROR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_DBUS_ERROR: + * + * Error domain for errors generated by a remote message bus. Errors + * in this domain will be from the #GDBusError enumeration. See + * #GError for more information on error domains. + * + * Note that this error domain is intended only for + * returning errors from a remote message bus process. Errors + * generated locally in-process by e.g. #GDBusConnection should use the + * %G_IO_ERROR domain. + * + * Since: 2.26 + */ +#define G_DBUS_ERROR g_dbus_error_quark() + +GIO_AVAILABLE_IN_ALL +GQuark g_dbus_error_quark (void); + +/* Used by applications to check, get and strip the D-Bus error name */ +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_error_is_remote_error (const GError *error); +GIO_AVAILABLE_IN_ALL +gchar *g_dbus_error_get_remote_error (const GError *error); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_error_strip_remote_error (GError *error); + +/** + * GDBusErrorEntry: + * @error_code: An error code. + * @dbus_error_name: The D-Bus error name to associate with @error_code. + * + * Struct used in g_dbus_error_register_error_domain(). + * + * Since: 2.26 + */ +struct _GDBusErrorEntry +{ + gint error_code; + const gchar *dbus_error_name; +}; + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_error_register_error (GQuark error_domain, + gint error_code, + const gchar *dbus_error_name); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_error_unregister_error (GQuark error_domain, + gint error_code, + const gchar *dbus_error_name); +GIO_AVAILABLE_IN_ALL +void g_dbus_error_register_error_domain (const gchar *error_domain_quark_name, + volatile gsize *quark_volatile, + const GDBusErrorEntry *entries, + guint num_entries); + +/* Only used by object mappings to map back and forth to GError */ +GIO_AVAILABLE_IN_ALL +GError *g_dbus_error_new_for_dbus_error (const gchar *dbus_error_name, + const gchar *dbus_error_message); +GIO_AVAILABLE_IN_ALL +void g_dbus_error_set_dbus_error (GError **error, + const gchar *dbus_error_name, + const gchar *dbus_error_message, + const gchar *format, + ...) G_GNUC_PRINTF(4, 5); +GIO_AVAILABLE_IN_ALL +void g_dbus_error_set_dbus_error_valist (GError **error, + const gchar *dbus_error_name, + const gchar *dbus_error_message, + const gchar *format, + va_list var_args) G_GNUC_PRINTF(4, 0); +GIO_AVAILABLE_IN_ALL +gchar *g_dbus_error_encode_gerror (const GError *error); + +G_END_DECLS + +#endif /* __G_DBUS_ERROR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusinterface.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusinterface.h new file mode 100644 index 00000000..44889754 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusinterface.h @@ -0,0 +1,75 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_INTERFACE_H__ +#define __G_DBUS_INTERFACE_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_INTERFACE (g_dbus_interface_get_type()) +#define G_DBUS_INTERFACE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_INTERFACE, GDBusInterface)) +#define G_IS_DBUS_INTERFACE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_INTERFACE)) +#define G_DBUS_INTERFACE_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), G_TYPE_DBUS_INTERFACE, GDBusInterfaceIface)) + +typedef struct _GDBusInterfaceIface GDBusInterfaceIface; + +/** + * GDBusInterfaceIface: + * @parent_iface: The parent interface. + * @get_info: Returns a #GDBusInterfaceInfo. See g_dbus_interface_get_info(). + * @get_object: Gets the enclosing #GDBusObject. See g_dbus_interface_get_object(). + * @set_object: Sets the enclosing #GDBusObject. See g_dbus_interface_set_object(). + * @dup_object: Gets a reference to the enclosing #GDBusObject. See g_dbus_interface_dup_object(). Added in 2.32. + * + * Base type for D-Bus interfaces. + * + * Since: 2.30 + */ +struct _GDBusInterfaceIface +{ + GTypeInterface parent_iface; + + /* Virtual Functions */ + GDBusInterfaceInfo *(*get_info) (GDBusInterface *interface_); + GDBusObject *(*get_object) (GDBusInterface *interface_); + void (*set_object) (GDBusInterface *interface_, + GDBusObject *object); + GDBusObject *(*dup_object) (GDBusInterface *interface_); +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_interface_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDBusInterfaceInfo *g_dbus_interface_get_info (GDBusInterface *interface_); +GIO_AVAILABLE_IN_ALL +GDBusObject *g_dbus_interface_get_object (GDBusInterface *interface_); +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_set_object (GDBusInterface *interface_, + GDBusObject *object); +GIO_AVAILABLE_IN_2_32 +GDBusObject *g_dbus_interface_dup_object (GDBusInterface *interface_); + +G_END_DECLS + +#endif /* __G_DBUS_INTERFACE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusinterfaceskeleton.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusinterfaceskeleton.h new file mode 100644 index 00000000..5de5ff92 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusinterfaceskeleton.h @@ -0,0 +1,121 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_INTERFACE_SKELETON_H__ +#define __G_DBUS_INTERFACE_SKELETON_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_INTERFACE_SKELETON (g_dbus_interface_skeleton_get_type ()) +#define G_DBUS_INTERFACE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_INTERFACE_SKELETON, GDBusInterfaceSkeleton)) +#define G_DBUS_INTERFACE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_INTERFACE_SKELETON, GDBusInterfaceSkeletonClass)) +#define G_DBUS_INTERFACE_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_INTERFACE_SKELETON, GDBusInterfaceSkeletonClass)) +#define G_IS_DBUS_INTERFACE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_INTERFACE_SKELETON)) +#define G_IS_DBUS_INTERFACE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_INTERFACE_SKELETON)) + +typedef struct _GDBusInterfaceSkeletonClass GDBusInterfaceSkeletonClass; +typedef struct _GDBusInterfaceSkeletonPrivate GDBusInterfaceSkeletonPrivate; + +struct _GDBusInterfaceSkeleton +{ + /*< private >*/ + GObject parent_instance; + GDBusInterfaceSkeletonPrivate *priv; +}; + +/** + * GDBusInterfaceSkeletonClass: + * @parent_class: The parent class. + * @get_info: Returns a #GDBusInterfaceInfo. See g_dbus_interface_skeleton_get_info() for details. + * @get_vtable: Returns a #GDBusInterfaceVTable. See g_dbus_interface_skeleton_get_vtable() for details. + * @get_properties: Returns a #GVariant with all properties. See g_dbus_interface_skeleton_get_properties(). + * @flush: Emits outstanding changes, if any. See g_dbus_interface_skeleton_flush(). + * @g_authorize_method: Signal class handler for the #GDBusInterfaceSkeleton::g-authorize-method signal. + * + * Class structure for #GDBusInterfaceSkeleton. + * + * Since: 2.30 + */ +struct _GDBusInterfaceSkeletonClass +{ + GObjectClass parent_class; + + /* Virtual Functions */ + GDBusInterfaceInfo *(*get_info) (GDBusInterfaceSkeleton *interface_); + GDBusInterfaceVTable *(*get_vtable) (GDBusInterfaceSkeleton *interface_); + GVariant *(*get_properties) (GDBusInterfaceSkeleton *interface_); + void (*flush) (GDBusInterfaceSkeleton *interface_); + + /*< private >*/ + gpointer vfunc_padding[8]; + /*< public >*/ + + /* Signals */ + gboolean (*g_authorize_method) (GDBusInterfaceSkeleton *interface_, + GDBusMethodInvocation *invocation); + + /*< private >*/ + gpointer signal_padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_interface_skeleton_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDBusInterfaceSkeletonFlags g_dbus_interface_skeleton_get_flags (GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_skeleton_set_flags (GDBusInterfaceSkeleton *interface_, + GDBusInterfaceSkeletonFlags flags); +GIO_AVAILABLE_IN_ALL +GDBusInterfaceInfo *g_dbus_interface_skeleton_get_info (GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +GDBusInterfaceVTable *g_dbus_interface_skeleton_get_vtable (GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_interface_skeleton_get_properties (GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_skeleton_flush (GDBusInterfaceSkeleton *interface_); + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_interface_skeleton_export (GDBusInterfaceSkeleton *interface_, + GDBusConnection *connection, + const gchar *object_path, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_skeleton_unexport (GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_skeleton_unexport_from_connection (GDBusInterfaceSkeleton *interface_, + GDBusConnection *connection); + +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_interface_skeleton_get_connection (GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +GList *g_dbus_interface_skeleton_get_connections (GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_interface_skeleton_has_connection (GDBusInterfaceSkeleton *interface_, + GDBusConnection *connection); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_interface_skeleton_get_object_path (GDBusInterfaceSkeleton *interface_); + +G_END_DECLS + +#endif /* __G_DBUS_INTERFACE_SKELETON_H */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusintrospection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusintrospection.h new file mode 100644 index 00000000..7b17c1af --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusintrospection.h @@ -0,0 +1,327 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_INTROSPECTION_H__ +#define __G_DBUS_INTROSPECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * GDBusAnnotationInfo: + * @ref_count: The reference count or -1 if statically allocated. + * @key: The name of the annotation, e.g. "org.freedesktop.DBus.Deprecated". + * @value: The value of the annotation. + * @annotations: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. + * + * Information about an annotation. + * + * Since: 2.26 + */ +struct _GDBusAnnotationInfo +{ + /*< public >*/ + gint ref_count; /* (atomic) */ + gchar *key; + gchar *value; + GDBusAnnotationInfo **annotations; +}; + +/** + * GDBusArgInfo: + * @ref_count: The reference count or -1 if statically allocated. + * @name: Name of the argument, e.g. @unix_user_id. + * @signature: D-Bus signature of the argument (a single complete type). + * @annotations: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. + * + * Information about an argument for a method or a signal. + * + * Since: 2.26 + */ +struct _GDBusArgInfo +{ + /*< public >*/ + gint ref_count; /* (atomic) */ + gchar *name; + gchar *signature; + GDBusAnnotationInfo **annotations; +}; + +/** + * GDBusMethodInfo: + * @ref_count: The reference count or -1 if statically allocated. + * @name: The name of the D-Bus method, e.g. @RequestName. + * @in_args: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusArgInfo structures or %NULL if there are no in arguments. + * @out_args: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusArgInfo structures or %NULL if there are no out arguments. + * @annotations: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. + * + * Information about a method on a D-Bus interface. + * + * Since: 2.26 + */ +struct _GDBusMethodInfo +{ + /*< public >*/ + gint ref_count; /* (atomic) */ + gchar *name; + GDBusArgInfo **in_args; + GDBusArgInfo **out_args; + GDBusAnnotationInfo **annotations; +}; + +/** + * GDBusSignalInfo: + * @ref_count: The reference count or -1 if statically allocated. + * @name: The name of the D-Bus signal, e.g. "NameOwnerChanged". + * @args: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusArgInfo structures or %NULL if there are no arguments. + * @annotations: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. + * + * Information about a signal on a D-Bus interface. + * + * Since: 2.26 + */ +struct _GDBusSignalInfo +{ + /*< public >*/ + gint ref_count; /* (atomic) */ + gchar *name; + GDBusArgInfo **args; + GDBusAnnotationInfo **annotations; +}; + +/** + * GDBusPropertyInfo: + * @ref_count: The reference count or -1 if statically allocated. + * @name: The name of the D-Bus property, e.g. "SupportedFilesystems". + * @signature: The D-Bus signature of the property (a single complete type). + * @flags: Access control flags for the property. + * @annotations: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. + * + * Information about a D-Bus property on a D-Bus interface. + * + * Since: 2.26 + */ +struct _GDBusPropertyInfo +{ + /*< public >*/ + gint ref_count; /* (atomic) */ + gchar *name; + gchar *signature; + GDBusPropertyInfoFlags flags; + GDBusAnnotationInfo **annotations; +}; + +/** + * GDBusInterfaceInfo: + * @ref_count: The reference count or -1 if statically allocated. + * @name: The name of the D-Bus interface, e.g. "org.freedesktop.DBus.Properties". + * @methods: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusMethodInfo structures or %NULL if there are no methods. + * @signals: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusSignalInfo structures or %NULL if there are no signals. + * @properties: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusPropertyInfo structures or %NULL if there are no properties. + * @annotations: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. + * + * Information about a D-Bus interface. + * + * Since: 2.26 + */ +struct _GDBusInterfaceInfo +{ + /*< public >*/ + gint ref_count; /* (atomic) */ + gchar *name; + GDBusMethodInfo **methods; + GDBusSignalInfo **signals; + GDBusPropertyInfo **properties; + GDBusAnnotationInfo **annotations; +}; + +/** + * GDBusNodeInfo: + * @ref_count: The reference count or -1 if statically allocated. + * @path: The path of the node or %NULL if omitted. Note that this may be a relative path. See the D-Bus specification for more details. + * @interfaces: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusInterfaceInfo structures or %NULL if there are no interfaces. + * @nodes: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusNodeInfo structures or %NULL if there are no nodes. + * @annotations: (array zero-terminated=1): A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. + * + * Information about nodes in a remote object hierarchy. + * + * Since: 2.26 + */ +struct _GDBusNodeInfo +{ + /*< public >*/ + gint ref_count; /* (atomic) */ + gchar *path; + GDBusInterfaceInfo **interfaces; + GDBusNodeInfo **nodes; + GDBusAnnotationInfo **annotations; +}; + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_annotation_info_lookup (GDBusAnnotationInfo **annotations, + const gchar *name); +GIO_AVAILABLE_IN_ALL +GDBusMethodInfo *g_dbus_interface_info_lookup_method (GDBusInterfaceInfo *info, + const gchar *name); +GIO_AVAILABLE_IN_ALL +GDBusSignalInfo *g_dbus_interface_info_lookup_signal (GDBusInterfaceInfo *info, + const gchar *name); +GIO_AVAILABLE_IN_ALL +GDBusPropertyInfo *g_dbus_interface_info_lookup_property (GDBusInterfaceInfo *info, + const gchar *name); +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_info_cache_build (GDBusInterfaceInfo *info); +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_info_cache_release (GDBusInterfaceInfo *info); + +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_info_generate_xml (GDBusInterfaceInfo *info, + guint indent, + GString *string_builder); + +GIO_AVAILABLE_IN_ALL +GDBusNodeInfo *g_dbus_node_info_new_for_xml (const gchar *xml_data, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusInterfaceInfo *g_dbus_node_info_lookup_interface (GDBusNodeInfo *info, + const gchar *name); +GIO_AVAILABLE_IN_ALL +void g_dbus_node_info_generate_xml (GDBusNodeInfo *info, + guint indent, + GString *string_builder); + +GIO_AVAILABLE_IN_ALL +GDBusNodeInfo *g_dbus_node_info_ref (GDBusNodeInfo *info); +GIO_AVAILABLE_IN_ALL +GDBusInterfaceInfo *g_dbus_interface_info_ref (GDBusInterfaceInfo *info); +GIO_AVAILABLE_IN_ALL +GDBusMethodInfo *g_dbus_method_info_ref (GDBusMethodInfo *info); +GIO_AVAILABLE_IN_ALL +GDBusSignalInfo *g_dbus_signal_info_ref (GDBusSignalInfo *info); +GIO_AVAILABLE_IN_ALL +GDBusPropertyInfo *g_dbus_property_info_ref (GDBusPropertyInfo *info); +GIO_AVAILABLE_IN_ALL +GDBusArgInfo *g_dbus_arg_info_ref (GDBusArgInfo *info); +GIO_AVAILABLE_IN_ALL +GDBusAnnotationInfo *g_dbus_annotation_info_ref (GDBusAnnotationInfo *info); + +GIO_AVAILABLE_IN_ALL +void g_dbus_node_info_unref (GDBusNodeInfo *info); +GIO_AVAILABLE_IN_ALL +void g_dbus_interface_info_unref (GDBusInterfaceInfo *info); +GIO_AVAILABLE_IN_ALL +void g_dbus_method_info_unref (GDBusMethodInfo *info); +GIO_AVAILABLE_IN_ALL +void g_dbus_signal_info_unref (GDBusSignalInfo *info); +GIO_AVAILABLE_IN_ALL +void g_dbus_property_info_unref (GDBusPropertyInfo *info); +GIO_AVAILABLE_IN_ALL +void g_dbus_arg_info_unref (GDBusArgInfo *info); +GIO_AVAILABLE_IN_ALL +void g_dbus_annotation_info_unref (GDBusAnnotationInfo *info); + +/** + * G_TYPE_DBUS_NODE_INFO: + * + * The #GType for a boxed type holding a #GDBusNodeInfo. + * + * Since: 2.26 + */ +#define G_TYPE_DBUS_NODE_INFO (g_dbus_node_info_get_type ()) + +/** + * G_TYPE_DBUS_INTERFACE_INFO: + * + * The #GType for a boxed type holding a #GDBusInterfaceInfo. + * + * Since: 2.26 + */ +#define G_TYPE_DBUS_INTERFACE_INFO (g_dbus_interface_info_get_type ()) + +/** + * G_TYPE_DBUS_METHOD_INFO: + * + * The #GType for a boxed type holding a #GDBusMethodInfo. + * + * Since: 2.26 + */ +#define G_TYPE_DBUS_METHOD_INFO (g_dbus_method_info_get_type ()) + +/** + * G_TYPE_DBUS_SIGNAL_INFO: + * + * The #GType for a boxed type holding a #GDBusSignalInfo. + * + * Since: 2.26 + */ +#define G_TYPE_DBUS_SIGNAL_INFO (g_dbus_signal_info_get_type ()) + +/** + * G_TYPE_DBUS_PROPERTY_INFO: + * + * The #GType for a boxed type holding a #GDBusPropertyInfo. + * + * Since: 2.26 + */ +#define G_TYPE_DBUS_PROPERTY_INFO (g_dbus_property_info_get_type ()) + +/** + * G_TYPE_DBUS_ARG_INFO: + * + * The #GType for a boxed type holding a #GDBusArgInfo. + * + * Since: 2.26 + */ +#define G_TYPE_DBUS_ARG_INFO (g_dbus_arg_info_get_type ()) + +/** + * G_TYPE_DBUS_ANNOTATION_INFO: + * + * The #GType for a boxed type holding a #GDBusAnnotationInfo. + * + * Since: 2.26 + */ +#define G_TYPE_DBUS_ANNOTATION_INFO (g_dbus_annotation_info_get_type ()) + +GIO_AVAILABLE_IN_ALL +GType g_dbus_node_info_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GType g_dbus_interface_info_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GType g_dbus_method_info_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GType g_dbus_signal_info_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GType g_dbus_property_info_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GType g_dbus_arg_info_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GType g_dbus_annotation_info_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_DBUS_INTROSPECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmenumodel.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmenumodel.h new file mode 100644 index 00000000..73489b5b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmenumodel.h @@ -0,0 +1,47 @@ +/* + * Copyright © 2011 Canonical Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_DBUS_MENU_MODEL_H__ +#define __G_DBUS_MENU_MODEL_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_MENU_MODEL (g_dbus_menu_model_get_type ()) +#define G_DBUS_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_DBUS_MENU_MODEL, GDBusMenuModel)) +#define G_IS_DBUS_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_DBUS_MENU_MODEL)) + +typedef struct _GDBusMenuModel GDBusMenuModel; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_menu_model_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GDBusMenuModel * g_dbus_menu_model_get (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path); + +G_END_DECLS + +#endif /* __G_DBUS_MENU_MODEL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmessage.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmessage.h new file mode 100644 index 00000000..643aca07 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmessage.h @@ -0,0 +1,205 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_MESSAGE_H__ +#define __G_DBUS_MESSAGE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_MESSAGE (g_dbus_message_get_type ()) +#define G_DBUS_MESSAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_MESSAGE, GDBusMessage)) +#define G_IS_DBUS_MESSAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_MESSAGE)) + +GIO_AVAILABLE_IN_ALL +GType g_dbus_message_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_new (void); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_new_signal (const gchar *path, + const gchar *interface_, + const gchar *signal); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_new_method_call (const gchar *name, + const gchar *path, + const gchar *interface_, + const gchar *method); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_new_method_reply (GDBusMessage *method_call_message); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_new_method_error (GDBusMessage *method_call_message, + const gchar *error_name, + const gchar *error_message_format, + ...) G_GNUC_PRINTF(3, 4); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_new_method_error_valist (GDBusMessage *method_call_message, + const gchar *error_name, + const gchar *error_message_format, + va_list var_args); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_new_method_error_literal (GDBusMessage *method_call_message, + const gchar *error_name, + const gchar *error_message); +GIO_AVAILABLE_IN_ALL +gchar *g_dbus_message_print (GDBusMessage *message, + guint indent); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_message_get_locked (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_lock (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_copy (GDBusMessage *message, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusMessageByteOrder g_dbus_message_get_byte_order (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_byte_order (GDBusMessage *message, + GDBusMessageByteOrder byte_order); + +GIO_AVAILABLE_IN_ALL +GDBusMessageType g_dbus_message_get_message_type (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_message_type (GDBusMessage *message, + GDBusMessageType type); +GIO_AVAILABLE_IN_ALL +GDBusMessageFlags g_dbus_message_get_flags (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_flags (GDBusMessage *message, + GDBusMessageFlags flags); +GIO_AVAILABLE_IN_ALL +guint32 g_dbus_message_get_serial (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_serial (GDBusMessage *message, + guint32 serial); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_message_get_header (GDBusMessage *message, + GDBusMessageHeaderField header_field); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_header (GDBusMessage *message, + GDBusMessageHeaderField header_field, + GVariant *value); +GIO_AVAILABLE_IN_ALL +guchar *g_dbus_message_get_header_fields (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_message_get_body (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_body (GDBusMessage *message, + GVariant *body); + +#ifdef G_OS_UNIX + +GIO_AVAILABLE_IN_ALL +GUnixFDList *g_dbus_message_get_unix_fd_list (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_unix_fd_list (GDBusMessage *message, + GUnixFDList *fd_list); + +#endif /* G_OS_UNIX */ + +GIO_AVAILABLE_IN_ALL +guint32 g_dbus_message_get_reply_serial (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_reply_serial (GDBusMessage *message, + guint32 value); + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_message_get_interface (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_interface (GDBusMessage *message, + const gchar *value); + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_message_get_member (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_member (GDBusMessage *message, + const gchar *value); + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_message_get_path (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_path (GDBusMessage *message, + const gchar *value); + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_message_get_sender (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_sender (GDBusMessage *message, + const gchar *value); + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_message_get_destination (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_destination (GDBusMessage *message, + const gchar *value); + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_message_get_error_name (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_error_name (GDBusMessage *message, + const gchar *value); + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_message_get_signature (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_signature (GDBusMessage *message, + const gchar *value); + +GIO_AVAILABLE_IN_ALL +guint32 g_dbus_message_get_num_unix_fds (GDBusMessage *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_message_set_num_unix_fds (GDBusMessage *message, + guint32 value); + +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_message_get_arg0 (GDBusMessage *message); +GIO_AVAILABLE_IN_2_80 +const gchar *g_dbus_message_get_arg0_path (GDBusMessage *message); + +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_message_new_from_blob (guchar *blob, + gsize blob_len, + GDBusCapabilityFlags capabilities, + GError **error); + +GIO_AVAILABLE_IN_ALL +gssize g_dbus_message_bytes_needed (guchar *blob, + gsize blob_len, + GError **error); + +GIO_AVAILABLE_IN_ALL +guchar *g_dbus_message_to_blob (GDBusMessage *message, + gsize *out_size, + GDBusCapabilityFlags capabilities, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_message_to_gerror (GDBusMessage *message, + GError **error); + +G_END_DECLS + +#endif /* __G_DBUS_MESSAGE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmethodinvocation.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmethodinvocation.h new file mode 100644 index 00000000..6266f38a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusmethodinvocation.h @@ -0,0 +1,136 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_METHOD_INVOCATION_H__ +#define __G_DBUS_METHOD_INVOCATION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_METHOD_INVOCATION (g_dbus_method_invocation_get_type ()) +#define G_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_METHOD_INVOCATION, GDBusMethodInvocation)) +#define G_IS_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_METHOD_INVOCATION)) + +/** + * G_DBUS_METHOD_INVOCATION_HANDLED: + * + * The value returned by handlers of the signals generated by + * the `gdbus-codegen` tool to indicate that a method call has been + * handled by an implementation. It is equal to %TRUE, but using + * this macro is sometimes more readable. + * + * In code that needs to be backwards-compatible with older GLib, + * use %TRUE instead, often written like this: + * + * |[ + * g_dbus_method_invocation_return_error (invocation, ...); + * return TRUE; // handled + * ]| + * + * Since: 2.68 + */ +#define G_DBUS_METHOD_INVOCATION_HANDLED TRUE GIO_AVAILABLE_MACRO_IN_2_68 + +/** + * G_DBUS_METHOD_INVOCATION_UNHANDLED: + * + * The value returned by handlers of the signals generated by + * the `gdbus-codegen` tool to indicate that a method call has not been + * handled by an implementation. It is equal to %FALSE, but using + * this macro is sometimes more readable. + * + * In code that needs to be backwards-compatible with older GLib, + * use %FALSE instead. + * + * Since: 2.68 + */ +#define G_DBUS_METHOD_INVOCATION_UNHANDLED FALSE GIO_AVAILABLE_MACRO_IN_2_68 + +GIO_AVAILABLE_IN_ALL +GType g_dbus_method_invocation_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_method_invocation_get_sender (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_method_invocation_get_object_path (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_method_invocation_get_interface_name (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_method_invocation_get_method_name (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_ALL +const GDBusMethodInfo *g_dbus_method_invocation_get_method_info (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_2_38 +const GDBusPropertyInfo *g_dbus_method_invocation_get_property_info (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_method_invocation_get_connection (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_ALL +GDBusMessage *g_dbus_method_invocation_get_message (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_method_invocation_get_parameters (GDBusMethodInvocation *invocation); +GIO_AVAILABLE_IN_ALL +gpointer g_dbus_method_invocation_get_user_data (GDBusMethodInvocation *invocation); + +GIO_AVAILABLE_IN_ALL +void g_dbus_method_invocation_return_value (GDBusMethodInvocation *invocation, + GVariant *parameters); +#ifdef G_OS_UNIX +GIO_AVAILABLE_IN_ALL +void g_dbus_method_invocation_return_value_with_unix_fd_list (GDBusMethodInvocation *invocation, + GVariant *parameters, + GUnixFDList *fd_list); +#endif /* G_OS_UNIX */ +GIO_AVAILABLE_IN_ALL +void g_dbus_method_invocation_return_error (GDBusMethodInvocation *invocation, + GQuark domain, + gint code, + const gchar *format, + ...) G_GNUC_PRINTF(4, 5); +GIO_AVAILABLE_IN_ALL +void g_dbus_method_invocation_return_error_valist (GDBusMethodInvocation *invocation, + GQuark domain, + gint code, + const gchar *format, + va_list var_args) + G_GNUC_PRINTF(4, 0); +GIO_AVAILABLE_IN_ALL +void g_dbus_method_invocation_return_error_literal (GDBusMethodInvocation *invocation, + GQuark domain, + gint code, + const gchar *message); +GIO_AVAILABLE_IN_ALL +void g_dbus_method_invocation_return_gerror (GDBusMethodInvocation *invocation, + const GError *error); +GIO_AVAILABLE_IN_ALL +void g_dbus_method_invocation_take_error (GDBusMethodInvocation *invocation, + GError *error); +GIO_AVAILABLE_IN_ALL +void g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation, + const gchar *error_name, + const gchar *error_message); + +G_END_DECLS + +#endif /* __G_DBUS_METHOD_INVOCATION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusnameowning.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusnameowning.h new file mode 100644 index 00000000..e31bf31e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusnameowning.h @@ -0,0 +1,119 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_NAME_OWNING_H__ +#define __G_DBUS_NAME_OWNING_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * GBusAcquiredCallback: + * @connection: the connection to a message bus + * @name: the name that is requested to be owned + * @user_data: user data passed to [func@Gio.bus_own_name] + * + * Invoked when a connection to a message bus has been obtained. + * + * Since: 2.26 + */ +typedef void (*GBusAcquiredCallback) (GDBusConnection *connection, + const gchar *name, + gpointer user_data); + +/** + * GBusNameAcquiredCallback: + * @connection: the connection on which to acquired the name + * @name: the name being owned + * @user_data: user data passed to [func@Gio.bus_own_name] or + * [func@Gio.bus_own_name_on_connection] + * + * Invoked when the name is acquired. + * + * Since: 2.26 + */ +typedef void (*GBusNameAcquiredCallback) (GDBusConnection *connection, + const gchar *name, + gpointer user_data); + +/** + * GBusNameLostCallback: + * @connection: the connect on which to acquire the name or `NULL` if + * the connection was disconnected + * @name: the name being owned + * @user_data: user data passed to [func@Gio.bus_own_name] or + * [func@Gio.bus_own_name_on_connection] + * + * Invoked when the name is lost or @connection has been closed. + * + * Since: 2.26 + */ +typedef void (*GBusNameLostCallback) (GDBusConnection *connection, + const gchar *name, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +guint g_bus_own_name (GBusType bus_type, + const gchar *name, + GBusNameOwnerFlags flags, + GBusAcquiredCallback bus_acquired_handler, + GBusNameAcquiredCallback name_acquired_handler, + GBusNameLostCallback name_lost_handler, + gpointer user_data, + GDestroyNotify user_data_free_func); + +GIO_AVAILABLE_IN_ALL +guint g_bus_own_name_on_connection (GDBusConnection *connection, + const gchar *name, + GBusNameOwnerFlags flags, + GBusNameAcquiredCallback name_acquired_handler, + GBusNameLostCallback name_lost_handler, + gpointer user_data, + GDestroyNotify user_data_free_func); + +GIO_AVAILABLE_IN_ALL +guint g_bus_own_name_with_closures (GBusType bus_type, + const gchar *name, + GBusNameOwnerFlags flags, + GClosure *bus_acquired_closure, + GClosure *name_acquired_closure, + GClosure *name_lost_closure); + +GIO_AVAILABLE_IN_ALL +guint g_bus_own_name_on_connection_with_closures ( + GDBusConnection *connection, + const gchar *name, + GBusNameOwnerFlags flags, + GClosure *name_acquired_closure, + GClosure *name_lost_closure); + +GIO_AVAILABLE_IN_ALL +void g_bus_unown_name (guint owner_id); + +G_END_DECLS + +#endif /* __G_DBUS_NAME_OWNING_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusnamewatching.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusnamewatching.h new file mode 100644 index 00000000..df836deb --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusnamewatching.h @@ -0,0 +1,104 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_NAME_WATCHING_H__ +#define __G_DBUS_NAME_WATCHING_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * GBusNameAppearedCallback: + * @connection: The #GDBusConnection the name is being watched on. + * @name: The name being watched. + * @name_owner: Unique name of the owner of the name being watched. + * @user_data: User data passed to g_bus_watch_name(). + * + * Invoked when the name being watched is known to have to have an owner. + * + * Since: 2.26 + */ +typedef void (*GBusNameAppearedCallback) (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data); + +/** + * GBusNameVanishedCallback: + * @connection: The #GDBusConnection the name is being watched on, or + * %NULL. + * @name: The name being watched. + * @user_data: User data passed to g_bus_watch_name(). + * + * Invoked when the name being watched is known not to have to have an owner. + * + * This is also invoked when the #GDBusConnection on which the watch was + * established has been closed. In that case, @connection will be + * %NULL. + * + * Since: 2.26 + */ +typedef void (*GBusNameVanishedCallback) (GDBusConnection *connection, + const gchar *name, + gpointer user_data); + + +GIO_AVAILABLE_IN_ALL +guint g_bus_watch_name (GBusType bus_type, + const gchar *name, + GBusNameWatcherFlags flags, + GBusNameAppearedCallback name_appeared_handler, + GBusNameVanishedCallback name_vanished_handler, + gpointer user_data, + GDestroyNotify user_data_free_func); +GIO_AVAILABLE_IN_ALL +guint g_bus_watch_name_on_connection (GDBusConnection *connection, + const gchar *name, + GBusNameWatcherFlags flags, + GBusNameAppearedCallback name_appeared_handler, + GBusNameVanishedCallback name_vanished_handler, + gpointer user_data, + GDestroyNotify user_data_free_func); +GIO_AVAILABLE_IN_ALL +guint g_bus_watch_name_with_closures (GBusType bus_type, + const gchar *name, + GBusNameWatcherFlags flags, + GClosure *name_appeared_closure, + GClosure *name_vanished_closure); +GIO_AVAILABLE_IN_ALL +guint g_bus_watch_name_on_connection_with_closures ( + GDBusConnection *connection, + const gchar *name, + GBusNameWatcherFlags flags, + GClosure *name_appeared_closure, + GClosure *name_vanished_closure); +GIO_AVAILABLE_IN_ALL +void g_bus_unwatch_name (guint watcher_id); + +G_END_DECLS + +#endif /* __G_DBUS_NAME_WATCHING_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobject.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobject.h new file mode 100644 index 00000000..b8186afc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobject.h @@ -0,0 +1,80 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_OBJECT_H__ +#define __G_DBUS_OBJECT_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_OBJECT (g_dbus_object_get_type()) +#define G_DBUS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_OBJECT, GDBusObject)) +#define G_IS_DBUS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_OBJECT)) +#define G_DBUS_OBJECT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), G_TYPE_DBUS_OBJECT, GDBusObjectIface)) + +typedef struct _GDBusObjectIface GDBusObjectIface; + +/** + * GDBusObjectIface: + * @parent_iface: The parent interface. + * @get_object_path: Returns the object path. See g_dbus_object_get_object_path(). + * @get_interfaces: Returns all interfaces. See g_dbus_object_get_interfaces(). + * @get_interface: Returns an interface by name. See g_dbus_object_get_interface(). + * @interface_added: Signal handler for the #GDBusObject::interface-added signal. + * @interface_removed: Signal handler for the #GDBusObject::interface-removed signal. + * + * Base object type for D-Bus objects. + * + * Since: 2.30 + */ +struct _GDBusObjectIface +{ + GTypeInterface parent_iface; + + /* Virtual Functions */ + const gchar *(*get_object_path) (GDBusObject *object); + GList *(*get_interfaces) (GDBusObject *object); + GDBusInterface *(*get_interface) (GDBusObject *object, + const gchar *interface_name); + + /* Signals */ + void (*interface_added) (GDBusObject *object, + GDBusInterface *interface_); + void (*interface_removed) (GDBusObject *object, + GDBusInterface *interface_); + +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_object_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_object_get_object_path (GDBusObject *object); +GIO_AVAILABLE_IN_ALL +GList *g_dbus_object_get_interfaces (GDBusObject *object); +GIO_AVAILABLE_IN_ALL +GDBusInterface *g_dbus_object_get_interface (GDBusObject *object, + const gchar *interface_name); + +G_END_DECLS + +#endif /* __G_DBUS_OBJECT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanager.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanager.h new file mode 100644 index 00000000..7bfa2ae0 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanager.h @@ -0,0 +1,96 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_OBJECT_MANAGER_H__ +#define __G_DBUS_OBJECT_MANAGER_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_OBJECT_MANAGER (g_dbus_object_manager_get_type()) +#define G_DBUS_OBJECT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_OBJECT_MANAGER, GDBusObjectManager)) +#define G_IS_DBUS_OBJECT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_OBJECT_MANAGER)) +#define G_DBUS_OBJECT_MANAGER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), G_TYPE_DBUS_OBJECT_MANAGER, GDBusObjectManagerIface)) + +typedef struct _GDBusObjectManagerIface GDBusObjectManagerIface; + +/** + * GDBusObjectManagerIface: + * @parent_iface: The parent interface. + * @get_object_path: Virtual function for g_dbus_object_manager_get_object_path(). + * @get_objects: Virtual function for g_dbus_object_manager_get_objects(). + * @get_object: Virtual function for g_dbus_object_manager_get_object(). + * @get_interface: Virtual function for g_dbus_object_manager_get_interface(). + * @object_added: Signal handler for the #GDBusObjectManager::object-added signal. + * @object_removed: Signal handler for the #GDBusObjectManager::object-removed signal. + * @interface_added: Signal handler for the #GDBusObjectManager::interface-added signal. + * @interface_removed: Signal handler for the #GDBusObjectManager::interface-removed signal. + * + * Base type for D-Bus object managers. + * + * Since: 2.30 + */ +struct _GDBusObjectManagerIface +{ + GTypeInterface parent_iface; + + /* Virtual Functions */ + const gchar *(*get_object_path) (GDBusObjectManager *manager); + GList *(*get_objects) (GDBusObjectManager *manager); + GDBusObject *(*get_object) (GDBusObjectManager *manager, + const gchar *object_path); + GDBusInterface *(*get_interface) (GDBusObjectManager *manager, + const gchar *object_path, + const gchar *interface_name); + + /* Signals */ + void (*object_added) (GDBusObjectManager *manager, + GDBusObject *object); + void (*object_removed) (GDBusObjectManager *manager, + GDBusObject *object); + + void (*interface_added) (GDBusObjectManager *manager, + GDBusObject *object, + GDBusInterface *interface_); + void (*interface_removed) (GDBusObjectManager *manager, + GDBusObject *object, + GDBusInterface *interface_); +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_object_manager_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_object_manager_get_object_path (GDBusObjectManager *manager); +GIO_AVAILABLE_IN_ALL +GList *g_dbus_object_manager_get_objects (GDBusObjectManager *manager); +GIO_AVAILABLE_IN_ALL +GDBusObject *g_dbus_object_manager_get_object (GDBusObjectManager *manager, + const gchar *object_path); +GIO_AVAILABLE_IN_ALL +GDBusInterface *g_dbus_object_manager_get_interface (GDBusObjectManager *manager, + const gchar *object_path, + const gchar *interface_name); + +G_END_DECLS + +#endif /* __G_DBUS_OBJECT_MANAGER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanagerclient.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanagerclient.h new file mode 100644 index 00000000..f02c6938 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanagerclient.h @@ -0,0 +1,140 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_OBJECT_MANAGER_CLIENT_H__ +#define __G_DBUS_OBJECT_MANAGER_CLIENT_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_OBJECT_MANAGER_CLIENT (g_dbus_object_manager_client_get_type ()) +#define G_DBUS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_OBJECT_MANAGER_CLIENT, GDBusObjectManagerClient)) +#define G_DBUS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_OBJECT_MANAGER_CLIENT, GDBusObjectManagerClientClass)) +#define G_DBUS_OBJECT_MANAGER_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_OBJECT_MANAGER_CLIENT, GDBusObjectManagerClientClass)) +#define G_IS_DBUS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_OBJECT_MANAGER_CLIENT)) +#define G_IS_DBUS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_OBJECT_MANAGER_CLIENT)) + +typedef struct _GDBusObjectManagerClientClass GDBusObjectManagerClientClass; +typedef struct _GDBusObjectManagerClientPrivate GDBusObjectManagerClientPrivate; + +struct _GDBusObjectManagerClient +{ + /*< private >*/ + GObject parent_instance; + GDBusObjectManagerClientPrivate *priv; +}; + +/** + * GDBusObjectManagerClientClass: + * @parent_class: The parent class. + * @interface_proxy_signal: Signal class handler for the #GDBusObjectManagerClient::interface-proxy-signal signal. + * @interface_proxy_properties_changed: Signal class handler for the #GDBusObjectManagerClient::interface-proxy-properties-changed signal. + * + * Class structure for #GDBusObjectManagerClient. + * + * Since: 2.30 + */ +struct _GDBusObjectManagerClientClass +{ + GObjectClass parent_class; + + /* signals */ + void (*interface_proxy_signal) (GDBusObjectManagerClient *manager, + GDBusObjectProxy *object_proxy, + GDBusProxy *interface_proxy, + const gchar *sender_name, + const gchar *signal_name, + GVariant *parameters); + + void (*interface_proxy_properties_changed) (GDBusObjectManagerClient *manager, + GDBusObjectProxy *object_proxy, + GDBusProxy *interface_proxy, + GVariant *changed_properties, + const gchar* const *invalidated_properties); + + /*< private >*/ + gpointer padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_object_manager_client_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +void g_dbus_object_manager_client_new (GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GDBusProxyTypeFunc get_proxy_type_func, + gpointer get_proxy_type_user_data, + GDestroyNotify get_proxy_type_destroy_notify, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GDBusObjectManager *g_dbus_object_manager_client_new_finish (GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusObjectManager *g_dbus_object_manager_client_new_sync (GDBusConnection *connection, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GDBusProxyTypeFunc get_proxy_type_func, + gpointer get_proxy_type_user_data, + GDestroyNotify get_proxy_type_destroy_notify, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_manager_client_new_for_bus (GBusType bus_type, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GDBusProxyTypeFunc get_proxy_type_func, + gpointer get_proxy_type_user_data, + GDestroyNotify get_proxy_type_destroy_notify, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GDBusObjectManager *g_dbus_object_manager_client_new_for_bus_finish (GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusObjectManager *g_dbus_object_manager_client_new_for_bus_sync (GBusType bus_type, + GDBusObjectManagerClientFlags flags, + const gchar *name, + const gchar *object_path, + GDBusProxyTypeFunc get_proxy_type_func, + gpointer get_proxy_type_user_data, + GDestroyNotify get_proxy_type_destroy_notify, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_object_manager_client_get_connection (GDBusObjectManagerClient *manager); +GIO_AVAILABLE_IN_ALL +GDBusObjectManagerClientFlags g_dbus_object_manager_client_get_flags (GDBusObjectManagerClient *manager); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_object_manager_client_get_name (GDBusObjectManagerClient *manager); +GIO_AVAILABLE_IN_ALL +gchar *g_dbus_object_manager_client_get_name_owner (GDBusObjectManagerClient *manager); + +G_END_DECLS + +#endif /* __G_DBUS_OBJECT_MANAGER_CLIENT_H */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanagerserver.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanagerserver.h new file mode 100644 index 00000000..a4b7418f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectmanagerserver.h @@ -0,0 +1,87 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_OBJECT_MANAGER_SERVER_H__ +#define __G_DBUS_OBJECT_MANAGER_SERVER_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_OBJECT_MANAGER_SERVER (g_dbus_object_manager_server_get_type ()) +#define G_DBUS_OBJECT_MANAGER_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_OBJECT_MANAGER_SERVER, GDBusObjectManagerServer)) +#define G_DBUS_OBJECT_MANAGER_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_OBJECT_MANAGER_SERVER, GDBusObjectManagerServerClass)) +#define G_DBUS_OBJECT_MANAGER_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_OBJECT_MANAGER_SERVER, GDBusObjectManagerServerClass)) +#define G_IS_DBUS_OBJECT_MANAGER_SERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_OBJECT_MANAGER_SERVER)) +#define G_IS_DBUS_OBJECT_MANAGER_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_OBJECT_MANAGER_SERVER)) + +typedef struct _GDBusObjectManagerServerClass GDBusObjectManagerServerClass; +typedef struct _GDBusObjectManagerServerPrivate GDBusObjectManagerServerPrivate; + +struct _GDBusObjectManagerServer +{ + /*< private >*/ + GObject parent_instance; + GDBusObjectManagerServerPrivate *priv; +}; + +/** + * GDBusObjectManagerServerClass: + * @parent_class: The parent class. + * + * Class structure for #GDBusObjectManagerServer. + * + * Since: 2.30 + */ +struct _GDBusObjectManagerServerClass +{ + GObjectClass parent_class; + + /*< private >*/ + gpointer padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_object_manager_server_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDBusObjectManagerServer *g_dbus_object_manager_server_new (const gchar *object_path); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_object_manager_server_get_connection (GDBusObjectManagerServer *manager); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_manager_server_set_connection (GDBusObjectManagerServer *manager, + GDBusConnection *connection); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_manager_server_export (GDBusObjectManagerServer *manager, + GDBusObjectSkeleton *object); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager, + GDBusObjectSkeleton *object); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_object_manager_server_is_exported (GDBusObjectManagerServer *manager, + GDBusObjectSkeleton *object); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_object_manager_server_unexport (GDBusObjectManagerServer *manager, + const gchar *object_path); + +G_END_DECLS + +#endif /* __G_DBUS_OBJECT_MANAGER_SERVER_H */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectproxy.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectproxy.h new file mode 100644 index 00000000..8397dba3 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectproxy.h @@ -0,0 +1,73 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_OBJECT_PROXY_H__ +#define __G_DBUS_OBJECT_PROXY_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_OBJECT_PROXY (g_dbus_object_proxy_get_type ()) +#define G_DBUS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_OBJECT_PROXY, GDBusObjectProxy)) +#define G_DBUS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_OBJECT_PROXY, GDBusObjectProxyClass)) +#define G_DBUS_OBJECT_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_OBJECT_PROXY, GDBusObjectProxyClass)) +#define G_IS_DBUS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_OBJECT_PROXY)) +#define G_IS_DBUS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_OBJECT_PROXY)) + +typedef struct _GDBusObjectProxyClass GDBusObjectProxyClass; +typedef struct _GDBusObjectProxyPrivate GDBusObjectProxyPrivate; + +struct _GDBusObjectProxy +{ + /*< private >*/ + GObject parent_instance; + GDBusObjectProxyPrivate *priv; +}; + +/** + * GDBusObjectProxyClass: + * @parent_class: The parent class. + * + * Class structure for #GDBusObjectProxy. + * + * Since: 2.30 + */ +struct _GDBusObjectProxyClass +{ + GObjectClass parent_class; + + /*< private >*/ + gpointer padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_object_proxy_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDBusObjectProxy *g_dbus_object_proxy_new (GDBusConnection *connection, + const gchar *object_path); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_object_proxy_get_connection (GDBusObjectProxy *proxy); + +G_END_DECLS + +#endif /* __G_DBUS_OBJECT_PROXY_H */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectskeleton.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectskeleton.h new file mode 100644 index 00000000..f902d54b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusobjectskeleton.h @@ -0,0 +1,90 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_OBJECT_SKELETON_H__ +#define __G_DBUS_OBJECT_SKELETON_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_OBJECT_SKELETON (g_dbus_object_skeleton_get_type ()) +#define G_DBUS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_OBJECT_SKELETON, GDBusObjectSkeleton)) +#define G_DBUS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_OBJECT_SKELETON, GDBusObjectSkeletonClass)) +#define G_DBUS_OBJECT_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_OBJECT_SKELETON, GDBusObjectSkeletonClass)) +#define G_IS_DBUS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_OBJECT_SKELETON)) +#define G_IS_DBUS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_OBJECT_SKELETON)) + +typedef struct _GDBusObjectSkeletonClass GDBusObjectSkeletonClass; +typedef struct _GDBusObjectSkeletonPrivate GDBusObjectSkeletonPrivate; + +struct _GDBusObjectSkeleton +{ + /*< private >*/ + GObject parent_instance; + GDBusObjectSkeletonPrivate *priv; +}; + +/** + * GDBusObjectSkeletonClass: + * @parent_class: The parent class. + * @authorize_method: Signal class handler for the #GDBusObjectSkeleton::authorize-method signal. + * + * Class structure for #GDBusObjectSkeleton. + * + * Since: 2.30 + */ +struct _GDBusObjectSkeletonClass +{ + GObjectClass parent_class; + + /* Signals */ + gboolean (*authorize_method) (GDBusObjectSkeleton *object, + GDBusInterfaceSkeleton *interface_, + GDBusMethodInvocation *invocation); + + /*< private >*/ + gpointer padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_object_skeleton_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDBusObjectSkeleton *g_dbus_object_skeleton_new (const gchar *object_path); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_skeleton_flush (GDBusObjectSkeleton *object); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_skeleton_add_interface (GDBusObjectSkeleton *object, + GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_skeleton_remove_interface (GDBusObjectSkeleton *object, + GDBusInterfaceSkeleton *interface_); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_skeleton_remove_interface_by_name (GDBusObjectSkeleton *object, + const gchar *interface_name); +GIO_AVAILABLE_IN_ALL +void g_dbus_object_skeleton_set_object_path (GDBusObjectSkeleton *object, + const gchar *object_path); + +G_END_DECLS + +#endif /* __G_DBUS_OBJECT_SKELETON_H */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusproxy.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusproxy.h new file mode 100644 index 00000000..d74cf759 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusproxy.h @@ -0,0 +1,212 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_PROXY_H__ +#define __G_DBUS_PROXY_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_PROXY (g_dbus_proxy_get_type ()) +#define G_DBUS_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_PROXY, GDBusProxy)) +#define G_DBUS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_PROXY, GDBusProxyClass)) +#define G_DBUS_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_PROXY, GDBusProxyClass)) +#define G_IS_DBUS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_PROXY)) +#define G_IS_DBUS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_PROXY)) + +typedef struct _GDBusProxyClass GDBusProxyClass; +typedef struct _GDBusProxyPrivate GDBusProxyPrivate; + +struct _GDBusProxy +{ + /*< private >*/ + GObject parent_instance; + GDBusProxyPrivate *priv; +}; + +/** + * GDBusProxyClass: + * @g_properties_changed: Signal class handler for the #GDBusProxy::g-properties-changed signal. + * @g_signal: Signal class handler for the #GDBusProxy::g-signal signal. + * + * Class structure for #GDBusProxy. + * + * Since: 2.26 + */ +struct _GDBusProxyClass +{ + /*< private >*/ + GObjectClass parent_class; + + /*< public >*/ + /* Signals */ + void (*g_properties_changed) (GDBusProxy *proxy, + GVariant *changed_properties, + const gchar* const *invalidated_properties); + void (*g_signal) (GDBusProxy *proxy, + const gchar *sender_name, + const gchar *signal_name, + GVariant *parameters); + + /*< private >*/ + /* Padding for future expansion */ + gpointer padding[32]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_dbus_proxy_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +void g_dbus_proxy_new (GDBusConnection *connection, + GDBusProxyFlags flags, + GDBusInterfaceInfo *info, + const gchar *name, + const gchar *object_path, + const gchar *interface_name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GDBusProxy *g_dbus_proxy_new_finish (GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusProxy *g_dbus_proxy_new_sync (GDBusConnection *connection, + GDBusProxyFlags flags, + GDBusInterfaceInfo *info, + const gchar *name, + const gchar *object_path, + const gchar *interface_name, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_dbus_proxy_new_for_bus (GBusType bus_type, + GDBusProxyFlags flags, + GDBusInterfaceInfo *info, + const gchar *name, + const gchar *object_path, + const gchar *interface_name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GDBusProxy *g_dbus_proxy_new_for_bus_finish (GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusProxy *g_dbus_proxy_new_for_bus_sync (GBusType bus_type, + GDBusProxyFlags flags, + GDBusInterfaceInfo *info, + const gchar *name, + const gchar *object_path, + const gchar *interface_name, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GDBusConnection *g_dbus_proxy_get_connection (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +GDBusProxyFlags g_dbus_proxy_get_flags (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_proxy_get_name (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +gchar *g_dbus_proxy_get_name_owner (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_proxy_get_object_path (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_proxy_get_interface_name (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +gint g_dbus_proxy_get_default_timeout (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +void g_dbus_proxy_set_default_timeout (GDBusProxy *proxy, + gint timeout_msec); +GIO_AVAILABLE_IN_ALL +GDBusInterfaceInfo *g_dbus_proxy_get_interface_info (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +void g_dbus_proxy_set_interface_info (GDBusProxy *proxy, + GDBusInterfaceInfo *info); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_proxy_get_cached_property (GDBusProxy *proxy, + const gchar *property_name); +GIO_AVAILABLE_IN_ALL +void g_dbus_proxy_set_cached_property (GDBusProxy *proxy, + const gchar *property_name, + GVariant *value); +GIO_AVAILABLE_IN_ALL +gchar **g_dbus_proxy_get_cached_property_names (GDBusProxy *proxy); +GIO_AVAILABLE_IN_ALL +void g_dbus_proxy_call (GDBusProxy *proxy, + const gchar *method_name, + GVariant *parameters, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_proxy_call_finish (GDBusProxy *proxy, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_proxy_call_sync (GDBusProxy *proxy, + const gchar *method_name, + GVariant *parameters, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GError **error); + +#ifdef G_OS_UNIX + +GIO_AVAILABLE_IN_ALL +void g_dbus_proxy_call_with_unix_fd_list (GDBusProxy *proxy, + const gchar *method_name, + GVariant *parameters, + GDBusCallFlags flags, + gint timeout_msec, + GUnixFDList *fd_list, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_proxy_call_with_unix_fd_list_finish (GDBusProxy *proxy, + GUnixFDList **out_fd_list, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_proxy_call_with_unix_fd_list_sync (GDBusProxy *proxy, + const gchar *method_name, + GVariant *parameters, + GDBusCallFlags flags, + gint timeout_msec, + GUnixFDList *fd_list, + GUnixFDList **out_fd_list, + GCancellable *cancellable, + GError **error); + +#endif /* G_OS_UNIX */ + +G_END_DECLS + +#endif /* __G_DBUS_PROXY_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusserver.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusserver.h new file mode 100644 index 00000000..8d460e36 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusserver.h @@ -0,0 +1,62 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_SERVER_H__ +#define __G_DBUS_SERVER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DBUS_SERVER (g_dbus_server_get_type ()) +#define G_DBUS_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_SERVER, GDBusServer)) +#define G_IS_DBUS_SERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_SERVER)) + +GIO_AVAILABLE_IN_ALL +GType g_dbus_server_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GDBusServer *g_dbus_server_new_sync (const gchar *address, + GDBusServerFlags flags, + const gchar *guid, + GDBusAuthObserver *observer, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_server_get_client_address (GDBusServer *server); +GIO_AVAILABLE_IN_ALL +const gchar *g_dbus_server_get_guid (GDBusServer *server); +GIO_AVAILABLE_IN_ALL +GDBusServerFlags g_dbus_server_get_flags (GDBusServer *server); +GIO_AVAILABLE_IN_ALL +void g_dbus_server_start (GDBusServer *server); +GIO_AVAILABLE_IN_ALL +void g_dbus_server_stop (GDBusServer *server); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_server_is_active (GDBusServer *server); + +G_END_DECLS + +#endif /* __G_DBUS_SERVER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdbusutils.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusutils.h new file mode 100644 index 00000000..3003b716 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdbusutils.h @@ -0,0 +1,65 @@ +/* GDBus - GLib D-Bus Library + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: David Zeuthen + */ + +#ifndef __G_DBUS_UTILS_H__ +#define __G_DBUS_UTILS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_is_guid (const gchar *string); +GIO_AVAILABLE_IN_ALL +gchar *g_dbus_generate_guid (void); + +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_is_name (const gchar *string); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_is_unique_name (const gchar *string); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_is_member_name (const gchar *string); +GIO_AVAILABLE_IN_ALL +gboolean g_dbus_is_interface_name (const gchar *string); +GIO_AVAILABLE_IN_2_70 +gboolean g_dbus_is_error_name (const gchar *string); + +GIO_AVAILABLE_IN_ALL +void g_dbus_gvariant_to_gvalue (GVariant *value, + GValue *out_gvalue); +GIO_AVAILABLE_IN_ALL +GVariant *g_dbus_gvalue_to_gvariant (const GValue *gvalue, + const GVariantType *type); +GIO_AVAILABLE_IN_2_68 +gchar *g_dbus_escape_object_path_bytestring (const guint8 *bytes); +GIO_AVAILABLE_IN_2_68 +gchar *g_dbus_escape_object_path (const gchar *s); +GIO_AVAILABLE_IN_2_68 +guint8 *g_dbus_unescape_object_path (const gchar *s); + +G_END_DECLS + +#endif /* __G_DBUS_UTILS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdebugcontroller.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdebugcontroller.h new file mode 100644 index 00000000..6acfc39a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdebugcontroller.h @@ -0,0 +1,73 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2021 Endless OS Foundation, LLC + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef __G_DEBUG_CONTROLLER_H__ +#define __G_DEBUG_CONTROLLER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_DEBUG_CONTROLLER_EXTENSION_POINT_NAME: + * + * Extension point for debug control functionality. + * See [Extending GIO](overview.html#extending-gio). + * + * Since: 2.72 + */ +#define G_DEBUG_CONTROLLER_EXTENSION_POINT_NAME "gio-debug-controller" + +#define G_TYPE_DEBUG_CONTROLLER (g_debug_controller_get_type ()) +GIO_AVAILABLE_IN_2_72 +G_DECLARE_INTERFACE(GDebugController, g_debug_controller, g, debug_controller, GObject) + +#define G_DEBUG_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DEBUG_CONTROLLER, GDebugController)) +#define G_IS_DEBUG_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DEBUG_CONTROLLER)) +#define G_DEBUG_CONTROLLER_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), G_TYPE_DEBUG_CONTROLLER, GDebugControllerInterface)) + +/** + * GDebugControllerInterface: + * @g_iface: The parent interface. + * + * The virtual function table for #GDebugController. + * + * Since: 2.72 + */ +struct _GDebugControllerInterface { + /*< private >*/ + GTypeInterface g_iface; +}; + +GIO_AVAILABLE_IN_2_72 +gboolean g_debug_controller_get_debug_enabled (GDebugController *self); +GIO_AVAILABLE_IN_2_72 +void g_debug_controller_set_debug_enabled (GDebugController *self, + gboolean debug_enabled); + +G_END_DECLS + +#endif /* __G_DEBUG_CONTROLLER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdebugcontrollerdbus.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdebugcontrollerdbus.h new file mode 100644 index 00000000..17e36586 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdebugcontrollerdbus.h @@ -0,0 +1,64 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2021 Endless OS Foundation, LLC + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef __G_DEBUG_CONTROLLER_DBUS_H__ +#define __G_DEBUG_CONTROLLER_DBUS_H__ + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_DEBUG_CONTROLLER_DBUS (g_debug_controller_dbus_get_type ()) +GIO_AVAILABLE_IN_2_72 +G_DECLARE_DERIVABLE_TYPE (GDebugControllerDBus, g_debug_controller_dbus, G, DEBUG_CONTROLLER_DBUS, GObject) + +/** + * GDebugControllerDBusClass: + * @parent_class: The parent class. + * @authorize: Default handler for the #GDebugControllerDBus::authorize signal. + * + * The virtual function table for #GDebugControllerDBus. + * + * Since: 2.72 + */ +struct _GDebugControllerDBusClass +{ + GObjectClass parent_class; + + gboolean (*authorize) (GDebugControllerDBus *controller, + GDBusMethodInvocation *invocation); + + gpointer padding[12]; +}; + +GIO_AVAILABLE_IN_2_72 +GDebugControllerDBus *g_debug_controller_dbus_new (GDBusConnection *connection, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_72 +void g_debug_controller_dbus_stop (GDebugControllerDBus *self); + +G_END_DECLS + +#endif /* __G_DEBUG_CONTROLLER_DBUS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdrive.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdrive.h new file mode 100644 index 00000000..7551a402 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdrive.h @@ -0,0 +1,274 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + * David Zeuthen + */ + +#ifndef __G_DRIVE_H__ +#define __G_DRIVE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE: + * + * The string used to obtain a Unix device path with g_drive_get_identifier(). + * + * Since: 2.58 + */ +#define G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE "unix-device" + +#define G_TYPE_DRIVE (g_drive_get_type ()) +#define G_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive)) +#define G_IS_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE)) +#define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface)) + +/** + * GDriveIface: + * @g_iface: The parent interface. + * @changed: Signal emitted when the drive is changed. + * @disconnected: The removed signal that is emitted when the #GDrive have been disconnected. If the recipient is holding references to the object they should release them so the object can be finalized. + * @eject_button: Signal emitted when the physical eject button (if any) of a drive have been pressed. + * @get_name: Returns the name for the given #GDrive. + * @get_icon: Returns a #GIcon for the given #GDrive. + * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes. + * @get_volumes: Returns a list #GList of #GVolume for the #GDrive. + * @is_removable: Returns %TRUE if the #GDrive and/or its media is considered removable by the user. Since 2.50. + * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media. + * @has_media: Returns %TRUE if the #GDrive has media inserted. + * @is_media_check_automatic: Returns %TRUE if the #GDrive is capable of automatically detecting media changes. + * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change. + * @can_eject: Returns %TRUE if the #GDrive can eject media. + * @eject: Ejects a #GDrive. + * @eject_finish: Finishes an eject operation. + * @poll_for_media: Poll for media insertion/removal on a #GDrive. + * @poll_for_media_finish: Finishes a media poll operation. + * @get_identifier: Returns the identifier of the given kind, or %NULL if + * the #GDrive doesn't have one. + * @enumerate_identifiers: Returns an array strings listing the kinds + * of identifiers which the #GDrive has. + * @get_start_stop_type: Gets a #GDriveStartStopType with details about starting/stopping the drive. Since 2.22. + * @can_stop: Returns %TRUE if a #GDrive can be stopped. Since 2.22. + * @stop: Stops a #GDrive. Since 2.22. + * @stop_finish: Finishes a stop operation. Since 2.22. + * @can_start: Returns %TRUE if a #GDrive can be started. Since 2.22. + * @can_start_degraded: Returns %TRUE if a #GDrive can be started degraded. Since 2.22. + * @start: Starts a #GDrive. Since 2.22. + * @start_finish: Finishes a start operation. Since 2.22. + * @stop_button: Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22. + * @eject_with_operation: Starts ejecting a #GDrive using a #GMountOperation. Since 2.22. + * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22. + * @get_sort_key: Gets a key used for sorting #GDrive instances or %NULL if no such key exists. Since 2.32. + * @get_symbolic_icon: Returns a symbolic #GIcon for the given #GDrive. Since 2.34. + * + * Interface for creating #GDrive implementations. + */ +typedef struct _GDriveIface GDriveIface; + +struct _GDriveIface +{ + GTypeInterface g_iface; + + /* signals */ + void (* changed) (GDrive *drive); + void (* disconnected) (GDrive *drive); + void (* eject_button) (GDrive *drive); + + /* Virtual Table */ + char * (* get_name) (GDrive *drive); + GIcon * (* get_icon) (GDrive *drive); + gboolean (* has_volumes) (GDrive *drive); + GList * (* get_volumes) (GDrive *drive); + gboolean (* is_media_removable) (GDrive *drive); + gboolean (* has_media) (GDrive *drive); + gboolean (* is_media_check_automatic) (GDrive *drive); + gboolean (* can_eject) (GDrive *drive); + gboolean (* can_poll_for_media) (GDrive *drive); + void (* eject) (GDrive *drive, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* eject_finish) (GDrive *drive, + GAsyncResult *result, + GError **error); + void (* poll_for_media) (GDrive *drive, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* poll_for_media_finish) (GDrive *drive, + GAsyncResult *result, + GError **error); + + char * (* get_identifier) (GDrive *drive, + const char *kind); + char ** (* enumerate_identifiers) (GDrive *drive); + + GDriveStartStopType (* get_start_stop_type) (GDrive *drive); + + gboolean (* can_start) (GDrive *drive); + gboolean (* can_start_degraded) (GDrive *drive); + void (* start) (GDrive *drive, + GDriveStartFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* start_finish) (GDrive *drive, + GAsyncResult *result, + GError **error); + + gboolean (* can_stop) (GDrive *drive); + void (* stop) (GDrive *drive, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* stop_finish) (GDrive *drive, + GAsyncResult *result, + GError **error); + /* signal, not VFunc */ + void (* stop_button) (GDrive *drive); + + void (* eject_with_operation) (GDrive *drive, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* eject_with_operation_finish) (GDrive *drive, + GAsyncResult *result, + GError **error); + + const gchar * (* get_sort_key) (GDrive *drive); + GIcon * (* get_symbolic_icon) (GDrive *drive); + gboolean (* is_removable) (GDrive *drive); + +}; + +GIO_AVAILABLE_IN_ALL +GType g_drive_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +char * g_drive_get_name (GDrive *drive); +GIO_AVAILABLE_IN_ALL +GIcon * g_drive_get_icon (GDrive *drive); +GIO_AVAILABLE_IN_ALL +GIcon * g_drive_get_symbolic_icon (GDrive *drive); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_has_volumes (GDrive *drive); +GIO_AVAILABLE_IN_ALL +GList * g_drive_get_volumes (GDrive *drive); +GIO_AVAILABLE_IN_2_50 +gboolean g_drive_is_removable (GDrive *drive); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_is_media_removable (GDrive *drive); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_has_media (GDrive *drive); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_is_media_check_automatic (GDrive *drive); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_can_poll_for_media (GDrive *drive); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_can_eject (GDrive *drive); +GIO_DEPRECATED_FOR(g_drive_eject_with_operation) +void g_drive_eject (GDrive *drive, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_DEPRECATED_FOR(g_drive_eject_with_operation_finish) +gboolean g_drive_eject_finish (GDrive *drive, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_drive_poll_for_media (GDrive *drive, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_poll_for_media_finish (GDrive *drive, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +char * g_drive_get_identifier (GDrive *drive, + const char *kind); +GIO_AVAILABLE_IN_ALL +char ** g_drive_enumerate_identifiers (GDrive *drive); + +GIO_AVAILABLE_IN_ALL +GDriveStartStopType g_drive_get_start_stop_type (GDrive *drive); + +GIO_AVAILABLE_IN_ALL +gboolean g_drive_can_start (GDrive *drive); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_can_start_degraded (GDrive *drive); +GIO_AVAILABLE_IN_ALL +void g_drive_start (GDrive *drive, + GDriveStartFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_start_finish (GDrive *drive, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_drive_can_stop (GDrive *drive); +GIO_AVAILABLE_IN_ALL +void g_drive_stop (GDrive *drive, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_stop_finish (GDrive *drive, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_drive_eject_with_operation (GDrive *drive, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_drive_eject_with_operation_finish (GDrive *drive, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_32 +const gchar *g_drive_get_sort_key (GDrive *drive); + +G_END_DECLS + +#endif /* __G_DRIVE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsclientconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsclientconnection.h new file mode 100644 index 00000000..f8ee1f49 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsclientconnection.h @@ -0,0 +1,77 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2010 Red Hat, Inc. + * Copyright © 2015 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_DTLS_CLIENT_CONNECTION_H__ +#define __G_DTLS_CLIENT_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DTLS_CLIENT_CONNECTION (g_dtls_client_connection_get_type ()) +#define G_DTLS_CLIENT_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_DTLS_CLIENT_CONNECTION, GDtlsClientConnection)) +#define G_IS_DTLS_CLIENT_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_DTLS_CLIENT_CONNECTION)) +#define G_DTLS_CLIENT_CONNECTION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_DTLS_CLIENT_CONNECTION, GDtlsClientConnectionInterface)) + +typedef struct _GDtlsClientConnectionInterface GDtlsClientConnectionInterface; + +/** + * GDtlsClientConnectionInterface: + * @g_iface: The parent interface. + * + * vtable for a #GDtlsClientConnection implementation. + * + * Since: 2.48 + */ +struct _GDtlsClientConnectionInterface +{ + GTypeInterface g_iface; +}; + +GIO_AVAILABLE_IN_2_48 +GType g_dtls_client_connection_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_48 +GDatagramBased *g_dtls_client_connection_new (GDatagramBased *base_socket, + GSocketConnectable *server_identity, + GError **error); + +GIO_AVAILABLE_IN_2_48 +GTlsCertificateFlags g_dtls_client_connection_get_validation_flags (GDtlsClientConnection *conn); +GIO_AVAILABLE_IN_2_48 +void g_dtls_client_connection_set_validation_flags (GDtlsClientConnection *conn, + GTlsCertificateFlags flags); +GIO_AVAILABLE_IN_2_48 +GSocketConnectable *g_dtls_client_connection_get_server_identity (GDtlsClientConnection *conn); +GIO_AVAILABLE_IN_2_48 +void g_dtls_client_connection_set_server_identity (GDtlsClientConnection *conn, + GSocketConnectable *identity); +GIO_AVAILABLE_IN_2_48 +GList * g_dtls_client_connection_get_accepted_cas (GDtlsClientConnection *conn); + + +G_END_DECLS + +#endif /* __G_DTLS_CLIENT_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsconnection.h new file mode 100644 index 00000000..c7513ee9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsconnection.h @@ -0,0 +1,230 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2010 Red Hat, Inc. + * Copyright © 2015 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_DTLS_CONNECTION_H__ +#define __G_DTLS_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DTLS_CONNECTION (g_dtls_connection_get_type ()) +#define G_DTLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_DTLS_CONNECTION, GDtlsConnection)) +#define G_IS_DTLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_DTLS_CONNECTION)) +#define G_DTLS_CONNECTION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_DTLS_CONNECTION, GDtlsConnectionInterface)) + +typedef struct _GDtlsConnectionInterface GDtlsConnectionInterface; + +/** + * GDtlsConnectionInterface: + * @g_iface: The parent interface. + * @accept_certificate: Check whether to accept a certificate. + * @handshake: Perform a handshake operation. + * @handshake_async: Start an asynchronous handshake operation. + * @handshake_finish: Finish an asynchronous handshake operation. + * @shutdown: Shut down one or both directions of the connection. + * @shutdown_async: Start an asynchronous shutdown operation. + * @shutdown_finish: Finish an asynchronous shutdown operation. + * @set_advertised_protocols: Set APLN protocol list (Since: 2.60) + * @get_negotiated_protocol: Get ALPN-negotiated protocol (Since: 2.60) + * @get_binding_data: Retrieve TLS channel binding data (Since: 2.66) + * + * Virtual method table for a #GDtlsConnection implementation. + * + * Since: 2.48 + */ +struct _GDtlsConnectionInterface +{ + GTypeInterface g_iface; + + /* signals */ + gboolean (*accept_certificate) (GDtlsConnection *connection, + GTlsCertificate *peer_cert, + GTlsCertificateFlags errors); + + /* methods */ + gboolean (*handshake) (GDtlsConnection *conn, + GCancellable *cancellable, + GError **error); + + void (*handshake_async) (GDtlsConnection *conn, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*handshake_finish) (GDtlsConnection *conn, + GAsyncResult *result, + GError **error); + + gboolean (*shutdown) (GDtlsConnection *conn, + gboolean shutdown_read, + gboolean shutdown_write, + GCancellable *cancellable, + GError **error); + + void (*shutdown_async) (GDtlsConnection *conn, + gboolean shutdown_read, + gboolean shutdown_write, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*shutdown_finish) (GDtlsConnection *conn, + GAsyncResult *result, + GError **error); + + void (*set_advertised_protocols) (GDtlsConnection *conn, + const gchar * const *protocols); + const gchar *(*get_negotiated_protocol) (GDtlsConnection *conn); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + gboolean (*get_binding_data) (GDtlsConnection *conn, + GTlsChannelBindingType type, + GByteArray *data, + GError **error); +G_GNUC_END_IGNORE_DEPRECATIONS +}; + +GIO_AVAILABLE_IN_2_48 +GType g_dtls_connection_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_48 +void g_dtls_connection_set_database (GDtlsConnection *conn, + GTlsDatabase *database); +GIO_AVAILABLE_IN_2_48 +GTlsDatabase *g_dtls_connection_get_database (GDtlsConnection *conn); + +GIO_AVAILABLE_IN_2_48 +void g_dtls_connection_set_certificate (GDtlsConnection *conn, + GTlsCertificate *certificate); +GIO_AVAILABLE_IN_2_48 +GTlsCertificate *g_dtls_connection_get_certificate (GDtlsConnection *conn); + +GIO_AVAILABLE_IN_2_48 +void g_dtls_connection_set_interaction (GDtlsConnection *conn, + GTlsInteraction *interaction); +GIO_AVAILABLE_IN_2_48 +GTlsInteraction *g_dtls_connection_get_interaction (GDtlsConnection *conn); + +GIO_AVAILABLE_IN_2_48 +GTlsCertificate *g_dtls_connection_get_peer_certificate (GDtlsConnection *conn); +GIO_AVAILABLE_IN_2_48 +GTlsCertificateFlags g_dtls_connection_get_peer_certificate_errors (GDtlsConnection *conn); + +GIO_AVAILABLE_IN_2_48 +void g_dtls_connection_set_require_close_notify (GDtlsConnection *conn, + gboolean require_close_notify); +GIO_AVAILABLE_IN_2_48 +gboolean g_dtls_connection_get_require_close_notify (GDtlsConnection *conn); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GIO_DEPRECATED_IN_2_60 +void g_dtls_connection_set_rehandshake_mode (GDtlsConnection *conn, + GTlsRehandshakeMode mode); +GIO_DEPRECATED_IN_2_60 +GTlsRehandshakeMode g_dtls_connection_get_rehandshake_mode (GDtlsConnection *conn); +G_GNUC_END_IGNORE_DEPRECATIONS + +GIO_AVAILABLE_IN_2_48 +gboolean g_dtls_connection_handshake (GDtlsConnection *conn, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_48 +void g_dtls_connection_handshake_async (GDtlsConnection *conn, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_48 +gboolean g_dtls_connection_handshake_finish (GDtlsConnection *conn, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_48 +gboolean g_dtls_connection_shutdown (GDtlsConnection *conn, + gboolean shutdown_read, + gboolean shutdown_write, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_48 +void g_dtls_connection_shutdown_async (GDtlsConnection *conn, + gboolean shutdown_read, + gboolean shutdown_write, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_48 +gboolean g_dtls_connection_shutdown_finish (GDtlsConnection *conn, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_48 +gboolean g_dtls_connection_close (GDtlsConnection *conn, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_48 +void g_dtls_connection_close_async (GDtlsConnection *conn, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_48 +gboolean g_dtls_connection_close_finish (GDtlsConnection *conn, + GAsyncResult *result, + GError **error); + +/*< protected >*/ +GIO_AVAILABLE_IN_2_48 +gboolean g_dtls_connection_emit_accept_certificate (GDtlsConnection *conn, + GTlsCertificate *peer_cert, + GTlsCertificateFlags errors); +GIO_AVAILABLE_IN_2_60 +void g_dtls_connection_set_advertised_protocols (GDtlsConnection *conn, + const gchar * const *protocols); + +GIO_AVAILABLE_IN_2_60 +const gchar * g_dtls_connection_get_negotiated_protocol (GDtlsConnection *conn); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GIO_AVAILABLE_IN_2_66 +gboolean g_dtls_connection_get_channel_binding_data (GDtlsConnection *conn, + GTlsChannelBindingType type, + GByteArray *data, + GError **error); +G_GNUC_END_IGNORE_DEPRECATIONS + +GIO_AVAILABLE_IN_2_70 +GTlsProtocolVersion g_dtls_connection_get_protocol_version (GDtlsConnection *conn); + +GIO_AVAILABLE_IN_2_70 +gchar * g_dtls_connection_get_ciphersuite_name (GDtlsConnection *conn); + +G_END_DECLS + +#endif /* __G_DTLS_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsserverconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsserverconnection.h new file mode 100644 index 00000000..3832818f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gdtlsserverconnection.h @@ -0,0 +1,63 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2010 Red Hat, Inc. + * Copyright © 2015 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_DTLS_SERVER_CONNECTION_H__ +#define __G_DTLS_SERVER_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_DTLS_SERVER_CONNECTION (g_dtls_server_connection_get_type ()) +#define G_DTLS_SERVER_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_DTLS_SERVER_CONNECTION, GDtlsServerConnection)) +#define G_IS_DTLS_SERVER_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_DTLS_SERVER_CONNECTION)) +#define G_DTLS_SERVER_CONNECTION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_DTLS_SERVER_CONNECTION, GDtlsServerConnectionInterface)) + +typedef struct _GDtlsServerConnectionInterface GDtlsServerConnectionInterface; + +/** + * GDtlsServerConnectionInterface: + * @g_iface: The parent interface. + * + * vtable for a #GDtlsServerConnection implementation. + * + * Since: 2.48 + */ +struct _GDtlsServerConnectionInterface +{ + GTypeInterface g_iface; +}; + +GIO_AVAILABLE_IN_2_48 +GType g_dtls_server_connection_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_48 +GDatagramBased *g_dtls_server_connection_new (GDatagramBased *base_socket, + GTlsCertificate *certificate, + GError **error); + +G_END_DECLS + +#endif /* __G_DTLS_SERVER_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gemblem.h b/illumos-x86_64/usr/include/glib-2.0/gio/gemblem.h new file mode 100644 index 00000000..3fa6b610 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gemblem.h @@ -0,0 +1,58 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Clemens N. Buss + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + */ + +#ifndef __G_EMBLEM_H__ +#define __G_EMBLEM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_EMBLEM (g_emblem_get_type ()) +#define G_EMBLEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_EMBLEM, GEmblem)) +#define G_EMBLEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_EMBLEM, GEmblemClass)) +#define G_IS_EMBLEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_EMBLEM)) +#define G_IS_EMBLEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_EMBLEM)) +#define G_EMBLEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_EMBLEM, GEmblemClass)) + +typedef struct _GEmblem GEmblem; +typedef struct _GEmblemClass GEmblemClass; + +GIO_AVAILABLE_IN_ALL +GType g_emblem_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GEmblem *g_emblem_new (GIcon *icon); +GIO_AVAILABLE_IN_ALL +GEmblem *g_emblem_new_with_origin (GIcon *icon, + GEmblemOrigin origin); +GIO_AVAILABLE_IN_ALL +GIcon *g_emblem_get_icon (GEmblem *emblem); +GIO_AVAILABLE_IN_ALL +GEmblemOrigin g_emblem_get_origin (GEmblem *emblem); + +G_END_DECLS + +#endif /* __G_EMBLEM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gemblemedicon.h b/illumos-x86_64/usr/include/glib-2.0/gio/gemblemedicon.h new file mode 100644 index 00000000..7145efdf --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gemblemedicon.h @@ -0,0 +1,78 @@ +/* Gio - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Matthias Clasen + * Clemens N. Buss + */ + +#ifndef __G_EMBLEMED_ICON_H__ +#define __G_EMBLEMED_ICON_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_EMBLEMED_ICON (g_emblemed_icon_get_type ()) +#define G_EMBLEMED_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_EMBLEMED_ICON, GEmblemedIcon)) +#define G_EMBLEMED_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_EMBLEMED_ICON, GEmblemedIconClass)) +#define G_IS_EMBLEMED_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_EMBLEMED_ICON)) +#define G_IS_EMBLEMED_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_EMBLEMED_ICON)) +#define G_EMBLEMED_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_EMBLEMED_ICON, GEmblemedIconClass)) + +typedef struct _GEmblemedIcon GEmblemedIcon; +typedef struct _GEmblemedIconClass GEmblemedIconClass; +typedef struct _GEmblemedIconPrivate GEmblemedIconPrivate; + +struct _GEmblemedIcon +{ + GObject parent_instance; + + /*< private >*/ + GEmblemedIconPrivate *priv; +}; + +struct _GEmblemedIconClass +{ + GObjectClass parent_class; +}; + +GIO_AVAILABLE_IN_ALL +GType g_emblemed_icon_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GIcon *g_emblemed_icon_new (GIcon *icon, + GEmblem *emblem); +GIO_AVAILABLE_IN_ALL +GIcon *g_emblemed_icon_get_icon (GEmblemedIcon *emblemed); +GIO_AVAILABLE_IN_ALL +GList *g_emblemed_icon_get_emblems (GEmblemedIcon *emblemed); +GIO_AVAILABLE_IN_ALL +void g_emblemed_icon_add_emblem (GEmblemedIcon *emblemed, + GEmblem *emblem); +GIO_AVAILABLE_IN_ALL +void g_emblemed_icon_clear_emblems (GEmblemedIcon *emblemed); + +G_END_DECLS + +#endif /* __G_EMBLEMED_ICON_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfile.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfile.h new file mode 100644 index 00000000..74e50db8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfile.h @@ -0,0 +1,1369 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_H__ +#define __G_FILE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILE (g_file_get_type ()) +#define G_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_FILE, GFile)) +#define G_IS_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_FILE)) +#define G_FILE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_FILE, GFileIface)) + +typedef struct _GFileIface GFileIface; + + +/** + * GFileIface: + * @g_iface: The parent interface. + * @dup: Duplicates a #GFile. + * @hash: Creates a hash of a #GFile. + * @equal: Checks equality of two given #GFiles. + * @is_native: Checks to see if a file is native to the system. + * @has_uri_scheme: Checks to see if a #GFile has a given URI scheme. + * @get_uri_scheme: Gets the URI scheme for a #GFile. + * @get_basename: Gets the basename for a given #GFile. + * @get_path: Gets the current path within a #GFile. + * @get_uri: Gets a URI for the path within a #GFile. + * @get_parse_name: Gets the parsed name for the #GFile. + * @get_parent: Gets the parent directory for the #GFile. + * @prefix_matches: Checks whether a #GFile contains a specified file. + * @get_relative_path: Gets the path for a #GFile relative to a given path. + * @resolve_relative_path: Resolves a relative path for a #GFile to an absolute path. + * @get_child_for_display_name: Gets the child #GFile for a given display name. + * @enumerate_children: Gets a #GFileEnumerator with the children of a #GFile. + * @enumerate_children_async: Asynchronously gets a #GFileEnumerator with the children of a #GFile. + * @enumerate_children_finish: Finishes asynchronously enumerating the children. + * @query_info: Gets the #GFileInfo for a #GFile. + * @query_info_async: Asynchronously gets the #GFileInfo for a #GFile. + * @query_info_finish: Finishes an asynchronous query info operation. + * @query_filesystem_info: Gets a #GFileInfo for the file system #GFile is on. + * @query_filesystem_info_async: Asynchronously gets a #GFileInfo for the file system #GFile is on. + * @query_filesystem_info_finish: Finishes asynchronously getting the file system info. + * @find_enclosing_mount: Gets a #GMount for the #GFile. + * @find_enclosing_mount_async: Asynchronously gets the #GMount for a #GFile. + * @find_enclosing_mount_finish: Finishes asynchronously getting the volume. + * @set_display_name: Sets the display name for a #GFile. + * @set_display_name_async: Asynchronously sets a #GFile's display name. + * @set_display_name_finish: Finishes asynchronously setting a #GFile's display name. + * @query_settable_attributes: Returns a list of #GFileAttributeInfos that can be set. + * @_query_settable_attributes_async: Asynchronously gets a list of #GFileAttributeInfos that can be set. + * @_query_settable_attributes_finish: Finishes asynchronously querying settable attributes. + * @query_writable_namespaces: Returns a list of #GFileAttributeInfo namespaces that are writable. + * @_query_writable_namespaces_async: Asynchronously gets a list of #GFileAttributeInfo namespaces that are writable. + * @_query_writable_namespaces_finish: Finishes asynchronously querying the writable namespaces. + * @set_attribute: Sets a #GFileAttributeInfo. + * @set_attributes_from_info: Sets a #GFileAttributeInfo with information from a #GFileInfo. + * @set_attributes_async: Asynchronously sets a file's attributes. + * @set_attributes_finish: Finishes setting a file's attributes asynchronously. + * @read_fn: Reads a file asynchronously. + * @read_async: Asynchronously reads a file. + * @read_finish: Finishes asynchronously reading a file. + * @append_to: Writes to the end of a file. + * @append_to_async: Asynchronously writes to the end of a file. + * @append_to_finish: Finishes an asynchronous file append operation. + * @create: Creates a new file. + * @create_async: Asynchronously creates a file. + * @create_finish: Finishes asynchronously creating a file. + * @replace: Replaces the contents of a file. + * @replace_async: Asynchronously replaces the contents of a file. + * @replace_finish: Finishes asynchronously replacing a file. + * @delete_file: Deletes a file. + * @delete_file_async: Asynchronously deletes a file. + * @delete_file_finish: Finishes an asynchronous delete. + * @trash: Sends a #GFile to the Trash location. + * @trash_async: Asynchronously sends a #GFile to the Trash location. + * @trash_finish: Finishes an asynchronous file trashing operation. + * @make_directory: Makes a directory. + * @make_directory_async: Asynchronously makes a directory. + * @make_directory_finish: Finishes making a directory asynchronously. + * @make_symbolic_link: (nullable): Makes a symbolic link. %NULL if symbolic + * links are unsupported. + * @make_symbolic_link_async: Asynchronously makes a symbolic link + * @make_symbolic_link_finish: Finishes making a symbolic link asynchronously. + * @copy: (nullable): Copies a file. %NULL if copying is unsupported, which will + * cause `GFile` to use a fallback copy method where it reads from the + * source and writes to the destination. + * @copy_async: Asynchronously copies a file. + * @copy_finish: Finishes an asynchronous copy operation. + * @move: Moves a file. + * @move_async: Asynchronously moves a file. Since: 2.72 + * @move_finish: Finishes an asynchronous move operation. Since: 2.72 + * @mount_mountable: Mounts a mountable object. + * @mount_mountable_finish: Finishes a mounting operation. + * @unmount_mountable: Unmounts a mountable object. + * @unmount_mountable_finish: Finishes an unmount operation. + * @eject_mountable: Ejects a mountable. + * @eject_mountable_finish: Finishes an eject operation. + * @mount_enclosing_volume: Mounts a specified location. + * @mount_enclosing_volume_finish: Finishes mounting a specified location. + * @monitor_dir: Creates a #GFileMonitor for the location. + * @monitor_file: Creates a #GFileMonitor for the location. + * @open_readwrite: Open file read/write. Since 2.22. + * @open_readwrite_async: Asynchronously opens file read/write. Since 2.22. + * @open_readwrite_finish: Finishes an asynchronous open read/write. Since 2.22. + * @create_readwrite: Creates file read/write. Since 2.22. + * @create_readwrite_async: Asynchronously creates file read/write. Since 2.22. + * @create_readwrite_finish: Finishes an asynchronous creates read/write. Since 2.22. + * @replace_readwrite: Replaces file read/write. Since 2.22. + * @replace_readwrite_async: Asynchronously replaces file read/write. Since 2.22. + * @replace_readwrite_finish: Finishes an asynchronous replace read/write. Since 2.22. + * @start_mountable: Starts a mountable object. Since 2.22. + * @start_mountable_finish: Finishes a start operation. Since 2.22. + * @stop_mountable: Stops a mountable. Since 2.22. + * @stop_mountable_finish: Finishes a stop operation. Since 2.22. + * @supports_thread_contexts: a boolean that indicates whether the #GFile implementation supports thread-default contexts. Since 2.22. + * @unmount_mountable_with_operation: Unmounts a mountable object using a #GMountOperation. Since 2.22. + * @unmount_mountable_with_operation_finish: Finishes an unmount operation using a #GMountOperation. Since 2.22. + * @eject_mountable_with_operation: Ejects a mountable object using a #GMountOperation. Since 2.22. + * @eject_mountable_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22. + * @poll_mountable: Polls a mountable object for media changes. Since 2.22. + * @poll_mountable_finish: Finishes a poll operation for media changes. Since 2.22. + * @measure_disk_usage: Recursively measures the disk usage of @file. Since 2.38 + * @measure_disk_usage_async: Asynchronously recursively measures the disk usage of @file. Since 2.38 + * @measure_disk_usage_finish: Finishes an asynchronous recursive measurement of the disk usage of @file. Since 2.38 + * @query_exists: Queries whether a file exists. Since 2.84 + * + * An interface for writing VFS file handles. + **/ +struct _GFileIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + GFile * (* dup) (GFile *file); + guint (* hash) (GFile *file); + gboolean (* equal) (GFile *file1, + GFile *file2); + gboolean (* is_native) (GFile *file); + gboolean (* has_uri_scheme) (GFile *file, + const char *uri_scheme); + char * (* get_uri_scheme) (GFile *file); + char * (* get_basename) (GFile *file); + char * (* get_path) (GFile *file); + char * (* get_uri) (GFile *file); + char * (* get_parse_name) (GFile *file); + GFile * (* get_parent) (GFile *file); + gboolean (* prefix_matches) (GFile *prefix, + GFile *file); + char * (* get_relative_path) (GFile *parent, + GFile *descendant); + GFile * (* resolve_relative_path) (GFile *file, + const char *relative_path); + GFile * (* get_child_for_display_name) (GFile *file, + const char *display_name, + GError **error); + + GFileEnumerator * (* enumerate_children) (GFile *file, + const char *attributes, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); + void (* enumerate_children_async) (GFile *file, + const char *attributes, + GFileQueryInfoFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileEnumerator * (* enumerate_children_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + GFileInfo * (* query_info) (GFile *file, + const char *attributes, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); + void (* query_info_async) (GFile *file, + const char *attributes, + GFileQueryInfoFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileInfo * (* query_info_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + GFileInfo * (* query_filesystem_info) (GFile *file, + const char *attributes, + GCancellable *cancellable, + GError **error); + void (* query_filesystem_info_async) (GFile *file, + const char *attributes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileInfo * (* query_filesystem_info_finish)(GFile *file, + GAsyncResult *res, + GError **error); + + GMount * (* find_enclosing_mount) (GFile *file, + GCancellable *cancellable, + GError **error); + void (* find_enclosing_mount_async) (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GMount * (* find_enclosing_mount_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + GFile * (* set_display_name) (GFile *file, + const char *display_name, + GCancellable *cancellable, + GError **error); + void (* set_display_name_async) (GFile *file, + const char *display_name, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFile * (* set_display_name_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + GFileAttributeInfoList * (* query_settable_attributes) (GFile *file, + GCancellable *cancellable, + GError **error); + void (* _query_settable_attributes_async) (void); + void (* _query_settable_attributes_finish) (void); + + GFileAttributeInfoList * (* query_writable_namespaces) (GFile *file, + GCancellable *cancellable, + GError **error); + void (* _query_writable_namespaces_async) (void); + void (* _query_writable_namespaces_finish) (void); + + gboolean (* set_attribute) (GFile *file, + const char *attribute, + GFileAttributeType type, + gpointer value_p, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); + gboolean (* set_attributes_from_info) (GFile *file, + GFileInfo *info, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); + void (* set_attributes_async) (GFile *file, + GFileInfo *info, + GFileQueryInfoFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* set_attributes_finish) (GFile *file, + GAsyncResult *result, + GFileInfo **info, + GError **error); + + GFileInputStream * (* read_fn) (GFile *file, + GCancellable *cancellable, + GError **error); + void (* read_async) (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileInputStream * (* read_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + GFileOutputStream * (* append_to) (GFile *file, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); + void (* append_to_async) (GFile *file, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileOutputStream * (* append_to_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + GFileOutputStream * (* create) (GFile *file, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); + void (* create_async) (GFile *file, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileOutputStream * (* create_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + GFileOutputStream * (* replace) (GFile *file, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); + void (* replace_async) (GFile *file, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileOutputStream * (* replace_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + gboolean (* delete_file) (GFile *file, + GCancellable *cancellable, + GError **error); + void (* delete_file_async) (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* delete_file_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + gboolean (* trash) (GFile *file, + GCancellable *cancellable, + GError **error); + void (* trash_async) (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* trash_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + gboolean (* make_directory) (GFile *file, + GCancellable *cancellable, + GError **error); + void (* make_directory_async) (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* make_directory_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + gboolean (* make_symbolic_link) (GFile *file, + const char *symlink_value, + GCancellable *cancellable, + GError **error); + void (* make_symbolic_link_async) (GFile *file, + const char *symlink_value, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* make_symbolic_link_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + gboolean (* copy) (GFile *source, + GFile *destination, + GFileCopyFlags flags, + GCancellable *cancellable, + GFileProgressCallback progress_callback, + gpointer progress_callback_data, + GError **error); + void (* copy_async) (GFile *source, + GFile *destination, + GFileCopyFlags flags, + int io_priority, + GCancellable *cancellable, + GFileProgressCallback progress_callback, + gpointer progress_callback_data, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* copy_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + gboolean (* move) (GFile *source, + GFile *destination, + GFileCopyFlags flags, + GCancellable *cancellable, + GFileProgressCallback progress_callback, + gpointer progress_callback_data, + GError **error); + void (* move_async) (GFile *source, + GFile *destination, + GFileCopyFlags flags, + int io_priority, + GCancellable *cancellable, + GFileProgressCallback progress_callback, + gpointer progress_callback_data, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* move_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + void (* mount_mountable) (GFile *file, + GMountMountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFile * (* mount_mountable_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + void (* unmount_mountable) (GFile *file, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* unmount_mountable_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + void (* eject_mountable) (GFile *file, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* eject_mountable_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + void (* mount_enclosing_volume) (GFile *location, + GMountMountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* mount_enclosing_volume_finish) (GFile *location, + GAsyncResult *result, + GError **error); + + GFileMonitor * (* monitor_dir) (GFile *file, + GFileMonitorFlags flags, + GCancellable *cancellable, + GError **error); + GFileMonitor * (* monitor_file) (GFile *file, + GFileMonitorFlags flags, + GCancellable *cancellable, + GError **error); + + GFileIOStream * (* open_readwrite) (GFile *file, + GCancellable *cancellable, + GError **error); + void (* open_readwrite_async) (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileIOStream * (* open_readwrite_finish) (GFile *file, + GAsyncResult *res, + GError **error); + GFileIOStream * (* create_readwrite) (GFile *file, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); + void (* create_readwrite_async) (GFile *file, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileIOStream * (* create_readwrite_finish) (GFile *file, + GAsyncResult *res, + GError **error); + GFileIOStream * (* replace_readwrite) (GFile *file, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); + void (* replace_readwrite_async) (GFile *file, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileIOStream * (* replace_readwrite_finish) (GFile *file, + GAsyncResult *res, + GError **error); + + void (* start_mountable) (GFile *file, + GDriveStartFlags flags, + GMountOperation *start_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* start_mountable_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + void (* stop_mountable) (GFile *file, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* stop_mountable_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + gboolean supports_thread_contexts; + + void (* unmount_mountable_with_operation) (GFile *file, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* unmount_mountable_with_operation_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + void (* eject_mountable_with_operation) (GFile *file, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* eject_mountable_with_operation_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + void (* poll_mountable) (GFile *file, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* poll_mountable_finish) (GFile *file, + GAsyncResult *result, + GError **error); + + gboolean (* measure_disk_usage) (GFile *file, + GFileMeasureFlags flags, + GCancellable *cancellable, + GFileMeasureProgressCallback progress_callback, + gpointer progress_data, + guint64 *disk_usage, + guint64 *num_dirs, + guint64 *num_files, + GError **error); + void (* measure_disk_usage_async) (GFile *file, + GFileMeasureFlags flags, + gint io_priority, + GCancellable *cancellable, + GFileMeasureProgressCallback progress_callback, + gpointer progress_data, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* measure_disk_usage_finish) (GFile *file, + GAsyncResult *result, + guint64 *disk_usage, + guint64 *num_dirs, + guint64 *num_files, + GError **error); + + gboolean (* query_exists) (GFile *file, + GCancellable *cancellable); +}; + +GIO_AVAILABLE_IN_ALL +GType g_file_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GFile * g_file_new_for_path (const char *path); +GIO_AVAILABLE_IN_ALL +GFile * g_file_new_for_uri (const char *uri); +GIO_AVAILABLE_IN_ALL +GFile * g_file_new_for_commandline_arg (const char *arg); +GIO_AVAILABLE_IN_2_36 +GFile * g_file_new_for_commandline_arg_and_cwd (const gchar *arg, + const gchar *cwd); +GIO_AVAILABLE_IN_2_32 +GFile * g_file_new_tmp (const char *tmpl, + GFileIOStream **iostream, + GError **error); +GIO_AVAILABLE_IN_2_74 +void g_file_new_tmp_async (const char *tmpl, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_74 +GFile * g_file_new_tmp_finish (GAsyncResult *result, + GFileIOStream **iostream, + GError **error); +GIO_AVAILABLE_IN_2_74 +void g_file_new_tmp_dir_async (const char *tmpl, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_74 +GFile * g_file_new_tmp_dir_finish (GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +GFile * g_file_parse_name (const char *parse_name); +GIO_AVAILABLE_IN_2_56 +GFile * g_file_new_build_filename (const gchar *first_element, + ...) G_GNUC_NULL_TERMINATED; +GIO_AVAILABLE_IN_2_78 +GFile * g_file_new_build_filenamev (const gchar * const *args); +GIO_AVAILABLE_IN_ALL +GFile * g_file_dup (GFile *file); +GIO_AVAILABLE_IN_ALL +guint g_file_hash (gconstpointer file); +GIO_AVAILABLE_IN_ALL +gboolean g_file_equal (GFile *file1, + GFile *file2); +GIO_AVAILABLE_IN_ALL +char * g_file_get_basename (GFile *file); +GIO_AVAILABLE_IN_ALL +char * g_file_get_path (GFile *file); +GIO_AVAILABLE_IN_2_56 +const char * g_file_peek_path (GFile *file); +GIO_AVAILABLE_IN_ALL +char * g_file_get_uri (GFile *file); +GIO_AVAILABLE_IN_ALL +char * g_file_get_parse_name (GFile *file); +GIO_AVAILABLE_IN_ALL +GFile * g_file_get_parent (GFile *file); +GIO_AVAILABLE_IN_ALL +gboolean g_file_has_parent (GFile *file, + GFile *parent); +GIO_AVAILABLE_IN_ALL +GFile * g_file_get_child (GFile *file, + const char *name); +GIO_AVAILABLE_IN_ALL +GFile * g_file_get_child_for_display_name (GFile *file, + const char *display_name, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_has_prefix (GFile *file, + GFile *prefix); +GIO_AVAILABLE_IN_ALL +char * g_file_get_relative_path (GFile *parent, + GFile *descendant); +GIO_AVAILABLE_IN_ALL +GFile * g_file_resolve_relative_path (GFile *file, + const char *relative_path); +GIO_AVAILABLE_IN_ALL +gboolean g_file_is_native (GFile *file); +GIO_AVAILABLE_IN_ALL +gboolean g_file_has_uri_scheme (GFile *file, + const char *uri_scheme); +GIO_AVAILABLE_IN_ALL +char * g_file_get_uri_scheme (GFile *file); +GIO_AVAILABLE_IN_ALL +GFileInputStream * g_file_read (GFile *file, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_read_async (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileInputStream * g_file_read_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileOutputStream * g_file_append_to (GFile *file, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileOutputStream * g_file_create (GFile *file, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileOutputStream * g_file_replace (GFile *file, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_append_to_async (GFile *file, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileOutputStream * g_file_append_to_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_create_async (GFile *file, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileOutputStream * g_file_create_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_replace_async (GFile *file, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileOutputStream * g_file_replace_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileIOStream * g_file_open_readwrite (GFile *file, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_open_readwrite_async (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileIOStream * g_file_open_readwrite_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileIOStream * g_file_create_readwrite (GFile *file, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_create_readwrite_async (GFile *file, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileIOStream * g_file_create_readwrite_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileIOStream * g_file_replace_readwrite (GFile *file, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_replace_readwrite_async (GFile *file, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileIOStream * g_file_replace_readwrite_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_query_exists (GFile *file, + GCancellable *cancellable); +GIO_AVAILABLE_IN_ALL +GFileType g_file_query_file_type (GFile *file, + GFileQueryInfoFlags flags, + GCancellable *cancellable); +GIO_AVAILABLE_IN_ALL +GFileInfo * g_file_query_info (GFile *file, + const char *attributes, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_query_info_async (GFile *file, + const char *attributes, + GFileQueryInfoFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileInfo * g_file_query_info_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileInfo * g_file_query_filesystem_info (GFile *file, + const char *attributes, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_query_filesystem_info_async (GFile *file, + const char *attributes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileInfo * g_file_query_filesystem_info_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GMount * g_file_find_enclosing_mount (GFile *file, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_find_enclosing_mount_async (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GMount * g_file_find_enclosing_mount_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileEnumerator * g_file_enumerate_children (GFile *file, + const char *attributes, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_enumerate_children_async (GFile *file, + const char *attributes, + GFileQueryInfoFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileEnumerator * g_file_enumerate_children_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +GFile * g_file_set_display_name (GFile *file, + const char *display_name, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_set_display_name_async (GFile *file, + const char *display_name, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFile * g_file_set_display_name_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_delete (GFile *file, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_34 +void g_file_delete_async (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_34 +gboolean g_file_delete_finish (GFile *file, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_file_trash (GFile *file, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_38 +void g_file_trash_async (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_38 +gboolean g_file_trash_finish (GFile *file, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_file_copy (GFile *source, + GFile *destination, + GFileCopyFlags flags, + GCancellable *cancellable, + GFileProgressCallback progress_callback, + gpointer progress_callback_data, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_copy_async (GFile *source, + GFile *destination, + GFileCopyFlags flags, + int io_priority, + GCancellable *cancellable, + GFileProgressCallback progress_callback, + gpointer progress_callback_data, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_82 +void g_file_copy_async_with_closures (GFile *source, + GFile *destination, + GFileCopyFlags flags, + int io_priority, + GCancellable *cancellable, + GClosure *progress_callback_closure, + GClosure *ready_callback_closure); +GIO_AVAILABLE_IN_ALL +gboolean g_file_copy_finish (GFile *file, + GAsyncResult *res, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_move (GFile *source, + GFile *destination, + GFileCopyFlags flags, + GCancellable *cancellable, + GFileProgressCallback progress_callback, + gpointer progress_callback_data, + GError **error); +GIO_AVAILABLE_IN_2_72 +void g_file_move_async (GFile *source, + GFile *destination, + GFileCopyFlags flags, + int io_priority, + GCancellable *cancellable, + GFileProgressCallback progress_callback, + gpointer progress_callback_data, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_82 +void g_file_move_async_with_closures (GFile *source, + GFile *destination, + GFileCopyFlags flags, + int io_priority, + GCancellable *cancellable, + GClosure *progress_callback_closure, + GClosure *ready_callback_closure); +GIO_AVAILABLE_IN_2_72 +gboolean g_file_move_finish (GFile *file, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_make_directory (GFile *file, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_38 +void g_file_make_directory_async (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_38 +gboolean g_file_make_directory_finish (GFile *file, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_file_make_directory_with_parents (GFile *file, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_make_symbolic_link (GFile *file, + const char *symlink_value, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_74 +void g_file_make_symbolic_link_async (GFile *file, + const char *symlink_value, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_74 +gboolean g_file_make_symbolic_link_finish (GFile *file, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileAttributeInfoList *g_file_query_settable_attributes (GFile *file, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileAttributeInfoList *g_file_query_writable_namespaces (GFile *file, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attribute (GFile *file, + const char *attribute, + GFileAttributeType type, + gpointer value_p, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attributes_from_info (GFile *file, + GFileInfo *info, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_set_attributes_async (GFile *file, + GFileInfo *info, + GFileQueryInfoFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attributes_finish (GFile *file, + GAsyncResult *result, + GFileInfo **info, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attribute_string (GFile *file, + const char *attribute, + const char *value, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attribute_byte_string (GFile *file, + const char *attribute, + const char *value, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attribute_uint32 (GFile *file, + const char *attribute, + guint32 value, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attribute_int32 (GFile *file, + const char *attribute, + gint32 value, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attribute_uint64 (GFile *file, + const char *attribute, + guint64 value, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_set_attribute_int64 (GFile *file, + const char *attribute, + gint64 value, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_mount_enclosing_volume (GFile *location, + GMountMountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_mount_enclosing_volume_finish (GFile *location, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_mount_mountable (GFile *file, + GMountMountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFile * g_file_mount_mountable_finish (GFile *file, + GAsyncResult *result, + GError **error); +GIO_DEPRECATED_FOR(g_file_unmount_mountable_with_operation) +void g_file_unmount_mountable (GFile *file, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_DEPRECATED_FOR(g_file_unmount_mountable_with_operation_finish) +gboolean g_file_unmount_mountable_finish (GFile *file, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_unmount_mountable_with_operation (GFile *file, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_unmount_mountable_with_operation_finish (GFile *file, + GAsyncResult *result, + GError **error); +GIO_DEPRECATED_FOR(g_file_eject_mountable_with_operation) +void g_file_eject_mountable (GFile *file, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_DEPRECATED_FOR(g_file_eject_mountable_with_operation_finish) +gboolean g_file_eject_mountable_finish (GFile *file, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_eject_mountable_with_operation (GFile *file, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_eject_mountable_with_operation_finish (GFile *file, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_68 +char * g_file_build_attribute_list_for_copy (GFile *file, + GFileCopyFlags flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_file_copy_attributes (GFile *source, + GFile *destination, + GFileCopyFlags flags, + GCancellable *cancellable, + GError **error); + + +GIO_AVAILABLE_IN_ALL +GFileMonitor* g_file_monitor_directory (GFile *file, + GFileMonitorFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileMonitor* g_file_monitor_file (GFile *file, + GFileMonitorFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GFileMonitor* g_file_monitor (GFile *file, + GFileMonitorFlags flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_38 +gboolean g_file_measure_disk_usage (GFile *file, + GFileMeasureFlags flags, + GCancellable *cancellable, + GFileMeasureProgressCallback progress_callback, + gpointer progress_data, + guint64 *disk_usage, + guint64 *num_dirs, + guint64 *num_files, + GError **error); + +GIO_AVAILABLE_IN_2_38 +void g_file_measure_disk_usage_async (GFile *file, + GFileMeasureFlags flags, + gint io_priority, + GCancellable *cancellable, + GFileMeasureProgressCallback progress_callback, + gpointer progress_data, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_38 +gboolean g_file_measure_disk_usage_finish (GFile *file, + GAsyncResult *result, + guint64 *disk_usage, + guint64 *num_dirs, + guint64 *num_files, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_file_start_mountable (GFile *file, + GDriveStartFlags flags, + GMountOperation *start_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_start_mountable_finish (GFile *file, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_stop_mountable (GFile *file, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_stop_mountable_finish (GFile *file, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_file_poll_mountable (GFile *file, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_poll_mountable_finish (GFile *file, + GAsyncResult *result, + GError **error); + +/* Utilities */ + +GIO_AVAILABLE_IN_ALL +GAppInfo *g_file_query_default_handler (GFile *file, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_60 +void g_file_query_default_handler_async (GFile *file, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_60 +GAppInfo *g_file_query_default_handler_finish (GFile *file, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_file_load_contents (GFile *file, + GCancellable *cancellable, + char **contents, + gsize *length, + char **etag_out, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_load_contents_async (GFile *file, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_load_contents_finish (GFile *file, + GAsyncResult *res, + char **contents, + gsize *length, + char **etag_out, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_load_partial_contents_async (GFile *file, + GCancellable *cancellable, + GFileReadMoreCallback read_more_callback, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_load_partial_contents_finish (GFile *file, + GAsyncResult *res, + char **contents, + gsize *length, + char **etag_out, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_replace_contents (GFile *file, + const char *contents, + gsize length, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + char **new_etag, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_replace_contents_async (GFile *file, + const char *contents, + gsize length, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_40 +void g_file_replace_contents_bytes_async (GFile *file, + GBytes *contents, + const char *etag, + gboolean make_backup, + GFileCreateFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_replace_contents_finish (GFile *file, + GAsyncResult *res, + char **new_etag, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_file_supports_thread_contexts (GFile *file); + +GIO_AVAILABLE_IN_2_56 +GBytes *g_file_load_bytes (GFile *file, + GCancellable *cancellable, + gchar **etag_out, + GError **error); +GIO_AVAILABLE_IN_2_56 +void g_file_load_bytes_async (GFile *file, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_56 +GBytes *g_file_load_bytes_finish (GFile *file, + GAsyncResult *result, + gchar **etag_out, + GError **error); + +G_END_DECLS + +#endif /* __G_FILE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfileattribute.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfileattribute.h new file mode 100644 index 00000000..0ce60981 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfileattribute.h @@ -0,0 +1,86 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_ATTRIBUTE_H__ +#define __G_FILE_ATTRIBUTE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * GFileAttributeInfo: + * @name: the name of the attribute. + * @type: the #GFileAttributeType type of the attribute. + * @flags: a set of #GFileAttributeInfoFlags. + * + * Information about a specific attribute. + **/ +struct _GFileAttributeInfo +{ + char *name; + GFileAttributeType type; + GFileAttributeInfoFlags flags; +}; + +/** + * GFileAttributeInfoList: + * @infos: an array of #GFileAttributeInfos. + * @n_infos: the number of values in the array. + * + * Acts as a lightweight registry for possible valid file attributes. + * The registry stores Key-Value pair formats as #GFileAttributeInfos. + **/ +struct _GFileAttributeInfoList +{ + GFileAttributeInfo *infos; + int n_infos; +}; + +#define G_TYPE_FILE_ATTRIBUTE_INFO_LIST (g_file_attribute_info_list_get_type ()) +GIO_AVAILABLE_IN_ALL +GType g_file_attribute_info_list_get_type (void); + +GIO_AVAILABLE_IN_ALL +GFileAttributeInfoList * g_file_attribute_info_list_new (void); +GIO_AVAILABLE_IN_ALL +GFileAttributeInfoList * g_file_attribute_info_list_ref (GFileAttributeInfoList *list); +GIO_AVAILABLE_IN_ALL +void g_file_attribute_info_list_unref (GFileAttributeInfoList *list); +GIO_AVAILABLE_IN_ALL +GFileAttributeInfoList * g_file_attribute_info_list_dup (GFileAttributeInfoList *list); +GIO_AVAILABLE_IN_ALL +const GFileAttributeInfo *g_file_attribute_info_list_lookup (GFileAttributeInfoList *list, + const char *name); +GIO_AVAILABLE_IN_ALL +void g_file_attribute_info_list_add (GFileAttributeInfoList *list, + const char *name, + GFileAttributeType type, + GFileAttributeInfoFlags flags); + +G_END_DECLS + +#endif /* __G_FILE_INFO_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfileenumerator.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfileenumerator.h new file mode 100644 index 00000000..274d8ed1 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfileenumerator.h @@ -0,0 +1,149 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_ENUMERATOR_H__ +#define __G_FILE_ENUMERATOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILE_ENUMERATOR (g_file_enumerator_get_type ()) +#define G_FILE_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_ENUMERATOR, GFileEnumerator)) +#define G_FILE_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_ENUMERATOR, GFileEnumeratorClass)) +#define G_IS_FILE_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_ENUMERATOR)) +#define G_IS_FILE_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_ENUMERATOR)) +#define G_FILE_ENUMERATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_ENUMERATOR, GFileEnumeratorClass)) + +typedef struct _GFileEnumeratorClass GFileEnumeratorClass; +typedef struct _GFileEnumeratorPrivate GFileEnumeratorPrivate; + +struct _GFileEnumerator +{ + GObject parent_instance; + + /*< private >*/ + GFileEnumeratorPrivate *priv; +}; + +struct _GFileEnumeratorClass +{ + GObjectClass parent_class; + + /* Virtual Table */ + + GFileInfo * (* next_file) (GFileEnumerator *enumerator, + GCancellable *cancellable, + GError **error); + gboolean (* close_fn) (GFileEnumerator *enumerator, + GCancellable *cancellable, + GError **error); + + void (* next_files_async) (GFileEnumerator *enumerator, + int num_files, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GList * (* next_files_finish) (GFileEnumerator *enumerator, + GAsyncResult *result, + GError **error); + void (* close_async) (GFileEnumerator *enumerator, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* close_finish) (GFileEnumerator *enumerator, + GAsyncResult *result, + GError **error); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); + void (*_g_reserved7) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_file_enumerator_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GFileInfo *g_file_enumerator_next_file (GFileEnumerator *enumerator, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_enumerator_close (GFileEnumerator *enumerator, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_enumerator_next_files_async (GFileEnumerator *enumerator, + int num_files, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GList * g_file_enumerator_next_files_finish (GFileEnumerator *enumerator, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_enumerator_close_async (GFileEnumerator *enumerator, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_file_enumerator_close_finish (GFileEnumerator *enumerator, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_file_enumerator_is_closed (GFileEnumerator *enumerator); +GIO_AVAILABLE_IN_ALL +gboolean g_file_enumerator_has_pending (GFileEnumerator *enumerator); +GIO_AVAILABLE_IN_ALL +void g_file_enumerator_set_pending (GFileEnumerator *enumerator, + gboolean pending); +GIO_AVAILABLE_IN_ALL +GFile * g_file_enumerator_get_container (GFileEnumerator *enumerator); +GIO_AVAILABLE_IN_2_36 +GFile * g_file_enumerator_get_child (GFileEnumerator *enumerator, + GFileInfo *info); + +GIO_AVAILABLE_IN_2_44 +gboolean g_file_enumerator_iterate (GFileEnumerator *direnum, + GFileInfo **out_info, + GFile **out_child, + GCancellable *cancellable, + GError **error); + + +G_END_DECLS + +#endif /* __G_FILE_ENUMERATOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfileicon.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfileicon.h new file mode 100644 index 00000000..971cf0c9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfileicon.h @@ -0,0 +1,54 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_ICON_H__ +#define __G_FILE_ICON_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILE_ICON (g_file_icon_get_type ()) +#define G_FILE_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_ICON, GFileIcon)) +#define G_FILE_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_ICON, GFileIconClass)) +#define G_IS_FILE_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_ICON)) +#define G_IS_FILE_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_ICON)) +#define G_FILE_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_ICON, GFileIconClass)) + +typedef struct _GFileIconClass GFileIconClass; + +GIO_AVAILABLE_IN_ALL +GType g_file_icon_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GIcon * g_file_icon_new (GFile *file); + +GIO_AVAILABLE_IN_ALL +GFile * g_file_icon_get_file (GFileIcon *icon); + +G_END_DECLS + +#endif /* __G_FILE_ICON_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfileinfo.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfileinfo.h new file mode 100644 index 00000000..6e4f02dc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfileinfo.h @@ -0,0 +1,1541 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_INFO_H__ +#define __G_FILE_INFO_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILE_INFO (g_file_info_get_type ()) +#define G_FILE_INFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_INFO, GFileInfo)) +#define G_FILE_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_INFO, GFileInfoClass)) +#define G_IS_FILE_INFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_INFO)) +#define G_IS_FILE_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_INFO)) +#define G_FILE_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_INFO, GFileInfoClass)) + +typedef struct _GFileInfoClass GFileInfoClass; + + +/* Common Attributes: */ +/** + * G_FILE_ATTRIBUTE_STANDARD_TYPE: + * + * A key in the "standard" namespace for storing file types. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + * + * The value for this key should contain a #GFileType. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_TYPE "standard::type" /* uint32 (GFileType) */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN: + * + * A key in the "standard" namespace for checking if a file is hidden. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN "standard::is-hidden" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP: + * + * A key in the "standard" namespace for checking if a file is a backup file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP "standard::is-backup" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK: + * + * A key in the "standard" namespace for checking if the file is a symlink. + * Typically the actual type is something else, if we followed the symlink + * to get the type. + * + * On Windows NTFS mountpoints are considered to be symlinks as well. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK "standard::is-symlink" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL: + * + * A key in the "standard" namespace for checking if a file is virtual. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL "standard::is-virtual" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE: + * + * A key in the "standard" namespace for checking if a file is + * volatile. This is meant for opaque, non-POSIX-like backends to + * indicate that the URI is not persistent. Applications should look + * at %G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET for the persistent URI. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.46 + **/ +#define G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE "standard::is-volatile" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_NAME: + * + * A key in the "standard" namespace for getting the name of the file. + * + * The name is the on-disk filename which may not be in any known encoding, + * and can thus not be generally displayed as is. It is guaranteed to be set on + * every file. + * + * Use %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME if you need to display the + * name in a user interface. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_NAME "standard::name" /* byte string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME: + * + * A key in the "standard" namespace for getting the display name of the file. + * + * A display name is guaranteed to be in UTF-8 and can thus be displayed in + * the UI. It is guaranteed to be set on every file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "standard::display-name" /* string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME: + * + * A key in the "standard" namespace for edit name of the file. + * + * An edit name is similar to the display name, but it is meant to be + * used when you want to rename the file in the UI. The display name + * might contain information you don't want in the new filename (such as + * "(invalid unicode)" if the filename was in an invalid encoding). + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME "standard::edit-name" /* string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_COPY_NAME: + * + * A key in the "standard" namespace for getting the copy name of the file. + * + * The copy name is an optional version of the name. If available it's always + * in UTF8, and corresponds directly to the original filename (only transcoded to + * UTF8). This is useful if you want to copy the file to another filesystem that + * might have a different encoding. If the filename is not a valid string in the + * encoding selected for the filesystem it is in then the copy name will not be set. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_COPY_NAME "standard::copy-name" /* string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION: + * + * A key in the "standard" namespace for getting the description of the file. + * + * The description is a utf8 string that describes the file, generally containing + * the filename, but can also contain further information. Example descriptions + * could be "filename (on hostname)" for a remote file or "filename (in trash)" + * for a file in the trash. This is useful for instance as the window title + * when displaying a directory or for a bookmarks menu. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION "standard::description" /* string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_ICON: + * + * A key in the "standard" namespace for getting the icon for the file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_OBJECT. + * + * The value for this key should contain a #GIcon. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_ICON "standard::icon" /* object (GIcon) */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON: + * + * A key in the "standard" namespace for getting the symbolic icon for the file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_OBJECT. + * + * The value for this key should contain a #GIcon. + * + * Since: 2.34 + **/ +#define G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON "standard::symbolic-icon" /* object (GIcon) */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE: + * + * A key in the "standard" namespace for getting the content type of the file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + * + * The value for this key should contain a valid content type. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "standard::content-type" /* string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE: + * + * A key in the "standard" namespace for getting the fast content type. + * + * The fast content type isn't as reliable as the regular one, as it + * only uses the filename to guess it, but it is faster to calculate than the + * regular content type. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + * + **/ +#define G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE "standard::fast-content-type" /* string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_SIZE: + * + * A key in the "standard" namespace for getting the file's size (in bytes). + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_SIZE "standard::size" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE: + * + * A key in the "standard" namespace for getting the amount of disk space + * that is consumed by the file (in bytes). + * + * This will generally be larger than the file size (due to block size + * overhead) but can occasionally be smaller (for example, for sparse files). + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. + * + * Since: 2.20 + **/ +#define G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE "standard::allocated-size" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET: + * + * A key in the "standard" namespace for getting the symlink target, if the file + * is a symlink. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET "standard::symlink-target" /* byte string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_TARGET_URI: + * + * A key in the "standard" namespace for getting the target URI for the file, in + * the case of %G_FILE_TYPE_SHORTCUT or %G_FILE_TYPE_MOUNTABLE files. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_TARGET_URI "standard::target-uri" /* string */ + +/** + * G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER: + * + * A key in the "standard" namespace for setting the sort order of a file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_INT32. + * + * An example use would be in file managers, which would use this key + * to set the order files are displayed. Files with smaller sort order + * should be sorted first, and files without sort order as if sort order + * was zero. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER "standard::sort-order" /* int32 */ + +/* Entity tags, used to avoid missing updates on save */ + +/** + * G_FILE_ATTRIBUTE_ETAG_VALUE: + * + * A key in the "etag" namespace for getting the value of the file's + * entity tag. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_ETAG_VALUE "etag::value" /* string */ + +/* File identifier, for e.g. avoiding loops when doing recursive + * directory scanning + */ + +/** + * G_FILE_ATTRIBUTE_ID_FILE: + * + * A key in the "id" namespace for getting a file identifier. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + * + * An example use would be during listing files, to avoid recursive + * directory scanning. + **/ +#define G_FILE_ATTRIBUTE_ID_FILE "id::file" /* string */ + +/** + * G_FILE_ATTRIBUTE_ID_FILESYSTEM: + * + * A key in the "id" namespace for getting the file system identifier. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + * + * An example use would be during drag and drop to see if the source + * and target are on the same filesystem (default to move) or not (default + * to copy). + **/ +#define G_FILE_ATTRIBUTE_ID_FILESYSTEM "id::filesystem" /* string */ + +/* Calculated Access Rights for current user */ + +/** + * G_FILE_ATTRIBUTE_ACCESS_CAN_READ: + * + * A key in the "access" namespace for getting read privileges. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * This attribute will be %TRUE if the user is able to read the file. + **/ +#define G_FILE_ATTRIBUTE_ACCESS_CAN_READ "access::can-read" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE: + * + * A key in the "access" namespace for getting write privileges. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * This attribute will be %TRUE if the user is able to write to the file. + **/ +#define G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE "access::can-write" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE: + * + * A key in the "access" namespace for getting execution privileges. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * This attribute will be %TRUE if the user is able to execute the file. + **/ +#define G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE "access::can-execute" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE: + * + * A key in the "access" namespace for checking deletion privileges. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * This attribute will be %TRUE if the user is able to delete the file. + **/ +#define G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE "access::can-delete" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH: + * + * A key in the "access" namespace for checking trashing privileges. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * This attribute will be %TRUE if the user is able to move the file to + * the trash. + **/ +#define G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH "access::can-trash" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME: + * + * A key in the "access" namespace for checking renaming privileges. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * This attribute will be %TRUE if the user is able to rename the file. + **/ +#define G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME "access::can-rename" /* boolean */ + +/* TODO: Should we have special version for directories? can_enumerate, etc */ + +/* Mountable attributes */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT: + * + * A key in the "mountable" namespace for checking if a file (of + * type G_FILE_TYPE_MOUNTABLE) is mountable. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT "mountable::can-mount" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT: + * + * A key in the "mountable" namespace for checking if a file (of + * type G_FILE_TYPE_MOUNTABLE) is unmountable. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT "mountable::can-unmount" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT: + * + * A key in the "mountable" namespace for checking if a file (of + * type G_FILE_TYPE_MOUNTABLE) can be ejected. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT "mountable::can-eject" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE: + * + * A key in the "mountable" namespace for getting the unix device. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE "mountable::unix-device" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE: + * + * A key in the "mountable" namespace for getting the unix device file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + * + * Since: 2.22 + **/ +#define G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE "mountable::unix-device-file" /* string */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI: + * + * A key in the "mountable" namespace for getting the HAL UDI for the mountable + * file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI "mountable::hal-udi" /* string */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START: + * + * A key in the "mountable" namespace for checking if a file (of + * type G_FILE_TYPE_MOUNTABLE) can be started. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.22 + */ +#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START "mountable::can-start" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED: + * + * A key in the "mountable" namespace for checking if a file (of + * type G_FILE_TYPE_MOUNTABLE) can be started degraded. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.22 + */ +#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED "mountable::can-start-degraded" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP: + * + * A key in the "mountable" namespace for checking if a file (of + * type G_FILE_TYPE_MOUNTABLE) can be stopped. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.22 + */ +#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP "mountable::can-stop" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE: + * + * A key in the "mountable" namespace for getting the #GDriveStartStopType. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + * + * Since: 2.22 + */ +#define G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE "mountable::start-stop-type" /* uint32 (GDriveStartStopType) */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL: + * + * A key in the "mountable" namespace for checking if a file (of + * type G_FILE_TYPE_MOUNTABLE) can be polled. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.22 + */ +#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL "mountable::can-poll" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC: + * + * A key in the "mountable" namespace for checking if a file (of + * type G_FILE_TYPE_MOUNTABLE) is automatically polled for media. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.22 + */ +#define G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC "mountable::is-media-check-automatic" /* boolean */ + +/* Time attributes */ + +/** + * G_FILE_ATTRIBUTE_TIME_MODIFIED: + * + * A key in the "time" namespace for getting the time the file was last + * modified. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64, and + * contains the time since the file was modified, in seconds since the UNIX + * epoch. + **/ +#define G_FILE_ATTRIBUTE_TIME_MODIFIED "time::modified" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC: + * + * A key in the "time" namespace for getting the microseconds of the time + * the file was last modified. + * + * This should be used in conjunction with %G_FILE_ATTRIBUTE_TIME_MODIFIED. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC "time::modified-usec" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC: + * + * A key in the "time" namespace for getting the nanoseconds of the time + * the file was last modified. This should be used in conjunction with + * #G_FILE_ATTRIBUTE_TIME_MODIFIED. Corresponding #GFileAttributeType is + * %G_FILE_ATTRIBUTE_TYPE_UINT32. + * + * Since: 2.74 + **/ +#define G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC "time::modified-nsec" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_TIME_ACCESS: + * + * A key in the "time" namespace for getting the time the file was last + * accessed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64, and + * contains the time since the file was last accessed, in seconds since the + * UNIX epoch. + **/ +#define G_FILE_ATTRIBUTE_TIME_ACCESS "time::access" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_TIME_ACCESS_USEC: + * + * A key in the "time" namespace for getting the microseconds of the time + * the file was last accessed. + * + * This should be used in conjunction with %G_FILE_ATTRIBUTE_TIME_ACCESS. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_TIME_ACCESS_USEC "time::access-usec" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC: + * + * A key in the "time" namespace for getting the nanoseconds of the time + * the file was last accessed. This should be used in conjunction with + * #G_FILE_ATTRIBUTE_TIME_ACCESS. Corresponding #GFileAttributeType is + * %G_FILE_ATTRIBUTE_TYPE_UINT32. + * + * Since: 2.74 + **/ +#define G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC "time::access-nsec" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_TIME_CHANGED: + * + * A key in the "time" namespace for getting the time the file was last + * changed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64, + * and contains the time since the file was last changed, in seconds since + * the UNIX epoch. + * + * This corresponds to the traditional UNIX ctime. + **/ +#define G_FILE_ATTRIBUTE_TIME_CHANGED "time::changed" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_TIME_CHANGED_USEC: + * + * A key in the "time" namespace for getting the microseconds of the time + * the file was last changed. + * + * This should be used in conjunction with %G_FILE_ATTRIBUTE_TIME_CHANGED. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_TIME_CHANGED_USEC "time::changed-usec" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_TIME_CHANGED_NSEC: + * + * A key in the "time" namespace for getting the nanoseconds of the time + * the file was last changed. This should be used in conjunction with + * #G_FILE_ATTRIBUTE_TIME_CHANGED. Corresponding #GFileAttributeType is + * %G_FILE_ATTRIBUTE_TYPE_UINT32. + * + * Since: 2.74 + **/ +#define G_FILE_ATTRIBUTE_TIME_CHANGED_NSEC "time::changed-nsec" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_TIME_CREATED: + * + * A key in the "time" namespace for getting the time the file was created. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64, + * and contains the time since the file was created, in seconds since the UNIX + * epoch. + * + * This may correspond to Linux `stx_btime`, FreeBSD `st_birthtim`, NetBSD + * `st_birthtime` or NTFS `ctime`. + **/ +#define G_FILE_ATTRIBUTE_TIME_CREATED "time::created" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_TIME_CREATED_USEC: + * + * A key in the "time" namespace for getting the microseconds of the time + * the file was created. + * + * This should be used in conjunction with %G_FILE_ATTRIBUTE_TIME_CREATED. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_TIME_CREATED_USEC "time::created-usec" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_TIME_CREATED_NSEC: + * + * A key in the "time" namespace for getting the nanoseconds of the time + * the file was created. This should be used in conjunction with + * #G_FILE_ATTRIBUTE_TIME_CREATED. Corresponding #GFileAttributeType is + * %G_FILE_ATTRIBUTE_TYPE_UINT32. + * + * Since: 2.74 + **/ +#define G_FILE_ATTRIBUTE_TIME_CREATED_NSEC "time::created-nsec" /* uint32 */ + +/* Unix specific attributes */ + +/** + * G_FILE_ATTRIBUTE_UNIX_DEVICE: + * + * A key in the "unix" namespace for getting the device id of the device the + * file is located on (see stat() documentation). + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_UNIX_DEVICE "unix::device" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_INODE: + * + * A key in the "unix" namespace for getting the inode of the file. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. + **/ +#define G_FILE_ATTRIBUTE_UNIX_INODE "unix::inode" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_MODE: + * + * A key in the "unix" namespace for getting the mode of the file + * (e.g. whether the file is a regular file, symlink, etc). + * + * See the documentation for `lstat()`: this attribute is equivalent to + * the `st_mode` member of `struct stat`, and includes both the file type + * and permissions. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_UNIX_MODE "unix::mode" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_NLINK: + * + * A key in the "unix" namespace for getting the number of hard links + * for a file. + * + * See the documentation for `lstat()`. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_UNIX_NLINK "unix::nlink" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_UID: + * + * A key in the "unix" namespace for getting the user ID for the file. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_UNIX_UID "unix::uid" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_GID: + * + * A key in the "unix" namespace for getting the group ID for the file. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_UNIX_GID "unix::gid" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_RDEV: + * + * A key in the "unix" namespace for getting the device ID for the file + * (if it is a special file). + * + * See the documentation for `lstat()`. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_UNIX_RDEV "unix::rdev" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE: + * + * A key in the "unix" namespace for getting the block size for the file + * system. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE "unix::block-size" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_BLOCKS: + * + * A key in the "unix" namespace for getting the number of blocks allocated + * for the file. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. + **/ +#define G_FILE_ATTRIBUTE_UNIX_BLOCKS "unix::blocks" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT: + * + * A key in the "unix" namespace for checking if the file represents a + * UNIX mount point. + * + * This attribute is %TRUE if the file is a UNIX mount point. + * + * Since 2.58, `/` is considered to be a mount point. + * + * This attribute is only available for UNIX file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT "unix::is-mountpoint" /* boolean */ + +/* DOS specific attributes */ + +/** + * G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE: + * + * A key in the "dos" namespace for checking if the file's archive flag + * is set. + * + * This attribute is %TRUE if the archive flag is set. + * + * This attribute is only available for DOS file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE "dos::is-archive" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_DOS_IS_SYSTEM: + * + * A key in the "dos" namespace for checking if the file's backup flag + * is set. + * + * This attribute is %TRUE if the backup flag is set. + * + * This attribute is only available for DOS file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_DOS_IS_SYSTEM "dos::is-system" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT: + * + * A key in the "dos" namespace for checking if the file is a NTFS mount point + * (a volume mount or a junction point). + * + * This attribute is %TRUE if file is a reparse point of type + * [IO_REPARSE_TAG_MOUNT_POINT](https://msdn.microsoft.com/en-us/library/dd541667.aspx). + * + * This attribute is only available for DOS file systems. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.60 + **/ +#define G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT "dos::is-mountpoint" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG: + * + * A key in the "dos" namespace for getting the file NTFS reparse tag. + * + * This value is 0 for files that are not reparse points. + * + * See the [Reparse Tags](https://msdn.microsoft.com/en-us/library/dd541667.aspx) + * page for possible reparse tag values. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + * + * Since: 2.60 + **/ +#define G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG "dos::reparse-point-tag" /* uint32 */ + +/* Owner attributes */ + +/** + * G_FILE_ATTRIBUTE_OWNER_USER: + * + * A key in the "owner" namespace for getting the user name of the + * file's owner. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_OWNER_USER "owner::user" /* string */ + +/** + * G_FILE_ATTRIBUTE_OWNER_USER_REAL: + * + * A key in the "owner" namespace for getting the real name of the + * user that owns the file. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_OWNER_USER_REAL "owner::user-real" /* string */ + +/** + * G_FILE_ATTRIBUTE_OWNER_GROUP: + * + * A key in the "owner" namespace for getting the file owner's group. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_OWNER_GROUP "owner::group" /* string */ + +/* Thumbnails */ + +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_PATH: + * + * A key in the "thumbnail" namespace for getting the path to the thumbnail + * image with the biggest size available. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. + **/ +#define G_FILE_ATTRIBUTE_THUMBNAIL_PATH "thumbnail::path" /* bytestring */ +/** + * G_FILE_ATTRIBUTE_THUMBNAILING_FAILED: + * + * A key in the "thumbnail" namespace for checking if thumbnailing failed. + * + * This attribute is %TRUE if thumbnailing failed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_THUMBNAILING_FAILED "thumbnail::failed" /* boolean */ +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID: + * + * A key in the "thumbnail" namespace for checking whether the thumbnail is outdated. + * + * This attribute is %TRUE if the thumbnail is up-to-date with the file it represents, + * and %FALSE if the file has been modified since the thumbnail was generated. + * + * If %G_FILE_ATTRIBUTE_THUMBNAILING_FAILED is %TRUE and this attribute is %FALSE, + * it indicates that thumbnailing may be attempted again and may succeed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.40 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID "thumbnail::is-valid" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_PATH_NORMAL: + * + * A key in the "thumbnail" namespace for getting the path to the normal + * thumbnail image. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_PATH_NORMAL "thumbnail::path-normal" /* bytestring */ +/** + * G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_NORMAL: + * + * A key in the "thumbnail" namespace for checking if thumbnailing failed + * for the normal image. + * + * This attribute is %TRUE if thumbnailing failed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_NORMAL "thumbnail::failed-normal" /* boolean */ +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_NORMAL: + * + * A key in the "thumbnail" namespace for checking whether the normal + * thumbnail is outdated. + * + * This attribute is %TRUE if the normal thumbnail is up-to-date with the file + * it represents, and %FALSE if the file has been modified since the thumbnail + * was generated. + * + * If %G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_NORMAL is %TRUE and this attribute + * is %FALSE, it indicates that thumbnailing may be attempted again and may + * succeed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_NORMAL "thumbnail::is-valid-normal" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_PATH_LARGE: + * + * A key in the "thumbnail" namespace for getting the path to the large + * thumbnail image. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_PATH_LARGE "thumbnail::path-large" /* bytestring */ +/** + * G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_LARGE: + * + * A key in the "thumbnail" namespace for checking if thumbnailing failed + * for the large image. + * + * This attribute is %TRUE if thumbnailing failed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_LARGE "thumbnail::failed-large" /* boolean */ +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_LARGE: + * + * A key in the "thumbnail" namespace for checking whether the large + * thumbnail is outdated. + * + * This attribute is %TRUE if the large thumbnail is up-to-date with the file + * it represents, and %FALSE if the file has been modified since the thumbnail + * was generated. + * + * If %G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_LARGE is %TRUE and this attribute + * is %FALSE, it indicates that thumbnailing may be attempted again and may + * succeed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_LARGE "thumbnail::is-valid-large" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_PATH_XLARGE: + * + * A key in the "thumbnail" namespace for getting the path to the x-large + * thumbnail image. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_PATH_XLARGE "thumbnail::path-xlarge" /* bytestring */ +/** + * G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XLARGE: + * + * A key in the "thumbnail" namespace for checking if thumbnailing failed + * for the x-large image. + * + * This attribute is %TRUE if thumbnailing failed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XLARGE "thumbnail::failed-xlarge" /* boolean */ +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XLARGE: + * + * A key in the "thumbnail" namespace for checking whether the x-large + * thumbnail is outdated. + * + * This attribute is %TRUE if the x-large thumbnail is up-to-date with the file + * it represents, and %FALSE if the file has been modified since the thumbnail + * was generated. + * + * If %G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XLARGE is %TRUE and this attribute + * is %FALSE, it indicates that thumbnailing may be attempted again and may + * succeed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XLARGE "thumbnail::is-valid-xlarge" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_PATH_XXLARGE: + * + * A key in the "thumbnail" namespace for getting the path to the xx-large + * thumbnail image. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_PATH_XXLARGE "thumbnail::path-xxlarge" /* bytestring */ +/** + * G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XXLARGE: + * + * A key in the "thumbnail" namespace for checking if thumbnailing failed + * for the xx-large image. + * + * This attribute is %TRUE if thumbnailing failed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XXLARGE "thumbnail::failed-xxlarge" /* boolean */ +/** + * G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XXLARGE: + * + * A key in the "thumbnail" namespace for checking whether the xx-large + * thumbnail is outdated. + * + * This attribute is %TRUE if the x-large thumbnail is up-to-date with the file + * it represents, and %FALSE if the file has been modified since the thumbnail + * was generated. + * + * If %G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XXLARGE is %TRUE and this attribute + * is %FALSE, it indicates that thumbnailing may be attempted again and may + * succeed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * + * Since: 2.76 + */ +#define G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XXLARGE "thumbnail::is-valid-xxlarge" /* boolean */ + +/* Preview */ + +/** + * G_FILE_ATTRIBUTE_PREVIEW_ICON: + * + * A key in the "preview" namespace for getting a #GIcon that can be + * used to get preview of the file. + * + * For example, it may be a low resolution thumbnail without metadata. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_OBJECT. + * + * The value for this key should contain a #GIcon. + * + * Since: 2.20 + **/ +#define G_FILE_ATTRIBUTE_PREVIEW_ICON "preview::icon" /* object (GIcon) */ + +/* File system info (for g_file_get_filesystem_info) */ + +/** + * G_FILE_ATTRIBUTE_FILESYSTEM_SIZE: + * + * A key in the "filesystem" namespace for getting the total size (in + * bytes) of the file system, used in g_file_query_filesystem_info(). + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. + **/ +#define G_FILE_ATTRIBUTE_FILESYSTEM_SIZE "filesystem::size" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_FILESYSTEM_FREE: + * + * A key in the "filesystem" namespace for getting the number of bytes + * of free space left on the file system. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. + **/ +#define G_FILE_ATTRIBUTE_FILESYSTEM_FREE "filesystem::free" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_FILESYSTEM_USED: + * + * A key in the "filesystem" namespace for getting the number of bytes + * used by data on the file system. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. + * + * Since: 2.32 + */ +#define G_FILE_ATTRIBUTE_FILESYSTEM_USED "filesystem::used" /* uint64 */ + +/** + * G_FILE_ATTRIBUTE_FILESYSTEM_TYPE: + * + * A key in the "filesystem" namespace for getting the file system's type. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_FILESYSTEM_TYPE "filesystem::type" /* string */ + +/** + * G_FILE_ATTRIBUTE_FILESYSTEM_READONLY: + * + * A key in the "filesystem" namespace for checking if the file system + * is read only. + * + * Is set to %TRUE if the file system is read only. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_FILESYSTEM_READONLY "filesystem::readonly" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW: + * + * A key in the "filesystem" namespace for hinting a file manager + * application whether it should preview (e.g. thumbnail) files on the + * file system. + * + * The value for this key contain a #GFilesystemPreviewType. + **/ +#define G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW "filesystem::use-preview" /* uint32 (GFilesystemPreviewType) */ + +/** + * G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE: + * + * A key in the "filesystem" namespace for checking if the file system + * is remote. + * + * Is set to %TRUE if the file system is remote. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + **/ +#define G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE "filesystem::remote" /* boolean */ + +/** + * G_FILE_ATTRIBUTE_GVFS_BACKEND: + * + * A key in the "gvfs" namespace that gets the name of the current + * GVFS backend in use. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + **/ +#define G_FILE_ATTRIBUTE_GVFS_BACKEND "gvfs::backend" /* string */ + +/** + * G_FILE_ATTRIBUTE_SELINUX_CONTEXT: + * + * A key in the "selinux" namespace for getting the file's SELinux + * context. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + * + * Note that this attribute is only available if GLib has been built + * with SELinux support. + **/ +#define G_FILE_ATTRIBUTE_SELINUX_CONTEXT "selinux::context" /* string */ + +/** + * G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT: + * + * A key in the "trash" namespace for getting the number of (toplevel) items + * that are present in the `trash:///` folder. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. + **/ +#define G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT "trash::item-count" /* uint32 */ + +/** + * G_FILE_ATTRIBUTE_TRASH_ORIG_PATH: + * + * A key in the "trash" namespace for getting the original path of a file + * inside the `trash:///` folder before it was trashed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. + * + * Since: 2.24 + **/ +#define G_FILE_ATTRIBUTE_TRASH_ORIG_PATH "trash::orig-path" /* byte string */ + +/** + * G_FILE_ATTRIBUTE_TRASH_DELETION_DATE: + * + * A key in the "trash" namespace for getting the deletion date and time + * of a file inside the `trash:///` folder. + * + * The format of the returned string is `YYYY-MM-DDThh:mm:ss`. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. + * + * Since: 2.24 + **/ +#define G_FILE_ATTRIBUTE_TRASH_DELETION_DATE "trash::deletion-date" /* string */ + +/** + * G_FILE_ATTRIBUTE_RECENT_MODIFIED: + * + * A key in the "recent" namespace for getting time, when the metadata for the + * file in `recent:///` was last changed. + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_INT64. + * + * Since: 2.52 + **/ +#define G_FILE_ATTRIBUTE_RECENT_MODIFIED "recent::modified" /* int64 (time_t) */ + +GIO_AVAILABLE_IN_ALL +GType g_file_info_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GFileInfo * g_file_info_new (void); +GIO_AVAILABLE_IN_ALL +GFileInfo * g_file_info_dup (GFileInfo *other); +GIO_AVAILABLE_IN_ALL +void g_file_info_copy_into (GFileInfo *src_info, + GFileInfo *dest_info); +GIO_AVAILABLE_IN_ALL +gboolean g_file_info_has_attribute (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +gboolean g_file_info_has_namespace (GFileInfo *info, + const char *name_space); +GIO_AVAILABLE_IN_ALL +char ** g_file_info_list_attributes (GFileInfo *info, + const char *name_space); +GIO_AVAILABLE_IN_ALL +gboolean g_file_info_get_attribute_data (GFileInfo *info, + const char *attribute, + GFileAttributeType *type, + gpointer *value_pp, + GFileAttributeStatus *status); +GIO_AVAILABLE_IN_ALL +GFileAttributeType g_file_info_get_attribute_type (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +void g_file_info_remove_attribute (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +GFileAttributeStatus g_file_info_get_attribute_status (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +gboolean g_file_info_set_attribute_status (GFileInfo *info, + const char *attribute, + GFileAttributeStatus status); +GIO_AVAILABLE_IN_ALL +char * g_file_info_get_attribute_as_string (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +const char * g_file_info_get_attribute_string (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +const char * g_file_info_get_attribute_byte_string (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +gboolean g_file_info_get_attribute_boolean (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +guint32 g_file_info_get_attribute_uint32 (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +gint32 g_file_info_get_attribute_int32 (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +guint64 g_file_info_get_attribute_uint64 (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +gint64 g_file_info_get_attribute_int64 (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +GObject * g_file_info_get_attribute_object (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_ALL +char ** g_file_info_get_attribute_stringv (GFileInfo *info, + const char *attribute); +GIO_AVAILABLE_IN_2_78 +const char * g_file_info_get_attribute_file_path (GFileInfo *info, + const char *attribute); + +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute (GFileInfo *info, + const char *attribute, + GFileAttributeType type, + gpointer value_p); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_string (GFileInfo *info, + const char *attribute, + const char *attr_value); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_byte_string (GFileInfo *info, + const char *attribute, + const char *attr_value); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_boolean (GFileInfo *info, + const char *attribute, + gboolean attr_value); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_uint32 (GFileInfo *info, + const char *attribute, + guint32 attr_value); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_int32 (GFileInfo *info, + const char *attribute, + gint32 attr_value); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_uint64 (GFileInfo *info, + const char *attribute, + guint64 attr_value); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_int64 (GFileInfo *info, + const char *attribute, + gint64 attr_value); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_object (GFileInfo *info, + const char *attribute, + GObject *attr_value); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_stringv (GFileInfo *info, + const char *attribute, + char **attr_value); +GIO_AVAILABLE_IN_2_78 +void g_file_info_set_attribute_file_path (GFileInfo *info, + const char *attribute, + const char *attr_value); + +GIO_AVAILABLE_IN_ALL +void g_file_info_clear_status (GFileInfo *info); + +/* Helper getters: */ +GIO_AVAILABLE_IN_2_36 +GDateTime * g_file_info_get_deletion_date (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +GFileType g_file_info_get_file_type (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +gboolean g_file_info_get_is_hidden (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +gboolean g_file_info_get_is_backup (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +gboolean g_file_info_get_is_symlink (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +const char * g_file_info_get_name (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +const char * g_file_info_get_display_name (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +const char * g_file_info_get_edit_name (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +GIcon * g_file_info_get_icon (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +GIcon * g_file_info_get_symbolic_icon (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +const char * g_file_info_get_content_type (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +goffset g_file_info_get_size (GFileInfo *info); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GIO_DEPRECATED_IN_2_62_FOR(g_file_info_get_modification_date_time) +void g_file_info_get_modification_time (GFileInfo *info, + GTimeVal *result); +G_GNUC_END_IGNORE_DEPRECATIONS +GIO_AVAILABLE_IN_2_62 +GDateTime * g_file_info_get_modification_date_time (GFileInfo *info); +GIO_AVAILABLE_IN_2_70 +GDateTime * g_file_info_get_access_date_time (GFileInfo *info); +GIO_AVAILABLE_IN_2_70 +GDateTime * g_file_info_get_creation_date_time (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +const char * g_file_info_get_symlink_target (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +const char * g_file_info_get_etag (GFileInfo *info); +GIO_AVAILABLE_IN_ALL +gint32 g_file_info_get_sort_order (GFileInfo *info); + +GIO_AVAILABLE_IN_ALL +void g_file_info_set_attribute_mask (GFileInfo *info, + GFileAttributeMatcher *mask); +GIO_AVAILABLE_IN_ALL +void g_file_info_unset_attribute_mask (GFileInfo *info); + +/* Helper setters: */ +GIO_AVAILABLE_IN_ALL +void g_file_info_set_file_type (GFileInfo *info, + GFileType type); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_is_hidden (GFileInfo *info, + gboolean is_hidden); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_is_symlink (GFileInfo *info, + gboolean is_symlink); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_name (GFileInfo *info, + const char *name); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_display_name (GFileInfo *info, + const char *display_name); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_edit_name (GFileInfo *info, + const char *edit_name); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_icon (GFileInfo *info, + GIcon *icon); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_symbolic_icon (GFileInfo *info, + GIcon *icon); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_content_type (GFileInfo *info, + const char *content_type); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_size (GFileInfo *info, + goffset size); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GIO_DEPRECATED_IN_2_62_FOR(g_file_info_set_modification_date_time) +void g_file_info_set_modification_time (GFileInfo *info, + GTimeVal *mtime); +G_GNUC_END_IGNORE_DEPRECATIONS +GIO_AVAILABLE_IN_2_62 +void g_file_info_set_modification_date_time (GFileInfo *info, + GDateTime *mtime); +GIO_AVAILABLE_IN_2_70 +void g_file_info_set_access_date_time (GFileInfo *info, + GDateTime *atime); +GIO_AVAILABLE_IN_2_70 +void g_file_info_set_creation_date_time (GFileInfo *info, + GDateTime *creation_time); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_symlink_target (GFileInfo *info, + const char *symlink_target); +GIO_AVAILABLE_IN_ALL +void g_file_info_set_sort_order (GFileInfo *info, + gint32 sort_order); + +#define G_TYPE_FILE_ATTRIBUTE_MATCHER (g_file_attribute_matcher_get_type ()) +GIO_AVAILABLE_IN_ALL +GType g_file_attribute_matcher_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GFileAttributeMatcher *g_file_attribute_matcher_new (const char *attributes); +GIO_AVAILABLE_IN_ALL +GFileAttributeMatcher *g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher); +GIO_AVAILABLE_IN_ALL +void g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher); +GIO_AVAILABLE_IN_ALL +GFileAttributeMatcher *g_file_attribute_matcher_subtract (GFileAttributeMatcher *matcher, + GFileAttributeMatcher *subtract); +GIO_AVAILABLE_IN_ALL +gboolean g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher, + const char *attribute); +GIO_AVAILABLE_IN_ALL +gboolean g_file_attribute_matcher_matches_only (GFileAttributeMatcher *matcher, + const char *attribute); +GIO_AVAILABLE_IN_ALL +gboolean g_file_attribute_matcher_enumerate_namespace (GFileAttributeMatcher *matcher, + const char *ns); +GIO_AVAILABLE_IN_ALL +const char * g_file_attribute_matcher_enumerate_next (GFileAttributeMatcher *matcher); +GIO_AVAILABLE_IN_2_32 +char * g_file_attribute_matcher_to_string (GFileAttributeMatcher *matcher); + +G_END_DECLS + +#endif /* __G_FILE_INFO_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfileinputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfileinputstream.h new file mode 100644 index 00000000..a1227654 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfileinputstream.h @@ -0,0 +1,108 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_INPUT_STREAM_H__ +#define __G_FILE_INPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILE_INPUT_STREAM (g_file_input_stream_get_type ()) +#define G_FILE_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_INPUT_STREAM, GFileInputStream)) +#define G_FILE_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_INPUT_STREAM, GFileInputStreamClass)) +#define G_IS_FILE_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_INPUT_STREAM)) +#define G_IS_FILE_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_INPUT_STREAM)) +#define G_FILE_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_INPUT_STREAM, GFileInputStreamClass)) + +typedef struct _GFileInputStreamClass GFileInputStreamClass; +typedef struct _GFileInputStreamPrivate GFileInputStreamPrivate; + +struct _GFileInputStream +{ + GInputStream parent_instance; + + /*< private >*/ + GFileInputStreamPrivate *priv; +}; + +struct _GFileInputStreamClass +{ + GInputStreamClass parent_class; + + goffset (* tell) (GFileInputStream *stream); + gboolean (* can_seek) (GFileInputStream *stream); + gboolean (* seek) (GFileInputStream *stream, + goffset offset, + GSeekType type, + GCancellable *cancellable, + GError **error); + GFileInfo * (* query_info) (GFileInputStream *stream, + const char *attributes, + GCancellable *cancellable, + GError **error); + void (* query_info_async) (GFileInputStream *stream, + const char *attributes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileInfo * (* query_info_finish) (GFileInputStream *stream, + GAsyncResult *result, + GError **error); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_file_input_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GFileInfo *g_file_input_stream_query_info (GFileInputStream *stream, + const char *attributes, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_input_stream_query_info_async (GFileInputStream *stream, + const char *attributes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileInfo *g_file_input_stream_query_info_finish (GFileInputStream *stream, + GAsyncResult *result, + GError **error); + +G_END_DECLS + +#endif /* __G_FILE_FILE_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfileiostream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfileiostream.h new file mode 100644 index 00000000..c516fb25 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfileiostream.h @@ -0,0 +1,115 @@ +/* GIO - GLib Input, Io and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_IO_STREAM_H__ +#define __G_FILE_IO_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILE_IO_STREAM (g_file_io_stream_get_type ()) +#define G_FILE_IO_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_IO_STREAM, GFileIOStream)) +#define G_FILE_IO_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_IO_STREAM, GFileIOStreamClass)) +#define G_IS_FILE_IO_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_IO_STREAM)) +#define G_IS_FILE_IO_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_IO_STREAM)) +#define G_FILE_IO_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_IO_STREAM, GFileIOStreamClass)) + +typedef struct _GFileIOStreamClass GFileIOStreamClass; +typedef struct _GFileIOStreamPrivate GFileIOStreamPrivate; + +struct _GFileIOStream +{ + GIOStream parent_instance; + + /*< private >*/ + GFileIOStreamPrivate *priv; +}; + +struct _GFileIOStreamClass +{ + GIOStreamClass parent_class; + + goffset (* tell) (GFileIOStream *stream); + gboolean (* can_seek) (GFileIOStream *stream); + gboolean (* seek) (GFileIOStream *stream, + goffset offset, + GSeekType type, + GCancellable *cancellable, + GError **error); + gboolean (* can_truncate) (GFileIOStream *stream); + gboolean (* truncate_fn) (GFileIOStream *stream, + goffset size, + GCancellable *cancellable, + GError **error); + GFileInfo * (* query_info) (GFileIOStream *stream, + const char *attributes, + GCancellable *cancellable, + GError **error); + void (* query_info_async) (GFileIOStream *stream, + const char *attributes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileInfo * (* query_info_finish) (GFileIOStream *stream, + GAsyncResult *result, + GError **error); + char * (* get_etag) (GFileIOStream *stream); + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_file_io_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GFileInfo *g_file_io_stream_query_info (GFileIOStream *stream, + const char *attributes, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_io_stream_query_info_async (GFileIOStream *stream, + const char *attributes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileInfo *g_file_io_stream_query_info_finish (GFileIOStream *stream, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +char * g_file_io_stream_get_etag (GFileIOStream *stream); + +G_END_DECLS + +#endif /* __G_FILE_FILE_IO_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfilemonitor.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfilemonitor.h new file mode 100644 index 00000000..63ab1e04 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfilemonitor.h @@ -0,0 +1,95 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_MONITOR_H__ +#define __G_FILE_MONITOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILE_MONITOR (g_file_monitor_get_type ()) +#define G_FILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_MONITOR, GFileMonitor)) +#define G_FILE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_MONITOR, GFileMonitorClass)) +#define G_IS_FILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_MONITOR)) +#define G_IS_FILE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_MONITOR)) +#define G_FILE_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_MONITOR, GFileMonitorClass)) + +typedef struct _GFileMonitorClass GFileMonitorClass; +typedef struct _GFileMonitorPrivate GFileMonitorPrivate; + +struct _GFileMonitor +{ + GObject parent_instance; + + /*< private >*/ + GFileMonitorPrivate *priv; +}; + +struct _GFileMonitorClass +{ + GObjectClass parent_class; + + /* Signals */ + void (* changed) (GFileMonitor *monitor, + GFile *file, + GFile *other_file, + GFileMonitorEvent event_type); + + /* Virtual Table */ + gboolean (* cancel) (GFileMonitor *monitor); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_file_monitor_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gboolean g_file_monitor_cancel (GFileMonitor *monitor); +GIO_AVAILABLE_IN_ALL +gboolean g_file_monitor_is_cancelled (GFileMonitor *monitor); +GIO_AVAILABLE_IN_ALL +void g_file_monitor_set_rate_limit (GFileMonitor *monitor, + gint limit_msecs); + + +/* For implementations */ +GIO_AVAILABLE_IN_ALL +void g_file_monitor_emit_event (GFileMonitor *monitor, + GFile *child, + GFile *other_file, + GFileMonitorEvent event_type); + +G_END_DECLS + +#endif /* __G_FILE_MONITOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfilenamecompleter.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfilenamecompleter.h new file mode 100644 index 00000000..d835af8d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfilenamecompleter.h @@ -0,0 +1,76 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILENAME_COMPLETER_H__ +#define __G_FILENAME_COMPLETER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILENAME_COMPLETER (g_filename_completer_get_type ()) +#define G_FILENAME_COMPLETER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILENAME_COMPLETER, GFilenameCompleter)) +#define G_FILENAME_COMPLETER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILENAME_COMPLETER, GFilenameCompleterClass)) +#define G_FILENAME_COMPLETER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILENAME_COMPLETER, GFilenameCompleterClass)) +#define G_IS_FILENAME_COMPLETER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILENAME_COMPLETER)) +#define G_IS_FILENAME_COMPLETER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILENAME_COMPLETER)) + +typedef struct _GFilenameCompleterClass GFilenameCompleterClass; + +struct _GFilenameCompleterClass +{ + GObjectClass parent_class; + + /*< public >*/ + /* signals */ + void (* got_completion_data) (GFilenameCompleter *filename_completer); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_filename_completer_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GFilenameCompleter *g_filename_completer_new (void); + +GIO_AVAILABLE_IN_ALL +char * g_filename_completer_get_completion_suffix (GFilenameCompleter *completer, + const char *initial_text); +GIO_AVAILABLE_IN_ALL +char ** g_filename_completer_get_completions (GFilenameCompleter *completer, + const char *initial_text); +GIO_AVAILABLE_IN_ALL +void g_filename_completer_set_dirs_only (GFilenameCompleter *completer, + gboolean dirs_only); + +G_END_DECLS + +#endif /* __G_FILENAME_COMPLETER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfileoutputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfileoutputstream.h new file mode 100644 index 00000000..edc9b103 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfileoutputstream.h @@ -0,0 +1,116 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_FILE_OUTPUT_STREAM_H__ +#define __G_FILE_OUTPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILE_OUTPUT_STREAM (g_file_output_stream_get_type ()) +#define G_FILE_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_OUTPUT_STREAM, GFileOutputStream)) +#define G_FILE_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_OUTPUT_STREAM, GFileOutputStreamClass)) +#define G_IS_FILE_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_OUTPUT_STREAM)) +#define G_IS_FILE_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_OUTPUT_STREAM)) +#define G_FILE_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_OUTPUT_STREAM, GFileOutputStreamClass)) + +typedef struct _GFileOutputStreamClass GFileOutputStreamClass; +typedef struct _GFileOutputStreamPrivate GFileOutputStreamPrivate; + +struct _GFileOutputStream +{ + GOutputStream parent_instance; + + /*< private >*/ + GFileOutputStreamPrivate *priv; +}; + +struct _GFileOutputStreamClass +{ + GOutputStreamClass parent_class; + + goffset (* tell) (GFileOutputStream *stream); + gboolean (* can_seek) (GFileOutputStream *stream); + gboolean (* seek) (GFileOutputStream *stream, + goffset offset, + GSeekType type, + GCancellable *cancellable, + GError **error); + gboolean (* can_truncate) (GFileOutputStream *stream); + gboolean (* truncate_fn) (GFileOutputStream *stream, + goffset size, + GCancellable *cancellable, + GError **error); + GFileInfo * (* query_info) (GFileOutputStream *stream, + const char *attributes, + GCancellable *cancellable, + GError **error); + void (* query_info_async) (GFileOutputStream *stream, + const char *attributes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GFileInfo * (* query_info_finish) (GFileOutputStream *stream, + GAsyncResult *result, + GError **error); + char * (* get_etag) (GFileOutputStream *stream); + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_file_output_stream_get_type (void) G_GNUC_CONST; + + +GIO_AVAILABLE_IN_ALL +GFileInfo *g_file_output_stream_query_info (GFileOutputStream *stream, + const char *attributes, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_file_output_stream_query_info_async (GFileOutputStream *stream, + const char *attributes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GFileInfo *g_file_output_stream_query_info_finish (GFileOutputStream *stream, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +char * g_file_output_stream_get_etag (GFileOutputStream *stream); + +G_END_DECLS + +#endif /* __G_FILE_FILE_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfilterinputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfilterinputstream.h new file mode 100644 index 00000000..6009eea8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfilterinputstream.h @@ -0,0 +1,75 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Christian Kellner + */ + +#ifndef __G_FILTER_INPUT_STREAM_H__ +#define __G_FILTER_INPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILTER_INPUT_STREAM (g_filter_input_stream_get_type ()) +#define G_FILTER_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILTER_INPUT_STREAM, GFilterInputStream)) +#define G_FILTER_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILTER_INPUT_STREAM, GFilterInputStreamClass)) +#define G_IS_FILTER_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILTER_INPUT_STREAM)) +#define G_IS_FILTER_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILTER_INPUT_STREAM)) +#define G_FILTER_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILTER_INPUT_STREAM, GFilterInputStreamClass)) + +typedef struct _GFilterInputStreamClass GFilterInputStreamClass; + +struct _GFilterInputStream +{ + GInputStream parent_instance; + + /**/ + GInputStream *base_stream; +}; + +struct _GFilterInputStreamClass +{ + GInputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); +}; + + +GIO_AVAILABLE_IN_ALL +GType g_filter_input_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GInputStream * g_filter_input_stream_get_base_stream (GFilterInputStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_filter_input_stream_get_close_base_stream (GFilterInputStream *stream); +GIO_AVAILABLE_IN_ALL +void g_filter_input_stream_set_close_base_stream (GFilterInputStream *stream, + gboolean close_base); + +G_END_DECLS + +#endif /* __G_FILTER_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gfilteroutputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gfilteroutputstream.h new file mode 100644 index 00000000..160e80da --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gfilteroutputstream.h @@ -0,0 +1,75 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Christian Kellner + */ + +#ifndef __G_FILTER_OUTPUT_STREAM_H__ +#define __G_FILTER_OUTPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_FILTER_OUTPUT_STREAM (g_filter_output_stream_get_type ()) +#define G_FILTER_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILTER_OUTPUT_STREAM, GFilterOutputStream)) +#define G_FILTER_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILTER_OUTPUT_STREAM, GFilterOutputStreamClass)) +#define G_IS_FILTER_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILTER_OUTPUT_STREAM)) +#define G_IS_FILTER_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILTER_OUTPUT_STREAM)) +#define G_FILTER_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILTER_OUTPUT_STREAM, GFilterOutputStreamClass)) + +typedef struct _GFilterOutputStreamClass GFilterOutputStreamClass; + +struct _GFilterOutputStream +{ + GOutputStream parent_instance; + + /*< protected >*/ + GOutputStream *base_stream; +}; + +struct _GFilterOutputStreamClass +{ + GOutputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); +}; + + +GIO_AVAILABLE_IN_ALL +GType g_filter_output_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GOutputStream * g_filter_output_stream_get_base_stream (GFilterOutputStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_filter_output_stream_get_close_base_stream (GFilterOutputStream *stream); +GIO_AVAILABLE_IN_ALL +void g_filter_output_stream_set_close_base_stream (GFilterOutputStream *stream, + gboolean close_base); + +G_END_DECLS + +#endif /* __G_FILTER_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gicon.h b/illumos-x86_64/usr/include/glib-2.0/gio/gicon.h new file mode 100644 index 00000000..d6dd5fe9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gicon.h @@ -0,0 +1,128 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_ICON_H__ +#define __G_ICON_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_ICON (g_icon_get_type ()) +#define G_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ICON, GIcon)) +#define G_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ICON)) +#define G_ICON_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ICON, GIconIface)) + +typedef struct _GIconIface GIconIface; + +/** + * GIconIface: + * @g_iface: The parent interface. + * @hash: A hash for a given #GIcon. + * @equal: Checks if two #GIcons are equal. + * @to_tokens: Serializes a #GIcon into tokens. The tokens must not + * contain any whitespace. Don't implement if the #GIcon can't be + * serialized (Since 2.20). + * @from_tokens: Constructs a #GIcon from tokens. Set the #GError if + * the tokens are malformed. Don't implement if the #GIcon can't be + * serialized (Since 2.20). + * @serialize: Serializes a #GIcon into a #GVariant. Since: 2.38 + * + * GIconIface is used to implement GIcon types for various + * different systems. See #GThemedIcon and #GLoadableIcon for + * examples of how to implement this interface. + */ +struct _GIconIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + guint (* hash) (GIcon *icon); + gboolean (* equal) (GIcon *icon1, + GIcon *icon2); + + /** + * GIconIface::to_tokens: + * @icon: The #GIcon + * @tokens: (element-type utf8) (out caller-allocates): + * The array to fill with tokens + * @out_version: (out): version of serialized tokens + * + * Serializes the @icon into string tokens. + * This is can be invoked when g_icon_new_for_string() is called. + * + * Returns: %TRUE if serialization took place, %FALSE otherwise + * + * Since: 2.20 + */ + gboolean (* to_tokens) (GIcon *icon, + GPtrArray *tokens, + gint *out_version); + + /** + * GIconIface::from_tokens: + * @tokens: (array length=num_tokens): An array of tokens + * @num_tokens: The number of tokens in @tokens + * @version: Version of the serialized tokens + * @error: Return location for errors, or %NULL to ignore + * + * Constructs a #GIcon from a list of @tokens. + * + * Returns: (nullable) (transfer full): the #GIcon or %NULL on error + * + * Since: 2.20 + */ + GIcon * (* from_tokens) (gchar **tokens, + gint num_tokens, + gint version, + GError **error); + + GVariant * (* serialize) (GIcon *icon); +}; + +GIO_AVAILABLE_IN_ALL +GType g_icon_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +guint g_icon_hash (gconstpointer icon); +GIO_AVAILABLE_IN_ALL +gboolean g_icon_equal (GIcon *icon1, + GIcon *icon2); +GIO_AVAILABLE_IN_ALL +gchar *g_icon_to_string (GIcon *icon); +GIO_AVAILABLE_IN_ALL +GIcon *g_icon_new_for_string (const gchar *str, + GError **error); + +GIO_AVAILABLE_IN_2_38 +GVariant * g_icon_serialize (GIcon *icon); +GIO_AVAILABLE_IN_2_38 +GIcon * g_icon_deserialize (GVariant *value); + +G_END_DECLS + +#endif /* __G_ICON_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/ginetaddress.h b/illumos-x86_64/usr/include/glib-2.0/gio/ginetaddress.h new file mode 100644 index 00000000..ea503a92 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/ginetaddress.h @@ -0,0 +1,125 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Christian Kellner + * Samuel Cormier-Iijima + */ + +#ifndef __G_INET_ADDRESS_H__ +#define __G_INET_ADDRESS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_INET_ADDRESS (g_inet_address_get_type ()) +#define G_INET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INET_ADDRESS, GInetAddress)) +#define G_INET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INET_ADDRESS, GInetAddressClass)) +#define G_IS_INET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INET_ADDRESS)) +#define G_IS_INET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INET_ADDRESS)) +#define G_INET_ADDRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INET_ADDRESS, GInetAddressClass)) + +typedef struct _GInetAddressClass GInetAddressClass; +typedef struct _GInetAddressPrivate GInetAddressPrivate; + +struct _GInetAddress +{ + GObject parent_instance; + + /*< private >*/ + GInetAddressPrivate *priv; +}; + +struct _GInetAddressClass +{ + GObjectClass parent_class; + + gchar * (*to_string) (GInetAddress *address); + const guint8 * (*to_bytes) (GInetAddress *address); +}; + +GIO_AVAILABLE_IN_ALL +GType g_inet_address_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GInetAddress * g_inet_address_new_from_string (const gchar *string); + +GIO_AVAILABLE_IN_ALL +GInetAddress * g_inet_address_new_from_bytes (const guint8 *bytes, + GSocketFamily family); + +GIO_AVAILABLE_IN_ALL +GInetAddress * g_inet_address_new_loopback (GSocketFamily family); + +GIO_AVAILABLE_IN_ALL +GInetAddress * g_inet_address_new_any (GSocketFamily family); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_equal (GInetAddress *address, + GInetAddress *other_address); + +GIO_AVAILABLE_IN_ALL +gchar * g_inet_address_to_string (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +const guint8 * g_inet_address_to_bytes (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gsize g_inet_address_get_native_size (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +GSocketFamily g_inet_address_get_family (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_any (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_loopback (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_link_local (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_site_local (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_multicast (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_mc_global (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_mc_link_local (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_mc_node_local (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_mc_org_local (GInetAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_inet_address_get_is_mc_site_local (GInetAddress *address); + +G_END_DECLS + +#endif /* __G_INET_ADDRESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/ginetaddressmask.h b/illumos-x86_64/usr/include/glib-2.0/gio/ginetaddressmask.h new file mode 100644 index 00000000..25cce750 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/ginetaddressmask.h @@ -0,0 +1,86 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright 2011 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_INET_ADDRESS_MASK_H__ +#define __G_INET_ADDRESS_MASK_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_INET_ADDRESS_MASK (g_inet_address_mask_get_type ()) +#define G_INET_ADDRESS_MASK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INET_ADDRESS_MASK, GInetAddressMask)) +#define G_INET_ADDRESS_MASK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INET_ADDRESS_MASK, GInetAddressMaskClass)) +#define G_IS_INET_ADDRESS_MASK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INET_ADDRESS_MASK)) +#define G_IS_INET_ADDRESS_MASK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INET_ADDRESS_MASK)) +#define G_INET_ADDRESS_MASK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INET_ADDRESS_MASK, GInetAddressMaskClass)) + +typedef struct _GInetAddressMaskClass GInetAddressMaskClass; +typedef struct _GInetAddressMaskPrivate GInetAddressMaskPrivate; + +struct _GInetAddressMask +{ + GObject parent_instance; + + /*< private >*/ + GInetAddressMaskPrivate *priv; +}; + +struct _GInetAddressMaskClass +{ + GObjectClass parent_class; + +}; + +GIO_AVAILABLE_IN_2_32 +GType g_inet_address_mask_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +GInetAddressMask *g_inet_address_mask_new (GInetAddress *addr, + guint length, + GError **error); + +GIO_AVAILABLE_IN_2_32 +GInetAddressMask *g_inet_address_mask_new_from_string (const gchar *mask_string, + GError **error); +GIO_AVAILABLE_IN_2_32 +gchar *g_inet_address_mask_to_string (GInetAddressMask *mask); + +GIO_AVAILABLE_IN_2_32 +GSocketFamily g_inet_address_mask_get_family (GInetAddressMask *mask); +GIO_AVAILABLE_IN_2_32 +GInetAddress *g_inet_address_mask_get_address (GInetAddressMask *mask); +GIO_AVAILABLE_IN_2_32 +guint g_inet_address_mask_get_length (GInetAddressMask *mask); + +GIO_AVAILABLE_IN_2_32 +gboolean g_inet_address_mask_matches (GInetAddressMask *mask, + GInetAddress *address); +GIO_AVAILABLE_IN_2_32 +gboolean g_inet_address_mask_equal (GInetAddressMask *mask, + GInetAddressMask *mask2); + +G_END_DECLS + +#endif /* __G_INET_ADDRESS_MASK_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/ginetsocketaddress.h b/illumos-x86_64/usr/include/glib-2.0/gio/ginetsocketaddress.h new file mode 100644 index 00000000..a983abef --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/ginetsocketaddress.h @@ -0,0 +1,80 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Christian Kellner + * Samuel Cormier-Iijima + */ + +#ifndef __G_INET_SOCKET_ADDRESS_H__ +#define __G_INET_SOCKET_ADDRESS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_INET_SOCKET_ADDRESS (g_inet_socket_address_get_type ()) +#define G_INET_SOCKET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INET_SOCKET_ADDRESS, GInetSocketAddress)) +#define G_INET_SOCKET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INET_SOCKET_ADDRESS, GInetSocketAddressClass)) +#define G_IS_INET_SOCKET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INET_SOCKET_ADDRESS)) +#define G_IS_INET_SOCKET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INET_SOCKET_ADDRESS)) +#define G_INET_SOCKET_ADDRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INET_SOCKET_ADDRESS, GInetSocketAddressClass)) + +typedef struct _GInetSocketAddressClass GInetSocketAddressClass; +typedef struct _GInetSocketAddressPrivate GInetSocketAddressPrivate; + +struct _GInetSocketAddress +{ + GSocketAddress parent_instance; + + /*< private >*/ + GInetSocketAddressPrivate *priv; +}; + +struct _GInetSocketAddressClass +{ + GSocketAddressClass parent_class; +}; + +GIO_AVAILABLE_IN_ALL +GType g_inet_socket_address_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_inet_socket_address_new (GInetAddress *address, + guint16 port); +GIO_AVAILABLE_IN_2_40 +GSocketAddress *g_inet_socket_address_new_from_string (const char *address, + guint port); + +GIO_AVAILABLE_IN_ALL +GInetAddress * g_inet_socket_address_get_address (GInetSocketAddress *address); +GIO_AVAILABLE_IN_ALL +guint16 g_inet_socket_address_get_port (GInetSocketAddress *address); + +GIO_AVAILABLE_IN_2_32 +guint32 g_inet_socket_address_get_flowinfo (GInetSocketAddress *address); +GIO_AVAILABLE_IN_2_32 +guint32 g_inet_socket_address_get_scope_id (GInetSocketAddress *address); + +G_END_DECLS + +#endif /* __G_INET_SOCKET_ADDRESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/ginitable.h b/illumos-x86_64/usr/include/glib-2.0/gio/ginitable.h new file mode 100644 index 00000000..5eee369e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/ginitable.h @@ -0,0 +1,100 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_INITABLE_H__ +#define __G_INITABLE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_INITABLE (g_initable_get_type ()) +#define G_INITABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_INITABLE, GInitable)) +#define G_IS_INITABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_INITABLE)) +#define G_INITABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_INITABLE, GInitableIface)) +#define G_TYPE_IS_INITABLE(type) (g_type_is_a ((type), G_TYPE_INITABLE)) + +typedef struct _GInitableIface GInitableIface; + +/** + * GInitableIface: + * @g_iface: The parent interface. + * @init: Initializes the object. + * + * Provides an interface for initializing object such that initialization + * may fail. + * + * Since: 2.22 + **/ +struct _GInitableIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + gboolean (* init) (GInitable *initable, + GCancellable *cancellable, + GError **error); +}; + + +GIO_AVAILABLE_IN_ALL +GType g_initable_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gboolean g_initable_init (GInitable *initable, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +gpointer g_initable_new (GType object_type, + GCancellable *cancellable, + GError **error, + const gchar *first_property_name, + ...); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +GIO_DEPRECATED_IN_2_54_FOR(g_object_new_with_properties and g_initable_init) +gpointer g_initable_newv (GType object_type, + guint n_parameters, + GParameter *parameters, + GCancellable *cancellable, + GError **error); + +G_GNUC_END_IGNORE_DEPRECATIONS + +GIO_AVAILABLE_IN_ALL +GObject* g_initable_new_valist (GType object_type, + const gchar *first_property_name, + va_list var_args, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + + +#endif /* __G_INITABLE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/ginputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/ginputstream.h new file mode 100644 index 00000000..f5cce170 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/ginputstream.h @@ -0,0 +1,213 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_INPUT_STREAM_H__ +#define __G_INPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_INPUT_STREAM (g_input_stream_get_type ()) +#define G_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INPUT_STREAM, GInputStream)) +#define G_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INPUT_STREAM, GInputStreamClass)) +#define G_IS_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INPUT_STREAM)) +#define G_IS_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INPUT_STREAM)) +#define G_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INPUT_STREAM, GInputStreamClass)) + +typedef struct _GInputStreamClass GInputStreamClass; +typedef struct _GInputStreamPrivate GInputStreamPrivate; + +struct _GInputStream +{ + GObject parent_instance; + + /*< private >*/ + GInputStreamPrivate *priv; +}; + +struct _GInputStreamClass +{ + GObjectClass parent_class; + + /* Sync ops: */ + + gssize (* read_fn) (GInputStream *stream, + void *buffer, + gsize count, + GCancellable *cancellable, + GError **error); + gssize (* skip) (GInputStream *stream, + gsize count, + GCancellable *cancellable, + GError **error); + gboolean (* close_fn) (GInputStream *stream, + GCancellable *cancellable, + GError **error); + + /* Async ops: (optional in derived classes) */ + void (* read_async) (GInputStream *stream, + void *buffer, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gssize (* read_finish) (GInputStream *stream, + GAsyncResult *result, + GError **error); + void (* skip_async) (GInputStream *stream, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gssize (* skip_finish) (GInputStream *stream, + GAsyncResult *result, + GError **error); + void (* close_async) (GInputStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* close_finish) (GInputStream *stream, + GAsyncResult *result, + GError **error); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_input_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gssize g_input_stream_read (GInputStream *stream, + void *buffer, + gsize count, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_input_stream_read_all (GInputStream *stream, + void *buffer, + gsize count, + gsize *bytes_read, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_34 +GBytes *g_input_stream_read_bytes (GInputStream *stream, + gsize count, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_input_stream_skip (GInputStream *stream, + gsize count, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_input_stream_close (GInputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_input_stream_read_async (GInputStream *stream, + void *buffer, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gssize g_input_stream_read_finish (GInputStream *stream, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_44 +void g_input_stream_read_all_async (GInputStream *stream, + void *buffer, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_44 +gboolean g_input_stream_read_all_finish (GInputStream *stream, + GAsyncResult *result, + gsize *bytes_read, + GError **error); + +GIO_AVAILABLE_IN_2_34 +void g_input_stream_read_bytes_async (GInputStream *stream, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_34 +GBytes *g_input_stream_read_bytes_finish (GInputStream *stream, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_input_stream_skip_async (GInputStream *stream, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gssize g_input_stream_skip_finish (GInputStream *stream, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_input_stream_close_async (GInputStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_input_stream_close_finish (GInputStream *stream, + GAsyncResult *result, + GError **error); + +/* For implementations: */ + +GIO_AVAILABLE_IN_ALL +gboolean g_input_stream_is_closed (GInputStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_input_stream_has_pending (GInputStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_input_stream_set_pending (GInputStream *stream, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_input_stream_clear_pending (GInputStream *stream); + +G_END_DECLS + +#endif /* __G_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gio-autocleanups.h b/illumos-x86_64/usr/include/glib-2.0/gio/gio-autocleanups.h new file mode 100644 index 00000000..315288e6 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gio-autocleanups.h @@ -0,0 +1,159 @@ +/* + * Copyright © 2015 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GI_SCANNER__ + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAction, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GActionMap, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAppInfo, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAppLaunchContext, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAppInfoMonitor, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GApplicationCommandLine, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GApplication, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAsyncInitable, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAsyncResult, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBufferedInputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBufferedOutputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBytesIcon, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GCancellable, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GCharsetConverter, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GConverter, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GConverterInputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GConverterOutputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GCredentials, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDatagramBased, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDataInputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDataOutputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusActionGroup, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusAuthObserver, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusConnection, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusInterface, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusInterfaceSkeleton, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusMenuModel, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusMessage, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusMethodInvocation, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusNodeInfo, g_dbus_node_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusObject, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusObjectManagerClient, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusObjectManager, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusObjectManagerServer, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusObjectProxy, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusObjectSkeleton, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusProxy, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusServer, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDrive, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GEmblemedIcon, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GEmblem, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileEnumerator, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFile, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileAttributeInfoList, g_file_attribute_info_list_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileIcon, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileInfo, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileInputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileIOStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileMonitor, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFilenameCompleter, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileOutputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFilterInputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFilterOutputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GIcon, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInetAddress, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInetAddressMask, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInetSocketAddress, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitable, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GIOModule, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GIOStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GLoadableIcon, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMemoryInputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMemoryOutputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMenu, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMenuItem, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMenuModel, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMenuAttributeIter, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMenuLinkIter, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMount, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMountOperation, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNativeVolumeMonitor, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNetworkAddress, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNetworkMonitor, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNetworkService, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNotification, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOutputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPermission, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPollableInputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPollableOutputStream, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPropertyAction, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GProxyAddressEnumerator, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GProxyAddress, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GProxy, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GProxyResolver, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRemoteActionGroup, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GResolver, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GResource, g_resource_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSeekable, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSettingsBackend, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSettingsSchema, g_settings_schema_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSettingsSchemaKey, g_settings_schema_key_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSettingsSchemaSource, g_settings_schema_source_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSettings, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSimpleActionGroup, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSimpleAction, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSimpleAsyncResult, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSimplePermission, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSimpleProxyResolver, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketAddressEnumerator, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketAddress, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketClient, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketConnectable, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketConnection, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketControlMessage, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocket, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketListener, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketService, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSubprocess, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSubprocessLauncher, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTask, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTcpConnection, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTcpWrapperConnection, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTestDBus, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GThemedIcon, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GThreadedSocketService, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsBackend, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsCertificate, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsClientConnection, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsConnection, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsDatabase, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsFileDatabase, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsInteraction, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsPassword, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsServerConnection, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVfs, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVolume, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVolumeMonitor, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GZlibCompressor, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GZlibDecompressor, g_object_unref) + +#endif /* __GI_SCANNER__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gio-visibility.h b/illumos-x86_64/usr/include/glib-2.0/gio/gio-visibility.h new file mode 100644 index 00000000..72ed3cd7 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gio-visibility.h @@ -0,0 +1,1054 @@ +#pragma once + +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(GIO_STATIC_COMPILATION) +# define _GIO_EXPORT __declspec(dllexport) +# define _GIO_IMPORT __declspec(dllimport) +#elif __GNUC__ >= 4 +# define _GIO_EXPORT __attribute__((visibility("default"))) +# define _GIO_IMPORT +#else +# define _GIO_EXPORT +# define _GIO_IMPORT +#endif +#ifdef GIO_COMPILATION +# define _GIO_API _GIO_EXPORT +#else +# define _GIO_API _GIO_IMPORT +#endif + +#define _GIO_EXTERN _GIO_API extern + +#define GIO_VAR _GIO_EXTERN +#define GIO_AVAILABLE_IN_ALL _GIO_EXTERN + +#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS +#define GIO_DEPRECATED _GIO_EXTERN +#define GIO_DEPRECATED_FOR(f) _GIO_EXTERN +#define GIO_UNAVAILABLE(maj,min) _GIO_EXTERN +#define GIO_UNAVAILABLE_STATIC_INLINE(maj,min) +#else +#define GIO_DEPRECATED G_DEPRECATED _GIO_EXTERN +#define GIO_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GIO_EXTERN +#define GIO_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GIO_EXTERN +#define GIO_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min) +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26 +#define GIO_DEPRECATED_IN_2_26 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_26_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_26 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_26_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_26 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_26 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_26_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_26 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_26_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_26 +#define GIO_DEPRECATED_MACRO_IN_2_26_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_26 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_26 +#define GIO_DEPRECATED_TYPE_IN_2_26_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26 +#define GIO_AVAILABLE_IN_2_26 GIO_UNAVAILABLE (2, 26) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_26 GLIB_UNAVAILABLE_STATIC_INLINE (2, 26) +#define GIO_AVAILABLE_MACRO_IN_2_26 GLIB_UNAVAILABLE_MACRO (2, 26) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_26 GLIB_UNAVAILABLE_ENUMERATOR (2, 26) +#define GIO_AVAILABLE_TYPE_IN_2_26 GLIB_UNAVAILABLE_TYPE (2, 26) +#else +#define GIO_AVAILABLE_IN_2_26 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_26 +#define GIO_AVAILABLE_MACRO_IN_2_26 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_26 +#define GIO_AVAILABLE_TYPE_IN_2_26 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28 +#define GIO_DEPRECATED_IN_2_28 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_28_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_28 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_28_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_28 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_28 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_28_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_28 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_28_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_28 +#define GIO_DEPRECATED_MACRO_IN_2_28_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_28 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_28 +#define GIO_DEPRECATED_TYPE_IN_2_28_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28 +#define GIO_AVAILABLE_IN_2_28 GIO_UNAVAILABLE (2, 28) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_28 GLIB_UNAVAILABLE_STATIC_INLINE (2, 28) +#define GIO_AVAILABLE_MACRO_IN_2_28 GLIB_UNAVAILABLE_MACRO (2, 28) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_28 GLIB_UNAVAILABLE_ENUMERATOR (2, 28) +#define GIO_AVAILABLE_TYPE_IN_2_28 GLIB_UNAVAILABLE_TYPE (2, 28) +#else +#define GIO_AVAILABLE_IN_2_28 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_28 +#define GIO_AVAILABLE_MACRO_IN_2_28 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_28 +#define GIO_AVAILABLE_TYPE_IN_2_28 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30 +#define GIO_DEPRECATED_IN_2_30 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_30_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_30 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_30_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_30 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_30 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_30_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_30 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_30_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_30 +#define GIO_DEPRECATED_MACRO_IN_2_30_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_30 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_30 +#define GIO_DEPRECATED_TYPE_IN_2_30_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30 +#define GIO_AVAILABLE_IN_2_30 GIO_UNAVAILABLE (2, 30) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_30 GLIB_UNAVAILABLE_STATIC_INLINE (2, 30) +#define GIO_AVAILABLE_MACRO_IN_2_30 GLIB_UNAVAILABLE_MACRO (2, 30) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_30 GLIB_UNAVAILABLE_ENUMERATOR (2, 30) +#define GIO_AVAILABLE_TYPE_IN_2_30 GLIB_UNAVAILABLE_TYPE (2, 30) +#else +#define GIO_AVAILABLE_IN_2_30 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_30 +#define GIO_AVAILABLE_MACRO_IN_2_30 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_30 +#define GIO_AVAILABLE_TYPE_IN_2_30 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32 +#define GIO_DEPRECATED_IN_2_32 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_32_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_32 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_32_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_32 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_32 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_32_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_32 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_32_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_32 +#define GIO_DEPRECATED_MACRO_IN_2_32_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_32 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_32 +#define GIO_DEPRECATED_TYPE_IN_2_32_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32 +#define GIO_AVAILABLE_IN_2_32 GIO_UNAVAILABLE (2, 32) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_32 GLIB_UNAVAILABLE_STATIC_INLINE (2, 32) +#define GIO_AVAILABLE_MACRO_IN_2_32 GLIB_UNAVAILABLE_MACRO (2, 32) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_32 GLIB_UNAVAILABLE_ENUMERATOR (2, 32) +#define GIO_AVAILABLE_TYPE_IN_2_32 GLIB_UNAVAILABLE_TYPE (2, 32) +#else +#define GIO_AVAILABLE_IN_2_32 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_32 +#define GIO_AVAILABLE_MACRO_IN_2_32 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_32 +#define GIO_AVAILABLE_TYPE_IN_2_32 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34 +#define GIO_DEPRECATED_IN_2_34 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_34_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_34 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_34_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_34 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_34 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_34_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_34 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_34_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_34 +#define GIO_DEPRECATED_MACRO_IN_2_34_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_34 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_34 +#define GIO_DEPRECATED_TYPE_IN_2_34_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34 +#define GIO_AVAILABLE_IN_2_34 GIO_UNAVAILABLE (2, 34) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_34 GLIB_UNAVAILABLE_STATIC_INLINE (2, 34) +#define GIO_AVAILABLE_MACRO_IN_2_34 GLIB_UNAVAILABLE_MACRO (2, 34) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_34 GLIB_UNAVAILABLE_ENUMERATOR (2, 34) +#define GIO_AVAILABLE_TYPE_IN_2_34 GLIB_UNAVAILABLE_TYPE (2, 34) +#else +#define GIO_AVAILABLE_IN_2_34 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_34 +#define GIO_AVAILABLE_MACRO_IN_2_34 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_34 +#define GIO_AVAILABLE_TYPE_IN_2_34 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36 +#define GIO_DEPRECATED_IN_2_36 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_36_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_36 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_36_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_36 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_36 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_36_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_36 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_36_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_36 +#define GIO_DEPRECATED_MACRO_IN_2_36_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_36 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_36 +#define GIO_DEPRECATED_TYPE_IN_2_36_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36 +#define GIO_AVAILABLE_IN_2_36 GIO_UNAVAILABLE (2, 36) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_36 GLIB_UNAVAILABLE_STATIC_INLINE (2, 36) +#define GIO_AVAILABLE_MACRO_IN_2_36 GLIB_UNAVAILABLE_MACRO (2, 36) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_36 GLIB_UNAVAILABLE_ENUMERATOR (2, 36) +#define GIO_AVAILABLE_TYPE_IN_2_36 GLIB_UNAVAILABLE_TYPE (2, 36) +#else +#define GIO_AVAILABLE_IN_2_36 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_36 +#define GIO_AVAILABLE_MACRO_IN_2_36 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_36 +#define GIO_AVAILABLE_TYPE_IN_2_36 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_38 +#define GIO_DEPRECATED_IN_2_38 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_38_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_38 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_38_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_38 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_38 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_38_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_38 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_38_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_38 +#define GIO_DEPRECATED_MACRO_IN_2_38_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_38 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_38 +#define GIO_DEPRECATED_TYPE_IN_2_38_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 +#define GIO_AVAILABLE_IN_2_38 GIO_UNAVAILABLE (2, 38) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_38 GLIB_UNAVAILABLE_STATIC_INLINE (2, 38) +#define GIO_AVAILABLE_MACRO_IN_2_38 GLIB_UNAVAILABLE_MACRO (2, 38) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_38 GLIB_UNAVAILABLE_ENUMERATOR (2, 38) +#define GIO_AVAILABLE_TYPE_IN_2_38 GLIB_UNAVAILABLE_TYPE (2, 38) +#else +#define GIO_AVAILABLE_IN_2_38 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_38 +#define GIO_AVAILABLE_MACRO_IN_2_38 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_38 +#define GIO_AVAILABLE_TYPE_IN_2_38 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_40 +#define GIO_DEPRECATED_IN_2_40 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_40_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_40 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_40_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_40 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_40 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_40_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_40 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_40_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_40 +#define GIO_DEPRECATED_MACRO_IN_2_40_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_40 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_40 +#define GIO_DEPRECATED_TYPE_IN_2_40_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_40 +#define GIO_AVAILABLE_IN_2_40 GIO_UNAVAILABLE (2, 40) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_40 GLIB_UNAVAILABLE_STATIC_INLINE (2, 40) +#define GIO_AVAILABLE_MACRO_IN_2_40 GLIB_UNAVAILABLE_MACRO (2, 40) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_40 GLIB_UNAVAILABLE_ENUMERATOR (2, 40) +#define GIO_AVAILABLE_TYPE_IN_2_40 GLIB_UNAVAILABLE_TYPE (2, 40) +#else +#define GIO_AVAILABLE_IN_2_40 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_40 +#define GIO_AVAILABLE_MACRO_IN_2_40 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_40 +#define GIO_AVAILABLE_TYPE_IN_2_40 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_42 +#define GIO_DEPRECATED_IN_2_42 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_42_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_42 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_42_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_42 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_42 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_42_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_42 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_42_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_42 +#define GIO_DEPRECATED_MACRO_IN_2_42_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_42 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_42 +#define GIO_DEPRECATED_TYPE_IN_2_42_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_42 +#define GIO_AVAILABLE_IN_2_42 GIO_UNAVAILABLE (2, 42) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_42 GLIB_UNAVAILABLE_STATIC_INLINE (2, 42) +#define GIO_AVAILABLE_MACRO_IN_2_42 GLIB_UNAVAILABLE_MACRO (2, 42) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_42 GLIB_UNAVAILABLE_ENUMERATOR (2, 42) +#define GIO_AVAILABLE_TYPE_IN_2_42 GLIB_UNAVAILABLE_TYPE (2, 42) +#else +#define GIO_AVAILABLE_IN_2_42 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_42 +#define GIO_AVAILABLE_MACRO_IN_2_42 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_42 +#define GIO_AVAILABLE_TYPE_IN_2_42 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_44 +#define GIO_DEPRECATED_IN_2_44 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_44_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_44 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_44_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_44 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_44 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_44_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_44 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_44_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_44 +#define GIO_DEPRECATED_MACRO_IN_2_44_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_44 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_44 +#define GIO_DEPRECATED_TYPE_IN_2_44_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_44 +#define GIO_AVAILABLE_IN_2_44 GIO_UNAVAILABLE (2, 44) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_44 GLIB_UNAVAILABLE_STATIC_INLINE (2, 44) +#define GIO_AVAILABLE_MACRO_IN_2_44 GLIB_UNAVAILABLE_MACRO (2, 44) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_44 GLIB_UNAVAILABLE_ENUMERATOR (2, 44) +#define GIO_AVAILABLE_TYPE_IN_2_44 GLIB_UNAVAILABLE_TYPE (2, 44) +#else +#define GIO_AVAILABLE_IN_2_44 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_44 +#define GIO_AVAILABLE_MACRO_IN_2_44 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_44 +#define GIO_AVAILABLE_TYPE_IN_2_44 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_46 +#define GIO_DEPRECATED_IN_2_46 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_46_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_46 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_46_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_46 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_46 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_46_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_46 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_46_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_46 +#define GIO_DEPRECATED_MACRO_IN_2_46_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_46 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_46 +#define GIO_DEPRECATED_TYPE_IN_2_46_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_46 +#define GIO_AVAILABLE_IN_2_46 GIO_UNAVAILABLE (2, 46) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_46 GLIB_UNAVAILABLE_STATIC_INLINE (2, 46) +#define GIO_AVAILABLE_MACRO_IN_2_46 GLIB_UNAVAILABLE_MACRO (2, 46) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_46 GLIB_UNAVAILABLE_ENUMERATOR (2, 46) +#define GIO_AVAILABLE_TYPE_IN_2_46 GLIB_UNAVAILABLE_TYPE (2, 46) +#else +#define GIO_AVAILABLE_IN_2_46 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_46 +#define GIO_AVAILABLE_MACRO_IN_2_46 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_46 +#define GIO_AVAILABLE_TYPE_IN_2_46 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_48 +#define GIO_DEPRECATED_IN_2_48 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_48_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_48 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_48_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_48 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_48 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_48_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_48 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_48_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_48 +#define GIO_DEPRECATED_MACRO_IN_2_48_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_48 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_48 +#define GIO_DEPRECATED_TYPE_IN_2_48_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_48 +#define GIO_AVAILABLE_IN_2_48 GIO_UNAVAILABLE (2, 48) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_48 GLIB_UNAVAILABLE_STATIC_INLINE (2, 48) +#define GIO_AVAILABLE_MACRO_IN_2_48 GLIB_UNAVAILABLE_MACRO (2, 48) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_48 GLIB_UNAVAILABLE_ENUMERATOR (2, 48) +#define GIO_AVAILABLE_TYPE_IN_2_48 GLIB_UNAVAILABLE_TYPE (2, 48) +#else +#define GIO_AVAILABLE_IN_2_48 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_48 +#define GIO_AVAILABLE_MACRO_IN_2_48 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_48 +#define GIO_AVAILABLE_TYPE_IN_2_48 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_50 +#define GIO_DEPRECATED_IN_2_50 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_50_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_50 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_50_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_50 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_50 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_50_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_50 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_50_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_50 +#define GIO_DEPRECATED_MACRO_IN_2_50_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_50 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_50 +#define GIO_DEPRECATED_TYPE_IN_2_50_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_50 +#define GIO_AVAILABLE_IN_2_50 GIO_UNAVAILABLE (2, 50) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_50 GLIB_UNAVAILABLE_STATIC_INLINE (2, 50) +#define GIO_AVAILABLE_MACRO_IN_2_50 GLIB_UNAVAILABLE_MACRO (2, 50) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_50 GLIB_UNAVAILABLE_ENUMERATOR (2, 50) +#define GIO_AVAILABLE_TYPE_IN_2_50 GLIB_UNAVAILABLE_TYPE (2, 50) +#else +#define GIO_AVAILABLE_IN_2_50 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_50 +#define GIO_AVAILABLE_MACRO_IN_2_50 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_50 +#define GIO_AVAILABLE_TYPE_IN_2_50 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_52 +#define GIO_DEPRECATED_IN_2_52 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_52_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_52 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_52_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_52 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_52 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_52_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_52 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_52_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_52 +#define GIO_DEPRECATED_MACRO_IN_2_52_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_52 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_52 +#define GIO_DEPRECATED_TYPE_IN_2_52_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_52 +#define GIO_AVAILABLE_IN_2_52 GIO_UNAVAILABLE (2, 52) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_52 GLIB_UNAVAILABLE_STATIC_INLINE (2, 52) +#define GIO_AVAILABLE_MACRO_IN_2_52 GLIB_UNAVAILABLE_MACRO (2, 52) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_52 GLIB_UNAVAILABLE_ENUMERATOR (2, 52) +#define GIO_AVAILABLE_TYPE_IN_2_52 GLIB_UNAVAILABLE_TYPE (2, 52) +#else +#define GIO_AVAILABLE_IN_2_52 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_52 +#define GIO_AVAILABLE_MACRO_IN_2_52 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_52 +#define GIO_AVAILABLE_TYPE_IN_2_52 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_54 +#define GIO_DEPRECATED_IN_2_54 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_54_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_54 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_54_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_54 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_54 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_54_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_54 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_54_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_54 +#define GIO_DEPRECATED_MACRO_IN_2_54_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_54 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_54 +#define GIO_DEPRECATED_TYPE_IN_2_54_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_54 +#define GIO_AVAILABLE_IN_2_54 GIO_UNAVAILABLE (2, 54) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_54 GLIB_UNAVAILABLE_STATIC_INLINE (2, 54) +#define GIO_AVAILABLE_MACRO_IN_2_54 GLIB_UNAVAILABLE_MACRO (2, 54) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_54 GLIB_UNAVAILABLE_ENUMERATOR (2, 54) +#define GIO_AVAILABLE_TYPE_IN_2_54 GLIB_UNAVAILABLE_TYPE (2, 54) +#else +#define GIO_AVAILABLE_IN_2_54 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_54 +#define GIO_AVAILABLE_MACRO_IN_2_54 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_54 +#define GIO_AVAILABLE_TYPE_IN_2_54 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_56 +#define GIO_DEPRECATED_IN_2_56 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_56_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_56 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_56_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_56 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_56 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_56_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_56 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_56_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_56 +#define GIO_DEPRECATED_MACRO_IN_2_56_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_56 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_56 +#define GIO_DEPRECATED_TYPE_IN_2_56_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_56 +#define GIO_AVAILABLE_IN_2_56 GIO_UNAVAILABLE (2, 56) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_56 GLIB_UNAVAILABLE_STATIC_INLINE (2, 56) +#define GIO_AVAILABLE_MACRO_IN_2_56 GLIB_UNAVAILABLE_MACRO (2, 56) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_56 GLIB_UNAVAILABLE_ENUMERATOR (2, 56) +#define GIO_AVAILABLE_TYPE_IN_2_56 GLIB_UNAVAILABLE_TYPE (2, 56) +#else +#define GIO_AVAILABLE_IN_2_56 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_56 +#define GIO_AVAILABLE_MACRO_IN_2_56 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_56 +#define GIO_AVAILABLE_TYPE_IN_2_56 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_58 +#define GIO_DEPRECATED_IN_2_58 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_58_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_58 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_58_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_58 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_58 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_58_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_58 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_58_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_58 +#define GIO_DEPRECATED_MACRO_IN_2_58_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_58 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_58 +#define GIO_DEPRECATED_TYPE_IN_2_58_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_58 +#define GIO_AVAILABLE_IN_2_58 GIO_UNAVAILABLE (2, 58) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_58 GLIB_UNAVAILABLE_STATIC_INLINE (2, 58) +#define GIO_AVAILABLE_MACRO_IN_2_58 GLIB_UNAVAILABLE_MACRO (2, 58) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_58 GLIB_UNAVAILABLE_ENUMERATOR (2, 58) +#define GIO_AVAILABLE_TYPE_IN_2_58 GLIB_UNAVAILABLE_TYPE (2, 58) +#else +#define GIO_AVAILABLE_IN_2_58 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_58 +#define GIO_AVAILABLE_MACRO_IN_2_58 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_58 +#define GIO_AVAILABLE_TYPE_IN_2_58 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_60 +#define GIO_DEPRECATED_IN_2_60 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_60_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_60 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_60_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_60 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_60 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_60_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_60 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_60_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_60 +#define GIO_DEPRECATED_MACRO_IN_2_60_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_60 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_60 +#define GIO_DEPRECATED_TYPE_IN_2_60_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_60 +#define GIO_AVAILABLE_IN_2_60 GIO_UNAVAILABLE (2, 60) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_60 GLIB_UNAVAILABLE_STATIC_INLINE (2, 60) +#define GIO_AVAILABLE_MACRO_IN_2_60 GLIB_UNAVAILABLE_MACRO (2, 60) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_60 GLIB_UNAVAILABLE_ENUMERATOR (2, 60) +#define GIO_AVAILABLE_TYPE_IN_2_60 GLIB_UNAVAILABLE_TYPE (2, 60) +#else +#define GIO_AVAILABLE_IN_2_60 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_60 +#define GIO_AVAILABLE_MACRO_IN_2_60 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_60 +#define GIO_AVAILABLE_TYPE_IN_2_60 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_62 +#define GIO_DEPRECATED_IN_2_62 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_62_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_62 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_62_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_62 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_62 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_62_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_62 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_62_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_62 +#define GIO_DEPRECATED_MACRO_IN_2_62_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_62 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_62 +#define GIO_DEPRECATED_TYPE_IN_2_62_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_62 +#define GIO_AVAILABLE_IN_2_62 GIO_UNAVAILABLE (2, 62) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_62 GLIB_UNAVAILABLE_STATIC_INLINE (2, 62) +#define GIO_AVAILABLE_MACRO_IN_2_62 GLIB_UNAVAILABLE_MACRO (2, 62) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_62 GLIB_UNAVAILABLE_ENUMERATOR (2, 62) +#define GIO_AVAILABLE_TYPE_IN_2_62 GLIB_UNAVAILABLE_TYPE (2, 62) +#else +#define GIO_AVAILABLE_IN_2_62 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_62 +#define GIO_AVAILABLE_MACRO_IN_2_62 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_62 +#define GIO_AVAILABLE_TYPE_IN_2_62 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 +#define GIO_DEPRECATED_IN_2_64 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_64_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_64 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_64_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_64 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_64 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_64_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_64 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_64_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_64 +#define GIO_DEPRECATED_MACRO_IN_2_64_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_64 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_64 +#define GIO_DEPRECATED_TYPE_IN_2_64_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64 +#define GIO_AVAILABLE_IN_2_64 GIO_UNAVAILABLE (2, 64) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_64 GLIB_UNAVAILABLE_STATIC_INLINE (2, 64) +#define GIO_AVAILABLE_MACRO_IN_2_64 GLIB_UNAVAILABLE_MACRO (2, 64) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_64 GLIB_UNAVAILABLE_ENUMERATOR (2, 64) +#define GIO_AVAILABLE_TYPE_IN_2_64 GLIB_UNAVAILABLE_TYPE (2, 64) +#else +#define GIO_AVAILABLE_IN_2_64 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_64 +#define GIO_AVAILABLE_MACRO_IN_2_64 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_64 +#define GIO_AVAILABLE_TYPE_IN_2_64 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_66 +#define GIO_DEPRECATED_IN_2_66 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_66_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_66 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_66_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_66 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_66 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_66_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_66 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_66_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_66 +#define GIO_DEPRECATED_MACRO_IN_2_66_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_66 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_66 +#define GIO_DEPRECATED_TYPE_IN_2_66_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_66 +#define GIO_AVAILABLE_IN_2_66 GIO_UNAVAILABLE (2, 66) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_66 GLIB_UNAVAILABLE_STATIC_INLINE (2, 66) +#define GIO_AVAILABLE_MACRO_IN_2_66 GLIB_UNAVAILABLE_MACRO (2, 66) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_66 GLIB_UNAVAILABLE_ENUMERATOR (2, 66) +#define GIO_AVAILABLE_TYPE_IN_2_66 GLIB_UNAVAILABLE_TYPE (2, 66) +#else +#define GIO_AVAILABLE_IN_2_66 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_66 +#define GIO_AVAILABLE_MACRO_IN_2_66 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_66 +#define GIO_AVAILABLE_TYPE_IN_2_66 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68 +#define GIO_DEPRECATED_IN_2_68 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_68_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_68 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_68_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_68 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_68 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_68_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_68 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_68_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_68 +#define GIO_DEPRECATED_MACRO_IN_2_68_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_68 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_68 +#define GIO_DEPRECATED_TYPE_IN_2_68_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_68 +#define GIO_AVAILABLE_IN_2_68 GIO_UNAVAILABLE (2, 68) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_68 GLIB_UNAVAILABLE_STATIC_INLINE (2, 68) +#define GIO_AVAILABLE_MACRO_IN_2_68 GLIB_UNAVAILABLE_MACRO (2, 68) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_68 GLIB_UNAVAILABLE_ENUMERATOR (2, 68) +#define GIO_AVAILABLE_TYPE_IN_2_68 GLIB_UNAVAILABLE_TYPE (2, 68) +#else +#define GIO_AVAILABLE_IN_2_68 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_68 +#define GIO_AVAILABLE_MACRO_IN_2_68 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_68 +#define GIO_AVAILABLE_TYPE_IN_2_68 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_70 +#define GIO_DEPRECATED_IN_2_70 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_70_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_70 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_70_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_70 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_70 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_70_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_70 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_70_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_70 +#define GIO_DEPRECATED_MACRO_IN_2_70_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_70 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_70 +#define GIO_DEPRECATED_TYPE_IN_2_70_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_70 +#define GIO_AVAILABLE_IN_2_70 GIO_UNAVAILABLE (2, 70) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_70 GLIB_UNAVAILABLE_STATIC_INLINE (2, 70) +#define GIO_AVAILABLE_MACRO_IN_2_70 GLIB_UNAVAILABLE_MACRO (2, 70) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_70 GLIB_UNAVAILABLE_ENUMERATOR (2, 70) +#define GIO_AVAILABLE_TYPE_IN_2_70 GLIB_UNAVAILABLE_TYPE (2, 70) +#else +#define GIO_AVAILABLE_IN_2_70 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_70 +#define GIO_AVAILABLE_MACRO_IN_2_70 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_70 +#define GIO_AVAILABLE_TYPE_IN_2_70 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_72 +#define GIO_DEPRECATED_IN_2_72 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_72_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_72 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_72_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_72 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_72 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_72_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_72 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_72_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_72 +#define GIO_DEPRECATED_MACRO_IN_2_72_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_72 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_72 +#define GIO_DEPRECATED_TYPE_IN_2_72_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_72 +#define GIO_AVAILABLE_IN_2_72 GIO_UNAVAILABLE (2, 72) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_72 GLIB_UNAVAILABLE_STATIC_INLINE (2, 72) +#define GIO_AVAILABLE_MACRO_IN_2_72 GLIB_UNAVAILABLE_MACRO (2, 72) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_72 GLIB_UNAVAILABLE_ENUMERATOR (2, 72) +#define GIO_AVAILABLE_TYPE_IN_2_72 GLIB_UNAVAILABLE_TYPE (2, 72) +#else +#define GIO_AVAILABLE_IN_2_72 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_72 +#define GIO_AVAILABLE_MACRO_IN_2_72 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_72 +#define GIO_AVAILABLE_TYPE_IN_2_72 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_74 +#define GIO_DEPRECATED_IN_2_74 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_74_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_74 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_74_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_74 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_74 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_74_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_74 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_74_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_74 +#define GIO_DEPRECATED_MACRO_IN_2_74_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_74 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_74 +#define GIO_DEPRECATED_TYPE_IN_2_74_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_74 +#define GIO_AVAILABLE_IN_2_74 GIO_UNAVAILABLE (2, 74) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_74 GLIB_UNAVAILABLE_STATIC_INLINE (2, 74) +#define GIO_AVAILABLE_MACRO_IN_2_74 GLIB_UNAVAILABLE_MACRO (2, 74) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_74 GLIB_UNAVAILABLE_ENUMERATOR (2, 74) +#define GIO_AVAILABLE_TYPE_IN_2_74 GLIB_UNAVAILABLE_TYPE (2, 74) +#else +#define GIO_AVAILABLE_IN_2_74 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_74 +#define GIO_AVAILABLE_MACRO_IN_2_74 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_74 +#define GIO_AVAILABLE_TYPE_IN_2_74 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76 +#define GIO_DEPRECATED_IN_2_76 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_76_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_76 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_76_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_76 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_76 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_76_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_76 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_76_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_76 +#define GIO_DEPRECATED_MACRO_IN_2_76_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_76 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_76 +#define GIO_DEPRECATED_TYPE_IN_2_76_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_76 +#define GIO_AVAILABLE_IN_2_76 GIO_UNAVAILABLE (2, 76) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_76 GLIB_UNAVAILABLE_STATIC_INLINE (2, 76) +#define GIO_AVAILABLE_MACRO_IN_2_76 GLIB_UNAVAILABLE_MACRO (2, 76) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_76 GLIB_UNAVAILABLE_ENUMERATOR (2, 76) +#define GIO_AVAILABLE_TYPE_IN_2_76 GLIB_UNAVAILABLE_TYPE (2, 76) +#else +#define GIO_AVAILABLE_IN_2_76 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_76 +#define GIO_AVAILABLE_MACRO_IN_2_76 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_76 +#define GIO_AVAILABLE_TYPE_IN_2_76 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 +#define GIO_DEPRECATED_IN_2_78 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_78_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_78 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_78_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_78 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_78 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_78_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_78 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_78_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_78 +#define GIO_DEPRECATED_MACRO_IN_2_78_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_78 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_78 +#define GIO_DEPRECATED_TYPE_IN_2_78_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_78 +#define GIO_AVAILABLE_IN_2_78 GIO_UNAVAILABLE (2, 78) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_78 GLIB_UNAVAILABLE_STATIC_INLINE (2, 78) +#define GIO_AVAILABLE_MACRO_IN_2_78 GLIB_UNAVAILABLE_MACRO (2, 78) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_78 GLIB_UNAVAILABLE_ENUMERATOR (2, 78) +#define GIO_AVAILABLE_TYPE_IN_2_78 GLIB_UNAVAILABLE_TYPE (2, 78) +#else +#define GIO_AVAILABLE_IN_2_78 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_78 +#define GIO_AVAILABLE_MACRO_IN_2_78 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_78 +#define GIO_AVAILABLE_TYPE_IN_2_78 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_80 +#define GIO_DEPRECATED_IN_2_80 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_80_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_80 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_80_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_80 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_80 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_80_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_80 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_80_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_80 +#define GIO_DEPRECATED_MACRO_IN_2_80_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_80 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_80 +#define GIO_DEPRECATED_TYPE_IN_2_80_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_80 +#define GIO_AVAILABLE_IN_2_80 GIO_UNAVAILABLE (2, 80) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_80 GLIB_UNAVAILABLE_STATIC_INLINE (2, 80) +#define GIO_AVAILABLE_MACRO_IN_2_80 GLIB_UNAVAILABLE_MACRO (2, 80) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_80 GLIB_UNAVAILABLE_ENUMERATOR (2, 80) +#define GIO_AVAILABLE_TYPE_IN_2_80 GLIB_UNAVAILABLE_TYPE (2, 80) +#else +#define GIO_AVAILABLE_IN_2_80 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_80 +#define GIO_AVAILABLE_MACRO_IN_2_80 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_80 +#define GIO_AVAILABLE_TYPE_IN_2_80 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_82 +#define GIO_DEPRECATED_IN_2_82 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_82_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_82 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_82_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_82 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_82 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_82_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_82 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_82_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_82 +#define GIO_DEPRECATED_MACRO_IN_2_82_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_82 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_82 +#define GIO_DEPRECATED_TYPE_IN_2_82_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_82 +#define GIO_AVAILABLE_IN_2_82 GIO_UNAVAILABLE (2, 82) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_82 GLIB_UNAVAILABLE_STATIC_INLINE (2, 82) +#define GIO_AVAILABLE_MACRO_IN_2_82 GLIB_UNAVAILABLE_MACRO (2, 82) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_82 GLIB_UNAVAILABLE_ENUMERATOR (2, 82) +#define GIO_AVAILABLE_TYPE_IN_2_82 GLIB_UNAVAILABLE_TYPE (2, 82) +#else +#define GIO_AVAILABLE_IN_2_82 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_82 +#define GIO_AVAILABLE_MACRO_IN_2_82 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_82 +#define GIO_AVAILABLE_TYPE_IN_2_82 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_84 +#define GIO_DEPRECATED_IN_2_84 GIO_DEPRECATED +#define GIO_DEPRECATED_IN_2_84_FOR(f) GIO_DEPRECATED_FOR (f) +#define GIO_DEPRECATED_MACRO_IN_2_84 GLIB_DEPRECATED_MACRO +#define GIO_DEPRECATED_MACRO_IN_2_84_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_84 GLIB_DEPRECATED_ENUMERATOR +#define GIO_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GIO_DEPRECATED_TYPE_IN_2_84 GLIB_DEPRECATED_TYPE +#define GIO_DEPRECATED_TYPE_IN_2_84_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GIO_DEPRECATED_IN_2_84 _GIO_EXTERN +#define GIO_DEPRECATED_IN_2_84_FOR(f) _GIO_EXTERN +#define GIO_DEPRECATED_MACRO_IN_2_84 +#define GIO_DEPRECATED_MACRO_IN_2_84_FOR(f) +#define GIO_DEPRECATED_ENUMERATOR_IN_2_84 +#define GIO_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) +#define GIO_DEPRECATED_TYPE_IN_2_84 +#define GIO_DEPRECATED_TYPE_IN_2_84_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_84 +#define GIO_AVAILABLE_IN_2_84 GIO_UNAVAILABLE (2, 84) +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_84 GLIB_UNAVAILABLE_STATIC_INLINE (2, 84) +#define GIO_AVAILABLE_MACRO_IN_2_84 GLIB_UNAVAILABLE_MACRO (2, 84) +#define GIO_AVAILABLE_ENUMERATOR_IN_2_84 GLIB_UNAVAILABLE_ENUMERATOR (2, 84) +#define GIO_AVAILABLE_TYPE_IN_2_84 GLIB_UNAVAILABLE_TYPE (2, 84) +#else +#define GIO_AVAILABLE_IN_2_84 _GIO_EXTERN +#define GIO_AVAILABLE_STATIC_INLINE_IN_2_84 +#define GIO_AVAILABLE_MACRO_IN_2_84 +#define GIO_AVAILABLE_ENUMERATOR_IN_2_84 +#define GIO_AVAILABLE_TYPE_IN_2_84 +#endif diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gio.h b/illumos-x86_64/usr/include/glib-2.0/gio/gio.h new file mode 100644 index 00000000..c17657db --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gio.h @@ -0,0 +1,186 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_IO_H__ +#define __G_IO_H__ + +#define __GIO_GIO_H_INSIDE__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#undef __GIO_GIO_H_INSIDE__ + +#endif /* __G_IO_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gioenums.h b/illumos-x86_64/usr/include/glib-2.0/gio/gioenums.h new file mode 100644 index 00000000..51a03a26 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gioenums.h @@ -0,0 +1,2165 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __GIO_ENUMS_H__ +#define __GIO_ENUMS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + + +/** + * GAppInfoCreateFlags: + * @G_APP_INFO_CREATE_NONE: No flags. + * @G_APP_INFO_CREATE_NEEDS_TERMINAL: Application opens in a terminal window. + * @G_APP_INFO_CREATE_SUPPORTS_URIS: Application supports URI arguments. + * @G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION: Application supports startup notification. Since 2.26 + * + * Flags used when creating a #GAppInfo. + */ +typedef enum { + G_APP_INFO_CREATE_NONE = 0, /*< nick=none >*/ + G_APP_INFO_CREATE_NEEDS_TERMINAL = (1 << 0), /*< nick=needs-terminal >*/ + G_APP_INFO_CREATE_SUPPORTS_URIS = (1 << 1), /*< nick=supports-uris >*/ + G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION = (1 << 2) /*< nick=supports-startup-notification >*/ +} GAppInfoCreateFlags; + +/** + * GConverterFlags: + * @G_CONVERTER_NO_FLAGS: No flags. + * @G_CONVERTER_INPUT_AT_END: At end of input data + * @G_CONVERTER_FLUSH: Flush data + * + * Flags used when calling a g_converter_convert(). + * + * Since: 2.24 + */ +typedef enum { + G_CONVERTER_NO_FLAGS = 0, /*< nick=none >*/ + G_CONVERTER_INPUT_AT_END = (1 << 0), /*< nick=input-at-end >*/ + G_CONVERTER_FLUSH = (1 << 1) /*< nick=flush >*/ +} GConverterFlags; + +/** + * GConverterResult: + * @G_CONVERTER_ERROR: There was an error during conversion. + * @G_CONVERTER_CONVERTED: Some data was consumed or produced + * @G_CONVERTER_FINISHED: The conversion is finished + * @G_CONVERTER_FLUSHED: Flushing is finished + * + * Results returned from g_converter_convert(). + * + * Since: 2.24 + */ +typedef enum { + G_CONVERTER_ERROR = 0, /*< nick=error >*/ + G_CONVERTER_CONVERTED = 1, /*< nick=converted >*/ + G_CONVERTER_FINISHED = 2, /*< nick=finished >*/ + G_CONVERTER_FLUSHED = 3 /*< nick=flushed >*/ +} GConverterResult; + + +/** + * GDataStreamByteOrder: + * @G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN: Selects Big Endian byte order. + * @G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN: Selects Little Endian byte order. + * @G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN: Selects endianness based on host machine's architecture. + * + * #GDataStreamByteOrder is used to ensure proper endianness of streaming data sources + * across various machine architectures. + * + **/ +typedef enum { + G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN, + G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN, + G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN +} GDataStreamByteOrder; + + +/** + * GDataStreamNewlineType: + * @G_DATA_STREAM_NEWLINE_TYPE_LF: Selects "LF" line endings, common on most modern UNIX platforms. + * @G_DATA_STREAM_NEWLINE_TYPE_CR: Selects "CR" line endings. + * @G_DATA_STREAM_NEWLINE_TYPE_CR_LF: Selects "CR, LF" line ending, common on Microsoft Windows. + * @G_DATA_STREAM_NEWLINE_TYPE_ANY: Automatically try to handle any line ending type. + * + * #GDataStreamNewlineType is used when checking for or setting the line endings for a given file. + **/ +typedef enum { + G_DATA_STREAM_NEWLINE_TYPE_LF, + G_DATA_STREAM_NEWLINE_TYPE_CR, + G_DATA_STREAM_NEWLINE_TYPE_CR_LF, + G_DATA_STREAM_NEWLINE_TYPE_ANY +} GDataStreamNewlineType; + + +/** + * GFileAttributeType: + * @G_FILE_ATTRIBUTE_TYPE_INVALID: indicates an invalid or uninitialized type. + * @G_FILE_ATTRIBUTE_TYPE_STRING: a null terminated UTF8 string. + * @G_FILE_ATTRIBUTE_TYPE_BYTE_STRING: a zero terminated string of non-zero bytes. + * @G_FILE_ATTRIBUTE_TYPE_BOOLEAN: a boolean value. + * @G_FILE_ATTRIBUTE_TYPE_UINT32: an unsigned 4-byte/32-bit integer. + * @G_FILE_ATTRIBUTE_TYPE_INT32: a signed 4-byte/32-bit integer. + * @G_FILE_ATTRIBUTE_TYPE_UINT64: an unsigned 8-byte/64-bit integer. + * @G_FILE_ATTRIBUTE_TYPE_INT64: a signed 8-byte/64-bit integer. + * @G_FILE_ATTRIBUTE_TYPE_OBJECT: a #GObject. + * @G_FILE_ATTRIBUTE_TYPE_STRINGV: a %NULL terminated char **. Since 2.22 + * + * The data types for file attributes. + **/ +typedef enum { + G_FILE_ATTRIBUTE_TYPE_INVALID = 0, + G_FILE_ATTRIBUTE_TYPE_STRING, + G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, /* zero terminated string of non-zero bytes */ + G_FILE_ATTRIBUTE_TYPE_BOOLEAN, + G_FILE_ATTRIBUTE_TYPE_UINT32, + G_FILE_ATTRIBUTE_TYPE_INT32, + G_FILE_ATTRIBUTE_TYPE_UINT64, + G_FILE_ATTRIBUTE_TYPE_INT64, + G_FILE_ATTRIBUTE_TYPE_OBJECT, + G_FILE_ATTRIBUTE_TYPE_STRINGV +} GFileAttributeType; + + +/** + * GFileAttributeInfoFlags: + * @G_FILE_ATTRIBUTE_INFO_NONE: no flags set. + * @G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE: copy the attribute values when the file is copied. + * @G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED: copy the attribute values when the file is moved. + * + * Flags specifying the behaviour of an attribute. + **/ +typedef enum { + G_FILE_ATTRIBUTE_INFO_NONE = 0, + G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE = (1 << 0), + G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED = (1 << 1) +} GFileAttributeInfoFlags; + + +/** + * GFileAttributeStatus: + * @G_FILE_ATTRIBUTE_STATUS_UNSET: Attribute value is unset (empty). + * @G_FILE_ATTRIBUTE_STATUS_SET: Attribute value is set. + * @G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING: Indicates an error in setting the value. + * + * Used by g_file_set_attributes_from_info() when setting file attributes. + **/ +typedef enum { + G_FILE_ATTRIBUTE_STATUS_UNSET = 0, + G_FILE_ATTRIBUTE_STATUS_SET, + G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING +} GFileAttributeStatus; + + +/** + * GFileQueryInfoFlags: + * @G_FILE_QUERY_INFO_NONE: No flags set. + * @G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS: Don't follow symlinks. + * + * Flags used when querying a #GFileInfo. + */ +typedef enum { + G_FILE_QUERY_INFO_NONE = 0, + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS = (1 << 0) /*< nick=nofollow-symlinks >*/ +} GFileQueryInfoFlags; + + +/** + * GFileCreateFlags: + * @G_FILE_CREATE_NONE: No flags set. + * @G_FILE_CREATE_PRIVATE: Create a file that can only be + * accessed by the current user. + * @G_FILE_CREATE_REPLACE_DESTINATION: Replace the destination + * as if it didn't exist before. Don't try to keep any old + * permissions, replace instead of following links. This + * is generally useful if you're doing a "copy over" + * rather than a "save new version of" replace operation. + * You can think of it as "unlink destination" before + * writing to it, although the implementation may not + * be exactly like that. This flag can only be used with + * g_file_replace() and its variants, including g_file_replace_contents(). + * Since 2.20 + * + * Flags used when an operation may create a file. + */ +typedef enum { + G_FILE_CREATE_NONE = 0, + G_FILE_CREATE_PRIVATE = (1 << 0), + G_FILE_CREATE_REPLACE_DESTINATION = (1 << 1) +} GFileCreateFlags; + +/** + * GFileMeasureFlags: + * @G_FILE_MEASURE_NONE: No flags set. + * @G_FILE_MEASURE_REPORT_ANY_ERROR: Report any error encountered + * while traversing the directory tree. Normally errors are only + * reported for the toplevel file. + * @G_FILE_MEASURE_APPARENT_SIZE: Tally usage based on apparent file + * sizes. Normally, the block-size is used, if available, as this is a + * more accurate representation of disk space used. + * Compare with `du --apparent-size`. + * Since GLib 2.78. and similarly to `du` since GNU Coreutils 9.2, this will + * ignore the sizes of file types other than regular files and links, as the + * sizes of other file types are not specified in a standard way. + * @G_FILE_MEASURE_NO_XDEV: Do not cross mount point boundaries. + * Compare with `du -x`. + * + * Flags that can be used with g_file_measure_disk_usage(). + * + * Since: 2.38 + **/ +typedef enum { + G_FILE_MEASURE_NONE = 0, + G_FILE_MEASURE_REPORT_ANY_ERROR = (1 << 1), + G_FILE_MEASURE_APPARENT_SIZE = (1 << 2), + G_FILE_MEASURE_NO_XDEV = (1 << 3) +} GFileMeasureFlags; + +/** + * GMountMountFlags: + * @G_MOUNT_MOUNT_NONE: No flags set. + * + * Flags used when mounting a mount. + */ +typedef enum /*< flags >*/ { + G_MOUNT_MOUNT_NONE = 0 +} GMountMountFlags; + + +/** + * GMountUnmountFlags: + * @G_MOUNT_UNMOUNT_NONE: No flags set. + * @G_MOUNT_UNMOUNT_FORCE: Unmount even if there are outstanding + * file operations on the mount. + * + * Flags used when an unmounting a mount. + */ +typedef enum { + G_MOUNT_UNMOUNT_NONE = 0, + G_MOUNT_UNMOUNT_FORCE = (1 << 0) +} GMountUnmountFlags; + +/** + * GDriveStartFlags: + * @G_DRIVE_START_NONE: No flags set. + * + * Flags used when starting a drive. + * + * Since: 2.22 + */ +typedef enum /*< flags >*/ { + G_DRIVE_START_NONE = 0 +} GDriveStartFlags; + +/** + * GDriveStartStopType: + * @G_DRIVE_START_STOP_TYPE_UNKNOWN: Unknown or drive doesn't support + * start/stop. + * @G_DRIVE_START_STOP_TYPE_SHUTDOWN: The stop method will physically + * shut down the drive and e.g. power down the port the drive is + * attached to. + * @G_DRIVE_START_STOP_TYPE_NETWORK: The start/stop methods are used + * for connecting/disconnect to the drive over the network. + * @G_DRIVE_START_STOP_TYPE_MULTIDISK: The start/stop methods will + * assemble/disassemble a virtual drive from several physical + * drives. + * @G_DRIVE_START_STOP_TYPE_PASSWORD: The start/stop methods will + * unlock/lock the disk (for example using the ATA `SECURITY UNLOCK + * DEVICE` command) + * + * Enumeration describing how a drive can be started/stopped. + * + * Since: 2.22 + */ +typedef enum { + G_DRIVE_START_STOP_TYPE_UNKNOWN, + G_DRIVE_START_STOP_TYPE_SHUTDOWN, + G_DRIVE_START_STOP_TYPE_NETWORK, + G_DRIVE_START_STOP_TYPE_MULTIDISK, + G_DRIVE_START_STOP_TYPE_PASSWORD +} GDriveStartStopType; + +/** + * GFileCopyFlags: + * @G_FILE_COPY_NONE: No flags set. + * @G_FILE_COPY_OVERWRITE: Overwrite any existing files + * @G_FILE_COPY_BACKUP: Make a backup of any existing files. + * @G_FILE_COPY_NOFOLLOW_SYMLINKS: Don't follow symlinks. + * @G_FILE_COPY_ALL_METADATA: Copy all file metadata instead of just default set used for copy (see #GFileInfo). + * @G_FILE_COPY_NO_FALLBACK_FOR_MOVE: Don't use copy and delete fallback if native move not supported. + * @G_FILE_COPY_TARGET_DEFAULT_PERMS: Leaves target file with default perms, instead of setting the source file perms. + * @G_FILE_COPY_TARGET_DEFAULT_MODIFIED_TIME: Use default modification + * timestamps instead of copying them from the source file. Since 2.80 + * + * Flags used when copying or moving files. + */ +typedef enum { + G_FILE_COPY_NONE = 0, /*< nick=none >*/ + G_FILE_COPY_OVERWRITE = (1 << 0), + G_FILE_COPY_BACKUP = (1 << 1), + G_FILE_COPY_NOFOLLOW_SYMLINKS = (1 << 2), + G_FILE_COPY_ALL_METADATA = (1 << 3), + G_FILE_COPY_NO_FALLBACK_FOR_MOVE = (1 << 4), + G_FILE_COPY_TARGET_DEFAULT_PERMS = (1 << 5), + G_FILE_COPY_TARGET_DEFAULT_MODIFIED_TIME GIO_AVAILABLE_ENUMERATOR_IN_2_80 = (1 << 6), +} GFileCopyFlags; + + +/** + * GFileMonitorFlags: + * @G_FILE_MONITOR_NONE: No flags set. + * @G_FILE_MONITOR_WATCH_MOUNTS: Watch for mount events. + * @G_FILE_MONITOR_SEND_MOVED: Pair DELETED and CREATED events caused + * by file renames (moves) and send a single G_FILE_MONITOR_EVENT_MOVED + * event instead (NB: not supported on all backends; the default + * behaviour -without specifying this flag- is to send single DELETED + * and CREATED events). Deprecated since 2.46: use + * %G_FILE_MONITOR_WATCH_MOVES instead. + * @G_FILE_MONITOR_WATCH_HARD_LINKS: Watch for changes to the file made + * via another hard link. Since 2.36. + * @G_FILE_MONITOR_WATCH_MOVES: Watch for rename operations on a + * monitored directory. This causes %G_FILE_MONITOR_EVENT_RENAMED, + * %G_FILE_MONITOR_EVENT_MOVED_IN and %G_FILE_MONITOR_EVENT_MOVED_OUT + * events to be emitted when possible. Since: 2.46. + * + * Flags used to set what a #GFileMonitor will watch for. + */ +typedef enum { + G_FILE_MONITOR_NONE = 0, + G_FILE_MONITOR_WATCH_MOUNTS = (1 << 0), + G_FILE_MONITOR_SEND_MOVED = (1 << 1), + G_FILE_MONITOR_WATCH_HARD_LINKS = (1 << 2), + G_FILE_MONITOR_WATCH_MOVES = (1 << 3) +} GFileMonitorFlags; + + +/** + * GFileType: + * @G_FILE_TYPE_UNKNOWN: File's type is unknown. + * @G_FILE_TYPE_REGULAR: File handle represents a regular file. + * @G_FILE_TYPE_DIRECTORY: File handle represents a directory. + * @G_FILE_TYPE_SYMBOLIC_LINK: File handle represents a symbolic link + * (Unix systems). + * @G_FILE_TYPE_SPECIAL: File is a "special" file, such as a socket, fifo, + * block device, or character device. + * @G_FILE_TYPE_SHORTCUT: File is a shortcut (Windows systems). + * @G_FILE_TYPE_MOUNTABLE: File is a mountable location. + * + * Indicates the file's on-disk type. + * + * On Windows systems a file will never have %G_FILE_TYPE_SYMBOLIC_LINK type; + * use #GFileInfo and %G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK to determine + * whether a file is a symlink or not. This is due to the fact that NTFS does + * not have a single filesystem object type for symbolic links - it has + * files that symlink to files, and directories that symlink to directories. + * #GFileType enumeration cannot precisely represent this important distinction, + * which is why all Windows symlinks will continue to be reported as + * %G_FILE_TYPE_REGULAR or %G_FILE_TYPE_DIRECTORY. + **/ +typedef enum { + G_FILE_TYPE_UNKNOWN = 0, + G_FILE_TYPE_REGULAR, + G_FILE_TYPE_DIRECTORY, + G_FILE_TYPE_SYMBOLIC_LINK, + G_FILE_TYPE_SPECIAL, /* socket, fifo, blockdev, chardev */ + G_FILE_TYPE_SHORTCUT, + G_FILE_TYPE_MOUNTABLE +} GFileType; + + +/** + * GFilesystemPreviewType: + * @G_FILESYSTEM_PREVIEW_TYPE_IF_ALWAYS: Only preview files if user has explicitly requested it. + * @G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL: Preview files if user has requested preview of "local" files. + * @G_FILESYSTEM_PREVIEW_TYPE_NEVER: Never preview files. + * + * Indicates a hint from the file system whether files should be + * previewed in a file manager. Returned as the value of the key + * %G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW. + **/ +typedef enum { + G_FILESYSTEM_PREVIEW_TYPE_IF_ALWAYS = 0, + G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL, + G_FILESYSTEM_PREVIEW_TYPE_NEVER +} GFilesystemPreviewType; + + +/** + * GFileMonitorEvent: + * @G_FILE_MONITOR_EVENT_CHANGED: a file changed. + * @G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: a hint that this was probably the last change in a set of changes. + * @G_FILE_MONITOR_EVENT_DELETED: a file was deleted. + * @G_FILE_MONITOR_EVENT_CREATED: a file was created. + * @G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: a file attribute was changed. + * @G_FILE_MONITOR_EVENT_PRE_UNMOUNT: the file location will soon be unmounted. + * @G_FILE_MONITOR_EVENT_UNMOUNTED: the file location was unmounted. + * @G_FILE_MONITOR_EVENT_MOVED: the file was moved -- only sent if the + * (deprecated) %G_FILE_MONITOR_SEND_MOVED flag is set + * @G_FILE_MONITOR_EVENT_RENAMED: the file was renamed within the + * current directory -- only sent if the %G_FILE_MONITOR_WATCH_MOVES + * flag is set. Since: 2.46. + * @G_FILE_MONITOR_EVENT_MOVED_IN: the file was moved into the + * monitored directory from another location -- only sent if the + * %G_FILE_MONITOR_WATCH_MOVES flag is set. Since: 2.46. + * @G_FILE_MONITOR_EVENT_MOVED_OUT: the file was moved out of the + * monitored directory to another location -- only sent if the + * %G_FILE_MONITOR_WATCH_MOVES flag is set. Since: 2.46 + * + * Specifies what type of event a monitor event is. + **/ +typedef enum { + G_FILE_MONITOR_EVENT_CHANGED, + G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT, + G_FILE_MONITOR_EVENT_DELETED, + G_FILE_MONITOR_EVENT_CREATED, + G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED, + G_FILE_MONITOR_EVENT_PRE_UNMOUNT, + G_FILE_MONITOR_EVENT_UNMOUNTED, + G_FILE_MONITOR_EVENT_MOVED, + G_FILE_MONITOR_EVENT_RENAMED, + G_FILE_MONITOR_EVENT_MOVED_IN, + G_FILE_MONITOR_EVENT_MOVED_OUT +} GFileMonitorEvent; + + +/* This enumeration conflicts with GIOError in giochannel.h. However, + * that is only used as a return value in some deprecated functions. + * So, we reuse the same prefix for the enumeration values, but call + * the actual enumeration (which is rarely used) GIOErrorEnum. + */ +/** + * GIOErrorEnum: + * @G_IO_ERROR_FAILED: Generic error condition for when an operation fails + * and no more specific #GIOErrorEnum value is defined. + * @G_IO_ERROR_NOT_FOUND: File not found. + * @G_IO_ERROR_EXISTS: File already exists. + * @G_IO_ERROR_IS_DIRECTORY: File is a directory. + * @G_IO_ERROR_NOT_DIRECTORY: File is not a directory. + * @G_IO_ERROR_NOT_EMPTY: File is a directory that isn't empty. + * @G_IO_ERROR_NOT_REGULAR_FILE: File is not a regular file. + * @G_IO_ERROR_NOT_SYMBOLIC_LINK: File is not a symbolic link. + * @G_IO_ERROR_NOT_MOUNTABLE_FILE: File cannot be mounted. + * @G_IO_ERROR_FILENAME_TOO_LONG: Filename is too many characters. + * @G_IO_ERROR_INVALID_FILENAME: Filename is invalid or contains invalid characters. + * @G_IO_ERROR_TOO_MANY_LINKS: File contains too many symbolic links. + * @G_IO_ERROR_NO_SPACE: No space left on drive. + * @G_IO_ERROR_INVALID_ARGUMENT: Invalid argument. + * @G_IO_ERROR_PERMISSION_DENIED: Permission denied. + * @G_IO_ERROR_NOT_SUPPORTED: Operation (or one of its parameters) not supported + * @G_IO_ERROR_NOT_MOUNTED: File isn't mounted. + * @G_IO_ERROR_ALREADY_MOUNTED: File is already mounted. + * @G_IO_ERROR_CLOSED: File was closed. + * @G_IO_ERROR_CANCELLED: Operation was cancelled. See #GCancellable. + * @G_IO_ERROR_PENDING: Operations are still pending. + * @G_IO_ERROR_READ_ONLY: File is read only. + * @G_IO_ERROR_CANT_CREATE_BACKUP: Backup couldn't be created. + * @G_IO_ERROR_WRONG_ETAG: File's Entity Tag was incorrect. + * @G_IO_ERROR_TIMED_OUT: Operation timed out. + * @G_IO_ERROR_WOULD_RECURSE: Operation would be recursive. + * @G_IO_ERROR_BUSY: File is busy. + * @G_IO_ERROR_WOULD_BLOCK: Operation would block. + * @G_IO_ERROR_HOST_NOT_FOUND: Host couldn't be found (remote operations). + * @G_IO_ERROR_WOULD_MERGE: Operation would merge files. + * @G_IO_ERROR_FAILED_HANDLED: Operation failed and a helper program has + * already interacted with the user. Do not display any error dialog. + * @G_IO_ERROR_TOO_MANY_OPEN_FILES: The current process has too many files + * open and can't open any more. Duplicate descriptors do count toward + * this limit. Since 2.20 + * @G_IO_ERROR_NOT_INITIALIZED: The object has not been initialized. Since 2.22 + * @G_IO_ERROR_ADDRESS_IN_USE: The requested address is already in use. Since 2.22 + * @G_IO_ERROR_PARTIAL_INPUT: Need more input to finish operation. Since 2.24 + * @G_IO_ERROR_INVALID_DATA: The input data was invalid. Since 2.24 + * @G_IO_ERROR_DBUS_ERROR: A remote object generated an error that + * doesn't correspond to a locally registered #GError error + * domain. Use g_dbus_error_get_remote_error() to extract the D-Bus + * error name and g_dbus_error_strip_remote_error() to fix up the + * message so it matches what was received on the wire. Since 2.26. + * @G_IO_ERROR_HOST_UNREACHABLE: Host unreachable. Since 2.26 + * @G_IO_ERROR_NETWORK_UNREACHABLE: Network unreachable. Since 2.26 + * @G_IO_ERROR_CONNECTION_REFUSED: Connection refused. Since 2.26 + * @G_IO_ERROR_PROXY_FAILED: Connection to proxy server failed. Since 2.26 + * @G_IO_ERROR_PROXY_AUTH_FAILED: Proxy authentication failed. Since 2.26 + * @G_IO_ERROR_PROXY_NEED_AUTH: Proxy server needs authentication. Since 2.26 + * @G_IO_ERROR_PROXY_NOT_ALLOWED: Proxy connection is not allowed by ruleset. + * Since 2.26 + * @G_IO_ERROR_BROKEN_PIPE: Broken pipe. Since 2.36 + * @G_IO_ERROR_CONNECTION_CLOSED: Connection closed by peer. Note that this + * is the same code as %G_IO_ERROR_BROKEN_PIPE; before 2.44 some + * "connection closed" errors returned %G_IO_ERROR_BROKEN_PIPE, but others + * returned %G_IO_ERROR_FAILED. Now they should all return the same + * value, which has this more logical name. Since 2.44. + * @G_IO_ERROR_NOT_CONNECTED: Transport endpoint is not connected. Since 2.44 + * @G_IO_ERROR_MESSAGE_TOO_LARGE: Message too large. Since 2.48. + * @G_IO_ERROR_NO_SUCH_DEVICE: No such device found. Since 2.74 + * @G_IO_ERROR_DESTINATION_UNSET: Destination address unset. Since 2.80 + * + * Error codes returned by GIO functions. + * + * Note that this domain may be extended in future GLib releases. In + * general, new error codes either only apply to new APIs, or else + * replace %G_IO_ERROR_FAILED in cases that were not explicitly + * distinguished before. You should therefore avoid writing code like + * |[ + * if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED)) + * { + * // Assume that this is EPRINTERONFIRE + * ... + * } + * ]| + * but should instead treat all unrecognized error codes the same as + * %G_IO_ERROR_FAILED. + * + * See also #GPollableReturn for a cheaper way of returning + * %G_IO_ERROR_WOULD_BLOCK to callers without allocating a #GError. + **/ +typedef enum { + G_IO_ERROR_FAILED, + G_IO_ERROR_NOT_FOUND, + G_IO_ERROR_EXISTS, + G_IO_ERROR_IS_DIRECTORY, + G_IO_ERROR_NOT_DIRECTORY, + G_IO_ERROR_NOT_EMPTY, + G_IO_ERROR_NOT_REGULAR_FILE, + G_IO_ERROR_NOT_SYMBOLIC_LINK, + G_IO_ERROR_NOT_MOUNTABLE_FILE, + G_IO_ERROR_FILENAME_TOO_LONG, + G_IO_ERROR_INVALID_FILENAME, + G_IO_ERROR_TOO_MANY_LINKS, + G_IO_ERROR_NO_SPACE, + G_IO_ERROR_INVALID_ARGUMENT, + G_IO_ERROR_PERMISSION_DENIED, + G_IO_ERROR_NOT_SUPPORTED, + G_IO_ERROR_NOT_MOUNTED, + G_IO_ERROR_ALREADY_MOUNTED, + G_IO_ERROR_CLOSED, + G_IO_ERROR_CANCELLED, + G_IO_ERROR_PENDING, + G_IO_ERROR_READ_ONLY, + G_IO_ERROR_CANT_CREATE_BACKUP, + G_IO_ERROR_WRONG_ETAG, + G_IO_ERROR_TIMED_OUT, + G_IO_ERROR_WOULD_RECURSE, + G_IO_ERROR_BUSY, + G_IO_ERROR_WOULD_BLOCK, + G_IO_ERROR_HOST_NOT_FOUND, + G_IO_ERROR_WOULD_MERGE, + G_IO_ERROR_FAILED_HANDLED, + G_IO_ERROR_TOO_MANY_OPEN_FILES, + G_IO_ERROR_NOT_INITIALIZED, + G_IO_ERROR_ADDRESS_IN_USE, + G_IO_ERROR_PARTIAL_INPUT, + G_IO_ERROR_INVALID_DATA, + G_IO_ERROR_DBUS_ERROR, + G_IO_ERROR_HOST_UNREACHABLE, + G_IO_ERROR_NETWORK_UNREACHABLE, + G_IO_ERROR_CONNECTION_REFUSED, + G_IO_ERROR_PROXY_FAILED, + G_IO_ERROR_PROXY_AUTH_FAILED, + G_IO_ERROR_PROXY_NEED_AUTH, + G_IO_ERROR_PROXY_NOT_ALLOWED, + G_IO_ERROR_BROKEN_PIPE, + G_IO_ERROR_CONNECTION_CLOSED = G_IO_ERROR_BROKEN_PIPE, + G_IO_ERROR_NOT_CONNECTED, + G_IO_ERROR_MESSAGE_TOO_LARGE, + G_IO_ERROR_NO_SUCH_DEVICE GIO_AVAILABLE_ENUMERATOR_IN_2_74, + G_IO_ERROR_DESTINATION_UNSET GIO_AVAILABLE_ENUMERATOR_IN_2_80, +} GIOErrorEnum; + + +/** + * GAskPasswordFlags: + * @G_ASK_PASSWORD_NEED_PASSWORD: operation requires a password. + * @G_ASK_PASSWORD_NEED_USERNAME: operation requires a username. + * @G_ASK_PASSWORD_NEED_DOMAIN: operation requires a domain. + * @G_ASK_PASSWORD_SAVING_SUPPORTED: operation supports saving settings. + * @G_ASK_PASSWORD_ANONYMOUS_SUPPORTED: operation supports anonymous users. + * @G_ASK_PASSWORD_TCRYPT: operation takes TCRYPT parameters (Since: 2.58) + * + * #GAskPasswordFlags are used to request specific information from the + * user, or to notify the user of their choices in an authentication + * situation. + **/ +typedef enum { + G_ASK_PASSWORD_NEED_PASSWORD = (1 << 0), + G_ASK_PASSWORD_NEED_USERNAME = (1 << 1), + G_ASK_PASSWORD_NEED_DOMAIN = (1 << 2), + G_ASK_PASSWORD_SAVING_SUPPORTED = (1 << 3), + G_ASK_PASSWORD_ANONYMOUS_SUPPORTED = (1 << 4), + G_ASK_PASSWORD_TCRYPT = (1 << 5), +} GAskPasswordFlags; + + +/** + * GPasswordSave: + * @G_PASSWORD_SAVE_NEVER: never save a password. + * @G_PASSWORD_SAVE_FOR_SESSION: save a password for the session. + * @G_PASSWORD_SAVE_PERMANENTLY: save a password permanently. + * + * #GPasswordSave is used to indicate the lifespan of a saved password. + * + * #Gvfs stores passwords in the Gnome keyring when this flag allows it + * to, and later retrieves it again from there. + **/ +typedef enum { + G_PASSWORD_SAVE_NEVER, + G_PASSWORD_SAVE_FOR_SESSION, + G_PASSWORD_SAVE_PERMANENTLY +} GPasswordSave; + + +/** + * GMountOperationResult: + * @G_MOUNT_OPERATION_HANDLED: The request was fulfilled and the + * user specified data is now available + * @G_MOUNT_OPERATION_ABORTED: The user requested the mount operation + * to be aborted + * @G_MOUNT_OPERATION_UNHANDLED: The request was unhandled (i.e. not + * implemented) + * + * #GMountOperationResult is returned as a result when a request for + * information is send by the mounting operation. + **/ +typedef enum { + G_MOUNT_OPERATION_HANDLED, + G_MOUNT_OPERATION_ABORTED, + G_MOUNT_OPERATION_UNHANDLED +} GMountOperationResult; + + +/** + * GOutputStreamSpliceFlags: + * @G_OUTPUT_STREAM_SPLICE_NONE: Do not close either stream. + * @G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE: Close the source stream after + * the splice. + * @G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET: Close the target stream after + * the splice. + * + * GOutputStreamSpliceFlags determine how streams should be spliced. + **/ +typedef enum { + G_OUTPUT_STREAM_SPLICE_NONE = 0, + G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE = (1 << 0), + G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET = (1 << 1) +} GOutputStreamSpliceFlags; + + +/** + * GIOStreamSpliceFlags: + * @G_IO_STREAM_SPLICE_NONE: Do not close either stream. + * @G_IO_STREAM_SPLICE_CLOSE_STREAM1: Close the first stream after + * the splice. + * @G_IO_STREAM_SPLICE_CLOSE_STREAM2: Close the second stream after + * the splice. + * @G_IO_STREAM_SPLICE_WAIT_FOR_BOTH: Wait for both splice operations to finish + * before calling the callback. + * + * GIOStreamSpliceFlags determine how streams should be spliced. + * + * Since: 2.28 + **/ +typedef enum { + G_IO_STREAM_SPLICE_NONE = 0, + G_IO_STREAM_SPLICE_CLOSE_STREAM1 = (1 << 0), + G_IO_STREAM_SPLICE_CLOSE_STREAM2 = (1 << 1), + G_IO_STREAM_SPLICE_WAIT_FOR_BOTH = (1 << 2) +} GIOStreamSpliceFlags; + +/** + * GEmblemOrigin: + * @G_EMBLEM_ORIGIN_UNKNOWN: Emblem of unknown origin + * @G_EMBLEM_ORIGIN_DEVICE: Emblem adds device-specific information + * @G_EMBLEM_ORIGIN_LIVEMETADATA: Emblem depicts live metadata, such as "readonly" + * @G_EMBLEM_ORIGIN_TAG: Emblem comes from a user-defined tag, e.g. set by nautilus (in the future) + * + * GEmblemOrigin is used to add information about the origin of the emblem + * to #GEmblem. + * + * Since: 2.18 + */ +typedef enum { + G_EMBLEM_ORIGIN_UNKNOWN, + G_EMBLEM_ORIGIN_DEVICE, + G_EMBLEM_ORIGIN_LIVEMETADATA, + G_EMBLEM_ORIGIN_TAG +} GEmblemOrigin; + +/** + * GResolverError: + * @G_RESOLVER_ERROR_NOT_FOUND: the requested name/address/service was not + * found + * @G_RESOLVER_ERROR_TEMPORARY_FAILURE: the requested information could not + * be looked up due to a network error or similar problem + * @G_RESOLVER_ERROR_INTERNAL: unknown error + * + * An error code used with %G_RESOLVER_ERROR in a #GError returned + * from a #GResolver routine. + * + * Since: 2.22 + */ +typedef enum { + G_RESOLVER_ERROR_NOT_FOUND, + G_RESOLVER_ERROR_TEMPORARY_FAILURE, + G_RESOLVER_ERROR_INTERNAL +} GResolverError; + +/** + * GResolverRecordType: + * @G_RESOLVER_RECORD_SRV: look up DNS SRV records for a domain + * @G_RESOLVER_RECORD_MX: look up DNS MX records for a domain + * @G_RESOLVER_RECORD_TXT: look up DNS TXT records for a name + * @G_RESOLVER_RECORD_SOA: look up DNS SOA records for a zone + * @G_RESOLVER_RECORD_NS: look up DNS NS records for a domain + * + * The type of record that g_resolver_lookup_records() or + * g_resolver_lookup_records_async() should retrieve. The records are returned + * as lists of #GVariant tuples. Each record type has different values in + * the variant tuples returned. + * + * %G_RESOLVER_RECORD_SRV records are returned as variants with the signature + * `(qqqs)`, containing a `guint16` with the priority, a `guint16` with the + * weight, a `guint16` with the port, and a string of the hostname. + * + * %G_RESOLVER_RECORD_MX records are returned as variants with the signature + * `(qs)`, representing a `guint16` with the preference, and a string containing + * the mail exchanger hostname. + * + * %G_RESOLVER_RECORD_TXT records are returned as variants with the signature + * `(as)`, representing an array of the strings in the text record. Note: Most TXT + * records only contain a single string, but + * [RFC 1035](https://tools.ietf.org/html/rfc1035#section-3.3.14) does allow a + * record to contain multiple strings. The RFC which defines the interpretation + * of a specific TXT record will likely require concatenation of multiple + * strings if they are present, as with + * [RFC 7208](https://tools.ietf.org/html/rfc7208#section-3.3). + * + * %G_RESOLVER_RECORD_SOA records are returned as variants with the signature + * `(ssuuuuu)`, representing a string containing the primary name server, a + * string containing the administrator, the serial as a `guint32`, the refresh + * interval as a `guint32`, the retry interval as a `guint32`, the expire timeout + * as a `guint32`, and the TTL as a `guint32`. + * + * %G_RESOLVER_RECORD_NS records are returned as variants with the signature + * `(s)`, representing a string of the hostname of the name server. + * + * Since: 2.34 + */ +typedef enum { + G_RESOLVER_RECORD_SRV = 1, + G_RESOLVER_RECORD_MX, + G_RESOLVER_RECORD_TXT, + G_RESOLVER_RECORD_SOA, + G_RESOLVER_RECORD_NS +} GResolverRecordType; + +/** + * GResourceError: + * @G_RESOURCE_ERROR_NOT_FOUND: no file was found at the requested path + * @G_RESOURCE_ERROR_INTERNAL: unknown error + * + * An error code used with %G_RESOURCE_ERROR in a #GError returned + * from a #GResource routine. + * + * Since: 2.32 + */ +typedef enum { + G_RESOURCE_ERROR_NOT_FOUND, + G_RESOURCE_ERROR_INTERNAL +} GResourceError; + +/** + * GResourceFlags: + * @G_RESOURCE_FLAGS_NONE: No flags set. + * @G_RESOURCE_FLAGS_COMPRESSED: The file is compressed. + * + * GResourceFlags give information about a particular file inside a resource + * bundle. + * + * Since: 2.32 + **/ +typedef enum { + G_RESOURCE_FLAGS_NONE = 0, + G_RESOURCE_FLAGS_COMPRESSED = (1<<0) +} GResourceFlags; + +/** + * GResourceLookupFlags: + * @G_RESOURCE_LOOKUP_FLAGS_NONE: No flags set. + * + * GResourceLookupFlags determine how resource path lookups are handled. + * + * Since: 2.32 + **/ +typedef enum /*< flags >*/ { + G_RESOURCE_LOOKUP_FLAGS_NONE = 0 +} GResourceLookupFlags; + +/** + * GSocketFamily: + * @G_SOCKET_FAMILY_INVALID: no address family + * @G_SOCKET_FAMILY_IPV4: the IPv4 family + * @G_SOCKET_FAMILY_IPV6: the IPv6 family + * @G_SOCKET_FAMILY_UNIX: the UNIX domain family + * + * The protocol family of a #GSocketAddress. (These values are + * identical to the system defines %AF_INET, %AF_INET6 and %AF_UNIX, + * if available.) + * + * Since: 2.22 + */ +typedef enum { + G_SOCKET_FAMILY_INVALID, + G_SOCKET_FAMILY_UNIX = GLIB_SYSDEF_AF_UNIX, + G_SOCKET_FAMILY_IPV4 = GLIB_SYSDEF_AF_INET, + G_SOCKET_FAMILY_IPV6 = GLIB_SYSDEF_AF_INET6 +} GSocketFamily; + +/** + * GSocketType: + * @G_SOCKET_TYPE_INVALID: Type unknown or wrong + * @G_SOCKET_TYPE_STREAM: Reliable connection-based byte streams (e.g. TCP). + * @G_SOCKET_TYPE_DATAGRAM: Connectionless, unreliable datagram passing. + * (e.g. UDP) + * @G_SOCKET_TYPE_SEQPACKET: Reliable connection-based passing of datagrams + * of fixed maximum length (e.g. SCTP). + * + * Flags used when creating a #GSocket. Some protocols may not implement + * all the socket types. + * + * Since: 2.22 + */ +typedef enum +{ + G_SOCKET_TYPE_INVALID, + G_SOCKET_TYPE_STREAM, + G_SOCKET_TYPE_DATAGRAM, + G_SOCKET_TYPE_SEQPACKET +} GSocketType; + +/** + * GSocketMsgFlags: + * @G_SOCKET_MSG_NONE: No flags. + * @G_SOCKET_MSG_OOB: Request to send/receive out of band data. + * @G_SOCKET_MSG_PEEK: Read data from the socket without removing it from + * the queue. + * @G_SOCKET_MSG_DONTROUTE: Don't use a gateway to send out the packet, + * only send to hosts on directly connected networks. + * + * Flags used in g_socket_receive_message() and g_socket_send_message(). + * The flags listed in the enum are some commonly available flags, but the + * values used for them are the same as on the platform, and any other flags + * are passed in/out as is. So to use a platform specific flag, just include + * the right system header and pass in the flag. + * + * Since: 2.22 + */ +typedef enum /*< flags >*/ +{ + G_SOCKET_MSG_NONE, + G_SOCKET_MSG_OOB = GLIB_SYSDEF_MSG_OOB, + G_SOCKET_MSG_PEEK = GLIB_SYSDEF_MSG_PEEK, + G_SOCKET_MSG_DONTROUTE = GLIB_SYSDEF_MSG_DONTROUTE +} GSocketMsgFlags; + +/** + * GSocketProtocol: + * @G_SOCKET_PROTOCOL_UNKNOWN: The protocol type is unknown + * @G_SOCKET_PROTOCOL_DEFAULT: The default protocol for the family/type + * @G_SOCKET_PROTOCOL_TCP: TCP over IP + * @G_SOCKET_PROTOCOL_UDP: UDP over IP + * @G_SOCKET_PROTOCOL_SCTP: SCTP over IP + * + * A protocol identifier is specified when creating a #GSocket, which is a + * family/type specific identifier, where 0 means the default protocol for + * the particular family/type. + * + * This enum contains a set of commonly available and used protocols. You + * can also pass any other identifiers handled by the platform in order to + * use protocols not listed here. + * + * Since: 2.22 + */ +typedef enum { + G_SOCKET_PROTOCOL_UNKNOWN = -1, + G_SOCKET_PROTOCOL_DEFAULT = 0, + G_SOCKET_PROTOCOL_TCP = 6, + G_SOCKET_PROTOCOL_UDP = 17, + G_SOCKET_PROTOCOL_SCTP = 132 +} GSocketProtocol; + +/** + * GZlibCompressorFormat: + * @G_ZLIB_COMPRESSOR_FORMAT_ZLIB: deflate compression with zlib header + * @G_ZLIB_COMPRESSOR_FORMAT_GZIP: gzip file format + * @G_ZLIB_COMPRESSOR_FORMAT_RAW: deflate compression with no header + * + * Used to select the type of data format to use for #GZlibDecompressor + * and #GZlibCompressor. + * + * Since: 2.24 + */ +typedef enum { + G_ZLIB_COMPRESSOR_FORMAT_ZLIB, + G_ZLIB_COMPRESSOR_FORMAT_GZIP, + G_ZLIB_COMPRESSOR_FORMAT_RAW +} GZlibCompressorFormat; + +/** + * GUnixSocketAddressType: + * @G_UNIX_SOCKET_ADDRESS_INVALID: invalid + * @G_UNIX_SOCKET_ADDRESS_ANONYMOUS: anonymous + * @G_UNIX_SOCKET_ADDRESS_PATH: a filesystem path + * @G_UNIX_SOCKET_ADDRESS_ABSTRACT: an abstract name + * @G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED: an abstract name, 0-padded + * to the full length of a unix socket name + * + * The type of name used by a #GUnixSocketAddress. + * %G_UNIX_SOCKET_ADDRESS_PATH indicates a traditional unix domain + * socket bound to a filesystem path. %G_UNIX_SOCKET_ADDRESS_ANONYMOUS + * indicates a socket not bound to any name (eg, a client-side socket, + * or a socket created with socketpair()). + * + * For abstract sockets, there are two incompatible ways of naming + * them; the man pages suggest using the entire `struct sockaddr_un` + * as the name, padding the unused parts of the %sun_path field with + * zeroes; this corresponds to %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED. + * However, many programs instead just use a portion of %sun_path, and + * pass an appropriate smaller length to bind() or connect(). This is + * %G_UNIX_SOCKET_ADDRESS_ABSTRACT. + * + * Since: 2.26 + */ +typedef enum { + G_UNIX_SOCKET_ADDRESS_INVALID, + G_UNIX_SOCKET_ADDRESS_ANONYMOUS, + G_UNIX_SOCKET_ADDRESS_PATH, + G_UNIX_SOCKET_ADDRESS_ABSTRACT, + G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED +} GUnixSocketAddressType; + +/** + * GBusType: + * @G_BUS_TYPE_STARTER: An alias for the message bus that activated the process, if any. + * @G_BUS_TYPE_NONE: Not a message bus. + * @G_BUS_TYPE_SYSTEM: The system-wide message bus. + * @G_BUS_TYPE_SESSION: The login session message bus. + * + * An enumeration for well-known message buses. + * + * Since: 2.26 + */ +typedef enum +{ + G_BUS_TYPE_STARTER = -1, + G_BUS_TYPE_NONE = 0, + G_BUS_TYPE_SYSTEM = 1, + G_BUS_TYPE_SESSION = 2 +} GBusType; + +/** + * GBusNameOwnerFlags: + * @G_BUS_NAME_OWNER_FLAGS_NONE: No flags set. + * @G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT: Allow another message bus connection to claim the name. + * @G_BUS_NAME_OWNER_FLAGS_REPLACE: If another message bus connection owns the name and have + * specified %G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, then take the name from the other connection. + * @G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE: If another message bus connection owns the name, immediately + * return an error from g_bus_own_name() rather than entering the waiting queue for that name. (Since 2.54) + * + * Flags used in g_bus_own_name(). + * + * Since: 2.26 + */ +typedef enum +{ + G_BUS_NAME_OWNER_FLAGS_NONE = 0, /*< nick=none >*/ + G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT = (1<<0), /*< nick=allow-replacement >*/ + G_BUS_NAME_OWNER_FLAGS_REPLACE = (1<<1), /*< nick=replace >*/ + G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE = (1<<2) /*< nick=do-not-queue >*/ +} GBusNameOwnerFlags; +/* When adding new flags, their numeric values must currently match those + * used in the D-Bus Specification. */ + +/** + * GBusNameWatcherFlags: + * @G_BUS_NAME_WATCHER_FLAGS_NONE: No flags set. + * @G_BUS_NAME_WATCHER_FLAGS_AUTO_START: If no-one owns the name when + * beginning to watch the name, ask the bus to launch an owner for the + * name. + * + * Flags used in g_bus_watch_name(). + * + * Since: 2.26 + */ +typedef enum +{ + G_BUS_NAME_WATCHER_FLAGS_NONE = 0, + G_BUS_NAME_WATCHER_FLAGS_AUTO_START = (1<<0) +} GBusNameWatcherFlags; + +/** + * GDBusProxyFlags: + * @G_DBUS_PROXY_FLAGS_NONE: No flags set. + * @G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES: Don't load properties. + * @G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS: Don't connect to signals on the remote object. + * @G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START: If the proxy is for a well-known name, + * do not ask the bus to launch an owner during proxy initialization or a method call. + * This flag is only meaningful in proxies for well-known names. + * @G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES: If set, the property value for any __invalidated property__ will be (asynchronously) retrieved upon receiving the [`PropertiesChanged`](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties) D-Bus signal and the property will not cause emission of the #GDBusProxy::g-properties-changed signal. When the value is received the #GDBusProxy::g-properties-changed signal is emitted for the property along with the retrieved value. Since 2.32. + * @G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION: If the proxy is for a well-known name, + * do not ask the bus to launch an owner during proxy initialization, but allow it to be + * autostarted by a method call. This flag is only meaningful in proxies for well-known names, + * and only if %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START is not also specified. + * @G_DBUS_PROXY_FLAGS_NO_MATCH_RULE: Don't actually send the AddMatch D-Bus + * call for this signal subscription. This gives you more control + * over which match rules you add (but you must add them manually). (Since: 2.72) + * + * Flags used when constructing an instance of a #GDBusProxy derived class. + * + * Since: 2.26 + */ +typedef enum +{ + G_DBUS_PROXY_FLAGS_NONE = 0, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES = (1<<0), + G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS = (1<<1), + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START = (1<<2), + G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES = (1<<3), + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION = (1<<4), + G_DBUS_PROXY_FLAGS_NO_MATCH_RULE GIO_AVAILABLE_ENUMERATOR_IN_2_72 = (1<<5) +} GDBusProxyFlags; + +/** + * GDBusError: + * @G_DBUS_ERROR_FAILED: + * A generic error; "something went wrong" - see the error message for + * more. + * @G_DBUS_ERROR_NO_MEMORY: + * There was not enough memory to complete an operation. + * @G_DBUS_ERROR_SERVICE_UNKNOWN: + * The bus doesn't know how to launch a service to supply the bus name + * you wanted. + * @G_DBUS_ERROR_NAME_HAS_NO_OWNER: + * The bus name you referenced doesn't exist (i.e. no application owns + * it). + * @G_DBUS_ERROR_NO_REPLY: + * No reply to a message expecting one, usually means a timeout occurred. + * @G_DBUS_ERROR_IO_ERROR: + * Something went wrong reading or writing to a socket, for example. + * @G_DBUS_ERROR_BAD_ADDRESS: + * A D-Bus bus address was malformed. + * @G_DBUS_ERROR_NOT_SUPPORTED: + * Requested operation isn't supported (like ENOSYS on UNIX). + * @G_DBUS_ERROR_LIMITS_EXCEEDED: + * Some limited resource is exhausted. + * @G_DBUS_ERROR_ACCESS_DENIED: + * Security restrictions don't allow doing what you're trying to do. + * @G_DBUS_ERROR_AUTH_FAILED: + * Authentication didn't work. + * @G_DBUS_ERROR_NO_SERVER: + * Unable to connect to server (probably caused by ECONNREFUSED on a + * socket). + * @G_DBUS_ERROR_TIMEOUT: + * Certain timeout errors, possibly ETIMEDOUT on a socket. Note that + * %G_DBUS_ERROR_NO_REPLY is used for message reply timeouts. Warning: + * this is confusingly-named given that %G_DBUS_ERROR_TIMED_OUT also + * exists. We can't fix it for compatibility reasons so just be + * careful. + * @G_DBUS_ERROR_NO_NETWORK: + * No network access (probably ENETUNREACH on a socket). + * @G_DBUS_ERROR_ADDRESS_IN_USE: + * Can't bind a socket since its address is in use (i.e. EADDRINUSE). + * @G_DBUS_ERROR_DISCONNECTED: + * The connection is disconnected and you're trying to use it. + * @G_DBUS_ERROR_INVALID_ARGS: + * Invalid arguments passed to a method call. + * @G_DBUS_ERROR_FILE_NOT_FOUND: + * Missing file. + * @G_DBUS_ERROR_FILE_EXISTS: + * Existing file and the operation you're using does not silently overwrite. + * @G_DBUS_ERROR_UNKNOWN_METHOD: + * Method name you invoked isn't known by the object you invoked it on. + * @G_DBUS_ERROR_UNKNOWN_OBJECT: + * Object you invoked a method on isn't known. Since 2.42 + * @G_DBUS_ERROR_UNKNOWN_INTERFACE: + * Interface you invoked a method on isn't known by the object. Since 2.42 + * @G_DBUS_ERROR_UNKNOWN_PROPERTY: + * Property you tried to access isn't known by the object. Since 2.42 + * @G_DBUS_ERROR_PROPERTY_READ_ONLY: + * Property you tried to set is read-only. Since 2.42 + * @G_DBUS_ERROR_TIMED_OUT: + * Certain timeout errors, e.g. while starting a service. Warning: this is + * confusingly-named given that %G_DBUS_ERROR_TIMEOUT also exists. We + * can't fix it for compatibility reasons so just be careful. + * @G_DBUS_ERROR_MATCH_RULE_NOT_FOUND: + * Tried to remove or modify a match rule that didn't exist. + * @G_DBUS_ERROR_MATCH_RULE_INVALID: + * The match rule isn't syntactically valid. + * @G_DBUS_ERROR_SPAWN_EXEC_FAILED: + * While starting a new process, the exec() call failed. + * @G_DBUS_ERROR_SPAWN_FORK_FAILED: + * While starting a new process, the fork() call failed. + * @G_DBUS_ERROR_SPAWN_CHILD_EXITED: + * While starting a new process, the child exited with a status code. + * @G_DBUS_ERROR_SPAWN_CHILD_SIGNALED: + * While starting a new process, the child exited on a signal. + * @G_DBUS_ERROR_SPAWN_FAILED: + * While starting a new process, something went wrong. + * @G_DBUS_ERROR_SPAWN_SETUP_FAILED: + * We failed to setup the environment correctly. + * @G_DBUS_ERROR_SPAWN_CONFIG_INVALID: + * We failed to setup the config parser correctly. + * @G_DBUS_ERROR_SPAWN_SERVICE_INVALID: + * Bus name was not valid. + * @G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND: + * Service file not found in system-services directory. + * @G_DBUS_ERROR_SPAWN_PERMISSIONS_INVALID: + * Permissions are incorrect on the setuid helper. + * @G_DBUS_ERROR_SPAWN_FILE_INVALID: + * Service file invalid (Name, User or Exec missing). + * @G_DBUS_ERROR_SPAWN_NO_MEMORY: + * Tried to get a UNIX process ID and it wasn't available. + * @G_DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN: + * Tried to get a UNIX process ID and it wasn't available. + * @G_DBUS_ERROR_INVALID_SIGNATURE: + * A type signature is not valid. + * @G_DBUS_ERROR_INVALID_FILE_CONTENT: + * A file contains invalid syntax or is otherwise broken. + * @G_DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN: + * Asked for SELinux security context and it wasn't available. + * @G_DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN: + * Asked for ADT audit data and it wasn't available. + * @G_DBUS_ERROR_OBJECT_PATH_IN_USE: + * There's already an object with the requested object path. + * + * Error codes for the %G_DBUS_ERROR error domain. + * + * Since: 2.26 + */ +typedef enum +{ + /* Well-known errors in the org.freedesktop.DBus.Error namespace */ + G_DBUS_ERROR_FAILED, /* org.freedesktop.DBus.Error.Failed */ + G_DBUS_ERROR_NO_MEMORY, /* org.freedesktop.DBus.Error.NoMemory */ + G_DBUS_ERROR_SERVICE_UNKNOWN, /* org.freedesktop.DBus.Error.ServiceUnknown */ + G_DBUS_ERROR_NAME_HAS_NO_OWNER, /* org.freedesktop.DBus.Error.NameHasNoOwner */ + G_DBUS_ERROR_NO_REPLY, /* org.freedesktop.DBus.Error.NoReply */ + G_DBUS_ERROR_IO_ERROR, /* org.freedesktop.DBus.Error.IOError */ + G_DBUS_ERROR_BAD_ADDRESS, /* org.freedesktop.DBus.Error.BadAddress */ + G_DBUS_ERROR_NOT_SUPPORTED, /* org.freedesktop.DBus.Error.NotSupported */ + G_DBUS_ERROR_LIMITS_EXCEEDED, /* org.freedesktop.DBus.Error.LimitsExceeded */ + G_DBUS_ERROR_ACCESS_DENIED, /* org.freedesktop.DBus.Error.AccessDenied */ + G_DBUS_ERROR_AUTH_FAILED, /* org.freedesktop.DBus.Error.AuthFailed */ + G_DBUS_ERROR_NO_SERVER, /* org.freedesktop.DBus.Error.NoServer */ + G_DBUS_ERROR_TIMEOUT, /* org.freedesktop.DBus.Error.Timeout */ + G_DBUS_ERROR_NO_NETWORK, /* org.freedesktop.DBus.Error.NoNetwork */ + G_DBUS_ERROR_ADDRESS_IN_USE, /* org.freedesktop.DBus.Error.AddressInUse */ + G_DBUS_ERROR_DISCONNECTED, /* org.freedesktop.DBus.Error.Disconnected */ + G_DBUS_ERROR_INVALID_ARGS, /* org.freedesktop.DBus.Error.InvalidArgs */ + G_DBUS_ERROR_FILE_NOT_FOUND, /* org.freedesktop.DBus.Error.FileNotFound */ + G_DBUS_ERROR_FILE_EXISTS, /* org.freedesktop.DBus.Error.FileExists */ + G_DBUS_ERROR_UNKNOWN_METHOD, /* org.freedesktop.DBus.Error.UnknownMethod */ + G_DBUS_ERROR_TIMED_OUT, /* org.freedesktop.DBus.Error.TimedOut */ + G_DBUS_ERROR_MATCH_RULE_NOT_FOUND, /* org.freedesktop.DBus.Error.MatchRuleNotFound */ + G_DBUS_ERROR_MATCH_RULE_INVALID, /* org.freedesktop.DBus.Error.MatchRuleInvalid */ + G_DBUS_ERROR_SPAWN_EXEC_FAILED, /* org.freedesktop.DBus.Error.Spawn.ExecFailed */ + G_DBUS_ERROR_SPAWN_FORK_FAILED, /* org.freedesktop.DBus.Error.Spawn.ForkFailed */ + G_DBUS_ERROR_SPAWN_CHILD_EXITED, /* org.freedesktop.DBus.Error.Spawn.ChildExited */ + G_DBUS_ERROR_SPAWN_CHILD_SIGNALED, /* org.freedesktop.DBus.Error.Spawn.ChildSignaled */ + G_DBUS_ERROR_SPAWN_FAILED, /* org.freedesktop.DBus.Error.Spawn.Failed */ + G_DBUS_ERROR_SPAWN_SETUP_FAILED, /* org.freedesktop.DBus.Error.Spawn.FailedToSetup */ + G_DBUS_ERROR_SPAWN_CONFIG_INVALID, /* org.freedesktop.DBus.Error.Spawn.ConfigInvalid */ + G_DBUS_ERROR_SPAWN_SERVICE_INVALID, /* org.freedesktop.DBus.Error.Spawn.ServiceNotValid */ + G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND, /* org.freedesktop.DBus.Error.Spawn.ServiceNotFound */ + G_DBUS_ERROR_SPAWN_PERMISSIONS_INVALID, /* org.freedesktop.DBus.Error.Spawn.PermissionsInvalid */ + G_DBUS_ERROR_SPAWN_FILE_INVALID, /* org.freedesktop.DBus.Error.Spawn.FileInvalid */ + G_DBUS_ERROR_SPAWN_NO_MEMORY, /* org.freedesktop.DBus.Error.Spawn.NoMemory */ + G_DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN, /* org.freedesktop.DBus.Error.UnixProcessIdUnknown */ + G_DBUS_ERROR_INVALID_SIGNATURE, /* org.freedesktop.DBus.Error.InvalidSignature */ + G_DBUS_ERROR_INVALID_FILE_CONTENT, /* org.freedesktop.DBus.Error.InvalidFileContent */ + G_DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN, /* org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown */ + G_DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN, /* org.freedesktop.DBus.Error.AdtAuditDataUnknown */ + G_DBUS_ERROR_OBJECT_PATH_IN_USE, /* org.freedesktop.DBus.Error.ObjectPathInUse */ + G_DBUS_ERROR_UNKNOWN_OBJECT, /* org.freedesktop.DBus.Error.UnknownObject */ + G_DBUS_ERROR_UNKNOWN_INTERFACE, /* org.freedesktop.DBus.Error.UnknownInterface */ + G_DBUS_ERROR_UNKNOWN_PROPERTY, /* org.freedesktop.DBus.Error.UnknownProperty */ + G_DBUS_ERROR_PROPERTY_READ_ONLY /* org.freedesktop.DBus.Error.PropertyReadOnly */ +} GDBusError; +/* Remember to update g_dbus_error_quark() in gdbuserror.c if you extend this enumeration */ + +/** + * GDBusConnectionFlags: + * @G_DBUS_CONNECTION_FLAGS_NONE: No flags set. + * @G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT: Perform authentication against server. + * @G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER: Perform authentication against client. + * @G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS: When + * authenticating as a server, allow the anonymous authentication + * method. + * @G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION: Pass this flag if connecting to a peer that is a + * message bus. This means that the Hello() method will be invoked as part of the connection setup. + * @G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING: If set, processing of D-Bus messages is + * delayed until g_dbus_connection_start_message_processing() is called. + * @G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER: When authenticating + * as a server, require the UID of the peer to be the same as the UID of the server. (Since: 2.68) + * @G_DBUS_CONNECTION_FLAGS_CROSS_NAMESPACE: When authenticating, try to use + * protocols that work across a Linux user namespace boundary, even if this + * reduces interoperability with older D-Bus implementations. This currently + * affects client-side `EXTERNAL` authentication, for which this flag makes + * connections to a server in another user namespace succeed, but causes + * a deadlock when connecting to a GDBus server older than 2.73.3. Since: 2.74 + * + * Flags used when creating a new #GDBusConnection. + * + * Since: 2.26 + */ +typedef enum { + G_DBUS_CONNECTION_FLAGS_NONE = 0, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT = (1<<0), + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER = (1<<1), + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS = (1<<2), + G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION = (1<<3), + G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING = (1<<4), + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER GIO_AVAILABLE_ENUMERATOR_IN_2_68 = (1<<5), + G_DBUS_CONNECTION_FLAGS_CROSS_NAMESPACE GIO_AVAILABLE_ENUMERATOR_IN_2_74 = (1<<6) +} GDBusConnectionFlags; + +/** + * GDBusCapabilityFlags: + * @G_DBUS_CAPABILITY_FLAGS_NONE: No flags set. + * @G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING: The connection + * supports exchanging UNIX file descriptors with the remote peer. + * + * Capabilities negotiated with the remote peer. + * + * Since: 2.26 + */ +typedef enum { + G_DBUS_CAPABILITY_FLAGS_NONE = 0, + G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING = (1<<0) +} GDBusCapabilityFlags; + +/** + * GDBusCallFlags: + * @G_DBUS_CALL_FLAGS_NONE: No flags set. + * @G_DBUS_CALL_FLAGS_NO_AUTO_START: The bus must not launch + * an owner for the destination name in response to this method + * invocation. + * @G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION: the caller is prepared to + * wait for interactive authorization. Since 2.46. + * + * Flags used in g_dbus_connection_call() and similar APIs. + * + * Since: 2.26 + */ +typedef enum { + G_DBUS_CALL_FLAGS_NONE = 0, + G_DBUS_CALL_FLAGS_NO_AUTO_START = (1<<0), + G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION = (1<<1) +} GDBusCallFlags; +/* (1<<31) is reserved for internal use by GDBusConnection, do not use it. */ + +/** + * GDBusMessageType: + * @G_DBUS_MESSAGE_TYPE_INVALID: Message is of invalid type. + * @G_DBUS_MESSAGE_TYPE_METHOD_CALL: Method call. + * @G_DBUS_MESSAGE_TYPE_METHOD_RETURN: Method reply. + * @G_DBUS_MESSAGE_TYPE_ERROR: Error reply. + * @G_DBUS_MESSAGE_TYPE_SIGNAL: Signal emission. + * + * Message types used in #GDBusMessage. + * + * Since: 2.26 + */ +typedef enum { + G_DBUS_MESSAGE_TYPE_INVALID, + G_DBUS_MESSAGE_TYPE_METHOD_CALL, + G_DBUS_MESSAGE_TYPE_METHOD_RETURN, + G_DBUS_MESSAGE_TYPE_ERROR, + G_DBUS_MESSAGE_TYPE_SIGNAL +} GDBusMessageType; + +/** + * GDBusMessageFlags: + * @G_DBUS_MESSAGE_FLAGS_NONE: No flags set. + * @G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED: A reply is not expected. + * @G_DBUS_MESSAGE_FLAGS_NO_AUTO_START: The bus must not launch an + * owner for the destination name in response to this message. + * @G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION: If set on a method + * call, this flag means that the caller is prepared to wait for interactive + * authorization. Since 2.46. + * + * Message flags used in #GDBusMessage. + * + * Since: 2.26 + */ +typedef enum { + G_DBUS_MESSAGE_FLAGS_NONE = 0, + G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED = (1<<0), + G_DBUS_MESSAGE_FLAGS_NO_AUTO_START = (1<<1), + G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION = (1<<2) +} GDBusMessageFlags; + +/** + * GDBusMessageHeaderField: + * @G_DBUS_MESSAGE_HEADER_FIELD_INVALID: Not a valid header field. + * @G_DBUS_MESSAGE_HEADER_FIELD_PATH: The object path. + * @G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE: The interface name. + * @G_DBUS_MESSAGE_HEADER_FIELD_MEMBER: The method or signal name. + * @G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME: The name of the error that occurred. + * @G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL: The serial number the message is a reply to. + * @G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION: The name the message is intended for. + * @G_DBUS_MESSAGE_HEADER_FIELD_SENDER: Unique name of the sender of the message (filled in by the bus). + * @G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE: The signature of the message body. + * @G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS: The number of UNIX file descriptors that accompany the message. + * + * Header fields used in #GDBusMessage. + * + * Since: 2.26 + */ +typedef enum { + G_DBUS_MESSAGE_HEADER_FIELD_INVALID, + G_DBUS_MESSAGE_HEADER_FIELD_PATH, + G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE, + G_DBUS_MESSAGE_HEADER_FIELD_MEMBER, + G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME, + G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL, + G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION, + G_DBUS_MESSAGE_HEADER_FIELD_SENDER, + G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE, + G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS +} GDBusMessageHeaderField; + +/** + * GDBusPropertyInfoFlags: + * @G_DBUS_PROPERTY_INFO_FLAGS_NONE: No flags set. + * @G_DBUS_PROPERTY_INFO_FLAGS_READABLE: Property is readable. + * @G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE: Property is writable. + * + * Flags describing the access control of a D-Bus property. + * + * Since: 2.26 + */ +typedef enum +{ + G_DBUS_PROPERTY_INFO_FLAGS_NONE = 0, + G_DBUS_PROPERTY_INFO_FLAGS_READABLE = (1<<0), + G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE = (1<<1) +} GDBusPropertyInfoFlags; + +/** + * GDBusSubtreeFlags: + * @G_DBUS_SUBTREE_FLAGS_NONE: No flags set. + * @G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES: Method calls to objects not in the enumerated range + * will still be dispatched. This is useful if you want + * to dynamically spawn objects in the subtree. + * + * Flags passed to g_dbus_connection_register_subtree(). + * + * Since: 2.26 + */ +typedef enum +{ + G_DBUS_SUBTREE_FLAGS_NONE = 0, + G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES = (1<<0) +} GDBusSubtreeFlags; + +/** + * GDBusServerFlags: + * @G_DBUS_SERVER_FLAGS_NONE: No flags set. + * @G_DBUS_SERVER_FLAGS_RUN_IN_THREAD: All #GDBusServer::new-connection + * signals will run in separated dedicated threads (see signal for + * details). + * @G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS: Allow the anonymous + * authentication method. + * @G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER: Require the UID of the + * peer to be the same as the UID of the server when authenticating. (Since: 2.68) + * + * Flags used when creating a #GDBusServer. + * + * Since: 2.26 + */ +typedef enum +{ + G_DBUS_SERVER_FLAGS_NONE = 0, + G_DBUS_SERVER_FLAGS_RUN_IN_THREAD = (1<<0), + G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS = (1<<1), + G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER GIO_AVAILABLE_ENUMERATOR_IN_2_68 = (1<<2) +} GDBusServerFlags; + +/** + * GDBusSignalFlags: + * @G_DBUS_SIGNAL_FLAGS_NONE: No flags set. + * @G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE: Don't actually send the AddMatch + * D-Bus call for this signal subscription. This gives you more control + * over which match rules you add (but you must add them manually). + * @G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE: Match first arguments that + * contain a bus or interface name with the given namespace. + * @G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH: Match first arguments that + * contain an object path that is either equivalent to the given path, + * or one of the paths is a subpath of the other. + * + * Flags used when subscribing to signals via g_dbus_connection_signal_subscribe(). + * + * Since: 2.26 + */ +typedef enum /*< flags >*/ +{ + G_DBUS_SIGNAL_FLAGS_NONE = 0, + G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE = (1<<0), + G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE = (1<<1), + G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH = (1<<2) +} GDBusSignalFlags; + +/** + * GDBusSendMessageFlags: + * @G_DBUS_SEND_MESSAGE_FLAGS_NONE: No flags set. + * @G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL: Do not automatically + * assign a serial number from the #GDBusConnection object when + * sending a message. + * + * Flags used when sending #GDBusMessages on a #GDBusConnection. + * + * Since: 2.26 + */ +typedef enum +{ + G_DBUS_SEND_MESSAGE_FLAGS_NONE = 0, + G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL = (1<<0) +} GDBusSendMessageFlags; +/* (1<<31) is reserved for internal use by GDBusConnection, do not use it. */ + +/** + * GCredentialsType: + * @G_CREDENTIALS_TYPE_INVALID: Indicates an invalid native credential type. + * @G_CREDENTIALS_TYPE_LINUX_UCRED: The native credentials type is a `struct ucred`. + * @G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED: The native credentials type is a `struct cmsgcred`. + * @G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED: The native credentials type is a `struct sockpeercred`. Added in 2.30. + * @G_CREDENTIALS_TYPE_SOLARIS_UCRED: The native credentials type is a `ucred_t`. Added in 2.40. + * @G_CREDENTIALS_TYPE_NETBSD_UNPCBID: The native credentials type is a `struct unpcbid`. Added in 2.42. + * @G_CREDENTIALS_TYPE_APPLE_XUCRED: The native credentials type is a `struct xucred`. Added in 2.66. + * @G_CREDENTIALS_TYPE_WIN32_PID: The native credentials type is a PID `DWORD`. Added in 2.72. + * + * Enumeration describing different kinds of native credential types. + * + * Since: 2.26 + */ +typedef enum +{ + G_CREDENTIALS_TYPE_INVALID, + G_CREDENTIALS_TYPE_LINUX_UCRED, + G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED, + G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED, + G_CREDENTIALS_TYPE_SOLARIS_UCRED, + G_CREDENTIALS_TYPE_NETBSD_UNPCBID, + G_CREDENTIALS_TYPE_APPLE_XUCRED, + G_CREDENTIALS_TYPE_WIN32_PID, +} GCredentialsType; + +/** + * GDBusMessageByteOrder: + * @G_DBUS_MESSAGE_BYTE_ORDER_BIG_ENDIAN: The byte order is big endian. + * @G_DBUS_MESSAGE_BYTE_ORDER_LITTLE_ENDIAN: The byte order is little endian. + * + * Enumeration used to describe the byte order of a D-Bus message. + * + * Since: 2.26 + */ +typedef enum +{ + G_DBUS_MESSAGE_BYTE_ORDER_BIG_ENDIAN = 'B', + G_DBUS_MESSAGE_BYTE_ORDER_LITTLE_ENDIAN = 'l' +} GDBusMessageByteOrder; + +/** + * GApplicationFlags: + * @G_APPLICATION_IS_SERVICE: Run as a service. In this mode, registration + * fails if the service is already running, and the application + * will initially wait up to 10 seconds for an initial activation + * message to arrive. + * @G_APPLICATION_IS_LAUNCHER: Don't try to become the primary instance. + * @G_APPLICATION_HANDLES_OPEN: This application handles opening files (in + * the primary instance). Note that this flag only affects the default + * implementation of local_command_line(), and has no effect if + * %G_APPLICATION_HANDLES_COMMAND_LINE is given. + * See g_application_run() for details. + * @G_APPLICATION_HANDLES_COMMAND_LINE: This application handles command line + * arguments (in the primary instance). Note that this flag only affect + * the default implementation of local_command_line(). + * See g_application_run() for details. + * @G_APPLICATION_SEND_ENVIRONMENT: Send the environment of the + * launching process to the primary instance. Set this flag if your + * application is expected to behave differently depending on certain + * environment variables. For instance, an editor might be expected + * to use the `GIT_COMMITTER_NAME` environment variable + * when editing a git commit message. The environment is available + * to the #GApplication::command-line signal handler, via + * g_application_command_line_getenv(). + * @G_APPLICATION_NON_UNIQUE: Make no attempts to do any of the typical + * single-instance application negotiation, even if the application + * ID is given. The application neither attempts to become the + * owner of the application ID nor does it check if an existing + * owner already exists. Everything occurs in the local process. + * Since: 2.30. + * @G_APPLICATION_CAN_OVERRIDE_APP_ID: Allow users to override the + * application ID from the command line with `--gapplication-app-id`. + * Since: 2.48 + * @G_APPLICATION_ALLOW_REPLACEMENT: Allow another instance to take over + * the bus name. Since: 2.60 + * @G_APPLICATION_REPLACE: Take over from another instance. This flag is + * usually set by passing `--gapplication-replace` on the commandline. + * Since: 2.60 + * + * Flags used to define the behaviour of a #GApplication. + * + * Since: 2.28 + **/ +/** + * G_APPLICATION_FLAGS_NONE: + * + * Default flags. + * + * Deprecated: 2.74: Use [flags@Gio.ApplicationFlags.DEFAULT_FLAGS]. + **/ +/** + * G_APPLICATION_DEFAULT_FLAGS: + * + * Default flags. + * + * Since: 2.74 + **/ +typedef enum /*< prefix=G_APPLICATION >*/ +{ + G_APPLICATION_FLAGS_NONE GIO_DEPRECATED_ENUMERATOR_IN_2_74_FOR(G_APPLICATION_DEFAULT_FLAGS), + G_APPLICATION_DEFAULT_FLAGS GIO_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_APPLICATION_IS_SERVICE = (1 << 0), + G_APPLICATION_IS_LAUNCHER = (1 << 1), + + G_APPLICATION_HANDLES_OPEN = (1 << 2), + G_APPLICATION_HANDLES_COMMAND_LINE = (1 << 3), + G_APPLICATION_SEND_ENVIRONMENT = (1 << 4), + + G_APPLICATION_NON_UNIQUE = (1 << 5), + + G_APPLICATION_CAN_OVERRIDE_APP_ID = (1 << 6), + G_APPLICATION_ALLOW_REPLACEMENT = (1 << 7), + G_APPLICATION_REPLACE = (1 << 8) +} GApplicationFlags; + +/** + * GTlsError: + * @G_TLS_ERROR_UNAVAILABLE: No TLS provider is available + * @G_TLS_ERROR_MISC: Miscellaneous TLS error + * @G_TLS_ERROR_BAD_CERTIFICATE: The certificate presented could not + * be parsed or failed validation. + * @G_TLS_ERROR_NOT_TLS: The TLS handshake failed because the + * peer does not seem to be a TLS server. + * @G_TLS_ERROR_HANDSHAKE: The TLS handshake failed because the + * peer's certificate was not acceptable. + * @G_TLS_ERROR_CERTIFICATE_REQUIRED: The TLS handshake failed because + * the server requested a client-side certificate, but none was + * provided. See g_tls_connection_set_certificate(). + * @G_TLS_ERROR_EOF: The TLS connection was closed without proper + * notice, which may indicate an attack. See + * g_tls_connection_set_require_close_notify(). + * @G_TLS_ERROR_INAPPROPRIATE_FALLBACK: The TLS handshake failed + * because the client sent the fallback SCSV, indicating a protocol + * downgrade attack. Since: 2.60 + * @G_TLS_ERROR_BAD_CERTIFICATE_PASSWORD: The certificate failed + * to load because a password was incorrect. Since: 2.72 + * + * An error code used with %G_TLS_ERROR in a #GError returned from a + * TLS-related routine. + * + * Since: 2.28 + */ +typedef enum { + G_TLS_ERROR_UNAVAILABLE, + G_TLS_ERROR_MISC, + G_TLS_ERROR_BAD_CERTIFICATE, + G_TLS_ERROR_NOT_TLS, + G_TLS_ERROR_HANDSHAKE, + G_TLS_ERROR_CERTIFICATE_REQUIRED, + G_TLS_ERROR_EOF, + G_TLS_ERROR_INAPPROPRIATE_FALLBACK, + G_TLS_ERROR_BAD_CERTIFICATE_PASSWORD +} GTlsError; + +/** + * GTlsCertificateFlags: + * @G_TLS_CERTIFICATE_NO_FLAGS: No flags set. Since: 2.74 + * @G_TLS_CERTIFICATE_UNKNOWN_CA: The signing certificate authority is + * not known. + * @G_TLS_CERTIFICATE_BAD_IDENTITY: The certificate does not match the + * expected identity of the site that it was retrieved from. + * @G_TLS_CERTIFICATE_NOT_ACTIVATED: The certificate's activation time + * is still in the future + * @G_TLS_CERTIFICATE_EXPIRED: The certificate has expired + * @G_TLS_CERTIFICATE_REVOKED: The certificate has been revoked + * according to the #GTlsConnection's certificate revocation list. + * @G_TLS_CERTIFICATE_INSECURE: The certificate's algorithm is + * considered insecure. + * @G_TLS_CERTIFICATE_GENERIC_ERROR: Some other error occurred validating + * the certificate + * @G_TLS_CERTIFICATE_VALIDATE_ALL: the combination of all of the above + * flags + * + * A set of flags describing TLS certification validation. This can be + * used to describe why a particular certificate was rejected (for + * example, in #GTlsConnection::accept-certificate). + * + * GLib guarantees that if certificate verification fails, at least one + * flag will be set, but it does not guarantee that all possible flags + * will be set. Accordingly, you may not safely decide to ignore any + * particular type of error. For example, it would be incorrect to mask + * %G_TLS_CERTIFICATE_EXPIRED if you want to allow expired certificates, + * because this could potentially be the only error flag set even if + * other problems exist with the certificate. + * + * Since: 2.28 + */ +typedef enum { + G_TLS_CERTIFICATE_NO_FLAGS GIO_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_TLS_CERTIFICATE_UNKNOWN_CA = (1 << 0), + G_TLS_CERTIFICATE_BAD_IDENTITY = (1 << 1), + G_TLS_CERTIFICATE_NOT_ACTIVATED = (1 << 2), + G_TLS_CERTIFICATE_EXPIRED = (1 << 3), + G_TLS_CERTIFICATE_REVOKED = (1 << 4), + G_TLS_CERTIFICATE_INSECURE = (1 << 5), + G_TLS_CERTIFICATE_GENERIC_ERROR = (1 << 6), + + G_TLS_CERTIFICATE_VALIDATE_ALL = 0x007f +} GTlsCertificateFlags; + +/** + * GTlsAuthenticationMode: + * @G_TLS_AUTHENTICATION_NONE: client authentication not required + * @G_TLS_AUTHENTICATION_REQUESTED: client authentication is requested + * @G_TLS_AUTHENTICATION_REQUIRED: client authentication is required + * + * The client authentication mode for a #GTlsServerConnection. + * + * Since: 2.28 + */ +typedef enum { + G_TLS_AUTHENTICATION_NONE, + G_TLS_AUTHENTICATION_REQUESTED, + G_TLS_AUTHENTICATION_REQUIRED +} GTlsAuthenticationMode; + +/** + * GTlsChannelBindingType: + * @G_TLS_CHANNEL_BINDING_TLS_UNIQUE: + * [`tls-unique`](https://tools.ietf.org/html/rfc5929#section-3) binding + * type + * @G_TLS_CHANNEL_BINDING_TLS_SERVER_END_POINT: + * [`tls-server-end-point`](https://tools.ietf.org/html/rfc5929#section-4) + * binding type + * @G_TLS_CHANNEL_BINDING_TLS_EXPORTER: + * [`tls-exporter`](https://www.rfc-editor.org/rfc/rfc9266.html) binding + * type. Since: 2.74 + * + * The type of TLS channel binding data to retrieve from #GTlsConnection + * or #GDtlsConnection, as documented by RFC 5929 or RFC 9266. The + * [`tls-unique-for-telnet`](https://tools.ietf.org/html/rfc5929#section-5) + * binding type is not currently implemented. + * + * Since: 2.66 + */ +GIO_AVAILABLE_TYPE_IN_2_66 +typedef enum { + G_TLS_CHANNEL_BINDING_TLS_UNIQUE, + G_TLS_CHANNEL_BINDING_TLS_SERVER_END_POINT, + G_TLS_CHANNEL_BINDING_TLS_EXPORTER GIO_AVAILABLE_ENUMERATOR_IN_2_74, +} GTlsChannelBindingType; + +/** + * GTlsChannelBindingError: + * @G_TLS_CHANNEL_BINDING_ERROR_NOT_IMPLEMENTED: Either entire binding + * retrieval facility or specific binding type is not implemented in the + * TLS backend. + * @G_TLS_CHANNEL_BINDING_ERROR_INVALID_STATE: The handshake is not yet + * complete on the connection which is a strong requirement for any existing + * binding type. + * @G_TLS_CHANNEL_BINDING_ERROR_NOT_AVAILABLE: Handshake is complete but + * binding data is not available. That normally indicates the TLS + * implementation failed to provide the binding data. For example, some + * implementations do not provide a peer certificate for resumed connections. + * @G_TLS_CHANNEL_BINDING_ERROR_NOT_SUPPORTED: Binding type is not supported + * on the current connection. This error could be triggered when requesting + * `tls-server-end-point` binding data for a certificate which has no hash + * function or uses multiple hash functions. + * @G_TLS_CHANNEL_BINDING_ERROR_GENERAL_ERROR: Any other backend error + * preventing binding data retrieval. + * + * An error code used with %G_TLS_CHANNEL_BINDING_ERROR in a #GError to + * indicate a TLS channel binding retrieval error. + * + * Since: 2.66 + */ +GIO_AVAILABLE_TYPE_IN_2_66 +typedef enum { + G_TLS_CHANNEL_BINDING_ERROR_NOT_IMPLEMENTED, + G_TLS_CHANNEL_BINDING_ERROR_INVALID_STATE, + G_TLS_CHANNEL_BINDING_ERROR_NOT_AVAILABLE, + G_TLS_CHANNEL_BINDING_ERROR_NOT_SUPPORTED, + G_TLS_CHANNEL_BINDING_ERROR_GENERAL_ERROR +} GTlsChannelBindingError; + +/** + * GTlsRehandshakeMode: + * @G_TLS_REHANDSHAKE_NEVER: Never allow rehandshaking + * @G_TLS_REHANDSHAKE_SAFELY: Allow safe rehandshaking only + * @G_TLS_REHANDSHAKE_UNSAFELY: Allow unsafe rehandshaking + * + * When to allow rehandshaking. See + * g_tls_connection_set_rehandshake_mode(). + * + * Since: 2.28 + * + * Deprecated: 2.60. Changing the rehandshake mode is no longer + * required for compatibility. Also, rehandshaking has been removed + * from the TLS protocol in TLS 1.3. + */ +typedef enum { + G_TLS_REHANDSHAKE_NEVER, + G_TLS_REHANDSHAKE_SAFELY, + G_TLS_REHANDSHAKE_UNSAFELY +} GTlsRehandshakeMode GIO_DEPRECATED_TYPE_IN_2_60; + +/** + * GTlsPasswordFlags: + * @G_TLS_PASSWORD_NONE: No flags + * @G_TLS_PASSWORD_RETRY: The password was wrong, and the user should retry. + * @G_TLS_PASSWORD_MANY_TRIES: Hint to the user that the password has been + * wrong many times, and the user may not have many chances left. + * @G_TLS_PASSWORD_FINAL_TRY: Hint to the user that this is the last try to get + * this password right. + * @G_TLS_PASSWORD_PKCS11_USER: For PKCS #11, the user PIN is required. + * Since: 2.70. + * @G_TLS_PASSWORD_PKCS11_SECURITY_OFFICER: For PKCS #11, the security officer + * PIN is required. Since: 2.70. + * @G_TLS_PASSWORD_PKCS11_CONTEXT_SPECIFIC: For PKCS #11, the context-specific + * PIN is required. Since: 2.70. + * + * Various flags for the password. + * + * Since: 2.30 + */ + +typedef enum _GTlsPasswordFlags +{ + G_TLS_PASSWORD_NONE = 0, + G_TLS_PASSWORD_RETRY = 1 << 1, + G_TLS_PASSWORD_MANY_TRIES = 1 << 2, + G_TLS_PASSWORD_FINAL_TRY = 1 << 3, + G_TLS_PASSWORD_PKCS11_USER = 1 << 4, + G_TLS_PASSWORD_PKCS11_SECURITY_OFFICER = 1 << 5, + G_TLS_PASSWORD_PKCS11_CONTEXT_SPECIFIC = 1 << 6 +} GTlsPasswordFlags; + +/** + * GTlsInteractionResult: + * @G_TLS_INTERACTION_UNHANDLED: The interaction was unhandled (i.e. not + * implemented). + * @G_TLS_INTERACTION_HANDLED: The interaction completed, and resulting data + * is available. + * @G_TLS_INTERACTION_FAILED: The interaction has failed, or was cancelled. + * and the operation should be aborted. + * + * #GTlsInteractionResult is returned by various functions in #GTlsInteraction + * when finishing an interaction request. + * + * Since: 2.30 + */ +typedef enum { + G_TLS_INTERACTION_UNHANDLED, + G_TLS_INTERACTION_HANDLED, + G_TLS_INTERACTION_FAILED +} GTlsInteractionResult; + +/** + * GDBusInterfaceSkeletonFlags: + * @G_DBUS_INTERFACE_SKELETON_FLAGS_NONE: No flags set. + * @G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD: Each method invocation is handled in + * a thread dedicated to the invocation. This means that the method implementation can use blocking IO + * without blocking any other part of the process. It also means that the method implementation must + * use locking to access data structures used by other threads. + * + * Flags describing the behavior of a #GDBusInterfaceSkeleton instance. + * + * Since: 2.30 + */ +typedef enum +{ + G_DBUS_INTERFACE_SKELETON_FLAGS_NONE = 0, + G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD = (1<<0) +} GDBusInterfaceSkeletonFlags; + +/** + * GDBusObjectManagerClientFlags: + * @G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE: No flags set. + * @G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START: If not set and the + * manager is for a well-known name, then request the bus to launch + * an owner for the name if no-one owns the name. This flag can only + * be used in managers for well-known names. + * + * Flags used when constructing a #GDBusObjectManagerClient. + * + * Since: 2.30 + */ +typedef enum +{ + G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE = 0, + G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START = (1<<0) +} GDBusObjectManagerClientFlags; + +/** + * GTlsDatabaseVerifyFlags: + * @G_TLS_DATABASE_VERIFY_NONE: No verification flags + * + * Flags for g_tls_database_verify_chain(). + * + * Since: 2.30 + */ +typedef enum /*< flags >*/ { + G_TLS_DATABASE_VERIFY_NONE = 0 +} GTlsDatabaseVerifyFlags; + +/** + * GTlsDatabaseLookupFlags: + * @G_TLS_DATABASE_LOOKUP_NONE: No lookup flags + * @G_TLS_DATABASE_LOOKUP_KEYPAIR: Restrict lookup to certificates that have + * a private key. + * + * Flags for g_tls_database_lookup_certificate_for_handle(), + * g_tls_database_lookup_certificate_issuer(), + * and g_tls_database_lookup_certificates_issued_by(). + * + * Since: 2.30 + */ +typedef enum { + G_TLS_DATABASE_LOOKUP_NONE = 0, + G_TLS_DATABASE_LOOKUP_KEYPAIR = 1 +} GTlsDatabaseLookupFlags; + +/** + * GTlsCertificateRequestFlags: + * @G_TLS_CERTIFICATE_REQUEST_NONE: No flags + * + * Flags for g_tls_interaction_request_certificate(), + * g_tls_interaction_request_certificate_async(), and + * g_tls_interaction_invoke_request_certificate(). + * + * Since: 2.40 + */ +typedef enum { + G_TLS_CERTIFICATE_REQUEST_NONE = 0 +} GTlsCertificateRequestFlags; + +/** + * GTlsProtocolVersion: + * @G_TLS_PROTOCOL_VERSION_UNKNOWN: No protocol version or unknown protocol version + * @G_TLS_PROTOCOL_VERSION_SSL_3_0: SSL 3.0, which is insecure and should not be used + * @G_TLS_PROTOCOL_VERSION_TLS_1_0: TLS 1.0, which is insecure and should not be used + * @G_TLS_PROTOCOL_VERSION_TLS_1_1: TLS 1.1, which is insecure and should not be used + * @G_TLS_PROTOCOL_VERSION_TLS_1_2: TLS 1.2, defined by [RFC 5246](https://datatracker.ietf.org/doc/html/rfc5246) + * @G_TLS_PROTOCOL_VERSION_TLS_1_3: TLS 1.3, defined by [RFC 8446](https://datatracker.ietf.org/doc/html/rfc8446) + * @G_TLS_PROTOCOL_VERSION_DTLS_1_0: DTLS 1.0, which is insecure and should not be used + * @G_TLS_PROTOCOL_VERSION_DTLS_1_2: DTLS 1.2, defined by [RFC 6347](https://datatracker.ietf.org/doc/html/rfc6347) + * + * The TLS or DTLS protocol version used by a #GTlsConnection or + * #GDtlsConnection. The integer values of these versions are sequential + * to ensure newer known protocol versions compare greater than older + * known versions. Any known DTLS protocol version will compare greater + * than any SSL or TLS protocol version. The protocol version may be + * %G_TLS_PROTOCOL_VERSION_UNKNOWN if the TLS backend supports a newer + * protocol version that GLib does not yet know about. This means that + * it's possible for an unknown DTLS protocol version to compare less + * than the TLS protocol versions. + * + * Since: 2.70 + */ +typedef enum { + G_TLS_PROTOCOL_VERSION_UNKNOWN = 0, + G_TLS_PROTOCOL_VERSION_SSL_3_0 = 1, + G_TLS_PROTOCOL_VERSION_TLS_1_0 = 2, + G_TLS_PROTOCOL_VERSION_TLS_1_1 = 3, + G_TLS_PROTOCOL_VERSION_TLS_1_2 = 4, + G_TLS_PROTOCOL_VERSION_TLS_1_3 = 5, + G_TLS_PROTOCOL_VERSION_DTLS_1_0 = 201, + G_TLS_PROTOCOL_VERSION_DTLS_1_2 = 202, +} GTlsProtocolVersion; + +/** + * GIOModuleScopeFlags: + * @G_IO_MODULE_SCOPE_NONE: No module scan flags + * @G_IO_MODULE_SCOPE_BLOCK_DUPLICATES: When using this scope to load or + * scan modules, automatically block a modules which has the same base + * basename as previously loaded module. + * + * Flags for use with g_io_module_scope_new(). + * + * Since: 2.30 + */ +typedef enum { + G_IO_MODULE_SCOPE_NONE, + G_IO_MODULE_SCOPE_BLOCK_DUPLICATES +} GIOModuleScopeFlags; + +/** + * GSocketClientEvent: + * @G_SOCKET_CLIENT_RESOLVING: The client is doing a DNS lookup. + * @G_SOCKET_CLIENT_RESOLVED: The client has completed a DNS lookup. + * @G_SOCKET_CLIENT_CONNECTING: The client is connecting to a remote + * host (either a proxy or the destination server). + * @G_SOCKET_CLIENT_CONNECTED: The client has connected to a remote + * host. + * @G_SOCKET_CLIENT_PROXY_NEGOTIATING: The client is negotiating + * with a proxy to connect to the destination server. + * @G_SOCKET_CLIENT_PROXY_NEGOTIATED: The client has negotiated + * with the proxy server. + * @G_SOCKET_CLIENT_TLS_HANDSHAKING: The client is performing a + * TLS handshake. + * @G_SOCKET_CLIENT_TLS_HANDSHAKED: The client has performed a + * TLS handshake. + * @G_SOCKET_CLIENT_COMPLETE: The client is done with a particular + * #GSocketConnectable. + * + * Describes an event occurring on a #GSocketClient. See the + * #GSocketClient::event signal for more details. + * + * Additional values may be added to this type in the future. + * + * Since: 2.32 + */ +typedef enum { + G_SOCKET_CLIENT_RESOLVING, + G_SOCKET_CLIENT_RESOLVED, + G_SOCKET_CLIENT_CONNECTING, + G_SOCKET_CLIENT_CONNECTED, + G_SOCKET_CLIENT_PROXY_NEGOTIATING, + G_SOCKET_CLIENT_PROXY_NEGOTIATED, + G_SOCKET_CLIENT_TLS_HANDSHAKING, + G_SOCKET_CLIENT_TLS_HANDSHAKED, + G_SOCKET_CLIENT_COMPLETE +} GSocketClientEvent; + +/** + * GSocketListenerEvent: + * @G_SOCKET_LISTENER_BINDING: The listener is about to bind a socket. + * @G_SOCKET_LISTENER_BOUND: The listener has bound a socket. + * @G_SOCKET_LISTENER_LISTENING: The listener is about to start + * listening on this socket. + * @G_SOCKET_LISTENER_LISTENED: The listener is now listening on + * this socket. + * + * Describes an event occurring on a #GSocketListener. See the + * #GSocketListener::event signal for more details. + * + * Additional values may be added to this type in the future. + * + * Since: 2.46 + */ +typedef enum { + G_SOCKET_LISTENER_BINDING, + G_SOCKET_LISTENER_BOUND, + G_SOCKET_LISTENER_LISTENING, + G_SOCKET_LISTENER_LISTENED +} GSocketListenerEvent; + +/** + * GTestDBusFlags: + * @G_TEST_DBUS_NONE: No flags. + * + * Flags to define future #GTestDBus behaviour. + * + * Since: 2.34 + */ +typedef enum /*< flags >*/ { + G_TEST_DBUS_NONE = 0 +} GTestDBusFlags; + +/** + * GSubprocessFlags: + * @G_SUBPROCESS_FLAGS_NONE: No flags. + * @G_SUBPROCESS_FLAGS_STDIN_PIPE: create a pipe for the stdin of the + * spawned process that can be accessed with + * g_subprocess_get_stdin_pipe(). + * @G_SUBPROCESS_FLAGS_STDIN_INHERIT: stdin is inherited from the + * calling process. + * @G_SUBPROCESS_FLAGS_STDOUT_PIPE: create a pipe for the stdout of the + * spawned process that can be accessed with + * g_subprocess_get_stdout_pipe(). + * @G_SUBPROCESS_FLAGS_STDOUT_SILENCE: silence the stdout of the spawned + * process (ie: redirect to `/dev/null`). + * @G_SUBPROCESS_FLAGS_STDERR_PIPE: create a pipe for the stderr of the + * spawned process that can be accessed with + * g_subprocess_get_stderr_pipe(). + * @G_SUBPROCESS_FLAGS_STDERR_SILENCE: silence the stderr of the spawned + * process (ie: redirect to `/dev/null`). + * @G_SUBPROCESS_FLAGS_STDERR_MERGE: merge the stderr of the spawned + * process with whatever the stdout happens to be. This is a good way + * of directing both streams to a common log file, for example. + * @G_SUBPROCESS_FLAGS_INHERIT_FDS: spawned processes will inherit the + * file descriptors of their parent, unless those descriptors have + * been explicitly marked as close-on-exec. This flag has no effect + * over the "standard" file descriptors (stdin, stdout, stderr). + * @G_SUBPROCESS_FLAGS_SEARCH_PATH_FROM_ENVP: if path searching is + * needed when spawning the subprocess, use the `PATH` in the launcher + * environment. (Since: 2.72) + * + * Flags to define the behaviour of a #GSubprocess. + * + * Note that the default for stdin is to redirect from `/dev/null`. For + * stdout and stderr the default are for them to inherit the + * corresponding descriptor from the calling process. + * + * Note that it is a programmer error to mix 'incompatible' flags. For + * example, you may not request both %G_SUBPROCESS_FLAGS_STDOUT_PIPE and + * %G_SUBPROCESS_FLAGS_STDOUT_SILENCE. + * + * Since: 2.40 + **/ +typedef enum { + G_SUBPROCESS_FLAGS_NONE = 0, + G_SUBPROCESS_FLAGS_STDIN_PIPE = (1u << 0), + G_SUBPROCESS_FLAGS_STDIN_INHERIT = (1u << 1), + G_SUBPROCESS_FLAGS_STDOUT_PIPE = (1u << 2), + G_SUBPROCESS_FLAGS_STDOUT_SILENCE = (1u << 3), + G_SUBPROCESS_FLAGS_STDERR_PIPE = (1u << 4), + G_SUBPROCESS_FLAGS_STDERR_SILENCE = (1u << 5), + G_SUBPROCESS_FLAGS_STDERR_MERGE = (1u << 6), + G_SUBPROCESS_FLAGS_INHERIT_FDS = (1u << 7), + G_SUBPROCESS_FLAGS_SEARCH_PATH_FROM_ENVP = (1u << 8) +} GSubprocessFlags; + +/** + * GNotificationPriority: + * @G_NOTIFICATION_PRIORITY_LOW: for notifications that do not require + * immediate attention - typically used for contextual background + * information, such as contact birthdays or local weather + * @G_NOTIFICATION_PRIORITY_NORMAL: the default priority, to be used for the + * majority of notifications (for example email messages, software updates, + * completed download/sync operations) + * @G_NOTIFICATION_PRIORITY_HIGH: for events that require more attention, + * usually because responses are time-sensitive (for example chat and SMS + * messages or alarms) + * @G_NOTIFICATION_PRIORITY_URGENT: for urgent notifications, or notifications + * that require a response in a short space of time (for example phone calls + * or emergency warnings) + * + * Priority levels for #GNotifications. + * + * Since: 2.42 + */ +typedef enum { + G_NOTIFICATION_PRIORITY_NORMAL, + G_NOTIFICATION_PRIORITY_LOW, + G_NOTIFICATION_PRIORITY_HIGH, + G_NOTIFICATION_PRIORITY_URGENT +} GNotificationPriority; + +/** + * GNetworkConnectivity: + * @G_NETWORK_CONNECTIVITY_LOCAL: The host is not configured with a + * route to the Internet; it may or may not be connected to a local + * network. + * @G_NETWORK_CONNECTIVITY_LIMITED: The host is connected to a network, but + * does not appear to be able to reach the full Internet, perhaps + * due to upstream network problems. + * @G_NETWORK_CONNECTIVITY_PORTAL: The host is behind a captive portal and + * cannot reach the full Internet. + * @G_NETWORK_CONNECTIVITY_FULL: The host is connected to a network, and + * appears to be able to reach the full Internet. + * + * The host's network connectivity state, as reported by #GNetworkMonitor. + * + * Since: 2.44 + */ +typedef enum { + G_NETWORK_CONNECTIVITY_LOCAL = 1, + G_NETWORK_CONNECTIVITY_LIMITED = 2, + G_NETWORK_CONNECTIVITY_PORTAL = 3, + G_NETWORK_CONNECTIVITY_FULL = 4 +} GNetworkConnectivity; + +/** + * GPollableReturn: + * @G_POLLABLE_RETURN_FAILED: Generic error condition for when an operation fails. + * @G_POLLABLE_RETURN_OK: The operation was successfully finished. + * @G_POLLABLE_RETURN_WOULD_BLOCK: The operation would block. + * + * Return value for various IO operations that signal errors via the + * return value and not necessarily via a #GError. + * + * This enum exists to be able to return errors to callers without having to + * allocate a #GError. Allocating #GErrors can be quite expensive for + * regularly happening errors like %G_IO_ERROR_WOULD_BLOCK. + * + * In case of %G_POLLABLE_RETURN_FAILED a #GError should be set for the + * operation to give details about the error that happened. + * + * Since: 2.60 + */ +typedef enum { + G_POLLABLE_RETURN_FAILED = 0, + G_POLLABLE_RETURN_OK = 1, + G_POLLABLE_RETURN_WOULD_BLOCK = -G_IO_ERROR_WOULD_BLOCK +} GPollableReturn; + +/** + * GMemoryMonitorWarningLevel: + * @G_MEMORY_MONITOR_WARNING_LEVEL_LOW: Memory on the device is low, processes + * should free up unneeded resources (for example, in-memory caches) so they can + * be used elsewhere. + * @G_MEMORY_MONITOR_WARNING_LEVEL_MEDIUM: Same as @G_MEMORY_MONITOR_WARNING_LEVEL_LOW + * but the device has even less free memory, so processes should try harder to free + * up unneeded resources. If your process does not need to stay running, it is a + * good time for it to quit. + * @G_MEMORY_MONITOR_WARNING_LEVEL_CRITICAL: The system will soon start terminating + * processes to reclaim memory, including background processes. + * + * Memory availability warning levels. + * + * Note that because new values might be added, it is recommended that applications check + * #GMemoryMonitorWarningLevel as ranges, for example: + * |[ + * if (warning_level > G_MEMORY_MONITOR_WARNING_LEVEL_LOW) + * drop_caches (); + * ]| + * + * Since: 2.64 + */ +typedef enum { + G_MEMORY_MONITOR_WARNING_LEVEL_LOW = 50, + G_MEMORY_MONITOR_WARNING_LEVEL_MEDIUM = 100, + G_MEMORY_MONITOR_WARNING_LEVEL_CRITICAL = 255 +} GMemoryMonitorWarningLevel; + +G_END_DECLS + +#endif /* __GIO_ENUMS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gioenumtypes.h b/illumos-x86_64/usr/include/glib-2.0/gio/gioenumtypes.h new file mode 100644 index 00000000..84a89fd9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gioenumtypes.h @@ -0,0 +1,207 @@ + +/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ + +/* + * Copyright © 2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Matthias Clasen + */ + +#ifndef __GIO_ENUM_TYPES_H__ +#define __GIO_ENUM_TYPES_H__ + +#include +#include + +G_BEGIN_DECLS + +/* enumerations from "gioenums.h" */ +GIO_AVAILABLE_IN_ALL GType g_app_info_create_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_APP_INFO_CREATE_FLAGS (g_app_info_create_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_converter_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_CONVERTER_FLAGS (g_converter_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_converter_result_get_type (void) G_GNUC_CONST; +#define G_TYPE_CONVERTER_RESULT (g_converter_result_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_data_stream_byte_order_get_type (void) G_GNUC_CONST; +#define G_TYPE_DATA_STREAM_BYTE_ORDER (g_data_stream_byte_order_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_data_stream_newline_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_DATA_STREAM_NEWLINE_TYPE (g_data_stream_newline_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_attribute_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_ATTRIBUTE_TYPE (g_file_attribute_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_attribute_info_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_ATTRIBUTE_INFO_FLAGS (g_file_attribute_info_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_attribute_status_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_ATTRIBUTE_STATUS (g_file_attribute_status_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_query_info_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_QUERY_INFO_FLAGS (g_file_query_info_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_create_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_CREATE_FLAGS (g_file_create_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_measure_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_MEASURE_FLAGS (g_file_measure_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_mount_mount_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_MOUNT_MOUNT_FLAGS (g_mount_mount_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_mount_unmount_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_MOUNT_UNMOUNT_FLAGS (g_mount_unmount_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_drive_start_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DRIVE_START_FLAGS (g_drive_start_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_drive_start_stop_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_DRIVE_START_STOP_TYPE (g_drive_start_stop_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_copy_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_COPY_FLAGS (g_file_copy_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_monitor_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_MONITOR_FLAGS (g_file_monitor_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_TYPE (g_file_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_filesystem_preview_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILESYSTEM_PREVIEW_TYPE (g_filesystem_preview_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_file_monitor_event_get_type (void) G_GNUC_CONST; +#define G_TYPE_FILE_MONITOR_EVENT (g_file_monitor_event_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_io_error_enum_get_type (void) G_GNUC_CONST; +#define G_TYPE_IO_ERROR_ENUM (g_io_error_enum_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_ask_password_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_ASK_PASSWORD_FLAGS (g_ask_password_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_password_save_get_type (void) G_GNUC_CONST; +#define G_TYPE_PASSWORD_SAVE (g_password_save_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_mount_operation_result_get_type (void) G_GNUC_CONST; +#define G_TYPE_MOUNT_OPERATION_RESULT (g_mount_operation_result_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_output_stream_splice_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS (g_output_stream_splice_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_io_stream_splice_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_IO_STREAM_SPLICE_FLAGS (g_io_stream_splice_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_emblem_origin_get_type (void) G_GNUC_CONST; +#define G_TYPE_EMBLEM_ORIGIN (g_emblem_origin_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_resolver_error_get_type (void) G_GNUC_CONST; +#define G_TYPE_RESOLVER_ERROR (g_resolver_error_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_resolver_record_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_RESOLVER_RECORD_TYPE (g_resolver_record_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_resource_error_get_type (void) G_GNUC_CONST; +#define G_TYPE_RESOURCE_ERROR (g_resource_error_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_resource_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_RESOURCE_FLAGS (g_resource_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_resource_lookup_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_RESOURCE_LOOKUP_FLAGS (g_resource_lookup_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_socket_family_get_type (void) G_GNUC_CONST; +#define G_TYPE_SOCKET_FAMILY (g_socket_family_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_socket_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_SOCKET_TYPE (g_socket_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_socket_msg_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_SOCKET_MSG_FLAGS (g_socket_msg_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_socket_protocol_get_type (void) G_GNUC_CONST; +#define G_TYPE_SOCKET_PROTOCOL (g_socket_protocol_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_zlib_compressor_format_get_type (void) G_GNUC_CONST; +#define G_TYPE_ZLIB_COMPRESSOR_FORMAT (g_zlib_compressor_format_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_unix_socket_address_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_UNIX_SOCKET_ADDRESS_TYPE (g_unix_socket_address_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_bus_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_BUS_TYPE (g_bus_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_bus_name_owner_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_BUS_NAME_OWNER_FLAGS (g_bus_name_owner_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_bus_name_watcher_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_BUS_NAME_WATCHER_FLAGS (g_bus_name_watcher_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_proxy_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_PROXY_FLAGS (g_dbus_proxy_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_error_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_ERROR (g_dbus_error_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_connection_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_CONNECTION_FLAGS (g_dbus_connection_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_capability_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_CAPABILITY_FLAGS (g_dbus_capability_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_call_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_CALL_FLAGS (g_dbus_call_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_message_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_MESSAGE_TYPE (g_dbus_message_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_message_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_MESSAGE_FLAGS (g_dbus_message_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_message_header_field_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_MESSAGE_HEADER_FIELD (g_dbus_message_header_field_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_property_info_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_PROPERTY_INFO_FLAGS (g_dbus_property_info_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_subtree_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_SUBTREE_FLAGS (g_dbus_subtree_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_server_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_SERVER_FLAGS (g_dbus_server_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_signal_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_SIGNAL_FLAGS (g_dbus_signal_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_send_message_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_SEND_MESSAGE_FLAGS (g_dbus_send_message_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_credentials_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_CREDENTIALS_TYPE (g_credentials_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_message_byte_order_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_MESSAGE_BYTE_ORDER (g_dbus_message_byte_order_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_application_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_APPLICATION_FLAGS (g_application_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_error_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_ERROR (g_tls_error_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_certificate_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_CERTIFICATE_FLAGS (g_tls_certificate_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_authentication_mode_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_AUTHENTICATION_MODE (g_tls_authentication_mode_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_channel_binding_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_CHANNEL_BINDING_TYPE (g_tls_channel_binding_type_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_channel_binding_error_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_rehandshake_mode_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_REHANDSHAKE_MODE (g_tls_rehandshake_mode_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_password_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_PASSWORD_FLAGS (g_tls_password_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_interaction_result_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_INTERACTION_RESULT (g_tls_interaction_result_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_interface_skeleton_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_INTERFACE_SKELETON_FLAGS (g_dbus_interface_skeleton_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_dbus_object_manager_client_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_DBUS_OBJECT_MANAGER_CLIENT_FLAGS (g_dbus_object_manager_client_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_database_verify_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_DATABASE_VERIFY_FLAGS (g_tls_database_verify_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_database_lookup_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_DATABASE_LOOKUP_FLAGS (g_tls_database_lookup_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_certificate_request_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_CERTIFICATE_REQUEST_FLAGS (g_tls_certificate_request_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_tls_protocol_version_get_type (void) G_GNUC_CONST; +#define G_TYPE_TLS_PROTOCOL_VERSION (g_tls_protocol_version_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_io_module_scope_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_IO_MODULE_SCOPE_FLAGS (g_io_module_scope_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_socket_client_event_get_type (void) G_GNUC_CONST; +#define G_TYPE_SOCKET_CLIENT_EVENT (g_socket_client_event_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_socket_listener_event_get_type (void) G_GNUC_CONST; +#define G_TYPE_SOCKET_LISTENER_EVENT (g_socket_listener_event_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_test_dbus_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_TEST_DBUS_FLAGS (g_test_dbus_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_subprocess_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_SUBPROCESS_FLAGS (g_subprocess_flags_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_notification_priority_get_type (void) G_GNUC_CONST; +#define G_TYPE_NOTIFICATION_PRIORITY (g_notification_priority_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_network_connectivity_get_type (void) G_GNUC_CONST; +#define G_TYPE_NETWORK_CONNECTIVITY (g_network_connectivity_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_pollable_return_get_type (void) G_GNUC_CONST; +#define G_TYPE_POLLABLE_RETURN (g_pollable_return_get_type ()) +GIO_AVAILABLE_IN_ALL GType g_memory_monitor_warning_level_get_type (void) G_GNUC_CONST; +#define G_TYPE_MEMORY_MONITOR_WARNING_LEVEL (g_memory_monitor_warning_level_get_type ()) + +/* enumerations from "gresolver.h" */ +GIO_AVAILABLE_IN_ALL GType g_resolver_name_lookup_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_RESOLVER_NAME_LOOKUP_FLAGS (g_resolver_name_lookup_flags_get_type ()) + +/* enumerations from "gsettings.h" */ +GIO_AVAILABLE_IN_ALL GType g_settings_bind_flags_get_type (void) G_GNUC_CONST; +#define G_TYPE_SETTINGS_BIND_FLAGS (g_settings_bind_flags_get_type ()) +G_END_DECLS + +#endif /* __GIO_ENUM_TYPES_H__ */ + +/* Generated data ends here */ + diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gioerror.h b/illumos-x86_64/usr/include/glib-2.0/gio/gioerror.h new file mode 100644 index 00000000..71ccdb17 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gioerror.h @@ -0,0 +1,58 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_IO_ERROR_H__ +#define __G_IO_ERROR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +/** + * G_IO_ERROR: + * + * Error domain for GIO. Errors in this domain will be from the #GIOErrorEnum enumeration. + * See #GError for more information on error domains. + **/ +#define G_IO_ERROR g_io_error_quark() + +GIO_AVAILABLE_IN_ALL +GQuark g_io_error_quark (void); +GIO_AVAILABLE_IN_ALL +GIOErrorEnum g_io_error_from_errno (gint err_no); +GIO_AVAILABLE_IN_2_74 +GIOErrorEnum g_io_error_from_file_error (GFileError file_error); + +#ifdef G_OS_WIN32 +GIO_AVAILABLE_IN_ALL +GIOErrorEnum g_io_error_from_win32_error (gint error_code); +#endif + +G_END_DECLS + +#endif /* __G_IO_ERROR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/giomodule.h b/illumos-x86_64/usr/include/glib-2.0/gio/giomodule.h new file mode 100644 index 00000000..f1460dec --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/giomodule.h @@ -0,0 +1,194 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_IO_MODULE_H__ +#define __G_IO_MODULE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GIOModuleScope GIOModuleScope; + +GIO_AVAILABLE_IN_2_30 +GIOModuleScope * g_io_module_scope_new (GIOModuleScopeFlags flags); +GIO_AVAILABLE_IN_2_30 +void g_io_module_scope_free (GIOModuleScope *scope); +GIO_AVAILABLE_IN_2_30 +void g_io_module_scope_block (GIOModuleScope *scope, + const gchar *basename); + +#define G_IO_TYPE_MODULE (g_io_module_get_type ()) +#define G_IO_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_IO_TYPE_MODULE, GIOModule)) +#define G_IO_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_IO_TYPE_MODULE, GIOModuleClass)) +#define G_IO_IS_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_IO_TYPE_MODULE)) +#define G_IO_IS_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_IO_TYPE_MODULE)) +#define G_IO_MODULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_IO_TYPE_MODULE, GIOModuleClass)) + +typedef struct _GIOModuleClass GIOModuleClass; + +GIO_AVAILABLE_IN_ALL +GType g_io_module_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GIOModule *g_io_module_new (const gchar *filename); + +GIO_AVAILABLE_IN_ALL +void g_io_modules_scan_all_in_directory (const char *dirname); +GIO_AVAILABLE_IN_ALL +GList *g_io_modules_load_all_in_directory (const gchar *dirname); + +GIO_AVAILABLE_IN_2_30 +void g_io_modules_scan_all_in_directory_with_scope (const gchar *dirname, + GIOModuleScope *scope); +GIO_AVAILABLE_IN_2_30 +GList *g_io_modules_load_all_in_directory_with_scope (const gchar *dirname, + GIOModuleScope *scope); + +GIO_AVAILABLE_IN_ALL +GIOExtensionPoint *g_io_extension_point_register (const char *name); +GIO_AVAILABLE_IN_ALL +GIOExtensionPoint *g_io_extension_point_lookup (const char *name); +GIO_AVAILABLE_IN_ALL +void g_io_extension_point_set_required_type (GIOExtensionPoint *extension_point, + GType type); +GIO_AVAILABLE_IN_ALL +GType g_io_extension_point_get_required_type (GIOExtensionPoint *extension_point); +GIO_AVAILABLE_IN_ALL +GList *g_io_extension_point_get_extensions (GIOExtensionPoint *extension_point); +GIO_AVAILABLE_IN_ALL +GIOExtension * g_io_extension_point_get_extension_by_name (GIOExtensionPoint *extension_point, + const char *name); +GIO_AVAILABLE_IN_ALL +GIOExtension * g_io_extension_point_implement (const char *extension_point_name, + GType type, + const char *extension_name, + gint priority); + +GIO_AVAILABLE_IN_ALL +GType g_io_extension_get_type (GIOExtension *extension); +GIO_AVAILABLE_IN_ALL +const char * g_io_extension_get_name (GIOExtension *extension); +GIO_AVAILABLE_IN_ALL +gint g_io_extension_get_priority (GIOExtension *extension); +GIO_AVAILABLE_IN_ALL +GTypeClass* g_io_extension_ref_class (GIOExtension *extension); + + +/* API for the modules to implement. + * Note that those functions are not implemented by libgio, they are declared + * here to be implemented in modules, that's why it uses G_MODULE_EXPORT + * instead of GIO_AVAILABLE_IN_ALL. + */ + +/** + * g_io_module_load: (skip) + * @module: a #GIOModule. + * + * Required API for GIO modules to implement. + * + * This function is run after the module has been loaded into GIO, + * to initialize the module. Typically, this function will call + * g_io_extension_point_implement(). + * + * Since 2.56, this function should be named `g_io__load`, where + * `modulename` is the plugin’s filename with the `lib` or `libgio` prefix and + * everything after the first dot removed, and with `-` replaced with `_` + * throughout. For example, `libgiognutls-helper.so` becomes `gnutls_helper`. + * Using the new symbol names avoids name clashes when building modules + * statically. The old symbol names continue to be supported, but cannot be used + * for static builds. + **/ +G_MODULE_EXPORT +void g_io_module_load (GIOModule *module); + +/** + * g_io_module_unload: (skip) + * @module: a #GIOModule. + * + * Required API for GIO modules to implement. + * + * This function is run when the module is being unloaded from GIO, + * to finalize the module. + * + * Since 2.56, this function should be named `g_io__unload`, where + * `modulename` is the plugin’s filename with the `lib` or `libgio` prefix and + * everything after the first dot removed, and with `-` replaced with `_` + * throughout. For example, `libgiognutls-helper.so` becomes `gnutls_helper`. + * Using the new symbol names avoids name clashes when building modules + * statically. The old symbol names continue to be supported, but cannot be used + * for static builds. + **/ +G_MODULE_EXPORT +void g_io_module_unload (GIOModule *module); + +/** + * g_io_module_query: + * + * Optional API for GIO modules to implement. + * + * Should return a list of all the extension points that may be + * implemented in this module. + * + * This method will not be called in normal use, however it may be + * called when probing existing modules and recording which extension + * points that this model is used for. This means we won't have to + * load and initialize this module unless its needed. + * + * If this function is not implemented by the module the module will + * always be loaded, initialized and then unloaded on application + * startup so that it can register its extension points during init. + * + * Note that a module need not actually implement all the extension + * points that g_io_module_query() returns, since the exact list of + * extension may depend on runtime issues. However all extension + * points actually implemented must be returned by g_io_module_query() + * (if defined). + * + * When installing a module that implements g_io_module_query() you must + * run gio-querymodules in order to build the cache files required for + * lazy loading. + * + * Since 2.56, this function should be named `g_io__query`, where + * `modulename` is the plugin’s filename with the `lib` or `libgio` prefix and + * everything after the first dot removed, and with `-` replaced with `_` + * throughout. For example, `libgiognutls-helper.so` becomes `gnutls_helper`. + * Using the new symbol names avoids name clashes when building modules + * statically. The old symbol names continue to be supported, but cannot be used + * for static builds. + * + * Returns: (transfer full): A %NULL-terminated array of strings, + * listing the supported extension points of the module. The array + * must be suitable for freeing with g_strfreev(). + * + * Since: 2.24 + **/ +G_MODULE_EXPORT +char **g_io_module_query (void); + +G_END_DECLS + +#endif /* __G_IO_MODULE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gioscheduler.h b/illumos-x86_64/usr/include/glib-2.0/gio/gioscheduler.h new file mode 100644 index 00000000..52162dce --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gioscheduler.h @@ -0,0 +1,56 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_IO_SCHEDULER_H__ +#define __G_IO_SCHEDULER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + + +GIO_DEPRECATED_IN_2_36_FOR ("GThreadPool or g_task_run_in_thread") +void g_io_scheduler_push_job (GIOSchedulerJobFunc job_func, + gpointer user_data, + GDestroyNotify notify, + gint io_priority, + GCancellable *cancellable); +GIO_DEPRECATED_IN_2_36 +void g_io_scheduler_cancel_all_jobs (void); +GIO_DEPRECATED_IN_2_36_FOR (g_main_context_invoke) +gboolean g_io_scheduler_job_send_to_mainloop (GIOSchedulerJob *job, + GSourceFunc func, + gpointer user_data, + GDestroyNotify notify); +GIO_DEPRECATED_IN_2_36_FOR (g_main_context_invoke) +void g_io_scheduler_job_send_to_mainloop_async (GIOSchedulerJob *job, + GSourceFunc func, + gpointer user_data, + GDestroyNotify notify); + +G_END_DECLS + +#endif /* __G_IO_SCHEDULER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/giostream.h b/illumos-x86_64/usr/include/glib-2.0/gio/giostream.h new file mode 100644 index 00000000..f8a958b2 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/giostream.h @@ -0,0 +1,132 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2008, 2009 Codethink Limited + * Copyright © 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * See the included COPYING file for more information. + * + * Authors: Ryan Lortie + * Alexander Larsson + */ + +#ifndef __G_IO_STREAM_H__ +#define __G_IO_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_IO_STREAM (g_io_stream_get_type ()) +#define G_IO_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_IO_STREAM, GIOStream)) +#define G_IO_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_IO_STREAM, GIOStreamClass)) +#define G_IS_IO_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_IO_STREAM)) +#define G_IS_IO_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_IO_STREAM)) +#define G_IO_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_IO_STREAM, GIOStreamClass)) + +typedef struct _GIOStreamPrivate GIOStreamPrivate; +typedef struct _GIOStreamClass GIOStreamClass; + +struct _GIOStream +{ + GObject parent_instance; + + /*< private >*/ + GIOStreamPrivate *priv; +}; + +struct _GIOStreamClass +{ + GObjectClass parent_class; + + GInputStream * (*get_input_stream) (GIOStream *stream); + GOutputStream * (*get_output_stream) (GIOStream *stream); + + gboolean (* close_fn) (GIOStream *stream, + GCancellable *cancellable, + GError **error); + void (* close_async) (GIOStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* close_finish) (GIOStream *stream, + GAsyncResult *result, + GError **error); + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); + void (*_g_reserved7) (void); + void (*_g_reserved8) (void); + void (*_g_reserved9) (void); + void (*_g_reserved10) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_io_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GInputStream * g_io_stream_get_input_stream (GIOStream *stream); +GIO_AVAILABLE_IN_ALL +GOutputStream *g_io_stream_get_output_stream (GIOStream *stream); + +GIO_AVAILABLE_IN_ALL +void g_io_stream_splice_async (GIOStream *stream1, + GIOStream *stream2, + GIOStreamSpliceFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +gboolean g_io_stream_splice_finish (GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_io_stream_close (GIOStream *stream, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_io_stream_close_async (GIOStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_io_stream_close_finish (GIOStream *stream, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_io_stream_is_closed (GIOStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_io_stream_has_pending (GIOStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_io_stream_set_pending (GIOStream *stream, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_io_stream_clear_pending (GIOStream *stream); + +G_END_DECLS + +#endif /* __G_IO_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/giotypes.h b/illumos-x86_64/usr/include/glib-2.0/gio/giotypes.h new file mode 100644 index 00000000..e6e67c5c --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/giotypes.h @@ -0,0 +1,557 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __GIO_TYPES_H__ +#define __GIO_TYPES_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GAppLaunchContext GAppLaunchContext; +typedef struct _GAppInfo GAppInfo; /* Dummy typedef */ +typedef struct _GAsyncResult GAsyncResult; /* Dummy typedef */ +typedef struct _GAsyncInitable GAsyncInitable; +typedef struct _GBufferedInputStream GBufferedInputStream; +typedef struct _GBufferedOutputStream GBufferedOutputStream; +typedef struct _GCancellable GCancellable; +typedef struct _GCharsetConverter GCharsetConverter; +typedef struct _GConverter GConverter; +typedef struct _GConverterInputStream GConverterInputStream; +typedef struct _GConverterOutputStream GConverterOutputStream; +typedef struct _GDatagramBased GDatagramBased; +typedef struct _GDataInputStream GDataInputStream; +typedef struct _GSimplePermission GSimplePermission; +typedef struct _GZlibCompressor GZlibCompressor; +typedef struct _GZlibDecompressor GZlibDecompressor; + +typedef struct _GSimpleActionGroup GSimpleActionGroup; +typedef struct _GRemoteActionGroup GRemoteActionGroup; +typedef struct _GDBusActionGroup GDBusActionGroup; +typedef struct _GActionMap GActionMap; +typedef struct _GActionGroup GActionGroup; +typedef struct _GPropertyAction GPropertyAction; +typedef struct _GSimpleAction GSimpleAction; +typedef struct _GAction GAction; +typedef struct _GApplication GApplication; +typedef struct _GApplicationCommandLine GApplicationCommandLine; +typedef struct _GSettingsBackend GSettingsBackend; +typedef struct _GSettings GSettings; +typedef struct _GPermission GPermission; + +typedef struct _GMenuModel GMenuModel; +typedef struct _GNotification GNotification; + +typedef struct _GDrive GDrive; /* Dummy typedef */ +typedef struct _GFileEnumerator GFileEnumerator; +typedef struct _GFileMonitor GFileMonitor; +typedef struct _GFilterInputStream GFilterInputStream; +typedef struct _GFilterOutputStream GFilterOutputStream; + +typedef struct _GFile GFile; /* Dummy typedef */ +typedef struct _GFileInfo GFileInfo; + +/** + * GFileAttributeMatcher: + * + * Determines if a string matches a file attribute. + **/ +typedef struct _GFileAttributeMatcher GFileAttributeMatcher; +typedef struct _GFileAttributeInfo GFileAttributeInfo; +typedef struct _GFileAttributeInfoList GFileAttributeInfoList; +typedef struct _GFileInputStream GFileInputStream; +typedef struct _GFileOutputStream GFileOutputStream; +typedef struct _GFileIOStream GFileIOStream; +typedef struct _GFileIcon GFileIcon; +typedef struct _GFilenameCompleter GFilenameCompleter; + + +typedef struct _GIcon GIcon; /* Dummy typedef */ +typedef struct _GInetAddress GInetAddress; +typedef struct _GInetAddressMask GInetAddressMask; +typedef struct _GInetSocketAddress GInetSocketAddress; +typedef struct _GNativeSocketAddress GNativeSocketAddress; +typedef struct _GInputStream GInputStream; +typedef struct _GInitable GInitable; +typedef struct _GIOModule GIOModule; +typedef struct _GIOExtensionPoint GIOExtensionPoint; +typedef struct _GIOExtension GIOExtension; + +/** + * GIOSchedulerJob: + * + * Opaque class for defining and scheduling IO jobs. + * + * Deprecated: 2.36: Use [struct@GLib.ThreadPool] or + * [method@Gio.Task.run_in_thread] + **/ +typedef struct _GIOSchedulerJob GIOSchedulerJob; +typedef struct _GIOStreamAdapter GIOStreamAdapter; +typedef struct _GLoadableIcon GLoadableIcon; /* Dummy typedef */ +typedef struct _GBytesIcon GBytesIcon; +typedef struct _GMemoryInputStream GMemoryInputStream; +typedef struct _GMemoryOutputStream GMemoryOutputStream; + +typedef struct _GMount GMount; /* Dummy typedef */ +typedef struct _GMountOperation GMountOperation; +typedef struct _GNetworkAddress GNetworkAddress; +typedef struct _GNetworkMonitor GNetworkMonitor; +typedef struct _GNetworkService GNetworkService; +typedef struct _GOutputStream GOutputStream; +typedef struct _GIOStream GIOStream; +typedef struct _GSimpleIOStream GSimpleIOStream; +typedef struct _GPollableInputStream GPollableInputStream; /* Dummy typedef */ +typedef struct _GPollableOutputStream GPollableOutputStream; /* Dummy typedef */ +typedef struct _GResolver GResolver; + +typedef struct _GResource GResource; +typedef struct _GSeekable GSeekable; +typedef struct _GSimpleAsyncResult GSimpleAsyncResult; + +typedef struct _GSocket GSocket; + +typedef struct _GSocketControlMessage GSocketControlMessage; +typedef struct _GSocketClient GSocketClient; +typedef struct _GSocketConnection GSocketConnection; +typedef struct _GSocketListener GSocketListener; +typedef struct _GSocketService GSocketService; +typedef struct _GSocketAddress GSocketAddress; +typedef struct _GSocketAddressEnumerator GSocketAddressEnumerator; +typedef struct _GSocketConnectable GSocketConnectable; +typedef struct _GSrvTarget GSrvTarget; +typedef struct _GTask GTask; +typedef struct _GTcpConnection GTcpConnection; +typedef struct _GTcpWrapperConnection GTcpWrapperConnection; +typedef struct _GThreadedSocketService GThreadedSocketService; +typedef struct _GDtlsConnection GDtlsConnection; +typedef struct _GDtlsClientConnection GDtlsClientConnection; /* Dummy typedef */ +typedef struct _GDtlsServerConnection GDtlsServerConnection; /* Dummy typedef */ +typedef struct _GThemedIcon GThemedIcon; +typedef struct _GTlsCertificate GTlsCertificate; +typedef struct _GTlsClientConnection GTlsClientConnection; /* Dummy typedef */ +typedef struct _GTlsConnection GTlsConnection; +typedef struct _GTlsDatabase GTlsDatabase; +typedef struct _GTlsFileDatabase GTlsFileDatabase; +typedef struct _GTlsInteraction GTlsInteraction; +typedef struct _GTlsPassword GTlsPassword; +typedef struct _GTlsServerConnection GTlsServerConnection; /* Dummy typedef */ +typedef struct _GVfs GVfs; /* Dummy typedef */ + +typedef struct _GProxyResolver GProxyResolver; +typedef struct _GProxy GProxy; +typedef struct _GProxyAddress GProxyAddress; +typedef struct _GProxyAddressEnumerator GProxyAddressEnumerator; + +typedef struct _GVolume GVolume; /* Dummy typedef */ +typedef struct _GVolumeMonitor GVolumeMonitor; + +/** + * GAsyncReadyCallback: + * @source_object: (nullable): the object the asynchronous operation was started with. + * @res: a #GAsyncResult. + * @data: user data passed to the callback. + * + * Type definition for a function that will be called back when an asynchronous + * operation within GIO has been completed. #GAsyncReadyCallback + * callbacks from #GTask are guaranteed to be invoked in a later + * iteration of the thread-default main context + * (see [method@GLib.MainContext.push_thread_default]) + * where the #GTask was created. All other users of + * #GAsyncReadyCallback must likewise call it asynchronously in a + * later iteration of the main context. + * + * The asynchronous operation is guaranteed to have held a reference to + * @source_object from the time when the `*_async()` function was called, until + * after this callback returns. + **/ +typedef void (*GAsyncReadyCallback) (GObject *source_object, + GAsyncResult *res, + gpointer data); + +/** + * GFileProgressCallback: + * @current_num_bytes: the current number of bytes in the operation. + * @total_num_bytes: the total number of bytes in the operation. + * @data: user data passed to the callback. + * + * When doing file operations that may take a while, such as moving + * a file or copying a file, a progress callback is used to pass how + * far along that operation is to the application. + **/ +typedef void (*GFileProgressCallback) (goffset current_num_bytes, + goffset total_num_bytes, + gpointer data); + +/** + * GFileReadMoreCallback: + * @file_contents: the data as currently read. + * @file_size: the size of the data currently read. + * @callback_data: data passed to the callback. + * + * When loading the partial contents of a file with g_file_load_partial_contents_async(), + * it may become necessary to determine if any more data from the file should be loaded. + * A #GFileReadMoreCallback function facilitates this by returning %TRUE if more data + * should be read, or %FALSE otherwise. + * + * Returns: %TRUE if more data should be read back. %FALSE otherwise. + **/ +typedef gboolean (* GFileReadMoreCallback) (const char *file_contents, + goffset file_size, + gpointer callback_data); + +/** + * GFileMeasureProgressCallback: + * @reporting: %TRUE if more reports will come + * @current_size: the current cumulative size measurement + * @num_dirs: the number of directories visited so far + * @num_files: the number of non-directory files encountered + * @data: the data passed to the original request for this callback + * + * This callback type is used by g_file_measure_disk_usage() to make + * periodic progress reports when measuring the amount of disk spaced + * used by a directory. + * + * These calls are made on a best-effort basis and not all types of + * #GFile will support them. At the minimum, however, one call will + * always be made immediately. + * + * In the case that there is no support, @reporting will be set to + * %FALSE (and the other values undefined) and no further calls will be + * made. Otherwise, the @reporting will be %TRUE and the other values + * all-zeros during the first (immediate) call. In this way, you can + * know which type of progress UI to show without a delay. + * + * For g_file_measure_disk_usage() the callback is made directly. For + * g_file_measure_disk_usage_async() the callback is made via the + * default main context of the calling thread (ie: the same way that the + * final async result would be reported). + * + * @current_size is in the same units as requested by the operation (see + * %G_FILE_MEASURE_APPARENT_SIZE). + * + * The frequency of the updates is implementation defined, but is + * ideally about once every 200ms. + * + * The last progress callback may or may not be equal to the final + * result. Always check the async result to get the final value. + * + * Since: 2.38 + **/ +typedef void (* GFileMeasureProgressCallback) (gboolean reporting, + guint64 current_size, + guint64 num_dirs, + guint64 num_files, + gpointer data); + +/** + * GIOSchedulerJobFunc: + * @job: a #GIOSchedulerJob. + * @cancellable: optional #GCancellable object, %NULL to ignore. + * @data: data passed to the callback function + * + * I/O Job function. + * + * Long-running jobs should periodically check the @cancellable + * to see if they have been cancelled. + * + * Returns: %TRUE if this function should be called again to + * complete the job, %FALSE if the job is complete (or cancelled) + * Deprecated: 2.36: Use [struct@GLib.ThreadPool] or + * [method@Gio.Task.run_in_thread] + **/ +typedef gboolean (*GIOSchedulerJobFunc) (GIOSchedulerJob *job, + GCancellable *cancellable, + gpointer data); + +/** + * GSimpleAsyncThreadFunc: + * @res: a #GSimpleAsyncResult. + * @object: a #GObject. + * @cancellable: optional #GCancellable object, %NULL to ignore. + * + * Simple thread function that runs an asynchronous operation and + * checks for cancellation. + **/ +typedef void (*GSimpleAsyncThreadFunc) (GSimpleAsyncResult *res, + GObject *object, + GCancellable *cancellable); + +/** + * GSocketSourceFunc: + * @socket: the #GSocket + * @condition: the current condition at the source fired. + * @data: data passed in by the user. + * + * This is the function type of the callback used for the #GSource + * returned by g_socket_create_source(). + * + * Returns: it should return %FALSE if the source should be removed. + * + * Since: 2.22 + */ +typedef gboolean (*GSocketSourceFunc) (GSocket *socket, + GIOCondition condition, + gpointer data); + +/** + * GDatagramBasedSourceFunc: + * @datagram_based: the #GDatagramBased + * @condition: the current condition at the source fired + * @data: data passed in by the user + * + * This is the function type of the callback used for the #GSource + * returned by g_datagram_based_create_source(). + * + * Returns: %G_SOURCE_REMOVE if the source should be removed, + * %G_SOURCE_CONTINUE otherwise + * + * Since: 2.48 + */ +typedef gboolean (*GDatagramBasedSourceFunc) (GDatagramBased *datagram_based, + GIOCondition condition, + gpointer data); + +/** + * GInputVector: + * @buffer: Pointer to a buffer where data will be written. + * @size: the available size in @buffer. + * + * Structure used for scatter/gather data input. + * You generally pass in an array of #GInputVectors + * and the operation will store the read data starting in the + * first buffer, switching to the next as needed. + * + * Since: 2.22 + */ +typedef struct _GInputVector GInputVector; + +struct _GInputVector { + gpointer buffer; + gsize size; +}; + +/** + * GInputMessage: + * @address: (optional) (out) (transfer full): return location + * for a #GSocketAddress, or %NULL + * @vectors: (array length=num_vectors) (out): pointer to an + * array of input vectors + * @num_vectors: the number of input vectors pointed to by @vectors + * @bytes_received: (out): will be set to the number of bytes that have been + * received + * @flags: (out): collection of #GSocketMsgFlags for the received message, + * outputted by the call + * @control_messages: (array length=num_control_messages) (optional) + * (out) (transfer full): return location for a + * caller-allocated array of #GSocketControlMessages, or %NULL + * @num_control_messages: (out) (optional): return location for the number of + * elements in @control_messages + * + * Structure used for scatter/gather data input when receiving multiple + * messages or packets in one go. You generally pass in an array of empty + * #GInputVectors and the operation will use all the buffers as if they + * were one buffer, and will set @bytes_received to the total number of bytes + * received across all #GInputVectors. + * + * This structure closely mirrors `struct mmsghdr` and `struct msghdr` from + * the POSIX sockets API (see `man 2 recvmmsg`). + * + * If @address is non-%NULL then it is set to the source address the message + * was received from, and the caller must free it afterwards. + * + * If @control_messages is non-%NULL then it is set to an array of control + * messages received with the message (if any), and the caller must free it + * afterwards. @num_control_messages is set to the number of elements in + * this array, which may be zero. + * + * Flags relevant to this message will be returned in @flags. For example, + * `MSG_EOR` or `MSG_TRUNC`. + * + * Since: 2.48 + */ +typedef struct _GInputMessage GInputMessage; + +struct _GInputMessage { + GSocketAddress **address; + + GInputVector *vectors; + guint num_vectors; + + gsize bytes_received; + gint flags; + + GSocketControlMessage ***control_messages; + guint *num_control_messages; +}; + +/** + * GOutputVector: + * @buffer: Pointer to a buffer of data to read. + * @size: the size of @buffer. + * + * Structure used for scatter/gather data output. + * You generally pass in an array of #GOutputVectors + * and the operation will use all the buffers as if they were + * one buffer. + * + * Since: 2.22 + */ +typedef struct _GOutputVector GOutputVector; + +struct _GOutputVector { + gconstpointer buffer; + gsize size; +}; + +/** + * GOutputMessage: + * @address: (nullable): a #GSocketAddress, or %NULL + * @vectors: pointer to an array of output vectors + * @num_vectors: the number of output vectors pointed to by @vectors. + * @bytes_sent: initialize to 0. Will be set to the number of bytes + * that have been sent + * @control_messages: (array length=num_control_messages) (nullable): a pointer + * to an array of #GSocketControlMessages, or %NULL. + * @num_control_messages: number of elements in @control_messages. + * + * Structure used for scatter/gather data output when sending multiple + * messages or packets in one go. You generally pass in an array of + * #GOutputVectors and the operation will use all the buffers as if they + * were one buffer. + * + * If @address is %NULL then the message is sent to the default receiver + * (as previously set by g_socket_connect()). + * + * Since: 2.44 + */ +typedef struct _GOutputMessage GOutputMessage; + +struct _GOutputMessage { + GSocketAddress *address; + + GOutputVector *vectors; + guint num_vectors; + + guint bytes_sent; + + GSocketControlMessage **control_messages; + guint num_control_messages; +}; + +typedef struct _GCredentials GCredentials; +typedef struct _GUnixCredentialsMessage GUnixCredentialsMessage; +typedef struct _GUnixFDList GUnixFDList; +typedef struct _GDBusMessage GDBusMessage; +typedef struct _GDBusConnection GDBusConnection; +typedef struct _GDBusProxy GDBusProxy; +typedef struct _GDBusMethodInvocation GDBusMethodInvocation; +typedef struct _GDBusServer GDBusServer; +typedef struct _GDBusAuthObserver GDBusAuthObserver; +typedef struct _GDBusErrorEntry GDBusErrorEntry; +typedef struct _GDBusInterfaceVTable GDBusInterfaceVTable; +typedef struct _GDBusSubtreeVTable GDBusSubtreeVTable; +typedef struct _GDBusAnnotationInfo GDBusAnnotationInfo; +typedef struct _GDBusArgInfo GDBusArgInfo; +typedef struct _GDBusMethodInfo GDBusMethodInfo; +typedef struct _GDBusSignalInfo GDBusSignalInfo; +typedef struct _GDBusPropertyInfo GDBusPropertyInfo; +typedef struct _GDBusInterfaceInfo GDBusInterfaceInfo; +typedef struct _GDBusNodeInfo GDBusNodeInfo; + +/** + * GCancellableSourceFunc: + * @cancellable: the #GCancellable + * @data: data passed in by the user. + * + * This is the function type of the callback used for the #GSource + * returned by g_cancellable_source_new(). + * + * Returns: it should return %FALSE if the source should be removed. + * + * Since: 2.28 + */ +typedef gboolean (*GCancellableSourceFunc) (GCancellable *cancellable, + gpointer data); + +/** + * GPollableSourceFunc: + * @pollable_stream: the #GPollableInputStream or #GPollableOutputStream + * @data: data passed in by the user. + * + * This is the function type of the callback used for the #GSource + * returned by g_pollable_input_stream_create_source() and + * g_pollable_output_stream_create_source(). + * + * Returns: it should return %FALSE if the source should be removed. + * + * Since: 2.28 + */ +typedef gboolean (*GPollableSourceFunc) (GObject *pollable_stream, + gpointer data); + +typedef struct _GDBusInterface GDBusInterface; /* Dummy typedef */ +typedef struct _GDBusInterfaceSkeleton GDBusInterfaceSkeleton; +typedef struct _GDBusObject GDBusObject; /* Dummy typedef */ +typedef struct _GDBusObjectSkeleton GDBusObjectSkeleton; +typedef struct _GDBusObjectProxy GDBusObjectProxy; +typedef struct _GDBusObjectManager GDBusObjectManager; /* Dummy typedef */ +typedef struct _GDBusObjectManagerClient GDBusObjectManagerClient; +typedef struct _GDBusObjectManagerServer GDBusObjectManagerServer; + +/** + * GDBusProxyTypeFunc: + * @manager: A #GDBusObjectManagerClient. + * @object_path: The object path of the remote object. + * @interface_name: (nullable): The interface name of the remote object or %NULL if a #GDBusObjectProxy #GType is requested. + * @data: data passed in by the user. + * + * Function signature for a function used to determine the #GType to + * use for an interface proxy (if @interface_name is not %NULL) or + * object proxy (if @interface_name is %NULL). + * + * This function is called in the thread-default main context + * (see [method@GLib.MainContext.push_thread_default]) + * that @manager was constructed in. + * + * Returns: A #GType to use for the remote object. The returned type + * must be a #GDBusProxy or #GDBusObjectProxy -derived + * type. + * + * Since: 2.30 + */ +typedef GType (*GDBusProxyTypeFunc) (GDBusObjectManagerClient *manager, + const gchar *object_path, + const gchar *interface_name, + gpointer data); + +typedef struct _GTestDBus GTestDBus; + +typedef struct _GSubprocess GSubprocess; +typedef struct _GSubprocessLauncher GSubprocessLauncher; + +G_END_DECLS + +#endif /* __GIO_TYPES_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/glistmodel.h b/illumos-x86_64/usr/include/glib-2.0/gio/glistmodel.h new file mode 100644 index 00000000..a96e3cea --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/glistmodel.h @@ -0,0 +1,74 @@ +/* + * Copyright 2015 Lars Uebernickel + * Copyright 2015 Ryan Lortie + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: + * Lars Uebernickel + * Ryan Lortie + */ + +#ifndef __G_LIST_MODEL_H__ +#define __G_LIST_MODEL_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_LIST_MODEL g_list_model_get_type () +GIO_AVAILABLE_IN_2_44 +G_DECLARE_INTERFACE(GListModel, g_list_model, G, LIST_MODEL, GObject) + +struct _GListModelInterface +{ + GTypeInterface g_iface; + + GType (* get_item_type) (GListModel *list); + + guint (* get_n_items) (GListModel *list); + + gpointer (* get_item) (GListModel *list, + guint position); +}; + +GIO_AVAILABLE_IN_2_44 +GType g_list_model_get_item_type (GListModel *list); + +GIO_AVAILABLE_IN_2_44 +guint g_list_model_get_n_items (GListModel *list); + +GIO_AVAILABLE_IN_2_44 +gpointer g_list_model_get_item (GListModel *list, + guint position); + +GIO_AVAILABLE_IN_2_44 +GObject * g_list_model_get_object (GListModel *list, + guint position); + +GIO_AVAILABLE_IN_2_44 +void g_list_model_items_changed (GListModel *list, + guint position, + guint removed, + guint added); + +G_END_DECLS + +#endif /* __G_LIST_MODEL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gliststore.h b/illumos-x86_64/usr/include/glib-2.0/gio/gliststore.h new file mode 100644 index 00000000..958ca60d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gliststore.h @@ -0,0 +1,97 @@ +/* + * Copyright 2015 Lars Uebernickel + * Copyright 2015 Ryan Lortie + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: + * Lars Uebernickel + * Ryan Lortie + */ + +#ifndef __G_LIST_STORE_H__ +#define __G_LIST_STORE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_LIST_STORE (g_list_store_get_type ()) +GIO_AVAILABLE_IN_2_44 +G_DECLARE_FINAL_TYPE(GListStore, g_list_store, G, LIST_STORE, GObject) + +GIO_AVAILABLE_IN_2_44 +GListStore * g_list_store_new (GType item_type); + +GIO_AVAILABLE_IN_2_44 +void g_list_store_insert (GListStore *store, + guint position, + gpointer item); + +GIO_AVAILABLE_IN_2_44 +guint g_list_store_insert_sorted (GListStore *store, + gpointer item, + GCompareDataFunc compare_func, + gpointer user_data); + +GIO_AVAILABLE_IN_2_46 +void g_list_store_sort (GListStore *store, + GCompareDataFunc compare_func, + gpointer user_data); + +GIO_AVAILABLE_IN_2_44 +void g_list_store_append (GListStore *store, + gpointer item); + +GIO_AVAILABLE_IN_2_44 +void g_list_store_remove (GListStore *store, + guint position); + +GIO_AVAILABLE_IN_2_44 +void g_list_store_remove_all (GListStore *store); + +GIO_AVAILABLE_IN_2_44 +void g_list_store_splice (GListStore *store, + guint position, + guint n_removals, + gpointer *additions, + guint n_additions); + +GIO_AVAILABLE_IN_2_64 +gboolean g_list_store_find (GListStore *store, + gpointer item, + guint *position); + +GIO_AVAILABLE_IN_2_64 +gboolean g_list_store_find_with_equal_func (GListStore *store, + gpointer item, + GEqualFunc equal_func, + guint *position); + +GIO_AVAILABLE_IN_2_74 +gboolean g_list_store_find_with_equal_func_full (GListStore *store, + gpointer item, + GEqualFuncFull equal_func, + gpointer user_data, + guint *position); + +G_END_DECLS + +#endif /* __G_LIST_STORE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gloadableicon.h b/illumos-x86_64/usr/include/glib-2.0/gio/gloadableicon.h new file mode 100644 index 00000000..bde104b0 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gloadableicon.h @@ -0,0 +1,95 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_LOADABLE_ICON_H__ +#define __G_LOADABLE_ICON_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_LOADABLE_ICON (g_loadable_icon_get_type ()) +#define G_LOADABLE_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_LOADABLE_ICON, GLoadableIcon)) +#define G_IS_LOADABLE_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_LOADABLE_ICON)) +#define G_LOADABLE_ICON_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_LOADABLE_ICON, GLoadableIconIface)) + +typedef struct _GLoadableIconIface GLoadableIconIface; + +/** + * GLoadableIconIface: + * @g_iface: The parent interface. + * @load: Loads an icon. + * @load_async: Loads an icon asynchronously. + * @load_finish: Finishes an asynchronous icon load. + * + * Interface for icons that can be loaded as a stream. + **/ +struct _GLoadableIconIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + GInputStream * (* load) (GLoadableIcon *icon, + int size, + char **type, + GCancellable *cancellable, + GError **error); + void (* load_async) (GLoadableIcon *icon, + int size, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GInputStream * (* load_finish) (GLoadableIcon *icon, + GAsyncResult *res, + char **type, + GError **error); +}; + +GIO_AVAILABLE_IN_ALL +GType g_loadable_icon_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GInputStream *g_loadable_icon_load (GLoadableIcon *icon, + int size, + char **type, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_loadable_icon_load_async (GLoadableIcon *icon, + int size, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GInputStream *g_loadable_icon_load_finish (GLoadableIcon *icon, + GAsyncResult *res, + char **type, + GError **error); + +G_END_DECLS + +#endif /* __G_LOADABLE_ICON_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gmemoryinputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gmemoryinputstream.h new file mode 100644 index 00000000..b3465670 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gmemoryinputstream.h @@ -0,0 +1,87 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Christian Kellner + */ + +#ifndef __G_MEMORY_INPUT_STREAM_H__ +#define __G_MEMORY_INPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_MEMORY_INPUT_STREAM (g_memory_input_stream_get_type ()) +#define G_MEMORY_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MEMORY_INPUT_STREAM, GMemoryInputStream)) +#define G_MEMORY_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MEMORY_INPUT_STREAM, GMemoryInputStreamClass)) +#define G_IS_MEMORY_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MEMORY_INPUT_STREAM)) +#define G_IS_MEMORY_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MEMORY_INPUT_STREAM)) +#define G_MEMORY_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MEMORY_INPUT_STREAM, GMemoryInputStreamClass)) + +typedef struct _GMemoryInputStreamClass GMemoryInputStreamClass; +typedef struct _GMemoryInputStreamPrivate GMemoryInputStreamPrivate; + +struct _GMemoryInputStream +{ + GInputStream parent_instance; + + /*< private >*/ + GMemoryInputStreamPrivate *priv; +}; + +struct _GMemoryInputStreamClass +{ + GInputStreamClass parent_class; + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + + +GIO_AVAILABLE_IN_ALL +GType g_memory_input_stream_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GInputStream * g_memory_input_stream_new (void); +GIO_AVAILABLE_IN_ALL +GInputStream * g_memory_input_stream_new_from_data (const void *data, + gssize len, + GDestroyNotify destroy); +GIO_AVAILABLE_IN_2_34 +GInputStream * g_memory_input_stream_new_from_bytes (GBytes *bytes); + +GIO_AVAILABLE_IN_ALL +void g_memory_input_stream_add_data (GMemoryInputStream *stream, + const void *data, + gssize len, + GDestroyNotify destroy); +GIO_AVAILABLE_IN_2_34 +void g_memory_input_stream_add_bytes (GMemoryInputStream *stream, + GBytes *bytes); + +G_END_DECLS + +#endif /* __G_MEMORY_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gmemorymonitor.h b/illumos-x86_64/usr/include/glib-2.0/gio/gmemorymonitor.h new file mode 100644 index 00000000..2a405267 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gmemorymonitor.h @@ -0,0 +1,64 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright 2019 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_MEMORY_MONITOR_H__ +#define __G_MEMORY_MONITOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_MEMORY_MONITOR_EXTENSION_POINT_NAME: + * + * Extension point for memory usage monitoring functionality. + * See [Extending GIO](overview.html#extending-gio). + * + * Since: 2.64 + */ +#define G_MEMORY_MONITOR_EXTENSION_POINT_NAME "gio-memory-monitor" + +#define G_TYPE_MEMORY_MONITOR (g_memory_monitor_get_type ()) +GIO_AVAILABLE_IN_2_64 +G_DECLARE_INTERFACE(GMemoryMonitor, g_memory_monitor, g, memory_monitor, GObject) + +#define G_MEMORY_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MEMORY_MONITOR, GMemoryMonitor)) +#define G_IS_MEMORY_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MEMORY_MONITOR)) +#define G_MEMORY_MONITOR_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), G_TYPE_MEMORY_MONITOR, GMemoryMonitorInterface)) + +struct _GMemoryMonitorInterface { + /*< private >*/ + GTypeInterface g_iface; + + /*< public >*/ + void (*low_memory_warning) (GMemoryMonitor *monitor, + GMemoryMonitorWarningLevel level); +}; + +GIO_AVAILABLE_IN_2_64 +GMemoryMonitor *g_memory_monitor_dup_default (void); + +G_END_DECLS + +#endif /* __G_MEMORY_MONITOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gmemoryoutputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gmemoryoutputstream.h new file mode 100644 index 00000000..6fb077be --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gmemoryoutputstream.h @@ -0,0 +1,104 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Christian Kellner + */ + +#ifndef __G_MEMORY_OUTPUT_STREAM_H__ +#define __G_MEMORY_OUTPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_MEMORY_OUTPUT_STREAM (g_memory_output_stream_get_type ()) +#define G_MEMORY_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStream)) +#define G_MEMORY_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStreamClass)) +#define G_IS_MEMORY_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MEMORY_OUTPUT_STREAM)) +#define G_IS_MEMORY_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MEMORY_OUTPUT_STREAM)) +#define G_MEMORY_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStreamClass)) + +typedef struct _GMemoryOutputStreamClass GMemoryOutputStreamClass; +typedef struct _GMemoryOutputStreamPrivate GMemoryOutputStreamPrivate; + +struct _GMemoryOutputStream +{ + GOutputStream parent_instance; + + /*< private >*/ + GMemoryOutputStreamPrivate *priv; +}; + +struct _GMemoryOutputStreamClass +{ + GOutputStreamClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +/** + * GReallocFunc: + * @data: memory block to reallocate + * @size: size to reallocate @data to + * + * Changes the size of the memory block pointed to by @data to + * @size bytes. + * + * The function should have the same semantics as realloc(). + * + * Returns: a pointer to the reallocated memory + */ +typedef gpointer (* GReallocFunc) (gpointer data, + gsize size); + +GIO_AVAILABLE_IN_ALL +GType g_memory_output_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GOutputStream *g_memory_output_stream_new (gpointer data, + gsize size, + GReallocFunc realloc_function, + GDestroyNotify destroy_function); +GIO_AVAILABLE_IN_2_36 +GOutputStream *g_memory_output_stream_new_resizable (void); +GIO_AVAILABLE_IN_ALL +gpointer g_memory_output_stream_get_data (GMemoryOutputStream *ostream); +GIO_AVAILABLE_IN_ALL +gsize g_memory_output_stream_get_size (GMemoryOutputStream *ostream); +GIO_AVAILABLE_IN_ALL +gsize g_memory_output_stream_get_data_size (GMemoryOutputStream *ostream); +GIO_AVAILABLE_IN_ALL +gpointer g_memory_output_stream_steal_data (GMemoryOutputStream *ostream); + +GIO_AVAILABLE_IN_2_34 +GBytes * g_memory_output_stream_steal_as_bytes (GMemoryOutputStream *ostream); + +G_END_DECLS + +#endif /* __G_MEMORY_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gmenu.h b/illumos-x86_64/usr/include/glib-2.0/gio/gmenu.h new file mode 100644 index 00000000..68e06842 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gmenu.h @@ -0,0 +1,184 @@ +/* + * Copyright © 2011 Canonical Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_MENU_H__ +#define __G_MENU_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_MENU (g_menu_get_type ()) +#define G_MENU(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_MENU, GMenu)) +#define G_IS_MENU(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_MENU)) + +#define G_TYPE_MENU_ITEM (g_menu_item_get_type ()) +#define G_MENU_ITEM(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_MENU_ITEM, GMenuItem)) +#define G_IS_MENU_ITEM(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_MENU_ITEM)) + +typedef struct _GMenuItem GMenuItem; +typedef struct _GMenu GMenu; + +GIO_AVAILABLE_IN_2_32 +GType g_menu_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_2_32 +GMenu * g_menu_new (void); + +GIO_AVAILABLE_IN_2_32 +void g_menu_freeze (GMenu *menu); + +GIO_AVAILABLE_IN_2_32 +void g_menu_insert_item (GMenu *menu, + gint position, + GMenuItem *item); +GIO_AVAILABLE_IN_2_32 +void g_menu_prepend_item (GMenu *menu, + GMenuItem *item); +GIO_AVAILABLE_IN_2_32 +void g_menu_append_item (GMenu *menu, + GMenuItem *item); +GIO_AVAILABLE_IN_2_32 +void g_menu_remove (GMenu *menu, + gint position); + +GIO_AVAILABLE_IN_2_38 +void g_menu_remove_all (GMenu *menu); + +GIO_AVAILABLE_IN_2_32 +void g_menu_insert (GMenu *menu, + gint position, + const gchar *label, + const gchar *detailed_action); +GIO_AVAILABLE_IN_2_32 +void g_menu_prepend (GMenu *menu, + const gchar *label, + const gchar *detailed_action); +GIO_AVAILABLE_IN_2_32 +void g_menu_append (GMenu *menu, + const gchar *label, + const gchar *detailed_action); + +GIO_AVAILABLE_IN_2_32 +void g_menu_insert_section (GMenu *menu, + gint position, + const gchar *label, + GMenuModel *section); +GIO_AVAILABLE_IN_2_32 +void g_menu_prepend_section (GMenu *menu, + const gchar *label, + GMenuModel *section); +GIO_AVAILABLE_IN_2_32 +void g_menu_append_section (GMenu *menu, + const gchar *label, + GMenuModel *section); + +GIO_AVAILABLE_IN_2_32 +void g_menu_insert_submenu (GMenu *menu, + gint position, + const gchar *label, + GMenuModel *submenu); +GIO_AVAILABLE_IN_2_32 +void g_menu_prepend_submenu (GMenu *menu, + const gchar *label, + GMenuModel *submenu); +GIO_AVAILABLE_IN_2_32 +void g_menu_append_submenu (GMenu *menu, + const gchar *label, + GMenuModel *submenu); + + +GIO_AVAILABLE_IN_2_32 +GType g_menu_item_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_2_32 +GMenuItem * g_menu_item_new (const gchar *label, + const gchar *detailed_action); + +GIO_AVAILABLE_IN_2_34 +GMenuItem * g_menu_item_new_from_model (GMenuModel *model, + gint item_index); + +GIO_AVAILABLE_IN_2_32 +GMenuItem * g_menu_item_new_submenu (const gchar *label, + GMenuModel *submenu); + +GIO_AVAILABLE_IN_2_32 +GMenuItem * g_menu_item_new_section (const gchar *label, + GMenuModel *section); + +GIO_AVAILABLE_IN_2_34 +GVariant * g_menu_item_get_attribute_value (GMenuItem *menu_item, + const gchar *attribute, + const GVariantType *expected_type); +GIO_AVAILABLE_IN_2_34 +gboolean g_menu_item_get_attribute (GMenuItem *menu_item, + const gchar *attribute, + const gchar *format_string, + ...); +GIO_AVAILABLE_IN_2_34 +GMenuModel *g_menu_item_get_link (GMenuItem *menu_item, + const gchar *link); + +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_attribute_value (GMenuItem *menu_item, + const gchar *attribute, + GVariant *value); +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_attribute (GMenuItem *menu_item, + const gchar *attribute, + const gchar *format_string, + ...); +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_link (GMenuItem *menu_item, + const gchar *link, + GMenuModel *model); +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_label (GMenuItem *menu_item, + const gchar *label); +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_submenu (GMenuItem *menu_item, + GMenuModel *submenu); +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_section (GMenuItem *menu_item, + GMenuModel *section); +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_action_and_target_value (GMenuItem *menu_item, + const gchar *action, + GVariant *target_value); +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_action_and_target (GMenuItem *menu_item, + const gchar *action, + const gchar *format_string, + ...); +GIO_AVAILABLE_IN_2_32 +void g_menu_item_set_detailed_action (GMenuItem *menu_item, + const gchar *detailed_action); + +GIO_AVAILABLE_IN_2_38 +void g_menu_item_set_icon (GMenuItem *menu_item, + GIcon *icon); + +G_END_DECLS + +#endif /* __G_MENU_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gmenuexporter.h b/illumos-x86_64/usr/include/glib-2.0/gio/gmenuexporter.h new file mode 100644 index 00000000..4651affd --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gmenuexporter.h @@ -0,0 +1,55 @@ +/* + * Copyright © 2011 Canonical Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_MENU_EXPORTER_H__ +#define __G_MENU_EXPORTER_H__ + +#include +#include + +G_BEGIN_DECLS + +/** + * G_MENU_EXPORTER_MAX_SECTION_SIZE: + * + * The maximum number of entries in a menu section supported by + * g_dbus_connection_export_menu_model(). + * + * The exact value of the limit may change in future GLib versions. + * + * Since: 2.76 + */ +#define G_MENU_EXPORTER_MAX_SECTION_SIZE 1000 \ + GIO_AVAILABLE_MACRO_IN_2_76 + +GIO_AVAILABLE_IN_2_32 +guint g_dbus_connection_export_menu_model (GDBusConnection *connection, + const gchar *object_path, + GMenuModel *menu, + GError **error); + +GIO_AVAILABLE_IN_2_32 +void g_dbus_connection_unexport_menu_model (GDBusConnection *connection, + guint export_id); + +G_END_DECLS + +#endif /* __G_MENU_EXPORTER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gmenumodel.h b/illumos-x86_64/usr/include/glib-2.0/gio/gmenumodel.h new file mode 100644 index 00000000..0ef7c9dc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gmenumodel.h @@ -0,0 +1,307 @@ +/* + * Copyright © 2011 Canonical Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_MENU_MODEL_H__ +#define __G_MENU_MODEL_H__ + +#include + +#include + +G_BEGIN_DECLS + +/** + * G_MENU_ATTRIBUTE_ACTION: + * + * The menu item attribute which holds the action name of the item. Action + * names are namespaced with an identifier for the action group in which the + * action resides. For example, "win." for window-specific actions and "app." + * for application-wide actions. + * + * See also g_menu_model_get_item_attribute() and g_menu_item_set_attribute(). + * + * Since: 2.32 + **/ +#define G_MENU_ATTRIBUTE_ACTION "action" + +/** + * G_MENU_ATTRIBUTE_ACTION_NAMESPACE: + * + * The menu item attribute that holds the namespace for all action names in + * menus that are linked from this item. + * + * Since: 2.36 + **/ +#define G_MENU_ATTRIBUTE_ACTION_NAMESPACE "action-namespace" + +/** + * G_MENU_ATTRIBUTE_TARGET: + * + * The menu item attribute which holds the target with which the item's action + * will be activated. + * + * See also g_menu_item_set_action_and_target() + * + * Since: 2.32 + **/ +#define G_MENU_ATTRIBUTE_TARGET "target" + +/** + * G_MENU_ATTRIBUTE_LABEL: + * + * The menu item attribute which holds the label of the item. + * + * Since: 2.32 + **/ +#define G_MENU_ATTRIBUTE_LABEL "label" + +/** + * G_MENU_ATTRIBUTE_ICON: + * + * The menu item attribute which holds the icon of the item. + * + * The icon is stored in the format returned by g_icon_serialize(). + * + * This attribute is intended only to represent 'noun' icons such as + * favicons for a webpage, or application icons. It should not be used + * for 'verbs' (ie: stock icons). + * + * Since: 2.38 + **/ +#define G_MENU_ATTRIBUTE_ICON "icon" + +/** + * G_MENU_LINK_SUBMENU: + * + * The name of the link that associates a menu item with a submenu. + * + * See also g_menu_item_set_link(). + * + * Since: 2.32 + **/ +#define G_MENU_LINK_SUBMENU "submenu" + +/** + * G_MENU_LINK_SECTION: + * + * The name of the link that associates a menu item with a section. The linked + * menu will usually be shown in place of the menu item, using the item's label + * as a header. + * + * See also g_menu_item_set_link(). + * + * Since: 2.32 + **/ +#define G_MENU_LINK_SECTION "section" + +#define G_TYPE_MENU_MODEL (g_menu_model_get_type ()) +#define G_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_MENU_MODEL, GMenuModel)) +#define G_MENU_MODEL_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_MENU_MODEL, GMenuModelClass)) +#define G_IS_MENU_MODEL(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_MENU_MODEL)) +#define G_IS_MENU_MODEL_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_MENU_MODEL)) +#define G_MENU_MODEL_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_MENU_MODEL, GMenuModelClass)) + +typedef struct _GMenuModelPrivate GMenuModelPrivate; +typedef struct _GMenuModelClass GMenuModelClass; + +typedef struct _GMenuAttributeIterPrivate GMenuAttributeIterPrivate; +typedef struct _GMenuAttributeIterClass GMenuAttributeIterClass; +typedef struct _GMenuAttributeIter GMenuAttributeIter; + +typedef struct _GMenuLinkIterPrivate GMenuLinkIterPrivate; +typedef struct _GMenuLinkIterClass GMenuLinkIterClass; +typedef struct _GMenuLinkIter GMenuLinkIter; + +struct _GMenuModel +{ + GObject parent_instance; + GMenuModelPrivate *priv; +}; + +/** + * GMenuModelClass::get_item_attributes: + * @model: the #GMenuModel to query + * @item_index: The #GMenuItem to query + * @attributes: (out) (element-type utf8 GLib.Variant): Attributes on the item + * + * Gets all the attributes associated with the item in the menu model. + */ +/** + * GMenuModelClass::get_item_links: + * @model: the #GMenuModel to query + * @item_index: The #GMenuItem to query + * @links: (out) (element-type utf8 Gio.MenuModel): Links from the item + * + * Gets all the links associated with the item in the menu model. + */ +struct _GMenuModelClass +{ + GObjectClass parent_class; + + gboolean (*is_mutable) (GMenuModel *model); + gint (*get_n_items) (GMenuModel *model); + void (*get_item_attributes) (GMenuModel *model, + gint item_index, + GHashTable **attributes); + GMenuAttributeIter * (*iterate_item_attributes) (GMenuModel *model, + gint item_index); + GVariant * (*get_item_attribute_value) (GMenuModel *model, + gint item_index, + const gchar *attribute, + const GVariantType *expected_type); + void (*get_item_links) (GMenuModel *model, + gint item_index, + GHashTable **links); + GMenuLinkIter * (*iterate_item_links) (GMenuModel *model, + gint item_index); + GMenuModel * (*get_item_link) (GMenuModel *model, + gint item_index, + const gchar *link); +}; + +GIO_AVAILABLE_IN_2_32 +GType g_menu_model_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +gboolean g_menu_model_is_mutable (GMenuModel *model); +GIO_AVAILABLE_IN_2_32 +gint g_menu_model_get_n_items (GMenuModel *model); + +GIO_AVAILABLE_IN_2_32 +GMenuAttributeIter * g_menu_model_iterate_item_attributes (GMenuModel *model, + gint item_index); +GIO_AVAILABLE_IN_2_32 +GVariant * g_menu_model_get_item_attribute_value (GMenuModel *model, + gint item_index, + const gchar *attribute, + const GVariantType *expected_type); +GIO_AVAILABLE_IN_2_32 +gboolean g_menu_model_get_item_attribute (GMenuModel *model, + gint item_index, + const gchar *attribute, + const gchar *format_string, + ...); +GIO_AVAILABLE_IN_2_32 +GMenuLinkIter * g_menu_model_iterate_item_links (GMenuModel *model, + gint item_index); +GIO_AVAILABLE_IN_2_32 +GMenuModel * g_menu_model_get_item_link (GMenuModel *model, + gint item_index, + const gchar *link); + +GIO_AVAILABLE_IN_2_32 +void g_menu_model_items_changed (GMenuModel *model, + gint position, + gint removed, + gint added); + + +#define G_TYPE_MENU_ATTRIBUTE_ITER (g_menu_attribute_iter_get_type ()) +#define G_MENU_ATTRIBUTE_ITER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIter)) +#define G_MENU_ATTRIBUTE_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass)) +#define G_IS_MENU_ATTRIBUTE_ITER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_MENU_ATTRIBUTE_ITER)) +#define G_IS_MENU_ATTRIBUTE_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_MENU_ATTRIBUTE_ITER)) +#define G_MENU_ATTRIBUTE_ITER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_MENU_ATTRIBUTE_ITER, GMenuAttributeIterClass)) + +struct _GMenuAttributeIter +{ + GObject parent_instance; + GMenuAttributeIterPrivate *priv; +}; + +struct _GMenuAttributeIterClass +{ + GObjectClass parent_class; + + gboolean (*get_next) (GMenuAttributeIter *iter, + const gchar **out_name, + GVariant **value); +}; + +GIO_AVAILABLE_IN_2_32 +GType g_menu_attribute_iter_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +gboolean g_menu_attribute_iter_get_next (GMenuAttributeIter *iter, + const gchar **out_name, + GVariant **value); +GIO_AVAILABLE_IN_2_32 +gboolean g_menu_attribute_iter_next (GMenuAttributeIter *iter); +GIO_AVAILABLE_IN_2_32 +const gchar * g_menu_attribute_iter_get_name (GMenuAttributeIter *iter); +GIO_AVAILABLE_IN_2_32 +GVariant * g_menu_attribute_iter_get_value (GMenuAttributeIter *iter); + + +#define G_TYPE_MENU_LINK_ITER (g_menu_link_iter_get_type ()) +#define G_MENU_LINK_ITER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_MENU_LINK_ITER, GMenuLinkIter)) +#define G_MENU_LINK_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass)) +#define G_IS_MENU_LINK_ITER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_MENU_LINK_ITER)) +#define G_IS_MENU_LINK_ITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_MENU_LINK_ITER)) +#define G_MENU_LINK_ITER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_MENU_LINK_ITER, GMenuLinkIterClass)) + +struct _GMenuLinkIter +{ + GObject parent_instance; + GMenuLinkIterPrivate *priv; +}; + +struct _GMenuLinkIterClass +{ + GObjectClass parent_class; + + gboolean (*get_next) (GMenuLinkIter *iter, + const gchar **out_link, + GMenuModel **value); +}; + +GIO_AVAILABLE_IN_2_32 +GType g_menu_link_iter_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +gboolean g_menu_link_iter_get_next (GMenuLinkIter *iter, + const gchar **out_link, + GMenuModel **value); +GIO_AVAILABLE_IN_2_32 +gboolean g_menu_link_iter_next (GMenuLinkIter *iter); +GIO_AVAILABLE_IN_2_32 +const gchar * g_menu_link_iter_get_name (GMenuLinkIter *iter); +GIO_AVAILABLE_IN_2_32 +GMenuModel * g_menu_link_iter_get_value (GMenuLinkIter *iter); + +G_END_DECLS + +#endif /* __G_MENU_MODEL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gmount.h b/illumos-x86_64/usr/include/glib-2.0/gio/gmount.h new file mode 100644 index 00000000..c17f79b3 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gmount.h @@ -0,0 +1,278 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2008 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + * David Zeuthen + */ + +#ifndef __G_MOUNT_H__ +#define __G_MOUNT_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_MOUNT (g_mount_get_type ()) +#define G_MOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_MOUNT, GMount)) +#define G_IS_MOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_MOUNT)) +#define G_MOUNT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_MOUNT, GMountIface)) + +typedef struct _GMountIface GMountIface; + +/** + * GMountIface: + * @g_iface: The parent interface. + * @changed: Changed signal that is emitted when the mount's state has changed. + * @unmounted: The unmounted signal that is emitted when the #GMount have been unmounted. If the recipient is holding references to the object they should release them so the object can be finalized. + * @pre_unmount: The ::pre-unmount signal that is emitted when the #GMount will soon be emitted. If the recipient is somehow holding the mount open by keeping an open file on it it should close the file. + * @get_root: Gets a #GFile to the root directory of the #GMount. + * @get_name: Gets a string containing the name of the #GMount. + * @get_icon: Gets a #GIcon for the #GMount. + * @get_uuid: Gets the UUID for the #GMount. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returns %NULL if there is no UUID available. + * @get_volume: Gets a #GVolume the mount is located on. Returns %NULL if the #GMount is not associated with a #GVolume. + * @get_drive: Gets a #GDrive the volume of the mount is located on. Returns %NULL if the #GMount is not associated with a #GDrive or a #GVolume. This is convenience method for getting the #GVolume and using that to get the #GDrive. + * @can_unmount: Checks if a #GMount can be unmounted. + * @can_eject: Checks if a #GMount can be ejected. + * @unmount: Starts unmounting a #GMount. + * @unmount_finish: Finishes an unmounting operation. + * @eject: Starts ejecting a #GMount. + * @eject_finish: Finishes an eject operation. + * @remount: Starts remounting a #GMount. + * @remount_finish: Finishes a remounting operation. + * @guess_content_type: Starts guessing the type of the content of a #GMount. + * See g_mount_guess_content_type() for more information on content + * type guessing. This operation was added in 2.18. + * @guess_content_type_finish: Finishes a content type guessing operation. Added in 2.18. + * @guess_content_type_sync: Synchronous variant of @guess_content_type. Added in 2.18 + * @unmount_with_operation: Starts unmounting a #GMount using a #GMountOperation. Since 2.22. + * @unmount_with_operation_finish: Finishes an unmounting operation using a #GMountOperation. Since 2.22. + * @eject_with_operation: Starts ejecting a #GMount using a #GMountOperation. Since 2.22. + * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22. + * @get_default_location: Gets a #GFile indication a start location that can be use as the entry point for this mount. Since 2.24. + * @get_sort_key: Gets a key used for sorting #GMount instance or %NULL if no such key exists. Since 2.32. + * @get_symbolic_icon: Gets a symbolic #GIcon for the #GMount. Since 2.34. + * + * Interface for implementing operations for mounts. + **/ +struct _GMountIface +{ + GTypeInterface g_iface; + + /* signals */ + + void (* changed) (GMount *mount); + void (* unmounted) (GMount *mount); + + /* Virtual Table */ + + GFile * (* get_root) (GMount *mount); + char * (* get_name) (GMount *mount); + GIcon * (* get_icon) (GMount *mount); + char * (* get_uuid) (GMount *mount); + GVolume * (* get_volume) (GMount *mount); + GDrive * (* get_drive) (GMount *mount); + gboolean (* can_unmount) (GMount *mount); + gboolean (* can_eject) (GMount *mount); + + void (* unmount) (GMount *mount, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* unmount_finish) (GMount *mount, + GAsyncResult *result, + GError **error); + + void (* eject) (GMount *mount, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* eject_finish) (GMount *mount, + GAsyncResult *result, + GError **error); + + void (* remount) (GMount *mount, + GMountMountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* remount_finish) (GMount *mount, + GAsyncResult *result, + GError **error); + + void (* guess_content_type) (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gchar ** (* guess_content_type_finish) (GMount *mount, + GAsyncResult *result, + GError **error); + gchar ** (* guess_content_type_sync) (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GError **error); + + /* Signal, not VFunc */ + void (* pre_unmount) (GMount *mount); + + void (* unmount_with_operation) (GMount *mount, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* unmount_with_operation_finish) (GMount *mount, + GAsyncResult *result, + GError **error); + + void (* eject_with_operation) (GMount *mount, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* eject_with_operation_finish) (GMount *mount, + GAsyncResult *result, + GError **error); + GFile * (* get_default_location) (GMount *mount); + + const gchar * (* get_sort_key) (GMount *mount); + GIcon * (* get_symbolic_icon) (GMount *mount); +}; + +GIO_AVAILABLE_IN_ALL +GType g_mount_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GFile * g_mount_get_root (GMount *mount); +GIO_AVAILABLE_IN_ALL +GFile * g_mount_get_default_location (GMount *mount); +GIO_AVAILABLE_IN_ALL +char * g_mount_get_name (GMount *mount); +GIO_AVAILABLE_IN_ALL +GIcon * g_mount_get_icon (GMount *mount); +GIO_AVAILABLE_IN_ALL +GIcon * g_mount_get_symbolic_icon (GMount *mount); +GIO_AVAILABLE_IN_ALL +char * g_mount_get_uuid (GMount *mount); +GIO_AVAILABLE_IN_ALL +GVolume * g_mount_get_volume (GMount *mount); +GIO_AVAILABLE_IN_ALL +GDrive * g_mount_get_drive (GMount *mount); +GIO_AVAILABLE_IN_ALL +gboolean g_mount_can_unmount (GMount *mount); +GIO_AVAILABLE_IN_ALL +gboolean g_mount_can_eject (GMount *mount); + +GIO_DEPRECATED_FOR(g_mount_unmount_with_operation) +void g_mount_unmount (GMount *mount, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_DEPRECATED_FOR(g_mount_unmount_with_operation_finish) +gboolean g_mount_unmount_finish (GMount *mount, + GAsyncResult *result, + GError **error); + +GIO_DEPRECATED_FOR(g_mount_eject_with_operation) +void g_mount_eject (GMount *mount, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_DEPRECATED_FOR(g_mount_eject_with_operation_finish) +gboolean g_mount_eject_finish (GMount *mount, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_mount_remount (GMount *mount, + GMountMountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_mount_remount_finish (GMount *mount, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_mount_guess_content_type (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gchar ** g_mount_guess_content_type_finish (GMount *mount, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +gchar ** g_mount_guess_content_type_sync (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_mount_is_shadowed (GMount *mount); +GIO_AVAILABLE_IN_ALL +void g_mount_shadow (GMount *mount); +GIO_AVAILABLE_IN_ALL +void g_mount_unshadow (GMount *mount); + +GIO_AVAILABLE_IN_ALL +void g_mount_unmount_with_operation (GMount *mount, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_mount_unmount_with_operation_finish (GMount *mount, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_mount_eject_with_operation (GMount *mount, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_mount_eject_with_operation_finish (GMount *mount, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +const gchar *g_mount_get_sort_key (GMount *mount); + +G_END_DECLS + +#endif /* __G_MOUNT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gmountoperation.h b/illumos-x86_64/usr/include/glib-2.0/gio/gmountoperation.h new file mode 100644 index 00000000..3302ec56 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gmountoperation.h @@ -0,0 +1,173 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_MOUNT_OPERATION_H__ +#define __G_MOUNT_OPERATION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_MOUNT_OPERATION (g_mount_operation_get_type ()) +#define G_MOUNT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MOUNT_OPERATION, GMountOperation)) +#define G_MOUNT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MOUNT_OPERATION, GMountOperationClass)) +#define G_IS_MOUNT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MOUNT_OPERATION)) +#define G_IS_MOUNT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MOUNT_OPERATION)) +#define G_MOUNT_OPERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MOUNT_OPERATION, GMountOperationClass)) + +typedef struct _GMountOperationClass GMountOperationClass; +typedef struct _GMountOperationPrivate GMountOperationPrivate; + +struct _GMountOperation +{ + GObject parent_instance; + + GMountOperationPrivate *priv; +}; + +struct _GMountOperationClass +{ + GObjectClass parent_class; + + /* signals: */ + + void (* ask_password) (GMountOperation *op, + const char *message, + const char *default_user, + const char *default_domain, + GAskPasswordFlags flags); + + /** + * GMountOperationClass::ask_question: + * @op: a #GMountOperation + * @message: string containing a message to display to the user + * @choices: (array zero-terminated=1) (element-type utf8): an array of + * strings for each possible choice + * + * Virtual implementation of #GMountOperation::ask-question. + */ + void (* ask_question) (GMountOperation *op, + const char *message, + const char *choices[]); + + void (* reply) (GMountOperation *op, + GMountOperationResult result); + + void (* aborted) (GMountOperation *op); + + /** + * GMountOperationClass::show_processes: + * @op: a #GMountOperation + * @message: string containing a message to display to the user + * @processes: (element-type GPid): an array of #GPid for processes blocking + * the operation + * @choices: (array zero-terminated=1) (element-type utf8): an array of + * strings for each possible choice + * + * Virtual implementation of #GMountOperation::show-processes. + * + * Since: 2.22 + */ + void (* show_processes) (GMountOperation *op, + const gchar *message, + GArray *processes, + const gchar *choices[]); + + void (* show_unmount_progress) (GMountOperation *op, + const gchar *message, + gint64 time_left, + gint64 bytes_left); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); + void (*_g_reserved7) (void); + void (*_g_reserved8) (void); + void (*_g_reserved9) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_mount_operation_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GMountOperation * g_mount_operation_new (void); + +GIO_AVAILABLE_IN_ALL +const char * g_mount_operation_get_username (GMountOperation *op); +GIO_AVAILABLE_IN_ALL +void g_mount_operation_set_username (GMountOperation *op, + const char *username); +GIO_AVAILABLE_IN_ALL +const char * g_mount_operation_get_password (GMountOperation *op); +GIO_AVAILABLE_IN_ALL +void g_mount_operation_set_password (GMountOperation *op, + const char *password); +GIO_AVAILABLE_IN_ALL +gboolean g_mount_operation_get_anonymous (GMountOperation *op); +GIO_AVAILABLE_IN_ALL +void g_mount_operation_set_anonymous (GMountOperation *op, + gboolean anonymous); +GIO_AVAILABLE_IN_ALL +const char * g_mount_operation_get_domain (GMountOperation *op); +GIO_AVAILABLE_IN_ALL +void g_mount_operation_set_domain (GMountOperation *op, + const char *domain); +GIO_AVAILABLE_IN_ALL +GPasswordSave g_mount_operation_get_password_save (GMountOperation *op); +GIO_AVAILABLE_IN_ALL +void g_mount_operation_set_password_save (GMountOperation *op, + GPasswordSave save); +GIO_AVAILABLE_IN_ALL +int g_mount_operation_get_choice (GMountOperation *op); +GIO_AVAILABLE_IN_ALL +void g_mount_operation_set_choice (GMountOperation *op, + int choice); +GIO_AVAILABLE_IN_ALL +void g_mount_operation_reply (GMountOperation *op, + GMountOperationResult result); +GIO_AVAILABLE_IN_2_58 +gboolean g_mount_operation_get_is_tcrypt_hidden_volume (GMountOperation *op); +GIO_AVAILABLE_IN_2_58 +void g_mount_operation_set_is_tcrypt_hidden_volume (GMountOperation *op, + gboolean hidden_volume); +GIO_AVAILABLE_IN_2_58 +gboolean g_mount_operation_get_is_tcrypt_system_volume (GMountOperation *op); +GIO_AVAILABLE_IN_2_58 +void g_mount_operation_set_is_tcrypt_system_volume (GMountOperation *op, + gboolean system_volume); +GIO_AVAILABLE_IN_2_58 +guint g_mount_operation_get_pim (GMountOperation *op); +GIO_AVAILABLE_IN_2_58 +void g_mount_operation_set_pim (GMountOperation *op, + guint pim); + +G_END_DECLS + +#endif /* __G_MOUNT_OPERATION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gnativesocketaddress.h b/illumos-x86_64/usr/include/glib-2.0/gio/gnativesocketaddress.h new file mode 100644 index 00000000..cd174ec8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gnativesocketaddress.h @@ -0,0 +1,67 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Christian Kellner + * Samuel Cormier-Iijima + */ + +#ifndef __G_NATIVE_SOCKET_ADDRESS_H__ +#define __G_NATIVE_SOCKET_ADDRESS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_NATIVE_SOCKET_ADDRESS (g_native_socket_address_get_type ()) +#define G_NATIVE_SOCKET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NATIVE_SOCKET_ADDRESS, GNativeSocketAddress)) +#define G_NATIVE_SOCKET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_NATIVE_SOCKET_ADDRESS, GNativeSocketAddressClass)) +#define G_IS_NATIVE_SOCKET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NATIVE_SOCKET_ADDRESS)) +#define G_IS_NATIVE_SOCKET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_NATIVE_SOCKET_ADDRESS)) +#define G_NATIVE_SOCKET_ADDRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_NATIVE_SOCKET_ADDRESS, GNativeSocketAddressClass)) + +typedef struct _GNativeSocketAddressClass GNativeSocketAddressClass; +typedef struct _GNativeSocketAddressPrivate GNativeSocketAddressPrivate; + +struct _GNativeSocketAddress +{ + GSocketAddress parent_instance; + + /*< private >*/ + GNativeSocketAddressPrivate *priv; +}; + +struct _GNativeSocketAddressClass +{ + GSocketAddressClass parent_class; +}; + +GIO_AVAILABLE_IN_2_46 +GType g_native_socket_address_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_46 +GSocketAddress *g_native_socket_address_new (gpointer native, + gsize len); + +G_END_DECLS + +#endif /* __G_NATIVE_SOCKET_ADDRESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gnativevolumemonitor.h b/illumos-x86_64/usr/include/glib-2.0/gio/gnativevolumemonitor.h new file mode 100644 index 00000000..9cea184b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gnativevolumemonitor.h @@ -0,0 +1,63 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_NATIVE_VOLUME_MONITOR_H__ +#define __G_NATIVE_VOLUME_MONITOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_NATIVE_VOLUME_MONITOR (g_native_volume_monitor_get_type ()) +#define G_NATIVE_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NATIVE_VOLUME_MONITOR, GNativeVolumeMonitor)) +#define G_NATIVE_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_NATIVE_VOLUME_MONITOR, GNativeVolumeMonitorClass)) +#define G_IS_NATIVE_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NATIVE_VOLUME_MONITOR)) +#define G_IS_NATIVE_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_NATIVE_VOLUME_MONITOR)) + +#define G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME "gio-native-volume-monitor" + +typedef struct _GNativeVolumeMonitor GNativeVolumeMonitor; +typedef struct _GNativeVolumeMonitorClass GNativeVolumeMonitorClass; + +struct _GNativeVolumeMonitor +{ + GVolumeMonitor parent_instance; +}; + +struct _GNativeVolumeMonitorClass +{ + GVolumeMonitorClass parent_class; + + GMount * (* get_mount_for_mount_path) (const char *mount_path, + GCancellable *cancellable); +}; + +GIO_AVAILABLE_IN_ALL +GType g_native_volume_monitor_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_NATIVE_VOLUME_MONITOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkaddress.h b/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkaddress.h new file mode 100644 index 00000000..0a12d852 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkaddress.h @@ -0,0 +1,82 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_NETWORK_ADDRESS_H__ +#define __G_NETWORK_ADDRESS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_NETWORK_ADDRESS (g_network_address_get_type ()) +#define G_NETWORK_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NETWORK_ADDRESS, GNetworkAddress)) +#define G_NETWORK_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_NETWORK_ADDRESS, GNetworkAddressClass)) +#define G_IS_NETWORK_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NETWORK_ADDRESS)) +#define G_IS_NETWORK_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_NETWORK_ADDRESS)) +#define G_NETWORK_ADDRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_NETWORK_ADDRESS, GNetworkAddressClass)) + +typedef struct _GNetworkAddressClass GNetworkAddressClass; +typedef struct _GNetworkAddressPrivate GNetworkAddressPrivate; + +struct _GNetworkAddress +{ + GObject parent_instance; + + /*< private >*/ + GNetworkAddressPrivate *priv; +}; + +struct _GNetworkAddressClass +{ + GObjectClass parent_class; + +}; + +GIO_AVAILABLE_IN_ALL +GType g_network_address_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketConnectable *g_network_address_new (const gchar *hostname, + guint16 port); +GIO_AVAILABLE_IN_2_44 +GSocketConnectable *g_network_address_new_loopback (guint16 port); +GIO_AVAILABLE_IN_ALL +GSocketConnectable *g_network_address_parse (const gchar *host_and_port, + guint16 default_port, + GError **error); +GIO_AVAILABLE_IN_ALL +GSocketConnectable *g_network_address_parse_uri (const gchar *uri, + guint16 default_port, + GError **error); +GIO_AVAILABLE_IN_ALL +const gchar *g_network_address_get_hostname (GNetworkAddress *addr); +GIO_AVAILABLE_IN_ALL +guint16 g_network_address_get_port (GNetworkAddress *addr); +GIO_AVAILABLE_IN_ALL +const gchar *g_network_address_get_scheme (GNetworkAddress *addr); + + +G_END_DECLS + +#endif /* __G_NETWORK_ADDRESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gnetworking.h b/illumos-x86_64/usr/include/glib-2.0/gio/gnetworking.h new file mode 100644 index 00000000..da3dcc5e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gnetworking.h @@ -0,0 +1,85 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008-2011 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_NETWORKING_H__ +#define __G_NETWORKING_H__ + +#include +#include + +#ifdef G_OS_WIN32 +#include +#include +#include +#include +#include +#include +#undef interface + +#else /* !G_OS_WIN32 */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#ifndef __GI_SCANNER__ + +#ifndef T_SRV +#define T_SRV 33 +#endif + +#ifndef _PATH_RESCONF +#define _PATH_RESCONF "/etc/resolv.conf" +#endif + +#ifndef CMSG_LEN +/* CMSG_LEN and CMSG_SPACE are defined by RFC 2292, but missing on + * some older platforms. + */ +#define CMSG_LEN(len) ((size_t)CMSG_DATA((struct cmsghdr *)NULL) + (len)) + +/* CMSG_SPACE must add at least as much padding as CMSG_NXTHDR() + * adds. We overestimate here. + */ +#define GLIB_ALIGN_TO_SIZEOF(len, obj) (((len) + sizeof (obj) - 1) & ~(sizeof (obj) - 1)) +#define CMSG_SPACE(len) GLIB_ALIGN_TO_SIZEOF (CMSG_LEN (len), struct cmsghdr) +#endif +#endif + +#endif /* !__GI_SCANNER__ */ + +G_BEGIN_DECLS + +GIO_AVAILABLE_IN_2_36 +void g_networking_init (void); + +G_END_DECLS + +#endif /* __G_NETWORKING_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkmonitor.h b/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkmonitor.h new file mode 100644 index 00000000..387c0452 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkmonitor.h @@ -0,0 +1,101 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright 2011 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_NETWORK_MONITOR_H__ +#define __G_NETWORK_MONITOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_NETWORK_MONITOR_EXTENSION_POINT_NAME: + * + * Extension point for network status monitoring functionality. + * See [Extending GIO](overview.html#extending-gio). + * + * Since: 2.30 + */ +#define G_NETWORK_MONITOR_EXTENSION_POINT_NAME "gio-network-monitor" + +#define G_TYPE_NETWORK_MONITOR (g_network_monitor_get_type ()) +#define G_NETWORK_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NETWORK_MONITOR, GNetworkMonitor)) +#define G_IS_NETWORK_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NETWORK_MONITOR)) +#define G_NETWORK_MONITOR_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), G_TYPE_NETWORK_MONITOR, GNetworkMonitorInterface)) + +typedef struct _GNetworkMonitorInterface GNetworkMonitorInterface; + +struct _GNetworkMonitorInterface { + GTypeInterface g_iface; + + void (*network_changed) (GNetworkMonitor *monitor, + gboolean network_available); + + gboolean (*can_reach) (GNetworkMonitor *monitor, + GSocketConnectable *connectable, + GCancellable *cancellable, + GError **error); + void (*can_reach_async) (GNetworkMonitor *monitor, + GSocketConnectable *connectable, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*can_reach_finish) (GNetworkMonitor *monitor, + GAsyncResult *result, + GError **error); +}; + +GIO_AVAILABLE_IN_2_32 +GType g_network_monitor_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_2_32 +GNetworkMonitor *g_network_monitor_get_default (void); + +GIO_AVAILABLE_IN_2_32 +gboolean g_network_monitor_get_network_available (GNetworkMonitor *monitor); + +GIO_AVAILABLE_IN_2_46 +gboolean g_network_monitor_get_network_metered (GNetworkMonitor *monitor); + +GIO_AVAILABLE_IN_2_44 +GNetworkConnectivity g_network_monitor_get_connectivity (GNetworkMonitor *monitor); + +GIO_AVAILABLE_IN_2_32 +gboolean g_network_monitor_can_reach (GNetworkMonitor *monitor, + GSocketConnectable *connectable, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_32 +void g_network_monitor_can_reach_async (GNetworkMonitor *monitor, + GSocketConnectable *connectable, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_32 +gboolean g_network_monitor_can_reach_finish (GNetworkMonitor *monitor, + GAsyncResult *result, + GError **error); + +G_END_DECLS + +#endif /* __G_NETWORK_MONITOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkservice.h b/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkservice.h new file mode 100644 index 00000000..ac00986d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gnetworkservice.h @@ -0,0 +1,77 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_NETWORK_SERVICE_H__ +#define __G_NETWORK_SERVICE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_NETWORK_SERVICE (g_network_service_get_type ()) +#define G_NETWORK_SERVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NETWORK_SERVICE, GNetworkService)) +#define G_NETWORK_SERVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_NETWORK_SERVICE, GNetworkServiceClass)) +#define G_IS_NETWORK_SERVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NETWORK_SERVICE)) +#define G_IS_NETWORK_SERVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_NETWORK_SERVICE)) +#define G_NETWORK_SERVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_NETWORK_SERVICE, GNetworkServiceClass)) + +typedef struct _GNetworkServiceClass GNetworkServiceClass; +typedef struct _GNetworkServicePrivate GNetworkServicePrivate; + +struct _GNetworkService +{ + GObject parent_instance; + + /*< private >*/ + GNetworkServicePrivate *priv; +}; + +struct _GNetworkServiceClass +{ + GObjectClass parent_class; + +}; + +GIO_AVAILABLE_IN_ALL +GType g_network_service_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketConnectable *g_network_service_new (const gchar *service, + const gchar *protocol, + const gchar *domain); + +GIO_AVAILABLE_IN_ALL +const gchar *g_network_service_get_service (GNetworkService *srv); +GIO_AVAILABLE_IN_ALL +const gchar *g_network_service_get_protocol (GNetworkService *srv); +GIO_AVAILABLE_IN_ALL +const gchar *g_network_service_get_domain (GNetworkService *srv); +GIO_AVAILABLE_IN_ALL +const gchar *g_network_service_get_scheme (GNetworkService *srv); +GIO_AVAILABLE_IN_ALL +void g_network_service_set_scheme (GNetworkService *srv, const gchar *scheme); + +G_END_DECLS + +#endif /* __G_NETWORK_SERVICE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gnotification.h b/illumos-x86_64/usr/include/glib-2.0/gio/gnotification.h new file mode 100644 index 00000000..cef00a73 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gnotification.h @@ -0,0 +1,103 @@ +/* + * Copyright © 2013 Lars Uebernickel + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Lars Uebernickel + */ + +#ifndef __G_NOTIFICATION_H__ +#define __G_NOTIFICATION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_NOTIFICATION (g_notification_get_type ()) +#define G_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NOTIFICATION, GNotification)) +#define G_IS_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NOTIFICATION)) + +GIO_AVAILABLE_IN_2_40 +GType g_notification_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_40 +GNotification * g_notification_new (const gchar *title); + +GIO_AVAILABLE_IN_2_40 +void g_notification_set_title (GNotification *notification, + const gchar *title); + +GIO_AVAILABLE_IN_2_40 +void g_notification_set_body (GNotification *notification, + const gchar *body); + +GIO_AVAILABLE_IN_2_40 +void g_notification_set_icon (GNotification *notification, + GIcon *icon); + +GIO_DEPRECATED_IN_2_42_FOR(g_notification_set_priority) +void g_notification_set_urgent (GNotification *notification, + gboolean urgent); + +GIO_AVAILABLE_IN_2_42 +void g_notification_set_priority (GNotification *notification, + GNotificationPriority priority); + +GIO_AVAILABLE_IN_2_70 +void g_notification_set_category (GNotification *notification, + const gchar *category); + +GIO_AVAILABLE_IN_2_40 +void g_notification_add_button (GNotification *notification, + const gchar *label, + const gchar *detailed_action); + +GIO_AVAILABLE_IN_2_40 +void g_notification_add_button_with_target (GNotification *notification, + const gchar *label, + const gchar *action, + const gchar *target_format, + ...); + +GIO_AVAILABLE_IN_2_40 +void g_notification_add_button_with_target_value (GNotification *notification, + const gchar *label, + const gchar *action, + GVariant *target); + +GIO_AVAILABLE_IN_2_40 +void g_notification_set_default_action (GNotification *notification, + const gchar *detailed_action); + +GIO_AVAILABLE_IN_2_40 +void g_notification_set_default_action_and_target (GNotification *notification, + const gchar *action, + const gchar *target_format, + ...); + +GIO_AVAILABLE_IN_2_40 +void g_notification_set_default_action_and_target_value (GNotification *notification, + const gchar *action, + GVariant *target); + +G_END_DECLS + +#endif diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/goutputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/goutputstream.h new file mode 100644 index 00000000..2ee1cbb0 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/goutputstream.h @@ -0,0 +1,325 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_OUTPUT_STREAM_H__ +#define __G_OUTPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_OUTPUT_STREAM (g_output_stream_get_type ()) +#define G_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_OUTPUT_STREAM, GOutputStream)) +#define G_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_OUTPUT_STREAM, GOutputStreamClass)) +#define G_IS_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_OUTPUT_STREAM)) +#define G_IS_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_OUTPUT_STREAM)) +#define G_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_OUTPUT_STREAM, GOutputStreamClass)) + +typedef struct _GOutputStreamClass GOutputStreamClass; +typedef struct _GOutputStreamPrivate GOutputStreamPrivate; + +struct _GOutputStream +{ + GObject parent_instance; + + /*< private >*/ + GOutputStreamPrivate *priv; +}; + + +struct _GOutputStreamClass +{ + GObjectClass parent_class; + + /* Sync ops: */ + + gssize (* write_fn) (GOutputStream *stream, + const void *buffer, + gsize count, + GCancellable *cancellable, + GError **error); + gssize (* splice) (GOutputStream *stream, + GInputStream *source, + GOutputStreamSpliceFlags flags, + GCancellable *cancellable, + GError **error); + gboolean (* flush) (GOutputStream *stream, + GCancellable *cancellable, + GError **error); + gboolean (* close_fn) (GOutputStream *stream, + GCancellable *cancellable, + GError **error); + + /* Async ops: (optional in derived classes) */ + + void (* write_async) (GOutputStream *stream, + const void *buffer, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gssize (* write_finish) (GOutputStream *stream, + GAsyncResult *result, + GError **error); + void (* splice_async) (GOutputStream *stream, + GInputStream *source, + GOutputStreamSpliceFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gssize (* splice_finish) (GOutputStream *stream, + GAsyncResult *result, + GError **error); + void (* flush_async) (GOutputStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* flush_finish) (GOutputStream *stream, + GAsyncResult *result, + GError **error); + void (* close_async) (GOutputStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* close_finish) (GOutputStream *stream, + GAsyncResult *result, + GError **error); + + gboolean (* writev_fn) (GOutputStream *stream, + const GOutputVector *vectors, + gsize n_vectors, + gsize *bytes_written, + GCancellable *cancellable, + GError **error); + + void (* writev_async) (GOutputStream *stream, + const GOutputVector *vectors, + gsize n_vectors, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + gboolean (* writev_finish) (GOutputStream *stream, + GAsyncResult *result, + gsize *bytes_written, + GError **error); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); + void (*_g_reserved7) (void); + void (*_g_reserved8) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_output_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gssize g_output_stream_write (GOutputStream *stream, + const void *buffer, + gsize count, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_write_all (GOutputStream *stream, + const void *buffer, + gsize count, + gsize *bytes_written, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_60 +gboolean g_output_stream_writev (GOutputStream *stream, + const GOutputVector *vectors, + gsize n_vectors, + gsize *bytes_written, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_60 +gboolean g_output_stream_writev_all (GOutputStream *stream, + GOutputVector *vectors, + gsize n_vectors, + gsize *bytes_written, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_40 +gboolean g_output_stream_printf (GOutputStream *stream, + gsize *bytes_written, + GCancellable *cancellable, + GError **error, + const gchar *format, + ...) G_GNUC_PRINTF (5, 6); +GIO_AVAILABLE_IN_2_40 +gboolean g_output_stream_vprintf (GOutputStream *stream, + gsize *bytes_written, + GCancellable *cancellable, + GError **error, + const gchar *format, + va_list args) G_GNUC_PRINTF (5, 0); +GIO_AVAILABLE_IN_2_34 +gssize g_output_stream_write_bytes (GOutputStream *stream, + GBytes *bytes, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_output_stream_splice (GOutputStream *stream, + GInputStream *source, + GOutputStreamSpliceFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_flush (GOutputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_close (GOutputStream *stream, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_output_stream_write_async (GOutputStream *stream, + const void *buffer, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gssize g_output_stream_write_finish (GOutputStream *stream, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_44 +void g_output_stream_write_all_async (GOutputStream *stream, + const void *buffer, + gsize count, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_44 +gboolean g_output_stream_write_all_finish (GOutputStream *stream, + GAsyncResult *result, + gsize *bytes_written, + GError **error); + +GIO_AVAILABLE_IN_2_60 +void g_output_stream_writev_async (GOutputStream *stream, + const GOutputVector *vectors, + gsize n_vectors, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_60 +gboolean g_output_stream_writev_finish (GOutputStream *stream, + GAsyncResult *result, + gsize *bytes_written, + GError **error); + +GIO_AVAILABLE_IN_2_60 +void g_output_stream_writev_all_async (GOutputStream *stream, + GOutputVector *vectors, + gsize n_vectors, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_60 +gboolean g_output_stream_writev_all_finish (GOutputStream *stream, + GAsyncResult *result, + gsize *bytes_written, + GError **error); + +GIO_AVAILABLE_IN_2_34 +void g_output_stream_write_bytes_async (GOutputStream *stream, + GBytes *bytes, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_34 +gssize g_output_stream_write_bytes_finish (GOutputStream *stream, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_output_stream_splice_async (GOutputStream *stream, + GInputStream *source, + GOutputStreamSpliceFlags flags, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gssize g_output_stream_splice_finish (GOutputStream *stream, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_output_stream_flush_async (GOutputStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_flush_finish (GOutputStream *stream, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_output_stream_close_async (GOutputStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_close_finish (GOutputStream *stream, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_is_closed (GOutputStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_is_closing (GOutputStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_has_pending (GOutputStream *stream); +GIO_AVAILABLE_IN_ALL +gboolean g_output_stream_set_pending (GOutputStream *stream, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_output_stream_clear_pending (GOutputStream *stream); + + +G_END_DECLS + +#endif /* __G_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gpermission.h b/illumos-x86_64/usr/include/glib-2.0/gio/gpermission.h new file mode 100644 index 00000000..828f6423 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gpermission.h @@ -0,0 +1,129 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_PERMISSION_H__ +#define __G_PERMISSION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_PERMISSION (g_permission_get_type ()) +#define G_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_PERMISSION, GPermission)) +#define G_PERMISSION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_PERMISSION, GPermissionClass)) +#define G_IS_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_PERMISSION)) +#define G_IS_PERMISSION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_PERMISSION)) +#define G_PERMISSION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_PERMISSION, GPermissionClass)) + +typedef struct _GPermissionPrivate GPermissionPrivate; +typedef struct _GPermissionClass GPermissionClass; + +struct _GPermission +{ + GObject parent_instance; + + /*< private >*/ + GPermissionPrivate *priv; +}; + +struct _GPermissionClass { + GObjectClass parent_class; + + gboolean (*acquire) (GPermission *permission, + GCancellable *cancellable, + GError **error); + void (*acquire_async) (GPermission *permission, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*acquire_finish) (GPermission *permission, + GAsyncResult *result, + GError **error); + + gboolean (*release) (GPermission *permission, + GCancellable *cancellable, + GError **error); + void (*release_async) (GPermission *permission, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*release_finish) (GPermission *permission, + GAsyncResult *result, + GError **error); + + gpointer reserved[16]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_permission_get_type (void); +GIO_AVAILABLE_IN_ALL +gboolean g_permission_acquire (GPermission *permission, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_permission_acquire_async (GPermission *permission, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_permission_acquire_finish (GPermission *permission, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_permission_release (GPermission *permission, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_permission_release_async (GPermission *permission, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_permission_release_finish (GPermission *permission, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_permission_get_allowed (GPermission *permission); +GIO_AVAILABLE_IN_ALL +gboolean g_permission_get_can_acquire (GPermission *permission); +GIO_AVAILABLE_IN_ALL +gboolean g_permission_get_can_release (GPermission *permission); + +GIO_AVAILABLE_IN_ALL +void g_permission_impl_update (GPermission *permission, + gboolean allowed, + gboolean can_acquire, + gboolean can_release); + +G_END_DECLS + +#endif /* __G_PERMISSION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gpollableinputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gpollableinputstream.h new file mode 100644 index 00000000..924b52ee --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gpollableinputstream.h @@ -0,0 +1,99 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_POLLABLE_INPUT_STREAM_H__ +#define __G_POLLABLE_INPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_POLLABLE_INPUT_STREAM (g_pollable_input_stream_get_type ()) +#define G_POLLABLE_INPUT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_POLLABLE_INPUT_STREAM, GPollableInputStream)) +#define G_IS_POLLABLE_INPUT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_POLLABLE_INPUT_STREAM)) +#define G_POLLABLE_INPUT_STREAM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_POLLABLE_INPUT_STREAM, GPollableInputStreamInterface)) + +typedef struct _GPollableInputStreamInterface GPollableInputStreamInterface; + +/** + * GPollableInputStreamInterface: + * @g_iface: The parent interface. + * @can_poll: Checks if the #GPollableInputStream instance is actually pollable + * @is_readable: Checks if the stream is readable + * @create_source: Creates a #GSource to poll the stream + * @read_nonblocking: Does a non-blocking read or returns + * %G_IO_ERROR_WOULD_BLOCK + * + * The interface for pollable input streams. + * + * The default implementation of @can_poll always returns %TRUE. + * + * The default implementation of @read_nonblocking calls + * g_pollable_input_stream_is_readable(), and then calls + * g_input_stream_read() if it returns %TRUE. This means you only need + * to override it if it is possible that your @is_readable + * implementation may return %TRUE when the stream is not actually + * readable. + * + * Since: 2.28 + */ +struct _GPollableInputStreamInterface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + gboolean (*can_poll) (GPollableInputStream *stream); + + gboolean (*is_readable) (GPollableInputStream *stream); + GSource * (*create_source) (GPollableInputStream *stream, + GCancellable *cancellable); + gssize (*read_nonblocking) (GPollableInputStream *stream, + void *buffer, + gsize count, + GError **error); +}; + +GIO_AVAILABLE_IN_ALL +GType g_pollable_input_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gboolean g_pollable_input_stream_can_poll (GPollableInputStream *stream); + +GIO_AVAILABLE_IN_ALL +gboolean g_pollable_input_stream_is_readable (GPollableInputStream *stream); +GIO_AVAILABLE_IN_ALL +GSource *g_pollable_input_stream_create_source (GPollableInputStream *stream, + GCancellable *cancellable); + +GIO_AVAILABLE_IN_ALL +gssize g_pollable_input_stream_read_nonblocking (GPollableInputStream *stream, + void *buffer, + gsize count, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + + +#endif /* __G_POLLABLE_INPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gpollableoutputstream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gpollableoutputstream.h new file mode 100644 index 00000000..e20c2f3b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gpollableoutputstream.h @@ -0,0 +1,120 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_POLLABLE_OUTPUT_STREAM_H__ +#define __G_POLLABLE_OUTPUT_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_POLLABLE_OUTPUT_STREAM (g_pollable_output_stream_get_type ()) +#define G_POLLABLE_OUTPUT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_POLLABLE_OUTPUT_STREAM, GPollableOutputStream)) +#define G_IS_POLLABLE_OUTPUT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_POLLABLE_OUTPUT_STREAM)) +#define G_POLLABLE_OUTPUT_STREAM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_POLLABLE_OUTPUT_STREAM, GPollableOutputStreamInterface)) + +typedef struct _GPollableOutputStreamInterface GPollableOutputStreamInterface; + +/** + * GPollableOutputStreamInterface: + * @g_iface: The parent interface. + * @can_poll: Checks if the #GPollableOutputStream instance is actually pollable + * @is_writable: Checks if the stream is writable + * @create_source: Creates a #GSource to poll the stream + * @write_nonblocking: Does a non-blocking write or returns + * %G_IO_ERROR_WOULD_BLOCK + * @writev_nonblocking: Does a vectored non-blocking write, or returns + * %G_POLLABLE_RETURN_WOULD_BLOCK + * + * The interface for pollable output streams. + * + * The default implementation of @can_poll always returns %TRUE. + * + * The default implementation of @write_nonblocking calls + * g_pollable_output_stream_is_writable(), and then calls + * g_output_stream_write() if it returns %TRUE. This means you only + * need to override it if it is possible that your @is_writable + * implementation may return %TRUE when the stream is not actually + * writable. + * + * The default implementation of @writev_nonblocking calls + * g_pollable_output_stream_write_nonblocking() for each vector, and converts + * its return value and error (if set) to a #GPollableReturn. You should + * override this where possible to avoid having to allocate a #GError to return + * %G_IO_ERROR_WOULD_BLOCK. + * + * Since: 2.28 + */ +struct _GPollableOutputStreamInterface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + gboolean (*can_poll) (GPollableOutputStream *stream); + + gboolean (*is_writable) (GPollableOutputStream *stream); + GSource * (*create_source) (GPollableOutputStream *stream, + GCancellable *cancellable); + gssize (*write_nonblocking) (GPollableOutputStream *stream, + const void *buffer, + gsize count, + GError **error); + GPollableReturn (*writev_nonblocking) (GPollableOutputStream *stream, + const GOutputVector *vectors, + gsize n_vectors, + gsize *bytes_written, + GError **error); +}; + +GIO_AVAILABLE_IN_ALL +GType g_pollable_output_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gboolean g_pollable_output_stream_can_poll (GPollableOutputStream *stream); + +GIO_AVAILABLE_IN_ALL +gboolean g_pollable_output_stream_is_writable (GPollableOutputStream *stream); +GIO_AVAILABLE_IN_ALL +GSource *g_pollable_output_stream_create_source (GPollableOutputStream *stream, + GCancellable *cancellable); + +GIO_AVAILABLE_IN_ALL +gssize g_pollable_output_stream_write_nonblocking (GPollableOutputStream *stream, + const void *buffer, + gsize count, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_60 +GPollableReturn g_pollable_output_stream_writev_nonblocking (GPollableOutputStream *stream, + const GOutputVector *vectors, + gsize n_vectors, + gsize *bytes_written, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + + +#endif /* __G_POLLABLE_OUTPUT_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gpollableutils.h b/illumos-x86_64/usr/include/glib-2.0/gio/gpollableutils.h new file mode 100644 index 00000000..879bcbbc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gpollableutils.h @@ -0,0 +1,66 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2012 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_POLLABLE_UTILS_H__ +#define __G_POLLABLE_UTILS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GIO_AVAILABLE_IN_ALL +GSource *g_pollable_source_new (GObject *pollable_stream); + +GIO_AVAILABLE_IN_2_34 +GSource *g_pollable_source_new_full (gpointer pollable_stream, + GSource *child_source, + GCancellable *cancellable); + +GIO_AVAILABLE_IN_2_34 +gssize g_pollable_stream_read (GInputStream *stream, + void *buffer, + gsize count, + gboolean blocking, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_34 +gssize g_pollable_stream_write (GOutputStream *stream, + const void *buffer, + gsize count, + gboolean blocking, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_34 +gboolean g_pollable_stream_write_all (GOutputStream *stream, + const void *buffer, + gsize count, + gboolean blocking, + gsize *bytes_written, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + +#endif /* _G_POLLABLE_UTILS_H_ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gpowerprofilemonitor.h b/illumos-x86_64/usr/include/glib-2.0/gio/gpowerprofilemonitor.h new file mode 100644 index 00000000..049f2c5d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gpowerprofilemonitor.h @@ -0,0 +1,65 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright 2019 Red Hat, Inc. + * Copyright 2021 Igalia S.L. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_POWER_PROFILE_MONITOR_H__ +#define __G_POWER_PROFILE_MONITOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_POWER_PROFILE_MONITOR_EXTENSION_POINT_NAME: + * + * Extension point for power profile usage monitoring functionality. + * See [Extending GIO](overview.html#extending-gio). + * + * Since: 2.70 + */ +#define G_POWER_PROFILE_MONITOR_EXTENSION_POINT_NAME "gio-power-profile-monitor" + +#define G_TYPE_POWER_PROFILE_MONITOR (g_power_profile_monitor_get_type ()) +GIO_AVAILABLE_IN_2_70 +G_DECLARE_INTERFACE (GPowerProfileMonitor, g_power_profile_monitor, g, power_profile_monitor, GObject) + +#define G_POWER_PROFILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_POWER_PROFILE_MONITOR, GPowerProfileMonitor)) +#define G_IS_POWER_PROFILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_POWER_PROFILE_MONITOR)) +#define G_POWER_PROFILE_MONITOR_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), G_TYPE_POWER_PROFILE_MONITOR, GPowerProfileMonitorInterface)) + +struct _GPowerProfileMonitorInterface +{ + /*< private >*/ + GTypeInterface g_iface; +}; + +GIO_AVAILABLE_IN_2_70 +GPowerProfileMonitor *g_power_profile_monitor_dup_default (void); + +GIO_AVAILABLE_IN_2_70 +gboolean g_power_profile_monitor_get_power_saver_enabled (GPowerProfileMonitor *monitor); + +G_END_DECLS + +#endif /* __G_POWER_PROFILE_MONITOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gpropertyaction.h b/illumos-x86_64/usr/include/glib-2.0/gio/gpropertyaction.h new file mode 100644 index 00000000..f746e741 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gpropertyaction.h @@ -0,0 +1,49 @@ +/* + * Copyright © 2013 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_PROPERTY_ACTION_H__ +#define __G_PROPERTY_ACTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_PROPERTY_ACTION (g_property_action_get_type ()) +#define G_PROPERTY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_PROPERTY_ACTION, GPropertyAction)) +#define G_IS_PROPERTY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_PROPERTY_ACTION)) + +GIO_AVAILABLE_IN_2_38 +GType g_property_action_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_38 +GPropertyAction * g_property_action_new (const gchar *name, + gpointer object, + const gchar *property_name); + +G_END_DECLS + +#endif /* __G_PROPERTY_ACTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gproxy.h b/illumos-x86_64/usr/include/glib-2.0/gio/gproxy.h new file mode 100644 index 00000000..6acecbcc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gproxy.h @@ -0,0 +1,123 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Collabora Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Nicolas Dufresne + */ + +#ifndef __G_PROXY_H__ +#define __G_PROXY_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_PROXY (g_proxy_get_type ()) +#define G_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_PROXY, GProxy)) +#define G_IS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_PROXY)) +#define G_PROXY_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_PROXY, GProxyInterface)) + +/** + * G_PROXY_EXTENSION_POINT_NAME: + * + * Extension point for proxy functionality. + * See [Extending GIO](overview.html#extending-gio). + * + * Since: 2.26 + */ +#define G_PROXY_EXTENSION_POINT_NAME "gio-proxy" + +typedef struct _GProxyInterface GProxyInterface; + +/** + * GProxyInterface: + * @g_iface: The parent interface. + * @connect: Connect to proxy server and wrap (if required) the #connection + * to handle payload. + * @connect_async: Same as connect() but asynchronous. + * @connect_finish: Returns the result of connect_async() + * @supports_hostname: Returns whether the proxy supports hostname lookups. + * + * Provides an interface for handling proxy connection and payload. + * + * Since: 2.26 + */ +struct _GProxyInterface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + GIOStream * (* connect) (GProxy *proxy, + GIOStream *connection, + GProxyAddress *proxy_address, + GCancellable *cancellable, + GError **error); + + void (* connect_async) (GProxy *proxy, + GIOStream *connection, + GProxyAddress *proxy_address, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + GIOStream * (* connect_finish) (GProxy *proxy, + GAsyncResult *result, + GError **error); + + gboolean (* supports_hostname) (GProxy *proxy); +}; + +GIO_AVAILABLE_IN_ALL +GType g_proxy_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GProxy *g_proxy_get_default_for_protocol (const gchar *protocol); + +GIO_AVAILABLE_IN_ALL +GIOStream *g_proxy_connect (GProxy *proxy, + GIOStream *connection, + GProxyAddress *proxy_address, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_proxy_connect_async (GProxy *proxy, + GIOStream *connection, + GProxyAddress *proxy_address, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +GIOStream *g_proxy_connect_finish (GProxy *proxy, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_proxy_supports_hostname (GProxy *proxy); + +G_END_DECLS + +#endif /* __G_PROXY_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gproxyaddress.h b/illumos-x86_64/usr/include/glib-2.0/gio/gproxyaddress.h new file mode 100644 index 00000000..a0176d65 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gproxyaddress.h @@ -0,0 +1,88 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Nicolas Dufresne + */ + +#ifndef __G_PROXY_ADDRESS_H__ +#define __G_PROXY_ADDRESS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_PROXY_ADDRESS (g_proxy_address_get_type ()) +#define G_PROXY_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_PROXY_ADDRESS, GProxyAddress)) +#define G_PROXY_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_PROXY_ADDRESS, GProxyAddressClass)) +#define G_IS_PROXY_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_PROXY_ADDRESS)) +#define G_IS_PROXY_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_PROXY_ADDRESS)) +#define G_PROXY_ADDRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_PROXY_ADDRESS, GProxyAddressClass)) + +typedef struct _GProxyAddressClass GProxyAddressClass; +typedef struct _GProxyAddressPrivate GProxyAddressPrivate; + +struct _GProxyAddress +{ + GInetSocketAddress parent_instance; + + /*< private >*/ + GProxyAddressPrivate *priv; +}; + +struct _GProxyAddressClass +{ + GInetSocketAddressClass parent_class; +}; + + +GIO_AVAILABLE_IN_ALL +GType g_proxy_address_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_proxy_address_new (GInetAddress *inetaddr, + guint16 port, + const gchar *protocol, + const gchar *dest_hostname, + guint16 dest_port, + const gchar *username, + const gchar *password); + +GIO_AVAILABLE_IN_ALL +const gchar *g_proxy_address_get_protocol (GProxyAddress *proxy); +GIO_AVAILABLE_IN_2_34 +const gchar *g_proxy_address_get_destination_protocol (GProxyAddress *proxy); +GIO_AVAILABLE_IN_ALL +const gchar *g_proxy_address_get_destination_hostname (GProxyAddress *proxy); +GIO_AVAILABLE_IN_ALL +guint16 g_proxy_address_get_destination_port (GProxyAddress *proxy); +GIO_AVAILABLE_IN_ALL +const gchar *g_proxy_address_get_username (GProxyAddress *proxy); +GIO_AVAILABLE_IN_ALL +const gchar *g_proxy_address_get_password (GProxyAddress *proxy); + +GIO_AVAILABLE_IN_2_34 +const gchar *g_proxy_address_get_uri (GProxyAddress *proxy); + +G_END_DECLS + +#endif /* __G_PROXY_ADDRESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gproxyaddressenumerator.h b/illumos-x86_64/usr/include/glib-2.0/gio/gproxyaddressenumerator.h new file mode 100644 index 00000000..7d36ef03 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gproxyaddressenumerator.h @@ -0,0 +1,75 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Nicolas Dufresne + */ + +#ifndef __G_PROXY_ADDRESS_ENUMERATOR_H__ +#define __G_PROXY_ADDRESS_ENUMERATOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_PROXY_ADDRESS_ENUMERATOR (g_proxy_address_enumerator_get_type ()) +#define G_PROXY_ADDRESS_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_PROXY_ADDRESS_ENUMERATOR, GProxyAddressEnumerator)) +#define G_PROXY_ADDRESS_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_PROXY_ADDRESS_ENUMERATOR, GProxyAddressEnumeratorClass)) +#define G_IS_PROXY_ADDRESS_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_PROXY_ADDRESS_ENUMERATOR)) +#define G_IS_PROXY_ADDRESS_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_PROXY_ADDRESS_ENUMERATOR)) +#define G_PROXY_ADDRESS_ENUMERATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_PROXY_ADDRESS_ENUMERATOR, GProxyAddressEnumeratorClass)) + +typedef struct _GProxyAddressEnumeratorClass GProxyAddressEnumeratorClass; +typedef struct _GProxyAddressEnumeratorPrivate GProxyAddressEnumeratorPrivate; + +struct _GProxyAddressEnumerator +{ + /*< private >*/ + GSocketAddressEnumerator parent_instance; + GProxyAddressEnumeratorPrivate *priv; +}; + +/** + * GProxyAddressEnumeratorClass: + * + * Class structure for #GProxyAddressEnumerator. + */ +struct _GProxyAddressEnumeratorClass +{ + /*< private >*/ + GSocketAddressEnumeratorClass parent_class; + + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); + void (*_g_reserved7) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_proxy_address_enumerator_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_PROXY_ADDRESS_ENUMERATOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gproxyresolver.h b/illumos-x86_64/usr/include/glib-2.0/gio/gproxyresolver.h new file mode 100644 index 00000000..9e764420 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gproxyresolver.h @@ -0,0 +1,97 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Nicolas Dufresne + */ + +#ifndef __G_PROXY_RESOLVER_H__ +#define __G_PROXY_RESOLVER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_PROXY_RESOLVER (g_proxy_resolver_get_type ()) +#define G_PROXY_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_PROXY_RESOLVER, GProxyResolver)) +#define G_IS_PROXY_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_PROXY_RESOLVER)) +#define G_PROXY_RESOLVER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), G_TYPE_PROXY_RESOLVER, GProxyResolverInterface)) + +/** + * G_PROXY_RESOLVER_EXTENSION_POINT_NAME: + * + * Extension point for proxy resolving functionality. + * See [Extending GIO](overview.html#extending-gio). + */ +#define G_PROXY_RESOLVER_EXTENSION_POINT_NAME "gio-proxy-resolver" + +typedef struct _GProxyResolverInterface GProxyResolverInterface; + +struct _GProxyResolverInterface { + GTypeInterface g_iface; + + /* Virtual Table */ + gboolean (* is_supported) (GProxyResolver *resolver); + + gchar ** (* lookup) (GProxyResolver *resolver, + const gchar *uri, + GCancellable *cancellable, + GError **error); + + void (* lookup_async) (GProxyResolver *resolver, + const gchar *uri, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + gchar ** (* lookup_finish) (GProxyResolver *resolver, + GAsyncResult *result, + GError **error); +}; + +GIO_AVAILABLE_IN_ALL +GType g_proxy_resolver_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GProxyResolver *g_proxy_resolver_get_default (void); + +GIO_AVAILABLE_IN_ALL +gboolean g_proxy_resolver_is_supported (GProxyResolver *resolver); +GIO_AVAILABLE_IN_ALL +gchar **g_proxy_resolver_lookup (GProxyResolver *resolver, + const gchar *uri, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_proxy_resolver_lookup_async (GProxyResolver *resolver, + const gchar *uri, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gchar **g_proxy_resolver_lookup_finish (GProxyResolver *resolver, + GAsyncResult *result, + GError **error); + + +G_END_DECLS + +#endif /* __G_PROXY_RESOLVER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gremoteactiongroup.h b/illumos-x86_64/usr/include/glib-2.0/gio/gremoteactiongroup.h new file mode 100644 index 00000000..fb0847ef --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gremoteactiongroup.h @@ -0,0 +1,77 @@ +/* + * Copyright © 2011 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_REMOTE_ACTION_GROUP_H__ +#define __G_REMOTE_ACTION_GROUP_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + + +#define G_TYPE_REMOTE_ACTION_GROUP (g_remote_action_group_get_type ()) +#define G_REMOTE_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_REMOTE_ACTION_GROUP, GRemoteActionGroup)) +#define G_IS_REMOTE_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_REMOTE_ACTION_GROUP)) +#define G_REMOTE_ACTION_GROUP_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \ + G_TYPE_REMOTE_ACTION_GROUP, \ + GRemoteActionGroupInterface)) + +typedef struct _GRemoteActionGroupInterface GRemoteActionGroupInterface; + +struct _GRemoteActionGroupInterface +{ + GTypeInterface g_iface; + + void (* activate_action_full) (GRemoteActionGroup *remote, + const gchar *action_name, + GVariant *parameter, + GVariant *platform_data); + + void (* change_action_state_full) (GRemoteActionGroup *remote, + const gchar *action_name, + GVariant *value, + GVariant *platform_data); +}; + +GIO_AVAILABLE_IN_2_32 +GType g_remote_action_group_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +void g_remote_action_group_activate_action_full (GRemoteActionGroup *remote, + const gchar *action_name, + GVariant *parameter, + GVariant *platform_data); + +GIO_AVAILABLE_IN_2_32 +void g_remote_action_group_change_action_state_full (GRemoteActionGroup *remote, + const gchar *action_name, + GVariant *value, + GVariant *platform_data); + +G_END_DECLS + +#endif /* __G_REMOTE_ACTION_GROUP_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gresolver.h b/illumos-x86_64/usr/include/glib-2.0/gio/gresolver.h new file mode 100644 index 00000000..cbcbdecb --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gresolver.h @@ -0,0 +1,299 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Red Hat, Inc. + * Copyright (C) 2018 Igalia S.L. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_RESOLVER_H__ +#define __G_RESOLVER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_RESOLVER (g_resolver_get_type ()) +#define G_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_RESOLVER, GResolver)) +#define G_RESOLVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_RESOLVER, GResolverClass)) +#define G_IS_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_RESOLVER)) +#define G_IS_RESOLVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_RESOLVER)) +#define G_RESOLVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_RESOLVER, GResolverClass)) + +typedef struct _GResolverPrivate GResolverPrivate; +typedef struct _GResolverClass GResolverClass; + +struct _GResolver { + GObject parent_instance; + + GResolverPrivate *priv; +}; + +/** + * GResolverNameLookupFlags: + * @G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT: default behavior (same as g_resolver_lookup_by_name()) + * @G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY: only resolve ipv4 addresses + * @G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY: only resolve ipv6 addresses + * + * Flags to modify lookup behavior. + * + * Since: 2.60 + */ +typedef enum { + G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT = 0, + G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY = 1 << 0, + G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY = 1 << 1, +} GResolverNameLookupFlags; + +struct _GResolverClass { + GObjectClass parent_class; + + /* Signals */ + void ( *reload) (GResolver *resolver); + + /* Virtual methods */ + GList * ( *lookup_by_name) (GResolver *resolver, + const gchar *hostname, + GCancellable *cancellable, + GError **error); + void ( *lookup_by_name_async) (GResolver *resolver, + const gchar *hostname, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GList * ( *lookup_by_name_finish) (GResolver *resolver, + GAsyncResult *result, + GError **error); + + gchar * ( *lookup_by_address) (GResolver *resolver, + GInetAddress *address, + GCancellable *cancellable, + GError **error); + void ( *lookup_by_address_async) (GResolver *resolver, + GInetAddress *address, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gchar * ( *lookup_by_address_finish) (GResolver *resolver, + GAsyncResult *result, + GError **error); + + GList * ( *lookup_service) (GResolver *resolver, + const gchar *rrname, + GCancellable *cancellable, + GError **error); + void ( *lookup_service_async) (GResolver *resolver, + const gchar *rrname, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GList * ( *lookup_service_finish) (GResolver *resolver, + GAsyncResult *result, + GError **error); + + GList * ( *lookup_records) (GResolver *resolver, + const gchar *rrname, + GResolverRecordType record_type, + GCancellable *cancellable, + GError **error); + + void ( *lookup_records_async) (GResolver *resolver, + const gchar *rrname, + GResolverRecordType record_type, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + GList * ( *lookup_records_finish) (GResolver *resolver, + GAsyncResult *result, + GError **error); + /** + * GResolverClass::lookup_by_name_with_flags_async: + * @resolver: a #GResolver + * @hostname: the hostname to resolve + * @flags: extra #GResolverNameLookupFlags to modify the lookup + * @cancellable: (nullable): a #GCancellable + * @callback: (scope async): a #GAsyncReadyCallback to call when completed + * @user_data: data to pass to @callback + * + * Asynchronous version of GResolverClass::lookup_by_name_with_flags + * + * GResolverClass::lookup_by_name_with_flags_finish will be called to get + * the result. + * + * Since: 2.60 + */ + void ( *lookup_by_name_with_flags_async) (GResolver *resolver, + const gchar *hostname, + GResolverNameLookupFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + /** + * GResolverClass::lookup_by_name_with_flags_finish: + * @resolver: a #GResolver + * @result: a #GAsyncResult + * @error: (nullable): a pointer to a %NULL #GError + * + * Gets the result from GResolverClass::lookup_by_name_with_flags_async + * + * Returns: (element-type GInetAddress) (transfer full): List of #GInetAddress. + * Since: 2.60 + */ + GList * ( *lookup_by_name_with_flags_finish) (GResolver *resolver, + GAsyncResult *result, + GError **error); + /** + * GResolverClass::lookup_by_name_with_flags: + * @resolver: a #GResolver + * @hostname: the hostname to resolve + * @flags: extra #GResolverNameLookupFlags to modify the lookup + * @cancellable: (nullable): a #GCancellable + * @error: (nullable): a pointer to a %NULL #GError + * + * This is identical to GResolverClass::lookup_by_name except it takes + * @flags which modifies the behavior of the lookup. See #GResolverNameLookupFlags + * for more details. + * + * Returns: (element-type GInetAddress) (transfer full): List of #GInetAddress. + * Since: 2.60 + */ + GList * ( *lookup_by_name_with_flags) (GResolver *resolver, + const gchar *hostname, + GResolverNameLookupFlags flags, + GCancellable *cancellable, + GError **error); + +}; + +GIO_AVAILABLE_IN_ALL +GType g_resolver_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GResolver *g_resolver_get_default (void); +GIO_AVAILABLE_IN_ALL +void g_resolver_set_default (GResolver *resolver); +GIO_AVAILABLE_IN_ALL +GList *g_resolver_lookup_by_name (GResolver *resolver, + const gchar *hostname, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_resolver_lookup_by_name_async (GResolver *resolver, + const gchar *hostname, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GList *g_resolver_lookup_by_name_finish (GResolver *resolver, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_2_60 +void g_resolver_lookup_by_name_with_flags_async (GResolver *resolver, + const gchar *hostname, + GResolverNameLookupFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_60 +GList *g_resolver_lookup_by_name_with_flags_finish (GResolver *resolver, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_2_60 +GList *g_resolver_lookup_by_name_with_flags (GResolver *resolver, + const gchar *hostname, + GResolverNameLookupFlags flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_resolver_free_addresses (GList *addresses); +GIO_AVAILABLE_IN_ALL +gchar *g_resolver_lookup_by_address (GResolver *resolver, + GInetAddress *address, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_resolver_lookup_by_address_async (GResolver *resolver, + GInetAddress *address, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gchar *g_resolver_lookup_by_address_finish (GResolver *resolver, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +GList *g_resolver_lookup_service (GResolver *resolver, + const gchar *service, + const gchar *protocol, + const gchar *domain, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_resolver_lookup_service_async (GResolver *resolver, + const gchar *service, + const gchar *protocol, + const gchar *domain, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GList *g_resolver_lookup_service_finish (GResolver *resolver, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_2_34 +GList *g_resolver_lookup_records (GResolver *resolver, + const gchar *rrname, + GResolverRecordType record_type, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_34 +void g_resolver_lookup_records_async (GResolver *resolver, + const gchar *rrname, + GResolverRecordType record_type, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_34 +GList *g_resolver_lookup_records_finish (GResolver *resolver, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_resolver_free_targets (GList *targets); + +GIO_AVAILABLE_IN_2_78 +unsigned g_resolver_get_timeout (GResolver *resolver); +GIO_AVAILABLE_IN_2_78 +void g_resolver_set_timeout (GResolver *resolver, + unsigned timeout_ms); + +/** + * G_RESOLVER_ERROR: + * + * Error domain for #GResolver. Errors in this domain will be from the + * #GResolverError enumeration. See #GError for more information on + * error domains. + */ +#define G_RESOLVER_ERROR (g_resolver_error_quark ()) +GIO_AVAILABLE_IN_ALL +GQuark g_resolver_error_quark (void); + +G_END_DECLS + +#endif /* __G_RESOLVER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gresource.h b/illumos-x86_64/usr/include/glib-2.0/gio/gresource.h new file mode 100644 index 00000000..56f92e1f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gresource.h @@ -0,0 +1,138 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_RESOURCE_H__ +#define __G_RESOURCE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_TYPE_RESOURCE: + * + * The #GType for #GResource. + */ +#define G_TYPE_RESOURCE (g_resource_get_type ()) + + +/** + * G_RESOURCE_ERROR: + * + * Error domain for #GResource. Errors in this domain will be from the + * #GResourceError enumeration. See #GError for more information on + * error domains. + */ +#define G_RESOURCE_ERROR (g_resource_error_quark ()) +GIO_AVAILABLE_IN_2_32 +GQuark g_resource_error_quark (void); + +typedef struct _GStaticResource GStaticResource; + +struct _GStaticResource { + /*< private >*/ + const guint8 *data; + gsize data_len; + GResource *resource; + GStaticResource *next; + gpointer padding; +}; + +GIO_AVAILABLE_IN_2_32 +GType g_resource_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_2_32 +GResource * g_resource_new_from_data (GBytes *data, + GError **error); +GIO_AVAILABLE_IN_2_32 +GResource * g_resource_ref (GResource *resource); +GIO_AVAILABLE_IN_2_32 +void g_resource_unref (GResource *resource); +GIO_AVAILABLE_IN_2_32 +GResource * g_resource_load (const gchar *filename, + GError **error); +GIO_AVAILABLE_IN_2_32 +GInputStream *g_resource_open_stream (GResource *resource, + const char *path, + GResourceLookupFlags lookup_flags, + GError **error); +GIO_AVAILABLE_IN_2_32 +GBytes * g_resource_lookup_data (GResource *resource, + const char *path, + GResourceLookupFlags lookup_flags, + GError **error); +GIO_AVAILABLE_IN_2_32 +char ** g_resource_enumerate_children (GResource *resource, + const char *path, + GResourceLookupFlags lookup_flags, + GError **error); +GIO_AVAILABLE_IN_2_32 +gboolean g_resource_get_info (GResource *resource, + const char *path, + GResourceLookupFlags lookup_flags, + gsize *size, + guint32 *flags, + GError **error); + +GIO_AVAILABLE_IN_2_32 +void g_resources_register (GResource *resource); +GIO_AVAILABLE_IN_2_32 +void g_resources_unregister (GResource *resource); +GIO_AVAILABLE_IN_2_32 +GInputStream *g_resources_open_stream (const char *path, + GResourceLookupFlags lookup_flags, + GError **error); +GIO_AVAILABLE_IN_2_32 +GBytes * g_resources_lookup_data (const char *path, + GResourceLookupFlags lookup_flags, + GError **error); +GIO_AVAILABLE_IN_2_32 +char ** g_resources_enumerate_children (const char *path, + GResourceLookupFlags lookup_flags, + GError **error); +GIO_AVAILABLE_IN_2_32 +gboolean g_resources_get_info (const char *path, + GResourceLookupFlags lookup_flags, + gsize *size, + guint32 *flags, + GError **error); + +GIO_AVAILABLE_IN_2_84 +gboolean g_resource_has_children (GResource *resource, + const char *path); +GIO_AVAILABLE_IN_2_84 +gboolean g_resources_has_children (const char *path); + + +GIO_AVAILABLE_IN_2_32 +void g_static_resource_init (GStaticResource *static_resource); +GIO_AVAILABLE_IN_2_32 +void g_static_resource_fini (GStaticResource *static_resource); +GIO_AVAILABLE_IN_2_32 +GResource *g_static_resource_get_resource (GStaticResource *static_resource); + +G_END_DECLS + +#endif /* __G_RESOURCE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gseekable.h b/illumos-x86_64/usr/include/glib-2.0/gio/gseekable.h new file mode 100644 index 00000000..e9978016 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gseekable.h @@ -0,0 +1,100 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_SEEKABLE_H__ +#define __G_SEEKABLE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SEEKABLE (g_seekable_get_type ()) +#define G_SEEKABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SEEKABLE, GSeekable)) +#define G_IS_SEEKABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SEEKABLE)) +#define G_SEEKABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_SEEKABLE, GSeekableIface)) + +typedef struct _GSeekableIface GSeekableIface; + +/** + * GSeekableIface: + * @g_iface: The parent interface. + * @tell: Tells the current location within a stream. + * @can_seek: Checks if seeking is supported by the stream. + * @seek: Seeks to a location within a stream. + * @can_truncate: Checks if truncation is supported by the stream. + * @truncate_fn: Truncates a stream. + * + * Provides an interface for implementing seekable functionality on I/O Streams. + **/ +struct _GSeekableIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + goffset (* tell) (GSeekable *seekable); + + gboolean (* can_seek) (GSeekable *seekable); + gboolean (* seek) (GSeekable *seekable, + goffset offset, + GSeekType type, + GCancellable *cancellable, + GError **error); + + gboolean (* can_truncate) (GSeekable *seekable); + gboolean (* truncate_fn) (GSeekable *seekable, + goffset offset, + GCancellable *cancellable, + GError **error); + + /* TODO: Async seek/truncate */ +}; + +GIO_AVAILABLE_IN_ALL +GType g_seekable_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +goffset g_seekable_tell (GSeekable *seekable); +GIO_AVAILABLE_IN_ALL +gboolean g_seekable_can_seek (GSeekable *seekable); +GIO_AVAILABLE_IN_ALL +gboolean g_seekable_seek (GSeekable *seekable, + goffset offset, + GSeekType type, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_seekable_can_truncate (GSeekable *seekable); +GIO_AVAILABLE_IN_ALL +gboolean g_seekable_truncate (GSeekable *seekable, + goffset offset, + GCancellable *cancellable, + GError **error); + +G_END_DECLS + + +#endif /* __G_SEEKABLE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsettings.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsettings.h new file mode 100644 index 00000000..e7e955fa --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsettings.h @@ -0,0 +1,359 @@ +/* + * Copyright © 2009, 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_SETTINGS_H__ +#define __G_SETTINGS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_SETTINGS (g_settings_get_type ()) +#define G_SETTINGS(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SETTINGS, GSettings)) +#define G_SETTINGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SETTINGS, GSettingsClass)) +#define G_IS_SETTINGS(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_SETTINGS)) +#define G_IS_SETTINGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_SETTINGS)) +#define G_SETTINGS_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SETTINGS, GSettingsClass)) + +typedef struct _GSettingsPrivate GSettingsPrivate; +typedef struct _GSettingsClass GSettingsClass; + +struct _GSettingsClass +{ + GObjectClass parent_class; + + /* Signals */ + void (*writable_changed) (GSettings *settings, + const gchar *key); + void (*changed) (GSettings *settings, + const gchar *key); + gboolean (*writable_change_event) (GSettings *settings, + GQuark key); + gboolean (*change_event) (GSettings *settings, + const GQuark *keys, + gint n_keys); + + gpointer padding[20]; +}; + +struct _GSettings +{ + GObject parent_instance; + GSettingsPrivate *priv; +}; + + +GIO_AVAILABLE_IN_ALL +GType g_settings_get_type (void); + +GIO_DEPRECATED_IN_2_40_FOR(g_settings_schema_source_list_schemas) +const gchar * const * g_settings_list_schemas (void); +GIO_DEPRECATED_IN_2_40_FOR(g_settings_schema_source_list_schemas) +const gchar * const * g_settings_list_relocatable_schemas (void); +GIO_AVAILABLE_IN_ALL +GSettings * g_settings_new (const gchar *schema_id); +GIO_AVAILABLE_IN_ALL +GSettings * g_settings_new_with_path (const gchar *schema_id, + const gchar *path); +GIO_AVAILABLE_IN_ALL +GSettings * g_settings_new_with_backend (const gchar *schema_id, + GSettingsBackend *backend); +GIO_AVAILABLE_IN_ALL +GSettings * g_settings_new_with_backend_and_path (const gchar *schema_id, + GSettingsBackend *backend, + const gchar *path); +GIO_AVAILABLE_IN_2_32 +GSettings * g_settings_new_full (GSettingsSchema *schema, + GSettingsBackend *backend, + const gchar *path); +GIO_AVAILABLE_IN_ALL +gchar ** g_settings_list_children (GSettings *settings); +GIO_DEPRECATED_IN_2_46_FOR(g_settings_schema_list_keys) +gchar ** g_settings_list_keys (GSettings *settings); +GIO_DEPRECATED_IN_2_40_FOR(g_settings_schema_key_get_range) +GVariant * g_settings_get_range (GSettings *settings, + const gchar *key); +GIO_DEPRECATED_IN_2_40_FOR(g_settings_schema_key_range_check) +gboolean g_settings_range_check (GSettings *settings, + const gchar *key, + GVariant *value); + +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set_value (GSettings *settings, + const gchar *key, + GVariant *value); +GIO_AVAILABLE_IN_ALL +GVariant * g_settings_get_value (GSettings *settings, + const gchar *key); + +GIO_AVAILABLE_IN_2_40 +GVariant * g_settings_get_user_value (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_2_40 +GVariant * g_settings_get_default_value (GSettings *settings, + const gchar *key); + +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set (GSettings *settings, + const gchar *key, + const gchar *format, + ...); +GIO_AVAILABLE_IN_ALL +void g_settings_get (GSettings *settings, + const gchar *key, + const gchar *format, + ...); +GIO_AVAILABLE_IN_ALL +void g_settings_reset (GSettings *settings, + const gchar *key); + +GIO_AVAILABLE_IN_ALL +gint g_settings_get_int (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set_int (GSettings *settings, + const gchar *key, + gint value); +GIO_AVAILABLE_IN_2_50 +gint64 g_settings_get_int64 (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_2_50 +gboolean g_settings_set_int64 (GSettings *settings, + const gchar *key, + gint64 value); +GIO_AVAILABLE_IN_2_32 +guint g_settings_get_uint (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_2_32 +gboolean g_settings_set_uint (GSettings *settings, + const gchar *key, + guint value); +GIO_AVAILABLE_IN_2_50 +guint64 g_settings_get_uint64 (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_2_50 +gboolean g_settings_set_uint64 (GSettings *settings, + const gchar *key, + guint64 value); +GIO_AVAILABLE_IN_ALL +gchar * g_settings_get_string (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set_string (GSettings *settings, + const gchar *key, + const gchar *value); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_get_boolean (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set_boolean (GSettings *settings, + const gchar *key, + gboolean value); +GIO_AVAILABLE_IN_ALL +gdouble g_settings_get_double (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set_double (GSettings *settings, + const gchar *key, + gdouble value); +GIO_AVAILABLE_IN_ALL +gchar ** g_settings_get_strv (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set_strv (GSettings *settings, + const gchar *key, + const gchar *const *value); +GIO_AVAILABLE_IN_ALL +gint g_settings_get_enum (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set_enum (GSettings *settings, + const gchar *key, + gint value); +GIO_AVAILABLE_IN_ALL +guint g_settings_get_flags (GSettings *settings, + const gchar *key); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_set_flags (GSettings *settings, + const gchar *key, + guint value); +GIO_AVAILABLE_IN_ALL +GSettings * g_settings_get_child (GSettings *settings, + const gchar *name); + +GIO_AVAILABLE_IN_ALL +gboolean g_settings_is_writable (GSettings *settings, + const gchar *name); + +GIO_AVAILABLE_IN_ALL +void g_settings_delay (GSettings *settings); +GIO_AVAILABLE_IN_ALL +void g_settings_apply (GSettings *settings); +GIO_AVAILABLE_IN_ALL +void g_settings_revert (GSettings *settings); +GIO_AVAILABLE_IN_ALL +gboolean g_settings_get_has_unapplied (GSettings *settings); +GIO_AVAILABLE_IN_ALL +void g_settings_sync (void); + +/** + * GSettingsBindSetMapping: + * @value: the property value to map + * @expected_type: expected type of the result + * @user_data: user data that was specified when the binding was created + * + * The type for the function that is used to convert an object property + * value to a [struct@GLib.Variant] for storing it in [class@Gio.Settings]. + * + * Returns: (nullable): a new [struct@GLib.Variant] holding the data from @value, + * or `NULL` in case of an error + */ +typedef GVariant * (*GSettingsBindSetMapping) (const GValue *value, + const GVariantType *expected_type, + gpointer user_data); + +/** + * GSettingsBindGetMapping: + * @value: return location for the property value + * @variant: variant to map to the property value + * @user_data: user data that was specified when the binding was created + * + * The type for the function that is used to convert from [class@Gio.Settings] + * to an object property. + * + * The @value is already initialized to hold values of the appropriate type. + * + * Returns: true if the conversion succeeded, false in case of an error + */ +typedef gboolean (*GSettingsBindGetMapping) (GValue *value, + GVariant *variant, + gpointer user_data); + +/** + * GSettingsGetMapping: + * @value: (nullable): variant to map to the application value + * @result: (out): the result of the mapping + * @user_data: (closure): the user data that was passed to + * [method@Gio.Settings.get_mapped] + * + * The type of the function that is used to convert from a value stored + * in a [class@Gio.Settings] to a value that is useful to the application. + * + * If the value is successfully mapped, the result should be stored at + * @result and true returned. If mapping fails (for example, if @value + * is not in the right format) then false should be returned. + * + * If @value is `NULL` then it means that the mapping function is being + * given a ‘last chance’ to successfully return a valid value. True + * must be returned in this case. + * + * Returns: true if the conversion succeeded, false in case of an error + **/ +typedef gboolean (*GSettingsGetMapping) (GVariant *value, + gpointer *result, + gpointer user_data); + +/** + * GSettingsBindFlags: + * @G_SETTINGS_BIND_DEFAULT: Equivalent to `G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET` + * @G_SETTINGS_BIND_GET: Update the [class@GObject.Object] property when the setting changes. + * It is an error to use this flag if the property is not writable. + * @G_SETTINGS_BIND_SET: Update the setting when the [class@GObject.Object] property changes. + * It is an error to use this flag if the property is not readable. + * @G_SETTINGS_BIND_NO_SENSITIVITY: Do not try to bind a ‘sensitivity’ property to the writability of the setting + * @G_SETTINGS_BIND_GET_NO_CHANGES: When set in addition to [flags@Gio.SettingsBindFlags.GET], + * set the [class@GObject.Object] property + * value initially from the setting, but do not listen for changes of the setting + * @G_SETTINGS_BIND_INVERT_BOOLEAN: When passed to [method@Gio.Settings.bind], + * uses a pair of mapping functions that invert + * the boolean value when mapping between the setting and the property. The setting and property must both + * be booleans. You cannot pass this flag to [method@Gio.Settings.bind_with_mapping]. + * + * Flags used when creating a binding. + * + * These flags determine in which direction the binding works. The default is to + * synchronize in both directions. + */ +typedef enum +{ + G_SETTINGS_BIND_DEFAULT, + G_SETTINGS_BIND_GET = (1<<0), + G_SETTINGS_BIND_SET = (1<<1), + G_SETTINGS_BIND_NO_SENSITIVITY = (1<<2), + G_SETTINGS_BIND_GET_NO_CHANGES = (1<<3), + G_SETTINGS_BIND_INVERT_BOOLEAN = (1<<4) +} GSettingsBindFlags; + +GIO_AVAILABLE_IN_ALL +void g_settings_bind (GSettings *settings, + const gchar *key, + gpointer object, + const gchar *property, + GSettingsBindFlags flags); +GIO_AVAILABLE_IN_ALL +void g_settings_bind_with_mapping (GSettings *settings, + const gchar *key, + gpointer object, + const gchar *property, + GSettingsBindFlags flags, + GSettingsBindGetMapping get_mapping, + GSettingsBindSetMapping set_mapping, + gpointer user_data, + GDestroyNotify destroy); +GIO_AVAILABLE_IN_2_82 +void g_settings_bind_with_mapping_closures (GSettings *settings, + const char *key, + GObject *object, + const char *property, + GSettingsBindFlags flags, + GClosure *get_mapping, + GClosure *set_mapping); +GIO_AVAILABLE_IN_ALL +void g_settings_bind_writable (GSettings *settings, + const gchar *key, + gpointer object, + const gchar *property, + gboolean inverted); +GIO_AVAILABLE_IN_ALL +void g_settings_unbind (gpointer object, + const gchar *property); + +GIO_AVAILABLE_IN_2_32 +GAction * g_settings_create_action (GSettings *settings, + const gchar *key); + +GIO_AVAILABLE_IN_ALL +gpointer g_settings_get_mapped (GSettings *settings, + const gchar *key, + GSettingsGetMapping mapping, + gpointer user_data); + +G_END_DECLS + +#endif /* __G_SETTINGS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsettingsbackend.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsettingsbackend.h new file mode 100644 index 00000000..2649605d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsettingsbackend.h @@ -0,0 +1,171 @@ +/* + * Copyright © 2009, 2010 Codethink Limited + * Copyright © 2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Authors: Ryan Lortie + * Matthias Clasen + */ + +#ifndef __G_SETTINGS_BACKEND_H__ +#define __G_SETTINGS_BACKEND_H__ + +#if !defined (G_SETTINGS_ENABLE_BACKEND) && !defined (GIO_COMPILATION) +#error "You must define G_SETTINGS_ENABLE_BACKEND before including ." +#endif + +#define __GIO_GIO_H_INSIDE__ +#include +#undef __GIO_GIO_H_INSIDE__ + +G_BEGIN_DECLS + +#define G_TYPE_SETTINGS_BACKEND (g_settings_backend_get_type ()) +#define G_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SETTINGS_BACKEND, GSettingsBackend)) +#define G_SETTINGS_BACKEND_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass)) +#define G_IS_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SETTINGS_BACKEND)) +#define G_IS_SETTINGS_BACKEND_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_SETTINGS_BACKEND)) +#define G_SETTINGS_BACKEND_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass)) + +/** + * G_SETTINGS_BACKEND_EXTENSION_POINT_NAME: + * + * Extension point for #GSettingsBackend functionality. + **/ +#define G_SETTINGS_BACKEND_EXTENSION_POINT_NAME "gsettings-backend" + +typedef struct _GSettingsBackendPrivate GSettingsBackendPrivate; +typedef struct _GSettingsBackendClass GSettingsBackendClass; + +/** + * GSettingsBackendClass: + * @read: virtual method to read a key's value + * @get_writable: virtual method to get if a key is writable + * @write: virtual method to change key's value + * @write_tree: virtual method to change a tree of keys + * @reset: virtual method to reset state + * @subscribe: virtual method to subscribe to key changes + * @unsubscribe: virtual method to unsubscribe to key changes + * @sync: virtual method to sync state + * @get_permission: virtual method to get permission of a key + * @read_user_value: virtual method to read user's key value + * + * Class structure for #GSettingsBackend. + */ +struct _GSettingsBackendClass +{ + GObjectClass parent_class; + + GVariant * (*read) (GSettingsBackend *backend, + const gchar *key, + const GVariantType *expected_type, + gboolean default_value); + + gboolean (*get_writable) (GSettingsBackend *backend, + const gchar *key); + + gboolean (*write) (GSettingsBackend *backend, + const gchar *key, + GVariant *value, + gpointer origin_tag); + gboolean (*write_tree) (GSettingsBackend *backend, + GTree *tree, + gpointer origin_tag); + void (*reset) (GSettingsBackend *backend, + const gchar *key, + gpointer origin_tag); + + void (*subscribe) (GSettingsBackend *backend, + const gchar *name); + void (*unsubscribe) (GSettingsBackend *backend, + const gchar *name); + void (*sync) (GSettingsBackend *backend); + + GPermission * (*get_permission) (GSettingsBackend *backend, + const gchar *path); + + GVariant * (*read_user_value) (GSettingsBackend *backend, + const gchar *key, + const GVariantType *expected_type); + + /*< private >*/ + gpointer padding[23]; +}; + +struct _GSettingsBackend +{ + GObject parent_instance; + + /*< private >*/ + GSettingsBackendPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_settings_backend_get_type (void); + +GIO_AVAILABLE_IN_ALL +void g_settings_backend_changed (GSettingsBackend *backend, + const gchar *key, + gpointer origin_tag); +GIO_AVAILABLE_IN_ALL +void g_settings_backend_path_changed (GSettingsBackend *backend, + const gchar *path, + gpointer origin_tag); +GIO_AVAILABLE_IN_ALL +void g_settings_backend_flatten_tree (GTree *tree, + gchar **path, + const gchar ***keys, + GVariant ***values); +GIO_AVAILABLE_IN_ALL +void g_settings_backend_keys_changed (GSettingsBackend *backend, + const gchar *path, + gchar const * const *items, + gpointer origin_tag); + +GIO_AVAILABLE_IN_ALL +void g_settings_backend_path_writable_changed (GSettingsBackend *backend, + const gchar *path); +GIO_AVAILABLE_IN_ALL +void g_settings_backend_writable_changed (GSettingsBackend *backend, + const gchar *key); +GIO_AVAILABLE_IN_ALL +void g_settings_backend_changed_tree (GSettingsBackend *backend, + GTree *tree, + gpointer origin_tag); + +GIO_AVAILABLE_IN_ALL +GSettingsBackend * g_settings_backend_get_default (void); + +GIO_AVAILABLE_IN_ALL +GSettingsBackend * g_keyfile_settings_backend_new (const gchar *filename, + const gchar *root_path, + const gchar *root_group); + +GIO_AVAILABLE_IN_ALL +GSettingsBackend * g_null_settings_backend_new (void); + +GIO_AVAILABLE_IN_ALL +GSettingsBackend * g_memory_settings_backend_new (void); + +G_END_DECLS + +#endif /* __G_SETTINGS_BACKEND_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsettingsschema.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsettingsschema.h new file mode 100644 index 00000000..a3bb7df8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsettingsschema.h @@ -0,0 +1,115 @@ +/* + * Copyright © 2010 Codethink Limited + * Copyright © 2011 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_SETTINGS_SCHEMA_H__ +#define __G_SETTINGS_SCHEMA_H__ + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GSettingsSchemaSource GSettingsSchemaSource; +typedef struct _GSettingsSchema GSettingsSchema; +typedef struct _GSettingsSchemaKey GSettingsSchemaKey; + +#define G_TYPE_SETTINGS_SCHEMA_SOURCE (g_settings_schema_source_get_type ()) +GIO_AVAILABLE_IN_2_32 +GType g_settings_schema_source_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +GSettingsSchemaSource * g_settings_schema_source_get_default (void); +GIO_AVAILABLE_IN_2_32 +GSettingsSchemaSource * g_settings_schema_source_ref (GSettingsSchemaSource *source); +GIO_AVAILABLE_IN_2_32 +void g_settings_schema_source_unref (GSettingsSchemaSource *source); + +GIO_AVAILABLE_IN_2_32 +GSettingsSchemaSource * g_settings_schema_source_new_from_directory (const gchar *directory, + GSettingsSchemaSource *parent, + gboolean trusted, + GError **error); + +GIO_AVAILABLE_IN_2_32 +GSettingsSchema * g_settings_schema_source_lookup (GSettingsSchemaSource *source, + const gchar *schema_id, + gboolean recursive); + +GIO_AVAILABLE_IN_2_40 +void g_settings_schema_source_list_schemas (GSettingsSchemaSource *source, + gboolean recursive, + gchar ***non_relocatable, + gchar ***relocatable); + +#define G_TYPE_SETTINGS_SCHEMA (g_settings_schema_get_type ()) +GIO_AVAILABLE_IN_2_32 +GType g_settings_schema_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +GSettingsSchema * g_settings_schema_ref (GSettingsSchema *schema); +GIO_AVAILABLE_IN_2_32 +void g_settings_schema_unref (GSettingsSchema *schema); + +GIO_AVAILABLE_IN_2_32 +const gchar * g_settings_schema_get_id (GSettingsSchema *schema); +GIO_AVAILABLE_IN_2_32 +const gchar * g_settings_schema_get_path (GSettingsSchema *schema); +GIO_AVAILABLE_IN_2_40 +GSettingsSchemaKey * g_settings_schema_get_key (GSettingsSchema *schema, + const gchar *name); +GIO_AVAILABLE_IN_2_40 +gboolean g_settings_schema_has_key (GSettingsSchema *schema, + const gchar *name); +GIO_AVAILABLE_IN_2_46 +gchar** g_settings_schema_list_keys (GSettingsSchema *schema); + + +GIO_AVAILABLE_IN_2_44 +gchar ** g_settings_schema_list_children (GSettingsSchema *schema); + +#define G_TYPE_SETTINGS_SCHEMA_KEY (g_settings_schema_key_get_type ()) +GIO_AVAILABLE_IN_2_40 +GType g_settings_schema_key_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_40 +GSettingsSchemaKey * g_settings_schema_key_ref (GSettingsSchemaKey *key); +GIO_AVAILABLE_IN_2_40 +void g_settings_schema_key_unref (GSettingsSchemaKey *key); + +GIO_AVAILABLE_IN_2_40 +const GVariantType * g_settings_schema_key_get_value_type (GSettingsSchemaKey *key); +GIO_AVAILABLE_IN_2_40 +GVariant * g_settings_schema_key_get_default_value (GSettingsSchemaKey *key); +GIO_AVAILABLE_IN_2_40 +GVariant * g_settings_schema_key_get_range (GSettingsSchemaKey *key); +GIO_AVAILABLE_IN_2_40 +gboolean g_settings_schema_key_range_check (GSettingsSchemaKey *key, + GVariant *value); + +GIO_AVAILABLE_IN_2_44 +const gchar * g_settings_schema_key_get_name (GSettingsSchemaKey *key); +GIO_AVAILABLE_IN_2_40 +const gchar * g_settings_schema_key_get_summary (GSettingsSchemaKey *key); +GIO_AVAILABLE_IN_2_40 +const gchar * g_settings_schema_key_get_description (GSettingsSchemaKey *key); + +G_END_DECLS + +#endif /* __G_SETTINGS_SCHEMA_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleaction.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleaction.h new file mode 100644 index 00000000..ce80e7ae --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleaction.h @@ -0,0 +1,65 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_SIMPLE_ACTION_H__ +#define __G_SIMPLE_ACTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SIMPLE_ACTION (g_simple_action_get_type ()) +#define G_SIMPLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SIMPLE_ACTION, GSimpleAction)) +#define G_IS_SIMPLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SIMPLE_ACTION)) + +GIO_AVAILABLE_IN_ALL +GType g_simple_action_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSimpleAction * g_simple_action_new (const gchar *name, + const GVariantType *parameter_type); + +GIO_AVAILABLE_IN_ALL +GSimpleAction * g_simple_action_new_stateful (const gchar *name, + const GVariantType *parameter_type, + GVariant *state); + +GIO_AVAILABLE_IN_ALL +void g_simple_action_set_enabled (GSimpleAction *simple, + gboolean enabled); + +GIO_AVAILABLE_IN_2_30 +void g_simple_action_set_state (GSimpleAction *simple, + GVariant *value); + +GIO_AVAILABLE_IN_2_44 +void g_simple_action_set_state_hint (GSimpleAction *simple, + GVariant *state_hint); + +G_END_DECLS + +#endif /* __G_SIMPLE_ACTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleactiongroup.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleactiongroup.h new file mode 100644 index 00000000..48f669db --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleactiongroup.h @@ -0,0 +1,92 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_SIMPLE_ACTION_GROUP_H__ +#define __G_SIMPLE_ACTION_GROUP_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include "gactiongroup.h" +#include "gactionmap.h" + +G_BEGIN_DECLS + +#define G_TYPE_SIMPLE_ACTION_GROUP (g_simple_action_group_get_type ()) +#define G_SIMPLE_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SIMPLE_ACTION_GROUP, GSimpleActionGroup)) +#define G_SIMPLE_ACTION_GROUP_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SIMPLE_ACTION_GROUP, GSimpleActionGroupClass)) +#define G_IS_SIMPLE_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SIMPLE_ACTION_GROUP)) +#define G_IS_SIMPLE_ACTION_GROUP_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_SIMPLE_ACTION_GROUP)) +#define G_SIMPLE_ACTION_GROUP_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SIMPLE_ACTION_GROUP, GSimpleActionGroupClass)) + +typedef struct _GSimpleActionGroupPrivate GSimpleActionGroupPrivate; +typedef struct _GSimpleActionGroupClass GSimpleActionGroupClass; + +struct _GSimpleActionGroup +{ + /*< private >*/ + GObject parent_instance; + + GSimpleActionGroupPrivate *priv; +}; + +struct _GSimpleActionGroupClass +{ + /*< private >*/ + GObjectClass parent_class; + + /*< private >*/ + gpointer padding[12]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_simple_action_group_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSimpleActionGroup * g_simple_action_group_new (void); + +GIO_DEPRECATED_IN_2_38_FOR (g_action_map_lookup_action) +GAction * g_simple_action_group_lookup (GSimpleActionGroup *simple, + const gchar *action_name); + +GIO_DEPRECATED_IN_2_38_FOR (g_action_map_add_action) +void g_simple_action_group_insert (GSimpleActionGroup *simple, + GAction *action); + +GIO_DEPRECATED_IN_2_38_FOR (g_action_map_remove_action) +void g_simple_action_group_remove (GSimpleActionGroup *simple, + const gchar *action_name); + +GIO_DEPRECATED_IN_2_38_FOR (g_action_map_add_action_entries) +void g_simple_action_group_add_entries (GSimpleActionGroup *simple, + const GActionEntry *entries, + gint n_entries, + gpointer user_data); + +G_END_DECLS + +#endif /* __G_SIMPLE_ACTION_GROUP_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleasyncresult.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleasyncresult.h new file mode 100644 index 00000000..94ad3557 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleasyncresult.h @@ -0,0 +1,159 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_SIMPLE_ASYNC_RESULT_H__ +#define __G_SIMPLE_ASYNC_RESULT_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SIMPLE_ASYNC_RESULT (g_simple_async_result_get_type ()) +#define G_SIMPLE_ASYNC_RESULT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResult)) +#define G_SIMPLE_ASYNC_RESULT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResultClass)) +#define G_IS_SIMPLE_ASYNC_RESULT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SIMPLE_ASYNC_RESULT)) +#define G_IS_SIMPLE_ASYNC_RESULT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SIMPLE_ASYNC_RESULT)) +#define G_SIMPLE_ASYNC_RESULT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResultClass)) + +typedef struct _GSimpleAsyncResultClass GSimpleAsyncResultClass; + + +GIO_AVAILABLE_IN_ALL +GType g_simple_async_result_get_type (void) G_GNUC_CONST; + +GIO_DEPRECATED_IN_2_46_FOR(g_task_new) +GSimpleAsyncResult *g_simple_async_result_new (GObject *source_object, + GAsyncReadyCallback callback, + gpointer user_data, + gpointer source_tag); +GIO_DEPRECATED_IN_2_46_FOR(g_task_new) +GSimpleAsyncResult *g_simple_async_result_new_error (GObject *source_object, + GAsyncReadyCallback callback, + gpointer user_data, + GQuark domain, + gint code, + const char *format, + ...) G_GNUC_PRINTF (6, 7); +GIO_DEPRECATED_IN_2_46_FOR(g_task_new) +GSimpleAsyncResult *g_simple_async_result_new_from_error (GObject *source_object, + GAsyncReadyCallback callback, + gpointer user_data, + const GError *error); +GIO_DEPRECATED_IN_2_46_FOR(g_task_new) +GSimpleAsyncResult *g_simple_async_result_new_take_error (GObject *source_object, + GAsyncReadyCallback callback, + gpointer user_data, + GError *error); + +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_set_op_res_gpointer (GSimpleAsyncResult *simple, + gpointer op_res, + GDestroyNotify destroy_op_res); +GIO_DEPRECATED_IN_2_46 +gpointer g_simple_async_result_get_op_res_gpointer (GSimpleAsyncResult *simple); + +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_set_op_res_gssize (GSimpleAsyncResult *simple, + gssize op_res); +GIO_DEPRECATED_IN_2_46 +gssize g_simple_async_result_get_op_res_gssize (GSimpleAsyncResult *simple); + +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_set_op_res_gboolean (GSimpleAsyncResult *simple, + gboolean op_res); +GIO_DEPRECATED_IN_2_46 +gboolean g_simple_async_result_get_op_res_gboolean (GSimpleAsyncResult *simple); + + + +GIO_AVAILABLE_IN_2_32 /* Also deprecated, but can't mark something both AVAILABLE and DEPRECATED */ +void g_simple_async_result_set_check_cancellable (GSimpleAsyncResult *simple, + GCancellable *check_cancellable); +GIO_DEPRECATED_IN_2_46 +gpointer g_simple_async_result_get_source_tag (GSimpleAsyncResult *simple); +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_set_handle_cancellation (GSimpleAsyncResult *simple, + gboolean handle_cancellation); +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_complete (GSimpleAsyncResult *simple); +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_complete_in_idle (GSimpleAsyncResult *simple); +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_run_in_thread (GSimpleAsyncResult *simple, + GSimpleAsyncThreadFunc func, + int io_priority, + GCancellable *cancellable); +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_set_from_error (GSimpleAsyncResult *simple, + const GError *error); +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_take_error (GSimpleAsyncResult *simple, + GError *error); +GIO_DEPRECATED_IN_2_46 +gboolean g_simple_async_result_propagate_error (GSimpleAsyncResult *simple, + GError **dest); +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_set_error (GSimpleAsyncResult *simple, + GQuark domain, + gint code, + const char *format, + ...) G_GNUC_PRINTF (4, 5); +GIO_DEPRECATED_IN_2_46 +void g_simple_async_result_set_error_va (GSimpleAsyncResult *simple, + GQuark domain, + gint code, + const char *format, + va_list args) + G_GNUC_PRINTF(4, 0); +GIO_DEPRECATED_IN_2_46 +gboolean g_simple_async_result_is_valid (GAsyncResult *result, + GObject *source, + gpointer source_tag); + +GIO_DEPRECATED_IN_2_46_FOR(g_task_report_error) +void g_simple_async_report_error_in_idle (GObject *object, + GAsyncReadyCallback callback, + gpointer user_data, + GQuark domain, + gint code, + const char *format, + ...) G_GNUC_PRINTF(6, 7); +GIO_DEPRECATED_IN_2_46_FOR(g_task_report_error) +void g_simple_async_report_gerror_in_idle (GObject *object, + GAsyncReadyCallback callback, + gpointer user_data, + const GError *error); +GIO_DEPRECATED_IN_2_46_FOR(g_task_report_error) +void g_simple_async_report_take_gerror_in_idle (GObject *object, + GAsyncReadyCallback callback, + gpointer user_data, + GError *error); + +G_END_DECLS + + + +#endif /* __G_SIMPLE_ASYNC_RESULT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleiostream.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleiostream.h new file mode 100644 index 00000000..1d98ffe9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleiostream.h @@ -0,0 +1,47 @@ +/* + * Copyright © 2014 NICE s.r.l. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ignacio Casal Quinteiro + */ + +#ifndef __G_SIMPLE_IO_STREAM_H__ +#define __G_SIMPLE_IO_STREAM_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_SIMPLE_IO_STREAM (g_simple_io_stream_get_type ()) +#define G_SIMPLE_IO_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SIMPLE_IO_STREAM, GSimpleIOStream)) +#define G_IS_SIMPLE_IO_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SIMPLE_IO_STREAM)) + +GIO_AVAILABLE_IN_2_44 +GType g_simple_io_stream_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_44 +GIOStream *g_simple_io_stream_new (GInputStream *input_stream, + GOutputStream *output_stream); + +G_END_DECLS + +#endif /* __G_SIMPLE_IO_STREAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsimplepermission.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsimplepermission.h new file mode 100644 index 00000000..19c42d70 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsimplepermission.h @@ -0,0 +1,47 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_SIMPLE_PERMISSION_H__ +#define __G_SIMPLE_PERMISSION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SIMPLE_PERMISSION (g_simple_permission_get_type ()) +#define G_SIMPLE_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SIMPLE_PERMISSION, \ + GSimplePermission)) +#define G_IS_SIMPLE_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SIMPLE_PERMISSION)) + +GIO_AVAILABLE_IN_ALL +GType g_simple_permission_get_type (void); +GIO_AVAILABLE_IN_ALL +GPermission * g_simple_permission_new (gboolean allowed); + +G_END_DECLS + +#endif /* __G_SIMPLE_PERMISSION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleproxyresolver.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleproxyresolver.h new file mode 100644 index 00000000..113b4911 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsimpleproxyresolver.h @@ -0,0 +1,86 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright 2010, 2013 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_SIMPLE_PROXY_RESOLVER_H__ +#define __G_SIMPLE_PROXY_RESOLVER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SIMPLE_PROXY_RESOLVER (g_simple_proxy_resolver_get_type ()) +#define G_SIMPLE_PROXY_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SIMPLE_PROXY_RESOLVER, GSimpleProxyResolver)) +#define G_SIMPLE_PROXY_RESOLVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SIMPLE_PROXY_RESOLVER, GSimpleProxyResolverClass)) +#define G_IS_SIMPLE_PROXY_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SIMPLE_PROXY_RESOLVER)) +#define G_IS_SIMPLE_PROXY_RESOLVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SIMPLE_PROXY_RESOLVER)) +#define G_SIMPLE_PROXY_RESOLVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SIMPLE_PROXY_RESOLVER, GSimpleProxyResolverClass)) + +typedef struct _GSimpleProxyResolver GSimpleProxyResolver; +typedef struct _GSimpleProxyResolverPrivate GSimpleProxyResolverPrivate; +typedef struct _GSimpleProxyResolverClass GSimpleProxyResolverClass; + +struct _GSimpleProxyResolver +{ + GObject parent_instance; + + /*< private >*/ + GSimpleProxyResolverPrivate *priv; +}; + +struct _GSimpleProxyResolverClass +{ + GObjectClass parent_class; + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GIO_AVAILABLE_IN_2_36 +GType g_simple_proxy_resolver_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_36 +GProxyResolver *g_simple_proxy_resolver_new (const gchar *default_proxy, + gchar **ignore_hosts); + +GIO_AVAILABLE_IN_2_36 +void g_simple_proxy_resolver_set_default_proxy (GSimpleProxyResolver *resolver, + const gchar *default_proxy); + +GIO_AVAILABLE_IN_2_36 +void g_simple_proxy_resolver_set_ignore_hosts (GSimpleProxyResolver *resolver, + gchar **ignore_hosts); + +GIO_AVAILABLE_IN_2_36 +void g_simple_proxy_resolver_set_uri_proxy (GSimpleProxyResolver *resolver, + const gchar *uri_scheme, + const gchar *proxy); + +G_END_DECLS + +#endif /* __G_SIMPLE_PROXY_RESOLVER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocket.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocket.h new file mode 100644 index 00000000..341e23e3 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocket.h @@ -0,0 +1,343 @@ +/* + * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima + * Copyright © 2009 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Christian Kellner + * Samuel Cormier-Iijima + * Ryan Lortie + */ + +#ifndef __G_SOCKET_H__ +#define __G_SOCKET_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET (g_socket_get_type ()) +#define G_SOCKET(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SOCKET, GSocket)) +#define G_SOCKET_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SOCKET, GSocketClass)) +#define G_IS_SOCKET(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SOCKET)) +#define G_IS_SOCKET_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_SOCKET)) +#define G_SOCKET_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SOCKET, GSocketClass)) + +typedef struct _GSocketPrivate GSocketPrivate; +typedef struct _GSocketClass GSocketClass; + +struct _GSocketClass +{ + GObjectClass parent_class; + + /*< private >*/ + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); + void (*_g_reserved7) (void); + void (*_g_reserved8) (void); + void (*_g_reserved9) (void); + void (*_g_reserved10) (void); +}; + +struct _GSocket +{ + GObject parent_instance; + GSocketPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GSocket * g_socket_new (GSocketFamily family, + GSocketType type, + GSocketProtocol protocol, + GError **error); +GIO_AVAILABLE_IN_ALL +GSocket * g_socket_new_from_fd (gint fd, + GError **error); +GIO_AVAILABLE_IN_ALL +int g_socket_get_fd (GSocket *socket); +GIO_AVAILABLE_IN_ALL +GSocketFamily g_socket_get_family (GSocket *socket); +GIO_AVAILABLE_IN_ALL +GSocketType g_socket_get_socket_type (GSocket *socket); +GIO_AVAILABLE_IN_ALL +GSocketProtocol g_socket_get_protocol (GSocket *socket); +GIO_AVAILABLE_IN_ALL +GSocketAddress * g_socket_get_local_address (GSocket *socket, + GError **error); +GIO_AVAILABLE_IN_ALL +GSocketAddress * g_socket_get_remote_address (GSocket *socket, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_socket_set_blocking (GSocket *socket, + gboolean blocking); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_get_blocking (GSocket *socket); +GIO_AVAILABLE_IN_ALL +void g_socket_set_keepalive (GSocket *socket, + gboolean keepalive); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_get_keepalive (GSocket *socket); +GIO_AVAILABLE_IN_ALL +gint g_socket_get_listen_backlog (GSocket *socket); +GIO_AVAILABLE_IN_ALL +void g_socket_set_listen_backlog (GSocket *socket, + gint backlog); +GIO_AVAILABLE_IN_ALL +guint g_socket_get_timeout (GSocket *socket); +GIO_AVAILABLE_IN_ALL +void g_socket_set_timeout (GSocket *socket, + guint timeout); + +GIO_AVAILABLE_IN_2_32 +guint g_socket_get_ttl (GSocket *socket); +GIO_AVAILABLE_IN_2_32 +void g_socket_set_ttl (GSocket *socket, + guint ttl); + +GIO_AVAILABLE_IN_2_32 +gboolean g_socket_get_broadcast (GSocket *socket); +GIO_AVAILABLE_IN_2_32 +void g_socket_set_broadcast (GSocket *socket, + gboolean broadcast); + +GIO_AVAILABLE_IN_2_32 +gboolean g_socket_get_multicast_loopback (GSocket *socket); +GIO_AVAILABLE_IN_2_32 +void g_socket_set_multicast_loopback (GSocket *socket, + gboolean loopback); +GIO_AVAILABLE_IN_2_32 +guint g_socket_get_multicast_ttl (GSocket *socket); +GIO_AVAILABLE_IN_2_32 +void g_socket_set_multicast_ttl (GSocket *socket, + guint ttl); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_is_connected (GSocket *socket); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_bind (GSocket *socket, + GSocketAddress *address, + gboolean allow_reuse, + GError **error); +GIO_AVAILABLE_IN_2_32 +gboolean g_socket_join_multicast_group (GSocket *socket, + GInetAddress *group, + gboolean source_specific, + const gchar *iface, + GError **error); +GIO_AVAILABLE_IN_2_32 +gboolean g_socket_leave_multicast_group (GSocket *socket, + GInetAddress *group, + gboolean source_specific, + const gchar *iface, + GError **error); +GIO_AVAILABLE_IN_2_56 +gboolean g_socket_join_multicast_group_ssm (GSocket *socket, + GInetAddress *group, + GInetAddress *source_specific, + const gchar *iface, + GError **error); +GIO_AVAILABLE_IN_2_56 +gboolean g_socket_leave_multicast_group_ssm (GSocket *socket, + GInetAddress *group, + GInetAddress *source_specific, + const gchar *iface, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_connect (GSocket *socket, + GSocketAddress *address, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_check_connect_result (GSocket *socket, + GError **error); + +GIO_AVAILABLE_IN_ALL +gssize g_socket_get_available_bytes (GSocket *socket); + +GIO_AVAILABLE_IN_ALL +GIOCondition g_socket_condition_check (GSocket *socket, + GIOCondition condition); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_condition_wait (GSocket *socket, + GIOCondition condition, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_32 +gboolean g_socket_condition_timed_wait (GSocket *socket, + GIOCondition condition, + gint64 timeout_us, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GSocket * g_socket_accept (GSocket *socket, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_listen (GSocket *socket, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_socket_receive (GSocket *socket, + gchar *buffer, + gsize size, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_80 +GBytes * g_socket_receive_bytes (GSocket *socket, + gsize size, + gint64 timeout_us, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_socket_receive_from (GSocket *socket, + GSocketAddress **address, + gchar *buffer, + gsize size, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_80 +GBytes * g_socket_receive_bytes_from (GSocket *socket, + GSocketAddress **address, + gsize size, + gint64 timeout_us, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_socket_send (GSocket *socket, + const gchar *buffer, + gsize size, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_socket_send_to (GSocket *socket, + GSocketAddress *address, + const gchar *buffer, + gsize size, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_socket_receive_message (GSocket *socket, + GSocketAddress **address, + GInputVector *vectors, + gint num_vectors, + GSocketControlMessage ***messages, + gint *num_messages, + gint *flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_socket_send_message (GSocket *socket, + GSocketAddress *address, + GOutputVector *vectors, + gint num_vectors, + GSocketControlMessage **messages, + gint num_messages, + gint flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_48 +gint g_socket_receive_messages (GSocket *socket, + GInputMessage *messages, + guint num_messages, + gint flags, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_44 +gint g_socket_send_messages (GSocket *socket, + GOutputMessage *messages, + guint num_messages, + gint flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_socket_close (GSocket *socket, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_shutdown (GSocket *socket, + gboolean shutdown_read, + gboolean shutdown_write, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_is_closed (GSocket *socket); +GIO_AVAILABLE_IN_ALL +GSource * g_socket_create_source (GSocket *socket, + GIOCondition condition, + GCancellable *cancellable); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_speaks_ipv4 (GSocket *socket); +GIO_AVAILABLE_IN_ALL +GCredentials *g_socket_get_credentials (GSocket *socket, + GError **error); + +GIO_AVAILABLE_IN_ALL +gssize g_socket_receive_with_blocking (GSocket *socket, + gchar *buffer, + gsize size, + gboolean blocking, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gssize g_socket_send_with_blocking (GSocket *socket, + const gchar *buffer, + gsize size, + gboolean blocking, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_60 +GPollableReturn g_socket_send_message_with_timeout (GSocket *socket, + GSocketAddress *address, + const GOutputVector *vectors, + gint num_vectors, + GSocketControlMessage **messages, + gint num_messages, + gint flags, + gint64 timeout_us, + gsize *bytes_written, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_36 +gboolean g_socket_get_option (GSocket *socket, + gint level, + gint optname, + gint *value, + GError **error); +GIO_AVAILABLE_IN_2_36 +gboolean g_socket_set_option (GSocket *socket, + gint level, + gint optname, + gint value, + GError **error); + +G_END_DECLS + +#endif /* __G_SOCKET_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocketaddress.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketaddress.h new file mode 100644 index 00000000..b2dcef24 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketaddress.h @@ -0,0 +1,84 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Christian Kellner + * Samuel Cormier-Iijima + */ + +#ifndef __G_SOCKET_ADDRESS_H__ +#define __G_SOCKET_ADDRESS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET_ADDRESS (g_socket_address_get_type ()) +#define G_SOCKET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SOCKET_ADDRESS, GSocketAddress)) +#define G_SOCKET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SOCKET_ADDRESS, GSocketAddressClass)) +#define G_IS_SOCKET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SOCKET_ADDRESS)) +#define G_IS_SOCKET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SOCKET_ADDRESS)) +#define G_SOCKET_ADDRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SOCKET_ADDRESS, GSocketAddressClass)) + +typedef struct _GSocketAddressClass GSocketAddressClass; + +struct _GSocketAddress +{ + GObject parent_instance; +}; + +struct _GSocketAddressClass +{ + GObjectClass parent_class; + + GSocketFamily (*get_family) (GSocketAddress *address); + + gssize (*get_native_size) (GSocketAddress *address); + + gboolean (*to_native) (GSocketAddress *address, + gpointer dest, + gsize destlen, + GError **error); +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_address_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketFamily g_socket_address_get_family (GSocketAddress *address); + +GIO_AVAILABLE_IN_ALL +GSocketAddress * g_socket_address_new_from_native (gpointer native, + gsize len); + +GIO_AVAILABLE_IN_ALL +gboolean g_socket_address_to_native (GSocketAddress *address, + gpointer dest, + gsize destlen, + GError **error); + +GIO_AVAILABLE_IN_ALL +gssize g_socket_address_get_native_size (GSocketAddress *address); + +G_END_DECLS + +#endif /* __G_SOCKET_ADDRESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocketaddressenumerator.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketaddressenumerator.h new file mode 100644 index 00000000..b3ff71c6 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketaddressenumerator.h @@ -0,0 +1,97 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_SOCKET_ADDRESS_ENUMERATOR_H__ +#define __G_SOCKET_ADDRESS_ENUMERATOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET_ADDRESS_ENUMERATOR (g_socket_address_enumerator_get_type ()) +#define G_SOCKET_ADDRESS_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SOCKET_ADDRESS_ENUMERATOR, GSocketAddressEnumerator)) +#define G_SOCKET_ADDRESS_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SOCKET_ADDRESS_ENUMERATOR, GSocketAddressEnumeratorClass)) +#define G_IS_SOCKET_ADDRESS_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SOCKET_ADDRESS_ENUMERATOR)) +#define G_IS_SOCKET_ADDRESS_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SOCKET_ADDRESS_ENUMERATOR)) +#define G_SOCKET_ADDRESS_ENUMERATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SOCKET_ADDRESS_ENUMERATOR, GSocketAddressEnumeratorClass)) + +typedef struct _GSocketAddressEnumeratorClass GSocketAddressEnumeratorClass; + +struct _GSocketAddressEnumerator +{ + /*< private >*/ + GObject parent_instance; +}; + +/** + * GSocketAddressEnumeratorClass: + * @next: Virtual method for g_socket_address_enumerator_next(). + * @next_async: Virtual method for g_socket_address_enumerator_next_async(). + * @next_finish: Virtual method for g_socket_address_enumerator_next_finish(). + * + * Class structure for #GSocketAddressEnumerator. + */ +struct _GSocketAddressEnumeratorClass +{ + /*< private >*/ + GObjectClass parent_class; + + /*< public >*/ + /* Virtual Table */ + + GSocketAddress * (* next) (GSocketAddressEnumerator *enumerator, + GCancellable *cancellable, + GError **error); + + void (* next_async) (GSocketAddressEnumerator *enumerator, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + GSocketAddress * (* next_finish) (GSocketAddressEnumerator *enumerator, + GAsyncResult *result, + GError **error); +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_address_enumerator_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_socket_address_enumerator_next (GSocketAddressEnumerator *enumerator, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_socket_address_enumerator_next_async (GSocketAddressEnumerator *enumerator, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_socket_address_enumerator_next_finish (GSocketAddressEnumerator *enumerator, + GAsyncResult *result, + GError **error); + +G_END_DECLS + + +#endif /* __G_SOCKET_ADDRESS_ENUMERATOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocketclient.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketclient.h new file mode 100644 index 00000000..e9f815ee --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketclient.h @@ -0,0 +1,199 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2008, 2009 Codethink Limited + * Copyright © 2009 Red Hat, Inc + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + * Alexander Larsson + */ + +#ifndef __G_SOCKET_CLIENT_H__ +#define __G_SOCKET_CLIENT_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET_CLIENT (g_socket_client_get_type ()) +#define G_SOCKET_CLIENT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SOCKET_CLIENT, GSocketClient)) +#define G_SOCKET_CLIENT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SOCKET_CLIENT, GSocketClientClass)) +#define G_IS_SOCKET_CLIENT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SOCKET_CLIENT)) +#define G_IS_SOCKET_CLIENT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_SOCKET_CLIENT)) +#define G_SOCKET_CLIENT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SOCKET_CLIENT, GSocketClientClass)) + +typedef struct _GSocketClientPrivate GSocketClientPrivate; +typedef struct _GSocketClientClass GSocketClientClass; + +struct _GSocketClientClass +{ + GObjectClass parent_class; + + void (* event) (GSocketClient *client, + GSocketClientEvent event, + GSocketConnectable *connectable, + GIOStream *connection); + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); +}; + +struct _GSocketClient +{ + GObject parent_instance; + GSocketClientPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_client_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketClient *g_socket_client_new (void); + +GIO_AVAILABLE_IN_ALL +GSocketFamily g_socket_client_get_family (GSocketClient *client); +GIO_AVAILABLE_IN_ALL +void g_socket_client_set_family (GSocketClient *client, + GSocketFamily family); +GIO_AVAILABLE_IN_ALL +GSocketType g_socket_client_get_socket_type (GSocketClient *client); +GIO_AVAILABLE_IN_ALL +void g_socket_client_set_socket_type (GSocketClient *client, + GSocketType type); +GIO_AVAILABLE_IN_ALL +GSocketProtocol g_socket_client_get_protocol (GSocketClient *client); +GIO_AVAILABLE_IN_ALL +void g_socket_client_set_protocol (GSocketClient *client, + GSocketProtocol protocol); +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_socket_client_get_local_address (GSocketClient *client); +GIO_AVAILABLE_IN_ALL +void g_socket_client_set_local_address (GSocketClient *client, + GSocketAddress *address); +GIO_AVAILABLE_IN_ALL +guint g_socket_client_get_timeout (GSocketClient *client); +GIO_AVAILABLE_IN_ALL +void g_socket_client_set_timeout (GSocketClient *client, + guint timeout); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_client_get_enable_proxy (GSocketClient *client); +GIO_AVAILABLE_IN_ALL +void g_socket_client_set_enable_proxy (GSocketClient *client, + gboolean enable); + +GIO_AVAILABLE_IN_2_28 +gboolean g_socket_client_get_tls (GSocketClient *client); +GIO_AVAILABLE_IN_2_28 +void g_socket_client_set_tls (GSocketClient *client, + gboolean tls); +GIO_DEPRECATED_IN_2_72 +GTlsCertificateFlags g_socket_client_get_tls_validation_flags (GSocketClient *client); +GIO_DEPRECATED_IN_2_72 +void g_socket_client_set_tls_validation_flags (GSocketClient *client, + GTlsCertificateFlags flags); +GIO_AVAILABLE_IN_2_36 +GProxyResolver *g_socket_client_get_proxy_resolver (GSocketClient *client); +GIO_AVAILABLE_IN_2_36 +void g_socket_client_set_proxy_resolver (GSocketClient *client, + GProxyResolver *proxy_resolver); + +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_client_connect (GSocketClient *client, + GSocketConnectable *connectable, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_client_connect_to_host (GSocketClient *client, + const gchar *host_and_port, + guint16 default_port, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_client_connect_to_service (GSocketClient *client, + const gchar *domain, + const gchar *service, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_26 +GSocketConnection * g_socket_client_connect_to_uri (GSocketClient *client, + const gchar *uri, + guint16 default_port, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_socket_client_connect_async (GSocketClient *client, + GSocketConnectable *connectable, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_client_connect_finish (GSocketClient *client, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_socket_client_connect_to_host_async (GSocketClient *client, + const gchar *host_and_port, + guint16 default_port, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_client_connect_to_host_finish (GSocketClient *client, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_socket_client_connect_to_service_async (GSocketClient *client, + const gchar *domain, + const gchar *service, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_client_connect_to_service_finish (GSocketClient *client, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_socket_client_connect_to_uri_async (GSocketClient *client, + const gchar *uri, + guint16 default_port, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_client_connect_to_uri_finish (GSocketClient *client, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_socket_client_add_application_proxy (GSocketClient *client, + const gchar *protocol); + +G_END_DECLS + +#endif /* __G_SOCKET_CLIENT_H___ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocketconnectable.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketconnectable.h new file mode 100644 index 00000000..bedef569 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketconnectable.h @@ -0,0 +1,78 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_SOCKET_CONNECTABLE_H__ +#define __G_SOCKET_CONNECTABLE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET_CONNECTABLE (g_socket_connectable_get_type ()) +#define G_SOCKET_CONNECTABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SOCKET_CONNECTABLE, GSocketConnectable)) +#define G_IS_SOCKET_CONNECTABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SOCKET_CONNECTABLE)) +#define G_SOCKET_CONNECTABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_SOCKET_CONNECTABLE, GSocketConnectableIface)) + +typedef struct _GSocketConnectableIface GSocketConnectableIface; + +/** + * GSocketConnectableIface: + * @g_iface: The parent interface. + * @enumerate: Creates a #GSocketAddressEnumerator + * @proxy_enumerate: Creates a #GProxyAddressEnumerator + * @to_string: Format the connectable’s address as a string for debugging. + * Implementing this is optional. (Since: 2.48) + * + * Provides an interface for returning a #GSocketAddressEnumerator + * and #GProxyAddressEnumerator + */ +struct _GSocketConnectableIface +{ + GTypeInterface g_iface; + + /* Virtual Table */ + + GSocketAddressEnumerator * (* enumerate) (GSocketConnectable *connectable); + + GSocketAddressEnumerator * (* proxy_enumerate) (GSocketConnectable *connectable); + + gchar * (* to_string) (GSocketConnectable *connectable); +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_connectable_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketAddressEnumerator *g_socket_connectable_enumerate (GSocketConnectable *connectable); + +GIO_AVAILABLE_IN_ALL +GSocketAddressEnumerator *g_socket_connectable_proxy_enumerate (GSocketConnectable *connectable); + +GIO_AVAILABLE_IN_2_48 +gchar *g_socket_connectable_to_string (GSocketConnectable *connectable); + +G_END_DECLS + + +#endif /* __G_SOCKET_CONNECTABLE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocketconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketconnection.h new file mode 100644 index 00000000..45de5ba9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketconnection.h @@ -0,0 +1,117 @@ +/* GIO - GLib Input, Output and Streaming Library + * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima + * Copyright © 2009 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Christian Kellner + * Samuel Cormier-Iijima + * Ryan Lortie + * Alexander Larsson + */ + +#ifndef __G_SOCKET_CONNECTION_H__ +#define __G_SOCKET_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET_CONNECTION (g_socket_connection_get_type ()) +#define G_SOCKET_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SOCKET_CONNECTION, GSocketConnection)) +#define G_SOCKET_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SOCKET_CONNECTION, GSocketConnectionClass)) +#define G_IS_SOCKET_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SOCKET_CONNECTION)) +#define G_IS_SOCKET_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_SOCKET_CONNECTION)) +#define G_SOCKET_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SOCKET_CONNECTION, GSocketConnectionClass)) + +typedef struct _GSocketConnectionPrivate GSocketConnectionPrivate; +typedef struct _GSocketConnectionClass GSocketConnectionClass; + +struct _GSocketConnectionClass +{ + GIOStreamClass parent_class; + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); +}; + +struct _GSocketConnection +{ + GIOStream parent_instance; + GSocketConnectionPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_connection_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_32 +gboolean g_socket_connection_is_connected (GSocketConnection *connection); +GIO_AVAILABLE_IN_2_32 +gboolean g_socket_connection_connect (GSocketConnection *connection, + GSocketAddress *address, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_32 +void g_socket_connection_connect_async (GSocketConnection *connection, + GSocketAddress *address, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_32 +gboolean g_socket_connection_connect_finish (GSocketConnection *connection, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +GSocket *g_socket_connection_get_socket (GSocketConnection *connection); +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_socket_connection_get_local_address (GSocketConnection *connection, + GError **error); +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_socket_connection_get_remote_address (GSocketConnection *connection, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_socket_connection_factory_register_type (GType g_type, + GSocketFamily family, + GSocketType type, + gint protocol); +GIO_AVAILABLE_IN_ALL +GType g_socket_connection_factory_lookup_type (GSocketFamily family, + GSocketType type, + gint protocol_id); +GIO_AVAILABLE_IN_ALL +GSocketConnection *g_socket_connection_factory_create_connection (GSocket *socket); + +G_END_DECLS + +#endif /* __G_SOCKET_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocketcontrolmessage.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketcontrolmessage.h new file mode 100644 index 00000000..51be2e17 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketcontrolmessage.h @@ -0,0 +1,113 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2009 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_SOCKET_CONTROL_MESSAGE_H__ +#define __G_SOCKET_CONTROL_MESSAGE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET_CONTROL_MESSAGE (g_socket_control_message_get_type ()) +#define G_SOCKET_CONTROL_MESSAGE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SOCKET_CONTROL_MESSAGE, \ + GSocketControlMessage)) +#define G_SOCKET_CONTROL_MESSAGE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SOCKET_CONTROL_MESSAGE, \ + GSocketControlMessageClass)) +#define G_IS_SOCKET_CONTROL_MESSAGE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SOCKET_CONTROL_MESSAGE)) +#define G_IS_SOCKET_CONTROL_MESSAGE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_SOCKET_CONTROL_MESSAGE)) +#define G_SOCKET_CONTROL_MESSAGE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SOCKET_CONTROL_MESSAGE, \ + GSocketControlMessageClass)) + +typedef struct _GSocketControlMessagePrivate GSocketControlMessagePrivate; +typedef struct _GSocketControlMessageClass GSocketControlMessageClass; + +/** + * GSocketControlMessageClass: + * @get_size: gets the size of the message. + * @get_level: gets the protocol of the message. + * @get_type: gets the protocol specific type of the message. + * @serialize: Writes out the message data. + * @deserialize: Tries to deserialize a message. + * + * Class structure for #GSocketControlMessage. + **/ + +struct _GSocketControlMessageClass +{ + GObjectClass parent_class; + + gsize (* get_size) (GSocketControlMessage *message); + int (* get_level) (GSocketControlMessage *message); + int (* get_type) (GSocketControlMessage *message); + void (* serialize) (GSocketControlMessage *message, + gpointer data); + GSocketControlMessage *(* deserialize) (int level, + int type, + gsize size, + gpointer data); + + /*< private >*/ + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +struct _GSocketControlMessage +{ + GObject parent_instance; + GSocketControlMessagePrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_control_message_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +gsize g_socket_control_message_get_size (GSocketControlMessage *message); +GIO_AVAILABLE_IN_ALL +int g_socket_control_message_get_level (GSocketControlMessage *message); +GIO_AVAILABLE_IN_ALL +int g_socket_control_message_get_msg_type (GSocketControlMessage *message); +GIO_AVAILABLE_IN_ALL +void g_socket_control_message_serialize (GSocketControlMessage *message, + gpointer data); +GIO_AVAILABLE_IN_ALL +GSocketControlMessage *g_socket_control_message_deserialize (int level, + int type, + gsize size, + gpointer data); + + +G_END_DECLS + +#endif /* __G_SOCKET_CONTROL_MESSAGE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocketlistener.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketlistener.h new file mode 100644 index 00000000..9ad6c8fe --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketlistener.h @@ -0,0 +1,157 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima + * Copyright © 2009 Codethink Limited + * Copyright © 2009 Red Hat, Inc + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Christian Kellner + * Samuel Cormier-Iijima + * Ryan Lortie + * Alexander Larsson + */ + +#ifndef __G_SOCKET_LISTENER_H__ +#define __G_SOCKET_LISTENER_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET_LISTENER (g_socket_listener_get_type ()) +#define G_SOCKET_LISTENER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SOCKET_LISTENER, GSocketListener)) +#define G_SOCKET_LISTENER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SOCKET_LISTENER, GSocketListenerClass)) +#define G_IS_SOCKET_LISTENER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SOCKET_LISTENER)) +#define G_IS_SOCKET_LISTENER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_SOCKET_LISTENER)) +#define G_SOCKET_LISTENER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SOCKET_LISTENER, GSocketListenerClass)) + +typedef struct _GSocketListenerPrivate GSocketListenerPrivate; +typedef struct _GSocketListenerClass GSocketListenerClass; + +/** + * GSocketListenerClass: + * @changed: virtual method called when the set of socket listened to changes + * + * Class structure for #GSocketListener. + **/ +struct _GSocketListenerClass +{ + GObjectClass parent_class; + + void (* changed) (GSocketListener *listener); + + void (* event) (GSocketListener *listener, + GSocketListenerEvent event, + GSocket *socket); + + /* Padding for future expansion */ + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); +}; + +struct _GSocketListener +{ + GObject parent_instance; + GSocketListenerPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_listener_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketListener * g_socket_listener_new (void); + +GIO_AVAILABLE_IN_ALL +void g_socket_listener_set_backlog (GSocketListener *listener, + int listen_backlog); + +GIO_AVAILABLE_IN_ALL +gboolean g_socket_listener_add_socket (GSocketListener *listener, + GSocket *socket, + GObject *source_object, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_listener_add_address (GSocketListener *listener, + GSocketAddress *address, + GSocketType type, + GSocketProtocol protocol, + GObject *source_object, + GSocketAddress **effective_address, + GError **error); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_listener_add_inet_port (GSocketListener *listener, + guint16 port, + GObject *source_object, + GError **error); +GIO_AVAILABLE_IN_ALL +guint16 g_socket_listener_add_any_inet_port (GSocketListener *listener, + GObject *source_object, + GError **error); + +GIO_AVAILABLE_IN_ALL +GSocket * g_socket_listener_accept_socket (GSocketListener *listener, + GObject **source_object, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +void g_socket_listener_accept_socket_async (GSocketListener *listener, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GSocket * g_socket_listener_accept_socket_finish (GSocketListener *listener, + GAsyncResult *result, + GObject **source_object, + GError **error); + + +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_listener_accept (GSocketListener *listener, + GObject **source_object, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_socket_listener_accept_async (GSocketListener *listener, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +GSocketConnection * g_socket_listener_accept_finish (GSocketListener *listener, + GAsyncResult *result, + GObject **source_object, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_socket_listener_close (GSocketListener *listener); + +G_END_DECLS + +#endif /* __G_SOCKET_LISTENER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsocketservice.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketservice.h new file mode 100644 index 00000000..f4e7c220 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsocketservice.h @@ -0,0 +1,95 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2009 Codethink Limited + * Copyright © 2009 Red Hat, Inc + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + * Alexander Larsson + */ + +#ifndef __G_SOCKET_SERVICE_H__ +#define __G_SOCKET_SERVICE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET_SERVICE (g_socket_service_get_type ()) +#define G_SOCKET_SERVICE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_SOCKET_SERVICE, GSocketService)) +#define G_SOCKET_SERVICE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_SOCKET_SERVICE, GSocketServiceClass)) +#define G_IS_SOCKET_SERVICE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_SOCKET_SERVICE)) +#define G_IS_SOCKET_SERVICE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_SOCKET_SERVICE)) +#define G_SOCKET_SERVICE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_SOCKET_SERVICE, GSocketServiceClass)) + +typedef struct _GSocketServicePrivate GSocketServicePrivate; +typedef struct _GSocketServiceClass GSocketServiceClass; + +/** + * GSocketServiceClass: + * @incoming: signal emitted when new connections are accepted + * + * Class structure for #GSocketService. + */ +struct _GSocketServiceClass +{ + GSocketListenerClass parent_class; + + gboolean (* incoming) (GSocketService *service, + GSocketConnection *connection, + GObject *source_object); + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); +}; + +struct _GSocketService +{ + GSocketListener parent_instance; + GSocketServicePrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_socket_service_get_type (void); + +GIO_AVAILABLE_IN_ALL +GSocketService *g_socket_service_new (void); +GIO_AVAILABLE_IN_ALL +void g_socket_service_start (GSocketService *service); +GIO_AVAILABLE_IN_ALL +void g_socket_service_stop (GSocketService *service); +GIO_AVAILABLE_IN_ALL +gboolean g_socket_service_is_active (GSocketService *service); + + +G_END_DECLS + +#endif /* __G_SOCKET_SERVICE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsrvtarget.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsrvtarget.h new file mode 100644 index 00000000..92bb256b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsrvtarget.h @@ -0,0 +1,60 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_SRV_TARGET_H__ +#define __G_SRV_TARGET_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GIO_AVAILABLE_IN_ALL +GType g_srv_target_get_type (void) G_GNUC_CONST; +#define G_TYPE_SRV_TARGET (g_srv_target_get_type ()) + +GIO_AVAILABLE_IN_ALL +GSrvTarget *g_srv_target_new (const gchar *hostname, + guint16 port, + guint16 priority, + guint16 weight); +GIO_AVAILABLE_IN_ALL +GSrvTarget *g_srv_target_copy (GSrvTarget *target); +GIO_AVAILABLE_IN_ALL +void g_srv_target_free (GSrvTarget *target); + +GIO_AVAILABLE_IN_ALL +const gchar *g_srv_target_get_hostname (GSrvTarget *target); +GIO_AVAILABLE_IN_ALL +guint16 g_srv_target_get_port (GSrvTarget *target); +GIO_AVAILABLE_IN_ALL +guint16 g_srv_target_get_priority (GSrvTarget *target); +GIO_AVAILABLE_IN_ALL +guint16 g_srv_target_get_weight (GSrvTarget *target); + +GIO_AVAILABLE_IN_ALL +GList *g_srv_target_list_sort (GList *targets); + +G_END_DECLS + +#endif /* __G_SRV_TARGET_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsubprocess.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsubprocess.h new file mode 100644 index 00000000..4d5b4886 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsubprocess.h @@ -0,0 +1,169 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2012 Colin Walters + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Colin Walters + */ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __G_SUBPROCESS_H__ +#define __G_SUBPROCESS_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SUBPROCESS (g_subprocess_get_type ()) +#define G_SUBPROCESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SUBPROCESS, GSubprocess)) +#define G_IS_SUBPROCESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SUBPROCESS)) + +GIO_AVAILABLE_IN_2_40 +GType g_subprocess_get_type (void) G_GNUC_CONST; + +/**** Core API ****/ + +GIO_AVAILABLE_IN_2_40 +GSubprocess * g_subprocess_new (GSubprocessFlags flags, + GError **error, + const gchar *argv0, + ...) G_GNUC_NULL_TERMINATED; +GIO_AVAILABLE_IN_2_40 +GSubprocess * g_subprocess_newv (const gchar * const *argv, + GSubprocessFlags flags, + GError **error); + +GIO_AVAILABLE_IN_2_40 +GOutputStream * g_subprocess_get_stdin_pipe (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +GInputStream * g_subprocess_get_stdout_pipe (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +GInputStream * g_subprocess_get_stderr_pipe (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +const gchar * g_subprocess_get_identifier (GSubprocess *subprocess); + +#ifdef G_OS_UNIX +GIO_AVAILABLE_IN_2_40 +void g_subprocess_send_signal (GSubprocess *subprocess, + gint signal_num); +#endif + +GIO_AVAILABLE_IN_2_40 +void g_subprocess_force_exit (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_wait (GSubprocess *subprocess, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_40 +void g_subprocess_wait_async (GSubprocess *subprocess, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_wait_finish (GSubprocess *subprocess, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_wait_check (GSubprocess *subprocess, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_40 +void g_subprocess_wait_check_async (GSubprocess *subprocess, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_wait_check_finish (GSubprocess *subprocess, + GAsyncResult *result, + GError **error); + + +GIO_AVAILABLE_IN_2_40 +gint g_subprocess_get_status (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_get_successful (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_get_if_exited (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +gint g_subprocess_get_exit_status (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_get_if_signaled (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +gint g_subprocess_get_term_sig (GSubprocess *subprocess); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_communicate (GSubprocess *subprocess, + GBytes *stdin_buf, + GCancellable *cancellable, + GBytes **stdout_buf, + GBytes **stderr_buf, + GError **error); +GIO_AVAILABLE_IN_2_40 +void g_subprocess_communicate_async (GSubprocess *subprocess, + GBytes *stdin_buf, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_communicate_finish (GSubprocess *subprocess, + GAsyncResult *result, + GBytes **stdout_buf, + GBytes **stderr_buf, + GError **error); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_communicate_utf8 (GSubprocess *subprocess, + const char *stdin_buf, + GCancellable *cancellable, + char **stdout_buf, + char **stderr_buf, + GError **error); +GIO_AVAILABLE_IN_2_40 +void g_subprocess_communicate_utf8_async (GSubprocess *subprocess, + const char *stdin_buf, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_40 +gboolean g_subprocess_communicate_utf8_finish (GSubprocess *subprocess, + GAsyncResult *result, + char **stdout_buf, + char **stderr_buf, + GError **error); + +G_END_DECLS + +#endif /* __G_SUBPROCESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gsubprocesslauncher.h b/illumos-x86_64/usr/include/glib-2.0/gio/gsubprocesslauncher.h new file mode 100644 index 00000000..0ab91452 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gsubprocesslauncher.h @@ -0,0 +1,121 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2012,2013 Colin Walters + * Copyright © 2012,2013 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Ryan Lortie + * Author: Colin Walters + */ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __G_SUBPROCESS_LAUNCHER_H__ +#define __G_SUBPROCESS_LAUNCHER_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_SUBPROCESS_LAUNCHER (g_subprocess_launcher_get_type ()) +#define G_SUBPROCESS_LAUNCHER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SUBPROCESS_LAUNCHER, GSubprocessLauncher)) +#define G_IS_SUBPROCESS_LAUNCHER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SUBPROCESS_LAUNCHER)) + +GIO_AVAILABLE_IN_2_40 +GType g_subprocess_launcher_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_40 +GSubprocessLauncher * g_subprocess_launcher_new (GSubprocessFlags flags); + +GIO_AVAILABLE_IN_2_40 +GSubprocess * g_subprocess_launcher_spawn (GSubprocessLauncher *self, + GError **error, + const gchar *argv0, + ...) G_GNUC_NULL_TERMINATED; + +GIO_AVAILABLE_IN_2_40 +GSubprocess * g_subprocess_launcher_spawnv (GSubprocessLauncher *self, + const gchar * const *argv, + GError **error); + +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_set_environ (GSubprocessLauncher *self, + gchar **env); + +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_setenv (GSubprocessLauncher *self, + const gchar *variable, + const gchar *value, + gboolean overwrite); + +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_unsetenv (GSubprocessLauncher *self, + const gchar *variable); + +GIO_AVAILABLE_IN_2_40 +const gchar * g_subprocess_launcher_getenv (GSubprocessLauncher *self, + const gchar *variable); + +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_set_cwd (GSubprocessLauncher *self, + const gchar *cwd); +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_set_flags (GSubprocessLauncher *self, + GSubprocessFlags flags); + +/* Extended I/O control, only available on UNIX */ +#ifdef G_OS_UNIX +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_set_stdin_file_path (GSubprocessLauncher *self, + const gchar *path); +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_take_stdin_fd (GSubprocessLauncher *self, + gint fd); +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_set_stdout_file_path (GSubprocessLauncher *self, + const gchar *path); +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_take_stdout_fd (GSubprocessLauncher *self, + gint fd); +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_set_stderr_file_path (GSubprocessLauncher *self, + const gchar *path); +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_take_stderr_fd (GSubprocessLauncher *self, + gint fd); + +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_take_fd (GSubprocessLauncher *self, + gint source_fd, + gint target_fd); + +GIO_AVAILABLE_IN_2_68 +void g_subprocess_launcher_close (GSubprocessLauncher *self); + +/* Child setup, only available on UNIX */ +GIO_AVAILABLE_IN_2_40 +void g_subprocess_launcher_set_child_setup (GSubprocessLauncher *self, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GDestroyNotify destroy_notify); +#endif + +G_END_DECLS + +#endif /* __G_SUBPROCESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtask.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtask.h new file mode 100644 index 00000000..9fabddce --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtask.h @@ -0,0 +1,219 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright 2011 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_TASK_H__ +#define __G_TASK_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TASK (g_task_get_type ()) +#define G_TASK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_TASK, GTask)) +#define G_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_TASK, GTaskClass)) +#define G_IS_TASK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_TASK)) +#define G_IS_TASK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_TASK)) +#define G_TASK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_TASK, GTaskClass)) + +typedef struct _GTaskClass GTaskClass; + +GIO_AVAILABLE_IN_2_36 +GType g_task_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_36 +GTask *g_task_new (gpointer source_object, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer callback_data); + +GIO_AVAILABLE_IN_2_36 +void g_task_report_error (gpointer source_object, + GAsyncReadyCallback callback, + gpointer callback_data, + gpointer source_tag, + GError *error); +GIO_AVAILABLE_IN_2_36 +void g_task_report_new_error (gpointer source_object, + GAsyncReadyCallback callback, + gpointer callback_data, + gpointer source_tag, + GQuark domain, + gint code, + const char *format, + ...) G_GNUC_PRINTF(7, 8); + +GIO_AVAILABLE_IN_2_36 +void g_task_set_task_data (GTask *task, + gpointer task_data, + GDestroyNotify task_data_destroy); +GIO_AVAILABLE_IN_2_36 +void g_task_set_priority (GTask *task, + gint priority); +GIO_AVAILABLE_IN_2_36 +void g_task_set_check_cancellable (GTask *task, + gboolean check_cancellable); +GIO_AVAILABLE_IN_2_36 +void g_task_set_source_tag (GTask *task, + gpointer source_tag); +GIO_AVAILABLE_IN_2_60 +void g_task_set_name (GTask *task, + const gchar *name); +GIO_AVAILABLE_IN_2_76 +void g_task_set_static_name (GTask *task, + const gchar *name); + +/* Macro wrapper to set the task name when setting the source tag. */ +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76 +#define g_task_set_source_tag(task, tag) G_STMT_START { \ + GTask *_task = (task); \ + (g_task_set_source_tag) (_task, tag); \ + if (g_task_get_name (_task) == NULL) \ + g_task_set_static_name (_task, G_STRINGIFY (tag)); \ +} G_STMT_END +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76 +#if defined (__GNUC__) && (__GNUC__ >= 2) +#define g_task_set_name(task, name) G_STMT_START { \ + GTask *_task = (task); \ + if (__builtin_constant_p (name)) \ + g_task_set_static_name (_task, name); \ + else \ + g_task_set_name (_task, name); \ +} G_STMT_END +#endif +#endif + +GIO_AVAILABLE_IN_2_36 +gpointer g_task_get_source_object (GTask *task); +GIO_AVAILABLE_IN_2_36 +gpointer g_task_get_task_data (GTask *task); +GIO_AVAILABLE_IN_2_36 +gint g_task_get_priority (GTask *task); +GIO_AVAILABLE_IN_2_36 +GMainContext *g_task_get_context (GTask *task); +GIO_AVAILABLE_IN_2_36 +GCancellable *g_task_get_cancellable (GTask *task); +GIO_AVAILABLE_IN_2_36 +gboolean g_task_get_check_cancellable (GTask *task); +GIO_AVAILABLE_IN_2_36 +gpointer g_task_get_source_tag (GTask *task); +GIO_AVAILABLE_IN_2_60 +const gchar *g_task_get_name (GTask *task); + +GIO_AVAILABLE_IN_2_36 +gboolean g_task_is_valid (gpointer result, + gpointer source_object); + + +typedef void (*GTaskThreadFunc) (GTask *task, + gpointer source_object, + gpointer task_data, + GCancellable *cancellable); +GIO_AVAILABLE_IN_2_36 +void g_task_run_in_thread (GTask *task, + GTaskThreadFunc task_func); +GIO_AVAILABLE_IN_2_36 +void g_task_run_in_thread_sync (GTask *task, + GTaskThreadFunc task_func); +GIO_AVAILABLE_IN_2_36 +gboolean g_task_set_return_on_cancel (GTask *task, + gboolean return_on_cancel); +GIO_AVAILABLE_IN_2_36 +gboolean g_task_get_return_on_cancel (GTask *task); + +GIO_AVAILABLE_IN_2_36 +void g_task_attach_source (GTask *task, + GSource *source, + GSourceFunc callback); + + +GIO_AVAILABLE_IN_2_36 +void g_task_return_pointer (GTask *task, + gpointer result, + GDestroyNotify result_destroy); +GIO_AVAILABLE_IN_2_36 +void g_task_return_boolean (GTask *task, + gboolean result); +GIO_AVAILABLE_IN_2_36 +void g_task_return_int (GTask *task, + gssize result); + +GIO_AVAILABLE_IN_2_36 +void g_task_return_error (GTask *task, + GError *error); +GIO_AVAILABLE_IN_2_80 +void g_task_return_prefixed_error (GTask *task, + GError *error, + const char *format, + ...) G_GNUC_PRINTF (3, 4); + +GIO_AVAILABLE_IN_2_36 +void g_task_return_new_error (GTask *task, + GQuark domain, + gint code, + const char *format, + ...) G_GNUC_PRINTF (4, 5); + +GIO_AVAILABLE_IN_2_80 +void g_task_return_new_error_literal (GTask *task, + GQuark domain, + gint code, + const char *message); +GIO_AVAILABLE_IN_2_64 +void g_task_return_value (GTask *task, + GValue *result); + +GIO_AVAILABLE_IN_2_36 +gboolean g_task_return_error_if_cancelled (GTask *task); + +GIO_AVAILABLE_IN_2_36 +gpointer g_task_propagate_pointer (GTask *task, + GError **error); +GIO_AVAILABLE_IN_2_36 +gboolean g_task_propagate_boolean (GTask *task, + GError **error); +GIO_AVAILABLE_IN_2_36 +gssize g_task_propagate_int (GTask *task, + GError **error); +GIO_AVAILABLE_IN_2_64 +gboolean g_task_propagate_value (GTask *task, + GValue *value, + GError **error); +GIO_AVAILABLE_IN_2_36 +gboolean g_task_had_error (GTask *task); +GIO_AVAILABLE_IN_2_44 +gboolean g_task_get_completed (GTask *task); + +/*< private >*/ +#ifndef __GTK_DOC_IGNORE__ +#ifndef __GI_SCANNER__ +/* Debugging API, not part of the public API */ +void g_task_print_alive_tasks (void); +#endif /* !__GI_SCANNER__ */ +#endif /* !__GTK_DOC_IGNORE__ */ + +G_END_DECLS + +#endif /* __G_TASK_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtcpconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtcpconnection.h new file mode 100644 index 00000000..03aa28ad --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtcpconnection.h @@ -0,0 +1,71 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2008, 2009 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_TCP_CONNECTION_H__ +#define __G_TCP_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TCP_CONNECTION (g_tcp_connection_get_type ()) +#define G_TCP_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_TCP_CONNECTION, GTcpConnection)) +#define G_TCP_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_TCP_CONNECTION, GTcpConnectionClass)) +#define G_IS_TCP_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_TCP_CONNECTION)) +#define G_IS_TCP_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_TCP_CONNECTION)) +#define G_TCP_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_TCP_CONNECTION, GTcpConnectionClass)) + +typedef struct _GTcpConnectionPrivate GTcpConnectionPrivate; +typedef struct _GTcpConnectionClass GTcpConnectionClass; + +struct _GTcpConnectionClass +{ + GSocketConnectionClass parent_class; +}; + +struct _GTcpConnection +{ + GSocketConnection parent_instance; + GTcpConnectionPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_tcp_connection_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +void g_tcp_connection_set_graceful_disconnect (GTcpConnection *connection, + gboolean graceful_disconnect); +GIO_AVAILABLE_IN_ALL +gboolean g_tcp_connection_get_graceful_disconnect (GTcpConnection *connection); + +G_END_DECLS + +#endif /* __G_TCP_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtcpwrapperconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtcpwrapperconnection.h new file mode 100644 index 00000000..1027154f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtcpwrapperconnection.h @@ -0,0 +1,71 @@ +/* GIO - GLib Input, Output and Streaming Library + * Copyright © 2010 Collabora Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Nicolas Dufresne + * + */ + +#ifndef __G_TCP_WRAPPER_CONNECTION_H__ +#define __G_TCP_WRAPPER_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TCP_WRAPPER_CONNECTION (g_tcp_wrapper_connection_get_type ()) +#define G_TCP_WRAPPER_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_TCP_WRAPPER_CONNECTION, GTcpWrapperConnection)) +#define G_TCP_WRAPPER_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_TCP_WRAPPER_CONNECTION, GTcpWrapperConnectionClass)) +#define G_IS_TCP_WRAPPER_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_TCP_WRAPPER_CONNECTION)) +#define G_IS_TCP_WRAPPER_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_TCP_WRAPPER_CONNECTION)) +#define G_TCP_WRAPPER_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_TCP_WRAPPER_CONNECTION, GTcpWrapperConnectionClass)) + +typedef struct _GTcpWrapperConnectionPrivate GTcpWrapperConnectionPrivate; +typedef struct _GTcpWrapperConnectionClass GTcpWrapperConnectionClass; + +struct _GTcpWrapperConnectionClass +{ + GTcpConnectionClass parent_class; +}; + +struct _GTcpWrapperConnection +{ + GTcpConnection parent_instance; + GTcpWrapperConnectionPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_tcp_wrapper_connection_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketConnection *g_tcp_wrapper_connection_new (GIOStream *base_io_stream, + GSocket *socket); +GIO_AVAILABLE_IN_ALL +GIOStream *g_tcp_wrapper_connection_get_base_io_stream (GTcpWrapperConnection *conn); + +G_END_DECLS + +#endif /* __G_TCP_WRAPPER_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtestdbus.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtestdbus.h new file mode 100644 index 00000000..f52ea1eb --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtestdbus.h @@ -0,0 +1,74 @@ +/* GIO testing utilities + * + * Copyright (C) 2008-2010 Red Hat, Inc. + * Copyright (C) 2012 Collabora Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: David Zeuthen + * Xavier Claessens + */ + +#ifndef __G_TEST_DBUS_H__ +#define __G_TEST_DBUS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TEST_DBUS \ + (g_test_dbus_get_type ()) +#define G_TEST_DBUS(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_TEST_DBUS, \ + GTestDBus)) +#define G_IS_TEST_DBUS(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_TEST_DBUS)) + +GIO_AVAILABLE_IN_2_34 +GType g_test_dbus_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_2_34 +GTestDBus * g_test_dbus_new (GTestDBusFlags flags); + +GIO_AVAILABLE_IN_2_34 +GTestDBusFlags g_test_dbus_get_flags (GTestDBus *self); + +GIO_AVAILABLE_IN_2_34 +const gchar * g_test_dbus_get_bus_address (GTestDBus *self); + +GIO_AVAILABLE_IN_2_34 +void g_test_dbus_add_service_dir (GTestDBus *self, + const gchar *path); + +GIO_AVAILABLE_IN_2_34 +void g_test_dbus_up (GTestDBus *self); + +GIO_AVAILABLE_IN_2_34 +void g_test_dbus_stop (GTestDBus *self); + +GIO_AVAILABLE_IN_2_34 +void g_test_dbus_down (GTestDBus *self); + +GIO_AVAILABLE_IN_2_34 +void g_test_dbus_unset (void); + +G_END_DECLS + +#endif /* __G_TEST_DBUS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gthemedicon.h b/illumos-x86_64/usr/include/glib-2.0/gio/gthemedicon.h new file mode 100644 index 00000000..432896d5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gthemedicon.h @@ -0,0 +1,65 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_THEMED_ICON_H__ +#define __G_THEMED_ICON_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_THEMED_ICON (g_themed_icon_get_type ()) +#define G_THEMED_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_THEMED_ICON, GThemedIcon)) +#define G_THEMED_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_THEMED_ICON, GThemedIconClass)) +#define G_IS_THEMED_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_THEMED_ICON)) +#define G_IS_THEMED_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_THEMED_ICON)) +#define G_THEMED_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_THEMED_ICON, GThemedIconClass)) + +typedef struct _GThemedIconClass GThemedIconClass; + +GIO_AVAILABLE_IN_ALL +GType g_themed_icon_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GIcon *g_themed_icon_new (const char *iconname); +GIO_AVAILABLE_IN_ALL +GIcon *g_themed_icon_new_with_default_fallbacks (const char *iconname); +GIO_AVAILABLE_IN_ALL +GIcon *g_themed_icon_new_from_names (char **iconnames, + int len); +GIO_AVAILABLE_IN_ALL +void g_themed_icon_prepend_name (GThemedIcon *icon, + const char *iconname); +GIO_AVAILABLE_IN_ALL +void g_themed_icon_append_name (GThemedIcon *icon, + const char *iconname); + +GIO_AVAILABLE_IN_ALL +const gchar* const * g_themed_icon_get_names (GThemedIcon *icon); + +G_END_DECLS + +#endif /* __G_THEMED_ICON_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gthreadedsocketservice.h b/illumos-x86_64/usr/include/glib-2.0/gio/gthreadedsocketservice.h new file mode 100644 index 00000000..48f5a312 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gthreadedsocketservice.h @@ -0,0 +1,83 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2009 Codethink Limited + * Copyright © 2009 Red Hat, Inc + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + * Alexander Larsson + */ + +#ifndef __G_THREADED_SOCKET_SERVICE_H__ +#define __G_THREADED_SOCKET_SERVICE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_THREADED_SOCKET_SERVICE (g_threaded_socket_service_get_type ()) +#define G_THREADED_SOCKET_SERVICE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_THREADED_SOCKET_SERVICE, \ + GThreadedSocketService)) +#define G_THREADED_SOCKET_SERVICE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_THREADED_SOCKET_SERVICE, \ + GThreadedSocketServiceClass)) +#define G_IS_THREADED_SOCKET_SERVICE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_THREADED_SOCKET_SERVICE)) +#define G_IS_THREADED_SOCKET_SERVICE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_THREADED_SOCKET_SERVICE)) +#define G_THREADED_SOCKET_SERVICE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_THREADED_SOCKET_SERVICE, \ + GThreadedSocketServiceClass)) + +typedef struct _GThreadedSocketServicePrivate GThreadedSocketServicePrivate; +typedef struct _GThreadedSocketServiceClass GThreadedSocketServiceClass; + +struct _GThreadedSocketServiceClass +{ + GSocketServiceClass parent_class; + + gboolean (* run) (GThreadedSocketService *service, + GSocketConnection *connection, + GObject *source_object); + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +struct _GThreadedSocketService +{ + GSocketService parent_instance; + GThreadedSocketServicePrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_threaded_socket_service_get_type (void); +GIO_AVAILABLE_IN_ALL +GSocketService * g_threaded_socket_service_new (int max_threads); + +G_END_DECLS + +#endif /* __G_THREADED_SOCKET_SERVICE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlsbackend.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsbackend.h new file mode 100644 index 00000000..2ad24f6f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsbackend.h @@ -0,0 +1,115 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Red Hat, Inc. + * Copyright © 2015 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_TLS_BACKEND_H__ +#define __G_TLS_BACKEND_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_TLS_BACKEND_EXTENSION_POINT_NAME: + * + * Extension point for TLS functionality via #GTlsBackend. + * See [Extending GIO](overview.html#extending-gio). + */ +#define G_TLS_BACKEND_EXTENSION_POINT_NAME "gio-tls-backend" + +#define G_TYPE_TLS_BACKEND (g_tls_backend_get_type ()) +#define G_TLS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_TLS_BACKEND, GTlsBackend)) +#define G_IS_TLS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_TLS_BACKEND)) +#define G_TLS_BACKEND_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_TLS_BACKEND, GTlsBackendInterface)) + +typedef struct _GTlsBackend GTlsBackend; +typedef struct _GTlsBackendInterface GTlsBackendInterface; + +/** + * GTlsBackendInterface: + * @g_iface: The parent interface. + * @supports_tls: returns whether the backend supports TLS. + * @supports_dtls: returns whether the backend supports DTLS + * @get_default_database: returns a default #GTlsDatabase instance. + * @get_certificate_type: returns the #GTlsCertificate implementation type + * @get_client_connection_type: returns the #GTlsClientConnection implementation type + * @get_server_connection_type: returns the #GTlsServerConnection implementation type + * @get_file_database_type: returns the #GTlsFileDatabase implementation type. + * @get_dtls_client_connection_type: returns the #GDtlsClientConnection implementation type + * @get_dtls_server_connection_type: returns the #GDtlsServerConnection implementation type + * + * Provides an interface for describing TLS-related types. + * + * Since: 2.28 + */ +struct _GTlsBackendInterface +{ + GTypeInterface g_iface; + + /* methods */ + gboolean ( *supports_tls) (GTlsBackend *backend); + GType ( *get_certificate_type) (void); + GType ( *get_client_connection_type) (void); + GType ( *get_server_connection_type) (void); + GType ( *get_file_database_type) (void); + GTlsDatabase * ( *get_default_database) (GTlsBackend *backend); + gboolean ( *supports_dtls) (GTlsBackend *backend); + GType ( *get_dtls_client_connection_type) (void); + GType ( *get_dtls_server_connection_type) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_backend_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GTlsBackend * g_tls_backend_get_default (void); + +GIO_AVAILABLE_IN_ALL +GTlsDatabase * g_tls_backend_get_default_database (GTlsBackend *backend); +GIO_AVAILABLE_IN_2_60 +void g_tls_backend_set_default_database (GTlsBackend *backend, + GTlsDatabase *database); + +GIO_AVAILABLE_IN_ALL +gboolean g_tls_backend_supports_tls (GTlsBackend *backend); +GIO_AVAILABLE_IN_2_48 +gboolean g_tls_backend_supports_dtls (GTlsBackend *backend); + +GIO_AVAILABLE_IN_ALL +GType g_tls_backend_get_certificate_type (GTlsBackend *backend); +GIO_AVAILABLE_IN_ALL +GType g_tls_backend_get_client_connection_type (GTlsBackend *backend); +GIO_AVAILABLE_IN_ALL +GType g_tls_backend_get_server_connection_type (GTlsBackend *backend); +GIO_AVAILABLE_IN_ALL +GType g_tls_backend_get_file_database_type (GTlsBackend *backend); + +GIO_AVAILABLE_IN_2_48 +GType g_tls_backend_get_dtls_client_connection_type (GTlsBackend *backend); +GIO_AVAILABLE_IN_2_48 +GType g_tls_backend_get_dtls_server_connection_type (GTlsBackend *backend); + +G_END_DECLS + +#endif /* __G_TLS_BACKEND_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlscertificate.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlscertificate.h new file mode 100644 index 00000000..c8d10bff --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlscertificate.h @@ -0,0 +1,125 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_TLS_CERTIFICATE_H__ +#define __G_TLS_CERTIFICATE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TLS_CERTIFICATE (g_tls_certificate_get_type ()) +#define G_TLS_CERTIFICATE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CERTIFICATE, GTlsCertificate)) +#define G_TLS_CERTIFICATE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CERTIFICATE, GTlsCertificateClass)) +#define G_IS_TLS_CERTIFICATE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CERTIFICATE)) +#define G_IS_TLS_CERTIFICATE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CERTIFICATE)) +#define G_TLS_CERTIFICATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CERTIFICATE, GTlsCertificateClass)) + +typedef struct _GTlsCertificateClass GTlsCertificateClass; +typedef struct _GTlsCertificatePrivate GTlsCertificatePrivate; + +struct _GTlsCertificate { + GObject parent_instance; + + GTlsCertificatePrivate *priv; +}; + +struct _GTlsCertificateClass +{ + GObjectClass parent_class; + + GTlsCertificateFlags (* verify) (GTlsCertificate *cert, + GSocketConnectable *identity, + GTlsCertificate *trusted_ca); + + /*< private >*/ + /* Padding for future expansion */ + gpointer padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_certificate_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GTlsCertificate *g_tls_certificate_new_from_pem (const gchar *data, + gssize length, + GError **error); +GIO_AVAILABLE_IN_2_72 +GTlsCertificate *g_tls_certificate_new_from_pkcs12 (const guint8 *data, + gsize length, + const gchar *password, + GError **error); +GIO_AVAILABLE_IN_2_72 +GTlsCertificate *g_tls_certificate_new_from_file_with_password (const gchar *file, + const gchar *password, + GError **error); +GIO_AVAILABLE_IN_ALL +GTlsCertificate *g_tls_certificate_new_from_file (const gchar *file, + GError **error); +GIO_AVAILABLE_IN_ALL +GTlsCertificate *g_tls_certificate_new_from_files (const gchar *cert_file, + const gchar *key_file, + GError **error); +GIO_AVAILABLE_IN_2_68 +GTlsCertificate *g_tls_certificate_new_from_pkcs11_uris (const gchar *pkcs11_uri, + const gchar *private_key_pkcs11_uri, + GError **error); + +GIO_AVAILABLE_IN_ALL +GList *g_tls_certificate_list_new_from_file (const gchar *file, + GError **error); + +GIO_AVAILABLE_IN_ALL +GTlsCertificate *g_tls_certificate_get_issuer (GTlsCertificate *cert); + +GIO_AVAILABLE_IN_ALL +GTlsCertificateFlags g_tls_certificate_verify (GTlsCertificate *cert, + GSocketConnectable *identity, + GTlsCertificate *trusted_ca); + +GIO_AVAILABLE_IN_2_34 +gboolean g_tls_certificate_is_same (GTlsCertificate *cert_one, + GTlsCertificate *cert_two); + +GIO_AVAILABLE_IN_2_70 +GDateTime *g_tls_certificate_get_not_valid_before (GTlsCertificate *cert); + +GIO_AVAILABLE_IN_2_70 +GDateTime *g_tls_certificate_get_not_valid_after (GTlsCertificate *cert); + +GIO_AVAILABLE_IN_2_70 +gchar *g_tls_certificate_get_subject_name (GTlsCertificate *cert); + +GIO_AVAILABLE_IN_2_70 +gchar *g_tls_certificate_get_issuer_name (GTlsCertificate *cert); + +GIO_AVAILABLE_IN_2_70 +GPtrArray *g_tls_certificate_get_dns_names (GTlsCertificate *cert); + +GIO_AVAILABLE_IN_2_70 +GPtrArray *g_tls_certificate_get_ip_addresses (GTlsCertificate *cert); + +G_END_DECLS + +#endif /* __G_TLS_CERTIFICATE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlsclientconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsclientconnection.h new file mode 100644 index 00000000..32d6274d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsclientconnection.h @@ -0,0 +1,88 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_TLS_CLIENT_CONNECTION_H__ +#define __G_TLS_CLIENT_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TLS_CLIENT_CONNECTION (g_tls_client_connection_get_type ()) +#define G_TLS_CLIENT_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CLIENT_CONNECTION, GTlsClientConnection)) +#define G_IS_TLS_CLIENT_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CLIENT_CONNECTION)) +#define G_TLS_CLIENT_CONNECTION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_TLS_CLIENT_CONNECTION, GTlsClientConnectionInterface)) + +typedef struct _GTlsClientConnectionInterface GTlsClientConnectionInterface; + +/** + * GTlsClientConnectionInterface: + * @g_iface: The parent interface. + * @copy_session_state: Copies session state from one #GTlsClientConnection to another. + * + * vtable for a #GTlsClientConnection implementation. + * + * Since: 2.26 + */ +struct _GTlsClientConnectionInterface +{ + GTypeInterface g_iface; + + void ( *copy_session_state ) (GTlsClientConnection *conn, + GTlsClientConnection *source); +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_client_connection_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GIOStream * g_tls_client_connection_new (GIOStream *base_io_stream, + GSocketConnectable *server_identity, + GError **error); + +GIO_DEPRECATED_IN_2_72 +GTlsCertificateFlags g_tls_client_connection_get_validation_flags (GTlsClientConnection *conn); +GIO_DEPRECATED_IN_2_72 +void g_tls_client_connection_set_validation_flags (GTlsClientConnection *conn, + GTlsCertificateFlags flags); +GIO_AVAILABLE_IN_ALL +GSocketConnectable *g_tls_client_connection_get_server_identity (GTlsClientConnection *conn); +GIO_AVAILABLE_IN_ALL +void g_tls_client_connection_set_server_identity (GTlsClientConnection *conn, + GSocketConnectable *identity); +GIO_DEPRECATED_IN_2_56 +gboolean g_tls_client_connection_get_use_ssl3 (GTlsClientConnection *conn); +GIO_DEPRECATED_IN_2_56 +void g_tls_client_connection_set_use_ssl3 (GTlsClientConnection *conn, + gboolean use_ssl3); +GIO_AVAILABLE_IN_ALL +GList * g_tls_client_connection_get_accepted_cas (GTlsClientConnection *conn); + +GIO_AVAILABLE_IN_2_46 +void g_tls_client_connection_copy_session_state (GTlsClientConnection *conn, + GTlsClientConnection *source); + +G_END_DECLS + +#endif /* __G_TLS_CLIENT_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlsconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsconnection.h new file mode 100644 index 00000000..a266d61b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsconnection.h @@ -0,0 +1,214 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_TLS_CONNECTION_H__ +#define __G_TLS_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TLS_CONNECTION (g_tls_connection_get_type ()) +#define G_TLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION, GTlsConnection)) +#define G_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION, GTlsConnectionClass)) +#define G_IS_TLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION)) +#define G_IS_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION)) +#define G_TLS_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION, GTlsConnectionClass)) + +typedef struct _GTlsConnectionClass GTlsConnectionClass; +typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate; + +struct _GTlsConnection { + GIOStream parent_instance; + + GTlsConnectionPrivate *priv; +}; + +/** + * GTlsConnectionClass: + * @parent_class: The parent class. + * @accept_certificate: Check whether to accept a certificate. + * @handshake: Perform a handshake operation. + * @handshake_async: Start an asynchronous handshake operation. + * @handshake_finish: Finish an asynchronous handshake operation. + * @get_binding_data: Retrieve TLS channel binding data (Since: 2.66) + * @get_negotiated_protocol: Get ALPN-negotiated protocol (Since: 2.70) + * + * The class structure for the #GTlsConnection type. + * + * Since: 2.28 + */ +struct _GTlsConnectionClass +{ + GIOStreamClass parent_class; + + /* signals */ + gboolean ( *accept_certificate) (GTlsConnection *connection, + GTlsCertificate *peer_cert, + GTlsCertificateFlags errors); + + /* methods */ + gboolean ( *handshake ) (GTlsConnection *conn, + GCancellable *cancellable, + GError **error); + + void ( *handshake_async ) (GTlsConnection *conn, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean ( *handshake_finish ) (GTlsConnection *conn, + GAsyncResult *result, + GError **error); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + gboolean ( *get_binding_data) (GTlsConnection *conn, + GTlsChannelBindingType type, + GByteArray *data, + GError **error); +G_GNUC_END_IGNORE_DEPRECATIONS + + const gchar *(*get_negotiated_protocol) (GTlsConnection *conn); + + /*< private >*/ + /* Padding for future expansion */ + gpointer padding[6]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_connection_get_type (void) G_GNUC_CONST; + +GIO_DEPRECATED +void g_tls_connection_set_use_system_certdb (GTlsConnection *conn, + gboolean use_system_certdb); +GIO_DEPRECATED +gboolean g_tls_connection_get_use_system_certdb (GTlsConnection *conn); + +GIO_AVAILABLE_IN_ALL +void g_tls_connection_set_database (GTlsConnection *conn, + GTlsDatabase *database); +GIO_AVAILABLE_IN_ALL +GTlsDatabase * g_tls_connection_get_database (GTlsConnection *conn); + +GIO_AVAILABLE_IN_ALL +void g_tls_connection_set_certificate (GTlsConnection *conn, + GTlsCertificate *certificate); +GIO_AVAILABLE_IN_ALL +GTlsCertificate *g_tls_connection_get_certificate (GTlsConnection *conn); + +GIO_AVAILABLE_IN_ALL +void g_tls_connection_set_interaction (GTlsConnection *conn, + GTlsInteraction *interaction); +GIO_AVAILABLE_IN_ALL +GTlsInteraction * g_tls_connection_get_interaction (GTlsConnection *conn); + +GIO_AVAILABLE_IN_ALL +GTlsCertificate *g_tls_connection_get_peer_certificate (GTlsConnection *conn); +GIO_AVAILABLE_IN_ALL +GTlsCertificateFlags g_tls_connection_get_peer_certificate_errors (GTlsConnection *conn); + +GIO_AVAILABLE_IN_ALL +void g_tls_connection_set_require_close_notify (GTlsConnection *conn, + gboolean require_close_notify); +GIO_AVAILABLE_IN_ALL +gboolean g_tls_connection_get_require_close_notify (GTlsConnection *conn); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GIO_DEPRECATED_IN_2_60 +void g_tls_connection_set_rehandshake_mode (GTlsConnection *conn, + GTlsRehandshakeMode mode); +GIO_DEPRECATED_IN_2_60 +GTlsRehandshakeMode g_tls_connection_get_rehandshake_mode (GTlsConnection *conn); +G_GNUC_END_IGNORE_DEPRECATIONS + +GIO_AVAILABLE_IN_2_60 +void g_tls_connection_set_advertised_protocols (GTlsConnection *conn, + const gchar * const *protocols); + +GIO_AVAILABLE_IN_2_60 +const gchar * g_tls_connection_get_negotiated_protocol (GTlsConnection *conn); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GIO_AVAILABLE_IN_2_66 +gboolean g_tls_connection_get_channel_binding_data (GTlsConnection *conn, + GTlsChannelBindingType type, + GByteArray *data, + GError **error); +G_GNUC_END_IGNORE_DEPRECATIONS + +GIO_AVAILABLE_IN_ALL +gboolean g_tls_connection_handshake (GTlsConnection *conn, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_tls_connection_handshake_async (GTlsConnection *conn, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_tls_connection_handshake_finish (GTlsConnection *conn, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_70 +GTlsProtocolVersion g_tls_connection_get_protocol_version (GTlsConnection *conn); + +GIO_AVAILABLE_IN_2_70 +gchar * g_tls_connection_get_ciphersuite_name (GTlsConnection *conn); + +/** + * G_TLS_ERROR: + * + * Error domain for TLS. Errors in this domain will be from the + * #GTlsError enumeration. See #GError for more information on error + * domains. + */ +#define G_TLS_ERROR (g_tls_error_quark ()) +GIO_AVAILABLE_IN_ALL +GQuark g_tls_error_quark (void); + +/** + * G_TLS_CHANNEL_BINDING_ERROR: + * + * Error domain for TLS channel binding. Errors in this domain will be from the + * #GTlsChannelBindingError enumeration. See #GError for more information on error + * domains. + * + * Since: 2.66 + */ +#define G_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_quark ()) +GIO_AVAILABLE_IN_2_66 +GQuark g_tls_channel_binding_error_quark (void); + +/*< protected >*/ +GIO_AVAILABLE_IN_ALL +gboolean g_tls_connection_emit_accept_certificate (GTlsConnection *conn, + GTlsCertificate *peer_cert, + GTlsCertificateFlags errors); + +G_END_DECLS + +#endif /* __G_TLS_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlsdatabase.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsdatabase.h new file mode 100644 index 00000000..4ae6dc33 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsdatabase.h @@ -0,0 +1,249 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Stef Walter + */ + +#ifndef __G_TLS_DATABASE_H__ +#define __G_TLS_DATABASE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER "1.3.6.1.5.5.7.3.1" +#define G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT "1.3.6.1.5.5.7.3.2" + +#define G_TYPE_TLS_DATABASE (g_tls_database_get_type ()) +#define G_TLS_DATABASE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_DATABASE, GTlsDatabase)) +#define G_TLS_DATABASE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_DATABASE, GTlsDatabaseClass)) +#define G_IS_TLS_DATABASE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_DATABASE)) +#define G_IS_TLS_DATABASE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_DATABASE)) +#define G_TLS_DATABASE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_DATABASE, GTlsDatabaseClass)) + +typedef struct _GTlsDatabaseClass GTlsDatabaseClass; +typedef struct _GTlsDatabasePrivate GTlsDatabasePrivate; + +struct _GTlsDatabase +{ + GObject parent_instance; + + GTlsDatabasePrivate *priv; +}; + +struct _GTlsDatabaseClass +{ + GObjectClass parent_class; + + /* virtual methods */ + + GTlsCertificateFlags (*verify_chain) (GTlsDatabase *self, + GTlsCertificate *chain, + const gchar *purpose, + GSocketConnectable *identity, + GTlsInteraction *interaction, + GTlsDatabaseVerifyFlags flags, + GCancellable *cancellable, + GError **error); + + void (*verify_chain_async) (GTlsDatabase *self, + GTlsCertificate *chain, + const gchar *purpose, + GSocketConnectable *identity, + GTlsInteraction *interaction, + GTlsDatabaseVerifyFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + GTlsCertificateFlags (*verify_chain_finish) (GTlsDatabase *self, + GAsyncResult *result, + GError **error); + + gchar* (*create_certificate_handle) (GTlsDatabase *self, + GTlsCertificate *certificate); + + GTlsCertificate* (*lookup_certificate_for_handle) (GTlsDatabase *self, + const gchar *handle, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GError **error); + + void (*lookup_certificate_for_handle_async) (GTlsDatabase *self, + const gchar *handle, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + GTlsCertificate* (*lookup_certificate_for_handle_finish) (GTlsDatabase *self, + GAsyncResult *result, + GError **error); + + GTlsCertificate* (*lookup_certificate_issuer) (GTlsDatabase *self, + GTlsCertificate *certificate, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GError **error); + + void (*lookup_certificate_issuer_async) (GTlsDatabase *self, + GTlsCertificate *certificate, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + GTlsCertificate* (*lookup_certificate_issuer_finish) (GTlsDatabase *self, + GAsyncResult *result, + GError **error); + + GList* (*lookup_certificates_issued_by) (GTlsDatabase *self, + GByteArray *issuer_raw_dn, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GError **error); + + void (*lookup_certificates_issued_by_async) (GTlsDatabase *self, + GByteArray *issuer_raw_dn, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + GList* (*lookup_certificates_issued_by_finish) (GTlsDatabase *self, + GAsyncResult *result, + GError **error); + + /*< private >*/ + /* Padding for future expansion */ + gpointer padding[16]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_database_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GTlsCertificateFlags g_tls_database_verify_chain (GTlsDatabase *self, + GTlsCertificate *chain, + const gchar *purpose, + GSocketConnectable *identity, + GTlsInteraction *interaction, + GTlsDatabaseVerifyFlags flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_tls_database_verify_chain_async (GTlsDatabase *self, + GTlsCertificate *chain, + const gchar *purpose, + GSocketConnectable *identity, + GTlsInteraction *interaction, + GTlsDatabaseVerifyFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +GTlsCertificateFlags g_tls_database_verify_chain_finish (GTlsDatabase *self, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +gchar* g_tls_database_create_certificate_handle (GTlsDatabase *self, + GTlsCertificate *certificate); + +GIO_AVAILABLE_IN_ALL +GTlsCertificate* g_tls_database_lookup_certificate_for_handle (GTlsDatabase *self, + const gchar *handle, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_tls_database_lookup_certificate_for_handle_async (GTlsDatabase *self, + const gchar *handle, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +GTlsCertificate* g_tls_database_lookup_certificate_for_handle_finish (GTlsDatabase *self, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +GTlsCertificate* g_tls_database_lookup_certificate_issuer (GTlsDatabase *self, + GTlsCertificate *certificate, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_tls_database_lookup_certificate_issuer_async (GTlsDatabase *self, + GTlsCertificate *certificate, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +GTlsCertificate* g_tls_database_lookup_certificate_issuer_finish (GTlsDatabase *self, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_ALL +GList* g_tls_database_lookup_certificates_issued_by (GTlsDatabase *self, + GByteArray *issuer_raw_dn, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_tls_database_lookup_certificates_issued_by_async (GTlsDatabase *self, + GByteArray *issuer_raw_dn, + GTlsInteraction *interaction, + GTlsDatabaseLookupFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +GList* g_tls_database_lookup_certificates_issued_by_finish (GTlsDatabase *self, + GAsyncResult *result, + GError **error); + +G_END_DECLS + +#endif /* __G_TLS_DATABASE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlsfiledatabase.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsfiledatabase.h new file mode 100644 index 00000000..57db68e4 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsfiledatabase.h @@ -0,0 +1,60 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2010 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * See the included COPYING file for more information. + * + * Author: Stef Walter + */ + +#ifndef __G_TLS_FILE_DATABASE_H__ +#define __G_TLS_FILE_DATABASE_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TLS_FILE_DATABASE (g_tls_file_database_get_type ()) +#define G_TLS_FILE_DATABASE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_FILE_DATABASE, GTlsFileDatabase)) +#define G_IS_TLS_FILE_DATABASE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_FILE_DATABASE)) +#define G_TLS_FILE_DATABASE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_TLS_FILE_DATABASE, GTlsFileDatabaseInterface)) + +typedef struct _GTlsFileDatabaseInterface GTlsFileDatabaseInterface; + +/** + * GTlsFileDatabaseInterface: + * @g_iface: The parent interface. + * + * Provides an interface for #GTlsFileDatabase implementations. + * + */ +struct _GTlsFileDatabaseInterface +{ + GTypeInterface g_iface; + + /*< private >*/ + /* Padding for future expansion */ + gpointer padding[8]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_file_database_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GTlsDatabase* g_tls_file_database_new (const gchar *anchors, + GError **error); + +G_END_DECLS + +#endif /* __G_TLS_FILE_DATABASE_H___ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlsinteraction.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsinteraction.h new file mode 100644 index 00000000..68e3662b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsinteraction.h @@ -0,0 +1,150 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2011 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Stef Walter + */ + +#ifndef __G_TLS_INTERACTION_H__ +#define __G_TLS_INTERACTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TLS_INTERACTION (g_tls_interaction_get_type ()) +#define G_TLS_INTERACTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_TLS_INTERACTION, GTlsInteraction)) +#define G_TLS_INTERACTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_TLS_INTERACTION, GTlsInteractionClass)) +#define G_IS_TLS_INTERACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_TLS_INTERACTION)) +#define G_IS_TLS_INTERACTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_TLS_INTERACTION)) +#define G_TLS_INTERACTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_TLS_INTERACTION, GTlsInteractionClass)) + +typedef struct _GTlsInteractionClass GTlsInteractionClass; +typedef struct _GTlsInteractionPrivate GTlsInteractionPrivate; + +struct _GTlsInteraction +{ + /*< private >*/ + GObject parent_instance; + GTlsInteractionPrivate *priv; +}; + +struct _GTlsInteractionClass +{ + /*< private >*/ + GObjectClass parent_class; + + /*< public >*/ + GTlsInteractionResult (* ask_password) (GTlsInteraction *interaction, + GTlsPassword *password, + GCancellable *cancellable, + GError **error); + + void (* ask_password_async) (GTlsInteraction *interaction, + GTlsPassword *password, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + GTlsInteractionResult (* ask_password_finish) (GTlsInteraction *interaction, + GAsyncResult *result, + GError **error); + + GTlsInteractionResult (* request_certificate) (GTlsInteraction *interaction, + GTlsConnection *connection, + GTlsCertificateRequestFlags flags, + GCancellable *cancellable, + GError **error); + + void (* request_certificate_async) (GTlsInteraction *interaction, + GTlsConnection *connection, + GTlsCertificateRequestFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + GTlsInteractionResult (* request_certificate_finish) (GTlsInteraction *interaction, + GAsyncResult *result, + GError **error); + + /*< private >*/ + /* Padding for future expansion */ + gpointer padding[21]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_interaction_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GTlsInteractionResult g_tls_interaction_invoke_ask_password (GTlsInteraction *interaction, + GTlsPassword *password, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +GTlsInteractionResult g_tls_interaction_ask_password (GTlsInteraction *interaction, + GTlsPassword *password, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +void g_tls_interaction_ask_password_async (GTlsInteraction *interaction, + GTlsPassword *password, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_ALL +GTlsInteractionResult g_tls_interaction_ask_password_finish (GTlsInteraction *interaction, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_40 +GTlsInteractionResult g_tls_interaction_invoke_request_certificate (GTlsInteraction *interaction, + GTlsConnection *connection, + GTlsCertificateRequestFlags flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_40 +GTlsInteractionResult g_tls_interaction_request_certificate (GTlsInteraction *interaction, + GTlsConnection *connection, + GTlsCertificateRequestFlags flags, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_2_40 +void g_tls_interaction_request_certificate_async (GTlsInteraction *interaction, + GTlsConnection *connection, + GTlsCertificateRequestFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_AVAILABLE_IN_2_40 +GTlsInteractionResult g_tls_interaction_request_certificate_finish (GTlsInteraction *interaction, + GAsyncResult *result, + GError **error); + +G_END_DECLS + +#endif /* __G_TLS_INTERACTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlspassword.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlspassword.h new file mode 100644 index 00000000..a33ec731 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlspassword.h @@ -0,0 +1,121 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2011 Collabora, Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Stef Walter + */ + +#ifndef __G_TLS_PASSWORD_H__ +#define __G_TLS_PASSWORD_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TLS_PASSWORD (g_tls_password_get_type ()) +#define G_TLS_PASSWORD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_TLS_PASSWORD, GTlsPassword)) +#define G_TLS_PASSWORD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_TLS_PASSWORD, GTlsPasswordClass)) +#define G_IS_TLS_PASSWORD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_TLS_PASSWORD)) +#define G_IS_TLS_PASSWORD_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_TLS_PASSWORD)) +#define G_TLS_PASSWORD_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_TLS_PASSWORD, GTlsPasswordClass)) + +typedef struct _GTlsPasswordClass GTlsPasswordClass; +typedef struct _GTlsPasswordPrivate GTlsPasswordPrivate; + +struct _GTlsPassword +{ + GObject parent_instance; + + GTlsPasswordPrivate *priv; +}; + +/** + * GTlsPasswordClass: + * @get_value: virtual method for g_tls_password_get_value() + * @set_value: virtual method for g_tls_password_set_value() + * @get_default_warning: virtual method for g_tls_password_get_warning() if no + * value has been set using g_tls_password_set_warning() + * + * Class structure for #GTlsPassword. + */ +struct _GTlsPasswordClass +{ + GObjectClass parent_class; + + /* methods */ + + const guchar * ( *get_value) (GTlsPassword *password, + gsize *length); + + void ( *set_value) (GTlsPassword *password, + guchar *value, + gssize length, + GDestroyNotify destroy); + + const gchar* ( *get_default_warning) (GTlsPassword *password); + + /*< private >*/ + /* Padding for future expansion */ + gpointer padding[4]; +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_password_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GTlsPassword * g_tls_password_new (GTlsPasswordFlags flags, + const gchar *description); + +GIO_AVAILABLE_IN_ALL +const guchar * g_tls_password_get_value (GTlsPassword *password, + gsize *length); +GIO_AVAILABLE_IN_ALL +void g_tls_password_set_value (GTlsPassword *password, + const guchar *value, + gssize length); +GIO_AVAILABLE_IN_ALL +void g_tls_password_set_value_full (GTlsPassword *password, + guchar *value, + gssize length, + GDestroyNotify destroy); + +GIO_AVAILABLE_IN_ALL +GTlsPasswordFlags g_tls_password_get_flags (GTlsPassword *password); +GIO_AVAILABLE_IN_ALL +void g_tls_password_set_flags (GTlsPassword *password, + GTlsPasswordFlags flags); + +GIO_AVAILABLE_IN_ALL +const gchar* g_tls_password_get_description (GTlsPassword *password); +GIO_AVAILABLE_IN_ALL +void g_tls_password_set_description (GTlsPassword *password, + const gchar *description); + +GIO_AVAILABLE_IN_ALL +const gchar * g_tls_password_get_warning (GTlsPassword *password); +GIO_AVAILABLE_IN_ALL +void g_tls_password_set_warning (GTlsPassword *password, + const gchar *warning); + +G_END_DECLS + +#endif /* __G_TLS_PASSWORD_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gtlsserverconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsserverconnection.h new file mode 100644 index 00000000..7c4e2832 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gtlsserverconnection.h @@ -0,0 +1,63 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_TLS_SERVER_CONNECTION_H__ +#define __G_TLS_SERVER_CONNECTION_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_TLS_SERVER_CONNECTION (g_tls_server_connection_get_type ()) +#define G_TLS_SERVER_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_SERVER_CONNECTION, GTlsServerConnection)) +#define G_IS_TLS_SERVER_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_SERVER_CONNECTION)) +#define G_TLS_SERVER_CONNECTION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_TLS_SERVER_CONNECTION, GTlsServerConnectionInterface)) + +typedef struct _GTlsServerConnectionInterface GTlsServerConnectionInterface; + +/** + * GTlsServerConnectionInterface: + * @g_iface: The parent interface. + * + * vtable for a #GTlsServerConnection implementation. + * + * Since: 2.26 + */ +struct _GTlsServerConnectionInterface +{ + GTypeInterface g_iface; + +}; + +GIO_AVAILABLE_IN_ALL +GType g_tls_server_connection_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GIOStream * g_tls_server_connection_new (GIOStream *base_io_stream, + GTlsCertificate *certificate, + GError **error); + +G_END_DECLS + +#endif /* __G_TLS_SERVER_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gunixconnection.h b/illumos-x86_64/usr/include/glib-2.0/gio/gunixconnection.h new file mode 100644 index 00000000..e08e8189 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gunixconnection.h @@ -0,0 +1,102 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2009 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_UNIX_CONNECTION_H__ +#define __G_UNIX_CONNECTION_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_UNIX_CONNECTION (g_unix_connection_get_type ()) +#define G_UNIX_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_UNIX_CONNECTION, GUnixConnection)) +#define G_UNIX_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_UNIX_CONNECTION, GUnixConnectionClass)) +#define G_IS_UNIX_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_UNIX_CONNECTION)) +#define G_IS_UNIX_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_UNIX_CONNECTION)) +#define G_UNIX_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_UNIX_CONNECTION, GUnixConnectionClass)) + +typedef struct _GUnixConnection GUnixConnection; +typedef struct _GUnixConnectionPrivate GUnixConnectionPrivate; +typedef struct _GUnixConnectionClass GUnixConnectionClass; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixConnection, g_object_unref) + +struct _GUnixConnectionClass +{ + GSocketConnectionClass parent_class; +}; + +struct _GUnixConnection +{ + GSocketConnection parent_instance; + GUnixConnectionPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_unix_connection_get_type (void); + +GIO_AVAILABLE_IN_ALL +gboolean g_unix_connection_send_fd (GUnixConnection *connection, + gint fd, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_ALL +gint g_unix_connection_receive_fd (GUnixConnection *connection, + GCancellable *cancellable, + GError **error); + +GIO_AVAILABLE_IN_ALL +gboolean g_unix_connection_send_credentials (GUnixConnection *connection, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_32 +void g_unix_connection_send_credentials_async (GUnixConnection *connection, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_2_32 +gboolean g_unix_connection_send_credentials_finish (GUnixConnection *connection, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_32 +GCredentials *g_unix_connection_receive_credentials (GUnixConnection *connection, + GCancellable *cancellable, + GError **error); +GIO_AVAILABLE_IN_2_32 +void g_unix_connection_receive_credentials_async (GUnixConnection *connection, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +GCredentials *g_unix_connection_receive_credentials_finish (GUnixConnection *connection, + GAsyncResult *result, + GError **error); + +G_END_DECLS + +#endif /* __G_UNIX_CONNECTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gunixcredentialsmessage.h b/illumos-x86_64/usr/include/glib-2.0/gio/gunixcredentialsmessage.h new file mode 100644 index 00000000..8f63bd25 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gunixcredentialsmessage.h @@ -0,0 +1,81 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2009 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: David Zeuthen + */ + +#ifndef __G_UNIX_CREDENTIALS_MESSAGE_H__ +#define __G_UNIX_CREDENTIALS_MESSAGE_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_UNIX_CREDENTIALS_MESSAGE (g_unix_credentials_message_get_type ()) +#define G_UNIX_CREDENTIALS_MESSAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNIX_CREDENTIALS_MESSAGE, GUnixCredentialsMessage)) +#define G_UNIX_CREDENTIALS_MESSAGE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), G_TYPE_UNIX_CREDENTIALS_MESSAGE, GUnixCredentialsMessageClass)) +#define G_IS_UNIX_CREDENTIALS_MESSAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNIX_CREDENTIALS_MESSAGE)) +#define G_IS_UNIX_CREDENTIALS_MESSAGE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), G_TYPE_UNIX_CREDENTIALS_MESSAGE)) +#define G_UNIX_CREDENTIALS_MESSAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_UNIX_CREDENTIALS_MESSAGE, GUnixCredentialsMessageClass)) + +typedef struct _GUnixCredentialsMessagePrivate GUnixCredentialsMessagePrivate; +typedef struct _GUnixCredentialsMessageClass GUnixCredentialsMessageClass; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixCredentialsMessage, g_object_unref) + +/** + * GUnixCredentialsMessageClass: + * + * Class structure for #GUnixCredentialsMessage. + * + * Since: 2.26 + */ +struct _GUnixCredentialsMessageClass +{ + GSocketControlMessageClass parent_class; + + /*< private >*/ + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); +}; + +struct _GUnixCredentialsMessage +{ + GSocketControlMessage parent_instance; + GUnixCredentialsMessagePrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_unix_credentials_message_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GSocketControlMessage *g_unix_credentials_message_new (void); +GIO_AVAILABLE_IN_ALL +GSocketControlMessage *g_unix_credentials_message_new_with_credentials (GCredentials *credentials); +GIO_AVAILABLE_IN_ALL +GCredentials *g_unix_credentials_message_get_credentials (GUnixCredentialsMessage *message); + +GIO_AVAILABLE_IN_ALL +gboolean g_unix_credentials_message_is_supported (void); + +G_END_DECLS + +#endif /* __G_UNIX_CREDENTIALS_MESSAGE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gunixfdlist.h b/illumos-x86_64/usr/include/glib-2.0/gio/gunixfdlist.h new file mode 100644 index 00000000..df5587ee --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gunixfdlist.h @@ -0,0 +1,97 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright © 2009 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Ryan Lortie + */ + +#ifndef __G_UNIX_FD_LIST_H__ +#define __G_UNIX_FD_LIST_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_UNIX_FD_LIST (g_unix_fd_list_get_type ()) +#define G_UNIX_FD_LIST(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_UNIX_FD_LIST, GUnixFDList)) +#define G_UNIX_FD_LIST_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + G_TYPE_UNIX_FD_LIST, GUnixFDListClass)) +#define G_IS_UNIX_FD_LIST(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_UNIX_FD_LIST)) +#define G_IS_UNIX_FD_LIST_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + G_TYPE_UNIX_FD_LIST)) +#define G_UNIX_FD_LIST_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + G_TYPE_UNIX_FD_LIST, GUnixFDListClass)) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixFDList, g_object_unref) + +typedef struct _GUnixFDListPrivate GUnixFDListPrivate; +typedef struct _GUnixFDListClass GUnixFDListClass; + +struct _GUnixFDListClass +{ + GObjectClass parent_class; + + /*< private >*/ + + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +struct _GUnixFDList +{ + GObject parent_instance; + GUnixFDListPrivate *priv; +}; + +GIO_AVAILABLE_IN_ALL +GType g_unix_fd_list_get_type (void) G_GNUC_CONST; +GIO_AVAILABLE_IN_ALL +GUnixFDList * g_unix_fd_list_new (void); +GIO_AVAILABLE_IN_ALL +GUnixFDList * g_unix_fd_list_new_from_array (const gint *fds, + gint n_fds); + +GIO_AVAILABLE_IN_ALL +gint g_unix_fd_list_append (GUnixFDList *list, + gint fd, + GError **error); + +GIO_AVAILABLE_IN_ALL +gint g_unix_fd_list_get_length (GUnixFDList *list); + +GIO_AVAILABLE_IN_ALL +gint g_unix_fd_list_get (GUnixFDList *list, + gint index_, + GError **error); + +GIO_AVAILABLE_IN_ALL +const gint * g_unix_fd_list_peek_fds (GUnixFDList *list, + gint *length); + +GIO_AVAILABLE_IN_ALL +gint * g_unix_fd_list_steal_fds (GUnixFDList *list, + gint *length); + +G_END_DECLS + +#endif /* __G_UNIX_FD_LIST_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gunixsocketaddress.h b/illumos-x86_64/usr/include/glib-2.0/gio/gunixsocketaddress.h new file mode 100644 index 00000000..705674b0 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gunixsocketaddress.h @@ -0,0 +1,83 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Authors: Christian Kellner + * Samuel Cormier-Iijima + */ + +#ifndef __G_UNIX_SOCKET_ADDRESS_H__ +#define __G_UNIX_SOCKET_ADDRESS_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPE_UNIX_SOCKET_ADDRESS (g_unix_socket_address_get_type ()) +#define G_UNIX_SOCKET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNIX_SOCKET_ADDRESS, GUnixSocketAddress)) +#define G_UNIX_SOCKET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNIX_SOCKET_ADDRESS, GUnixSocketAddressClass)) +#define G_IS_UNIX_SOCKET_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNIX_SOCKET_ADDRESS)) +#define G_IS_UNIX_SOCKET_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNIX_SOCKET_ADDRESS)) +#define G_UNIX_SOCKET_ADDRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_UNIX_SOCKET_ADDRESS, GUnixSocketAddressClass)) + +typedef struct _GUnixSocketAddress GUnixSocketAddress; +typedef struct _GUnixSocketAddressClass GUnixSocketAddressClass; +typedef struct _GUnixSocketAddressPrivate GUnixSocketAddressPrivate; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUnixSocketAddress, g_object_unref) + +struct _GUnixSocketAddress +{ + GSocketAddress parent_instance; + + /*< private >*/ + GUnixSocketAddressPrivate *priv; +}; + +struct _GUnixSocketAddressClass +{ + GSocketAddressClass parent_class; +}; + +GIO_AVAILABLE_IN_ALL +GType g_unix_socket_address_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_unix_socket_address_new (const gchar *path); +GIO_DEPRECATED_FOR(g_unix_socket_address_new_with_type) +GSocketAddress *g_unix_socket_address_new_abstract (const gchar *path, + gint path_len); +GIO_AVAILABLE_IN_ALL +GSocketAddress *g_unix_socket_address_new_with_type (const gchar *path, + gint path_len, + GUnixSocketAddressType type); +GIO_AVAILABLE_IN_ALL +const char * g_unix_socket_address_get_path (GUnixSocketAddress *address); +GIO_AVAILABLE_IN_ALL +gsize g_unix_socket_address_get_path_len (GUnixSocketAddress *address); +GIO_AVAILABLE_IN_ALL +GUnixSocketAddressType g_unix_socket_address_get_address_type (GUnixSocketAddress *address); +GIO_DEPRECATED +gboolean g_unix_socket_address_get_is_abstract (GUnixSocketAddress *address); + +GIO_AVAILABLE_IN_ALL +gboolean g_unix_socket_address_abstract_names_supported (void); + +G_END_DECLS + +#endif /* __G_UNIX_SOCKET_ADDRESS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gvfs.h b/illumos-x86_64/usr/include/glib-2.0/gio/gvfs.h new file mode 100644 index 00000000..18909c6b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gvfs.h @@ -0,0 +1,165 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_VFS_H__ +#define __G_VFS_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_VFS (g_vfs_get_type ()) +#define G_VFS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_VFS, GVfs)) +#define G_VFS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_VFS, GVfsClass)) +#define G_VFS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_VFS, GVfsClass)) +#define G_IS_VFS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_VFS)) +#define G_IS_VFS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_VFS)) + +/** + * GVfsFileLookupFunc: + * @vfs: a #GVfs + * @identifier: the identifier to look up a #GFile for. This can either + * be a URI or a parse name as returned by g_file_get_parse_name() + * @user_data: (nullable): user data passed to the function, or %NULL + * + * This function type is used by g_vfs_register_uri_scheme() to make it + * possible for a client to associate a URI scheme to a different #GFile + * implementation. + * + * The client should return a reference to the new file that has been + * created for @uri, or %NULL to continue with the default implementation. + * + * Returns: (nullable) (transfer full): a #GFile for @identifier. + * + * Since: 2.50 + */ +typedef GFile * (* GVfsFileLookupFunc) (GVfs *vfs, + const char *identifier, + gpointer user_data); + +/** + * G_VFS_EXTENSION_POINT_NAME: + * + * Extension point for #GVfs functionality. + * See [Extending GIO](overview.html#extending-gio). + */ +#define G_VFS_EXTENSION_POINT_NAME "gio-vfs" + +typedef struct _GVfsClass GVfsClass; + +struct _GVfs +{ + GObject parent_instance; +}; + +struct _GVfsClass +{ + GObjectClass parent_class; + + /* Virtual Table */ + + gboolean (* is_active) (GVfs *vfs); + GFile * (* get_file_for_path) (GVfs *vfs, + const char *path); + GFile * (* get_file_for_uri) (GVfs *vfs, + const char *uri); + const gchar * const * (* get_supported_uri_schemes) (GVfs *vfs); + GFile * (* parse_name) (GVfs *vfs, + const char *parse_name); + + /*< private >*/ + void (* local_file_add_info) (GVfs *vfs, + const char *filename, + guint64 device, + GFileAttributeMatcher *attribute_matcher, + GFileInfo *info, + GCancellable *cancellable, + gpointer *extra_data, + GDestroyNotify *free_extra_data); + void (* add_writable_namespaces) (GVfs *vfs, + GFileAttributeInfoList *list); + gboolean (* local_file_set_attributes) (GVfs *vfs, + const char *filename, + GFileInfo *info, + GFileQueryInfoFlags flags, + GCancellable *cancellable, + GError **error); + void (* local_file_removed) (GVfs *vfs, + const char *filename); + void (* local_file_moved) (GVfs *vfs, + const char *source, + const char *dest); + GIcon * (* deserialize_icon) (GVfs *vfs, + GVariant *value); + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_vfs_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +gboolean g_vfs_is_active (GVfs *vfs); +GIO_AVAILABLE_IN_ALL +GFile * g_vfs_get_file_for_path (GVfs *vfs, + const char *path); +GIO_AVAILABLE_IN_ALL +GFile * g_vfs_get_file_for_uri (GVfs *vfs, + const char *uri); +GIO_AVAILABLE_IN_ALL +const gchar* const * g_vfs_get_supported_uri_schemes (GVfs *vfs); + +GIO_AVAILABLE_IN_ALL +GFile * g_vfs_parse_name (GVfs *vfs, + const char *parse_name); + +GIO_AVAILABLE_IN_ALL +GVfs * g_vfs_get_default (void); +GIO_AVAILABLE_IN_ALL +GVfs * g_vfs_get_local (void); + +GIO_AVAILABLE_IN_2_50 +gboolean g_vfs_register_uri_scheme (GVfs *vfs, + const char *scheme, + GVfsFileLookupFunc uri_func, + gpointer uri_data, + GDestroyNotify uri_destroy, + GVfsFileLookupFunc parse_name_func, + gpointer parse_name_data, + GDestroyNotify parse_name_destroy); +GIO_AVAILABLE_IN_2_50 +gboolean g_vfs_unregister_uri_scheme (GVfs *vfs, + const char *scheme); + + +G_END_DECLS + +#endif /* __G_VFS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gvolume.h b/illumos-x86_64/usr/include/glib-2.0/gio/gvolume.h new file mode 100644 index 00000000..7b5a81a0 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gvolume.h @@ -0,0 +1,255 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + * David Zeuthen + */ + +#ifndef __G_VOLUME_H__ +#define __G_VOLUME_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_VOLUME_IDENTIFIER_KIND_HAL_UDI: + * + * The string used to obtain a Hal UDI with g_volume_get_identifier(). + * + * Deprecated: 2.58: Do not use, HAL is deprecated. + */ +#define G_VOLUME_IDENTIFIER_KIND_HAL_UDI "hal-udi" GIO_DEPRECATED_MACRO_IN_2_58 + +/** + * G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE: + * + * The string used to obtain a Unix device path with g_volume_get_identifier(). + */ +#define G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE "unix-device" + +/** + * G_VOLUME_IDENTIFIER_KIND_LABEL: + * + * The string used to obtain a filesystem label with g_volume_get_identifier(). + */ +#define G_VOLUME_IDENTIFIER_KIND_LABEL "label" + +/** + * G_VOLUME_IDENTIFIER_KIND_UUID: + * + * The string used to obtain a UUID with g_volume_get_identifier(). + */ +#define G_VOLUME_IDENTIFIER_KIND_UUID "uuid" + +/** + * G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT: + * + * The string used to obtain a NFS mount with g_volume_get_identifier(). + */ +#define G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT "nfs-mount" + +/** + * G_VOLUME_IDENTIFIER_KIND_CLASS: + * + * The string used to obtain the volume class with g_volume_get_identifier(). + * + * Known volume classes include `device`, `network`, and `loop`. Other + * classes may be added in the future. + * + * This is intended to be used by applications to classify #GVolume + * instances into different sections - for example a file manager or + * file chooser can use this information to show `network` volumes under + * a "Network" heading and `device` volumes under a "Devices" heading. + */ +#define G_VOLUME_IDENTIFIER_KIND_CLASS "class" + + +#define G_TYPE_VOLUME (g_volume_get_type ()) +#define G_VOLUME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_VOLUME, GVolume)) +#define G_IS_VOLUME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_VOLUME)) +#define G_VOLUME_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_VOLUME, GVolumeIface)) + +/** + * GVolumeIface: + * @g_iface: The parent interface. + * @changed: Changed signal that is emitted when the volume's state has changed. + * @removed: The removed signal that is emitted when the #GVolume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized. + * @get_name: Gets a string containing the name of the #GVolume. + * @get_icon: Gets a #GIcon for the #GVolume. + * @get_uuid: Gets the UUID for the #GVolume. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returns %NULL if there is no UUID available. + * @get_drive: Gets a #GDrive the volume is located on. Returns %NULL if the #GVolume is not associated with a #GDrive. + * @get_mount: Gets a #GMount representing the mounted volume. Returns %NULL if the #GVolume is not mounted. + * @can_mount: Returns %TRUE if the #GVolume can be mounted. + * @can_eject: Checks if a #GVolume can be ejected. + * @mount_fn: Mounts a given #GVolume. + * #GVolume implementations must emit the #GMountOperation::aborted + * signal before completing a mount operation that is aborted while + * awaiting input from the user through a #GMountOperation instance. + * @mount_finish: Finishes a mount operation. + * @eject: Ejects a given #GVolume. + * @eject_finish: Finishes an eject operation. + * @get_identifier: Returns the [identifier](#volume-identifiers) of the given kind, or %NULL if + * the #GVolume doesn't have one. + * @enumerate_identifiers: Returns an array strings listing the kinds + * of [identifiers](#volume-identifiers) which the #GVolume has. + * @should_automount: Returns %TRUE if the #GVolume should be automatically mounted. + * @get_activation_root: Returns the activation root for the #GVolume if it is known in advance or %NULL if + * it is not known. + * @eject_with_operation: Starts ejecting a #GVolume using a #GMountOperation. Since 2.22. + * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22. + * @get_sort_key: Gets a key used for sorting #GVolume instance or %NULL if no such key exists. Since 2.32. + * @get_symbolic_icon: Gets a symbolic #GIcon for the #GVolume. Since 2.34. + * + * Interface for implementing operations for mountable volumes. + **/ +typedef struct _GVolumeIface GVolumeIface; + +struct _GVolumeIface +{ + GTypeInterface g_iface; + + /* signals */ + + void (* changed) (GVolume *volume); + void (* removed) (GVolume *volume); + + /* Virtual Table */ + + char * (* get_name) (GVolume *volume); + GIcon * (* get_icon) (GVolume *volume); + char * (* get_uuid) (GVolume *volume); + GDrive * (* get_drive) (GVolume *volume); + GMount * (* get_mount) (GVolume *volume); + gboolean (* can_mount) (GVolume *volume); + gboolean (* can_eject) (GVolume *volume); + void (* mount_fn) (GVolume *volume, + GMountMountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* mount_finish) (GVolume *volume, + GAsyncResult *result, + GError **error); + void (* eject) (GVolume *volume, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* eject_finish) (GVolume *volume, + GAsyncResult *result, + GError **error); + + char * (* get_identifier) (GVolume *volume, + const char *kind); + char ** (* enumerate_identifiers) (GVolume *volume); + + gboolean (* should_automount) (GVolume *volume); + + GFile * (* get_activation_root) (GVolume *volume); + + void (* eject_with_operation) (GVolume *volume, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* eject_with_operation_finish) (GVolume *volume, + GAsyncResult *result, + GError **error); + + const gchar * (* get_sort_key) (GVolume *volume); + GIcon * (* get_symbolic_icon) (GVolume *volume); +}; + +GIO_AVAILABLE_IN_ALL +GType g_volume_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +char * g_volume_get_name (GVolume *volume); +GIO_AVAILABLE_IN_ALL +GIcon * g_volume_get_icon (GVolume *volume); +GIO_AVAILABLE_IN_ALL +GIcon * g_volume_get_symbolic_icon (GVolume *volume); +GIO_AVAILABLE_IN_ALL +char * g_volume_get_uuid (GVolume *volume); +GIO_AVAILABLE_IN_ALL +GDrive * g_volume_get_drive (GVolume *volume); +GIO_AVAILABLE_IN_ALL +GMount * g_volume_get_mount (GVolume *volume); +GIO_AVAILABLE_IN_ALL +gboolean g_volume_can_mount (GVolume *volume); +GIO_AVAILABLE_IN_ALL +gboolean g_volume_can_eject (GVolume *volume); +GIO_AVAILABLE_IN_ALL +gboolean g_volume_should_automount (GVolume *volume); +GIO_AVAILABLE_IN_ALL +void g_volume_mount (GVolume *volume, + GMountMountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_volume_mount_finish (GVolume *volume, + GAsyncResult *result, + GError **error); +GIO_DEPRECATED_FOR(g_volume_eject_with_operation) +void g_volume_eject (GVolume *volume, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +GIO_DEPRECATED_FOR(g_volume_eject_with_operation_finish) +gboolean g_volume_eject_finish (GVolume *volume, + GAsyncResult *result, + GError **error); +GIO_AVAILABLE_IN_ALL +char * g_volume_get_identifier (GVolume *volume, + const char *kind); +GIO_AVAILABLE_IN_ALL +char ** g_volume_enumerate_identifiers (GVolume *volume); + +GIO_AVAILABLE_IN_ALL +GFile * g_volume_get_activation_root (GVolume *volume); + +GIO_AVAILABLE_IN_ALL +void g_volume_eject_with_operation (GVolume *volume, + GMountUnmountFlags flags, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GIO_AVAILABLE_IN_ALL +gboolean g_volume_eject_with_operation_finish (GVolume *volume, + GAsyncResult *result, + GError **error); + +GIO_AVAILABLE_IN_2_32 +const gchar *g_volume_get_sort_key (GVolume *volume); + +G_END_DECLS + +#endif /* __G_VOLUME_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gvolumemonitor.h b/illumos-x86_64/usr/include/glib-2.0/gio/gvolumemonitor.h new file mode 100644 index 00000000..4edb6ce1 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gvolumemonitor.h @@ -0,0 +1,151 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2006-2007 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + * David Zeuthen + */ + +#ifndef __G_VOLUME_MONITOR_H__ +#define __G_VOLUME_MONITOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_TYPE_VOLUME_MONITOR (g_volume_monitor_get_type ()) +#define G_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_VOLUME_MONITOR, GVolumeMonitor)) +#define G_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_VOLUME_MONITOR, GVolumeMonitorClass)) +#define G_VOLUME_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_VOLUME_MONITOR, GVolumeMonitorClass)) +#define G_IS_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_VOLUME_MONITOR)) +#define G_IS_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_VOLUME_MONITOR)) + +/** + * G_VOLUME_MONITOR_EXTENSION_POINT_NAME: + * + * Extension point for volume monitor functionality. + * See [Extending GIO](overview.html#extending-gio). + */ +#define G_VOLUME_MONITOR_EXTENSION_POINT_NAME "gio-volume-monitor" + +typedef struct _GVolumeMonitorClass GVolumeMonitorClass; + +struct _GVolumeMonitor +{ + GObject parent_instance; + + /*< private >*/ + gpointer priv; +}; + +struct _GVolumeMonitorClass +{ + GObjectClass parent_class; + + /*< public >*/ + /* signals */ + void (* volume_added) (GVolumeMonitor *volume_monitor, + GVolume *volume); + void (* volume_removed) (GVolumeMonitor *volume_monitor, + GVolume *volume); + void (* volume_changed) (GVolumeMonitor *volume_monitor, + GVolume *volume); + + void (* mount_added) (GVolumeMonitor *volume_monitor, + GMount *mount); + void (* mount_removed) (GVolumeMonitor *volume_monitor, + GMount *mount); + void (* mount_pre_unmount) (GVolumeMonitor *volume_monitor, + GMount *mount); + void (* mount_changed) (GVolumeMonitor *volume_monitor, + GMount *mount); + + void (* drive_connected) (GVolumeMonitor *volume_monitor, + GDrive *drive); + void (* drive_disconnected) (GVolumeMonitor *volume_monitor, + GDrive *drive); + void (* drive_changed) (GVolumeMonitor *volume_monitor, + GDrive *drive); + + /* Vtable */ + + gboolean (* is_supported) (void); + + GList * (* get_connected_drives) (GVolumeMonitor *volume_monitor); + GList * (* get_volumes) (GVolumeMonitor *volume_monitor); + GList * (* get_mounts) (GVolumeMonitor *volume_monitor); + + GVolume * (* get_volume_for_uuid) (GVolumeMonitor *volume_monitor, + const char *uuid); + + GMount * (* get_mount_for_uuid) (GVolumeMonitor *volume_monitor, + const char *uuid); + + + /* These arguments are unfortunately backwards by mistake (bug #520169). Deprecated in 2.20. */ + GVolume * (* adopt_orphan_mount) (GMount *mount, + GVolumeMonitor *volume_monitor); + + /* signal added in 2.17 */ + void (* drive_eject_button) (GVolumeMonitor *volume_monitor, + GDrive *drive); + + /* signal added in 2.21 */ + void (* drive_stop_button) (GVolumeMonitor *volume_monitor, + GDrive *drive); + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); + void (*_g_reserved6) (void); +}; + +GIO_AVAILABLE_IN_ALL +GType g_volume_monitor_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GVolumeMonitor *g_volume_monitor_get (void); +GIO_AVAILABLE_IN_ALL +GList * g_volume_monitor_get_connected_drives (GVolumeMonitor *volume_monitor); +GIO_AVAILABLE_IN_ALL +GList * g_volume_monitor_get_volumes (GVolumeMonitor *volume_monitor); +GIO_AVAILABLE_IN_ALL +GList * g_volume_monitor_get_mounts (GVolumeMonitor *volume_monitor); +GIO_AVAILABLE_IN_ALL +GVolume * g_volume_monitor_get_volume_for_uuid (GVolumeMonitor *volume_monitor, + const char *uuid); +GIO_AVAILABLE_IN_ALL +GMount * g_volume_monitor_get_mount_for_uuid (GVolumeMonitor *volume_monitor, + const char *uuid); + +GIO_DEPRECATED +GVolume * g_volume_monitor_adopt_orphan_mount (GMount *mount); + +G_END_DECLS + +#endif /* __G_VOLUME_MONITOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gzlibcompressor.h b/illumos-x86_64/usr/include/glib-2.0/gio/gzlibcompressor.h new file mode 100644 index 00000000..b8a99eaa --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gzlibcompressor.h @@ -0,0 +1,64 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_ZLIB_COMPRESSOR_H__ +#define __G_ZLIB_COMPRESSOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_ZLIB_COMPRESSOR (g_zlib_compressor_get_type ()) +#define G_ZLIB_COMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_ZLIB_COMPRESSOR, GZlibCompressor)) +#define G_ZLIB_COMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_ZLIB_COMPRESSOR, GZlibCompressorClass)) +#define G_IS_ZLIB_COMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_ZLIB_COMPRESSOR)) +#define G_IS_ZLIB_COMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_ZLIB_COMPRESSOR)) +#define G_ZLIB_COMPRESSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_ZLIB_COMPRESSOR, GZlibCompressorClass)) + +typedef struct _GZlibCompressorClass GZlibCompressorClass; + +struct _GZlibCompressorClass +{ + GObjectClass parent_class; +}; + +GIO_AVAILABLE_IN_ALL +GType g_zlib_compressor_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GZlibCompressor *g_zlib_compressor_new (GZlibCompressorFormat format, + int level); + +GIO_AVAILABLE_IN_ALL +GFileInfo *g_zlib_compressor_get_file_info (GZlibCompressor *compressor); +GIO_AVAILABLE_IN_ALL +void g_zlib_compressor_set_file_info (GZlibCompressor *compressor, + GFileInfo *file_info); + +G_END_DECLS + +#endif /* __G_ZLIB_COMPRESSOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gio/gzlibdecompressor.h b/illumos-x86_64/usr/include/glib-2.0/gio/gzlibdecompressor.h new file mode 100644 index 00000000..ef97439f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gio/gzlibdecompressor.h @@ -0,0 +1,60 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Alexander Larsson + */ + +#ifndef __G_ZLIB_DECOMPRESSOR_H__ +#define __G_ZLIB_DECOMPRESSOR_H__ + +#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_ZLIB_DECOMPRESSOR (g_zlib_decompressor_get_type ()) +#define G_ZLIB_DECOMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_ZLIB_DECOMPRESSOR, GZlibDecompressor)) +#define G_ZLIB_DECOMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_ZLIB_DECOMPRESSOR, GZlibDecompressorClass)) +#define G_IS_ZLIB_DECOMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_ZLIB_DECOMPRESSOR)) +#define G_IS_ZLIB_DECOMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_ZLIB_DECOMPRESSOR)) +#define G_ZLIB_DECOMPRESSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_ZLIB_DECOMPRESSOR, GZlibDecompressorClass)) + +typedef struct _GZlibDecompressorClass GZlibDecompressorClass; + +struct _GZlibDecompressorClass +{ + GObjectClass parent_class; +}; + +GIO_AVAILABLE_IN_ALL +GType g_zlib_decompressor_get_type (void) G_GNUC_CONST; + +GIO_AVAILABLE_IN_ALL +GZlibDecompressor *g_zlib_decompressor_new (GZlibCompressorFormat format); + +GIO_AVAILABLE_IN_ALL +GFileInfo *g_zlib_decompressor_get_file_info (GZlibDecompressor *decompressor); + +G_END_DECLS + +#endif /* __G_ZLIB_DECOMPRESSOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gi-visibility.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gi-visibility.h new file mode 100644 index 00000000..66866c44 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gi-visibility.h @@ -0,0 +1,1054 @@ +#pragma once + +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(GI_STATIC_COMPILATION) +# define _GI_EXPORT __declspec(dllexport) +# define _GI_IMPORT __declspec(dllimport) +#elif __GNUC__ >= 4 +# define _GI_EXPORT __attribute__((visibility("default"))) +# define _GI_IMPORT +#else +# define _GI_EXPORT +# define _GI_IMPORT +#endif +#ifdef GI_COMPILATION +# define _GI_API _GI_EXPORT +#else +# define _GI_API _GI_IMPORT +#endif + +#define _GI_EXTERN _GI_API extern + +#define GI_VAR _GI_EXTERN +#define GI_AVAILABLE_IN_ALL _GI_EXTERN + +#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS +#define GI_DEPRECATED _GI_EXTERN +#define GI_DEPRECATED_FOR(f) _GI_EXTERN +#define GI_UNAVAILABLE(maj,min) _GI_EXTERN +#define GI_UNAVAILABLE_STATIC_INLINE(maj,min) +#else +#define GI_DEPRECATED G_DEPRECATED _GI_EXTERN +#define GI_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GI_EXTERN +#define GI_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GI_EXTERN +#define GI_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min) +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26 +#define GI_DEPRECATED_IN_2_26 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_26_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_26 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_26_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_26 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_26 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_26_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_26 _GI_EXTERN +#define GI_DEPRECATED_IN_2_26_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_26 +#define GI_DEPRECATED_MACRO_IN_2_26_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_26 +#define GI_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_26 +#define GI_DEPRECATED_TYPE_IN_2_26_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26 +#define GI_AVAILABLE_IN_2_26 GI_UNAVAILABLE (2, 26) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_26 GLIB_UNAVAILABLE_STATIC_INLINE (2, 26) +#define GI_AVAILABLE_MACRO_IN_2_26 GLIB_UNAVAILABLE_MACRO (2, 26) +#define GI_AVAILABLE_ENUMERATOR_IN_2_26 GLIB_UNAVAILABLE_ENUMERATOR (2, 26) +#define GI_AVAILABLE_TYPE_IN_2_26 GLIB_UNAVAILABLE_TYPE (2, 26) +#else +#define GI_AVAILABLE_IN_2_26 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_26 +#define GI_AVAILABLE_MACRO_IN_2_26 +#define GI_AVAILABLE_ENUMERATOR_IN_2_26 +#define GI_AVAILABLE_TYPE_IN_2_26 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28 +#define GI_DEPRECATED_IN_2_28 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_28_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_28 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_28_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_28 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_28 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_28_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_28 _GI_EXTERN +#define GI_DEPRECATED_IN_2_28_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_28 +#define GI_DEPRECATED_MACRO_IN_2_28_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_28 +#define GI_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_28 +#define GI_DEPRECATED_TYPE_IN_2_28_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28 +#define GI_AVAILABLE_IN_2_28 GI_UNAVAILABLE (2, 28) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_28 GLIB_UNAVAILABLE_STATIC_INLINE (2, 28) +#define GI_AVAILABLE_MACRO_IN_2_28 GLIB_UNAVAILABLE_MACRO (2, 28) +#define GI_AVAILABLE_ENUMERATOR_IN_2_28 GLIB_UNAVAILABLE_ENUMERATOR (2, 28) +#define GI_AVAILABLE_TYPE_IN_2_28 GLIB_UNAVAILABLE_TYPE (2, 28) +#else +#define GI_AVAILABLE_IN_2_28 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_28 +#define GI_AVAILABLE_MACRO_IN_2_28 +#define GI_AVAILABLE_ENUMERATOR_IN_2_28 +#define GI_AVAILABLE_TYPE_IN_2_28 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30 +#define GI_DEPRECATED_IN_2_30 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_30_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_30 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_30_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_30 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_30 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_30_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_30 _GI_EXTERN +#define GI_DEPRECATED_IN_2_30_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_30 +#define GI_DEPRECATED_MACRO_IN_2_30_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_30 +#define GI_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_30 +#define GI_DEPRECATED_TYPE_IN_2_30_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30 +#define GI_AVAILABLE_IN_2_30 GI_UNAVAILABLE (2, 30) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_30 GLIB_UNAVAILABLE_STATIC_INLINE (2, 30) +#define GI_AVAILABLE_MACRO_IN_2_30 GLIB_UNAVAILABLE_MACRO (2, 30) +#define GI_AVAILABLE_ENUMERATOR_IN_2_30 GLIB_UNAVAILABLE_ENUMERATOR (2, 30) +#define GI_AVAILABLE_TYPE_IN_2_30 GLIB_UNAVAILABLE_TYPE (2, 30) +#else +#define GI_AVAILABLE_IN_2_30 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_30 +#define GI_AVAILABLE_MACRO_IN_2_30 +#define GI_AVAILABLE_ENUMERATOR_IN_2_30 +#define GI_AVAILABLE_TYPE_IN_2_30 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32 +#define GI_DEPRECATED_IN_2_32 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_32_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_32 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_32_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_32 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_32 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_32_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_32 _GI_EXTERN +#define GI_DEPRECATED_IN_2_32_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_32 +#define GI_DEPRECATED_MACRO_IN_2_32_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_32 +#define GI_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_32 +#define GI_DEPRECATED_TYPE_IN_2_32_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32 +#define GI_AVAILABLE_IN_2_32 GI_UNAVAILABLE (2, 32) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_32 GLIB_UNAVAILABLE_STATIC_INLINE (2, 32) +#define GI_AVAILABLE_MACRO_IN_2_32 GLIB_UNAVAILABLE_MACRO (2, 32) +#define GI_AVAILABLE_ENUMERATOR_IN_2_32 GLIB_UNAVAILABLE_ENUMERATOR (2, 32) +#define GI_AVAILABLE_TYPE_IN_2_32 GLIB_UNAVAILABLE_TYPE (2, 32) +#else +#define GI_AVAILABLE_IN_2_32 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_32 +#define GI_AVAILABLE_MACRO_IN_2_32 +#define GI_AVAILABLE_ENUMERATOR_IN_2_32 +#define GI_AVAILABLE_TYPE_IN_2_32 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34 +#define GI_DEPRECATED_IN_2_34 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_34_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_34 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_34_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_34 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_34 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_34_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_34 _GI_EXTERN +#define GI_DEPRECATED_IN_2_34_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_34 +#define GI_DEPRECATED_MACRO_IN_2_34_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_34 +#define GI_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_34 +#define GI_DEPRECATED_TYPE_IN_2_34_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34 +#define GI_AVAILABLE_IN_2_34 GI_UNAVAILABLE (2, 34) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_34 GLIB_UNAVAILABLE_STATIC_INLINE (2, 34) +#define GI_AVAILABLE_MACRO_IN_2_34 GLIB_UNAVAILABLE_MACRO (2, 34) +#define GI_AVAILABLE_ENUMERATOR_IN_2_34 GLIB_UNAVAILABLE_ENUMERATOR (2, 34) +#define GI_AVAILABLE_TYPE_IN_2_34 GLIB_UNAVAILABLE_TYPE (2, 34) +#else +#define GI_AVAILABLE_IN_2_34 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_34 +#define GI_AVAILABLE_MACRO_IN_2_34 +#define GI_AVAILABLE_ENUMERATOR_IN_2_34 +#define GI_AVAILABLE_TYPE_IN_2_34 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36 +#define GI_DEPRECATED_IN_2_36 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_36_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_36 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_36_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_36 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_36 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_36_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_36 _GI_EXTERN +#define GI_DEPRECATED_IN_2_36_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_36 +#define GI_DEPRECATED_MACRO_IN_2_36_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_36 +#define GI_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_36 +#define GI_DEPRECATED_TYPE_IN_2_36_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36 +#define GI_AVAILABLE_IN_2_36 GI_UNAVAILABLE (2, 36) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_36 GLIB_UNAVAILABLE_STATIC_INLINE (2, 36) +#define GI_AVAILABLE_MACRO_IN_2_36 GLIB_UNAVAILABLE_MACRO (2, 36) +#define GI_AVAILABLE_ENUMERATOR_IN_2_36 GLIB_UNAVAILABLE_ENUMERATOR (2, 36) +#define GI_AVAILABLE_TYPE_IN_2_36 GLIB_UNAVAILABLE_TYPE (2, 36) +#else +#define GI_AVAILABLE_IN_2_36 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_36 +#define GI_AVAILABLE_MACRO_IN_2_36 +#define GI_AVAILABLE_ENUMERATOR_IN_2_36 +#define GI_AVAILABLE_TYPE_IN_2_36 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_38 +#define GI_DEPRECATED_IN_2_38 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_38_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_38 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_38_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_38 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_38 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_38_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_38 _GI_EXTERN +#define GI_DEPRECATED_IN_2_38_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_38 +#define GI_DEPRECATED_MACRO_IN_2_38_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_38 +#define GI_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_38 +#define GI_DEPRECATED_TYPE_IN_2_38_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 +#define GI_AVAILABLE_IN_2_38 GI_UNAVAILABLE (2, 38) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_38 GLIB_UNAVAILABLE_STATIC_INLINE (2, 38) +#define GI_AVAILABLE_MACRO_IN_2_38 GLIB_UNAVAILABLE_MACRO (2, 38) +#define GI_AVAILABLE_ENUMERATOR_IN_2_38 GLIB_UNAVAILABLE_ENUMERATOR (2, 38) +#define GI_AVAILABLE_TYPE_IN_2_38 GLIB_UNAVAILABLE_TYPE (2, 38) +#else +#define GI_AVAILABLE_IN_2_38 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_38 +#define GI_AVAILABLE_MACRO_IN_2_38 +#define GI_AVAILABLE_ENUMERATOR_IN_2_38 +#define GI_AVAILABLE_TYPE_IN_2_38 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_40 +#define GI_DEPRECATED_IN_2_40 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_40_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_40 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_40_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_40 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_40 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_40_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_40 _GI_EXTERN +#define GI_DEPRECATED_IN_2_40_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_40 +#define GI_DEPRECATED_MACRO_IN_2_40_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_40 +#define GI_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_40 +#define GI_DEPRECATED_TYPE_IN_2_40_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_40 +#define GI_AVAILABLE_IN_2_40 GI_UNAVAILABLE (2, 40) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_40 GLIB_UNAVAILABLE_STATIC_INLINE (2, 40) +#define GI_AVAILABLE_MACRO_IN_2_40 GLIB_UNAVAILABLE_MACRO (2, 40) +#define GI_AVAILABLE_ENUMERATOR_IN_2_40 GLIB_UNAVAILABLE_ENUMERATOR (2, 40) +#define GI_AVAILABLE_TYPE_IN_2_40 GLIB_UNAVAILABLE_TYPE (2, 40) +#else +#define GI_AVAILABLE_IN_2_40 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_40 +#define GI_AVAILABLE_MACRO_IN_2_40 +#define GI_AVAILABLE_ENUMERATOR_IN_2_40 +#define GI_AVAILABLE_TYPE_IN_2_40 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_42 +#define GI_DEPRECATED_IN_2_42 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_42_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_42 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_42_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_42 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_42 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_42_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_42 _GI_EXTERN +#define GI_DEPRECATED_IN_2_42_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_42 +#define GI_DEPRECATED_MACRO_IN_2_42_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_42 +#define GI_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_42 +#define GI_DEPRECATED_TYPE_IN_2_42_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_42 +#define GI_AVAILABLE_IN_2_42 GI_UNAVAILABLE (2, 42) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_42 GLIB_UNAVAILABLE_STATIC_INLINE (2, 42) +#define GI_AVAILABLE_MACRO_IN_2_42 GLIB_UNAVAILABLE_MACRO (2, 42) +#define GI_AVAILABLE_ENUMERATOR_IN_2_42 GLIB_UNAVAILABLE_ENUMERATOR (2, 42) +#define GI_AVAILABLE_TYPE_IN_2_42 GLIB_UNAVAILABLE_TYPE (2, 42) +#else +#define GI_AVAILABLE_IN_2_42 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_42 +#define GI_AVAILABLE_MACRO_IN_2_42 +#define GI_AVAILABLE_ENUMERATOR_IN_2_42 +#define GI_AVAILABLE_TYPE_IN_2_42 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_44 +#define GI_DEPRECATED_IN_2_44 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_44_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_44 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_44_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_44 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_44 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_44_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_44 _GI_EXTERN +#define GI_DEPRECATED_IN_2_44_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_44 +#define GI_DEPRECATED_MACRO_IN_2_44_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_44 +#define GI_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_44 +#define GI_DEPRECATED_TYPE_IN_2_44_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_44 +#define GI_AVAILABLE_IN_2_44 GI_UNAVAILABLE (2, 44) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_44 GLIB_UNAVAILABLE_STATIC_INLINE (2, 44) +#define GI_AVAILABLE_MACRO_IN_2_44 GLIB_UNAVAILABLE_MACRO (2, 44) +#define GI_AVAILABLE_ENUMERATOR_IN_2_44 GLIB_UNAVAILABLE_ENUMERATOR (2, 44) +#define GI_AVAILABLE_TYPE_IN_2_44 GLIB_UNAVAILABLE_TYPE (2, 44) +#else +#define GI_AVAILABLE_IN_2_44 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_44 +#define GI_AVAILABLE_MACRO_IN_2_44 +#define GI_AVAILABLE_ENUMERATOR_IN_2_44 +#define GI_AVAILABLE_TYPE_IN_2_44 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_46 +#define GI_DEPRECATED_IN_2_46 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_46_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_46 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_46_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_46 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_46 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_46_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_46 _GI_EXTERN +#define GI_DEPRECATED_IN_2_46_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_46 +#define GI_DEPRECATED_MACRO_IN_2_46_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_46 +#define GI_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_46 +#define GI_DEPRECATED_TYPE_IN_2_46_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_46 +#define GI_AVAILABLE_IN_2_46 GI_UNAVAILABLE (2, 46) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_46 GLIB_UNAVAILABLE_STATIC_INLINE (2, 46) +#define GI_AVAILABLE_MACRO_IN_2_46 GLIB_UNAVAILABLE_MACRO (2, 46) +#define GI_AVAILABLE_ENUMERATOR_IN_2_46 GLIB_UNAVAILABLE_ENUMERATOR (2, 46) +#define GI_AVAILABLE_TYPE_IN_2_46 GLIB_UNAVAILABLE_TYPE (2, 46) +#else +#define GI_AVAILABLE_IN_2_46 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_46 +#define GI_AVAILABLE_MACRO_IN_2_46 +#define GI_AVAILABLE_ENUMERATOR_IN_2_46 +#define GI_AVAILABLE_TYPE_IN_2_46 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_48 +#define GI_DEPRECATED_IN_2_48 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_48_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_48 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_48_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_48 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_48 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_48_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_48 _GI_EXTERN +#define GI_DEPRECATED_IN_2_48_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_48 +#define GI_DEPRECATED_MACRO_IN_2_48_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_48 +#define GI_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_48 +#define GI_DEPRECATED_TYPE_IN_2_48_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_48 +#define GI_AVAILABLE_IN_2_48 GI_UNAVAILABLE (2, 48) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_48 GLIB_UNAVAILABLE_STATIC_INLINE (2, 48) +#define GI_AVAILABLE_MACRO_IN_2_48 GLIB_UNAVAILABLE_MACRO (2, 48) +#define GI_AVAILABLE_ENUMERATOR_IN_2_48 GLIB_UNAVAILABLE_ENUMERATOR (2, 48) +#define GI_AVAILABLE_TYPE_IN_2_48 GLIB_UNAVAILABLE_TYPE (2, 48) +#else +#define GI_AVAILABLE_IN_2_48 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_48 +#define GI_AVAILABLE_MACRO_IN_2_48 +#define GI_AVAILABLE_ENUMERATOR_IN_2_48 +#define GI_AVAILABLE_TYPE_IN_2_48 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_50 +#define GI_DEPRECATED_IN_2_50 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_50_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_50 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_50_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_50 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_50 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_50_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_50 _GI_EXTERN +#define GI_DEPRECATED_IN_2_50_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_50 +#define GI_DEPRECATED_MACRO_IN_2_50_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_50 +#define GI_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_50 +#define GI_DEPRECATED_TYPE_IN_2_50_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_50 +#define GI_AVAILABLE_IN_2_50 GI_UNAVAILABLE (2, 50) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_50 GLIB_UNAVAILABLE_STATIC_INLINE (2, 50) +#define GI_AVAILABLE_MACRO_IN_2_50 GLIB_UNAVAILABLE_MACRO (2, 50) +#define GI_AVAILABLE_ENUMERATOR_IN_2_50 GLIB_UNAVAILABLE_ENUMERATOR (2, 50) +#define GI_AVAILABLE_TYPE_IN_2_50 GLIB_UNAVAILABLE_TYPE (2, 50) +#else +#define GI_AVAILABLE_IN_2_50 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_50 +#define GI_AVAILABLE_MACRO_IN_2_50 +#define GI_AVAILABLE_ENUMERATOR_IN_2_50 +#define GI_AVAILABLE_TYPE_IN_2_50 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_52 +#define GI_DEPRECATED_IN_2_52 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_52_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_52 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_52_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_52 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_52 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_52_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_52 _GI_EXTERN +#define GI_DEPRECATED_IN_2_52_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_52 +#define GI_DEPRECATED_MACRO_IN_2_52_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_52 +#define GI_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_52 +#define GI_DEPRECATED_TYPE_IN_2_52_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_52 +#define GI_AVAILABLE_IN_2_52 GI_UNAVAILABLE (2, 52) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_52 GLIB_UNAVAILABLE_STATIC_INLINE (2, 52) +#define GI_AVAILABLE_MACRO_IN_2_52 GLIB_UNAVAILABLE_MACRO (2, 52) +#define GI_AVAILABLE_ENUMERATOR_IN_2_52 GLIB_UNAVAILABLE_ENUMERATOR (2, 52) +#define GI_AVAILABLE_TYPE_IN_2_52 GLIB_UNAVAILABLE_TYPE (2, 52) +#else +#define GI_AVAILABLE_IN_2_52 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_52 +#define GI_AVAILABLE_MACRO_IN_2_52 +#define GI_AVAILABLE_ENUMERATOR_IN_2_52 +#define GI_AVAILABLE_TYPE_IN_2_52 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_54 +#define GI_DEPRECATED_IN_2_54 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_54_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_54 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_54_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_54 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_54 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_54_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_54 _GI_EXTERN +#define GI_DEPRECATED_IN_2_54_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_54 +#define GI_DEPRECATED_MACRO_IN_2_54_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_54 +#define GI_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_54 +#define GI_DEPRECATED_TYPE_IN_2_54_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_54 +#define GI_AVAILABLE_IN_2_54 GI_UNAVAILABLE (2, 54) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_54 GLIB_UNAVAILABLE_STATIC_INLINE (2, 54) +#define GI_AVAILABLE_MACRO_IN_2_54 GLIB_UNAVAILABLE_MACRO (2, 54) +#define GI_AVAILABLE_ENUMERATOR_IN_2_54 GLIB_UNAVAILABLE_ENUMERATOR (2, 54) +#define GI_AVAILABLE_TYPE_IN_2_54 GLIB_UNAVAILABLE_TYPE (2, 54) +#else +#define GI_AVAILABLE_IN_2_54 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_54 +#define GI_AVAILABLE_MACRO_IN_2_54 +#define GI_AVAILABLE_ENUMERATOR_IN_2_54 +#define GI_AVAILABLE_TYPE_IN_2_54 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_56 +#define GI_DEPRECATED_IN_2_56 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_56_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_56 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_56_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_56 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_56 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_56_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_56 _GI_EXTERN +#define GI_DEPRECATED_IN_2_56_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_56 +#define GI_DEPRECATED_MACRO_IN_2_56_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_56 +#define GI_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_56 +#define GI_DEPRECATED_TYPE_IN_2_56_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_56 +#define GI_AVAILABLE_IN_2_56 GI_UNAVAILABLE (2, 56) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_56 GLIB_UNAVAILABLE_STATIC_INLINE (2, 56) +#define GI_AVAILABLE_MACRO_IN_2_56 GLIB_UNAVAILABLE_MACRO (2, 56) +#define GI_AVAILABLE_ENUMERATOR_IN_2_56 GLIB_UNAVAILABLE_ENUMERATOR (2, 56) +#define GI_AVAILABLE_TYPE_IN_2_56 GLIB_UNAVAILABLE_TYPE (2, 56) +#else +#define GI_AVAILABLE_IN_2_56 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_56 +#define GI_AVAILABLE_MACRO_IN_2_56 +#define GI_AVAILABLE_ENUMERATOR_IN_2_56 +#define GI_AVAILABLE_TYPE_IN_2_56 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_58 +#define GI_DEPRECATED_IN_2_58 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_58_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_58 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_58_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_58 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_58 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_58_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_58 _GI_EXTERN +#define GI_DEPRECATED_IN_2_58_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_58 +#define GI_DEPRECATED_MACRO_IN_2_58_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_58 +#define GI_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_58 +#define GI_DEPRECATED_TYPE_IN_2_58_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_58 +#define GI_AVAILABLE_IN_2_58 GI_UNAVAILABLE (2, 58) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_58 GLIB_UNAVAILABLE_STATIC_INLINE (2, 58) +#define GI_AVAILABLE_MACRO_IN_2_58 GLIB_UNAVAILABLE_MACRO (2, 58) +#define GI_AVAILABLE_ENUMERATOR_IN_2_58 GLIB_UNAVAILABLE_ENUMERATOR (2, 58) +#define GI_AVAILABLE_TYPE_IN_2_58 GLIB_UNAVAILABLE_TYPE (2, 58) +#else +#define GI_AVAILABLE_IN_2_58 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_58 +#define GI_AVAILABLE_MACRO_IN_2_58 +#define GI_AVAILABLE_ENUMERATOR_IN_2_58 +#define GI_AVAILABLE_TYPE_IN_2_58 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_60 +#define GI_DEPRECATED_IN_2_60 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_60_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_60 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_60_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_60 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_60 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_60_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_60 _GI_EXTERN +#define GI_DEPRECATED_IN_2_60_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_60 +#define GI_DEPRECATED_MACRO_IN_2_60_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_60 +#define GI_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_60 +#define GI_DEPRECATED_TYPE_IN_2_60_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_60 +#define GI_AVAILABLE_IN_2_60 GI_UNAVAILABLE (2, 60) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_60 GLIB_UNAVAILABLE_STATIC_INLINE (2, 60) +#define GI_AVAILABLE_MACRO_IN_2_60 GLIB_UNAVAILABLE_MACRO (2, 60) +#define GI_AVAILABLE_ENUMERATOR_IN_2_60 GLIB_UNAVAILABLE_ENUMERATOR (2, 60) +#define GI_AVAILABLE_TYPE_IN_2_60 GLIB_UNAVAILABLE_TYPE (2, 60) +#else +#define GI_AVAILABLE_IN_2_60 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_60 +#define GI_AVAILABLE_MACRO_IN_2_60 +#define GI_AVAILABLE_ENUMERATOR_IN_2_60 +#define GI_AVAILABLE_TYPE_IN_2_60 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_62 +#define GI_DEPRECATED_IN_2_62 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_62_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_62 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_62_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_62 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_62 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_62_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_62 _GI_EXTERN +#define GI_DEPRECATED_IN_2_62_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_62 +#define GI_DEPRECATED_MACRO_IN_2_62_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_62 +#define GI_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_62 +#define GI_DEPRECATED_TYPE_IN_2_62_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_62 +#define GI_AVAILABLE_IN_2_62 GI_UNAVAILABLE (2, 62) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_62 GLIB_UNAVAILABLE_STATIC_INLINE (2, 62) +#define GI_AVAILABLE_MACRO_IN_2_62 GLIB_UNAVAILABLE_MACRO (2, 62) +#define GI_AVAILABLE_ENUMERATOR_IN_2_62 GLIB_UNAVAILABLE_ENUMERATOR (2, 62) +#define GI_AVAILABLE_TYPE_IN_2_62 GLIB_UNAVAILABLE_TYPE (2, 62) +#else +#define GI_AVAILABLE_IN_2_62 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_62 +#define GI_AVAILABLE_MACRO_IN_2_62 +#define GI_AVAILABLE_ENUMERATOR_IN_2_62 +#define GI_AVAILABLE_TYPE_IN_2_62 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 +#define GI_DEPRECATED_IN_2_64 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_64_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_64 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_64_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_64 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_64 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_64_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_64 _GI_EXTERN +#define GI_DEPRECATED_IN_2_64_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_64 +#define GI_DEPRECATED_MACRO_IN_2_64_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_64 +#define GI_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_64 +#define GI_DEPRECATED_TYPE_IN_2_64_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64 +#define GI_AVAILABLE_IN_2_64 GI_UNAVAILABLE (2, 64) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_64 GLIB_UNAVAILABLE_STATIC_INLINE (2, 64) +#define GI_AVAILABLE_MACRO_IN_2_64 GLIB_UNAVAILABLE_MACRO (2, 64) +#define GI_AVAILABLE_ENUMERATOR_IN_2_64 GLIB_UNAVAILABLE_ENUMERATOR (2, 64) +#define GI_AVAILABLE_TYPE_IN_2_64 GLIB_UNAVAILABLE_TYPE (2, 64) +#else +#define GI_AVAILABLE_IN_2_64 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_64 +#define GI_AVAILABLE_MACRO_IN_2_64 +#define GI_AVAILABLE_ENUMERATOR_IN_2_64 +#define GI_AVAILABLE_TYPE_IN_2_64 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_66 +#define GI_DEPRECATED_IN_2_66 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_66_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_66 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_66_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_66 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_66 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_66_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_66 _GI_EXTERN +#define GI_DEPRECATED_IN_2_66_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_66 +#define GI_DEPRECATED_MACRO_IN_2_66_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_66 +#define GI_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_66 +#define GI_DEPRECATED_TYPE_IN_2_66_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_66 +#define GI_AVAILABLE_IN_2_66 GI_UNAVAILABLE (2, 66) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_66 GLIB_UNAVAILABLE_STATIC_INLINE (2, 66) +#define GI_AVAILABLE_MACRO_IN_2_66 GLIB_UNAVAILABLE_MACRO (2, 66) +#define GI_AVAILABLE_ENUMERATOR_IN_2_66 GLIB_UNAVAILABLE_ENUMERATOR (2, 66) +#define GI_AVAILABLE_TYPE_IN_2_66 GLIB_UNAVAILABLE_TYPE (2, 66) +#else +#define GI_AVAILABLE_IN_2_66 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_66 +#define GI_AVAILABLE_MACRO_IN_2_66 +#define GI_AVAILABLE_ENUMERATOR_IN_2_66 +#define GI_AVAILABLE_TYPE_IN_2_66 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68 +#define GI_DEPRECATED_IN_2_68 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_68_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_68 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_68_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_68 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_68 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_68_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_68 _GI_EXTERN +#define GI_DEPRECATED_IN_2_68_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_68 +#define GI_DEPRECATED_MACRO_IN_2_68_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_68 +#define GI_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_68 +#define GI_DEPRECATED_TYPE_IN_2_68_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_68 +#define GI_AVAILABLE_IN_2_68 GI_UNAVAILABLE (2, 68) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_68 GLIB_UNAVAILABLE_STATIC_INLINE (2, 68) +#define GI_AVAILABLE_MACRO_IN_2_68 GLIB_UNAVAILABLE_MACRO (2, 68) +#define GI_AVAILABLE_ENUMERATOR_IN_2_68 GLIB_UNAVAILABLE_ENUMERATOR (2, 68) +#define GI_AVAILABLE_TYPE_IN_2_68 GLIB_UNAVAILABLE_TYPE (2, 68) +#else +#define GI_AVAILABLE_IN_2_68 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_68 +#define GI_AVAILABLE_MACRO_IN_2_68 +#define GI_AVAILABLE_ENUMERATOR_IN_2_68 +#define GI_AVAILABLE_TYPE_IN_2_68 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_70 +#define GI_DEPRECATED_IN_2_70 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_70_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_70 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_70_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_70 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_70 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_70_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_70 _GI_EXTERN +#define GI_DEPRECATED_IN_2_70_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_70 +#define GI_DEPRECATED_MACRO_IN_2_70_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_70 +#define GI_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_70 +#define GI_DEPRECATED_TYPE_IN_2_70_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_70 +#define GI_AVAILABLE_IN_2_70 GI_UNAVAILABLE (2, 70) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_70 GLIB_UNAVAILABLE_STATIC_INLINE (2, 70) +#define GI_AVAILABLE_MACRO_IN_2_70 GLIB_UNAVAILABLE_MACRO (2, 70) +#define GI_AVAILABLE_ENUMERATOR_IN_2_70 GLIB_UNAVAILABLE_ENUMERATOR (2, 70) +#define GI_AVAILABLE_TYPE_IN_2_70 GLIB_UNAVAILABLE_TYPE (2, 70) +#else +#define GI_AVAILABLE_IN_2_70 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_70 +#define GI_AVAILABLE_MACRO_IN_2_70 +#define GI_AVAILABLE_ENUMERATOR_IN_2_70 +#define GI_AVAILABLE_TYPE_IN_2_70 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_72 +#define GI_DEPRECATED_IN_2_72 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_72_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_72 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_72_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_72 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_72 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_72_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_72 _GI_EXTERN +#define GI_DEPRECATED_IN_2_72_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_72 +#define GI_DEPRECATED_MACRO_IN_2_72_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_72 +#define GI_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_72 +#define GI_DEPRECATED_TYPE_IN_2_72_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_72 +#define GI_AVAILABLE_IN_2_72 GI_UNAVAILABLE (2, 72) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_72 GLIB_UNAVAILABLE_STATIC_INLINE (2, 72) +#define GI_AVAILABLE_MACRO_IN_2_72 GLIB_UNAVAILABLE_MACRO (2, 72) +#define GI_AVAILABLE_ENUMERATOR_IN_2_72 GLIB_UNAVAILABLE_ENUMERATOR (2, 72) +#define GI_AVAILABLE_TYPE_IN_2_72 GLIB_UNAVAILABLE_TYPE (2, 72) +#else +#define GI_AVAILABLE_IN_2_72 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_72 +#define GI_AVAILABLE_MACRO_IN_2_72 +#define GI_AVAILABLE_ENUMERATOR_IN_2_72 +#define GI_AVAILABLE_TYPE_IN_2_72 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_74 +#define GI_DEPRECATED_IN_2_74 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_74_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_74 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_74_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_74 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_74 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_74_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_74 _GI_EXTERN +#define GI_DEPRECATED_IN_2_74_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_74 +#define GI_DEPRECATED_MACRO_IN_2_74_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_74 +#define GI_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_74 +#define GI_DEPRECATED_TYPE_IN_2_74_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_74 +#define GI_AVAILABLE_IN_2_74 GI_UNAVAILABLE (2, 74) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_74 GLIB_UNAVAILABLE_STATIC_INLINE (2, 74) +#define GI_AVAILABLE_MACRO_IN_2_74 GLIB_UNAVAILABLE_MACRO (2, 74) +#define GI_AVAILABLE_ENUMERATOR_IN_2_74 GLIB_UNAVAILABLE_ENUMERATOR (2, 74) +#define GI_AVAILABLE_TYPE_IN_2_74 GLIB_UNAVAILABLE_TYPE (2, 74) +#else +#define GI_AVAILABLE_IN_2_74 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_74 +#define GI_AVAILABLE_MACRO_IN_2_74 +#define GI_AVAILABLE_ENUMERATOR_IN_2_74 +#define GI_AVAILABLE_TYPE_IN_2_74 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76 +#define GI_DEPRECATED_IN_2_76 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_76_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_76 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_76_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_76 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_76 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_76_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_76 _GI_EXTERN +#define GI_DEPRECATED_IN_2_76_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_76 +#define GI_DEPRECATED_MACRO_IN_2_76_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_76 +#define GI_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_76 +#define GI_DEPRECATED_TYPE_IN_2_76_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_76 +#define GI_AVAILABLE_IN_2_76 GI_UNAVAILABLE (2, 76) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_76 GLIB_UNAVAILABLE_STATIC_INLINE (2, 76) +#define GI_AVAILABLE_MACRO_IN_2_76 GLIB_UNAVAILABLE_MACRO (2, 76) +#define GI_AVAILABLE_ENUMERATOR_IN_2_76 GLIB_UNAVAILABLE_ENUMERATOR (2, 76) +#define GI_AVAILABLE_TYPE_IN_2_76 GLIB_UNAVAILABLE_TYPE (2, 76) +#else +#define GI_AVAILABLE_IN_2_76 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_76 +#define GI_AVAILABLE_MACRO_IN_2_76 +#define GI_AVAILABLE_ENUMERATOR_IN_2_76 +#define GI_AVAILABLE_TYPE_IN_2_76 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 +#define GI_DEPRECATED_IN_2_78 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_78_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_78 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_78_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_78 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_78 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_78_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_78 _GI_EXTERN +#define GI_DEPRECATED_IN_2_78_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_78 +#define GI_DEPRECATED_MACRO_IN_2_78_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_78 +#define GI_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_78 +#define GI_DEPRECATED_TYPE_IN_2_78_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_78 +#define GI_AVAILABLE_IN_2_78 GI_UNAVAILABLE (2, 78) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_78 GLIB_UNAVAILABLE_STATIC_INLINE (2, 78) +#define GI_AVAILABLE_MACRO_IN_2_78 GLIB_UNAVAILABLE_MACRO (2, 78) +#define GI_AVAILABLE_ENUMERATOR_IN_2_78 GLIB_UNAVAILABLE_ENUMERATOR (2, 78) +#define GI_AVAILABLE_TYPE_IN_2_78 GLIB_UNAVAILABLE_TYPE (2, 78) +#else +#define GI_AVAILABLE_IN_2_78 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_78 +#define GI_AVAILABLE_MACRO_IN_2_78 +#define GI_AVAILABLE_ENUMERATOR_IN_2_78 +#define GI_AVAILABLE_TYPE_IN_2_78 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_80 +#define GI_DEPRECATED_IN_2_80 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_80_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_80 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_80_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_80 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_80 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_80_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_80 _GI_EXTERN +#define GI_DEPRECATED_IN_2_80_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_80 +#define GI_DEPRECATED_MACRO_IN_2_80_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_80 +#define GI_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_80 +#define GI_DEPRECATED_TYPE_IN_2_80_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_80 +#define GI_AVAILABLE_IN_2_80 GI_UNAVAILABLE (2, 80) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_80 GLIB_UNAVAILABLE_STATIC_INLINE (2, 80) +#define GI_AVAILABLE_MACRO_IN_2_80 GLIB_UNAVAILABLE_MACRO (2, 80) +#define GI_AVAILABLE_ENUMERATOR_IN_2_80 GLIB_UNAVAILABLE_ENUMERATOR (2, 80) +#define GI_AVAILABLE_TYPE_IN_2_80 GLIB_UNAVAILABLE_TYPE (2, 80) +#else +#define GI_AVAILABLE_IN_2_80 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_80 +#define GI_AVAILABLE_MACRO_IN_2_80 +#define GI_AVAILABLE_ENUMERATOR_IN_2_80 +#define GI_AVAILABLE_TYPE_IN_2_80 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_82 +#define GI_DEPRECATED_IN_2_82 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_82_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_82 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_82_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_82 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_82 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_82_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_82 _GI_EXTERN +#define GI_DEPRECATED_IN_2_82_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_82 +#define GI_DEPRECATED_MACRO_IN_2_82_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_82 +#define GI_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_82 +#define GI_DEPRECATED_TYPE_IN_2_82_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_82 +#define GI_AVAILABLE_IN_2_82 GI_UNAVAILABLE (2, 82) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_82 GLIB_UNAVAILABLE_STATIC_INLINE (2, 82) +#define GI_AVAILABLE_MACRO_IN_2_82 GLIB_UNAVAILABLE_MACRO (2, 82) +#define GI_AVAILABLE_ENUMERATOR_IN_2_82 GLIB_UNAVAILABLE_ENUMERATOR (2, 82) +#define GI_AVAILABLE_TYPE_IN_2_82 GLIB_UNAVAILABLE_TYPE (2, 82) +#else +#define GI_AVAILABLE_IN_2_82 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_82 +#define GI_AVAILABLE_MACRO_IN_2_82 +#define GI_AVAILABLE_ENUMERATOR_IN_2_82 +#define GI_AVAILABLE_TYPE_IN_2_82 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_84 +#define GI_DEPRECATED_IN_2_84 GI_DEPRECATED +#define GI_DEPRECATED_IN_2_84_FOR(f) GI_DEPRECATED_FOR (f) +#define GI_DEPRECATED_MACRO_IN_2_84 GLIB_DEPRECATED_MACRO +#define GI_DEPRECATED_MACRO_IN_2_84_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_84 GLIB_DEPRECATED_ENUMERATOR +#define GI_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GI_DEPRECATED_TYPE_IN_2_84 GLIB_DEPRECATED_TYPE +#define GI_DEPRECATED_TYPE_IN_2_84_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GI_DEPRECATED_IN_2_84 _GI_EXTERN +#define GI_DEPRECATED_IN_2_84_FOR(f) _GI_EXTERN +#define GI_DEPRECATED_MACRO_IN_2_84 +#define GI_DEPRECATED_MACRO_IN_2_84_FOR(f) +#define GI_DEPRECATED_ENUMERATOR_IN_2_84 +#define GI_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) +#define GI_DEPRECATED_TYPE_IN_2_84 +#define GI_DEPRECATED_TYPE_IN_2_84_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_84 +#define GI_AVAILABLE_IN_2_84 GI_UNAVAILABLE (2, 84) +#define GI_AVAILABLE_STATIC_INLINE_IN_2_84 GLIB_UNAVAILABLE_STATIC_INLINE (2, 84) +#define GI_AVAILABLE_MACRO_IN_2_84 GLIB_UNAVAILABLE_MACRO (2, 84) +#define GI_AVAILABLE_ENUMERATOR_IN_2_84 GLIB_UNAVAILABLE_ENUMERATOR (2, 84) +#define GI_AVAILABLE_TYPE_IN_2_84 GLIB_UNAVAILABLE_TYPE (2, 84) +#else +#define GI_AVAILABLE_IN_2_84 _GI_EXTERN +#define GI_AVAILABLE_STATIC_INLINE_IN_2_84 +#define GI_AVAILABLE_MACRO_IN_2_84 +#define GI_AVAILABLE_ENUMERATOR_IN_2_84 +#define GI_AVAILABLE_TYPE_IN_2_84 +#endif diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/giarginfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/giarginfo.h new file mode 100644 index 00000000..e7a61b1d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/giarginfo.h @@ -0,0 +1,100 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Argument + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_ARG_INFO (gi_arg_info_get_type ()) + +/** + * GI_ARG_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.ArgInfo] or derived pointer into a + * `(GIArgInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_ARG_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_ARG_INFO, GIArgInfo)) + +/** + * GI_IS_ARG_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.ArgInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_ARG_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_ARG_INFO)) + + +GI_AVAILABLE_IN_ALL +GIDirection gi_arg_info_get_direction (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_arg_info_is_return_value (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_arg_info_is_optional (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_arg_info_is_caller_allocates (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_arg_info_may_be_null (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_arg_info_is_skip (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +GITransfer gi_arg_info_get_ownership_transfer (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +GIScopeType gi_arg_info_get_scope (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_arg_info_get_closure_index (GIArgInfo *info, + unsigned int *out_closure_index); + +GI_AVAILABLE_IN_ALL +gboolean gi_arg_info_get_destroy_index (GIArgInfo *info, + unsigned int *out_destroy_index); + +GI_AVAILABLE_IN_ALL +GITypeInfo * gi_arg_info_get_type_info (GIArgInfo *info); + +GI_AVAILABLE_IN_ALL +void gi_arg_info_load_type_info (GIArgInfo *info, + GITypeInfo *type); +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gibaseinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gibaseinfo.h new file mode 100644 index 00000000..4f87b9f5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gibaseinfo.h @@ -0,0 +1,129 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: GIBaseInfo + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +/** + * GIAttributeIter: + * + * An opaque structure used to iterate over attributes + * in a [class@GIRepository.BaseInfo] struct. + * + * Since: 2.80 + */ +typedef struct { + /*< private >*/ + void *data; + void *_dummy[4]; +} GIAttributeIter; + +/** + * GI_ATTRIBUTE_ITER_INIT: + * + * Initialise a stack-allocated [type@GIRepository.AttributeIter] to a value + * suitable for passing to the first call to an ‘iterate’ function. + * + * Since: 2.80 + */ +#define GI_ATTRIBUTE_ITER_INIT { NULL, { NULL, } } + +#define GI_TYPE_BASE_INFO (gi_base_info_get_type ()) + +/** + * GI_BASE_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.BaseInfo] or derived pointer into a + * `(GIBaseInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_BASE_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_BASE_INFO, GIBaseInfo)) + +/** + * GI_IS_BASE_INFO: + * @info: Instance to check for being a `GI_TYPE_BASE_INFO`. + * + * Checks whether a valid [type@GObject.TypeInstance] pointer is of type + * `GI_TYPE_BASE_INFO` (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_BASE_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_BASE_INFO)) + +GI_AVAILABLE_IN_ALL +GType gi_base_info_get_type (void) G_GNUC_CONST; + +GI_AVAILABLE_IN_ALL +GIBaseInfo * gi_base_info_ref (void *info); + +GI_AVAILABLE_IN_ALL +void gi_base_info_unref (void *info); + +GI_AVAILABLE_IN_ALL +void gi_base_info_clear (void *info); + +GI_AVAILABLE_IN_ALL +const char * gi_base_info_get_name (GIBaseInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_base_info_get_namespace (GIBaseInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_base_info_is_deprecated (GIBaseInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_base_info_get_attribute (GIBaseInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +gboolean gi_base_info_iterate_attributes (GIBaseInfo *info, + GIAttributeIter *iterator, + const char **name, + const char **value); + +GI_AVAILABLE_IN_ALL +GIBaseInfo * gi_base_info_get_container (GIBaseInfo *info); + +GI_AVAILABLE_IN_ALL +GITypelib * gi_base_info_get_typelib (GIBaseInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_base_info_equal (GIBaseInfo *info1, + GIBaseInfo *info2); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gicallableinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gicallableinfo.h new file mode 100644 index 00000000..42fcf42c --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gicallableinfo.h @@ -0,0 +1,131 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_CALLABLE_INFO (gi_callable_info_get_type ()) + +/** + * GI_CALLABLE_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.CallableInfo] or derived pointer into a + * `(GICallableInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_CALLABLE_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_CALLABLE_INFO, GICallableInfo)) + +/** + * GI_IS_CALLABLE_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.CallableInfo] or derived from it. + * + * Since: 2.80 + */ +#define GI_IS_CALLABLE_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_CALLABLE_INFO)) + + +GI_AVAILABLE_IN_ALL +gboolean gi_callable_info_is_method (GICallableInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_callable_info_can_throw_gerror (GICallableInfo *info); + +GI_AVAILABLE_IN_ALL +GITypeInfo * gi_callable_info_get_return_type (GICallableInfo *info); + +GI_AVAILABLE_IN_ALL +void gi_callable_info_load_return_type (GICallableInfo *info, + GITypeInfo *type); + +GI_AVAILABLE_IN_ALL +const char * gi_callable_info_get_return_attribute (GICallableInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +gboolean gi_callable_info_iterate_return_attributes (GICallableInfo *info, + GIAttributeIter *iterator, + const char **name, + const char **value); + +GI_AVAILABLE_IN_ALL +GITransfer gi_callable_info_get_caller_owns (GICallableInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_callable_info_may_return_null (GICallableInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_callable_info_skip_return (GICallableInfo *info); + +GI_AVAILABLE_IN_ALL +unsigned int gi_callable_info_get_n_args (GICallableInfo *info); + +GI_AVAILABLE_IN_ALL +GIArgInfo * gi_callable_info_get_arg (GICallableInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +void gi_callable_info_load_arg (GICallableInfo *info, + unsigned int n, + GIArgInfo *arg); + +GI_AVAILABLE_IN_ALL +gboolean gi_callable_info_invoke (GICallableInfo *info, + void *function, + const GIArgument *in_args, + size_t n_in_args, + GIArgument *out_args, + size_t n_out_args, + GIArgument *return_value, + GError **error); + +GI_AVAILABLE_IN_ALL +GITransfer gi_callable_info_get_instance_ownership_transfer (GICallableInfo *info); + +GI_AVAILABLE_IN_2_84 +GICallableInfo *gi_callable_info_get_async_function (GICallableInfo *info); + +GI_AVAILABLE_IN_2_84 +GICallableInfo *gi_callable_info_get_sync_function (GICallableInfo *info); + +GI_AVAILABLE_IN_2_84 +GICallableInfo *gi_callable_info_get_finish_function (GICallableInfo *info); + +GI_AVAILABLE_IN_2_84 +gboolean gi_callable_info_is_async (GICallableInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gicallbackinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gicallbackinfo.h new file mode 100644 index 00000000..8f559023 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gicallbackinfo.h @@ -0,0 +1,60 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable + * + * Copyright 2023 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_CALLBACK_INFO (gi_callback_info_get_type ()) + +/** + * GI_CALLBACK_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.CallbackInfo] or derived pointer into a + * `(GICallbackInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_CALLBACK_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_CALLBACK_INFO, GICallbackInfo)) + +/** + * GI_IS_CALLBACK_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.CallbackInfo] or derived from it. + * + * Since: 2.80 + */ +#define GI_IS_CALLBACK_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_CALLBACK_INFO)) + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/giconstantinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/giconstantinfo.h new file mode 100644 index 00000000..eda69895 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/giconstantinfo.h @@ -0,0 +1,72 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Constant + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_CONSTANT_INFO (gi_constant_info_get_type ()) + +/** + * GI_CONSTANT_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.ConstantInfo] or derived pointer into a + * `(GIConstantInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_CONSTANT_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_CONSTANT_INFO, GIConstantInfo)) + +/** + * GI_IS_CONSTANT_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.ConstantInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_CONSTANT_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_CONSTANT_INFO)) + + +GI_AVAILABLE_IN_ALL +GITypeInfo * gi_constant_info_get_type_info (GIConstantInfo *info); + +GI_AVAILABLE_IN_ALL +void gi_constant_info_free_value (GIConstantInfo *info, + GIArgument *value); + +GI_AVAILABLE_IN_ALL +size_t gi_constant_info_get_value (GIConstantInfo *info, + GIArgument *value); +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gienuminfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gienuminfo.h new file mode 100644 index 00000000..fcd22059 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gienuminfo.h @@ -0,0 +1,82 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Enum and Enum values + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_ENUM_INFO (gi_enum_info_get_type ()) + +/** + * GI_ENUM_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.EnumInfo] or derived pointer into a + * `(GIEnumInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_ENUM_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_ENUM_INFO, GIEnumInfo)) + +/** + * GI_IS_ENUM_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.EnumInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_ENUM_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_ENUM_INFO)) + + +GI_AVAILABLE_IN_ALL +unsigned int gi_enum_info_get_n_values (GIEnumInfo *info); + +GI_AVAILABLE_IN_ALL +GIValueInfo * gi_enum_info_get_value (GIEnumInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +unsigned int gi_enum_info_get_n_methods (GIEnumInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_enum_info_get_method (GIEnumInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GITypeTag gi_enum_info_get_storage_type (GIEnumInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_enum_info_get_error_domain (GIEnumInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gifieldinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gifieldinfo.h new file mode 100644 index 00000000..e3d13724 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gifieldinfo.h @@ -0,0 +1,84 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Field and Field values + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_FIELD_INFO (gi_field_info_get_type ()) + +/** + * GI_FIELD_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.FieldInfo] or derived pointer into a + * `(GIFieldInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_FIELD_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_FIELD_INFO, GIFieldInfo)) + +/** + * GI_IS_FIELD_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.FieldInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_FIELD_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_FIELD_INFO)) + + +GI_AVAILABLE_IN_ALL +GIFieldInfoFlags gi_field_info_get_flags (GIFieldInfo *info); + +GI_AVAILABLE_IN_ALL +size_t gi_field_info_get_size (GIFieldInfo *info); + +GI_AVAILABLE_IN_ALL +size_t gi_field_info_get_offset (GIFieldInfo *info); + +GI_AVAILABLE_IN_ALL +GITypeInfo * gi_field_info_get_type_info (GIFieldInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_field_info_get_field (GIFieldInfo *field_info, + void *mem, + GIArgument *value); + +GI_AVAILABLE_IN_ALL +gboolean gi_field_info_set_field (GIFieldInfo *field_info, + void *mem, + const GIArgument *value); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/giflagsinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/giflagsinfo.h new file mode 100644 index 00000000..1070eff8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/giflagsinfo.h @@ -0,0 +1,60 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Flags type + * + * Copyright 2024 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_FLAGS_INFO (gi_flags_info_get_type ()) + +/** + * GI_FLAGS_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.FlagsInfo] or derived pointer into a + * `(GIFlagsInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_FLAGS_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_FLAGS_INFO, GIFlagsInfo)) + +/** + * GI_IS_FLAGS_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.FlagsInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_FLAGS_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_FLAGS_INFO)) + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gifunctioninfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gifunctioninfo.h new file mode 100644 index 00000000..ce7dd9e3 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gifunctioninfo.h @@ -0,0 +1,117 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Function + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_FUNCTION_INFO (gi_function_info_get_type ()) + +/** + * GI_FUNCTION_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.FunctionInfo] or derived pointer into a + * `(GIFunctionInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_FUNCTION_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_FUNCTION_INFO, GIFunctionInfo)) + +/** + * GI_IS_FUNCTION_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.FunctionInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_FUNCTION_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_FUNCTION_INFO)) + + +GI_AVAILABLE_IN_ALL +const char * gi_function_info_get_symbol (GIFunctionInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfoFlags gi_function_info_get_flags (GIFunctionInfo *info); + +GI_AVAILABLE_IN_ALL +GIPropertyInfo * gi_function_info_get_property (GIFunctionInfo *info); + +GI_AVAILABLE_IN_ALL +GIVFuncInfo * gi_function_info_get_vfunc (GIFunctionInfo *info); + +/** + * GI_INVOKE_ERROR: + * + * Type quark function for [enum@GIRepository.InvokeError]. + * + * Since: 2.80 + */ +#define GI_INVOKE_ERROR (gi_invoke_error_quark ()) + +GI_AVAILABLE_IN_ALL +GQuark gi_invoke_error_quark (void); + +/** + * GIInvokeError: + * @GI_INVOKE_ERROR_FAILED: invocation failed, unknown error. + * @GI_INVOKE_ERROR_SYMBOL_NOT_FOUND: symbol couldn’t be found in any of the + * libraries associated with the typelib of the function. + * @GI_INVOKE_ERROR_ARGUMENT_MISMATCH: the arguments provided didn’t match + * the expected arguments for the function’s type signature. + * + * An error occurring while invoking a function via + * [method@GIRepository.FunctionInfo.invoke]. + * + * Since: 2.80 + */ +typedef enum +{ + GI_INVOKE_ERROR_FAILED, + GI_INVOKE_ERROR_SYMBOL_NOT_FOUND, + GI_INVOKE_ERROR_ARGUMENT_MISMATCH +} GIInvokeError; + + +GI_AVAILABLE_IN_ALL +gboolean gi_function_info_invoke (GIFunctionInfo *info, + const GIArgument *in_args, + size_t n_in_args, + GIArgument *out_args, + size_t n_out_args, + GIArgument *return_value, + GError **error); + + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/giinterfaceinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/giinterfaceinfo.h new file mode 100644 index 00000000..9cb0d4e6 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/giinterfaceinfo.h @@ -0,0 +1,120 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Interface + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_INTERFACE_INFO (gi_interface_info_get_type ()) + +/** + * GI_INTERFACE_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.InterfaceInfo] or derived pointer into a + * `(GIInterfaceInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_INTERFACE_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_INTERFACE_INFO, GIInterfaceInfo)) + +/** + * GI_IS_INTERFACE_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.InterfaceInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_INTERFACE_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_INTERFACE_INFO)) + + +GI_AVAILABLE_IN_ALL +unsigned int gi_interface_info_get_n_prerequisites (GIInterfaceInfo *info); + +GI_AVAILABLE_IN_ALL +GIBaseInfo * gi_interface_info_get_prerequisite (GIInterfaceInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +unsigned int gi_interface_info_get_n_properties (GIInterfaceInfo *info); + +GI_AVAILABLE_IN_ALL +GIPropertyInfo * gi_interface_info_get_property (GIInterfaceInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +unsigned int gi_interface_info_get_n_methods (GIInterfaceInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_interface_info_get_method (GIInterfaceInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_interface_info_find_method (GIInterfaceInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +unsigned int gi_interface_info_get_n_signals (GIInterfaceInfo *info); + +GI_AVAILABLE_IN_ALL +GISignalInfo * gi_interface_info_get_signal (GIInterfaceInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GISignalInfo * gi_interface_info_find_signal (GIInterfaceInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +unsigned int gi_interface_info_get_n_vfuncs (GIInterfaceInfo *info); + +GI_AVAILABLE_IN_ALL +GIVFuncInfo * gi_interface_info_get_vfunc (GIInterfaceInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GIVFuncInfo * gi_interface_info_find_vfunc (GIInterfaceInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +unsigned int gi_interface_info_get_n_constants (GIInterfaceInfo *info); + +GI_AVAILABLE_IN_ALL +GIConstantInfo * gi_interface_info_get_constant (GIInterfaceInfo *info, + unsigned int n); + + +GI_AVAILABLE_IN_ALL +GIStructInfo * gi_interface_info_get_iface_struct (GIInterfaceInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/giobjectinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/giobjectinfo.h new file mode 100644 index 00000000..cb652704 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/giobjectinfo.h @@ -0,0 +1,230 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Object + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * GIObjectInfoRefFunction: (skip) + * @object: object instance pointer + * + * Increases the reference count of an object instance. + * + * Returns: (transfer full): the object instance + * Since: 2.80 + */ +typedef void * (*GIObjectInfoRefFunction) (void *object); + +/** + * GIObjectInfoUnrefFunction: (skip) + * @object: (transfer full): object instance pointer + * + * Decreases the reference count of an object instance. + * + * Since: 2.80 + */ +typedef void (*GIObjectInfoUnrefFunction) (void *object); + +/** + * GIObjectInfoSetValueFunction: (skip) + * @value: a [type@GObject.Value] + * @object: object instance pointer + * + * Update @value and attach the object instance pointer @object to it. + * + * Since: 2.80 + */ +typedef void (*GIObjectInfoSetValueFunction) (GValue *value, void *object); + +/** + * GIObjectInfoGetValueFunction: (skip) + * @value: a [type@GObject.Value] + * + * Extract an object instance out of @value. + * + * Returns: (transfer full): the object instance + * Since: 2.80 + */ +typedef void * (*GIObjectInfoGetValueFunction) (const GValue *value); + +#define GI_TYPE_OBJECT_INFO (gi_object_info_get_type ()) + +/** + * GI_OBJECT_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.ObjectInfo] or derived pointer into a + * `(GIObjectInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_OBJECT_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_OBJECT_INFO, GIObjectInfo)) + +/** + * GI_IS_OBJECT_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.ObjectInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_OBJECT_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_OBJECT_INFO)) + + +GI_AVAILABLE_IN_ALL +const char * gi_object_info_get_type_name (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_object_info_get_type_init_function_name (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_object_info_get_abstract (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_object_info_get_final (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_object_info_get_fundamental (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIObjectInfo * gi_object_info_get_parent (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +unsigned int gi_object_info_get_n_interfaces (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIInterfaceInfo * gi_object_info_get_interface (GIObjectInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +unsigned int gi_object_info_get_n_fields (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIFieldInfo * gi_object_info_get_field (GIObjectInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +unsigned int gi_object_info_get_n_properties (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIPropertyInfo * gi_object_info_get_property (GIObjectInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +unsigned int gi_object_info_get_n_methods (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, + const char *name); + + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_object_info_find_method_using_interfaces (GIObjectInfo *info, + const char *name, + GIBaseInfo **declarer); + + +GI_AVAILABLE_IN_ALL +unsigned int gi_object_info_get_n_signals (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info, + unsigned int n); + + +GI_AVAILABLE_IN_ALL +GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info, + const char *name); + + +GI_AVAILABLE_IN_ALL +unsigned int gi_object_info_get_n_vfuncs (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +GIVFuncInfo * gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, + const char *name, + GIBaseInfo **declarer); + +GI_AVAILABLE_IN_ALL +unsigned int gi_object_info_get_n_constants (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIConstantInfo * gi_object_info_get_constant (GIObjectInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GIStructInfo * gi_object_info_get_class_struct (GIObjectInfo *info); + + +GI_AVAILABLE_IN_ALL +const char * gi_object_info_get_ref_function_name (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIObjectInfoRefFunction gi_object_info_get_ref_function_pointer (GIObjectInfo *info); + + +GI_AVAILABLE_IN_ALL +const char * gi_object_info_get_unref_function_name (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIObjectInfoUnrefFunction gi_object_info_get_unref_function_pointer (GIObjectInfo *info); + + +GI_AVAILABLE_IN_ALL +const char * gi_object_info_get_set_value_function_name (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIObjectInfoSetValueFunction gi_object_info_get_set_value_function_pointer (GIObjectInfo *info); + + +GI_AVAILABLE_IN_ALL +const char * gi_object_info_get_get_value_function_name (GIObjectInfo *info); + +GI_AVAILABLE_IN_ALL +GIObjectInfoGetValueFunction gi_object_info_get_get_value_function_pointer (GIObjectInfo *info); + + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gipropertyinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gipropertyinfo.h new file mode 100644 index 00000000..a21831a7 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gipropertyinfo.h @@ -0,0 +1,77 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Property + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_PROPERTY_INFO (gi_property_info_get_type ()) + +/** + * GI_PROPERTY_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.PropertyInfo] or derived pointer into a + * `(GIPropertyInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_PROPERTY_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_PROPERTY_INFO, GIPropertyInfo)) + +/** + * GI_IS_PROPERTY_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.PropertyInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_PROPERTY_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_PROPERTY_INFO)) + + +GI_AVAILABLE_IN_ALL +GParamFlags gi_property_info_get_flags (GIPropertyInfo *info); + +GI_AVAILABLE_IN_ALL +GITypeInfo *gi_property_info_get_type_info (GIPropertyInfo *info); + +GI_AVAILABLE_IN_ALL +GITransfer gi_property_info_get_ownership_transfer (GIPropertyInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo *gi_property_info_get_setter (GIPropertyInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo *gi_property_info_get_getter (GIPropertyInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/giregisteredtypeinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/giregisteredtypeinfo.h new file mode 100644 index 00000000..a6fe2ddb --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/giregisteredtypeinfo.h @@ -0,0 +1,75 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Registered Type + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define GI_TYPE_REGISTERED_TYPE_INFO (gi_registered_type_info_get_type ()) + +/** + * GI_REGISTERED_TYPE_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.RegisteredTypeInfo] or derived pointer into a + * `(GIRegisteredTypeInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_REGISTERED_TYPE_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_REGISTERED_TYPE_INFO, GIRegisteredTypeInfo)) + +/** + * GI_IS_REGISTERED_TYPE_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.RegisteredTypeInfo] or derived from + * it. + * + * Since: 2.80 + */ +#define GI_IS_REGISTERED_TYPE_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_REGISTERED_TYPE_INFO)) + +GI_AVAILABLE_IN_ALL +const char * gi_registered_type_info_get_type_name (GIRegisteredTypeInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_registered_type_info_get_type_init_function_name (GIRegisteredTypeInfo *info); + +GI_AVAILABLE_IN_ALL +GType gi_registered_type_info_get_g_type (GIRegisteredTypeInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_registered_type_info_is_boxed (GIRegisteredTypeInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/girepository-autocleanups.h b/illumos-x86_64/usr/include/glib-2.0/girepository/girepository-autocleanups.h new file mode 100644 index 00000000..d48e7b2c --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/girepository-autocleanups.h @@ -0,0 +1,56 @@ +/* + * Copyright 2024 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Philip Withnall + */ + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GI_SCANNER__ + +/* GIRepository already has its cleanups defined by G_DECLARE_FINAL_TYPE */ +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GITypelib, gi_typelib_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIBaseInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIArgInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GICallableInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GICallbackInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIConstantInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIEnumInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIFieldInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIFlagsInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIFunctionInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIInterfaceInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIObjectInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIPropertyInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIRegisteredTypeInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GISignalInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIStructInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GITypeInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIUnionInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIUnresolvedInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIValueInfo, gi_base_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GIVFuncInfo, gi_base_info_unref) + +/* These types can additionally be stack allocated and cleared */ +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (GIArgInfo, gi_base_info_clear) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (GITypeInfo, gi_base_info_clear) + +#endif /* __GI_SCANNER__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/girepository.h b/illumos-x86_64/usr/include/glib-2.0/girepository/girepository.h new file mode 100644 index 00000000..13d94cdf --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/girepository.h @@ -0,0 +1,247 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Repository + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#include +#include + +#include + +#define __GIREPOSITORY_H_INSIDE__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define GI_TYPE_REPOSITORY (gi_repository_get_type ()) +GI_AVAILABLE_IN_ALL +G_DECLARE_FINAL_TYPE (GIRepository, gi_repository, GI, REPOSITORY, GObject) + +/** + * GIRepositoryLoadFlags: + * @GI_REPOSITORY_LOAD_FLAG_NONE: No flags set. + * @GI_REPOSITORY_LOAD_FLAG_LAZY: Lazily load the typelib. + * + * Flags that control how a typelib is loaded. + * + * Since: 2.80 + */ +typedef enum +{ + GI_REPOSITORY_LOAD_FLAG_NONE = 0, + GI_REPOSITORY_LOAD_FLAG_LAZY = 1 << 0 +} GIRepositoryLoadFlags; + +/* Repository */ + +GI_AVAILABLE_IN_ALL +GIRepository *gi_repository_new (void); + +GI_AVAILABLE_IN_ALL +void gi_repository_prepend_search_path (GIRepository *repository, + const char *directory); + +GI_AVAILABLE_IN_ALL +void gi_repository_prepend_library_path (GIRepository *repository, + const char *directory); + +GI_AVAILABLE_IN_ALL +const char * const * gi_repository_get_search_path (GIRepository *repository, + size_t *n_paths_out); + +GI_AVAILABLE_IN_ALL +const char * const *gi_repository_get_library_path (GIRepository *repository, + size_t *n_paths_out); + +GI_AVAILABLE_IN_ALL +const char * gi_repository_load_typelib (GIRepository *repository, + GITypelib *typelib, + GIRepositoryLoadFlags flags, + GError **error); + +GI_AVAILABLE_IN_ALL +gboolean gi_repository_is_registered (GIRepository *repository, + const char *namespace_, + const char *version); + +GI_AVAILABLE_IN_ALL +GIBaseInfo * gi_repository_find_by_name (GIRepository *repository, + const char *namespace_, + const char *name); + +GI_AVAILABLE_IN_ALL +char ** gi_repository_enumerate_versions (GIRepository *repository, + const char *namespace_, + size_t *n_versions_out); + +GI_AVAILABLE_IN_ALL +GITypelib * gi_repository_require (GIRepository *repository, + const char *namespace_, + const char *version, + GIRepositoryLoadFlags flags, + GError **error); + +GI_AVAILABLE_IN_ALL +GITypelib * gi_repository_require_private (GIRepository *repository, + const char *typelib_dir, + const char *namespace_, + const char *version, + GIRepositoryLoadFlags flags, + GError **error); + +GI_AVAILABLE_IN_ALL +char ** gi_repository_get_immediate_dependencies (GIRepository *repository, + const char *namespace_, + size_t *n_dependencies_out); + +GI_AVAILABLE_IN_ALL +char ** gi_repository_get_dependencies (GIRepository *repository, + const char *namespace_, + size_t *n_dependencies_out); + +GI_AVAILABLE_IN_ALL +char ** gi_repository_get_loaded_namespaces (GIRepository *repository, + size_t *n_namespaces_out); + +GI_AVAILABLE_IN_ALL +GIBaseInfo * gi_repository_find_by_gtype (GIRepository *repository, + GType gtype); + +GI_AVAILABLE_IN_ALL +void gi_repository_get_object_gtype_interfaces (GIRepository *repository, + GType gtype, + size_t *n_interfaces_out, + GIInterfaceInfo ***interfaces_out); + +GI_AVAILABLE_IN_ALL +unsigned int gi_repository_get_n_infos (GIRepository *repository, + const char *namespace_); + +GI_AVAILABLE_IN_ALL +GIBaseInfo * gi_repository_get_info (GIRepository *repository, + const char *namespace_, + unsigned int idx); + +GI_AVAILABLE_IN_ALL +GIEnumInfo * gi_repository_find_by_error_domain (GIRepository *repository, + GQuark domain); + +GI_AVAILABLE_IN_ALL +const char * gi_repository_get_typelib_path (GIRepository *repository, + const char *namespace_); +GI_AVAILABLE_IN_ALL +const char * const *gi_repository_get_shared_libraries (GIRepository *repository, + const char *namespace_, + size_t *out_n_elements); +GI_AVAILABLE_IN_ALL +const char * gi_repository_get_c_prefix (GIRepository *repository, + const char *namespace_); +GI_AVAILABLE_IN_ALL +const char * gi_repository_get_version (GIRepository *repository, + const char *namespace_); + + +GI_AVAILABLE_IN_ALL +GOptionGroup * gi_repository_get_option_group (void); + + +GI_AVAILABLE_IN_ALL +gboolean gi_repository_dump (const char *input_filename, + const char *output_filename, + GError **error); + +/** + * GIRepositoryError: + * @GI_REPOSITORY_ERROR_TYPELIB_NOT_FOUND: the typelib could not be found. + * @GI_REPOSITORY_ERROR_NAMESPACE_MISMATCH: the namespace does not match the + * requested namespace. + * @GI_REPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT: the version of the + * typelib does not match the requested version. + * @GI_REPOSITORY_ERROR_LIBRARY_NOT_FOUND: the library used by the typelib + * could not be found. + * + * An error code used with `GI_REPOSITORY_ERROR` in a [type@GLib.Error] + * returned from a [class@GIRepository.Repository] routine. + * + * Since: 2.80 + */ +typedef enum +{ + GI_REPOSITORY_ERROR_TYPELIB_NOT_FOUND, + GI_REPOSITORY_ERROR_NAMESPACE_MISMATCH, + GI_REPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT, + GI_REPOSITORY_ERROR_LIBRARY_NOT_FOUND +} GIRepositoryError; + +/** + * GI_REPOSITORY_ERROR: + * + * Error domain for [class@GIRepository.Repository]. + * + * Errors in this domain will be from the [enum@GIRepository.Error] enumeration. + * See [type@GLib.Error] for more information on error domains. + * + * Since: 2.80 + */ +#define GI_REPOSITORY_ERROR (gi_repository_error_quark ()) + +GI_AVAILABLE_IN_ALL +GQuark gi_repository_error_quark (void); + + +/* Global utility functions */ + +GI_AVAILABLE_IN_ALL +void gi_cclosure_marshal_generic (GClosure *closure, + GValue *return_gvalue, + unsigned int n_param_values, + const GValue *param_values, + void *invocation_hint, + void *marshal_data); + +#include + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/girffi.h b/illumos-x86_64/usr/include/glib-2.0/girepository/girffi.h new file mode 100644 index 00000000..5d792c92 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/girffi.h @@ -0,0 +1,129 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Helper functions for ffi integration + * + * Copyright (C) 2008 Red Hat, Inc + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include "girepository.h" + +G_BEGIN_DECLS + +/** + * GIFFIClosureCallback: + * @cif: the `ffi_cif` passed to + * [method@GIRepository.CallableInfo.create_closure] + * @ret: (out caller-allocates): a pointer to the memory used for the function’s + * return value + * @args: a vector of pointers to memory holding the arguments to the function + * @user_data: the user data passed to + * [method@GIRepository.CallableInfo.create_closure] + * + * The function which will be called when a closure created with + * [method@GIRepository.CallableInfo.create_closure] is invoked. + * + * The value of @ret is undefined if the function returns `void`. + * + * Since: 2.80 + */ +typedef void (*GIFFIClosureCallback) (ffi_cif *cif, + void *ret, + void **args, + void *user_data); + +/** + * GIFunctionInvoker: + * @cif: the cif + * @native_address: the native address + * + * Structure containing the data necessary to invoke a callable function. + * + * Since: 2.80 + */ +typedef struct { + ffi_cif cif; + void *native_address; + /*< private >*/ + void *padding[3]; +} GIFunctionInvoker; + +/** + * GIFFIReturnValue: + * + * The type of a return value from a callable invocation closure. + * + * Since: 2.80 + */ +typedef GIArgument GIFFIReturnValue; + +GI_AVAILABLE_IN_ALL +ffi_type * gi_type_tag_get_ffi_type (GITypeTag type_tag, gboolean is_pointer); + +GI_AVAILABLE_IN_ALL +ffi_type * gi_type_info_get_ffi_type (GITypeInfo *info); + +GI_AVAILABLE_IN_ALL +void gi_type_info_extract_ffi_return_value (GITypeInfo *return_info, + GIFFIReturnValue *ffi_value, + GIArgument *arg); + +GI_AVAILABLE_IN_ALL +void gi_type_tag_extract_ffi_return_value (GITypeTag return_tag, + GType interface_type, + GIFFIReturnValue *ffi_value, + GIArgument *arg); + +GI_AVAILABLE_IN_ALL +gboolean gi_function_info_prep_invoker (GIFunctionInfo *info, + GIFunctionInvoker *invoker, + GError **error); + +GI_AVAILABLE_IN_ALL +gboolean gi_function_invoker_new_for_address (void *addr, + GICallableInfo *info, + GIFunctionInvoker *invoker, + GError **error); + +GI_AVAILABLE_IN_ALL +void gi_function_invoker_clear (GIFunctionInvoker *invoker); + +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (GIFunctionInvoker, gi_function_invoker_clear) + +GI_AVAILABLE_IN_ALL +ffi_closure * gi_callable_info_create_closure (GICallableInfo *callable_info, + ffi_cif *cif, + GIFFIClosureCallback callback, + void *user_data); + +GI_AVAILABLE_IN_ALL +void ** gi_callable_info_get_closure_native_address (GICallableInfo *callable_info, + ffi_closure *closure); + +GI_AVAILABLE_IN_ALL +void gi_callable_info_destroy_closure (GICallableInfo *callable_info, + ffi_closure *closure); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gisignalinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gisignalinfo.h new file mode 100644 index 00000000..ebac506c --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gisignalinfo.h @@ -0,0 +1,72 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Signal + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define GI_TYPE_SIGNAL_INFO (gi_signal_info_get_type ()) + +/** + * GI_SIGNAL_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.SignalInfo] or derived pointer into a + * `(GISignalInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_SIGNAL_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_SIGNAL_INFO, GISignalInfo)) + +/** + * GI_IS_SIGNAL_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.SignalInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_SIGNAL_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_SIGNAL_INFO)) + + +GI_AVAILABLE_IN_ALL +GSignalFlags gi_signal_info_get_flags (GISignalInfo *info); + +GI_AVAILABLE_IN_ALL +GIVFuncInfo * gi_signal_info_get_class_closure (GISignalInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_signal_info_true_stops_emit (GISignalInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gistructinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gistructinfo.h new file mode 100644 index 00000000..c9e82cea --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gistructinfo.h @@ -0,0 +1,102 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Struct + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_STRUCT_INFO (gi_struct_info_get_type ()) + +/** + * GI_STRUCT_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.StructInfo] or derived pointer into a + * `(GIStructInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_STRUCT_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_STRUCT_INFO, GIStructInfo)) + +/** + * GI_IS_STRUCT_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.StructInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_STRUCT_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_STRUCT_INFO)) + + +GI_AVAILABLE_IN_ALL +unsigned int gi_struct_info_get_n_fields (GIStructInfo *info); + +GI_AVAILABLE_IN_ALL +GIFieldInfo * gi_struct_info_get_field (GIStructInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GIFieldInfo * gi_struct_info_find_field (GIStructInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +unsigned int gi_struct_info_get_n_methods (GIStructInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_struct_info_get_method (GIStructInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_struct_info_find_method (GIStructInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +size_t gi_struct_info_get_size (GIStructInfo *info); + +GI_AVAILABLE_IN_ALL +size_t gi_struct_info_get_alignment (GIStructInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_struct_info_is_gtype_struct (GIStructInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_struct_info_is_foreign (GIStructInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_struct_info_get_copy_function_name (GIStructInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_struct_info_get_free_function_name (GIStructInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gitypeinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gitypeinfo.h new file mode 100644 index 00000000..73f0ce42 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gitypeinfo.h @@ -0,0 +1,144 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Type + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_TYPE_INFO (gi_type_info_get_type ()) + +/** + * GI_TYPE_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.TypeInfo] or derived pointer into a + * `(GITypeInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_TYPE_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_TYPE_INFO, GITypeInfo)) + +/** + * GI_IS_TYPE_INFO: + * @info: an info structure + * + * Checks if @info is a [alias@GIRepository.TypeInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_TYPE_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_TYPE_INFO)) + +/** + * GI_TYPE_TAG_IS_BASIC: + * @tag: a type tag + * + * Checks if @tag is a basic type. + * + * Since: 2.80 + */ +#define GI_TYPE_TAG_IS_BASIC(tag) ((tag) < GI_TYPE_TAG_ARRAY || (tag) == GI_TYPE_TAG_UNICHAR) + +/** + * GI_TYPE_TAG_IS_NUMERIC: + * @tag: a type tag + * + * Checks if @tag is a numeric type. That is, integer or floating point. + * + * Since: 2.80 + */ +#define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE) + +/** + * GI_TYPE_TAG_IS_CONTAINER: + * @tag: a type tag + * + * Checks if @tag is a container type. That is, a type which may have a nonnull + * return from [method@GIRepository.TypeInfo.get_param_type]. + * + * Since: 2.80 + */ + #define GI_TYPE_TAG_IS_CONTAINER(tag) ((tag) == GI_TYPE_TAG_ARRAY || \ + ((tag) >= GI_TYPE_TAG_GLIST && (tag) <= GI_TYPE_TAG_GHASH)) + +GI_AVAILABLE_IN_ALL +const char * gi_type_tag_to_string (GITypeTag type); + +GI_AVAILABLE_IN_ALL +gboolean gi_type_info_is_pointer (GITypeInfo *info); + +GI_AVAILABLE_IN_ALL +GITypeTag gi_type_info_get_tag (GITypeInfo *info); + +GI_AVAILABLE_IN_ALL +GITypeInfo * gi_type_info_get_param_type (GITypeInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +GIBaseInfo * gi_type_info_get_interface (GITypeInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_type_info_get_array_length_index (GITypeInfo *info, + unsigned int *out_length_index); + +GI_AVAILABLE_IN_ALL +gboolean gi_type_info_get_array_fixed_size (GITypeInfo *info, + size_t *out_size); + +GI_AVAILABLE_IN_ALL +gboolean gi_type_info_is_zero_terminated (GITypeInfo *info); + +GI_AVAILABLE_IN_ALL +GIArrayType gi_type_info_get_array_type (GITypeInfo *info); + +GI_AVAILABLE_IN_ALL +GITypeTag gi_type_info_get_storage_type (GITypeInfo *info); + +GI_AVAILABLE_IN_ALL +void gi_type_info_argument_from_hash_pointer (GITypeInfo *info, + void *hash_pointer, + GIArgument *arg); + +GI_AVAILABLE_IN_ALL +void * gi_type_info_hash_pointer_from_argument (GITypeInfo *info, + GIArgument *arg); + +GI_AVAILABLE_IN_ALL +void gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type, + void *hash_pointer, + GIArgument *arg); + +GI_AVAILABLE_IN_ALL +void * gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type, + GIArgument *arg); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gitypelib.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gitypelib.h new file mode 100644 index 00000000..add5804d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gitypelib.h @@ -0,0 +1,61 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Public typelib API + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#include + +G_BEGIN_DECLS + +typedef struct _GITypelib GITypelib; + +#define GI_TYPE_TYPELIB (gi_typelib_get_type ()) +GI_AVAILABLE_IN_ALL +GType gi_typelib_get_type (void) G_GNUC_CONST; + +GI_AVAILABLE_IN_ALL +GITypelib * gi_typelib_new_from_bytes (GBytes *bytes, + GError **error); + +GI_AVAILABLE_IN_ALL +GITypelib * gi_typelib_ref (GITypelib *typelib); +GI_AVAILABLE_IN_ALL +void gi_typelib_unref (GITypelib *typelib); + +GI_AVAILABLE_IN_ALL +gboolean gi_typelib_symbol (GITypelib *typelib, + const char *symbol_name, + void **symbol); + +GI_AVAILABLE_IN_ALL +const char * gi_typelib_get_namespace (GITypelib *typelib); + + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/gitypes.h b/illumos-x86_64/usr/include/glib-2.0/girepository/gitypes.h new file mode 100644 index 00000000..a76b9793 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/gitypes.h @@ -0,0 +1,422 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: types + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#include +#include + +#include "gi-visibility.h" + +G_BEGIN_DECLS + +/* Documented in gibaseinfo.c */ +typedef struct _GIBaseInfo GIBaseInfo; +typedef struct _GIBaseInfoClass GIBaseInfoClass; + +typedef struct +{ + /*< private >*/ + GTypeInstance parent_instance; + + int dummy0; + void *dummy1[3]; + uint32_t dummy2[2]; + void *dummy3[6]; +} GIBaseInfoStack; + +/* Documented in gicallableinfo.c */ +typedef struct _GICallableInfo GICallableInfo; +GI_AVAILABLE_IN_ALL GType gi_callable_info_get_type (void); + +/* Documented in gifunctioninfo.c */ +typedef struct _GIFunctionInfo GIFunctionInfo; +GI_AVAILABLE_IN_ALL GType gi_function_info_get_type (void); + +/* Documented in gicallbackinfo.c */ +typedef struct _GICallbackInfo GICallbackInfo; +GI_AVAILABLE_IN_ALL GType gi_callback_info_get_type (void); + +/* Documented in giregisteredtypeinfo.c */ +typedef struct _GIRegisteredTypeInfo GIRegisteredTypeInfo; +GI_AVAILABLE_IN_ALL GType gi_registered_type_info_get_type (void); + +/* Documented in gistructinfo.c */ +typedef struct _GIStructInfo GIStructInfo; +GI_AVAILABLE_IN_ALL GType gi_struct_info_get_type (void); + +/* Documented in giunioninfo.c */ +typedef struct _GIUnionInfo GIUnionInfo; +GI_AVAILABLE_IN_ALL GType gi_union_info_get_type (void); + +/* Documented in gienuminfo.c */ +typedef struct _GIEnumInfo GIEnumInfo; +GI_AVAILABLE_IN_ALL GType gi_enum_info_get_type (void); + +/* Documented in giflagsinfo.c */ +typedef struct _GIFlagsInfo GIFlagsInfo; +GI_AVAILABLE_IN_ALL GType gi_flags_info_get_type (void); + +/* Documented in giobjectinfo.c */ +typedef struct _GIObjectInfo GIObjectInfo; +GI_AVAILABLE_IN_ALL GType gi_object_info_get_type (void); + +/* Documented in giinterfaceinfo.c */ +typedef struct _GIInterfaceInfo GIInterfaceInfo; +GI_AVAILABLE_IN_ALL GType gi_interface_info_get_type (void); + +/* Documented in giconstantinfo.c */ +typedef struct _GIConstantInfo GIConstantInfo; +GI_AVAILABLE_IN_ALL GType gi_constant_info_get_type (void); + +/* Documented in givalueinfo.c */ +typedef struct _GIValueInfo GIValueInfo; +GI_AVAILABLE_IN_ALL GType gi_value_info_get_type (void); + +/* Documented in gisignalinfo.c */ +typedef struct _GISignalInfo GISignalInfo; +GI_AVAILABLE_IN_ALL GType gi_signal_info_get_type (void); + +/* Documented in givfuncinfo.c */ +typedef struct _GIVFuncInfo GIVFuncInfo; +GI_AVAILABLE_IN_ALL GType gi_vfunc_info_get_type (void); + +/* Documented in gipropertyinfo.c */ +typedef struct _GIPropertyInfo GIPropertyInfo; +GI_AVAILABLE_IN_ALL GType gi_property_info_get_type (void); + +/* Documented in gifieldinfo.c */ +typedef struct _GIFieldInfo GIFieldInfo; +GI_AVAILABLE_IN_ALL GType gi_field_info_get_type (void); + +/* Documented in giarginfo.c */ +typedef struct +{ + /*< private >*/ + GIBaseInfoStack parent; + + void *padding[6]; +} GIArgInfo; +GI_AVAILABLE_IN_ALL GType gi_arg_info_get_type (void); + +/* Documented in gitypeinfo.c */ +typedef struct +{ + /*< private >*/ + GIBaseInfoStack parent; + + void *padding[6]; +} GITypeInfo; +GI_AVAILABLE_IN_ALL GType gi_type_info_get_type (void); + +/* Documented in giunresolvedinfo.c */ +typedef struct _GIUnresolvedInfo GIUnresolvedInfo; +GI_AVAILABLE_IN_ALL GType gi_unresolved_info_get_type (void); + +union _GIArgument +{ + gboolean v_boolean; + int8_t v_int8; + uint8_t v_uint8; + int16_t v_int16; + uint16_t v_uint16; + int32_t v_int32; + uint32_t v_uint32; + int64_t v_int64; + uint64_t v_uint64; + float v_float; + double v_double; + short v_short; + unsigned short v_ushort; + int v_int; + unsigned int v_uint; + long v_long; + unsigned long v_ulong; + gssize v_ssize; + size_t v_size; + char *v_string; + void *v_pointer; +}; + +/** + * GIArgument: + * @v_boolean: boolean value + * @v_int8: 8-bit signed integer value + * @v_uint8: 8-bit unsigned integer value + * @v_int16: 16-bit signed integer value + * @v_uint16: 16-bit unsigned integer value + * @v_int32: 32-bit signed integer value + * @v_uint32: 32-bit unsigned integer value + * @v_int64: 64-bit signed integer value + * @v_uint64: 64-bit unsigned integer value + * @v_float: single float value + * @v_double: double float value + * @v_short: signed short integer value + * @v_ushort: unsigned short integer value + * @v_int: signed integer value + * @v_uint: unsigned integer value + * @v_long: signed long integer value + * @v_ulong: unsigned long integer value + * @v_ssize: sized `size_t` value + * @v_size: unsigned `size_t` value + * @v_string: nul-terminated string value + * @v_pointer: arbitrary pointer value + * + * Stores an argument of varying type. + * + * Since: 2.80 + */ +typedef union _GIArgument GIArgument; + +/** + * GITransfer: + * @GI_TRANSFER_NOTHING: Transfer nothing from the callee (function or the type + * instance the property belongs to) to the caller. The callee retains the + * ownership of the transfer and the caller doesn’t need to do anything to + * free up the resources of this transfer. + * @GI_TRANSFER_CONTAINER: Transfer the container (list, array, hash table) from + * the callee to the caller. The callee retains the ownership of the + * individual items in the container and the caller has to free up the + * container resources ([func@GLib.List.free], + * [func@GLib.HashTable.destroy], etc) of this transfer. + * @GI_TRANSFER_EVERYTHING: Transfer everything, e.g. the container and its + * contents from the callee to the caller. This is the case when the callee + * creates a copy of all the data it returns. The caller is responsible for + * cleaning up the container and item resources of this transfer. + * + * `GITransfer` specifies who’s responsible for freeing the resources after an + * ownership transfer is complete. + * + * The transfer is the exchange of data between two parts, from the callee to + * the caller. + * + * The callee is either a function/method/signal or an object/interface where a + * property is defined. The caller is the side accessing a property or calling a + * function. + * + * In the case of a containing type such as a list, an array or a hash table the + * container itself is specified differently from the items within the + * container. Each container is freed differently, check the documentation for + * the types themselves for information on how to free them. + * + * Since: 2.80 + */ +typedef enum { + GI_TRANSFER_NOTHING, + GI_TRANSFER_CONTAINER, + GI_TRANSFER_EVERYTHING +} GITransfer; + +/** + * GIDirection: + * @GI_DIRECTION_IN: ‘in’ argument. + * @GI_DIRECTION_OUT: ‘out’ argument. + * @GI_DIRECTION_INOUT: ‘in and out’ argument. + * + * The direction of a [class@GIRepository.ArgInfo]. + * + * Since: 2.80 + */ +typedef enum { + GI_DIRECTION_IN, + GI_DIRECTION_OUT, + GI_DIRECTION_INOUT +} GIDirection; + +/** + * GIScopeType: + * @GI_SCOPE_TYPE_INVALID: The argument is not of callback type. + * @GI_SCOPE_TYPE_CALL: The callback and associated `user_data` is only + * used during the call to this function. + * @GI_SCOPE_TYPE_ASYNC: The callback and associated `user_data` is + * only used until the callback is invoked, and the callback. + * is invoked always exactly once. + * @GI_SCOPE_TYPE_NOTIFIED: The callback and associated + * `user_data` is used until the caller is notified via the + * [type@GLib.DestroyNotify]. + * @GI_SCOPE_TYPE_FOREVER: The callback and associated `user_data` is + * used until the process terminates + * + * Scope type of a [class@GIRepository.ArgInfo] representing callback, + * determines how the callback is invoked and is used to decided when the invoke + * structs can be freed. + * + * Since: 2.80 + */ +typedef enum { + GI_SCOPE_TYPE_INVALID, + GI_SCOPE_TYPE_CALL, + GI_SCOPE_TYPE_ASYNC, + GI_SCOPE_TYPE_NOTIFIED, + GI_SCOPE_TYPE_FOREVER +} GIScopeType; + +/** + * GITypeTag: + * @GI_TYPE_TAG_VOID: void + * @GI_TYPE_TAG_BOOLEAN: boolean + * @GI_TYPE_TAG_INT8: 8-bit signed integer + * @GI_TYPE_TAG_UINT8: 8-bit unsigned integer + * @GI_TYPE_TAG_INT16: 16-bit signed integer + * @GI_TYPE_TAG_UINT16: 16-bit unsigned integer + * @GI_TYPE_TAG_INT32: 32-bit signed integer + * @GI_TYPE_TAG_UINT32: 32-bit unsigned integer + * @GI_TYPE_TAG_INT64: 64-bit signed integer + * @GI_TYPE_TAG_UINT64: 64-bit unsigned integer + * @GI_TYPE_TAG_FLOAT: float + * @GI_TYPE_TAG_DOUBLE: double floating point + * @GI_TYPE_TAG_GTYPE: a [type@GObject.Type] + * @GI_TYPE_TAG_UTF8: a UTF-8 encoded string + * @GI_TYPE_TAG_FILENAME: a filename, encoded in the same encoding + * as the native filesystem is using. + * @GI_TYPE_TAG_ARRAY: an array + * @GI_TYPE_TAG_INTERFACE: an extended interface object + * @GI_TYPE_TAG_GLIST: a [type@GLib.List] + * @GI_TYPE_TAG_GSLIST: a [type@GLib.SList] + * @GI_TYPE_TAG_GHASH: a [type@GLib.HashTable] + * @GI_TYPE_TAG_ERROR: a [type@GLib.Error] + * @GI_TYPE_TAG_UNICHAR: Unicode character + * + * The type tag of a [class@GIRepository.TypeInfo]. + * + * Since: 2.80 + */ +typedef enum { + /* Basic types */ + GI_TYPE_TAG_VOID = 0, + GI_TYPE_TAG_BOOLEAN = 1, + GI_TYPE_TAG_INT8 = 2, /* Start of GI_TYPE_TAG_IS_NUMERIC types */ + GI_TYPE_TAG_UINT8 = 3, + GI_TYPE_TAG_INT16 = 4, + GI_TYPE_TAG_UINT16 = 5, + GI_TYPE_TAG_INT32 = 6, + GI_TYPE_TAG_UINT32 = 7, + GI_TYPE_TAG_INT64 = 8, + GI_TYPE_TAG_UINT64 = 9, + GI_TYPE_TAG_FLOAT = 10, + GI_TYPE_TAG_DOUBLE = 11, /* End of numeric types */ + GI_TYPE_TAG_GTYPE = 12, + GI_TYPE_TAG_UTF8 = 13, + GI_TYPE_TAG_FILENAME = 14, + /* Non-basic types; compare with GI_TYPE_TAG_IS_BASIC */ + GI_TYPE_TAG_ARRAY = 15, /* container (see GI_TYPE_TAG_IS_CONTAINER) */ + GI_TYPE_TAG_INTERFACE = 16, + GI_TYPE_TAG_GLIST = 17, /* container */ + GI_TYPE_TAG_GSLIST = 18, /* container */ + GI_TYPE_TAG_GHASH = 19, /* container */ + GI_TYPE_TAG_ERROR = 20, + /* Another basic type */ + GI_TYPE_TAG_UNICHAR = 21 + /* Note - there is currently only room for 32 tags */ +} GITypeTag; + +/** + * GI_TYPE_TAG_N_TYPES: + * + * Number of entries in [enum@GIRepository.TypeTag]. + * + * Since: 2.80 + */ +#define GI_TYPE_TAG_N_TYPES (GI_TYPE_TAG_UNICHAR+1) + +/** + * GIArrayType: + * @GI_ARRAY_TYPE_C: a C array, `char[]` for instance + * @GI_ARRAY_TYPE_ARRAY: a [type@GLib.Array] array + * @GI_ARRAY_TYPE_PTR_ARRAY: a [type@GLib.PtrArray] array + * @GI_ARRAY_TYPE_BYTE_ARRAY: a [type@GLib.ByteArray] array + * + * The type of array in a [class@GIRepository.TypeInfo]. + * + * Since: 2.80 + */ +typedef enum { + GI_ARRAY_TYPE_C, + GI_ARRAY_TYPE_ARRAY, + GI_ARRAY_TYPE_PTR_ARRAY, + GI_ARRAY_TYPE_BYTE_ARRAY +} GIArrayType; + +/** + * GIFieldInfoFlags: + * @GI_FIELD_IS_READABLE: field is readable. + * @GI_FIELD_IS_WRITABLE: field is writable. + * + * Flags for a [class@GIRepository.FieldInfo]. + * + * Since: 2.80 + */ + +typedef enum +{ + GI_FIELD_IS_READABLE = 1 << 0, + GI_FIELD_IS_WRITABLE = 1 << 1 +} GIFieldInfoFlags; + +/** + * GIVFuncInfoFlags: + * @GI_VFUNC_MUST_CHAIN_UP: chains up to the parent type + * @GI_VFUNC_MUST_OVERRIDE: overrides + * @GI_VFUNC_MUST_NOT_OVERRIDE: does not override + * + * Flags of a [class@GIRepository.VFuncInfo] struct. + * + * Since: 2.80 + */ +typedef enum +{ + GI_VFUNC_MUST_CHAIN_UP = 1 << 0, + GI_VFUNC_MUST_OVERRIDE = 1 << 1, + GI_VFUNC_MUST_NOT_OVERRIDE = 1 << 2, +} GIVFuncInfoFlags; + +/** + * GIFunctionInfoFlags: + * @GI_FUNCTION_IS_METHOD: is a method. + * @GI_FUNCTION_IS_CONSTRUCTOR: is a constructor. + * @GI_FUNCTION_IS_GETTER: is a getter of a [class@GIRepository.PropertyInfo]. + * @GI_FUNCTION_IS_SETTER: is a setter of a [class@GIRepository.PropertyInfo]. + * @GI_FUNCTION_WRAPS_VFUNC: represents a virtual function. + * + * Flags for a [class@GIRepository.FunctionInfo] struct. + * + * Since: 2.80 + */ +typedef enum +{ + GI_FUNCTION_IS_METHOD = 1 << 0, + GI_FUNCTION_IS_CONSTRUCTOR = 1 << 1, + GI_FUNCTION_IS_GETTER = 1 << 2, + GI_FUNCTION_IS_SETTER = 1 << 3, + GI_FUNCTION_WRAPS_VFUNC = 1 << 4, + GI_FUNCTION_IS_ASYNC = 1 << 5, +} GIFunctionInfoFlags; + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/giunioninfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/giunioninfo.h new file mode 100644 index 00000000..d2273621 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/giunioninfo.h @@ -0,0 +1,105 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Union + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_UNION_INFO (gi_union_info_get_type ()) + +/** + * GI_UNION_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.UnionInfo] or derived pointer into a + * `(GIUnionInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_UNION_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_UNION_INFO, GIUnionInfo)) + +/** + * GI_IS_UNION_INFO: + * @info: an info structure + * + * Checks if @info is a [struct@GIRepository.UnionInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_UNION_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_UNION_INFO)) + +GI_AVAILABLE_IN_ALL +unsigned int gi_union_info_get_n_fields (GIUnionInfo *info); + +GI_AVAILABLE_IN_ALL +GIFieldInfo * gi_union_info_get_field (GIUnionInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +unsigned int gi_union_info_get_n_methods (GIUnionInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_union_info_get_method (GIUnionInfo *info, + unsigned int n); + +GI_AVAILABLE_IN_ALL +gboolean gi_union_info_is_discriminated (GIUnionInfo *info); + +GI_AVAILABLE_IN_ALL +gboolean gi_union_info_get_discriminator_offset (GIUnionInfo *info, + size_t *out_offset); + +GI_AVAILABLE_IN_ALL +GITypeInfo * gi_union_info_get_discriminator_type (GIUnionInfo *info); + +GI_AVAILABLE_IN_ALL +GIConstantInfo * gi_union_info_get_discriminator (GIUnionInfo *info, + size_t n); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, + const char *name); + +GI_AVAILABLE_IN_ALL +size_t gi_union_info_get_size (GIUnionInfo *info); + +GI_AVAILABLE_IN_ALL +size_t gi_union_info_get_alignment (GIUnionInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_union_info_get_copy_function_name (GIUnionInfo *info); + +GI_AVAILABLE_IN_ALL +const char * gi_union_info_get_free_function_name (GIUnionInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/giunresolvedinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/giunresolvedinfo.h new file mode 100644 index 00000000..9eeb7618 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/giunresolvedinfo.h @@ -0,0 +1,60 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable + * + * Copyright 2023 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_UNRESOLVED_INFO (gi_unresolved_info_get_type ()) + +/** + * GI_UNRESOLVED_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.UnresolvedInfo] or derived pointer into a + * `(GIUnresolvedInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_UNRESOLVED_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_UNRESOLVED_INFO, GIUnresolvedInfo)) + +/** + * GI_IS_UNRESOLVED_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.UnresolvedInfo] or derived from it. + * + * Since: 2.80 + */ +#define GI_IS_UNRESOLVED_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_UNRESOLVED_INFO)) + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/givalueinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/givalueinfo.h new file mode 100644 index 00000000..7eb7cce5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/givalueinfo.h @@ -0,0 +1,65 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Enum and Enum values + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_VALUE_INFO (gi_value_info_get_type ()) + +/** + * GI_VALUE_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.ValueInfo] or derived pointer into a + * `(GIValueInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_VALUE_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_VALUE_INFO, GIValueInfo)) + +/** + * GI_IS_VALUE_INFO: + * @info: an info structure + * + * Checks if @info is a [class@GIRepository.ValueInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_VALUE_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_VALUE_INFO)) + + +GI_AVAILABLE_IN_ALL +int64_t gi_value_info_get_value (GIValueInfo *info); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/girepository/givfuncinfo.h b/illumos-x86_64/usr/include/glib-2.0/girepository/givfuncinfo.h new file mode 100644 index 00000000..cbb8abec --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/girepository/givfuncinfo.h @@ -0,0 +1,88 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Virtual Functions + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_TYPE_VFUNC_INFO (gi_vfunc_info_get_type ()) + +/** + * GI_VFUNC_INFO: + * @info: Info object which is subject to casting. + * + * Casts a [type@GIRepository.VFuncInfo] or derived pointer into a + * `(GIVFuncInfo*)` pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + * + * Since: 2.80 + */ +#define GI_VFUNC_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_VFUNC_INFO, GIVFuncInfo)) + +/** + * GI_IS_VFUNC_INFO: + * @info: an info structure + * + * Checks if @info is a [struct@GIRepository.VFuncInfo] (or a derived type). + * + * Since: 2.80 + */ +#define GI_IS_VFUNC_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_VFUNC_INFO)) + +GI_AVAILABLE_IN_ALL +GIVFuncInfoFlags gi_vfunc_info_get_flags (GIVFuncInfo *info); + +GI_AVAILABLE_IN_ALL +size_t gi_vfunc_info_get_offset (GIVFuncInfo *info); + +GI_AVAILABLE_IN_ALL +GISignalInfo * gi_vfunc_info_get_signal (GIVFuncInfo *info); + +GI_AVAILABLE_IN_ALL +GIFunctionInfo * gi_vfunc_info_get_invoker (GIVFuncInfo *info); + +GI_AVAILABLE_IN_ALL +void * gi_vfunc_info_get_address (GIVFuncInfo *info, + GType implementor_gtype, + GError **error); + +GI_AVAILABLE_IN_ALL +gboolean gi_vfunc_info_invoke (GIVFuncInfo *info, + GType implementor, + const GIArgument *in_args, + size_t n_in_args, + GIArgument *out_args, + size_t n_out_args, + GIArgument *return_value, + GError **error); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/glib-object.h b/illumos-x86_64/usr/include/glib-2.0/glib-object.h new file mode 100644 index 00000000..b00392d8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib-object.h @@ -0,0 +1,46 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __GLIB_GOBJECT_H__ +#define __GLIB_GOBJECT_H__ + +#define __GLIB_GOBJECT_H_INSIDE__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#undef __GLIB_GOBJECT_H_INSIDE__ + +#endif /* __GLIB_GOBJECT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib-unix.h b/illumos-x86_64/usr/include/glib-2.0/glib-unix.h new file mode 100644 index 00000000..d4551827 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib-unix.h @@ -0,0 +1,360 @@ +/* glib-unix.h - Unix specific integration + * Copyright (C) 2011 Red Hat, Inc. + * Copyright 2023 Collabora Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_UNIX_H__ +#define __G_UNIX_H__ + +/* We need to include the UNIX headers needed to use the APIs below, + * but we also take this opportunity to include a wide selection of + * other UNIX headers. If one of the headers below is broken on some + * system, work around it here (or better, fix the system or tell + * people to use a better one). + */ +#include +#include +#include +#include +#include + +#include +#include + +#ifndef G_OS_UNIX +#error "This header may only be used on UNIX" +#endif + +G_BEGIN_DECLS + +/** + * G_UNIX_ERROR: + * + * Error domain for API in the g_unix_ namespace. Note that there is no + * exported enumeration mapping %errno. Instead, all functions ensure that + * %errno is relevant. The code for all %G_UNIX_ERROR is always 0, and the + * error message is always generated via g_strerror(). + * + * It is expected that most code will not look at %errno from these APIs. + * Important cases where one would want to differentiate between errors are + * already covered by existing cross-platform GLib API, such as e.g. #GFile + * wrapping `ENOENT`. However, it is provided for completeness, at least. + */ +#define G_UNIX_ERROR (g_unix_error_quark()) + +GLIB_AVAILABLE_IN_2_30 +GQuark g_unix_error_quark (void); + +GLIB_AVAILABLE_IN_2_30 +gboolean g_unix_open_pipe (gint *fds, + gint flags, + GError **error); + +GLIB_AVAILABLE_IN_2_30 +gboolean g_unix_set_fd_nonblocking (gint fd, + gboolean nonblock, + GError **error); + +GLIB_AVAILABLE_IN_2_30 +GSource *g_unix_signal_source_new (gint signum); + +GLIB_AVAILABLE_IN_2_30 +guint g_unix_signal_add_full (gint priority, + gint signum, + GSourceFunc handler, + gpointer user_data, + GDestroyNotify notify); + +GLIB_AVAILABLE_IN_2_30 +guint g_unix_signal_add (gint signum, + GSourceFunc handler, + gpointer user_data); + +/** + * GUnixFDSourceFunc: + * @fd: the fd that triggered the event + * @condition: the IO conditions reported on @fd + * @user_data: user data passed to g_unix_fd_add() + * + * The type of functions to be called when a UNIX fd watch source + * triggers. + * + * Returns: %FALSE if the source should be removed + **/ +typedef gboolean (*GUnixFDSourceFunc) (gint fd, + GIOCondition condition, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_36 +GSource *g_unix_fd_source_new (gint fd, + GIOCondition condition); + +GLIB_AVAILABLE_IN_2_36 +guint g_unix_fd_add_full (gint priority, + gint fd, + GIOCondition condition, + GUnixFDSourceFunc function, + gpointer user_data, + GDestroyNotify notify); + +GLIB_AVAILABLE_IN_2_36 +guint g_unix_fd_add (gint fd, + GIOCondition condition, + GUnixFDSourceFunc function, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_64 +struct passwd *g_unix_get_passwd_entry (const gchar *user_name, + GError **error); + +/** + * GUnixPipe: + * @fds: A pair of file descriptors, each negative if closed or not yet opened. + * The file descriptor with index %G_UNIX_PIPE_END_READ is readable. + * The file descriptor with index %G_UNIX_PIPE_END_WRITE is writable. + * + * A Unix pipe. The advantage of this type over `int[2]` is that it can + * be closed automatically when it goes out of scope, using `g_auto(GUnixPipe)`, + * on compilers that support that feature. + * + * Since: 2.80 + */ +GLIB_AVAILABLE_TYPE_IN_2_80 +typedef struct { + int fds[2]; +} GUnixPipe; + +/** + * GUnixPipeEnd: + * @G_UNIX_PIPE_END_READ: The readable file descriptor 0 + * @G_UNIX_PIPE_END_WRITE: The writable file descriptor 1 + * + * Mnemonic constants for the ends of a Unix pipe. + * + * Since: 2.80 + */ +GLIB_AVAILABLE_TYPE_IN_2_80 +typedef enum +{ + G_UNIX_PIPE_END_READ = 0, + G_UNIX_PIPE_END_WRITE = 1 +} GUnixPipeEnd; + +/** + * G_UNIX_PIPE_INIT: + * + * Initializer for a #GUnixPipe that has not yet been opened. + * Both of its file descriptors are initialized to `-1` (invalid), + * the same as if they had been closed. + * + * Since: 2.80 + */ +#define G_UNIX_PIPE_INIT { { -1, -1 } } GLIB_AVAILABLE_MACRO_IN_2_80 + +/* Suppress "Not available before" warnings when declaring the + * implementations */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +/** + * g_unix_pipe_open: + * @self: A pair of file descriptors + * @flags: Flags to pass to g_unix_open_pipe(), typically `O_CLOEXEC` + * @error: Used to report an error on failure + * + * Open a pipe. This is the same as g_unix_open_pipe(), but uses the + * #GUnixPipe data structure. + * + * Returns: %TRUE on success + * + * Since: 2.80 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline gboolean g_unix_pipe_open (GUnixPipe *self, + int flags, + GError **error); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline gboolean +g_unix_pipe_open (GUnixPipe *self, + int flags, + GError **error) +{ + return g_unix_open_pipe (self->fds, flags, error); +} + +/** + * g_unix_pipe_get: + * @self: A pair of file descriptors + * @end: One of the ends of the pipe + * + * Return one of the ends of the pipe. It remains owned by @self. + * + * This function is async-signal safe (see [`signal(7)`](man:signal(7)) and + * [`signal-safety(7)`](man:signal-safety(7))), making it safe to call from a + * signal handler or a #GSpawnChildSetupFunc. + * + * This function preserves the value of `errno`. + * + * Returns: a non-negative file descriptor owned by @self, which must not + * be closed by the caller, or a negative number if the corresponding + * end of the pipe was already closed or stolen + * + * Since: 2.80 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline int g_unix_pipe_get (GUnixPipe *self, + GUnixPipeEnd end); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline int +g_unix_pipe_get (GUnixPipe *self, + GUnixPipeEnd end) +{ + return self->fds[end]; +} + +/** + * g_unix_pipe_steal: + * @self: A pair of file descriptors + * @end: One of the ends of the pipe + * + * Return one of the ends of the pipe. It becomes owned by the caller, + * and the file descriptor in the data structure is set to `-1`, + * similar to g_steal_fd(). + * + * This function is async-signal safe (see [`signal(7)`](man:signal(7)) and + * [`signal-safety(7)`](man:signal-safety(7))), making it safe to call from a + * signal handler or a #GSpawnChildSetupFunc. + * + * This function preserves the value of `errno`. + * + * Returns: a non-negative file descriptor, which becomes owned by the + * caller and must be closed by the caller if required, or a negative + * number if the corresponding end of the pipe was already closed or stolen + * + * Since: 2.80 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline int g_unix_pipe_steal (GUnixPipe *self, + GUnixPipeEnd end); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline int +g_unix_pipe_steal (GUnixPipe *self, + GUnixPipeEnd end) +{ + return g_steal_fd (&self->fds[end]); +} + +/** + * g_unix_pipe_close: + * @self: A pair of file descriptors + * @end: One of the ends of the pipe + * @error: Optionally used to report an error on failure + * + * Close one of the ends of the pipe and set the relevant member of @fds + * to `-1` before returning, equivalent to g_clear_fd(). + * + * Like g_close(), if closing the file descriptor fails, the error is + * stored in both %errno and @error. If this function succeeds, + * %errno is undefined. + * + * This function is async-signal safe if @error is %NULL and the relevant + * member of @fds is either negative or a valid open file descriptor. + * This makes it safe to call from a signal handler or a #GSpawnChildSetupFunc + * under those conditions. + * See [`signal(7)`](man:signal(7)) and + * [`signal-safety(7)`](man:signal-safety(7)) for more details. + * + * To close both file descriptors and ignore any errors, use + * g_unix_pipe_clear() instead. + * + * Returns: %TRUE on success + * + * Since: 2.80 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline gboolean g_unix_pipe_close (GUnixPipe *self, + GUnixPipeEnd end, + GError **error); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline gboolean +g_unix_pipe_close (GUnixPipe *self, + GUnixPipeEnd end, + GError **error) +{ + return g_clear_fd (&self->fds[end], error); +} + +/** + * g_unix_pipe_clear: + * @self: a #GUnixPipe + * + * Close both ends of the pipe, unless they have already been closed or + * stolen. Any errors are ignored: use g_unix_pipe_close() or g_clear_fd() + * if error-handling is required. + * + * This function is async-signal safe if @error is %NULL and each member + * of @fds are either negative or a valid open file descriptor. + * As a result, it is safe to call this function or use `g_auto(GUnixPipe)` + * (on compilers that support it) in a signal handler or a + * #GSpawnChildSetupFunc, as long as those conditions are ensured to be true. + * See [`signal(7)`](man:signal(7)) and + * [`signal-safety(7)`](man:signal-safety(7)) for more details. + * + * This function preserves the value of `errno`. + * + * Since: 2.80 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline void g_unix_pipe_clear (GUnixPipe *self); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +static inline void +g_unix_pipe_clear (GUnixPipe *self) +{ + /* Don't overwrite thread-local errno if closing the fd fails */ + int errsv = errno; + + if (!g_unix_pipe_close (self, G_UNIX_PIPE_END_READ, NULL)) + { + /* ignore */ + } + + if (!g_unix_pipe_close (self, G_UNIX_PIPE_END_WRITE, NULL)) + { + /* ignore */ + } + + errno = errsv; +} + +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (GUnixPipe, g_unix_pipe_clear) + +GLIB_AVAILABLE_IN_2_80 +int g_closefrom (int lowfd); + +GLIB_AVAILABLE_IN_2_80 +int g_fdwalk_set_cloexec (int lowfd); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_UNIX_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib.h b/illumos-x86_64/usr/include/glib-2.0/glib.h new file mode 100644 index 00000000..40e50199 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib.h @@ -0,0 +1,122 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_LIB_H__ +#define __G_LIB_H__ + +#define __GLIB_H_INSIDE__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef G_PLATFORM_WIN32 +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include + +#undef __GLIB_H_INSIDE__ + +#endif /* __G_LIB_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gallocator.h b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gallocator.h new file mode 100644 index 00000000..005e92b6 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gallocator.h @@ -0,0 +1,88 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_ALLOCATOR_H__ +#define __G_ALLOCATOR_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GAllocator GAllocator; +typedef struct _GMemChunk GMemChunk; + +#define G_ALLOC_ONLY 1 +#define G_ALLOC_AND_FREE 2 +#define G_ALLOCATOR_LIST 1 +#define G_ALLOCATOR_SLIST 2 +#define G_ALLOCATOR_NODE 3 + +#define g_chunk_new(type, chunk) ((type *) g_mem_chunk_alloc (chunk)) +#define g_chunk_new0(type, chunk) ((type *) g_mem_chunk_alloc0 (chunk)) +#define g_chunk_free(mem, mem_chunk) (g_mem_chunk_free (mem_chunk, mem)) +#define g_mem_chunk_create(type, x, y) (g_mem_chunk_new (NULL, sizeof (type), 0, 0)) + + +GLIB_DEPRECATED +GMemChunk * g_mem_chunk_new (const gchar *name, + gint atom_size, + gsize area_size, + gint type); +GLIB_DEPRECATED +void g_mem_chunk_destroy (GMemChunk *mem_chunk); +GLIB_DEPRECATED +gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk); +GLIB_DEPRECATED +gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk); +GLIB_DEPRECATED +void g_mem_chunk_free (GMemChunk *mem_chunk, + gpointer mem); +GLIB_DEPRECATED +void g_mem_chunk_clean (GMemChunk *mem_chunk); +GLIB_DEPRECATED +void g_mem_chunk_reset (GMemChunk *mem_chunk); +GLIB_DEPRECATED +void g_mem_chunk_print (GMemChunk *mem_chunk); +GLIB_DEPRECATED +void g_mem_chunk_info (void); +GLIB_DEPRECATED +void g_blow_chunks (void); + + +GLIB_DEPRECATED +GAllocator * g_allocator_new (const gchar *name, + guint n_preallocs); +GLIB_DEPRECATED +void g_allocator_free (GAllocator *allocator); +GLIB_DEPRECATED +void g_list_push_allocator (GAllocator *allocator); +GLIB_DEPRECATED +void g_list_pop_allocator (void); +GLIB_DEPRECATED +void g_slist_push_allocator (GAllocator *allocator); +GLIB_DEPRECATED +void g_slist_pop_allocator (void); +GLIB_DEPRECATED +void g_node_push_allocator (GAllocator *allocator); +GLIB_DEPRECATED +void g_node_pop_allocator (void); + +G_END_DECLS + +#endif /* __G_ALLOCATOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gcache.h b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gcache.h new file mode 100644 index 00000000..201f7cf5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gcache.h @@ -0,0 +1,77 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_CACHE_H__ +#define __G_CACHE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GCache GCache GLIB_DEPRECATED_TYPE_IN_2_26_FOR(GHashTable); + +typedef gpointer (*GCacheNewFunc) (gpointer key) GLIB_DEPRECATED_TYPE_IN_2_26; +typedef gpointer (*GCacheDupFunc) (gpointer value) GLIB_DEPRECATED_TYPE_IN_2_26; +typedef void (*GCacheDestroyFunc) (gpointer value) GLIB_DEPRECATED_TYPE_IN_2_26; + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +/* Caches + */ +GLIB_DEPRECATED +GCache* g_cache_new (GCacheNewFunc value_new_func, + GCacheDestroyFunc value_destroy_func, + GCacheDupFunc key_dup_func, + GCacheDestroyFunc key_destroy_func, + GHashFunc hash_key_func, + GHashFunc hash_value_func, + GEqualFunc key_equal_func); +GLIB_DEPRECATED +void g_cache_destroy (GCache *cache); +GLIB_DEPRECATED +gpointer g_cache_insert (GCache *cache, + gpointer key); +GLIB_DEPRECATED +void g_cache_remove (GCache *cache, + gconstpointer value); +GLIB_DEPRECATED +void g_cache_key_foreach (GCache *cache, + GHFunc func, + gpointer user_data); +GLIB_DEPRECATED +void g_cache_value_foreach (GCache *cache, + GHFunc func, + gpointer user_data); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_CACHE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gcompletion.h b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gcompletion.h new file mode 100644 index 00000000..7f9f7825 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gcompletion.h @@ -0,0 +1,85 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_COMPLETION_H__ +#define __G_COMPLETION_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GCompletion GCompletion; + +typedef gchar* (*GCompletionFunc) (gpointer item); + +/* GCompletion + */ + +typedef gint (*GCompletionStrncmpFunc) (const gchar *s1, + const gchar *s2, + gsize n); + +struct _GCompletion +{ + GList* items; + GCompletionFunc func; + + gchar* prefix; + GList* cache; + GCompletionStrncmpFunc strncmp_func; +}; + +GLIB_DEPRECATED_IN_2_26 +GCompletion* g_completion_new (GCompletionFunc func); +GLIB_DEPRECATED_IN_2_26 +void g_completion_add_items (GCompletion* cmp, + GList* items); +GLIB_DEPRECATED_IN_2_26 +void g_completion_remove_items (GCompletion* cmp, + GList* items); +GLIB_DEPRECATED_IN_2_26 +void g_completion_clear_items (GCompletion* cmp); +GLIB_DEPRECATED_IN_2_26 +GList* g_completion_complete (GCompletion* cmp, + const gchar* prefix, + gchar** new_prefix); +GLIB_DEPRECATED_IN_2_26 +GList* g_completion_complete_utf8 (GCompletion *cmp, + const gchar* prefix, + gchar** new_prefix); +GLIB_DEPRECATED_IN_2_26 +void g_completion_set_compare (GCompletion *cmp, + GCompletionStrncmpFunc strncmp_func); +GLIB_DEPRECATED_IN_2_26 +void g_completion_free (GCompletion* cmp); + +G_END_DECLS + +#endif /* __G_COMPLETION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gmain.h b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gmain.h new file mode 100644 index 00000000..ed01f8e5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gmain.h @@ -0,0 +1,137 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_DEPRECATED_MAIN_H__ +#define __G_DEPRECATED_MAIN_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* ============== Compat main loop stuff ================== */ + +/** + * g_main_new: + * @is_running: set to %TRUE to indicate that the loop is running. This + * is not very important since calling g_main_run() will set this + * to %TRUE anyway. + * + * Creates a new #GMainLoop for th default main context. + * + * Returns: a new #GMainLoop + * + * Deprecated: 2.2: Use g_main_loop_new() instead + */ +#define g_main_new(is_running) g_main_loop_new (NULL, is_running) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_new) + +/** + * g_main_run: + * @loop: a #GMainLoop + * + * Runs a main loop until it stops running. + * + * Deprecated: 2.2: Use g_main_loop_run() instead + */ +#define g_main_run(loop) g_main_loop_run(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_run) + +/** + * g_main_quit: + * @loop: a #GMainLoop + * + * Stops the #GMainLoop. + * If g_main_run() was called to run the #GMainLoop, it will now return. + * + * Deprecated: 2.2: Use g_main_loop_quit() instead + */ +#define g_main_quit(loop) g_main_loop_quit(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_quit) + +/** + * g_main_destroy: + * @loop: a #GMainLoop + * + * Frees the memory allocated for the #GMainLoop. + * + * Deprecated: 2.2: Use g_main_loop_unref() instead + */ +#define g_main_destroy(loop) g_main_loop_unref(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_unref) + +/** + * g_main_is_running: + * @loop: a #GMainLoop + * + * Checks if the main loop is running. + * + * Returns: %TRUE if the main loop is running + * + * Deprecated: 2.2: Use g_main_loop_is_running() instead + */ +#define g_main_is_running(loop) g_main_loop_is_running(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_is_running) + +/** + * g_main_iteration: + * @may_block: set to %TRUE if it should block (i.e. wait) until an event + * source becomes ready. It will return after an event source has been + * processed. If set to %FALSE it will return immediately if no event + * source is ready to be processed. + * + * Runs a single iteration for the default #GMainContext. + * + * Returns: %TRUE if more events are pending. + * + * Deprecated: 2.2: Use g_main_context_iteration() instead. + */ +#define g_main_iteration(may_block) g_main_context_iteration (NULL, may_block) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_iteration) + +/** + * g_main_pending: + * + * Checks if any events are pending for the default #GMainContext + * (i.e. ready to be processed). + * + * Returns: %TRUE if any events are pending. + * + * Deprecated: 2.2: Use g_main_context_pending() instead. + */ +#define g_main_pending() g_main_context_pending (NULL) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_pending) + +/** + * g_main_set_poll_func: + * @func: the function to call to poll all file descriptors + * + * Sets the function to use for the handle polling of file descriptors + * for the default main context. + * + * Deprecated: 2.2: Use g_main_context_set_poll_func() again + */ +#define g_main_set_poll_func(func) g_main_context_set_poll_func (NULL, func) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_set_poll_func) + +G_END_DECLS + +#endif /* __G_DEPRECATED_MAIN_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/grel.h b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/grel.h new file mode 100644 index 00000000..1f299985 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/grel.h @@ -0,0 +1,84 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_REL_H__ +#define __G_REL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GRelation GRelation; +typedef struct _GTuples GTuples; + +struct _GTuples +{ + guint len; +}; + +GLIB_DEPRECATED_IN_2_26 +GRelation* g_relation_new (gint fields); +GLIB_DEPRECATED_IN_2_26 +void g_relation_destroy (GRelation *relation); +GLIB_DEPRECATED_IN_2_26 +void g_relation_index (GRelation *relation, + gint field, + GHashFunc hash_func, + GEqualFunc key_equal_func); +GLIB_DEPRECATED_IN_2_26 +void g_relation_insert (GRelation *relation, + ...); +GLIB_DEPRECATED_IN_2_26 +gint g_relation_delete (GRelation *relation, + gconstpointer key, + gint field); +GLIB_DEPRECATED_IN_2_26 +GTuples* g_relation_select (GRelation *relation, + gconstpointer key, + gint field); +GLIB_DEPRECATED_IN_2_26 +gint g_relation_count (GRelation *relation, + gconstpointer key, + gint field); +GLIB_DEPRECATED_IN_2_26 +gboolean g_relation_exists (GRelation *relation, + ...); +GLIB_DEPRECATED_IN_2_26 +void g_relation_print (GRelation *relation); +GLIB_DEPRECATED_IN_2_26 +void g_tuples_destroy (GTuples *tuples); +GLIB_DEPRECATED_IN_2_26 +gpointer g_tuples_index (GTuples *tuples, + gint index_, + gint field); + +G_END_DECLS + +#endif /* __G_REL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gthread.h b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gthread.h new file mode 100644 index 00000000..4988e004 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/deprecated/gthread.h @@ -0,0 +1,299 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_DEPRECATED_THREAD_H__ +#define __G_DEPRECATED_THREAD_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +typedef enum +{ + G_THREAD_PRIORITY_LOW, + G_THREAD_PRIORITY_NORMAL, + G_THREAD_PRIORITY_HIGH, + G_THREAD_PRIORITY_URGENT +} GThreadPriority GLIB_DEPRECATED_TYPE_IN_2_32; + +struct _GThread +{ + /*< private >*/ + GThreadFunc func; + gpointer data; + gboolean joinable; + GThreadPriority priority; +}; + +typedef struct _GThreadFunctions GThreadFunctions GLIB_DEPRECATED_TYPE_IN_2_32; +struct _GThreadFunctions +{ + GMutex* (*mutex_new) (void); + void (*mutex_lock) (GMutex *mutex); + gboolean (*mutex_trylock) (GMutex *mutex); + void (*mutex_unlock) (GMutex *mutex); + void (*mutex_free) (GMutex *mutex); + GCond* (*cond_new) (void); + void (*cond_signal) (GCond *cond); + void (*cond_broadcast) (GCond *cond); + void (*cond_wait) (GCond *cond, + GMutex *mutex); + gboolean (*cond_timed_wait) (GCond *cond, + GMutex *mutex, + GTimeVal *end_time); + void (*cond_free) (GCond *cond); + GPrivate* (*private_new) (GDestroyNotify destructor); + gpointer (*private_get) (GPrivate *private_key); + void (*private_set) (GPrivate *private_key, + gpointer data); + void (*thread_create) (GThreadFunc func, + gpointer data, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority, + gpointer thread, + GError **error); + void (*thread_yield) (void); + void (*thread_join) (gpointer thread); + void (*thread_exit) (void); + void (*thread_set_priority)(gpointer thread, + GThreadPriority priority); + void (*thread_self) (gpointer thread); + gboolean (*thread_equal) (gpointer thread1, + gpointer thread2); +} GLIB_DEPRECATED_TYPE_IN_2_32; + +GLIB_VAR GThreadFunctions g_thread_functions_for_glib_use; +GLIB_VAR gboolean g_thread_use_default_impl; + +GLIB_VAR guint64 (*g_thread_gettime) (void); + +GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new) +GThread *g_thread_create (GThreadFunc func, + gpointer data, + gboolean joinable, + GError **error); + +GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new) +GThread *g_thread_create_full (GThreadFunc func, + gpointer data, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority, + GError **error); + +GLIB_DEPRECATED_IN_2_32 +void g_thread_set_priority (GThread *thread, + GThreadPriority priority); + +GLIB_DEPRECATED_IN_2_32 +void g_thread_foreach (GFunc thread_func, + gpointer user_data); + +#ifndef G_OS_WIN32 +#include +#include +#endif + +#define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl GLIB_DEPRECATED_MACRO_IN_2_32 +#ifndef G_OS_WIN32 +#define G_STATIC_MUTEX_INIT { NULL, PTHREAD_MUTEX_INITIALIZER } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) +#else +#define G_STATIC_MUTEX_INIT { NULL } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) +#endif +typedef struct +{ + GMutex *mutex; +#ifndef __GI_SCANNER__ +# ifndef G_OS_WIN32 + /* only for ABI compatibility reasons */ + pthread_mutex_t unused; +# endif /* !G_OS_WIN32 */ +#endif /* !__GI_SCANNER__ */ +} GStaticMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GMutex); + +#define g_static_mutex_lock(mutex) \ + g_mutex_lock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_lock) +#define g_static_mutex_trylock(mutex) \ + g_mutex_trylock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_trylock) +#define g_static_mutex_unlock(mutex) \ + g_mutex_unlock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_unlock) + +GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_init) +void g_static_mutex_init (GStaticMutex *mutex); +GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_clear) +void g_static_mutex_free (GStaticMutex *mutex); +GLIB_DEPRECATED_IN_2_32_FOR(GMutex) +GMutex *g_static_mutex_get_mutex_impl (GStaticMutex *mutex); + +typedef struct _GStaticRecMutex GStaticRecMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); +struct _GStaticRecMutex +{ + /*< private >*/ + GStaticMutex mutex; + guint depth; + +#ifndef __GI_SCANNER__ + /* ABI compat only */ + union { +# ifdef G_OS_WIN32 + void *owner; +# else + pthread_t owner; +# endif /* !G_OS_WIN32 */ + gdouble dummy; + } unused; +#endif /* !__GI_SCANNER__ */ +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); + +#define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT, 0, { 0 } } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rec_mutex_init) +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_init) +void g_static_rec_mutex_init (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_lock) +void g_static_rec_mutex_lock (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_try_lock) +gboolean g_static_rec_mutex_trylock (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_unlock) +void g_static_rec_mutex_unlock (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32 +void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, + guint depth); + +GLIB_DEPRECATED_IN_2_32 +guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_free) +void g_static_rec_mutex_free (GStaticRecMutex *mutex); + +typedef struct _GStaticRWLock GStaticRWLock GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); +struct _GStaticRWLock +{ + /*< private >*/ + GStaticMutex mutex; + GCond *read_cond; + GCond *write_cond; + guint read_counter; + gboolean have_writer; + guint want_to_read; + guint want_to_write; +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); + +#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rw_lock_init) + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_init) +void g_static_rw_lock_init (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_lock) +void g_static_rw_lock_reader_lock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_trylock) +gboolean g_static_rw_lock_reader_trylock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_unlock) +void g_static_rw_lock_reader_unlock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_lock) +void g_static_rw_lock_writer_lock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_trylock) +gboolean g_static_rw_lock_writer_trylock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_unlock) +void g_static_rw_lock_writer_unlock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_free) +void g_static_rw_lock_free (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32 +GPrivate * g_private_new (GDestroyNotify notify); + +typedef struct _GStaticPrivate GStaticPrivate GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); +struct _GStaticPrivate +{ + /*< private >*/ + guint index; +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); + +#define G_STATIC_PRIVATE_INIT { 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(G_PRIVATE_INIT) +GLIB_DEPRECATED_IN_2_32 +void g_static_private_init (GStaticPrivate *private_key); + +GLIB_DEPRECATED_IN_2_32_FOR(g_private_get) +gpointer g_static_private_get (GStaticPrivate *private_key); + +GLIB_DEPRECATED_IN_2_32_FOR(g_private_set) +void g_static_private_set (GStaticPrivate *private_key, + gpointer data, + GDestroyNotify notify); + +GLIB_DEPRECATED_IN_2_32 +void g_static_private_free (GStaticPrivate *private_key); + +GLIB_DEPRECATED_IN_2_32 +gboolean g_once_init_enter_impl (volatile gsize *location); + +GLIB_DEPRECATED_IN_2_32 +void g_thread_init (gpointer vtable); +GLIB_DEPRECATED_IN_2_32 +void g_thread_init_with_errorcheck_mutexes (gpointer vtable); + +GLIB_DEPRECATED_IN_2_32 +gboolean g_thread_get_initialized (void); + +GLIB_VAR gboolean g_threads_got_initialized; + +#define g_thread_supported() (1) GLIB_DEPRECATED_MACRO_IN_2_32 + +GLIB_DEPRECATED_IN_2_32 +GMutex * g_mutex_new (void); +GLIB_DEPRECATED_IN_2_32 +void g_mutex_free (GMutex *mutex); +GLIB_DEPRECATED_IN_2_32 +GCond * g_cond_new (void); +GLIB_DEPRECATED_IN_2_32 +void g_cond_free (GCond *cond); +GLIB_DEPRECATED_IN_2_32 +gboolean g_cond_timed_wait (GCond *cond, + GMutex *mutex, + GTimeVal *abs_time); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_DEPRECATED_THREAD_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/galloca.h b/illumos-x86_64/usr/include/glib-2.0/glib/galloca.h new file mode 100644 index 00000000..db01fe52 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/galloca.h @@ -0,0 +1,147 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_ALLOCA_H__ +#define __G_ALLOCA_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +#if defined(__BIONIC__) && defined (GLIB_HAVE_ALLOCA_H) +# include +#elif defined(__GNUC__) +/* GCC does the right thing */ +# undef alloca +# define alloca(size) __builtin_alloca (size) +#elif defined (GLIB_HAVE_ALLOCA_H) +/* a native and working alloca.h is there */ +# include +#else /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */ +# if defined(_MSC_VER) || defined(__DMC__) +# include +# define alloca _alloca +# else /* !_MSC_VER && !__DMC__ */ +# ifdef _AIX +# pragma alloca +# else /* !_AIX */ +# ifndef alloca /* predefined by HP cc +Olibcalls */ +G_BEGIN_DECLS +char *alloca (); +G_END_DECLS +# endif /* !alloca */ +# endif /* !_AIX */ +# endif /* !_MSC_VER && !__DMC__ */ +#endif /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */ + +/** + * g_alloca: + * @size: number of bytes to allocate. + * + * Allocates @size bytes on the stack; these bytes will be freed when the current + * stack frame is cleaned up. This macro essentially just wraps the alloca() + * function present on most UNIX variants. + * Thus it provides the same advantages and pitfalls as alloca(): + * + * - alloca() is very fast, as on most systems it's implemented by just adjusting + * the stack pointer register. + * + * - It doesn't cause any memory fragmentation, within its scope, separate alloca() + * blocks just build up and are released together at function end. + * + * - Allocation sizes have to fit into the current stack frame. For instance in a + * threaded environment on Linux, the per-thread stack size is limited to 2 Megabytes, + * so be sparse with alloca() uses. + * + * - Allocation failure due to insufficient stack space is not indicated with a %NULL + * return like e.g. with malloc(). Instead, most systems probably handle it the same + * way as out of stack space situations from infinite function recursion, i.e. + * with a segmentation fault. + * + * - Allowing @size to be specified by an untrusted party would allow for them + * to trigger a segmentation fault by specifying a large size, leading to a + * denial of service vulnerability. @size must always be entirely under the + * control of the program. + * + * - Special care has to be taken when mixing alloca() with GNU C variable sized arrays. + * Stack space allocated with alloca() in the same scope as a variable sized array + * will be freed together with the variable sized array upon exit of that scope, and + * not upon exit of the enclosing function scope. + * + * Returns: space for @size bytes, allocated on the stack + */ +#define g_alloca(size) alloca (size) + +/** + * g_alloca0: + * @size: number of bytes to allocate. + * + * Wraps g_alloca() and initializes allocated memory to zeroes. + * If @size is `0` it returns %NULL. + * + * Note that the @size argument will be evaluated multiple times. + * + * Returns: (nullable) (transfer full): space for @size bytes, allocated on the stack + * + * Since: 2.72 + */ +#define g_alloca0(size) ((size) == 0 ? NULL : memset (g_alloca (size), 0, (size))) + +/** + * g_newa: + * @struct_type: Type of memory chunks to be allocated + * @n_structs: Number of chunks to be allocated + * + * Wraps g_alloca() in a more typesafe manner. + * + * As mentioned in the documentation for g_alloca(), @n_structs must always be + * entirely under the control of the program, or you may introduce a denial of + * service vulnerability. In addition, the multiplication of @struct_type by + * @n_structs is not checked, so an overflow may lead to a remote code execution + * vulnerability. + * + * Returns: Pointer to stack space for @n_structs chunks of type @struct_type + */ +#define g_newa(struct_type, n_structs) ((struct_type*) g_alloca (sizeof (struct_type) * (gsize) (n_structs))) + +/** + * g_newa0: + * @struct_type: the type of the elements to allocate. + * @n_structs: the number of elements to allocate. + * + * Wraps g_alloca0() in a more typesafe manner. + * + * Returns: (nullable) (transfer full): Pointer to stack space for @n_structs + * chunks of type @struct_type + * + * Since: 2.72 + */ +#define g_newa0(struct_type, n_structs) ((struct_type*) g_alloca0 (sizeof (struct_type) * (gsize) (n_structs))) + +#endif /* __G_ALLOCA_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/garray.h b/illumos-x86_64/usr/include/glib-2.0/glib/garray.h new file mode 100644 index 00000000..b3d8e68b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/garray.h @@ -0,0 +1,323 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_ARRAY_H__ +#define __G_ARRAY_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GBytes GBytes; +typedef struct _GArray GArray; +typedef struct _GByteArray GByteArray; +typedef struct _GPtrArray GPtrArray; + +struct _GArray +{ + gchar *data; + guint len; +}; + +struct _GByteArray +{ + guint8 *data; + guint len; +}; + +struct _GPtrArray +{ + gpointer *pdata; + guint len; +}; + +/* Resizable arrays. remove fills any cleared spot and shortens the + * array, while preserving the order. remove_fast will distort the + * order by moving the last element to the position of the removed. + */ + +#define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1) +#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &(v), 1) +#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1) +#define g_array_index(a,t,i) (((t*) (void *) (a)->data) [(i)]) + +GLIB_AVAILABLE_IN_ALL +GArray* g_array_new (gboolean zero_terminated, + gboolean clear_, + guint element_size); +GLIB_AVAILABLE_IN_2_76 +GArray* g_array_new_take (gpointer data, + gsize len, + gboolean clear, + gsize element_size); +GLIB_AVAILABLE_IN_2_76 +GArray* g_array_new_take_zero_terminated (gpointer data, + gboolean clear, + gsize element_size); +GLIB_AVAILABLE_IN_2_64 +gpointer g_array_steal (GArray *array, + gsize *len); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_sized_new (gboolean zero_terminated, + gboolean clear_, + guint element_size, + guint reserved_size); +GLIB_AVAILABLE_IN_2_62 +GArray* g_array_copy (GArray *array); +GLIB_AVAILABLE_IN_ALL +gchar* g_array_free (GArray *array, + gboolean free_segment); +GLIB_AVAILABLE_IN_ALL +GArray *g_array_ref (GArray *array); +GLIB_AVAILABLE_IN_ALL +void g_array_unref (GArray *array); +GLIB_AVAILABLE_IN_ALL +guint g_array_get_element_size (GArray *array); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_append_vals (GArray *array, + gconstpointer data, + guint len); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_prepend_vals (GArray *array, + gconstpointer data, + guint len); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_insert_vals (GArray *array, + guint index_, + gconstpointer data, + guint len); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_set_size (GArray *array, + guint length); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_remove_index (GArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_remove_index_fast (GArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_remove_range (GArray *array, + guint index_, + guint length); +GLIB_AVAILABLE_IN_ALL +void g_array_sort (GArray *array, + GCompareFunc compare_func); +GLIB_AVAILABLE_IN_ALL +void g_array_sort_with_data (GArray *array, + GCompareDataFunc compare_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_62 +gboolean g_array_binary_search (GArray *array, + gconstpointer target, + GCompareFunc compare_func, + guint *out_match_index); +GLIB_AVAILABLE_IN_ALL +void g_array_set_clear_func (GArray *array, + GDestroyNotify clear_func); + +/* Resizable pointer array. This interface is much less complicated + * than the above. Add appends a pointer. Remove fills any cleared + * spot and shortens the array. remove_fast will again distort order. + */ +#define g_ptr_array_index(array,index_) ((array)->pdata)[index_] +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_new (void); +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_new_with_free_func (GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_2_76 +GPtrArray* g_ptr_array_new_take (gpointer *data, + gsize len, + GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_2_76 +GPtrArray* g_ptr_array_new_from_array (gpointer *data, + gsize len, + GCopyFunc copy_func, + gpointer copy_func_user_data, + GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_2_64 +gpointer* g_ptr_array_steal (GPtrArray *array, + gsize *len); +GLIB_AVAILABLE_IN_2_62 +GPtrArray *g_ptr_array_copy (GPtrArray *array, + GCopyFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_sized_new (guint reserved_size); +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_new_full (guint reserved_size, + GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_2_74 +GPtrArray* g_ptr_array_new_null_terminated (guint reserved_size, + GDestroyNotify element_free_func, + gboolean null_terminated); +GLIB_AVAILABLE_IN_2_76 +GPtrArray* g_ptr_array_new_take_null_terminated (gpointer *data, + GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_2_76 +GPtrArray* g_ptr_array_new_from_null_terminated_array (gpointer *data, + GCopyFunc copy_func, + gpointer copy_func_user_data, + GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_ALL +gpointer* g_ptr_array_free (GPtrArray *array, + gboolean free_segment); +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_ref (GPtrArray *array); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_unref (GPtrArray *array); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_set_free_func (GPtrArray *array, + GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_set_size (GPtrArray *array, + gint length); +GLIB_AVAILABLE_IN_ALL +gpointer g_ptr_array_remove_index (GPtrArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +gpointer g_ptr_array_remove_index_fast (GPtrArray *array, + guint index_); +GLIB_AVAILABLE_IN_2_58 +gpointer g_ptr_array_steal_index (GPtrArray *array, + guint index_); +GLIB_AVAILABLE_IN_2_58 +gpointer g_ptr_array_steal_index_fast (GPtrArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +gboolean g_ptr_array_remove (GPtrArray *array, + gpointer data); +GLIB_AVAILABLE_IN_ALL +gboolean g_ptr_array_remove_fast (GPtrArray *array, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GPtrArray *g_ptr_array_remove_range (GPtrArray *array, + guint index_, + guint length); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_add (GPtrArray *array, + gpointer data); +GLIB_AVAILABLE_IN_2_62 +void g_ptr_array_extend (GPtrArray *array_to_extend, + GPtrArray *array, + GCopyFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_62 +void g_ptr_array_extend_and_steal (GPtrArray *array_to_extend, + GPtrArray *array); +GLIB_AVAILABLE_IN_2_40 +void g_ptr_array_insert (GPtrArray *array, + gint index_, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_sort (GPtrArray *array, + GCompareFunc compare_func); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_sort_with_data (GPtrArray *array, + GCompareDataFunc compare_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_76 +void g_ptr_array_sort_values (GPtrArray *array, + GCompareFunc compare_func); +GLIB_AVAILABLE_IN_2_76 +void g_ptr_array_sort_values_with_data (GPtrArray *array, + GCompareDataFunc compare_func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_foreach (GPtrArray *array, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_54 +gboolean g_ptr_array_find (GPtrArray *haystack, + gconstpointer needle, + guint *index_); +GLIB_AVAILABLE_IN_2_54 +gboolean g_ptr_array_find_with_equal_func (GPtrArray *haystack, + gconstpointer needle, + GEqualFunc equal_func, + guint *index_); + +GLIB_AVAILABLE_IN_2_74 +gboolean g_ptr_array_is_null_terminated (GPtrArray *array); + +/* Byte arrays, an array of guint8. Implemented as a GArray, + * but type-safe. + */ + +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_new (void); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_new_take (guint8 *data, + gsize len); +GLIB_AVAILABLE_IN_2_64 +guint8* g_byte_array_steal (GByteArray *array, + gsize *len); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_sized_new (guint reserved_size); +GLIB_AVAILABLE_IN_ALL +guint8* g_byte_array_free (GByteArray *array, + gboolean free_segment); +GLIB_AVAILABLE_IN_ALL +GBytes* g_byte_array_free_to_bytes (GByteArray *array); +GLIB_AVAILABLE_IN_ALL +GByteArray *g_byte_array_ref (GByteArray *array); +GLIB_AVAILABLE_IN_ALL +void g_byte_array_unref (GByteArray *array); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_append (GByteArray *array, + const guint8 *data, + guint len); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_prepend (GByteArray *array, + const guint8 *data, + guint len); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_set_size (GByteArray *array, + guint length); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_remove_index (GByteArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_remove_index_fast (GByteArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_remove_range (GByteArray *array, + guint index_, + guint length); +GLIB_AVAILABLE_IN_ALL +void g_byte_array_sort (GByteArray *array, + GCompareFunc compare_func); +GLIB_AVAILABLE_IN_ALL +void g_byte_array_sort_with_data (GByteArray *array, + GCompareDataFunc compare_func, + gpointer user_data); + +G_END_DECLS + +#endif /* __G_ARRAY_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gasyncqueue.h b/illumos-x86_64/usr/include/glib-2.0/glib/gasyncqueue.h new file mode 100644 index 00000000..b1de117f --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gasyncqueue.h @@ -0,0 +1,126 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_ASYNCQUEUE_H__ +#define __G_ASYNCQUEUE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GAsyncQueue GAsyncQueue; + +GLIB_AVAILABLE_IN_ALL +GAsyncQueue *g_async_queue_new (void); +GLIB_AVAILABLE_IN_ALL +GAsyncQueue *g_async_queue_new_full (GDestroyNotify item_free_func); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_lock (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_unlock (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +GAsyncQueue *g_async_queue_ref (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_unref (GAsyncQueue *queue); + +GLIB_DEPRECATED_FOR(g_async_queue_ref) +void g_async_queue_ref_unlocked (GAsyncQueue *queue); + +GLIB_DEPRECATED_FOR(g_async_queue_unref) +void g_async_queue_unref_and_unlock (GAsyncQueue *queue); + +GLIB_AVAILABLE_IN_ALL +void g_async_queue_push (GAsyncQueue *queue, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_push_unlocked (GAsyncQueue *queue, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_push_sorted (GAsyncQueue *queue, + gpointer data, + GCompareDataFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_push_sorted_unlocked (GAsyncQueue *queue, + gpointer data, + GCompareDataFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_pop (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_pop_unlocked (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_try_pop (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_try_pop_unlocked (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_timeout_pop (GAsyncQueue *queue, + guint64 timeout); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_timeout_pop_unlocked (GAsyncQueue *queue, + guint64 timeout); +GLIB_AVAILABLE_IN_ALL +gint g_async_queue_length (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gint g_async_queue_length_unlocked (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_sort (GAsyncQueue *queue, + GCompareDataFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_sort_unlocked (GAsyncQueue *queue, + GCompareDataFunc func, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_46 +gboolean g_async_queue_remove (GAsyncQueue *queue, + gpointer item); +GLIB_AVAILABLE_IN_2_46 +gboolean g_async_queue_remove_unlocked (GAsyncQueue *queue, + gpointer item); +GLIB_AVAILABLE_IN_2_46 +void g_async_queue_push_front (GAsyncQueue *queue, + gpointer item); +GLIB_AVAILABLE_IN_2_46 +void g_async_queue_push_front_unlocked (GAsyncQueue *queue, + gpointer item); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_FOR(g_async_queue_timeout_pop) +gpointer g_async_queue_timed_pop (GAsyncQueue *queue, + GTimeVal *end_time); +GLIB_DEPRECATED_FOR(g_async_queue_timeout_pop_unlocked) +gpointer g_async_queue_timed_pop_unlocked (GAsyncQueue *queue, + GTimeVal *end_time); +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_ASYNCQUEUE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gatomic.h b/illumos-x86_64/usr/include/glib-2.0/glib/gatomic.h new file mode 100644 index 00000000..93998880 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gatomic.h @@ -0,0 +1,587 @@ +/* + * Copyright © 2011 Ryan Lortie + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_ATOMIC_H__ +#define __G_ATOMIC_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gint g_atomic_int_get (const volatile gint *atomic); +GLIB_AVAILABLE_IN_ALL +void g_atomic_int_set (volatile gint *atomic, + gint newval); +GLIB_AVAILABLE_IN_ALL +void g_atomic_int_inc (volatile gint *atomic); +GLIB_AVAILABLE_IN_ALL +gboolean g_atomic_int_dec_and_test (volatile gint *atomic); +GLIB_AVAILABLE_IN_ALL +gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic, + gint oldval, + gint newval); +GLIB_AVAILABLE_IN_2_74 +gboolean g_atomic_int_compare_and_exchange_full (gint *atomic, + gint oldval, + gint newval, + gint *preval); +GLIB_AVAILABLE_IN_2_74 +gint g_atomic_int_exchange (gint *atomic, + gint newval); +GLIB_AVAILABLE_IN_ALL +gint g_atomic_int_add (volatile gint *atomic, + gint val); +GLIB_AVAILABLE_IN_2_30 +guint g_atomic_int_and (volatile guint *atomic, + guint val); +GLIB_AVAILABLE_IN_2_30 +guint g_atomic_int_or (volatile guint *atomic, + guint val); +GLIB_AVAILABLE_IN_ALL +guint g_atomic_int_xor (volatile guint *atomic, + guint val); + +GLIB_AVAILABLE_IN_ALL +gpointer g_atomic_pointer_get (const volatile void *atomic); +GLIB_AVAILABLE_IN_ALL +void g_atomic_pointer_set (volatile void *atomic, + gpointer newval); +GLIB_AVAILABLE_IN_ALL +gboolean g_atomic_pointer_compare_and_exchange (volatile void *atomic, + gpointer oldval, + gpointer newval); +GLIB_AVAILABLE_IN_2_74 +gboolean g_atomic_pointer_compare_and_exchange_full (void *atomic, + gpointer oldval, + gpointer newval, + void *preval); +GLIB_AVAILABLE_IN_2_74 +gpointer g_atomic_pointer_exchange (void *atomic, + gpointer newval); +GLIB_AVAILABLE_IN_ALL +gintptr g_atomic_pointer_add (volatile void *atomic, + gssize val); +GLIB_AVAILABLE_IN_2_30 +guintptr g_atomic_pointer_and (volatile void *atomic, + gsize val); +GLIB_AVAILABLE_IN_2_30 +guintptr g_atomic_pointer_or (volatile void *atomic, + gsize val); +GLIB_AVAILABLE_IN_ALL +guintptr g_atomic_pointer_xor (volatile void *atomic, + gsize val); + +GLIB_DEPRECATED_IN_2_30_FOR(g_atomic_int_add) +gint g_atomic_int_exchange_and_add (volatile gint *atomic, + gint val); + +G_END_DECLS + +#if defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) + +/* We prefer the new C11-style atomic extension of GCC if available */ +#if defined(__ATOMIC_SEQ_CST) + +#define g_atomic_int_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + gint gaig_temp; \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + __atomic_load ((gint *)(atomic), &gaig_temp, __ATOMIC_SEQ_CST); \ + (gint) gaig_temp; \ + })) +#define g_atomic_int_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + gint gais_temp = (gint) (newval); \ + (void) (0 ? *(atomic) ^ (newval) : 1); \ + __atomic_store ((gint *)(atomic), &gais_temp, __ATOMIC_SEQ_CST); \ + })) + +#if defined(glib_typeof) +#define g_atomic_pointer_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + glib_typeof (*(atomic)) gapg_temp_newval; \ + glib_typeof ((atomic)) gapg_temp_atomic = (atomic); \ + __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ + gapg_temp_newval; \ + })) +#define g_atomic_pointer_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + glib_typeof ((atomic)) gaps_temp_atomic = (atomic); \ + glib_typeof (*(atomic)) gaps_temp_newval = (newval); \ + (void) (0 ? (gpointer) * (atomic) : NULL); \ + __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ + })) +#else /* if !(defined(glib_typeof) */ +#define g_atomic_pointer_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + gpointer gapg_temp_newval; \ + gpointer *gapg_temp_atomic = (gpointer *)(atomic); \ + __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ + gapg_temp_newval; \ + })) +#define g_atomic_pointer_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + gpointer *gaps_temp_atomic = (gpointer *)(atomic); \ + gpointer gaps_temp_newval = (gpointer)(newval); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ + })) +#endif /* if defined(glib_typeof) */ + +#define g_atomic_int_inc(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + (void) __atomic_fetch_add ((atomic), 1, __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_int_dec_and_test(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + __atomic_fetch_sub ((atomic), 1, __ATOMIC_SEQ_CST) == 1; \ + })) +#if defined(glib_typeof) && defined(G_CXX_STD_VERSION) +/* See comments below about equivalent g_atomic_pointer_compare_and_exchange() + * shenanigans for type-safety when compiling in C++ mode. */ +#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + glib_typeof (*(atomic)) gaicae_oldval = (oldval); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \ + __atomic_compare_exchange_n ((atomic), &gaicae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ + })) +#else /* if !(defined(glib_typeof) && defined(G_CXX_STD_VERSION)) */ +#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + gint gaicae_oldval = (oldval); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \ + __atomic_compare_exchange_n ((atomic), (void *) (&(gaicae_oldval)), (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ + })) +#endif /* defined(glib_typeof) */ +#define g_atomic_int_compare_and_exchange_full(atomic, oldval, newval, preval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + G_STATIC_ASSERT (sizeof *(preval) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) ^ (oldval) ^ *(preval) : 1); \ + *(preval) = (oldval); \ + __atomic_compare_exchange_n ((atomic), (preval), (newval), FALSE, \ + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) \ + ? TRUE : FALSE; \ + })) +#define g_atomic_int_exchange(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) : 1); \ + (gint) __atomic_exchange_n ((atomic), (newval), __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_int_add(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (gint) __atomic_fetch_add ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_int_and(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __atomic_fetch_and ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_int_or(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __atomic_fetch_or ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_int_xor(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __atomic_fetch_xor ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) + +#if defined(glib_typeof) && defined(G_CXX_STD_VERSION) +/* This is typesafe because we check we can assign oldval to the type of + * (*atomic). Unfortunately it can only be done in C++ because gcc/clang warn + * when atomic is volatile and not oldval, or when atomic is gsize* and oldval + * is NULL. Note that clang++ force us to be typesafe because it is an error if the 2nd + * argument of __atomic_compare_exchange_n() has a different type than the + * first. + * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1919 + * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1715#note_1024120. */ +#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof (static_cast((oldval))) \ + == sizeof (gpointer)); \ + glib_typeof (*(atomic)) gapcae_oldval = (oldval); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ + })) +#else /* if !(defined(glib_typeof) && defined(G_CXX_STD_VERSION) */ +#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \ + gpointer gapcae_oldval = (gpointer)(oldval); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __atomic_compare_exchange_n ((atomic), (void *) (&(gapcae_oldval)), (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ + })) +#endif /* defined(glib_typeof) */ +#define g_atomic_pointer_compare_and_exchange_full(atomic, oldval, newval, preval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof *(preval) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (gpointer) *(preval) : NULL); \ + *(preval) = (oldval); \ + __atomic_compare_exchange_n ((atomic), (preval), (newval), FALSE, \ + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? \ + TRUE : FALSE; \ + })) +#define g_atomic_pointer_exchange(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (gpointer) __atomic_exchange_n ((atomic), (newval), __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_pointer_add(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gintptr) __atomic_fetch_add ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_pointer_and(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + guintptr *gapa_atomic = (guintptr *) (atomic); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (guintptr)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (guintptr) __atomic_fetch_and (gapa_atomic, (val), __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_pointer_or(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + guintptr *gapo_atomic = (guintptr *) (atomic); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (guintptr)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (guintptr) __atomic_fetch_or (gapo_atomic, (val), __ATOMIC_SEQ_CST); \ + })) +#define g_atomic_pointer_xor(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + guintptr *gapx_atomic = (guintptr *) (atomic); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (guintptr)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (guintptr) __atomic_fetch_xor (gapx_atomic, (val), __ATOMIC_SEQ_CST); \ + })) + +#else /* defined(__ATOMIC_SEQ_CST) */ + +/* We want to achieve __ATOMIC_SEQ_CST semantics here. See + * https://en.cppreference.com/w/c/atomic/memory_order#Constants. For load + * operations, that means performing an *acquire*: + * > A load operation with this memory order performs the acquire operation on + * > the affected memory location: no reads or writes in the current thread can + * > be reordered before this load. All writes in other threads that release + * > the same atomic variable are visible in the current thread. + * + * “no reads or writes in the current thread can be reordered before this load†+ * is implemented using a compiler barrier (a no-op `__asm__` section) to + * prevent instruction reordering. Writes in other threads are synchronised + * using `__sync_synchronize()`. It’s unclear from the GCC documentation whether + * `__sync_synchronize()` acts as a compiler barrier, hence our explicit use of + * one. + * + * For store operations, `__ATOMIC_SEQ_CST` means performing a *release*: + * > A store operation with this memory order performs the release operation: + * > no reads or writes in the current thread can be reordered after this store. + * > All writes in the current thread are visible in other threads that acquire + * > the same atomic variable (see Release-Acquire ordering below) and writes + * > that carry a dependency into the atomic variable become visible in other + * > threads that consume the same atomic (see Release-Consume ordering below). + * + * “no reads or writes in the current thread can be reordered after this store†+ * is implemented using a compiler barrier to prevent instruction reordering. + * “All writes in the current thread are visible in other threads†is implemented + * using `__sync_synchronize()`; similarly for “writes that carry a dependencyâ€. + */ +#define g_atomic_int_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + gint gaig_result; \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + gaig_result = (gint) *(atomic); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + gaig_result; \ + })) +#define g_atomic_int_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) : 1); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + *(atomic) = (newval); \ + })) +#define g_atomic_pointer_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + gpointer gapg_result; \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + gapg_result = (gpointer) *(atomic); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + gapg_result; \ + })) +#if defined(glib_typeof) +#define g_atomic_pointer_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + *(atomic) = (glib_typeof (*(atomic))) (guintptr) (newval); \ + })) +#else /* if !(defined(glib_typeof) */ +#define g_atomic_pointer_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + *(atomic) = (gpointer) (guintptr) (newval); \ + })) +#endif /* if defined(glib_typeof) */ + +#define g_atomic_int_inc(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + (void) __sync_fetch_and_add ((atomic), 1); \ + })) +#define g_atomic_int_dec_and_test(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + __sync_fetch_and_sub ((atomic), 1) == 1; \ + })) +#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \ + __sync_bool_compare_and_swap ((atomic), (oldval), (newval)) ? TRUE : FALSE; \ + })) +#define g_atomic_int_compare_and_exchange_full(atomic, oldval, newval, preval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + G_STATIC_ASSERT (sizeof *(preval) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) ^ (oldval) ^ *(preval) : 1); \ + *(preval) = __sync_val_compare_and_swap ((atomic), (oldval), (newval)); \ + (*(preval) == (oldval)) ? TRUE : FALSE; \ + })) +#if defined(_GLIB_GCC_HAVE_SYNC_SWAP) +#define g_atomic_int_exchange(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) : 1); \ + (gint) __sync_swap ((atomic), (newval)); \ + })) +#else /* defined(_GLIB_GCC_HAVE_SYNC_SWAP) */ + #define g_atomic_int_exchange(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + gint oldval; \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) : 1); \ + do \ + { \ + oldval = *atomic; \ + } while (!__sync_bool_compare_and_swap (atomic, oldval, newval)); \ + oldval; \ + })) +#endif /* defined(_GLIB_GCC_HAVE_SYNC_SWAP) */ +#define g_atomic_int_add(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (gint) __sync_fetch_and_add ((atomic), (val)); \ + })) +#define g_atomic_int_and(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __sync_fetch_and_and ((atomic), (val)); \ + })) +#define g_atomic_int_or(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __sync_fetch_and_or ((atomic), (val)); \ + })) +#define g_atomic_int_xor(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __sync_fetch_and_xor ((atomic), (val)); \ + })) + +#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __sync_bool_compare_and_swap ((atomic), (oldval), (newval)) ? TRUE : FALSE; \ + })) +#define g_atomic_pointer_compare_and_exchange_full(atomic, oldval, newval, preval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof *(preval) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (gpointer) *(preval) : NULL); \ + *(preval) = __sync_val_compare_and_swap ((atomic), (oldval), (newval)); \ + (*(preval) == (oldval)) ? TRUE : FALSE; \ + })) +#if defined(_GLIB_GCC_HAVE_SYNC_SWAP) +#define g_atomic_pointer_exchange(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (gpointer) __sync_swap ((atomic), (newval)); \ + })) +#else +#define g_atomic_pointer_exchange(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + gpointer oldval; \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + do \ + { \ + oldval = (gpointer) *atomic; \ + } while (!__sync_bool_compare_and_swap (atomic, oldval, newval)); \ + oldval; \ + })) +#endif /* defined(_GLIB_GCC_HAVE_SYNC_SWAP) */ +#define g_atomic_pointer_add(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gintptr) __sync_fetch_and_add ((atomic), (val)); \ + })) +#define g_atomic_pointer_and(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (guintptr) __sync_fetch_and_and ((atomic), (val)); \ + })) +#define g_atomic_pointer_or(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (guintptr) __sync_fetch_and_or ((atomic), (val)); \ + })) +#define g_atomic_pointer_xor(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (guintptr) __sync_fetch_and_xor ((atomic), (val)); \ + })) + +#endif /* !defined(__ATOMIC_SEQ_CST) */ + +#else /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */ + +#define g_atomic_int_get(atomic) \ + (g_atomic_int_get ((gint *) (atomic))) +#define g_atomic_int_set(atomic, newval) \ + (g_atomic_int_set ((gint *) (atomic), (gint) (newval))) +#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ + (g_atomic_int_compare_and_exchange ((gint *) (atomic), (oldval), (newval))) +#define g_atomic_int_compare_and_exchange_full(atomic, oldval, newval, preval) \ + (g_atomic_int_compare_and_exchange_full ((gint *) (atomic), (oldval), (newval), (gint *) (preval))) +#define g_atomic_int_exchange(atomic, newval) \ + (g_atomic_int_exchange ((gint *) (atomic), (newval))) +#define g_atomic_int_add(atomic, val) \ + (g_atomic_int_add ((gint *) (atomic), (val))) +#define g_atomic_int_and(atomic, val) \ + (g_atomic_int_and ((guint *) (atomic), (val))) +#define g_atomic_int_or(atomic, val) \ + (g_atomic_int_or ((guint *) (atomic), (val))) +#define g_atomic_int_xor(atomic, val) \ + (g_atomic_int_xor ((guint *) (atomic), (val))) +#define g_atomic_int_inc(atomic) \ + (g_atomic_int_inc ((gint *) (atomic))) +#define g_atomic_int_dec_and_test(atomic) \ + (g_atomic_int_dec_and_test ((gint *) (atomic))) + +#if defined(glib_typeof) + /* The (void *) cast in the middle *looks* redundant, because + * g_atomic_pointer_get returns void * already, but it's to silence + * -Werror=bad-function-cast when we're doing something like: + * guintptr a, b; ...; a = g_atomic_pointer_get (&b); + * which would otherwise be assigning the void * result of + * g_atomic_pointer_get directly to the pointer-sized but + * non-pointer-typed result. */ +#define g_atomic_pointer_get(atomic) \ + (glib_typeof (*(atomic))) (void *) ((g_atomic_pointer_get) ((void *) atomic)) +#else /* !(defined(glib_typeof) */ +#define g_atomic_pointer_get(atomic) \ + (g_atomic_pointer_get (atomic)) +#endif + +#define g_atomic_pointer_set(atomic, newval) \ + (g_atomic_pointer_set ((atomic), (gpointer) (newval))) + +#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ + (g_atomic_pointer_compare_and_exchange ((atomic), (gpointer) (oldval), (gpointer) (newval))) +#define g_atomic_pointer_compare_and_exchange_full(atomic, oldval, newval, prevval) \ + (g_atomic_pointer_compare_and_exchange_full ((atomic), (gpointer) (oldval), (gpointer) (newval), (prevval))) +#define g_atomic_pointer_exchange(atomic, newval) \ + (g_atomic_pointer_exchange ((atomic), (gpointer) (newval))) +#define g_atomic_pointer_add(atomic, val) \ + (g_atomic_pointer_add ((atomic), (gssize) (val))) +#define g_atomic_pointer_and(atomic, val) \ + (g_atomic_pointer_and ((atomic), (gsize) (val))) +#define g_atomic_pointer_or(atomic, val) \ + (g_atomic_pointer_or ((atomic), (gsize) (val))) +#define g_atomic_pointer_xor(atomic, val) \ + (g_atomic_pointer_xor ((atomic), (gsize) (val))) + +#endif /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */ + +#endif /* __G_ATOMIC_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gbacktrace.h b/illumos-x86_64/usr/include/glib-2.0/glib/gbacktrace.h new file mode 100644 index 00000000..11293b31 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gbacktrace.h @@ -0,0 +1,74 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_BACKTRACE_H__ +#define __G_BACKTRACE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#ifdef __sun__ +#include +#endif +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +void g_on_error_query (const gchar *prg_name); +GLIB_AVAILABLE_IN_ALL +void g_on_error_stack_trace (const gchar *prg_name); + +/** + * G_BREAKPOINT: + * + * Inserts a breakpoint instruction into the code. + * + * On architectures which support it, this is implemented as a soft interrupt + * and on other architectures it raises a `SIGTRAP` signal. + * + * `SIGTRAP` is used rather than abort() to allow breakpoints to be skipped past + * in a debugger if they are not the desired target of debugging. + */ +#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__) && __GNUC__ >= 2 +# define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END +#elif (defined (_MSC_VER) || defined (__DMC__)) && defined (_M_IX86) +# define G_BREAKPOINT() G_STMT_START{ __asm int 3h }G_STMT_END +#elif defined (_MSC_VER) +# define G_BREAKPOINT() G_STMT_START{ __debugbreak(); }G_STMT_END +#elif defined (__alpha__) && !defined(__osf__) && defined (__GNUC__) && __GNUC__ >= 2 +# define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("bpt"); }G_STMT_END +#elif defined (__APPLE__) || (defined(_WIN32) && (defined(__clang__) || defined(__GNUC__))) +# define G_BREAKPOINT() G_STMT_START{ __builtin_trap(); }G_STMT_END +#else /* !__i386__ && !__alpha__ */ +# define G_BREAKPOINT() G_STMT_START{ raise (SIGTRAP); }G_STMT_END +#endif /* __i386__ */ + +G_END_DECLS + +#endif /* __G_BACKTRACE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gbase64.h b/illumos-x86_64/usr/include/glib-2.0/glib/gbase64.h new file mode 100644 index 00000000..4cb9ef24 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gbase64.h @@ -0,0 +1,63 @@ +/* gbase64.h - Base64 coding functions + * + * Copyright (C) 2005 Alexander Larsson + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_BASE64_H__ +#define __G_BASE64_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gsize g_base64_encode_step (const guchar *in, + gsize len, + gboolean break_lines, + gchar *out, + gint *state, + gint *save); +GLIB_AVAILABLE_IN_ALL +gsize g_base64_encode_close (gboolean break_lines, + gchar *out, + gint *state, + gint *save); +GLIB_AVAILABLE_IN_ALL +gchar* g_base64_encode (const guchar *data, + gsize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gsize g_base64_decode_step (const gchar *in, + gsize len, + guchar *out, + gint *state, + guint *save); +GLIB_AVAILABLE_IN_ALL +guchar *g_base64_decode (const gchar *text, + gsize *out_len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +guchar *g_base64_decode_inplace (gchar *text, + gsize *out_len); + + +G_END_DECLS + +#endif /* __G_BASE64_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gbitlock.h b/illumos-x86_64/usr/include/glib-2.0/glib/gbitlock.h new file mode 100644 index 00000000..f44a52c3 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gbitlock.h @@ -0,0 +1,109 @@ +/* + * Copyright © 2008 Ryan Lortie + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_BITLOCK_H__ +#define __G_BITLOCK_H__ + +#include + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +void g_bit_lock (volatile gint *address, + gint lock_bit); +GLIB_AVAILABLE_IN_ALL +gboolean g_bit_trylock (volatile gint *address, + gint lock_bit); +GLIB_AVAILABLE_IN_ALL +void g_bit_unlock (volatile gint *address, + gint lock_bit); + +GLIB_AVAILABLE_IN_ALL +void g_pointer_bit_lock (volatile void *address, + gint lock_bit); + +GLIB_AVAILABLE_IN_2_80 +void g_pointer_bit_lock_and_get (gpointer address, + guint lock_bit, + guintptr *out_ptr); + +GLIB_AVAILABLE_IN_ALL +gboolean g_pointer_bit_trylock (volatile void *address, + gint lock_bit); +GLIB_AVAILABLE_IN_ALL +void g_pointer_bit_unlock (volatile void *address, + gint lock_bit); + +GLIB_AVAILABLE_IN_2_80 +gpointer g_pointer_bit_lock_mask_ptr (gpointer ptr, + guint lock_bit, + gboolean set, + guintptr preserve_mask, + gpointer preserve_ptr); + +GLIB_AVAILABLE_IN_2_80 +void g_pointer_bit_unlock_and_set (void *address, + guint lock_bit, + gpointer ptr, + guintptr preserve_mask); + +#ifdef __GNUC__ + +#define g_pointer_bit_lock(address, lock_bit) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ + g_pointer_bit_lock ((address), (lock_bit)); \ + })) + +#define g_pointer_bit_lock_and_get(address, lock_bit, out_ptr) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ + g_pointer_bit_lock_and_get ((address), (lock_bit), (out_ptr)); \ + })) + +#define g_pointer_bit_trylock(address, lock_bit) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ + g_pointer_bit_trylock ((address), (lock_bit)); \ + })) + +#define g_pointer_bit_unlock(address, lock_bit) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ + g_pointer_bit_unlock ((address), (lock_bit)); \ + })) + +#define g_pointer_bit_unlock_and_set(address, lock_bit, ptr, preserve_mask) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ + g_pointer_bit_unlock_and_set ((address), (lock_bit), (ptr), (preserve_mask)); \ + })) + +#endif + +G_END_DECLS + +#endif /* __G_BITLOCK_H_ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gbookmarkfile.h b/illumos-x86_64/usr/include/glib-2.0/glib/gbookmarkfile.h new file mode 100644 index 00000000..3c3271d1 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gbookmarkfile.h @@ -0,0 +1,338 @@ +/* gbookmarkfile.h: parsing and building desktop bookmarks + * + * Copyright (C) 2005-2006 Emmanuele Bassi + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_BOOKMARK_FILE_H__ +#define __G_BOOKMARK_FILE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +/** + * G_BOOKMARK_FILE_ERROR: + * + * Error domain for bookmark file parsing. + * + * Errors in this domain will be from the #GBookmarkFileError + * enumeration. See #GError for information on error domains. + */ +#define G_BOOKMARK_FILE_ERROR (g_bookmark_file_error_quark ()) + + +/** + * GBookmarkFileError: + * @G_BOOKMARK_FILE_ERROR_INVALID_URI: URI was ill-formed + * @G_BOOKMARK_FILE_ERROR_INVALID_VALUE: a requested field was not found + * @G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED: a requested application did + * not register a bookmark + * @G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND: a requested URI was not found + * @G_BOOKMARK_FILE_ERROR_READ: document was ill formed + * @G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was + * in an unknown encoding + * @G_BOOKMARK_FILE_ERROR_WRITE: an error occurred while writing + * @G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND: requested file was not found + * + * Error codes returned by bookmark file parsing. + */ +typedef enum +{ + G_BOOKMARK_FILE_ERROR_INVALID_URI, + G_BOOKMARK_FILE_ERROR_INVALID_VALUE, + G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED, + G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND, + G_BOOKMARK_FILE_ERROR_READ, + G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING, + G_BOOKMARK_FILE_ERROR_WRITE, + G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND +} GBookmarkFileError; + +GLIB_AVAILABLE_IN_ALL +GQuark g_bookmark_file_error_quark (void); + +/** + * GBookmarkFile: + * + * `GBookmarkFile` lets you parse, edit or create files containing bookmarks. + * + * Bookmarks refer to a URI, along with some meta-data about the resource + * pointed by the URI like its MIME type, the application that is registering + * the bookmark and the icon that should be used to represent the bookmark. + * The data is stored using the + * [Desktop Bookmark Specification](https://www.freedesktop.org/wiki/Specifications/desktop-bookmark-spec/). + * + * The syntax of the bookmark files is described in detail inside the + * Desktop Bookmark Specification, here is a quick summary: bookmark + * files use a sub-class of the XML Bookmark Exchange Language + * specification, consisting of valid UTF-8 encoded XML, under the + * `` root element; each bookmark is stored inside a + * `` element, using its URI: no relative paths can + * be used inside a bookmark file. The bookmark may have a user defined + * title and description, to be used instead of the URI. Under the + * `` element, with its owner attribute set to + * `http://freedesktop.org`, is stored the meta-data about a resource + * pointed by its URI. The meta-data consists of the resource's MIME + * type; the applications that have registered a bookmark; the groups + * to which a bookmark belongs to; a visibility flag, used to set the + * bookmark as "private" to the applications and groups that has it + * registered; the URI and MIME type of an icon, to be used when + * displaying the bookmark inside a GUI. + * + * Here is an example of a bookmark file: + * [bookmarks.xbel](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/glib/tests/bookmarks.xbel) + * + * A bookmark file might contain more than one bookmark; each bookmark + * is accessed through its URI. + * + * The important caveat of bookmark files is that when you add a new + * bookmark you must also add the application that is registering it, using + * [method@GLib.BookmarkFile.add_application] or [method@GLib.BookmarkFile.set_application_info]. + * If a bookmark has no applications then it won't be dumped when creating + * the on disk representation, using [method@GLib.BookmarkFile.to_data] or + * [method@GLib.BookmarkFile.to_file]. + * + * Since: 2.12 + */ +typedef struct _GBookmarkFile GBookmarkFile; + +GLIB_AVAILABLE_IN_ALL +GBookmarkFile *g_bookmark_file_new (void); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_free (GBookmarkFile *bookmark); + +GLIB_AVAILABLE_IN_2_76 +GBookmarkFile *g_bookmark_file_copy (GBookmarkFile *bookmark); + +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_load_from_file (GBookmarkFile *bookmark, + const gchar *filename, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_load_from_data (GBookmarkFile *bookmark, + const gchar *data, + gsize length, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_load_from_data_dirs (GBookmarkFile *bookmark, + const gchar *file, + gchar **full_path, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar * g_bookmark_file_to_data (GBookmarkFile *bookmark, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_to_file (GBookmarkFile *bookmark, + const gchar *filename, + GError **error); + +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_title (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *title); +GLIB_AVAILABLE_IN_ALL +gchar * g_bookmark_file_get_title (GBookmarkFile *bookmark, + const gchar *uri, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_description (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *description); +GLIB_AVAILABLE_IN_ALL +gchar * g_bookmark_file_get_description (GBookmarkFile *bookmark, + const gchar *uri, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_mime_type (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *mime_type); +GLIB_AVAILABLE_IN_ALL +gchar * g_bookmark_file_get_mime_type (GBookmarkFile *bookmark, + const gchar *uri, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_groups (GBookmarkFile *bookmark, + const gchar *uri, + const gchar **groups, + gsize length); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_add_group (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *group); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_has_group (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *group, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark, + const gchar *uri, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_add_application (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + const gchar *exec); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_has_application (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark, + const gchar *uri, + gsize *length, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_application_info) +gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + const gchar *exec, + gint count, + time_t stamp, + GError **error); +GLIB_AVAILABLE_IN_2_66 +gboolean g_bookmark_file_set_application_info (GBookmarkFile *bookmark, + const char *uri, + const char *name, + const char *exec, + int count, + GDateTime *stamp, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_application_info) +gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + gchar **exec, + guint *count, + time_t *stamp, + GError **error); +GLIB_AVAILABLE_IN_2_66 +gboolean g_bookmark_file_get_application_info (GBookmarkFile *bookmark, + const char *uri, + const char *name, + char **exec, + unsigned int *count, + GDateTime **stamp, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_is_private (GBookmarkFile *bookmark, + const gchar *uri, + gboolean is_private); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_icon (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *href, + const gchar *mime_type); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark, + const gchar *uri, + gchar **href, + gchar **mime_type, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_added_date_time) +void g_bookmark_file_set_added (GBookmarkFile *bookmark, + const gchar *uri, + time_t added); +GLIB_AVAILABLE_IN_2_66 +void g_bookmark_file_set_added_date_time (GBookmarkFile *bookmark, + const char *uri, + GDateTime *added); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_added_date_time) +time_t g_bookmark_file_get_added (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_2_66 +GDateTime *g_bookmark_file_get_added_date_time (GBookmarkFile *bookmark, + const char *uri, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_modified_date_time) +void g_bookmark_file_set_modified (GBookmarkFile *bookmark, + const gchar *uri, + time_t modified); +GLIB_AVAILABLE_IN_2_66 +void g_bookmark_file_set_modified_date_time (GBookmarkFile *bookmark, + const char *uri, + GDateTime *modified); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_modified_date_time) +time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_2_66 +GDateTime *g_bookmark_file_get_modified_date_time (GBookmarkFile *bookmark, + const char *uri, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_visited_date_time) +void g_bookmark_file_set_visited (GBookmarkFile *bookmark, + const gchar *uri, + time_t visited); +GLIB_AVAILABLE_IN_2_66 +void g_bookmark_file_set_visited_date_time (GBookmarkFile *bookmark, + const char *uri, + GDateTime *visited); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_visited_date_time) +time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_2_66 +GDateTime *g_bookmark_file_get_visited_date_time (GBookmarkFile *bookmark, + const char *uri, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark, + const gchar *uri); +GLIB_AVAILABLE_IN_ALL +gint g_bookmark_file_get_size (GBookmarkFile *bookmark); +GLIB_AVAILABLE_IN_ALL +gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *group, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark, + const gchar *old_uri, + const gchar *new_uri, + GError **error); + +G_END_DECLS + +#endif /* __G_BOOKMARK_FILE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gbytes.h b/illumos-x86_64/usr/include/glib-2.0/glib/gbytes.h new file mode 100644 index 00000000..d9349894 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gbytes.h @@ -0,0 +1,99 @@ +/* + * Copyright © 2009, 2010 Codethink Limited + * Copyright © 2011 Collabora Ltd. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + * Stef Walter + */ + +#ifndef __G_BYTES_H__ +#define __G_BYTES_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new (gconstpointer data, + gsize size); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new_take (gpointer data, + gsize size); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new_static (gconstpointer data, + gsize size); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new_with_free_func (gconstpointer data, + gsize size, + GDestroyNotify free_func, + gpointer user_data); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new_from_bytes (GBytes *bytes, + gsize offset, + gsize length); + +GLIB_AVAILABLE_IN_ALL +gconstpointer g_bytes_get_data (GBytes *bytes, + gsize *size); + +GLIB_AVAILABLE_IN_ALL +gsize g_bytes_get_size (GBytes *bytes); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_ref (GBytes *bytes); + +GLIB_AVAILABLE_IN_ALL +void g_bytes_unref (GBytes *bytes); + +GLIB_AVAILABLE_IN_ALL +gpointer g_bytes_unref_to_data (GBytes *bytes, + gsize *size); + +GLIB_AVAILABLE_IN_ALL +GByteArray * g_bytes_unref_to_array (GBytes *bytes); + +GLIB_AVAILABLE_IN_ALL +guint g_bytes_hash (gconstpointer bytes); + +GLIB_AVAILABLE_IN_ALL +gboolean g_bytes_equal (gconstpointer bytes1, + gconstpointer bytes2); + +GLIB_AVAILABLE_IN_ALL +gint g_bytes_compare (gconstpointer bytes1, + gconstpointer bytes2); + +GLIB_AVAILABLE_IN_2_70 +gconstpointer g_bytes_get_region (GBytes *bytes, + gsize element_size, + gsize offset, + gsize n_elements); + + +G_END_DECLS + +#endif /* __G_BYTES_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gcharset.h b/illumos-x86_64/usr/include/glib-2.0/glib/gcharset.h new file mode 100644 index 00000000..144ec7a0 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gcharset.h @@ -0,0 +1,49 @@ +/* gcharset.h - Charset functions + * + * Copyright (C) 2011 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_CHARSET_H__ +#define __G_CHARSET_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gboolean g_get_charset (const char **charset); +GLIB_AVAILABLE_IN_ALL +gchar * g_get_codeset (void); +GLIB_AVAILABLE_IN_2_62 +gboolean g_get_console_charset (const char **charset); + +GLIB_AVAILABLE_IN_ALL +const gchar * const * g_get_language_names (void); +GLIB_AVAILABLE_IN_2_58 +const gchar * const * g_get_language_names_with_category + (const gchar *category_name); +GLIB_AVAILABLE_IN_ALL +gchar ** g_get_locale_variants (const gchar *locale); + +G_END_DECLS + +#endif /* __G_CHARSET_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gchecksum.h b/illumos-x86_64/usr/include/glib-2.0/glib/gchecksum.h new file mode 100644 index 00000000..3dd84fd8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gchecksum.h @@ -0,0 +1,96 @@ +/* gchecksum.h - data hashing functions + * + * Copyright (C) 2007 Emmanuele Bassi + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_CHECKSUM_H__ +#define __G_CHECKSUM_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/** + * GChecksumType: + * @G_CHECKSUM_MD5: Use the MD5 hashing algorithm + * @G_CHECKSUM_SHA1: Use the SHA-1 hashing algorithm + * @G_CHECKSUM_SHA256: Use the SHA-256 hashing algorithm + * @G_CHECKSUM_SHA384: Use the SHA-384 hashing algorithm (Since: 2.51) + * @G_CHECKSUM_SHA512: Use the SHA-512 hashing algorithm (Since: 2.36) + * + * The hashing algorithm to be used by #GChecksum when performing the + * digest of some data. + * + * Note that the #GChecksumType enumeration may be extended at a later + * date to include new hashing algorithm types. + * + * Since: 2.16 + */ +typedef enum { + G_CHECKSUM_MD5, + G_CHECKSUM_SHA1, + G_CHECKSUM_SHA256, + G_CHECKSUM_SHA512, + G_CHECKSUM_SHA384 +} GChecksumType; + +typedef struct _GChecksum GChecksum; + +GLIB_AVAILABLE_IN_ALL +gssize g_checksum_type_get_length (GChecksumType checksum_type); + +GLIB_AVAILABLE_IN_ALL +GChecksum * g_checksum_new (GChecksumType checksum_type); +GLIB_AVAILABLE_IN_ALL +void g_checksum_reset (GChecksum *checksum); +GLIB_AVAILABLE_IN_ALL +GChecksum * g_checksum_copy (const GChecksum *checksum); +GLIB_AVAILABLE_IN_ALL +void g_checksum_free (GChecksum *checksum); +GLIB_AVAILABLE_IN_ALL +void g_checksum_update (GChecksum *checksum, + const guchar *data, + gssize length); +GLIB_AVAILABLE_IN_ALL +const gchar * g_checksum_get_string (GChecksum *checksum); +GLIB_AVAILABLE_IN_ALL +void g_checksum_get_digest (GChecksum *checksum, + guint8 *buffer, + gsize *digest_len); + +GLIB_AVAILABLE_IN_ALL +gchar *g_compute_checksum_for_data (GChecksumType checksum_type, + const guchar *data, + gsize length); +GLIB_AVAILABLE_IN_ALL +gchar *g_compute_checksum_for_string (GChecksumType checksum_type, + const gchar *str, + gssize length); + +GLIB_AVAILABLE_IN_2_34 +gchar *g_compute_checksum_for_bytes (GChecksumType checksum_type, + GBytes *data); + +G_END_DECLS + +#endif /* __G_CHECKSUM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gconvert.h b/illumos-x86_64/usr/include/glib-2.0/glib/gconvert.h new file mode 100644 index 00000000..81b41c04 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gconvert.h @@ -0,0 +1,179 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_CONVERT_H__ +#define __G_CONVERT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * GConvertError: + * @G_CONVERT_ERROR_NO_CONVERSION: Conversion between the requested character + * sets is not supported. + * @G_CONVERT_ERROR_ILLEGAL_SEQUENCE: Invalid byte sequence in conversion input; + * or the character sequence could not be represented in the target + * character set. + * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason. + * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input. + * @G_CONVERT_ERROR_BAD_URI: URI is invalid. + * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path. + * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40 + * @G_CONVERT_ERROR_EMBEDDED_NUL: An embedded NUL character is present in + * conversion output where a NUL-terminated string is expected. + * Since: 2.56 + * + * Error codes returned by character set conversion routines. + */ +typedef enum +{ + G_CONVERT_ERROR_NO_CONVERSION, + G_CONVERT_ERROR_ILLEGAL_SEQUENCE, + G_CONVERT_ERROR_FAILED, + G_CONVERT_ERROR_PARTIAL_INPUT, + G_CONVERT_ERROR_BAD_URI, + G_CONVERT_ERROR_NOT_ABSOLUTE_PATH, + G_CONVERT_ERROR_NO_MEMORY, + G_CONVERT_ERROR_EMBEDDED_NUL +} GConvertError; + +/** + * G_CONVERT_ERROR: + * + * Error domain for character set conversions. Errors in this domain will + * be from the #GConvertError enumeration. See #GError for information on + * error domains. + */ +#define G_CONVERT_ERROR g_convert_error_quark() +GLIB_AVAILABLE_IN_ALL +GQuark g_convert_error_quark (void); + +/** + * GIConv: (skip) + * + * The GIConv struct wraps an iconv() conversion descriptor. It contains + * private data and should only be accessed using the following functions. + */ +typedef struct _GIConv *GIConv; + +GLIB_AVAILABLE_IN_ALL +GIConv g_iconv_open (const gchar *to_codeset, + const gchar *from_codeset); +GLIB_AVAILABLE_IN_ALL +gsize g_iconv (GIConv converter, + gchar **inbuf, + gsize *inbytes_left, + gchar **outbuf, + gsize *outbytes_left); +GLIB_AVAILABLE_IN_ALL +gint g_iconv_close (GIConv converter); + + +GLIB_AVAILABLE_IN_ALL +gchar* g_convert (const gchar *str, + gssize len, + const gchar *to_codeset, + const gchar *from_codeset, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_convert_with_iconv (const gchar *str, + gssize len, + GIConv converter, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_convert_with_fallback (const gchar *str, + gssize len, + const gchar *to_codeset, + const gchar *from_codeset, + const gchar *fallback, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; + + +/* Convert between libc's idea of strings and UTF-8. + */ +GLIB_AVAILABLE_IN_ALL +gchar* g_locale_to_utf8 (const gchar *opsysstring, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_locale_from_utf8 (const gchar *utf8string, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; + +/* Convert between the operating system (or C runtime) + * representation of file names and UTF-8. + */ +GLIB_AVAILABLE_IN_ALL +gchar* g_filename_to_utf8 (const gchar *opsysstring, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_filename_from_utf8 (const gchar *utf8string, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar *g_filename_from_uri (const gchar *uri, + gchar **hostname, + GError **error) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar *g_filename_to_uri (const gchar *filename, + const gchar *hostname, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gboolean g_get_filename_charsets (const gchar ***filename_charsets); + +GLIB_AVAILABLE_IN_ALL +gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar **g_uri_list_extract_uris (const gchar *uri_list); + +G_END_DECLS + +#endif /* __G_CONVERT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gdataset.h b/illumos-x86_64/usr/include/glib-2.0/glib/gdataset.h new file mode 100644 index 00000000..a0d44b09 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gdataset.h @@ -0,0 +1,156 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_DATASET_H__ +#define __G_DATASET_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GData GData; + +typedef void (*GDataForeachFunc) (GQuark key_id, + gpointer data, + gpointer user_data); + +/* Keyed Data List + */ +GLIB_AVAILABLE_IN_ALL +void g_datalist_init (GData **datalist); +GLIB_AVAILABLE_IN_ALL +void g_datalist_clear (GData **datalist); +GLIB_AVAILABLE_IN_ALL +gpointer g_datalist_id_get_data (GData **datalist, + GQuark key_id); +GLIB_AVAILABLE_IN_ALL +void g_datalist_id_set_data_full (GData **datalist, + GQuark key_id, + gpointer data, + GDestroyNotify destroy_func); +GLIB_AVAILABLE_IN_2_74 +void g_datalist_id_remove_multiple (GData **datalist, + GQuark *keys, + gsize n_keys); + +typedef gpointer (*GDuplicateFunc) (gpointer data, gpointer user_data); + +GLIB_AVAILABLE_IN_2_34 +gpointer g_datalist_id_dup_data (GData **datalist, + GQuark key_id, + GDuplicateFunc dup_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_34 +gboolean g_datalist_id_replace_data (GData **datalist, + GQuark key_id, + gpointer oldval, + gpointer newval, + GDestroyNotify destroy, + GDestroyNotify *old_destroy); + +GLIB_AVAILABLE_IN_ALL +gpointer g_datalist_id_remove_no_notify (GData **datalist, + GQuark key_id); +GLIB_AVAILABLE_IN_ALL +void g_datalist_foreach (GData **datalist, + GDataForeachFunc func, + gpointer user_data); + +/** + * G_DATALIST_FLAGS_MASK: + * + * A bitmask that restricts the possible flags passed to + * g_datalist_set_flags(). Passing a flags value where + * flags & ~G_DATALIST_FLAGS_MASK != 0 is an error. + */ +#define G_DATALIST_FLAGS_MASK 0x3 + +GLIB_AVAILABLE_IN_ALL +void g_datalist_set_flags (GData **datalist, + guint flags); +GLIB_AVAILABLE_IN_ALL +void g_datalist_unset_flags (GData **datalist, + guint flags); +GLIB_AVAILABLE_IN_ALL +guint g_datalist_get_flags (GData **datalist); + +#define g_datalist_id_set_data(dl, q, d) \ + g_datalist_id_set_data_full ((dl), (q), (d), NULL) +#define g_datalist_id_remove_data(dl, q) \ + g_datalist_id_set_data ((dl), (q), NULL) +#define g_datalist_set_data_full(dl, k, d, f) \ + g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f)) +#define g_datalist_remove_no_notify(dl, k) \ + g_datalist_id_remove_no_notify ((dl), g_quark_try_string (k)) +#define g_datalist_set_data(dl, k, d) \ + g_datalist_set_data_full ((dl), (k), (d), NULL) +#define g_datalist_remove_data(dl, k) \ + g_datalist_id_set_data ((dl), g_quark_try_string (k), NULL) + +/* Location Associated Keyed Data + */ +GLIB_AVAILABLE_IN_ALL +void g_dataset_destroy (gconstpointer dataset_location); +GLIB_AVAILABLE_IN_ALL +gpointer g_dataset_id_get_data (gconstpointer dataset_location, + GQuark key_id); +GLIB_AVAILABLE_IN_ALL +gpointer g_datalist_get_data (GData **datalist, + const gchar *key); +GLIB_AVAILABLE_IN_ALL +void g_dataset_id_set_data_full (gconstpointer dataset_location, + GQuark key_id, + gpointer data, + GDestroyNotify destroy_func); +GLIB_AVAILABLE_IN_ALL +gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, + GQuark key_id); +GLIB_AVAILABLE_IN_ALL +void g_dataset_foreach (gconstpointer dataset_location, + GDataForeachFunc func, + gpointer user_data); +#define g_dataset_id_set_data(l, k, d) \ + g_dataset_id_set_data_full ((l), (k), (d), NULL) +#define g_dataset_id_remove_data(l, k) \ + g_dataset_id_set_data ((l), (k), NULL) +#define g_dataset_get_data(l, k) \ + (g_dataset_id_get_data ((l), g_quark_try_string (k))) +#define g_dataset_set_data_full(l, k, d, f) \ + g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f)) +#define g_dataset_remove_no_notify(l, k) \ + g_dataset_id_remove_no_notify ((l), g_quark_try_string (k)) +#define g_dataset_set_data(l, k, d) \ + g_dataset_set_data_full ((l), (k), (d), NULL) +#define g_dataset_remove_data(l, k) \ + g_dataset_id_set_data ((l), g_quark_try_string (k), NULL) + +G_END_DECLS + +#endif /* __G_DATASET_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gdate.h b/illumos-x86_64/usr/include/glib-2.0/glib/gdate.h new file mode 100644 index 00000000..35a2e912 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gdate.h @@ -0,0 +1,300 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_DATE_H__ +#define __G_DATE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#include +#include + +G_BEGIN_DECLS + +typedef gint32 GTime GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); +typedef guint16 GDateYear; +typedef guint8 GDateDay; /* day of the month */ +typedef struct _GDate GDate; + +/* enum used to specify order of appearance in parsed date strings */ +typedef enum +{ + G_DATE_DAY = 0, + G_DATE_MONTH = 1, + G_DATE_YEAR = 2 +} GDateDMY; + +/* actual week and month values */ +typedef enum +{ + G_DATE_BAD_WEEKDAY = 0, + G_DATE_MONDAY = 1, + G_DATE_TUESDAY = 2, + G_DATE_WEDNESDAY = 3, + G_DATE_THURSDAY = 4, + G_DATE_FRIDAY = 5, + G_DATE_SATURDAY = 6, + G_DATE_SUNDAY = 7 +} GDateWeekday; +typedef enum +{ + G_DATE_BAD_MONTH = 0, + G_DATE_JANUARY = 1, + G_DATE_FEBRUARY = 2, + G_DATE_MARCH = 3, + G_DATE_APRIL = 4, + G_DATE_MAY = 5, + G_DATE_JUNE = 6, + G_DATE_JULY = 7, + G_DATE_AUGUST = 8, + G_DATE_SEPTEMBER = 9, + G_DATE_OCTOBER = 10, + G_DATE_NOVEMBER = 11, + G_DATE_DECEMBER = 12 +} GDateMonth; + +#define G_DATE_BAD_JULIAN 0U +#define G_DATE_BAD_DAY 0U +#define G_DATE_BAD_YEAR 0U + +/* Note: directly manipulating structs is generally a bad idea, but + * in this case it's an *incredibly* bad idea, because all or part + * of this struct can be invalid at any given time. Use the functions, + * or you will get hosed, I promise. + */ +struct _GDate +{ + guint julian_days : 32; /* julian days representation - we use a + * bitfield hoping that 64 bit platforms + * will pack this whole struct in one big + * int + */ + + guint julian : 1; /* julian is valid */ + guint dmy : 1; /* dmy is valid */ + + /* DMY representation */ + guint day : 6; + guint month : 4; + guint year : 16; +}; + +/* g_date_new() returns an invalid date, you then have to _set() stuff + * to get a usable object. You can also allocate a GDate statically, + * then call g_date_clear() to initialize. + */ +GLIB_AVAILABLE_IN_ALL +GDate* g_date_new (void); +GLIB_AVAILABLE_IN_ALL +GDate* g_date_new_dmy (GDateDay day, + GDateMonth month, + GDateYear year); +GLIB_AVAILABLE_IN_ALL +GDate* g_date_new_julian (guint32 julian_day); +GLIB_AVAILABLE_IN_ALL +void g_date_free (GDate *date); +GLIB_AVAILABLE_IN_2_56 +GDate* g_date_copy (const GDate *date); + +/* check g_date_valid() after doing an operation that might fail, like + * _parse. Almost all g_date operations are undefined on invalid + * dates (the exceptions are the mutators, since you need those to + * return to validity). + */ +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid (const GDate *date); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_day (GDateDay day) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_month (GDateMonth month) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_year (GDateYear year) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_weekday (GDateWeekday weekday) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_julian (guint32 julian_date) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_dmy (GDateDay day, + GDateMonth month, + GDateYear year) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +GDateWeekday g_date_get_weekday (const GDate *date); +GLIB_AVAILABLE_IN_ALL +GDateMonth g_date_get_month (const GDate *date); +GLIB_AVAILABLE_IN_ALL +GDateYear g_date_get_year (const GDate *date); +GLIB_AVAILABLE_IN_ALL +GDateDay g_date_get_day (const GDate *date); +GLIB_AVAILABLE_IN_ALL +guint32 g_date_get_julian (const GDate *date); +GLIB_AVAILABLE_IN_ALL +guint g_date_get_day_of_year (const GDate *date); +/* First monday/sunday is the start of week 1; if we haven't reached + * that day, return 0. These are not ISO weeks of the year; that + * routine needs to be added. + * these functions return the number of weeks, starting on the + * corresponding day + */ +GLIB_AVAILABLE_IN_ALL +guint g_date_get_monday_week_of_year (const GDate *date); +GLIB_AVAILABLE_IN_ALL +guint g_date_get_sunday_week_of_year (const GDate *date); +GLIB_AVAILABLE_IN_ALL +guint g_date_get_iso8601_week_of_year (const GDate *date); + +/* If you create a static date struct you need to clear it to get it + * in a safe state before use. You can clear a whole array at + * once with the ndates argument. + */ +GLIB_AVAILABLE_IN_ALL +void g_date_clear (GDate *date, + guint n_dates); + +/* The parse routine is meant for dates typed in by a user, so it + * permits many formats but tries to catch common typos. If your data + * needs to be strictly validated, it is not an appropriate function. + */ +GLIB_AVAILABLE_IN_ALL +void g_date_set_parse (GDate *date, + const gchar *str); +GLIB_AVAILABLE_IN_ALL +void g_date_set_time_t (GDate *date, + time_t timet); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62_FOR(g_date_set_time_t) +void g_date_set_time_val (GDate *date, + GTimeVal *timeval); +GLIB_DEPRECATED_FOR(g_date_set_time_t) +void g_date_set_time (GDate *date, + GTime time_); +G_GNUC_END_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_ALL +void g_date_set_month (GDate *date, + GDateMonth month); +GLIB_AVAILABLE_IN_ALL +void g_date_set_day (GDate *date, + GDateDay day); +GLIB_AVAILABLE_IN_ALL +void g_date_set_year (GDate *date, + GDateYear year); +GLIB_AVAILABLE_IN_ALL +void g_date_set_dmy (GDate *date, + GDateDay day, + GDateMonth month, + GDateYear y); +GLIB_AVAILABLE_IN_ALL +void g_date_set_julian (GDate *date, + guint32 julian_date); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_is_first_of_month (const GDate *date); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_is_last_of_month (const GDate *date); + +/* To go forward by some number of weeks just go forward weeks*7 days */ +GLIB_AVAILABLE_IN_ALL +void g_date_add_days (GDate *date, + guint n_days); +GLIB_AVAILABLE_IN_ALL +void g_date_subtract_days (GDate *date, + guint n_days); + +/* If you add/sub months while day > 28, the day might change */ +GLIB_AVAILABLE_IN_ALL +void g_date_add_months (GDate *date, + guint n_months); +GLIB_AVAILABLE_IN_ALL +void g_date_subtract_months (GDate *date, + guint n_months); + +/* If it's feb 29, changing years can move you to the 28th */ +GLIB_AVAILABLE_IN_ALL +void g_date_add_years (GDate *date, + guint n_years); +GLIB_AVAILABLE_IN_ALL +void g_date_subtract_years (GDate *date, + guint n_years); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +guint8 g_date_get_days_in_month (GDateMonth month, + GDateYear year) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST; + +/* Returns the number of days between the two dates. If date2 comes + before date1, a negative value is return. */ +GLIB_AVAILABLE_IN_ALL +gint g_date_days_between (const GDate *date1, + const GDate *date2); + +/* qsort-friendly (with a cast...) */ +GLIB_AVAILABLE_IN_ALL +gint g_date_compare (const GDate *lhs, + const GDate *rhs); +GLIB_AVAILABLE_IN_ALL +void g_date_to_struct_tm (const GDate *date, + struct tm *tm); + +GLIB_AVAILABLE_IN_ALL +void g_date_clamp (GDate *date, + const GDate *min_date, + const GDate *max_date); + +/* Swap date1 and date2's values if date1 > date2. */ +GLIB_AVAILABLE_IN_ALL +void g_date_order (GDate *date1, GDate *date2); + +/* Just like strftime() except you can only use date-related formats. + * Using a time format is undefined. + */ +GLIB_AVAILABLE_IN_ALL +gsize g_date_strftime (gchar *s, + gsize slen, + const gchar *format, + const GDate *date); + +#define g_date_weekday g_date_get_weekday GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_weekday) +#define g_date_month g_date_get_month GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_month) +#define g_date_year g_date_get_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_year) +#define g_date_day g_date_get_day GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_day) +#define g_date_julian g_date_get_julian GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_julian) +#define g_date_day_of_year g_date_get_day_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_day_of_year) +#define g_date_monday_week_of_year g_date_get_monday_week_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_monday_week_of_year) +#define g_date_sunday_week_of_year g_date_get_sunday_week_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_sunday_week_of_year) +#define g_date_days_in_month g_date_get_days_in_month GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_days_in_month) +#define g_date_monday_weeks_in_year g_date_get_monday_weeks_in_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_monday_weeks_in_year) +#define g_date_sunday_weeks_in_year g_date_get_sunday_weeks_in_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_sunday_weeks_in_year) + +G_END_DECLS + +#endif /* __G_DATE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gdatetime.h b/illumos-x86_64/usr/include/glib-2.0/glib/gdatetime.h new file mode 100644 index 00000000..846d22ca --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gdatetime.h @@ -0,0 +1,307 @@ +/* + * Copyright (C) 2009-2010 Christian Hergert + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * licence, or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + * + * Authors: Christian Hergert + * Thiago Santos + * Emmanuele Bassi + * Ryan Lortie + */ + +#ifndef __G_DATE_TIME_H__ +#define __G_DATE_TIME_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_TIME_SPAN_DAY: + * + * Evaluates to a time span of one day. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000)) + +/** + * G_TIME_SPAN_HOUR: + * + * Evaluates to a time span of one hour. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000)) + +/** + * G_TIME_SPAN_MINUTE: + * + * Evaluates to a time span of one minute. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000)) + +/** + * G_TIME_SPAN_SECOND: + * + * Evaluates to a time span of one second. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000)) + +/** + * G_TIME_SPAN_MILLISECOND: + * + * Evaluates to a time span of one millisecond. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000)) + +/** + * GTimeSpan: + * + * A value representing an interval of time, in microseconds. + * + * Since: 2.26 + */ +typedef gint64 GTimeSpan; + +/** + * GDateTime: + * + * `GDateTime` is a structure that combines a Gregorian date and time + * into a single structure. + * + * `GDateTime` provides many conversion and methods to manipulate dates and times. + * Time precision is provided down to microseconds and the time can range + * (proleptically) from 0001-01-01 00:00:00 to 9999-12-31 23:59:59.999999. + * `GDateTime` follows POSIX time in the sense that it is oblivious to leap + * seconds. + * + * `GDateTime` is an immutable object; once it has been created it cannot + * be modified further. All modifiers will create a new `GDateTime`. + * Nearly all such functions can fail due to the date or time going out + * of range, in which case %NULL will be returned. + * + * `GDateTime` is reference counted: the reference count is increased by calling + * [method@GLib.DateTime.ref] and decreased by calling [method@GLib.DateTime.unref]. + * When the reference count drops to 0, the resources allocated by the `GDateTime` + * structure are released. + * + * Many parts of the API may produce non-obvious results. As an + * example, adding two months to January 31st will yield March 31st + * whereas adding one month and then one month again will yield either + * March 28th or March 29th. Also note that adding 24 hours is not + * always the same as adding one day (since days containing daylight + * savings time transitions are either 23 or 25 hours in length). + * + * Since: 2.26 + */ +typedef struct _GDateTime GDateTime; + +GLIB_AVAILABLE_IN_ALL +void g_date_time_unref (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_ref (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_now (GTimeZone *tz); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_now_local (void); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_now_utc (void); + +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_from_unix_local (gint64 t); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_from_unix_utc (gint64 t); + +GLIB_AVAILABLE_IN_2_80 +GDateTime * g_date_time_new_from_unix_local_usec (gint64 usecs); +GLIB_AVAILABLE_IN_2_80 +GDateTime * g_date_time_new_from_unix_utc_usec (gint64 usecs); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_local) +GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv); +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_utc) +GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_2_56 +GDateTime * g_date_time_new_from_iso8601 (const gchar *text, + GTimeZone *default_tz); + +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new (GTimeZone *tz, + gint year, + gint month, + gint day, + gint hour, + gint minute, + gdouble seconds); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_local (gint year, + gint month, + gint day, + gint hour, + gint minute, + gdouble seconds); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_utc (gint year, + gint month, + gint day, + gint hour, + gint minute, + gdouble seconds); + +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add (GDateTime *datetime, + GTimeSpan timespan); + +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_years (GDateTime *datetime, + gint years); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_months (GDateTime *datetime, + gint months); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_weeks (GDateTime *datetime, + gint weeks); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_days (GDateTime *datetime, + gint days); + +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_hours (GDateTime *datetime, + gint hours); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_minutes (GDateTime *datetime, + gint minutes); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_seconds (GDateTime *datetime, + gdouble seconds); + +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_full (GDateTime *datetime, + gint years, + gint months, + gint days, + gint hours, + gint minutes, + gdouble seconds); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_compare (gconstpointer dt1, + gconstpointer dt2); +GLIB_AVAILABLE_IN_ALL +GTimeSpan g_date_time_difference (GDateTime *end, + GDateTime *begin); +GLIB_AVAILABLE_IN_ALL +guint g_date_time_hash (gconstpointer datetime); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_time_equal (gconstpointer dt1, + gconstpointer dt2); + +GLIB_AVAILABLE_IN_ALL +void g_date_time_get_ymd (GDateTime *datetime, + gint *year, + gint *month, + gint *day); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_year (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_month (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_day_of_month (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_week_numbering_year (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_week_of_year (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_day_of_week (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_day_of_year (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_hour (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_minute (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_second (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_microsecond (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gdouble g_date_time_get_seconds (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gint64 g_date_time_to_unix (GDateTime *datetime); +GLIB_AVAILABLE_IN_2_80 +gint64 g_date_time_to_unix_usec (GDateTime *datetime); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_to_unix) +gboolean g_date_time_to_timeval (GDateTime *datetime, + GTimeVal *tv); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime); +GLIB_AVAILABLE_IN_2_58 +GTimeZone * g_date_time_get_timezone (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +const gchar * g_date_time_get_timezone_abbreviation (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_time_is_daylight_savings (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_to_timezone (GDateTime *datetime, + GTimeZone *tz); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_to_local (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_to_utc (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gchar * g_date_time_format (GDateTime *datetime, + const gchar *format) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_62 +gchar * g_date_time_format_iso8601 (GDateTime *datetime) G_GNUC_MALLOC; + +G_END_DECLS + +#endif /* __G_DATE_TIME_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gdir.h b/illumos-x86_64/usr/include/glib-2.0/glib/gdir.h new file mode 100644 index 00000000..1b59b276 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gdir.h @@ -0,0 +1,59 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * gdir.c: Simplified wrapper around the DIRENT functions. + * + * Copyright 2001 Hans Breuer + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_DIR_H__ +#define __G_DIR_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#ifdef G_OS_UNIX +#include +#endif + +G_BEGIN_DECLS + +typedef struct _GDir GDir; + +GLIB_AVAILABLE_IN_ALL +GDir * g_dir_open (const gchar *path, + guint flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +const gchar * g_dir_read_name (GDir *dir); +GLIB_AVAILABLE_IN_ALL +void g_dir_rewind (GDir *dir); +GLIB_AVAILABLE_IN_ALL +void g_dir_close (GDir *dir); + +GLIB_AVAILABLE_IN_2_80 +GDir * g_dir_ref (GDir *dir); +GLIB_AVAILABLE_IN_2_80 +void g_dir_unref (GDir *dir); + +G_END_DECLS + +#endif /* __G_DIR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/genviron.h b/illumos-x86_64/usr/include/glib-2.0/glib/genviron.h new file mode 100644 index 00000000..3ac38464 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/genviron.h @@ -0,0 +1,65 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_ENVIRON_H__ +#define __G_ENVIRON_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +const gchar * g_getenv (const gchar *variable); +GLIB_AVAILABLE_IN_ALL +gboolean g_setenv (const gchar *variable, + const gchar *value, + gboolean overwrite); +GLIB_AVAILABLE_IN_ALL +void g_unsetenv (const gchar *variable); +GLIB_AVAILABLE_IN_ALL +gchar ** g_listenv (void); + +GLIB_AVAILABLE_IN_ALL +gchar ** g_get_environ (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_environ_getenv (gchar **envp, + const gchar *variable); +GLIB_AVAILABLE_IN_ALL +gchar ** g_environ_setenv (gchar **envp, + const gchar *variable, + const gchar *value, + gboolean overwrite) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gchar ** g_environ_unsetenv (gchar **envp, + const gchar *variable) G_GNUC_WARN_UNUSED_RESULT; + +G_END_DECLS + +#endif /* __G_ENVIRON_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gerror.h b/illumos-x86_64/usr/include/glib-2.0/glib/gerror.h new file mode 100644 index 00000000..2d5527cc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gerror.h @@ -0,0 +1,263 @@ +/* gerror.h - Error reporting system + * + * Copyright 2000 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_ERROR_H__ +#define __G_ERROR_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#include + +G_BEGIN_DECLS + +/** + * GError: + * @domain: error domain, e.g. %G_FILE_ERROR + * @code: error code, e.g. %G_FILE_ERROR_NOENT + * @message: human-readable informative error message + * + * The `GError` structure contains information about + * an error that has occurred. + */ +typedef struct _GError GError; + +struct _GError +{ + GQuark domain; + gint code; + gchar *message; +}; + +/** + * G_DEFINE_EXTENDED_ERROR: + * @ErrorType: name to return a #GQuark for + * @error_type: prefix for the function name + * + * A convenience macro which defines two functions. First, returning + * the #GQuark for the extended error type @ErrorType; it is called + * `error_type_quark()`. Second, returning the private data from a + * passed #GError; it is called `error_type_get_private()`. + * + * For this macro to work, a type named `ErrorTypePrivate` should be + * defined, `error_type_private_init()`, `error_type_private_copy()` + * and `error_type_private_clear()` functions need to be either + * declared or defined. The functions should be similar to + * #GErrorInitFunc, #GErrorCopyFunc and #GErrorClearFunc, + * respectively, but they should receive the private data type instead + * of #GError. + * + * See [Extended #GError Domains](error-reporting.html#extended-gerror-domains) for an example. + * + * Since: 2.68 + */ +#define G_DEFINE_EXTENDED_ERROR(ErrorType, error_type) \ +static inline ErrorType ## Private * \ +error_type ## _get_private (const GError *error) \ +{ \ + /* Copied from gtype.c (STRUCT_ALIGNMENT and ALIGN_STRUCT macros). */ \ + const gsize sa = 2 * sizeof (gsize); \ + const gsize as = (sizeof (ErrorType ## Private) + (sa - 1)) & -sa; \ + g_return_val_if_fail (error != NULL, NULL); \ + g_return_val_if_fail (error->domain == error_type ## _quark (), NULL); \ + return (ErrorType ## Private *) (((guint8 *)error) - as); \ +} \ + \ +static void \ +g_error_with_ ## error_type ## _private_init (GError *error) \ +{ \ + ErrorType ## Private *priv = error_type ## _get_private (error); \ + error_type ## _private_init (priv); \ +} \ + \ +static void \ +g_error_with_ ## error_type ## _private_copy (const GError *src_error, \ + GError *dest_error) \ +{ \ + const ErrorType ## Private *src_priv = error_type ## _get_private (src_error); \ + ErrorType ## Private *dest_priv = error_type ## _get_private (dest_error); \ + error_type ## _private_copy (src_priv, dest_priv); \ +} \ + \ +static void \ +g_error_with_ ## error_type ## _private_clear (GError *error) \ +{ \ + ErrorType ## Private *priv = error_type ## _get_private (error); \ + error_type ## _private_clear (priv); \ +} \ + \ +GQuark \ +error_type ## _quark (void) \ +{ \ + static GQuark q; \ + static gsize initialized = 0; \ + \ + if (g_once_init_enter (&initialized)) \ + { \ + q = g_error_domain_register_static (#ErrorType, \ + sizeof (ErrorType ## Private), \ + g_error_with_ ## error_type ## _private_init, \ + g_error_with_ ## error_type ## _private_copy, \ + g_error_with_ ## error_type ## _private_clear); \ + g_once_init_leave (&initialized, 1); \ + } \ + \ + return q; \ +} + +/** + * GErrorInitFunc: + * @error: extended error + * + * Specifies the type of function which is called just after an + * extended error instance is created and its fields filled. It should + * only initialize the fields in the private data, which can be + * received with the generated `*_get_private()` function. + * + * Normally, it is better to use G_DEFINE_EXTENDED_ERROR(), as it + * already takes care of getting the private data from @error. + * + * Since: 2.68 + */ +typedef void (*GErrorInitFunc) (GError *error); + +/** + * GErrorCopyFunc: + * @src_error: source extended error + * @dest_error: destination extended error + * + * Specifies the type of function which is called when an extended + * error instance is copied. It is passed the pointer to the + * destination error and source error, and should copy only the fields + * of the private data from @src_error to @dest_error. + * + * Normally, it is better to use G_DEFINE_EXTENDED_ERROR(), as it + * already takes care of getting the private data from @src_error and + * @dest_error. + * + * Since: 2.68 + */ +typedef void (*GErrorCopyFunc) (const GError *src_error, GError *dest_error); + +/** + * GErrorClearFunc: + * @error: extended error to clear + * + * Specifies the type of function which is called when an extended + * error instance is freed. It is passed the error pointer about to be + * freed, and should free the error's private data fields. + * + * Normally, it is better to use G_DEFINE_EXTENDED_ERROR(), as it + * already takes care of getting the private data from @error. + * + * Since: 2.68 + */ +typedef void (*GErrorClearFunc) (GError *error); + +GLIB_AVAILABLE_IN_2_68 +GQuark g_error_domain_register_static (const char *error_type_name, + gsize error_type_private_size, + GErrorInitFunc error_type_init, + GErrorCopyFunc error_type_copy, + GErrorClearFunc error_type_clear); + +GLIB_AVAILABLE_IN_2_68 +GQuark g_error_domain_register (const char *error_type_name, + gsize error_type_private_size, + GErrorInitFunc error_type_init, + GErrorCopyFunc error_type_copy, + GErrorClearFunc error_type_clear); + +GLIB_AVAILABLE_IN_ALL +GError* g_error_new (GQuark domain, + gint code, + const gchar *format, + ...) G_GNUC_PRINTF (3, 4); + +GLIB_AVAILABLE_IN_ALL +GError* g_error_new_literal (GQuark domain, + gint code, + const gchar *message); +GLIB_AVAILABLE_IN_ALL +GError* g_error_new_valist (GQuark domain, + gint code, + const gchar *format, + va_list args) G_GNUC_PRINTF(3, 0); + +GLIB_AVAILABLE_IN_ALL +void g_error_free (GError *error); +GLIB_AVAILABLE_IN_ALL +GError* g_error_copy (const GError *error); + +GLIB_AVAILABLE_IN_ALL +gboolean g_error_matches (const GError *error, + GQuark domain, + gint code); + +/* if (err) *err = g_error_new(domain, code, format, ...), also has + * some sanity checks. + */ +GLIB_AVAILABLE_IN_ALL +void g_set_error (GError **err, + GQuark domain, + gint code, + const gchar *format, + ...) G_GNUC_PRINTF (4, 5); + +GLIB_AVAILABLE_IN_ALL +void g_set_error_literal (GError **err, + GQuark domain, + gint code, + const gchar *message); + +/* if (dest) *dest = src; also has some sanity checks. + */ +GLIB_AVAILABLE_IN_ALL +void g_propagate_error (GError **dest, + GError *src); + +/* if (err && *err) { g_error_free(*err); *err = NULL; } */ +GLIB_AVAILABLE_IN_ALL +void g_clear_error (GError **err); + +/* if (err) prefix the formatted string to the ->message */ +GLIB_AVAILABLE_IN_ALL +void g_prefix_error (GError **err, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); + +/* if (err) prefix the string to the ->message */ +GLIB_AVAILABLE_IN_2_70 +void g_prefix_error_literal (GError **err, + const gchar *prefix); + +/* g_propagate_error then g_error_prefix on dest */ +GLIB_AVAILABLE_IN_ALL +void g_propagate_prefixed_error (GError **dest, + GError *src, + const gchar *format, + ...) G_GNUC_PRINTF (3, 4); + +G_END_DECLS + +#endif /* __G_ERROR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gfileutils.h b/illumos-x86_64/usr/include/glib-2.0/glib/gfileutils.h new file mode 100644 index 00000000..c056dd03 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gfileutils.h @@ -0,0 +1,223 @@ +/* gfileutils.h - File utility functions + * + * Copyright 2000 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_FILEUTILS_H__ +#define __G_FILEUTILS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_FILE_ERROR g_file_error_quark () + +typedef enum +{ + G_FILE_ERROR_EXIST, + G_FILE_ERROR_ISDIR, + G_FILE_ERROR_ACCES, + G_FILE_ERROR_NAMETOOLONG, + G_FILE_ERROR_NOENT, + G_FILE_ERROR_NOTDIR, + G_FILE_ERROR_NXIO, + G_FILE_ERROR_NODEV, + G_FILE_ERROR_ROFS, + G_FILE_ERROR_TXTBSY, + G_FILE_ERROR_FAULT, + G_FILE_ERROR_LOOP, + G_FILE_ERROR_NOSPC, + G_FILE_ERROR_NOMEM, + G_FILE_ERROR_MFILE, + G_FILE_ERROR_NFILE, + G_FILE_ERROR_BADF, + G_FILE_ERROR_INVAL, + G_FILE_ERROR_PIPE, + G_FILE_ERROR_AGAIN, + G_FILE_ERROR_INTR, + G_FILE_ERROR_IO, + G_FILE_ERROR_PERM, + G_FILE_ERROR_NOSYS, + G_FILE_ERROR_FAILED +} GFileError; + +/* For backward-compat reasons, these are synced to an old + * anonymous enum in libgnome. But don't use that enum + * in new code. + */ +typedef enum +{ + G_FILE_TEST_IS_REGULAR = 1 << 0, + G_FILE_TEST_IS_SYMLINK = 1 << 1, + G_FILE_TEST_IS_DIR = 1 << 2, + G_FILE_TEST_IS_EXECUTABLE = 1 << 3, + G_FILE_TEST_EXISTS = 1 << 4 +} GFileTest; + +/** + * GFileSetContentsFlags: + * @G_FILE_SET_CONTENTS_NONE: No guarantees about file consistency or durability. + * The most dangerous setting, which is slightly faster than other settings. + * @G_FILE_SET_CONTENTS_CONSISTENT: Guarantee file consistency: after a crash, + * either the old version of the file or the new version of the file will be + * available, but not a mixture. On Unix systems this equates to an `fsync()` + * on the file and use of an atomic `rename()` of the new version of the file + * over the old. + * @G_FILE_SET_CONTENTS_DURABLE: Guarantee file durability: after a crash, the + * new version of the file will be available. On Unix systems this equates to + * an `fsync()` on the file (if %G_FILE_SET_CONTENTS_CONSISTENT is unset), or + * the effects of %G_FILE_SET_CONTENTS_CONSISTENT plus an `fsync()` on the + * directory containing the file after calling `rename()`. + * @G_FILE_SET_CONTENTS_ONLY_EXISTING: Only apply consistency and durability + * guarantees if the file already exists. This may speed up file operations + * if the file doesn’t currently exist, but may result in a corrupted version + * of the new file if the system crashes while writing it. + * + * Flags to pass to g_file_set_contents_full() to affect its safety and + * performance. + * + * Since: 2.66 + */ +typedef enum +{ + G_FILE_SET_CONTENTS_NONE = 0, + G_FILE_SET_CONTENTS_CONSISTENT = 1 << 0, + G_FILE_SET_CONTENTS_DURABLE = 1 << 1, + G_FILE_SET_CONTENTS_ONLY_EXISTING = 1 << 2 +} GFileSetContentsFlags +GLIB_AVAILABLE_ENUMERATOR_IN_2_66; + +GLIB_AVAILABLE_IN_ALL +GQuark g_file_error_quark (void); +/* So other code can generate a GFileError */ +GLIB_AVAILABLE_IN_ALL +GFileError g_file_error_from_errno (gint err_no); + +GLIB_AVAILABLE_IN_ALL +gboolean g_file_test (const gchar *filename, + GFileTest test); +GLIB_AVAILABLE_IN_ALL +gboolean g_file_get_contents (const gchar *filename, + gchar **contents, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_file_set_contents (const gchar *filename, + const gchar *contents, + gssize length, + GError **error); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_2_66 +gboolean g_file_set_contents_full (const gchar *filename, + const gchar *contents, + gssize length, + GFileSetContentsFlags flags, + int mode, + GError **error); +G_GNUC_END_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_ALL +gchar *g_file_read_link (const gchar *filename, + GError **error); + +/* Wrapper / workalike for mkdtemp() */ +GLIB_AVAILABLE_IN_2_30 +gchar *g_mkdtemp (gchar *tmpl); +GLIB_AVAILABLE_IN_2_30 +gchar *g_mkdtemp_full (gchar *tmpl, + gint mode); + +/* Wrapper / workalike for mkstemp() */ +GLIB_AVAILABLE_IN_ALL +gint g_mkstemp (gchar *tmpl); +GLIB_AVAILABLE_IN_ALL +gint g_mkstemp_full (gchar *tmpl, + gint flags, + gint mode); + +/* Wrappers for g_mkstemp and g_mkdtemp() */ +GLIB_AVAILABLE_IN_ALL +gint g_file_open_tmp (const gchar *tmpl, + gchar **name_used, + GError **error); +GLIB_AVAILABLE_IN_2_30 +gchar *g_dir_make_tmp (const gchar *tmpl, + GError **error); + +GLIB_AVAILABLE_IN_ALL +gchar *g_build_path (const gchar *separator, + const gchar *first_element, + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +gchar *g_build_pathv (const gchar *separator, + gchar **args) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar *g_build_filename (const gchar *first_element, + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_56 +gchar *g_build_filename_valist (const gchar *first_element, + va_list *args) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gint g_mkdir_with_parents (const gchar *pathname, + gint mode); + +#ifdef G_OS_WIN32 + +/* On Win32, the canonical directory separator is the backslash, and + * the search path separator is the semicolon. Note that also the + * (forward) slash works as directory separator. + */ +#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/') + +#else /* !G_OS_WIN32 */ + +#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR) + +#endif /* !G_OS_WIN32 */ + +GLIB_AVAILABLE_IN_ALL +gboolean g_path_is_absolute (const gchar *file_name); +GLIB_AVAILABLE_IN_ALL +const gchar *g_path_skip_root (const gchar *file_name); + +GLIB_DEPRECATED_FOR(g_path_get_basename) +const gchar *g_basename (const gchar *file_name); +#define g_dirname g_path_get_dirname GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_path_get_dirname) + +GLIB_AVAILABLE_IN_ALL +gchar *g_get_current_dir (void); +GLIB_AVAILABLE_IN_ALL +gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_2_58 +gchar *g_canonicalize_filename (const gchar *filename, + const gchar *relative_to) G_GNUC_MALLOC; + +G_END_DECLS + +#endif /* __G_FILEUTILS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/ggettext.h b/illumos-x86_64/usr/include/glib-2.0/glib/ggettext.h new file mode 100644 index 00000000..33a1fbe8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/ggettext.h @@ -0,0 +1,65 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_GETTEXT_H__ +#define __G_GETTEXT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +const gchar *g_strip_context (const gchar *msgid, + const gchar *msgval) G_GNUC_FORMAT(1); + +GLIB_AVAILABLE_IN_ALL +const gchar *g_dgettext (const gchar *domain, + const gchar *msgid) G_GNUC_FORMAT(2); +GLIB_AVAILABLE_IN_ALL +const gchar *g_dcgettext (const gchar *domain, + const gchar *msgid, + gint category) G_GNUC_FORMAT(2); +GLIB_AVAILABLE_IN_ALL +const gchar *g_dngettext (const gchar *domain, + const gchar *msgid, + const gchar *msgid_plural, + gulong n) G_GNUC_FORMAT(3); +GLIB_AVAILABLE_IN_ALL +const gchar *g_dpgettext (const gchar *domain, + const gchar *msgctxtid, + gsize msgidoffset) G_GNUC_FORMAT(2); +GLIB_AVAILABLE_IN_ALL +const gchar *g_dpgettext2 (const gchar *domain, + const gchar *context, + const gchar *msgid) G_GNUC_FORMAT(3); + +G_END_DECLS + +#endif /* __G_GETTEXT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/ghash.h b/illumos-x86_64/usr/include/glib-2.0/glib/ghash.h new file mode 100644 index 00000000..3eb8f3be --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/ghash.h @@ -0,0 +1,206 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_HASH_H__ +#define __G_HASH_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +typedef struct _GHashTable GHashTable; + +typedef gboolean (*GHRFunc) (gpointer key, + gpointer value, + gpointer user_data); + +typedef struct _GHashTableIter GHashTableIter; + +struct _GHashTableIter +{ + /*< private >*/ + gpointer dummy1; + gpointer dummy2; + gpointer dummy3; + int dummy4; + gboolean dummy5; + gpointer dummy6; +}; + +GLIB_AVAILABLE_IN_ALL +GHashTable* g_hash_table_new (GHashFunc hash_func, + GEqualFunc key_equal_func); +GLIB_AVAILABLE_IN_ALL +GHashTable* g_hash_table_new_full (GHashFunc hash_func, + GEqualFunc key_equal_func, + GDestroyNotify key_destroy_func, + GDestroyNotify value_destroy_func); +GLIB_AVAILABLE_IN_2_72 +GHashTable *g_hash_table_new_similar (GHashTable *other_hash_table); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_destroy (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_insert (GHashTable *hash_table, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_replace (GHashTable *hash_table, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_add (GHashTable *hash_table, + gpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_remove (GHashTable *hash_table, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_remove_all (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_steal (GHashTable *hash_table, + gconstpointer key); +GLIB_AVAILABLE_IN_2_58 +gboolean g_hash_table_steal_extended (GHashTable *hash_table, + gconstpointer lookup_key, + gpointer *stolen_key, + gpointer *stolen_value); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_steal_all (GHashTable *hash_table); +GLIB_AVAILABLE_IN_2_76 +GPtrArray * g_hash_table_steal_all_keys (GHashTable *hash_table); +GLIB_AVAILABLE_IN_2_76 +GPtrArray * g_hash_table_steal_all_values (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +gpointer g_hash_table_lookup (GHashTable *hash_table, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_contains (GHashTable *hash_table, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_lookup_extended (GHashTable *hash_table, + gconstpointer lookup_key, + gpointer *orig_key, + gpointer *value); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_foreach (GHashTable *hash_table, + GHFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_hash_table_find (GHashTable *hash_table, + GHRFunc predicate, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +guint g_hash_table_foreach_remove (GHashTable *hash_table, + GHRFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +guint g_hash_table_foreach_steal (GHashTable *hash_table, + GHRFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +guint g_hash_table_size (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +GList * g_hash_table_get_keys (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +GList * g_hash_table_get_values (GHashTable *hash_table); +GLIB_AVAILABLE_IN_2_40 +gpointer * g_hash_table_get_keys_as_array (GHashTable *hash_table, + guint *length); +GLIB_AVAILABLE_IN_2_76 +GPtrArray * g_hash_table_get_keys_as_ptr_array (GHashTable *hash_table); + +GLIB_AVAILABLE_IN_2_76 +GPtrArray * g_hash_table_get_values_as_ptr_array (GHashTable *hash_table); + +GLIB_AVAILABLE_IN_ALL +void g_hash_table_iter_init (GHashTableIter *iter, + GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_iter_next (GHashTableIter *iter, + gpointer *key, + gpointer *value); +GLIB_AVAILABLE_IN_ALL +GHashTable* g_hash_table_iter_get_hash_table (GHashTableIter *iter); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_iter_remove (GHashTableIter *iter); +GLIB_AVAILABLE_IN_2_30 +void g_hash_table_iter_replace (GHashTableIter *iter, + gpointer value); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_iter_steal (GHashTableIter *iter); + +GLIB_AVAILABLE_IN_ALL +GHashTable* g_hash_table_ref (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_unref (GHashTable *hash_table); + +#define g_hash_table_freeze(hash_table) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 +#define g_hash_table_thaw(hash_table) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 + +/* Hash Functions + */ +GLIB_AVAILABLE_IN_ALL +gboolean g_str_equal (gconstpointer v1, + gconstpointer v2); + +/* Macro for optimization in the case it is not used as callback function */ +#define g_str_equal(v1, v2) (strcmp ((const char *) (v1), (const char *) (v2)) == 0) + +GLIB_AVAILABLE_IN_ALL +guint g_str_hash (gconstpointer v); + +GLIB_AVAILABLE_IN_ALL +gboolean g_int_equal (gconstpointer v1, + gconstpointer v2); +GLIB_AVAILABLE_IN_ALL +guint g_int_hash (gconstpointer v); + +GLIB_AVAILABLE_IN_ALL +gboolean g_int64_equal (gconstpointer v1, + gconstpointer v2); +GLIB_AVAILABLE_IN_ALL +guint g_int64_hash (gconstpointer v); + +GLIB_AVAILABLE_IN_ALL +gboolean g_double_equal (gconstpointer v1, + gconstpointer v2); +GLIB_AVAILABLE_IN_ALL +guint g_double_hash (gconstpointer v); + +GLIB_AVAILABLE_IN_ALL +guint g_direct_hash (gconstpointer v) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_direct_equal (gconstpointer v1, + gconstpointer v2) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_HASH_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/ghmac.h b/illumos-x86_64/usr/include/glib-2.0/glib/ghmac.h new file mode 100644 index 00000000..79380b6b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/ghmac.h @@ -0,0 +1,76 @@ +/* ghmac.h - secure data hashing + * + * Copyright (C) 2011 Stef Walter + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_HMAC_H__ +#define __G_HMAC_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include "gchecksum.h" + +G_BEGIN_DECLS + +typedef struct _GHmac GHmac; + +GLIB_AVAILABLE_IN_2_30 +GHmac * g_hmac_new (GChecksumType digest_type, + const guchar *key, + gsize key_len); +GLIB_AVAILABLE_IN_2_30 +GHmac * g_hmac_copy (const GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 +GHmac * g_hmac_ref (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 +void g_hmac_unref (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 +void g_hmac_update (GHmac *hmac, + const guchar *data, + gssize length); +GLIB_AVAILABLE_IN_2_30 +const gchar * g_hmac_get_string (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 +void g_hmac_get_digest (GHmac *hmac, + guint8 *buffer, + gsize *digest_len); + +GLIB_AVAILABLE_IN_2_30 +gchar *g_compute_hmac_for_data (GChecksumType digest_type, + const guchar *key, + gsize key_len, + const guchar *data, + gsize length); +GLIB_AVAILABLE_IN_2_30 +gchar *g_compute_hmac_for_string (GChecksumType digest_type, + const guchar *key, + gsize key_len, + const gchar *str, + gssize length); +GLIB_AVAILABLE_IN_2_50 +gchar *g_compute_hmac_for_bytes (GChecksumType digest_type, + GBytes *key, + GBytes *data); + + +G_END_DECLS + +#endif /* __G_CHECKSUM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/ghook.h b/illumos-x86_64/usr/include/glib-2.0/glib/ghook.h new file mode 100644 index 00000000..1bd85821 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/ghook.h @@ -0,0 +1,204 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_HOOK_H__ +#define __G_HOOK_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + + +/* --- typedefs --- */ +typedef struct _GHook GHook; +typedef struct _GHookList GHookList; + +typedef gint (*GHookCompareFunc) (GHook *new_hook, + GHook *sibling); +typedef gboolean (*GHookFindFunc) (GHook *hook, + gpointer data); +typedef void (*GHookMarshaller) (GHook *hook, + gpointer marshal_data); +typedef gboolean (*GHookCheckMarshaller) (GHook *hook, + gpointer marshal_data); +typedef void (*GHookFunc) (gpointer data); +typedef gboolean (*GHookCheckFunc) (gpointer data); +typedef void (*GHookFinalizeFunc) (GHookList *hook_list, + GHook *hook); +typedef enum +{ + G_HOOK_FLAG_ACTIVE = 1 << 0, + G_HOOK_FLAG_IN_CALL = 1 << 1, + G_HOOK_FLAG_MASK = 0x0f +} GHookFlagMask; +#define G_HOOK_FLAG_USER_SHIFT (4) + + +/* --- structures --- */ +struct _GHookList +{ + gulong seq_id; + guint hook_size : 16; + guint is_setup : 1; + GHook *hooks; + gpointer dummy3; + GHookFinalizeFunc finalize_hook; + gpointer dummy[2]; +}; +struct _GHook +{ + gpointer data; + GHook *next; + GHook *prev; + guint ref_count; + gulong hook_id; + guint flags; + gpointer func; + GDestroyNotify destroy; +}; + + +/* --- macros --- */ +#define G_HOOK(hook) ((GHook*) (hook)) +#define G_HOOK_FLAGS(hook) (G_HOOK (hook)->flags) +#define G_HOOK_ACTIVE(hook) ((G_HOOK_FLAGS (hook) & \ + G_HOOK_FLAG_ACTIVE) != 0) +#define G_HOOK_IN_CALL(hook) ((G_HOOK_FLAGS (hook) & \ + G_HOOK_FLAG_IN_CALL) != 0) +#define G_HOOK_IS_VALID(hook) (G_HOOK (hook)->hook_id != 0 && \ + (G_HOOK_FLAGS (hook) & \ + G_HOOK_FLAG_ACTIVE)) +#define G_HOOK_IS_UNLINKED(hook) (G_HOOK (hook)->next == NULL && \ + G_HOOK (hook)->prev == NULL && \ + G_HOOK (hook)->hook_id == 0 && \ + G_HOOK (hook)->ref_count == 0) + + +/* --- prototypes --- */ +/* callback maintenance functions */ +GLIB_AVAILABLE_IN_ALL +void g_hook_list_init (GHookList *hook_list, + guint hook_size); +GLIB_AVAILABLE_IN_ALL +void g_hook_list_clear (GHookList *hook_list); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_alloc (GHookList *hook_list); +GLIB_AVAILABLE_IN_ALL +void g_hook_free (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +GHook * g_hook_ref (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +void g_hook_unref (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +gboolean g_hook_destroy (GHookList *hook_list, + gulong hook_id); +GLIB_AVAILABLE_IN_ALL +void g_hook_destroy_link (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +void g_hook_prepend (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +void g_hook_insert_before (GHookList *hook_list, + GHook *sibling, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +void g_hook_insert_sorted (GHookList *hook_list, + GHook *hook, + GHookCompareFunc func); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_get (GHookList *hook_list, + gulong hook_id); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_find (GHookList *hook_list, + gboolean need_valids, + GHookFindFunc func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_find_data (GHookList *hook_list, + gboolean need_valids, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_find_func (GHookList *hook_list, + gboolean need_valids, + gpointer func); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_find_func_data (GHookList *hook_list, + gboolean need_valids, + gpointer func, + gpointer data); +/* return the first valid hook, and increment its reference count */ +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_first_valid (GHookList *hook_list, + gboolean may_be_in_call); +/* return the next valid hook with incremented reference count, and + * decrement the reference count of the original hook + */ +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_next_valid (GHookList *hook_list, + GHook *hook, + gboolean may_be_in_call); +/* GHookCompareFunc implementation to insert hooks sorted by their id */ +GLIB_AVAILABLE_IN_ALL +gint g_hook_compare_ids (GHook *new_hook, + GHook *sibling); +/* convenience macros */ +#define g_hook_append( hook_list, hook ) \ + g_hook_insert_before ((hook_list), NULL, (hook)) +/* invoke all valid hooks with the (*GHookFunc) signature. + */ +GLIB_AVAILABLE_IN_ALL +void g_hook_list_invoke (GHookList *hook_list, + gboolean may_recurse); +/* invoke all valid hooks with the (*GHookCheckFunc) signature, + * and destroy the hook if FALSE is returned. + */ +GLIB_AVAILABLE_IN_ALL +void g_hook_list_invoke_check (GHookList *hook_list, + gboolean may_recurse); +/* invoke a marshaller on all valid hooks. + */ +GLIB_AVAILABLE_IN_ALL +void g_hook_list_marshal (GHookList *hook_list, + gboolean may_recurse, + GHookMarshaller marshaller, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_hook_list_marshal_check (GHookList *hook_list, + gboolean may_recurse, + GHookCheckMarshaller marshaller, + gpointer marshal_data); + +G_END_DECLS + +#endif /* __G_HOOK_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/ghostutils.h b/illumos-x86_64/usr/include/glib-2.0/glib/ghostutils.h new file mode 100644 index 00000000..6f350976 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/ghostutils.h @@ -0,0 +1,45 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 2008 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_HOST_UTILS_H__ +#define __G_HOST_UTILS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gboolean g_hostname_is_non_ascii (const gchar *hostname); +GLIB_AVAILABLE_IN_ALL +gboolean g_hostname_is_ascii_encoded (const gchar *hostname); +GLIB_AVAILABLE_IN_ALL +gboolean g_hostname_is_ip_address (const gchar *hostname); + +GLIB_AVAILABLE_IN_ALL +gchar *g_hostname_to_ascii (const gchar *hostname); +GLIB_AVAILABLE_IN_ALL +gchar *g_hostname_to_unicode (const gchar *hostname); + +G_END_DECLS + +#endif /* __G_HOST_UTILS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gi18n-lib.h b/illumos-x86_64/usr/include/glib-2.0/glib/gi18n-lib.h new file mode 100644 index 00000000..fe9e79db --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gi18n-lib.h @@ -0,0 +1,38 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997, 2002 Peter Mattis, Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_I18N_LIB_H__ +#define __G_I18N_LIB_H__ + +#include + +#include +#include + +#ifndef GETTEXT_PACKAGE +#error You must define GETTEXT_PACKAGE before including gi18n-lib.h. Did you forget to include config.h? +#endif + +#define _(String) ((char *) g_dgettext (GETTEXT_PACKAGE, String)) +#define Q_(String) g_dpgettext (GETTEXT_PACKAGE, String, 0) +#define N_(String) (String) +#define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE, Context "\004" String, strlen (Context) + 1) +#define NC_(Context, String) (String) + +#endif /* __G_I18N_LIB_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gi18n.h b/illumos-x86_64/usr/include/glib-2.0/glib/gi18n.h new file mode 100644 index 00000000..dbb2cb3a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gi18n.h @@ -0,0 +1,34 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997, 2002 Peter Mattis, Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_I18N_H__ +#define __G_I18N_H__ + +#include + +#include +#include + +#define _(String) gettext (String) +#define Q_(String) g_dpgettext (NULL, String, 0) +#define N_(String) (String) +#define C_(Context,String) g_dpgettext (NULL, Context "\004" String, strlen (Context) + 1) +#define NC_(Context, String) (String) + +#endif /* __G_I18N_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/giochannel.h b/illumos-x86_64/usr/include/glib-2.0/glib/giochannel.h new file mode 100644 index 00000000..9304cb64 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/giochannel.h @@ -0,0 +1,407 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_IOCHANNEL_H__ +#define __G_IOCHANNEL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +/* GIOChannel + */ + +typedef struct _GIOChannel GIOChannel; +typedef struct _GIOFuncs GIOFuncs; + +typedef enum +{ + G_IO_ERROR_NONE, + G_IO_ERROR_AGAIN, + G_IO_ERROR_INVAL, + G_IO_ERROR_UNKNOWN +} GIOError; + +#define G_IO_CHANNEL_ERROR g_io_channel_error_quark() + +typedef enum +{ + /* Derived from errno */ + G_IO_CHANNEL_ERROR_FBIG, + G_IO_CHANNEL_ERROR_INVAL, + G_IO_CHANNEL_ERROR_IO, + G_IO_CHANNEL_ERROR_ISDIR, + G_IO_CHANNEL_ERROR_NOSPC, + G_IO_CHANNEL_ERROR_NXIO, + G_IO_CHANNEL_ERROR_OVERFLOW, + G_IO_CHANNEL_ERROR_PIPE, + /* Other */ + G_IO_CHANNEL_ERROR_FAILED +} GIOChannelError; + +typedef enum +{ + G_IO_STATUS_ERROR, + G_IO_STATUS_NORMAL, + G_IO_STATUS_EOF, + G_IO_STATUS_AGAIN +} GIOStatus; + +typedef enum +{ + G_SEEK_CUR, + G_SEEK_SET, + G_SEEK_END +} GSeekType; + +typedef enum +{ + G_IO_FLAG_NONE GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_IO_FLAG_APPEND = 1 << 0, + G_IO_FLAG_NONBLOCK = 1 << 1, + G_IO_FLAG_IS_READABLE = 1 << 2, /* Read only flag */ + G_IO_FLAG_IS_WRITABLE = 1 << 3, /* Read only flag */ + G_IO_FLAG_IS_WRITEABLE = 1 << 3, /* Misspelling in 2.29.10 and earlier */ + G_IO_FLAG_IS_SEEKABLE = 1 << 4, /* Read only flag */ + G_IO_FLAG_MASK = (1 << 5) - 1, + G_IO_FLAG_GET_MASK = G_IO_FLAG_MASK, + G_IO_FLAG_SET_MASK = G_IO_FLAG_APPEND | G_IO_FLAG_NONBLOCK +} GIOFlags; + +struct _GIOChannel +{ + /*< private >*/ + gint ref_count; + GIOFuncs *funcs; + + gchar *encoding; + GIConv read_cd; + GIConv write_cd; + gchar *line_term; /* String which indicates the end of a line of text */ + guint line_term_len; /* So we can have null in the line term */ + + gsize buf_size; + GString *read_buf; /* Raw data from the channel */ + GString *encoded_read_buf; /* Channel data converted to UTF-8 */ + GString *write_buf; /* Data ready to be written to the file */ + gchar partial_write_buf[6]; /* UTF-8 partial characters, null terminated */ + + /* Group the flags together, immediately after partial_write_buf, to save memory */ + + guint use_buffer : 1; /* The encoding uses the buffers */ + guint do_encode : 1; /* The encoding uses the GIConv converters */ + guint close_on_unref : 1; /* Close the channel on final unref */ + guint is_readable : 1; /* Cached GIOFlag */ + guint is_writeable : 1; /* ditto */ + guint is_seekable : 1; /* ditto */ + + gpointer reserved1; + gpointer reserved2; +}; + +typedef gboolean (*GIOFunc) (GIOChannel *source, + GIOCondition condition, + gpointer data); +struct _GIOFuncs +{ + GIOStatus (*io_read) (GIOChannel *channel, + gchar *buf, + gsize count, + gsize *bytes_read, + GError **err); + GIOStatus (*io_write) (GIOChannel *channel, + const gchar *buf, + gsize count, + gsize *bytes_written, + GError **err); + GIOStatus (*io_seek) (GIOChannel *channel, + gint64 offset, + GSeekType type, + GError **err); + GIOStatus (*io_close) (GIOChannel *channel, + GError **err); + GSource* (*io_create_watch) (GIOChannel *channel, + GIOCondition condition); + void (*io_free) (GIOChannel *channel); + GIOStatus (*io_set_flags) (GIOChannel *channel, + GIOFlags flags, + GError **err); + GIOFlags (*io_get_flags) (GIOChannel *channel); +}; + +GLIB_AVAILABLE_IN_ALL +void g_io_channel_init (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +GIOChannel *g_io_channel_ref (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +void g_io_channel_unref (GIOChannel *channel); + +GLIB_DEPRECATED_FOR(g_io_channel_read_chars) +GIOError g_io_channel_read (GIOChannel *channel, + gchar *buf, + gsize count, + gsize *bytes_read); + +GLIB_DEPRECATED_FOR(g_io_channel_write_chars) +GIOError g_io_channel_write (GIOChannel *channel, + const gchar *buf, + gsize count, + gsize *bytes_written); + +GLIB_DEPRECATED_FOR(g_io_channel_seek_position) +GIOError g_io_channel_seek (GIOChannel *channel, + gint64 offset, + GSeekType type); + +GLIB_DEPRECATED_FOR(g_io_channel_shutdown) +void g_io_channel_close (GIOChannel *channel); + +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_shutdown (GIOChannel *channel, + gboolean flush, + GError **err); +GLIB_AVAILABLE_IN_ALL +guint g_io_add_watch_full (GIOChannel *channel, + gint priority, + GIOCondition condition, + GIOFunc func, + gpointer user_data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +GSource * g_io_create_watch (GIOChannel *channel, + GIOCondition condition); +GLIB_AVAILABLE_IN_ALL +guint g_io_add_watch (GIOChannel *channel, + GIOCondition condition, + GIOFunc func, + gpointer user_data); + +/* character encoding conversion involved functions. + */ + +GLIB_AVAILABLE_IN_ALL +void g_io_channel_set_buffer_size (GIOChannel *channel, + gsize size); +GLIB_AVAILABLE_IN_ALL +gsize g_io_channel_get_buffer_size (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +GIOCondition g_io_channel_get_buffer_condition (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_set_flags (GIOChannel *channel, + GIOFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOFlags g_io_channel_get_flags (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +void g_io_channel_set_line_term (GIOChannel *channel, + const gchar *line_term, + gint length); +GLIB_AVAILABLE_IN_ALL +const gchar * g_io_channel_get_line_term (GIOChannel *channel, + gint *length); +GLIB_AVAILABLE_IN_ALL +void g_io_channel_set_buffered (GIOChannel *channel, + gboolean buffered); +GLIB_AVAILABLE_IN_ALL +gboolean g_io_channel_get_buffered (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_set_encoding (GIOChannel *channel, + const gchar *encoding, + GError **error); +GLIB_AVAILABLE_IN_ALL +const gchar * g_io_channel_get_encoding (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +void g_io_channel_set_close_on_unref (GIOChannel *channel, + gboolean do_close); +GLIB_AVAILABLE_IN_ALL +gboolean g_io_channel_get_close_on_unref (GIOChannel *channel); + + +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_flush (GIOChannel *channel, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_line (GIOChannel *channel, + gchar **str_return, + gsize *length, + gsize *terminator_pos, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_line_string (GIOChannel *channel, + GString *buffer, + gsize *terminator_pos, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_to_end (GIOChannel *channel, + gchar **str_return, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_chars (GIOChannel *channel, + gchar *buf, + gsize count, + gsize *bytes_read, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_unichar (GIOChannel *channel, + gunichar *thechar, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_write_chars (GIOChannel *channel, + const gchar *buf, + gssize count, + gsize *bytes_written, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_write_unichar (GIOChannel *channel, + gunichar thechar, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_seek_position (GIOChannel *channel, + gint64 offset, + GSeekType type, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOChannel* g_io_channel_new_file (const gchar *filename, + const gchar *mode, + GError **error); + +/* Error handling */ + +GLIB_AVAILABLE_IN_ALL +GQuark g_io_channel_error_quark (void); +GLIB_AVAILABLE_IN_ALL +GIOChannelError g_io_channel_error_from_errno (gint en); + +/* On Unix, IO channels created with this function for any file + * descriptor or socket. + * + * On Win32, this can be used either for files opened with the MSVCRT + * (the Microsoft run-time C library) _open() or _pipe, including file + * descriptors 0, 1 and 2 (corresponding to stdin, stdout and stderr), + * or for Winsock SOCKETs. If the parameter is a legal file + * descriptor, it is assumed to be such, otherwise it should be a + * SOCKET. This relies on SOCKETs and file descriptors not + * overlapping. If you want to be certain, call either + * g_io_channel_win32_new_fd() or g_io_channel_win32_new_socket() + * instead as appropriate. + * + * The term file descriptor as used in the context of Win32 refers to + * the emulated Unix-like file descriptors MSVCRT provides. The native + * corresponding concept is file HANDLE. There isn't as of yet a way to + * get GIOChannels for Win32 file HANDLEs. + */ +GLIB_AVAILABLE_IN_ALL +GIOChannel* g_io_channel_unix_new (int fd); +GLIB_AVAILABLE_IN_ALL +gint g_io_channel_unix_get_fd (GIOChannel *channel); + + +/* Hook for GClosure / GSource integration. Don't touch */ +GLIB_VAR GSourceFuncs g_io_watch_funcs; + +#ifdef G_OS_WIN32 + +/* You can use this "pseudo file descriptor" in a GPollFD to add + * polling for Windows messages. GTK applications should not do that. + */ + +#define G_WIN32_MSG_HANDLE 19981206 + +/* Use this to get a GPollFD from a GIOChannel, so that you can call + * g_io_channel_win32_poll(). After calling this you should only use + * g_io_channel_read() to read from the GIOChannel, i.e. never read() + * from the underlying file descriptor. For SOCKETs, it is possible to call + * recv(). + */ +GLIB_AVAILABLE_IN_ALL +void g_io_channel_win32_make_pollfd (GIOChannel *channel, + GIOCondition condition, + GPollFD *fd); + +/* This can be used to wait until at least one of the channels is readable. + * On Unix you would do a select() on the file descriptors of the channels. + */ +GLIB_AVAILABLE_IN_ALL +gint g_io_channel_win32_poll (GPollFD *fds, + gint n_fds, + gint timeout_); + +/* Create an IO channel for Windows messages for window handle hwnd. */ +#if GLIB_SIZEOF_VOID_P == 8 +/* We use gsize here so that it is still an integer type and not a + * pointer, like the guint in the traditional prototype. We can't use + * intptr_t as that is not portable enough. + */ +GLIB_AVAILABLE_IN_ALL +GIOChannel *g_io_channel_win32_new_messages (gsize hwnd); +#else +GLIB_AVAILABLE_IN_ALL +GIOChannel *g_io_channel_win32_new_messages (guint hwnd); +#endif + +/* Create an IO channel for C runtime (emulated Unix-like) file + * descriptors. After calling g_io_add_watch() on an IO channel + * returned by this function, you shouldn't call read() on the file + * descriptor. This is because adding polling for a file descriptor is + * implemented on Win32 by starting a thread that sits blocked in a + * read() from the file descriptor most of the time. All reads from + * the file descriptor should be done by this internal GLib + * thread. Your code should call only g_io_channel_read_chars(). + */ +GLIB_AVAILABLE_IN_ALL +GIOChannel* g_io_channel_win32_new_fd (gint fd); + +/* Get the C runtime file descriptor of a channel. */ +GLIB_AVAILABLE_IN_ALL +gint g_io_channel_win32_get_fd (GIOChannel *channel); + +/* Create an IO channel for a winsock socket. The parameter should be + * a SOCKET. Contrary to IO channels for file descriptors (on *Win32), + * you can use normal recv() or recvfrom() on sockets even if GLib + * is polling them. + */ +GLIB_AVAILABLE_IN_ALL +GIOChannel *g_io_channel_win32_new_socket (gint socket); + +GLIB_DEPRECATED_FOR(g_io_channel_win32_new_socket) +GIOChannel *g_io_channel_win32_new_stream_socket (gint socket); + +GLIB_AVAILABLE_IN_ALL +void g_io_channel_win32_set_debug (GIOChannel *channel, + gboolean flag); + +#endif + +G_END_DECLS + +#endif /* __G_IOCHANNEL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gkeyfile.h b/illumos-x86_64/usr/include/glib-2.0/glib/gkeyfile.h new file mode 100644 index 00000000..9d026d68 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gkeyfile.h @@ -0,0 +1,332 @@ +/* gkeyfile.h - desktop entry file parser + * + * Copyright 2004 Red Hat, Inc. + * + * Ray Strode + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_KEY_FILE_H__ +#define __G_KEY_FILE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef enum +{ + G_KEY_FILE_ERROR_UNKNOWN_ENCODING, + G_KEY_FILE_ERROR_PARSE, + G_KEY_FILE_ERROR_NOT_FOUND, + G_KEY_FILE_ERROR_KEY_NOT_FOUND, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + G_KEY_FILE_ERROR_INVALID_VALUE +} GKeyFileError; + +#define G_KEY_FILE_ERROR g_key_file_error_quark() + +GLIB_AVAILABLE_IN_ALL +GQuark g_key_file_error_quark (void); + +typedef struct _GKeyFile GKeyFile; + +typedef enum +{ + G_KEY_FILE_NONE = 0, + G_KEY_FILE_KEEP_COMMENTS = 1 << 0, + G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1 +} GKeyFileFlags; + +GLIB_AVAILABLE_IN_ALL +GKeyFile *g_key_file_new (void); +GLIB_AVAILABLE_IN_ALL +GKeyFile *g_key_file_ref (GKeyFile *key_file); +GLIB_AVAILABLE_IN_ALL +void g_key_file_unref (GKeyFile *key_file); +GLIB_AVAILABLE_IN_ALL +void g_key_file_free (GKeyFile *key_file); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_list_separator (GKeyFile *key_file, + gchar separator); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_load_from_file (GKeyFile *key_file, + const gchar *file, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_load_from_data (GKeyFile *key_file, + const gchar *data, + gsize length, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_2_50 +gboolean g_key_file_load_from_bytes (GKeyFile *key_file, + GBytes *bytes, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_load_from_dirs (GKeyFile *key_file, + const gchar *file, + const gchar **search_dirs, + gchar **full_path, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_load_from_data_dirs (GKeyFile *key_file, + const gchar *file, + gchar **full_path, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_to_data (GKeyFile *key_file, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_40 +gboolean g_key_file_save_to_file (GKeyFile *key_file, + const gchar *filename, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar **g_key_file_get_groups (GKeyFile *key_file, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar **g_key_file_get_keys (GKeyFile *key_file, + const gchar *group_name, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_has_group (GKeyFile *key_file, + const gchar *group_name); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_has_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_value (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_value (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *value); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *string); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_locale_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_56 +gchar *g_key_file_get_locale_for_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_locale_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + const gchar *string); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_get_boolean (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_boolean (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gboolean value); +GLIB_AVAILABLE_IN_ALL +gint g_key_file_get_integer (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_integer (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint value); +GLIB_AVAILABLE_IN_ALL +gint64 g_key_file_get_int64 (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_int64 (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint64 value); +GLIB_AVAILABLE_IN_ALL +guint64 g_key_file_get_uint64 (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_uint64 (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + guint64 value); +GLIB_AVAILABLE_IN_ALL +gdouble g_key_file_get_double (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_double (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gdouble value); +GLIB_AVAILABLE_IN_ALL +gchar **g_key_file_get_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar * const list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gchar **g_key_file_get_locale_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_locale_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + const gchar * const list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gboolean *g_key_file_get_boolean_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_boolean_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gboolean list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gint *g_key_file_get_integer_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_double_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gdouble list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gdouble *g_key_file_get_double_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_integer_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_set_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *comment, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_remove_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_remove_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_remove_group (GKeyFile *key_file, + const gchar *group_name, + GError **error); + +/* Defines for handling freedesktop.org Desktop files */ +#define G_KEY_FILE_DESKTOP_GROUP "Desktop Entry" + +#define G_KEY_FILE_DESKTOP_KEY_TYPE "Type" +#define G_KEY_FILE_DESKTOP_KEY_VERSION "Version" +#define G_KEY_FILE_DESKTOP_KEY_NAME "Name" +#define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME "GenericName" +#define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY "NoDisplay" +#define G_KEY_FILE_DESKTOP_KEY_COMMENT "Comment" +#define G_KEY_FILE_DESKTOP_KEY_ICON "Icon" +#define G_KEY_FILE_DESKTOP_KEY_HIDDEN "Hidden" +#define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN "OnlyShowIn" +#define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN "NotShowIn" +#define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC "TryExec" +#define G_KEY_FILE_DESKTOP_KEY_EXEC "Exec" +#define G_KEY_FILE_DESKTOP_KEY_PATH "Path" +#define G_KEY_FILE_DESKTOP_KEY_TERMINAL "Terminal" +#define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE "MimeType" +#define G_KEY_FILE_DESKTOP_KEY_CATEGORIES "Categories" +#define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "StartupNotify" +#define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass" +#define G_KEY_FILE_DESKTOP_KEY_URL "URL" +#define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable" +#define G_KEY_FILE_DESKTOP_KEY_ACTIONS "Actions" + +#define G_KEY_FILE_DESKTOP_TYPE_APPLICATION "Application" +#define G_KEY_FILE_DESKTOP_TYPE_LINK "Link" +#define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY "Directory" + +G_END_DECLS + +#endif /* __G_KEY_FILE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/glib-autocleanups.h b/illumos-x86_64/usr/include/glib-2.0/glib/glib-autocleanups.h new file mode 100644 index 00000000..68be87c8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/glib-autocleanups.h @@ -0,0 +1,111 @@ +/* + * Copyright © 2015 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GI_SCANNER__ + +static inline void +g_autoptr_cleanup_generic_gfree (void *p) +{ + void **pp = (void**)p; + g_free (*pp); +} + +static inline void +g_autoptr_cleanup_gstring_free (GString *string) +{ + if (string) + g_string_free (string, TRUE); +} + +/* Ignore deprecations in case we refer to a type which was added in a more + * recent GLib version than the user’s #GLIB_VERSION_MAX_ALLOWED definition. */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +/* If adding a cleanup here, please also add a test case to + * glib/tests/autoptr.c + */ +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAsyncQueue, g_async_queue_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBookmarkFile, g_bookmark_file_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBytes, g_bytes_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GChecksum, g_checksum_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDateTime, g_date_time_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDate, g_date_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDir, g_dir_close) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GError, g_error_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHashTable, g_hash_table_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHmac, g_hmac_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GIOChannel, g_io_channel_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GKeyFile, g_key_file_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GList, g_list_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GArray, g_array_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPtrArray, g_ptr_array_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GByteArray, g_byte_array_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainContext, g_main_context_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainContextPusher, g_main_context_pusher_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainLoop, g_main_loop_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSource, g_source_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMappedFile, g_mapped_file_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMarkupParseContext, g_markup_parse_context_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNode, g_node_destroy) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionContext, g_option_context_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionGroup, g_option_group_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPatternSpec, g_pattern_spec_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GQueue, g_queue_free) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRand, g_rand_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRegex, g_regex_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMatchInfo, g_match_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GScanner, g_scanner_destroy) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSequence, g_sequence_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSList, g_slist_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GString, g_autoptr_cleanup_gstring_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GStringChunk, g_string_chunk_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GStrvBuilder, g_strv_builder_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GThread, g_thread_unref) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GMutex, g_mutex_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMutexLocker, g_mutex_locker_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRecMutexLocker, g_rec_mutex_locker_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRWLockWriterLocker, g_rw_lock_writer_locker_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRWLockReaderLocker, g_rw_lock_reader_locker_free) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GCond, g_cond_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTimer, g_timer_destroy) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTimeZone, g_time_zone_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTree, g_tree_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariant, g_variant_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantBuilder, g_variant_builder_unref) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantBuilder, g_variant_builder_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantIter, g_variant_iter_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantDict, g_variant_dict_unref) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantDict, g_variant_dict_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantType, g_variant_type_free) +G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRefString, g_ref_string_release) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUri, g_uri_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GPathBuf, g_path_buf_free) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (GPathBuf, g_path_buf_clear) + +G_GNUC_END_IGNORE_DEPRECATIONS + +#endif /* __GI_SCANNER__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/glib-typeof.h b/illumos-x86_64/usr/include/glib-2.0/glib/glib-typeof.h new file mode 100644 index 00000000..c3519fa4 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/glib-typeof.h @@ -0,0 +1,47 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 2021 Iain Lane, Xavier Claessens + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __GLIB_TYPEOF_H__ +#define __GLIB_TYPEOF_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +/* + * We can only use __typeof__ on GCC >= 4.8, and not when compiling C++. Since + * __typeof__ is used in a few places in GLib, provide a pre-processor symbol + * to factor the check out from callers. + * + * This symbol is private. + */ +#undef glib_typeof +#if !G_CXX_STD_CHECK_VERSION (11) && \ + (G_GNUC_CHECK_VERSION(4, 8) || defined(__clang__)) +#define glib_typeof(t) __typeof__ (t) +#elif G_CXX_STD_CHECK_VERSION (11) && \ + GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68 +/* C++11 decltype() is close enough for our usage */ +#include +#define glib_typeof(t) typename std::remove_reference::type +#endif + +#endif /* __GLIB_TYPEOF_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/glib-visibility.h b/illumos-x86_64/usr/include/glib-2.0/glib/glib-visibility.h new file mode 100644 index 00000000..7a5c3c4a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/glib-visibility.h @@ -0,0 +1,1054 @@ +#pragma once + +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(GLIB_STATIC_COMPILATION) +# define _GLIB_EXPORT __declspec(dllexport) +# define _GLIB_IMPORT __declspec(dllimport) +#elif __GNUC__ >= 4 +# define _GLIB_EXPORT __attribute__((visibility("default"))) +# define _GLIB_IMPORT +#else +# define _GLIB_EXPORT +# define _GLIB_IMPORT +#endif +#ifdef GLIB_COMPILATION +# define _GLIB_API _GLIB_EXPORT +#else +# define _GLIB_API _GLIB_IMPORT +#endif + +#define _GLIB_EXTERN _GLIB_API extern + +#define GLIB_VAR _GLIB_EXTERN +#define GLIB_AVAILABLE_IN_ALL _GLIB_EXTERN + +#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS +#define GLIB_DEPRECATED _GLIB_EXTERN +#define GLIB_DEPRECATED_FOR(f) _GLIB_EXTERN +#define GLIB_UNAVAILABLE(maj,min) _GLIB_EXTERN +#define GLIB_UNAVAILABLE_STATIC_INLINE(maj,min) +#else +#define GLIB_DEPRECATED G_DEPRECATED _GLIB_EXTERN +#define GLIB_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GLIB_EXTERN +#define GLIB_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GLIB_EXTERN +#define GLIB_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min) +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26 +#define GLIB_DEPRECATED_IN_2_26 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_26_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_26 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_26_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_26 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_26 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_26_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_26 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_26_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_26 +#define GLIB_DEPRECATED_MACRO_IN_2_26_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_26 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_26 +#define GLIB_DEPRECATED_TYPE_IN_2_26_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26 +#define GLIB_AVAILABLE_IN_2_26 GLIB_UNAVAILABLE (2, 26) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_26 GLIB_UNAVAILABLE_STATIC_INLINE (2, 26) +#define GLIB_AVAILABLE_MACRO_IN_2_26 GLIB_UNAVAILABLE_MACRO (2, 26) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_26 GLIB_UNAVAILABLE_ENUMERATOR (2, 26) +#define GLIB_AVAILABLE_TYPE_IN_2_26 GLIB_UNAVAILABLE_TYPE (2, 26) +#else +#define GLIB_AVAILABLE_IN_2_26 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_26 +#define GLIB_AVAILABLE_MACRO_IN_2_26 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_26 +#define GLIB_AVAILABLE_TYPE_IN_2_26 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28 +#define GLIB_DEPRECATED_IN_2_28 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_28_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_28 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_28_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_28 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_28 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_28_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_28 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_28_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_28 +#define GLIB_DEPRECATED_MACRO_IN_2_28_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_28 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_28 +#define GLIB_DEPRECATED_TYPE_IN_2_28_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28 +#define GLIB_AVAILABLE_IN_2_28 GLIB_UNAVAILABLE (2, 28) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_28 GLIB_UNAVAILABLE_STATIC_INLINE (2, 28) +#define GLIB_AVAILABLE_MACRO_IN_2_28 GLIB_UNAVAILABLE_MACRO (2, 28) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_28 GLIB_UNAVAILABLE_ENUMERATOR (2, 28) +#define GLIB_AVAILABLE_TYPE_IN_2_28 GLIB_UNAVAILABLE_TYPE (2, 28) +#else +#define GLIB_AVAILABLE_IN_2_28 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_28 +#define GLIB_AVAILABLE_MACRO_IN_2_28 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_28 +#define GLIB_AVAILABLE_TYPE_IN_2_28 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30 +#define GLIB_DEPRECATED_IN_2_30 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_30_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_30 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_30_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_30 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_30 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_30_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_30 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_30_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_30 +#define GLIB_DEPRECATED_MACRO_IN_2_30_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_30 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_30 +#define GLIB_DEPRECATED_TYPE_IN_2_30_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30 +#define GLIB_AVAILABLE_IN_2_30 GLIB_UNAVAILABLE (2, 30) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_30 GLIB_UNAVAILABLE_STATIC_INLINE (2, 30) +#define GLIB_AVAILABLE_MACRO_IN_2_30 GLIB_UNAVAILABLE_MACRO (2, 30) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_30 GLIB_UNAVAILABLE_ENUMERATOR (2, 30) +#define GLIB_AVAILABLE_TYPE_IN_2_30 GLIB_UNAVAILABLE_TYPE (2, 30) +#else +#define GLIB_AVAILABLE_IN_2_30 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_30 +#define GLIB_AVAILABLE_MACRO_IN_2_30 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_30 +#define GLIB_AVAILABLE_TYPE_IN_2_30 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32 +#define GLIB_DEPRECATED_IN_2_32 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_32_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_32 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_32_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_32 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_32 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_32_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_32 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_32_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_32 +#define GLIB_DEPRECATED_MACRO_IN_2_32_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_32 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_32 +#define GLIB_DEPRECATED_TYPE_IN_2_32_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32 +#define GLIB_AVAILABLE_IN_2_32 GLIB_UNAVAILABLE (2, 32) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_32 GLIB_UNAVAILABLE_STATIC_INLINE (2, 32) +#define GLIB_AVAILABLE_MACRO_IN_2_32 GLIB_UNAVAILABLE_MACRO (2, 32) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_32 GLIB_UNAVAILABLE_ENUMERATOR (2, 32) +#define GLIB_AVAILABLE_TYPE_IN_2_32 GLIB_UNAVAILABLE_TYPE (2, 32) +#else +#define GLIB_AVAILABLE_IN_2_32 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_32 +#define GLIB_AVAILABLE_MACRO_IN_2_32 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_32 +#define GLIB_AVAILABLE_TYPE_IN_2_32 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34 +#define GLIB_DEPRECATED_IN_2_34 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_34_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_34 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_34_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_34 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_34 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_34_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_34 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_34_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_34 +#define GLIB_DEPRECATED_MACRO_IN_2_34_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_34 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_34 +#define GLIB_DEPRECATED_TYPE_IN_2_34_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34 +#define GLIB_AVAILABLE_IN_2_34 GLIB_UNAVAILABLE (2, 34) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_34 GLIB_UNAVAILABLE_STATIC_INLINE (2, 34) +#define GLIB_AVAILABLE_MACRO_IN_2_34 GLIB_UNAVAILABLE_MACRO (2, 34) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_34 GLIB_UNAVAILABLE_ENUMERATOR (2, 34) +#define GLIB_AVAILABLE_TYPE_IN_2_34 GLIB_UNAVAILABLE_TYPE (2, 34) +#else +#define GLIB_AVAILABLE_IN_2_34 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_34 +#define GLIB_AVAILABLE_MACRO_IN_2_34 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_34 +#define GLIB_AVAILABLE_TYPE_IN_2_34 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36 +#define GLIB_DEPRECATED_IN_2_36 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_36_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_36 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_36_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_36 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_36 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_36_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_36 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_36_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_36 +#define GLIB_DEPRECATED_MACRO_IN_2_36_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_36 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_36 +#define GLIB_DEPRECATED_TYPE_IN_2_36_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36 +#define GLIB_AVAILABLE_IN_2_36 GLIB_UNAVAILABLE (2, 36) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_36 GLIB_UNAVAILABLE_STATIC_INLINE (2, 36) +#define GLIB_AVAILABLE_MACRO_IN_2_36 GLIB_UNAVAILABLE_MACRO (2, 36) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_36 GLIB_UNAVAILABLE_ENUMERATOR (2, 36) +#define GLIB_AVAILABLE_TYPE_IN_2_36 GLIB_UNAVAILABLE_TYPE (2, 36) +#else +#define GLIB_AVAILABLE_IN_2_36 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_36 +#define GLIB_AVAILABLE_MACRO_IN_2_36 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_36 +#define GLIB_AVAILABLE_TYPE_IN_2_36 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_38 +#define GLIB_DEPRECATED_IN_2_38 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_38_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_38 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_38_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_38 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_38 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_38_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_38 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_38_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_38 +#define GLIB_DEPRECATED_MACRO_IN_2_38_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_38 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_38 +#define GLIB_DEPRECATED_TYPE_IN_2_38_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 +#define GLIB_AVAILABLE_IN_2_38 GLIB_UNAVAILABLE (2, 38) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_38 GLIB_UNAVAILABLE_STATIC_INLINE (2, 38) +#define GLIB_AVAILABLE_MACRO_IN_2_38 GLIB_UNAVAILABLE_MACRO (2, 38) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_38 GLIB_UNAVAILABLE_ENUMERATOR (2, 38) +#define GLIB_AVAILABLE_TYPE_IN_2_38 GLIB_UNAVAILABLE_TYPE (2, 38) +#else +#define GLIB_AVAILABLE_IN_2_38 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_38 +#define GLIB_AVAILABLE_MACRO_IN_2_38 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_38 +#define GLIB_AVAILABLE_TYPE_IN_2_38 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_40 +#define GLIB_DEPRECATED_IN_2_40 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_40_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_40 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_40_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_40 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_40 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_40_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_40 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_40_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_40 +#define GLIB_DEPRECATED_MACRO_IN_2_40_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_40 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_40 +#define GLIB_DEPRECATED_TYPE_IN_2_40_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_40 +#define GLIB_AVAILABLE_IN_2_40 GLIB_UNAVAILABLE (2, 40) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_40 GLIB_UNAVAILABLE_STATIC_INLINE (2, 40) +#define GLIB_AVAILABLE_MACRO_IN_2_40 GLIB_UNAVAILABLE_MACRO (2, 40) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_40 GLIB_UNAVAILABLE_ENUMERATOR (2, 40) +#define GLIB_AVAILABLE_TYPE_IN_2_40 GLIB_UNAVAILABLE_TYPE (2, 40) +#else +#define GLIB_AVAILABLE_IN_2_40 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_40 +#define GLIB_AVAILABLE_MACRO_IN_2_40 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_40 +#define GLIB_AVAILABLE_TYPE_IN_2_40 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_42 +#define GLIB_DEPRECATED_IN_2_42 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_42_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_42 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_42_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_42 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_42 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_42_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_42 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_42_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_42 +#define GLIB_DEPRECATED_MACRO_IN_2_42_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_42 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_42 +#define GLIB_DEPRECATED_TYPE_IN_2_42_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_42 +#define GLIB_AVAILABLE_IN_2_42 GLIB_UNAVAILABLE (2, 42) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_42 GLIB_UNAVAILABLE_STATIC_INLINE (2, 42) +#define GLIB_AVAILABLE_MACRO_IN_2_42 GLIB_UNAVAILABLE_MACRO (2, 42) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_42 GLIB_UNAVAILABLE_ENUMERATOR (2, 42) +#define GLIB_AVAILABLE_TYPE_IN_2_42 GLIB_UNAVAILABLE_TYPE (2, 42) +#else +#define GLIB_AVAILABLE_IN_2_42 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_42 +#define GLIB_AVAILABLE_MACRO_IN_2_42 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_42 +#define GLIB_AVAILABLE_TYPE_IN_2_42 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_44 +#define GLIB_DEPRECATED_IN_2_44 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_44_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_44 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_44_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_44 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_44 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_44_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_44 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_44_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_44 +#define GLIB_DEPRECATED_MACRO_IN_2_44_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_44 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_44 +#define GLIB_DEPRECATED_TYPE_IN_2_44_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_44 +#define GLIB_AVAILABLE_IN_2_44 GLIB_UNAVAILABLE (2, 44) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 GLIB_UNAVAILABLE_STATIC_INLINE (2, 44) +#define GLIB_AVAILABLE_MACRO_IN_2_44 GLIB_UNAVAILABLE_MACRO (2, 44) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_44 GLIB_UNAVAILABLE_ENUMERATOR (2, 44) +#define GLIB_AVAILABLE_TYPE_IN_2_44 GLIB_UNAVAILABLE_TYPE (2, 44) +#else +#define GLIB_AVAILABLE_IN_2_44 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +#define GLIB_AVAILABLE_MACRO_IN_2_44 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_44 +#define GLIB_AVAILABLE_TYPE_IN_2_44 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_46 +#define GLIB_DEPRECATED_IN_2_46 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_46_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_46 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_46_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_46 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_46 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_46_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_46 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_46_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_46 +#define GLIB_DEPRECATED_MACRO_IN_2_46_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_46 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_46 +#define GLIB_DEPRECATED_TYPE_IN_2_46_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_46 +#define GLIB_AVAILABLE_IN_2_46 GLIB_UNAVAILABLE (2, 46) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_46 GLIB_UNAVAILABLE_STATIC_INLINE (2, 46) +#define GLIB_AVAILABLE_MACRO_IN_2_46 GLIB_UNAVAILABLE_MACRO (2, 46) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_46 GLIB_UNAVAILABLE_ENUMERATOR (2, 46) +#define GLIB_AVAILABLE_TYPE_IN_2_46 GLIB_UNAVAILABLE_TYPE (2, 46) +#else +#define GLIB_AVAILABLE_IN_2_46 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_46 +#define GLIB_AVAILABLE_MACRO_IN_2_46 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_46 +#define GLIB_AVAILABLE_TYPE_IN_2_46 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_48 +#define GLIB_DEPRECATED_IN_2_48 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_48_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_48 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_48_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_48 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_48 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_48_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_48 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_48_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_48 +#define GLIB_DEPRECATED_MACRO_IN_2_48_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_48 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_48 +#define GLIB_DEPRECATED_TYPE_IN_2_48_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_48 +#define GLIB_AVAILABLE_IN_2_48 GLIB_UNAVAILABLE (2, 48) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_48 GLIB_UNAVAILABLE_STATIC_INLINE (2, 48) +#define GLIB_AVAILABLE_MACRO_IN_2_48 GLIB_UNAVAILABLE_MACRO (2, 48) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_48 GLIB_UNAVAILABLE_ENUMERATOR (2, 48) +#define GLIB_AVAILABLE_TYPE_IN_2_48 GLIB_UNAVAILABLE_TYPE (2, 48) +#else +#define GLIB_AVAILABLE_IN_2_48 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_48 +#define GLIB_AVAILABLE_MACRO_IN_2_48 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_48 +#define GLIB_AVAILABLE_TYPE_IN_2_48 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_50 +#define GLIB_DEPRECATED_IN_2_50 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_50_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_50 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_50_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_50 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_50 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_50_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_50 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_50_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_50 +#define GLIB_DEPRECATED_MACRO_IN_2_50_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_50 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_50 +#define GLIB_DEPRECATED_TYPE_IN_2_50_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_50 +#define GLIB_AVAILABLE_IN_2_50 GLIB_UNAVAILABLE (2, 50) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_50 GLIB_UNAVAILABLE_STATIC_INLINE (2, 50) +#define GLIB_AVAILABLE_MACRO_IN_2_50 GLIB_UNAVAILABLE_MACRO (2, 50) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_50 GLIB_UNAVAILABLE_ENUMERATOR (2, 50) +#define GLIB_AVAILABLE_TYPE_IN_2_50 GLIB_UNAVAILABLE_TYPE (2, 50) +#else +#define GLIB_AVAILABLE_IN_2_50 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_50 +#define GLIB_AVAILABLE_MACRO_IN_2_50 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_50 +#define GLIB_AVAILABLE_TYPE_IN_2_50 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_52 +#define GLIB_DEPRECATED_IN_2_52 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_52_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_52 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_52_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_52 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_52 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_52_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_52 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_52_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_52 +#define GLIB_DEPRECATED_MACRO_IN_2_52_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_52 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_52 +#define GLIB_DEPRECATED_TYPE_IN_2_52_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_52 +#define GLIB_AVAILABLE_IN_2_52 GLIB_UNAVAILABLE (2, 52) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_52 GLIB_UNAVAILABLE_STATIC_INLINE (2, 52) +#define GLIB_AVAILABLE_MACRO_IN_2_52 GLIB_UNAVAILABLE_MACRO (2, 52) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_52 GLIB_UNAVAILABLE_ENUMERATOR (2, 52) +#define GLIB_AVAILABLE_TYPE_IN_2_52 GLIB_UNAVAILABLE_TYPE (2, 52) +#else +#define GLIB_AVAILABLE_IN_2_52 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_52 +#define GLIB_AVAILABLE_MACRO_IN_2_52 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_52 +#define GLIB_AVAILABLE_TYPE_IN_2_52 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_54 +#define GLIB_DEPRECATED_IN_2_54 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_54_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_54 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_54_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_54 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_54 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_54_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_54 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_54_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_54 +#define GLIB_DEPRECATED_MACRO_IN_2_54_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_54 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_54 +#define GLIB_DEPRECATED_TYPE_IN_2_54_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_54 +#define GLIB_AVAILABLE_IN_2_54 GLIB_UNAVAILABLE (2, 54) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_54 GLIB_UNAVAILABLE_STATIC_INLINE (2, 54) +#define GLIB_AVAILABLE_MACRO_IN_2_54 GLIB_UNAVAILABLE_MACRO (2, 54) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_54 GLIB_UNAVAILABLE_ENUMERATOR (2, 54) +#define GLIB_AVAILABLE_TYPE_IN_2_54 GLIB_UNAVAILABLE_TYPE (2, 54) +#else +#define GLIB_AVAILABLE_IN_2_54 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_54 +#define GLIB_AVAILABLE_MACRO_IN_2_54 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_54 +#define GLIB_AVAILABLE_TYPE_IN_2_54 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_56 +#define GLIB_DEPRECATED_IN_2_56 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_56_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_56 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_56_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_56 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_56 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_56_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_56 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_56_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_56 +#define GLIB_DEPRECATED_MACRO_IN_2_56_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_56 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_56 +#define GLIB_DEPRECATED_TYPE_IN_2_56_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_56 +#define GLIB_AVAILABLE_IN_2_56 GLIB_UNAVAILABLE (2, 56) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_56 GLIB_UNAVAILABLE_STATIC_INLINE (2, 56) +#define GLIB_AVAILABLE_MACRO_IN_2_56 GLIB_UNAVAILABLE_MACRO (2, 56) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_56 GLIB_UNAVAILABLE_ENUMERATOR (2, 56) +#define GLIB_AVAILABLE_TYPE_IN_2_56 GLIB_UNAVAILABLE_TYPE (2, 56) +#else +#define GLIB_AVAILABLE_IN_2_56 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_56 +#define GLIB_AVAILABLE_MACRO_IN_2_56 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_56 +#define GLIB_AVAILABLE_TYPE_IN_2_56 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_58 +#define GLIB_DEPRECATED_IN_2_58 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_58_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_58 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_58_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_58 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_58 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_58_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_58 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_58_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_58 +#define GLIB_DEPRECATED_MACRO_IN_2_58_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_58 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_58 +#define GLIB_DEPRECATED_TYPE_IN_2_58_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_58 +#define GLIB_AVAILABLE_IN_2_58 GLIB_UNAVAILABLE (2, 58) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_58 GLIB_UNAVAILABLE_STATIC_INLINE (2, 58) +#define GLIB_AVAILABLE_MACRO_IN_2_58 GLIB_UNAVAILABLE_MACRO (2, 58) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_58 GLIB_UNAVAILABLE_ENUMERATOR (2, 58) +#define GLIB_AVAILABLE_TYPE_IN_2_58 GLIB_UNAVAILABLE_TYPE (2, 58) +#else +#define GLIB_AVAILABLE_IN_2_58 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_58 +#define GLIB_AVAILABLE_MACRO_IN_2_58 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_58 +#define GLIB_AVAILABLE_TYPE_IN_2_58 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_60 +#define GLIB_DEPRECATED_IN_2_60 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_60_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_60 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_60_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_60 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_60 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_60_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_60 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_60_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_60 +#define GLIB_DEPRECATED_MACRO_IN_2_60_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_60 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_60 +#define GLIB_DEPRECATED_TYPE_IN_2_60_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_60 +#define GLIB_AVAILABLE_IN_2_60 GLIB_UNAVAILABLE (2, 60) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 GLIB_UNAVAILABLE_STATIC_INLINE (2, 60) +#define GLIB_AVAILABLE_MACRO_IN_2_60 GLIB_UNAVAILABLE_MACRO (2, 60) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_60 GLIB_UNAVAILABLE_ENUMERATOR (2, 60) +#define GLIB_AVAILABLE_TYPE_IN_2_60 GLIB_UNAVAILABLE_TYPE (2, 60) +#else +#define GLIB_AVAILABLE_IN_2_60 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 +#define GLIB_AVAILABLE_MACRO_IN_2_60 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_60 +#define GLIB_AVAILABLE_TYPE_IN_2_60 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_62 +#define GLIB_DEPRECATED_IN_2_62 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_62_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_62 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_62_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_62 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_62 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_62_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_62 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_62_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_62 +#define GLIB_DEPRECATED_MACRO_IN_2_62_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_62 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_62 +#define GLIB_DEPRECATED_TYPE_IN_2_62_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_62 +#define GLIB_AVAILABLE_IN_2_62 GLIB_UNAVAILABLE (2, 62) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 GLIB_UNAVAILABLE_STATIC_INLINE (2, 62) +#define GLIB_AVAILABLE_MACRO_IN_2_62 GLIB_UNAVAILABLE_MACRO (2, 62) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_62 GLIB_UNAVAILABLE_ENUMERATOR (2, 62) +#define GLIB_AVAILABLE_TYPE_IN_2_62 GLIB_UNAVAILABLE_TYPE (2, 62) +#else +#define GLIB_AVAILABLE_IN_2_62 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +#define GLIB_AVAILABLE_MACRO_IN_2_62 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_62 +#define GLIB_AVAILABLE_TYPE_IN_2_62 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 +#define GLIB_DEPRECATED_IN_2_64 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_64_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_64 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_64_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_64 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_64 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_64_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_64 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_64_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_64 +#define GLIB_DEPRECATED_MACRO_IN_2_64_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_64 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_64 +#define GLIB_DEPRECATED_TYPE_IN_2_64_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64 +#define GLIB_AVAILABLE_IN_2_64 GLIB_UNAVAILABLE (2, 64) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 GLIB_UNAVAILABLE_STATIC_INLINE (2, 64) +#define GLIB_AVAILABLE_MACRO_IN_2_64 GLIB_UNAVAILABLE_MACRO (2, 64) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_64 GLIB_UNAVAILABLE_ENUMERATOR (2, 64) +#define GLIB_AVAILABLE_TYPE_IN_2_64 GLIB_UNAVAILABLE_TYPE (2, 64) +#else +#define GLIB_AVAILABLE_IN_2_64 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 +#define GLIB_AVAILABLE_MACRO_IN_2_64 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_64 +#define GLIB_AVAILABLE_TYPE_IN_2_64 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_66 +#define GLIB_DEPRECATED_IN_2_66 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_66_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_66 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_66_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_66 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_66 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_66_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_66 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_66_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_66 +#define GLIB_DEPRECATED_MACRO_IN_2_66_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_66 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_66 +#define GLIB_DEPRECATED_TYPE_IN_2_66_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_66 +#define GLIB_AVAILABLE_IN_2_66 GLIB_UNAVAILABLE (2, 66) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_66 GLIB_UNAVAILABLE_STATIC_INLINE (2, 66) +#define GLIB_AVAILABLE_MACRO_IN_2_66 GLIB_UNAVAILABLE_MACRO (2, 66) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_66 GLIB_UNAVAILABLE_ENUMERATOR (2, 66) +#define GLIB_AVAILABLE_TYPE_IN_2_66 GLIB_UNAVAILABLE_TYPE (2, 66) +#else +#define GLIB_AVAILABLE_IN_2_66 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_66 +#define GLIB_AVAILABLE_MACRO_IN_2_66 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_66 +#define GLIB_AVAILABLE_TYPE_IN_2_66 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68 +#define GLIB_DEPRECATED_IN_2_68 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_68_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_68 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_68_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_68 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_68 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_68_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_68 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_68_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_68 +#define GLIB_DEPRECATED_MACRO_IN_2_68_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_68 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_68 +#define GLIB_DEPRECATED_TYPE_IN_2_68_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_68 +#define GLIB_AVAILABLE_IN_2_68 GLIB_UNAVAILABLE (2, 68) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_68 GLIB_UNAVAILABLE_STATIC_INLINE (2, 68) +#define GLIB_AVAILABLE_MACRO_IN_2_68 GLIB_UNAVAILABLE_MACRO (2, 68) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_68 GLIB_UNAVAILABLE_ENUMERATOR (2, 68) +#define GLIB_AVAILABLE_TYPE_IN_2_68 GLIB_UNAVAILABLE_TYPE (2, 68) +#else +#define GLIB_AVAILABLE_IN_2_68 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_68 +#define GLIB_AVAILABLE_MACRO_IN_2_68 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_68 +#define GLIB_AVAILABLE_TYPE_IN_2_68 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_70 +#define GLIB_DEPRECATED_IN_2_70 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_70_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_70 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_70_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_70 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_70 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_70_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_70 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_70_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_70 +#define GLIB_DEPRECATED_MACRO_IN_2_70_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_70 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_70 +#define GLIB_DEPRECATED_TYPE_IN_2_70_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_70 +#define GLIB_AVAILABLE_IN_2_70 GLIB_UNAVAILABLE (2, 70) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_70 GLIB_UNAVAILABLE_STATIC_INLINE (2, 70) +#define GLIB_AVAILABLE_MACRO_IN_2_70 GLIB_UNAVAILABLE_MACRO (2, 70) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_70 GLIB_UNAVAILABLE_ENUMERATOR (2, 70) +#define GLIB_AVAILABLE_TYPE_IN_2_70 GLIB_UNAVAILABLE_TYPE (2, 70) +#else +#define GLIB_AVAILABLE_IN_2_70 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_70 +#define GLIB_AVAILABLE_MACRO_IN_2_70 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_70 +#define GLIB_AVAILABLE_TYPE_IN_2_70 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_72 +#define GLIB_DEPRECATED_IN_2_72 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_72_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_72 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_72_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_72 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_72 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_72_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_72 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_72_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_72 +#define GLIB_DEPRECATED_MACRO_IN_2_72_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_72 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_72 +#define GLIB_DEPRECATED_TYPE_IN_2_72_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_72 +#define GLIB_AVAILABLE_IN_2_72 GLIB_UNAVAILABLE (2, 72) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_72 GLIB_UNAVAILABLE_STATIC_INLINE (2, 72) +#define GLIB_AVAILABLE_MACRO_IN_2_72 GLIB_UNAVAILABLE_MACRO (2, 72) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_72 GLIB_UNAVAILABLE_ENUMERATOR (2, 72) +#define GLIB_AVAILABLE_TYPE_IN_2_72 GLIB_UNAVAILABLE_TYPE (2, 72) +#else +#define GLIB_AVAILABLE_IN_2_72 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_72 +#define GLIB_AVAILABLE_MACRO_IN_2_72 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_72 +#define GLIB_AVAILABLE_TYPE_IN_2_72 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_74 +#define GLIB_DEPRECATED_IN_2_74 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_74_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_74 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_74_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_74 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_74 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_74_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_74 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_74_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_74 +#define GLIB_DEPRECATED_MACRO_IN_2_74_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_74 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_74 +#define GLIB_DEPRECATED_TYPE_IN_2_74_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_74 +#define GLIB_AVAILABLE_IN_2_74 GLIB_UNAVAILABLE (2, 74) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_74 GLIB_UNAVAILABLE_STATIC_INLINE (2, 74) +#define GLIB_AVAILABLE_MACRO_IN_2_74 GLIB_UNAVAILABLE_MACRO (2, 74) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_74 GLIB_UNAVAILABLE_ENUMERATOR (2, 74) +#define GLIB_AVAILABLE_TYPE_IN_2_74 GLIB_UNAVAILABLE_TYPE (2, 74) +#else +#define GLIB_AVAILABLE_IN_2_74 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_74 +#define GLIB_AVAILABLE_MACRO_IN_2_74 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_74 +#define GLIB_AVAILABLE_TYPE_IN_2_74 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76 +#define GLIB_DEPRECATED_IN_2_76 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_76_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_76 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_76_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_76 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_76 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_76_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_76 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_76_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_76 +#define GLIB_DEPRECATED_MACRO_IN_2_76_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_76 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_76 +#define GLIB_DEPRECATED_TYPE_IN_2_76_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_76 +#define GLIB_AVAILABLE_IN_2_76 GLIB_UNAVAILABLE (2, 76) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 GLIB_UNAVAILABLE_STATIC_INLINE (2, 76) +#define GLIB_AVAILABLE_MACRO_IN_2_76 GLIB_UNAVAILABLE_MACRO (2, 76) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_76 GLIB_UNAVAILABLE_ENUMERATOR (2, 76) +#define GLIB_AVAILABLE_TYPE_IN_2_76 GLIB_UNAVAILABLE_TYPE (2, 76) +#else +#define GLIB_AVAILABLE_IN_2_76 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 +#define GLIB_AVAILABLE_MACRO_IN_2_76 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_76 +#define GLIB_AVAILABLE_TYPE_IN_2_76 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 +#define GLIB_DEPRECATED_IN_2_78 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_78_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_78 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_78_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_78 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_78 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_78_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_78 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_78_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_78 +#define GLIB_DEPRECATED_MACRO_IN_2_78_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_78 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_78 +#define GLIB_DEPRECATED_TYPE_IN_2_78_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_78 +#define GLIB_AVAILABLE_IN_2_78 GLIB_UNAVAILABLE (2, 78) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_78 GLIB_UNAVAILABLE_STATIC_INLINE (2, 78) +#define GLIB_AVAILABLE_MACRO_IN_2_78 GLIB_UNAVAILABLE_MACRO (2, 78) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_78 GLIB_UNAVAILABLE_ENUMERATOR (2, 78) +#define GLIB_AVAILABLE_TYPE_IN_2_78 GLIB_UNAVAILABLE_TYPE (2, 78) +#else +#define GLIB_AVAILABLE_IN_2_78 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_78 +#define GLIB_AVAILABLE_MACRO_IN_2_78 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_78 +#define GLIB_AVAILABLE_TYPE_IN_2_78 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_80 +#define GLIB_DEPRECATED_IN_2_80 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_80_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_80 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_80_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_80 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_80 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_80_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_80 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_80_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_80 +#define GLIB_DEPRECATED_MACRO_IN_2_80_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_80 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_80 +#define GLIB_DEPRECATED_TYPE_IN_2_80_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_80 +#define GLIB_AVAILABLE_IN_2_80 GLIB_UNAVAILABLE (2, 80) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 GLIB_UNAVAILABLE_STATIC_INLINE (2, 80) +#define GLIB_AVAILABLE_MACRO_IN_2_80 GLIB_UNAVAILABLE_MACRO (2, 80) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_80 GLIB_UNAVAILABLE_ENUMERATOR (2, 80) +#define GLIB_AVAILABLE_TYPE_IN_2_80 GLIB_UNAVAILABLE_TYPE (2, 80) +#else +#define GLIB_AVAILABLE_IN_2_80 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_80 +#define GLIB_AVAILABLE_MACRO_IN_2_80 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_80 +#define GLIB_AVAILABLE_TYPE_IN_2_80 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_82 +#define GLIB_DEPRECATED_IN_2_82 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_82_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_82 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_82_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_82 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_82 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_82_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_82 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_82_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_82 +#define GLIB_DEPRECATED_MACRO_IN_2_82_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_82 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_82 +#define GLIB_DEPRECATED_TYPE_IN_2_82_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_82 +#define GLIB_AVAILABLE_IN_2_82 GLIB_UNAVAILABLE (2, 82) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_82 GLIB_UNAVAILABLE_STATIC_INLINE (2, 82) +#define GLIB_AVAILABLE_MACRO_IN_2_82 GLIB_UNAVAILABLE_MACRO (2, 82) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_82 GLIB_UNAVAILABLE_ENUMERATOR (2, 82) +#define GLIB_AVAILABLE_TYPE_IN_2_82 GLIB_UNAVAILABLE_TYPE (2, 82) +#else +#define GLIB_AVAILABLE_IN_2_82 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_82 +#define GLIB_AVAILABLE_MACRO_IN_2_82 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_82 +#define GLIB_AVAILABLE_TYPE_IN_2_82 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_84 +#define GLIB_DEPRECATED_IN_2_84 GLIB_DEPRECATED +#define GLIB_DEPRECATED_IN_2_84_FOR(f) GLIB_DEPRECATED_FOR (f) +#define GLIB_DEPRECATED_MACRO_IN_2_84 GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_IN_2_84_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_84 GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GLIB_DEPRECATED_TYPE_IN_2_84 GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_IN_2_84_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GLIB_DEPRECATED_IN_2_84 _GLIB_EXTERN +#define GLIB_DEPRECATED_IN_2_84_FOR(f) _GLIB_EXTERN +#define GLIB_DEPRECATED_MACRO_IN_2_84 +#define GLIB_DEPRECATED_MACRO_IN_2_84_FOR(f) +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_84 +#define GLIB_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) +#define GLIB_DEPRECATED_TYPE_IN_2_84 +#define GLIB_DEPRECATED_TYPE_IN_2_84_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_84 +#define GLIB_AVAILABLE_IN_2_84 GLIB_UNAVAILABLE (2, 84) +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_84 GLIB_UNAVAILABLE_STATIC_INLINE (2, 84) +#define GLIB_AVAILABLE_MACRO_IN_2_84 GLIB_UNAVAILABLE_MACRO (2, 84) +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_84 GLIB_UNAVAILABLE_ENUMERATOR (2, 84) +#define GLIB_AVAILABLE_TYPE_IN_2_84 GLIB_UNAVAILABLE_TYPE (2, 84) +#else +#define GLIB_AVAILABLE_IN_2_84 _GLIB_EXTERN +#define GLIB_AVAILABLE_STATIC_INLINE_IN_2_84 +#define GLIB_AVAILABLE_MACRO_IN_2_84 +#define GLIB_AVAILABLE_ENUMERATOR_IN_2_84 +#define GLIB_AVAILABLE_TYPE_IN_2_84 +#endif diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/glist.h b/illumos-x86_64/usr/include/glib-2.0/glib/glist.h new file mode 100644 index 00000000..2a453b79 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/glist.h @@ -0,0 +1,179 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_LIST_H__ +#define __G_LIST_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GList GList; + +struct _GList +{ + gpointer data; + GList *next; + GList *prev; +}; + +/* Doubly linked lists + */ +GLIB_AVAILABLE_IN_ALL +GList* g_list_alloc (void) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +void g_list_free (GList *list); +GLIB_AVAILABLE_IN_ALL +void g_list_free_1 (GList *list); +#define g_list_free1 g_list_free_1 +GLIB_AVAILABLE_IN_ALL +void g_list_free_full (GList *list, + GDestroyNotify free_func); +GLIB_AVAILABLE_IN_ALL +GList* g_list_append (GList *list, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_prepend (GList *list, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_insert (GList *list, + gpointer data, + gint position) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_insert_sorted (GList *list, + gpointer data, + GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_insert_sorted_with_data (GList *list, + gpointer data, + GCompareDataFunc func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_insert_before (GList *list, + GList *sibling, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_2_62 +GList* g_list_insert_before_link (GList *list, + GList *sibling, + GList *link_) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_concat (GList *list1, + GList *list2) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_remove (GList *list, + gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_remove_all (GList *list, + gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_remove_link (GList *list, + GList *llink) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_delete_link (GList *list, + GList *link_) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_reverse (GList *list) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_copy (GList *list) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_2_34 +GList* g_list_copy_deep (GList *list, + GCopyFunc func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_ALL +GList* g_list_nth (GList *list, + guint n); +GLIB_AVAILABLE_IN_ALL +GList* g_list_nth_prev (GList *list, + guint n); +GLIB_AVAILABLE_IN_ALL +GList* g_list_find (GList *list, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GList* g_list_find_custom (GList *list, + gconstpointer data, + GCompareFunc func); +GLIB_AVAILABLE_IN_ALL +gint g_list_position (GList *list, + GList *llink); +GLIB_AVAILABLE_IN_ALL +gint g_list_index (GList *list, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GList* g_list_last (GList *list); +GLIB_AVAILABLE_IN_ALL +GList* g_list_first (GList *list); +GLIB_AVAILABLE_IN_ALL +guint g_list_length (GList *list); +GLIB_AVAILABLE_IN_ALL +void g_list_foreach (GList *list, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GList* g_list_sort (GList *list, + GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_sort_with_data (GList *list, + GCompareDataFunc compare_func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gpointer g_list_nth_data (GList *list, + guint n); + +GLIB_AVAILABLE_IN_2_64 +void g_clear_list (GList **list_ptr, + GDestroyNotify destroy); + +#define g_clear_list(list_ptr, destroy) \ + G_STMT_START { \ + GList *_list; \ + \ + _list = *(list_ptr); \ + if (_list) \ + { \ + *list_ptr = NULL; \ + \ + if ((destroy) != NULL) \ + g_list_free_full (_list, (destroy)); \ + else \ + g_list_free (_list); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_64 + + +#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL) +#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) + +G_END_DECLS + +#endif /* __G_LIST_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gmacros.h b/illumos-x86_64/usr/include/glib-2.0/glib/gmacros.h new file mode 100644 index 00000000..c686e809 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gmacros.h @@ -0,0 +1,1433 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +/* This file must not include any other glib header file and must thus + * not refer to variables from glibconfig.h + */ + +#ifndef __G_MACROS_H__ +#define __G_MACROS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* We include stddef.h to get the system's definition of NULL + */ +#include + +/* + * Note: Clang (but not clang-cl) defines __GNUC__ and __GNUC_MINOR__. + * Both Clang 11.1 on current Arch Linux and Apple's Clang 12.0 define + * __GNUC__ = 4 and __GNUC_MINOR__ = 2. So G_GNUC_CHECK_VERSION(4, 2) on + * current Clang will be 1. + */ +#ifdef __GNUC__ +#define G_GNUC_CHECK_VERSION(major, minor) \ + ((__GNUC__ > (major)) || \ + ((__GNUC__ == (major)) && \ + (__GNUC_MINOR__ >= (minor)))) +#else +#define G_GNUC_CHECK_VERSION(major, minor) 0 +#endif + +/* Here we provide G_GNUC_EXTENSION as an alias for __extension__, + * where this is valid. This allows for warningless compilation of + * "long long" types even in the presence of '-ansi -pedantic'. + */ +#if G_GNUC_CHECK_VERSION(2, 8) +#define G_GNUC_EXTENSION __extension__ +#else +#define G_GNUC_EXTENSION +#endif + +#if !defined (__cplusplus) + +# undef G_CXX_STD_VERSION +# define G_CXX_STD_CHECK_VERSION(version) (0) + +# if defined (__STDC_VERSION__) +# define G_C_STD_VERSION __STDC_VERSION__ +# else +# define G_C_STD_VERSION 199000L +# endif /* defined (__STDC_VERSION__) */ + +# define G_C_STD_CHECK_VERSION(version) ( \ + ((version) >= 199000L && (version) <= G_C_STD_VERSION) || \ + ((version) == 89 && G_C_STD_VERSION >= 199000L) || \ + ((version) == 90 && G_C_STD_VERSION >= 199000L) || \ + ((version) == 99 && G_C_STD_VERSION >= 199901L) || \ + ((version) == 11 && G_C_STD_VERSION >= 201112L) || \ + ((version) == 17 && G_C_STD_VERSION >= 201710L) || \ + 0) + +#else /* defined (__cplusplus) */ + +# undef G_C_STD_VERSION +# define G_C_STD_CHECK_VERSION(version) (0) + +# if defined (_MSVC_LANG) +# define G_CXX_STD_VERSION (_MSVC_LANG > __cplusplus ? _MSVC_LANG : __cplusplus) +# else +# define G_CXX_STD_VERSION __cplusplus +# endif /* defined(_MSVC_LANG) */ + +# define G_CXX_STD_CHECK_VERSION(version) ( \ + ((version) >= 199711L && (version) <= G_CXX_STD_VERSION) || \ + ((version) == 98 && G_CXX_STD_VERSION >= 199711L) || \ + ((version) == 03 && G_CXX_STD_VERSION >= 199711L) || \ + ((version) == 11 && G_CXX_STD_VERSION >= 201103L) || \ + ((version) == 14 && G_CXX_STD_VERSION >= 201402L) || \ + ((version) == 17 && G_CXX_STD_VERSION >= 201703L) || \ + ((version) == 20 && G_CXX_STD_VERSION >= 202002L) || \ + 0) + +#endif /* !defined (__cplusplus) */ + +/* Every compiler that we target supports inlining, but some of them may + * complain about it if we don't say "__inline". If we have C99, or if + * we are using C++, then we can use "inline" directly. + * Otherwise, we say "__inline" to avoid the warning. + * Unfortunately Visual Studio does not define __STDC_VERSION__ (if not + * using /std:cXX) so we need to check whether we are on Visual Studio 2013 + * or earlier to see whether we need to say "__inline" in C mode. + */ +#define G_CAN_INLINE +#ifdef G_C_STD_VERSION +# ifdef _MSC_VER +# if (_MSC_VER < 1900) +# define G_INLINE_DEFINE_NEEDED +# endif +# elif !G_C_STD_CHECK_VERSION (99) +# define G_INLINE_DEFINE_NEEDED +# endif +#endif + +#ifdef G_INLINE_DEFINE_NEEDED +# undef inline +# define inline __inline +#endif + +#undef G_INLINE_DEFINE_NEEDED + +/** + * G_INLINE_FUNC: + * + * This macro used to be used to conditionally define inline functions + * in a compatible way before this feature was supported in all + * compilers. These days, GLib requires inlining support from the + * compiler, so your GLib-using programs can safely assume that the + * "inline" keyword works properly. + * + * Never use this macro anymore. Just say "static inline". + * + * Deprecated: 2.48: Use "static inline" instead + */ + +/* For historical reasons we need to continue to support those who + * define G_IMPLEMENT_INLINES to mean "don't implement this here". + */ +#ifdef G_IMPLEMENT_INLINES +# define G_INLINE_FUNC extern GLIB_DEPRECATED_MACRO_IN_2_48_FOR(static inline) +# undef G_CAN_INLINE +#else +# define G_INLINE_FUNC static inline GLIB_DEPRECATED_MACRO_IN_2_48_FOR(static inline) +#endif /* G_IMPLEMENT_INLINES */ + +/* + * Attribute support detection. Works on clang and GCC >= 5 + * https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute + * https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html + */ + +#ifdef __has_attribute +#define g_macro__has_attribute __has_attribute +#else + +/* + * Fallback for GCC < 5 and other compilers not supporting __has_attribute. + */ +#define g_macro__has_attribute(x) g_macro__has_attribute_##x + +#define g_macro__has_attribute___alloc_size__ G_GNUC_CHECK_VERSION (4, 3) +#define g_macro__has_attribute___always_inline__ G_GNUC_CHECK_VERSION (2, 0) +#define g_macro__has_attribute___const__ G_GNUC_CHECK_VERSION (2, 4) +#define g_macro__has_attribute___deprecated__ G_GNUC_CHECK_VERSION (3, 1) +#define g_macro__has_attribute___format__ G_GNUC_CHECK_VERSION (2, 4) +#define g_macro__has_attribute___format_arg__ G_GNUC_CHECK_VERSION (2, 4) +#define g_macro__has_attribute___malloc__ G_GNUC_CHECK_VERSION (2, 96) +#define g_macro__has_attribute___no_instrument_function__ G_GNUC_CHECK_VERSION (2, 4) +#define g_macro__has_attribute___noinline__ G_GNUC_CHECK_VERSION (2, 96) +#define g_macro__has_attribute___noreturn__ (G_GNUC_CHECK_VERSION (2, 8) || (0x5110 <= __SUNPRO_C)) +#define g_macro__has_attribute___pure__ G_GNUC_CHECK_VERSION (2, 96) +#define g_macro__has_attribute___sentinel__ G_GNUC_CHECK_VERSION (4, 0) +#define g_macro__has_attribute___unused__ G_GNUC_CHECK_VERSION (2, 4) +#define g_macro__has_attribute___weak__ G_GNUC_CHECK_VERSION (2, 8) +#define g_macro__has_attribute_cleanup G_GNUC_CHECK_VERSION (3, 3) +#define g_macro__has_attribute_fallthrough G_GNUC_CHECK_VERSION (6, 0) +#define g_macro__has_attribute_may_alias G_GNUC_CHECK_VERSION (3, 3) +#define g_macro__has_attribute_warn_unused_result G_GNUC_CHECK_VERSION (3, 4) +#define g_macro__has_attribute_no_sanitize_address 0 +#define g_macro__has_attribute_ifunc 0 + +#endif + +/* Provide macros to feature the GCC function attribute. + */ + +/** + * G_GNUC_PURE: + * + * Expands to the GNU C `pure` function attribute if the compiler is gcc. + * Declaring a function as `pure` enables better optimization of calls to + * the function. A `pure` function has no effects except its return value + * and the return value depends only on the parameters and/or global + * variables. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * gboolean g_type_check_value (const GValue *value) G_GNUC_PURE; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute) for more details. + */ + +/** + * G_GNUC_MALLOC: + * + * Expands to the + * [GNU C `malloc` function attribute](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-functions-that-behave-like-malloc) + * if the compiler is gcc. + * Declaring a function as `malloc` enables better optimization of the function, + * but must only be done if the allocation behaviour of the function is fully + * understood, otherwise miscompilation can result. + * + * A function can have the `malloc` attribute if it returns a pointer which is + * guaranteed to not alias with any other pointer valid when the function + * returns, and moreover no pointers to valid objects occur in any storage + * addressed by the returned pointer. + * + * In practice, this means that `G_GNUC_MALLOC` can be used with any function + * which returns unallocated or zeroed-out memory, but not with functions which + * return initialised structures containing other pointers, or with functions + * that reallocate memory. This definition changed in GLib 2.58 to match the + * stricter definition introduced around GCC 5. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-functions-that-behave-like-malloc) + * for more details. + * + * Since: 2.6 + */ + +/** + * G_GNUC_NO_INLINE: + * + * Expands to the GNU C `noinline` function attribute if the compiler is gcc. + * If the compiler is not gcc, this macro expands to nothing. + * + * Declaring a function as `noinline` prevents the function from being + * considered for inlining. + * + * This macro is provided for retro-compatibility and will be eventually + * deprecated, but %G_NO_INLINE should be used instead. + * + * The attribute may be placed before the declaration or definition, + * right before the `static` keyword. + * + * |[ + * G_GNUC_NO_INLINE + * static int + * do_not_inline_this (void) + * { + * ... + * } + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute) + * for more details. + * + * See also: %G_NO_INLINE, %G_ALWAYS_INLINE. + * + * Since: 2.58 + */ + +#if g_macro__has_attribute(__pure__) +#define G_GNUC_PURE __attribute__((__pure__)) +#else +#define G_GNUC_PURE +#endif + +#if g_macro__has_attribute(__malloc__) +#define G_GNUC_MALLOC __attribute__ ((__malloc__)) +#else +#define G_GNUC_MALLOC +#endif + +#if g_macro__has_attribute(__noinline__) +#define G_GNUC_NO_INLINE __attribute__ ((__noinline__)) \ + GLIB_AVAILABLE_MACRO_IN_2_58 +#else +#define G_GNUC_NO_INLINE \ + GLIB_AVAILABLE_MACRO_IN_2_58 +#endif + +/** + * G_GNUC_NULL_TERMINATED: + * + * Expands to the GNU C `sentinel` function attribute if the compiler is gcc. + * This function attribute only applies to variadic functions and instructs + * the compiler to check that the argument list is terminated with an + * explicit %NULL. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * gchar *g_strconcat (const gchar *string1, + * ...) G_GNUC_NULL_TERMINATED; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-sentinel-function-attribute) for more details. + * + * Since: 2.8 + */ +#if g_macro__has_attribute(__sentinel__) +#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) +#else +#define G_GNUC_NULL_TERMINATED +#endif + +/* + * Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html + * These are not available on GCC, but since the pre-processor doesn't do + * operator short-circuiting, we can't use it in a statement or we'll get: + * + * error: missing binary operator before token "(" + * + * So we define it to 0 to satisfy the pre-processor. + */ + +#ifdef __has_feature +#define g_macro__has_feature __has_feature +#else +#define g_macro__has_feature(x) 0 +#endif + +#ifdef __has_builtin +#define g_macro__has_builtin __has_builtin +#else +#define g_macro__has_builtin(x) 0 +#endif + +#ifdef __has_extension +#define g_macro__has_extension __has_extension +#else +#define g_macro__has_extension(x) 0 +#endif + +/** + * G_GNUC_ALLOC_SIZE: + * @x: the index of the argument specifying the allocation size + * + * Expands to the GNU C `alloc_size` function attribute if the compiler + * is a new enough gcc. This attribute tells the compiler that the + * function returns a pointer to memory of a size that is specified + * by the @xth function parameter. + * + * Place the attribute after the function declaration, just before the + * semicolon. + * + * |[ + * gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute) for more details. + * + * Since: 2.18 + */ + +/** + * G_GNUC_ALLOC_SIZE2: + * @x: the index of the argument specifying one factor of the allocation size + * @y: the index of the argument specifying the second factor of the allocation size + * + * Expands to the GNU C `alloc_size` function attribute if the compiler is a + * new enough gcc. This attribute tells the compiler that the function returns + * a pointer to memory of a size that is specified by the product of two + * function parameters. + * + * Place the attribute after the function declaration, just before the + * semicolon. + * + * |[ + * gpointer g_malloc_n (gsize n_blocks, + * gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1, 2); + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute) for more details. + * + * Since: 2.18 + */ +#if g_macro__has_attribute(__alloc_size__) +#define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) +#define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y))) +#else +#define G_GNUC_ALLOC_SIZE(x) +#define G_GNUC_ALLOC_SIZE2(x,y) +#endif + +/** + * G_GNUC_PRINTF: + * @format_idx: the index of the argument corresponding to the + * format string (the arguments are numbered from 1) + * @arg_idx: the index of the first of the format arguments, or 0 if + * there are no format arguments + * + * Expands to the GNU C `format` function attribute if the compiler is gcc. + * This is used for declaring functions which take a variable number of + * arguments, with the same syntax as `printf()`. It allows the compiler + * to type-check the arguments passed to the function. + * + * Place the attribute after the function declaration, just before the + * semicolon. + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) + * for more details. + * + * |[ + * gint g_snprintf (gchar *string, + * gulong n, + * gchar const *format, + * ...) G_GNUC_PRINTF (3, 4); + * ]| + */ + +/** + * G_GNUC_SCANF: + * @format_idx: the index of the argument corresponding to + * the format string (the arguments are numbered from 1) + * @arg_idx: the index of the first of the format arguments, or 0 if + * there are no format arguments + * + * Expands to the GNU C `format` function attribute if the compiler is gcc. + * This is used for declaring functions which take a variable number of + * arguments, with the same syntax as `scanf()`. It allows the compiler + * to type-check the arguments passed to the function. + * + * |[ + * int my_scanf (MyStream *stream, + * const char *format, + * ...) G_GNUC_SCANF (2, 3); + * int my_vscanf (MyStream *stream, + * const char *format, + * va_list ap) G_GNUC_SCANF (2, 0); + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) + * for details. + */ + +/** + * G_GNUC_STRFTIME: + * @format_idx: the index of the argument corresponding to + * the format string (the arguments are numbered from 1) + * + * Expands to the GNU C `strftime` format function attribute if the compiler + * is gcc. This is used for declaring functions which take a format argument + * which is passed to `strftime()` or an API implementing its formats. It allows + * the compiler check the format passed to the function. + * + * |[ + * gsize my_strftime (MyBuffer *buffer, + * const char *format, + * const struct tm *tm) G_GNUC_STRFTIME (2); + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) + * for details. + * + * Since: 2.60 + */ + +/** + * G_GNUC_FORMAT: + * @arg_idx: the index of the argument + * + * Expands to the GNU C `format_arg` function attribute if the compiler + * is gcc. This function attribute specifies that a function takes a + * format string for a `printf()`, `scanf()`, `strftime()` or `strfmon()` style + * function and modifies it, so that the result can be passed to a `printf()`, + * `scanf()`, `strftime()` or `strfmon()` style function (with the remaining + * arguments to the format function the same as they would have been + * for the unmodified string). + * + * Place the attribute after the function declaration, just before the + * semicolon. + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-nonliteral-1) for more details. + * + * |[ + * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2); + * ]| + */ + +/** + * G_GNUC_NORETURN: + * + * Expands to the GNU C `noreturn` function attribute if the compiler is gcc. + * It is used for declaring functions which never return. It enables + * optimization of the function, and avoids possible compiler warnings. + * + * Since 2.68, it is recommended that code uses %G_NORETURN instead of + * %G_GNUC_NORETURN, as that works on more platforms and compilers (in + * particular, MSVC and C++11) than %G_GNUC_NORETURN, which works with GCC and + * Clang only. %G_GNUC_NORETURN continues to work, so has not been deprecated + * yet. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * void g_abort (void) G_GNUC_NORETURN; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute) for more details. + */ + +/** + * G_GNUC_CONST: + * + * Expands to the GNU C `const` function attribute if the compiler is gcc. + * Declaring a function as `const` enables better optimization of calls to + * the function. A `const` function doesn't examine any values except its + * parameters, and has no effects except its return value. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * gchar g_ascii_tolower (gchar c) G_GNUC_CONST; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute) for more details. + * + * A function that has pointer arguments and examines the data pointed to + * must not be declared `const`. Likewise, a function that calls a non-`const` + * function usually must not be `const`. It doesn't make sense for a `const` + * function to return `void`. + */ + +/** + * G_GNUC_UNUSED: + * + * Expands to the GNU C `unused` function attribute if the compiler is gcc. + * It is used for declaring functions and arguments which may never be used. + * It avoids possible compiler warnings. + * + * For functions, place the attribute after the declaration, just before the + * semicolon. For arguments, place the attribute at the beginning of the + * argument declaration. + * + * |[ + * void my_unused_function (G_GNUC_UNUSED gint unused_argument, + * gint other_argument) G_GNUC_UNUSED; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-unused-function-attribute) for more details. + */ + +/** + * G_GNUC_NO_INSTRUMENT: + * + * Expands to the GNU C `no_instrument_function` function attribute if the + * compiler is gcc. Functions with this attribute will not be instrumented + * for profiling, when the compiler is called with the + * `-finstrument-functions` option. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * int do_uninteresting_things (void) G_GNUC_NO_INSTRUMENT; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005finstrument_005ffunction-function-attribute) for more details. + */ + +#if g_macro__has_attribute(__format__) + +#if !defined (__clang__) && G_GNUC_CHECK_VERSION (4, 4) +#define G_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((__format__ (gnu_printf, format_idx, arg_idx))) +#define G_GNUC_SCANF( format_idx, arg_idx ) \ + __attribute__((__format__ (gnu_scanf, format_idx, arg_idx))) +#define G_GNUC_STRFTIME( format_idx ) \ + __attribute__((__format__ (gnu_strftime, format_idx, 0))) \ + GLIB_AVAILABLE_MACRO_IN_2_60 +#else +#define G_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#define G_GNUC_SCANF( format_idx, arg_idx ) \ + __attribute__((__format__ (__scanf__, format_idx, arg_idx))) +#define G_GNUC_STRFTIME( format_idx ) \ + __attribute__((__format__ (__strftime__, format_idx, 0))) \ + GLIB_AVAILABLE_MACRO_IN_2_60 +#endif + +#else + +#define G_GNUC_PRINTF( format_idx, arg_idx ) +#define G_GNUC_SCANF( format_idx, arg_idx ) +#define G_GNUC_STRFTIME( format_idx ) \ + GLIB_AVAILABLE_MACRO_IN_2_60 + +#endif + +#if g_macro__has_attribute(__format_arg__) +#define G_GNUC_FORMAT(arg_idx) \ + __attribute__ ((__format_arg__ (arg_idx))) +#else +#define G_GNUC_FORMAT( arg_idx ) +#endif + +#if g_macro__has_attribute(__noreturn__) +#define G_GNUC_NORETURN \ + __attribute__ ((__noreturn__)) +#else +/* NOTE: MSVC has __declspec(noreturn) but unlike GCC __attribute__, + * __declspec can only be placed at the start of the function prototype + * and not at the end, so we can't use it without breaking API. + */ +#define G_GNUC_NORETURN +#endif + +#if g_macro__has_attribute(__const__) +#define G_GNUC_CONST \ + __attribute__ ((__const__)) +#else +#define G_GNUC_CONST +#endif + +#if g_macro__has_attribute(__unused__) +#define G_GNUC_UNUSED \ + __attribute__ ((__unused__)) +#else +#define G_GNUC_UNUSED +#endif + +#if g_macro__has_attribute(__no_instrument_function__) +#define G_GNUC_NO_INSTRUMENT \ + __attribute__ ((__no_instrument_function__)) +#else +#define G_GNUC_NO_INSTRUMENT +#endif + +/** + * G_GNUC_FALLTHROUGH: + * + * Expands to the GNU C `fallthrough` statement attribute if the compiler supports it. + * This allows declaring case statement to explicitly fall through in switch + * statements. To enable this feature, use `-Wimplicit-fallthrough` during + * compilation. + * + * Put the attribute right before the case statement you want to fall through + * to. + * + * |[ + * switch (foo) + * { + * case 1: + * g_message ("it's 1"); + * G_GNUC_FALLTHROUGH; + * case 2: + * g_message ("it's either 1 or 2"); + * break; + * } + * ]| + * + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#index-fallthrough-statement-attribute) for more details. + * + * Since: 2.60 + */ +#if g_macro__has_attribute(fallthrough) +#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) \ + GLIB_AVAILABLE_MACRO_IN_2_60 +#else +#define G_GNUC_FALLTHROUGH \ + GLIB_AVAILABLE_MACRO_IN_2_60 +#endif + +/** + * G_GNUC_DEPRECATED: + * + * Expands to the GNU C `deprecated` attribute if the compiler is gcc. + * It can be used to mark `typedef`s, variables and functions as deprecated. + * When called with the `-Wdeprecated-declarations` option, + * gcc will generate warnings when deprecated interfaces are used. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * int my_mistake (void) G_GNUC_DEPRECATED; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-deprecated-function-attribute) for more details. + * + * Since: 2.2 + */ +#if g_macro__has_attribute(__deprecated__) +#define G_GNUC_DEPRECATED __attribute__((__deprecated__)) +#else +#define G_GNUC_DEPRECATED +#endif /* __GNUC__ */ + +/** + * G_GNUC_DEPRECATED_FOR: + * @f: the intended replacement for the deprecated symbol, + * such as the name of a function + * + * Like %G_GNUC_DEPRECATED, but names the intended replacement for the + * deprecated symbol if the version of gcc in use is new enough to support + * custom deprecation messages. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * int my_mistake (void) G_GNUC_DEPRECATED_FOR(my_replacement); + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-deprecated-function-attribute) for more details. + * + * Note that if @f is a macro, it will be expanded in the warning message. + * You can enclose it in quotes to prevent this. (The quotes will show up + * in the warning, but it's better than showing the macro expansion.) + * + * Since: 2.26 + */ +#if G_GNUC_CHECK_VERSION(4, 5) || defined(__clang__) +#define G_GNUC_DEPRECATED_FOR(f) \ + __attribute__((deprecated("Use " #f " instead"))) \ + GLIB_AVAILABLE_MACRO_IN_2_26 +#else +#define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED \ + GLIB_AVAILABLE_MACRO_IN_2_26 +#endif /* __GNUC__ */ + +#ifdef __ICC +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma ("warning (push)") \ + _Pragma ("warning (disable:1478)") +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma ("warning (pop)") +#elif G_GNUC_CHECK_VERSION(4, 6) +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma ("GCC diagnostic pop") +#elif defined (_MSC_VER) && (_MSC_VER >= 1500) && !defined (__clang__) +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + __pragma (warning (push)) \ + __pragma (warning (disable : 4996)) +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + __pragma (warning (pop)) +#elif defined (__clang__) +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic pop") +#else +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS +#define G_GNUC_END_IGNORE_DEPRECATIONS +#define GLIB_CANNOT_IGNORE_DEPRECATIONS +#endif + +/** + * G_GNUC_MAY_ALIAS: + * + * Expands to the GNU C `may_alias` type attribute if the compiler is gcc. + * Types with this attribute will not be subjected to type-based alias + * analysis, but are assumed to alias with any other type, just like `char`. + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-may_005falias-type-attribute) for details. + * + * Since: 2.14 + */ +#if g_macro__has_attribute(may_alias) +#define G_GNUC_MAY_ALIAS __attribute__((may_alias)) +#else +#define G_GNUC_MAY_ALIAS +#endif + +/** + * G_GNUC_WARN_UNUSED_RESULT: + * + * Expands to the GNU C `warn_unused_result` function attribute if the compiler + * is gcc. This function attribute makes the compiler emit a warning if the + * result of a function call is ignored. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * GList *g_list_append (GList *list, + * gpointer data) G_GNUC_WARN_UNUSED_RESULT; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warn_005funused_005fresult-function-attribute) for more details. + * + * Since: 2.10 + */ +#if g_macro__has_attribute(warn_unused_result) +#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define G_GNUC_WARN_UNUSED_RESULT +#endif /* __GNUC__ */ + +/** + * G_GNUC_FUNCTION: + * + * Expands to "" on all modern compilers, and to __FUNCTION__ on gcc + * version 2.x. Don't use it. + * + * Deprecated: 2.16: Use G_STRFUNC() instead + */ + +/** + * G_GNUC_PRETTY_FUNCTION: + * + * Expands to "" on all modern compilers, and to __PRETTY_FUNCTION__ + * on gcc version 2.x. Don't use it. + * + * Deprecated: 2.16: Use G_STRFUNC() instead + */ + +/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with + * macros, so we can refer to them as strings unconditionally. + * usage not-recommended since gcc-3.0 + * + * Mark them as deprecated since 2.26, since that’s when version macros were + * introduced. + */ +#if defined (__GNUC__) && (__GNUC__ < 3) +#define G_GNUC_FUNCTION __FUNCTION__ GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) +#define G_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__ GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) +#else /* !__GNUC__ */ +#define G_GNUC_FUNCTION "" GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) +#define G_GNUC_PRETTY_FUNCTION "" GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) +#endif /* !__GNUC__ */ + +#if g_macro__has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__) +#define G_ANALYZER_ANALYZING 1 +#define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +#elif defined(__COVERITY__) +#define G_ANALYZER_ANALYZING 1 +#define G_ANALYZER_NORETURN __attribute__((noreturn)) +#else +#define G_ANALYZER_ANALYZING 0 +#define G_ANALYZER_NORETURN +#endif + +#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string) +#define G_STRINGIFY_ARG(contents) #contents + +#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 +#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2) + +#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */ +#if G_CXX_STD_CHECK_VERSION (11) +#define G_STATIC_ASSERT(expr) static_assert (expr, "Expression evaluates to false") +#elif (G_C_STD_CHECK_VERSION (11) || \ + g_macro__has_feature(c_static_assert) || g_macro__has_extension(c_static_assert)) +#define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false") +#else +#ifdef __COUNTER__ +#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED +#else +#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __LINE__)[(expr) ? 1 : -1] G_GNUC_UNUSED +#endif +#endif /* G_CXX_STD_CHECK_VERSION (11) */ +#define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1 : -1])) +#else /* __GI_SCANNER__ */ +#define G_STATIC_ASSERT(expr) static int G_PASTE (_GStaticAssertGiScannerNoop, __LINE__) G_GNUC_UNUSED +#define G_STATIC_ASSERT_EXPR(expr) static int G_PASTE (_GStaticAssertGiScannerNoop, __LINE__) G_GNUC_UNUSED +#endif /* __GI_SCANNER__ */ + +/* Provide a string identifying the current code position */ +#if defined (__GNUC__) && (__GNUC__ < 3) && !defined (G_CXX_STD_VERSION) +#define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()" +#else +#define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) +#endif + +/* Provide a string identifying the current function, non-concatenatable */ +#if defined (__GNUC__) && defined (G_CXX_STD_VERSION) +#define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) +#elif G_C_STD_CHECK_VERSION (99) +#define G_STRFUNC ((const char*) (__func__)) +#elif defined (__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1300)) +#define G_STRFUNC ((const char*) (__FUNCTION__)) +#else +#define G_STRFUNC ((const char*) ("???")) +#endif + +/* Guard C code in headers, while including them from C++ */ +#ifdef G_CXX_STD_VERSION +#define G_BEGIN_DECLS extern "C" { +#define G_END_DECLS } +#else +#define G_BEGIN_DECLS +#define G_END_DECLS +#endif + +/* Provide definitions for some commonly used macros. + * Some of them are only provided if they haven't already + * been defined. It is assumed that if they are already + * defined then the current definition is correct. + */ +#ifndef NULL +# if G_CXX_STD_CHECK_VERSION (11) +# define NULL (nullptr) +# elif defined (G_CXX_STD_VERSION) +# define NULL (0L) +# else +# define NULL ((void*) 0) +# endif /* G_CXX_STD_CHECK_VERSION (11) */ +#endif + +#ifndef FALSE +#define FALSE (0) +#endif + +#ifndef TRUE +#define TRUE (!FALSE) +#endif + +#undef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +#undef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +#undef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) + +#undef CLAMP +#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) + +#define G_APPROX_VALUE(a, b, epsilon) \ + (((a) > (b) ? (a) - (b) : (b) - (a)) < (epsilon)) + +/* Count the number of elements in an array. The array must be defined + * as such; using this with a dynamically allocated array will give + * incorrect results. + */ +#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0])) + +/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT + */ +#define GPOINTER_TO_SIZE(p) ((gsize) (p)) +#define GSIZE_TO_POINTER(s) ((gpointer) (guintptr) (gsize) (s)) + +/* Provide convenience macros for handling structure + * fields through their offsets. + */ + +#if G_GNUC_CHECK_VERSION(4, 0) || defined(_MSC_VER) +#define G_STRUCT_OFFSET(struct_type, member) \ + ((glong) offsetof (struct_type, member)) +#else +#define G_STRUCT_OFFSET(struct_type, member) \ + ((glong) ((guint8*) &((struct_type*) 0)->member)) +#endif + +#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \ + ((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset))) +#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \ + (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset))) + +/* Provide simple macro statement wrappers: + * G_STMT_START { statements; } G_STMT_END; + * This can be used as a single statement, like: + * if (x) G_STMT_START { ... } G_STMT_END; else ... + * This intentionally does not use compiler extensions like GCC's '({...})' to + * avoid portability issue or side effects when compiled with different compilers. + * MSVC complains about "while(0)": C4127: "Conditional expression is constant", + * so we use __pragma to avoid the warning since the use here is intentional. + */ +#if !(defined (G_STMT_START) && defined (G_STMT_END)) +#define G_STMT_START do +#if defined (_MSC_VER) && (_MSC_VER >= 1500) +#define G_STMT_END \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + while(0) \ + __pragma(warning(pop)) +#else +#define G_STMT_END while (0) +#endif +#endif + +/* Provide G_ALIGNOF alignment macro. + * + * Note we cannot use the gcc __alignof__ operator here, as that returns the + * preferred alignment rather than the minimal alignment. See + * https://gitlab.gnome.org/GNOME/glib/merge_requests/538/diffs#note_390790. + */ + +/** + * G_ALIGNOF + * @type: a type-name + * + * Return the minimal alignment required by the platform ABI for values of the given + * type. The address of a variable or struct member of the given type must always be + * a multiple of this alignment. For example, most platforms require int variables + * to be aligned at a 4-byte boundary, so `G_ALIGNOF (int)` is 4 on most platforms. + * + * Note this is not necessarily the same as the value returned by GCC’s + * `__alignof__` operator, which returns the preferred alignment for a type. + * The preferred alignment may be a stricter alignment than the minimal + * alignment. + * + * Since: 2.60 + */ +#if G_C_STD_CHECK_VERSION (11) +#define G_ALIGNOF(type) _Alignof (type) \ + GLIB_AVAILABLE_MACRO_IN_2_60 +#else +#define G_ALIGNOF(type) (G_STRUCT_OFFSET (struct { char a; type b; }, b)) \ + GLIB_AVAILABLE_MACRO_IN_2_60 +#endif + +/** + * G_CONST_RETURN: + * + * If %G_DISABLE_CONST_RETURNS is defined, this macro expands + * to nothing. By default, the macro expands to const. The macro + * can be used in place of const for functions that return a value + * that should not be modified. The purpose of this macro is to allow + * us to turn on const for returned constant strings by default, while + * allowing programmers who find that annoying to turn it off. This macro + * should only be used for return values and for "out" parameters, it + * doesn't make sense for "in" parameters. + * + * Deprecated: 2.30: API providers should replace all existing uses with + * const and API consumers should adjust their code accordingly + */ +#ifdef G_DISABLE_CONST_RETURNS +#define G_CONST_RETURN GLIB_DEPRECATED_MACRO_IN_2_30_FOR(const) +#else +#define G_CONST_RETURN const GLIB_DEPRECATED_MACRO_IN_2_30_FOR(const) +#endif + +/** + * G_NORETURN: + * + * Expands to the GNU C or MSVC `noreturn` function attribute depending on + * the compiler. It is used for declaring functions which never return. + * Enables optimization of the function, and avoids possible compiler warnings. + * + * Note that %G_NORETURN supersedes the previous %G_GNUC_NORETURN macro, which + * will eventually be deprecated. %G_NORETURN supports more platforms. + * + * Place the attribute before the function declaration as follows: + * + * |[ + * G_NORETURN void g_abort (void); + * ]| + * + * Since: 2.68 + */ +/* Note: We can’t annotate this with GLIB_AVAILABLE_MACRO_IN_2_68 because it’s + * used within the GLib headers in function declarations which are always + * evaluated when a header is included. This results in warnings in third party + * code which includes glib.h, even if the third party code doesn’t use the new + * macro itself. */ +#if G_CXX_STD_CHECK_VERSION (11) + /* Use ISO C++11 syntax when the compiler supports it. */ +# define G_NORETURN [[noreturn]] +#elif g_macro__has_attribute(__noreturn__) + /* For compatibility with G_NORETURN_FUNCPTR on clang, use + __attribute__((__noreturn__)), not _Noreturn. */ +# define G_NORETURN __attribute__ ((__noreturn__)) +#elif defined (_MSC_VER) && (1200 <= _MSC_VER) + /* Use MSVC specific syntax. */ +# define G_NORETURN __declspec (noreturn) + /* Use ISO C11 syntax when the compiler supports it. */ +#elif G_C_STD_CHECK_VERSION (11) +# define G_NORETURN _Noreturn +#else +# define G_NORETURN /* empty */ +#endif + +/** + * G_NORETURN_FUNCPTR: + * + * Expands to the GNU C or MSVC `noreturn` function attribute depending on + * the compiler. It is used for declaring function pointers which never return. + * Enables optimization of the function, and avoids possible compiler warnings. + * + * Place the attribute before the function declaration as follows: + * + * |[ + * G_NORETURN_FUNCPTR void (*funcptr) (void); + * ]| + * + * Note that if the function is not a function pointer, you can simply use + * the %G_NORETURN macro as follows: + * + * |[ + * G_NORETURN void g_abort (void); + * ]| + * + * Since: 2.68 + */ +#if g_macro__has_attribute(__noreturn__) +# define G_NORETURN_FUNCPTR __attribute__ ((__noreturn__)) \ + GLIB_AVAILABLE_MACRO_IN_2_68 +#else +# define G_NORETURN_FUNCPTR /* empty */ \ + GLIB_AVAILABLE_MACRO_IN_2_68 +#endif + +/** + * G_ALWAYS_INLINE: + * + * Expands to the GNU C `always_inline` or MSVC `__forceinline` function + * attribute depending on the compiler. It is used for declaring functions + * as always inlined, ignoring the compiler optimization levels. + * + * The attribute may be placed before the declaration or definition, + * right before the `static` keyword. + * + * |[ + * G_ALWAYS_INLINE + * static int + * do_inline_this (void) + * { + * ... + * } + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute) + * and the + * [MSVC documentation](https://docs.microsoft.com/en-us/visualstudio/misc/inline-inline-forceinline) + * + * Since: 2.74 + */ +/* Note: We can’t annotate this with GLIB_AVAILABLE_MACRO_IN_2_74 because it’s + * used within the GLib headers in function declarations which are always + * evaluated when a header is included. This results in warnings in third party + * code which includes glib.h, even if the third party code doesn’t use the new + * macro itself. */ +#if g_macro__has_attribute(__always_inline__) +# if G_CXX_STD_CHECK_VERSION (11) + /* Use ISO C++11 syntax when the compiler supports it. */ +# define G_ALWAYS_INLINE [[gnu::always_inline]] +# else +# define G_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# endif +#elif defined (_MSC_VER) + /* Use MSVC specific syntax. */ +# if G_CXX_STD_CHECK_VERSION (20) && _MSC_VER >= 1927 +# define G_ALWAYS_INLINE [[msvc::forceinline]] +# else +# define G_ALWAYS_INLINE __forceinline +# endif +#else +# define G_ALWAYS_INLINE /* empty */ +#endif + +/** + * G_NO_INLINE: + * + * Expands to the GNU C or MSVC `noinline` function attribute + * depending on the compiler. It is used for declaring functions + * preventing from being considered for inlining. + * + * Note that %G_NO_INLINE supersedes the previous %G_GNUC_NO_INLINE + * macro, which will eventually be deprecated. + * %G_NO_INLINE supports more platforms. + * + * The attribute may be placed before the declaration or definition, + * right before the `static` keyword. + * + * |[ + * G_NO_INLINE + * static int + * do_not_inline_this (void) + * { + * ... + * } + * ]| + * + * Since: 2.74 + */ +/* Note: We can’t annotate this with GLIB_AVAILABLE_MACRO_IN_2_74 because it’s + * used within the GLib headers in function declarations which are always + * evaluated when a header is included. This results in warnings in third party + * code which includes glib.h, even if the third party code doesn’t use the new + * macro itself. */ +#if g_macro__has_attribute(__noinline__) +# if G_CXX_STD_CHECK_VERSION (11) + /* Use ISO C++11 syntax when the compiler supports it. */ +# if defined (__GNUC__) +# define G_NO_INLINE [[gnu::noinline]] +# elif defined (_MSC_VER) +# if G_CXX_STD_CHECK_VERSION (20) && _MSC_VER >= 1927 +# define G_NO_INLINE [[msvc::noinline]] +# else +# define G_NO_INLINE __declspec (noinline) +# endif +# endif +# else +# define G_NO_INLINE __attribute__ ((__noinline__)) +# endif +#elif defined (_MSC_VER) && (1200 <= _MSC_VER) + /* Use MSVC specific syntax. */ + /* Use ISO C++11 syntax when the compiler supports it. */ +# if G_CXX_STD_CHECK_VERSION (20) && _MSC_VER >= 1927 +# define G_NO_INLINE [[msvc::noinline]] +# else +# define G_NO_INLINE __declspec (noinline) +# endif +#else +# define G_NO_INLINE /* empty */ +#endif + +/* + * The G_LIKELY and G_UNLIKELY macros let the programmer give hints to + * the compiler about the expected result of an expression. Some compilers + * can use this information for optimizations. + * + * The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when + * putting assignments in g_return_if_fail (). + */ +#if G_GNUC_CHECK_VERSION(2, 0) && defined(__OPTIMIZE__) +#define _G_BOOLEAN_EXPR_IMPL(uniq, expr) \ + G_GNUC_EXTENSION ({ \ + int G_PASTE (_g_boolean_var_, uniq) = 0; \ + if (expr) \ + G_PASTE (_g_boolean_var_, uniq) = 1; \ + G_PASTE (_g_boolean_var_, uniq); \ +}) +#define _G_BOOLEAN_EXPR(expr) _G_BOOLEAN_EXPR_IMPL (__COUNTER__, expr) +#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) +#define G_UNLIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 0)) +#else +#define G_LIKELY(expr) (expr) +#define G_UNLIKELY(expr) (expr) +#endif + +#if __GNUC__ >= 4 && !defined(_WIN32) && !defined(__CYGWIN__) +#define G_HAVE_GNUC_VISIBILITY 1 +#endif + +/* GLIB_CANNOT_IGNORE_DEPRECATIONS is defined above for compilers that do not + * have a way to temporarily suppress deprecation warnings. In these cases, + * suppress the deprecated attribute altogether (otherwise a simple #include + * will emit a barrage of warnings). + */ +#if defined(GLIB_CANNOT_IGNORE_DEPRECATIONS) +#define G_DEPRECATED +#elif G_GNUC_CHECK_VERSION(3, 1) || defined(__clang__) +#define G_DEPRECATED __attribute__((__deprecated__)) +#elif defined(_MSC_VER) && (_MSC_VER >= 1300) +#define G_DEPRECATED __declspec(deprecated) +#else +#define G_DEPRECATED +#endif + +#if defined(GLIB_CANNOT_IGNORE_DEPRECATIONS) +#define G_DEPRECATED_FOR(f) G_DEPRECATED +#elif G_GNUC_CHECK_VERSION(4, 5) || defined(__clang__) +#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead"))) +#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) +#define G_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) +#else +#define G_DEPRECATED_FOR(f) G_DEPRECATED +#endif + +#if G_GNUC_CHECK_VERSION(4, 5) || defined(__clang__) +#define G_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min))) +#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) +#define G_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min)) +#else +#define G_UNAVAILABLE(maj,min) G_DEPRECATED +#endif + +/* These macros are used to mark deprecated symbols in GLib headers, + * and thus have to be exposed in installed headers. But please + * do *not* use them in other projects. Instead, use G_DEPRECATED + * or define your own wrappers around it. + */ + +#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ + (G_GNUC_CHECK_VERSION(4, 6) || \ + __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4)) +#define _GLIB_GNUC_DO_PRAGMA(x) _Pragma(G_STRINGIFY (x)) +#define GLIB_DEPRECATED_MACRO _GLIB_GNUC_DO_PRAGMA(GCC warning "Deprecated pre-processor symbol") +#define GLIB_DEPRECATED_MACRO_FOR(f) \ + _GLIB_GNUC_DO_PRAGMA(GCC warning G_STRINGIFY (Deprecated pre-processor symbol: replace with #f)) +#define GLIB_UNAVAILABLE_MACRO(maj,min) \ + _GLIB_GNUC_DO_PRAGMA(GCC warning G_STRINGIFY (Not available before maj.min)) +#else +#define GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_FOR(f) +#define GLIB_UNAVAILABLE_MACRO(maj,min) +#endif + +#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ + (G_GNUC_CHECK_VERSION(6, 1) || \ + (defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0)))) +#define GLIB_DEPRECATED_ENUMERATOR G_DEPRECATED +#define GLIB_DEPRECATED_ENUMERATOR_FOR(f) G_DEPRECATED_FOR(f) +#define GLIB_UNAVAILABLE_ENUMERATOR(maj,min) G_UNAVAILABLE(maj,min) +#else +#define GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_FOR(f) +#define GLIB_UNAVAILABLE_ENUMERATOR(maj,min) +#endif + +#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ + (G_GNUC_CHECK_VERSION(3, 1) || \ + (defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0)))) +#define GLIB_DEPRECATED_TYPE G_DEPRECATED +#define GLIB_DEPRECATED_TYPE_FOR(f) G_DEPRECATED_FOR(f) +#define GLIB_UNAVAILABLE_TYPE(maj,min) G_UNAVAILABLE(maj,min) +#else +#define GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_FOR(f) +#define GLIB_UNAVAILABLE_TYPE(maj,min) +#endif + +#ifndef __GI_SCANNER__ + +#if g_macro__has_attribute(cleanup) + +/* these macros are private; note that gstdio.h also uses _GLIB_CLEANUP */ +#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName +#define _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) glib_autoptr_clear_##TypeName +#define _GLIB_AUTOPTR_DESTROY_FUNC_NAME(TypeName) glib_autoptr_destroy_##TypeName +#define _GLIB_AUTOPTR_TYPENAME(TypeName) TypeName##_autoptr +#define _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) glib_listautoptr_cleanup_##TypeName +#define _GLIB_AUTOPTR_LIST_TYPENAME(TypeName) TypeName##_listautoptr +#define _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) glib_slistautoptr_cleanup_##TypeName +#define _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName) TypeName##_slistautoptr +#define _GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName) glib_queueautoptr_cleanup_##TypeName +#define _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName) TypeName##_queueautoptr +#define _GLIB_AUTO_FUNC_NAME(TypeName) glib_auto_cleanup_##TypeName +#define _GLIB_CLEANUP(func) __attribute__((cleanup(func))) +#define _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, ParentName, cleanup) \ + typedef TypeName *_GLIB_AUTOPTR_TYPENAME(TypeName); \ + typedef GList *_GLIB_AUTOPTR_LIST_TYPENAME(TypeName); \ + typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName); \ + typedef GQueue *_GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) (TypeName *_ptr) \ + { if (_ptr) (cleanup) ((ParentName *) _ptr); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) \ + { _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) (*_ptr); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_DESTROY_FUNC_NAME(TypeName) (void *_ptr) \ + { (cleanup) ((ParentName *) _ptr); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) \ + { g_list_free_full (*_l, _GLIB_AUTOPTR_DESTROY_FUNC_NAME(TypeName)); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) \ + { g_slist_free_full (*_l, _GLIB_AUTOPTR_DESTROY_FUNC_NAME(TypeName)); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName) (GQueue **_q) \ + { if (*_q) g_queue_free_full (*_q, _GLIB_AUTOPTR_DESTROY_FUNC_NAME(TypeName)); } \ + G_GNUC_END_IGNORE_DEPRECATIONS +#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) \ + _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(ModuleObjName, ParentName, _GLIB_AUTOPTR_CLEAR_FUNC_NAME(ParentName)) + + +/* these macros are API */ +#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) \ + _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { (func) (_ptr); } \ + G_GNUC_END_IGNORE_DEPRECATIONS +#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { if (*_ptr != none) (func) (*_ptr); } \ + G_GNUC_END_IGNORE_DEPRECATIONS +#define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName) +#define g_autolist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_LIST_TYPENAME(TypeName) +#define g_autoslist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName) +#define g_autoqueue(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName) +#define g_auto(TypeName) _GLIB_CLEANUP(_GLIB_AUTO_FUNC_NAME(TypeName)) TypeName +#define g_autofree _GLIB_CLEANUP(g_autoptr_cleanup_generic_gfree) + +#else /* not GNU C */ +/* this (dummy) macro is private */ +#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) + +/* these (dummy) macros are API */ +#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) + +/* no declaration of g_auto() or g_autoptr() here */ +#endif /* __GNUC__ */ + +#else + +#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) + +#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) + +#endif /* __GI_SCANNER__ */ + +/** + * G_SIZEOF_MEMBER: + * @struct_type: a structure type, e.g. #GOutputVector + * @member: a field in the structure, e.g. `size` + * + * Returns the size of @member in the struct definition without having a + * declared instance of @struct_type. + * + * Returns: the size of @member in bytes. + * + * Since: 2.64 + */ +#define G_SIZEOF_MEMBER(struct_type, member) \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + sizeof (((struct_type *) 0)->member) + +#endif /* __G_MACROS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gmain.h b/illumos-x86_64/usr/include/glib-2.0/glib/gmain.h new file mode 100644 index 00000000..d8a9e21e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gmain.h @@ -0,0 +1,1031 @@ +/* gmain.h - the GLib Main loop + * Copyright (C) 1998-2000 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_MAIN_H__ +#define __G_MAIN_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +typedef enum /*< flags >*/ +{ + G_IO_IN GLIB_SYSDEF_POLLIN, + G_IO_OUT GLIB_SYSDEF_POLLOUT, + G_IO_PRI GLIB_SYSDEF_POLLPRI, + G_IO_ERR GLIB_SYSDEF_POLLERR, + G_IO_HUP GLIB_SYSDEF_POLLHUP, + G_IO_NVAL GLIB_SYSDEF_POLLNVAL +} GIOCondition; + +/** + * GMainContextFlags: + * @G_MAIN_CONTEXT_FLAGS_NONE: Default behaviour. + * @G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING: Assume that polling for events will + * free the thread to process other jobs. That's useful if you're using + * `g_main_context_{prepare,query,check,dispatch}` to integrate GMainContext in + * other event loops. + * + * Flags to pass to [ctor@GLib.MainContext.new_with_flags] which affect the + * behaviour of a [struct@GLib.MainContext]. + * + * Since: 2.72 + */ +GLIB_AVAILABLE_TYPE_IN_2_72 +typedef enum /*< flags >*/ +{ + G_MAIN_CONTEXT_FLAGS_NONE = 0, + G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING = 1 +} GMainContextFlags; + + +/** + * GMainContext: + * + * The `GMainContext` struct is an opaque data + * type representing a set of sources to be handled in a main loop. + */ +typedef struct _GMainContext GMainContext; + +/** + * GMainLoop: + * + * The `GMainLoop` struct is an opaque data type + * representing the main event loop of a GLib or GTK application. + */ +typedef struct _GMainLoop GMainLoop; + +/** + * GSource: + * + * The `GSource` struct is an opaque data type + * representing an event source. + */ +typedef struct _GSource GSource; +typedef struct _GSourcePrivate GSourcePrivate; + +/** + * GSourceCallbackFuncs: + * @ref: Called when a reference is added to the callback object + * @unref: Called when a reference to the callback object is dropped + * @get: Called to extract the callback function and data from the + * callback object. + * + * The `GSourceCallbackFuncs` struct contains + * functions for managing callback objects. + */ +typedef struct _GSourceCallbackFuncs GSourceCallbackFuncs; + +/** + * GSourceFuncs: + * @prepare: Called before all the file descriptors are polled. If the + * source can determine that it is ready here (without waiting for the + * results of the poll() call) it should return %TRUE. It can also return + * a @timeout_ value which should be the maximum timeout (in milliseconds) + * which should be passed to the poll() call. The actual timeout used will + * be -1 if all sources returned -1, or it will be the minimum of all + * the @timeout_ values returned which were >= 0. Since 2.36 this may + * be %NULL, in which case the effect is as if the function always returns + * %FALSE with a timeout of -1. If @prepare returns a + * timeout and the source also has a ready time set, then the + * lower of the two will be used. + * @check: Called after all the file descriptors are polled. The source + * should return %TRUE if it is ready to be dispatched. Note that some + * time may have passed since the previous prepare function was called, + * so the source should be checked again here. Since 2.36 this may + * be %NULL, in which case the effect is as if the function always returns + * %FALSE. + * @dispatch: Called to dispatch the event source, after it has returned + * %TRUE in either its @prepare or its @check function, or if a ready time + * has been reached. The @dispatch function receives a callback function and + * user data. The callback function may be %NULL if the source was never + * connected to a callback using [method@GLib.Source.set_callback]. The + * @dispatch function should call the callback function with @user_data and + * whatever additional parameters are needed for this type of event source. + * The return value of the @dispatch function should be + * [const@GLib.SOURCE_REMOVE] if the source should be removed or + * [const@GLib.SOURCE_CONTINUE] to keep it. + * @finalize: Called when the source is finalized. At this point, the source + * will have been destroyed, had its callback cleared, and have been removed + * from its [struct@GLib.MainContext], but it will still have its final + * reference count, so methods can be called on it from within this + * function. + * + * The `GSourceFuncs` struct contains a table of + * functions used to handle event sources in a generic manner. + * + * For idle sources, the prepare and check functions always return %TRUE + * to indicate that the source is always ready to be processed. The prepare + * function also returns a timeout value of 0 to ensure that the poll() call + * doesn't block (since that would be time wasted which could have been spent + * running the idle function). + * + * For timeout sources, the prepare and check functions both return %TRUE + * if the timeout interval has expired. The prepare function also returns + * a timeout value to ensure that the poll() call doesn't block too long + * and miss the next timeout. + * + * For file descriptor sources, the prepare function typically returns %FALSE, + * since it must wait until poll() has been called before it knows whether + * any events need to be processed. It sets the returned timeout to -1 to + * indicate that it doesn't mind how long the poll() call blocks. In the + * check function, it tests the results of the poll() call to see if the + * required condition has been met, and returns %TRUE if so. + */ +typedef struct _GSourceFuncs GSourceFuncs; + +/** + * GPid: + * + * A type which is used to hold a process identification. + * + * On UNIX, processes are identified by a process id (an integer), + * while Windows uses process handles (which are pointers). + * + * GPid is used in GLib only for descendant processes spawned with + * the g_spawn functions. + */ +/* defined in glibconfig.h */ + +/** + * G_PID_FORMAT: + * + * A format specifier that can be used in printf()-style format strings + * when printing a #GPid. + * + * Since: 2.50 + */ +/* defined in glibconfig.h */ + +/** + * GSourceFunc: + * @user_data: data passed to the function, set when the source was + * created with one of the above functions + * + * Specifies the type of function passed to [func@GLib.timeout_add], + * [func@GLib.timeout_add_full], [func@GLib.idle_add], and + * [func@GLib.idle_add_full]. + * + * When calling [method@GLib.Source.set_callback], you may need to cast a + * function of a different type to this type. Use [func@GLib.SOURCE_FUNC] to + * avoid warnings about incompatible function types. + * + * Returns: %FALSE if the source should be removed. + * [const@GLib.SOURCE_CONTINUE] and [const@GLib.SOURCE_REMOVE] are more + * memorable names for the return value. + */ +typedef gboolean (*GSourceFunc) (gpointer user_data); + +/** + * GSourceOnceFunc: + * @user_data: data passed to the function, set when the source was + * created + * + * A source function that is only called once before being removed from the main + * context automatically. + * + * See: [func@GLib.idle_add_once], [func@GLib.timeout_add_once] + * + * Since: 2.74 + */ +typedef void (* GSourceOnceFunc) (gpointer user_data); + +/** + * G_SOURCE_FUNC: + * @f: a function pointer. + * + * Cast a function pointer to a [callback@GLib.SourceFunc], suppressing + * warnings from GCC 8 onwards with `-Wextra` or `-Wcast-function-type` enabled + * about the function types being incompatible. + * + * For example, the correct type of callback for a source created by + * [func@GLib.child_watch_source_new] is #GChildWatchFunc, which accepts more + * arguments than [callback@GLib.SourceFunc]. Casting the function with + * `(GSourceFunc)` to call [method@GLib.Source.set_callback] will trigger a + * warning, even though it will be cast back to the correct type before it is + * called by the source. + * + * Since: 2.58 + */ +#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f)) GLIB_AVAILABLE_MACRO_IN_2_58 + +/** + * GChildWatchFunc: + * @pid: the process id of the child process + * @wait_status: Status information about the child process, encoded + * in a platform-specific manner + * @user_data: user data passed to [func@GLib.child_watch_add] + * + * Prototype of a #GChildWatchSource callback, called when a child + * process has exited. + * + * To interpret @wait_status, see the documentation for + * [func@GLib.spawn_check_wait_status]. In particular, + * on Unix platforms, note that it is usually not equal + * to the integer passed to `exit()` or returned from `main()`. + */ +typedef void (*GChildWatchFunc) (GPid pid, + gint wait_status, + gpointer user_data); + + +/** + * GSourceDisposeFunc: + * @source: #GSource that is currently being disposed + * + * Dispose function for @source. See [method@GLib.Source.set_dispose_function] + * for details. + * + * Since: 2.64 + */ +GLIB_AVAILABLE_TYPE_IN_2_64 +typedef void (*GSourceDisposeFunc) (GSource *source); + +struct _GSource +{ + /*< private >*/ + gpointer callback_data; + GSourceCallbackFuncs *callback_funcs; + + const GSourceFuncs *source_funcs; + guint ref_count; + + GMainContext *context; + + gint priority; + guint flags; /* (atomic) */ + guint source_id; + + GSList *poll_fds; + + GSource *prev; + GSource *next; + + char *name; + + GSourcePrivate *priv; +}; + +struct _GSourceCallbackFuncs +{ + void (*ref) (gpointer cb_data); + void (*unref) (gpointer cb_data); + void (*get) (gpointer cb_data, + GSource *source, + GSourceFunc *func, + gpointer *data); +}; + +/** + * GSourceDummyMarshal: + * + * This is just a placeholder for #GClosureMarshal, + * which cannot be used here for dependency reasons. + */ +typedef void (*GSourceDummyMarshal) (void); + +/** + * GSourceFuncsPrepareFunc: + * @source: The #GSource + * @timeout_: (out) (optional): the maximum timeout (in milliseconds) which should be passed to the poll call + * + * Checks the source for readiness. + * + * Called before all the file descriptors are polled. If the + * source can determine that it is ready here (without waiting for the + * results of the poll call) it should return %TRUE. It can also return + * a @timeout_ value which should be the maximum timeout (in milliseconds) + * which should be passed to the poll call. The actual timeout used will + * be `-1` if all sources returned `-1`, or it will be the minimum of all + * the @timeout_ values returned which were greater than or equal to `0`. + * If the prepare function returns a timeout and the source also has a + * ready time set, then the lower of the two will be used. + * + * Since 2.36 this may be `NULL`, in which case the effect is as if the + * function always returns `FALSE` with a timeout of `-1`. + * + * Returns: %TRUE if the source is ready, %FALSE otherwise + * + * Since: 2.82 + */ +typedef gboolean (*GSourceFuncsPrepareFunc) (GSource *source, + gint *timeout_); + +/** + * GSourceFuncsCheckFunc: + * @source: The #GSource + * + * Checks if the source is ready to be dispatched. + * + * Called after all the file descriptors are polled. The source + * should return %TRUE if it is ready to be dispatched. Note that some + * time may have passed since the previous prepare function was called, + * so the source should be checked again here. + * + * Since 2.36 this may be `NULL`, in which case the effect is + * as if the function always returns `FALSE`. + * + * Returns: %TRUE if ready to be dispatched, %FALSE otherwise + * + * Since: 2.82 + */ +typedef gboolean (*GSourceFuncsCheckFunc) (GSource *source); + +/** + * GSourceFuncsDispatchFunc: + * @source: The #GSource + * @callback: (nullable): The #GSourceFunc to call + * @user_data: (nullable): data to pass to @callback + * + * Dispatches the source callback. + * + * Called to dispatch the event source, after it has returned + * `TRUE` in either its prepare or its check function, or if a ready time + * has been reached. The dispatch function receives a callback function and + * user data. The callback function may be `NULL` if the source was never + * connected to a callback using [method@GLib.Source.set_callback]. The dispatch + * function should call the callback function with @user_data and whatever + * additional parameters are needed for this type of event source. The + * return value of the dispatch function should be [const@GLib.SOURCE_REMOVE] + * if the source should be removed or [const@GLib.SOURCE_CONTINUE] to keep it. + * + * Returns: [const@GLib.SOURCE_REMOVE] if the source should be removed, + * [const@GLib.SOURCE_CONTINUE] otherwise. + * + * Since: 2.82 + */ +typedef gboolean (*GSourceFuncsDispatchFunc) (GSource *source, + GSourceFunc callback, + gpointer user_data); + +/** + * GSourceFuncsFinalizeFunc: + * @source: The #GSource + * + * Finalizes the source. + * + * Called when the source is finalized. At this point, the source + * will have been destroyed, had its callback cleared, and have been removed + * from its [type@GLib.MainContext], but it will still have its final reference + * count, so methods can be called on it from within this function. + * + * Since: 2.82 + */ +typedef void (*GSourceFuncsFinalizeFunc) (GSource *source); + +struct _GSourceFuncs +{ + GSourceFuncsPrepareFunc prepare; /* Can be NULL */ + GSourceFuncsCheckFunc check; /* Can be NULL */ + GSourceFuncsDispatchFunc dispatch; + GSourceFuncsFinalizeFunc finalize; /* Can be NULL */ + + /*< private >*/ + /* For use by g_source_set_closure */ + GSourceFunc closure_callback; + GSourceDummyMarshal closure_marshal; /* Really is of type GClosureMarshal */ +}; + +/* Standard priorities */ + +/** + * G_PRIORITY_HIGH: + * + * Use this for high priority event sources. + * + * It is not used within GLib or GTK. + */ +#define G_PRIORITY_HIGH -100 + +/** + * G_PRIORITY_DEFAULT: + * + * Use this for default priority event sources. + * + * In GLib this priority is used when adding timeout functions + * with [func@GLib.timeout_add]. In GDK this priority is used for events + * from the X server. + */ +#define G_PRIORITY_DEFAULT 0 + +/** + * G_PRIORITY_HIGH_IDLE: + * + * Use this for high priority idle functions. + * + * GTK uses %G_PRIORITY_HIGH_IDLE + 10 for resizing operations, + * and %G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is + * done to ensure that any pending resizes are processed before any + * pending redraws, so that widgets are not redrawn twice unnecessarily.) + */ +#define G_PRIORITY_HIGH_IDLE 100 + +/** + * G_PRIORITY_DEFAULT_IDLE: + * + * Use this for default priority idle functions. + * + * In GLib this priority is used when adding idle functions with + * [func@GLib.idle_add]. + */ +#define G_PRIORITY_DEFAULT_IDLE 200 + +/** + * G_PRIORITY_LOW: + * + * Use this for very low priority background tasks. + * + * It is not used within GLib or GTK. + */ +#define G_PRIORITY_LOW 300 + +/** + * G_SOURCE_REMOVE: + * + * Use this macro as the return value of a [callback@GLib.SourceFunc] to remove + * the [struct@GLib.Source] from the main loop. + * + * Since: 2.32 + */ +#define G_SOURCE_REMOVE FALSE + +/** + * G_SOURCE_CONTINUE: + * + * Use this macro as the return value of a [callback@GLib.SourceFunc] to leave + * the [struct@GLib.Source] in the main loop. + * + * Since: 2.32 + */ +#define G_SOURCE_CONTINUE TRUE + +/* GMainContext: */ + +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_new (void); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_2_72 +GMainContext *g_main_context_new_with_flags (GMainContextFlags flags); +G_GNUC_END_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_ref (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +void g_main_context_unref (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_default (void); + +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_iteration (GMainContext *context, + gboolean may_block); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_pending (GMainContext *context); + +/* For implementation of legacy interfaces + */ +GLIB_AVAILABLE_IN_ALL +GSource *g_main_context_find_source_by_id (GMainContext *context, + guint source_id); +GLIB_AVAILABLE_IN_ALL +GSource *g_main_context_find_source_by_user_data (GMainContext *context, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GSource *g_main_context_find_source_by_funcs_user_data (GMainContext *context, + GSourceFuncs *funcs, + gpointer user_data); + +/* Low level functions for implementing custom main loops. + */ +GLIB_AVAILABLE_IN_ALL +void g_main_context_wakeup (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_acquire (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +void g_main_context_release (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_is_owner (GMainContext *context); +GLIB_DEPRECATED_IN_2_58_FOR(g_main_context_is_owner) +gboolean g_main_context_wait (GMainContext *context, + GCond *cond, + GMutex *mutex); + +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_prepare (GMainContext *context, + gint *priority); +GLIB_AVAILABLE_IN_ALL +gint g_main_context_query (GMainContext *context, + gint max_priority, + gint *timeout_, + GPollFD *fds, + gint n_fds); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_check (GMainContext *context, + gint max_priority, + GPollFD *fds, + gint n_fds); +GLIB_AVAILABLE_IN_ALL +void g_main_context_dispatch (GMainContext *context); + +GLIB_AVAILABLE_IN_ALL +void g_main_context_set_poll_func (GMainContext *context, + GPollFunc func); +GLIB_AVAILABLE_IN_ALL +GPollFunc g_main_context_get_poll_func (GMainContext *context); + +/* Low level functions for use by source implementations + */ +GLIB_AVAILABLE_IN_ALL +void g_main_context_add_poll (GMainContext *context, + GPollFD *fd, + gint priority); +GLIB_AVAILABLE_IN_ALL +void g_main_context_remove_poll (GMainContext *context, + GPollFD *fd); + +GLIB_AVAILABLE_IN_ALL +gint g_main_depth (void); +GLIB_AVAILABLE_IN_ALL +GSource *g_main_current_source (void); + +/* GMainContexts for other threads + */ +GLIB_AVAILABLE_IN_ALL +void g_main_context_push_thread_default (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +void g_main_context_pop_thread_default (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_get_thread_default (void); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_ref_thread_default (void); + +/** + * GMainContextPusher: + * + * Opaque type. See g_main_context_pusher_new() for details. + * + * Since: 2.64 + */ +typedef void GMainContextPusher GLIB_AVAILABLE_TYPE_IN_2_64; + +/** + * g_main_context_pusher_new: + * @main_context: (transfer none): a main context to push + * + * Push @main_context as the new thread-default main context for the current + * thread, using [method@GLib.MainContext.push_thread_default], and return a + * new [alias@GLib.MainContextPusher]. Pop with g_main_context_pusher_free(). + * Using [method@GLib.MainContext.pop_thread_default] on @main_context while a + * [alias@GLib.MainContextPusher] exists for it can lead to undefined behaviour. + * + * Using two [alias@GLib.MainContextPusher]s in the same scope is not allowed, + * as it leads to an undefined pop order. + * + * This is intended to be used with g_autoptr(). Note that g_autoptr() + * is only available when using GCC or clang, so the following example + * will only work with those compilers: + * |[ + * typedef struct + * { + * ... + * GMainContext *context; + * ... + * } MyObject; + * + * static void + * my_object_do_stuff (MyObject *self) + * { + * g_autoptr(GMainContextPusher) pusher = g_main_context_pusher_new (self->context); + * + * // Code with main context as the thread default here + * + * if (cond) + * // No need to pop + * return; + * + * // Optionally early pop + * g_clear_pointer (&pusher, g_main_context_pusher_free); + * + * // Code with main context no longer the thread default here + * } + * ]| + * + * Returns: (transfer full): a #GMainContextPusher + * Since: 2.64 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 +static inline GMainContextPusher *g_main_context_pusher_new (GMainContext *main_context); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 +static inline GMainContextPusher * +g_main_context_pusher_new (GMainContext *main_context) +{ + g_main_context_push_thread_default (main_context); + return (GMainContextPusher *) main_context; +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * g_main_context_pusher_free: + * @pusher: (transfer full): a #GMainContextPusher + * + * Pop @pusher’s main context as the thread default main context. + * See g_main_context_pusher_new() for details. + * + * This will pop the [struct@GLib.MainContext] as the current thread-default + * main context, but will not call [method@GLib.MainContext.unref] on it. + * + * Since: 2.64 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 +static inline void g_main_context_pusher_free (GMainContextPusher *pusher); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 +static inline void +g_main_context_pusher_free (GMainContextPusher *pusher) +{ + g_main_context_pop_thread_default ((GMainContext *) pusher); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/* GMainLoop: */ + +GLIB_AVAILABLE_IN_ALL +GMainLoop *g_main_loop_new (GMainContext *context, + gboolean is_running); +GLIB_AVAILABLE_IN_ALL +void g_main_loop_run (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +void g_main_loop_quit (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +GMainLoop *g_main_loop_ref (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +void g_main_loop_unref (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_loop_is_running (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_loop_get_context (GMainLoop *loop); + +/* GSource: */ + +GLIB_AVAILABLE_IN_ALL +GSource *g_source_new (GSourceFuncs *source_funcs, + guint struct_size); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_2_64 +void g_source_set_dispose_function (GSource *source, + GSourceDisposeFunc dispose); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +GSource *g_source_ref (GSource *source); +GLIB_AVAILABLE_IN_ALL +void g_source_unref (GSource *source); + +GLIB_AVAILABLE_IN_ALL +guint g_source_attach (GSource *source, + GMainContext *context); +GLIB_AVAILABLE_IN_ALL +void g_source_destroy (GSource *source); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_priority (GSource *source, + gint priority); +GLIB_AVAILABLE_IN_ALL +gint g_source_get_priority (GSource *source); +GLIB_AVAILABLE_IN_ALL +void g_source_set_can_recurse (GSource *source, + gboolean can_recurse); +GLIB_AVAILABLE_IN_ALL +gboolean g_source_get_can_recurse (GSource *source); +GLIB_AVAILABLE_IN_ALL +guint g_source_get_id (GSource *source); + +GLIB_AVAILABLE_IN_ALL +GMainContext *g_source_get_context (GSource *source); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_callback (GSource *source, + GSourceFunc func, + gpointer data, + GDestroyNotify notify); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_funcs (GSource *source, + GSourceFuncs *funcs); +GLIB_AVAILABLE_IN_ALL +gboolean g_source_is_destroyed (GSource *source); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_name (GSource *source, + const char *name); +GLIB_AVAILABLE_IN_2_70 +void g_source_set_static_name (GSource *source, + const char *name); +GLIB_AVAILABLE_IN_ALL +const char * g_source_get_name (GSource *source); +GLIB_AVAILABLE_IN_ALL +void g_source_set_name_by_id (guint tag, + const char *name); + +GLIB_AVAILABLE_IN_2_36 +void g_source_set_ready_time (GSource *source, + gint64 ready_time); +GLIB_AVAILABLE_IN_2_36 +gint64 g_source_get_ready_time (GSource *source); + +#ifdef G_OS_UNIX +GLIB_AVAILABLE_IN_2_36 +gpointer g_source_add_unix_fd (GSource *source, + gint fd, + GIOCondition events); +GLIB_AVAILABLE_IN_2_36 +void g_source_modify_unix_fd (GSource *source, + gpointer tag, + GIOCondition new_events); +GLIB_AVAILABLE_IN_2_36 +void g_source_remove_unix_fd (GSource *source, + gpointer tag); +GLIB_AVAILABLE_IN_2_36 +GIOCondition g_source_query_unix_fd (GSource *source, + gpointer tag); +#endif + +/* Used to implement g_source_connect_closure and internally*/ +GLIB_AVAILABLE_IN_ALL +void g_source_set_callback_indirect (GSource *source, + gpointer callback_data, + GSourceCallbackFuncs *callback_funcs); + +GLIB_AVAILABLE_IN_ALL +void g_source_add_poll (GSource *source, + GPollFD *fd); +GLIB_AVAILABLE_IN_ALL +void g_source_remove_poll (GSource *source, + GPollFD *fd); + +GLIB_AVAILABLE_IN_ALL +void g_source_add_child_source (GSource *source, + GSource *child_source); +GLIB_AVAILABLE_IN_ALL +void g_source_remove_child_source (GSource *source, + GSource *child_source); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_28_FOR(g_source_get_time) +void g_source_get_current_time (GSource *source, + GTimeVal *timeval); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +gint64 g_source_get_time (GSource *source); + + /* void g_source_connect_closure (GSource *source, + GClosure *closure); + */ + +/* Specific source types + */ +GLIB_AVAILABLE_IN_ALL +GSource *g_idle_source_new (void); +GLIB_AVAILABLE_IN_ALL +GSource *g_child_watch_source_new (GPid pid); +GLIB_AVAILABLE_IN_ALL +GSource *g_timeout_source_new (guint interval); +GLIB_AVAILABLE_IN_ALL +GSource *g_timeout_source_new_seconds (guint interval); + +/* Miscellaneous functions + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62_FOR(g_get_real_time) +void g_get_current_time (GTimeVal *result); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +gint64 g_get_monotonic_time (void); +GLIB_AVAILABLE_IN_ALL +gint64 g_get_real_time (void); + + +/* Source manipulation by ID */ +GLIB_AVAILABLE_IN_ALL +gboolean g_source_remove (guint tag); +GLIB_AVAILABLE_IN_ALL +gboolean g_source_remove_by_user_data (gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gboolean g_source_remove_by_funcs_user_data (GSourceFuncs *funcs, + gpointer user_data); + +/** + * GClearHandleFunc: + * @handle_id: the handle ID to clear + * + * Specifies the type of function passed to [func@GLib.clear_handle_id] The + * implementation is expected to free the resource identified by @handle_id; + * for instance, if @handle_id is a [struct@GLib.Source] ID, + * [func@GLib.Source.remove] can be used. + * + * Since: 2.56 + */ +typedef void (* GClearHandleFunc) (guint handle_id); + +GLIB_AVAILABLE_IN_2_56 +void g_clear_handle_id (guint *tag_ptr, + GClearHandleFunc clear_func); + +#define g_clear_handle_id(tag_ptr, clear_func) \ + G_STMT_START { \ + G_STATIC_ASSERT (sizeof *(tag_ptr) == sizeof (guint)); \ + guint *_tag_ptr = (guint *) (tag_ptr); \ + guint _handle_id; \ + \ + _handle_id = *_tag_ptr; \ + if (_handle_id > 0) \ + { \ + *_tag_ptr = 0; \ + clear_func (_handle_id); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_56 + +/** + * g_steal_handle_id: + * @handle_pointer: (inout) (not optional): a pointer to a handle ID + * + * Sets @handle_pointer to `0`, returning the value that was there before. + * + * Conceptually, this transfers the ownership of the handle ID from the + * referenced variable to the ‘caller’ of the macro (ie: ‘steals’ the + * handle ID). + * + * This can be very useful to make ownership transfer explicit, or to prevent + * a handle from being released multiple times. For example: + * + * ```c + * void + * maybe_unsubscribe_signal (ContextStruct *data) + * { + * if (some_complex_logic (data)) + * { + * g_dbus_connection_signal_unsubscribe (data->connection, + * g_steal_handle_id (&data->subscription_id)); + * // now data->subscription_id isn’t a dangling handle + * } + * } + * ``` + * + * While [func@GLib.clear_handle_id] can be used in many of the same situations + * as `g_steal_handle_id()`, this is one situation where it cannot be used, as + * there is no way to pass the `GDBusConnection` to a + * [type@GLib.ClearHandleFunc]. + * + * Since: 2.84 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_84 +static inline unsigned int g_steal_handle_id (unsigned int *handle_pointer); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_84 +static inline unsigned int +g_steal_handle_id (unsigned int *handle_pointer) +{ + unsigned int handle; + + handle = *handle_pointer; + *handle_pointer = 0; + + return handle; +} + +/* Idles, child watchers and timeouts */ +GLIB_AVAILABLE_IN_ALL +guint g_timeout_add_full (gint priority, + guint interval, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +guint g_timeout_add (guint interval, + GSourceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_2_74 +guint g_timeout_add_once (guint interval, + GSourceOnceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_timeout_add_seconds_full (gint priority, + guint interval, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +guint g_timeout_add_seconds (guint interval, + GSourceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_2_78 +guint g_timeout_add_seconds_once (guint interval, + GSourceOnceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_child_watch_add_full (gint priority, + GPid pid, + GChildWatchFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +guint g_child_watch_add (GPid pid, + GChildWatchFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_idle_add (GSourceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_idle_add_full (gint priority, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_2_74 +guint g_idle_add_once (GSourceOnceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +gboolean g_idle_remove_by_data (gpointer data); + +GLIB_AVAILABLE_IN_ALL +void g_main_context_invoke_full (GMainContext *context, + gint priority, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +void g_main_context_invoke (GMainContext *context, + GSourceFunc function, + gpointer data); + +/** + * g_steal_fd: + * @fd_ptr: (not optional) (inout): A pointer to a file descriptor + * + * Sets @fd_ptr to `-1`, returning the value that was there before. + * + * Conceptually, this transfers the ownership of the file descriptor + * from the referenced variable to the caller of the function (i.e. + * ‘steals’ the reference). This is very similar to [func@GLib.steal_pointer], + * but for file descriptors. + * + * On POSIX platforms, this function is async-signal safe + * (see [`signal(7)`](man:signal(7)) and + * [`signal-safety(7)`](man:signal-safety(7))), making it safe to call from a + * signal handler or a #GSpawnChildSetupFunc. + * + * This function preserves the value of `errno`. + * + * Returns: the value that @fd_ptr previously had + * Since: 2.70 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_70 +static inline int g_steal_fd (int *fd_ptr); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_70 +static inline int +g_steal_fd (int *fd_ptr) +{ + int fd = *fd_ptr; + *fd_ptr = -1; + return fd; +} + +/* Hook for GClosure / GSource integration. Don't touch */ +GLIB_VAR GSourceFuncs g_timeout_funcs; +GLIB_VAR GSourceFuncs g_child_watch_funcs; +GLIB_VAR GSourceFuncs g_idle_funcs; +#ifdef G_OS_UNIX +GLIB_VAR GSourceFuncs g_unix_signal_funcs; +GLIB_VAR GSourceFuncs g_unix_fd_source_funcs; +#endif + +G_END_DECLS + +#endif /* __G_MAIN_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gmappedfile.h b/illumos-x86_64/usr/include/glib-2.0/glib/gmappedfile.h new file mode 100644 index 00000000..4f5f6981 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gmappedfile.h @@ -0,0 +1,60 @@ +/* GLIB - Library of useful routines for C programming + * gmappedfile.h: Simplified wrapper around the mmap function + * + * Copyright 2005 Matthias Clasen + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_MAPPED_FILE_H__ +#define __G_MAPPED_FILE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GMappedFile GMappedFile; + +GLIB_AVAILABLE_IN_ALL +GMappedFile *g_mapped_file_new (const gchar *filename, + gboolean writable, + GError **error); +GLIB_AVAILABLE_IN_ALL +GMappedFile *g_mapped_file_new_from_fd (gint fd, + gboolean writable, + GError **error); +GLIB_AVAILABLE_IN_ALL +gsize g_mapped_file_get_length (GMappedFile *file); +GLIB_AVAILABLE_IN_ALL +gchar *g_mapped_file_get_contents (GMappedFile *file); +GLIB_AVAILABLE_IN_2_34 +GBytes * g_mapped_file_get_bytes (GMappedFile *file); +GLIB_AVAILABLE_IN_ALL +GMappedFile *g_mapped_file_ref (GMappedFile *file); +GLIB_AVAILABLE_IN_ALL +void g_mapped_file_unref (GMappedFile *file); + +GLIB_DEPRECATED_FOR(g_mapped_file_unref) +void g_mapped_file_free (GMappedFile *file); + +G_END_DECLS + +#endif /* __G_MAPPED_FILE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gmarkup.h b/illumos-x86_64/usr/include/glib-2.0/glib/gmarkup.h new file mode 100644 index 00000000..5b578135 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gmarkup.h @@ -0,0 +1,265 @@ +/* gmarkup.h - Simple XML-like string parser/writer + * + * Copyright 2000 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_MARKUP_H__ +#define __G_MARKUP_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#include +#include + +G_BEGIN_DECLS + +/** + * GMarkupError: + * @G_MARKUP_ERROR_BAD_UTF8: text being parsed was not valid UTF-8 + * @G_MARKUP_ERROR_EMPTY: document contained nothing, or only whitespace + * @G_MARKUP_ERROR_PARSE: document was ill-formed + * @G_MARKUP_ERROR_UNKNOWN_ELEMENT: error should be set by #GMarkupParser + * functions; element wasn't known + * @G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE: error should be set by #GMarkupParser + * functions; attribute wasn't known + * @G_MARKUP_ERROR_INVALID_CONTENT: error should be set by #GMarkupParser + * functions; content was invalid + * @G_MARKUP_ERROR_MISSING_ATTRIBUTE: error should be set by #GMarkupParser + * functions; a required attribute was missing + * + * Error codes returned by markup parsing. + */ +typedef enum +{ + G_MARKUP_ERROR_BAD_UTF8, + G_MARKUP_ERROR_EMPTY, + G_MARKUP_ERROR_PARSE, + /* The following are primarily intended for specific GMarkupParser + * implementations to set. + */ + G_MARKUP_ERROR_UNKNOWN_ELEMENT, + G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, + G_MARKUP_ERROR_INVALID_CONTENT, + G_MARKUP_ERROR_MISSING_ATTRIBUTE +} GMarkupError; + +/** + * G_MARKUP_ERROR: + * + * Error domain for markup parsing. + * Errors in this domain will be from the #GMarkupError enumeration. + * See #GError for information on error domains. + */ +#define G_MARKUP_ERROR g_markup_error_quark () + +GLIB_AVAILABLE_IN_ALL +GQuark g_markup_error_quark (void); + +/** + * GMarkupParseFlags: + * @G_MARKUP_DEFAULT_FLAGS: No special behaviour. Since: 2.74 + * @G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG: flag you should not use + * @G_MARKUP_TREAT_CDATA_AS_TEXT: When this flag is set, CDATA marked + * sections are not passed literally to the @passthrough function of + * the parser. Instead, the content of the section (without the + * ``) is + * passed to the @text function. This flag was added in GLib 2.12 + * @G_MARKUP_PREFIX_ERROR_POSITION: Normally errors caught by GMarkup + * itself have line/column information prefixed to them to let the + * caller know the location of the error. When this flag is set the + * location information is also prefixed to errors generated by the + * #GMarkupParser implementation functions + * @G_MARKUP_IGNORE_QUALIFIED: Ignore (don't report) qualified + * attributes and tags, along with their contents. A qualified + * attribute or tag is one that contains ':' in its name (ie: is in + * another namespace). Since: 2.40. + * + * Flags that affect the behaviour of the parser. + */ +typedef enum +{ + G_MARKUP_DEFAULT_FLAGS GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0, + G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1, + G_MARKUP_PREFIX_ERROR_POSITION = 1 << 2, + G_MARKUP_IGNORE_QUALIFIED = 1 << 3 +} GMarkupParseFlags; + +/** + * GMarkupParseContext: + * + * A parse context is used to parse a stream of bytes that + * you expect to contain marked-up text. + * + * See g_markup_parse_context_new(), #GMarkupParser, and so + * on for more details. + */ +typedef struct _GMarkupParseContext GMarkupParseContext; +typedef struct _GMarkupParser GMarkupParser; + +/** + * GMarkupParser: + * @start_element: Callback to invoke when the opening tag of an element + * is seen. The callback's @attribute_names and @attribute_values parameters + * are %NULL-terminated. + * @end_element: Callback to invoke when the closing tag of an element + * is seen. Note that this is also called for empty tags like + * ``. + * @text: Callback to invoke when some text is seen (text is always + * inside an element). Note that the text of an element may be spread + * over multiple calls of this function. If the + * %G_MARKUP_TREAT_CDATA_AS_TEXT flag is set, this function is also + * called for the content of CDATA marked sections. + * @passthrough: Callback to invoke for comments, processing instructions + * and doctype declarations; if you're re-writing the parsed document, + * write the passthrough text back out in the same position. If the + * %G_MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also + * called for CDATA marked sections. + * @error: Callback to invoke when an error occurs. + * + * Any of the fields in #GMarkupParser can be %NULL, in which case they + * will be ignored. Except for the @error function, any of these callbacks + * can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT, + * %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %G_MARKUP_ERROR_INVALID_CONTENT + * errors are intended to be set from these callbacks. If you set an error + * from a callback, g_markup_parse_context_parse() will report that error + * back to its caller. + */ +struct _GMarkupParser +{ + /* Called for open tags */ + void (*start_element) (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error); + + /* Called for close tags */ + void (*end_element) (GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, + GError **error); + + /* Called for character data */ + /* text is not nul-terminated */ + void (*text) (GMarkupParseContext *context, + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error); + + /* Called for strings that should be re-saved verbatim in this same + * position, but are not otherwise interpretable. At the moment + * this includes comments and processing instructions. + */ + /* text is not nul-terminated. */ + void (*passthrough) (GMarkupParseContext *context, + const gchar *passthrough_text, + gsize text_len, + gpointer user_data, + GError **error); + + /* Called on error, including one set by other + * methods in the vtable. The GError should not be freed. + */ + void (*error) (GMarkupParseContext *context, + GError *error, + gpointer user_data); +}; + +GLIB_AVAILABLE_IN_ALL +GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser, + GMarkupParseFlags flags, + gpointer user_data, + GDestroyNotify user_data_dnotify); +GLIB_AVAILABLE_IN_2_36 +GMarkupParseContext *g_markup_parse_context_ref (GMarkupParseContext *context); +GLIB_AVAILABLE_IN_2_36 +void g_markup_parse_context_unref (GMarkupParseContext *context); +GLIB_AVAILABLE_IN_ALL +void g_markup_parse_context_free (GMarkupParseContext *context); +GLIB_AVAILABLE_IN_ALL +gboolean g_markup_parse_context_parse (GMarkupParseContext *context, + const gchar *text, + gssize text_len, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_markup_parse_context_push (GMarkupParseContext *context, + const GMarkupParser *parser, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_markup_parse_context_pop (GMarkupParseContext *context); + +GLIB_AVAILABLE_IN_ALL +gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context, + GError **error); +GLIB_AVAILABLE_IN_ALL +const gchar * g_markup_parse_context_get_element (GMarkupParseContext *context); +GLIB_AVAILABLE_IN_ALL +const GSList * g_markup_parse_context_get_element_stack (GMarkupParseContext *context); + +/* For user-constructed error messages, has no precise semantics */ +GLIB_AVAILABLE_IN_ALL +void g_markup_parse_context_get_position (GMarkupParseContext *context, + gint *line_number, + gint *char_number); +GLIB_AVAILABLE_IN_ALL +gpointer g_markup_parse_context_get_user_data (GMarkupParseContext *context); + +/* useful when saving */ +GLIB_AVAILABLE_IN_ALL +gchar* g_markup_escape_text (const gchar *text, + gssize length); + +GLIB_AVAILABLE_IN_ALL +gchar *g_markup_printf_escaped (const char *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +gchar *g_markup_vprintf_escaped (const char *format, + va_list args) G_GNUC_PRINTF(1, 0); + +typedef enum +{ + G_MARKUP_COLLECT_INVALID, + G_MARKUP_COLLECT_STRING, + G_MARKUP_COLLECT_STRDUP, + G_MARKUP_COLLECT_BOOLEAN, + G_MARKUP_COLLECT_TRISTATE, + + G_MARKUP_COLLECT_OPTIONAL = (1 << 16) +} GMarkupCollectType; + + +/* useful from start_element */ +GLIB_AVAILABLE_IN_ALL +gboolean g_markup_collect_attributes (const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + GError **error, + GMarkupCollectType first_type, + const gchar *first_attr, + ...); + +G_END_DECLS + +#endif /* __G_MARKUP_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gmem.h b/illumos-x86_64/usr/include/glib-2.0/glib/gmem.h new file mode 100644 index 00000000..cfdf44bb --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gmem.h @@ -0,0 +1,428 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_MEM_H__ +#define __G_MEM_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/** + * GMemVTable: + * @malloc: function to use for allocating memory. + * @realloc: function to use for reallocating memory. + * @free: function to use to free memory. + * @calloc: function to use for allocating zero-filled memory. + * @try_malloc: function to use for allocating memory without a default error handler. + * @try_realloc: function to use for reallocating memory without a default error handler. + * + * A set of functions used to perform memory allocation. The same #GMemVTable must + * be used for all allocations in the same program; a call to g_mem_set_vtable(), + * if it exists, should be prior to any use of GLib. + * + * This functions related to this has been deprecated in 2.46, and no longer work. + */ +typedef struct _GMemVTable GMemVTable; + + +#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG +/** + * G_MEM_ALIGN: + * + * Indicates the number of bytes to which memory will be aligned on the + * current platform. + */ +# define G_MEM_ALIGN GLIB_SIZEOF_VOID_P +#else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */ +# define G_MEM_ALIGN GLIB_SIZEOF_LONG +#endif /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */ + + +/* Memory allocation functions + */ + +GLIB_AVAILABLE_IN_ALL +void (g_free) (gpointer mem); +GLIB_AVAILABLE_IN_2_76 +void g_free_sized (gpointer mem, + size_t size); + +GLIB_AVAILABLE_IN_2_34 +void g_clear_pointer (gpointer *pp, + GDestroyNotify destroy); + +GLIB_AVAILABLE_IN_ALL +gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_malloc0 (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_realloc (gpointer mem, + gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gpointer g_try_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_try_malloc0 (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_try_realloc (gpointer mem, + gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_ALL +gpointer g_malloc_n (gsize n_blocks, + gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_ALL +gpointer g_malloc0_n (gsize n_blocks, + gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_ALL +gpointer g_realloc_n (gpointer mem, + gsize n_blocks, + gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gpointer g_try_malloc_n (gsize n_blocks, + gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_ALL +gpointer g_try_malloc0_n (gsize n_blocks, + gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_ALL +gpointer g_try_realloc_n (gpointer mem, + gsize n_blocks, + gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_2_72 +gpointer g_aligned_alloc (gsize n_blocks, + gsize n_block_bytes, + gsize alignment) G_GNUC_WARN_UNUSED_RESULT G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_2_72 +gpointer g_aligned_alloc0 (gsize n_blocks, + gsize n_block_bytes, + gsize alignment) G_GNUC_WARN_UNUSED_RESULT G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_2_72 +void g_aligned_free (gpointer mem); +GLIB_AVAILABLE_IN_2_76 +void g_aligned_free_sized (gpointer mem, + size_t alignment, + size_t size); + +#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 +#define g_clear_pointer(pp, destroy) \ + G_STMT_START \ + { \ + G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ + glib_typeof ((pp)) _pp = (pp); \ + glib_typeof (*(pp)) _ptr = *_pp; \ + *_pp = NULL; \ + if (_ptr) \ + (destroy) (_ptr); \ + } \ + G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_34 +#else /* __GNUC__ */ +#define g_clear_pointer(pp, destroy) \ + G_STMT_START { \ + G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ + /* Only one access, please; work around type aliasing */ \ + union { char *in; gpointer *out; } _pp; \ + gpointer _p; \ + /* This assignment is needed to avoid a gcc warning */ \ + GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ + \ + _pp.in = (char *) (pp); \ + _p = *_pp.out; \ + if (_p) \ + { \ + *_pp.out = NULL; \ + _destroy (_p); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_34 +#endif /* __GNUC__ */ + + +#if G_GNUC_CHECK_VERSION (4, 1) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED) + +#define g_free(mem) \ + (__builtin_object_size ((mem), 0) != ((size_t) - 1)) ? \ + g_free_sized (mem, __builtin_object_size ((mem), 0)) : (g_free) (mem) + +#endif /* G_GNUC_CHECK_VERSION (4, 1) && && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED) */ + +/** + * g_steal_pointer: + * @pp: (not nullable): a pointer to a pointer + * + * Sets @pp to %NULL, returning the value that was there before. + * + * Conceptually, this transfers the ownership of the pointer from the + * referenced variable to the "caller" of the macro (ie: "steals" the + * reference). + * + * The return value will be properly typed, according to the type of + * @pp. + * + * This can be very useful when combined with g_autoptr() to prevent the + * return value of a function from being automatically freed. Consider + * the following example (which only works on GCC and clang): + * + * |[ + * GObject * + * create_object (void) + * { + * g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL); + * + * if (early_error_case) + * return NULL; + * + * return g_steal_pointer (&obj); + * } + * ]| + * + * It can also be used in similar ways for 'out' parameters and is + * particularly useful for dealing with optional out parameters: + * + * |[ + * gboolean + * get_object (GObject **obj_out) + * { + * g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL); + * + * if (early_error_case) + * return FALSE; + * + * if (obj_out) + * *obj_out = g_steal_pointer (&obj); + * + * return TRUE; + * } + * ]| + * + * In the above example, the object will be automatically freed in the + * early error case and also in the case that %NULL was given for + * @obj_out. + * + * Since: 2.44 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +static inline gpointer g_steal_pointer (gpointer pp); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +static inline gpointer +g_steal_pointer (gpointer pp) +{ + gpointer *ptr = (gpointer *) pp; + gpointer ref; + + ref = *ptr; + *ptr = NULL; + + return ref; +} + +/* type safety */ +#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 +#define g_steal_pointer(pp) ((glib_typeof (*pp)) (g_steal_pointer) (pp)) +#else /* __GNUC__ */ +/* This version does not depend on gcc extensions, but gcc does not warn + * about incompatible-pointer-types: */ +#define g_steal_pointer(pp) \ + (0 ? (*(pp)) : (g_steal_pointer) (pp)) +#endif /* __GNUC__ */ + +/* Optimise: avoid the call to the (slower) _n function if we can + * determine at compile-time that no overflow happens. + */ +#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) +# define _G_NEW(struct_type, n_structs, func) \ + (struct_type *) (G_GNUC_EXTENSION ({ \ + gsize __n = (gsize) (n_structs); \ + gsize __s = sizeof (struct_type); \ + gpointer __p; \ + if (__s == 1) \ + __p = g_##func (__n); \ + else if (__builtin_constant_p (__n) && \ + (__s == 0 || __n <= G_MAXSIZE / __s)) \ + __p = g_##func (__n * __s); \ + else \ + __p = g_##func##_n (__n, __s); \ + __p; \ + })) +# define _G_RENEW(struct_type, mem, n_structs, func) \ + (struct_type *) (G_GNUC_EXTENSION ({ \ + gsize __n = (gsize) (n_structs); \ + gsize __s = sizeof (struct_type); \ + gpointer __p = (gpointer) (mem); \ + if (__s == 1) \ + __p = g_##func (__p, __n); \ + else if (__builtin_constant_p (__n) && \ + (__s == 0 || __n <= G_MAXSIZE / __s)) \ + __p = g_##func (__p, __n * __s); \ + else \ + __p = g_##func##_n (__p, __n, __s); \ + __p; \ + })) + +#else + +/* Unoptimised version: always call the _n() function. */ + +#define _G_NEW(struct_type, n_structs, func) \ + ((struct_type *) g_##func##_n ((n_structs), sizeof (struct_type))) +#define _G_RENEW(struct_type, mem, n_structs, func) \ + ((struct_type *) g_##func##_n (mem, (n_structs), sizeof (struct_type))) + +#endif + +/** + * g_new: + * @struct_type: the type of the elements to allocate + * @n_structs: the number of elements to allocate + * + * Allocates @n_structs elements of type @struct_type. + * The returned pointer is cast to a pointer to the given type. + * If @n_structs is 0 it returns %NULL. + * Care is taken to avoid overflow when calculating the size of the allocated block. + * + * Since the returned pointer is already casted to the right type, + * it is normally unnecessary to cast it explicitly, and doing + * so might hide memory allocation errors. + * + * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type + */ +#define g_new(struct_type, n_structs) _G_NEW (struct_type, n_structs, malloc) +/** + * g_new0: + * @struct_type: the type of the elements to allocate. + * @n_structs: the number of elements to allocate. + * + * Allocates @n_structs elements of type @struct_type, initialized to 0's. + * The returned pointer is cast to a pointer to the given type. + * If @n_structs is 0 it returns %NULL. + * Care is taken to avoid overflow when calculating the size of the allocated block. + * + * Since the returned pointer is already casted to the right type, + * it is normally unnecessary to cast it explicitly, and doing + * so might hide memory allocation errors. + * + * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type. + */ +#define g_new0(struct_type, n_structs) _G_NEW (struct_type, n_structs, malloc0) +/** + * g_renew: + * @struct_type: the type of the elements to allocate + * @mem: the currently allocated memory + * @n_structs: the number of elements to allocate + * + * Reallocates the memory pointed to by @mem, so that it now has space for + * @n_structs elements of type @struct_type. It returns the new address of + * the memory, which may have been moved. + * Care is taken to avoid overflow when calculating the size of the allocated block. + * + * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type + */ +#define g_renew(struct_type, mem, n_structs) _G_RENEW (struct_type, mem, n_structs, realloc) +/** + * g_try_new: + * @struct_type: the type of the elements to allocate + * @n_structs: the number of elements to allocate + * + * Attempts to allocate @n_structs elements of type @struct_type, and returns + * %NULL on failure. Contrast with g_new(), which aborts the program on failure. + * The returned pointer is cast to a pointer to the given type. + * The function returns %NULL when @n_structs is 0 of if an overflow occurs. + * + * Since: 2.8 + * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type + */ +#define g_try_new(struct_type, n_structs) _G_NEW (struct_type, n_structs, try_malloc) +/** + * g_try_new0: + * @struct_type: the type of the elements to allocate + * @n_structs: the number of elements to allocate + * + * Attempts to allocate @n_structs elements of type @struct_type, initialized + * to 0's, and returns %NULL on failure. Contrast with g_new0(), which aborts + * the program on failure. + * The returned pointer is cast to a pointer to the given type. + * The function returns %NULL when @n_structs is 0 or if an overflow occurs. + * + * Since: 2.8 + * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type + */ +#define g_try_new0(struct_type, n_structs) _G_NEW (struct_type, n_structs, try_malloc0) +/** + * g_try_renew: + * @struct_type: the type of the elements to allocate + * @mem: the currently allocated memory + * @n_structs: the number of elements to allocate + * + * Attempts to reallocate the memory pointed to by @mem, so that it now has + * space for @n_structs elements of type @struct_type, and returns %NULL on + * failure. Contrast with g_renew(), which aborts the program on failure. + * It returns the new address of the memory, which may have been moved. + * The function returns %NULL if an overflow occurs. + * + * Since: 2.8 + * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type + */ +#define g_try_renew(struct_type, mem, n_structs) _G_RENEW (struct_type, mem, n_structs, try_realloc) + + +/* Memory allocation virtualization for debugging purposes + * g_mem_set_vtable() has to be the very first GLib function called + * if being used + */ +struct _GMemVTable { + gpointer (*malloc) (gsize n_bytes); + gpointer (*realloc) (gpointer mem, + gsize n_bytes); + void (*free) (gpointer mem); + /* optional; set to NULL if not used ! */ + gpointer (*calloc) (gsize n_blocks, + gsize n_block_bytes); + gpointer (*try_malloc) (gsize n_bytes); + gpointer (*try_realloc) (gpointer mem, + gsize n_bytes); +}; +GLIB_DEPRECATED_IN_2_46 +void g_mem_set_vtable (GMemVTable *vtable); +GLIB_DEPRECATED_IN_2_46 +gboolean g_mem_is_system_malloc (void); + +GLIB_VAR gboolean g_mem_gc_friendly; + +/* Memory profiler and checker, has to be enabled via g_mem_set_vtable() + */ +GLIB_VAR GMemVTable *glib_mem_profiler_table; +GLIB_DEPRECATED_IN_2_46 +void g_mem_profile (void); + +G_END_DECLS + +#endif /* __G_MEM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gmessages.h b/illumos-x86_64/usr/include/glib-2.0/glib/gmessages.h new file mode 100644 index 00000000..4867cdcb --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gmessages.h @@ -0,0 +1,701 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_MESSAGES_H__ +#define __G_MESSAGES_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include +#include +#include + +G_BEGIN_DECLS + +/* calculate a string size, guaranteed to fit format + args. + */ +GLIB_AVAILABLE_IN_ALL +gsize g_printf_string_upper_bound (const gchar* format, + va_list args) G_GNUC_PRINTF(1, 0); + +/* Log level shift offset for user defined + * log levels (0-7 are used by GLib). + */ +#define G_LOG_LEVEL_USER_SHIFT (8) + +/* Glib log levels and flags. + */ +typedef enum +{ + /* log flags */ + G_LOG_FLAG_RECURSION = 1 << 0, + G_LOG_FLAG_FATAL = 1 << 1, + + /* GLib log levels */ + G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */ + G_LOG_LEVEL_CRITICAL = 1 << 3, + G_LOG_LEVEL_WARNING = 1 << 4, + G_LOG_LEVEL_MESSAGE = 1 << 5, + G_LOG_LEVEL_INFO = 1 << 6, + G_LOG_LEVEL_DEBUG = 1 << 7, + + G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL) +} GLogLevelFlags; + +/* GLib log levels that are considered fatal by default */ +#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR) + +typedef void (*GLogFunc) (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data); + +/* Logging mechanism + */ +GLIB_AVAILABLE_IN_ALL +guint g_log_set_handler (const gchar *log_domain, + GLogLevelFlags log_levels, + GLogFunc log_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_46 +guint g_log_set_handler_full (const gchar *log_domain, + GLogLevelFlags log_levels, + GLogFunc log_func, + gpointer user_data, + GDestroyNotify destroy); +GLIB_AVAILABLE_IN_ALL +void g_log_remove_handler (const gchar *log_domain, + guint handler_id); +GLIB_AVAILABLE_IN_ALL +void g_log_default_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer unused_data); +GLIB_AVAILABLE_IN_ALL +GLogFunc g_log_set_default_handler (GLogFunc log_func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_log (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *format, + ...) G_GNUC_PRINTF (3, 4); +GLIB_AVAILABLE_IN_ALL +void g_logv (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *format, + va_list args) G_GNUC_PRINTF(3, 0); +GLIB_AVAILABLE_IN_ALL +GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, + GLogLevelFlags fatal_mask); +GLIB_AVAILABLE_IN_ALL +GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask); + +/* Structured logging mechanism. */ + +/** + * GLogWriterOutput: + * @G_LOG_WRITER_HANDLED: Log writer has handled the log entry. + * @G_LOG_WRITER_UNHANDLED: Log writer could not handle the log entry. + * + * Return values from #GLogWriterFuncs to indicate whether the given log entry + * was successfully handled by the writer, or whether there was an error in + * handling it (and hence a fallback writer should be used). + * + * If a #GLogWriterFunc ignores a log entry, it should return + * %G_LOG_WRITER_HANDLED. + * + * Since: 2.50 + */ +typedef enum +{ + G_LOG_WRITER_HANDLED = 1, + G_LOG_WRITER_UNHANDLED = 0, +} GLogWriterOutput; + +/** + * GLogField: + * @key: field name (UTF-8 string) + * @value: field value (arbitrary bytes) + * @length: length of @value, in bytes, or -1 if it is nul-terminated + * + * Structure representing a single field in a structured log entry. See + * g_log_structured() for details. + * + * Log fields may contain arbitrary values, including binary with embedded nul + * bytes. If the field contains a string, the string must be UTF-8 encoded and + * have a trailing nul byte. Otherwise, @length must be set to a non-negative + * value. + * + * Since: 2.50 + */ +typedef struct _GLogField GLogField; +struct _GLogField +{ + const gchar *key; + gconstpointer value; + gssize length; +}; + +/** + * GLogWriterFunc: + * @log_level: log level of the message + * @fields: (array length=n_fields): fields forming the message + * @n_fields: number of @fields + * @user_data: user data passed to g_log_set_writer_func() + * + * Writer function for log entries. A log entry is a collection of one or more + * #GLogFields, using the standard [field names from journal + * specification](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html). + * See g_log_structured() for more information. + * + * Writer functions must ignore fields which they do not recognise, unless they + * can write arbitrary binary output, as field values may be arbitrary binary. + * + * @log_level is guaranteed to be included in @fields as the `PRIORITY` field, + * but is provided separately for convenience of deciding whether or where to + * output the log entry. + * + * Writer functions should return %G_LOG_WRITER_HANDLED if they handled the log + * message successfully or if they deliberately ignored it. If there was an + * error handling the message (for example, if the writer function is meant to + * send messages to a remote logging server and there is a network error), it + * should return %G_LOG_WRITER_UNHANDLED. This allows writer functions to be + * chained and fall back to simpler handlers in case of failure. + * + * Returns: %G_LOG_WRITER_HANDLED if the log entry was handled successfully; + * %G_LOG_WRITER_UNHANDLED otherwise + * + * Since: 2.50 + */ +typedef GLogWriterOutput (*GLogWriterFunc) (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_50 +void g_log_structured (const gchar *log_domain, + GLogLevelFlags log_level, + ...); +GLIB_AVAILABLE_IN_2_50 +void g_log_structured_array (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields); + +GLIB_AVAILABLE_IN_2_50 +void g_log_variant (const gchar *log_domain, + GLogLevelFlags log_level, + GVariant *fields); + +GLIB_AVAILABLE_IN_2_50 +void g_log_set_writer_func (GLogWriterFunc func, + gpointer user_data, + GDestroyNotify user_data_free); + +GLIB_AVAILABLE_IN_2_50 +gboolean g_log_writer_supports_color (gint output_fd); +GLIB_AVAILABLE_IN_2_50 +gboolean g_log_writer_is_journald (gint output_fd); + +GLIB_AVAILABLE_IN_2_50 +gchar *g_log_writer_format_fields (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gboolean use_color); + +GLIB_AVAILABLE_IN_2_80 +GLogWriterOutput g_log_writer_syslog (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); +GLIB_AVAILABLE_IN_2_50 +GLogWriterOutput g_log_writer_journald (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); +GLIB_AVAILABLE_IN_2_50 +GLogWriterOutput g_log_writer_standard_streams (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); +GLIB_AVAILABLE_IN_2_50 +GLogWriterOutput g_log_writer_default (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_68 +void g_log_writer_default_set_use_stderr (gboolean use_stderr); +GLIB_AVAILABLE_IN_2_68 +gboolean g_log_writer_default_would_drop (GLogLevelFlags log_level, + const char *log_domain); +GLIB_AVAILABLE_IN_2_80 +void g_log_writer_default_set_debug_domains (const gchar * const *domains); + + +/* G_MESSAGES_DEBUG enablement */ +GLIB_AVAILABLE_IN_2_72 +gboolean g_log_get_debug_enabled (void); +GLIB_AVAILABLE_IN_2_72 +void g_log_set_debug_enabled (gboolean enabled); + +/** + * G_DEBUG_HERE: + * + * A convenience form of g_log_structured(), recommended to be added to + * functions when debugging. It prints the current monotonic time and the code + * location using %G_STRLOC. + * + * Since: 2.50 + */ +#define G_DEBUG_HERE() \ + g_log_structured (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "CODE_FILE", __FILE__, \ + "CODE_LINE", G_STRINGIFY (__LINE__), \ + "CODE_FUNC", G_STRFUNC, \ + "MESSAGE", "%" G_GINT64_FORMAT ": %s", \ + g_get_monotonic_time (), G_STRLOC) + +/* internal */ +void _g_log_fallback_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer unused_data); + +/* Internal functions, used to implement the following macros */ +GLIB_AVAILABLE_IN_ALL +void g_return_if_fail_warning (const char *log_domain, + const char *pretty_function, + const char *expression) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +void g_warn_message (const char *domain, + const char *file, + int line, + const char *func, + const char *warnexpr) G_ANALYZER_NORETURN; +G_NORETURN +GLIB_DEPRECATED +void g_assert_warning (const char *log_domain, + const char *file, + const int line, + const char *pretty_function, + const char *expression); + +GLIB_AVAILABLE_IN_2_56 +void g_log_structured_standard (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *file, + const gchar *line, + const gchar *func, + const gchar *message_format, + ...) G_GNUC_PRINTF (6, 7); + +#ifndef G_LOG_DOMAIN +#define G_LOG_DOMAIN ((gchar*) 0) +#endif /* G_LOG_DOMAIN */ + +#if defined(G_HAVE_ISO_VARARGS) && !G_ANALYZER_ANALYZING +#if defined(G_LOG_USE_STRUCTURED) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 +#define g_error(...) G_STMT_START { \ + g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__); \ + for (;;) ; \ + } G_STMT_END +#define g_message(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#define g_critical(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#define g_warning(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#define g_info(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#define g_debug(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#else +/* for(;;) ; so that GCC knows that control doesn't go past g_error(). + * Put space before ending semicolon to avoid C++ build warnings. + */ +#define g_error(...) G_STMT_START { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + __VA_ARGS__); \ + for (;;) ; \ + } G_STMT_END +#define g_message(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_MESSAGE, \ + __VA_ARGS__) +#define g_critical(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + __VA_ARGS__) +#define g_warning(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_WARNING, \ + __VA_ARGS__) +#define g_info(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_INFO, \ + __VA_ARGS__) +#define g_debug(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_DEBUG, \ + __VA_ARGS__) +#endif +#elif defined(G_HAVE_GNUC_VARARGS) && !G_ANALYZER_ANALYZING +#if defined(G_LOG_USE_STRUCTURED) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 +#define g_error(format...) G_STMT_START { \ + g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format); \ + for (;;) ; \ + } G_STMT_END +#define g_message(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#define g_critical(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#define g_warning(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#define g_info(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#define g_debug(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#else +#define g_error(format...) G_STMT_START { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + format); \ + for (;;) ; \ + } G_STMT_END + +#define g_message(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_MESSAGE, \ + format) +#define g_critical(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + format) +#define g_warning(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_WARNING, \ + format) +#define g_info(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_INFO, \ + format) +#define g_debug(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_DEBUG, \ + format) +#endif +#else /* no varargs macros */ +G_NORETURN static void g_error (const gchar *format, ...) G_ANALYZER_NORETURN; +static void g_critical (const gchar *format, ...) G_ANALYZER_NORETURN; + +static inline void +g_error (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args); + va_end (args); + + for(;;) ; +} +static inline void +g_message (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args); + va_end (args); +} +static inline void +g_critical (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, args); + va_end (args); +} +static inline void +g_warning (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args); + va_end (args); +} +static inline void +g_info (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format, args); + va_end (args); +} +static inline void +g_debug (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); + va_end (args); +} +#endif /* !__GNUC__ */ + +/** + * g_warning_once: + * @...: format string, followed by parameters to insert + * into the format string (as with printf()) + * + * Logs a warning only once. + * + * g_warning_once() calls g_warning() with the passed message the first time + * the statement is executed; subsequent times it is a no-op. + * + * Note! On platforms where the compiler doesn't support variadic macros, the + * warning is printed each time instead of only once. + * + * Since: 2.64 + */ +#if defined(G_HAVE_ISO_VARARGS) && !G_ANALYZER_ANALYZING +#define g_warning_once(...) \ + G_STMT_START { \ + static int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; /* (atomic) */ \ + if (g_atomic_int_compare_and_exchange (&G_PASTE (_GWarningOnceBoolean, __LINE__), \ + 0, 1)) \ + g_warning (__VA_ARGS__); \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_64 +#elif defined(G_HAVE_GNUC_VARARGS) && !G_ANALYZER_ANALYZING +#define g_warning_once(format...) \ + G_STMT_START { \ + static int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; /* (atomic) */ \ + if (g_atomic_int_compare_and_exchange (&G_PASTE (_GWarningOnceBoolean, __LINE__), \ + 0, 1)) \ + g_warning (format); \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_64 +#else +#define g_warning_once g_warning +#endif + +/** + * GPrintFunc: + * @string: the message to output + * + * Specifies the type of the print handler functions. + * These are called with the complete formatted string to output. + */ +typedef void (*GPrintFunc) (const gchar *string); +GLIB_AVAILABLE_IN_ALL +void g_print (const gchar *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +GPrintFunc g_set_print_handler (GPrintFunc func); +GLIB_AVAILABLE_IN_ALL +void g_printerr (const gchar *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +GPrintFunc g_set_printerr_handler (GPrintFunc func); + +/** + * g_warn_if_reached: + * + * Logs a warning. + * + * Since: 2.16 + */ +#define g_warn_if_reached() \ + do { \ + g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); \ + } while (0) + +/** + * g_warn_if_fail: + * @expr: the expression to check + * + * Logs a warning if the expression is not true. + * + * Unlike g_return_if_fail(), the expression is always evaluated, even if + * checks and assertions are disabled. + * + * Since: 2.16 + */ +#define g_warn_if_fail(expr) \ + do { \ + if G_LIKELY (expr) ; \ + else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, #expr); \ + } while (0) + +#ifdef G_DISABLE_CHECKS + +/** + * g_return_if_fail: + * @expr: the expression to check + * + * Verifies that the expression @expr, usually representing a precondition, + * evaluates to %TRUE. If the function returns a value, use + * g_return_val_if_fail() instead. + * + * If @expr evaluates to %FALSE, the current function should be considered to + * have undefined behaviour (a programmer error). The only correct solution + * to such an error is to change the module that is calling the current + * function, so that it avoids this incorrect call. + * + * To make this undefined behaviour visible, if @expr evaluates to %FALSE, + * the result is usually that a critical message is logged and the current + * function returns. + * + * If `G_DISABLE_CHECKS` is defined then the check is not performed. You + * should therefore not depend on any side effects of @expr. + * + * To debug failure of a g_return_if_fail() check, run the code under a debugger + * with `G_DEBUG=fatal-criticals` or `G_DEBUG=fatal-warnings` defined in the + * environment (see [Running GLib Applications](glib-running.html)): + * + * |[ + * G_DEBUG=fatal-warnings gdb ./my-program + * ]| + * + * Any unrelated failures can be skipped over in + * [gdb](https://www.gnu.org/software/gdb/) using the `continue` command. + */ +#define g_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END + +/** + * g_return_val_if_fail: + * @expr: the expression to check + * @val: the value to return from the current function + * if the expression is not true + * + * Verifies that the expression @expr, usually representing a precondition, + * evaluates to %TRUE. If the function does not return a value, use + * g_return_if_fail() instead. + * + * If @expr evaluates to %FALSE, the current function should be considered to + * have undefined behaviour (a programmer error). The only correct solution + * to such an error is to change the module that is calling the current + * function, so that it avoids this incorrect call. + * + * To make this undefined behaviour visible, if @expr evaluates to %FALSE, + * the result is usually that a critical message is logged and @val is + * returned from the current function. + * + * If `G_DISABLE_CHECKS` is defined then the check is not performed. You + * should therefore not depend on any side effects of @expr. + * + * See g_return_if_fail() for guidance on how to debug failure of this check. + */ +#define g_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END + +/** + * g_return_if_reached: + * + * Logs a critical message and returns from the current function. + * This can only be used in functions which do not return a value. + * + * See g_return_if_fail() for guidance on how to debug failure of this check. + */ +#define g_return_if_reached() G_STMT_START{ return; }G_STMT_END + +/** + * g_return_val_if_reached: + * @val: the value to return from the current function + * + * Logs a critical message and returns @val. + * + * See g_return_if_fail() for guidance on how to debug failure of this check. + */ +#define g_return_val_if_reached(val) G_STMT_START{ return (val); }G_STMT_END + +#else /* !G_DISABLE_CHECKS */ + +#define g_return_if_fail(expr) \ + G_STMT_START { \ + if (G_LIKELY (expr)) \ + { } \ + else \ + { \ + g_return_if_fail_warning (G_LOG_DOMAIN, \ + G_STRFUNC, \ + #expr); \ + return; \ + } \ + } G_STMT_END + +#define g_return_val_if_fail(expr, val) \ + G_STMT_START { \ + if (G_LIKELY (expr)) \ + { } \ + else \ + { \ + g_return_if_fail_warning (G_LOG_DOMAIN, \ + G_STRFUNC, \ + #expr); \ + return (val); \ + } \ + } G_STMT_END + +#define g_return_if_reached() \ + G_STMT_START { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d (%s): should not be reached", \ + __FILE__, \ + __LINE__, \ + G_STRFUNC); \ + return; \ + } G_STMT_END + +#define g_return_val_if_reached(val) \ + G_STMT_START { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d (%s): should not be reached", \ + __FILE__, \ + __LINE__, \ + G_STRFUNC); \ + return (val); \ + } G_STMT_END + +#endif /* !G_DISABLE_CHECKS */ + +G_END_DECLS + +#endif /* __G_MESSAGES_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gnode.h b/illumos-x86_64/usr/include/glib-2.0/glib/gnode.h new file mode 100644 index 00000000..94ab9962 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gnode.h @@ -0,0 +1,309 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_NODE_H__ +#define __G_NODE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GNode GNode; + +/* Tree traverse flags */ +typedef enum +{ + G_TRAVERSE_LEAVES = 1 << 0, + G_TRAVERSE_NON_LEAVES = 1 << 1, + G_TRAVERSE_ALL = G_TRAVERSE_LEAVES | G_TRAVERSE_NON_LEAVES, + G_TRAVERSE_MASK = 0x03, + G_TRAVERSE_LEAFS = G_TRAVERSE_LEAVES, + G_TRAVERSE_NON_LEAFS = G_TRAVERSE_NON_LEAVES +} GTraverseFlags; + +/* Tree traverse orders */ +typedef enum +{ + G_IN_ORDER, + G_PRE_ORDER, + G_POST_ORDER, + G_LEVEL_ORDER +} GTraverseType; + +typedef gboolean (*GNodeTraverseFunc) (GNode *node, + gpointer data); +typedef void (*GNodeForeachFunc) (GNode *node, + gpointer data); + +/* N-way tree implementation + */ +struct _GNode +{ + gpointer data; + GNode *next; + GNode *prev; + GNode *parent; + GNode *children; +}; + +/** + * G_NODE_IS_ROOT: + * @node: a #GNode + * + * Returns %TRUE if a #GNode is the root of a tree. + * + * Returns: %TRUE if the #GNode is the root of a tree + * (i.e. it has no parent or siblings) + */ +#define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \ + ((GNode*) (node))->prev == NULL && \ + ((GNode*) (node))->next == NULL) + +/** + * G_NODE_IS_LEAF: + * @node: a #GNode + * + * Returns %TRUE if a #GNode is a leaf node. + * + * Returns: %TRUE if the #GNode is a leaf node + * (i.e. it has no children) + */ +#define G_NODE_IS_LEAF(node) (((GNode*) (node))->children == NULL) + +GLIB_AVAILABLE_IN_ALL +GNode* g_node_new (gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_node_destroy (GNode *root); +GLIB_AVAILABLE_IN_ALL +void g_node_unlink (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_copy_deep (GNode *node, + GCopyFunc copy_func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_copy (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_insert (GNode *parent, + gint position, + GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_insert_before (GNode *parent, + GNode *sibling, + GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_insert_after (GNode *parent, + GNode *sibling, + GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_prepend (GNode *parent, + GNode *node); +GLIB_AVAILABLE_IN_ALL +guint g_node_n_nodes (GNode *root, + GTraverseFlags flags); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_get_root (GNode *node); +GLIB_AVAILABLE_IN_ALL +gboolean g_node_is_ancestor (GNode *node, + GNode *descendant); +GLIB_AVAILABLE_IN_ALL +guint g_node_depth (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_find (GNode *root, + GTraverseType order, + GTraverseFlags flags, + gpointer data); + +/* convenience macros */ +/** + * g_node_append: + * @parent: the #GNode to place the new #GNode under + * @node: the #GNode to insert + * + * Inserts a #GNode as the last child of the given parent. + * + * Returns: the inserted #GNode + */ +#define g_node_append(parent, node) \ + g_node_insert_before ((parent), NULL, (node)) + +/** + * g_node_insert_data: + * @parent: the #GNode to place the new #GNode under + * @position: the position to place the new #GNode at. If position is -1, + * the new #GNode is inserted as the last child of @parent + * @data: the data for the new #GNode + * + * Inserts a new #GNode at the given position. + * + * Returns: the new #GNode + */ +#define g_node_insert_data(parent, position, data) \ + g_node_insert ((parent), (position), g_node_new (data)) + +/** + * g_node_insert_data_after: + * @parent: the #GNode to place the new #GNode under + * @sibling: the sibling #GNode to place the new #GNode after + * @data: the data for the new #GNode + * + * Inserts a new #GNode after the given sibling. + * + * Returns: the new #GNode + */ + +#define g_node_insert_data_after(parent, sibling, data) \ + g_node_insert_after ((parent), (sibling), g_node_new (data)) +/** + * g_node_insert_data_before: + * @parent: the #GNode to place the new #GNode under + * @sibling: the sibling #GNode to place the new #GNode before + * @data: the data for the new #GNode + * + * Inserts a new #GNode before the given sibling. + * + * Returns: the new #GNode + */ +#define g_node_insert_data_before(parent, sibling, data) \ + g_node_insert_before ((parent), (sibling), g_node_new (data)) + +/** + * g_node_prepend_data: + * @parent: the #GNode to place the new #GNode under + * @data: the data for the new #GNode + * + * Inserts a new #GNode as the first child of the given parent. + * + * Returns: the new #GNode + */ +#define g_node_prepend_data(parent, data) \ + g_node_prepend ((parent), g_node_new (data)) + +/** + * g_node_append_data: + * @parent: the #GNode to place the new #GNode under + * @data: the data for the new #GNode + * + * Inserts a new #GNode as the last child of the given parent. + * + * Returns: the new #GNode + */ +#define g_node_append_data(parent, data) \ + g_node_insert_before ((parent), NULL, g_node_new (data)) + +/* traversal function, assumes that 'node' is root + * (only traverses 'node' and its subtree). + * this function is just a high level interface to + * low level traversal functions, optimized for speed. + */ +GLIB_AVAILABLE_IN_ALL +void g_node_traverse (GNode *root, + GTraverseType order, + GTraverseFlags flags, + gint max_depth, + GNodeTraverseFunc func, + gpointer data); + +/* return the maximum tree height starting with 'node', this is an expensive + * operation, since we need to visit all nodes. this could be shortened by + * adding 'guint height' to struct _GNode, but then again, this is not very + * often needed, and would make g_node_insert() more time consuming. + */ +GLIB_AVAILABLE_IN_ALL +guint g_node_max_height (GNode *root); + +GLIB_AVAILABLE_IN_ALL +void g_node_children_foreach (GNode *node, + GTraverseFlags flags, + GNodeForeachFunc func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_node_reverse_children (GNode *node); +GLIB_AVAILABLE_IN_ALL +guint g_node_n_children (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_nth_child (GNode *node, + guint n); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_last_child (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_find_child (GNode *node, + GTraverseFlags flags, + gpointer data); +GLIB_AVAILABLE_IN_ALL +gint g_node_child_position (GNode *node, + GNode *child); +GLIB_AVAILABLE_IN_ALL +gint g_node_child_index (GNode *node, + gpointer data); + +GLIB_AVAILABLE_IN_ALL +GNode* g_node_first_sibling (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_last_sibling (GNode *node); + +/** + * g_node_prev_sibling: + * @node: a #GNode + * + * Gets the previous sibling of a #GNode. + * + * Returns: the previous sibling of @node, or %NULL if @node is the first + * node or %NULL + */ +#define g_node_prev_sibling(node) ((node) ? \ + ((GNode*) (node))->prev : NULL) + +/** + * g_node_next_sibling: + * @node: a #GNode + * + * Gets the next sibling of a #GNode. + * + * Returns: the next sibling of @node, or %NULL if @node is the last node + * or %NULL + */ +#define g_node_next_sibling(node) ((node) ? \ + ((GNode*) (node))->next : NULL) + +/** + * g_node_first_child: + * @node: a #GNode + * + * Gets the first child of a #GNode. + * + * Returns: the first child of @node, or %NULL if @node is %NULL + * or has no children + */ +#define g_node_first_child(node) ((node) ? \ + ((GNode*) (node))->children : NULL) + +G_END_DECLS + +#endif /* __G_NODE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/goption.h b/illumos-x86_64/usr/include/glib-2.0/glib/goption.h new file mode 100644 index 00000000..a68c6d14 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/goption.h @@ -0,0 +1,431 @@ +/* goption.h - Option parser + * + * Copyright (C) 2004 Anders Carlsson + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_OPTION_H__ +#define __G_OPTION_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/** + * GOptionContext: + * + * A `GOptionContext` struct defines which options + * are accepted by the commandline option parser. The struct has only private + * fields and should not be directly accessed. + */ +typedef struct _GOptionContext GOptionContext; + +/** + * GOptionGroup: + * + * A `GOptionGroup` struct defines the options in a single + * group. The struct has only private fields and should not be directly accessed. + * + * All options in a group share the same translation function. Libraries which + * need to parse commandline options are expected to provide a function for + * getting a `GOptionGroup` holding their options, which + * the application can then add to its #GOptionContext. + */ +typedef struct _GOptionGroup GOptionGroup; +typedef struct _GOptionEntry GOptionEntry; + +/** + * GOptionFlags: + * @G_OPTION_FLAG_HIDDEN: The option doesn't appear in `--help` output. + * @G_OPTION_FLAG_IN_MAIN: The option appears in the main section of the + * `--help` output, even if it is defined in a group. + * @G_OPTION_FLAG_REVERSE: For options of the %G_OPTION_ARG_NONE kind, this + * flag indicates that the sense of the option is reversed. i.e. %FALSE will + * be stored into the argument rather than %TRUE. + * @G_OPTION_FLAG_NO_ARG: For options of the %G_OPTION_ARG_CALLBACK kind, + * this flag indicates that the callback does not take any argument + * (like a %G_OPTION_ARG_NONE option). Since 2.8 + * @G_OPTION_FLAG_FILENAME: For options of the %G_OPTION_ARG_CALLBACK + * kind, this flag indicates that the argument should be passed to the + * callback in the GLib filename encoding rather than UTF-8. Since 2.8 + * @G_OPTION_FLAG_OPTIONAL_ARG: For options of the %G_OPTION_ARG_CALLBACK + * kind, this flag indicates that the argument supply is optional. + * If no argument is given then data of %GOptionParseFunc will be + * set to NULL. Since 2.8 + * @G_OPTION_FLAG_NOALIAS: This flag turns off the automatic conflict + * resolution which prefixes long option names with `groupname-` if + * there is a conflict. This option should only be used in situations + * where aliasing is necessary to model some legacy commandline interface. + * It is not safe to use this option, unless all option groups are under + * your direct control. Since 2.8. + * + * Flags which modify individual options. + */ + +/** + * G_OPTION_FLAG_NONE: + * + * No flags. + * + * Since: 2.42 + */ + +/** + * G_OPTION_FLAG_DEPRECATED: + * + * This flag marks the option as deprecated in the `--help`. + * + * You should update the description of the option to describe what + * the user should do in response to the deprecation, for instance: + * remove the option, or replace it with another one. + * + * Since: 2.84 + */ +typedef enum +{ + G_OPTION_FLAG_NONE = 0, + G_OPTION_FLAG_HIDDEN = 1 << 0, + G_OPTION_FLAG_IN_MAIN = 1 << 1, + G_OPTION_FLAG_REVERSE = 1 << 2, + G_OPTION_FLAG_NO_ARG = 1 << 3, + G_OPTION_FLAG_FILENAME = 1 << 4, + G_OPTION_FLAG_OPTIONAL_ARG = 1 << 5, + G_OPTION_FLAG_NOALIAS = 1 << 6, + G_OPTION_FLAG_DEPRECATED GLIB_AVAILABLE_ENUMERATOR_IN_2_84 = 1 << 7 +} GOptionFlags; + +/** + * GOptionArg: + * @G_OPTION_ARG_NONE: No extra argument. This is useful for simple flags or booleans. + * @G_OPTION_ARG_STRING: The option takes a UTF-8 string argument. + * @G_OPTION_ARG_INT: The option takes an integer argument. + * @G_OPTION_ARG_CALLBACK: The option provides a callback (of type #GOptionArgFunc) + * to parse the extra argument. + * @G_OPTION_ARG_FILENAME: The option takes a filename as argument, which will + be in the GLib filename encoding rather than UTF-8. + * @G_OPTION_ARG_STRING_ARRAY: The option takes a string argument, multiple + * uses of the option are collected into an array of strings. + * @G_OPTION_ARG_FILENAME_ARRAY: The option takes a filename as argument, + * multiple uses of the option are collected into an array of strings. + * @G_OPTION_ARG_DOUBLE: The option takes a double argument. The argument + * can be formatted either for the user's locale or for the "C" locale. + * Since 2.12 + * @G_OPTION_ARG_INT64: The option takes a 64-bit integer. Like + * %G_OPTION_ARG_INT but for larger numbers. The number can be in + * decimal base, or in hexadecimal (when prefixed with `0x`, for + * example, `0xffffffff`). Since 2.12 + * + * The #GOptionArg enum values determine which type of extra argument the + * options expect to find. If an option expects an extra argument, it can + * be specified in several ways; with a short option: `-x arg`, with a long + * option: `--name arg` or combined in a single argument: `--name=arg`. + */ +typedef enum +{ + G_OPTION_ARG_NONE, + G_OPTION_ARG_STRING, + G_OPTION_ARG_INT, + G_OPTION_ARG_CALLBACK, + G_OPTION_ARG_FILENAME, + G_OPTION_ARG_STRING_ARRAY, + G_OPTION_ARG_FILENAME_ARRAY, + G_OPTION_ARG_DOUBLE, + G_OPTION_ARG_INT64 +} GOptionArg; + +/** + * GOptionArgFunc: + * @option_name: The name of the option being parsed. This will be either a + * single dash followed by a single letter (for a short name) or two dashes + * followed by a long option name. + * @value: The value to be parsed. + * @data: User data added to the #GOptionGroup containing the option when it + * was created with g_option_group_new() + * @error: A return location for errors. The error code %G_OPTION_ERROR_FAILED + * is intended to be used for errors in #GOptionArgFunc callbacks. + * + * The type of function to be passed as callback for %G_OPTION_ARG_CALLBACK + * options. + * + * Returns: %TRUE if the option was successfully parsed, %FALSE if an error + * occurred, in which case @error should be set with g_set_error() + */ +typedef gboolean (*GOptionArgFunc) (const gchar *option_name, + const gchar *value, + gpointer data, + GError **error); + +/** + * GOptionParseFunc: + * @context: The active #GOptionContext + * @group: The group to which the function belongs + * @data: User data added to the #GOptionGroup containing the option when it + * was created with g_option_group_new() + * @error: A return location for error details + * + * The type of function that can be called before and after parsing. + * + * Returns: %TRUE if the function completed successfully, %FALSE if an error + * occurred, in which case @error should be set with g_set_error() + */ +typedef gboolean (*GOptionParseFunc) (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error); + +/** + * GOptionErrorFunc: + * @context: The active #GOptionContext + * @group: The group to which the function belongs + * @data: User data added to the #GOptionGroup containing the option when it + * was created with g_option_group_new() + * @error: The #GError containing details about the parse error + * + * The type of function to be used as callback when a parse error occurs. + */ +typedef void (*GOptionErrorFunc) (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error); + +/** + * G_OPTION_ERROR: + * + * Error domain for option parsing. Errors in this domain will + * be from the #GOptionError enumeration. See #GError for information on + * error domains. + */ +#define G_OPTION_ERROR (g_option_error_quark ()) + +/** + * GOptionError: + * @G_OPTION_ERROR_UNKNOWN_OPTION: An option was not known to the parser. + * This error will only be reported, if the parser hasn't been instructed + * to ignore unknown options, see g_option_context_set_ignore_unknown_options(). + * @G_OPTION_ERROR_BAD_VALUE: A value couldn't be parsed. + * @G_OPTION_ERROR_FAILED: A #GOptionArgFunc callback failed. + * + * Error codes returned by option parsing. + */ +typedef enum +{ + G_OPTION_ERROR_UNKNOWN_OPTION, + G_OPTION_ERROR_BAD_VALUE, + G_OPTION_ERROR_FAILED +} GOptionError; + +GLIB_AVAILABLE_IN_ALL +GQuark g_option_error_quark (void); + +/** + * GOptionEntry: + * @long_name: The long name of an option can be used to specify it + * in a commandline as `--long_name`. Every option must have a + * long name. To resolve conflicts if multiple option groups contain + * the same long name, it is also possible to specify the option as + * `--groupname-long_name`. + * @short_name: If an option has a short name, it can be specified + * `-short_name` in a commandline. @short_name must be a printable + * ASCII character different from '-', or zero if the option has no + * short name. + * @flags: Flags from #GOptionFlags + * @arg: The type of the option, as a #GOptionArg + * @arg_data: If the @arg type is %G_OPTION_ARG_CALLBACK, then @arg_data + * must point to a #GOptionArgFunc callback function, which will be + * called to handle the extra argument. Otherwise, @arg_data is a + * pointer to a location to store the value, the required type of + * the location depends on the @arg type: + * + * - %G_OPTION_ARG_NONE: %gboolean + * - %G_OPTION_ARG_STRING: %gchar* + * - %G_OPTION_ARG_INT: %gint + * - %G_OPTION_ARG_FILENAME: %gchar* + * - %G_OPTION_ARG_STRING_ARRAY: %gchar** + * - %G_OPTION_ARG_FILENAME_ARRAY: %gchar** + * - %G_OPTION_ARG_DOUBLE: %gdouble + * + * If @arg type is %G_OPTION_ARG_STRING or %G_OPTION_ARG_FILENAME, + * the location will contain a newly allocated string if the option + * was given. That string needs to be freed by the callee using g_free(). + * Likewise if @arg type is %G_OPTION_ARG_STRING_ARRAY or + * %G_OPTION_ARG_FILENAME_ARRAY, the data should be freed using g_strfreev(). + * @description: the description for the option in `--help` + * output. The @description is translated using the @translate_func + * of the group, see g_option_group_set_translation_domain(). + * @arg_description: The placeholder to use for the extra argument parsed + * by the option in `--help` output. The @arg_description is translated + * using the @translate_func of the group, see + * g_option_group_set_translation_domain(). + * + * A GOptionEntry struct defines a single option. To have an effect, they + * must be added to a #GOptionGroup with g_option_context_add_main_entries() + * or g_option_group_add_entries(). + */ +struct _GOptionEntry +{ + const gchar *long_name; + gchar short_name; + gint flags; + + GOptionArg arg; + gpointer arg_data; + + const gchar *description; + const gchar *arg_description; +}; + +/** + * G_OPTION_REMAINING: + * + * If a long option in the main group has this name, it is not treated as a + * regular option. Instead it collects all non-option arguments which would + * otherwise be left in `argv`. The option must be of type + * %G_OPTION_ARG_CALLBACK, %G_OPTION_ARG_STRING_ARRAY + * or %G_OPTION_ARG_FILENAME_ARRAY. + * + * + * Using %G_OPTION_REMAINING instead of simply scanning `argv` + * for leftover arguments has the advantage that GOption takes care of + * necessary encoding conversions for strings or filenames. + * + * Since: 2.6 + */ +#define G_OPTION_REMAINING "" + +/** + * G_OPTION_ENTRY_NULL: + * + * A #GOptionEntry array requires a %NULL terminator, this macro can + * be used as terminator instead of an explicit `{ 0 }` but it cannot + * be assigned to a variable. + * + * |[ + * GOptionEntry option[] = { G_OPTION_ENTRY_NULL }; + * ]| + * + * Since: 2.70 + */ +#define G_OPTION_ENTRY_NULL \ + GLIB_AVAILABLE_MACRO_IN_2_70 \ + { NULL, 0, 0, 0, NULL, NULL, NULL } + + +GLIB_AVAILABLE_IN_ALL +GOptionContext *g_option_context_new (const gchar *parameter_string); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_summary (GOptionContext *context, + const gchar *summary); +GLIB_AVAILABLE_IN_ALL +const gchar * g_option_context_get_summary (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_description (GOptionContext *context, + const gchar *description); +GLIB_AVAILABLE_IN_ALL +const gchar * g_option_context_get_description (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +void g_option_context_free (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_help_enabled (GOptionContext *context, + gboolean help_enabled); +GLIB_AVAILABLE_IN_ALL +gboolean g_option_context_get_help_enabled (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_ignore_unknown_options (GOptionContext *context, + gboolean ignore_unknown); +GLIB_AVAILABLE_IN_ALL +gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context); + +GLIB_AVAILABLE_IN_2_44 +void g_option_context_set_strict_posix (GOptionContext *context, + gboolean strict_posix); +GLIB_AVAILABLE_IN_2_44 +gboolean g_option_context_get_strict_posix (GOptionContext *context); + +GLIB_AVAILABLE_IN_ALL +void g_option_context_add_main_entries (GOptionContext *context, + const GOptionEntry *entries, + const gchar *translation_domain); +GLIB_AVAILABLE_IN_ALL +gboolean g_option_context_parse (GOptionContext *context, + gint *argc, + gchar ***argv, + GError **error); +GLIB_AVAILABLE_IN_2_40 +gboolean g_option_context_parse_strv (GOptionContext *context, + gchar ***arguments, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_translate_func (GOptionContext *context, + GTranslateFunc func, + gpointer data, + GDestroyNotify destroy_notify); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_translation_domain (GOptionContext *context, + const gchar *domain); + +GLIB_AVAILABLE_IN_ALL +void g_option_context_add_group (GOptionContext *context, + GOptionGroup *group); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_main_group (GOptionContext *context, + GOptionGroup *group); +GLIB_AVAILABLE_IN_ALL +GOptionGroup *g_option_context_get_main_group (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +gchar *g_option_context_get_help (GOptionContext *context, + gboolean main_help, + GOptionGroup *group); + +GLIB_AVAILABLE_IN_ALL +GOptionGroup *g_option_group_new (const gchar *name, + const gchar *description, + const gchar *help_description, + gpointer user_data, + GDestroyNotify destroy); +GLIB_AVAILABLE_IN_ALL +void g_option_group_set_parse_hooks (GOptionGroup *group, + GOptionParseFunc pre_parse_func, + GOptionParseFunc post_parse_func); +GLIB_AVAILABLE_IN_ALL +void g_option_group_set_error_hook (GOptionGroup *group, + GOptionErrorFunc error_func); +GLIB_DEPRECATED_IN_2_44 +void g_option_group_free (GOptionGroup *group); +GLIB_AVAILABLE_IN_2_44 +GOptionGroup *g_option_group_ref (GOptionGroup *group); +GLIB_AVAILABLE_IN_2_44 +void g_option_group_unref (GOptionGroup *group); +GLIB_AVAILABLE_IN_ALL +void g_option_group_add_entries (GOptionGroup *group, + const GOptionEntry *entries); +GLIB_AVAILABLE_IN_ALL +void g_option_group_set_translate_func (GOptionGroup *group, + GTranslateFunc func, + gpointer data, + GDestroyNotify destroy_notify); +GLIB_AVAILABLE_IN_ALL +void g_option_group_set_translation_domain (GOptionGroup *group, + const gchar *domain); + +G_END_DECLS + +#endif /* __G_OPTION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gpathbuf.h b/illumos-x86_64/usr/include/glib-2.0/glib/gpathbuf.h new file mode 100644 index 00000000..1ea01f03 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gpathbuf.h @@ -0,0 +1,83 @@ +/* gpathbuf.h: A mutable path builder + * + * SPDX-FileCopyrightText: 2023 Emmanuele Bassi + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#pragma once + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GPathBuf GPathBuf; + +struct _GPathBuf +{ + /*< private >*/ + gpointer dummy[8]; +}; + +/** + * G_PATH_BUF_INIT: + * + * Initializes a #GPathBuf on the stack. + * + * A stack-allocated `GPathBuf` must be initialized if it is used + * together with g_auto() to avoid warnings and crashes if the + * function returns before calling g_path_buf_init(). + * + * |[ + * g_auto (GPathBuf) buf = G_PATH_BUF_INIT; + * ]| + * + * Since: 2.76 + */ +#define G_PATH_BUF_INIT { { NULL, } } \ + GLIB_AVAILABLE_MACRO_IN_2_76 + +GLIB_AVAILABLE_IN_2_76 +GPathBuf * g_path_buf_new (void); +GLIB_AVAILABLE_IN_2_76 +GPathBuf * g_path_buf_new_from_path (const char *path); +GLIB_AVAILABLE_IN_2_76 +GPathBuf * g_path_buf_init (GPathBuf *buf); +GLIB_AVAILABLE_IN_2_76 +GPathBuf * g_path_buf_init_from_path (GPathBuf *buf, + const char *path); +GLIB_AVAILABLE_IN_2_76 +void g_path_buf_clear (GPathBuf *buf); +GLIB_AVAILABLE_IN_2_76 +char * g_path_buf_clear_to_path (GPathBuf *buf) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_2_76 +void g_path_buf_free (GPathBuf *buf); +GLIB_AVAILABLE_IN_2_76 +char * g_path_buf_free_to_path (GPathBuf *buf) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_2_76 +GPathBuf * g_path_buf_copy (GPathBuf *buf); + +GLIB_AVAILABLE_IN_2_76 +GPathBuf * g_path_buf_push (GPathBuf *buf, + const char *path); +GLIB_AVAILABLE_IN_2_76 +gboolean g_path_buf_pop (GPathBuf *buf); + +GLIB_AVAILABLE_IN_2_76 +gboolean g_path_buf_set_filename (GPathBuf *buf, + const char *file_name); +GLIB_AVAILABLE_IN_2_76 +gboolean g_path_buf_set_extension (GPathBuf *buf, + const char *extension); + +GLIB_AVAILABLE_IN_2_76 +char * g_path_buf_to_path (GPathBuf *buf) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_2_76 +gboolean g_path_buf_equal (gconstpointer v1, + gconstpointer v2); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gpattern.h b/illumos-x86_64/usr/include/glib-2.0/glib/gpattern.h new file mode 100644 index 00000000..c8ceb84d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gpattern.h @@ -0,0 +1,65 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997, 1999 Peter Mattis, Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_PATTERN_H__ +#define __G_PATTERN_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + + +typedef struct _GPatternSpec GPatternSpec; + +GLIB_AVAILABLE_IN_ALL +GPatternSpec* g_pattern_spec_new (const gchar *pattern); +GLIB_AVAILABLE_IN_ALL +void g_pattern_spec_free (GPatternSpec *pspec); +GLIB_AVAILABLE_IN_2_70 +GPatternSpec *g_pattern_spec_copy (GPatternSpec *pspec); +GLIB_AVAILABLE_IN_ALL +gboolean g_pattern_spec_equal (GPatternSpec *pspec1, + GPatternSpec *pspec2); +GLIB_AVAILABLE_IN_2_70 +gboolean g_pattern_spec_match (GPatternSpec *pspec, + gsize string_length, + const gchar *string, + const gchar *string_reversed); +GLIB_AVAILABLE_IN_2_70 +gboolean g_pattern_spec_match_string (GPatternSpec *pspec, + const gchar *string); +GLIB_DEPRECATED_IN_2_70_FOR (g_pattern_spec_match) +gboolean g_pattern_match (GPatternSpec *pspec, + guint string_length, + const gchar *string, + const gchar *string_reversed); +GLIB_DEPRECATED_IN_2_70_FOR (g_pattern_spec_match_string) +gboolean g_pattern_match_string (GPatternSpec *pspec, + const gchar *string); +GLIB_AVAILABLE_IN_ALL +gboolean g_pattern_match_simple (const gchar *pattern, + const gchar *string); + +G_END_DECLS + +#endif /* __G_PATTERN_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gpoll.h b/illumos-x86_64/usr/include/glib-2.0/glib/gpoll.h new file mode 100644 index 00000000..bd72bc42 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gpoll.h @@ -0,0 +1,122 @@ +/* gpoll.h - poll(2) support + * Copyright (C) 2008 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_POLL_H__ +#define __G_POLL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (__G_MAIN_H__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/* Any definitions using GPollFD or GPollFunc are primarily + * for Unix and not guaranteed to be the compatible on all + * operating systems on which GLib runs. Right now, the + * GLib does use these functions on Win32 as well, but interprets + * them in a fairly different way than on Unix. If you use + * these definitions, you are should be prepared to recode + * for different operating systems. + * + * Note that on systems with a working poll(2), that function is used + * in place of g_poll(). Thus g_poll() must have the same signature as + * poll(), meaning GPollFD must have the same layout as struct pollfd. + * + * On Win32, the fd in a GPollFD should be Win32 HANDLE (*not* a file + * descriptor as provided by the C runtime) that can be used by + * MsgWaitForMultipleObjects. This does *not* include file handles + * from CreateFile, SOCKETs, nor pipe handles. (But you can use + * WSAEventSelect to signal events when a SOCKET is readable). + * + * On Win32, fd can also be the special value G_WIN32_MSG_HANDLE to + * indicate polling for messages. + * + * But note that G_WIN32_MSG_HANDLE GPollFDs should not be used by GDK + * (GTK) programs, as GDK itself wants to read messages and convert them + * to GDK events. + * + * So, unless you really know what you are doing, it's best not to try + * to use the main loop polling stuff for your own needs on + * Windows. + */ +typedef struct _GPollFD GPollFD; + +/** + * GPollFunc: + * @ufds: an array of #GPollFD elements + * @nfsd: the number of elements in @ufds + * @timeout_: the maximum time to wait for an event of the file descriptors. + * A negative value indicates an infinite timeout. + * + * Specifies the type of function passed to g_main_context_set_poll_func(). + * The semantics of the function should match those of the poll() system call. + * + * Returns: the number of #GPollFD elements which have events or errors + * reported, or -1 if an error occurred. + */ +typedef gint (*GPollFunc) (GPollFD *ufds, + guint nfsd, + gint timeout_); + +/** + * GPollFD: + * @fd: the file descriptor to poll (or a HANDLE on Win32) + * @events: a bitwise combination from #GIOCondition, specifying which + * events should be polled for. Typically for reading from a file + * descriptor you would use %G_IO_IN | %G_IO_HUP | %G_IO_ERR, and + * for writing you would use %G_IO_OUT | %G_IO_ERR. + * @revents: a bitwise combination of flags from #GIOCondition, returned + * from the poll() function to indicate which events occurred. + * + * Represents a file descriptor, which events to poll for, and which events + * occurred. + */ +struct _GPollFD +{ +#if defined (G_OS_WIN32) && GLIB_SIZEOF_VOID_P == 8 +#ifndef __GTK_DOC_IGNORE__ + gint64 fd; +#endif +#else + gint fd; +#endif + gushort events; + gushort revents; +}; + +/** + * G_POLLFD_FORMAT: + * + * A format specifier that can be used in printf()-style format strings + * when printing the @fd member of a #GPollFD. + */ +/* defined in glibconfig.h */ + +GLIB_AVAILABLE_IN_ALL +gint +g_poll (GPollFD *fds, + guint nfds, + gint timeout); + +G_END_DECLS + +#endif /* __G_POLL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gprimes.h b/illumos-x86_64/usr/include/glib-2.0/glib/gprimes.h new file mode 100644 index 00000000..f35b5fd6 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gprimes.h @@ -0,0 +1,52 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_PRIMES_H__ +#define __G_PRIMES_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* Prime numbers. + */ + +/* This function returns prime numbers spaced by approximately 1.5-2.0 + * and is for use in resizing data structures which prefer + * prime-valued sizes. The closest spaced prime function returns the + * next largest prime, or the highest it knows about which is about + * MAXINT/4. + */ +GLIB_AVAILABLE_IN_ALL +guint g_spaced_primes_closest (guint num) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_PRIMES_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gprintf.h b/illumos-x86_64/usr/include/glib-2.0/glib/gprintf.h new file mode 100644 index 00000000..78b25202 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gprintf.h @@ -0,0 +1,59 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997, 2002 Peter Mattis, Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_PRINTF_H__ +#define __G_PRINTF_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gint g_printf (gchar const *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +gint g_fprintf (FILE *file, + gchar const *format, + ...) G_GNUC_PRINTF (2, 3); +GLIB_AVAILABLE_IN_ALL +gint g_sprintf (gchar *string, + gchar const *format, + ...) G_GNUC_PRINTF (2, 3); + +GLIB_AVAILABLE_IN_ALL +gint g_vprintf (gchar const *format, + va_list args) G_GNUC_PRINTF(1, 0); +GLIB_AVAILABLE_IN_ALL +gint g_vfprintf (FILE *file, + gchar const *format, + va_list args) G_GNUC_PRINTF(2, 0); +GLIB_AVAILABLE_IN_ALL +gint g_vsprintf (gchar *string, + gchar const *format, + va_list args) G_GNUC_PRINTF(2, 0); +GLIB_AVAILABLE_IN_ALL +gint g_vasprintf (gchar **string, + gchar const *format, + va_list args) G_GNUC_PRINTF(2, 0); + +G_END_DECLS + +#endif /* __G_PRINTF_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gqsort.h b/illumos-x86_64/usr/include/glib-2.0/glib/gqsort.h new file mode 100644 index 00000000..611135f3 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gqsort.h @@ -0,0 +1,54 @@ + /* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_QSORT_H__ +#define __G_QSORT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GLIB_DEPRECATED_IN_2_82_FOR(g_sort_array) +void g_qsort_with_data (gconstpointer pbase, + gint total_elems, + gsize size, + GCompareDataFunc compare_func, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_82 +void g_sort_array (const void *array, + size_t n_elements, + size_t element_size, + GCompareDataFunc compare_func, + void *user_data); + +G_END_DECLS + +#endif /* __G_QSORT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gquark.h b/illumos-x86_64/usr/include/glib-2.0/glib/gquark.h new file mode 100644 index 00000000..d0c44039 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gquark.h @@ -0,0 +1,70 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_QUARK_H__ +#define __G_QUARK_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef guint32 GQuark; + +/* Quarks (string<->id association) + */ +GLIB_AVAILABLE_IN_ALL +GQuark g_quark_try_string (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GQuark g_quark_from_static_string (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GQuark g_quark_from_string (const gchar *string); +GLIB_AVAILABLE_IN_ALL +const gchar * g_quark_to_string (GQuark quark) G_GNUC_CONST; + +#define G_DEFINE_QUARK(QN, q_n) \ +GQuark \ +q_n##_quark (void) \ +{ \ + static GQuark q; \ + \ + if G_UNLIKELY (q == 0) \ + q = g_quark_from_static_string (#QN); \ + \ + return q; \ +} + +GLIB_AVAILABLE_IN_ALL +const gchar * g_intern_string (const gchar *string); +GLIB_AVAILABLE_IN_ALL +const gchar * g_intern_static_string (const gchar *string); + +G_END_DECLS + +#endif /* __G_QUARK_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gqueue.h b/illumos-x86_64/usr/include/glib-2.0/glib/gqueue.h new file mode 100644 index 00000000..5b0113b5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gqueue.h @@ -0,0 +1,205 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_QUEUE_H__ +#define __G_QUEUE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GQueue GQueue; + +/** + * GQueue: + * @head: a pointer to the first element of the queue + * @tail: a pointer to the last element of the queue + * @length: the number of elements in the queue + * + * Contains the public fields of a + * [Queue](data-structures.html#double-ended-queues). + */ +struct _GQueue +{ + GList *head; + GList *tail; + guint length; +}; + +/** + * G_QUEUE_INIT: + * + * A statically-allocated #GQueue must be initialized with this + * macro before it can be used. This macro can be used to initialize + * a variable, but it cannot be assigned to a variable. In that case + * you have to use g_queue_init(). + * + * |[ + * GQueue my_queue = G_QUEUE_INIT; + * ]| + * + * Since: 2.14 + */ +#define G_QUEUE_INIT { NULL, NULL, 0 } + +/* Queues + */ +GLIB_AVAILABLE_IN_ALL +GQueue* g_queue_new (void); +GLIB_AVAILABLE_IN_ALL +void g_queue_free (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_queue_free_full (GQueue *queue, + GDestroyNotify free_func); +GLIB_AVAILABLE_IN_ALL +void g_queue_init (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_queue_clear (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gboolean g_queue_is_empty (GQueue *queue); +GLIB_AVAILABLE_IN_2_60 +void g_queue_clear_full (GQueue *queue, + GDestroyNotify free_func); +GLIB_AVAILABLE_IN_ALL +guint g_queue_get_length (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_queue_reverse (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GQueue * g_queue_copy (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_queue_foreach (GQueue *queue, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GList * g_queue_find (GQueue *queue, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GList * g_queue_find_custom (GQueue *queue, + gconstpointer data, + GCompareFunc func); +GLIB_AVAILABLE_IN_ALL +void g_queue_sort (GQueue *queue, + GCompareDataFunc compare_func, + gpointer user_data); + +GLIB_AVAILABLE_IN_ALL +void g_queue_push_head (GQueue *queue, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_queue_push_tail (GQueue *queue, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_queue_push_nth (GQueue *queue, + gpointer data, + gint n); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_pop_head (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_pop_tail (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_pop_nth (GQueue *queue, + guint n); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_peek_head (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_peek_tail (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_peek_nth (GQueue *queue, + guint n); +GLIB_AVAILABLE_IN_ALL +gint g_queue_index (GQueue *queue, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +gboolean g_queue_remove (GQueue *queue, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_queue_remove_all (GQueue *queue, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +void g_queue_insert_before (GQueue *queue, + GList *sibling, + gpointer data); +GLIB_AVAILABLE_IN_2_62 +void g_queue_insert_before_link + (GQueue *queue, + GList *sibling, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_insert_after (GQueue *queue, + GList *sibling, + gpointer data); +GLIB_AVAILABLE_IN_2_62 +void g_queue_insert_after_link + (GQueue *queue, + GList *sibling, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_insert_sorted (GQueue *queue, + gpointer data, + GCompareDataFunc func, + gpointer user_data); + +GLIB_AVAILABLE_IN_ALL +void g_queue_push_head_link (GQueue *queue, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_push_tail_link (GQueue *queue, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_push_nth_link (GQueue *queue, + gint n, + GList *link_); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_pop_head_link (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_pop_tail_link (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_pop_nth_link (GQueue *queue, + guint n); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_peek_head_link (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_peek_tail_link (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_peek_nth_link (GQueue *queue, + guint n); +GLIB_AVAILABLE_IN_ALL +gint g_queue_link_index (GQueue *queue, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_unlink (GQueue *queue, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_delete_link (GQueue *queue, + GList *link_); + +G_END_DECLS + +#endif /* __G_QUEUE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/grand.h b/illumos-x86_64/usr/include/glib-2.0/glib/grand.h new file mode 100644 index 00000000..c4ae956a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/grand.h @@ -0,0 +1,101 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_RAND_H__ +#define __G_RAND_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GRand GRand; + +/* GRand - a good and fast random number generator: Mersenne Twister + * see http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html for more info. + * The range functions return a value in the interval [begin, end). + * int -> [0..2^32-1] + * int_range -> [begin..end-1] + * double -> [0..1) + * double_range -> [begin..end) + */ + +GLIB_AVAILABLE_IN_ALL +GRand* g_rand_new_with_seed (guint32 seed); +GLIB_AVAILABLE_IN_ALL +GRand* g_rand_new_with_seed_array (const guint32 *seed, + guint seed_length); +GLIB_AVAILABLE_IN_ALL +GRand* g_rand_new (void); +GLIB_AVAILABLE_IN_ALL +void g_rand_free (GRand *rand_); +GLIB_AVAILABLE_IN_ALL +GRand* g_rand_copy (GRand *rand_); +GLIB_AVAILABLE_IN_ALL +void g_rand_set_seed (GRand *rand_, + guint32 seed); +GLIB_AVAILABLE_IN_ALL +void g_rand_set_seed_array (GRand *rand_, + const guint32 *seed, + guint seed_length); + +#define g_rand_boolean(rand_) ((g_rand_int (rand_) & (1 << 15)) != 0) + +GLIB_AVAILABLE_IN_ALL +guint32 g_rand_int (GRand *rand_); +GLIB_AVAILABLE_IN_ALL +gint32 g_rand_int_range (GRand *rand_, + gint32 begin, + gint32 end); +GLIB_AVAILABLE_IN_ALL +gdouble g_rand_double (GRand *rand_); +GLIB_AVAILABLE_IN_ALL +gdouble g_rand_double_range (GRand *rand_, + gdouble begin, + gdouble end); +GLIB_AVAILABLE_IN_ALL +void g_random_set_seed (guint32 seed); + +#define g_random_boolean() ((g_random_int () & (1 << 15)) != 0) + +GLIB_AVAILABLE_IN_ALL +guint32 g_random_int (void); +GLIB_AVAILABLE_IN_ALL +gint32 g_random_int_range (gint32 begin, + gint32 end); +GLIB_AVAILABLE_IN_ALL +gdouble g_random_double (void); +GLIB_AVAILABLE_IN_ALL +gdouble g_random_double_range (gdouble begin, + gdouble end); + + +G_END_DECLS + +#endif /* __G_RAND_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/grcbox.h b/illumos-x86_64/usr/include/glib-2.0/glib/grcbox.h new file mode 100644 index 00000000..f101e43a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/grcbox.h @@ -0,0 +1,91 @@ +/* grcbox.h: Reference counted data + * + * Copyright 2018 Emmanuele Bassi + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#pragma once + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_58 +gpointer g_rc_box_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_rc_box_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_rc_box_dup (gsize block_size, + gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_rc_box_acquire (gpointer mem_block); +GLIB_AVAILABLE_IN_2_58 +void g_rc_box_release (gpointer mem_block); +GLIB_AVAILABLE_IN_2_58 +void g_rc_box_release_full (gpointer mem_block, + GDestroyNotify clear_func); + +GLIB_AVAILABLE_IN_2_58 +gsize g_rc_box_get_size (gpointer mem_block); + +GLIB_AVAILABLE_IN_2_58 +gpointer g_atomic_rc_box_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_atomic_rc_box_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_atomic_rc_box_dup (gsize block_size, + gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_atomic_rc_box_acquire (gpointer mem_block); +GLIB_AVAILABLE_IN_2_58 +void g_atomic_rc_box_release (gpointer mem_block); +GLIB_AVAILABLE_IN_2_58 +void g_atomic_rc_box_release_full (gpointer mem_block, + GDestroyNotify clear_func); + +GLIB_AVAILABLE_IN_2_58 +gsize g_atomic_rc_box_get_size (gpointer mem_block); + +#define g_rc_box_new(type) \ + ((type *) g_rc_box_alloc (sizeof (type))) +#define g_rc_box_new0(type) \ + ((type *) g_rc_box_alloc0 (sizeof (type))) +#define g_atomic_rc_box_new(type) \ + ((type *) g_atomic_rc_box_alloc (sizeof (type))) +#define g_atomic_rc_box_new0(type) \ + ((type *) g_atomic_rc_box_alloc0 (sizeof (type))) + +#if defined(glib_typeof) +/* Type check to avoid assigning references to different types */ +#define g_rc_box_acquire(mem_block) \ + ((glib_typeof (mem_block)) (g_rc_box_acquire) (mem_block)) +#define g_atomic_rc_box_acquire(mem_block) \ + ((glib_typeof (mem_block)) (g_atomic_rc_box_acquire) (mem_block)) + +/* Type check to avoid duplicating data to different types */ +#define g_rc_box_dup(block_size, mem_block) \ + ((glib_typeof (mem_block)) (g_rc_box_dup) (block_size, mem_block)) +#define g_atomic_rc_box_dup(block_size, mem_block) \ + ((glib_typeof (mem_block)) (g_atomic_rc_box_dup) (block_size, mem_block)) +#endif + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/grefcount.h b/illumos-x86_64/usr/include/glib-2.0/glib/grefcount.h new file mode 100644 index 00000000..53b96932 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/grefcount.h @@ -0,0 +1,179 @@ +/* grefcount.h: Reference counting + * + * Copyright 2018 Emmanuele Bassi + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __GREFCOUNT_H__ +#define __GREFCOUNT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_58 +void g_ref_count_init (grefcount *rc); +GLIB_AVAILABLE_IN_2_58 +void g_ref_count_inc (grefcount *rc); +GLIB_AVAILABLE_IN_2_58 +gboolean g_ref_count_dec (grefcount *rc); +GLIB_AVAILABLE_IN_2_58 +gboolean g_ref_count_compare (grefcount *rc, + gint val); + +GLIB_AVAILABLE_IN_2_58 +void g_atomic_ref_count_init (gatomicrefcount *arc); +GLIB_AVAILABLE_IN_2_58 +void g_atomic_ref_count_inc (gatomicrefcount *arc); +GLIB_AVAILABLE_IN_2_58 +gboolean g_atomic_ref_count_dec (gatomicrefcount *arc); +GLIB_AVAILABLE_IN_2_58 +gboolean g_atomic_ref_count_compare (gatomicrefcount *arc, + gint val); + +/** + * G_REF_COUNT_INIT: + * + * Evaluates to the initial reference count for `grefcount`. + * + * This macro is useful for initializing `grefcount` fields inside + * structures, for instance: + * + * |[ + * typedef struct { + * grefcount ref_count; + * char *name; + * char *address; + * } Person; + * + * static const Person default_person = { + * .ref_count = G_REF_COUNT_INIT, + * .name = "Default name", + * .address = "Default address", + * }; + * ]| + * + * Since: 2.78 + */ +#define G_REF_COUNT_INIT -1 \ + GLIB_AVAILABLE_MACRO_IN_2_78 + +/** + * G_ATOMIC_REF_COUNT_INIT: + * + * Evaluates to the initial reference count for `gatomicrefcount`. + * + * This macro is useful for initializing `gatomicrefcount` fields inside + * structures, for instance: + * + * |[ + * typedef struct { + * gatomicrefcount ref_count; + * char *name; + * char *address; + * } Person; + * + * static const Person default_person = { + * .ref_count = G_ATOMIC_REF_COUNT_INIT, + * .name = "Default name", + * .address = "Default address", + * }; + * ]| + * + * Since: 2.78 + */ +#define G_ATOMIC_REF_COUNT_INIT 1 \ + GLIB_AVAILABLE_MACRO_IN_2_78 + +/* On GCC we can use __extension__ to inline the API without using + * ancillary functions; we only do this when disabling checks, as + * it disables warnings when saturating the reference counters + */ +#if defined(__GNUC__) && defined(G_DISABLE_CHECKS) + +# define g_ref_count_init(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + *(rc) = -1; \ + })) + +# define g_ref_count_inc(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + if (*(rc) == G_MININT) ; else { \ + *(rc) -= 1; \ + } \ + })) + +# define g_ref_count_dec(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ + grefcount __rc = *(rc); \ + __rc += 1; \ + if (__rc == 0) ; else { \ + *(rc) = __rc; \ + } \ + (gboolean) (__rc == 0); \ + })) + +# define g_ref_count_compare(rc,val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ + (void) (0 ? *(rc) ^ (val) : 1); \ + (gboolean) (*(rc) == -(val)); \ + })) + +# define g_atomic_ref_count_init(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + *(rc) = 1; \ + })) + +# define g_atomic_ref_count_inc(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + (void) (g_atomic_int_get (rc) == G_MAXINT ? 0 : g_atomic_int_inc ((rc))); \ + })) + +# define g_atomic_ref_count_dec(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + g_atomic_int_dec_and_test ((rc)); \ + })) + +# define g_atomic_ref_count_compare(rc,val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ + (void) (0 ? *(rc) ^ (val) : 1); \ + (gboolean) (g_atomic_int_get (rc) == (val)); \ + })) + +#endif /* __GNUC__ && G_DISABLE_CHECKS */ + +G_END_DECLS + +#endif /* __GREFCOUNT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/grefstring.h b/illumos-x86_64/usr/include/glib-2.0/glib/grefstring.h new file mode 100644 index 00000000..b149b731 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/grefstring.h @@ -0,0 +1,63 @@ +/* grefstring.h: Reference counted strings + * + * Copyright 2018 Emmanuele Bassi + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#pragma once + +#include "gmem.h" +#include "gmacros.h" + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_58 +char * g_ref_string_new (const char *str); +GLIB_AVAILABLE_IN_2_58 +char * g_ref_string_new_len (const char *str, + gssize len); +GLIB_AVAILABLE_IN_2_58 +char * g_ref_string_new_intern (const char *str); + +GLIB_AVAILABLE_IN_2_58 +char * g_ref_string_acquire (char *str); +GLIB_AVAILABLE_IN_2_58 +void g_ref_string_release (char *str); + +GLIB_AVAILABLE_IN_2_58 +gsize g_ref_string_length (char *str); + +/** + * GRefString: + * + * A typedef for a reference-counted string. A pointer to a #GRefString can be + * treated like a standard `char*` array by all code, but can additionally have + * `g_ref_string_*()` methods called on it. `g_ref_string_*()` methods cannot be + * called on `char*` arrays not allocated using g_ref_string_new(). + * + * If using #GRefString with autocleanups, g_autoptr() must be used rather than + * g_autofree(), so that the reference counting metadata is also freed. + * + * Since: 2.58 + */ +typedef char GRefString; + +GLIB_AVAILABLE_IN_2_84 +gboolean g_ref_string_equal (const char *str1, + const char *str2); + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gregex.h b/illumos-x86_64/usr/include/glib-2.0/glib/gregex.h new file mode 100644 index 00000000..fd2bf818 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gregex.h @@ -0,0 +1,612 @@ +/* GRegex -- regular expression API wrapper around PCRE. + * + * Copyright (C) 1999, 2000 Scott Wimer + * Copyright (C) 2004, Matthias Clasen + * Copyright (C) 2005 - 2007, Marco Barisione + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_REGEX_H__ +#define __G_REGEX_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/** + * GRegexError: + * @G_REGEX_ERROR_COMPILE: Compilation of the regular expression failed. + * @G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression failed. + * @G_REGEX_ERROR_REPLACE: Replacement failed due to an ill-formed replacement + * string. + * @G_REGEX_ERROR_MATCH: The match process failed. + * @G_REGEX_ERROR_INTERNAL: Internal error of the regular expression engine. + * Since 2.16 + * @G_REGEX_ERROR_STRAY_BACKSLASH: "\\" at end of pattern. Since 2.16 + * @G_REGEX_ERROR_MISSING_CONTROL_CHAR: "\\c" at end of pattern. Since 2.16 + * @G_REGEX_ERROR_UNRECOGNIZED_ESCAPE: Unrecognized character follows "\\". + * Since 2.16 + * @G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER: Numbers out of order in "{}" + * quantifier. Since 2.16 + * @G_REGEX_ERROR_QUANTIFIER_TOO_BIG: Number too big in "{}" quantifier. + * Since 2.16 + * @G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS: Missing terminating "]" for + * character class. Since 2.16 + * @G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS: Invalid escape sequence + * in character class. Since 2.16 + * @G_REGEX_ERROR_RANGE_OUT_OF_ORDER: Range out of order in character class. + * Since 2.16 + * @G_REGEX_ERROR_NOTHING_TO_REPEAT: Nothing to repeat. Since 2.16 + * @G_REGEX_ERROR_UNRECOGNIZED_CHARACTER: Unrecognized character after "(?", + * "(?<" or "(?P". Since 2.16 + * @G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS: POSIX named classes are + * supported only within a class. Since 2.16 + * @G_REGEX_ERROR_UNMATCHED_PARENTHESIS: Missing terminating ")" or ")" + * without opening "(". Since 2.16 + * @G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE: Reference to non-existent + * subpattern. Since 2.16 + * @G_REGEX_ERROR_UNTERMINATED_COMMENT: Missing terminating ")" after comment. + * Since 2.16 + * @G_REGEX_ERROR_EXPRESSION_TOO_LARGE: Regular expression too large. + * Since 2.16 + * @G_REGEX_ERROR_MEMORY_ERROR: Failed to get memory. Since 2.16 + * @G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND: Lookbehind assertion is not + * fixed length. Since 2.16 + * @G_REGEX_ERROR_MALFORMED_CONDITION: Malformed number or name after "(?(". + * Since 2.16 + * @G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES: Conditional group contains + * more than two branches. Since 2.16 + * @G_REGEX_ERROR_ASSERTION_EXPECTED: Assertion expected after "(?(". + * Since 2.16 + * @G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME: Unknown POSIX class name. + * Since 2.16 + * @G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED: POSIX collating + * elements are not supported. Since 2.16 + * @G_REGEX_ERROR_HEX_CODE_TOO_LARGE: Character value in "\\x{...}" sequence + * is too large. Since 2.16 + * @G_REGEX_ERROR_INVALID_CONDITION: Invalid condition "(?(0)". Since 2.16 + * @G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND: \\C not allowed in + * lookbehind assertion. Since 2.16 + * @G_REGEX_ERROR_INFINITE_LOOP: Recursive call could loop indefinitely. + * Since 2.16 + * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR: Missing terminator + * in subpattern name. Since 2.16 + * @G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME: Two named subpatterns have + * the same name. Since 2.16 + * @G_REGEX_ERROR_MALFORMED_PROPERTY: Malformed "\\P" or "\\p" sequence. + * Since 2.16 + * @G_REGEX_ERROR_UNKNOWN_PROPERTY: Unknown property name after "\\P" or + * "\\p". Since 2.16 + * @G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG: Subpattern name is too long + * (maximum 32 characters). Since 2.16 + * @G_REGEX_ERROR_TOO_MANY_SUBPATTERNS: Too many named subpatterns (maximum + * 10,000). Since 2.16 + * @G_REGEX_ERROR_INVALID_OCTAL_VALUE: Octal value is greater than "\\377". + * Since 2.16 + * @G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE: "DEFINE" group contains more + * than one branch. Since 2.16 + * @G_REGEX_ERROR_DEFINE_REPETION: Repeating a "DEFINE" group is not allowed. + * This error is never raised. Since: 2.16 Deprecated: 2.34 + * @G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS: Inconsistent newline options. + * Since 2.16 + * @G_REGEX_ERROR_MISSING_BACK_REFERENCE: "\\g" is not followed by a braced, + * angle-bracketed, or quoted name or number, or by a plain number. Since: 2.16 + * @G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE: relative reference must not be zero. Since: 2.34 + * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN: the backtracing + * control verb used does not allow an argument. Since: 2.34 + * @G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB: unknown backtracing + * control verb. Since: 2.34 + * @G_REGEX_ERROR_NUMBER_TOO_BIG: number is too big in escape sequence. Since: 2.34 + * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME: Missing subpattern name. Since: 2.34 + * @G_REGEX_ERROR_MISSING_DIGIT: Missing digit. Since 2.34 + * @G_REGEX_ERROR_INVALID_DATA_CHARACTER: In JavaScript compatibility mode, + * "[" is an invalid data character. Since: 2.34 + * @G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME: different names for subpatterns of the + * same number are not allowed. Since: 2.34 + * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED: the backtracing control + * verb requires an argument. Since: 2.34 + * @G_REGEX_ERROR_INVALID_CONTROL_CHAR: "\\c" must be followed by an ASCII + * character. Since: 2.34 + * @G_REGEX_ERROR_MISSING_NAME: "\\k" is not followed by a braced, angle-bracketed, or + * quoted name. Since: 2.34 + * @G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS: "\\N" is not supported in a class. Since: 2.34 + * @G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES: too many forward references. Since: 2.34 + * @G_REGEX_ERROR_NAME_TOO_LONG: the name is too long in "(*MARK)", "(*PRUNE)", + * "(*SKIP)", or "(*THEN)". Since: 2.34 + * @G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE: the character value in the \\u sequence is + * too large. Since: 2.34 + * + * Error codes returned by regular expressions functions. + * + * Since: 2.14 + */ +typedef enum +{ + G_REGEX_ERROR_COMPILE, + G_REGEX_ERROR_OPTIMIZE, + G_REGEX_ERROR_REPLACE, + G_REGEX_ERROR_MATCH, + G_REGEX_ERROR_INTERNAL, + + /* These are the error codes from PCRE + 100 */ + G_REGEX_ERROR_STRAY_BACKSLASH = 101, + G_REGEX_ERROR_MISSING_CONTROL_CHAR = 102, + G_REGEX_ERROR_UNRECOGNIZED_ESCAPE = 103, + G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER = 104, + G_REGEX_ERROR_QUANTIFIER_TOO_BIG = 105, + G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS = 106, + G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS = 107, + G_REGEX_ERROR_RANGE_OUT_OF_ORDER = 108, + G_REGEX_ERROR_NOTHING_TO_REPEAT = 109, + G_REGEX_ERROR_UNRECOGNIZED_CHARACTER = 112, + G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113, + G_REGEX_ERROR_UNMATCHED_PARENTHESIS = 114, + G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE = 115, + G_REGEX_ERROR_UNTERMINATED_COMMENT = 118, + G_REGEX_ERROR_EXPRESSION_TOO_LARGE = 120, + G_REGEX_ERROR_MEMORY_ERROR = 121, + G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND = 125, + G_REGEX_ERROR_MALFORMED_CONDITION = 126, + G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES = 127, + G_REGEX_ERROR_ASSERTION_EXPECTED = 128, + G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME = 130, + G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131, + G_REGEX_ERROR_HEX_CODE_TOO_LARGE = 134, + G_REGEX_ERROR_INVALID_CONDITION = 135, + G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136, + G_REGEX_ERROR_INFINITE_LOOP = 140, + G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR = 142, + G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME = 143, + G_REGEX_ERROR_MALFORMED_PROPERTY = 146, + G_REGEX_ERROR_UNKNOWN_PROPERTY = 147, + G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG = 148, + G_REGEX_ERROR_TOO_MANY_SUBPATTERNS = 149, + G_REGEX_ERROR_INVALID_OCTAL_VALUE = 151, + G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE = 154, + G_REGEX_ERROR_DEFINE_REPETION = 155, + G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS = 156, + G_REGEX_ERROR_MISSING_BACK_REFERENCE = 157, + G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE = 158, + G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN = 159, + G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB = 160, + G_REGEX_ERROR_NUMBER_TOO_BIG = 161, + G_REGEX_ERROR_MISSING_SUBPATTERN_NAME = 162, + G_REGEX_ERROR_MISSING_DIGIT = 163, + G_REGEX_ERROR_INVALID_DATA_CHARACTER = 164, + G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME = 165, + G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED = 166, + G_REGEX_ERROR_INVALID_CONTROL_CHAR = 168, + G_REGEX_ERROR_MISSING_NAME = 169, + G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS = 171, + G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES = 172, + G_REGEX_ERROR_NAME_TOO_LONG = 175, + G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE = 176 +} GRegexError; + +/** + * G_REGEX_ERROR: + * + * Error domain for regular expressions. Errors in this domain will be + * from the #GRegexError enumeration. See #GError for information on + * error domains. + * + * Since: 2.14 + */ +#define G_REGEX_ERROR g_regex_error_quark () + +GLIB_AVAILABLE_IN_ALL +GQuark g_regex_error_quark (void); + +/** + * GRegexCompileFlags: + * @G_REGEX_DEFAULT: No special options set. Since: 2.74 + * @G_REGEX_CASELESS: Letters in the pattern match both upper- and + * lowercase letters. This option can be changed within a pattern + * by a "(?i)" option setting. + * @G_REGEX_MULTILINE: By default, GRegex treats the strings as consisting + * of a single line of characters (even if it actually contains + * newlines). The "start of line" metacharacter ("^") matches only + * at the start of the string, while the "end of line" metacharacter + * ("$") matches only at the end of the string, or before a terminating + * newline (unless %G_REGEX_DOLLAR_ENDONLY is set). When + * %G_REGEX_MULTILINE is set, the "start of line" and "end of line" + * constructs match immediately following or immediately before any + * newline in the string, respectively, as well as at the very start + * and end. This can be changed within a pattern by a "(?m)" option + * setting. + * @G_REGEX_DOTALL: A dot metacharacter (".") in the pattern matches all + * characters, including newlines. Without it, newlines are excluded. + * This option can be changed within a pattern by a ("?s") option setting. + * @G_REGEX_EXTENDED: Whitespace data characters in the pattern are + * totally ignored except when escaped or inside a character class. + * Whitespace does not include the VT character (code 11). In addition, + * characters between an unescaped "#" outside a character class and + * the next newline character, inclusive, are also ignored. This can + * be changed within a pattern by a "(?x)" option setting. + * @G_REGEX_ANCHORED: The pattern is forced to be "anchored", that is, + * it is constrained to match only at the first matching point in the + * string that is being searched. This effect can also be achieved by + * appropriate constructs in the pattern itself such as the "^" + * metacharacter. + * @G_REGEX_DOLLAR_ENDONLY: A dollar metacharacter ("$") in the pattern + * matches only at the end of the string. Without this option, a + * dollar also matches immediately before the final character if + * it is a newline (but not before any other newlines). This option + * is ignored if %G_REGEX_MULTILINE is set. + * @G_REGEX_UNGREEDY: Inverts the "greediness" of the quantifiers so that + * they are not greedy by default, but become greedy if followed by "?". + * It can also be set by a "(?U)" option setting within the pattern. + * @G_REGEX_RAW: Usually strings must be valid UTF-8 strings, using this + * flag they are considered as a raw sequence of bytes. + * @G_REGEX_NO_AUTO_CAPTURE: Disables the use of numbered capturing + * parentheses in the pattern. Any opening parenthesis that is not + * followed by "?" behaves as if it were followed by "?:" but named + * parentheses can still be used for capturing (and they acquire numbers + * in the usual way). + * @G_REGEX_OPTIMIZE: Since 2.74 and the port to pcre2, requests JIT + * compilation, which, if the just-in-time compiler is available, further + * processes a compiled pattern into machine code that executes much + * faster. However, it comes at the cost of extra processing before the + * match is performed, so it is most beneficial to use this when the same + * compiled pattern is used for matching many times. Before 2.74 this + * option used the built-in non-JIT optimizations in pcre1. + * @G_REGEX_FIRSTLINE: Limits an unanchored pattern to match before (or at) the + * first newline. Since: 2.34 + * @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not + * be unique. This can be helpful for certain types of pattern when it + * is known that only one instance of the named subpattern can ever be + * matched. + * @G_REGEX_NEWLINE_CR: Usually any newline character or character sequence is + * recognized. If this option is set, the only recognized newline character + * is '\r'. + * @G_REGEX_NEWLINE_LF: Usually any newline character or character sequence is + * recognized. If this option is set, the only recognized newline character + * is '\n'. + * @G_REGEX_NEWLINE_CRLF: Usually any newline character or character sequence is + * recognized. If this option is set, the only recognized newline character + * sequence is '\r\n'. + * @G_REGEX_NEWLINE_ANYCRLF: Usually any newline character or character sequence + * is recognized. If this option is set, the only recognized newline character + * sequences are '\r', '\n', and '\r\n'. Since: 2.34 + * @G_REGEX_BSR_ANYCRLF: Usually any newline character or character sequence + * is recognised. If this option is set, then "\R" only recognizes the newline + * characters '\r', '\n' and '\r\n'. Since: 2.34 + * @G_REGEX_JAVASCRIPT_COMPAT: Changes behaviour so that it is compatible with + * JavaScript rather than PCRE. Since GLib 2.74 this is no longer supported, + * as libpcre2 does not support it. Since: 2.34 Deprecated: 2.74 + * + * Flags specifying compile-time options. + * + * Since: 2.14 + */ +/* Remember to update G_REGEX_COMPILE_MASK in gregex.c after + * adding a new flag. + */ +typedef enum +{ + G_REGEX_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_REGEX_CASELESS = 1 << 0, + G_REGEX_MULTILINE = 1 << 1, + G_REGEX_DOTALL = 1 << 2, + G_REGEX_EXTENDED = 1 << 3, + G_REGEX_ANCHORED = 1 << 4, + G_REGEX_DOLLAR_ENDONLY = 1 << 5, + G_REGEX_UNGREEDY = 1 << 9, + G_REGEX_RAW = 1 << 11, + G_REGEX_NO_AUTO_CAPTURE = 1 << 12, + G_REGEX_OPTIMIZE = 1 << 13, + G_REGEX_FIRSTLINE = 1 << 18, + G_REGEX_DUPNAMES = 1 << 19, + G_REGEX_NEWLINE_CR = 1 << 20, + G_REGEX_NEWLINE_LF = 1 << 21, + G_REGEX_NEWLINE_CRLF = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF, + G_REGEX_NEWLINE_ANYCRLF = G_REGEX_NEWLINE_CR | 1 << 22, + G_REGEX_BSR_ANYCRLF = 1 << 23, + G_REGEX_JAVASCRIPT_COMPAT GLIB_DEPRECATED_ENUMERATOR_IN_2_74 = 1 << 25 +} GRegexCompileFlags; + +/** + * GRegexMatchFlags: + * @G_REGEX_MATCH_DEFAULT: No special options set. Since: 2.74 + * @G_REGEX_MATCH_ANCHORED: The pattern is forced to be "anchored", that is, + * it is constrained to match only at the first matching point in the + * string that is being searched. This effect can also be achieved by + * appropriate constructs in the pattern itself such as the "^" + * metacharacter. + * @G_REGEX_MATCH_NOTBOL: Specifies that first character of the string is + * not the beginning of a line, so the circumflex metacharacter should + * not match before it. Setting this without %G_REGEX_MULTILINE (at + * compile time) causes circumflex never to match. This option affects + * only the behaviour of the circumflex metacharacter, it does not + * affect "\A". + * @G_REGEX_MATCH_NOTEOL: Specifies that the end of the subject string is + * not the end of a line, so the dollar metacharacter should not match + * it nor (except in multiline mode) a newline immediately before it. + * Setting this without %G_REGEX_MULTILINE (at compile time) causes + * dollar never to match. This option affects only the behaviour of + * the dollar metacharacter, it does not affect "\Z" or "\z". + * @G_REGEX_MATCH_NOTEMPTY: An empty string is not considered to be a valid + * match if this option is set. If there are alternatives in the pattern, + * they are tried. If all the alternatives match the empty string, the + * entire match fails. For example, if the pattern "a?b?" is applied to + * a string not beginning with "a" or "b", it matches the empty string + * at the start of the string. With this flag set, this match is not + * valid, so GRegex searches further into the string for occurrences + * of "a" or "b". + * @G_REGEX_MATCH_PARTIAL: Turns on the partial matching feature, for more + * documentation on partial matching see g_match_info_is_partial_match(). + * @G_REGEX_MATCH_NEWLINE_CR: Overrides the newline definition set when + * creating a new #GRegex, setting the '\r' character as line terminator. + * @G_REGEX_MATCH_NEWLINE_LF: Overrides the newline definition set when + * creating a new #GRegex, setting the '\n' character as line terminator. + * @G_REGEX_MATCH_NEWLINE_CRLF: Overrides the newline definition set when + * creating a new #GRegex, setting the '\r\n' characters sequence as line terminator. + * @G_REGEX_MATCH_NEWLINE_ANY: Overrides the newline definition set when + * creating a new #GRegex, any Unicode newline sequence + * is recognised as a newline. These are '\r', '\n' and '\rn', and the + * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), + * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and + * U+2029 PARAGRAPH SEPARATOR. + * @G_REGEX_MATCH_NEWLINE_ANYCRLF: Overrides the newline definition set when + * creating a new #GRegex; any '\r', '\n', or '\r\n' character sequence + * is recognized as a newline. Since: 2.34 + * @G_REGEX_MATCH_BSR_ANYCRLF: Overrides the newline definition for "\R" set when + * creating a new #GRegex; only '\r', '\n', or '\r\n' character sequences + * are recognized as a newline by "\R". Since: 2.34 + * @G_REGEX_MATCH_BSR_ANY: Overrides the newline definition for "\R" set when + * creating a new #GRegex; any Unicode newline character or character sequence + * are recognized as a newline by "\R". These are '\r', '\n' and '\rn', and the + * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), + * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and + * U+2029 PARAGRAPH SEPARATOR. Since: 2.34 + * @G_REGEX_MATCH_PARTIAL_SOFT: An alias for %G_REGEX_MATCH_PARTIAL. Since: 2.34 + * @G_REGEX_MATCH_PARTIAL_HARD: Turns on the partial matching feature. In contrast to + * to %G_REGEX_MATCH_PARTIAL_SOFT, this stops matching as soon as a partial match + * is found, without continuing to search for a possible complete match. See + * g_match_info_is_partial_match() for more information. Since: 2.34 + * @G_REGEX_MATCH_NOTEMPTY_ATSTART: Like %G_REGEX_MATCH_NOTEMPTY, but only applied to + * the start of the matched string. For anchored + * patterns this can only happen for pattern containing "\K". Since: 2.34 + * + * Flags specifying match-time options. + * + * Since: 2.14 + */ +/* Remember to update G_REGEX_MATCH_MASK in gregex.c after + * adding a new flag. */ +typedef enum +{ + G_REGEX_MATCH_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_REGEX_MATCH_ANCHORED = 1 << 4, + G_REGEX_MATCH_NOTBOL = 1 << 7, + G_REGEX_MATCH_NOTEOL = 1 << 8, + G_REGEX_MATCH_NOTEMPTY = 1 << 10, + G_REGEX_MATCH_PARTIAL = 1 << 15, + G_REGEX_MATCH_NEWLINE_CR = 1 << 20, + G_REGEX_MATCH_NEWLINE_LF = 1 << 21, + G_REGEX_MATCH_NEWLINE_CRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_LF, + G_REGEX_MATCH_NEWLINE_ANY = 1 << 22, + G_REGEX_MATCH_NEWLINE_ANYCRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_ANY, + G_REGEX_MATCH_BSR_ANYCRLF = 1 << 23, + G_REGEX_MATCH_BSR_ANY = 1 << 24, + G_REGEX_MATCH_PARTIAL_SOFT = G_REGEX_MATCH_PARTIAL, + G_REGEX_MATCH_PARTIAL_HARD = 1 << 27, + G_REGEX_MATCH_NOTEMPTY_ATSTART = 1 << 28 +} GRegexMatchFlags; + +typedef struct _GRegex GRegex; + + +/** + * GMatchInfo: + * + * A GMatchInfo is an opaque struct used to return information about + * matches. + */ +typedef struct _GMatchInfo GMatchInfo; + +/** + * GRegexEvalCallback: + * @match_info: the #GMatchInfo generated by the match. + * Use g_match_info_get_regex() and g_match_info_get_string() if you + * need the #GRegex or the matched string. + * @result: a #GString containing the new string + * @user_data: user data passed to g_regex_replace_eval() + * + * Specifies the type of the function passed to g_regex_replace_eval(). + * It is called for each occurrence of the pattern in the string passed + * to g_regex_replace_eval(), and it should append the replacement to + * @result. + * + * Returns: %FALSE to continue the replacement process, %TRUE to stop it + * + * Since: 2.14 + */ +typedef gboolean (*GRegexEvalCallback) (const GMatchInfo *match_info, + GString *result, + gpointer user_data); + + +GLIB_AVAILABLE_IN_ALL +GRegex *g_regex_new (const gchar *pattern, + GRegexCompileFlags compile_options, + GRegexMatchFlags match_options, + GError **error); +GLIB_AVAILABLE_IN_ALL +GRegex *g_regex_ref (GRegex *regex); +GLIB_AVAILABLE_IN_ALL +void g_regex_unref (GRegex *regex); +GLIB_AVAILABLE_IN_ALL +const gchar *g_regex_get_pattern (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +gint g_regex_get_max_backref (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +gint g_regex_get_capture_count (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_get_has_cr_or_lf (const GRegex *regex); +GLIB_AVAILABLE_IN_2_38 +gint g_regex_get_max_lookbehind (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +gint g_regex_get_string_number (const GRegex *regex, + const gchar *name); +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_escape_string (const gchar *string, + gint length); +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_escape_nul (const gchar *string, + gint length); + +GLIB_AVAILABLE_IN_ALL +GRegexCompileFlags g_regex_get_compile_flags (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +GRegexMatchFlags g_regex_get_match_flags (const GRegex *regex); + +/* Matching. */ +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match_simple (const gchar *pattern, + const gchar *string, + GRegexCompileFlags compile_options, + GRegexMatchFlags match_options); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match (const GRegex *regex, + const gchar *string, + GRegexMatchFlags match_options, + GMatchInfo **match_info); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match_full (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + GRegexMatchFlags match_options, + GMatchInfo **match_info, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match_all (const GRegex *regex, + const gchar *string, + GRegexMatchFlags match_options, + GMatchInfo **match_info); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match_all_full (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + GRegexMatchFlags match_options, + GMatchInfo **match_info, + GError **error); + +/* String splitting. */ +GLIB_AVAILABLE_IN_ALL +gchar **g_regex_split_simple (const gchar *pattern, + const gchar *string, + GRegexCompileFlags compile_options, + GRegexMatchFlags match_options); +GLIB_AVAILABLE_IN_ALL +gchar **g_regex_split (const GRegex *regex, + const gchar *string, + GRegexMatchFlags match_options); +GLIB_AVAILABLE_IN_ALL +gchar **g_regex_split_full (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + GRegexMatchFlags match_options, + gint max_tokens, + GError **error); + +/* String replacement. */ +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_replace (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + const gchar *replacement, + GRegexMatchFlags match_options, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_replace_literal (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + const gchar *replacement, + GRegexMatchFlags match_options, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_replace_eval (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + GRegexMatchFlags match_options, + GRegexEvalCallback eval, + gpointer user_data, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_check_replacement (const gchar *replacement, + gboolean *has_references, + GError **error); + +/* Match info */ +GLIB_AVAILABLE_IN_ALL +GRegex *g_match_info_get_regex (const GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +const gchar *g_match_info_get_string (const GMatchInfo *match_info); + +GLIB_AVAILABLE_IN_ALL +GMatchInfo *g_match_info_ref (GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +void g_match_info_unref (GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +void g_match_info_free (GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_next (GMatchInfo *match_info, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_matches (const GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +gint g_match_info_get_match_count (const GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_is_partial_match (const GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +gchar *g_match_info_expand_references(const GMatchInfo *match_info, + const gchar *string_to_expand, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_match_info_fetch (const GMatchInfo *match_info, + gint match_num); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_fetch_pos (const GMatchInfo *match_info, + gint match_num, + gint *start_pos, + gint *end_pos); +GLIB_AVAILABLE_IN_ALL +gchar *g_match_info_fetch_named (const GMatchInfo *match_info, + const gchar *name); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_fetch_named_pos (const GMatchInfo *match_info, + const gchar *name, + gint *start_pos, + gint *end_pos); +GLIB_AVAILABLE_IN_ALL +gchar **g_match_info_fetch_all (const GMatchInfo *match_info); + +G_END_DECLS + +#endif /* __G_REGEX_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gscanner.h b/illumos-x86_64/usr/include/glib-2.0/glib/gscanner.h new file mode 100644 index 00000000..bbad353e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gscanner.h @@ -0,0 +1,301 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_SCANNER_H__ +#define __G_SCANNER_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GScanner GScanner; +typedef struct _GScannerConfig GScannerConfig; +typedef union _GTokenValue GTokenValue; + +typedef void (*GScannerMsgFunc) (GScanner *scanner, + gchar *message, + gboolean error); + +/* GScanner: Flexible lexical scanner for general purpose. + */ + +/* Character sets */ +#define G_CSET_A_2_Z "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +#define G_CSET_a_2_z "abcdefghijklmnopqrstuvwxyz" +#define G_CSET_DIGITS "0123456789" +#define G_CSET_LATINC "\300\301\302\303\304\305\306"\ + "\307\310\311\312\313\314\315\316\317\320"\ + "\321\322\323\324\325\326"\ + "\330\331\332\333\334\335\336" +#define G_CSET_LATINS "\337\340\341\342\343\344\345\346"\ + "\347\350\351\352\353\354\355\356\357\360"\ + "\361\362\363\364\365\366"\ + "\370\371\372\373\374\375\376\377" + +/* Error types */ +typedef enum +{ + G_ERR_UNKNOWN, + G_ERR_UNEXP_EOF, + G_ERR_UNEXP_EOF_IN_STRING, + G_ERR_UNEXP_EOF_IN_COMMENT, + G_ERR_NON_DIGIT_IN_CONST, + G_ERR_DIGIT_RADIX, + G_ERR_FLOAT_RADIX, + G_ERR_FLOAT_MALFORMED +} GErrorType; + +/* Token types */ +typedef enum +{ + G_TOKEN_EOF = 0, + + G_TOKEN_LEFT_PAREN = '(', + G_TOKEN_RIGHT_PAREN = ')', + G_TOKEN_LEFT_CURLY = '{', + G_TOKEN_RIGHT_CURLY = '}', + G_TOKEN_LEFT_BRACE = '[', + G_TOKEN_RIGHT_BRACE = ']', + G_TOKEN_EQUAL_SIGN = '=', + G_TOKEN_COMMA = ',', + + G_TOKEN_NONE = 256, + + G_TOKEN_ERROR, + + G_TOKEN_CHAR, + G_TOKEN_BINARY, + G_TOKEN_OCTAL, + G_TOKEN_INT, + G_TOKEN_HEX, + G_TOKEN_FLOAT, + G_TOKEN_STRING, + + G_TOKEN_SYMBOL, + G_TOKEN_IDENTIFIER, + G_TOKEN_IDENTIFIER_NULL, + + G_TOKEN_COMMENT_SINGLE, + G_TOKEN_COMMENT_MULTI, + + /*< private >*/ + G_TOKEN_LAST +} GTokenType; + +union _GTokenValue +{ + gpointer v_symbol; + gchar *v_identifier; + gulong v_binary; + gulong v_octal; + gulong v_int; + guint64 v_int64; + gdouble v_float; + gulong v_hex; + gchar *v_string; + gchar *v_comment; + guchar v_char; + guint v_error; +}; + +struct _GScannerConfig +{ + /* Character sets + */ + gchar *cset_skip_characters; /* default: " \t\n" */ + gchar *cset_identifier_first; + gchar *cset_identifier_nth; + gchar *cpair_comment_single; /* default: "#\n" */ + + /* Should symbol lookup work case sensitive? + */ + guint case_sensitive : 1; + + /* Boolean values to be adjusted "on the fly" + * to configure scanning behaviour. + */ + guint skip_comment_multi : 1; /* C like comment */ + guint skip_comment_single : 1; /* single line comment */ + guint scan_comment_multi : 1; /* scan multi line comments? */ + guint scan_identifier : 1; + guint scan_identifier_1char : 1; + guint scan_identifier_NULL : 1; + guint scan_symbols : 1; + guint scan_binary : 1; + guint scan_octal : 1; + guint scan_float : 1; + guint scan_hex : 1; /* '0x0ff0' */ + guint scan_hex_dollar : 1; /* '$0ff0' */ + guint scan_string_sq : 1; /* string: 'anything' */ + guint scan_string_dq : 1; /* string: "\\-escapes!\n" */ + guint numbers_2_int : 1; /* bin, octal, hex => int */ + guint int_2_float : 1; /* int => G_TOKEN_FLOAT? */ + guint identifier_2_string : 1; + guint char_2_token : 1; /* return G_TOKEN_CHAR? */ + guint symbol_2_token : 1; + guint scope_0_fallback : 1; /* try scope 0 on lookups? */ + guint store_int64 : 1; /* use value.v_int64 rather than v_int */ + + /*< private >*/ + guint padding_dummy; +}; + +struct _GScanner +{ + /* unused fields */ + gpointer user_data; + guint max_parse_errors; + + /* g_scanner_error() increments this field */ + guint parse_errors; + + /* name of input stream, featured by the default message handler */ + const gchar *input_name; + + /* quarked data */ + GData *qdata; + + /* link into the scanner configuration */ + GScannerConfig *config; + + /* fields filled in after g_scanner_get_next_token() */ + GTokenType token; + GTokenValue value; + guint line; + guint position; + + /* fields filled in after g_scanner_peek_next_token() */ + GTokenType next_token; + GTokenValue next_value; + guint next_line; + guint next_position; + + /*< private >*/ + /* to be considered private */ + GHashTable *symbol_table; + gint input_fd; + const gchar *text; + const gchar *text_end; + gchar *buffer; + guint scope_id; + + /*< public >*/ + /* handler function for _warn and _error */ + GScannerMsgFunc msg_handler; +}; + +GLIB_AVAILABLE_IN_ALL +GScanner* g_scanner_new (const GScannerConfig *config_templ); +GLIB_AVAILABLE_IN_ALL +void g_scanner_destroy (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +void g_scanner_input_file (GScanner *scanner, + gint input_fd); +GLIB_AVAILABLE_IN_ALL +void g_scanner_sync_file_offset (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +void g_scanner_input_text (GScanner *scanner, + const gchar *text, + guint text_len); +GLIB_AVAILABLE_IN_ALL +GTokenType g_scanner_get_next_token (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +GTokenType g_scanner_peek_next_token (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +GTokenType g_scanner_cur_token (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +GTokenValue g_scanner_cur_value (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +guint g_scanner_cur_line (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +guint g_scanner_cur_position (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +gboolean g_scanner_eof (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +guint g_scanner_set_scope (GScanner *scanner, + guint scope_id); +GLIB_AVAILABLE_IN_ALL +void g_scanner_scope_add_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol, + gpointer value); +GLIB_AVAILABLE_IN_ALL +void g_scanner_scope_remove_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol); +GLIB_AVAILABLE_IN_ALL +gpointer g_scanner_scope_lookup_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol); +GLIB_AVAILABLE_IN_ALL +void g_scanner_scope_foreach_symbol (GScanner *scanner, + guint scope_id, + GHFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_scanner_lookup_symbol (GScanner *scanner, + const gchar *symbol); +GLIB_AVAILABLE_IN_ALL +void g_scanner_unexp_token (GScanner *scanner, + GTokenType expected_token, + const gchar *identifier_spec, + const gchar *symbol_spec, + const gchar *symbol_name, + const gchar *message, + gint is_error); +GLIB_AVAILABLE_IN_ALL +void g_scanner_error (GScanner *scanner, + const gchar *format, + ...) G_GNUC_PRINTF (2,3); +GLIB_AVAILABLE_IN_ALL +void g_scanner_warn (GScanner *scanner, + const gchar *format, + ...) G_GNUC_PRINTF (2,3); + +/* keep downward source compatibility */ +#define g_scanner_add_symbol( scanner, symbol, value ) G_STMT_START { \ + g_scanner_scope_add_symbol ((scanner), 0, (symbol), (value)); \ +} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_add_symbol) +#define g_scanner_remove_symbol( scanner, symbol ) G_STMT_START { \ + g_scanner_scope_remove_symbol ((scanner), 0, (symbol)); \ +} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_remove_symbol) +#define g_scanner_foreach_symbol( scanner, func, data ) G_STMT_START { \ + g_scanner_scope_foreach_symbol ((scanner), 0, (func), (data)); \ +} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_foreach_symbol) + +/* The following two functions are deprecated and will be removed in + * the next major release. They do no good. */ +#define g_scanner_freeze_symbol_table(scanner) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 +#define g_scanner_thaw_symbol_table(scanner) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 + +G_END_DECLS + +#endif /* __G_SCANNER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gsequence.h b/illumos-x86_64/usr/include/glib-2.0/glib/gsequence.h new file mode 100644 index 00000000..c1b34049 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gsequence.h @@ -0,0 +1,175 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 + * Soeren Sandmann (sandmann@daimi.au.dk) + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_SEQUENCE_H__ +#define __G_SEQUENCE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GSequence GSequence; +typedef struct _GSequenceNode GSequenceIter; + +typedef gint (* GSequenceIterCompareFunc) (GSequenceIter *a, + GSequenceIter *b, + gpointer data); + + +/* GSequence */ +GLIB_AVAILABLE_IN_ALL +GSequence * g_sequence_new (GDestroyNotify data_destroy); +GLIB_AVAILABLE_IN_ALL +void g_sequence_free (GSequence *seq); +GLIB_AVAILABLE_IN_ALL +gint g_sequence_get_length (GSequence *seq); +GLIB_AVAILABLE_IN_ALL +void g_sequence_foreach (GSequence *seq, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_foreach_range (GSequenceIter *begin, + GSequenceIter *end, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_sort (GSequence *seq, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_sort_iter (GSequence *seq, + GSequenceIterCompareFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_2_48 +gboolean g_sequence_is_empty (GSequence *seq); + + +/* Getting iters */ +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_get_begin_iter (GSequence *seq); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_get_end_iter (GSequence *seq); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_get_iter_at_pos (GSequence *seq, + gint pos); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_append (GSequence *seq, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_prepend (GSequence *seq, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_insert_before (GSequenceIter *iter, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_move (GSequenceIter *src, + GSequenceIter *dest); +GLIB_AVAILABLE_IN_ALL +void g_sequence_swap (GSequenceIter *a, + GSequenceIter *b); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_insert_sorted (GSequence *seq, + gpointer data, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_insert_sorted_iter (GSequence *seq, + gpointer data, + GSequenceIterCompareFunc iter_cmp, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_sort_changed (GSequenceIter *iter, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_sort_changed_iter (GSequenceIter *iter, + GSequenceIterCompareFunc iter_cmp, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_remove (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +void g_sequence_remove_range (GSequenceIter *begin, + GSequenceIter *end); +GLIB_AVAILABLE_IN_ALL +void g_sequence_move_range (GSequenceIter *dest, + GSequenceIter *begin, + GSequenceIter *end); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_search (GSequence *seq, + gpointer data, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_search_iter (GSequence *seq, + gpointer data, + GSequenceIterCompareFunc iter_cmp, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_lookup (GSequence *seq, + gpointer data, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_lookup_iter (GSequence *seq, + gpointer data, + GSequenceIterCompareFunc iter_cmp, + gpointer cmp_data); + + +/* Dereferencing */ +GLIB_AVAILABLE_IN_ALL +gpointer g_sequence_get (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +void g_sequence_set (GSequenceIter *iter, + gpointer data); + +/* Operations on GSequenceIter * */ +GLIB_AVAILABLE_IN_ALL +gboolean g_sequence_iter_is_begin (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +gboolean g_sequence_iter_is_end (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_iter_next (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_iter_prev (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +gint g_sequence_iter_get_position (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_iter_move (GSequenceIter *iter, + gint delta); +GLIB_AVAILABLE_IN_ALL +GSequence * g_sequence_iter_get_sequence (GSequenceIter *iter); + + +/* Search */ +GLIB_AVAILABLE_IN_ALL +gint g_sequence_iter_compare (GSequenceIter *a, + GSequenceIter *b); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_range_get_midpoint (GSequenceIter *begin, + GSequenceIter *end); + +G_END_DECLS + +#endif /* __G_SEQUENCE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gshell.h b/illumos-x86_64/usr/include/glib-2.0/glib/gshell.h new file mode 100644 index 00000000..4084b69c --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gshell.h @@ -0,0 +1,59 @@ +/* gshell.h - Shell-related utilities + * + * Copyright 2000 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_SHELL_H__ +#define __G_SHELL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define G_SHELL_ERROR g_shell_error_quark () + +typedef enum +{ + /* mismatched or otherwise mangled quoting */ + G_SHELL_ERROR_BAD_QUOTING, + /* string to be parsed was empty */ + G_SHELL_ERROR_EMPTY_STRING, + G_SHELL_ERROR_FAILED +} GShellError; + +GLIB_AVAILABLE_IN_ALL +GQuark g_shell_error_quark (void); + +GLIB_AVAILABLE_IN_ALL +gchar* g_shell_quote (const gchar *unquoted_string); +GLIB_AVAILABLE_IN_ALL +gchar* g_shell_unquote (const gchar *quoted_string, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_shell_parse_argv (const gchar *command_line, + gint *argcp, + gchar ***argvp, + GError **error); + +G_END_DECLS + +#endif /* __G_SHELL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gslice.h b/illumos-x86_64/usr/include/glib-2.0/glib/gslice.h new file mode 100644 index 00000000..cfa528ed --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gslice.h @@ -0,0 +1,119 @@ +/* GLIB sliced memory - fast threaded memory chunk allocator + * Copyright (C) 2005 Tim Janik + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_SLICE_H__ +#define __G_SLICE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/* slices - fast allocation/release of small memory blocks + */ +GLIB_AVAILABLE_IN_ALL +gpointer g_slice_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_slice_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_slice_copy (gsize block_size, + gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +void g_slice_free1 (gsize block_size, + gpointer mem_block); +GLIB_AVAILABLE_IN_ALL +void g_slice_free_chain_with_offset (gsize block_size, + gpointer mem_chain, + gsize next_offset); +#define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type))) + +/* Allow the compiler to inline memset(). Since the size is a constant, this + * can significantly improve performance. */ +#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) +# define g_slice_new0(type) \ + (type *) (G_GNUC_EXTENSION ({ \ + gsize __s = sizeof (type); \ + gpointer __p; \ + __p = g_slice_alloc (__s); \ + memset (__p, 0, __s); \ + __p; \ + })) +#else +# define g_slice_new0(type) ((type*) g_slice_alloc0 (sizeof (type))) +#endif + +/* MemoryBlockType * + * g_slice_dup (MemoryBlockType, + * MemoryBlockType *mem_block); + * g_slice_free (MemoryBlockType, + * MemoryBlockType *mem_block); + * g_slice_free_chain (MemoryBlockType, + * MemoryBlockType *first_chain_block, + * memory_block_next_field); + * pseudo prototypes for the macro + * definitions following below. + */ + +/* we go through extra hoops to ensure type safety */ +#define g_slice_dup(type, mem) \ + (1 ? (type*) g_slice_copy (sizeof (type), (mem)) \ + : ((void) ((type*) 0 == (mem)), (type*) 0)) +#define g_slice_free(type, mem) \ +G_STMT_START { \ + if (1) g_slice_free1 (sizeof (type), (mem)); \ + else (void) ((type*) 0 == (mem)); \ +} G_STMT_END +#define g_slice_free_chain(type, mem_chain, next) \ +G_STMT_START { \ + if (1) g_slice_free_chain_with_offset (sizeof (type), \ + (mem_chain), G_STRUCT_OFFSET (type, next)); \ + else (void) ((type*) 0 == (mem_chain)); \ +} G_STMT_END + +/* --- internal debugging API --- */ +typedef enum { + G_SLICE_CONFIG_ALWAYS_MALLOC = 1, + G_SLICE_CONFIG_BYPASS_MAGAZINES, + G_SLICE_CONFIG_WORKING_SET_MSECS, + G_SLICE_CONFIG_COLOR_INCREMENT, + G_SLICE_CONFIG_CHUNK_SIZES, + G_SLICE_CONFIG_CONTENTION_COUNTER +} GSliceConfig; + +GLIB_DEPRECATED_IN_2_34 +void g_slice_set_config (GSliceConfig ckey, gint64 value); +GLIB_DEPRECATED_IN_2_34 +gint64 g_slice_get_config (GSliceConfig ckey); +GLIB_DEPRECATED_IN_2_34 +gint64* g_slice_get_config_state (GSliceConfig ckey, gint64 address, guint *n_values); + +#ifndef __GI_SCANNER__ +#ifdef G_ENABLE_DEBUG +GLIB_AVAILABLE_IN_ALL +void g_slice_debug_tree_statistics (void); +#endif +#endif + +G_END_DECLS + +#endif /* __G_SLICE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gslist.h b/illumos-x86_64/usr/include/glib-2.0/glib/gslist.h new file mode 100644 index 00000000..c8e0cf22 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gslist.h @@ -0,0 +1,166 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_SLIST_H__ +#define __G_SLIST_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GSList GSList; + +struct _GSList +{ + gpointer data; + GSList *next; +}; + +/* Singly linked lists + */ +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_alloc (void) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +void g_slist_free (GSList *list); +GLIB_AVAILABLE_IN_ALL +void g_slist_free_1 (GSList *list); +#define g_slist_free1 g_slist_free_1 +GLIB_AVAILABLE_IN_ALL +void g_slist_free_full (GSList *list, + GDestroyNotify free_func); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_append (GSList *list, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_prepend (GSList *list, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_insert (GSList *list, + gpointer data, + gint position) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_insert_sorted (GSList *list, + gpointer data, + GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_insert_sorted_with_data (GSList *list, + gpointer data, + GCompareDataFunc func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_insert_before (GSList *slist, + GSList *sibling, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_concat (GSList *list1, + GSList *list2) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_remove (GSList *list, + gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_remove_all (GSList *list, + gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_remove_link (GSList *list, + GSList *link_) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_delete_link (GSList *list, + GSList *link_) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_reverse (GSList *list) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_copy (GSList *list) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_2_34 +GSList* g_slist_copy_deep (GSList *list, + GCopyFunc func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_nth (GSList *list, + guint n); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_find (GSList *list, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_find_custom (GSList *list, + gconstpointer data, + GCompareFunc func); +GLIB_AVAILABLE_IN_ALL +gint g_slist_position (GSList *list, + GSList *llink); +GLIB_AVAILABLE_IN_ALL +gint g_slist_index (GSList *list, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_last (GSList *list); +GLIB_AVAILABLE_IN_ALL +guint g_slist_length (GSList *list); +GLIB_AVAILABLE_IN_ALL +void g_slist_foreach (GSList *list, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_sort (GSList *list, + GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_sort_with_data (GSList *list, + GCompareDataFunc compare_func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gpointer g_slist_nth_data (GSList *list, + guint n); + +GLIB_AVAILABLE_IN_2_64 +void g_clear_slist (GSList **slist_ptr, + GDestroyNotify destroy); + +#define g_clear_slist(slist_ptr, destroy) \ + G_STMT_START { \ + GSList *_slist; \ + \ + _slist = *(slist_ptr); \ + if (_slist) \ + { \ + *slist_ptr = NULL; \ + \ + if ((destroy) != NULL) \ + g_slist_free_full (_slist, (destroy)); \ + else \ + g_slist_free (_slist); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_64 + +#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL) + +G_END_DECLS + +#endif /* __G_SLIST_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gspawn.h b/illumos-x86_64/usr/include/glib-2.0/glib/gspawn.h new file mode 100644 index 00000000..a3c4aca5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gspawn.h @@ -0,0 +1,323 @@ +/* gspawn.h - Process launching + * + * Copyright 2000 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_SPAWN_H__ +#define __G_SPAWN_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + + +/* I'm not sure I remember our proposed naming convention here. */ +/** + * G_SPAWN_ERROR: + * + * Error domain for spawning processes. Errors in this domain will + * be from the #GSpawnError enumeration. See #GError for information on + * error domains. + */ +#define G_SPAWN_ERROR g_spawn_error_quark () + +/** + * GSpawnError: + * @G_SPAWN_ERROR_FORK: Fork failed due to lack of memory. + * @G_SPAWN_ERROR_READ: Read or select on pipes failed. + * @G_SPAWN_ERROR_CHDIR: Changing to working directory failed. + * @G_SPAWN_ERROR_ACCES: execv() returned `EACCES` + * @G_SPAWN_ERROR_PERM: execv() returned `EPERM` + * @G_SPAWN_ERROR_TOO_BIG: execv() returned `E2BIG` + * @G_SPAWN_ERROR_2BIG: deprecated alias for %G_SPAWN_ERROR_TOO_BIG (deprecated since GLib 2.32) + * @G_SPAWN_ERROR_NOEXEC: execv() returned `ENOEXEC` + * @G_SPAWN_ERROR_NAMETOOLONG: execv() returned `ENAMETOOLONG` + * @G_SPAWN_ERROR_NOENT: execv() returned `ENOENT` + * @G_SPAWN_ERROR_NOMEM: execv() returned `ENOMEM` + * @G_SPAWN_ERROR_NOTDIR: execv() returned `ENOTDIR` + * @G_SPAWN_ERROR_LOOP: execv() returned `ELOOP` + * @G_SPAWN_ERROR_TXTBUSY: execv() returned `ETXTBUSY` + * @G_SPAWN_ERROR_IO: execv() returned `EIO` + * @G_SPAWN_ERROR_NFILE: execv() returned `ENFILE` + * @G_SPAWN_ERROR_MFILE: execv() returned `EMFILE` + * @G_SPAWN_ERROR_INVAL: execv() returned `EINVAL` + * @G_SPAWN_ERROR_ISDIR: execv() returned `EISDIR` + * @G_SPAWN_ERROR_LIBBAD: execv() returned `ELIBBAD` + * @G_SPAWN_ERROR_FAILED: Some other fatal failure, + * `error->message` should explain. + * + * Error codes returned by spawning processes. + */ +typedef enum +{ + G_SPAWN_ERROR_FORK, /* fork failed due to lack of memory */ + G_SPAWN_ERROR_READ, /* read or select on pipes failed */ + G_SPAWN_ERROR_CHDIR, /* changing to working dir failed */ + G_SPAWN_ERROR_ACCES, /* execv() returned EACCES */ + G_SPAWN_ERROR_PERM, /* execv() returned EPERM */ + G_SPAWN_ERROR_TOO_BIG,/* execv() returned E2BIG */ + G_SPAWN_ERROR_2BIG GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(G_SPAWN_ERROR_TOO_BIG) = G_SPAWN_ERROR_TOO_BIG, + G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */ + G_SPAWN_ERROR_NAMETOOLONG, /* "" "" ENAMETOOLONG */ + G_SPAWN_ERROR_NOENT, /* "" "" ENOENT */ + G_SPAWN_ERROR_NOMEM, /* "" "" ENOMEM */ + G_SPAWN_ERROR_NOTDIR, /* "" "" ENOTDIR */ + G_SPAWN_ERROR_LOOP, /* "" "" ELOOP */ + G_SPAWN_ERROR_TXTBUSY, /* "" "" ETXTBUSY */ + G_SPAWN_ERROR_IO, /* "" "" EIO */ + G_SPAWN_ERROR_NFILE, /* "" "" ENFILE */ + G_SPAWN_ERROR_MFILE, /* "" "" EMFLE */ + G_SPAWN_ERROR_INVAL, /* "" "" EINVAL */ + G_SPAWN_ERROR_ISDIR, /* "" "" EISDIR */ + G_SPAWN_ERROR_LIBBAD, /* "" "" ELIBBAD */ + G_SPAWN_ERROR_FAILED /* other fatal failure, error->message + * should explain + */ +} GSpawnError; + +/** + * G_SPAWN_EXIT_ERROR: + * + * Error domain used by g_spawn_check_wait_status(). The code + * will be the program exit code. + */ +#define G_SPAWN_EXIT_ERROR g_spawn_exit_error_quark () + +/** + * GSpawnChildSetupFunc: + * @data: user data passed to the function. + * + * Specifies the type of the setup function passed to g_spawn_async(), + * g_spawn_sync() and g_spawn_async_with_pipes(), which can, in very + * limited ways, be used to affect the child's execution. + * + * On POSIX platforms, the function is called in the child after GLib + * has performed all the setup it plans to perform, but before calling + * exec(). Actions taken in this function will only affect the child, + * not the parent. + * + * On Windows, the function is called in the parent. Its usefulness on + * Windows is thus questionable. In many cases executing the child setup + * function in the parent can have ill effects, and you should be very + * careful when porting software to Windows that uses child setup + * functions. + * + * However, even on POSIX, you are extremely limited in what you can + * safely do from a #GSpawnChildSetupFunc, because any mutexes that were + * held by other threads in the parent process at the time of the fork() + * will still be locked in the child process, and they will never be + * unlocked (since the threads that held them don't exist in the child). + * POSIX allows only async-signal-safe functions (see signal(7)) to be + * called in the child between fork() and exec(), which drastically limits + * the usefulness of child setup functions. + * + * In particular, it is not safe to call any function which may + * call malloc(), which includes POSIX functions such as setenv(). + * If you need to set up the child environment differently from + * the parent, you should use g_get_environ(), g_environ_setenv(), + * and g_environ_unsetenv(), and then pass the complete environment + * list to the `g_spawn...` function. + */ +typedef void (* GSpawnChildSetupFunc) (gpointer data); + +/** + * GSpawnFlags: + * @G_SPAWN_DEFAULT: no flags, default behaviour + * @G_SPAWN_LEAVE_DESCRIPTORS_OPEN: the parent's open file descriptors will + * be inherited by the child; otherwise all descriptors except stdin, + * stdout and stderr will be closed before calling exec() in the child. + * @G_SPAWN_DO_NOT_REAP_CHILD: the child will not be automatically reaped; + * you must use g_child_watch_add() yourself (or call waitpid() or handle + * `SIGCHLD` yourself), or the child will become a zombie. + * @G_SPAWN_SEARCH_PATH: `argv[0]` need not be an absolute path, it will be + * looked for in the user's `PATH`. + * @G_SPAWN_STDOUT_TO_DEV_NULL: the child's standard output will be discarded, + * instead of going to the same location as the parent's standard output. + * @G_SPAWN_STDERR_TO_DEV_NULL: the child's standard error will be discarded. + * @G_SPAWN_CHILD_INHERITS_STDIN: the child will inherit the parent's standard + * input (by default, the child's standard input is attached to `/dev/null`). + * @G_SPAWN_FILE_AND_ARGV_ZERO: the first element of `argv` is the file to + * execute, while the remaining elements are the actual argument vector + * to pass to the file. Normally g_spawn_async_with_pipes() uses `argv[0]` + * as the file to execute, and passes all of `argv` to the child. + * @G_SPAWN_SEARCH_PATH_FROM_ENVP: if `argv[0]` is not an absolute path, + * it will be looked for in the `PATH` from the passed child environment. + * Since: 2.34 + * @G_SPAWN_CLOEXEC_PIPES: create all pipes with the `O_CLOEXEC` flag set. + * Since: 2.40 + * @G_SPAWN_CHILD_INHERITS_STDOUT: the child will inherit the parent's standard output. + * Since: 2.74 + * @G_SPAWN_CHILD_INHERITS_STDERR: the child will inherit the parent's standard error. + * Since: 2.74 + * @G_SPAWN_STDIN_FROM_DEV_NULL: the child's standard input is attached to `/dev/null`. + * Since: 2.74 + * + * Flags passed to g_spawn_sync(), g_spawn_async() and g_spawn_async_with_pipes(). + */ +typedef enum +{ + G_SPAWN_DEFAULT = 0, + G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0, + G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, + /* look for argv[0] in the path i.e. use execvp() */ + G_SPAWN_SEARCH_PATH = 1 << 2, + /* Dump output to /dev/null */ + G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, + G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, + G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5, + G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6, + G_SPAWN_SEARCH_PATH_FROM_ENVP = 1 << 7, + G_SPAWN_CLOEXEC_PIPES = 1 << 8, + + /** + * G_SPAWN_CHILD_INHERITS_STDOUT: + * + * The child will inherit the parent's standard output. + * + * Since: 2.74 + */ + G_SPAWN_CHILD_INHERITS_STDOUT = 1 << 9, + + /** + * G_SPAWN_CHILD_INHERITS_STDERR: + * + * The child will inherit the parent's standard error. + * + * Since: 2.74 + */ + G_SPAWN_CHILD_INHERITS_STDERR = 1 << 10, + + /** + * G_SPAWN_STDIN_FROM_DEV_NULL: + * + * The child's standard input is attached to `/dev/null`. + * + * Since: 2.74 + */ + G_SPAWN_STDIN_FROM_DEV_NULL = 1 << 11 +} GSpawnFlags; + +GLIB_AVAILABLE_IN_ALL +GQuark g_spawn_error_quark (void); +GLIB_AVAILABLE_IN_ALL +GQuark g_spawn_exit_error_quark (void); + +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_async (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + GError **error); + + +/* Opens pipes for non-NULL standard_output, standard_input, standard_error, + * and returns the parent's end of the pipes. + */ +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_async_with_pipes (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + gint *standard_input, + gint *standard_output, + gint *standard_error, + GError **error); + +GLIB_AVAILABLE_IN_2_68 +gboolean g_spawn_async_with_pipes_and_fds (const gchar *working_directory, + const gchar * const *argv, + const gchar * const *envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + gint stdin_fd, + gint stdout_fd, + gint stderr_fd, + const gint *source_fds, + const gint *target_fds, + gsize n_fds, + GPid *child_pid_out, + gint *stdin_pipe_out, + gint *stdout_pipe_out, + gint *stderr_pipe_out, + GError **error); + +/* Lets you provide fds for stdin/stdout/stderr */ +GLIB_AVAILABLE_IN_2_58 +gboolean g_spawn_async_with_fds (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + gint stdin_fd, + gint stdout_fd, + gint stderr_fd, + GError **error); + +/* If standard_output or standard_error are non-NULL, the full + * standard output or error of the command will be placed there. + */ + +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_sync (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + gchar **standard_output, + gchar **standard_error, + gint *wait_status, + GError **error); + +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_command_line_sync (const gchar *command_line, + gchar **standard_output, + gchar **standard_error, + gint *wait_status, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_command_line_async (const gchar *command_line, + GError **error); + +GLIB_AVAILABLE_IN_2_70 +gboolean g_spawn_check_wait_status (gint wait_status, + GError **error); + +GLIB_DEPRECATED_IN_2_70_FOR(g_spawn_check_wait_status) +gboolean g_spawn_check_exit_status (gint wait_status, + GError **error); + +GLIB_AVAILABLE_IN_ALL +void g_spawn_close_pid (GPid pid); + +G_END_DECLS + +#endif /* __G_SPAWN_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gstdio.h b/illumos-x86_64/usr/include/glib-2.0/glib/gstdio.h new file mode 100644 index 00000000..9fbc12d7 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gstdio.h @@ -0,0 +1,296 @@ +/* gstdio.h - GFilename wrappers for C library functions + * + * Copyright 2004 Tor Lillqvist + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_STDIO_H__ +#define __G_STDIO_H__ + +#include + +#include +#include + +G_BEGIN_DECLS + +#if (defined (__MINGW64_VERSION_MAJOR) || defined (_MSC_VER)) && !defined(_WIN64) + +/* Make it clear that we mean the struct with 32-bit st_size and + * 32-bit st_*time fields as that is how the 32-bit GLib DLL normally + * has been compiled. If you get a compiler warning when calling + * g_stat(), do take it seriously and make sure that the type of + * struct stat the code in GLib fills in matches the struct the type + * of struct stat you pass to g_stat(). To avoid hassle, to get file + * attributes just use the GIO API instead which doesn't use struct + * stat. + * + * Sure, it would be nicer to use a struct with 64-bit st_size and + * 64-bit st_*time fields, but changing that now would break ABI. And + * in MinGW, a plain "struct stat" is the one with 32-bit st_size and + * st_*time fields. + */ + +typedef struct _stat32 GStatBuf; + +#elif defined(__MINGW64_VERSION_MAJOR) && defined(_WIN64) + +typedef struct _stat64 GStatBuf; + +#else + +typedef struct stat GStatBuf; + +#endif + +#if defined(G_OS_UNIX) && !defined(G_STDIO_WRAP_ON_UNIX) && !defined(__GI_SCANNER__) + +/* Just pass on to the system functions, so there's no potential for data + * format mismatches, especially with large file interfaces. + * A few functions can't be handled in this way, since they are not defined + * in a portable system header that we could include here. + * + * G_STDIO_WRAP_ON_UNIX is not public API and its behaviour is not guaranteed + * in future. + */ + +#ifndef __GTK_DOC_IGNORE__ +#define g_chmod chmod +#define g_open open +#define g_creat creat +#define g_rename rename +#define g_mkdir mkdir +#define g_stat stat +#define g_lstat lstat +#define g_remove remove +#define g_fopen fopen +#define g_freopen freopen +#define g_fsync fsync +#define g_utime utime +#endif + +GLIB_AVAILABLE_IN_ALL +int g_access (const gchar *filename, + int mode); + +GLIB_AVAILABLE_IN_ALL +int g_chdir (const gchar *path); + +GLIB_AVAILABLE_IN_ALL +int g_unlink (const gchar *filename); + +GLIB_AVAILABLE_IN_ALL +int g_rmdir (const gchar *filename); + +#else /* ! G_OS_UNIX */ + +/* Wrappers for C library functions that take pathname arguments. On + * Unix, the pathname is a file name as it literally is in the file + * system. On well-maintained systems with consistent users who know + * what they are doing and no exchange of files with others this would + * be a well-defined encoding, preferably UTF-8. On Windows, the + * pathname is always in UTF-8, even if that is not the on-disk + * encoding, and not the encoding accepted by the C library or Win32 + * API. + */ + +GLIB_AVAILABLE_IN_ALL +int g_access (const gchar *filename, + int mode); + +GLIB_AVAILABLE_IN_ALL +int g_chmod (const gchar *filename, + int mode); + +GLIB_AVAILABLE_IN_ALL +int g_open (const gchar *filename, + int flags, + int mode); + +GLIB_AVAILABLE_IN_ALL +int g_creat (const gchar *filename, + int mode); + +GLIB_AVAILABLE_IN_ALL +int g_rename (const gchar *oldfilename, + const gchar *newfilename); + +GLIB_AVAILABLE_IN_ALL +int g_mkdir (const gchar *filename, + int mode); + +GLIB_AVAILABLE_IN_ALL +int g_chdir (const gchar *path); + +GLIB_AVAILABLE_IN_ALL +int g_stat (const gchar *filename, + GStatBuf *buf); + +GLIB_AVAILABLE_IN_ALL +int g_lstat (const gchar *filename, + GStatBuf *buf); + +GLIB_AVAILABLE_IN_ALL +int g_unlink (const gchar *filename); + +GLIB_AVAILABLE_IN_ALL +int g_remove (const gchar *filename); + +GLIB_AVAILABLE_IN_ALL +int g_rmdir (const gchar *filename); + +GLIB_AVAILABLE_IN_ALL +FILE *g_fopen (const gchar *filename, + const gchar *mode); + +GLIB_AVAILABLE_IN_ALL +FILE *g_freopen (const gchar *filename, + const gchar *mode, + FILE *stream); + +GLIB_AVAILABLE_IN_2_64 +gint g_fsync (gint fd); + +struct utimbuf; /* Don't need the real definition of struct utimbuf when just + * including this header. + */ + +GLIB_AVAILABLE_IN_ALL +int g_utime (const gchar *filename, + struct utimbuf *utb); + +#endif /* G_OS_UNIX */ + +GLIB_AVAILABLE_IN_2_36 +gboolean g_close (gint fd, + GError **error); + +/** + * g_clear_fd: (skip) + * @fd_ptr: (not optional) (inout) (transfer full): a pointer to a file descriptor + * @error: Used to return an error on failure + * + * If @fd_ptr points to a file descriptor, close it and return + * whether closing it was successful, like g_close(). + * If @fd_ptr points to a negative number, return %TRUE without closing + * anything. + * In both cases, set @fd_ptr to `-1` before returning. + * + * Like g_close(), if closing the file descriptor fails, the error is + * stored in both %errno and @error. If this function succeeds, + * %errno is undefined. + * + * On POSIX platforms, this function is async-signal safe + * if @error is %NULL and @fd_ptr points to either a negative number or a + * valid open file descriptor. + * This makes it safe to call from a signal handler or a #GSpawnChildSetupFunc + * under those conditions. + * See [`signal(7)`](man:signal(7)) and + * [`signal-safety(7)`](man:signal-safety(7)) for more details. + * + * It is a programming error for @fd_ptr to point to a non-negative + * number that is not a valid file descriptor. + * + * A typical use of this function is to clean up a file descriptor at + * the end of its scope, whether it has been set successfully or not: + * + * |[ + * gboolean + * operate_on_fd (GError **error) + * { + * gboolean ret = FALSE; + * int fd = -1; + * + * fd = open_a_fd (error); + * + * if (fd < 0) + * goto out; + * + * if (!do_something (fd, error)) + * goto out; + * + * if (!g_clear_fd (&fd, error)) + * goto out; + * + * ret = TRUE; + * + * out: + * // OK to call even if fd was never opened or was already closed + * g_clear_fd (&fd, NULL); + * return ret; + * } + * ]| + * + * This function is also useful in conjunction with #g_autofd. + * + * Returns: %TRUE on success + * Since: 2.76 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 +static inline gboolean g_clear_fd (int *fd_ptr, + GError **error); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 +static inline gboolean +g_clear_fd (int *fd_ptr, + GError **error) +{ + int fd = *fd_ptr; + + *fd_ptr = -1; + + if (fd < 0) + return TRUE; + + /* Suppress "Not available before" warning */ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + return g_close (fd, error); + G_GNUC_END_IGNORE_DEPRECATIONS +} + +/* g_autofd should be defined on the same compilers where g_autofree is + * This avoids duplicating the feature-detection here. */ +#ifdef g_autofree +#ifndef __GTK_DOC_IGNORE__ +/* Not public API */ +static inline void +_g_clear_fd_ignore_error (int *fd_ptr) +{ + /* Don't overwrite thread-local errno if closing the fd fails */ + int errsv = errno; + + /* Suppress "Not available before" warning */ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + + if (!g_clear_fd (fd_ptr, NULL)) + { + /* Do nothing: we ignore all errors, except for EBADF which + * is a programming error, checked for by g_close(). */ + } + + G_GNUC_END_IGNORE_DEPRECATIONS + + errno = errsv; +} +#endif + +#define g_autofd _GLIB_CLEANUP(_g_clear_fd_ignore_error) GLIB_AVAILABLE_MACRO_IN_2_76 +#endif + +G_END_DECLS + +#endif /* __G_STDIO_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gstrfuncs.h b/illumos-x86_64/usr/include/glib-2.0/glib/gstrfuncs.h new file mode 100644 index 00000000..102aa38b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gstrfuncs.h @@ -0,0 +1,502 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_STRFUNCS_H__ +#define __G_STRFUNCS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +#include +#include +#include +#include + +G_BEGIN_DECLS + +/* Functions like the ones in that are not affected by locale. */ +typedef enum { + G_ASCII_ALNUM = 1 << 0, + G_ASCII_ALPHA = 1 << 1, + G_ASCII_CNTRL = 1 << 2, + G_ASCII_DIGIT = 1 << 3, + G_ASCII_GRAPH = 1 << 4, + G_ASCII_LOWER = 1 << 5, + G_ASCII_PRINT = 1 << 6, + G_ASCII_PUNCT = 1 << 7, + G_ASCII_SPACE = 1 << 8, + G_ASCII_UPPER = 1 << 9, + G_ASCII_XDIGIT = 1 << 10 +} GAsciiType; + +GLIB_VAR const guint16 * const g_ascii_table; + +#define g_ascii_isalnum(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_ALNUM) != 0) + +#define g_ascii_isalpha(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_ALPHA) != 0) + +#define g_ascii_iscntrl(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_CNTRL) != 0) + +#define g_ascii_isdigit(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_DIGIT) != 0) + +#define g_ascii_isgraph(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_GRAPH) != 0) + +#define g_ascii_islower(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_LOWER) != 0) + +#define g_ascii_isprint(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_PRINT) != 0) + +#define g_ascii_ispunct(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_PUNCT) != 0) + +#define g_ascii_isspace(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_SPACE) != 0) + +#define g_ascii_isupper(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_UPPER) != 0) + +#define g_ascii_isxdigit(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_XDIGIT) != 0) + +GLIB_AVAILABLE_IN_ALL +gchar g_ascii_tolower (gchar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gchar g_ascii_toupper (gchar c) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +gint g_ascii_digit_value (gchar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gint g_ascii_xdigit_value (gchar c) G_GNUC_CONST; + +/* String utility functions that modify a string argument or + * return a constant string that must not be freed. + */ +#define G_STR_DELIMITERS "_-|> <." +GLIB_AVAILABLE_IN_ALL +gchar* g_strdelimit (gchar *string, + const gchar *delimiters, + gchar new_delimiter); +GLIB_AVAILABLE_IN_ALL +gchar* g_strcanon (gchar *string, + const gchar *valid_chars, + gchar substitutor); +GLIB_AVAILABLE_IN_ALL +const gchar * g_strerror (gint errnum) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +const gchar * g_strsignal (gint signum) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gchar * g_strreverse (gchar *string); +GLIB_AVAILABLE_IN_ALL +gsize g_strlcpy (gchar *dest, + const gchar *src, + gsize dest_size); +GLIB_AVAILABLE_IN_ALL +gsize g_strlcat (gchar *dest, + const gchar *src, + gsize dest_size); +GLIB_AVAILABLE_IN_ALL +gchar * g_strstr_len (const gchar *haystack, + gssize haystack_len, + const gchar *needle); +GLIB_AVAILABLE_IN_ALL +gchar * g_strrstr (const gchar *haystack, + const gchar *needle); +GLIB_AVAILABLE_IN_ALL +gchar * g_strrstr_len (const gchar *haystack, + gssize haystack_len, + const gchar *needle); + +GLIB_AVAILABLE_IN_ALL +gboolean (g_str_has_suffix) (const gchar *str, + const gchar *suffix); +GLIB_AVAILABLE_IN_ALL +gboolean (g_str_has_prefix) (const gchar *str, + const gchar *prefix); + +#if G_GNUC_CHECK_VERSION (2, 0) +#ifndef __GTK_DOC_IGNORE__ +#ifndef __GI_SCANNER__ + +/* This macro is defeat a false -Wnonnull warning in GCC. + * Without it, it thinks strlen and memcmp may be getting passed NULL + * despite the explicit check for NULL right above the calls. + */ +#define _G_STR_NONNULL(x) ((x) + !(x)) + +#define g_str_has_prefix(STR, PREFIX) \ + (__builtin_constant_p (PREFIX)? \ + G_GNUC_EXTENSION ({ \ + const char * const __str = (STR); \ + const char * const __prefix = (PREFIX); \ + gboolean __result = FALSE; \ + \ + if G_UNLIKELY (__str == NULL || __prefix == NULL) \ + __result = (g_str_has_prefix) (__str, __prefix); \ + else \ + { \ + const size_t __str_len = strlen (_G_STR_NONNULL (__str)); \ + const size_t __prefix_len = strlen (_G_STR_NONNULL (__prefix)); \ + if (__str_len >= __prefix_len) \ + __result = memcmp (_G_STR_NONNULL (__str), \ + _G_STR_NONNULL (__prefix), \ + __prefix_len) == 0; \ + } \ + __result; \ + }) \ + : \ + (g_str_has_prefix) (STR, PREFIX) \ + ) + +#define g_str_has_suffix(STR, SUFFIX) \ + (__builtin_constant_p (SUFFIX)? \ + G_GNUC_EXTENSION ({ \ + const char * const __str = (STR); \ + const char * const __suffix = (SUFFIX); \ + gboolean __result = FALSE; \ + \ + if G_UNLIKELY (__str == NULL || __suffix == NULL) \ + __result = (g_str_has_suffix) (__str, __suffix); \ + else \ + { \ + const size_t __str_len = strlen (_G_STR_NONNULL (__str)); \ + const size_t __suffix_len = strlen (_G_STR_NONNULL (__suffix)); \ + if (__str_len >= __suffix_len) \ + __result = memcmp (__str + __str_len - __suffix_len, \ + _G_STR_NONNULL (__suffix), \ + __suffix_len) == 0; \ + } \ + __result; \ + }) \ + : \ + (g_str_has_suffix) (STR, SUFFIX) \ + ) + +#endif /* !defined (__GI_SCANNER__) */ +#endif /* !defined (__GTK_DOC_IGNORE__) */ +#endif /* G_GNUC_CHECK_VERSION (2, 0) */ + +/* String to/from double conversion functions */ + +GLIB_AVAILABLE_IN_ALL +gdouble g_strtod (const gchar *nptr, + gchar **endptr); +GLIB_AVAILABLE_IN_ALL +gdouble g_ascii_strtod (const gchar *nptr, + gchar **endptr); +GLIB_AVAILABLE_IN_ALL +guint64 g_ascii_strtoull (const gchar *nptr, + gchar **endptr, + guint base); +GLIB_AVAILABLE_IN_ALL +gint64 g_ascii_strtoll (const gchar *nptr, + gchar **endptr, + guint base); +/* 29 bytes should enough for all possible values that + * g_ascii_dtostr can produce. + * Then add 10 for good measure */ +#define G_ASCII_DTOSTR_BUF_SIZE (29 + 10) +GLIB_AVAILABLE_IN_ALL +gchar * g_ascii_dtostr (gchar *buffer, + gint buf_len, + gdouble d); +GLIB_AVAILABLE_IN_ALL +gchar * g_ascii_formatd (gchar *buffer, + gint buf_len, + const gchar *format, + gdouble d); + +/* removes leading spaces */ +GLIB_AVAILABLE_IN_ALL +gchar* g_strchug (gchar *string); +/* removes trailing spaces */ +GLIB_AVAILABLE_IN_ALL +gchar* g_strchomp (gchar *string); +/* removes leading & trailing spaces */ +#define g_strstrip( string ) g_strchomp (g_strchug (string)) + +GLIB_AVAILABLE_IN_ALL +gint g_ascii_strcasecmp (const gchar *s1, + const gchar *s2); +GLIB_AVAILABLE_IN_ALL +gint g_ascii_strncasecmp (const gchar *s1, + const gchar *s2, + gsize n); +GLIB_AVAILABLE_IN_ALL +gchar* g_ascii_strdown (const gchar *str, + gssize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_ascii_strup (const gchar *str, + gssize len) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_2_40 +gboolean g_str_is_ascii (const gchar *str); + +GLIB_DEPRECATED +gint g_strcasecmp (const gchar *s1, + const gchar *s2); +GLIB_DEPRECATED +gint g_strncasecmp (const gchar *s1, + const gchar *s2, + guint n); +GLIB_DEPRECATED +gchar* g_strdown (gchar *string); +GLIB_DEPRECATED +gchar* g_strup (gchar *string); + + +/* String utility functions that return a newly allocated string which + * ought to be freed with g_free from the caller at some point. + */ +GLIB_AVAILABLE_IN_ALL +gchar* (g_strdup) (const gchar *str) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strdup_printf (const gchar *format, + ...) G_GNUC_PRINTF (1, 2) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strdup_vprintf (const gchar *format, + va_list args) G_GNUC_PRINTF(1, 0) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strndup (const gchar *str, + gsize n) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strnfill (gsize length, + gchar fill_char) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strconcat (const gchar *string1, + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +gchar* g_strjoin (const gchar *separator, + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; + +#if G_GNUC_CHECK_VERSION(2, 0) +#ifndef __GTK_DOC_IGNORE__ +#ifndef __GI_SCANNER__ + +G_ALWAYS_INLINE static inline char * +g_strdup_inline (const char *str) +{ + if (__builtin_constant_p (!str) && !str) + return NULL; + + if (__builtin_constant_p (!!str) && !!str && __builtin_constant_p (strlen (str))) + { + const size_t len = strlen (str) + 1; + char *dup_str = (char *) g_malloc (len); + return (char *) memcpy (dup_str, str, len); + } + + return g_strdup (str); +} + +#define g_strdup(x) g_strdup_inline (x) + +#endif /* !defined (__GI_SCANNER__) */ +#endif /* !defined (__GTK_DOC_IGNORE__) */ +#endif /* G_GNUC_CHECK_VERSION (2, 0) */ + +GLIB_AVAILABLE_IN_ALL +gchar* g_strcompress (const gchar *source) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar* g_strescape (const gchar *source, + const gchar *exceptions) G_GNUC_MALLOC; + +GLIB_DEPRECATED_IN_2_68_FOR (g_memdup2) +gpointer g_memdup (gconstpointer mem, + guint byte_size) G_GNUC_ALLOC_SIZE(2); + +GLIB_AVAILABLE_IN_2_68 +gpointer g_memdup2 (gconstpointer mem, + gsize byte_size) G_GNUC_ALLOC_SIZE(2); + +/* NULL terminated string arrays. + * g_strsplit(), g_strsplit_set() split up string into max_tokens tokens + * at delim and return a newly allocated string array. + * g_strjoinv() concatenates all of str_array's strings, sliding in an + * optional separator, the returned string is newly allocated. + * g_strfreev() frees the array itself and all of its strings. + * g_strdupv() copies a NULL-terminated array of strings + * g_strv_length() returns the length of a NULL-terminated array of strings + */ +typedef gchar** GStrv; +GLIB_AVAILABLE_IN_ALL +gchar** g_strsplit (const gchar *string, + const gchar *delimiter, + gint max_tokens); +GLIB_AVAILABLE_IN_ALL +gchar ** g_strsplit_set (const gchar *string, + const gchar *delimiters, + gint max_tokens); +GLIB_AVAILABLE_IN_ALL +gchar* g_strjoinv (const gchar *separator, + gchar **str_array) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_strfreev (gchar **str_array); +GLIB_AVAILABLE_IN_ALL +gchar** g_strdupv (gchar **str_array); +GLIB_AVAILABLE_IN_ALL +guint g_strv_length (gchar **str_array); + +GLIB_AVAILABLE_IN_ALL +gchar* g_stpcpy (gchar *dest, + const char *src); + +GLIB_AVAILABLE_IN_2_40 +gchar * g_str_to_ascii (const gchar *str, + const gchar *from_locale); + +GLIB_AVAILABLE_IN_2_40 +gchar ** g_str_tokenize_and_fold (const gchar *string, + const gchar *translit_locale, + gchar ***ascii_alternates); + +GLIB_AVAILABLE_IN_2_40 +gboolean g_str_match_string (const gchar *search_term, + const gchar *potential_hit, + gboolean accept_alternates); + +GLIB_AVAILABLE_IN_2_44 +gboolean g_strv_contains (const gchar * const *strv, + const gchar *str); + +GLIB_AVAILABLE_IN_2_60 +gboolean g_strv_equal (const gchar * const *strv1, + const gchar * const *strv2); + +/* Convenience ASCII string to number API */ + +/** + * GNumberParserError: + * @G_NUMBER_PARSER_ERROR_INVALID: string was not a valid number + * @G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS: string was a number, but out of bounds + * + * Error codes returned by functions converting a string to a number. + * + * Since: 2.54 + */ +typedef enum + { + G_NUMBER_PARSER_ERROR_INVALID, + G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS, + } GNumberParserError; + +/** + * G_NUMBER_PARSER_ERROR: + * + * Domain for errors returned by functions converting a string to a + * number. + * + * Since: 2.54 + */ +#define G_NUMBER_PARSER_ERROR (g_number_parser_error_quark ()) + +GLIB_AVAILABLE_IN_2_54 +GQuark g_number_parser_error_quark (void); + +GLIB_AVAILABLE_IN_2_54 +gboolean g_ascii_string_to_signed (const gchar *str, + guint base, + gint64 min, + gint64 max, + gint64 *out_num, + GError **error); + +GLIB_AVAILABLE_IN_2_54 +gboolean g_ascii_string_to_unsigned (const gchar *str, + guint base, + guint64 min, + guint64 max, + guint64 *out_num, + GError **error); + +/** + * g_set_str: (skip) + * @str_pointer: (inout) (not optional) (nullable): a pointer to either + * a string or `NULL` + * @new_str: (nullable): a string to assign to @str_pointer + * + * Updates a pointer to a string to a copy of @new_str and returns whether the + * string was changed. + * + * If @new_str matches the previous string, this function is a no-op. If + * @new_str is different, a copy of it will be assigned to @str_pointer and + * the previous string pointed to by @str_pointer will be freed with + * [func@GLib.free]. + * + * @str_pointer must not be `NULL`, but can point to a `NULL` value. + * + * One convenient usage of this function is in implementing property settings: + * ```C + * void + * foo_set_bar (Foo *foo, + * const char *new_bar) + * { + * g_return_if_fail (IS_FOO (foo)); + * + * if (g_set_str (&foo->bar, new_bar)) + * g_object_notify (foo, "bar"); + * } + * ``` + * + * Returns: true if the value of @str_pointer changed, false otherwise + * + * Since: 2.76 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 +static inline gboolean g_set_str (char **str_pointer, + const char *new_str); + +GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 +static inline gboolean +g_set_str (char **str_pointer, + const char *new_str) +{ + char *copy; + + if (*str_pointer == new_str || + (*str_pointer && new_str && strcmp (*str_pointer, new_str) == 0)) + return FALSE; + + copy = g_strdup (new_str); + g_free (*str_pointer); + *str_pointer = copy; + + return TRUE; +} + +G_END_DECLS + +#endif /* __G_STRFUNCS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gstring.h b/illumos-x86_64/usr/include/glib-2.0/glib/gstring.h new file mode 100644 index 00000000..3e66367a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gstring.h @@ -0,0 +1,300 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_STRING_H__ +#define __G_STRING_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include +#include +#include /* for G_CAN_INLINE */ +#include + +G_BEGIN_DECLS + +typedef struct _GString GString; + +struct _GString +{ + gchar *str; + gsize len; + gsize allocated_len; +}; + +GLIB_AVAILABLE_IN_ALL +GString* g_string_new (const gchar *init); +GLIB_AVAILABLE_IN_2_78 +GString* g_string_new_take (gchar *init); +GLIB_AVAILABLE_IN_ALL +GString* g_string_new_len (const gchar *init, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_sized_new (gsize dfl_size); +GLIB_AVAILABLE_IN_ALL +gchar* (g_string_free) (GString *string, + gboolean free_segment); +GLIB_AVAILABLE_IN_2_76 +gchar* g_string_free_and_steal (GString *string) G_GNUC_WARN_UNUSED_RESULT; + +#if G_GNUC_CHECK_VERSION (2, 0) && (GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76) + +#if !defined(__cplusplus) || !G_GNUC_CHECK_VERSION (6, 1) || G_GNUC_CHECK_VERSION (7, 3) + +#define g_string_free(str, free_segment) \ + (__builtin_constant_p (free_segment) ? \ + ((free_segment) ? \ + (g_string_free) ((str), (free_segment)) : \ + g_string_free_and_steal (str)) \ + : \ + (g_string_free) ((str), (free_segment))) + +#endif /* !defined(__cplusplus) || !G_GNUC_CHECK_VERSION (6, 1) || G_GNUC_CHECK_VERSION (7, 3) */ + +#endif /* G_GNUC_CHECK_VERSION (2, 0) && (GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76) */ + +GLIB_AVAILABLE_IN_2_34 +GBytes* g_string_free_to_bytes (GString *string); +GLIB_AVAILABLE_IN_ALL +gboolean g_string_equal (const GString *v, + const GString *v2); +GLIB_AVAILABLE_IN_ALL +guint g_string_hash (const GString *str); +GLIB_AVAILABLE_IN_ALL +GString* g_string_assign (GString *string, + const gchar *rval); +GLIB_AVAILABLE_IN_ALL +GString* g_string_truncate (GString *string, + gsize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_set_size (GString *string, + gsize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_insert_len (GString *string, + gssize pos, + const gchar *val, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append (GString *string, + const gchar *val); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append_len (GString *string, + const gchar *val, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append_c (GString *string, + gchar c); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append_unichar (GString *string, + gunichar wc); +GLIB_AVAILABLE_IN_ALL +GString* g_string_prepend (GString *string, + const gchar *val); +GLIB_AVAILABLE_IN_ALL +GString* g_string_prepend_c (GString *string, + gchar c); +GLIB_AVAILABLE_IN_ALL +GString* g_string_prepend_unichar (GString *string, + gunichar wc); +GLIB_AVAILABLE_IN_ALL +GString* g_string_prepend_len (GString *string, + const gchar *val, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_insert (GString *string, + gssize pos, + const gchar *val); +GLIB_AVAILABLE_IN_ALL +GString* g_string_insert_c (GString *string, + gssize pos, + gchar c); +GLIB_AVAILABLE_IN_ALL +GString* g_string_insert_unichar (GString *string, + gssize pos, + gunichar wc); +GLIB_AVAILABLE_IN_ALL +GString* g_string_overwrite (GString *string, + gsize pos, + const gchar *val); +GLIB_AVAILABLE_IN_ALL +GString* g_string_overwrite_len (GString *string, + gsize pos, + const gchar *val, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_erase (GString *string, + gssize pos, + gssize len); +GLIB_AVAILABLE_IN_2_68 +guint g_string_replace (GString *string, + const gchar *find, + const gchar *replace, + guint limit); +GLIB_AVAILABLE_IN_ALL +GString* g_string_ascii_down (GString *string); +GLIB_AVAILABLE_IN_ALL +GString* g_string_ascii_up (GString *string); +GLIB_AVAILABLE_IN_ALL +void g_string_vprintf (GString *string, + const gchar *format, + va_list args) + G_GNUC_PRINTF(2, 0); +GLIB_AVAILABLE_IN_ALL +void g_string_printf (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); +GLIB_AVAILABLE_IN_ALL +void g_string_append_vprintf (GString *string, + const gchar *format, + va_list args) + G_GNUC_PRINTF(2, 0); +GLIB_AVAILABLE_IN_ALL +void g_string_append_printf (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append_uri_escaped (GString *string, + const gchar *unescaped, + const gchar *reserved_chars_allowed, + gboolean allow_utf8); + +#ifdef G_CAN_INLINE + +#if defined (_MSC_VER) && !defined (__clang__) +#pragma warning (push) +#pragma warning (disable : 4141) /* silence "warning C4141: 'inline' used more than once" */ +#endif + +#ifndef __GTK_DOC_IGNORE__ + +G_ALWAYS_INLINE +static inline GString* +g_string_append_c_inline (GString *gstring, + gchar c) +{ + if (G_LIKELY (gstring != NULL && + gstring->len + 1 < gstring->allocated_len)) + { + gstring->str[gstring->len++] = c; + gstring->str[gstring->len] = 0; + } + else + g_string_insert_c (gstring, -1, c); + return gstring; +} + +#define g_string_append_c(gstr,c) \ + g_string_append_c_inline (gstr, c) + +G_ALWAYS_INLINE +static inline GString * +g_string_append_len_inline (GString *gstring, + const char *val, + gssize len) +{ + gsize len_unsigned; + + if G_UNLIKELY (gstring == NULL) + return g_string_append_len (gstring, val, len); + + if G_UNLIKELY (val == NULL) + return (len != 0) ? g_string_append_len (gstring, val, len) : gstring; + + if (len < 0) + len_unsigned = strlen (val); + else + len_unsigned = (gsize) len; + + if (G_LIKELY (gstring->len + len_unsigned < gstring->allocated_len)) + { + char *end = gstring->str + gstring->len; + if (G_LIKELY (val + len_unsigned <= end || val > end + len_unsigned)) + memcpy (end, val, len_unsigned); + else + memmove (end, val, len_unsigned); + gstring->len += len_unsigned; + gstring->str[gstring->len] = 0; + return gstring; + } + else + return g_string_insert_len (gstring, -1, val, len); +} + +#define g_string_append_len(gstr, val, len) \ + g_string_append_len_inline (gstr, val, len) + +G_ALWAYS_INLINE +static inline GString * +g_string_truncate_inline (GString *gstring, + gsize len) +{ + gstring->len = MIN (len, gstring->len); + gstring->str[gstring->len] = '\0'; + return gstring; +} + +#define g_string_truncate(gstr, len) \ + g_string_truncate_inline (gstr, len) + +#if G_GNUC_CHECK_VERSION (2, 0) + +#define g_string_append(gstr, val) \ + (__builtin_constant_p (val) ? \ + G_GNUC_EXTENSION ({ \ + const char * const __val = (val); \ + g_string_append_len (gstr, __val, \ + G_LIKELY (__val != NULL) ? \ + (gssize) strlen (_G_STR_NONNULL (__val)) \ + : (gssize) -1); \ + }) \ + : \ + g_string_append_len (gstr, val, (gssize) -1)) + +#endif /* G_GNUC_CHECK_VERSION (2, 0) */ + +#endif /* __GTK_DOC_IGNORE__ */ + +#if defined (_MSC_VER) && !defined (__clang__) +#pragma warning (pop) /* #pragma warning (disable : 4141) */ +#endif + +#endif /* G_CAN_INLINE */ + +GLIB_DEPRECATED +GString *g_string_down (GString *string); +GLIB_DEPRECATED +GString *g_string_up (GString *string); + +#define g_string_sprintf g_string_printf GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_string_printf) +#define g_string_sprintfa g_string_append_printf GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_string_append_printf) + +G_END_DECLS + +#endif /* __G_STRING_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gstringchunk.h b/illumos-x86_64/usr/include/glib-2.0/glib/gstringchunk.h new file mode 100644 index 00000000..a79a4cb0 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gstringchunk.h @@ -0,0 +1,59 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_STRINGCHUNK_H__ +#define __G_STRINGCHUNK_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GStringChunk GStringChunk; + +GLIB_AVAILABLE_IN_ALL +GStringChunk* g_string_chunk_new (gsize size); +GLIB_AVAILABLE_IN_ALL +void g_string_chunk_free (GStringChunk *chunk); +GLIB_AVAILABLE_IN_ALL +void g_string_chunk_clear (GStringChunk *chunk); +GLIB_AVAILABLE_IN_ALL +gchar* g_string_chunk_insert (GStringChunk *chunk, + const gchar *string); +GLIB_AVAILABLE_IN_ALL +gchar* g_string_chunk_insert_len (GStringChunk *chunk, + const gchar *string, + gssize len); +GLIB_AVAILABLE_IN_ALL +gchar* g_string_chunk_insert_const (GStringChunk *chunk, + const gchar *string); + +G_END_DECLS + +#endif /* __G_STRING_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gstrvbuilder.h b/illumos-x86_64/usr/include/glib-2.0/glib/gstrvbuilder.h new file mode 100644 index 00000000..276ab37b --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gstrvbuilder.h @@ -0,0 +1,68 @@ +/* + * Copyright © 2020 Canonical Ltd. + * Copyright © 2021 Alexandros Theodotou + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_STRVBUILDER_H__ +#define __G_STRVBUILDER_H__ + +#if !defined(__GLIB_H_INSIDE__) && !defined(GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GStrvBuilder GStrvBuilder; + +GLIB_AVAILABLE_IN_2_68 +GStrvBuilder *g_strv_builder_new (void); + +GLIB_AVAILABLE_IN_2_68 +void g_strv_builder_unref (GStrvBuilder *builder); + +GLIB_AVAILABLE_IN_2_82 +GStrv g_strv_builder_unref_to_strv (GStrvBuilder *builder); + +GLIB_AVAILABLE_IN_2_68 +GStrvBuilder *g_strv_builder_ref (GStrvBuilder *builder); + +GLIB_AVAILABLE_IN_2_68 +void g_strv_builder_add (GStrvBuilder *builder, + const char *value); + +GLIB_AVAILABLE_IN_2_70 +void g_strv_builder_addv (GStrvBuilder *builder, + const char **value); + +GLIB_AVAILABLE_IN_2_70 +void g_strv_builder_add_many (GStrvBuilder *builder, + ...) G_GNUC_NULL_TERMINATED; + +GLIB_AVAILABLE_IN_2_80 +void g_strv_builder_take (GStrvBuilder *builder, + char *value); + +GLIB_AVAILABLE_IN_2_68 +GStrv g_strv_builder_end (GStrvBuilder *builder); + +G_END_DECLS + +#endif /* __G_STRVBUILDER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gtestutils.h b/illumos-x86_64/usr/include/glib-2.0/glib/gtestutils.h new file mode 100644 index 00000000..5ea26365 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gtestutils.h @@ -0,0 +1,800 @@ +/* GLib testing utilities + * Copyright (C) 2007 Imendio AB + * Authors: Tim Janik + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_TEST_UTILS_H__ +#define __G_TEST_UTILS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include +#include +#include +#include +#include + +G_BEGIN_DECLS + +typedef struct GTestCase GTestCase; +typedef struct GTestSuite GTestSuite; +typedef void (*GTestFunc) (void); +typedef void (*GTestDataFunc) (gconstpointer user_data); +typedef void (*GTestFixtureFunc) (gpointer fixture, + gconstpointer user_data); + +/* assertion API */ +#define g_assert_cmpstr(s1, cmp, s2) G_STMT_START { \ + const char *__s1 = (s1), *__s2 = (s2); \ + if (g_strcmp0 (__s1, __s2) cmp 0) ; else \ + g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #s1 " " #cmp " " #s2, __s1, #cmp, __s2); \ + } G_STMT_END +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 +#define g_assert_cmpint(n1, cmp, n2) G_STMT_START { \ + gint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpint (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (guint64)__n1, #cmp, (guint64)__n2, 'i'); \ + } G_STMT_END +#define g_assert_cmpuint(n1, cmp, n2) G_STMT_START { \ + guint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpint (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'u'); \ + } G_STMT_END +#define g_assert_cmphex(n1, cmp, n2) G_STMT_START { \ + guint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpint (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'x'); \ + } G_STMT_END +#else /* GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_78 */ +#define g_assert_cmpint(n1, cmp, n2) G_STMT_START { \ + gint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'i'); \ + } G_STMT_END +#define g_assert_cmpuint(n1, cmp, n2) G_STMT_START { \ + guint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'i'); \ + } G_STMT_END +#define g_assert_cmphex(n1, cmp, n2) G_STMT_START {\ + guint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'x'); \ + } G_STMT_END +#endif /* GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 */ +#define g_assert_cmpfloat(n1,cmp,n2) G_STMT_START { \ + long double __n1 = (long double) (n1), __n2 = (long double) (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'f'); \ + } G_STMT_END +#define g_assert_cmpfloat_with_epsilon(n1,n2,epsilon) \ + G_STMT_START { \ + double __n1 = (n1), __n2 = (n2), __epsilon = (epsilon); \ + if (G_APPROX_VALUE (__n1, __n2, __epsilon)) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " == " #n2 " (+/- " #epsilon ")", __n1, "==", __n2, 'f'); \ + } G_STMT_END +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 +#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\ + gconstpointer __m1 = m1, __m2 = m2; \ + size_t __l1 = (size_t) l1, __l2 = (size_t) l2; \ + if (__l1 != 0 && __m1 == NULL) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #l1 " == 0 || " #m1 " != NULL)"); \ + else if (__l2 != 0 && __m2 == NULL) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #l2 " == 0 || " #m2 " != NULL)"); \ + else if (__l1 != __l2) \ + g_assertion_message_cmpint (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", \ + __l1, "==", __l2, 'u'); \ + else if (__l1 != 0 && __m2 != NULL && memcmp (__m1, __m2, __l1) != 0) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #m1 " == " #m2 ")"); \ + } G_STMT_END +#else /* GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_78 */ +#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\ + gconstpointer __m1 = m1, __m2 = m2; \ + size_t __l1 = (size_t) l1, __l2 = (size_t) l2; \ + if (__l1 != 0 && __m1 == NULL) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #l1 " == 0 || " #m1 " != NULL)"); \ + else if (__l2 != 0 && __m2 == NULL) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #l2 " == 0 || " #m2 " != NULL)"); \ + else if (__l1 != __l2) \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", \ + (long double) __l1, "==", (long double) __l2, 'i'); \ + else if (__l1 != 0 && __m2 != NULL && memcmp (__m1, __m2, __l1) != 0) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #m1 " == " #m2 ")"); \ + } G_STMT_END +#endif /* GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 */ +#define g_assert_cmpvariant(v1, v2) \ + G_STMT_START \ + { \ + GVariant *__v1 = (v1), *__v2 = (v2); \ + if (!g_variant_equal (__v1, __v2)) \ + { \ + gchar *__s1, *__s2, *__msg; \ + __s1 = g_variant_print (__v1, TRUE); \ + __s2 = g_variant_print (__v2, TRUE); \ + __msg = g_strdup_printf ("assertion failed (" #v1 " == " #v2 "): %s does not equal %s", __s1, __s2); \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ + g_free (__s1); \ + g_free (__s2); \ + g_free (__msg); \ + } \ + } \ + G_STMT_END +#define g_assert_cmpstrv(strv1, strv2) \ + G_STMT_START \ + { \ + const char * const *__strv1 = (const char * const *) (strv1); \ + const char * const *__strv2 = (const char * const *) (strv2); \ + if (!__strv1 || !__strv2) \ + { \ + if (__strv1) \ + { \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #strv1 " == " #strv2 "): " #strv2 " is NULL, but " #strv1 " is not"); \ + } \ + else if (__strv2) \ + { \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #strv1 " == " #strv2 "): " #strv1 " is NULL, but " #strv2 " is not"); \ + } \ + } \ + else \ + { \ + guint __l1 = g_strv_length ((char **) __strv1); \ + guint __l2 = g_strv_length ((char **) __strv2); \ + if (__l1 != __l2) \ + { \ + char *__msg; \ + __msg = g_strdup_printf ("assertion failed (" #strv1 " == " #strv2 "): length %u does not equal length %u", __l1, __l2); \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ + g_free (__msg); \ + } \ + else \ + { \ + guint __i; \ + for (__i = 0; __i < __l1; __i++) \ + { \ + if (g_strcmp0 (__strv1[__i], __strv2[__i]) != 0) \ + { \ + g_assertion_message_cmpstrv (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #strv1 " == " #strv2, \ + __strv1, __strv2, __i); \ + } \ + } \ + } \ + } \ + } \ + G_STMT_END +#define g_assert_no_errno(expr) G_STMT_START { \ + int __ret, __errsv; \ + errno = 0; \ + __ret = expr; \ + __errsv = errno; \ + if (__ret < 0) \ + { \ + gchar *__msg; \ + __msg = g_strdup_printf ("assertion failed (" #expr " >= 0): errno %i: %s", __errsv, g_strerror (__errsv)); \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ + g_free (__msg); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_66 +#define g_assert_no_error(err) G_STMT_START { \ + if (err) \ + g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #err, err, 0, 0); \ + } G_STMT_END +#define g_assert_error(err, dom, c) G_STMT_START { \ + if (!err || (err)->domain != dom || (err)->code != c) \ + g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #err, err, dom, c); \ + } G_STMT_END +#define g_assert_true(expr) G_STMT_START { \ + if G_LIKELY (expr) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should be TRUE"); \ + } G_STMT_END +#define g_assert_false(expr) G_STMT_START { \ + if G_LIKELY (!(expr)) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should be FALSE"); \ + } G_STMT_END + +/* Use nullptr in C++ to catch misuse of these macros. */ +#if G_CXX_STD_CHECK_VERSION (11) +#define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == nullptr) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should be nullptr"); \ + } G_STMT_END +#define g_assert_nonnull(expr) G_STMT_START { \ + if G_LIKELY ((expr) != nullptr) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should not be nullptr"); \ + } G_STMT_END +#else /* not C++ */ +#define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == NULL) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should be NULL"); \ + } G_STMT_END +#define g_assert_nonnull(expr) G_STMT_START { \ + if G_LIKELY ((expr) != NULL) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should not be NULL"); \ + } G_STMT_END +#endif + +#ifdef G_DISABLE_ASSERT +/* https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005funreachable + * GCC 5 is not a strict lower bound for versions of GCC which provide __builtin_unreachable(). */ +#if __GNUC__ >= 5 || g_macro__has_builtin(__builtin_unreachable) +#define g_assert_not_reached() G_STMT_START { (void) 0; __builtin_unreachable (); } G_STMT_END +#elif defined (_MSC_VER) +#define g_assert_not_reached() G_STMT_START { (void) 0; __assume (0); } G_STMT_END +#else /* if __builtin_unreachable() is not supported: */ +#define g_assert_not_reached() G_STMT_START { (void) 0; } G_STMT_END +#endif + +#define g_assert(expr) G_STMT_START { (void) 0; } G_STMT_END +#else /* !G_DISABLE_ASSERT */ +#define g_assert_not_reached() G_STMT_START { g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } G_STMT_END +#define g_assert(expr) G_STMT_START { \ + if G_LIKELY (expr) ; else \ + g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #expr); \ + } G_STMT_END +#endif /* !G_DISABLE_ASSERT */ + +GLIB_AVAILABLE_IN_ALL +int g_strcmp0 (const char *str1, + const char *str2); + +/* report performance results */ +GLIB_AVAILABLE_IN_ALL +void g_test_minimized_result (double minimized_quantity, + const char *format, + ...) G_GNUC_PRINTF (2, 3); +GLIB_AVAILABLE_IN_ALL +void g_test_maximized_result (double maximized_quantity, + const char *format, + ...) G_GNUC_PRINTF (2, 3); + +/* initialize testing framework */ +GLIB_AVAILABLE_IN_ALL +void g_test_init (int *argc, + char ***argv, + ...) G_GNUC_NULL_TERMINATED; + +/** + * G_TEST_OPTION_ISOLATE_DIRS: + * + * A value that can be passed as an option to [func@GLib.test_init]. + * + * Creates a unique temporary directory for each unit test and uses sets + * XDG directories to point into subdirectories of it for the duration of + * the unit test. The directory tree is cleaned up after the test finishes + * successfully. + * + * Note that this doesn’t take effect until [func@GLib.test_run] is called, + * so calls to (for example) [func@GLib.get_home_dir] will return the + * system-wide value when made in a test program’s main() function. + * + * The following functions will return subdirectories of the temporary directory + * when this option is used. The specific subdirectory paths in use are not + * guaranteed to be stable API — always use a getter function to retrieve them. + * + * - [func@GLib.get_home_dir] + * - [func@GLib.get_user_cache_dir] + * - [func@GLib.get_system_config_dirs] + * - [func@GLib.get_user_config_dir] + * - [func@GLib.get_system_data_dirs] + * - [func@GLib.get_user_data_dir] + * - [func@GLib.get_user_state_dir] + * - [func@GLib.get_user_runtime_dir] + * + * The subdirectories may not be created by the test harness; as with normal + * calls to functions like [func@GLib.get_user_cache_dir], the caller must + * be prepared to create the directory if it doesn’t exist. + * + * Since: 2.60 + */ +#define G_TEST_OPTION_ISOLATE_DIRS "isolate_dirs" + +/** + * G_TEST_OPTION_NO_PRGNAME: + * + * A value that can be passed as an option to [func@GLib.test_init]. + * + * If this option is given, [func@GLib.test_init] will not call [func@GLib.set_prgname]. + * + * Since: 2.84 + */ +#define G_TEST_OPTION_NO_PRGNAME "no_g_set_prgname" + +/** + * G_TEST_OPTION_NONFATAL_ASSERTIONS: + * + * A value that can be passed as an option to [func@GLib.test_init]. + * + * If this option is given, assertions will not abort the process, but + * call [func@GLib.test_fail]. Equivalent to [func@GLib.test_set_nonfatal_assertions]. + * + * Since: 2.84 + */ +#define G_TEST_OPTION_NONFATAL_ASSERTIONS "nonfatal-assertions" + +/* While we discourage its use, g_assert() is often used in unit tests + * (especially in legacy code). g_assert_*() should really be used instead. + * g_assert() can be disabled at client program compile time, which can render + * tests useless. Highlight that to the user. */ +#ifdef G_DISABLE_ASSERT +#if defined(G_HAVE_ISO_VARARGS) +#define g_test_init(argc, argv, ...) \ + G_STMT_START { \ + g_printerr ("Tests were compiled with G_DISABLE_ASSERT and are likely no-ops. Aborting.\n"); \ + exit (1); \ + } G_STMT_END +#elif defined(G_HAVE_GNUC_VARARGS) +#define g_test_init(argc, argv...) \ + G_STMT_START { \ + g_printerr ("Tests were compiled with G_DISABLE_ASSERT and are likely no-ops. Aborting.\n"); \ + exit (1); \ + } G_STMT_END +#else /* no varargs */ + /* do nothing */ +#endif /* varargs support */ +#endif /* G_DISABLE_ASSERT */ + +/* query testing framework config */ +#define g_test_initialized() (g_test_config_vars->test_initialized) +#define g_test_quick() (g_test_config_vars->test_quick) +#define g_test_slow() (!g_test_config_vars->test_quick) +#define g_test_thorough() (!g_test_config_vars->test_quick) +#define g_test_perf() (g_test_config_vars->test_perf) +#define g_test_verbose() (g_test_config_vars->test_verbose) +#define g_test_quiet() (g_test_config_vars->test_quiet) +#define g_test_undefined() (g_test_config_vars->test_undefined) +GLIB_AVAILABLE_IN_2_38 +gboolean g_test_subprocess (void); + +/* run all tests under toplevel suite (path: /) */ +GLIB_AVAILABLE_IN_ALL +int g_test_run (void); +/* hook up a test functions under test path */ +GLIB_AVAILABLE_IN_ALL +void g_test_add_func (const char *testpath, + GTestFunc test_func); + +GLIB_AVAILABLE_IN_ALL +void g_test_add_data_func (const char *testpath, + gconstpointer test_data, + GTestDataFunc test_func); + +GLIB_AVAILABLE_IN_2_34 +void g_test_add_data_func_full (const char *testpath, + gpointer test_data, + GTestDataFunc test_func, + GDestroyNotify data_free_func); + +/* tell about currently run test */ +GLIB_AVAILABLE_IN_2_68 +const char * g_test_get_path (void); + +/* tell about failure */ +GLIB_AVAILABLE_IN_2_30 +void g_test_fail (void); +GLIB_AVAILABLE_IN_2_70 +void g_test_fail_printf (const char *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_2_38 +void g_test_incomplete (const gchar *msg); +GLIB_AVAILABLE_IN_2_70 +void g_test_incomplete_printf (const char *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_2_38 +void g_test_skip (const gchar *msg); +GLIB_AVAILABLE_IN_2_70 +void g_test_skip_printf (const char *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_2_38 +gboolean g_test_failed (void); +GLIB_AVAILABLE_IN_2_38 +void g_test_set_nonfatal_assertions (void); +GLIB_AVAILABLE_IN_2_78 +void g_test_disable_crash_reporting (void); + +/** + * g_test_add: + * @testpath: the test path for a new test case + * @Fixture: the type of a fixture data structure + * @tdata: data argument for the test functions + * @fsetup: the function to set up the fixture data + * @ftest: the actual test function + * @fteardown: the function to tear down the fixture data + * + * Hooks up a new test case at @testpath. + * + * This function is similar to [func@GLib.test_add_func]. + * + * A fixture data structure with setup and teardown functions + * may be provided, similar to [func@GLib.test_create_case]. + * + * `g_test_add()` is implemented as a macro, so that the @fsetup, + * @ftest and @fteardown callbacks can expect a @Fixture pointer + * as their first argument in a type safe manner. They otherwise + * have type `GTestFixtureFunc`. + * + * Since: 2.16 + */ +#define g_test_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \ + G_STMT_START { \ + void (*add_vtable) (const char*, \ + gsize, \ + gconstpointer, \ + void (*) (Fixture*, gconstpointer), \ + void (*) (Fixture*, gconstpointer), \ + void (*) (Fixture*, gconstpointer)) = (void (*) (const gchar *, gsize, gconstpointer, void (*) (Fixture*, gconstpointer), void (*) (Fixture*, gconstpointer), void (*) (Fixture*, gconstpointer))) g_test_add_vtable; \ + add_vtable \ + (testpath, sizeof (Fixture), tdata, fsetup, ftest, fteardown); \ + } G_STMT_END + +/* add test messages to the test report */ +GLIB_AVAILABLE_IN_ALL +void g_test_message (const char *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +void g_test_bug_base (const char *uri_pattern); +GLIB_AVAILABLE_IN_ALL +void g_test_bug (const char *bug_uri_snippet); +GLIB_AVAILABLE_IN_2_62 +void g_test_summary (const char *summary); +/* measure test timings */ +GLIB_AVAILABLE_IN_ALL +void g_test_timer_start (void); +GLIB_AVAILABLE_IN_ALL +double g_test_timer_elapsed (void); /* elapsed seconds */ +GLIB_AVAILABLE_IN_ALL +double g_test_timer_last (void); /* repeat last elapsed() result */ + +/* automatically g_free or g_object_unref upon teardown */ +GLIB_AVAILABLE_IN_ALL +void g_test_queue_free (gpointer gfree_pointer); +GLIB_AVAILABLE_IN_ALL +void g_test_queue_destroy (GDestroyNotify destroy_func, + gpointer destroy_data); +#define g_test_queue_unref(gobject) g_test_queue_destroy (g_object_unref, gobject) + +/** + * GTestTrapFlags: + * @G_TEST_TRAP_DEFAULT: Default behaviour. Since: 2.74 + * @G_TEST_TRAP_SILENCE_STDOUT: Redirect stdout of the test child to + * `/dev/null` so it cannot be observed on the console during test + * runs. The actual output is still captured though to allow later + * tests with g_test_trap_assert_stdout(). + * @G_TEST_TRAP_SILENCE_STDERR: Redirect stderr of the test child to + * `/dev/null` so it cannot be observed on the console during test + * runs. The actual output is still captured though to allow later + * tests with g_test_trap_assert_stderr(). + * @G_TEST_TRAP_INHERIT_STDIN: If this flag is given, stdin of the + * child process is shared with stdin of its parent process. + * It is redirected to `/dev/null` otherwise. + * + * Flags to pass to [func@GLib.test_trap_fork] to control input and output. + * + * Test traps are guards around forked tests. These flags determine what traps to set. + * + * Deprecated: 2.38: `GTestTrapFlags` is used only with [func@GLib.test_trap_fork], + * which is deprecated. Its replacement, [func@GLib.test_trap_subprocess] uses + * [flags@GLib.TestSubprocessFlags]. + */ +typedef enum { + G_TEST_TRAP_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_TEST_TRAP_SILENCE_STDOUT = 1 << 7, + G_TEST_TRAP_SILENCE_STDERR = 1 << 8, + G_TEST_TRAP_INHERIT_STDIN = 1 << 9 +} GTestTrapFlags GLIB_DEPRECATED_TYPE_IN_2_38_FOR(GTestSubprocessFlags); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +GLIB_DEPRECATED_IN_2_38_FOR (g_test_trap_subprocess) +gboolean g_test_trap_fork (guint64 usec_timeout, + GTestTrapFlags test_trap_flags); + +G_GNUC_END_IGNORE_DEPRECATIONS + +typedef enum { + G_TEST_SUBPROCESS_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_TEST_SUBPROCESS_INHERIT_STDIN = 1 << 0, + G_TEST_SUBPROCESS_INHERIT_STDOUT = 1 << 1, + G_TEST_SUBPROCESS_INHERIT_STDERR = 1 << 2 +} GTestSubprocessFlags; + +GLIB_AVAILABLE_IN_2_38 +void g_test_trap_subprocess (const char *test_path, + guint64 usec_timeout, + GTestSubprocessFlags test_flags); +GLIB_AVAILABLE_IN_2_80 +void g_test_trap_subprocess_with_envp (const char *test_path, + const char * const *envp, + guint64 usec_timeout, + GTestSubprocessFlags test_flags); + +GLIB_AVAILABLE_IN_ALL +gboolean g_test_trap_has_passed (void); +GLIB_AVAILABLE_IN_ALL +gboolean g_test_trap_reached_timeout (void); +#define g_test_trap_assert_passed() g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 0, 0) +#define g_test_trap_assert_failed() g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 1, 0) +#define g_test_trap_assert_stdout(soutpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 2, soutpattern) +#define g_test_trap_assert_stdout_unmatched(soutpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 3, soutpattern) +#define g_test_trap_assert_stderr(serrpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 4, serrpattern) +#define g_test_trap_assert_stderr_unmatched(serrpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 5, serrpattern) + +/* provide seed-able random numbers for tests */ +#define g_test_rand_bit() (0 != (g_test_rand_int() & (1 << 15))) +GLIB_AVAILABLE_IN_ALL +gint32 g_test_rand_int (void); +GLIB_AVAILABLE_IN_ALL +gint32 g_test_rand_int_range (gint32 begin, + gint32 end); +GLIB_AVAILABLE_IN_ALL +double g_test_rand_double (void); +GLIB_AVAILABLE_IN_ALL +double g_test_rand_double_range (double range_start, + double range_end); + +/* + * semi-internal API: non-documented symbols with stable ABI. You + * should use the non-internal helper macros instead. However, for + * compatibility reason, you may use this semi-internal API. + */ +GLIB_AVAILABLE_IN_ALL +GTestCase* g_test_create_case (const char *test_name, + gsize data_size, + gconstpointer test_data, + GTestFixtureFunc data_setup, + GTestFixtureFunc data_test, + GTestFixtureFunc data_teardown); +GLIB_AVAILABLE_IN_ALL +GTestSuite* g_test_create_suite (const char *suite_name); +GLIB_AVAILABLE_IN_ALL +GTestSuite* g_test_get_root (void); +GLIB_AVAILABLE_IN_ALL +void g_test_suite_add (GTestSuite *suite, + GTestCase *test_case); +GLIB_AVAILABLE_IN_ALL +void g_test_suite_add_suite (GTestSuite *suite, + GTestSuite *nestedsuite); +GLIB_AVAILABLE_IN_ALL +int g_test_run_suite (GTestSuite *suite); + +GLIB_AVAILABLE_IN_2_70 +void g_test_case_free (GTestCase *test_case); + +GLIB_AVAILABLE_IN_2_70 +void g_test_suite_free (GTestSuite *suite); + +GLIB_AVAILABLE_IN_ALL +void g_test_trap_assertions (const char *domain, + const char *file, + int line, + const char *func, + guint64 assertion_flags, /* 0-pass, 1-fail, 2-outpattern, 4-errpattern */ + const char *pattern); +GLIB_AVAILABLE_IN_ALL +void g_assertion_message (const char *domain, + const char *file, + int line, + const char *func, + const char *message) G_ANALYZER_NORETURN; +G_NORETURN +GLIB_AVAILABLE_IN_ALL +void g_assertion_message_expr (const char *domain, + const char *file, + int line, + const char *func, + const char *expr); +GLIB_AVAILABLE_IN_ALL +void g_assertion_message_cmpstr (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + const char *arg1, + const char *cmp, + const char *arg2) G_ANALYZER_NORETURN; + +GLIB_AVAILABLE_IN_2_68 +void g_assertion_message_cmpstrv (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + const char * const *arg1, + const char * const *arg2, + gsize first_wrong_idx) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_2_78 +void g_assertion_message_cmpint (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + guint64 arg1, + const char *cmp, + guint64 arg2, + char numtype) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +void g_assertion_message_cmpnum (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + long double arg1, + const char *cmp, + long double arg2, + char numtype) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +void g_assertion_message_error (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + const GError *error, + GQuark error_domain, + int error_code) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +void g_test_add_vtable (const char *testpath, + gsize data_size, + gconstpointer test_data, + GTestFixtureFunc data_setup, + GTestFixtureFunc data_test, + GTestFixtureFunc data_teardown); +typedef struct { + gboolean test_initialized; + gboolean test_quick; /* disable thorough tests */ + gboolean test_perf; /* run performance tests */ + gboolean test_verbose; /* extra info */ + gboolean test_quiet; /* reduce output */ + gboolean test_undefined; /* run tests that are meant to assert */ +} GTestConfig; +GLIB_VAR const GTestConfig * const g_test_config_vars; + +/* internal logging API */ +typedef enum { + G_TEST_RUN_SUCCESS, + G_TEST_RUN_SKIPPED, + G_TEST_RUN_FAILURE, + G_TEST_RUN_INCOMPLETE +} GTestResult; + +typedef enum { + G_TEST_LOG_NONE, + G_TEST_LOG_ERROR, /* s:msg */ + G_TEST_LOG_START_BINARY, /* s:binaryname s:seed */ + G_TEST_LOG_LIST_CASE, /* s:testpath */ + G_TEST_LOG_SKIP_CASE, /* s:testpath */ + G_TEST_LOG_START_CASE, /* s:testpath */ + G_TEST_LOG_STOP_CASE, /* d:status d:nforks d:elapsed */ + G_TEST_LOG_MIN_RESULT, /* s:blurb d:result */ + G_TEST_LOG_MAX_RESULT, /* s:blurb d:result */ + G_TEST_LOG_MESSAGE, /* s:blurb */ + G_TEST_LOG_START_SUITE, + G_TEST_LOG_STOP_SUITE +} GTestLogType; + +typedef struct { + GTestLogType log_type; + guint n_strings; + gchar **strings; /* NULL terminated */ + guint n_nums; + long double *nums; +} GTestLogMsg; +typedef struct { + /*< private >*/ + GString *data; + GSList *msgs; +} GTestLogBuffer; + +GLIB_AVAILABLE_IN_ALL +const char* g_test_log_type_name (GTestLogType log_type); +GLIB_AVAILABLE_IN_ALL +GTestLogBuffer* g_test_log_buffer_new (void); +GLIB_AVAILABLE_IN_ALL +void g_test_log_buffer_free (GTestLogBuffer *tbuffer); +GLIB_AVAILABLE_IN_ALL +void g_test_log_buffer_push (GTestLogBuffer *tbuffer, + guint n_bytes, + const guint8 *bytes); +GLIB_AVAILABLE_IN_ALL +GTestLogMsg* g_test_log_buffer_pop (GTestLogBuffer *tbuffer); +GLIB_AVAILABLE_IN_ALL +void g_test_log_msg_free (GTestLogMsg *tmsg); + +/** + * GTestLogFatalFunc: + * @log_domain: the log domain of the message + * @log_level: the log level of the message (including the fatal and recursion flags) + * @message: the message to process + * @user_data: user data, set in g_test_log_set_fatal_handler() + * + * Specifies the prototype of fatal log handler functions. + * + * Returns: %TRUE if the program should abort, %FALSE otherwise + * + * Since: 2.22 + */ +typedef gboolean (*GTestLogFatalFunc) (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void +g_test_log_set_fatal_handler (GTestLogFatalFunc log_func, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_34 +void g_test_expect_message (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *pattern); +GLIB_AVAILABLE_IN_2_34 +void g_test_assert_expected_messages_internal (const char *domain, + const char *file, + int line, + const char *func); + +typedef enum +{ + G_TEST_DIST, + G_TEST_BUILT +} GTestFileType; + +GLIB_AVAILABLE_IN_2_38 +gchar * g_test_build_filename (GTestFileType file_type, + const gchar *first_path, + ...) G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_2_38 +const gchar *g_test_get_dir (GTestFileType file_type); +GLIB_AVAILABLE_IN_2_38 +const gchar *g_test_get_filename (GTestFileType file_type, + const gchar *first_path, + ...) G_GNUC_NULL_TERMINATED; + +#define g_test_assert_expected_messages() g_test_assert_expected_messages_internal (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC) + +G_END_DECLS + +#endif /* __G_TEST_UTILS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gthread.h b/illumos-x86_64/usr/include/glib-2.0/glib/gthread.h new file mode 100644 index 00000000..4aa5290c --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gthread.h @@ -0,0 +1,818 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_THREAD_H__ +#define __G_THREAD_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +#define G_THREAD_ERROR g_thread_error_quark () +GLIB_AVAILABLE_IN_ALL +GQuark g_thread_error_quark (void); + +typedef enum +{ + G_THREAD_ERROR_AGAIN /* Resource temporarily unavailable */ +} GThreadError; + +typedef gpointer (*GThreadFunc) (gpointer data); + +typedef struct _GThread GThread; + +typedef union _GMutex GMutex; +typedef struct _GRecMutex GRecMutex; +typedef struct _GRWLock GRWLock; +typedef struct _GCond GCond; +typedef struct _GPrivate GPrivate; +typedef struct _GOnce GOnce; + +union _GMutex +{ + /*< private >*/ + gpointer p; + guint i[2]; +}; + +struct _GRWLock +{ + /*< private >*/ + gpointer p; + guint i[2]; +}; + +struct _GCond +{ + /*< private >*/ + gpointer p; + guint i[2]; +}; + +struct _GRecMutex +{ + /*< private >*/ + gpointer p; + guint i[2]; +}; + +#define G_PRIVATE_INIT(notify) { NULL, (notify), { NULL, NULL } } +struct _GPrivate +{ + /*< private >*/ + gpointer p; + GDestroyNotify notify; + gpointer future[2]; +}; + +typedef enum +{ + G_ONCE_STATUS_NOTCALLED, + G_ONCE_STATUS_PROGRESS, + G_ONCE_STATUS_READY +} GOnceStatus; + +#define G_ONCE_INIT { G_ONCE_STATUS_NOTCALLED, NULL } +struct _GOnce +{ + volatile GOnceStatus status; + volatile gpointer retval; +}; + +#define G_LOCK_NAME(name) g__ ## name ## _lock +#define G_LOCK_DEFINE_STATIC(name) static G_LOCK_DEFINE (name) +#define G_LOCK_DEFINE(name) GMutex G_LOCK_NAME (name) +#define G_LOCK_EXTERN(name) extern GMutex G_LOCK_NAME (name) + +#ifdef G_DEBUG_LOCKS +# define G_LOCK(name) G_STMT_START{ \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): locking: %s ", \ + __FILE__, __LINE__, G_STRFUNC, \ + #name); \ + g_mutex_lock (&G_LOCK_NAME (name)); \ + }G_STMT_END +# define G_UNLOCK(name) G_STMT_START{ \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): unlocking: %s ", \ + __FILE__, __LINE__, G_STRFUNC, \ + #name); \ + g_mutex_unlock (&G_LOCK_NAME (name)); \ + }G_STMT_END +# define G_TRYLOCK(name) \ + (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): try locking: %s ", \ + __FILE__, __LINE__, G_STRFUNC, \ + #name), g_mutex_trylock (&G_LOCK_NAME (name))) +#else /* !G_DEBUG_LOCKS */ +# define G_LOCK(name) g_mutex_lock (&G_LOCK_NAME (name)) +# define G_UNLOCK(name) g_mutex_unlock (&G_LOCK_NAME (name)) +# define G_TRYLOCK(name) g_mutex_trylock (&G_LOCK_NAME (name)) +#endif /* !G_DEBUG_LOCKS */ + +#ifdef g_autoptr +#define G_AUTO_LOCK(name) G_MUTEX_AUTO_LOCK (&G_LOCK_NAME (name), g__##name##_locker) +#endif /* g_autoptr */ + +GLIB_AVAILABLE_IN_2_32 +GThread * g_thread_ref (GThread *thread); +GLIB_AVAILABLE_IN_2_32 +void g_thread_unref (GThread *thread); +GLIB_AVAILABLE_IN_2_32 +GThread * g_thread_new (const gchar *name, + GThreadFunc func, + gpointer data); +GLIB_AVAILABLE_IN_2_32 +GThread * g_thread_try_new (const gchar *name, + GThreadFunc func, + gpointer data, + GError **error); +GLIB_AVAILABLE_IN_ALL +GThread * g_thread_self (void); +G_NORETURN GLIB_AVAILABLE_IN_ALL +void g_thread_exit (gpointer retval); +GLIB_AVAILABLE_IN_ALL +gpointer g_thread_join (GThread *thread); +GLIB_AVAILABLE_IN_ALL +void g_thread_yield (void); + +GLIB_AVAILABLE_IN_2_84 +const char * g_thread_get_name (GThread *thread); + +GLIB_AVAILABLE_IN_2_32 +void g_mutex_init (GMutex *mutex); +GLIB_AVAILABLE_IN_2_32 +void g_mutex_clear (GMutex *mutex); +GLIB_AVAILABLE_IN_ALL +void g_mutex_lock (GMutex *mutex); +GLIB_AVAILABLE_IN_ALL +gboolean g_mutex_trylock (GMutex *mutex); +GLIB_AVAILABLE_IN_ALL +void g_mutex_unlock (GMutex *mutex); + +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_init (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_clear (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_writer_lock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +gboolean g_rw_lock_writer_trylock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_writer_unlock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_reader_lock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +gboolean g_rw_lock_reader_trylock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_reader_unlock (GRWLock *rw_lock); + +GLIB_AVAILABLE_IN_2_32 +void g_rec_mutex_init (GRecMutex *rec_mutex); +GLIB_AVAILABLE_IN_2_32 +void g_rec_mutex_clear (GRecMutex *rec_mutex); +GLIB_AVAILABLE_IN_2_32 +void g_rec_mutex_lock (GRecMutex *rec_mutex); +GLIB_AVAILABLE_IN_2_32 +gboolean g_rec_mutex_trylock (GRecMutex *rec_mutex); +GLIB_AVAILABLE_IN_2_32 +void g_rec_mutex_unlock (GRecMutex *rec_mutex); + +GLIB_AVAILABLE_IN_2_32 +void g_cond_init (GCond *cond); +GLIB_AVAILABLE_IN_2_32 +void g_cond_clear (GCond *cond); +GLIB_AVAILABLE_IN_ALL +void g_cond_wait (GCond *cond, + GMutex *mutex); +GLIB_AVAILABLE_IN_ALL +void g_cond_signal (GCond *cond); +GLIB_AVAILABLE_IN_ALL +void g_cond_broadcast (GCond *cond); +GLIB_AVAILABLE_IN_2_32 +gboolean g_cond_wait_until (GCond *cond, + GMutex *mutex, + gint64 end_time); + +GLIB_AVAILABLE_IN_ALL +gpointer g_private_get (GPrivate *key); +GLIB_AVAILABLE_IN_ALL +void g_private_set (GPrivate *key, + gpointer value); +GLIB_AVAILABLE_IN_2_32 +void g_private_replace (GPrivate *key, + gpointer value); + +GLIB_AVAILABLE_IN_ALL +gpointer g_once_impl (GOnce *once, + GThreadFunc func, + gpointer arg); +GLIB_AVAILABLE_IN_ALL +gboolean g_once_init_enter (volatile void *location); +GLIB_AVAILABLE_IN_ALL +void g_once_init_leave (volatile void *location, + gsize result); + +GLIB_AVAILABLE_IN_2_80 +gboolean g_once_init_enter_pointer (void *location); +GLIB_AVAILABLE_IN_2_80 +void g_once_init_leave_pointer (void *location, + gpointer result); + +/* Use C11-style atomic extensions to check the fast path for status=ready. If + * they are not available, fall back to using a mutex and condition variable in + * g_once_impl(). + * + * On the C11-style codepath, only the load of once->status needs to be atomic, + * as the writes to it and once->retval in g_once_impl() are related by a + * happens-before relation. Release-acquire semantics are defined such that any + * atomic/non-atomic write which happens-before a store/release is guaranteed to + * be seen by the load/acquire of the same atomic variable. */ +#if defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) && defined(__ATOMIC_SEQ_CST) +# define g_once(once, func, arg) \ + ((__atomic_load_n (&(once)->status, __ATOMIC_ACQUIRE) == G_ONCE_STATUS_READY) ? \ + (once)->retval : \ + g_once_impl ((once), (func), (arg))) +#else +# define g_once(once, func, arg) g_once_impl ((once), (func), (arg)) +#endif + +#ifdef __GNUC__ +# define g_once_init_enter(location) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(location) : NULL); \ + (!g_atomic_pointer_get (location) && \ + g_once_init_enter (location)); \ + })) +# define g_once_init_leave(location, result) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ + 0 ? (void) (*(location) = (result)) : (void) 0; \ + g_once_init_leave ((location), (gsize) (result)); \ + })) +# define g_once_init_enter_pointer(location) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) * (location) : NULL); \ + (!g_atomic_pointer_get (location) && \ + g_once_init_enter_pointer (location)); \ + })) GLIB_AVAILABLE_MACRO_IN_2_80 +# define g_once_init_leave_pointer(location, result) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ + 0 ? (void) (*(location) = (result)) : (void) 0; \ + g_once_init_leave_pointer ((location), (gpointer) (guintptr) (result)); \ + })) GLIB_AVAILABLE_MACRO_IN_2_80 +#else +# define g_once_init_enter(location) \ + (g_once_init_enter((location))) +# define g_once_init_leave(location, result) \ + (g_once_init_leave((location), (gsize) (result))) +# define g_once_init_enter_pointer(location) \ + (g_once_init_enter_pointer((location))) \ + GLIB_AVAILABLE_MACRO_IN_2_80 +# define g_once_init_leave_pointer(location, result) \ + (g_once_init_leave_pointer((location), (gpointer) (guintptr) (result))) \ + GLIB_AVAILABLE_MACRO_IN_2_80 +#endif + +GLIB_AVAILABLE_IN_2_36 +guint g_get_num_processors (void); + +/** + * GMutexLocker: + * + * Opaque type. See g_mutex_locker_new() for details. + * Since: 2.44 + */ +typedef void GMutexLocker; + +/** + * g_mutex_locker_new: + * @mutex: a mutex to lock + * + * Lock @mutex and return a new #GMutexLocker. Unlock with + * g_mutex_locker_free(). Using g_mutex_unlock() on @mutex + * while a #GMutexLocker exists can lead to undefined behaviour. + * + * No allocation is performed, it is equivalent to a g_mutex_lock() call. + * + * This is intended to be used with g_autoptr(). Note that g_autoptr() + * is only available when using GCC or clang, so the following example + * will only work with those compilers: + * |[ + * typedef struct + * { + * ... + * GMutex mutex; + * ... + * } MyObject; + * + * static void + * my_object_do_stuff (MyObject *self) + * { + * g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&self->mutex); + * + * // Code with mutex locked here + * + * if (condition) + * // No need to unlock + * return; + * + * // Optionally early unlock + * g_clear_pointer (&locker, g_mutex_locker_free); + * + * // Code with mutex unlocked here + * } + * ]| + * + * Note that it is common for the declared variable to not be used in the scope, + * which causes some compilers to warn. That can be avoided by using + * `G_GNUC_UNUSED` or, since 2.80, [func@GLib.MUTEX_AUTO_LOCK]. + * + * Returns: a #GMutexLocker + * Since: 2.44 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +static inline GMutexLocker * +g_mutex_locker_new (GMutex *mutex) +{ + g_mutex_lock (mutex); + return (GMutexLocker *) mutex; +} + +/** + * g_mutex_locker_free: + * @locker: a GMutexLocker + * + * Unlock @locker's mutex. See g_mutex_locker_new() for details. + * + * No memory is freed, it is equivalent to a g_mutex_unlock() call. + * + * Since: 2.44 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +static inline void +g_mutex_locker_free (GMutexLocker *locker) +{ + g_mutex_unlock ((GMutex *) locker); +} + +/** + * G_MUTEX_AUTO_LOCK: + * @mutex: a [type@GLib.Mutex] + * @var: a variable name to be declared + * + * Declare a [type@GLib.MutexLocker] variable with `g_autoptr()` and lock the + * mutex. The mutex will be unlocked automatically when leaving the scope. The + * variable is declared with `G_GNUC_UNUSED` to avoid compiler warning if it is + * not used in the scope. + * + * This feature is only supported on GCC and clang. This macro is not defined on + * other compilers and should not be used in programs that are intended to be + * portable to those compilers. + * + * Note that this should be used in a place where it is allowed to declare a + * variable, which could be before any statement in the case + * `-Wdeclaration-after-statement` is used, or C standard prior to C99. + * + * ```c + * { + * G_MUTEX_AUTO_LOCK (&obj->mutex, locker); + * + * obj->stuff_with_lock (); + * if (condition) + * { + * // No need to unlock + * return; + * } + * + * // Unlock before end of scope + * g_clear_pointer (&locker, g_mutex_locker_free); + * obj->stuff_without_lock (); + * } + * ``` + * + * Since: 2.80.0 + */ +#ifdef g_autoptr +#define G_MUTEX_AUTO_LOCK(mutex, var) \ + GLIB_AVAILABLE_MACRO_IN_2_80 g_autoptr (GMutexLocker) \ + G_GNUC_UNUSED var = g_mutex_locker_new (mutex) +#endif /* g_autoptr */ + +/** + * GRecMutexLocker: + * + * Opaque type. See g_rec_mutex_locker_new() for details. + * Since: 2.60 + */ +typedef void GRecMutexLocker; + +/** + * g_rec_mutex_locker_new: + * @rec_mutex: a recursive mutex to lock + * + * Lock @rec_mutex and return a new #GRecMutexLocker. Unlock with + * g_rec_mutex_locker_free(). Using g_rec_mutex_unlock() on @rec_mutex + * while a #GRecMutexLocker exists can lead to undefined behaviour. + * + * No allocation is performed, it is equivalent to a g_rec_mutex_lock() call. + * + * This is intended to be used with g_autoptr(). Note that g_autoptr() + * is only available when using GCC or clang, so the following example + * will only work with those compilers: + * |[ + * typedef struct + * { + * ... + * GRecMutex rec_mutex; + * ... + * } MyObject; + * + * static void + * my_object_do_stuff (MyObject *self) + * { + * g_autoptr(GRecMutexLocker) locker = g_rec_mutex_locker_new (&self->rec_mutex); + * + * // Code with rec_mutex locked here + * + * if (condition) + * // No need to unlock + * return; + * + * // Optionally early unlock + * g_clear_pointer (&locker, g_rec_mutex_locker_free); + * + * // Code with rec_mutex unlocked here + * } + * ]| + * + * Note that it is common for the declared variable to not be used in the scope, + * which causes some compilers to warn. That can be avoided by using + * `G_GNUC_UNUSED` or, since 2.80, [func@GLib.REC_MUTEX_AUTO_LOCK]. + * + * Returns: a #GRecMutexLocker + * Since: 2.60 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 +static inline GRecMutexLocker * +g_rec_mutex_locker_new (GRecMutex *rec_mutex) +{ + g_rec_mutex_lock (rec_mutex); + return (GRecMutexLocker *) rec_mutex; +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * g_rec_mutex_locker_free: + * @locker: a GRecMutexLocker + * + * Unlock @locker's recursive mutex. See g_rec_mutex_locker_new() for details. + * + * No memory is freed, it is equivalent to a g_rec_mutex_unlock() call. + * + * Since: 2.60 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 +static inline void +g_rec_mutex_locker_free (GRecMutexLocker *locker) +{ + g_rec_mutex_unlock ((GRecMutex *) locker); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_REC_MUTEX_AUTO_LOCK: + * @mutex: a [type@GLib.RecMutex] + * @var: a variable name to be declared + * + * Declare a [type@GLib.RecMutexLocker] variable with `g_autoptr()` and lock the + * mutex. The mutex will be unlocked automatically when leaving the scope. The + * variable is declared with `G_GNUC_UNUSED` to avoid compiler warning if it is + * not used in the scope. + * + * This feature is only supported on GCC and clang. This macro is not defined on + * other compilers and should not be used in programs that are intended to be + * portable to those compilers. + * + * Note that this should be used in a place where it is allowed to declare a + * variable, which could be before any statement in the case + * `-Wdeclaration-after-statement` is used, or C standard prior to C99. + * + * ```c + * { + * G_REC_MUTEX_AUTO_LOCK (&obj->rec_mutex, locker); + * + * obj->stuff_with_lock (); + * if (condition) + * { + * // No need to unlock + * return; + * } + * + * // Unlock before end of scope + * g_clear_pointer (&locker, g_rec_mutex_locker_free); + * obj->stuff_without_lock (); + * } + * ``` + * + * Since: 2.80.0 + */ +#ifdef g_autoptr +#define G_REC_MUTEX_AUTO_LOCK(mutex, var) \ + GLIB_AVAILABLE_MACRO_IN_2_80 g_autoptr (GRecMutexLocker) \ + G_GNUC_UNUSED var = g_rec_mutex_locker_new (mutex) +#endif /* g_autoptr */ + +/** + * GRWLockWriterLocker: + * + * Opaque type. See g_rw_lock_writer_locker_new() for details. + * Since: 2.62 + */ +typedef void GRWLockWriterLocker; + +/** + * g_rw_lock_writer_locker_new: + * @rw_lock: a #GRWLock + * + * Obtain a write lock on @rw_lock and return a new #GRWLockWriterLocker. + * Unlock with g_rw_lock_writer_locker_free(). Using g_rw_lock_writer_unlock() + * on @rw_lock while a #GRWLockWriterLocker exists can lead to undefined + * behaviour. + * + * No allocation is performed, it is equivalent to a g_rw_lock_writer_lock() call. + * + * This is intended to be used with g_autoptr(). Note that g_autoptr() + * is only available when using GCC or clang, so the following example + * will only work with those compilers: + * |[ + * typedef struct + * { + * ... + * GRWLock rw_lock; + * GPtrArray *array; + * ... + * } MyObject; + * + * static gchar * + * my_object_get_data (MyObject *self, guint index) + * { + * g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new (&self->rw_lock); + * + * // Code with a read lock obtained on rw_lock here + * + * if (self->array == NULL) + * // No need to unlock + * return NULL; + * + * if (index < self->array->len) + * // No need to unlock + * return g_ptr_array_index (self->array, index); + * + * // Optionally early unlock + * g_clear_pointer (&locker, g_rw_lock_reader_locker_free); + * + * // Code with rw_lock unlocked here + * return NULL; + * } + * + * static void + * my_object_set_data (MyObject *self, guint index, gpointer data) + * { + * g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&self->rw_lock); + * + * // Code with a write lock obtained on rw_lock here + * + * if (self->array == NULL) + * self->array = g_ptr_array_new (); + * + * if (condition) + * // No need to unlock + * return; + * + * if (index >= self->array->len) + * g_ptr_array_set_size (self->array, index+1); + * g_ptr_array_index (self->array, index) = data; + * + * // Optionally early unlock + * g_clear_pointer (&locker, g_rw_lock_writer_locker_free); + * + * // Code with rw_lock unlocked here + * } + * ]| + * + * Note that it is common for the declared variable to not be used in the scope, + * which causes some compilers to warn. That can be avoided by using + * `G_GNUC_UNUSED` or, since 2.80, [func@GLib.RW_LOCK_WRITER_AUTO_LOCK]. + * + * Returns: a #GRWLockWriterLocker + * Since: 2.62 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +static inline GRWLockWriterLocker * +g_rw_lock_writer_locker_new (GRWLock *rw_lock) +{ + g_rw_lock_writer_lock (rw_lock); + return (GRWLockWriterLocker *) rw_lock; +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * g_rw_lock_writer_locker_free: + * @locker: a GRWLockWriterLocker + * + * Release a write lock on @locker's read-write lock. See + * g_rw_lock_writer_locker_new() for details. + * + * No memory is freed, it is equivalent to a g_rw_lock_writer_unlock() call. + * + * Since: 2.62 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +static inline void +g_rw_lock_writer_locker_free (GRWLockWriterLocker *locker) +{ + g_rw_lock_writer_unlock ((GRWLock *) locker); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_RW_LOCK_WRITER_AUTO_LOCK: + * @mutex: a [type@GLib.RWLock] + * @var: a variable name to be declared + * + * Declare a [type@GLib.RWLockWriterLocker] variable with `g_autoptr()` and lock + * for writing. The mutex will be unlocked automatically when leaving the scope. + * The variable is declared with `G_GNUC_UNUSED` to avoid compiler warning if it + * is not used in the scope. + * + * This feature is only supported on GCC and clang. This macro is not defined on + * other compilers and should not be used in programs that are intended to be + * portable to those compilers. + * + * Note that this should be used in a place where it is allowed to declare a + * variable, which could be before any statement in the case + * `-Wdeclaration-after-statement` is used, or C standard prior to C99. + * + * ```c + * { + * G_RW_LOCK_WRITER_AUTO_LOCK (&obj->rw_lock, locker); + * + * obj->stuff_with_lock (); + * if (condition) + * { + * // No need to unlock + * return; + * } + * + * // Unlock before end of scope + * g_clear_pointer (&locker, g_rw_lock_writer_locker_free); + * obj->stuff_without_lock (); + * } + * ``` + * + * Since: 2.80.0 + */ +#ifdef g_autoptr +#define G_RW_LOCK_WRITER_AUTO_LOCK(mutex, var) \ + GLIB_AVAILABLE_MACRO_IN_2_80 g_autoptr (GRWLockWriterLocker) \ + G_GNUC_UNUSED var = g_rw_lock_writer_locker_new (mutex) +#endif /* g_autoptr */ + +/** + * GRWLockReaderLocker: + * + * Opaque type. See g_rw_lock_reader_locker_new() for details. + * Since: 2.62 + */ +typedef void GRWLockReaderLocker; + +/** + * g_rw_lock_reader_locker_new: + * @rw_lock: a #GRWLock + * + * Obtain a read lock on @rw_lock and return a new #GRWLockReaderLocker. + * Unlock with g_rw_lock_reader_locker_free(). Using g_rw_lock_reader_unlock() + * on @rw_lock while a #GRWLockReaderLocker exists can lead to undefined + * behaviour. + * + * No allocation is performed, it is equivalent to a g_rw_lock_reader_lock() call. + * + * This is intended to be used with g_autoptr(). For a code sample, see + * g_rw_lock_writer_locker_new(). + * + * Returns: a #GRWLockReaderLocker + * Since: 2.62 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +static inline GRWLockReaderLocker * +g_rw_lock_reader_locker_new (GRWLock *rw_lock) +{ + g_rw_lock_reader_lock (rw_lock); + return (GRWLockReaderLocker *) rw_lock; +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * g_rw_lock_reader_locker_free: + * @locker: a GRWLockReaderLocker + * + * Release a read lock on @locker's read-write lock. See + * g_rw_lock_reader_locker_new() for details. + * + * No memory is freed, it is equivalent to a g_rw_lock_reader_unlock() call. + * + * Since: 2.62 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +static inline void +g_rw_lock_reader_locker_free (GRWLockReaderLocker *locker) +{ + g_rw_lock_reader_unlock ((GRWLock *) locker); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_RW_LOCK_READER_AUTO_LOCK: + * @mutex: a [type@GLib.RWLock] + * @var: a variable name to be declared + * + * Declare a [type@GLib.RWLockReaderLocker] variable with `g_autoptr()` and lock + * for reading. The mutex will be unlocked automatically when leaving the scope. + * The variable is declared with `G_GNUC_UNUSED` to avoid compiler warning if it + * is not used in the scope. + * + * This feature is only supported on GCC and clang. This macro is not defined on + * other compilers and should not be used in programs that are intended to be + * portable to those compilers. + * + * Note that this should be used in a place where it is allowed to declare a + * variable, which could be before any statement in the case + * `-Wdeclaration-after-statement` is used, or C standard prior to C99. + * + * ```c + * { + * G_RW_LOCK_READER_AUTO_LOCK (&obj->rw_lock, locker); + * + * obj->stuff_with_lock (); + * if (condition) + * { + * // No need to unlock + * return; + * } + * + * // Unlock before end of scope + * g_clear_pointer (&locker, g_rw_lock_reader_locker_free); + * obj->stuff_without_lock (); + * } + * ``` + * + * Since: 2.80.0 + */ +#ifdef g_autoptr +#define G_RW_LOCK_READER_AUTO_LOCK(mutex, var) \ + GLIB_AVAILABLE_MACRO_IN_2_80 g_autoptr (GRWLockReaderLocker) \ + G_GNUC_UNUSED var = g_rw_lock_reader_locker_new (mutex) +#endif /* g_autoptr */ + +G_END_DECLS + +#endif /* __G_THREAD_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gthreadpool.h b/illumos-x86_64/usr/include/glib-2.0/glib/gthreadpool.h new file mode 100644 index 00000000..921bee44 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gthreadpool.h @@ -0,0 +1,105 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_THREADPOOL_H__ +#define __G_THREADPOOL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GThreadPool GThreadPool; + +/* Thread Pools + */ + +struct _GThreadPool +{ + GFunc func; + gpointer user_data; + gboolean exclusive; +}; + +GLIB_AVAILABLE_IN_ALL +GThreadPool * g_thread_pool_new (GFunc func, + gpointer user_data, + gint max_threads, + gboolean exclusive, + GError **error); +GLIB_AVAILABLE_IN_2_70 +GThreadPool * g_thread_pool_new_full (GFunc func, + gpointer user_data, + GDestroyNotify item_free_func, + gint max_threads, + gboolean exclusive, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_free (GThreadPool *pool, + gboolean immediate, + gboolean wait_); +GLIB_AVAILABLE_IN_ALL +gboolean g_thread_pool_push (GThreadPool *pool, + gpointer data, + GError **error); +GLIB_AVAILABLE_IN_ALL +guint g_thread_pool_unprocessed (GThreadPool *pool); +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_set_sort_function (GThreadPool *pool, + GCompareDataFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_46 +gboolean g_thread_pool_move_to_front (GThreadPool *pool, + gpointer data); + +GLIB_AVAILABLE_IN_ALL +gboolean g_thread_pool_set_max_threads (GThreadPool *pool, + gint max_threads, + GError **error); +GLIB_AVAILABLE_IN_ALL +gint g_thread_pool_get_max_threads (GThreadPool *pool); +GLIB_AVAILABLE_IN_ALL +guint g_thread_pool_get_num_threads (GThreadPool *pool); + +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_set_max_unused_threads (gint max_threads); +GLIB_AVAILABLE_IN_ALL +gint g_thread_pool_get_max_unused_threads (void); +GLIB_AVAILABLE_IN_ALL +guint g_thread_pool_get_num_unused_threads (void); +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_stop_unused_threads (void); +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_set_max_idle_time (guint interval); +GLIB_AVAILABLE_IN_ALL +guint g_thread_pool_get_max_idle_time (void); + +G_END_DECLS + +#endif /* __G_THREADPOOL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gtimer.h b/illumos-x86_64/usr/include/glib-2.0/glib/gtimer.h new file mode 100644 index 00000000..439ffad9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gtimer.h @@ -0,0 +1,80 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_TIMER_H__ +#define __G_TIMER_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* Timer + */ + +/* microseconds per second */ +typedef struct _GTimer GTimer; + +#define G_USEC_PER_SEC 1000000 + +GLIB_AVAILABLE_IN_ALL +GTimer* g_timer_new (void); +GLIB_AVAILABLE_IN_ALL +void g_timer_destroy (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +void g_timer_start (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +void g_timer_stop (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +void g_timer_reset (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +void g_timer_continue (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +gdouble g_timer_elapsed (GTimer *timer, + gulong *microseconds); +GLIB_AVAILABLE_IN_2_62 +gboolean g_timer_is_active (GTimer *timer); + +GLIB_AVAILABLE_IN_ALL +void g_usleep (gulong microseconds); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62 +void g_time_val_add (GTimeVal *time_, + glong microseconds); +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_iso8601) +gboolean g_time_val_from_iso8601 (const gchar *iso_date, + GTimeVal *time_); +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_format) +gchar* g_time_val_to_iso8601 (GTimeVal *time_) G_GNUC_MALLOC; +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_TIMER_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gtimezone.h b/illumos-x86_64/usr/include/glib-2.0/glib/gtimezone.h new file mode 100644 index 00000000..679ed4e9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gtimezone.h @@ -0,0 +1,98 @@ +/* + * Copyright © 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_TIME_ZONE_H__ +#define __G_TIME_ZONE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GTimeZone GTimeZone; + +/** + * GTimeType: + * @G_TIME_TYPE_STANDARD: the time is in local standard time + * @G_TIME_TYPE_DAYLIGHT: the time is in local daylight time + * @G_TIME_TYPE_UNIVERSAL: the time is in UTC + * + * Disambiguates a given time in two ways. + * + * First, specifies if the given time is in universal or local time. + * + * Second, if the time is in local time, specifies if it is local + * standard time or local daylight time. This is important for the case + * where the same local time occurs twice (during daylight savings time + * transitions, for example). + */ +typedef enum +{ + G_TIME_TYPE_STANDARD, + G_TIME_TYPE_DAYLIGHT, + G_TIME_TYPE_UNIVERSAL +} GTimeType; + +GLIB_DEPRECATED_IN_2_68_FOR (g_time_zone_new_identifier) +GTimeZone * g_time_zone_new (const gchar *identifier); +GLIB_AVAILABLE_IN_2_68 +GTimeZone * g_time_zone_new_identifier (const gchar *identifier); +GLIB_AVAILABLE_IN_ALL +GTimeZone * g_time_zone_new_utc (void); +GLIB_AVAILABLE_IN_ALL +GTimeZone * g_time_zone_new_local (void); +GLIB_AVAILABLE_IN_2_58 +GTimeZone * g_time_zone_new_offset (gint32 seconds); + +GLIB_AVAILABLE_IN_ALL +GTimeZone * g_time_zone_ref (GTimeZone *tz); +GLIB_AVAILABLE_IN_ALL +void g_time_zone_unref (GTimeZone *tz); + +GLIB_AVAILABLE_IN_ALL +gint g_time_zone_find_interval (GTimeZone *tz, + GTimeType type, + gint64 time_); + +GLIB_AVAILABLE_IN_ALL +gint g_time_zone_adjust_time (GTimeZone *tz, + GTimeType type, + gint64 *time_); + +GLIB_AVAILABLE_IN_ALL +const gchar * g_time_zone_get_abbreviation (GTimeZone *tz, + gint interval); +GLIB_AVAILABLE_IN_ALL +gint32 g_time_zone_get_offset (GTimeZone *tz, + gint interval); +GLIB_AVAILABLE_IN_ALL +gboolean g_time_zone_is_dst (GTimeZone *tz, + gint interval); +GLIB_AVAILABLE_IN_2_58 +const gchar * g_time_zone_get_identifier (GTimeZone *tz); + +G_END_DECLS + +#endif /* __G_TIME_ZONE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gtrashstack.h b/illumos-x86_64/usr/include/glib-2.0/glib/gtrashstack.h new file mode 100644 index 00000000..81456d39 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gtrashstack.h @@ -0,0 +1,60 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_TRASH_STACK_H__ +#define __G_TRASH_STACK_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +typedef struct _GTrashStack GTrashStack GLIB_DEPRECATED_TYPE_IN_2_48; +struct _GTrashStack +{ + GTrashStack *next; +} GLIB_DEPRECATED_TYPE_IN_2_48; + +GLIB_DEPRECATED_IN_2_48 +void g_trash_stack_push (GTrashStack **stack_p, + gpointer data_p); +GLIB_DEPRECATED_IN_2_48 +gpointer g_trash_stack_pop (GTrashStack **stack_p); +GLIB_DEPRECATED_IN_2_48 +gpointer g_trash_stack_peek (GTrashStack **stack_p); +GLIB_DEPRECATED_IN_2_48 +guint g_trash_stack_height (GTrashStack **stack_p); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_TRASH_STACK_H_ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gtree.h b/illumos-x86_64/usr/include/glib-2.0/glib/gtree.h new file mode 100644 index 00000000..74ab9ce9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gtree.h @@ -0,0 +1,181 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_TREE_H__ +#define __G_TREE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#undef G_TREE_DEBUG + +typedef struct _GTree GTree; + +/** + * GTreeNode: + * + * An opaque type which identifies a specific node in a #GTree. + * + * Since: 2.68 + */ +typedef struct _GTreeNode GTreeNode; + +typedef gboolean (*GTraverseFunc) (gpointer key, + gpointer value, + gpointer data); + +/** + * GTraverseNodeFunc: + * @node: a #GTreeNode + * @data: user data passed to g_tree_foreach_node() + * + * Specifies the type of function passed to g_tree_foreach_node(). It is + * passed each node, together with the @user_data parameter passed to + * g_tree_foreach_node(). If the function returns %TRUE, the traversal is + * stopped. + * + * Returns: %TRUE to stop the traversal + * Since: 2.68 + */ +typedef gboolean (*GTraverseNodeFunc) (GTreeNode *node, + gpointer data); + +/* Balanced binary trees + */ +GLIB_AVAILABLE_IN_ALL +GTree* g_tree_new (GCompareFunc key_compare_func); +GLIB_AVAILABLE_IN_ALL +GTree* g_tree_new_with_data (GCompareDataFunc key_compare_func, + gpointer key_compare_data); +GLIB_AVAILABLE_IN_ALL +GTree* g_tree_new_full (GCompareDataFunc key_compare_func, + gpointer key_compare_data, + GDestroyNotify key_destroy_func, + GDestroyNotify value_destroy_func); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_node_first (GTree *tree); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_node_last (GTree *tree); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_node_previous (GTreeNode *node); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_node_next (GTreeNode *node); +GLIB_AVAILABLE_IN_ALL +GTree* g_tree_ref (GTree *tree); +GLIB_AVAILABLE_IN_ALL +void g_tree_unref (GTree *tree); +GLIB_AVAILABLE_IN_ALL +void g_tree_destroy (GTree *tree); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_insert_node (GTree *tree, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +void g_tree_insert (GTree *tree, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_replace_node (GTree *tree, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +void g_tree_replace (GTree *tree, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +gboolean g_tree_remove (GTree *tree, + gconstpointer key); + +GLIB_AVAILABLE_IN_2_70 +void g_tree_remove_all (GTree *tree); + +GLIB_AVAILABLE_IN_ALL +gboolean g_tree_steal (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_2_68 +gpointer g_tree_node_key (GTreeNode *node); +GLIB_AVAILABLE_IN_2_68 +gpointer g_tree_node_value (GTreeNode *node); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_lookup_node (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gpointer g_tree_lookup (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_tree_lookup_extended (GTree *tree, + gconstpointer lookup_key, + gpointer *orig_key, + gpointer *value); +GLIB_AVAILABLE_IN_ALL +void g_tree_foreach (GTree *tree, + GTraverseFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_68 +void g_tree_foreach_node (GTree *tree, + GTraverseNodeFunc func, + gpointer user_data); + +GLIB_DEPRECATED +void g_tree_traverse (GTree *tree, + GTraverseFunc traverse_func, + GTraverseType traverse_type, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_search_node (GTree *tree, + GCompareFunc search_func, + gconstpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_tree_search (GTree *tree, + GCompareFunc search_func, + gconstpointer user_data); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_lower_bound (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_upper_bound (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gint g_tree_height (GTree *tree); +GLIB_AVAILABLE_IN_ALL +gint g_tree_nnodes (GTree *tree); + +#ifdef G_TREE_DEBUG +/*< private >*/ +#ifndef __GTK_DOC_IGNORE__ +void g_tree_dump (GTree *tree); +#endif /* !__GTK_DOC_IGNORE__ */ +#endif /* G_TREE_DEBUG */ + +G_END_DECLS + +#endif /* __G_TREE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gtypes.h b/illumos-x86_64/usr/include/glib-2.0/glib/gtypes.h new file mode 100644 index 00000000..2dba92f1 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gtypes.h @@ -0,0 +1,591 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_TYPES_H__ +#define __G_TYPES_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +/* Must be included after the 3 headers above */ +#include + +#include + +G_BEGIN_DECLS + +/* Provide type definitions for commonly used types. + * These are useful because a "gint8" can be adjusted + * to be 1 byte (8 bits) on all platforms. Similarly and + * more importantly, "gint32" can be adjusted to be + * 4 bytes (32 bits) on all platforms. + */ + +typedef char gchar; +typedef short gshort; +typedef long glong; +typedef int gint; +typedef gint gboolean; + +typedef unsigned char guchar; +typedef unsigned short gushort; +typedef unsigned long gulong; +typedef unsigned int guint; + +typedef float gfloat; +typedef double gdouble; + +/* Define min and max constants for the fixed size numerical types */ +/** + * G_MININT8: (value -128) + * + * The minimum value which can be held in a #gint8. + * + * Since: 2.4 + */ +#define G_MININT8 ((gint8) (-G_MAXINT8 - 1)) +#define G_MAXINT8 ((gint8) 0x7f) +#define G_MAXUINT8 ((guint8) 0xff) + +/** + * G_MININT16: (value -32768) + * + * The minimum value which can be held in a #gint16. + * + * Since: 2.4 + */ +#define G_MININT16 ((gint16) (-G_MAXINT16 - 1)) +#define G_MAXINT16 ((gint16) 0x7fff) +#define G_MAXUINT16 ((guint16) 0xffff) + +/** + * G_MININT32: (value -2147483648) + * + * The minimum value which can be held in a #gint32. + * + * Since: 2.4 + */ +#define G_MININT32 ((gint32) (-G_MAXINT32 - 1)) +#define G_MAXINT32 ((gint32) 0x7fffffff) +#define G_MAXUINT32 ((guint32) 0xffffffff) + +/** + * G_MININT64: (value -9223372036854775808) + * + * The minimum value which can be held in a #gint64. + */ +#define G_MININT64 ((gint64) (-G_MAXINT64 - G_GINT64_CONSTANT(1))) +#define G_MAXINT64 G_GINT64_CONSTANT(0x7fffffffffffffff) +#define G_MAXUINT64 G_GUINT64_CONSTANT(0xffffffffffffffff) + +typedef void* gpointer; +typedef const void *gconstpointer; + +typedef gint (*GCompareFunc) (gconstpointer a, + gconstpointer b); +typedef gint (*GCompareDataFunc) (gconstpointer a, + gconstpointer b, + gpointer user_data); +typedef gboolean (*GEqualFunc) (gconstpointer a, + gconstpointer b); + +/** + * GEqualFuncFull: + * @a: a value + * @b: a value to compare with + * @user_data: user data provided by the caller + * + * Specifies the type of a function used to test two values for + * equality. The function should return %TRUE if both values are equal + * and %FALSE otherwise. + * + * This is a version of #GEqualFunc which provides a @user_data closure from + * the caller. + * + * Returns: %TRUE if @a = @b; %FALSE otherwise + * Since: 2.74 + */ +typedef gboolean (*GEqualFuncFull) (gconstpointer a, + gconstpointer b, + gpointer user_data); + +typedef void (*GDestroyNotify) (gpointer data); +typedef void (*GFunc) (gpointer data, + gpointer user_data); +typedef guint (*GHashFunc) (gconstpointer key); +typedef void (*GHFunc) (gpointer key, + gpointer value, + gpointer user_data); + +/** + * GCopyFunc: + * @src: (not nullable): A pointer to the data which should be copied + * @data: Additional data + * + * A function of this signature is used to copy the node data + * when doing a deep-copy of a tree. + * + * Returns: (not nullable): A pointer to the copy + * + * Since: 2.4 + */ +typedef gpointer (*GCopyFunc) (gconstpointer src, + gpointer data); +/** + * GFreeFunc: + * @data: a data pointer + * + * Declares a type of function which takes an arbitrary + * data pointer argument and has no return value. It is + * not currently used in GLib or GTK. + */ +typedef void (*GFreeFunc) (gpointer data); + +/** + * GTranslateFunc: + * @str: the untranslated string + * @data: user data specified when installing the function, e.g. + * in g_option_group_set_translate_func() + * + * The type of functions which are used to translate user-visible + * strings, for output. + * + * Returns: a translation of the string for the current locale. + * The returned string is owned by GLib and must not be freed. + */ +typedef const gchar * (*GTranslateFunc) (const gchar *str, + gpointer data); + + +/* Define some mathematical constants that aren't available + * symbolically in some strict ISO C implementations. + * + * Note that the large number of digits used in these definitions + * doesn't imply that GLib or current computers in general would be + * able to handle floating point numbers with an accuracy like this. + * It's mostly an exercise in futility and future proofing. For + * extended precision floating point support, look somewhere else + * than GLib. + */ +#define G_E 2.7182818284590452353602874713526624977572470937000 +#define G_LN2 0.69314718055994530941723212145817656807550013436026 +#define G_LN10 2.3025850929940456840179914546843642076011014886288 +#define G_PI 3.1415926535897932384626433832795028841971693993751 +#define G_PI_2 1.5707963267948966192313216916397514420985846996876 +#define G_PI_4 0.78539816339744830961566084581987572104929234984378 +#define G_SQRT2 1.4142135623730950488016887242096980785696718753769 + +/* Portable endian checks and conversions + * + * glibconfig.h defines G_BYTE_ORDER which expands to one of + * the below macros. + */ +#define G_LITTLE_ENDIAN 1234 +#define G_BIG_ENDIAN 4321 +#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */ + + +/* Basic bit swapping functions + */ +#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \ + (guint16) ((guint16) (val) >> 8) | \ + (guint16) ((guint16) (val) << 8))) + +#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ + (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ + (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ + (((guint32) (val) & (guint32) 0xff000000U) >> 24))) + +#define GUINT64_SWAP_LE_BE_CONSTANT(val) ((guint64) ( \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x00000000000000ffU)) << 56) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x000000000000ff00U)) << 40) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x0000000000ff0000U)) << 24) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x00000000ff000000U)) << 8) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x000000ff00000000U)) >> 8) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x0000ff0000000000U)) >> 24) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x00ff000000000000U)) >> 40) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0xff00000000000000U)) >> 56))) + +/* Arch specific stuff for speed + */ +#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) + +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +# define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((guint32) (val))) +# define GUINT64_SWAP_LE_BE(val) ((guint64) __builtin_bswap64 ((guint64) (val))) +# endif + +# if defined (__i386__) +# define GUINT16_SWAP_LE_BE_IA32(val) \ + (G_GNUC_EXTENSION \ + ({ guint16 __v, __x = ((guint16) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("rorw $8, %w0" \ + : "=r" (__v) \ + : "0" (__x) \ + : "cc"); \ + __v; })) +# if !defined (__i486__) && !defined (__i586__) \ + && !defined (__pentium__) && !defined (__i686__) \ + && !defined (__pentiumpro__) && !defined (__pentium4__) +# define GUINT32_SWAP_LE_BE_IA32(val) \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("rorw $8, %w0\n\t" \ + "rorl $16, %0\n\t" \ + "rorw $8, %w0" \ + : "=r" (__v) \ + : "0" (__x) \ + : "cc"); \ + __v; })) +# else /* 486 and higher has bswap */ +# define GUINT32_SWAP_LE_BE_IA32(val) \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("bswap %0" \ + : "=r" (__v) \ + : "0" (__x)); \ + __v; })) +# endif /* processor specific 32-bit stuff */ +# define GUINT64_SWAP_LE_BE_IA32(val) \ + (G_GNUC_EXTENSION \ + ({ union { guint64 __ll; \ + guint32 __l[2]; } __w, __r; \ + __w.__ll = ((guint64) (val)); \ + if (__builtin_constant_p (__w.__ll)) \ + __r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (__w.__ll); \ + else \ + { \ + __r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]); \ + __r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]); \ + } \ + __r.__ll; })) + /* Possibly just use the constant version and let gcc figure it out? */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA32 (val)) +# endif +# elif defined (__ia64__) +# define GUINT16_SWAP_LE_BE_IA64(val) \ + (G_GNUC_EXTENSION \ + ({ guint16 __v, __x = ((guint16) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ __volatile__ ("shl %0 = %1, 48 ;;" \ + "mux1 %0 = %0, @rev ;;" \ + : "=r" (__v) \ + : "r" (__x)); \ + __v; })) +# define GUINT32_SWAP_LE_BE_IA64(val) \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ __volatile__ ("shl %0 = %1, 32 ;;" \ + "mux1 %0 = %0, @rev ;;" \ + : "=r" (__v) \ + : "r" (__x)); \ + __v; })) +# define GUINT64_SWAP_LE_BE_IA64(val) \ + (G_GNUC_EXTENSION \ + ({ guint64 __v, __x = ((guint64) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \ + : "=r" (__v) \ + : "r" (__x)); \ + __v; })) +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA64 (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA64 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA64 (val)) +# endif +# elif defined (__x86_64__) +# define GUINT32_SWAP_LE_BE_X86_64(val) \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("bswapl %0" \ + : "=r" (__v) \ + : "0" (__x)); \ + __v; })) +# define GUINT64_SWAP_LE_BE_X86_64(val) \ + (G_GNUC_EXTENSION \ + ({ guint64 __v, __x = ((guint64) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("bswapq %0" \ + : "=r" (__v) \ + : "0" (__x)); \ + __v; })) + /* gcc seems to figure out optimal code for this on its own */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val)) +# endif +# else /* generic gcc */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val)) +# endif +# endif +#else /* generic */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val)) +#endif /* generic */ + +#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val)) +#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val)) +#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \ + (((guint32) (val) & (guint32) 0xffff0000U) >> 16))) +#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \ + (((guint32) (val) & (guint32) 0xff00ff00U) >> 8))) + +/* The G*_TO_?E() macros are defined in glibconfig.h. + * The transformation is symmetric, so the FROM just maps to the TO. + */ +#define GINT16_FROM_LE(val) (GINT16_TO_LE (val)) +#define GUINT16_FROM_LE(val) (GUINT16_TO_LE (val)) +#define GINT16_FROM_BE(val) (GINT16_TO_BE (val)) +#define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val)) +#define GINT32_FROM_LE(val) (GINT32_TO_LE (val)) +#define GUINT32_FROM_LE(val) (GUINT32_TO_LE (val)) +#define GINT32_FROM_BE(val) (GINT32_TO_BE (val)) +#define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) + +#define GINT64_FROM_LE(val) (GINT64_TO_LE (val)) +#define GUINT64_FROM_LE(val) (GUINT64_TO_LE (val)) +#define GINT64_FROM_BE(val) (GINT64_TO_BE (val)) +#define GUINT64_FROM_BE(val) (GUINT64_TO_BE (val)) + +#define GLONG_FROM_LE(val) (GLONG_TO_LE (val)) +#define GULONG_FROM_LE(val) (GULONG_TO_LE (val)) +#define GLONG_FROM_BE(val) (GLONG_TO_BE (val)) +#define GULONG_FROM_BE(val) (GULONG_TO_BE (val)) + +#define GINT_FROM_LE(val) (GINT_TO_LE (val)) +#define GUINT_FROM_LE(val) (GUINT_TO_LE (val)) +#define GINT_FROM_BE(val) (GINT_TO_BE (val)) +#define GUINT_FROM_BE(val) (GUINT_TO_BE (val)) + +#define GSIZE_FROM_LE(val) (GSIZE_TO_LE (val)) +#define GSSIZE_FROM_LE(val) (GSSIZE_TO_LE (val)) +#define GSIZE_FROM_BE(val) (GSIZE_TO_BE (val)) +#define GSSIZE_FROM_BE(val) (GSSIZE_TO_BE (val)) + +/* Portable versions of host-network order stuff + */ +#define g_ntohl(val) (GUINT32_FROM_BE (val)) +#define g_ntohs(val) (GUINT16_FROM_BE (val)) +#define g_htonl(val) (GUINT32_TO_BE (val)) +#define g_htons(val) (GUINT16_TO_BE (val)) + +/* Overflow-checked unsigned integer arithmetic + */ +#ifndef _GLIB_TEST_OVERFLOW_FALLBACK +/* https://bugzilla.gnome.org/show_bug.cgi?id=769104 */ +#if __GNUC__ >= 5 && !defined(__INTEL_COMPILER) +#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS +#elif g_macro__has_builtin(__builtin_add_overflow) +#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS +#endif +#endif + +#ifdef _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS + +#define g_uint_checked_add(dest, a, b) \ + (!__builtin_add_overflow(a, b, dest)) +#define g_uint_checked_mul(dest, a, b) \ + (!__builtin_mul_overflow(a, b, dest)) + +#define g_uint64_checked_add(dest, a, b) \ + (!__builtin_add_overflow(a, b, dest)) +#define g_uint64_checked_mul(dest, a, b) \ + (!__builtin_mul_overflow(a, b, dest)) + +#define g_size_checked_add(dest, a, b) \ + (!__builtin_add_overflow(a, b, dest)) +#define g_size_checked_mul(dest, a, b) \ + (!__builtin_mul_overflow(a, b, dest)) + +#else /* !_GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS */ + +/* The names of the following inlines are private. Use the macro + * definitions above. + */ +static inline gboolean _GLIB_CHECKED_ADD_UINT (guint *dest, guint a, guint b) { + *dest = a + b; return *dest >= a; } +static inline gboolean _GLIB_CHECKED_MUL_UINT (guint *dest, guint a, guint b) { + *dest = a * b; return !a || *dest / a == b; } +static inline gboolean _GLIB_CHECKED_ADD_UINT64 (guint64 *dest, guint64 a, guint64 b) { + *dest = a + b; return *dest >= a; } +static inline gboolean _GLIB_CHECKED_MUL_UINT64 (guint64 *dest, guint64 a, guint64 b) { + *dest = a * b; return !a || *dest / a == b; } +static inline gboolean _GLIB_CHECKED_ADD_SIZE (gsize *dest, gsize a, gsize b) { + *dest = a + b; return *dest >= a; } +static inline gboolean _GLIB_CHECKED_MUL_SIZE (gsize *dest, gsize a, gsize b) { + *dest = a * b; return !a || *dest / a == b; } + +#define g_uint_checked_add(dest, a, b) \ + _GLIB_CHECKED_ADD_UINT(dest, a, b) +#define g_uint_checked_mul(dest, a, b) \ + _GLIB_CHECKED_MUL_UINT(dest, a, b) + +#define g_uint64_checked_add(dest, a, b) \ + _GLIB_CHECKED_ADD_UINT64(dest, a, b) +#define g_uint64_checked_mul(dest, a, b) \ + _GLIB_CHECKED_MUL_UINT64(dest, a, b) + +#define g_size_checked_add(dest, a, b) \ + _GLIB_CHECKED_ADD_SIZE(dest, a, b) +#define g_size_checked_mul(dest, a, b) \ + _GLIB_CHECKED_MUL_SIZE(dest, a, b) + +#endif /* !_GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS */ + +/* IEEE Standard 754 Single Precision Storage Format (gfloat): + * + * 31 30 23 22 0 + * +--------+---------------+---------------+ + * | s 1bit | e[30:23] 8bit | f[22:0] 23bit | + * +--------+---------------+---------------+ + * B0------------------->B1------->B2-->B3--> + * + * IEEE Standard 754 Double Precision Storage Format (gdouble): + * + * 63 62 52 51 32 31 0 + * +--------+----------------+----------------+ +---------------+ + * | s 1bit | e[62:52] 11bit | f[51:32] 20bit | | f[31:0] 32bit | + * +--------+----------------+----------------+ +---------------+ + * B0--------------->B1---------->B2--->B3----> B4->B5->B6->B7-> + */ +/* subtract from biased_exponent to form base2 exponent (normal numbers) */ +typedef union _GDoubleIEEE754 GDoubleIEEE754; +typedef union _GFloatIEEE754 GFloatIEEE754; +#define G_IEEE754_FLOAT_BIAS (127) +#define G_IEEE754_DOUBLE_BIAS (1023) +/* multiply with base2 exponent to get base10 exponent (normal numbers) */ +#define G_LOG_2_BASE_10 (0.30102999566398119521) +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +union _GFloatIEEE754 +{ + gfloat v_float; + struct { + guint mantissa : 23; + guint biased_exponent : 8; + guint sign : 1; + } mpn; +}; +union _GDoubleIEEE754 +{ + gdouble v_double; + struct { + guint mantissa_low : 32; + guint mantissa_high : 20; + guint biased_exponent : 11; + guint sign : 1; + } mpn; +}; +#elif G_BYTE_ORDER == G_BIG_ENDIAN +union _GFloatIEEE754 +{ + gfloat v_float; + struct { + guint sign : 1; + guint biased_exponent : 8; + guint mantissa : 23; + } mpn; +}; +union _GDoubleIEEE754 +{ + gdouble v_double; + struct { + guint sign : 1; + guint biased_exponent : 11; + guint mantissa_high : 20; + guint mantissa_low : 32; + } mpn; +}; +#else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */ +#error unknown ENDIAN type +#endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */ + +typedef struct _GTimeVal GTimeVal GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); + +struct _GTimeVal +{ + glong tv_sec; + glong tv_usec; +} GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); + +typedef gint grefcount; +typedef gint gatomicrefcount; /* should be accessed only using atomics */ + +G_END_DECLS + +#endif /* __G_TYPES_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gunicode.h b/illumos-x86_64/usr/include/glib-2.0/glib/gunicode.h new file mode 100644 index 00000000..cb8e30b4 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gunicode.h @@ -0,0 +1,1000 @@ +/* gunicode.h - Unicode manipulation functions + * + * Copyright (C) 1999, 2000 Tom Tromey + * Copyright 2000, 2005 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_UNICODE_H__ +#define __G_UNICODE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/** + * gunichar: + * + * A type which can hold any UTF-32 or UCS-4 character code, + * also known as a Unicode code point. + * + * If you want to produce the UTF-8 representation of a #gunichar, + * use g_ucs4_to_utf8(). See also g_utf8_to_ucs4() for the reverse + * process. + * + * To print/scan values of this type as integer, use + * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT. + * + * The notation to express a Unicode code point in running text is + * as a hexadecimal number with four to six digits and uppercase + * letters, prefixed by the string "U+". Leading zeros are omitted, + * unless the code point would have fewer than four hexadecimal digits. + * For example, "U+0041 LATIN CAPITAL LETTER A". To print a code point + * in the U+-notation, use the format string "U+\%04"G_GINT32_FORMAT"X". + * To scan, use the format string "U+\%06"G_GINT32_FORMAT"X". + * + * |[ + * gunichar c; + * sscanf ("U+0041", "U+%06"G_GINT32_FORMAT"X", &c) + * g_print ("Read U+%04"G_GINT32_FORMAT"X", c); + * ]| + */ +typedef guint32 gunichar; + +/** + * gunichar2: + * + * A type which can hold any UTF-16 code + * pointUTF-16 also has so called + * surrogate pairs to encode characters beyond + * the BMP as pairs of 16bit numbers. Surrogate pairs cannot be stored + * in a single gunichar2 field, but all GLib functions accepting gunichar2 + * arrays will correctly interpret surrogate pairs.. + * + * To print/scan values of this type to/from text you need to convert + * to/from UTF-8, using g_utf16_to_utf8()/g_utf8_to_utf16(). + * + * To print/scan values of this type as integer, use + * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT. + */ +typedef guint16 gunichar2; + +/** + * GUnicodeType: + * @G_UNICODE_CONTROL: General category "Other, Control" (Cc) + * @G_UNICODE_FORMAT: General category "Other, Format" (Cf) + * @G_UNICODE_UNASSIGNED: General category "Other, Not Assigned" (Cn) + * @G_UNICODE_PRIVATE_USE: General category "Other, Private Use" (Co) + * @G_UNICODE_SURROGATE: General category "Other, Surrogate" (Cs) + * @G_UNICODE_LOWERCASE_LETTER: General category "Letter, Lowercase" (Ll) + * @G_UNICODE_MODIFIER_LETTER: General category "Letter, Modifier" (Lm) + * @G_UNICODE_OTHER_LETTER: General category "Letter, Other" (Lo) + * @G_UNICODE_TITLECASE_LETTER: General category "Letter, Titlecase" (Lt) + * @G_UNICODE_UPPERCASE_LETTER: General category "Letter, Uppercase" (Lu) + * @G_UNICODE_SPACING_MARK: General category "Mark, Spacing" (Mc) + * @G_UNICODE_ENCLOSING_MARK: General category "Mark, Enclosing" (Me) + * @G_UNICODE_NON_SPACING_MARK: General category "Mark, Nonspacing" (Mn) + * @G_UNICODE_DECIMAL_NUMBER: General category "Number, Decimal Digit" (Nd) + * @G_UNICODE_LETTER_NUMBER: General category "Number, Letter" (Nl) + * @G_UNICODE_OTHER_NUMBER: General category "Number, Other" (No) + * @G_UNICODE_CONNECT_PUNCTUATION: General category "Punctuation, Connector" (Pc) + * @G_UNICODE_DASH_PUNCTUATION: General category "Punctuation, Dash" (Pd) + * @G_UNICODE_CLOSE_PUNCTUATION: General category "Punctuation, Close" (Pe) + * @G_UNICODE_FINAL_PUNCTUATION: General category "Punctuation, Final quote" (Pf) + * @G_UNICODE_INITIAL_PUNCTUATION: General category "Punctuation, Initial quote" (Pi) + * @G_UNICODE_OTHER_PUNCTUATION: General category "Punctuation, Other" (Po) + * @G_UNICODE_OPEN_PUNCTUATION: General category "Punctuation, Open" (Ps) + * @G_UNICODE_CURRENCY_SYMBOL: General category "Symbol, Currency" (Sc) + * @G_UNICODE_MODIFIER_SYMBOL: General category "Symbol, Modifier" (Sk) + * @G_UNICODE_MATH_SYMBOL: General category "Symbol, Math" (Sm) + * @G_UNICODE_OTHER_SYMBOL: General category "Symbol, Other" (So) + * @G_UNICODE_LINE_SEPARATOR: General category "Separator, Line" (Zl) + * @G_UNICODE_PARAGRAPH_SEPARATOR: General category "Separator, Paragraph" (Zp) + * @G_UNICODE_SPACE_SEPARATOR: General category "Separator, Space" (Zs) + * + * These are the possible character classifications from the + * Unicode specification. + * See [Unicode Character Database](http://www.unicode.org/reports/tr44/#General_Category_Values). + */ +typedef enum +{ + G_UNICODE_CONTROL, + G_UNICODE_FORMAT, + G_UNICODE_UNASSIGNED, + G_UNICODE_PRIVATE_USE, + G_UNICODE_SURROGATE, + G_UNICODE_LOWERCASE_LETTER, + G_UNICODE_MODIFIER_LETTER, + G_UNICODE_OTHER_LETTER, + G_UNICODE_TITLECASE_LETTER, + G_UNICODE_UPPERCASE_LETTER, + G_UNICODE_SPACING_MARK, + G_UNICODE_ENCLOSING_MARK, + G_UNICODE_NON_SPACING_MARK, + G_UNICODE_DECIMAL_NUMBER, + G_UNICODE_LETTER_NUMBER, + G_UNICODE_OTHER_NUMBER, + G_UNICODE_CONNECT_PUNCTUATION, + G_UNICODE_DASH_PUNCTUATION, + G_UNICODE_CLOSE_PUNCTUATION, + G_UNICODE_FINAL_PUNCTUATION, + G_UNICODE_INITIAL_PUNCTUATION, + G_UNICODE_OTHER_PUNCTUATION, + G_UNICODE_OPEN_PUNCTUATION, + G_UNICODE_CURRENCY_SYMBOL, + G_UNICODE_MODIFIER_SYMBOL, + G_UNICODE_MATH_SYMBOL, + G_UNICODE_OTHER_SYMBOL, + G_UNICODE_LINE_SEPARATOR, + G_UNICODE_PARAGRAPH_SEPARATOR, + G_UNICODE_SPACE_SEPARATOR +} GUnicodeType; + +/** + * G_UNICODE_COMBINING_MARK: + * + * Older name for %G_UNICODE_SPACING_MARK. + * + * Deprecated: 2.30: Use %G_UNICODE_SPACING_MARK. + */ +#define G_UNICODE_COMBINING_MARK G_UNICODE_SPACING_MARK GLIB_DEPRECATED_MACRO_IN_2_30_FOR(G_UNICODE_SPACING_MARK) + +/** + * GUnicodeBreakType: + * @G_UNICODE_BREAK_MANDATORY: Mandatory Break (BK) + * @G_UNICODE_BREAK_CARRIAGE_RETURN: Carriage Return (CR) + * @G_UNICODE_BREAK_LINE_FEED: Line Feed (LF) + * @G_UNICODE_BREAK_COMBINING_MARK: Attached Characters and Combining Marks (CM) + * @G_UNICODE_BREAK_SURROGATE: Surrogates (SG) + * @G_UNICODE_BREAK_ZERO_WIDTH_SPACE: Zero Width Space (ZW) + * @G_UNICODE_BREAK_INSEPARABLE: Inseparable (IN) + * @G_UNICODE_BREAK_NON_BREAKING_GLUE: Non-breaking ("Glue") (GL) + * @G_UNICODE_BREAK_CONTINGENT: Contingent Break Opportunity (CB) + * @G_UNICODE_BREAK_SPACE: Space (SP) + * @G_UNICODE_BREAK_AFTER: Break Opportunity After (BA) + * @G_UNICODE_BREAK_BEFORE: Break Opportunity Before (BB) + * @G_UNICODE_BREAK_BEFORE_AND_AFTER: Break Opportunity Before and After (B2) + * @G_UNICODE_BREAK_HYPHEN: Hyphen (HY) + * @G_UNICODE_BREAK_NON_STARTER: Nonstarter (NS) + * @G_UNICODE_BREAK_OPEN_PUNCTUATION: Opening Punctuation (OP) + * @G_UNICODE_BREAK_CLOSE_PUNCTUATION: Closing Punctuation (CL) + * @G_UNICODE_BREAK_QUOTATION: Ambiguous Quotation (QU) + * @G_UNICODE_BREAK_EXCLAMATION: Exclamation/Interrogation (EX) + * @G_UNICODE_BREAK_IDEOGRAPHIC: Ideographic (ID) + * @G_UNICODE_BREAK_NUMERIC: Numeric (NU) + * @G_UNICODE_BREAK_INFIX_SEPARATOR: Infix Separator (Numeric) (IS) + * @G_UNICODE_BREAK_SYMBOL: Symbols Allowing Break After (SY) + * @G_UNICODE_BREAK_ALPHABETIC: Ordinary Alphabetic and Symbol Characters (AL) + * @G_UNICODE_BREAK_PREFIX: Prefix (Numeric) (PR) + * @G_UNICODE_BREAK_POSTFIX: Postfix (Numeric) (PO) + * @G_UNICODE_BREAK_COMPLEX_CONTEXT: Complex Content Dependent (South East Asian) (SA) + * @G_UNICODE_BREAK_AMBIGUOUS: Ambiguous (Alphabetic or Ideographic) (AI) + * @G_UNICODE_BREAK_UNKNOWN: Unknown (XX) + * @G_UNICODE_BREAK_NEXT_LINE: Next Line (NL) + * @G_UNICODE_BREAK_WORD_JOINER: Word Joiner (WJ) + * @G_UNICODE_BREAK_HANGUL_L_JAMO: Hangul L Jamo (JL) + * @G_UNICODE_BREAK_HANGUL_V_JAMO: Hangul V Jamo (JV) + * @G_UNICODE_BREAK_HANGUL_T_JAMO: Hangul T Jamo (JT) + * @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE: Hangul LV Syllable (H2) + * @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE: Hangul LVT Syllable (H3) + * @G_UNICODE_BREAK_CLOSE_PARANTHESIS: Closing Parenthesis (CP). Since 2.28. Deprecated: 2.70: Use %G_UNICODE_BREAK_CLOSE_PARENTHESIS instead. + * @G_UNICODE_BREAK_CLOSE_PARENTHESIS: Closing Parenthesis (CP). Since 2.70 + * @G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER: Conditional Japanese Starter (CJ). Since: 2.32 + * @G_UNICODE_BREAK_HEBREW_LETTER: Hebrew Letter (HL). Since: 2.32 + * @G_UNICODE_BREAK_REGIONAL_INDICATOR: Regional Indicator (RI). Since: 2.36 + * @G_UNICODE_BREAK_EMOJI_BASE: Emoji Base (EB). Since: 2.50 + * @G_UNICODE_BREAK_EMOJI_MODIFIER: Emoji Modifier (EM). Since: 2.50 + * @G_UNICODE_BREAK_ZERO_WIDTH_JOINER: Zero Width Joiner (ZWJ). Since: 2.50 + * @G_UNICODE_BREAK_AKSARA: Aksara (AK). Since: 2.80 + * @G_UNICODE_BREAK_AKSARA_PRE_BASE: Aksara Pre-Base (AP). Since: 2.80 + * @G_UNICODE_BREAK_AKSARA_START: Aksara Start (AS). Since: 2.80 + * @G_UNICODE_BREAK_VIRAMA_FINAL: Virama Final (VF). Since: 2.80 + * @G_UNICODE_BREAK_VIRAMA: Virama (VI). Since: 2.80 + * + * These are the possible line break classifications. + * + * Since new Unicode versions may add new types here, applications should be ready + * to handle unknown values. They may be regarded as %G_UNICODE_BREAK_UNKNOWN. + * + * See [Unicode Line Breaking Algorithm](https://www.unicode.org/reports/tr14/). + */ +typedef enum +{ + G_UNICODE_BREAK_MANDATORY, + G_UNICODE_BREAK_CARRIAGE_RETURN, + G_UNICODE_BREAK_LINE_FEED, + G_UNICODE_BREAK_COMBINING_MARK, + G_UNICODE_BREAK_SURROGATE, + G_UNICODE_BREAK_ZERO_WIDTH_SPACE, + G_UNICODE_BREAK_INSEPARABLE, + G_UNICODE_BREAK_NON_BREAKING_GLUE, + G_UNICODE_BREAK_CONTINGENT, + G_UNICODE_BREAK_SPACE, + G_UNICODE_BREAK_AFTER, + G_UNICODE_BREAK_BEFORE, + G_UNICODE_BREAK_BEFORE_AND_AFTER, + G_UNICODE_BREAK_HYPHEN, + G_UNICODE_BREAK_NON_STARTER, + G_UNICODE_BREAK_OPEN_PUNCTUATION, + G_UNICODE_BREAK_CLOSE_PUNCTUATION, + G_UNICODE_BREAK_QUOTATION, + G_UNICODE_BREAK_EXCLAMATION, + G_UNICODE_BREAK_IDEOGRAPHIC, + G_UNICODE_BREAK_NUMERIC, + G_UNICODE_BREAK_INFIX_SEPARATOR, + G_UNICODE_BREAK_SYMBOL, + G_UNICODE_BREAK_ALPHABETIC, + G_UNICODE_BREAK_PREFIX, + G_UNICODE_BREAK_POSTFIX, + G_UNICODE_BREAK_COMPLEX_CONTEXT, + G_UNICODE_BREAK_AMBIGUOUS, + G_UNICODE_BREAK_UNKNOWN, + G_UNICODE_BREAK_NEXT_LINE, + G_UNICODE_BREAK_WORD_JOINER, + G_UNICODE_BREAK_HANGUL_L_JAMO, + G_UNICODE_BREAK_HANGUL_V_JAMO, + G_UNICODE_BREAK_HANGUL_T_JAMO, + G_UNICODE_BREAK_HANGUL_LV_SYLLABLE, + G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE, + G_UNICODE_BREAK_CLOSE_PARANTHESIS, + G_UNICODE_BREAK_CLOSE_PARENTHESIS GLIB_AVAILABLE_ENUMERATOR_IN_2_70 = G_UNICODE_BREAK_CLOSE_PARANTHESIS, + G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER, + G_UNICODE_BREAK_HEBREW_LETTER, + G_UNICODE_BREAK_REGIONAL_INDICATOR, + G_UNICODE_BREAK_EMOJI_BASE, + G_UNICODE_BREAK_EMOJI_MODIFIER, + G_UNICODE_BREAK_ZERO_WIDTH_JOINER, + G_UNICODE_BREAK_AKSARA, + G_UNICODE_BREAK_AKSARA_PRE_BASE, + G_UNICODE_BREAK_AKSARA_START, + G_UNICODE_BREAK_VIRAMA_FINAL, + G_UNICODE_BREAK_VIRAMA +} GUnicodeBreakType; + +/** + * GUnicodeScript: + * @G_UNICODE_SCRIPT_INVALID_CODE: + * a value never returned from g_unichar_get_script() + * @G_UNICODE_SCRIPT_COMMON: a character used by multiple different scripts + * @G_UNICODE_SCRIPT_INHERITED: a mark glyph that takes its script from the + * base glyph to which it is attached + * @G_UNICODE_SCRIPT_ARABIC: Arabic + * @G_UNICODE_SCRIPT_ARMENIAN: Armenian + * @G_UNICODE_SCRIPT_BENGALI: Bengali + * @G_UNICODE_SCRIPT_BOPOMOFO: Bopomofo + * @G_UNICODE_SCRIPT_CHEROKEE: Cherokee + * @G_UNICODE_SCRIPT_COPTIC: Coptic + * @G_UNICODE_SCRIPT_CYRILLIC: Cyrillic + * @G_UNICODE_SCRIPT_DESERET: Deseret + * @G_UNICODE_SCRIPT_DEVANAGARI: Devanagari + * @G_UNICODE_SCRIPT_ETHIOPIC: Ethiopic + * @G_UNICODE_SCRIPT_GEORGIAN: Georgian + * @G_UNICODE_SCRIPT_GOTHIC: Gothic + * @G_UNICODE_SCRIPT_GREEK: Greek + * @G_UNICODE_SCRIPT_GUJARATI: Gujarati + * @G_UNICODE_SCRIPT_GURMUKHI: Gurmukhi + * @G_UNICODE_SCRIPT_HAN: Han + * @G_UNICODE_SCRIPT_HANGUL: Hangul + * @G_UNICODE_SCRIPT_HEBREW: Hebrew + * @G_UNICODE_SCRIPT_HIRAGANA: Hiragana + * @G_UNICODE_SCRIPT_KANNADA: Kannada + * @G_UNICODE_SCRIPT_KATAKANA: Katakana + * @G_UNICODE_SCRIPT_KHMER: Khmer + * @G_UNICODE_SCRIPT_LAO: Lao + * @G_UNICODE_SCRIPT_LATIN: Latin + * @G_UNICODE_SCRIPT_MALAYALAM: Malayalam + * @G_UNICODE_SCRIPT_MONGOLIAN: Mongolian + * @G_UNICODE_SCRIPT_MYANMAR: Myanmar + * @G_UNICODE_SCRIPT_OGHAM: Ogham + * @G_UNICODE_SCRIPT_OLD_ITALIC: Old Italic + * @G_UNICODE_SCRIPT_ORIYA: Oriya + * @G_UNICODE_SCRIPT_RUNIC: Runic + * @G_UNICODE_SCRIPT_SINHALA: Sinhala + * @G_UNICODE_SCRIPT_SYRIAC: Syriac + * @G_UNICODE_SCRIPT_TAMIL: Tamil + * @G_UNICODE_SCRIPT_TELUGU: Telugu + * @G_UNICODE_SCRIPT_THAANA: Thaana + * @G_UNICODE_SCRIPT_THAI: Thai + * @G_UNICODE_SCRIPT_TIBETAN: Tibetan + * @G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL: + * Canadian Aboriginal + * @G_UNICODE_SCRIPT_YI: Yi + * @G_UNICODE_SCRIPT_TAGALOG: Tagalog + * @G_UNICODE_SCRIPT_HANUNOO: Hanunoo + * @G_UNICODE_SCRIPT_BUHID: Buhid + * @G_UNICODE_SCRIPT_TAGBANWA: Tagbanwa + * @G_UNICODE_SCRIPT_BRAILLE: Braille + * @G_UNICODE_SCRIPT_CYPRIOT: Cypriot + * @G_UNICODE_SCRIPT_LIMBU: Limbu + * @G_UNICODE_SCRIPT_OSMANYA: Osmanya + * @G_UNICODE_SCRIPT_SHAVIAN: Shavian + * @G_UNICODE_SCRIPT_LINEAR_B: Linear B + * @G_UNICODE_SCRIPT_TAI_LE: Tai Le + * @G_UNICODE_SCRIPT_UGARITIC: Ugaritic + * @G_UNICODE_SCRIPT_NEW_TAI_LUE: + * New Tai Lue + * @G_UNICODE_SCRIPT_BUGINESE: Buginese + * @G_UNICODE_SCRIPT_GLAGOLITIC: Glagolitic + * @G_UNICODE_SCRIPT_TIFINAGH: Tifinagh + * @G_UNICODE_SCRIPT_SYLOTI_NAGRI: + * Syloti Nagri + * @G_UNICODE_SCRIPT_OLD_PERSIAN: + * Old Persian + * @G_UNICODE_SCRIPT_KHAROSHTHI: Kharoshthi + * @G_UNICODE_SCRIPT_UNKNOWN: an unassigned code point + * @G_UNICODE_SCRIPT_BALINESE: Balinese + * @G_UNICODE_SCRIPT_CUNEIFORM: Cuneiform + * @G_UNICODE_SCRIPT_PHOENICIAN: Phoenician + * @G_UNICODE_SCRIPT_PHAGS_PA: Phags-pa + * @G_UNICODE_SCRIPT_NKO: N'Ko + * @G_UNICODE_SCRIPT_KAYAH_LI: Kayah Li. Since 2.16.3 + * @G_UNICODE_SCRIPT_LEPCHA: Lepcha. Since 2.16.3 + * @G_UNICODE_SCRIPT_REJANG: Rejang. Since 2.16.3 + * @G_UNICODE_SCRIPT_SUNDANESE: Sundanese. Since 2.16.3 + * @G_UNICODE_SCRIPT_SAURASHTRA: Saurashtra. Since 2.16.3 + * @G_UNICODE_SCRIPT_CHAM: Cham. Since 2.16.3 + * @G_UNICODE_SCRIPT_OL_CHIKI: Ol Chiki. Since 2.16.3 + * @G_UNICODE_SCRIPT_VAI: Vai. Since 2.16.3 + * @G_UNICODE_SCRIPT_CARIAN: Carian. Since 2.16.3 + * @G_UNICODE_SCRIPT_LYCIAN: Lycian. Since 2.16.3 + * @G_UNICODE_SCRIPT_LYDIAN: Lydian. Since 2.16.3 + * @G_UNICODE_SCRIPT_AVESTAN: Avestan. Since 2.26 + * @G_UNICODE_SCRIPT_BAMUM: Bamum. Since 2.26 + * @G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS: + * Egyptian Hieroglpyhs. Since 2.26 + * @G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC: + * Imperial Aramaic. Since 2.26 + * @G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI: + * Inscriptional Pahlavi. Since 2.26 + * @G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN: + * Inscriptional Parthian. Since 2.26 + * @G_UNICODE_SCRIPT_JAVANESE: Javanese. Since 2.26 + * @G_UNICODE_SCRIPT_KAITHI: Kaithi. Since 2.26 + * @G_UNICODE_SCRIPT_LISU: Lisu. Since 2.26 + * @G_UNICODE_SCRIPT_MEETEI_MAYEK: + * Meetei Mayek. Since 2.26 + * @G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN: + * Old South Arabian. Since 2.26 + * @G_UNICODE_SCRIPT_OLD_TURKIC: Old Turkic. Since 2.28 + * @G_UNICODE_SCRIPT_SAMARITAN: Samaritan. Since 2.26 + * @G_UNICODE_SCRIPT_TAI_THAM: Tai Tham. Since 2.26 + * @G_UNICODE_SCRIPT_TAI_VIET: Tai Viet. Since 2.26 + * @G_UNICODE_SCRIPT_BATAK: Batak. Since 2.28 + * @G_UNICODE_SCRIPT_BRAHMI: Brahmi. Since 2.28 + * @G_UNICODE_SCRIPT_MANDAIC: Mandaic. Since 2.28 + * @G_UNICODE_SCRIPT_CHAKMA: Chakma. Since: 2.32 + * @G_UNICODE_SCRIPT_MEROITIC_CURSIVE: Meroitic Cursive. Since: 2.32 + * @G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS: Meroitic Hieroglyphs. Since: 2.32 + * @G_UNICODE_SCRIPT_MIAO: Miao. Since: 2.32 + * @G_UNICODE_SCRIPT_SHARADA: Sharada. Since: 2.32 + * @G_UNICODE_SCRIPT_SORA_SOMPENG: Sora Sompeng. Since: 2.32 + * @G_UNICODE_SCRIPT_TAKRI: Takri. Since: 2.32 + * @G_UNICODE_SCRIPT_BASSA_VAH: Bassa. Since: 2.42 + * @G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN: Caucasian Albanian. Since: 2.42 + * @G_UNICODE_SCRIPT_DUPLOYAN: Duployan. Since: 2.42 + * @G_UNICODE_SCRIPT_ELBASAN: Elbasan. Since: 2.42 + * @G_UNICODE_SCRIPT_GRANTHA: Grantha. Since: 2.42 + * @G_UNICODE_SCRIPT_KHOJKI: Kjohki. Since: 2.42 + * @G_UNICODE_SCRIPT_KHUDAWADI: Khudawadi, Sindhi. Since: 2.42 + * @G_UNICODE_SCRIPT_LINEAR_A: Linear A. Since: 2.42 + * @G_UNICODE_SCRIPT_MAHAJANI: Mahajani. Since: 2.42 + * @G_UNICODE_SCRIPT_MANICHAEAN: Manichaean. Since: 2.42 + * @G_UNICODE_SCRIPT_MENDE_KIKAKUI: Mende Kikakui. Since: 2.42 + * @G_UNICODE_SCRIPT_MODI: Modi. Since: 2.42 + * @G_UNICODE_SCRIPT_MRO: Mro. Since: 2.42 + * @G_UNICODE_SCRIPT_NABATAEAN: Nabataean. Since: 2.42 + * @G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN: Old North Arabian. Since: 2.42 + * @G_UNICODE_SCRIPT_OLD_PERMIC: Old Permic. Since: 2.42 + * @G_UNICODE_SCRIPT_PAHAWH_HMONG: Pahawh Hmong. Since: 2.42 + * @G_UNICODE_SCRIPT_PALMYRENE: Palmyrene. Since: 2.42 + * @G_UNICODE_SCRIPT_PAU_CIN_HAU: Pau Cin Hau. Since: 2.42 + * @G_UNICODE_SCRIPT_PSALTER_PAHLAVI: Psalter Pahlavi. Since: 2.42 + * @G_UNICODE_SCRIPT_SIDDHAM: Siddham. Since: 2.42 + * @G_UNICODE_SCRIPT_TIRHUTA: Tirhuta. Since: 2.42 + * @G_UNICODE_SCRIPT_WARANG_CITI: Warang Citi. Since: 2.42 + * @G_UNICODE_SCRIPT_AHOM: Ahom. Since: 2.48 + * @G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS: Anatolian Hieroglyphs. Since: 2.48 + * @G_UNICODE_SCRIPT_HATRAN: Hatran. Since: 2.48 + * @G_UNICODE_SCRIPT_MULTANI: Multani. Since: 2.48 + * @G_UNICODE_SCRIPT_OLD_HUNGARIAN: Old Hungarian. Since: 2.48 + * @G_UNICODE_SCRIPT_SIGNWRITING: Signwriting. Since: 2.48 + * @G_UNICODE_SCRIPT_ADLAM: Adlam. Since: 2.50 + * @G_UNICODE_SCRIPT_BHAIKSUKI: Bhaiksuki. Since: 2.50 + * @G_UNICODE_SCRIPT_MARCHEN: Marchen. Since: 2.50 + * @G_UNICODE_SCRIPT_NEWA: Newa. Since: 2.50 + * @G_UNICODE_SCRIPT_OSAGE: Osage. Since: 2.50 + * @G_UNICODE_SCRIPT_TANGUT: Tangut. Since: 2.50 + * @G_UNICODE_SCRIPT_MASARAM_GONDI: Masaram Gondi. Since: 2.54 + * @G_UNICODE_SCRIPT_NUSHU: Nushu. Since: 2.54 + * @G_UNICODE_SCRIPT_SOYOMBO: Soyombo. Since: 2.54 + * @G_UNICODE_SCRIPT_ZANABAZAR_SQUARE: Zanabazar Square. Since: 2.54 + * @G_UNICODE_SCRIPT_DOGRA: Dogra. Since: 2.58 + * @G_UNICODE_SCRIPT_GUNJALA_GONDI: Gunjala Gondi. Since: 2.58 + * @G_UNICODE_SCRIPT_HANIFI_ROHINGYA: Hanifi Rohingya. Since: 2.58 + * @G_UNICODE_SCRIPT_MAKASAR: Makasar. Since: 2.58 + * @G_UNICODE_SCRIPT_MEDEFAIDRIN: Medefaidrin. Since: 2.58 + * @G_UNICODE_SCRIPT_OLD_SOGDIAN: Old Sogdian. Since: 2.58 + * @G_UNICODE_SCRIPT_SOGDIAN: Sogdian. Since: 2.58 + * @G_UNICODE_SCRIPT_ELYMAIC: Elym. Since: 2.62 + * @G_UNICODE_SCRIPT_NANDINAGARI: Nand. Since: 2.62 + * @G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG: Rohg. Since: 2.62 + * @G_UNICODE_SCRIPT_WANCHO: Wcho. Since: 2.62 + * @G_UNICODE_SCRIPT_CHORASMIAN: Chorasmian. Since: 2.66 + * @G_UNICODE_SCRIPT_DIVES_AKURU: Dives Akuru. Since: 2.66 + * @G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT: Khitan small script. Since: 2.66 + * @G_UNICODE_SCRIPT_YEZIDI: Yezidi. Since: 2.66 + * @G_UNICODE_SCRIPT_CYPRO_MINOAN: Cypro-Minoan. Since: 2.72 + * @G_UNICODE_SCRIPT_OLD_UYGHUR: Old Uyghur. Since: 2.72 + * @G_UNICODE_SCRIPT_TANGSA: Tangsa. Since: 2.72 + * @G_UNICODE_SCRIPT_TOTO: Toto. Since: 2.72 + * @G_UNICODE_SCRIPT_VITHKUQI: Vithkuqi. Since: 2.72 + * @G_UNICODE_SCRIPT_MATH: Mathematical notation. Since: 2.72 + * @G_UNICODE_SCRIPT_KAWI: Kawi. Since 2.74 + * @G_UNICODE_SCRIPT_NAG_MUNDARI: Nag Mundari. Since 2.74 + * @G_UNICODE_SCRIPT_TODHRI: Todhri. Since: 2.84 + * @G_UNICODE_SCRIPT_GARAY: Garay. Since: 2.84 + * @G_UNICODE_SCRIPT_TULU_TIGALARI: Tulu-Tigalari. Since: 2.84 + * @G_UNICODE_SCRIPT_SUNUWAR: Sunuwar. Since: 2.84 + * @G_UNICODE_SCRIPT_GURUNG_KHEMA: Gurung Khema. Since: 2.84 + * @G_UNICODE_SCRIPT_KIRAT_RAI: Kirat Rai. Since: 2.84 + * @G_UNICODE_SCRIPT_OL_ONAL: Ol Onal. Since: 2.84 + * + * The #GUnicodeScript enumeration identifies different writing + * systems. The values correspond to the names as defined in the + * Unicode standard. The enumeration has been added in GLib 2.14, + * and is interchangeable with #PangoScript. + * + * Note that new types may be added in the future. Applications + * should be ready to handle unknown values. + * See [Unicode Standard Annex #24: Script names](http://www.unicode.org/reports/tr24/). + */ +typedef enum +{ /* ISO 15924 code */ + G_UNICODE_SCRIPT_INVALID_CODE = -1, + G_UNICODE_SCRIPT_COMMON = 0, /* Zyyy */ + G_UNICODE_SCRIPT_INHERITED, /* Zinh (Qaai) */ + G_UNICODE_SCRIPT_ARABIC, /* Arab */ + G_UNICODE_SCRIPT_ARMENIAN, /* Armn */ + G_UNICODE_SCRIPT_BENGALI, /* Beng */ + G_UNICODE_SCRIPT_BOPOMOFO, /* Bopo */ + G_UNICODE_SCRIPT_CHEROKEE, /* Cher */ + G_UNICODE_SCRIPT_COPTIC, /* Copt (Qaac) */ + G_UNICODE_SCRIPT_CYRILLIC, /* Cyrl (Cyrs) */ + G_UNICODE_SCRIPT_DESERET, /* Dsrt */ + G_UNICODE_SCRIPT_DEVANAGARI, /* Deva */ + G_UNICODE_SCRIPT_ETHIOPIC, /* Ethi */ + G_UNICODE_SCRIPT_GEORGIAN, /* Geor (Geon, Geoa) */ + G_UNICODE_SCRIPT_GOTHIC, /* Goth */ + G_UNICODE_SCRIPT_GREEK, /* Grek */ + G_UNICODE_SCRIPT_GUJARATI, /* Gujr */ + G_UNICODE_SCRIPT_GURMUKHI, /* Guru */ + G_UNICODE_SCRIPT_HAN, /* Hani */ + G_UNICODE_SCRIPT_HANGUL, /* Hang */ + G_UNICODE_SCRIPT_HEBREW, /* Hebr */ + G_UNICODE_SCRIPT_HIRAGANA, /* Hira */ + G_UNICODE_SCRIPT_KANNADA, /* Knda */ + G_UNICODE_SCRIPT_KATAKANA, /* Kana */ + G_UNICODE_SCRIPT_KHMER, /* Khmr */ + G_UNICODE_SCRIPT_LAO, /* Laoo */ + G_UNICODE_SCRIPT_LATIN, /* Latn (Latf, Latg) */ + G_UNICODE_SCRIPT_MALAYALAM, /* Mlym */ + G_UNICODE_SCRIPT_MONGOLIAN, /* Mong */ + G_UNICODE_SCRIPT_MYANMAR, /* Mymr */ + G_UNICODE_SCRIPT_OGHAM, /* Ogam */ + G_UNICODE_SCRIPT_OLD_ITALIC, /* Ital */ + G_UNICODE_SCRIPT_ORIYA, /* Orya */ + G_UNICODE_SCRIPT_RUNIC, /* Runr */ + G_UNICODE_SCRIPT_SINHALA, /* Sinh */ + G_UNICODE_SCRIPT_SYRIAC, /* Syrc (Syrj, Syrn, Syre) */ + G_UNICODE_SCRIPT_TAMIL, /* Taml */ + G_UNICODE_SCRIPT_TELUGU, /* Telu */ + G_UNICODE_SCRIPT_THAANA, /* Thaa */ + G_UNICODE_SCRIPT_THAI, /* Thai */ + G_UNICODE_SCRIPT_TIBETAN, /* Tibt */ + G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL, /* Cans */ + G_UNICODE_SCRIPT_YI, /* Yiii */ + G_UNICODE_SCRIPT_TAGALOG, /* Tglg */ + G_UNICODE_SCRIPT_HANUNOO, /* Hano */ + G_UNICODE_SCRIPT_BUHID, /* Buhd */ + G_UNICODE_SCRIPT_TAGBANWA, /* Tagb */ + + /* Unicode-4.0 additions */ + G_UNICODE_SCRIPT_BRAILLE, /* Brai */ + G_UNICODE_SCRIPT_CYPRIOT, /* Cprt */ + G_UNICODE_SCRIPT_LIMBU, /* Limb */ + G_UNICODE_SCRIPT_OSMANYA, /* Osma */ + G_UNICODE_SCRIPT_SHAVIAN, /* Shaw */ + G_UNICODE_SCRIPT_LINEAR_B, /* Linb */ + G_UNICODE_SCRIPT_TAI_LE, /* Tale */ + G_UNICODE_SCRIPT_UGARITIC, /* Ugar */ + + /* Unicode-4.1 additions */ + G_UNICODE_SCRIPT_NEW_TAI_LUE, /* Talu */ + G_UNICODE_SCRIPT_BUGINESE, /* Bugi */ + G_UNICODE_SCRIPT_GLAGOLITIC, /* Glag */ + G_UNICODE_SCRIPT_TIFINAGH, /* Tfng */ + G_UNICODE_SCRIPT_SYLOTI_NAGRI, /* Sylo */ + G_UNICODE_SCRIPT_OLD_PERSIAN, /* Xpeo */ + G_UNICODE_SCRIPT_KHAROSHTHI, /* Khar */ + + /* Unicode-5.0 additions */ + G_UNICODE_SCRIPT_UNKNOWN, /* Zzzz */ + G_UNICODE_SCRIPT_BALINESE, /* Bali */ + G_UNICODE_SCRIPT_CUNEIFORM, /* Xsux */ + G_UNICODE_SCRIPT_PHOENICIAN, /* Phnx */ + G_UNICODE_SCRIPT_PHAGS_PA, /* Phag */ + G_UNICODE_SCRIPT_NKO, /* Nkoo */ + + /* Unicode-5.1 additions */ + G_UNICODE_SCRIPT_KAYAH_LI, /* Kali */ + G_UNICODE_SCRIPT_LEPCHA, /* Lepc */ + G_UNICODE_SCRIPT_REJANG, /* Rjng */ + G_UNICODE_SCRIPT_SUNDANESE, /* Sund */ + G_UNICODE_SCRIPT_SAURASHTRA, /* Saur */ + G_UNICODE_SCRIPT_CHAM, /* Cham */ + G_UNICODE_SCRIPT_OL_CHIKI, /* Olck */ + G_UNICODE_SCRIPT_VAI, /* Vaii */ + G_UNICODE_SCRIPT_CARIAN, /* Cari */ + G_UNICODE_SCRIPT_LYCIAN, /* Lyci */ + G_UNICODE_SCRIPT_LYDIAN, /* Lydi */ + + /* Unicode-5.2 additions */ + G_UNICODE_SCRIPT_AVESTAN, /* Avst */ + G_UNICODE_SCRIPT_BAMUM, /* Bamu */ + G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, /* Egyp */ + G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC, /* Armi */ + G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI, /* Phli */ + G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN, /* Prti */ + G_UNICODE_SCRIPT_JAVANESE, /* Java */ + G_UNICODE_SCRIPT_KAITHI, /* Kthi */ + G_UNICODE_SCRIPT_LISU, /* Lisu */ + G_UNICODE_SCRIPT_MEETEI_MAYEK, /* Mtei */ + G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN, /* Sarb */ + G_UNICODE_SCRIPT_OLD_TURKIC, /* Orkh */ + G_UNICODE_SCRIPT_SAMARITAN, /* Samr */ + G_UNICODE_SCRIPT_TAI_THAM, /* Lana */ + G_UNICODE_SCRIPT_TAI_VIET, /* Tavt */ + + /* Unicode-6.0 additions */ + G_UNICODE_SCRIPT_BATAK, /* Batk */ + G_UNICODE_SCRIPT_BRAHMI, /* Brah */ + G_UNICODE_SCRIPT_MANDAIC, /* Mand */ + + /* Unicode-6.1 additions */ + G_UNICODE_SCRIPT_CHAKMA, /* Cakm */ + G_UNICODE_SCRIPT_MEROITIC_CURSIVE, /* Merc */ + G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS, /* Mero */ + G_UNICODE_SCRIPT_MIAO, /* Plrd */ + G_UNICODE_SCRIPT_SHARADA, /* Shrd */ + G_UNICODE_SCRIPT_SORA_SOMPENG, /* Sora */ + G_UNICODE_SCRIPT_TAKRI, /* Takr */ + + /* Unicode 7.0 additions */ + G_UNICODE_SCRIPT_BASSA_VAH, /* Bass */ + G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN, /* Aghb */ + G_UNICODE_SCRIPT_DUPLOYAN, /* Dupl */ + G_UNICODE_SCRIPT_ELBASAN, /* Elba */ + G_UNICODE_SCRIPT_GRANTHA, /* Gran */ + G_UNICODE_SCRIPT_KHOJKI, /* Khoj */ + G_UNICODE_SCRIPT_KHUDAWADI, /* Sind */ + G_UNICODE_SCRIPT_LINEAR_A, /* Lina */ + G_UNICODE_SCRIPT_MAHAJANI, /* Mahj */ + G_UNICODE_SCRIPT_MANICHAEAN, /* Mani */ + G_UNICODE_SCRIPT_MENDE_KIKAKUI, /* Mend */ + G_UNICODE_SCRIPT_MODI, /* Modi */ + G_UNICODE_SCRIPT_MRO, /* Mroo */ + G_UNICODE_SCRIPT_NABATAEAN, /* Nbat */ + G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN, /* Narb */ + G_UNICODE_SCRIPT_OLD_PERMIC, /* Perm */ + G_UNICODE_SCRIPT_PAHAWH_HMONG, /* Hmng */ + G_UNICODE_SCRIPT_PALMYRENE, /* Palm */ + G_UNICODE_SCRIPT_PAU_CIN_HAU, /* Pauc */ + G_UNICODE_SCRIPT_PSALTER_PAHLAVI, /* Phlp */ + G_UNICODE_SCRIPT_SIDDHAM, /* Sidd */ + G_UNICODE_SCRIPT_TIRHUTA, /* Tirh */ + G_UNICODE_SCRIPT_WARANG_CITI, /* Wara */ + + /* Unicode 8.0 additions */ + G_UNICODE_SCRIPT_AHOM, /* Ahom */ + G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS, /* Hluw */ + G_UNICODE_SCRIPT_HATRAN, /* Hatr */ + G_UNICODE_SCRIPT_MULTANI, /* Mult */ + G_UNICODE_SCRIPT_OLD_HUNGARIAN, /* Hung */ + G_UNICODE_SCRIPT_SIGNWRITING, /* Sgnw */ + + /* Unicode 9.0 additions */ + G_UNICODE_SCRIPT_ADLAM, /* Adlm */ + G_UNICODE_SCRIPT_BHAIKSUKI, /* Bhks */ + G_UNICODE_SCRIPT_MARCHEN, /* Marc */ + G_UNICODE_SCRIPT_NEWA, /* Newa */ + G_UNICODE_SCRIPT_OSAGE, /* Osge */ + G_UNICODE_SCRIPT_TANGUT, /* Tang */ + + /* Unicode 10.0 additions */ + G_UNICODE_SCRIPT_MASARAM_GONDI, /* Gonm */ + G_UNICODE_SCRIPT_NUSHU, /* Nshu */ + G_UNICODE_SCRIPT_SOYOMBO, /* Soyo */ + G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, /* Zanb */ + + /* Unicode 11.0 additions */ + G_UNICODE_SCRIPT_DOGRA, /* Dogr */ + G_UNICODE_SCRIPT_GUNJALA_GONDI, /* Gong */ + G_UNICODE_SCRIPT_HANIFI_ROHINGYA, /* Rohg */ + G_UNICODE_SCRIPT_MAKASAR, /* Maka */ + G_UNICODE_SCRIPT_MEDEFAIDRIN, /* Medf */ + G_UNICODE_SCRIPT_OLD_SOGDIAN, /* Sogo */ + G_UNICODE_SCRIPT_SOGDIAN, /* Sogd */ + + /* Unicode 12.0 additions */ + G_UNICODE_SCRIPT_ELYMAIC, /* Elym */ + G_UNICODE_SCRIPT_NANDINAGARI, /* Nand */ + G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG, /* Rohg */ + G_UNICODE_SCRIPT_WANCHO, /* Wcho */ + + /* Unicode 13.0 additions */ + G_UNICODE_SCRIPT_CHORASMIAN, /* Chrs */ + G_UNICODE_SCRIPT_DIVES_AKURU, /* Diak */ + G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, /* Kits */ + G_UNICODE_SCRIPT_YEZIDI, /* Yezi */ + + /* Unicode 14.0 additions */ + G_UNICODE_SCRIPT_CYPRO_MINOAN, /* Cpmn */ + G_UNICODE_SCRIPT_OLD_UYGHUR, /* Ougr */ + G_UNICODE_SCRIPT_TANGSA, /* Tnsa */ + G_UNICODE_SCRIPT_TOTO, /* Toto */ + G_UNICODE_SCRIPT_VITHKUQI, /* Vith */ + + /* not really a Unicode script, but part of ISO 15924 */ + G_UNICODE_SCRIPT_MATH, /* Zmth */ + + /* Unicode 15.0 additions */ + G_UNICODE_SCRIPT_KAWI GLIB_AVAILABLE_ENUMERATOR_IN_2_74, /* Kawi */ + G_UNICODE_SCRIPT_NAG_MUNDARI GLIB_AVAILABLE_ENUMERATOR_IN_2_74, /* Nagm */ + + /* Unicode 16.0 additions */ + G_UNICODE_SCRIPT_TODHRI GLIB_AVAILABLE_ENUMERATOR_IN_2_84, /* Todr */ + G_UNICODE_SCRIPT_GARAY GLIB_AVAILABLE_ENUMERATOR_IN_2_84, /* Gara */ + G_UNICODE_SCRIPT_TULU_TIGALARI GLIB_AVAILABLE_ENUMERATOR_IN_2_84, /* Tutg */ + G_UNICODE_SCRIPT_SUNUWAR GLIB_AVAILABLE_ENUMERATOR_IN_2_84, /* Sunu */ + G_UNICODE_SCRIPT_GURUNG_KHEMA GLIB_AVAILABLE_ENUMERATOR_IN_2_84, /* Gukh */ + G_UNICODE_SCRIPT_KIRAT_RAI GLIB_AVAILABLE_ENUMERATOR_IN_2_84, /* Krai */ + G_UNICODE_SCRIPT_OL_ONAL GLIB_AVAILABLE_ENUMERATOR_IN_2_84, /* Onao */ +} GUnicodeScript; + +GLIB_AVAILABLE_IN_ALL +guint32 g_unicode_script_to_iso15924 (GUnicodeScript script); +GLIB_AVAILABLE_IN_ALL +GUnicodeScript g_unicode_script_from_iso15924 (guint32 iso15924); + +/* These are all analogs of the functions. + */ +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isalnum (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isalpha (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_iscntrl (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isdigit (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isgraph (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_islower (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isprint (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_ispunct (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isspace (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isupper (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isxdigit (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_istitle (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isdefined (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_iswide (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_iswide_cjk(gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_iszerowidth(gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_ismark (gunichar c) G_GNUC_CONST; + +/* More functions. These convert between the three cases. + * See the Unicode book to understand title case. */ +GLIB_AVAILABLE_IN_ALL +gunichar g_unichar_toupper (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gunichar g_unichar_tolower (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gunichar g_unichar_totitle (gunichar c) G_GNUC_CONST; + +/* If C is a digit (according to 'g_unichar_isdigit'), then return its + numeric value. Otherwise return -1. */ +GLIB_AVAILABLE_IN_ALL +gint g_unichar_digit_value (gunichar c) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +gint g_unichar_xdigit_value (gunichar c) G_GNUC_CONST; + +/* Return the Unicode character type of a given character. */ +GLIB_AVAILABLE_IN_ALL +GUnicodeType g_unichar_type (gunichar c) G_GNUC_CONST; + +/* Return the line break property for a given character */ +GLIB_AVAILABLE_IN_ALL +GUnicodeBreakType g_unichar_break_type (gunichar c) G_GNUC_CONST; + +/* Returns the combining class for a given character */ +GLIB_AVAILABLE_IN_ALL +gint g_unichar_combining_class (gunichar uc) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_get_mirror_char (gunichar ch, + gunichar *mirrored_ch); + +GLIB_AVAILABLE_IN_ALL +GUnicodeScript g_unichar_get_script (gunichar ch) G_GNUC_CONST; + +/* Validate a Unicode character */ +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_validate (gunichar ch) G_GNUC_CONST; + +/* Pairwise canonical compose/decompose */ +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_compose (gunichar a, + gunichar b, + gunichar *ch); +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_decompose (gunichar ch, + gunichar *a, + gunichar *b); + +GLIB_AVAILABLE_IN_ALL +gsize g_unichar_fully_decompose (gunichar ch, + gboolean compat, + gunichar *result, + gsize result_len); + +/** + * G_UNICHAR_MAX_DECOMPOSITION_LENGTH: + * + * The maximum length (in codepoints) of a compatibility or canonical + * decomposition of a single Unicode character. + * + * This is as defined by Unicode 6.1. + * + * Since: 2.32 + */ +#define G_UNICHAR_MAX_DECOMPOSITION_LENGTH 18 /* codepoints */ + +/* Compute canonical ordering of a string in-place. This rearranges + decomposed characters in the string according to their combining + classes. See the Unicode manual for more information. */ +GLIB_AVAILABLE_IN_ALL +void g_unicode_canonical_ordering (gunichar *string, + gsize len); + + +GLIB_DEPRECATED_IN_2_30 +gunichar *g_unicode_canonical_decomposition (gunichar ch, + gsize *result_len) G_GNUC_MALLOC; + +/* Array of skip-bytes-per-initial character. + */ +GLIB_VAR const gchar * const g_utf8_skip; + +/** + * g_utf8_next_char: + * @p: Pointer to the start of a valid UTF-8 character + * + * Skips to the next character in a UTF-8 string. + * + * The string must be valid; this macro is as fast as possible, and has + * no error-checking. + * + * You would use this macro to iterate over a string character by character. + * + * The macro returns the start of the next UTF-8 character. + * + * Before using this macro, use g_utf8_validate() to validate strings + * that may contain invalid UTF-8. + */ +#define g_utf8_next_char(p) ((p) + g_utf8_skip[*(const guchar *)(p)]) + +GLIB_AVAILABLE_IN_ALL +gunichar g_utf8_get_char (const gchar *p) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gunichar g_utf8_get_char_validated (const gchar *p, + gssize max_len) G_GNUC_PURE; + +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_offset_to_pointer (const gchar *str, + glong offset) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +glong g_utf8_pointer_to_offset (const gchar *str, + const gchar *pos) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_prev_char (const gchar *p) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_find_next_char (const gchar *p, + const gchar *end) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_find_prev_char (const gchar *str, + const gchar *p) G_GNUC_PURE; + +GLIB_AVAILABLE_IN_ALL +glong g_utf8_strlen (const gchar *p, + gssize max) G_GNUC_PURE; + +GLIB_AVAILABLE_IN_2_30 +gchar *g_utf8_substring (const gchar *str, + glong start_pos, + glong end_pos) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_strncpy (gchar *dest, + const gchar *src, + gsize n); + +GLIB_AVAILABLE_IN_2_78 +gchar *g_utf8_truncate_middle (const gchar *string, + gsize truncate_length); + +/* Find the UTF-8 character corresponding to ch, in string p. These + functions are equivalants to strchr and strrchr */ +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_strchr (const gchar *p, + gssize len, + gunichar c); +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_strrchr (const gchar *p, + gssize len, + gunichar c); +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_strreverse (const gchar *str, + gssize len); + +GLIB_AVAILABLE_IN_ALL +gunichar2 *g_utf8_to_utf16 (const gchar *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gunichar * g_utf8_to_ucs4 (const gchar *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gunichar * g_utf8_to_ucs4_fast (const gchar *str, + glong len, + glong *items_written) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gunichar * g_utf16_to_ucs4 (const gunichar2 *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_utf16_to_utf8 (const gunichar2 *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gunichar2 *g_ucs4_to_utf16 (const gunichar *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_ucs4_to_utf8 (const gunichar *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gint g_unichar_to_utf8 (gunichar c, + gchar *outbuf); + +GLIB_AVAILABLE_IN_ALL +gboolean g_utf8_validate (const gchar *str, + gssize max_len, + const gchar **end); +GLIB_AVAILABLE_IN_2_60 +gboolean g_utf8_validate_len (const gchar *str, + gsize max_len, + const gchar **end); + +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_strup (const gchar *str, + gssize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_strdown (const gchar *str, + gssize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_casefold (const gchar *str, + gssize len) G_GNUC_MALLOC; + +/** + * GNormalizeMode: + * @G_NORMALIZE_DEFAULT: standardize differences that do not affect the + * text content, such as the above-mentioned accent representation + * @G_NORMALIZE_NFD: another name for %G_NORMALIZE_DEFAULT + * @G_NORMALIZE_DEFAULT_COMPOSE: like %G_NORMALIZE_DEFAULT, but with + * composed forms rather than a maximally decomposed form + * @G_NORMALIZE_NFC: another name for %G_NORMALIZE_DEFAULT_COMPOSE + * @G_NORMALIZE_ALL: beyond %G_NORMALIZE_DEFAULT also standardize the + * "compatibility" characters in Unicode, such as SUPERSCRIPT THREE + * to the standard forms (in this case DIGIT THREE). Formatting + * information may be lost but for most text operations such + * characters should be considered the same + * @G_NORMALIZE_NFKD: another name for %G_NORMALIZE_ALL + * @G_NORMALIZE_ALL_COMPOSE: like %G_NORMALIZE_ALL, but with composed + * forms rather than a maximally decomposed form + * @G_NORMALIZE_NFKC: another name for %G_NORMALIZE_ALL_COMPOSE + * + * Defines how a Unicode string is transformed in a canonical + * form, standardizing such issues as whether a character with + * an accent is represented as a base character and combining + * accent or as a single precomposed character. Unicode strings + * should generally be normalized before comparing them. + */ +typedef enum { + G_NORMALIZE_DEFAULT, + G_NORMALIZE_NFD = G_NORMALIZE_DEFAULT, + G_NORMALIZE_DEFAULT_COMPOSE, + G_NORMALIZE_NFC = G_NORMALIZE_DEFAULT_COMPOSE, + G_NORMALIZE_ALL, + G_NORMALIZE_NFKD = G_NORMALIZE_ALL, + G_NORMALIZE_ALL_COMPOSE, + G_NORMALIZE_NFKC = G_NORMALIZE_ALL_COMPOSE +} GNormalizeMode; + +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_normalize (const gchar *str, + gssize len, + GNormalizeMode mode) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gint g_utf8_collate (const gchar *str1, + const gchar *str2) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_collate_key (const gchar *str, + gssize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_collate_key_for_filename (const gchar *str, + gssize len) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_2_52 +gchar *g_utf8_make_valid (const gchar *str, + gssize len) G_GNUC_MALLOC; + +G_END_DECLS + +#endif /* __G_UNICODE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/guri.h b/illumos-x86_64/usr/include/glib-2.0/glib/guri.h new file mode 100644 index 00000000..5989eabc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/guri.h @@ -0,0 +1,420 @@ +/* GLIB - Library of useful routines for C programming + * Copyright © 2020 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * . + */ + +#pragma once + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +typedef struct _GUri GUri; + +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_ref (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +void g_uri_unref (GUri *uri); + +/** + * GUriFlags: + * @G_URI_FLAGS_NONE: No flags set. + * @G_URI_FLAGS_PARSE_RELAXED: Parse the URI more relaxedly than the + * [RFC 3986](https://tools.ietf.org/html/rfc3986) grammar specifies, + * fixing up or ignoring common mistakes in URIs coming from external + * sources. This is also needed for some obscure URI schemes where `;` + * separates the host from the path. Don’t use this flag unless you need to. + * @G_URI_FLAGS_HAS_PASSWORD: The userinfo field may contain a password, + * which will be separated from the username by `:`. + * @G_URI_FLAGS_HAS_AUTH_PARAMS: The userinfo may contain additional + * authentication-related parameters, which will be separated from + * the username and/or password by `;`. + * @G_URI_FLAGS_NON_DNS: The host component should not be assumed to be a + * DNS hostname or IP address (for example, for `smb` URIs with NetBIOS + * hostnames). + * @G_URI_FLAGS_ENCODED: When parsing a URI, this indicates that `%`-encoded + * characters in the userinfo, path, query, and fragment fields + * should not be decoded. (And likewise the host field if + * %G_URI_FLAGS_NON_DNS is also set.) When building a URI, it indicates + * that you have already `%`-encoded the components, and so #GUri + * should not do any encoding itself. + * @G_URI_FLAGS_ENCODED_QUERY: Same as %G_URI_FLAGS_ENCODED, for the query + * field only. + * @G_URI_FLAGS_ENCODED_PATH: Same as %G_URI_FLAGS_ENCODED, for the path only. + * @G_URI_FLAGS_ENCODED_FRAGMENT: Same as %G_URI_FLAGS_ENCODED, for the + * fragment only. + * @G_URI_FLAGS_SCHEME_NORMALIZE: A scheme-based normalization will be applied. + * For example, when parsing an HTTP URI changing omitted path to `/` and + * omitted port to `80`; and when building a URI, changing empty path to `/` + * and default port `80`). This only supports a subset of known schemes. (Since: 2.68) + * + * Flags that describe a URI. + * + * When parsing a URI, if you need to choose different flags based on + * the type of URI, you can use g_uri_peek_scheme() on the URI string + * to check the scheme first, and use that to decide what flags to + * parse it with. + * + * Since: 2.66 + */ +GLIB_AVAILABLE_TYPE_IN_2_66 +typedef enum { + G_URI_FLAGS_NONE = 0, + G_URI_FLAGS_PARSE_RELAXED = 1 << 0, + G_URI_FLAGS_HAS_PASSWORD = 1 << 1, + G_URI_FLAGS_HAS_AUTH_PARAMS = 1 << 2, + G_URI_FLAGS_ENCODED = 1 << 3, + G_URI_FLAGS_NON_DNS = 1 << 4, + G_URI_FLAGS_ENCODED_QUERY = 1 << 5, + G_URI_FLAGS_ENCODED_PATH = 1 << 6, + G_URI_FLAGS_ENCODED_FRAGMENT = 1 << 7, + G_URI_FLAGS_SCHEME_NORMALIZE GLIB_AVAILABLE_ENUMERATOR_IN_2_68 = 1 << 8, +} GUriFlags; + +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_split (const gchar *uri_ref, + GUriFlags flags, + gchar **scheme, + gchar **userinfo, + gchar **host, + gint *port, + gchar **path, + gchar **query, + gchar **fragment, + GError **error); +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_split_with_user (const gchar *uri_ref, + GUriFlags flags, + gchar **scheme, + gchar **user, + gchar **password, + gchar **auth_params, + gchar **host, + gint *port, + gchar **path, + gchar **query, + gchar **fragment, + GError **error); +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_split_network (const gchar *uri_string, + GUriFlags flags, + gchar **scheme, + gchar **host, + gint *port, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_is_valid (const gchar *uri_string, + GUriFlags flags, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +gchar * g_uri_join (GUriFlags flags, + const gchar *scheme, + const gchar *userinfo, + const gchar *host, + gint port, + const gchar *path, + const gchar *query, + const gchar *fragment); +GLIB_AVAILABLE_IN_2_66 +gchar * g_uri_join_with_user (GUriFlags flags, + const gchar *scheme, + const gchar *user, + const gchar *password, + const gchar *auth_params, + const gchar *host, + gint port, + const gchar *path, + const gchar *query, + const gchar *fragment); + +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_parse (const gchar *uri_string, + GUriFlags flags, + GError **error); +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_parse_relative (GUri *base_uri, + const gchar *uri_ref, + GUriFlags flags, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +gchar * g_uri_resolve_relative (const gchar *base_uri_string, + const gchar *uri_ref, + GUriFlags flags, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_build (GUriFlags flags, + const gchar *scheme, + const gchar *userinfo, + const gchar *host, + gint port, + const gchar *path, + const gchar *query, + const gchar *fragment); +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_build_with_user (GUriFlags flags, + const gchar *scheme, + const gchar *user, + const gchar *password, + const gchar *auth_params, + const gchar *host, + gint port, + const gchar *path, + const gchar *query, + const gchar *fragment); + +/** + * GUriHideFlags: + * @G_URI_HIDE_NONE: No flags set. + * @G_URI_HIDE_USERINFO: Hide the userinfo. + * @G_URI_HIDE_PASSWORD: Hide the password. + * @G_URI_HIDE_AUTH_PARAMS: Hide the auth_params. + * @G_URI_HIDE_QUERY: Hide the query. + * @G_URI_HIDE_FRAGMENT: Hide the fragment. + * + * Flags describing what parts of the URI to hide in + * g_uri_to_string_partial(). Note that %G_URI_HIDE_PASSWORD and + * %G_URI_HIDE_AUTH_PARAMS will only work if the #GUri was parsed with + * the corresponding flags. + * + * Since: 2.66 + */ +GLIB_AVAILABLE_TYPE_IN_2_66 +typedef enum { + G_URI_HIDE_NONE = 0, + G_URI_HIDE_USERINFO = 1 << 0, + G_URI_HIDE_PASSWORD = 1 << 1, + G_URI_HIDE_AUTH_PARAMS = 1 << 2, + G_URI_HIDE_QUERY = 1 << 3, + G_URI_HIDE_FRAGMENT = 1 << 4, +} GUriHideFlags; + +GLIB_AVAILABLE_IN_2_66 +char * g_uri_to_string (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +char * g_uri_to_string_partial (GUri *uri, + GUriHideFlags flags); + +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_scheme (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_userinfo (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_user (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_password (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_auth_params (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_host (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +gint g_uri_get_port (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_path (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_query (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_fragment (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +GUriFlags g_uri_get_flags (GUri *uri); + +/** + * GUriParamsFlags: + * @G_URI_PARAMS_NONE: No flags set. + * @G_URI_PARAMS_CASE_INSENSITIVE: Parameter names are case insensitive. + * @G_URI_PARAMS_WWW_FORM: Replace `+` with space character. Only useful for + * URLs on the web, using the `https` or `http` schemas. + * @G_URI_PARAMS_PARSE_RELAXED: See %G_URI_FLAGS_PARSE_RELAXED. + * + * Flags modifying the way parameters are handled by g_uri_parse_params() and + * #GUriParamsIter. + * + * Since: 2.66 + */ +GLIB_AVAILABLE_TYPE_IN_2_66 +typedef enum { + G_URI_PARAMS_NONE = 0, + G_URI_PARAMS_CASE_INSENSITIVE = 1 << 0, + G_URI_PARAMS_WWW_FORM = 1 << 1, + G_URI_PARAMS_PARSE_RELAXED = 1 << 2, +} GUriParamsFlags; + +GLIB_AVAILABLE_IN_2_66 +GHashTable *g_uri_parse_params (const gchar *params, + gssize length, + const gchar *separators, + GUriParamsFlags flags, + GError **error); + +typedef struct _GUriParamsIter GUriParamsIter; + +struct _GUriParamsIter +{ + /*< private >*/ + gint dummy0; + gpointer dummy1; + gpointer dummy2; + guint8 dummy3[256]; +}; + +GLIB_AVAILABLE_IN_2_66 +void g_uri_params_iter_init (GUriParamsIter *iter, + const gchar *params, + gssize length, + const gchar *separators, + GUriParamsFlags flags); + +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_params_iter_next (GUriParamsIter *iter, + gchar **attribute, + gchar **value, + GError **error); + +/** + * G_URI_ERROR: + * + * Error domain for URI methods. Errors in this domain will be from + * the #GUriError enumeration. See #GError for information on error + * domains. + * + * Since: 2.66 + */ +#define G_URI_ERROR (g_uri_error_quark ()) GLIB_AVAILABLE_MACRO_IN_2_66 +GLIB_AVAILABLE_IN_2_66 +GQuark g_uri_error_quark (void); + +/** + * GUriError: + * @G_URI_ERROR_FAILED: Generic error if no more specific error is available. + * See the error message for details. + * @G_URI_ERROR_BAD_SCHEME: The scheme of a URI could not be parsed. + * @G_URI_ERROR_BAD_USER: The user/userinfo of a URI could not be parsed. + * @G_URI_ERROR_BAD_PASSWORD: The password of a URI could not be parsed. + * @G_URI_ERROR_BAD_AUTH_PARAMS: The authentication parameters of a URI could not be parsed. + * @G_URI_ERROR_BAD_HOST: The host of a URI could not be parsed. + * @G_URI_ERROR_BAD_PORT: The port of a URI could not be parsed. + * @G_URI_ERROR_BAD_PATH: The path of a URI could not be parsed. + * @G_URI_ERROR_BAD_QUERY: The query of a URI could not be parsed. + * @G_URI_ERROR_BAD_FRAGMENT: The fragment of a URI could not be parsed. + * + * Error codes returned by #GUri methods. + * + * Since: 2.66 + */ +typedef enum { + G_URI_ERROR_FAILED, + G_URI_ERROR_BAD_SCHEME, + G_URI_ERROR_BAD_USER, + G_URI_ERROR_BAD_PASSWORD, + G_URI_ERROR_BAD_AUTH_PARAMS, + G_URI_ERROR_BAD_HOST, + G_URI_ERROR_BAD_PORT, + G_URI_ERROR_BAD_PATH, + G_URI_ERROR_BAD_QUERY, + G_URI_ERROR_BAD_FRAGMENT, +} GUriError; + +/** + * G_URI_RESERVED_CHARS_GENERIC_DELIMITERS: + * + * Generic delimiters characters as defined in + * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `:/?#[]@`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_GENERIC_DELIMITERS ":/?#[]@" + +/** + * G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS: + * + * Subcomponent delimiter characters as defined in + * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `!$&'()*+,;=`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS "!$&'()*+,;=" + +/** + * G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT: + * + * Allowed characters in path elements. Includes `!$&'()*+,;=:@`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":@" + +/** + * G_URI_RESERVED_CHARS_ALLOWED_IN_PATH: + * + * Allowed characters in a path. Includes `!$&'()*+,;=:@/`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_ALLOWED_IN_PATH G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT "/" + +/** + * G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO: + * + * Allowed characters in userinfo as defined in + * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `!$&'()*+,;=:`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":" + +GLIB_AVAILABLE_IN_ALL +char * g_uri_unescape_string (const char *escaped_string, + const char *illegal_characters); +GLIB_AVAILABLE_IN_ALL +char * g_uri_unescape_segment (const char *escaped_string, + const char *escaped_string_end, + const char *illegal_characters); + +GLIB_AVAILABLE_IN_ALL +char * g_uri_parse_scheme (const char *uri); +GLIB_AVAILABLE_IN_2_66 +const char *g_uri_peek_scheme (const char *uri); + +GLIB_AVAILABLE_IN_ALL +char * g_uri_escape_string (const char *unescaped, + const char *reserved_chars_allowed, + gboolean allow_utf8); + +GLIB_AVAILABLE_IN_2_66 +GBytes * g_uri_unescape_bytes (const char *escaped_string, + gssize length, + const char *illegal_characters, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +char * g_uri_escape_bytes (const guint8 *unescaped, + gsize length, + const char *reserved_chars_allowed); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gutils.h b/illumos-x86_64/usr/include/glib-2.0/glib/gutils.h new file mode 100644 index 00000000..efc69144 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gutils.h @@ -0,0 +1,479 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_UTILS_H__ +#define __G_UTILS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_name (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_real_name (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_home_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_tmp_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_host_name (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_prgname (void); +GLIB_AVAILABLE_IN_ALL +void g_set_prgname (const gchar *prgname); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_application_name (void); +GLIB_AVAILABLE_IN_ALL +void g_set_application_name (const gchar *application_name); +GLIB_AVAILABLE_IN_2_64 +gchar * g_get_os_info (const gchar *key_name); + +/** + * G_OS_INFO_KEY_NAME: + * + * A key to get the name of the operating system excluding version information suitable for presentation to the user, e.g. "YoYoOS" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_NAME \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "NAME" + +/** + * G_OS_INFO_KEY_PRETTY_NAME: + * + * A key to get the name of the operating system in a format suitable for presentation to the user, e.g. "YoYoOS Foo" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_PRETTY_NAME \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "PRETTY_NAME" + +/** + * G_OS_INFO_KEY_VERSION: + * + * A key to get the operating system version suitable for presentation to the user, e.g. "42 (Foo)" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_VERSION \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "VERSION" + +/** + * G_OS_INFO_KEY_VERSION_CODENAME: + * + * A key to get a codename identifying the operating system release suitable for processing by scripts or usage in generated filenames, e.g. "foo" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_VERSION_CODENAME \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "VERSION_CODENAME" + +/** + * G_OS_INFO_KEY_VERSION_ID: + * + * A key to get the version of the operating system suitable for processing by scripts or usage in generated filenames, e.g. "42" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_VERSION_ID \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "VERSION_ID" + +/** + * G_OS_INFO_KEY_ID: + * + * A key to get an ID identifying the operating system suitable for processing by scripts or usage in generated filenames, e.g. "yoyoos" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_ID \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "ID" + +/** + * G_OS_INFO_KEY_HOME_URL: + * + * A key to get the homepage for the operating system, e.g. "https://www.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_HOME_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "HOME_URL" + +/** + * G_OS_INFO_KEY_DOCUMENTATION_URL: + * + * A key to get the documentation page for the operating system, e.g. "https://docs.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_DOCUMENTATION_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "DOCUMENTATION_URL" + +/** + * G_OS_INFO_KEY_SUPPORT_URL: + * + * A key to get the support page for the operating system, e.g. "https://support.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_SUPPORT_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "SUPPORT_URL" + +/** + * G_OS_INFO_KEY_BUG_REPORT_URL: + * + * A key to get the bug reporting page for the operating system, e.g. "https://bugs.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_BUG_REPORT_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "BUG_REPORT_URL" + +/** + * G_OS_INFO_KEY_PRIVACY_POLICY_URL: + * + * A key to get the privacy policy for the operating system, e.g. "https://privacy.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_PRIVACY_POLICY_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "PRIVACY_POLICY_URL" + +GLIB_AVAILABLE_IN_ALL +void g_reload_user_special_dirs_cache (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_data_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_config_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_cache_dir (void); +GLIB_AVAILABLE_IN_2_72 +const gchar * g_get_user_state_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * const * g_get_system_data_dirs (void); + +#ifdef G_OS_WIN32 +/* This function is not part of the public GLib API */ +GLIB_AVAILABLE_IN_ALL +const gchar * const * g_win32_get_system_data_dirs_for_module (void (*address_of_function)(void)); +#endif + +#if defined (G_OS_WIN32) && defined (G_CAN_INLINE) +/* This function is not part of the public GLib API either. Just call + * g_get_system_data_dirs() in your code, never mind that that is + * actually a macro and you will in fact call this inline function. + */ +static inline const gchar * const * +_g_win32_get_system_data_dirs (void) +{ + return g_win32_get_system_data_dirs_for_module ((void (*)(void)) &_g_win32_get_system_data_dirs); +} +#define g_get_system_data_dirs _g_win32_get_system_data_dirs +#endif + +GLIB_AVAILABLE_IN_ALL +const gchar * const * g_get_system_config_dirs (void); + +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_runtime_dir (void); + +/** + * GUserDirectory: + * @G_USER_DIRECTORY_DESKTOP: the user's Desktop directory + * @G_USER_DIRECTORY_DOCUMENTS: the user's Documents directory + * @G_USER_DIRECTORY_DOWNLOAD: the user's Downloads directory + * @G_USER_DIRECTORY_MUSIC: the user's Music directory + * @G_USER_DIRECTORY_PICTURES: the user's Pictures directory + * @G_USER_DIRECTORY_PUBLIC_SHARE: the user's shared directory + * @G_USER_DIRECTORY_TEMPLATES: the user's Templates directory + * @G_USER_DIRECTORY_VIDEOS: the user's Movies directory + * @G_USER_N_DIRECTORIES: the number of enum values + * + * These are logical ids for special directories which are defined + * depending on the platform used. You should use g_get_user_special_dir() + * to retrieve the full path associated to the logical id. + * + * The #GUserDirectory enumeration can be extended at later date. Not + * every platform has a directory for every logical id in this + * enumeration. + * + * Since: 2.14 + */ +typedef enum { + G_USER_DIRECTORY_DESKTOP, + G_USER_DIRECTORY_DOCUMENTS, + G_USER_DIRECTORY_DOWNLOAD, + G_USER_DIRECTORY_MUSIC, + G_USER_DIRECTORY_PICTURES, + G_USER_DIRECTORY_PUBLIC_SHARE, + G_USER_DIRECTORY_TEMPLATES, + G_USER_DIRECTORY_VIDEOS, + + G_USER_N_DIRECTORIES +} GUserDirectory; + +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_special_dir (GUserDirectory directory); + +/** + * GDebugKey: + * @key: the string + * @value: the flag + * + * Associates a string with a bit flag. + * Used in g_parse_debug_string(). + */ +typedef struct _GDebugKey GDebugKey; +struct _GDebugKey +{ + const gchar *key; + guint value; +}; + +/* Miscellaneous utility functions + */ +GLIB_AVAILABLE_IN_ALL +guint g_parse_debug_string (const gchar *string, + const GDebugKey *keys, + guint nkeys); + +GLIB_AVAILABLE_IN_ALL +gint g_snprintf (gchar *string, + gulong n, + gchar const *format, + ...) G_GNUC_PRINTF (3, 4); +GLIB_AVAILABLE_IN_ALL +gint g_vsnprintf (gchar *string, + gulong n, + gchar const *format, + va_list args) + G_GNUC_PRINTF(3, 0); + +GLIB_AVAILABLE_IN_ALL +void g_nullify_pointer (gpointer *nullify_location); + +typedef enum +{ + G_FORMAT_SIZE_DEFAULT = 0, + G_FORMAT_SIZE_LONG_FORMAT = 1 << 0, + G_FORMAT_SIZE_IEC_UNITS = 1 << 1, + G_FORMAT_SIZE_BITS = 1 << 2, + G_FORMAT_SIZE_ONLY_VALUE GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 1 << 3, + G_FORMAT_SIZE_ONLY_UNIT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 1 << 4 +} GFormatSizeFlags; + +GLIB_AVAILABLE_IN_2_30 +gchar *g_format_size_full (guint64 size, + GFormatSizeFlags flags); +GLIB_AVAILABLE_IN_2_30 +gchar *g_format_size (guint64 size); + +GLIB_DEPRECATED_IN_2_30_FOR(g_format_size) +gchar *g_format_size_for_display (goffset size); + +#define g_ATEXIT(proc) (atexit (proc)) GLIB_DEPRECATED_MACRO_IN_2_32 +#define g_memmove(dest,src,len) \ + G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_40_FOR(memmove) + +/** + * GVoidFunc: + * + * Declares a type of function which takes no arguments + * and has no return value. It is used to specify the type + * function passed to g_atexit(). + */ +typedef void (*GVoidFunc) (void) GLIB_DEPRECATED_TYPE_IN_2_32; +#define ATEXIT(proc) g_ATEXIT(proc) GLIB_DEPRECATED_MACRO_IN_2_32 + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED +void g_atexit (GVoidFunc func); +G_GNUC_END_IGNORE_DEPRECATIONS + +#ifdef G_OS_WIN32 +/* It's a bad idea to wrap atexit() on Windows. If the GLib DLL calls + * atexit(), the function will be called when the GLib DLL is detached + * from the program, which is not what the caller wants. The caller + * wants the function to be called when it *itself* exits (or is + * detached, in case the caller, too, is a DLL). + */ +#if (defined(__MINGW_H) && !defined(_STDLIB_H_)) || (defined(_MSC_VER) && !defined(_INC_STDLIB)) +int atexit (void (*)(void)); +#endif +#define g_atexit(func) atexit(func) GLIB_DEPRECATED_MACRO_IN_2_32 +#endif + + +/* Look for an executable in PATH, following execvp() rules */ +GLIB_AVAILABLE_IN_ALL +gchar* g_find_program_in_path (const gchar *program); + +/* Bit tests + * + * These are defined in a convoluted way because we want the compiler to + * be able to inline the code for performance reasons, but for + * historical reasons, we must continue to provide non-inline versions + * on our ABI. + * + * We define these as functions in gutils.c which are just implemented + * as calls to the _impl() versions in order to preserve the ABI. + */ + +#define g_bit_nth_lsf(mask, nth_bit) g_bit_nth_lsf_impl(mask, nth_bit) +#define g_bit_nth_msf(mask, nth_bit) g_bit_nth_msf_impl(mask, nth_bit) +#define g_bit_storage(number) g_bit_storage_impl(number) + +GLIB_AVAILABLE_IN_ALL +gint (g_bit_nth_lsf) (gulong mask, + gint nth_bit); +GLIB_AVAILABLE_IN_ALL +gint (g_bit_nth_msf) (gulong mask, + gint nth_bit); +GLIB_AVAILABLE_IN_ALL +guint (g_bit_storage) (gulong number); + +static inline gint +g_bit_nth_lsf_impl (gulong mask, + gint nth_bit) +{ + if (G_UNLIKELY (nth_bit < -1)) + nth_bit = -1; + while (nth_bit < ((GLIB_SIZEOF_LONG * 8) - 1)) + { + nth_bit++; + if (mask & (1UL << nth_bit)) + return nth_bit; + } + return -1; +} + +static inline gint +g_bit_nth_msf_impl (gulong mask, + gint nth_bit) +{ + if (nth_bit < 0 || G_UNLIKELY (nth_bit > GLIB_SIZEOF_LONG * 8)) + nth_bit = GLIB_SIZEOF_LONG * 8; + while (nth_bit > 0) + { + nth_bit--; + if (mask & (1UL << nth_bit)) + return nth_bit; + } + return -1; +} + +static inline guint +g_bit_storage_impl (gulong number) +{ +#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) + return G_LIKELY (number) ? + ((GLIB_SIZEOF_LONG * 8U - 1) ^ (guint) __builtin_clzl(number)) + 1 : 1; +#else + guint n_bits = 0; + + do + { + n_bits++; + number >>= 1; + } + while (number); + return n_bits; +#endif +} + +/* Crashes the program. */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_50 +#ifndef G_OS_WIN32 +# include +# define g_abort() abort () +#else +G_NORETURN GLIB_AVAILABLE_IN_2_50 void g_abort (void) G_ANALYZER_NORETURN; +#endif +#endif + +/* + * This macro is deprecated. This DllMain() is too complex. It is + * recommended to write an explicit minimal DLlMain() that just saves + * the handle to the DLL and then use that handle instead, for + * instance passing it to + * g_win32_get_package_installation_directory_of_module(). + * + * On Windows, this macro defines a DllMain function that stores the + * actual DLL name that the code being compiled will be included in. + * STATIC should be empty or 'static'. DLL_NAME is the name of the + * (pointer to the) char array where the DLL name will be stored. If + * this is used, you must also include . If you need a more complex + * DLL entry point function, you cannot use this. + * + * On non-Windows platforms, expands to nothing. + */ + +#ifndef G_PLATFORM_WIN32 +# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) GLIB_DEPRECATED_MACRO_IN_2_26 +#else +# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) \ +static char *dll_name; \ + \ +BOOL WINAPI \ +DllMain (HINSTANCE hinstDLL, \ + DWORD fdwReason, \ + LPVOID lpvReserved) \ +{ \ + wchar_t wcbfr[1000]; \ + char *tem; \ + switch (fdwReason) \ + { \ + case DLL_PROCESS_ATTACH: \ + GetModuleFileNameW ((HMODULE) hinstDLL, wcbfr, G_N_ELEMENTS (wcbfr)); \ + tem = g_utf16_to_utf8 (wcbfr, -1, NULL, NULL, NULL); \ + dll_name = g_path_get_basename (tem); \ + g_free (tem); \ + break; \ + } \ + \ + return TRUE; \ +} GLIB_DEPRECATED_MACRO_IN_2_26 +#endif /* G_PLATFORM_WIN32 */ + +G_END_DECLS + +#endif /* __G_UTILS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/guuid.h b/illumos-x86_64/usr/include/glib-2.0/glib/guuid.h new file mode 100644 index 00000000..c653188a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/guuid.h @@ -0,0 +1,42 @@ +/* guuid.h - UUID functions + * + * Copyright (C) 2013-2015, 2017 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * licence, or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 + * USA. + * + * Authors: Marc-André Lureau + */ + +#ifndef __G_UUID_H__ +#define __G_UUID_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_52 +gboolean g_uuid_string_is_valid (const gchar *str); + +GLIB_AVAILABLE_IN_2_52 +gchar * g_uuid_string_random (void); + +G_END_DECLS + +#endif /* __G_UUID_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gvariant.h b/illumos-x86_64/usr/include/glib-2.0/glib/gvariant.h new file mode 100644 index 00000000..4868cbac --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gvariant.h @@ -0,0 +1,578 @@ +/* + * Copyright © 2007, 2008 Ryan Lortie + * Copyright © 2009, 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_VARIANT_H__ +#define __G_VARIANT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +typedef struct _GVariant GVariant; + +typedef enum +{ + G_VARIANT_CLASS_BOOLEAN = 'b', + G_VARIANT_CLASS_BYTE = 'y', + G_VARIANT_CLASS_INT16 = 'n', + G_VARIANT_CLASS_UINT16 = 'q', + G_VARIANT_CLASS_INT32 = 'i', + G_VARIANT_CLASS_UINT32 = 'u', + G_VARIANT_CLASS_INT64 = 'x', + G_VARIANT_CLASS_UINT64 = 't', + G_VARIANT_CLASS_HANDLE = 'h', + G_VARIANT_CLASS_DOUBLE = 'd', + G_VARIANT_CLASS_STRING = 's', + G_VARIANT_CLASS_OBJECT_PATH = 'o', + G_VARIANT_CLASS_SIGNATURE = 'g', + G_VARIANT_CLASS_VARIANT = 'v', + G_VARIANT_CLASS_MAYBE = 'm', + G_VARIANT_CLASS_ARRAY = 'a', + G_VARIANT_CLASS_TUPLE = '(', + G_VARIANT_CLASS_DICT_ENTRY = '{' +} GVariantClass; + +GLIB_AVAILABLE_IN_ALL +void g_variant_unref (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_ref (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_ref_sink (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_floating (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_take_ref (GVariant *value); + +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_get_type (GVariant *value); +GLIB_AVAILABLE_IN_ALL +const gchar * g_variant_get_type_string (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_of_type (GVariant *value, + const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_container (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariantClass g_variant_classify (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_boolean (gboolean value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_byte (guint8 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_int16 (gint16 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_uint16 (guint16 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_int32 (gint32 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_uint32 (guint32 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_int64 (gint64 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_uint64 (guint64 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_handle (gint32 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_double (gdouble value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_string (const gchar *string); +GLIB_AVAILABLE_IN_2_38 +GVariant * g_variant_new_take_string (gchar *string); +GLIB_AVAILABLE_IN_2_38 +GVariant * g_variant_new_printf (const gchar *format_string, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_object_path (const gchar *object_path); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_object_path (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_signature (const gchar *signature); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_signature (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_variant (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_strv (const gchar * const *strv, + gssize length); +GLIB_AVAILABLE_IN_2_30 +GVariant * g_variant_new_objv (const gchar * const *strv, + gssize length); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_bytestring (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_bytestring_array (const gchar * const *strv, + gssize length); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_fixed_array (const GVariantType *element_type, + gconstpointer elements, + gsize n_elements, + gsize element_size); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_get_boolean (GVariant *value); +GLIB_AVAILABLE_IN_ALL +guint8 g_variant_get_byte (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gint16 g_variant_get_int16 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +guint16 g_variant_get_uint16 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gint32 g_variant_get_int32 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +guint32 g_variant_get_uint32 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gint64 g_variant_get_int64 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +guint64 g_variant_get_uint64 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gint32 g_variant_get_handle (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gdouble g_variant_get_double (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_get_variant (GVariant *value); +GLIB_AVAILABLE_IN_ALL +const gchar * g_variant_get_string (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar * g_variant_dup_string (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +const gchar ** g_variant_get_strv (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar ** g_variant_dup_strv (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_2_30 +const gchar ** g_variant_get_objv (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar ** g_variant_dup_objv (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +const gchar * g_variant_get_bytestring (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gchar * g_variant_dup_bytestring (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +const gchar ** g_variant_get_bytestring_array (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar ** g_variant_dup_bytestring_array (GVariant *value, + gsize *length); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_maybe (const GVariantType *child_type, + GVariant *child); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_array (const GVariantType *child_type, + GVariant * const *children, + gsize n_children); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_tuple (GVariant * const *children, + gsize n_children); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_dict_entry (GVariant *key, + GVariant *value); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_get_maybe (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gsize g_variant_n_children (GVariant *value); +GLIB_AVAILABLE_IN_ALL +void g_variant_get_child (GVariant *value, + gsize index_, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_get_child_value (GVariant *value, + gsize index_); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_lookup (GVariant *dictionary, + const gchar *key, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_lookup_value (GVariant *dictionary, + const gchar *key, + const GVariantType *expected_type); +GLIB_AVAILABLE_IN_ALL +gconstpointer g_variant_get_fixed_array (GVariant *value, + gsize *n_elements, + gsize element_size); + +GLIB_AVAILABLE_IN_ALL +gsize g_variant_get_size (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gconstpointer g_variant_get_data (GVariant *value); +GLIB_AVAILABLE_IN_2_36 +GBytes * g_variant_get_data_as_bytes (GVariant *value); +GLIB_AVAILABLE_IN_ALL +void g_variant_store (GVariant *value, + gpointer data); + +GLIB_AVAILABLE_IN_ALL +gchar * g_variant_print (GVariant *value, + gboolean type_annotate); +GLIB_AVAILABLE_IN_ALL +GString * g_variant_print_string (GVariant *value, + GString *string, + gboolean type_annotate); + +GLIB_AVAILABLE_IN_ALL +guint g_variant_hash (gconstpointer value); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_equal (gconstpointer one, + gconstpointer two); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_get_normal_form (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_normal_form (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_byteswap (GVariant *value); + +GLIB_AVAILABLE_IN_2_36 +GVariant * g_variant_new_from_bytes (const GVariantType *type, + GBytes *bytes, + gboolean trusted); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_from_data (const GVariantType *type, + gconstpointer data, + gsize size, + gboolean trusted, + GDestroyNotify notify, + gpointer user_data); + +typedef struct _GVariantIter GVariantIter; +struct _GVariantIter { + /*< private >*/ + guintptr x[16]; +}; + +GLIB_AVAILABLE_IN_ALL +GVariantIter * g_variant_iter_new (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gsize g_variant_iter_init (GVariantIter *iter, + GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariantIter * g_variant_iter_copy (GVariantIter *iter); +GLIB_AVAILABLE_IN_ALL +gsize g_variant_iter_n_children (GVariantIter *iter); +GLIB_AVAILABLE_IN_ALL +void g_variant_iter_free (GVariantIter *iter); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_iter_next_value (GVariantIter *iter); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_iter_next (GVariantIter *iter, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_iter_loop (GVariantIter *iter, + const gchar *format_string, + ...); + + +typedef struct _GVariantBuilder GVariantBuilder; +struct _GVariantBuilder { + /*< private >*/ + union + { + struct { + gsize partial_magic; + const GVariantType *type; + guintptr y[14]; + } s; + guintptr x[16]; + } u; +}; + +typedef enum +{ + G_VARIANT_PARSE_ERROR_FAILED, + G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED, + G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE, + G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED, + G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END, + G_VARIANT_PARSE_ERROR_INVALID_CHARACTER, + G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING, + G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH, + G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE, + G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING, + G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE, + G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE, + G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG, + G_VARIANT_PARSE_ERROR_TYPE_ERROR, + G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN, + G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD, + G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT, + G_VARIANT_PARSE_ERROR_VALUE_EXPECTED, + G_VARIANT_PARSE_ERROR_RECURSION +} GVariantParseError; +#define G_VARIANT_PARSE_ERROR (g_variant_parse_error_quark ()) + +GLIB_DEPRECATED_IN_2_38_FOR(g_variant_parse_error_quark) +GQuark g_variant_parser_get_error_quark (void); + +GLIB_AVAILABLE_IN_ALL +GQuark g_variant_parse_error_quark (void); + +/** + * G_VARIANT_BUILDER_INIT: + * @variant_type: a const GVariantType* + * + * A stack-allocated [struct@GLib.VariantBuilder] must be initialized + * if it is used together with + * [`g_auto()`](auto-cleanup.html#variable-declaration). This macro can + * be used as initializer when declaring the builder, but it cannot be + * assigned to a variable. + * + * The effects of initializing the builder with + * `G_VARIANT_BUILDER_INIT` is the same as initializing it with + * [func@GLib.VARIANT_BUILDER_INIT_UNSET], followed by a call to + * [method@GLib.VariantBuilder.init]. + * + * The passed @variant_type should be a static [type@GLib.VariantType] + * to avoid lifetime issues, as copying the @variant_type does not + * happen in the `G_VARIANT_BUILDER_INIT` call, but rather in functions + * that make sure that [struct@GLib.VariantBuilder] is valid. + * + * ```c + * g_auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_BYTESTRING); + * ``` + * + * Since: 2.50 + */ +#define G_VARIANT_BUILDER_INIT(variant_type) \ + { \ + { \ + { \ + 2942751021u /* == GVSB_MAGIC_PARTIAL, see gvariant.c */, variant_type, { 0, } \ + } \ + } \ + } + +/** + * G_VARIANT_BUILDER_INIT_UNSET: + * + * A stack-allocated [struct@GLib.VariantBuilder] must be initialized + * if it is used together with + * [`g_auto()`](auto-cleanup.html#variable-declaration). This macro can + * be used as initializer when declaring the builder, but it cannot be + * assigned to a variable. + * + * The builder can be initialized to a specific [type@GLib.VariantType] + * later with [method@GLib.VariantBuilder.init]. + * + * Use [func@GLib.VARIANT_BUILDER_INIT] to directly initialize the + * builder with a specific [type@GLib.VariantType]. + * + * ```c + * g_auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT_UNSET (); + * + * if (condition) + * return NULL; + * + * g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{su}")); + * return g_variant_ref_sink (g_variant_builder_end (&builder)); + * ``` + * + * Since: 2.84 + */ +#define G_VARIANT_BUILDER_INIT_UNSET() \ + { \ + 0, \ + } GLIB_AVAILABLE_MACRO_IN_2_84 + +GLIB_AVAILABLE_IN_ALL +GVariantBuilder * g_variant_builder_new (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_unref (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +GVariantBuilder * g_variant_builder_ref (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_init (GVariantBuilder *builder, + const GVariantType *type); +GLIB_AVAILABLE_IN_2_84 +void g_variant_builder_init_static (GVariantBuilder *builder, + const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_builder_end (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_clear (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_open (GVariantBuilder *builder, + const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_close (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_add_value (GVariantBuilder *builder, + GVariant *value); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_add (GVariantBuilder *builder, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_add_parsed (GVariantBuilder *builder, + const gchar *format, + ...); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new (const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +void g_variant_get (GVariant *value, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_va (const gchar *format_string, + const gchar **endptr, + va_list *app); +GLIB_AVAILABLE_IN_ALL +void g_variant_get_va (GVariant *value, + const gchar *format_string, + const gchar **endptr, + va_list *app); +GLIB_AVAILABLE_IN_2_34 +gboolean g_variant_check_format_string (GVariant *value, + const gchar *format_string, + gboolean copy_only); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_parse (const GVariantType *type, + const gchar *text, + const gchar *limit, + const gchar **endptr, + GError **error); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_parsed (const gchar *format, + ...); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_parsed_va (const gchar *format, + va_list *app); + +GLIB_AVAILABLE_IN_2_40 +gchar * g_variant_parse_error_print_context (GError *error, + const gchar *source_str); + +GLIB_AVAILABLE_IN_ALL +gint g_variant_compare (gconstpointer one, + gconstpointer two); + +typedef struct _GVariantDict GVariantDict; +struct _GVariantDict { + /*< private >*/ + union + { + struct { + GVariant *asv; + gsize partial_magic; + guintptr y[14]; + } s; + guintptr x[16]; + } u; +}; + +/** + * G_VARIANT_DICT_INIT: + * @asv: (nullable): a GVariant* + * + * A stack-allocated #GVariantDict must be initialized if it is used + * together with g_auto() to avoid warnings or crashes if function + * returns before g_variant_dict_init() is called on the builder. + * + * This macro can be used as initializer instead of an explicit + * zeroing a variable when declaring it and a following + * g_variant_dict_init(), but it cannot be assigned to a variable. + * + * The passed @asv has to live long enough for #GVariantDict to gather + * the entries from, as the gathering does not happen in the + * G_VARIANT_DICT_INIT() call, but rather in functions that make sure + * that #GVariantDict is valid. In context where the initialization + * value has to be a constant expression, the only possible value of + * @asv is %NULL. It is still possible to call g_variant_dict_init() + * safely with a different @asv right after the variable was + * initialized with G_VARIANT_DICT_INIT(). + * + * |[ + * g_autoptr(GVariant) variant = get_asv_variant (); + * g_auto(GVariantDict) dict = G_VARIANT_DICT_INIT (variant); + * ]| + * + * Since: 2.50 + */ +#define G_VARIANT_DICT_INIT(asv) \ + { \ + { \ + { \ + asv, 3488698669u /* == GVSD_MAGIC_PARTIAL, see gvariant.c */, { 0, } \ + } \ + } \ + } + +GLIB_AVAILABLE_IN_2_40 +GVariantDict * g_variant_dict_new (GVariant *from_asv); + +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_init (GVariantDict *dict, + GVariant *from_asv); + +GLIB_AVAILABLE_IN_2_40 +gboolean g_variant_dict_lookup (GVariantDict *dict, + const gchar *key, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_2_40 +GVariant * g_variant_dict_lookup_value (GVariantDict *dict, + const gchar *key, + const GVariantType *expected_type); +GLIB_AVAILABLE_IN_2_40 +gboolean g_variant_dict_contains (GVariantDict *dict, + const gchar *key); +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_insert (GVariantDict *dict, + const gchar *key, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_insert_value (GVariantDict *dict, + const gchar *key, + GVariant *value); +GLIB_AVAILABLE_IN_2_40 +gboolean g_variant_dict_remove (GVariantDict *dict, + const gchar *key); +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_clear (GVariantDict *dict); +GLIB_AVAILABLE_IN_2_40 +GVariant * g_variant_dict_end (GVariantDict *dict); +GLIB_AVAILABLE_IN_2_40 +GVariantDict * g_variant_dict_ref (GVariantDict *dict); +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_unref (GVariantDict *dict); + +G_END_DECLS + +#endif /* __G_VARIANT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gvarianttype.h b/illumos-x86_64/usr/include/glib-2.0/glib/gvarianttype.h new file mode 100644 index 00000000..38980af8 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gvarianttype.h @@ -0,0 +1,391 @@ +/* + * Copyright © 2007, 2008 Ryan Lortie + * Copyright © 2009, 2010 Codethink Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_VARIANT_TYPE_H__ +#define __G_VARIANT_TYPE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +typedef struct _GVariantType GVariantType; + +/** + * G_VARIANT_TYPE_BOOLEAN: + * + * The type of a value that can be either true or false. + **/ +#define G_VARIANT_TYPE_BOOLEAN ((const GVariantType *) "b") + +/** + * G_VARIANT_TYPE_BYTE: + * + * The type of an integer value that can range from 0 to 255. + **/ +#define G_VARIANT_TYPE_BYTE ((const GVariantType *) "y") + +/** + * G_VARIANT_TYPE_INT16: + * + * The type of an integer value that can range from -32768 to 32767. + **/ +#define G_VARIANT_TYPE_INT16 ((const GVariantType *) "n") + +/** + * G_VARIANT_TYPE_UINT16: + * + * The type of an integer value that can range from 0 to 65535. + * + * There were about this many people living in Toronto in the 1870s. + **/ +#define G_VARIANT_TYPE_UINT16 ((const GVariantType *) "q") + +/** + * G_VARIANT_TYPE_INT32: + * + * The type of an integer value that can range from -2147483648 to + * 2147483647. + **/ +#define G_VARIANT_TYPE_INT32 ((const GVariantType *) "i") + +/** + * G_VARIANT_TYPE_UINT32: + * + * The type of an integer value that can range from 0 to 4294967295. + * + * That’s one number for everyone who was around in the late 1970s. + **/ +#define G_VARIANT_TYPE_UINT32 ((const GVariantType *) "u") + +/** + * G_VARIANT_TYPE_INT64: + * + * The type of an integer value that can range from + * -9223372036854775808 to 9223372036854775807. + **/ +#define G_VARIANT_TYPE_INT64 ((const GVariantType *) "x") + +/** + * G_VARIANT_TYPE_UINT64: + * + * The type of an integer value that can range from 0 + * to 18446744073709551615 (inclusive). + * + * That’s a really big number, but a Rubik’s cube can have a bit more than + * twice as many possible positions. + **/ +#define G_VARIANT_TYPE_UINT64 ((const GVariantType *) "t") + +/** + * G_VARIANT_TYPE_DOUBLE: + * + * The type of a double precision + * [IEEE 754 floating point number](https://en.wikipedia.org/wiki/IEEE_754). + * + * These go up to about 1.80e308 (plus and minus) but miss out on + * some numbers in between. In any case, that’s far greater than the + * estimated number of fundamental particles in the observable + * universe. + **/ +#define G_VARIANT_TYPE_DOUBLE ((const GVariantType *) "d") + +/** + * G_VARIANT_TYPE_STRING: + * + * The type of a string. + * + * `""` is a string. `NULL` is not a string. + **/ +#define G_VARIANT_TYPE_STRING ((const GVariantType *) "s") + +/** + * G_VARIANT_TYPE_OBJECT_PATH: + * + * The type of a + * [D-Bus object path](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path). + * + * These are strings of a specific format used to identify objects at a given + * destination on the bus. + * + * If you are not interacting with D-Bus, then there is no reason to make + * use of this type. If you are, then the D-Bus specification contains a + * [precise description of valid object paths](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path). + **/ +#define G_VARIANT_TYPE_OBJECT_PATH ((const GVariantType *) "o") + +/** + * G_VARIANT_TYPE_SIGNATURE: + * + * The type of a + * [D-Bus type signature](https://dbus.freedesktop.org/doc/dbus-specification.html#type-system). + * + * These are strings of a specific format used as type signatures for D-Bus + * methods and messages. + * + * If you are not interacting with D-Bus, then there is no reason to make + * use of this type. If you are, then the D-Bus specification contains a + * [precise description of valid signature strings](https://dbus.freedesktop.org/doc/dbus-specification.html#type-system). + **/ +#define G_VARIANT_TYPE_SIGNATURE ((const GVariantType *) "g") + +/** + * G_VARIANT_TYPE_VARIANT: + * + * The type of a box that contains any other value (including another + * variant). + **/ +#define G_VARIANT_TYPE_VARIANT ((const GVariantType *) "v") + +/** + * G_VARIANT_TYPE_HANDLE: + * + * The type of a 32-bit signed integer value, that by convention, is used + * as an index into an array of file descriptors that are sent alongside + * a D-Bus message. + * + * If you are not interacting with D-Bus, then there is no reason to make + * use of this type. + **/ +#define G_VARIANT_TYPE_HANDLE ((const GVariantType *) "h") + +/** + * G_VARIANT_TYPE_UNIT: + * + * The empty tuple type. + * + * Has only one instance. Known also as ‘triv’ or ‘void’. + **/ +#define G_VARIANT_TYPE_UNIT ((const GVariantType *) "()") + +/** + * G_VARIANT_TYPE_ANY: + * + * An indefinite type that is a supertype of every type (including + * itself). + **/ +#define G_VARIANT_TYPE_ANY ((const GVariantType *) "*") + +/** + * G_VARIANT_TYPE_BASIC: + * + * An indefinite type that is a supertype of every basic (ie: + * non-container) type. + **/ +#define G_VARIANT_TYPE_BASIC ((const GVariantType *) "?") + +/** + * G_VARIANT_TYPE_MAYBE: + * + * An indefinite type that is a supertype of every ‘maybe’ type. + **/ +#define G_VARIANT_TYPE_MAYBE ((const GVariantType *) "m*") + +/** + * G_VARIANT_TYPE_ARRAY: + * + * An indefinite type that is a supertype of every array type. + **/ +#define G_VARIANT_TYPE_ARRAY ((const GVariantType *) "a*") + +/** + * G_VARIANT_TYPE_TUPLE: + * + * An indefinite type that is a supertype of every tuple type, + * regardless of the number of items in the tuple. + **/ +#define G_VARIANT_TYPE_TUPLE ((const GVariantType *) "r") + +/** + * G_VARIANT_TYPE_DICT_ENTRY: + * + * An indefinite type that is a supertype of every dictionary entry + * type. + **/ +#define G_VARIANT_TYPE_DICT_ENTRY ((const GVariantType *) "{?*}") + +/** + * G_VARIANT_TYPE_DICTIONARY: + * + * An indefinite type that is a supertype of every dictionary type — + * that is, any array type that has an element type equal to any + * dictionary entry type. + **/ +#define G_VARIANT_TYPE_DICTIONARY ((const GVariantType *) "a{?*}") + +/** + * G_VARIANT_TYPE_STRING_ARRAY: + * + * The type of an array of strings. + **/ +#define G_VARIANT_TYPE_STRING_ARRAY ((const GVariantType *) "as") + +/** + * G_VARIANT_TYPE_OBJECT_PATH_ARRAY: + * + * The type of an array of object paths. + **/ +#define G_VARIANT_TYPE_OBJECT_PATH_ARRAY ((const GVariantType *) "ao") + +/** + * G_VARIANT_TYPE_BYTESTRING: + * + * The type of an array of bytes. + * + * This type is commonly used to pass around strings that may not be valid + * UTF-8, such as file system paths. In that case, the + * convention is that the nul terminator character should be included as + * the last character in the array. + **/ +#define G_VARIANT_TYPE_BYTESTRING ((const GVariantType *) "ay") + +/** + * G_VARIANT_TYPE_BYTESTRING_ARRAY: + * + * The type of an array of byte strings (an array of arrays of bytes). + **/ +#define G_VARIANT_TYPE_BYTESTRING_ARRAY ((const GVariantType *) "aay") + +/** + * G_VARIANT_TYPE_VARDICT: + * + * The type of a dictionary mapping strings to variants (the ubiquitous + * `a{sv}` type). + * + * Since: 2.30 + **/ +#define G_VARIANT_TYPE_VARDICT ((const GVariantType *) "a{sv}") + + +/** + * G_VARIANT_TYPE: + * @type_string: a well-formed [type@GLib.VariantType] type string + * + * Converts a string to a const [type@GLib.VariantType]. + * + * Depending on the current debugging level, this function may perform a runtime + * check to ensure that @string is a valid [type@GLib.Variant] type string. + * + * It is always a programmer error to use this macro with an invalid + * type string. If in doubt, use [func@GLib.variant_type_string_is_valid] to + * check if the string is valid. + * + * Since 2.24 + **/ +#ifndef G_DISABLE_CAST_CHECKS +# define G_VARIANT_TYPE(type_string) (g_variant_type_checked_ ((type_string))) +#else +# define G_VARIANT_TYPE(type_string) ((const GVariantType *) (type_string)) +#endif + +/* type string checking */ +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_string_is_valid (const gchar *type_string) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_string_scan (const gchar *string, + const gchar *limit, + const gchar **endptr); + +/* create/destroy */ +GLIB_AVAILABLE_IN_ALL +void g_variant_type_free (GVariantType *type); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_copy (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new (const gchar *type_string); + +/* getters */ +GLIB_AVAILABLE_IN_ALL +gsize g_variant_type_get_string_length (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +const gchar * g_variant_type_peek_string (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gchar * g_variant_type_dup_string (const GVariantType *type); + +/* classification */ +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_definite (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_container (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_basic (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_maybe (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_array (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_tuple (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_dict_entry (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_variant (const GVariantType *type) G_GNUC_CONST; + +/* for hash tables */ +GLIB_AVAILABLE_IN_ALL +guint g_variant_type_hash (gconstpointer type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_equal (gconstpointer type1, + gconstpointer type2); + +/* subtypes */ +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_subtype_of (const GVariantType *type, + const GVariantType *supertype) G_GNUC_CONST; + +/* type iterator interface */ +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_element (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_first (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_next (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gsize g_variant_type_n_items (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_key (const GVariantType *type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_value (const GVariantType *type) G_GNUC_CONST; + +/* constructors */ +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new_array (const GVariantType *element); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new_maybe (const GVariantType *element); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new_tuple (const GVariantType * const *items, + gint length); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new_dict_entry (const GVariantType *key, + const GVariantType *value); + +/*< private >*/ +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_checked_ (const gchar *type_string); +GLIB_AVAILABLE_IN_2_60 +gsize g_variant_type_string_get_depth_ (const gchar *type_string); + +G_END_DECLS + +#endif /* __G_VARIANT_TYPE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gversion.h b/illumos-x86_64/usr/include/glib-2.0/glib/gversion.h new file mode 100644 index 00000000..d15f5481 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gversion.h @@ -0,0 +1,57 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_VERSION_H__ +#define __G_VERSION_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +GLIB_VAR const guint glib_major_version; +GLIB_VAR const guint glib_minor_version; +GLIB_VAR const guint glib_micro_version; +GLIB_VAR const guint glib_interface_age; +GLIB_VAR const guint glib_binary_age; + +GLIB_AVAILABLE_IN_ALL +const gchar * glib_check_version (guint required_major, + guint required_minor, + guint required_micro); + +#define GLIB_CHECK_VERSION(major,minor,micro) \ + (GLIB_MAJOR_VERSION > (major) || \ + (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \ + (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \ + GLIB_MICRO_VERSION >= (micro))) + +G_END_DECLS + +#endif /* __G_VERSION_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/glib/gversionmacros.h b/illumos-x86_64/usr/include/glib-2.0/glib/gversionmacros.h new file mode 100644 index 00000000..68d4768e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/glib/gversionmacros.h @@ -0,0 +1,517 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_VERSION_MACROS_H__ +#define __G_VERSION_MACROS_H__ + +#if !defined(__GLIB_H_INSIDE__) && !defined(GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* Version boundaries checks */ + +#define G_ENCODE_VERSION(major, minor) ((major) << 16 | (minor) << 8) + +/** +* GLIB_VERSION_2_2: +* +* A macro that evaluates to the 2.2 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_2 (G_ENCODE_VERSION (2, 2)) +/** +* GLIB_VERSION_2_4: +* +* A macro that evaluates to the 2.4 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_4 (G_ENCODE_VERSION (2, 4)) +/** +* GLIB_VERSION_2_6: +* +* A macro that evaluates to the 2.6 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_6 (G_ENCODE_VERSION (2, 6)) +/** +* GLIB_VERSION_2_8: +* +* A macro that evaluates to the 2.8 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_8 (G_ENCODE_VERSION (2, 8)) +/** +* GLIB_VERSION_2_10: +* +* A macro that evaluates to the 2.10 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_10 (G_ENCODE_VERSION (2, 10)) +/** +* GLIB_VERSION_2_12: +* +* A macro that evaluates to the 2.12 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_12 (G_ENCODE_VERSION (2, 12)) +/** +* GLIB_VERSION_2_14: +* +* A macro that evaluates to the 2.14 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_14 (G_ENCODE_VERSION (2, 14)) +/** +* GLIB_VERSION_2_16: +* +* A macro that evaluates to the 2.16 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_16 (G_ENCODE_VERSION (2, 16)) +/** +* GLIB_VERSION_2_18: +* +* A macro that evaluates to the 2.18 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_18 (G_ENCODE_VERSION (2, 18)) +/** +* GLIB_VERSION_2_20: +* +* A macro that evaluates to the 2.20 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_20 (G_ENCODE_VERSION (2, 20)) +/** +* GLIB_VERSION_2_22: +* +* A macro that evaluates to the 2.22 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_22 (G_ENCODE_VERSION (2, 22)) +/** +* GLIB_VERSION_2_24: +* +* A macro that evaluates to the 2.24 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_24 (G_ENCODE_VERSION (2, 24)) +/** +* GLIB_VERSION_2_26: +* +* A macro that evaluates to the 2.26 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_26 (G_ENCODE_VERSION (2, 26)) +/** +* GLIB_VERSION_2_28: +* +* A macro that evaluates to the 2.28 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_28 (G_ENCODE_VERSION (2, 28)) +/** +* GLIB_VERSION_2_30: +* +* A macro that evaluates to the 2.30 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_30 (G_ENCODE_VERSION (2, 30)) +/** +* GLIB_VERSION_2_32: +* +* A macro that evaluates to the 2.32 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.32 +*/ +#define GLIB_VERSION_2_32 (G_ENCODE_VERSION (2, 32)) +/** +* GLIB_VERSION_2_34: +* +* A macro that evaluates to the 2.34 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.34 +*/ +#define GLIB_VERSION_2_34 (G_ENCODE_VERSION (2, 34)) +/** +* GLIB_VERSION_2_36: +* +* A macro that evaluates to the 2.36 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.36 +*/ +#define GLIB_VERSION_2_36 (G_ENCODE_VERSION (2, 36)) +/** +* GLIB_VERSION_2_38: +* +* A macro that evaluates to the 2.38 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.38 +*/ +#define GLIB_VERSION_2_38 (G_ENCODE_VERSION (2, 38)) +/** +* GLIB_VERSION_2_40: +* +* A macro that evaluates to the 2.40 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.40 +*/ +#define GLIB_VERSION_2_40 (G_ENCODE_VERSION (2, 40)) +/** +* GLIB_VERSION_2_42: +* +* A macro that evaluates to the 2.42 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.42 +*/ +#define GLIB_VERSION_2_42 (G_ENCODE_VERSION (2, 42)) +/** +* GLIB_VERSION_2_44: +* +* A macro that evaluates to the 2.44 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.44 +*/ +#define GLIB_VERSION_2_44 (G_ENCODE_VERSION (2, 44)) +/** +* GLIB_VERSION_2_46: +* +* A macro that evaluates to the 2.46 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.46 +*/ +#define GLIB_VERSION_2_46 (G_ENCODE_VERSION (2, 46)) +/** +* GLIB_VERSION_2_48: +* +* A macro that evaluates to the 2.48 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.48 +*/ +#define GLIB_VERSION_2_48 (G_ENCODE_VERSION (2, 48)) +/** +* GLIB_VERSION_2_50: +* +* A macro that evaluates to the 2.50 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.50 +*/ +#define GLIB_VERSION_2_50 (G_ENCODE_VERSION (2, 50)) +/** +* GLIB_VERSION_2_52: +* +* A macro that evaluates to the 2.52 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.52 +*/ +#define GLIB_VERSION_2_52 (G_ENCODE_VERSION (2, 52)) +/** +* GLIB_VERSION_2_54: +* +* A macro that evaluates to the 2.54 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.54 +*/ +#define GLIB_VERSION_2_54 (G_ENCODE_VERSION (2, 54)) +/** +* GLIB_VERSION_2_56: +* +* A macro that evaluates to the 2.56 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.56 +*/ +#define GLIB_VERSION_2_56 (G_ENCODE_VERSION (2, 56)) +/** +* GLIB_VERSION_2_58: +* +* A macro that evaluates to the 2.58 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.58 +*/ +#define GLIB_VERSION_2_58 (G_ENCODE_VERSION (2, 58)) +/** +* GLIB_VERSION_2_60: +* +* A macro that evaluates to the 2.60 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.60 +*/ +#define GLIB_VERSION_2_60 (G_ENCODE_VERSION (2, 60)) +/** +* GLIB_VERSION_2_62: +* +* A macro that evaluates to the 2.62 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.62 +*/ +#define GLIB_VERSION_2_62 (G_ENCODE_VERSION (2, 62)) +/** +* GLIB_VERSION_2_64: +* +* A macro that evaluates to the 2.64 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.64 +*/ +#define GLIB_VERSION_2_64 (G_ENCODE_VERSION (2, 64)) +/** +* GLIB_VERSION_2_66: +* +* A macro that evaluates to the 2.66 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.66 +*/ +#define GLIB_VERSION_2_66 (G_ENCODE_VERSION (2, 66)) +/** +* GLIB_VERSION_2_68: +* +* A macro that evaluates to the 2.68 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.68 +*/ +#define GLIB_VERSION_2_68 (G_ENCODE_VERSION (2, 68)) +/** +* GLIB_VERSION_2_70: +* +* A macro that evaluates to the 2.70 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.70 +*/ +#define GLIB_VERSION_2_70 (G_ENCODE_VERSION (2, 70)) +/** +* GLIB_VERSION_2_72: +* +* A macro that evaluates to the 2.72 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.72 +*/ +#define GLIB_VERSION_2_72 (G_ENCODE_VERSION (2, 72)) +/** +* GLIB_VERSION_2_74: +* +* A macro that evaluates to the 2.74 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.74 +*/ +#define GLIB_VERSION_2_74 (G_ENCODE_VERSION (2, 74)) +/** +* GLIB_VERSION_2_76: +* +* A macro that evaluates to the 2.76 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.76 +*/ +#define GLIB_VERSION_2_76 (G_ENCODE_VERSION (2, 76)) +/** +* GLIB_VERSION_2_78: +* +* A macro that evaluates to the 2.78 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.78 +*/ +#define GLIB_VERSION_2_78 (G_ENCODE_VERSION (2, 78)) +/** +* GLIB_VERSION_2_80: +* +* A macro that evaluates to the 2.80 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.80 +*/ +#define GLIB_VERSION_2_80 (G_ENCODE_VERSION (2, 80)) +/** +* GLIB_VERSION_2_82: +* +* A macro that evaluates to the 2.82 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.82 +*/ +#define GLIB_VERSION_2_82 (G_ENCODE_VERSION (2, 82)) +/** +* GLIB_VERSION_2_84: +* +* A macro that evaluates to the 2.84 version of GLib, in a format +* that can be used by the C pre-processor. +* +* Since: 2.84 +*/ +#define GLIB_VERSION_2_84 (G_ENCODE_VERSION (2, 84)) + +/** + * GLIB_VERSION_CUR_STABLE: + * + * A macro that evaluates to the current stable version of GLib, in a format + * that can be used by the C pre-processor. + * + * During an unstable development cycle, this evaluates to the next stable + * (unreleased) version which will be the result of the development cycle. + * + * Since: 2.32 + */ +#if (GLIB_MINOR_VERSION % 2) +#define GLIB_VERSION_CUR_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION + 1)) +#else +#define GLIB_VERSION_CUR_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION)) +#endif + +/** + * GLIB_VERSION_PREV_STABLE: + * + * A macro that evaluates to the previous stable version of GLib, in a format + * that can be used by the C pre-processor. + * + * During an unstable development cycle, this evaluates to the most recent + * released stable release, which preceded this development cycle. + * + * Since: 2.32 + */ +#if (GLIB_MINOR_VERSION % 2) +#define GLIB_VERSION_PREV_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 1)) +#else +#define GLIB_VERSION_PREV_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 2)) +#endif + +/** + * GLIB_VERSION_MIN_REQUIRED: + * + * A macro that should be defined by the user prior to including + * the glib.h header. + * The definition should be one of the predefined GLib version + * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,... + * + * This macro defines the earliest version of GLib that the package is + * required to be able to compile against. + * + * If the compiler is configured to warn about the use of deprecated + * functions, then using functions that were deprecated in version + * %GLIB_VERSION_MIN_REQUIRED or earlier will cause warnings (but + * using functions deprecated in later releases will not). + * + * Since: 2.32 + */ +/* If the package sets GLIB_VERSION_MIN_REQUIRED to some future + * GLIB_VERSION_X_Y value that we don't know about, it will compare as + * 0 in preprocessor tests. + */ +#ifndef GLIB_VERSION_MIN_REQUIRED +#define GLIB_VERSION_MIN_REQUIRED (GLIB_VERSION_CUR_STABLE) +#elif GLIB_VERSION_MIN_REQUIRED == 0 +#undef GLIB_VERSION_MIN_REQUIRED +#define GLIB_VERSION_MIN_REQUIRED (GLIB_VERSION_CUR_STABLE + 2) +#endif + +/** + * GLIB_VERSION_MAX_ALLOWED: + * + * A macro that should be defined by the user prior to including + * the glib.h header. + * The definition should be one of the predefined GLib version + * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,... + * + * This macro defines the latest version of the GLib API that the + * package is allowed to make use of. + * + * If the compiler is configured to warn about the use of deprecated + * functions, then using functions added after version + * %GLIB_VERSION_MAX_ALLOWED will cause warnings. + * + * Unless you are using GLIB_CHECK_VERSION() or the like to compile + * different code depending on the GLib version, then this should be + * set to the same value as %GLIB_VERSION_MIN_REQUIRED. + * + * Since: 2.32 + */ +#if !defined(GLIB_VERSION_MAX_ALLOWED) || (GLIB_VERSION_MAX_ALLOWED == 0) +#undef GLIB_VERSION_MAX_ALLOWED +#define GLIB_VERSION_MAX_ALLOWED (GLIB_VERSION_CUR_STABLE) +#endif + +/* sanity checks */ +#if GLIB_VERSION_MIN_REQUIRED > GLIB_VERSION_CUR_STABLE +#error "GLIB_VERSION_MIN_REQUIRED must be <= GLIB_VERSION_CUR_STABLE" +#endif +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_MIN_REQUIRED +#error "GLIB_VERSION_MAX_ALLOWED must be >= GLIB_VERSION_MIN_REQUIRED" +#endif +#if GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_26 +#error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26" +#endif + +#endif /* __G_VERSION_MACROS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gmodule.h b/illumos-x86_64/usr/include/glib-2.0/gmodule.h new file mode 100644 index 00000000..5330a08e --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gmodule.h @@ -0,0 +1,147 @@ +/* GMODULE - GLIB wrapper code for dynamic module loading + * Copyright (C) 1998 Tim Janik + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __GMODULE_H__ +#define __GMODULE_H__ + +#include +#include + +G_BEGIN_DECLS + +/* exporting and importing functions, this is special cased + * to feature Windows dll stubs. + */ +#if defined(_WIN32) || defined(__CYGWIN__) +# define G_MODULE_EXPORT __declspec(dllexport) +# define G_MODULE_IMPORT __declspec(dllimport) extern +#elif __GNUC__ >= 4 +# define G_MODULE_EXPORT __attribute__((visibility("default"))) +# define G_MODULE_IMPORT extern +#else /* !defined(_WIN32) && !defined(__CYGWIN__) && __GNUC__ < 4 */ +# define G_MODULE_EXPORT +# define G_MODULE_IMPORT extern +#endif + +/** + * GModuleFlags: + * @G_MODULE_BIND_LAZY: specifies that symbols are only resolved when + * needed. The default action is to bind all symbols when the module + * is loaded. + * @G_MODULE_BIND_LOCAL: specifies that symbols in the module should + * not be added to the global name space. The default action on most + * platforms is to place symbols in the module in the global name space, + * which may cause conflicts with existing symbols. + * @G_MODULE_BIND_MASK: mask for all flags. + * + * Flags passed to g_module_open(). + * Note that these flags are not supported on all platforms. + */ +typedef enum +{ + G_MODULE_BIND_LAZY = 1 << 0, + G_MODULE_BIND_LOCAL = 1 << 1, + G_MODULE_BIND_MASK = 0x03 +} GModuleFlags; + +typedef struct _GModule GModule; +typedef const gchar* (*GModuleCheckInit) (GModule *module); +typedef void (*GModuleUnload) (GModule *module); + +#define G_MODULE_ERROR g_module_error_quark () GMODULE_AVAILABLE_MACRO_IN_2_70 +GMODULE_AVAILABLE_IN_2_70 +GQuark g_module_error_quark (void); + +/** + * GModuleError: + * @G_MODULE_ERROR_FAILED: there was an error loading or opening a module file + * @G_MODULE_ERROR_CHECK_FAILED: a module returned an error from its `g_module_check_init()` function + * + * Errors returned by g_module_open_full(). + * + * Since: 2.70 + */ +typedef enum +{ + G_MODULE_ERROR_FAILED, + G_MODULE_ERROR_CHECK_FAILED, +} GModuleError +GMODULE_AVAILABLE_ENUMERATOR_IN_2_70; + +/* return TRUE if dynamic module loading is supported */ +GMODULE_AVAILABLE_IN_ALL +gboolean g_module_supported (void) G_GNUC_CONST; + +/* open a module 'file_name' and return handle, which is NULL on error */ +GMODULE_AVAILABLE_IN_ALL +GModule* g_module_open (const gchar *file_name, + GModuleFlags flags); + +GMODULE_AVAILABLE_IN_2_70 +GModule *g_module_open_full (const gchar *file_name, + GModuleFlags flags, + GError **error); + +/* close a previously opened module, returns TRUE on success */ +GMODULE_AVAILABLE_IN_ALL +gboolean g_module_close (GModule *module); + +/* make a module resident so g_module_close on it will be ignored */ +GMODULE_AVAILABLE_IN_ALL +void g_module_make_resident (GModule *module); + +/* query the last module error as a string */ +GMODULE_AVAILABLE_IN_ALL +const gchar * g_module_error (void); + +/* retrieve a symbol pointer from 'module', returns TRUE on success */ +GMODULE_AVAILABLE_IN_ALL +gboolean g_module_symbol (GModule *module, + const gchar *symbol_name, + gpointer *symbol); + +/* retrieve the file name from an existing module */ +GMODULE_AVAILABLE_IN_ALL +const gchar * g_module_name (GModule *module); + +/* Build the actual file name containing a module. 'directory' is the + * directory where the module file is supposed to be, or NULL or empty + * in which case it should either be in the current directory or, on + * some operating systems, in some standard place, for instance on the + * PATH. Hence, to be absolutely sure to get the correct module, + * always pass in a directory. The file name consists of the directory, + * if supplied, and 'module_name' suitably decorated according to + * the operating system's conventions (for instance lib*.so or *.dll). + * + * No checks are made that the file exists, or is of correct type. + */ +GMODULE_DEPRECATED_IN_2_76 +gchar* g_module_build_path (const gchar *directory, + const gchar *module_name); + +G_END_DECLS + +#endif /* __GMODULE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gmodule/gmodule-visibility.h b/illumos-x86_64/usr/include/glib-2.0/gmodule/gmodule-visibility.h new file mode 100644 index 00000000..50b31597 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gmodule/gmodule-visibility.h @@ -0,0 +1,1054 @@ +#pragma once + +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(GMODULE_STATIC_COMPILATION) +# define _GMODULE_EXPORT __declspec(dllexport) +# define _GMODULE_IMPORT __declspec(dllimport) +#elif __GNUC__ >= 4 +# define _GMODULE_EXPORT __attribute__((visibility("default"))) +# define _GMODULE_IMPORT +#else +# define _GMODULE_EXPORT +# define _GMODULE_IMPORT +#endif +#ifdef GMODULE_COMPILATION +# define _GMODULE_API _GMODULE_EXPORT +#else +# define _GMODULE_API _GMODULE_IMPORT +#endif + +#define _GMODULE_EXTERN _GMODULE_API extern + +#define GMODULE_VAR _GMODULE_EXTERN +#define GMODULE_AVAILABLE_IN_ALL _GMODULE_EXTERN + +#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS +#define GMODULE_DEPRECATED _GMODULE_EXTERN +#define GMODULE_DEPRECATED_FOR(f) _GMODULE_EXTERN +#define GMODULE_UNAVAILABLE(maj,min) _GMODULE_EXTERN +#define GMODULE_UNAVAILABLE_STATIC_INLINE(maj,min) +#else +#define GMODULE_DEPRECATED G_DEPRECATED _GMODULE_EXTERN +#define GMODULE_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GMODULE_EXTERN +#define GMODULE_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GMODULE_EXTERN +#define GMODULE_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min) +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26 +#define GMODULE_DEPRECATED_IN_2_26 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_26_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_26 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_26_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_26 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_26 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_26_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_26 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_26_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_26 +#define GMODULE_DEPRECATED_MACRO_IN_2_26_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_26 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_26 +#define GMODULE_DEPRECATED_TYPE_IN_2_26_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26 +#define GMODULE_AVAILABLE_IN_2_26 GMODULE_UNAVAILABLE (2, 26) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_26 GLIB_UNAVAILABLE_STATIC_INLINE (2, 26) +#define GMODULE_AVAILABLE_MACRO_IN_2_26 GLIB_UNAVAILABLE_MACRO (2, 26) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_26 GLIB_UNAVAILABLE_ENUMERATOR (2, 26) +#define GMODULE_AVAILABLE_TYPE_IN_2_26 GLIB_UNAVAILABLE_TYPE (2, 26) +#else +#define GMODULE_AVAILABLE_IN_2_26 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_26 +#define GMODULE_AVAILABLE_MACRO_IN_2_26 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_26 +#define GMODULE_AVAILABLE_TYPE_IN_2_26 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28 +#define GMODULE_DEPRECATED_IN_2_28 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_28_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_28 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_28_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_28 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_28 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_28_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_28 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_28_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_28 +#define GMODULE_DEPRECATED_MACRO_IN_2_28_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_28 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_28 +#define GMODULE_DEPRECATED_TYPE_IN_2_28_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28 +#define GMODULE_AVAILABLE_IN_2_28 GMODULE_UNAVAILABLE (2, 28) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_28 GLIB_UNAVAILABLE_STATIC_INLINE (2, 28) +#define GMODULE_AVAILABLE_MACRO_IN_2_28 GLIB_UNAVAILABLE_MACRO (2, 28) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_28 GLIB_UNAVAILABLE_ENUMERATOR (2, 28) +#define GMODULE_AVAILABLE_TYPE_IN_2_28 GLIB_UNAVAILABLE_TYPE (2, 28) +#else +#define GMODULE_AVAILABLE_IN_2_28 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_28 +#define GMODULE_AVAILABLE_MACRO_IN_2_28 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_28 +#define GMODULE_AVAILABLE_TYPE_IN_2_28 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30 +#define GMODULE_DEPRECATED_IN_2_30 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_30_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_30 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_30_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_30 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_30 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_30_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_30 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_30_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_30 +#define GMODULE_DEPRECATED_MACRO_IN_2_30_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_30 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_30 +#define GMODULE_DEPRECATED_TYPE_IN_2_30_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30 +#define GMODULE_AVAILABLE_IN_2_30 GMODULE_UNAVAILABLE (2, 30) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_30 GLIB_UNAVAILABLE_STATIC_INLINE (2, 30) +#define GMODULE_AVAILABLE_MACRO_IN_2_30 GLIB_UNAVAILABLE_MACRO (2, 30) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_30 GLIB_UNAVAILABLE_ENUMERATOR (2, 30) +#define GMODULE_AVAILABLE_TYPE_IN_2_30 GLIB_UNAVAILABLE_TYPE (2, 30) +#else +#define GMODULE_AVAILABLE_IN_2_30 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_30 +#define GMODULE_AVAILABLE_MACRO_IN_2_30 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_30 +#define GMODULE_AVAILABLE_TYPE_IN_2_30 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32 +#define GMODULE_DEPRECATED_IN_2_32 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_32_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_32 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_32_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_32 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_32 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_32_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_32 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_32_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_32 +#define GMODULE_DEPRECATED_MACRO_IN_2_32_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_32 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_32 +#define GMODULE_DEPRECATED_TYPE_IN_2_32_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32 +#define GMODULE_AVAILABLE_IN_2_32 GMODULE_UNAVAILABLE (2, 32) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_32 GLIB_UNAVAILABLE_STATIC_INLINE (2, 32) +#define GMODULE_AVAILABLE_MACRO_IN_2_32 GLIB_UNAVAILABLE_MACRO (2, 32) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_32 GLIB_UNAVAILABLE_ENUMERATOR (2, 32) +#define GMODULE_AVAILABLE_TYPE_IN_2_32 GLIB_UNAVAILABLE_TYPE (2, 32) +#else +#define GMODULE_AVAILABLE_IN_2_32 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_32 +#define GMODULE_AVAILABLE_MACRO_IN_2_32 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_32 +#define GMODULE_AVAILABLE_TYPE_IN_2_32 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34 +#define GMODULE_DEPRECATED_IN_2_34 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_34_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_34 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_34_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_34 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_34 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_34_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_34 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_34_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_34 +#define GMODULE_DEPRECATED_MACRO_IN_2_34_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_34 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_34 +#define GMODULE_DEPRECATED_TYPE_IN_2_34_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34 +#define GMODULE_AVAILABLE_IN_2_34 GMODULE_UNAVAILABLE (2, 34) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_34 GLIB_UNAVAILABLE_STATIC_INLINE (2, 34) +#define GMODULE_AVAILABLE_MACRO_IN_2_34 GLIB_UNAVAILABLE_MACRO (2, 34) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_34 GLIB_UNAVAILABLE_ENUMERATOR (2, 34) +#define GMODULE_AVAILABLE_TYPE_IN_2_34 GLIB_UNAVAILABLE_TYPE (2, 34) +#else +#define GMODULE_AVAILABLE_IN_2_34 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_34 +#define GMODULE_AVAILABLE_MACRO_IN_2_34 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_34 +#define GMODULE_AVAILABLE_TYPE_IN_2_34 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36 +#define GMODULE_DEPRECATED_IN_2_36 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_36_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_36 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_36_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_36 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_36 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_36_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_36 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_36_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_36 +#define GMODULE_DEPRECATED_MACRO_IN_2_36_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_36 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_36 +#define GMODULE_DEPRECATED_TYPE_IN_2_36_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36 +#define GMODULE_AVAILABLE_IN_2_36 GMODULE_UNAVAILABLE (2, 36) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_36 GLIB_UNAVAILABLE_STATIC_INLINE (2, 36) +#define GMODULE_AVAILABLE_MACRO_IN_2_36 GLIB_UNAVAILABLE_MACRO (2, 36) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_36 GLIB_UNAVAILABLE_ENUMERATOR (2, 36) +#define GMODULE_AVAILABLE_TYPE_IN_2_36 GLIB_UNAVAILABLE_TYPE (2, 36) +#else +#define GMODULE_AVAILABLE_IN_2_36 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_36 +#define GMODULE_AVAILABLE_MACRO_IN_2_36 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_36 +#define GMODULE_AVAILABLE_TYPE_IN_2_36 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_38 +#define GMODULE_DEPRECATED_IN_2_38 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_38_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_38 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_38_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_38 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_38 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_38_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_38 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_38_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_38 +#define GMODULE_DEPRECATED_MACRO_IN_2_38_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_38 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_38 +#define GMODULE_DEPRECATED_TYPE_IN_2_38_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 +#define GMODULE_AVAILABLE_IN_2_38 GMODULE_UNAVAILABLE (2, 38) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_38 GLIB_UNAVAILABLE_STATIC_INLINE (2, 38) +#define GMODULE_AVAILABLE_MACRO_IN_2_38 GLIB_UNAVAILABLE_MACRO (2, 38) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_38 GLIB_UNAVAILABLE_ENUMERATOR (2, 38) +#define GMODULE_AVAILABLE_TYPE_IN_2_38 GLIB_UNAVAILABLE_TYPE (2, 38) +#else +#define GMODULE_AVAILABLE_IN_2_38 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_38 +#define GMODULE_AVAILABLE_MACRO_IN_2_38 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_38 +#define GMODULE_AVAILABLE_TYPE_IN_2_38 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_40 +#define GMODULE_DEPRECATED_IN_2_40 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_40_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_40 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_40_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_40 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_40 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_40_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_40 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_40_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_40 +#define GMODULE_DEPRECATED_MACRO_IN_2_40_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_40 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_40 +#define GMODULE_DEPRECATED_TYPE_IN_2_40_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_40 +#define GMODULE_AVAILABLE_IN_2_40 GMODULE_UNAVAILABLE (2, 40) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_40 GLIB_UNAVAILABLE_STATIC_INLINE (2, 40) +#define GMODULE_AVAILABLE_MACRO_IN_2_40 GLIB_UNAVAILABLE_MACRO (2, 40) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_40 GLIB_UNAVAILABLE_ENUMERATOR (2, 40) +#define GMODULE_AVAILABLE_TYPE_IN_2_40 GLIB_UNAVAILABLE_TYPE (2, 40) +#else +#define GMODULE_AVAILABLE_IN_2_40 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_40 +#define GMODULE_AVAILABLE_MACRO_IN_2_40 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_40 +#define GMODULE_AVAILABLE_TYPE_IN_2_40 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_42 +#define GMODULE_DEPRECATED_IN_2_42 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_42_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_42 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_42_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_42 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_42 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_42_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_42 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_42_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_42 +#define GMODULE_DEPRECATED_MACRO_IN_2_42_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_42 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_42 +#define GMODULE_DEPRECATED_TYPE_IN_2_42_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_42 +#define GMODULE_AVAILABLE_IN_2_42 GMODULE_UNAVAILABLE (2, 42) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_42 GLIB_UNAVAILABLE_STATIC_INLINE (2, 42) +#define GMODULE_AVAILABLE_MACRO_IN_2_42 GLIB_UNAVAILABLE_MACRO (2, 42) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_42 GLIB_UNAVAILABLE_ENUMERATOR (2, 42) +#define GMODULE_AVAILABLE_TYPE_IN_2_42 GLIB_UNAVAILABLE_TYPE (2, 42) +#else +#define GMODULE_AVAILABLE_IN_2_42 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_42 +#define GMODULE_AVAILABLE_MACRO_IN_2_42 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_42 +#define GMODULE_AVAILABLE_TYPE_IN_2_42 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_44 +#define GMODULE_DEPRECATED_IN_2_44 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_44_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_44 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_44_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_44 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_44 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_44_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_44 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_44_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_44 +#define GMODULE_DEPRECATED_MACRO_IN_2_44_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_44 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_44 +#define GMODULE_DEPRECATED_TYPE_IN_2_44_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_44 +#define GMODULE_AVAILABLE_IN_2_44 GMODULE_UNAVAILABLE (2, 44) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_44 GLIB_UNAVAILABLE_STATIC_INLINE (2, 44) +#define GMODULE_AVAILABLE_MACRO_IN_2_44 GLIB_UNAVAILABLE_MACRO (2, 44) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_44 GLIB_UNAVAILABLE_ENUMERATOR (2, 44) +#define GMODULE_AVAILABLE_TYPE_IN_2_44 GLIB_UNAVAILABLE_TYPE (2, 44) +#else +#define GMODULE_AVAILABLE_IN_2_44 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_44 +#define GMODULE_AVAILABLE_MACRO_IN_2_44 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_44 +#define GMODULE_AVAILABLE_TYPE_IN_2_44 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_46 +#define GMODULE_DEPRECATED_IN_2_46 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_46_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_46 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_46_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_46 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_46 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_46_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_46 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_46_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_46 +#define GMODULE_DEPRECATED_MACRO_IN_2_46_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_46 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_46 +#define GMODULE_DEPRECATED_TYPE_IN_2_46_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_46 +#define GMODULE_AVAILABLE_IN_2_46 GMODULE_UNAVAILABLE (2, 46) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_46 GLIB_UNAVAILABLE_STATIC_INLINE (2, 46) +#define GMODULE_AVAILABLE_MACRO_IN_2_46 GLIB_UNAVAILABLE_MACRO (2, 46) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_46 GLIB_UNAVAILABLE_ENUMERATOR (2, 46) +#define GMODULE_AVAILABLE_TYPE_IN_2_46 GLIB_UNAVAILABLE_TYPE (2, 46) +#else +#define GMODULE_AVAILABLE_IN_2_46 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_46 +#define GMODULE_AVAILABLE_MACRO_IN_2_46 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_46 +#define GMODULE_AVAILABLE_TYPE_IN_2_46 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_48 +#define GMODULE_DEPRECATED_IN_2_48 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_48_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_48 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_48_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_48 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_48 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_48_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_48 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_48_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_48 +#define GMODULE_DEPRECATED_MACRO_IN_2_48_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_48 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_48 +#define GMODULE_DEPRECATED_TYPE_IN_2_48_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_48 +#define GMODULE_AVAILABLE_IN_2_48 GMODULE_UNAVAILABLE (2, 48) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_48 GLIB_UNAVAILABLE_STATIC_INLINE (2, 48) +#define GMODULE_AVAILABLE_MACRO_IN_2_48 GLIB_UNAVAILABLE_MACRO (2, 48) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_48 GLIB_UNAVAILABLE_ENUMERATOR (2, 48) +#define GMODULE_AVAILABLE_TYPE_IN_2_48 GLIB_UNAVAILABLE_TYPE (2, 48) +#else +#define GMODULE_AVAILABLE_IN_2_48 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_48 +#define GMODULE_AVAILABLE_MACRO_IN_2_48 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_48 +#define GMODULE_AVAILABLE_TYPE_IN_2_48 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_50 +#define GMODULE_DEPRECATED_IN_2_50 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_50_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_50 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_50_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_50 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_50 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_50_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_50 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_50_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_50 +#define GMODULE_DEPRECATED_MACRO_IN_2_50_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_50 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_50 +#define GMODULE_DEPRECATED_TYPE_IN_2_50_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_50 +#define GMODULE_AVAILABLE_IN_2_50 GMODULE_UNAVAILABLE (2, 50) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_50 GLIB_UNAVAILABLE_STATIC_INLINE (2, 50) +#define GMODULE_AVAILABLE_MACRO_IN_2_50 GLIB_UNAVAILABLE_MACRO (2, 50) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_50 GLIB_UNAVAILABLE_ENUMERATOR (2, 50) +#define GMODULE_AVAILABLE_TYPE_IN_2_50 GLIB_UNAVAILABLE_TYPE (2, 50) +#else +#define GMODULE_AVAILABLE_IN_2_50 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_50 +#define GMODULE_AVAILABLE_MACRO_IN_2_50 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_50 +#define GMODULE_AVAILABLE_TYPE_IN_2_50 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_52 +#define GMODULE_DEPRECATED_IN_2_52 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_52_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_52 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_52_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_52 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_52 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_52_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_52 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_52_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_52 +#define GMODULE_DEPRECATED_MACRO_IN_2_52_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_52 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_52 +#define GMODULE_DEPRECATED_TYPE_IN_2_52_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_52 +#define GMODULE_AVAILABLE_IN_2_52 GMODULE_UNAVAILABLE (2, 52) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_52 GLIB_UNAVAILABLE_STATIC_INLINE (2, 52) +#define GMODULE_AVAILABLE_MACRO_IN_2_52 GLIB_UNAVAILABLE_MACRO (2, 52) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_52 GLIB_UNAVAILABLE_ENUMERATOR (2, 52) +#define GMODULE_AVAILABLE_TYPE_IN_2_52 GLIB_UNAVAILABLE_TYPE (2, 52) +#else +#define GMODULE_AVAILABLE_IN_2_52 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_52 +#define GMODULE_AVAILABLE_MACRO_IN_2_52 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_52 +#define GMODULE_AVAILABLE_TYPE_IN_2_52 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_54 +#define GMODULE_DEPRECATED_IN_2_54 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_54_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_54 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_54_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_54 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_54 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_54_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_54 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_54_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_54 +#define GMODULE_DEPRECATED_MACRO_IN_2_54_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_54 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_54 +#define GMODULE_DEPRECATED_TYPE_IN_2_54_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_54 +#define GMODULE_AVAILABLE_IN_2_54 GMODULE_UNAVAILABLE (2, 54) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_54 GLIB_UNAVAILABLE_STATIC_INLINE (2, 54) +#define GMODULE_AVAILABLE_MACRO_IN_2_54 GLIB_UNAVAILABLE_MACRO (2, 54) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_54 GLIB_UNAVAILABLE_ENUMERATOR (2, 54) +#define GMODULE_AVAILABLE_TYPE_IN_2_54 GLIB_UNAVAILABLE_TYPE (2, 54) +#else +#define GMODULE_AVAILABLE_IN_2_54 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_54 +#define GMODULE_AVAILABLE_MACRO_IN_2_54 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_54 +#define GMODULE_AVAILABLE_TYPE_IN_2_54 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_56 +#define GMODULE_DEPRECATED_IN_2_56 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_56_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_56 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_56_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_56 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_56 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_56_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_56 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_56_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_56 +#define GMODULE_DEPRECATED_MACRO_IN_2_56_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_56 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_56 +#define GMODULE_DEPRECATED_TYPE_IN_2_56_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_56 +#define GMODULE_AVAILABLE_IN_2_56 GMODULE_UNAVAILABLE (2, 56) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_56 GLIB_UNAVAILABLE_STATIC_INLINE (2, 56) +#define GMODULE_AVAILABLE_MACRO_IN_2_56 GLIB_UNAVAILABLE_MACRO (2, 56) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_56 GLIB_UNAVAILABLE_ENUMERATOR (2, 56) +#define GMODULE_AVAILABLE_TYPE_IN_2_56 GLIB_UNAVAILABLE_TYPE (2, 56) +#else +#define GMODULE_AVAILABLE_IN_2_56 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_56 +#define GMODULE_AVAILABLE_MACRO_IN_2_56 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_56 +#define GMODULE_AVAILABLE_TYPE_IN_2_56 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_58 +#define GMODULE_DEPRECATED_IN_2_58 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_58_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_58 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_58_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_58 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_58 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_58_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_58 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_58_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_58 +#define GMODULE_DEPRECATED_MACRO_IN_2_58_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_58 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_58 +#define GMODULE_DEPRECATED_TYPE_IN_2_58_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_58 +#define GMODULE_AVAILABLE_IN_2_58 GMODULE_UNAVAILABLE (2, 58) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_58 GLIB_UNAVAILABLE_STATIC_INLINE (2, 58) +#define GMODULE_AVAILABLE_MACRO_IN_2_58 GLIB_UNAVAILABLE_MACRO (2, 58) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_58 GLIB_UNAVAILABLE_ENUMERATOR (2, 58) +#define GMODULE_AVAILABLE_TYPE_IN_2_58 GLIB_UNAVAILABLE_TYPE (2, 58) +#else +#define GMODULE_AVAILABLE_IN_2_58 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_58 +#define GMODULE_AVAILABLE_MACRO_IN_2_58 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_58 +#define GMODULE_AVAILABLE_TYPE_IN_2_58 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_60 +#define GMODULE_DEPRECATED_IN_2_60 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_60_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_60 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_60_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_60 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_60 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_60_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_60 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_60_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_60 +#define GMODULE_DEPRECATED_MACRO_IN_2_60_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_60 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_60 +#define GMODULE_DEPRECATED_TYPE_IN_2_60_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_60 +#define GMODULE_AVAILABLE_IN_2_60 GMODULE_UNAVAILABLE (2, 60) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_60 GLIB_UNAVAILABLE_STATIC_INLINE (2, 60) +#define GMODULE_AVAILABLE_MACRO_IN_2_60 GLIB_UNAVAILABLE_MACRO (2, 60) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_60 GLIB_UNAVAILABLE_ENUMERATOR (2, 60) +#define GMODULE_AVAILABLE_TYPE_IN_2_60 GLIB_UNAVAILABLE_TYPE (2, 60) +#else +#define GMODULE_AVAILABLE_IN_2_60 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_60 +#define GMODULE_AVAILABLE_MACRO_IN_2_60 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_60 +#define GMODULE_AVAILABLE_TYPE_IN_2_60 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_62 +#define GMODULE_DEPRECATED_IN_2_62 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_62_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_62 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_62_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_62 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_62 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_62_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_62 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_62_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_62 +#define GMODULE_DEPRECATED_MACRO_IN_2_62_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_62 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_62 +#define GMODULE_DEPRECATED_TYPE_IN_2_62_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_62 +#define GMODULE_AVAILABLE_IN_2_62 GMODULE_UNAVAILABLE (2, 62) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_62 GLIB_UNAVAILABLE_STATIC_INLINE (2, 62) +#define GMODULE_AVAILABLE_MACRO_IN_2_62 GLIB_UNAVAILABLE_MACRO (2, 62) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_62 GLIB_UNAVAILABLE_ENUMERATOR (2, 62) +#define GMODULE_AVAILABLE_TYPE_IN_2_62 GLIB_UNAVAILABLE_TYPE (2, 62) +#else +#define GMODULE_AVAILABLE_IN_2_62 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_62 +#define GMODULE_AVAILABLE_MACRO_IN_2_62 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_62 +#define GMODULE_AVAILABLE_TYPE_IN_2_62 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 +#define GMODULE_DEPRECATED_IN_2_64 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_64_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_64 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_64_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_64 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_64 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_64_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_64 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_64_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_64 +#define GMODULE_DEPRECATED_MACRO_IN_2_64_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_64 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_64 +#define GMODULE_DEPRECATED_TYPE_IN_2_64_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64 +#define GMODULE_AVAILABLE_IN_2_64 GMODULE_UNAVAILABLE (2, 64) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_64 GLIB_UNAVAILABLE_STATIC_INLINE (2, 64) +#define GMODULE_AVAILABLE_MACRO_IN_2_64 GLIB_UNAVAILABLE_MACRO (2, 64) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_64 GLIB_UNAVAILABLE_ENUMERATOR (2, 64) +#define GMODULE_AVAILABLE_TYPE_IN_2_64 GLIB_UNAVAILABLE_TYPE (2, 64) +#else +#define GMODULE_AVAILABLE_IN_2_64 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_64 +#define GMODULE_AVAILABLE_MACRO_IN_2_64 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_64 +#define GMODULE_AVAILABLE_TYPE_IN_2_64 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_66 +#define GMODULE_DEPRECATED_IN_2_66 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_66_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_66 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_66_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_66 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_66 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_66_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_66 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_66_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_66 +#define GMODULE_DEPRECATED_MACRO_IN_2_66_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_66 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_66 +#define GMODULE_DEPRECATED_TYPE_IN_2_66_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_66 +#define GMODULE_AVAILABLE_IN_2_66 GMODULE_UNAVAILABLE (2, 66) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_66 GLIB_UNAVAILABLE_STATIC_INLINE (2, 66) +#define GMODULE_AVAILABLE_MACRO_IN_2_66 GLIB_UNAVAILABLE_MACRO (2, 66) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_66 GLIB_UNAVAILABLE_ENUMERATOR (2, 66) +#define GMODULE_AVAILABLE_TYPE_IN_2_66 GLIB_UNAVAILABLE_TYPE (2, 66) +#else +#define GMODULE_AVAILABLE_IN_2_66 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_66 +#define GMODULE_AVAILABLE_MACRO_IN_2_66 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_66 +#define GMODULE_AVAILABLE_TYPE_IN_2_66 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68 +#define GMODULE_DEPRECATED_IN_2_68 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_68_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_68 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_68_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_68 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_68 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_68_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_68 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_68_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_68 +#define GMODULE_DEPRECATED_MACRO_IN_2_68_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_68 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_68 +#define GMODULE_DEPRECATED_TYPE_IN_2_68_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_68 +#define GMODULE_AVAILABLE_IN_2_68 GMODULE_UNAVAILABLE (2, 68) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_68 GLIB_UNAVAILABLE_STATIC_INLINE (2, 68) +#define GMODULE_AVAILABLE_MACRO_IN_2_68 GLIB_UNAVAILABLE_MACRO (2, 68) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_68 GLIB_UNAVAILABLE_ENUMERATOR (2, 68) +#define GMODULE_AVAILABLE_TYPE_IN_2_68 GLIB_UNAVAILABLE_TYPE (2, 68) +#else +#define GMODULE_AVAILABLE_IN_2_68 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_68 +#define GMODULE_AVAILABLE_MACRO_IN_2_68 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_68 +#define GMODULE_AVAILABLE_TYPE_IN_2_68 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_70 +#define GMODULE_DEPRECATED_IN_2_70 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_70_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_70 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_70_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_70 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_70 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_70_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_70 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_70_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_70 +#define GMODULE_DEPRECATED_MACRO_IN_2_70_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_70 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_70 +#define GMODULE_DEPRECATED_TYPE_IN_2_70_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_70 +#define GMODULE_AVAILABLE_IN_2_70 GMODULE_UNAVAILABLE (2, 70) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_70 GLIB_UNAVAILABLE_STATIC_INLINE (2, 70) +#define GMODULE_AVAILABLE_MACRO_IN_2_70 GLIB_UNAVAILABLE_MACRO (2, 70) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_70 GLIB_UNAVAILABLE_ENUMERATOR (2, 70) +#define GMODULE_AVAILABLE_TYPE_IN_2_70 GLIB_UNAVAILABLE_TYPE (2, 70) +#else +#define GMODULE_AVAILABLE_IN_2_70 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_70 +#define GMODULE_AVAILABLE_MACRO_IN_2_70 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_70 +#define GMODULE_AVAILABLE_TYPE_IN_2_70 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_72 +#define GMODULE_DEPRECATED_IN_2_72 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_72_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_72 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_72_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_72 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_72 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_72_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_72 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_72_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_72 +#define GMODULE_DEPRECATED_MACRO_IN_2_72_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_72 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_72 +#define GMODULE_DEPRECATED_TYPE_IN_2_72_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_72 +#define GMODULE_AVAILABLE_IN_2_72 GMODULE_UNAVAILABLE (2, 72) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_72 GLIB_UNAVAILABLE_STATIC_INLINE (2, 72) +#define GMODULE_AVAILABLE_MACRO_IN_2_72 GLIB_UNAVAILABLE_MACRO (2, 72) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_72 GLIB_UNAVAILABLE_ENUMERATOR (2, 72) +#define GMODULE_AVAILABLE_TYPE_IN_2_72 GLIB_UNAVAILABLE_TYPE (2, 72) +#else +#define GMODULE_AVAILABLE_IN_2_72 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_72 +#define GMODULE_AVAILABLE_MACRO_IN_2_72 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_72 +#define GMODULE_AVAILABLE_TYPE_IN_2_72 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_74 +#define GMODULE_DEPRECATED_IN_2_74 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_74_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_74 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_74_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_74 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_74 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_74_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_74 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_74_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_74 +#define GMODULE_DEPRECATED_MACRO_IN_2_74_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_74 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_74 +#define GMODULE_DEPRECATED_TYPE_IN_2_74_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_74 +#define GMODULE_AVAILABLE_IN_2_74 GMODULE_UNAVAILABLE (2, 74) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_74 GLIB_UNAVAILABLE_STATIC_INLINE (2, 74) +#define GMODULE_AVAILABLE_MACRO_IN_2_74 GLIB_UNAVAILABLE_MACRO (2, 74) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_74 GLIB_UNAVAILABLE_ENUMERATOR (2, 74) +#define GMODULE_AVAILABLE_TYPE_IN_2_74 GLIB_UNAVAILABLE_TYPE (2, 74) +#else +#define GMODULE_AVAILABLE_IN_2_74 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_74 +#define GMODULE_AVAILABLE_MACRO_IN_2_74 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_74 +#define GMODULE_AVAILABLE_TYPE_IN_2_74 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76 +#define GMODULE_DEPRECATED_IN_2_76 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_76_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_76 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_76_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_76 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_76 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_76_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_76 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_76_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_76 +#define GMODULE_DEPRECATED_MACRO_IN_2_76_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_76 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_76 +#define GMODULE_DEPRECATED_TYPE_IN_2_76_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_76 +#define GMODULE_AVAILABLE_IN_2_76 GMODULE_UNAVAILABLE (2, 76) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_76 GLIB_UNAVAILABLE_STATIC_INLINE (2, 76) +#define GMODULE_AVAILABLE_MACRO_IN_2_76 GLIB_UNAVAILABLE_MACRO (2, 76) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_76 GLIB_UNAVAILABLE_ENUMERATOR (2, 76) +#define GMODULE_AVAILABLE_TYPE_IN_2_76 GLIB_UNAVAILABLE_TYPE (2, 76) +#else +#define GMODULE_AVAILABLE_IN_2_76 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_76 +#define GMODULE_AVAILABLE_MACRO_IN_2_76 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_76 +#define GMODULE_AVAILABLE_TYPE_IN_2_76 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 +#define GMODULE_DEPRECATED_IN_2_78 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_78_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_78 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_78_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_78 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_78 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_78_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_78 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_78_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_78 +#define GMODULE_DEPRECATED_MACRO_IN_2_78_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_78 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_78 +#define GMODULE_DEPRECATED_TYPE_IN_2_78_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_78 +#define GMODULE_AVAILABLE_IN_2_78 GMODULE_UNAVAILABLE (2, 78) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_78 GLIB_UNAVAILABLE_STATIC_INLINE (2, 78) +#define GMODULE_AVAILABLE_MACRO_IN_2_78 GLIB_UNAVAILABLE_MACRO (2, 78) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_78 GLIB_UNAVAILABLE_ENUMERATOR (2, 78) +#define GMODULE_AVAILABLE_TYPE_IN_2_78 GLIB_UNAVAILABLE_TYPE (2, 78) +#else +#define GMODULE_AVAILABLE_IN_2_78 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_78 +#define GMODULE_AVAILABLE_MACRO_IN_2_78 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_78 +#define GMODULE_AVAILABLE_TYPE_IN_2_78 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_80 +#define GMODULE_DEPRECATED_IN_2_80 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_80_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_80 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_80_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_80 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_80 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_80_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_80 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_80_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_80 +#define GMODULE_DEPRECATED_MACRO_IN_2_80_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_80 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_80 +#define GMODULE_DEPRECATED_TYPE_IN_2_80_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_80 +#define GMODULE_AVAILABLE_IN_2_80 GMODULE_UNAVAILABLE (2, 80) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_80 GLIB_UNAVAILABLE_STATIC_INLINE (2, 80) +#define GMODULE_AVAILABLE_MACRO_IN_2_80 GLIB_UNAVAILABLE_MACRO (2, 80) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_80 GLIB_UNAVAILABLE_ENUMERATOR (2, 80) +#define GMODULE_AVAILABLE_TYPE_IN_2_80 GLIB_UNAVAILABLE_TYPE (2, 80) +#else +#define GMODULE_AVAILABLE_IN_2_80 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_80 +#define GMODULE_AVAILABLE_MACRO_IN_2_80 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_80 +#define GMODULE_AVAILABLE_TYPE_IN_2_80 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_82 +#define GMODULE_DEPRECATED_IN_2_82 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_82_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_82 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_82_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_82 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_82 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_82_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_82 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_82_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_82 +#define GMODULE_DEPRECATED_MACRO_IN_2_82_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_82 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_82 +#define GMODULE_DEPRECATED_TYPE_IN_2_82_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_82 +#define GMODULE_AVAILABLE_IN_2_82 GMODULE_UNAVAILABLE (2, 82) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_82 GLIB_UNAVAILABLE_STATIC_INLINE (2, 82) +#define GMODULE_AVAILABLE_MACRO_IN_2_82 GLIB_UNAVAILABLE_MACRO (2, 82) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_82 GLIB_UNAVAILABLE_ENUMERATOR (2, 82) +#define GMODULE_AVAILABLE_TYPE_IN_2_82 GLIB_UNAVAILABLE_TYPE (2, 82) +#else +#define GMODULE_AVAILABLE_IN_2_82 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_82 +#define GMODULE_AVAILABLE_MACRO_IN_2_82 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_82 +#define GMODULE_AVAILABLE_TYPE_IN_2_82 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_84 +#define GMODULE_DEPRECATED_IN_2_84 GMODULE_DEPRECATED +#define GMODULE_DEPRECATED_IN_2_84_FOR(f) GMODULE_DEPRECATED_FOR (f) +#define GMODULE_DEPRECATED_MACRO_IN_2_84 GLIB_DEPRECATED_MACRO +#define GMODULE_DEPRECATED_MACRO_IN_2_84_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_84 GLIB_DEPRECATED_ENUMERATOR +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GMODULE_DEPRECATED_TYPE_IN_2_84 GLIB_DEPRECATED_TYPE +#define GMODULE_DEPRECATED_TYPE_IN_2_84_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GMODULE_DEPRECATED_IN_2_84 _GMODULE_EXTERN +#define GMODULE_DEPRECATED_IN_2_84_FOR(f) _GMODULE_EXTERN +#define GMODULE_DEPRECATED_MACRO_IN_2_84 +#define GMODULE_DEPRECATED_MACRO_IN_2_84_FOR(f) +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_84 +#define GMODULE_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) +#define GMODULE_DEPRECATED_TYPE_IN_2_84 +#define GMODULE_DEPRECATED_TYPE_IN_2_84_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_84 +#define GMODULE_AVAILABLE_IN_2_84 GMODULE_UNAVAILABLE (2, 84) +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_84 GLIB_UNAVAILABLE_STATIC_INLINE (2, 84) +#define GMODULE_AVAILABLE_MACRO_IN_2_84 GLIB_UNAVAILABLE_MACRO (2, 84) +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_84 GLIB_UNAVAILABLE_ENUMERATOR (2, 84) +#define GMODULE_AVAILABLE_TYPE_IN_2_84 GLIB_UNAVAILABLE_TYPE (2, 84) +#else +#define GMODULE_AVAILABLE_IN_2_84 _GMODULE_EXTERN +#define GMODULE_AVAILABLE_STATIC_INLINE_IN_2_84 +#define GMODULE_AVAILABLE_MACRO_IN_2_84 +#define GMODULE_AVAILABLE_ENUMERATOR_IN_2_84 +#define GMODULE_AVAILABLE_TYPE_IN_2_84 +#endif diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gbinding.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gbinding.h new file mode 100644 index 00000000..4c7da7e2 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gbinding.h @@ -0,0 +1,148 @@ +/* gbinding.h: Binding for object properties + * + * Copyright (C) 2010 Intel Corp. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Emmanuele Bassi + */ + +#ifndef __G_BINDING_H__ +#define __G_BINDING_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define G_TYPE_BINDING_FLAGS (g_binding_flags_get_type ()) + +#define G_TYPE_BINDING (g_binding_get_type ()) +#define G_BINDING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_BINDING, GBinding)) +#define G_IS_BINDING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_BINDING)) + +typedef struct _GBinding GBinding; + +/** + * GBindingTransformFunc: + * @binding: a #GBinding + * @from_value: the #GValue containing the value to transform + * @to_value: the #GValue in which to store the transformed value + * @user_data: data passed to the transform function + * + * A function to be called to transform @from_value to @to_value. + * + * If this is the @transform_to function of a binding, then @from_value + * is the @source_property on the @source object, and @to_value is the + * @target_property on the @target object. If this is the + * @transform_from function of a %G_BINDING_BIDIRECTIONAL binding, + * then those roles are reversed. + * + * Returns: %TRUE if the transformation was successful, and %FALSE + * otherwise + * + * Since: 2.26 + */ +typedef gboolean (* GBindingTransformFunc) (GBinding *binding, + const GValue *from_value, + GValue *to_value, + gpointer user_data); + +/** + * GBindingFlags: + * @G_BINDING_DEFAULT: The default binding; if the source property + * changes, the target property is updated with its value. + * @G_BINDING_BIDIRECTIONAL: Bidirectional binding; if either the + * property of the source or the property of the target changes, + * the other is updated. + * @G_BINDING_SYNC_CREATE: Synchronize the values of the source and + * target properties when creating the binding; the direction of + * the synchronization is always from the source to the target. + * @G_BINDING_INVERT_BOOLEAN: If the two properties being bound are + * booleans, setting one to %TRUE will result in the other being + * set to %FALSE and vice versa. This flag will only work for + * boolean properties, and cannot be used when passing custom + * transformation functions to g_object_bind_property_full(). + * + * Flags to be passed to g_object_bind_property() or + * g_object_bind_property_full(). + * + * This enumeration can be extended at later date. + * + * Since: 2.26 + */ +typedef enum { /*< prefix=G_BINDING >*/ + G_BINDING_DEFAULT = 0, + + G_BINDING_BIDIRECTIONAL = 1 << 0, + G_BINDING_SYNC_CREATE = 1 << 1, + G_BINDING_INVERT_BOOLEAN = 1 << 2 +} GBindingFlags; + +GOBJECT_AVAILABLE_IN_ALL +GType g_binding_flags_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_binding_get_type (void) G_GNUC_CONST; + +GOBJECT_AVAILABLE_IN_ALL +GBindingFlags g_binding_get_flags (GBinding *binding); +GOBJECT_DEPRECATED_IN_2_68_FOR(g_binding_dup_source) +GObject * g_binding_get_source (GBinding *binding); +GOBJECT_AVAILABLE_IN_2_68 +GObject * g_binding_dup_source (GBinding *binding); +GOBJECT_DEPRECATED_IN_2_68_FOR(g_binding_dup_target) +GObject * g_binding_get_target (GBinding *binding); +GOBJECT_AVAILABLE_IN_2_68 +GObject * g_binding_dup_target (GBinding *binding); +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_binding_get_source_property (GBinding *binding); +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_binding_get_target_property (GBinding *binding); +GOBJECT_AVAILABLE_IN_2_38 +void g_binding_unbind (GBinding *binding); + +GOBJECT_AVAILABLE_IN_ALL +GBinding *g_object_bind_property (gpointer source, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GBinding *g_object_bind_property_full (gpointer source, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags, + GBindingTransformFunc transform_to, + GBindingTransformFunc transform_from, + gpointer user_data, + GDestroyNotify notify); +GOBJECT_AVAILABLE_IN_ALL +GBinding *g_object_bind_property_with_closures (gpointer source, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags, + GClosure *transform_to, + GClosure *transform_from); + +G_END_DECLS + +#endif /* __G_BINDING_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gbindinggroup.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gbindinggroup.h new file mode 100644 index 00000000..39857919 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gbindinggroup.h @@ -0,0 +1,77 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * + * Copyright (C) 2015-2022 Christian Hergert + * Copyright (C) 2015 Garrett Regier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef __G_BINDING_GROUP_H__ +#define __G_BINDING_GROUP_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +#define G_BINDING_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_BINDING_GROUP, GBindingGroup)) +#define G_IS_BINDING_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_BINDING_GROUP)) +#define G_TYPE_BINDING_GROUP (g_binding_group_get_type()) + +typedef struct _GBindingGroup GBindingGroup; + +GOBJECT_AVAILABLE_IN_2_72 +GType g_binding_group_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_72 +GBindingGroup *g_binding_group_new (void); +GOBJECT_AVAILABLE_IN_2_72 +gpointer g_binding_group_dup_source (GBindingGroup *self); +GOBJECT_AVAILABLE_IN_2_72 +void g_binding_group_set_source (GBindingGroup *self, + gpointer source); +GOBJECT_AVAILABLE_IN_2_72 +void g_binding_group_bind (GBindingGroup *self, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags); +GOBJECT_AVAILABLE_IN_2_72 +void g_binding_group_bind_full (GBindingGroup *self, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags, + GBindingTransformFunc transform_to, + GBindingTransformFunc transform_from, + gpointer user_data, + GDestroyNotify user_data_destroy); +GOBJECT_AVAILABLE_IN_2_72 +void g_binding_group_bind_with_closures (GBindingGroup *self, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags, + GClosure *transform_to, + GClosure *transform_from); + +G_END_DECLS + +#endif /* __G_BINDING_GROUP_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gboxed.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gboxed.h new file mode 100644 index 00000000..d7b3d4e9 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gboxed.h @@ -0,0 +1,124 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000-2001 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_BOXED_H__ +#define __G_BOXED_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#ifndef __GI_SCANNER__ +#include +#endif + +G_BEGIN_DECLS + +/* --- type macros --- */ +#define G_TYPE_IS_BOXED(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED) +/** + * G_VALUE_HOLDS_BOXED: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived + * from type %G_TYPE_BOXED. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED)) + + +/* --- typedefs --- */ +/** + * GBoxedCopyFunc: + * @boxed: (not nullable): The boxed structure to be copied. + * + * This function is provided by the user and should produce a copy + * of the passed in boxed structure. + * + * Returns: (not nullable): The newly created copy of the boxed structure. + */ +typedef gpointer (*GBoxedCopyFunc) (gpointer boxed); + +/** + * GBoxedFreeFunc: + * @boxed: (not nullable): The boxed structure to be freed. + * + * This function is provided by the user and should free the boxed + * structure passed. + */ +typedef void (*GBoxedFreeFunc) (gpointer boxed); + + +/* --- prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +gpointer g_boxed_copy (GType boxed_type, + gconstpointer src_boxed); +GOBJECT_AVAILABLE_IN_ALL +void g_boxed_free (GType boxed_type, + gpointer boxed); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_boxed (GValue *value, + gconstpointer v_boxed); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_static_boxed (GValue *value, + gconstpointer v_boxed); +GOBJECT_AVAILABLE_IN_ALL +void g_value_take_boxed (GValue *value, + gconstpointer v_boxed); +GOBJECT_DEPRECATED_FOR(g_value_take_boxed) +void g_value_set_boxed_take_ownership (GValue *value, + gconstpointer v_boxed); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_value_get_boxed (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_value_dup_boxed (const GValue *value); + + +/* --- convenience --- */ +GOBJECT_AVAILABLE_IN_ALL +GType g_boxed_type_register_static (const gchar *name, + GBoxedCopyFunc boxed_copy, + GBoxedFreeFunc boxed_free); + +/* --- GObject boxed types --- */ +/** + * G_TYPE_CLOSURE: + * + * The #GType for #GClosure. + */ +#define G_TYPE_CLOSURE (g_closure_get_type ()) + +/** + * G_TYPE_VALUE: + * + * The type ID of the "GValue" type which is a boxed type, + * used to pass around pointers to GValues. + */ +#define G_TYPE_VALUE (g_value_get_type ()) + +GOBJECT_AVAILABLE_IN_ALL +GType g_closure_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_value_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_BOXED_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gclosure.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gclosure.h new file mode 100644 index 00000000..2462bce5 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gclosure.h @@ -0,0 +1,315 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000-2001 Red Hat, Inc. + * Copyright (C) 2005 Imendio AB + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_CLOSURE_H__ +#define __G_CLOSURE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* --- defines --- */ +/** + * G_CLOSURE_NEEDS_MARSHAL: + * @closure: a #GClosure + * + * Check if the closure still needs a marshaller. See g_closure_set_marshal(). + * + * Returns: %TRUE if a #GClosureMarshal marshaller has not yet been set on + * @closure. + */ +#define G_CLOSURE_NEEDS_MARSHAL(closure) (((GClosure*) (closure))->marshal == NULL) +/** + * G_CLOSURE_N_NOTIFIERS: + * @cl: a #GClosure + * + * Get the total number of notifiers connected with the closure @cl. + * + * The count includes the meta marshaller, the finalize and invalidate notifiers + * and the marshal guards. Note that each guard counts as two notifiers. + * See g_closure_set_meta_marshal(), g_closure_add_finalize_notifier(), + * g_closure_add_invalidate_notifier() and g_closure_add_marshal_guards(). + * + * Returns: number of notifiers + */ +#define G_CLOSURE_N_NOTIFIERS(cl) (((cl)->n_guards << 1L) + \ + (cl)->n_fnotifiers + (cl)->n_inotifiers) +/** + * G_CCLOSURE_SWAP_DATA: + * @cclosure: a #GCClosure + * + * Checks whether the user data of the #GCClosure should be passed as the + * first parameter to the callback. See g_cclosure_new_swap(). + * + * Returns: %TRUE if data has to be swapped. + */ +#define G_CCLOSURE_SWAP_DATA(cclosure) (((GClosure*) (cclosure))->derivative_flag) +/** + * G_CALLBACK: + * @f: a function pointer. + * + * Cast a function pointer to a #GCallback. + */ +#define G_CALLBACK(f) ((GCallback) (f)) + + +/* -- typedefs --- */ +typedef struct _GClosure GClosure; +typedef struct _GClosureNotifyData GClosureNotifyData; + +/** + * GCallback: + * + * The type used for callback functions in structure definitions and function + * signatures. + * + * This doesn't mean that all callback functions must take no parameters and + * return void. The required signature of a callback function is determined by + * the context in which is used (e.g. the signal to which it is connected). + * + * Use G_CALLBACK() to cast the callback function to a #GCallback. + */ +typedef void (*GCallback) (void); +/** + * GClosureNotify: + * @data: data specified when registering the notification callback + * @closure: the #GClosure on which the notification is emitted + * + * The type used for the various notification callbacks which can be registered + * on closures. + */ +typedef void (*GClosureNotify) (gpointer data, + GClosure *closure); +/** + * GClosureMarshal: + * @closure: the #GClosure to which the marshaller belongs + * @return_value: (nullable): a #GValue to store the return + * value. May be %NULL if the callback of @closure doesn't return a + * value. + * @n_param_values: the length of the @param_values array + * @param_values: (array length=n_param_values): an array of + * #GValues holding the arguments on which to invoke the + * callback of @closure + * @invocation_hint: (nullable): the invocation hint given as the + * last argument to g_closure_invoke() + * @marshal_data: (nullable): additional data specified when + * registering the marshaller, see g_closure_set_marshal() and + * g_closure_set_meta_marshal() + * + * The type used for marshaller functions. + */ +typedef void (*GClosureMarshal) (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/** + * GVaClosureMarshal: + * @closure: the #GClosure to which the marshaller belongs + * @return_value: (nullable): a #GValue to store the return + * value. May be %NULL if the callback of @closure doesn't return a + * value. + * @instance: (type GObject.TypeInstance): the instance on which the closure is + * invoked. + * @args: va_list of arguments to be passed to the closure. + * @marshal_data: (nullable): additional data specified when + * registering the marshaller, see g_closure_set_marshal() and + * g_closure_set_meta_marshal() + * @n_params: the length of the @param_types array + * @param_types: (array length=n_params): the #GType of each argument from + * @args. + * + * This is the signature of va_list marshaller functions, an optional + * marshaller that can be used in some situations to avoid + * marshalling the signal argument into GValues. + */ +typedef void (* GVaClosureMarshal) (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/** + * GCClosure: + * @closure: the #GClosure + * @callback: the callback function + * + * A #GCClosure is a specialization of #GClosure for C function callbacks. + */ +typedef struct _GCClosure GCClosure; + + +/* --- structures --- */ +struct _GClosureNotifyData +{ + gpointer data; + GClosureNotify notify; +}; + +struct _GClosure +{ + /*< private >*/ + guint ref_count : 15; /* (atomic) */ + /* meta_marshal is not used anymore but must be zero for historical reasons + as it was exposed in the G_CLOSURE_N_NOTIFIERS macro */ + guint meta_marshal_nouse : 1; /* (atomic) */ + guint n_guards : 1; /* (atomic) */ + guint n_fnotifiers : 2; /* finalization notifiers (atomic) */ + guint n_inotifiers : 8; /* invalidation notifiers (atomic) */ + guint in_inotify : 1; /* (atomic) */ + guint floating : 1; /* (atomic) */ + /*< protected >*/ + guint derivative_flag : 1; /* (atomic) */ + /*< public >*/ + guint in_marshal : 1; /* (atomic) */ + guint is_invalid : 1; /* (atomic) */ + + /*< private >*/ void (*marshal) (GClosure *closure, + GValue /*out*/ *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + /*< protected >*/ gpointer data; + + /*< private >*/ GClosureNotifyData *notifiers; + + /* invariants/constraints: + * - ->marshal and ->data are _invalid_ as soon as ->is_invalid==TRUE + * - invocation of all inotifiers occurs prior to fnotifiers + * - order of inotifiers is random + * inotifiers may _not_ free/invalidate parameter values (e.g. ->data) + * - order of fnotifiers is random + * - each notifier may only be removed before or during its invocation + * - reference counting may only happen prior to fnotify invocation + * (in that sense, fnotifiers are really finalization handlers) + */ +}; +/* closure for C function calls, callback() is the user function + */ +struct _GCClosure +{ + GClosure closure; + gpointer callback; +}; + + +/* --- prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +GClosure* g_cclosure_new (GCallback callback_func, + gpointer user_data, + GClosureNotify destroy_data); +GOBJECT_AVAILABLE_IN_ALL +GClosure* g_cclosure_new_swap (GCallback callback_func, + gpointer user_data, + GClosureNotify destroy_data); +GOBJECT_AVAILABLE_IN_ALL +GClosure* g_signal_type_cclosure_new (GType itype, + guint struct_offset); + + +/* --- prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +GClosure* g_closure_ref (GClosure *closure); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_sink (GClosure *closure); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_unref (GClosure *closure); +/* intimidating */ +GOBJECT_AVAILABLE_IN_ALL +GClosure* g_closure_new_simple (guint sizeof_closure, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_add_finalize_notifier (GClosure *closure, + gpointer notify_data, + GClosureNotify notify_func); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_remove_finalize_notifier (GClosure *closure, + gpointer notify_data, + GClosureNotify notify_func); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_add_invalidate_notifier (GClosure *closure, + gpointer notify_data, + GClosureNotify notify_func); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_remove_invalidate_notifier (GClosure *closure, + gpointer notify_data, + GClosureNotify notify_func); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_add_marshal_guards (GClosure *closure, + gpointer pre_marshal_data, + GClosureNotify pre_marshal_notify, + gpointer post_marshal_data, + GClosureNotify post_marshal_notify); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_set_marshal (GClosure *closure, + GClosureMarshal marshal); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_set_meta_marshal (GClosure *closure, + gpointer marshal_data, + GClosureMarshal meta_marshal); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_invalidate (GClosure *closure); +GOBJECT_AVAILABLE_IN_ALL +void g_closure_invoke (GClosure *closure, + GValue /*out*/ *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint); + +/* FIXME: + OK: data_object::destroy -> closure_invalidate(); + MIS: closure_invalidate() -> disconnect(closure); + MIS: disconnect(closure) -> (unlink) closure_unref(); + OK: closure_finalize() -> g_free (data_string); + + random remarks: + - need marshaller repo with decent aliasing to base types + - provide marshaller collection, virtually covering anything out there +*/ + +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_generic (GClosure *closure, + GValue *return_gvalue, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_generic_va (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args_list, + gpointer marshal_data, + int n_params, + GType *param_types); + + +G_END_DECLS + +#endif /* __G_CLOSURE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/genums.h b/illumos-x86_64/usr/include/glib-2.0/gobject/genums.h new file mode 100644 index 00000000..0ee8a610 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/genums.h @@ -0,0 +1,381 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_ENUMS_H__ +#define __G_ENUMS_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_TYPE_IS_ENUM: + * @type: a #GType ID. + * + * Checks whether @type "is a" %G_TYPE_ENUM. + * + * Returns: %TRUE if @type "is a" %G_TYPE_ENUM. + */ +#define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM) +/** + * G_ENUM_CLASS: + * @class: a valid #GEnumClass + * + * Casts a derived #GEnumClass structure into a #GEnumClass structure. + */ +#define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass)) +/** + * G_IS_ENUM_CLASS: + * @class: a #GEnumClass + * + * Checks whether @class "is a" valid #GEnumClass structure of type %G_TYPE_ENUM + * or derived. + */ +#define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM)) +/** + * G_ENUM_CLASS_TYPE: + * @class: a #GEnumClass + * + * Get the type identifier from a given #GEnumClass structure. + * + * Returns: the #GType + */ +#define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) +/** + * G_ENUM_CLASS_TYPE_NAME: + * @class: a #GEnumClass + * + * Get the static type name from a given #GEnumClass structure. + * + * Returns: the type name. + */ +#define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_CLASS_TYPE (class))) + + +/** + * G_TYPE_IS_FLAGS: + * @type: a #GType ID. + * + * Checks whether @type "is a" %G_TYPE_FLAGS. + * + * Returns: %TRUE if @type "is a" %G_TYPE_FLAGS. + */ +#define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS) +/** + * G_FLAGS_CLASS: + * @class: a valid #GFlagsClass + * + * Casts a derived #GFlagsClass structure into a #GFlagsClass structure. + */ +#define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass)) +/** + * G_IS_FLAGS_CLASS: + * @class: a #GFlagsClass + * + * Checks whether @class "is a" valid #GFlagsClass structure of type %G_TYPE_FLAGS + * or derived. + */ +#define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS)) +/** + * G_FLAGS_CLASS_TYPE: + * @class: a #GFlagsClass + * + * Get the type identifier from a given #GFlagsClass structure. + * + * Returns: the #GType + */ +#define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) +/** + * G_FLAGS_CLASS_TYPE_NAME: + * @class: a #GFlagsClass + * + * Get the static type name from a given #GFlagsClass structure. + * + * Returns: the type name. + */ +#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class))) + + +/** + * G_VALUE_HOLDS_ENUM: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived from type %G_TYPE_ENUM. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM)) +/** + * G_VALUE_HOLDS_FLAGS: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived from type %G_TYPE_FLAGS. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS)) + + +/* --- enum/flag values & classes --- */ +typedef struct _GEnumClass GEnumClass; +typedef struct _GFlagsClass GFlagsClass; +typedef struct _GEnumValue GEnumValue; +typedef struct _GFlagsValue GFlagsValue; + +/** + * GEnumClass: + * @g_type_class: the parent class + * @minimum: the smallest possible value. + * @maximum: the largest possible value. + * @n_values: the number of possible values. + * @values: an array of #GEnumValue structs describing the + * individual values. + * + * The class of an enumeration type holds information about its + * possible values. + */ +struct _GEnumClass +{ + GTypeClass g_type_class; + + /*< public >*/ + gint minimum; + gint maximum; + guint n_values; + GEnumValue *values; +}; +/** + * GFlagsClass: + * @g_type_class: the parent class + * @mask: a mask covering all possible values. + * @n_values: the number of possible values. + * @values: an array of #GFlagsValue structs describing the + * individual values. + * + * The class of a flags type holds information about its + * possible values. + */ +struct _GFlagsClass +{ + GTypeClass g_type_class; + + /*< public >*/ + guint mask; + guint n_values; + GFlagsValue *values; +}; +/** + * GEnumValue: + * @value: the enum value + * @value_name: the name of the value + * @value_nick: the nickname of the value + * + * A structure which contains a single enum value, its name, and its + * nickname. + */ +struct _GEnumValue +{ + gint value; + const gchar *value_name; + const gchar *value_nick; +}; +/** + * GFlagsValue: + * @value: the flags value + * @value_name: the name of the value + * @value_nick: the nickname of the value + * + * A structure which contains a single flags value, its name, and its + * nickname. + */ +struct _GFlagsValue +{ + guint value; + const gchar *value_name; + const gchar *value_nick; +}; + + +/* --- prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +GEnumValue* g_enum_get_value (GEnumClass *enum_class, + gint value); +GOBJECT_AVAILABLE_IN_ALL +GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class, + const gchar *name); +GOBJECT_AVAILABLE_IN_ALL +GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class, + const gchar *nick); +GOBJECT_AVAILABLE_IN_ALL +GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class, + guint value); +GOBJECT_AVAILABLE_IN_ALL +GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class, + const gchar *name); +GOBJECT_AVAILABLE_IN_ALL +GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class, + const gchar *nick); +GOBJECT_AVAILABLE_IN_2_54 +gchar *g_enum_to_string (GType g_enum_type, + gint value); +GOBJECT_AVAILABLE_IN_2_54 +gchar *g_flags_to_string (GType flags_type, + guint value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_enum (GValue *value, + gint v_enum); +GOBJECT_AVAILABLE_IN_ALL +gint g_value_get_enum (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_flags (GValue *value, + guint v_flags); +GOBJECT_AVAILABLE_IN_ALL +guint g_value_get_flags (const GValue *value); + + + +/* --- registration functions --- */ +/* const_static_values is a NULL terminated array of enum/flags + * values that is taken over! + */ +GOBJECT_AVAILABLE_IN_ALL +GType g_enum_register_static (const gchar *name, + const GEnumValue *const_static_values); +GOBJECT_AVAILABLE_IN_ALL +GType g_flags_register_static (const gchar *name, + const GFlagsValue *const_static_values); +/* functions to complete the type information + * for enums/flags implemented by plugins + */ +GOBJECT_AVAILABLE_IN_ALL +void g_enum_complete_type_info (GType g_enum_type, + GTypeInfo *info, + const GEnumValue *const_values); +GOBJECT_AVAILABLE_IN_ALL +void g_flags_complete_type_info (GType g_flags_type, + GTypeInfo *info, + const GFlagsValue *const_values); + +/* {{{ Macros */ + +/** + * G_DEFINE_ENUM_VALUE: + * @EnumValue: an enumeration value + * @EnumNick: a short string representing the enumeration value + * + * Defines an enumeration value, and maps it to a "nickname". + * + * This macro can only be used with G_DEFINE_ENUM_TYPE() and + * G_DEFINE_FLAGS_TYPE(). + * + * Since: 2.74 + */ +#define G_DEFINE_ENUM_VALUE(EnumValue, EnumNick) \ + { EnumValue, #EnumValue, EnumNick } \ + GOBJECT_AVAILABLE_MACRO_IN_2_74 + +/** + * G_DEFINE_ENUM_TYPE: + * @TypeName: the enumeration type, in `CamelCase` + * @type_name: the enumeration type prefixed, in `snake_case` + * @...: a list of enumeration values, defined using G_DEFINE_ENUM_VALUE() + * + * A convenience macro for defining enumeration types. + * + * This macro will generate a `*_get_type()` function for the + * given @TypeName, using @type_name as the function prefix. + * + * |[ + * G_DEFINE_ENUM_TYPE (GtkOrientation, gtk_orientation, + * G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_HORIZONTAL, "horizontal"), + * G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_VERTICAL, "vertical")) + * ]| + * + * For projects that have multiple enumeration types, or enumeration + * types with many values, you should consider using glib-mkenums to + * generate the type function. + * + * Since: 2.74 + */ +#define G_DEFINE_ENUM_TYPE(TypeName, type_name, ...) \ +GType \ +type_name ## _get_type (void) { \ + static _g_type_once_init_type g_define_type__static = 0; \ + if (_g_type_once_init_enter (&g_define_type__static)) { \ + static const GEnumValue enum_values[] = { \ + __VA_ARGS__ , \ + { 0, NULL, NULL }, \ + }; \ + GType g_define_type = g_enum_register_static (g_intern_static_string (#TypeName), enum_values); \ + _g_type_once_init_leave (&g_define_type__static, g_define_type); \ + } \ + return g_define_type__static; \ +} \ + GOBJECT_AVAILABLE_MACRO_IN_2_74 + +/** + * G_DEFINE_FLAGS_TYPE: + * @TypeName: the enumeration type, in `CamelCase` + * @type_name: the enumeration type prefixed, in `snake_case` + * @...: a list of enumeration values, defined using G_DEFINE_ENUM_VALUE() + * + * A convenience macro for defining flag types. + * + * This macro will generate a `*_get_type()` function for the + * given @TypeName, using @type_name as the function prefix. + * + * |[ + * G_DEFINE_FLAGS_TYPE (GSettingsBindFlags, g_settings_bind_flags, + * G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_DEFAULT, "default"), + * G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET, "get"), + * G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_SET, "set"), + * G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_NO_SENSITIVITY, "no-sensitivity"), + * G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET_NO_CHANGES, "get-no-changes"), + * G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_INVERT_BOOLEAN, "invert-boolean")) + * ]| + * + * For projects that have multiple enumeration types, or enumeration + * types with many values, you should consider using glib-mkenums to + * generate the type function. + * + * Since: 2.74 + */ +#define G_DEFINE_FLAGS_TYPE(TypeName, type_name, ...) \ +GType \ +type_name ## _get_type (void) { \ + static _g_type_once_init_type g_define_type__static = 0; \ + if (_g_type_once_init_enter (&g_define_type__static)) { \ + static const GFlagsValue flags_values[] = { \ + __VA_ARGS__ , \ + { 0, NULL, NULL }, \ + }; \ + GType g_define_type = g_flags_register_static (g_intern_static_string (#TypeName), flags_values); \ + _g_type_once_init_leave (&g_define_type__static, g_define_type); \ + } \ + return g_define_type__static; \ +} \ + GOBJECT_AVAILABLE_MACRO_IN_2_74 + +G_END_DECLS + +#endif /* __G_ENUMS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/glib-enumtypes.h b/illumos-x86_64/usr/include/glib-2.0/gobject/glib-enumtypes.h new file mode 100644 index 00000000..40b3c48d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/glib-enumtypes.h @@ -0,0 +1,25 @@ + +/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ + +#ifndef __GOBJECT_ENUM_TYPES_H__ +#define __GOBJECT_ENUM_TYPES_H__ + +#include + +G_BEGIN_DECLS + +/* enumerations from "gunicode.h" */ +GOBJECT_AVAILABLE_IN_2_60 GType g_unicode_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_UNICODE_TYPE (g_unicode_type_get_type ()) +GOBJECT_AVAILABLE_IN_2_60 GType g_unicode_break_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_UNICODE_BREAK_TYPE (g_unicode_break_type_get_type ()) +GOBJECT_AVAILABLE_IN_2_60 GType g_unicode_script_get_type (void) G_GNUC_CONST; +#define G_TYPE_UNICODE_SCRIPT (g_unicode_script_get_type ()) +GOBJECT_AVAILABLE_IN_2_60 GType g_normalize_mode_get_type (void) G_GNUC_CONST; +#define G_TYPE_NORMALIZE_MODE (g_normalize_mode_get_type ()) +G_END_DECLS + +#endif /* __GOBJECT_ENUM_TYPES_H__ */ + +/* Generated data ends here */ + diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/glib-types.h b/illumos-x86_64/usr/include/glib-2.0/gobject/glib-types.h new file mode 100644 index 00000000..e31baf14 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/glib-types.h @@ -0,0 +1,453 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000-2001 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __GLIB_TYPES_H__ +#define __GLIB_TYPES_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) && !defined(GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/* A hack necesssary to preprocess this file with g-ir-scanner */ +#ifdef __GI_SCANNER__ +typedef gsize GType; +#endif + +/* --- GLib boxed types --- */ +/** + * G_TYPE_DATE: + * + * The #GType for #GDate. + */ +#define G_TYPE_DATE (g_date_get_type ()) + +/** + * G_TYPE_STRV: + * + * The #GType for a boxed type holding a %NULL-terminated array of strings. + * + * The code fragments in the following example show the use of a property of + * type %G_TYPE_STRV with g_object_class_install_property(), g_object_set() + * and g_object_get(). + * + * |[ + * g_object_class_install_property (object_class, + * PROP_AUTHORS, + * g_param_spec_boxed ("authors", + * _("Authors"), + * _("List of authors"), + * G_TYPE_STRV, + * G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + * + * gchar *authors[] = { "Owen", "Tim", NULL }; + * g_object_set (obj, "authors", authors, NULL); + * + * gchar *writers[]; + * g_object_get (obj, "authors", &writers, NULL); + * /* do something with writers */ + * g_strfreev (writers); + * ]| + * + * Since: 2.4 + */ +#define G_TYPE_STRV (g_strv_get_type ()) + +/** + * G_TYPE_GSTRING: + * + * The #GType for #GString. + */ +#define G_TYPE_GSTRING (g_gstring_get_type ()) + +/** + * G_TYPE_HASH_TABLE: + * + * The #GType for a boxed type holding a #GHashTable reference. + * + * Since: 2.10 + */ +#define G_TYPE_HASH_TABLE (g_hash_table_get_type ()) + +/** + * G_TYPE_REGEX: + * + * The #GType for a boxed type holding a #GRegex reference. + * + * Since: 2.14 + */ +#define G_TYPE_REGEX (g_regex_get_type ()) + +/** + * G_TYPE_MATCH_INFO: + * + * The #GType for a boxed type holding a #GMatchInfo reference. + * + * Since: 2.30 + */ +#define G_TYPE_MATCH_INFO (g_match_info_get_type ()) + +/** + * G_TYPE_ARRAY: + * + * The #GType for a boxed type holding a #GArray reference. + * + * Since: 2.22 + */ +#define G_TYPE_ARRAY (g_array_get_type ()) + +/** + * G_TYPE_BYTE_ARRAY: + * + * The #GType for a boxed type holding a #GByteArray reference. + * + * Since: 2.22 + */ +#define G_TYPE_BYTE_ARRAY (g_byte_array_get_type ()) + +/** + * G_TYPE_PTR_ARRAY: + * + * The #GType for a boxed type holding a #GPtrArray reference. + * + * Since: 2.22 + */ +#define G_TYPE_PTR_ARRAY (g_ptr_array_get_type ()) + +/** + * G_TYPE_BYTES: + * + * The #GType for #GBytes. + * + * Since: 2.32 + */ +#define G_TYPE_BYTES (g_bytes_get_type ()) + +/** + * G_TYPE_VARIANT_TYPE: + * + * The #GType for a boxed type holding a #GVariantType. + * + * Since: 2.24 + */ +#define G_TYPE_VARIANT_TYPE (g_variant_type_get_gtype ()) + +/** + * G_TYPE_ERROR: + * + * The #GType for a boxed type holding a #GError. + * + * Since: 2.26 + */ +#define G_TYPE_ERROR (g_error_get_type ()) + +/** + * G_TYPE_DATE_TIME: + * + * The #GType for a boxed type holding a #GDateTime. + * + * Since: 2.26 + */ +#define G_TYPE_DATE_TIME (g_date_time_get_type ()) + +/** + * G_TYPE_TIME_ZONE: + * + * The #GType for a boxed type holding a #GTimeZone. + * + * Since: 2.34 + */ +#define G_TYPE_TIME_ZONE (g_time_zone_get_type ()) + +/** + * G_TYPE_IO_CHANNEL: + * + * The #GType for #GIOChannel. + */ +#define G_TYPE_IO_CHANNEL (g_io_channel_get_type ()) + +/** + * G_TYPE_IO_CONDITION: + * + * The #GType for #GIOCondition. + */ +#define G_TYPE_IO_CONDITION (g_io_condition_get_type ()) + +/** + * G_TYPE_VARIANT_BUILDER: + * + * The #GType for a boxed type holding a #GVariantBuilder. + * + * Since: 2.30 + */ +#define G_TYPE_VARIANT_BUILDER (g_variant_builder_get_type ()) + +/** + * G_TYPE_VARIANT_DICT: + * + * The #GType for a boxed type holding a #GVariantDict. + * + * Since: 2.40 + */ +#define G_TYPE_VARIANT_DICT (g_variant_dict_get_type ()) + +/** + * G_TYPE_MAIN_LOOP: + * + * The #GType for a boxed type holding a #GMainLoop. + * + * Since: 2.30 + */ +#define G_TYPE_MAIN_LOOP (g_main_loop_get_type ()) + +/** + * G_TYPE_MAIN_CONTEXT: + * + * The #GType for a boxed type holding a #GMainContext. + * + * Since: 2.30 + */ +#define G_TYPE_MAIN_CONTEXT (g_main_context_get_type ()) + +/** + * G_TYPE_SOURCE: + * + * The #GType for a boxed type holding a #GSource. + * + * Since: 2.30 + */ +#define G_TYPE_SOURCE (g_source_get_type ()) + +/** + * G_TYPE_POLLFD: + * + * The #GType for a boxed type holding a #GPollFD. + * + * Since: 2.36 + */ +#define G_TYPE_POLLFD (g_pollfd_get_type ()) + +/** + * G_TYPE_MARKUP_PARSE_CONTEXT: + * + * The #GType for a boxed type holding a #GMarkupParseContext. + * + * Since: 2.36 + */ +#define G_TYPE_MARKUP_PARSE_CONTEXT (g_markup_parse_context_get_type ()) + +/** + * G_TYPE_KEY_FILE: + * + * The #GType for a boxed type holding a #GKeyFile. + * + * Since: 2.32 + */ +#define G_TYPE_KEY_FILE (g_key_file_get_type ()) + +/** + * G_TYPE_MAPPED_FILE: + * + * The #GType for a boxed type holding a #GMappedFile. + * + * Since: 2.40 + */ +#define G_TYPE_MAPPED_FILE (g_mapped_file_get_type ()) + +/** + * G_TYPE_THREAD: + * + * The #GType for a boxed type holding a #GThread. + * + * Since: 2.36 + */ +#define G_TYPE_THREAD (g_thread_get_type ()) + +/** + * G_TYPE_CHECKSUM: + * + * The #GType for a boxed type holding a #GChecksum. + * + * Since: 2.36 + */ +#define G_TYPE_CHECKSUM (g_checksum_get_type ()) + +/** + * G_TYPE_OPTION_GROUP: + * + * The #GType for a boxed type holding a #GOptionGroup. + * + * Since: 2.44 + */ +#define G_TYPE_OPTION_GROUP (g_option_group_get_type ()) + +/** + * G_TYPE_URI: + * + * The #GType for a boxed type holding a #GUri. + * + * Since: 2.66 + */ +#define G_TYPE_URI (g_uri_get_type ()) + +/** + * G_TYPE_TREE: + * + * The #GType for #GTree. + * + * Since: 2.68 + */ +#define G_TYPE_TREE (g_tree_get_type ()) + +/** + * G_TYPE_PATTERN_SPEC: + * + * The #GType for #GPatternSpec. + * + * Since: 2.70 + */ +#define G_TYPE_PATTERN_SPEC (g_pattern_spec_get_type ()) + +/** + * G_TYPE_BOOKMARK_FILE: + * + * The #GType for a boxed type holding a #GBookmarkFile. + * + * Since: 2.76 + */ +#define G_TYPE_BOOKMARK_FILE (g_bookmark_file_get_type ()) + +/** + * G_TYPE_HMAC: + * + * The #GType for a boxed type holding a #GHmac. + * + * Since: 2.80 + */ +#define G_TYPE_HMAC (g_hmac_get_type ()) + +/** + * G_TYPE_DIR: + * + * The #GType for a boxed type holding a #GDir. + * + * Since: 2.80 + */ +#define G_TYPE_DIR (g_dir_get_type ()) + +/** + * G_TYPE_RAND: + * + * The #GType for a boxed type holding a #GRand. + * + * Since: 2.80 + */ +#define G_TYPE_RAND (g_rand_get_type ()) + +/** + * G_TYPE_STRV_BUILDER: + * + * The #GType for a boxed type holding a #GStrvBuilder. + * + * Since: 2.80 + */ +#define G_TYPE_STRV_BUILDER (g_strv_builder_get_type ()) + +GOBJECT_AVAILABLE_IN_ALL +GType g_date_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_strv_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_gstring_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_hash_table_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_array_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_byte_array_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_ptr_array_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_bytes_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_variant_type_get_gtype (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_regex_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_30 +GType g_match_info_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_error_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_date_time_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_time_zone_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_io_channel_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_io_condition_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_variant_builder_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_40 +GType g_variant_dict_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +GType g_key_file_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_30 +GType g_main_loop_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_30 +GType g_main_context_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_30 +GType g_source_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_36 +GType g_pollfd_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_36 +GType g_thread_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_36 +GType g_checksum_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_36 +GType g_markup_parse_context_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_40 +GType g_mapped_file_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_44 +GType g_option_group_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_66 +GType g_uri_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_68 +GType g_tree_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_70 +GType g_pattern_spec_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_76 +GType g_bookmark_file_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_80 +GType g_hmac_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_80 +GType g_dir_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_80 +GType g_rand_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_80 +GType g_strv_builder_get_type (void) G_GNUC_CONST; + +GOBJECT_DEPRECATED_FOR('G_TYPE_VARIANT') +GType g_variant_get_gtype (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __GLIB_TYPES_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gmarshal.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gmarshal.h new file mode 100644 index 00000000..96c7c4ee --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gmarshal.h @@ -0,0 +1,434 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_MARSHAL_H__ +#define __G_MARSHAL_H__ + +G_BEGIN_DECLS + +/* VOID:VOID */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__VOID (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__VOIDv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:BOOLEAN */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__BOOLEAN (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__BOOLEANv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:CHAR */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__CHAR (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__CHARv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:UCHAR */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UCHAR (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UCHARv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:INT */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__INT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__INTv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:UINT */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UINT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UINTv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:LONG */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__LONG (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__LONGv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:ULONG */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__ULONG (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__ULONGv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:ENUM */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__ENUM (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__ENUMv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:FLAGS */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__FLAGS (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__FLAGSv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:FLOAT */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__FLOAT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__FLOATv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:DOUBLE */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__DOUBLE (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__DOUBLEv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:STRING */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__STRINGv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:PARAM */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__PARAM (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__PARAMv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:BOXED */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__BOXED (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__BOXEDv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:POINTER */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__POINTERv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:OBJECT */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__OBJECT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__OBJECTv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:VARIANT */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__VARIANT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__VARIANTv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:UINT,POINTER */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UINT_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UINT_POINTERv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* BOOL:FLAGS */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_BOOLEAN__FLAGS (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_BOOLEAN__FLAGSv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/** + * g_cclosure_marshal_BOOL__FLAGS: + * @closure: A #GClosure. + * @return_value: A #GValue to store the return value. May be %NULL + * if the callback of closure doesn't return a value. + * @n_param_values: The length of the @param_values array. + * @param_values: An array of #GValues holding the arguments + * on which to invoke the callback of closure. + * @invocation_hint: The invocation hint given as the last argument to + * g_closure_invoke(). + * @marshal_data: Additional data specified when registering the + * marshaller, see g_closure_set_marshal() and + * g_closure_set_meta_marshal() + * + * An old alias for g_cclosure_marshal_BOOLEAN__FLAGS(). + */ +#define g_cclosure_marshal_BOOL__FLAGS g_cclosure_marshal_BOOLEAN__FLAGS + +/* STRING:OBJECT,POINTER */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_STRING__OBJECT_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_STRING__OBJECT_POINTERv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* BOOL:BOXED,BOXED */ +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_BOOLEAN__BOXED_BOXED (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GOBJECT_AVAILABLE_IN_ALL +void g_cclosure_marshal_BOOLEAN__BOXED_BOXEDv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/** + * g_cclosure_marshal_BOOL__BOXED_BOXED: + * @closure: A #GClosure. + * @return_value: A #GValue to store the return value. May be %NULL + * if the callback of closure doesn't return a value. + * @n_param_values: The length of the @param_values array. + * @param_values: An array of #GValues holding the arguments + * on which to invoke the callback of closure. + * @invocation_hint: The invocation hint given as the last argument to + * g_closure_invoke(). + * @marshal_data: Additional data specified when registering the + * marshaller, see g_closure_set_marshal() and + * g_closure_set_meta_marshal() + * + * An old alias for g_cclosure_marshal_BOOLEAN__BOXED_BOXED(). + */ +#define g_cclosure_marshal_BOOL__BOXED_BOXED g_cclosure_marshal_BOOLEAN__BOXED_BOXED + +G_END_DECLS + +#endif /* __G_MARSHAL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gobject-autocleanups.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gobject-autocleanups.h new file mode 100644 index 00000000..23d4f6d4 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gobject-autocleanups.h @@ -0,0 +1,37 @@ +/* + * Copyright © 2015 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GI_SCANNER__ + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GClosure, g_closure_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GEnumClass, g_type_class_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFlagsClass, g_type_class_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GParamSpec, g_param_spec_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTypeClass, g_type_class_unref) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset) + +#endif /* __GI_SCANNER__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gobject-visibility.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gobject-visibility.h new file mode 100644 index 00000000..7f8a4729 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gobject-visibility.h @@ -0,0 +1,1054 @@ +#pragma once + +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(GOBJECT_STATIC_COMPILATION) +# define _GOBJECT_EXPORT __declspec(dllexport) +# define _GOBJECT_IMPORT __declspec(dllimport) +#elif __GNUC__ >= 4 +# define _GOBJECT_EXPORT __attribute__((visibility("default"))) +# define _GOBJECT_IMPORT +#else +# define _GOBJECT_EXPORT +# define _GOBJECT_IMPORT +#endif +#ifdef GOBJECT_COMPILATION +# define _GOBJECT_API _GOBJECT_EXPORT +#else +# define _GOBJECT_API _GOBJECT_IMPORT +#endif + +#define _GOBJECT_EXTERN _GOBJECT_API extern + +#define GOBJECT_VAR _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_IN_ALL _GOBJECT_EXTERN + +#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS +#define GOBJECT_DEPRECATED _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_UNAVAILABLE(maj,min) _GOBJECT_EXTERN +#define GOBJECT_UNAVAILABLE_STATIC_INLINE(maj,min) +#else +#define GOBJECT_DEPRECATED G_DEPRECATED _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GOBJECT_EXTERN +#define GOBJECT_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min) +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26 +#define GOBJECT_DEPRECATED_IN_2_26 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_26_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_26 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_26_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_26 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_26 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_26_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_26 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_26_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_26 +#define GOBJECT_DEPRECATED_MACRO_IN_2_26_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_26 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_26 +#define GOBJECT_DEPRECATED_TYPE_IN_2_26_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26 +#define GOBJECT_AVAILABLE_IN_2_26 GOBJECT_UNAVAILABLE (2, 26) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_26 GLIB_UNAVAILABLE_STATIC_INLINE (2, 26) +#define GOBJECT_AVAILABLE_MACRO_IN_2_26 GLIB_UNAVAILABLE_MACRO (2, 26) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_26 GLIB_UNAVAILABLE_ENUMERATOR (2, 26) +#define GOBJECT_AVAILABLE_TYPE_IN_2_26 GLIB_UNAVAILABLE_TYPE (2, 26) +#else +#define GOBJECT_AVAILABLE_IN_2_26 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_26 +#define GOBJECT_AVAILABLE_MACRO_IN_2_26 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_26 +#define GOBJECT_AVAILABLE_TYPE_IN_2_26 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28 +#define GOBJECT_DEPRECATED_IN_2_28 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_28_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_28 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_28_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_28 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_28 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_28_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_28 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_28_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_28 +#define GOBJECT_DEPRECATED_MACRO_IN_2_28_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_28 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_28 +#define GOBJECT_DEPRECATED_TYPE_IN_2_28_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28 +#define GOBJECT_AVAILABLE_IN_2_28 GOBJECT_UNAVAILABLE (2, 28) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_28 GLIB_UNAVAILABLE_STATIC_INLINE (2, 28) +#define GOBJECT_AVAILABLE_MACRO_IN_2_28 GLIB_UNAVAILABLE_MACRO (2, 28) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_28 GLIB_UNAVAILABLE_ENUMERATOR (2, 28) +#define GOBJECT_AVAILABLE_TYPE_IN_2_28 GLIB_UNAVAILABLE_TYPE (2, 28) +#else +#define GOBJECT_AVAILABLE_IN_2_28 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_28 +#define GOBJECT_AVAILABLE_MACRO_IN_2_28 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_28 +#define GOBJECT_AVAILABLE_TYPE_IN_2_28 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30 +#define GOBJECT_DEPRECATED_IN_2_30 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_30_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_30 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_30_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_30 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_30 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_30_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_30 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_30_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_30 +#define GOBJECT_DEPRECATED_MACRO_IN_2_30_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_30 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_30 +#define GOBJECT_DEPRECATED_TYPE_IN_2_30_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30 +#define GOBJECT_AVAILABLE_IN_2_30 GOBJECT_UNAVAILABLE (2, 30) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_30 GLIB_UNAVAILABLE_STATIC_INLINE (2, 30) +#define GOBJECT_AVAILABLE_MACRO_IN_2_30 GLIB_UNAVAILABLE_MACRO (2, 30) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_30 GLIB_UNAVAILABLE_ENUMERATOR (2, 30) +#define GOBJECT_AVAILABLE_TYPE_IN_2_30 GLIB_UNAVAILABLE_TYPE (2, 30) +#else +#define GOBJECT_AVAILABLE_IN_2_30 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_30 +#define GOBJECT_AVAILABLE_MACRO_IN_2_30 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_30 +#define GOBJECT_AVAILABLE_TYPE_IN_2_30 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32 +#define GOBJECT_DEPRECATED_IN_2_32 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_32_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_32 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_32_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_32 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_32 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_32_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_32 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_32_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_32 +#define GOBJECT_DEPRECATED_MACRO_IN_2_32_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_32 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_32 +#define GOBJECT_DEPRECATED_TYPE_IN_2_32_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32 +#define GOBJECT_AVAILABLE_IN_2_32 GOBJECT_UNAVAILABLE (2, 32) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_32 GLIB_UNAVAILABLE_STATIC_INLINE (2, 32) +#define GOBJECT_AVAILABLE_MACRO_IN_2_32 GLIB_UNAVAILABLE_MACRO (2, 32) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_32 GLIB_UNAVAILABLE_ENUMERATOR (2, 32) +#define GOBJECT_AVAILABLE_TYPE_IN_2_32 GLIB_UNAVAILABLE_TYPE (2, 32) +#else +#define GOBJECT_AVAILABLE_IN_2_32 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_32 +#define GOBJECT_AVAILABLE_MACRO_IN_2_32 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_32 +#define GOBJECT_AVAILABLE_TYPE_IN_2_32 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34 +#define GOBJECT_DEPRECATED_IN_2_34 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_34_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_34 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_34_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_34 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_34 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_34_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_34 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_34_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_34 +#define GOBJECT_DEPRECATED_MACRO_IN_2_34_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_34 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_34 +#define GOBJECT_DEPRECATED_TYPE_IN_2_34_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34 +#define GOBJECT_AVAILABLE_IN_2_34 GOBJECT_UNAVAILABLE (2, 34) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_34 GLIB_UNAVAILABLE_STATIC_INLINE (2, 34) +#define GOBJECT_AVAILABLE_MACRO_IN_2_34 GLIB_UNAVAILABLE_MACRO (2, 34) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_34 GLIB_UNAVAILABLE_ENUMERATOR (2, 34) +#define GOBJECT_AVAILABLE_TYPE_IN_2_34 GLIB_UNAVAILABLE_TYPE (2, 34) +#else +#define GOBJECT_AVAILABLE_IN_2_34 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_34 +#define GOBJECT_AVAILABLE_MACRO_IN_2_34 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_34 +#define GOBJECT_AVAILABLE_TYPE_IN_2_34 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36 +#define GOBJECT_DEPRECATED_IN_2_36 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_36_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_36 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_36_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_36 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_36 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_36_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_36 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_36_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_36 +#define GOBJECT_DEPRECATED_MACRO_IN_2_36_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_36 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_36 +#define GOBJECT_DEPRECATED_TYPE_IN_2_36_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36 +#define GOBJECT_AVAILABLE_IN_2_36 GOBJECT_UNAVAILABLE (2, 36) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_36 GLIB_UNAVAILABLE_STATIC_INLINE (2, 36) +#define GOBJECT_AVAILABLE_MACRO_IN_2_36 GLIB_UNAVAILABLE_MACRO (2, 36) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_36 GLIB_UNAVAILABLE_ENUMERATOR (2, 36) +#define GOBJECT_AVAILABLE_TYPE_IN_2_36 GLIB_UNAVAILABLE_TYPE (2, 36) +#else +#define GOBJECT_AVAILABLE_IN_2_36 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_36 +#define GOBJECT_AVAILABLE_MACRO_IN_2_36 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_36 +#define GOBJECT_AVAILABLE_TYPE_IN_2_36 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_38 +#define GOBJECT_DEPRECATED_IN_2_38 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_38_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_38 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_38_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_38 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_38 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_38_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_38 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_38_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_38 +#define GOBJECT_DEPRECATED_MACRO_IN_2_38_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_38 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_38 +#define GOBJECT_DEPRECATED_TYPE_IN_2_38_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 +#define GOBJECT_AVAILABLE_IN_2_38 GOBJECT_UNAVAILABLE (2, 38) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_38 GLIB_UNAVAILABLE_STATIC_INLINE (2, 38) +#define GOBJECT_AVAILABLE_MACRO_IN_2_38 GLIB_UNAVAILABLE_MACRO (2, 38) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_38 GLIB_UNAVAILABLE_ENUMERATOR (2, 38) +#define GOBJECT_AVAILABLE_TYPE_IN_2_38 GLIB_UNAVAILABLE_TYPE (2, 38) +#else +#define GOBJECT_AVAILABLE_IN_2_38 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_38 +#define GOBJECT_AVAILABLE_MACRO_IN_2_38 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_38 +#define GOBJECT_AVAILABLE_TYPE_IN_2_38 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_40 +#define GOBJECT_DEPRECATED_IN_2_40 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_40_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_40 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_40_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_40 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_40 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_40_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_40 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_40_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_40 +#define GOBJECT_DEPRECATED_MACRO_IN_2_40_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_40 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_40 +#define GOBJECT_DEPRECATED_TYPE_IN_2_40_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_40 +#define GOBJECT_AVAILABLE_IN_2_40 GOBJECT_UNAVAILABLE (2, 40) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_40 GLIB_UNAVAILABLE_STATIC_INLINE (2, 40) +#define GOBJECT_AVAILABLE_MACRO_IN_2_40 GLIB_UNAVAILABLE_MACRO (2, 40) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_40 GLIB_UNAVAILABLE_ENUMERATOR (2, 40) +#define GOBJECT_AVAILABLE_TYPE_IN_2_40 GLIB_UNAVAILABLE_TYPE (2, 40) +#else +#define GOBJECT_AVAILABLE_IN_2_40 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_40 +#define GOBJECT_AVAILABLE_MACRO_IN_2_40 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_40 +#define GOBJECT_AVAILABLE_TYPE_IN_2_40 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_42 +#define GOBJECT_DEPRECATED_IN_2_42 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_42_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_42 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_42_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_42 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_42 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_42_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_42 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_42_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_42 +#define GOBJECT_DEPRECATED_MACRO_IN_2_42_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_42 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_42 +#define GOBJECT_DEPRECATED_TYPE_IN_2_42_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_42 +#define GOBJECT_AVAILABLE_IN_2_42 GOBJECT_UNAVAILABLE (2, 42) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_42 GLIB_UNAVAILABLE_STATIC_INLINE (2, 42) +#define GOBJECT_AVAILABLE_MACRO_IN_2_42 GLIB_UNAVAILABLE_MACRO (2, 42) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_42 GLIB_UNAVAILABLE_ENUMERATOR (2, 42) +#define GOBJECT_AVAILABLE_TYPE_IN_2_42 GLIB_UNAVAILABLE_TYPE (2, 42) +#else +#define GOBJECT_AVAILABLE_IN_2_42 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_42 +#define GOBJECT_AVAILABLE_MACRO_IN_2_42 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_42 +#define GOBJECT_AVAILABLE_TYPE_IN_2_42 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_44 +#define GOBJECT_DEPRECATED_IN_2_44 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_44_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_44 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_44_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_44 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_44 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_44_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_44 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_44_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_44 +#define GOBJECT_DEPRECATED_MACRO_IN_2_44_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_44 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_44 +#define GOBJECT_DEPRECATED_TYPE_IN_2_44_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_44 +#define GOBJECT_AVAILABLE_IN_2_44 GOBJECT_UNAVAILABLE (2, 44) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_44 GLIB_UNAVAILABLE_STATIC_INLINE (2, 44) +#define GOBJECT_AVAILABLE_MACRO_IN_2_44 GLIB_UNAVAILABLE_MACRO (2, 44) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_44 GLIB_UNAVAILABLE_ENUMERATOR (2, 44) +#define GOBJECT_AVAILABLE_TYPE_IN_2_44 GLIB_UNAVAILABLE_TYPE (2, 44) +#else +#define GOBJECT_AVAILABLE_IN_2_44 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_44 +#define GOBJECT_AVAILABLE_MACRO_IN_2_44 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_44 +#define GOBJECT_AVAILABLE_TYPE_IN_2_44 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_46 +#define GOBJECT_DEPRECATED_IN_2_46 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_46_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_46 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_46_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_46 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_46 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_46_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_46 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_46_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_46 +#define GOBJECT_DEPRECATED_MACRO_IN_2_46_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_46 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_46 +#define GOBJECT_DEPRECATED_TYPE_IN_2_46_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_46 +#define GOBJECT_AVAILABLE_IN_2_46 GOBJECT_UNAVAILABLE (2, 46) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_46 GLIB_UNAVAILABLE_STATIC_INLINE (2, 46) +#define GOBJECT_AVAILABLE_MACRO_IN_2_46 GLIB_UNAVAILABLE_MACRO (2, 46) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_46 GLIB_UNAVAILABLE_ENUMERATOR (2, 46) +#define GOBJECT_AVAILABLE_TYPE_IN_2_46 GLIB_UNAVAILABLE_TYPE (2, 46) +#else +#define GOBJECT_AVAILABLE_IN_2_46 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_46 +#define GOBJECT_AVAILABLE_MACRO_IN_2_46 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_46 +#define GOBJECT_AVAILABLE_TYPE_IN_2_46 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_48 +#define GOBJECT_DEPRECATED_IN_2_48 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_48_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_48 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_48_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_48 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_48 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_48_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_48 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_48_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_48 +#define GOBJECT_DEPRECATED_MACRO_IN_2_48_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_48 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_48 +#define GOBJECT_DEPRECATED_TYPE_IN_2_48_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_48 +#define GOBJECT_AVAILABLE_IN_2_48 GOBJECT_UNAVAILABLE (2, 48) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_48 GLIB_UNAVAILABLE_STATIC_INLINE (2, 48) +#define GOBJECT_AVAILABLE_MACRO_IN_2_48 GLIB_UNAVAILABLE_MACRO (2, 48) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_48 GLIB_UNAVAILABLE_ENUMERATOR (2, 48) +#define GOBJECT_AVAILABLE_TYPE_IN_2_48 GLIB_UNAVAILABLE_TYPE (2, 48) +#else +#define GOBJECT_AVAILABLE_IN_2_48 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_48 +#define GOBJECT_AVAILABLE_MACRO_IN_2_48 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_48 +#define GOBJECT_AVAILABLE_TYPE_IN_2_48 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_50 +#define GOBJECT_DEPRECATED_IN_2_50 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_50_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_50 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_50_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_50 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_50 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_50_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_50 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_50_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_50 +#define GOBJECT_DEPRECATED_MACRO_IN_2_50_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_50 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_50 +#define GOBJECT_DEPRECATED_TYPE_IN_2_50_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_50 +#define GOBJECT_AVAILABLE_IN_2_50 GOBJECT_UNAVAILABLE (2, 50) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_50 GLIB_UNAVAILABLE_STATIC_INLINE (2, 50) +#define GOBJECT_AVAILABLE_MACRO_IN_2_50 GLIB_UNAVAILABLE_MACRO (2, 50) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_50 GLIB_UNAVAILABLE_ENUMERATOR (2, 50) +#define GOBJECT_AVAILABLE_TYPE_IN_2_50 GLIB_UNAVAILABLE_TYPE (2, 50) +#else +#define GOBJECT_AVAILABLE_IN_2_50 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_50 +#define GOBJECT_AVAILABLE_MACRO_IN_2_50 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_50 +#define GOBJECT_AVAILABLE_TYPE_IN_2_50 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_52 +#define GOBJECT_DEPRECATED_IN_2_52 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_52_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_52 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_52_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_52 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_52 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_52_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_52 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_52_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_52 +#define GOBJECT_DEPRECATED_MACRO_IN_2_52_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_52 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_52 +#define GOBJECT_DEPRECATED_TYPE_IN_2_52_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_52 +#define GOBJECT_AVAILABLE_IN_2_52 GOBJECT_UNAVAILABLE (2, 52) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_52 GLIB_UNAVAILABLE_STATIC_INLINE (2, 52) +#define GOBJECT_AVAILABLE_MACRO_IN_2_52 GLIB_UNAVAILABLE_MACRO (2, 52) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_52 GLIB_UNAVAILABLE_ENUMERATOR (2, 52) +#define GOBJECT_AVAILABLE_TYPE_IN_2_52 GLIB_UNAVAILABLE_TYPE (2, 52) +#else +#define GOBJECT_AVAILABLE_IN_2_52 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_52 +#define GOBJECT_AVAILABLE_MACRO_IN_2_52 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_52 +#define GOBJECT_AVAILABLE_TYPE_IN_2_52 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_54 +#define GOBJECT_DEPRECATED_IN_2_54 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_54_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_54 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_54_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_54 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_54 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_54_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_54 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_54_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_54 +#define GOBJECT_DEPRECATED_MACRO_IN_2_54_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_54 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_54 +#define GOBJECT_DEPRECATED_TYPE_IN_2_54_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_54 +#define GOBJECT_AVAILABLE_IN_2_54 GOBJECT_UNAVAILABLE (2, 54) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_54 GLIB_UNAVAILABLE_STATIC_INLINE (2, 54) +#define GOBJECT_AVAILABLE_MACRO_IN_2_54 GLIB_UNAVAILABLE_MACRO (2, 54) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_54 GLIB_UNAVAILABLE_ENUMERATOR (2, 54) +#define GOBJECT_AVAILABLE_TYPE_IN_2_54 GLIB_UNAVAILABLE_TYPE (2, 54) +#else +#define GOBJECT_AVAILABLE_IN_2_54 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_54 +#define GOBJECT_AVAILABLE_MACRO_IN_2_54 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_54 +#define GOBJECT_AVAILABLE_TYPE_IN_2_54 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_56 +#define GOBJECT_DEPRECATED_IN_2_56 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_56_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_56 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_56_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_56 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_56 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_56_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_56 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_56_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_56 +#define GOBJECT_DEPRECATED_MACRO_IN_2_56_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_56 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_56 +#define GOBJECT_DEPRECATED_TYPE_IN_2_56_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_56 +#define GOBJECT_AVAILABLE_IN_2_56 GOBJECT_UNAVAILABLE (2, 56) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_56 GLIB_UNAVAILABLE_STATIC_INLINE (2, 56) +#define GOBJECT_AVAILABLE_MACRO_IN_2_56 GLIB_UNAVAILABLE_MACRO (2, 56) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_56 GLIB_UNAVAILABLE_ENUMERATOR (2, 56) +#define GOBJECT_AVAILABLE_TYPE_IN_2_56 GLIB_UNAVAILABLE_TYPE (2, 56) +#else +#define GOBJECT_AVAILABLE_IN_2_56 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_56 +#define GOBJECT_AVAILABLE_MACRO_IN_2_56 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_56 +#define GOBJECT_AVAILABLE_TYPE_IN_2_56 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_58 +#define GOBJECT_DEPRECATED_IN_2_58 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_58_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_58 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_58_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_58 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_58 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_58_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_58 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_58_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_58 +#define GOBJECT_DEPRECATED_MACRO_IN_2_58_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_58 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_58 +#define GOBJECT_DEPRECATED_TYPE_IN_2_58_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_58 +#define GOBJECT_AVAILABLE_IN_2_58 GOBJECT_UNAVAILABLE (2, 58) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_58 GLIB_UNAVAILABLE_STATIC_INLINE (2, 58) +#define GOBJECT_AVAILABLE_MACRO_IN_2_58 GLIB_UNAVAILABLE_MACRO (2, 58) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_58 GLIB_UNAVAILABLE_ENUMERATOR (2, 58) +#define GOBJECT_AVAILABLE_TYPE_IN_2_58 GLIB_UNAVAILABLE_TYPE (2, 58) +#else +#define GOBJECT_AVAILABLE_IN_2_58 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_58 +#define GOBJECT_AVAILABLE_MACRO_IN_2_58 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_58 +#define GOBJECT_AVAILABLE_TYPE_IN_2_58 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_60 +#define GOBJECT_DEPRECATED_IN_2_60 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_60_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_60 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_60_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_60 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_60 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_60_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_60 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_60_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_60 +#define GOBJECT_DEPRECATED_MACRO_IN_2_60_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_60 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_60 +#define GOBJECT_DEPRECATED_TYPE_IN_2_60_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_60 +#define GOBJECT_AVAILABLE_IN_2_60 GOBJECT_UNAVAILABLE (2, 60) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_60 GLIB_UNAVAILABLE_STATIC_INLINE (2, 60) +#define GOBJECT_AVAILABLE_MACRO_IN_2_60 GLIB_UNAVAILABLE_MACRO (2, 60) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_60 GLIB_UNAVAILABLE_ENUMERATOR (2, 60) +#define GOBJECT_AVAILABLE_TYPE_IN_2_60 GLIB_UNAVAILABLE_TYPE (2, 60) +#else +#define GOBJECT_AVAILABLE_IN_2_60 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_60 +#define GOBJECT_AVAILABLE_MACRO_IN_2_60 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_60 +#define GOBJECT_AVAILABLE_TYPE_IN_2_60 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_62 +#define GOBJECT_DEPRECATED_IN_2_62 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_62_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_62 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_62_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_62 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_62 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_62_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_62 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_62_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_62 +#define GOBJECT_DEPRECATED_MACRO_IN_2_62_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_62 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_62 +#define GOBJECT_DEPRECATED_TYPE_IN_2_62_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_62 +#define GOBJECT_AVAILABLE_IN_2_62 GOBJECT_UNAVAILABLE (2, 62) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_62 GLIB_UNAVAILABLE_STATIC_INLINE (2, 62) +#define GOBJECT_AVAILABLE_MACRO_IN_2_62 GLIB_UNAVAILABLE_MACRO (2, 62) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_62 GLIB_UNAVAILABLE_ENUMERATOR (2, 62) +#define GOBJECT_AVAILABLE_TYPE_IN_2_62 GLIB_UNAVAILABLE_TYPE (2, 62) +#else +#define GOBJECT_AVAILABLE_IN_2_62 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_62 +#define GOBJECT_AVAILABLE_MACRO_IN_2_62 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_62 +#define GOBJECT_AVAILABLE_TYPE_IN_2_62 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 +#define GOBJECT_DEPRECATED_IN_2_64 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_64_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_64 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_64_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_64 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_64 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_64_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_64 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_64_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_64 +#define GOBJECT_DEPRECATED_MACRO_IN_2_64_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_64 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_64 +#define GOBJECT_DEPRECATED_TYPE_IN_2_64_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64 +#define GOBJECT_AVAILABLE_IN_2_64 GOBJECT_UNAVAILABLE (2, 64) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_64 GLIB_UNAVAILABLE_STATIC_INLINE (2, 64) +#define GOBJECT_AVAILABLE_MACRO_IN_2_64 GLIB_UNAVAILABLE_MACRO (2, 64) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_64 GLIB_UNAVAILABLE_ENUMERATOR (2, 64) +#define GOBJECT_AVAILABLE_TYPE_IN_2_64 GLIB_UNAVAILABLE_TYPE (2, 64) +#else +#define GOBJECT_AVAILABLE_IN_2_64 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_64 +#define GOBJECT_AVAILABLE_MACRO_IN_2_64 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_64 +#define GOBJECT_AVAILABLE_TYPE_IN_2_64 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_66 +#define GOBJECT_DEPRECATED_IN_2_66 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_66_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_66 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_66_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_66 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_66 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_66_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_66 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_66_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_66 +#define GOBJECT_DEPRECATED_MACRO_IN_2_66_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_66 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_66 +#define GOBJECT_DEPRECATED_TYPE_IN_2_66_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_66 +#define GOBJECT_AVAILABLE_IN_2_66 GOBJECT_UNAVAILABLE (2, 66) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_66 GLIB_UNAVAILABLE_STATIC_INLINE (2, 66) +#define GOBJECT_AVAILABLE_MACRO_IN_2_66 GLIB_UNAVAILABLE_MACRO (2, 66) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_66 GLIB_UNAVAILABLE_ENUMERATOR (2, 66) +#define GOBJECT_AVAILABLE_TYPE_IN_2_66 GLIB_UNAVAILABLE_TYPE (2, 66) +#else +#define GOBJECT_AVAILABLE_IN_2_66 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_66 +#define GOBJECT_AVAILABLE_MACRO_IN_2_66 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_66 +#define GOBJECT_AVAILABLE_TYPE_IN_2_66 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68 +#define GOBJECT_DEPRECATED_IN_2_68 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_68_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_68 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_68_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_68 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_68 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_68_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_68 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_68_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_68 +#define GOBJECT_DEPRECATED_MACRO_IN_2_68_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_68 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_68 +#define GOBJECT_DEPRECATED_TYPE_IN_2_68_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_68 +#define GOBJECT_AVAILABLE_IN_2_68 GOBJECT_UNAVAILABLE (2, 68) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_68 GLIB_UNAVAILABLE_STATIC_INLINE (2, 68) +#define GOBJECT_AVAILABLE_MACRO_IN_2_68 GLIB_UNAVAILABLE_MACRO (2, 68) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_68 GLIB_UNAVAILABLE_ENUMERATOR (2, 68) +#define GOBJECT_AVAILABLE_TYPE_IN_2_68 GLIB_UNAVAILABLE_TYPE (2, 68) +#else +#define GOBJECT_AVAILABLE_IN_2_68 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_68 +#define GOBJECT_AVAILABLE_MACRO_IN_2_68 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_68 +#define GOBJECT_AVAILABLE_TYPE_IN_2_68 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_70 +#define GOBJECT_DEPRECATED_IN_2_70 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_70_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_70 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_70_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_70 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_70 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_70_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_70 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_70_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_70 +#define GOBJECT_DEPRECATED_MACRO_IN_2_70_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_70 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_70_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_70 +#define GOBJECT_DEPRECATED_TYPE_IN_2_70_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_70 +#define GOBJECT_AVAILABLE_IN_2_70 GOBJECT_UNAVAILABLE (2, 70) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_70 GLIB_UNAVAILABLE_STATIC_INLINE (2, 70) +#define GOBJECT_AVAILABLE_MACRO_IN_2_70 GLIB_UNAVAILABLE_MACRO (2, 70) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_70 GLIB_UNAVAILABLE_ENUMERATOR (2, 70) +#define GOBJECT_AVAILABLE_TYPE_IN_2_70 GLIB_UNAVAILABLE_TYPE (2, 70) +#else +#define GOBJECT_AVAILABLE_IN_2_70 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_70 +#define GOBJECT_AVAILABLE_MACRO_IN_2_70 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_70 +#define GOBJECT_AVAILABLE_TYPE_IN_2_70 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_72 +#define GOBJECT_DEPRECATED_IN_2_72 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_72_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_72 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_72_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_72 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_72 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_72_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_72 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_72_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_72 +#define GOBJECT_DEPRECATED_MACRO_IN_2_72_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_72 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_72_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_72 +#define GOBJECT_DEPRECATED_TYPE_IN_2_72_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_72 +#define GOBJECT_AVAILABLE_IN_2_72 GOBJECT_UNAVAILABLE (2, 72) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_72 GLIB_UNAVAILABLE_STATIC_INLINE (2, 72) +#define GOBJECT_AVAILABLE_MACRO_IN_2_72 GLIB_UNAVAILABLE_MACRO (2, 72) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_72 GLIB_UNAVAILABLE_ENUMERATOR (2, 72) +#define GOBJECT_AVAILABLE_TYPE_IN_2_72 GLIB_UNAVAILABLE_TYPE (2, 72) +#else +#define GOBJECT_AVAILABLE_IN_2_72 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_72 +#define GOBJECT_AVAILABLE_MACRO_IN_2_72 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_72 +#define GOBJECT_AVAILABLE_TYPE_IN_2_72 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_74 +#define GOBJECT_DEPRECATED_IN_2_74 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_74_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_74 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_74_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_74 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_74 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_74_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_74 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_74_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_74 +#define GOBJECT_DEPRECATED_MACRO_IN_2_74_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_74 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_74_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_74 +#define GOBJECT_DEPRECATED_TYPE_IN_2_74_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_74 +#define GOBJECT_AVAILABLE_IN_2_74 GOBJECT_UNAVAILABLE (2, 74) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_74 GLIB_UNAVAILABLE_STATIC_INLINE (2, 74) +#define GOBJECT_AVAILABLE_MACRO_IN_2_74 GLIB_UNAVAILABLE_MACRO (2, 74) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_74 GLIB_UNAVAILABLE_ENUMERATOR (2, 74) +#define GOBJECT_AVAILABLE_TYPE_IN_2_74 GLIB_UNAVAILABLE_TYPE (2, 74) +#else +#define GOBJECT_AVAILABLE_IN_2_74 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_74 +#define GOBJECT_AVAILABLE_MACRO_IN_2_74 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_74 +#define GOBJECT_AVAILABLE_TYPE_IN_2_74 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_76 +#define GOBJECT_DEPRECATED_IN_2_76 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_76_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_76 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_76_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_76 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_76 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_76_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_76 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_76_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_76 +#define GOBJECT_DEPRECATED_MACRO_IN_2_76_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_76 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_76_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_76 +#define GOBJECT_DEPRECATED_TYPE_IN_2_76_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_76 +#define GOBJECT_AVAILABLE_IN_2_76 GOBJECT_UNAVAILABLE (2, 76) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_76 GLIB_UNAVAILABLE_STATIC_INLINE (2, 76) +#define GOBJECT_AVAILABLE_MACRO_IN_2_76 GLIB_UNAVAILABLE_MACRO (2, 76) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_76 GLIB_UNAVAILABLE_ENUMERATOR (2, 76) +#define GOBJECT_AVAILABLE_TYPE_IN_2_76 GLIB_UNAVAILABLE_TYPE (2, 76) +#else +#define GOBJECT_AVAILABLE_IN_2_76 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_76 +#define GOBJECT_AVAILABLE_MACRO_IN_2_76 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_76 +#define GOBJECT_AVAILABLE_TYPE_IN_2_76 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_78 +#define GOBJECT_DEPRECATED_IN_2_78 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_78_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_78 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_78_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_78 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_78 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_78_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_78 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_78_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_78 +#define GOBJECT_DEPRECATED_MACRO_IN_2_78_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_78 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_78_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_78 +#define GOBJECT_DEPRECATED_TYPE_IN_2_78_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_78 +#define GOBJECT_AVAILABLE_IN_2_78 GOBJECT_UNAVAILABLE (2, 78) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_78 GLIB_UNAVAILABLE_STATIC_INLINE (2, 78) +#define GOBJECT_AVAILABLE_MACRO_IN_2_78 GLIB_UNAVAILABLE_MACRO (2, 78) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_78 GLIB_UNAVAILABLE_ENUMERATOR (2, 78) +#define GOBJECT_AVAILABLE_TYPE_IN_2_78 GLIB_UNAVAILABLE_TYPE (2, 78) +#else +#define GOBJECT_AVAILABLE_IN_2_78 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_78 +#define GOBJECT_AVAILABLE_MACRO_IN_2_78 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_78 +#define GOBJECT_AVAILABLE_TYPE_IN_2_78 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_80 +#define GOBJECT_DEPRECATED_IN_2_80 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_80_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_80 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_80_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_80 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_80 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_80_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_80 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_80_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_80 +#define GOBJECT_DEPRECATED_MACRO_IN_2_80_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_80 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_80_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_80 +#define GOBJECT_DEPRECATED_TYPE_IN_2_80_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_80 +#define GOBJECT_AVAILABLE_IN_2_80 GOBJECT_UNAVAILABLE (2, 80) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_80 GLIB_UNAVAILABLE_STATIC_INLINE (2, 80) +#define GOBJECT_AVAILABLE_MACRO_IN_2_80 GLIB_UNAVAILABLE_MACRO (2, 80) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_80 GLIB_UNAVAILABLE_ENUMERATOR (2, 80) +#define GOBJECT_AVAILABLE_TYPE_IN_2_80 GLIB_UNAVAILABLE_TYPE (2, 80) +#else +#define GOBJECT_AVAILABLE_IN_2_80 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_80 +#define GOBJECT_AVAILABLE_MACRO_IN_2_80 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_80 +#define GOBJECT_AVAILABLE_TYPE_IN_2_80 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_82 +#define GOBJECT_DEPRECATED_IN_2_82 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_82_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_82 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_82_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_82 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_82 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_82_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_82 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_82_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_82 +#define GOBJECT_DEPRECATED_MACRO_IN_2_82_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_82 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_82_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_82 +#define GOBJECT_DEPRECATED_TYPE_IN_2_82_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_82 +#define GOBJECT_AVAILABLE_IN_2_82 GOBJECT_UNAVAILABLE (2, 82) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_82 GLIB_UNAVAILABLE_STATIC_INLINE (2, 82) +#define GOBJECT_AVAILABLE_MACRO_IN_2_82 GLIB_UNAVAILABLE_MACRO (2, 82) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_82 GLIB_UNAVAILABLE_ENUMERATOR (2, 82) +#define GOBJECT_AVAILABLE_TYPE_IN_2_82 GLIB_UNAVAILABLE_TYPE (2, 82) +#else +#define GOBJECT_AVAILABLE_IN_2_82 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_82 +#define GOBJECT_AVAILABLE_MACRO_IN_2_82 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_82 +#define GOBJECT_AVAILABLE_TYPE_IN_2_82 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_84 +#define GOBJECT_DEPRECATED_IN_2_84 GOBJECT_DEPRECATED +#define GOBJECT_DEPRECATED_IN_2_84_FOR(f) GOBJECT_DEPRECATED_FOR (f) +#define GOBJECT_DEPRECATED_MACRO_IN_2_84 GLIB_DEPRECATED_MACRO +#define GOBJECT_DEPRECATED_MACRO_IN_2_84_FOR(f) GLIB_DEPRECATED_MACRO_FOR (f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_84 GLIB_DEPRECATED_ENUMERATOR +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR (f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_84 GLIB_DEPRECATED_TYPE +#define GOBJECT_DEPRECATED_TYPE_IN_2_84_FOR(f) GLIB_DEPRECATED_TYPE_FOR (f) +#else +#define GOBJECT_DEPRECATED_IN_2_84 _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_IN_2_84_FOR(f) _GOBJECT_EXTERN +#define GOBJECT_DEPRECATED_MACRO_IN_2_84 +#define GOBJECT_DEPRECATED_MACRO_IN_2_84_FOR(f) +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_84 +#define GOBJECT_DEPRECATED_ENUMERATOR_IN_2_84_FOR(f) +#define GOBJECT_DEPRECATED_TYPE_IN_2_84 +#define GOBJECT_DEPRECATED_TYPE_IN_2_84_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_84 +#define GOBJECT_AVAILABLE_IN_2_84 GOBJECT_UNAVAILABLE (2, 84) +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_84 GLIB_UNAVAILABLE_STATIC_INLINE (2, 84) +#define GOBJECT_AVAILABLE_MACRO_IN_2_84 GLIB_UNAVAILABLE_MACRO (2, 84) +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_84 GLIB_UNAVAILABLE_ENUMERATOR (2, 84) +#define GOBJECT_AVAILABLE_TYPE_IN_2_84 GLIB_UNAVAILABLE_TYPE (2, 84) +#else +#define GOBJECT_AVAILABLE_IN_2_84 _GOBJECT_EXTERN +#define GOBJECT_AVAILABLE_STATIC_INLINE_IN_2_84 +#define GOBJECT_AVAILABLE_MACRO_IN_2_84 +#define GOBJECT_AVAILABLE_ENUMERATOR_IN_2_84 +#define GOBJECT_AVAILABLE_TYPE_IN_2_84 +#endif diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gobject.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gobject.h new file mode 100644 index 00000000..cea4df92 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gobject.h @@ -0,0 +1,938 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_OBJECT_H__ +#define __G_OBJECT_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include +#include +#include +#include + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_TYPE_IS_OBJECT: + * @type: Type id to check + * + * Check if the passed in type id is a %G_TYPE_OBJECT or derived from it. + * + * Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT. + */ +#define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT) +/** + * G_OBJECT: + * @object: Object which is subject to casting. + * + * Casts a #GObject or derived pointer into a (GObject*) pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + */ +#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject)) +/** + * G_OBJECT_CLASS: + * @class: a valid #GObjectClass + * + * Casts a derived #GObjectClass structure into a #GObjectClass structure. + */ +#define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass)) +/** + * G_IS_OBJECT: + * @object: Instance to check for being a %G_TYPE_OBJECT. + * + * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT. + */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_42 +#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE ((object), G_TYPE_OBJECT)) +#else +#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT)) +#endif +/** + * G_IS_OBJECT_CLASS: + * @class: a #GObjectClass + * + * Checks whether @class "is a" valid #GObjectClass structure of type + * %G_TYPE_OBJECT or derived. + */ +#define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT)) +/** + * G_OBJECT_GET_CLASS: + * @object: a #GObject instance. + * + * Get the class structure associated to a #GObject instance. + * + * Returns: pointer to object class structure. + */ +#define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass)) +/** + * G_OBJECT_TYPE: + * @object: Object to return the type id for. + * + * Get the type id of an object. + * + * Returns: Type id of @object. + */ +#define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object)) +/** + * G_OBJECT_TYPE_NAME: + * @object: Object to return the type name for. + * + * Get the name of an object's type. + * + * Returns: Type name of @object. The string is owned by the type system and + * should not be freed. + */ +#define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object))) +/** + * G_OBJECT_CLASS_TYPE: + * @class: a valid #GObjectClass + * + * Get the type id of a class structure. + * + * Returns: Type id of @class. + */ +#define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) +/** + * G_OBJECT_CLASS_NAME: + * @class: a valid #GObjectClass + * + * Return the name of a class structure's type. + * + * Returns: Type name of @class. The string is owned by the type system and + * should not be freed. + */ +#define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class))) +/** + * G_VALUE_HOLDS_OBJECT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived from type %G_TYPE_OBJECT. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT)) + +/* --- type macros --- */ +/** + * G_TYPE_INITIALLY_UNOWNED: + * + * The type for #GInitiallyUnowned. + */ +#define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type()) +/** + * G_INITIALLY_UNOWNED: + * @object: Object which is subject to casting. + * + * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*) + * pointer. + * + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + */ +#define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned)) +/** + * G_INITIALLY_UNOWNED_CLASS: + * @class: a valid #GInitiallyUnownedClass + * + * Casts a derived #GInitiallyUnownedClass structure into a + * #GInitiallyUnownedClass structure. + */ +#define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass)) +/** + * G_IS_INITIALLY_UNOWNED: + * @object: Instance to check for being a %G_TYPE_INITIALLY_UNOWNED. + * + * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_INITIALLY_UNOWNED. + */ +#define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED)) +/** + * G_IS_INITIALLY_UNOWNED_CLASS: + * @class: a #GInitiallyUnownedClass + * + * Checks whether @class "is a" valid #GInitiallyUnownedClass structure of type + * %G_TYPE_INITIALLY_UNOWNED or derived. + */ +#define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED)) +/** + * G_INITIALLY_UNOWNED_GET_CLASS: + * @object: a #GInitiallyUnowned instance. + * + * Get the class structure associated to a #GInitiallyUnowned instance. + * + * Returns: pointer to object class structure. + */ +#define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass)) +/* GInitiallyUnowned ia a GObject with initially floating reference count */ + + +/* --- typedefs & structures --- */ +typedef struct _GObject GObject; +typedef struct _GObjectClass GObjectClass; +typedef struct _GObject GInitiallyUnowned; +typedef struct _GObjectClass GInitiallyUnownedClass; +typedef struct _GObjectConstructParam GObjectConstructParam; +/** + * GObjectGetPropertyFunc: + * @object: a #GObject + * @property_id: the numeric id under which the property was registered with + * g_object_class_install_property(). + * @value: a #GValue to return the property value in + * @pspec: the #GParamSpec describing the property + * + * The type of the @get_property function of #GObjectClass. + */ +typedef void (*GObjectGetPropertyFunc) (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); +/** + * GObjectSetPropertyFunc: + * @object: a #GObject + * @property_id: the numeric id under which the property was registered with + * g_object_class_install_property(). + * @value: the new value for the property + * @pspec: the #GParamSpec describing the property + * + * The type of the @set_property function of #GObjectClass. + */ +typedef void (*GObjectSetPropertyFunc) (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +/** + * GObjectFinalizeFunc: + * @object: the #GObject being finalized + * + * The type of the @finalize function of #GObjectClass. + */ +typedef void (*GObjectFinalizeFunc) (GObject *object); +/** + * GWeakNotify: + * @data: data that was provided when the weak reference was established + * @where_the_object_was: the object being disposed + * + * A #GWeakNotify function can be added to an object as a callback that gets + * triggered when the object is finalized. + * + * Since the object is already being disposed when the #GWeakNotify is called, + * there's not much you could do with the object, apart from e.g. using its + * address as hash-index or the like. + * + * In particular, this means it’s invalid to call g_object_ref(), + * g_weak_ref_init(), g_weak_ref_set(), g_object_add_toggle_ref(), + * g_object_weak_ref(), g_object_add_weak_pointer() or any function which calls + * them on the object from this callback. + */ +typedef void (*GWeakNotify) (gpointer data, + GObject *where_the_object_was); + +struct _GObject +{ + GTypeInstance g_type_instance; + + /*< private >*/ + guint ref_count; /* (atomic) */ + GData *qdata; +}; +/** + * GObjectClass: + * @g_type_class: the parent class + * @constructor: the @constructor function is called by g_object_new () to + * complete the object initialization after all the construction properties are + * set. The first thing a @constructor implementation must do is chain up to the + * @constructor of the parent class. Overriding @constructor should be rarely + * needed, e.g. to handle construct properties, or to implement singletons. + * @set_property: the generic setter for all properties of this type. Should be + * overridden for every type with properties. If implementations of + * @set_property don't emit property change notification explicitly, this will + * be done implicitly by the type system. However, if the notify signal is + * emitted explicitly, the type system will not emit it a second time. + * @get_property: the generic getter for all properties of this type. Should be + * overridden for every type with properties. + * @dispose: the @dispose function is supposed to drop all references to other + * objects, but keep the instance otherwise intact, so that client method + * invocations still work. It may be run multiple times (due to reference + * loops). Before returning, @dispose should chain up to the @dispose method + * of the parent class. + * @finalize: instance finalization function, should finish the finalization of + * the instance begun in @dispose and chain up to the @finalize method of the + * parent class. + * @dispatch_properties_changed: emits property change notification for a bunch + * of properties. Overriding @dispatch_properties_changed should be rarely + * needed. + * @notify: the class closure for the notify signal + * @constructed: the @constructed function is called by g_object_new() as the + * final step of the object creation process. At the point of the call, all + * construction properties have been set on the object. The purpose of this + * call is to allow for object initialisation steps that can only be performed + * after construction properties have been set. @constructed implementors + * should chain up to the @constructed call of their parent class to allow it + * to complete its initialisation. + * + * The class structure for the GObject type. + * + * |[ + * // Example of implementing a singleton using a constructor. + * static MySingleton *the_singleton = NULL; + * + * static GObject* + * my_singleton_constructor (GType type, + * guint n_construct_params, + * GObjectConstructParam *construct_params) + * { + * GObject *object; + * + * if (!the_singleton) + * { + * object = G_OBJECT_CLASS (parent_class)->constructor (type, + * n_construct_params, + * construct_params); + * the_singleton = MY_SINGLETON (object); + * } + * else + * object = g_object_ref (G_OBJECT (the_singleton)); + * + * return object; + * } + * ]| + */ +struct _GObjectClass +{ + GTypeClass g_type_class; + + /*< private >*/ + GSList *construct_properties; + + /*< public >*/ + /* seldom overridden */ + GObject* (*constructor) (GType type, + guint n_construct_properties, + GObjectConstructParam *construct_properties); + /* overridable methods */ + void (*set_property) (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); + void (*get_property) (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + void (*dispose) (GObject *object); + void (*finalize) (GObject *object); + /* seldom overridden */ + void (*dispatch_properties_changed) (GObject *object, + guint n_pspecs, + GParamSpec **pspecs); + /* signals */ + void (*notify) (GObject *object, + GParamSpec *pspec); + + /* called when done constructing */ + void (*constructed) (GObject *object); + + /*< private >*/ + gsize flags; + + gsize n_construct_properties; + + gpointer pspecs; + gsize n_pspecs; + + /* padding */ + gpointer pdummy[3]; +}; + +/** + * GObjectConstructParam: + * @pspec: the #GParamSpec of the construct parameter + * @value: the value to set the parameter to + * + * The GObjectConstructParam struct is an auxiliary structure used to hand + * #GParamSpec/#GValue pairs to the @constructor of a #GObjectClass. + */ +struct _GObjectConstructParam +{ + GParamSpec *pspec; + GValue *value; +}; + +/** + * GInitiallyUnowned: + * + * A type for objects that have an initially floating reference. + * + * All the fields in the `GInitiallyUnowned` structure are private to the + * implementation and should never be accessed directly. + */ +/** + * GInitiallyUnownedClass: + * + * The class structure for the GInitiallyUnowned type. + */ + + +/* --- prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +GType g_initially_unowned_get_type (void); +GOBJECT_AVAILABLE_IN_ALL +void g_object_class_install_property (GObjectClass *oclass, + guint property_id, + GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_object_class_find_property (GObjectClass *oclass, + const gchar *property_name); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec**g_object_class_list_properties (GObjectClass *oclass, + guint *n_properties); +GOBJECT_AVAILABLE_IN_ALL +void g_object_class_override_property (GObjectClass *oclass, + guint property_id, + const gchar *name); +GOBJECT_AVAILABLE_IN_ALL +void g_object_class_install_properties (GObjectClass *oclass, + guint n_pspecs, + GParamSpec **pspecs); + +GOBJECT_AVAILABLE_IN_ALL +void g_object_interface_install_property (gpointer g_iface, + GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_object_interface_find_property (gpointer g_iface, + const gchar *property_name); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec**g_object_interface_list_properties (gpointer g_iface, + guint *n_properties_p); + +GOBJECT_AVAILABLE_IN_ALL +GType g_object_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +gpointer g_object_new (GType object_type, + const gchar *first_property_name, + ...); +GOBJECT_AVAILABLE_IN_2_54 +GObject* g_object_new_with_properties (GType object_type, + guint n_properties, + const char *names[], + const GValue values[]); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +GOBJECT_DEPRECATED_IN_2_54_FOR(g_object_new_with_properties) +gpointer g_object_newv (GType object_type, + guint n_parameters, + GParameter *parameters); + +G_GNUC_END_IGNORE_DEPRECATIONS + +GOBJECT_AVAILABLE_IN_ALL +GObject* g_object_new_valist (GType object_type, + const gchar *first_property_name, + va_list var_args); +GOBJECT_AVAILABLE_IN_ALL +void g_object_set (gpointer object, + const gchar *first_property_name, + ...) G_GNUC_NULL_TERMINATED; +GOBJECT_AVAILABLE_IN_ALL +void g_object_get (gpointer object, + const gchar *first_property_name, + ...) G_GNUC_NULL_TERMINATED; +GOBJECT_AVAILABLE_IN_ALL +gpointer g_object_connect (gpointer object, + const gchar *signal_spec, + ...) G_GNUC_NULL_TERMINATED; +GOBJECT_AVAILABLE_IN_ALL +void g_object_disconnect (gpointer object, + const gchar *signal_spec, + ...) G_GNUC_NULL_TERMINATED; +GOBJECT_AVAILABLE_IN_2_54 +void g_object_setv (GObject *object, + guint n_properties, + const gchar *names[], + const GValue values[]); +GOBJECT_AVAILABLE_IN_ALL +void g_object_set_valist (GObject *object, + const gchar *first_property_name, + va_list var_args); +GOBJECT_AVAILABLE_IN_2_54 +void g_object_getv (GObject *object, + guint n_properties, + const gchar *names[], + GValue values[]); +GOBJECT_AVAILABLE_IN_ALL +void g_object_get_valist (GObject *object, + const gchar *first_property_name, + va_list var_args); +GOBJECT_AVAILABLE_IN_ALL +void g_object_set_property (GObject *object, + const gchar *property_name, + const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_object_get_property (GObject *object, + const gchar *property_name, + GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_object_freeze_notify (GObject *object); +GOBJECT_AVAILABLE_IN_ALL +void g_object_notify (GObject *object, + const gchar *property_name); +GOBJECT_AVAILABLE_IN_ALL +void g_object_notify_by_pspec (GObject *object, + GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +void g_object_thaw_notify (GObject *object); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_object_is_floating (gpointer object); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_object_ref_sink (gpointer object); +GOBJECT_AVAILABLE_IN_2_70 +gpointer g_object_take_ref (gpointer object); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_object_ref (gpointer object); +GOBJECT_AVAILABLE_IN_ALL +void g_object_unref (gpointer object); +GOBJECT_AVAILABLE_IN_ALL +void g_object_weak_ref (GObject *object, + GWeakNotify notify, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +void g_object_weak_unref (GObject *object, + GWeakNotify notify, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +void g_object_add_weak_pointer (GObject *object, + gpointer *weak_pointer_location); +GOBJECT_AVAILABLE_IN_ALL +void g_object_remove_weak_pointer (GObject *object, + gpointer *weak_pointer_location); + +#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 +/* Make reference APIs type safe with macros */ +#define g_object_ref(Obj) ((glib_typeof (Obj)) (g_object_ref) (Obj)) +#define g_object_ref_sink(Obj) ((glib_typeof (Obj)) (g_object_ref_sink) (Obj)) +#endif + +/** + * GToggleNotify: + * @data: Callback data passed to g_object_add_toggle_ref() + * @object: The object on which g_object_add_toggle_ref() was called. + * @is_last_ref: %TRUE if the toggle reference is now the + * last reference to the object. %FALSE if the toggle + * reference was the last reference and there are now other + * references. + * + * A callback function used for notification when the state + * of a toggle reference changes. + * + * See also: g_object_add_toggle_ref() + */ +typedef void (*GToggleNotify) (gpointer data, + GObject *object, + gboolean is_last_ref); + +GOBJECT_AVAILABLE_IN_ALL +void g_object_add_toggle_ref (GObject *object, + GToggleNotify notify, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +void g_object_remove_toggle_ref (GObject *object, + GToggleNotify notify, + gpointer data); + +GOBJECT_AVAILABLE_IN_ALL +gpointer g_object_get_qdata (GObject *object, + GQuark quark); +GOBJECT_AVAILABLE_IN_ALL +void g_object_set_qdata (GObject *object, + GQuark quark, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +void g_object_set_qdata_full (GObject *object, + GQuark quark, + gpointer data, + GDestroyNotify destroy); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_object_steal_qdata (GObject *object, + GQuark quark); + +GOBJECT_AVAILABLE_IN_2_34 +gpointer g_object_dup_qdata (GObject *object, + GQuark quark, + GDuplicateFunc dup_func, + gpointer user_data); +GOBJECT_AVAILABLE_IN_2_34 +gboolean g_object_replace_qdata (GObject *object, + GQuark quark, + gpointer oldval, + gpointer newval, + GDestroyNotify destroy, + GDestroyNotify *old_destroy); + +GOBJECT_AVAILABLE_IN_ALL +gpointer g_object_get_data (GObject *object, + const gchar *key); +GOBJECT_AVAILABLE_IN_ALL +void g_object_set_data (GObject *object, + const gchar *key, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +void g_object_set_data_full (GObject *object, + const gchar *key, + gpointer data, + GDestroyNotify destroy); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_object_steal_data (GObject *object, + const gchar *key); + +GOBJECT_AVAILABLE_IN_2_34 +gpointer g_object_dup_data (GObject *object, + const gchar *key, + GDuplicateFunc dup_func, + gpointer user_data); +GOBJECT_AVAILABLE_IN_2_34 +gboolean g_object_replace_data (GObject *object, + const gchar *key, + gpointer oldval, + gpointer newval, + GDestroyNotify destroy, + GDestroyNotify *old_destroy); + + +GOBJECT_AVAILABLE_IN_ALL +void g_object_watch_closure (GObject *object, + GClosure *closure); +GOBJECT_AVAILABLE_IN_ALL +GClosure* g_cclosure_new_object (GCallback callback_func, + GObject *object); +GOBJECT_AVAILABLE_IN_ALL +GClosure* g_cclosure_new_object_swap (GCallback callback_func, + GObject *object); +GOBJECT_AVAILABLE_IN_ALL +GClosure* g_closure_new_object (guint sizeof_closure, + GObject *object); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_object (GValue *value, + gpointer v_object); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_value_get_object (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_value_dup_object (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +gulong g_signal_connect_object (gpointer instance, + const gchar *detailed_signal, + GCallback c_handler, + gpointer gobject, + GConnectFlags connect_flags); + +/*< protected >*/ +GOBJECT_AVAILABLE_IN_ALL +void g_object_force_floating (GObject *object); +GOBJECT_AVAILABLE_IN_ALL +void g_object_run_dispose (GObject *object); + + +GOBJECT_AVAILABLE_IN_ALL +void g_value_take_object (GValue *value, + gpointer v_object); +GOBJECT_DEPRECATED_FOR(g_value_take_object) +void g_value_set_object_take_ownership (GValue *value, + gpointer v_object); + +GOBJECT_DEPRECATED +gsize g_object_compat_control (gsize what, + gpointer data); + +/* --- implementation macros --- */ +#define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \ +G_STMT_START { \ + GObject *_glib__object = (GObject*) (object); \ + GParamSpec *_glib__pspec = (GParamSpec*) (pspec); \ + guint _glib__property_id = (property_id); \ + g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'", \ + __FILE__, __LINE__, \ + (pname), \ + _glib__property_id, \ + _glib__pspec->name, \ + g_type_name (G_PARAM_SPEC_TYPE (_glib__pspec)), \ + G_OBJECT_TYPE_NAME (_glib__object)); \ +} G_STMT_END +/** + * G_OBJECT_WARN_INVALID_PROPERTY_ID: + * @object: the #GObject on which set_property() or get_property() was called + * @property_id: the numeric id of the property + * @pspec: the #GParamSpec of the property + * + * This macro should be used to emit a standard warning about unexpected + * properties in set_property() and get_property() implementations. + */ +#define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \ + G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec)) + +GOBJECT_AVAILABLE_IN_ALL +void g_clear_object (GObject **object_ptr); +#define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref) + +/** + * g_set_object: (skip) + * @object_ptr: (inout) (not optional) (nullable): a pointer to a #GObject reference + * @new_object: (nullable) (transfer none): a pointer to the new #GObject to + * assign to @object_ptr, or %NULL to clear the pointer + * + * Updates a #GObject pointer to refer to @new_object. + * + * It increments the reference count of @new_object (if non-%NULL), decrements + * the reference count of the current value of @object_ptr (if non-%NULL), and + * assigns @new_object to @object_ptr. The assignment is not atomic. + * + * @object_ptr must not be %NULL, but can point to a %NULL value. + * + * A macro is also included that allows this function to be used without + * pointer casts. The function itself is static inline, so its address may vary + * between compilation units. + * + * One convenient usage of this function is in implementing property setters: + * |[ + * void + * foo_set_bar (Foo *foo, + * Bar *new_bar) + * { + * g_return_if_fail (IS_FOO (foo)); + * g_return_if_fail (new_bar == NULL || IS_BAR (new_bar)); + * + * if (g_set_object (&foo->bar, new_bar)) + * g_object_notify (foo, "bar"); + * } + * ]| + * + * Returns: %TRUE if the value of @object_ptr changed, %FALSE otherwise + * + * Since: 2.44 + */ +static inline gboolean +(g_set_object) (GObject **object_ptr, + GObject *new_object) +{ + GObject *old_object = *object_ptr; + + /* rely on g_object_[un]ref() to check the pointers are actually GObjects; + * elide a (object_ptr != NULL) check because most of the time we will be + * operating on struct members with a constant offset, so a NULL check would + * not catch bugs + */ + + if (old_object == new_object) + return FALSE; + + if (new_object != NULL) + (void)g_object_ref (new_object); + + *object_ptr = new_object; + + if (old_object != NULL) + g_object_unref (old_object); + + return TRUE; +} + +/* We need GCC for __extension__, which we need to sort out strict aliasing of @object_ptr */ +#if defined(__GNUC__) + +#define g_set_object(object_ptr, new_object) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(object_ptr) == sizeof (new_object)); \ + /* Only one access, please; work around type aliasing */ \ + union { char *in; GObject **out; } _object_ptr; \ + _object_ptr.in = (char *) (object_ptr); \ + /* Check types match */ \ + (void) (0 ? *(object_ptr) = (new_object), FALSE : FALSE); \ + (g_set_object) (_object_ptr.out, (GObject *) new_object); \ + })) \ + GOBJECT_AVAILABLE_MACRO_IN_2_44 + +#else /* if !defined(__GNUC__) */ + +#define g_set_object(object_ptr, new_object) \ + (/* Check types match. */ \ + 0 ? *(object_ptr) = (new_object), FALSE : \ + (g_set_object) ((GObject **) (object_ptr), (GObject *) (new_object)) \ + ) + +#endif /* !defined(__GNUC__) */ + +/** + * g_assert_finalize_object: (skip) + * @object: (transfer full) (type GObject.Object): an object + * + * Assert that @object is non-%NULL, then release one reference to it with + * g_object_unref() and assert that it has been finalized (i.e. that there + * are no more references). + * + * If assertions are disabled via `G_DISABLE_ASSERT`, + * this macro just calls g_object_unref() without any further checks. + * + * This macro should only be used in regression tests. + * + * Since: 2.62 + */ +static inline void +(g_assert_finalize_object) (GObject *object) +{ + gpointer weak_pointer = object; + + g_assert_true (G_IS_OBJECT (weak_pointer)); + g_object_add_weak_pointer (object, &weak_pointer); + g_object_unref (weak_pointer); + g_assert_null (weak_pointer); +} + +#ifdef G_DISABLE_ASSERT +#define g_assert_finalize_object(object) g_object_unref (object) +#else +#define g_assert_finalize_object(object) (g_assert_finalize_object ((GObject *) object)) +#endif + +/** + * g_clear_weak_pointer: (skip) + * @weak_pointer_location: The memory address of a pointer + * + * Clears a weak reference to a #GObject. + * + * @weak_pointer_location must not be %NULL. + * + * If the weak reference is %NULL then this function does nothing. + * Otherwise, the weak reference to the object is removed for that location + * and the pointer is set to %NULL. + * + * A macro is also included that allows this function to be used without + * pointer casts. The function itself is static inline, so its address may vary + * between compilation units. + * + * Since: 2.56 + */ +static inline void +(g_clear_weak_pointer) (gpointer *weak_pointer_location) +{ + GObject *object = (GObject *) *weak_pointer_location; + + if (object != NULL) + { + g_object_remove_weak_pointer (object, weak_pointer_location); + *weak_pointer_location = NULL; + } +} + +#define g_clear_weak_pointer(weak_pointer_location) \ + (/* Check types match. */ \ + (g_clear_weak_pointer) ((gpointer *) (weak_pointer_location)) \ + ) + +/** + * g_set_weak_pointer: (skip) + * @weak_pointer_location: the memory address of a pointer + * @new_object: (nullable) (transfer none): a pointer to the new #GObject to + * assign to it, or %NULL to clear the pointer + * + * Updates a pointer to weakly refer to @new_object. + * + * It assigns @new_object to @weak_pointer_location and ensures + * that @weak_pointer_location will automatically be set to %NULL + * if @new_object gets destroyed. The assignment is not atomic. + * The weak reference is not thread-safe, see g_object_add_weak_pointer() + * for details. + * + * The @weak_pointer_location argument must not be %NULL. + * + * A macro is also included that allows this function to be used without + * pointer casts. The function itself is static inline, so its address may vary + * between compilation units. + * + * One convenient usage of this function is in implementing property setters: + * |[ + * void + * foo_set_bar (Foo *foo, + * Bar *new_bar) + * { + * g_return_if_fail (IS_FOO (foo)); + * g_return_if_fail (new_bar == NULL || IS_BAR (new_bar)); + * + * if (g_set_weak_pointer (&foo->bar, new_bar)) + * g_object_notify (foo, "bar"); + * } + * ]| + * + * Returns: %TRUE if the value of @weak_pointer_location changed, %FALSE otherwise + * + * Since: 2.56 + */ +static inline gboolean +(g_set_weak_pointer) (gpointer *weak_pointer_location, + GObject *new_object) +{ + GObject *old_object = (GObject *) *weak_pointer_location; + + /* elide a (weak_pointer_location != NULL) check because most of the time we + * will be operating on struct members with a constant offset, so a NULL + * check would not catch bugs + */ + + if (old_object == new_object) + return FALSE; + + if (old_object != NULL) + g_object_remove_weak_pointer (old_object, weak_pointer_location); + + *weak_pointer_location = new_object; + + if (new_object != NULL) + g_object_add_weak_pointer (new_object, weak_pointer_location); + + return TRUE; +} + +#define g_set_weak_pointer(weak_pointer_location, new_object) \ + (/* Check types match. */ \ + 0 ? *(weak_pointer_location) = (new_object), FALSE : \ + (g_set_weak_pointer) ((gpointer *) (weak_pointer_location), (GObject *) (new_object)) \ + ) + +typedef struct { + /**/ + union { gpointer p; } priv; +} GWeakRef; + +GOBJECT_AVAILABLE_IN_ALL +void g_weak_ref_init (GWeakRef *weak_ref, + gpointer object); +GOBJECT_AVAILABLE_IN_ALL +void g_weak_ref_clear (GWeakRef *weak_ref); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_weak_ref_get (GWeakRef *weak_ref); +GOBJECT_AVAILABLE_IN_ALL +void g_weak_ref_set (GWeakRef *weak_ref, + gpointer object); + +G_END_DECLS + +#endif /* __G_OBJECT_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gobjectnotifyqueue.c b/illumos-x86_64/usr/include/glib-2.0/gobject/gobjectnotifyqueue.c new file mode 100644 index 00000000..00266730 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gobjectnotifyqueue.c @@ -0,0 +1,199 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +/* WARNING: + * + * This file is INSTALLED and other projects (outside of glib) + * #include its contents. + */ + +#ifndef __G_OBJECT_NOTIFY_QUEUE_H__ +#define __G_OBJECT_NOTIFY_QUEUE_H__ + +#include /* memset */ + +#include + +G_BEGIN_DECLS + + +/* --- typedefs --- */ +typedef struct _GObjectNotifyContext GObjectNotifyContext; +typedef struct _GObjectNotifyQueue GObjectNotifyQueue; +typedef void (*GObjectNotifyQueueDispatcher) (GObject *object, + guint n_pspecs, + GParamSpec **pspecs); + + +/* --- structures --- */ +struct _GObjectNotifyContext +{ + GQuark quark_notify_queue; + GObjectNotifyQueueDispatcher dispatcher; + void *_nqueue_trash; /* unused */ +}; +struct _GObjectNotifyQueue +{ + GObjectNotifyContext *context; + GSList *pspecs; + guint16 n_pspecs; + guint16 freeze_count; +}; + +G_LOCK_DEFINE_STATIC(notify_lock); + +/* --- functions --- */ +static void +g_object_notify_queue_free (gpointer data) +{ + GObjectNotifyQueue *nqueue = data; + + g_slist_free (nqueue->pspecs); + g_slice_free (GObjectNotifyQueue, nqueue); +} + +static inline GObjectNotifyQueue* +g_object_notify_queue_freeze (GObject *object, + GObjectNotifyContext *context) +{ + GObjectNotifyQueue *nqueue; + + G_LOCK(notify_lock); + nqueue = g_datalist_id_get_data (&object->qdata, context->quark_notify_queue); + if (!nqueue) + { + nqueue = g_slice_new0 (GObjectNotifyQueue); + nqueue->context = context; + g_datalist_id_set_data_full (&object->qdata, context->quark_notify_queue, + nqueue, g_object_notify_queue_free); + } + + if (nqueue->freeze_count >= 65535) + g_critical("Free queue for %s (%p) is larger than 65535," + " called g_object_freeze_notify() too often." + " Forgot to call g_object_thaw_notify() or infinite loop", + G_OBJECT_TYPE_NAME (object), object); + else + nqueue->freeze_count++; + G_UNLOCK(notify_lock); + + return nqueue; +} + +static inline void +g_object_notify_queue_thaw (GObject *object, + GObjectNotifyQueue *nqueue) +{ + GObjectNotifyContext *context = nqueue->context; + GParamSpec *pspecs_mem[16], **pspecs, **free_me = NULL; + GSList *slist; + guint n_pspecs = 0; + + g_return_if_fail (nqueue->freeze_count > 0); + g_return_if_fail (g_atomic_int_get(&object->ref_count) > 0); + + G_LOCK(notify_lock); + + /* Just make sure we never get into some nasty race condition */ + if (G_UNLIKELY(nqueue->freeze_count == 0)) { + G_UNLOCK(notify_lock); + g_critical ("%s: property-changed notification for %s(%p) is not frozen", + G_STRFUNC, G_OBJECT_TYPE_NAME (object), object); + return; + } + + nqueue->freeze_count--; + if (nqueue->freeze_count) { + G_UNLOCK(notify_lock); + return; + } + + pspecs = nqueue->n_pspecs > 16 ? free_me = g_new (GParamSpec*, nqueue->n_pspecs) : pspecs_mem; + + for (slist = nqueue->pspecs; slist; slist = slist->next) + { + pspecs[n_pspecs++] = slist->data; + } + g_datalist_id_set_data (&object->qdata, context->quark_notify_queue, NULL); + + G_UNLOCK(notify_lock); + + if (n_pspecs) + context->dispatcher (object, n_pspecs, pspecs); + g_free (free_me); +} + +static inline void +g_object_notify_queue_clear (GObject *object G_GNUC_UNUSED, + GObjectNotifyQueue *nqueue) +{ + g_return_if_fail (nqueue->freeze_count > 0); + + G_LOCK(notify_lock); + + g_slist_free (nqueue->pspecs); + nqueue->pspecs = NULL; + nqueue->n_pspecs = 0; + + G_UNLOCK(notify_lock); +} + +static inline void +g_object_notify_queue_add (GObject *object G_GNUC_UNUSED, + GObjectNotifyQueue *nqueue, + GParamSpec *pspec) +{ + if (pspec->flags & G_PARAM_READABLE) + { + GParamSpec *redirect; + + G_LOCK(notify_lock); + + g_return_if_fail (nqueue->n_pspecs < 65535); + + redirect = g_param_spec_get_redirect_target (pspec); + if (redirect) + pspec = redirect; + + /* we do the deduping in _thaw */ + if (g_slist_find (nqueue->pspecs, pspec) == NULL) + { + nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec); + nqueue->n_pspecs++; + } + + G_UNLOCK(notify_lock); + } +} + +/* NB: This function is not threadsafe, do not ever use it if + * you need a threadsafe notify queue. + * Use g_object_notify_queue_freeze() to acquire the queue and + * g_object_notify_queue_thaw() after you are done instead. + */ +static inline GObjectNotifyQueue* +g_object_notify_queue_from_object (GObject *object, + GObjectNotifyContext *context) +{ + return g_datalist_id_get_data (&object->qdata, context->quark_notify_queue); +} + +G_END_DECLS + +#endif /* __G_OBJECT_NOTIFY_QUEUE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gparam.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gparam.h new file mode 100644 index 00000000..147ff53a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gparam.h @@ -0,0 +1,469 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gparam.h: GParamSpec base class implementation + */ +#ifndef __G_PARAM_H__ +#define __G_PARAM_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* --- standard type macros --- */ +/** + * G_TYPE_IS_PARAM: + * @type: a #GType ID + * + * Checks whether @type "is a" %G_TYPE_PARAM. + */ +#define G_TYPE_IS_PARAM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_PARAM) +/** + * G_PARAM_SPEC: + * @pspec: a valid #GParamSpec + * + * Casts a derived #GParamSpec object (e.g. of type #GParamSpecInt) into + * a #GParamSpec object. + */ +#define G_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM, GParamSpec)) +/** + * G_IS_PARAM_SPEC: + * @pspec: a #GParamSpec + * + * Checks whether @pspec "is a" valid #GParamSpec structure of type %G_TYPE_PARAM + * or derived. + */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_42 +#define G_IS_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE ((pspec), G_TYPE_PARAM)) +#else +#define G_IS_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM)) +#endif +/** + * G_PARAM_SPEC_CLASS: + * @pclass: a valid #GParamSpecClass + * + * Casts a derived #GParamSpecClass structure into a #GParamSpecClass structure. + */ +#define G_PARAM_SPEC_CLASS(pclass) (G_TYPE_CHECK_CLASS_CAST ((pclass), G_TYPE_PARAM, GParamSpecClass)) +/** + * G_IS_PARAM_SPEC_CLASS: + * @pclass: a #GParamSpecClass + * + * Checks whether @pclass "is a" valid #GParamSpecClass structure of type + * %G_TYPE_PARAM or derived. + */ +#define G_IS_PARAM_SPEC_CLASS(pclass) (G_TYPE_CHECK_CLASS_TYPE ((pclass), G_TYPE_PARAM)) +/** + * G_PARAM_SPEC_GET_CLASS: + * @pspec: a valid #GParamSpec + * + * Retrieves the #GParamSpecClass of a #GParamSpec. + */ +#define G_PARAM_SPEC_GET_CLASS(pspec) (G_TYPE_INSTANCE_GET_CLASS ((pspec), G_TYPE_PARAM, GParamSpecClass)) + + +/* --- convenience macros --- */ +/** + * G_PARAM_SPEC_TYPE: + * @pspec: a valid #GParamSpec + * + * Retrieves the #GType of this @pspec. + */ +#define G_PARAM_SPEC_TYPE(pspec) (G_TYPE_FROM_INSTANCE (pspec)) +/** + * G_PARAM_SPEC_TYPE_NAME: + * @pspec: a valid #GParamSpec + * + * Retrieves the #GType name of this @pspec. + */ +#define G_PARAM_SPEC_TYPE_NAME(pspec) (g_type_name (G_PARAM_SPEC_TYPE (pspec))) +/** + * G_PARAM_SPEC_VALUE_TYPE: + * @pspec: a valid #GParamSpec + * + * Retrieves the #GType to initialize a #GValue for this parameter. + */ +#define G_PARAM_SPEC_VALUE_TYPE(pspec) (G_PARAM_SPEC (pspec)->value_type) +/** + * G_VALUE_HOLDS_PARAM: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived from type %G_TYPE_PARAM. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_PARAM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_PARAM)) + + +/* --- flags --- */ +/** + * GParamFlags: + * @G_PARAM_READABLE: the parameter is readable + * @G_PARAM_WRITABLE: the parameter is writable + * @G_PARAM_READWRITE: alias for %G_PARAM_READABLE | %G_PARAM_WRITABLE + * @G_PARAM_CONSTRUCT: the parameter will be set upon object construction. + * See [vfunc@Object.constructed] for more details + * @G_PARAM_CONSTRUCT_ONLY: the parameter can only be set upon object construction. + * See [vfunc@Object.constructed] for more details + * @G_PARAM_LAX_VALIDATION: upon parameter conversion (see g_param_value_convert()) + * strict validation is not required + * @G_PARAM_STATIC_NAME: the string used as name when constructing the + * parameter is guaranteed to remain valid and + * unmodified for the lifetime of the parameter. + * Since 2.8 + * @G_PARAM_STATIC_NICK: the string used as nick when constructing the + * parameter is guaranteed to remain valid and + * unmmodified for the lifetime of the parameter. + * Since 2.8 + * @G_PARAM_STATIC_BLURB: the string used as blurb when constructing the + * parameter is guaranteed to remain valid and + * unmodified for the lifetime of the parameter. + * Since 2.8 + * @G_PARAM_EXPLICIT_NOTIFY: calls to g_object_set_property() for this + * property will not automatically result in a "notify" signal being + * emitted: the implementation must call g_object_notify() themselves + * in case the property actually changes. Since: 2.42. + * @G_PARAM_PRIVATE: internal + * @G_PARAM_DEPRECATED: the parameter is deprecated and will be removed + * in a future version. A warning will be generated if it is used + * while running with G_ENABLE_DIAGNOSTIC=1. + * Since 2.26 + * + * Through the #GParamFlags flag values, certain aspects of parameters + * can be configured. + * + * See also: %G_PARAM_STATIC_STRINGS + */ +typedef enum +{ + G_PARAM_READABLE = 1 << 0, + G_PARAM_WRITABLE = 1 << 1, + G_PARAM_READWRITE = (G_PARAM_READABLE | G_PARAM_WRITABLE), + G_PARAM_CONSTRUCT = 1 << 2, + G_PARAM_CONSTRUCT_ONLY = 1 << 3, + G_PARAM_LAX_VALIDATION = 1 << 4, + G_PARAM_STATIC_NAME = 1 << 5, + G_PARAM_PRIVATE GOBJECT_DEPRECATED_ENUMERATOR_IN_2_26 = G_PARAM_STATIC_NAME, + G_PARAM_STATIC_NICK = 1 << 6, + G_PARAM_STATIC_BLURB = 1 << 7, + /* User defined flags go here */ + G_PARAM_EXPLICIT_NOTIFY = 1 << 30, + /* Avoid warning with -Wpedantic for gcc6 */ + G_PARAM_DEPRECATED = (gint)(1u << 31) +} GParamFlags; + +/** + * G_PARAM_STATIC_STRINGS: + * + * #GParamFlags value alias for %G_PARAM_STATIC_NAME | %G_PARAM_STATIC_NICK | %G_PARAM_STATIC_BLURB. + * + * It is recommended to use this for all properties by default, as it allows for + * internal performance improvements in GObject. + * + * It is very rare that a property would have a dynamically constructed name, + * nickname or blurb. + * + * Since 2.13.0 + */ +#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) +/* bits in the range 0xffffff00 are reserved for 3rd party usage */ +/** + * G_PARAM_MASK: + * + * Mask containing the bits of #GParamSpec.flags which are reserved for GLib. + */ +#define G_PARAM_MASK (0x000000ff) +/** + * G_PARAM_USER_SHIFT: + * + * Minimum shift count to be used for user defined flags, to be stored in + * #GParamSpec.flags. The maximum allowed is 10. + */ +#define G_PARAM_USER_SHIFT (8) + +/* --- typedefs & structures --- */ +typedef struct _GParamSpec GParamSpec; +typedef struct _GParamSpecClass GParamSpecClass; +typedef struct _GParameter GParameter GOBJECT_DEPRECATED_TYPE_IN_2_54; +typedef struct _GParamSpecPool GParamSpecPool; + +struct _GParamSpec +{ + GTypeInstance g_type_instance; + + const gchar *name; /* interned string */ + GParamFlags flags; + GType value_type; + GType owner_type; /* class or interface using this property */ + + /*< private >*/ + gchar *_nick; + gchar *_blurb; + GData *qdata; + guint ref_count; + guint param_id; /* sort-criteria */ +}; +/** + * GParamSpecClass: + * @g_type_class: the parent class + * @value_type: the #GValue type for this parameter + * @finalize: The instance finalization function (optional), should chain + * up to the finalize method of the parent class. + * @value_set_default: Resets a @value to the default value for this type + * (recommended, the default is g_value_reset()), see + * g_param_value_set_default(). + * @value_validate: Ensures that the contents of @value comply with the + * specifications set out by this type (optional), see + * g_param_value_validate(). + * @values_cmp: Compares @value1 with @value2 according to this type + * (recommended, the default is memcmp()), see g_param_values_cmp(). + * @value_is_valid: Checks if contents of @value comply with the specifications + * set out by this type, without modifying the value. This vfunc is optional. + * If it isn't set, GObject will use @value_validate. Since 2.74 + * + * The class structure for the GParamSpec type. + * Normally, GParamSpec classes are filled by + * g_param_type_register_static(). + */ +struct _GParamSpecClass +{ + GTypeClass g_type_class; + + GType value_type; + + void (*finalize) (GParamSpec *pspec); + + /* GParam methods */ + void (*value_set_default) (GParamSpec *pspec, + GValue *value); + gboolean (*value_validate) (GParamSpec *pspec, + GValue *value); + gint (*values_cmp) (GParamSpec *pspec, + const GValue *value1, + const GValue *value2); + + gboolean (*value_is_valid) (GParamSpec *pspec, + const GValue *value); + + /*< private >*/ + gpointer dummy[3]; +}; +/** + * GParameter: + * @name: the parameter name + * @value: the parameter value + * + * The GParameter struct is an auxiliary structure used + * to hand parameter name/value pairs to g_object_newv(). + * + * Deprecated: 2.54: This type is not introspectable. + */ +struct _GParameter /* auxiliary structure for _setv() variants */ +{ + const gchar *name; + GValue value; +} GOBJECT_DEPRECATED_TYPE_IN_2_54; + + +/* --- prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_ref (GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +void g_param_spec_unref (GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +void g_param_spec_sink (GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_ref_sink (GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_param_spec_get_qdata (GParamSpec *pspec, + GQuark quark); +GOBJECT_AVAILABLE_IN_ALL +void g_param_spec_set_qdata (GParamSpec *pspec, + GQuark quark, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +void g_param_spec_set_qdata_full (GParamSpec *pspec, + GQuark quark, + gpointer data, + GDestroyNotify destroy); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_param_spec_steal_qdata (GParamSpec *pspec, + GQuark quark); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_get_redirect_target (GParamSpec *pspec); + +GOBJECT_AVAILABLE_IN_ALL +void g_param_value_set_default (GParamSpec *pspec, + GValue *value); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_param_value_defaults (GParamSpec *pspec, + const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_param_value_validate (GParamSpec *pspec, + GValue *value); +GOBJECT_AVAILABLE_IN_2_74 +gboolean g_param_value_is_valid (GParamSpec *pspec, + const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_param_value_convert (GParamSpec *pspec, + const GValue *src_value, + GValue *dest_value, + gboolean strict_validation); +GOBJECT_AVAILABLE_IN_ALL +gint g_param_values_cmp (GParamSpec *pspec, + const GValue *value1, + const GValue *value2); +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_param_spec_get_name (GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_param_spec_get_nick (GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_param_spec_get_blurb (GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_param (GValue *value, + GParamSpec *param); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_value_get_param (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_value_dup_param (const GValue *value); + + +GOBJECT_AVAILABLE_IN_ALL +void g_value_take_param (GValue *value, + GParamSpec *param); +GOBJECT_DEPRECATED_FOR(g_value_take_param) +void g_value_set_param_take_ownership (GValue *value, + GParamSpec *param); +GOBJECT_AVAILABLE_IN_2_36 +const GValue * g_param_spec_get_default_value (GParamSpec *pspec); + +GOBJECT_AVAILABLE_IN_2_46 +GQuark g_param_spec_get_name_quark (GParamSpec *pspec); + +/* --- convenience functions --- */ +typedef struct _GParamSpecTypeInfo GParamSpecTypeInfo; +/** + * GParamSpecTypeInfo: + * @instance_size: Size of the instance (object) structure. + * @n_preallocs: Prior to GLib 2.10, it specified the number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching). Since GLib 2.10, it is ignored, since instances are allocated with the [slice allocator][glib-Memory-Slices] now. + * @instance_init: Location of the instance initialization function (optional). + * @value_type: The #GType of values conforming to this #GParamSpec + * @finalize: The instance finalization function (optional). + * @value_set_default: Resets a @value to the default value for @pspec + * (recommended, the default is g_value_reset()), see + * g_param_value_set_default(). + * @value_validate: Ensures that the contents of @value comply with the + * specifications set out by @pspec (optional), see + * g_param_value_validate(). + * @values_cmp: Compares @value1 with @value2 according to @pspec + * (recommended, the default is memcmp()), see g_param_values_cmp(). + * + * This structure is used to provide the type system with the information + * required to initialize and destruct (finalize) a parameter's class and + * instances thereof. + * + * The initialized structure is passed to the g_param_type_register_static() + * The type system will perform a deep copy of this structure, so its memory + * does not need to be persistent across invocation of + * g_param_type_register_static(). + */ +struct _GParamSpecTypeInfo +{ + /* type system portion */ + guint16 instance_size; /* obligatory */ + guint16 n_preallocs; /* optional */ + void (*instance_init) (GParamSpec *pspec); /* optional */ + + /* class portion */ + GType value_type; /* obligatory */ + void (*finalize) (GParamSpec *pspec); /* optional */ + void (*value_set_default) (GParamSpec *pspec, /* recommended */ + GValue *value); + gboolean (*value_validate) (GParamSpec *pspec, /* optional */ + GValue *value); + gint (*values_cmp) (GParamSpec *pspec, /* recommended */ + const GValue *value1, + const GValue *value2); +}; +GOBJECT_AVAILABLE_IN_ALL +GType g_param_type_register_static (const gchar *name, + const GParamSpecTypeInfo *pspec_info); + +GOBJECT_AVAILABLE_IN_2_66 +gboolean g_param_spec_is_valid_name (const gchar *name); + +/* For registering builting types */ +GType _g_param_type_register_static_constant (const gchar *name, + const GParamSpecTypeInfo *pspec_info, + GType opt_type); + + +/* --- protected --- */ +GOBJECT_AVAILABLE_IN_ALL +gpointer g_param_spec_internal (GType param_type, + const gchar *name, + const gchar *nick, + const gchar *blurb, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpecPool* g_param_spec_pool_new (gboolean type_prefixing); +GOBJECT_AVAILABLE_IN_ALL +void g_param_spec_pool_insert (GParamSpecPool *pool, + GParamSpec *pspec, + GType owner_type); +GOBJECT_AVAILABLE_IN_ALL +void g_param_spec_pool_remove (GParamSpecPool *pool, + GParamSpec *pspec); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_pool_lookup (GParamSpecPool *pool, + const gchar *param_name, + GType owner_type, + gboolean walk_ancestors); +GOBJECT_AVAILABLE_IN_ALL +GList* g_param_spec_pool_list_owned (GParamSpecPool *pool, + GType owner_type); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec** g_param_spec_pool_list (GParamSpecPool *pool, + GType owner_type, + guint *n_pspecs_p); +GOBJECT_AVAILABLE_IN_2_80 +void g_param_spec_pool_free (GParamSpecPool *pool); + +/* contracts: + * + * gboolean value_validate (GParamSpec *pspec, + * GValue *value): + * modify value contents in the least destructive way, so + * that it complies with pspec's requirements (i.e. + * according to minimum/maximum ranges etc...). return + * whether modification was necessary. + * + * gint values_cmp (GParamSpec *pspec, + * const GValue *value1, + * const GValue *value2): + * return value1 - value2, i.e. (-1) if value1 < value2, + * (+1) if value1 > value2, and (0) otherwise (equality) + */ + +G_END_DECLS + +#endif /* __G_PARAM_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gparamspecs.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gparamspecs.h new file mode 100644 index 00000000..eaabc10d --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gparamspecs.h @@ -0,0 +1,1151 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gparamspecs.h: GLib default param specs + */ +#ifndef __G_PARAMSPECS_H__ +#define __G_PARAMSPECS_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include +#include + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_TYPE_PARAM_CHAR: + * + * The #GType of #GParamSpecChar. + */ +#define G_TYPE_PARAM_CHAR (g_param_spec_types[0]) +/** + * G_IS_PARAM_SPEC_CHAR: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_CHAR. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_CHAR)) +/** + * G_PARAM_SPEC_CHAR: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecChar. + */ +#define G_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_CHAR, GParamSpecChar)) + +/** + * G_TYPE_PARAM_UCHAR: + * + * The #GType of #GParamSpecUChar. + */ +#define G_TYPE_PARAM_UCHAR (g_param_spec_types[1]) +/** + * G_IS_PARAM_SPEC_UCHAR: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UCHAR. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UCHAR)) +/** + * G_PARAM_SPEC_UCHAR: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecUChar. + */ +#define G_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UCHAR, GParamSpecUChar)) + +/** + * G_TYPE_PARAM_BOOLEAN: + * + * The #GType of #GParamSpecBoolean. + */ +#define G_TYPE_PARAM_BOOLEAN (g_param_spec_types[2]) +/** + * G_IS_PARAM_SPEC_BOOLEAN: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_BOOLEAN. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOOLEAN)) +/** + * G_PARAM_SPEC_BOOLEAN: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecBoolean. + */ +#define G_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOOLEAN, GParamSpecBoolean)) + +/** + * G_TYPE_PARAM_INT: + * + * The #GType of #GParamSpecInt. + */ +#define G_TYPE_PARAM_INT (g_param_spec_types[3]) +/** + * G_IS_PARAM_SPEC_INT: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_INT. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT)) +/** + * G_PARAM_SPEC_INT: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecInt. + */ +#define G_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT, GParamSpecInt)) + +/** + * G_TYPE_PARAM_UINT: + * + * The #GType of #GParamSpecUInt. + */ +#define G_TYPE_PARAM_UINT (g_param_spec_types[4]) +/** + * G_IS_PARAM_SPEC_UINT: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UINT. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT)) +/** + * G_PARAM_SPEC_UINT: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecUInt. + */ +#define G_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT, GParamSpecUInt)) + +/** + * G_TYPE_PARAM_LONG: + * + * The #GType of #GParamSpecLong. + */ +#define G_TYPE_PARAM_LONG (g_param_spec_types[5]) +/** + * G_IS_PARAM_SPEC_LONG: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_LONG. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG)) +/** + * G_PARAM_SPEC_LONG: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecLong. + */ +#define G_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong)) + +/** + * G_TYPE_PARAM_ULONG: + * + * The #GType of #GParamSpecULong. + */ +#define G_TYPE_PARAM_ULONG (g_param_spec_types[6]) +/** + * G_IS_PARAM_SPEC_ULONG: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_ULONG. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG)) +/** + * G_PARAM_SPEC_ULONG: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecULong. + */ +#define G_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong)) + +/** + * G_TYPE_PARAM_INT64: + * + * The #GType of #GParamSpecInt64. + */ +#define G_TYPE_PARAM_INT64 (g_param_spec_types[7]) +/** + * G_IS_PARAM_SPEC_INT64: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_INT64. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_INT64(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT64)) +/** + * G_PARAM_SPEC_INT64: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecInt64. + */ +#define G_PARAM_SPEC_INT64(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT64, GParamSpecInt64)) + +/** + * G_TYPE_PARAM_UINT64: + * + * The #GType of #GParamSpecUInt64. + */ +#define G_TYPE_PARAM_UINT64 (g_param_spec_types[8]) +/** + * G_IS_PARAM_SPEC_UINT64: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UINT64. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_UINT64(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT64)) +/** + * G_PARAM_SPEC_UINT64: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecUInt64. + */ +#define G_PARAM_SPEC_UINT64(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT64, GParamSpecUInt64)) + +/** + * G_TYPE_PARAM_UNICHAR: + * + * The #GType of #GParamSpecUnichar. + */ +#define G_TYPE_PARAM_UNICHAR (g_param_spec_types[9]) +/** + * G_PARAM_SPEC_UNICHAR: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecUnichar. + */ +#define G_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UNICHAR, GParamSpecUnichar)) +/** + * G_IS_PARAM_SPEC_UNICHAR: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UNICHAR. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UNICHAR)) + +/** + * G_TYPE_PARAM_ENUM: + * + * The #GType of #GParamSpecEnum. + */ +#define G_TYPE_PARAM_ENUM (g_param_spec_types[10]) +/** + * G_IS_PARAM_SPEC_ENUM: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_ENUM. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM)) +/** + * G_PARAM_SPEC_ENUM: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecEnum. + */ +#define G_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum)) + +/** + * G_TYPE_PARAM_FLAGS: + * + * The #GType of #GParamSpecFlags. + */ +#define G_TYPE_PARAM_FLAGS (g_param_spec_types[11]) +/** + * G_IS_PARAM_SPEC_FLAGS: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_FLAGS. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLAGS)) +/** + * G_PARAM_SPEC_FLAGS: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecFlags. + */ +#define G_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLAGS, GParamSpecFlags)) + +/** + * G_TYPE_PARAM_FLOAT: + * + * The #GType of #GParamSpecFloat. + */ +#define G_TYPE_PARAM_FLOAT (g_param_spec_types[12]) +/** + * G_IS_PARAM_SPEC_FLOAT: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_FLOAT. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLOAT)) +/** + * G_PARAM_SPEC_FLOAT: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecFloat. + */ +#define G_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLOAT, GParamSpecFloat)) + +/** + * G_TYPE_PARAM_DOUBLE: + * + * The #GType of #GParamSpecDouble. + */ +#define G_TYPE_PARAM_DOUBLE (g_param_spec_types[13]) +/** + * G_IS_PARAM_SPEC_DOUBLE: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_DOUBLE. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_DOUBLE)) +/** + * G_PARAM_SPEC_DOUBLE: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecDouble. + */ +#define G_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_DOUBLE, GParamSpecDouble)) + +/** + * G_TYPE_PARAM_STRING: + * + * The #GType of #GParamSpecString. + */ +#define G_TYPE_PARAM_STRING (g_param_spec_types[14]) +/** + * G_IS_PARAM_SPEC_STRING: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_STRING. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_STRING)) +/** + * G_PARAM_SPEC_STRING: + * @pspec: a valid #GParamSpec instance + * + * Casts a #GParamSpec instance into a #GParamSpecString. + */ +#define G_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_STRING, GParamSpecString)) + +/** + * G_TYPE_PARAM_PARAM: + * + * The #GType of #GParamSpecParam. + */ +#define G_TYPE_PARAM_PARAM (g_param_spec_types[15]) +/** + * G_IS_PARAM_SPEC_PARAM: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_PARAM. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_PARAM)) +/** + * G_PARAM_SPEC_PARAM: + * @pspec: a valid #GParamSpec instance + * + * Casts a #GParamSpec instance into a #GParamSpecParam. + */ +#define G_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_PARAM, GParamSpecParam)) + +/** + * G_TYPE_PARAM_BOXED: + * + * The #GType of #GParamSpecBoxed. + */ +#define G_TYPE_PARAM_BOXED (g_param_spec_types[16]) +/** + * G_IS_PARAM_SPEC_BOXED: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_BOXED. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOXED)) +/** + * G_PARAM_SPEC_BOXED: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecBoxed. + */ +#define G_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOXED, GParamSpecBoxed)) + +/** + * G_TYPE_PARAM_POINTER: + * + * The #GType of #GParamSpecPointer. + */ +#define G_TYPE_PARAM_POINTER (g_param_spec_types[17]) +/** + * G_IS_PARAM_SPEC_POINTER: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_POINTER. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_POINTER)) +/** + * G_PARAM_SPEC_POINTER: + * @pspec: a valid #GParamSpec instance + * + * Casts a #GParamSpec instance into a #GParamSpecPointer. + */ +#define G_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_POINTER, GParamSpecPointer)) + +/** + * G_TYPE_PARAM_VALUE_ARRAY: + * + * The #GType of #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray + */ +#define G_TYPE_PARAM_VALUE_ARRAY (g_param_spec_types[18]) GOBJECT_DEPRECATED_MACRO_IN_2_32 +/** + * G_IS_PARAM_SPEC_VALUE_ARRAY: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VALUE_ARRAY. + * + * Returns: %TRUE on success. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray + */ +#define G_IS_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VALUE_ARRAY)) GOBJECT_DEPRECATED_MACRO_IN_2_32 +/** + * G_PARAM_SPEC_VALUE_ARRAY: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray + */ +#define G_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VALUE_ARRAY, GParamSpecValueArray)) GOBJECT_DEPRECATED_MACRO_IN_2_32 + +/** + * G_TYPE_PARAM_OBJECT: + * + * The #GType of #GParamSpecObject. + */ +#define G_TYPE_PARAM_OBJECT (g_param_spec_types[19]) +/** + * G_IS_PARAM_SPEC_OBJECT: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_OBJECT. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OBJECT)) +/** + * G_PARAM_SPEC_OBJECT: + * @pspec: a valid #GParamSpec instance + * + * Casts a #GParamSpec instance into a #GParamSpecObject. + */ +#define G_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OBJECT, GParamSpecObject)) + +/** + * G_TYPE_PARAM_OVERRIDE: + * + * The #GType of #GParamSpecOverride. + * + * Since: 2.4 + */ +#define G_TYPE_PARAM_OVERRIDE (g_param_spec_types[20]) +/** + * G_IS_PARAM_SPEC_OVERRIDE: + * @pspec: a #GParamSpec + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_OVERRIDE. + * + * Since: 2.4 + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_OVERRIDE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OVERRIDE)) +/** + * G_PARAM_SPEC_OVERRIDE: + * @pspec: a #GParamSpec + * + * Casts a #GParamSpec into a #GParamSpecOverride. + * + * Since: 2.4 + */ +#define G_PARAM_SPEC_OVERRIDE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OVERRIDE, GParamSpecOverride)) + +/** + * G_TYPE_PARAM_GTYPE: + * + * The #GType of #GParamSpecGType. + * + * Since: 2.10 + */ +#define G_TYPE_PARAM_GTYPE (g_param_spec_types[21]) +/** + * G_IS_PARAM_SPEC_GTYPE: + * @pspec: a #GParamSpec + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_GTYPE. + * + * Since: 2.10 + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_GTYPE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_GTYPE)) +/** + * G_PARAM_SPEC_GTYPE: + * @pspec: a #GParamSpec + * + * Casts a #GParamSpec into a #GParamSpecGType. + * + * Since: 2.10 + */ +#define G_PARAM_SPEC_GTYPE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_GTYPE, GParamSpecGType)) + +/** + * G_TYPE_PARAM_VARIANT: + * + * The #GType of #GParamSpecVariant. + * + * Since: 2.26 + */ +#define G_TYPE_PARAM_VARIANT (g_param_spec_types[22]) +/** + * G_IS_PARAM_SPEC_VARIANT: + * @pspec: a #GParamSpec + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VARIANT. + * + * Returns: %TRUE on success + * + * Since: 2.26 + */ +#define G_IS_PARAM_SPEC_VARIANT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VARIANT)) +/** + * G_PARAM_SPEC_VARIANT: + * @pspec: a #GParamSpec + * + * Casts a #GParamSpec into a #GParamSpecVariant. + * + * Since: 2.26 + */ +#define G_PARAM_SPEC_VARIANT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VARIANT, GParamSpecVariant)) + +/* --- typedefs & structures --- */ +typedef struct _GParamSpecChar GParamSpecChar; +typedef struct _GParamSpecUChar GParamSpecUChar; +typedef struct _GParamSpecBoolean GParamSpecBoolean; +typedef struct _GParamSpecInt GParamSpecInt; +typedef struct _GParamSpecUInt GParamSpecUInt; +typedef struct _GParamSpecLong GParamSpecLong; +typedef struct _GParamSpecULong GParamSpecULong; +typedef struct _GParamSpecInt64 GParamSpecInt64; +typedef struct _GParamSpecUInt64 GParamSpecUInt64; +typedef struct _GParamSpecUnichar GParamSpecUnichar; +typedef struct _GParamSpecEnum GParamSpecEnum; +typedef struct _GParamSpecFlags GParamSpecFlags; +typedef struct _GParamSpecFloat GParamSpecFloat; +typedef struct _GParamSpecDouble GParamSpecDouble; +typedef struct _GParamSpecString GParamSpecString; +typedef struct _GParamSpecParam GParamSpecParam; +typedef struct _GParamSpecBoxed GParamSpecBoxed; +typedef struct _GParamSpecPointer GParamSpecPointer; +typedef struct _GParamSpecValueArray GParamSpecValueArray; +typedef struct _GParamSpecObject GParamSpecObject; +typedef struct _GParamSpecOverride GParamSpecOverride; +typedef struct _GParamSpecGType GParamSpecGType; +typedef struct _GParamSpecVariant GParamSpecVariant; + +/** + * GParamSpecChar: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for character properties. + */ +struct _GParamSpecChar +{ + GParamSpec parent_instance; + + gint8 minimum; + gint8 maximum; + gint8 default_value; +}; +/** + * GParamSpecUChar: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unsigned character properties. + */ +struct _GParamSpecUChar +{ + GParamSpec parent_instance; + + guint8 minimum; + guint8 maximum; + guint8 default_value; +}; +/** + * GParamSpecBoolean: + * @parent_instance: private #GParamSpec portion + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for boolean properties. + */ +struct _GParamSpecBoolean +{ + GParamSpec parent_instance; + + gboolean default_value; +}; +/** + * GParamSpecInt: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for integer properties. + */ +struct _GParamSpecInt +{ + GParamSpec parent_instance; + + gint minimum; + gint maximum; + gint default_value; +}; +/** + * GParamSpecUInt: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unsigned integer properties. + */ +struct _GParamSpecUInt +{ + GParamSpec parent_instance; + + guint minimum; + guint maximum; + guint default_value; +}; +/** + * GParamSpecLong: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for long integer properties. + */ +struct _GParamSpecLong +{ + GParamSpec parent_instance; + + glong minimum; + glong maximum; + glong default_value; +}; +/** + * GParamSpecULong: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unsigned long integer properties. + */ +struct _GParamSpecULong +{ + GParamSpec parent_instance; + + gulong minimum; + gulong maximum; + gulong default_value; +}; +/** + * GParamSpecInt64: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for 64bit integer properties. + */ +struct _GParamSpecInt64 +{ + GParamSpec parent_instance; + + gint64 minimum; + gint64 maximum; + gint64 default_value; +}; +/** + * GParamSpecUInt64: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unsigned 64bit integer properties. + */ +struct _GParamSpecUInt64 +{ + GParamSpec parent_instance; + + guint64 minimum; + guint64 maximum; + guint64 default_value; +}; +/** + * GParamSpecUnichar: + * @parent_instance: private #GParamSpec portion + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unichar (unsigned integer) properties. + */ +struct _GParamSpecUnichar +{ + GParamSpec parent_instance; + + gunichar default_value; +}; +/** + * GParamSpecEnum: + * @parent_instance: private #GParamSpec portion + * @enum_class: the #GEnumClass for the enum + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for enum + * properties. + */ +struct _GParamSpecEnum +{ + GParamSpec parent_instance; + + GEnumClass *enum_class; + gint default_value; +}; +/** + * GParamSpecFlags: + * @parent_instance: private #GParamSpec portion + * @flags_class: the #GFlagsClass for the flags + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for flags + * properties. + */ +struct _GParamSpecFlags +{ + GParamSpec parent_instance; + + GFlagsClass *flags_class; + guint default_value; +}; +/** + * GParamSpecFloat: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * @epsilon: values closer than @epsilon will be considered identical + * by g_param_values_cmp(); the default value is 1e-30. + * + * A #GParamSpec derived structure that contains the meta data for float properties. + */ +struct _GParamSpecFloat +{ + GParamSpec parent_instance; + + gfloat minimum; + gfloat maximum; + gfloat default_value; + gfloat epsilon; +}; +/** + * GParamSpecDouble: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * @epsilon: values closer than @epsilon will be considered identical + * by g_param_values_cmp(); the default value is 1e-90. + * + * A #GParamSpec derived structure that contains the meta data for double properties. + */ +struct _GParamSpecDouble +{ + GParamSpec parent_instance; + + gdouble minimum; + gdouble maximum; + gdouble default_value; + gdouble epsilon; +}; +/** + * GParamSpecString: + * @parent_instance: private #GParamSpec portion + * @default_value: default value for the property specified + * @cset_first: a string containing the allowed values for the first byte + * @cset_nth: a string containing the allowed values for the subsequent bytes + * @substitutor: the replacement byte for bytes which don't match @cset_first or @cset_nth. + * @null_fold_if_empty: replace empty string by %NULL + * @ensure_non_null: replace %NULL strings by an empty string + * + * A #GParamSpec derived structure that contains the meta data for string + * properties. + */ +struct _GParamSpecString +{ + GParamSpec parent_instance; + + gchar *default_value; + gchar *cset_first; + gchar *cset_nth; + gchar substitutor; + guint null_fold_if_empty : 1; + guint ensure_non_null : 1; +}; +/** + * GParamSpecParam: + * @parent_instance: private #GParamSpec portion + * + * A #GParamSpec derived structure that contains the meta data for %G_TYPE_PARAM + * properties. + */ +struct _GParamSpecParam +{ + GParamSpec parent_instance; +}; +/** + * GParamSpecBoxed: + * @parent_instance: private #GParamSpec portion + * + * A #GParamSpec derived structure that contains the meta data for boxed properties. + */ +struct _GParamSpecBoxed +{ + GParamSpec parent_instance; +}; +/** + * GParamSpecPointer: + * @parent_instance: private #GParamSpec portion + * + * A #GParamSpec derived structure that contains the meta data for pointer properties. + */ +struct _GParamSpecPointer +{ + GParamSpec parent_instance; +}; +/** + * GParamSpecValueArray: + * @parent_instance: private #GParamSpec portion + * @element_spec: a #GParamSpec describing the elements contained in arrays of this property, may be %NULL + * @fixed_n_elements: if greater than 0, arrays of this property will always have this many elements + * + * A #GParamSpec derived structure that contains the meta data for #GValueArray properties. + */ +struct _GParamSpecValueArray +{ + GParamSpec parent_instance; + GParamSpec *element_spec; + guint fixed_n_elements; +}; +/** + * GParamSpecObject: + * @parent_instance: private #GParamSpec portion + * + * A #GParamSpec derived structure that contains the meta data for object properties. + */ +struct _GParamSpecObject +{ + GParamSpec parent_instance; +}; +/** + * GParamSpecOverride: + * + * A #GParamSpec derived structure that redirects operations to + * other types of #GParamSpec. + * + * All operations other than getting or setting the value are redirected, + * including accessing the nick and blurb, validating a value, and so + * forth. + * + * See g_param_spec_get_redirect_target() for retrieving the overridden + * property. #GParamSpecOverride is used in implementing + * g_object_class_override_property(), and will not be directly useful + * unless you are implementing a new base type similar to GObject. + * + * Since: 2.4 + */ +struct _GParamSpecOverride +{ + /*< private >*/ + GParamSpec parent_instance; + GParamSpec *overridden; +}; +/** + * GParamSpecGType: + * @parent_instance: private #GParamSpec portion + * @is_a_type: a #GType whose subtypes can occur as values + * + * A #GParamSpec derived structure that contains the meta data for #GType properties. + * + * Since: 2.10 + */ +struct _GParamSpecGType +{ + GParamSpec parent_instance; + GType is_a_type; +}; +/** + * GParamSpecVariant: + * @parent_instance: private #GParamSpec portion + * @type: a #GVariantType, or %NULL + * @default_value: a #GVariant, or %NULL + * + * A #GParamSpec derived structure that contains the meta data for #GVariant properties. + * + * When comparing values with g_param_values_cmp(), scalar values with the same + * type will be compared with g_variant_compare(). Other non-%NULL variants will + * be checked for equality with g_variant_equal(), and their sort order is + * otherwise undefined. %NULL is ordered before non-%NULL variants. Two %NULL + * values compare equal. + * + * Since: 2.26 + */ +struct _GParamSpecVariant +{ + GParamSpec parent_instance; + GVariantType *type; + GVariant *default_value; + + /*< private >*/ + gpointer padding[4]; +}; + +/* --- GParamSpec prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_char (const gchar *name, + const gchar *nick, + const gchar *blurb, + gint8 minimum, + gint8 maximum, + gint8 default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_uchar (const gchar *name, + const gchar *nick, + const gchar *blurb, + guint8 minimum, + guint8 maximum, + guint8 default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_boolean (const gchar *name, + const gchar *nick, + const gchar *blurb, + gboolean default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_int (const gchar *name, + const gchar *nick, + const gchar *blurb, + gint minimum, + gint maximum, + gint default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_uint (const gchar *name, + const gchar *nick, + const gchar *blurb, + guint minimum, + guint maximum, + guint default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_long (const gchar *name, + const gchar *nick, + const gchar *blurb, + glong minimum, + glong maximum, + glong default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_ulong (const gchar *name, + const gchar *nick, + const gchar *blurb, + gulong minimum, + gulong maximum, + gulong default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_int64 (const gchar *name, + const gchar *nick, + const gchar *blurb, + gint64 minimum, + gint64 maximum, + gint64 default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_uint64 (const gchar *name, + const gchar *nick, + const gchar *blurb, + guint64 minimum, + guint64 maximum, + guint64 default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_unichar (const gchar *name, + const gchar *nick, + const gchar *blurb, + gunichar default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_enum (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType enum_type, + gint default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_flags (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType flags_type, + guint default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_float (const gchar *name, + const gchar *nick, + const gchar *blurb, + gfloat minimum, + gfloat maximum, + gfloat default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_double (const gchar *name, + const gchar *nick, + const gchar *blurb, + gdouble minimum, + gdouble maximum, + gdouble default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_string (const gchar *name, + const gchar *nick, + const gchar *blurb, + const gchar *default_value, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_param (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType param_type, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_boxed (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType boxed_type, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_pointer (const gchar *name, + const gchar *nick, + const gchar *blurb, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_value_array (const gchar *name, + const gchar *nick, + const gchar *blurb, + GParamSpec *element_spec, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_object (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType object_type, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_override (const gchar *name, + GParamSpec *overridden); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_gtype (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType is_a_type, + GParamFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_variant (const gchar *name, + const gchar *nick, + const gchar *blurb, + const GVariantType *type, + GVariant *default_value, + GParamFlags flags); + +GOBJECT_VAR GType *g_param_spec_types; + +G_END_DECLS + +#endif /* __G_PARAMSPECS_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gsignal.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gsignal.h new file mode 100644 index 00000000..b5cdcad1 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gsignal.h @@ -0,0 +1,697 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000-2001 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_SIGNAL_H__ +#define __G_SIGNAL_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include +#include + +G_BEGIN_DECLS + +/* --- typedefs --- */ +typedef struct _GSignalQuery GSignalQuery; +typedef struct _GSignalInvocationHint GSignalInvocationHint; +/** + * GSignalCMarshaller: + * + * This is the signature of marshaller functions, required to marshall + * arrays of parameter values to signal emissions into C language callback + * invocations. + * + * It is merely an alias to #GClosureMarshal since the #GClosure mechanism + * takes over responsibility of actual function invocation for the signal + * system. + */ +typedef GClosureMarshal GSignalCMarshaller; +/** + * GSignalCVaMarshaller: + * + * This is the signature of va_list marshaller functions, an optional + * marshaller that can be used in some situations to avoid + * marshalling the signal argument into GValues. + */ +typedef GVaClosureMarshal GSignalCVaMarshaller; +/** + * GSignalEmissionHook: + * @ihint: Signal invocation hint, see #GSignalInvocationHint. + * @n_param_values: the number of parameters to the function, including + * the instance on which the signal was emitted. + * @param_values: (array length=n_param_values): the instance on which + * the signal was emitted, followed by the parameters of the emission. + * @data: user data associated with the hook. + * + * A simple function pointer to get invoked when the signal is emitted. + * + * Emission hooks allow you to tie a hook to the signal type, so that it will + * trap all emissions of that signal, from any object. + * + * You may not attach these to signals created with the %G_SIGNAL_NO_HOOKS flag. + * + * Returns: whether it wants to stay connected. If it returns %FALSE, the signal + * hook is disconnected (and destroyed). + */ +typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint, + guint n_param_values, + const GValue *param_values, + gpointer data); +/** + * GSignalAccumulator: + * @ihint: Signal invocation hint, see #GSignalInvocationHint. + * @return_accu: Accumulator to collect callback return values in, this + * is the return value of the current signal emission. + * @handler_return: A #GValue holding the return value of the signal handler. + * @data: Callback data that was specified when creating the signal. + * + * The signal accumulator is a special callback function that can be used + * to collect return values of the various callbacks that are called + * during a signal emission. + * + * The signal accumulator is specified at signal creation time, if it is + * left %NULL, no accumulation of callback return values is performed. + * The return value of signal emissions is then the value returned by the + * last callback. + * + * Returns: The accumulator function returns whether the signal emission + * should be aborted. Returning %TRUE will continue with + * the signal emission. Returning %FALSE will abort the current emission. + * Since 2.62, returning %FALSE will skip to the CLEANUP stage. In this case, + * emission will occur as normal in the CLEANUP stage and the handler's + * return value will be accumulated. + */ +typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer data); + + +/* --- run, match and connect types --- */ +/** + * GSignalFlags: + * @G_SIGNAL_RUN_FIRST: Invoke the object method handler in the first emission stage. + * @G_SIGNAL_RUN_LAST: Invoke the object method handler in the third emission stage. + * @G_SIGNAL_RUN_CLEANUP: Invoke the object method handler in the last emission stage. + * @G_SIGNAL_NO_RECURSE: Signals being emitted for an object while currently being in + * emission for this very object will not be emitted recursively, + * but instead cause the first emission to be restarted. + * @G_SIGNAL_DETAILED: This signal supports "::detail" appendices to the signal name + * upon handler connections and emissions. + * @G_SIGNAL_ACTION: Action signals are signals that may freely be emitted on alive + * objects from user code via g_signal_emit() and friends, without + * the need of being embedded into extra code that performs pre or + * post emission adjustments on the object. They can also be thought + * of as object methods which can be called generically by + * third-party code. + * @G_SIGNAL_NO_HOOKS: No emissions hooks are supported for this signal. + * + * The signal flags are used to specify a signal's behaviour. + */ +typedef enum +{ + G_SIGNAL_RUN_FIRST = 1 << 0, + G_SIGNAL_RUN_LAST = 1 << 1, + G_SIGNAL_RUN_CLEANUP = 1 << 2, + G_SIGNAL_NO_RECURSE = 1 << 3, + G_SIGNAL_DETAILED = 1 << 4, + G_SIGNAL_ACTION = 1 << 5, + G_SIGNAL_NO_HOOKS = 1 << 6, + G_SIGNAL_MUST_COLLECT = 1 << 7, + G_SIGNAL_DEPRECATED = 1 << 8, + /* normal signal flags until 1 << 16 */ + G_SIGNAL_ACCUMULATOR_FIRST_RUN = 1 << 17, +} GSignalFlags; + +/** + * G_SIGNAL_MUST_COLLECT: + * + * Varargs signal emission will always collect the arguments, even if there + * are no signal handlers connected. + * + * Since: 2.30 + */ + +/** + * G_SIGNAL_DEPRECATED: + * + * The signal is deprecated and will be removed in a future version. + * + * A warning will be generated if it is connected while running with + * `G_ENABLE_DIAGNOSTIC=1`. + * + * Since: 2.32 + */ + +/** + * G_SIGNAL_ACCUMULATOR_FIRST_RUN: + * + * The signal accumulator was invoked for the first time. + * + * This flag is only used in [callback@GObject.SignalAccumulator][accumulator functions] + * for the `run_type` field of the [struct@GObject.SignalInvocationHint], to + * mark the first call to the accumulator function for a signal emission. + * + * Since: 2.68 + */ + +/** + * G_SIGNAL_FLAGS_MASK: + * + * A mask for all #GSignalFlags bits. + */ +#define G_SIGNAL_FLAGS_MASK 0x1ff +/** + * GConnectFlags: + * @G_CONNECT_DEFAULT: Default behaviour (no special flags). Since: 2.74 + * @G_CONNECT_AFTER: If set, the handler should be called after the + * default handler of the signal. Normally, the handler is called before + * the default handler. + * @G_CONNECT_SWAPPED: If set, the instance and data should be swapped when + * calling the handler; see g_signal_connect_swapped() for an example. + * + * The connection flags are used to specify the behaviour of a signal's + * connection. + */ +typedef enum +{ + G_CONNECT_DEFAULT GOBJECT_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_CONNECT_AFTER = 1 << 0, + G_CONNECT_SWAPPED = 1 << 1 +} GConnectFlags; +/** + * GSignalMatchType: + * @G_SIGNAL_MATCH_ID: The signal id must be equal. + * @G_SIGNAL_MATCH_DETAIL: The signal detail must be equal. + * @G_SIGNAL_MATCH_CLOSURE: The closure must be the same. + * @G_SIGNAL_MATCH_FUNC: The C closure callback must be the same. + * @G_SIGNAL_MATCH_DATA: The closure data must be the same. + * @G_SIGNAL_MATCH_UNBLOCKED: Only unblocked signals may be matched. + * + * The match types specify what g_signal_handlers_block_matched(), + * g_signal_handlers_unblock_matched() and g_signal_handlers_disconnect_matched() + * match signals by. + */ +typedef enum +{ + G_SIGNAL_MATCH_ID = 1 << 0, + G_SIGNAL_MATCH_DETAIL = 1 << 1, + G_SIGNAL_MATCH_CLOSURE = 1 << 2, + G_SIGNAL_MATCH_FUNC = 1 << 3, + G_SIGNAL_MATCH_DATA = 1 << 4, + G_SIGNAL_MATCH_UNBLOCKED = 1 << 5 +} GSignalMatchType; +/** + * G_SIGNAL_MATCH_MASK: + * + * A mask for all #GSignalMatchType bits. + */ +#define G_SIGNAL_MATCH_MASK 0x3f +/** + * G_SIGNAL_TYPE_STATIC_SCOPE: + * + * This macro flags signal argument types for which the signal system may + * assume that instances thereof remain persistent across all signal emissions + * they are used in. This is only useful for non ref-counted, value-copy types. + * + * To flag a signal argument in this way, add `| G_SIGNAL_TYPE_STATIC_SCOPE` + * to the corresponding argument of g_signal_new(). + * |[ + * g_signal_new ("size_request", + * G_TYPE_FROM_CLASS (gobject_class), + * G_SIGNAL_RUN_FIRST, + * G_STRUCT_OFFSET (GtkWidgetClass, size_request), + * NULL, NULL, + * _gtk_marshal_VOID__BOXED, + * G_TYPE_NONE, 1, + * GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE); + * ]| + */ +#define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT) + + +/* --- signal information --- */ +/** + * GSignalInvocationHint: + * @signal_id: The signal id of the signal invoking the callback + * @detail: The detail passed on for this emission + * @run_type: The stage the signal emission is currently in, this + * field will contain one of %G_SIGNAL_RUN_FIRST, + * %G_SIGNAL_RUN_LAST or %G_SIGNAL_RUN_CLEANUP and %G_SIGNAL_ACCUMULATOR_FIRST_RUN. + * %G_SIGNAL_ACCUMULATOR_FIRST_RUN is only set for the first run of the accumulator + * function for a signal emission. + * + * The #GSignalInvocationHint structure is used to pass on additional information + * to callbacks during a signal emission. + */ +struct _GSignalInvocationHint +{ + guint signal_id; + GQuark detail; + GSignalFlags run_type; +}; +/** + * GSignalQuery: + * @signal_id: The signal id of the signal being queried, or 0 if the + * signal to be queried was unknown. + * @signal_name: The signal name. + * @itype: The interface/instance type that this signal can be emitted for. + * @signal_flags: The signal flags as passed in to g_signal_new(). + * @return_type: The return type for user callbacks. + * @n_params: The number of parameters that user callbacks take. + * @param_types: (array length=n_params): The individual parameter types for + * user callbacks, note that the effective callback signature is: + * |[ + * @return_type callback (#gpointer data1, + * [param_types param_names,] + * gpointer data2); + * ]| + * + * A structure holding in-depth information for a specific signal. + * + * See also: g_signal_query() + */ +struct _GSignalQuery +{ + guint signal_id; + const gchar *signal_name; + GType itype; + GSignalFlags signal_flags; + GType return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ + guint n_params; + const GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ +}; + + +/* --- signals --- */ +GOBJECT_AVAILABLE_IN_ALL +guint g_signal_newv (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + GClosure *class_closure, + GSignalAccumulator accumulator, + gpointer accu_data, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + GType *param_types); +GOBJECT_AVAILABLE_IN_ALL +guint g_signal_new_valist (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + GClosure *class_closure, + GSignalAccumulator accumulator, + gpointer accu_data, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + va_list args); +GOBJECT_AVAILABLE_IN_ALL +guint g_signal_new (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + guint class_offset, + GSignalAccumulator accumulator, + gpointer accu_data, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + ...); +GOBJECT_AVAILABLE_IN_ALL +guint g_signal_new_class_handler (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + GCallback class_handler, + GSignalAccumulator accumulator, + gpointer accu_data, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + ...); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_set_va_marshaller (guint signal_id, + GType instance_type, + GSignalCVaMarshaller va_marshaller); + +GOBJECT_AVAILABLE_IN_ALL +void g_signal_emitv (const GValue *instance_and_params, + guint signal_id, + GQuark detail, + GValue *return_value); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_emit_valist (gpointer instance, + guint signal_id, + GQuark detail, + va_list var_args); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_emit (gpointer instance, + guint signal_id, + GQuark detail, + ...); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_emit_by_name (gpointer instance, + const gchar *detailed_signal, + ...); +GOBJECT_AVAILABLE_IN_ALL +guint g_signal_lookup (const gchar *name, + GType itype); +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_signal_name (guint signal_id); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_query (guint signal_id, + GSignalQuery *query); +GOBJECT_AVAILABLE_IN_ALL +guint* g_signal_list_ids (GType itype, + guint *n_ids); +GOBJECT_AVAILABLE_IN_2_66 +gboolean g_signal_is_valid_name (const gchar *name); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_signal_parse_name (const gchar *detailed_signal, + GType itype, + guint *signal_id_p, + GQuark *detail_p, + gboolean force_detail_quark); +GOBJECT_AVAILABLE_IN_ALL +GSignalInvocationHint* g_signal_get_invocation_hint (gpointer instance); + + +/* --- signal emissions --- */ +GOBJECT_AVAILABLE_IN_ALL +void g_signal_stop_emission (gpointer instance, + guint signal_id, + GQuark detail); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_stop_emission_by_name (gpointer instance, + const gchar *detailed_signal); +GOBJECT_AVAILABLE_IN_ALL +gulong g_signal_add_emission_hook (guint signal_id, + GQuark detail, + GSignalEmissionHook hook_func, + gpointer hook_data, + GDestroyNotify data_destroy); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_remove_emission_hook (guint signal_id, + gulong hook_id); + + +/* --- signal handlers --- */ +GOBJECT_AVAILABLE_IN_ALL +gboolean g_signal_has_handler_pending (gpointer instance, + guint signal_id, + GQuark detail, + gboolean may_be_blocked); +GOBJECT_AVAILABLE_IN_ALL +gulong g_signal_connect_closure_by_id (gpointer instance, + guint signal_id, + GQuark detail, + GClosure *closure, + gboolean after); +GOBJECT_AVAILABLE_IN_ALL +gulong g_signal_connect_closure (gpointer instance, + const gchar *detailed_signal, + GClosure *closure, + gboolean after); +GOBJECT_AVAILABLE_IN_ALL +gulong g_signal_connect_data (gpointer instance, + const gchar *detailed_signal, + GCallback c_handler, + gpointer data, + GClosureNotify destroy_data, + GConnectFlags connect_flags); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_handler_block (gpointer instance, + gulong handler_id); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_handler_unblock (gpointer instance, + gulong handler_id); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_handler_disconnect (gpointer instance, + gulong handler_id); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_signal_handler_is_connected (gpointer instance, + gulong handler_id); +GOBJECT_AVAILABLE_IN_ALL +gulong g_signal_handler_find (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +guint g_signal_handlers_block_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +guint g_signal_handlers_unblock_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +guint g_signal_handlers_disconnect_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); + +GOBJECT_AVAILABLE_IN_2_62 +void g_clear_signal_handler (gulong *handler_id_ptr, + gpointer instance); + +#define g_clear_signal_handler(handler_id_ptr, instance) \ + G_STMT_START { \ + gpointer const _instance = (instance); \ + gulong *const _handler_id_ptr = (handler_id_ptr); \ + const gulong _handler_id = *_handler_id_ptr; \ + \ + if (_handler_id > 0) \ + { \ + *_handler_id_ptr = 0; \ + g_signal_handler_disconnect (_instance, _handler_id); \ + } \ + } G_STMT_END \ + GOBJECT_AVAILABLE_MACRO_IN_2_62 + +/* --- overriding and chaining --- */ +GOBJECT_AVAILABLE_IN_ALL +void g_signal_override_class_closure (guint signal_id, + GType instance_type, + GClosure *class_closure); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_override_class_handler (const gchar *signal_name, + GType instance_type, + GCallback class_handler); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_chain_from_overridden (const GValue *instance_and_params, + GValue *return_value); +GOBJECT_AVAILABLE_IN_ALL +void g_signal_chain_from_overridden_handler (gpointer instance, + ...); + + +/* --- convenience --- */ +/** + * g_signal_connect: + * @instance: the instance to connect to. + * @detailed_signal: a string of the form "signal-name::detail". + * @c_handler: the #GCallback to connect. + * @data: data to pass to @c_handler calls. + * + * Connects a [type@GObject.Callback] function to a signal for a particular object. + * + * The handler will be called synchronously, before the default handler of the signal. + * [func@GObject.signal_emit] will not return control until all handlers are called. + * + * See [memory management of signal handlers](signals.html#memory-management-of-signal-handlers) for + * details on how to handle the return value and memory management of @data. + * + * This function cannot fail. If the given signal name doesn’t exist, + * a critical warning is emitted. No validation is performed on the + * ‘detail’ string when specified in @detailed_signal, other than a + * non-empty check. + * + * Refer to the [signals documentation](signals.html) for more + * details. + * + * Returns: the handler ID, of type `gulong` (always greater than 0) + */ +/* Intentionally not using G_CONNECT_DEFAULT here to avoid deprecation + * warnings with older GLIB_VERSION_MAX_ALLOWED */ +#define g_signal_connect(instance, detailed_signal, c_handler, data) \ + g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0) +/** + * g_signal_connect_after: + * @instance: the instance to connect to. + * @detailed_signal: a string of the form "signal-name::detail". + * @c_handler: the #GCallback to connect. + * @data: data to pass to @c_handler calls. + * + * Connects a #GCallback function to a signal for a particular object. + * + * The handler will be called synchronously, after the default handler of the signal. + * + * This function cannot fail. If the given signal name doesn’t exist, + * a critical warning is emitted. No validation is performed on the + * ‘detail’ string when specified in @detailed_signal, other than a + * non-empty check. + * + * Refer to the [signals documentation](signals.html) for more + * details. + * + * Returns: the handler ID, of type `gulong` (always greater than 0) + */ +#define g_signal_connect_after(instance, detailed_signal, c_handler, data) \ + g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_AFTER) +/** + * g_signal_connect_swapped: + * @instance: the instance to connect to. + * @detailed_signal: a string of the form "signal-name::detail". + * @c_handler: the #GCallback to connect. + * @data: data to pass to @c_handler calls. + * + * Connects a #GCallback function to a signal for a particular object. + * + * The instance on which the signal is emitted and @data will be swapped when + * calling the handler. This is useful when calling pre-existing functions to + * operate purely on the @data, rather than the @instance: swapping the + * parameters avoids the need to write a wrapper function. + * + * For example, this allows the shorter code: + * |[ + * g_signal_connect_swapped (button, "clicked", + * (GCallback) gtk_widget_hide, other_widget); + * ]| + * + * Rather than the cumbersome: + * |[ + * static void + * button_clicked_cb (GtkButton *button, GtkWidget *other_widget) + * { + * gtk_widget_hide (other_widget); + * } + * + * ... + * + * g_signal_connect (button, "clicked", + * (GCallback) button_clicked_cb, other_widget); + * ]| + * + * This function cannot fail. If the given signal name doesn’t exist, + * a critical warning is emitted. No validation is performed on the + * ‘detail’ string when specified in @detailed_signal, other than a + * non-empty check. + * + * Refer to the [signals documentation](signals.html) for more + * details. + * + * Returns: the handler ID, of type `gulong` (always greater than 0) + */ +#define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \ + g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_SWAPPED) +/** + * g_signal_handlers_disconnect_by_func: + * @instance: The instance to remove handlers from. + * @func: The C closure callback of the handlers (useless for non-C closures). + * @data: The closure data of the handlers' closures. + * + * Disconnects all handlers on an instance that match @func and @data. + * + * Returns: The number of handlers that matched. + */ +#define g_signal_handlers_disconnect_by_func(instance, func, data) \ + g_signal_handlers_disconnect_matched ((instance), \ + (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ + 0, 0, NULL, (func), (data)) + +/** + * g_signal_handlers_disconnect_by_data: + * @instance: The instance to remove handlers from + * @data: the closure data of the handlers' closures + * + * Disconnects all handlers on an instance that match @data. + * + * Returns: The number of handlers that matched. + * + * Since: 2.32 + */ +#define g_signal_handlers_disconnect_by_data(instance, data) \ + g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (data)) + +/** + * g_signal_handlers_block_by_func: + * @instance: The instance to block handlers from. + * @func: The C closure callback of the handlers (useless for non-C closures). + * @data: The closure data of the handlers' closures. + * + * Blocks all handlers on an instance that match @func and @data. + * + * Returns: The number of handlers that matched. + */ +#define g_signal_handlers_block_by_func(instance, func, data) \ + g_signal_handlers_block_matched ((instance), \ + (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ + 0, 0, NULL, (func), (data)) +/** + * g_signal_handlers_unblock_by_func: + * @instance: The instance to unblock handlers from. + * @func: The C closure callback of the handlers (useless for non-C closures). + * @data: The closure data of the handlers' closures. + * + * Unblocks all handlers on an instance that match @func and @data. + * + * Returns: The number of handlers that matched. + */ +#define g_signal_handlers_unblock_by_func(instance, func, data) \ + g_signal_handlers_unblock_matched ((instance), \ + (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ + 0, 0, NULL, (func), (data)) + + +GOBJECT_AVAILABLE_IN_ALL +gboolean g_signal_accumulator_true_handled (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer dummy); + +GOBJECT_AVAILABLE_IN_ALL +gboolean g_signal_accumulator_first_wins (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer dummy); + +/*< private >*/ +GOBJECT_AVAILABLE_IN_ALL +void g_signal_handlers_destroy (gpointer instance); +void _g_signals_destroy (GType itype); + +G_END_DECLS + +#endif /* __G_SIGNAL_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gsignalgroup.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gsignalgroup.h new file mode 100644 index 00000000..38fd2e03 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gsignalgroup.h @@ -0,0 +1,90 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * + * Copyright (C) 2015-2022 Christian Hergert + * Copyright (C) 2015 Garrett Regier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef __G_SIGNAL_GROUP_H__ +#define __G_SIGNAL_GROUP_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +#define G_SIGNAL_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SIGNAL_GROUP, GSignalGroup)) +#define G_IS_SIGNAL_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SIGNAL_GROUP)) +#define G_TYPE_SIGNAL_GROUP (g_signal_group_get_type()) + +typedef struct _GSignalGroup GSignalGroup; + +GOBJECT_AVAILABLE_IN_2_72 +GType g_signal_group_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_2_72 +GSignalGroup *g_signal_group_new (GType target_type); +GOBJECT_AVAILABLE_IN_2_72 +void g_signal_group_set_target (GSignalGroup *self, + gpointer target); +GOBJECT_AVAILABLE_IN_2_72 +gpointer g_signal_group_dup_target (GSignalGroup *self); +GOBJECT_AVAILABLE_IN_2_72 +void g_signal_group_block (GSignalGroup *self); +GOBJECT_AVAILABLE_IN_2_72 +void g_signal_group_unblock (GSignalGroup *self); +GOBJECT_AVAILABLE_IN_2_74 +void g_signal_group_connect_closure (GSignalGroup *self, + const gchar *detailed_signal, + GClosure *closure, + gboolean after); +GOBJECT_AVAILABLE_IN_2_72 +void g_signal_group_connect_object (GSignalGroup *self, + const gchar *detailed_signal, + GCallback c_handler, + gpointer object, + GConnectFlags flags); +GOBJECT_AVAILABLE_IN_2_72 +void g_signal_group_connect_data (GSignalGroup *self, + const gchar *detailed_signal, + GCallback c_handler, + gpointer data, + GClosureNotify notify, + GConnectFlags flags); +GOBJECT_AVAILABLE_IN_2_72 +void g_signal_group_connect (GSignalGroup *self, + const gchar *detailed_signal, + GCallback c_handler, + gpointer data); +GOBJECT_AVAILABLE_IN_2_72 +void g_signal_group_connect_after (GSignalGroup *self, + const gchar *detailed_signal, + GCallback c_handler, + gpointer data); +GOBJECT_AVAILABLE_IN_2_72 +void g_signal_group_connect_swapped (GSignalGroup *self, + const gchar *detailed_signal, + GCallback c_handler, + gpointer data); + +G_END_DECLS + +#endif /* __G_SIGNAL_GROUP_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gsourceclosure.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gsourceclosure.h new file mode 100644 index 00000000..d6091654 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gsourceclosure.h @@ -0,0 +1,40 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2001 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_SOURCECLOSURE_H__ +#define __G_SOURCECLOSURE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +GOBJECT_AVAILABLE_IN_ALL +void g_source_set_closure (GSource *source, + GClosure *closure); + +GOBJECT_AVAILABLE_IN_ALL +void g_source_set_dummy_callback (GSource *source); + +G_END_DECLS + +#endif /* __G_SOURCECLOSURE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gtype.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gtype.h new file mode 100644 index 00000000..fcb176d2 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gtype.h @@ -0,0 +1,2742 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_TYPE_H__ +#define __G_TYPE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/* Basic Type Macros + */ +/** + * G_TYPE_FUNDAMENTAL: + * @type: A #GType value. + * + * The fundamental type which is the ancestor of @type. + * + * Fundamental types are types that serve as ultimate bases for the derived types, + * thus they are the roots of distinct inheritance hierarchies. + */ +#define G_TYPE_FUNDAMENTAL(type) (g_type_fundamental (type)) +/** + * G_TYPE_FUNDAMENTAL_SHIFT: + * + * Shift value used in converting numbers to type IDs. + */ +#define G_TYPE_FUNDAMENTAL_SHIFT (2) +/** + * G_TYPE_FUNDAMENTAL_MAX: (value 1020) + * + * An integer constant that represents the number of identifiers reserved + * for types that are assigned at compile-time. + */ +#define G_TYPE_FUNDAMENTAL_MAX (255 << G_TYPE_FUNDAMENTAL_SHIFT) + +/* Constant fundamental types, + */ +/** + * G_TYPE_INVALID: + * + * An invalid #GType used as error return value in some functions which return + * a #GType. + */ +#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0) +/** + * G_TYPE_NONE: + * + * A fundamental type which is used as a replacement for the C + * void return type. + */ +#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1) +/** + * G_TYPE_INTERFACE: + * + * The fundamental type from which all interfaces are derived. + */ +#define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2) +/** + * G_TYPE_CHAR: + * + * The fundamental type corresponding to #gchar. + * + * The type designated by %G_TYPE_CHAR is unconditionally an 8-bit signed integer. + * This may or may not be the same type a the C type "gchar". + */ +#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3) +/** + * G_TYPE_UCHAR: + * + * The fundamental type corresponding to #guchar. + */ +#define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4) +/** + * G_TYPE_BOOLEAN: + * + * The fundamental type corresponding to #gboolean. + */ +#define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5) +/** + * G_TYPE_INT: + * + * The fundamental type corresponding to #gint. + */ +#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6) +/** + * G_TYPE_UINT: + * + * The fundamental type corresponding to #guint. + */ +#define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7) +/** + * G_TYPE_LONG: + * + * The fundamental type corresponding to #glong. + */ +#define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8) +/** + * G_TYPE_ULONG: + * + * The fundamental type corresponding to #gulong. + */ +#define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9) +/** + * G_TYPE_INT64: + * + * The fundamental type corresponding to #gint64. + */ +#define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10) +/** + * G_TYPE_UINT64: + * + * The fundamental type corresponding to #guint64. + */ +#define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11) +/** + * G_TYPE_ENUM: + * + * The fundamental type from which all enumeration types are derived. + */ +#define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12) +/** + * G_TYPE_FLAGS: + * + * The fundamental type from which all flags types are derived. + */ +#define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13) +/** + * G_TYPE_FLOAT: + * + * The fundamental type corresponding to #gfloat. + */ +#define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14) +/** + * G_TYPE_DOUBLE: + * + * The fundamental type corresponding to #gdouble. + */ +#define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15) +/** + * G_TYPE_STRING: + * + * The fundamental type corresponding to nul-terminated C strings. + */ +#define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16) +/** + * G_TYPE_POINTER: + * + * The fundamental type corresponding to #gpointer. + */ +#define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17) +/** + * G_TYPE_BOXED: + * + * The fundamental type from which all boxed types are derived. + */ +#define G_TYPE_BOXED G_TYPE_MAKE_FUNDAMENTAL (18) +/** + * G_TYPE_PARAM: + * + * The fundamental type from which all #GParamSpec types are derived. + */ +#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19) +/** + * G_TYPE_OBJECT: + * + * The fundamental type for #GObject. + */ +#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20) +/** + * G_TYPE_VARIANT: + * + * The fundamental type corresponding to #GVariant. + * + * All floating #GVariant instances passed through the #GType system are + * consumed. + * + * Note that callbacks in closures, and signal handlers + * for signals of return type %G_TYPE_VARIANT, must never return floating + * variants. + * + * Note: GLib 2.24 did include a boxed type with this name. It was replaced + * with this fundamental type in 2.26. + * + * Since: 2.26 + */ +#define G_TYPE_VARIANT G_TYPE_MAKE_FUNDAMENTAL (21) + + +/* Reserved fundamental type numbers to create new fundamental + * type IDs with G_TYPE_MAKE_FUNDAMENTAL(). + * + * Open an issue on https://gitlab.gnome.org/GNOME/glib/issues/new for + * reservations. + */ +/** + * G_TYPE_MAKE_FUNDAMENTAL: + * @x: the fundamental type number. + * + * Get the type ID for the fundamental type number @x. + * + * Use g_type_fundamental_next() instead of this macro to create new fundamental + * types. + * + * Returns: the GType + */ +#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT)) +/** + * G_TYPE_RESERVED_GLIB_FIRST: + * + * First fundamental type number to create a new fundamental type id with + * G_TYPE_MAKE_FUNDAMENTAL() reserved for GLib. + */ +#define G_TYPE_RESERVED_GLIB_FIRST (22) +/** + * G_TYPE_RESERVED_GLIB_LAST: + * + * Last fundamental type number reserved for GLib. + */ +#define G_TYPE_RESERVED_GLIB_LAST (31) +/** + * G_TYPE_RESERVED_BSE_FIRST: + * + * First fundamental type number to create a new fundamental type id with + * G_TYPE_MAKE_FUNDAMENTAL() reserved for BSE. + */ +#define G_TYPE_RESERVED_BSE_FIRST (32) +/** + * G_TYPE_RESERVED_BSE_LAST: + * + * Last fundamental type number reserved for BSE. + */ +#define G_TYPE_RESERVED_BSE_LAST (48) +/** + * G_TYPE_RESERVED_USER_FIRST: + * + * First available fundamental type number to create new fundamental + * type id with G_TYPE_MAKE_FUNDAMENTAL(). + */ +#define G_TYPE_RESERVED_USER_FIRST (49) + + +/* Type Checking Macros + */ +/** + * G_TYPE_IS_FUNDAMENTAL: + * @type: A #GType value + * + * Checks if @type is a fundamental type. + * + * Returns: %TRUE is @type is fundamental + */ +#define G_TYPE_IS_FUNDAMENTAL(type) ((type) <= G_TYPE_FUNDAMENTAL_MAX) +/** + * G_TYPE_IS_DERIVED: + * @type: A #GType value + * + * Checks if @type is derived (or in object-oriented terminology: + * inherited) from another type (this holds true for all non-fundamental + * types). + * + * Returns: %TRUE if @type is derived + */ +#define G_TYPE_IS_DERIVED(type) ((type) > G_TYPE_FUNDAMENTAL_MAX) +/** + * G_TYPE_IS_INTERFACE: + * @type: A #GType value + * + * Checks if @type is an interface type. + * + * An interface type provides a pure API, the implementation + * of which is provided by another type (which is then said to conform + * to the interface). GLib interfaces are somewhat analogous to Java + * interfaces and C++ classes containing only pure virtual functions, + * with the difference that GType interfaces are not derivable (but see + * g_type_interface_add_prerequisite() for an alternative). + * + * Returns: %TRUE if @type is an interface + */ +#define G_TYPE_IS_INTERFACE(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE) +/** + * G_TYPE_IS_CLASSED: + * @type: A #GType value + * + * Checks if @type is a classed type. + * + * A classed type has an associated #GTypeClass which can be derived to store + * class-wide virtual function pointers and data for all instances of the type. + * This allows for subclassing. All #GObjects are classed; none of the scalar + * fundamental types built into GLib are classed. + * + * Interfaces are not classed: while their #GTypeInterface struct could be + * considered similar to #GTypeClass, and classes can derive interfaces, + * #GTypeInterface doesn’t allow for subclassing. + * + * Returns: %TRUE if @type is classed + */ +#define G_TYPE_IS_CLASSED(type) (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED)) +/** + * G_TYPE_IS_INSTANTIATABLE: + * @type: A #GType value + * + * Checks if @type can be instantiated. Instantiation is the + * process of creating an instance (object) of this type. + * + * Returns: %TRUE if @type is instantiatable + */ +#define G_TYPE_IS_INSTANTIATABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE)) +/** + * G_TYPE_IS_DERIVABLE: + * @type: A #GType value + * + * Checks if @type is a derivable type. A derivable type can + * be used as the base class of a flat (single-level) class hierarchy. + * + * Returns: %TRUE if @type is derivable + */ +#define G_TYPE_IS_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DERIVABLE)) +/** + * G_TYPE_IS_DEEP_DERIVABLE: + * @type: A #GType value + * + * Checks if @type is a deep derivable type. A deep derivable type + * can be used as the base class of a deep (multi-level) class hierarchy. + * + * Returns: %TRUE if @type is deep derivable + */ +#define G_TYPE_IS_DEEP_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE)) +/** + * G_TYPE_IS_ABSTRACT: + * @type: A #GType value + * + * Checks if @type is an abstract type. An abstract type cannot be + * instantiated and is normally used as an abstract base class for + * derived classes. + * + * Returns: %TRUE if @type is abstract + */ +#define G_TYPE_IS_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)) +/** + * G_TYPE_IS_VALUE_ABSTRACT: + * @type: A #GType value + * + * Checks if @type is an abstract value type. An abstract value type introduces + * a value table, but can't be used for g_value_init() and is normally used as + * an abstract base type for derived value types. + * + * Returns: %TRUE if @type is an abstract value type + */ +#define G_TYPE_IS_VALUE_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT)) +/** + * G_TYPE_IS_VALUE_TYPE: + * @type: A #GType value + * + * Checks if @type is a value type and can be used with g_value_init(). + * + * Returns: %TRUE if @type is a value type + */ +#define G_TYPE_IS_VALUE_TYPE(type) (g_type_check_is_value_type (type)) +/** + * G_TYPE_HAS_VALUE_TABLE: + * @type: A #GType value + * + * Checks if @type has a #GTypeValueTable. + * + * Returns: %TRUE if @type has a value table + */ +#define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL) +/** + * G_TYPE_IS_FINAL: + * @type: a #GType value + * + * Checks if @type is a final type. A final type cannot be derived any + * further. + * + * Returns: %TRUE if @type is final + * + * Since: 2.70 + */ +#define G_TYPE_IS_FINAL(type) (g_type_test_flags ((type), G_TYPE_FLAG_FINAL)) GOBJECT_AVAILABLE_MACRO_IN_2_70 + +/** + * G_TYPE_IS_DEPRECATED: + * @type: a #GType value + * + * Checks if @type is deprecated. Instantiating a deprecated type will + * trigger a warning if running with `G_ENABLE_DIAGNOSTIC=1`. + * + * Returns: %TRUE if the type is deprecated + * + * Since: 2.76 + */ +#define G_TYPE_IS_DEPRECATED(type) (g_type_test_flags ((type), G_TYPE_FLAG_DEPRECATED)) GOBJECT_AVAILABLE_MACRO_IN_2_76 + + +/* Typedefs + */ +/** + * GType: + * + * A numerical value which represents the unique identifier of a registered + * type. + */ +#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_SIZE_T +typedef guintptr GType; +#elif GLIB_SIZEOF_SIZE_T != GLIB_SIZEOF_LONG || !defined (G_CXX_STD_VERSION) +typedef gsize GType; +#else /* for historic reasons, C++ on non-Morello/CHERI systems links against gulong GTypes */ +typedef gulong GType; +#endif +typedef struct _GValue GValue; +typedef union _GTypeCValue GTypeCValue; +typedef struct _GTypePlugin GTypePlugin; +typedef struct _GTypeClass GTypeClass; +typedef struct _GTypeInterface GTypeInterface; +typedef struct _GTypeInstance GTypeInstance; +typedef struct _GTypeInfo GTypeInfo; +typedef struct _GTypeFundamentalInfo GTypeFundamentalInfo; +typedef struct _GInterfaceInfo GInterfaceInfo; +typedef struct _GTypeValueTable GTypeValueTable; +typedef struct _GTypeQuery GTypeQuery; + + +/* Basic Type Structures + */ +/** + * GTypeClass: + * + * An opaque structure used as the base of all classes. + */ +struct _GTypeClass +{ + /*< private >*/ + GType g_type; +}; +/** + * GTypeInstance: + * + * An opaque structure used as the base of all type instances. + */ +struct _GTypeInstance +{ + /*< private >*/ + GTypeClass *g_class; +}; +/** + * GTypeInterface: + * + * An opaque structure used as the base of all interface types. + */ +struct _GTypeInterface +{ + /*< private >*/ + GType g_type; /* iface type */ + GType g_instance_type; +}; +/** + * GTypeQuery: + * @type: the #GType value of the type + * @type_name: the name of the type + * @class_size: the size of the class structure + * @instance_size: the size of the instance structure + * + * A structure holding information for a specific type. + * + * See also: g_type_query() + */ +struct _GTypeQuery +{ + GType type; + const gchar *type_name; + guint class_size; + guint instance_size; +}; + + +/* Casts, checks and accessors for structured types + * usage of these macros is reserved to type implementations only + */ +/*< protected >*/ +/** + * G_TYPE_CHECK_INSTANCE: + * @instance: Location of a #GTypeInstance structure + * + * Checks if @instance is a valid #GTypeInstance structure, + * otherwise issues a warning and returns %FALSE. %NULL is not a valid + * #GTypeInstance. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE if @instance is valid + */ +#define G_TYPE_CHECK_INSTANCE(instance) (_G_TYPE_CHI ((GTypeInstance*) (instance))) +/** + * G_TYPE_CHECK_INSTANCE_CAST: + * @instance: (nullable): Location of a #GTypeInstance structure + * @g_type: The type to be returned + * @c_type: The corresponding C type of @g_type + * + * Checks that @instance is an instance of the type identified by @g_type + * and issues a warning if this is not the case. Returns @instance casted + * to a pointer to @c_type. + * + * No warning will be issued if @instance is %NULL, and %NULL will be returned. + * + * This macro should only be used in type implementations. + */ +#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) +/** + * G_TYPE_CHECK_INSTANCE_TYPE: + * @instance: (nullable): Location of a #GTypeInstance structure. + * @g_type: The type to be checked + * + * Checks if @instance is an instance of the type identified by @g_type. If + * @instance is %NULL, %FALSE will be returned. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE if @instance is an instance of @g_type + */ +#define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type))) +/** + * G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE: + * @instance: (nullable): Location of a #GTypeInstance structure. + * @g_type: The fundamental type to be checked + * + * Checks if @instance is an instance of the fundamental type identified by @g_type. + * If @instance is %NULL, %FALSE will be returned. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE if @instance is an instance of @g_type + */ +#define G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE(instance, g_type) (_G_TYPE_CIFT ((instance), (g_type))) +/** + * G_TYPE_INSTANCE_GET_CLASS: + * @instance: Location of the #GTypeInstance structure + * @g_type: The #GType of the class to be returned + * @c_type: The C type of the class structure + * + * Get the class structure of a given @instance, casted + * to a specified ancestor type @g_type of the instance. + * + * Note that while calling a GInstanceInitFunc(), the class pointer + * gets modified, so it might not always return the expected pointer. + * + * This macro should only be used in type implementations. + * + * Returns: a pointer to the class structure + */ +#define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type) (_G_TYPE_IGC ((instance), (g_type), c_type)) +/** + * G_TYPE_INSTANCE_GET_INTERFACE: + * @instance: Location of the #GTypeInstance structure + * @g_type: The #GType of the interface to be returned + * @c_type: The C type of the interface structure + * + * Get the interface structure for interface @g_type of a given @instance. + * + * This macro should only be used in type implementations. + * + * Returns: a pointer to the interface structure + */ +#define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type)) +/** + * G_TYPE_CHECK_CLASS_CAST: + * @g_class: Location of a #GTypeClass structure + * @g_type: The type to be returned + * @c_type: The corresponding C type of class structure of @g_type + * + * Checks that @g_class is a class structure of the type identified by @g_type + * and issues a warning if this is not the case. Returns @g_class casted + * to a pointer to @c_type. %NULL is not a valid class structure. + * + * This macro should only be used in type implementations. + */ +#define G_TYPE_CHECK_CLASS_CAST(g_class, g_type, c_type) (_G_TYPE_CCC ((g_class), (g_type), c_type)) +/** + * G_TYPE_CHECK_CLASS_TYPE: + * @g_class: (nullable): Location of a #GTypeClass structure + * @g_type: The type to be checked + * + * Checks if @g_class is a class structure of the type identified by + * @g_type. If @g_class is %NULL, %FALSE will be returned. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE if @g_class is a class structure of @g_type + */ +#define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type) (_G_TYPE_CCT ((g_class), (g_type))) +/** + * G_TYPE_CHECK_VALUE: + * @value: a #GValue + * + * Checks if @value has been initialized to hold values + * of a value type. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE if @value is initialized + */ +#define G_TYPE_CHECK_VALUE(value) (_G_TYPE_CHV ((value))) +/** + * G_TYPE_CHECK_VALUE_TYPE: + * @value: a #GValue + * @g_type: The type to be checked + * + * Checks if @value has been initialized to hold values + * of type @g_type. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE if @value has been initialized to hold values of type @g_type + */ +#define G_TYPE_CHECK_VALUE_TYPE(value, g_type) (_G_TYPE_CVH ((value), (g_type))) +/** + * G_TYPE_FROM_INSTANCE: + * @instance: Location of a valid #GTypeInstance structure + * + * Get the type identifier from a given @instance structure. + * + * This macro should only be used in type implementations. + * + * Returns: the #GType + */ +#define G_TYPE_FROM_INSTANCE(instance) (G_TYPE_FROM_CLASS (((GTypeInstance*) (instance))->g_class)) +/** + * G_TYPE_FROM_CLASS: + * @g_class: Location of a valid #GTypeClass structure + * + * Get the type identifier from a given @class structure. + * + * This macro should only be used in type implementations. + * + * Returns: the #GType + */ +#define G_TYPE_FROM_CLASS(g_class) (((GTypeClass*) (g_class))->g_type) +/** + * G_TYPE_FROM_INTERFACE: + * @g_iface: Location of a valid #GTypeInterface structure + * + * Get the type identifier from a given @interface structure. + * + * This macro should only be used in type implementations. + * + * Returns: the #GType + */ +#define G_TYPE_FROM_INTERFACE(g_iface) (((GTypeInterface*) (g_iface))->g_type) + +/** + * G_TYPE_INSTANCE_GET_PRIVATE: + * @instance: the instance of a type deriving from @private_type + * @g_type: the type identifying which private data to retrieve + * @c_type: The C type for the private structure + * + * Gets the private structure for a particular type. + * + * The private structure must have been registered in the + * class_init function with g_type_class_add_private(). + * + * This macro should only be used in type implementations. + * + * Since: 2.4 + * Deprecated: 2.58: Use G_ADD_PRIVATE() and the generated + * `your_type_get_instance_private()` function instead + * Returns: (not nullable): a pointer to the private data structure + */ +#define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type) ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type))) GOBJECT_DEPRECATED_MACRO_IN_2_58_FOR(G_ADD_PRIVATE) + +/** + * G_TYPE_CLASS_GET_PRIVATE: + * @klass: the class of a type deriving from @private_type + * @g_type: the type identifying which private data to retrieve + * @c_type: The C type for the private structure + * + * Gets the private class structure for a particular type. + * + * The private structure must have been registered in the + * get_type() function with g_type_add_class_private(). + * + * This macro should only be used in type implementations. + * + * Since: 2.24 + * Returns: (not nullable): a pointer to the private data structure + */ +#define G_TYPE_CLASS_GET_PRIVATE(klass, g_type, c_type) ((c_type*) g_type_class_get_private ((GTypeClass*) (klass), (g_type))) + +/** + * GTypeDebugFlags: + * @G_TYPE_DEBUG_NONE: Print no messages + * @G_TYPE_DEBUG_OBJECTS: Print messages about object bookkeeping + * @G_TYPE_DEBUG_SIGNALS: Print messages about signal emissions + * @G_TYPE_DEBUG_MASK: Mask covering all debug flags + * @G_TYPE_DEBUG_INSTANCE_COUNT: Keep a count of instances of each type + * + * These flags used to be passed to g_type_init_with_debug_flags() which + * is now deprecated. + * + * If you need to enable debugging features, use the `GOBJECT_DEBUG` + * environment variable. + * + * Deprecated: 2.36: g_type_init() is now done automatically + */ +typedef enum /*< skip >*/ +{ + G_TYPE_DEBUG_NONE = 0, + G_TYPE_DEBUG_OBJECTS = 1 << 0, + G_TYPE_DEBUG_SIGNALS = 1 << 1, + G_TYPE_DEBUG_INSTANCE_COUNT = 1 << 2, + G_TYPE_DEBUG_MASK = 0x07 +} GTypeDebugFlags GOBJECT_DEPRECATED_TYPE_IN_2_36; + + +/* --- prototypes --- */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GOBJECT_DEPRECATED_IN_2_36 +void g_type_init (void); +GOBJECT_DEPRECATED_IN_2_36 +void g_type_init_with_debug_flags (GTypeDebugFlags debug_flags); +G_GNUC_END_IGNORE_DEPRECATIONS + +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_type_name (GType type); +GOBJECT_AVAILABLE_IN_ALL +GQuark g_type_qname (GType type); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_from_name (const gchar *name); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_parent (GType type); +GOBJECT_AVAILABLE_IN_ALL +guint g_type_depth (GType type); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_next_base (GType leaf_type, + GType root_type); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_is_a (GType type, + GType is_a_type); + +/* Hoist exact GType comparisons into the caller */ +#define g_type_is_a(a,b) ((a) == (b) || (g_type_is_a) ((a), (b))) + +GOBJECT_AVAILABLE_IN_2_84 +gpointer g_type_class_get (GType type); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_class_ref (GType type); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_class_peek (GType type); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_class_peek_static (GType type); +GOBJECT_AVAILABLE_IN_ALL +void g_type_class_unref (gpointer g_class); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_class_peek_parent (gpointer g_class); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_interface_peek (gpointer instance_class, + GType iface_type); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_interface_peek_parent (gpointer g_iface); + +GOBJECT_AVAILABLE_IN_2_84 +gpointer g_type_default_interface_get (GType g_type); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_default_interface_ref (GType g_type); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_default_interface_peek (GType g_type); +GOBJECT_AVAILABLE_IN_ALL +void g_type_default_interface_unref (gpointer g_iface); + +/* g_free() the returned arrays */ +GOBJECT_AVAILABLE_IN_ALL +GType* g_type_children (GType type, + guint *n_children); +GOBJECT_AVAILABLE_IN_ALL +GType* g_type_interfaces (GType type, + guint *n_interfaces); + +/* per-type _static_ data */ +GOBJECT_AVAILABLE_IN_ALL +void g_type_set_qdata (GType type, + GQuark quark, + gpointer data); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_get_qdata (GType type, + GQuark quark); +GOBJECT_AVAILABLE_IN_ALL +void g_type_query (GType type, + GTypeQuery *query); + +GOBJECT_AVAILABLE_IN_2_44 +int g_type_get_instance_count (GType type); + +/* --- type registration --- */ +/** + * GBaseInitFunc: + * @g_class: (type GObject.TypeClass): The #GTypeClass structure to initialize + * + * A callback function used by the type system to do base initialization + * of the class structures of derived types. + * + * This function is called as part of the initialization process of all derived + * classes and should reallocate or reset all dynamic class members copied over + * from the parent class. + * + * For example, class members (such as strings) that are not sufficiently + * handled by a plain memory copy of the parent class into the derived class + * have to be altered. See GClassInitFunc() for a discussion of the class + * initialization process. + */ +typedef void (*GBaseInitFunc) (gpointer g_class); +/** + * GBaseFinalizeFunc: + * @g_class: (type GObject.TypeClass): The #GTypeClass structure to finalize + * + * A callback function used by the type system to finalize those portions + * of a derived types class structure that were setup from the corresponding + * GBaseInitFunc() function. + * + * Class finalization basically works the inverse way in which class + * initialization is performed. + * + * See GClassInitFunc() for a discussion of the class initialization process. + */ +typedef void (*GBaseFinalizeFunc) (gpointer g_class); +/** + * GClassInitFunc: + * @g_class: (type GObject.TypeClass): The #GTypeClass structure to initialize. + * @class_data: The @class_data member supplied via the #GTypeInfo structure. + * + * A callback function used by the type system to initialize the class + * of a specific type. + * + * This function should initialize all static class members. + * + * The initialization process of a class involves: + * + * - Copying common members from the parent class over to the + * derived class structure. + * - Zero initialization of the remaining members not copied + * over from the parent class. + * - Invocation of the GBaseInitFunc() initializers of all parent + * types and the class' type. + * - Invocation of the class' GClassInitFunc() initializer. + * + * Since derived classes are partially initialized through a memory copy + * of the parent class, the general rule is that GBaseInitFunc() and + * GBaseFinalizeFunc() should take care of necessary reinitialization + * and release of those class members that were introduced by the type + * that specified these GBaseInitFunc()/GBaseFinalizeFunc(). + * GClassInitFunc() should only care about initializing static + * class members, while dynamic class members (such as allocated strings + * or reference counted resources) are better handled by a GBaseInitFunc() + * for this type, so proper initialization of the dynamic class members + * is performed for class initialization of derived types as well. + * + * An example may help to correspond the intend of the different class + * initializers: + * + * |[ + * typedef struct { + * GObjectClass parent_class; + * gint static_integer; + * gchar *dynamic_string; + * } TypeAClass; + * static void + * type_a_base_class_init (TypeAClass *class) + * { + * class->dynamic_string = g_strdup ("some string"); + * } + * static void + * type_a_base_class_finalize (TypeAClass *class) + * { + * g_free (class->dynamic_string); + * } + * static void + * type_a_class_init (TypeAClass *class) + * { + * class->static_integer = 42; + * } + * + * typedef struct { + * TypeAClass parent_class; + * gfloat static_float; + * GString *dynamic_gstring; + * } TypeBClass; + * static void + * type_b_base_class_init (TypeBClass *class) + * { + * class->dynamic_gstring = g_string_new ("some other string"); + * } + * static void + * type_b_base_class_finalize (TypeBClass *class) + * { + * g_string_free (class->dynamic_gstring); + * } + * static void + * type_b_class_init (TypeBClass *class) + * { + * class->static_float = 3.14159265358979323846; + * } + * ]| + * + * Initialization of TypeBClass will first cause initialization of + * TypeAClass (derived classes reference their parent classes, see + * g_type_class_ref() on this). + * + * Initialization of TypeAClass roughly involves zero-initializing its fields, + * then calling its GBaseInitFunc() type_a_base_class_init() to allocate + * its dynamic members (dynamic_string), and finally calling its GClassInitFunc() + * type_a_class_init() to initialize its static members (static_integer). + * The first step in the initialization process of TypeBClass is then + * a plain memory copy of the contents of TypeAClass into TypeBClass and + * zero-initialization of the remaining fields in TypeBClass. + * The dynamic members of TypeAClass within TypeBClass now need + * reinitialization which is performed by calling type_a_base_class_init() + * with an argument of TypeBClass. + * + * After that, the GBaseInitFunc() of TypeBClass, type_b_base_class_init() + * is called to allocate the dynamic members of TypeBClass (dynamic_gstring), + * and finally the GClassInitFunc() of TypeBClass, type_b_class_init(), + * is called to complete the initialization process with the static members + * (static_float). + * + * Corresponding finalization counter parts to the GBaseInitFunc() functions + * have to be provided to release allocated resources at class finalization + * time. + */ +typedef void (*GClassInitFunc) (gpointer g_class, + gpointer class_data); +/** + * GClassFinalizeFunc: + * @g_class: (type GObject.TypeClass): The #GTypeClass structure to finalize + * @class_data: The @class_data member supplied via the #GTypeInfo structure + * + * A callback function used by the type system to finalize a class. + * + * This function is rarely needed, as dynamically allocated class resources + * should be handled by GBaseInitFunc() and GBaseFinalizeFunc(). + * + * Also, specification of a GClassFinalizeFunc() in the #GTypeInfo + * structure of a static type is invalid, because classes of static types + * will never be finalized (they are artificially kept alive when their + * reference count drops to zero). + */ +typedef void (*GClassFinalizeFunc) (gpointer g_class, + gpointer class_data); +/** + * GInstanceInitFunc: + * @instance: The instance to initialize + * @g_class: (type GObject.TypeClass): The class of the type the instance is + * created for + * + * A callback function used by the type system to initialize a new + * instance of a type. + * + * This function initializes all instance members and allocates any resources + * required by it. + * + * Initialization of a derived instance involves calling all its parent + * types instance initializers, so the class member of the instance + * is altered during its initialization to always point to the class that + * belongs to the type the current initializer was introduced for. + * + * The extended members of @instance are guaranteed to have been filled with + * zeros before this function is called. + */ +typedef void (*GInstanceInitFunc) (GTypeInstance *instance, + gpointer g_class); +/** + * GInterfaceInitFunc: + * @g_iface: (type GObject.TypeInterface): The interface structure to initialize + * @iface_data: The @interface_data supplied via the #GInterfaceInfo structure + * + * A callback function used by the type system to initialize a new + * interface. + * + * This function should initialize all internal data and* allocate any + * resources required by the interface. + * + * The members of @iface_data are guaranteed to have been filled with + * zeros before this function is called. + */ +typedef void (*GInterfaceInitFunc) (gpointer g_iface, + gpointer iface_data); +/** + * GInterfaceFinalizeFunc: + * @g_iface: (type GObject.TypeInterface): The interface structure to finalize + * @iface_data: The @interface_data supplied via the #GInterfaceInfo structure + * + * A callback function used by the type system to finalize an interface. + * + * This function should destroy any internal data and release any resources + * allocated by the corresponding GInterfaceInitFunc() function. + */ +typedef void (*GInterfaceFinalizeFunc) (gpointer g_iface, + gpointer iface_data); +/** + * GTypeClassCacheFunc: + * @cache_data: data that was given to the g_type_add_class_cache_func() call + * @g_class: (type GObject.TypeClass): The #GTypeClass structure which is + * unreferenced + * + * A callback function which is called when the reference count of a class + * drops to zero. + * + * It may use g_type_class_ref() to prevent the class from being freed. You + * should not call g_type_class_unref() from a #GTypeClassCacheFunc function + * to prevent infinite recursion, use g_type_class_unref_uncached() instead. + * + * The functions have to check the class id passed in to figure + * whether they actually want to cache the class of this type, since all + * classes are routed through the same #GTypeClassCacheFunc chain. + * + * Returns: %TRUE to stop further #GTypeClassCacheFuncs from being + * called, %FALSE to continue + */ +typedef gboolean (*GTypeClassCacheFunc) (gpointer cache_data, + GTypeClass *g_class); +/** + * GTypeInterfaceCheckFunc: + * @check_data: data passed to g_type_add_interface_check() + * @g_iface: (type GObject.TypeInterface): the interface that has been + * initialized + * + * A callback called after an interface vtable is initialized. + * + * See g_type_add_interface_check(). + * + * Since: 2.4 + */ +typedef void (*GTypeInterfaceCheckFunc) (gpointer check_data, + gpointer g_iface); +/** + * GTypeFundamentalFlags: + * @G_TYPE_FLAG_CLASSED: Indicates a classed type + * @G_TYPE_FLAG_INSTANTIATABLE: Indicates an instantiatable type (implies classed) + * @G_TYPE_FLAG_DERIVABLE: Indicates a flat derivable type + * @G_TYPE_FLAG_DEEP_DERIVABLE: Indicates a deep derivable type (implies derivable) + * + * Bit masks used to check or determine specific characteristics of a + * fundamental type. + */ +typedef enum /*< skip >*/ +{ + /* There is no G_TYPE_FUNDAMENTAL_FLAGS_NONE: this is implemented to use + * the same bits as GTypeFlags */ + G_TYPE_FLAG_CLASSED = (1 << 0), + G_TYPE_FLAG_INSTANTIATABLE = (1 << 1), + G_TYPE_FLAG_DERIVABLE = (1 << 2), + G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3) +} GTypeFundamentalFlags; +/** + * GTypeFlags: + * @G_TYPE_FLAG_NONE: No special flags. Since: 2.74 + * @G_TYPE_FLAG_ABSTRACT: Indicates an abstract type. No instances can be + * created for an abstract type + * @G_TYPE_FLAG_VALUE_ABSTRACT: Indicates an abstract value type, i.e. a type + * that introduces a value table, but can't be used for + * g_value_init() + * @G_TYPE_FLAG_FINAL: Indicates a final type. A final type is a non-derivable + * leaf node in a deep derivable type hierarchy tree. Since: 2.70 + * @G_TYPE_FLAG_DEPRECATED: The type is deprecated and may be removed in a + * future version. A warning will be emitted if it is instantiated while + * running with `G_ENABLE_DIAGNOSTIC=1`. Since 2.76 + * + * Bit masks used to check or determine characteristics of a type. + */ +typedef enum /*< skip >*/ +{ + G_TYPE_FLAG_NONE GOBJECT_AVAILABLE_ENUMERATOR_IN_2_74 = 0, + G_TYPE_FLAG_ABSTRACT = (1 << 4), + G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5), + G_TYPE_FLAG_FINAL GOBJECT_AVAILABLE_ENUMERATOR_IN_2_70 = (1 << 6), + G_TYPE_FLAG_DEPRECATED GOBJECT_AVAILABLE_ENUMERATOR_IN_2_76 = (1 << 7) +} GTypeFlags; +/** + * GTypeInfo: + * @class_size: Size of the class structure (required for interface, classed and instantiatable types) + * @base_init: Location of the base initialization function (optional) + * @base_finalize: Location of the base finalization function (optional) + * @class_init: Location of the class initialization function for + * classed and instantiatable types. Location of the default vtable + * initialization function for interface types. (optional) This function + * is used both to fill in virtual functions in the class or default vtable, + * and to do type-specific setup such as registering signals and object + * properties. + * @class_finalize: Location of the class finalization function for + * classed and instantiatable types. Location of the default vtable + * finalization function for interface types. (optional) + * @class_data: User-supplied data passed to the class init/finalize functions + * @instance_size: Size of the instance (object) structure (required for instantiatable types only) + * @n_preallocs: Prior to GLib 2.10, it specified the number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching). Since GLib 2.10 this field is ignored. + * @instance_init: Location of the instance initialization function (optional, for instantiatable types only) + * @value_table: A #GTypeValueTable function table for generic handling of GValues + * of this type (usually only useful for fundamental types) + * + * This structure is used to provide the type system with the information + * required to initialize and destruct (finalize) a type's class and + * its instances. + * + * The initialized structure is passed to the g_type_register_static() function + * (or is copied into the provided #GTypeInfo structure in the + * g_type_plugin_complete_type_info()). The type system will perform a deep + * copy of this structure, so its memory does not need to be persistent + * across invocation of g_type_register_static(). + */ +struct _GTypeInfo +{ + /* interface types, classed types, instantiated types */ + guint16 class_size; + + GBaseInitFunc base_init; + GBaseFinalizeFunc base_finalize; + + /* interface types, classed types, instantiated types */ + GClassInitFunc class_init; + GClassFinalizeFunc class_finalize; + gconstpointer class_data; + + /* instantiated types */ + guint16 instance_size; + guint16 n_preallocs; + GInstanceInitFunc instance_init; + + /* value handling */ + const GTypeValueTable *value_table; +}; +/** + * GTypeFundamentalInfo: + * @type_flags: #GTypeFundamentalFlags describing the characteristics of the fundamental type + * + * A structure that provides information to the type system which is + * used specifically for managing fundamental types. + */ +struct _GTypeFundamentalInfo +{ + GTypeFundamentalFlags type_flags; +}; +/** + * GInterfaceInfo: + * @interface_init: location of the interface initialization function + * @interface_finalize: location of the interface finalization function + * @interface_data: user-supplied data passed to the interface init/finalize functions + * + * A structure that provides information to the type system which is + * used specifically for managing interface types. + */ +struct _GInterfaceInfo +{ + GInterfaceInitFunc interface_init; + GInterfaceFinalizeFunc interface_finalize; + gpointer interface_data; +}; + +/** + * GTypeValueInitFunc: + * @value: the value to initialize + * + * Initializes the value contents by setting the fields of the `value->data` + * array. + * + * The data array of the #GValue passed into this function was zero-filled + * with `memset()`, so no care has to be taken to free any old contents. + * For example, in the case of a string value that may never be %NULL, the + * implementation might look like: + * + * |[ + * value->data[0].v_pointer = g_strdup (""); + * ]| + * + * Since: 2.78 + */ +GOBJECT_AVAILABLE_TYPE_IN_2_78 +typedef void (* GTypeValueInitFunc) (GValue *value); + +/** + * GTypeValueFreeFunc: + * @value: the value to free + * + * Frees any old contents that might be left in the `value->data` array of + * the given value. + * + * No resources may remain allocated through the #GValue contents after this + * function returns. E.g. for our above string type: + * + * |[ + * // only free strings without a specific flag for static storage + * if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)) + * g_free (value->data[0].v_pointer); + * ]| + * + * Since: 2.78 + */ +GOBJECT_AVAILABLE_TYPE_IN_2_78 +typedef void (* GTypeValueFreeFunc) (GValue *value); + +/** + * GTypeValueCopyFunc: + * @src_value: the value to copy + * @dest_value: (out): the location of the copy + * + * Copies the content of a #GValue into another. + * + * The @dest_value is a #GValue with zero-filled data section and @src_value + * is a properly initialized #GValue of same type, or derived type. + * + * The purpose of this function is to copy the contents of @src_value + * into @dest_value in a way, that even after @src_value has been freed, the + * contents of @dest_value remain valid. String type example: + * + * |[ + * dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer); + * ]| + * + * Since: 2.78 + */ +GOBJECT_AVAILABLE_TYPE_IN_2_78 +typedef void (* GTypeValueCopyFunc) (const GValue *src_value, + GValue *dest_value); + +/** + * GTypeValuePeekPointerFunc: + * @value: the value to peek + * + * If the value contents fit into a pointer, such as objects or strings, + * return this pointer, so the caller can peek at the current contents. + * + * To extend on our above string example: + * + * |[ + * return value->data[0].v_pointer; + * ]| + * + * Returns: (transfer none): a pointer to the value contents + * + * Since: 2.78 + */ +GOBJECT_AVAILABLE_TYPE_IN_2_78 +typedef gpointer (* GTypeValuePeekPointerFunc) (const GValue *value); + +/** + * GTypeValueCollectFunc: + * @value: the value to initialize + * @n_collect_values: the number of collected values + * @collect_values: (array length=n_collect_values): the collected values + * @collect_flags: optional flags + * + * This function is responsible for converting the values collected from + * a variadic argument list into contents suitable for storage in a #GValue. + * + * This function should setup @value similar to #GTypeValueInitFunc; e.g. + * for a string value that does not allow `NULL` pointers, it needs to either + * emit an error, or do an implicit conversion by storing an empty string. + * + * The @value passed in to this function has a zero-filled data array, so + * just like for #GTypeValueInitFunc it is guaranteed to not contain any old + * contents that might need freeing. + * + * The @n_collect_values argument is the string length of the `collect_format` + * field of #GTypeValueTable, and `collect_values` is an array of #GTypeCValue + * with length of @n_collect_values, containing the collected values according + * to `collect_format`. + * + * The @collect_flags argument provided as a hint by the caller. It may + * contain the flag %G_VALUE_NOCOPY_CONTENTS indicating that the collected + * value contents may be considered ‘static’ for the duration of the @value + * lifetime. Thus an extra copy of the contents stored in @collect_values is + * not required for assignment to @value. + * + * For our above string example, we continue with: + * + * |[ + * if (!collect_values[0].v_pointer) + * value->data[0].v_pointer = g_strdup (""); + * else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) + * { + * value->data[0].v_pointer = collect_values[0].v_pointer; + * // keep a flag for the value_free() implementation to not free this string + * value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS; + * } + * else + * value->data[0].v_pointer = g_strdup (collect_values[0].v_pointer); + * return NULL; + * ]| + * + * It should be noted, that it is generally a bad idea to follow the + * %G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to + * reentrancy requirements and reference count assertions performed + * by the signal emission code, reference counts should always be + * incremented for reference counted contents stored in the `value->data` + * array. To deviate from our string example for a moment, and taking + * a look at an exemplary implementation for `GTypeValueTable.collect_value()` + * of `GObject`: + * + * |[ + * GObject *object = G_OBJECT (collect_values[0].v_pointer); + * g_return_val_if_fail (object != NULL, + * g_strdup_printf ("Object %p passed as invalid NULL pointer", object)); + * // never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types + * value->data[0].v_pointer = g_object_ref (object); + * return NULL; + * ]| + * + * The reference count for valid objects is always incremented, regardless + * of `collect_flags`. For invalid objects, the example returns a newly + * allocated string without altering `value`. + * + * Upon success, `collect_value()` needs to return `NULL`. If, however, + * an error condition occurred, `collect_value()` should return a newly + * allocated string containing an error diagnostic. + * + * The calling code makes no assumptions about the `value` contents being + * valid upon error returns, `value` is simply thrown away without further + * freeing. As such, it is a good idea to not allocate `GValue` contents + * prior to returning an error; however, `collect_values()` is not obliged + * to return a correctly setup @value for error returns, simply because + * any non-`NULL` return is considered a fatal programming error, and + * further program behaviour is undefined. + * + * Returns: (transfer full) (nullable): `NULL` on success, otherwise a + * newly allocated error string on failure + * + * Since: 2.78 + */ +GOBJECT_AVAILABLE_TYPE_IN_2_78 +typedef gchar * (* GTypeValueCollectFunc) (GValue *value, + guint n_collect_values, + GTypeCValue *collect_values, + guint collect_flags); + +/** + * GTypeValueLCopyFunc: + * @value: the value to lcopy + * @n_collect_values: the number of collected values + * @collect_values: (array length=n_collect_values): the collected + * locations for storage + * @collect_flags: optional flags + * + * This function is responsible for storing the `value` + * contents into arguments passed through a variadic argument list which + * got collected into `collect_values` according to `lcopy_format`. + * + * The `n_collect_values` argument equals the string length of + * `lcopy_format`, and `collect_flags` may contain %G_VALUE_NOCOPY_CONTENTS. + * + * In contrast to #GTypeValueCollectFunc, this function is obliged to always + * properly support %G_VALUE_NOCOPY_CONTENTS. + * + * Similar to #GTypeValueCollectFunc the function may prematurely abort by + * returning a newly allocated string describing an error condition. To + * complete the string example: + * + * |[ + * gchar **string_p = collect_values[0].v_pointer; + * g_return_val_if_fail (string_p != NULL, + * g_strdup ("string location passed as NULL")); + * + * if (collect_flags & G_VALUE_NOCOPY_CONTENTS) + * *string_p = value->data[0].v_pointer; + * else + * *string_p = g_strdup (value->data[0].v_pointer); + * ]| + * + * And an illustrative version of this function for reference-counted + * types: + * + * |[ + * GObject **object_p = collect_values[0].v_pointer; + * g_return_val_if_fail (object_p != NULL, + * g_strdup ("object location passed as NULL")); + * + * if (value->data[0].v_pointer == NULL) + * *object_p = NULL; + * else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) // always honour + * *object_p = value->data[0].v_pointer; + * else + * *object_p = g_object_ref (value->data[0].v_pointer); + * + * return NULL; + * ]| + * + * Returns: (transfer full) (nullable): `NULL` on success, otherwise + * a newly allocated error string on failure + * + * Since: 2.78 + */ +GOBJECT_AVAILABLE_TYPE_IN_2_78 +typedef gchar * (* GTypeValueLCopyFunc) (const GValue *value, + guint n_collect_values, + GTypeCValue *collect_values, + guint collect_flags); + +/** + * GTypeValueTable: + * @value_init: Function to initialize a GValue + * @value_free: Function to free a GValue + * @value_copy: Function to copy a GValue + * @value_peek_pointer: Function to peek the contents of a GValue if they fit + * into a pointer + * @collect_format: A string format describing how to collect the contents of + * this value bit-by-bit. Each character in the format represents + * an argument to be collected, and the characters themselves indicate + * the type of the argument. Currently supported arguments are: + * + * - `'i'`: Integers, passed as `collect_values[].v_int` + * - `'l'`: Longs, passed as `collect_values[].v_long` + * - `'d'`: Doubles, passed as `collect_values[].v_double` + * - `'p'`: Pointers, passed as `collect_values[].v_pointer` + * + * It should be noted that for variable argument list construction, + * ANSI C promotes every type smaller than an integer to an int, and + * floats to doubles. So for collection of short int or char, `'i'` + * needs to be used, and for collection of floats `'d'`. + * @collect_value: Function to initialize a GValue from the values + * collected from variadic arguments + * @lcopy_format: Format description of the arguments to collect for @lcopy_value, + * analogous to @collect_format. Usually, @lcopy_format string consists + * only of `'p'`s to provide lcopy_value() with pointers to storage locations. + * @lcopy_value: Function to store the contents of a value into the + * locations collected from variadic arguments + * + * The #GTypeValueTable provides the functions required by the #GValue + * implementation, to serve as a container for values of a type. + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +struct _GTypeValueTable +{ + GTypeValueInitFunc value_init; + GTypeValueFreeFunc value_free; + GTypeValueCopyFunc value_copy; + GTypeValuePeekPointerFunc value_peek_pointer; + + const gchar *collect_format; + GTypeValueCollectFunc collect_value; + + const gchar *lcopy_format; + GTypeValueLCopyFunc lcopy_value; +}; +G_GNUC_END_IGNORE_DEPRECATIONS + +GOBJECT_AVAILABLE_IN_ALL +GType g_type_register_static (GType parent_type, + const gchar *type_name, + const GTypeInfo *info, + GTypeFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_register_static_simple (GType parent_type, + const gchar *type_name, + guint class_size, + GClassInitFunc class_init, + guint instance_size, + GInstanceInitFunc instance_init, + GTypeFlags flags); + +GOBJECT_AVAILABLE_IN_ALL +GType g_type_register_dynamic (GType parent_type, + const gchar *type_name, + GTypePlugin *plugin, + GTypeFlags flags); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_register_fundamental (GType type_id, + const gchar *type_name, + const GTypeInfo *info, + const GTypeFundamentalInfo *finfo, + GTypeFlags flags); +GOBJECT_AVAILABLE_IN_ALL +void g_type_add_interface_static (GType instance_type, + GType interface_type, + const GInterfaceInfo *info); +GOBJECT_AVAILABLE_IN_ALL +void g_type_add_interface_dynamic (GType instance_type, + GType interface_type, + GTypePlugin *plugin); +GOBJECT_AVAILABLE_IN_ALL +void g_type_interface_add_prerequisite (GType interface_type, + GType prerequisite_type); +GOBJECT_AVAILABLE_IN_ALL +GType*g_type_interface_prerequisites (GType interface_type, + guint *n_prerequisites); +GOBJECT_AVAILABLE_IN_2_68 +GType g_type_interface_instantiatable_prerequisite + (GType interface_type); +GOBJECT_DEPRECATED_IN_2_58 +void g_type_class_add_private (gpointer g_class, + gsize private_size); +GOBJECT_AVAILABLE_IN_2_38 +gint g_type_add_instance_private (GType class_type, + gsize private_size); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_instance_get_private (GTypeInstance *instance, + GType private_type); +GOBJECT_AVAILABLE_IN_2_38 +void g_type_class_adjust_private_offset (gpointer g_class, + gint *private_size_or_offset); + +GOBJECT_AVAILABLE_IN_ALL +void g_type_add_class_private (GType class_type, + gsize private_size); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_type_class_get_private (GTypeClass *klass, + GType private_type); +GOBJECT_AVAILABLE_IN_2_38 +gint g_type_class_get_instance_private_offset (gpointer g_class); + +GOBJECT_AVAILABLE_IN_2_34 +void g_type_ensure (GType type); +GOBJECT_AVAILABLE_IN_2_36 +guint g_type_get_type_registration_serial (void); + + +/* --- GType boilerplate --- */ +/** + * G_DECLARE_FINAL_TYPE: + * @ModuleObjName: The name of the new type, in camel case (like `GtkWidget`) + * @module_obj_name: The name of the new type in lowercase, with words + * separated by `_` (like `gtk_widget`) + * @MODULE: The name of the module, in all caps (like `GTK`) + * @OBJ_NAME: The bare name of the type, in all caps (like `WIDGET`) + * @ParentName: the name of the parent type, in camel case (like `GtkWidget`) + * + * A convenience macro for emitting the usual declarations in the header file + * for a type which is not (at the present time) intended to be subclassed. + * + * You might use it in a header as follows: + * + * |[ + * #ifndef _myapp_window_h_ + * #define _myapp_window_h_ + * + * #include + * + * #define MY_APP_TYPE_WINDOW my_app_window_get_type () + * G_DECLARE_FINAL_TYPE (MyAppWindow, my_app_window, MY_APP, WINDOW, GtkWindow) + * + * MyAppWindow * my_app_window_new (void); + * + * ... + * + * #endif + * ]| + * + * And use it as follow in your C file: + * + * |[ + * struct _MyAppWindow + * { + * GtkWindow parent; + * ... + * }; + * G_DEFINE_TYPE (MyAppWindow, my_app_window, GTK_TYPE_WINDOW) + * ]| + * + * This results in the following things happening: + * + * - the usual `my_app_window_get_type()` function is declared with a return type of #GType + * + * - the `MyAppWindow` type is defined as a `typedef` of `struct _MyAppWindow`. The struct itself is not + * defined and should be defined from the .c file before G_DEFINE_TYPE() is used. + * + * - the `MY_APP_WINDOW()` cast is emitted as `static inline` function along with the `MY_APP_IS_WINDOW()` type + * checking function + * + * - the `MyAppWindowClass` type is defined as a struct containing `GtkWindowClass`. This is done for the + * convenience of the person defining the type and should not be considered to be part of the ABI. In + * particular, without a firm declaration of the instance structure, it is not possible to subclass the type + * and therefore the fact that the size of the class structure is exposed is not a concern and it can be + * freely changed at any point in the future. + * + * - g_autoptr() support being added for your type, based on the type of your parent class + * + * You can only use this function if your parent type also supports g_autoptr(). + * + * Because the type macro (`MY_APP_TYPE_WINDOW` in the above example) is not a callable, you must continue to + * manually define this as a macro for yourself. + * + * The declaration of the `_get_type()` function is the first thing emitted by the macro. This allows this macro + * to be used in the usual way with export control and API versioning macros. + * + * If you want to declare your own class structure, use G_DECLARE_DERIVABLE_TYPE(). + * + * If you are writing a library, it is important to note that it is possible to convert a type from using + * G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you + * should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be + * subclassed. Once a class structure has been exposed it is not possible to change its size or remove or + * reorder items without breaking the API and/or ABI. + * + * Since: 2.44 + **/ +#define G_DECLARE_FINAL_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \ + GType module_obj_name##_get_type (void); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + typedef struct _##ModuleObjName ModuleObjName; \ + typedef struct { ParentName##Class parent_class; } ModuleObjName##Class; \ + \ + _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \ + G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref) \ + \ + G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_DECLARE_DERIVABLE_TYPE: + * @ModuleObjName: The name of the new type, in camel case (like `GtkWidget`) + * @module_obj_name: The name of the new type in lowercase, with words + * separated by `_` (like `gtk_widget`) + * @MODULE: The name of the module, in all caps (like `GTK`) + * @OBJ_NAME: The bare name of the type, in all caps (like `WIDGET`) + * @ParentName: the name of the parent type, in camel case (like `GtkWidget`) + * + * A convenience macro for emitting the usual declarations in the + * header file for a type which is intended to be subclassed. + * + * You might use it in a header as follows: + * + * |[ + * #ifndef _gtk_frobber_h_ + * #define _gtk_frobber_h_ + * + * #define GTK_TYPE_FROBBER gtk_frobber_get_type () + * GDK_AVAILABLE_IN_3_12 + * G_DECLARE_DERIVABLE_TYPE (GtkFrobber, gtk_frobber, GTK, FROBBER, GtkWidget) + * + * struct _GtkFrobberClass + * { + * GtkWidgetClass parent_class; + * + * void (* handle_frob) (GtkFrobber *frobber, + * guint n_frobs); + * + * gpointer padding[12]; + * }; + * + * GtkWidget * gtk_frobber_new (void); + * + * ... + * + * #endif + * ]| + * + * Since the instance structure is public it is often needed to declare a + * private struct as follow in your C file: + * + * |[ + * typedef struct _GtkFrobberPrivate GtkFrobberPrivate; + * struct _GtkFrobberPrivate + * { + * ... + * }; + * G_DEFINE_TYPE_WITH_PRIVATE (GtkFrobber, gtk_frobber, GTK_TYPE_WIDGET) + * ]| + * + * This results in the following things happening: + * + * - the usual `gtk_frobber_get_type()` function is declared with a return type of #GType + * + * - the `GtkFrobber` struct is created with `GtkWidget` as the first and only item. You are expected to use + * a private structure from your .c file to store your instance variables. + * + * - the `GtkFrobberClass` type is defined as a typedef to `struct _GtkFrobberClass`, which is left undefined. + * You should do this from the header file directly after you use the macro. + * + * - the `GTK_FROBBER()` and `GTK_FROBBER_CLASS()` casts are emitted as `static inline` functions along with + * the `GTK_IS_FROBBER()` and `GTK_IS_FROBBER_CLASS()` type checking functions and `GTK_FROBBER_GET_CLASS()` + * function. + * + * - g_autoptr() support being added for your type, based on the type of your parent class + * + * You can only use this function if your parent type also supports g_autoptr(). + * + * Because the type macro (`GTK_TYPE_FROBBER` in the above example) is not a callable, you must continue to + * manually define this as a macro for yourself. + * + * The declaration of the `_get_type()` function is the first thing emitted by the macro. This allows this macro + * to be used in the usual way with export control and API versioning macros. + * + * If you are writing a library, it is important to note that it is possible to convert a type from using + * G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you + * should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be + * subclassed. Once a class structure has been exposed it is not possible to change its size or remove or + * reorder items without breaking the API and/or ABI. If you want to declare your own class structure, use + * G_DECLARE_DERIVABLE_TYPE(). If you want to declare a class without exposing the class or instance + * structures, use G_DECLARE_FINAL_TYPE(). + * + * If you must use G_DECLARE_DERIVABLE_TYPE() you should be sure to include some padding at the bottom of your + * class structure to leave space for the addition of future virtual functions. + * + * Since: 2.44 + **/ +#define G_DECLARE_DERIVABLE_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \ + GType module_obj_name##_get_type (void); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + typedef struct _##ModuleObjName ModuleObjName; \ + typedef struct _##ModuleObjName##Class ModuleObjName##Class; \ + struct _##ModuleObjName { ParentName parent_instance; }; \ + \ + _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \ + G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref) \ + \ + G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ + G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_CLASS (gpointer ptr) { \ + return G_TYPE_CHECK_CLASS_CAST (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME##_CLASS (gpointer ptr) { \ + return G_TYPE_CHECK_CLASS_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_GET_CLASS (gpointer ptr) { \ + return G_TYPE_INSTANCE_GET_CLASS (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \ + G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_DECLARE_INTERFACE: + * @ModuleObjName: The name of the new type, in camel case (like `GtkWidget`) + * @module_obj_name: The name of the new type in lowercase, with words + * separated by `_` (like `gtk_widget`) + * @MODULE: The name of the module, in all caps (like `GTK`) + * @OBJ_NAME: The bare name of the type, in all caps (like `WIDGET`) + * @PrerequisiteName: the name of the prerequisite type, in camel case (like `GtkWidget`) + * + * A convenience macro for emitting the usual declarations in the header file for a #GInterface type. + * + * You might use it in a header as follows: + * + * |[ + * #ifndef _my_model_h_ + * #define _my_model_h_ + * + * #define MY_TYPE_MODEL my_model_get_type () + * GDK_AVAILABLE_IN_3_12 + * G_DECLARE_INTERFACE (MyModel, my_model, MY, MODEL, GObject) + * + * struct _MyModelInterface + * { + * GTypeInterface g_iface; + * + * gpointer (* get_item) (MyModel *model); + * }; + * + * gpointer my_model_get_item (MyModel *model); + * + * ... + * + * #endif + * ]| + * + * And use it as follow in your C file: + * + * |[ + * G_DEFINE_INTERFACE (MyModel, my_model, G_TYPE_OBJECT); + * + * static void + * my_model_default_init (MyModelInterface *iface) + * { + * ... + * } + * ]| + * + * This results in the following things happening: + * + * - the usual `my_model_get_type()` function is declared with a return type of #GType + * + * - the `MyModelInterface` type is defined as a typedef to `struct _MyModelInterface`, + * which is left undefined. You should do this from the header file directly after + * you use the macro. + * + * - the `MY_MODEL()` cast is emitted as `static inline` functions along with + * the `MY_IS_MODEL()` type checking function and `MY_MODEL_GET_IFACE()` function. + * + * - g_autoptr() support being added for your type, based on your prerequisite type. + * + * You can only use this function if your prerequisite type also supports g_autoptr(). + * + * Because the type macro (`MY_TYPE_MODEL` in the above example) is not a callable, you must continue to + * manually define this as a macro for yourself. + * + * The declaration of the `_get_type()` function is the first thing emitted by the macro. This allows this macro + * to be used in the usual way with export control and API versioning macros. + * + * Since: 2.44 + **/ +#define G_DECLARE_INTERFACE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, PrerequisiteName) \ + GType module_obj_name##_get_type (void); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + typedef struct _##ModuleObjName ModuleObjName; \ + typedef struct _##ModuleObjName##Interface ModuleObjName##Interface; \ + \ + _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, PrerequisiteName) \ + \ + G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_UNUSED static inline ModuleObjName##Interface * MODULE##_##OBJ_NAME##_GET_IFACE (gpointer ptr) { \ + return G_TYPE_INSTANCE_GET_INTERFACE (ptr, module_obj_name##_get_type (), ModuleObjName##Interface); } \ + G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_DEFINE_TYPE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by `_`. + * @T_P: The #GType of the parent type. + * + * A convenience macro for type implementations, which declares a class + * initialization function, an instance initialization function (see #GTypeInfo + * for information about these) and a static variable named `t_n_parent_class` + * pointing to the parent class. Furthermore, it defines a `*_get_type()` function. + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.4 + */ +#define G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {}) +/** + * G_DEFINE_TYPE_WITH_CODE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type in lowercase, with words separated by `_`. + * @T_P: The #GType of the parent type. + * @_C_: Custom code that gets inserted in the `*_get_type()` function. + * + * A convenience macro for type implementations. + * + * Similar to G_DEFINE_TYPE(), but allows you to insert custom code into the + * `*_get_type()` function, e.g. interface implementations via G_IMPLEMENT_INTERFACE(). + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.4 + */ +#define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() +/** + * G_DEFINE_TYPE_WITH_PRIVATE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by `_`. + * @T_P: The #GType of the parent type. + * + * A convenience macro for type implementations, which declares a class + * initialization function, an instance initialization function (see #GTypeInfo + * for information about these), a static variable named `t_n_parent_class` + * pointing to the parent class, and adds private instance data to the type. + * + * Furthermore, it defines a `*_get_type()` function. See G_DEFINE_TYPE_EXTENDED() + * for an example. + * + * Note that private structs added with this macros must have a struct + * name of the form `TN ## Private`. + * + * The private instance data can be retrieved using the automatically generated + * getter function `t_n_get_instance_private()`. + * + * See also: G_ADD_PRIVATE() + * + * Since: 2.38 + */ +#define G_DEFINE_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, G_ADD_PRIVATE (TN)) +/** + * G_DEFINE_ABSTRACT_TYPE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by `_`. + * @T_P: The #GType of the parent type. + * + * A convenience macro for type implementations. + * + * Similar to G_DEFINE_TYPE(), but defines an abstract type. + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.4 + */ +#define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {}) +/** + * G_DEFINE_ABSTRACT_TYPE_WITH_CODE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by `_`. + * @T_P: The #GType of the parent type. + * @_C_: Custom code that gets inserted in the `type_name_get_type()` function. + * + * A convenience macro for type implementations. + * + * Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type and + * allows you to insert custom code into the `*_get_type()` function, e.g. + * interface implementations via G_IMPLEMENT_INTERFACE(). + * + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.4 + */ +#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() +/** + * G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by `_`. + * @T_P: The #GType of the parent type. + * + * Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines an abstract type. + * + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.38 + */ +#define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (TN)) +/** + * G_DEFINE_FINAL_TYPE: + * @TN: the name of the new type, in Camel case + * @t_n: the name of the new type, in lower case, with words + * separated by `_` (snake case) + * @T_P: the #GType of the parent type + * + * A convenience macro for type implementations. + * + * Similar to G_DEFINE_TYPE(), but defines a final type. + * + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.70 + */ +#define G_DEFINE_FINAL_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_FINAL, {}) GOBJECT_AVAILABLE_MACRO_IN_2_70 +/** + * G_DEFINE_FINAL_TYPE_WITH_CODE: + * @TN: the name of the new type, in Camel case + * @t_n: the name of the new type, in lower case, with words + * separated by `_` (snake case) + * @T_P: the #GType of the parent type + * @_C_: Custom code that gets inserted in the `type_name_get_type()` function. + * + * A convenience macro for type implementations. + * + * Similar to G_DEFINE_TYPE_WITH_CODE(), but defines a final type and + * allows you to insert custom code into the `*_get_type()` function, e.g. + * interface implementations via G_IMPLEMENT_INTERFACE(). + * + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.70 + */ +#define G_DEFINE_FINAL_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_FINAL) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() GOBJECT_AVAILABLE_MACRO_IN_2_70 +/** + * G_DEFINE_FINAL_TYPE_WITH_PRIVATE: + * @TN: the name of the new type, in Camel case + * @t_n: the name of the new type, in lower case, with words + * separated by `_` (snake case) + * @T_P: the #GType of the parent type + * + * A convenience macro for type implementations. + * + * Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines a final type. + * + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.70 + */ +#define G_DEFINE_FINAL_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_FINAL, G_ADD_PRIVATE (TN)) GOBJECT_AVAILABLE_MACRO_IN_2_70 +/** + * G_DEFINE_TYPE_EXTENDED: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by `_`. + * @T_P: The #GType of the parent type. + * @_f_: #GTypeFlags to pass to g_type_register_static() + * @_C_: Custom code that gets inserted in the `*_get_type()` function. + * + * The most general convenience macro for type implementations, on which + * G_DEFINE_TYPE(), etc are based. + * + * |[ + * G_DEFINE_TYPE_EXTENDED (GtkGadget, + * gtk_gadget, + * GTK_TYPE_WIDGET, + * 0, + * G_ADD_PRIVATE (GtkGadget) + * G_IMPLEMENT_INTERFACE (TYPE_GIZMO, + * gtk_gadget_gizmo_init)); + * ]| + * + * expands to + * + * |[ + * static void gtk_gadget_init (GtkGadget *self); + * static void gtk_gadget_class_init (GtkGadgetClass *klass); + * static gpointer gtk_gadget_parent_class = NULL; + * static gint GtkGadget_private_offset; + * static void gtk_gadget_class_intern_init (gpointer klass) + * { + * gtk_gadget_parent_class = g_type_class_peek_parent (klass); + * if (GtkGadget_private_offset != 0) + * g_type_class_adjust_private_offset (klass, &GtkGadget_private_offset); + * gtk_gadget_class_init ((GtkGadgetClass*) klass); + * } + * static inline gpointer gtk_gadget_get_instance_private (GtkGadget *self) + * { + * return (G_STRUCT_MEMBER_P (self, GtkGadget_private_offset)); + * } + * + * GType + * gtk_gadget_get_type (void) + * { + * static GType static_g_define_type_id = 0; + * if (g_once_init_enter_pointer (&static_g_define_type_id)) + * { + * GType g_define_type_id = + * g_type_register_static_simple (GTK_TYPE_WIDGET, + * g_intern_static_string ("GtkGadget"), + * sizeof (GtkGadgetClass), + * (GClassInitFunc) gtk_gadget_class_intern_init, + * sizeof (GtkGadget), + * (GInstanceInitFunc) gtk_gadget_init, + * 0); + * { + * GtkGadget_private_offset = + * g_type_add_instance_private (g_define_type_id, sizeof (GtkGadgetPrivate)); + * } + * { + * const GInterfaceInfo g_implement_interface_info = { + * (GInterfaceInitFunc) gtk_gadget_gizmo_init + * }; + * g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); + * } + * g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id); + * } + * return static_g_define_type_id; + * } + * ]| + * + * The only pieces which have to be manually provided are the definitions of + * the instance and class structure and the definitions of the instance and + * class init functions. + * + * Since: 2.4 + */ +#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() + +/** + * G_DEFINE_INTERFACE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words separated by `_`. + * @T_P: The #GType of the prerequisite type for the interface, or %G_TYPE_INVALID + * for no prerequisite type. + * + * A convenience macro for #GTypeInterface definitions, which declares + * a default vtable initialization function and defines a `*_get_type()` + * function. + * + * The macro expects the interface initialization function to have the + * name `t_n ## _default_init`, and the interface structure to have the + * name `TN ## Interface`. + * + * The initialization function has signature + * `static void t_n ## _default_init (TypeName##Interface *klass);`, rather than + * the full #GInterfaceInitFunc signature, for brevity and convenience. If you + * need to use an initialization function with an `iface_data` argument, you + * must write the #GTypeInterface definitions manually. + * + * Since: 2.24 + */ +#define G_DEFINE_INTERFACE(TN, t_n, T_P) G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;) + +/** + * G_DEFINE_INTERFACE_WITH_CODE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words separated by `_`. + * @T_P: The #GType of the prerequisite type for the interface, or %G_TYPE_INVALID + * for no prerequisite type. + * @_C_: Custom code that gets inserted in the `*_get_type()` function. + * + * A convenience macro for #GTypeInterface definitions. + * + * Similar to G_DEFINE_INTERFACE(), but allows you to insert custom code + * into the `*_get_type()` function, e.g. additional interface implementations + * via G_IMPLEMENT_INTERFACE(), or additional prerequisite types. + * + * See G_DEFINE_TYPE_EXTENDED() for a similar example using + * G_DEFINE_TYPE_WITH_CODE(). + * + * Since: 2.24 + */ +#define G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TN, t_n, T_P) {_C_;} _G_DEFINE_INTERFACE_EXTENDED_END() + +/** + * G_IMPLEMENT_INTERFACE: + * @TYPE_IFACE: The #GType of the interface to add + * @iface_init: (type GInterfaceInitFunc): The interface init function, of type #GInterfaceInitFunc + * + * A convenience macro to ease interface addition in the `_C_` section + * of G_DEFINE_TYPE_WITH_CODE() or G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Note that this macro can only be used together with the `G_DEFINE_TYPE_*` + * macros, since it depends on variable names from those macros. + * + * Since: 2.4 + */ +#define G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) { \ + const GInterfaceInfo g_implement_interface_info = { \ + (GInterfaceInitFunc)(void (*)(void)) iface_init, NULL, NULL \ + }; \ + g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \ +} + +/** + * G_ADD_PRIVATE: + * @TypeName: the name of the type in CamelCase + * + * A convenience macro to ease adding private data to instances of a new type + * in the @_C_ section of G_DEFINE_TYPE_WITH_CODE() or + * G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). + * + * For instance: + * + * |[ + * typedef struct _MyObject MyObject; + * typedef struct _MyObjectClass MyObjectClass; + * + * typedef struct { + * gint foo; + * gint bar; + * } MyObjectPrivate; + * + * G_DEFINE_TYPE_WITH_CODE (MyObject, my_object, G_TYPE_OBJECT, + * G_ADD_PRIVATE (MyObject)) + * ]| + * + * Will add `MyObjectPrivate` as the private data to any instance of the + * `MyObject` type. + * + * `G_DEFINE_TYPE_*` macros will automatically create a private function + * based on the arguments to this macro, which can be used to safely + * retrieve the private data from an instance of the type; for instance: + * + * |[ + * gint + * my_object_get_foo (MyObject *obj) + * { + * MyObjectPrivate *priv = my_object_get_instance_private (obj); + * + * g_return_val_if_fail (MY_IS_OBJECT (obj), 0); + * + * return priv->foo; + * } + * + * void + * my_object_set_bar (MyObject *obj, + * gint bar) + * { + * MyObjectPrivate *priv = my_object_get_instance_private (obj); + * + * g_return_if_fail (MY_IS_OBJECT (obj)); + * + * if (priv->bar != bar) + * priv->bar = bar; + * } + * ]| + * + * Since GLib 2.72, the returned `MyObjectPrivate` pointer is guaranteed to be + * aligned to at least the alignment of the largest basic GLib type (typically + * this is #guint64 or #gdouble). If you need larger alignment for an element in + * the struct, you should allocate it on the heap (aligned), or arrange for your + * `MyObjectPrivate` struct to be appropriately padded. + * + * Note that this macro can only be used together with the `G_DEFINE_TYPE_*` + * macros, since it depends on variable names from those macros. + * + * Also note that private structs added with these macros must have a struct + * name of the form `TypeNamePrivate`. + * + * It is safe to call the `_get_instance_private` function on %NULL or invalid + * objects since it's only adding an offset to the instance pointer. In that + * case the returned pointer must not be dereferenced. + * + * Since: 2.38 + */ +#define G_ADD_PRIVATE(TypeName) { \ + TypeName##_private_offset = \ + g_type_add_instance_private (g_define_type_id, sizeof (TypeName##Private)); \ +} + +/** + * G_PRIVATE_OFFSET: + * @TypeName: the name of the type in CamelCase + * @field: the name of the field in the private data structure + * + * Evaluates to the offset of the @field inside the instance private data + * structure for @TypeName. + * + * Note that this macro can only be used together with the `G_DEFINE_TYPE_*` + * and G_ADD_PRIVATE() macros, since it depends on variable names from + * those macros. + * + * Since: 2.38 + */ +#define G_PRIVATE_OFFSET(TypeName, field) \ + (TypeName##_private_offset + (G_STRUCT_OFFSET (TypeName##Private, field))) + +/** + * G_PRIVATE_FIELD_P: + * @TypeName: the name of the type in CamelCase + * @inst: the instance of @TypeName you wish to access + * @field_name: the name of the field in the private data structure + * + * Evaluates to a pointer to the @field_name inside the @inst private data + * structure for @TypeName. + * + * Note that this macro can only be used together with the `G_DEFINE_TYPE_*` + * and G_ADD_PRIVATE() macros, since it depends on variable names from + * those macros. + * + * Since: 2.38 + */ +#define G_PRIVATE_FIELD_P(TypeName, inst, field_name) \ + G_STRUCT_MEMBER_P (inst, G_PRIVATE_OFFSET (TypeName, field_name)) + +/** + * G_PRIVATE_FIELD: + * @TypeName: the name of the type in CamelCase + * @inst: the instance of @TypeName you wish to access + * @field_type: the type of the field in the private data structure + * @field_name: the name of the field in the private data structure + * + * Evaluates to the @field_name inside the @inst private data + * structure for @TypeName. + * + * Note that this macro can only be used together with the `G_DEFINE_TYPE_*` + * and G_ADD_PRIVATE() macros, since it depends on variable names from + * those macros. + * + * Since: 2.38 + */ +#define G_PRIVATE_FIELD(TypeName, inst, field_type, field_name) \ + G_STRUCT_MEMBER (field_type, inst, G_PRIVATE_OFFSET (TypeName, field_name)) + +/* we need to have this macro under conditional expansion, as it references + * a function that has been added in 2.38. see bug: + * https://bugzilla.gnome.org/show_bug.cgi?id=703191 + */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 +#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ +static void type_name##_class_intern_init (gpointer klass) \ +{ \ + type_name##_parent_class = g_type_class_peek_parent (klass); \ + if (TypeName##_private_offset != 0) \ + g_type_class_adjust_private_offset (klass, &TypeName##_private_offset); \ + type_name##_class_init ((TypeName##Class*) klass); \ +} + +#else +#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ +static void type_name##_class_intern_init (gpointer klass) \ +{ \ + type_name##_parent_class = g_type_class_peek_parent (klass); \ + type_name##_class_init ((TypeName##Class*) klass); \ +} +#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */ + +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_80 +#define _g_type_once_init_type GType +#define _g_type_once_init_enter g_once_init_enter_pointer +#define _g_type_once_init_leave g_once_init_leave_pointer +#else /* if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_80 */ +#define _g_type_once_init_type gsize +#define _g_type_once_init_enter g_once_init_enter +#define _g_type_once_init_leave g_once_init_leave +#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_80 */ + +/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */ +#define _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name) \ +\ +static void type_name##_init (TypeName *self); \ +static void type_name##_class_init (TypeName##Class *klass); \ +static GType type_name##_get_type_once (void); \ +static gpointer type_name##_parent_class = NULL; \ +static gint TypeName##_private_offset; \ +\ +_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ +\ +G_GNUC_UNUSED \ +static inline gpointer \ +type_name##_get_instance_private (TypeName *self) \ +{ \ + return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \ +} \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static _g_type_once_init_type static_g_define_type_id = 0; + /* Prelude goes here */ + +/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */ +#define _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \ + if (_g_type_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = type_name##_get_type_once (); \ + _g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} /* closes type_name##_get_type() */ \ +\ +G_NO_INLINE \ +static GType \ +type_name##_get_type_once (void) \ +{ \ + GType g_define_type_id = \ + g_type_register_static_simple (TYPE_PARENT, \ + g_intern_static_string (#TypeName), \ + sizeof (TypeName##Class), \ + (GClassInitFunc)(void (*)(void)) type_name##_class_intern_init, \ + sizeof (TypeName), \ + (GInstanceInitFunc)(void (*)(void)) type_name##_init, \ + (GTypeFlags) flags); \ + { /* custom code follows */ +#define _G_DEFINE_TYPE_EXTENDED_END() \ + /* following custom code */ \ + } \ + return g_define_type_id; \ +} /* closes type_name##_get_type_once() */ + +/* This was defined before we had _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE in + * gtype-private.h, it's simplest to keep it. + */ +#define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \ + _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE (TypeName, type_name) \ + _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER (TypeName, type_name, TYPE_PARENT, flags) + +/* Intentionally using (GTypeFlags) 0 instead of G_TYPE_FLAG_NONE here, + * to avoid deprecation warnings with older GLIB_VERSION_MAX_ALLOWED */ +#define _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PREREQ) \ +\ +static void type_name##_default_init (TypeName##Interface *klass); \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static _g_type_once_init_type static_g_define_type_id = 0; \ + if (_g_type_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = \ + g_type_register_static_simple (G_TYPE_INTERFACE, \ + g_intern_static_string (#TypeName), \ + sizeof (TypeName##Interface), \ + (GClassInitFunc)(void (*)(void)) type_name##_default_init, \ + 0, \ + (GInstanceInitFunc)NULL, \ + (GTypeFlags) 0); \ + if (TYPE_PREREQ != G_TYPE_INVALID) \ + g_type_interface_add_prerequisite (g_define_type_id, TYPE_PREREQ); \ + { /* custom code follows */ +#define _G_DEFINE_INTERFACE_EXTENDED_END() \ + /* following custom code */ \ + } \ + _g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} /* closes type_name##_get_type() */ + +/** + * G_DEFINE_BOXED_TYPE: + * @TypeName: The name of the new type, in Camel case + * @type_name: The name of the new type, in lowercase, with words + * separated by `_` + * @copy_func: the #GBoxedCopyFunc for the new type + * @free_func: the #GBoxedFreeFunc for the new type + * + * A convenience macro for defining a new custom boxed type. + * + * Using this macro is the recommended way of defining new custom boxed + * types, over calling g_boxed_type_register_static() directly. It defines + * a `type_name_get_type()` function which will return the newly defined + * #GType, enabling lazy instantiation. + * + * You might start by putting declarations in a header as follows: + * + * |[ + * #define MY_TYPE_STRUCT my_struct_get_type () + * GType my_struct_get_type (void) G_GNUC_CONST; + * + * MyStruct * my_struct_new (void); + * void my_struct_free (MyStruct *self); + * MyStruct * my_struct_copy (MyStruct *self); + * ]| + * + * And then use this macro and define your implementation in the source file as + * follows: + * + * |[ + * MyStruct * + * my_struct_new (void) + * { + * // ... your code to allocate a new MyStruct ... + * } + * + * void + * my_struct_free (MyStruct *self) + * { + * // ... your code to free a MyStruct ... + * } + * + * MyStruct * + * my_struct_copy (MyStruct *self) + * { + * // ... your code return a newly allocated copy of a MyStruct ... + * } + * + * G_DEFINE_BOXED_TYPE (MyStruct, my_struct, my_struct_copy, my_struct_free) + * + * void + * foo () + * { + * MyStruct *ms; + * + * ms = my_struct_new (); + * // ... your code ... + * my_struct_free (ms); + * } + * ]| + * + * Since: 2.26 + */ +#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {}) +/** + * G_DEFINE_BOXED_TYPE_WITH_CODE: + * @TypeName: The name of the new type, in Camel case + * @type_name: The name of the new type, in lowercase, with words + * separated by `_` + * @copy_func: the #GBoxedCopyFunc for the new type + * @free_func: the #GBoxedFreeFunc for the new type + * @_C_: Custom code that gets inserted in the `*_get_type()` function + * + * A convenience macro for boxed type implementations. + * + * Similar to G_DEFINE_BOXED_TYPE(), but allows to insert custom code into the + * `type_name_get_type()` function, e.g. to register value transformations with + * g_value_register_transform_func(), for instance: + * + * |[ + * G_DEFINE_BOXED_TYPE_WITH_CODE (GdkRectangle, gdk_rectangle, + * gdk_rectangle_copy, + * gdk_rectangle_free, + * register_rectangle_transform_funcs (g_define_type_id)) + * ]| + * + * Similarly to the `G_DEFINE_TYPE_*` family of macros, the #GType of the newly + * defined boxed type is exposed in the `g_define_type_id` variable. + * + * Since: 2.26 + */ +#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() + +/* Only use this in non-C++ on GCC >= 2.7, except for Darwin/ppc64. + * See https://bugzilla.gnome.org/show_bug.cgi?id=647145 + */ +#if !defined (G_CXX_STD_VERSION) && (G_GNUC_CHECK_VERSION(2, 7)) && \ + !(defined (__APPLE__) && defined (__ppc64__)) +#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \ +static GType type_name##_get_type_once (void); \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static _g_type_once_init_type static_g_define_type_id = 0; \ + if (_g_type_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = type_name##_get_type_once (); \ + _g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} \ +\ +G_NO_INLINE \ +static GType \ +type_name##_get_type_once (void) \ +{ \ + GType (* _g_register_boxed) \ + (const gchar *, \ + union \ + { \ + TypeName * (*do_copy_type) (TypeName *); \ + TypeName * (*do_const_copy_type) (const TypeName *); \ + GBoxedCopyFunc do_copy_boxed; \ + } __attribute__((__transparent_union__)), \ + union \ + { \ + void (* do_free_type) (TypeName *); \ + GBoxedFreeFunc do_free_boxed; \ + } __attribute__((__transparent_union__)) \ + ) = g_boxed_type_register_static; \ + GType g_define_type_id = \ + _g_register_boxed (g_intern_static_string (#TypeName), copy_func, free_func); \ + { /* custom code follows */ +#else +#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \ +static GType type_name##_get_type_once (void); \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static _g_type_once_init_type static_g_define_type_id = 0; \ + if (_g_type_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = type_name##_get_type_once (); \ + _g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} \ +\ +G_NO_INLINE \ +static GType \ +type_name##_get_type_once (void) \ +{ \ + GType g_define_type_id = \ + g_boxed_type_register_static (g_intern_static_string (#TypeName), \ + (GBoxedCopyFunc) copy_func, \ + (GBoxedFreeFunc) free_func); \ + { /* custom code follows */ +#endif /* __GNUC__ */ + +/** + * G_DEFINE_POINTER_TYPE: + * @TypeName: The name of the new type, in Camel case + * @type_name: The name of the new type, in lowercase, with words + * separated by `_` + * + * A convenience macro for pointer type implementations, which defines a + * `type_name_get_type()` function registering the pointer type. + * + * Since: 2.26 + */ +#define G_DEFINE_POINTER_TYPE(TypeName, type_name) G_DEFINE_POINTER_TYPE_WITH_CODE (TypeName, type_name, {}) +/** + * G_DEFINE_POINTER_TYPE_WITH_CODE: + * @TypeName: The name of the new type, in Camel case + * @type_name: The name of the new type, in lowercase, with words + * separated by `_` + * @_C_: Custom code that gets inserted in the `*_get_type()` function + * + * A convenience macro for pointer type implementations. + * Similar to G_DEFINE_POINTER_TYPE(), but allows to insert + * custom code into the `type_name_get_type()` function. + * + * Since: 2.26 + */ +#define G_DEFINE_POINTER_TYPE_WITH_CODE(TypeName, type_name, _C_) _G_DEFINE_POINTER_TYPE_BEGIN (TypeName, type_name) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() + +#define _G_DEFINE_POINTER_TYPE_BEGIN(TypeName, type_name) \ +static GType type_name##_get_type_once (void); \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static _g_type_once_init_type static_g_define_type_id = 0; \ + if (_g_type_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = type_name##_get_type_once (); \ + _g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} \ +\ +G_NO_INLINE \ +static GType \ +type_name##_get_type_once (void) \ +{ \ + GType g_define_type_id = \ + g_pointer_type_register_static (g_intern_static_string (#TypeName)); \ + { /* custom code follows */ + +/* --- protected (for fundamental type implementations) --- */ +GOBJECT_AVAILABLE_IN_ALL +GTypePlugin* g_type_get_plugin (GType type); +GOBJECT_AVAILABLE_IN_ALL +GTypePlugin* g_type_interface_get_plugin (GType instance_type, + GType interface_type); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_fundamental_next (void); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_fundamental (GType type_id); +GOBJECT_AVAILABLE_IN_ALL +GTypeInstance* g_type_create_instance (GType type); +GOBJECT_AVAILABLE_IN_ALL +void g_type_free_instance (GTypeInstance *instance); + +GOBJECT_AVAILABLE_IN_ALL +void g_type_add_class_cache_func (gpointer cache_data, + GTypeClassCacheFunc cache_func); +GOBJECT_AVAILABLE_IN_ALL +void g_type_remove_class_cache_func (gpointer cache_data, + GTypeClassCacheFunc cache_func); +GOBJECT_AVAILABLE_IN_ALL +void g_type_class_unref_uncached (gpointer g_class); + +GOBJECT_AVAILABLE_IN_ALL +void g_type_add_interface_check (gpointer check_data, + GTypeInterfaceCheckFunc check_func); +GOBJECT_AVAILABLE_IN_ALL +void g_type_remove_interface_check (gpointer check_data, + GTypeInterfaceCheckFunc check_func); + +GOBJECT_AVAILABLE_IN_ALL +GTypeValueTable* g_type_value_table_peek (GType type); + + +/*< private >*/ +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_check_instance (GTypeInstance *instance) G_GNUC_PURE; +GOBJECT_AVAILABLE_IN_ALL +GTypeInstance* g_type_check_instance_cast (GTypeInstance *instance, + GType iface_type); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_check_instance_is_a (GTypeInstance *instance, + GType iface_type) G_GNUC_PURE; +GOBJECT_AVAILABLE_IN_2_42 +gboolean g_type_check_instance_is_fundamentally_a (GTypeInstance *instance, + GType fundamental_type) G_GNUC_PURE; +GOBJECT_AVAILABLE_IN_ALL +GTypeClass* g_type_check_class_cast (GTypeClass *g_class, + GType is_a_type); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_check_class_is_a (GTypeClass *g_class, + GType is_a_type) G_GNUC_PURE; +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_check_is_value_type (GType type) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_check_value (const GValue *value) G_GNUC_PURE; +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_check_value_holds (const GValue *value, + GType type) G_GNUC_PURE; +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_test_flags (GType type, + guint flags) G_GNUC_CONST; + + +/* --- debugging functions --- */ +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_type_name_from_instance (GTypeInstance *instance); +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_type_name_from_class (GTypeClass *g_class); + + +/* --- implementation bits --- */ +#if defined(G_DISABLE_CAST_CHECKS) || defined(__OPTIMIZE__) +# define _G_TYPE_CIC(ip, gt, ct) ((ct*) (void *) ip) +# define _G_TYPE_CCC(cp, gt, ct) ((ct*) (void *) cp) +#else +# define _G_TYPE_CIC(ip, gt, ct) \ + ((ct*) (void *) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) +# define _G_TYPE_CCC(cp, gt, ct) \ + ((ct*) (void *) g_type_check_class_cast ((GTypeClass*) cp, gt)) +#endif + +#define _G_TYPE_CHI(ip) (g_type_check_instance ((GTypeInstance*) ip)) +#define _G_TYPE_CHV(vl) (g_type_check_value ((GValue*) vl)) +#define _G_TYPE_IGC(ip, gt, ct) ((ct*) (((GTypeInstance*) ip)->g_class)) +#define _G_TYPE_IGI(ip, gt, ct) ((ct*) g_type_interface_peek (((GTypeInstance*) ip)->g_class, gt)) +#define _G_TYPE_CIFT(ip, ft) (g_type_check_instance_is_fundamentally_a ((GTypeInstance*) ip, ft)) +#ifdef __GNUC__ +# define _G_TYPE_CIT(ip, gt) (G_GNUC_EXTENSION ({ \ + GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \ + if (!__inst) \ + __r = FALSE; \ + else if (__inst->g_class && __inst->g_class->g_type == __t) \ + __r = TRUE; \ + else \ + __r = g_type_check_instance_is_a (__inst, __t); \ + __r; \ +})) +# define _G_TYPE_CCT(cp, gt) (G_GNUC_EXTENSION ({ \ + GTypeClass *__class = (GTypeClass*) cp; GType __t = gt; gboolean __r; \ + if (!__class) \ + __r = FALSE; \ + else if (__class->g_type == __t) \ + __r = TRUE; \ + else \ + __r = g_type_check_class_is_a (__class, __t); \ + __r; \ +})) +# define _G_TYPE_CVH(vl, gt) (G_GNUC_EXTENSION ({ \ + const GValue *__val = (const GValue*) vl; GType __t = gt; gboolean __r; \ + if (!__val) \ + __r = FALSE; \ + else if (__val->g_type == __t) \ + __r = TRUE; \ + else \ + __r = g_type_check_value_holds (__val, __t); \ + __r; \ +})) +#else /* !__GNUC__ */ +# define _G_TYPE_CIT(ip, gt) (g_type_check_instance_is_a ((GTypeInstance*) ip, gt)) +# define _G_TYPE_CCT(cp, gt) (g_type_check_class_is_a ((GTypeClass*) cp, gt)) +# define _G_TYPE_CVH(vl, gt) (g_type_check_value_holds ((const GValue*) vl, gt)) +#endif /* !__GNUC__ */ +/** + * G_TYPE_FLAG_RESERVED_ID_BIT: + * + * A bit in the type number that's supposed to be left untouched. + */ +#define G_TYPE_FLAG_RESERVED_ID_BIT ((GType) (1 << 0)) + +/** + * GPOINTER_TO_TYPE: + * @p: The pointer to convert to a #GType + * + * This macro should be used instead of GPOINTER_TO_SIZE() to ensure + * portability since #GType is not guaranteed to be the same as #gsize. + * + * Since: 2.80 + */ +#define GPOINTER_TO_TYPE(p) ((GType) (guintptr) (p)) GOBJECT_AVAILABLE_MACRO_IN_2_80 +/** + * GTYPE_TO_POINTER: + * @t: The #GType to convert to a pointer + * + * This macro should be used instead of GSIZE_TO_POINTER() to ensure + * portability since #GType is not guaranteed to be the same as #gsize. + * + * Since: 2.80 + */ +#define GTYPE_TO_POINTER(t) ((gpointer) (guintptr) (t)) GOBJECT_AVAILABLE_MACRO_IN_2_80 + +G_END_DECLS + +#endif /* __G_TYPE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gtypemodule.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gtypemodule.h new file mode 100644 index 00000000..fba714bc --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gtypemodule.h @@ -0,0 +1,295 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef __G_TYPE_MODULE_H__ +#define __G_TYPE_MODULE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct _GTypeModule GTypeModule; +typedef struct _GTypeModuleClass GTypeModuleClass; + +#define G_TYPE_TYPE_MODULE (g_type_module_get_type ()) +#define G_TYPE_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), G_TYPE_TYPE_MODULE, GTypeModule)) +#define G_TYPE_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TYPE_MODULE, GTypeModuleClass)) +#define G_IS_TYPE_MODULE(module) (G_TYPE_CHECK_INSTANCE_TYPE ((module), G_TYPE_TYPE_MODULE)) +#define G_IS_TYPE_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TYPE_MODULE)) +#define G_TYPE_MODULE_GET_CLASS(module) (G_TYPE_INSTANCE_GET_CLASS ((module), G_TYPE_TYPE_MODULE, GTypeModuleClass)) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTypeModule, g_object_unref) + +struct _GTypeModule +{ + GObject parent_instance; + + guint use_count; + GSList *type_infos; + GSList *interface_infos; + + /*< public >*/ + gchar *name; +}; + +/** + * GTypeModuleClass: + * @parent_class: the parent class + * @load: loads the module and registers one or more types using + * g_type_module_register_type(). + * @unload: unloads the module + * + * In order to implement dynamic loading of types based on #GTypeModule, + * the @load and @unload functions in #GTypeModuleClass must be implemented. + */ +struct _GTypeModuleClass +{ + GObjectClass parent_class; + + /*< public >*/ + gboolean (* load) (GTypeModule *module); + void (* unload) (GTypeModule *module); + + /*< private >*/ + /* Padding for future expansion */ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); + void (*reserved4) (void); +}; + +/** + * G_DEFINE_DYNAMIC_TYPE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by '_'. + * @T_P: The #GType of the parent type. + * + * A convenience macro for dynamic type implementations, which declares a + * class initialization function, an instance initialization function (see + * #GTypeInfo for information about these) and a static variable named + * `t_n`_parent_class pointing to the parent class. + * + * Furthermore, it defines a `*_get_type()` and a static `*_register_type()` + * functions for use in your `module_init()`. + * + * See G_DEFINE_DYNAMIC_TYPE_EXTENDED() for an example. + * + * Since: 2.14 + */ +#define G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P) G_DEFINE_DYNAMIC_TYPE_EXTENDED (TN, t_n, T_P, 0, {}) +/** + * G_DEFINE_DYNAMIC_TYPE_EXTENDED: + * @TypeName: The name of the new type, in Camel case. + * @type_name: The name of the new type, in lowercase, with words + * separated by '_'. + * @TYPE_PARENT: The #GType of the parent type. + * @flags: #GTypeFlags to pass to g_type_module_register_type() + * @CODE: Custom code that gets inserted in the *_get_type() function. + * + * A more general version of G_DEFINE_DYNAMIC_TYPE() which + * allows to specify #GTypeFlags and custom code. + * + * |[ + * G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtkGadget, + * gtk_gadget, + * GTK_TYPE_THING, + * 0, + * G_IMPLEMENT_INTERFACE_DYNAMIC (TYPE_GIZMO, + * gtk_gadget_gizmo_init)); + * ]| + * + * expands to + * + * |[ + * static void gtk_gadget_init (GtkGadget *self); + * static void gtk_gadget_class_init (GtkGadgetClass *klass); + * static void gtk_gadget_class_finalize (GtkGadgetClass *klass); + * + * static gpointer gtk_gadget_parent_class = NULL; + * static GType gtk_gadget_type_id = 0; + * + * static void gtk_gadget_class_intern_init (gpointer klass) + * { + * gtk_gadget_parent_class = g_type_class_peek_parent (klass); + * gtk_gadget_class_init ((GtkGadgetClass*) klass); + * } + * + * GType + * gtk_gadget_get_type (void) + * { + * return gtk_gadget_type_id; + * } + * + * static void + * gtk_gadget_register_type (GTypeModule *type_module) + * { + * const GTypeInfo g_define_type_info = { + * sizeof (GtkGadgetClass), + * (GBaseInitFunc) NULL, + * (GBaseFinalizeFunc) NULL, + * (GClassInitFunc) gtk_gadget_class_intern_init, + * (GClassFinalizeFunc) gtk_gadget_class_finalize, + * NULL, // class_data + * sizeof (GtkGadget), + * 0, // n_preallocs + * (GInstanceInitFunc) gtk_gadget_init, + * NULL // value_table + * }; + * gtk_gadget_type_id = g_type_module_register_type (type_module, + * GTK_TYPE_THING, + * "GtkGadget", + * &g_define_type_info, + * (GTypeFlags) flags); + * { + * const GInterfaceInfo g_implement_interface_info = { + * (GInterfaceInitFunc) gtk_gadget_gizmo_init + * }; + * g_type_module_add_interface (type_module, g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); + * } + * } + * ]| + * + * Since: 2.14 + */ +#define G_DEFINE_DYNAMIC_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \ +static void type_name##_init (TypeName *self); \ +static void type_name##_class_init (TypeName##Class *klass); \ +static void type_name##_class_finalize (TypeName##Class *klass); \ +static gpointer type_name##_parent_class = NULL; \ +static GType type_name##_type_id = 0; \ +static gint TypeName##_private_offset; \ +\ +_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ +\ +G_GNUC_UNUSED \ +static inline gpointer \ +type_name##_get_instance_private (TypeName *self) \ +{ \ + return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \ +} \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + return type_name##_type_id; \ +} \ +static void \ +type_name##_register_type (GTypeModule *type_module) \ +{ \ + GType g_define_type_id G_GNUC_UNUSED; \ + const GTypeInfo g_define_type_info = { \ + sizeof (TypeName##Class), \ + (GBaseInitFunc) NULL, \ + (GBaseFinalizeFunc) NULL, \ + (GClassInitFunc)(void (*)(void)) type_name##_class_intern_init, \ + (GClassFinalizeFunc)(void (*)(void)) type_name##_class_finalize, \ + NULL, /* class_data */ \ + sizeof (TypeName), \ + 0, /* n_preallocs */ \ + (GInstanceInitFunc)(void (*)(void)) type_name##_init, \ + NULL /* value_table */ \ + }; \ + type_name##_type_id = g_type_module_register_type (type_module, \ + TYPE_PARENT, \ + #TypeName, \ + &g_define_type_info, \ + (GTypeFlags) flags); \ + g_define_type_id = type_name##_type_id; \ + { CODE ; } \ +} + +/** + * G_IMPLEMENT_INTERFACE_DYNAMIC: + * @TYPE_IFACE: The #GType of the interface to add + * @iface_init: The interface init function + * + * A convenience macro to ease interface addition in the @_C_ section + * of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). + * + * See G_DEFINE_DYNAMIC_TYPE_EXTENDED() for an example. + * + * Note that this macro can only be used together with the + * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable + * names from that macro. + * + * Since: 2.24 + */ +#define G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) { \ + const GInterfaceInfo g_implement_interface_info = { \ + (GInterfaceInitFunc)(void (*)(void)) iface_init, NULL, NULL \ + }; \ + g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \ +} + +/** + * G_ADD_PRIVATE_DYNAMIC: + * @TypeName: the name of the type in CamelCase + * + * A convenience macro to ease adding private data to instances of a new dynamic + * type in the @_C_ section of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). + * + * See G_ADD_PRIVATE() for details, it is similar but for static types. + * + * Note that this macro can only be used together with the + * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable + * names from that macro. + * + * Since: 2.38 + */ +#define G_ADD_PRIVATE_DYNAMIC(TypeName) { \ + TypeName##_private_offset = sizeof (TypeName##Private); \ +} + +GOBJECT_AVAILABLE_IN_ALL +GType g_type_module_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +gboolean g_type_module_use (GTypeModule *module); +GOBJECT_AVAILABLE_IN_ALL +void g_type_module_unuse (GTypeModule *module); +GOBJECT_AVAILABLE_IN_ALL +void g_type_module_set_name (GTypeModule *module, + const gchar *name); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_module_register_type (GTypeModule *module, + GType parent_type, + const gchar *type_name, + const GTypeInfo *type_info, + GTypeFlags flags); +GOBJECT_AVAILABLE_IN_ALL +void g_type_module_add_interface (GTypeModule *module, + GType instance_type, + GType interface_type, + const GInterfaceInfo *interface_info); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_module_register_enum (GTypeModule *module, + const gchar *name, + const GEnumValue *const_static_values); +GOBJECT_AVAILABLE_IN_ALL +GType g_type_module_register_flags (GTypeModule *module, + const gchar *name, + const GFlagsValue *const_static_values); + +G_END_DECLS + +#endif /* __G_TYPE_MODULE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gtypeplugin.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gtypeplugin.h new file mode 100644 index 00000000..c950dfbd --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gtypeplugin.h @@ -0,0 +1,130 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_TYPE_PLUGIN_H__ +#define __G_TYPE_PLUGIN_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* --- type macros --- */ +#define G_TYPE_TYPE_PLUGIN (g_type_plugin_get_type ()) +#define G_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TYPE_PLUGIN, GTypePlugin)) +#define G_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), G_TYPE_TYPE_PLUGIN, GTypePluginClass)) +#define G_IS_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TYPE_PLUGIN)) +#define G_IS_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), G_TYPE_TYPE_PLUGIN)) +#define G_TYPE_PLUGIN_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_TYPE_PLUGIN, GTypePluginClass)) + + +/* --- typedefs & structures --- */ +typedef struct _GTypePluginClass GTypePluginClass; +/** + * GTypePluginUse: + * @plugin: the #GTypePlugin whose use count should be increased + * + * The type of the @use_plugin function of #GTypePluginClass, which gets called + * to increase the use count of @plugin. + */ +typedef void (*GTypePluginUse) (GTypePlugin *plugin); +/** + * GTypePluginUnuse: + * @plugin: the #GTypePlugin whose use count should be decreased + * + * The type of the @unuse_plugin function of #GTypePluginClass. + */ +typedef void (*GTypePluginUnuse) (GTypePlugin *plugin); +/** + * GTypePluginCompleteTypeInfo: + * @plugin: the #GTypePlugin + * @g_type: the #GType whose info is completed + * @info: the #GTypeInfo struct to fill in + * @value_table: the #GTypeValueTable to fill in + * + * The type of the @complete_type_info function of #GTypePluginClass. + */ +typedef void (*GTypePluginCompleteTypeInfo) (GTypePlugin *plugin, + GType g_type, + GTypeInfo *info, + GTypeValueTable *value_table); +/** + * GTypePluginCompleteInterfaceInfo: + * @plugin: the #GTypePlugin + * @instance_type: the #GType of an instantiatable type to which the interface + * is added + * @interface_type: the #GType of the interface whose info is completed + * @info: the #GInterfaceInfo to fill in + * + * The type of the @complete_interface_info function of #GTypePluginClass. + */ +typedef void (*GTypePluginCompleteInterfaceInfo) (GTypePlugin *plugin, + GType instance_type, + GType interface_type, + GInterfaceInfo *info); +/** + * GTypePluginClass: + * @use_plugin: Increases the use count of the plugin. + * @unuse_plugin: Decreases the use count of the plugin. + * @complete_type_info: Fills in the #GTypeInfo and + * #GTypeValueTable structs for the type. The structs are initialized + * with `memset(s, 0, sizeof (s))` before calling this function. + * @complete_interface_info: Fills in missing parts of the #GInterfaceInfo + * for the interface. The structs is initialized with + * `memset(s, 0, sizeof (s))` before calling this function. + * + * The #GTypePlugin interface is used by the type system in order to handle + * the lifecycle of dynamically loaded types. + */ +struct _GTypePluginClass +{ + /*< private >*/ + GTypeInterface base_iface; + + /*< public >*/ + GTypePluginUse use_plugin; + GTypePluginUnuse unuse_plugin; + GTypePluginCompleteTypeInfo complete_type_info; + GTypePluginCompleteInterfaceInfo complete_interface_info; +}; + + +/* --- prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +GType g_type_plugin_get_type (void) G_GNUC_CONST; +GOBJECT_AVAILABLE_IN_ALL +void g_type_plugin_use (GTypePlugin *plugin); +GOBJECT_AVAILABLE_IN_ALL +void g_type_plugin_unuse (GTypePlugin *plugin); +GOBJECT_AVAILABLE_IN_ALL +void g_type_plugin_complete_type_info (GTypePlugin *plugin, + GType g_type, + GTypeInfo *info, + GTypeValueTable *value_table); +GOBJECT_AVAILABLE_IN_ALL +void g_type_plugin_complete_interface_info (GTypePlugin *plugin, + GType instance_type, + GType interface_type, + GInterfaceInfo *info); + +G_END_DECLS + +#endif /* __G_TYPE_PLUGIN_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gvalue.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gvalue.h new file mode 100644 index 00000000..2ac5ca18 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gvalue.h @@ -0,0 +1,212 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gvalue.h: generic GValue functions + */ +#ifndef __G_VALUE_H__ +#define __G_VALUE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_TYPE_IS_VALUE: + * @type: A #GType value. + * + * Checks whether the passed in type ID can be used for g_value_init(). + * + * That is, this macro checks whether this type provides an implementation + * of the #GTypeValueTable functions required for a type to create a #GValue of. + * + * Returns: Whether @type is suitable as a #GValue type. + */ +#define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type)) +/** + * G_IS_VALUE: + * @value: A #GValue structure. + * + * Checks if @value is a valid and initialized #GValue structure. + * + * Returns: %TRUE on success. + */ +#define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value)) +/** + * G_VALUE_TYPE: + * @value: A #GValue structure. + * + * Get the type identifier of @value. + * + * Returns: the #GType. + */ +#define G_VALUE_TYPE(value) (((GValue*) (value))->g_type) +/** + * G_VALUE_TYPE_NAME: + * @value: A #GValue structure. + * + * Gets the type name of @value. + * + * Returns: the type name. + */ +#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value))) +/** + * G_VALUE_HOLDS: + * @value: A #GValue structure. + * @type: A #GType value. + * + * Checks if @value holds (or contains) a value of @type. + * This macro will also check for @value != %NULL and issue a + * warning if the check fails. + * + * Returns: %TRUE if @value holds the @type. + */ +#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type))) + + +/* --- typedefs & structures --- */ +/** + * GValueTransform: + * @src_value: Source value. + * @dest_value: Target value. + * + * The type of value transformation functions which can be registered with + * g_value_register_transform_func(). + * + * @dest_value will be initialized to the correct destination type. + */ +typedef void (*GValueTransform) (const GValue *src_value, + GValue *dest_value); +/** + * GValue: + * + * An opaque structure used to hold different types of values. + * + * The data within the structure has protected scope: it is accessible only + * to functions within a #GTypeValueTable structure, or implementations of + * the g_value_*() API. That is, code portions which implement new fundamental + * types. + * + * #GValue users cannot make any assumptions about how data is stored + * within the 2 element @data union, and the @g_type member should + * only be accessed through the G_VALUE_TYPE() macro. + */ +struct _GValue +{ + /*< private >*/ + GType g_type; + + /* public for GTypeValueTable methods */ + union { + gint v_int; + guint v_uint; + glong v_long; + gulong v_ulong; + gint64 v_int64; + guint64 v_uint64; + gfloat v_float; + gdouble v_double; + gpointer v_pointer; + } data[2]; +}; + + +/* --- prototypes --- */ +GOBJECT_AVAILABLE_IN_ALL +GValue* g_value_init (GValue *value, + GType g_type); +GOBJECT_AVAILABLE_IN_ALL +void g_value_copy (const GValue *src_value, + GValue *dest_value); +GOBJECT_AVAILABLE_IN_ALL +GValue* g_value_reset (GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_unset (GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_instance (GValue *value, + gpointer instance); +GOBJECT_AVAILABLE_IN_2_42 +void g_value_init_from_instance (GValue *value, + gpointer instance); + + +/* --- private --- */ +GOBJECT_AVAILABLE_IN_ALL +gboolean g_value_fits_pointer (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_value_peek_pointer (const GValue *value); + + +/* --- implementation details --- */ +GOBJECT_AVAILABLE_IN_ALL +gboolean g_value_type_compatible (GType src_type, + GType dest_type); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_value_type_transformable (GType src_type, + GType dest_type); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_value_transform (const GValue *src_value, + GValue *dest_value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_register_transform_func (GType src_type, + GType dest_type, + GValueTransform transform_func); + +/** + * G_VALUE_NOCOPY_CONTENTS: + * + * If passed to G_VALUE_COLLECT(), allocated data won't be copied + * but used verbatim. This does not affect ref-counted types like + * objects. This does not affect usage of g_value_copy(), the data will + * be copied if it is not ref-counted. + */ +#define G_VALUE_NOCOPY_CONTENTS (1 << 27) + +/** + * G_VALUE_INTERNED_STRING: + * + * For string values, indicates that the string contained is canonical and will + * exist for the duration of the process. See g_value_set_interned_string(). + * + * Since: 2.66 + */ +#define G_VALUE_INTERNED_STRING (1 << 28) GOBJECT_AVAILABLE_MACRO_IN_2_66 + +/** + * G_VALUE_INIT: + * + * A #GValue must be initialized before it can be used. This macro can + * be used as initializer instead of an explicit `{ 0 }` when declaring + * a variable, but it cannot be assigned to a variable. + * + * |[ + * GValue value = G_VALUE_INIT; + * ]| + * + * Since: 2.30 + */ +#define G_VALUE_INIT { 0, { { 0 } } } + + +G_END_DECLS + +#endif /* __G_VALUE_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluearray.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluearray.h new file mode 100644 index 00000000..d6052c0a --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluearray.h @@ -0,0 +1,99 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2001 Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gvaluearray.h: GLib array type holding GValues + */ +#ifndef __G_VALUE_ARRAY_H__ +#define __G_VALUE_ARRAY_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * G_TYPE_VALUE_ARRAY: + * + * The type ID of the "GValueArray" type which is a boxed type, + * used to pass around pointers to GValueArrays. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray + */ +#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ()) GOBJECT_DEPRECATED_MACRO_IN_2_32_FOR(G_TYPE_ARRAY) + +/* --- typedefs & structs --- */ +typedef struct _GValueArray GValueArray; +struct _GValueArray +{ + guint n_values; + GValue *values; + + /*< private >*/ + guint n_prealloced; +}; + +/* --- prototypes --- */ +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GType g_value_array_get_type (void) G_GNUC_CONST; + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValue* g_value_array_get_nth (GValueArray *value_array, + guint index_); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_new (guint n_prealloced); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +void g_value_array_free (GValueArray *value_array); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_copy (const GValueArray *value_array); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_prepend (GValueArray *value_array, + const GValue *value); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_append (GValueArray *value_array, + const GValue *value); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_insert (GValueArray *value_array, + guint index_, + const GValue *value); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_remove (GValueArray *value_array, + guint index_); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_sort (GValueArray *value_array, + GCompareFunc compare_func); + +GOBJECT_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_sort_with_data (GValueArray *value_array, + GCompareDataFunc compare_func, + gpointer user_data); + + +G_END_DECLS + +#endif /* __G_VALUE_ARRAY_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluecollector.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluecollector.h new file mode 100644 index 00000000..35608b10 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluecollector.h @@ -0,0 +1,280 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gvaluecollector.h: GValue varargs stubs + */ + +#ifndef __G_VALUE_COLLECTOR_H__ +#define __G_VALUE_COLLECTOR_H__ + +#include + +G_BEGIN_DECLS + +/* we may want to add aggregate types here some day, if requested + * by users. the basic C types are covered already, everything + * smaller than an int is promoted to an integer and floats are + * always promoted to doubles for varargs call constructions. + */ +enum /*< skip >*/ +{ + G_VALUE_COLLECT_INT = 'i', + G_VALUE_COLLECT_LONG = 'l', + G_VALUE_COLLECT_INT64 = 'q', + G_VALUE_COLLECT_DOUBLE = 'd', + G_VALUE_COLLECT_POINTER = 'p' +}; + + +/* vararg union holding actual values collected + */ +/** + * GTypeCValue: + * @v_int: the field for holding integer values + * @v_long: the field for holding long integer values + * @v_int64: the field for holding 64 bit integer values + * @v_double: the field for holding floating point values + * @v_pointer: the field for holding pointers + * + * A union holding one collected value. + */ +union _GTypeCValue +{ + gint v_int; + glong v_long; + gint64 v_int64; + gdouble v_double; + gpointer v_pointer; +}; + +/** + * G_VALUE_COLLECT_INIT: + * @value: a #GValue return location. @value must contain only 0 bytes. + * @_value_type: the #GType to use for @value. + * @var_args: the va_list variable; it may be evaluated multiple times + * @flags: flags which are passed on to the collect_value() function of + * the #GTypeValueTable of @value. + * @__error: a #gchar** variable that will be modified to hold a g_new() + * allocated error messages if something fails + * + * Collects a variable argument value from a `va_list`. + * + * We have to implement the varargs collection as a macro, because on some + * systems `va_list` variables cannot be passed by reference. + * + * Since: 2.24 + */ +#define G_VALUE_COLLECT_INIT(value, _value_type, var_args, flags, __error) \ + G_STMT_START { \ + GTypeValueTable *g_vci_vtab; \ + G_VALUE_COLLECT_INIT2(value, g_vci_vtab, _value_type, var_args, flags, __error); \ +} G_STMT_END + +/** + * G_VALUE_COLLECT_INIT2: + * @value: a #GValue return location. @value must contain only 0 bytes. + * @g_vci_vtab: a #GTypeValueTable pointer that will be set to the value table + * for @_value_type + * @_value_type: the #GType to use for @value. + * @var_args: the va_list variable; it may be evaluated multiple times + * @flags: flags which are passed on to the collect_value() function of + * the #GTypeValueTable of @value. + * @__error: a #gchar** variable that will be modified to hold a g_new() + * allocated error messages if something fails + * + * A variant of G_VALUE_COLLECT_INIT() that provides the #GTypeValueTable + * to the caller. + * + * Since: 2.74 + */ +#define G_VALUE_COLLECT_INIT2(value, g_vci_vtab, _value_type, var_args, flags, __error) \ +G_STMT_START { \ + GValue *g_vci_val = (value); \ + guint g_vci_flags = (flags); \ + const gchar *g_vci_collect_format; \ + GTypeCValue g_vci_cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \ + guint g_vci_n_values = 0; \ + g_vci_vtab = g_type_value_table_peek (_value_type); \ + g_vci_collect_format = g_vci_vtab->collect_format; \ + g_vci_val->g_type = _value_type; /* value_meminit() from gvalue.c */ \ + while (*g_vci_collect_format) \ + { \ + GTypeCValue *g_vci_cvalue = g_vci_cvalues + g_vci_n_values++; \ + \ + switch (*g_vci_collect_format++) \ + { \ + case G_VALUE_COLLECT_INT: \ + g_vci_cvalue->v_int = va_arg ((var_args), gint); \ + break; \ + case G_VALUE_COLLECT_LONG: \ + g_vci_cvalue->v_long = va_arg ((var_args), glong); \ + break; \ + case G_VALUE_COLLECT_INT64: \ + g_vci_cvalue->v_int64 = va_arg ((var_args), gint64); \ + break; \ + case G_VALUE_COLLECT_DOUBLE: \ + g_vci_cvalue->v_double = va_arg ((var_args), gdouble); \ + break; \ + case G_VALUE_COLLECT_POINTER: \ + g_vci_cvalue->v_pointer = va_arg ((var_args), gpointer); \ + break; \ + default: \ + g_assert_not_reached (); \ + } \ + } \ + *(__error) = g_vci_vtab->collect_value (g_vci_val, \ + g_vci_n_values, \ + g_vci_cvalues, \ + g_vci_flags); \ +} G_STMT_END + +/** + * G_VALUE_COLLECT: + * @value: a #GValue return location. @value is supposed to be initialized + * according to the value type to be collected + * @var_args: the va_list variable; it may be evaluated multiple times + * @flags: flags which are passed on to the collect_value() function of + * the #GTypeValueTable of @value. + * @__error: a #gchar** variable that will be modified to hold a g_new() + * allocated error messages if something fails + * + * Collects a variable argument value from a `va_list`. + * + * We have to implement the varargs collection as a macro, because on some systems + * `va_list` variables cannot be passed by reference. + * + * Note: If you are creating the @value argument just before calling this macro, + * you should use the G_VALUE_COLLECT_INIT() variant and pass the uninitialized + * #GValue. That variant is faster than G_VALUE_COLLECT(). + */ +#define G_VALUE_COLLECT(value, var_args, flags, __error) G_STMT_START { \ + GValue *g_vc_value = (value); \ + GType g_vc_value_type = G_VALUE_TYPE (g_vc_value); \ + GTypeValueTable *g_vc_vtable = g_type_value_table_peek (g_vc_value_type); \ + \ + if (g_vc_vtable->value_free) \ + g_vc_vtable->value_free (g_vc_value); \ + memset (g_vc_value->data, 0, sizeof (g_vc_value->data)); \ + \ + G_VALUE_COLLECT_INIT(value, g_vc_value_type, var_args, flags, __error); \ +} G_STMT_END + +/** + * G_VALUE_COLLECT_SKIP: + * @_value_type: the #GType of the value to skip + * @var_args: the va_list variable; it may be evaluated multiple times + * + * Skip an argument of type @_value_type from @var_args. + */ +#define G_VALUE_COLLECT_SKIP(_value_type, var_args) \ +G_STMT_START { \ + GTypeValueTable *g_vcs_vtable = g_type_value_table_peek (_value_type); \ + const gchar *g_vcs_collect_format = g_vcs_vtable->collect_format; \ + \ + while (*g_vcs_collect_format) \ + { \ + switch (*g_vcs_collect_format++) \ + { \ + case G_VALUE_COLLECT_INT: \ + va_arg ((var_args), gint); \ + break; \ + case G_VALUE_COLLECT_LONG: \ + va_arg ((var_args), glong); \ + break; \ + case G_VALUE_COLLECT_INT64: \ + va_arg ((var_args), gint64); \ + break; \ + case G_VALUE_COLLECT_DOUBLE: \ + va_arg ((var_args), gdouble); \ + break; \ + case G_VALUE_COLLECT_POINTER: \ + va_arg ((var_args), gpointer); \ + break; \ + default: \ + g_assert_not_reached (); \ + } \ + } \ +} G_STMT_END + +/** + * G_VALUE_LCOPY: + * @value: a #GValue to store into the @var_args; this must be initialized + * and set + * @var_args: the va_list variable; it may be evaluated multiple times + * @flags: flags which are passed on to the lcopy_value() function of + * the #GTypeValueTable of @value. + * @__error: a #gchar** variable that will be modified to hold a g_new() + * allocated error message if something fails + * + * Stores a value’s value into one or more argument locations from a `va_list`. + * + * This is the inverse of G_VALUE_COLLECT(). + */ +#define G_VALUE_LCOPY(value, var_args, flags, __error) \ +G_STMT_START { \ + const GValue *g_vl_value = (value); \ + guint g_vl_flags = (flags); \ + GType g_vl_value_type = G_VALUE_TYPE (g_vl_value); \ + GTypeValueTable *g_vl_vtable = g_type_value_table_peek (g_vl_value_type); \ + const gchar *g_vl_lcopy_format = g_vl_vtable->lcopy_format; \ + GTypeCValue g_vl_cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \ + guint g_vl_n_values = 0; \ + \ + while (*g_vl_lcopy_format) \ + { \ + GTypeCValue *g_vl_cvalue = g_vl_cvalues + g_vl_n_values++; \ + \ + switch (*g_vl_lcopy_format++) \ + { \ + case G_VALUE_COLLECT_INT: \ + g_vl_cvalue->v_int = va_arg ((var_args), gint); \ + break; \ + case G_VALUE_COLLECT_LONG: \ + g_vl_cvalue->v_long = va_arg ((var_args), glong); \ + break; \ + case G_VALUE_COLLECT_INT64: \ + g_vl_cvalue->v_int64 = va_arg ((var_args), gint64); \ + break; \ + case G_VALUE_COLLECT_DOUBLE: \ + g_vl_cvalue->v_double = va_arg ((var_args), gdouble); \ + break; \ + case G_VALUE_COLLECT_POINTER: \ + g_vl_cvalue->v_pointer = va_arg ((var_args), gpointer); \ + break; \ + default: \ + g_assert_not_reached (); \ + } \ + } \ + *(__error) = g_vl_vtable->lcopy_value (g_vl_value, \ + g_vl_n_values, \ + g_vl_cvalues, \ + g_vl_flags); \ +} G_STMT_END + + +/** + * G_VALUE_COLLECT_FORMAT_MAX_LENGTH: + * + * The maximal number of #GTypeCValues which can be collected for a + * single #GValue. + */ +#define G_VALUE_COLLECT_FORMAT_MAX_LENGTH (8) + +G_END_DECLS + +#endif /* __G_VALUE_COLLECTOR_H__ */ diff --git a/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluetypes.h b/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluetypes.h new file mode 100644 index 00000000..afa65953 --- /dev/null +++ b/illumos-x86_64/usr/include/glib-2.0/gobject/gvaluetypes.h @@ -0,0 +1,320 @@ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gvaluetypes.h: GLib default values + */ +#ifndef __G_VALUETYPES_H__ +#define __G_VALUETYPES_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_VALUE_HOLDS_CHAR: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR)) +/** + * G_VALUE_HOLDS_UCHAR: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR)) +/** + * G_VALUE_HOLDS_BOOLEAN: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN)) +/** + * G_VALUE_HOLDS_INT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_INT. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT)) +/** + * G_VALUE_HOLDS_UINT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_UINT. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT)) +/** + * G_VALUE_HOLDS_LONG: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_LONG. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG)) +/** + * G_VALUE_HOLDS_ULONG: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG)) +/** + * G_VALUE_HOLDS_INT64: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_INT64. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_INT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64)) +/** + * G_VALUE_HOLDS_UINT64: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_UINT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64)) +/** + * G_VALUE_HOLDS_FLOAT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT)) +/** + * G_VALUE_HOLDS_DOUBLE: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE)) +/** + * G_VALUE_HOLDS_STRING: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_STRING. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING)) +/** + * G_VALUE_IS_INTERNED_STRING: + * @value: a valid #GValue structure + * + * Checks whether @value contains a string which is canonical. + * + * Returns: %TRUE if the value contains a string in its canonical + * representation, as returned by g_intern_string(). See also + * g_value_set_interned_string(). + * + * Since: 2.66 + */ +#define G_VALUE_IS_INTERNED_STRING(value) (G_VALUE_HOLDS_STRING (value) && ((value)->data[1].v_uint & G_VALUE_INTERNED_STRING)) GOBJECT_AVAILABLE_MACRO_IN_2_66 +/** + * G_VALUE_HOLDS_POINTER: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER)) +/** + * G_TYPE_GTYPE: + * + * The type for #GType. + */ +#define G_TYPE_GTYPE (g_gtype_get_type()) +/** + * G_VALUE_HOLDS_GTYPE: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE. + * + * Since: 2.12 + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE)) +/** + * G_VALUE_HOLDS_VARIANT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT. + * + * Returns: %TRUE on success. + * + * Since: 2.26 + */ +#define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT)) + + +/* --- prototypes --- */ +GOBJECT_DEPRECATED_IN_2_32_FOR(g_value_set_schar) +void g_value_set_char (GValue *value, + gchar v_char); +GOBJECT_DEPRECATED_IN_2_32_FOR(g_value_get_schar) +gchar g_value_get_char (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_schar (GValue *value, + gint8 v_char); +GOBJECT_AVAILABLE_IN_ALL +gint8 g_value_get_schar (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_uchar (GValue *value, + guchar v_uchar); +GOBJECT_AVAILABLE_IN_ALL +guchar g_value_get_uchar (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_boolean (GValue *value, + gboolean v_boolean); +GOBJECT_AVAILABLE_IN_ALL +gboolean g_value_get_boolean (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_int (GValue *value, + gint v_int); +GOBJECT_AVAILABLE_IN_ALL +gint g_value_get_int (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_uint (GValue *value, + guint v_uint); +GOBJECT_AVAILABLE_IN_ALL +guint g_value_get_uint (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_long (GValue *value, + glong v_long); +GOBJECT_AVAILABLE_IN_ALL +glong g_value_get_long (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_ulong (GValue *value, + gulong v_ulong); +GOBJECT_AVAILABLE_IN_ALL +gulong g_value_get_ulong (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_int64 (GValue *value, + gint64 v_int64); +GOBJECT_AVAILABLE_IN_ALL +gint64 g_value_get_int64 (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_uint64 (GValue *value, + guint64 v_uint64); +GOBJECT_AVAILABLE_IN_ALL +guint64 g_value_get_uint64 (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_float (GValue *value, + gfloat v_float); +GOBJECT_AVAILABLE_IN_ALL +gfloat g_value_get_float (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_double (GValue *value, + gdouble v_double); +GOBJECT_AVAILABLE_IN_ALL +gdouble g_value_get_double (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_string (GValue *value, + const gchar *v_string); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_static_string (GValue *value, + const gchar *v_string); +GOBJECT_AVAILABLE_IN_2_66 +void g_value_set_interned_string (GValue *value, + const gchar *v_string); +GOBJECT_AVAILABLE_IN_ALL +const gchar * g_value_get_string (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +gchar* g_value_dup_string (const GValue *value); +GOBJECT_AVAILABLE_IN_2_80 +gchar* g_value_steal_string (GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_pointer (GValue *value, + gpointer v_pointer); +GOBJECT_AVAILABLE_IN_ALL +gpointer g_value_get_pointer (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +GType g_gtype_get_type (void); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_gtype (GValue *value, + GType v_gtype); +GOBJECT_AVAILABLE_IN_ALL +GType g_value_get_gtype (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +void g_value_set_variant (GValue *value, + GVariant *variant); +GOBJECT_AVAILABLE_IN_ALL +void g_value_take_variant (GValue *value, + GVariant *variant); +GOBJECT_AVAILABLE_IN_ALL +GVariant* g_value_get_variant (const GValue *value); +GOBJECT_AVAILABLE_IN_ALL +GVariant* g_value_dup_variant (const GValue *value); + + +/* Convenience for registering new pointer types */ +GOBJECT_AVAILABLE_IN_ALL +GType g_pointer_type_register_static (const gchar *name); + +/* debugging aid, describe value contents as string */ +GOBJECT_AVAILABLE_IN_ALL +gchar* g_strdup_value_contents (const GValue *value); + + +GOBJECT_AVAILABLE_IN_ALL +void g_value_take_string (GValue *value, + gchar *v_string); +GOBJECT_DEPRECATED_FOR(g_value_take_string) +void g_value_set_string_take_ownership (GValue *value, + gchar *v_string); + + +/* humpf, need a C representable type name for G_TYPE_STRING */ +/** + * gchararray: + * + * A C representable type name for %G_TYPE_STRING. + */ +typedef gchar* gchararray; + + +G_END_DECLS + +#endif /* __G_VALUETYPES_H__ */ diff --git a/illumos-x86_64/usr/include/glob.h b/illumos-x86_64/usr/include/glob.h new file mode 100644 index 00000000..83bb9985 --- /dev/null +++ b/illumos-x86_64/usr/include/glob.h @@ -0,0 +1,182 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 1985, 1992 by Mortice Kern Systems Inc. All rights reserved. + */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)glob.h 8.1 (Berkeley) 6/2/93 + */ + +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2013 Gary Mills + */ + +#ifndef _GLOB_H +#define _GLOB_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct glob_t { + /* + * Members specified by POSIX + */ + size_t gl_pathc; /* Total count of paths matched by pattern */ + char **gl_pathv; /* List of matched pathnames */ + size_t gl_offs; /* # of slots reserved in gl_pathv */ + + /* + * Internal-use members: + * + * NB: The next two members are carried in both the + * libc backward compatibility wrapper functions and + * the extended functions. + */ + char **gl_pathp; /* gl_pathv + gl_offs */ + int gl_pathn; /* # of elements allocated */ + + /* + * Non-POSIX extensions + * + * NB: The following members are not carried in + * the libc backward compatibility wrapper functions. + */ + int gl_matchc; /* Count of paths matching pattern. */ + int gl_flags; /* Copy of flags parameter to glob. */ + struct stat **gl_statv; /* Stat entries corresponding to gl_pathv */ + + /* + * Alternate filesystem access methods for glob; replacement + * versions of closedir(3), readdir(3), opendir(3), stat(2) + * and lstat(2). + */ + void (*gl_closedir)(void *); + struct dirent *(*gl_readdir)(void *); + void *(*gl_opendir)(const char *); + int (*gl_lstat)(const char *, struct stat *); + int (*gl_stat)(const char *, struct stat *); +} glob_t; + +/* + * POSIX "flags" argument to glob function. + */ +#define GLOB_ERR 0x0001 /* Don't continue on directory error */ +#define GLOB_MARK 0x0002 /* Mark directories with trailing / */ +#define GLOB_NOSORT 0x0004 /* Don't sort pathnames */ +#define GLOB_NOCHECK 0x0008 /* Return unquoted arg if no match */ +#define GLOB_DOOFFS 0x0010 /* Ignore gl_offs unless set */ +#define GLOB_APPEND 0x0020 /* Append to previous glob_t */ +#define GLOB_NOESCAPE 0x0040 /* Backslashes do not quote M-chars */ + +/* + * Non-POSIX "flags" argument to glob function, from OpenBSD. + */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define GLOB_POSIX 0x007F /* All POSIX flags */ +#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ +#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ +#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ +#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ +#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ +#define GLOB_LIMIT 0x2000 /* Limit pattern match output to ARG_MAX */ +#define GLOB_KEEPSTAT 0x4000 /* Retain stat data for paths in gl_statv. */ +#define GLOB_ALTDIRFUNC 0x8000 /* Use alternately specified directory funcs. */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* + * Error returns from "glob" + */ +#define GLOB_NOSYS (-4) /* function not supported (XPG4) */ +#define GLOB_NOMATCH (-3) /* Pattern does not match */ +#define GLOB_NOSPACE (-2) /* Not enough memory */ +#define GLOB_ABORTED (-1) /* GLOB_ERR set or errfunc return!=0 */ +#define GLOB_ABEND GLOB_ABORTED /* backward compatibility */ + + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#pragma redefine_extname glob _glob_ext64 +#pragma redefine_extname globfree _globfree_ext64 +#else +#pragma redefine_extname glob _glob_ext +#pragma redefine_extname globfree _globfree_ext +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#define glob _glob_ext64 +#define globfree _globfree_ext64 +#else +#define glob _glob_ext +#define globfree _globfree_ext +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +extern int glob(const char *_RESTRICT_KYWD, int, int(*)(const char *, int), + glob_t *_RESTRICT_KYWD); +extern void globfree(glob_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _GLOB_H */ diff --git a/illumos-x86_64/usr/include/gmp/gmp.h b/illumos-x86_64/usr/include/gmp/gmp.h new file mode 100644 index 00000000..747dabf4 --- /dev/null +++ b/illumos-x86_64/usr/include/gmp/gmp.h @@ -0,0 +1,2352 @@ +/* Definitions for GNU multiple precision functions. -*- mode: c -*- + +Copyright 1991, 1993-1997, 1999-2016, 2020, 2021 Free Software +Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + +or + + * the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any + later version. + +or both in parallel, as here. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received copies of the GNU General Public License and the +GNU Lesser General Public License along with the GNU MP Library. If not, +see https://www.gnu.org/licenses/. */ + +#ifndef __GMP_H__ + +#if defined (__cplusplus) +#include /* for std::istream, std::ostream, std::string */ +#include +#endif + + +/* Instantiated by configure. */ +#if ! defined (__GMP_WITHIN_CONFIGURE) +#define __GMP_HAVE_HOST_CPU_FAMILY_power 0 +#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0 +#define GMP_NAIL_BITS 0 +#if defined(__amd64) || defined(__aarch64__) +#define GMP_LIMB_BITS 64 +#else +#define GMP_LIMB_BITS 32 +#endif +#endif +#define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS) +#define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS) +#define GMP_NUMB_MAX GMP_NUMB_MASK +#define GMP_NAIL_MASK (~ GMP_NUMB_MASK) + + +#ifndef __GNU_MP__ +#define __GNU_MP__ 6 + +#include /* for size_t */ +#include + +/* Instantiated by configure. */ +#if ! defined (__GMP_WITHIN_CONFIGURE) +/* #undef _LONG_LONG_LIMB */ +#define __GMP_LIBGMP_DLL 0 +#endif + + +/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in + all other circumstances. + + When compiling objects for libgmp, __GMP_DECLSPEC is an export directive, + or when compiling for an application it's an import directive. The two + cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles + (and not defined from an application). + + __GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX + indicates when building libgmpxx, and in that case libgmpxx functions are + exports, but libgmp functions which might get called are imports. + + Libtool DLL_EXPORT define is not used. + + There's no attempt to support GMP built both static and DLL. Doing so + would mean applications would have to tell us which of the two is going + to be used when linking, and that seems very tedious and error prone if + using GMP by hand, and equally tedious from a package since autoconf and + automake don't give much help. + + __GMP_DECLSPEC is required on all documented global functions and + variables, the various internals in gmp-impl.h etc can be left unadorned. + But internals used by the test programs or speed measuring programs + should have __GMP_DECLSPEC, and certainly constants or variables must + have it or the wrong address will be resolved. + + In gcc __declspec can go at either the start or end of a prototype. + + In Microsoft C __declspec must go at the start, or after the type like + void __declspec(...) *foo()". There's no __dllexport or anything to + guard against someone foolish #defining dllexport. _export used to be + available, but no longer. + + In Borland C _export still exists, but needs to go after the type, like + "void _export foo();". Would have to change the __GMP_DECLSPEC syntax to + make use of that. Probably more trouble than it's worth. */ + +#if defined (__GNUC__) +#define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__) +#define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__) +#endif +#if defined (_MSC_VER) || defined (__BORLANDC__) +#define __GMP_DECLSPEC_EXPORT __declspec(dllexport) +#define __GMP_DECLSPEC_IMPORT __declspec(dllimport) +#endif +#ifdef __WATCOMC__ +#define __GMP_DECLSPEC_EXPORT __export +#define __GMP_DECLSPEC_IMPORT __import +#endif +#ifdef __IBMC__ +#define __GMP_DECLSPEC_EXPORT _Export +#define __GMP_DECLSPEC_IMPORT _Import +#endif + +#if __GMP_LIBGMP_DLL +#ifdef __GMP_WITHIN_GMP +/* compiling to go into a DLL libgmp */ +#define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT +#else +/* compiling to go into an application which will link to a DLL libgmp */ +#define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT +#endif +#else +/* all other cases */ +#define __GMP_DECLSPEC +#endif + + +#ifdef __GMP_SHORT_LIMB +typedef unsigned int mp_limb_t; +typedef int mp_limb_signed_t; +#else +#ifdef _LONG_LONG_LIMB +typedef unsigned long long int mp_limb_t; +typedef long long int mp_limb_signed_t; +#else +typedef unsigned long int mp_limb_t; +typedef long int mp_limb_signed_t; +#endif +#endif +typedef unsigned long int mp_bitcnt_t; + +/* For reference, note that the name __mpz_struct gets into C++ mangled + function names, which means although the "__" suggests an internal, we + must leave this name for binary compatibility. */ +typedef struct +{ + int _mp_alloc; /* Number of *limbs* allocated and pointed + to by the _mp_d field. */ + int _mp_size; /* abs(_mp_size) is the number of limbs the + last field points to. If _mp_size is + negative this is a negative number. */ + mp_limb_t *_mp_d; /* Pointer to the limbs. */ +} __mpz_struct; + +#endif /* __GNU_MP__ */ + + +typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */ +typedef __mpz_struct mpz_t[1]; + +typedef mp_limb_t * mp_ptr; +typedef const mp_limb_t * mp_srcptr; +#if defined (_CRAY) && ! defined (_CRAYMPP) +/* plain `int' is much faster (48 bits) */ +#define __GMP_MP_SIZE_T_INT 1 +typedef int mp_size_t; +typedef int mp_exp_t; +#else +#define __GMP_MP_SIZE_T_INT 0 +typedef long int mp_size_t; +typedef long int mp_exp_t; +#endif + +typedef struct +{ + __mpz_struct _mp_num; + __mpz_struct _mp_den; +} __mpq_struct; + +typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */ +typedef __mpq_struct mpq_t[1]; + +typedef struct +{ + int _mp_prec; /* Max precision, in number of `mp_limb_t's. + Set by mpf_init and modified by + mpf_set_prec. The area pointed to by the + _mp_d field contains `prec' + 1 limbs. */ + int _mp_size; /* abs(_mp_size) is the number of limbs the + last field points to. If _mp_size is + negative this is a negative number. */ + mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */ + mp_limb_t *_mp_d; /* Pointer to the limbs. */ +} __mpf_struct; + +/* typedef __mpf_struct MP_FLOAT; */ +typedef __mpf_struct mpf_t[1]; + +/* Available random number generation algorithms. */ +typedef enum +{ + GMP_RAND_ALG_DEFAULT = 0, + GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */ +} gmp_randalg_t; + +/* Random state struct. */ +typedef struct +{ + mpz_t _mp_seed; /* _mp_d member points to state of the generator. */ + gmp_randalg_t _mp_alg; /* Currently unused. */ + union { + void *_mp_lc; /* Pointer to function pointers structure. */ + } _mp_algdata; +} __gmp_randstate_struct; +typedef __gmp_randstate_struct gmp_randstate_t[1]; + +/* Types for function declarations in gmp files. */ +/* ??? Should not pollute user name space with these ??? */ +typedef const __mpz_struct *mpz_srcptr; +typedef __mpz_struct *mpz_ptr; +typedef const __mpf_struct *mpf_srcptr; +typedef __mpf_struct *mpf_ptr; +typedef const __mpq_struct *mpq_srcptr; +typedef __mpq_struct *mpq_ptr; +typedef __gmp_randstate_struct *gmp_randstate_ptr; +typedef const __gmp_randstate_struct *gmp_randstate_srcptr; + + +#if __GMP_LIBGMP_DLL +#ifdef __GMP_WITHIN_GMPXX +/* compiling to go into a DLL libgmpxx */ +#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT +#else +/* compiling to go into a application which will link to a DLL libgmpxx */ +#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT +#endif +#else +/* all other cases */ +#define __GMP_DECLSPEC_XX +#endif + + +#ifndef __MPN +#define __MPN(x) __gmpn_##x +#endif + +/* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4, + defines EOF but not FILE. */ +#if defined (FILE) \ + || defined (H_STDIO) \ + || defined (_H_STDIO) /* AIX */ \ + || defined (_STDIO_H) /* glibc, Sun, SCO */ \ + || defined (_STDIO_H_) /* BSD, OSF */ \ + || defined (__STDIO_H) /* Borland */ \ + || defined (__STDIO_H__) /* IRIX */ \ + || defined (_STDIO_INCLUDED) /* HPUX */ \ + || defined (__dj_include_stdio_h_) /* DJGPP */ \ + || defined (_FILE_DEFINED) /* Microsoft */ \ + || defined (__STDIO__) /* Apple MPW MrC */ \ + || defined (_MSL_STDIO_H) /* Metrowerks */ \ + || defined (_STDIO_H_INCLUDED) /* QNX4 */ \ + || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \ + || defined (__STDIO_LOADED) /* VMS */ \ + || defined (_STDIO) /* HPE NonStop */ \ + || defined (__DEFINED_FILE) /* musl */ +#define _GMP_H_HAVE_FILE 1 +#endif + +/* In ISO C, if a prototype involving "struct obstack *" is given without + that structure defined, then the struct is scoped down to just the + prototype, causing a conflict if it's subsequently defined for real. So + only give prototypes if we've got obstack.h. */ +#if defined (_OBSTACK_H) /* glibc */ +#define _GMP_H_HAVE_OBSTACK 1 +#endif + +/* The prototypes for gmp_vprintf etc are provided only if va_list is defined, + via an application having included . Usually va_list is a typedef + so can't be tested directly, but C99 specifies that va_start is a macro. + + will define some sort of va_list for vprintf and vfprintf, but + let's not bother trying to use that since it's not standard and since + application uses for gmp_vprintf etc will almost certainly require the + whole anyway. */ + +#ifdef va_start +#define _GMP_H_HAVE_VA_LIST 1 +#endif + +/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */ +#if defined (__GNUC__) && defined (__GNUC_MINOR__) +#define __GMP_GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +#define __GMP_GNUC_PREREQ(maj, min) 0 +#endif + +/* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically + it means a function does nothing but examine its arguments and memory + (global or via arguments) to generate a return value, but changes nothing + and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets + tune/common.c etc turn this off when trying to write timing loops. */ +#if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE) +#define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +#define __GMP_ATTRIBUTE_PURE +#endif + + +/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean + to "g++ -Wold-style-cast". + + Casts in "extern inline" code within an extern "C" block don't induce + these warnings, so __GMP_CAST only needs to be used on documented + macros. */ + +#ifdef __cplusplus +#define __GMP_CAST(type, expr) (static_cast (expr)) +#else +#define __GMP_CAST(type, expr) ((type) (expr)) +#endif + + +/* An empty "throw ()" means the function doesn't throw any C++ exceptions, + this can save some stack frame info in applications. + + Currently it's given only on functions which never divide-by-zero etc, + don't allocate memory, and are expected to never need to allocate memory. + This leaves open the possibility of a C++ throw from a future GMP + exceptions scheme. + + mpz_set_ui etc are omitted to leave open the lazy allocation scheme + described in doc/tasks.html. mpz_get_d etc are omitted to leave open + exceptions for float overflows. + + Note that __GMP_NOTHROW must be given on any inlines the same as on their + prototypes (for g++ at least, where they're used together). Note also + that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like + __GMP_ATTRIBUTE_PURE. */ + +#if defined (__cplusplus) +#if __cplusplus >= 201103L +#define __GMP_NOTHROW noexcept +#else +#define __GMP_NOTHROW throw () +#endif +#else +#define __GMP_NOTHROW +#endif + + +/* PORTME: What other compilers have a useful "extern inline"? "static + inline" would be an acceptable substitute if the compiler (or linker) + discards unused statics. */ + + /* gcc has __inline__ in all modes, including strict ansi. Give a prototype + for an inline too, so as to correctly specify "dllimport" on windows, in + case the function is called rather than inlined. + GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 + inline semantics, unless -fgnu89-inline is used. */ +#ifdef __GNUC__ +#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) \ + || (defined __GNUC_GNU_INLINE__ && defined __cplusplus) +#define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__)) +#else +#define __GMP_EXTERN_INLINE extern __inline__ +#endif +#define __GMP_INLINE_PROTOTYPES 1 +#else +#ifdef __SUNPRO_C +#define __GMP_EXTERN_INLINE static inline +#endif +#endif + +/* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1 + strict ANSI mode. Inlining is done even when not optimizing (ie. -O0 + mode, which is the default), but an unnecessary local copy of foo is + emitted unless -O is used. "extern __inline" is accepted, but the + "extern" appears to be ignored, ie. it becomes a plain global function + but which is inlined within its file. Don't know if all old versions of + DEC C supported __inline, but as a start let's do the right thing for + current versions. */ +#ifdef __DECC +#define __GMP_EXTERN_INLINE static __inline +#endif + +/* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict + ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes + place under -O. Without -O "foo" seems to be emitted whether it's used + or not, which is wasteful. "extern inline foo()" isn't useful, the + "extern" is apparently ignored, so foo is inlined if possible but also + emitted as a global, which causes multiple definition errors when + building a shared libgmp. */ +#ifdef __SCO_VERSION__ +#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \ + && ! defined (__GMP_EXTERN_INLINE) +#define __GMP_EXTERN_INLINE static inline +#endif +#endif + +/* Microsoft's C compiler accepts __inline */ +#ifdef _MSC_VER +#define __GMP_EXTERN_INLINE __inline +#endif + +/* Recent enough Sun C compilers want "inline" */ +#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \ + && ! defined (__GMP_EXTERN_INLINE) +#define __GMP_EXTERN_INLINE inline +#endif + +/* Somewhat older Sun C compilers want "static inline" */ +#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \ + && ! defined (__GMP_EXTERN_INLINE) +#define __GMP_EXTERN_INLINE static inline +#endif + + +/* C++ always has "inline" and since it's a normal feature the linker should + discard duplicate non-inlined copies, or if it doesn't then that's a + problem for everyone, not just GMP. */ +#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE) +#define __GMP_EXTERN_INLINE inline +#endif + +/* Don't do any inlining within a configure run, since if the compiler ends + up emitting copies of the code into the object file it can end up + demanding the various support routines (like mpn_popcount) for linking, + making the "alloca" test and perhaps others fail. And on hppa ia64 a + pre-release gcc 3.2 was seen not respecting the "extern" in "extern + __inline__", triggering this problem too. */ +#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE +#undef __GMP_EXTERN_INLINE +#endif + +/* By default, don't give a prototype when there's going to be an inline + version. Note in particular that Cray C++ objects to the combination of + prototype and inline. */ +#ifdef __GMP_EXTERN_INLINE +#ifndef __GMP_INLINE_PROTOTYPES +#define __GMP_INLINE_PROTOTYPES 0 +#endif +#else +#define __GMP_INLINE_PROTOTYPES 1 +#endif + + +#define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x)) +#define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i)) + + +/* __builtin_expect is in gcc 3.0, and not in 2.95. */ +#if __GMP_GNUC_PREREQ (3,0) +#define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1) +#define __GMP_UNLIKELY(cond) __builtin_expect ((cond) != 0, 0) +#else +#define __GMP_LIKELY(cond) (cond) +#define __GMP_UNLIKELY(cond) (cond) +#endif + +#ifdef _CRAY +#define __GMP_CRAY_Pragma(str) _Pragma (str) +#else +#define __GMP_CRAY_Pragma(str) +#endif + + +/* Allow direct user access to numerator and denominator of an mpq_t object. */ +#define mpq_numref(Q) (&((Q)->_mp_num)) +#define mpq_denref(Q) (&((Q)->_mp_den)) + + +#if defined (__cplusplus) +extern "C" { +using std::FILE; +#endif + +#define mp_set_memory_functions __gmp_set_memory_functions +__GMP_DECLSPEC void mp_set_memory_functions (void *(*) (size_t), + void *(*) (void *, size_t, size_t), + void (*) (void *, size_t)) __GMP_NOTHROW; + +#define mp_get_memory_functions __gmp_get_memory_functions +__GMP_DECLSPEC void mp_get_memory_functions (void *(**) (size_t), + void *(**) (void *, size_t, size_t), + void (**) (void *, size_t)) __GMP_NOTHROW; + +#define mp_bits_per_limb __gmp_bits_per_limb +__GMP_DECLSPEC extern const int mp_bits_per_limb; + +#define gmp_errno __gmp_errno +__GMP_DECLSPEC extern int gmp_errno; + +#define gmp_version __gmp_version +__GMP_DECLSPEC extern const char * const gmp_version; + + +/**************** Random number routines. ****************/ + +/* obsolete */ +#define gmp_randinit __gmp_randinit +__GMP_DECLSPEC void gmp_randinit (gmp_randstate_ptr, gmp_randalg_t, ...); + +#define gmp_randinit_default __gmp_randinit_default +__GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_ptr); + +#define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp +__GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_ptr, mpz_srcptr, unsigned long int, mp_bitcnt_t); + +#define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size +__GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_ptr, mp_bitcnt_t); + +#define gmp_randinit_mt __gmp_randinit_mt +__GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_ptr); + +#define gmp_randinit_set __gmp_randinit_set +__GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_ptr, gmp_randstate_srcptr); + +#define gmp_randseed __gmp_randseed +__GMP_DECLSPEC void gmp_randseed (gmp_randstate_ptr, mpz_srcptr); + +#define gmp_randseed_ui __gmp_randseed_ui +__GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_ptr, unsigned long int); + +#define gmp_randclear __gmp_randclear +__GMP_DECLSPEC void gmp_randclear (gmp_randstate_ptr); + +#define gmp_urandomb_ui __gmp_urandomb_ui +__GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_ptr, unsigned long); + +#define gmp_urandomm_ui __gmp_urandomm_ui +__GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_ptr, unsigned long); + + +/**************** Formatted output routines. ****************/ + +#define gmp_asprintf __gmp_asprintf +__GMP_DECLSPEC int gmp_asprintf (char **, const char *, ...); + +#define gmp_fprintf __gmp_fprintf +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC int gmp_fprintf (FILE *, const char *, ...); +#endif + +#define gmp_obstack_printf __gmp_obstack_printf +#if defined (_GMP_H_HAVE_OBSTACK) +__GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...); +#endif + +#define gmp_obstack_vprintf __gmp_obstack_vprintf +#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list); +#endif + +#define gmp_printf __gmp_printf +__GMP_DECLSPEC int gmp_printf (const char *, ...); + +#define gmp_snprintf __gmp_snprintf +__GMP_DECLSPEC int gmp_snprintf (char *, size_t, const char *, ...); + +#define gmp_sprintf __gmp_sprintf +__GMP_DECLSPEC int gmp_sprintf (char *, const char *, ...); + +#define gmp_vasprintf __gmp_vasprintf +#if defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_vasprintf (char **, const char *, va_list); +#endif + +#define gmp_vfprintf __gmp_vfprintf +#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_vfprintf (FILE *, const char *, va_list); +#endif + +#define gmp_vprintf __gmp_vprintf +#if defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_vprintf (const char *, va_list); +#endif + +#define gmp_vsnprintf __gmp_vsnprintf +#if defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_vsnprintf (char *, size_t, const char *, va_list); +#endif + +#define gmp_vsprintf __gmp_vsprintf +#if defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_vsprintf (char *, const char *, va_list); +#endif + + +/**************** Formatted input routines. ****************/ + +#define gmp_fscanf __gmp_fscanf +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC int gmp_fscanf (FILE *, const char *, ...); +#endif + +#define gmp_scanf __gmp_scanf +__GMP_DECLSPEC int gmp_scanf (const char *, ...); + +#define gmp_sscanf __gmp_sscanf +__GMP_DECLSPEC int gmp_sscanf (const char *, const char *, ...); + +#define gmp_vfscanf __gmp_vfscanf +#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_vfscanf (FILE *, const char *, va_list); +#endif + +#define gmp_vscanf __gmp_vscanf +#if defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_vscanf (const char *, va_list); +#endif + +#define gmp_vsscanf __gmp_vsscanf +#if defined (_GMP_H_HAVE_VA_LIST) +__GMP_DECLSPEC int gmp_vsscanf (const char *, const char *, va_list); +#endif + + +/**************** Integer (i.e. Z) routines. ****************/ + +#define _mpz_realloc __gmpz_realloc +#define mpz_realloc __gmpz_realloc +__GMP_DECLSPEC void *_mpz_realloc (mpz_ptr, mp_size_t); + +#define mpz_abs __gmpz_abs +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs) +__GMP_DECLSPEC void mpz_abs (mpz_ptr, mpz_srcptr); +#endif + +#define mpz_add __gmpz_add +__GMP_DECLSPEC void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_add_ui __gmpz_add_ui +__GMP_DECLSPEC void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_addmul __gmpz_addmul +__GMP_DECLSPEC void mpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_addmul_ui __gmpz_addmul_ui +__GMP_DECLSPEC void mpz_addmul_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_and __gmpz_and +__GMP_DECLSPEC void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_array_init __gmpz_array_init +__GMP_DECLSPEC void mpz_array_init (mpz_ptr, mp_size_t, mp_size_t); + +#define mpz_bin_ui __gmpz_bin_ui +__GMP_DECLSPEC void mpz_bin_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_bin_uiui __gmpz_bin_uiui +__GMP_DECLSPEC void mpz_bin_uiui (mpz_ptr, unsigned long int, unsigned long int); + +#define mpz_cdiv_q __gmpz_cdiv_q +__GMP_DECLSPEC void mpz_cdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp +__GMP_DECLSPEC void mpz_cdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); + +#define mpz_cdiv_q_ui __gmpz_cdiv_q_ui +__GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_cdiv_qr __gmpz_cdiv_qr +__GMP_DECLSPEC void mpz_cdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui +__GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_cdiv_r __gmpz_cdiv_r +__GMP_DECLSPEC void mpz_cdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp +__GMP_DECLSPEC void mpz_cdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); + +#define mpz_cdiv_r_ui __gmpz_cdiv_r_ui +__GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_cdiv_ui __gmpz_cdiv_ui +__GMP_DECLSPEC unsigned long int mpz_cdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; + +#define mpz_clear __gmpz_clear +__GMP_DECLSPEC void mpz_clear (mpz_ptr); + +#define mpz_clears __gmpz_clears +__GMP_DECLSPEC void mpz_clears (mpz_ptr, ...); + +#define mpz_clrbit __gmpz_clrbit +__GMP_DECLSPEC void mpz_clrbit (mpz_ptr, mp_bitcnt_t); + +#define mpz_cmp __gmpz_cmp +__GMP_DECLSPEC int mpz_cmp (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_cmp_d __gmpz_cmp_d +__GMP_DECLSPEC int mpz_cmp_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE; + +#define _mpz_cmp_si __gmpz_cmp_si +__GMP_DECLSPEC int _mpz_cmp_si (mpz_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define _mpz_cmp_ui __gmpz_cmp_ui +__GMP_DECLSPEC int _mpz_cmp_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_cmpabs __gmpz_cmpabs +__GMP_DECLSPEC int mpz_cmpabs (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_cmpabs_d __gmpz_cmpabs_d +__GMP_DECLSPEC int mpz_cmpabs_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE; + +#define mpz_cmpabs_ui __gmpz_cmpabs_ui +__GMP_DECLSPEC int mpz_cmpabs_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_com __gmpz_com +__GMP_DECLSPEC void mpz_com (mpz_ptr, mpz_srcptr); + +#define mpz_combit __gmpz_combit +__GMP_DECLSPEC void mpz_combit (mpz_ptr, mp_bitcnt_t); + +#define mpz_congruent_p __gmpz_congruent_p +__GMP_DECLSPEC int mpz_congruent_p (mpz_srcptr, mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpz_congruent_2exp_p __gmpz_congruent_2exp_p +__GMP_DECLSPEC int mpz_congruent_2exp_p (mpz_srcptr, mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_congruent_ui_p __gmpz_congruent_ui_p +__GMP_DECLSPEC int mpz_congruent_ui_p (mpz_srcptr, unsigned long, unsigned long) __GMP_ATTRIBUTE_PURE; + +#define mpz_divexact __gmpz_divexact +__GMP_DECLSPEC void mpz_divexact (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_divexact_ui __gmpz_divexact_ui +__GMP_DECLSPEC void mpz_divexact_ui (mpz_ptr, mpz_srcptr, unsigned long); + +#define mpz_divisible_p __gmpz_divisible_p +__GMP_DECLSPEC int mpz_divisible_p (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpz_divisible_ui_p __gmpz_divisible_ui_p +__GMP_DECLSPEC int mpz_divisible_ui_p (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE; + +#define mpz_divisible_2exp_p __gmpz_divisible_2exp_p +__GMP_DECLSPEC int mpz_divisible_2exp_p (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_dump __gmpz_dump +__GMP_DECLSPEC void mpz_dump (mpz_srcptr); + +#define mpz_export __gmpz_export +__GMP_DECLSPEC void *mpz_export (void *, size_t *, int, size_t, int, size_t, mpz_srcptr); + +#define mpz_fac_ui __gmpz_fac_ui +__GMP_DECLSPEC void mpz_fac_ui (mpz_ptr, unsigned long int); + +#define mpz_2fac_ui __gmpz_2fac_ui +__GMP_DECLSPEC void mpz_2fac_ui (mpz_ptr, unsigned long int); + +#define mpz_mfac_uiui __gmpz_mfac_uiui +__GMP_DECLSPEC void mpz_mfac_uiui (mpz_ptr, unsigned long int, unsigned long int); + +#define mpz_primorial_ui __gmpz_primorial_ui +__GMP_DECLSPEC void mpz_primorial_ui (mpz_ptr, unsigned long int); + +#define mpz_fdiv_q __gmpz_fdiv_q +__GMP_DECLSPEC void mpz_fdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp +__GMP_DECLSPEC void mpz_fdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); + +#define mpz_fdiv_q_ui __gmpz_fdiv_q_ui +__GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_fdiv_qr __gmpz_fdiv_qr +__GMP_DECLSPEC void mpz_fdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui +__GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_fdiv_r __gmpz_fdiv_r +__GMP_DECLSPEC void mpz_fdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp +__GMP_DECLSPEC void mpz_fdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); + +#define mpz_fdiv_r_ui __gmpz_fdiv_r_ui +__GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_fdiv_ui __gmpz_fdiv_ui +__GMP_DECLSPEC unsigned long int mpz_fdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; + +#define mpz_fib_ui __gmpz_fib_ui +__GMP_DECLSPEC void mpz_fib_ui (mpz_ptr, unsigned long int); + +#define mpz_fib2_ui __gmpz_fib2_ui +__GMP_DECLSPEC void mpz_fib2_ui (mpz_ptr, mpz_ptr, unsigned long int); + +#define mpz_fits_sint_p __gmpz_fits_sint_p +__GMP_DECLSPEC int mpz_fits_sint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_fits_slong_p __gmpz_fits_slong_p +__GMP_DECLSPEC int mpz_fits_slong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_fits_sshort_p __gmpz_fits_sshort_p +__GMP_DECLSPEC int mpz_fits_sshort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_fits_uint_p __gmpz_fits_uint_p +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p) +__GMP_DECLSPEC int mpz_fits_uint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpz_fits_ulong_p __gmpz_fits_ulong_p +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p) +__GMP_DECLSPEC int mpz_fits_ulong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpz_fits_ushort_p __gmpz_fits_ushort_p +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p) +__GMP_DECLSPEC int mpz_fits_ushort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpz_gcd __gmpz_gcd +__GMP_DECLSPEC void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_gcd_ui __gmpz_gcd_ui +__GMP_DECLSPEC unsigned long int mpz_gcd_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_gcdext __gmpz_gcdext +__GMP_DECLSPEC void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_get_d __gmpz_get_d +__GMP_DECLSPEC double mpz_get_d (mpz_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpz_get_d_2exp __gmpz_get_d_2exp +__GMP_DECLSPEC double mpz_get_d_2exp (signed long int *, mpz_srcptr); + +#define mpz_get_si __gmpz_get_si +__GMP_DECLSPEC /* signed */ long int mpz_get_si (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_get_str __gmpz_get_str +__GMP_DECLSPEC char *mpz_get_str (char *, int, mpz_srcptr); + +#define mpz_get_ui __gmpz_get_ui +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui) +__GMP_DECLSPEC unsigned long int mpz_get_ui (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpz_getlimbn __gmpz_getlimbn +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn) +__GMP_DECLSPEC mp_limb_t mpz_getlimbn (mpz_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpz_hamdist __gmpz_hamdist +__GMP_DECLSPEC mp_bitcnt_t mpz_hamdist (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_import __gmpz_import +__GMP_DECLSPEC void mpz_import (mpz_ptr, size_t, int, size_t, int, size_t, const void *); + +#define mpz_init __gmpz_init +__GMP_DECLSPEC void mpz_init (mpz_ptr) __GMP_NOTHROW; + +#define mpz_init2 __gmpz_init2 +__GMP_DECLSPEC void mpz_init2 (mpz_ptr, mp_bitcnt_t); + +#define mpz_inits __gmpz_inits +__GMP_DECLSPEC void mpz_inits (mpz_ptr, ...) __GMP_NOTHROW; + +#define mpz_init_set __gmpz_init_set +__GMP_DECLSPEC void mpz_init_set (mpz_ptr, mpz_srcptr); + +#define mpz_init_set_d __gmpz_init_set_d +__GMP_DECLSPEC void mpz_init_set_d (mpz_ptr, double); + +#define mpz_init_set_si __gmpz_init_set_si +__GMP_DECLSPEC void mpz_init_set_si (mpz_ptr, signed long int); + +#define mpz_init_set_str __gmpz_init_set_str +__GMP_DECLSPEC int mpz_init_set_str (mpz_ptr, const char *, int); + +#define mpz_init_set_ui __gmpz_init_set_ui +__GMP_DECLSPEC void mpz_init_set_ui (mpz_ptr, unsigned long int); + +#define mpz_inp_raw __gmpz_inp_raw +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC size_t mpz_inp_raw (mpz_ptr, FILE *); +#endif + +#define mpz_inp_str __gmpz_inp_str +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC size_t mpz_inp_str (mpz_ptr, FILE *, int); +#endif + +#define mpz_invert __gmpz_invert +__GMP_DECLSPEC int mpz_invert (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_ior __gmpz_ior +__GMP_DECLSPEC void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_jacobi __gmpz_jacobi +__GMP_DECLSPEC int mpz_jacobi (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpz_kronecker mpz_jacobi /* alias */ + +#define mpz_kronecker_si __gmpz_kronecker_si +__GMP_DECLSPEC int mpz_kronecker_si (mpz_srcptr, long) __GMP_ATTRIBUTE_PURE; + +#define mpz_kronecker_ui __gmpz_kronecker_ui +__GMP_DECLSPEC int mpz_kronecker_ui (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE; + +#define mpz_si_kronecker __gmpz_si_kronecker +__GMP_DECLSPEC int mpz_si_kronecker (long, mpz_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpz_ui_kronecker __gmpz_ui_kronecker +__GMP_DECLSPEC int mpz_ui_kronecker (unsigned long, mpz_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpz_lcm __gmpz_lcm +__GMP_DECLSPEC void mpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_lcm_ui __gmpz_lcm_ui +__GMP_DECLSPEC void mpz_lcm_ui (mpz_ptr, mpz_srcptr, unsigned long); + +#define mpz_legendre mpz_jacobi /* alias */ + +#define mpz_lucnum_ui __gmpz_lucnum_ui +__GMP_DECLSPEC void mpz_lucnum_ui (mpz_ptr, unsigned long int); + +#define mpz_lucnum2_ui __gmpz_lucnum2_ui +__GMP_DECLSPEC void mpz_lucnum2_ui (mpz_ptr, mpz_ptr, unsigned long int); + +#define mpz_millerrabin __gmpz_millerrabin +__GMP_DECLSPEC int mpz_millerrabin (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE; + +#define mpz_mod __gmpz_mod +__GMP_DECLSPEC void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */ + +#define mpz_mul __gmpz_mul +__GMP_DECLSPEC void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_mul_2exp __gmpz_mul_2exp +__GMP_DECLSPEC void mpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); + +#define mpz_mul_si __gmpz_mul_si +__GMP_DECLSPEC void mpz_mul_si (mpz_ptr, mpz_srcptr, long int); + +#define mpz_mul_ui __gmpz_mul_ui +__GMP_DECLSPEC void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_neg __gmpz_neg +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg) +__GMP_DECLSPEC void mpz_neg (mpz_ptr, mpz_srcptr); +#endif + +#define mpz_nextprime __gmpz_nextprime +__GMP_DECLSPEC void mpz_nextprime (mpz_ptr, mpz_srcptr); + +#define mpz_prevprime __gmpz_prevprime +__GMP_DECLSPEC int mpz_prevprime (mpz_ptr, mpz_srcptr); + +#define mpz_out_raw __gmpz_out_raw +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC size_t mpz_out_raw (FILE *, mpz_srcptr); +#endif + +#define mpz_out_str __gmpz_out_str +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC size_t mpz_out_str (FILE *, int, mpz_srcptr); +#endif + +#define mpz_perfect_power_p __gmpz_perfect_power_p +__GMP_DECLSPEC int mpz_perfect_power_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpz_perfect_square_p __gmpz_perfect_square_p +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p) +__GMP_DECLSPEC int mpz_perfect_square_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE; +#endif + +#define mpz_popcount __gmpz_popcount +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount) +__GMP_DECLSPEC mp_bitcnt_t mpz_popcount (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpz_pow_ui __gmpz_pow_ui +__GMP_DECLSPEC void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_powm __gmpz_powm +__GMP_DECLSPEC void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); + +#define mpz_powm_sec __gmpz_powm_sec +__GMP_DECLSPEC void mpz_powm_sec (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); + +#define mpz_powm_ui __gmpz_powm_ui +__GMP_DECLSPEC void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr); + +#define mpz_probab_prime_p __gmpz_probab_prime_p +__GMP_DECLSPEC int mpz_probab_prime_p (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE; + +#define mpz_random __gmpz_random +__GMP_DECLSPEC void mpz_random (mpz_ptr, mp_size_t); + +#define mpz_random2 __gmpz_random2 +__GMP_DECLSPEC void mpz_random2 (mpz_ptr, mp_size_t); + +#define mpz_realloc2 __gmpz_realloc2 +__GMP_DECLSPEC void mpz_realloc2 (mpz_ptr, mp_bitcnt_t); + +#define mpz_remove __gmpz_remove +__GMP_DECLSPEC mp_bitcnt_t mpz_remove (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_root __gmpz_root +__GMP_DECLSPEC int mpz_root (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_rootrem __gmpz_rootrem +__GMP_DECLSPEC void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_rrandomb __gmpz_rrandomb +__GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_ptr, mp_bitcnt_t); + +#define mpz_scan0 __gmpz_scan0 +__GMP_DECLSPEC mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_scan1 __gmpz_scan1 +__GMP_DECLSPEC mp_bitcnt_t mpz_scan1 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_set __gmpz_set +__GMP_DECLSPEC void mpz_set (mpz_ptr, mpz_srcptr); + +#define mpz_set_d __gmpz_set_d +__GMP_DECLSPEC void mpz_set_d (mpz_ptr, double); + +#define mpz_set_f __gmpz_set_f +__GMP_DECLSPEC void mpz_set_f (mpz_ptr, mpf_srcptr); + +#define mpz_set_q __gmpz_set_q +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q) +__GMP_DECLSPEC void mpz_set_q (mpz_ptr, mpq_srcptr); +#endif + +#define mpz_set_si __gmpz_set_si +__GMP_DECLSPEC void mpz_set_si (mpz_ptr, signed long int); + +#define mpz_set_str __gmpz_set_str +__GMP_DECLSPEC int mpz_set_str (mpz_ptr, const char *, int); + +#define mpz_set_ui __gmpz_set_ui +__GMP_DECLSPEC void mpz_set_ui (mpz_ptr, unsigned long int); + +#define mpz_setbit __gmpz_setbit +__GMP_DECLSPEC void mpz_setbit (mpz_ptr, mp_bitcnt_t); + +#define mpz_size __gmpz_size +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size) +__GMP_DECLSPEC size_t mpz_size (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpz_sizeinbase __gmpz_sizeinbase +__GMP_DECLSPEC size_t mpz_sizeinbase (mpz_srcptr, int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_sqrt __gmpz_sqrt +__GMP_DECLSPEC void mpz_sqrt (mpz_ptr, mpz_srcptr); + +#define mpz_sqrtrem __gmpz_sqrtrem +__GMP_DECLSPEC void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr); + +#define mpz_sub __gmpz_sub +__GMP_DECLSPEC void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_sub_ui __gmpz_sub_ui +__GMP_DECLSPEC void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_ui_sub __gmpz_ui_sub +__GMP_DECLSPEC void mpz_ui_sub (mpz_ptr, unsigned long int, mpz_srcptr); + +#define mpz_submul __gmpz_submul +__GMP_DECLSPEC void mpz_submul (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_submul_ui __gmpz_submul_ui +__GMP_DECLSPEC void mpz_submul_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_swap __gmpz_swap +__GMP_DECLSPEC void mpz_swap (mpz_ptr, mpz_ptr) __GMP_NOTHROW; + +#define mpz_tdiv_ui __gmpz_tdiv_ui +__GMP_DECLSPEC unsigned long int mpz_tdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; + +#define mpz_tdiv_q __gmpz_tdiv_q +__GMP_DECLSPEC void mpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp +__GMP_DECLSPEC void mpz_tdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); + +#define mpz_tdiv_q_ui __gmpz_tdiv_q_ui +__GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_tdiv_qr __gmpz_tdiv_qr +__GMP_DECLSPEC void mpz_tdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui +__GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_tdiv_r __gmpz_tdiv_r +__GMP_DECLSPEC void mpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp +__GMP_DECLSPEC void mpz_tdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); + +#define mpz_tdiv_r_ui __gmpz_tdiv_r_ui +__GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); + +#define mpz_tstbit __gmpz_tstbit +__GMP_DECLSPEC int mpz_tstbit (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpz_ui_pow_ui __gmpz_ui_pow_ui +__GMP_DECLSPEC void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int); + +#define mpz_urandomb __gmpz_urandomb +__GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_ptr, mp_bitcnt_t); + +#define mpz_urandomm __gmpz_urandomm +__GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_ptr, mpz_srcptr); + +#define mpz_xor __gmpz_xor +#define mpz_eor __gmpz_xor +__GMP_DECLSPEC void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr); + +#define mpz_limbs_read __gmpz_limbs_read +__GMP_DECLSPEC mp_srcptr mpz_limbs_read (mpz_srcptr); + +#define mpz_limbs_write __gmpz_limbs_write +__GMP_DECLSPEC mp_ptr mpz_limbs_write (mpz_ptr, mp_size_t); + +#define mpz_limbs_modify __gmpz_limbs_modify +__GMP_DECLSPEC mp_ptr mpz_limbs_modify (mpz_ptr, mp_size_t); + +#define mpz_limbs_finish __gmpz_limbs_finish +__GMP_DECLSPEC void mpz_limbs_finish (mpz_ptr, mp_size_t); + +#define mpz_roinit_n __gmpz_roinit_n +__GMP_DECLSPEC mpz_srcptr mpz_roinit_n (mpz_ptr, mp_srcptr, mp_size_t); + +#define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }} + +/**************** Rational (i.e. Q) routines. ****************/ + +#define mpq_abs __gmpq_abs +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs) +__GMP_DECLSPEC void mpq_abs (mpq_ptr, mpq_srcptr); +#endif + +#define mpq_add __gmpq_add +__GMP_DECLSPEC void mpq_add (mpq_ptr, mpq_srcptr, mpq_srcptr); + +#define mpq_canonicalize __gmpq_canonicalize +__GMP_DECLSPEC void mpq_canonicalize (mpq_ptr); + +#define mpq_clear __gmpq_clear +__GMP_DECLSPEC void mpq_clear (mpq_ptr); + +#define mpq_clears __gmpq_clears +__GMP_DECLSPEC void mpq_clears (mpq_ptr, ...); + +#define mpq_cmp __gmpq_cmp +__GMP_DECLSPEC int mpq_cmp (mpq_srcptr, mpq_srcptr) __GMP_ATTRIBUTE_PURE; + +#define _mpq_cmp_si __gmpq_cmp_si +__GMP_DECLSPEC int _mpq_cmp_si (mpq_srcptr, long, unsigned long) __GMP_ATTRIBUTE_PURE; + +#define _mpq_cmp_ui __gmpq_cmp_ui +__GMP_DECLSPEC int _mpq_cmp_ui (mpq_srcptr, unsigned long int, unsigned long int) __GMP_ATTRIBUTE_PURE; + +#define mpq_cmp_z __gmpq_cmp_z +__GMP_DECLSPEC int mpq_cmp_z (mpq_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpq_div __gmpq_div +__GMP_DECLSPEC void mpq_div (mpq_ptr, mpq_srcptr, mpq_srcptr); + +#define mpq_div_2exp __gmpq_div_2exp +__GMP_DECLSPEC void mpq_div_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t); + +#define mpq_equal __gmpq_equal +__GMP_DECLSPEC int mpq_equal (mpq_srcptr, mpq_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpq_get_num __gmpq_get_num +__GMP_DECLSPEC void mpq_get_num (mpz_ptr, mpq_srcptr); + +#define mpq_get_den __gmpq_get_den +__GMP_DECLSPEC void mpq_get_den (mpz_ptr, mpq_srcptr); + +#define mpq_get_d __gmpq_get_d +__GMP_DECLSPEC double mpq_get_d (mpq_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpq_get_str __gmpq_get_str +__GMP_DECLSPEC char *mpq_get_str (char *, int, mpq_srcptr); + +#define mpq_init __gmpq_init +__GMP_DECLSPEC void mpq_init (mpq_ptr); + +#define mpq_inits __gmpq_inits +__GMP_DECLSPEC void mpq_inits (mpq_ptr, ...); + +#define mpq_inp_str __gmpq_inp_str +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC size_t mpq_inp_str (mpq_ptr, FILE *, int); +#endif + +#define mpq_inv __gmpq_inv +__GMP_DECLSPEC void mpq_inv (mpq_ptr, mpq_srcptr); + +#define mpq_mul __gmpq_mul +__GMP_DECLSPEC void mpq_mul (mpq_ptr, mpq_srcptr, mpq_srcptr); + +#define mpq_mul_2exp __gmpq_mul_2exp +__GMP_DECLSPEC void mpq_mul_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t); + +#define mpq_neg __gmpq_neg +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg) +__GMP_DECLSPEC void mpq_neg (mpq_ptr, mpq_srcptr); +#endif + +#define mpq_out_str __gmpq_out_str +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC size_t mpq_out_str (FILE *, int, mpq_srcptr); +#endif + +#define mpq_set __gmpq_set +__GMP_DECLSPEC void mpq_set (mpq_ptr, mpq_srcptr); + +#define mpq_set_d __gmpq_set_d +__GMP_DECLSPEC void mpq_set_d (mpq_ptr, double); + +#define mpq_set_den __gmpq_set_den +__GMP_DECLSPEC void mpq_set_den (mpq_ptr, mpz_srcptr); + +#define mpq_set_f __gmpq_set_f +__GMP_DECLSPEC void mpq_set_f (mpq_ptr, mpf_srcptr); + +#define mpq_set_num __gmpq_set_num +__GMP_DECLSPEC void mpq_set_num (mpq_ptr, mpz_srcptr); + +#define mpq_set_si __gmpq_set_si +__GMP_DECLSPEC void mpq_set_si (mpq_ptr, signed long int, unsigned long int); + +#define mpq_set_str __gmpq_set_str +__GMP_DECLSPEC int mpq_set_str (mpq_ptr, const char *, int); + +#define mpq_set_ui __gmpq_set_ui +__GMP_DECLSPEC void mpq_set_ui (mpq_ptr, unsigned long int, unsigned long int); + +#define mpq_set_z __gmpq_set_z +__GMP_DECLSPEC void mpq_set_z (mpq_ptr, mpz_srcptr); + +#define mpq_sub __gmpq_sub +__GMP_DECLSPEC void mpq_sub (mpq_ptr, mpq_srcptr, mpq_srcptr); + +#define mpq_swap __gmpq_swap +__GMP_DECLSPEC void mpq_swap (mpq_ptr, mpq_ptr) __GMP_NOTHROW; + + +/**************** Float (i.e. F) routines. ****************/ + +#define mpf_abs __gmpf_abs +__GMP_DECLSPEC void mpf_abs (mpf_ptr, mpf_srcptr); + +#define mpf_add __gmpf_add +__GMP_DECLSPEC void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr); + +#define mpf_add_ui __gmpf_add_ui +__GMP_DECLSPEC void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned long int); +#define mpf_ceil __gmpf_ceil +__GMP_DECLSPEC void mpf_ceil (mpf_ptr, mpf_srcptr); + +#define mpf_clear __gmpf_clear +__GMP_DECLSPEC void mpf_clear (mpf_ptr); + +#define mpf_clears __gmpf_clears +__GMP_DECLSPEC void mpf_clears (mpf_ptr, ...); + +#define mpf_cmp __gmpf_cmp +__GMP_DECLSPEC int mpf_cmp (mpf_srcptr, mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_cmp_z __gmpf_cmp_z +__GMP_DECLSPEC int mpf_cmp_z (mpf_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_cmp_d __gmpf_cmp_d +__GMP_DECLSPEC int mpf_cmp_d (mpf_srcptr, double) __GMP_ATTRIBUTE_PURE; + +#define mpf_cmp_si __gmpf_cmp_si +__GMP_DECLSPEC int mpf_cmp_si (mpf_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_cmp_ui __gmpf_cmp_ui +__GMP_DECLSPEC int mpf_cmp_ui (mpf_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_div __gmpf_div +__GMP_DECLSPEC void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr); + +#define mpf_div_2exp __gmpf_div_2exp +__GMP_DECLSPEC void mpf_div_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t); + +#define mpf_div_ui __gmpf_div_ui +__GMP_DECLSPEC void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned long int); + +#define mpf_dump __gmpf_dump +__GMP_DECLSPEC void mpf_dump (mpf_srcptr); + +#define mpf_eq __gmpf_eq +__GMP_DECLSPEC int mpf_eq (mpf_srcptr, mpf_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; + +#define mpf_fits_sint_p __gmpf_fits_sint_p +__GMP_DECLSPEC int mpf_fits_sint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_fits_slong_p __gmpf_fits_slong_p +__GMP_DECLSPEC int mpf_fits_slong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_fits_sshort_p __gmpf_fits_sshort_p +__GMP_DECLSPEC int mpf_fits_sshort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_fits_uint_p __gmpf_fits_uint_p +__GMP_DECLSPEC int mpf_fits_uint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_fits_ulong_p __gmpf_fits_ulong_p +__GMP_DECLSPEC int mpf_fits_ulong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_fits_ushort_p __gmpf_fits_ushort_p +__GMP_DECLSPEC int mpf_fits_ushort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_floor __gmpf_floor +__GMP_DECLSPEC void mpf_floor (mpf_ptr, mpf_srcptr); + +#define mpf_get_d __gmpf_get_d +__GMP_DECLSPEC double mpf_get_d (mpf_srcptr) __GMP_ATTRIBUTE_PURE; + +#define mpf_get_d_2exp __gmpf_get_d_2exp +__GMP_DECLSPEC double mpf_get_d_2exp (signed long int *, mpf_srcptr); + +#define mpf_get_default_prec __gmpf_get_default_prec +__GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec (void) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_get_prec __gmpf_get_prec +__GMP_DECLSPEC mp_bitcnt_t mpf_get_prec (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_get_si __gmpf_get_si +__GMP_DECLSPEC long mpf_get_si (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_get_str __gmpf_get_str +__GMP_DECLSPEC char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr); + +#define mpf_get_ui __gmpf_get_ui +__GMP_DECLSPEC unsigned long mpf_get_ui (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_init __gmpf_init +__GMP_DECLSPEC void mpf_init (mpf_ptr); + +#define mpf_init2 __gmpf_init2 +__GMP_DECLSPEC void mpf_init2 (mpf_ptr, mp_bitcnt_t); + +#define mpf_inits __gmpf_inits +__GMP_DECLSPEC void mpf_inits (mpf_ptr, ...); + +#define mpf_init_set __gmpf_init_set +__GMP_DECLSPEC void mpf_init_set (mpf_ptr, mpf_srcptr); + +#define mpf_init_set_d __gmpf_init_set_d +__GMP_DECLSPEC void mpf_init_set_d (mpf_ptr, double); + +#define mpf_init_set_si __gmpf_init_set_si +__GMP_DECLSPEC void mpf_init_set_si (mpf_ptr, signed long int); + +#define mpf_init_set_str __gmpf_init_set_str +__GMP_DECLSPEC int mpf_init_set_str (mpf_ptr, const char *, int); + +#define mpf_init_set_ui __gmpf_init_set_ui +__GMP_DECLSPEC void mpf_init_set_ui (mpf_ptr, unsigned long int); + +#define mpf_inp_str __gmpf_inp_str +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC size_t mpf_inp_str (mpf_ptr, FILE *, int); +#endif + +#define mpf_integer_p __gmpf_integer_p +__GMP_DECLSPEC int mpf_integer_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_mul __gmpf_mul +__GMP_DECLSPEC void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr); + +#define mpf_mul_2exp __gmpf_mul_2exp +__GMP_DECLSPEC void mpf_mul_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t); + +#define mpf_mul_ui __gmpf_mul_ui +__GMP_DECLSPEC void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned long int); + +#define mpf_neg __gmpf_neg +__GMP_DECLSPEC void mpf_neg (mpf_ptr, mpf_srcptr); + +#define mpf_out_str __gmpf_out_str +#ifdef _GMP_H_HAVE_FILE +__GMP_DECLSPEC size_t mpf_out_str (FILE *, int, size_t, mpf_srcptr); +#endif + +#define mpf_pow_ui __gmpf_pow_ui +__GMP_DECLSPEC void mpf_pow_ui (mpf_ptr, mpf_srcptr, unsigned long int); + +#define mpf_random2 __gmpf_random2 +__GMP_DECLSPEC void mpf_random2 (mpf_ptr, mp_size_t, mp_exp_t); + +#define mpf_reldiff __gmpf_reldiff +__GMP_DECLSPEC void mpf_reldiff (mpf_ptr, mpf_srcptr, mpf_srcptr); + +#define mpf_set __gmpf_set +__GMP_DECLSPEC void mpf_set (mpf_ptr, mpf_srcptr); + +#define mpf_set_d __gmpf_set_d +__GMP_DECLSPEC void mpf_set_d (mpf_ptr, double); + +#define mpf_set_default_prec __gmpf_set_default_prec +__GMP_DECLSPEC void mpf_set_default_prec (mp_bitcnt_t) __GMP_NOTHROW; + +#define mpf_set_prec __gmpf_set_prec +__GMP_DECLSPEC void mpf_set_prec (mpf_ptr, mp_bitcnt_t); + +#define mpf_set_prec_raw __gmpf_set_prec_raw +__GMP_DECLSPEC void mpf_set_prec_raw (mpf_ptr, mp_bitcnt_t) __GMP_NOTHROW; + +#define mpf_set_q __gmpf_set_q +__GMP_DECLSPEC void mpf_set_q (mpf_ptr, mpq_srcptr); + +#define mpf_set_si __gmpf_set_si +__GMP_DECLSPEC void mpf_set_si (mpf_ptr, signed long int); + +#define mpf_set_str __gmpf_set_str +__GMP_DECLSPEC int mpf_set_str (mpf_ptr, const char *, int); + +#define mpf_set_ui __gmpf_set_ui +__GMP_DECLSPEC void mpf_set_ui (mpf_ptr, unsigned long int); + +#define mpf_set_z __gmpf_set_z +__GMP_DECLSPEC void mpf_set_z (mpf_ptr, mpz_srcptr); + +#define mpf_size __gmpf_size +__GMP_DECLSPEC size_t mpf_size (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpf_sqrt __gmpf_sqrt +__GMP_DECLSPEC void mpf_sqrt (mpf_ptr, mpf_srcptr); + +#define mpf_sqrt_ui __gmpf_sqrt_ui +__GMP_DECLSPEC void mpf_sqrt_ui (mpf_ptr, unsigned long int); + +#define mpf_sub __gmpf_sub +__GMP_DECLSPEC void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr); + +#define mpf_sub_ui __gmpf_sub_ui +__GMP_DECLSPEC void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned long int); + +#define mpf_swap __gmpf_swap +__GMP_DECLSPEC void mpf_swap (mpf_ptr, mpf_ptr) __GMP_NOTHROW; + +#define mpf_trunc __gmpf_trunc +__GMP_DECLSPEC void mpf_trunc (mpf_ptr, mpf_srcptr); + +#define mpf_ui_div __gmpf_ui_div +__GMP_DECLSPEC void mpf_ui_div (mpf_ptr, unsigned long int, mpf_srcptr); + +#define mpf_ui_sub __gmpf_ui_sub +__GMP_DECLSPEC void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr); + +#define mpf_urandomb __gmpf_urandomb +__GMP_DECLSPEC void mpf_urandomb (mpf_ptr, gmp_randstate_ptr, mp_bitcnt_t); + + +/************ Low level positive-integer (i.e. N) routines. ************/ + +/* This is ugly, but we need to make user calls reach the prefixed function. */ + +#define mpn_add __MPN(add) +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add) +__GMP_DECLSPEC mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); +#endif + +#define mpn_add_1 __MPN(add_1) +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1) +__GMP_DECLSPEC mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW; +#endif + +#define mpn_add_n __MPN(add_n) +__GMP_DECLSPEC mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); + +#define mpn_addmul_1 __MPN(addmul_1) +__GMP_DECLSPEC mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); + +#define mpn_cmp __MPN(cmp) +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp) +__GMP_DECLSPEC int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpn_zero_p __MPN(zero_p) +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_zero_p) +__GMP_DECLSPEC int mpn_zero_p (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; +#endif + +#define mpn_divexact_1 __MPN(divexact_1) +__GMP_DECLSPEC void mpn_divexact_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); + +#define mpn_divexact_by3(dst,src,size) \ + mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0)) + +#define mpn_divexact_by3c __MPN(divexact_by3c) +__GMP_DECLSPEC mp_limb_t mpn_divexact_by3c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); + +#define mpn_divmod_1(qp,np,nsize,dlimb) \ + mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb) + +#define mpn_divrem __MPN(divrem) +__GMP_DECLSPEC mp_limb_t mpn_divrem (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t); + +#define mpn_divrem_1 __MPN(divrem_1) +__GMP_DECLSPEC mp_limb_t mpn_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); + +#define mpn_divrem_2 __MPN(divrem_2) +__GMP_DECLSPEC mp_limb_t mpn_divrem_2 (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr); + +#define mpn_div_qr_1 __MPN(div_qr_1) +__GMP_DECLSPEC mp_limb_t mpn_div_qr_1 (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t); + +#define mpn_div_qr_2 __MPN(div_qr_2) +__GMP_DECLSPEC mp_limb_t mpn_div_qr_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); + +#define mpn_gcd __MPN(gcd) +__GMP_DECLSPEC mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t); + +#define mpn_gcd_11 __MPN(gcd_11) +__GMP_DECLSPEC mp_limb_t mpn_gcd_11 (mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_gcd_1 __MPN(gcd_1) +__GMP_DECLSPEC mp_limb_t mpn_gcd_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_gcdext_1 __MPN(gcdext_1) +__GMP_DECLSPEC mp_limb_t mpn_gcdext_1 (mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t); + +#define mpn_gcdext __MPN(gcdext) +__GMP_DECLSPEC mp_size_t mpn_gcdext (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t); + +#define mpn_get_str __MPN(get_str) +__GMP_DECLSPEC size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t); + +#define mpn_hamdist __MPN(hamdist) +__GMP_DECLSPEC mp_bitcnt_t mpn_hamdist (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpn_lshift __MPN(lshift) +__GMP_DECLSPEC mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); + +#define mpn_mod_1 __MPN(mod_1) +__GMP_DECLSPEC mp_limb_t mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_mul __MPN(mul) +__GMP_DECLSPEC mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); + +#define mpn_mul_1 __MPN(mul_1) +__GMP_DECLSPEC mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); + +#define mpn_mul_n __MPN(mul_n) +__GMP_DECLSPEC void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); + +#define mpn_sqr __MPN(sqr) +__GMP_DECLSPEC void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t); + +#define mpn_neg __MPN(neg) +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_neg) +__GMP_DECLSPEC mp_limb_t mpn_neg (mp_ptr, mp_srcptr, mp_size_t); +#endif + +#define mpn_com __MPN(com) +__GMP_DECLSPEC void mpn_com (mp_ptr, mp_srcptr, mp_size_t); + +#define mpn_perfect_square_p __MPN(perfect_square_p) +__GMP_DECLSPEC int mpn_perfect_square_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_perfect_power_p __MPN(perfect_power_p) +__GMP_DECLSPEC int mpn_perfect_power_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_popcount __MPN(popcount) +__GMP_DECLSPEC mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; + +#define mpn_pow_1 __MPN(pow_1) +__GMP_DECLSPEC mp_size_t mpn_pow_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); + +/* undocumented now, but retained here for upward compatibility */ +#define mpn_preinv_mod_1 __MPN(preinv_mod_1) +__GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_random __MPN(random) +__GMP_DECLSPEC void mpn_random (mp_ptr, mp_size_t); + +#define mpn_random2 __MPN(random2) +__GMP_DECLSPEC void mpn_random2 (mp_ptr, mp_size_t); + +#define mpn_rshift __MPN(rshift) +__GMP_DECLSPEC mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); + +#define mpn_scan0 __MPN(scan0) +__GMP_DECLSPEC mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_scan1 __MPN(scan1) +__GMP_DECLSPEC mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_set_str __MPN(set_str) +__GMP_DECLSPEC mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int); + +#define mpn_sizeinbase __MPN(sizeinbase) +__GMP_DECLSPEC size_t mpn_sizeinbase (mp_srcptr, mp_size_t, int); + +#define mpn_sqrtrem __MPN(sqrtrem) +__GMP_DECLSPEC mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t); + +#define mpn_sub __MPN(sub) +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub) +__GMP_DECLSPEC mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); +#endif + +#define mpn_sub_1 __MPN(sub_1) +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1) +__GMP_DECLSPEC mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW; +#endif + +#define mpn_sub_n __MPN(sub_n) +__GMP_DECLSPEC mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); + +#define mpn_submul_1 __MPN(submul_1) +__GMP_DECLSPEC mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); + +#define mpn_tdiv_qr __MPN(tdiv_qr) +__GMP_DECLSPEC void mpn_tdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); + +#define mpn_and_n __MPN(and_n) +__GMP_DECLSPEC void mpn_and_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); +#define mpn_andn_n __MPN(andn_n) +__GMP_DECLSPEC void mpn_andn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); +#define mpn_nand_n __MPN(nand_n) +__GMP_DECLSPEC void mpn_nand_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); +#define mpn_ior_n __MPN(ior_n) +__GMP_DECLSPEC void mpn_ior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); +#define mpn_iorn_n __MPN(iorn_n) +__GMP_DECLSPEC void mpn_iorn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); +#define mpn_nior_n __MPN(nior_n) +__GMP_DECLSPEC void mpn_nior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); +#define mpn_xor_n __MPN(xor_n) +__GMP_DECLSPEC void mpn_xor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); +#define mpn_xnor_n __MPN(xnor_n) +__GMP_DECLSPEC void mpn_xnor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); + +#define mpn_copyi __MPN(copyi) +__GMP_DECLSPEC void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t); +#define mpn_copyd __MPN(copyd) +__GMP_DECLSPEC void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t); +#define mpn_zero __MPN(zero) +__GMP_DECLSPEC void mpn_zero (mp_ptr, mp_size_t); + +#define mpn_cnd_add_n __MPN(cnd_add_n) +__GMP_DECLSPEC mp_limb_t mpn_cnd_add_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); +#define mpn_cnd_sub_n __MPN(cnd_sub_n) +__GMP_DECLSPEC mp_limb_t mpn_cnd_sub_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); + +#define mpn_sec_add_1 __MPN(sec_add_1) +__GMP_DECLSPEC mp_limb_t mpn_sec_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); +#define mpn_sec_add_1_itch __MPN(sec_add_1_itch) +__GMP_DECLSPEC mp_size_t mpn_sec_add_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_sec_sub_1 __MPN(sec_sub_1) +__GMP_DECLSPEC mp_limb_t mpn_sec_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); +#define mpn_sec_sub_1_itch __MPN(sec_sub_1_itch) +__GMP_DECLSPEC mp_size_t mpn_sec_sub_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_cnd_swap __MPN(cnd_swap) +__GMP_DECLSPEC void mpn_cnd_swap (mp_limb_t, volatile mp_limb_t *, volatile mp_limb_t *, mp_size_t); + +#define mpn_sec_mul __MPN(sec_mul) +__GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); +#define mpn_sec_mul_itch __MPN(sec_mul_itch) +__GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_sec_sqr __MPN(sec_sqr) +__GMP_DECLSPEC void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); +#define mpn_sec_sqr_itch __MPN(sec_sqr_itch) +__GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_sec_powm __MPN(sec_powm) +__GMP_DECLSPEC void mpn_sec_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_bitcnt_t, mp_srcptr, mp_size_t, mp_ptr); +#define mpn_sec_powm_itch __MPN(sec_powm_itch) +__GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_bitcnt_t, mp_size_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_sec_tabselect __MPN(sec_tabselect) +__GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t); + +#define mpn_sec_div_qr __MPN(sec_div_qr) +__GMP_DECLSPEC mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); +#define mpn_sec_div_qr_itch __MPN(sec_div_qr_itch) +__GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; +#define mpn_sec_div_r __MPN(sec_div_r) +__GMP_DECLSPEC void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); +#define mpn_sec_div_r_itch __MPN(sec_div_r_itch) +__GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; + +#define mpn_sec_invert __MPN(sec_invert) +__GMP_DECLSPEC int mpn_sec_invert (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_bitcnt_t, mp_ptr); +#define mpn_sec_invert_itch __MPN(sec_invert_itch) +__GMP_DECLSPEC mp_size_t mpn_sec_invert_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; + + +/**************** mpz inlines ****************/ + +/* The following are provided as inlines where possible, but always exist as + library functions too, for binary compatibility. + + Within gmp itself this inlining generally isn't relied on, since it + doesn't get done for all compilers, whereas if something is worth + inlining then it's worth arranging always. + + There are two styles of inlining here. When the same bit of code is + wanted for the inline as for the library version, then __GMP_FORCE_foo + arranges for that code to be emitted and the __GMP_EXTERN_INLINE + directive suppressed, eg. mpz_fits_uint_p. When a different bit of code + is wanted for the inline than for the library version, then + __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */ + +#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs) +__GMP_EXTERN_INLINE void +mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) +{ + if (__gmp_w != __gmp_u) + mpz_set (__gmp_w, __gmp_u); + __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size); +} +#endif + +#if GMP_NAIL_BITS == 0 +#define __GMPZ_FITS_UTYPE_P(z,maxval) \ + mp_size_t __gmp_n = z->_mp_size; \ + mp_ptr __gmp_p = z->_mp_d; \ + return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval)); +#else +#define __GMPZ_FITS_UTYPE_P(z,maxval) \ + mp_size_t __gmp_n = z->_mp_size; \ + mp_ptr __gmp_p = z->_mp_d; \ + return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval) \ + || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS))); +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p) +#if ! defined (__GMP_FORCE_mpz_fits_uint_p) +__GMP_EXTERN_INLINE +#endif +int +mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW +{ + __GMPZ_FITS_UTYPE_P (__gmp_z, UINT_MAX); +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p) +#if ! defined (__GMP_FORCE_mpz_fits_ulong_p) +__GMP_EXTERN_INLINE +#endif +int +mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW +{ + __GMPZ_FITS_UTYPE_P (__gmp_z, ULONG_MAX); +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p) +#if ! defined (__GMP_FORCE_mpz_fits_ushort_p) +__GMP_EXTERN_INLINE +#endif +int +mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW +{ + __GMPZ_FITS_UTYPE_P (__gmp_z, USHRT_MAX); +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui) +#if ! defined (__GMP_FORCE_mpz_get_ui) +__GMP_EXTERN_INLINE +#endif +unsigned long +mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW +{ + mp_ptr __gmp_p = __gmp_z->_mp_d; + mp_size_t __gmp_n = __gmp_z->_mp_size; + mp_limb_t __gmp_l = __gmp_p[0]; + /* This is a "#if" rather than a plain "if" so as to avoid gcc warnings + about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland + C++ 6.0 warnings about condition always true for something like + "ULONG_MAX < GMP_NUMB_MASK". */ +#if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB) + /* limb==long and no nails, or limb==longlong, one limb is enough */ + return (__gmp_n != 0 ? __gmp_l : 0); +#else + /* limb==long and nails, need two limbs when available */ + __gmp_n = __GMP_ABS (__gmp_n); + if (__gmp_n <= 1) + return (__gmp_n != 0 ? __gmp_l : 0); + else + return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS); +#endif +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn) +#if ! defined (__GMP_FORCE_mpz_getlimbn) +__GMP_EXTERN_INLINE +#endif +mp_limb_t +mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW +{ + mp_limb_t __gmp_result = 0; + if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size))) + __gmp_result = __gmp_z->_mp_d[__gmp_n]; + return __gmp_result; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg) +__GMP_EXTERN_INLINE void +mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) +{ + if (__gmp_w != __gmp_u) + mpz_set (__gmp_w, __gmp_u); + __gmp_w->_mp_size = - __gmp_w->_mp_size; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p) +#if ! defined (__GMP_FORCE_mpz_perfect_square_p) +__GMP_EXTERN_INLINE +#endif +int +mpz_perfect_square_p (mpz_srcptr __gmp_a) +{ + mp_size_t __gmp_asize; + int __gmp_result; + + __gmp_asize = __gmp_a->_mp_size; + __gmp_result = (__gmp_asize >= 0); /* zero is a square, negatives are not */ + if (__GMP_LIKELY (__gmp_asize > 0)) + __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize); + return __gmp_result; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount) +#if ! defined (__GMP_FORCE_mpz_popcount) +__GMP_EXTERN_INLINE +#endif +mp_bitcnt_t +mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW +{ + mp_size_t __gmp_usize; + mp_bitcnt_t __gmp_result; + + __gmp_usize = __gmp_u->_mp_size; + __gmp_result = (__gmp_usize < 0 ? ~ __GMP_CAST (mp_bitcnt_t, 0) : __GMP_CAST (mp_bitcnt_t, 0)); + if (__GMP_LIKELY (__gmp_usize > 0)) + __gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize); + return __gmp_result; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q) +#if ! defined (__GMP_FORCE_mpz_set_q) +__GMP_EXTERN_INLINE +#endif +void +mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u) +{ + mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u)); +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size) +#if ! defined (__GMP_FORCE_mpz_size) +__GMP_EXTERN_INLINE +#endif +size_t +mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW +{ + return __GMP_ABS (__gmp_z->_mp_size); +} +#endif + + +/**************** mpq inlines ****************/ + +#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs) +__GMP_EXTERN_INLINE void +mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) +{ + if (__gmp_w != __gmp_u) + mpq_set (__gmp_w, __gmp_u); + __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size); +} +#endif + +#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg) +__GMP_EXTERN_INLINE void +mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) +{ + if (__gmp_w != __gmp_u) + mpq_set (__gmp_w, __gmp_u); + __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size; +} +#endif + + +/**************** mpn inlines ****************/ + +/* The comments with __GMPN_ADD_1 below apply here too. + + The test for FUNCTION returning 0 should predict well. If it's assumed + {yp,ysize} will usually have a random number of bits then the high limb + won't be full and a carry out will occur a good deal less than 50% of the + time. + + ysize==0 isn't a documented feature, but is used internally in a few + places. + + Producing cout last stops it using up a register during the main part of + the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))" + doesn't seem able to move the true and false legs of the conditional up + to the two places cout is generated. */ + +#define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \ + do { \ + mp_size_t __gmp_i; \ + mp_limb_t __gmp_x; \ + \ + /* ASSERT ((ysize) >= 0); */ \ + /* ASSERT ((xsize) >= (ysize)); */ \ + /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \ + /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \ + \ + __gmp_i = (ysize); \ + if (__gmp_i != 0) \ + { \ + if (FUNCTION (wp, xp, yp, __gmp_i)) \ + { \ + do \ + { \ + if (__gmp_i >= (xsize)) \ + { \ + (cout) = 1; \ + goto __gmp_done; \ + } \ + __gmp_x = (xp)[__gmp_i]; \ + } \ + while (TEST); \ + } \ + } \ + if ((wp) != (xp)) \ + __GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \ + (cout) = 0; \ + __gmp_done: \ + ; \ + } while (0) + +#define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \ + __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \ + (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0)) +#define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \ + __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \ + (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0)) + + +/* The use of __gmp_i indexing is designed to ensure a compile time src==dst + remains nice and clear to the compiler, so that __GMPN_COPY_REST can + disappear, and the load/add/store gets a chance to become a + read-modify-write on CISC CPUs. + + Alternatives: + + Using a pair of pointers instead of indexing would be possible, but gcc + isn't able to recognise compile-time src==dst in that case, even when the + pointers are incremented more or less together. Other compilers would + very likely have similar difficulty. + + gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or + similar to detect a compile-time src==dst. This works nicely on gcc + 2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems + to be always false, for a pointer p. But the current code form seems + good enough for src==dst anyway. + + gcc on x86 as usual doesn't give particularly good flags handling for the + carry/borrow detection. It's tempting to want some multi instruction asm + blocks to help it, and this was tried, but in truth there's only a few + instructions to save and any gain is all too easily lost by register + juggling setting up for the asm. */ + +#if GMP_NAIL_BITS == 0 +#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \ + do { \ + mp_size_t __gmp_i; \ + mp_limb_t __gmp_x, __gmp_r; \ + \ + /* ASSERT ((n) >= 1); */ \ + /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \ + \ + __gmp_x = (src)[0]; \ + __gmp_r = __gmp_x OP (v); \ + (dst)[0] = __gmp_r; \ + if (CB (__gmp_r, __gmp_x, (v))) \ + { \ + (cout) = 1; \ + for (__gmp_i = 1; __gmp_i < (n);) \ + { \ + __gmp_x = (src)[__gmp_i]; \ + __gmp_r = __gmp_x OP 1; \ + (dst)[__gmp_i] = __gmp_r; \ + ++__gmp_i; \ + if (!CB (__gmp_r, __gmp_x, 1)) \ + { \ + if ((src) != (dst)) \ + __GMPN_COPY_REST (dst, src, n, __gmp_i); \ + (cout) = 0; \ + break; \ + } \ + } \ + } \ + else \ + { \ + if ((src) != (dst)) \ + __GMPN_COPY_REST (dst, src, n, 1); \ + (cout) = 0; \ + } \ + } while (0) +#endif + +#if GMP_NAIL_BITS >= 1 +#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \ + do { \ + mp_size_t __gmp_i; \ + mp_limb_t __gmp_x, __gmp_r; \ + \ + /* ASSERT ((n) >= 1); */ \ + /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \ + \ + __gmp_x = (src)[0]; \ + __gmp_r = __gmp_x OP (v); \ + (dst)[0] = __gmp_r & GMP_NUMB_MASK; \ + if (__gmp_r >> GMP_NUMB_BITS != 0) \ + { \ + (cout) = 1; \ + for (__gmp_i = 1; __gmp_i < (n);) \ + { \ + __gmp_x = (src)[__gmp_i]; \ + __gmp_r = __gmp_x OP 1; \ + (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \ + ++__gmp_i; \ + if (__gmp_r >> GMP_NUMB_BITS == 0) \ + { \ + if ((src) != (dst)) \ + __GMPN_COPY_REST (dst, src, n, __gmp_i); \ + (cout) = 0; \ + break; \ + } \ + } \ + } \ + else \ + { \ + if ((src) != (dst)) \ + __GMPN_COPY_REST (dst, src, n, 1); \ + (cout) = 0; \ + } \ + } while (0) +#endif + +#define __GMPN_ADDCB(r,x,y) ((r) < (y)) +#define __GMPN_SUBCB(r,x,y) ((x) < (y)) + +#define __GMPN_ADD_1(cout, dst, src, n, v) \ + __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB) +#define __GMPN_SUB_1(cout, dst, src, n, v) \ + __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB) + + +/* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or + negative. size==0 is allowed. On random data usually only one limb will + need to be examined to get a result, so it's worth having it inline. */ +#define __GMPN_CMP(result, xp, yp, size) \ + do { \ + mp_size_t __gmp_i; \ + mp_limb_t __gmp_x, __gmp_y; \ + \ + /* ASSERT ((size) >= 0); */ \ + \ + (result) = 0; \ + __gmp_i = (size); \ + while (--__gmp_i >= 0) \ + { \ + __gmp_x = (xp)[__gmp_i]; \ + __gmp_y = (yp)[__gmp_i]; \ + if (__gmp_x != __gmp_y) \ + { \ + /* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \ + (result) = (__gmp_x > __gmp_y ? 1 : -1); \ + break; \ + } \ + } \ + } while (0) + + +#if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST) +#define __GMPN_COPY_REST(dst, src, size, start) \ + do { \ + /* ASSERT ((start) >= 0); */ \ + /* ASSERT ((start) <= (size)); */ \ + __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \ + } while (0) +#endif + +/* Copy {src,size} to {dst,size}, starting at "start". This is designed to + keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1, + __GMPN_ADD, etc. */ +#if ! defined (__GMPN_COPY_REST) +#define __GMPN_COPY_REST(dst, src, size, start) \ + do { \ + mp_size_t __gmp_j; \ + /* ASSERT ((size) >= 0); */ \ + /* ASSERT ((start) >= 0); */ \ + /* ASSERT ((start) <= (size)); */ \ + /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \ + __GMP_CRAY_Pragma ("_CRI ivdep"); \ + for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \ + (dst)[__gmp_j] = (src)[__gmp_j]; \ + } while (0) +#endif + +/* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use + mpn_copyi if there's a native version, and if we don't mind demanding + binary compatibility for it (on targets which use it). */ + +#if ! defined (__GMPN_COPY) +#define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0) +#endif + + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add) +#if ! defined (__GMP_FORCE_mpn_add) +__GMP_EXTERN_INLINE +#endif +mp_limb_t +mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) +{ + mp_limb_t __gmp_c; + __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize); + return __gmp_c; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1) +#if ! defined (__GMP_FORCE_mpn_add_1) +__GMP_EXTERN_INLINE +#endif +mp_limb_t +mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW +{ + mp_limb_t __gmp_c; + __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n); + return __gmp_c; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp) +#if ! defined (__GMP_FORCE_mpn_cmp) +__GMP_EXTERN_INLINE +#endif +int +mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW +{ + int __gmp_result; + __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size); + return __gmp_result; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_zero_p) +#if ! defined (__GMP_FORCE_mpn_zero_p) +__GMP_EXTERN_INLINE +#endif +int +mpn_zero_p (mp_srcptr __gmp_p, mp_size_t __gmp_n) __GMP_NOTHROW +{ + /* if (__GMP_LIKELY (__gmp_n > 0)) */ + do { + if (__gmp_p[--__gmp_n] != 0) + return 0; + } while (__gmp_n != 0); + return 1; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub) +#if ! defined (__GMP_FORCE_mpn_sub) +__GMP_EXTERN_INLINE +#endif +mp_limb_t +mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) +{ + mp_limb_t __gmp_c; + __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize); + return __gmp_c; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1) +#if ! defined (__GMP_FORCE_mpn_sub_1) +__GMP_EXTERN_INLINE +#endif +mp_limb_t +mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW +{ + mp_limb_t __gmp_c; + __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n); + return __gmp_c; +} +#endif + +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_neg) +#if ! defined (__GMP_FORCE_mpn_neg) +__GMP_EXTERN_INLINE +#endif +mp_limb_t +mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n) +{ + while (*__gmp_up == 0) /* Low zero limbs are unchanged by negation. */ + { + *__gmp_rp = 0; + if (!--__gmp_n) /* All zero */ + return 0; + ++__gmp_up; ++__gmp_rp; + } + + *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK; + + if (--__gmp_n) /* Higher limbs get complemented. */ + mpn_com (++__gmp_rp, ++__gmp_up, __gmp_n); + + return 1; +} +#endif + +#if defined (__cplusplus) +} +#endif + + +/* Allow faster testing for negative, zero, and positive. */ +#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0) +#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0) +#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0) + +/* When using GCC, optimize certain common comparisons. */ +#if defined (__GNUC__) && __GNUC__ >= 2 +#define mpz_cmp_ui(Z,UI) \ + (__builtin_constant_p (UI) && (UI) == 0 \ + ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI)) +#define mpz_cmp_si(Z,SI) \ + (__builtin_constant_p ((SI) >= 0) && (SI) >= 0 \ + ? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI)) \ + : _mpz_cmp_si (Z,SI)) +#define mpq_cmp_ui(Q,NUI,DUI) \ + (__builtin_constant_p (NUI) && (NUI) == 0 ? mpq_sgn (Q) \ + : __builtin_constant_p ((NUI) == (DUI)) && (NUI) == (DUI) \ + ? mpz_cmp (mpq_numref (Q), mpq_denref (Q)) \ + : _mpq_cmp_ui (Q,NUI,DUI)) +#define mpq_cmp_si(q,n,d) \ + (__builtin_constant_p ((n) >= 0) && (n) >= 0 \ + ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \ + : _mpq_cmp_si (q, n, d)) +#else +#define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI) +#define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI) +#define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI) +#define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d) +#endif + + +/* Using "&" rather than "&&" means these can come out branch-free. Every + mpz_t has at least one limb allocated, so fetching the low limb is always + allowed. */ +#define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0])) +#define mpz_even_p(z) (! mpz_odd_p (z)) + + +/**************** C++ routines ****************/ + +#ifdef __cplusplus +__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr); +__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr); +__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr); +__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr); +__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr); +__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr); +#endif + + +/* Source-level compatibility with GMP 2 and earlier. */ +#define mpn_divmod(qp,np,nsize,dp,dsize) \ + mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize) + +/* Source-level compatibility with GMP 1. */ +#define mpz_mdiv mpz_fdiv_q +#define mpz_mdivmod mpz_fdiv_qr +#define mpz_mmod mpz_fdiv_r +#define mpz_mdiv_ui mpz_fdiv_q_ui +#define mpz_mdivmod_ui(q,r,n,d) \ + (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d)) +#define mpz_mmod_ui(r,n,d) \ + (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d)) + +/* Useful synonyms, but not quite compatible with GMP 1. */ +#define mpz_div mpz_fdiv_q +#define mpz_divmod mpz_fdiv_qr +#define mpz_div_ui mpz_fdiv_q_ui +#define mpz_divmod_ui mpz_fdiv_qr_ui +#define mpz_div_2exp mpz_fdiv_q_2exp +#define mpz_mod_2exp mpz_fdiv_r_2exp + +enum +{ + GMP_ERROR_NONE = 0, + GMP_ERROR_UNSUPPORTED_ARGUMENT = 1, + GMP_ERROR_DIVISION_BY_ZERO = 2, + GMP_ERROR_SQRT_OF_NEGATIVE = 4, + GMP_ERROR_INVALID_ARGUMENT = 8, + GMP_ERROR_MPZ_OVERFLOW = 16 +}; + +/* Define CC and CFLAGS which were used to build this version of GMP */ +#define __GMP_CC "/opt/gcc-14/bin/gcc" +#define __GMP_CFLAGS "-O2 -fno-omit-frame-pointer -fno-aggressive-loop-optimizations -fstack-protector-strong -fexceptions -gdwarf-4 -gstrict-dwarf -m64" + +/* Major version number is the value of __GNU_MP__ too, above. */ +#define __GNU_MP_VERSION 6 +#define __GNU_MP_VERSION_MINOR 3 +#define __GNU_MP_VERSION_PATCHLEVEL 0 +#define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL) + +#define __GMP_H__ +#endif /* __GMP_H__ */ diff --git a/illumos-x86_64/usr/include/gmp/gmpxx.h b/illumos-x86_64/usr/include/gmp/gmpxx.h new file mode 100644 index 00000000..b7ed06a4 --- /dev/null +++ b/illumos-x86_64/usr/include/gmp/gmpxx.h @@ -0,0 +1,3712 @@ +/* gmpxx.h -- C++ class wrapper for GMP types. -*- C++ -*- + +Copyright 2001-2003, 2006, 2008, 2011-2015, 2018 Free Software +Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + +or + + * the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any + later version. + +or both in parallel, as here. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received copies of the GNU General Public License and the +GNU Lesser General Public License along with the GNU MP Library. If not, +see https://www.gnu.org/licenses/. */ + +#ifndef __GMP_PLUSPLUS__ +#define __GMP_PLUSPLUS__ + +#include + +#include /* for strlen */ +#include /* numeric_limits */ +#include +#include /* swap */ +#include +#include +#include +#include + +// wrapper for gcc's __builtin_constant_p +// __builtin_constant_p has been in gcc since forever, +// but g++-3.4 miscompiles it. +#if __GMP_GNUC_PREREQ(4, 2) +#define __GMPXX_CONSTANT(X) __builtin_constant_p(X) +#else +#define __GMPXX_CONSTANT(X) false +#endif +#define __GMPXX_CONSTANT_TRUE(X) (__GMPXX_CONSTANT(X) && (X)) + +// Use C++11 features +#ifndef __GMPXX_USE_CXX11 +#if __cplusplus >= 201103L +#define __GMPXX_USE_CXX11 1 +#else +#define __GMPXX_USE_CXX11 0 +#endif +#endif + +#if __GMPXX_USE_CXX11 +#define __GMPXX_NOEXCEPT noexcept +#include // for common_type +#else +#define __GMPXX_NOEXCEPT +#endif + +// Max allocations for plain types when converted to GMP types +#if GMP_NAIL_BITS != 0 && ! defined _LONG_LONG_LIMB +#define __GMPZ_ULI_LIMBS 2 +#else +#define __GMPZ_ULI_LIMBS 1 +#endif + +#define __GMPXX_BITS_TO_LIMBS(n) (((n) + (GMP_NUMB_BITS - 1)) / GMP_NUMB_BITS) +#define __GMPZ_DBL_LIMBS __GMPXX_BITS_TO_LIMBS(DBL_MAX_EXP)+1 +#define __GMPQ_NUM_DBL_LIMBS __GMPZ_DBL_LIMBS +#define __GMPQ_DEN_DBL_LIMBS __GMPXX_BITS_TO_LIMBS(DBL_MANT_DIG+1-DBL_MIN_EXP)+1 +// The final +1s are a security margin. The current implementation of +// mpq_set_d seems to need it for the denominator. + +inline void __mpz_set_ui_safe(mpz_ptr p, unsigned long l) +{ + p->_mp_size = (l != 0); + p->_mp_d[0] = l & GMP_NUMB_MASK; +#if __GMPZ_ULI_LIMBS > 1 + l >>= GMP_NUMB_BITS; + p->_mp_d[1] = l; + p->_mp_size += (l != 0); +#endif +} + +inline void __mpz_set_si_safe(mpz_ptr p, long l) +{ + if(l < 0) + { + __mpz_set_ui_safe(p, -static_cast(l)); + mpz_neg(p, p); + } + else + __mpz_set_ui_safe(p, l); + // Note: we know the high bit of l is 0 so we could do slightly better +} + +// Fake temporary variables +#define __GMPXX_TMPZ_UI \ + mpz_t temp; \ + mp_limb_t limbs[__GMPZ_ULI_LIMBS]; \ + temp->_mp_d = limbs; \ + __mpz_set_ui_safe (temp, l) +#define __GMPXX_TMPZ_SI \ + mpz_t temp; \ + mp_limb_t limbs[__GMPZ_ULI_LIMBS]; \ + temp->_mp_d = limbs; \ + __mpz_set_si_safe (temp, l) +#define __GMPXX_TMPZ_D \ + mpz_t temp; \ + mp_limb_t limbs[__GMPZ_DBL_LIMBS]; \ + temp->_mp_d = limbs; \ + temp->_mp_alloc = __GMPZ_DBL_LIMBS; \ + mpz_set_d (temp, d) + +#define __GMPXX_TMPQ_UI \ + mpq_t temp; \ + mp_limb_t limbs[__GMPZ_ULI_LIMBS+1]; \ + mpq_numref(temp)->_mp_d = limbs; \ + __mpz_set_ui_safe (mpq_numref(temp), l); \ + mpq_denref(temp)->_mp_d = limbs + __GMPZ_ULI_LIMBS; \ + mpq_denref(temp)->_mp_size = 1; \ + mpq_denref(temp)->_mp_d[0] = 1 +#define __GMPXX_TMPQ_SI \ + mpq_t temp; \ + mp_limb_t limbs[__GMPZ_ULI_LIMBS+1]; \ + mpq_numref(temp)->_mp_d = limbs; \ + __mpz_set_si_safe (mpq_numref(temp), l); \ + mpq_denref(temp)->_mp_d = limbs + __GMPZ_ULI_LIMBS; \ + mpq_denref(temp)->_mp_size = 1; \ + mpq_denref(temp)->_mp_d[0] = 1 +#define __GMPXX_TMPQ_D \ + mpq_t temp; \ + mp_limb_t limbs[__GMPQ_NUM_DBL_LIMBS + __GMPQ_DEN_DBL_LIMBS]; \ + mpq_numref(temp)->_mp_d = limbs; \ + mpq_numref(temp)->_mp_alloc = __GMPQ_NUM_DBL_LIMBS; \ + mpq_denref(temp)->_mp_d = limbs + __GMPQ_NUM_DBL_LIMBS; \ + mpq_denref(temp)->_mp_alloc = __GMPQ_DEN_DBL_LIMBS; \ + mpq_set_d (temp, d) + +inline unsigned long __gmpxx_abs_ui (signed long l) +{ + return l >= 0 ? static_cast(l) + : -static_cast(l); +} + +/**************** Function objects ****************/ +/* Any evaluation of a __gmp_expr ends up calling one of these functions + all intermediate functions being inline, the evaluation should optimize + to a direct call to the relevant function, thus yielding no overhead + over the C interface. */ + +struct __gmp_unary_plus +{ + static void eval(mpz_ptr z, mpz_srcptr w) { mpz_set(z, w); } + static void eval(mpq_ptr q, mpq_srcptr r) { mpq_set(q, r); } + static void eval(mpf_ptr f, mpf_srcptr g) { mpf_set(f, g); } +}; + +struct __gmp_unary_minus +{ + static void eval(mpz_ptr z, mpz_srcptr w) { mpz_neg(z, w); } + static void eval(mpq_ptr q, mpq_srcptr r) { mpq_neg(q, r); } + static void eval(mpf_ptr f, mpf_srcptr g) { mpf_neg(f, g); } +}; + +struct __gmp_unary_com +{ + static void eval(mpz_ptr z, mpz_srcptr w) { mpz_com(z, w); } +}; + +struct __gmp_binary_plus +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_add(z, w, v); } + + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { + // Ideally, those checks should happen earlier so that the tree + // generated for a+0+b would just be sum(a,b). + if (__GMPXX_CONSTANT(l) && l == 0) + { + if (z != w) mpz_set(z, w); + } + else + mpz_add_ui(z, w, l); + } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { + if (l >= 0) + eval(z, w, static_cast(l)); + else + mpz_sub_ui(z, w, -static_cast(l)); + } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_add (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { eval(z, w, d); } + + static void eval(mpq_ptr q, mpq_srcptr r, mpq_srcptr s) + { mpq_add(q, r, s); } + + static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) + { + if (__GMPXX_CONSTANT(l) && l == 0) + { + if (q != r) mpq_set(q, r); + } + else if (__GMPXX_CONSTANT(l) && l == 1) + { + mpz_add (mpq_numref(q), mpq_numref(r), mpq_denref(r)); + if (q != r) mpz_set(mpq_denref(q), mpq_denref(r)); + } + else + { + if (q == r) + mpz_addmul_ui(mpq_numref(q), mpq_denref(q), l); + else + { + mpz_mul_ui(mpq_numref(q), mpq_denref(r), l); + mpz_add(mpq_numref(q), mpq_numref(q), mpq_numref(r)); + mpz_set(mpq_denref(q), mpq_denref(r)); + } + } + } + static void eval(mpq_ptr q, unsigned long int l, mpq_srcptr r) + { eval(q, r, l); } + static inline void eval(mpq_ptr q, mpq_srcptr r, signed long int l); + // defined after __gmp_binary_minus + static void eval(mpq_ptr q, signed long int l, mpq_srcptr r) + { eval(q, r, l); } + static void eval(mpq_ptr q, mpq_srcptr r, double d) + { __GMPXX_TMPQ_D; mpq_add (q, r, temp); } + static void eval(mpq_ptr q, double d, mpq_srcptr r) + { eval(q, r, d); } + + static void eval(mpq_ptr q, mpq_srcptr r, mpz_srcptr z) + { + if (q == r) + mpz_addmul(mpq_numref(q), mpq_denref(q), z); + else + { + mpz_mul(mpq_numref(q), mpq_denref(r), z); + mpz_add(mpq_numref(q), mpq_numref(q), mpq_numref(r)); + mpz_set(mpq_denref(q), mpq_denref(r)); + } + } + static void eval(mpq_ptr q, mpz_srcptr z, mpq_srcptr r) + { eval(q, r, z); } + + static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) + { mpf_add(f, g, h); } + + static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) + { mpf_add_ui(f, g, l); } + static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) + { mpf_add_ui(f, g, l); } + static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) + { + if (l >= 0) + mpf_add_ui(f, g, l); + else + mpf_sub_ui(f, g, -static_cast(l)); + } + static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) + { eval(f, g, l); } + static void eval(mpf_ptr f, mpf_srcptr g, double d) + { + mpf_t temp; + mpf_init2(temp, 8*sizeof(double)); + mpf_set_d(temp, d); + mpf_add(f, g, temp); + mpf_clear(temp); + } + static void eval(mpf_ptr f, double d, mpf_srcptr g) + { eval(f, g, d); } +}; + +struct __gmp_binary_minus +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_sub(z, w, v); } + + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { + if (__GMPXX_CONSTANT(l) && l == 0) + { + if (z != w) mpz_set(z, w); + } + else + mpz_sub_ui(z, w, l); + } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { + if (__GMPXX_CONSTANT(l) && l == 0) + { + mpz_neg(z, w); + } + else + mpz_ui_sub(z, l, w); + } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { + if (l >= 0) + eval(z, w, static_cast(l)); + else + mpz_add_ui(z, w, -static_cast(l)); + } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { + if (l >= 0) + eval(z, static_cast(l), w); + else + { + mpz_add_ui(z, w, -static_cast(l)); + mpz_neg(z, z); + } + } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_sub (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { __GMPXX_TMPZ_D; mpz_sub (z, temp, w); } + + static void eval(mpq_ptr q, mpq_srcptr r, mpq_srcptr s) + { mpq_sub(q, r, s); } + + static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) + { + if (__GMPXX_CONSTANT(l) && l == 0) + { + if (q != r) mpq_set(q, r); + } + else if (__GMPXX_CONSTANT(l) && l == 1) + { + mpz_sub (mpq_numref(q), mpq_numref(r), mpq_denref(r)); + if (q != r) mpz_set(mpq_denref(q), mpq_denref(r)); + } + else + { + if (q == r) + mpz_submul_ui(mpq_numref(q), mpq_denref(q), l); + else + { + mpz_mul_ui(mpq_numref(q), mpq_denref(r), l); + mpz_sub(mpq_numref(q), mpq_numref(r), mpq_numref(q)); + mpz_set(mpq_denref(q), mpq_denref(r)); + } + } + } + static void eval(mpq_ptr q, unsigned long int l, mpq_srcptr r) + { eval(q, r, l); mpq_neg(q, q); } + static void eval(mpq_ptr q, mpq_srcptr r, signed long int l) + { + if (l >= 0) + eval(q, r, static_cast(l)); + else + __gmp_binary_plus::eval(q, r, -static_cast(l)); + } + static void eval(mpq_ptr q, signed long int l, mpq_srcptr r) + { eval(q, r, l); mpq_neg(q, q); } + static void eval(mpq_ptr q, mpq_srcptr r, double d) + { __GMPXX_TMPQ_D; mpq_sub (q, r, temp); } + static void eval(mpq_ptr q, double d, mpq_srcptr r) + { __GMPXX_TMPQ_D; mpq_sub (q, temp, r); } + + static void eval(mpq_ptr q, mpq_srcptr r, mpz_srcptr z) + { + if (q == r) + mpz_submul(mpq_numref(q), mpq_denref(q), z); + else + { + mpz_mul(mpq_numref(q), mpq_denref(r), z); + mpz_sub(mpq_numref(q), mpq_numref(r), mpq_numref(q)); + mpz_set(mpq_denref(q), mpq_denref(r)); + } + } + static void eval(mpq_ptr q, mpz_srcptr z, mpq_srcptr r) + { eval(q, r, z); mpq_neg(q, q); } + + static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) + { mpf_sub(f, g, h); } + + static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) + { mpf_sub_ui(f, g, l); } + static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) + { mpf_ui_sub(f, l, g); } + static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) + { + if (l >= 0) + mpf_sub_ui(f, g, l); + else + mpf_add_ui(f, g, -static_cast(l)); + } + static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) + { + if (l >= 0) + mpf_sub_ui(f, g, l); + else + mpf_add_ui(f, g, -static_cast(l)); + mpf_neg(f, f); + } + static void eval(mpf_ptr f, mpf_srcptr g, double d) + { + mpf_t temp; + mpf_init2(temp, 8*sizeof(double)); + mpf_set_d(temp, d); + mpf_sub(f, g, temp); + mpf_clear(temp); + } + static void eval(mpf_ptr f, double d, mpf_srcptr g) + { + mpf_t temp; + mpf_init2(temp, 8*sizeof(double)); + mpf_set_d(temp, d); + mpf_sub(f, temp, g); + mpf_clear(temp); + } +}; + +// defined here so it can reference __gmp_binary_minus +inline void +__gmp_binary_plus::eval(mpq_ptr q, mpq_srcptr r, signed long int l) +{ + if (l >= 0) + eval(q, r, static_cast(l)); + else + __gmp_binary_minus::eval(q, r, -static_cast(l)); +} + +struct __gmp_binary_lshift +{ + static void eval(mpz_ptr z, mpz_srcptr w, mp_bitcnt_t l) + { + if (__GMPXX_CONSTANT(l) && (l == 0)) + { + if (z != w) mpz_set(z, w); + } + else + mpz_mul_2exp(z, w, l); + } + static void eval(mpq_ptr q, mpq_srcptr r, mp_bitcnt_t l) + { + if (__GMPXX_CONSTANT(l) && (l == 0)) + { + if (q != r) mpq_set(q, r); + } + else + mpq_mul_2exp(q, r, l); + } + static void eval(mpf_ptr f, mpf_srcptr g, mp_bitcnt_t l) + { mpf_mul_2exp(f, g, l); } +}; + +struct __gmp_binary_rshift +{ + static void eval(mpz_ptr z, mpz_srcptr w, mp_bitcnt_t l) + { + if (__GMPXX_CONSTANT(l) && (l == 0)) + { + if (z != w) mpz_set(z, w); + } + else + mpz_fdiv_q_2exp(z, w, l); + } + static void eval(mpq_ptr q, mpq_srcptr r, mp_bitcnt_t l) + { + if (__GMPXX_CONSTANT(l) && (l == 0)) + { + if (q != r) mpq_set(q, r); + } + else + mpq_div_2exp(q, r, l); + } + static void eval(mpf_ptr f, mpf_srcptr g, mp_bitcnt_t l) + { mpf_div_2exp(f, g, l); } +}; + +struct __gmp_binary_multiplies +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_mul(z, w, v); } + + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { +// gcc-3.3 doesn't have __builtin_ctzl. Don't bother optimizing for old gcc. +#if __GMP_GNUC_PREREQ(3, 4) + if (__GMPXX_CONSTANT(l) && (l & (l-1)) == 0) + { + if (l == 0) + { + z->_mp_size = 0; + } + else + { + __gmp_binary_lshift::eval(z, w, __builtin_ctzl(l)); + } + } + else +#endif + mpz_mul_ui(z, w, l); + } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { + if (__GMPXX_CONSTANT_TRUE(l >= 0)) + eval(z, w, static_cast(l)); + else if (__GMPXX_CONSTANT_TRUE(l <= 0)) + { + eval(z, w, -static_cast(l)); + mpz_neg(z, z); + } + else + mpz_mul_si (z, w, l); + } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_mul (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { eval(z, w, d); } + + static void eval(mpq_ptr q, mpq_srcptr r, mpq_srcptr s) + { mpq_mul(q, r, s); } + + static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) + { +#if __GMP_GNUC_PREREQ(3, 4) + if (__GMPXX_CONSTANT(l) && (l & (l-1)) == 0) + { + if (l == 0) + { + mpq_set_ui(q, 0, 1); + } + else + { + __gmp_binary_lshift::eval(q, r, __builtin_ctzl(l)); + } + } + else +#endif + { + __GMPXX_TMPQ_UI; + mpq_mul (q, r, temp); + } + } + static void eval(mpq_ptr q, unsigned long int l, mpq_srcptr r) + { eval(q, r, l); } + static void eval(mpq_ptr q, mpq_srcptr r, signed long int l) + { + if (__GMPXX_CONSTANT_TRUE(l >= 0)) + eval(q, r, static_cast(l)); + else if (__GMPXX_CONSTANT_TRUE(l <= 0)) + { + eval(q, r, -static_cast(l)); + mpq_neg(q, q); + } + else + { + __GMPXX_TMPQ_SI; + mpq_mul (q, r, temp); + } + } + static void eval(mpq_ptr q, signed long int l, mpq_srcptr r) + { eval(q, r, l); } + static void eval(mpq_ptr q, mpq_srcptr r, double d) + { __GMPXX_TMPQ_D; mpq_mul (q, r, temp); } + static void eval(mpq_ptr q, double d, mpq_srcptr r) + { eval(q, r, d); } + + static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) + { mpf_mul(f, g, h); } + + static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) + { mpf_mul_ui(f, g, l); } + static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) + { mpf_mul_ui(f, g, l); } + static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) + { + if (l >= 0) + mpf_mul_ui(f, g, l); + else + { + mpf_mul_ui(f, g, -static_cast(l)); + mpf_neg(f, f); + } + } + static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) + { eval(f, g, l); } + static void eval(mpf_ptr f, mpf_srcptr g, double d) + { + mpf_t temp; + mpf_init2(temp, 8*sizeof(double)); + mpf_set_d(temp, d); + mpf_mul(f, g, temp); + mpf_clear(temp); + } + static void eval(mpf_ptr f, double d, mpf_srcptr g) + { eval(f, g, d); } +}; + +struct __gmp_binary_divides +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_tdiv_q(z, w, v); } + + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { +#if __GMP_GNUC_PREREQ(3, 4) + // Don't optimize division by 0... + if (__GMPXX_CONSTANT(l) && (l & (l-1)) == 0 && l != 0) + { + if (l == 1) + { + if (z != w) mpz_set(z, w); + } + else + mpz_tdiv_q_2exp(z, w, __builtin_ctzl(l)); + // warning: do not use rshift (fdiv) + } + else +#endif + mpz_tdiv_q_ui(z, w, l); + } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { + if (mpz_sgn(w) >= 0) + { + if (mpz_fits_ulong_p(w)) + mpz_set_ui(z, l / mpz_get_ui(w)); + else + mpz_set_ui(z, 0); + } + else + { + mpz_neg(z, w); + if (mpz_fits_ulong_p(z)) + { + mpz_set_ui(z, l / mpz_get_ui(z)); + mpz_neg(z, z); + } + else + mpz_set_ui(z, 0); + } + } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { + if (l >= 0) + eval(z, w, static_cast(l)); + else + { + eval(z, w, -static_cast(l)); + mpz_neg(z, z); + } + } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { + if (mpz_fits_slong_p(w)) + mpz_set_si(z, l / mpz_get_si(w)); + else + { + /* if w is bigger than a long then the quotient must be zero, unless + l==LONG_MIN and w==-LONG_MIN in which case the quotient is -1 */ + mpz_set_si (z, (mpz_cmpabs_ui (w, __gmpxx_abs_ui(l)) == 0 ? -1 : 0)); + } + } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_tdiv_q (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { __GMPXX_TMPZ_D; mpz_tdiv_q (z, temp, w); } + + static void eval(mpq_ptr q, mpq_srcptr r, mpq_srcptr s) + { mpq_div(q, r, s); } + + static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) + { +#if __GMP_GNUC_PREREQ(3, 4) + if (__GMPXX_CONSTANT(l) && (l & (l-1)) == 0 && l != 0) + __gmp_binary_rshift::eval(q, r, __builtin_ctzl(l)); + else +#endif + { + __GMPXX_TMPQ_UI; + mpq_div (q, r, temp); + } + } + static void eval(mpq_ptr q, unsigned long int l, mpq_srcptr r) + { + if (__GMPXX_CONSTANT_TRUE(l == 0)) + mpq_set_ui(q, 0, 1); + else if (__GMPXX_CONSTANT_TRUE(l == 1)) + mpq_inv(q, r); + else + { + __GMPXX_TMPQ_UI; + mpq_div (q, temp, r); + } + } + static void eval(mpq_ptr q, mpq_srcptr r, signed long int l) + { + if (__GMPXX_CONSTANT_TRUE(l >= 0)) + eval(q, r, static_cast(l)); + else if (__GMPXX_CONSTANT_TRUE(l <= 0)) + { + eval(q, r, -static_cast(l)); + mpq_neg(q, q); + } + else + { + __GMPXX_TMPQ_SI; + mpq_div (q, r, temp); + } + } + static void eval(mpq_ptr q, signed long int l, mpq_srcptr r) + { + if (__GMPXX_CONSTANT_TRUE(l == 0)) + mpq_set_ui(q, 0, 1); + else if (__GMPXX_CONSTANT_TRUE(l == 1)) + mpq_inv(q, r); + else if (__GMPXX_CONSTANT_TRUE(l == -1)) + { + mpq_inv(q, r); + mpq_neg(q, q); + } + else + { + __GMPXX_TMPQ_SI; + mpq_div (q, temp, r); + } + } + static void eval(mpq_ptr q, mpq_srcptr r, double d) + { __GMPXX_TMPQ_D; mpq_div (q, r, temp); } + static void eval(mpq_ptr q, double d, mpq_srcptr r) + { __GMPXX_TMPQ_D; mpq_div (q, temp, r); } + + static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) + { mpf_div(f, g, h); } + + static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) + { mpf_div_ui(f, g, l); } + static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) + { mpf_ui_div(f, l, g); } + static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) + { + if (l >= 0) + mpf_div_ui(f, g, l); + else + { + mpf_div_ui(f, g, -static_cast(l)); + mpf_neg(f, f); + } + } + static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) + { + if (l >= 0) + mpf_ui_div(f, l, g); + else + { + mpf_ui_div(f, -static_cast(l), g); + mpf_neg(f, f); + } + } + static void eval(mpf_ptr f, mpf_srcptr g, double d) + { + mpf_t temp; + mpf_init2(temp, 8*sizeof(double)); + mpf_set_d(temp, d); + mpf_div(f, g, temp); + mpf_clear(temp); + } + static void eval(mpf_ptr f, double d, mpf_srcptr g) + { + mpf_t temp; + mpf_init2(temp, 8*sizeof(double)); + mpf_set_d(temp, d); + mpf_div(f, temp, g); + mpf_clear(temp); + } +}; + +struct __gmp_binary_modulus +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_tdiv_r(z, w, v); } + + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { mpz_tdiv_r_ui(z, w, l); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { + if (mpz_sgn(w) >= 0) + { + if (mpz_fits_ulong_p(w)) + mpz_set_ui(z, l % mpz_get_ui(w)); + else + mpz_set_ui(z, l); + } + else + { + mpz_neg(z, w); + if (mpz_fits_ulong_p(z)) + mpz_set_ui(z, l % mpz_get_ui(z)); + else + mpz_set_ui(z, l); + } + } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { + mpz_tdiv_r_ui (z, w, __gmpxx_abs_ui(l)); + } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { + if (mpz_fits_slong_p(w)) + mpz_set_si(z, l % mpz_get_si(w)); + else + { + /* if w is bigger than a long then the remainder is l unchanged, + unless l==LONG_MIN and w==-LONG_MIN in which case it's 0 */ + mpz_set_si (z, mpz_cmpabs_ui (w, __gmpxx_abs_ui(l)) == 0 ? 0 : l); + } + } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_tdiv_r (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { __GMPXX_TMPZ_D; mpz_tdiv_r (z, temp, w); } +}; + +struct __gmp_binary_and +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_and(z, w, v); } + + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { __GMPXX_TMPZ_UI; mpz_and (z, w, temp); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { __GMPXX_TMPZ_SI; mpz_and (z, w, temp); } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_and (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { eval(z, w, d); } +}; + +struct __gmp_binary_ior +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_ior(z, w, v); } + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { __GMPXX_TMPZ_UI; mpz_ior (z, w, temp); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { __GMPXX_TMPZ_SI; mpz_ior (z, w, temp); } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_ior (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { eval(z, w, d); } +}; + +struct __gmp_binary_xor +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_xor(z, w, v); } + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { __GMPXX_TMPZ_UI; mpz_xor (z, w, temp); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { __GMPXX_TMPZ_SI; mpz_xor (z, w, temp); } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_xor (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { eval(z, w, d); } +}; + +struct __gmp_cmp_function +{ + static int eval(mpz_srcptr z, mpz_srcptr w) { return mpz_cmp(z, w); } + + static int eval(mpz_srcptr z, unsigned long int l) + { return mpz_cmp_ui(z, l); } + static int eval(unsigned long int l, mpz_srcptr z) + { return -mpz_cmp_ui(z, l); } + static int eval(mpz_srcptr z, signed long int l) + { return mpz_cmp_si(z, l); } + static int eval(signed long int l, mpz_srcptr z) + { return -mpz_cmp_si(z, l); } + static int eval(mpz_srcptr z, double d) + { return mpz_cmp_d(z, d); } + static int eval(double d, mpz_srcptr z) + { return -mpz_cmp_d(z, d); } + + static int eval(mpq_srcptr q, mpq_srcptr r) { return mpq_cmp(q, r); } + + static int eval(mpq_srcptr q, unsigned long int l) + { return mpq_cmp_ui(q, l, 1); } + static int eval(unsigned long int l, mpq_srcptr q) + { return -mpq_cmp_ui(q, l, 1); } + static int eval(mpq_srcptr q, signed long int l) + { return mpq_cmp_si(q, l, 1); } + static int eval(signed long int l, mpq_srcptr q) + { return -mpq_cmp_si(q, l, 1); } + static int eval(mpq_srcptr q, double d) + { __GMPXX_TMPQ_D; return mpq_cmp (q, temp); } + static int eval(double d, mpq_srcptr q) + { __GMPXX_TMPQ_D; return mpq_cmp (temp, q); } + static int eval(mpq_srcptr q, mpz_srcptr z) + { return mpq_cmp_z(q, z); } + static int eval(mpz_srcptr z, mpq_srcptr q) + { return -mpq_cmp_z(q, z); } + + static int eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g); } + + static int eval(mpf_srcptr f, unsigned long int l) + { return mpf_cmp_ui(f, l); } + static int eval(unsigned long int l, mpf_srcptr f) + { return -mpf_cmp_ui(f, l); } + static int eval(mpf_srcptr f, signed long int l) + { return mpf_cmp_si(f, l); } + static int eval(signed long int l, mpf_srcptr f) + { return -mpf_cmp_si(f, l); } + static int eval(mpf_srcptr f, double d) + { return mpf_cmp_d(f, d); } + static int eval(double d, mpf_srcptr f) + { return -mpf_cmp_d(f, d); } + static int eval(mpf_srcptr f, mpz_srcptr z) + { return mpf_cmp_z(f, z); } + static int eval(mpz_srcptr z, mpf_srcptr f) + { return -mpf_cmp_z(f, z); } + static int eval(mpf_srcptr f, mpq_srcptr q) + { + mpf_t qf; + mpf_init(qf); /* Should we use the precision of f? */ + mpf_set_q(qf, q); + int ret = eval(f, qf); + mpf_clear(qf); + return ret; + } + static int eval(mpq_srcptr q, mpf_srcptr f) + { return -eval(f, q); } +}; + +struct __gmp_binary_equal +{ + static bool eval(mpz_srcptr z, mpz_srcptr w) { return mpz_cmp(z, w) == 0; } + + static bool eval(mpz_srcptr z, unsigned long int l) + { return mpz_cmp_ui(z, l) == 0; } + static bool eval(unsigned long int l, mpz_srcptr z) + { return eval(z, l); } + static bool eval(mpz_srcptr z, signed long int l) + { return mpz_cmp_si(z, l) == 0; } + static bool eval(signed long int l, mpz_srcptr z) + { return eval(z, l); } + static bool eval(mpz_srcptr z, double d) + { return mpz_cmp_d(z, d) == 0; } + static bool eval(double d, mpz_srcptr z) + { return eval(z, d); } + + static bool eval(mpq_srcptr q, mpq_srcptr r) + { return mpq_equal(q, r) != 0; } + + static bool eval(mpq_srcptr q, unsigned long int l) + { return ((__GMPXX_CONSTANT(l) && l == 0) || + mpz_cmp_ui(mpq_denref(q), 1) == 0) && + mpz_cmp_ui(mpq_numref(q), l) == 0; } + static bool eval(unsigned long int l, mpq_srcptr q) + { return eval(q, l); } + static bool eval(mpq_srcptr q, signed long int l) + { return ((__GMPXX_CONSTANT(l) && l == 0) || + mpz_cmp_ui(mpq_denref(q), 1) == 0) && + mpz_cmp_si(mpq_numref(q), l) == 0; } + static bool eval(signed long int l, mpq_srcptr q) + { return eval(q, l); } + static bool eval(mpq_srcptr q, double d) + { __GMPXX_TMPQ_D; return mpq_equal (q, temp) != 0; } + static bool eval(double d, mpq_srcptr q) + { return eval(q, d); } + static bool eval(mpq_srcptr q, mpz_srcptr z) + { return mpz_cmp_ui(mpq_denref(q), 1) == 0 && mpz_cmp(mpq_numref(q), z) == 0; } + static bool eval(mpz_srcptr z, mpq_srcptr q) + { return eval(q, z); } + + static bool eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g) == 0; } + + static bool eval(mpf_srcptr f, unsigned long int l) + { return mpf_cmp_ui(f, l) == 0; } + static bool eval(unsigned long int l, mpf_srcptr f) + { return eval(f, l); } + static bool eval(mpf_srcptr f, signed long int l) + { return mpf_cmp_si(f, l) == 0; } + static bool eval(signed long int l, mpf_srcptr f) + { return eval(f, l); } + static bool eval(mpf_srcptr f, double d) + { return mpf_cmp_d(f, d) == 0; } + static bool eval(double d, mpf_srcptr f) + { return eval(f, d); } + static bool eval(mpf_srcptr f, mpz_srcptr z) + { return mpf_cmp_z(f, z) == 0; } + static bool eval(mpz_srcptr z, mpf_srcptr f) + { return eval(f, z); } + static bool eval(mpf_srcptr f, mpq_srcptr q) + { return __gmp_cmp_function::eval(f, q) == 0; } + static bool eval(mpq_srcptr q, mpf_srcptr f) + { return eval(f, q); } +}; + +struct __gmp_binary_less +{ + static bool eval(mpz_srcptr z, mpz_srcptr w) { return mpz_cmp(z, w) < 0; } + + static bool eval(mpz_srcptr z, unsigned long int l) + { return mpz_cmp_ui(z, l) < 0; } + static bool eval(unsigned long int l, mpz_srcptr z) + { return mpz_cmp_ui(z, l) > 0; } + static bool eval(mpz_srcptr z, signed long int l) + { return mpz_cmp_si(z, l) < 0; } + static bool eval(signed long int l, mpz_srcptr z) + { return mpz_cmp_si(z, l) > 0; } + static bool eval(mpz_srcptr z, double d) + { return mpz_cmp_d(z, d) < 0; } + static bool eval(double d, mpz_srcptr z) + { return mpz_cmp_d(z, d) > 0; } + + static bool eval(mpq_srcptr q, mpq_srcptr r) { return mpq_cmp(q, r) < 0; } + + static bool eval(mpq_srcptr q, unsigned long int l) + { return mpq_cmp_ui(q, l, 1) < 0; } + static bool eval(unsigned long int l, mpq_srcptr q) + { return mpq_cmp_ui(q, l, 1) > 0; } + static bool eval(mpq_srcptr q, signed long int l) + { return mpq_cmp_si(q, l, 1) < 0; } + static bool eval(signed long int l, mpq_srcptr q) + { return mpq_cmp_si(q, l, 1) > 0; } + static bool eval(mpq_srcptr q, double d) + { __GMPXX_TMPQ_D; return mpq_cmp (q, temp) < 0; } + static bool eval(double d, mpq_srcptr q) + { __GMPXX_TMPQ_D; return mpq_cmp (temp, q) < 0; } + static bool eval(mpq_srcptr q, mpz_srcptr z) + { return mpq_cmp_z(q, z) < 0; } + static bool eval(mpz_srcptr z, mpq_srcptr q) + { return mpq_cmp_z(q, z) > 0; } + + static bool eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g) < 0; } + + static bool eval(mpf_srcptr f, unsigned long int l) + { return mpf_cmp_ui(f, l) < 0; } + static bool eval(unsigned long int l, mpf_srcptr f) + { return mpf_cmp_ui(f, l) > 0; } + static bool eval(mpf_srcptr f, signed long int l) + { return mpf_cmp_si(f, l) < 0; } + static bool eval(signed long int l, mpf_srcptr f) + { return mpf_cmp_si(f, l) > 0; } + static bool eval(mpf_srcptr f, double d) + { return mpf_cmp_d(f, d) < 0; } + static bool eval(double d, mpf_srcptr f) + { return mpf_cmp_d(f, d) > 0; } + static bool eval(mpf_srcptr f, mpz_srcptr z) + { return mpf_cmp_z(f, z) < 0; } + static bool eval(mpz_srcptr z, mpf_srcptr f) + { return mpf_cmp_z(f, z) > 0; } + static bool eval(mpf_srcptr f, mpq_srcptr q) + { return __gmp_cmp_function::eval(f, q) < 0; } + static bool eval(mpq_srcptr q, mpf_srcptr f) + { return __gmp_cmp_function::eval(q, f) < 0; } +}; + +struct __gmp_binary_greater +{ + template + static inline bool eval(T t, U u) { return __gmp_binary_less::eval(u, t); } +}; + +struct __gmp_unary_increment +{ + static void eval(mpz_ptr z) { mpz_add_ui(z, z, 1); } + static void eval(mpq_ptr q) + { mpz_add(mpq_numref(q), mpq_numref(q), mpq_denref(q)); } + static void eval(mpf_ptr f) { mpf_add_ui(f, f, 1); } +}; + +struct __gmp_unary_decrement +{ + static void eval(mpz_ptr z) { mpz_sub_ui(z, z, 1); } + static void eval(mpq_ptr q) + { mpz_sub(mpq_numref(q), mpq_numref(q), mpq_denref(q)); } + static void eval(mpf_ptr f) { mpf_sub_ui(f, f, 1); } +}; + +struct __gmp_abs_function +{ + static void eval(mpz_ptr z, mpz_srcptr w) { mpz_abs(z, w); } + static void eval(mpq_ptr q, mpq_srcptr r) { mpq_abs(q, r); } + static void eval(mpf_ptr f, mpf_srcptr g) { mpf_abs(f, g); } +}; + +struct __gmp_trunc_function +{ + static void eval(mpf_ptr f, mpf_srcptr g) { mpf_trunc(f, g); } +}; + +struct __gmp_floor_function +{ + static void eval(mpf_ptr f, mpf_srcptr g) { mpf_floor(f, g); } +}; + +struct __gmp_ceil_function +{ + static void eval(mpf_ptr f, mpf_srcptr g) { mpf_ceil(f, g); } +}; + +struct __gmp_sqrt_function +{ + static void eval(mpz_ptr z, mpz_srcptr w) { mpz_sqrt(z, w); } + static void eval(mpf_ptr f, mpf_srcptr g) { mpf_sqrt(f, g); } +}; + +struct __gmp_hypot_function +{ + static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) + { + mpf_t temp; + mpf_init2(temp, mpf_get_prec(f)); + mpf_mul(temp, g, g); + mpf_mul(f, h, h); + mpf_add(f, f, temp); + mpf_sqrt(f, f); + mpf_clear(temp); + } + + static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) + { + mpf_t temp; + mpf_init2(temp, mpf_get_prec(f)); + mpf_mul(temp, g, g); + mpf_set_ui(f, l); + mpf_mul_ui(f, f, l); + mpf_add(f, f, temp); + mpf_clear(temp); + mpf_sqrt(f, f); + } + static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) + { eval(f, g, l); } + static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) + { eval(f, g, __gmpxx_abs_ui(l)); } + static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) + { eval(f, g, l); } + static void eval(mpf_ptr f, mpf_srcptr g, double d) + { + mpf_t temp; + mpf_init2(temp, mpf_get_prec(f)); + mpf_mul(temp, g, g); + mpf_set_d(f, d); + mpf_mul(f, f, f); + mpf_add(f, f, temp); + mpf_sqrt(f, f); + mpf_clear(temp); + } + static void eval(mpf_ptr f, double d, mpf_srcptr g) + { eval(f, g, d); } +}; + +struct __gmp_sgn_function +{ + static int eval(mpz_srcptr z) { return mpz_sgn(z); } + static int eval(mpq_srcptr q) { return mpq_sgn(q); } + static int eval(mpf_srcptr f) { return mpf_sgn(f); } +}; + +struct __gmp_gcd_function +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_gcd(z, w, v); } + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { mpz_gcd_ui(z, w, l); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { eval(z, w, __gmpxx_abs_ui(l)); } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_gcd (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { eval(z, w, d); } +}; + +struct __gmp_lcm_function +{ + static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) + { mpz_lcm(z, w, v); } + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { mpz_lcm_ui(z, w, l); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { eval(z, w, __gmpxx_abs_ui(l)); } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { eval(z, w, l); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMPZ_D; mpz_lcm (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { eval(z, w, d); } +}; + +struct __gmp_rand_function +{ + static void eval(mpz_ptr z, gmp_randstate_t s, mp_bitcnt_t l) + { mpz_urandomb(z, s, l); } + static void eval(mpz_ptr z, gmp_randstate_t s, mpz_srcptr w) + { mpz_urandomm(z, s, w); } + static void eval(mpf_ptr f, gmp_randstate_t s, mp_bitcnt_t prec) + { mpf_urandomb(f, s, prec); } +}; + +struct __gmp_fac_function +{ + static void eval(mpz_ptr z, unsigned long l) { mpz_fac_ui(z, l); } + static void eval(mpz_ptr z, signed long l) + { + if (l < 0) + throw std::domain_error ("factorial(negative)"); + eval(z, static_cast(l)); + } + static void eval(mpz_ptr z, mpz_srcptr w) + { + if (!mpz_fits_ulong_p(w)) + { + if (mpz_sgn(w) < 0) + throw std::domain_error ("factorial(negative)"); + else + throw std::bad_alloc(); // or std::overflow_error ("factorial")? + } + eval(z, mpz_get_ui(w)); + } + static void eval(mpz_ptr z, double d) + { __GMPXX_TMPZ_D; eval (z, temp); } +}; + +struct __gmp_primorial_function +{ + static void eval(mpz_ptr z, unsigned long l) { mpz_primorial_ui(z, l); } + static void eval(mpz_ptr z, signed long l) + { + if (l < 0) + throw std::domain_error ("primorial(negative)"); + eval(z, static_cast(l)); + } + static void eval(mpz_ptr z, mpz_srcptr w) + { + if (!mpz_fits_ulong_p(w)) + { + if (mpz_sgn(w) < 0) + throw std::domain_error ("primorial(negative)"); + else + throw std::bad_alloc(); // or std::overflow_error ("primorial")? + } + eval(z, mpz_get_ui(w)); + } + static void eval(mpz_ptr z, double d) + { __GMPXX_TMPZ_D; eval (z, temp); } +}; + +struct __gmp_fib_function +{ + static void eval(mpz_ptr z, unsigned long l) { mpz_fib_ui(z, l); } + static void eval(mpz_ptr z, signed long l) + { + if (l < 0) + { + eval(z, -static_cast(l)); + if ((l & 1) == 0) + mpz_neg(z, z); + } + else + eval(z, static_cast(l)); + } + static void eval(mpz_ptr z, mpz_srcptr w) + { + if (!mpz_fits_slong_p(w)) + throw std::bad_alloc(); // or std::overflow_error ("fibonacci")? + eval(z, mpz_get_si(w)); + } + static void eval(mpz_ptr z, double d) + { __GMPXX_TMPZ_D; eval (z, temp); } +}; + + +/**************** Auxiliary classes ****************/ + +/* this is much the same as gmp_allocated_string in gmp-impl.h + since gmp-impl.h is not publicly available, I redefine it here + I use a different name to avoid possible clashes */ + +extern "C" { + typedef void (*__gmp_freefunc_t) (void *, size_t); +} +struct __gmp_alloc_cstring +{ + char *str; + __gmp_alloc_cstring(char *s) { str = s; } + ~__gmp_alloc_cstring() + { + __gmp_freefunc_t freefunc; + mp_get_memory_functions (NULL, NULL, &freefunc); + (*freefunc) (str, std::strlen(str)+1); + } +}; + + +// general expression template class +template +class __gmp_expr; + + +// templates for resolving expression types +template +struct __gmp_resolve_ref +{ + typedef T ref_type; +}; + +template +struct __gmp_resolve_ref<__gmp_expr > +{ + typedef const __gmp_expr & ref_type; +}; + + +template +struct __gmp_resolve_expr; + +template <> +struct __gmp_resolve_expr +{ + typedef mpz_t value_type; + typedef mpz_ptr ptr_type; + typedef mpz_srcptr srcptr_type; +}; + +template <> +struct __gmp_resolve_expr +{ + typedef mpq_t value_type; + typedef mpq_ptr ptr_type; + typedef mpq_srcptr srcptr_type; +}; + +template <> +struct __gmp_resolve_expr +{ + typedef mpf_t value_type; + typedef mpf_ptr ptr_type; + typedef mpf_srcptr srcptr_type; +}; + +template <> +struct __gmp_resolve_expr +{ + typedef mpq_t value_type; +}; + +template <> +struct __gmp_resolve_expr +{ + typedef mpq_t value_type; +}; + +template <> +struct __gmp_resolve_expr +{ + typedef mpf_t value_type; +}; + +template <> +struct __gmp_resolve_expr +{ + typedef mpf_t value_type; +}; + +template <> +struct __gmp_resolve_expr +{ + typedef mpf_t value_type; +}; + +template <> +struct __gmp_resolve_expr +{ + typedef mpf_t value_type; +}; + +#if __GMPXX_USE_CXX11 +namespace std { + template + struct common_type <__gmp_expr, __gmp_expr > + { + private: + typedef typename __gmp_resolve_expr::value_type X; + public: + typedef __gmp_expr type; + }; + + template + struct common_type <__gmp_expr > + { + typedef __gmp_expr type; + }; + +#define __GMPXX_DECLARE_COMMON_TYPE(typ) \ + template \ + struct common_type <__gmp_expr, typ > \ + { \ + typedef __gmp_expr type; \ + }; \ + \ + template \ + struct common_type > \ + { \ + typedef __gmp_expr type; \ + } + + __GMPXX_DECLARE_COMMON_TYPE(signed char); + __GMPXX_DECLARE_COMMON_TYPE(unsigned char); + __GMPXX_DECLARE_COMMON_TYPE(signed int); + __GMPXX_DECLARE_COMMON_TYPE(unsigned int); + __GMPXX_DECLARE_COMMON_TYPE(signed short int); + __GMPXX_DECLARE_COMMON_TYPE(unsigned short int); + __GMPXX_DECLARE_COMMON_TYPE(signed long int); + __GMPXX_DECLARE_COMMON_TYPE(unsigned long int); + __GMPXX_DECLARE_COMMON_TYPE(float); + __GMPXX_DECLARE_COMMON_TYPE(double); +#undef __GMPXX_DECLARE_COMMON_TYPE +} +#endif + +// classes for evaluating unary and binary expressions +template +struct __gmp_unary_expr +{ + typename __gmp_resolve_ref::ref_type val; + + __gmp_unary_expr(const T &v) : val(v) { } +private: + __gmp_unary_expr(); +}; + +template +struct __gmp_binary_expr +{ + typename __gmp_resolve_ref::ref_type val1; + typename __gmp_resolve_ref::ref_type val2; + + __gmp_binary_expr(const T &v1, const U &v2) : val1(v1), val2(v2) { } +private: + __gmp_binary_expr(); +}; + + + +/**************** Macros for in-class declarations ****************/ +/* This is just repetitive code that is easier to maintain if it's written + only once */ + +#define __GMPP_DECLARE_COMPOUND_OPERATOR(fun) \ + template \ + __gmp_expr & fun(const __gmp_expr &); + +#define __GMPN_DECLARE_COMPOUND_OPERATOR(fun) \ + __gmp_expr & fun(signed char); \ + __gmp_expr & fun(unsigned char); \ + __gmp_expr & fun(signed int); \ + __gmp_expr & fun(unsigned int); \ + __gmp_expr & fun(signed short int); \ + __gmp_expr & fun(unsigned short int); \ + __gmp_expr & fun(signed long int); \ + __gmp_expr & fun(unsigned long int); \ + __gmp_expr & fun(float); \ + __gmp_expr & fun(double); \ + /* __gmp_expr & fun(long double); */ + +#define __GMP_DECLARE_COMPOUND_OPERATOR(fun) \ +__GMPP_DECLARE_COMPOUND_OPERATOR(fun) \ +__GMPN_DECLARE_COMPOUND_OPERATOR(fun) + +#define __GMP_DECLARE_COMPOUND_OPERATOR_UI(fun) \ + __gmp_expr & fun(mp_bitcnt_t); + +#define __GMP_DECLARE_INCREMENT_OPERATOR(fun) \ + inline __gmp_expr & fun(); \ + inline __gmp_expr fun(int); + +#define __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS \ + __gmp_expr(signed char c) { init_si(c); } \ + __gmp_expr(unsigned char c) { init_ui(c); } \ + __gmp_expr(signed int i) { init_si(i); } \ + __gmp_expr(unsigned int i) { init_ui(i); } \ + __gmp_expr(signed short int s) { init_si(s); } \ + __gmp_expr(unsigned short int s) { init_ui(s); } \ + __gmp_expr(signed long int l) { init_si(l); } \ + __gmp_expr(unsigned long int l) { init_ui(l); } \ + __gmp_expr(float f) { init_d(f); } \ + __gmp_expr(double d) { init_d(d); } + +#define __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS \ + __gmp_expr & operator=(signed char c) { assign_si(c); return *this; } \ + __gmp_expr & operator=(unsigned char c) { assign_ui(c); return *this; } \ + __gmp_expr & operator=(signed int i) { assign_si(i); return *this; } \ + __gmp_expr & operator=(unsigned int i) { assign_ui(i); return *this; } \ + __gmp_expr & operator=(signed short int s) { assign_si(s); return *this; } \ + __gmp_expr & operator=(unsigned short int s) { assign_ui(s); return *this; } \ + __gmp_expr & operator=(signed long int l) { assign_si(l); return *this; } \ + __gmp_expr & operator=(unsigned long int l) { assign_ui(l); return *this; } \ + __gmp_expr & operator=(float f) { assign_d(f); return *this; } \ + __gmp_expr & operator=(double d) { assign_d(d); return *this; } + +#define __GMPP_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ +template \ +static __gmp_expr, eval_fun> > \ +fun(const __gmp_expr &expr); + +#define __GMPNN_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type, bigtype) \ +static inline __gmp_expr > \ +fun(type expr); + +#define __GMPNS_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type) \ +__GMPNN_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type, signed long) +#define __GMPNU_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type) \ +__GMPNN_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type, unsigned long) +#define __GMPND_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type) \ +__GMPNN_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type, double) + +#define __GMPN_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ +__GMPNS_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, signed char) \ +__GMPNU_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, unsigned char) \ +__GMPNS_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, signed int) \ +__GMPNU_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, unsigned int) \ +__GMPNS_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, signed short int) \ +__GMPNU_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, unsigned short int) \ +__GMPNS_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, signed long int) \ +__GMPNU_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, unsigned long int) \ +__GMPND_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, float) \ +__GMPND_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, double) + +#define __GMP_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ +__GMPP_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ +__GMPN_DECLARE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) + +/**************** mpz_class -- wrapper for mpz_t ****************/ + +template <> +class __gmp_expr +{ +private: + typedef mpz_t value_type; + value_type mp; + + // Helper functions used for all arithmetic types + void assign_ui(unsigned long l) + { + if (__GMPXX_CONSTANT_TRUE(l == 0)) + __get_mp()->_mp_size = 0; + else + mpz_set_ui(mp, l); + } + void assign_si(signed long l) + { + if (__GMPXX_CONSTANT_TRUE(l >= 0)) + assign_ui(l); + else if (__GMPXX_CONSTANT_TRUE(l <= 0)) + { + assign_ui(-static_cast(l)); + mpz_neg(mp, mp); + } + else + mpz_set_si(mp, l); + } + void assign_d (double d) + { + mpz_set_d (mp, d); + } + + void init_ui(unsigned long l) + { + if (__GMPXX_CONSTANT_TRUE(l == 0)) + mpz_init(mp); + else + mpz_init_set_ui(mp, l); + } + void init_si(signed long l) + { + if (__GMPXX_CONSTANT_TRUE(l >= 0)) + init_ui(l); + else if (__GMPXX_CONSTANT_TRUE(l <= 0)) + { + init_ui(-static_cast(l)); + mpz_neg(mp, mp); + } + else + mpz_init_set_si(mp, l); + } + void init_d (double d) + { + mpz_init_set_d (mp, d); + } + +public: + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } + + // constructors and destructor + __gmp_expr() __GMPXX_NOEXCEPT { mpz_init(mp); } + + __gmp_expr(const __gmp_expr &z) { mpz_init_set(mp, z.mp); } +#if __GMPXX_USE_CXX11 + __gmp_expr(__gmp_expr &&z) noexcept + { *__get_mp() = *z.__get_mp(); mpz_init(z.mp); } +#endif + template + __gmp_expr(const __gmp_expr &expr) + { mpz_init(mp); __gmp_set_expr(mp, expr); } + template + explicit __gmp_expr(const __gmp_expr &expr) + { mpz_init(mp); __gmp_set_expr(mp, expr); } + + __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS + + explicit __gmp_expr(const char *s, int base = 0) + { + if (mpz_init_set_str (mp, s, base) != 0) + { + mpz_clear (mp); + throw std::invalid_argument ("mpz_set_str"); + } + } + explicit __gmp_expr(const std::string &s, int base = 0) + { + if (mpz_init_set_str(mp, s.c_str(), base) != 0) + { + mpz_clear (mp); + throw std::invalid_argument ("mpz_set_str"); + } + } + + explicit __gmp_expr(mpz_srcptr z) { mpz_init_set(mp, z); } + + ~__gmp_expr() { mpz_clear(mp); } + + void swap(__gmp_expr& z) __GMPXX_NOEXCEPT + { std::swap(*__get_mp(), *z.__get_mp()); } + + // assignment operators + __gmp_expr & operator=(const __gmp_expr &z) + { mpz_set(mp, z.mp); return *this; } +#if __GMPXX_USE_CXX11 + __gmp_expr & operator=(__gmp_expr &&z) noexcept + { swap(z); return *this; } +#endif + template + __gmp_expr & operator=(const __gmp_expr &expr) + { __gmp_set_expr(mp, expr); return *this; } + + __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS + + __gmp_expr & operator=(const char *s) + { + if (mpz_set_str (mp, s, 0) != 0) + throw std::invalid_argument ("mpz_set_str"); + return *this; + } + __gmp_expr & operator=(const std::string &s) + { + if (mpz_set_str(mp, s.c_str(), 0) != 0) + throw std::invalid_argument ("mpz_set_str"); + return *this; + } + + // string input/output functions + int set_str(const char *s, int base) + { return mpz_set_str(mp, s, base); } + int set_str(const std::string &s, int base) + { return mpz_set_str(mp, s.c_str(), base); } + std::string get_str(int base = 10) const + { + __gmp_alloc_cstring temp(mpz_get_str(0, base, mp)); + return std::string(temp.str); + } + + // conversion functions + mpz_srcptr __get_mp() const { return mp; } + mpz_ptr __get_mp() { return mp; } + mpz_srcptr get_mpz_t() const { return mp; } + mpz_ptr get_mpz_t() { return mp; } + + signed long int get_si() const { return mpz_get_si(mp); } + unsigned long int get_ui() const { return mpz_get_ui(mp); } + double get_d() const { return mpz_get_d(mp); } + + // bool fits_schar_p() const { return mpz_fits_schar_p(mp); } + // bool fits_uchar_p() const { return mpz_fits_uchar_p(mp); } + bool fits_sint_p() const { return mpz_fits_sint_p(mp); } + bool fits_uint_p() const { return mpz_fits_uint_p(mp); } + bool fits_sshort_p() const { return mpz_fits_sshort_p(mp); } + bool fits_ushort_p() const { return mpz_fits_ushort_p(mp); } + bool fits_slong_p() const { return mpz_fits_slong_p(mp); } + bool fits_ulong_p() const { return mpz_fits_ulong_p(mp); } + // bool fits_float_p() const { return mpz_fits_float_p(mp); } + // bool fits_double_p() const { return mpz_fits_double_p(mp); } + // bool fits_ldouble_p() const { return mpz_fits_ldouble_p(mp); } + +#if __GMPXX_USE_CXX11 + explicit operator bool() const { return __get_mp()->_mp_size != 0; } +#endif + + // member operators + __GMP_DECLARE_COMPOUND_OPERATOR(operator+=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator-=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator*=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator/=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator%=) + + __GMP_DECLARE_COMPOUND_OPERATOR(operator&=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator|=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator^=) + + __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator<<=) + __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator>>=) + + __GMP_DECLARE_INCREMENT_OPERATOR(operator++) + __GMP_DECLARE_INCREMENT_OPERATOR(operator--) + + __GMP_DECLARE_UNARY_STATIC_MEMFUN(mpz_t, factorial, __gmp_fac_function) + __GMP_DECLARE_UNARY_STATIC_MEMFUN(mpz_t, primorial, __gmp_primorial_function) + __GMP_DECLARE_UNARY_STATIC_MEMFUN(mpz_t, fibonacci, __gmp_fib_function) +}; + +typedef __gmp_expr mpz_class; + + +/**************** mpq_class -- wrapper for mpq_t ****************/ + +template <> +class __gmp_expr +{ +private: + typedef mpq_t value_type; + value_type mp; + + // Helper functions used for all arithmetic types + void assign_ui(unsigned long l) { mpq_set_ui(mp, l, 1); } + void assign_si(signed long l) + { + if (__GMPXX_CONSTANT_TRUE(l >= 0)) + assign_ui(l); + else + mpq_set_si(mp, l, 1); + } + void assign_d (double d) { mpq_set_d (mp, d); } + + void init_ui(unsigned long l) { mpq_init(mp); get_num() = l; } + void init_si(signed long l) { mpq_init(mp); get_num() = l; } + void init_d (double d) { mpq_init(mp); assign_d (d); } + +public: + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } + void canonicalize() { mpq_canonicalize(mp); } + + // constructors and destructor + __gmp_expr() { mpq_init(mp); } + + __gmp_expr(const __gmp_expr &q) + { + mpz_init_set(mpq_numref(mp), mpq_numref(q.mp)); + mpz_init_set(mpq_denref(mp), mpq_denref(q.mp)); + } +#if __GMPXX_USE_CXX11 + __gmp_expr(__gmp_expr &&q) + { *mp = *q.mp; mpq_init(q.mp); } + __gmp_expr(mpz_class &&z) + { + *mpq_numref(mp) = *z.get_mpz_t(); + mpz_init_set_ui(mpq_denref(mp), 1); + mpz_init(z.get_mpz_t()); + } +#endif + template + __gmp_expr(const __gmp_expr &expr) + { mpq_init(mp); __gmp_set_expr(mp, expr); } + template + __gmp_expr(const __gmp_expr &expr) + { mpq_init(mp); __gmp_set_expr(mp, expr); } + template + explicit __gmp_expr(const __gmp_expr &expr) + { mpq_init(mp); __gmp_set_expr(mp, expr); } + + __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS + + explicit __gmp_expr(const char *s, int base = 0) + { + mpq_init (mp); + // If s is the literal 0, we meant to call another constructor. + // If s just happens to evaluate to 0, we would crash, so whatever. + if (s == 0) + { + // Don't turn mpq_class(0,0) into 0 + mpz_set_si(mpq_denref(mp), base); + } + else if (mpq_set_str(mp, s, base) != 0) + { + mpq_clear (mp); + throw std::invalid_argument ("mpq_set_str"); + } + } + explicit __gmp_expr(const std::string &s, int base = 0) + { + mpq_init(mp); + if (mpq_set_str (mp, s.c_str(), base) != 0) + { + mpq_clear (mp); + throw std::invalid_argument ("mpq_set_str"); + } + } + explicit __gmp_expr(mpq_srcptr q) + { + mpz_init_set(mpq_numref(mp), mpq_numref(q)); + mpz_init_set(mpq_denref(mp), mpq_denref(q)); + } + + __gmp_expr(const mpz_class &num, const mpz_class &den) + { + mpz_init_set(mpq_numref(mp), num.get_mpz_t()); + mpz_init_set(mpq_denref(mp), den.get_mpz_t()); + } + + ~__gmp_expr() { mpq_clear(mp); } + + void swap(__gmp_expr& q) __GMPXX_NOEXCEPT { std::swap(*mp, *q.mp); } + + // assignment operators + __gmp_expr & operator=(const __gmp_expr &q) + { mpq_set(mp, q.mp); return *this; } +#if __GMPXX_USE_CXX11 + __gmp_expr & operator=(__gmp_expr &&q) noexcept + { swap(q); return *this; } + __gmp_expr & operator=(mpz_class &&z) noexcept + { get_num() = std::move(z); get_den() = 1u; return *this; } +#endif + template + __gmp_expr & operator=(const __gmp_expr &expr) + { __gmp_set_expr(mp, expr); return *this; } + + __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS + + __gmp_expr & operator=(const char *s) + { + if (mpq_set_str (mp, s, 0) != 0) + throw std::invalid_argument ("mpq_set_str"); + return *this; + } + __gmp_expr & operator=(const std::string &s) + { + if (mpq_set_str(mp, s.c_str(), 0) != 0) + throw std::invalid_argument ("mpq_set_str"); + return *this; + } + + // string input/output functions + int set_str(const char *s, int base) + { return mpq_set_str(mp, s, base); } + int set_str(const std::string &s, int base) + { return mpq_set_str(mp, s.c_str(), base); } + std::string get_str(int base = 10) const + { + __gmp_alloc_cstring temp(mpq_get_str(0, base, mp)); + return std::string(temp.str); + } + + // conversion functions + + // casting a reference to an mpz_t to mpz_class & is a dirty hack. + // It kind of works because the internal representation of mpz_class is + // exactly an mpz_t, but compilers are allowed to assume that mpq_class + // and mpz_class do not alias... In mpz_class, we avoid using mp directly, + // to reduce the risks of such problematic optimizations. + const mpz_class & get_num() const + { return reinterpret_cast(*mpq_numref(mp)); } + mpz_class & get_num() + { return reinterpret_cast(*mpq_numref(mp)); } + const mpz_class & get_den() const + { return reinterpret_cast(*mpq_denref(mp)); } + mpz_class & get_den() + { return reinterpret_cast(*mpq_denref(mp)); } + + mpq_srcptr __get_mp() const { return mp; } + mpq_ptr __get_mp() { return mp; } + mpq_srcptr get_mpq_t() const { return mp; } + mpq_ptr get_mpq_t() { return mp; } + + mpz_srcptr get_num_mpz_t() const { return mpq_numref(mp); } + mpz_ptr get_num_mpz_t() { return mpq_numref(mp); } + mpz_srcptr get_den_mpz_t() const { return mpq_denref(mp); } + mpz_ptr get_den_mpz_t() { return mpq_denref(mp); } + + double get_d() const { return mpq_get_d(mp); } + +#if __GMPXX_USE_CXX11 + explicit operator bool() const { return mpq_numref(mp)->_mp_size != 0; } +#endif + + // compound assignments + __GMP_DECLARE_COMPOUND_OPERATOR(operator+=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator-=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator*=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator/=) + + __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator<<=) + __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator>>=) + + __GMP_DECLARE_INCREMENT_OPERATOR(operator++) + __GMP_DECLARE_INCREMENT_OPERATOR(operator--) +}; + +typedef __gmp_expr mpq_class; + + +/**************** mpf_class -- wrapper for mpf_t ****************/ + +template <> +class __gmp_expr +{ +private: + typedef mpf_t value_type; + value_type mp; + + // Helper functions used for all arithmetic types + void assign_ui(unsigned long l) { mpf_set_ui(mp, l); } + void assign_si(signed long l) + { + if (__GMPXX_CONSTANT_TRUE(l >= 0)) + assign_ui(l); + else + mpf_set_si(mp, l); + } + void assign_d (double d) { mpf_set_d (mp, d); } + + void init_ui(unsigned long l) + { + if (__GMPXX_CONSTANT_TRUE(l == 0)) + mpf_init(mp); + else + mpf_init_set_ui(mp, l); + } + void init_si(signed long l) + { + if (__GMPXX_CONSTANT_TRUE(l >= 0)) + init_ui(l); + else + mpf_init_set_si(mp, l); + } + void init_d (double d) { mpf_init_set_d (mp, d); } + +public: + mp_bitcnt_t get_prec() const { return mpf_get_prec(mp); } + + void set_prec(mp_bitcnt_t prec) { mpf_set_prec(mp, prec); } + void set_prec_raw(mp_bitcnt_t prec) { mpf_set_prec_raw(mp, prec); } + + // constructors and destructor + __gmp_expr() { mpf_init(mp); } + + __gmp_expr(const __gmp_expr &f) + { mpf_init2(mp, f.get_prec()); mpf_set(mp, f.mp); } +#if __GMPXX_USE_CXX11 + __gmp_expr(__gmp_expr &&f) + { *mp = *f.mp; mpf_init2(f.mp, get_prec()); } +#endif + __gmp_expr(const __gmp_expr &f, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set(mp, f.mp); } + template + __gmp_expr(const __gmp_expr &expr) + { mpf_init2(mp, expr.get_prec()); __gmp_set_expr(mp, expr); } + template + __gmp_expr(const __gmp_expr &expr, mp_bitcnt_t prec) + { mpf_init2(mp, prec); __gmp_set_expr(mp, expr); } + + __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS + + __gmp_expr(signed char c, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_si(mp, c); } + __gmp_expr(unsigned char c, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_ui(mp, c); } + + __gmp_expr(signed int i, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_si(mp, i); } + __gmp_expr(unsigned int i, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_ui(mp, i); } + + __gmp_expr(signed short int s, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_si(mp, s); } + __gmp_expr(unsigned short int s, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_ui(mp, s); } + + __gmp_expr(signed long int l, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_si(mp, l); } + __gmp_expr(unsigned long int l, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_ui(mp, l); } + + __gmp_expr(float f, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_d(mp, f); } + __gmp_expr(double d, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set_d(mp, d); } + // __gmp_expr(long double ld) { mpf_init_set_d(mp, ld); } + // __gmp_expr(long double ld, mp_bitcnt_t prec) + // { mpf_init2(mp, prec); mpf_set_d(mp, ld); } + + explicit __gmp_expr(const char *s) + { + if (mpf_init_set_str (mp, s, 0) != 0) + { + mpf_clear (mp); + throw std::invalid_argument ("mpf_set_str"); + } + } + __gmp_expr(const char *s, mp_bitcnt_t prec, int base = 0) + { + mpf_init2(mp, prec); + if (mpf_set_str(mp, s, base) != 0) + { + mpf_clear (mp); + throw std::invalid_argument ("mpf_set_str"); + } + } + explicit __gmp_expr(const std::string &s) + { + if (mpf_init_set_str(mp, s.c_str(), 0) != 0) + { + mpf_clear (mp); + throw std::invalid_argument ("mpf_set_str"); + } + } + __gmp_expr(const std::string &s, mp_bitcnt_t prec, int base = 0) + { + mpf_init2(mp, prec); + if (mpf_set_str(mp, s.c_str(), base) != 0) + { + mpf_clear (mp); + throw std::invalid_argument ("mpf_set_str"); + } + } + + explicit __gmp_expr(mpf_srcptr f) + { mpf_init2(mp, mpf_get_prec(f)); mpf_set(mp, f); } + __gmp_expr(mpf_srcptr f, mp_bitcnt_t prec) + { mpf_init2(mp, prec); mpf_set(mp, f); } + + ~__gmp_expr() { mpf_clear(mp); } + + void swap(__gmp_expr& f) __GMPXX_NOEXCEPT { std::swap(*mp, *f.mp); } + + // assignment operators + __gmp_expr & operator=(const __gmp_expr &f) + { mpf_set(mp, f.mp); return *this; } +#if __GMPXX_USE_CXX11 + __gmp_expr & operator=(__gmp_expr &&f) noexcept + { swap(f); return *this; } +#endif + template + __gmp_expr & operator=(const __gmp_expr &expr) + { __gmp_set_expr(mp, expr); return *this; } + + __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS + + __gmp_expr & operator=(const char *s) + { + if (mpf_set_str (mp, s, 0) != 0) + throw std::invalid_argument ("mpf_set_str"); + return *this; + } + __gmp_expr & operator=(const std::string &s) + { + if (mpf_set_str(mp, s.c_str(), 0) != 0) + throw std::invalid_argument ("mpf_set_str"); + return *this; + } + + // string input/output functions + int set_str(const char *s, int base) + { return mpf_set_str(mp, s, base); } + int set_str(const std::string &s, int base) + { return mpf_set_str(mp, s.c_str(), base); } + std::string get_str(mp_exp_t &expo, int base = 10, size_t size = 0) const + { + __gmp_alloc_cstring temp(mpf_get_str(0, &expo, base, size, mp)); + return std::string(temp.str); + } + + // conversion functions + mpf_srcptr __get_mp() const { return mp; } + mpf_ptr __get_mp() { return mp; } + mpf_srcptr get_mpf_t() const { return mp; } + mpf_ptr get_mpf_t() { return mp; } + + signed long int get_si() const { return mpf_get_si(mp); } + unsigned long int get_ui() const { return mpf_get_ui(mp); } + double get_d() const { return mpf_get_d(mp); } + + // bool fits_schar_p() const { return mpf_fits_schar_p(mp); } + // bool fits_uchar_p() const { return mpf_fits_uchar_p(mp); } + bool fits_sint_p() const { return mpf_fits_sint_p(mp); } + bool fits_uint_p() const { return mpf_fits_uint_p(mp); } + bool fits_sshort_p() const { return mpf_fits_sshort_p(mp); } + bool fits_ushort_p() const { return mpf_fits_ushort_p(mp); } + bool fits_slong_p() const { return mpf_fits_slong_p(mp); } + bool fits_ulong_p() const { return mpf_fits_ulong_p(mp); } + // bool fits_float_p() const { return mpf_fits_float_p(mp); } + // bool fits_double_p() const { return mpf_fits_double_p(mp); } + // bool fits_ldouble_p() const { return mpf_fits_ldouble_p(mp); } + +#if __GMPXX_USE_CXX11 + explicit operator bool() const { return mpf_sgn(mp) != 0; } +#endif + + // compound assignments + __GMP_DECLARE_COMPOUND_OPERATOR(operator+=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator-=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator*=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator/=) + + __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator<<=) + __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator>>=) + + __GMP_DECLARE_INCREMENT_OPERATOR(operator++) + __GMP_DECLARE_INCREMENT_OPERATOR(operator--) +}; + +typedef __gmp_expr mpf_class; + + + +/**************** User-defined literals ****************/ + +#if __GMPXX_USE_CXX11 +inline mpz_class operator"" _mpz(const char* s) +{ + return mpz_class(s); +} + +inline mpq_class operator"" _mpq(const char* s) +{ + mpq_class q; + q.get_num() = s; + return q; +} + +inline mpf_class operator"" _mpf(const char* s) +{ + return mpf_class(s); +} +#endif + +/**************** I/O operators ****************/ + +// these should (and will) be provided separately + +template +inline std::ostream & operator<< +(std::ostream &o, const __gmp_expr &expr) +{ + __gmp_expr const& temp(expr); + return o << temp.__get_mp(); +} + +template +inline std::istream & operator>>(std::istream &i, __gmp_expr &expr) +{ + return i >> expr.__get_mp(); +} + +/* +// you might want to uncomment this +inline std::istream & operator>>(std::istream &i, mpq_class &q) +{ + i >> q.get_mpq_t(); + q.canonicalize(); + return i; +} +*/ + + +/**************** Functions for type conversion ****************/ + +inline void __gmp_set_expr(mpz_ptr z, const mpz_class &w) +{ + mpz_set(z, w.get_mpz_t()); +} + +template +inline void __gmp_set_expr(mpz_ptr z, const __gmp_expr &expr) +{ + expr.eval(z); +} + +template +inline void __gmp_set_expr(mpz_ptr z, const __gmp_expr &expr) +{ + mpq_class const& temp(expr); + mpz_set_q(z, temp.get_mpq_t()); +} + +template +inline void __gmp_set_expr(mpz_ptr z, const __gmp_expr &expr) +{ + mpf_class const& temp(expr); + mpz_set_f(z, temp.get_mpf_t()); +} + +inline void __gmp_set_expr(mpq_ptr q, const mpz_class &z) +{ + mpq_set_z(q, z.get_mpz_t()); +} + +template +inline void __gmp_set_expr(mpq_ptr q, const __gmp_expr &expr) +{ + __gmp_set_expr(mpq_numref(q), expr); + mpz_set_ui(mpq_denref(q), 1); +} + +inline void __gmp_set_expr(mpq_ptr q, const mpq_class &r) +{ + mpq_set(q, r.get_mpq_t()); +} + +template +inline void __gmp_set_expr(mpq_ptr q, const __gmp_expr &expr) +{ + expr.eval(q); +} + +template +inline void __gmp_set_expr(mpq_ptr q, const __gmp_expr &expr) +{ + mpf_class const& temp(expr); + mpq_set_f(q, temp.get_mpf_t()); +} + +template +inline void __gmp_set_expr(mpf_ptr f, const __gmp_expr &expr) +{ + mpz_class const& temp(expr); + mpf_set_z(f, temp.get_mpz_t()); +} + +template +inline void __gmp_set_expr(mpf_ptr f, const __gmp_expr &expr) +{ + mpq_class const& temp(expr); + mpf_set_q(f, temp.get_mpq_t()); +} + +inline void __gmp_set_expr(mpf_ptr f, const mpf_class &g) +{ + mpf_set(f, g.get_mpf_t()); +} + +template +inline void __gmp_set_expr(mpf_ptr f, const __gmp_expr &expr) +{ + expr.eval(f); +} + + +/* Temporary objects */ + +template +class __gmp_temp +{ + __gmp_expr val; + public: + template + __gmp_temp(U const& u, V) : val (u) {} + typename __gmp_resolve_expr::srcptr_type + __get_mp() const { return val.__get_mp(); } +}; + +template <> +class __gmp_temp +{ + mpf_class val; + public: + template + __gmp_temp(U const& u, mpf_ptr res) : val (u, mpf_get_prec(res)) {} + mpf_srcptr __get_mp() const { return val.__get_mp(); } +}; + +/**************** Specializations of __gmp_expr ****************/ +/* The eval() method of __gmp_expr evaluates the corresponding + expression and assigns the result to its argument, which is either an + mpz_t, mpq_t, or mpf_t as specified by the T argument. + Compound expressions are evaluated recursively (temporaries are created + to hold intermediate values), while for simple expressions the eval() + method of the appropriate function object (available as the Op argument + of either __gmp_unary_expr or __gmp_binary_expr) is + called. */ + + +/**************** Unary expressions ****************/ +/* cases: + - simple: argument is mp*_class, that is, __gmp_expr + - compound: argument is __gmp_expr (with U not equal to T) */ + + +// simple expressions + +template +class __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val_type; + + __gmp_unary_expr expr; +public: + explicit __gmp_expr(const val_type &val) : expr(val) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { Op::eval(p, expr.val.__get_mp()); } + const val_type & get_val() const { return expr.val; } + mp_bitcnt_t get_prec() const { return expr.val.get_prec(); } +}; + + +// simple expressions, U is a built-in numerical type + +template +class __gmp_expr > +{ +private: + typedef U val_type; + + __gmp_unary_expr expr; +public: + explicit __gmp_expr(const val_type &val) : expr(val) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { Op::eval(p, expr.val); } + const val_type & get_val() const { return expr.val; } + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } +}; + + +// compound expressions + +template +class __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val_type; + + __gmp_unary_expr expr; +public: + explicit __gmp_expr(const val_type &val) : expr(val) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { expr.val.eval(p); Op::eval(p, p); } + const val_type & get_val() const { return expr.val; } + mp_bitcnt_t get_prec() const { return expr.val.get_prec(); } +}; + + +/**************** Binary expressions ****************/ +/* simple: + - arguments are both mp*_class + - one argument is mp*_class, one is a built-in type + compound: + - one is mp*_class, one is __gmp_expr + - one is __gmp_expr, one is built-in + - both arguments are __gmp_expr<...> */ + + +// simple expressions + +template +class __gmp_expr +, __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { Op::eval(p, expr.val1.__get_mp(), expr.val2.__get_mp()); } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const + { + mp_bitcnt_t prec1 = expr.val1.get_prec(), + prec2 = expr.val2.get_prec(); + return (prec1 > prec2) ? prec1 : prec2; + } +}; + + +// simple expressions, U is a built-in numerical type + +template +class __gmp_expr, U, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef U val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { Op::eval(p, expr.val1.__get_mp(), expr.val2); } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const { return expr.val1.get_prec(); } +}; + +template +class __gmp_expr, Op> > +{ +private: + typedef U val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { Op::eval(p, expr.val1, expr.val2.__get_mp()); } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const { return expr.val2.get_prec(); } +}; + + +// compound expressions, one argument is a subexpression + +template +class __gmp_expr +, __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + if(p != expr.val1.__get_mp()) + { + __gmp_set_expr(p, expr.val2); + Op::eval(p, expr.val1.__get_mp(), p); + } + else + { + __gmp_temp temp(expr.val2, p); + Op::eval(p, expr.val1.__get_mp(), temp.__get_mp()); + } + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const + { + mp_bitcnt_t prec1 = expr.val1.get_prec(), + prec2 = expr.val2.get_prec(); + return (prec1 > prec2) ? prec1 : prec2; + } +}; + +template +class __gmp_expr +, __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + if(p != expr.val2.__get_mp()) + { + __gmp_set_expr(p, expr.val1); + Op::eval(p, p, expr.val2.__get_mp()); + } + else + { + __gmp_temp temp(expr.val1, p); + Op::eval(p, temp.__get_mp(), expr.val2.__get_mp()); + } + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const + { + mp_bitcnt_t prec1 = expr.val1.get_prec(), + prec2 = expr.val2.get_prec(); + return (prec1 > prec2) ? prec1 : prec2; + } +}; + +template +class __gmp_expr +, __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + if(p != expr.val1.__get_mp()) + { + __gmp_set_expr(p, expr.val2); + Op::eval(p, expr.val1.__get_mp(), p); + } + else + { + __gmp_temp temp(expr.val2, p); + Op::eval(p, expr.val1.__get_mp(), temp.__get_mp()); + } + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const + { + mp_bitcnt_t prec1 = expr.val1.get_prec(), + prec2 = expr.val2.get_prec(); + return (prec1 > prec2) ? prec1 : prec2; + } +}; + +template +class __gmp_expr +, __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + if(p != expr.val2.__get_mp()) + { + __gmp_set_expr(p, expr.val1); + Op::eval(p, p, expr.val2.__get_mp()); + } + else + { + __gmp_temp temp(expr.val1, p); + Op::eval(p, temp.__get_mp(), expr.val2.__get_mp()); + } + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const + { + mp_bitcnt_t prec1 = expr.val1.get_prec(), + prec2 = expr.val2.get_prec(); + return (prec1 > prec2) ? prec1 : prec2; + } +}; + + +// one argument is a subexpression, one is a built-in + +template +class __gmp_expr, V, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef V val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + expr.val1.eval(p); + Op::eval(p, p, expr.val2); + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const { return expr.val1.get_prec(); } +}; + +template +class __gmp_expr, Op> > +{ +private: + typedef U val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + expr.val2.eval(p); + Op::eval(p, expr.val1, p); + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const { return expr.val2.get_prec(); } +}; + + +// both arguments are subexpressions + +template +class __gmp_expr +, __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + __gmp_temp temp2(expr.val2, p); + expr.val1.eval(p); + Op::eval(p, p, temp2.__get_mp()); + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const + { + mp_bitcnt_t prec1 = expr.val1.get_prec(), + prec2 = expr.val2.get_prec(); + return (prec1 > prec2) ? prec1 : prec2; + } +}; + +template +class __gmp_expr +, __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + __gmp_temp temp1(expr.val1, p); + expr.val2.eval(p); + Op::eval(p, temp1.__get_mp(), p); + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const + { + mp_bitcnt_t prec1 = expr.val1.get_prec(), + prec2 = expr.val2.get_prec(); + return (prec1 > prec2) ? prec1 : prec2; + } +}; + +template +class __gmp_expr +, __gmp_expr, Op> > +{ +private: + typedef __gmp_expr val1_type; + typedef __gmp_expr val2_type; + + __gmp_binary_expr expr; +public: + __gmp_expr(const val1_type &val1, const val2_type &val2) + : expr(val1, val2) { } + void eval(typename __gmp_resolve_expr::ptr_type p) const + { + __gmp_temp temp2(expr.val2, p); + expr.val1.eval(p); + Op::eval(p, p, temp2.__get_mp()); + } + const val1_type & get_val1() const { return expr.val1; } + const val2_type & get_val2() const { return expr.val2; } + mp_bitcnt_t get_prec() const + { + mp_bitcnt_t prec1 = expr.val1.get_prec(), + prec2 = expr.val2.get_prec(); + return (prec1 > prec2) ? prec1 : prec2; + } +}; + + +/**************** Special cases ****************/ + +/* Some operations (i.e., add and subtract) with mixed mpz/mpq arguments + can be done directly without first converting the mpz to mpq. + Appropriate specializations of __gmp_expr are required. */ + + +#define __GMPZQ_DEFINE_EXPR(eval_fun) \ + \ +template <> \ +class __gmp_expr > \ +{ \ +private: \ + typedef mpz_class val1_type; \ + typedef mpq_class val2_type; \ + \ + __gmp_binary_expr expr; \ +public: \ + __gmp_expr(const val1_type &val1, const val2_type &val2) \ + : expr(val1, val2) { } \ + void eval(mpq_ptr q) const \ + { eval_fun::eval(q, expr.val1.get_mpz_t(), expr.val2.get_mpq_t()); } \ + const val1_type & get_val1() const { return expr.val1; } \ + const val2_type & get_val2() const { return expr.val2; } \ + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ +}; \ + \ +template <> \ +class __gmp_expr > \ +{ \ +private: \ + typedef mpq_class val1_type; \ + typedef mpz_class val2_type; \ + \ + __gmp_binary_expr expr; \ +public: \ + __gmp_expr(const val1_type &val1, const val2_type &val2) \ + : expr(val1, val2) { } \ + void eval(mpq_ptr q) const \ + { eval_fun::eval(q, expr.val1.get_mpq_t(), expr.val2.get_mpz_t()); } \ + const val1_type & get_val1() const { return expr.val1; } \ + const val2_type & get_val2() const { return expr.val2; } \ + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ +}; \ + \ +template \ +class __gmp_expr \ +, eval_fun> > \ +{ \ +private: \ + typedef mpz_class val1_type; \ + typedef __gmp_expr val2_type; \ + \ + __gmp_binary_expr expr; \ +public: \ + __gmp_expr(const val1_type &val1, const val2_type &val2) \ + : expr(val1, val2) { } \ + void eval(mpq_ptr q) const \ + { \ + mpq_class temp(expr.val2); \ + eval_fun::eval(q, expr.val1.get_mpz_t(), temp.get_mpq_t()); \ + } \ + const val1_type & get_val1() const { return expr.val1; } \ + const val2_type & get_val2() const { return expr.val2; } \ + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ +}; \ + \ +template \ +class __gmp_expr \ +, eval_fun> > \ +{ \ +private: \ + typedef mpq_class val1_type; \ + typedef __gmp_expr val2_type; \ + \ + __gmp_binary_expr expr; \ +public: \ + __gmp_expr(const val1_type &val1, const val2_type &val2) \ + : expr(val1, val2) { } \ + void eval(mpq_ptr q) const \ + { \ + mpz_class temp(expr.val2); \ + eval_fun::eval(q, expr.val1.get_mpq_t(), temp.get_mpz_t()); \ + } \ + const val1_type & get_val1() const { return expr.val1; } \ + const val2_type & get_val2() const { return expr.val2; } \ + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ +}; \ + \ +template \ +class __gmp_expr \ +, mpq_class, eval_fun> > \ +{ \ +private: \ + typedef __gmp_expr val1_type; \ + typedef mpq_class val2_type; \ + \ + __gmp_binary_expr expr; \ +public: \ + __gmp_expr(const val1_type &val1, const val2_type &val2) \ + : expr(val1, val2) { } \ + void eval(mpq_ptr q) const \ + { \ + mpz_class temp(expr.val1); \ + eval_fun::eval(q, temp.get_mpz_t(), expr.val2.get_mpq_t()); \ + } \ + const val1_type & get_val1() const { return expr.val1; } \ + const val2_type & get_val2() const { return expr.val2; } \ + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ +}; \ + \ +template \ +class __gmp_expr \ +, mpz_class, eval_fun> > \ +{ \ +private: \ + typedef __gmp_expr val1_type; \ + typedef mpz_class val2_type; \ + \ + __gmp_binary_expr expr; \ +public: \ + __gmp_expr(const val1_type &val1, const val2_type &val2) \ + : expr(val1, val2) { } \ + void eval(mpq_ptr q) const \ + { \ + mpq_class temp(expr.val1); \ + eval_fun::eval(q, temp.get_mpq_t(), expr.val2.get_mpz_t()); \ + } \ + const val1_type & get_val1() const { return expr.val1; } \ + const val2_type & get_val2() const { return expr.val2; } \ + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ +}; \ + \ +template \ +class __gmp_expr, __gmp_expr, eval_fun> > \ +{ \ +private: \ + typedef __gmp_expr val1_type; \ + typedef __gmp_expr val2_type; \ + \ + __gmp_binary_expr expr; \ +public: \ + __gmp_expr(const val1_type &val1, const val2_type &val2) \ + : expr(val1, val2) { } \ + void eval(mpq_ptr q) const \ + { \ + mpz_class temp1(expr.val1); \ + expr.val2.eval(q); \ + eval_fun::eval(q, temp1.get_mpz_t(), q); \ + } \ + const val1_type & get_val1() const { return expr.val1; } \ + const val2_type & get_val2() const { return expr.val2; } \ + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ +}; \ + \ +template \ +class __gmp_expr, __gmp_expr, eval_fun> > \ +{ \ +private: \ + typedef __gmp_expr val1_type; \ + typedef __gmp_expr val2_type; \ + \ + __gmp_binary_expr expr; \ +public: \ + __gmp_expr(const val1_type &val1, const val2_type &val2) \ + : expr(val1, val2) { } \ + void eval(mpq_ptr q) const \ + { \ + mpz_class temp2(expr.val2); \ + expr.val1.eval(q); \ + eval_fun::eval(q, q, temp2.get_mpz_t()); \ + } \ + const val1_type & get_val1() const { return expr.val1; } \ + const val2_type & get_val2() const { return expr.val2; } \ + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ +}; + + +__GMPZQ_DEFINE_EXPR(__gmp_binary_plus) +__GMPZQ_DEFINE_EXPR(__gmp_binary_minus) + + + +/**************** Macros for defining functions ****************/ +/* Results of operators and functions are instances of __gmp_expr. + T determines the numerical type of the expression: it can be either + mpz_t, mpq_t, or mpf_t. When the arguments of a binary + expression have different numerical types, __gmp_resolve_expr is used + to determine the "larger" type. + U is either __gmp_unary_expr or __gmp_binary_expr, + where V and W are the arguments' types -- they can in turn be + expressions, thus allowing to build compound expressions to any + degree of complexity. + Op is a function object that must have an eval() method accepting + appropriate arguments. + Actual evaluation of a __gmp_expr object is done when it gets + assigned to an mp*_class ("lazy" evaluation): this is done by calling + its eval() method. */ + + +// non-member unary operators and functions + +#define __GMP_DEFINE_UNARY_FUNCTION(fun, eval_fun) \ + \ +template \ +inline __gmp_expr, eval_fun> > \ +fun(const __gmp_expr &expr) \ +{ \ + return __gmp_expr, eval_fun> >(expr); \ +} + +// variant that only works for one of { mpz, mpq, mpf } + +#define __GMP_DEFINE_UNARY_FUNCTION_1(T, fun, eval_fun) \ + \ +template \ +inline __gmp_expr, eval_fun> > \ +fun(const __gmp_expr &expr) \ +{ \ + return __gmp_expr, eval_fun> >(expr); \ +} + +#define __GMP_DEFINE_UNARY_TYPE_FUNCTION(type, fun, eval_fun) \ + \ +template \ +inline type fun(const __gmp_expr &expr) \ +{ \ + __gmp_expr const& temp(expr); \ + return eval_fun::eval(temp.__get_mp()); \ +} + + +// non-member binary operators and functions + +#define __GMPP_DEFINE_BINARY_FUNCTION(fun, eval_fun) \ + \ +template \ +inline __gmp_expr::value_type, \ +__gmp_binary_expr<__gmp_expr, __gmp_expr, eval_fun> > \ +fun(const __gmp_expr &expr1, const __gmp_expr &expr2) \ +{ \ + return __gmp_expr::value_type, \ + __gmp_binary_expr<__gmp_expr, __gmp_expr, eval_fun> > \ + (expr1, expr2); \ +} + +#define __GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, bigtype) \ + \ +template \ +inline __gmp_expr \ +, bigtype, eval_fun> > \ +fun(const __gmp_expr &expr, type t) \ +{ \ + return __gmp_expr \ + , bigtype, eval_fun> >(expr, t); \ +} \ + \ +template \ +inline __gmp_expr \ +, eval_fun> > \ +fun(type t, const __gmp_expr &expr) \ +{ \ + return __gmp_expr \ + , eval_fun> >(t, expr); \ +} + +#define __GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \ +__GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, signed long int) + +#define __GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \ +__GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, unsigned long int) + +#define __GMPND_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \ +__GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, double) + +#define __GMPNLD_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \ +__GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, long double) + +#define __GMPN_DEFINE_BINARY_FUNCTION(fun, eval_fun) \ +__GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed char) \ +__GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned char) \ +__GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed int) \ +__GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned int) \ +__GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed short int) \ +__GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned short int) \ +__GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed long int) \ +__GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned long int) \ +__GMPND_DEFINE_BINARY_FUNCTION(fun, eval_fun, float) \ +__GMPND_DEFINE_BINARY_FUNCTION(fun, eval_fun, double) \ +/* __GMPNLD_DEFINE_BINARY_FUNCTION(fun, eval_fun, long double) */ + +#define __GMP_DEFINE_BINARY_FUNCTION(fun, eval_fun) \ +__GMPP_DEFINE_BINARY_FUNCTION(fun, eval_fun) \ +__GMPN_DEFINE_BINARY_FUNCTION(fun, eval_fun) + +// variant that only works for one of { mpz, mpq, mpf } + +#define __GMPP_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun) \ + \ +template \ +inline __gmp_expr, __gmp_expr, eval_fun> > \ +fun(const __gmp_expr &expr1, const __gmp_expr &expr2) \ +{ \ + return __gmp_expr, __gmp_expr, eval_fun> > \ + (expr1, expr2); \ +} + +#define __GMPNN_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type, bigtype) \ + \ +template \ +inline __gmp_expr \ +, bigtype, eval_fun> > \ +fun(const __gmp_expr &expr, type t) \ +{ \ + return __gmp_expr \ + , bigtype, eval_fun> >(expr, t); \ +} \ + \ +template \ +inline __gmp_expr \ +, eval_fun> > \ +fun(type t, const __gmp_expr &expr) \ +{ \ + return __gmp_expr \ + , eval_fun> >(t, expr); \ +} + +#define __GMPNS_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type) \ +__GMPNN_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type, signed long int) + +#define __GMPNU_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type) \ +__GMPNN_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type, unsigned long int) + +#define __GMPND_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type) \ +__GMPNN_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type, double) + +#define __GMPNLD_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type) \ +__GMPNN_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, type, long double) + +#define __GMPN_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun) \ +__GMPNS_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, signed char) \ +__GMPNU_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, unsigned char) \ +__GMPNS_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, signed int) \ +__GMPNU_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, unsigned int) \ +__GMPNS_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, signed short int) \ +__GMPNU_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, unsigned short int) \ +__GMPNS_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, signed long int) \ +__GMPNU_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, unsigned long int) \ +__GMPND_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, float) \ +__GMPND_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, double) \ +/* __GMPNLD_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun, long double) */ + +#define __GMP_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun) \ +__GMPP_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun) \ +__GMPN_DEFINE_BINARY_FUNCTION_1(T, fun, eval_fun) + + +#define __GMP_DEFINE_BINARY_FUNCTION_UI(fun, eval_fun) \ + \ +template \ +inline __gmp_expr \ +, mp_bitcnt_t, eval_fun> > \ +fun(const __gmp_expr &expr, mp_bitcnt_t l) \ +{ \ + return __gmp_expr, mp_bitcnt_t, eval_fun> >(expr, l); \ +} + + +#define __GMPP_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \ + \ +template \ +inline type fun(const __gmp_expr &expr1, \ + const __gmp_expr &expr2) \ +{ \ + __gmp_expr const& temp1(expr1); \ + __gmp_expr const& temp2(expr2); \ + return eval_fun::eval(temp1.__get_mp(), temp2.__get_mp()); \ +} + +#define __GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, \ + type2, bigtype) \ + \ +template \ +inline type fun(const __gmp_expr &expr, type2 t) \ +{ \ + __gmp_expr const& temp(expr); \ + return eval_fun::eval(temp.__get_mp(), static_cast(t)); \ +} \ + \ +template \ +inline type fun(type2 t, const __gmp_expr &expr) \ +{ \ + __gmp_expr const& temp(expr); \ + return eval_fun::eval(static_cast(t), temp.__get_mp()); \ +} + +#define __GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \ +__GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, \ + type2, signed long int) + +#define __GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \ +__GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, \ + type2, unsigned long int) + +#define __GMPND_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \ +__GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2, double) + +#define __GMPNLD_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \ +__GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2, long double) + +#define __GMPN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \ +__GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed char) \ +__GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned char) \ +__GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed int) \ +__GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned int) \ +__GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed short int) \ +__GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned short int) \ +__GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed long int) \ +__GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned long int) \ +__GMPND_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, float) \ +__GMPND_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, double) \ +/* __GMPNLD_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, long double) */ + +#define __GMP_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \ +__GMPP_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \ +__GMPN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) + + +// member operators + +#define __GMPP_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \ + \ +template \ +inline type##_class & type##_class::fun(const __gmp_expr &expr) \ +{ \ + __gmp_set_expr(mp, __gmp_expr, eval_fun> >(*this, expr)); \ + return *this; \ +} + +#define __GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, \ + type2, bigtype) \ + \ +inline type##_class & type##_class::fun(type2 t) \ +{ \ + __gmp_set_expr(mp, __gmp_expr >(*this, t)); \ + return *this; \ +} + +#define __GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \ +__GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, \ + type2, signed long int) + +#define __GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \ +__GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, \ + type2, unsigned long int) + +#define __GMPND_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \ +__GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2, double) + +#define __GMPNLD_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \ +__GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2, long double) + +#define __GMPN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \ +__GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed char) \ +__GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned char) \ +__GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed int) \ +__GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned int) \ +__GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed short int) \ +__GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned short int) \ +__GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed long int) \ +__GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned long int) \ +__GMPND_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, float) \ +__GMPND_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, double) \ +/* __GMPNLD_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, long double) */ + +#define __GMP_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \ +__GMPP_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \ +__GMPN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) + +#define __GMPZ_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ +__GMP_DEFINE_COMPOUND_OPERATOR(mpz, fun, eval_fun) + +#define __GMPQ_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ +__GMP_DEFINE_COMPOUND_OPERATOR(mpq, fun, eval_fun) + +#define __GMPF_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ +__GMP_DEFINE_COMPOUND_OPERATOR(mpf, fun, eval_fun) + + + +#define __GMP_DEFINE_COMPOUND_OPERATOR_UI(type, fun, eval_fun) \ + \ +inline type##_class & type##_class::fun(mp_bitcnt_t l) \ +{ \ + __gmp_set_expr(mp, __gmp_expr >(*this, l)); \ + return *this; \ +} + +#define __GMPZ_DEFINE_COMPOUND_OPERATOR_UI(fun, eval_fun) \ +__GMP_DEFINE_COMPOUND_OPERATOR_UI(mpz, fun, eval_fun) + +#define __GMPQ_DEFINE_COMPOUND_OPERATOR_UI(fun, eval_fun) \ +__GMP_DEFINE_COMPOUND_OPERATOR_UI(mpq, fun, eval_fun) + +#define __GMPF_DEFINE_COMPOUND_OPERATOR_UI(fun, eval_fun) \ +__GMP_DEFINE_COMPOUND_OPERATOR_UI(mpf, fun, eval_fun) + + + +#define __GMP_DEFINE_INCREMENT_OPERATOR(type, fun, eval_fun) \ + \ +inline type##_class & type##_class::fun() \ +{ \ + eval_fun::eval(mp); \ + return *this; \ +} \ + \ +inline type##_class type##_class::fun(int) \ +{ \ + type##_class temp(*this); \ + eval_fun::eval(mp); \ + return temp; \ +} + +#define __GMPZ_DEFINE_INCREMENT_OPERATOR(fun, eval_fun) \ +__GMP_DEFINE_INCREMENT_OPERATOR(mpz, fun, eval_fun) + +#define __GMPQ_DEFINE_INCREMENT_OPERATOR(fun, eval_fun) \ +__GMP_DEFINE_INCREMENT_OPERATOR(mpq, fun, eval_fun) + +#define __GMPF_DEFINE_INCREMENT_OPERATOR(fun, eval_fun) \ +__GMP_DEFINE_INCREMENT_OPERATOR(mpf, fun, eval_fun) + + +#define __GMPP_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ +template \ +__gmp_expr, eval_fun> > \ +fun(const __gmp_expr &expr) \ +{ \ + return __gmp_expr, eval_fun> >(expr); \ +} + +#define __GMPNN_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type, bigtype) \ +inline __gmp_expr > \ +fun(type expr) \ +{ \ + return __gmp_expr >(expr); \ +} + +#define __GMPNS_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type) \ +__GMPNN_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type, signed long) +#define __GMPNU_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type) \ +__GMPNN_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type, unsigned long) +#define __GMPND_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type) \ +__GMPNN_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, type, double) + +#define __GMPN_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ +__GMPNS_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, signed char) \ +__GMPNU_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, unsigned char) \ +__GMPNS_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, signed int) \ +__GMPNU_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, unsigned int) \ +__GMPNS_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, signed short int) \ +__GMPNU_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, unsigned short int) \ +__GMPNS_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, signed long int) \ +__GMPNU_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, unsigned long int) \ +__GMPND_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, float) \ +__GMPND_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun, double) \ + +#define __GMP_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ +__GMPP_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ +__GMPN_DEFINE_UNARY_STATIC_MEMFUN(T, fun, eval_fun) \ + + +/**************** Arithmetic operators and functions ****************/ + +// non-member operators and functions + +__GMP_DEFINE_UNARY_FUNCTION(operator+, __gmp_unary_plus) +__GMP_DEFINE_UNARY_FUNCTION(operator-, __gmp_unary_minus) +__GMP_DEFINE_UNARY_FUNCTION_1(mpz_t, operator~, __gmp_unary_com) + +__GMP_DEFINE_BINARY_FUNCTION(operator+, __gmp_binary_plus) +__GMP_DEFINE_BINARY_FUNCTION(operator-, __gmp_binary_minus) +__GMP_DEFINE_BINARY_FUNCTION(operator*, __gmp_binary_multiplies) +__GMP_DEFINE_BINARY_FUNCTION(operator/, __gmp_binary_divides) +__GMP_DEFINE_BINARY_FUNCTION_1(mpz_t, operator%, __gmp_binary_modulus) +__GMP_DEFINE_BINARY_FUNCTION_1(mpz_t, operator&, __gmp_binary_and) +__GMP_DEFINE_BINARY_FUNCTION_1(mpz_t, operator|, __gmp_binary_ior) +__GMP_DEFINE_BINARY_FUNCTION_1(mpz_t, operator^, __gmp_binary_xor) + +__GMP_DEFINE_BINARY_FUNCTION_UI(operator<<, __gmp_binary_lshift) +__GMP_DEFINE_BINARY_FUNCTION_UI(operator>>, __gmp_binary_rshift) + +__GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator==, __gmp_binary_equal) +__GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator!=, ! __gmp_binary_equal) +__GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator<, __gmp_binary_less) +__GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator<=, ! __gmp_binary_greater) +__GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator>, __gmp_binary_greater) +__GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator>=, ! __gmp_binary_less) + +__GMP_DEFINE_UNARY_FUNCTION(abs, __gmp_abs_function) +__GMP_DEFINE_UNARY_FUNCTION_1(mpf_t, trunc, __gmp_trunc_function) +__GMP_DEFINE_UNARY_FUNCTION_1(mpf_t, floor, __gmp_floor_function) +__GMP_DEFINE_UNARY_FUNCTION_1(mpf_t, ceil, __gmp_ceil_function) +__GMP_DEFINE_UNARY_FUNCTION_1(mpf_t, sqrt, __gmp_sqrt_function) +__GMP_DEFINE_UNARY_FUNCTION_1(mpz_t, sqrt, __gmp_sqrt_function) +__GMP_DEFINE_UNARY_FUNCTION_1(mpz_t, factorial, __gmp_fac_function) +__GMP_DEFINE_UNARY_FUNCTION_1(mpz_t, primorial, __gmp_primorial_function) +__GMP_DEFINE_UNARY_FUNCTION_1(mpz_t, fibonacci, __gmp_fib_function) +__GMP_DEFINE_BINARY_FUNCTION_1(mpf_t, hypot, __gmp_hypot_function) +__GMP_DEFINE_BINARY_FUNCTION_1(mpz_t, gcd, __gmp_gcd_function) +__GMP_DEFINE_BINARY_FUNCTION_1(mpz_t, lcm, __gmp_lcm_function) + +__GMP_DEFINE_UNARY_TYPE_FUNCTION(int, sgn, __gmp_sgn_function) +__GMP_DEFINE_BINARY_TYPE_FUNCTION(int, cmp, __gmp_cmp_function) + +template +void swap(__gmp_expr& x, __gmp_expr& y) __GMPXX_NOEXCEPT +{ x.swap(y); } + +// member operators for mpz_class + +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator+=, __gmp_binary_plus) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator-=, __gmp_binary_minus) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator*=, __gmp_binary_multiplies) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator/=, __gmp_binary_divides) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator%=, __gmp_binary_modulus) + +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator&=, __gmp_binary_and) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator|=, __gmp_binary_ior) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator^=, __gmp_binary_xor) + +__GMPZ_DEFINE_COMPOUND_OPERATOR_UI(operator<<=, __gmp_binary_lshift) +__GMPZ_DEFINE_COMPOUND_OPERATOR_UI(operator>>=, __gmp_binary_rshift) + +__GMPZ_DEFINE_INCREMENT_OPERATOR(operator++, __gmp_unary_increment) +__GMPZ_DEFINE_INCREMENT_OPERATOR(operator--, __gmp_unary_decrement) + +__GMP_DEFINE_UNARY_STATIC_MEMFUN(mpz_t, mpz_class::factorial, __gmp_fac_function) +__GMP_DEFINE_UNARY_STATIC_MEMFUN(mpz_t, mpz_class::primorial, __gmp_primorial_function) +__GMP_DEFINE_UNARY_STATIC_MEMFUN(mpz_t, mpz_class::fibonacci, __gmp_fib_function) + +// member operators for mpq_class + +__GMPQ_DEFINE_COMPOUND_OPERATOR(operator+=, __gmp_binary_plus) +__GMPQ_DEFINE_COMPOUND_OPERATOR(operator-=, __gmp_binary_minus) +__GMPQ_DEFINE_COMPOUND_OPERATOR(operator*=, __gmp_binary_multiplies) +__GMPQ_DEFINE_COMPOUND_OPERATOR(operator/=, __gmp_binary_divides) + +__GMPQ_DEFINE_COMPOUND_OPERATOR_UI(operator<<=, __gmp_binary_lshift) +__GMPQ_DEFINE_COMPOUND_OPERATOR_UI(operator>>=, __gmp_binary_rshift) + +__GMPQ_DEFINE_INCREMENT_OPERATOR(operator++, __gmp_unary_increment) +__GMPQ_DEFINE_INCREMENT_OPERATOR(operator--, __gmp_unary_decrement) + +// member operators for mpf_class + +__GMPF_DEFINE_COMPOUND_OPERATOR(operator+=, __gmp_binary_plus) +__GMPF_DEFINE_COMPOUND_OPERATOR(operator-=, __gmp_binary_minus) +__GMPF_DEFINE_COMPOUND_OPERATOR(operator*=, __gmp_binary_multiplies) +__GMPF_DEFINE_COMPOUND_OPERATOR(operator/=, __gmp_binary_divides) + +__GMPF_DEFINE_COMPOUND_OPERATOR_UI(operator<<=, __gmp_binary_lshift) +__GMPF_DEFINE_COMPOUND_OPERATOR_UI(operator>>=, __gmp_binary_rshift) + +__GMPF_DEFINE_INCREMENT_OPERATOR(operator++, __gmp_unary_increment) +__GMPF_DEFINE_INCREMENT_OPERATOR(operator--, __gmp_unary_decrement) + + + +/**************** Class wrapper for gmp_randstate_t ****************/ + +class __gmp_urandomb_value { }; +class __gmp_urandomm_value { }; + +template <> +class __gmp_expr +{ +private: + __gmp_randstate_struct *state; + mp_bitcnt_t bits; +public: + __gmp_expr(gmp_randstate_t s, mp_bitcnt_t l) : state(s), bits(l) { } + void eval(mpz_ptr z) const { __gmp_rand_function::eval(z, state, bits); } + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } +}; + +template <> +class __gmp_expr +{ +private: + __gmp_randstate_struct *state; + mpz_class range; +public: + __gmp_expr(gmp_randstate_t s, const mpz_class &z) : state(s), range(z) { } + void eval(mpz_ptr z) const + { __gmp_rand_function::eval(z, state, range.get_mpz_t()); } + mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } +}; + +template <> +class __gmp_expr +{ +private: + __gmp_randstate_struct *state; + mp_bitcnt_t bits; +public: + __gmp_expr(gmp_randstate_t s, mp_bitcnt_t l) : state(s), bits(l) { } + void eval(mpf_ptr f) const + { + __gmp_rand_function::eval(f, state, + (bits>0) ? bits : mpf_get_prec(f)); + } + mp_bitcnt_t get_prec() const + { + if (bits == 0) + return mpf_get_default_prec(); + else + return bits; + } +}; + +extern "C" { + typedef void __gmp_randinit_default_t (gmp_randstate_t); + typedef void __gmp_randinit_lc_2exp_t (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t); + typedef int __gmp_randinit_lc_2exp_size_t (gmp_randstate_t, mp_bitcnt_t); +} + +class gmp_randclass +{ +private: + gmp_randstate_t state; + + // copy construction and assignment not allowed + gmp_randclass(const gmp_randclass &); + void operator=(const gmp_randclass &); +public: + // constructors and destructor + gmp_randclass(gmp_randalg_t alg, unsigned long int size) + { + switch (alg) + { + case GMP_RAND_ALG_LC: // no other cases for now + default: + gmp_randinit(state, alg, size); + break; + } + } + + // gmp_randinit_default + gmp_randclass(__gmp_randinit_default_t* f) { f(state); } + + // gmp_randinit_lc_2exp + gmp_randclass(__gmp_randinit_lc_2exp_t* f, + mpz_class z, unsigned long int l1, mp_bitcnt_t l2) + { f(state, z.get_mpz_t(), l1, l2); } + + // gmp_randinit_lc_2exp_size + gmp_randclass(__gmp_randinit_lc_2exp_size_t* f, + mp_bitcnt_t size) + { + if (f (state, size) == 0) + throw std::length_error ("gmp_randinit_lc_2exp_size"); + } + + ~gmp_randclass() { gmp_randclear(state); } + + // initialize + void seed(); // choose a random seed some way (?) + void seed(unsigned long int s) { gmp_randseed_ui(state, s); } + void seed(const mpz_class &z) { gmp_randseed(state, z.get_mpz_t()); } + + // get random number + __gmp_expr get_z_bits(mp_bitcnt_t l) + { return __gmp_expr(state, l); } + __gmp_expr get_z_bits(const mpz_class &z) + { return get_z_bits(z.get_ui()); } + // FIXME: z.get_bitcnt_t() ? + + __gmp_expr get_z_range(const mpz_class &z) + { return __gmp_expr(state, z); } + + __gmp_expr get_f(mp_bitcnt_t prec = 0) + { return __gmp_expr(state, prec); } +}; + + +/**************** Specialize std::numeric_limits ****************/ + +namespace std { + template <> class numeric_limits + { + public: + static const bool is_specialized = true; + static mpz_class min() { return mpz_class(); } + static mpz_class max() { return mpz_class(); } + static mpz_class lowest() { return mpz_class(); } + static const int digits = 0; + static const int digits10 = 0; + static const int max_digits10 = 0; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static mpz_class epsilon() { return mpz_class(); } + static mpz_class round_error() { return mpz_class(); } + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + static mpz_class infinity() { return mpz_class(); } + static mpz_class quiet_NaN() { return mpz_class(); } + static mpz_class signaling_NaN() { return mpz_class(); } + static mpz_class denorm_min() { return mpz_class(); } + static const bool is_iec559 = false; + static const bool is_bounded = false; + static const bool is_modulo = false; + static const bool traps = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + template <> class numeric_limits + { + public: + static const bool is_specialized = true; + static mpq_class min() { return mpq_class(); } + static mpq_class max() { return mpq_class(); } + static mpq_class lowest() { return mpq_class(); } + static const int digits = 0; + static const int digits10 = 0; + static const int max_digits10 = 0; + static const bool is_signed = true; + static const bool is_integer = false; + static const bool is_exact = true; + static const int radix = 2; + static mpq_class epsilon() { return mpq_class(); } + static mpq_class round_error() { return mpq_class(); } + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + static mpq_class infinity() { return mpq_class(); } + static mpq_class quiet_NaN() { return mpq_class(); } + static mpq_class signaling_NaN() { return mpq_class(); } + static mpq_class denorm_min() { return mpq_class(); } + static const bool is_iec559 = false; + static const bool is_bounded = false; + static const bool is_modulo = false; + static const bool traps = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + template <> class numeric_limits + { + public: + static const bool is_specialized = true; + static mpf_class min() { return mpf_class(); } + static mpf_class max() { return mpf_class(); } + static mpf_class lowest() { return mpf_class(); } + static const int digits = 0; + static const int digits10 = 0; + static const int max_digits10 = 0; + static const bool is_signed = true; + static const bool is_integer = false; + static const bool is_exact = false; + static const int radix = 2; + static mpf_class epsilon() { return mpf_class(); } + static mpf_class round_error() { return mpf_class(); } + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + static mpf_class infinity() { return mpf_class(); } + static mpf_class quiet_NaN() { return mpf_class(); } + static mpf_class signaling_NaN() { return mpf_class(); } + static mpf_class denorm_min() { return mpf_class(); } + static const bool is_iec559 = false; + static const bool is_bounded = false; + static const bool is_modulo = false; + static const bool traps = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + }; +} + + +/**************** #undef all private macros ****************/ + +#undef __GMPP_DECLARE_COMPOUND_OPERATOR +#undef __GMPN_DECLARE_COMPOUND_OPERATOR +#undef __GMP_DECLARE_COMPOUND_OPERATOR +#undef __GMP_DECLARE_COMPOUND_OPERATOR_UI +#undef __GMP_DECLARE_INCREMENT_OPERATOR +#undef __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS +#undef __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS + +#undef __GMPZQ_DEFINE_EXPR + +#undef __GMP_DEFINE_UNARY_FUNCTION_1 +#undef __GMP_DEFINE_UNARY_FUNCTION +#undef __GMP_DEFINE_UNARY_TYPE_FUNCTION + +#undef __GMPP_DEFINE_BINARY_FUNCTION +#undef __GMPNN_DEFINE_BINARY_FUNCTION +#undef __GMPNS_DEFINE_BINARY_FUNCTION +#undef __GMPNU_DEFINE_BINARY_FUNCTION +#undef __GMPND_DEFINE_BINARY_FUNCTION +#undef __GMPNLD_DEFINE_BINARY_FUNCTION +#undef __GMPN_DEFINE_BINARY_FUNCTION +#undef __GMP_DEFINE_BINARY_FUNCTION + +#undef __GMP_DEFINE_BINARY_FUNCTION_UI + +#undef __GMPP_DEFINE_BINARY_TYPE_FUNCTION +#undef __GMPNN_DEFINE_BINARY_TYPE_FUNCTION +#undef __GMPNS_DEFINE_BINARY_TYPE_FUNCTION +#undef __GMPNU_DEFINE_BINARY_TYPE_FUNCTION +#undef __GMPND_DEFINE_BINARY_TYPE_FUNCTION +#undef __GMPNLD_DEFINE_BINARY_TYPE_FUNCTION +#undef __GMPN_DEFINE_BINARY_TYPE_FUNCTION +#undef __GMP_DEFINE_BINARY_TYPE_FUNCTION + +#undef __GMPZ_DEFINE_COMPOUND_OPERATOR + +#undef __GMPP_DEFINE_COMPOUND_OPERATOR +#undef __GMPNN_DEFINE_COMPOUND_OPERATOR +#undef __GMPNS_DEFINE_COMPOUND_OPERATOR +#undef __GMPNU_DEFINE_COMPOUND_OPERATOR +#undef __GMPND_DEFINE_COMPOUND_OPERATOR +#undef __GMPNLD_DEFINE_COMPOUND_OPERATOR +#undef __GMPN_DEFINE_COMPOUND_OPERATOR +#undef __GMP_DEFINE_COMPOUND_OPERATOR + +#undef __GMPQ_DEFINE_COMPOUND_OPERATOR +#undef __GMPF_DEFINE_COMPOUND_OPERATOR + +#undef __GMP_DEFINE_COMPOUND_OPERATOR_UI +#undef __GMPZ_DEFINE_COMPOUND_OPERATOR_UI +#undef __GMPQ_DEFINE_COMPOUND_OPERATOR_UI +#undef __GMPF_DEFINE_COMPOUND_OPERATOR_UI + +#undef __GMP_DEFINE_INCREMENT_OPERATOR +#undef __GMPZ_DEFINE_INCREMENT_OPERATOR +#undef __GMPQ_DEFINE_INCREMENT_OPERATOR +#undef __GMPF_DEFINE_INCREMENT_OPERATOR + +#undef __GMPXX_CONSTANT_TRUE +#undef __GMPXX_CONSTANT + +#endif /* __GMP_PLUSPLUS__ */ diff --git a/illumos-x86_64/usr/include/grp.h b/illumos-x86_64/usr/include/grp.h new file mode 100644 index 00000000..1a7e8ffb --- /dev/null +++ b/illumos-x86_64/usr/include/grp.h @@ -0,0 +1,159 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _GRP_H +#define _GRP_H + +#include + +#include + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct group { /* see getgrent(3C) */ + char *gr_name; + char *gr_passwd; + gid_t gr_gid; + char **gr_mem; +}; + +extern struct group *getgrgid(gid_t); /* MT-unsafe */ +extern struct group *getgrnam(const char *); /* MT-unsafe */ + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +extern struct group *getgrent_r(struct group *, char *, int); +extern struct group *fgetgrent_r(FILE *, struct group *, char *, int); + + +extern struct group *fgetgrent(FILE *); /* MT-unsafe */ +extern int initgroups(const char *, gid_t); +extern int getgrouplist(const char *, gid_t, gid_t *, int *); +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */ + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) +extern void endgrent(void); +extern void setgrent(void); +extern struct group *getgrent(void); /* MT-unsafe */ +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */ + +/* + * getgrgid_r() & getgrnam_r() prototypes are defined here. + */ + +/* + * Previous releases of Solaris, starting at 2.3, provided definitions of + * various functions as specified in POSIX.1c, Draft 6. For some of these + * functions, the final POSIX 1003.1c standard had a different number of + * arguments and return values. + * + * The following segment of this header provides support for the standard + * interfaces while supporting applications written under earlier + * releases. The application defines appropriate values of the feature + * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate + * whether it was written to expect the Draft 6 or standard versions of + * these interfaces, before including this header. This header then + * provides a mapping from the source version of the interface to an + * appropriate binary interface. Such mappings permit an application + * to be built from libraries and objects which have mixed expectations + * of the definitions of these functions. + * + * For applications using the Draft 6 definitions, the binary symbol is the + * same as the source symbol, and no explicit mapping is needed. For the + * standard interface, the function func() is mapped to the binary symbol + * _posix_func(). The preferred mechanism for the remapping is a compiler + * #pragma. If the compiler does not provide such a #pragma, the header file + * defines a static function func() which calls the _posix_func() version; + * this has to be done instead of #define since POSIX specifies that an + * application can #undef the symbol and still be bound to the correct + * implementation. Unfortunately, the statics confuse lint so we fallback to + * #define in that case. + * + * NOTE: Support for the Draft 6 definitions is provided for compatibility + * only. New applications/libraries should use the standard definitions. + */ + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ + (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) + +#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getgrgid_r __posix_getgrgid_r +#pragma redefine_extname getgrnam_r __posix_getgrnam_r +extern int getgrgid_r(gid_t, struct group *, char *, + size_t, struct group **); +extern int getgrnam_r(const char *, struct group *, char *, + size_t, struct group **); +#else /* __PRAGMA_REDEFINE_EXTNAME */ + +extern int __posix_getgrgid_r(gid_t, struct group *, char *, size_t, + struct group **); +extern int __posix_getgrnam_r(const char *, struct group *, char *, size_t, + struct group **); + +static int +getgrgid_r(gid_t __gid, struct group *__grp, char *__buf, size_t __len, + struct group **__res) +{ + return (__posix_getgrgid_r(__gid, __grp, __buf, __len, __res)); +} +static int +getgrnam_r(const char *__cb, struct group *__grp, char *__buf, size_t __len, + struct group **__res) +{ + return (__posix_getgrnam_r(__cb, __grp, __buf, __len, __res)); +} + +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +extern struct group *getgrgid_r(gid_t, struct group *, char *, int); +extern struct group *getgrnam_r(const char *, struct group *, char *, int); + +#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GRP_H */ diff --git a/illumos-x86_64/usr/include/gssapi/gssapi.h b/illumos-x86_64/usr/include/gssapi/gssapi.h new file mode 100644 index 00000000..4e07ec76 --- /dev/null +++ b/illumos-x86_64/usr/include/gssapi/gssapi.h @@ -0,0 +1,880 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 1993 by OpenVision Technologies, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appears in all copies and + * that both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of OpenVision not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. OpenVision makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _GSSAPI_H_ +#define _GSSAPI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * First, include sys/types.h to get size_t defined. + */ +#include + +/* + * If the platform supports the xom.h header file, it should be + * included here. + */ +#ifdef HAVE_XOM_H +#include +#endif + +/* + * Now define the three implementation-dependent types. + */ +struct gss_ctx_id; +struct gss_cred_id; +struct gss_name; + +typedef struct gss_ctx_id *gss_ctx_id_t; +typedef struct gss_cred_id *gss_cred_id_t; +typedef struct gss_name *gss_name_t; + +/* + * The following type must be defined as the smallest natural + * unsigned integer supported by the platform that has at least + * 32 bits of precision. + */ +typedef unsigned int gss_uint32; +typedef int gss_int32; + + +#ifdef OM_STRING +/* + * We have included the xom.h header file. Verify that OM_uint32 + * is defined correctly. + */ + +#if sizeof (gss_uint32) != sizeof (OM_uint32) +#error Incompatible definition of OM_uint32 from xom.h +#endif + +typedef OM_object_identifier gss_OID_desc, *gss_OID; + +#else + + + +/* + * We can't use X/Open definitions, so roll our own. + */ + +typedef gss_uint32 OM_uint32; + +typedef struct gss_OID_desc_struct { + OM_uint32 length; + void*elements; +} gss_OID_desc, *gss_OID; + +#endif + +typedef struct gss_OID_set_desc_struct { + size_t count; + gss_OID elements; +} gss_OID_set_desc, *gss_OID_set; + +#ifdef _SYSCALL32 +typedef struct gss_OID_desc_struct32 { + OM_uint32 length; + caddr32_t elements; +} gss_OID_desc32, *gss_OID32; +#endif /* _SYSCALL32 */ + +typedef struct gss_buffer_desc_struct { + size_t length; + void *value; +} gss_buffer_desc, *gss_buffer_t; + +typedef struct gss_channel_bindings_struct { + OM_uint32 initiator_addrtype; + gss_buffer_desc initiator_address; + OM_uint32 acceptor_addrtype; + gss_buffer_desc acceptor_address; + gss_buffer_desc application_data; +} *gss_channel_bindings_t; + +/* + * For now, define a QOP-type as an OM_uint32 + */ +typedef OM_uint32 gss_qop_t; +typedef int gss_cred_usage_t; + +/* + * Flag bits for context-level services. + */ +#define GSS_C_DELEG_FLAG 1 +#define GSS_C_MUTUAL_FLAG 2 +#define GSS_C_REPLAY_FLAG 4 +#define GSS_C_SEQUENCE_FLAG 8 +#define GSS_C_CONF_FLAG 16 +#define GSS_C_INTEG_FLAG 32 +#define GSS_C_ANON_FLAG 64 +#define GSS_C_PROT_READY_FLAG 128 +#define GSS_C_TRANS_FLAG 256 + +/* + * Credential usage options + */ +#define GSS_C_BOTH 0 +#define GSS_C_INITIATE 1 +#define GSS_C_ACCEPT 2 + +/* + * Status code types for gss_display_status + */ +#define GSS_C_GSS_CODE 1 +#define GSS_C_MECH_CODE 2 + +/* + * The constant definitions for channel-bindings address families + */ +#define GSS_C_AF_UNSPEC 0 +#define GSS_C_AF_LOCAL 1 +#define GSS_C_AF_INET 2 +#define GSS_C_AF_IMPLINK 3 +#define GSS_C_AF_PUP 4 +#define GSS_C_AF_CHAOS 5 +#define GSS_C_AF_NS 6 +#define GSS_C_AF_NBS 7 +#define GSS_C_AF_ECMA 8 +#define GSS_C_AF_DATAKIT 9 +#define GSS_C_AF_CCITT 10 +#define GSS_C_AF_SNA 11 +#define GSS_C_AF_DECnet 12 +#define GSS_C_AF_DLI 13 +#define GSS_C_AF_LAT 14 +#define GSS_C_AF_HYLINK 15 +#define GSS_C_AF_APPLETALK 16 +#define GSS_C_AF_BSC 17 +#define GSS_C_AF_DSS 18 +#define GSS_C_AF_OSI 19 +#define GSS_C_AF_X25 21 + +#define GSS_C_AF_NULLADDR 255 + +/* + * Various Null values + */ +#define GSS_C_NO_NAME ((gss_name_t) 0) +#define GSS_C_NO_BUFFER ((gss_buffer_t) 0) +#define GSS_C_NO_OID ((gss_OID) 0) +#define GSS_C_NO_OID_SET ((gss_OID_set) 0) +#define GSS_C_NO_CONTEXT ((gss_ctx_id_t) 0) +#define GSS_C_NO_CREDENTIAL ((gss_cred_id_t) 0) +#define GSS_C_NO_CHANNEL_BINDINGS ((gss_channel_bindings_t) 0) +#define GSS_C_EMPTY_BUFFER {0, NULL} + +/* + * Some alternate names for a couple of the above + * values. These are defined for V1 compatibility. + */ +#define GSS_C_NULL_OID GSS_C_NO_OID +#define GSS_C_NULL_OID_SET GSS_C_NO_OID_SET + +/* + * Define the default Quality of Protection for per-message + * services. Note that an implementation that offers multiple + * levels of QOP may define GSS_C_QOP_DEFAULT to be either zero + * (as done here) to mean "default protection", or to a specific + * explicit QOP value. However, a value of 0 should always be + * interpreted by a GSSAPI implementation as a request for the + * default protection level. + */ +#define GSS_C_QOP_DEFAULT 0 + +/* + * Expiration time of 2^32-1 seconds means infinite lifetime for a + * credential or security context + */ +#define GSS_C_INDEFINITE ((OM_uint32) 0xfffffffful) + +/* + * The implementation must reserve static storage for a + * gss_OID_desc object containing the value + * {10, (void *)"\x2a\x86\x48\x86\xf7\x12" + * "\x01\x02\x01\x01"}, + * corresponding to an object-identifier value of + * {iso(1) member-body(2) United States(840) mit(113554) + * infosys(1) gssapi(2) generic(1) user_name(1)}. The constant + * GSS_C_NT_USER_NAME should be initialized to point + * to that gss_OID_desc. + */ +extern const gss_OID GSS_C_NT_USER_NAME; + +/* + * The implementation must reserve static storage for a + * gss_OID_desc object containing the value + * {10, (void *)"\x2a\x86\x48\x86\xf7\x12" + * "\x01\x02\x01\x02"}, + * corresponding to an object-identifier value of + * {iso(1) member-body(2) United States(840) mit(113554) + * infosys(1) gssapi(2) generic(1) machine_uid_name(2)}. + * The constant GSS_C_NT_MACHINE_UID_NAME should be + * initialized to point to that gss_OID_desc. + */ +extern const gss_OID GSS_C_NT_MACHINE_UID_NAME; + +/* + * The implementation must reserve static storage for a + * gss_OID_desc object containing the value + * {10, (void *)"\x2a\x86\x48\x86\xf7\x12" + * "\x01\x02\x01\x03"}, + * corresponding to an object-identifier value of + * {iso(1) member-body(2) United States(840) mit(113554) + * infosys(1) gssapi(2) generic(1) string_uid_name(3)}. + * The constant GSS_C_NT_STRING_UID_NAME should be + * initialized to point to that gss_OID_desc. + */ +extern const gss_OID GSS_C_NT_STRING_UID_NAME; + +/* + * The implementation must reserve static storage for a + * gss_OID_desc object containing the value + * {6, (void *)"\x2b\x06\x01\x05\x06\x02"}, + * corresponding to an object-identifier value of + * {1(iso), 3(org), 6(dod), 1(internet), 5(security), + * 6(nametypes), 2(gss-host-based-services)}. The constant + * GSS_C_NT_HOSTBASED_SERVICE should be initialized to point + * to that gss_OID_desc. + */ +extern const gss_OID GSS_C_NT_HOSTBASED_SERVICE; + +/* + * The implementation must reserve static storage for a + * gss_OID_desc object containing the value + * {6, (void *)"\x2b\x06\01\x05\x06\x03"}, + * corresponding to an object identifier value of + * {1(iso), 3(org), 6(dod), 1(internet), 5(security), + * 6(nametypes), 3(gss-anonymous-name)}. The constant + * and GSS_C_NT_ANONYMOUS should be initialized to point + * to that gss_OID_desc. + */ +extern const gss_OID GSS_C_NT_ANONYMOUS; + +/* + * The implementation must reserve static storage for a + * gss_OID_desc object containing the value + * {6, (void *)"\x2b\x06\x01\x05\x06\x04"}, + * corresponding to an object-identifier value of + * {1(iso), 3(org), 6(dod), 1(internet), 5(security), + * 6(nametypes), 4(gss-api-exported-name)}. The constant + * GSS_C_NT_EXPORT_NAME should be initialized to point + * to that gss_OID_desc. + */ +extern const gss_OID GSS_C_NT_EXPORT_NAME; + + +/* Major status codes */ + +#define GSS_S_COMPLETE 0 + +/* + * Some "helper" definitions to make the status code macros obvious. + */ +#define GSS_C_CALLING_ERROR_OFFSET 24 +#define GSS_C_ROUTINE_ERROR_OFFSET 16 +#define GSS_C_SUPPLEMENTARY_OFFSET 0 +#define GSS_C_CALLING_ERROR_MASK ((OM_uint32) 0377ul) +#define GSS_C_ROUTINE_ERROR_MASK ((OM_uint32) 0377ul) +#define GSS_C_SUPPLEMENTARY_MASK ((OM_uint32) 0177777ul) + +/* + * The macros that test status codes for error conditions. + * Note that the GSS_ERROR() macro has changed slightly from + * the V1 GSSAPI so that it now evaluates its argument + * only once. + */ +#define GSS_CALLING_ERROR(x) \ + ((x) & (GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET)) +#define GSS_ROUTINE_ERROR(x) \ + ((x) & (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET)) +#define GSS_SUPPLEMENTARY_INFO(x) \ + ((x) & (GSS_C_SUPPLEMENTARY_MASK << GSS_C_SUPPLEMENTARY_OFFSET)) +#define GSS_ERROR(x) \ + ((x) & ((GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET) | \ + (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET))) + +/* + * Now the actual status code definitions + */ + +/* + * Calling errors: + */ +#define GSS_S_CALL_INACCESSIBLE_READ \ + (((OM_uint32) 1ul) << GSS_C_CALLING_ERROR_OFFSET) +#define GSS_S_CALL_INACCESSIBLE_WRITE \ + (((OM_uint32) 2ul) << GSS_C_CALLING_ERROR_OFFSET) +#define GSS_S_CALL_BAD_STRUCTURE \ + (((OM_uint32) 3ul) << GSS_C_CALLING_ERROR_OFFSET) + +/* + * Routine errors: + */ +#define GSS_S_BAD_MECH (((OM_uint32) 1ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_BAD_NAME (((OM_uint32) 2ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_BAD_NAMETYPE (((OM_uint32) 3ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_BAD_BINDINGS (((OM_uint32) 4ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_BAD_STATUS (((OM_uint32) 5ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_BAD_SIG (((OM_uint32) 6ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_BAD_MIC GSS_S_BAD_SIG +#define GSS_S_NO_CRED (((OM_uint32) 7ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_NO_CONTEXT (((OM_uint32) 8ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_DEFECTIVE_TOKEN (((OM_uint32) 9ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_DEFECTIVE_CREDENTIAL \ + (((OM_uint32) 10ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_CREDENTIALS_EXPIRED \ + (((OM_uint32) 11ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_CONTEXT_EXPIRED \ + (((OM_uint32) 12ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_FAILURE (((OM_uint32) 13ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_BAD_QOP (((OM_uint32) 14ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_UNAUTHORIZED (((OM_uint32) 15ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_UNAVAILABLE (((OM_uint32) 16ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_DUPLICATE_ELEMENT \ + (((OM_uint32) 17ul) << GSS_C_ROUTINE_ERROR_OFFSET) +#define GSS_S_NAME_NOT_MN (((OM_uint32) 18ul) << GSS_C_ROUTINE_ERROR_OFFSET) + +/* + * Supplementary info bits: + */ +#define GSS_S_CONTINUE_NEEDED (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 0)) +#define GSS_S_DUPLICATE_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 1)) +#define GSS_S_OLD_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 2)) +#define GSS_S_UNSEQ_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 3)) +#define GSS_S_GAP_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 4)) + + +/* + * Finally, function prototypes for the GSS-API routines. + */ + +OM_uint32 gss_acquire_cred( + OM_uint32 *, /* minor_status */ + const gss_name_t, /* desired_name */ + OM_uint32, /* time_req */ + const gss_OID_set, /* desired_mechs */ + gss_cred_usage_t, /* cred_usage */ + gss_cred_id_t *, /* output_cred_handle */ + gss_OID_set *, /* actual_mechs */ + OM_uint32 * /* time_rec */ +); + +OM_uint32 gss_release_cred( + OM_uint32 *, /* minor_status */ + gss_cred_id_t * /* cred_handle */ +); + +OM_uint32 gss_init_sec_context( + OM_uint32 *, /* minor_status */ + const gss_cred_id_t, /* initiator_cred_handle */ + gss_ctx_id_t *, /* context_handle */ + const gss_name_t, /* target_name */ + const gss_OID, /* mech_type */ + OM_uint32, /* req_flags */ + OM_uint32, /* time_req */ + gss_channel_bindings_t, /* input_chan_bindings */ + const gss_buffer_t, /* input_token */ + gss_OID *, /* actual_mech_type */ + gss_buffer_t, /* output_token */ + OM_uint32 *, /* ret_flags */ + OM_uint32 * /* time_rec */ +); + +OM_uint32 gss_accept_sec_context( + OM_uint32 *, /* minor_status */ + gss_ctx_id_t *, /* context_handle */ + const gss_cred_id_t, /* acceptor_cred_handle */ + const gss_buffer_t, /* input_token_buffer */ + const gss_channel_bindings_t, /* input_chan_bindings */ + gss_name_t *, /* src_name */ + gss_OID *, /* mech_type */ + gss_buffer_t, /* output_token */ + OM_uint32 *, /* ret_flags */ + OM_uint32 *, /* time_rec */ + gss_cred_id_t * /* delegated_cred_handle */ +); + +OM_uint32 gss_process_context_token( + OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + const gss_buffer_t /* token_buffer */ +); + +OM_uint32 gss_delete_sec_context( + OM_uint32 *, /* minor_status */ + gss_ctx_id_t *, /* context_handle */ + gss_buffer_t /* output_token */ +); + +OM_uint32 gss_context_time( + OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + OM_uint32 * /* time_rec */ +); + +OM_uint32 gss_get_mic( + OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + gss_qop_t, /* qop_req */ + const gss_buffer_t, /* message_buffer */ + gss_buffer_t /* message_token */ +); + +OM_uint32 gss_verify_mic( + OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + const gss_buffer_t, /* message_buffer */ + const gss_buffer_t, /* token_buffer */ + gss_qop_t * /* qop_state */ +); + +OM_uint32 gss_wrap( + OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + int, /* conf_req_flag */ + gss_qop_t, /* qop_req */ + const gss_buffer_t, /* input_message_buffer */ + int *, /* conf_state */ + gss_buffer_t /* output_message_buffer */ +); + +OM_uint32 gss_unwrap( + OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + const gss_buffer_t, /* input_message_buffer */ + gss_buffer_t, /* output_message_buffer */ + int *, /* conf_state */ + gss_qop_t * /* qop_state */ +); + +OM_uint32 gss_display_status( + OM_uint32 *, /* minor_status */ + OM_uint32, /* status_value */ + int, /* status_type */ + const gss_OID, /* mech_type */ + OM_uint32 *, /* message_context */ + gss_buffer_t /* status_string */ +); + +OM_uint32 gss_indicate_mechs( + OM_uint32 *, /* minor_status */ + gss_OID_set * /* mech_set */ +); + +OM_uint32 gss_compare_name( + OM_uint32 *, /* minor_status */ + const gss_name_t, /* name1 */ + const gss_name_t, /* name2 */ + int * /* name_equal */ +); + +OM_uint32 gss_display_name( + OM_uint32 *, /* minor_status */ + const gss_name_t, /* input_name */ + gss_buffer_t, /* output_name_buffer */ + gss_OID * /* output_name_type */ +); + +OM_uint32 gss_import_name( + OM_uint32 *, /* minor_status */ + const gss_buffer_t, /* input_name_buffer */ + const gss_OID, /* input_name_type */ + gss_name_t * /* output_name */ +); + +OM_uint32 gss_export_name( + OM_uint32 *, /* minor_status */ + const gss_name_t, /* input_name */ + gss_buffer_t /* exported_name */ +); + +OM_uint32 gss_release_name( + OM_uint32 *, /* minor_status */ + gss_name_t * /* input_name */ +); + +OM_uint32 gss_release_buffer( + OM_uint32 *, /* minor_status */ + gss_buffer_t /* buffer */ +); + +OM_uint32 gss_release_oid_set( + OM_uint32 *, /* minor_status */ + gss_OID_set * /* set */ +); + +OM_uint32 gss_inquire_cred( + OM_uint32 *, /* minor_status */ + const gss_cred_id_t, /* cred_handle */ + gss_name_t *, /* name */ + OM_uint32 *, /* lifetime */ + gss_cred_usage_t *, /* cred_usage */ + gss_OID_set * /* mechanisms */ +); + +OM_uint32 gss_inquire_context( + OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + gss_name_t *, /* src_name */ + gss_name_t *, /* targ_name */ + OM_uint32 *, /* lifetime_rec */ + gss_OID *, /* mech_type */ + OM_uint32 *, /* ctx_flags */ + int *, /* locally_initiated */ + int * /* open */ +); + +OM_uint32 gss_wrap_size_limit( + OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + int, /* conf_req_flag */ + gss_qop_t, /* qop_req */ + OM_uint32, /* req_output_size */ + OM_uint32 * /* max_input_size */ +); + +OM_uint32 gss_add_cred( + OM_uint32 *, /* minor_status */ + const gss_cred_id_t, /* input_cred_handle */ + const gss_name_t, /* desired_name */ + const gss_OID, /* desired_mech */ + gss_cred_usage_t, /* cred_usage */ + OM_uint32, /* initiator_time_req */ + OM_uint32, /* acceptor_time_req */ + gss_cred_id_t *, /* output_cred_handle */ + gss_OID_set *, /* actual_mechs */ + OM_uint32 *, /* initiator_time_rec */ + OM_uint32 * /* acceptor_time_rec */ +); + +OM_uint32 gss_store_cred( + OM_uint32 *, /* minor_status */ + const gss_cred_id_t, /* input_cred */ + gss_cred_usage_t, /* cred_usage */ + const gss_OID, /* desired_mech */ + OM_uint32, /* overwrite_cred */ + OM_uint32, /* default_cred */ + gss_OID_set *, /* elements_stored */ + gss_cred_usage_t * /* cred_usage_stored */ +); + +OM_uint32 gss_inquire_cred_by_mech( + OM_uint32 *, /* minor_status */ + const gss_cred_id_t, /* cred_handle */ + const gss_OID, /* mech_type */ + gss_name_t *, /* name */ + OM_uint32 *, /* initiator_lifetime */ + OM_uint32 *, /* acceptor_lifetime */ + gss_cred_usage_t * /* cred_usage */ +); + +OM_uint32 gss_export_sec_context( + OM_uint32 *, /* minor_status */ + gss_ctx_id_t *, /* context_handle */ + gss_buffer_t /* interprocess_token */ +); + +OM_uint32 gss_import_sec_context( + OM_uint32 *, /* minor_status */ + const gss_buffer_t, /* interprocess_token */ + gss_ctx_id_t * /* context_handle */ +); + +OM_uint32 gss_create_empty_oid_set( + OM_uint32 *, /* minor_status */ + gss_OID_set * /* oid_set */ +); + +OM_uint32 gss_add_oid_set_member( + OM_uint32 *, /* minor_status */ + const gss_OID, /* member_oid */ + gss_OID_set * /* oid_set */ +); + +OM_uint32 gss_test_oid_set_member( + OM_uint32 *, /* minor_status */ + const gss_OID, /* member */ + const gss_OID_set, /* set */ + int * /* present */ +); + +OM_uint32 gss_inquire_names_for_mech( + OM_uint32 *, /* minor_status */ + const gss_OID, /* mechanism */ + gss_OID_set * /* name_types */ +); + +OM_uint32 gss_inquire_mechs_for_name( + OM_uint32 *, /* minor_status */ + const gss_name_t, /* input_name */ + gss_OID_set * /* mech_types */ +); + +OM_uint32 gss_canonicalize_name( + OM_uint32 *, /* minor_status */ + const gss_name_t, /* input_name */ + const gss_OID, /* mech_type */ + gss_name_t * /* output_name */ +); + +OM_uint32 gss_duplicate_name( + OM_uint32 *, /* minor_status */ + const gss_name_t, /* src_name */ + gss_name_t * /* dest_name */ +); + + +OM_uint32 gss_release_oid( + OM_uint32 *, /* minor_status */ + gss_OID * /* oid */ +); + +OM_uint32 gss_str_to_oid( + OM_uint32 *, /* minor_status */ + const gss_buffer_t, /* oid_str */ + gss_OID * /* oid */ +); + +OM_uint32 gss_oid_to_str( + OM_uint32 *, /* minor_status */ + const gss_OID, /* oid */ + gss_buffer_t /* oid_str */ +); + + +/* + * The following routines are obsolete variants of gss_get_mic, + * gss_verify_mic, gss_wrap and gss_unwrap. They should be + * provided by GSSAPI V2 implementations for backwards + * compatibility with V1 applications. Distinct entrypoints + * (as opposed to #defines) should be provided, both to allow + * GSSAPI V1 applications to link against GSSAPI V2 implementations, + * and to retain the slight parameter type differences between the + * obsolete versions of these routines and their current forms. + */ + +OM_uint32 gss_sign( + OM_uint32 *, /* minor_status */ + gss_ctx_id_t, /* context_handle */ + int, /* qop_req */ + gss_buffer_t, /* message_buffer */ + gss_buffer_t /* message_token */ +); + +OM_uint32 gss_verify( + OM_uint32 *, /* minor_status */ + gss_ctx_id_t, /* context_handle */ + gss_buffer_t, /* message_buffer */ + gss_buffer_t, /* token_buffer */ + int * /* qop_state */ +); + +OM_uint32 gss_seal( + OM_uint32 *, /* minor_status */ + gss_ctx_id_t, /* context_handle */ + int, /* conf_req_flag */ + int, /* qop_req */ + gss_buffer_t, /* input_message_buffer */ + int *, /* conf_state */ + gss_buffer_t /* output_message_buffer */ +); + +OM_uint32 gss_unseal( + OM_uint32 *, /* minor_status */ + gss_ctx_id_t, /* context_handle */ + gss_buffer_t, /* input_message_buffer */ + gss_buffer_t, /* output_message_buffer */ + int *, /* conf_state */ + int * /* qop_state */ +); + + +#ifdef _KERNEL /* For kernel */ + +#include + +void kgss_free_oid(gss_OID oid); + +OM_uint32 kgss_acquire_cred( + OM_uint32 *, + const gss_name_t, + OM_uint32, + const gss_OID_set, + int, + gss_cred_id_t *, + gss_OID_set *, + OM_uint32 *, + uid_t); + +OM_uint32 kgss_add_cred( + OM_uint32 *, + gss_cred_id_t, + gss_name_t, + gss_OID, + int, + int, + int, + gss_OID_set *, + OM_uint32 *, + OM_uint32 *, + uid_t); + +OM_uint32 kgss_release_cred( + OM_uint32 *, + gss_cred_id_t *, + uid_t); + +OM_uint32 kgss_init_sec_context( + OM_uint32 *, + const gss_cred_id_t, + gss_ctx_id_t *, + const gss_name_t, + const gss_OID, + int, + OM_uint32, + const gss_channel_bindings_t, + const gss_buffer_t, + gss_OID *, + gss_buffer_t, + int *, + OM_uint32 *, + uid_t); + +OM_uint32 kgss_accept_sec_context( + OM_uint32 *, + gss_ctx_id_t *, + const gss_cred_id_t, + const gss_buffer_t, + const gss_channel_bindings_t, + const gss_buffer_t, + gss_OID *, + gss_buffer_t, + int *, + OM_uint32 *, + gss_cred_id_t *, + uid_t); + +OM_uint32 kgss_process_context_token( + OM_uint32 *, + const gss_ctx_id_t, + const gss_buffer_t, + uid_t); + +OM_uint32 kgss_delete_sec_context( + OM_uint32 *, + gss_ctx_id_t *, + gss_buffer_t); + +OM_uint32 kgss_export_sec_context( + OM_uint32 *, + const gss_ctx_id_t, + gss_buffer_t); + +OM_uint32 kgss_import_sec_context( + OM_uint32 *, + const gss_buffer_t, + gss_ctx_id_t); + +OM_uint32 kgss_context_time( + OM_uint32 *, + const gss_ctx_id_t, + OM_uint32 *, + uid_t); + +OM_uint32 kgss_sign( + OM_uint32 *, + const gss_ctx_id_t, + int, + const gss_buffer_t, + gss_buffer_t); + + +OM_uint32 kgss_verify( + OM_uint32 *, + const gss_ctx_id_t, + const gss_buffer_t, + const gss_buffer_t, + int *); + +OM_uint32 kgss_seal( + OM_uint32 *, + const gss_ctx_id_t, + int, + int, + const gss_buffer_t, + int *, + gss_buffer_t); + +OM_uint32 kgss_unseal( + OM_uint32 *, + const gss_ctx_id_t, + const gss_buffer_t, + gss_buffer_t, + int *, + int *); + +OM_uint32 kgss_display_status( + OM_uint32 *, + OM_uint32, + int, + const gss_OID, + int *, + gss_buffer_t, + uid_t); + +OM_uint32 kgss_indicate_mechs( + OM_uint32 *, + gss_OID_set *, + uid_t); + +OM_uint32 kgss_inquire_cred( + OM_uint32 *, + const gss_cred_id_t, + gss_name_t *, + OM_uint32 *, + int *, + gss_OID_set *, + uid_t); + +OM_uint32 kgss_inquire_cred_by_mech( + OM_uint32 *, + gss_cred_id_t, + gss_OID, + uid_t); + + +#endif /* if _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GSSAPI_H_ */ diff --git a/illumos-x86_64/usr/include/gssapi/gssapi_ext.h b/illumos-x86_64/usr/include/gssapi/gssapi_ext.h new file mode 100644 index 00000000..3e26dfef --- /dev/null +++ b/illumos-x86_64/usr/include/gssapi/gssapi_ext.h @@ -0,0 +1,277 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Private extensions and utilities to the GSS-API. + * These are not part of the GSS-API specification + * but may be useful to GSS-API users. + */ + +#ifndef _GSSAPI_EXT_H +#define _GSSAPI_EXT_H + +#include +#ifdef _KERNEL +#include +#else +#include +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* MACRO for comparison of gss_OID's */ +#define g_OID_equal(o1, o2) \ + (((o1)->length == (o2)->length) && \ + (memcmp((o1)->elements, (o2)->elements, (int)(o1)->length) == 0)) + + +/* + * MACRO for copying of OIDs - memory must already be allocated + * o2 is copied to o1 + */ +#define g_OID_copy(o1, o2) \ + bcopy((o2)->elements, (o1)->elements, (o2)->length);\ + (o1)->length = (o2)->length; + + +/* MACRO to check if input buffer is valid */ +#define GSS_EMPTY_BUFFER(buf) ((buf) == NULL ||\ + (buf)->value == NULL || (buf)->length == 0) + + +/* + * GSSAPI Extension functions -- these functions aren't + * in the GSSAPI specification, but are provided in our + * GSS library. + */ + +#ifndef _KERNEL + +/* + * qop configuration file handling. + */ +#define MAX_QOP_NUM_PAIRS 128 +#define MAX_QOPS_PER_MECH 128 + +typedef struct _qop_num { + char *qop; + OM_uint32 num; + char *mech; +} qop_num; + +OM_uint32 +__gss_qop_to_num( + char *qop, /* input qop string */ + char *mech, /* input mech string */ + OM_uint32 *num /* output qop num */ +); + +OM_uint32 +__gss_num_to_qop( + char *mech, /* input mech string */ + OM_uint32 num, /* input qop num */ + char **qop /* output qop name */ +); + +OM_uint32 +__gss_get_mech_info( + char *mech, /* input mech string */ + char **qops /* buffer for return qops */ +); + +OM_uint32 +__gss_mech_qops( + char *mech, /* input mech */ + qop_num *mech_qops, /* mech qops buffer */ + int *numqops /* buffer to return numqops */ +); + +OM_uint32 +__gss_mech_to_oid( + const char *mech, /* mechanism string name */ + gss_OID *oid /* mechanism oid */ +); + +const char * +__gss_oid_to_mech( + const gss_OID oid /* mechanism oid */ +); + +OM_uint32 +__gss_get_mechanisms( + char *mechArray[], /* array to populate with mechs */ + int arrayLen /* length of passed in array */ +); + +OM_uint32 +__gss_get_mech_type( + gss_OID oid, /* mechanism oid */ + const gss_buffer_t token /* token */ +); + +OM_uint32 +__gss_userok( + OM_uint32 *, /* minor status */ + const gss_name_t, /* remote user principal name */ + const char *, /* local unix user name */ + int *); /* remote principal ok to login w/out pw? */ + +OM_uint32 +gsscred_expname_to_unix_cred( + const gss_buffer_t, /* export name */ + uid_t *, /* uid out */ + gid_t *, /* gid out */ + gid_t *[], /* gid array out */ + int *); /* gid array length */ + +OM_uint32 +gsscred_name_to_unix_cred( + const gss_name_t, /* gss name */ + const gss_OID, /* mechanim type */ + uid_t *, /* uid out */ + gid_t *, /* gid out */ + gid_t *[], /* gid array out */ + int *); /* gid array length */ + + +/* + * The following function will be used to resolve group + * ids from a UNIX uid. + */ +OM_uint32 +gss_get_group_info( + const uid_t, /* entity UNIX uid */ + gid_t *, /* gid out */ + gid_t *[], /* gid array */ + int *); /* length of the gid array */ + + + +OM_uint32 +gss_acquire_cred_with_password( + OM_uint32 * minor_status, + const gss_name_t desired_name, + const gss_buffer_t password, + OM_uint32 time_req, + const gss_OID_set desired_mechs, + int cred_usage, + gss_cred_id_t *output_cred_handle, + gss_OID_set * actual_mechs, + OM_uint32 * time_rec); + +OM_uint32 +gss_add_cred_with_password( + OM_uint32 *minor_status, + const gss_cred_id_t input_cred_handle, + const gss_name_t desired_name, + const gss_OID desired_mech, + const gss_buffer_t password, + gss_cred_usage_t cred_usage, + OM_uint32 initiator_time_req, + OM_uint32 acceptor_time_req, + gss_cred_id_t *output_cred_handle, + gss_OID_set *actual_mechs, + OM_uint32 *initiator_time_rec, + OM_uint32 *acceptor_time_rec); + +/* + * Returns a buffer set with the first member containing the + * session key for SSPI compatibility. The optional second + * member contains an OID identifying the session key type. + */ +extern const gss_OID GSS_C_INQ_SSPI_SESSION_KEY; + +/* + * For compatability with other GSSAPI implementations. + * This is needed by Samba. + */ +extern const gss_OID_desc * const gss_mech_krb5; + +#else /* _KERNEL */ + +OM_uint32 +kgsscred_expname_to_unix_cred( + const gss_buffer_t expName, + uid_t *uidOut, + gid_t *gidOut, + gid_t *gids[], + int *gidsLen, + uid_t uid); + +OM_uint32 +kgsscred_name_to_unix_cred( + const gss_name_t intName, + const gss_OID mechType, + uid_t *uidOut, + gid_t *gidOut, + gid_t *gids[], + int *gidsLen, + uid_t uid); + +OM_uint32 +kgss_get_group_info( + const uid_t puid, + gid_t *gidOut, + gid_t *gids[], + int *gidsLen, + uid_t uid); +#endif + +/* + * GGF extensions + */ +typedef struct gss_buffer_set_desc_struct { + size_t count; + gss_buffer_desc *elements; +} gss_buffer_set_desc, *gss_buffer_set_t; + +#define GSS_C_NO_BUFFER_SET ((gss_buffer_set_t)0) + +OM_uint32 gss_create_empty_buffer_set + (OM_uint32 *, /* minor_status */ + gss_buffer_set_t *); /* buffer_set */ + +OM_uint32 gss_add_buffer_set_member + (OM_uint32 *, /* minor_status */ + const gss_buffer_t, /* member_buffer */ + gss_buffer_set_t *); /* buffer_set */ + +OM_uint32 gss_release_buffer_set + (OM_uint32 *, /* minor_status */ + gss_buffer_set_t *); /* buffer_set */ + +OM_uint32 gss_inquire_sec_context_by_oid + (OM_uint32 *, /* minor_status */ + const gss_ctx_id_t, /* context_handle */ + const gss_OID, /* desired_object */ + gss_buffer_set_t *); /* data_set */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GSSAPI_EXT_H */ diff --git a/illumos-x86_64/usr/include/hal/libhal-storage.h b/illumos-x86_64/usr/include/hal/libhal-storage.h new file mode 100644 index 00000000..e77de95f --- /dev/null +++ b/illumos-x86_64/usr/include/hal/libhal-storage.h @@ -0,0 +1,362 @@ +/*************************************************************************** + * CVSID: $Id$ + * + * libhal-storage.h : HAL convenience library for storage devices and volumes + * + * Copyright (C) 2004 Red Hat, Inc. + * + * Author: David Zeuthen + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + **************************************************************************/ + +#ifndef LIBHAL_STORAGE_H +#define LIBHAL_STORAGE_H + +#include + +#if defined(__cplusplus) +extern "C" { +#if 0 +} /* shut up emacs indenting */ +#endif +#endif + +struct LibHalDrive_s; +typedef struct LibHalDrive_s LibHalDrive; +struct LibHalVolume_s; +typedef struct LibHalVolume_s LibHalVolume; +struct LibHalStoragePolicy_s; +typedef struct LibHalStoragePolicy_s LibHalStoragePolicy; + + +typedef enum { + LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK = 0x10000, + LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IDE = 0x10001, + LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_SCSI = 0x10002, + LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_USB = 0x10003, + LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IEEE1394 = 0x10004, + LIBHAL_STORAGE_ICON_DRIVE_DISK = 0x10100, + LIBHAL_STORAGE_ICON_DRIVE_DISK_IDE = 0x10101, + LIBHAL_STORAGE_ICON_DRIVE_DISK_SCSI = 0x10102, + LIBHAL_STORAGE_ICON_DRIVE_DISK_USB = 0x10103, + LIBHAL_STORAGE_ICON_DRIVE_DISK_IEEE1394 = 0x10104, + LIBHAL_STORAGE_ICON_DRIVE_CDROM = 0x10200, + LIBHAL_STORAGE_ICON_DRIVE_CDROM_IDE = 0x10201, + LIBHAL_STORAGE_ICON_DRIVE_CDROM_SCSI = 0x10202, + LIBHAL_STORAGE_ICON_DRIVE_CDROM_USB = 0x10203, + LIBHAL_STORAGE_ICON_DRIVE_CDROM_IEEE1394 = 0x10204, + LIBHAL_STORAGE_ICON_DRIVE_FLOPPY = 0x10300, + LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_IDE = 0x10301, + LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_SCSI = 0x10302, + LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_USB = 0x10303, + LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_IEEE1394 = 0x10304, + LIBHAL_STORAGE_ICON_DRIVE_TAPE = 0x10400, + LIBHAL_STORAGE_ICON_DRIVE_COMPACT_FLASH = 0x10500, + LIBHAL_STORAGE_ICON_DRIVE_MEMORY_STICK = 0x10600, + LIBHAL_STORAGE_ICON_DRIVE_SMART_MEDIA = 0x10700, + LIBHAL_STORAGE_ICON_DRIVE_SD_MMC = 0x10800, + LIBHAL_STORAGE_ICON_DRIVE_CAMERA = 0x10900, + LIBHAL_STORAGE_ICON_DRIVE_PORTABLE_AUDIO_PLAYER = 0x10a00, + LIBHAL_STORAGE_ICON_DRIVE_ZIP = 0x10b00, + LIBHAL_STORAGE_ICON_DRIVE_JAZ = 0x10c00, + LIBHAL_STORAGE_ICON_DRIVE_FLASH_KEY = 0x10d00, + + LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK = 0x20000, + LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IDE = 0x20001, + LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_SCSI = 0x20002, + LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_USB = 0x20003, + LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IEEE1394 = 0x20004, + LIBHAL_STORAGE_ICON_VOLUME_DISK = 0x20100, + LIBHAL_STORAGE_ICON_VOLUME_DISK_IDE = 0x20101, + LIBHAL_STORAGE_ICON_VOLUME_DISK_SCSI = 0x20102, + LIBHAL_STORAGE_ICON_VOLUME_DISK_USB = 0x20103, + LIBHAL_STORAGE_ICON_VOLUME_DISK_IEEE1394 = 0x20104, + LIBHAL_STORAGE_ICON_VOLUME_CDROM = 0x20200, + LIBHAL_STORAGE_ICON_VOLUME_CDROM_IDE = 0x20201, + LIBHAL_STORAGE_ICON_VOLUME_CDROM_SCSI = 0x20202, + LIBHAL_STORAGE_ICON_VOLUME_CDROM_USB = 0x20203, + LIBHAL_STORAGE_ICON_VOLUME_CDROM_IEEE1394 = 0x20204, + LIBHAL_STORAGE_ICON_VOLUME_FLOPPY = 0x20300, + LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_IDE = 0x20301, + LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_SCSI = 0x20302, + LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_USB = 0x20303, + LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_IEEE1394 = 0x20304, + LIBHAL_STORAGE_ICON_VOLUME_TAPE = 0x20400, + LIBHAL_STORAGE_ICON_VOLUME_COMPACT_FLASH = 0x20500, + LIBHAL_STORAGE_ICON_VOLUME_MEMORY_STICK = 0x20600, + LIBHAL_STORAGE_ICON_VOLUME_SMART_MEDIA = 0x20700, + LIBHAL_STORAGE_ICON_VOLUME_SD_MMC = 0x20800, + LIBHAL_STORAGE_ICON_VOLUME_CAMERA = 0x20900, + LIBHAL_STORAGE_ICON_VOLUME_PORTABLE_AUDIO_PLAYER = 0x20a00, + LIBHAL_STORAGE_ICON_VOLUME_ZIP = 0x20b00, + LIBHAL_STORAGE_ICON_VOLUME_JAZ = 0x20c00, + LIBHAL_STORAGE_ICON_VOLUME_FLASH_KEY = 0x20d00, + + LIBHAL_STORAGE_ICON_DISC_CDROM = 0x30000, + LIBHAL_STORAGE_ICON_DISC_CDR = 0x30001, + LIBHAL_STORAGE_ICON_DISC_CDRW = 0x30002, + LIBHAL_STORAGE_ICON_DISC_DVDROM = 0x30003, + LIBHAL_STORAGE_ICON_DISC_DVDRAM = 0x30004, + LIBHAL_STORAGE_ICON_DISC_DVDR = 0x30005, + LIBHAL_STORAGE_ICON_DISC_DVDRW = 0x30006, + LIBHAL_STORAGE_ICON_DISC_DVDPLUSR = 0x30007, + LIBHAL_STORAGE_ICON_DISC_DVDPLUSRW = 0x30008, + LIBHAL_STORAGE_ICON_DISC_DVDPLUSRWDL = 0x30009, + LIBHAL_STORAGE_ICON_DISC_BDROM = 0x3000a, + LIBHAL_STORAGE_ICON_DISC_BDR = 0x3000b, + LIBHAL_STORAGE_ICON_DISC_BDRE = 0x3000c, + LIBHAL_STORAGE_ICON_DISC_HDDVDROM = 0x3000d, + LIBHAL_STORAGE_ICON_DISC_HDDVDR = 0x3000e, + LIBHAL_STORAGE_ICON_DISC_HDDVDRW = 0x3000f +} LibHalStoragePolicyIcon; + +typedef struct { + LibHalStoragePolicyIcon icon; + const char *icon_path; +} LibHalStoragePolicyIconPair; + +LibHalStoragePolicy *libhal_storage_policy_new (void) LIBHAL_DEPRECATED; +void libhal_storage_policy_free (LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; + +void libhal_storage_policy_set_icon_path (LibHalStoragePolicy *policy, + LibHalStoragePolicyIcon icon, + const char *path) LIBHAL_DEPRECATED; + +void libhal_storage_policy_set_icon_mapping (LibHalStoragePolicy *policy, + LibHalStoragePolicyIconPair *pairs) LIBHAL_DEPRECATED; +const char *libhal_storage_policy_lookup_icon (LibHalStoragePolicy *policy, + LibHalStoragePolicyIcon icon) LIBHAL_DEPRECATED; + +typedef enum { + LIBHAL_DRIVE_BUS_UNKNOWN = 0x00, + LIBHAL_DRIVE_BUS_IDE = 0x01, + LIBHAL_DRIVE_BUS_SCSI = 0x02, + LIBHAL_DRIVE_BUS_USB = 0x03, + LIBHAL_DRIVE_BUS_IEEE1394 = 0x04, + LIBHAL_DRIVE_BUS_CCW = 0x05 +} LibHalDriveBus; + +typedef enum { + LIBHAL_DRIVE_TYPE_REMOVABLE_DISK = 0x00, + LIBHAL_DRIVE_TYPE_DISK = 0x01, + LIBHAL_DRIVE_TYPE_CDROM = 0x02, + LIBHAL_DRIVE_TYPE_FLOPPY = 0x03, + LIBHAL_DRIVE_TYPE_TAPE = 0x04, + LIBHAL_DRIVE_TYPE_COMPACT_FLASH = 0x05, + LIBHAL_DRIVE_TYPE_MEMORY_STICK = 0x06, + LIBHAL_DRIVE_TYPE_SMART_MEDIA = 0x07, + LIBHAL_DRIVE_TYPE_SD_MMC = 0x08, + LIBHAL_DRIVE_TYPE_CAMERA = 0x09, + LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER = 0x0a, + LIBHAL_DRIVE_TYPE_ZIP = 0x0b, + LIBHAL_DRIVE_TYPE_JAZ = 0x0c, + LIBHAL_DRIVE_TYPE_FLASHKEY = 0x0d +} LibHalDriveType; + +typedef enum { + LIBHAL_DRIVE_CDROM_CAPS_CDROM = 0x00001, + LIBHAL_DRIVE_CDROM_CAPS_CDR = 0x00002, + LIBHAL_DRIVE_CDROM_CAPS_CDRW = 0x00004, + LIBHAL_DRIVE_CDROM_CAPS_DVDRAM = 0x00008, + LIBHAL_DRIVE_CDROM_CAPS_DVDROM = 0x00010, + LIBHAL_DRIVE_CDROM_CAPS_DVDR = 0x00020, + LIBHAL_DRIVE_CDROM_CAPS_DVDRW = 0x00040, + LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR = 0x00080, + LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW = 0x00100, + LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL = 0x00200, + LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRWDL = 0x00400, + LIBHAL_DRIVE_CDROM_CAPS_BDROM = 0x00800, + LIBHAL_DRIVE_CDROM_CAPS_BDR = 0x01000, + LIBHAL_DRIVE_CDROM_CAPS_BDRE = 0x02000, + LIBHAL_DRIVE_CDROM_CAPS_HDDVDROM = 0x04000, + LIBHAL_DRIVE_CDROM_CAPS_HDDVDR = 0x08000, + LIBHAL_DRIVE_CDROM_CAPS_HDDVDRW = 0x10000 +} LibHalDriveCdromCaps; + +LibHalDrive *libhal_drive_from_udi (LibHalContext *hal_ctx, + const char *udi); +LibHalDrive *libhal_drive_from_device_file (LibHalContext *hal_ctx, + const char *device_file); +void libhal_drive_free (LibHalDrive *drive); + +dbus_bool_t libhal_drive_is_hotpluggable (LibHalDrive *drive); +dbus_bool_t libhal_drive_uses_removable_media (LibHalDrive *drive); +dbus_bool_t libhal_drive_is_media_detected (LibHalDrive *drive); +dbus_uint64_t libhal_drive_get_size (LibHalDrive *drive); +dbus_uint64_t libhal_drive_get_media_size (LibHalDrive *drive); +const char *libhal_drive_get_partition_scheme (LibHalDrive *drive); +dbus_bool_t libhal_drive_no_partitions_hint (LibHalDrive *drive); +dbus_bool_t libhal_drive_requires_eject (LibHalDrive *drive); +LibHalDriveType libhal_drive_get_type (LibHalDrive *drive); +LibHalDriveBus libhal_drive_get_bus (LibHalDrive *drive); +LibHalDriveCdromCaps libhal_drive_get_cdrom_caps (LibHalDrive *drive); +unsigned int libhal_drive_get_device_major (LibHalDrive *drive); +unsigned int libhal_drive_get_device_minor (LibHalDrive *drive); +const char *libhal_drive_get_type_textual (LibHalDrive *drive); +const char *libhal_drive_get_device_file (LibHalDrive *drive); +const char *libhal_drive_get_udi (LibHalDrive *drive); +const char *libhal_drive_get_serial (LibHalDrive *drive); +const char *libhal_drive_get_firmware_version (LibHalDrive *drive); +const char *libhal_drive_get_model (LibHalDrive *drive); +const char *libhal_drive_get_vendor (LibHalDrive *drive); +const char *libhal_drive_get_physical_device_udi (LibHalDrive *drive); + +const char *libhal_drive_get_dedicated_icon_drive (LibHalDrive *drive); +const char *libhal_drive_get_dedicated_icon_volume (LibHalDrive *drive); + +char *libhal_drive_policy_compute_display_name (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; +char *libhal_drive_policy_compute_icon_name (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; + +dbus_bool_t libhal_drive_policy_is_mountable (LibHalDrive *drive, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; +const char *libhal_drive_policy_get_desired_mount_point (LibHalDrive *drive, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; +const char *libhal_drive_policy_get_mount_options (LibHalDrive *drive, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; +const char *libhal_drive_policy_get_mount_fs (LibHalDrive *drive, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; + +char **libhal_drive_find_all_volumes (LibHalContext *hal_ctx, + LibHalDrive *drive, + int *num_volumes); + + +char *libhal_drive_policy_default_get_mount_root (LibHalContext *hal_ctx) LIBHAL_DEPRECATED; +dbus_bool_t libhal_drive_policy_default_use_managed_keyword (LibHalContext *hal_ctx) LIBHAL_DEPRECATED; +char *libhal_drive_policy_default_get_managed_keyword_primary (LibHalContext *hal_ctx) LIBHAL_DEPRECATED; +char *libhal_drive_policy_default_get_managed_keyword_secondary (LibHalContext *hal_ctx) LIBHAL_DEPRECATED; + + +typedef enum { + LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM, + LIBHAL_VOLUME_USAGE_PARTITION_TABLE, + LIBHAL_VOLUME_USAGE_RAID_MEMBER, + LIBHAL_VOLUME_USAGE_CRYPTO, + LIBHAL_VOLUME_USAGE_UNKNOWN, + LIBHAL_VOLUME_USAGE_OTHER +} LibHalVolumeUsage; + +typedef enum { + LIBHAL_VOLUME_DISC_TYPE_CDROM = 0x00, + LIBHAL_VOLUME_DISC_TYPE_CDR = 0x01, + LIBHAL_VOLUME_DISC_TYPE_CDRW = 0x02, + LIBHAL_VOLUME_DISC_TYPE_DVDROM = 0x03, + LIBHAL_VOLUME_DISC_TYPE_DVDRAM = 0x04, + LIBHAL_VOLUME_DISC_TYPE_DVDR = 0x05, + LIBHAL_VOLUME_DISC_TYPE_DVDRW = 0x06, + LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR = 0x07, + LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW = 0x08, + LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR_DL = 0x09, + LIBHAL_VOLUME_DISC_TYPE_BDROM = 0x0a, + LIBHAL_VOLUME_DISC_TYPE_BDR = 0x0b, + LIBHAL_VOLUME_DISC_TYPE_BDRE = 0x0c, + LIBHAL_VOLUME_DISC_TYPE_HDDVDROM = 0x0d, + LIBHAL_VOLUME_DISC_TYPE_HDDVDR = 0x0e, + LIBHAL_VOLUME_DISC_TYPE_HDDVDRW = 0x0f +} LibHalVolumeDiscType; + +LibHalVolume *libhal_volume_from_udi (LibHalContext *hal_ctx, + const char *udi); +LibHalVolume *libhal_volume_from_device_file (LibHalContext *hal_ctx, + const char *device_file); +void libhal_volume_free (LibHalVolume *volume); +dbus_uint64_t libhal_volume_get_size (LibHalVolume *volume); +dbus_uint64_t libhal_volume_get_disc_capacity (LibHalVolume *volume); + +const char *libhal_volume_get_udi (LibHalVolume *volume); +const char *libhal_volume_get_device_file (LibHalVolume *volume); +unsigned int libhal_volume_get_device_major (LibHalVolume *volume); +unsigned int libhal_volume_get_device_minor (LibHalVolume *volume); +const char *libhal_volume_get_fstype (LibHalVolume *volume); +const char *libhal_volume_get_fsversion (LibHalVolume *volume); +LibHalVolumeUsage libhal_volume_get_fsusage (LibHalVolume *volume); +dbus_bool_t libhal_volume_is_mounted (LibHalVolume *volume); +dbus_bool_t libhal_volume_is_mounted_read_only (LibHalVolume *volume); +dbus_bool_t libhal_volume_is_partition (LibHalVolume *volume); +dbus_bool_t libhal_volume_is_disc (LibHalVolume *volume); + +const char *libhal_volume_get_partition_scheme (LibHalVolume *volume); +const char *libhal_volume_get_partition_type (LibHalVolume *volume); +const char *libhal_volume_get_partition_label (LibHalVolume *volume); +const char *libhal_volume_get_partition_uuid (LibHalVolume *volume); +const char **libhal_volume_get_partition_flags (LibHalVolume *volume); +unsigned int libhal_volume_get_partition_number (LibHalVolume *volume); +dbus_uint64_t libhal_volume_get_partition_start_offset (LibHalVolume *volume); +dbus_uint64_t libhal_volume_get_partition_media_size (LibHalVolume *volume); + +const char *libhal_volume_get_label (LibHalVolume *volume); +const char *libhal_volume_get_mount_point (LibHalVolume *volume); +const char *libhal_volume_get_uuid (LibHalVolume *volume); +const char *libhal_volume_get_storage_device_udi (LibHalVolume *volume); + +const char *libhal_volume_crypto_get_backing_volume_udi (LibHalVolume *volume); +char *libhal_volume_crypto_get_clear_volume_udi (LibHalContext *hal_ctx, LibHalVolume *volume); + + +dbus_bool_t libhal_volume_disc_has_audio (LibHalVolume *volume); +dbus_bool_t libhal_volume_disc_has_data (LibHalVolume *volume); +dbus_bool_t libhal_volume_disc_is_blank (LibHalVolume *volume); +dbus_bool_t libhal_volume_disc_is_rewritable (LibHalVolume *volume); +dbus_bool_t libhal_volume_disc_is_appendable (LibHalVolume *volume); +LibHalVolumeDiscType libhal_volume_get_disc_type (LibHalVolume *volume); + +int libhal_volume_get_msdos_part_table_type (LibHalVolume *volume) LIBHAL_DEPRECATED; +dbus_uint64_t libhal_volume_get_msdos_part_table_start (LibHalVolume *volume) LIBHAL_DEPRECATED; +dbus_uint64_t libhal_volume_get_msdos_part_table_size (LibHalVolume *volume) LIBHAL_DEPRECATED; + + +dbus_bool_t libhal_volume_should_ignore (LibHalVolume *volume); + +char *libhal_volume_policy_compute_size_as_string (LibHalVolume *volume) LIBHAL_DEPRECATED; + +char *libhal_volume_policy_compute_display_name (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; +char *libhal_volume_policy_compute_icon_name (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; + +dbus_bool_t libhal_volume_policy_should_be_visible (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy, + const char *target_mount_point) LIBHAL_DEPRECATED; + +dbus_bool_t libhal_volume_policy_is_mountable (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; +const char *libhal_volume_policy_get_desired_mount_point (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; +const char *libhal_volume_policy_get_mount_options (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; +const char *libhal_volume_policy_get_mount_fs (LibHalDrive *drive, + LibHalVolume *volume, + LibHalStoragePolicy *policy) LIBHAL_DEPRECATED; + + +#if defined(__cplusplus) +} +#endif + +#endif /* LIBHAL_STORAGE_H */ diff --git a/illumos-x86_64/usr/include/hal/libhal.h b/illumos-x86_64/usr/include/hal/libhal.h new file mode 100644 index 00000000..a7735d1d --- /dev/null +++ b/illumos-x86_64/usr/include/hal/libhal.h @@ -0,0 +1,625 @@ +/*************************************************************************** + * CVSID: $Id$ + * + * libhal.h : HAL daemon C convenience library headers + * + * Copyright (C) 2003 David Zeuthen, + * Copyright (C) 2007 Codethink Ltd. Author Rob Taylor + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + **************************************************************************/ + +#ifndef LIBHAL_H +#define LIBHAL_H + +#include + +#if defined(__cplusplus) +extern "C" { +#if 0 +} /* shut up emacs indenting */ +#endif +#endif + +#if defined(__GNUC__) +#define LIBHAL_DEPRECATED __attribute__ ((deprecated)) +#else +#define LIBHAL_DEPRECATED +#endif + + +#define LIBHAL_FREE_DBUS_ERROR(_dbus_error_) \ + do { \ + if (dbus_error_is_set(_dbus_error_)) \ + dbus_error_free (_dbus_error_); \ + } while (0) + + +/** + * LIBHAL_CHECK_LIBHALCONTEXT: + * @_ctx_: the context + * @_ret_: what to use for return value if context is invalid + * + * Handy macro for checking whether a context is valid. + */ +#define LIBHAL_CHECK_LIBHALCONTEXT(_ctx_, _ret_) \ + do { \ + if (_ctx_ == NULL) { \ + fprintf (stderr, \ + "%s %d : LibHalContext *ctx is NULL\n", \ + __FILE__, __LINE__); \ + return _ret_; \ + } \ + } while(0) + +/** + * LibHalPropertyType: + * + * Possible types for properties on hal device objects + */ +typedef enum { + /** Used to report error condition */ + LIBHAL_PROPERTY_TYPE_INVALID = DBUS_TYPE_INVALID, + + /** Type for 32-bit signed integer property */ + LIBHAL_PROPERTY_TYPE_INT32 = DBUS_TYPE_INT32, + + /** Type for 64-bit unsigned integer property */ + LIBHAL_PROPERTY_TYPE_UINT64 = DBUS_TYPE_UINT64, + + /** Type for double precision floating point property */ + LIBHAL_PROPERTY_TYPE_DOUBLE = DBUS_TYPE_DOUBLE, + + /** Type for boolean property */ + LIBHAL_PROPERTY_TYPE_BOOLEAN = DBUS_TYPE_BOOLEAN, + + /** Type code marking a D-Bus array type */ + LIBHAL_PROPERTY_TYPE_ARRAY = DBUS_TYPE_ARRAY, + + /** Type for UTF-8 string property */ + LIBHAL_PROPERTY_TYPE_STRING = DBUS_TYPE_STRING, + + /** Type for list of UTF-8 strings property */ + LIBHAL_PROPERTY_TYPE_STRLIST = ((int) (DBUS_TYPE_STRING<<8)+('l')) +} LibHalPropertyType; + + +typedef struct LibHalContext_s LibHalContext; + +/** + * LibHalIntegrateDBusIntoMainLoop: + * @ctx: context for connection to hald + * @dbus_connection: DBus connection to use in ctx + * + * Type for function in application code that integrates a + * DBusConnection object into its own mainloop. + */ +typedef void (*LibHalIntegrateDBusIntoMainLoop) (LibHalContext *ctx, + DBusConnection *dbus_connection); + +/** + * LibHalDeviceAdded: + * @ctx: context for connection to hald + * @udi: the Unique Device Id + * + * Type for callback when a device is added. + */ +typedef void (*LibHalDeviceAdded) (LibHalContext *ctx, + const char *udi); + +/** + * LibHalDeviceRemoved: + * @ctx: context for connection to hald + * @udi: the Unique Device Id + * + * Type for callback when a device is removed. + */ +typedef void (*LibHalDeviceRemoved) (LibHalContext *ctx, + const char *udi); + +/** + * LibHalDeviceNewCapability: + * @ctx: context for connection to hald + * @udi: the Unique Device Id + * @capability: capability of the device + * + * Type for callback when a device gains a new capability. + * + */ +typedef void (*LibHalDeviceNewCapability) (LibHalContext *ctx, + const char *udi, + const char *capability); + +/** + * LibHalDeviceLostCapability: + * @ctx: context for connection to hald + * @udi: the Unique Device Id + * @capability: capability of the device + * + * Type for callback when a device loses a capability. + * + */ +typedef void (*LibHalDeviceLostCapability) (LibHalContext *ctx, + const char *udi, + const char *capability); + +/** + * LibHalDevicePropertyModified: + * @ctx: context for connection to hald + * @udi: the Unique Device Id + * @key: name of the property that has changed + * @is_removed: whether or not property was removed + * @is_added: whether or not property was added + * + * Type for callback when a property of a device changes. + */ +typedef void (*LibHalDevicePropertyModified) (LibHalContext *ctx, + const char *udi, + const char *key, + dbus_bool_t is_removed, + dbus_bool_t is_added); + +/** + * LibHalDeviceCondition: + * @ctx: context for connection to hald + * @udi: the Unique Device Id + * @condition_name: name of the condition, e.g. ProcessorOverheating. Consult the HAL spec for details + * @condition_detail: detail of condition + * + * Type for callback when a non-continuous condition occurs on a device. + */ +typedef void (*LibHalDeviceCondition) (LibHalContext *ctx, + const char *udi, + const char *condition_name, + const char *condition_detail); + + +/* Create a new context for a connection with hald */ +LibHalContext *libhal_ctx_new (void); + +/* Enable or disable caching */ +dbus_bool_t libhal_ctx_set_cache (LibHalContext *ctx, dbus_bool_t use_cache); + +/* Set DBus connection to use to talk to hald. */ +dbus_bool_t libhal_ctx_set_dbus_connection (LibHalContext *ctx, DBusConnection *conn); + +/* Get DBus connection to use to talk to hald. */ +DBusConnection *libhal_ctx_get_dbus_connection (LibHalContext *ctx); + +/* Set user data for the context */ +dbus_bool_t libhal_ctx_set_user_data (LibHalContext *ctx, void *user_data); + +/* Get user data for the context */ +void* libhal_ctx_get_user_data (LibHalContext *ctx); + +/* Set the callback for when a device is added */ +dbus_bool_t libhal_ctx_set_device_added (LibHalContext *ctx, LibHalDeviceAdded callback); + +/* Set the callback for when a device is removed */ +dbus_bool_t libhal_ctx_set_device_removed (LibHalContext *ctx, LibHalDeviceRemoved callback); + +/* Set the callback for when a device gains a new capability */ +dbus_bool_t libhal_ctx_set_device_new_capability (LibHalContext *ctx, LibHalDeviceNewCapability callback); + +/* Set the callback for when a device loses a capability */ +dbus_bool_t libhal_ctx_set_device_lost_capability (LibHalContext *ctx, LibHalDeviceLostCapability callback); + +/* Set the callback for when a property is modified on a device */ +dbus_bool_t libhal_ctx_set_device_property_modified (LibHalContext *ctx, LibHalDevicePropertyModified callback); + +/* Set the callback for when a device emits a condition */ +dbus_bool_t libhal_ctx_set_device_condition (LibHalContext *ctx, LibHalDeviceCondition callback); + +/* Initialize the connection to hald */ +dbus_bool_t libhal_ctx_init (LibHalContext *ctx, DBusError *error); + +/* Shut down a connection to hald */ +dbus_bool_t libhal_ctx_shutdown (LibHalContext *ctx, DBusError *error); + +/* Free a LibHalContext resource */ +dbus_bool_t libhal_ctx_free (LibHalContext *ctx); + +/* Create an already initialized connection to hald */ +LibHalContext *libhal_ctx_init_direct (DBusError *error); + +/* Get all devices in the Global Device List (GDL). */ +char **libhal_get_all_devices (LibHalContext *ctx, int *num_devices, DBusError *error); + +/* Determine if a device exists. */ +dbus_bool_t libhal_device_exists (LibHalContext *ctx, const char *udi, DBusError *error); + +/* Print a device to stdout; useful for debugging. */ +dbus_bool_t libhal_device_print (LibHalContext *ctx, const char *udi, DBusError *error); + +/* Determine if a property on a device exists. */ +dbus_bool_t libhal_device_property_exists (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +/* Get the value of a property of type string. */ +char *libhal_device_get_property_string (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +/* Get the value of a property of type signed integer. */ +dbus_int32_t libhal_device_get_property_int (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +/* Get the value of a property of type unsigned integer. */ +dbus_uint64_t libhal_device_get_property_uint64 (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +/* Get the value of a property of type double. */ +double libhal_device_get_property_double (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +/* Get the value of a property of type bool. */ +dbus_bool_t libhal_device_get_property_bool (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +/* Get the value of a property of type string list. */ +char **libhal_device_get_property_strlist (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +/* Set a property of type string. */ +dbus_bool_t libhal_device_set_property_string (LibHalContext *ctx, + const char *udi, + const char *key, + const char *value, + DBusError *error); + +/* Set a property of type signed integer. */ +dbus_bool_t libhal_device_set_property_int (LibHalContext *ctx, + const char *udi, + const char *key, + dbus_int32_t value, + DBusError *error); + +/* Set a property of type unsigned integer. */ +dbus_bool_t libhal_device_set_property_uint64 (LibHalContext *ctx, + const char *udi, + const char *key, + dbus_uint64_t value, + DBusError *error); + +/* Set a property of type double. */ +dbus_bool_t libhal_device_set_property_double (LibHalContext *ctx, + const char *udi, + const char *key, + double value, + DBusError *error); + +/* Set a property of type bool. */ +dbus_bool_t libhal_device_set_property_bool (LibHalContext *ctx, + const char *udi, + const char *key, + dbus_bool_t value, + DBusError *error); + +/* Append to a property of type strlist. */ +dbus_bool_t libhal_device_property_strlist_append (LibHalContext *ctx, + const char *udi, + const char *key, + const char *value, + DBusError *error); + +/* Prepend to a property of type strlist. */ +dbus_bool_t libhal_device_property_strlist_prepend (LibHalContext *ctx, + const char *udi, + const char *key, + const char *value, + DBusError *error); + +/* Remove a specified string from a property of type strlist. */ +dbus_bool_t libhal_device_property_strlist_remove_index (LibHalContext *ctx, + const char *udi, + const char *key, + unsigned int idx, + DBusError *error); + +/* Remove a specified string from a property of type strlist. */ +dbus_bool_t libhal_device_property_strlist_remove (LibHalContext *ctx, + const char *udi, + const char *key, + const char *value, + DBusError *error); + +/* Remove a property. */ +dbus_bool_t libhal_device_remove_property (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +/* Query a property type of a device. */ +LibHalPropertyType libhal_device_get_property_type (LibHalContext *ctx, + const char *udi, + const char *key, + DBusError *error); + +struct LibHalChangeSet_s; +typedef struct LibHalChangeSet_s LibHalChangeSet; + +LibHalChangeSet *libhal_device_new_changeset (const char *udi); + +dbus_bool_t libhal_changeset_set_property_string (LibHalChangeSet *changeset, + const char *key, + const char *value); + +dbus_bool_t libhal_changeset_set_property_int (LibHalChangeSet *changeset, + const char *key, + dbus_int32_t value); + +dbus_bool_t libhal_changeset_set_property_uint64 (LibHalChangeSet *changeset, + const char *key, + dbus_uint64_t value); + +dbus_bool_t libhal_changeset_set_property_double (LibHalChangeSet *changeset, + const char *key, + double value); + +dbus_bool_t libhal_changeset_set_property_bool (LibHalChangeSet *changeset, + const char *key, + dbus_bool_t value); + +dbus_bool_t libhal_changeset_set_property_strlist (LibHalChangeSet *changeset, + const char *key, + const char **value); + +dbus_bool_t libhal_device_commit_changeset (LibHalContext *ctx, + LibHalChangeSet *changeset, + DBusError *error); + +void libhal_device_free_changeset (LibHalChangeSet *changeset); + + +struct LibHalProperty_s; +typedef struct LibHalProperty_s LibHalProperty; + +struct LibHalPropertySet_s; +typedef struct LibHalPropertySet_s LibHalPropertySet; + + +/* Retrieve all the properties on a device. */ +LibHalPropertySet *libhal_device_get_all_properties (LibHalContext *ctx, + const char *udi, + DBusError *error); + +/* Free a property set earlier obtained with libhal_device_get_all_properties(). */ +void libhal_free_property_set (LibHalPropertySet *set); + +/* Get the number of properties in a property set. */ +unsigned int libhal_property_set_get_num_elems (LibHalPropertySet *set); + +/* Get type of property. */ +LibHalPropertyType libhal_ps_get_type (const LibHalPropertySet *set, const char *key); + +/* Get the value of a property of type string. */ +const char *libhal_ps_get_string (const LibHalPropertySet *set, const char *key); + +/* Get the value of a property of type signed integer. */ +dbus_int32_t libhal_ps_get_int32 (const LibHalPropertySet *set, const char *key); + +/* Get the value of a property of type unsigned integer. */ +dbus_uint64_t libhal_ps_get_uint64 (const LibHalPropertySet *set, const char *key); + +/* Get the value of a property of type double. */ +double libhal_ps_get_double (const LibHalPropertySet *set, const char *key); + +/* Get the value of a property of type bool. */ +dbus_bool_t libhal_ps_get_bool (const LibHalPropertySet *set, const char *key); + +/* Get the value of a property of type string list. */ +const char * const *libhal_ps_get_strlist (const LibHalPropertySet *set, const char *key); + + +/** + * LibHalPropertySetIterator: + * + * Iterator for inspecting all properties. Do not access any members; + * use the libhal_psi_* family of functions instead. + */ +struct LibHalPropertySetIterator_s { + LibHalPropertySet *set; /**< Property set we are iterating over */ + unsigned int idx; /**< Index into current element */ + LibHalProperty *cur_prop; /**< Current property being visited */ + void *reservered0; /**< Reserved for future use */ + void *reservered1; /**< Reserved for future use */ +}; + + +typedef struct LibHalPropertySetIterator_s LibHalPropertySetIterator; + +/* Initialize a property set iterator. */ +void libhal_psi_init (LibHalPropertySetIterator *iter, LibHalPropertySet *set); + +/* Determine whether there are more properties to iterate over */ +dbus_bool_t libhal_psi_has_more (LibHalPropertySetIterator *iter); + +/* Advance iterator to next property. */ +void libhal_psi_next (LibHalPropertySetIterator *iter); + +/* Get type of property. */ +LibHalPropertyType libhal_psi_get_type (LibHalPropertySetIterator *iter); + +/* Get the key of a property. */ +char *libhal_psi_get_key (LibHalPropertySetIterator *iter); + +/* Get the value of a property of type string. */ +char *libhal_psi_get_string (LibHalPropertySetIterator *iter); + +/* Get the value of a property of type signed integer. */ +dbus_int32_t libhal_psi_get_int (LibHalPropertySetIterator *iter); + +/* Get the value of a property of type unsigned integer. */ +dbus_uint64_t libhal_psi_get_uint64 (LibHalPropertySetIterator *iter); + +/* Get the value of a property of type double. */ +double libhal_psi_get_double (LibHalPropertySetIterator *iter); + +/* Get the value of a property of type bool. */ +dbus_bool_t libhal_psi_get_bool (LibHalPropertySetIterator *iter); + +/* Get the value of a property of type string list. */ +char **libhal_psi_get_strlist (LibHalPropertySetIterator *iter); + +/* Get the length of an array of strings */ +unsigned int libhal_string_array_length (char **str_array); + +/* Frees a NULL-terminated array of strings. If passed NULL, does nothing. */ +void libhal_free_string_array (char **str_array); + +/* Frees a nul-terminated string */ +void libhal_free_string (char *str); + +/* Create a new device object which will be hidden from applications + * until the CommitToGdl(), ie. libhal_device_commit_to_gdl(), method is called. + */ +char *libhal_new_device (LibHalContext *ctx, DBusError *error); + +/* When a hidden device has been built using the NewDevice method, ie. + * libhal_new_device(), and the org.freedesktop.Hal.Device interface + * this function will commit it to the global device list. + */ +dbus_bool_t libhal_device_commit_to_gdl (LibHalContext *ctx, + const char *temp_udi, + const char *udi, + DBusError *error); + +/* This method can be invoked when a device is removed. The HAL daemon + * will shut down the device. Note that the device may still be in the device + * list if the Persistent property is set to true. + */ +dbus_bool_t libhal_remove_device (LibHalContext *ctx, + const char *udi, + DBusError *error); + +/* Merge properties from one device to another. */ +dbus_bool_t libhal_merge_properties (LibHalContext *ctx, + const char *target_udi, + const char *source_udi, + DBusError *error); + +/* Check a set of properties for two devices matches. */ +dbus_bool_t libhal_device_matches (LibHalContext *ctx, + const char *udi1, + const char *udi2, + const char *property_namespace, + DBusError *error); + +/* Find a device in the GDL where a single string property matches a + * given value. + */ +char **libhal_manager_find_device_string_match (LibHalContext *ctx, + const char *key, + const char *value, + int *num_devices, + DBusError *error); + +/* Assign a capability to a device. */ +dbus_bool_t libhal_device_add_capability (LibHalContext *ctx, + const char *udi, + const char *capability, + DBusError *error); + +/* Check if a device has a capability. The result is undefined if the + * device doesn't exist. + */ +dbus_bool_t libhal_device_query_capability (LibHalContext *ctx, + const char *udi, + const char *capability, + DBusError *error); + +/* Find devices with a given capability. */ +char **libhal_find_device_by_capability (LibHalContext *ctx, + const char *capability, + int *num_devices, + DBusError *error); + +/* Watch all devices, ie. the device_property_changed callback is + * invoked when the properties on any device changes. + */ +dbus_bool_t libhal_device_property_watch_all (LibHalContext *ctx, + DBusError *error); + +/* Add a watch on a device, so the device_property_changed callback is + * invoked when the properties on the given device changes. + */ +dbus_bool_t libhal_device_add_property_watch (LibHalContext *ctx, + const char *udi, + DBusError *error); + +/* Remove a watch on a device */ +dbus_bool_t libhal_device_remove_property_watch (LibHalContext *ctx, + const char *udi, + DBusError *error); + +/* Take an advisory lock on the device. */ +dbus_bool_t libhal_device_lock (LibHalContext *ctx, + const char *udi, + const char *reason_to_lock, + char **reason_why_locked, + DBusError *error); + +/* Release an advisory lock on the device. */ +dbus_bool_t libhal_device_unlock (LibHalContext *ctx, + const char *udi, + DBusError *error); + +dbus_bool_t libhal_device_rescan (LibHalContext *ctx, + const char *udi, + DBusError *error); + +dbus_bool_t libhal_device_reprobe (LibHalContext *ctx, + const char *udi, + DBusError *error); + +/* Emit a condition from a device (for hald helpers only) */ +dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx, + const char *udi, + const char *condition_name, + const char *condition_details, + DBusError *error); + +/* Claim an interface for a device (for hald helpers only) */ +dbus_bool_t libhal_device_claim_interface (LibHalContext *ctx, + const char *udi, + const char *interface_name, + const char *introspection_xml, + DBusError *error); + +/* hald waits for all addons to call this function before announcing the addon (for hald helpers only) */ +dbus_bool_t libhal_device_addon_is_ready (LibHalContext *ctx, const char *udi, DBusError *error); + + +#if defined(__cplusplus) +} +#endif + +#endif /* LIBHAL_H */ diff --git a/illumos-x86_64/usr/include/hbaapi.h b/illumos-x86_64/usr/include/hbaapi.h new file mode 100644 index 00000000..0b6315e7 --- /dev/null +++ b/illumos-x86_64/usr/include/hbaapi.h @@ -0,0 +1,958 @@ +/* + * ***************************************************************************** + * + * Description + * hbaapi.h - general header file for client + * and library developers + * + * License: + * The contents of this file are subject to the SNIA Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * /http://www.snia.org/English/Resources/Code/OpenSource.html + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is SNIA HBA API general header file + * + * The Initial Developer of the Original Code is: + * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com) + * + * Contributor(s): + * Tuan Lam, QLogic Corp. (t_lam@qlc.com) + * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com) + * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com) + * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com) + * + ******************************************************************************* + * + * Changes: + * 03/09/2000 Initial Draft + * (for other changes... see the CVS logs) + ******************************************************************************* + */ + +/* + * Copyright 2020 RackTop Systems, Inc. + */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef HBA_API_H +#define HBA_API_H + +/* Library version string */ +#define HBA_LIBVERSION 2 + +/* DLL imports for WIN32 operation */ +#ifdef WIN32 +#ifdef HBAAPI_EXPORTS +#define HBA_API __declspec(dllexport) +#else +#define HBA_API __declspec(dllimport) +#endif +#else +#define HBA_API +#endif + +/* OS specific definitions */ + +#ifdef WIN32 +typedef unsigned char HBA_UINT8; // Unsigned 8 bits +typedef char HBA_INT8; // Signed 8 bits +typedef unsigned short HBA_UINT16; // Unsigned 16 bits +typedef short HBA_INT16; // Signed 16 bits +typedef unsigned int HBA_UINT32; // Unsigned 32 bits +typedef int HBA_INT32; // Signed 32 bits +typedef void* HBA_PVOID; // Pointer to void +typedef HBA_UINT32 HBA_VOID32; // Opaque 32 bits + + +/* Don't confuse, _WIN32 with WIN32... OK, how do you accompish that */ +#ifdef _WIN32 +typedef _int64 HBA_INT64; +typedef unsigned _int64 HBA_UINT64; +#else +typedef struct { + TN_UINT32 lo_val; + TN_UINT32 hi_val; +} HBA_INT64; + +typedef struct { + TN_UINT32 lo_val; + TN_UINT32 hi_val; +} HBA_UINT64; +#endif /* #ifdef _WIN32 */ + + +#else +#include /* Needed for struct tm */ + +/* Note this section needs to be cleaned up for various Unix platforms */ +typedef unsigned char HBA_UINT8; /* Unsigned 8 bits */ +typedef char HBA_INT8; /* Signed 8 bits */ +typedef unsigned short HBA_UINT16; /* Unsigned 16 bits */ +typedef short HBA_INT16; /* Signed 16 bits */ +typedef unsigned int HBA_UINT32; /* Unsigned 32 bits */ +typedef int HBA_INT32; /* Signed 32 bits */ +typedef void* HBA_PVOID; /* Pointer to void */ +typedef HBA_UINT32 HBA_VOID32; /* Opaque 32 bits */ +typedef long long HBA_INT64; +typedef long long HBA_UINT64; + +#endif /* #ifdef WIN32 */ + + +/* 4.2.1 Handle to Device */ +typedef HBA_UINT32 HBA_HANDLE; + +#define HBA_HANDLE_INVALID 0 + +/* 4.2.2 Status Return Values */ +typedef HBA_UINT32 HBA_STATUS; + +#define HBA_STATUS_OK 0 +#define HBA_STATUS_ERROR 1 /* Error */ +#define HBA_STATUS_ERROR_NOT_SUPPORTED 2 /* Function not supported.*/ +#define HBA_STATUS_ERROR_INVALID_HANDLE 3 /* invalid handle */ +#define HBA_STATUS_ERROR_ARG 4 /* Bad argument */ +#define HBA_STATUS_ERROR_ILLEGAL_WWN 5 /* WWN not recognized */ +#define HBA_STATUS_ERROR_ILLEGAL_INDEX 6 /* Index not recognized */ +#define HBA_STATUS_ERROR_MORE_DATA 7 /* Larger buffer required */ +#define HBA_STATUS_ERROR_STALE_DATA 8 /* Information has changed since + * last call to + * HBA_Refreshinformation */ +#define HBA_STATUS_SCSI_CHECK_CONDITION 9 /* Obvious */ +#define HBA_STATUS_ERROR_BUSY 10 /* Adapter busy or reserved, + * retry may be effective */ +#define HBA_STATUS_ERROR_TRY_AGAIN 11 /* Request timedout, + * retry may be effective */ +#define HBA_STATUS_ERROR_UNAVAILABLE 12 /* Referenced HBA has been removed + * or deactivated */ +#define HBA_STATUS_ERROR_ELS_REJECT 13 /* The requested ELS was rejected by + * the local adapter */ +#define HBA_STATUS_ERROR_INVALID_LUN 14 /* The specified LUN is not provided + * the specified adapter */ +#define HBA_STATUS_ERROR_INCOMPATIBLE 15 /* An incompatibility has been + * detected among the library and driver modules + * invoked which will cause one or more functions + * in the highest version that all support to + * operate incorrectly. The differing function + * sets of software modules implementing different + * versions of the HBA API specification does not + * in itself constitute an incompatibility. Known + * interoperability bugs among supposedly + * compatible versions should be reported as + * incompatibilities, but not all such + * interoperability bugs may be known. This value + * may be returned by any function that calls a + * Vendor Specific Library and returns an + * HBA_STATUS, and by HBA_LoadLibrary and + * HBA_GetAdapterName. */ + +#define HBA_STATUS_ERROR_AMBIGUOUS_WWN 16 /* Multiple adapters have a matching + * WWN. This could occur if the + * NodeWWN of multiple adapters is + * identical */ +#define HBA_STATUS_ERROR_LOCAL_BUS 17 /* A persistent binding request + * included a bad local SCSI bus + * number */ +#define HBA_STATUS_ERROR_LOCAL_TARGET 18 /* A persistent binding request + * included a bad local SCSI target + * number */ +#define HBA_STATUS_ERROR_LOCAL_LUN 19 /* A persistent binding request + * included a bad local SCSI logical + * unit number */ +#define HBA_STATUS_ERROR_LOCAL_SCSIID_BOUND 20 + /* A persistent binding set request + * included a local SCSI ID that was + * already bound */ +#define HBA_STATUS_ERROR_TARGET_FCID 21 /* A persistent binding request + * included a bad or unlocatable FCP + * Target FCID */ +#define HBA_STATUS_ERROR_TARGET_NODE_WWN 22 /* A persistent binding request + * included a bad FCP Target Node + * WWN */ +#define HBA_STATUS_ERROR_TARGET_PORT_WWN 23 /* A persistent binding request + * included a bad FCP Target Port + * WWN */ +#define HBA_STATUS_ERROR_TARGET_LUN 24 /* A persistent binding request + * included an FCP Logical Unit Number + * not defined by the identified + * Target*/ +#define HBA_STATUS_ERROR_TARGET_LUID 25 /* A persistent binding request + * included an undefined or otherwise + * inaccessible Logical Unit Unique + * Identifier */ +#define HBA_STATUS_ERROR_NO_SUCH_BINDING 26 /* A persistent binding remove request + * included a binding which did not + * match a binding established by the + * specified port */ +#define HBA_STATUS_ERROR_NOT_A_TARGET 27 /* A SCSI command was requested to an + * Nx_Port that was not a SCSI + * Target Port */ +#define HBA_STATUS_ERROR_UNSUPPORTED_FC4 28 /* A request was made concerning an + * unsupported FC-4 protocol */ + + +#define HBA_STATUS_ERROR_INCAPABLE 29 /* A request was made to enable + * unimplemented capabilities for a + * port */ + +/* 4.2.3 Port Operational Modes Values */ +typedef HBA_UINT32 HBA_PORTTYPE; + +#define HBA_PORTTYPE_UNKNOWN 1 /* Unknown */ +#define HBA_PORTTYPE_OTHER 2 /* Other */ +#define HBA_PORTTYPE_NOTPRESENT 3 /* Not present */ +#define HBA_PORTTYPE_NPORT 5 /* Fabric */ +#define HBA_PORTTYPE_NLPORT 6 /* Public Loop */ +#define HBA_PORTTYPE_FLPORT 7 +#define HBA_PORTTYPE_FPORT 8 /* Fabric Port */ +#define HBA_PORTTYPE_EPORT 9 /* Fabric expansion port */ +#define HBA_PORTTYPE_GPORT 10 /* Generic Fabric Port */ +#define HBA_PORTTYPE_LPORT 20 /* Private Loop */ +#define HBA_PORTTYPE_PTP 21 /* Point to Point */ + + +typedef HBA_UINT32 HBA_PORTSTATE; +#define HBA_PORTSTATE_UNKNOWN 1 /* Unknown */ +#define HBA_PORTSTATE_ONLINE 2 /* Operational */ +#define HBA_PORTSTATE_OFFLINE 3 /* User Offline */ +#define HBA_PORTSTATE_BYPASSED 4 /* Bypassed */ +#define HBA_PORTSTATE_DIAGNOSTICS 5 /* In diagnostics mode */ +#define HBA_PORTSTATE_LINKDOWN 6 /* Link Down */ +#define HBA_PORTSTATE_ERROR 7 /* Port Error */ +#define HBA_PORTSTATE_LOOPBACK 8 /* Loopback */ + + +typedef HBA_UINT32 HBA_PORTSPEED; +#define HBA_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver incable + * of reporting */ +#define HBA_PORTSPEED_1GBIT 1 /* 1 GBit/sec */ +#define HBA_PORTSPEED_2GBIT 2 /* 2 GBit/sec */ +#define HBA_PORTSPEED_10GBIT 4 /* 10 GBit/sec */ +#define HBA_PORTSPEED_4GBIT 8 /* 4 GBit/sec */ +#define HBA_PORTSPEED_8GBIT 16 /* 8 GBit/sec */ +#define HBA_PORTSPEED_16GBIT 32 /* 16 GBit/sec */ +#define HBA_PORTSPEED_32GBIT 64 /* 32 GBit/sec */ +#define HBA_PORTSPEED_NOT_NEGOTIATED (1<<15) /* Speed not established */ + + + +/* 4.2.4 Class of Service Values - See GS-2 Spec.*/ + +typedef HBA_UINT32 HBA_COS; + + +/* 4.2.5 Fc4Types Values */ + +typedef struct HBA_fc4types { + HBA_UINT8 bits[32]; /* 32 bytes of FC-4 per GS-2 */ +} HBA_FC4TYPES, *PHBA_FC4TYPES; + +/* 4.2.6 Basic Types */ + +typedef struct HBA_wwn { + HBA_UINT8 wwn[8]; +} HBA_WWN, *PHBA_WWN; + +typedef struct HBA_ipaddress { + int ipversion; /* see enumerations in RNID */ + union + { + unsigned char ipv4address[4]; + unsigned char ipv6address[16]; + } ipaddress; +} HBA_IPADDRESS, *PHBA_IPADDRESS; + +typedef HBA_INT8 HBA_BOOLEAN; + +/* 4.2.7 Adapter Attributes */ +typedef struct hba_AdapterAttributes { + char Manufacturer[64]; /*Emulex */ + char SerialNumber[64]; /* A12345 */ + char Model[256]; /* QLA2200 */ + char ModelDescription[256]; /* Agilent TachLite */ + HBA_WWN NodeWWN; + char NodeSymbolicName[256]; /* From GS-3 */ + char HardwareVersion[256]; /* Vendor use */ + char DriverVersion[256]; /* Vendor use */ + char OptionROMVersion[256]; /* Vendor use - i.e. hardware boot ROM*/ + char FirmwareVersion[256]; /* Vendor use */ + HBA_UINT32 VendorSpecificID; /* Vendor specific */ + HBA_UINT32 NumberOfPorts; + char DriverName[256]; /* Binary path and/or name of driver + *file */ +} HBA_ADAPTERATTRIBUTES, *PHBA_ADAPTERATTRIBUTES; + +/* 4.2.8 Port Attributes */ +typedef struct HBA_PortAttributes { + HBA_WWN NodeWWN; + HBA_WWN PortWWN; + HBA_UINT32 PortFcId; + HBA_PORTTYPE PortType; /*PTP, Fabric, etc. */ + HBA_PORTSTATE PortState; + HBA_COS PortSupportedClassofService; + HBA_FC4TYPES PortSupportedFc4Types; + HBA_FC4TYPES PortActiveFc4Types; + char PortSymbolicName[256]; + char OSDeviceName[256]; /* \device\ScsiPort3 */ + HBA_PORTSPEED PortSupportedSpeed; + HBA_PORTSPEED PortSpeed; + HBA_UINT32 PortMaxFrameSize; + HBA_WWN FabricName; + HBA_UINT32 NumberofDiscoveredPorts; +} HBA_PORTATTRIBUTES, *PHBA_PORTATTRIBUTES; + + + +/* 4.2.9 Port Statistics */ + +typedef struct HBA_PortStatistics { + HBA_INT64 SecondsSinceLastReset; + HBA_INT64 TxFrames; + HBA_INT64 TxWords; + HBA_INT64 RxFrames; + HBA_INT64 RxWords; + HBA_INT64 LIPCount; + HBA_INT64 NOSCount; + HBA_INT64 ErrorFrames; + HBA_INT64 DumpedFrames; + HBA_INT64 LinkFailureCount; + HBA_INT64 LossOfSyncCount; + HBA_INT64 LossOfSignalCount; + HBA_INT64 PrimitiveSeqProtocolErrCount; + HBA_INT64 InvalidTxWordCount; + HBA_INT64 InvalidCRCCount; +} HBA_PORTSTATISTICS, *PHBA_PORTSTATISTICS; + + + +/* 4.2.10 FCP Attributes */ + +typedef enum HBA_fcpbindingtype { TO_D_ID, TO_WWN, TO_OTHER } HBA_FCPBINDINGTYPE; + +typedef struct HBA_ScsiId { + char OSDeviceName[256]; /* \device\ScsiPort3 */ + HBA_UINT32 ScsiBusNumber; /* Bus on the HBA */ + HBA_UINT32 ScsiTargetNumber; /* SCSI Target ID to OS */ + HBA_UINT32 ScsiOSLun; +} HBA_SCSIID, *PHBA_SCSIID; + +typedef struct HBA_FcpId { + HBA_UINT32 FcId; + HBA_WWN NodeWWN; + HBA_WWN PortWWN; + HBA_UINT64 FcpLun; +} HBA_FCPID, *PHBA_FCPID; + +typedef struct HBA_LUID { + char buffer[256]; /* Unique Device Identifier */ +} HBA_LUID, *PHBA_LUID; + +typedef struct HBA_FcpScsiEntry { + HBA_SCSIID ScsiId; + HBA_FCPID FcpId; +} HBA_FCPSCSIENTRY, *PHBA_FCPSCSIENTRY; + +typedef struct HBA_FcpScsiEntryV2 { + HBA_SCSIID ScsiId; + HBA_FCPID FcpId; + HBA_LUID LUID; +} HBA_FCPSCSIENTRYV2, *PHBA_FCPSCSIENTRYV2; + +typedef struct HBA_FCPTargetMapping { + HBA_UINT32 NumberOfEntries; + HBA_FCPSCSIENTRY entry[1]; /* Variable length array + * containing mappings */ +} HBA_FCPTARGETMAPPING, *PHBA_FCPTARGETMAPPING; + +typedef struct HBA_FCPTargetMappingV2 { + HBA_UINT32 NumberOfEntries; + HBA_FCPSCSIENTRYV2 entry[1]; /* Variable length array + * containing mappings */ +} HBA_FCPTARGETMAPPINGV2, *PHBA_FCPTARGETMAPPINGV2; + +typedef struct HBA_FCPBindingEntry { + HBA_FCPBINDINGTYPE type; + HBA_SCSIID ScsiId; + HBA_FCPID FcpId; /* WWN valid only if type is + * to WWN, FcpLun always valid */ + HBA_UINT32 FcId; +} HBA_FCPBINDINGENTRY, *PHBA_FCPBINDINGENTRY; + +typedef struct HBA_FCPBinding { + HBA_UINT32 NumberOfEntries; + HBA_FCPBINDINGENTRY entry[1]; /* Variable length array */ +} HBA_FCPBINDING, *PHBA_FCPBINDING; + +/* 4.2.11 FC-3 Management Atrributes */ + +typedef enum HBA_wwntype { NODE_WWN, PORT_WWN } HBA_WWNTYPE; + +typedef struct HBA_MgmtInfo { + HBA_WWN wwn; + HBA_UINT32 unittype; + HBA_UINT32 PortId; + HBA_UINT32 NumberOfAttachedNodes; + HBA_UINT16 IPVersion; + HBA_UINT16 UDPPort; + HBA_UINT8 IPAddress[16]; + HBA_UINT16 reserved; + HBA_UINT16 TopologyDiscoveryFlags; +} HBA_MGMTINFO, *PHBA_MGMTINFO; + +/* Event Codes */ +#define HBA_EVENT_LIP_OCCURRED 1 +#define HBA_EVENT_LINK_UP 2 +#define HBA_EVENT_LINK_DOWN 3 +#define HBA_EVENT_LIP_RESET_OCCURRED 4 +#define HBA_EVENT_RSCN 5 +#define HBA_EVENT_PROPRIETARY 0xFFFF + +typedef struct HBA_Link_EventInfo { + HBA_UINT32 PortFcId; /* Port where event occurred */ + HBA_UINT32 Reserved[3]; +} HBA_LINK_EVENTINFO, *PHBA_LINK_EVENTINFO; + +typedef struct HBA_RSCN_EventInfo { + HBA_UINT32 PortFcId; /* Port where event occurred */ + HBA_UINT32 NPortPage; /* Reference FC-FS for RSCN ELS + * "Affected N-Port Pages"*/ + HBA_UINT32 Reserved[2]; +} HBA_RSCN_EVENTINFO, *PHBA_RSCN_EVENTINFO; + +typedef struct HBA_Pty_EventInfo { + HBA_UINT32 PtyData[4]; /* Proprietary data */ +} HBA_PTY_EVENTINFO, *PHBA_PTY_EVENTINFO; + +typedef struct HBA_EventInfo { + HBA_UINT32 EventCode; + union { + HBA_LINK_EVENTINFO Link_EventInfo; + HBA_RSCN_EVENTINFO RSCN_EventInfo; + HBA_PTY_EVENTINFO Pty_EventInfo; + } Event; +} HBA_EVENTINFO, *PHBA_EVENTINFO; + +typedef struct HBA_LibraryAttributes { + HBA_BOOLEAN final; + char LibPath[256]; + char VName[256]; + char VVersion[256]; + struct tm build_date; +} HBA_LIBRARYATTRIBUTES, *PHBA_LIBRARYATTRIBUTES; + +/* Persistant Binding... */ +typedef HBA_UINT32 HBA_BIND_TYPE; +#define HBA_BIND_TO_D_ID 0x0001 +#define HBA_BIND_TO_WWPN 0x0002 +#define HBA_BIND_TO_WWNN 0x0004 +#define HBA_BIND_TO_LUID 0x0008 +#define HBA_BIND_TARGETS 0x0800 + +/* A bit mask of Rev 2.0 persistent binding capabilities */ +typedef HBA_UINT32 HBA_BIND_CAPABILITY; +/* The following are bit flags indicating persistent binding capabilities */ +#define HBA_CAN_BIND_TO_D_ID 0x0001 +#define HBA_CAN_BIND_TO_WWPN 0x0002 +#define HBA_CAN_BIND_TO_WWNN 0x0004 +#define HBA_CAN_BIND_TO_LUID 0x0008 +#define HBA_CAN_BIND_ANY_LUNS 0x0400 +#define HBA_CAN_BIND_TARGETS 0x0800 +#define HBA_CAN_BIND_AUTOMAP 0x1000 +#define HBA_CAN_BIND_CONFIGURED 0x2000 + +#define HBA_BIND_STATUS_DISABLED 0x00 +#define HBA_BIND_STATUS_ENABLED 0x01 + +typedef HBA_UINT32 HBA_BIND_STATUS; + +#define HBA_BIND_EFFECTIVE_AT_REBOOT 0x00 +#define HBA_BIND_EFFECTIVE_IMMEDIATE 0x01 + +typedef HBA_UINT32 HBA_BIND_EFFECTIVE; + +typedef struct HBA_FCPBindingEntry2 { + HBA_BIND_TYPE type; + HBA_SCSIID ScsiId; + HBA_FCPID FcpId; + HBA_LUID LUID; + HBA_STATUS status; +} HBA_FCPBINDINGENTRY2, *PHBA_FCPBINDINGENTRY2; + +typedef struct HBA_FcpBinding2 { + HBA_UINT32 NumberOfEntries; + HBA_FCPBINDINGENTRY2 + entry[1]; /* Variable length array */ +} HBA_FCPBINDING2, *PHBA_FCPBINDING2; + +/* FC-4 Instrumentation */ +typedef struct HBA_FC4Statistics { + HBA_INT64 InputRequests; + HBA_INT64 OutputRequests; + HBA_INT64 ControlRequests; + HBA_INT64 InputMegabytes; + HBA_INT64 OutputMegabytes; +} HBA_FC4STATISTICS, *PHBA_FC4STATISTICS; + + +typedef void * HBA_CALLBACKHANDLE; +/* Adapter Level Events */ +#define HBA_EVENT_ADAPTER_UNKNOWN 0x100 +#define HBA_EVENT_ADAPTER_ADD 0x101 +#define HBA_EVENT_ADAPTER_REMOVE 0x102 +#define HBA_EVENT_ADAPTER_CHANGE 0x103 + +/* Port Level Events */ +#define HBA_EVENT_PORT_UNKNOWN 0x200 +#define HBA_EVENT_PORT_OFFLINE 0x201 +#define HBA_EVENT_PORT_ONLINE 0x202 +#define HBA_EVENT_PORT_NEW_TARGETS 0x203 +#define HBA_EVENT_PORT_FABRIC 0x204 + +/* Port Statistics Events */ +#define HBA_EVENT_PORT_STAT_THRESHOLD 0x301 +#define HBA_EVENT_PORT_STAT_GROWTH 0x302 + +/* Target Level Events */ +#define HBA_EVENT_TARGET_UNKNOWN 0x400 +#define HBA_EVENT_TARGET_OFFLINE 0x401 +#define HBA_EVENT_TARGET_ONLINE 0x402 +#define HBA_EVENT_TARGET_REMOVED 0x403 + +/* Fabric Link Events */ +#define HBA_EVENT_LINK_UNKNOWN 0x500 +#define HBA_EVENT_LINK_INCIDENT 0x501 + +HBA_API HBA_UINT32 HBA_GetVersion(); + +/* + * Make sure HBA_LoadLibrary returns before any other threads + * make calls to the library + */ +HBA_API HBA_STATUS HBA_LoadLibrary(void); + +HBA_API HBA_STATUS HBA_FreeLibrary(void); + +HBA_API HBA_UINT32 HBA_GetNumberOfAdapters(void); + +HBA_API HBA_STATUS HBA_GetAdapterName( + HBA_UINT32 adapterindex, + char *adaptername + ); + +HBA_API HBA_HANDLE HBA_OpenAdapter( + char* adaptername + ); + +HBA_API HBA_STATUS HBA_OpenAdapterByWWN( + HBA_HANDLE *handle, + HBA_WWN wwn + ); + +HBA_API void HBA_CloseAdapter( + HBA_HANDLE handle + ); + +HBA_API HBA_STATUS HBA_GetAdapterAttributes( + HBA_HANDLE handle, + HBA_ADAPTERATTRIBUTES + *hbaattributes + ); + +HBA_API HBA_STATUS HBA_GetAdapterPortAttributes( + HBA_HANDLE handle, + HBA_UINT32 portindex, + HBA_PORTATTRIBUTES *portattributes + ); + +HBA_API HBA_STATUS HBA_GetPortStatistics( + HBA_HANDLE handle, + HBA_UINT32 portindex, + HBA_PORTSTATISTICS *portstatistics + ); + +HBA_API HBA_STATUS HBA_GetDiscoveredPortAttributes( + HBA_HANDLE handle, + HBA_UINT32 portindex, + HBA_UINT32 discoveredportindex, + HBA_PORTATTRIBUTES *portattributes + ); + +HBA_API HBA_STATUS HBA_GetPortAttributesByWWN( + HBA_HANDLE handle, + HBA_WWN PortWWN, + HBA_PORTATTRIBUTES *portattributes + ); + +HBA_API HBA_STATUS HBA_SendCTPassThruV2( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + void *pReqBuffer, + HBA_UINT32 ReqBufferSize, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize + ); + +/* Depricated, but supported */ +HBA_API HBA_STATUS HBA_SendCTPassThru( + HBA_HANDLE handle, + void *pReqBuffer, + HBA_UINT32 ReqBufferSize, + void *pRspBuffer, + HBA_UINT32 RspBufferSize + ); + +HBA_API void HBA_RefreshAdapterConfiguration(); + +HBA_API HBA_STATUS HBA_GetEventBuffer( + HBA_HANDLE handle, + HBA_EVENTINFO *EventBuffer, + HBA_UINT32 *EventBufferCount + ); + +HBA_API HBA_STATUS HBA_SetRNIDMgmtInfo( + HBA_HANDLE handle, + HBA_MGMTINFO Info + ); + +HBA_API HBA_STATUS HBA_GetRNIDMgmtInfo( + HBA_HANDLE handle, + HBA_MGMTINFO *pInfo + ); + +HBA_API HBA_STATUS HBA_SendRNIDV2( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN destWWN, + HBA_UINT32 destFCID, + HBA_UINT32 NodeIdDataFormat, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize + ); + +/* Depricated, but supported */ +HBA_API HBA_STATUS HBA_SendRNID( + HBA_HANDLE handle, + HBA_WWN wwn, + HBA_WWNTYPE wwntype, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize + ); + +HBA_API HBA_STATUS HBA_SendRLS ( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN destWWN, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize + ); + +HBA_API HBA_STATUS HBA_SendRPL ( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN agent_wwn, + HBA_UINT32 agent_domain, + HBA_UINT32 portindex, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize + ); + +HBA_API HBA_STATUS HBA_SendRPS ( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN agent_wwn, + HBA_UINT32 agent_domain, + HBA_WWN object_wwn, + HBA_UINT32 object_port_number, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize + ); + +HBA_API HBA_STATUS HBA_SendSRL ( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN wwn, + HBA_UINT32 domain, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize + ); + +HBA_API HBA_STATUS HBA_SendLIRR ( + HBA_HANDLE handle, + HBA_WWN sourceWWN, + HBA_WWN destWWN, + HBA_UINT8 function, + HBA_UINT8 type, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize + ); + + +HBA_API HBA_STATUS HBA_GetFC4Statistics ( + HBA_HANDLE handle, + HBA_WWN portWWN, + HBA_UINT8 FC4type, + HBA_FC4STATISTICS *pstatistics + ); + +HBA_API HBA_STATUS HBA_GetFCPStatistics ( + HBA_HANDLE handle, + const HBA_SCSIID *lunit, + HBA_FC4STATISTICS *pstatistics); + +HBA_API void HBA_RefreshInformation( + HBA_HANDLE handle + ); + +HBA_API void HBA_ResetStatistics( + HBA_HANDLE handle, + HBA_UINT32 portindex + ); + +HBA_API HBA_STATUS HBA_GetFcpTargetMapping( + HBA_HANDLE handle, + HBA_FCPTARGETMAPPING + *pmapping + ); + +HBA_API HBA_STATUS HBA_GetFcpTargetMappingV2( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_FCPTARGETMAPPINGV2 + *pmapping + ); + +HBA_API HBA_STATUS HBA_GetBindingCapability( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_BIND_CAPABILITY *pcapability + ); + +HBA_API HBA_STATUS HBA_GetBindingSupport( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_BIND_CAPABILITY *pcapability + ); + +HBA_API HBA_STATUS HBA_SetBindingSupport( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_BIND_CAPABILITY capability + ); + +HBA_API HBA_STATUS HBA_SetPersistentBindingV2( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + const HBA_FCPBINDING2 + *pbinding + ); + +HBA_API HBA_STATUS HBA_GetPersistentBindingV2( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_FCPBINDING2 *binding + ); + +HBA_API HBA_STATUS HBA_RemovePersistentBinding( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + const HBA_FCPBINDING2 + *pbinding + ); + +/* Depricated, but supported */ +HBA_API HBA_STATUS HBA_GetFcpPersistentBinding( + HBA_HANDLE handle, + HBA_FCPBINDING *binding + ); + +HBA_API HBA_STATUS HBA_RemoveAllPersistentBindings( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN + ); + +HBA_STATUS HBA_ScsiInquiryV2 ( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN discoveredPortWWN, + HBA_UINT64 fcLUN, + HBA_UINT8 CDB_Byte1, + HBA_UINT8 CDB_BYte2, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize, + HBA_UINT8 *pScsiStatus, + void *pSenseBuffer, + HBA_UINT32 *pSenseBufferSize + ); + +/* Depricated, but supported */ +HBA_API HBA_STATUS HBA_SendScsiInquiry ( + HBA_HANDLE handle, + HBA_WWN PortWWN, + HBA_UINT64 fcLUN, + HBA_UINT8 EVPD, + HBA_UINT32 PageCode, + void *pRspBuffer, + HBA_UINT32 RspBufferSize, + void *pSenseBuffer, + HBA_UINT32 SenseBufferSize + ); + +HBA_API HBA_STATUS HBA_ScsiReportLUNsV2( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN discoveredPortWWN, + void *pRespBuffer, + HBA_UINT32 *pRespBufferSize, + HBA_UINT8 *pScsiStatus, + void *pSenseBuffer, + HBA_UINT32 *pSenseBufferSize + ); + +/* Depricated, but supported */ +HBA_API HBA_STATUS HBA_SendReportLUNs ( + HBA_HANDLE handle, + HBA_WWN portWWN, + void *pRspBuffer, + HBA_UINT32 RspBufferSize, + void *pSenseBuffer, + HBA_UINT32 SenseBufferSize + ); + +HBA_API HBA_STATUS HBA_ScsiReadCapacityV2( + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN discoveredPortWWN, + HBA_UINT64 fcLUN, + void *pRspBuffer, + HBA_UINT32 *pRspBufferSize, + HBA_UINT8 *pScsiStatus, + void *pSenseBuffer, + HBA_UINT32 *SenseBufferSize + ); + +/* Depricated, but supported */ +HBA_API HBA_STATUS HBA_SendReadCapacity ( + HBA_HANDLE handle, + HBA_WWN portWWN, + HBA_UINT64 fcLUN, + void *pRspBuffer, + HBA_UINT32 RspBufferSize, + void *pSenseBuffer, + HBA_UINT32 SenseBufferSize + ); + +HBA_API HBA_UINT32 HBA_GetVendorLibraryAttributes ( + HBA_UINT32 adapter_index, + HBA_LIBRARYATTRIBUTES + *attributes + ); + +HBA_API HBA_STATUS HBA_RemoveCallback( + HBA_CALLBACKHANDLE callbackHandle + ); + +HBA_API HBA_STATUS HBA_RegisterForAdapterAddEvents( + void (*callback) ( + void *data, + HBA_WWN PortWWN, + HBA_UINT32 eventType + ), + void *userData, + HBA_CALLBACKHANDLE *callbackHandle + ); + +HBA_API HBA_STATUS HBA_RegisterForAdapterEvents( + void (*callback)( + void *data, + HBA_WWN PortWWN, + HBA_UINT32 eventType + ), + void *userData, + HBA_HANDLE handle, + HBA_CALLBACKHANDLE *callbackHandle + ); + +HBA_API HBA_STATUS HBA_RegisterForAdapterPortEvents( + void (*callback)( + void *data, + HBA_WWN PortWWN, + HBA_UINT32 eventType, + HBA_UINT32 fabricPortID + ), + void *userData, + HBA_HANDLE handle, + HBA_WWN PortWWN, + HBA_CALLBACKHANDLE *callbackHandle + ); + +HBA_API HBA_STATUS HBA_RegisterForAdapterPortStatEvents( + void (*callback)( + void *data, + HBA_WWN PortWWN, + HBA_UINT32 eventType + ), + void *userData, + HBA_HANDLE handle, + HBA_WWN PortWWN, + HBA_PORTSTATISTICS stats, + HBA_UINT32 statType, + HBA_CALLBACKHANDLE *callbackHandle + ); + + +HBA_API HBA_STATUS HBA_RegisterForTargetEvents( + void (*callback)( + void *data, + HBA_WWN hbaPortWWN, + HBA_WWN discoveredPortWWN, + HBA_UINT32 eventType + ), + void *userData, + HBA_HANDLE handle, + HBA_WWN hbaPortWWN, + HBA_WWN discoveredPortWWN, + HBA_CALLBACKHANDLE *callbackHandle, + HBA_UINT32 allTargets + ); + +HBA_API HBA_STATUS HBA_RegisterForLinkEvents( + void (*callback) + ( + void *data, + HBA_WWN adapterWWN, + HBA_UINT32 eventType, + void *pRLIRBuffer, + HBA_UINT32 RLIRBufferSize + ), + void *userData, + void *pRLIRBuffer, + HBA_UINT32 RLIRBufferSize, + HBA_HANDLE handle, + HBA_CALLBACKHANDLE *callbackHandle +); + +/* Wrapper library specific entry points */ + +HBA_API HBA_UINT32 HBA_GetWrapperLibraryAttributes ( + HBA_LIBRARYATTRIBUTES + *attributes +); + +#endif /* HBA_API_H */ + +#ifdef __cplusplus +} +#endif + + diff --git a/illumos-x86_64/usr/include/histedit.h b/illumos-x86_64/usr/include/histedit.h new file mode 100644 index 00000000..65112382 --- /dev/null +++ b/illumos-x86_64/usr/include/histedit.h @@ -0,0 +1,322 @@ +/* $NetBSD: histedit.h,v 1.62 2023/02/03 22:01:42 christos Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)histedit.h 8.2 (Berkeley) 1/3/94 + */ + +/* + * histedit.h: Line editor and history interface. + */ +#ifndef _HISTEDIT_H_ +#define _HISTEDIT_H_ + +#define LIBEDIT_MAJOR 2 +#define LIBEDIT_MINOR 11 + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ==== Editing ==== + */ + +typedef struct editline EditLine; + +/* + * For user-defined function interface + */ +typedef struct lineinfo { + const char *buffer; + const char *cursor; + const char *lastchar; +} LineInfo; + +/* + * EditLine editor function return codes. + * For user-defined function interface + */ +#define CC_NORM 0 +#define CC_NEWLINE 1 +#define CC_EOF 2 +#define CC_ARGHACK 3 +#define CC_REFRESH 4 +#define CC_CURSOR 5 +#define CC_ERROR 6 +#define CC_FATAL 7 +#define CC_REDISPLAY 8 +#define CC_REFRESH_BEEP 9 + +/* + * Initialization, cleanup, and resetting + */ +EditLine *el_init(const char *, FILE *, FILE *, FILE *); +EditLine *el_init_fd(const char *, FILE *, FILE *, FILE *, + int, int, int); +void el_end(EditLine *); +void el_reset(EditLine *); + +/* + * Get a line, a character or push a string back in the input queue + */ +const char *el_gets(EditLine *, int *); +int el_getc(EditLine *, char *); +void el_push(EditLine *, const char *); + +/* + * Beep! + */ +void el_beep(EditLine *); + +/* + * High level function internals control + * Parses argc, argv array and executes builtin editline commands + */ +int el_parse(EditLine *, int, const char **); + +/* + * Low level editline access functions + */ +int el_set(EditLine *, int, ...); +int el_get(EditLine *, int, ...); +unsigned char _el_fn_complete(EditLine *, int); +unsigned char _el_fn_sh_complete(EditLine *, int); + +/* + * el_set/el_get parameters + * + * When using el_wset/el_wget (as opposed to el_set/el_get): + * Char is wchar_t, otherwise it is char. + * prompt_func is el_wpfunc_t, otherwise it is el_pfunc_t . + + * Prompt function prototypes are: + * typedef char *(*el_pfunct_t) (EditLine *); + * typedef wchar_t *(*el_wpfunct_t) (EditLine *); + * + * For operations that support set or set/get, the argument types listed are for + * the "set" operation. For "get", each listed type must be a pointer. + * E.g. EL_EDITMODE takes an int when set, but an int* when get. + * + * Operations that only support "get" have the correct argument types listed. + */ +#define EL_PROMPT 0 /* , prompt_func); set/get */ +#define EL_TERMINAL 1 /* , const char *); set/get */ +#define EL_EDITOR 2 /* , const Char *); set/get */ +#define EL_SIGNAL 3 /* , int); set/get */ +#define EL_BIND 4 /* , const Char *, ..., NULL); set */ +#define EL_TELLTC 5 /* , const Char *, ..., NULL); set */ +#define EL_SETTC 6 /* , const Char *, ..., NULL); set */ +#define EL_ECHOTC 7 /* , const Char *, ..., NULL); set */ +#define EL_SETTY 8 /* , const Char *, ..., NULL); set */ +#define EL_ADDFN 9 /* , const Char *, const Char, set */ + /* el_func_t); */ +#define EL_HIST 10 /* , hist_fun_t, const void *); set */ +#define EL_EDITMODE 11 /* , int); set/get */ +#define EL_RPROMPT 12 /* , prompt_func); set/get */ +#define EL_GETCFN 13 /* , el_rfunc_t); set/get */ +#define EL_CLIENTDATA 14 /* , void *); set/get */ +#define EL_UNBUFFERED 15 /* , int); set/get */ +#define EL_PREP_TERM 16 /* , int); set */ +#define EL_GETTC 17 /* , const Char *, ..., NULL); get */ +#define EL_GETFP 18 /* , int, FILE **); get */ +#define EL_SETFP 19 /* , int, FILE *); set */ +#define EL_REFRESH 20 /* , void); set */ +#define EL_PROMPT_ESC 21 /* , prompt_func, Char); set/get */ +#define EL_RPROMPT_ESC 22 /* , prompt_func, Char); set/get */ +#define EL_RESIZE 23 /* , el_zfunc_t, void *); set */ +#define EL_ALIAS_TEXT 24 /* , el_afunc_t, void *); set */ +#define EL_SAFEREAD 25 /* , int); set/get */ + +#define EL_BUILTIN_GETCFN (NULL) + +/* + * Source named file or $PWD/.editrc or $HOME/.editrc + */ +int el_source(EditLine *, const char *); + +/* + * Must be called when the terminal changes size; If EL_SIGNAL + * is set this is done automatically otherwise it is the responsibility + * of the application + */ +void el_resize(EditLine *); + +/* + * User-defined function interface. + */ +const LineInfo *el_line(EditLine *); +int el_insertstr(EditLine *, const char *); +void el_deletestr(EditLine *, int); +int el_replacestr(EditLine *, const char *); +int el_deletestr1(EditLine *, int, int); + +/* + * ==== History ==== + */ + +typedef struct history History; + +typedef struct HistEvent { + int num; + const char *str; +} HistEvent; + +/* + * History access functions. + */ +History * history_init(void); +void history_end(History *); + +int history(History *, HistEvent *, int, ...); + +#define H_FUNC 0 /* , UTSL */ +#define H_SETSIZE 1 /* , const int); */ +#define H_GETSIZE 2 /* , void); */ +#define H_FIRST 3 /* , void); */ +#define H_LAST 4 /* , void); */ +#define H_PREV 5 /* , void); */ +#define H_NEXT 6 /* , void); */ +#define H_CURR 8 /* , const int); */ +#define H_SET 7 /* , int); */ +#define H_ADD 9 /* , const wchar_t *); */ +#define H_ENTER 10 /* , const wchar_t *); */ +#define H_APPEND 11 /* , const wchar_t *); */ +#define H_END 12 /* , void); */ +#define H_NEXT_STR 13 /* , const wchar_t *); */ +#define H_PREV_STR 14 /* , const wchar_t *); */ +#define H_NEXT_EVENT 15 /* , const int); */ +#define H_PREV_EVENT 16 /* , const int); */ +#define H_LOAD 17 /* , const char *); */ +#define H_SAVE 18 /* , const char *); */ +#define H_CLEAR 19 /* , void); */ +#define H_SETUNIQUE 20 /* , int); */ +#define H_GETUNIQUE 21 /* , void); */ +#define H_DEL 22 /* , int); */ +#define H_NEXT_EVDATA 23 /* , const int, histdata_t *); */ +#define H_DELDATA 24 /* , int, histdata_t *);*/ +#define H_REPLACE 25 /* , const char *, histdata_t); */ +#define H_SAVE_FP 26 /* , FILE *); */ +#define H_NSAVE_FP 27 /* , size_t, FILE *); */ + + + +/* + * ==== Tokenization ==== + */ + +typedef struct tokenizer Tokenizer; + +/* + * String tokenization functions, using simplified sh(1) quoting rules + */ +Tokenizer *tok_init(const char *); +void tok_end(Tokenizer *); +void tok_reset(Tokenizer *); +int tok_line(Tokenizer *, const LineInfo *, + int *, const char ***, int *, int *); +int tok_str(Tokenizer *, const char *, + int *, const char ***); + +/* + * Begin Wide Character Support + */ +#include +#include + +#ifndef HAVE_WCSDUP +wchar_t * wcsdup(const wchar_t *str); +#endif + +/* + * ==== Editing ==== + */ +typedef struct lineinfow { + const wchar_t *buffer; + const wchar_t *cursor; + const wchar_t *lastchar; +} LineInfoW; + +typedef int (*el_rfunc_t)(EditLine *, wchar_t *); + +const wchar_t *el_wgets(EditLine *, int *); +int el_wgetc(EditLine *, wchar_t *); +void el_wpush(EditLine *, const wchar_t *); + +int el_wparse(EditLine *, int, const wchar_t **); + +int el_wset(EditLine *, int, ...); +int el_wget(EditLine *, int, ...); + +int el_cursor(EditLine *, int); +const LineInfoW *el_wline(EditLine *); +int el_winsertstr(EditLine *, const wchar_t *); +#define el_wdeletestr el_deletestr +int el_wreplacestr(EditLine *, const wchar_t *); + +/* + * ==== History ==== + */ +typedef struct histeventW { + int num; + const wchar_t *str; +} HistEventW; + +typedef struct historyW HistoryW; + +HistoryW * history_winit(void); +void history_wend(HistoryW *); + +int history_w(HistoryW *, HistEventW *, int, ...); + +/* + * ==== Tokenization ==== + */ +typedef struct tokenizerW TokenizerW; + +/* Wide character tokenizer support */ +TokenizerW *tok_winit(const wchar_t *); +void tok_wend(TokenizerW *); +void tok_wreset(TokenizerW *); +int tok_wline(TokenizerW *, const LineInfoW *, + int *, const wchar_t ***, int *, int *); +int tok_wstr(TokenizerW *, const wchar_t *, + int *, const wchar_t ***); + +#ifdef __cplusplus +} +#endif + +#endif /* _HISTEDIT_H_ */ diff --git a/illumos-x86_64/usr/include/ia32/sys/asm_linkage.h b/illumos-x86_64/usr/include/ia32/sys/asm_linkage.h new file mode 120000 index 00000000..8426aa12 --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/asm_linkage.h @@ -0,0 +1 @@ +../../sys/asm_linkage.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/ia32/sys/kdi_regs.h b/illumos-x86_64/usr/include/ia32/sys/kdi_regs.h new file mode 100644 index 00000000..e8794818 --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/kdi_regs.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _IA32_SYS_KDI_REGS_H +#define _IA32_SYS_KDI_REGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define KDIREG_NGREG 21 + +/* + * %ss appears in a different place than a typical struct regs, since the + * machine won't save %ss on a trap entry from the same privilege level. + */ + +#define KDIREG_SAVFP 0 +#define KDIREG_SAVPC 1 +#define KDIREG_SS 2 +#define KDIREG_GS 3 +#define KDIREG_FS 4 +#define KDIREG_ES 5 +#define KDIREG_DS 6 +#define KDIREG_EDI 7 +#define KDIREG_ESI 8 +#define KDIREG_EBP 9 +#define KDIREG_ESP 10 +#define KDIREG_EBX 11 +#define KDIREG_EDX 12 +#define KDIREG_ECX 13 +#define KDIREG_EAX 14 +#define KDIREG_TRAPNO 15 +#define KDIREG_ERR 16 +#define KDIREG_EIP 17 +#define KDIREG_CS 18 +#define KDIREG_EFLAGS 19 +#define KDIREG_UESP 20 + +#define KDIREG_PC KDIREG_EIP +#define KDIREG_SP KDIREG_ESP +#define KDIREG_FP KDIREG_EBP + +#ifdef __cplusplus +} +#endif + +#endif /* _IA32_SYS_KDI_REGS_H */ diff --git a/illumos-x86_64/usr/include/ia32/sys/machtypes.h b/illumos-x86_64/usr/include/ia32/sys/machtypes.h new file mode 120000 index 00000000..05666611 --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/machtypes.h @@ -0,0 +1 @@ +../../sys/machtypes.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/ia32/sys/privmregs.h b/illumos-x86_64/usr/include/ia32/sys/privmregs.h new file mode 100644 index 00000000..51a7f591 --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/privmregs.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IA32_SYS_PRIVMREGS_H +#define _IA32_SYS_PRIVMREGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__i386) +#error "non-i386 code depends on i386 privileged header!" +#endif + +#ifndef _ASM + +#define PM_GREGS (1 << 0) +#define PM_CRREGS (1 << 1) +#define PM_DRREGS (1 << 2) + +/* + * This structure is intended to represent a complete machine state for a CPU, + * when that information is available. It is only for use internally between + * KMDB and the kernel, or within MDB. Note that this isn't yet finished. + */ +typedef struct privmregs { + ulong_t pm_flags; + /* general registers */ + struct regs pm_gregs; + /* cr0-8 */ + ulong_t pm_cr[8]; + /* dr0-8 */ + ulong_t pm_dr[8]; +} privmregs_t; + +#endif /* !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_IA32_SYS_PRIVMREGS_H */ diff --git a/illumos-x86_64/usr/include/ia32/sys/privregs.h b/illumos-x86_64/usr/include/ia32/sys/privregs.h new file mode 100644 index 00000000..44d8f71a --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/privregs.h @@ -0,0 +1,256 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IA32_SYS_PRIVREGS_H +#define _IA32_SYS_PRIVREGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file describes the cpu's privileged register set, and + * how the machine state is saved on the stack when a trap occurs. + */ + +#if !defined(__i386) +#error "non-i386 code depends on i386 privileged header!" +#endif + +#ifndef _ASM + +/* + * This is NOT the structure to use for general purpose debugging; + * see /proc for that. This is NOT the structure to use to decode + * the ucontext or grovel about in a core file; see . + */ + +struct regs { + /* + * Extra frame for mdb to follow through high level interrupts and + * system traps. Set them to 0 to terminate stacktrace. + */ + greg_t r_savfp; /* a copy of %ebp */ + greg_t r_savpc; /* a copy of %eip */ + + greg_t r_gs; + greg_t r_fs; + greg_t r_es; + greg_t r_ds; + greg_t r_edi; + greg_t r_esi; + greg_t r_ebp; + greg_t r_esp; + greg_t r_ebx; + greg_t r_edx; + greg_t r_ecx; + greg_t r_eax; + greg_t r_trapno; + greg_t r_err; + greg_t r_eip; + greg_t r_cs; + greg_t r_efl; + greg_t r_uesp; + greg_t r_ss; +}; + +#define r_r0 r_eax /* r0 for portability */ +#define r_r1 r_edx /* r1 for portability */ +#define r_fp r_ebp /* system frame pointer */ +#define r_sp r_uesp /* user stack pointer */ +#define r_pc r_eip /* user's instruction pointer */ +#define r_ps r_efl /* user's EFLAGS */ + +#define GREG_NUM 8 /* Number of regs between %edi and %eax */ + +#ifdef _KERNEL +#define lwptoregs(lwp) ((struct regs *)((lwp)->lwp_regs)) +#endif /* _KERNEL */ + +#else /* !_ASM */ + +#if defined(_MACHDEP) + +#include + +/* + * Save current frame on the stack. Uses %eax. + */ +#define __FRAME_PUSH \ + subl $8, %esp; \ + movl REGOFF_EIP(%esp), %eax; \ + movl %eax, REGOFF_SAVPC(%esp); \ + movl %ebp, REGOFF_SAVFP(%esp); + +/* + * Save segment registers on the stack. + */ +#define __SEGREGS_PUSH \ + subl $16, %esp; \ + movw %ds, 12(%esp); \ + movw %es, 8(%esp); \ + movw %fs, 4(%esp); \ + movw %gs, 0(%esp); + +/* + * Load segment register with kernel selectors. + * %gs must be the last one to be set to make the + * check in cmnint valid. + */ +#define __SEGREGS_LOAD_KERNEL \ + movw $KDS_SEL, %cx; \ + movw %cx, %ds; \ + movw %cx, %es; \ + movw $KFS_SEL, %cx; \ + movw $KGS_SEL, %dx; \ + movw %cx, %fs; \ + movw %dx, %gs; + +/* + * Restore segment registers off the stack. + * + * NOTE THE ORDER IS VITAL! + * + * Also note the subtle interdependency with kern_gpfault() + * that needs to disassemble these instructions to diagnose + * what happened when things (like bad segment register + * values) go horribly wrong. + */ +#define __SEGREGS_POP \ + movw 0(%esp), %gs; \ + movw 4(%esp), %fs; \ + movw 8(%esp), %es; \ + movw 12(%esp), %ds; \ + addl $16, %esp; + +/* + * Macros for saving all registers necessary on interrupt entry, + * and restoring them on exit. + */ +#define INTR_PUSH \ + cld; \ + pusha; \ + __SEGREGS_PUSH \ + __FRAME_PUSH \ + cmpw $KGS_SEL, REGOFF_GS(%esp); \ + je 8f; \ + movl $0, REGOFF_SAVFP(%esp); \ + __SEGREGS_LOAD_KERNEL \ +8: CLEAN_CS + +#define __INTR_POP \ + popa; \ + addl $8, %esp; /* get TRAPNO and ERR off the stack */ + +#define INTR_POP_USER \ + addl $8, %esp; /* get extra frame off the stack */ \ + __SEGREGS_POP \ + __INTR_POP + +#define INTR_POP_KERNEL \ + addl $24, %esp; /* skip extra frame and segment registers */ \ + __INTR_POP +/* + * Macros for saving all registers necessary on system call entry, + * and restoring them on exit. + */ +#define SYSCALL_PUSH \ + cld; \ + pusha; \ + __SEGREGS_PUSH \ + subl $8, %esp; \ + pushfl; \ + popl %ecx; \ + orl $PS_IE, %ecx; \ + movl %ecx, REGOFF_EFL(%esp); \ + movl $0, REGOFF_SAVPC(%esp); \ + movl $0, REGOFF_SAVFP(%esp); \ + __SEGREGS_LOAD_KERNEL; \ + +#define SYSENTER_PUSH \ + cld; \ + pusha; \ + __SEGREGS_PUSH \ + subl $8, %esp; \ + movl $0, REGOFF_SAVPC(%esp); \ + movl $0, REGOFF_SAVFP(%esp); \ + __SEGREGS_LOAD_KERNEL + +#define SYSCALL_POP \ + INTR_POP_USER + +#endif /* _MACHDEP */ + +/* + * This is used to set eflags to known values at the head of an + * interrupt gate handler, i.e. interrupts are -already- disabled. + */ +#define INTGATE_INIT_KERNEL_FLAGS \ + pushl $F_OFF; \ + popfl + +#endif /* !_ASM */ + +#include + +/* Control register layout for panic dump */ + +#define CREGSZ 36 +#define CREG_GDT 0 +#define CREG_IDT 8 +#define CREG_LDT 16 +#define CREG_TASKR 18 +#define CREG_CR0 20 +#define CREG_CR2 24 +#define CREG_CR3 28 +#define CREG_CR4 32 + +#if !defined(_ASM) && defined(_INT64_TYPE) + +typedef uint64_t creg64_t; + +struct cregs { + creg64_t cr_gdt; + creg64_t cr_idt; + uint16_t cr_ldt; + uint16_t cr_task; + uint32_t cr_cr0; + uint32_t cr_cr2; + uint32_t cr_cr3; + uint32_t cr_cr4; +}; + +#if defined(_KERNEL) +extern void getcregs(struct cregs *); +#endif /* _KERNEL */ + +#endif /* !_ASM && _INT64_TYPE */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_IA32_SYS_PRIVREGS_H */ diff --git a/illumos-x86_64/usr/include/ia32/sys/psw.h b/illumos-x86_64/usr/include/ia32/sys/psw.h new file mode 120000 index 00000000..b31154a8 --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/psw.h @@ -0,0 +1 @@ +../../sys/psw.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/ia32/sys/pte.h b/illumos-x86_64/usr/include/ia32/sys/pte.h new file mode 120000 index 00000000..e12ebe3f --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/pte.h @@ -0,0 +1 @@ +../../sys/pte.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/ia32/sys/reg.h b/illumos-x86_64/usr/include/ia32/sys/reg.h new file mode 120000 index 00000000..087daa1e --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/reg.h @@ -0,0 +1 @@ +../../sys/reg.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/ia32/sys/stack.h b/illumos-x86_64/usr/include/ia32/sys/stack.h new file mode 120000 index 00000000..ce5b0c46 --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/stack.h @@ -0,0 +1 @@ +../../sys/stack.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/ia32/sys/trap.h b/illumos-x86_64/usr/include/ia32/sys/trap.h new file mode 120000 index 00000000..f9adbdb7 --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/trap.h @@ -0,0 +1 @@ +../../sys/trap.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/ia32/sys/traptrace.h b/illumos-x86_64/usr/include/ia32/sys/traptrace.h new file mode 120000 index 00000000..78acfa91 --- /dev/null +++ b/illumos-x86_64/usr/include/ia32/sys/traptrace.h @@ -0,0 +1 @@ +../../sys/traptrace.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/iconv.h b/illumos-x86_64/usr/include/iconv.h new file mode 100644 index 00000000..7d6230a4 --- /dev/null +++ b/illumos-x86_64/usr/include/iconv.h @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ICONV_H +#define _ICONV_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _iconv_info *iconv_t; + +extern iconv_t iconv_open(const char *, const char *); +#ifdef _XPG6 +extern size_t iconv(iconv_t, char **_RESTRICT_KYWD, + size_t *_RESTRICT_KYWD, char **_RESTRICT_KYWD, + size_t *_RESTRICT_KYWD); +#else +extern size_t iconv(iconv_t, const char **_RESTRICT_KYWD, + size_t *_RESTRICT_KYWD, char **_RESTRICT_KYWD, + size_t *_RESTRICT_KYWD); +#endif +extern int iconv_close(iconv_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _ICONV_H */ diff --git a/illumos-x86_64/usr/include/idmap.h b/illumos-x86_64/usr/include/idmap.h new file mode 100644 index 00000000..b29bf56e --- /dev/null +++ b/illumos-x86_64/usr/include/idmap.h @@ -0,0 +1,147 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + */ + +/* + * Header File for Clients of Native Identity Mapping Service + */ + +#ifndef _IDMAP_H +#define _IDMAP_H + + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The ifdef's for these two accomodate duplicate definitions in + * lib/smbsrv/libfksmbsrv/common/sys/kidmap.h See notes there. + */ + +/* Status */ +#ifndef _IDMAP_STAT_TYPE +#define _IDMAP_STAT_TYPE +typedef int32_t idmap_stat; +#endif /* _IDMAP_STAT_TYPE */ + +/* Opaque get handle */ +#ifndef _IDMAP_GET_HANDLE_T +#define _IDMAP_GET_HANDLE_T +typedef struct idmap_get_handle idmap_get_handle_t; +#endif /* _IDMAP_GET_HANDLE_T */ + +typedef uint32_t idmap_rid_t; + +/* Logger prototype which is based on syslog */ +typedef void (*idmap_logger_t)(int, const char *, ...); + +/* + * Setup API + */ + +/* Status code to string */ +extern const char *idmap_stat2string(idmap_stat); + +/* Free memory allocated by the API */ +extern void idmap_free(void *); + + +/* + * Supported flag values for mapping requests. + * These flag values are applicable to the batch API and the + * Windows Name API below. + */ +/* Use the libidmap cache */ +#define IDMAP_REQ_FLG_USE_CACHE 0x00000010 + +/* + * API to batch SID to UID/GID mapping requests + */ +/* Create handle */ +extern idmap_stat idmap_get_create(idmap_get_handle_t **); + +/* Given SID, get UID */ +extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *, + idmap_rid_t, int, uid_t *, idmap_stat *); + +/* Given SID, get GID */ +extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *, + idmap_rid_t, int, gid_t *, idmap_stat *); + +/* Given SID, get UID or GID */ +extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *, + idmap_rid_t, int, uid_t *, int *, idmap_stat *); + +/* Given UID, get SID */ +extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int, + char **, idmap_rid_t *, idmap_stat *); + +/* Given GID, get SID */ +extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int, + char **, idmap_rid_t *, idmap_stat *); + +/* Process the batched requests */ +extern idmap_stat idmap_get_mappings(idmap_get_handle_t *); + +/* Destroy the handle */ +extern void idmap_get_destroy(idmap_get_handle_t *); + + +/* + * API to get Windows name by UID/GID and vice-versa + */ +/* Given UID, get Windows name */ +extern idmap_stat idmap_getwinnamebyuid(uid_t, int, char **, char **); + +/* Given GID, get Windows name */ +extern idmap_stat idmap_getwinnamebygid(gid_t, int, char **, char **); + +/* Given PID, get Windows name */ +extern idmap_stat idmap_getwinnamebypid(uid_t, int, int, char **, char **); + +/* Given Windows name, get UID */ +extern idmap_stat idmap_getuidbywinname(const char *, const char *, + int, uid_t *); + +/* Given Windows name, get GID */ +extern idmap_stat idmap_getgidbywinname(const char *, const char *, + int, gid_t *); + + +/* Logger */ +extern void idmap_set_logger(idmap_logger_t funct); + +#ifdef __cplusplus +} +#endif + +#endif /* _IDMAP_H */ diff --git a/illumos-x86_64/usr/include/idn-free.h b/illumos-x86_64/usr/include/idn-free.h new file mode 100644 index 00000000..d7c505fb --- /dev/null +++ b/illumos-x86_64/usr/include/idn-free.h @@ -0,0 +1,82 @@ +/* idn-free.h --- Invoke the free function to release memory + Copyright (C) 2004-2025 Simon Josefsson + + This file is part of GNU Libidn. + + GNU Libidn is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version. + + or both in parallel, as here. + + GNU Libidn is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see . */ + +#ifndef IDN_FREE_H +# define IDN_FREE_H + +/** + * SECTION:idn-free + * @title: idn-free.h + * @short_description: Memory deallocation functions + * + * Memory deallocation functions. + */ + +# ifndef IDNAPI +# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY +# define IDNAPI __attribute__((__visibility__("default"))) +# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllexport) +# elif defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllimport) +# else +# define IDNAPI +# endif +# endif + +# ifdef __cplusplus +extern "C" +{ +# endif + +/* I don't recommend using this interface in general. Use `free'. + * + * I'm told Microsoft Windows may use one set of `malloc' and `free' + * in a library, and another incompatible set in a statically compiled + * application that link to the library, thus creating problems if the + * application would invoke `free' on a pointer pointing to memory + * allocated by the library. This motivated adding this function. + * + * The theory of isolating all memory allocations and de-allocations + * within a code package (library) sounds good, to simplify hunting + * down memory allocation related problems, but I'm not sure if it is + * worth enough to motivate recommending this interface over calling + * `free' directly, though. + * + * See the manual section 'Memory handling under Windows' for more + * information. + */ + + extern void IDNAPI idn_free (void *ptr); + +# ifdef __cplusplus +} +# endif + +#endif /* IDN_FREE_H */ diff --git a/illumos-x86_64/usr/include/idn-int.h b/illumos-x86_64/usr/include/idn-int.h new file mode 100644 index 00000000..349353f5 --- /dev/null +++ b/illumos-x86_64/usr/include/idn-int.h @@ -0,0 +1,752 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Copyright (C) 2001-2002, 2004-2025 Free Software Foundation, Inc. + Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. + This file is part of gnulib. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* + * ISO C 99 for platforms that lack it. + * + */ + +#ifndef _GL_LGL_STDINT_H + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + + +/* When including a system file that in turn includes , + use the system , not our substitute. This avoids + problems with (for example) VMS, whose includes + . */ +#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H + +/* On Android (Bionic libc), includes this file before + having defined 'time_t'. Therefore in this case avoid including + other system header files; just include the system's . + Ideally we should test __BIONIC__ here, but it is only defined after + has been included; hence test __ANDROID__ instead. */ +#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H +# include +#else + +/* Get those types that are already defined in other system include + files, so that we can "#define int8_t signed char" below without + worrying about a later system include file containing a "typedef + signed char int8_t;" that will get messed up by our macro. Our + macros should all be consistent with the system versions, except + for the "fast" types and macros, which we recommend against using + in public interfaces due to compiler differences. */ + +#if 1 +# if defined __sgi && ! defined __c99 + /* Bypass IRIX's if in C89 mode, since it merely annoys users + with "This header file is to be used only for c99 mode compilations" + diagnostics. */ +# define __STDINT_H__ +# endif + + /* Some pre-C++11 implementations need this. */ +# ifdef __cplusplus +# ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS 1 +# endif +# ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS 1 +# endif +# endif + + /* Other systems may have an incomplete or buggy . + Include it before , since any "#include " + in would reinclude us, skipping our contents because + _GL_LGL_STDINT_H is defined. + The include requires a split double-inclusion guard. */ +# include +#endif + +#if ! defined _GL_LGL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H +#define _GL_LGL_STDINT_H + +/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, + LONG_MIN, LONG_MAX, ULONG_MAX, CHAR_BIT, _GL_INTEGER_WIDTH. */ +#include + +/* Override WINT_MIN and WINT_MAX if gnulib's or overrides + wint_t. */ +#if 0 +# undef WINT_MIN +# undef WINT_MAX +# define WINT_MIN 0x0U +# define WINT_MAX 0xffffffffU +#endif + +#if ! 0 + +/* defines some of the stdint.h types as well, on glibc, + IRIX 6.5, and OpenBSD 3.8 (via ). + AIX 5.2 isn't needed and causes troubles. + Mac OS X 10.4.6 includes (which is us), but + relies on the system definitions, so include + after . */ +# if 1 && ! defined _AIX +# include +# endif + +# if 1 + /* In OpenBSD 3.8, includes , which defines + int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. + also defines intptr_t and uintptr_t. */ +# include +# elif 1 + /* Solaris 7 has the types except the *_fast*_t types, and + the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ +# include +# endif + +# if 0 && ! defined __BIT_TYPES_DEFINED__ + /* Linux libc4 >= 4.6.7 and libc5 have a that defines + int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is + included by . */ +# include +# endif + +# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H + +/* Minimum and maximum values for an integer type under the usual assumption. + Return an unspecified value if BITS == 0, adding a check to pacify + picky compilers. */ + +/* These are separate macros, because if you try to merge these macros into + a single one, HP-UX cc rejects the resulting expression in constant + expressions. */ +# define _STDINT_UNSIGNED_MIN(bits, zero) \ + (zero) +# define _STDINT_SIGNED_MIN(bits, zero) \ + (~ _STDINT_MAX (1, bits, zero)) + +# define _STDINT_MAX(signed, bits, zero) \ + (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) + +#if !GNULIB_defined_stdint_types + +/* 7.18.1.1. Exact-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. */ + +# undef int8_t +# undef uint8_t +typedef signed char gl_int8_t; +typedef unsigned char gl_uint8_t; +# define int8_t gl_int8_t +# define uint8_t gl_uint8_t + +# undef int16_t +# undef uint16_t +typedef short int gl_int16_t; +typedef unsigned short int gl_uint16_t; +# define int16_t gl_int16_t +# define uint16_t gl_uint16_t + +# undef int32_t +# undef uint32_t +typedef int gl_int32_t; +typedef unsigned int gl_uint32_t; +# define int32_t gl_int32_t +# define uint32_t gl_uint32_t + +/* If the system defines INT64_MAX, assume int64_t works. That way, + if the underlying platform defines int64_t to be a 64-bit long long + int, the code below won't mistakenly define it to be a 64-bit long + int, which would mess up C++ name mangling. We must use #ifdef + rather than #if, to avoid an error with HP-UX 10.20 cc. */ + +# ifdef INT64_MAX +# define GL_INT64_T +# else +/* Do not undefine int64_t if gnulib is not being used with 64-bit + types, since otherwise it breaks platforms like Tandem/NSK. */ +# if LONG_MAX >> 31 >> 31 == 1 +# undef int64_t +typedef long int gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# elif defined _MSC_VER +# undef int64_t +typedef __int64 gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# else +/* Verify that 'long long' has exactly 64 bits. */ +typedef _gl_verify_int64_bits[ + _STDINT_MAX (1, sizeof (long long) * CHAR_BIT, 0ll) >> 31 >> 31 == 1 + ? 1 : -1]; +# undef int64_t +typedef long long int gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# endif +# endif + +# ifdef UINT64_MAX +# define GL_UINT64_T +# else +# if ULONG_MAX >> 31 >> 31 >> 1 == 1 +# undef uint64_t +typedef unsigned long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# elif defined _MSC_VER +# undef uint64_t +typedef unsigned __int64 gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# else +/* Verify that 'unsigned long long' has exactly 64 bits. */ +typedef _gl_verify_uint64_bits[ + _STDINT_MAX (0, sizeof (unsigned long long) * CHAR_BIT, 0ull) + >> 31 >> 31 >> 1 == 1 + ? 1 : -1]; +# undef uint64_t +typedef unsigned long long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# endif +# endif + +/* Avoid collision with Solaris 2.5.1 etc. */ +# define _UINT8_T +# define _UINT32_T +# define _UINT64_T + + +/* 7.18.1.2. Minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types + are the same as the corresponding N_t types. */ + +# undef int_least8_t +# undef uint_least8_t +# undef int_least16_t +# undef uint_least16_t +# undef int_least32_t +# undef uint_least32_t +# undef int_least64_t +# undef uint_least64_t +# define int_least8_t int8_t +# define uint_least8_t uint8_t +# define int_least16_t int16_t +# define uint_least16_t uint16_t +# define int_least32_t int32_t +# define uint_least32_t uint32_t +# ifdef GL_INT64_T +# define int_least64_t int64_t +# endif +# ifdef GL_UINT64_T +# define uint_least64_t uint64_t +# endif + +/* 7.18.1.3. Fastest minimum-width integer types */ + +/* Note: Other substitutes may define these types differently. + It is not recommended to use these types in public header files. */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types + are taken from the same list of types. The following code normally + uses types consistent with glibc, as that lessens the chance of + incompatibility with older GNU hosts. */ + +# undef int_fast8_t +# undef uint_fast8_t +# undef int_fast16_t +# undef uint_fast16_t +# undef int_fast32_t +# undef uint_fast32_t +# undef int_fast64_t +# undef uint_fast64_t +typedef signed char gl_int_fast8_t; +typedef unsigned char gl_uint_fast8_t; + +# ifdef __sun +/* Define types compatible with SunOS 5.10, so that code compiled under + earlier SunOS versions works with code compiled under SunOS 5.10. */ +typedef int gl_int_fast32_t; +typedef unsigned int gl_uint_fast32_t; +# else +typedef long int gl_int_fast32_t; +typedef unsigned long int gl_uint_fast32_t; +# endif +typedef gl_int_fast32_t gl_int_fast16_t; +typedef gl_uint_fast32_t gl_uint_fast16_t; + +# define int_fast8_t gl_int_fast8_t +# define uint_fast8_t gl_uint_fast8_t +# define int_fast16_t gl_int_fast16_t +# define uint_fast16_t gl_uint_fast16_t +# define int_fast32_t gl_int_fast32_t +# define uint_fast32_t gl_uint_fast32_t +# ifdef GL_INT64_T +# define int_fast64_t int64_t +# endif +# ifdef GL_UINT64_T +# define uint_fast64_t uint64_t +# endif + +/* 7.18.1.4. Integer types capable of holding object pointers */ + +/* kLIBC's defines _INTPTR_T_DECLARED and needs its own + definitions of intptr_t and uintptr_t (which use int and unsigned) + to avoid clashes with declarations of system functions like sbrk. + Similarly, MinGW WSL-5.4.1 needs its own intptr_t and + uintptr_t to avoid conflicting declarations of system functions like + _findclose in . */ +# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \ + || (defined __INTPTR_WIDTH__ \ + && __INTPTR_WIDTH__ != (defined _WIN64 ? LLONG_WIDTH : LONG_WIDTH)) \ + || defined __MINGW32__) +# undef intptr_t +# undef uintptr_t +# ifdef _WIN64 +typedef long long int gl_intptr_t; +typedef unsigned long long int gl_uintptr_t; +# else +typedef long int gl_intptr_t; +typedef unsigned long int gl_uintptr_t; +# endif +# define intptr_t gl_intptr_t +# define uintptr_t gl_uintptr_t +# endif + +/* 7.18.1.5. Greatest-width integer types */ + +/* Note: These types are compiler dependent. It may be unwise to use them in + public header files. */ + +/* If the system defines INTMAX_MAX, assume that intmax_t works, and + similarly for UINTMAX_MAX and uintmax_t. This avoids problems with + assuming one type where another is used by the system. */ + +# ifndef INTMAX_MAX +# undef INTMAX_C +# undef intmax_t +# if LONG_MAX >> 30 == 1 +typedef long long int gl_intmax_t; +# define intmax_t gl_intmax_t +# elif defined GL_INT64_T +# define intmax_t int64_t +# else +typedef long int gl_intmax_t; +# define intmax_t gl_intmax_t +# endif +# endif + +# ifndef UINTMAX_MAX +# undef UINTMAX_C +# undef uintmax_t +# if ULONG_MAX >> 31 == 1 +typedef unsigned long long int gl_uintmax_t; +# define uintmax_t gl_uintmax_t +# elif defined GL_UINT64_T +# define uintmax_t uint64_t +# else +typedef unsigned long int gl_uintmax_t; +# define uintmax_t gl_uintmax_t +# endif +# endif + +/* Verify that intmax_t and uintmax_t have the same size. Too much code + breaks if this is not the case. If this check fails, the reason is likely + to be found in the autoconf macros. */ +typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) + ? 1 : -1]; + +# define GNULIB_defined_stdint_types 1 +# endif /* !GNULIB_defined_stdint_types */ + +/* 7.18.2. Limits of specified-width integer types */ + +/* 7.18.2.1. Limits of exact-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. */ + +# undef INT8_MIN +# undef INT8_MAX +# undef UINT8_MAX +# define INT8_MIN (~ INT8_MAX) +# define INT8_MAX 127 +# define UINT8_MAX 255 + +# undef INT16_MIN +# undef INT16_MAX +# undef UINT16_MAX +# define INT16_MIN (~ INT16_MAX) +# define INT16_MAX 32767 +# define UINT16_MAX 65535 + +# undef INT32_MIN +# undef INT32_MAX +# undef UINT32_MAX +# define INT32_MIN (~ INT32_MAX) +# define INT32_MAX 2147483647 +# define UINT32_MAX 4294967295U + +# if defined GL_INT64_T && ! defined INT64_MAX +/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 + evaluates the latter incorrectly in preprocessor expressions. */ +# define INT64_MIN (- INTMAX_C (1) << 63) +# define INT64_MAX INTMAX_C (9223372036854775807) +# endif + +# if defined GL_UINT64_T && ! defined UINT64_MAX +# define UINT64_MAX UINTMAX_C (18446744073709551615) +# endif + +/* 7.18.2.2. Limits of minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types + are the same as the corresponding N_t types. */ + +# undef INT_LEAST8_MIN +# undef INT_LEAST8_MAX +# undef UINT_LEAST8_MAX +# define INT_LEAST8_MIN INT8_MIN +# define INT_LEAST8_MAX INT8_MAX +# define UINT_LEAST8_MAX UINT8_MAX + +# undef INT_LEAST16_MIN +# undef INT_LEAST16_MAX +# undef UINT_LEAST16_MAX +# define INT_LEAST16_MIN INT16_MIN +# define INT_LEAST16_MAX INT16_MAX +# define UINT_LEAST16_MAX UINT16_MAX + +# undef INT_LEAST32_MIN +# undef INT_LEAST32_MAX +# undef UINT_LEAST32_MAX +# define INT_LEAST32_MIN INT32_MIN +# define INT_LEAST32_MAX INT32_MAX +# define UINT_LEAST32_MAX UINT32_MAX + +# undef INT_LEAST64_MIN +# undef INT_LEAST64_MAX +# ifdef GL_INT64_T +# define INT_LEAST64_MIN INT64_MIN +# define INT_LEAST64_MAX INT64_MAX +# endif + +# undef UINT_LEAST64_MAX +# ifdef GL_UINT64_T +# define UINT_LEAST64_MAX UINT64_MAX +# endif + +/* 7.18.2.3. Limits of fastest minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types + are taken from the same list of types. */ + +# undef INT_FAST8_MIN +# undef INT_FAST8_MAX +# undef UINT_FAST8_MAX +# define INT_FAST8_MIN SCHAR_MIN +# define INT_FAST8_MAX SCHAR_MAX +# define UINT_FAST8_MAX UCHAR_MAX + +# undef INT_FAST16_MIN +# undef INT_FAST16_MAX +# undef UINT_FAST16_MAX +# define INT_FAST16_MIN INT_FAST32_MIN +# define INT_FAST16_MAX INT_FAST32_MAX +# define UINT_FAST16_MAX UINT_FAST32_MAX + +# undef INT_FAST32_MIN +# undef INT_FAST32_MAX +# undef UINT_FAST32_MAX +# ifdef __sun +# define INT_FAST32_MIN INT_MIN +# define INT_FAST32_MAX INT_MAX +# define UINT_FAST32_MAX UINT_MAX +# else +# define INT_FAST32_MIN LONG_MIN +# define INT_FAST32_MAX LONG_MAX +# define UINT_FAST32_MAX ULONG_MAX +# endif + +# undef INT_FAST64_MIN +# undef INT_FAST64_MAX +# ifdef GL_INT64_T +# define INT_FAST64_MIN INT64_MIN +# define INT_FAST64_MAX INT64_MAX +# endif + +# undef UINT_FAST64_MAX +# ifdef GL_UINT64_T +# define UINT_FAST64_MAX UINT64_MAX +# endif + +/* 7.18.2.4. Limits of integer types capable of holding object pointers */ + +# undef INTPTR_MIN +# undef INTPTR_MAX +# undef UINTPTR_MAX +# ifdef _WIN64 +# define INTPTR_MIN LLONG_MIN +# define INTPTR_MAX LLONG_MAX +# define UINTPTR_MAX ULLONG_MAX +# else +# define INTPTR_MIN LONG_MIN +# define INTPTR_MAX LONG_MAX +# define UINTPTR_MAX ULONG_MAX +# endif + +/* 7.18.2.5. Limits of greatest-width integer types */ + +# ifndef INTMAX_MAX +# undef INTMAX_MIN +# ifdef INT64_MAX +# define INTMAX_MIN INT64_MIN +# define INTMAX_MAX INT64_MAX +# else +# define INTMAX_MIN INT32_MIN +# define INTMAX_MAX INT32_MAX +# endif +# endif + +# ifndef UINTMAX_MAX +# ifdef UINT64_MAX +# define UINTMAX_MAX UINT64_MAX +# else +# define UINTMAX_MAX UINT32_MAX +# endif +# endif + +/* 7.18.3. Limits of other integer types */ + +/* ptrdiff_t limits */ +# undef PTRDIFF_MIN +# undef PTRDIFF_MAX +# if 0 +# ifdef _LP64 +# define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l) +# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) +# else +# define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0) +# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) +# endif +# else +# define PTRDIFF_MIN \ + _STDINT_SIGNED_MIN (64, 0l) +# define PTRDIFF_MAX \ + _STDINT_MAX (1, 64, 0l) +# endif + +/* sig_atomic_t limits */ +# undef SIG_ATOMIC_MIN +# undef SIG_ATOMIC_MAX +# if 1 +# define SIG_ATOMIC_MIN \ + _STDINT_SIGNED_MIN (32, 0) +# else +# define SIG_ATOMIC_MIN \ + _STDINT_UNSIGNED_MIN (32, 0) +# endif +# define SIG_ATOMIC_MAX \ + _STDINT_MAX (1, 32, \ + 0) + + +/* size_t limit */ +# undef SIZE_MAX +# if 0 +# ifdef _LP64 +# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) +# else +# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) +# endif +# else +# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) +# endif + +/* wchar_t limits */ +/* Get WCHAR_MIN, WCHAR_MAX. + This include is not on the top, above, because on OSF/1 4.0 we have a + sequence of nested includes + -> -> -> , and the latter includes + and assumes its types are already defined. */ +# if 1 && ! (defined WCHAR_MIN && defined WCHAR_MAX) +# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H +# include +# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H +# endif +# undef WCHAR_MIN +# undef WCHAR_MAX +# if 1 +# define WCHAR_MIN \ + _STDINT_SIGNED_MIN (32, 0) +# else +# define WCHAR_MIN \ + _STDINT_UNSIGNED_MIN (32, 0) +# endif +# define WCHAR_MAX \ + _STDINT_MAX (1, 32, 0) + +/* wint_t limits */ +/* If gnulib's or overrides wint_t, is not + accurate, therefore use the definitions from above. */ +# if !0 +# undef WINT_MIN +# undef WINT_MAX +# if 1 +# define WINT_MIN \ + _STDINT_SIGNED_MIN (32, 0) +# else +# define WINT_MIN \ + _STDINT_UNSIGNED_MIN (32, 0) +# endif +# define WINT_MAX \ + _STDINT_MAX (1, 32, 0) +# endif + +/* 7.18.4. Macros for integer constants */ + +/* 7.18.4.1. Macros for minimum-width integer constants */ +/* According to ISO C 99 Technical Corrigendum 1 */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ + +# undef INT8_C +# undef UINT8_C +# define INT8_C(x) x +# define UINT8_C(x) x + +# undef INT16_C +# undef UINT16_C +# define INT16_C(x) x +# define UINT16_C(x) x + +# undef INT32_C +# undef UINT32_C +# define INT32_C(x) x +# define UINT32_C(x) x ## U + +# undef INT64_C +# undef UINT64_C +# if LONG_MAX >> 31 >> 31 == 1 +# define INT64_C(x) x##L +# elif defined _MSC_VER +# define INT64_C(x) x##i64 +# else +# define INT64_C(x) x##LL +# endif +# if ULONG_MAX >> 31 >> 31 >> 1 == 1 +# define UINT64_C(x) x##UL +# elif defined _MSC_VER +# define UINT64_C(x) x##ui64 +# else +# define UINT64_C(x) x##ULL +# endif + +/* 7.18.4.2. Macros for greatest-width integer constants */ + +# ifndef INTMAX_C +# if LONG_MAX >> 30 == 1 +# define INTMAX_C(x) x##LL +# elif defined GL_INT64_T +# define INTMAX_C(x) INT64_C(x) +# else +# define INTMAX_C(x) x##L +# endif +# endif + +# ifndef UINTMAX_C +# if ULONG_MAX >> 31 == 1 +# define UINTMAX_C(x) x##ULL +# elif defined GL_UINT64_T +# define UINTMAX_C(x) UINT64_C(x) +# else +# define UINTMAX_C(x) x##UL +# endif +# endif + +#endif /* !0 */ + +/* Macros specified by ISO/IEC TS 18661-1:2014. */ + +#if (!defined UINTMAX_WIDTH \ + && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__)) +# ifdef INT8_MAX +# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX) +# endif +# ifdef UINT8_MAX +# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX) +# endif +# ifdef INT16_MAX +# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX) +# endif +# ifdef UINT16_MAX +# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX) +# endif +# ifdef INT32_MAX +# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX) +# endif +# ifdef UINT32_MAX +# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX) +# endif +# ifdef INT64_MAX +# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX) +# endif +# ifdef UINT64_MAX +# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX) +# endif +# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX) +# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX) +# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX) +# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX) +# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX) +# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX) +# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX) +# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX) +# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX) +# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX) +# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX) +# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX) +# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX) +# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX) +# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX) +# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX) +# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX) +# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX) +# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX) +# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX) +# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX) +# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX) +# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX) +# ifdef WINT_MAX +# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX) +# endif +# ifdef SIG_ATOMIC_MAX +# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX) +# endif +#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */ + +#endif /* _GL_LGL_STDINT_H */ +#endif /* !(defined __ANDROID__ && ...) */ +#endif /* !defined _GL_LGL_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ diff --git a/illumos-x86_64/usr/include/idna.h b/illumos-x86_64/usr/include/idna.h new file mode 100644 index 00000000..1de36e58 --- /dev/null +++ b/illumos-x86_64/usr/include/idna.h @@ -0,0 +1,141 @@ +/* idna.h --- Prototypes for Internationalized Domain Name library. + Copyright (C) 2002-2025 Simon Josefsson + + This file is part of GNU Libidn. + + GNU Libidn is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version. + + or both in parallel, as here. + + GNU Libidn is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see . */ + +#ifndef IDNA_H +# define IDNA_H + +/** + * SECTION:idna + * @title: idna.h + * @short_description: IDNA-related functions + * + * IDNA-related functions. + */ + +/** + * IDNAPI: + * + * Symbol holding shared library API visibility decorator. + * + * This is used internally by the library header file and should never + * be used or modified by the application. + * + * https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html + */ +# ifndef IDNAPI +# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY +# define IDNAPI __attribute__((__visibility__("default"))) +# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllexport) +# elif defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllimport) +# else +# define IDNAPI +# endif +# endif + +# include /* size_t */ +# include /* uint32_t */ + +# ifdef __cplusplus +extern "C" +{ +# endif + + /* Error codes. */ + typedef enum + { + IDNA_SUCCESS = 0, + IDNA_STRINGPREP_ERROR = 1, + IDNA_PUNYCODE_ERROR = 2, + IDNA_CONTAINS_NON_LDH = 3, + /* Workaround typo in earlier versions. */ + IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH, + IDNA_CONTAINS_MINUS = 4, + IDNA_INVALID_LENGTH = 5, + IDNA_NO_ACE_PREFIX = 6, + IDNA_ROUNDTRIP_VERIFY_ERROR = 7, + IDNA_CONTAINS_ACE_PREFIX = 8, + IDNA_ICONV_ERROR = 9, + /* Internal errors. */ + IDNA_MALLOC_ERROR = 201, + IDNA_DLOPEN_ERROR = 202 + } Idna_rc; + + /* IDNA flags */ + typedef enum + { + IDNA_ALLOW_UNASSIGNED = 0x0001, + IDNA_USE_STD3_ASCII_RULES = 0x0002 + } Idna_flags; + +# ifndef IDNA_ACE_PREFIX +# define IDNA_ACE_PREFIX "xn--" +# endif + + extern IDNAPI const char *idna_strerror (Idna_rc rc); + + /* Core functions */ + extern IDNAPI int idna_to_ascii_4i (const uint32_t * in, size_t inlen, + char *out, int flags); + extern IDNAPI int idna_to_unicode_44i (const uint32_t * in, size_t inlen, + uint32_t * out, size_t *outlen, + int flags); + + /* Wrappers that handle several labels */ + + extern IDNAPI int idna_to_ascii_4z (const uint32_t * input, + char **output, int flags); + + extern IDNAPI int idna_to_ascii_8z (const char *input, char **output, + int flags); + + extern IDNAPI int idna_to_ascii_lz (const char *input, char **output, + int flags); + + extern IDNAPI int idna_to_unicode_4z4z (const uint32_t * input, + uint32_t ** output, int flags); + + extern IDNAPI int idna_to_unicode_8z4z (const char *input, + uint32_t ** output, int flags); + + extern IDNAPI int idna_to_unicode_8z8z (const char *input, + char **output, int flags); + + extern IDNAPI int idna_to_unicode_8zlz (const char *input, + char **output, int flags); + + extern IDNAPI int idna_to_unicode_lzlz (const char *input, + char **output, int flags); + +# ifdef __cplusplus +} +# endif + +#endif /* IDNA_H */ diff --git a/illumos-x86_64/usr/include/ieeefp.h b/illumos-x86_64/usr/include/ieeefp.h new file mode 100644 index 00000000..0c19be32 --- /dev/null +++ b/illumos-x86_64/usr/include/ieeefp.h @@ -0,0 +1,300 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _IEEEFP_H +#define _IEEEFP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Floating point enviornment for machines that support + * the IEEE 754 floating-point standard. This file currently + * supports the 80*87, and SPARC families. + * + * This header defines the following interfaces: + * 1) Classes of floating point numbers + * 2) Rounding Control + * 3) Exception Control + * 4) Exception Handling + * 5) Utility Macros + * 6) Full Exception Environment Control + */ + +/* + * CLASSES of floating point numbers ************************* + * IEEE floating point values fall into 1 of the following 10 + * classes + */ +typedef enum fpclass_t { + FP_SNAN = 0, /* signaling NaN */ + FP_QNAN = 1, /* quiet NaN */ + FP_NINF = 2, /* negative infinity */ + FP_PINF = 3, /* positive infinity */ + FP_NDENORM = 4, /* negative denormalized non-zero */ + FP_PDENORM = 5, /* positive denormalized non-zero */ + FP_NZERO = 6, /* -0.0 */ + FP_PZERO = 7, /* +0.0 */ + FP_NNORM = 8, /* negative normalized non-zero */ + FP_PNORM = 9 /* positive normalized non-zero */ +} fpclass_t; + +extern fpclass_t fpclass(double); /* get class of double value */ +extern int finite(double); +extern int unordered(double, double); + +/* + * ROUNDING CONTROL ****************************************** + * + * At all times, floating-point math is done using one of four + * mutually-exclusive rounding modes. + */ + +#if defined(__i386) || defined(__amd64) + +/* + * NOTE: the values given are chosen to match those used by the + * 80*87 rounding mode field in the control word. + */ +typedef enum fp_rnd { + FP_RN = 0, /* round to nearest representable number, tie -> even */ + FP_RM = 1, /* round toward minus infinity */ + FP_RP = 2, /* round toward plus infinity */ + FP_RZ = 3 /* round toward zero (truncate) */ +} fp_rnd; + +#endif + +#if defined(__sparc) + +/* + * NOTE: the values given are chosen to match those used by the + * RD (Round Direction) field of the FSR (Floating Point State Register). + */ +typedef enum fp_rnd { + FP_RN = 0, /* round to nearest representable number, tie -> even */ + FP_RZ = 1, /* round toward zero (truncate) */ + FP_RP = 2, /* round toward plus infinity */ + FP_RM = 3 /* round toward minus infinity */ +} fp_rnd; + +#endif + +extern fp_rnd fpsetround(fp_rnd); /* set rounding mode, return previous */ +extern fp_rnd fpgetround(void); /* return current rounding mode */ + +/* + * EXCEPTION CONTROL ***************************************** + * + */ + +#define fp_except int + +#define FP_DISABLE 0 /* exception will be ignored */ +#define FP_ENABLE 1 /* exception will cause SIGFPE */ +#define FP_CLEAR 0 /* exception has not occurred */ +#define FP_SET 1 /* exception has occurred */ + +#if defined(__i386) || defined(__amd64) + +/* + * There are six floating point exceptions, which can be individually + * ENABLED (== 1) or DISABLED (== 0). When an exception occurs + * (ENABLED or not), the fact is noted by changing an associated + * "sticky bit" from CLEAR (==0) to SET (==1). + * + * NOTE: the bit positions in fp_except are chosen to match those of + * the 80*87 control word mask bits. Although the 87 chips actually + * ENABLE exceptions with a mask value of 0 (not 1, as on the 3b), it + * is felt that switching these values may create more problems than + * it solves. + */ + +/* an fp_except can have the following (not exclusive) values: */ +#define FP_X_INV 0x01 /* invalid operation exception */ +#define FP_X_DNML 0x02 /* denormalization exception */ +#define FP_X_DZ 0x04 /* divide-by-zero exception */ +#define FP_X_OFL 0x08 /* overflow exception */ +#define FP_X_UFL 0x10 /* underflow exception */ +#define FP_X_IMP 0x20 /* imprecise (loss of precision) */ + +#endif + +#if defined(__sparc) + +/* + * There are five floating-point exceptions, which can be individually + * ENABLED (== 1) or DISABLED (== 0). When an exception occurs + * (ENABLED or not), the fact is noted by changing an associated + * "sticky bit" from CLEAR (==0) to SET (==1). + * + * NOTE: the bit positions in an fp_except are chosen to match that in + * the Trap Enable Mask of the FSR (Floating Point State Register). + */ + +/* an fp_except can have the following (not exclusive) values: */ +#define FP_X_INV 0x10 /* invalid operation exception */ +#define FP_X_OFL 0x08 /* overflow exception */ +#define FP_X_UFL 0x04 /* underflow exception */ +#define FP_X_DZ 0x02 /* divide-by-zero exception */ +#define FP_X_IMP 0x01 /* imprecise (loss of precision) */ + +#endif + +extern fp_except fpgetmask(void); /* current exception mask */ +extern fp_except fpsetmask(fp_except); /* set mask, return previous */ +extern fp_except fpgetsticky(void); /* return logged exceptions */ +extern fp_except fpsetsticky(fp_except); /* change logged exceptions */ + +/* + * UTILITY MACROS ******************************************** + */ + +extern int isnanf(float); +extern int isnand(double); + +#if defined(__i386) || defined(__amd64) + +/* + * EXCEPTION HANDLING **************************************** + * + * When a signal handler catches an FPE, it will have a freshly initialized + * coprocessor. This allows signal handling routines to make use of + * floating point arithmetic, if need be. The previous state of the 87 + * chip is available, however. There are two ways to get at this information, + * depending on how the signal handler was set up. + * + * If the handler was set via signal() or sigset(), the old, SVR3, method + * should be used: the signal handler assumes that it has a single parameter, + * which is of type struct _fpstackframe, defined below. By investigating + * this parameter, the cause of the FPE may be determined. By modifying it, + * the state of the coprocessor can be changed upon return to the main task. + * THIS METHOD IS OBSOLETE, AND MAY NOT BE SUPPORTED IN FUTURE RELEASES. + * + * If the handler was set via sigaction(), the new, SVR4, method should be + * used: the third argument to the handler will be a pointer to a ucontext + * structure (see sys/ucontext.h). The uc_mcontext.fpregs member of the + * ucontext structure holds the saved floating-point registers. This can be + * examined and/or modified. By modifying it, the state of the coprocessor + * can be changed upon return to the main task. + */ + +struct _fpreg { /* structure of a temp real fp register */ + unsigned short significand[4]; /* 64 bit mantissa value */ + unsigned short exponent; /* 15 bit exponent and sign bit */ +}; + +#if defined(__i386) + +/* + * AMD64 users should use sigaction() as described above. + */ + +struct _fpstackframe { /* signal handler's argument */ + long signo; /* signal number arg */ + long regs[19]; /* all registers */ + struct _fpstate *fpsp; /* address of saved 387 state */ + char *wsp; /* address of saved Weitek state */ +}; + +#endif + +#if defined(__i386) || defined(__amd64) + +#if defined(__amd64) +#define _fpstate _fpstate32 +#endif + +struct _fpstate { /* saved state info from an exception */ + unsigned int cw, /* control word */ + sw, /* status word after fnclex-not useful */ + tag, /* tag word */ + ipoff, /* %eip register */ + cssel, /* code segment selector */ + dataoff, /* data operand address */ + datasel; /* data operand selector */ + struct _fpreg _st[8]; /* saved register stack */ + unsigned int status; /* status word saved at exception */ + unsigned int mxcsr; + unsigned int xstatus; /* status word saved at exception */ + unsigned int __pad[2]; + unsigned int xmm[8][4]; +}; + +#if defined(__amd64) +#undef _fpstate +#endif + +#endif /* __i386 || __amd64 */ + +/* + * The structure of the 80*87 status and control words, and the mxcsr + * register are given by the following structures. + */ +struct _cw87 { + unsigned + mask: 6, /* exception masks */ + res1: 2, /* not used */ + prec: 2, /* precision control field */ + rnd: 2, /* rounding control field */ + inf: 1, /* infinity control (not on 387) */ + res2: 3; /* not used */ +}; + +struct _sw87 { + unsigned + excp: 6, /* exception sticky bits */ + res1: 1, /* not used */ + errs: 1, /* error summary-set if unmasked excp */ + c012: 3, /* condition code bits 0..2 */ + stkt: 3, /* stack top pointer */ + c3: 1, /* condition code bit 3 */ + busy: 1; /* coprocessor busy */ +}; + +struct _mxcsr { + unsigned + excp: 6, /* exception sticky bits */ + daz: 1, /* denormals are zeroes */ + mask: 6, /* exception masks */ + rnd: 2, /* rounding control */ + fzero: 1; /* flush to zero */ +}; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _IEEEFP_H */ diff --git a/illumos-x86_64/usr/include/ifaddrs.h b/illumos-x86_64/usr/include/ifaddrs.h new file mode 100644 index 00000000..81588394 --- /dev/null +++ b/illumos-x86_64/usr/include/ifaddrs.h @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2022 Sebastian Wiedenroth + */ +#ifndef _IFADDRS_H +#define _IFADDRS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * The `getifaddrs' function generates a linked list of these structures. + * Each element of the list describes one network interface. + */ +#if defined(_INT64_TYPE) +struct ifaddrs { + struct ifaddrs *ifa_next; /* Pointer to the next structure. */ + char *ifa_name; /* Name of this network interface. */ + uint64_t ifa_flags; /* Flags as from SIOCGLIFFLAGS ioctl. */ + struct sockaddr *ifa_addr; /* Network address of this interface. */ + struct sockaddr *ifa_netmask; /* Netmask of this interface. */ + union { + /* + * At most one of the following two is valid. If the + * IFF_BROADCAST bit is set in `ifa_flags', then + * `ifa_broadaddr' is valid. If the IFF_POINTOPOINT bit is + * set, then `ifa_dstaddr' is valid. It is never the case that + * both these bits are set at once. + */ + struct sockaddr *ifu_broadaddr; + struct sockaddr *ifu_dstaddr; + } ifa_ifu; + void *ifa_data; /* Address-specific data (may be unused). */ +/* + * This may have been defined in . + */ +#ifndef ifa_broadaddr +#define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ +#endif +#ifndef ifa_dstaddr +#define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */ +#endif +}; +#endif + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getifaddrs __getifaddrs +#else +extern int __getifaddrs(struct ifaddrs **); +#define getifaddrs __getifaddrs +#endif + +/* + * Create a linked list of `struct ifaddrs' structures, one for each + * network interface on the host machine. If successful, store the + * list in *ifap and return 0. On errors, return -1 and set `errno'. + * + * The storage returned in *ifap is allocated dynamically and can + * only be properly freed by passing it to `freeifaddrs'. + */ +extern int getifaddrs(struct ifaddrs **); + +/* Reclaim the storage allocated by a previous `getifaddrs' call. */ +extern void freeifaddrs(struct ifaddrs *); + + +#ifdef __cplusplus +} +#endif + +#endif /* _IFADDRS_H */ diff --git a/illumos-x86_64/usr/include/ima.h b/illumos-x86_64/usr/include/ima.h new file mode 100644 index 00000000..b95a96cb --- /dev/null +++ b/illumos-x86_64/usr/include/ima.h @@ -0,0 +1,2457 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/****************************************************************************** + * + * Description + * Ima.h - general header file for client + * and library developers + * + * License: + * The contents of this file are subject to the SNIA Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * /http://www.snia.org/English/Resources/Code/OpenSource.html + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is SNIA HBA API and IMA general header file + * + * The Initial Developer of the Original Code is: + * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com) + * David Dillard VERITAS Software david.dillard@veritas.com + * + * Contributor(s): + * Jeff Ding, Adaptec, Inc. (jding@corp.adaptec.com) + * Dave Wysochanski, Network Appliance, Inc. (davidw@netapp.com) + * + ****************************************************************************** + * + * Changes: + * 09/24/2003 Initial Draft + * (for other changes... see the CVS logs) + * 12/15/2003 corrected the defined parameter in IMA_SetPhbaIsnsDiscovery(). + * lower case the computer name as iscsi name in + * IMA_GenerateNodeName(). + * 03/01/2004 Brought up to date with respect to IMA v1.0.1; made formatting + * changes - lines to 80 cols - for readability. + * + * 01/21/2005 Updated to support IMA 1.1.3. + *****************************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef IMA_H +#define IMA_H + +#include +#include + + +/* Library version string */ +#define HBA_LIBVERSION 2 + +#define IMA_MAX_CALLBACK_PER_PLUGIN 64 +#define IMA_MAX_NUM_PLUGINS 32 + +/* DLL imports for WIN32 operation */ +#ifdef WIN32 +#ifdef IMA_EXPORTS +#define IMA_API __declspec(dllexport) +#else +#define IMA_API __declspec(dllimport) +#endif +#else +#define IMA_API +#endif + +/* OS specific definitions */ + +#ifdef WIN32 +typedef unsigned char IMA_UINT8; // Unsigned 8 bits +typedef char IMA_INT8; // Signed 8 bits +typedef unsigned short IMA_UINT16; // Unsigned 16 bits +typedef short IMA_INT16; // Signed 16 bits +typedef unsigned int IMA_UINT32; // Unsigned 32 bits +typedef int IMA_INT32; // Signed 32 bits +typedef void* IMA_PVOID; // Pointer to void +typedef IMA_UINT32 IMA_VOID32; // Opaque 32 bits + + +/* Don't confuse, _WIN32 with WIN32... OK, how do you accompish that */ +#ifdef _WIN32 +typedef __int64 IMA_INT64; +typedef unsigned __int64 IMA_UINT64; +#else +typedef struct { + TN_UINT32 lo_val; + TN_UINT32 hi_val; +} IMA_INT64; + +typedef struct { + TN_UINT32 lo_val; + TN_UINT32 hi_val; +} IMA_UINT64; +#endif /* #ifdef _WIN32 */ + + +#else + +/* Note this section needs to be cleaned up for various Unix platforms */ +typedef unsigned char IMA_UINT8; /* Unsigned 8 bits */ +typedef char IMA_INT8; /* Signed 8 bits */ +typedef unsigned short IMA_UINT16; /* Unsigned 16 bits */ +typedef short IMA_INT16; /* Signed 16 bits */ +typedef unsigned int IMA_UINT32; /* Unsigned 32 bits */ +typedef int IMA_INT32; /* Signed 32 bits */ +typedef void* IMA_PVOID; /* Pointer to void */ +typedef IMA_UINT32 IMA_VOID32; /* Opaque 32 bits */ +typedef long long IMA_INT64; +typedef long long IMA_UINT64; + +#endif /* #ifdef WIN32 */ + + + +/** +******************************************************************************* +* +* Generic IMA Constant Definitions +* +******************************************************************************* +*/ +#define RL_LIBRARY_SEQNUM 0 +#define RL_SHARED_NODE_SEQNUM 0 + +/** +* Value which can be assigned to an IMA_BOOL and or an IMA_XBOOL. +*/ +#define IMA_TRUE 1 + +/** +* Value which can be assigned to an IMA_BOOL and or an IMA_XBOOL. +*/ +#define IMA_FALSE 0 + +/** +* Value which can be assigned to an IMA_XBOOL. +*/ +#define IMA_UNKNOWN 0xFFFFFFFF + + + +/** +******************************************************************************* +* +* Base IMA Type Definitions +* +* @note Types that have a specific size must be defined ImaOsTypes.h which is +* an OS specific include file which is included by this file. +* +******************************************************************************* +*/ + +/** +* A character. +*/ +typedef char IMA_CHAR; + +/** +* A wide character. +*/ +typedef wchar_t IMA_WCHAR; + +/** +* An integer. Spec states this is 32 bits on 32-bit systems, and 64-bit +* on 64-bit systems. +*/ +typedef unsigned long IMA_UINT; + +/** +* A boolean. +*/ +typedef IMA_UINT32 IMA_BOOL; + +/** +* An extended boolean: can have the values @ref IMA_TRUE, @ref IMA_FALSE, and +* @ref IMA_UNKNOWN. +*/ +typedef IMA_UINT32 IMA_XBOOL; + +/** +* A date and time. +*/ +typedef struct tm IMA_DATETIME; + +typedef unsigned char IMA_BYTE; + +/** +******************************************************************************* +* +* Constants and macros declarations related to IMA_STATUS +* +******************************************************************************* +*/ +#ifdef SOLARIS +typedef IMA_UINT IMA_STATUS; + +#define IMA_STATUS_SUCCESS 0x00000000 +#define IMA_STATUS_ERROR 0x80000000 + +#define IMA_SUCCESS(status) (((IMA_STATUS)(status) & \ + (IMA_STATUS)IMA_STATUS_ERROR) == 0 ? IMA_TRUE : IMA_FALSE) +#define IMA_ERROR(status) (((IMA_STATUS)(status) & \ + (IMA_STATUS)IMA_STATUS_ERROR) == 0x8000000 ? IMA_TRUE : IMA_FALSE) + +#define MAKE_IMA_STATUS(x) ((IMA_STATUS)(x)) +#define MAKE_IMA_ERROR(x) ((IMA_STATUS)(IMA_STATUS_ERROR | (x))) +#define GET_SYSTEM_ERROR(x) (((IMA_STATUS)(x) & 0x0000FFFF)) + +#define IMA_STATUS_REBOOT_NECESSARY MAKE_IMA_STATUS(0x01) +#define IMA_STATUS_INCONSISTENT_NODE_PROPERTIES MAKE_IMA_STATUS(0x02) +#define IMA_STATUS_SCSI_STATUS_CONDITION_MET MAKE_IMA_STATUS(0x100) + +#define IMA_ERROR_NOT_SUPPORTED MAKE_IMA_ERROR(0x01) +#define IMA_ERROR_INSUFFICIENT_MEMORY MAKE_IMA_ERROR(0x02) +#define IMA_ERROR_LAST_PRIMARY_DISCOVERY_METHOD MAKE_IMA_ERROR(0x03) +#define IMA_ERROR_UNEXPECTED_OS_ERROR MAKE_IMA_ERROR(0x04) +#define IMA_ERROR_SYNC_TIMEOUT MAKE_IMA_ERROR(0x05) +#define IMA_ERROR_LU_EXPOSED MAKE_IMA_ERROR(0x06) +#define IMA_ERROR_LU_NOT_EXPOSED MAKE_IMA_ERROR(0x07) +#define IMA_ERROR_LU_IN_USE MAKE_IMA_ERROR(0x08) +#define IMA_ERROR_TARGET_TIMEOUT MAKE_IMA_ERROR(0x09) +#define IMA_ERROR_LOGIN_REJECTED MAKE_IMA_ERROR(0x0A) +#define IMA_ERROR_STATS_COLLECTION_NOT_ENABLED MAKE_IMA_ERROR(0x0B) +#define IMA_ERROR_SCSI_STATUS_CHECK_CONDITION MAKE_IMA_ERROR(0x100) +#define IMA_ERROR_SCSI_STATUS_BUSY MAKE_IMA_ERROR(0x101) +#define IMA_ERROR_SCSI_STATUS_RESERVATION_CONFLICT MAKE_IMA_ERROR(0x102) +#define IMA_ERROR_SCSI_STATUS_TASK_SET_FULL MAKE_IMA_ERROR(0x103) +#define IMA_ERROR_SCSI_STATUS_ACA_ACTIVE MAKE_IMA_ERROR(0x104) +#define IMA_ERROR_SCSI_STATUS_TASK_ABORTED MAKE_IMA_ERROR(0x105) +#define IMA_ERROR_INVALID_PARAMETER MAKE_IMA_ERROR(0x40000000) +#define IMA_ERROR_INVALID_OBJECT_TYPE MAKE_IMA_ERROR(0x40000001) +#define IMA_ERROR_INCORRECT_OBJECT_TYPE MAKE_IMA_ERROR(0x40000002) +#define IMA_ERROR_OBJECT_NOT_FOUND MAKE_IMA_ERROR(0x40000003) +#define IMA_ERROR_NAME_TOO_LONG MAKE_IMA_ERROR(0x40000004) +#define IMA_ERROR_UNKNOWN_ERROR MAKE_IMA_ERROR(0x0fffffff) + +#else + +typedef enum { + IMA_STATUS_SUCCESS = 0x00000000, + IMA_STATUS_REBOOT_NECESSARY = 0x00000001, + IMA_STATUS_INCONSISTENT_NODE_PROPERTIES = 0x00000002, + IMA_STATUS_SCSI_STATUS_CONDITION_MET = 0x00000100, + + IMA_STATUS_ERROR = 0x80000000, + IMA_ERROR_NOT_SUPPORTED = 0x80000001, + IMA_ERROR_INSUFFICIENT_MEMORY = 0x80000002, + IMA_ERROR_LAST_PRIMARY_DISCOVERY_METHOD = 0x80000003, + IMA_ERROR_UNEXPECTED_OS_ERROR = 0x80000004, + IMA_ERROR_SYNC_TIMEOUT = 0x80000005, + IMA_ERROR_LU_EXPOSED = 0x80000006, + IMA_ERROR_LU_NOT_EXPOSED = 0x80000007, + IMA_ERROR_LU_IN_USE = 0x80000008, + IMA_ERROR_TARGET_TIMEOUT = 0x80000009, + IMA_ERROR_LOGIN_REJECTED = 0x8000000A, + IMA_ERROR_STATS_COLLECTION_NOT_ENABLED = 0x8000000B, + IMA_ERROR_SCSI_STATUS_CHECK_CONDITION = 0x80000100, + IMA_ERROR_SCSI_STATUS_BUSY = 0x80000101, + IMA_ERROR_SCSI_STATUS_RESERVATION_CONFLICT = 0x80000102, + IMA_ERROR_SCSI_STATUS_TASK_SET_FULL = 0x80000103, + IMA_ERROR_SCSI_STATUS_ACA_ACTIVE = 0x80000104, + IMA_ERROR_SCSI_STATUS_TASK_ABORTED = 0x80000105, + IMA_ERROR_INVALID_PARAMETER = 0xC0000000, + IMA_ERROR_INVALID_OBJECT_TYPE = 0xC0000001, + IMA_ERROR_INCORRECT_OBJECT_TYPE = 0xC0000002, + IMA_ERROR_OBJECT_NOT_FOUND = 0xC0000003, + IMA_ERROR_NAME_TOO_LONG = 0xC0000004, + IMA_ERROR_UNKNOWN_ERROR = 0x8FFFFFFF +} IMA_STATUS; + +/* +#define IMA_SUCCESS(status) ( (IMA_UINT32)(status) & \ + (IMA_UINT32)IMA_STATUS_ERROR == 0 ? \ + IMA_TRUE : IMA_FALSE ) +#define IMA_ERROR(status) ( (IMA_UINT32)(status) & \ + (IMA_UINT32)IMA_STATUS_ERROR == 0x8000000 ? \ + IMA_TRUE : IMA_FALSE ) +*/ + +#define IMA_SUCCESS(status) !((status) & IMA_STATUS_ERROR) +#define IMA_ERROR(status) ((status) & IMA_STATUS_ERROR) + +#endif + +/** +******************************************************************************* +* +* Declaration of the IMA_OBJECT_TYPE enumeration +* +******************************************************************************* +*/ +typedef enum +{ + IMA_OBJECT_TYPE_UNKNOWN = 0, + IMA_OBJECT_TYPE_PLUGIN = 1, + IMA_OBJECT_TYPE_NODE = 2, + IMA_OBJECT_TYPE_LHBA = 3, + IMA_OBJECT_TYPE_PHBA = 4, + IMA_OBJECT_TYPE_NETWORK_PORTAL = 5, + IMA_OBJECT_TYPE_PORTAL_GROUP = 6, + IMA_OBJECT_TYPE_LNP = 7, + IMA_OBJECT_TYPE_PNP = 8, + IMA_OBJECT_TYPE_TARGET = 9, + IMA_OBJECT_TYPE_LU = 10, + IMA_OBJECT_TYPE_DISCOVERY_ADDRESS = 11, + IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET = 12, + IMA_OBJECT_TYPE_CONNECTION = 13, + IMA_OBJECT_TYPE_SESSION = 14 +} IMA_OBJECT_TYPE; + +typedef enum +{ + IMA_ISNS_DISCOVERY_METHOD_STATIC = 0, + IMA_ISNS_DISCOVERY_METHOD_DHCP = 1, + IMA_ISNS_DISCOVERY_METHOD_SLP = 2 +} IMA_ISNS_DISCOVERY_METHOD; + +typedef enum +{ + IMA_DOWNLOAD_IMAGE_TYPE_FIRMWARE = 0, + IMA_DOWNLOAD_IMAGE_TYPE_OPTION_ROM = 1, + IMA_DOWNLOAD_IMAGE_TYPE_ALL = 2, + IMA_DOWNLOAD_IMAGE_TYPE_BOOTCODE = 3 +} IMA_PHBA_DOWNLOAD_IMAGE_TYPE; + +typedef enum +{ + IMA_PHBA_STATUS_WORKING = 0, + IMA_PHBA_STATUS_FAILED = 1 +} IMA_PHBA_STATUS; + +typedef enum +{ + IMA_NETWORK_PORT_STATUS_WORKING = 0, + IMA_NETWORK_PORT_STATUS_DEGRADED = 1, + IMA_NETWORK_PORT_STATUS_CRITICAL = 2, + IMA_NETWORK_PORT_STATUS_FAILED = 3, + IMA_NETWORK_PORT_STATUS_DISCONNECTED = 4 +} IMA_NETWORK_PORT_STATUS; + +typedef enum +{ + IMA_TARGET_DISCOVERY_METHOD_STATIC = 1, + IMA_TARGET_DISCOVERY_METHOD_SLP = 2, + IMA_TARGET_DISCOVERY_METHOD_ISNS = 4, + IMA_TARGET_DISCOVERY_METHOD_SENDTARGETS = 8 +} IMA_TARGET_DISCOVERY_METHOD; + +typedef enum +{ + IMA_AUTHMETHOD_NONE = 0, + IMA_AUTHMETHOD_CHAP = 1, + IMA_AUTHMETHOD_SRP = 2, + IMA_AUTHMETHOD_KRB5 = 3, + IMA_AUTHMETHOD_SPKM1 = 4, + IMA_AUTHMETHOD_SPKM2 = 5 +} IMA_AUTHMETHOD; + +typedef enum +{ + IMA_COMMIT_TYPE_AUTO = 0, + IMA_COMMIT_TYPE_ACTIVE, + IMA_COMMIT_TYPE_PERSISTENT, + IMA_COMMIT_TYPE_ACTIVE_AND_PERSISTENT, + IMA_COMMIT_TYPE_ALL_WITH_RESET +} IMA_COMMIT_LEVEL; + +typedef enum +{ + IMA_DIGEST_NONE = 0, + IMA_DIGEST_CRC32C = 1 +} IMA_DIGEST_TYPE; + + +/** +******************************************************************************* +* +* Declaration of the IMA_OID structure +* +* This structure should be treated as opaque by clients of the API. +* Appropriate APIs should be used to extract information from the structure. +* +******************************************************************************* +*/ +typedef struct _IMA_OID +{ + /** + * The type of the object. When an object ID is supplied as a parameter + * to an API the library uses this value to insure that the supplied + * object's type is appropriate for the API. + */ + IMA_OBJECT_TYPE objectType; + + /** + * A value determined by the library which it uses to uniquely identify the + * owner of an object. The owner of an object is either the library itself + * or a plugin. When an object ID is supplied as a parameter to an API the + * library uses this value to determine if it should handle the call itself + * or direct the call to one or more plugins. + */ + IMA_UINT32 ownerId; + + /** + * A value determined by a plugin which a plugin uses, perhaps in + * combination with the object type, to uniquely identify one of its + * objects. + */ + IMA_UINT64 objectSequenceNumber; + +} IMA_OID; + + + +/** +******************************************************************************* +* +* Declaration of the IMA_OID_LIST structure +* +* This structure is used by a number of APIs to return lists of objects. Any +* instance of this structure returned by an API must be freed by a client +* using the IMA_FreeObjectIdList API. Although oids is declared to be an +* array of one +* @ref IMA_OID structure it can in fact contain any number of +* @ref IMA_OID structures. +* +* @note The @a oids array is a variable length array, despite its declaration +* below it can be of any length. +* +******************************************************************************* +*/ +typedef struct _IMA_OID_LIST +{ + /** + * The number of object IDs in the @a oids array. + */ + IMA_UINT oidCount; + + /** + * A variable length array of zero or more object IDs. There are + * 'oidCount' object IDs in this array. + */ + IMA_OID oids[1]; + +} IMA_OID_LIST; + +#define IMA_HOST_NAME_LEN 256 +typedef IMA_WCHAR IMA_HOST_NAME[IMA_HOST_NAME_LEN]; +typedef IMA_BYTE IMA_MAC_ADDRESS[6]; + +/** +******************************************************************************* +* +* Declaration of the IMA_LIBRARY_PROPERTIES structure +* +******************************************************************************* +*/ +typedef struct _IMA_LIBRARY_PROPERTIES +{ + /** + * The version of the iSCSI Management API implemented by the library. + * The value returned by a library for the API as described in this + * document is one. + */ + IMA_UINT supportedImaVersion; + + /** + * A nul terminated ASCII string containing the name of the vendor that + * created the binary version of the library. + */ + IMA_WCHAR vendor[256]; + + /** + * A nul terminated ASCII string containing the implementation version + * of the library from the vendor specified in the 'vendor' field. + */ + IMA_WCHAR implementationVersion[256]; + + /** + * A nul terminated ASCII string ideally containing the path and file + * name of the library that is being used by the currently executing + * process can be found. If the path cannot be determined then it is + * acceptable to fill this field with only the name (and extension if + * applicable) of the file of the library. If this cannot be determined + * then this field should be an empty string. + */ + IMA_WCHAR fileName[256]; + + /** + * The time and date that the library that is executing was built. + */ + IMA_DATETIME buildTime; + + IMA_BYTE reserved[64]; +} IMA_LIBRARY_PROPERTIES; + + + +/** +******************************************************************************* +* +* Declaration of the IMA_PLUGIN_PROPERTIES structure +* +******************************************************************************* +*/ +typedef struct _IMA_PLUGIN_PROPERTIES +{ + IMA_UINT supportedImaVersion; + IMA_WCHAR vendor[256]; + IMA_WCHAR implementationVersion[256]; + IMA_WCHAR fileName[256]; + IMA_DATETIME buildTime; + + IMA_BOOL lhbasCanBeCreatedAndDestroyed; + + IMA_BYTE reserved[64]; + +} IMA_PLUGIN_PROPERTIES; + + +typedef struct _IMA_IP_ADDRESS +{ + IMA_BOOL ipv4Address; + IMA_BYTE ipAddress[16]; + +} IMA_IP_ADDRESS; + +typedef struct _IMA_ADDRESS_KEY +{ + IMA_IP_ADDRESS ipAddress; + IMA_UINT16 portNumber; + +} IMA_ADDRESS_KEY; + +typedef struct _IMA_ADDRESS_KEYS +{ + IMA_UINT addressKeyCount; + IMA_ADDRESS_KEY addressKeys[1]; + +} IMA_ADDRESS_KEYS; + +typedef struct _IMA_ADDRESS_KEY_PROPERTIES +{ + IMA_UINT addressKeyCount; + IMA_ADDRESS_KEY addressKeys[1]; + +} IMA_ADDRESS_KEY_PROPERTIES; + +typedef struct _IMA_IP_PROPERTIES +{ + IMA_BOOL ipConfigurationMethodSettable; + IMA_BOOL dhcpConfigurationEnabled; + + IMA_BOOL subnetMaskSettable; + IMA_BOOL subnetMaskValid; + IMA_IP_ADDRESS subnetMask; + + IMA_BOOL defaultGatewaySettable; + IMA_BOOL defaultGatewayValid; + IMA_IP_ADDRESS defaultGateway; + + IMA_BOOL primaryDnsServerAddressSettable; + IMA_BOOL primaryDnsServerAddressValid; + IMA_IP_ADDRESS primaryDnsServerAddress; + + IMA_BOOL alternateDnsServerAddressSettable; + IMA_BOOL alternateDnsServerAddressValid; + IMA_IP_ADDRESS alternateDnsServerAddress; + + IMA_BYTE reserved[64]; + +} IMA_IP_PROPERTIES; + +typedef struct _IMA_HOST_ID +{ + IMA_BOOL hostnameInUse; + union { + + IMA_HOST_NAME hostname; + IMA_IP_ADDRESS ipAddress; + + } id; + +} IMA_HOST_ID; + +typedef struct _IMA_TARGET_ADDRESS +{ + IMA_HOST_ID hostnameIpAddress; + IMA_UINT16 portNumber; + +} IMA_TARGET_ADDRESS; + +/** +******************************************************************************* +* +* Declaration of the IMA_NODE_NAME type +* +******************************************************************************* +*/ +#define IMA_NODE_NAME_LEN 224 +typedef IMA_WCHAR IMA_NODE_NAME[IMA_NODE_NAME_LEN]; + + + +/** +******************************************************************************* +* +* Declaration of the IMA_NODE_ALIAS type +* +******************************************************************************* +*/ +#define IMA_NODE_ALIAS_LEN 256 +typedef IMA_WCHAR IMA_NODE_ALIAS[IMA_NODE_ALIAS_LEN]; + + + +/** +******************************************************************************* +* +* Declaration of the IMA_DOMAIN_NAME type +* +* A variable of this type may be formatted in any of the following four ways: +* 1. An empty string, which indicates that no host or IP address is +* specified +* 2. A DNS host name +* 3. A dotted-decimal IPv4 address +* 4. A bracketed IPv6 address as specified in RFC 2732 +* +* In all cases a domain name is terminated by a nul character. +* This type is used by several APIs: IMA_SetPhbaSnsDiscovery(), +* IMA_SetNetworkPortalIpAddress(), and indirectly by +* IMA_GetPhbaDiscoveryProperties(). +* +******************************************************************************* +*/ +typedef wchar_t IMA_DOMAIN_NAME[256]; + +typedef struct _IMA_PHBA_DOWNLOAD_IMAGE_PROPERTIES +{ + IMA_PHBA_DOWNLOAD_IMAGE_TYPE imageType; + IMA_WCHAR version[32]; + IMA_WCHAR description[512]; + IMA_XBOOL upgrade; +} IMA_PHBA_DOWNLOAD_IMAGE_PROPERTIES; + + +/** +******************************************************************************* +* +* Declaration of the IMA_NODE_PROPERTIES structure +* +* This structure is returned by the IMA_GetNodeProperties() API. +* +* NOTE: It is possible for both 'runningInInitiatorMode' and +* 'runningInTargetMode' to be set to @c IMA_TRUE. This means that +* the node is operating both as an initiator and as a target. +* +******************************************************************************* +*/ +typedef struct _IMA_NODE_PROPERTIES +{ + /** + * A boolean indicating if the node is running as initiator or not. + */ + IMA_BOOL runningInInitiatorMode; + + /** + * A boolean indicating if the node is running as a target or not. + */ + IMA_BOOL runningInTargetMode; + + /** + * A boolean which indicates if the node's name is set or not. + */ + IMA_BOOL nameValid; + + /** + * A nul terminated Unicode string which contains the name of the node. + * The value in this field is only valid if 'nameValid' is set to + * IMA_TRUE, in which case it will be Unicode NULL terminated. If + * 'nameValid' is set to IMA_FALSE then this field will contain an + * empty string. + */ + IMA_NODE_NAME name; + + /** + * A boolean which indicates if the node's alias is set or not. + */ + IMA_BOOL aliasValid; + + /** + * A nul terminated Unicode string which contains the alias of the node. + * This field is only valid if 'aliasValid' is set to IMA_TRUE, in which + * case it will be Unicode NULL terminated. If 'aliasValid' is set to + * IMA_FALSE then this field will contain an empty string. + */ + IMA_NODE_ALIAS alias; + + /* + * Boolean indicating if both the name and alias are settable using + * IMA_SetNodeName() and IMA_SetNodeAlias(). + */ + IMA_BOOL nameAndAliasSettable; + + IMA_BYTE reserved[64]; + +} IMA_NODE_PROPERTIES; + + + +/** +******************************************************************************* +* +* Declaration of the IMA_LHBA_PROPERTIES structure +* +* This structure is returned by the IMA_GetLhbaProperties() API. +* +******************************************************************************* +*/ +typedef struct _IMA_LHBA_PROPERTIES +{ + IMA_WCHAR osDeviceName[256]; + IMA_BOOL luExposingSupported; + IMA_BOOL isDestroyable; + + IMA_BOOL staleDataRemovable; + IMA_UINT staleDataSize; + + IMA_BOOL initiatorAuthMethodsSettable; + IMA_BOOL targetAuthMethodsSettable; + + IMA_BYTE reserved[128]; +} IMA_LHBA_PROPERTIES; + + + +/** +******************************************************************************* +* +* Declaration of the IMA_ULP_xxx constants +* +******************************************************************************* +*/ +#define IMA_ULP_TCP 0x01 +#define IMA_ULP_SCTP 0x02 +#define IMA_ULP_UDP 0x04 + + + +/** +******************************************************************************* +* +* Declaration of the IMA_MIN_MAX_VALUE structure +* +* Note: If the 'currentValueValid' field is IMA_FALSE then the value of +* 'settable' must also be set to IMA_FALSE. +* +* Note: The fields in this structure contain values which are defined by the +* implementation and not by the iSCSI specification. It is possible +* that an implementation may be more or less restrictive in the values +* that it can accept than the iSCSI specification allows. +* +* Note: An example of how to use 'incrementValue': Suppose that a structure is +* obtained where 'currentValueValid' is IMA_TRUE, 'settable' is +* IMA_TRUE, 'currentValue' is 50, 'defaultValue' is 50, 'minimumValue' +* is 30, 'maximumValue' is 70 and 'incrementValue' is 10. In this case, +* the possible values that the property can be set to are 30, 40, 50, +* 60, and 70. The new value must be the current value plus or minus +* some multiple of 'incrementValue'. +* +******************************************************************************* +*/ +typedef struct _IMA_MIN_MAX_VALUE +{ + /** + * A boolean indicating if the @a currentValue field contains a valid value. + */ + IMA_BOOL currentValueValid; + + /** + * Indicates if the corresponding property is settable. If this field + * has the value IMA_TRUE then the 'defaultValue', 'minimumValue', + * 'maximumValue', and 'incrementValue' fields shall contain valid + * values. If this field has the value IMA_FALSE then these fields + * have undefined values. + */ + IMA_BOOL settable; + + /** + * If currentValueValid has the value IMA_TRUE then this field contains + * the current value of the associated property. If 'currentValueValid' has + * the value IMA_FALSE then the value of this field is undefined. + */ + IMA_UINT32 currentValue; + + /** + * If 'settable' has the value IMA_TRUE then this field contains the + * implementation's default value of the associated property. If 'settable' + * has the value IMA_FALSE then the value of this field is undefined. + */ + IMA_UINT32 defaultValue; + + /** + * If 'settable' has the value IMA_TRUE then this field contains the + * implementation's minimum value of the associated property. If 'settable' + * has the value IMA_FALSE then the value of this field is undefined. + */ + IMA_UINT32 minimumValue; + + /** + * If 'settable' has the value IMA_TRUE then this field contains the + * implementation's maximum value of the associated property. If 'settable' + * has the value IMA_FALSE then the value of this field is undefined. + */ + IMA_UINT32 maximumValue; + + /** + * If 'settable' has the value IMA_TRUE then this field contains a value + * which can be added to or subtracted from 'currentValue' to obtain other + * possible values of the associated property. If 'settable' has the value + * IMA_FALSE then the value of this field is undefined. + */ + IMA_UINT32 incrementValue; + +} IMA_MIN_MAX_VALUE; + +typedef struct _IMA_BOOL_VALUE +{ + IMA_BOOL currentValueValid; + IMA_BOOL settable; + IMA_BOOL currentValue; + IMA_BOOL defaultValue; +} IMA_BOOL_VALUE; + +/** +******************************************************************************* +* +* Declaration of the IMA_PHBA_PROPERTIES structure +* +* This structure is returned by the IMA_GetPhbaProperties() API. +* +* Note: Both 'isInitiator' and 'isTarget' cannot be set to IMA_FALSE as this +* would mean that the PHBA was not functioning as either an initiator or +* target, which means that its not functioning at all. +* +******************************************************************************* +*/ +typedef struct _IMA_PHBA_PROPERTIES +{ + /** + * A nul terminated ASCII string which contains the name of the vendor + * of a PHBA. If the first character in this field is nul then the + * vendor is unknown. + */ + IMA_WCHAR vendor[64]; + + /** + * A nul terminated ASCII string which contains the name of the model of + * a PHBA. If the first character in this field is nul then the model is + * unknown. + */ + IMA_WCHAR model[256]; + + /** + * A nul terminated ASCII string which contains a description of a PHBA. + * This is a user friendly description of the PHBA. If the first character + * in this field is nul then there is no description. + */ + IMA_WCHAR description[256]; + + /** + * A nul terminated ASCII string which contains the serial number of a + * PHBA. If the first character in this field is nul then the serial + * number is unknown. + */ + IMA_WCHAR serialNumber[64]; + + /** + * A nul terminated ASCII string which contains the hardware version of + * a PHBA. If the first character in this field is nul then the hardware + * version is unknown. + */ + IMA_WCHAR hardwareVersion[256]; + + /** + * A nul terminated ASCII string which contains the ASIC version of a + * PHBA. If the first character in this field is nul then the ASIC + * version is unknown or is not applicable. + */ + IMA_WCHAR asicVersion[256]; + + /** + * A nul terminated ASCII string which contains the firmware version of + * a PHBA. If the first character in this field is nul then the firmware + * version is unknown or is not applicable. + */ + IMA_WCHAR firmwareVersion[256]; + + /** + * A nul terminated ASCII string which contains the option ROM version + * of a PHBA. If the first character in this field is nul then the option + * ROM version is unknown or is not applicable. + */ + IMA_WCHAR optionRomVersion[256]; + + /** + * A nul terminated ASCII string which contains the name of the driver + * controlling a PHBA. If the first character in this field is nul then + * the name of the driver is unknown. + */ + IMA_WCHAR driverName[256]; + + /** + * A nul terminated ASCII string which contains the version of the driver + * specified in 'driverName'. If the first character in this field is nul + * then the version of the driver is unknown. + * + * This field can have a known value only if @a driverName has a known + * value as well. + */ + IMA_WCHAR driverVersion[256]; + + /** + * A field containing flags which indicate what upper level protocols + * are supported by a PHBA. Examples of upper level protocols include: + * + * - TCP, represented by IMA_ULP_TCP + * - SCTP, represented by IMA_ULP_SCTP + * - UDP, represented by IMA_ULP_UDP + */ + IMA_UINT supportedUlps; + + /** + * A extended boolean which indicates if a PHBA supports executing SCSI + * commands which cause bidirectional transfers. + * + * Note: The value of this field applies to the entire stack: + * the hardware, ASIC, firmware, driver, etc. All must support SCSI + * commands which cause bidirectional transfers for this field to be + * set to IMA_TRUE. + */ + IMA_XBOOL bidirectionalTransfersSupported; + + /** + * The maximum length, in bytes, of a CDB that can be transferred by + * this PHBA. If this field has a value of zero that indicates that + * this value is unknown. + * + * Note: The value of this field applies to the entire stack: + * the hardware, ASIC, firmware, driver, etc. All must support the + * maximum CDB length returned in this field. + */ + IMA_UINT maximumCdbLength; + + /** + * An extended boolean which indicates if a PHBA can also function as + * a standard NIC concurrently with functioning as an iSCSI PHBA. + */ + IMA_XBOOL canBeNic; + + /** + * A extended boolean which indicates if a PHBA is functioning as a + * standard NIC concurrently with functioning as an iSCSI PHBA. + */ + IMA_XBOOL isNic; + + /** + * An extended boolean indicating if the PHBA is functioning as an + * initiator. + */ + IMA_XBOOL isInitiator; + + /** + * An extended boolean indicating if the PHBA is functioning as a target. + */ + IMA_XBOOL isTarget; + + /** + * An extended boolean indicating if the PHBA is using a TCP offload engine. + * + * Note: This value should only be set to @c IMA_TRUE if a TCP offload + * engine is present and is being used. If it can be determined that a + * TCP offload engine is present, but it cannot be determined if that + * offload engine is being used then this value should be set to + * IMA_UNKNOWN. + */ + IMA_XBOOL usingTcpOffloadEngine; + + /** + * An extended boolean indicating if the PHBA is using a iSCSI offload + * engine. + * + * Note: This value should only be set to @c IMA_TRUE if a iSCSI offload + * engine is present and is being used. If it can be determined that an + * iSCSI offload engine is present, but it cannot be determined if that + * offload engine is being used then this value should be set to + * IMA_UNKNOWN. + */ + IMA_XBOOL usingIscsiOffloadEngine; + + IMA_BYTE reserved[128]; + +} IMA_PHBA_PROPERTIES; + +/** +******************************************************************************* +* +* Declaration of the IMA_DISCOVERY_PROPERTIES structure +* +******************************************************************************* +*/ +typedef struct _IMA_DISCOVERY_PROPERTIES +{ + IMA_BOOL iSnsDiscoverySettable; + IMA_XBOOL iSnsDiscoveryEnabled; + IMA_ISNS_DISCOVERY_METHOD iSnsDiscoveryMethod; + IMA_HOST_ID iSnsHost; + + IMA_BOOL slpDiscoverySettable; + IMA_XBOOL slpDiscoveryEnabled; + + IMA_BOOL staticDiscoverySettable; + IMA_XBOOL staticDiscoveryEnabled; + + IMA_BOOL sendTargetsDiscoverySettable; + IMA_XBOOL sendTargetsDiscoveryEnabled; + + IMA_BYTE reserved[128]; +} IMA_DISCOVERY_PROPERTIES; + + +typedef struct _IMA_PHBA_DOWNLOAD_PROPERTIES +{ + IMA_BOOL isPhbaDownloadFileSupported; + IMA_BOOL optionRomDownloadSupported; + IMA_BOOL firmwareDownloadSupported; + + IMA_BYTE reserved[32]; +} IMA_PHBA_DOWNLOAD_PROPERTIES; + +typedef struct _IMA_IPSEC_PROPERTIES +{ + IMA_BOOL ipsecSupported; + IMA_BOOL implementedInHardware; + IMA_BOOL implementedInSoftware; + + IMA_BYTE reserved[32]; + +} IMA_IPSEC_PROPERTIES; + +typedef struct _IMA_LNP_PROPERTIES +{ + IMA_MAC_ADDRESS macAddress; + IMA_BOOL macAddressSettable; + IMA_BYTE reserved[32]; + +} IMA_LNP_PROPERTIES; + +typedef struct _IMA_PNP_PROPERTIES +{ + IMA_OID associatedPhbaOid; + + IMA_MAC_ADDRESS macAddress; + IMA_BOOL macAddressSettable; + + IMA_UINT maximumTransferRate; + IMA_UINT currentTransferRate; + + IMA_UINT maximumFrameSize; + + IMA_BYTE reserved[64]; +} IMA_PNP_PROPERTIES; + +typedef struct _IMA_PNP_STATISTICS +{ + IMA_UINT64 bytesSent; + IMA_UINT32 pdusSent; + IMA_UINT64 bytesReceived; + IMA_UINT32 pdusReceived; + +} IMA_PNP_STATISTICS; + +typedef struct _IMA_TARGET_PROPERTIES +{ + IMA_OID associatedNodeOid; + IMA_OID associatedLhbaOid; + + IMA_NODE_NAME name; + IMA_NODE_ALIAS alias; + IMA_UINT32 discoveryMethodFlags; + + IMA_BOOL sendTargetsDiscoverySettable; + IMA_BOOL sendTargetsDiscoveryEnabled; + + IMA_BYTE reserved[128]; + +} IMA_TARGET_PROPERTIES; + +typedef struct _IMA_CONNECTION_PROPERTIES +{ + IMA_OID associatedSessionOid; + IMA_UINT16 connectionId; + IMA_DIGEST_TYPE dataDigest; + IMA_DIGEST_TYPE headerDigest; + IMA_BOOL ifMarker; + IMA_UINT32 ifMarkInt; + IMA_UINT32 maxRecvDataSegmentLength; + IMA_UINT32 maxTransmitDataSegmentLength; + IMA_BOOL ofMarker; + IMA_UINT32 ofMarkInt; +} IMA_CONNECTION_PROPERTIES; + + +typedef struct _IMA_SESSION_PROPERTIES +{ + IMA_OID associatedLhbaOid; + IMA_AUTHMETHOD authMethod; + IMA_BOOL dataPduInOrder; + IMA_BOOL dataSequenceInOrder; + IMA_UINT16 defaultTime2Retain; + IMA_UINT16 defaultTime2Wait; + IMA_UINT16 errorRecoveryLevel; + IMA_UINT32 firstBurstLength; + IMA_BOOL immediateData; + IMA_BOOL initialR2T; + IMA_BYTE isid[6]; + IMA_UINT32 maxBurstLength; + IMA_UINT16 maxConnections; + IMA_UINT16 maxOutstandingR2T; + IMA_UINT16 targetPortalGroupTag; + IMA_UINT16 tsih; +} IMA_SESSION_PROPERTIES; + + +typedef struct _IMA_TARGET_ERROR_STATISTICS +{ + IMA_BOOL loginFailedCountValid; + IMA_UINT32 loginFailedCount; + + IMA_BOOL sessionFailedCountValid; + IMA_UINT32 sessionFailedCount; + + IMA_BOOL headerOrDigestSessionFailedCountValid; + IMA_UINT32 headerOrDigestSessionFailedCount; + + IMA_BOOL timeLimitExceededSessionFailedCountValid; + IMA_UINT32 timeLimitExceededSessionFailedCount; + + IMA_BOOL formatErrorSessionFailedCountValid; + IMA_UINT32 formatErrorSessionFailedCount; + + IMA_BOOL closedConnectionDueToTimeoutCountValid; + IMA_UINT32 closedConnectionDueToTimeoutCount; + + IMA_BOOL lastLoginFailureTimeValid; + IMA_DATETIME lastLoginFailureTime; + + IMA_BYTE reserved[64]; + +} IMA_TARGET_ERROR_STATISTICS; + +typedef struct _IMA_LU_PROPERTIES +{ + IMA_OID associatedTargetOid; + IMA_UINT64 targetLun; + + IMA_BOOL exposedToOs; + IMA_DATETIME timeExposedToOs; + + IMA_BOOL osDeviceNameValid; + IMA_WCHAR osDeviceName[64]; + + IMA_BOOL osParallelIdsValid; + IMA_UINT32 osBusNumber; + IMA_UINT32 osTargetId; + IMA_UINT32 osLun; + + IMA_BYTE reserved[128]; + +} IMA_LU_PROPERTIES; + +typedef struct _IMA_STATISTICS_PROPERTIES +{ + IMA_BOOL statisticsCollectionSettable; + IMA_BOOL statisticsCollectionEnabled; + +} IMA_STATISTICS_PROPERTIES; + +typedef struct _IMA_DEVICE_STATISTICS +{ + IMA_UINT64 scsiPayloadBytesSent; + IMA_UINT64 scsiPayloadBytesReceived; + + IMA_UINT64 iScsiPduBytesSent; + IMA_UINT64 iScsiPduBytesReceived; + + IMA_UINT64 iScsiPdusSent; + IMA_UINT64 iScsiPdusReceived; + + IMA_UINT64 millisecondsSpentSending; + IMA_UINT64 millisecondsSpentReceiving; + +} IMA_DEVICE_STATISTICS; + +typedef struct _IMA_NETWORK_PORTAL_PROPERTIES +{ + IMA_IP_ADDRESS ipAddress; + IMA_OID associatedLnp; + + IMA_BYTE reserved[32]; +} IMA_NETWORK_PORTAL_PROPERTIES; + +typedef void (* IMA_OBJECT_VISIBILITY_FN)( + IMA_BOOL becomingVisible, + IMA_OID oid +); + +typedef void (* IMA_OBJECT_PROPERTY_FN)( + IMA_OID oid +); + +typedef struct _IMA_CHAP_INITIATOR_AUTHPARMS +{ + + IMA_UINT retries; + + IMA_BYTE name[512]; + IMA_UINT nameLength; + + IMA_UINT minValueLength; + IMA_UINT maxValueLength; + + IMA_BYTE challengeSecret[256]; + IMA_UINT challengeSecretLength; + + IMA_BYTE reserved[512]; + +} IMA_CHAP_INITIATOR_AUTHPARMS; + +typedef struct _IMA_SRP_INITIATOR_AUTHPARMS +{ + + IMA_BYTE userName[512]; + IMA_UINT userNameLength; + + IMA_BYTE reserved[512]; + +} IMA_SRP_INITIATOR_AUTHPARMS; + +typedef struct _IMA_KRB5_INITIATOR_AUTHPARMS +{ + + IMA_BYTE clientKey[1024]; + IMA_UINT clientKeyLength; + + IMA_BYTE reserved[2048]; + +} IMA_KRB5_INITIATOR_AUTHPARMS; + +typedef struct _IMA_SPKM_INITIATOR_AUTHPARMS +{ + + IMA_BYTE privateKey[4096]; + IMA_UINT privateKeyLength; + + IMA_BYTE publicKey[4096]; + IMA_UINT publicKeyLength; + + IMA_BYTE reserved[4096]; + +} IMA_SPKM_INITIATOR_AUTHPARMS; + +typedef union _IMA_INITIATOR_AUTHPARMS +{ + + IMA_CHAP_INITIATOR_AUTHPARMS chapParms; + IMA_SRP_INITIATOR_AUTHPARMS srpParms; + IMA_KRB5_INITIATOR_AUTHPARMS kerberosParms; + IMA_SPKM_INITIATOR_AUTHPARMS spkmParms; + +} IMA_INITIATOR_AUTHPARMS; + + +typedef struct _IMA_STATIC_DISCOVERY_TARGET +{ + IMA_NODE_NAME targetName; + IMA_TARGET_ADDRESS targetAddress; + +} IMA_STATIC_DISCOVERY_TARGET; + +typedef struct _IMA_DISCOVERY_ADDRESS_PROPERTIES +{ + IMA_OID associatedNodeOid; + IMA_OID associatedLhbaOid; + IMA_TARGET_ADDRESS discoveryAddress; + +} IMA_DISCOVERY_ADDRESS_PROPERTIES; + +typedef struct _IMA_STATIC_TGT_PROPERTIES +{ + IMA_OID associatedNodeOid; + IMA_OID associatedLhbaOid; + IMA_STATIC_DISCOVERY_TARGET staticTarget; + +} IMA_STATIC_DISCOVERY_TARGET_PROPERTIES; + +typedef struct ima_plugin_info { + char PluginName[64]; + char PluginPath[256]; +#ifdef WIN32 + HINSTANCE hPlugin; /* Handle to a loaded DLL */ +#else + void* hPlugin; /* Handle to a loaded DLL */ +#endif + IMA_UINT32 ownerId; +#ifdef WIN32 + HANDLE pluginMutex; +#else + int pluginMutex; +#endif + IMA_UINT number_of_vbcallbacks; + IMA_OBJECT_VISIBILITY_FN vbcallback[IMA_MAX_CALLBACK_PER_PLUGIN]; + IMA_UINT number_of_pccallbacks; + IMA_OBJECT_PROPERTY_FN pccallback[IMA_MAX_CALLBACK_PER_PLUGIN]; +} IMA_PLUGIN_INFO, *PIMA_PLUGIN_INFO; + + +/** +******************************************************************************* +* +* The individual APIs of the IMA are declared below. +* +******************************************************************************* +*/ + +/** +******************************************************************************* +* +* Gets the properties of the IMA library that is being used. +* +* @param pProps +* A pointer to an IMA_LIBRARY_PROPERTIES structure allocated by +* the caller. On successful return this structure will contain the +* properties of the IMA library. +* +* @return An IMA_STATUS indicating if the operation was successful or if +* an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the library properties were successfully returned. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'pProps' is NULL or specifies a memory area to which +* data cannot be written. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetLibraryProperties( + IMA_LIBRARY_PROPERTIES *pProps +); + + + +/** +******************************************************************************* +* +* Gets a list of the object IDs of all currently loaded plugins. +* +* @param ppList +* A pointer to a pointer to an IMA_OID_LIST. On successful +* return this will contain a pointer to an @ref IMA_OID_LIST +* which contains the object IDs of all of the plugins currently +* loaded by the library. +* +* @return An IMA_STATUS indicating if the operation was successful or +* if an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the plugin ID list was successfully returned. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'ppList' is NULL or specifies a memory area to +* which data cannot be written. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetPluginOidList( + IMA_OID_LIST **ppList +); + + + +/** +******************************************************************************* +* +* Gets the properties of the specified vendor plugin. +* +* @param pluginOid +* The ID of the plugin whose properties are being retrieved. +* +* @param pProps +* A pointer to an @ref IMA_PLUGIN_PROPERTIES structure allocated by +* the caller. On successful return this will contain the properties +* of the plugin specified by pluginOid. +* +* @return An IMA_STATUS indicating if the operation was successful or if an +* error occurred. +* +* @retval IMA_SUCCESS +* Returned if the plugin properties were successfully returned. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'pluginOid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'pluginOid' does not specify a plugin object. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'pluginOid' refers to a plugin, but not one that +* is currently loaded. +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'pProps' is NULL or specifies a memory area to +* which data cannot be written. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetPluginProperties( + IMA_OID pluginOid, + IMA_PLUGIN_PROPERTIES *pProps +); + + + +/** +******************************************************************************* +* +* Gets the object ID for the plugin associated with the specified object ID. +* +* @param oid +* The object ID of an object that has been received from a previous +* library call. +* +* @param pPluginOid +* A pointer to an IMA_OID structure allocated by the caller. On +* successful return this will contain the object ID of the plugin +* associated with the object specified by @a objectId. This +* can then be used to work with the plugin, e.g., to get the +* properties of the plugin or the send the plugin an IOCtl. +* +* @return An IMA_STATUS indicating if the operation was successful or if +* an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the associated plugin ID was successfully returned. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'pPluginOid' is NULL or specifies a memory area to +* which data cannot be written. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'oid' specifies an object not owned by a plugin, but +* instead one that is owned by the library. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'oid' specifies an object with an invalid type. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetAssociatedPluginOid( + IMA_OID oid, + IMA_OID *pPluginOid +); + + + +/** +******************************************************************************* +* +* Gets the object ID of the shared node. +* +* @param pSharedNodeOid +* A pointer to an IMA_OID structure allocated by the caller. On +* successful return it will contain the object ID of the +* shared node of the currently executing system is placed. +* +* @return An IMA_STATUS indicating if the operation was successful or +* if an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the shared node ID has been successfully retrieved. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'pSharedNodeOid' is NULL or specifies a memory area +* to which data cannot be written. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetSharedNodeOid( + IMA_OID *pSharedNodeOid +); + +IMA_API IMA_STATUS IMA_GetObjectType( + IMA_OID oid, + IMA_OBJECT_TYPE *pObjectType +); + + +/** +******************************************************************************* +* +* Gets the properties of the specified iSCSI node. +* +* @param nodeOid +* The ID of the node to get the properties of. +* +* @param pProps +* A pointer to an @ref IMA_NODE_PROPERTIES structure which on +* successful return will contain the properties of the specified node. +* +* @return An IMA_STATUS indicating if the operation was successful or if +* an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the node properties have been successfully retrieved. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'pProps' is NULL or specifies a memory area to which +* data cannot be written. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'nodeOid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'nodeOid' does not specify a node object. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'nodeOid' does not specify a node which is currently +* known to the system. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetNodeProperties( + IMA_OID nodeOid, + IMA_NODE_PROPERTIES *pProps +); + + + +/** +******************************************************************************* +* +* Sets the name of the specified node. +* +* @param nodeOid +* The object ID of the node whose name is being set. +* +* @param newName +* The new name of the node. +* +* @return An IMA_STATUS indicating if the operation was successful or +* if an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the node name was successfully changed. +* +* @retval IMA_STATUS_REBOOT_NECESSARY +* Returned if a reboot is necessary before the setting of the +* name actually takes affect. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'newName' is NULL, or specifies a memory area +* to which data cannot be written, or has a length of 0. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'nodeOid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'nodeOid' does not specify a node object. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'nodeOid' does not specify a node which is +* currently known to the system. +* +* @retval IMA_ERROR_NAME_TOO_LONG +* Returned if 'newName' contains too many characters. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_SetNodeName( + IMA_OID nodeOid, + const IMA_NODE_NAME newName +); + + + +/** +******************************************************************************* +* +* Generates a unique node name for the currently running system. +* +* @param generatedName +* On successful return contains the generated node name. +* +* @return An IMA_STATUS indicating if the operation was successful or if an +* error occurred. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'generatedname is NULL or +* specifies a memory area to which data cannot be written. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GenerateNodeName( + IMA_NODE_NAME generatedName +); + + + +/** +******************************************************************************* +* +* Sets the alias of the specified node. +* +* @param nodeOid +* The object ID of the node whose alias is being set. +* +* @param newAlias +* A pointer to a Unicode string which contains the new node alias. +* If this parameter is NULL then the current alias is deleted, in which +* case the specified node no longer has an alias. +* +* @return An IMA_STATUS indicating if the operation was successful or +* if an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the node's alias has been successfully set. +* +* @retval IMA_STATUS_REBOOT_NECESSARY +* A reboot is necessary before the setting of the alias actually +* takes effect. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'nodeOid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'nodeOid' does not specify a node object. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'nodeOid' does not specify a node which is currently +* known to the system. +* +* @retval IMA_ERROR_NAME_TOO_LONG +* Returned if 'newAlias' contains too many characters. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_SetNodeAlias( + IMA_OID nodeOid, + const IMA_NODE_ALIAS newAlias +); + + + +/** +******************************************************************************* +* +* Gets a list of the object IDs of all the logical HBAs in the system. +* +* @param ppList +* A pointer to a pointer to an @ref IMA_OID_LIST structure. On +* successful return this will contain a pointer to an +* IMA_OID_LIST which contains the object IDs of all of the +* LHBAs currently in the system. +* +* @return An IMA_STATUS indicating if the operation was successful or if +* an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the LHBA ID list has been successfully returned. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'ppList' is NULL or specifies a memory area to which +* data cannot be written. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetLhbaOidList( + IMA_OID_LIST **ppList +); + + + +/** +******************************************************************************* +* +* Gets the properties of the specified logical HBA. +* +* @param lhbaOid +* The object ID of the LHBA whose properties are being retrieved. +* +* @param pProps +* A pointer to an IMA_LHBA_PROPERTIES structure. On successful +* return this will contain the properties of the LHBA specified by +* 'lhbaOid'. +* +* @return An IMA_STATUS indicating if the operation was successful or if +* an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the properties of the specified LHBA have been +* successfully retrieved. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'pProps' is NULL or specifies a memory area to which +* data cannot be written. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'lhbaOid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'lhbaOid' does not specify a LHBA. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'lhbaOid' does not specify a LHBA which is currently +* known to the system. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetLhbaProperties( + IMA_OID lhbaOid, + IMA_LHBA_PROPERTIES *pProps +); + + + +/** +******************************************************************************* +* +* Gets a list of the object IDs of all the physical HBAs in the system. +* +* @param ppList +* A pointer to a pointer to an IMA_OID_LIST structure. On successful +* return this will contain a pointer to an IMA_OID_LIST which +* contains the object IDs of all of the PHBAs currently in the system. +* +* @return An IMA_STATUS indicating if the operation was successful or if +* an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the PHBA OID list has been successfully returned. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'ppList' is NULL or specifies a memory area to which +* data cannot be written. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetPhbaOidList( + IMA_OID_LIST **ppList +); + + + +/** +******************************************************************************* +* +* Gets the general properties of a physical HBA. +* +* @param phbaOid +* The object ID of the PHBA whose properties are being queried. +* +* @param pProps +* A pointer to an @ref IMA_PHBA_PROPERTIES structure. On successful +* return this will contain the properties of the PHBA specified by +* 'phbaOid'. +# +* @return An IMA_STATUS indicating if the operation was successful or +* if an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the properties of the specified PHBA have been +* successfully retrieved. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'pProps' is NULL or specifies a memory area to which +* data cannot be written. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'phbaOid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'phbaOid' does not specify a PHBA. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'phbaOid' does not specify a PHBA which is currently +* known to the system. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetPhbaProperties( + IMA_OID phbaOid, + IMA_PHBA_PROPERTIES *pProps +); + +/** +******************************************************************************* +* +* Frees a previously allocated IMA_OID_LIST structure. +* +* @param pMemory A pointer to an IMA_OID_LIST structure allocated by the +* library. On successful return the memory allocated by the +* list is freed. +* @return An IMA_STATUS indicating if the operation was successful or if an +* error occurred. +* @retval IMA_SUCCESS +* Returned if the specified object ID list was successfully +* freed. +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if pMemory is NULL or specifies a memory area from which +* data cannot be read. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_FreeMemory( + void *pMemory +); + + + +IMA_API IMA_STATUS IMA_GetNonSharedNodeOidList( + IMA_OID_LIST **ppList +); + + + + +/** +******************************************************************************* +* +* Gets the first burst length properties of the specified logical HBA. +* +* @param oid +* The object ID of the logical HBA to get the first burst length +* properties of. +* +* @param pProps +* A pointer to a min/max values structure. +* +* @return An IMA_STATUS indicating if the operation was successful or if an +* error occurred. +* +* @retval IMA_SUCCESS +* Returned if the first burst length properties have been +* successfully retrieved. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if pProps is NULL or specifies a memory area to which +* data cannot be written. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'oid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'oid' does not specify a LHBA. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'oid' does not specify a LHBA which is currently +* known to the system. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetFirstBurstLengthProperties( + IMA_OID oid, + IMA_MIN_MAX_VALUE *pProps +); + + +/** +******************************************************************************* +* +* Gets the max burst length properties of the specified logical HBA. +* +* @param oid +* The object ID of the logical HBA to get the max burst length +* properties of. +* +* @param pProps +* A pointer to an IMA_MIN_MAX_VALUE structure allocated by the +* caller. On successful return this structure will contain the max +* burst length properties of this LHBA. +* +* @return An IMA_STATUS indicating if the operation was successful or if +* an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the max burst length properties have been successfully +* retrieved. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if pProps is NULL or specifies a memory area to which +* data cannot be written. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'oid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'oid' does not specify a LHBA. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'oid' does not specify a LHBA which is currently +* known to the system. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetMaxBurstLengthProperties( + IMA_OID Oid, + IMA_MIN_MAX_VALUE *pProps +); + +/** +******************************************************************************* +* +* Gets the maximum receive data segment length properties of the specified +* logical HBA. +* +* @param oid +* The object ID of the logical HBA to get the max receive data +* segment length properties of. +* +* @param pProps +* A pointer to an @ref IMA_MIN_MAX_VALUE structure allocated by the +* caller. On successful return this structure will contain the max +* receive data segment length properties of this LHBA. +* +* @return An IMA_STATUS indicating if the operation was successful or if +* an error occurred. +* +* @retval IMA_SUCCESS +* Returned if the max receive data segment length properties +* have been successfully retrieved. +* +* @retval IMA_ERROR_INVALID_PARAMETER +* Returned if 'pProps' is NULL or specifies a memory area to which +* data cannot be written. +* +* @retval IMA_ERROR_INVALID_OBJECT_TYPE +* Returned if 'oid' does not specify any valid object type. +* +* @retval IMA_ERROR_INCORRECT_OBJECT_TYPE +* Returned if 'oid' does not specify a LHBA. +* +* @retval IMA_ERROR_OBJECT_NOT_FOUND +* Returned if 'oid' does not specify a LHBA which is currently +* known to the system. +* +******************************************************************************* +*/ +IMA_API IMA_STATUS IMA_GetMaxRecvDataSegmentLengthProperties( + IMA_OID oid, + IMA_MIN_MAX_VALUE *pProps +); + + +/*---------------------------------------------*/ +IMA_API IMA_STATUS IMA_PluginIOCtl( + IMA_OID pluginOid, + IMA_UINT command, + const void *pInputBuffer, + IMA_UINT inputBufferLength, + void *pOutputBuffer, + IMA_UINT *pOutputBufferLength +); + + + +IMA_API IMA_STATUS IMA_GetNetworkPortalOidList( + IMA_OID oid, + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_SetFirstBurstLength( + IMA_OID oid, + IMA_UINT firstBurstLength +); + +IMA_API IMA_STATUS IMA_SetMaxBurstLength( + IMA_OID oid, + IMA_UINT maxBurstLength +); + +IMA_API IMA_STATUS IMA_SetMaxRecvDataSegmentLength( + IMA_OID oid, + IMA_UINT maxRecvDataSegmentLength +); + +IMA_API IMA_STATUS IMA_GetMaxConnectionsProperties( + IMA_OID oid, + IMA_MIN_MAX_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetMaxConnections( + IMA_OID oid, + IMA_UINT maxConnections +); + +IMA_API IMA_STATUS IMA_GetDefaultTime2RetainProperties( + IMA_OID oid, + IMA_MIN_MAX_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetDefaultTime2Retain( + IMA_OID oid, + IMA_UINT defaultTime2Retain +); + +IMA_API IMA_STATUS IMA_GetDefaultTime2WaitProperties( + IMA_OID oid, + IMA_MIN_MAX_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetDefaultTime2Wait( + IMA_OID oid, + IMA_UINT defaultTime2Wait +); + +IMA_API IMA_STATUS IMA_GetMaxOutstandingR2TProperties( + IMA_OID oid, + IMA_MIN_MAX_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetMaxOutstandingR2T( + IMA_OID oid, + IMA_UINT maxOutstandingR2T +); + +IMA_API IMA_STATUS IMA_GetErrorRecoveryLevelProperties( + IMA_OID oid, + IMA_MIN_MAX_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetErrorRecoveryLevel( + IMA_OID oid, + IMA_UINT errorRecoveryLevel +); + +IMA_API IMA_STATUS IMA_GetInitialR2TProperties( + IMA_OID oid, + IMA_BOOL_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetInitialR2T( + IMA_OID oid, + IMA_BOOL initialR2T +); + +IMA_API IMA_STATUS IMA_GetImmediateDataProperties( + IMA_OID oid, + IMA_BOOL_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetImmediateData( + IMA_OID oid, + IMA_BOOL immediateData +); + +IMA_API IMA_STATUS IMA_GetDataPduInOrderProperties( + IMA_OID oid, + IMA_BOOL_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetDataPduInOrder( + IMA_OID oid, + IMA_BOOL dataPduInOrder +); + +IMA_API IMA_STATUS IMA_GetDataSequenceInOrderProperties( + IMA_OID oid, + IMA_BOOL_VALUE *pProps +); + +IMA_API IMA_STATUS IMA_SetDataSequenceInOrder( + IMA_OID oid, + IMA_BOOL dataSequenceInOrder +); + +IMA_API IMA_STATUS IMA_SetStatisticsCollection( + IMA_OID oid, + IMA_BOOL enableStatisticsCollection +); + +IMA_API IMA_STATUS IMA_GetNetworkPortStatus( + IMA_OID portOid, + IMA_NETWORK_PORT_STATUS *pStatus +); + +IMA_API IMA_STATUS IMA_GetTargetOidList( + IMA_OID oid, + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_RemoveStaleData( + IMA_OID lhbaOid +); + +IMA_API IMA_STATUS IMA_SetIsnsDiscovery( + IMA_OID phbaId, + IMA_BOOL enableIsnsDiscovery, + IMA_ISNS_DISCOVERY_METHOD discoveryMethod, + const IMA_HOST_ID *iSnsHost +); + +IMA_API IMA_STATUS IMA_SetSlpDiscovery( + IMA_OID phbaOid, + IMA_BOOL enableSlpDiscovery +); + +IMA_API IMA_STATUS IMA_SetStaticDiscovery( + IMA_OID phbaOid, + IMA_BOOL enableStaticDiscovery +); + +IMA_API IMA_STATUS IMA_SetSendTargetsDiscovery( + IMA_OID oid, + IMA_BOOL enableSendTargetsDiscovery +); + +IMA_API IMA_STATUS IMA_RemoveStaticDiscoveryTarget( + IMA_OID targetOid +); + +IMA_API IMA_STATUS IMA_GetIpsecProperties( + IMA_OID phbaOid, + IMA_IPSEC_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_GetPnpOidList( + IMA_OID oid, + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_GetPhbaDownloadProperties( + IMA_OID phbaOid, + IMA_PHBA_DOWNLOAD_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_IsPhbaDownloadFile( + IMA_OID phbaOid, + const IMA_WCHAR *pFileName, + IMA_PHBA_DOWNLOAD_IMAGE_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_PhbaDownload( + IMA_OID phbaOid, + IMA_PHBA_DOWNLOAD_IMAGE_TYPE imageType, + const IMA_WCHAR *pFileName +); + +IMA_API IMA_STATUS IMA_GetNetworkPortalProperties( + IMA_OID networkPortalOid, + IMA_NETWORK_PORTAL_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_SetNetworkPortalIpAddress( + IMA_OID networkPortalOid, + const IMA_IP_ADDRESS NewIpAddress +); + +IMA_API IMA_STATUS IMA_GetLnpOidList( + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_GetLnpProperties( + IMA_OID lnpOid, + IMA_LNP_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_GetPnpProperties( + IMA_OID pnpOid, + IMA_PNP_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_GetPnpStatistics( + IMA_OID pnpOid, + IMA_PNP_STATISTICS *pStats +); + +IMA_API IMA_STATUS IMA_GetTargetProperties( + IMA_OID targetOid, + IMA_TARGET_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_GetTargetErrorStatistics( + IMA_OID targetOid, + IMA_TARGET_ERROR_STATISTICS *pStats +); + +IMA_API IMA_STATUS IMA_GetLuOidList( + IMA_OID oid, + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_GetLuOid( + IMA_OID targetOid, + IMA_UINT64 lun, + IMA_OID *pluOid +); + +IMA_API IMA_STATUS IMA_GetLuProperties( + IMA_OID luOid, + IMA_LU_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_GetStatisticsProperties( + IMA_OID oid, + IMA_STATISTICS_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_GetDeviceStatistics( + IMA_OID oid, + IMA_DEVICE_STATISTICS *pStats +); + +IMA_API IMA_STATUS IMA_LuInquiry( + IMA_OID deviceOid, + IMA_BOOL evpd, + IMA_BOOL cmddt, + IMA_BYTE pageCode, + + IMA_BYTE *pOutputBuffer, + IMA_UINT *pOutputBufferLength, + + IMA_BYTE *pSenseBuffer, + IMA_UINT *pSenseBufferLength +); + +IMA_API IMA_STATUS IMA_LuReadCapacity( + IMA_OID deviceOid, + IMA_UINT cdbLength, + IMA_BYTE *pOutputBuffer, + IMA_UINT *pOutputBufferLength, + + IMA_BYTE *pSenseBuffer, + IMA_UINT *pSenseBufferLength +); + +IMA_API IMA_STATUS IMA_LuReportLuns( + IMA_OID deviceOid, + IMA_BOOL sendToWellKnownLun, + IMA_BYTE selectReport, + + IMA_BYTE *pOutputBuffer, + IMA_UINT *pOutputBufferLength, + + IMA_BYTE *pSenseBuffer, + IMA_UINT *pSenseBufferLength +); + +IMA_API IMA_STATUS IMA_ExposeLu( + IMA_OID luOid +); + +IMA_API IMA_STATUS IMA_UnexposeLu( + IMA_OID luOid +); + +IMA_API IMA_STATUS IMA_GetPhbaStatus( + IMA_OID hbaOid, + IMA_PHBA_STATUS *pStatus +); + +IMA_API IMA_STATUS IMA_RegisterForObjectVisibilityChanges ( + IMA_OBJECT_VISIBILITY_FN pClientFn +); + +IMA_API IMA_STATUS IMA_DeregisterForObjectVisibilityChanges ( + IMA_OBJECT_VISIBILITY_FN pClientFn +); + +IMA_API IMA_STATUS IMA_RegisterForObjectPropertyChanges ( + IMA_OBJECT_PROPERTY_FN pClientFn +); + +IMA_API IMA_STATUS IMA_DeregisterForObjectPropertyChanges ( + IMA_OBJECT_PROPERTY_FN pClientFn +); + + +IMA_API IMA_STATUS IMA_GetAddressKeyProperties( + IMA_OID targetOid, + IMA_ADDRESS_KEY_PROPERTIES **ppProps +); + +IMA_API IMA_STATUS IMA_GetIpProperties( + IMA_OID oid, + IMA_IP_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_SetIpConfigMethod( + IMA_OID oid, + IMA_BOOL enableDhcpIpConfiguration +); + +IMA_API IMA_STATUS IMA_SetIsnsDiscovery( + IMA_OID oid, + IMA_BOOL enableIsnsDiscovery, + IMA_ISNS_DISCOVERY_METHOD discoveryMethod, + const IMA_HOST_ID *iSnsHost +); + + +IMA_API IMA_STATUS IMA_SetSubnetMask( + IMA_OID oid, + IMA_IP_ADDRESS subnetMask +); + +IMA_API IMA_STATUS IMA_SetDnsServerAddress( + IMA_OID oid, + const IMA_IP_ADDRESS *pPrimaryDnsServerAddress, + const IMA_IP_ADDRESS *pAlternateDnsServerAddress +); + +IMA_API IMA_STATUS IMA_SetDefaultGateway( + IMA_OID oid, + IMA_IP_ADDRESS defaultGateway +); + +IMA_API IMA_STATUS IMA_GetSupportedAuthMethods( + IMA_OID lhbaOid, + IMA_BOOL getSettableMethods, + IMA_UINT *pMethodCount, + IMA_AUTHMETHOD *pMethodList +); + +IMA_API IMA_STATUS IMA_GetInUseInitiatorAuthMethods( + IMA_OID lhbaOid, + IMA_UINT *pMethodCount, + IMA_AUTHMETHOD *pMethodList +); + +IMA_API IMA_STATUS IMA_GetInitiatorAuthParms( + IMA_OID lhbaOid, + IMA_AUTHMETHOD method, + IMA_INITIATOR_AUTHPARMS *pParms +); + +IMA_API IMA_STATUS IMA_SetInitiatorAuthMethods( + IMA_OID lhbaOid, + IMA_UINT methodCount, + const IMA_AUTHMETHOD *pMethodList +); + +IMA_API IMA_STATUS IMA_SetInitiatorAuthParms( + IMA_OID lhbaOid, + IMA_AUTHMETHOD method, + const IMA_INITIATOR_AUTHPARMS *pParms +); + + +IMA_API IMA_STATUS IMA_GetStaticDiscoveryTargetOidList ( + IMA_OID oid, + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_GetStaticDiscoveryTargetProperties( + IMA_OID staticDiscoveryTargetOid, + IMA_STATIC_DISCOVERY_TARGET_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_SetStaticDiscovery( + IMA_OID oid, + IMA_BOOL enableStaticDiscovery +); + +IMA_API IMA_STATUS IMA_GetDiscoveryProperties( + IMA_OID oid, + IMA_DISCOVERY_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_AddDiscoveryAddress( + IMA_OID oid, + const IMA_TARGET_ADDRESS discoveryAddress, + IMA_OID *pDiscoveryAddressOid +); + +IMA_API IMA_STATUS IMA_AddStaticDiscoveryTarget( + IMA_OID oid, + const IMA_STATIC_DISCOVERY_TARGET staticDiscoveryTarget, + IMA_OID *pStaticDiscoveryTargetOid +); + +IMA_API IMA_STATUS IMA_GetAddressKeys( + IMA_OID targetOid, + IMA_ADDRESS_KEYS **ppKeys +); + +IMA_API IMA_STATUS IMA_GetSessionOidList ( + IMA_OID oid, + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_GetConnectionOidList ( + IMA_OID oid, + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_GetDiscoveryAddressOidList ( + IMA_OID oid, + IMA_OID_LIST **ppList +); + +IMA_API IMA_STATUS IMA_GetDiscoveryAddressProperties ( + IMA_OID discoveryAddressOid, + IMA_DISCOVERY_ADDRESS_PROPERTIES *pProps +); + +IMA_API IMA_STATUS IMA_RemoveDiscoveryAddress ( + IMA_OID oid +); + +IMA_API IMA_STATUS QIMA_SetUpdateInterval(IMA_OID pluginOid, time_t interval); + +IMA_API IMA_STATUS IMA_CommitHbaParameters (IMA_OID lhba, IMA_COMMIT_LEVEL commitLevel); + +#endif + +#ifdef __cplusplus +}; +#endif + + diff --git a/illumos-x86_64/usr/include/inet/arp.h b/illumos-x86_64/usr/include/inet/arp.h new file mode 100644 index 00000000..de0602e1 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/arp.h @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_ARP_H +#define _INET_ARP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Warning: the interfaces described in this file are private to the + * implementation. They may change at any time without notice and are not + * documented. Do not depend on them. + */ + +#define ARP_REQUEST 1 +#define ARP_RESPONSE 2 +#define RARP_REQUEST 3 +#define RARP_RESPONSE 4 + +/* Both ace_flags; must also modify arp.c in mdb */ +#define ACE_F_PERMANENT 0x0001 +#define ACE_F_PUBLISH 0x0002 +#define ACE_F_DYING 0x0004 +#define ACE_F_RESOLVED 0x0008 +/* Using bit mask extraction from target address */ +#define ACE_F_MAPPING 0x0010 +#define ACE_F_MYADDR 0x0020 /* IP claims to own this address */ +#define ACE_F_UNVERIFIED 0x0040 /* DAD not yet complete */ +#define ACE_F_AUTHORITY 0x0080 /* check for duplicate MACs */ +#define ACE_F_DEFEND 0x0100 /* single transmit (area_flags only) */ +#define ACE_F_OLD 0x0200 /* should revalidate when IP asks */ +#define ACE_F_FAST 0x0400 /* fast probe enabled */ +#define ACE_F_DELAYED 0x0800 /* rescheduled on arp_defend_rate */ +#define ACE_F_DAD_ABORTED 0x1000 /* DAD was aborted on link down */ + +/* Client Notification Codes */ +#define AR_CN_BOGON 1 +#define AR_CN_ANNOUNCE 2 +#define AR_CN_READY 3 /* DAD complete; address usable */ +#define AR_CN_FAILED 4 /* DAD failed; address unusable */ + +/* ARP Header */ +typedef struct arh_s { + uchar_t arh_hardware[2]; + uchar_t arh_proto[2]; + uchar_t arh_hlen; + uchar_t arh_plen; + uchar_t arh_operation[2]; + /* The sender and target hw/proto pairs follow */ +} arh_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_ARP_H */ diff --git a/illumos-x86_64/usr/include/inet/cc.h b/illumos-x86_64/usr/include/inet/cc.h new file mode 100644 index 00000000..d92535cd --- /dev/null +++ b/illumos-x86_64/usr/include/inet/cc.h @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2007-2008 + * Swinburne University of Technology, Melbourne, Australia. + * Copyright (c) 2009-2010 Lawrence Stewart + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. + * + * This software was developed at the Centre for Advanced Internet + * Architectures, Swinburne University of Technology, by Lawrence Stewart and + * James Healy, made possible in part by a grant from the Cisco University + * Research Program Fund at Community Foundation Silicon Valley. + * + * Portions of this software were developed at the Centre for Advanced + * Internet Architectures, Swinburne University of Technology, Melbourne, + * Australia by David Hayes under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * This software was first released in 2007 by James Healy and Lawrence Stewart + * whilst working on the NewTCP research project at Swinburne University of + * Technology's Centre for Advanced Internet Architectures, Melbourne, + * Australia, which was made possible in part by a grant from the Cisco + * University Research Program Fund at Community Foundation Silicon Valley. + * More details are available at: + * http://caia.swin.edu.au/urp/newtcp/ + */ + +#ifndef _NETINET_CC_H_ +#define _NETINET_CC_H_ + +#if (defined(_KERNEL) || defined(_KMEMUSER)) + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define CC_ALGO_NAME_MAX 16 /* max congestion control name length */ + +#define CC_DEFAULT_ALGO_NAME "sunreno" + +struct tcp_s; +struct sctp_s; + +/* CC housekeeping functions. */ +extern struct cc_algo *cc_load_algo(const char *name); +extern int cc_register_algo(struct cc_algo *add_cc); +extern int cc_deregister_algo(struct cc_algo *remove_cc); + +/* + * Wrapper around transport structs that contain same-named congestion + * control variables. Allows algos to be shared amongst multiple CC aware + * transports. + * + * In theory, this code (from FreeBSD) can be used to support pluggable + * congestion control for sctp as well as tcp. However, the support for sctp + * in FreeBSD is incomplete, and in practice "type" is ignored. cc_module.h + * provides a CCV macro which implementations can use to get a variable out of + * the protocol-appropriate structure. + * + * If FreeBSD eventually does extend support for pluggable congestion control + * to sctp, we'll need to make sure we're setting "type" appropriately or use + * a definition of CCV that ignores it. + */ +struct cc_var { + void *cc_data; /* Per-connection private algorithm data. */ + int bytes_this_ack; /* # bytes acked by the current ACK. */ + int t_bytes_acked; /* # bytes acked during current RTT */ + tcp_seq curack; /* Most recent ACK. */ + uint32_t flags; /* Flags for cc_var (see below) */ + int type; /* Indicates which ptr is valid in ccvc. */ + union ccv_container { + struct tcp_s *tcp; + struct sctp_s *sctp; + } ccvc; + uint16_t nsegs; /* # segments coalesced into current chain. */ +}; + +/* + * cc_var flags. + * + * CCF_ABC_SENTAWND is set when a full congestion window of data has been ACKed + * according to the Appropriate Byte Counting spec, defined in RFC 3465. + */ +#define CCF_ABC_SENTAWND 0x0001 /* ABC counted cwnd worth of bytes? */ +#define CCF_CWND_LIMITED 0x0002 /* Are we currently cwnd limited? */ +#define CCF_FASTRECOVERY 0x0004 /* in NewReno Fast Recovery */ +#define CCF_WASFRECOVERY 0x0008 /* was in NewReno Fast Recovery */ +#define CCF_CONGRECOVERY 0x0010 /* congestion recovery mode */ +#define CCF_WASCRECOVERY 0x0020 /* was in congestion recovery */ +/* + * In slow-start due to a retransmission timeout. This flag is enabled for the + * duration of the slow-start phase. + */ +#define CCF_RTO 0x0040 /* in slow-start due to timeout */ + +#define IN_FASTRECOVERY(flags) (flags & CCF_FASTRECOVERY) +#define ENTER_FASTRECOVERY(flags) flags |= CCF_FASTRECOVERY +#define EXIT_FASTRECOVERY(flags) flags &= ~CCF_FASTRECOVERY + +#define IN_CONGRECOVERY(flags) (flags & CCF_CONGRECOVERY) +#define ENTER_CONGRECOVERY(flags) flags |= CCF_CONGRECOVERY +#define EXIT_CONGRECOVERY(flags) flags &= ~CCF_CONGRECOVERY + +#define IN_RECOVERY(flags) (flags & (CCF_CONGRECOVERY | CCF_FASTRECOVERY)) +#define ENTER_RECOVERY(flags) flags |= (CCF_CONGRECOVERY | CCF_FASTRECOVERY) +#define EXIT_RECOVERY(flags) flags &= ~(CCF_CONGRECOVERY | CCF_FASTRECOVERY) + +/* + * ACK types passed to the ack_received() hook. + * + * CC_ACK is passed when an ACK acknowledges previously unACKed data. + * CC_DUPACK is passed when a duplicate ACK is received. The conditions under + * which an ACK is considered a duplicate ACK are defined in RFC 5681. + */ +#define CC_ACK 0x0001 /* Regular in sequence ACK. */ +#define CC_DUPACK 0x0002 /* Duplicate ACK. */ +#define CC_PARTIALACK 0x0004 /* Not yet. */ +#define CC_SACK 0x0008 /* Not yet. */ + +/* + * Congestion signal types passed to the cong_signal() hook. The highest order 8 + * bits (0x01000000 - 0x80000000) are reserved for CC algos to declare their own + * congestion signal types. + * + * The congestion signals defined here cover the following situations: + * CC_ECN: A packet with an Explicit Congestion Notification was received + * See RFC 3168. + * CC_RTO: A round-trip timeout occured. + * CC_RTO_ERR: An ACK was received for a sequence number after we fired an RTO + * for that sequence number + * CC_NDUPACK: Trigger fast retransmit based on the assumption that receiving + * N duplicate ACKs indicates packet loss rather than reordering. Fast + * retransmit is followed by fast recovery. Fast retransmit and recovery + * were originally described in RFC 2581 and were updated by RFC3782 + * (NewReno). In both RFC2581 and RFC3782, N is 3. + */ +#define CC_ECN 0x00000001 /* ECN marked packet received. */ +#define CC_RTO 0x00000002 /* RTO fired. */ +#define CC_RTO_ERR 0x00000004 /* RTO fired in error. */ +#define CC_NDUPACK 0x00000008 /* Threshold of dupack's reached. */ + +#define CC_SIGPRIVMASK 0xFF000000 /* Mask to check if sig is private. */ + +/* + * Structure to hold data and function pointers that together represent a + * congestion control algorithm. + */ +struct cc_algo { + char name[CC_ALGO_NAME_MAX]; + + /* Init CC state for a new control block. */ + int (*cb_init)(struct cc_var *ccv); + + /* Cleanup CC state for a terminating control block. */ + void (*cb_destroy)(struct cc_var *ccv); + + /* Init variables for a newly established connection. */ + void (*conn_init)(struct cc_var *ccv); + + /* Called on receipt of an ack. */ + void (*ack_received)(struct cc_var *ccv, uint16_t type); + + /* Called on detection of a congestion signal. */ + void (*cong_signal)(struct cc_var *ccv, uint32_t type); + + /* Called after exiting congestion recovery. */ + void (*post_recovery)(struct cc_var *ccv); + + /* Called when data transfer resumes after an idle period. */ + void (*after_idle)(struct cc_var *ccv); + + STAILQ_ENTRY(cc_algo) entries; +}; + +typedef int cc_walk_func_t(void *, struct cc_algo *); +extern int cc_walk_algos(cc_walk_func_t *, void *); + +/* Macro to obtain the CC algo's struct ptr. */ +#define CC_ALGO(tp) ((tp)->tcp_cc_algo) + +/* Macro to obtain the CC algo's data ptr. */ +#define CC_DATA(tp) ((tp)->tcp_ccv.cc_data) + +#ifdef __cplusplus +} +#endif + +#endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ + +#endif /* _NETINET_CC_H_ */ diff --git a/illumos-x86_64/usr/include/inet/common.h b/illumos-x86_64/usr/include/inet/common.h new file mode 100644 index 00000000..2e34c9b6 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/common.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_COMMON_H +#define _INET_COMMON_H + +/* + * WARNING: This file contains implementation-specific constants, typedefs + * and macros which may change from release to release. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define A_CNT(arr) (sizeof (arr) / sizeof (arr[0])) +#define A_END(arr) (&arr[A_CNT(arr)]) +#define A_LAST(arr) (&arr[A_CNT(arr) - 1]) + +#define nilp(t) ((t *)0) +#define nil(t) ((t)0) +#define noop + +typedef int (*pfi_t)(); +typedef void (*pfv_t)(); + +#define BE32_EQL(a, b) (((uint8_t *)a)[0] == ((uint8_t *)b)[0] && \ + ((uint8_t *)a)[1] == ((uint8_t *)b)[1] && \ + ((uint8_t *)a)[2] == ((uint8_t *)b)[2] && \ + ((uint8_t *)a)[3] == ((uint8_t *)b)[3]) +#define BE16_EQL(a, b) (((uint8_t *)a)[0] == ((uint8_t *)b)[0] && \ + ((uint8_t *)a)[1] == ((uint8_t *)b)[1]) +#define BE16_TO_U16(a) ((((uint16_t)((uint8_t *)a)[0] << 8) | \ + ((uint16_t)((uint8_t *)a)[1])) & 0xFFFF) +#define BE32_TO_U32(a) ((((uint32_t)((uint8_t *)a)[0]) << 24) | \ + (((uint32_t)((uint8_t *)a)[1]) << 16) | \ + (((uint32_t)((uint8_t *)a)[2]) << 8) | \ + ((uint32_t)((uint8_t *)a)[3])) +#define U16_TO_BE16(u, a) ((((uint8_t *)a)[0] = (uint8_t)((u) >> 8)), \ + (((uint8_t *)a)[1] = (uint8_t)(u))) +#define U32_TO_BE32(u, a) ((((uint8_t *)a)[0] = (uint8_t)((u) >> 24)), \ + (((uint8_t *)a)[1] = (uint8_t)((u) >> 16)), \ + (((uint8_t *)a)[2] = (uint8_t)((u) >> 8)), \ + (((uint8_t *)a)[3] = (uint8_t)(u))) + +/* + * Local Environment Definition, this may and should override the + * the default definitions above where the local environment differs. + */ +#include +#include + +#ifdef _BIG_ENDIAN +#define ABE32_TO_U32(p) (*((uint32_t *)p)) +#define ABE16_TO_U16(p) (*((uint16_t *)p)) +#define U16_TO_ABE16(u, p) (*((uint16_t *)p) = (u)) +#define U32_TO_ABE16(u, p) U16_TO_ABE16(u, p) +#define U32_TO_ABE32(u, p) (*((uint32_t *)p) = (u)) +#else +#define ABE16_TO_U16(p) BE16_TO_U16(p) +#define ABE32_TO_U32(p) BE32_TO_U32(p) +#define U16_TO_ABE16(u, p) U16_TO_BE16(u, p) +#define U32_TO_ABE16(u, p) U16_TO_ABE16(u, p) +#define U32_TO_ABE32(u, p) U32_TO_BE32(u, p) +#endif + +#define INET_MIN_DEV 2 /* minimum minor device number */ + +#ifdef _KERNEL +#include + +extern void *inet_minor_create(char *, dev_t, dev_t, int); +extern void inet_minor_destroy(void *); +extern dev_t inet_minor_alloc(void *); +extern void inet_minor_free(void *, dev_t); +extern void inet_freemsg(mblk_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_COMMON_H */ diff --git a/illumos-x86_64/usr/include/inet/ip.h b/illumos-x86_64/usr/include/inet/ip.h new file mode 100644 index 00000000..e52adb92 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip.h @@ -0,0 +1,3793 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1990 Mentat Inc. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 Nexenta Systems, Inc. + * Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved. + * Copyright 2019, Joyent, Inc. + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _INET_IP_H +#define _INET_IP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +#define CONN_DEBUG +#endif + +#define IP_DEBUG +/* + * The mt-streams(9F) flags for the IP module; put here so that other + * "drivers" that are actually IP (e.g., ICMP, UDP) can use the same set + * of flags. + */ +#define IP_DEVMTFLAGS D_MP +#endif /* _KERNEL */ + +#define IP_MOD_NAME "ip" +#define IP_DEV_NAME "/dev/ip" +#define IP6_DEV_NAME "/dev/ip6" + +#define UDP_MOD_NAME "udp" +#define UDP_DEV_NAME "/dev/udp" +#define UDP6_DEV_NAME "/dev/udp6" + +#define TCP_MOD_NAME "tcp" +#define TCP_DEV_NAME "/dev/tcp" +#define TCP6_DEV_NAME "/dev/tcp6" + +#define SCTP_MOD_NAME "sctp" + +#ifndef _IPADDR_T +#define _IPADDR_T +typedef uint32_t ipaddr_t; +#endif + +/* Number of bits in an address */ +#define IP_ABITS 32 +#define IPV4_ABITS IP_ABITS +#define IPV6_ABITS 128 +#define IP_MAX_HW_LEN 40 + +#define IP_HOST_MASK (ipaddr_t)0xffffffffU + +#define IP_CSUM(mp, off, sum) (~ip_cksum(mp, off, sum) & 0xFFFF) +#define IP_CSUM_PARTIAL(mp, off, sum) ip_cksum(mp, off, sum) +#define IP_BCSUM_PARTIAL(bp, len, sum) bcksum(bp, len, sum) + +#define ILL_FRAG_HASH_TBL_COUNT ((unsigned int)64) +#define ILL_FRAG_HASH_TBL_SIZE (ILL_FRAG_HASH_TBL_COUNT * sizeof (ipfb_t)) + +#define IPV4_ADDR_LEN 4 +#define IP_ADDR_LEN IPV4_ADDR_LEN +#define IP_ARP_PROTO_TYPE 0x0800 + +#define IPV4_VERSION 4 +#define IP_VERSION IPV4_VERSION +#define IP_SIMPLE_HDR_LENGTH_IN_WORDS 5 +#define IP_SIMPLE_HDR_LENGTH 20 +#define IP_MAX_HDR_LENGTH 60 + +#define IP_MAX_OPT_LENGTH (IP_MAX_HDR_LENGTH-IP_SIMPLE_HDR_LENGTH) + +#define IP_MIN_MTU (IP_MAX_HDR_LENGTH + 8) /* 68 bytes */ + +/* + * XXX IP_MAXPACKET is defined in as well. At some point the + * 2 files should be cleaned up to remove all redundant definitions. + */ +#define IP_MAXPACKET 65535 +#define IP_SIMPLE_HDR_VERSION \ + ((IP_VERSION << 4) | IP_SIMPLE_HDR_LENGTH_IN_WORDS) + +#define UDPH_SIZE 8 + +/* + * Constants and type definitions to support IP IOCTL commands + */ +#define IP_IOCTL (('i'<<8)|'p') +#define IP_IOC_IRE_DELETE 4 +#define IP_IOC_IRE_DELETE_NO_REPLY 5 +#define IP_IOC_RTS_REQUEST 7 + +/* Common definitions used by IP IOCTL data structures */ +typedef struct ipllcmd_s { + uint_t ipllc_cmd; + uint_t ipllc_name_offset; + uint_t ipllc_name_length; +} ipllc_t; + +/* IP IRE Delete Command Structure. */ +typedef struct ipid_s { + ipllc_t ipid_ipllc; + uint_t ipid_ire_type; + uint_t ipid_addr_offset; + uint_t ipid_addr_length; + uint_t ipid_mask_offset; + uint_t ipid_mask_length; +} ipid_t; + +#define ipid_cmd ipid_ipllc.ipllc_cmd + +#ifdef _KERNEL +/* + * Temporary state for ip options parser. + */ +typedef struct ipoptp_s +{ + uint8_t *ipoptp_next; /* next option to look at */ + uint8_t *ipoptp_end; /* end of options */ + uint8_t *ipoptp_cur; /* start of current option */ + uint8_t ipoptp_len; /* length of current option */ + uint32_t ipoptp_flags; +} ipoptp_t; + +/* + * Flag(s) for ipoptp_flags + */ +#define IPOPTP_ERROR 0x00000001 +#endif /* _KERNEL */ + +/* Controls forwarding of IP packets, set via ipadm(8)/ndd(8) */ +#define IP_FORWARD_NEVER 0 +#define IP_FORWARD_ALWAYS 1 + +#define WE_ARE_FORWARDING(ipst) ((ipst)->ips_ip_forwarding == IP_FORWARD_ALWAYS) + +#define IPH_HDR_LENGTH(ipha) \ + ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length & 0xF) << 2) + +#define IPH_HDR_VERSION(ipha) \ + ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length) >> 4) + +#ifdef _KERNEL +/* + * IP reassembly macros. We hide starting and ending offsets in b_next and + * b_prev of messages on the reassembly queue. The messages are chained using + * b_cont. These macros are used in ip_reassemble() so we don't have to see + * the ugly casts and assignments. + * Note that the offsets are <= 64k i.e. a uint_t is sufficient to represent + * them. + */ +#define IP_REASS_START(mp) ((uint_t)(uintptr_t)((mp)->b_next)) +#define IP_REASS_SET_START(mp, u) \ + ((mp)->b_next = (mblk_t *)(uintptr_t)(u)) +#define IP_REASS_END(mp) ((uint_t)(uintptr_t)((mp)->b_prev)) +#define IP_REASS_SET_END(mp, u) \ + ((mp)->b_prev = (mblk_t *)(uintptr_t)(u)) + +#define IP_REASS_COMPLETE 0x1 +#define IP_REASS_PARTIAL 0x2 +#define IP_REASS_FAILED 0x4 + +/* + * Test to determine whether this is a module instance of IP or a + * driver instance of IP. + */ +#define CONN_Q(q) (WR(q)->q_next == NULL) + +#define Q_TO_CONN(q) ((conn_t *)(q)->q_ptr) +#define Q_TO_TCP(q) (Q_TO_CONN((q))->conn_tcp) +#define Q_TO_UDP(q) (Q_TO_CONN((q))->conn_udp) +#define Q_TO_ICMP(q) (Q_TO_CONN((q))->conn_icmp) +#define Q_TO_RTS(q) (Q_TO_CONN((q))->conn_rts) + +#define CONNP_TO_WQ(connp) ((connp)->conn_wq) +#define CONNP_TO_RQ(connp) ((connp)->conn_rq) + +#define GRAB_CONN_LOCK(q) { \ + if (q != NULL && CONN_Q(q)) \ + mutex_enter(&(Q_TO_CONN(q))->conn_lock); \ +} + +#define RELEASE_CONN_LOCK(q) { \ + if (q != NULL && CONN_Q(q)) \ + mutex_exit(&(Q_TO_CONN(q))->conn_lock); \ +} + +/* + * Ref counter macros for ioctls. This provides a guard for TCP to stop + * tcp_close from removing the rq/wq whilst an ioctl is still in flight on the + * stream. The ioctl could have been queued on e.g. an ipsq. tcp_close will wait + * until the ioctlref count is zero before proceeding. + * Ideally conn_oper_pending_ill would be used for this purpose. However, in the + * case where an ioctl is aborted or interrupted, it can be cleared prematurely. + * There are also some race possibilities between ip and the stream head which + * can also end up with conn_oper_pending_ill being cleared prematurely. So, to + * avoid these situations, we use a dedicated ref counter for ioctls which is + * used in addition to and in parallel with the normal conn_ref count. + */ +#define CONN_INC_IOCTLREF_LOCKED(connp) { \ + ASSERT(MUTEX_HELD(&(connp)->conn_lock)); \ + DTRACE_PROBE1(conn__inc__ioctlref, conn_t *, (connp)); \ + (connp)->conn_ioctlref++; \ + mutex_exit(&(connp)->conn_lock); \ +} + +#define CONN_INC_IOCTLREF(connp) { \ + mutex_enter(&(connp)->conn_lock); \ + CONN_INC_IOCTLREF_LOCKED(connp); \ +} + +#define CONN_DEC_IOCTLREF(connp) { \ + mutex_enter(&(connp)->conn_lock); \ + DTRACE_PROBE1(conn__dec__ioctlref, conn_t *, (connp)); \ + /* Make sure conn_ioctlref will not underflow. */ \ + ASSERT((connp)->conn_ioctlref != 0); \ + if ((--(connp)->conn_ioctlref == 0) && \ + ((connp)->conn_state_flags & CONN_CLOSING)) { \ + cv_broadcast(&(connp)->conn_cv); \ + } \ + mutex_exit(&(connp)->conn_lock); \ +} + + +/* + * Complete the pending operation. Usually an ioctl. Can also + * be a bind or option management request that got enqueued + * in an ipsq_t. Called on completion of the operation. + */ +#define CONN_OPER_PENDING_DONE(connp) { \ + mutex_enter(&(connp)->conn_lock); \ + (connp)->conn_oper_pending_ill = NULL; \ + cv_broadcast(&(connp)->conn_refcv); \ + mutex_exit(&(connp)->conn_lock); \ + CONN_DEC_REF(connp); \ +} + +/* + * Values for squeue switch: + */ +#define IP_SQUEUE_ENTER_NODRAIN 1 +#define IP_SQUEUE_ENTER 2 +#define IP_SQUEUE_FILL 3 + +extern int ip_squeue_flag; + +/* IP Fragmentation Reassembly Header */ +typedef struct ipf_s { + struct ipf_s *ipf_hash_next; + struct ipf_s **ipf_ptphn; /* Pointer to previous hash next. */ + uint32_t ipf_ident; /* Ident to match. */ + uint8_t ipf_protocol; /* Protocol to match. */ + uchar_t ipf_last_frag_seen : 1; /* Last fragment seen ? */ + time_t ipf_timestamp; /* Reassembly start time. */ + mblk_t *ipf_mp; /* mblk we live in. */ + mblk_t *ipf_tail_mp; /* Frag queue tail pointer. */ + int ipf_hole_cnt; /* Number of holes (hard-case). */ + int ipf_end; /* Tail end offset (0 -> hard-case). */ + uint_t ipf_gen; /* Frag queue generation */ + size_t ipf_count; /* Count of bytes used by frag */ + uint_t ipf_nf_hdr_len; /* Length of nonfragmented header */ + in6_addr_t ipf_v6src; /* IPv6 source address */ + in6_addr_t ipf_v6dst; /* IPv6 dest address */ + uint_t ipf_prev_nexthdr_offset; /* Offset for nexthdr value */ + uint8_t ipf_ecn; /* ECN info for the fragments */ + uint8_t ipf_num_dups; /* Number of times dup frags recvd */ + uint16_t ipf_checksum_flags; /* Hardware checksum flags */ + uint32_t ipf_checksum; /* Partial checksum of fragment data */ +} ipf_t; + +/* + * IPv4 Fragments + */ +#define IS_V4_FRAGMENT(ipha_fragment_offset_and_flags) \ + (((ntohs(ipha_fragment_offset_and_flags) & IPH_OFFSET) != 0) || \ + ((ntohs(ipha_fragment_offset_and_flags) & IPH_MF) != 0)) + +#define ipf_src V4_PART_OF_V6(ipf_v6src) +#define ipf_dst V4_PART_OF_V6(ipf_v6dst) + +#endif /* _KERNEL */ + +/* ICMP types */ +#define ICMP_ECHO_REPLY 0 +#define ICMP_DEST_UNREACHABLE 3 +#define ICMP_SOURCE_QUENCH 4 +#define ICMP_REDIRECT 5 +#define ICMP_ECHO_REQUEST 8 +#define ICMP_ROUTER_ADVERTISEMENT 9 +#define ICMP_ROUTER_SOLICITATION 10 +#define ICMP_TIME_EXCEEDED 11 +#define ICMP_PARAM_PROBLEM 12 +#define ICMP_TIME_STAMP_REQUEST 13 +#define ICMP_TIME_STAMP_REPLY 14 +#define ICMP_INFO_REQUEST 15 +#define ICMP_INFO_REPLY 16 +#define ICMP_ADDRESS_MASK_REQUEST 17 +#define ICMP_ADDRESS_MASK_REPLY 18 + +/* Evaluates to true if the ICMP type is an ICMP error */ +#define ICMP_IS_ERROR(type) ( \ + (type) == ICMP_DEST_UNREACHABLE || \ + (type) == ICMP_SOURCE_QUENCH || \ + (type) == ICMP_TIME_EXCEEDED || \ + (type) == ICMP_PARAM_PROBLEM) + +/* ICMP_TIME_EXCEEDED codes */ +#define ICMP_TTL_EXCEEDED 0 +#define ICMP_REASSEMBLY_TIME_EXCEEDED 1 + +/* ICMP_DEST_UNREACHABLE codes */ +#define ICMP_NET_UNREACHABLE 0 +#define ICMP_HOST_UNREACHABLE 1 +#define ICMP_PROTOCOL_UNREACHABLE 2 +#define ICMP_PORT_UNREACHABLE 3 +#define ICMP_FRAGMENTATION_NEEDED 4 +#define ICMP_SOURCE_ROUTE_FAILED 5 +#define ICMP_DEST_NET_UNKNOWN 6 +#define ICMP_DEST_HOST_UNKNOWN 7 +#define ICMP_SRC_HOST_ISOLATED 8 +#define ICMP_DEST_NET_UNREACH_ADMIN 9 +#define ICMP_DEST_HOST_UNREACH_ADMIN 10 +#define ICMP_DEST_NET_UNREACH_TOS 11 +#define ICMP_DEST_HOST_UNREACH_TOS 12 + +/* ICMP Header Structure */ +typedef struct icmph_s { + uint8_t icmph_type; + uint8_t icmph_code; + uint16_t icmph_checksum; + union { + struct { /* ECHO request/response structure */ + uint16_t u_echo_ident; + uint16_t u_echo_seqnum; + } u_echo; + struct { /* Destination unreachable structure */ + uint16_t u_du_zero; + uint16_t u_du_mtu; + } u_du; + struct { /* Parameter problem structure */ + uint8_t u_pp_ptr; + uint8_t u_pp_rsvd[3]; + } u_pp; + struct { /* Redirect structure */ + ipaddr_t u_rd_gateway; + } u_rd; + } icmph_u; +} icmph_t; + +#define icmph_echo_ident icmph_u.u_echo.u_echo_ident +#define icmph_echo_seqnum icmph_u.u_echo.u_echo_seqnum +#define icmph_du_zero icmph_u.u_du.u_du_zero +#define icmph_du_mtu icmph_u.u_du.u_du_mtu +#define icmph_pp_ptr icmph_u.u_pp.u_pp_ptr +#define icmph_rd_gateway icmph_u.u_rd.u_rd_gateway + +#define ICMPH_SIZE 8 + +/* + * Minimum length of transport layer header included in an ICMP error + * message for it to be considered valid. + */ +#define ICMP_MIN_TP_HDR_LEN 8 + +/* Aligned IP header */ +typedef struct ipha_s { + uint8_t ipha_version_and_hdr_length; + uint8_t ipha_type_of_service; + uint16_t ipha_length; + uint16_t ipha_ident; + uint16_t ipha_fragment_offset_and_flags; + uint8_t ipha_ttl; + uint8_t ipha_protocol; + uint16_t ipha_hdr_checksum; + ipaddr_t ipha_src; + ipaddr_t ipha_dst; +} ipha_t; + +/* + * IP Flags + * + * Some of these constant names are copied for the DTrace IP provider in + * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept + * in sync. + */ +#define IPH_DF 0x4000 /* Don't fragment */ +#define IPH_MF 0x2000 /* More fragments to come */ +#define IPH_OFFSET 0x1FFF /* Where the offset lives */ + +/* Byte-order specific values */ +#ifdef _BIG_ENDIAN +#define IPH_DF_HTONS 0x4000 /* Don't fragment */ +#define IPH_MF_HTONS 0x2000 /* More fragments to come */ +#define IPH_OFFSET_HTONS 0x1FFF /* Where the offset lives */ +#else +#define IPH_DF_HTONS 0x0040 /* Don't fragment */ +#define IPH_MF_HTONS 0x0020 /* More fragments to come */ +#define IPH_OFFSET_HTONS 0xFF1F /* Where the offset lives */ +#endif + +/* ECN code points for IPv4 TOS byte and IPv6 traffic class octet. */ +#define IPH_ECN_NECT 0x0 /* Not ECN-Capable Transport */ +#define IPH_ECN_ECT1 0x1 /* ECN-Capable Transport, ECT(1) */ +#define IPH_ECN_ECT0 0x2 /* ECN-Capable Transport, ECT(0) */ +#define IPH_ECN_CE 0x3 /* ECN-Congestion Experienced (CE) */ + +struct ill_s; + +typedef void ip_v6intfid_func_t(struct ill_s *, in6_addr_t *); +typedef void ip_v6mapinfo_func_t(struct ill_s *, uchar_t *, uchar_t *); +typedef void ip_v4mapinfo_func_t(struct ill_s *, uchar_t *, uchar_t *); + +/* IP Mac info structure */ +typedef struct ip_m_s { + t_uscalar_t ip_m_mac_type; /* From */ + int ip_m_type; /* From */ + t_uscalar_t ip_m_ipv4sap; + t_uscalar_t ip_m_ipv6sap; + ip_v4mapinfo_func_t *ip_m_v4mapping; + ip_v6mapinfo_func_t *ip_m_v6mapping; + ip_v6intfid_func_t *ip_m_v6intfid; + ip_v6intfid_func_t *ip_m_v6destintfid; +} ip_m_t; + +/* + * The following functions attempt to reduce the link layer dependency + * of the IP stack. The current set of link specific operations are: + * a. map from IPv4 class D (224.0/4) multicast address range or the + * IPv6 multicast address range (ff00::/8) to the link layer multicast + * address. + * b. derive the default IPv6 interface identifier from the interface. + * c. derive the default IPv6 destination interface identifier from + * the interface (point-to-point only). + */ +extern void ip_mcast_mapping(struct ill_s *, uchar_t *, uchar_t *); +/* ip_m_v6*intfid return void and are never NULL */ +#define MEDIA_V6INTFID(ip_m, ill, v6ptr) (ip_m)->ip_m_v6intfid(ill, v6ptr) +#define MEDIA_V6DESTINTFID(ip_m, ill, v6ptr) \ + (ip_m)->ip_m_v6destintfid(ill, v6ptr) + +/* Router entry types */ +#define IRE_BROADCAST 0x0001 /* Route entry for broadcast address */ +#define IRE_DEFAULT 0x0002 /* Route entry for default gateway */ +#define IRE_LOCAL 0x0004 /* Route entry for local address */ +#define IRE_LOOPBACK 0x0008 /* Route entry for loopback address */ +#define IRE_PREFIX 0x0010 /* Route entry for prefix routes */ +#ifndef _KERNEL +/* Keep so user-level still compiles */ +#define IRE_CACHE 0x0020 /* Cached Route entry */ +#endif +#define IRE_IF_NORESOLVER 0x0040 /* Route entry for local interface */ + /* net without any address mapping. */ +#define IRE_IF_RESOLVER 0x0080 /* Route entry for local interface */ + /* net with resolver. */ +#define IRE_HOST 0x0100 /* Host route entry */ +/* Keep so user-level still compiles */ +#define IRE_HOST_REDIRECT 0x0200 /* only used for T_SVR4_OPTMGMT_REQ */ +#define IRE_IF_CLONE 0x0400 /* Per host clone of IRE_IF */ +#define IRE_MULTICAST 0x0800 /* Special - not in table */ +#define IRE_NOROUTE 0x1000 /* Special - not in table */ + +#define IRE_INTERFACE (IRE_IF_NORESOLVER | IRE_IF_RESOLVER) + +#define IRE_IF_ALL (IRE_IF_NORESOLVER | IRE_IF_RESOLVER | \ + IRE_IF_CLONE) +#define IRE_OFFSUBNET (IRE_DEFAULT | IRE_PREFIX | IRE_HOST) +#define IRE_OFFLINK IRE_OFFSUBNET +/* + * Note that we view IRE_NOROUTE as ONLINK since we can "send" to them without + * going through a router; the result of sending will be an error/icmp error. + */ +#define IRE_ONLINK (IRE_IF_ALL|IRE_LOCAL|IRE_LOOPBACK| \ + IRE_BROADCAST|IRE_MULTICAST|IRE_NOROUTE) + +/* Arguments to ire_flush_cache() */ +#define IRE_FLUSH_DELETE 0 +#define IRE_FLUSH_ADD 1 +#define IRE_FLUSH_GWCHANGE 2 + +/* + * Flags to ire_route_recursive + */ +#define IRR_NONE 0 +#define IRR_ALLOCATE 1 /* OK to allocate IRE_IF_CLONE */ +#define IRR_INCOMPLETE 2 /* OK to return incomplete chain */ + +/* + * Open/close synchronization flags. + * These are kept in a separate field in the conn and the synchronization + * depends on the atomic 32 bit access to that field. + */ +#define CONN_CLOSING 0x01 /* ip_close waiting for ip_wsrv */ +#define CONN_CONDEMNED 0x02 /* conn is closing, no more refs */ +#define CONN_INCIPIENT 0x04 /* conn not yet visible, no refs */ +#define CONN_QUIESCED 0x08 /* conn is now quiescent */ +#define CONN_UPDATE_ILL 0x10 /* conn_update_ill in progress */ + +/* + * Flags for dce_flags field. Specifies which information has been set. + * dce_ident is always present, but the other ones are identified by the flags. + */ +#define DCEF_DEFAULT 0x0001 /* Default DCE - no pmtu or uinfo */ +#define DCEF_PMTU 0x0002 /* Different than interface MTU */ +#define DCEF_UINFO 0x0004 /* dce_uinfo set */ +#define DCEF_TOO_SMALL_PMTU 0x0008 /* Smaller than IPv4 MIN */ + +#ifdef _KERNEL +/* + * Extra structures need for per-src-addr filtering (IGMPv3/MLDv2) + */ +#define MAX_FILTER_SIZE 64 + +typedef struct slist_s { + int sl_numsrc; + in6_addr_t sl_addr[MAX_FILTER_SIZE]; +} slist_t; + +/* + * Following struct is used to maintain retransmission state for + * a multicast group. One rtx_state_t struct is an in-line field + * of the ilm_t struct; the slist_ts in the rtx_state_t struct are + * alloc'd as needed. + */ +typedef struct rtx_state_s { + uint_t rtx_timer; /* retrans timer */ + int rtx_cnt; /* retrans count */ + int rtx_fmode_cnt; /* retrans count for fmode change */ + slist_t *rtx_allow; + slist_t *rtx_block; +} rtx_state_t; + +/* + * Used to construct list of multicast address records that will be + * sent in a single listener report. + */ +typedef struct mrec_s { + struct mrec_s *mrec_next; + uint8_t mrec_type; + uint8_t mrec_auxlen; /* currently unused */ + in6_addr_t mrec_group; + slist_t mrec_srcs; +} mrec_t; + +/* Group membership list per upper conn */ + +/* + * We record the multicast information from the socket option in + * ilg_ifaddr/ilg_ifindex. This allows rejoining the group in the case when + * the ifaddr (or ifindex) disappears and later reappears, potentially on + * a different ill. The IPv6 multicast socket options and ioctls all specify + * the interface using an ifindex. For IPv4 some socket options/ioctls use + * the interface address and others use the index. We record here the method + * that was actually used (and leave the other of ilg_ifaddr or ilg_ifindex) + * at zero so that we can rejoin the way the application intended. + * + * We track the ill on which we will or already have joined an ilm using + * ilg_ill. When we have succeeded joining the ilm and have a refhold on it + * then we set ilg_ilm. Thus intentionally there is a window where ilg_ill is + * set and ilg_ilm is not set. This allows clearing ilg_ill as a signal that + * the ill is being unplumbed and the ilm should be discarded. + * + * ilg records the state of multicast memberships of a socket end point. + * ilm records the state of multicast memberships with the driver and is + * maintained per interface. + * + * The ilg state is protected by conn_ilg_lock. + * The ilg will not be freed until ilg_refcnt drops to zero. + */ +typedef struct ilg_s { + struct ilg_s *ilg_next; + struct ilg_s **ilg_ptpn; + struct conn_s *ilg_connp; /* Back pointer to get lock */ + in6_addr_t ilg_v6group; + ipaddr_t ilg_ifaddr; /* For some IPv4 cases */ + uint_t ilg_ifindex; /* IPv6 and some other IPv4 cases */ + struct ill_s *ilg_ill; /* Where ilm is joined. No refhold */ + struct ilm_s *ilg_ilm; /* With ilm_refhold */ + uint_t ilg_refcnt; + mcast_record_t ilg_fmode; /* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */ + slist_t *ilg_filter; + boolean_t ilg_condemned; /* Conceptually deleted */ +} ilg_t; + +/* + * Multicast address list entry for ill. + * ilm_ill is used by IPv4 and IPv6 + * + * The ilm state (and other multicast state on the ill) is protected by + * ill_mcast_lock. Operations that change state on both an ilg and ilm + * in addition use ill_mcast_serializer to ensure that we can't have + * interleaving between e.g., add and delete operations for the same conn_t, + * group, and ill. The ill_mcast_serializer is also used to ensure that + * multicast group joins do not occur on an interface that is in the process + * of joining an IPMP group. + * + * The comment below (and for other netstack_t references) refers + * to the fact that we only do netstack_hold in particular cases, + * such as the references from open endpoints (ill_t and conn_t's + * pointers). Internally within IP we rely on IP's ability to cleanup e.g. + * ire_t's when an ill goes away. + */ +typedef struct ilm_s { + in6_addr_t ilm_v6addr; + int ilm_refcnt; + uint_t ilm_timer; /* IGMP/MLD query resp timer, in msec */ + struct ilm_s *ilm_next; /* Linked list for each ill */ + uint_t ilm_state; /* state of the membership */ + struct ill_s *ilm_ill; /* Back pointer to ill - ill_ilm_cnt */ + zoneid_t ilm_zoneid; + int ilm_no_ilg_cnt; /* number of joins w/ no ilg */ + mcast_record_t ilm_fmode; /* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */ + slist_t *ilm_filter; /* source filter list */ + slist_t *ilm_pendsrcs; /* relevant src addrs for pending req */ + rtx_state_t ilm_rtx; /* SCR retransmission state */ + ipaddr_t ilm_ifaddr; /* For IPv4 netstat */ + ip_stack_t *ilm_ipst; /* Does not have a netstack_hold */ +} ilm_t; + +#define ilm_addr V4_PART_OF_V6(ilm_v6addr) + +/* + * Soft reference to an IPsec SA. + * + * On relative terms, conn's can be persistent (living as long as the + * processes which create them), while SA's are ephemeral (dying when + * they hit their time-based or byte-based lifetimes). + * + * We could hold a hard reference to an SA from an ipsec_latch_t, + * but this would cause expired SA's to linger for a potentially + * unbounded time. + * + * Instead, we remember the hash bucket number and bucket generation + * in addition to the pointer. The bucket generation is incremented on + * each deletion. + */ +typedef struct ipsa_ref_s +{ + struct ipsa_s *ipsr_sa; + struct isaf_s *ipsr_bucket; + uint64_t ipsr_gen; +} ipsa_ref_t; + +/* + * IPsec "latching" state. + * + * In the presence of IPsec policy, fully-bound conn's bind a connection + * to more than just the 5-tuple, but also a specific IPsec action and + * identity-pair. + * The identity pair is accessed from both the receive and transmit side + * hence it is maintained in the ipsec_latch_t structure. conn_latch and + * ixa_ipsec_latch points to it. + * The policy and actions are stored in conn_latch_in_policy and + * conn_latch_in_action for the inbound side, and in ixa_ipsec_policy and + * ixa_ipsec_action for the transmit side. + * + * As an optimization, we also cache soft references to IPsec SA's in + * ip_xmit_attr_t so that we can fast-path around most of the work needed for + * outbound IPsec SA selection. + */ +typedef struct ipsec_latch_s +{ + kmutex_t ipl_lock; + uint32_t ipl_refcnt; + + struct ipsid_s *ipl_local_cid; + struct ipsid_s *ipl_remote_cid; + unsigned int + ipl_ids_latched : 1, + + ipl_pad_to_bit_31 : 31; +} ipsec_latch_t; + +#define IPLATCH_REFHOLD(ipl) { \ + atomic_inc_32(&(ipl)->ipl_refcnt); \ + ASSERT((ipl)->ipl_refcnt != 0); \ +} + +#define IPLATCH_REFRELE(ipl) { \ + ASSERT((ipl)->ipl_refcnt != 0); \ + membar_exit(); \ + if (atomic_dec_32_nv(&(ipl)->ipl_refcnt) == 0) \ + iplatch_free(ipl); \ +} + +/* + * peer identity structure. + */ +typedef struct conn_s conn_t; + +/* + * This is used to match an inbound/outbound datagram with policy. + */ +typedef struct ipsec_selector { + in6_addr_t ips_local_addr_v6; + in6_addr_t ips_remote_addr_v6; + uint16_t ips_local_port; + uint16_t ips_remote_port; + uint8_t ips_icmp_type; + uint8_t ips_icmp_code; + uint8_t ips_protocol; + uint8_t ips_isv4 : 1, + ips_is_icmp_inv_acq: 1; +} ipsec_selector_t; + +/* + * Note that we put v4 addresses in the *first* 32-bit word of the + * selector rather than the last to simplify the prefix match/mask code + * in spd.c + */ +#define ips_local_addr_v4 ips_local_addr_v6.s6_addr32[0] +#define ips_remote_addr_v4 ips_remote_addr_v6.s6_addr32[0] + +/* Values used in IP by IPSEC Code */ +#define IPSEC_OUTBOUND B_TRUE +#define IPSEC_INBOUND B_FALSE + +/* + * There are two variants in policy failures. The packet may come in + * secure when not needed (IPSEC_POLICY_???_NOT_NEEDED) or it may not + * have the desired level of protection (IPSEC_POLICY_MISMATCH). + */ +#define IPSEC_POLICY_NOT_NEEDED 0 +#define IPSEC_POLICY_MISMATCH 1 +#define IPSEC_POLICY_AUTH_NOT_NEEDED 2 +#define IPSEC_POLICY_ENCR_NOT_NEEDED 3 +#define IPSEC_POLICY_SE_NOT_NEEDED 4 +#define IPSEC_POLICY_MAX 5 /* Always max + 1. */ + +/* + * Check with IPSEC inbound policy if + * + * 1) per-socket policy is present - indicated by conn_in_enforce_policy. + * 2) Or if we have not cached policy on the conn and the global policy is + * non-empty. + */ +#define CONN_INBOUND_POLICY_PRESENT(connp, ipss) \ + ((connp)->conn_in_enforce_policy || \ + (!((connp)->conn_policy_cached) && \ + (ipss)->ipsec_inbound_v4_policy_present)) + +#define CONN_INBOUND_POLICY_PRESENT_V6(connp, ipss) \ + ((connp)->conn_in_enforce_policy || \ + (!(connp)->conn_policy_cached && \ + (ipss)->ipsec_inbound_v6_policy_present)) + +#define CONN_OUTBOUND_POLICY_PRESENT(connp, ipss) \ + ((connp)->conn_out_enforce_policy || \ + (!((connp)->conn_policy_cached) && \ + (ipss)->ipsec_outbound_v4_policy_present)) + +#define CONN_OUTBOUND_POLICY_PRESENT_V6(connp, ipss) \ + ((connp)->conn_out_enforce_policy || \ + (!(connp)->conn_policy_cached && \ + (ipss)->ipsec_outbound_v6_policy_present)) + +/* + * Information cached in IRE for upper layer protocol (ULP). + */ +typedef struct iulp_s { + boolean_t iulp_set; /* Is any metric set? */ + uint32_t iulp_ssthresh; /* Slow start threshold (TCP). */ + clock_t iulp_rtt; /* Guestimate in millisecs. */ + clock_t iulp_rtt_sd; /* Cached value of RTT variance. */ + uint32_t iulp_spipe; /* Send pipe size. */ + uint32_t iulp_rpipe; /* Receive pipe size. */ + uint32_t iulp_rtomax; /* Max round trip timeout. */ + uint32_t iulp_sack; /* Use SACK option (TCP)? */ + uint32_t iulp_mtu; /* Setable with routing sockets */ + + uint32_t + iulp_tstamp_ok : 1, /* Use timestamp option (TCP)? */ + iulp_wscale_ok : 1, /* Use window scale option (TCP)? */ + iulp_ecn_ok : 1, /* Enable ECN (for TCP)? */ + iulp_pmtud_ok : 1, /* Enable PMTUd? */ + + /* These three are passed out by ip_set_destination */ + iulp_localnet: 1, /* IRE_ONLINK */ + iulp_loopback: 1, /* IRE_LOOPBACK */ + iulp_local: 1, /* IRE_LOCAL */ + + iulp_not_used : 25; +} iulp_t; + +/* + * The conn drain list structure (idl_t), protected by idl_lock. Each conn_t + * inserted in the list points back at this idl_t using conn_idl, and is + * chained by conn_drain_next and conn_drain_prev, which are also protected by + * idl_lock. When flow control is relieved, either ip_wsrv() (STREAMS) or + * ill_flow_enable() (non-STREAMS) will call conn_drain(). + * + * The conn drain list, idl_t, itself is part of tx cookie list structure. + * A tx cookie list points to a blocked Tx ring and contains the list of + * all conn's that are blocked due to the flow-controlled Tx ring (via + * the idl drain list). Note that a link can have multiple Tx rings. The + * drain list will store the conn's blocked due to Tx ring being flow + * controlled. + */ + +typedef uintptr_t ip_mac_tx_cookie_t; +typedef struct idl_s idl_t; +typedef struct idl_tx_list_s idl_tx_list_t; + +struct idl_tx_list_s { + ip_mac_tx_cookie_t txl_cookie; + kmutex_t txl_lock; /* Lock for this list */ + idl_t *txl_drain_list; + int txl_drain_index; +}; + +struct idl_s { + conn_t *idl_conn; /* Head of drain list */ + kmutex_t idl_lock; /* Lock for this list */ + idl_tx_list_t *idl_itl; +}; + +/* + * Interface route structure which holds the necessary information to recreate + * routes that are tied to an interface i.e. have ire_ill set. + * + * These routes which were initially created via a routing socket or via the + * SIOCADDRT ioctl may be gateway routes (RTF_GATEWAY being set) or may be + * traditional interface routes. When an ill comes back up after being + * down, this information will be used to recreate the routes. These + * are part of an mblk_t chain that hangs off of the ILL (ill_saved_ire_mp). + */ +typedef struct ifrt_s { + ushort_t ifrt_type; /* Type of IRE */ + in6_addr_t ifrt_v6addr; /* Address IRE represents. */ + in6_addr_t ifrt_v6gateway_addr; /* Gateway if IRE_OFFLINK */ + in6_addr_t ifrt_v6setsrc_addr; /* Src addr if RTF_SETSRC */ + in6_addr_t ifrt_v6mask; /* Mask for matching IRE. */ + uint32_t ifrt_flags; /* flags related to route */ + iulp_t ifrt_metrics; /* Routing socket metrics */ + zoneid_t ifrt_zoneid; /* zoneid for route */ +} ifrt_t; + +#define ifrt_addr V4_PART_OF_V6(ifrt_v6addr) +#define ifrt_gateway_addr V4_PART_OF_V6(ifrt_v6gateway_addr) +#define ifrt_mask V4_PART_OF_V6(ifrt_v6mask) +#define ifrt_setsrc_addr V4_PART_OF_V6(ifrt_v6setsrc_addr) + +/* Number of IP addresses that can be hosted on a physical interface */ +#define MAX_ADDRS_PER_IF 8192 +/* + * Number of Source addresses to be considered for source address + * selection. Used by ipif_select_source_v4/v6. + */ +#define MAX_IPIF_SELECT_SOURCE 50 + +#ifdef IP_DEBUG +/* + * Trace refholds and refreles for debugging. + */ +#define TR_STACK_DEPTH 14 +typedef struct tr_buf_s { + int tr_depth; + clock_t tr_time; + pc_t tr_stack[TR_STACK_DEPTH]; +} tr_buf_t; + +typedef struct th_trace_s { + int th_refcnt; + uint_t th_trace_lastref; + kthread_t *th_id; +#define TR_BUF_MAX 38 + tr_buf_t th_trbuf[TR_BUF_MAX]; +} th_trace_t; + +typedef struct th_hash_s { + list_node_t thh_link; + mod_hash_t *thh_hash; + ip_stack_t *thh_ipst; +} th_hash_t; +#endif + +/* The following are ipif_state_flags */ +#define IPIF_CONDEMNED 0x1 /* The ipif is being removed */ +#define IPIF_CHANGING 0x2 /* A critcal ipif field is changing */ +#define IPIF_SET_LINKLOCAL 0x10 /* transient flag during bringup */ + +/* IP interface structure, one per local address */ +typedef struct ipif_s { + struct ipif_s *ipif_next; + struct ill_s *ipif_ill; /* Back pointer to our ill */ + int ipif_id; /* Logical unit number */ + in6_addr_t ipif_v6lcl_addr; /* Local IP address for this if. */ + in6_addr_t ipif_v6subnet; /* Subnet prefix for this if. */ + in6_addr_t ipif_v6net_mask; /* Net mask for this interface. */ + in6_addr_t ipif_v6brd_addr; /* Broadcast addr for this interface. */ + in6_addr_t ipif_v6pp_dst_addr; /* Point-to-point dest address. */ + uint64_t ipif_flags; /* Interface flags. */ + uint_t ipif_ire_type; /* IRE_LOCAL or IRE_LOOPBACK */ + + /* + * The packet count in the ipif contain the sum of the + * packet counts in dead IRE_LOCAL/LOOPBACK for this ipif. + */ + uint_t ipif_ib_pkt_count; /* Inbound packets for our dead IREs */ + + /* Exclusive bit fields, protected by ipsq_t */ + unsigned int + ipif_was_up : 1, /* ipif was up before */ + ipif_addr_ready : 1, /* DAD is done */ + ipif_was_dup : 1, /* DAD had failed */ + ipif_added_nce : 1, /* nce added for local address */ + + ipif_pad_to_31 : 28; + + ilm_t *ipif_allhosts_ilm; /* For all-nodes join */ + ilm_t *ipif_solmulti_ilm; /* For IPv6 solicited multicast join */ + + uint_t ipif_seqid; /* unique index across all ills */ + uint_t ipif_state_flags; /* See IPIF_* flag defs above */ + uint_t ipif_refcnt; /* active consistent reader cnt */ + + zoneid_t ipif_zoneid; /* zone ID number */ + timeout_id_t ipif_recovery_id; /* Timer for DAD recovery */ + boolean_t ipif_trace_disable; /* True when alloc fails */ + /* + * For an IPMP interface, ipif_bound_ill tracks the ill whose hardware + * information this ipif is associated with via ARP/NDP. We can use + * an ill pointer (rather than an index) because only ills that are + * part of a group will be pointed to, and an ill cannot disappear + * while it's in a group. + */ + struct ill_s *ipif_bound_ill; + struct ipif_s *ipif_bound_next; /* bound ipif chain */ + boolean_t ipif_bound; /* B_TRUE if we successfully bound */ + + struct ire_s *ipif_ire_local; /* Our IRE_LOCAL or LOOPBACK */ + struct ire_s *ipif_ire_if; /* Our IRE_INTERFACE */ +} ipif_t; + +/* + * The following table lists the protection levels of the various members + * of the ipif_t. The following notation is used. + * + * Write once - Written to only once at the time of bringing up + * the interface and can be safely read after the bringup without any lock. + * + * ipsq - Need to execute in the ipsq to perform the indicated access. + * + * ill_lock - Need to hold this mutex to perform the indicated access. + * + * ill_g_lock - Need to hold this rw lock as reader/writer for read access or + * write access respectively. + * + * down ill - Written to only when the ill is down (i.e all ipifs are down) + * up ill - Read only when the ill is up (i.e. at least 1 ipif is up) + * + * Table of ipif_t members and their protection + * + * ipif_next ipsq + ill_lock + ipsq OR ill_lock OR + * ill_g_lock ill_g_lock + * ipif_ill ipsq + down ipif write once + * ipif_id ipsq + down ipif write once + * ipif_v6lcl_addr ipsq + down ipif up ipif + * ipif_v6subnet ipsq + down ipif up ipif + * ipif_v6net_mask ipsq + down ipif up ipif + * + * ipif_v6brd_addr + * ipif_v6pp_dst_addr + * ipif_flags ill_lock ill_lock + * ipif_ire_type ipsq + down ill up ill + * + * ipif_ib_pkt_count Approx + * + * bit fields ill_lock ill_lock + * + * ipif_allhosts_ilm ipsq ipsq + * ipif_solmulti_ilm ipsq ipsq + * + * ipif_seqid ipsq Write once + * + * ipif_state_flags ill_lock ill_lock + * ipif_refcnt ill_lock ill_lock + * ipif_bound_ill ipsq + ipmp_lock ipsq OR ipmp_lock + * ipif_bound_next ipsq ipsq + * ipif_bound ipsq ipsq + * + * ipif_ire_local ipsq + ips_ill_g_lock ipsq OR ips_ill_g_lock + * ipif_ire_if ipsq + ips_ill_g_lock ipsq OR ips_ill_g_lock + */ + +/* + * Return values from ip_laddr_verify_{v4,v6} + */ +typedef enum { IPVL_UNICAST_UP, IPVL_UNICAST_DOWN, IPVL_MCAST, IPVL_BCAST, + IPVL_BAD} ip_laddr_t; + + +#define IP_TR_HASH(tid) ((((uintptr_t)tid) >> 6) & (IP_TR_HASH_MAX - 1)) + +#ifdef DEBUG +#define IPIF_TRACE_REF(ipif) ipif_trace_ref(ipif) +#define ILL_TRACE_REF(ill) ill_trace_ref(ill) +#define IPIF_UNTRACE_REF(ipif) ipif_untrace_ref(ipif) +#define ILL_UNTRACE_REF(ill) ill_untrace_ref(ill) +#else +#define IPIF_TRACE_REF(ipif) +#define ILL_TRACE_REF(ill) +#define IPIF_UNTRACE_REF(ipif) +#define ILL_UNTRACE_REF(ill) +#endif + +/* IPv4 compatibility macros */ +#define ipif_lcl_addr V4_PART_OF_V6(ipif_v6lcl_addr) +#define ipif_subnet V4_PART_OF_V6(ipif_v6subnet) +#define ipif_net_mask V4_PART_OF_V6(ipif_v6net_mask) +#define ipif_brd_addr V4_PART_OF_V6(ipif_v6brd_addr) +#define ipif_pp_dst_addr V4_PART_OF_V6(ipif_v6pp_dst_addr) + +/* Macros for easy backreferences to the ill. */ +#define ipif_isv6 ipif_ill->ill_isv6 + +#define SIOCLIFADDR_NDX 112 /* ndx of SIOCLIFADDR in the ndx ioctl table */ + +/* + * mode value for ip_ioctl_finish for finishing an ioctl + */ +#define CONN_CLOSE 1 /* No mi_copy */ +#define COPYOUT 2 /* do an mi_copyout if needed */ +#define NO_COPYOUT 3 /* do an mi_copy_done */ +#define IPI2MODE(ipi) ((ipi)->ipi_flags & IPI_GET_CMD ? COPYOUT : NO_COPYOUT) + +/* + * The IP-MT design revolves around the serialization objects ipsq_t (IPSQ) + * and ipxop_t (exclusive operation or "xop"). Becoming "writer" on an IPSQ + * ensures that no other threads can become "writer" on any IPSQs sharing that + * IPSQ's xop until the writer thread is done. + * + * Each phyint points to one IPSQ that remains fixed over the phyint's life. + * Each IPSQ points to one xop that can change over the IPSQ's life. If a + * phyint is *not* in an IPMP group, then its IPSQ will refer to the IPSQ's + * "own" xop (ipsq_ownxop). If a phyint *is* part of an IPMP group, then its + * IPSQ will refer to the "group" xop, which is shorthand for the xop of the + * IPSQ of the IPMP meta-interface's phyint. Thus, all phyints that are part + * of the same IPMP group will have their IPSQ's point to the group xop, and + * thus becoming "writer" on any phyint in the group will prevent any other + * writer on any other phyint in the group. All IPSQs sharing the same xop + * are chained together through ipsq_next (in the degenerate common case, + * ipsq_next simply refers to itself). Note that the group xop is guaranteed + * to exist at least as long as there are members in the group, since the IPMP + * meta-interface can only be destroyed if the group is empty. + * + * Incoming exclusive operation requests are enqueued on the IPSQ they arrived + * on rather than the xop. This makes switching xop's (as would happen when a + * phyint leaves an IPMP group) simple, because after the phyint leaves the + * group, any operations enqueued on its IPSQ can be safely processed with + * respect to its new xop, and any operations enqueued on the IPSQs of its + * former group can be processed with respect to their existing group xop. + * Even so, switching xops is a subtle dance; see ipsq_dq() for details. + * + * An IPSQ's "own" xop is embedded within the IPSQ itself since they have have + * identical lifetimes, and because doing so simplifies pointer management. + * While each phyint and IPSQ point to each other, it is not possible to free + * the IPSQ when the phyint is freed, since we may still *inside* the IPSQ + * when the phyint is being freed. Thus, ipsq_phyint is set to NULL when the + * phyint is freed, and the IPSQ free is later done in ipsq_exit(). + * + * ipsq_t synchronization: read write + * + * ipsq_xopq_mphead ipx_lock ipx_lock + * ipsq_xopq_mptail ipx_lock ipx_lock + * ipsq_xop_switch_mp ipsq_lock ipsq_lock + * ipsq_phyint write once write once + * ipsq_next RW_READER ill_g_lock RW_WRITER ill_g_lock + * ipsq_xop ipsq_lock or ipsq ipsq_lock + ipsq + * ipsq_swxop ipsq ipsq + * ipsq_ownxop see ipxop_t see ipxop_t + * ipsq_ipst write once write once + * + * ipxop_t synchronization: read write + * + * ipx_writer ipx_lock ipx_lock + * ipx_xop_queued ipx_lock ipx_lock + * ipx_mphead ipx_lock ipx_lock + * ipx_mptail ipx_lock ipx_lock + * ipx_ipsq write once write once + * ips_ipsq_queued ipx_lock ipx_lock + * ipx_waitfor ipsq or ipx_lock ipsq + ipx_lock + * ipx_reentry_cnt ipsq or ipx_lock ipsq + ipx_lock + * ipx_current_done ipsq ipsq + * ipx_current_ioctl ipsq ipsq + * ipx_current_ipif ipsq or ipx_lock ipsq + ipx_lock + * ipx_pending_ipif ipsq or ipx_lock ipsq + ipx_lock + * ipx_pending_mp ipsq or ipx_lock ipsq + ipx_lock + * ipx_forced ipsq ipsq + * ipx_depth ipsq ipsq + * ipx_stack ipsq ipsq + */ +typedef struct ipxop_s { + kmutex_t ipx_lock; /* see above */ + kthread_t *ipx_writer; /* current owner */ + mblk_t *ipx_mphead; /* messages tied to this op */ + mblk_t *ipx_mptail; + struct ipsq_s *ipx_ipsq; /* associated ipsq */ + boolean_t ipx_ipsq_queued; /* ipsq using xop has queued op */ + int ipx_waitfor; /* waiting; values encoded below */ + int ipx_reentry_cnt; + boolean_t ipx_current_done; /* is the current operation done? */ + int ipx_current_ioctl; /* current ioctl, or 0 if no ioctl */ + ipif_t *ipx_current_ipif; /* ipif for current op */ + ipif_t *ipx_pending_ipif; /* ipif for ipx_pending_mp */ + mblk_t *ipx_pending_mp; /* current ioctl mp while waiting */ + boolean_t ipx_forced; /* debugging aid */ +#ifdef DEBUG + int ipx_depth; /* debugging aid */ +#define IPX_STACK_DEPTH 15 + pc_t ipx_stack[IPX_STACK_DEPTH]; /* debugging aid */ +#endif +} ipxop_t; + +typedef struct ipsq_s { + kmutex_t ipsq_lock; /* see above */ + mblk_t *ipsq_switch_mp; /* op to handle right after switch */ + mblk_t *ipsq_xopq_mphead; /* list of excl ops (mostly ioctls) */ + mblk_t *ipsq_xopq_mptail; + struct phyint *ipsq_phyint; /* associated phyint */ + struct ipsq_s *ipsq_next; /* next ipsq sharing ipsq_xop */ + struct ipxop_s *ipsq_xop; /* current xop synchronization info */ + struct ipxop_s *ipsq_swxop; /* switch xop to on ipsq_exit() */ + struct ipxop_s ipsq_ownxop; /* our own xop (may not be in-use) */ + ip_stack_t *ipsq_ipst; /* does not have a netstack_hold */ +} ipsq_t; + +/* + * ipx_waitfor values: + */ +enum { + IPIF_DOWN = 1, /* ipif_down() waiting for refcnts to drop */ + ILL_DOWN, /* ill_down() waiting for refcnts to drop */ + IPIF_FREE, /* ipif_free() waiting for refcnts to drop */ + ILL_FREE /* ill unplumb waiting for refcnts to drop */ +}; + +/* Operation types for ipsq_try_enter() */ +#define CUR_OP 0 /* request writer within current operation */ +#define NEW_OP 1 /* request writer for a new operation */ +#define SWITCH_OP 2 /* request writer once IPSQ XOP switches */ + +/* + * Kstats tracked on each IPMP meta-interface. Order here must match + * ipmp_kstats[] in ip/ipmp.c. + */ +enum { + IPMP_KSTAT_OBYTES, IPMP_KSTAT_OBYTES64, IPMP_KSTAT_RBYTES, + IPMP_KSTAT_RBYTES64, IPMP_KSTAT_OPACKETS, IPMP_KSTAT_OPACKETS64, + IPMP_KSTAT_OERRORS, IPMP_KSTAT_IPACKETS, IPMP_KSTAT_IPACKETS64, + IPMP_KSTAT_IERRORS, IPMP_KSTAT_MULTIRCV, IPMP_KSTAT_MULTIXMT, + IPMP_KSTAT_BRDCSTRCV, IPMP_KSTAT_BRDCSTXMT, IPMP_KSTAT_LINK_UP, + IPMP_KSTAT_MAX /* keep last */ +}; + +/* + * phyint represents state that is common to both IPv4 and IPv6 interfaces. + * There is a separate ill_t representing IPv4 and IPv6 which has a + * backpointer to the phyint structure for accessing common state. + */ +typedef struct phyint { + struct ill_s *phyint_illv4; + struct ill_s *phyint_illv6; + uint_t phyint_ifindex; /* SIOCSLIFINDEX */ + uint64_t phyint_flags; + avl_node_t phyint_avl_by_index; /* avl tree by index */ + avl_node_t phyint_avl_by_name; /* avl tree by name */ + kmutex_t phyint_lock; + struct ipsq_s *phyint_ipsq; /* back pointer to ipsq */ + struct ipmp_grp_s *phyint_grp; /* associated IPMP group */ + char phyint_name[LIFNAMSIZ]; /* physical interface name */ + uint64_t phyint_kstats0[IPMP_KSTAT_MAX]; /* baseline kstats */ +} phyint_t; + +#define CACHE_ALIGN_SIZE 64 +#define CACHE_ALIGN(align_struct) P2ROUNDUP(sizeof (struct align_struct),\ + CACHE_ALIGN_SIZE) +struct _phyint_list_s_ { + avl_tree_t phyint_list_avl_by_index; /* avl tree by index */ + avl_tree_t phyint_list_avl_by_name; /* avl tree by name */ +}; + +typedef union phyint_list_u { + struct _phyint_list_s_ phyint_list_s; + char phyint_list_filler[CACHE_ALIGN(_phyint_list_s_)]; +} phyint_list_t; + +#define phyint_list_avl_by_index phyint_list_s.phyint_list_avl_by_index +#define phyint_list_avl_by_name phyint_list_s.phyint_list_avl_by_name + +/* + * Fragmentation hash bucket + */ +typedef struct ipfb_s { + struct ipf_s *ipfb_ipf; /* List of ... */ + size_t ipfb_count; /* Count of bytes used by frag(s) */ + kmutex_t ipfb_lock; /* Protect all ipf in list */ + uint_t ipfb_frag_pkts; /* num of distinct fragmented pkts */ +} ipfb_t; + +/* + * IRE bucket structure. Usually there is an array of such structures, + * each pointing to a linked list of ires. irb_refcnt counts the number + * of walkers of a given hash bucket. Usually the reference count is + * bumped up if the walker wants no IRES to be DELETED while walking the + * list. Bumping up does not PREVENT ADDITION. This allows walking a given + * hash bucket without stumbling up on a free pointer. + * + * irb_t structures in ip_ftable are dynamically allocated and freed. + * In order to identify the irb_t structures that can be safely kmem_free'd + * we need to ensure that + * - the irb_refcnt is quiescent, indicating no other walkers, + * - no other threads or ire's are holding references to the irb, + * i.e., irb_nire == 0, + * - there are no active ire's in the bucket, i.e., irb_ire_cnt == 0 + */ +typedef struct irb { + struct ire_s *irb_ire; /* First ire in this bucket */ + /* Should be first in this struct */ + krwlock_t irb_lock; /* Protect this bucket */ + uint_t irb_refcnt; /* Protected by irb_lock */ + uchar_t irb_marks; /* CONDEMNED ires in this bucket ? */ +#define IRB_MARK_CONDEMNED 0x0001 /* Contains some IRE_IS_CONDEMNED */ +#define IRB_MARK_DYNAMIC 0x0002 /* Dynamically allocated */ + /* Once IPv6 uses radix then IRB_MARK_DYNAMIC will be always be set */ + uint_t irb_ire_cnt; /* Num of active IRE in this bucket */ + int irb_nire; /* Num of ftable ire's that ref irb */ + ip_stack_t *irb_ipst; /* Does not have a netstack_hold */ +} irb_t; + +/* + * This is the structure used to store the multicast physical addresses + * that an interface has joined. + * The refcnt keeps track of the number of multicast IP addresses mapping + * to a physical multicast address. + */ +typedef struct multiphysaddr_s { + struct multiphysaddr_s *mpa_next; + char mpa_addr[IP_MAX_HW_LEN]; + int mpa_refcnt; +} multiphysaddr_t; + +#define IRB2RT(irb) (rt_t *)((caddr_t)(irb) - offsetof(rt_t, rt_irb)) + +/* Forward declarations */ +struct dce_s; +typedef struct dce_s dce_t; +struct ire_s; +typedef struct ire_s ire_t; +struct ncec_s; +typedef struct ncec_s ncec_t; +struct nce_s; +typedef struct nce_s nce_t; +struct ip_recv_attr_s; +typedef struct ip_recv_attr_s ip_recv_attr_t; +struct ip_xmit_attr_s; +typedef struct ip_xmit_attr_s ip_xmit_attr_t; + +struct tsol_ire_gw_secattr_s; +typedef struct tsol_ire_gw_secattr_s tsol_ire_gw_secattr_t; + +/* + * This is a structure for a one-element route cache that is passed + * by reference between ip_input and ill_inputfn. + */ +typedef struct { + ire_t *rtc_ire; + ipaddr_t rtc_ipaddr; + in6_addr_t rtc_ip6addr; +} rtc_t; + +/* + * Note: Temporarily use 64 bits, and will probably go back to 32 bits after + * more cleanup work is done. + */ +typedef uint64_t iaflags_t; + +/* The ill input function pointer type */ +typedef void (*pfillinput_t)(mblk_t *, void *, void *, ip_recv_attr_t *, + rtc_t *); + +/* The ire receive function pointer type */ +typedef void (*pfirerecv_t)(ire_t *, mblk_t *, void *, ip_recv_attr_t *); + +/* The ire send and postfrag function pointer types */ +typedef int (*pfiresend_t)(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +typedef int (*pfirepostfrag_t)(mblk_t *, nce_t *, iaflags_t, uint_t, uint32_t, + zoneid_t, zoneid_t, uintptr_t *); + + +#define IP_V4_G_HEAD 0 +#define IP_V6_G_HEAD 1 + +#define MAX_G_HEADS 2 + +/* + * unpadded ill_if structure + */ +struct _ill_if_s_ { + union ill_if_u *illif_next; + union ill_if_u *illif_prev; + avl_tree_t illif_avl_by_ppa; /* AVL tree sorted on ppa */ + vmem_t *illif_ppa_arena; /* ppa index space */ + uint16_t illif_mcast_v1; /* hints for */ + uint16_t illif_mcast_v2; /* [igmp|mld]_slowtimo */ + int illif_name_len; /* name length */ + char illif_name[LIFNAMSIZ]; /* name of interface type */ +}; + +/* cache aligned ill_if structure */ +typedef union ill_if_u { + struct _ill_if_s_ ill_if_s; + char illif_filler[CACHE_ALIGN(_ill_if_s_)]; +} ill_if_t; + +#define illif_next ill_if_s.illif_next +#define illif_prev ill_if_s.illif_prev +#define illif_avl_by_ppa ill_if_s.illif_avl_by_ppa +#define illif_ppa_arena ill_if_s.illif_ppa_arena +#define illif_mcast_v1 ill_if_s.illif_mcast_v1 +#define illif_mcast_v2 ill_if_s.illif_mcast_v2 +#define illif_name ill_if_s.illif_name +#define illif_name_len ill_if_s.illif_name_len + +typedef struct ill_walk_context_s { + int ctx_current_list; /* current list being searched */ + int ctx_last_list; /* last list to search */ +} ill_walk_context_t; + +/* + * ill_g_heads structure, one for IPV4 and one for IPV6 + */ +struct _ill_g_head_s_ { + ill_if_t *ill_g_list_head; + ill_if_t *ill_g_list_tail; +}; + +typedef union ill_g_head_u { + struct _ill_g_head_s_ ill_g_head_s; + char ill_g_head_filler[CACHE_ALIGN(_ill_g_head_s_)]; +} ill_g_head_t; + +#define ill_g_list_head ill_g_head_s.ill_g_list_head +#define ill_g_list_tail ill_g_head_s.ill_g_list_tail + +#define IP_V4_ILL_G_LIST(ipst) \ + (ipst)->ips_ill_g_heads[IP_V4_G_HEAD].ill_g_list_head +#define IP_V6_ILL_G_LIST(ipst) \ + (ipst)->ips_ill_g_heads[IP_V6_G_HEAD].ill_g_list_head +#define IP_VX_ILL_G_LIST(i, ipst) \ + (ipst)->ips_ill_g_heads[i].ill_g_list_head + +#define ILL_START_WALK_V4(ctx_ptr, ipst) \ + ill_first(IP_V4_G_HEAD, IP_V4_G_HEAD, ctx_ptr, ipst) +#define ILL_START_WALK_V6(ctx_ptr, ipst) \ + ill_first(IP_V6_G_HEAD, IP_V6_G_HEAD, ctx_ptr, ipst) +#define ILL_START_WALK_ALL(ctx_ptr, ipst) \ + ill_first(MAX_G_HEADS, MAX_G_HEADS, ctx_ptr, ipst) + +/* + * Capabilities, possible flags for ill_capabilities. + */ +#define ILL_CAPAB_LSO 0x04 /* Large Send Offload */ +#define ILL_CAPAB_HCKSUM 0x08 /* Hardware checksumming */ +#define ILL_CAPAB_ZEROCOPY 0x10 /* Zero-copy */ +#define ILL_CAPAB_DLD 0x20 /* DLD capabilities */ +#define ILL_CAPAB_DLD_POLL 0x40 /* Polling */ +#define ILL_CAPAB_DLD_DIRECT 0x80 /* Direct function call */ + +/* + * Per-ill Hardware Checksumming capbilities. + */ +typedef struct ill_hcksum_capab_s ill_hcksum_capab_t; + +/* + * Per-ill Zero-copy capabilities. + */ +typedef struct ill_zerocopy_capab_s ill_zerocopy_capab_t; + +/* + * DLD capbilities. + */ +typedef struct ill_dld_capab_s ill_dld_capab_t; + +/* + * Per-ill polling resource map. + */ +typedef struct ill_rx_ring ill_rx_ring_t; + +/* + * Per-ill Large Send Offload capabilities. + */ +typedef struct ill_lso_capab_s ill_lso_capab_t; + +/* The following are ill_state_flags */ +#define ILL_LL_SUBNET_PENDING 0x01 /* Waiting for DL_INFO_ACK from drv */ +#define ILL_CONDEMNED 0x02 /* No more new ref's to the ILL */ +#define ILL_DL_UNBIND_IN_PROGRESS 0x04 /* UNBIND_REQ is sent */ +/* + * ILL_DOWN_IN_PROGRESS is set to ensure the following: + * - no packets are sent to the driver after the DL_UNBIND_REQ is sent, + * - no longstanding references will be acquired on objects that are being + * brought down. + */ +#define ILL_DOWN_IN_PROGRESS 0x08 + +/* Is this an ILL whose source address is used by other ILL's ? */ +#define IS_USESRC_ILL(ill) \ + (((ill)->ill_usesrc_ifindex == 0) && \ + ((ill)->ill_usesrc_grp_next != NULL)) + +/* Is this a client/consumer of the usesrc ILL ? */ +#define IS_USESRC_CLI_ILL(ill) \ + (((ill)->ill_usesrc_ifindex != 0) && \ + ((ill)->ill_usesrc_grp_next != NULL)) + +/* Is this an virtual network interface (vni) ILL ? */ +#define IS_VNI(ill) \ + (((ill)->ill_phyint->phyint_flags & (PHYI_LOOPBACK|PHYI_VIRTUAL)) == \ + PHYI_VIRTUAL) + +/* Is this a loopback ILL? */ +#define IS_LOOPBACK(ill) \ + ((ill)->ill_phyint->phyint_flags & PHYI_LOOPBACK) + +/* Is this an IPMP meta-interface ILL? */ +#define IS_IPMP(ill) \ + ((ill)->ill_phyint->phyint_flags & PHYI_IPMP) + +/* Is this ILL under an IPMP meta-interface? (aka "in a group?") */ +#define IS_UNDER_IPMP(ill) \ + ((ill)->ill_grp != NULL && !IS_IPMP(ill)) + +/* Is ill1 in the same illgrp as ill2? */ +#define IS_IN_SAME_ILLGRP(ill1, ill2) \ + ((ill1)->ill_grp != NULL && ((ill1)->ill_grp == (ill2)->ill_grp)) + +/* Is ill1 on the same LAN as ill2? */ +#define IS_ON_SAME_LAN(ill1, ill2) \ + ((ill1) == (ill2) || IS_IN_SAME_ILLGRP(ill1, ill2)) + +#define ILL_OTHER(ill) \ + ((ill)->ill_isv6 ? (ill)->ill_phyint->phyint_illv4 : \ + (ill)->ill_phyint->phyint_illv6) + +/* + * IPMP group ILL state structure -- up to two per IPMP group (V4 and V6). + * Created when the V4 and/or V6 IPMP meta-interface is I_PLINK'd. It is + * guaranteed to persist while there are interfaces of that type in the group. + * In general, most fields are accessed outside of the IPSQ (e.g., in the + * datapath), and thus use locks in addition to the IPSQ for protection. + * + * synchronization: read write + * + * ig_if ipsq or ill_g_lock ipsq and ill_g_lock + * ig_actif ipsq or ipmp_lock ipsq and ipmp_lock + * ig_nactif ipsq or ipmp_lock ipsq and ipmp_lock + * ig_next_ill ipsq or ipmp_lock ipsq and ipmp_lock + * ig_ipmp_ill write once write once + * ig_cast_ill ipsq or ipmp_lock ipsq and ipmp_lock + * ig_arpent ipsq ipsq + * ig_mtu ipsq ipsq + * ig_mc_mtu ipsq ipsq + */ +typedef struct ipmp_illgrp_s { + list_t ig_if; /* list of all interfaces */ + list_t ig_actif; /* list of active interfaces */ + uint_t ig_nactif; /* number of active interfaces */ + struct ill_s *ig_next_ill; /* next active interface to use */ + struct ill_s *ig_ipmp_ill; /* backpointer to IPMP meta-interface */ + struct ill_s *ig_cast_ill; /* nominated ill for multi/broadcast */ + list_t ig_arpent; /* list of ARP entries */ + uint_t ig_mtu; /* ig_ipmp_ill->ill_mtu */ + uint_t ig_mc_mtu; /* ig_ipmp_ill->ill_mc_mtu */ +} ipmp_illgrp_t; + +/* + * IPMP group state structure -- one per IPMP group. Created when the + * IPMP meta-interface is plumbed; it is guaranteed to persist while there + * are interfaces in it. + * + * ipmp_grp_t synchronization: read write + * + * gr_name ipmp_lock ipmp_lock + * gr_ifname write once write once + * gr_mactype ipmp_lock ipmp_lock + * gr_phyint write once write once + * gr_nif ipmp_lock ipmp_lock + * gr_nactif ipsq ipsq + * gr_v4 ipmp_lock ipmp_lock + * gr_v6 ipmp_lock ipmp_lock + * gr_nv4 ipmp_lock ipmp_lock + * gr_nv6 ipmp_lock ipmp_lock + * gr_pendv4 ipmp_lock ipmp_lock + * gr_pendv6 ipmp_lock ipmp_lock + * gr_linkdownmp ipsq ipsq + * gr_ksp ipmp_lock ipmp_lock + * gr_kstats0 atomic atomic + */ +typedef struct ipmp_grp_s { + char gr_name[LIFGRNAMSIZ]; /* group name */ + char gr_ifname[LIFNAMSIZ]; /* interface name */ + t_uscalar_t gr_mactype; /* DLPI mactype of group */ + phyint_t *gr_phyint; /* IPMP group phyint */ + uint_t gr_nif; /* number of interfaces in group */ + uint_t gr_nactif; /* number of active interfaces */ + ipmp_illgrp_t *gr_v4; /* V4 group information */ + ipmp_illgrp_t *gr_v6; /* V6 group information */ + uint_t gr_nv4; /* number of ills in V4 group */ + uint_t gr_nv6; /* number of ills in V6 group */ + uint_t gr_pendv4; /* number of pending ills in V4 group */ + uint_t gr_pendv6; /* number of pending ills in V6 group */ + mblk_t *gr_linkdownmp; /* message used to bring link down */ + kstat_t *gr_ksp; /* group kstat pointer */ + uint64_t gr_kstats0[IPMP_KSTAT_MAX]; /* baseline group kstats */ +} ipmp_grp_t; + +/* + * IPMP ARP entry -- one per SIOCS*ARP entry tied to the group. Used to keep + * ARP up-to-date as the active set of interfaces in the group changes. + */ +typedef struct ipmp_arpent_s { + ipaddr_t ia_ipaddr; /* IP address for this entry */ + boolean_t ia_proxyarp; /* proxy ARP entry? */ + boolean_t ia_notified; /* ARP notified about this entry? */ + list_node_t ia_node; /* next ARP entry in list */ + uint16_t ia_flags; /* nce_flags for the address */ + size_t ia_lladdr_len; + uchar_t *ia_lladdr; +} ipmp_arpent_t; + +struct arl_s; + +/* + * Per-ill capabilities. + */ +struct ill_hcksum_capab_s { + uint_t ill_hcksum_version; /* interface version */ + uint_t ill_hcksum_txflags; /* capabilities on transmit */ +}; + +struct ill_zerocopy_capab_s { + uint_t ill_zerocopy_version; /* interface version */ + uint_t ill_zerocopy_flags; /* capabilities */ +}; + +struct ill_lso_capab_s { + uint_t ill_lso_flags; /* capabilities */ + uint_t ill_lso_max_tcpv4; /* maximum size of payload */ + uint_t ill_lso_max_tcpv6; /* maximum size of payload */ +}; + +/* + * IP Lower level Structure. + * Instance data structure in ip_open when there is a device below us. + */ +typedef struct ill_s { + pfillinput_t ill_inputfn; /* Fast input function selector */ + ill_if_t *ill_ifptr; /* pointer to interface type */ + queue_t *ill_rq; /* Read queue. */ + queue_t *ill_wq; /* Write queue. */ + + int ill_error; /* Error value sent up by device. */ + + ipif_t *ill_ipif; /* Interface chain for this ILL. */ + + uint_t ill_ipif_up_count; /* Number of IPIFs currently up. */ + uint_t ill_max_frag; /* Max IDU from DLPI. */ + uint_t ill_current_frag; /* Current IDU from DLPI. */ + uint_t ill_mtu; /* User-specified MTU; SIOCSLIFMTU */ + uint_t ill_mc_mtu; /* MTU for multi/broadcast */ + uint_t ill_metric; /* BSD if metric, for compatibility. */ + char *ill_name; /* Our name. */ + uint_t ill_ipif_dup_count; /* Number of duplicate addresses. */ + uint_t ill_name_length; /* Name length, incl. terminator. */ + uint_t ill_net_type; /* IRE_IF_RESOLVER/IRE_IF_NORESOLVER. */ + /* + * Physical Point of Attachment num. If DLPI style 1 provider + * then this is derived from the devname. + */ + uint_t ill_ppa; + t_uscalar_t ill_sap; + t_scalar_t ill_sap_length; /* Including sign (for position) */ + uint_t ill_phys_addr_length; /* Excluding the sap. */ + uint_t ill_bcast_addr_length; /* Only set when the DL provider */ + /* supports broadcast. */ + t_uscalar_t ill_mactype; + uint8_t *ill_frag_ptr; /* Reassembly state. */ + timeout_id_t ill_frag_timer_id; /* timeout id for the frag timer */ + ipfb_t *ill_frag_hash_tbl; /* Fragment hash list head. */ + + krwlock_t ill_mcast_lock; /* Protects multicast state */ + kmutex_t ill_mcast_serializer; /* Serialize across ilg and ilm state */ + ilm_t *ill_ilm; /* Multicast membership for ill */ + uint_t ill_global_timer; /* for IGMPv3/MLDv2 general queries */ + int ill_mcast_type; /* type of router which is querier */ + /* on this interface */ + uint16_t ill_mcast_v1_time; /* # slow timeouts since last v1 qry */ + uint16_t ill_mcast_v2_time; /* # slow timeouts since last v2 qry */ + uint8_t ill_mcast_v1_tset; /* 1 => timer is set; 0 => not set */ + uint8_t ill_mcast_v2_tset; /* 1 => timer is set; 0 => not set */ + + uint8_t ill_mcast_rv; /* IGMPv3/MLDv2 robustness variable */ + int ill_mcast_qi; /* IGMPv3/MLDv2 query interval var */ + + /* + * All non-NULL cells between 'ill_first_mp_to_free' and + * 'ill_last_mp_to_free' are freed in ill_delete. + */ +#define ill_first_mp_to_free ill_bcast_mp + mblk_t *ill_bcast_mp; /* DLPI header for broadcasts. */ + mblk_t *ill_unbind_mp; /* unbind mp from ill_dl_up() */ + mblk_t *ill_promiscoff_mp; /* for ill_leave_allmulti() */ + mblk_t *ill_dlpi_deferred; /* b_next chain of control messages */ + mblk_t *ill_dest_addr_mp; /* mblk which holds ill_dest_addr */ + mblk_t *ill_replumb_mp; /* replumb mp from ill_replumb() */ + mblk_t *ill_phys_addr_mp; /* mblk which holds ill_phys_addr */ + mblk_t *ill_mcast_deferred; /* b_next chain of IGMP/MLD packets */ +#define ill_last_mp_to_free ill_mcast_deferred + + cred_t *ill_credp; /* opener's credentials */ + uint8_t *ill_phys_addr; /* ill_phys_addr_mp->b_rptr + off */ + uint8_t *ill_dest_addr; /* ill_dest_addr_mp->b_rptr + off */ + + uint_t ill_state_flags; /* see ILL_* flags above */ + + /* Following bit fields protected by ipsq_t */ + uint_t + ill_needs_attach : 1, + ill_reserved : 1, + ill_isv6 : 1, + ill_dlpi_style_set : 1, + + ill_ifname_pending : 1, + ill_logical_down : 1, + ill_dl_up : 1, + ill_up_ipifs : 1, + + ill_note_link : 1, /* supports link-up notification */ + ill_capab_reneg : 1, /* capability renegotiation to be done */ + ill_dld_capab_inprog : 1, /* direct dld capab call in prog */ + ill_need_recover_multicast : 1, + + ill_replumbing : 1, + ill_arl_dlpi_pending : 1, + ill_grp_pending : 1, + + ill_pad_to_bit_31 : 17; + + /* Following bit fields protected by ill_lock */ + uint_t + ill_fragtimer_executing : 1, + ill_fragtimer_needrestart : 1, + ill_manual_token : 1, /* system won't override ill_token */ + /* + * ill_manual_linklocal : system will not change the + * linklocal whenever ill_token changes. + */ + ill_manual_linklocal : 1, + + ill_manual_dst_linklocal : 1, /* same for pt-pt dst linklocal */ + + ill_mcast_ncec_cleanup : 1, /* Reaping mcast ncecs. */ + ill_pad_bit_31 : 26; + + /* + * Used in SIOCSIFMUXID and SIOCGIFMUXID for 'ifconfig unplumb'. + */ + int ill_muxid; /* muxid returned from plink */ + + /* Used for IP frag reassembly throttling on a per ILL basis. */ + uint_t ill_ipf_gen; /* Generation of next fragment queue */ + uint_t ill_frag_count; /* Count of all reassembly mblk bytes */ + uint_t ill_frag_free_num_pkts; /* num of fragmented packets to free */ + clock_t ill_last_frag_clean_time; /* time when frag's were pruned */ + int ill_type; /* From */ + uint_t ill_dlpi_multicast_state; /* See below IDS_* */ + uint_t ill_dlpi_fastpath_state; /* See below IDS_* */ + + /* + * Capabilities related fields. + */ + uint_t ill_dlpi_capab_state; /* State of capability query, IDCS_* */ + uint_t ill_capab_pending_cnt; + uint64_t ill_capabilities; /* Enabled capabilities, ILL_CAPAB_* */ + ill_hcksum_capab_t *ill_hcksum_capab; /* H/W cksumming capabilities */ + ill_zerocopy_capab_t *ill_zerocopy_capab; /* Zero-copy capabilities */ + ill_dld_capab_t *ill_dld_capab; /* DLD capabilities */ + ill_lso_capab_t *ill_lso_capab; /* Large Segment Offload capabilities */ + mblk_t *ill_capab_reset_mp; /* Preallocated mblk for capab reset */ + + uint8_t ill_max_hops; /* Maximum hops for any logical interface */ + uint_t ill_user_mtu; /* User-specified MTU via SIOCSLIFLNKINFO */ + uint32_t ill_reachable_time; /* Value for ND algorithm in msec */ + uint32_t ill_reachable_retrans_time; /* Value for ND algorithm msec */ + uint_t ill_max_buf; /* Max # of req to buffer for ND */ + in6_addr_t ill_token; /* IPv6 interface id */ + in6_addr_t ill_dest_token; /* Destination IPv6 interface id */ + uint_t ill_token_length; + uint32_t ill_xmit_count; /* ndp max multicast xmits */ + mib2_ipIfStatsEntry_t *ill_ip_mib; /* ver indep. interface mib */ + mib2_ipv6IfIcmpEntry_t *ill_icmp6_mib; /* Per interface mib */ + + phyint_t *ill_phyint; + uint64_t ill_flags; + + kmutex_t ill_lock; /* Please see table below */ + /* + * The ill_nd_lla* fields handle the link layer address option + * from neighbor discovery. This is used for external IPv6 + * address resolution. + */ + mblk_t *ill_nd_lla_mp; /* mblk which holds ill_nd_lla */ + uint8_t *ill_nd_lla; /* Link Layer Address */ + uint_t ill_nd_lla_len; /* Link Layer Address length */ + /* + * We have 4 phys_addr_req's sent down. This field keeps track + * of which one is pending. + */ + t_uscalar_t ill_phys_addr_pend; /* which dl_phys_addr_req pending */ + /* + * Used to save errors that occur during plumbing + */ + uint_t ill_ifname_pending_err; + avl_node_t ill_avl_byppa; /* avl node based on ppa */ + uint_t ill_mcast_nces; /* Number of NCEs that are multicast. */ + list_t ill_nce; /* pointer to nce_s list */ + uint_t ill_refcnt; /* active refcnt by threads */ + uint_t ill_ire_cnt; /* ires associated with this ill */ + kcondvar_t ill_cv; + uint_t ill_ncec_cnt; /* ncecs associated with this ill */ + uint_t ill_nce_cnt; /* nces associated with this ill */ + uint_t ill_waiters; /* threads waiting in ipsq_enter */ + /* + * Contains the upper read queue pointer of the module immediately + * beneath IP. This field allows IP to validate sub-capability + * acknowledgments coming up from downstream. + */ + queue_t *ill_lmod_rq; /* read queue pointer of module below */ + uint_t ill_lmod_cnt; /* number of modules beneath IP */ + ip_m_t *ill_media; /* media specific params/functions */ + t_uscalar_t ill_dlpi_pending; /* Last DLPI primitive issued */ + uint_t ill_usesrc_ifindex; /* use src addr from this ILL */ + struct ill_s *ill_usesrc_grp_next; /* Next ILL in the usesrc group */ + boolean_t ill_trace_disable; /* True when alloc fails */ + zoneid_t ill_zoneid; + ip_stack_t *ill_ipst; /* Corresponds to a netstack_hold */ + uint32_t ill_dhcpinit; /* IP_DHCPINIT_IFs for ill */ + void *ill_flownotify_mh; /* Tx flow ctl, mac cb handle */ + uint_t ill_ilm_cnt; /* ilms referencing this ill */ + uint_t ill_ipallmulti_cnt; /* ip_join_allmulti() calls */ + ilm_t *ill_ipallmulti_ilm; + + mblk_t *ill_saved_ire_mp; /* Allocated for each extra IRE */ + /* with ire_ill set so they can */ + /* survive the ill going down and up. */ + kmutex_t ill_saved_ire_lock; /* Protects ill_saved_ire_mp, cnt */ + uint_t ill_saved_ire_cnt; /* # entries */ + struct arl_ill_common_s *ill_common; + ire_t *ill_ire_multicast; /* IRE_MULTICAST for ill */ + clock_t ill_defend_start; /* start of 1 hour period */ + uint_t ill_defend_count; /* # of announce/defends per ill */ + /* + * IPMP fields. + */ + ipmp_illgrp_t *ill_grp; /* IPMP group information */ + list_node_t ill_actnode; /* next active ill in group */ + list_node_t ill_grpnode; /* next ill in group */ + ipif_t *ill_src_ipif; /* source address selection rotor */ + ipif_t *ill_move_ipif; /* ipif awaiting move to new ill */ + boolean_t ill_nom_cast; /* nominated for mcast/bcast */ + uint_t ill_bound_cnt; /* # of data addresses bound to ill */ + ipif_t *ill_bound_ipif; /* ipif chain bound to ill */ + timeout_id_t ill_refresh_tid; /* ill refresh retry timeout id */ + + uint32_t ill_mrouter_cnt; /* mrouter allmulti joins */ + uint32_t ill_allowed_ips_cnt; + in6_addr_t *ill_allowed_ips; + + /* list of multicast physical addresses joined on this ill */ + multiphysaddr_t *ill_mphysaddr_list; +} ill_t; + +/* + * ILL_FREE_OK() means that there are no incoming pointer references + * to the ill. + */ +#define ILL_FREE_OK(ill) \ + ((ill)->ill_ire_cnt == 0 && (ill)->ill_ilm_cnt == 0 && \ + (ill)->ill_ncec_cnt == 0 && (ill)->ill_nce_cnt == 0) + +/* + * An ipif/ill can be marked down only when the ire and ncec references + * to that ipif/ill goes to zero. ILL_DOWN_OK() is a necessary condition + * quiescence checks. See comments above IPIF_DOWN_OK for details + * on why ires and nces are selectively considered for this macro. + */ +#define ILL_DOWN_OK(ill) \ + (ill->ill_ire_cnt == 0 && ill->ill_ncec_cnt == 0 && \ + ill->ill_nce_cnt == 0) + +/* + * The following table lists the protection levels of the various members + * of the ill_t. Same notation as that used for ipif_t above is used. + * + * Write Read + * + * ill_ifptr ill_g_lock + s Write once + * ill_rq ipsq Write once + * ill_wq ipsq Write once + * + * ill_error ipsq None + * ill_ipif ill_g_lock + ipsq ill_g_lock OR ipsq + * ill_ipif_up_count ill_lock + ipsq ill_lock OR ipsq + * ill_max_frag ill_lock ill_lock + * ill_current_frag ill_lock ill_lock + * + * ill_name ill_g_lock + ipsq Write once + * ill_name_length ill_g_lock + ipsq Write once + * ill_ndd_name ipsq Write once + * ill_net_type ipsq Write once + * ill_ppa ill_g_lock + ipsq Write once + * ill_sap ipsq + down ill Write once + * ill_sap_length ipsq + down ill Write once + * ill_phys_addr_length ipsq + down ill Write once + * + * ill_bcast_addr_length ipsq ipsq + * ill_mactype ipsq ipsq + * ill_frag_ptr ipsq ipsq + * + * ill_frag_timer_id ill_lock ill_lock + * ill_frag_hash_tbl ipsq up ill + * ill_ilm ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * ill_global_timer ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * ill_mcast_type ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * ill_mcast_v1_time ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * ill_mcast_v2_time ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * ill_mcast_v1_tset ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * ill_mcast_v2_tset ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * ill_mcast_rv ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * ill_mcast_qi ill_mcast_lock(WRITER) ill_mcast_lock(READER) + * + * ill_down_mp ipsq ipsq + * ill_dlpi_deferred ill_lock ill_lock + * ill_dlpi_pending ipsq + ill_lock ipsq or ill_lock or + * absence of ipsq writer. + * ill_phys_addr_mp ipsq + down ill only when ill is up + * ill_mcast_deferred ill_lock ill_lock + * ill_phys_addr ipsq + down ill only when ill is up + * ill_dest_addr_mp ipsq + down ill only when ill is up + * ill_dest_addr ipsq + down ill only when ill is up + * + * ill_state_flags ill_lock ill_lock + * exclusive bit flags ipsq_t ipsq_t + * shared bit flags ill_lock ill_lock + * + * ill_muxid ipsq Not atomic + * + * ill_ipf_gen Not atomic + * ill_frag_count atomics atomics + * ill_type ipsq + down ill only when ill is up + * ill_dlpi_multicast_state ill_lock ill_lock + * ill_dlpi_fastpath_state ill_lock ill_lock + * ill_dlpi_capab_state ipsq ipsq + * ill_max_hops ipsq Not atomic + * + * ill_mtu ill_lock None + * ill_mc_mtu ill_lock None + * + * ill_user_mtu ipsq + ill_lock ill_lock + * ill_reachable_time ipsq + ill_lock ill_lock + * ill_reachable_retrans_time ipsq + ill_lock ill_lock + * ill_max_buf ipsq + ill_lock ill_lock + * + * Next 2 fields need ill_lock because of the get ioctls. They should not + * report partially updated results without executing in the ipsq. + * ill_token ipsq + ill_lock ill_lock + * ill_token_length ipsq + ill_lock ill_lock + * ill_dest_token ipsq + down ill only when ill is up + * ill_xmit_count ipsq + down ill write once + * ill_ip6_mib ipsq + down ill only when ill is up + * ill_icmp6_mib ipsq + down ill only when ill is up + * + * ill_phyint ipsq, ill_g_lock, ill_lock Any of them + * ill_flags ill_lock ill_lock + * ill_nd_lla_mp ipsq + down ill only when ill is up + * ill_nd_lla ipsq + down ill only when ill is up + * ill_nd_lla_len ipsq + down ill only when ill is up + * ill_phys_addr_pend ipsq + down ill only when ill is up + * ill_ifname_pending_err ipsq ipsq + * ill_avl_byppa ipsq, ill_g_lock write once + * + * ill_fastpath_list ill_lock ill_lock + * ill_refcnt ill_lock ill_lock + * ill_ire_cnt ill_lock ill_lock + * ill_cv ill_lock ill_lock + * ill_mcast_nces ill_lock ill_lock + * ill_ncec_cnt ill_lock ill_lock + * ill_nce_cnt ill_lock ill_lock + * ill_ilm_cnt ill_lock ill_lock + * ill_src_ipif ill_g_lock ill_g_lock + * ill_trace ill_lock ill_lock + * ill_usesrc_grp_next ill_g_usesrc_lock ill_g_usesrc_lock + * ill_dhcpinit atomics atomics + * ill_flownotify_mh write once write once + * ill_capab_pending_cnt ipsq ipsq + * ill_ipallmulti_cnt ill_lock ill_lock + * ill_ipallmulti_ilm ill_lock ill_lock + * ill_saved_ire_mp ill_saved_ire_lock ill_saved_ire_lock + * ill_saved_ire_cnt ill_saved_ire_lock ill_saved_ire_lock + * ill_arl ??? ??? + * ill_ire_multicast ipsq + quiescent none + * ill_bound_ipif ipsq ipsq + * ill_actnode ipsq + ipmp_lock ipsq OR ipmp_lock + * ill_grpnode ipsq + ill_g_lock ipsq OR ill_g_lock + * ill_src_ipif ill_g_lock ill_g_lock + * ill_move_ipif ipsq ipsq + * ill_nom_cast ipsq ipsq OR advisory + * ill_refresh_tid ill_lock ill_lock + * ill_grp (for IPMP ill) write once write once + * ill_grp (for underlying ill) ipsq + ill_g_lock ipsq OR ill_g_lock + * ill_grp_pending ill_mcast_serializer ill_mcast_serializer + * ill_mrouter_cnt atomics atomics + * ill_mphysaddr_list ill_lock ill_lock + * + * NOTE: It's OK to make heuristic decisions on an underlying interface + * by using IS_UNDER_IPMP() or comparing ill_grp's raw pointer value. + */ + +/* + * For ioctl restart mechanism see ip_reprocess_ioctl() + */ +struct ip_ioctl_cmd_s; + +typedef int (*ifunc_t)(ipif_t *, struct sockaddr_in *, queue_t *, mblk_t *, + struct ip_ioctl_cmd_s *, void *); + +typedef struct ip_ioctl_cmd_s { + int ipi_cmd; + size_t ipi_copyin_size; + uint_t ipi_flags; + uint_t ipi_cmd_type; + ifunc_t ipi_func; + ifunc_t ipi_func_restart; +} ip_ioctl_cmd_t; + +/* + * ipi_cmd_type: + * + * IF_CMD 1 old style ifreq cmd + * LIF_CMD 2 new style lifreq cmd + * ARP_CMD 3 arpreq cmd + * XARP_CMD 4 xarpreq cmd + * MSFILT_CMD 5 multicast source filter cmd + * MISC_CMD 6 misc cmd (not a more specific one above) + */ + +enum { IF_CMD = 1, LIF_CMD, ARP_CMD, XARP_CMD, MSFILT_CMD, MISC_CMD }; + +#define IPI_DONTCARE 0 /* For ioctl encoded values that don't matter */ + +/* Flag values in ipi_flags */ +#define IPI_PRIV 0x1 /* Command requires PRIV_SYS_IP_CONFIG */ +#define IPI_MODOK 0x2 /* Permitted on mod instance of IP */ +#define IPI_WR 0x4 /* Need to grab writer access */ +#define IPI_GET_CMD 0x8 /* branch to mi_copyout on success */ +/* unused 0x10 */ +#define IPI_NULL_BCONT 0x20 /* ioctl has not data and hence no b_cont */ + +extern ip_ioctl_cmd_t ip_ndx_ioctl_table[]; +extern ip_ioctl_cmd_t ip_misc_ioctl_table[]; +extern int ip_ndx_ioctl_count; +extern int ip_misc_ioctl_count; + +/* Passed down by ARP to IP during I_PLINK/I_PUNLINK */ +typedef struct ipmx_s { + char ipmx_name[LIFNAMSIZ]; /* if name */ + uint_t + ipmx_arpdev_stream : 1, /* This is the arp stream */ + ipmx_notused : 31; +} ipmx_t; + +/* + * State for detecting if a driver supports certain features. + * Support for DL_ENABMULTI_REQ uses ill_dlpi_multicast_state. + * Support for DLPI M_DATA fastpath uses ill_dlpi_fastpath_state. + */ +#define IDS_UNKNOWN 0 /* No DLPI request sent */ +#define IDS_INPROGRESS 1 /* DLPI request sent */ +#define IDS_OK 2 /* DLPI request completed successfully */ +#define IDS_FAILED 3 /* DLPI request failed */ + +/* Support for DL_CAPABILITY_REQ uses ill_dlpi_capab_state. */ +enum { + IDCS_UNKNOWN, + IDCS_PROBE_SENT, + IDCS_OK, + IDCS_RESET_SENT, + IDCS_RENEG, + IDCS_FAILED +}; + +/* Extended NDP Management Structure */ +typedef struct ipndp_s { + ndgetf_t ip_ndp_getf; + ndsetf_t ip_ndp_setf; + caddr_t ip_ndp_data; + char *ip_ndp_name; +} ipndp_t; + +/* IXA Notification types */ +typedef enum { + IXAN_LSO, /* LSO capability change */ + IXAN_PMTU, /* PMTU change */ + IXAN_ZCOPY /* ZEROCOPY capability change */ +} ixa_notify_type_t; + +typedef uint_t ixa_notify_arg_t; + +typedef void (*ixa_notify_t)(void *, ip_xmit_attr_t *ixa, ixa_notify_type_t, + ixa_notify_arg_t); + +/* + * Attribute flags that are common to the transmit and receive attributes + */ +#define IAF_IS_IPV4 0x80000000 /* ipsec_*_v4 */ +#define IAF_TRUSTED_ICMP 0x40000000 /* ipsec_*_icmp_loopback */ +#define IAF_NO_LOOP_ZONEID_SET 0x20000000 /* Zone that shouldn't have */ + /* a copy */ +#define IAF_LOOPBACK_COPY 0x10000000 /* For multi and broadcast */ + +#define IAF_MASK 0xf0000000 /* Flags that are common */ + +/* + * Transmit side attributes used between the transport protocols and IP as + * well as inside IP. It is also used to cache information in the conn_t i.e. + * replaces conn_ire and the IPsec caching in the conn_t. + */ +struct ip_xmit_attr_s { + iaflags_t ixa_flags; /* IXAF_*. See below */ + + uint32_t ixa_free_flags; /* IXA_FREE_*. See below */ + uint32_t ixa_refcnt; /* Using atomics */ + + /* + * Always initialized independently of ixa_flags settings. + * Used by ip_xmit so we keep them up front for cache locality. + */ + uint32_t ixa_xmit_hint; /* For ECMP and GLD TX ring fanout */ + uint_t ixa_pktlen; /* Always set. For frag and stats */ + zoneid_t ixa_zoneid; /* Assumed always set */ + + /* Always set for conn_ip_output(); might be stale */ + /* + * Since TCP keeps the conn_t around past the process going away + * we need to use the "notr" (e.g, ire_refhold_notr) for ixa_ire, + * ixa_nce, and ixa_dce. + */ + ire_t *ixa_ire; /* Forwarding table entry */ + uint_t ixa_ire_generation; + nce_t *ixa_nce; /* Neighbor cache entry */ + dce_t *ixa_dce; /* Destination cache entry */ + uint_t ixa_dce_generation; + uint_t ixa_src_generation; /* If IXAF_VERIFY_SOURCE */ + + uint32_t ixa_src_preferences; /* prefs for src addr select */ + uint32_t ixa_pmtu; /* IXAF_VERIFY_PMTU */ + + /* Set by ULP if IXAF_VERIFY_PMTU; otherwise set by IP */ + uint32_t ixa_fragsize; + + int8_t ixa_use_min_mtu; /* IXAF_USE_MIN_MTU values */ + + pfirepostfrag_t ixa_postfragfn; /* Set internally in IP */ + + in6_addr_t ixa_nexthop_v6; /* IXAF_NEXTHOP_SET */ +#define ixa_nexthop_v4 V4_PART_OF_V6(ixa_nexthop_v6) + + zoneid_t ixa_no_loop_zoneid; /* IXAF_NO_LOOP_ZONEID_SET */ + + uint_t ixa_scopeid; /* For IPv6 link-locals */ + + uint_t ixa_broadcast_ttl; /* IXAF_BROACAST_TTL_SET */ + + uint_t ixa_multicast_ttl; /* Assumed set for multicast */ + uint_t ixa_multicast_ifindex; /* Assumed set for multicast */ + ipaddr_t ixa_multicast_ifaddr; /* Assumed set for multicast */ + + int ixa_raw_cksum_offset; /* If IXAF_SET_RAW_CKSUM */ + + uint32_t ixa_ident; /* For IPv6 fragment header */ + + uint64_t ixa_conn_id; /* Used by DTrace */ + /* + * Cached LSO information. + */ + ill_lso_capab_t ixa_lso_capab; /* Valid when IXAF_LSO_CAPAB */ + + uint64_t ixa_ipsec_policy_gen; /* Generation from iph_gen */ + /* + * The following IPsec fields are only initialized when + * IXAF_IPSEC_SECURE is set. Otherwise they contain garbage. + */ + ipsec_latch_t *ixa_ipsec_latch; /* Just the ids */ + struct ipsa_s *ixa_ipsec_ah_sa; /* Hard reference SA for AH */ + struct ipsa_s *ixa_ipsec_esp_sa; /* Hard reference SA for ESP */ + struct ipsec_policy_s *ixa_ipsec_policy; /* why are we here? */ + struct ipsec_action_s *ixa_ipsec_action; /* For reflected packets */ + ipsa_ref_t ixa_ipsec_ref[2]; /* Soft reference to SA */ + /* 0: ESP, 1: AH */ + + /* + * The selectors here are potentially different than the SPD rule's + * selectors, and we need to have both available for IKEv2. + * + * NOTE: "Source" and "Dest" are w.r.t. outbound datagrams. Ports can + * be zero, and the protocol number is needed to make the ports + * significant. + */ + uint16_t ixa_ipsec_src_port; /* Source port number of d-gram. */ + uint16_t ixa_ipsec_dst_port; /* Destination port number of d-gram. */ + uint8_t ixa_ipsec_icmp_type; /* ICMP type of d-gram */ + uint8_t ixa_ipsec_icmp_code; /* ICMP code of d-gram */ + + sa_family_t ixa_ipsec_inaf; /* Inner address family */ +#define IXA_MAX_ADDRLEN 4 /* Max addr len. (in 32-bit words) */ + uint32_t ixa_ipsec_insrc[IXA_MAX_ADDRLEN]; /* Inner src address */ + uint32_t ixa_ipsec_indst[IXA_MAX_ADDRLEN]; /* Inner dest address */ + uint8_t ixa_ipsec_insrcpfx; /* Inner source prefix */ + uint8_t ixa_ipsec_indstpfx; /* Inner destination prefix */ + + uint8_t ixa_ipsec_proto; /* IP protocol number for d-gram. */ + + /* Always initialized independently of ixa_flags settings */ + uint_t ixa_ifindex; /* Assumed always set */ + uint16_t ixa_ip_hdr_length; /* Points to ULP header */ + uint8_t ixa_protocol; /* Protocol number for ULP cksum */ + ts_label_t *ixa_tsl; /* Always set. NULL if not TX */ + ip_stack_t *ixa_ipst; /* Always set */ + uint32_t ixa_extra_ident; /* Set if LSO */ + cred_t *ixa_cred; /* For getpeerucred */ + pid_t ixa_cpid; /* For getpeerucred */ + +#ifdef DEBUG + kthread_t *ixa_curthread; /* For serialization assert */ +#endif + squeue_t *ixa_sqp; /* Set from conn_sqp as a hint */ + uintptr_t ixa_cookie; /* cookie to use for tx flow control */ + + /* + * Must be set by ULP if any of IXAF_VERIFY_LSO, IXAF_VERIFY_PMTU, + * or IXAF_VERIFY_ZCOPY is set. + */ + ixa_notify_t ixa_notify; /* Registered upcall notify function */ + void *ixa_notify_cookie; /* ULP cookie for ixa_notify */ + + uint_t ixa_tcpcleanup; /* Used by conn_ixa_cleanup */ +}; + +/* + * Flags to indicate which transmit attributes are set. + * Split into "xxx_SET" ones which indicate that the "xxx" field it set, and + * single flags. + */ +#define IXAF_REACH_CONF 0x00000001 /* Reachability confirmation */ +#define IXAF_BROADCAST_TTL_SET 0x00000002 /* ixa_broadcast_ttl valid */ +#define IXAF_SET_SOURCE 0x00000004 /* Replace if broadcast */ +#define IXAF_USE_MIN_MTU 0x00000008 /* IPV6_USE_MIN_MTU */ + +#define IXAF_DONTFRAG 0x00000010 /* IP*_DONTFRAG */ +#define IXAF_VERIFY_PMTU 0x00000020 /* ixa_pmtu/ixa_fragsize set */ +#define IXAF_PMTU_DISCOVERY 0x00000040 /* Create/use PMTU state */ +#define IXAF_MULTICAST_LOOP 0x00000080 /* IP_MULTICAST_LOOP */ + +#define IXAF_IPSEC_SECURE 0x00000100 /* Need IPsec processing */ +#define IXAF_UCRED_TSL 0x00000200 /* ixa_tsl from SCM_UCRED */ +#define IXAF_DONTROUTE 0x00000400 /* SO_DONTROUTE */ +#define IXAF_NO_IPSEC 0x00000800 /* Ignore policy */ + +#define IXAF_PMTU_TOO_SMALL 0x00001000 /* PMTU too small */ +#define IXAF_SET_ULP_CKSUM 0x00002000 /* Calculate ULP checksum */ +#define IXAF_VERIFY_SOURCE 0x00004000 /* Check that source is ok */ +#define IXAF_NEXTHOP_SET 0x00008000 /* ixa_nexthop set */ + +#define IXAF_PMTU_IPV4_DF 0x00010000 /* Set IPv4 DF */ +#define IXAF_NO_DEV_FLOW_CTL 0x00020000 /* Protocol needs no flow ctl */ +#define IXAF_NO_TTL_CHANGE 0x00040000 /* Internal to IP */ +#define IXAF_IPV6_ADD_FRAGHDR 0x00080000 /* Add fragment header */ + +#define IXAF_IPSEC_TUNNEL 0x00100000 /* Tunnel mode */ +#define IXAF_NO_PFHOOK 0x00200000 /* Skip xmit pfhook */ +#define IXAF_NO_TRACE 0x00400000 /* When back from ARP/ND */ +#define IXAF_SCOPEID_SET 0x00800000 /* ixa_scopeid set */ + +#define IXAF_MULTIRT_MULTICAST 0x01000000 /* MULTIRT for multicast */ +#define IXAF_NO_HW_CKSUM 0x02000000 /* Force software cksum */ +#define IXAF_SET_RAW_CKSUM 0x04000000 /* Use ixa_raw_cksum_offset */ +#define IXAF_IPSEC_GLOBAL_POLICY 0x08000000 /* Policy came from global */ + +/* Note the following uses bits 0x10000000 through 0x80000000 */ +#define IXAF_IS_IPV4 IAF_IS_IPV4 +#define IXAF_TRUSTED_ICMP IAF_TRUSTED_ICMP +#define IXAF_NO_LOOP_ZONEID_SET IAF_NO_LOOP_ZONEID_SET +#define IXAF_LOOPBACK_COPY IAF_LOOPBACK_COPY + +/* Note: use the upper 32 bits */ +#define IXAF_VERIFY_LSO 0x100000000 /* Check LSO capability */ +#define IXAF_LSO_CAPAB 0x200000000 /* Capable of LSO */ +#define IXAF_VERIFY_ZCOPY 0x400000000 /* Check Zero Copy capability */ +#define IXAF_ZCOPY_CAPAB 0x800000000 /* Capable of ZEROCOPY */ + +/* + * The normal flags for sending packets e.g., icmp errors + */ +#define IXAF_BASIC_SIMPLE_V4 \ + (IXAF_SET_ULP_CKSUM | IXAF_IS_IPV4 | IXAF_VERIFY_SOURCE) +#define IXAF_BASIC_SIMPLE_V6 (IXAF_SET_ULP_CKSUM | IXAF_VERIFY_SOURCE) + +/* + * Normally these fields do not have a hold. But in some cases they do, for + * instance when we've gone through ip_*_attr_to/from_mblk. + * We use ixa_free_flags to indicate that they have a hold and need to be + * released on cleanup. + */ +#define IXA_FREE_CRED 0x00000001 /* ixa_cred needs to be rele */ +#define IXA_FREE_TSL 0x00000002 /* ixa_tsl needs to be rele */ + +/* + * Trivial state machine used to synchronize IXA cleanup for TCP connections. + * See conn_ixa_cleanup(). + */ +#define IXATC_IDLE 0x00000000 +#define IXATC_INPROGRESS 0x00000001 +#define IXATC_COMPLETE 0x00000002 + +/* + * Simplistic way to set the ixa_xmit_hint for locally generated traffic + * and forwarded traffic. The shift amount are based on the size of the + * structs to discard the low order bits which don't have much if any variation + * (coloring in kmem_cache_alloc might provide some variation). + * + * Basing the locally generated hint on the address of the conn_t means that + * the packets from the same socket/connection do not get reordered. + * Basing the hint for forwarded traffic on the ill_ring_t means that + * packets from the same NIC+ring are likely to use the same outbound ring + * hence we get low contention on the ring in the transmitting driver. + */ +#define CONN_TO_XMIT_HINT(connp) ((uint32_t)(((uintptr_t)connp) >> 11)) +#define ILL_RING_TO_XMIT_HINT(ring) ((uint32_t)(((uintptr_t)ring) >> 7)) + +/* + * IP set Destination Flags used by function ip_set_destination, + * ip_attr_connect, and conn_connect. + */ +#define IPDF_ALLOW_MCBC 0x1 /* Allow multi/broadcast */ +#define IPDF_VERIFY_DST 0x2 /* Verify destination addr */ +#define IPDF_SELECT_SRC 0x4 /* Select source address */ +#define IPDF_LSO 0x8 /* Try LSO */ +#define IPDF_IPSEC 0x10 /* Set IPsec policy */ +#define IPDF_ZONE_IS_GLOBAL 0x20 /* From conn_zone_is_global */ +#define IPDF_ZCOPY 0x40 /* Try ZEROCOPY */ +#define IPDF_UNIQUE_DCE 0x80 /* Get a per-destination DCE */ + +/* + * Receive side attributes used between the transport protocols and IP as + * well as inside IP. + */ +struct ip_recv_attr_s { + iaflags_t ira_flags; /* See below */ + + uint32_t ira_free_flags; /* IRA_FREE_*. See below */ + + /* + * This is a hint for TCP SYN packets. + * Always initialized independently of ira_flags settings + */ + squeue_t *ira_sqp; + ill_rx_ring_t *ira_ring; /* Internal to IP */ + + /* For ip_accept_tcp when IRAF_TARGET_SQP is set */ + squeue_t *ira_target_sqp; + mblk_t *ira_target_sqp_mp; + + /* Always initialized independently of ira_flags settings */ + uint32_t ira_xmit_hint; /* For ECMP and GLD TX ring fanout */ + zoneid_t ira_zoneid; /* ALL_ZONES unless local delivery */ + uint_t ira_pktlen; /* Always set. For frag and stats */ + uint16_t ira_ip_hdr_length; /* Points to ULP header */ + uint8_t ira_protocol; /* Protocol number for ULP cksum */ + uint8_t ira_ttl; /* IP TTL / IPv6 Hop Count */ + uint_t ira_rifindex; /* Received ifindex */ + uint_t ira_ruifindex; /* Received upper ifindex */ + ts_label_t *ira_tsl; /* Always set. NULL if not TX */ + /* + * ira_rill and ira_ill is set inside IP, but not when conn_recv is + * called; ULPs should use ira_ruifindex instead. + */ + ill_t *ira_rill; /* ill where packet came */ + ill_t *ira_ill; /* ill where IP address hosted */ + cred_t *ira_cred; /* For getpeerucred */ + pid_t ira_cpid; /* For getpeerucred */ + + /* Used when IRAF_VERIFIED_SRC is set; this source was ok */ + ipaddr_t ira_verified_src; + + /* + * The following IPsec fields are only initialized when + * IRAF_IPSEC_SECURE is set. Otherwise they contain garbage. + */ + struct ipsec_action_s *ira_ipsec_action; /* how we made it in.. */ + struct ipsa_s *ira_ipsec_ah_sa; /* SA for AH */ + struct ipsa_s *ira_ipsec_esp_sa; /* SA for ESP */ + + ipaddr_t ira_mroute_tunnel; /* IRAF_MROUTE_TUNNEL_SET */ + + zoneid_t ira_no_loop_zoneid; /* IRAF_NO_LOOP_ZONEID_SET */ + + uint32_t ira_esp_udp_ports; /* IRAF_ESP_UDP_PORTS */ + + /* + * For IP_RECVSLLA and ip_ndp_conflict/find_solicitation. + * Same size as max for sockaddr_dl + */ +#define IRA_L2SRC_SIZE 244 + uint8_t ira_l2src[IRA_L2SRC_SIZE]; /* If IRAF_L2SRC_SET */ + + /* + * Local handle that we use to do lazy setting of ira_l2src. + * We defer setting l2src until needed but we do before any + * ip_input pullupmsg or copymsg. + */ + struct mac_header_info_s *ira_mhip; /* Could be NULL */ +}; + +/* + * Flags to indicate which receive attributes are set. + */ +#define IRAF_SYSTEM_LABELED 0x00000001 /* is_system_labeled() */ +#define IRAF_IPV4_OPTIONS 0x00000002 /* Performance */ +#define IRAF_MULTICAST 0x00000004 /* Was multicast at L3 */ +#define IRAF_BROADCAST 0x00000008 /* Was broadcast at L3 */ +#define IRAF_MULTIBROADCAST (IRAF_MULTICAST|IRAF_BROADCAST) + +#define IRAF_LOOPBACK 0x00000010 /* Looped back by IP */ +#define IRAF_VERIFY_IP_CKSUM 0x00000020 /* Need to verify IP */ +#define IRAF_VERIFY_ULP_CKSUM 0x00000040 /* Need to verify TCP,UDP,etc */ +#define IRAF_SCTP_CSUM_ERR 0x00000080 /* sctp pkt has failed chksum */ + +#define IRAF_IPSEC_SECURE 0x00000100 /* Passed AH and/or ESP */ +#define IRAF_DHCP_UNICAST 0x00000200 +#define IRAF_IPSEC_DECAPS 0x00000400 /* Was packet decapsulated */ + /* from a matching inner packet? */ +#define IRAF_TARGET_SQP 0x00000800 /* ira_target_sqp is set */ +#define IRAF_VERIFIED_SRC 0x00001000 /* ira_verified_src set */ +#define IRAF_RSVP 0x00002000 /* RSVP packet for rsvpd */ +#define IRAF_MROUTE_TUNNEL_SET 0x00004000 /* From ip_mroute_decap */ +#define IRAF_PIM_REGISTER 0x00008000 /* From register_mforward */ + +#define IRAF_TX_MAC_EXEMPTABLE 0x00010000 /* Allow MAC_EXEMPT readdown */ +#define IRAF_TX_SHARED_ADDR 0x00020000 /* Arrived on ALL_ZONES addr */ +#define IRAF_ESP_UDP_PORTS 0x00040000 /* NAT-traversal packet */ +#define IRAF_NO_HW_CKSUM 0x00080000 /* Force software cksum */ + +#define IRAF_ICMP_ERROR 0x00100000 /* Send to conn_recvicmp */ +#define IRAF_ROUTER_ALERT 0x00200000 /* IPv6 router alert */ +#define IRAF_L2SRC_SET 0x00400000 /* ira_l2src has been set */ +#define IRAF_L2SRC_LOOPBACK 0x00800000 /* Came from us */ + +#define IRAF_L2DST_MULTICAST 0x01000000 /* Multicast at L2 */ +#define IRAF_L2DST_BROADCAST 0x02000000 /* Broadcast at L2 */ +/* Unused 0x04000000 */ +/* Unused 0x08000000 */ + +/* Below starts with 0x10000000 */ +#define IRAF_IS_IPV4 IAF_IS_IPV4 +#define IRAF_TRUSTED_ICMP IAF_TRUSTED_ICMP +#define IRAF_NO_LOOP_ZONEID_SET IAF_NO_LOOP_ZONEID_SET +#define IRAF_LOOPBACK_COPY IAF_LOOPBACK_COPY + +/* + * Normally these fields do not have a hold. But in some cases they do, for + * instance when we've gone through ip_*_attr_to/from_mblk. + * We use ira_free_flags to indicate that they have a hold and need to be + * released on cleanup. + */ +#define IRA_FREE_CRED 0x00000001 /* ira_cred needs to be rele */ +#define IRA_FREE_TSL 0x00000002 /* ira_tsl needs to be rele */ + +/* + * Optional destination cache entry for path MTU information, + * and ULP metrics. + */ +struct dce_s { + uint_t dce_generation; /* Changed since cached? */ + uint_t dce_flags; /* See below */ + uint_t dce_ipversion; /* IPv4/IPv6 version */ + uint32_t dce_pmtu; /* Path MTU if DCEF_PMTU */ + uint32_t dce_ident; /* Per destination IP ident. */ + iulp_t dce_uinfo; /* Metrics if DCEF_UINFO */ + + struct dce_s *dce_next; + struct dce_s **dce_ptpn; + struct dcb_s *dce_bucket; + + union { + in6_addr_t dceu_v6addr; + ipaddr_t dceu_v4addr; + } dce_u; +#define dce_v4addr dce_u.dceu_v4addr +#define dce_v6addr dce_u.dceu_v6addr + /* Note that for IPv6+IPMP we use the ifindex for the upper interface */ + uint_t dce_ifindex; /* For IPv6 link-locals */ + + kmutex_t dce_lock; + uint_t dce_refcnt; + uint64_t dce_last_change_time; /* Path MTU. In seconds */ + + ip_stack_t *dce_ipst; /* Does not have a netstack_hold */ +}; + +/* + * Values for dce_generation. + * + * If a DCE has DCE_GENERATION_CONDEMNED, the last dce_refrele should delete + * it. + * + * DCE_GENERATION_VERIFY is never stored in dce_generation but it is + * stored in places that cache DCE (such as ixa_dce_generation). + * It is used as a signal that the cache is stale and needs to be reverified. + */ +#define DCE_GENERATION_CONDEMNED 0 +#define DCE_GENERATION_VERIFY 1 +#define DCE_GENERATION_INITIAL 2 +#define DCE_IS_CONDEMNED(dce) \ + ((dce)->dce_generation == DCE_GENERATION_CONDEMNED) + + +/* + * Values for ips_src_generation. + * + * SRC_GENERATION_VERIFY is never stored in ips_src_generation but it is + * stored in places that cache IREs (ixa_src_generation). It is used as a + * signal that the cache is stale and needs to be reverified. + */ +#define SRC_GENERATION_VERIFY 0 +#define SRC_GENERATION_INITIAL 1 + +/* + * The kernel stores security attributes of all gateways in a database made + * up of one or more tsol_gcdb_t elements. Each tsol_gcdb_t contains the + * security-related credentials of the gateway. More than one gateways may + * share entries in the database. + * + * The tsol_gc_t structure represents the gateway to credential association, + * and refers to an entry in the database. One or more tsol_gc_t entities are + * grouped together to form one or more tsol_gcgrp_t, each representing the + * list of security attributes specific to the gateway. A gateway may be + * associated with at most one credentials group. + */ +struct tsol_gcgrp_s; + +extern uchar_t ip6opt_ls; /* TX IPv6 enabler */ + +/* + * Gateway security credential record. + */ +typedef struct tsol_gcdb_s { + uint_t gcdb_refcnt; /* reference count */ + struct rtsa_s gcdb_attr; /* security attributes */ +#define gcdb_mask gcdb_attr.rtsa_mask +#define gcdb_doi gcdb_attr.rtsa_doi +#define gcdb_slrange gcdb_attr.rtsa_slrange +} tsol_gcdb_t; + +/* + * Gateway to credential association. + */ +typedef struct tsol_gc_s { + uint_t gc_refcnt; /* reference count */ + struct tsol_gcgrp_s *gc_grp; /* pointer to group */ + struct tsol_gc_s *gc_prev; /* previous in list */ + struct tsol_gc_s *gc_next; /* next in list */ + tsol_gcdb_t *gc_db; /* pointer to actual credentials */ +} tsol_gc_t; + +/* + * Gateway credentials group address. + */ +typedef struct tsol_gcgrp_addr_s { + int ga_af; /* address family */ + in6_addr_t ga_addr; /* IPv4 mapped or IPv6 address */ +} tsol_gcgrp_addr_t; + +/* + * Gateway credentials group. + */ +typedef struct tsol_gcgrp_s { + uint_t gcgrp_refcnt; /* reference count */ + krwlock_t gcgrp_rwlock; /* lock to protect following */ + uint_t gcgrp_count; /* number of credentials */ + tsol_gc_t *gcgrp_head; /* first credential in list */ + tsol_gc_t *gcgrp_tail; /* last credential in list */ + tsol_gcgrp_addr_t gcgrp_addr; /* next-hop gateway address */ +} tsol_gcgrp_t; + +extern kmutex_t gcgrp_lock; + +#define GC_REFRELE(p) { \ + ASSERT((p)->gc_grp != NULL); \ + rw_enter(&(p)->gc_grp->gcgrp_rwlock, RW_WRITER); \ + ASSERT((p)->gc_refcnt > 0); \ + if (--((p)->gc_refcnt) == 0) \ + gc_inactive(p); \ + else \ + rw_exit(&(p)->gc_grp->gcgrp_rwlock); \ +} + +#define GCGRP_REFHOLD(p) { \ + mutex_enter(&gcgrp_lock); \ + ++((p)->gcgrp_refcnt); \ + ASSERT((p)->gcgrp_refcnt != 0); \ + mutex_exit(&gcgrp_lock); \ +} + +#define GCGRP_REFRELE(p) { \ + mutex_enter(&gcgrp_lock); \ + ASSERT((p)->gcgrp_refcnt > 0); \ + if (--((p)->gcgrp_refcnt) == 0) \ + gcgrp_inactive(p); \ + ASSERT(MUTEX_HELD(&gcgrp_lock)); \ + mutex_exit(&gcgrp_lock); \ +} + +/* + * IRE gateway security attributes structure, pointed to by tsol_ire_gw_secattr + */ +struct tsol_tnrhc; + +struct tsol_ire_gw_secattr_s { + kmutex_t igsa_lock; /* lock to protect following */ + struct tsol_tnrhc *igsa_rhc; /* host entry for gateway */ + tsol_gc_t *igsa_gc; /* for prefix IREs */ +}; + +void irb_refrele_ftable(irb_t *); + +extern struct kmem_cache *rt_entry_cache; + +typedef struct ire4 { + ipaddr_t ire4_mask; /* Mask for matching this IRE. */ + ipaddr_t ire4_addr; /* Address this IRE represents. */ + ipaddr_t ire4_gateway_addr; /* Gateway including for IRE_ONLINK */ + ipaddr_t ire4_setsrc_addr; /* RTF_SETSRC */ +} ire4_t; + +typedef struct ire6 { + in6_addr_t ire6_mask; /* Mask for matching this IRE. */ + in6_addr_t ire6_addr; /* Address this IRE represents. */ + in6_addr_t ire6_gateway_addr; /* Gateway including for IRE_ONLINK */ + in6_addr_t ire6_setsrc_addr; /* RTF_SETSRC */ +} ire6_t; + +typedef union ire_addr { + ire6_t ire6_u; + ire4_t ire4_u; +} ire_addr_u_t; + +/* + * Internet Routing Entry + * When we have multiple identical IREs we logically add them by manipulating + * ire_identical_ref and ire_delete first decrements + * that and when it reaches 1 we know it is the last IRE. + * "identical" is defined as being the same for: + * ire_addr, ire_netmask, ire_gateway, ire_ill, ire_zoneid, and ire_type + * For instance, multiple IRE_BROADCASTs for the same subnet number are + * viewed as identical, and so are the IRE_INTERFACEs when there are + * multiple logical interfaces (on the same ill) with the same subnet prefix. + */ +struct ire_s { + struct ire_s *ire_next; /* The hash chain must be first. */ + struct ire_s **ire_ptpn; /* Pointer to previous next. */ + uint32_t ire_refcnt; /* Number of references */ + ill_t *ire_ill; + uint32_t ire_identical_ref; /* IRE_INTERFACE, IRE_BROADCAST */ + uchar_t ire_ipversion; /* IPv4/IPv6 version */ + ushort_t ire_type; /* Type of IRE */ + uint_t ire_generation; /* Generation including CONDEMNED */ + uint_t ire_ib_pkt_count; /* Inbound packets for ire_addr */ + uint_t ire_ob_pkt_count; /* Outbound packets to ire_addr */ + time_t ire_create_time; /* Time (in secs) IRE was created. */ + uint32_t ire_flags; /* flags related to route (RTF_*) */ + /* + * ire_testhidden is TRUE for INTERFACE IREs of IS_UNDER_IPMP(ill) + * interfaces + */ + boolean_t ire_testhidden; + pfirerecv_t ire_recvfn; /* Receive side handling */ + pfiresend_t ire_sendfn; /* Send side handling */ + pfirepostfrag_t ire_postfragfn; /* Bottom end of send handling */ + + uint_t ire_masklen; /* # bits in ire_mask{,_v6} */ + ire_addr_u_t ire_u; /* IPv4/IPv6 address info. */ + + irb_t *ire_bucket; /* Hash bucket when ire_ptphn is set */ + kmutex_t ire_lock; + clock_t ire_last_used_time; /* For IRE_LOCAL reception */ + tsol_ire_gw_secattr_t *ire_gw_secattr; /* gateway security attributes */ + zoneid_t ire_zoneid; + + /* + * Cached information of where to send packets that match this route. + * The ire_dep_* information is used to determine when ire_nce_cache + * needs to be updated. + * ire_nce_cache is the fastpath for the Neighbor Cache Entry + * for IPv6; arp info for IPv4 + * Since this is a cache setup and torn down independently of + * applications we need to use nce_ref{rele,hold}_notr for it. + */ + nce_t *ire_nce_cache; + + /* + * Quick check whether the ire_type and ire_masklen indicates + * that the IRE can have ire_nce_cache set i.e., whether it is + * IRE_ONLINK and for a single destination. + */ + boolean_t ire_nce_capable; + + /* + * Dependency tracking so we can safely cache IRE and NCE pointers + * in offlink and onlink IREs. + * These are locked under the ips_ire_dep_lock rwlock. Write held + * when modifying the linkage. + * ire_dep_parent (Also chain towards IRE for nexthop) + * ire_dep_parent_generation: ire_generation of ire_dep_parent + * ire_dep_children (From parent to first child) + * ire_dep_sib_next (linked list of siblings) + * ire_dep_sib_ptpn (linked list of siblings) + * + * The parent has a ire_refhold on each child, and each child has + * an ire_refhold on its parent. + * Since ire_dep_parent is a cache setup and torn down independently of + * applications we need to use ire_ref{rele,hold}_notr for it. + */ + ire_t *ire_dep_parent; + ire_t *ire_dep_children; + ire_t *ire_dep_sib_next; + ire_t **ire_dep_sib_ptpn; /* Pointer to previous next */ + uint_t ire_dep_parent_generation; + + uint_t ire_badcnt; /* Number of times ND_UNREACHABLE */ + uint64_t ire_last_badcnt; /* In seconds */ + + /* ire_defense* and ire_last_used_time are only used on IRE_LOCALs */ + uint_t ire_defense_count; /* number of ARP conflicts */ + uint_t ire_defense_time; /* last time defended (secs) */ + + boolean_t ire_trace_disable; /* True when alloc fails */ + ip_stack_t *ire_ipst; /* Does not have a netstack_hold */ + iulp_t ire_metrics; + /* + * default and prefix routes that are added without explicitly + * specifying the interface are termed "unbound" routes, and will + * have ire_unbound set to true. + */ + boolean_t ire_unbound; +}; + +/* IPv4 compatibility macros */ +#define ire_mask ire_u.ire4_u.ire4_mask +#define ire_addr ire_u.ire4_u.ire4_addr +#define ire_gateway_addr ire_u.ire4_u.ire4_gateway_addr +#define ire_setsrc_addr ire_u.ire4_u.ire4_setsrc_addr + +#define ire_mask_v6 ire_u.ire6_u.ire6_mask +#define ire_addr_v6 ire_u.ire6_u.ire6_addr +#define ire_gateway_addr_v6 ire_u.ire6_u.ire6_gateway_addr +#define ire_setsrc_addr_v6 ire_u.ire6_u.ire6_setsrc_addr + +/* + * Values for ire_generation. + * + * If an IRE is marked with IRE_IS_CONDEMNED, the last walker of + * the bucket should delete this IRE from this bucket. + * + * IRE_GENERATION_VERIFY is never stored in ire_generation but it is + * stored in places that cache IREs (such as ixa_ire_generation and + * ire_dep_parent_generation). It is used as a signal that the cache is + * stale and needs to be reverified. + */ +#define IRE_GENERATION_CONDEMNED 0 +#define IRE_GENERATION_VERIFY 1 +#define IRE_GENERATION_INITIAL 2 +#define IRE_IS_CONDEMNED(ire) \ + ((ire)->ire_generation == IRE_GENERATION_CONDEMNED) + +/* Convenient typedefs for sockaddrs */ +typedef struct sockaddr_in sin_t; +typedef struct sockaddr_in6 sin6_t; + +/* Name/Value Descriptor. */ +typedef struct nv_s { + uint64_t nv_value; + char *nv_name; +} nv_t; + +#define ILL_FRAG_HASH(s, i) \ + ((ntohl(s) ^ ((i) ^ ((i) >> 8))) % ILL_FRAG_HASH_TBL_COUNT) + +/* + * The MAX number of allowed fragmented packets per hash bucket + * calculation is based on the most common mtu size of 1500. This limit + * will work well for other mtu sizes as well. + */ +#define COMMON_IP_MTU 1500 +#define MAX_FRAG_MIN 10 +#define MAX_FRAG_PKTS(ipst) \ + MAX(MAX_FRAG_MIN, (2 * (ipst->ips_ip_reass_queue_bytes / \ + (COMMON_IP_MTU * ILL_FRAG_HASH_TBL_COUNT)))) + +/* + * Maximum dups allowed per packet. + */ +extern uint_t ip_max_frag_dups; + +/* + * Per-packet information for received packets and transmitted. + * Used by the transport protocols when converting between the packet + * and ancillary data and socket options. + * + * Note: This private data structure and related IPPF_* constant + * definitions are exposed to enable compilation of some debugging tools + * like lsof which use struct tcp_t in . This is intended to be + * a temporary hack and long term alternate interfaces should be defined + * to support the needs of such tools and private definitions moved to + * private headers. + */ +struct ip_pkt_s { + uint_t ipp_fields; /* Which fields are valid */ + in6_addr_t ipp_addr; /* pktinfo src/dst addr */ +#define ipp_addr_v4 V4_PART_OF_V6(ipp_addr) + uint_t ipp_unicast_hops; /* IPV6_UNICAST_HOPS, IP_TTL */ + uint_t ipp_hoplimit; /* IPV6_HOPLIMIT */ + uint_t ipp_hopoptslen; + uint_t ipp_rthdrdstoptslen; + uint_t ipp_rthdrlen; + uint_t ipp_dstoptslen; + uint_t ipp_fraghdrlen; + ip6_hbh_t *ipp_hopopts; + ip6_dest_t *ipp_rthdrdstopts; + ip6_rthdr_t *ipp_rthdr; + ip6_dest_t *ipp_dstopts; + ip6_frag_t *ipp_fraghdr; + uint8_t ipp_tclass; /* IPV6_TCLASS */ + uint8_t ipp_type_of_service; /* IP_TOS */ + uint_t ipp_ipv4_options_len; /* Len of IPv4 options */ + uint8_t *ipp_ipv4_options; /* Ptr to IPv4 options */ + uint_t ipp_label_len_v4; /* Len of TX label for IPv4 */ + uint8_t *ipp_label_v4; /* TX label for IPv4 */ + uint_t ipp_label_len_v6; /* Len of TX label for IPv6 */ + uint8_t *ipp_label_v6; /* TX label for IPv6 */ +}; +typedef struct ip_pkt_s ip_pkt_t; + +extern void ip_pkt_free(ip_pkt_t *); /* free storage inside ip_pkt_t */ +extern ipaddr_t ip_pkt_source_route_v4(const ip_pkt_t *); +extern in6_addr_t *ip_pkt_source_route_v6(const ip_pkt_t *); +extern int ip_pkt_copy(ip_pkt_t *, ip_pkt_t *, int); +extern void ip_pkt_source_route_reverse_v4(ip_pkt_t *); + +/* ipp_fields values */ +#define IPPF_ADDR 0x0001 /* Part of in6_pktinfo: src/dst addr */ +#define IPPF_HOPLIMIT 0x0002 /* Overrides unicast and multicast */ +#define IPPF_TCLASS 0x0004 /* Overrides class in sin6_flowinfo */ + +#define IPPF_HOPOPTS 0x0010 /* ipp_hopopts set */ +#define IPPF_RTHDR 0x0020 /* ipp_rthdr set */ +#define IPPF_RTHDRDSTOPTS 0x0040 /* ipp_rthdrdstopts set */ +#define IPPF_DSTOPTS 0x0080 /* ipp_dstopts set */ + +#define IPPF_IPV4_OPTIONS 0x0100 /* ipp_ipv4_options set */ +#define IPPF_LABEL_V4 0x0200 /* ipp_label_v4 set */ +#define IPPF_LABEL_V6 0x0400 /* ipp_label_v6 set */ + +#define IPPF_FRAGHDR 0x0800 /* Used for IPsec receive side */ + +/* + * Data structure which is passed to conn_opt_get/set. + * The conn_t is included even though it can be inferred from queue_t. + * setsockopt and getsockopt use conn_ixa and conn_xmit_ipp. However, + * when handling ancillary data we use separate ixa and ipps. + */ +typedef struct conn_opt_arg_s { + conn_t *coa_connp; + ip_xmit_attr_t *coa_ixa; + ip_pkt_t *coa_ipp; + boolean_t coa_ancillary; /* Ancillary data and not setsockopt */ + uint_t coa_changed; /* See below */ +} conn_opt_arg_t; + +/* + * Flags for what changed. + * If we want to be more efficient in the future we can have more fine + * grained flags e.g., a flag for just IP_TOS changing. + * For now we either call ip_set_destination (for "route changed") + * and/or conn_build_hdr_template/conn_prepend_hdr (for "header changed"). + */ +#define COA_HEADER_CHANGED 0x0001 +#define COA_ROUTE_CHANGED 0x0002 +#define COA_RCVBUF_CHANGED 0x0004 /* SO_RCVBUF */ +#define COA_SNDBUF_CHANGED 0x0008 /* SO_SNDBUF */ +#define COA_WROFF_CHANGED 0x0010 /* Header size changed */ +#define COA_ICMP_BIND_NEEDED 0x0020 +#define COA_OOBINLINE_CHANGED 0x0040 + +#define TCP_PORTS_OFFSET 0 +#define UDP_PORTS_OFFSET 0 + +/* + * lookups return the ill/ipif only if the flags are clear OR Iam writer. + * ill / ipif lookup functions increment the refcnt on the ill / ipif only + * after calling these macros. This ensures that the refcnt on the ipif or + * ill will eventually drop down to zero. + */ +#define ILL_LOOKUP_FAILED 1 /* Used as error code */ +#define IPIF_LOOKUP_FAILED 2 /* Used as error code */ + +#define ILL_CAN_LOOKUP(ill) \ + (!((ill)->ill_state_flags & ILL_CONDEMNED) || \ + IAM_WRITER_ILL(ill)) + +#define ILL_IS_CONDEMNED(ill) \ + ((ill)->ill_state_flags & ILL_CONDEMNED) + +#define IPIF_CAN_LOOKUP(ipif) \ + (!((ipif)->ipif_state_flags & IPIF_CONDEMNED) || \ + IAM_WRITER_IPIF(ipif)) + +#define IPIF_IS_CONDEMNED(ipif) \ + ((ipif)->ipif_state_flags & IPIF_CONDEMNED) + +#define IPIF_IS_CHANGING(ipif) \ + ((ipif)->ipif_state_flags & IPIF_CHANGING) + +/* Macros used to assert that this thread is a writer */ +#define IAM_WRITER_IPSQ(ipsq) ((ipsq)->ipsq_xop->ipx_writer == curthread) +#define IAM_WRITER_ILL(ill) IAM_WRITER_IPSQ((ill)->ill_phyint->phyint_ipsq) +#define IAM_WRITER_IPIF(ipif) IAM_WRITER_ILL((ipif)->ipif_ill) + +/* + * Grab ill locks in the proper order. The order is highest addressed + * ill is locked first. + */ +#define GRAB_ILL_LOCKS(ill_1, ill_2) \ +{ \ + if ((ill_1) > (ill_2)) { \ + if (ill_1 != NULL) \ + mutex_enter(&(ill_1)->ill_lock); \ + if (ill_2 != NULL) \ + mutex_enter(&(ill_2)->ill_lock); \ + } else { \ + if (ill_2 != NULL) \ + mutex_enter(&(ill_2)->ill_lock); \ + if (ill_1 != NULL && ill_1 != ill_2) \ + mutex_enter(&(ill_1)->ill_lock); \ + } \ +} + +#define RELEASE_ILL_LOCKS(ill_1, ill_2) \ +{ \ + if (ill_1 != NULL) \ + mutex_exit(&(ill_1)->ill_lock); \ + if (ill_2 != NULL && ill_2 != ill_1) \ + mutex_exit(&(ill_2)->ill_lock); \ +} + +/* Get the other protocol instance ill */ +#define ILL_OTHER(ill) \ + ((ill)->ill_isv6 ? (ill)->ill_phyint->phyint_illv4 : \ + (ill)->ill_phyint->phyint_illv6) + +/* ioctl command info: Ioctl properties extracted and stored in here */ +typedef struct cmd_info_s +{ + ipif_t *ci_ipif; /* ipif associated with [l]ifreq ioctl's */ + sin_t *ci_sin; /* the sin struct passed down */ + sin6_t *ci_sin6; /* the sin6_t struct passed down */ + struct lifreq *ci_lifr; /* the lifreq struct passed down */ +} cmd_info_t; + +extern struct kmem_cache *ire_cache; + +extern ipaddr_t ip_g_all_ones; + +extern uint_t ip_loopback_mtu; /* /etc/system */ +extern uint_t ip_loopback_mtuplus; +extern uint_t ip_loopback_mtu_v6plus; + +extern vmem_t *ip_minor_arena_sa; +extern vmem_t *ip_minor_arena_la; + +/* + * ip_g_forward controls IP forwarding. It takes two values: + * 0: IP_FORWARD_NEVER Don't forward packets ever. + * 1: IP_FORWARD_ALWAYS Forward packets for elsewhere. + * + * RFC1122 says there must be a configuration switch to control forwarding, + * but that the default MUST be to not forward packets ever. Implicit + * control based on configuration of multiple interfaces MUST NOT be + * implemented (Section 3.1). SunOS 4.1 did provide the "automatic" capability + * and, in fact, it was the default. That capability is now provided in the + * /etc/rc2.d/S69inet script. + */ + +#define ips_ip_respond_to_address_mask_broadcast \ + ips_propinfo_tbl[0].prop_cur_bval +#define ips_ip_g_resp_to_echo_bcast ips_propinfo_tbl[1].prop_cur_bval +#define ips_ip_g_resp_to_echo_mcast ips_propinfo_tbl[2].prop_cur_bval +#define ips_ip_g_resp_to_timestamp ips_propinfo_tbl[3].prop_cur_bval +#define ips_ip_g_resp_to_timestamp_bcast ips_propinfo_tbl[4].prop_cur_bval +#define ips_ip_g_send_redirects ips_propinfo_tbl[5].prop_cur_bval +#define ips_ip_g_forward_directed_bcast ips_propinfo_tbl[6].prop_cur_bval +#define ips_ip_mrtdebug ips_propinfo_tbl[7].prop_cur_uval +#define ips_ip_ire_reclaim_fraction ips_propinfo_tbl[8].prop_cur_uval +#define ips_ip_nce_reclaim_fraction ips_propinfo_tbl[9].prop_cur_uval +#define ips_ip_dce_reclaim_fraction ips_propinfo_tbl[10].prop_cur_uval +#define ips_ip_def_ttl ips_propinfo_tbl[11].prop_cur_uval +#define ips_ip_forward_src_routed ips_propinfo_tbl[12].prop_cur_bval +#define ips_ip_wroff_extra ips_propinfo_tbl[13].prop_cur_uval +#define ips_ip_pathmtu_interval ips_propinfo_tbl[14].prop_cur_uval +#define ips_ip_icmp_return ips_propinfo_tbl[15].prop_cur_uval +#define ips_ip_path_mtu_discovery ips_propinfo_tbl[16].prop_cur_bval +#define ips_ip_pmtu_min ips_propinfo_tbl[17].prop_cur_uval +#define ips_ip_ignore_redirect ips_propinfo_tbl[18].prop_cur_bval +#define ips_ip_arp_icmp_error ips_propinfo_tbl[19].prop_cur_bval +#define ips_ip_broadcast_ttl ips_propinfo_tbl[20].prop_cur_uval +#define ips_ip_icmp_err_interval ips_propinfo_tbl[21].prop_cur_uval +#define ips_ip_icmp_err_burst ips_propinfo_tbl[22].prop_cur_uval +#define ips_ip_reass_queue_bytes ips_propinfo_tbl[23].prop_cur_uval +#define ips_ip_strict_dst_multihoming ips_propinfo_tbl[24].prop_cur_uval +#define ips_ip_addrs_per_if ips_propinfo_tbl[25].prop_cur_uval +#define ips_ipsec_override_persocket_policy ips_propinfo_tbl[26].prop_cur_bval +#define ips_icmp_accept_clear_messages ips_propinfo_tbl[27].prop_cur_bval +#define ips_igmp_accept_clear_messages ips_propinfo_tbl[28].prop_cur_bval + +/* IPv6 configuration knobs */ +#define ips_delay_first_probe_time ips_propinfo_tbl[29].prop_cur_uval +#define ips_max_unicast_solicit ips_propinfo_tbl[30].prop_cur_uval +#define ips_ipv6_def_hops ips_propinfo_tbl[31].prop_cur_uval +#define ips_ipv6_icmp_return ips_propinfo_tbl[32].prop_cur_uval +#define ips_ipv6_forward_src_routed ips_propinfo_tbl[33].prop_cur_bval +#define ips_ipv6_resp_echo_mcast ips_propinfo_tbl[34].prop_cur_bval +#define ips_ipv6_send_redirects ips_propinfo_tbl[35].prop_cur_bval +#define ips_ipv6_ignore_redirect ips_propinfo_tbl[36].prop_cur_bval +#define ips_ipv6_strict_dst_multihoming ips_propinfo_tbl[37].prop_cur_uval +#define ips_src_check ips_propinfo_tbl[38].prop_cur_uval +#define ips_ipsec_policy_log_interval ips_propinfo_tbl[39].prop_cur_uval +#define ips_pim_accept_clear_messages ips_propinfo_tbl[40].prop_cur_bval +#define ips_ip_ndp_unsolicit_interval ips_propinfo_tbl[41].prop_cur_uval +#define ips_ip_ndp_unsolicit_count ips_propinfo_tbl[42].prop_cur_uval +#define ips_ipv6_ignore_home_address_opt ips_propinfo_tbl[43].prop_cur_bval + +/* Misc IP configuration knobs */ +#define ips_ip_policy_mask ips_propinfo_tbl[44].prop_cur_uval +#define ips_ip_ecmp_behavior ips_propinfo_tbl[45].prop_cur_uval +#define ips_ip_multirt_ttl ips_propinfo_tbl[46].prop_cur_uval +#define ips_ip_ire_badcnt_lifetime ips_propinfo_tbl[47].prop_cur_uval +#define ips_ip_max_temp_idle ips_propinfo_tbl[48].prop_cur_uval +#define ips_ip_max_temp_defend ips_propinfo_tbl[49].prop_cur_uval +#define ips_ip_max_defend ips_propinfo_tbl[50].prop_cur_uval +#define ips_ip_defend_interval ips_propinfo_tbl[51].prop_cur_uval +#define ips_ip_dup_recovery ips_propinfo_tbl[52].prop_cur_uval +#define ips_ip_restrict_interzone_loopback ips_propinfo_tbl[53].prop_cur_bval +#define ips_ip_lso_outbound ips_propinfo_tbl[54].prop_cur_bval +#define ips_igmp_max_version ips_propinfo_tbl[55].prop_cur_uval +#define ips_mld_max_version ips_propinfo_tbl[56].prop_cur_uval +#define ips_ip_forwarding ips_propinfo_tbl[57].prop_cur_bval +#define ips_ipv6_forwarding ips_propinfo_tbl[58].prop_cur_bval +#define ips_ip_reassembly_timeout ips_propinfo_tbl[59].prop_cur_uval +#define ips_ipv6_reassembly_timeout ips_propinfo_tbl[60].prop_cur_uval +#define ips_ip_cgtp_filter ips_propinfo_tbl[61].prop_cur_bval +#define ips_arp_probe_delay ips_propinfo_tbl[62].prop_cur_uval +#define ips_arp_fastprobe_delay ips_propinfo_tbl[63].prop_cur_uval +#define ips_arp_probe_interval ips_propinfo_tbl[64].prop_cur_uval +#define ips_arp_fastprobe_interval ips_propinfo_tbl[65].prop_cur_uval +#define ips_arp_probe_count ips_propinfo_tbl[66].prop_cur_uval +#define ips_arp_fastprobe_count ips_propinfo_tbl[67].prop_cur_uval +#define ips_ipv4_dad_announce_interval ips_propinfo_tbl[68].prop_cur_uval +#define ips_ipv6_dad_announce_interval ips_propinfo_tbl[69].prop_cur_uval +#define ips_arp_defend_interval ips_propinfo_tbl[70].prop_cur_uval +#define ips_arp_defend_rate ips_propinfo_tbl[71].prop_cur_uval +#define ips_ndp_defend_interval ips_propinfo_tbl[72].prop_cur_uval +#define ips_ndp_defend_rate ips_propinfo_tbl[73].prop_cur_uval +#define ips_arp_defend_period ips_propinfo_tbl[74].prop_cur_uval +#define ips_ndp_defend_period ips_propinfo_tbl[75].prop_cur_uval +#define ips_ipv4_icmp_return_pmtu ips_propinfo_tbl[76].prop_cur_bval +#define ips_ipv6_icmp_return_pmtu ips_propinfo_tbl[77].prop_cur_bval +#define ips_ip_arp_publish_count ips_propinfo_tbl[78].prop_cur_uval +#define ips_ip_arp_publish_interval ips_propinfo_tbl[79].prop_cur_uval +#define ips_ip_strict_src_multihoming ips_propinfo_tbl[80].prop_cur_uval +#define ips_ipv6_strict_src_multihoming ips_propinfo_tbl[81].prop_cur_uval +#define ips_ipv6_drop_inbound_icmpv6 ips_propinfo_tbl[82].prop_cur_bval +#define ips_ip_dce_reclaim_threshold ips_propinfo_tbl[83].prop_cur_uval + +extern int dohwcksum; /* use h/w cksum if supported by the h/w */ +#ifdef ZC_TEST +extern int noswcksum; +#endif + +extern char ipif_loopback_name[]; + +extern nv_t *ire_nv_tbl; + +extern struct module_info ip_mod_info; + +#define HOOKS4_INTERESTED_PHYSICAL_IN(ipst) \ + ((ipst)->ips_ip4_physical_in_event.he_interested) +#define HOOKS6_INTERESTED_PHYSICAL_IN(ipst) \ + ((ipst)->ips_ip6_physical_in_event.he_interested) +#define HOOKS4_INTERESTED_PHYSICAL_OUT(ipst) \ + ((ipst)->ips_ip4_physical_out_event.he_interested) +#define HOOKS6_INTERESTED_PHYSICAL_OUT(ipst) \ + ((ipst)->ips_ip6_physical_out_event.he_interested) +#define HOOKS4_INTERESTED_FORWARDING(ipst) \ + ((ipst)->ips_ip4_forwarding_event.he_interested) +#define HOOKS6_INTERESTED_FORWARDING(ipst) \ + ((ipst)->ips_ip6_forwarding_event.he_interested) +#define HOOKS4_INTERESTED_LOOPBACK_IN(ipst) \ + ((ipst)->ips_ip4_loopback_in_event.he_interested) +#define HOOKS6_INTERESTED_LOOPBACK_IN(ipst) \ + ((ipst)->ips_ip6_loopback_in_event.he_interested) +#define HOOKS4_INTERESTED_LOOPBACK_OUT(ipst) \ + ((ipst)->ips_ip4_loopback_out_event.he_interested) +#define HOOKS6_INTERESTED_LOOPBACK_OUT(ipst) \ + ((ipst)->ips_ip6_loopback_out_event.he_interested) +/* + * Hooks marcos used inside of ip + * The callers use the above INTERESTED macros first, hence + * the he_interested check is superflous. + */ +#define FW_HOOKS(_hook, _event, _ilp, _olp, _iph, _fm, _m, _llm, ipst, _err) \ + if ((_hook).he_interested) { \ + hook_pkt_event_t info; \ + \ + _NOTE(CONSTCOND) \ + ASSERT((_ilp != NULL) || (_olp != NULL)); \ + \ + FW_SET_ILL_INDEX(info.hpe_ifp, (ill_t *)_ilp); \ + FW_SET_ILL_INDEX(info.hpe_ofp, (ill_t *)_olp); \ + info.hpe_protocol = ipst->ips_ipv4_net_data; \ + info.hpe_hdr = _iph; \ + info.hpe_mp = &(_fm); \ + info.hpe_mb = _m; \ + info.hpe_flags = _llm; \ + _err = hook_run(ipst->ips_ipv4_net_data->netd_hooks, \ + _event, (hook_data_t)&info); \ + if (_err != 0) { \ + ip2dbg(("%s hook dropped mblk chain %p hdr %p\n",\ + (_hook).he_name, (void *)_fm, (void *)_m)); \ + if (_fm != NULL) { \ + freemsg(_fm); \ + _fm = NULL; \ + } \ + _iph = NULL; \ + _m = NULL; \ + } else { \ + _iph = info.hpe_hdr; \ + _m = info.hpe_mb; \ + } \ + } + +#define FW_HOOKS6(_hook, _event, _ilp, _olp, _iph, _fm, _m, _llm, ipst, _err) \ + if ((_hook).he_interested) { \ + hook_pkt_event_t info; \ + \ + _NOTE(CONSTCOND) \ + ASSERT((_ilp != NULL) || (_olp != NULL)); \ + \ + FW_SET_ILL_INDEX(info.hpe_ifp, (ill_t *)_ilp); \ + FW_SET_ILL_INDEX(info.hpe_ofp, (ill_t *)_olp); \ + info.hpe_protocol = ipst->ips_ipv6_net_data; \ + info.hpe_hdr = _iph; \ + info.hpe_mp = &(_fm); \ + info.hpe_mb = _m; \ + info.hpe_flags = _llm; \ + _err = hook_run(ipst->ips_ipv6_net_data->netd_hooks, \ + _event, (hook_data_t)&info); \ + if (_err != 0) { \ + ip2dbg(("%s hook dropped mblk chain %p hdr %p\n",\ + (_hook).he_name, (void *)_fm, (void *)_m)); \ + if (_fm != NULL) { \ + freemsg(_fm); \ + _fm = NULL; \ + } \ + _iph = NULL; \ + _m = NULL; \ + } else { \ + _iph = info.hpe_hdr; \ + _m = info.hpe_mb; \ + } \ + } + +#define FW_SET_ILL_INDEX(fp, ill) \ + _NOTE(CONSTCOND) \ + if ((ill) == NULL || (ill)->ill_phyint == NULL) { \ + (fp) = 0; \ + _NOTE(CONSTCOND) \ + } else if (IS_UNDER_IPMP(ill)) { \ + (fp) = ipmp_ill_get_ipmp_ifindex(ill); \ + } else { \ + (fp) = (ill)->ill_phyint->phyint_ifindex; \ + } + +/* + * Network byte order macros + */ +#ifdef _BIG_ENDIAN +#define N_IN_CLASSA_NET IN_CLASSA_NET +#define N_IN_CLASSD_NET IN_CLASSD_NET +#define N_INADDR_UNSPEC_GROUP INADDR_UNSPEC_GROUP +#define N_IN_LOOPBACK_NET (ipaddr_t)0x7f000000U +#else /* _BIG_ENDIAN */ +#define N_IN_CLASSA_NET (ipaddr_t)0x000000ffU +#define N_IN_CLASSD_NET (ipaddr_t)0x000000f0U +#define N_INADDR_UNSPEC_GROUP (ipaddr_t)0x000000e0U +#define N_IN_LOOPBACK_NET (ipaddr_t)0x0000007fU +#endif /* _BIG_ENDIAN */ +#define CLASSD(addr) (((addr) & N_IN_CLASSD_NET) == N_INADDR_UNSPEC_GROUP) +#define CLASSE(addr) (((addr) & N_IN_CLASSD_NET) == N_IN_CLASSD_NET) +#define IP_LOOPBACK_ADDR(addr) \ + (((addr) & N_IN_CLASSA_NET == N_IN_LOOPBACK_NET)) + +extern int ip_debug; +extern uint_t ip_thread_data; +extern krwlock_t ip_thread_rwlock; +extern list_t ip_thread_list; + +#ifdef IP_DEBUG +#include +#include + +#define ip0dbg(a) printf a +#define ip1dbg(a) if (ip_debug > 2) printf a +#define ip2dbg(a) if (ip_debug > 3) printf a +#define ip3dbg(a) if (ip_debug > 4) printf a +#else +#define ip0dbg(a) /* */ +#define ip1dbg(a) /* */ +#define ip2dbg(a) /* */ +#define ip3dbg(a) /* */ +#endif /* IP_DEBUG */ + +/* Default MAC-layer address string length for mac_colon_addr */ +#define MAC_STR_LEN 128 + +struct mac_header_info_s; + +extern void ill_frag_timer(void *); +extern ill_t *ill_first(int, int, ill_walk_context_t *, ip_stack_t *); +extern ill_t *ill_next(ill_walk_context_t *, ill_t *); +extern void ill_frag_timer_start(ill_t *); +extern void ill_nic_event_dispatch(ill_t *, lif_if_t, nic_event_t, + nic_event_data_t, size_t); +extern mblk_t *ip_carve_mp(mblk_t **, ssize_t); +extern mblk_t *ip_dlpi_alloc(size_t, t_uscalar_t); +extern mblk_t *ip_dlnotify_alloc(uint_t, uint_t); +extern mblk_t *ip_dlnotify_alloc2(uint_t, uint_t, uint_t); +extern char *ip_dot_addr(ipaddr_t, char *); +extern const char *mac_colon_addr(const uint8_t *, size_t, char *, size_t); +extern int ip_lwput(queue_t *, mblk_t *); +extern boolean_t icmp_err_rate_limit(ip_stack_t *); +extern void icmp_frag_needed(mblk_t *, int, ip_recv_attr_t *); +extern mblk_t *icmp_inbound_v4(mblk_t *, ip_recv_attr_t *); +extern void icmp_time_exceeded(mblk_t *, uint8_t, ip_recv_attr_t *); +extern void icmp_unreachable(mblk_t *, uint8_t, ip_recv_attr_t *); +extern boolean_t ip_ipsec_policy_inherit(conn_t *, conn_t *, ip_recv_attr_t *); +extern void *ip_pullup(mblk_t *, ssize_t, ip_recv_attr_t *); +extern void ip_setl2src(mblk_t *, ip_recv_attr_t *, ill_t *); +extern mblk_t *ip_check_and_align_header(mblk_t *, uint_t, ip_recv_attr_t *); +extern mblk_t *ip_check_length(mblk_t *, uchar_t *, ssize_t, uint_t, uint_t, + ip_recv_attr_t *); +extern mblk_t *ip_check_optlen(mblk_t *, ipha_t *, uint_t, uint_t, + ip_recv_attr_t *); +extern mblk_t *ip_fix_dbref(mblk_t *, ip_recv_attr_t *); +extern uint_t ip_cksum(mblk_t *, int, uint32_t); +extern int ip_close(queue_t *, int, cred_t *); +extern uint16_t ip_csum_hdr(ipha_t *); +extern void ip_forward_xmit_v4(nce_t *, ill_t *, mblk_t *, ipha_t *, + ip_recv_attr_t *, uint32_t, uint32_t); +extern boolean_t ip_forward_options(mblk_t *, ipha_t *, ill_t *, + ip_recv_attr_t *); +extern int ip_fragment_v4(mblk_t *, nce_t *, iaflags_t, uint_t, uint32_t, + uint32_t, zoneid_t, zoneid_t, pfirepostfrag_t postfragfn, + uintptr_t *cookie); +extern void ip_proto_not_sup(mblk_t *, ip_recv_attr_t *); +extern void ip_ire_g_fini(void); +extern void ip_ire_g_init(void); +extern void ip_ire_fini(ip_stack_t *); +extern void ip_ire_init(ip_stack_t *); +extern void ip_mdata_to_mhi(ill_t *, mblk_t *, struct mac_header_info_s *); +extern int ip_openv4(queue_t *q, dev_t *devp, int flag, int sflag, + cred_t *credp); +extern int ip_openv6(queue_t *q, dev_t *devp, int flag, int sflag, + cred_t *credp); +extern int ip_reassemble(mblk_t *, ipf_t *, uint_t, boolean_t, ill_t *, + size_t); +extern int ip_rput(queue_t *, mblk_t *); +extern void ip_input(ill_t *, ill_rx_ring_t *, mblk_t *, + struct mac_header_info_s *); +extern void ip_input_v6(ill_t *, ill_rx_ring_t *, mblk_t *, + struct mac_header_info_s *); +extern mblk_t *ip_input_common_v4(ill_t *, ill_rx_ring_t *, mblk_t *, + struct mac_header_info_s *, squeue_t *, mblk_t **, uint_t *); +extern mblk_t *ip_input_common_v6(ill_t *, ill_rx_ring_t *, mblk_t *, + struct mac_header_info_s *, squeue_t *, mblk_t **, uint_t *); +extern void ill_input_full_v4(mblk_t *, void *, void *, + ip_recv_attr_t *, rtc_t *); +extern void ill_input_short_v4(mblk_t *, void *, void *, + ip_recv_attr_t *, rtc_t *); +extern void ill_input_full_v6(mblk_t *, void *, void *, + ip_recv_attr_t *, rtc_t *); +extern void ill_input_short_v6(mblk_t *, void *, void *, + ip_recv_attr_t *, rtc_t *); +extern ipaddr_t ip_input_options(ipha_t *, ipaddr_t, mblk_t *, + ip_recv_attr_t *, int *); +extern boolean_t ip_input_local_options(mblk_t *, ipha_t *, ip_recv_attr_t *); +extern mblk_t *ip_input_fragment(mblk_t *, ipha_t *, ip_recv_attr_t *); +extern mblk_t *ip_input_fragment_v6(mblk_t *, ip6_t *, ip6_frag_t *, uint_t, + ip_recv_attr_t *); +extern void ip_input_post_ipsec(mblk_t *, ip_recv_attr_t *); +extern void ip_fanout_v4(mblk_t *, ipha_t *, ip_recv_attr_t *); +extern void ip_fanout_v6(mblk_t *, ip6_t *, ip_recv_attr_t *); +extern void ip_fanout_proto_conn(conn_t *, mblk_t *, ipha_t *, ip6_t *, + ip_recv_attr_t *); +extern void ip_fanout_proto_v4(mblk_t *, ipha_t *, ip_recv_attr_t *); +extern void ip_fanout_send_icmp_v4(mblk_t *, uint_t, uint_t, + ip_recv_attr_t *); +extern void ip_fanout_udp_conn(conn_t *, mblk_t *, ipha_t *, ip6_t *, + ip_recv_attr_t *); +extern void ip_fanout_udp_multi_v4(mblk_t *, ipha_t *, uint16_t, uint16_t, + ip_recv_attr_t *); +extern mblk_t *zero_spi_check(mblk_t *, ip_recv_attr_t *); +extern void ip_build_hdrs_v4(uchar_t *, uint_t, const ip_pkt_t *, uint8_t); +extern int ip_find_hdr_v4(ipha_t *, ip_pkt_t *, boolean_t); +extern int ip_total_hdrs_len_v4(const ip_pkt_t *); + +extern mblk_t *ip_accept_tcp(ill_t *, ill_rx_ring_t *, squeue_t *, + mblk_t *, mblk_t **, uint_t *cnt); +extern void ip_rput_dlpi(ill_t *, mblk_t *); +extern void ip_rput_notdata(ill_t *, mblk_t *); + +extern void ip_mib2_add_ip_stats(mib2_ipIfStatsEntry_t *, + mib2_ipIfStatsEntry_t *); +extern void ip_mib2_add_icmp6_stats(mib2_ipv6IfIcmpEntry_t *, + mib2_ipv6IfIcmpEntry_t *); +extern void ip_rput_other(ipsq_t *, queue_t *, mblk_t *, void *); +extern ire_t *ip_check_multihome(void *, ire_t *, ill_t *); +extern void ip_send_potential_redirect_v4(mblk_t *, ipha_t *, ire_t *, + ip_recv_attr_t *); +extern int ip_set_destination_v4(ipaddr_t *, ipaddr_t, ipaddr_t, + ip_xmit_attr_t *, iulp_t *, uint32_t, uint_t); +extern int ip_set_destination_v6(in6_addr_t *, const in6_addr_t *, + const in6_addr_t *, ip_xmit_attr_t *, iulp_t *, uint32_t, uint_t); + +extern int ip_output_simple(mblk_t *, ip_xmit_attr_t *); +extern int ip_output_simple_v4(mblk_t *, ip_xmit_attr_t *); +extern int ip_output_simple_v6(mblk_t *, ip_xmit_attr_t *); +extern int ip_output_options(mblk_t *, ipha_t *, ip_xmit_attr_t *, + ill_t *); +extern void ip_output_local_options(ipha_t *, ip_stack_t *); + +extern ip_xmit_attr_t *conn_get_ixa(conn_t *, boolean_t); +extern ip_xmit_attr_t *conn_get_ixa_tryhard(conn_t *, boolean_t); +extern ip_xmit_attr_t *conn_replace_ixa(conn_t *, ip_xmit_attr_t *); +extern ip_xmit_attr_t *conn_get_ixa_exclusive(conn_t *); +extern ip_xmit_attr_t *ip_xmit_attr_duplicate(ip_xmit_attr_t *); +extern void ip_xmit_attr_replace_tsl(ip_xmit_attr_t *, ts_label_t *); +extern void ip_xmit_attr_restore_tsl(ip_xmit_attr_t *, cred_t *); +boolean_t ip_recv_attr_replace_label(ip_recv_attr_t *, ts_label_t *); +extern void ixa_inactive(ip_xmit_attr_t *); +extern void ixa_refrele(ip_xmit_attr_t *); +extern boolean_t ixa_check_drain_insert(conn_t *, ip_xmit_attr_t *); +extern void ixa_cleanup(ip_xmit_attr_t *); +extern void ira_cleanup(ip_recv_attr_t *, boolean_t); +extern void ixa_safe_copy(ip_xmit_attr_t *, ip_xmit_attr_t *); + +extern int conn_ip_output(mblk_t *, ip_xmit_attr_t *); +extern boolean_t ip_output_verify_local(ip_xmit_attr_t *); +extern mblk_t *ip_output_process_local(mblk_t *, ip_xmit_attr_t *, boolean_t, + boolean_t, conn_t *); + +extern int conn_opt_get(conn_opt_arg_t *, t_scalar_t, t_scalar_t, + uchar_t *); +extern int conn_opt_set(conn_opt_arg_t *, t_scalar_t, t_scalar_t, uint_t, + uchar_t *, boolean_t, cred_t *); +extern boolean_t conn_same_as_last_v4(conn_t *, sin_t *); +extern boolean_t conn_same_as_last_v6(conn_t *, sin6_t *); +extern int conn_update_label(const conn_t *, const ip_xmit_attr_t *, + const in6_addr_t *, ip_pkt_t *); + +extern int ip_opt_set_multicast_group(conn_t *, t_scalar_t, + uchar_t *, boolean_t, boolean_t); +extern int ip_opt_set_multicast_sources(conn_t *, t_scalar_t, + uchar_t *, boolean_t, boolean_t); +extern int conn_getsockname(conn_t *, struct sockaddr *, uint_t *); +extern int conn_getpeername(conn_t *, struct sockaddr *, uint_t *); + +extern int conn_build_hdr_template(conn_t *, uint_t, uint_t, + const in6_addr_t *, const in6_addr_t *, uint32_t); +extern mblk_t *conn_prepend_hdr(ip_xmit_attr_t *, const ip_pkt_t *, + const in6_addr_t *, const in6_addr_t *, uint8_t, uint32_t, uint_t, + mblk_t *, uint_t, uint_t, uint32_t *, int *); +extern void ip_attr_newdst(ip_xmit_attr_t *); +extern void ip_attr_nexthop(const ip_pkt_t *, const ip_xmit_attr_t *, + const in6_addr_t *, in6_addr_t *); +extern int conn_connect(conn_t *, iulp_t *, uint32_t); +extern int ip_attr_connect(const conn_t *, ip_xmit_attr_t *, + const in6_addr_t *, const in6_addr_t *, const in6_addr_t *, in_port_t, + in6_addr_t *, iulp_t *, uint32_t); +extern int conn_inherit_parent(conn_t *, conn_t *); + +extern void conn_ixa_cleanup(conn_t *connp, void *arg); + +extern boolean_t conn_wantpacket(conn_t *, ip_recv_attr_t *, ipha_t *); +extern uint_t ip_type_v4(ipaddr_t, ip_stack_t *); +extern uint_t ip_type_v6(const in6_addr_t *, ip_stack_t *); + +extern int ip_wput_nondata(queue_t *, mblk_t *); +extern int ip_wsrv(queue_t *); +extern char *ip_nv_lookup(nv_t *, int); +extern boolean_t ip_local_addr_ok_v6(const in6_addr_t *, const in6_addr_t *); +extern boolean_t ip_remote_addr_ok_v6(const in6_addr_t *, const in6_addr_t *); +extern ipaddr_t ip_massage_options(ipha_t *, netstack_t *); +extern ipaddr_t ip_net_mask(ipaddr_t); +extern void arp_bringup_done(ill_t *, int); +extern void arp_replumb_done(ill_t *, int); + +extern struct qinit iprinitv6; + +extern void ipmp_init(ip_stack_t *); +extern void ipmp_destroy(ip_stack_t *); +extern ipmp_grp_t *ipmp_grp_create(const char *, phyint_t *); +extern void ipmp_grp_destroy(ipmp_grp_t *); +extern void ipmp_grp_info(const ipmp_grp_t *, lifgroupinfo_t *); +extern int ipmp_grp_rename(ipmp_grp_t *, const char *); +extern ipmp_grp_t *ipmp_grp_lookup(const char *, ip_stack_t *); +extern int ipmp_grp_vet_phyint(ipmp_grp_t *, phyint_t *); +extern ipmp_illgrp_t *ipmp_illgrp_create(ill_t *); +extern void ipmp_illgrp_destroy(ipmp_illgrp_t *); +extern ill_t *ipmp_illgrp_add_ipif(ipmp_illgrp_t *, ipif_t *); +extern void ipmp_illgrp_del_ipif(ipmp_illgrp_t *, ipif_t *); +extern ill_t *ipmp_illgrp_next_ill(ipmp_illgrp_t *); +extern ill_t *ipmp_illgrp_hold_next_ill(ipmp_illgrp_t *); +extern ill_t *ipmp_illgrp_hold_cast_ill(ipmp_illgrp_t *); +extern ill_t *ipmp_illgrp_ipmp_ill(ipmp_illgrp_t *); +extern void ipmp_illgrp_refresh_mtu(ipmp_illgrp_t *); +extern ipmp_arpent_t *ipmp_illgrp_create_arpent(ipmp_illgrp_t *, + boolean_t, ipaddr_t, uchar_t *, size_t, uint16_t); +extern void ipmp_illgrp_destroy_arpent(ipmp_illgrp_t *, ipmp_arpent_t *); +extern ipmp_arpent_t *ipmp_illgrp_lookup_arpent(ipmp_illgrp_t *, ipaddr_t *); +extern void ipmp_illgrp_refresh_arpent(ipmp_illgrp_t *); +extern void ipmp_illgrp_mark_arpent(ipmp_illgrp_t *, ipmp_arpent_t *); +extern ill_t *ipmp_illgrp_find_ill(ipmp_illgrp_t *, uchar_t *, uint_t); +extern void ipmp_illgrp_link_grp(ipmp_illgrp_t *, ipmp_grp_t *); +extern int ipmp_illgrp_unlink_grp(ipmp_illgrp_t *); +extern uint_t ipmp_ill_get_ipmp_ifindex(const ill_t *); +extern void ipmp_ill_join_illgrp(ill_t *, ipmp_illgrp_t *); +extern void ipmp_ill_leave_illgrp(ill_t *); +extern ill_t *ipmp_ill_hold_ipmp_ill(ill_t *); +extern ill_t *ipmp_ill_hold_xmit_ill(ill_t *, boolean_t); +extern boolean_t ipmp_ill_is_active(ill_t *); +extern void ipmp_ill_refresh_active(ill_t *); +extern void ipmp_phyint_join_grp(phyint_t *, ipmp_grp_t *); +extern void ipmp_phyint_leave_grp(phyint_t *); +extern void ipmp_phyint_refresh_active(phyint_t *); +extern ill_t *ipmp_ipif_bound_ill(const ipif_t *); +extern ill_t *ipmp_ipif_hold_bound_ill(const ipif_t *); +extern boolean_t ipmp_ipif_is_dataaddr(const ipif_t *); +extern boolean_t ipmp_ipif_is_stubaddr(const ipif_t *); +extern boolean_t ipmp_packet_is_probe(mblk_t *, ill_t *); +extern void ipmp_ncec_delete_nce(ncec_t *); +extern void ipmp_ncec_refresh_nce(ncec_t *); + +extern void conn_drain_insert(conn_t *, idl_tx_list_t *); +extern void conn_setqfull(conn_t *, boolean_t *); +extern void conn_clrqfull(conn_t *, boolean_t *); +extern int conn_ipsec_length(conn_t *); +extern ipaddr_t ip_get_dst(ipha_t *); +extern uint_t ip_get_pmtu(ip_xmit_attr_t *); +extern uint_t ip_get_base_mtu(ill_t *, ire_t *); +extern mblk_t *ip_output_attach_policy(mblk_t *, ipha_t *, ip6_t *, + const conn_t *, ip_xmit_attr_t *); +extern int ipsec_out_extra_length(ip_xmit_attr_t *); +extern int ipsec_out_process(mblk_t *, ip_xmit_attr_t *); +extern int ip_output_post_ipsec(mblk_t *, ip_xmit_attr_t *); +extern void ipsec_out_to_in(ip_xmit_attr_t *, ill_t *ill, + ip_recv_attr_t *); + +extern void ire_cleanup(ire_t *); +extern void ire_inactive(ire_t *); +extern boolean_t irb_inactive(irb_t *); +extern ire_t *ire_unlink(irb_t *); + +#ifdef DEBUG +extern boolean_t th_trace_ref(const void *, ip_stack_t *); +extern void th_trace_unref(const void *); +extern void th_trace_cleanup(const void *, boolean_t); +extern void ire_trace_ref(ire_t *); +extern void ire_untrace_ref(ire_t *); +#endif + +extern int ip_srcid_insert(const in6_addr_t *, zoneid_t, ip_stack_t *); +extern int ip_srcid_remove(const in6_addr_t *, zoneid_t, ip_stack_t *); +extern boolean_t ip_srcid_find_id(uint_t, in6_addr_t *, zoneid_t, boolean_t, + netstack_t *); +extern uint_t ip_srcid_find_addr(const in6_addr_t *, zoneid_t, netstack_t *); + +extern uint8_t ipoptp_next(ipoptp_t *); +extern uint8_t ipoptp_first(ipoptp_t *, ipha_t *); +extern int ip_opt_get_user(conn_t *, uchar_t *); +extern int ipsec_req_from_conn(conn_t *, ipsec_req_t *, int); +extern int ip_snmp_get(queue_t *q, mblk_t *mctl, int level, boolean_t); +extern int ip_snmp_set(queue_t *q, int, int, uchar_t *, int); +extern void ip_process_ioctl(ipsq_t *, queue_t *, mblk_t *, void *); +extern void ip_quiesce_conn(conn_t *); +extern void ip_reprocess_ioctl(ipsq_t *, queue_t *, mblk_t *, void *); +extern void ip_ioctl_finish(queue_t *, mblk_t *, int, int, ipsq_t *); + +extern boolean_t ip_cmpbuf(const void *, uint_t, boolean_t, const void *, + uint_t); +extern boolean_t ip_allocbuf(void **, uint_t *, boolean_t, const void *, + uint_t); +extern void ip_savebuf(void **, uint_t *, boolean_t, const void *, uint_t); + +extern boolean_t ipsq_pending_mp_cleanup(ill_t *, conn_t *); +extern void conn_ioctl_cleanup(conn_t *); + +extern void ip_unbind(conn_t *); + +extern void tnet_init(void); +extern void tnet_fini(void); + +/* + * Hook functions to enable cluster networking + * On non-clustered systems these vectors must always be NULL. + */ +extern int (*cl_inet_isclusterwide)(netstackid_t stack_id, uint8_t protocol, + sa_family_t addr_family, uint8_t *laddrp, void *args); +extern uint32_t (*cl_inet_ipident)(netstackid_t stack_id, uint8_t protocol, + sa_family_t addr_family, uint8_t *laddrp, uint8_t *faddrp, + void *args); +extern int (*cl_inet_connect2)(netstackid_t stack_id, uint8_t protocol, + boolean_t is_outgoing, sa_family_t addr_family, uint8_t *laddrp, + in_port_t lport, uint8_t *faddrp, in_port_t fport, void *args); +extern void (*cl_inet_getspi)(netstackid_t, uint8_t, uint8_t *, size_t, + void *); +extern void (*cl_inet_getspi)(netstackid_t stack_id, uint8_t protocol, + uint8_t *ptr, size_t len, void *args); +extern int (*cl_inet_checkspi)(netstackid_t stack_id, uint8_t protocol, + uint32_t spi, void *args); +extern void (*cl_inet_deletespi)(netstackid_t stack_id, uint8_t protocol, + uint32_t spi, void *args); +extern void (*cl_inet_idlesa)(netstackid_t, uint8_t, uint32_t, + sa_family_t, in6_addr_t, in6_addr_t, void *); + + +/* Hooks for CGTP (multirt routes) filtering module */ +#define CGTP_FILTER_REV_1 1 +#define CGTP_FILTER_REV_2 2 +#define CGTP_FILTER_REV_3 3 +#define CGTP_FILTER_REV CGTP_FILTER_REV_3 + +/* cfo_filter and cfo_filter_v6 hooks return values */ +#define CGTP_IP_PKT_NOT_CGTP 0 +#define CGTP_IP_PKT_PREMIUM 1 +#define CGTP_IP_PKT_DUPLICATE 2 + +/* Version 3 of the filter interface */ +typedef struct cgtp_filter_ops { + int cfo_filter_rev; /* CGTP_FILTER_REV_3 */ + int (*cfo_change_state)(netstackid_t, int); + int (*cfo_add_dest_v4)(netstackid_t, ipaddr_t, ipaddr_t, + ipaddr_t, ipaddr_t); + int (*cfo_del_dest_v4)(netstackid_t, ipaddr_t, ipaddr_t); + int (*cfo_add_dest_v6)(netstackid_t, in6_addr_t *, in6_addr_t *, + in6_addr_t *, in6_addr_t *); + int (*cfo_del_dest_v6)(netstackid_t, in6_addr_t *, in6_addr_t *); + int (*cfo_filter)(netstackid_t, uint_t, mblk_t *); + int (*cfo_filter_v6)(netstackid_t, uint_t, ip6_t *, + ip6_frag_t *); +} cgtp_filter_ops_t; + +#define CGTP_MCAST_SUCCESS 1 + +/* + * The separate CGTP module needs this global symbol so that it + * can check the version and determine whether to use the old or the new + * version of the filtering interface. + */ +extern int ip_cgtp_filter_rev; + +extern int ip_cgtp_filter_supported(void); +extern int ip_cgtp_filter_register(netstackid_t, cgtp_filter_ops_t *); +extern int ip_cgtp_filter_unregister(netstackid_t); +extern int ip_cgtp_filter_is_registered(netstackid_t); + +/* + * rr_ring_state cycles in the order shown below from RR_FREE through + * RR_FREE_IN_PROG and back to RR_FREE. + */ +typedef enum { + RR_FREE, /* Free slot */ + RR_SQUEUE_UNBOUND, /* Ring's squeue is unbound */ + RR_SQUEUE_BIND_INPROG, /* Ring's squeue bind in progress */ + RR_SQUEUE_BOUND, /* Ring's squeue bound to cpu */ + RR_FREE_INPROG /* Ring is being freed */ +} ip_ring_state_t; + +#define ILL_MAX_RINGS 256 /* Max num of rx rings we can manage */ +#define ILL_POLLING 0x01 /* Polling in use */ + +/* + * These functions pointer types are exported by the mac/dls layer. + * we need to duplicate the definitions here because we cannot + * include mac/dls header files here. + */ +typedef boolean_t (*ip_mac_intr_disable_t)(void *); +typedef int (*ip_mac_intr_enable_t)(void *); +typedef ip_mac_tx_cookie_t (*ip_dld_tx_t)(void *, mblk_t *, + uint64_t, uint16_t); +typedef void (*ip_flow_enable_t)(void *, ip_mac_tx_cookie_t); +typedef void *(*ip_dld_callb_t)(void *, + ip_flow_enable_t, void *); +typedef boolean_t (*ip_dld_fctl_t)(void *, ip_mac_tx_cookie_t); +typedef int (*ip_capab_func_t)(void *, uint_t, + void *, uint_t); + +/* + * POLLING README + * sq_get_pkts() is called to pick packets from softring in poll mode. It + * calls rr_rx to get the chain and process it with rr_ip_accept. + * rr_rx = mac_soft_ring_poll() to pick packets + * rr_ip_accept = ip_accept_tcp() to process packets + */ + +/* + * XXX: With protocol, service specific squeues, they will have + * specific acceptor functions. + */ +typedef mblk_t *(*ip_mac_rx_t)(void *, size_t); +typedef mblk_t *(*ip_accept_t)(ill_t *, ill_rx_ring_t *, + squeue_t *, mblk_t *, mblk_t **, uint_t *); + +/* + * rr_intr_enable, rr_intr_disable, rr_rx_handle, rr_rx: + * May be accessed while in the squeue AND after checking that SQS_POLL_CAPAB + * is set. + * + * rr_ring_state: Protected by ill_lock. + */ +struct ill_rx_ring { + ip_mac_intr_disable_t rr_intr_disable; /* Interrupt disabling func */ + ip_mac_intr_enable_t rr_intr_enable; /* Interrupt enabling func */ + void *rr_intr_handle; /* Handle interrupt funcs */ + ip_mac_rx_t rr_rx; /* Driver receive function */ + ip_accept_t rr_ip_accept; /* IP accept function */ + void *rr_rx_handle; /* Handle for Rx ring */ + squeue_t *rr_sqp; /* Squeue the ring is bound to */ + ill_t *rr_ill; /* back pointer to ill */ + ip_ring_state_t rr_ring_state; /* State of this ring */ +}; + +/* + * IP - DLD direct function call capability + * Suffixes, df - dld function, dh - dld handle, + * cf - client (IP) function, ch - client handle + */ +typedef struct ill_dld_direct_s { /* DLD provided driver Tx */ + ip_dld_tx_t idd_tx_df; /* str_mdata_fastpath_put */ + void *idd_tx_dh; /* dld_str_t *dsp */ + ip_dld_callb_t idd_tx_cb_df; /* mac_tx_srs_notify */ + void *idd_tx_cb_dh; /* mac_client_handle_t *mch */ + ip_dld_fctl_t idd_tx_fctl_df; /* mac_tx_is_flow_blocked */ + void *idd_tx_fctl_dh; /* mac_client_handle */ +} ill_dld_direct_t; + +/* IP - DLD polling capability */ +typedef struct ill_dld_poll_s { + ill_rx_ring_t idp_ring_tbl[ILL_MAX_RINGS]; +} ill_dld_poll_t; + +/* Describes ill->ill_dld_capab */ +struct ill_dld_capab_s { + ip_capab_func_t idc_capab_df; /* dld_capab_func */ + void *idc_capab_dh; /* dld_str_t *dsp */ + ill_dld_direct_t idc_direct; + ill_dld_poll_t idc_poll; +}; + +/* + * IP squeues exports + */ +extern boolean_t ip_squeue_fanout; + +#define IP_SQUEUE_GET(hint) ip_squeue_random(hint) + +extern void ip_squeue_init(void (*)(squeue_t *)); +extern squeue_t *ip_squeue_random(uint_t); +extern squeue_t *ip_squeue_get(ill_rx_ring_t *); +extern squeue_t *ip_squeue_getfree(pri_t); +extern int ip_squeue_cpu_move(squeue_t *, processorid_t); +extern void *ip_squeue_add_ring(ill_t *, void *); +extern void ip_squeue_bind_ring(ill_t *, ill_rx_ring_t *, processorid_t); +extern void ip_squeue_clean_ring(ill_t *, ill_rx_ring_t *); +extern void ip_squeue_quiesce_ring(ill_t *, ill_rx_ring_t *); +extern void ip_squeue_restart_ring(ill_t *, ill_rx_ring_t *); +extern void ip_squeue_clean_all(ill_t *); +extern boolean_t ip_source_routed(ipha_t *, ip_stack_t *); + +extern int tcp_wput(queue_t *, mblk_t *); + +extern int ip_fill_mtuinfo(conn_t *, ip_xmit_attr_t *, + struct ip6_mtuinfo *); +extern hook_t *ipobs_register_hook(netstack_t *, pfv_t); +extern void ipobs_unregister_hook(netstack_t *, hook_t *); +extern void ipobs_hook(mblk_t *, int, zoneid_t, zoneid_t, const ill_t *, + ip_stack_t *); +typedef void (*ipsq_func_t)(ipsq_t *, queue_t *, mblk_t *, void *); + +extern void dce_g_init(void); +extern void dce_g_destroy(void); +extern void dce_stack_init(ip_stack_t *); +extern void dce_stack_destroy(ip_stack_t *); +extern void dce_cleanup(uint_t, ip_stack_t *); +extern dce_t *dce_get_default(ip_stack_t *); +extern dce_t *dce_lookup_pkt(mblk_t *, ip_xmit_attr_t *, uint_t *); +extern dce_t *dce_lookup_v4(ipaddr_t, ip_stack_t *, uint_t *); +extern dce_t *dce_lookup_v6(const in6_addr_t *, uint_t, ip_stack_t *, + uint_t *); +extern dce_t *dce_lookup_and_add_v4(ipaddr_t, ip_stack_t *); +extern dce_t *dce_lookup_and_add_v6(const in6_addr_t *, uint_t, + ip_stack_t *); +extern int dce_update_uinfo_v4(ipaddr_t, iulp_t *, ip_stack_t *); +extern int dce_update_uinfo_v6(const in6_addr_t *, uint_t, iulp_t *, + ip_stack_t *); +extern int dce_update_uinfo(const in6_addr_t *, uint_t, iulp_t *, + ip_stack_t *); +extern void dce_increment_generation(dce_t *); +extern void dce_increment_all_generations(boolean_t, ip_stack_t *); +extern void dce_refrele(dce_t *); +extern void dce_refhold(dce_t *); +extern void dce_refrele_notr(dce_t *); +extern void dce_refhold_notr(dce_t *); +mblk_t *ip_snmp_get_mib2_ip_dce(queue_t *, mblk_t *, ip_stack_t *ipst); + +extern ip_laddr_t ip_laddr_verify_v4(ipaddr_t, zoneid_t, + ip_stack_t *, boolean_t); +extern ip_laddr_t ip_laddr_verify_v6(const in6_addr_t *, zoneid_t, + ip_stack_t *, boolean_t, uint_t); +extern int ip_laddr_fanout_insert(conn_t *); + +extern boolean_t ip_verify_src(mblk_t *, ip_xmit_attr_t *, uint_t *); +extern int ip_verify_ire(mblk_t *, ip_xmit_attr_t *); + +extern mblk_t *ip_xmit_attr_to_mblk(ip_xmit_attr_t *); +extern boolean_t ip_xmit_attr_from_mblk(mblk_t *, ip_xmit_attr_t *); +extern mblk_t *ip_xmit_attr_free_mblk(mblk_t *); +extern mblk_t *ip_recv_attr_to_mblk(ip_recv_attr_t *); +extern boolean_t ip_recv_attr_from_mblk(mblk_t *, ip_recv_attr_t *); +extern mblk_t *ip_recv_attr_free_mblk(mblk_t *); +extern boolean_t ip_recv_attr_is_mblk(mblk_t *); + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname inet_ntop _inet_ntop +#pragma redefine_extname inet_pton _inet_pton +#else +#define inet_ntop _inet_ntop +#define inet_pton _inet_pton +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +extern char *inet_ntop(int, const void *, char *, int); +extern int inet_pton(int, char *, void *); + +/* + * Squeue tags. Tags only need to be unique when the callback function is the + * same to distinguish between different calls, but we use unique tags for + * convenience anyway. + */ +#define SQTAG_IP_INPUT 1 +#define SQTAG_TCP_INPUT_ICMP_ERR 2 +#define SQTAG_TCP6_INPUT_ICMP_ERR 3 +#define SQTAG_IP_TCP_INPUT 4 +#define SQTAG_IP6_TCP_INPUT 5 +#define SQTAG_IP_TCP_CLOSE 6 +#define SQTAG_TCP_OUTPUT 7 +#define SQTAG_TCP_TIMER 8 +#define SQTAG_TCP_TIMEWAIT 9 +#define SQTAG_TCP_ACCEPT_FINISH 10 +#define SQTAG_TCP_ACCEPT_FINISH_Q0 11 +#define SQTAG_TCP_ACCEPT_PENDING 12 +#define SQTAG_TCP_LISTEN_DISCON 13 +#define SQTAG_TCP_CONN_REQ_1 14 +#define SQTAG_TCP_EAGER_BLOWOFF 15 +#define SQTAG_TCP_EAGER_CLEANUP 16 +#define SQTAG_TCP_EAGER_CLEANUP_Q0 17 +#define SQTAG_TCP_CONN_IND 18 +#define SQTAG_TCP_RSRV 19 +#define SQTAG_TCP_ABORT_BUCKET 20 +#define SQTAG_TCP_REINPUT 21 +#define SQTAG_TCP_REINPUT_EAGER 22 +#define SQTAG_TCP_INPUT_MCTL 23 +#define SQTAG_TCP_RPUTOTHER 24 +#define SQTAG_IP_PROTO_AGAIN 25 +#define SQTAG_IP_FANOUT_TCP 26 +#define SQTAG_IPSQ_CLEAN_RING 27 +#define SQTAG_TCP_WPUT_OTHER 28 +#define SQTAG_TCP_CONN_REQ_UNBOUND 29 +#define SQTAG_TCP_SEND_PENDING 30 +#define SQTAG_BIND_RETRY 31 +#define SQTAG_UDP_FANOUT 32 +#define SQTAG_UDP_INPUT 33 +#define SQTAG_UDP_WPUT 34 +#define SQTAG_UDP_OUTPUT 35 +#define SQTAG_TCP_KSSL_INPUT 36 +#define SQTAG_TCP_DROP_Q0 37 +#define SQTAG_TCP_CONN_REQ_2 38 +#define SQTAG_IP_INPUT_RX_RING 39 +#define SQTAG_SQUEUE_CHANGE 40 +#define SQTAG_CONNECT_FINISH 41 +#define SQTAG_SYNCHRONOUS_OP 42 +#define SQTAG_TCP_SHUTDOWN_OUTPUT 43 +#define SQTAG_TCP_IXA_CLEANUP 44 +#define SQTAG_TCP_SEND_SYNACK 45 + +extern sin_t sin_null; /* Zero address for quick clears */ +extern sin6_t sin6_null; /* Zero address for quick clears */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP_H */ diff --git a/illumos-x86_64/usr/include/inet/ip6.h b/illumos-x86_64/usr/include/inet/ip6.h new file mode 100644 index 00000000..01c25b52 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip6.h @@ -0,0 +1,294 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _INET_IP6_H +#define _INET_IP6_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef _KERNEL +/* icmp6_t is used in the prototype of icmp_inbound_error_fanout_v6() */ +#include +#endif /* _KERNEL */ + +/* version number for IPv6 - hard to get this one wrong! */ +#define IPV6_VERSION 6 + +#define IPV6_HDR_LEN 40 + +#define IPV6_ADDR_LEN 16 + +/* + * IPv6 address scopes. The values of these enums also match the scope + * field of multicast addresses. + */ +typedef enum { + IP6_SCOPE_INTFLOCAL = 1, /* Multicast addresses only */ + IP6_SCOPE_LINKLOCAL, + IP6_SCOPE_SUBNETLOCAL, /* Multicast addresses only */ + IP6_SCOPE_ADMINLOCAL, /* Multicast addresses only */ + IP6_SCOPE_SITELOCAL, + IP6_SCOPE_GLOBAL +} in6addr_scope_t; + +/* From RFC 3542 - setting for IPV6_USE_MIN_MTU socket option */ +#define IPV6_USE_MIN_MTU_MULTICAST -1 /* Default */ +#define IPV6_USE_MIN_MTU_NEVER 0 +#define IPV6_USE_MIN_MTU_ALWAYS 1 + +#ifdef _KERNEL + +/* Extract the scope from a multicast address */ +#ifdef _BIG_ENDIAN +#define IN6_ADDR_MC_SCOPE(addr) \ + (((addr)->s6_addr32[0] & 0x000f0000) >> 16) +#else +#define IN6_ADDR_MC_SCOPE(addr) \ + (((addr)->s6_addr32[0] & 0x00000f00) >> 8) +#endif + +/* Default IPv4 TTL for IPv6-in-IPv4 encapsulated packets */ +#define IPV6_DEFAULT_HOPS 60 /* XXX What should it be? */ + +/* Max IPv6 TTL */ +#define IPV6_MAX_HOPS 255 + +/* Minimum IPv6 MTU from rfc2460 */ +#define IPV6_MIN_MTU 1280 + +/* EUI-64 based token length */ +#define IPV6_TOKEN_LEN 64 + +/* Length of an advertised IPv6 prefix */ +#define IPV6_PREFIX_LEN 64 + +/* Default and maximum tunnel encapsulation limits. See RFC 2473. */ +#define IPV6_DEFAULT_ENCAPLIMIT 4 +#define IPV6_MAX_ENCAPLIMIT 255 + +/* + * Minimum and maximum extension header lengths for IPv6. The 8-bit + * length field of each extension header (see rfc2460) specifies the + * number of 8 octet units of data in the header not including the + * first 8 octets. A value of 0 would indicate 8 bytes (0 * 8 + 8), + * and 255 would indicate 2048 bytes (255 * 8 + 8). + */ +#define MIN_EHDR_LEN 8 +#define MAX_EHDR_LEN 2048 + +#ifdef _BIG_ENDIAN +#define IPV6_DEFAULT_VERS_AND_FLOW 0x60000000 +#define IPV6_VERS_AND_FLOW_MASK 0xF0000000 +#define V6_MCAST 0xFF000000 +#define V6_LINKLOCAL 0xFE800000 + +#define IPV6_FLOW_TCLASS(x) (((x) & IPV6_FLOWINFO_TCLASS) >> 20) +#define IPV6_TCLASS_FLOW(f, c) (((f) & ~IPV6_FLOWINFO_TCLASS) |\ + ((c) << 20)) +#else +#define IPV6_DEFAULT_VERS_AND_FLOW 0x00000060 +#define IPV6_VERS_AND_FLOW_MASK 0x000000F0 +#define V6_MCAST 0x000000FF +#define V6_LINKLOCAL 0x000080FE + +#define IPV6_FLOW_TCLASS(x) ((((x) & 0xf000U) >> 12) |\ + (((x) & 0xf) << 4)) +#define IPV6_TCLASS_FLOW(f, c) (((f) & ~IPV6_FLOWINFO_TCLASS) |\ + ((((c) & 0xf) << 12) |\ + (((c) & 0xf0) >> 4))) +#endif + +/* + * UTILITY MACROS FOR ADDRESSES. + */ + +/* + * Convert an IPv4 address mask to an IPv6 mask. Pad with 1-bits. + */ +#define V4MASK_TO_V6(v4, v6) ((v6).s6_addr32[0] = 0xffffffffUL, \ + (v6).s6_addr32[1] = 0xffffffffUL, \ + (v6).s6_addr32[2] = 0xffffffffUL, \ + (v6).s6_addr32[3] = (v4)) + +/* + * Convert aligned IPv4-mapped IPv6 address into an IPv4 address. + * Note: We use "v6" here in definition of macro instead of "(v6)" + * Not possible to use "(v6)" here since macro is used with struct + * field names as arguments. + */ +#define V4_PART_OF_V6(v6) v6.s6_addr32[3] + +#ifdef _BIG_ENDIAN +#define V6_OR_V4_INADDR_ANY(a) ((a).s6_addr32[3] == 0 && \ + ((a).s6_addr32[2] == 0xffffU || \ + (a).s6_addr32[2] == 0) && \ + (a).s6_addr32[1] == 0 && \ + (a).s6_addr32[0] == 0) + +#else +#define V6_OR_V4_INADDR_ANY(a) ((a).s6_addr32[3] == 0 && \ + ((a).s6_addr32[2] == 0xffff0000U || \ + (a).s6_addr32[2] == 0) && \ + (a).s6_addr32[1] == 0 && \ + (a).s6_addr32[0] == 0) +#endif /* _BIG_ENDIAN */ + +/* IPv4-mapped CLASSD addresses */ +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_V4MAPPED_CLASSD(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \ + (CLASSD((addr)->_S6_un._S6_u32[3])) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_V4MAPPED_CLASSD(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \ + (CLASSD((addr)->_S6_un._S6_u32[3])) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#endif /* _BIG_ENDIAN */ + +/* Clear an IPv6 addr */ +#define V6_SET_ZERO(a) ((a).s6_addr32[0] = 0, \ + (a).s6_addr32[1] = 0, \ + (a).s6_addr32[2] = 0, \ + (a).s6_addr32[3] = 0) + +/* Mask comparison: is IPv6 addr a, and'ed with mask m, equal to addr b? */ +#define V6_MASK_EQ(a, m, b) \ + ((((a).s6_addr32[0] & (m).s6_addr32[0]) == (b).s6_addr32[0]) && \ + (((a).s6_addr32[1] & (m).s6_addr32[1]) == (b).s6_addr32[1]) && \ + (((a).s6_addr32[2] & (m).s6_addr32[2]) == (b).s6_addr32[2]) && \ + (((a).s6_addr32[3] & (m).s6_addr32[3]) == (b).s6_addr32[3])) + +#define V6_MASK_EQ_2(a, m, b) \ + ((((a).s6_addr32[0] & (m).s6_addr32[0]) == \ + ((b).s6_addr32[0] & (m).s6_addr32[0])) && \ + (((a).s6_addr32[1] & (m).s6_addr32[1]) == \ + ((b).s6_addr32[1] & (m).s6_addr32[1])) && \ + (((a).s6_addr32[2] & (m).s6_addr32[2]) == \ + ((b).s6_addr32[2] & (m).s6_addr32[2])) && \ + (((a).s6_addr32[3] & (m).s6_addr32[3]) == \ + ((b).s6_addr32[3] & (m).s6_addr32[3]))) + +/* Copy IPv6 address (s), logically and'ed with mask (m), into (d) */ +#define V6_MASK_COPY(s, m, d) \ + ((d).s6_addr32[0] = (s).s6_addr32[0] & (m).s6_addr32[0], \ + (d).s6_addr32[1] = (s).s6_addr32[1] & (m).s6_addr32[1], \ + (d).s6_addr32[2] = (s).s6_addr32[2] & (m).s6_addr32[2], \ + (d).s6_addr32[3] = (s).s6_addr32[3] & (m).s6_addr32[3]) + +#define ILL_FRAG_HASH_V6(v6addr, i) \ + ((ntohl((v6addr).s6_addr32[3]) ^ (i ^ (i >> 8))) % \ + ILL_FRAG_HASH_TBL_COUNT) + + +/* + * GLOBAL EXTERNALS + */ +extern const in6_addr_t ipv6_all_ones; +extern const in6_addr_t ipv6_all_zeros; +extern const in6_addr_t ipv6_loopback; +extern const in6_addr_t ipv6_all_hosts_mcast; +extern const in6_addr_t ipv6_all_rtrs_mcast; +extern const in6_addr_t ipv6_all_v2rtrs_mcast; +extern const in6_addr_t ipv6_solicited_node_mcast; +extern const in6_addr_t ipv6_unspecified_group; + +/* + * FUNCTION PROTOTYPES + */ +extern void icmp_param_problem_nexthdr_v6(mblk_t *, boolean_t, + ip_recv_attr_t *); +extern void icmp_pkt2big_v6(mblk_t *, uint32_t, boolean_t, + ip_recv_attr_t *); +extern void icmp_time_exceeded_v6(mblk_t *, uint8_t, boolean_t, + ip_recv_attr_t *); +extern void icmp_unreachable_v6(mblk_t *, uint8_t, boolean_t, + ip_recv_attr_t *); +extern mblk_t *icmp_inbound_v6(mblk_t *, ip_recv_attr_t *); +extern void icmp_inbound_error_fanout_v6(mblk_t *, icmp6_t *, + ip_recv_attr_t *); +extern void icmp_update_out_mib_v6(ill_t *, icmp6_t *); + +extern boolean_t conn_wantpacket_v6(conn_t *, ip_recv_attr_t *, ip6_t *); + +extern in6addr_scope_t ip_addr_scope_v6(const in6_addr_t *); +extern void ip_build_hdrs_v6(uchar_t *, uint_t, const ip_pkt_t *, uint8_t, + uint32_t); +extern void ip_fanout_udp_multi_v6(mblk_t *, ip6_t *, uint16_t, uint16_t, + ip_recv_attr_t *); +extern void ip_fanout_send_icmp_v6(mblk_t *, uint_t, uint8_t, + ip_recv_attr_t *); +extern void ip_fanout_proto_v6(mblk_t *, ip6_t *, ip_recv_attr_t *); +extern int ip_find_hdr_v6(mblk_t *, ip6_t *, boolean_t, ip_pkt_t *, + uint8_t *); +extern in6_addr_t ip_get_dst_v6(ip6_t *, const mblk_t *, boolean_t *); +extern ip6_rthdr_t *ip_find_rthdr_v6(ip6_t *, uint8_t *); +extern boolean_t ip_hdr_length_nexthdr_v6(mblk_t *, ip6_t *, + uint16_t *, uint8_t **); +extern uint16_t ip_hdr_length_v6(mblk_t *, ip6_t *); +extern uint32_t ip_massage_options_v6(ip6_t *, ip6_rthdr_t *, netstack_t *); +extern void ip_forward_xmit_v6(nce_t *, mblk_t *, ip6_t *, ip_recv_attr_t *, + uint32_t, uint32_t); +extern mblk_t *ip_fraghdr_add_v6(mblk_t *, uint32_t, ip_xmit_attr_t *); +extern int ip_fragment_v6(mblk_t *, nce_t *, iaflags_t, uint_t, uint32_t, + uint32_t, zoneid_t, zoneid_t, pfirepostfrag_t postfragfn, + uintptr_t *ixa_cookie); +extern int ip_process_options_v6(mblk_t *, ip6_t *, + uint8_t *, uint_t, uint8_t, ip_recv_attr_t *); +extern void ip_process_rthdr(mblk_t *, ip6_t *, ip6_rthdr_t *, + ip_recv_attr_t *); +extern int ip_total_hdrs_len_v6(const ip_pkt_t *); +extern mblk_t *ipsec_early_ah_v6(mblk_t *, ip_recv_attr_t *); +extern int ipsec_ah_get_hdr_size_v6(mblk_t *, boolean_t); +extern void ip_send_potential_redirect_v6(mblk_t *, ip6_t *, ire_t *, + ip_recv_attr_t *); +extern int ip_rput_v6(queue_t *, mblk_t *); +extern mblk_t *mld_input(mblk_t *, ip_recv_attr_t *); +extern void mld_joingroup(ilm_t *); +extern void mld_leavegroup(ilm_t *); +extern void mld_timeout_handler(void *); + +extern void pr_addr_dbg(char *, int, const void *); +extern void *ip6_kstat_init(netstackid_t, ip6_stat_t *); +extern void ip6_kstat_fini(netstackid_t, kstat_t *); +extern size_t ip6_get_src_preferences(ip_xmit_attr_t *, uint32_t *); +extern int ip6_set_src_preferences(ip_xmit_attr_t *, uint32_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP6_H */ diff --git a/illumos-x86_64/usr/include/inet/ip6_asp.h b/illumos-x86_64/usr/include/inet/ip6_asp.h new file mode 100644 index 00000000..7cffedfd --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip6_asp.h @@ -0,0 +1,134 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_IP6_ASP_H +#define _INET_IP6_ASP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * The maximum size of the label, including NULL bytes following the + * label string. The implementation assumes that this value is 16. + */ +#define IP6_ASP_MAXLABELSIZE 16 + +typedef struct ip6_asp { + in6_addr_t ip6_asp_prefix; + in6_addr_t ip6_asp_mask; + /* + * ip6_asp_label must be on an 8 byte boundary because we cast + * them as (int64_t *) in order to compare them as two 64 bit + * integers rather than sixteen characters. + */ + union { + char iau_label_c[IP6_ASP_MAXLABELSIZE]; + int64_t iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int64_t)]; + } ip6_asp_u; + uint32_t ip6_asp_precedence; +} ip6_asp_t; +#define ip6_asp_label ip6_asp_u.iau_label_c + +#if defined(_SYSCALL32) && _LONG_LONG_ALIGNMENT_32 == 4 + +/* + * The ip6_asp structure as seen by a 64-bit kernel looking + * at a 32-bit process, where the 32-bit process uses 32-bit + * alignment for 64-bit quantities. Like i386 does :-) + */ +typedef struct ip6_asp32 { + in6_addr_t ip6_asp_prefix; + in6_addr_t ip6_asp_mask; + union { + char iau_label_c[IP6_ASP_MAXLABELSIZE]; + int32_t iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int32_t)]; + } ip6_asp_u; + uint32_t ip6_asp_precedence; +} ip6_asp32_t; + +#endif /* _SYSCALL32 && _LONG_LONG_ALIGNMENT_32 == 4 */ + +#define IP6_ASP_TABLE_REFHOLD(ipst) { \ + ipst->ips_ip6_asp_refcnt++; \ + ASSERT(ipst->ips_ip6_asp_refcnt != 0); \ +} + +#define IP6_ASP_TABLE_REFRELE(ipst) { \ + mutex_enter(&ipst->ips_ip6_asp_lock); \ + ASSERT(ipst->ips_ip6_asp_refcnt != 0); \ + if (--ipst->ips_ip6_asp_refcnt == 0) { \ + mutex_exit(&ipst->ips_ip6_asp_lock); \ + ip6_asp_check_for_updates(ipst); \ + } else { \ + mutex_exit(&ipst->ips_ip6_asp_lock); \ + } \ +} + +/* + * Structure used in the SIOCGDSTINFO request. + * Used to retrieve information about the given destination + * address, to be used by the caller to sort a list of + * potential destination addresses. + */ +struct dstinforeq { + in6_addr_t dir_daddr; /* destination address */ + in6_addr_t dir_saddr; /* source address for daddr */ + in6addr_scope_t dir_dscope; /* destination scope */ + in6addr_scope_t dir_sscope; /* source scope */ + t_uscalar_t dir_dmactype; /* dl_mac_type of output inf */ + uint32_t dir_precedence; /* destination precedence */ + uint8_t dir_dreachable : 1, /* is destination reachable? */ + dir_sdeprecated : 1, /* is source deprecated? */ + dir_labelmatch: 1, /* src and dst labels match? */ + dir_padbits : 5; +}; + +#ifdef _KERNEL + +typedef void (*aspfunc_t)(ipsq_t *, queue_t *, mblk_t *, void *); + +extern void ip6_asp_free(ip_stack_t *); +extern void ip6_asp_init(ip_stack_t *); +extern boolean_t ip6_asp_can_lookup(ip_stack_t *); +extern void ip6_asp_table_refrele(ip_stack_t *); +extern char *ip6_asp_lookup(const in6_addr_t *, uint32_t *, ip_stack_t *); +extern void ip6_asp_replace(mblk_t *mp, ip6_asp_t *, size_t, boolean_t, + ip_stack_t *, model_t); +extern int ip6_asp_get(ip6_asp_t *, size_t, ip_stack_t *); +extern boolean_t ip6_asp_labelcmp(const char *, const char *); +extern void ip6_asp_pending_op(queue_t *, mblk_t *, aspfunc_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP6_ASP_H */ diff --git a/illumos-x86_64/usr/include/inet/ip_arp.h b/illumos-x86_64/usr/include/inet/ip_arp.h new file mode 100644 index 00000000..91ce3565 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip_arp.h @@ -0,0 +1,136 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _IP_ARP_H +#define _IP_ARP_H + +/* + * Data-structures and functions related to the IP STREAMS queue that handles + * packets with the SAP set to 0x806 (ETHERTYPE_ARP). + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#ifdef _KERNEL +extern struct streamtab dummymodinfo; + +struct arl_ill_common_s; +/* + * The arl_s structure tracks the state of the associated ARP stream. + */ +typedef struct arl_s { + queue_t *arl_rq; + queue_t *arl_wq; + ip_stack_t *arl_ipst; + zoneid_t arl_zoneid; + cred_t *arl_credp; + ip_m_t arl_media; + struct arl_ill_common_s *arl_common; + int arl_muxid; + uint_t arl_ppa; + t_uscalar_t arl_sap; + t_uscalar_t arl_sap_length; + uint_t arl_phys_addr_length; + char *arl_name; + int arl_name_length; + t_uscalar_t arl_mactype; +#define arl_first_mp_to_free arl_dlpi_deferred + mblk_t *arl_dlpi_deferred; + mblk_t *arl_unbind_mp; + mblk_t *arl_detach_mp; +#define arl_last_mp_to_free arl_detach_mp + uint_t arl_state_flags; + uint_t + arl_needs_attach:1, + arl_dlpi_style_set:1, + arl_pad_to_bit_31:30; + uint_t arl_refcnt; + kcondvar_t arl_cv; + t_uscalar_t arl_dlpi_pending; + kmutex_t arl_lock; + int arl_error; +} arl_t; + +/* + * The arl_ill_common_t structure is a super-structure that contains pointers + * to a pair of matching ill_t, arl_t structures. Given an arl_t (or + * ill_t) the corresponding ill_t (or arl_t) must be obtained by + * synchronizing on the ai_lock, and ensuring that the desired ill/arl + * pointer is non-null, not condemned. The arl_ill_common_t is allocated in + * arl_init() and freed only when both the ill_t and the arl_t structures + * become NULL. + * Lock hierarchy: the ai_lock must be take before the ill_lock or arl_lock. + */ + +typedef struct arl_ill_common_s { + kmutex_t ai_lock; + ill_t *ai_ill; + arl_t *ai_arl; + kcondvar_t ai_ill_unplumb_done; /* sent from ip_modclose() */ +} arl_ill_common_t; + +extern boolean_t arp_no_defense; + +extern struct module_info arp_mod_info; +extern int arp_ll_up(ill_t *); +extern int arp_ll_down(ill_t *); +extern boolean_t arp_announce(ncec_t *); +extern boolean_t arp_probe(ncec_t *); +extern int arp_request(ncec_t *, in_addr_t, ill_t *); +extern void arp_failure(mblk_t *, ip_recv_attr_t *); +extern int arl_wait_for_info_ack(arl_t *); +extern int arl_init(queue_t *, arl_t *); +extern void arl_set_muxid(ill_t *, int); +extern int arl_get_muxid(ill_t *); +extern void arp_send_replumb_conf(ill_t *); +extern void arp_unbind_complete(ill_t *); +extern ill_t *arl_to_ill(arl_t *); +extern uint32_t arp_hw_type(t_uscalar_t); +#endif + +#define ARP_RETRANS_TIMER 500 /* time in milliseconds */ + +/* The following are arl_state_flags */ +#define ARL_LL_SUBNET_PENDING 0x01 /* Waiting for DL_INFO_ACK from drv */ +#define ARL_CONDEMNED 0x02 /* No more new ref's to the ILL */ +#define ARL_DL_UNBIND_IN_PROGRESS 0x04 /* UNBIND_REQ is sent */ +#define ARL_LL_BIND_PENDING 0x0020 /* BIND sent */ +#define ARL_LL_UP 0x0040 /* BIND acked */ +#define ARL_LL_DOWN 0x0080 +#define ARL_LL_UNBOUND 0x0100 /* UNBIND acked */ +#define ARL_LL_REPLUMBING 0x0200 /* replumb in progress */ + +#ifdef __cplusplus +} +#endif + +#endif /* _IP_ARP_H */ diff --git a/illumos-x86_64/usr/include/inet/ip_ftable.h b/illumos-x86_64/usr/include/inet/ip_ftable.h new file mode 100644 index 00000000..d8fa9e56 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip_ftable.h @@ -0,0 +1,92 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_IP_FTABLE_H +#define _INET_IP_FTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include +#include +#include + +struct rt_entry { + struct radix_node rt_nodes[2]; /* tree glue, and other values */ + /* + * struct rt_entry must begin with a struct radix_node (or two!) + * to a 'struct rt_entry *' + */ + struct rt_sockaddr rt_dst; + /* + * multiple routes to same dest/mask via varying gate/ifp are stored + * in the rt_irb bucket. + */ + irb_t rt_irb; +}; + +/* + * vehicle for passing args through rn_walktree + * + * The comment below (and for other netstack_t references) refers + * to the fact that we only do netstack_hold in particular cases, + * such as the references from open endpoints (ill_t and conn_t's + * pointers). Internally within IP we rely on IP's ability to cleanup e.g. + * ire_t's when an ill goes away. + */ +struct rtfuncarg { + pfv_t rt_func; + char *rt_arg; + uint_t rt_match_flags; + uint_t rt_ire_type; + ill_t *rt_ill; + zoneid_t rt_zoneid; + ip_stack_t *rt_ipst; /* Does not have a netstack_hold */ +}; +int rtfunc(struct radix_node *, void *); + +typedef struct rt_entry rt_t; +typedef struct rtfuncarg rtf_t; + +struct ts_label_s; +extern void ire_delete_host_redirects(ipaddr_t, ip_stack_t *); +extern irb_t *ire_get_bucket(ire_t *); +extern uint_t ifindex_lookup(const struct sockaddr *, zoneid_t); +extern int ipfil_sendpkt(const struct sockaddr *, mblk_t *, uint_t, zoneid_t); + +extern void irb_refhold_rn(struct radix_node *); +extern void irb_refrele_rn(struct radix_node *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP_FTABLE_H */ diff --git a/illumos-x86_64/usr/include/inet/ip_if.h b/illumos-x86_64/usr/include/inet/ip_if.h new file mode 100644 index 00000000..a625ec92 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip_if.h @@ -0,0 +1,540 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1990 Mentat Inc. + */ + +#ifndef _INET_IP_IF_H +#define _INET_IP_IF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PREFIX_INFINITY 0xffffffffUL + +#define IP_LOOPBACK_MTU (8*1024) + +#ifdef _KERNEL +/* + * Interface flags actually represent the state/properties of 3 different + * abstractions of interfaces in IP. Interface flags are set using + * SIOCS[L]IFFLAGS ioctl. The three abstractions are : + * + * 1) Physical interface (phyint) : There is one phyint allocated common + * to both IPv4 and IPv6 physical interface instance. + * + * 2) Physical interface instance (ill) : This encompasses all the state + * that is common across all IP addresses assigned to a physical + * interface but different between the IPv4 and IPv6 instance. + * + * 3) Logical interface (ipif) : This has state about a single IP address. + * + * Values for the various states are derived from the same name space + * as applications querying the state using SIOCGIFFLAGS/SIOCGLIFFLAGS + * see only one state returned in lifr_flags which is a union of all + * the above states/properties. Thus deriving the values from the common + * name space makes implementation easier. All these values are stored in + * uint64_t and any other structure/code using these flags should use + * uint64_ts. + * + * As we maintain the interface flags in 3 different flags namely + * phyint_flags, ill_flags, ipif_flags we define the following flag values + * to be used within the kernel to reduce potential errors. The ones + * starting with PHYI_ are supposed to be used with phyint_flags, the ones + * starting with ILLF_ are supposed to be used with ill_flags and the ones + * starting with IPIF_ are supposed to be used with ipif_flags. If you see + * any code with a mismatch i.e phyint_flags & IPIF_UP - it is wrong. Only + * PHYI_XXX can be used with phyint_flags. + * + * NOTE : For EVERY FLAG in if.h, there should be a corresponding value + * defined HERE and this is the one that should be USED within IP. We + * use IFF_ flags within IP only when we examine lifr_flags. + */ +#define IFF_PHYINT_FLAGS (IFF_LOOPBACK|IFF_RUNNING|IFF_PROMISC| \ + IFF_ALLMULTI|IFF_INTELLIGENT|IFF_MULTI_BCAST|IFF_FAILED|IFF_STANDBY| \ + IFF_INACTIVE|IFF_OFFLINE|IFF_VIRTUAL|IFF_IPMP|IFF_L3PROTECT) + +#define IFF_PHYINTINST_FLAGS (IFF_DEBUG|IFF_NOTRAILERS|IFF_NOARP| \ + IFF_MULTICAST|IFF_ROUTER|IFF_NONUD|IFF_NORTEXCH|IFF_IPV4|IFF_IPV6| \ + IFF_COS_ENABLED|IFF_FIXEDMTU|IFF_VRRP|IFF_NOACCEPT|IFF_NOLINKLOCAL) + +#define IFF_LOGINT_FLAGS (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT| \ + IFF_UNNUMBERED|IFF_DHCPRUNNING|IFF_PRIVATE|IFF_NOXMIT|IFF_NOLOCAL| \ + IFF_DEPRECATED|IFF_ADDRCONF|IFF_ANYCAST|IFF_NOFAILOVER| \ + IFF_PREFERRED|IFF_TEMPORARY|IFF_DUPLICATE) + +#define PHYI_LOOPBACK IFF_LOOPBACK /* is a loopback net */ +#define PHYI_RUNNING IFF_RUNNING /* resources allocated */ +#define PHYI_PROMISC IFF_PROMISC /* receive all packets */ +#define PHYI_ALLMULTI IFF_ALLMULTI /* receive all multi packets */ +#define PHYI_INTELLIGENT IFF_INTELLIGENT /* protocol code on board */ +#define PHYI_MULTI_BCAST IFF_MULTI_BCAST /* multicast using broadcast */ +#define PHYI_FAILED IFF_FAILED /* NIC has failed */ +#define PHYI_STANDBY IFF_STANDBY /* Standby NIC */ +#define PHYI_INACTIVE IFF_INACTIVE /* Standby active or not ? */ +#define PHYI_OFFLINE IFF_OFFLINE /* NIC has been offlined */ +#define PHYI_VIRTUAL IFF_VIRTUAL /* Will not send or recv pkts */ +#define PHYI_IPMP IFF_IPMP /* IPMP meta-interface */ +#define PHYI_L3PROTECT IFF_L3PROTECT /* Layer-3 protected */ + +#define ILLF_DEBUG IFF_DEBUG /* turn on debugging */ +#define ILLF_NOTRAILERS IFF_NOTRAILERS /* avoid use of trailers */ +#define ILLF_NOARP IFF_NOARP /* no ARP for this interface */ +#define ILLF_MULTICAST IFF_MULTICAST /* supports multicast */ +#define ILLF_ROUTER IFF_ROUTER /* router on this interface */ +#define ILLF_NONUD IFF_NONUD /* No NUD on this interface */ +#define ILLF_NORTEXCH IFF_NORTEXCH /* No routing info exchange */ +#define ILLF_IPV4 IFF_IPV4 /* IPv4 interface */ +#define ILLF_IPV6 IFF_IPV6 /* IPv6 interface */ +#define ILLF_COS_ENABLED IFF_COS_ENABLED /* Is CoS marking supported */ +#define ILLF_FIXEDMTU IFF_FIXEDMTU /* set with SIOCSLIFMTU */ +#define ILLF_VRRP IFF_VRRP /* managed by VRRP */ +#define ILLF_NOACCEPT IFF_NOACCEPT /* accept only ND messagees */ +#define ILLF_NOLINKLOCAL IFF_NOLINKLOCAL /* No default linklocal */ + +#define IPIF_UP IFF_UP /* interface is up */ +#define IPIF_BROADCAST IFF_BROADCAST /* broadcast address valid */ +#define IPIF_POINTOPOINT IFF_POINTOPOINT /* point-to-point link */ +#define IPIF_UNNUMBERED IFF_UNNUMBERED /* non-unique address */ +#define IPIF_DHCPRUNNING IFF_DHCPRUNNING /* DHCP controlled interface */ +#define IPIF_PRIVATE IFF_PRIVATE /* do not advertise */ +#define IPIF_NOXMIT IFF_NOXMIT /* Do not transmit packets */ +#define IPIF_NOLOCAL IFF_NOLOCAL /* Just on-link subnet */ +#define IPIF_DEPRECATED IFF_DEPRECATED /* address deprecated */ +#define IPIF_ADDRCONF IFF_ADDRCONF /* stateless addrconf */ +#define IPIF_ANYCAST IFF_ANYCAST /* Anycast address */ +#define IPIF_NOFAILOVER IFF_NOFAILOVER /* No failover on NIC failure */ +#define IPIF_PREFERRED IFF_PREFERRED /* Prefer as source address */ +#define IPIF_TEMPORARY IFF_TEMPORARY /* RFC3041 */ +#define IPIF_DUPLICATE IFF_DUPLICATE /* address is in use */ + +#ifdef DEBUG +#define ILL_MAC_PERIM_HELD(ill) ill_mac_perim_held(ill) +#else +#define ILL_MAC_PERIM_HELD(ill) +#endif + +/* + * match flags for ipif_lookup_addr_common* functions + */ +#define IPIF_MATCH_ILLGRP 0x00000001 +#define IPIF_MATCH_NONDUP 0x00000002 + +/* for ipif_resolver_up */ +enum ip_resolver_action { + Res_act_initial, /* initial address establishment */ + Res_act_rebind, /* IPMP address rebind (new hwaddr) */ + Res_act_defend, /* address defense */ + Res_act_none /* do nothing */ +}; + +extern int ill_add_ires(ill_t *); +extern void ill_delete_ires(ill_t *); +extern void ill_dlpi_done(ill_t *, t_uscalar_t); +extern boolean_t ill_dlpi_pending(ill_t *, t_uscalar_t); +extern void ill_dlpi_dispatch(ill_t *, mblk_t *); +extern void ill_dlpi_send(ill_t *, mblk_t *); +extern void ill_dlpi_send_deferred(ill_t *); +extern void ill_dlpi_queue(ill_t *, mblk_t *); +extern void ill_dlpi_send_queued(ill_t *); +extern void ill_mcast_queue(ill_t *, mblk_t *); +extern void ill_mcast_send_queued(ill_t *); +extern void ill_mcast_timer_start(ip_stack_t *); +extern void ill_capability_done(ill_t *); + +extern mblk_t *ill_dlur_gen(uchar_t *, uint_t, t_uscalar_t, t_scalar_t); +/* NOTE: Keep unmodified ill_lookup_on_ifindex for ipp for now */ +extern ill_t *ill_lookup_on_ifindex_global_instance(uint_t, boolean_t); +extern ill_t *ill_lookup_on_ifindex(uint_t, boolean_t, ip_stack_t *); +extern ill_t *ill_lookup_on_ifindex_zoneid(uint_t, zoneid_t, boolean_t, + ip_stack_t *); +extern ill_t *ill_lookup_on_name(char *, boolean_t, + boolean_t, boolean_t *, ip_stack_t *); +extern boolean_t ip_xmit_ifindex_valid(uint_t, zoneid_t, boolean_t, + ip_stack_t *); +extern uint_t ill_get_next_ifindex(uint_t, boolean_t, ip_stack_t *); +extern uint_t ill_get_ifindex_by_name(char *, ip_stack_t *); +extern uint_t ill_get_upper_ifindex(const ill_t *); +extern void ill_delete(ill_t *); +extern void ill_delete_tail(ill_t *); +extern int ill_dl_phys(ill_t *, ipif_t *, mblk_t *, queue_t *); +extern int ill_dls_info(struct sockaddr_dl *, const ill_t *); +extern void ill_fastpath_ack(ill_t *, mblk_t *); +extern int ill_fastpath_probe(ill_t *, mblk_t *); +extern int ill_forward_set(ill_t *, boolean_t); +extern void ill_frag_prune(ill_t *, uint_t); +extern void ill_frag_free_pkts(ill_t *, ipfb_t *, ipf_t *, int); +extern time_t ill_frag_timeout(ill_t *, time_t); +extern int ill_init(queue_t *, ill_t *); +extern void ill_restart_dad(ill_t *, boolean_t); +extern void ill_setdefaulttoken(ill_t *); +extern void ill_setdesttoken(ill_t *); +extern void ill_set_inputfn(ill_t *); +extern void ill_set_inputfn_all(ip_stack_t *); +extern int ill_set_phys_addr(ill_t *, mblk_t *); +extern void ill_set_allowed_ips(ill_t *, mblk_t *); +extern int ill_replumb(ill_t *, mblk_t *); +extern void ill_set_ndmp(ill_t *, mblk_t *, uint_t, uint_t); + +extern boolean_t ill_is_freeable(ill_t *ill); +extern void ill_refhold(ill_t *); +extern void ill_refhold_locked(ill_t *); +extern boolean_t ill_check_and_refhold(ill_t *); +extern void ill_refrele(ill_t *); +extern boolean_t ill_waiter_inc(ill_t *); +extern void ill_waiter_dcr(ill_t *); +extern void ill_trace_ref(ill_t *); +extern void ill_untrace_ref(ill_t *); +extern void ill_downi(ire_t *, char *); +extern void ill_downi_if_clone(ire_t *, char *); +extern boolean_t ill_down_start(queue_t *, mblk_t *); +extern ill_t *ill_lookup_group_v4(ipaddr_t, zoneid_t, + ip_stack_t *, boolean_t *, ipaddr_t *); +extern ill_t *ill_lookup_group_v6(const in6_addr_t *, zoneid_t, + ip_stack_t *, boolean_t *, in6_addr_t *); + +extern void ill_capability_ack(ill_t *, mblk_t *); +extern void ill_capability_probe(ill_t *); +extern void ill_capability_reset(ill_t *, boolean_t); +extern void ill_taskq_dispatch(ip_stack_t *); + +extern void ill_get_name(const ill_t *, char *, int); +extern void ill_group_cleanup(ill_t *); +extern int ill_up_ipifs(ill_t *, queue_t *, mblk_t *); +extern void ip_update_source_selection(ip_stack_t *); +extern uint_t ill_appaddr_cnt(const ill_t *); +extern uint_t ill_ptpaddr_cnt(const ill_t *); +extern uint_t ill_admupaddr_cnt(const ill_t *); + +extern ill_t *ill_lookup_multicast(ip_stack_t *, zoneid_t, boolean_t); +extern void ill_save_ire(ill_t *, ire_t *); +extern void ill_remove_saved_ire(ill_t *, ire_t *); +extern int ill_recover_saved_ire(ill_t *); + +extern void ip_interface_cleanup(ip_stack_t *); +extern void ipif_get_name(const ipif_t *, char *, int); +extern ipif_t *ipif_getby_indexes(uint_t, uint_t, boolean_t, ip_stack_t *); +extern void ipif_init(ip_stack_t *); +extern ipif_t *ipif_lookup_addr(ipaddr_t, ill_t *, zoneid_t, ip_stack_t *); +extern ipif_t *ipif_lookup_addr_exact(ipaddr_t, ill_t *, ip_stack_t *); +extern ipif_t *ipif_lookup_addr_nondup(ipaddr_t, ill_t *, zoneid_t, + ip_stack_t *); +extern ipif_t *ipif_lookup_addr_v6(const in6_addr_t *, ill_t *, zoneid_t, + ip_stack_t *); +extern ipif_t *ipif_lookup_addr_exact_v6(const in6_addr_t *, ill_t *, + ip_stack_t *); +extern ipif_t *ipif_lookup_addr_nondup_v6(const in6_addr_t *, ill_t *, + zoneid_t, ip_stack_t *); +extern zoneid_t ipif_lookup_addr_zoneid(ipaddr_t, ill_t *, ip_stack_t *); +extern zoneid_t ipif_lookup_addr_zoneid_v6(const in6_addr_t *, ill_t *, + ip_stack_t *); +extern ipif_t *ipif_lookup_interface(ipaddr_t, ipaddr_t, ip_stack_t *); +extern ipif_t *ipif_lookup_remote(ill_t *, ipaddr_t, zoneid_t); +extern boolean_t ipif_lookup_testaddr_v6(ill_t *, const in6_addr_t *, + ipif_t **); +extern boolean_t ipif_lookup_testaddr_v4(ill_t *, const in_addr_t *, + ipif_t **); +extern ipif_t *ipif_select_source_v4(ill_t *, ipaddr_t, zoneid_t, boolean_t, + boolean_t *); +extern boolean_t ipif_zone_avail(uint_t, boolean_t, zoneid_t, ip_stack_t *); +extern ipif_t *ipif_good_addr(ill_t *, zoneid_t); +extern int ip_select_source_v4(ill_t *, ipaddr_t, ipaddr_t, ipaddr_t, + zoneid_t, ip_stack_t *, ipaddr_t *, uint32_t *, uint64_t *); +extern void ipif_refhold(ipif_t *); +extern void ipif_refhold_locked(ipif_t *); +extern void ipif_refrele(ipif_t *); +extern void ipif_all_down_tail(ipsq_t *, queue_t *, mblk_t *, void *); +extern int ipif_resolver_up(ipif_t *, enum ip_resolver_action); +extern int ipif_down(ipif_t *, queue_t *, mblk_t *); +extern int ipif_down_tail(ipif_t *); +extern void ipif_multicast_down(ipif_t *); +extern void ipif_multicast_up(ipif_t *); +extern void ipif_ndp_down(ipif_t *); +extern int ipif_ndp_up(ipif_t *, boolean_t); +extern int ipif_up_done(ipif_t *); +extern int ipif_up_done_v6(ipif_t *); +extern void ipif_up_notify(ipif_t *); +extern ipif_t *ipif_select_source_v6(ill_t *, const in6_addr_t *, boolean_t, + uint32_t, zoneid_t, boolean_t, boolean_t *); +extern int ip_select_source_v6(ill_t *, const in6_addr_t *, + const in6_addr_t *, zoneid_t, ip_stack_t *, uint_t, uint32_t, in6_addr_t *, + uint32_t *, uint64_t *); +extern boolean_t ipif_cant_setlinklocal(ipif_t *); +extern void ipif_setlinklocal(ipif_t *); +extern void ipif_setdestlinklocal(ipif_t *); +extern ipif_t *ipif_lookup_on_ifindex(uint_t, boolean_t, zoneid_t, + ip_stack_t *); +extern ipif_t *ipif_get_next_ipif(ipif_t *curr, ill_t *ill); +extern void ipif_ill_refrele_tail(ill_t *ill); +extern void ipif_nce_down(ipif_t *ipif); +extern int ipif_arp_down(ipif_t *ipif); +extern void ipif_mask_reply(ipif_t *); +extern int ipif_up(ipif_t *, queue_t *, mblk_t *); +extern ill_t *ill_lookup_usesrc(ill_t *); + +extern void ipsq_current_start(ipsq_t *, ipif_t *, int); +extern void ipsq_current_finish(ipsq_t *); +extern void ipsq_enq(ipsq_t *, queue_t *, mblk_t *, ipsq_func_t, int, + ill_t *); +extern boolean_t ipsq_enter(ill_t *, boolean_t, int); +extern ipsq_t *ipsq_try_enter(ipif_t *, ill_t *, queue_t *, mblk_t *, + ipsq_func_t, int, boolean_t); +extern void ipsq_exit(ipsq_t *); +extern boolean_t ill_mac_perim_held(ill_t *); +extern mblk_t *ipsq_pending_mp_get(ipsq_t *, conn_t **); +extern boolean_t ipsq_pending_mp_add(conn_t *, ipif_t *, queue_t *, + mblk_t *, int); +extern void qwriter_ip(ill_t *, queue_t *, mblk_t *, ipsq_func_t, int, + boolean_t); + +typedef int ip_extract_func_t(queue_t *, mblk_t *, const ip_ioctl_cmd_t *, + cmd_info_t *); + +extern ip_extract_func_t ip_extract_arpreq, ip_extract_lifreq; + +extern int ip_addr_availability_check(ipif_t *); +extern void ip_ll_subnet_defaults(ill_t *, mblk_t *); +extern void ill_capability_send(ill_t *, mblk_t *); + +extern int ip_rt_add(ipaddr_t, ipaddr_t, ipaddr_t, ipaddr_t, int, + ill_t *, ire_t **, boolean_t, struct rtsa_s *, ip_stack_t *, zoneid_t); +extern int ip_rt_add_v6(const in6_addr_t *, const in6_addr_t *, + const in6_addr_t *, const in6_addr_t *, int, ill_t *, ire_t **, + struct rtsa_s *, ip_stack_t *, zoneid_t); +extern int ip_rt_delete(ipaddr_t, ipaddr_t, ipaddr_t, uint_t, int, + ill_t *, boolean_t, ip_stack_t *, zoneid_t); +extern int ip_rt_delete_v6(const in6_addr_t *, const in6_addr_t *, + const in6_addr_t *, uint_t, int, ill_t *, ip_stack_t *, zoneid_t); +extern int ip_siocdelndp_v6(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_siocqueryndp_v6(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_siocsetndp_v6(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_siocaddrt(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_siocdelrt(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_prefix(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_prefix_restart(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_addr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_addr_restart(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_addr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_dstaddr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_dstaddr_restart(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_dstaddr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_flags(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_flags_restart(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_flags(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_mtu(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_mtu(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_get_ifconf(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_lifconf(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_ifnum(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_lifnum(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_token(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_token(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int if_unitsel(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int if_unitsel_restart(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_sifname(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_slifname(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_slifname_restart(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_slifindex(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_lifindex(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_brdaddr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_brdaddr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_get_muxid(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_muxid(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_netmask(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_netmask(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_netmask_restart(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_subnet(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_subnet_restart(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_subnet(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_lnkinfo(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_lnkinfo(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_metric(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_metric(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_arp(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_addif(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_removeif(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_removeif_restart(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_tonlink(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_tmysite(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_tmyaddr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_get_binding(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_groupname(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_groupname(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_groupinfo(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_get_lifzone(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_slifzone(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_slifzone_restart(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_get_lifusesrc(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_slifusesrc(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_lifsrcof(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_get_dadstate(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern int ip_sioctl_get_ifhwaddr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_get_lifhwaddr(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); + +extern void ip_sioctl_copyin_resume(ipsq_t *, queue_t *, mblk_t *, void *); +extern void ip_sioctl_copyin_setup(queue_t *, mblk_t *); +extern ip_ioctl_cmd_t *ip_sioctl_lookup(int); +extern void ipif_delete_ires_v4(ipif_t *); +extern void ipif_delete_ires_v6(ipif_t *); +extern int ipif_arp_up(ipif_t *, enum ip_resolver_action, boolean_t); +extern void ipif_dup_recovery(void *); +extern void ipif_do_recovery(ipif_t *); + +/* + * Notes on reference tracing on ill, ipif, ire, nce data structures: + * + * The current model of references on an ipif or ill is purely based on threads + * acquiring a reference by doing a lookup on the ill or ipif or by calling a + * refhold function on the ill or ipif. In particular any data structure that + * points to an ipif or ill does not explicitly contribute to a reference on the + * ill or ipif. More details may be seen in the block comment above ipif_down(). + * Thus in the quiescent state an ill or ipif has a refcnt of zero. Similarly + * when a thread exits, there can't be any references on the ipif or ill due to + * the exiting thread. + * + * As a debugging aid, the refhold and refrele functions call into tracing + * functions that record the stack trace of the caller and the references + * acquired or released by the calling thread, hashed by the structure address + * in thread-specific-data (TSD). On thread exit, ip_thread_exit destroys the + * hash, and the destructor for the hash entries (th_trace_free) verifies that + * there are no outstanding references to the ipif or ill from the exiting + * thread. + * + * In the case of ires and nces, the model is slightly different. Typically each + * ire pointing to an nce contributes to the nce_refcnt. Similarly a conn_t + * pointing to an ire also contributes to the ire_refcnt. Excluding the above + * special cases, the tracing behavior is similar to the tracing on ipif / ill. + * Traces are neither recorded nor verified in the exception cases, and the code + * is careful to use the right refhold and refrele functions. On thread exit + * ire_thread_exit, nce_thread_exit does the verification that are no + * outstanding references on the ire / nce from the exiting thread. + * + * The reference verification is driven from the TSD destructor which calls + * into IP's verification function ip_thread_exit. This debugging aid may be + * helpful in tracing missing refrele's on a debug kernel. On a non-debug + * kernel, these missing refrele's are noticeable only when an interface is + * being unplumbed, and the unplumb hangs, long after the missing refrele. On a + * debug kernel, the traces (th_trace_t) which contain the stack backtraces can + * be examined on a crash dump to locate the missing refrele. + */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP_IF_H */ diff --git a/illumos-x86_64/usr/include/inet/ip_ire.h b/illumos-x86_64/usr/include/inet/ip_ire.h new file mode 100644 index 00000000..9045f984 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip_ire.h @@ -0,0 +1,356 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_IP_IRE_H +#define _INET_IP_IRE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define IPV6_LL_PREFIXLEN 10 /* Number of bits in link-local pref */ + +#define IP_CACHE_TABLE_SIZE 256 +#define IP_MASK_TABLE_SIZE (IP_ABITS + 1) /* 33 ptrs */ + +#define IP6_FTABLE_HASH_SIZE 32 /* size of each hash table in ptrs */ +#define IP6_CACHE_TABLE_SIZE 256 +#define IP6_MASK_TABLE_SIZE (IPV6_ABITS + 1) /* 129 ptrs */ + +/* + * We use the common modulo hash function. In ip_ire_init(), we make + * sure that the cache table size is always a power of 2. That's why + * we can use & instead of %. Also note that we try hard to make sure + * the lower bits of an address capture most info from the whole address. + * The reason being that since our hash table is probably a lot smaller + * than 2^32 buckets so the lower bits are the most important. + */ +#define IRE_ADDR_HASH(addr, table_size) \ + (((addr) ^ ((addr) >> 8) ^ ((addr) >> 16) ^ ((addr) >> 24)) & \ + ((table_size) - 1)) + +/* + * To make a byte-order neutral hash for IPv6, just take all the + * bytes in the bottom 32 bits into account. + */ +#define IRE_ADDR_HASH_V6(addr, table_size) \ + IRE_ADDR_HASH((addr).s6_addr32[3], table_size) + +/* + * This assumes that the ftable size is a power of 2. + * We include some high-order bytes to avoid all IRE_LOCALs in the same + * bucket for performance reasons. + */ +#define IRE_ADDR_MASK_HASH_V6(addr, mask, table_size) \ + ((((addr).s6_addr8[0] & (mask).s6_addr8[0]) ^ \ + ((addr).s6_addr8[1] & (mask).s6_addr8[1]) ^ \ + ((addr).s6_addr8[6] & (mask).s6_addr8[6]) ^ \ + ((addr).s6_addr8[7] & (mask).s6_addr8[7]) ^ \ + ((addr).s6_addr8[8] & (mask).s6_addr8[8]) ^ \ + ((addr).s6_addr8[9] & (mask).s6_addr8[9]) ^ \ + ((addr).s6_addr8[10] & (mask).s6_addr8[10]) ^ \ + ((addr).s6_addr8[13] & (mask).s6_addr8[13]) ^ \ + ((addr).s6_addr8[14] & (mask).s6_addr8[14]) ^ \ + ((addr).s6_addr8[15] & (mask).s6_addr8[15])) & ((table_size) - 1)) + +#define IRE_HIDDEN_TYPE(ire_type) ((ire_type) & \ + (IRE_HOST | IRE_PREFIX | IRE_DEFAULT | IRE_IF_ALL | IRE_BROADCAST)) + +/* + * match parameter definitions for IRE lookup routines. + */ +#define MATCH_IRE_DSTONLY 0x0000 /* Match just the address */ +#define MATCH_IRE_TYPE 0x0001 /* Match IRE type */ +#define MATCH_IRE_MASK 0x0002 /* Match IRE mask */ +#define MATCH_IRE_SHORTERMASK 0x0004 /* A mask shorter than the argument */ +#define MATCH_IRE_GW 0x0008 /* Match IRE gateway */ +#define MATCH_IRE_ILL 0x0010 /* Match IRE on the ill */ +#define MATCH_IRE_ZONEONLY 0x0020 /* Match IREs in specified zone, ie */ + /* don't match IRE_LOCALs from other */ + /* zones or shared IREs */ +#define MATCH_IRE_SECATTR 0x0040 /* Match gateway security attributes */ +#define MATCH_IRE_TESTHIDDEN 0x0080 /* Match ire_testhidden IREs */ +#define MATCH_IRE_SRC_ILL 0x0100 /* ire_ill uses a src address on ill */ +#define MATCH_IRE_DIRECT 0x0200 /* Don't match indirect routes */ + +#define MAX_IRE_RECURSION 4 /* Max IREs in ire_route_recursive */ + + +/* + * We use atomics so that we get an accurate accounting on the ires. + * Otherwise we can't determine leaks correctly. + */ +#define BUMP_IRE_STATS(ire_stats, x) atomic_inc_64(&(ire_stats).x) + +#ifdef _KERNEL +struct ts_label_s; +struct nce_s; +/* + * structure for passing args between ire_ftable_lookup and ire_find_best_route + */ +typedef struct ire_ftable_args_s { + in6_addr_t ift_addr_v6; + in6_addr_t ift_mask_v6; + in6_addr_t ift_gateway_v6; +#define ift_addr V4_PART_OF_V6(ift_addr_v6) +#define ift_mask V4_PART_OF_V6(ift_mask_v6) +#define ift_gateway V4_PART_OF_V6(ift_gateway_v6) + int ift_type; + const ill_t *ift_ill; + zoneid_t ift_zoneid; + const ts_label_t *ift_tsl; + int ift_flags; + ire_t *ift_best_ire; +} ire_ftable_args_t; + +extern ipaddr_t ip_plen_to_mask(uint_t); +extern in6_addr_t *ip_plen_to_mask_v6(uint_t, in6_addr_t *); + +extern int ip_ire_advise(queue_t *, mblk_t *, cred_t *); +extern int ip_ire_delete(queue_t *, mblk_t *, cred_t *); +extern void ip_ire_reclaim(void *); + +extern int ip_mask_to_plen(ipaddr_t); +extern int ip_mask_to_plen_v6(const in6_addr_t *); + +extern ire_t *ire_add(ire_t *); +extern ire_t *ire_add_v6(ire_t *); +extern int ire_atomic_start(irb_t *irb_ptr, ire_t *ire); +extern void ire_atomic_end(irb_t *irb_ptr, ire_t *ire); + +extern ire_t *ire_create(uchar_t *, uchar_t *, uchar_t *, + ushort_t, ill_t *, zoneid_t, uint_t, tsol_gc_t *, ip_stack_t *); + +extern ire_t **ire_create_bcast(ill_t *, ipaddr_t, zoneid_t, ire_t **); +extern ire_t *ire_create_if_clone(ire_t *, const in6_addr_t *, uint_t *); +extern ire_t *ire_lookup_bcast(ill_t *, ipaddr_t, zoneid_t); +extern int ire_init_v4(ire_t *, uchar_t *, uchar_t *, uchar_t *, + ushort_t, ill_t *, zoneid_t, uint_t, tsol_gc_t *, ip_stack_t *); +extern int ire_init_v6(ire_t *, const in6_addr_t *, const in6_addr_t *, + const in6_addr_t *, ushort_t, ill_t *, zoneid_t, uint_t, tsol_gc_t *, + ip_stack_t *); + +extern int ire_init_common(ire_t *, ushort_t, ill_t *, zoneid_t, uint_t, + uchar_t, tsol_gc_t *, ip_stack_t *); + +extern ire_t *ire_create_v6(const in6_addr_t *, const in6_addr_t *, + const in6_addr_t *, ushort_t, ill_t *, zoneid_t, uint_t, + tsol_gc_t *, ip_stack_t *); + +extern void ire_delete(ire_t *); +extern void ire_delete_v6(ire_t *); + +extern boolean_t ire_dep_build(ire_t *[], uint_t [], uint_t); +extern void ire_dep_delete_if_clone(ire_t *); +extern void ire_dep_incr_generation(ire_t *); +extern void ire_dep_remove(ire_t *); +extern void ire_dep_unbuild(ire_t *[], uint_t); +extern uint_t ire_dep_validate_generations(ire_t *); +extern void ire_dep_invalidate_generations(ire_t *); +extern boolean_t ire_determine_nce_capable(ire_t *); + +extern void ire_flush_cache_v4(ire_t *, int); +extern void ire_flush_cache_v6(ire_t *, int); + +extern ire_t *ire_ftable_lookup_v4(ipaddr_t, ipaddr_t, ipaddr_t, int, + const ill_t *, zoneid_t, const struct ts_label_s *, int, uint32_t, + ip_stack_t *, uint_t *); +extern ire_t *ire_ftable_lookup_v6(const in6_addr_t *, const in6_addr_t *, + const in6_addr_t *, int, const ill_t *, zoneid_t, + const struct ts_label_s *, int, uint32_t, ip_stack_t *, uint_t *); + +extern ire_t *ire_ftable_lookup_simple_v4(ipaddr_t, uint32_t, ip_stack_t *, + uint_t *); +extern ire_t *ire_ftable_lookup_simple_v6(const in6_addr_t *, uint32_t, + ip_stack_t *, uint_t *); + +extern boolean_t ire_gateway_ok_zone_v4(ipaddr_t, zoneid_t, ill_t *, + const ts_label_t *, ip_stack_t *, boolean_t); +extern boolean_t ire_gateway_ok_zone_v6(const in6_addr_t *, zoneid_t, ill_t *, + const ts_label_t *, ip_stack_t *, boolean_t); + +extern ire_t *ire_alt_local(ire_t *, zoneid_t, const ts_label_t *, + const ill_t *, uint_t *); + +extern ill_t *ire_lookup_multi_ill_v4(ipaddr_t, zoneid_t, ip_stack_t *, + boolean_t *, ipaddr_t *); +extern ill_t *ire_lookup_multi_ill_v6(const in6_addr_t *, zoneid_t, + ip_stack_t *, boolean_t *, in6_addr_t *); + +extern ire_t *ire_nexthop(ire_t *); +extern ill_t *ire_nexthop_ill(ire_t *); +extern ill_t *ire_nce_ill(ire_t *); + +extern ire_t *ire_reject(ip_stack_t *, boolean_t); +extern ire_t *ire_blackhole(ip_stack_t *, boolean_t); +extern ire_t *ire_multicast(ill_t *); + +/* The different ire_recvfn functions */ +extern void ire_recv_forward_v4(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_noroute_v4(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_broadcast_v4(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_multicast_v4(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_multirt_v4(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_loopback_v4(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_local_v4(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_noaccept_v4(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); + +extern void ire_recv_forward_v6(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_noroute_v6(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_multicast_v6(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_multirt_v6(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_loopback_v6(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); +extern void ire_recv_local_v6(ire_t *, mblk_t *, void *, ip_recv_attr_t *); +extern void ire_recv_noaccept_v6(ire_t *, mblk_t *, void *, + ip_recv_attr_t *); + +extern void irb_refhold(irb_t *); +extern void irb_refhold_locked(irb_t *); +extern void irb_refrele(irb_t *); +extern void irb_increment_generation(irb_t *); + +extern void ire_refhold(ire_t *); +extern void ire_refhold_notr(ire_t *); +extern void ire_refhold_locked(ire_t *); +extern void ire_refrele(ire_t *); +extern void ire_refrele_notr(ire_t *); +extern void ire_make_condemned(ire_t *); +extern boolean_t ire_no_good(ire_t *); +extern nce_t *ire_handle_condemned_nce(nce_t *, ire_t *, ipha_t *, ip6_t *, + boolean_t); + +extern ire_t *ire_round_robin(irb_t *, ire_ftable_args_t *, uint_t, + ire_t *, ip_stack_t *); + +extern ire_t *ire_route_recursive_v4(ipaddr_t, uint_t, const ill_t *, + zoneid_t, const ts_label_t *, uint_t, uint_t, uint32_t, ip_stack_t *, + ipaddr_t *, tsol_ire_gw_secattr_t **, uint_t *); +extern ire_t *ire_route_recursive_v6(const in6_addr_t *, uint_t, + const ill_t *, zoneid_t, const ts_label_t *, uint_t, uint_t, uint32_t, + ip_stack_t *, in6_addr_t *, tsol_ire_gw_secattr_t **, uint_t *); +extern ire_t *ire_route_recursive_dstonly_v4(ipaddr_t, uint_t, + uint32_t, ip_stack_t *); +extern ire_t *ire_route_recursive_dstonly_v6(const in6_addr_t *, uint_t, + uint32_t, ip_stack_t *); +extern ire_t *ire_route_recursive_impl_v4(ire_t *ire, ipaddr_t, uint_t, + const ill_t *, zoneid_t, const ts_label_t *, uint_t, uint_t, uint32_t, + ip_stack_t *, ipaddr_t *, tsol_ire_gw_secattr_t **, uint_t *); +extern ire_t *ire_route_recursive_impl_v6(ire_t *ire, const in6_addr_t *, + uint_t, const ill_t *, zoneid_t, const ts_label_t *, uint_t, uint_t, + uint32_t, ip_stack_t *, in6_addr_t *, tsol_ire_gw_secattr_t **, uint_t *); + +/* The different ire_sendfn functions */ +extern int ire_send_local_v4(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_multirt_v4(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_noroute_v4(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_multicast_v4(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_broadcast_v4(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_wire_v4(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_local_v6(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_multirt_v6(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_noroute_v6(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_multicast_v6(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); +extern int ire_send_wire_v6(ire_t *, mblk_t *, void *, + ip_xmit_attr_t *, uint32_t *); + +extern nce_t *ire_to_nce_pkt(ire_t *, mblk_t *); +extern nce_t *ire_to_nce(ire_t *, ipaddr_t, const in6_addr_t *); + +/* Different ire_postfragfn functions */ +extern int ip_xmit(mblk_t *, struct nce_s *, + iaflags_t, uint_t, uint32_t, zoneid_t, zoneid_t, uintptr_t *); +extern int ip_postfrag_loopcheck(mblk_t *, struct nce_s *, + iaflags_t, uint_t, uint32_t, zoneid_t, zoneid_t, uintptr_t *); +extern int ip_postfrag_multirt_v4(mblk_t *, struct nce_s *, + iaflags_t, uint_t, uint32_t, zoneid_t, zoneid_t, uintptr_t *); +extern int ip_postfrag_multirt_v6(mblk_t *, struct nce_s *, + iaflags_t, uint_t, uint32_t, zoneid_t, zoneid_t, uintptr_t *); + +extern void ip_postfrag_loopback(mblk_t *, struct nce_s *, + iaflags_t, uint_t, zoneid_t); +extern int ire_revalidate_nce(ire_t *); + +extern ire_t *ip_select_route_pkt(mblk_t *, ip_xmit_attr_t *, + uint_t *, int *, boolean_t *); +extern ire_t *ip_select_route(const in6_addr_t *, const in6_addr_t, + ip_xmit_attr_t *, uint_t *, in6_addr_t *, int *, boolean_t *); +extern ire_t *ip_select_route_v4(ipaddr_t, ipaddr_t, ip_xmit_attr_t *, + uint_t *, ipaddr_t *, int *, boolean_t *); +extern ire_t *ip_select_route_v6(const in6_addr_t *, const in6_addr_t, + ip_xmit_attr_t *, uint_t *, in6_addr_t *, int *, boolean_t *); + +extern void ire_walk(pfv_t, void *, ip_stack_t *); +extern void ire_walk_ill(uint_t, uint_t, pfv_t, void *, ill_t *); +extern void ire_walk_v4(pfv_t, void *, zoneid_t, ip_stack_t *); +extern void ire_walk_ill_tables(uint_t match_flags, uint_t ire_type, + pfv_t func, void *arg, size_t ftbl_sz, size_t htbl_sz, + irb_t **ipftbl, ill_t *ill, + zoneid_t zoneid, ip_stack_t *); +extern void ire_walk_v6(pfv_t, void *, zoneid_t, ip_stack_t *); + +extern boolean_t ire_match_args(ire_t *, ipaddr_t, ipaddr_t, ipaddr_t, + int, const ill_t *, zoneid_t, const struct ts_label_s *, int); +extern boolean_t ire_match_args_v6(ire_t *, const in6_addr_t *, + const in6_addr_t *, const in6_addr_t *, int, const ill_t *, zoneid_t, + const ts_label_t *, int); + +extern struct nce_s *arp_nce_init(ill_t *, in_addr_t, int); +extern boolean_t ire_walk_ill_match(uint_t, uint_t, ire_t *, ill_t *, + zoneid_t, ip_stack_t *); +extern void ire_increment_generation(ire_t *); +extern void ire_increment_multicast_generation(ip_stack_t *, boolean_t); +extern void ire_rebind(ire_t *); +extern boolean_t ire_clone_verify(ire_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP_IRE_H */ diff --git a/illumos-x86_64/usr/include/inet/ip_multi.h b/illumos-x86_64/usr/include/inet/ip_multi.h new file mode 100644 index 00000000..c41ef99e --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip_multi.h @@ -0,0 +1,132 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_IP_MULTI_H +#define _INET_IP_MULTI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) + +#define INFINITY 0xffffffffU +/* + * Enum used to pass ilg status to ip_addmulti() and friends. There + * are three possibilities: the group is being joined from within ip, + * in which case there is no associated ilg; the group is being joined + * from an upper layer with an associated ilg that's been newly created + * by this join; or the upper layer is changing its group membership + * state (the ilg existed before this call). + */ +typedef enum { + ILGSTAT_NONE, + ILGSTAT_NEW, + ILGSTAT_CHANGE +} ilg_stat_t; + +/* + * Extern functions + */ +extern mblk_t *igmp_input(mblk_t *, ip_recv_attr_t *); +extern void igmp_joingroup(ilm_t *); +extern void igmp_leavegroup(ilm_t *); +extern void igmp_slowtimo(void *); +extern void igmp_timeout_handler(void *); +extern void igmp_statechange(ilm_t *, mcast_record_t, slist_t *); + +extern void mld_joingroup(ilm_t *); +extern void mld_leavegroup(ilm_t *); +extern void mld_statechange(ilm_t *, mcast_record_t, slist_t *); +extern void mld_slowtimo(void *); + +extern void ilg_delete_all(conn_t *connp); +extern boolean_t conn_hasmembers_ill_withsrc_v4(conn_t *, ipaddr_t, + ipaddr_t, ill_t *); +extern boolean_t conn_hasmembers_ill_withsrc_v6(conn_t *, + const in6_addr_t *, const in6_addr_t *, ill_t *); + +extern void ill_leave_multicast(ill_t *); +extern void ill_recover_multicast(ill_t *); +extern void ip_dlur_to_mhi(ill_t *, mblk_t *, + struct mac_header_info_s *); + +/* These make up the data path interface used by ip_output and ip_input */ +extern boolean_t ill_hasmembers_v4(ill_t *, ipaddr_t); +extern boolean_t ill_hasmembers_v6(ill_t *, const in6_addr_t *); +extern boolean_t ill_hasmembers_otherzones_v4(ill_t *, ipaddr_t, + zoneid_t); +extern boolean_t ill_hasmembers_otherzones_v6(ill_t *, + const in6_addr_t *, zoneid_t); +extern zoneid_t ill_hasmembers_nextzone_v4(ill_t *, ipaddr_t, zoneid_t); +extern zoneid_t ill_hasmembers_nextzone_v6(ill_t *, const in6_addr_t *, + zoneid_t); + +extern ilm_t *ip_addmulti(const in6_addr_t *, ill_t *, zoneid_t, + int *); +extern int ip_delmulti(ilm_t *); +extern int ip_mforward(mblk_t *, ip_recv_attr_t *); +extern void ip_mroute_decap(mblk_t *, ip_recv_attr_t *); +extern int ill_join_allmulti(ill_t *); +extern void ill_leave_allmulti(ill_t *); +extern int ip_join_allmulti(uint_t, boolean_t, ip_stack_t *); +extern int ip_leave_allmulti(uint_t, boolean_t, ip_stack_t *); +extern void ip_purge_allmulti(ill_t *); +extern int ip_mroute_mrt(mblk_t *, ip_stack_t *); +extern int ip_mroute_stats(mblk_t *, ip_stack_t *); +extern int ip_mroute_vif(mblk_t *, ip_stack_t *); +extern int ip_mrouter_done(ip_stack_t *); +extern int ip_mrouter_get(int, conn_t *, uchar_t *); +extern int ip_mrouter_set(int, conn_t *, int, uchar_t *, int); +extern void ip_mrouter_stack_init(ip_stack_t *); +extern void ip_mrouter_stack_destroy(ip_stack_t *); + +extern int ip_opt_add_group(conn_t *, boolean_t, + const in6_addr_t *, ipaddr_t, uint_t, mcast_record_t, const in6_addr_t *); +extern int ip_opt_delete_group(conn_t *, boolean_t, + const in6_addr_t *, ipaddr_t, uint_t, mcast_record_t, const in6_addr_t *); + +extern int mrt_ioctl(ipif_t *, sin_t *, queue_t *, mblk_t *, + ip_ioctl_cmd_t *, void *); +extern int ip_sioctl_msfilter(ipif_t *, sin_t *, queue_t *, + mblk_t *, ip_ioctl_cmd_t *, void *); +extern int ip_copyin_msfilter(queue_t *, mblk_t *); + +extern mblk_t *pim_input(mblk_t *, ip_recv_attr_t *); +extern void update_conn_ill(ill_t *, ip_stack_t *); +extern void reset_mrt_ill(ill_t *); +extern void reset_mrt_vif_ipif(ipif_t *); +extern void igmp_start_timers(unsigned, ip_stack_t *); +extern void mld_start_timers(unsigned, ip_stack_t *); +extern void ilm_inactive(ilm_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP_MULTI_H */ diff --git a/illumos-x86_64/usr/include/inet/ip_netinfo.h b/illumos-x86_64/usr/include/inet/ip_netinfo.h new file mode 100644 index 00000000..a496248e --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip_netinfo.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_IP_NETINFO_H +#define _INET_IP_NETINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +extern ddi_taskq_t *eventq_queue_nic; + +extern void ip_net_g_init(); +extern void ip_net_g_destroy(); +extern void ip_net_init(ip_stack_t *, netstack_t *); +extern void ip_net_destroy(ip_stack_t *); +extern void ipv4_hook_init(ip_stack_t *); +extern void ipv6_hook_init(ip_stack_t *); +extern void arp_hook_init(ip_stack_t *); +extern void ipv4_hook_destroy(ip_stack_t *); +extern void ipv6_hook_destroy(ip_stack_t *); +extern void arp_hook_destroy(ip_stack_t *); +extern void ipv4_hook_shutdown(ip_stack_t *); +extern void ipv6_hook_shutdown(ip_stack_t *); +extern void arp_hook_shutdown(ip_stack_t *); +extern void ip_ne_queue_func(void *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP_NETINFO_H */ diff --git a/illumos-x86_64/usr/include/inet/ip_rts.h b/illumos-x86_64/usr/include/inet/ip_rts.h new file mode 100644 index 00000000..f5cbedd3 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip_rts.h @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_IP_RTS_H +#define _INET_IP_RTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Maximum number of route security attributes that can be + * configured per route destination through the routing + * socket message. + */ +#define TSOL_RTSA_REQUEST_MAX 1 /* one per route destination */ + +/* + * Flags for RTS queuing operations. + */ +#define RTSQ_UNDER_IPMP 0x01 /* send only on RTAW_UNDER_IPMP queues */ +#define RTSQ_NORMAL 0x02 /* send only on normal queues */ +#define RTSQ_ALL (RTSQ_UNDER_IPMP|RTSQ_NORMAL) /* send on all queues */ +#define RTSQ_DEFAULT 0x04 /* use standard filtering */ + +#ifdef _KERNEL + +extern void ip_rts_change(int, ipaddr_t, ipaddr_t, + ipaddr_t, ipaddr_t, ipaddr_t, int, int, + int, ip_stack_t *); + +extern void ip_rts_change_v6(int, const in6_addr_t *, const in6_addr_t *, + const in6_addr_t *, const in6_addr_t *, const in6_addr_t *, int, int, int, + ip_stack_t *); + +extern void ip_rts_ifmsg(const ipif_t *, uint_t); + +extern void ip_rts_xifmsg(const ipif_t *, uint64_t, uint64_t, uint_t); + +extern void ip_rts_newaddrmsg(int, int, const ipif_t *, uint_t); + +extern int ip_rts_request(queue_t *, mblk_t *, cred_t *); + +extern void ip_rts_register(conn_t *); + +extern void ip_rts_rtmsg(int, ire_t *, int, ip_stack_t *); + +extern void ip_rts_unregister(conn_t *); + +extern mblk_t *rts_alloc_msg(int, int, sa_family_t, uint_t); + +extern size_t rts_data_msg_size(int, sa_family_t, uint_t); + +extern void rts_fill_msg_v6(int, int, const in6_addr_t *, + const in6_addr_t *, const in6_addr_t *, const in6_addr_t *, + const in6_addr_t *, const in6_addr_t *, const in6_addr_t *, + const ill_t *, mblk_t *, const tsol_gc_t *); + +extern size_t rts_header_msg_size(int); + +extern void rts_merge_metrics(iulp_t *, const iulp_t *); + +extern void rts_queue_input(mblk_t *, conn_t *, sa_family_t, uint_t, + ip_stack_t *); + +extern int ip_rts_request_common(mblk_t *mp, conn_t *, cred_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP_RTS_H */ diff --git a/illumos-x86_64/usr/include/inet/ip_stack.h b/illumos-x86_64/usr/include/inet/ip_stack.h new file mode 100644 index 00000000..e45e44ad --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ip_stack.h @@ -0,0 +1,458 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2019 Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _INET_IP_STACK_H +#define _INET_IP_STACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#ifdef _KERNEL +#include + + +/* + * IP statistics. + */ +#define IP_STAT(ipst, x) ((ipst)->ips_ip_statistics.x.value.ui64++) +#define IP_STAT_UPDATE(ipst, x, n) \ + ((ipst)->ips_ip_statistics.x.value.ui64 += (n)) + +typedef struct ip_stat { + kstat_named_t ip_udp_fannorm; + kstat_named_t ip_udp_fanmb; + kstat_named_t ip_recv_pullup; + kstat_named_t ip_db_ref; + kstat_named_t ip_notaligned; + kstat_named_t ip_multimblk; + kstat_named_t ip_opt; + kstat_named_t ipsec_proto_ahesp; + kstat_named_t ip_conn_flputbq; + kstat_named_t ip_conn_walk_drain; + kstat_named_t ip_out_sw_cksum; + kstat_named_t ip_out_sw_cksum_bytes; + kstat_named_t ip_in_sw_cksum; + kstat_named_t ip_ire_reclaim_calls; + kstat_named_t ip_ire_reclaim_deleted; + kstat_named_t ip_nce_reclaim_calls; + kstat_named_t ip_nce_reclaim_deleted; + kstat_named_t ip_nce_mcast_reclaim_calls; + kstat_named_t ip_nce_mcast_reclaim_deleted; + kstat_named_t ip_nce_mcast_reclaim_tqfail; + kstat_named_t ip_dce_reclaim_calls; + kstat_named_t ip_dce_reclaim_deleted; + kstat_named_t ip_tcp_in_full_hw_cksum_err; + kstat_named_t ip_tcp_in_part_hw_cksum_err; + kstat_named_t ip_tcp_in_sw_cksum_err; + kstat_named_t ip_udp_in_full_hw_cksum_err; + kstat_named_t ip_udp_in_part_hw_cksum_err; + kstat_named_t ip_udp_in_sw_cksum_err; + kstat_named_t conn_in_recvdstaddr; + kstat_named_t conn_in_recvopts; + kstat_named_t conn_in_recvif; + kstat_named_t conn_in_recvslla; + kstat_named_t conn_in_recvucred; + kstat_named_t conn_in_recvttl; + kstat_named_t conn_in_recvtos; + kstat_named_t conn_in_recvhopopts; + kstat_named_t conn_in_recvhoplimit; + kstat_named_t conn_in_recvdstopts; + kstat_named_t conn_in_recvrthdrdstopts; + kstat_named_t conn_in_recvrthdr; + kstat_named_t conn_in_recvpktinfo; + kstat_named_t conn_in_recvtclass; + kstat_named_t conn_in_timestamp; +} ip_stat_t; + + +/* + * IP6 statistics. + */ +#define IP6_STAT(ipst, x) ((ipst)->ips_ip6_statistics.x.value.ui64++) +#define IP6_STAT_UPDATE(ipst, x, n) \ + ((ipst)->ips_ip6_statistics.x.value.ui64 += (n)) + +typedef struct ip6_stat { + kstat_named_t ip6_udp_fannorm; + kstat_named_t ip6_udp_fanmb; + kstat_named_t ip6_recv_pullup; + kstat_named_t ip6_db_ref; + kstat_named_t ip6_notaligned; + kstat_named_t ip6_multimblk; + kstat_named_t ipsec_proto_ahesp; + kstat_named_t ip6_out_sw_cksum; + kstat_named_t ip6_out_sw_cksum_bytes; + kstat_named_t ip6_in_sw_cksum; + kstat_named_t ip6_tcp_in_full_hw_cksum_err; + kstat_named_t ip6_tcp_in_part_hw_cksum_err; + kstat_named_t ip6_tcp_in_sw_cksum_err; + kstat_named_t ip6_udp_in_full_hw_cksum_err; + kstat_named_t ip6_udp_in_part_hw_cksum_err; + kstat_named_t ip6_udp_in_sw_cksum_err; +} ip6_stat_t; + +typedef struct ire_stats { + uint64_t ire_stats_alloced; /* # of ires alloced */ + uint64_t ire_stats_freed; /* # of ires freed */ + uint64_t ire_stats_inserted; /* # of ires inserted in the bucket */ + uint64_t ire_stats_deleted; /* # of ires deleted from the bucket */ +} ire_stats_t; + +#define TX_FANOUT_SIZE 128 +#define IDLHASHINDEX(X) \ + ((((uintptr_t)(X) >> 2) + ((uintptr_t)(X) >> 9)) & (TX_FANOUT_SIZE - 1)) + +/* Data structure to represent addresses */ +typedef struct srcid_map { + struct srcid_map *sm_next; + in6_addr_t sm_addr; /* Local address */ + uint_t sm_srcid; /* source id */ + uint_t sm_refcnt; /* > 1 ipif with same addr? */ + zoneid_t sm_zoneid; /* zone id */ +} srcid_map_t; + +/* + * IP stack instances + */ +struct ip_stack { + netstack_t *ips_netstack; /* Common netstack */ + + uint_t ips_src_generation; /* Both IPv4 and IPv6 */ + + struct mod_prop_info_s *ips_propinfo_tbl; /* ip tunables table */ + + mib2_ipIfStatsEntry_t ips_ip_mib; /* SNMP fixed size info */ + mib2_icmp_t ips_icmp_mib; + /* + * IPv6 mibs when the interface (ill) is not known. + * When the ill is known the per-interface mib in the ill is used. + */ + mib2_ipIfStatsEntry_t ips_ip6_mib; + mib2_ipv6IfIcmpEntry_t ips_icmp6_mib; + + struct igmpstat ips_igmpstat; + + kstat_t *ips_ip_mibkp; /* kstat exporting ip_mib data */ + kstat_t *ips_icmp_mibkp; /* kstat exporting icmp_mib data */ + kstat_t *ips_ip_kstat; + ip_stat_t ips_ip_statistics; + kstat_t *ips_ip6_kstat; + ip6_stat_t ips_ip6_statistics; + +/* ip.c */ + kmutex_t ips_igmp_timer_lock; + kmutex_t ips_mld_timer_lock; + kmutex_t ips_ip_mi_lock; + kmutex_t ips_ip_addr_avail_lock; + krwlock_t ips_ill_g_lock; + + krwlock_t ips_ill_g_usesrc_lock; + + /* Taskq dispatcher for capability operations */ + kmutex_t ips_capab_taskq_lock; + kcondvar_t ips_capab_taskq_cv; + mblk_t *ips_capab_taskq_head; + mblk_t *ips_capab_taskq_tail; + kthread_t *ips_capab_taskq_thread; + boolean_t ips_capab_taskq_quit; + +/* ipclassifier.c - keep in ip_stack_t */ + /* ipclassifier hash tables */ + struct connf_s *ips_rts_clients; + struct connf_s *ips_ipcl_conn_fanout; + struct connf_s *ips_ipcl_bind_fanout; + struct connf_s *ips_ipcl_proto_fanout_v4; + struct connf_s *ips_ipcl_proto_fanout_v6; + struct connf_s *ips_ipcl_udp_fanout; + struct connf_s *ips_ipcl_raw_fanout; /* RAW SCTP sockets */ + struct connf_s *ips_ipcl_iptun_fanout; + uint_t ips_ipcl_conn_fanout_size; + uint_t ips_ipcl_bind_fanout_size; + uint_t ips_ipcl_udp_fanout_size; + uint_t ips_ipcl_raw_fanout_size; + uint_t ips_ipcl_iptun_fanout_size; + struct connf_s *ips_ipcl_globalhash_fanout; + int ips_conn_g_index; + +/* ip.c */ + /* Following protected by igmp_timer_lock */ + int ips_igmp_time_to_next; /* Time since last timeout */ + int ips_igmp_timer_scheduled_last; + int ips_igmp_deferred_next; + timeout_id_t ips_igmp_timeout_id; + boolean_t ips_igmp_timer_setter_active; + boolean_t ips_igmp_timer_quiesce; + + /* Following protected by mld_timer_lock */ + int ips_mld_time_to_next; /* Time since last timeout */ + int ips_mld_timer_scheduled_last; + int ips_mld_deferred_next; + timeout_id_t ips_mld_timeout_id; + boolean_t ips_mld_timer_setter_active; + boolean_t ips_mld_timer_quiesce; + + /* Protected by igmp_slowtimeout_lock */ + timeout_id_t ips_igmp_slowtimeout_id; + kmutex_t ips_igmp_slowtimeout_lock; + boolean_t ips_igmp_slowtimeout_quiesce; + + /* Protected by mld_slowtimeout_lock */ + timeout_id_t ips_mld_slowtimeout_id; + kmutex_t ips_mld_slowtimeout_lock; + boolean_t ips_mld_slowtimeout_quiesce; + + /* IPv4 forwarding table */ + struct radix_node_head *ips_ip_ftable; + +#define IPV6_ABITS 128 +#define IP6_MASK_TABLE_SIZE (IPV6_ABITS + 1) /* 129 ptrs */ + struct irb *ips_ip_forwarding_table_v6[IP6_MASK_TABLE_SIZE]; + + /* + * ire_ft_init_lock is used while initializing ip_forwarding_table + * dynamically in ire_add. + */ + kmutex_t ips_ire_ft_init_lock; + + /* + * This is the IPv6 counterpart of RADIX_NODE_HEAD_LOCK. It is used + * to prevent adds and deletes while we are doing a ftable_lookup + * and extracting the ire_generation. + */ + krwlock_t ips_ip6_ire_head_lock; + + uint32_t ips_ip6_ftable_hash_size; + + ire_stats_t ips_ire_stats_v4; /* IPv4 ire statistics */ + ire_stats_t ips_ire_stats_v6; /* IPv6 ire statistics */ + + /* Count how many condemned objects for kmem_cache callbacks */ + uint32_t ips_num_ire_condemned; + uint32_t ips_num_nce_condemned; + uint32_t ips_num_dce_condemned; + + struct ire_s *ips_ire_reject_v4; /* For unreachable dests */ + struct ire_s *ips_ire_reject_v6; /* For unreachable dests */ + struct ire_s *ips_ire_blackhole_v4; /* For temporary failures */ + struct ire_s *ips_ire_blackhole_v6; /* For temporary failures */ + + /* ips_ire_dep_lock protects ire_dep_* relationship between IREs */ + krwlock_t ips_ire_dep_lock; + + /* Destination Cache Entries */ + struct dce_s *ips_dce_default; + uint_t ips_dce_hashsize; + struct dcb_s *ips_dce_hash_v4; + struct dcb_s *ips_dce_hash_v6; + uint_t ips_dce_reclaim_needed; + + /* pending binds */ + mblk_t *ips_ip6_asp_pending_ops; + mblk_t *ips_ip6_asp_pending_ops_tail; + + /* Synchronize updates with table usage */ + mblk_t *ips_ip6_asp_pending_update; /* pending table updates */ + + boolean_t ips_ip6_asp_uip; /* table update in progress */ + kmutex_t ips_ip6_asp_lock; /* protect all the above */ + uint32_t ips_ip6_asp_refcnt; /* outstanding references */ + + struct ip6_asp *ips_ip6_asp_table; + /* The number of policy entries in the table */ + uint_t ips_ip6_asp_table_count; + + struct conn_s *ips_ip_g_mrouter; + + /* Time since last icmp_pkt_err */ + clock_t ips_icmp_pkt_err_last; + /* Number of packets sent in burst */ + uint_t ips_icmp_pkt_err_sent; + + /* Protected by ip_mi_lock */ + void *ips_ip_g_head; /* IP Instance Data List Head */ + void *ips_arp_g_head; /* ARP Instance Data List Head */ + + /* Multirouting stuff */ + /* Interval (in ms) between consecutive 'bad MTU' warnings */ + hrtime_t ips_ip_multirt_log_interval; + /* Time since last warning issued. */ + hrtime_t ips_multirt_bad_mtu_last_time; + + /* + * CGTP hooks. Enabling and disabling of hooks is controlled by an + * IP tunable 'ips_ip_cgtp_filter'. + */ + struct cgtp_filter_ops *ips_ip_cgtp_filter_ops; + + struct ipsq_s *ips_ipsq_g_head; + uint_t ips_ill_index; /* Used to assign interface indicies */ + /* When set search for unused index */ + boolean_t ips_ill_index_wrap; + + uint_t ips_loopback_packets; + + /* NDP/NCE structures for IPv4 and IPv6 */ + struct ndp_g_s *ips_ndp4; + struct ndp_g_s *ips_ndp6; + + /* ip_mroute stuff */ + kmutex_t ips_ip_g_mrouter_mutex; + + struct mrtstat *ips_mrtstat; /* Stats for netstat */ + int ips_saved_ip_forwarding; + + /* numvifs is only a hint about the max interface being used. */ + ushort_t ips_numvifs; + kmutex_t ips_numvifs_mutex; + + struct vif *ips_vifs; + struct mfcb *ips_mfcs; /* kernel routing table */ + struct tbf *ips_tbfs; + /* + * One-back cache used to locate a tunnel's vif, + * given a datagram's src ip address. + */ + ipaddr_t ips_last_encap_src; + struct vif *ips_last_encap_vif; + kmutex_t ips_last_encap_lock; /* Protects the above */ + + /* + * reg_vif_num is protected by numvifs_mutex + */ + /* Whether or not special PIM assert processing is enabled. */ + ushort_t ips_reg_vif_num; /* Index to Register vif */ + int ips_pim_assert; + + union ill_g_head_u *ips_ill_g_heads; /* ILL List Head */ + + kstat_t *ips_loopback_ksp; + + /* Array of conn drain lists */ + struct idl_tx_list_s *ips_idl_tx_list; + uint_t ips_conn_drain_list_cnt; /* Count of conn_drain_list */ + + /* + * ID used to assign next free one. + * Increases by one. Once it wraps we search for an unused ID. + */ + uint_t ips_ip_src_id; + boolean_t ips_srcid_wrapped; + + struct srcid_map *ips_srcid_head; + krwlock_t ips_srcid_lock; + + uint64_t ips_ipif_g_seqid; /* Used only for sctp_addr.c */ + union phyint_list_u *ips_phyint_g_list; /* start of phyint list */ + +/* ip_netinfo.c */ + hook_family_t ips_ipv4root; + hook_family_t ips_ipv6root; + hook_family_t ips_arproot; + + net_handle_t ips_ipv4_net_data; + net_handle_t ips_ipv6_net_data; + net_handle_t ips_arp_net_data; + + /* + * Hooks for firewalling + */ + hook_event_t ips_ip4_physical_in_event; + hook_event_t ips_ip4_physical_out_event; + hook_event_t ips_ip4_forwarding_event; + hook_event_t ips_ip4_loopback_in_event; + hook_event_t ips_ip4_loopback_out_event; + + hook_event_t ips_ip6_physical_in_event; + hook_event_t ips_ip6_physical_out_event; + hook_event_t ips_ip6_forwarding_event; + hook_event_t ips_ip6_loopback_in_event; + hook_event_t ips_ip6_loopback_out_event; + + hook_event_t ips_arp_physical_in_event; + hook_event_t ips_arp_physical_out_event; + hook_event_t ips_arp_nic_events; + + hook_event_token_t ips_ipv4firewall_physical_in; + hook_event_token_t ips_ipv4firewall_physical_out; + hook_event_token_t ips_ipv4firewall_forwarding; + hook_event_token_t ips_ipv4firewall_loopback_in; + hook_event_token_t ips_ipv4firewall_loopback_out; + + hook_event_token_t ips_ipv6firewall_physical_in; + hook_event_token_t ips_ipv6firewall_physical_out; + hook_event_token_t ips_ipv6firewall_forwarding; + hook_event_token_t ips_ipv6firewall_loopback_in; + hook_event_token_t ips_ipv6firewall_loopback_out; + + hook_event_t ips_ip4_nic_events; + hook_event_t ips_ip6_nic_events; + hook_event_token_t ips_ipv4nicevents; + hook_event_token_t ips_ipv6nicevents; + + hook_event_token_t ips_arp_physical_in; + hook_event_token_t ips_arp_physical_out; + hook_event_token_t ips_arpnicevents; + + net_handle_t ips_ip4_observe_pr; + net_handle_t ips_ip6_observe_pr; + hook_event_t ips_ip4_observe; + hook_event_t ips_ip6_observe; + hook_event_token_t ips_ipv4observing; + hook_event_token_t ips_ipv6observing; + + struct __ldi_ident *ips_ldi_ident; + +/* ipmp.c */ + krwlock_t ips_ipmp_lock; + mod_hash_t *ips_ipmp_grp_hash; + +}; +typedef struct ip_stack ip_stack_t; + +/* Finding an ip_stack_t */ +#define CONNQ_TO_IPST(_q) (Q_TO_CONN(_q)->conn_netstack->netstack_ip) +#define ILLQ_TO_IPST(_q) (((ill_t *)(_q)->q_ptr)->ill_ipst) +#define PHYINT_TO_IPST(phyi) ((phyi)->phyint_ipsq->ipsq_ipst) + +#else /* _KERNEL */ +typedef int ip_stack_t; +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IP_STACK_H */ diff --git a/illumos-x86_64/usr/include/inet/ipclassifier.h b/illumos-x86_64/usr/include/inet/ipclassifier.h new file mode 100644 index 00000000..2fc1012c --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ipclassifier.h @@ -0,0 +1,752 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. + */ + +/* + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +/* + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _INET_IPCLASSIFIER_H +#define _INET_IPCLASSIFIER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include /* for IPPROTO_* constants */ +#include +#include +#include +#include + +typedef void (*edesc_rpf)(void *, mblk_t *, void *, ip_recv_attr_t *); +struct icmph_s; +struct icmp6_hdr; +typedef boolean_t (*edesc_vpf)(conn_t *, void *, struct icmph_s *, + struct icmp6_hdr *, ip_recv_attr_t *); + +/* + * ============================== + * = The CONNECTION = + * ============================== + */ + +/* + * The connection structure contains the common information/flags/ref needed. + * Implementation will keep the connection struct, the layers (with their + * respective data for event i.e. tcp_t if event was tcp_input_data) all in one + * contiguous memory location. + */ + +/* Conn Flags */ +/* Unused 0x00020000 */ +/* Unused 0x00040000 */ +#define IPCL_FULLY_BOUND 0x00080000 /* Bound to correct squeue */ +/* Unused 0x00100000 */ +/* Unused 0x00200000 */ +/* Unused 0x00400000 */ +#define IPCL_CL_LISTENER 0x00800000 /* Cluster listener */ +/* Unused 0x01000000 */ +/* Unused 0x02000000 */ +/* Unused 0x04000000 */ +/* Unused 0x08000000 */ +/* Unused 0x10000000 */ +/* Unused 0x20000000 */ +#define IPCL_CONNECTED 0x40000000 /* Conn in connected table */ +#define IPCL_BOUND 0x80000000 /* Conn in bind table */ + +/* Flags identifying the type of conn */ +#define IPCL_TCPCONN 0x00000001 /* From tcp_conn_cache */ +#define IPCL_SCTPCONN 0x00000002 /* From sctp_conn_cache */ +#define IPCL_IPCCONN 0x00000004 /* From ip_conn_cache */ +#define IPCL_UDPCONN 0x00000008 /* From udp_conn_cache */ +#define IPCL_RAWIPCONN 0x00000010 /* From rawip_conn_cache */ +#define IPCL_RTSCONN 0x00000020 /* From rts_conn_cache */ +/* Unused 0x00000040 */ +#define IPCL_IPTUN 0x00000080 /* iptun module above us */ + +#define IPCL_NONSTR 0x00001000 /* A non-STREAMS socket */ +/* Unused 0x10000000 */ + +#define IPCL_REMOVED 0x00000100 +#define IPCL_REUSED 0x00000200 + +#define IPCL_IS_CONNECTED(connp) \ + ((connp)->conn_flags & IPCL_CONNECTED) + +#define IPCL_IS_BOUND(connp) \ + ((connp)->conn_flags & IPCL_BOUND) + +/* + * Can't use conn_proto since we need to tell difference + * between a real TCP socket and a SOCK_RAW, IPPROTO_TCP. + */ +#define IPCL_IS_TCP(connp) \ + ((connp)->conn_flags & IPCL_TCPCONN) + +#define IPCL_IS_SCTP(connp) \ + ((connp)->conn_flags & IPCL_SCTPCONN) + +#define IPCL_IS_UDP(connp) \ + ((connp)->conn_flags & IPCL_UDPCONN) + +#define IPCL_IS_RAWIP(connp) \ + ((connp)->conn_flags & IPCL_RAWIPCONN) + +#define IPCL_IS_RTS(connp) \ + ((connp)->conn_flags & IPCL_RTSCONN) + +#define IPCL_IS_IPTUN(connp) \ + ((connp)->conn_flags & IPCL_IPTUN) + +#define IPCL_IS_NONSTR(connp) ((connp)->conn_flags & IPCL_NONSTR) + +typedef struct connf_s connf_t; + +typedef struct +{ + int ctb_depth; +#define CONN_STACK_DEPTH 15 + pc_t ctb_stack[CONN_STACK_DEPTH]; +} conn_trace_t; + +typedef struct ip_helper_minor_info_s { + dev_t ip_minfo_dev; /* Device */ + vmem_t *ip_minfo_arena; /* Arena */ +} ip_helper_minfo_t; + +/* + * ip helper stream info + */ +typedef struct ip_helper_stream_info_s { + ldi_handle_t iphs_handle; + queue_t *iphs_rq; + queue_t *iphs_wq; + ip_helper_minfo_t *iphs_minfo; +} ip_helper_stream_info_t; + +/* + * Mandatory Access Control mode, in conn_t's conn_mac_mode field. + * CONN_MAC_DEFAULT: strict enforcement of MAC. + * CONN_MAC_AWARE: allows communications between unlabeled systems + * and privileged daemons + * CONN_MAC_IMPLICIT: allows communications without explicit labels + * on the wire with privileged daemons. + * + * CONN_MAC_IMPLICIT is intended specifically for labeled IPsec key management + * in networks which don't pass CIPSO-labeled packets. + */ +#define CONN_MAC_DEFAULT 0 +#define CONN_MAC_AWARE 1 +#define CONN_MAC_IMPLICIT 2 + +/* + * conn receive ancillary definition. + * + * These are the set of socket options that make the receive side + * potentially pass up ancillary data items. + * We have a union with an integer so that we can quickly check whether + * any ancillary data items need to be added. + */ +typedef struct crb_s { + union { + uint32_t crbu_all; + struct { + uint32_t + crbb_recvdstaddr : 1, /* IP_RECVDSTADDR option */ + crbb_recvopts : 1, /* IP_RECVOPTS option */ + crbb_recvif : 1, /* IP_RECVIF option */ + crbb_recvslla : 1, /* IP_RECVSLLA option */ + + crbb_recvttl : 1, /* IP_RECVTTL option */ + crbb_recvtos : 1, /* IP_RECVTOS option */ + crbb_ip_recvpktinfo : 1, /* IP*_RECVPKTINFO option */ + crbb_ipv6_recvhoplimit : 1, /* IPV6_RECVHOPLIMIT option */ + crbb_ipv6_recvhopopts : 1, /* IPV6_RECVHOPOPTS option */ + + crbb_ipv6_recvdstopts : 1, /* IPV6_RECVDSTOPTS option */ + crbb_ipv6_recvrthdr : 1, /* IPV6_RECVRTHDR option */ + crbb_old_ipv6_recvdstopts : 1, /* old form of IPV6_DSTOPTS */ + crbb_ipv6_recvrthdrdstopts : 1, /* IPV6_RECVRTHDRDSTOPTS */ + + crbb_ipv6_recvtclass : 1, /* IPV6_RECVTCLASS */ + crbb_recvucred : 1, /* IP_RECVUCRED option */ + crbb_timestamp : 1; /* SO_TIMESTAMP "socket" option */ + + } crbb; + } crbu; +} crb_t; + +#define crb_all crbu.crbu_all +#define crb_recvdstaddr crbu.crbb.crbb_recvdstaddr +#define crb_recvopts crbu.crbb.crbb_recvopts +#define crb_recvif crbu.crbb.crbb_recvif +#define crb_recvslla crbu.crbb.crbb_recvslla +#define crb_recvttl crbu.crbb.crbb_recvttl +#define crb_recvtos crbu.crbb.crbb_recvtos +#define crb_ip_recvpktinfo crbu.crbb.crbb_ip_recvpktinfo +#define crb_ipv6_recvhoplimit crbu.crbb.crbb_ipv6_recvhoplimit +#define crb_ipv6_recvhopopts crbu.crbb.crbb_ipv6_recvhopopts +#define crb_ipv6_recvdstopts crbu.crbb.crbb_ipv6_recvdstopts +#define crb_ipv6_recvrthdr crbu.crbb.crbb_ipv6_recvrthdr +#define crb_old_ipv6_recvdstopts crbu.crbb.crbb_old_ipv6_recvdstopts +#define crb_ipv6_recvrthdrdstopts crbu.crbb.crbb_ipv6_recvrthdrdstopts +#define crb_ipv6_recvtclass crbu.crbb.crbb_ipv6_recvtclass +#define crb_recvucred crbu.crbb.crbb_recvucred +#define crb_timestamp crbu.crbb.crbb_timestamp + +/* + * The initial fields in the conn_t are setup by the kmem_cache constructor, + * and are preserved when it is freed. Fields after that are bzero'ed when + * the conn_t is freed. + * + * Much of the conn_t is protected by conn_lock. + * + * conn_lock is also used by some ULPs (like UDP and RAWIP) to protect + * their state. + */ +struct conn_s { + kmutex_t conn_lock; + uint32_t conn_ref; /* Reference counter */ + uint32_t conn_flags; /* Conn Flags */ + + union { + tcp_t *cp_tcp; /* Pointer to the tcp struct */ + struct udp_s *cp_udp; /* Pointer to the udp struct */ + struct icmp_s *cp_icmp; /* Pointer to rawip struct */ + struct rts_s *cp_rts; /* Pointer to rts struct */ + struct iptun_s *cp_iptun; /* Pointer to iptun_t */ + struct sctp_s *cp_sctp; /* For IPCL_SCTPCONN */ + void *cp_priv; + } conn_proto_priv; +#define conn_tcp conn_proto_priv.cp_tcp +#define conn_udp conn_proto_priv.cp_udp +#define conn_icmp conn_proto_priv.cp_icmp +#define conn_rts conn_proto_priv.cp_rts +#define conn_iptun conn_proto_priv.cp_iptun +#define conn_sctp conn_proto_priv.cp_sctp +#define conn_priv conn_proto_priv.cp_priv + + kcondvar_t conn_cv; + uint8_t conn_proto; /* protocol type */ + + edesc_rpf conn_recv; /* Pointer to recv routine */ + edesc_rpf conn_recvicmp; /* For ICMP error */ + edesc_vpf conn_verifyicmp; /* Verify ICMP error */ + + ip_xmit_attr_t *conn_ixa; /* Options if no ancil data */ + + /* Fields after this are bzero'ed when the conn_t is freed. */ +#define conn_start_clr conn_recv_ancillary + + /* Options for receive-side ancillary data */ + crb_t conn_recv_ancillary; + + squeue_t *conn_sqp; /* Squeue for processing */ + uint_t conn_state_flags; /* IP state flags */ + + int conn_lingertime; /* linger time (in seconds) */ + + unsigned int + conn_on_sqp : 1, /* Conn is being processed */ + conn_linger : 1, /* SO_LINGER state */ + conn_useloopback : 1, /* SO_USELOOPBACK state */ + conn_broadcast : 1, /* SO_BROADCAST state */ + + conn_reuseaddr : 1, /* SO_REUSEADDR state */ + conn_keepalive : 1, /* SO_KEEPALIVE state */ + conn_multi_router : 1, /* Wants all multicast pkts */ + conn_unspec_src : 1, /* IP_UNSPEC_SRC */ + + conn_policy_cached : 1, /* Is policy cached/latched ? */ + conn_in_enforce_policy : 1, /* Enforce Policy on inbound */ + conn_out_enforce_policy : 1, /* Enforce Policy on outbound */ + conn_debug : 1, /* SO_DEBUG */ + + conn_ipv6_v6only : 1, /* IPV6_V6ONLY */ + conn_oobinline : 1, /* SO_OOBINLINE state */ + conn_dgram_errind : 1, /* SO_DGRAM_ERRIND state */ + conn_exclbind : 1, /* SO_EXCLBIND state */ + + conn_mdt_ok : 1, /* MDT is permitted */ + conn_allzones : 1, /* SO_ALLZONES */ + conn_ipv6_recvpathmtu : 1, /* IPV6_RECVPATHMTU */ + conn_mcbc_bind : 1, /* Bound to multi/broadcast */ + + conn_reuseport : 1, /* SO_REUSEPORT state */ + conn_pad_to_bit_31 : 11; + + boolean_t conn_blocked; /* conn is flow-controlled */ + + squeue_t *conn_initial_sqp; /* Squeue at open time */ + squeue_t *conn_final_sqp; /* Squeue after connect */ + ill_t *conn_dhcpinit_ill; /* IP_DHCPINIT_IF */ + ipsec_latch_t *conn_latch; /* latched IDS */ + struct ipsec_policy_s *conn_latch_in_policy; /* latched policy (in) */ + struct ipsec_action_s *conn_latch_in_action; /* latched action (in) */ + uint_t conn_bound_if; /* IP*_BOUND_IF */ + queue_t *conn_rq; /* Read queue */ + queue_t *conn_wq; /* Write queue */ + dev_t conn_dev; /* Minor number */ + vmem_t *conn_minor_arena; /* Minor arena */ + ip_helper_stream_info_t *conn_helper_info; + + cred_t *conn_cred; /* Credentials */ + pid_t conn_cpid; /* pid from open/connect */ + uint64_t conn_open_time; /* time when this was opened */ + + connf_t *conn_g_fanout; /* Global Hash bucket head */ + struct conn_s *conn_g_next; /* Global Hash chain next */ + struct conn_s *conn_g_prev; /* Global Hash chain prev */ + struct ipsec_policy_head_s *conn_policy; /* Configured policy */ + in6_addr_t conn_bound_addr_v6; /* Address in bind() */ +#define conn_bound_addr_v4 V4_PART_OF_V6(conn_bound_addr_v6) + connf_t *conn_fanout; /* Hash bucket we're part of */ + struct conn_s *conn_next; /* Hash chain next */ + struct conn_s *conn_prev; /* Hash chain prev */ + + struct { + in6_addr_t connua_laddr; /* Local address - match */ + in6_addr_t connua_faddr; /* Remote address */ + } connua_v6addr; +#define conn_laddr_v4 V4_PART_OF_V6(connua_v6addr.connua_laddr) +#define conn_faddr_v4 V4_PART_OF_V6(connua_v6addr.connua_faddr) +#define conn_laddr_v6 connua_v6addr.connua_laddr +#define conn_faddr_v6 connua_v6addr.connua_faddr + in6_addr_t conn_saddr_v6; /* Local address - source */ +#define conn_saddr_v4 V4_PART_OF_V6(conn_saddr_v6) + + union { + /* Used for classifier match performance */ + uint32_t connu_ports2; + struct { + in_port_t connu_fport; /* Remote port */ + in_port_t connu_lport; /* Local port */ + } connu_ports; + } u_port; +#define conn_fport u_port.connu_ports.connu_fport +#define conn_lport u_port.connu_ports.connu_lport +#define conn_ports u_port.connu_ports2 + + uint_t conn_incoming_ifindex; /* IP{,V6}_BOUND_IF, scopeid */ + ill_t *conn_oper_pending_ill; /* pending shared ioctl */ + + krwlock_t conn_ilg_lock; /* Protects conn_ilg_* */ + ilg_t *conn_ilg; /* Group memberships */ + + kcondvar_t conn_refcv; /* For conn_oper_pending_ill */ + + struct conn_s *conn_drain_next; /* Next conn in drain list */ + struct conn_s *conn_drain_prev; /* Prev conn in drain list */ + idl_t *conn_idl; /* Ptr to the drain list head */ + mblk_t *conn_ipsec_opt_mp; /* ipsec option mblk */ + zoneid_t conn_zoneid; /* zone connection is in */ + int conn_rtaware; /* RT_AWARE sockopt value */ + kcondvar_t conn_sq_cv; /* For non-STREAMS socket IO */ + sock_upcalls_t *conn_upcalls; /* Upcalls to sockfs */ + sock_upper_handle_t conn_upper_handle; /* Upper handle: sonode * */ + + unsigned int + conn_mlp_type : 2, /* mlp_type_t; tsol/tndb.h */ + conn_anon_mlp : 1, /* user wants anon MLP */ + conn_anon_port : 1, /* user bound anonymously */ + + conn_mac_mode : 2, /* normal/loose/implicit MAC */ + conn_anon_priv_bind : 1, /* *_ANON_PRIV_BIND state */ + conn_zone_is_global : 1, /* GLOBAL_ZONEID */ + conn_isvrrp : 1, /* VRRP control socket */ + conn_spare : 23; + + boolean_t conn_flow_cntrld; + netstack_t *conn_netstack; /* Corresponds to a netstack_hold */ + + /* + * IP format that packets received for this struct should use. + * Value can be IP4_VERSION or IPV6_VERSION. + * The sending version is encoded using IXAF_IS_IPV4. + */ + ushort_t conn_ipversion; + + /* Written to only once at the time of opening the endpoint */ + sa_family_t conn_family; /* Family from socket() call */ + uint_t conn_so_type; /* Type from socket() call */ + + uint_t conn_sndbuf; /* SO_SNDBUF state */ + uint_t conn_rcvbuf; /* SO_RCVBUF state */ + uint_t conn_wroff; /* Current write offset */ + + uint_t conn_sndlowat; /* Send buffer low water mark */ + uint_t conn_rcvlowat; /* Recv buffer low water mark */ + + uint8_t conn_default_ttl; /* Default TTL/hoplimit */ + uint8_t conn_min_ttl; /* IP_MINTTL+IPV6_MINHOPLIMIT */ + + uint32_t conn_flowinfo; /* Connected flow id and tclass */ + + /* + * The most recent address for sendto. Initially set to zero + * which is always different than then the destination address + * since the send interprets zero as the loopback address. + */ + in6_addr_t conn_v6lastdst; +#define conn_v4lastdst V4_PART_OF_V6(conn_v6lastdst) + ushort_t conn_lastipversion; + in_port_t conn_lastdstport; + uint32_t conn_lastflowinfo; /* IPv6-only */ + uint_t conn_lastscopeid; /* IPv6-only */ + uint_t conn_lastsrcid; /* Only for AF_INET6 */ + /* + * When we are not connected conn_saddr might be unspecified. + * We track the source that was used with conn_v6lastdst here. + */ + in6_addr_t conn_v6lastsrc; +#define conn_v4lastsrc V4_PART_OF_V6(conn_v6lastsrc) + + /* Templates for transmitting packets */ + ip_pkt_t conn_xmit_ipp; /* Options if no ancil data */ + + /* + * Header template - conn_ht_ulp is a pointer into conn_ht_iphc. + * Note that ixa_ip_hdr_length indicates the offset of ht_ulp in + * ht_iphc + * + * The header template is maintained for connected endpoints (and + * updated when sticky options are changed) and also for the lastdst. + * There is no conflict between those usages since SOCK_DGRAM and + * SOCK_RAW can not be used to specify a destination address (with + * sendto/sendmsg) if the socket has been connected. + */ + uint8_t *conn_ht_iphc; /* Start of IP header */ + uint_t conn_ht_iphc_allocated; /* Allocated buffer size */ + uint_t conn_ht_iphc_len; /* IP+ULP size */ + uint8_t *conn_ht_ulp; /* Upper-layer header */ + uint_t conn_ht_ulp_len; /* ULP header len */ + + /* Checksum to compensate for source routed packets. Host byte order */ + uint32_t conn_sum; + + uint32_t conn_ioctlref; /* ioctl ref count */ +#ifdef CONN_DEBUG +#define CONN_TRACE_MAX 10 + int conn_trace_last; /* ndx of last used tracebuf */ + conn_trace_t conn_trace_buf[CONN_TRACE_MAX]; +#endif +}; + +/* + * connf_t - connection fanout data. + * + * The hash tables and their linkage (conn_t.{hashnextp, hashprevp} are + * protected by the per-bucket lock. Each conn_t inserted in the list + * points back at the connf_t that heads the bucket. + */ +struct connf_s { + struct conn_s *connf_head; + kmutex_t connf_lock; +}; + +#define CONN_INC_REF(connp) { \ + mutex_enter(&(connp)->conn_lock); \ + DTRACE_PROBE1(conn__inc__ref, conn_t *, connp); \ + ASSERT(conn_trace_ref(connp)); \ + (connp)->conn_ref++; \ + ASSERT((connp)->conn_ref != 0); \ + mutex_exit(&(connp)->conn_lock); \ +} + +#define CONN_INC_REF_LOCKED(connp) { \ + DTRACE_PROBE1(conn__inc__ref, conn_t *, connp); \ + ASSERT(MUTEX_HELD(&(connp)->conn_lock)); \ + ASSERT(conn_trace_ref(connp)); \ + (connp)->conn_ref++; \ + ASSERT((connp)->conn_ref != 0); \ +} + +#define CONN_DEC_REF(connp) { \ + mutex_enter(&(connp)->conn_lock); \ + DTRACE_PROBE1(conn__dec__ref, conn_t *, connp); \ + /* \ + * The squeue framework always does a CONN_DEC_REF after return \ + * from TCP. Hence the refcnt must be at least 2 if conn_on_sqp \ + * is B_TRUE and conn_ref is being decremented. This is to \ + * account for the mblk being currently processed. \ + */ \ + if ((connp)->conn_ref == 0 || \ + ((connp)->conn_ref == 1 && (connp)->conn_on_sqp)) \ + cmn_err(CE_PANIC, "CONN_DEC_REF: connp(%p) has ref " \ + "= %d\n", (void *)(connp), (connp)->conn_ref); \ + ASSERT(conn_untrace_ref(connp)); \ + (connp)->conn_ref--; \ + if ((connp)->conn_ref == 0) { \ + /* Refcnt can't increase again, safe to drop lock */ \ + mutex_exit(&(connp)->conn_lock); \ + ipcl_conn_destroy(connp); \ + } else { \ + cv_broadcast(&(connp)->conn_cv); \ + mutex_exit(&(connp)->conn_lock); \ + } \ +} + +/* + * For use with subsystems within ip which use ALL_ZONES as a wildcard + */ +#define IPCL_ZONEID(connp) \ + ((connp)->conn_allzones ? ALL_ZONES : (connp)->conn_zoneid) + +/* + * For matching between a conn_t and a zoneid. + */ +#define IPCL_ZONE_MATCH(connp, zoneid) \ + (((connp)->conn_allzones) || \ + ((zoneid) == ALL_ZONES) || \ + (connp)->conn_zoneid == (zoneid)) + +/* + * On a labeled system, we must treat bindings to ports + * on shared IP addresses by sockets with MAC exemption + * privilege as being in all zones, as there's + * otherwise no way to identify the right receiver. + */ + +#define IPCL_CONNS_MAC(conn1, conn2) \ + (((conn1)->conn_mac_mode != CONN_MAC_DEFAULT) || \ + ((conn2)->conn_mac_mode != CONN_MAC_DEFAULT)) + +#define IPCL_BIND_ZONE_MATCH(conn1, conn2) \ + (IPCL_CONNS_MAC(conn1, conn2) || \ + IPCL_ZONE_MATCH(conn1, conn2->conn_zoneid) || \ + IPCL_ZONE_MATCH(conn2, conn1->conn_zoneid)) + + +#define _IPCL_V4_MATCH(v6addr, v4addr) \ + (V4_PART_OF_V6((v6addr)) == (v4addr) && IN6_IS_ADDR_V4MAPPED(&(v6addr))) + +#define _IPCL_V4_MATCH_ANY(addr) \ + (IN6_IS_ADDR_V4MAPPED_ANY(&(addr)) || IN6_IS_ADDR_UNSPECIFIED(&(addr))) + + +/* + * IPCL_PROTO_MATCH() and IPCL_PROTO_MATCH_V6() only matches conns with + * the specified ira_zoneid or conn_allzones by calling conn_wantpacket. + */ +#define IPCL_PROTO_MATCH(connp, ira, ipha) \ + ((((connp)->conn_laddr_v4 == INADDR_ANY) || \ + (((connp)->conn_laddr_v4 == ((ipha)->ipha_dst)) && \ + (((connp)->conn_faddr_v4 == INADDR_ANY) || \ + ((connp)->conn_faddr_v4 == ((ipha)->ipha_src))))) && \ + conn_wantpacket((connp), (ira), (ipha))) + +#define IPCL_PROTO_MATCH_V6(connp, ira, ip6h) \ + ((IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_laddr_v6) || \ + (IN6_ARE_ADDR_EQUAL(&(connp)->conn_laddr_v6, &((ip6h)->ip6_dst)) && \ + (IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_faddr_v6) || \ + IN6_ARE_ADDR_EQUAL(&(connp)->conn_faddr_v6, &((ip6h)->ip6_src))))) && \ + (conn_wantpacket_v6((connp), (ira), (ip6h)))) + +#define IPCL_CONN_HASH(src, ports, ipst) \ + ((unsigned)(ntohl((src)) ^ ((ports) >> 24) ^ ((ports) >> 16) ^ \ + ((ports) >> 8) ^ (ports)) % (ipst)->ips_ipcl_conn_fanout_size) + +#define IPCL_CONN_HASH_V6(src, ports, ipst) \ + IPCL_CONN_HASH(V4_PART_OF_V6((src)), (ports), (ipst)) + +#define IPCL_CONN_MATCH(connp, proto, src, dst, ports) \ + ((connp)->conn_proto == (proto) && \ + (connp)->conn_ports == (ports) && \ + _IPCL_V4_MATCH((connp)->conn_faddr_v6, (src)) && \ + _IPCL_V4_MATCH((connp)->conn_laddr_v6, (dst)) && \ + !(connp)->conn_ipv6_v6only) + +#define IPCL_CONN_MATCH_V6(connp, proto, src, dst, ports) \ + ((connp)->conn_proto == (proto) && \ + (connp)->conn_ports == (ports) && \ + IN6_ARE_ADDR_EQUAL(&(connp)->conn_faddr_v6, &(src)) && \ + IN6_ARE_ADDR_EQUAL(&(connp)->conn_laddr_v6, &(dst))) + +#define IPCL_PORT_HASH(port, size) \ + ((((port) >> 8) ^ (port)) & ((size) - 1)) + +#define IPCL_BIND_HASH(lport, ipst) \ + ((unsigned)(((lport) >> 8) ^ (lport)) % \ + (ipst)->ips_ipcl_bind_fanout_size) + +#define IPCL_BIND_MATCH(connp, proto, laddr, lport) \ + ((connp)->conn_proto == (proto) && \ + (connp)->conn_lport == (lport) && \ + (_IPCL_V4_MATCH_ANY((connp)->conn_laddr_v6) || \ + _IPCL_V4_MATCH((connp)->conn_laddr_v6, (laddr))) && \ + !(connp)->conn_ipv6_v6only) + +#define IPCL_BIND_MATCH_V6(connp, proto, laddr, lport) \ + ((connp)->conn_proto == (proto) && \ + (connp)->conn_lport == (lport) && \ + (IN6_ARE_ADDR_EQUAL(&(connp)->conn_laddr_v6, &(laddr)) || \ + IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_laddr_v6))) + +/* + * We compare conn_laddr since it captures both connected and a bind to + * a multicast or broadcast address. + * The caller needs to match the zoneid and also call conn_wantpacket + * for multicast, broadcast, or when conn_incoming_ifindex is set. + */ +#define IPCL_UDP_MATCH(connp, lport, laddr, fport, faddr) \ + (((connp)->conn_lport == (lport)) && \ + ((_IPCL_V4_MATCH_ANY((connp)->conn_laddr_v6) || \ + (_IPCL_V4_MATCH((connp)->conn_laddr_v6, (laddr)) && \ + (_IPCL_V4_MATCH_ANY((connp)->conn_faddr_v6) || \ + (_IPCL_V4_MATCH((connp)->conn_faddr_v6, (faddr)) && \ + (connp)->conn_fport == (fport)))))) && \ + !(connp)->conn_ipv6_v6only) + +/* + * We compare conn_laddr since it captures both connected and a bind to + * a multicast or broadcast address. + * The caller needs to match the zoneid and also call conn_wantpacket_v6 + * for multicast or when conn_incoming_ifindex is set. + */ +#define IPCL_UDP_MATCH_V6(connp, lport, laddr, fport, faddr) \ + (((connp)->conn_lport == (lport)) && \ + (IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_laddr_v6) || \ + (IN6_ARE_ADDR_EQUAL(&(connp)->conn_laddr_v6, &(laddr)) && \ + (IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_faddr_v6) || \ + (IN6_ARE_ADDR_EQUAL(&(connp)->conn_faddr_v6, &(faddr)) && \ + (connp)->conn_fport == (fport)))))) + +#define IPCL_IPTUN_HASH(laddr, faddr) \ + ((ntohl(laddr) ^ ((ntohl(faddr) << 24) | (ntohl(faddr) >> 8))) % \ + ipcl_iptun_fanout_size) + +#define IPCL_IPTUN_HASH_V6(laddr, faddr) \ + IPCL_IPTUN_HASH((laddr)->s6_addr32[0] ^ (laddr)->s6_addr32[1] ^ \ + (faddr)->s6_addr32[2] ^ (faddr)->s6_addr32[3], \ + (faddr)->s6_addr32[0] ^ (faddr)->s6_addr32[1] ^ \ + (laddr)->s6_addr32[2] ^ (laddr)->s6_addr32[3]) + +#define IPCL_IPTUN_MATCH(connp, laddr, faddr) \ + (_IPCL_V4_MATCH((connp)->conn_laddr_v6, (laddr)) && \ + _IPCL_V4_MATCH((connp)->conn_faddr_v6, (faddr))) + +#define IPCL_IPTUN_MATCH_V6(connp, laddr, faddr) \ + (IN6_ARE_ADDR_EQUAL(&(connp)->conn_laddr_v6, (laddr)) && \ + IN6_ARE_ADDR_EQUAL(&(connp)->conn_faddr_v6, (faddr))) + +#define IPCL_UDP_HASH(lport, ipst) \ + IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_udp_fanout_size) + +#define CONN_G_HASH_SIZE 1024 + +/* Raw socket hash function. */ +#define IPCL_RAW_HASH(lport, ipst) \ + IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_raw_fanout_size) + +/* + * This is similar to IPCL_BIND_MATCH except that the local port check + * is changed to a wildcard port check. + * We compare conn_laddr since it captures both connected and a bind to + * a multicast or broadcast address. + */ +#define IPCL_RAW_MATCH(connp, proto, laddr) \ + ((connp)->conn_proto == (proto) && \ + (connp)->conn_lport == 0 && \ + (_IPCL_V4_MATCH_ANY((connp)->conn_laddr_v6) || \ + _IPCL_V4_MATCH((connp)->conn_laddr_v6, (laddr)))) + +#define IPCL_RAW_MATCH_V6(connp, proto, laddr) \ + ((connp)->conn_proto == (proto) && \ + (connp)->conn_lport == 0 && \ + (IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_laddr_v6) || \ + IN6_ARE_ADDR_EQUAL(&(connp)->conn_laddr_v6, &(laddr)))) + +/* Function prototypes */ +extern void ipcl_g_init(void); +extern void ipcl_init(ip_stack_t *); +extern void ipcl_g_destroy(void); +extern void ipcl_destroy(ip_stack_t *); +extern conn_t *ipcl_conn_create(uint32_t, int, netstack_t *); +extern void ipcl_conn_destroy(conn_t *); + +void ipcl_hash_insert_wildcard(connf_t *, conn_t *); +void ipcl_hash_remove(conn_t *); +void ipcl_hash_remove_locked(conn_t *connp, connf_t *connfp); + +extern int ipcl_bind_insert(conn_t *); +extern int ipcl_bind_insert_v4(conn_t *); +extern int ipcl_bind_insert_v6(conn_t *); +extern int ipcl_conn_insert(conn_t *); +extern int ipcl_conn_insert_v4(conn_t *); +extern int ipcl_conn_insert_v6(conn_t *); +extern conn_t *ipcl_get_next_conn(connf_t *, conn_t *, uint32_t); + +conn_t *ipcl_classify_v4(mblk_t *, uint8_t, uint_t, ip_recv_attr_t *, + ip_stack_t *); +conn_t *ipcl_classify_v6(mblk_t *, uint8_t, uint_t, ip_recv_attr_t *, + ip_stack_t *); +conn_t *ipcl_classify(mblk_t *, ip_recv_attr_t *, ip_stack_t *); +conn_t *ipcl_classify_raw(mblk_t *, uint8_t, uint32_t, ipha_t *, + ip6_t *, ip_recv_attr_t *, ip_stack_t *); +conn_t *ipcl_iptun_classify_v4(ipaddr_t *, ipaddr_t *, ip_stack_t *); +conn_t *ipcl_iptun_classify_v6(in6_addr_t *, in6_addr_t *, ip_stack_t *); +void ipcl_globalhash_insert(conn_t *); +void ipcl_globalhash_remove(conn_t *); +void ipcl_walk(pfv_t, void *, ip_stack_t *); +conn_t *ipcl_tcp_lookup_reversed_ipv4(ipha_t *, tcpha_t *, int, ip_stack_t *); +conn_t *ipcl_tcp_lookup_reversed_ipv6(ip6_t *, tcpha_t *, int, uint_t, + ip_stack_t *); +conn_t *ipcl_lookup_listener_v4(uint16_t, ipaddr_t, zoneid_t, ip_stack_t *); +conn_t *ipcl_lookup_listener_v6(uint16_t, in6_addr_t *, uint_t, zoneid_t, + ip_stack_t *); +int conn_trace_ref(conn_t *); +int conn_untrace_ref(conn_t *); +void ipcl_conn_cleanup(conn_t *); +extern uint_t conn_recvancillary_size(conn_t *, crb_t, ip_recv_attr_t *, + mblk_t *, ip_pkt_t *); +extern void conn_recvancillary_add(conn_t *, crb_t, ip_recv_attr_t *, + ip_pkt_t *, uchar_t *, uint_t); +conn_t *ipcl_conn_tcp_lookup_reversed_ipv4(conn_t *, ipha_t *, tcpha_t *, + ip_stack_t *); +conn_t *ipcl_conn_tcp_lookup_reversed_ipv6(conn_t *, ip6_t *, tcpha_t *, + ip_stack_t *); + +extern int ip_create_helper_stream(conn_t *, ldi_ident_t); +extern void ip_free_helper_stream(conn_t *); +extern int ip_helper_stream_setup(queue_t *, dev_t *, int, int, + cred_t *, boolean_t); +extern mib2_socketInfoEntry_t *conn_get_socket_info(conn_t *, + mib2_socketInfoEntry_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IPCLASSIFIER_H */ diff --git a/illumos-x86_64/usr/include/inet/ipdrop.h b/illumos-x86_64/usr/include/inet/ipdrop.h new file mode 100644 index 00000000..eadc3034 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ipdrop.h @@ -0,0 +1,135 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_IPDROP_H +#define _INET_IPDROP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +/* + * Opaque data type which will contain state about an entity that is dropping + * a packet (e.g. IPsec SPD, IPsec SADB, TCP, IP forwarding, etc.). + */ +typedef struct ipdropper_s { + char *ipd_name; +} ipdropper_t; + +void ip_drop_register(ipdropper_t *, char *); +void ip_drop_unregister(ipdropper_t *); +void ip_drop_packet(mblk_t *, boolean_t, ill_t *, struct kstat_named *, + ipdropper_t *); +void ip_drop_input(char *, mblk_t *, ill_t *); +void ip_drop_output(char *, mblk_t *, ill_t *); + +/* + * ip_dropstats - When a protocol developer comes up with a new reason to + * drop a packet, it should have a bean counter placed here in this structure, + * and an initializer in ipdrop.c's ip_drop_init(). + * + * This will suffice until we come up with a more dynamic way of adding + * named kstats to a single kstat instance (if that is possible). + */ +struct ip_dropstats { + /* TCP IPsec drop statistics. */ + kstat_named_t ipds_tcp_clear; + kstat_named_t ipds_tcp_secure; + kstat_named_t ipds_tcp_mismatch; + kstat_named_t ipds_tcp_ipsec_alloc; + + /* SADB-specific drop statistics. */ + kstat_named_t ipds_sadb_inlarval_timeout; + kstat_named_t ipds_sadb_inlarval_replace; + kstat_named_t ipds_sadb_inidle_timeout; + kstat_named_t ipds_sadb_inidle_overflow; + kstat_named_t ipds_sadb_acquire_nomem; + kstat_named_t ipds_sadb_acquire_toofull; + kstat_named_t ipds_sadb_acquire_timeout; + + /* SPD drop statistics. */ + kstat_named_t ipds_spd_ahesp_diffid; + kstat_named_t ipds_spd_loopback_mismatch; + kstat_named_t ipds_spd_explicit; + kstat_named_t ipds_spd_got_secure; + kstat_named_t ipds_spd_got_clear; + kstat_named_t ipds_spd_bad_ahalg; + kstat_named_t ipds_spd_got_ah; + kstat_named_t ipds_spd_bad_espealg; + kstat_named_t ipds_spd_bad_espaalg; + kstat_named_t ipds_spd_got_esp; + kstat_named_t ipds_spd_got_selfencap; + kstat_named_t ipds_spd_bad_selfencap; + kstat_named_t ipds_spd_nomem; + kstat_named_t ipds_spd_ah_badid; + kstat_named_t ipds_spd_esp_badid; + kstat_named_t ipds_spd_ah_innermismatch; + kstat_named_t ipds_spd_esp_innermismatch; + kstat_named_t ipds_spd_no_policy; + kstat_named_t ipds_spd_malformed_packet; + kstat_named_t ipds_spd_malformed_frag; + kstat_named_t ipds_spd_overlap_frag; + kstat_named_t ipds_spd_evil_frag; + kstat_named_t ipds_spd_max_frags; + kstat_named_t ipds_spd_expired_frags; + + /* ESP-specific drop statistics. */ + kstat_named_t ipds_esp_nomem; + kstat_named_t ipds_esp_no_sa; + kstat_named_t ipds_esp_early_replay; + kstat_named_t ipds_esp_replay; + kstat_named_t ipds_esp_bytes_expire; + kstat_named_t ipds_esp_bad_padlen; + kstat_named_t ipds_esp_bad_padding; + kstat_named_t ipds_esp_bad_auth; + kstat_named_t ipds_esp_crypto_failed; + kstat_named_t ipds_esp_icmp; + kstat_named_t ipds_esp_nat_t_ipsec; + kstat_named_t ipds_esp_nat_t_ka; + kstat_named_t ipds_esp_iv_wrap; + + /* AH-specific drop statistics. */ + kstat_named_t ipds_ah_nomem; + kstat_named_t ipds_ah_bad_v6_hdrs; + kstat_named_t ipds_ah_bad_v4_opts; + kstat_named_t ipds_ah_no_sa; + kstat_named_t ipds_ah_bad_length; + kstat_named_t ipds_ah_bad_auth; + kstat_named_t ipds_ah_crypto_failed; + kstat_named_t ipds_ah_early_replay; + kstat_named_t ipds_ah_replay; + kstat_named_t ipds_ah_bytes_expire; + + /* IP-specific drop statistics. */ + kstat_named_t ipds_ip_ipsec_not_loaded; +}; + +#endif /* _KERNEL */ +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IPDROP_H */ diff --git a/illumos-x86_64/usr/include/inet/ipnet.h b/illumos-x86_64/usr/include/inet/ipnet.h new file mode 100644 index 00000000..8c8a4c83 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ipnet.h @@ -0,0 +1,264 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_IPNET_H +#define _INET_IPNET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct ipnet_kstats_s { + kstat_named_t ik_duplicationFail; + kstat_named_t ik_dispatchOk; + kstat_named_t ik_dispatchFail; + kstat_named_t ik_dispatchHeaderDrop; + kstat_named_t ik_dispatchDupDrop; + kstat_named_t ik_dispatchPutDrop; + kstat_named_t ik_dispatchDeliver; + kstat_named_t ik_acceptOk; + kstat_named_t ik_acceptFail; +} ipnet_kstats_t; + +#define IPSK_BUMP(_x, _y) (_x)->ips_stats._y.value.ui64++ + +/* + * Structure used to hold information for both IPv4 and IPv6 addresses. + * + * When ifa_shared is non-NULL, it points to a "fake" ipnetif_t structure + * that represents the network interface for each zone that shares its + * network stack. This is used by BPF to build a list of interface names + * present in each zone. Multiple ipnetif_addr_t's may point to a single + * ipnetif_t using ifa_shared. The typical case is the global zone has + * a bge0 that other zones use as bge0:1, bge0:2, etc. In ipnet, the + * ipnetif_addr_t's that store the IP address for bge0:1, etc, would + * point to an ipnetif_t stored in the if_avl_by_shared tree that has + * the name "bge0". + */ +typedef struct ipnetif_addr { + union { + ipaddr_t ifau_ip4addr; + in6_addr_t ifau_ip6addr; + } ifa_addr; + ipaddr_t ifa_brdaddr; + zoneid_t ifa_zone; + uint64_t ifa_id; + list_node_t ifa_link; + struct ipnetif *ifa_shared; +} ipnetif_addr_t; +#define ifa_ip4addr ifa_addr.ifau_ip4addr +#define ifa_ip6addr ifa_addr.ifau_ip6addr + +/* + * Structure describes the ipnet module representation of an ip interface. + * The structure holds both IPv4 and IPv6 addresses, the address lists are + * protected by a mutex. The ipnetif structures are held per stack instance + * within avl trees indexed on name and ip index. + * + * if_avl_by_shared is used by zones that share their instance of IP with + * other zones. It is used to store ipnetif_t structures. An example of this + * is the global zone sharing its instance of IP with other local zones. + * In this case, if_avl_by_shared is a tree of names that are in active use + * by zones using a shared instance of IP. + * The value in if_sharecnt represents the number of ipnetif_addr_t's that + * point to it. + */ +typedef struct ipnetif { + char if_name[LIFNAMSIZ]; + uint_t if_flags; + uint_t if_index; + kmutex_t if_addr_lock; /* protects both addr lists */ + list_t if_ip4addr_list; + list_t if_ip6addr_list; + avl_node_t if_avl_by_index; + avl_node_t if_avl_by_name; + dev_t if_dev; + uint_t if_multicnt; /* protected by ips_event_lock */ + kmutex_t if_reflock; /* protects if_refcnt */ + int if_refcnt; /* if_reflock */ + zoneid_t if_zoneid; + avl_node_t if_avl_by_shared; /* protected by ips_avl_lock */ + struct ipnet_stack *if_stackp; + int if_sharecnt; /* protected by if_reflock */ +} ipnetif_t; + +/* if_flags */ +#define IPNETIF_IPV4PLUMBED 0x01 +#define IPNETIF_IPV6PLUMBED 0x02 +#define IPNETIF_IPV4ALLMULTI 0x04 +#define IPNETIF_IPV6ALLMULTI 0x08 +#define IPNETIF_LOOPBACK 0x10 + +/* + * Structure used by the accept callback function. This is simply an address + * pointer into a packet (either IPv4 or IPv6), along with an address family + * that denotes which pointer is valid. + */ +typedef struct ipnet_addrp { + sa_family_t iap_family; + union { + ipaddr_t *iapu_addr4; + in6_addr_t *iapu_addr6; + } iap_addrp; +} ipnet_addrp_t; +#define iap_addr4 iap_addrp.iapu_addr4 +#define iap_addr6 iap_addrp.iapu_addr6 + +struct ipnet; +struct ipobs_hook_data; +typedef boolean_t ipnet_acceptfn_t(struct ipnet *, struct hook_pkt_observe_s *, + ipnet_addrp_t *, ipnet_addrp_t *); + +/* + * Per instance data for all open streams. Instance data is held on a + * per netstack list see struct ipnet_stack below. + */ +typedef struct ipnet { + queue_t *ipnet_rq; /* read queue pointer */ + minor_t ipnet_minor; /* minor number for this instance */ + ipnetif_t *ipnet_if; /* ipnetif for this open instance */ + zoneid_t ipnet_zoneid; /* zoneid the device was opened in */ + uint_t ipnet_flags; /* see below */ + t_scalar_t ipnet_family; /* protocol family of this instance */ + t_uscalar_t ipnet_dlstate; /* dlpi state */ + list_node_t ipnet_next; /* list next member */ + netstack_t *ipnet_ns; /* netstack of zone we were opened in */ + ipnet_acceptfn_t *ipnet_acceptfn; /* accept callback function pointer */ + hook_t *ipnet_hook; /* hook token to unregister */ + void *ipnet_data; /* value to pass back to bpf_itap */ +} ipnet_t; + +/* ipnet_flags */ +#define IPNET_PROMISC_PHYS 0x01 +#define IPNET_PROMISC_MULTI 0x02 +#define IPNET_PROMISC_SAP 0x04 +#define IPNET_INFO 0x08 +#define IPNET_LOMODE 0x10 + +/* + * Per-netstack data holding: + * - net_handle_t references for IPv4 and IPv6 for this netstack. + * - avl trees by name and index for ip interfaces associated with this + * netstack. The trees are protected by ips_avl_lock. + * - ips_str_list is a list of open client streams. ips_walkers_lock in + * conjunction with ips_walkers_cv and ips_walkers_cnt synchronize access to + * the list. The count is incremented in ipnet_dispatch() at the start of a + * walk and decremented when the walk is finished. If the walkers count is 0 + * then we cv_broadcast() waiting any threads waiting on the walkers count. + * - ips_event_lock synchronizes ipnet_if_init() and incoming NIC info events. + * We cannot be processing any NIC info events while initializing interfaces + * in ipnet_if_init(). + * + * Note on lock ordering: If a thread needs to both hold the ips_event_lock + * and any other lock such as ips_walkers_lock, ips_avl_lock, or if_addr_lock, + * the ips_event_lock must be held first. This lock ordering is mandated by + * ipnet_nicevent_cb() which must always grab ips_event_lock before continuing + * with processing NIC events. + */ +typedef struct ipnet_stack { + net_handle_t ips_ndv4; + net_handle_t ips_ndv6; + netstack_t *ips_netstack; + hook_t *ips_nicevents; + kmutex_t ips_event_lock; + kmutex_t ips_avl_lock; + avl_tree_t ips_avl_by_index; + avl_tree_t ips_avl_by_name; + kmutex_t ips_walkers_lock; + kcondvar_t ips_walkers_cv; + uint_t ips_walkers_cnt; + list_t ips_str_list; + kstat_t *ips_kstatp; + ipnet_kstats_t ips_stats; + avl_tree_t ips_avl_by_shared; + hook_t *ips_hook; +} ipnet_stack_t; + +/* + * Template for dl_info_ack_t initialization. We don't have an address, so we + * set the address length to just the SAP length (16 bits). We don't really + * have a maximum SDU, but setting it to UINT_MAX proved problematic with + * applications that performed arithmetic on dl_max_sdu and wrapped around, so + * we sleaze out and use INT_MAX. + */ +#define IPNET_INFO_ACK_INIT { \ + DL_INFO_ACK, /* dl_primitive */ \ + INT_MAX, /* dl_max_sdu */ \ + 0, /* dl_min_sdu */ \ + sizeof (uint16_t), /* dl_addr_length */ \ + DL_IPNET, /* dl_mac_type */ \ + 0, /* dl_reserved */ \ + 0, /* dl_current_state */ \ + sizeof (uint16_t), /* dl_sap_length */ \ + DL_CLDLS, /* dl_service_mode */ \ + 0, /* dl_qos_length */ \ + 0, /* dl_qos_offset */ \ + 0, /* dl_range_length */ \ + 0, /* dl_range_offset */ \ + DL_STYLE1, /* dl_provider_style */ \ + 0, /* dl_addr_offset */ \ + DL_VERSION_2, /* dl_version */ \ + 0, /* dl_brdcst_addr_length */ \ + 0 /* dl_brdcst_addr_offset */ \ +} + +typedef void ipnet_walkfunc_t(const char *, void *, dev_t); + +extern int ipnet_client_open(ipnetif_t *, ipnetif_t **); +extern void ipnet_client_close(ipnetif_t *); +extern void ipnet_close_byhandle(ipnetif_t *); +extern ipnet_stack_t *ipnet_find_by_zoneid(zoneid_t zoneid); +extern int ipnet_get_linkid_byname(const char *, datalink_id_t *, + zoneid_t); +extern dev_t ipnet_if_getdev(char *, zoneid_t); +extern const char *ipnet_name(ipnetif_t *); +extern int ipnet_open_byname(const char *, ipnetif_t **, zoneid_t); +extern int ipnet_promisc_add(void *, uint_t, void *, uintptr_t *, int); +extern void ipnet_promisc_remove(void *); +extern void ipnet_rele(ipnet_stack_t *); +extern void ipnet_set_itap(bpf_itap_fn_t); +extern void ipnet_walk_if(ipnet_walkfunc_t *, void *, zoneid_t); + +extern bpf_provider_t bpf_ipnet; + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IPNET_H */ diff --git a/illumos-x86_64/usr/include/inet/ipp_common.h b/illumos-x86_64/usr/include/inet/ipp_common.h new file mode 100644 index 00000000..d7380896 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/ipp_common.h @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_IPP_COMMON_H +#define _INET_IPP_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +#include + +/* + * IPP -- IP Policy -- interface. + * + * WARNING: Everything in this file is private, belonging to the IPP + * subsystem. The interfaces and declarations made here are subject + * to change. + */ + +extern uint32_t ipp_action_count; + +/* Whether ip policy is enabled at callout position proc */ +#define IPP_ENABLED(proc, ipst) ((ipp_action_count != 0) && \ + (~((ipst)->ips_ip_policy_mask) & (proc))) + +/* Extracts 8 bit traffic class from IPV6 flow label field */ +#ifdef _BIG_ENDIAN +#define __IPV6_TCLASS_FROM_FLOW(n) (((n)>>20) & 0xff) +#else +#define __IPV6_TCLASS_FROM_FLOW(n) ((((n)<<4) | (((n)>>12) & 0xf)) & 0xff) +#endif /* _BIG_ENDIAN */ + +typedef enum { + IPP_LOCAL_IN = 0x01, + IPP_LOCAL_OUT = 0x02, + IPP_FWD_IN = 0x04, + IPP_FWD_OUT = 0x08 +} ip_proc_t; + +/* IP private data structure */ +typedef struct ip_priv { + ip_proc_t proc; + uint32_t ill_index; +} ip_priv_t; + +/* The entry point for ip policy processing */ +#ifdef ILL_CONDEMNED +extern mblk_t *ip_process(ip_proc_t, mblk_t *, ill_t *, ill_t *); +#endif +extern void ip_priv_free(void *); +#endif /* _KERNEL */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_IPP_COMMON_H */ diff --git a/illumos-x86_64/usr/include/inet/led.h b/illumos-x86_64/usr/include/inet/led.h new file mode 100644 index 00000000..2d669dd7 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/led.h @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_LED_H +#define _INET_LED_H + +/* + * WARNING: This file contains implementation-specific constants, typedefs + * and macros which may change from release to release. + * + * WARNING: This file has nothing to do with things that blink. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * x86 can handle unaligned access. However, the checksum routine + * assumes that the source is 16 bit aligned so we always make sure + * that packet headers are 16 bit aligned. + */ +#define OK_16PTR(p) (!((uintptr_t)(p) & 0x1)) +#if defined(__x86) +#define OK_32PTR(p) OK_16PTR(p) +#else +#define OK_32PTR(p) (!((uintptr_t)(p) & 0x3)) +#endif + +#ifdef _KERNEL + +typedef char *IDP; +typedef struct msgb *MBLKP; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_LED_H */ diff --git a/illumos-x86_64/usr/include/inet/mi.h b/illumos-x86_64/usr/include/inet/mi.h new file mode 100644 index 00000000..51350ed5 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/mi.h @@ -0,0 +1,168 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_MI_H +#define _INET_MI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include +#include +#include +#include + +#define MI_MIN_DEV INET_MIN_DEV /* minimum minor device number */ +#define MI_COPY_IN 1 +#define MI_COPY_OUT 2 +#define MI_COPY_DIRECTION(mp) (*(int *)&(mp)->b_cont->b_next) +#define MI_COPY_COUNT(mp) (*(int *)&(mp)->b_cont->b_prev) +#define MI_COPY_CASE(dir, cnt) (((cnt)<<2)|dir) +#define MI_COPY_STATE(mp) MI_COPY_CASE(MI_COPY_DIRECTION(mp), \ + MI_COPY_COUNT(mp)) + +/* + * Double linked list of type MI_O with a mi_head_t as the head. + * Used for mi_open_comm etc. + */ +typedef struct mi_o_s { + struct mi_o_s *mi_o_next; + struct mi_o_s *mi_o_prev; + boolean_t mi_o_isdev; /* Is this a device instance */ + dev_t mi_o_dev; +} MI_O, *MI_OP; + +/* + * List head for MI_O doubly linked list. + * The list contains unsorted driver, module and detached instances. + * + * Minor numbers are allocated from mh_arena which initially contains + * [MI_MIN_DEV, mh_maxminor] numbers. When this arena is fully allocated, it is + * extended to MAXMIN32. + * + * The module_dev is used to give almost unique numbers to module instances. + * This is only needed for mi_strlog which uses the mi_o_dev field when + * logging messages. + */ + +typedef struct mi_head_s { + struct mi_o_s mh_o; /* Contains head of doubly linked list */ + vmem_t *mh_arena; /* Minor number arena */ + int mh_module_dev; /* Wraparound number for use when MODOPEN */ + minor_t mh_maxminor; /* max minor number in the arena */ +} mi_head_t; + +extern void *mi_alloc(size_t size, uint_t pri); +extern void *mi_alloc_sleep(size_t size, uint_t pri); +extern void mi_free(void *ptr); + +extern int mi_close_comm(void **mi_head, queue_t *q); +extern void mi_close_free(IDP ptr); +extern void mi_close_unlink(void **mi_head, IDP ptr); + +extern void mi_copyin(queue_t *q, MBLKP mp, char *uaddr, size_t len); +extern void mi_copyin_n(queue_t *q, MBLKP mp, size_t offset, size_t len); +extern void mi_copyout(queue_t *q, MBLKP mp); +extern MBLKP mi_copyout_alloc(queue_t *q, MBLKP mp, char *uaddr, size_t len, + boolean_t free_on_error); +extern void mi_copy_done(queue_t *q, MBLKP mp, int err); +extern int mi_copy_state(queue_t *q, MBLKP mp, MBLKP *mpp); + +/*PRINTFLIKE2*/ +extern int mi_mpprintf(MBLKP mp, char *fmt, ...) + __KPRINTFLIKE(2); +/*PRINTFLIKE2*/ +extern int mi_mpprintf_nr(MBLKP mp, char *fmt, ...) + __KPRINTFLIKE(2); +extern int mi_mpprintf_putc(char *cookie, int ch); + +extern IDP mi_first_ptr(void **mi_head); +extern IDP mi_first_dev_ptr(void **mi_head); +extern IDP mi_next_ptr(void **mi_head, IDP ptr); +extern IDP mi_next_dev_ptr(void **mi_head, IDP ptr); + +extern IDP mi_open_alloc(size_t size); +extern IDP mi_open_alloc_sleep(size_t size); +extern int mi_open_comm(void **mi_head, size_t size, queue_t *q, + dev_t *devp, int flag, int sflag, cred_t *credp); +extern int mi_open_link(void **mi_head, IDP ptr, dev_t *devp, int flag, + int sflag, cred_t *credp); + +extern uint8_t *mi_offset_param(mblk_t *mp, size_t offset, size_t len); +extern uint8_t *mi_offset_paramc(mblk_t *mp, size_t offset, size_t len); + +/*PRINTFLIKE2*/ +extern int mi_sprintf(char *buf, char *fmt, ...) + __KPRINTFLIKE(2); +extern int mi_sprintf_putc(char *cookie, int ch); + +extern int mi_strcmp(const char *cp1, const char *cp2); +extern size_t mi_strlen(const char *str); + +/*PRINTFLIKE4*/ +extern int mi_strlog(queue_t *q, char level, ushort_t flags, + char *fmt, ...) __KPRINTFLIKE(4); +#pragma rarely_called(mi_strlog) + +extern long mi_strtol(const char *str, char **ptr, int base); + +extern void mi_timer(queue_t *q, MBLKP mp, clock_t tim); +extern MBLKP mi_timer_alloc(size_t size); +extern void mi_timer_free(MBLKP mp); +extern void mi_timer_move(queue_t *, mblk_t *); +extern void mi_timer_stop(mblk_t *); +extern boolean_t mi_timer_valid(MBLKP mp); + +extern MBLKP mi_tpi_conn_con(MBLKP trailer_mp, char *src, + t_scalar_t src_length, char *opt, t_scalar_t opt_length); +extern MBLKP mi_tpi_conn_ind(MBLKP trailer_mp, char *src, + t_scalar_t src_length, char *opt, t_scalar_t opt_length, + t_scalar_t seqnum); +extern MBLKP mi_tpi_extconn_ind(MBLKP trailer_mp, char *src, + t_scalar_t src_length, char *opt, t_scalar_t opt_length, + char *dst, t_scalar_t dst_length, t_scalar_t seqnum); +extern MBLKP mi_tpi_discon_ind(MBLKP trailer_mp, t_scalar_t reason, + t_scalar_t seqnum); +extern MBLKP mi_tpi_err_ack_alloc(MBLKP mp, t_scalar_t tlierr, int unixerr); +extern MBLKP mi_tpi_ok_ack_alloc(MBLKP mp); +extern MBLKP mi_tpi_ok_ack_alloc_extra(MBLKP mp, int extra); +extern MBLKP mi_tpi_ordrel_ind(void); +extern MBLKP mi_tpi_uderror_ind(char *dest, t_scalar_t dest_length, + char *opt, t_scalar_t opt_length, t_scalar_t error); + +extern IDP mi_zalloc(size_t size); +extern IDP mi_zalloc_sleep(size_t size); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_MI_H */ diff --git a/illumos-x86_64/usr/include/inet/mib2.h b/illumos-x86_64/usr/include/inet/mib2.h new file mode 100644 index 00000000..5a168523 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/mib2.h @@ -0,0 +1,1823 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright (c) 1990 Mentat Inc. + * Copyright (c) 2015, 2016 by Delphix. All rights reserved. + */ + +/* + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _INET_MIB2_H +#define _INET_MIB2_H + +#include /* For in6_addr_t */ +#include /* For brange_t */ +#include /* For brange_t */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The IPv6 parts of this are derived from: + * RFC 2465 + * RFC 2466 + * RFC 2452 + * RFC 2454 + */ + +/* + * SNMP set/get via M_PROTO T_OPTMGMT_REQ. Structure is that used + * for [gs]etsockopt() calls. get uses T_CURRENT, set uses T_NEOGTIATE + * MGMT_flags value. The following definition of opthdr is taken from + * socket.h: + * + * An option specification consists of an opthdr, followed by the value of + * the option. An options buffer contains one or more options. The len + * field of opthdr specifies the length of the option value in bytes. This + * length must be a multiple of sizeof(long) (use OPTLEN macro). + * + * struct opthdr { + * long level; protocol level affected + * long name; option to modify + * long len; length of option value + * }; + * + * #define OPTLEN(x) ((((x) + sizeof(long) - 1) / sizeof(long)) * sizeof(long)) + * #define OPTVAL(opt) ((char *)(opt + 1)) + * + * For get requests (T_CURRENT), any MIB2_xxx value can be used (only + * "get all" is supported, so all modules get a copy of the request to + * return everything it knows. In general, we use MIB2_IP. There is + * one exception: in general, IP will not report information related to + * ire_testhidden and IRE_IF_CLONE routes (e.g., in the MIB2_IP_ROUTE + * table). However, using the special value EXPER_IP_AND_ALL_IRES will cause + * all information to be reported. This special value should only be + * used by IPMP-aware low-level utilities (e.g. in.mpathd). + * + * IMPORTANT: some fields are grouped in a different structure than + * suggested by MIB-II, e.g., checksum error counts. The original MIB-2 + * field name has been retained. Field names beginning with "mi" are not + * defined in the MIB but contain important & useful information maintained + * by the corresponding module. + */ +#ifndef IPPROTO_MAX +#define IPPROTO_MAX 256 +#endif + +#define MIB2_SYSTEM (IPPROTO_MAX+1) +#define MIB2_INTERFACES (IPPROTO_MAX+2) +#define MIB2_AT (IPPROTO_MAX+3) +#define MIB2_IP (IPPROTO_MAX+4) +#define MIB2_ICMP (IPPROTO_MAX+5) +#define MIB2_TCP (IPPROTO_MAX+6) +#define MIB2_UDP (IPPROTO_MAX+7) +#define MIB2_EGP (IPPROTO_MAX+8) +#define MIB2_CMOT (IPPROTO_MAX+9) +#define MIB2_TRANSMISSION (IPPROTO_MAX+10) +#define MIB2_SNMP (IPPROTO_MAX+11) +#define MIB2_IP6 (IPPROTO_MAX+12) +#define MIB2_ICMP6 (IPPROTO_MAX+13) +#define MIB2_TCP6 (IPPROTO_MAX+14) +#define MIB2_UDP6 (IPPROTO_MAX+15) +#define MIB2_SCTP (IPPROTO_MAX+16) + +/* + * Define range of levels for use with MIB2_* + */ +#define MIB2_RANGE_START (IPPROTO_MAX+1) +#define MIB2_RANGE_END (IPPROTO_MAX+16) + + +#define EXPER 1024 /* experimental - not part of mib */ +#define EXPER_IGMP (EXPER+1) +#define EXPER_DVMRP (EXPER+2) +#define EXPER_RAWIP (EXPER+3) +#define EXPER_IP_AND_ALL_IRES (EXPER+4) + +/* + * Define range of levels for experimental use + */ +#define EXPER_RANGE_START (EXPER+1) +#define EXPER_RANGE_END (EXPER+4) + +#define BUMP_MIB(s, x) { \ + extern void __dtrace_probe___mib_##x(int, void *); \ + void *stataddr = &((s)->x); \ + __dtrace_probe___mib_##x(1, stataddr); \ + (s)->x++; \ +} + +#define UPDATE_MIB(s, x, y) { \ + extern void __dtrace_probe___mib_##x(int, void *); \ + void *stataddr = &((s)->x); \ + __dtrace_probe___mib_##x(y, stataddr); \ + (s)->x += (y); \ +} + +#define SET_MIB(x, y) x = y +#define BUMP_LOCAL(x) (x)++ +#define UPDATE_LOCAL(x, y) (x) += (y) +#define SYNC32_MIB(s, m32, m64) SET_MIB((s)->m32, (s)->m64 & 0xffffffff) + +/* + * Each struct that has been extended have a macro (MIB_FIRST_NEW_ELM_type) + * that is set to the first new element of the extended struct. + * The LEGACY_MIB_SIZE macro can be used to determine the size of MIB + * objects that needs to be returned to older applications unaware of + * these extensions. + */ +#define MIB_PTRDIFF(s, e) (caddr_t)e - (caddr_t)s +#define LEGACY_MIB_SIZE(s, t) MIB_PTRDIFF(s, &(s)->MIB_FIRST_NEW_ELM_##t) + +#define OCTET_LENGTH 32 /* Must be at least LIFNAMSIZ */ +typedef struct Octet_s { + int o_length; + char o_bytes[OCTET_LENGTH]; +} Octet_t; + +typedef uint32_t Counter; +typedef uint32_t Counter32; +typedef uint64_t Counter64; +typedef uint32_t Gauge; +typedef uint32_t IpAddress; +typedef struct in6_addr Ip6Address; +typedef Octet_t DeviceName; +typedef Octet_t PhysAddress; +typedef uint32_t DeviceIndex; /* Interface index */ + +#define MIB2_UNKNOWN_INTERFACE 0 +#define MIB2_UNKNOWN_PROCESS 0 + +/* + * IP group + */ +#define MIB2_IP_ADDR 20 /* ipAddrEntry */ +#define MIB2_IP_ROUTE 21 /* ipRouteEntry */ +#define MIB2_IP_MEDIA 22 /* ipNetToMediaEntry */ +#define MIB2_IP6_ROUTE 23 /* ipv6RouteEntry */ +#define MIB2_IP6_MEDIA 24 /* ipv6NetToMediaEntry */ +#define MIB2_IP6_ADDR 25 /* ipv6AddrEntry */ +#define MIB2_IP_TRAFFIC_STATS 31 /* ipIfStatsEntry (IPv4) */ +#define EXPER_IP_GROUP_MEMBERSHIP 100 +#define EXPER_IP6_GROUP_MEMBERSHIP 101 +#define EXPER_IP_GROUP_SOURCES 102 +#define EXPER_IP6_GROUP_SOURCES 103 +#define EXPER_IP_RTATTR 104 +#define EXPER_IP_DCE 105 + +/* + * There can be one of each of these tables per transport (MIB2_* above). + */ +#define EXPER_XPORT_MLP 105 /* transportMLPEntry */ +#define EXPER_SOCK_INFO 106 /* socketInfoEntry */ + +/* Old names retained for compatibility */ +#define MIB2_IP_20 MIB2_IP_ADDR +#define MIB2_IP_21 MIB2_IP_ROUTE +#define MIB2_IP_22 MIB2_IP_MEDIA + +typedef struct mib2_ip { + /* forwarder? 1 gateway, 2 NOT gateway {ip 1} RW */ + int ipForwarding; + /* default Time-to-Live for iph {ip 2} RW */ + int ipDefaultTTL; + /* # of input datagrams {ip 3} */ + Counter ipInReceives; + /* # of dg discards for iph error {ip 4} */ + Counter ipInHdrErrors; + /* # of dg discards for bad addr {ip 5} */ + Counter ipInAddrErrors; + /* # of dg being forwarded {ip 6} */ + Counter ipForwDatagrams; + /* # of dg discards for unk protocol {ip 7} */ + Counter ipInUnknownProtos; + /* # of dg discards of good dg's {ip 8} */ + Counter ipInDiscards; + /* # of dg sent upstream {ip 9} */ + Counter ipInDelivers; + /* # of outdgs recv'd from upstream {ip 10} */ + Counter ipOutRequests; + /* # of good outdgs discarded {ip 11} */ + Counter ipOutDiscards; + /* # of outdg discards: no route found {ip 12} */ + Counter ipOutNoRoutes; + /* sec's recv'd frags held for reass. {ip 13} */ + int ipReasmTimeout; + /* # of ip frags needing reassembly {ip 14} */ + Counter ipReasmReqds; + /* # of dg's reassembled {ip 15} */ + Counter ipReasmOKs; + /* # of reassembly failures (not dg cnt){ip 16} */ + Counter ipReasmFails; + /* # of dg's fragged {ip 17} */ + Counter ipFragOKs; + /* # of dg discards for no frag set {ip 18} */ + Counter ipFragFails; + /* # of dg frags from fragmentation {ip 19} */ + Counter ipFragCreates; + /* {ip 20} */ + int ipAddrEntrySize; + /* {ip 21} */ + int ipRouteEntrySize; + /* {ip 22} */ + int ipNetToMediaEntrySize; + /* # of valid route entries discarded {ip 23} */ + Counter ipRoutingDiscards; +/* + * following defined in MIB-II as part of TCP & UDP groups: + */ + /* total # of segments recv'd with error { tcp 14 } */ + Counter tcpInErrs; + /* # of recv'd dg's not deliverable (no appl.) { udp 2 } */ + Counter udpNoPorts; +/* + * In addition to MIB-II + */ + /* # of bad IP header checksums */ + Counter ipInCksumErrs; + /* # of complete duplicates in reassembly */ + Counter ipReasmDuplicates; + /* # of partial duplicates in reassembly */ + Counter ipReasmPartDups; + /* # of packets not forwarded due to adminstrative reasons */ + Counter ipForwProhibits; + /* # of UDP packets with bad UDP checksums */ + Counter udpInCksumErrs; + /* # of UDP packets droped due to queue overflow */ + Counter udpInOverflows; + /* + * # of RAW IP packets (all IP protocols except UDP, TCP + * and ICMP) droped due to queue overflow + */ + Counter rawipInOverflows; + + /* + * Folowing are private IPSEC MIB. + */ + /* # of incoming packets that succeeded policy checks */ + Counter ipsecInSucceeded; + /* # of incoming packets that failed policy checks */ + Counter ipsecInFailed; +/* Compatible extensions added here */ + int ipMemberEntrySize; /* Size of ip_member_t */ + int ipGroupSourceEntrySize; /* Size of ip_grpsrc_t */ + + Counter ipInIPv6; /* # of IPv6 packets received by IPv4 and dropped */ + Counter ipOutIPv6; /* No longer used */ + Counter ipOutSwitchIPv6; /* No longer used */ + + int ipRouteAttributeSize; /* Size of mib2_ipAttributeEntry_t */ + int transportMLPSize; /* Size of mib2_transportMLPEntry_t */ + int ipDestEntrySize; /* Size of dest_cache_entry_t */ +} mib2_ip_t; + +/* + * ipv6IfStatsEntry OBJECT-TYPE + * SYNTAX Ipv6IfStatsEntry + * MAX-ACCESS not-accessible + * STATUS current + * DESCRIPTION + * "An interface statistics entry containing objects + * at a particular IPv6 interface." + * AUGMENTS { ipv6IfEntry } + * ::= { ipv6IfStatsTable 1 } + * + * Per-interface IPv6 statistics table + */ + +typedef struct mib2_ipv6IfStatsEntry { + /* Local ifindex to identify the interface */ + DeviceIndex ipv6IfIndex; + + /* forwarder? 1 gateway, 2 NOT gateway {ipv6MIBObjects 1} RW */ + int ipv6Forwarding; + /* default Hoplimit for IPv6 {ipv6MIBObjects 2} RW */ + int ipv6DefaultHopLimit; + + int ipv6IfStatsEntrySize; + int ipv6AddrEntrySize; + int ipv6RouteEntrySize; + int ipv6NetToMediaEntrySize; + int ipv6MemberEntrySize; /* Size of ipv6_member_t */ + int ipv6GroupSourceEntrySize; /* Size of ipv6_grpsrc_t */ + + /* # input datagrams (incl errors) { ipv6IfStatsEntry 1 } */ + Counter ipv6InReceives; + /* # errors in IPv6 headers and options { ipv6IfStatsEntry 2 } */ + Counter ipv6InHdrErrors; + /* # exceeds outgoing link MTU { ipv6IfStatsEntry 3 } */ + Counter ipv6InTooBigErrors; + /* # discarded due to no route to dest { ipv6IfStatsEntry 4 } */ + Counter ipv6InNoRoutes; + /* # invalid or unsupported addresses { ipv6IfStatsEntry 5 } */ + Counter ipv6InAddrErrors; + /* # unknown next header { ipv6IfStatsEntry 6 } */ + Counter ipv6InUnknownProtos; + /* # too short packets { ipv6IfStatsEntry 7 } */ + Counter ipv6InTruncatedPkts; + /* # discarded e.g. due to no buffers { ipv6IfStatsEntry 8 } */ + Counter ipv6InDiscards; + /* # delivered to upper layer protocols { ipv6IfStatsEntry 9 } */ + Counter ipv6InDelivers; + /* # forwarded out interface { ipv6IfStatsEntry 10 } */ + Counter ipv6OutForwDatagrams; + /* # originated out interface { ipv6IfStatsEntry 11 } */ + Counter ipv6OutRequests; + /* # discarded e.g. due to no buffers { ipv6IfStatsEntry 12 } */ + Counter ipv6OutDiscards; + /* # sucessfully fragmented packets { ipv6IfStatsEntry 13 } */ + Counter ipv6OutFragOKs; + /* # fragmentation failed { ipv6IfStatsEntry 14 } */ + Counter ipv6OutFragFails; + /* # fragments created { ipv6IfStatsEntry 15 } */ + Counter ipv6OutFragCreates; + /* # fragments to reassemble { ipv6IfStatsEntry 16 } */ + Counter ipv6ReasmReqds; + /* # packets after reassembly { ipv6IfStatsEntry 17 } */ + Counter ipv6ReasmOKs; + /* # reassembly failed { ipv6IfStatsEntry 18 } */ + Counter ipv6ReasmFails; + /* # received multicast packets { ipv6IfStatsEntry 19 } */ + Counter ipv6InMcastPkts; + /* # transmitted multicast packets { ipv6IfStatsEntry 20 } */ + Counter ipv6OutMcastPkts; +/* + * In addition to defined MIBs + */ + /* # discarded due to no route to dest */ + Counter ipv6OutNoRoutes; + /* # of complete duplicates in reassembly */ + Counter ipv6ReasmDuplicates; + /* # of partial duplicates in reassembly */ + Counter ipv6ReasmPartDups; + /* # of packets not forwarded due to adminstrative reasons */ + Counter ipv6ForwProhibits; + /* # of UDP packets with bad UDP checksums */ + Counter udpInCksumErrs; + /* # of UDP packets droped due to queue overflow */ + Counter udpInOverflows; + /* + * # of RAW IPv6 packets (all IPv6 protocols except UDP, TCP + * and ICMPv6) droped due to queue overflow + */ + Counter rawipInOverflows; + + /* # of IPv4 packets received by IPv6 and dropped */ + Counter ipv6InIPv4; + /* # of IPv4 packets transmitted by ip_wput_wput */ + Counter ipv6OutIPv4; + /* # of times ip_wput_v6 has switched to become ip_wput */ + Counter ipv6OutSwitchIPv4; +} mib2_ipv6IfStatsEntry_t; + +/* + * Per interface IP statistics, both v4 and v6. + * + * Some applications expect to get mib2_ipv6IfStatsEntry_t structs back when + * making a request. To ensure backwards compatability, the first + * sizeof(mib2_ipv6IfStatsEntry_t) bytes of the structure is identical to + * mib2_ipv6IfStatsEntry_t. This should work as long the application is + * written correctly (i.e., using ipv6IfStatsEntrySize to get the size of + * the struct) + * + * RFC4293 introduces several new counters, as well as defining 64-bit + * versions of existing counters. For a new counters, if they have both 32- + * and 64-bit versions, then we only added the latter. However, for already + * existing counters, we have added the 64-bit versions without removing the + * old (32-bit) ones. The 64- and 32-bit counters will only be synchronized + * when the structure contains IPv6 statistics, which is done to ensure + * backwards compatibility. + */ + +/* The following are defined in RFC 4001 and are used for ipIfStatsIPVersion */ +#define MIB2_INETADDRESSTYPE_unknown 0 +#define MIB2_INETADDRESSTYPE_ipv4 1 +#define MIB2_INETADDRESSTYPE_ipv6 2 + +/* + * On amd64, the alignment requirements for long long's is different for + * 32 and 64 bits. If we have a struct containing long long's that is being + * passed between a 64-bit kernel to a 32-bit application, then it is very + * likely that the size of the struct will differ due to padding. Therefore, we + * pack the data to ensure that the struct size is the same for 32- and + * 64-bits. + */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct mib2_ipIfStatsEntry { + + /* Local ifindex to identify the interface */ + DeviceIndex ipIfStatsIfIndex; + + /* forwarder? 1 gateway, 2 NOT gateway { ipv6MIBObjects 1} RW */ + int ipIfStatsForwarding; + /* default Hoplimit for IPv6 { ipv6MIBObjects 2} RW */ + int ipIfStatsDefaultHopLimit; +#define ipIfStatsDefaultTTL ipIfStatsDefaultHopLimit + + int ipIfStatsEntrySize; + int ipIfStatsAddrEntrySize; + int ipIfStatsRouteEntrySize; + int ipIfStatsNetToMediaEntrySize; + int ipIfStatsMemberEntrySize; + int ipIfStatsGroupSourceEntrySize; + + /* # input datagrams (incl errors) { ipIfStatsEntry 3 } */ + Counter ipIfStatsInReceives; + /* # errors in IP headers and options { ipIfStatsEntry 7 } */ + Counter ipIfStatsInHdrErrors; + /* # exceeds outgoing link MTU(v6 only) { ipv6IfStatsEntry 3 } */ + Counter ipIfStatsInTooBigErrors; + /* # discarded due to no route to dest { ipIfStatsEntry 8 } */ + Counter ipIfStatsInNoRoutes; + /* # invalid or unsupported addresses { ipIfStatsEntry 9 } */ + Counter ipIfStatsInAddrErrors; + /* # unknown next header { ipIfStatsEntry 10 } */ + Counter ipIfStatsInUnknownProtos; + /* # too short packets { ipIfStatsEntry 11 } */ + Counter ipIfStatsInTruncatedPkts; + /* # discarded e.g. due to no buffers { ipIfStatsEntry 17 } */ + Counter ipIfStatsInDiscards; + /* # delivered to upper layer protocols { ipIfStatsEntry 18 } */ + Counter ipIfStatsInDelivers; + /* # forwarded out interface { ipIfStatsEntry 23 } */ + Counter ipIfStatsOutForwDatagrams; + /* # originated out interface { ipIfStatsEntry 20 } */ + Counter ipIfStatsOutRequests; + /* # discarded e.g. due to no buffers { ipIfStatsEntry 25 } */ + Counter ipIfStatsOutDiscards; + /* # sucessfully fragmented packets { ipIfStatsEntry 27 } */ + Counter ipIfStatsOutFragOKs; + /* # fragmentation failed { ipIfStatsEntry 28 } */ + Counter ipIfStatsOutFragFails; + /* # fragments created { ipIfStatsEntry 29 } */ + Counter ipIfStatsOutFragCreates; + /* # fragments to reassemble { ipIfStatsEntry 14 } */ + Counter ipIfStatsReasmReqds; + /* # packets after reassembly { ipIfStatsEntry 15 } */ + Counter ipIfStatsReasmOKs; + /* # reassembly failed { ipIfStatsEntry 16 } */ + Counter ipIfStatsReasmFails; + /* # received multicast packets { ipIfStatsEntry 34 } */ + Counter ipIfStatsInMcastPkts; + /* # transmitted multicast packets { ipIfStatsEntry 38 } */ + Counter ipIfStatsOutMcastPkts; + + /* + * In addition to defined MIBs + */ + + /* # discarded due to no route to dest { ipSystemStatsEntry 22 } */ + Counter ipIfStatsOutNoRoutes; + /* # of complete duplicates in reassembly */ + Counter ipIfStatsReasmDuplicates; + /* # of partial duplicates in reassembly */ + Counter ipIfStatsReasmPartDups; + /* # of packets not forwarded due to adminstrative reasons */ + Counter ipIfStatsForwProhibits; + /* # of UDP packets with bad UDP checksums */ + Counter udpInCksumErrs; +#define udpIfStatsInCksumErrs udpInCksumErrs + /* # of UDP packets droped due to queue overflow */ + Counter udpInOverflows; +#define udpIfStatsInOverflows udpInOverflows + /* + * # of RAW IP packets (all IP protocols except UDP, TCP + * and ICMP) droped due to queue overflow + */ + Counter rawipInOverflows; +#define rawipIfStatsInOverflows rawipInOverflows + + /* + * # of IP packets received with the wrong version (i.e., not equal + * to ipIfStatsIPVersion) and that were dropped. + */ + Counter ipIfStatsInWrongIPVersion; + /* + * This counter is no longer used + */ + Counter ipIfStatsOutWrongIPVersion; + /* + * This counter is no longer used + */ + Counter ipIfStatsOutSwitchIPVersion; + + /* + * Fields defined in RFC 4293 + */ + + /* ip version { ipIfStatsEntry 1 } */ + int ipIfStatsIPVersion; + /* # input datagrams (incl errors) { ipIfStatsEntry 4 } */ + Counter64 ipIfStatsHCInReceives; + /* # input octets (incl errors) { ipIfStatsEntry 6 } */ + Counter64 ipIfStatsHCInOctets; + /* + * { ipIfStatsEntry 13 } + * # input datagrams for which a forwarding attempt was made + */ + Counter64 ipIfStatsHCInForwDatagrams; + /* # delivered to upper layer protocols { ipIfStatsEntry 19 } */ + Counter64 ipIfStatsHCInDelivers; + /* # originated out interface { ipIfStatsEntry 21 } */ + Counter64 ipIfStatsHCOutRequests; + /* # forwarded out interface { ipIfStatsEntry 23 } */ + Counter64 ipIfStatsHCOutForwDatagrams; + /* # dg's requiring fragmentation { ipIfStatsEntry 26 } */ + Counter ipIfStatsOutFragReqds; + /* # output datagrams { ipIfStatsEntry 31 } */ + Counter64 ipIfStatsHCOutTransmits; + /* # output octets { ipIfStatsEntry 33 } */ + Counter64 ipIfStatsHCOutOctets; + /* # received multicast datagrams { ipIfStatsEntry 35 } */ + Counter64 ipIfStatsHCInMcastPkts; + /* # received multicast octets { ipIfStatsEntry 37 } */ + Counter64 ipIfStatsHCInMcastOctets; + /* # transmitted multicast datagrams { ipIfStatsEntry 39 } */ + Counter64 ipIfStatsHCOutMcastPkts; + /* # transmitted multicast octets { ipIfStatsEntry 41 } */ + Counter64 ipIfStatsHCOutMcastOctets; + /* # received broadcast datagrams { ipIfStatsEntry 43 } */ + Counter64 ipIfStatsHCInBcastPkts; + /* # transmitted broadcast datagrams { ipIfStatsEntry 45 } */ + Counter64 ipIfStatsHCOutBcastPkts; + + /* + * Fields defined in mib2_ip_t + */ + + /* # of incoming packets that succeeded policy checks */ + Counter ipsecInSucceeded; +#define ipsecIfStatsInSucceeded ipsecInSucceeded + /* # of incoming packets that failed policy checks */ + Counter ipsecInFailed; +#define ipsecIfStatsInFailed ipsecInFailed + /* # of bad IP header checksums */ + Counter ipInCksumErrs; +#define ipIfStatsInCksumErrs ipInCksumErrs + /* total # of segments recv'd with error { tcp 14 } */ + Counter tcpInErrs; +#define tcpIfStatsInErrs tcpInErrs + /* # of recv'd dg's not deliverable (no appl.) { udp 2 } */ + Counter udpNoPorts; +#define udpIfStatsNoPorts udpNoPorts +} mib2_ipIfStatsEntry_t; +#define MIB_FIRST_NEW_ELM_mib2_ipIfStatsEntry_t ipIfStatsIPVersion + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * The IP address table contains this entity's IP addressing information. + * + * ipAddrTable OBJECT-TYPE + * SYNTAX SEQUENCE OF IpAddrEntry + * ACCESS not-accessible + * STATUS mandatory + * DESCRIPTION + * "The table of addressing information relevant to + * this entity's IP addresses." + * ::= { ip 20 } + */ + +typedef struct mib2_ipAddrEntry { + /* IP address of this entry {ipAddrEntry 1} */ + IpAddress ipAdEntAddr; + /* Unique interface index {ipAddrEntry 2} */ + DeviceName ipAdEntIfIndex; + /* Subnet mask for this IP addr {ipAddrEntry 3} */ + IpAddress ipAdEntNetMask; + /* 2^lsb of IP broadcast addr {ipAddrEntry 4} */ + int ipAdEntBcastAddr; + /* max size for dg reassembly {ipAddrEntry 5} */ + int ipAdEntReasmMaxSize; + /* additional ipif_t fields */ + struct ipAdEntInfo_s { + Gauge ae_mtu; + /* BSD if metric */ + int ae_metric; + /* ipif broadcast addr. relation to above?? */ + IpAddress ae_broadcast_addr; + /* point-point dest addr */ + IpAddress ae_pp_dst_addr; + int ae_flags; /* IFF_* flags in if.h */ + Counter ae_ibcnt; /* Inbound packets */ + Counter ae_obcnt; /* Outbound packets */ + Counter ae_focnt; /* Forwarded packets */ + IpAddress ae_subnet; /* Subnet prefix */ + int ae_subnet_len; /* Subnet prefix length */ + IpAddress ae_src_addr; /* Source address */ + } ipAdEntInfo; + uint32_t ipAdEntRetransmitTime; /* ipInterfaceRetransmitTime */ +} mib2_ipAddrEntry_t; +#define MIB_FIRST_NEW_ELM_mib2_ipAddrEntry_t ipAdEntRetransmitTime + +/* + * ipv6AddrTable OBJECT-TYPE + * SYNTAX SEQUENCE OF Ipv6AddrEntry + * MAX-ACCESS not-accessible + * STATUS current + * DESCRIPTION + * "The table of addressing information relevant to + * this node's interface addresses." + * ::= { ipv6MIBObjects 8 } + */ + +typedef struct mib2_ipv6AddrEntry { + /* Unique interface index { Part of INDEX } */ + DeviceName ipv6AddrIfIndex; + + /* IPv6 address of this entry { ipv6AddrEntry 1 } */ + Ip6Address ipv6AddrAddress; + /* Prefix length { ipv6AddrEntry 2 } */ + uint_t ipv6AddrPfxLength; + /* Type: stateless(1), stateful(2), unknown(3) { ipv6AddrEntry 3 } */ + uint_t ipv6AddrType; + /* Anycast: true(1), false(2) { ipv6AddrEntry 4 } */ + uint_t ipv6AddrAnycastFlag; + /* + * Address status: preferred(1), deprecated(2), invalid(3), + * inaccessible(4), unknown(5) { ipv6AddrEntry 5 } + */ + uint_t ipv6AddrStatus; + struct ipv6AddrInfo_s { + Gauge ae_mtu; + /* BSD if metric */ + int ae_metric; + /* point-point dest addr */ + Ip6Address ae_pp_dst_addr; + int ae_flags; /* IFF_* flags in if.h */ + Counter ae_ibcnt; /* Inbound packets */ + Counter ae_obcnt; /* Outbound packets */ + Counter ae_focnt; /* Forwarded packets */ + Ip6Address ae_subnet; /* Subnet prefix */ + int ae_subnet_len; /* Subnet prefix length */ + Ip6Address ae_src_addr; /* Source address */ + } ipv6AddrInfo; + uint32_t ipv6AddrReasmMaxSize; /* InterfaceReasmMaxSize */ + Ip6Address ipv6AddrIdentifier; /* InterfaceIdentifier */ + uint32_t ipv6AddrIdentifierLen; + uint32_t ipv6AddrReachableTime; /* InterfaceReachableTime */ + uint32_t ipv6AddrRetransmitTime; /* InterfaceRetransmitTime */ +} mib2_ipv6AddrEntry_t; +#define MIB_FIRST_NEW_ELM_mib2_ipv6AddrEntry_t ipv6AddrReasmMaxSize + +/* + * The IP routing table contains an entry for each route presently known to + * this entity. (for IPv4 routes) + * + * ipRouteTable OBJECT-TYPE + * SYNTAX SEQUENCE OF IpRouteEntry + * ACCESS not-accessible + * STATUS mandatory + * DESCRIPTION + * "This entity's IP Routing table." + * ::= { ip 21 } + */ + +typedef struct mib2_ipRouteEntry { + /* dest ip addr for this route {ipRouteEntry 1 } RW */ + IpAddress ipRouteDest; + /* unique interface index for this hop {ipRouteEntry 2 } RW */ + DeviceName ipRouteIfIndex; + /* primary route metric {ipRouteEntry 3 } RW */ + int ipRouteMetric1; + /* alternate route metric {ipRouteEntry 4 } RW */ + int ipRouteMetric2; + /* alternate route metric {ipRouteEntry 5 } RW */ + int ipRouteMetric3; + /* alternate route metric {ipRouteEntry 6 } RW */ + int ipRouteMetric4; + /* ip addr of next hop on this route {ipRouteEntry 7 } RW */ + IpAddress ipRouteNextHop; + /* other(1), inval(2), dir(3), indir(4) {ipRouteEntry 8 } RW */ + int ipRouteType; + /* mechanism by which route was learned {ipRouteEntry 9 } */ + int ipRouteProto; + /* sec's since last update of route {ipRouteEntry 10} RW */ + int ipRouteAge; + /* {ipRouteEntry 11} RW */ + IpAddress ipRouteMask; + /* alternate route metric {ipRouteEntry 12} RW */ + int ipRouteMetric5; + /* additional info from ire's {ipRouteEntry 13 } */ + struct ipRouteInfo_s { + Gauge re_max_frag; + Gauge re_rtt; + Counter re_ref; + int re_frag_flag; + IpAddress re_src_addr; + int re_ire_type; + Counter re_obpkt; + Counter re_ibpkt; + int re_flags; + /* + * The following two elements (re_in_ill and re_in_src_addr) + * are no longer used but are left here for the benefit of + * old Apps that won't be able to handle the change in the + * size of this struct. These elements will always be + * set to zeroes. + */ + DeviceName re_in_ill; /* Input interface */ + IpAddress re_in_src_addr; /* Input source address */ + } ipRouteInfo; +} mib2_ipRouteEntry_t; + +/* + * The IPv6 routing table contains an entry for each route presently known to + * this entity. + * + * ipv6RouteTable OBJECT-TYPE + * SYNTAX SEQUENCE OF IpRouteEntry + * ACCESS not-accessible + * STATUS current + * DESCRIPTION + * "IPv6 Routing table. This table contains + * an entry for each valid IPv6 unicast route + * that can be used for packet forwarding + * determination." + * ::= { ipv6MIBObjects 11 } + */ + +typedef struct mib2_ipv6RouteEntry { + /* dest ip addr for this route { ipv6RouteEntry 1 } */ + Ip6Address ipv6RouteDest; + /* prefix length { ipv6RouteEntry 2 } */ + int ipv6RoutePfxLength; + /* unique route index { ipv6RouteEntry 3 } */ + unsigned ipv6RouteIndex; + /* unique interface index for this hop { ipv6RouteEntry 4 } */ + DeviceName ipv6RouteIfIndex; + /* IPv6 addr of next hop on this route { ipv6RouteEntry 5 } */ + Ip6Address ipv6RouteNextHop; + /* other(1), discard(2), local(3), remote(4) */ + /* { ipv6RouteEntry 6 } */ + int ipv6RouteType; + /* mechanism by which route was learned { ipv6RouteEntry 7 } */ + /* + * other(1), local(2), netmgmt(3), ndisc(4), rip(5), ospf(6), + * bgp(7), idrp(8), igrp(9) + */ + int ipv6RouteProtocol; + /* policy hook or traffic class { ipv6RouteEntry 8 } */ + unsigned ipv6RoutePolicy; + /* sec's since last update of route { ipv6RouteEntry 9} */ + int ipv6RouteAge; + /* Routing domain ID of the next hop { ipv6RouteEntry 10 } */ + unsigned ipv6RouteNextHopRDI; + /* route metric { ipv6RouteEntry 11 } */ + unsigned ipv6RouteMetric; + /* preference (impl specific) { ipv6RouteEntry 12 } */ + unsigned ipv6RouteWeight; + /* additional info from ire's { } */ + struct ipv6RouteInfo_s { + Gauge re_max_frag; + Gauge re_rtt; + Counter re_ref; + int re_frag_flag; + Ip6Address re_src_addr; + int re_ire_type; + Counter re_obpkt; + Counter re_ibpkt; + int re_flags; + } ipv6RouteInfo; +} mib2_ipv6RouteEntry_t; + +/* + * The IPv4 and IPv6 routing table entries on a trusted system also have + * security attributes in the form of label ranges. This experimental + * interface provides information about these labels. + * + * Each entry in this table contains a label range and an index that refers + * back to the entry in the routing table to which it applies. There may be 0, + * 1, or many label ranges for each routing table entry. + * + * (opthdr.level is set to MIB2_IP for IPv4 entries and MIB2_IP6 for IPv6. + * opthdr.name is set to EXPER_IP_GWATTR.) + * + * ipRouteAttributeTable OBJECT-TYPE + * SYNTAX SEQUENCE OF IpAttributeEntry + * ACCESS not-accessible + * STATUS current + * DESCRIPTION + * "IPv4 routing attributes table. This table contains + * an entry for each valid trusted label attached to a + * route in the system." + * ::= { ip 102 } + * + * ipv6RouteAttributeTable OBJECT-TYPE + * SYNTAX SEQUENCE OF IpAttributeEntry + * ACCESS not-accessible + * STATUS current + * DESCRIPTION + * "IPv6 routing attributes table. This table contains + * an entry for each valid trusted label attached to a + * route in the system." + * ::= { ip6 102 } + */ + +typedef struct mib2_ipAttributeEntry { + uint_t iae_routeidx; + int iae_doi; + brange_t iae_slrange; +} mib2_ipAttributeEntry_t; + +/* + * The IP address translation table contain the IpAddress to + * `physical' address equivalences. Some interfaces do not + * use translation tables for determining address + * equivalences (e.g., DDN-X.25 has an algorithmic method); + * if all interfaces are of this type, then the Address + * Translation table is empty, i.e., has zero entries. + * + * ipNetToMediaTable OBJECT-TYPE + * SYNTAX SEQUENCE OF IpNetToMediaEntry + * ACCESS not-accessible + * STATUS mandatory + * DESCRIPTION + * "The IP Address Translation table used for mapping + * from IP addresses to physical addresses." + * ::= { ip 22 } + */ + +typedef struct mib2_ipNetToMediaEntry { + /* Unique interface index { ipNetToMediaEntry 1 } RW */ + DeviceName ipNetToMediaIfIndex; + /* Media dependent physical addr { ipNetToMediaEntry 2 } RW */ + PhysAddress ipNetToMediaPhysAddress; + /* ip addr for this physical addr { ipNetToMediaEntry 3 } RW */ + IpAddress ipNetToMediaNetAddress; + /* other(1), inval(2), dyn(3), stat(4) { ipNetToMediaEntry 4 } RW */ + int ipNetToMediaType; + struct ipNetToMediaInfo_s { + PhysAddress ntm_mask; /* subnet mask for entry */ + int ntm_flags; /* ACE_F_* flags in arp.h */ + } ipNetToMediaInfo; +} mib2_ipNetToMediaEntry_t; + +/* + * ipv6NetToMediaTable OBJECT-TYPE + * SYNTAX SEQUENCE OF Ipv6NetToMediaEntry + * MAX-ACCESS not-accessible + * STATUS current + * DESCRIPTION + * "The IPv6 Address Translation table used for + * mapping from IPv6 addresses to physical addresses. + * + * The IPv6 address translation table contain the + * Ipv6Address to `physical' address equivalencies. + * Some interfaces do not use translation tables + * for determining address equivalencies; if all + * interfaces are of this type, then the Address + * Translation table is empty, i.e., has zero + * entries." + * ::= { ipv6MIBObjects 12 } + */ + +typedef struct mib2_ipv6NetToMediaEntry { + /* Unique interface index { Part of INDEX } */ + DeviceIndex ipv6NetToMediaIfIndex; + + /* ip addr for this physical addr { ipv6NetToMediaEntry 1 } */ + Ip6Address ipv6NetToMediaNetAddress; + /* Media dependent physical addr { ipv6NetToMediaEntry 2 } */ + PhysAddress ipv6NetToMediaPhysAddress; + /* + * Type of mapping + * other(1), dynamic(2), static(3), local(4) + * { ipv6NetToMediaEntry 3 } + */ + int ipv6NetToMediaType; + /* + * NUD state + * reachable(1), stale(2), delay(3), probe(4), invalid(5), unknown(6) + * Note: The kernel returns ND_* states. + * { ipv6NetToMediaEntry 4 } + */ + int ipv6NetToMediaState; + /* sysUpTime last time entry was updated { ipv6NetToMediaEntry 5 } */ + int ipv6NetToMediaLastUpdated; +} mib2_ipv6NetToMediaEntry_t; + + +/* + * List of group members per interface + */ +typedef struct ip_member { + /* Interface index */ + DeviceName ipGroupMemberIfIndex; + /* IP Multicast address */ + IpAddress ipGroupMemberAddress; + /* Number of member sockets */ + Counter ipGroupMemberRefCnt; + /* Filter mode: 1 => include, 2 => exclude */ + int ipGroupMemberFilterMode; +} ip_member_t; + + +/* + * List of IPv6 group members per interface + */ +typedef struct ipv6_member { + /* Interface index */ + DeviceIndex ipv6GroupMemberIfIndex; + /* IP Multicast address */ + Ip6Address ipv6GroupMemberAddress; + /* Number of member sockets */ + Counter ipv6GroupMemberRefCnt; + /* Filter mode: 1 => include, 2 => exclude */ + int ipv6GroupMemberFilterMode; +} ipv6_member_t; + +/* + * This is used to mark transport layer entities (e.g., TCP connections) that + * are capable of receiving packets from a range of labels. 'level' is set to + * the protocol of interest (e.g., MIB2_TCP), and 'name' is set to + * EXPER_XPORT_MLP. The tme_connidx refers back to the entry in MIB2_TCP_CONN, + * MIB2_TCP6_CONN, or MIB2_SCTP_CONN. + * + * It is also used to report connections that receive packets at a single label + * that's other than the zone's label. This is the case when a TCP connection + * is accepted from a particular peer using an MLP listener. + */ +typedef struct mib2_transportMLPEntry { + uint_t tme_connidx; + uint_t tme_flags; + int tme_doi; + bslabel_t tme_label; +} mib2_transportMLPEntry_t; + +/* + * This is not part of mib2 but is used to communicate additional information + * about a socket alongside the mib2 data. This is used by netstat to + * associate sockets with processes that are connected to them. + */ + +#define MIB2_SOCKINFO_STREAM 0x1 +#define MIB2_SOCKINFO_IPV6 0x2 /* IPV6 entry in an IPv4 table */ + +typedef struct mib2_socketInfoEntry { + uint64_t sie_connidx; + uint64_t sie_inode; + uint64_t sie_flags; + uint64_t sie_dev; +} mib2_socketInfoEntry_t; + +#define MIB2_TMEF_PRIVATE 0x00000001 /* MLP on private addresses */ +#define MIB2_TMEF_SHARED 0x00000002 /* MLP on shared addresses */ +#define MIB2_TMEF_ANONMLP 0x00000004 /* Anonymous MLP port */ +#define MIB2_TMEF_MACEXEMPT 0x00000008 /* MAC-Exempt port */ +#define MIB2_TMEF_IS_LABELED 0x00000010 /* tme_doi & tme_label exists */ +#define MIB2_TMEF_MACIMPLICIT 0x00000020 /* MAC-Implicit */ +/* + * List of IPv4 source addresses being filtered per interface + */ +typedef struct ip_grpsrc { + /* Interface index */ + DeviceName ipGroupSourceIfIndex; + /* IP Multicast address */ + IpAddress ipGroupSourceGroup; + /* IP Source address */ + IpAddress ipGroupSourceAddress; +} ip_grpsrc_t; + + +/* + * List of IPv6 source addresses being filtered per interface + */ +typedef struct ipv6_grpsrc { + /* Interface index */ + DeviceIndex ipv6GroupSourceIfIndex; + /* IP Multicast address */ + Ip6Address ipv6GroupSourceGroup; + /* IP Source address */ + Ip6Address ipv6GroupSourceAddress; +} ipv6_grpsrc_t; + + +/* + * List of destination cache entries + */ +typedef struct dest_cache_entry { + /* IP Multicast address */ + IpAddress DestIpv4Address; + Ip6Address DestIpv6Address; + uint_t DestFlags; /* DCEF_* */ + uint32_t DestPmtu; /* Path MTU if DCEF_PMTU */ + uint32_t DestIdent; /* Per destination IP ident. */ + DeviceIndex DestIfindex; /* For IPv6 link-locals */ + uint32_t DestAge; /* Age of MTU info in seconds */ +} dest_cache_entry_t; + + +/* + * ICMP Group + */ +typedef struct mib2_icmp { + /* total # of recv'd ICMP msgs { icmp 1 } */ + Counter icmpInMsgs; + /* recv'd ICMP msgs with errors { icmp 2 } */ + Counter icmpInErrors; + /* recv'd "dest unreachable" msg's { icmp 3 } */ + Counter icmpInDestUnreachs; + /* recv'd "time exceeded" msg's { icmp 4 } */ + Counter icmpInTimeExcds; + /* recv'd "parameter problem" msg's { icmp 5 } */ + Counter icmpInParmProbs; + /* recv'd "source quench" msg's { icmp 6 } */ + Counter icmpInSrcQuenchs; + /* recv'd "ICMP redirect" msg's { icmp 7 } */ + Counter icmpInRedirects; + /* recv'd "echo request" msg's { icmp 8 } */ + Counter icmpInEchos; + /* recv'd "echo reply" msg's { icmp 9 } */ + Counter icmpInEchoReps; + /* recv'd "timestamp" msg's { icmp 10 } */ + Counter icmpInTimestamps; + /* recv'd "timestamp reply" msg's { icmp 11 } */ + Counter icmpInTimestampReps; + /* recv'd "address mask request" msg's { icmp 12 } */ + Counter icmpInAddrMasks; + /* recv'd "address mask reply" msg's { icmp 13 } */ + Counter icmpInAddrMaskReps; + /* total # of sent ICMP msg's { icmp 14 } */ + Counter icmpOutMsgs; + /* # of msg's not sent for internal icmp errors { icmp 15 } */ + Counter icmpOutErrors; + /* # of "dest unreachable" msg's sent { icmp 16 } */ + Counter icmpOutDestUnreachs; + /* # of "time exceeded" msg's sent { icmp 17 } */ + Counter icmpOutTimeExcds; + /* # of "parameter problme" msg's sent { icmp 18 } */ + Counter icmpOutParmProbs; + /* # of "source quench" msg's sent { icmp 19 } */ + Counter icmpOutSrcQuenchs; + /* # of "ICMP redirect" msg's sent { icmp 20 } */ + Counter icmpOutRedirects; + /* # of "Echo request" msg's sent { icmp 21 } */ + Counter icmpOutEchos; + /* # of "Echo reply" msg's sent { icmp 22 } */ + Counter icmpOutEchoReps; + /* # of "timestamp request" msg's sent { icmp 23 } */ + Counter icmpOutTimestamps; + /* # of "timestamp reply" msg's sent { icmp 24 } */ + Counter icmpOutTimestampReps; + /* # of "address mask request" msg's sent { icmp 25 } */ + Counter icmpOutAddrMasks; + /* # of "address mask reply" msg's sent { icmp 26 } */ + Counter icmpOutAddrMaskReps; +/* + * In addition to MIB-II + */ + /* # of received packets with checksum errors */ + Counter icmpInCksumErrs; + /* # of received packets with unknow codes */ + Counter icmpInUnknowns; + /* # of received unreachables with "fragmentation needed" */ + Counter icmpInFragNeeded; + /* # of sent unreachables with "fragmentation needed" */ + Counter icmpOutFragNeeded; + /* + * # of msg's not sent since original packet was broadcast/multicast + * or an ICMP error packet + */ + Counter icmpOutDrops; + /* # of ICMP packets droped due to queue overflow */ + Counter icmpInOverflows; + /* recv'd "ICMP redirect" msg's that are bad thus ignored */ + Counter icmpInBadRedirects; +} mib2_icmp_t; + + +/* + * ipv6IfIcmpEntry OBJECT-TYPE + * SYNTAX Ipv6IfIcmpEntry + * MAX-ACCESS not-accessible + * STATUS current + * DESCRIPTION + * "An ICMPv6 statistics entry containing + * objects at a particular IPv6 interface. + * + * Note that a receiving interface is + * the interface to which a given ICMPv6 message + * is addressed which may not be necessarily + * the input interface for the message. + * + * Similarly, the sending interface is + * the interface that sources a given + * ICMP message which is usually but not + * necessarily the output interface for the message." + * AUGMENTS { ipv6IfEntry } + * ::= { ipv6IfIcmpTable 1 } + * + * Per-interface ICMPv6 statistics table + */ + +typedef struct mib2_ipv6IfIcmpEntry { + /* Local ifindex to identify the interface */ + DeviceIndex ipv6IfIcmpIfIndex; + + int ipv6IfIcmpEntrySize; /* Size of ipv6IfIcmpEntry */ + + /* The total # ICMP msgs rcvd includes ipv6IfIcmpInErrors */ + Counter32 ipv6IfIcmpInMsgs; + /* # ICMP with ICMP-specific errors (bad checkum, length, etc) */ + Counter32 ipv6IfIcmpInErrors; + /* # ICMP Destination Unreachable */ + Counter32 ipv6IfIcmpInDestUnreachs; + /* # ICMP destination unreachable/communication admin prohibited */ + Counter32 ipv6IfIcmpInAdminProhibs; + Counter32 ipv6IfIcmpInTimeExcds; + Counter32 ipv6IfIcmpInParmProblems; + Counter32 ipv6IfIcmpInPktTooBigs; + Counter32 ipv6IfIcmpInEchos; + Counter32 ipv6IfIcmpInEchoReplies; + Counter32 ipv6IfIcmpInRouterSolicits; + Counter32 ipv6IfIcmpInRouterAdvertisements; + Counter32 ipv6IfIcmpInNeighborSolicits; + Counter32 ipv6IfIcmpInNeighborAdvertisements; + Counter32 ipv6IfIcmpInRedirects; + Counter32 ipv6IfIcmpInGroupMembQueries; + Counter32 ipv6IfIcmpInGroupMembResponses; + Counter32 ipv6IfIcmpInGroupMembReductions; + /* Total # ICMP messages attempted to send (includes OutErrors) */ + Counter32 ipv6IfIcmpOutMsgs; + /* # ICMP messages not sent due to ICMP problems (e.g. no buffers) */ + Counter32 ipv6IfIcmpOutErrors; + Counter32 ipv6IfIcmpOutDestUnreachs; + Counter32 ipv6IfIcmpOutAdminProhibs; + Counter32 ipv6IfIcmpOutTimeExcds; + Counter32 ipv6IfIcmpOutParmProblems; + Counter32 ipv6IfIcmpOutPktTooBigs; + Counter32 ipv6IfIcmpOutEchos; + Counter32 ipv6IfIcmpOutEchoReplies; + Counter32 ipv6IfIcmpOutRouterSolicits; + Counter32 ipv6IfIcmpOutRouterAdvertisements; + Counter32 ipv6IfIcmpOutNeighborSolicits; + Counter32 ipv6IfIcmpOutNeighborAdvertisements; + Counter32 ipv6IfIcmpOutRedirects; + Counter32 ipv6IfIcmpOutGroupMembQueries; + Counter32 ipv6IfIcmpOutGroupMembResponses; + Counter32 ipv6IfIcmpOutGroupMembReductions; +/* Additions beyond the MIB */ + Counter32 ipv6IfIcmpInOverflows; + /* recv'd "ICMPv6 redirect" msg's that are bad thus ignored */ + Counter32 ipv6IfIcmpBadHoplimit; + Counter32 ipv6IfIcmpInBadNeighborAdvertisements; + Counter32 ipv6IfIcmpInBadNeighborSolicitations; + Counter32 ipv6IfIcmpInBadRedirects; + Counter32 ipv6IfIcmpInGroupMembTotal; + Counter32 ipv6IfIcmpInGroupMembBadQueries; + Counter32 ipv6IfIcmpInGroupMembBadReports; + Counter32 ipv6IfIcmpInGroupMembOurReports; +} mib2_ipv6IfIcmpEntry_t; + +/* + * the TCP group + * + * Note that instances of object types that represent + * information about a particular TCP connection are + * transient; they persist only as long as the connection + * in question. + */ +#define MIB2_TCP_CONN 13 /* tcpConnEntry */ +#define MIB2_TCP6_CONN 14 /* tcp6ConnEntry */ + +/* Old name retained for compatibility */ +#define MIB2_TCP_13 MIB2_TCP_CONN + +/* Pack data in mib2_tcp to make struct size the same for 32- and 64-bits */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif +typedef struct mib2_tcp { + /* algorithm used for transmit timeout value { tcp 1 } */ + int tcpRtoAlgorithm; + /* minimum retransmit timeout (ms) { tcp 2 } */ + int tcpRtoMin; + /* maximum retransmit timeout (ms) { tcp 3 } */ + int tcpRtoMax; + /* maximum # of connections supported { tcp 4 } */ + int tcpMaxConn; + /* # of direct transitions CLOSED -> SYN-SENT { tcp 5 } */ + Counter tcpActiveOpens; + /* # of direct transitions LISTEN -> SYN-RCVD { tcp 6 } */ + Counter tcpPassiveOpens; + /* # of direct SIN-SENT/RCVD -> CLOSED/LISTEN { tcp 7 } */ + Counter tcpAttemptFails; + /* # of direct ESTABLISHED/CLOSE-WAIT -> CLOSED { tcp 8 } */ + Counter tcpEstabResets; + /* # of connections ESTABLISHED or CLOSE-WAIT { tcp 9 } */ + Gauge tcpCurrEstab; + /* total # of segments recv'd { tcp 10 } */ + Counter tcpInSegs; + /* total # of segments sent { tcp 11 } */ + Counter tcpOutSegs; + /* total # of segments retransmitted { tcp 12 } */ + Counter tcpRetransSegs; + /* {tcp 13} */ + int tcpConnTableSize; /* Size of tcpConnEntry_t */ + /* in ip {tcp 14} */ + /* # of segments sent with RST flag { tcp 15 } */ + Counter tcpOutRsts; +/* In addition to MIB-II */ +/* Sender */ + /* total # of data segments sent */ + Counter tcpOutDataSegs; + /* total # of bytes in data segments sent */ + Counter tcpOutDataBytes; + /* total # of bytes in segments retransmitted */ + Counter tcpRetransBytes; + /* total # of acks sent */ + Counter tcpOutAck; + /* total # of delayed acks sent */ + Counter tcpOutAckDelayed; + /* total # of segments sent with the urg flag on */ + Counter tcpOutUrg; + /* total # of window updates sent */ + Counter tcpOutWinUpdate; + /* total # of zero window probes sent */ + Counter tcpOutWinProbe; + /* total # of control segments sent (syn, fin, rst) */ + Counter tcpOutControl; + /* total # of segments sent due to "fast retransmit" */ + Counter tcpOutFastRetrans; +/* Receiver */ + /* total # of ack segments received */ + Counter tcpInAckSegs; + /* total # of bytes acked */ + Counter tcpInAckBytes; + /* total # of duplicate acks */ + Counter tcpInDupAck; + /* total # of acks acking unsent data */ + Counter tcpInAckUnsent; + /* total # of data segments received in order */ + Counter tcpInDataInorderSegs; + /* total # of data bytes received in order */ + Counter tcpInDataInorderBytes; + /* total # of data segments received out of order */ + Counter tcpInDataUnorderSegs; + /* total # of data bytes received out of order */ + Counter tcpInDataUnorderBytes; + /* total # of complete duplicate data segments received */ + Counter tcpInDataDupSegs; + /* total # of bytes in the complete duplicate data segments received */ + Counter tcpInDataDupBytes; + /* total # of partial duplicate data segments received */ + Counter tcpInDataPartDupSegs; + /* total # of bytes in the partial duplicate data segments received */ + Counter tcpInDataPartDupBytes; + /* total # of data segments received past the window */ + Counter tcpInDataPastWinSegs; + /* total # of data bytes received part the window */ + Counter tcpInDataPastWinBytes; + /* total # of zero window probes received */ + Counter tcpInWinProbe; + /* total # of window updates received */ + Counter tcpInWinUpdate; + /* total # of data segments received after the connection has closed */ + Counter tcpInClosed; +/* Others */ + /* total # of failed attempts to update the rtt estimate */ + Counter tcpRttNoUpdate; + /* total # of successful attempts to update the rtt estimate */ + Counter tcpRttUpdate; + /* total # of retransmit timeouts */ + Counter tcpTimRetrans; + /* total # of retransmit timeouts dropping the connection */ + Counter tcpTimRetransDrop; + /* total # of keepalive timeouts */ + Counter tcpTimKeepalive; + /* total # of keepalive timeouts sending a probe */ + Counter tcpTimKeepaliveProbe; + /* total # of keepalive timeouts dropping the connection */ + Counter tcpTimKeepaliveDrop; + /* total # of connections refused due to backlog full on listen */ + Counter tcpListenDrop; + /* total # of connections refused due to half-open queue (q0) full */ + Counter tcpListenDropQ0; + /* total # of connections dropped from a full half-open queue (q0) */ + Counter tcpHalfOpenDrop; + /* total # of retransmitted segments by SACK retransmission */ + Counter tcpOutSackRetransSegs; + + int tcp6ConnTableSize; /* Size of tcp6ConnEntry_t */ + + /* + * fields from RFC 4022 + */ + + /* total # of segments recv'd { tcp 17 } */ + Counter64 tcpHCInSegs; + /* total # of segments sent { tcp 18 } */ + Counter64 tcpHCOutSegs; +} mib2_tcp_t; +#define MIB_FIRST_NEW_ELM_mib2_tcp_t tcpHCInSegs + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * The TCP/IPv4 connection table {tcp 13} contains information about this + * entity's existing TCP connections over IPv4. + */ +/* For tcpConnState and tcp6ConnState */ +#define MIB2_TCP_closed 1 +#define MIB2_TCP_listen 2 +#define MIB2_TCP_synSent 3 +#define MIB2_TCP_synReceived 4 +#define MIB2_TCP_established 5 +#define MIB2_TCP_finWait1 6 +#define MIB2_TCP_finWait2 7 +#define MIB2_TCP_closeWait 8 +#define MIB2_TCP_lastAck 9 +#define MIB2_TCP_closing 10 +#define MIB2_TCP_timeWait 11 +#define MIB2_TCP_deleteTCB 12 /* only writeable value */ + +/* Pack data to make struct size the same for 32- and 64-bits */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct tcpConnEntryInfo_s { + Counter64 ce_in_data_inorder_bytes; + Counter64 ce_in_data_inorder_segs; + Counter64 ce_in_data_unorder_bytes; + Counter64 ce_in_data_unorder_segs; + Counter64 ce_in_zwnd_probes; + + Counter64 ce_out_data_bytes; + Counter64 ce_out_data_segs; + Counter64 ce_out_retrans_bytes; + Counter64 ce_out_retrans_segs; + Counter64 ce_out_zwnd_probes; + Counter64 ce_rtt_sum; + + /* seq # of next segment to send */ + Gauge ce_snxt; + /* seq # of of last segment unacknowledged */ + Gauge ce_suna; + /* current send window size */ + Gauge ce_swnd; + /* current congestion window size */ + Gauge ce_cwnd; + /* seq # of next expected segment */ + Gauge ce_rnxt; + /* seq # of last ack'd segment */ + Gauge ce_rack; + /* # of unsent bytes in the xmit queue */ + Gauge ce_unsent; + /* current receive window size */ + Gauge ce_rwnd; + /* round-trip time smoothed average (us) */ + Gauge ce_rtt_sa; + /* current rto (retransmit timeout) */ + Gauge ce_rto; + /* round-trip time count */ + Gauge ce_rtt_cnt; + /* current max segment size */ + Gauge ce_mss; + /* actual internal state */ + int ce_state; +} tcpConnEntryInfo_t; + +typedef struct mib2_tcpConnEntry { + /* state of tcp connection { tcpConnEntry 1} RW */ + int tcpConnState; + /* local ip addr for this connection { tcpConnEntry 2 } */ + IpAddress tcpConnLocalAddress; + /* local port for this connection { tcpConnEntry 3 } */ + int tcpConnLocalPort; /* In host byte order */ + /* remote ip addr for this connection { tcpConnEntry 4 } */ + IpAddress tcpConnRemAddress; + /* remote port for this connection { tcpConnEntry 5 } */ + int tcpConnRemPort; /* In host byte order */ + tcpConnEntryInfo_t tcpConnEntryInfo; + + /* pid of the processes that created this connection */ + uint32_t tcpConnCreationProcess; + /* system uptime when the connection was created */ + uint64_t tcpConnCreationTime; +} mib2_tcpConnEntry_t; +#define MIB_FIRST_NEW_ELM_mib2_tcpConnEntry_t tcpConnCreationProcess + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + + +/* + * The TCP/IPv6 connection table {tcp 14} contains information about this + * entity's existing TCP connections over IPv6. + */ + +/* Pack data to make struct size the same for 32- and 64-bits */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif +typedef struct mib2_tcp6ConnEntry { + /* local ip addr for this connection { ipv6TcpConnEntry 1 } */ + Ip6Address tcp6ConnLocalAddress; + /* local port for this connection { ipv6TcpConnEntry 2 } */ + int tcp6ConnLocalPort; + /* remote ip addr for this connection { ipv6TcpConnEntry 3 } */ + Ip6Address tcp6ConnRemAddress; + /* remote port for this connection { ipv6TcpConnEntry 4 } */ + int tcp6ConnRemPort; + /* interface index or zero { ipv6TcpConnEntry 5 } */ + DeviceIndex tcp6ConnIfIndex; + /* state of tcp6 connection { ipv6TcpConnEntry 6 } RW */ + int tcp6ConnState; + tcpConnEntryInfo_t tcp6ConnEntryInfo; + + /* pid of the processes that created this connection */ + uint32_t tcp6ConnCreationProcess; + /* system uptime when the connection was created */ + uint64_t tcp6ConnCreationTime; +} mib2_tcp6ConnEntry_t; +#define MIB_FIRST_NEW_ELM_mib2_tcp6ConnEntry_t tcp6ConnCreationProcess + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * the UDP group + */ +#define MIB2_UDP_ENTRY 5 /* udpEntry */ +#define MIB2_UDP6_ENTRY 6 /* udp6Entry */ + +/* Old name retained for compatibility */ +#define MIB2_UDP_5 MIB2_UDP_ENTRY + +/* Pack data to make struct size the same for 32- and 64-bits */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif +typedef struct mib2_udp { + /* total # of UDP datagrams sent upstream { udp 1 } */ + Counter udpInDatagrams; + /* in ip { udp 2 } */ + /* # of recv'd dg's not deliverable (other) { udp 3 } */ + Counter udpInErrors; + /* total # of dg's sent { udp 4 } */ + Counter udpOutDatagrams; + /* { udp 5 } */ + int udpEntrySize; /* Size of udpEntry_t */ + int udp6EntrySize; /* Size of udp6Entry_t */ + Counter udpOutErrors; + + /* + * fields from RFC 4113 + */ + + /* total # of UDP datagrams sent upstream { udp 8 } */ + Counter64 udpHCInDatagrams; + /* total # of dg's sent { udp 9 } */ + Counter64 udpHCOutDatagrams; +} mib2_udp_t; +#define MIB_FIRST_NEW_ELM_mib2_udp_t udpHCInDatagrams + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * The UDP listener table contains information about this entity's UDP + * end-points on which a local application is currently accepting datagrams. + */ + +/* For both IPv4 and IPv6 ue_state: */ +#define MIB2_UDP_unbound 1 +#define MIB2_UDP_idle 2 +#define MIB2_UDP_connected 3 +#define MIB2_UDP_unknown 4 + +/* Pack data to make struct size the same for 32- and 64-bits */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif +typedef struct mib2_udpEntry { + /* local ip addr of listener { udpEntry 1 } */ + IpAddress udpLocalAddress; + /* local port of listener { udpEntry 2 } */ + int udpLocalPort; /* In host byte order */ + struct udpEntryInfo_s { + int ue_state; + IpAddress ue_RemoteAddress; + int ue_RemotePort; /* In host byte order */ + } udpEntryInfo; + + /* + * RFC 4113 + */ + + /* Unique id for this 4-tuple { udpEndpointEntry 7 } */ + uint32_t udpInstance; + /* pid of the processes that created this endpoint */ + uint32_t udpCreationProcess; + /* system uptime when the endpoint was created */ + uint64_t udpCreationTime; +} mib2_udpEntry_t; +#define MIB_FIRST_NEW_ELM_mib2_udpEntry_t udpInstance + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * The UDP (for IPv6) listener table contains information about this + * entity's UDP end-points on which a local application is + * currently accepting datagrams. + */ + +/* Pack data to make struct size the same for 32- and 64-bits */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif +typedef struct mib2_udp6Entry { + /* local ip addr of listener { ipv6UdpEntry 1 } */ + Ip6Address udp6LocalAddress; + /* local port of listener { ipv6UdpEntry 2 } */ + int udp6LocalPort; /* In host byte order */ + /* interface index or zero { ipv6UdpEntry 3 } */ + DeviceIndex udp6IfIndex; + struct udp6EntryInfo_s { + int ue_state; + Ip6Address ue_RemoteAddress; + int ue_RemotePort; /* In host byte order */ + } udp6EntryInfo; + + /* + * RFC 4113 + */ + + /* Unique id for this 4-tuple { udpEndpointEntry 7 } */ + uint32_t udp6Instance; + /* pid of the processes that created this endpoint */ + uint32_t udp6CreationProcess; + /* system uptime when the endpoint was created */ + uint64_t udp6CreationTime; +} mib2_udp6Entry_t; +#define MIB_FIRST_NEW_ELM_mib2_udp6Entry_t udp6Instance + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * the RAWIP group + */ +typedef struct mib2_rawip { + /* total # of RAWIP datagrams sent upstream */ + Counter rawipInDatagrams; + /* # of RAWIP packets with bad IPV6_CHECKSUM checksums */ + Counter rawipInCksumErrs; + /* # of recv'd dg's not deliverable (other) */ + Counter rawipInErrors; + /* total # of dg's sent */ + Counter rawipOutDatagrams; + /* total # of dg's not sent (e.g. no memory) */ + Counter rawipOutErrors; +} mib2_rawip_t; + +/* DVMRP group */ +#define EXPER_DVMRP_VIF 1 +#define EXPER_DVMRP_MRT 2 + + +/* + * The SCTP group + */ +#define MIB2_SCTP_CONN 15 +#define MIB2_SCTP_CONN_LOCAL 16 +#define MIB2_SCTP_CONN_REMOTE 17 + +#define MIB2_SCTP_closed 1 +#define MIB2_SCTP_cookieWait 2 +#define MIB2_SCTP_cookieEchoed 3 +#define MIB2_SCTP_established 4 +#define MIB2_SCTP_shutdownPending 5 +#define MIB2_SCTP_shutdownSent 6 +#define MIB2_SCTP_shutdownReceived 7 +#define MIB2_SCTP_shutdownAckSent 8 +#define MIB2_SCTP_deleteTCB 9 +#define MIB2_SCTP_listen 10 /* Not in the MIB */ + +#define MIB2_SCTP_ACTIVE 1 +#define MIB2_SCTP_INACTIVE 2 + +#define MIB2_SCTP_ADDR_V4 1 +#define MIB2_SCTP_ADDR_V6 2 + +#define MIB2_SCTP_RTOALGO_OTHER 1 +#define MIB2_SCTP_RTOALGO_VANJ 2 + +typedef struct mib2_sctpConnEntry { + /* connection identifier { sctpAssocEntry 1 } */ + uint32_t sctpAssocId; + /* remote hostname (not used) { sctpAssocEntry 2 } */ + Octet_t sctpAssocRemHostName; + /* local port number { sctpAssocEntry 3 } */ + uint32_t sctpAssocLocalPort; + /* remote port number { sctpAssocEntry 4 } */ + uint32_t sctpAssocRemPort; + /* type of primary remote addr { sctpAssocEntry 5 } */ + int sctpAssocRemPrimAddrType; + /* primary remote address { sctpAssocEntry 6 } */ + Ip6Address sctpAssocRemPrimAddr; + /* local address */ + Ip6Address sctpAssocLocPrimAddr; + /* current heartbeat interval { sctpAssocEntry 7 } */ + uint32_t sctpAssocHeartBeatInterval; + /* state of this association { sctpAssocEntry 8 } */ + int sctpAssocState; + /* # of inbound streams { sctpAssocEntry 9 } */ + uint32_t sctpAssocInStreams; + /* # of outbound streams { sctpAssocEntry 10 } */ + uint32_t sctpAssocOutStreams; + /* max # of data retans { sctpAssocEntry 11 } */ + uint32_t sctpAssocMaxRetr; + /* sysId for assoc owner { sctpAssocEntry 12 } */ + uint32_t sctpAssocPrimProcess; + /* # of rxmit timeouts during hanshake */ + Counter32 sctpAssocT1expired; /* { sctpAssocEntry 13 } */ + /* # of rxmit timeouts during shutdown */ + Counter32 sctpAssocT2expired; /* { sctpAssocEntry 14 } */ + /* # of rxmit timeouts during data transfer */ + Counter32 sctpAssocRtxChunks; /* { sctpAssocEntry 15 } */ + /* assoc start-up time { sctpAssocEntry 16 } */ + uint32_t sctpAssocStartTime; + struct sctpConnEntryInfo_s { + /* amount of data in send Q */ + Gauge ce_sendq; + /* amount of data in recv Q */ + Gauge ce_recvq; + /* currect send window size */ + Gauge ce_swnd; + /* currenct receive window size */ + Gauge ce_rwnd; + /* current max segment size */ + Gauge ce_mss; + } sctpConnEntryInfo; +} mib2_sctpConnEntry_t; + +typedef struct mib2_sctpConnLocalAddrEntry { + /* connection identifier */ + uint32_t sctpAssocId; + /* type of local addr { sctpAssocLocalEntry 1 } */ + int sctpAssocLocalAddrType; + /* local address { sctpAssocLocalEntry 2 } */ + Ip6Address sctpAssocLocalAddr; +} mib2_sctpConnLocalEntry_t; + +typedef struct mib2_sctpConnRemoteAddrEntry { + /* connection identier */ + uint32_t sctpAssocId; + /* remote addr type { sctpAssocRemEntry 1 } */ + int sctpAssocRemAddrType; + /* remote address { sctpAssocRemEntry 2 } */ + Ip6Address sctpAssocRemAddr; + /* is the address active { sctpAssocRemEntry 3 } */ + int sctpAssocRemAddrActive; + /* whether hearbeat is active { sctpAssocRemEntry 4 } */ + int sctpAssocRemAddrHBActive; + /* current RTO { sctpAssocRemEntry 5 } */ + uint32_t sctpAssocRemAddrRTO; + /* max # of rexmits before becoming inactive */ + uint32_t sctpAssocRemAddrMaxPathRtx; /* {sctpAssocRemEntry 6} */ + /* # of rexmits to this dest { sctpAssocRemEntry 7 } */ + uint32_t sctpAssocRemAddrRtx; +} mib2_sctpConnRemoteEntry_t; + + + +/* Pack data in mib2_sctp to make struct size the same for 32- and 64-bits */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct mib2_sctp { + /* algorithm used to determine rto { sctpParams 1 } */ + int sctpRtoAlgorithm; + /* min RTO in msecs { sctpParams 2 } */ + uint32_t sctpRtoMin; + /* max RTO in msecs { sctpParams 3 } */ + uint32_t sctpRtoMax; + /* initial RTO in msecs { sctpParams 4 } */ + uint32_t sctpRtoInitial; + /* max # of assocs { sctpParams 5 } */ + int32_t sctpMaxAssocs; + /* cookie lifetime in msecs { sctpParams 6 } */ + uint32_t sctpValCookieLife; + /* max # of retrans in startup { sctpParams 7 } */ + uint32_t sctpMaxInitRetr; + /* # of conns ESTABLISHED, SHUTDOWN-RECEIVED or SHUTDOWN-PENDING */ + Counter32 sctpCurrEstab; /* { sctpStats 1 } */ + /* # of active opens { sctpStats 2 } */ + Counter32 sctpActiveEstab; + /* # of passive opens { sctpStats 3 } */ + Counter32 sctpPassiveEstab; + /* # of aborted conns { sctpStats 4 } */ + Counter32 sctpAborted; + /* # of graceful shutdowns { sctpStats 5 } */ + Counter32 sctpShutdowns; + /* # of OOB packets { sctpStats 6 } */ + Counter32 sctpOutOfBlue; + /* # of packets discarded due to cksum { sctpStats 7 } */ + Counter32 sctpChecksumError; + /* # of control chunks sent { sctpStats 8 } */ + Counter64 sctpOutCtrlChunks; + /* # of ordered data chunks sent { sctpStats 9 } */ + Counter64 sctpOutOrderChunks; + /* # of unordered data chunks sent { sctpStats 10 } */ + Counter64 sctpOutUnorderChunks; + /* # of retransmitted data chunks */ + Counter64 sctpRetransChunks; + /* # of SACK chunks sent */ + Counter sctpOutAck; + /* # of delayed ACK timeouts */ + Counter sctpOutAckDelayed; + /* # of SACK chunks sent to update window */ + Counter sctpOutWinUpdate; + /* # of fast retransmits */ + Counter sctpOutFastRetrans; + /* # of window probes sent */ + Counter sctpOutWinProbe; + /* # of control chunks received { sctpStats 11 } */ + Counter64 sctpInCtrlChunks; + /* # of ordered data chunks rcvd { sctpStats 12 } */ + Counter64 sctpInOrderChunks; + /* # of unord data chunks rcvd { sctpStats 13 } */ + Counter64 sctpInUnorderChunks; + /* # of received SACK chunks */ + Counter sctpInAck; + /* # of received SACK chunks with duplicate TSN */ + Counter sctpInDupAck; + /* # of SACK chunks acking unsent data */ + Counter sctpInAckUnsent; + /* # of Fragmented User Messages { sctpStats 14 } */ + Counter64 sctpFragUsrMsgs; + /* # of Reassembled User Messages { sctpStats 15 } */ + Counter64 sctpReasmUsrMsgs; + /* # of Sent SCTP Packets { sctpStats 16 } */ + Counter64 sctpOutSCTPPkts; + /* # of Received SCTP Packets { sctpStats 17 } */ + Counter64 sctpInSCTPPkts; + /* # of invalid cookies received */ + Counter sctpInInvalidCookie; + /* total # of retransmit timeouts */ + Counter sctpTimRetrans; + /* total # of retransmit timeouts dropping the connection */ + Counter sctpTimRetransDrop; + /* total # of heartbeat probes */ + Counter sctpTimHeartBeatProbe; + /* total # of heartbeat timeouts dropping the connection */ + Counter sctpTimHeartBeatDrop; + /* total # of conns refused due to backlog full on listen */ + Counter sctpListenDrop; + /* total # of pkts received after the association has closed */ + Counter sctpInClosed; + int sctpEntrySize; + int sctpLocalEntrySize; + int sctpRemoteEntrySize; +} mib2_sctp_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_MIB2_H */ diff --git a/illumos-x86_64/usr/include/inet/nd.h b/illumos-x86_64/usr/include/inet/nd.h new file mode 100644 index 00000000..e4a2bb46 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/nd.h @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_ND_H +#define _INET_ND_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define ND_BASE ('N' << 8) /* base */ +#define ND_GET (ND_BASE + 0) /* Get a value */ +#define ND_SET (ND_BASE + 1) /* Set a value */ + +#ifdef _KERNEL +/* ND callback function prototypes */ +typedef int (*ndgetf_t)(queue_t *, MBLKP, caddr_t, cred_t *); +typedef int (*ndsetf_t)(queue_t *, MBLKP, char *, caddr_t, cred_t *); + +/* Named dispatch table entry */ +typedef struct nde_s { + char *nde_name; + pfi_t nde_get_pfi; + pfi_t nde_set_pfi; + caddr_t nde_data; +} NDE; + +/* Name dispatch table */ +typedef struct nd_s { + int nd_free_count; /* number of unused nd table entries */ + int nd_size; /* size (in bytes) of current table */ + NDE *nd_tbl; /* pointer to table in heap */ +} ND; + +#define NDE_ALLOC_COUNT 32 +#define NDE_ALLOC_SIZE (sizeof (NDE) * NDE_ALLOC_COUNT) + +/* 64K STREAM limit - the max ndd info header. */ +#define ND_MAX_BUF_LEN 65303 + +/* + * See uts/common/inet/nd.c for comments on how to use these routines. + */ +extern boolean_t nd_load(caddr_t *, char *, ndgetf_t, ndsetf_t, caddr_t); +extern void nd_unload(caddr_t *, char *); +extern void nd_free(caddr_t *); +extern int nd_getset(queue_t *, caddr_t, MBLKP); + +/* + * Canned nd_get and nd_set routines for use with nd_load(). + */ +extern int nd_get_default(queue_t *, MBLKP, caddr_t, cred_t *); +extern int nd_get_long(queue_t *, MBLKP, caddr_t, cred_t *); +extern int nd_get_names(queue_t *, MBLKP, caddr_t, cred_t *); +extern int nd_set_default(queue_t *, MBLKP, char *, caddr_t, cred_t *); +extern int nd_set_long(queue_t *, MBLKP, char *, caddr_t, cred_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_ND_H */ diff --git a/illumos-x86_64/usr/include/inet/optcom.h b/illumos-x86_64/usr/include/inet/optcom.h new file mode 100644 index 00000000..01ca52a7 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/optcom.h @@ -0,0 +1,208 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_OPTCOM_H +#define _INET_OPTCOM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) && defined(__STDC__) + +#include + +/* Options Description Structure */ +typedef struct opdes_s { + t_uscalar_t opdes_name; /* option name */ + t_uscalar_t opdes_level; /* option "level" */ + int opdes_access_nopriv; /* permissions for non-privileged */ + int opdes_access_priv; /* permissions for privileged */ + int opdes_access_req_priv; /* required privilege, OP_NP if none */ + int opdes_props; /* properties of associated with option */ + t_uscalar_t opdes_size; /* length of option */ + /* [ or maxlen if variable */ + /* length(OP_VARLEN) property set for option] */ + union { + /* + * + * Note: C semantics: + * static initializer of "union" type assume + * the constant on RHS is of the type of the + * first member of the union. So what comes first + * is important. + */ +#define OPDES_DEFSZ_MAX 64 + int64_t opdes_def_int64; + char opdes_def_charbuf[OPDES_DEFSZ_MAX]; + } opdes_def; +} opdes_t; + +#define opdes_default opdes_def.opdes_def_int64 +#define opdes_defbuf opdes_def.opdes_def_charbuf +/* + * Flags to set in opdes_acces_{all,priv} fields in opdes_t + * + * OA_R read access + * OA_W write access + * OA_RW read-write access + * OA_X execute access + * + * Note: - semantics "execute" access used for operations excuted using + * option management interface + * - no bits set means this option is not visible. Some options may not + * even be visible to all but priviliged users. + */ +#define OA_R 0x1 +#define OA_W 0x2 +#define OA_X 0x4 + +/* + * Utility macros to test permissions needed to compose more + * complex ones. (Only a few really used directly in code). + */ +#define OA_RW (OA_R|OA_W) +#define OA_WX (OA_W|OA_X) +#define OA_RX (OA_R|OA_X) +#define OA_RWX (OA_R|OA_W|OA_X) + +#define OA_ANY_ACCESS(x) ((x)->opdes_access_nopriv|(x)->opdes_access_priv) +#define OA_R_NOPRIV(x) ((x)->opdes_access_nopriv & OA_R) +#define OA_R_ANYPRIV(x) (OA_ANY_ACCESS(x) & OA_R) +#define OA_W_NOPRIV(x) ((x)->opdes_access_nopriv & OA_W) +#define OA_X_ANYPRIV(x) (OA_ANY_ACCESS(x) & OA_X) +#define OA_X_NOPRIV(x) ((x)->opdes_access_nopriv & OA_X) +#define OA_W_ANYPRIV(x) (OA_ANY_ACCESS(x) & OA_W) +#define OA_WX_NOPRIV(x) ((x)->opdes_access_nopriv & OA_WX) +#define OA_WX_ANYPRIV(x) (OA_ANY_ACCESS(x) & OA_WX) +#define OA_RWX_ANYPRIV(x) (OA_ANY_ACCESS(x) & OA_RWX) +#define OA_RONLY_NOPRIV(x) (((x)->opdes_access_nopriv & OA_RWX) == OA_R) +#define OA_RONLY_ANYPRIV(x) ((OA_ANY_ACCESS(x) & OA_RWX) == OA_R) + +#define OP_NP (-1) /* No privilege required */ +#define OP_CONFIG (0) /* Network configuration */ +#define OP_RAW (1) /* Raw packets */ +#define OP_PRIVPORT (2) /* Privileged ports */ + + +/* + * Following macros supply the option and their privilege and + * are used to determine permissions. + */ +#define OA_POLICY_OK(x, c) \ + (secpolicy_ip((c), (x)->opdes_access_req_priv, B_FALSE) == 0) + +#define OA_POLICY_ONLY_OK(x, c) \ + (secpolicy_ip((c), (x)->opdes_access_req_priv, B_TRUE) == 0) + +#define OA_MATCHED_PRIV(x, c) ((x)->opdes_access_req_priv != OP_NP && \ + OA_POLICY_ONLY_OK((x), (c))) + +#define OA_READ_PERMISSION(x, c) (OA_R_NOPRIV(x) || \ + (OA_R_ANYPRIV(x) && OA_POLICY_OK((x), (c)))) + +#define OA_WRITE_OR_EXECUTE(x, c) (OA_WX_NOPRIV(x) || \ + (OA_WX_ANYPRIV(x) && OA_POLICY_OK((x), (c)))) + +#define OA_READONLY_PERMISSION(x, c) (OA_RONLY_NOPRIV(x) || \ + (OA_RONLY_ANYPRIV(x) && OA_POLICY_OK((x), (c)))) + +#define OA_WRITE_PERMISSION(x, c) (OA_W_NOPRIV(x) || \ + (OA_W_ANYPRIV(x) && OA_POLICY_ONLY_OK((x), (c)))) + +#define OA_EXECUTE_PERMISSION(x, c) (OA_X_NOPRIV(x) || \ + (OA_X_ANYPRIV(x) && OA_POLICY_ONLY_OK((x), (c)))) + +#define OA_NO_PERMISSION(x, c) (OA_MATCHED_PRIV((x), (c)) ? \ + ((x)->opdes_access_priv == 0) : ((x)->opdes_access_nopriv == 0)) + +/* + * Other properties set in opdes_props field. + */ +#define OP_VARLEN 0x1 /* option is varible length */ +#define OP_NOT_ABSREQ 0x2 /* option is not a "absolute requirement" */ + /* i.e. failure to negotiate does not */ + /* abort primitive ("ignore" semantics ok) */ +#define OP_NODEFAULT 0x4 /* no concept of "default value" */ +#define OP_DEF_FN 0x8 /* call a "default function" to get default */ + /* value, not from static table */ + + +/* + * Structure to represent attributed of option management specific + * to one particular layer of "transport". + */ + +typedef t_uscalar_t optlevel_t; + +typedef int (*opt_def_fn)(queue_t *, int, int, uchar_t *); +typedef int (*opt_get_fn)(queue_t *, int, int, uchar_t *); +typedef int (*opt_set_fn)(queue_t *, uint_t, int, int, uint_t, uchar_t *, + uint_t *, uchar_t *, void *, cred_t *); + +typedef struct optdb_obj { + opt_def_fn odb_deffn; /* default value function */ + opt_get_fn odb_getfn; /* get function */ + opt_set_fn odb_setfn; /* set function */ + /* provider or downstream */ + uint_t odb_opt_arr_cnt; /* count of number of options in db */ + opdes_t *odb_opt_des_arr; /* option descriptors in db */ + uint_t odb_valid_levels_arr_cnt; + /* count of option levels supported */ + optlevel_t *odb_valid_levels_arr; + /* array of option levels supported */ +} optdb_obj_t; + +/* + * Values for "optset_context" parameter passed to + * transport specific "setfn()" routines + */ +#define SETFN_OPTCOM_CHECKONLY 1 /* "checkonly" semantics T_CHECK */ +#define SETFN_OPTCOM_NEGOTIATE 2 /* semantics for T_*_OPTCOM_REQ */ +#define SETFN_UD_NEGOTIATE 3 /* semantics for T_UNITDATA_REQ */ +#define SETFN_CONN_NEGOTIATE 4 /* semantics for T_CONN_*_REQ */ + +/* + * Function prototypes + */ +extern void optcom_err_ack(queue_t *, mblk_t *, t_scalar_t, int); +extern void svr4_optcom_req(queue_t *, mblk_t *, cred_t *, optdb_obj_t *); +extern void tpi_optcom_req(queue_t *, mblk_t *, cred_t *, optdb_obj_t *); +extern int tpi_optcom_buf(queue_t *, mblk_t *, t_scalar_t *, t_scalar_t, + cred_t *, optdb_obj_t *, void *, int *); +extern t_uscalar_t optcom_max_optsize(opdes_t *, uint_t); +extern int optcom_pkt_set(uchar_t *, uint_t, uchar_t **, uint_t *); +extern int process_auxiliary_options(conn_t *, void *, t_uscalar_t, + void *, optdb_obj_t *, int (*)(conn_t *, uint_t, int, int, uint_t, + uchar_t *, uint_t *, uchar_t *, void *, cred_t *), cred_t *); + +#endif /* defined(_KERNEL) && defined(__STDC__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_OPTCOM_H */ diff --git a/illumos-x86_64/usr/include/inet/sctp_itf.h b/illumos-x86_64/usr/include/inet/sctp_itf.h new file mode 100644 index 00000000..2ae6d366 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/sctp_itf.h @@ -0,0 +1,154 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_SCTP_ITF_H +#define _INET_SCTP_ITF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Kernel SCTP programming interface. Note that this interface + * is private to Sun and can be changed without notice. + */ + +#ifdef _KERNEL + +/* + * The version number of the SCTP kernel interface. Use it with + * sctp_itf_ver() to verify if the kernel supports the correct + * version of the interface. + * + * NOTE: do not assume backward compatibility of the interface. + * If the return value of sctp_itf_ver() is different from what + * is expected, do not call any of the routines. + */ +#define SCTP_ITF_VER 2 + +/* + * This struct holds various flow control limits the caller of + * sctp_create() should observe when interacting with SCTP. + */ +typedef struct sctp_sockbuf_limits_s { + int sbl_rxbuf; + int sbl_rxlowat; + int sbl_txbuf; + int sbl_txlowat; +} sctp_sockbuf_limits_t; + +/* + * Parameter to SCTP_UC_SWAP setsockopt + */ +struct sock_upcalls_s; +struct sctp_uc_swap { + void *sus_handle; + struct sock_upcalls_s *sus_upcalls; +}; + +struct sctp_s; + +/* + * The list of routines the SCTP kernel module provides. + */ +extern mblk_t *sctp_alloc_hdr(const char *name, int namelen, + const char *control, int controllen, int flags); +extern int sctp_bind(struct sctp_s *conn, struct sockaddr *addr, + socklen_t addrlen); +extern int sctp_bindx(struct sctp_s *conn, const void *addrs, int addrcnt, + int flags); +extern void sctp_close(struct sctp_s *conn); +extern int sctp_connect(struct sctp_s *conn, const struct sockaddr *dst, + socklen_t addrlen, cred_t *cr, pid_t pid); +extern struct sctp_s *sctp_create(void *newhandle, struct sctp_s *parent, + int family, int type, int flags, struct sock_upcalls_s *su, + sctp_sockbuf_limits_t *sbl, cred_t *cr); +extern int sctp_disconnect(struct sctp_s *conn); +extern int sctp_get_opt(struct sctp_s *conn, int level, int opt, void *opts, + socklen_t *optlen); +extern int sctp_getpeername(struct sctp_s *conn, struct sockaddr *addr, + socklen_t *addrlen); +extern int sctp_getsockname(struct sctp_s *conn, struct sockaddr *addr, + socklen_t *addrlen); +extern int sctp_itf_ver(int); +extern int sctp_listen(struct sctp_s *conn); +extern void sctp_recvd(struct sctp_s *conn, int len); +extern int sctp_sendmsg(struct sctp_s *conn, mblk_t *mp, int flags); +extern int sctp_set_opt(struct sctp_s *conn, int level, int opt, + const void *opts, socklen_t optlen); + +/* Flags for sctp_create(), sctp_alloc_hdr() */ +#define SCTP_CAN_BLOCK 0x01 + +/* Flags for upcall su_recv() */ +#define SCTP_NOTIFICATION 0x01 /* message is a notification */ +#define SCTP_PARTIAL_DATA 0x02 /* not a full message */ + +/* Use by sockfs to do sctp_peeloff(). */ +#define SCTP_UC_SWAP 255 + +/* + * The following are private interfaces between Solaris SCTP and SunCluster. + * Hence, these interfaces are only for use by SunCluster and are *not* part + * of the general SCTP kernel interface. + */ + +typedef uintptr_t cl_sctp_handle_t; + +typedef struct cl_sctp_info_s { + ushort_t cl_sctpi_version; + ushort_t cl_sctpi_family; + ushort_t cl_sctpi_ipversion; + int32_t cl_sctpi_state; + in_port_t cl_sctpi_lport; + in_port_t cl_sctpi_fport; + uint_t cl_sctpi_nladdr; + uchar_t *cl_sctpi_laddrp; + uint_t cl_sctpi_nfaddr; + uchar_t *cl_sctpi_faddrp; + cl_sctp_handle_t cl_sctpi_handle; +} cl_sctp_info_t; + +#define CL_SCTPI_V1 1 /* cl_sctpi_version number */ + +/* Used to indicate if the local or peer address list has changed */ +#define SCTP_CL_LADDR 1 +#define SCTP_CL_PADDR 2 + +extern int cl_sctp_cookie_paddr(sctp_chunk_hdr_t *, in6_addr_t *); +extern int cl_sctp_walk_list(int (*callback)(cl_sctp_info_t *, void *), void *, + boolean_t); + +/* End of private SunCluster interfaces */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_SCTP_ITF_H */ diff --git a/illumos-x86_64/usr/include/inet/snmpcom.h b/illumos-x86_64/usr/include/inet/snmpcom.h new file mode 100644 index 00000000..1aa9d93f --- /dev/null +++ b/illumos-x86_64/usr/include/inet/snmpcom.h @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_SNMPCOM_H +#define _INET_SNMPCOM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) && defined(__STDC__) + +/* snmpcom_req function prototypes */ +typedef int (*snmp_setf_t)(queue_t *, int, int, uchar_t *, int); +typedef int (*snmp_getf_t)(queue_t *, mblk_t *, int, boolean_t); + +extern int snmp_append_data(mblk_t *mpdata, char *blob, int len); +extern int snmp_append_data2(mblk_t *mpdata, mblk_t **last_mpp, + char *blob, int len); + +extern boolean_t snmpcom_req(queue_t *q, mblk_t *mp, + snmp_setf_t setfn, snmp_getf_t getfn, cred_t *cr); + +#endif /* defined(_KERNEL) && defined(__STDC__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_SNMPCOM_H */ diff --git a/illumos-x86_64/usr/include/inet/tcp.h b/illumos-x86_64/usr/include/inet/tcp.h new file mode 100644 index 00000000..c1634586 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/tcp.h @@ -0,0 +1,619 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015 Joyent, Inc. + * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2014, 2017 by Delphix. All rights reserved. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2024 Oxide Computer Company + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _INET_TCP_H +#define _INET_TCP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* TCP states */ +#define TCPS_CLOSED -6 +#define TCPS_IDLE -5 /* idle (opened, but not bound) */ +#define TCPS_BOUND -4 /* bound, ready to connect or accept */ +#define TCPS_LISTEN -3 /* listening for connection */ +#define TCPS_SYN_SENT -2 /* active, have sent syn */ +#define TCPS_SYN_RCVD -1 /* have received syn (and sent ours) */ +/* states < TCPS_ESTABLISHED are those where connections not established */ +#define TCPS_ESTABLISHED 0 /* established */ +#define TCPS_CLOSE_WAIT 1 /* rcvd fin, waiting for close */ +/* states > TCPS_CLOSE_WAIT are those where user has closed */ +#define TCPS_FIN_WAIT_1 2 /* have closed and sent fin */ +#define TCPS_CLOSING 3 /* closed, xchd FIN, await FIN ACK */ +#define TCPS_LAST_ACK 4 /* had fin and close; await FIN ACK */ +/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ +#define TCPS_FIN_WAIT_2 5 /* have closed, fin is acked */ +#define TCPS_TIME_WAIT 6 /* in 2*msl quiet wait after close */ + +/* + * Internal flags used in conjunction with the packet header flags. + * Used in tcp_input_data to keep track of what needs to be done. + */ +#define TH_LIMIT_XMIT 0x0400 /* Limited xmit is needed */ +#define TH_XMIT_NEEDED 0x0800 /* Window opened - send queued data */ +#define TH_REXMIT_NEEDED 0x1000 /* Time expired for unacked data */ +#define TH_ACK_NEEDED 0x2000 /* Send an ack now. */ +#define TH_NEED_SACK_REXMIT 0x4000 /* Use SACK info to retransmission */ +#define TH_ACK_TIMER_NEEDED 0x8000 /* Start the delayed ACK timer */ +#define TH_ORDREL_NEEDED 0x10000 /* Generate an ordrel indication */ +#define TH_MARKNEXT_NEEDED 0x20000 /* Data should have MSGMARKNEXT */ +#define TH_SEND_URP_MARK 0x40000 /* Send up tcp_urp_mark_mp */ + +/* + * TCP sequence numbers are 32 bit integers operated + * on with modular arithmetic. These macros can be + * used to compare such integers. + */ +#define SEQ_LT(a, b) ((int32_t)((a)-(b)) < 0) +#define SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) +#define SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) +#define SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) + +/* TCP Protocol header */ +typedef struct tcphdr_s { + uint8_t th_lport[2]; /* Source port */ + uint8_t th_fport[2]; /* Destination port */ + uint8_t th_seq[4]; /* Sequence number */ + uint8_t th_ack[4]; /* Acknowledgement number */ + uint8_t th_offset_and_rsrvd[1]; /* Offset to the packet data */ + uint8_t th_flags[1]; + uint8_t th_win[2]; /* Allocation number */ + uint8_t th_sum[2]; /* TCP checksum */ + uint8_t th_urp[2]; /* Urgent pointer */ +} tcph_t; + +#define TCP_HDR_LENGTH(tcph) \ + ((((tcph_t *)tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2)) +#define TCP_MAX_COMBINED_HEADER_LENGTH (60 + 60) /* Maxed out ip + tcp */ +#define TCP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) +#define TCP_MAX_HDR_LENGTH 60 +#define TCP_MAX_TCP_OPTIONS_LENGTH (60 - sizeof (tcpha_t)) +#define TCP_MIN_HEADER_LENGTH 20 +#define TCP_MAXWIN 65535 +#define TCP_PORT_LEN sizeof (in_port_t) +#define TCP_MAX_WINSHIFT 14 +#define TCP_MAX_LARGEWIN (TCP_MAXWIN << TCP_MAX_WINSHIFT) +#define TCP_MAX_LSO_LENGTH (IP_MAXPACKET - TCP_MAX_COMBINED_HEADER_LENGTH) + +#define TCPIP_HDR_LENGTH(mp, n) \ + (n) = IPH_HDR_LENGTH((mp)->b_rptr), \ + (n) += TCP_HDR_LENGTH((tcpha_t *)&(mp)->b_rptr[(n)]) + +/* TCP Protocol header (used if the header is known to be 32-bit aligned) */ +typedef struct tcphdra_s { + in_port_t tha_lport; /* Source port */ + in_port_t tha_fport; /* Destination port */ + uint32_t tha_seq; /* Sequence number */ + uint32_t tha_ack; /* Acknowledgement number */ + uint8_t tha_offset_and_reserved; /* Offset to the packet data */ + uint8_t tha_flags; + uint16_t tha_win; /* Allocation number */ + uint16_t tha_sum; /* TCP checksum */ + uint16_t tha_urp; /* Urgent pointer */ +} tcpha_t; + +struct conn_s; +struct tcp_listen_cnt_s; +struct tcp_rg_s; + +/* + * Control structure for each open TCP stream, + * defined only within the kernel or for a kmem user. + * NOTE: tcp_reinit_values MUST have a line for each field in this structure! + */ +#if (defined(_KERNEL) || defined(_KMEMUSER)) + +typedef struct tcp_s { + struct tcp_s *tcp_time_wait_next; + /* Pointer to next T/W block */ + struct tcp_s *tcp_time_wait_prev; + /* Pointer to previous T/W next */ + int64_t tcp_time_wait_expire; + + struct conn_s *tcp_connp; /* back pointer to conn_t */ + tcp_stack_t *tcp_tcps; /* back pointer to tcp_stack_t */ + + struct cc_algo *tcp_cc_algo; /* congestion control algorithm */ + struct cc_var tcp_ccv; /* congestion control specific vars */ + + int32_t tcp_state; + int32_t tcp_rcv_ws; /* My window scale power */ + int32_t tcp_snd_ws; /* Sender's window scale power */ + uint32_t tcp_ts_recent; /* Timestamp of earliest unacked */ + /* data segment */ + clock_t tcp_rto; /* Round trip timeout */ + int64_t tcp_last_rcv_lbolt; + /* lbolt on last packet, used for PAWS */ + uint32_t tcp_rto_initial; /* Initial RTO */ + uint32_t tcp_rto_min; /* Minimum RTO */ + uint32_t tcp_rto_max; /* Maximum RTO */ + + uint32_t tcp_snxt; /* Senders next seq num */ + uint32_t tcp_swnd; /* Senders window (relative to suna) */ + uint32_t tcp_mss; /* Max segment size */ + uint32_t tcp_iss; /* Initial send seq num */ + uint32_t tcp_rnxt; /* Seq we expect to recv next */ + uint32_t tcp_rwnd; + + /* Fields arranged in approximate access order along main paths */ + mblk_t *tcp_xmit_head; /* Head of xmit/rexmit list */ + mblk_t *tcp_xmit_last; /* Last valid data seen by tcp_wput */ + mblk_t *tcp_xmit_tail; /* Last data sent */ + uint32_t tcp_unsent; /* # of bytes in hand that are unsent */ + uint32_t tcp_xmit_tail_unsent; /* # of unsent bytes in xmit_tail */ + uint32_t tcp_suna; /* Sender unacknowledged */ + uint32_t tcp_rexmit_nxt; /* Next rexmit seq num */ + uint32_t tcp_rexmit_max; /* Max retran seq num */ + uint32_t tcp_cwnd; /* Congestion window */ + int32_t tcp_cwnd_cnt; /* cwnd cnt in congestion avoidance */ + uint32_t tcp_naglim; /* Tunable nagle limit */ + uint32_t tcp_valid_bits; +#define TCP_ISS_VALID 0x1 /* Is the tcp_iss seq num active? */ +#define TCP_FSS_VALID 0x2 /* Is the tcp_fss seq num active? */ +#define TCP_URG_VALID 0x4 /* Is the tcp_urg seq num active? */ +#define TCP_OFO_FIN_VALID 0x8 /* Has TCP received an out of order FIN? */ + + timeout_id_t tcp_timer_tid; /* Control block for timer service */ + uchar_t tcp_timer_backoff; /* Backoff shift count. */ + int64_t tcp_last_recv_time; /* Last time we receive a segment. */ + uint32_t tcp_init_cwnd; /* Initial cwnd (start/restart) */ + + /* Following manipulated by TCP under squeue protection */ + uint32_t + tcp_urp_last_valid : 1, /* Is tcp_urp_last valid? */ + tcp_hard_binding : 1, /* TCP_DETACHED_NONEAGER */ + tcp_fin_acked : 1, /* Has our FIN been acked? */ + tcp_fin_rcvd : 1, /* Have we seen a FIN? */ + + tcp_fin_sent : 1, /* Have we sent our FIN yet? */ + tcp_ordrel_done : 1, /* Have we sent the ord_rel upstream? */ + tcp_detached : 1, /* If we're detached from a stream */ + tcp_zero_win_probe: 1, /* Zero win probing is in progress */ + + tcp_loopback: 1, /* src and dst are the same machine */ + tcp_localnet: 1, /* src and dst are on the same subnet */ + tcp_syn_defense: 1, /* For defense against SYN attack */ +#define tcp_dontdrop tcp_syn_defense + tcp_set_timer : 1, + + tcp_active_open: 1, /* This is a active open */ + tcp_rexmit : 1, /* TCP is retransmitting */ + tcp_snd_sack_ok : 1, /* Can use SACK for this connection */ + tcp_hwcksum : 1, /* The NIC is capable of hwcksum */ + + tcp_ip_forward_progress : 1, + tcp_ecn_ok : 1, /* Can use ECN for this connection */ + tcp_ecn_echo_on : 1, /* Need to do ECN echo */ + tcp_ecn_cwr_sent : 1, /* ECN_CWR has been sent */ + + tcp_cwr : 1, /* Cwnd has reduced recently */ + + tcp_pad_to_bit31 : 11; + + /* Following manipulated by TCP under squeue protection */ + uint32_t + tcp_snd_ts_ok : 1, + tcp_snd_ws_ok : 1, + tcp_reserved_port : 1, + tcp_in_free_list : 1, + + tcp_snd_zcopy_on : 1, /* xmit zero-copy enabled */ + tcp_snd_zcopy_aware : 1, /* client is zero-copy aware */ + tcp_xmit_zc_clean : 1, /* the xmit list is free of zc-mblk */ + tcp_wait_for_eagers : 1, /* Wait for eagers to disappear */ + + tcp_accept_error : 1, /* Error during TLI accept */ + tcp_send_discon_ind : 1, /* TLI accept err, send discon ind */ + tcp_cork : 1, /* tcp_cork option */ + tcp_quickack : 1, /* Send acks immediately */ + tcp_tconnind_started : 1, /* conn_ind message is being sent */ + + tcp_lso :1, /* Lower layer is capable of LSO */ + tcp_is_wnd_shrnk : 1, /* Window has shrunk */ + tcp_md5sig : 1, /* Add MD5 signature option */ + + tcp_pad_to_bit_31 : 16; + + uint32_t tcp_initial_pmtu; /* Initial outgoing Path MTU. */ + + mblk_t *tcp_reass_head; /* Out of order reassembly list head */ + mblk_t *tcp_reass_tail; /* Out of order reassembly list tail */ + + /* SACK related info */ + tcp_sack_info_t tcp_sack_info; + +#define tcp_pipe tcp_sack_info.tcp_pipe +#define tcp_fack tcp_sack_info.tcp_fack +#define tcp_sack_snxt tcp_sack_info.tcp_sack_snxt +#define tcp_max_sack_blk tcp_sack_info.tcp_max_sack_blk +#define tcp_num_sack_blk tcp_sack_info.tcp_num_sack_blk +#define tcp_sack_list tcp_sack_info.tcp_sack_list +#define tcp_num_notsack_blk tcp_sack_info.tcp_num_notsack_blk +#define tcp_cnt_notsack_list tcp_sack_info.tcp_cnt_notsack_list +#define tcp_notsack_list tcp_sack_info.tcp_notsack_list + + mblk_t *tcp_rcv_list; /* Queued until push, urgent data, */ + mblk_t *tcp_rcv_last_head; /* optdata, or the count exceeds */ + mblk_t *tcp_rcv_last_tail; /* tcp_rcv_push_wait. */ + uint32_t tcp_rcv_cnt; /* tcp_rcv_list is b_next chain. */ + + uint32_t tcp_cwnd_ssthresh; /* Congestion window */ + uint32_t tcp_cwnd_max; + uint32_t tcp_csuna; /* Clear (no rexmits in window) suna */ + + hrtime_t tcp_rtt_sum; /* Round trip sum */ + uint32_t tcp_rtt_cnt; /* Round trip count (non_dup ACKs) */ + hrtime_t tcp_rtt_sa; /* Round trip smoothed average */ + hrtime_t tcp_rtt_sd; /* Round trip smoothed deviation */ + uint32_t tcp_rtt_update; /* Round trip update(s) */ + clock_t tcp_ms_we_have_waited; /* Total retrans time */ + + uint32_t tcp_swl1; /* These help us avoid using stale */ + uint32_t tcp_swl2; /* packets to update state */ + + uint32_t tcp_rack; /* Seq # we have acked */ + uint32_t tcp_rack_cnt; /* # of segs we have deferred ack */ + uint32_t tcp_rack_cur_max; /* # of segs we may defer ack for now */ + uint32_t tcp_rack_abs_max; /* # of segs we may defer ack ever */ + timeout_id_t tcp_ack_tid; /* Delayed ACK timer ID */ + timeout_id_t tcp_push_tid; /* Push timer ID */ + + uint32_t tcp_max_swnd; /* Maximum swnd we have seen */ + + struct tcp_s *tcp_listener; /* Our listener */ + + uint32_t tcp_irs; /* Initial recv seq num */ + uint32_t tcp_fss; /* Final/fin send seq num */ + uint32_t tcp_urg; /* Urgent data seq num */ + + clock_t tcp_first_timer_threshold; /* When to prod IP */ + clock_t tcp_second_timer_threshold; /* When to give up completely */ + clock_t tcp_first_ctimer_threshold; /* 1st threshold while connecting */ + clock_t tcp_second_ctimer_threshold; /* 2nd ... while connecting */ + + uint32_t tcp_urp_last; /* Last urp for which signal sent */ + mblk_t *tcp_urp_mp; /* T_EXDATA_IND for urgent byte */ + mblk_t *tcp_urp_mark_mp; /* zero-length marked/unmarked msg */ + + int tcp_conn_req_cnt_q0; /* # of conn reqs in SYN_RCVD */ + int tcp_conn_req_cnt_q; /* # of conn reqs in ESTABLISHED */ + int tcp_conn_req_max; /* # of ESTABLISHED conn reqs allowed */ + t_scalar_t tcp_conn_req_seqnum; /* Incrementing pending conn req ID */ +#define tcp_ip_addr_cache tcp_reass_tail + /* Cache ip addresses that */ + /* complete the 3-way handshake */ + kmutex_t tcp_eager_lock; + struct tcp_s *tcp_eager_next_q; /* next eager in ESTABLISHED state */ + struct tcp_s *tcp_eager_last_q; /* last eager in ESTABLISHED state */ + struct tcp_s *tcp_eager_next_q0; /* next eager in SYN_RCVD state */ + struct tcp_s *tcp_eager_prev_q0; /* prev eager in SYN_RCVD state */ + /* all eagers form a circular list */ + boolean_t tcp_conn_def_q0; /* move from q0 to q deferred */ + + union { + mblk_t *tcp_eager_conn_ind; /* T_CONN_IND waiting for 3rd ack. */ + mblk_t *tcp_opts_conn_req; /* T_CONN_REQ w/ options processed */ + } tcp_conn; + uint32_t tcp_syn_rcvd_timeout; /* How many SYN_RCVD timeout in q0 */ + + /* + * TCP Keepalive Timer members. + * All keepalive timer intervals are in milliseconds. + */ + int32_t tcp_ka_last_intrvl; /* Last probe interval */ + timeout_id_t tcp_ka_tid; /* Keepalive timer ID */ + uint32_t tcp_ka_interval; /* Keepalive interval */ + + /* + * TCP connection is terminated if we don't hear back from the peer + * for tcp_ka_abort_thres milliseconds after the first keepalive probe. + * tcp_ka_rinterval is the interval in milliseconds between successive + * keepalive probes. tcp_ka_cnt is the number of keepalive probes to + * be sent before terminating the connection, if we don't hear back from + * peer. + * tcp_ka_abort_thres = tcp_ka_rinterval * tcp_ka_cnt + */ + uint32_t tcp_ka_rinterval; /* keepalive retransmit interval */ + uint32_t tcp_ka_abort_thres; /* Keepalive abort threshold */ + uint32_t tcp_ka_cnt; /* count of keepalive probes */ + + int32_t tcp_client_errno; /* How the client screwed up */ + + /* + * The header template lives in conn_ht_iphc allocated by tcp_build_hdrs + * We maintain three pointers into conn_ht_iphc. + */ + ipha_t *tcp_ipha; /* IPv4 header in conn_ht_iphc */ + ip6_t *tcp_ip6h; /* IPv6 header in conn_ht_iphc */ + tcpha_t *tcp_tcpha; /* TCP header in conn_ht_iphc */ + + uint16_t tcp_last_sent_len; /* Record length for nagle */ + uint16_t tcp_last_recv_len; /* Used by DTrace */ + uint16_t tcp_dupack_cnt; /* # of consequtive duplicate acks */ + + kmutex_t *tcp_acceptor_lockp; /* Ptr to tf_lock */ + + mblk_t *tcp_ordrel_mp; /* T_ordrel_ind mblk */ + t_uscalar_t tcp_acceptor_id; /* ACCEPTOR_id */ + + int tcp_ipsec_overhead; + + uint_t tcp_recvtos; /* Last received IP_RECVTOS */ + uint_t tcp_recvifindex; /* Last received IPV6_RCVPKTINFO */ + uint_t tcp_recvhops; /* Last received IPV6_RECVHOPLIMIT */ + uint_t tcp_recvtclass; /* Last received IPV6_RECVTCLASS */ + ip6_hbh_t *tcp_hopopts; /* Last received IPV6_RECVHOPOPTS */ + ip6_dest_t *tcp_dstopts; /* Last received IPV6_RECVDSTOPTS */ + ip6_dest_t *tcp_rthdrdstopts; /* Last recv IPV6_RECVRTHDRDSTOPTS */ + ip6_rthdr_t *tcp_rthdr; /* Last received IPV6_RECVRTHDR */ + uint_t tcp_hopoptslen; + uint_t tcp_dstoptslen; + uint_t tcp_rthdrdstoptslen; + uint_t tcp_rthdrlen; + + mblk_t *tcp_timercache; + + kmutex_t tcp_closelock; + kcondvar_t tcp_closecv; + uint8_t tcp_closed; + uint8_t tcp_closeflags; + mblk_t tcp_closemp; + timeout_id_t tcp_linger_tid; /* Linger timer ID */ + + struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */ + struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */ + struct tcp_s *tcp_bind_hash; /* Bind hash chain */ + struct tcp_s *tcp_bind_hash_port; /* tcp_t's bound to the same lport */ + struct tcp_s **tcp_ptpbhn; + + /* + * Group of tcp_t entries bound to the same adress and port via + * SO_REUSEPORT. The pointer itself is protected by tf_lock in the + * containing tcps_bind_fanout slot. + */ + struct tcp_rg_s *tcp_rg_bind; + + uint_t tcp_maxpsz_multiplier; + + uint32_t tcp_lso_max; /* maximum LSO payload */ + + uint32_t tcp_ofo_fin_seq; /* Recv out of order FIN seq num */ + uint32_t tcp_cwr_snd_max; + + struct tcp_s *tcp_saved_listener; /* saved value of listener */ + + uint32_t tcp_in_ack_unsent; /* ACK for unsent data cnt. */ + + /* + * All fusion-related fields are protected by squeue. + */ + struct tcp_s *tcp_loopback_peer; /* peer tcp for loopback */ + mblk_t *tcp_fused_sigurg_mp; /* M_PCSIG mblk for SIGURG */ + + uint32_t + tcp_fused : 1, /* loopback tcp in fusion mode */ + tcp_unfusable : 1, /* fusion not allowed on endpoint */ + tcp_fused_sigurg : 1, /* send SIGURG upon draining */ + + tcp_fuse_to_bit_31 : 29; + + kmutex_t tcp_non_sq_lock; + + /* + * This variable is accessed without any lock protection + * and therefore must not be declared as a bit field along + * with the rest which require such condition. + */ + boolean_t tcp_issocket; /* this is a socket tcp */ + + /* protected by the tcp_non_sq_lock lock */ + uint32_t tcp_squeue_bytes; + + /* + * tcp_closemp_used is protected by listener's tcp_eager_lock + * when used for eagers. When used for a tcp in TIME_WAIT state + * or in tcp_close(), it is not protected by any lock as we + * do not expect any other thread to use it concurrently. + * We do allow re-use of tcp_closemp in tcp_time_wait_collector() + * and tcp_close() but not concurrently. + */ + boolean_t tcp_closemp_used; + + /* + * previous and next eagers in the list of droppable eagers. See + * the comments before MAKE_DROPPABLE(). These pointers are + * protected by listener's tcp_eager_lock. + */ + struct tcp_s *tcp_eager_prev_drop_q0; + struct tcp_s *tcp_eager_next_drop_q0; + + /* + * Have we flow controlled xmitter? + * This variable can be modified outside the squeue and hence must + * not be declared as a bit field along with the rest that are + * modified only within the squeue. + * protected by the tcp_non_sq_lock lock. + */ + boolean_t tcp_flow_stopped; + + /* + * Sender's next sequence number at the time the window was shrunk. + */ + uint32_t tcp_snxt_shrunk; + + /* + * Socket generation number which is bumped when a connection attempt + * is initiated. Its main purpose is to ensure that the socket does not + * miss the asynchronous connected/disconnected notification. + */ + sock_connid_t tcp_connid; + + /* mblk_t used to enter TCP's squeue from the service routine. */ + mblk_t *tcp_rsrv_mp; + /* Mutex for accessing tcp_rsrv_mp */ + kmutex_t tcp_rsrv_mp_lock; + + /* For connection counting. */ + struct tcp_listen_cnt_s *tcp_listen_cnt; + + /* Segment reassembly timer. */ + timeout_id_t tcp_reass_tid; + + /* FIN-WAIT-2 flush timeout */ + uint32_t tcp_fin_wait_2_flush_interval; + + tcp_conn_stats_t tcp_cs; + + /* + * The cached inbound and outbound security associations (SAs) for the + * TCP signature (TCP_MD5SIG). + */ + void *tcp_sig_sa_in; + void *tcp_sig_sa_out; + +#ifdef DEBUG + pc_t tcmp_stk[15]; +#endif +} tcp_t; + +#ifdef DEBUG +#define TCP_DEBUG_GETPCSTACK(buffer, depth) ((void) getpcstack(buffer, \ + depth)) +#else +#define TCP_DEBUG_GETPCSTACK(buffer, depth) +#endif + +extern void tcp_conn_reclaim(void *); +extern void tcp_free(tcp_t *tcp); +extern void tcp_ddi_g_init(void); +extern void tcp_ddi_g_destroy(void); +extern conn_t *tcp_get_conn(void *arg, tcp_stack_t *); +extern mblk_t *tcp_snmp_get(queue_t *, mblk_t *, boolean_t); +extern int tcp_snmp_set(queue_t *, int, int, uchar_t *, int len); + +/* Pad for the tf_t structure to avoid false cache line sharing. */ +#define TF_CACHEL_PAD 64 + +/* + * The TCP Fanout structure for bind and acceptor hashes. + * The hash tables and their linkage (tcp_*_hash, tcp_ptp*hn) are + * protected by the per-bucket tf_lock. Each tcp_t + * inserted in the list points back at this lock using tcp_*_lockp. + * + * The bind and acceptor hash queues are lists of tcp_t. + */ +/* listener hash and acceptor hash queue head */ +typedef struct tf_s { + tcp_t *tf_tcp; + kmutex_t tf_lock; + unsigned char tf_pad[TF_CACHEL_PAD - + (sizeof (tcp_t *) + sizeof (kmutex_t))]; +} tf_t; + + +/* Also used in ipclassifier.c */ +extern struct kmem_cache *tcp_sack_info_cache; + +#endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ + +/* Contract private interface between TCP and Clustering. */ + +#define CL_TCPI_V1 1 /* cl_tcpi_version number */ + +typedef struct cl_tcp_info_s { + ushort_t cl_tcpi_version; /* cl_tcp_info_t's version no */ + ushort_t cl_tcpi_ipversion; /* IP version */ + int32_t cl_tcpi_state; /* TCP state */ + in_port_t cl_tcpi_lport; /* Local port */ + in_port_t cl_tcpi_fport; /* Remote port */ + in6_addr_t cl_tcpi_laddr_v6; /* Local IP address */ + in6_addr_t cl_tcpi_faddr_v6; /* Remote IP address */ +#ifdef _KERNEL +/* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */ +#define cl_tcpi_laddr V4_PART_OF_V6(cl_tcpi_laddr_v6) +#define cl_tcpi_faddr V4_PART_OF_V6(cl_tcpi_faddr_v6) + +#endif /* _KERNEL */ +} cl_tcp_info_t; + +/* + * Hook functions to enable cluster networking + * On non-clustered systems these vectors must always be NULL. + */ +extern void (*cl_inet_listen)(netstackid_t, uint8_t, sa_family_t, + uint8_t *, in_port_t, void *); +extern void (*cl_inet_unlisten)(netstackid_t, uint8_t, sa_family_t, + uint8_t *, in_port_t, void *); + +/* + * Contracted Consolidation Private ioctl for aborting TCP connections. + * In order to keep the offsets and size of the structure the same between + * a 32-bit application and a 64-bit amd64 kernel, we use a #pragma + * pack(4). + */ +#define TCP_IOC_ABORT_CONN (('T' << 8) + 91) + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct tcp_ioc_abort_conn_s { + struct sockaddr_storage ac_local; /* local addr and port */ + struct sockaddr_storage ac_remote; /* remote addr and port */ + int32_t ac_start; /* start state */ + int32_t ac_end; /* end state */ + int32_t ac_zoneid; /* zoneid */ +} tcp_ioc_abort_conn_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_TCP_H */ diff --git a/illumos-x86_64/usr/include/inet/tcp_sack.h b/illumos-x86_64/usr/include/inet/tcp_sack.h new file mode 100644 index 00000000..5a4e9e4f --- /dev/null +++ b/illumos-x86_64/usr/include/inet/tcp_sack.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _INET_TCP_SACK_H +#define _INET_TCP_SACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Maximum num of receiver's SACK blocks */ +#define MAX_SACK_BLK 5 + +/* Receiver's SACK blk structure */ +typedef struct sack_blk +{ + tcp_seq begin; + tcp_seq end; +} sack_blk_t; + +/* Sender's notsack'ed blk structure */ +typedef struct notsack_blk +{ + struct notsack_blk *next; + tcp_seq begin; + tcp_seq end; + uint32_t sack_cnt; /* Dup SACK count */ +} notsack_blk_t; + + +/* SACK information in the tcp_t structure. */ +typedef struct +{ + int32_t tcp_pipe; /* # of bytes in network */ + tcp_seq tcp_fack; /* highest sack'ed seq num */ + tcp_seq tcp_sack_snxt; /* next seq num to be rexmited using SACK. */ + + int32_t tcp_max_sack_blk; /* max # of SACK info blk in a segment */ + int32_t tcp_num_sack_blk; /* num of blks in sack list */ + sack_blk_t tcp_sack_list[MAX_SACK_BLK]; /* the sack list */ + + /* num of blks in notsack list */ + int32_t tcp_num_notsack_blk; + /* # of bytes represented in blks in notsack list */ + uint32_t tcp_cnt_notsack_list; + /* the notsack list */ + notsack_blk_t *tcp_notsack_list; +} tcp_sack_info_t; + +extern void tcp_sack_insert(sack_blk_t *, tcp_seq, tcp_seq, int32_t *); +extern void tcp_sack_remove(sack_blk_t *, tcp_seq, int32_t *); +extern void tcp_notsack_insert(notsack_blk_t **, tcp_seq, tcp_seq, + int32_t *, uint32_t *); +extern void tcp_notsack_remove(notsack_blk_t **, tcp_seq, int32_t *, + uint32_t *); +extern void tcp_notsack_update(notsack_blk_t **, tcp_seq, tcp_seq, + int32_t *, uint32_t *); + +/* Defined in tcp_sack.c */ +extern kmem_cache_t *tcp_notsack_blk_cache; + +/* + * Macro to remove all the notsack'ed blks in sender. + * + * Param: + * notsack_blk_t *head: pointer to the head of the list of notsack'ed blks. + */ +#define TCP_NOTSACK_REMOVE_ALL(head, tcp) \ +{ \ + if ((head) != NULL) { \ + notsack_blk_t *prev, *tmp; \ + tmp = (head); \ + do { \ + prev = tmp; \ + tmp = tmp->next; \ + kmem_cache_free(tcp_notsack_blk_cache, prev); \ + } while (tmp != NULL); \ + (head) = NULL; \ + (tcp)->tcp_cnt_notsack_list = 0; \ + (tcp)->tcp_num_notsack_blk = 0; \ + } else { \ + ASSERT((tcp)->tcp_cnt_notsack_list == 0); \ + ASSERT((tcp)->tcp_num_notsack_blk == 0); \ + } \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_TCP_SACK_H */ diff --git a/illumos-x86_64/usr/include/inet/tcp_stack.h b/illumos-x86_64/usr/include/inet/tcp_stack.h new file mode 100644 index 00000000..82ecabeb --- /dev/null +++ b/illumos-x86_64/usr/include/inet/tcp_stack.h @@ -0,0 +1,142 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. + */ + +#ifndef _INET_TCP_STACK_H +#define _INET_TCP_STACK_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * TCP stack instances + */ +struct tcp_stack { + netstack_t *tcps_netstack; /* Common netstack */ + + /* + * Extra privileged ports. In host byte order. + * Protected by tcp_epriv_port_lock. + */ +#define TCP_NUM_EPRIV_PORTS 64 + int tcps_g_num_epriv_ports; + in_port_t tcps_g_epriv_ports[TCP_NUM_EPRIV_PORTS]; + kmutex_t tcps_epriv_port_lock; + + /* + * The smallest anonymous port in the priviledged port range which TCP + * looks for free port. Use in the option TCP_ANONPRIVBIND. + */ + in_port_t tcps_min_anonpriv_port; + + /* holds the tcp tunables */ + struct mod_prop_info_s *tcps_propinfo_tbl; + + /* Hint not protected by any lock */ + uint_t tcps_next_port_to_try; + + /* TCP bind hash list - all tcp_t with state >= BOUND. */ + struct tf_s *tcps_bind_fanout; + + /* TCP queue hash list - all tcp_t in case they will be an acceptor. */ + struct tf_s *tcps_acceptor_fanout; + + /* + * MIB-2 stuff for SNMP + * Note: tcpInErrs {tcp 15} is accumulated in ip.c + */ + kstat_t *tcps_mibkp; /* kstat exporting mib2_tcp_t data */ + kstat_t *tcps_kstat; /* kstat exporting tcp_stat_t data */ + + uint32_t tcps_iss_incr_extra; + /* Incremented for each connection */ + kmutex_t tcps_iss_key_lock; + MD5_CTX tcps_iss_key; + + /* Packet dropper for TCP IPsec policy drops. */ + ipdropper_t tcps_dropper; + + /* + * These two variables control the rate for TCP to generate RSTs in + * response to segments not belonging to any connections. We limit + * TCP to sent out tcp_rst_sent_rate (ndd param) number of RSTs in + * each 1 second interval. This is to protect TCP against DoS attack. + */ + int64_t tcps_last_rst_intrvl; + uint32_t tcps_rst_cnt; + + ldi_ident_t tcps_ldi_ident; + + /* Used to synchronize access when reclaiming memory */ + mblk_t *tcps_ixa_cleanup_mp; + kmutex_t tcps_ixa_cleanup_lock; + kcondvar_t tcps_ixa_cleanup_ready_cv; + kcondvar_t tcps_ixa_cleanup_done_cv; + + /* Variables for handling kmem reclaim call back. */ + kmutex_t tcps_reclaim_lock; + boolean_t tcps_reclaim; + timeout_id_t tcps_reclaim_tid; + uint32_t tcps_reclaim_period; + + /* Listener connection limit configuration. */ + kmutex_t tcps_listener_conf_lock; + list_t tcps_listener_conf; + + struct cc_algo *tcps_default_cc_algo; + + /* TCP signature database and lock. */ + kmutex_t tcps_sigdb_lock; + void *tcps_sigdb; + + /* + * Per CPU stats + * + * tcps_sc: array of pointer to per CPU stats. The i-th element in the + * array represents the stats of the CPU with cpu_seqid. + * tcps_sc_cnt: number of CPU stats in the tcps_sc array. + */ + tcp_stats_cpu_t **tcps_sc; + int tcps_sc_cnt; +}; + +typedef struct tcp_stack tcp_stack_t; + +#endif /* _KERNEL */ +#ifdef __cplusplus +} +#endif + +#endif /* _INET_TCP_STACK_H */ diff --git a/illumos-x86_64/usr/include/inet/tcp_stats.h b/illumos-x86_64/usr/include/inet/tcp_stats.h new file mode 100644 index 00000000..bd18d169 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/tcp_stats.h @@ -0,0 +1,283 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015 by Delphix. All rights reserved. + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _INET_TCP_STATS_H +#define _INET_TCP_STATS_H + +/* + * TCP private kernel statistics declarations. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * TCP Statistics. + * + * How TCP statistics work. + * + * There are two types of statistics invoked by two macros. + * + * TCP_STAT(name) does non-atomic increment of a named stat counter. It is + * supposed to be used in non MT-hot paths of the code. + * + * TCP_DBGSTAT(name) does atomic increment of a named stat counter. It is + * supposed to be used for DEBUG purposes and may be used on a hot path. + * These counters are only available in a debugged kernel. They are grouped + * under the TCP_DEBUG_COUNTER C pre-processor condition. + * + * Both TCP_STAT and TCP_DBGSTAT counters are available using kstat + * (use "kstat tcp" to get them). + * + * How to add new counters. + * + * 1) Add a field in the tcp_stat structure describing your counter. + * 2) Add a line in the template in tcp_kstat2_init() with the name + * of the counter. + * 3) Update tcp_clr_stats() and tcp_cp_stats() with the new counters. + * IMPORTANT!! - make sure that all the above functions are in sync !! + * 4) Use either TCP_STAT or TCP_DBGSTAT with the name. + * + * Please avoid using private counters which are not kstat-exported. + * + * Implementation note. + * + * Both the MIB2 and tcp_stat_t counters are kept per CPU in the array + * tcps_sc in tcp_stack_t. Each array element is a pointer to a + * tcp_stats_cpu_t struct. Once allocated, the tcp_stats_cpu_t struct is + * not freed until the tcp_stack_t is going away. So there is no need to + * acquire a lock before accessing the stats counters. + */ + +#ifndef TCP_DEBUG_COUNTER +#ifdef DEBUG +#define TCP_DEBUG_COUNTER 1 +#else +#define TCP_DEBUG_COUNTER 0 +#endif +#endif + +/* Kstats */ +typedef struct tcp_stat { + kstat_named_t tcp_time_wait_syn_success; + kstat_named_t tcp_clean_death_nondetached; + kstat_named_t tcp_eager_blowoff_q; + kstat_named_t tcp_eager_blowoff_q0; + kstat_named_t tcp_no_listener; + kstat_named_t tcp_listendrop; + kstat_named_t tcp_listendropq0; + kstat_named_t tcp_wsrv_called; + kstat_named_t tcp_flwctl_on; + kstat_named_t tcp_timer_fire_early; + kstat_named_t tcp_timer_fire_miss; + kstat_named_t tcp_zcopy_on; + kstat_named_t tcp_zcopy_off; + kstat_named_t tcp_zcopy_backoff; + kstat_named_t tcp_fusion_flowctl; + kstat_named_t tcp_fusion_backenabled; + kstat_named_t tcp_fusion_urg; + kstat_named_t tcp_fusion_putnext; + kstat_named_t tcp_fusion_unfusable; + kstat_named_t tcp_fusion_aborted; + kstat_named_t tcp_fusion_unqualified; + kstat_named_t tcp_fusion_rrw_busy; + kstat_named_t tcp_fusion_rrw_msgcnt; + kstat_named_t tcp_fusion_rrw_plugged; + kstat_named_t tcp_in_ack_unsent_drop; + kstat_named_t tcp_sock_fallback; + kstat_named_t tcp_lso_enabled; + kstat_named_t tcp_lso_disabled; + kstat_named_t tcp_lso_times; + kstat_named_t tcp_lso_pkt_out; + kstat_named_t tcp_listen_cnt_drop; + kstat_named_t tcp_listen_mem_drop; + kstat_named_t tcp_zwin_mem_drop; + kstat_named_t tcp_zwin_ack_syn; + kstat_named_t tcp_rst_unsent; + kstat_named_t tcp_reclaim_cnt; + kstat_named_t tcp_reass_timeout; + kstat_named_t tcp_sig_no_option; + kstat_named_t tcp_sig_no_space; + kstat_named_t tcp_sig_match_failed; + kstat_named_t tcp_sig_verify_failed; + kstat_named_t tcp_sig_degraded; +#ifdef TCP_DEBUG_COUNTER + kstat_named_t tcp_time_wait; + kstat_named_t tcp_rput_time_wait; + kstat_named_t tcp_detach_time_wait; + kstat_named_t tcp_timeout_calls; + kstat_named_t tcp_timeout_cached_alloc; + kstat_named_t tcp_timeout_cancel_reqs; + kstat_named_t tcp_timeout_canceled; + kstat_named_t tcp_timermp_freed; + kstat_named_t tcp_push_timer_cnt; + kstat_named_t tcp_ack_timer_cnt; +#endif +} tcp_stat_t; + +/* + * This struct contains only the counter part of tcp_stat_t. It is used + * in tcp_stats_cpu_t instead of tcp_stat_t to save memory space. + */ +typedef struct tcp_stat_counter_s { + uint64_t tcp_time_wait_syn_success; + uint64_t tcp_clean_death_nondetached; + uint64_t tcp_eager_blowoff_q; + uint64_t tcp_eager_blowoff_q0; + uint64_t tcp_no_listener; + uint64_t tcp_listendrop; + uint64_t tcp_listendropq0; + uint64_t tcp_wsrv_called; + uint64_t tcp_flwctl_on; + uint64_t tcp_timer_fire_early; + uint64_t tcp_timer_fire_miss; + uint64_t tcp_zcopy_on; + uint64_t tcp_zcopy_off; + uint64_t tcp_zcopy_backoff; + uint64_t tcp_fusion_flowctl; + uint64_t tcp_fusion_backenabled; + uint64_t tcp_fusion_urg; + uint64_t tcp_fusion_putnext; + uint64_t tcp_fusion_unfusable; + uint64_t tcp_fusion_aborted; + uint64_t tcp_fusion_unqualified; + uint64_t tcp_fusion_rrw_busy; + uint64_t tcp_fusion_rrw_msgcnt; + uint64_t tcp_fusion_rrw_plugged; + uint64_t tcp_in_ack_unsent_drop; + uint64_t tcp_sock_fallback; + uint64_t tcp_lso_enabled; + uint64_t tcp_lso_disabled; + uint64_t tcp_lso_times; + uint64_t tcp_lso_pkt_out; + uint64_t tcp_listen_cnt_drop; + uint64_t tcp_listen_mem_drop; + uint64_t tcp_zwin_mem_drop; + uint64_t tcp_zwin_ack_syn; + uint64_t tcp_rst_unsent; + uint64_t tcp_reclaim_cnt; + uint64_t tcp_reass_timeout; + uint64_t tcp_sig_no_option; + uint64_t tcp_sig_no_space; + uint64_t tcp_sig_match_failed; + uint64_t tcp_sig_verify_failed; + uint64_t tcp_sig_degraded; +#ifdef TCP_DEBUG_COUNTER + uint64_t tcp_time_wait; + uint64_t tcp_rput_time_wait; + uint64_t tcp_detach_time_wait; + uint64_t tcp_timeout_calls; + uint64_t tcp_timeout_cached_alloc; + uint64_t tcp_timeout_cancel_reqs; + uint64_t tcp_timeout_canceled; + uint64_t tcp_timermp_freed; + uint64_t tcp_push_timer_cnt; + uint64_t tcp_ack_timer_cnt; +#endif +} tcp_stat_counter_t; + +typedef struct tcp_g_stat { + kstat_named_t tcp_timermp_alloced; + kstat_named_t tcp_timermp_allocfail; + kstat_named_t tcp_timermp_allocdblfail; + kstat_named_t tcp_freelist_cleanup; +} tcp_g_stat_t; + +/* Per CPU stats: TCP MIB2, TCP kstat and connection counter. */ +typedef struct { + int64_t tcp_sc_conn_cnt; + mib2_tcp_t tcp_sc_mib; + tcp_stat_counter_t tcp_sc_stats; +} tcp_stats_cpu_t; + +/* + * Per-connection statistics. Some of these are also kept globally in the + * per-cpu tcp_sc_mib entry (see tcp_stats_cpu_t above). We need not maintain + * per-cpu versions of these stats since a connection is typically processed + * on the same CPU. + */ +typedef struct tcp_conn_stats { + uint64_t tcp_in_data_inorder_bytes; + uint64_t tcp_in_data_inorder_segs; + uint64_t tcp_in_data_unorder_bytes; + uint64_t tcp_in_data_unorder_segs; + uint64_t tcp_in_zwnd_probes; + + uint64_t tcp_out_data_bytes; + uint64_t tcp_out_data_segs; + uint64_t tcp_out_retrans_bytes; + uint64_t tcp_out_retrans_segs; + uint64_t tcp_out_zwnd_probes; +} tcp_conn_stats_t; + +#define TCPS_BUMP_MIB(tcps, x) \ + BUMP_MIB(&(tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_mib, x) + +#define TCPS_UPDATE_MIB(tcps, x, y) \ + UPDATE_MIB(&(tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_mib, x, y) + +#if TCP_DEBUG_COUNTER +#define TCP_DBGSTAT(tcps, x) \ + atomic_inc_64( \ + &((tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_stats.x)) +#define TCP_G_DBGSTAT(x) \ + atomic_inc_64(&(tcp_g_statistics.x.value.ui64)) +#else +#define TCP_DBGSTAT(tcps, x) +#define TCP_G_DBGSTAT(x) +#endif + +#define TCP_G_STAT(x) (tcp_g_statistics.x.value.ui64++) + +#define TCP_STAT(tcps, x) \ + ((tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_stats.x++) +#define TCP_STAT_UPDATE(tcps, x, n) \ + ((tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_stats.x += (n)) +#define TCP_STAT_SET(tcps, x, n) \ + ((tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_stats.x = (n)) + +/* Global TCP stats for all IP stacks. */ +extern tcp_g_stat_t tcp_g_statistics; +extern kstat_t *tcp_g_kstat; + +extern void *tcp_g_kstat_init(tcp_g_stat_t *); +extern void tcp_g_kstat_fini(kstat_t *); +extern void *tcp_kstat_init(netstackid_t); +extern void tcp_kstat_fini(netstackid_t, kstat_t *); +extern void *tcp_kstat2_init(netstackid_t); +extern void tcp_kstat2_fini(netstackid_t, kstat_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_TCP_STATS_H */ diff --git a/illumos-x86_64/usr/include/inet/tunables.h b/illumos-x86_64/usr/include/inet/tunables.h new file mode 100644 index 00000000..cd425e69 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/tunables.h @@ -0,0 +1,196 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1990 Mentat Inc. + * Copyright (c) 2013 by Delphix. All rights reserved. + */ + +#ifndef _INET_TUNABLES_H +#define _INET_TUNABLES_H + +#include +#include +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAXPROPNAMELEN 64 + +/* + * The `mod_ioc_prop_s' datastructure is used as an IOCTL argument for + * SIOCSETPROP and SIOCGETPROP ioctls. This datastructure identifies the + * protocol (`mpr_proto') property (`mpr_name'), which needs to be modified + * or retrieved (`mpr_valsize' and `mpr_val'). If the property applies to an + * interface then `mpr_ifname' contains the name of the interface. + */ +typedef struct mod_ioc_prop_s { + uint_t mpr_version; + uint_t mpr_flags; /* see below */ + /* name of the interface (ill) for which property will be applied */ + char mpr_ifname[LIFNAMSIZ]; + uint_t mpr_proto; /* see below */ + char mpr_name[MAXPROPNAMELEN]; /* property name */ + uint_t mpr_valsize; /* size of mpr_val */ + char mpr_val[1]; +} mod_ioc_prop_t; + +#define MOD_PROP_VERSION 1 + +/* permission flags for properties */ +#define MOD_PROP_PERM_READ 0x1 +#define MOD_PROP_PERM_WRITE 0x2 +#define MOD_PROP_PERM_RW (MOD_PROP_PERM_READ|MOD_PROP_PERM_WRITE) + +/* mpr_flags values */ +#define MOD_PROP_ACTIVE 0x01 /* current value of the property */ +#define MOD_PROP_DEFAULT 0x02 /* default value of the property */ +#define MOD_PROP_POSSIBLE 0x04 /* possible values for the property */ +#define MOD_PROP_PERM 0x08 /* read/write permission for property */ +#define MOD_PROP_APPEND 0x10 /* append to multi-valued property */ +#define MOD_PROP_REMOVE 0x20 /* remove from multi-valued property */ + +/* mpr_proto values */ +#define MOD_PROTO_NONE 0x00 +#define MOD_PROTO_IPV4 0x01 /* property is applicable to IPV4 */ +#define MOD_PROTO_IPV6 0x02 /* property is applicable to IPV6 */ +#define MOD_PROTO_RAWIP 0x04 /* property is applicable to ICMP */ +#define MOD_PROTO_TCP 0x08 /* property is applicable to TCP */ +#define MOD_PROTO_UDP 0x10 /* property is applicable to UDP */ +#define MOD_PROTO_SCTP 0x20 /* property is applicable to SCTP */ + +/* property is applicable to both IPV[4|6] */ +#define MOD_PROTO_IP (MOD_PROTO_IPV4|MOD_PROTO_IPV6) + +#ifdef _KERNEL + +typedef struct mod_prop_info_s mod_prop_info_t; + +/* set/get property callback functions */ +typedef int mod_prop_setf_t(netstack_t *, cred_t *, mod_prop_info_t *, + const char *, const void *, uint_t); +typedef int mod_prop_getf_t(netstack_t *, mod_prop_info_t *, const char *, + void *, uint_t, uint_t); + +typedef struct mod_propval_uint32_s { + uint32_t mod_propval_umin; + uint32_t mod_propval_umax; + uint32_t mod_propval_ucur; +} mod_propval_uint32_t; + +/* + * protocol property information + */ +struct mod_prop_info_s { + char *mpi_name; /* property name */ + uint_t mpi_proto; /* property protocol */ + mod_prop_setf_t *mpi_setf; /* sets the property value */ + mod_prop_getf_t *mpi_getf; /* gets the property value */ + /* + * Holds the current value of the property. Whenever applicable + * holds the min/max value too. + */ + union { + mod_propval_uint32_t mpi_uval; + boolean_t mpi_bval; + uint64_t _pad[2]; + } u; + /* + * Holds the default value of the property, that is value of + * the property at boot time. + */ + union { + uint32_t mpi_def_uval; + boolean_t mpi_def_bval; + } u_def; +}; + +/* shortcuts to access current/default values */ +#define prop_min_uval u.mpi_uval.mod_propval_umin +#define prop_max_uval u.mpi_uval.mod_propval_umax +#define prop_cur_uval u.mpi_uval.mod_propval_ucur +#define prop_cur_bval u.mpi_bval +#define prop_def_uval u_def.mpi_def_uval +#define prop_def_bval u_def.mpi_def_bval + +#define MS 1L +#define SECONDS (1000 * MS) +#define MINUTES (60 * SECONDS) +#define HOURS (60 * MINUTES) +#define DAYS (24 * HOURS) + +#define MB (1024 * 1024) + +/* Largest TCP/UDP/SCTP port number */ +#define ULP_MAX_PORT (64 * 1024 - 1) + +/* extra privilege ports for upper layer protocols, tcp, sctp and udp */ +#define ULP_DEF_EPRIV_PORT1 2049 +#define ULP_DEF_EPRIV_PORT2 4045 + +#define ULP_MAX_BUF (1<<30) /* Largest possible send/receive buffer */ + +/* generic function to set/get global module properties */ +extern mod_prop_setf_t mod_set_boolean, mod_set_uint32, + mod_set_aligned, mod_set_extra_privports; + +extern mod_prop_getf_t mod_get_boolean, mod_get_uint32, + mod_get_allprop, mod_get_extra_privports; + +extern int mod_uint32_value(const void *, mod_prop_info_t *, + uint_t, unsigned long *); +extern mod_prop_info_t *mod_prop_lookup(mod_prop_info_t[], const char *, + uint_t); +extern int mod_set_buf_prop(mod_prop_info_t[], netstack_t *, + cred_t *cr, mod_prop_info_t *, const char *, const void *, uint_t); +extern int mod_get_buf_prop(mod_prop_info_t[], netstack_t *, + mod_prop_info_t *, const char *, void *, uint_t, uint_t); + +#endif /* _KERNEL */ + +/* + * End-system model definitions that include the weak/strong end-system + * definitions in RFC 1122, Section 3.3.4.5. IP_WEAK_ES and IP_STRONG_ES + * conform to the corresponding RFC 1122 definitions. The IP_SRC_PRI_ES + * hostmodel is similar to IP_WEAK_ES with one additional enhancement: for + * a packet with source S2, destination D2, the route selection algorithm + * will first attempt to find a route for the destination that goes out + * through an interface where S2 is configured and marked UP. If such + * a route cannot be found, then the best-matching route for D2 will be + * selected, ignoring any mismatches between S2 and the interface addresses + * on the outgoing interface implied by the route. + */ +typedef enum { + IP_WEAK_ES = 0, + IP_SRC_PRI_ES, + IP_STRONG_ES, + IP_MAXVAL_ES +} ip_hostmodel_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_TUNABLES_H */ diff --git a/illumos-x86_64/usr/include/inet/wifi_ioctl.h b/illumos-x86_64/usr/include/inet/wifi_ioctl.h new file mode 100644 index 00000000..08b78099 --- /dev/null +++ b/illumos-x86_64/usr/include/inet/wifi_ioctl.h @@ -0,0 +1,396 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Macro and date structures defined for 802.11 wifi config tool. + */ + +#ifndef __WIFI_IOCTL_H +#define __WIFI_IOCTL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_KEY_LENGTH 26 +#define MAX_ESSID_LENGTH (32 + 1) /* max essid length is 32 */ + /* one more for '\0' */ +#define MAX_CHANNEL_NUM 99 +#define MAX_RSSI 15 +#define MAX_NWEPKEYS 4 +#define NET_802_11 80211 +#define MAX_BUF_LEN 65536 +#define MAX_SCAN_SUPPORT_RATES 8 + +/* + * ioctls + */ +#define WLAN_IOCTL_BASE 0x1000 +#define WLAN_GET_VERSION (WLAN_IOCTL_BASE + 0x0) +#define WLAN_SET_PARAM (WLAN_IOCTL_BASE + 0x2) +#define WLAN_GET_PARAM (WLAN_IOCTL_BASE + 0x3) +#define WLAN_COMMAND (WLAN_IOCTL_BASE + 0x4) + +/* + * parameters + */ +#define WL_PARAMETERS_BASE 0x2000 +#define WL_BSSID (WL_PARAMETERS_BASE + 0x0) +#define WL_ESSID (WL_PARAMETERS_BASE + 0x1) +#define WL_NODE_NAME (WL_PARAMETERS_BASE + 0x2) +#define WL_PHY_SUPPORT (WL_PARAMETERS_BASE + 0x3) +#define WL_PHY_CONFIG (WL_PARAMETERS_BASE + 0x4) +#define WL_DOMAIN (WL_PARAMETERS_BASE + 0x5) +#define WL_POWER_MODE (WL_PARAMETERS_BASE + 0x6) +#define WL_TX_POWER (WL_PARAMETERS_BASE + 0x7) +#define WL_RSSI (WL_PARAMETERS_BASE + 0x8) +#define WL_RSSI_THRESHOLD (WL_PARAMETERS_BASE + 0x9) +#define WL_ESS_LIST (WL_PARAMETERS_BASE + 0xa) +#define WL_BSS_TYPE (WL_PARAMETERS_BASE + 0xb) +#define WL_CREATE_IBSS (WL_PARAMETERS_BASE + 0xc) +#define WL_RTS_THRESHOLD (WL_PARAMETERS_BASE + 0xd) +#define WL_SHORT_RETRY (WL_PARAMETERS_BASE + 0xe) +#define WL_LONG_RETRY (WL_PARAMETERS_BASE + 0xf) +#define WL_BEACON_PERIOD (WL_PARAMETERS_BASE + 0x10) +#define WL_TX_LIFETIME (WL_PARAMETERS_BASE + 0x11) +#define WL_RX_LIFETIME (WL_PARAMETERS_BASE + 0x12) +#define WL_FRAG_THRESHOLD (WL_PARAMETERS_BASE + 0x13) +#define WL_VENDOR_ID (WL_PARAMETERS_BASE + 0x14) +#define WL_PRODUCT_ID (WL_PARAMETERS_BASE + 0x15) +#define WL_NUM_ANTS (WL_PARAMETERS_BASE + 0x16) +#define WL_RX_ANTENNA (WL_PARAMETERS_BASE + 0x17) +#define WL_TX_ANTENNA (WL_PARAMETERS_BASE + 0x18) +#define WL_SUPPORTED_RATES (WL_PARAMETERS_BASE + 0x19) +#define WL_DESIRED_RATES (WL_PARAMETERS_BASE + 0x1a) +#define WL_WEP_KEY_TAB (WL_PARAMETERS_BASE + 0x1b) +#define WL_WEP_KEY_ID (WL_PARAMETERS_BASE + 0x1c) +#define WL_WEP_MAPPING_TAB (WL_PARAMETERS_BASE + 0x1d) +#define WL_WEP_MAPPING_LEN (WL_PARAMETERS_BASE + 0x1e) +#define WL_ENCRYPTION (WL_PARAMETERS_BASE + 0x1f) +#define WL_AUTH_MODE (WL_PARAMETERS_BASE + 0x20) +#define WL_EXCL_UNENC (WL_PARAMETERS_BASE + 0x21) +#define WL_RFMON (WL_PARAMETERS_BASE + 0x22) +#define WL_RADIO (WL_PARAMETERS_BASE + 0x23) +#define WL_LINKSTATUS (WL_PARAMETERS_BASE + 0x24) +#define WL_DEV_DEPEND (WL_PARAMETERS_BASE + 0x25) +/* + * commands + */ +#define WL_COMMAND_BASE 0x3000 +#define WL_SCAN (WL_COMMAND_BASE + 0x0) +#define WL_DISASSOCIATE (WL_COMMAND_BASE + 0x1) +#define WL_REASSOCIATE (WL_COMMAND_BASE + 0x2) +#define WL_LOAD_DEFAULTS (WL_COMMAND_BASE + 0x3) +#define WL_ASSOCIAT (WL_COMMAND_BASE + 0x4) + +/* + * domains + */ +/* --USA */ +#define WL_DOMAIN_BASE 0x4000 +#define WL_DOMAIN_FCC (WL_DOMAIN_BASE + 0x0) +/* --Canada */ +#define WL_DOMAIN_DOC (WL_DOMAIN_BASE + 0x1) +/* --Most of Europe */ +#define WL_DOMAIN_ETSI (WL_DOMAIN_BASE + 0x2) +/* --Spain */ +#define WL_DOMAIN_SPAIN (WL_DOMAIN_BASE + 0x3) +/* --France */ +#define WL_DOMAIN_FRANCE (WL_DOMAIN_BASE + 0x4) +/* --Japan */ +#define WL_DOMAIN_MKK (WL_DOMAIN_BASE + 0x5) + +/* + * power mode + */ + +#define WL_PM_AM 0x0 +#define WL_PM_MPS 0x1 +#define WL_PM_FAST 0x2 +#define WL_PM_USER 0x3 + +/* + * rates + */ +#define WL_RATE_BASIC_SET 0x80 +#define WL_RATE_1M 2 +#define WL_RATE_2M 4 +#define WL_RATE_5_5M 11 +#define WL_RATE_6M 12 +#define WL_RATE_9M 18 +#define WL_RATE_11M 22 +#define WL_RATE_12M 24 +#define WL_RATE_18M 36 +#define WL_RATE_22M 44 +#define WL_RATE_24M 48 +#define WL_RATE_33M 66 +#define WL_RATE_36M 72 +#define WL_RATE_48M 96 +#define WL_RATE_54M 108 +/* + * wep operations + */ +#define WL_WEP_OPERATION_BASE 0x6000 +#define WL_ADD (WL_WEP_OPERATION_BASE + 0x0) +#define WL_DEL (WL_WEP_OPERATION_BASE + 0x1) +#define WL_NUL (WL_WEP_OPERATION_BASE + 0x2) +#define WL_IND (WL_WEP_OPERATION_BASE + 0x3) + +#define WL_NOENCRYPTION 0x0 +#define WL_ENC_WEP 0x1 +#define WL_ENC_WPA 0x2 +#define WL_OPENSYSTEM 0x1 +#define WL_SHAREDKEY 0x2 + +/* + * linkstatus + */ +#define WL_CONNECTED 0x0 +#define WL_NOTCONNECTED 0x1 + +/* + * prives + */ +#define WL_PRIV_BASE 0x7000 +#define WL_PRIV_RW (WL_PRIV_BASE + 0x0) +#define WL_PRIV_R (WL_PRIV_BASE + 0x1) +#define WL_PRIV_W (WL_PRIV_BASE + 0x2) +#define WL_PRIV_INT (WL_PRIV_BASE + 0x3) +#define WL_PRIV_INT_ARRAY (WL_PRIV_BASE + 0x4) +#define WL_PRIV_BYTE (WL_PRIV_BASE + 0x5) +#define WL_PRIV_BYTE_ARRAY (WL_PRIV_BASE + 0x6) +#define WL_PRIV_STRING (WL_PRIV_BASE + 0x7) +#define WL_PRIV_STRING_ARRAY (WL_PRIV_BASE + 0x8) +/* + * return values + */ +#define WL_SUCCESS 0x0 +#define WL_NOTSUPPORTED EINVAL +#define WL_LACK_FEATURE ENOTSUP +#define WL_HW_ERROR EIO +#define WL_ACCESS_DENIED EACCES +#define WL_RETURN_BASE 0x7000 +#define WL_READONLY (WL_RETURN_BASE + 0x1) +#define WL_WRITEONLY (WL_RETURN_BASE + 0x2) +#define WL_NOAP (WL_RETURN_BASE + 0x3) +/* + * other values + */ +#define WL_OTHER_BASE 0x8000 +#define WL_FHSS (WL_OTHER_BASE + 0x0) +#define WL_DSSS (WL_OTHER_BASE + 0x1) +#define WL_IRBASE (WL_OTHER_BASE + 0x2) +#define WL_OFDM (WL_OTHER_BASE + 0x3) +#define WL_HRDS (WL_OTHER_BASE + 0x4) +#define WL_ERP (WL_OTHER_BASE + 0x5) + +#define WL_BSS_BSS 1 +#define WL_BSS_IBSS 3 +#define WL_BSS_ANY 2 +/* + * field_offset + */ +#define WIFI_BUF_OFFSET offsetof(wldp_t, wldp_buf) + +/* + * type definationes + */ +typedef boolean_t wl_create_ibss_t; +typedef char wl_bssid_t[6]; + +typedef struct wl_essid { + uint32_t wl_essid_length; + char wl_essid_essid[34]; +}wl_essid_t; + +typedef struct wl_nodename { + uint32_t wl_nodename_length; + char wl_nodename_name[34]; +} wl_nodename_t; + +typedef struct wl_phy_supported { + uint32_t wl_phy_support_num; + uint32_t wl_phy_support_phy_types[1]; +} wl_phy_supported_t; + +typedef struct wl_fhss { + uint32_t wl_fhss_subtype; + uint32_t wl_fhss_channel; + uint32_t wl_fhss_hoptime; + uint32_t wl_fhss_hoppattern; + uint32_t wl_fhss_hopset; + uint32_t wl_fhss_dwelltime; +} wl_fhss_t; + +typedef struct wl_dsss { + uint32_t wl_dsss_subtype; + uint32_t wl_dsss_channel; + boolean_t wl_dsss_have_short_preamble; + uint32_t wl_dsss_preamble_mode; + boolean_t wl_dsss_agility_enabled; + boolean_t wl_dsss_have_pbcc; + boolean_t wl_dsss_pbcc_enable; +} wl_dsss_t; + +typedef struct wl_ofdm { + uint32_t wl_ofdm_subtype; + uint32_t wl_ofdm_frequency; + uint32_t wl_ofdm_freq_supported; + boolean_t wl_ofdm_ht_enabled; +} wl_ofdm_t; + +typedef struct wl_erp { + uint32_t wl_erp_subtype; + uint32_t wl_erp_channel; + boolean_t wl_erp_have_short_preamble; + uint32_t wl_erp_preamble_mode; + boolean_t wl_erp_have_agility; + boolean_t wl_erp_agility_enabled; + boolean_t wl_erp_have_pbcc; + boolean_t wl_erp_pbcc_enabled; + boolean_t wl_erp_have_dsss_ofdm; + boolean_t wl_erp_dsss_ofdm_enabled; + boolean_t wl_erp_have_sst; + boolean_t wl_erp_sst_enabled; + boolean_t wl_erp_ht_enabled; +} wl_erp_t; + +typedef union wl_phy_conf { + wl_fhss_t wl_phy_fhss_conf; + wl_dsss_t wl_phy_dsss_conf; + wl_ofdm_t wl_phy_ofdm_conf; + wl_erp_t wl_phy_erp_conf; +} wl_phy_conf_t; + +typedef uint32_t wl_domain_t; + +typedef struct wl_ps_mode { + uint32_t wl_ps_mode; + uint32_t wl_ps_max_sleep; + uint32_t wl_ps_min_sleep; + uint32_t wl_ps_max_awake; + uint32_t wl_ps_min_awake; + boolean_t wl_ps_nobroadcast; +} wl_ps_mode_t; + +typedef uint32_t wl_linkstatus_t; +typedef uint32_t wl_tx_pwer_t; +typedef uint32_t wl_rssi_t; +typedef uint32_t wl_rssi_threshold_t; +typedef uint32_t wl_bss_type_t; +typedef uint32_t wl_authmode_t; +typedef uint32_t wl_encryption_t; +typedef uint32_t wl_wep_key_id_t; +typedef boolean_t wl_radio_t; +typedef uint32_t wl_rts_threshold_t; +typedef uint32_t wl_short_retry_t; +typedef uint32_t wl_long_retry_t; +typedef uint32_t wl_beacon_period_t; +typedef uint32_t wl_tx_lifetime_t; +typedef uint32_t wl_rx_lifetime_t; +typedef uint32_t wl_frag_threshold_t; +typedef char wl_vendor_t[128]; +typedef char wl_product_t[128]; +typedef uint32_t wl_num_ants_t; +typedef uint32_t wl_rx_antenna_t; +typedef uint32_t wl_tx_antenna_t; + +typedef struct wl_rates { + uint32_t wl_rates_num; + char wl_rates_rates[1]; +} wl_rates_t; + +typedef struct wl_ess_conf { + uint32_t wl_ess_conf_length; + wl_essid_t wl_ess_conf_essid; + wl_bssid_t wl_ess_conf_bssid; + char wl_ess_conf_reserved[2]; + wl_bss_type_t wl_ess_conf_bsstype; + wl_authmode_t wl_ess_conf_authmode; + boolean_t wl_ess_conf_wepenabled; + wl_rssi_t wl_ess_conf_sl; + union { + wl_fhss_t wl_phy_fhss_conf; + wl_dsss_t wl_phy_dsss_conf; + wl_ofdm_t wl_phy_ofdm_conf; + wl_erp_t wl_phy_erp_conf; + } wl_phy_conf; + char wl_supported_rates[MAX_SCAN_SUPPORT_RATES]; +} wl_ess_conf_t; + +typedef struct wl_ess_list { + uint32_t wl_ess_list_num; + wl_ess_conf_t wl_ess_list_ess[1]; +} wl_ess_list_t; + +typedef struct wl_wep_key { + uint32_t wl_wep_length; + char wl_wep_key[MAX_KEY_LENGTH]; + uint32_t wl_wep_operation; +} wl_wep_key_t; +typedef wl_wep_key_t wl_wep_key_tab_t[MAX_NWEPKEYS]; + +typedef struct wep_mapping { + uint32_t wl_wep_map_index; + boolean_t wl_wep_map_wepon; + char wl_wep_map_mac_addr[6]; + char wl_wep_map_reserved[2]; + wl_wep_key_t wl_wep_map_wepkey; +} wep_mapping_t; +typedef wep_mapping_t wep_mapping_tab_t[1]; + +typedef struct wl_priv_param { + char wl_priv_name[8]; + uint32_t wl_priv_type; + uint32_t wl_priv_size; + char wl_priv_value[1]; +} wl_priv_param_t; + +typedef struct wl_dev_depend { + uint32_t wl_dev_depend_num; + uint32_t wl_dev_depend_ret_idx; + wl_priv_param_t wl_dev_depend_priv[1]; +} wl_dev_depend_t; + +typedef struct wlan_ver { + uint32_t wl_ver_major; + uint32_t wl_ver_minor; +} wlan_ver_t; + +typedef struct wldp { + uint32_t wldp_length; + uint32_t wldp_type; + uint32_t wldp_result; + uint32_t wldp_id; + uint32_t wldp_buf[1]; +} wldp_t; + +#ifdef __cplusplus +} +#endif + +#endif /* __WIFI_IOCTL_H */ diff --git a/illumos-x86_64/usr/include/inttypes.h b/illumos-x86_64/usr/include/inttypes.h new file mode 100644 index 00000000..125fe4e4 --- /dev/null +++ b/illumos-x86_64/usr/include/inttypes.h @@ -0,0 +1,125 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INTTYPES_H +#define _INTTYPES_H + +/* + * This file, , is specified by the ISO C standard, + * standard, ISO/IEC 9899:1999 Programming language - C and is + * also defined by SUSv3. + * + * ISO International Organization for Standardization. + * SUSv3 Single Unix Specification, Version 3 + */ + +#include +#include + +#if (!defined(_XOPEN_SOURCE) || defined(_XPG6)) || defined(_STDC_C99) || \ + defined(__EXTENSIONS__) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Inclusion of breaks namespace, therefore define wchar_t */ + +/* + * wchar_t is a built-in type in standard C++ and as such is not + * defined here when using standard C++. However, the GNU compiler + * fixincludes utility nonetheless creates its own version of this + * header for use by gcc and g++. In that version it adds a redundant + * guard for __cplusplus. To avoid the creation of a gcc/g++ specific + * header we need to include the following magic comment: + * + * we must use the C++ compiler's type + * + * The above comment should not be removed or changed until GNU + * gcc/fixinc/inclhack.def is updated to bypass this header. + */ +#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__)) +#ifndef _WCHAR_T +#define _WCHAR_T +#if defined(_LP64) +typedef int wchar_t; +#else +typedef long wchar_t; +#endif +#endif /* !_WCHAR_T */ +#endif /* !__cplusplus || (__cplusplus < 199711L && !__GNUG__) */ + +#if (!defined(_XOPEN_SOURCE) || defined(_XPG6)) || defined(_STDC_C99) || \ + defined(__EXTENSIONS__) +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; +#endif /* (!defined(_XOPEN_SOURCE) || defined(_XPG6)) ... */ + +#if !defined(_LP64) && !defined(_LONGLONG_TYPE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname imaxabs _imaxabs_c89 +#pragma redefine_extname imaxdiv _imaxdiv_c89 +#pragma redefine_extname strtoimax _strtoimax_c89 +#pragma redefine_extname strtoumax _strtoumax_c89 +#pragma redefine_extname wcstoimax _wcstoimax_c89 +#pragma redefine_extname wcstoumax _wcstoumax_c89 +#else +#define imaxabs _imaxabs_c89 +#define imaxdiv _imaxdiv_c89 +#define strtoimax _strtoimax_c89 +#define strtoumax _strtoumax_c89 +#define wcstoimax _wcstoimax_c89 +#define wcstoumax _wcstoumax_c89 +#endif +#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */ + +#if (!defined(_XOPEN_SOURCE) || defined(_XPG6)) || defined(_STDC_C99) || \ + defined(__EXTENSIONS__) + +extern intmax_t imaxabs(intmax_t); +extern imaxdiv_t imaxdiv(intmax_t, intmax_t); +extern intmax_t strtoimax(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, + int); +extern uintmax_t strtoumax(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, + int); +extern intmax_t wcstoimax(const wchar_t *_RESTRICT_KYWD, + wchar_t **_RESTRICT_KYWD, int); +extern uintmax_t wcstoumax(const wchar_t *_RESTRICT_KYWD, + wchar_t **_RESTRICT_KYWD, int); + +#endif /* (!defined(_XOPEN_SOURCE) || defined(_XPG6)) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _INTTYPES_H */ diff --git a/illumos-x86_64/usr/include/ipmp.h b/illumos-x86_64/usr/include/ipmp.h new file mode 100644 index 00000000..2ca0a9b2 --- /dev/null +++ b/illumos-x86_64/usr/include/ipmp.h @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IPMP_H +#define _IPMP_H + +/* + * General IPMP-related definitions and functions. + * + * These interfaces may only be used within ON or after signing a contract + * with ON. For documentation, refer to PSARC/2002/615. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * IPMP library error codes. + */ +enum { + IPMP_SUCCESS, /* operation succeeded */ + IPMP_FAILURE, /* operation failed (check errno) */ + IPMP_EMINRED, /* minimum failover redundancy not met */ + IPMP_EFBDISABLED, /* failback disabled */ + IPMP_EUNKADDR, /* unknown IPMP data address */ + IPMP_EINVAL, /* invalid argument */ + IPMP_ENOMEM, /* out of memory */ + IPMP_ENOMPATHD, /* cannot contact in.mpathd */ + IPMP_EUNKGROUP, /* unknown IPMP group */ + IPMP_EUNKIF, /* interface is not using IPMP */ + IPMP_EPROTO, /* unable to communicate with in.mpathd */ + IPMP_EHWADDRDUP, /* interface has duplicate hardware address */ + IPMP_NERR /* number of error codes */ +}; + +typedef struct ipmp_state *ipmp_handle_t; + +extern int ipmp_open(ipmp_handle_t *); +extern void ipmp_close(ipmp_handle_t); +extern const char *ipmp_errmsg(int); + +#ifdef __cplusplus +} +#endif + +#endif /* _IPMP_H */ diff --git a/illumos-x86_64/usr/include/ipmp_admin.h b/illumos-x86_64/usr/include/ipmp_admin.h new file mode 100644 index 00000000..fa0986f7 --- /dev/null +++ b/illumos-x86_64/usr/include/ipmp_admin.h @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IPMP_ADMIN_H +#define _IPMP_ADMIN_H + +#include +#include + +/* + * IPMP administrative interfaces. + * + * These interfaces may only be used within ON or after signing a contract + * with ON. For documentation, refer to PSARC/2007/272. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int ipmp_offline(ipmp_handle_t, const char *, uint_t); +extern int ipmp_undo_offline(ipmp_handle_t, const char *); +extern int ipmp_ping_daemon(ipmp_handle_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _IPMP_ADMIN_H */ diff --git a/illumos-x86_64/usr/include/ipmp_mpathd.h b/illumos-x86_64/usr/include/ipmp_mpathd.h new file mode 100644 index 00000000..eec34c7f --- /dev/null +++ b/illumos-x86_64/usr/include/ipmp_mpathd.h @@ -0,0 +1,154 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2021 Tintri by DDN, Inc. All rights reserved. + */ + +#ifndef _IPMP_MPATHD_H +#define _IPMP_MPATHD_H + +/* + * Definitions for the messaging protocol between in.mpathd and libipmp. + * This interface is project-private to the IPMP subsystem. + */ + +#include +#include /* needed for */ +#include /* needed for LIFNAMSIZ */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MPATHD_PORT 5999 +#define MPATHD_PATH "/lib/inet/in.mpathd" + +/* + * Supported commands. + */ +enum { + MI_PING = 0, /* ping in.mpathd */ + MI_OFFLINE = 1, /* offline the interface */ + MI_UNDO_OFFLINE = 2, /* undo the offline */ + MI_QUERY = 3, /* query ipmp-related information */ + MI_NCMD /* total number of commands */ +}; + +/* + * Types of information which can be requested and received (except for + * IPMP_IFLIST and IPMP_ADDRLIST, which can only be received). + */ +typedef enum { + IPMP_GROUPLIST = 1, + IPMP_GROUPINFO = 2, + IPMP_GROUPCNT = 3, + IPMP_IFINFO = 4, + IPMP_IFLIST = 5, + IPMP_IFCNT = 6, + IPMP_ADDRLIST = 7, + IPMP_ADDRINFO = 8, + IPMP_ADDRCNT = 9, + IPMP_SNAP = 10 +} ipmp_infotype_t; + +/* + * Daemon ping request. + */ +typedef struct mi_ping { + uint32_t mip_command; +} mi_ping_t; + +/* + * Interface offline request; `mio_ifname' is the interface to offline; + * `mio_min_redundancy' is the minimum amount of usable interfaces after + * offline that must exist for the operation to succeed. + */ +typedef struct mi_offline { + uint32_t mio_command; + char mio_ifname[LIFNAMSIZ]; + uint32_t mio_min_redundancy; +} mi_offline_t; + +/* + * Interface undo-offline request; `miu_uname' is the interface to + * undo-offline. + */ +typedef struct mi_undo_offline { + uint32_t miu_command; + char miu_ifname[LIFNAMSIZ]; +} mi_undo_offline_t; + +/* + * Retrieve IPMP-related information: `miq_inforeq' is the type of information + * being request (see above for the list of types). If the request type is + * IPMP_GROUPINFO, then `miq_grname' indicates the group. If the request type + * is IPMP_IFINFO, then `miq_ifname' indicates the interface. If the request + * type is IPMP_ADDRINFO then `miq_grname' indicates the group and `miq_addr' + * indicates the address. + */ +typedef struct mi_query { + uint32_t miq_command; + ipmp_infotype_t miq_inforeq; + union { + char miqu_ifname[LIFNAMSIZ]; + char miqu_grname[LIFGRNAMSIZ]; + } miq_infodata; + struct sockaddr_storage miq_addr; +} mi_query_t; +#define miq_ifname miq_infodata.miqu_ifname +#define miq_grname miq_infodata.miqu_grname + +/* + * Union of all commands. Can be used to estimate the maximum buffer size + * requirement for receiving any command. + */ +union mi_commands { + uint32_t mi_command; + mi_ping_t mi_pcmd; + mi_offline_t mi_ocmd; + mi_undo_offline_t mi_ucmd; + mi_query_t mi_qcmd; +}; + +/* + * Result structure returned by in.mpathd. + */ +typedef struct mi_result { + uint32_t me_sys_error; /* System error (errno.h) */ + uint32_t me_mpathd_error; /* Mpathd error */ +} mi_result_t; + +#define IPMP_REQTIMEOUT 5 /* seconds */ + +extern int ipmp_connect(int *); +extern int ipmp_read(int, void *, size_t, const struct timeval *); +extern int ipmp_write(int, const void *, size_t); +extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *); +extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **, + const struct timeval *); + +#ifdef __cplusplus +} +#endif + +#endif /* _IPMP_MPATHD_H */ diff --git a/illumos-x86_64/usr/include/ipmp_query.h b/illumos-x86_64/usr/include/ipmp_query.h new file mode 100644 index 00000000..f2482163 --- /dev/null +++ b/illumos-x86_64/usr/include/ipmp_query.h @@ -0,0 +1,227 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2021 Tintri by DDN, Inc. All rights reserved. + */ + +#ifndef _IPMP_QUERY_H +#define _IPMP_QUERY_H + +#include +#include /* needed by */ +#include /* for LIF*NAMSIZ */ +#include + +/* + * IPMP query interfaces. + * + * These interfaces may only be used within ON or after signing a contract + * with ON. For documentation, refer to PSARC/2002/615 and PSARC/2007/272. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Assorted enumerations used in the data types described below. + */ +typedef enum ipmp_if_probestate { + IPMP_PROBE_OK, /* probes detect no problems */ + IPMP_PROBE_FAILED, /* probes detect failure */ + IPMP_PROBE_UNKNOWN, /* probe detection unavailable */ + IPMP_PROBE_DISABLED /* probe detection disabled */ +} ipmp_if_probestate_t; + +typedef enum ipmp_if_linkstate { + IPMP_LINK_UP, /* link detects up */ + IPMP_LINK_DOWN, /* link detects down */ + IPMP_LINK_UNKNOWN /* link detection unavailable */ +} ipmp_if_linkstate_t; + +typedef enum ipmp_if_flags { + IPMP_IFFLAG_INACTIVE = 0x1, + IPMP_IFFLAG_HWADDRDUP = 0x2, + IPMP_IFFLAG_ACTIVE = 0x4, + IPMP_IFFLAG_DOWN = 0x8 +} ipmp_if_flags_t; + +typedef enum ipmp_addr_state { + IPMP_ADDR_UP, /* address is up */ + IPMP_ADDR_DOWN /* address is down */ +} ipmp_addr_state_t; + +typedef enum ipmp_if_targmode { + IPMP_TARG_DISABLED, /* use of targets is disabled */ + IPMP_TARG_ROUTES, /* route-learned targets */ + IPMP_TARG_MULTICAST /* multicast-learned targets */ +} ipmp_if_targmode_t; + +#define IPMP_LIST_SIZE(listtype, elsize, nel) \ + ((sizeof (ipmp_ ## listtype ## _t) - (elsize)) + ((nel) * (elsize))) + +/* + * Data type describing a list of IPMP groups. + */ +typedef struct ipmp_grouplist { + uint64_t gl_sig; + unsigned int gl_ngroup; + uint32_t gl_pad; + char gl_groups[1][LIFGRNAMSIZ]; +} ipmp_grouplist_t; + +#define IPMP_GROUPLIST_SIZE(ngr) \ + IPMP_LIST_SIZE(grouplist, LIFGRNAMSIZ, ngr) + +/* + * Data type describing a list of interfaces. + */ +typedef struct ipmp_iflist { + unsigned int il_nif; + char il_ifs[1][LIFNAMSIZ]; +} ipmp_iflist_t; + +#define IPMP_IFLIST_SIZE(nif) \ + IPMP_LIST_SIZE(iflist, LIFNAMSIZ, nif) + +/* + * Data type describing a list of addresses. + */ +typedef struct ipmp_addrlist { + unsigned int al_naddr; + uint32_t al_pad; + struct sockaddr_storage al_addrs[1]; +} ipmp_addrlist_t; + +#define IPMP_ADDRLIST_SIZE(naddr) \ + IPMP_LIST_SIZE(addrlist, sizeof (struct sockaddr_storage), naddr) + +/* + * Data type describing the state of an IPMP group, and a subset data type + * used for communication between libipmp and in.mpathd. + */ +typedef struct ipmp_groupinfo { + char gr_name[LIFGRNAMSIZ]; + uint64_t gr_sig; + ipmp_group_state_t gr_state; + ipmp_iflist_t *gr_iflistp; + ipmp_addrlist_t *gr_adlistp; + char gr_ifname[LIFNAMSIZ]; + char gr_m4ifname[LIFNAMSIZ]; + char gr_m6ifname[LIFNAMSIZ]; + char gr_bcifname[LIFNAMSIZ]; + unsigned int gr_fdt; +} ipmp_groupinfo_t; + +typedef struct ipmp_groupinfo_xfer { + char grx_name[LIFGRNAMSIZ]; + uint64_t grx_sig; + ipmp_group_state_t grx_state; + char grx_ifname[LIFNAMSIZ]; + char grx_m4ifname[LIFNAMSIZ]; + char grx_m6ifname[LIFNAMSIZ]; + char grx_bcifname[LIFNAMSIZ]; + unsigned int grx_fdt; +} ipmp_groupinfo_xfer_t; + +/* + * Data type describing IPMP target information for a particular interface, + * and a subset data type used for communication between libipmp and in.mpathd. + */ +typedef struct ipmp_targinfo { + char it_name[LIFNAMSIZ]; + struct sockaddr_storage it_testaddr; + ipmp_if_targmode_t it_targmode; + ipmp_addrlist_t *it_targlistp; +} ipmp_targinfo_t; + +typedef struct ipmp_targinfo_xfer { + char itx_name[LIFNAMSIZ]; + struct sockaddr_storage itx_testaddr; + ipmp_if_targmode_t itx_targmode; + uint32_t itx_pad; +} ipmp_targinfo_xfer_t; + + +/* + * Data type describing the IPMP-related state of an interface, and a subset + * data type used for communication between libipmp and in.mpathd. + */ +typedef struct ipmp_ifinfo { + char if_name[LIFNAMSIZ]; + char if_group[LIFGRNAMSIZ]; + ipmp_if_state_t if_state; + ipmp_if_type_t if_type; + ipmp_if_linkstate_t if_linkstate; + ipmp_if_probestate_t if_probestate; + ipmp_if_flags_t if_flags; + ipmp_targinfo_t if_targinfo4; + ipmp_targinfo_t if_targinfo6; +} ipmp_ifinfo_t; + +typedef struct ipmp_ifinfo_xfer { + char ifx_name[LIFNAMSIZ]; + char ifx_group[LIFGRNAMSIZ]; + ipmp_if_state_t ifx_state; + ipmp_if_type_t ifx_type; + ipmp_if_linkstate_t ifx_linkstate; + ipmp_if_probestate_t ifx_probestate; + ipmp_if_flags_t ifx_flags; + uint32_t ifx_pad; + ipmp_targinfo_xfer_t ifx_targinfo4; + ipmp_targinfo_xfer_t ifx_targinfo6; +} ipmp_ifinfo_xfer_t; + + +/* + * Data type describing an IPMP data address. + */ +typedef struct ipmp_addrinfo { + struct sockaddr_storage ad_addr; + ipmp_addr_state_t ad_state; + char ad_group[LIFGRNAMSIZ]; + char ad_binding[LIFNAMSIZ]; + uint32_t ad_pad; +} ipmp_addrinfo_t; + +typedef enum { + IPMP_QCONTEXT_LIVE, + IPMP_QCONTEXT_SNAP +} ipmp_qcontext_t; + +extern int ipmp_setqcontext(ipmp_handle_t, ipmp_qcontext_t); +extern int ipmp_getgrouplist(ipmp_handle_t, ipmp_grouplist_t **); +extern void ipmp_freegrouplist(ipmp_grouplist_t *); +extern int ipmp_getgroupinfo(ipmp_handle_t, const char *, ipmp_groupinfo_t **); +extern void ipmp_freegroupinfo(ipmp_groupinfo_t *); +extern int ipmp_getifinfo(ipmp_handle_t, const char *, ipmp_ifinfo_t **); +extern void ipmp_freeifinfo(ipmp_ifinfo_t *); +extern int ipmp_getaddrinfo(ipmp_handle_t, const char *, + struct sockaddr_storage *, ipmp_addrinfo_t **); +extern void ipmp_freeaddrinfo(ipmp_addrinfo_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _IPMP_QUERY_H */ diff --git a/illumos-x86_64/usr/include/ipp/ipgpc/ipgpc.h b/illumos-x86_64/usr/include/ipp/ipgpc/ipgpc.h new file mode 100644 index 00000000..51edc313 --- /dev/null +++ b/illumos-x86_64/usr/include/ipp/ipgpc/ipgpc.h @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IPP_IPGPC_IPGPC_H +#define _IPP_IPGPC_IPGPC_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Header file for IP Generic Packet Classifier (ipgpc) ipp kernel module */ + +/* names for single ipgpc action and module name */ +#define IPGPC_CLASSIFY "ipgpc.classify" +#define IPGPC_NAME "ipgpc" + +/* config names of name-value pairs and type */ +#define IPGPC_UID "ipgpc.user" /* int32_t */ +#define IPGPC_PROJID "ipgpc.projid" /* int32_t */ +#define IPGPC_IF_INDEX "ipgpc.if_index" /* uint32_t */ +#define IPGPC_DIR "ipgpc.direction" /* uint32_t */ +#define IPGPC_PROTO "ipgpc.protocol" /* byte */ +#define IPGPC_DSFIELD "ipgpc.dsfield" /* byte */ +#define IPGPC_DSFIELD_MASK "ipgpc.dsfield_mask" /* byte */ +#define IPGPC_SPORT "ipgpc.sport" /* uint16_t */ +#define IPGPC_SPORT_MASK "ipgpc.sport_mask" /* uint16_t */ +#define IPGPC_DPORT "ipgpc.dport" /* uint16_t */ +#define IPGPC_DPORT_MASK "ipgpc.dport_mask" /* uint16_t */ +#define IPGPC_SADDR "ipgpc.saddr" /* uint32_t[4] */ +#define IPGPC_SADDR_MASK "ipgpc.saddr_mask" /* uint32_t[4] */ +#define IPGPC_SADDR_HOSTNAME "ipgpc.saddr_hostname" /* string */ +#define IPGPC_DADDR "ipgpc.daddr" /* uint32_t[4] */ +#define IPGPC_DADDR_MASK "ipgpc.daddr_mask" /* uint32_t[4] */ +#define IPGPC_DADDR_HOSTNAME "ipgpc.daddr_hostname" /* string */ +#define IPGPC_PRECEDENCE "ipgpc.precedence" /* uint32_t */ +#define IPGPC_PRIORITY "ipgpc.priority" /* uint32_t */ +#define IPGPC_FILTER_TYPE "ipgpc.filter_type" /* byte */ +#define IPGPC_FILTER_INSTANCE "ipgpc.filter_instance" /* int32_t */ +#define IPGPC_FILTER_PRIVATE "ipgpc.filter_private" /* string */ + +/* Filter Types for IPGPC_FILTER_TYPE */ +#define IPGPC_GENERIC_FLTR 0 +#define IPGPC_V4_FLTR 1 +#define IPGPC_V6_FLTR 2 + +#ifdef __cplusplus +} +#endif + +#endif /* _IPP_IPGPC_IPGPC_H */ diff --git a/illumos-x86_64/usr/include/ipp/ipp.h b/illumos-x86_64/usr/include/ipp/ipp.h new file mode 100644 index 00000000..69a15f63 --- /dev/null +++ b/illumos-x86_64/usr/include/ipp/ipp.h @@ -0,0 +1,174 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IPP_IPP_H +#define _IPP_IPP_H + +/* + * IP Policy Framework (IPPF) + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +typedef struct ipp_mod ipp_mod_t; +typedef int32_t ipp_mod_id_t; + +#define IPP_MOD_RESERVED 0 /* Upper limit of reserved values */ +#define IPP_MOD_INVAL -1 + +typedef struct ipp_action ipp_action_t; +typedef int32_t ipp_action_id_t; + +#define IPP_ACTION_RESERVED 0 /* Upper limit of reserved values */ +#define IPP_ACTION_INVAL -1 +#define IPP_ACTION_CONT -2 +#define IPP_ACTION_DEFER -3 +#define IPP_ACTION_DROP -4 + +#endif /* _KERNEL */ + +#define IPP_ANAME_CONT "ipp.continue" +#define IPP_ANAME_DEFER "ipp.defer" +#define IPP_ANAME_DROP "ipp.drop" + +typedef enum ipp_flags { + IPP_DESTROY_REF = 0x00000001 +} ipp_flags_t; + +#ifdef _KERNEL + +typedef struct ipp_stat ipp_stat_t; + +/* + * NOTE: Semi-opaque alias for struct ipp_stat_impl in common/ipp/ipp_impl.h + */ +struct ipp_stat { + void *ipps_data; +}; + +#define IPP_STAT_TAG 0x80 + +#define IPP_STAT_INT32 (IPP_STAT_TAG | KSTAT_DATA_INT32) +#define IPP_STAT_UINT32 (IPP_STAT_TAG | KSTAT_DATA_UINT32) +#define IPP_STAT_INT64 (IPP_STAT_TAG | KSTAT_DATA_INT64) +#define IPP_STAT_UINT64 (IPP_STAT_TAG | KSTAT_DATA_UINT64) +#define IPP_STAT_STRING (IPP_STAT_TAG | KSTAT_DATA_CHAR) + +#define IPP_STAT_READ KSTAT_READ +#define IPP_STAT_WRITE KSTAT_WRITE + +typedef kstat_named_t ipp_named_t; + +typedef struct ipp_class ipp_class_t; +typedef struct ipp_log ipp_log_t; + +typedef struct ipp_packet ipp_packet_t; + +#define IPPO_REV_1 1 +#define IPPO_REV IPPO_REV_1 /* interface version */ + +typedef struct ipp_ops ipp_ops_t; + +struct ipp_ops { + int ippo_rev; + int (*ippo_action_create)(ipp_action_id_t, nvlist_t **, + ipp_flags_t); + int (*ippo_action_modify)(ipp_action_id_t, nvlist_t **, + ipp_flags_t); + int (*ippo_action_destroy)(ipp_action_id_t, ipp_flags_t); + int (*ippo_action_info)(ipp_action_id_t, int (*)(nvlist_t *, + void *), void *, ipp_flags_t); + int (*ippo_action_invoke)(ipp_action_id_t, ipp_packet_t *); +}; + +/* + * IPPF client interface + */ + +extern int ipp_list_mods(ipp_mod_id_t **, int *); + +extern ipp_mod_id_t ipp_mod_lookup(const char *); +extern int ipp_mod_name(ipp_mod_id_t, char **); +extern int ipp_mod_register(const char *, ipp_ops_t *); +extern int ipp_mod_unregister(ipp_mod_id_t); +extern int ipp_mod_list_actions(ipp_mod_id_t, ipp_action_id_t **, + int *); + +extern ipp_action_id_t ipp_action_lookup(const char *); +extern int ipp_action_name(ipp_action_id_t, char **); +extern int ipp_action_mod(ipp_action_id_t, ipp_mod_id_t *); +extern int ipp_action_create(ipp_mod_id_t, const char *, + nvlist_t **, ipp_flags_t, ipp_action_id_t *); +extern int ipp_action_modify(ipp_action_id_t, nvlist_t **, + ipp_flags_t); +extern int ipp_action_destroy(ipp_action_id_t, ipp_flags_t); +extern int ipp_action_info(ipp_action_id_t, int (*)(nvlist_t *, + void *), void *, ipp_flags_t); +extern void ipp_action_set_ptr(ipp_action_id_t, void *); +extern void *ipp_action_get_ptr(ipp_action_id_t); +extern int ipp_action_ref(ipp_action_id_t, ipp_action_id_t, + ipp_flags_t); +extern int ipp_action_unref(ipp_action_id_t, ipp_action_id_t, + ipp_flags_t); + +extern int ipp_packet_alloc(ipp_packet_t **, const char *, + ipp_action_id_t); +extern void ipp_packet_free(ipp_packet_t *); +extern int ipp_packet_add_class(ipp_packet_t *, const char *, + ipp_action_id_t); +extern int ipp_packet_process(ipp_packet_t **); +extern int ipp_packet_next(ipp_packet_t *, ipp_action_id_t); +extern void ipp_packet_set_data(ipp_packet_t *, mblk_t *); +extern mblk_t *ipp_packet_get_data(ipp_packet_t *); +extern void ipp_packet_set_private(ipp_packet_t *, void *, + void (*)(void *)); +extern void *ipp_packet_get_private(ipp_packet_t *); + +extern int ipp_stat_create(ipp_action_id_t, const char *, int, + int (*)(ipp_stat_t *, void *, int), void *, ipp_stat_t **); +extern void ipp_stat_install(ipp_stat_t *); +extern void ipp_stat_destroy(ipp_stat_t *); +extern int ipp_stat_named_init(ipp_stat_t *, const char *, + uchar_t, ipp_named_t *); +extern int ipp_stat_named_op(ipp_named_t *, void *, int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _IPP_IPP_H */ diff --git a/illumos-x86_64/usr/include/ipp/ipp_config.h b/illumos-x86_64/usr/include/ipp/ipp_config.h new file mode 100644 index 00000000..3eaa6036 --- /dev/null +++ b/illumos-x86_64/usr/include/ipp/ipp_config.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IPP_IPP_CONFIG_H +#define _IPP_IPP_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ipp action modules configuration type codes + */ + +#define IPP_CONFIG_TYPE "ipp.config_type" /* byte */ + +#define IPP_SET 0x00 + +/* + * Classifier configuration type codes. + */ +#define CLASSIFIER_ADD_FILTER 0x01 +#define CLASSIFIER_ADD_CLASS 0x02 +#define CLASSIFIER_REMOVE_FILTER 0x03 +#define CLASSIFIER_REMOVE_CLASS 0x04 +#define CLASSIFIER_MODIFY_FILTER 0x05 +#define CLASSIFIER_MODIFY_CLASS 0x06 + +/* classifier generic parameters */ +#define CLASSIFIER_FILTER_NAME "ipp.filter_name" +#define CLASSIFIER_CLASS_NAME "ipp.class_name" +#define CLASSIFIER_NEXT_ACTION "ipp.next_action_name" +#define CLASSIFIER_CLASS_STATS_ENABLE "ipp.class_stats" + +/* all actions generic parameters */ +#define IPP_ACTION_STATS_ENABLE "ipp.action_stats" +#define IPP_MODULE_VERSION "ipp.module_version" + +/* + * Record configuration object ownership + */ +#define IPP_CONFIG_ORIGINATOR "ipp.originator" + +#define IPP_CONFIG_PERMANENT 0x00000000 +#define IPP_CONFIG_IPQOSCONF 0x00000001 +#define IPP_CONFIG_FTPCL 0x00000002 + +#define IPP_CONFIG_NAME_PERMANENT "permanent" +#define IPP_CONFIG_NAME_IPQOSCONF "ipqosconf" +#define IPP_CONFIG_NAME_FTPCL "ftpcl" + +/* + * macros to extract the major and minor version from a module version + * integer encoding. + */ +#define IPP_MAJOR_MODULE_VER(ver) (ver / 10000) +#define IPP_MINOR_MODULE_VER(ver) (ver % 10000) + +#ifdef __cplusplus +} +#endif + +#endif /* _IPP_IPP_CONFIG_H */ diff --git a/illumos-x86_64/usr/include/ipp/ipp_impl.h b/illumos-x86_64/usr/include/ipp/ipp_impl.h new file mode 100644 index 00000000..4ea01949 --- /dev/null +++ b/illumos-x86_64/usr/include/ipp/ipp_impl.h @@ -0,0 +1,240 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IPP_IPP_IMPL_H +#define _IPP_IPP_IMPL_H + +/* + * IP Policy Framework (IPPF) implementation detail. + * + * WARNING: Everything in this file is private, belonging to the IPPF + * subsystem. The interfaces and declarations made here are subject + * to change. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#define IPP_ALIGN 64 + +#define IPP_NBUCKET 23 + +#define IPP_LOG2NACTION 16 +#define IPP_NACTION (1 << IPP_LOG2NACTION) + +#define IPP_LOG2NMOD 6 +#define IPP_NMOD (1 << IPP_LOG2NMOD) + +#define IPP_NCLASS 5 +#define IPP_NLOG IPP_NMOD + +typedef struct ipp_ref ipp_ref_t; + +struct ipp_ref { + ipp_ref_t *ippr_nextp; + uint_t ippr_count; + union { + ipp_mod_t *u_mod; + ipp_action_t *u_action; + void *u_ptr; + } ippr_u; +}; + +#define ippr_action ippr_u.u_action +#define ippr_mod ippr_u.u_mod +#define ippr_ptr ippr_u.u_ptr + +typedef enum { + IPP_MODSTATE_PROTO = 0x10, + IPP_MODSTATE_AVAILABLE +} ipp_modstate_t; + +struct ipp_mod { + ipp_mod_id_t ippm_id; + ipp_ops_t *ippm_ops; + ipp_ref_t *ippm_action; + ipp_modstate_t ippm_state; + krwlock_t ippm_lock[1]; + uint32_t ippm_hold_count; + boolean_t ippm_destruct_pending; + char ippm_name[MAXNAMELEN]; +}; + +typedef enum { + IPP_ASTATE_PROTO = 0x20, + IPP_ASTATE_CONFIG_PENDING, + IPP_ASTATE_AVAILABLE +} ipp_astate_t; + +typedef struct cfglock { + kmutex_t cl_mutex[1]; + kcondvar_t cl_cv[1]; + uint_t cl_writers; + boolean_t cl_reader; + kthread_id_t cl_owner; +} cfglock_t; + +#ifndef __lint + +#define CL_READ 0 +#define CL_WRITE 1 + +#define CONFIG_LOCK_INIT(_clp) \ + { \ + mutex_init((_clp)->cl_mutex, NULL, MUTEX_DEFAULT, \ + (void *)ipltospl(LOCK_LEVEL)); \ + cv_init((_clp)->cl_cv, NULL, CV_DEFAULT, NULL); \ + } + +#define CONFIG_LOCK_FINI(_clp) \ + { \ + mutex_destroy((_clp)->cl_mutex); \ + cv_destroy((_clp)->cl_cv); \ + } + +#define CONFIG_LOCK_ENTER(_clp, _rw) \ + { \ + mutex_enter((_clp)->cl_mutex); \ + if ((_rw) == CL_WRITE) { \ + while ((_clp)->cl_reader || \ + ((_clp)->cl_owner != NULL && \ + (_clp)->cl_owner != curthread)) \ + cv_wait((_clp)->cl_cv, \ + (_clp)->cl_mutex); \ + (_clp)->cl_owner = curthread; \ + (_clp)->cl_writers++; \ + } \ + else if ((_rw) == CL_READ) { \ + while ((_clp)->cl_reader || \ + (_clp)->cl_writers > 0) { \ + ASSERT((_clp)->cl_owner != curthread); \ + cv_wait((_clp)->cl_cv, \ + (_clp)->cl_mutex); \ + } \ + (_clp)->cl_owner = curthread; \ + (_clp)->cl_reader = B_TRUE; \ + } \ + mutex_exit((_clp)->cl_mutex); \ + } + +#define CONFIG_LOCK_EXIT(_clp) \ + { \ + mutex_enter((_clp)->cl_mutex); \ + if ((_clp)->cl_reader) { \ + (_clp)->cl_reader = B_FALSE; \ + (_clp)->cl_owner = NULL; \ + cv_broadcast((_clp)->cl_cv); \ + } else { \ + ASSERT((_clp)->cl_writers != 0); \ + (_clp)->cl_writers--; \ + if ((_clp)->cl_writers == 0) { \ + (_clp)->cl_owner = NULL; \ + cv_broadcast((_clp)->cl_cv); \ + } \ + } \ + mutex_exit((_clp)->cl_mutex); \ + } + +#else /* __lint */ + +#define CONFIG_LOCK_INIT(_clp) +#define CONFIG_LOCK_FINI(_clp) +#define CONFIG_LOCK_ENTER(_clp, _rw) +#define CONFIG_LOCK_EXIT(_clp) + +#endif /* __lint */ + +struct ipp_action { + ipp_action_id_t ippa_id; + ipp_mod_t *ippa_mod; + ipp_ref_t *ippa_ref; + ipp_ref_t *ippa_refby; + void *ippa_ptr; + uint32_t ippa_packets; + ipp_astate_t ippa_state; + krwlock_t ippa_lock[1]; + uint32_t ippa_hold_count; + boolean_t ippa_destruct_pending; + cfglock_t ippa_config_lock[1]; + boolean_t ippa_nameless; + char ippa_name[MAXNAMELEN]; + ipp_ref_t **ippa_condemned; +}; + +struct ipp_class { + ipp_action_id_t ippc_aid; + char ippc_name[MAXNAMELEN]; +}; + +struct ipp_log { + ipp_action_id_t ippl_aid; + timespec_t ippl_begin; + timespec_t ippl_end; + char ippl_name[MAXNAMELEN]; +}; + +typedef struct ipp_stat_impl ipp_stat_impl_t; + +struct ipp_stat_impl { + void *ippsi_data; + kstat_t *ippsi_ksp; + int ippsi_limit; + int ippsi_count; + int (*ippsi_update)(ipp_stat_t *, void *, int); + void *ippsi_arg; + kmutex_t ippsi_lock[1]; + char ippsi_name[MAXNAMELEN]; +}; + +struct ipp_packet { + mblk_t *ippp_data; + ipp_class_t *ippp_class_array; + uint_t ippp_class_limit; + uint_t ippp_class_rindex; + uint_t ippp_class_windex; + ipp_log_t *ippp_log; + uint_t ippp_log_limit; + uint_t ippp_log_windex; + void *ippp_private; + void (*ippp_private_free)(void *); +}; + +extern void ipp_init(void); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _IPP_IPP_IMPL_H */ diff --git a/illumos-x86_64/usr/include/ipp/ippctl.h b/illumos-x86_64/usr/include/ipp/ippctl.h new file mode 100644 index 00000000..03401ea7 --- /dev/null +++ b/illumos-x86_64/usr/include/ipp/ippctl.h @@ -0,0 +1,95 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IPP_IPPCTL_H +#define _IPP_IPPCTL_H + +/* + * Header file for the IPP Policy Framework Configuration Driver + * + * WARNING: Everything in this file is private, belonging to the IPP + * subsystem. The interfaces and declarations made here are subject + * to change. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * nvpair keys + */ + +#define IPPCTL_OP "ippctl.op" +#define IPPCTL_MODNAME "ippctl.modname" +#define IPPCTL_MODNAME_ARRAY "ippctl.modname_array" +#define IPPCTL_ANAME "ippctl.aname" +#define IPPCTL_ANAME_ARRAY "ippctl.aname_array" +#define IPPCTL_FLAGS "ippctl.flags" +#define IPPCTL_RC "ippctl.rc" + +/* + * ioctl values + */ + +#define IPPCTL_BASE ('I' << 24 | 'P' << 16 | 'P' << 8) + +#define IPPCTL_CMD (IPPCTL_BASE | 0x01) +#define IPPCTL_DATA (IPPCTL_BASE | 0x02) + +/* + * op values + */ + +#define IPPCTL_OP_ACTION_CREATE 0x00 +#define IPPCTL_OP_ACTION_MODIFY 0x01 +#define IPPCTL_OP_ACTION_DESTROY 0x02 +#define IPPCTL_OP_ACTION_INFO 0x03 +#define IPPCTL_OP_ACTION_MOD 0x04 +#define IPPCTL_OP_LIST_MODS 0x05 +#define IPPCTL_OP_MOD_LIST_ACTIONS 0x06 + +/* + * ioctl structure + */ + +typedef struct ippctl_ioctl { + caddr_t ii_buf; + size_t ii_buflen; +} ippctl_ioctl_t; + +#ifdef _SYSCALL32 +typedef struct ippctl_ioctl32 { + caddr32_t ii32_buf; + size32_t ii32_buflen; +} ippctl_ioctl32_t; +#endif /* _SYSCALL32 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _IPP_IPPCTL_H */ diff --git a/illumos-x86_64/usr/include/iso/assert_iso.h b/illumos-x86_64/usr/include/iso/assert_iso.h new file mode 100644 index 00000000..d2b64153 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/assert_iso.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2016 Joyent, Inc. + * Copyright 2025 Oxide Computer Company + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ISO_ASSERT_ISO_H +#define _ISO_ASSERT_ISO_H + +/* + * This file contains all of the portions of the assert.h implementation that we + * wish to be re-entrant safe. This is not in as a number of + * third-party applications have tried to use their own wrappers that use a + * header guard, which lead to us losing the definitions that we need to have. + * While those applications are potentially using the implementation namespace + * incorrectly, separating out the two logical uses is helpful nonetheless and + * hopefully makes it clearer what is what. + * + * This header should not be included directly by applications! + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_STDC_C99) +extern _NORETURN_KYWD void __assert_c99(const char *, const char *, int, + const char *) __NORETURN; +#else +extern _NORETURN_KYWD void __assert(const char *, const char *, int) __NORETURN; +#endif /* _STDC_C99 */ + +/* + * In C11 the static_assert macro is always defined, unlike the assert macro. + * Starting in C23, static_assert is a keyword, so this is no longer required. + */ +#if defined(_STDC_C11) && !defined(__cplusplus) && !defined(_STDC_C23) +#define static_assert _Static_assert +#endif /* _STDC_C11 && !defined(__cplusplus) && !_STDC_C23 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_ASSERT_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/ctype_iso.h b/illumos-x86_64/usr/include/iso/ctype_iso.h new file mode 100644 index 00000000..475c1123 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/ctype_iso.h @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_CTYPE_ISO_H +#define _ISO_CTYPE_ISO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define _U 0x00000001 /* Upper case */ +#define _L 0x00000002 /* Lower case */ +#define _N 0x00000004 /* Numeral (digit) */ +#define _S 0x00000008 /* Spacing character */ +#define _P 0x00000010 /* Punctuation */ +#define _C 0x00000020 /* Control character */ +#define _B 0x00000040 /* Blank */ +#define _X 0x00000080 /* heXadecimal digit */ + +#define _ISUPPER _U +#define _ISLOWER _L +#define _ISDIGIT _N +#define _ISSPACE _S +#define _ISPUNCT _P +#define _ISCNTRL _C +#define _ISBLANK _B +#define _ISXDIGIT _X +#define _ISGRAPH 0x00002000 +#define _ISALPHA 0x00004000 +#define _ISPRINT 0x00008000 +#define _ISALNUM (_ISALPHA | _ISDIGIT) + +extern unsigned char __ctype[]; +extern unsigned int *__ctype_mask; +extern int *__trans_upper; +extern int *__trans_lower; + +#if __cplusplus >= 199711L +namespace std { +#endif + +/* + * These used to be macros, which while more efficient, precludes operation + * with thread specific locales. The old macros will still work, but new + * code compiles to use functions. This is specifically permitted by the + * various standards. Only _tolower and _toupper were required to be + * delivered in macro form. + */ +extern int isalnum(int); +extern int isalpha(int); +extern int iscntrl(int); +extern int isdigit(int); +extern int isgraph(int); +extern int islower(int); +extern int isprint(int); +extern int ispunct(int); +extern int isspace(int); +extern int isupper(int); +extern int isxdigit(int); +#if defined(_XPG6) || defined(_STDC_C99) || !defined(_STRICT_SYMBOLS) +extern int isblank(int); +#endif + +extern int tolower(int); +extern int toupper(int); + +#if __cplusplus >= 199711L +} /* end of namespace std */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_CTYPE_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/errno_iso.h b/illumos-x86_64/usr/include/iso/errno_iso.h new file mode 120000 index 00000000..2fbdb73c --- /dev/null +++ b/illumos-x86_64/usr/include/iso/errno_iso.h @@ -0,0 +1 @@ +../errno.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/iso/float_iso.h b/illumos-x86_64/usr/include/iso/float_iso.h new file mode 120000 index 00000000..da020eaa --- /dev/null +++ b/illumos-x86_64/usr/include/iso/float_iso.h @@ -0,0 +1 @@ +../float.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/iso/iso646_iso.h b/illumos-x86_64/usr/include/iso/iso646_iso.h new file mode 120000 index 00000000..2a445707 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/iso646_iso.h @@ -0,0 +1 @@ +../iso646.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/iso/limits_iso.h b/illumos-x86_64/usr/include/iso/limits_iso.h new file mode 100644 index 00000000..47902e54 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/limits_iso.h @@ -0,0 +1,102 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_LIMITS_ISO_H +#define _ISO_LIMITS_ISO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Sizes of integral types + */ +#define CHAR_BIT 8 /* max # of bits in a "char" */ +#define SCHAR_MIN (-128) /* min value of a "signed char" */ +#define SCHAR_MAX 127 /* max value of a "signed char" */ +#define UCHAR_MAX 255 /* max value of an "unsigned char" */ + +#define MB_LEN_MAX 5 + +#if defined(_CHAR_IS_SIGNED) +#define CHAR_MIN SCHAR_MIN /* min value of a "char" */ +#define CHAR_MAX SCHAR_MAX /* max value of a "char" */ +#elif defined(_CHAR_IS_UNSIGNED) +#define CHAR_MIN 0 /* min value of a "char" */ +#define CHAR_MAX UCHAR_MAX /* max value of a "char" */ +#else +#error "chars are signed or unsigned" +#endif + +#define SHRT_MIN (-32768) /* min value of a "short int" */ +#define SHRT_MAX 32767 /* max value of a "short int" */ +#define USHRT_MAX 65535 /* max value of "unsigned short int" */ +#define INT_MIN (-2147483647-1) /* min value of an "int" */ +#define INT_MAX 2147483647 /* max value of an "int" */ +#define UINT_MAX 4294967295U /* max value of an "unsigned int" */ +#if defined(_LP64) +#define LONG_MIN (-9223372036854775807L-1L) + /* min value of a "long int" */ +#define LONG_MAX 9223372036854775807L + /* max value of a "long int" */ +#define ULONG_MAX 18446744073709551615UL + /* max value of "unsigned long int" */ +#else /* _ILP32 */ +#define LONG_MIN (-2147483647L-1L) + /* min value of a "long int" */ +#define LONG_MAX 2147483647L /* max value of a "long int" */ +#define ULONG_MAX 4294967295UL /* max value of "unsigned long int" */ +#endif +#if !defined(_STRICT_STDC) || defined(_STDC_C99) || defined(__EXTENSIONS__) +#define LLONG_MIN (-9223372036854775807LL-1LL) + /* min value of a long long */ +#define LLONG_MAX 9223372036854775807LL + /* max value of a long long */ +#define ULLONG_MAX 18446744073709551615ULL + /* max value of "unsigned long long */ +#endif /* !defined(_STRICT_STDC) || defined(_STDC_C99)... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_LIMITS_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/locale_iso.h b/illumos-x86_64/usr/include/iso/locale_iso.h new file mode 100644 index 00000000..a29488c1 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/locale_iso.h @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2014 PALO, Richard. + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_LOCALE_ISO_H +#define _ISO_LOCALE_ISO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +struct lconv { + char *decimal_point; + char *thousands_sep; + char *grouping; + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; + +/* + * New in IEEE Std 1003.1-2001 for alignment with the ISO/IEC 9899:1999 + * standard. Namespace and binary compatibility dictate that visibility + * of these new members be limited, but all instances of this structure created + * by libc include space for the new fields. The new fields are excluded in a + * strictly-conforming pre-C99 environment if _LCONV_C99 is not also defined. + */ +#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C99) || defined(_LCONV_C99) + char int_p_cs_precedes; + char int_p_sep_by_space; + char int_n_cs_precedes; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; +#endif +}; + +#define LC_CTYPE 0 +#define LC_NUMERIC 1 +#define LC_TIME 2 +#define LC_COLLATE 3 +#define LC_MONETARY 4 +#define LC_MESSAGES 5 +#define LC_ALL 6 + +extern char *setlocale(int, const char *); +extern struct lconv *localeconv(void); + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_LOCALE_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/math_c99.h b/illumos-x86_64/usr/include/iso/math_c99.h new file mode 100644 index 00000000..1a3cdd90 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/math_c99.h @@ -0,0 +1,527 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ISO_MATH_C99_H +#define _ISO_MATH_C99_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#undef FP_ZERO +#define FP_ZERO 0 +#undef FP_SUBNORMAL +#define FP_SUBNORMAL 1 +#undef FP_NORMAL +#define FP_NORMAL 2 +#undef FP_INFINITE +#define FP_INFINITE 3 +#undef FP_NAN +#define FP_NAN 4 + +#if defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || defined(__C99FEATURES__) +#if defined(__GNUC__) +#undef HUGE_VAL +#define HUGE_VAL (__builtin_huge_val()) +#undef HUGE_VALF +#define HUGE_VALF (__builtin_huge_valf()) +#undef HUGE_VALL +#define HUGE_VALL (__builtin_huge_vall()) +#undef INFINITY +#define INFINITY (__builtin_inff()) +#undef NAN +#define NAN (__builtin_nanf("")) + +/* + * C99 7.12.3 classification macros + */ +#undef isnan +#undef isinf +#if __GNUC__ >= 4 +#define fpclassify(x) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, \ + FP_SUBNORMAL, FP_ZERO, x) +#define isnan(x) __builtin_isnan(x) +#define isinf(x) __builtin_isinf(x) +#define isfinite(x) (__builtin_isfinite(x) != 0) +#define isnormal(x) (__builtin_isnormal(x) != 0) +#define signbit(x) (__builtin_signbit(x) != 0) +#else /* __GNUC__ >= 4 */ +#define isnan(x) __extension__( \ + { __typeof(x) __x_n = (x); \ + __builtin_isunordered(__x_n, __x_n); }) +#define isinf(x) __extension__( \ + { __typeof(x) __x_i = (x); \ + __x_i == (__typeof(__x_i)) INFINITY || \ + __x_i == (__typeof(__x_i)) (-INFINITY); }) +#undef isfinite +#define isfinite(x) __extension__( \ + { __typeof(x) __x_f = (x); \ + !isnan(__x_f) && !isinf(__x_f); }) +#undef isnormal +#define isnormal(x) __extension__( \ + { __typeof(x) __x_r = (x); isfinite(__x_r) && \ + (sizeof (__x_r) == sizeof (float) ? \ + __builtin_fabsf(__x_r) >= __FLT_MIN__ : \ + sizeof (__x_r) == sizeof (double) ? \ + __builtin_fabs(__x_r) >= __DBL_MIN__ : \ + __builtin_fabsl(__x_r) >= __LDBL_MIN__); }) +#undef fpclassify +#define fpclassify(x) __extension__( \ + { __typeof(x) __x_c = (x); \ + isnan(__x_c) ? FP_NAN : \ + isinf(__x_c) ? FP_INFINITE : \ + isnormal(__x_c) ? FP_NORMAL : \ + __x_c == (__typeof(__x_c)) 0 ? FP_ZERO : \ + FP_SUBNORMAL; }) +#undef signbit +#if defined(_BIG_ENDIAN) +#define signbit(x) __extension__( \ + { __typeof(x) __x_s = (x); \ + (int)(*(unsigned *)&__x_s >> 31); }) +#elif defined(_LITTLE_ENDIAN) +#define signbit(x) __extension__( \ + { __typeof(x) __x_s = (x); \ + (sizeof (__x_s) == sizeof (float) ? \ + (int)(*(unsigned *)&__x_s >> 31) : \ + sizeof (__x_s) == sizeof (double) ? \ + (int)(((unsigned *)&__x_s)[1] >> 31) : \ + (int)(((unsigned short *)&__x_s)[4] >> 15)); }) +#endif /* defined(_BIG_ENDIAN) */ +#endif /* __GNUC__ >= 4 */ + +/* + * C99 7.12.14 comparison macros + */ +#undef isgreater +#define isgreater(x, y) __builtin_isgreater(x, y) +#undef isgreaterequal +#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y) +#undef isless +#define isless(x, y) __builtin_isless(x, y) +#undef islessequal +#define islessequal(x, y) __builtin_islessequal(x, y) +#undef islessgreater +#define islessgreater(x, y) __builtin_islessgreater(x, y) +#undef isunordered +#define isunordered(x, y) __builtin_isunordered(x, y) +#else /* defined(__GNUC__) */ +#undef HUGE_VAL +#define HUGE_VAL __builtin_huge_val +#undef HUGE_VALF +#define HUGE_VALF __builtin_huge_valf +#undef HUGE_VALL +#define HUGE_VALL __builtin_huge_vall +#undef INFINITY +#define INFINITY __builtin_infinity +#undef NAN +#define NAN __builtin_nan + +/* + * C99 7.12.3 classification macros + */ +#undef fpclassify +#define fpclassify(x) __builtin_fpclassify(x) +#undef isfinite +#define isfinite(x) __builtin_isfinite(x) +#undef isinf +#define isinf(x) __builtin_isinf(x) +#undef isnan +#define isnan(x) __builtin_isnan(x) +#undef isnormal +#define isnormal(x) __builtin_isnormal(x) +#undef signbit +#define signbit(x) __builtin_signbit(x) + +/* + * C99 7.12.14 comparison macros + */ +#undef isgreater +#define isgreater(x, y) ((x) __builtin_isgreater(y)) +#undef isgreaterequal +#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y)) +#undef isless +#define isless(x, y) ((x) __builtin_isless(y)) +#undef islessequal +#define islessequal(x, y) ((x) __builtin_islessequal(y)) +#undef islessgreater +#define islessgreater(x, y) ((x) __builtin_islessgreater(y)) +#undef isunordered +#define isunordered(x, y) ((x) __builtin_isunordered(y)) +#endif /* defined(__GNUC__) */ +#endif /* defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || ... */ + +#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(__C99FEATURES__) +#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ - 0 == 0 +typedef float float_t; +typedef double double_t; +#elif __FLT_EVAL_METHOD__ - 0 == 1 +typedef double float_t; +typedef double double_t; +#elif __FLT_EVAL_METHOD__ - 0 == 2 +typedef long double float_t; +typedef long double double_t; +#elif defined(__sparc) || defined(__amd64) +typedef float float_t; +typedef double double_t; +#elif defined(__i386) +typedef long double float_t; +typedef long double double_t; +#endif + +#undef FP_ILOGB0 +#define FP_ILOGB0 (-2147483647) +#undef FP_ILOGBNAN +#define FP_ILOGBNAN 2147483647 + +#undef MATH_ERRNO +#define MATH_ERRNO 1 +#undef MATH_ERREXCEPT +#define MATH_ERREXCEPT 2 +#undef math_errhandling +#define math_errhandling MATH_ERREXCEPT + +extern double acosh(double); +extern double asinh(double); +extern double atanh(double); + +extern double exp2(double); +extern double expm1(double); +extern int ilogb(double); +extern double log1p(double); +extern double log2(double); +extern double logb(double); +extern double scalbn(double, int); +extern double scalbln(double, long int); + +extern double cbrt(double); +extern double hypot(double, double); + +extern double erf(double); +extern double erfc(double); +extern double lgamma(double); +extern double tgamma(double); + +extern double nearbyint(double); +extern double rint(double); +extern long int lrint(double); +extern double round(double); +extern long int lround(double); +extern double trunc(double); + +extern double remainder(double, double); +extern double remquo(double, double, int *); + +extern double copysign(double, double); +extern double nan(const char *); +extern double nextafter(double, double); +extern double nexttoward(double, long double); + +extern double fdim(double, double); +extern double fmax(double, double); +extern double fmin(double, double); + +extern double fma(double, double, double); + +extern float acosf(float); +extern float asinf(float); +extern float atanf(float); +extern float atan2f(float, float); +extern float cosf(float); +extern float sinf(float); +extern float tanf(float); + +extern float acoshf(float); +extern float asinhf(float); +extern float atanhf(float); +extern float coshf(float); +extern float sinhf(float); +extern float tanhf(float); + +extern float expf(float); +extern float exp2f(float); +extern float expm1f(float); +extern float frexpf(float, int *); +extern int ilogbf(float); +extern float ldexpf(float, int); +extern float logf(float); +extern float log10f(float); +extern float log1pf(float); +extern float log2f(float); +extern float logbf(float); +extern float modff(float, float *); +extern float scalbnf(float, int); +extern float scalblnf(float, long int); + +extern float cbrtf(float); +extern float fabsf(float); +extern float hypotf(float, float); +extern float powf(float, float); +extern float sqrtf(float); + +extern float erff(float); +extern float erfcf(float); +extern float lgammaf(float); +extern float tgammaf(float); + +extern float ceilf(float); +extern float floorf(float); +extern float nearbyintf(float); +extern float rintf(float); +extern long int lrintf(float); +extern float roundf(float); +extern long int lroundf(float); +extern float truncf(float); + +extern float fmodf(float, float); +extern float remainderf(float, float); +extern float remquof(float, float, int *); + +extern float copysignf(float, float); +extern float nanf(const char *); +extern float nextafterf(float, float); +extern float nexttowardf(float, long double); + +extern float fdimf(float, float); +extern float fmaxf(float, float); +extern float fminf(float, float); + +extern float fmaf(float, float, float); + +extern long double acosl(long double); +extern long double asinl(long double); +extern long double atanl(long double); +extern long double atan2l(long double, long double); +extern long double cosl(long double); +extern long double sinl(long double); +extern long double tanl(long double); + +extern long double acoshl(long double); +extern long double asinhl(long double); +extern long double atanhl(long double); +extern long double coshl(long double); +extern long double sinhl(long double); +extern long double tanhl(long double); + +extern long double expl(long double); +extern long double exp2l(long double); +extern long double expm1l(long double); +extern long double frexpl(long double, int *); +extern int ilogbl(long double); +extern long double ldexpl(long double, int); +extern long double logl(long double); +extern long double log10l(long double); +extern long double log1pl(long double); +extern long double log2l(long double); +extern long double logbl(long double); +extern long double modfl(long double, long double *); +extern long double scalbnl(long double, int); +extern long double scalblnl(long double, long int); + +extern long double cbrtl(long double); +extern long double fabsl(long double); +extern long double hypotl(long double, long double); +extern long double powl(long double, long double); +extern long double sqrtl(long double); + +extern long double erfl(long double); +extern long double erfcl(long double); +extern long double lgammal(long double); +extern long double tgammal(long double); + +extern long double ceill(long double); +extern long double floorl(long double); +extern long double nearbyintl(long double); +extern long double rintl(long double); +extern long int lrintl(long double); +extern long double roundl(long double); +extern long int lroundl(long double); +extern long double truncl(long double); + +extern long double fmodl(long double, long double); +extern long double remainderl(long double, long double); +extern long double remquol(long double, long double, int *); + +extern long double copysignl(long double, long double); +extern long double nanl(const char *); +extern long double nextafterl(long double, long double); +extern long double nexttowardl(long double, long double); + +extern long double fdiml(long double, long double); +extern long double fmaxl(long double, long double); +extern long double fminl(long double, long double); + +extern long double fmal(long double, long double, long double); + +#if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \ + defined(__C99FEATURES__) +extern long long int llrint(double); +extern long long int llround(double); + +extern long long int llrintf(float); +extern long long int llroundf(float); + +extern long long int llrintl(long double); +extern long long int llroundl(long double); +#endif + +#if !defined(__cplusplus) +#pragma does_not_read_global_data(asinh, exp2, expm1) +#pragma does_not_read_global_data(ilogb, log2) +#pragma does_not_read_global_data(scalbn, scalbln, cbrt) +#pragma does_not_read_global_data(erf, erfc, tgamma) +#pragma does_not_read_global_data(nearbyint, rint, lrint, round, lround, trunc) +#pragma does_not_read_global_data(remquo) +#pragma does_not_read_global_data(copysign, nan, nexttoward) +#pragma does_not_read_global_data(fdim, fmax, fmin, fma) +#pragma does_not_write_global_data(asinh, exp2, expm1) +#pragma does_not_write_global_data(ilogb, log2) +#pragma does_not_write_global_data(scalbn, scalbln, cbrt) +#pragma does_not_write_global_data(erf, erfc, tgamma) +#pragma does_not_write_global_data(nearbyint, rint, lrint, round, lround, trunc) +#pragma does_not_write_global_data(copysign, nan, nexttoward) +#pragma does_not_write_global_data(fdim, fmax, fmin, fma) + +#pragma does_not_read_global_data(acosf, asinf, atanf, atan2f) +#pragma does_not_read_global_data(cosf, sinf, tanf) +#pragma does_not_read_global_data(acoshf, asinhf, atanhf, coshf, sinhf, tanhf) +#pragma does_not_read_global_data(expf, exp2f, expm1f, frexpf, ilogbf, ldexpf) +#pragma does_not_read_global_data(logf, log10f, log1pf, log2f, logbf) +#pragma does_not_read_global_data(modff, scalbnf, scalblnf) +#pragma does_not_read_global_data(cbrtf, fabsf, hypotf, powf, sqrtf) +#pragma does_not_read_global_data(erff, erfcf, lgammaf, tgammaf) +#pragma does_not_read_global_data(ceilf, floorf, nearbyintf) +#pragma does_not_read_global_data(rintf, lrintf, roundf, lroundf, truncf) +#pragma does_not_read_global_data(fmodf, remainderf, remquof) +#pragma does_not_read_global_data(copysignf, nanf, nextafterf, nexttowardf) +#pragma does_not_read_global_data(fdimf, fmaxf, fminf, fmaf) +#pragma does_not_write_global_data(acosf, asinf, atanf, atan2f) +#pragma does_not_write_global_data(cosf, sinf, tanf) +#pragma does_not_write_global_data(acoshf, asinhf, atanhf, coshf, sinhf, tanhf) +#pragma does_not_write_global_data(expf, exp2f, expm1f, ilogbf, ldexpf) +#pragma does_not_write_global_data(logf, log10f, log1pf, log2f, logbf) +#pragma does_not_write_global_data(cbrtf, fabsf, hypotf, powf, sqrtf) +#pragma does_not_write_global_data(erff, erfcf, tgammaf) +#pragma does_not_write_global_data(ceilf, floorf, nearbyintf) +#pragma does_not_write_global_data(rintf, lrintf, roundf, lroundf, truncf) +#pragma does_not_write_global_data(fmodf, remainderf) +#pragma does_not_write_global_data(copysignf, nanf, nextafterf, nexttowardf) +#pragma does_not_write_global_data(fdimf, fmaxf, fminf, fmaf) + +#pragma does_not_read_global_data(acosl, asinl, atanl, atan2l) +#pragma does_not_read_global_data(cosl, sinl, tanl) +#pragma does_not_read_global_data(acoshl, asinhl, atanhl, coshl, sinhl, tanhl) +#pragma does_not_read_global_data(expl, exp2l, expm1l, frexpl, ilogbl, ldexpl) +#pragma does_not_read_global_data(logl, log10l, log1pl, log2l, logbl) +#pragma does_not_read_global_data(modfl, scalbnl, scalblnl) +#pragma does_not_read_global_data(cbrtl, fabsl, hypotl, powl, sqrtl) +#pragma does_not_read_global_data(erfl, erfcl, lgammal, tgammal) +#pragma does_not_read_global_data(ceill, floorl, nearbyintl) +#pragma does_not_read_global_data(rintl, lrintl, roundl, lroundl, truncl) +#pragma does_not_read_global_data(fmodl, remainderl, remquol) +#pragma does_not_read_global_data(copysignl, nanl, nextafterl, nexttowardl) +#pragma does_not_read_global_data(fdiml, fmaxl, fminl, fmal) +#pragma does_not_write_global_data(acosl, asinl, atanl, atan2l) +#pragma does_not_write_global_data(cosl, sinl, tanl) +#pragma does_not_write_global_data(acoshl, asinhl, atanhl, coshl, sinhl, tanhl) +#pragma does_not_write_global_data(expl, exp2l, expm1l, ilogbl, ldexpl) +#pragma does_not_write_global_data(logl, log10l, log1pl, log2l, logbl) +#pragma does_not_write_global_data(cbrtl, fabsl, hypotl, powl, sqrtl) +#pragma does_not_write_global_data(erfl, erfcl, tgammal) +#pragma does_not_write_global_data(ceill, floorl, nearbyintl) +#pragma does_not_write_global_data(rintl, lrintl, roundl, lroundl, truncl) +#pragma does_not_write_global_data(fmodl, remainderl) +#pragma does_not_write_global_data(copysignl, nanl, nextafterl, nexttowardl) +#pragma does_not_write_global_data(fdiml, fmaxl, fminl, fmal) + +#if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \ + defined(__C99FEATURES__) +#pragma does_not_read_global_data(llrint, llround) +#pragma does_not_read_global_data(llrintf, llroundf, llrintl, llroundl) +#pragma does_not_write_global_data(llrint, llround) +#pragma does_not_write_global_data(llrintf, llroundf, llrintl, llroundl) +#endif +#endif /* !defined(__cplusplus) */ + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(acosh, atanh, hypot, lgamma, log1p, logb) +#pragma does_not_read_global_data(nextafter, remainder) +#pragma does_not_write_global_data(acosh, atanh, hypot, log1p, logb) +#pragma does_not_write_global_data(nextafter, remainder) + +#pragma no_side_effect(acosh, asinh, atanh, exp2, expm1) +#pragma no_side_effect(ilogb, log1p, log2, logb) +#pragma no_side_effect(scalbn, scalbln, cbrt, hypot) +#pragma no_side_effect(erf, erfc, tgamma) +#pragma no_side_effect(nearbyint, rint, lrint, round, lround, trunc) +#pragma no_side_effect(remainder) +#pragma no_side_effect(copysign, nan, nextafter, nexttoward) +#pragma no_side_effect(fdim, fmax, fmin, fma) + +#pragma no_side_effect(acosf, asinf, atanf, atan2f) +#pragma no_side_effect(cosf, sinf, tanf, coshf, sinhf, tanhf) +#pragma no_side_effect(acoshf, asinhf, atanhf, coshf, sinhf, tanhf) +#pragma no_side_effect(expf, exp2f, expm1f, ilogbf, ldexpf) +#pragma no_side_effect(logf, log10f, log1pf, log2f, logbf) +#pragma no_side_effect(cbrtf, fabsf, hypotf, powf, sqrtf) +#pragma no_side_effect(erff, erfcf, tgammaf) +#pragma no_side_effect(ceilf, floorf, nearbyintf) +#pragma no_side_effect(rintf, lrintf, roundf, lroundf, truncf) +#pragma no_side_effect(fmodf, remainderf) +#pragma no_side_effect(copysignf, nanf, nextafterf, nexttowardf) +#pragma no_side_effect(fdimf, fmaxf, fminf, fmaf) + +#pragma no_side_effect(acosl, asinl, atanl, atan2l) +#pragma no_side_effect(cosl, sinl, tanl, coshl, sinhl, tanhl) +#pragma no_side_effect(acoshl, asinhl, atanhl, coshl, sinhl, tanhl) +#pragma no_side_effect(expl, exp2l, expm1l, ilogbl, ldexpl) +#pragma no_side_effect(logl, log10l, log1pl, log2l, logbl) +#pragma no_side_effect(cbrtl, fabsl, hypotl, powl, sqrtl) +#pragma no_side_effect(erfl, erfcl, tgammal) +#pragma no_side_effect(ceill, floorl, nearbyintl) +#pragma no_side_effect(rintl, lrintl, roundl, lroundl, truncl) +#pragma no_side_effect(fmodl, remainderl) +#pragma no_side_effect(copysignl, nanl, nextafterl, nexttowardl) +#pragma no_side_effect(fdiml, fmaxl, fminl, fmal) + +#if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \ + defined(__C99FEATURES__) +#pragma no_side_effect(llrint, llround, llrintf, llroundf, llrintl, llroundl) +#endif +#endif /* defined(__MATHERR_ERRNO_DONTCARE) */ +#endif /* defined(__EXTENSIONS__) || defined(_STDC_C99) || ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_MATH_C99_H */ diff --git a/illumos-x86_64/usr/include/iso/math_iso.h b/illumos-x86_64/usr/include/iso/math_iso.h new file mode 100644 index 00000000..f0186f24 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/math_iso.h @@ -0,0 +1,246 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ISO_MATH_ISO_H +#define _ISO_MATH_ISO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_STDC_C99) && _XOPEN_SOURCE - 0 < 600 && !defined(__C99FEATURES__) +typedef union _h_val { + unsigned long _i[sizeof (double) / sizeof (unsigned long)]; + double _d; +} _h_val; + +#ifdef __STDC__ +extern const _h_val __huge_val; +#else +extern _h_val __huge_val; +#endif +#undef HUGE_VAL +#define HUGE_VAL __huge_val._d +#endif /* !defined(_STDC_C99) && _XOPEN_SOURCE - 0 < 600 && ... */ + +#if __cplusplus >= 199711L +namespace std { +#endif + +extern double acos(double); +extern double asin(double); +extern double atan(double); +extern double atan2(double, double); +extern double cos(double); +extern double sin(double); +extern double tan(double); + +extern double cosh(double); +extern double sinh(double); +extern double tanh(double); + +extern double exp(double); +extern double frexp(double, int *); +extern double ldexp(double, int); +extern double log(double); +extern double log10(double); +extern double modf(double, double *); + +extern double pow(double, double); +extern double sqrt(double); + +extern double ceil(double); +extern double fabs(double); +extern double floor(double); +extern double fmod(double, double); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(acos, asin, atan, atan2) +#pragma does_not_read_global_data(cos, sin, tan, cosh, sinh, tanh) +#pragma does_not_read_global_data(exp, log, log10, pow, sqrt) +#pragma does_not_read_global_data(frexp, ldexp, modf) +#pragma does_not_read_global_data(ceil, fabs, floor, fmod) +#pragma does_not_write_global_data(acos, asin, atan, atan2) +#pragma does_not_write_global_data(cos, sin, tan, cosh, sinh, tanh) +#pragma does_not_write_global_data(exp, log, log10, pow, sqrt) +#pragma does_not_write_global_data(ldexp) +#pragma does_not_write_global_data(ceil, fabs, floor, fmod) +#pragma no_side_effect(acos, asin, atan, atan2) +#pragma no_side_effect(cos, sin, tan, cosh, sinh, tanh) +#pragma no_side_effect(exp, log, log10, pow, sqrt) +#pragma no_side_effect(ldexp) +#pragma no_side_effect(ceil, fabs, floor, fmod) +#endif + +#if __cplusplus >= 199711L +extern float __acosf(float); +extern float __asinf(float); +extern float __atanf(float); +extern float __atan2f(float, float); +extern float __ceilf(float); +extern float __cosf(float); +extern float __coshf(float); +extern float __expf(float); +extern float __fabsf(float); +extern float __floorf(float); +extern float __fmodf(float, float); +extern float __frexpf(float, int *); +extern float __ldexpf(float, int); +extern float __logf(float); +extern float __log10f(float); +extern float __modff(float, float *); +extern float __powf(float, float); +extern float __sinf(float); +extern float __sinhf(float); +extern float __sqrtf(float); +extern float __tanf(float); +extern float __tanhf(float); + +extern long double __acosl(long double); +extern long double __asinl(long double); +extern long double __atanl(long double); +extern long double __atan2l(long double, long double); +extern long double __ceill(long double); +extern long double __cosl(long double); +extern long double __coshl(long double); +extern long double __expl(long double); +extern long double __fabsl(long double); +extern long double __floorl(long double); +extern long double __fmodl(long double, long double); +extern long double __frexpl(long double, int *); +extern long double __ldexpl(long double, int); +extern long double __logl(long double); +extern long double __log10l(long double); +extern long double __modfl(long double, long double *); +extern long double __powl(long double, long double); +extern long double __sinl(long double); +extern long double __sinhl(long double); +extern long double __sqrtl(long double); +extern long double __tanl(long double); +extern long double __tanhl(long double); + +extern "C++" { +#undef __X +#undef __Y + inline double abs(double __X) { return fabs(__X); } + + inline double pow(double __X, int __Y) { + return (pow(__X, (double)(__Y))); + } + + inline float abs(float __X) { return __fabsf(__X); } + inline float acos(float __X) { return __acosf(__X); } + inline float asin(float __X) { return __asinf(__X); } + inline float atan(float __X) { return __atanf(__X); } + inline float atan2(float __X, float __Y) { return __atan2f(__X, __Y); } + inline float ceil(float __X) { return __ceilf(__X); } + inline float cos(float __X) { return __cosf(__X); } + inline float cosh(float __X) { return __coshf(__X); } + inline float exp(float __X) { return __expf(__X); } + inline float fabs(float __X) { return __fabsf(__X); } + inline float floor(float __X) { return __floorf(__X); } + inline float fmod(float __X, float __Y) { return __fmodf(__X, __Y); } + inline float frexp(float __X, int *__Y) { return __frexpf(__X, __Y); } + inline float ldexp(float __X, int __Y) { return __ldexpf(__X, __Y); } + inline float log(float __X) { return __logf(__X); } + inline float log10(float __X) { return __log10f(__X); } + inline float modf(float __X, float *__Y) { return __modff(__X, __Y); } + inline float pow(float __X, float __Y) { return __powf(__X, __Y); } + + inline float pow(float __X, int __Y) { + return (pow((double)(__X), (double)(__Y))); + } + + inline float sin(float __X) { return __sinf(__X); } + inline float sinh(float __X) { return __sinhf(__X); } + inline float sqrt(float __X) { return __sqrtf(__X); } + inline float tan(float __X) { return __tanf(__X); } + inline float tanh(float __X) { return __tanhf(__X); } + + inline long double abs(long double __X) { return __fabsl(__X); } + inline long double acos(long double __X) { return __acosl(__X); } + inline long double asin(long double __X) { return __asinl(__X); } + inline long double atan(long double __X) { return __atanl(__X); } + + inline long double atan2(long double __X, long double __Y) { + return (__atan2l(__X, __Y)); + } + + inline long double ceil(long double __X) { return __ceill(__X); } + inline long double cos(long double __X) { return __cosl(__X); } + inline long double cosh(long double __X) { return __coshl(__X); } + inline long double exp(long double __X) { return __expl(__X); } + inline long double fabs(long double __X) { return __fabsl(__X); } + inline long double floor(long double __X) { return __floorl(__X); } + + inline long double fmod(long double __X, long double __Y) { + return (__fmodl(__X, __Y)); + } + + inline long double frexp(long double __X, int *__Y) { + return (__frexpl(__X, __Y)); + } + + inline long double ldexp(long double __X, int __Y) { + return (__ldexpl(__X, __Y)); + } + + inline long double log(long double __X) { return __logl(__X); } + inline long double log10(long double __X) { return __log10l(__X); } + + inline long double modf(long double __X, long double *__Y) { + return (__modfl(__X, __Y)); + } + + inline long double pow(long double __X, long double __Y) { + return (__powl(__X, __Y)); + } + + inline long double pow(long double __X, int __Y) { + return (__powl(__X, (long double) (__Y))); + } + + inline long double sin(long double __X) { return __sinl(__X); } + inline long double sinh(long double __X) { return __sinhl(__X); } + inline long double sqrt(long double __X) { return __sqrtl(__X); } + inline long double tan(long double __X) { return __tanl(__X); } + inline long double tanh(long double __X) { return __tanhl(__X); } +} /* end of extern "C++" */ +#endif /* __cplusplus >= 199711L */ + +#if __cplusplus >= 199711L +} /* end of namespace std */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_MATH_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/setjmp_iso.h b/illumos-x86_64/usr/include/iso/setjmp_iso.h new file mode 100644 index 00000000..3b8235be --- /dev/null +++ b/illumos-x86_64/usr/include/iso/setjmp_iso.h @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_SETJMP_ISO_H +#define _ISO_SETJMP_ISO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _JBLEN + +/* + * The sizes of the jump-buffer (_JBLEN) and the sigjump-buffer + * (_SIGJBLEN) are defined by the appropriate, processor specific, + * ABI. + */ +#if defined(__amd64) +#define _JBLEN 8 /* ABI value */ +#define _SIGJBLEN 128 /* ABI value */ +#elif defined(__i386) +#define _JBLEN 10 /* ABI value */ +#define _SIGJBLEN 128 /* ABI value */ +#elif defined(__sparcv9) +#define _JBLEN 12 /* ABI value */ +#define _SIGJBLEN 19 /* ABI value */ +#elif defined(__sparc) +#define _JBLEN 12 /* ABI value */ +#define _SIGJBLEN 19 /* ABI value */ +#else +#error "ISA not supported" +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +#if defined(__i386) || defined(__amd64) || \ + defined(__sparc) || defined(__sparcv9) +#if defined(_LP64) +typedef long jmp_buf[_JBLEN]; +#else +typedef int jmp_buf[_JBLEN]; +#endif +#else +#error "ISA not supported" +#endif + +extern int setjmp(jmp_buf) __RETURNS_TWICE; +#pragma unknown_control_flow(setjmp) +extern int _setjmp(jmp_buf) __RETURNS_TWICE; +#pragma unknown_control_flow(_setjmp) +extern void longjmp(jmp_buf, int) __NORETURN; +extern void _longjmp(jmp_buf, int) __NORETURN; + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#if __cplusplus >= 199711L +using std::setjmp; +#endif + +#if defined(_STRICT_STDC) || __cplusplus >= 199711L +#define setjmp(env) setjmp(env) +#endif + +#endif /* _JBLEN */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_SETJMP_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/signal_iso.h b/illumos-x86_64/usr/include/iso/signal_iso.h new file mode 100644 index 00000000..df640ad9 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/signal_iso.h @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1998-1999, by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_SIGNAL_ISO_H +#define _ISO_SIGNAL_ISO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +typedef int sig_atomic_t; + +#ifdef __cplusplus +extern "C" SIG_PF signal(int, SIG_PF); +#else +extern void (*signal(int, void (*)(int)))(int); +#endif +extern int raise(int); + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_SIGNAL_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/stdarg_c99.h b/illumos-x86_64/usr/include/iso/stdarg_c99.h new file mode 100644 index 00000000..3d21bb41 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/stdarg_c99.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ISO_STDARG_C99_H +#define _ISO_STDARG_C99_H + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * This header defines the va_copy variable argument macro, which is + * new in ISO C 1999, and thus not present in ISO C 1989 and ISO C++ + * 1998. Because this macro is a long-standing Solaris extension, it + * is also permitted in other contexts. + * + * The varargs definitions within this header are defined in terms of + * implementation definitions. These implementation definitions reside + * in . This organization enables protected use of + * the implementation by other standard headers without introducing + * names into the users' namespace. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * va_copy was initially a Solaris extension to provide a portable + * way to perform a variable argument list ``bookmarking'' function. + * It is now specified in the ISO/IEC 9899:1999 standard. + */ +#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG6) + +#define va_copy(to, from) __va_copy(to, from) + +#endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STDARG_C99_H */ diff --git a/illumos-x86_64/usr/include/iso/stdarg_iso.h b/illumos-x86_64/usr/include/iso/stdarg_iso.h new file mode 100644 index 00000000..ba82a918 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/stdarg_iso.h @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_STDARG_ISO_H +#define _ISO_STDARG_ISO_H + +/* + * This header defines the ISO C 1989 and ISO C++ 1998 variable + * argument definitions. + * + * The varargs definitions within this header are defined in terms of + * implementation definitions. These implementation definitions reside + * in . This organization enables protected use of + * the implementation by other standard headers without introducing + * names into the users' namespace. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +typedef __va_list va_list; +} +#elif !defined(_VA_LIST) +#define _VA_LIST +typedef __va_list va_list; +#endif + +#define va_start(list, name) __va_start(list, name) +#define va_arg(list, type) __va_arg(list, type) +#define va_end(list) __va_end(list) + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STDARG_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/stddef_iso.h b/illumos-x86_64/usr/include/iso/stddef_iso.h new file mode 100644 index 00000000..858dd5ea --- /dev/null +++ b/illumos-x86_64/usr/include/iso/stddef_iso.h @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2014 PALO, Richard. + * Copyright 2016 Joyent, Inc. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_STDDEF_ISO_H +#define _ISO_STDDEF_ISO_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +#if !defined(_PTRDIFF_T) || __cplusplus >= 199711L +#define _PTRDIFF_T +#if defined(_LP64) +typedef long ptrdiff_t; /* pointer difference */ +#else +typedef int ptrdiff_t; /* (historical version) */ +#endif +#endif /* !_PTRDIFF_T */ + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* !_SIZE_T */ + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#if !defined(_MAX_ALIGN_T) +#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11) +#define _MAX_ALIGN_T +typedef _MAX_ALIGNMENT_TYPE max_align_t; +#endif /* !_STRICT_SYMBOLS || _STDC_C11 */ +#endif /* _MAX_ALIGN_T */ + +#if __EXT1_VISIBLE +/* ISO/IEC 9899:2011 K.3.3.2 */ +#ifndef _RSIZE_T_DEFINED +#define _RSIZE_T_DEFINED +typedef size_t rsize_t; +#endif +#endif /* __EXT1_VISIBLE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STDDEF_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/stdio_c99.h b/illumos-x86_64/usr/include/iso/stdio_c99.h new file mode 100644 index 00000000..8004ff51 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/stdio_c99.h @@ -0,0 +1,93 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in + * the C99 standard and in conflict with the C++ implementation of the + * standard header. The C++ standard may adopt the C99 standard at + * which point it is expected that the symbols included here will + * become part of the C++ std namespace. + */ + +#ifndef _ISO_STDIO_C99_H +#define _ISO_STDIO_C99_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following have been added as a result of the ISO/IEC 9899:1999 + * standard. For a strictly conforming C application, visibility is + * contingent on the value of __STDC_VERSION__ (see sys/feature_tests.h). + * For non-strictly conforming C applications, there are no restrictions + * on the C namespace. + */ + +#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + +#if !defined(_LP64) && !defined(_LONGLONG_TYPE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname snprintf _snprintf_c89 +#pragma redefine_extname vsnprintf _vsnprintf_c89 +#pragma redefine_extname vfscanf _vfscanf_c89 +#pragma redefine_extname vscanf _vscanf_c89 +#pragma redefine_extname vsscanf _vsscanf_c89 +#else +#define snprintf _snprintf_c89 +#define vsnprintf _vsnprintf_c89 +#define vfscanf _vfscanf_c89 +#define vscanf _vscanf_c89 +#define vsscanf _vsscanf_c89 +#endif +#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */ + +extern int vfscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, __va_list); +extern int vscanf(const char *_RESTRICT_KYWD, __va_list); +extern int vsscanf(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + __va_list); +#endif /* defined(__EXTENSIONS__) ... */ +#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG5) +extern int snprintf(char *_RESTRICT_KYWD, size_t, const char *_RESTRICT_KYWD, + ...); +extern int vsnprintf(char *_RESTRICT_KYWD, size_t, const char *_RESTRICT_KYWD, + __va_list); + +#endif /* defined(__EXTENSIONS__) || defined(_STDC_C99) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STDIO_C99_H */ diff --git a/illumos-x86_64/usr/include/iso/stdio_iso.h b/illumos-x86_64/usr/include/iso/stdio_iso.h new file mode 100644 index 00000000..bfb287d3 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/stdio_iso.h @@ -0,0 +1,327 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2014 PALO, Richard. + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +/* + * User-visible pieces of the ANSI C standard I/O package. + */ + +#ifndef _ISO_STDIO_ISO_H +#define _ISO_STDIO_ISO_H + +#include +#include +#include +#include +#include + +/* + * If feature test macros are set that enable interfaces that use types + * defined in , get those types by doing the include. + * + * Note that in asking for the interfaces associated with this feature test + * macro one also asks for definitions of the POSIX types. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_LP64) && (_FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE)) +/* + * The following typedefs are adopted from ones in (with leading + * underscores added to avoid polluting the ANSI C name space). See the + * commentary there for further explanation. + */ +#if defined(_LONGLONG_TYPE) +typedef long long __longlong_t; +#else +/* used to reserve space and generate alignment */ +typedef union { + double _d; + int _l[2]; +} __longlong_t; +#endif +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE) */ + +#if __cplusplus >= 199711L +namespace std { +#endif + +#if !defined(_FILEDEFED) || __cplusplus >= 199711L +#define _FILEDEFED +typedef __FILE FILE; +#endif + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* !_SIZE_T */ + +#if defined(_LP64) || _FILE_OFFSET_BITS == 32 +typedef long fpos_t; +#else +typedef __longlong_t fpos_t; +#endif + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#define BUFSIZ 1024 + +/* + * The value of _NFILE is defined in the Processor Specific ABI. The value + * is chosen for historical reasons rather than for truly processor related + * attribute. Note that the SPARC Processor Specific ABI uses the common + * UNIX historical value of 20 so it is allowed to fall through. + */ +#if defined(__i386) +#define _NFILE 60 /* initial number of streams: Intel x86 ABI */ +#else +#define _NFILE 20 /* initial number of streams: SPARC ABI and default */ +#endif + +#define _SBFSIZ 8 /* compatibility with shared libs */ + +#define _IOFBF 0000 /* full buffered */ +#define _IOLBF 0100 /* line buffered */ +#define _IONBF 0004 /* not buffered */ +#define _IOEOF 0020 /* EOF reached on read */ +#define _IOERR 0040 /* I/O error from system */ + +#define _IOREAD 0001 /* currently reading */ +#define _IOWRT 0002 /* currently writing */ +#define _IORW 0200 /* opened for reading and writing */ +#define _IOMYBUF 0010 /* stdio malloc()'d buffer */ + +#ifndef EOF +#define EOF (-1) +#endif + +#define FOPEN_MAX _NFILE +#define FILENAME_MAX 1024 /* max # of characters in a path name */ + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#define TMP_MAX 17576 /* 26 * 26 * 26 */ + +#define L_tmpnam 25 /* (sizeof(P_tmpdir) + 15) */ + +extern __FILE __iob[_NFILE]; +#define stdin (&__iob[0]) +#define stdout (&__iob[1]) +#define stderr (&__iob[2]) + +#if __cplusplus >= 199711L +namespace std { +#endif + +#if !defined(_LP64) && !defined(_LONGLONG_TYPE) + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname fprintf _fprintf_c89 +#pragma redefine_extname printf _printf_c89 +#pragma redefine_extname sprintf _sprintf_c89 +#pragma redefine_extname vfprintf _vfprintf_c89 +#pragma redefine_extname vprintf _vprintf_c89 +#pragma redefine_extname vsprintf _vsprintf_c89 +#pragma redefine_extname fscanf _fscanf_c89 +#pragma redefine_extname scanf _scanf_c89 +#pragma redefine_extname sscanf _sscanf_c89 +#else +#define fprintf _fprintf_c89 +#define printf _printf_c89 +#define sprintf _sprintf_c89 +#define vfprintf _vfprintf_c89 +#define vprintf _vprintf_c89 +#define vsprintf _vsprintf_c89 +#define fscanf _fscanf_c89 +#define scanf _scanf_c89 +#define sscanf _sscanf_c89 +#endif + +#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */ + +extern int remove(const char *); +extern int rename(const char *, const char *); +extern FILE *tmpfile(void); +extern char *tmpnam(char *); +extern int fclose(FILE *); +extern int fflush(FILE *); +extern FILE *fopen(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); +extern FILE *freopen(const char *_RESTRICT_KYWD, + const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD); +extern void setbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD); +extern int setvbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD, int, + size_t); +/* PRINTFLIKE2 */ +extern int fprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); +/* SCANFLIKE2 */ +extern int fscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); +/* PRINTFLIKE1 */ +extern int printf(const char *_RESTRICT_KYWD, ...); +/* SCANFLIKE1 */ +extern int scanf(const char *_RESTRICT_KYWD, ...); +/* PRINTFLIKE2 */ +extern int sprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); +/* SCANFLIKE2 */ +extern int sscanf(const char *_RESTRICT_KYWD, + const char *_RESTRICT_KYWD, ...); +extern int vfprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + __va_list); +extern int vprintf(const char *_RESTRICT_KYWD, __va_list); +extern int vsprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + __va_list); +extern int fgetc(FILE *); +extern char *fgets(char *_RESTRICT_KYWD, int, FILE *_RESTRICT_KYWD); +extern int fputc(int, FILE *); +extern int fputs(const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD); +#if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \ + __cplusplus < 199711L +extern int getc(FILE *); +extern int putc(int, FILE *); +#endif +#if (__cplusplus >= 199711L && defined(_REENTRANT)) || \ + __cplusplus < 199711L +extern int getchar(void); +extern int putchar(int); +#endif + +/* + * ISO/IEC C11 removed gets from the standard library. Therefore if a strict C11 + * environment has been requested, we remove it. + */ +#if !defined(_STDC_C11) || defined(__EXTENSIONS__) +extern char *gets(char *); +#endif +extern int puts(const char *); +extern int ungetc(int, FILE *); +extern size_t fread(void *_RESTRICT_KYWD, size_t, size_t, + FILE *_RESTRICT_KYWD); +extern size_t fwrite(const void *_RESTRICT_KYWD, size_t, size_t, + FILE *_RESTRICT_KYWD); +#if !defined(__lint) || defined(_LP64) || _FILE_OFFSET_BITS == 32 +extern int fgetpos(FILE *_RESTRICT_KYWD, fpos_t *_RESTRICT_KYWD); +extern int fsetpos(FILE *, const fpos_t *); +#endif +extern int fseek(FILE *, long, int); +extern long ftell(FILE *); +extern void rewind(FILE *); +#if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \ + __cplusplus < 199711L +extern void clearerr(FILE *); +extern int feof(FILE *); +extern int ferror(FILE *); +#endif +extern void perror(const char *); + +#ifndef _LP64 +extern int __filbuf(FILE *); +extern int __flsbuf(int, FILE *); +#endif /* _LP64 */ + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#if !defined(__lint) + +#if !defined(_REENTRANT) && !defined(_LP64) + +#if __cplusplus >= 199711L +namespace std { +inline int getc(FILE *_p) { + return (--_p->_cnt < 0 ? __filbuf(_p) : (int)*_p->_ptr++); } +inline int putc(int _x, FILE *_p) { + return (--_p->_cnt < 0 ? __flsbuf(_x, _p) + : (int)(*_p->_ptr++ = (unsigned char) _x)); } +} +#else /* __cplusplus >= 199711L */ +#define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++) +#define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \ + : (int)(*(p)->_ptr++ = (unsigned char) (x))) +#endif /* __cplusplus >= 199711L */ + +#endif /* !defined(_REENTRANT) && !defined(_LP64) */ + +#ifndef _REENTRANT + +#if __cplusplus >= 199711L +namespace std { +inline int getchar() { return getc(stdin); } +inline int putchar(int _x) { return putc(_x, stdout); } +} +#else +#define getchar() getc(stdin) +#define putchar(x) putc((x), stdout) +#endif /* __cplusplus >= 199711L */ + +#ifndef _LP64 +#if __cplusplus >= 199711L +namespace std { +inline void clearerr(FILE *_p) { _p->_flag &= ~(_IOERR | _IOEOF); } +inline int feof(FILE *_p) { return _p->_flag & _IOEOF; } +inline int ferror(FILE *_p) { return _p->_flag & _IOERR; } +} +#else /* __cplusplus >= 199711L */ +#define clearerr(p) ((void)((p)->_flag &= ~(_IOERR | _IOEOF))) +#define feof(p) ((p)->_flag & _IOEOF) +#define ferror(p) ((p)->_flag & _IOERR) +#endif /* __cplusplus >= 199711L */ +#endif /* _LP64 */ + +#endif /* _REENTRANT */ + +#endif /* !defined(__lint) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STDIO_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/stdlib_c11.h b/illumos-x86_64/usr/include/iso/stdlib_c11.h new file mode 100644 index 00000000..fe3a1e98 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/stdlib_c11.h @@ -0,0 +1,102 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2016 Joyent, Inc. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other illumos headers. + * + * The contents of this header is limited to identifiers specified in + * the C11 standard and in conflict with the C++ implementation of the + * standard header. The C++ standard may adopt the C11 standard at + * which point it is expected that the symbols included here will + * become part of the C++ std namespace. + */ + +#ifndef _ISO_STDLIB_C11_H +#define _ISO_STDLIB_C11_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +/* + * The following have been added as a result of the ISO/IEC 9899:2011 + * standard. For a strictly conforming C application, visibility is + * contingent on the value of __STDC_VERSION__ (see sys/feature_tests.h). + * For non-strictly conforming C applications, there are no restrictions + * on the C namespace. + */ + +/* + * Work around fix-includes and other bad actors with using multiple headers. + */ +#if !defined(_NORETURN_KYWD) +#if __STDC_VERSION__ - 0 >= 201112L +#define _NORETURN_KYWD _Noreturn +#else +#define _NORETURN_KYWD +#endif /* __STDC_VERSION__ - 0 >= 201112L */ +#endif /* !defined(_NORETURN_KYWD) */ + +#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11) +extern void *aligned_alloc(size_t, size_t); +#endif /* !_STRICT_SYMBOLS || _STDC_C11 */ + +#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11) || __cplusplus >= 201103L +extern int at_quick_exit(void (*)(void)); +extern _NORETURN_KYWD void quick_exit(int); +#endif /* !_STRICT_SYMBOLS || _STDC_C11 || __cplusplus >= 201103L */ + +#if __cplusplus >= 199711L +} +#endif + +/* + * ISO C11 Annex K functions are not allowed to be in the standard + * namespace; however, it is implementation-defined as to whether or + * not they are in the global namespace and we opt to make them + * available to software. + */ +#if __EXT1_VISIBLE + +#ifndef _ERRNO_T_DEFINED +#define _ERRNO_T_DEFINED +typedef int errno_t; +#endif + +/* K.3.6 */ +typedef void (*constraint_handler_t)(const char *_RESTRICT_KYWD, + void *_RESTRICT_KYWD, errno_t); +/* K.3.6.1.1 */ +extern constraint_handler_t set_constraint_handler_s(constraint_handler_t); +/* K.3.6.1.2 */ +extern _NORETURN_KYWD void abort_handler_s(const char *_RESTRICT_KYWD, + void *_RESTRICT_KYWD, errno_t); +/* K3.6.1.3 */ +extern void ignore_handler_s(const char *_RESTRICT_KYWD, void *_RESTRICT_KYWD, + errno_t); +#endif /* __EXT1_VISIBLE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STDLIB_C11_H */ diff --git a/illumos-x86_64/usr/include/iso/stdlib_c99.h b/illumos-x86_64/usr/include/iso/stdlib_c99.h new file mode 100644 index 00000000..59f26002 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/stdlib_c99.h @@ -0,0 +1,95 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in + * the C99 standard and in conflict with the C++ implementation of the + * standard header. The C++ standard may adopt the C99 standard at + * which point it is expected that the symbols included here will + * become part of the C++ std namespace. + */ + +#ifndef _ISO_STDLIB_C99_H +#define _ISO_STDLIB_C99_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following have been added as a result of the ISO/IEC 9899:1999 + * standard. For a strictly conforming C application, visibility is + * contingent on the value of __STDC_VERSION__ (see sys/feature_tests.h). + * For non-strictly conforming C applications, there are no restrictions + * on the C namespace. + */ + +#if defined(_LONGLONG_TYPE) +typedef struct { + long long quot; + long long rem; +} lldiv_t; +#endif /* defined(_LONGLONG_TYPE) */ + +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_STDC_C99) || defined(__EXTENSIONS__) + +#if !defined(_NORETURN_KYWD) +#if __STDC_VERSION__ - 0 >= 201112L +#define _NORETURN_KYWD _Noreturn +#else +#define _NORETURN_KYWD +#endif /* __STDC_VERSION__ - 0 >= 201112L */ +#endif /* !defined(_NORETURN_KYWD) */ + +extern _NORETURN_KYWD void _Exit(int); +extern float strtof(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD); +extern long double strtold(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD); + +#if defined(_LONGLONG_TYPE) +extern long long atoll(const char *); +extern long long llabs(long long); +extern lldiv_t lldiv(long long, long long); +extern long long strtoll(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, + int); +extern unsigned long long strtoull(const char *_RESTRICT_KYWD, + char **_RESTRICT_KYWD, int); +#endif /* defined(_LONGLONG_TYPE) */ + +#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STDLIB_C99_H */ diff --git a/illumos-x86_64/usr/include/iso/stdlib_iso.h b/illumos-x86_64/usr/include/iso/stdlib_iso.h new file mode 100644 index 00000000..eecc19b7 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/stdlib_iso.h @@ -0,0 +1,180 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2014 PALO, Richard. + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_STDLIB_ISO_H +#define _ISO_STDLIB_ISO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned char __mb_cur_max(void); +#ifndef MB_CUR_MAX +#define MB_CUR_MAX (__mb_cur_max()) +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +typedef struct { + int quot; + int rem; +} div_t; + +typedef struct { + long quot; + long rem; +} ldiv_t; + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* !_SIZE_T */ + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 +#define RAND_MAX 32767 + +/* + * wchar_t is a built-in type in standard C++ and as such is not + * defined here when using standard C++. However, the GNU compiler + * fixincludes utility nonetheless creates its own version of this + * header for use by gcc and g++. In that version it adds a redundant + * guard for __cplusplus. To avoid the creation of a gcc/g++ specific + * header we need to include the following magic comment: + * + * we must use the C++ compiler's type + * + * The above comment should not be removed or changed until GNU + * gcc/fixinc/inclhack.def is updated to bypass this header. + */ +#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__)) +#ifndef _WCHAR_T +#define _WCHAR_T +#if defined(_LP64) +typedef int wchar_t; +#else +typedef long wchar_t; +#endif +#endif /* !_WCHAR_T */ +#endif /* !defined(__cplusplus) ... */ + +#if !defined(_NORETURN_KYWD) +#if __STDC_VERSION__ - 0 >= 201112L +#define _NORETURN_KYWD _Noreturn +#else +#define _NORETURN_KYWD +#endif /* __STDC_VERSION__ - 0 >= 201112L */ +#endif /* !defined(_NORETURN_KYWD) */ + +extern _NORETURN_KYWD void abort(void) __NORETURN; +extern int abs(int); +extern int atexit(void (*)(void)); +extern double atof(const char *); +extern int atoi(const char *); +extern long int atol(const char *); +extern void *bsearch(const void *, const void *, size_t, size_t, + int (*)(const void *, const void *)); +#if __cplusplus >= 199711L && defined(__SUNPRO_CC) +extern "C++" { + void *bsearch(const void *, const void *, size_t, size_t, + int (*)(const void *, const void *)); +} +#endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */ +extern void *calloc(size_t, size_t); +extern div_t div(int, int); +extern _NORETURN_KYWD void exit(int) + __NORETURN; +extern void free(void *); +extern char *getenv(const char *); +extern long int labs(long); +extern ldiv_t ldiv(long, long); +extern void *malloc(size_t); +extern int mblen(const char *, size_t); +extern size_t mbstowcs(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + size_t); +extern int mbtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t); +extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); +#if __cplusplus >= 199711L && defined(__SUNPRO_CC) +extern "C++" { + void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); +} +#endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */ +extern int rand(void); +extern void *realloc(void *, size_t); +extern void srand(unsigned int); +extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD); +extern long int strtol(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, int); +extern unsigned long int strtoul(const char *_RESTRICT_KYWD, + char **_RESTRICT_KYWD, int); +extern int system(const char *); +extern int wctomb(char *, wchar_t); +extern size_t wcstombs(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); + +#if __cplusplus >= 199711L +extern "C++" { + inline long abs(long _l) { return labs(_l); } + inline ldiv_t div(long _l1, long _l2) { return ldiv(_l1, _l2); } +} +#endif /* __cplusplus */ + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STDLIB_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/string_iso.h b/illumos-x86_64/usr/include/iso/string_iso.h new file mode 100644 index 00000000..e8cfc231 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/string_iso.h @@ -0,0 +1,180 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2014 PALO, Richard. + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_STRING_ISO_H +#define _ISO_STRING_ISO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* !_SIZE_T */ + +extern int memcmp(const void *, const void *, size_t); +extern void *memcpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, size_t); +extern void *memmove(void *, const void *, size_t); +extern void *memset(void *, int, size_t); +extern char *strcat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); +extern int strcmp(const char *, const char *); +extern char *strcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); +extern int strcoll(const char *, const char *); +extern size_t strcspn(const char *, const char *); +extern char *strerror(int); +extern size_t strlen(const char *); +extern char *strncat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t); +extern int strncmp(const char *, const char *, size_t); +extern char *strncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t); +extern size_t strspn(const char *, const char *); +extern char *strtok(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); +extern size_t strxfrm(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t); + +/* + * The C++ Standard (ISO/IEC 14882:1998) specifies that each of the + * function signatures for the following functions be replaced by + * two declarations, both of which have the same behavior. + */ +#if __cplusplus >= 199711L +extern const void *memchr(const void *, int, size_t); +#ifndef _MEMCHR_INLINE +#define _MEMCHR_INLINE +extern "C++" { + inline void *memchr(void * __s, int __c, size_t __n) { + return (void *)memchr((const void *)__s, __c, __n); + } +} +#endif /* _MEMCHR_INLINE */ +extern const char *strchr(const char *, int); +#ifndef _STRCHR_INLINE +#define _STRCHR_INLINE +extern "C++" { + inline char *strchr(char *__s, int __c) { + return (char *)strchr((const char *)__s, __c); + } +} +#endif /* _STRCHR_INLINE */ +extern const char *strpbrk(const char *, const char *); +#ifndef _STRPBRK_INLINE +#define _STRPBRK_INLINE +extern "C++" { + inline char *strpbrk(char *__s1, const char *__s2) { + return (char *)strpbrk((const char *)__s1, __s2); + } +} +#endif /* _STRPBRK_INLINE */ +extern const char *strrchr(const char *, int); +#ifndef _STRRCHR_INLINE +#define _STRRCHR_INLINE +extern "C++" { + inline char *strrchr(char *__s, int __c) { + return (char *)strrchr((const char *)__s, __c); + } +} +#endif /* _STRRCHR_INLINE */ +extern const char *strstr(const char *, const char *); +#ifndef _STRSTR_INLINE +#define _STRSTR_INLINE +extern "C++" { + inline char *strstr(char *__s1, const char *__s2) { + return (char *)strstr((const char *)__s1, __s2); + } +} +#endif /* _STRSTR_INLINE */ +#else /* __cplusplus >= 199711L */ +extern void *memchr(const void *, int, size_t); +extern char *strchr(const char *, int); +extern char *strpbrk(const char *, const char *); +extern char *strrchr(const char *, int); +extern char *strstr(const char *, const char *); +#endif /* __cplusplus >= 199711L */ + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +/* + * ISO C11 Annex K functions are not allowed to be in the standard + * namespace; however, it is implementation-defined as to whether or + * not they are in the global namespace and we opt to make them + * available to software. + */ +#if __EXT1_VISIBLE + +#ifndef _RSIZE_T_DEFINED +#define _RSIZE_T_DEFINED +#if __cplusplus >= 199711L +typedef std::size_t rsize_t; +#else +typedef size_t rsize_t; +#endif +#endif + +#ifndef _ERRNO_T_DEFINED +#define _ERRNO_T_DEFINED +typedef int errno_t; +#endif + +/* ISO/IEC 9899:2011 K.3.7.4.1.1 */ +extern errno_t memset_s(void *, rsize_t, int, rsize_t); +#endif /* __EXT1_VISIBLE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_STRING_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/time_iso.h b/illumos-x86_64/usr/include/iso/time_iso.h new file mode 100644 index 00000000..46bc632a --- /dev/null +++ b/illumos-x86_64/usr/include/iso/time_iso.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2014 PALO, Richard. + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_TIME_ISO_H +#define _ISO_TIME_ISO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned size_t; /* (historical version) */ +#endif +#endif /* !_SIZE_T */ + +#if !defined(_CLOCK_T) || __cplusplus >= 199711L +#define _CLOCK_T +typedef long clock_t; +#endif /* !_CLOCK_T */ + +#if !defined(_TIME_T) || __cplusplus >= 199711L +#define _TIME_T +typedef long time_t; +#endif /* !_TIME_T */ + +#define CLOCKS_PER_SEC 1000000L + +struct tm { /* see ctime(3) */ + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + + +extern char *asctime(const struct tm *); +extern clock_t clock(void); +extern char *ctime(const time_t *); +extern double difftime(time_t, time_t); +extern struct tm *gmtime(const time_t *); +extern struct tm *localtime(const time_t *); +extern time_t mktime(struct tm *); +extern time_t time(time_t *); +extern size_t strftime(char *_RESTRICT_KYWD, size_t, const char *_RESTRICT_KYWD, + const struct tm *_RESTRICT_KYWD); + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_TIME_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/wchar_c99.h b/illumos-x86_64/usr/include/iso/wchar_c99.h new file mode 100644 index 00000000..25db569d --- /dev/null +++ b/illumos-x86_64/usr/include/iso/wchar_c99.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in + * the C99 standard and in conflict with the C++ implementation of the + * standard header. The C++ standard may adopt the C99 standard at + * which point it is expected that the symbols included here will + * become part of the C++ std namespace. + */ + +#ifndef _ISO_WCHAR_C99_H +#define _ISO_WCHAR_C99_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Introduced in ISO/IEC 9899:1999 standard */ + +#if !defined(_LP64) && !defined(_LONGLONG_TYPE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname vfwscanf _vfwscanf_c89 +#pragma redefine_extname vswscanf _vswscanf_c89 +#pragma redefine_extname vwscanf _vwscanf_c89 +#else +#define vfwscanf _vfwscanf_c89 +#define vswscanf _vswscanf_c89 +#define vwscanf _vwscanf_c89 +#endif +#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */ + +#if defined(_STDC_C99) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG6) || defined(__EXTENSIONS__) +extern int vfwscanf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + __va_list); +extern int vswscanf(const wchar_t *_RESTRICT_KYWD, + const wchar_t *_RESTRICT_KYWD, __va_list); +extern int vwscanf(const wchar_t *_RESTRICT_KYWD, __va_list); +extern float wcstof(const wchar_t *_RESTRICT_KYWD, + wchar_t **_RESTRICT_KYWD); +#if defined(_LONGLONG_TYPE) +extern long double wcstold(const wchar_t *_RESTRICT_KYWD, + wchar_t **_RESTRICT_KYWD); +extern long long wcstoll(const wchar_t *_RESTRICT_KYWD, + wchar_t **_RESTRICT_KYWD, int); +extern unsigned long long wcstoull(const wchar_t *_RESTRICT_KYWD, + wchar_t **_RESTRICT_KYWD, int); +#endif /* defined(_LONGLONG_TYPE) */ + +#endif /* defined(_STDC_C99) || (!defined(_STRICT_STDC)... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_WCHAR_C99_H */ diff --git a/illumos-x86_64/usr/include/iso/wchar_iso.h b/illumos-x86_64/usr/include/iso/wchar_iso.h new file mode 100644 index 00000000..43cd872a --- /dev/null +++ b/illumos-x86_64/usr/include/iso/wchar_iso.h @@ -0,0 +1,349 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2014 PALO, Richard. + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_WCHAR_ISO_H +#define _ISO_WCHAR_ISO_H + +#include +#include +#include +#include +#include + +#if (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) || \ + (!defined(__cplusplus) && !defined(_STRICT_STDC)) || \ + defined(__EXTENSIONS__) +#include +#endif /* (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) ... */ + +#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) +#include +#include +#endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +/* + * wchar_t is a built-in type in standard C++ and as such is not + * defined here when using standard C++. However, the GNU compiler + * fixincludes utility nonetheless creates its own version of this + * header for use by gcc and g++. In that version it adds a redundant + * guard for __cplusplus. To avoid the creation of a gcc/g++ specific + * header we need to include the following magic comment: + * + * we must use the C++ compiler's type + * + * The above comment should not be removed or changed until GNU + * gcc/fixinc/inclhack.def is updated to bypass this header. + */ +#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__)) +#ifndef _WCHAR_T +#define _WCHAR_T +#if defined(_LP64) +typedef int wchar_t; +#else +typedef long wchar_t; +#endif +#endif /* !_WCHAR_T */ +#endif /* !defined(__cplusplus) ... */ + +#if !defined(_WINT_T) || __cplusplus >= 199711L +#define _WINT_T +#if defined(_LP64) +typedef int wint_t; +#else +typedef long wint_t; +#endif +#endif /* !defined(_WINT_T) || __cplusplus >= 199711L */ + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* !defined(_SIZE_T) || __cplusplus >= 199711L */ + +#ifndef WEOF +#if __cplusplus >= 199711L +#define WEOF ((std::wint_t)(-1)) +#else +#define WEOF ((wint_t)(-1)) +#endif +#endif /* WEOF */ + +/* not XPG4 and not XPG4v2 */ +#if !defined(_XPG4) || defined(_XPG5) +#ifndef WCHAR_MAX +#define WCHAR_MAX 2147483647 +#endif +#ifndef WCHAR_MIN +#define WCHAR_MIN (-2147483647-1) +#endif +#endif /* not XPG4 and not XPG4v2 */ + +#if !defined(_MBSTATE_T) || __cplusplus >= 199711L +#define _MBSTATE_T +typedef __mbstate_t mbstate_t; +#endif /* _MBSTATE_T */ + +#if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L +#define _FILEDEFED +typedef __FILE FILE; +#endif + +#if !defined(_LP64) && !defined(_LONGLONG_TYPE) + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname fwprintf _fwprintf_c89 +#pragma redefine_extname swprintf _swprintf_c89 +#pragma redefine_extname vfwprintf _vfwprintf_c89 +#pragma redefine_extname vswprintf _vswprintf_c89 +#pragma redefine_extname vwprintf _vwprintf_c89 +#pragma redefine_extname wprintf _wprintf_c89 +#pragma redefine_extname fwscanf _fwscanf_c89 +#pragma redefine_extname swscanf _swscanf_c89 +#pragma redefine_extname wscanf _wscanf_c89 +#else +#define fwprintf _fwprintf_c89 +#define swprintf _swprintf_c89 +#define vfwprintf _vfwprintf_c89 +#define vswprintf _vswprintf_c89 +#define vwprintf _vwprintf_c89 +#define wprintf _wprintf_c89 +#define fwscanf _fwscanf_c89 +#define swscanf _swscanf_c89 +#define wscanf _wscanf_c89 +#endif + +#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */ + +#if (!defined(_MSE_INT_H)) +/* not XPG4 and not XPG4v2 */ +#if !defined(_XPG4) || defined(_XPG5) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname fgetwc __fgetwc_xpg5 +#pragma redefine_extname getwc __getwc_xpg5 +#pragma redefine_extname getwchar __getwchar_xpg5 +#pragma redefine_extname fputwc __fputwc_xpg5 +#pragma redefine_extname putwc __putwc_xpg5 +#pragma redefine_extname putwchar __putwchar_xpg5 +#pragma redefine_extname fgetws __fgetws_xpg5 +#pragma redefine_extname fputws __fputws_xpg5 +#pragma redefine_extname ungetwc __ungetwc_xpg5 +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern wint_t __fgetwc_xpg5(__FILE *); +extern wint_t __getwc_xpg5(__FILE *); +extern wint_t __getwchar_xpg5(void); +extern wint_t __fputwc_xpg5(wint_t, __FILE *); +extern wint_t __putwc_xpg5(wint_t, __FILE *); +extern wint_t __putwchar_xpg5(wint_t); +extern wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD, int, + __FILE *_RESTRICT_KYWD); +extern int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD); +extern wint_t __ungetwc_xpg5(wint_t, __FILE *); +#define fgetwc __fgetwc_xpg5 +#define getwc __getwc_xpg5 +#define getwchar __getwchar_xpg5 +#define fputwc __fputwc_xpg5 +#define putwc __putwc_xpg5 +#define putwchar __putwchar_xpg5 +#define fgetws __fgetws_xpg5 +#define fputws __fputws_xpg5 +#define ungetwc __ungetwc_xpg5 +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* not XPG4 and not XPG4v2 */ +#endif /* defined(_MSE_INT_H) */ + +extern wint_t fgetwc(__FILE *); +extern wchar_t *fgetws(wchar_t *_RESTRICT_KYWD, int, __FILE *_RESTRICT_KYWD); +extern wint_t fputwc(wint_t, __FILE *); +extern int fputws(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD); +extern wint_t ungetwc(wint_t, __FILE *); +extern wint_t getwc(__FILE *); +extern wint_t getwchar(void); +extern wint_t putwc(wint_t, __FILE *); +extern wint_t putwchar(wint_t); +extern double wcstod(const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD); +extern long wcstol(const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD, + int); +extern unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD, + wchar_t **_RESTRICT_KYWD, int); +extern wchar_t *wcscat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD); +extern int wcscmp(const wchar_t *, const wchar_t *); +extern int wcscoll(const wchar_t *, const wchar_t *); +extern wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD); +extern size_t wcscspn(const wchar_t *, const wchar_t *); +extern size_t wcslen(const wchar_t *); +extern wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); +extern int wcsncmp(const wchar_t *, const wchar_t *, size_t); +extern wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); +extern size_t wcsspn(const wchar_t *, const wchar_t *); +extern size_t wcsxfrm(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); +#if __cplusplus >= 199711L +extern const wchar_t *wcschr(const wchar_t *, wchar_t); +extern "C++" { + inline wchar_t *wcschr(wchar_t *__ws, wchar_t __wc) { + return (wchar_t *)wcschr((const wchar_t *)__ws, __wc); + } +} +extern const wchar_t *wcspbrk(const wchar_t *, const wchar_t *); +extern "C++" { + inline wchar_t *wcspbrk(wchar_t *__ws1, const wchar_t *__ws2) { + return (wchar_t *)wcspbrk((const wchar_t *)__ws1, __ws2); + } +} +extern const wchar_t *wcsrchr(const wchar_t *, wchar_t); +extern "C++" { + inline wchar_t *wcsrchr(wchar_t *__ws, wchar_t __wc) { + return (wchar_t *)wcsrchr((const wchar_t *)__ws, __wc); + } +} +#else /* __cplusplus >= 199711L */ +extern wchar_t *wcschr(const wchar_t *, wchar_t); +extern wchar_t *wcspbrk(const wchar_t *, const wchar_t *); +extern wchar_t *wcsrchr(const wchar_t *, wchar_t); +#endif /* __cplusplus >= 199711L */ + +#if (!defined(_MSE_INT_H)) +#if defined(_XPG4) && !defined(_XPG5) /* XPG4 or XPG4v2 */ +extern wchar_t *wcstok(wchar_t *, const wchar_t *); +extern size_t wcsftime(wchar_t *, size_t, const char *, const struct tm *); +#else /* XPG4 or XPG4v2 */ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname wcstok __wcstok_xpg5 +#pragma redefine_extname wcsftime __wcsftime_xpg5 +extern wchar_t *wcstok(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + wchar_t **_RESTRICT_KYWD); +extern size_t wcsftime(wchar_t *_RESTRICT_KYWD, size_t, + const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD); +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD, + const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD); +extern size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD, size_t, + const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD); +#define wcstok __wcstok_xpg5 +#define wcsftime __wcsftime_xpg5 +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* XPG4 or XPG4v2 */ +#endif /* !defined(_MSE_INT_H) */ + +/* not XPG4 and not XPG4v2 */ +#if !defined(_XPG4) || defined(_XPG5) +extern wint_t btowc(int); +extern int fwprintf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + ...); +extern int fwscanf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + ...); +extern int fwide(__FILE *, int); +extern int mbsinit(const mbstate_t *); +extern size_t mbrlen(const char *_RESTRICT_KYWD, size_t, + mbstate_t *_RESTRICT_KYWD); +extern size_t mbrtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + size_t, mbstate_t *_RESTRICT_KYWD); +extern size_t mbsrtowcs(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD, + size_t, mbstate_t *_RESTRICT_KYWD); +extern int swprintf(wchar_t *_RESTRICT_KYWD, size_t, + const wchar_t *_RESTRICT_KYWD, ...); +extern int swscanf(const wchar_t *_RESTRICT_KYWD, + const wchar_t *_RESTRICT_KYWD, ...); +extern int vfwprintf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + __va_list); +extern int vwprintf(const wchar_t *_RESTRICT_KYWD, __va_list); +extern int vswprintf(wchar_t *_RESTRICT_KYWD, size_t, + const wchar_t *_RESTRICT_KYWD, __va_list); +extern size_t wcrtomb(char *_RESTRICT_KYWD, wchar_t, + mbstate_t *_RESTRICT_KYWD); +extern size_t wcsrtombs(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, + size_t, mbstate_t *_RESTRICT_KYWD); +#if defined(_XPG7) || !defined(_STRICT_SYMBOLS) +extern size_t wcsnrtombs(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, + size_t, size_t, mbstate_t *_RESTRICT_KYWD); +#endif +extern int wctob(wint_t); +extern int wmemcmp(const wchar_t *, const wchar_t *, size_t); +extern wchar_t *wmemcpy(wchar_t *_RESTRICT_KYWD, + const wchar_t *_RESTRICT_KYWD, size_t); +extern wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); +extern wchar_t *wmemset(wchar_t *, wchar_t, size_t); +extern int wprintf(const wchar_t *_RESTRICT_KYWD, ...); +extern int wscanf(const wchar_t *_RESTRICT_KYWD, ...); +#if __cplusplus >= 199711L +extern const wchar_t *wcsstr(const wchar_t *, const wchar_t *); +extern "C++" { + inline wchar_t *wcsstr(wchar_t *__ws1, const wchar_t *__ws2) { + return (wchar_t *)wcsstr((const wchar_t *)__ws1, __ws2); + } +} +extern const wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); +extern "C++" { + inline wchar_t *wmemchr(wchar_t *__ws, wchar_t __wc, size_t __n) { + return (wchar_t *)wmemchr((const wchar_t *)__ws, __wc, __n); + } +} +#else /* __cplusplus >= 199711L */ +extern wchar_t *wcsstr(const wchar_t *_RESTRICT_KYWD, + const wchar_t *_RESTRICT_KYWD); +extern wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); +#endif /* __cplusplus >= 199711L */ +#endif /* not XPG4 and not XPG4v2 */ + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_WCHAR_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso/wctype_iso.h b/illumos-x86_64/usr/include/iso/wctype_iso.h new file mode 100644 index 00000000..04ba7a94 --- /dev/null +++ b/illumos-x86_64/usr/include/iso/wctype_iso.h @@ -0,0 +1,146 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* wctype.h 1.13 89/11/02 SMI; JLE */ +/* from AT&T JAE 2.1 */ +/* definitions for international functions */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _ISO_WCTYPE_ISO_H +#define _ISO_WCTYPE_ISO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus >= 199711L +namespace std { +#endif + +#if !defined(_WINT_T) || __cplusplus >= 199711L +#define _WINT_T +#if defined(_LP64) +typedef int wint_t; +#else +typedef long wint_t; +#endif +#endif /* !defined(_WINT_T) || __cplusplus >= 199711L */ + +#if !defined(_WCTYPE_T) || __cplusplus >= 199711L +#define _WCTYPE_T +typedef int wctype_t; +#endif + +typedef unsigned int wctrans_t; + +/* not XPG4 and not XPG4v2 */ +#if !defined(_XPG4) || defined(_XPG5) +#ifndef WEOF +#if __cplusplus >= 199711L +#define WEOF ((std::wint_t)(-1)) +#else +#define WEOF ((wint_t)(-1)) +#endif +#endif /* WEOF */ +#endif /* not XPG4 and not XPG4v2 */ + +extern int iswalnum(wint_t); +extern int iswalpha(wint_t); +extern int iswcntrl(wint_t); +extern int iswdigit(wint_t); +extern int iswgraph(wint_t); +extern int iswlower(wint_t); +extern int iswprint(wint_t); +extern int iswpunct(wint_t); +extern int iswspace(wint_t); +extern int iswupper(wint_t); +extern int iswxdigit(wint_t); + +#if (__cplusplus >= 201103L) || defined(_STDC_C99) || defined(_XPG6) || \ + !defined(_STRICT_SYMBOLS) +extern int iswblank(wint_t); +#endif + +/* tow* also become functions */ +extern wint_t towlower(wint_t); +extern wint_t towupper(wint_t); +extern wctrans_t wctrans(const char *); +extern wint_t towctrans(wint_t, wctrans_t); +extern int iswctype(wint_t, wctype_t); +extern wctype_t wctype(const char *); + +/* bit definition for character class */ + +#define _E1 0x00000100 /* phonogram (international use) */ +#define _E2 0x00000200 /* ideogram (international use) */ +#define _E3 0x00000400 /* English (international use) */ +#define _E4 0x00000800 /* number (international use) */ +#define _E5 0x00001000 /* special (international use) */ +#define _E6 0x00002000 /* other characters (international use) */ +#define _E7 0x00004000 /* reserved (international use) */ +#define _E8 0x00008000 /* reserved (international use) */ + +#define _E9 0x00010000 +#define _E10 0x00020000 +#define _E11 0x00040000 +#define _E12 0x00080000 +#define _E13 0x00100000 +#define _E14 0x00200000 +#define _E15 0x00400000 +#define _E16 0x00800000 +#define _E17 0x01000000 +#define _E18 0x02000000 +#define _E19 0x04000000 +#define _E20 0x08000000 +#define _E21 0x10000000 +#define _E22 0x20000000 +#define _E23 0x40000000 +#define _E24 0x80000000 + +#if __cplusplus >= 199711L +} +#endif /* end of namespace std */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO_WCTYPE_ISO_H */ diff --git a/illumos-x86_64/usr/include/iso646.h b/illumos-x86_64/usr/include/iso646.h new file mode 100644 index 00000000..45be479f --- /dev/null +++ b/illumos-x86_64/usr/include/iso646.h @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ISO646_H +#define _ISO646_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Introduced in ISO/IEC 9899:1990/Ammendment 1:1995 (C Standard). + * In ISO/IEC 14882:1998 (C++ Standard), these tokens are keywords + * rather than macro names. + */ + +#if !defined(__cplusplus) || __cplusplus < 199711L +#define and && +#define and_eq &= +#define bitand & +#define bitor | +#define compl ~ +#define not ! +#define not_eq != +#define or || +#define or_eq |= +#define xor ^ +#define xor_eq ^= +#endif /* !defined(__cplusplus) || __cplusplus < 199711 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ISO646_H */ diff --git a/illumos-x86_64/usr/include/kerberosv5/com_err.h b/illumos-x86_64/usr/include/kerberosv5/com_err.h new file mode 100644 index 00000000..ebf61266 --- /dev/null +++ b/illumos-x86_64/usr/include/kerberosv5/com_err.h @@ -0,0 +1,81 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Header file for common error description library. + * + * Copyright 1988, Student Information Processing Board of the + * Massachusetts Institute of Technology. + * + * Copyright 1995 by Cygnus Support. + * + * For copyright and distribution info, see the documentation supplied + * with this package. + */ + +#ifndef __COM_ERR_H + +#if defined(_WIN32) +#include +#endif + +#ifndef KRB5_CALLCONV +#define KRB5_CALLCONV +#define KRB5_CALLCONV_C +#endif + +#include + +typedef long errcode_t; +typedef void (*et_old_error_hook_func) (const char *, errcode_t, + const char *, va_list ap); + +struct error_table { + /*@shared@*/ char const * const * msgs; + long base; + unsigned int n_msgs; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public interfaces */ +extern void KRB5_CALLCONV_C com_err + (const char *, errcode_t, const char *, ...); +extern void KRB5_CALLCONV com_err_va + (const char *whoami, errcode_t code, const char *fmt, + va_list ap); +extern /*@observer@*//*@dependent@*/ const char * KRB5_CALLCONV error_message + (errcode_t) + /*@modifies internalState@*/; + +/* + * Solaris Kerberos + * {add_,remove_}error_table have been removed here as they don't exist + * in the Solaris mech. + * + * initialize_krb5_error_table is not be needed anymore but Samba still + * calls it so we make it a no-op. + */ +#define initialize_krb5_error_table() + +#if !defined(_WIN32) +/* + * The display routine should be application specific. A global hook, + * may cause inappropriate display procedures to be called between + * applications under non-Unix environments. + */ + +extern et_old_error_hook_func set_com_err_hook (et_old_error_hook_func); +extern et_old_error_hook_func reset_com_err_hook (void); +#endif + +#ifdef __cplusplus +} +#endif + +#define __COM_ERR_H +#endif /* ! defined(__COM_ERR_H) */ diff --git a/illumos-x86_64/usr/include/kerberosv5/krb5.h b/illumos-x86_64/usr/include/kerberosv5/krb5.h new file mode 100644 index 00000000..835ace04 --- /dev/null +++ b/illumos-x86_64/usr/include/kerberosv5/krb5.h @@ -0,0 +1,3404 @@ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* This is the prologue to krb5.h */ +/* Unfortunately some of these defines are compiler dependent */ +#ifndef _KRB5_H +#define _KRB5_H + + +#define SIZEOF_INT 4 + +#ifdef _LP64 +#define SIZEOF_LONG 8 +#else +#define SIZEOF_LONG 4 +#endif + +#define SIZEOF_SHORT 2 +#define HAVE_STDARG_H 1 +#define HAVE_SYS_TYPES_H 1 +/* End of prologue section */ +/* + * include/krb5.h + * + * Copyright 1989,1990,1995,2001, 2003 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * + * General definitions for Kerberos version 5. + */ + +/* + * Copyright (C) 1998 by the FundsXpress, INC. + * + * All rights reserved. + * + * Export of this software from the United States of America may require + * a specific license from the United States Government. It is the + * responsibility of any person or organization contemplating export to + * obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of FundsXpress. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. FundsXpress makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef KRB5_GENERAL__ +#define KRB5_GENERAL__ + +#ifdef _KERNEL +#include +#include + +#include +#include + +/* + * Just to be safe lets make sure the buffers are zero'ed after + * malloc() as some code assumes this is the case. To avoid warnings + * of duplicated defines let remove the old one if present. + */ +#ifdef MALLOC +#undef MALLOC +#endif +#define MALLOC(n) kmem_zalloc((n), KM_SLEEP) + +#define FREE(x, n) kmem_free((x), (n)) +#define CALLOC(n, s) kmem_zalloc((n)*(s), KM_SLEEP) +#define strcpy(dst,src,n) bcopy((src),(dst),(n)) +#define mutex_lock(lck) mutex_enter(lck) +#define mutex_unlock(lck) mutex_exit(lck) + +#else /* !_KERNEL */ +#define MALLOC(n) malloc(n) +#define FREE(x, n) free(x) +#define CALLOC(n, s) calloc((n), (s)) +#include +#include +#include +#include +#include /* for *_MAX */ +#endif /* _KERNEL */ + +/* By default, do not expose deprecated interfaces. */ +/* SUNW14resync - we need to enable this for rlogind and such */ +#ifndef KRB5_DEPRECATED +#define KRB5_DEPRECATED 1 +#endif +/* Do not expose private interfaces. Build system will override. */ +/* SUNW14resync - for the Solaris build we set it to 1 here */ +#ifndef KRB5_PRIVATE +#define KRB5_PRIVATE 1 +#endif + +#if defined(__MACH__) && defined(__APPLE__) +# include +# if TARGET_RT_MAC_CFM +# error "Use KfM 4.0 SDK headers for CFM compilation." +# endif +#endif + +#if defined(_MSDOS) || defined(_WIN32) +#include +#endif + +#ifndef KRB5_CONFIG__ +#ifndef KRB5_CALLCONV +#define KRB5_CALLCONV +#define KRB5_CALLCONV_C +#endif /* !KRB5_CALLCONV */ +#endif /* !KRB5_CONFIG__ */ + +#ifndef KRB5_CALLCONV_WRONG +#define KRB5_CALLCONV_WRONG +#endif + +/* SUNW14resync XXX */ +#include +#include + +#ifndef THREEPARAMOPEN +#define THREEPARAMOPEN(x,y,z) open(x,y,z) +#endif + + +/* + * Solaris Kerberos: + * Samba needs a couple of these interfaces so old crypto is enabled. + */ +#define KRB5_OLD_CRYPTO + + +#ifndef KRB5INT_BEGIN_DECLS +#if defined(__cplusplus) +#define KRB5INT_BEGIN_DECLS extern "C" { +#define KRB5INT_END_DECLS } +#else +#define KRB5INT_BEGIN_DECLS +#define KRB5INT_END_DECLS +#endif +#endif + +KRB5INT_BEGIN_DECLS + +#if TARGET_OS_MAC +# pragma options align=mac68k +#endif + +/* from profile.h */ +struct _profile_t; +/* typedef struct _profile_t *profile_t; */ + +/* + * begin wordsize.h + */ + +/* + * Word-size related definition. + */ + +typedef unsigned char krb5_octet; + +#if INT_MAX == 0x7fff +typedef int krb5_int16; +typedef unsigned int krb5_ui_2; +#elif SHRT_MAX == 0x7fff +typedef short krb5_int16; +typedef unsigned short krb5_ui_2; +#else +#error undefined 16 bit type +#endif + +#if INT_MAX == 0x7fffffffL +typedef int krb5_int32; +typedef unsigned int krb5_ui_4; +#elif LONG_MAX == 0x7fffffffL +typedef long krb5_int32; +typedef unsigned long krb5_ui_4; +#elif SHRT_MAX == 0x7fffffffL +typedef short krb5_int32; +typedef unsigned short krb5_ui_4; +#else +#error: undefined 32 bit type +#endif + +#define VALID_INT_BITS INT_MAX +#define VALID_UINT_BITS UINT_MAX + +#define KRB5_INT32_MAX 2147483647 +/* this strange form is necessary since - is a unary operator, not a sign + indicator */ +#define KRB5_INT32_MIN (-KRB5_INT32_MAX-1) + +#define KRB5_INT16_MAX 65535 +/* this strange form is necessary since - is a unary operator, not a sign + indicator */ +#define KRB5_INT16_MIN (-KRB5_INT16_MAX-1) + +/* + * end wordsize.h + */ + +/* + * begin "base-defs.h" + */ + +/* + * Basic definitions for Kerberos V5 library + */ + +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + +typedef unsigned int krb5_boolean; +typedef unsigned int krb5_msgtype; +typedef unsigned int krb5_kvno; + +typedef krb5_int32 krb5_addrtype; +typedef krb5_int32 krb5_enctype; +typedef krb5_int32 krb5_cksumtype; +typedef krb5_int32 krb5_authdatatype; +typedef krb5_int32 krb5_keyusage; + +typedef krb5_int32 krb5_preauthtype; /* This may change, later on */ +typedef krb5_int32 krb5_flags; +typedef krb5_int32 krb5_timestamp; +typedef krb5_int32 krb5_error_code; +typedef krb5_int32 krb5_deltat; + +typedef krb5_error_code krb5_magic; + +typedef struct _krb5_data { + krb5_magic magic; + unsigned int length; + char *data; +} krb5_data; + +typedef struct _krb5_octet_data { + krb5_magic magic; + unsigned int length; + krb5_octet *data; +} krb5_octet_data; + +/* + * Hack length for crypto library to use the afs_string_to_key It is + * equivalent to -1 without possible sign extension + * We also overload for an unset salt type length - which is also -1, but + * hey, why not.... +*/ +#define SALT_TYPE_AFS_LENGTH UINT_MAX +#define SALT_TYPE_NO_LENGTH UINT_MAX + +typedef void * krb5_pointer; +typedef void const * krb5_const_pointer; + +typedef struct krb5_principal_data { + krb5_magic magic; + krb5_data realm; + krb5_data *data; /* An array of strings */ + krb5_int32 length; + krb5_int32 type; +} krb5_principal_data; + +typedef krb5_principal_data * krb5_principal; + +/* + * Per V5 spec on definition of principal types + */ + +/* Name type not known */ +#define KRB5_NT_UNKNOWN 0 +/* Just the name of the principal as in DCE, or for users */ +#define KRB5_NT_PRINCIPAL 1 +/* Service and other unique instance (krbtgt) */ +#define KRB5_NT_SRV_INST 2 +/* Service with host name as instance (telnet, rcommands) */ +#define KRB5_NT_SRV_HST 3 +/* Service with host as remaining components */ +#define KRB5_NT_SRV_XHST 4 +/* Unique ID */ +#define KRB5_NT_UID 5 +/* PKINIT */ +#define KRB5_NT_X500_PRINCIPAL 6 +/* Name in form of SMTP email name */ +#define KRB5_NT_SMTP_NAME 7 +/* Windows 2000 UPN */ +#define KRB5_NT_ENTERPRISE_PRINCIPAL 10 +/* Windows 2000 UPN and SID */ +#define KRB5_NT_MS_PRINCIPAL -128 +/* NT 4 style name */ +#define KRB5_NT_MS_PRINCIPAL_AND_ID -129 +/* NT 4 style name and SID */ +#define KRB5_NT_ENT_PRINCIPAL_AND_ID -130 + +/* constant version thereof: */ +typedef const krb5_principal_data *krb5_const_principal; + +#define krb5_princ_realm(context, princ) (&(princ)->realm) +#define krb5_princ_set_realm(context, princ,value) ((princ)->realm = *(value)) +#define krb5_princ_set_realm_length(context, princ,value) (princ)->realm.length = (value) +#define krb5_princ_set_realm_data(context, princ,value) (princ)->realm.data = (value) +#define krb5_princ_size(context, princ) (princ)->length +#define krb5_princ_type(context, princ) (princ)->type +#define krb5_princ_name(context, princ) (princ)->data +#define krb5_princ_component(context, princ,i) \ + (((i) < krb5_princ_size(context, princ)) \ + ? (princ)->data + (i) \ + : NULL) + +/* + * Constants for realm referrals. + */ +#define KRB5_REFERRAL_REALM "" + +/* + * Referral-specific functions. + */ +krb5_boolean KRB5_CALLCONV krb5_is_referral_realm(const krb5_data *); + +/* + * end "base-defs.h" + */ + +/* + * begin "hostaddr.h" + */ + +/* structure for address */ +typedef struct _krb5_address { + krb5_magic magic; + krb5_addrtype addrtype; + unsigned int length; + krb5_octet *contents; +} krb5_address; + +/* per Kerberos v5 protocol spec */ +#define ADDRTYPE_INET 0x0002 +#define ADDRTYPE_CHAOS 0x0005 +#define ADDRTYPE_XNS 0x0006 +#define ADDRTYPE_ISO 0x0007 +#define ADDRTYPE_DDP 0x0010 +#define ADDRTYPE_INET6 0x0018 +/* not yet in the spec... */ +#define ADDRTYPE_ADDRPORT 0x0100 +#define ADDRTYPE_IPPORT 0x0101 + +/* macros to determine if a type is a local type */ +#define ADDRTYPE_IS_LOCAL(addrtype) (addrtype & 0x8000) + +/* + * end "hostaddr.h" + */ + + +struct _krb5_context; +typedef struct _krb5_context * krb5_context; + +struct _krb5_auth_context; +typedef struct _krb5_auth_context * krb5_auth_context; + +struct _krb5_cryptosystem_entry; + +/* SUNW EF (I assume) crypto mods ... */ +struct _krb5_keyblock; + +/* + * keyblocks will contain a list of derived keys, + * this structure will contain the derived key data. + */ +typedef struct _dk_node { + krb5_keyusage usage; + struct _krb5_keyblock *derived_key; + uchar_t dkid; /* derived key identifier byte */ + struct _dk_node *next; +} krb5_dk_node; + +/* + * begin "encryption.h" + */ + +typedef struct _krb5_keyblock { + krb5_magic magic; + krb5_enctype enctype; + unsigned int length; + krb5_octet *contents; + krb5_dk_node *dk_list; /* list of keys derived from this key */ +#ifdef _KERNEL + crypto_mech_type_t kef_mt; + crypto_key_t kef_key; + crypto_ctx_template_t key_tmpl; +#else + CK_OBJECT_HANDLE hKey; /* PKCS#11 key object handle */ + pid_t pid; /* fork safety */ +#endif /* _KERNEL */ +} krb5_keyblock; + +typedef struct _krb5_checksum { + krb5_magic magic; + krb5_cksumtype checksum_type; /* checksum type */ + unsigned int length; + krb5_octet *contents; +} krb5_checksum; + +typedef struct _krb5_encrypt_block { + krb5_magic magic; + krb5_enctype crypto_entry; /* to call krb5_encrypt_size, you need + this. it was a pointer, but it + doesn't have to be. gross. */ + krb5_keyblock *key; +} krb5_encrypt_block; + +typedef struct _krb5_enc_data { + krb5_magic magic; + krb5_enctype enctype; + krb5_kvno kvno; + krb5_data ciphertext; +} krb5_enc_data; + +/* per Kerberos v5 protocol spec */ +#define ENCTYPE_NULL 0x0000 +#define ENCTYPE_DES_CBC_CRC 0x0001 /* DES cbc mode with CRC-32 */ +#define ENCTYPE_DES_CBC_MD4 0x0002 /* DES cbc mode with RSA-MD4 */ +#define ENCTYPE_DES_CBC_MD5 0x0003 /* DES cbc mode with RSA-MD5 */ +#define ENCTYPE_DES_CBC_RAW 0x0004 /* DES cbc mode raw */ +/* XXX deprecated? */ +#define ENCTYPE_DES3_CBC_SHA 0x0005 /* DES-3 cbc mode with NIST-SHA */ +#define ENCTYPE_DES3_CBC_RAW 0x0006 /* DES-3 cbc mode raw */ +#define ENCTYPE_DES_HMAC_SHA1 0x0008 +#define ENCTYPE_DES3_CBC_SHA1 0x0010 +#define ENCTYPE_AES128_CTS_HMAC_SHA1_96 0x0011 +#define ENCTYPE_AES256_CTS_HMAC_SHA1_96 0x0012 +#define ENCTYPE_ARCFOUR_HMAC 0x0017 +#define ENCTYPE_ARCFOUR_HMAC_EXP 0x0018 +#define ENCTYPE_UNKNOWN 0x01ff + +#define CKSUMTYPE_CRC32 0x0001 +#define CKSUMTYPE_RSA_MD4 0x0002 +#define CKSUMTYPE_RSA_MD4_DES 0x0003 +#define CKSUMTYPE_DESCBC 0x0004 +/* des-mac-k */ +/* rsa-md4-des-k */ +#define CKSUMTYPE_RSA_MD5 0x0007 +#define CKSUMTYPE_RSA_MD5_DES 0x0008 +#define CKSUMTYPE_NIST_SHA 0x0009 +#define CKSUMTYPE_HMAC_SHA1_DES3 0x000c +#define CKSUMTYPE_HMAC_SHA1_96_AES128 0x000f +#define CKSUMTYPE_HMAC_SHA1_96_AES256 0x0010 +#define CKSUMTYPE_HMAC_MD5_ARCFOUR -138 /*Microsoft md5 hmac cksumtype*/ + +/* The following are entropy source designations. Whenever + * krb5_C_random_add_entropy is called, one of these source ids is passed + * in. This allows the library to better estimate bits of + * entropy in the sample and to keep track of what sources of entropy have + * contributed enough entropy. Sources marked internal MUST NOT be + * used by applications outside the Kerberos library +*/ + +enum { + KRB5_C_RANDSOURCE_OLDAPI = 0, /*calls to krb5_C_RANDOM_SEED (INTERNAL)*/ + KRB5_C_RANDSOURCE_OSRAND = 1, /* /dev/random or equivalent (internal)*/ + KRB5_C_RANDSOURCE_TRUSTEDPARTY = 2, /* From KDC or other trusted party*/ + /*This source should be used carefully; data in this category + * should be from a third party trusted to give random bits + * For example keys issued by the KDC in the application server. + */ + KRB5_C_RANDSOURCE_TIMING = 3, /* Timing of operations*/ + KRB5_C_RANDSOURCE_EXTERNAL_PROTOCOL = 4, /*Protocol data possibly from attacker*/ + KRB5_C_RANDSOURCE_MAX = 5 /*Do not use; maximum source ID*/ +}; + +#ifndef krb5_roundup +/* round x up to nearest multiple of y */ +#define krb5_roundup(x, y) ((((x) + (y) - 1)/(y))*(y)) +#endif /* roundup */ + +/* macro function definitions to help clean up code */ + +#ifndef _KERNEL +#define krb5_x(ptr,args) ((ptr)?((*(ptr)) args):(abort(),1)) +#define krb5_xc(ptr,args) ((ptr)?((*(ptr)) args):(abort(),(char*)0)) +#else +#define krb5_x(ptr,args) ((*(ptr)) args) +#define krb5_xc(ptr,args) ((*(ptr)) args) +#endif + +krb5_error_code KRB5_CALLCONV + krb5_c_encrypt + (krb5_context context, const krb5_keyblock *key, + krb5_keyusage usage, const krb5_data *cipher_state, + const krb5_data *input, krb5_enc_data *output); + +krb5_error_code KRB5_CALLCONV + krb5_c_decrypt + (krb5_context context, const krb5_keyblock *key, + krb5_keyusage usage, const krb5_data *cipher_state, + const krb5_enc_data *input, krb5_data *output); + +krb5_error_code KRB5_CALLCONV + krb5_c_encrypt_length + (krb5_context context, krb5_enctype enctype, + size_t inputlen, size_t *length); + +krb5_error_code KRB5_CALLCONV + krb5_c_block_size + (krb5_context context, krb5_enctype enctype, + size_t *blocksize); + +krb5_error_code KRB5_CALLCONV + krb5_c_keylengths + (krb5_context context, krb5_enctype enctype, + size_t *keybytes, size_t *keylength); + +krb5_error_code KRB5_CALLCONV + krb5_c_init_state(krb5_context, + const krb5_keyblock *, krb5_keyusage, + krb5_data *); + +krb5_error_code KRB5_CALLCONV + krb5_c_free_state(krb5_context, + const krb5_keyblock *, krb5_data *); + +krb5_error_code KRB5_CALLCONV + krb5_c_make_random_key + (krb5_context context, krb5_enctype enctype, + krb5_keyblock *random_key); + +krb5_error_code KRB5_CALLCONV + krb5_c_random_to_key + (krb5_context context, krb5_enctype enctype, + krb5_data *random_data, krb5_keyblock *k5_random_key); + +/* Register a new entropy sample with the PRNG. may cause +* the PRNG to be reseeded, although this is not guaranteed. See previous randsource definitions +* for information on how each source should be used. +*/ +krb5_error_code KRB5_CALLCONV + krb5_c_random_add_entropy +(krb5_context context, unsigned int randsource_id, const krb5_data *data); + +krb5_error_code KRB5_CALLCONV + krb5_c_random_make_octets + (krb5_context context, krb5_data *data); + +/* +* Collect entropy from the OS if possible. strong requests that as strong +* of a source of entropy as available be used. Setting strong may +* increase the probability of blocking and should not be used for normal +* applications. Good uses include seeding the PRNG for kadmind +* and realm setup. +* If successful is non-null, then successful is set to 1 if the OS provided +* entropy else zero. +*/ +#if 0 /* SUNW14resync - not used in Solaris */ +krb5_error_code KRB5_CALLCONV +krb5_c_random_os_entropy +(krb5_context context, int strong, int *success); +#endif + +/*deprecated*/ krb5_error_code KRB5_CALLCONV + krb5_c_random_seed + (krb5_context context, krb5_data *data); + +krb5_error_code KRB5_CALLCONV + krb5_c_string_to_key + (krb5_context context, krb5_enctype enctype, + const krb5_data *string, const krb5_data *salt, + krb5_keyblock *key); +krb5_error_code KRB5_CALLCONV +krb5_c_string_to_key_with_params(krb5_context context, + krb5_enctype enctype, + const krb5_data *string, + const krb5_data *salt, + const krb5_data *params, + krb5_keyblock *key); + +krb5_error_code KRB5_CALLCONV + krb5_c_enctype_compare + (krb5_context context, krb5_enctype e1, krb5_enctype e2, + krb5_boolean *similar); + +krb5_error_code KRB5_CALLCONV + krb5_c_make_checksum + (krb5_context context, krb5_cksumtype cksumtype, + const krb5_keyblock *key, krb5_keyusage usage, + const krb5_data *input, krb5_checksum *cksum); + +krb5_error_code KRB5_CALLCONV + krb5_c_verify_checksum + (krb5_context context, + const krb5_keyblock *key, krb5_keyusage usage, + const krb5_data *data, + const krb5_checksum *cksum, + krb5_boolean *valid); + +krb5_error_code KRB5_CALLCONV + krb5_c_checksum_length + (krb5_context context, krb5_cksumtype cksumtype, + size_t *length); + +krb5_error_code KRB5_CALLCONV + krb5_c_keyed_checksum_types + (krb5_context context, krb5_enctype enctype, + unsigned int *count, krb5_cksumtype **cksumtypes); + +#define KRB5_KEYUSAGE_AS_REQ_PA_ENC_TS 1 +#define KRB5_KEYUSAGE_KDC_REP_TICKET 2 +#define KRB5_KEYUSAGE_AS_REP_ENCPART 3 +#define KRB5_KEYUSAGE_TGS_REQ_AD_SESSKEY 4 +#define KRB5_KEYUSAGE_TGS_REQ_AD_SUBKEY 5 +#define KRB5_KEYUSAGE_TGS_REQ_AUTH_CKSUM 6 +#define KRB5_KEYUSAGE_TGS_REQ_AUTH 7 +#define KRB5_KEYUSAGE_TGS_REP_ENCPART_SESSKEY 8 +#define KRB5_KEYUSAGE_TGS_REP_ENCPART_SUBKEY 9 +#define KRB5_KEYUSAGE_AP_REQ_AUTH_CKSUM 10 +#define KRB5_KEYUSAGE_AP_REQ_AUTH 11 +#define KRB5_KEYUSAGE_AP_REP_ENCPART 12 +#define KRB5_KEYUSAGE_KRB_PRIV_ENCPART 13 +#define KRB5_KEYUSAGE_KRB_CRED_ENCPART 14 +#define KRB5_KEYUSAGE_KRB_SAFE_CKSUM 15 +#define KRB5_KEYUSAGE_APP_DATA_ENCRYPT 16 +#define KRB5_KEYUSAGE_APP_DATA_CKSUM 17 +#define KRB5_KEYUSAGE_KRB_ERROR_CKSUM 18 +#define KRB5_KEYUSAGE_AD_KDCISSUED_CKSUM 19 +#define KRB5_KEYUSAGE_AD_MTE 20 +#define KRB5_KEYUSAGE_AD_ITE 21 + +/* XXX need to register these */ + +#define KRB5_KEYUSAGE_GSS_TOK_MIC 22 +#define KRB5_KEYUSAGE_GSS_TOK_WRAP_INTEG 23 +#define KRB5_KEYUSAGE_GSS_TOK_WRAP_PRIV 24 + +/* Defined in hardware preauth draft */ + +#define KRB5_KEYUSAGE_PA_SAM_CHALLENGE_CKSUM 25 +#define KRB5_KEYUSAGE_PA_SAM_CHALLENGE_TRACKID 26 +#define KRB5_KEYUSAGE_PA_SAM_RESPONSE 27 + +/* Defined in KDC referrals draft */ +#define KRB5_KEYUSAGE_PA_REFERRAL 26 /* XXX note conflict with above */ + +krb5_boolean KRB5_CALLCONV krb5_c_valid_enctype + (krb5_enctype ktype); +krb5_boolean KRB5_CALLCONV krb5_c_valid_cksumtype + (krb5_cksumtype ctype); +krb5_boolean KRB5_CALLCONV krb5_c_is_coll_proof_cksum + (krb5_cksumtype ctype); +krb5_boolean KRB5_CALLCONV krb5_c_is_keyed_cksum + (krb5_cksumtype ctype); + +#if KRB5_PRIVATE +/* Use the above four instead. */ +krb5_boolean KRB5_CALLCONV valid_enctype + (krb5_enctype ktype); +krb5_boolean KRB5_CALLCONV valid_cksumtype + (krb5_cksumtype ctype); +krb5_boolean KRB5_CALLCONV is_coll_proof_cksum + (krb5_cksumtype ctype); +krb5_boolean KRB5_CALLCONV is_keyed_cksum + (krb5_cksumtype ctype); +#endif + +#ifdef KRB5_OLD_CRYPTO +/* + * old cryptosystem routine prototypes. These are now layered + * on top of the functions above. + */ +krb5_error_code KRB5_CALLCONV krb5_encrypt + (krb5_context context, + krb5_const_pointer inptr, + krb5_pointer outptr, + size_t size, + krb5_encrypt_block * eblock, + krb5_pointer ivec); +krb5_error_code KRB5_CALLCONV krb5_decrypt + (krb5_context context, + krb5_const_pointer inptr, + krb5_pointer outptr, + size_t size, + krb5_encrypt_block * eblock, + krb5_pointer ivec); +krb5_error_code KRB5_CALLCONV krb5_process_key + (krb5_context context, + krb5_encrypt_block * eblock, + const krb5_keyblock * key); +krb5_error_code KRB5_CALLCONV krb5_finish_key + (krb5_context context, + krb5_encrypt_block * eblock); +krb5_error_code KRB5_CALLCONV krb5_string_to_key + (krb5_context context, + const krb5_encrypt_block * eblock, + krb5_keyblock * keyblock, + const krb5_data * data, + const krb5_data * salt); +krb5_error_code KRB5_CALLCONV krb5_init_random_key + (krb5_context context, + const krb5_encrypt_block * eblock, + const krb5_keyblock * keyblock, + krb5_pointer * ptr); +krb5_error_code KRB5_CALLCONV krb5_finish_random_key + (krb5_context context, + const krb5_encrypt_block * eblock, + krb5_pointer * ptr); +krb5_error_code KRB5_CALLCONV krb5_random_key + (krb5_context context, + const krb5_encrypt_block * eblock, + krb5_pointer ptr, + krb5_keyblock ** keyblock); +krb5_enctype KRB5_CALLCONV krb5_eblock_enctype + (krb5_context context, + const krb5_encrypt_block * eblock); +krb5_error_code KRB5_CALLCONV krb5_use_enctype + (krb5_context context, + krb5_encrypt_block * eblock, + krb5_enctype enctype); +size_t KRB5_CALLCONV krb5_encrypt_size + (size_t length, + krb5_enctype crypto); +size_t KRB5_CALLCONV krb5_checksum_size + (krb5_context context, + krb5_cksumtype ctype); +krb5_error_code KRB5_CALLCONV krb5_calculate_checksum + (krb5_context context, + krb5_cksumtype ctype, + krb5_const_pointer in, size_t in_length, + krb5_const_pointer seed, size_t seed_length, + krb5_checksum * outcksum); +krb5_error_code KRB5_CALLCONV krb5_verify_checksum + (krb5_context context, + krb5_cksumtype ctype, + const krb5_checksum * cksum, + krb5_const_pointer in, size_t in_length, + krb5_const_pointer seed, size_t seed_length); + +#if KRB5_PRIVATE +krb5_error_code KRB5_CALLCONV krb5_random_confounder + (size_t, krb5_pointer); + +krb5_error_code krb5_encrypt_data + (krb5_context context, krb5_keyblock *key, + krb5_pointer ivec, krb5_data *data, + krb5_enc_data *enc_data); + +krb5_error_code krb5_decrypt_data + (krb5_context context, krb5_keyblock *key, + krb5_pointer ivec, krb5_enc_data *data, + krb5_data *enc_data); +#endif + +#endif /* KRB5_OLD_CRYPTO */ + +/* + * end "encryption.h" + */ + +/* + * begin "fieldbits.h" + */ + +/* kdc_options for kdc_request */ +/* options is 32 bits; each host is responsible to put the 4 bytes + representing these bits into net order before transmission */ +/* #define KDC_OPT_RESERVED 0x80000000 */ +#define KDC_OPT_FORWARDABLE 0x40000000 +#define KDC_OPT_FORWARDED 0x20000000 +#define KDC_OPT_PROXIABLE 0x10000000 +#define KDC_OPT_PROXY 0x08000000 +#define KDC_OPT_ALLOW_POSTDATE 0x04000000 +#define KDC_OPT_POSTDATED 0x02000000 +/* #define KDC_OPT_UNUSED 0x01000000 */ +#define KDC_OPT_RENEWABLE 0x00800000 +/* #define KDC_OPT_UNUSED 0x00400000 */ +/* #define KDC_OPT_RESERVED 0x00200000 */ +/* #define KDC_OPT_RESERVED 0x00100000 */ +/* #define KDC_OPT_RESERVED 0x00080000 */ +/* #define KDC_OPT_RESERVED 0x00040000 */ +#define KDC_OPT_REQUEST_ANONYMOUS 0x00020000 +#define KDC_OPT_CANONICALIZE 0x00010000 +/* #define KDC_OPT_RESERVED 0x00008000 */ +/* #define KDC_OPT_RESERVED 0x00004000 */ +/* #define KDC_OPT_RESERVED 0x00002000 */ +/* #define KDC_OPT_RESERVED 0x00001000 */ +/* #define KDC_OPT_RESERVED 0x00000800 */ +/* #define KDC_OPT_RESERVED 0x00000400 */ +/* #define KDC_OPT_RESERVED 0x00000200 */ +/* #define KDC_OPT_RESERVED 0x00000100 */ +/* #define KDC_OPT_RESERVED 0x00000080 */ +/* #define KDC_OPT_RESERVED 0x00000040 */ +#define KDC_OPT_DISABLE_TRANSITED_CHECK 0x00000020 +#define KDC_OPT_RENEWABLE_OK 0x00000010 +#define KDC_OPT_ENC_TKT_IN_SKEY 0x00000008 +/* #define KDC_OPT_UNUSED 0x00000004 */ +#define KDC_OPT_RENEW 0x00000002 +#define KDC_OPT_VALIDATE 0x00000001 + +/* + * Mask of ticket flags in the TGT which should be converted into KDC + * options when using the TGT to get derivitive tickets. + * + * New mask = KDC_OPT_FORWARDABLE | KDC_OPT_PROXIABLE | + * KDC_OPT_ALLOW_POSTDATE | KDC_OPT_RENEWABLE + */ +#define KDC_TKT_COMMON_MASK 0x54800000 + +/* definitions for ap_options fields */ +/* ap_options are 32 bits; each host is responsible to put the 4 bytes + representing these bits into net order before transmission */ +#define AP_OPTS_RESERVED 0x80000000 +#define AP_OPTS_USE_SESSION_KEY 0x40000000 +#define AP_OPTS_MUTUAL_REQUIRED 0x20000000 +/* #define AP_OPTS_RESERVED 0x10000000 */ +/* #define AP_OPTS_RESERVED 0x08000000 */ +/* #define AP_OPTS_RESERVED 0x04000000 */ +/* #define AP_OPTS_RESERVED 0x02000000 */ +/* #define AP_OPTS_RESERVED 0x01000000 */ +/* #define AP_OPTS_RESERVED 0x00800000 */ +/* #define AP_OPTS_RESERVED 0x00400000 */ +/* #define AP_OPTS_RESERVED 0x00200000 */ +/* #define AP_OPTS_RESERVED 0x00100000 */ +/* #define AP_OPTS_RESERVED 0x00080000 */ +/* #define AP_OPTS_RESERVED 0x00040000 */ +/* #define AP_OPTS_RESERVED 0x00020000 */ +/* #define AP_OPTS_RESERVED 0x00010000 */ +/* #define AP_OPTS_RESERVED 0x00008000 */ +/* #define AP_OPTS_RESERVED 0x00004000 */ +/* #define AP_OPTS_RESERVED 0x00002000 */ +/* #define AP_OPTS_RESERVED 0x00001000 */ +/* #define AP_OPTS_RESERVED 0x00000800 */ +/* #define AP_OPTS_RESERVED 0x00000400 */ +/* #define AP_OPTS_RESERVED 0x00000200 */ +/* #define AP_OPTS_RESERVED 0x00000100 */ +/* #define AP_OPTS_RESERVED 0x00000080 */ +/* #define AP_OPTS_RESERVED 0x00000040 */ +/* #define AP_OPTS_RESERVED 0x00000020 */ +/* #define AP_OPTS_RESERVED 0x00000010 */ +/* #define AP_OPTS_RESERVED 0x00000008 */ +/* #define AP_OPTS_RESERVED 0x00000004 */ +/* #define AP_OPTS_RESERVED 0x00000002 */ +#define AP_OPTS_USE_SUBKEY 0x00000001 + +#define AP_OPTS_WIRE_MASK 0xfffffff0 + +/* definitions for ad_type fields. */ +#define AD_TYPE_RESERVED 0x8000 +#define AD_TYPE_EXTERNAL 0x4000 +#define AD_TYPE_REGISTERED 0x2000 + +#define AD_TYPE_FIELD_TYPE_MASK 0x1fff + +/* Ticket flags */ +/* flags are 32 bits; each host is responsible to put the 4 bytes + representing these bits into net order before transmission */ +/* #define TKT_FLG_RESERVED 0x80000000 */ +#define TKT_FLG_FORWARDABLE 0x40000000 +#define TKT_FLG_FORWARDED 0x20000000 +#define TKT_FLG_PROXIABLE 0x10000000 +#define TKT_FLG_PROXY 0x08000000 +#define TKT_FLG_MAY_POSTDATE 0x04000000 +#define TKT_FLG_POSTDATED 0x02000000 +#define TKT_FLG_INVALID 0x01000000 +#define TKT_FLG_RENEWABLE 0x00800000 +#define TKT_FLG_INITIAL 0x00400000 +#define TKT_FLG_PRE_AUTH 0x00200000 +#define TKT_FLG_HW_AUTH 0x00100000 +#define TKT_FLG_TRANSIT_POLICY_CHECKED 0x00080000 +#define TKT_FLG_OK_AS_DELEGATE 0x00040000 +#define TKT_FLG_ANONYMOUS 0x00020000 +/* #define TKT_FLG_RESERVED 0x00010000 */ +/* #define TKT_FLG_RESERVED 0x00008000 */ +/* #define TKT_FLG_RESERVED 0x00004000 */ +/* #define TKT_FLG_RESERVED 0x00002000 */ +/* #define TKT_FLG_RESERVED 0x00001000 */ +/* #define TKT_FLG_RESERVED 0x00000800 */ +/* #define TKT_FLG_RESERVED 0x00000400 */ +/* #define TKT_FLG_RESERVED 0x00000200 */ +/* #define TKT_FLG_RESERVED 0x00000100 */ +/* #define TKT_FLG_RESERVED 0x00000080 */ +/* #define TKT_FLG_RESERVED 0x00000040 */ +/* #define TKT_FLG_RESERVED 0x00000020 */ +/* #define TKT_FLG_RESERVED 0x00000010 */ +/* #define TKT_FLG_RESERVED 0x00000008 */ +/* #define TKT_FLG_RESERVED 0x00000004 */ +/* #define TKT_FLG_RESERVED 0x00000002 */ +/* #define TKT_FLG_RESERVED 0x00000001 */ + +/* definitions for lr_type fields. */ +#define LR_TYPE_THIS_SERVER_ONLY 0x8000 + +#define LR_TYPE_INTERPRETATION_MASK 0x7fff + +/* definitions for ad_type fields. */ +#define AD_TYPE_EXTERNAL 0x4000 +#define AD_TYPE_REGISTERED 0x2000 + +#define AD_TYPE_FIELD_TYPE_MASK 0x1fff +#define AD_TYPE_INTERNAL_MASK 0x3fff + +/* definitions for msec direction bit for KRB_SAFE, KRB_PRIV */ +#define MSEC_DIRBIT 0x8000 +#define MSEC_VAL_MASK 0x7fff + +/* + * end "fieldbits.h" + */ + +/* + * begin "proto.h" + */ + +/* Protocol version number */ +#define KRB5_PVNO 5 + +/* Message types */ + +#define KRB5_AS_REQ ((krb5_msgtype)10) /* Req for initial authentication */ +#define KRB5_AS_REP ((krb5_msgtype)11) /* Response to KRB_AS_REQ request */ +#define KRB5_TGS_REQ ((krb5_msgtype)12) /* TGS request to server */ +#define KRB5_TGS_REP ((krb5_msgtype)13) /* Response to KRB_TGS_REQ req */ +#define KRB5_AP_REQ ((krb5_msgtype)14) /* application request to server */ +#define KRB5_AP_REP ((krb5_msgtype)15) /* Response to KRB_AP_REQ_MUTUAL */ +#define KRB5_SAFE ((krb5_msgtype)20) /* Safe application message */ +#define KRB5_PRIV ((krb5_msgtype)21) /* Private application message */ +#define KRB5_CRED ((krb5_msgtype)22) /* Credential forwarding message */ +#define KRB5_ERROR ((krb5_msgtype)30) /* Error response */ + +/* LastReq types */ +#define KRB5_LRQ_NONE 0 +#define KRB5_LRQ_ALL_LAST_TGT 1 +#define KRB5_LRQ_ONE_LAST_TGT (-1) +#define KRB5_LRQ_ALL_LAST_INITIAL 2 +#define KRB5_LRQ_ONE_LAST_INITIAL (-2) +#define KRB5_LRQ_ALL_LAST_TGT_ISSUED 3 +#define KRB5_LRQ_ONE_LAST_TGT_ISSUED (-3) +#define KRB5_LRQ_ALL_LAST_RENEWAL 4 +#define KRB5_LRQ_ONE_LAST_RENEWAL (-4) +#define KRB5_LRQ_ALL_LAST_REQ 5 +#define KRB5_LRQ_ONE_LAST_REQ (-5) +#define KRB5_LRQ_ALL_PW_EXPTIME 6 +#define KRB5_LRQ_ONE_PW_EXPTIME (-6) + +/* PADATA types */ +#define KRB5_PADATA_NONE 0 +#define KRB5_PADATA_AP_REQ 1 +#define KRB5_PADATA_TGS_REQ KRB5_PADATA_AP_REQ +#define KRB5_PADATA_ENC_TIMESTAMP 2 +#define KRB5_PADATA_PW_SALT 3 +#if 0 /* Not used */ +#define KRB5_PADATA_ENC_ENCKEY 4 /* Key encrypted within itself */ +#endif +#define KRB5_PADATA_ENC_UNIX_TIME 5 /* timestamp encrypted in key */ +#define KRB5_PADATA_ENC_SANDIA_SECURID 6 /* SecurId passcode */ +#define KRB5_PADATA_SESAME 7 /* Sesame project */ +#define KRB5_PADATA_OSF_DCE 8 /* OSF DCE */ +#define KRB5_CYBERSAFE_SECUREID 9 /* Cybersafe */ +#define KRB5_PADATA_AFS3_SALT 10 /* Cygnus */ +#define KRB5_PADATA_ETYPE_INFO 11 /* Etype info for preauth */ +#define KRB5_PADATA_SAM_CHALLENGE 12 /* draft challenge system */ +#define KRB5_PADATA_SAM_RESPONSE 13 /* draft challenge system response */ +#define KRB5_PADATA_PK_AS_REQ_OLD 14 /* PKINIT */ +#define KRB5_PADATA_PK_AS_REP_OLD 15 /* PKINIT */ +#define KRB5_PADATA_PK_AS_REQ 16 /* PKINIT */ +#define KRB5_PADATA_PK_AS_REP 17 /* PKINIT */ +#define KRB5_PADATA_ETYPE_INFO2 19 +#define KRB5_PADATA_REFERRAL 25 /* draft referral system */ +#define KRB5_PADATA_SAM_CHALLENGE_2 30 /* draft challenge system, updated */ +#define KRB5_PADATA_SAM_RESPONSE_2 31 /* draft challenge system, updated */ + +#define KRB5_SAM_USE_SAD_AS_KEY 0x80000000 +#define KRB5_SAM_SEND_ENCRYPTED_SAD 0x40000000 +#define KRB5_SAM_MUST_PK_ENCRYPT_SAD 0x20000000 /* currently must be zero */ + +/* Reserved for SPX pre-authentication. */ +#define KRB5_PADATA_DASS 16 + +/* Transited encoding types */ +#define KRB5_DOMAIN_X500_COMPRESS 1 + +/* alternate authentication types */ +#define KRB5_ALTAUTH_ATT_CHALLENGE_RESPONSE 64 + +/* authorization data types */ +#define KRB5_AUTHDATA_IF_RELEVANT 1 +#define KRB5_AUTHDATA_KDC_ISSUED 4 +#define KRB5_AUTHDATA_AND_OR 5 +#define KRB5_AUTHDATA_MANDATORY_FOR_KDC 8 +#define KRB5_AUTHDATA_INITIAL_VERIFIED_CAS 9 +#define KRB5_AUTHDATA_OSF_DCE 64 +#define KRB5_AUTHDATA_SESAME 65 +#define KRB5_AUTHDATA_WIN2K_PAC 128 +#define KRB5_AUTHDATA_ETYPE_NEGOTIATION 129 /* RFC 4537 */ +#define KRB5_AUTHDATA_FX_ARMOR 71 + +/* password change constants */ + +#define KRB5_KPASSWD_SUCCESS 0 +#define KRB5_KPASSWD_MALFORMED 1 +#define KRB5_KPASSWD_HARDERROR 2 +#define KRB5_KPASSWD_AUTHERROR 3 +#define KRB5_KPASSWD_SOFTERROR 4 +/* These are Microsoft's extensions in RFC 3244, and it looks like + they'll become standardized, possibly with other additions. */ +#define KRB5_KPASSWD_ACCESSDENIED 5 /* unused */ +#define KRB5_KPASSWD_BAD_VERSION 6 +#define KRB5_KPASSWD_INITIAL_FLAG_NEEDED 7 /* unused */ + +/* + * end "proto.h" + */ + +/* Time set */ +typedef struct _krb5_ticket_times { + krb5_timestamp authtime; /* XXX ? should ktime in KDC_REP == authtime + in ticket? otherwise client can't get this */ + krb5_timestamp starttime; /* optional in ticket, if not present, + use authtime */ + krb5_timestamp endtime; + krb5_timestamp renew_till; +} krb5_ticket_times; + +/* structure for auth data */ +typedef struct _krb5_authdata { + krb5_magic magic; + krb5_authdatatype ad_type; + unsigned int length; + krb5_octet *contents; +} krb5_authdata; + +/* structure for transited encoding */ +typedef struct _krb5_transited { + krb5_magic magic; + krb5_octet tr_type; + krb5_data tr_contents; +} krb5_transited; + +typedef struct _krb5_enc_tkt_part { + krb5_magic magic; + /* to-be-encrypted portion */ + krb5_flags flags; /* flags */ + krb5_keyblock *session; /* session key: includes enctype */ + krb5_principal client; /* client name/realm */ + krb5_transited transited; /* list of transited realms */ + krb5_ticket_times times; /* auth, start, end, renew_till */ + krb5_address **caddrs; /* array of ptrs to addresses */ + krb5_authdata **authorization_data; /* auth data */ +} krb5_enc_tkt_part; + +typedef struct _krb5_ticket { + krb5_magic magic; + /* cleartext portion */ + krb5_principal server; /* server name/realm */ + krb5_enc_data enc_part; /* encryption type, kvno, encrypted + encoding */ + krb5_enc_tkt_part *enc_part2; /* ptr to decrypted version, if + available */ +} krb5_ticket; + +/* the unencrypted version */ +typedef struct _krb5_authenticator { + krb5_magic magic; + krb5_principal client; /* client name/realm */ + krb5_checksum *checksum; /* checksum, includes type, optional */ + krb5_int32 cusec; /* client usec portion */ + krb5_timestamp ctime; /* client sec portion */ + krb5_keyblock *subkey; /* true session key, optional */ + krb5_ui_4 seq_number; /* sequence #, optional */ + krb5_authdata **authorization_data; /* New add by Ari, auth data */ +} krb5_authenticator; + +typedef struct _krb5_tkt_authent { + krb5_magic magic; + krb5_ticket *ticket; + krb5_authenticator *authenticator; + krb5_flags ap_options; +} krb5_tkt_authent; + +/* credentials: Ticket, session key, etc. */ +typedef struct _krb5_creds { + krb5_magic magic; + krb5_principal client; /* client's principal identifier */ + krb5_principal server; /* server's principal identifier */ + krb5_keyblock keyblock; /* session encryption key info */ + krb5_ticket_times times; /* lifetime info */ + krb5_boolean is_skey; /* true if ticket is encrypted in + another ticket's skey */ + krb5_flags ticket_flags; /* flags in ticket */ + krb5_address * *addresses; /* addrs in ticket */ + krb5_data ticket; /* ticket string itself */ + krb5_data second_ticket; /* second ticket, if related to + ticket (via DUPLICATE-SKEY or + ENC-TKT-IN-SKEY) */ + krb5_authdata **authdata; /* authorization data */ +} krb5_creds; + +/* Last request fields */ +typedef struct _krb5_last_req_entry { + krb5_magic magic; + krb5_int32 lr_type; + krb5_timestamp value; +} krb5_last_req_entry; + +/* pre-authentication data */ +typedef struct _krb5_pa_data { + krb5_magic magic; + krb5_preauthtype pa_type; + unsigned int length; + krb5_octet *contents; +} krb5_pa_data; + +typedef struct _krb5_kdc_req { + krb5_magic magic; + krb5_msgtype msg_type; /* AS_REQ or TGS_REQ? */ + krb5_pa_data **padata; /* e.g. encoded AP_REQ */ + /* real body */ + krb5_flags kdc_options; /* requested options */ + krb5_principal client; /* includes realm; optional */ + krb5_principal server; /* includes realm (only used if no + client) */ + krb5_timestamp from; /* requested starttime */ + krb5_timestamp till; /* requested endtime */ + krb5_timestamp rtime; /* (optional) requested renew_till */ + krb5_int32 nonce; /* nonce to match request/response */ + int nktypes; /* # of ktypes, must be positive */ + krb5_enctype *ktype; /* requested enctype(s) */ + krb5_address **addresses; /* requested addresses, optional */ + krb5_enc_data authorization_data; /* encrypted auth data; OPTIONAL */ + krb5_authdata **unenc_authdata; /* unencrypted auth data, + if available */ + krb5_ticket **second_ticket;/* second ticket array; OPTIONAL */ +} krb5_kdc_req; + +typedef struct _krb5_enc_kdc_rep_part { + krb5_magic magic; + /* encrypted part: */ + krb5_msgtype msg_type; /* krb5 message type */ + krb5_keyblock *session; /* session key */ + krb5_last_req_entry **last_req; /* array of ptrs to entries */ + krb5_int32 nonce; /* nonce from request */ + krb5_timestamp key_exp; /* expiration date */ + krb5_flags flags; /* ticket flags */ + krb5_ticket_times times; /* lifetime info */ + krb5_principal server; /* server's principal identifier */ + krb5_address **caddrs; /* array of ptrs to addresses, + optional */ + krb5_pa_data **enc_padata; /* Windows 2000 compat */ +} krb5_enc_kdc_rep_part; + +typedef struct _krb5_kdc_rep { + krb5_magic magic; + /* cleartext part: */ + krb5_msgtype msg_type; /* AS_REP or KDC_REP? */ + krb5_pa_data **padata; /* preauthentication data from KDC */ + krb5_principal client; /* client's principal identifier */ + krb5_ticket *ticket; /* ticket */ + krb5_enc_data enc_part; /* encryption type, kvno, encrypted + encoding */ + krb5_enc_kdc_rep_part *enc_part2;/* unencrypted version, if available */ +} krb5_kdc_rep; + +/* error message structure */ +typedef struct _krb5_error { + krb5_magic magic; + /* some of these may be meaningless in certain contexts */ + krb5_timestamp ctime; /* client sec portion; optional */ + krb5_int32 cusec; /* client usec portion; optional */ + krb5_int32 susec; /* server usec portion */ + krb5_timestamp stime; /* server sec portion */ + krb5_ui_4 error; /* error code (protocol error #'s) */ + krb5_principal client; /* client's principal identifier; + optional */ + krb5_principal server; /* server's principal identifier */ + krb5_data text; /* descriptive text */ + krb5_data e_data; /* additional error-describing data */ +} krb5_error; + +typedef struct _krb5_ap_req { + krb5_magic magic; + krb5_flags ap_options; /* requested options */ + krb5_ticket *ticket; /* ticket */ + krb5_enc_data authenticator; /* authenticator (already encrypted) */ +} krb5_ap_req; + +typedef struct _krb5_ap_rep { + krb5_magic magic; + krb5_enc_data enc_part; +} krb5_ap_rep; + +typedef struct _krb5_ap_rep_enc_part { + krb5_magic magic; + krb5_timestamp ctime; /* client time, seconds portion */ + krb5_int32 cusec; /* client time, microseconds portion */ + krb5_keyblock *subkey; /* true session key, optional */ + krb5_ui_4 seq_number; /* sequence #, optional */ +} krb5_ap_rep_enc_part; + +typedef struct _krb5_response { + krb5_magic magic; + krb5_octet message_type; + krb5_data response; + krb5_int32 expected_nonce; /* The expected nonce for KDC_REP messages */ + krb5_timestamp request_time; /* When we made the request */ +} krb5_response; + +typedef struct _krb5_cred_info { + krb5_magic magic; + krb5_keyblock *session; /* session key used to encrypt */ + /* ticket */ + krb5_principal client; /* client name/realm, optional */ + krb5_principal server; /* server name/realm, optional */ + krb5_flags flags; /* ticket flags, optional */ + krb5_ticket_times times; /* auth, start, end, renew_till, */ + /* optional */ + krb5_address **caddrs; /* array of ptrs to addresses */ +} krb5_cred_info; + +typedef struct _krb5_cred_enc_part { + krb5_magic magic; + krb5_int32 nonce; /* nonce, optional */ + krb5_timestamp timestamp; /* client time */ + krb5_int32 usec; /* microsecond portion of time */ + krb5_address *s_address; /* sender address, optional */ + krb5_address *r_address; /* recipient address, optional */ + krb5_cred_info **ticket_info; +} krb5_cred_enc_part; + +typedef struct _krb5_cred { + krb5_magic magic; + krb5_ticket **tickets; /* tickets */ + krb5_enc_data enc_part; /* encrypted part */ + krb5_cred_enc_part *enc_part2; /* unencrypted version, if available*/ +} krb5_cred; + +/* Sandia password generation structures */ +typedef struct _passwd_phrase_element { + krb5_magic magic; + krb5_data *passwd; + krb5_data *phrase; +} passwd_phrase_element; + +typedef struct _krb5_pwd_data { + krb5_magic magic; + int sequence_count; + passwd_phrase_element **element; +} krb5_pwd_data; + +/* these need to be here so the typedefs are available for the prototypes */ + +typedef struct _krb5_pa_svr_referral_data { + /* Referred name, only realm is required */ + krb5_principal principal; +} krb5_pa_svr_referral_data; + +typedef struct _krb5_pa_server_referral_data { + krb5_data *referred_realm; + krb5_principal true_principal_name; + krb5_principal requested_principal_name; + krb5_timestamp referral_valid_until; + krb5_checksum rep_cksum; +} krb5_pa_server_referral_data; + +typedef struct _krb5_pa_pac_req { + /* TRUE if a PAC should be included in TGS-REP */ + krb5_boolean include_pac; +} krb5_pa_pac_req; + +/* + * begin "safepriv.h" + */ + +#define KRB5_AUTH_CONTEXT_DO_TIME 0x00000001 +#define KRB5_AUTH_CONTEXT_RET_TIME 0x00000002 +#define KRB5_AUTH_CONTEXT_DO_SEQUENCE 0x00000004 +#define KRB5_AUTH_CONTEXT_RET_SEQUENCE 0x00000008 +#define KRB5_AUTH_CONTEXT_PERMIT_ALL 0x00000010 +#define KRB5_AUTH_CONTEXT_USE_SUBKEY 0x00000020 + +typedef struct krb5_replay_data { + krb5_timestamp timestamp; + krb5_int32 usec; + krb5_int32 seq; +} krb5_replay_data; + +/* flags for krb5_auth_con_genaddrs() */ +#define KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR 0x00000001 +#define KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR 0x00000002 +#define KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR 0x00000004 +#define KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR 0x00000008 + +/* type of function used as a callback to generate checksum data for + * mk_req */ + +typedef krb5_error_code +(KRB5_CALLCONV * krb5_mk_req_checksum_func) (krb5_context, krb5_auth_context , void *, + krb5_data **); + +/* + * end "safepriv.h" + */ + + +/* + * begin "ccache.h" + */ + +typedef krb5_pointer krb5_cc_cursor; /* cursor for sequential lookup */ + +struct _krb5_ccache; +typedef struct _krb5_ccache *krb5_ccache; +struct _krb5_cc_ops; +typedef struct _krb5_cc_ops krb5_cc_ops; + +/* for retrieve_cred */ +#define KRB5_TC_MATCH_TIMES 0x00000001 +#define KRB5_TC_MATCH_IS_SKEY 0x00000002 +#define KRB5_TC_MATCH_FLAGS 0x00000004 +#define KRB5_TC_MATCH_TIMES_EXACT 0x00000008 +#define KRB5_TC_MATCH_FLAGS_EXACT 0x00000010 +#define KRB5_TC_MATCH_AUTHDATA 0x00000020 +#define KRB5_TC_MATCH_SRV_NAMEONLY 0x00000040 +#define KRB5_TC_MATCH_2ND_TKT 0x00000080 +#define KRB5_TC_MATCH_KTYPE 0x00000100 +#define KRB5_TC_SUPPORTED_KTYPES 0x00000200 + +/* for set_flags and other functions */ +#define KRB5_TC_OPENCLOSE 0x00000001 +#define KRB5_TC_NOTICKET 0x00000002 + + +krb5_error_code KRB5_CALLCONV +krb5_cc_gen_new (krb5_context context, krb5_ccache *cache); + +krb5_error_code KRB5_CALLCONV +krb5_cc_initialize(krb5_context context, krb5_ccache cache, + krb5_principal principal); + +krb5_error_code KRB5_CALLCONV +krb5_cc_destroy (krb5_context context, krb5_ccache cache); + +krb5_error_code KRB5_CALLCONV +krb5_cc_close (krb5_context context, krb5_ccache cache); + +krb5_error_code KRB5_CALLCONV +krb5_cc_store_cred (krb5_context context, krb5_ccache cache, + krb5_creds *creds); + +krb5_error_code KRB5_CALLCONV +krb5_cc_retrieve_cred (krb5_context context, krb5_ccache cache, + krb5_flags flags, krb5_creds *mcreds, + krb5_creds *creds); + +krb5_error_code KRB5_CALLCONV +krb5_cc_get_principal (krb5_context context, krb5_ccache cache, + krb5_principal *principal); + +krb5_error_code KRB5_CALLCONV +krb5_cc_start_seq_get (krb5_context context, krb5_ccache cache, + krb5_cc_cursor *cursor); + +krb5_error_code KRB5_CALLCONV +krb5_cc_next_cred (krb5_context context, krb5_ccache cache, + krb5_cc_cursor *cursor, krb5_creds *creds); + +krb5_error_code KRB5_CALLCONV +krb5_cc_end_seq_get (krb5_context context, krb5_ccache cache, + krb5_cc_cursor *cursor); + +krb5_error_code KRB5_CALLCONV +krb5_cc_remove_cred (krb5_context context, krb5_ccache cache, krb5_flags flags, + krb5_creds *creds); + +krb5_error_code KRB5_CALLCONV +krb5_cc_set_flags (krb5_context context, krb5_ccache cache, krb5_flags flags); + +krb5_error_code KRB5_CALLCONV +krb5_cc_get_flags (krb5_context context, krb5_ccache cache, krb5_flags *flags); + +const char * KRB5_CALLCONV +krb5_cc_get_type (krb5_context context, krb5_ccache cache); + +/* SUNW14resync - add_cred.c needs this func */ +const char * KRB5_CALLCONV +krb5_cc_get_name (krb5_context context, krb5_ccache cache); + +krb5_error_code KRB5_CALLCONV +krb5_cc_new_unique( + krb5_context context, + const char *type, + const char *hint, + krb5_ccache *id); + +/* + * end "ccache.h" + */ + +/* + * begin "rcache.h" + */ + +struct krb5_rc_st; +typedef struct krb5_rc_st *krb5_rcache; + +/* + * end "rcache.h" + */ + +/* + * begin "keytab.h" + */ + + +/* XXX */ +#define MAX_KEYTAB_NAME_LEN 1100 /* Long enough for MAXPATHLEN + some extra */ + +typedef krb5_pointer krb5_kt_cursor; /* XXX */ + +typedef struct krb5_keytab_entry_st { + krb5_magic magic; + krb5_principal principal; /* principal of this key */ + krb5_timestamp timestamp; /* time entry written to keytable */ + krb5_kvno vno; /* key version number */ + krb5_keyblock key; /* the secret key */ +} krb5_keytab_entry; + +#if KRB5_PRIVATE +struct _krb5_kt_ops; +typedef struct _krb5_kt { /* should move into k5-int.h */ + krb5_magic magic; + const struct _krb5_kt_ops *ops; + krb5_pointer data; +} *krb5_keytab; +#else +struct _krb5_kt; +typedef struct _krb5_kt *krb5_keytab; +#endif + +char * KRB5_CALLCONV +krb5_kt_get_type (krb5_context, krb5_keytab keytab); +krb5_error_code KRB5_CALLCONV +krb5_kt_get_name(krb5_context context, krb5_keytab keytab, char *name, + unsigned int namelen); +krb5_error_code KRB5_CALLCONV +krb5_kt_close(krb5_context context, krb5_keytab keytab); +krb5_error_code KRB5_CALLCONV +krb5_kt_get_entry(krb5_context context, krb5_keytab keytab, + krb5_const_principal principal, krb5_kvno vno, + krb5_enctype enctype, krb5_keytab_entry *entry); +krb5_error_code KRB5_CALLCONV +krb5_kt_start_seq_get(krb5_context context, krb5_keytab keytab, + krb5_kt_cursor *cursor); +krb5_error_code KRB5_CALLCONV +krb5_kt_next_entry(krb5_context context, krb5_keytab keytab, + krb5_keytab_entry *entry, krb5_kt_cursor *cursor); +krb5_error_code KRB5_CALLCONV +krb5_kt_end_seq_get(krb5_context context, krb5_keytab keytab, + krb5_kt_cursor *cursor); +/* Solaris Kerberos */ +krb5_error_code +krb5_kt_find_realm(krb5_context context, krb5_keytab keytab, + krb5_principal princ, krb5_data *realm); + +/* + * end "keytab.h" + */ + +/* + * begin "func-proto.h" + */ + +/* Solaris Kerberos */ +krb5_error_code krb5_init_ef_handle(krb5_context); +krb5_error_code krb5_free_ef_handle(krb5_context); + +krb5_boolean krb5_privacy_allowed(void); + +/* + * Solaris Kerberos: + * krb5_copy_keyblock_data is a new routine to hide the details + * of a keyblock copy operation. + */ +krb5_error_code KRB5_CALLCONV krb5_copy_keyblock_data + (krb5_context, + const krb5_keyblock *, + krb5_keyblock *); + + + +krb5_error_code KRB5_CALLCONV krb5_init_context + (krb5_context *); +krb5_error_code KRB5_CALLCONV krb5_init_secure_context + (krb5_context *); +void KRB5_CALLCONV krb5_free_context + (krb5_context); + +#if KRB5_PRIVATE +krb5_error_code krb5_set_default_in_tkt_ktypes + (krb5_context, + const krb5_enctype *); +krb5_error_code krb5_get_default_in_tkt_ktypes + (krb5_context, + krb5_enctype **); + +krb5_error_code krb5_set_default_tgs_ktypes + (krb5_context, + const krb5_enctype *); +#endif + +krb5_error_code KRB5_CALLCONV +krb5_set_default_tgs_enctypes + (krb5_context, + const krb5_enctype *); +#if KRB5_PRIVATE +krb5_error_code KRB5_CALLCONV krb5_get_tgs_ktypes + (krb5_context, + krb5_const_principal, + krb5_enctype **); +#endif + +krb5_error_code KRB5_CALLCONV krb5_get_permitted_enctypes + (krb5_context, krb5_enctype **); + +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_ktypes + (krb5_context, krb5_enctype *); + +krb5_boolean krb5_is_permitted_enctype + (krb5_context, krb5_enctype); +#endif + +krb5_boolean KRB5_CALLCONV krb5_is_thread_safe(void); + +/* libkrb.spec */ +#if KRB5_PRIVATE +krb5_error_code krb5_kdc_rep_decrypt_proc + (krb5_context, + const krb5_keyblock *, + krb5_const_pointer, + krb5_kdc_rep * ); +krb5_error_code KRB5_CALLCONV krb5_decrypt_tkt_part + (krb5_context, + const krb5_keyblock *, + krb5_ticket * ); +krb5_error_code krb5_get_cred_from_kdc + (krb5_context, + krb5_ccache, /* not const, as reading may save + state */ + krb5_creds *, + krb5_creds **, + krb5_creds *** ); +krb5_error_code krb5_get_cred_from_kdc_validate + (krb5_context, + krb5_ccache, /* not const, as reading may save + state */ + krb5_creds *, + krb5_creds **, + krb5_creds *** ); +krb5_error_code krb5_get_cred_from_kdc_renew + (krb5_context, + krb5_ccache, /* not const, as reading may save + state */ + krb5_creds *, + krb5_creds **, + krb5_creds *** ); +#endif + +void KRB5_CALLCONV krb5_free_tgt_creds + (krb5_context, + krb5_creds **); /* XXX too hard to do with const */ + +#define KRB5_GC_USER_USER 1 /* want user-user ticket */ +#define KRB5_GC_CACHED 2 /* want cached ticket only */ + +krb5_error_code KRB5_CALLCONV krb5_get_credentials + (krb5_context, + krb5_flags, + krb5_ccache, + krb5_creds *, + krb5_creds **); +krb5_error_code KRB5_CALLCONV krb5_get_credentials_validate + (krb5_context, + krb5_flags, + krb5_ccache, + krb5_creds *, + krb5_creds **); +krb5_error_code KRB5_CALLCONV krb5_get_credentials_renew + (krb5_context, + krb5_flags, + krb5_ccache, + krb5_creds *, + krb5_creds **); +#if KRB5_PRIVATE +krb5_error_code krb5_get_cred_via_tkt + (krb5_context, + krb5_creds *, + krb5_flags, + krb5_address * const *, + krb5_creds *, + krb5_creds **); +#endif +krb5_error_code KRB5_CALLCONV krb5_mk_req + (krb5_context, + krb5_auth_context *, + krb5_flags, + char *, + char *, + krb5_data *, + krb5_ccache, + krb5_data * ); +krb5_error_code KRB5_CALLCONV krb5_mk_req_extended + (krb5_context, + krb5_auth_context *, + krb5_flags, + krb5_data *, + krb5_creds *, + krb5_data * ); +krb5_error_code KRB5_CALLCONV krb5_mk_rep + (krb5_context, + krb5_auth_context, + krb5_data *); +krb5_error_code KRB5_CALLCONV krb5_rd_rep + (krb5_context, + krb5_auth_context, + const krb5_data *, + krb5_ap_rep_enc_part **); +krb5_error_code KRB5_CALLCONV krb5_mk_error + (krb5_context, + const krb5_error *, + krb5_data * ); +krb5_error_code KRB5_CALLCONV krb5_rd_error + (krb5_context, + const krb5_data *, + krb5_error ** ); +krb5_error_code KRB5_CALLCONV krb5_rd_safe + (krb5_context, + krb5_auth_context, + const krb5_data *, + krb5_data *, + krb5_replay_data *); +krb5_error_code KRB5_CALLCONV krb5_rd_priv + (krb5_context, + krb5_auth_context, + const krb5_data *, + krb5_data *, + krb5_replay_data *); +krb5_error_code KRB5_CALLCONV krb5_parse_name + (krb5_context, + const char *, + krb5_principal * ); +#define KRB5_PRINCIPAL_PARSE_NO_REALM 0x1 +#define KRB5_PRINCIPAL_PARSE_REQUIRE_REALM 0x2 +#define KRB5_PRINCIPAL_PARSE_ENTERPRISE 0x4 +krb5_error_code KRB5_CALLCONV krb5_parse_name_flags + (krb5_context, + const char *, + int, + krb5_principal * ); +krb5_error_code KRB5_CALLCONV krb5_unparse_name + (krb5_context, + krb5_const_principal, + char ** ); +krb5_error_code KRB5_CALLCONV krb5_unparse_name_ext + (krb5_context, + krb5_const_principal, + char **, + unsigned int *); +#define KRB5_PRINCIPAL_UNPARSE_SHORT 0x1 +#define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 +#define KRB5_PRINCIPAL_UNPARSE_DISPLAY 0x4 +krb5_error_code KRB5_CALLCONV krb5_unparse_name_flags + (krb5_context, + krb5_const_principal, + int, + char **); +krb5_error_code KRB5_CALLCONV krb5_unparse_name_flags_ext + (krb5_context, + krb5_const_principal, + int, + char **, + unsigned int *); + +krb5_error_code KRB5_CALLCONV krb5_set_principal_realm + (krb5_context, krb5_principal, const char *); + +krb5_boolean KRB5_CALLCONV_WRONG krb5_address_search + (krb5_context, + const krb5_address *, + krb5_address * const *); +krb5_boolean KRB5_CALLCONV krb5_address_compare + (krb5_context, + const krb5_address *, + const krb5_address *); +int KRB5_CALLCONV krb5_address_order + (krb5_context, + const krb5_address *, + const krb5_address *); +krb5_boolean KRB5_CALLCONV krb5_realm_compare + (krb5_context, + krb5_const_principal, + krb5_const_principal); +krb5_boolean KRB5_CALLCONV krb5_principal_compare + (krb5_context, + krb5_const_principal, + krb5_const_principal); +krb5_error_code KRB5_CALLCONV krb5_init_keyblock + (krb5_context, krb5_enctype enctype, + size_t length, krb5_keyblock **out); + /* Initialize a new keyblock and allocate storage + * for the contents of the key, which will be freed along + * with the keyblock when krb5_free_keyblock is called. + * It is legal to pass in a length of 0, in which + * case contents are left unallocated. + */ + +/* + * Solaris Kerberos + * Start - keyblock API (MIT will ship this also in a future release) + */ +/* + * Similiar to krb5_init_keyblock but this routine expects the + * keyblock to already be allocated. + */ +krb5_error_code KRB5_CALLCONV krb5_init_allocated_keyblock + (krb5_context, + krb5_enctype, + unsigned int, + krb5_keyblock *); + +krb5_enctype KRB5_CALLCONV krb5_get_key_enctype + (krb5_keyblock *); + +unsigned int KRB5_CALLCONV krb5_get_key_length + (krb5_keyblock *); + +krb5_octet KRB5_CALLCONV *krb5_get_key_data + (krb5_keyblock *); + +void KRB5_CALLCONV krb5_set_key_enctype + (krb5_keyblock *, + krb5_enctype); + +void KRB5_CALLCONV krb5_set_key_data + (krb5_keyblock *, + krb5_octet *); + +void KRB5_CALLCONV krb5_set_key_length + (krb5_keyblock *, + unsigned int); +/* + * Solaris Kerberos + * End - keyblock API + */ + +krb5_error_code KRB5_CALLCONV krb5_copy_keyblock + (krb5_context, + const krb5_keyblock *, + krb5_keyblock **); +krb5_error_code KRB5_CALLCONV krb5_copy_keyblock_contents + (krb5_context, + const krb5_keyblock *, + krb5_keyblock *); +krb5_error_code KRB5_CALLCONV krb5_copy_creds + (krb5_context, + const krb5_creds *, + krb5_creds **); +krb5_error_code KRB5_CALLCONV krb5_copy_data + (krb5_context, + const krb5_data *, + krb5_data **); +krb5_error_code KRB5_CALLCONV krb5_copy_principal + (krb5_context, + krb5_const_principal, + krb5_principal *); +#if KRB5_PRIVATE +krb5_error_code KRB5_CALLCONV krb5_copy_addr + (krb5_context, + const krb5_address *, + krb5_address **); +#endif +krb5_error_code KRB5_CALLCONV krb5_copy_addresses + (krb5_context, + krb5_address * const *, + krb5_address ***); +krb5_error_code KRB5_CALLCONV krb5_copy_ticket + (krb5_context, + const krb5_ticket *, + krb5_ticket **); +krb5_error_code KRB5_CALLCONV krb5_copy_authdata + (krb5_context, + krb5_authdata * const *, + krb5_authdata ***); +krb5_error_code KRB5_CALLCONV krb5_merge_authdata + (krb5_context, + krb5_authdata * const *, + krb5_authdata *const *, + krb5_authdata ***); +/* Merge two authdata arrays, such as the array from a ticket + * and authenticator */ + +krb5_error_code KRB5_CALLCONV krb5_copy_authenticator + (krb5_context, + const krb5_authenticator *, + krb5_authenticator **); +krb5_error_code KRB5_CALLCONV krb5_copy_checksum + (krb5_context, + const krb5_checksum *, + krb5_checksum **); +#if KRB5_PRIVATE +void krb5_init_ets + (krb5_context); +void krb5_free_ets + (krb5_context); +krb5_error_code krb5_generate_subkey + (krb5_context, + const krb5_keyblock *, krb5_keyblock **); +krb5_error_code krb5_generate_seq_number + (krb5_context, + const krb5_keyblock *, krb5_ui_4 *); +#endif +krb5_error_code KRB5_CALLCONV krb5_get_server_rcache + (krb5_context, + const krb5_data *, krb5_rcache *); +krb5_error_code KRB5_CALLCONV_C krb5_build_principal_ext + (krb5_context, krb5_principal *, unsigned int, const char *, ...); +krb5_error_code KRB5_CALLCONV_C krb5_build_principal + (krb5_context, krb5_principal *, unsigned int, const char *, ...); +#ifdef va_start +/* XXX depending on varargs include file defining va_start... */ +krb5_error_code KRB5_CALLCONV krb5_build_principal_va + (krb5_context, + krb5_principal, unsigned int, const char *, va_list); +#endif + +krb5_error_code KRB5_CALLCONV krb5_425_conv_principal + (krb5_context, + const char *name, + const char *instance, const char *realm, + krb5_principal *princ); + +krb5_error_code KRB5_CALLCONV krb5_524_conv_principal + (krb5_context context, krb5_const_principal princ, + char *name, char *inst, char *realm); + +struct credentials; +int KRB5_CALLCONV krb5_524_convert_creds + (krb5_context context, krb5_creds *v5creds, + struct credentials *v4creds); +#if KRB5_DEPRECATED +#define krb524_convert_creds_kdc krb5_524_convert_creds +#define krb524_init_ets(x) (0) +#endif + +/* libkt.spec */ +#if KRB5_PRIVATE +krb5_error_code KRB5_CALLCONV krb5_kt_register + (krb5_context, + const struct _krb5_kt_ops * ); +#endif + +krb5_error_code KRB5_CALLCONV krb5_kt_resolve + (krb5_context, + const char *, + krb5_keytab * ); +krb5_error_code KRB5_CALLCONV krb5_kt_default_name + (krb5_context, + char *, + int ); +krb5_error_code KRB5_CALLCONV krb5_kt_default + (krb5_context, + krb5_keytab * ); +krb5_error_code KRB5_CALLCONV krb5_free_keytab_entry_contents + (krb5_context, + krb5_keytab_entry * ); +#if KRB5_PRIVATE +/* use krb5_free_keytab_entry_contents instead */ +krb5_error_code KRB5_CALLCONV krb5_kt_free_entry + (krb5_context, + krb5_keytab_entry * ); +#endif +/* remove and add are functions, so that they can return NOWRITE + if not a writable keytab */ +krb5_error_code KRB5_CALLCONV krb5_kt_remove_entry + (krb5_context, + krb5_keytab, + krb5_keytab_entry * ); +krb5_error_code KRB5_CALLCONV krb5_kt_add_entry + (krb5_context, + krb5_keytab, + krb5_keytab_entry * ); +krb5_error_code KRB5_CALLCONV_WRONG krb5_principal2salt + (krb5_context, + krb5_const_principal, krb5_data *); +#if KRB5_PRIVATE +krb5_error_code krb5_principal2salt_norealm + (krb5_context, + krb5_const_principal, krb5_data *); +#endif +/* librc.spec--see rcache.h */ + +/* libcc.spec */ +krb5_error_code KRB5_CALLCONV krb5_cc_resolve + (krb5_context, + const char *, + krb5_ccache * ); +const char * KRB5_CALLCONV krb5_cc_default_name + (krb5_context); +krb5_error_code KRB5_CALLCONV krb5_cc_set_default_name + (krb5_context, const char *); +krb5_error_code KRB5_CALLCONV krb5_cc_default + (krb5_context, + krb5_ccache *); +#if KRB5_PRIVATE +unsigned int KRB5_CALLCONV krb5_get_notification_message + (void); +#endif + +krb5_error_code KRB5_CALLCONV krb5_cc_copy_creds + (krb5_context context, + krb5_ccache incc, + krb5_ccache outcc); + + +/* chk_trans.c */ +#if KRB5_PRIVATE +krb5_error_code krb5_check_transited_list + (krb5_context, const krb5_data *trans, + const krb5_data *realm1, const krb5_data *realm2); +#endif + +/* free_rtree.c */ +#if KRB5_PRIVATE +void krb5_free_realm_tree + (krb5_context, + krb5_principal *); +#endif + +/* krb5_free.c */ +void KRB5_CALLCONV krb5_free_principal + (krb5_context, krb5_principal ); +void KRB5_CALLCONV krb5_free_authenticator + (krb5_context, krb5_authenticator * ); +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_authenticator_contents + (krb5_context, krb5_authenticator * ); +#endif +void KRB5_CALLCONV krb5_free_addresses + (krb5_context, krb5_address ** ); +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_address + (krb5_context, krb5_address * ); +#endif +void KRB5_CALLCONV krb5_free_authdata + (krb5_context, krb5_authdata ** ); +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_enc_tkt_part + (krb5_context, krb5_enc_tkt_part * ); +#endif +void KRB5_CALLCONV krb5_free_ticket + (krb5_context, krb5_ticket * ); +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_tickets + (krb5_context, krb5_ticket ** ); +void KRB5_CALLCONV krb5_free_kdc_req + (krb5_context, krb5_kdc_req * ); +void KRB5_CALLCONV krb5_free_kdc_rep + (krb5_context, krb5_kdc_rep * ); +void KRB5_CALLCONV krb5_free_last_req + (krb5_context, krb5_last_req_entry ** ); +void KRB5_CALLCONV krb5_free_enc_kdc_rep_part + (krb5_context, krb5_enc_kdc_rep_part * ); +#endif +void KRB5_CALLCONV krb5_free_error + (krb5_context, krb5_error * ); +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_ap_req + (krb5_context, krb5_ap_req * ); +void KRB5_CALLCONV krb5_free_ap_rep + (krb5_context, krb5_ap_rep * ); +void KRB5_CALLCONV krb5_free_cred + (krb5_context, krb5_cred *); +#endif +void KRB5_CALLCONV krb5_free_creds + (krb5_context, krb5_creds *); +void KRB5_CALLCONV krb5_free_cred_contents + (krb5_context, krb5_creds *); +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_cred_enc_part + (krb5_context, krb5_cred_enc_part *); +#endif +void KRB5_CALLCONV krb5_free_checksum + (krb5_context, krb5_checksum *); +void KRB5_CALLCONV krb5_free_checksum_contents + (krb5_context, krb5_checksum *); +void KRB5_CALLCONV krb5_free_keyblock + (krb5_context, krb5_keyblock *); +void KRB5_CALLCONV krb5_free_keyblock_contents + (krb5_context, krb5_keyblock *); +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_pa_data + (krb5_context, krb5_pa_data **); +#endif +void KRB5_CALLCONV krb5_free_ap_rep_enc_part + (krb5_context, krb5_ap_rep_enc_part *); +#if KRB5_PRIVATE +void KRB5_CALLCONV krb5_free_tkt_authent + (krb5_context, krb5_tkt_authent *); +void KRB5_CALLCONV krb5_free_pwd_data + (krb5_context, krb5_pwd_data *); +void KRB5_CALLCONV krb5_free_pwd_sequences + (krb5_context, passwd_phrase_element **); +#endif +void KRB5_CALLCONV krb5_free_data + (krb5_context, krb5_data *); +void KRB5_CALLCONV krb5_free_data_contents + (krb5_context, krb5_data *); +void KRB5_CALLCONV krb5_free_unparsed_name + (krb5_context, char *); +void KRB5_CALLCONV krb5_free_cksumtypes + (krb5_context, krb5_cksumtype *); + +/* From krb5/os but needed but by the outside world */ +krb5_error_code KRB5_CALLCONV krb5_us_timeofday + (krb5_context, + krb5_int32 *, + krb5_int32 * ); +krb5_error_code KRB5_CALLCONV krb5_timeofday + (krb5_context, + krb5_int32 * ); + /* get all the addresses of this host */ +krb5_error_code KRB5_CALLCONV krb5_os_localaddr + (krb5_context, + krb5_address ***); +krb5_error_code KRB5_CALLCONV krb5_get_default_realm + (krb5_context, + char ** ); +krb5_error_code KRB5_CALLCONV krb5_set_default_realm + (krb5_context, + const char * ); +void KRB5_CALLCONV krb5_free_default_realm + (krb5_context, + char * ); +krb5_error_code KRB5_CALLCONV krb5_sname_to_principal + (krb5_context, + const char *, + const char *, + krb5_int32, + krb5_principal *); +krb5_error_code KRB5_CALLCONV +krb5_change_password + (krb5_context context, krb5_creds *creds, char *newpw, + int *result_code, krb5_data *result_code_string, + krb5_data *result_string); +krb5_error_code KRB5_CALLCONV +krb5_set_password + (krb5_context context, krb5_creds *creds, char *newpw, krb5_principal change_password_for, + int *result_code, krb5_data *result_code_string, krb5_data *result_string); +krb5_error_code KRB5_CALLCONV +krb5_set_password_using_ccache + (krb5_context context, krb5_ccache ccache, char *newpw, krb5_principal change_password_for, + int *result_code, krb5_data *result_code_string, krb5_data *result_string); + +#if KRB5_PRIVATE +krb5_error_code krb5_set_config_files + (krb5_context, const char **); + +krb5_error_code KRB5_CALLCONV krb5_get_default_config_files + (char ***filenames); + +void KRB5_CALLCONV krb5_free_config_files + (char **filenames); +#endif + +krb5_error_code KRB5_CALLCONV +krb5_get_profile + (krb5_context, struct _profile_t * /* profile_t */ *); + +#if KRB5_PRIVATE +krb5_error_code krb5_send_tgs + (krb5_context, + krb5_flags, + const krb5_ticket_times *, + const krb5_enctype *, + krb5_const_principal, + krb5_address * const *, + krb5_authdata * const *, + krb5_pa_data * const *, + const krb5_data *, + krb5_creds *, + krb5_response * ); + +krb5_error_code krb5_send_tgs2 + (krb5_context, + krb5_flags, + const krb5_ticket_times *, + const krb5_enctype *, + krb5_const_principal, + krb5_address * const *, + krb5_authdata * const *, + krb5_pa_data * const *, + const krb5_data *, + krb5_creds *, + krb5_response * , + char **); +#endif + +#if KRB5_DEPRECATED +krb5_error_code KRB5_CALLCONV krb5_get_in_tkt + (krb5_context, + krb5_flags, + krb5_address * const *, + krb5_enctype *, + krb5_preauthtype *, + krb5_error_code ( * )(krb5_context, + krb5_enctype, + krb5_data *, + krb5_const_pointer, + krb5_keyblock **), + krb5_const_pointer, + krb5_error_code ( * )(krb5_context, + const krb5_keyblock *, + krb5_const_pointer, + krb5_kdc_rep * ), + krb5_const_pointer, + krb5_creds *, + krb5_ccache, + krb5_kdc_rep ** ); + +krb5_error_code KRB5_CALLCONV krb5_get_in_tkt_with_password + (krb5_context, + krb5_flags, + krb5_address * const *, + krb5_enctype *, + krb5_preauthtype *, + const char *, + krb5_ccache, + krb5_creds *, + krb5_kdc_rep ** ); + +krb5_error_code KRB5_CALLCONV krb5_get_in_tkt_with_skey + (krb5_context, + krb5_flags, + krb5_address * const *, + krb5_enctype *, + krb5_preauthtype *, + const krb5_keyblock *, + krb5_ccache, + krb5_creds *, + krb5_kdc_rep ** ); + +krb5_error_code KRB5_CALLCONV krb5_get_in_tkt_with_keytab + (krb5_context, + krb5_flags, + krb5_address * const *, + krb5_enctype *, + krb5_preauthtype *, + krb5_keytab, + krb5_ccache, + krb5_creds *, + krb5_kdc_rep ** ); +#endif /* KRB5_DEPRECATED */ + +#if KRB5_PRIVATE +krb5_error_code krb5_decode_kdc_rep + (krb5_context, + krb5_data *, + const krb5_keyblock *, + krb5_kdc_rep ** ); +#endif + +krb5_error_code KRB5_CALLCONV krb5_rd_req + (krb5_context, + krb5_auth_context *, + const krb5_data *, + krb5_const_principal, + krb5_keytab, + krb5_flags *, + krb5_ticket **); + +#if KRB5_PRIVATE +krb5_error_code krb5_rd_req_decoded + (krb5_context, + krb5_auth_context *, + const krb5_ap_req *, + krb5_const_principal, + krb5_keytab, + krb5_flags *, + krb5_ticket **); + +krb5_error_code krb5_rd_req_decoded_anyflag + (krb5_context, + krb5_auth_context *, + const krb5_ap_req *, + krb5_const_principal, + krb5_keytab, + krb5_flags *, + krb5_ticket **); +#endif + +krb5_error_code KRB5_CALLCONV krb5_kt_read_service_key + (krb5_context, + krb5_pointer, + krb5_principal, + krb5_kvno, + krb5_enctype, + krb5_keyblock **); +krb5_error_code KRB5_CALLCONV krb5_mk_safe + (krb5_context, + krb5_auth_context, + const krb5_data *, + krb5_data *, + krb5_replay_data *); +krb5_error_code KRB5_CALLCONV krb5_mk_priv + (krb5_context, + krb5_auth_context, + const krb5_data *, + krb5_data *, + krb5_replay_data *); +#if KRB5_PRIVATE +krb5_error_code KRB5_CALLCONV krb5_cc_register + (krb5_context, + krb5_cc_ops *, + krb5_boolean ); +#endif + +krb5_error_code KRB5_CALLCONV krb5_sendauth + (krb5_context, + krb5_auth_context *, + krb5_pointer, + char *, + krb5_principal, + krb5_principal, + krb5_flags, + krb5_data *, + krb5_creds *, + krb5_ccache, + krb5_error **, + krb5_ap_rep_enc_part **, + krb5_creds **); + +krb5_error_code KRB5_CALLCONV krb5_recvauth + (krb5_context, + krb5_auth_context *, + krb5_pointer, + char *, + krb5_principal, + krb5_int32, + krb5_keytab, + krb5_ticket **); +krb5_error_code KRB5_CALLCONV krb5_recvauth_version + (krb5_context, + krb5_auth_context *, + krb5_pointer, + krb5_principal, + krb5_int32, + krb5_keytab, + krb5_ticket **, + krb5_data *); + +#if KRB5_PRIVATE +krb5_error_code krb5_walk_realm_tree + (krb5_context, + const krb5_data *, + const krb5_data *, + krb5_principal **, + int); +#endif + +krb5_error_code KRB5_CALLCONV krb5_mk_ncred + (krb5_context, + krb5_auth_context, + krb5_creds **, + krb5_data **, + krb5_replay_data *); + +krb5_error_code KRB5_CALLCONV krb5_mk_1cred + (krb5_context, + krb5_auth_context, + krb5_creds *, + krb5_data **, + krb5_replay_data *); + +krb5_error_code KRB5_CALLCONV krb5_rd_cred + (krb5_context, + krb5_auth_context, + krb5_data *, + krb5_creds ***, + krb5_replay_data *); + +krb5_error_code KRB5_CALLCONV krb5_fwd_tgt_creds + (krb5_context, + krb5_auth_context, + char *, + krb5_principal, + krb5_principal, + krb5_ccache, + int forwardable, + krb5_data *); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_init + (krb5_context, + krb5_auth_context *); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_free + (krb5_context, + krb5_auth_context); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_setflags + (krb5_context, + krb5_auth_context, + krb5_int32); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getflags + (krb5_context, + krb5_auth_context, + krb5_int32 *); + +krb5_error_code KRB5_CALLCONV +krb5_auth_con_set_checksum_func (krb5_context, krb5_auth_context, + krb5_mk_req_checksum_func, void *); + +krb5_error_code KRB5_CALLCONV +krb5_auth_con_get_checksum_func( krb5_context, krb5_auth_context, + krb5_mk_req_checksum_func *, void **); + +krb5_error_code KRB5_CALLCONV_WRONG krb5_auth_con_setaddrs + (krb5_context, + krb5_auth_context, + krb5_address *, + krb5_address *); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getaddrs + (krb5_context, + krb5_auth_context, + krb5_address **, + krb5_address **); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_setports + (krb5_context, + krb5_auth_context, + krb5_address *, + krb5_address *); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_setuseruserkey + (krb5_context, + krb5_auth_context, + krb5_keyblock *); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getkey + (krb5_context, + krb5_auth_context, + krb5_keyblock **); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getsendsubkey( + krb5_context, krb5_auth_context, krb5_keyblock **); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getrecvsubkey( + krb5_context, krb5_auth_context, krb5_keyblock **); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_setsendsubkey( + krb5_context, krb5_auth_context, krb5_keyblock *); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_setrecvsubkey( + krb5_context, krb5_auth_context, krb5_keyblock *); + +#if KRB5_DEPRECATED +krb5_error_code KRB5_CALLCONV krb5_auth_con_getlocalsubkey + (krb5_context, + krb5_auth_context, + krb5_keyblock **); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getremotesubkey + (krb5_context, + krb5_auth_context, + krb5_keyblock **); +#endif + +#if KRB5_PRIVATE +krb5_error_code KRB5_CALLCONV krb5_auth_con_set_req_cksumtype + (krb5_context, + krb5_auth_context, + krb5_cksumtype); + +krb5_error_code krb5_auth_con_set_safe_cksumtype + (krb5_context, + krb5_auth_context, + krb5_cksumtype); +#endif + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getlocalseqnumber + (krb5_context, + krb5_auth_context, + krb5_int32 *); + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getremoteseqnumber + (krb5_context, + krb5_auth_context, + krb5_int32 *); + +#if KRB5_DEPRECATED +krb5_error_code KRB5_CALLCONV krb5_auth_con_initivector + (krb5_context, + krb5_auth_context); +#endif + +#if KRB5_PRIVATE +krb5_error_code krb5_auth_con_setivector + (krb5_context, + krb5_auth_context, + krb5_pointer); + +krb5_error_code krb5_auth_con_getivector + (krb5_context, + krb5_auth_context, + krb5_pointer *); +#endif + +krb5_error_code KRB5_CALLCONV krb5_auth_con_setrcache + (krb5_context, + krb5_auth_context, + krb5_rcache); + +krb5_error_code KRB5_CALLCONV_WRONG krb5_auth_con_getrcache + (krb5_context, + krb5_auth_context, + krb5_rcache *); + +#if KRB5_PRIVATE +krb5_error_code krb5_auth_con_setpermetypes + (krb5_context, + krb5_auth_context, + const krb5_enctype *); + +krb5_error_code krb5_auth_con_getpermetypes + (krb5_context, + krb5_auth_context, + krb5_enctype **); +#endif + +krb5_error_code KRB5_CALLCONV krb5_auth_con_getauthenticator + (krb5_context, + krb5_auth_context, + krb5_authenticator **); + +#define KRB5_REALM_BRANCH_CHAR '.' + +/* + * end "func-proto.h" + */ + +/* + * begin stuff from libos.h + */ + +#if KRB5_PRIVATE +krb5_error_code krb5_read_message (krb5_context, krb5_pointer, krb5_data *); +krb5_error_code krb5_write_message (krb5_context, krb5_pointer, krb5_data *); +int krb5_net_read (krb5_context, int , char *, int); +int krb5_net_write (krb5_context, int , const char *, int); +#endif + +krb5_error_code KRB5_CALLCONV krb5_read_password + (krb5_context, + const char *, + const char *, + char *, + unsigned int * ); +krb5_error_code KRB5_CALLCONV krb5_aname_to_localname + (krb5_context, + krb5_const_principal, + int, + char * ); +krb5_error_code KRB5_CALLCONV krb5_get_host_realm + (krb5_context, + const char *, + char *** ); +krb5_error_code KRB5_CALLCONV krb5_get_fallback_host_realm + (krb5_context, + krb5_data *, + char *** ); +krb5_error_code KRB5_CALLCONV krb5_free_host_realm + (krb5_context, + char * const * ); +#if KRB5_PRIVATE +krb5_error_code KRB5_CALLCONV krb5_get_realm_domain + (krb5_context, + const char *, + char ** ); +#endif +krb5_boolean KRB5_CALLCONV krb5_kuserok + (krb5_context, + krb5_principal, const char *); +krb5_error_code KRB5_CALLCONV krb5_auth_con_genaddrs + (krb5_context, + krb5_auth_context, + int, int); +#if KRB5_PRIVATE +krb5_error_code krb5_gen_portaddr + (krb5_context, + const krb5_address *, + krb5_const_pointer, + krb5_address **); +krb5_error_code krb5_gen_replay_name + (krb5_context, + const krb5_address *, + const char *, + char **); +krb5_error_code krb5_make_fulladdr + (krb5_context, + krb5_address *, + krb5_address *, + krb5_address *); +#endif + +krb5_error_code KRB5_CALLCONV krb5_set_real_time + (krb5_context, krb5_int32, krb5_int32); + +#if KRB5_PRIVATE +krb5_error_code krb5_set_debugging_time + (krb5_context, krb5_int32, krb5_int32); +krb5_error_code krb5_use_natural_time + (krb5_context); +#endif +krb5_error_code KRB5_CALLCONV krb5_get_time_offsets + (krb5_context, krb5_int32 *, krb5_int32 *); +#if KRB5_PRIVATE +krb5_error_code krb5_set_time_offsets + (krb5_context, krb5_int32, krb5_int32); +#endif + +/* str_conv.c */ +krb5_error_code KRB5_CALLCONV krb5_string_to_enctype + (char *, krb5_enctype *); +krb5_error_code KRB5_CALLCONV krb5_string_to_salttype + (char *, krb5_int32 *); +krb5_error_code KRB5_CALLCONV krb5_string_to_cksumtype + (char *, krb5_cksumtype *); +krb5_error_code KRB5_CALLCONV krb5_string_to_timestamp + (char *, krb5_timestamp *); +krb5_error_code KRB5_CALLCONV krb5_string_to_deltat + (char *, krb5_deltat *); +krb5_error_code KRB5_CALLCONV krb5_enctype_to_string + (krb5_enctype, char *, size_t); +/* Solaris Kerberos */ +krb5_error_code KRB5_CALLCONV krb5_enctype_to_istring + (krb5_enctype, char *, size_t); +krb5_error_code KRB5_CALLCONV krb5_salttype_to_string + (krb5_int32, char *, size_t); +krb5_error_code KRB5_CALLCONV krb5_cksumtype_to_string + (krb5_cksumtype, char *, size_t); +krb5_error_code KRB5_CALLCONV krb5_timestamp_to_string + (krb5_timestamp, char *, size_t); +krb5_error_code KRB5_CALLCONV krb5_timestamp_to_sfstring + (krb5_timestamp, char *, size_t, char *); +krb5_error_code KRB5_CALLCONV krb5_deltat_to_string + (krb5_deltat, char *, size_t); + + +/* + * end stuff from libos.h + */ + +/* + * begin "k5-free.h" + */ + +/* to keep lint happy */ +#ifdef _KERNEL +#define krb5_xfree_wrap(val,n) kmem_free((char *)(val),n) +#else +#define krb5_xfree_wrap(val,n) free((char *)(val)) +#define krb5_xfree(val) free((char *)(val)) +#endif + +/* + * end "k5-free.h" + */ + +/* The name of the Kerberos ticket granting service... and its size */ +#define KRB5_TGS_NAME "krbtgt" +#define KRB5_TGS_NAME_SIZE 6 + +/* flags for recvauth */ +#define KRB5_RECVAUTH_SKIP_VERSION 0x0001 +#define KRB5_RECVAUTH_BADAUTHVERS 0x0002 +/* initial ticket api functions */ + +typedef struct _krb5_prompt { + char *prompt; + int hidden; + krb5_data *reply; +} krb5_prompt; + +typedef krb5_error_code (KRB5_CALLCONV *krb5_prompter_fct)(krb5_context context, + void *data, + const char *name, + const char *banner, + int num_prompts, + krb5_prompt prompts[]); + + +krb5_error_code KRB5_CALLCONV +krb5_prompter_posix (krb5_context context, + void *data, + const char *name, + const char *banner, + int num_prompts, + krb5_prompt prompts[]); + +typedef struct _krb5_get_init_creds_opt { + krb5_flags flags; + krb5_deltat tkt_life; + krb5_deltat renew_life; + int forwardable; + int proxiable; + krb5_enctype *etype_list; + int etype_list_length; + krb5_address **address_list; + krb5_preauthtype *preauth_list; + int preauth_list_length; + krb5_data *salt; +} krb5_get_init_creds_opt; + +#define KRB5_GET_INIT_CREDS_OPT_TKT_LIFE 0x0001 +#define KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE 0x0002 +#define KRB5_GET_INIT_CREDS_OPT_FORWARDABLE 0x0004 +#define KRB5_GET_INIT_CREDS_OPT_PROXIABLE 0x0008 +#define KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST 0x0010 +#define KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST 0x0020 +#define KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST 0x0040 +#define KRB5_GET_INIT_CREDS_OPT_SALT 0x0080 +#define KRB5_GET_INIT_CREDS_OPT_CHG_PWD_PRMPT 0x0100 + +krb5_error_code KRB5_CALLCONV +krb5_get_init_creds_opt_alloc +(krb5_context context, + krb5_get_init_creds_opt **opt); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_free +(krb5_context context, + krb5_get_init_creds_opt *opt); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_init +(krb5_get_init_creds_opt *opt); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_tkt_life +(krb5_get_init_creds_opt *opt, + krb5_deltat tkt_life); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_renew_life +(krb5_get_init_creds_opt *opt, + krb5_deltat renew_life); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_forwardable +(krb5_get_init_creds_opt *opt, + int forwardable); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_proxiable +(krb5_get_init_creds_opt *opt, + int proxiable); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_etype_list +(krb5_get_init_creds_opt *opt, + krb5_enctype *etype_list, + int etype_list_length); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_address_list +(krb5_get_init_creds_opt *opt, + krb5_address **addresses); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_preauth_list +(krb5_get_init_creds_opt *opt, + krb5_preauthtype *preauth_list, + int preauth_list_length); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_salt +(krb5_get_init_creds_opt *opt, + krb5_data *salt); + +void KRB5_CALLCONV +krb5_get_init_creds_opt_set_change_password_prompt +(krb5_get_init_creds_opt *opt, + int prompt); + +/* Generic preauth option attribute/value pairs */ +typedef struct _krb5_gic_opt_pa_data { + char *attr; + char *value; +} krb5_gic_opt_pa_data; + +/* + * This function allows the caller to supply options to preauth + * plugins. Preauth plugin modules are given a chance to look + * at each option at the time this function is called in ordre + * to check the validity of the option. + * The 'opt' pointer supplied to this function must have been + * obtained using krb5_get_init_creds_opt_alloc() + */ +krb5_error_code KRB5_CALLCONV +krb5_get_init_creds_opt_set_pa + (krb5_context context, + krb5_get_init_creds_opt *opt, + const char *attr, + const char *value); + +krb5_error_code KRB5_CALLCONV +krb5_get_init_creds_password +(krb5_context context, + krb5_creds *creds, + krb5_principal client, + char *password, + krb5_prompter_fct prompter, + void *data, + krb5_deltat start_time, + char *in_tkt_service, + krb5_get_init_creds_opt *k5_gic_options); + +krb5_error_code KRB5_CALLCONV +krb5_get_init_creds_keytab +(krb5_context context, + krb5_creds *creds, + krb5_principal client, + krb5_keytab arg_keytab, + krb5_deltat start_time, + char *in_tkt_service, + krb5_get_init_creds_opt *k5_gic_options); + +typedef struct _krb5_verify_init_creds_opt { + krb5_flags flags; + int ap_req_nofail; +} krb5_verify_init_creds_opt; + +#define KRB5_VERIFY_INIT_CREDS_OPT_AP_REQ_NOFAIL 0x0001 + +void KRB5_CALLCONV +krb5_verify_init_creds_opt_init +(krb5_verify_init_creds_opt *k5_vic_options); +void KRB5_CALLCONV +krb5_verify_init_creds_opt_set_ap_req_nofail +(krb5_verify_init_creds_opt *k5_vic_options, + int ap_req_nofail); + +krb5_error_code KRB5_CALLCONV +krb5_verify_init_creds +(krb5_context context, + krb5_creds *creds, + krb5_principal ap_req_server, + krb5_keytab ap_req_keytab, + krb5_ccache *ccache, + krb5_verify_init_creds_opt *k5_vic_options); + +krb5_error_code KRB5_CALLCONV +krb5_get_validated_creds +(krb5_context context, + krb5_creds *creds, + krb5_principal client, + krb5_ccache ccache, + char *in_tkt_service); + +krb5_error_code KRB5_CALLCONV +krb5_get_renewed_creds +(krb5_context context, + krb5_creds *creds, + krb5_principal client, + krb5_ccache ccache, + char *in_tkt_service); + +krb5_error_code KRB5_CALLCONV +krb5_decode_ticket +(const krb5_data *code, + krb5_ticket **rep); + +void KRB5_CALLCONV +krb5_appdefault_string +(krb5_context context, + const char *appname, + const krb5_data *realm, + const char *option, + const char *default_value, + char ** ret_value); + +void KRB5_CALLCONV +krb5_appdefault_boolean +(krb5_context context, + const char *appname, + const krb5_data *realm, + const char *option, + int default_value, + int *ret_value); + +#if KRB5_PRIVATE +/* + * The realm iterator functions + */ + +krb5_error_code KRB5_CALLCONV krb5_realm_iterator_create + (krb5_context context, void **iter_p); + +krb5_error_code KRB5_CALLCONV krb5_realm_iterator + (krb5_context context, void **iter_p, char **ret_realm); + +void KRB5_CALLCONV krb5_realm_iterator_free + (krb5_context context, void **iter_p); + +void KRB5_CALLCONV krb5_free_realm_string + (krb5_context context, char *str); +#endif + +/* + * The realm iterator functions + */ + +krb5_error_code KRB5_CALLCONV krb5_realm_iterator_create + (krb5_context context, void **iter_p); + +krb5_error_code KRB5_CALLCONV krb5_realm_iterator + (krb5_context context, void **iter_p, char **ret_realm); + +void KRB5_CALLCONV krb5_realm_iterator_free + (krb5_context context, void **iter_p); + +void KRB5_CALLCONV krb5_free_realm_string + (krb5_context context, char *str); + +/* + * Prompter enhancements + */ + +#define KRB5_PROMPT_TYPE_PASSWORD 0x1 +#define KRB5_PROMPT_TYPE_NEW_PASSWORD 0x2 +#define KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN 0x3 +#define KRB5_PROMPT_TYPE_PREAUTH 0x4 + +typedef krb5_int32 krb5_prompt_type; + +krb5_prompt_type* KRB5_CALLCONV krb5_get_prompt_types + (krb5_context context); + +/* Error reporting */ +void KRB5_CALLCONV_C +krb5_set_error_message (krb5_context, krb5_error_code, const char *, ...); +#ifdef va_start +void KRB5_CALLCONV +krb5_vset_error_message (krb5_context, krb5_error_code, const char *, va_list); +#endif +/* + * The behavior of krb5_get_error_message is only defined the first + * time it is called after a failed call to a krb5 function using the + * same context, and only when the error code passed in is the same as + * that returned by the krb5 function. Future versions may return the + * same string for the second and following calls. + * + * The string returned by this function must be freed using + * krb5_free_error_message. + */ +const char * KRB5_CALLCONV +krb5_get_error_message (krb5_context, krb5_error_code); +void KRB5_CALLCONV +krb5_free_error_message (krb5_context, const char *); +void KRB5_CALLCONV +krb5_clear_error_message (krb5_context); + +krb5_error_code KRB5_CALLCONV +krb5_decode_authdata_container(krb5_context context, + krb5_authdatatype type, + const krb5_authdata *container, + krb5_authdata ***authdata); +krb5_error_code KRB5_CALLCONV +krb5_encode_authdata_container(krb5_context context, + krb5_authdatatype type, + krb5_authdata * const*authdata, + krb5_authdata ***container); + +/* + * Windows PAC + */ +struct krb5_pac_data; +typedef struct krb5_pac_data *krb5_pac; + +krb5_error_code KRB5_CALLCONV +krb5_pac_add_buffer +(krb5_context context, + krb5_pac pac, + krb5_ui_4 type, + const krb5_data *data); + +void KRB5_CALLCONV +krb5_pac_free +(krb5_context context, + krb5_pac pac); + +krb5_error_code KRB5_CALLCONV +krb5_pac_get_buffer +(krb5_context context, + krb5_pac pac, + krb5_ui_4 type, + krb5_data *data); + +krb5_error_code KRB5_CALLCONV +krb5_pac_get_types +(krb5_context context, + krb5_pac pac, + size_t *len, + krb5_ui_4 **types); + +krb5_error_code KRB5_CALLCONV +krb5_pac_init +(krb5_context context, + krb5_pac *pac); + +krb5_error_code KRB5_CALLCONV +krb5_pac_parse +(krb5_context context, + const void *ptr, + size_t len, + krb5_pac *pac); + +krb5_error_code KRB5_CALLCONV +krb5_pac_verify +(krb5_context context, + const krb5_pac pac, + krb5_timestamp authtime, + krb5_const_principal principal, + const krb5_keyblock *server, + const krb5_keyblock *privsvr); + + +#if TARGET_OS_MAC +# pragma pack(pop) +#endif + +KRB5INT_END_DECLS + +/* Don't use this! We're going to phase it out. It's just here to keep + applications from breaking right away. */ +#define krb5_const const + +#endif /* KRB5_GENERAL__ */ + +/* + * Solaris Kerberos: the following differs from the MIT krb5.hin as that file is + * processed to produce their krb5.h. We do not process a krb5.hin so our + * krb5.h is manually edited. + */ + +/* + * krb5_err.h: + * This file is automatically generated; please do not edit it. + */ + +#define KRB5KDC_ERR_NONE (-1765328384L) +#define KRB5KDC_ERR_NAME_EXP (-1765328383L) +#define KRB5KDC_ERR_SERVICE_EXP (-1765328382L) +#define KRB5KDC_ERR_BAD_PVNO (-1765328381L) +#define KRB5KDC_ERR_C_OLD_MAST_KVNO (-1765328380L) +#define KRB5KDC_ERR_S_OLD_MAST_KVNO (-1765328379L) +#define KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN (-1765328378L) +#define KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN (-1765328377L) +#define KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE (-1765328376L) +#define KRB5KDC_ERR_NULL_KEY (-1765328375L) +#define KRB5KDC_ERR_CANNOT_POSTDATE (-1765328374L) +#define KRB5KDC_ERR_NEVER_VALID (-1765328373L) +#define KRB5KDC_ERR_POLICY (-1765328372L) +#define KRB5KDC_ERR_BADOPTION (-1765328371L) +#define KRB5KDC_ERR_ETYPE_NOSUPP (-1765328370L) +#define KRB5KDC_ERR_SUMTYPE_NOSUPP (-1765328369L) +#define KRB5KDC_ERR_PADATA_TYPE_NOSUPP (-1765328368L) +#define KRB5KDC_ERR_TRTYPE_NOSUPP (-1765328367L) +#define KRB5KDC_ERR_CLIENT_REVOKED (-1765328366L) +#define KRB5KDC_ERR_SERVICE_REVOKED (-1765328365L) +#define KRB5KDC_ERR_TGT_REVOKED (-1765328364L) +#define KRB5KDC_ERR_CLIENT_NOTYET (-1765328363L) +#define KRB5KDC_ERR_SERVICE_NOTYET (-1765328362L) +#define KRB5KDC_ERR_KEY_EXP (-1765328361L) +#define KRB5KDC_ERR_PREAUTH_FAILED (-1765328360L) +#define KRB5KDC_ERR_PREAUTH_REQUIRED (-1765328359L) +#define KRB5KDC_ERR_SERVER_NOMATCH (-1765328358L) +#define KRB5KDC_ERR_MUST_USE_USER2USER (-1765328357L) +#define KRB5KDC_ERR_PATH_NOT_ACCEPTED (-1765328356L) +#define KRB5KDC_ERR_SVC_UNAVAILABLE (-1765328355L) +#define KRB5PLACEHOLD_30 (-1765328354L) +#define KRB5KRB_AP_ERR_BAD_INTEGRITY (-1765328353L) +#define KRB5KRB_AP_ERR_TKT_EXPIRED (-1765328352L) +#define KRB5KRB_AP_ERR_TKT_NYV (-1765328351L) +#define KRB5KRB_AP_ERR_REPEAT (-1765328350L) +#define KRB5KRB_AP_ERR_NOT_US (-1765328349L) +#define KRB5KRB_AP_ERR_BADMATCH (-1765328348L) +#define KRB5KRB_AP_ERR_SKEW (-1765328347L) +#define KRB5KRB_AP_ERR_BADADDR (-1765328346L) +#define KRB5KRB_AP_ERR_BADVERSION (-1765328345L) +#define KRB5KRB_AP_ERR_MSG_TYPE (-1765328344L) +#define KRB5KRB_AP_ERR_MODIFIED (-1765328343L) +#define KRB5KRB_AP_ERR_BADORDER (-1765328342L) +#define KRB5KRB_AP_ERR_ILL_CR_TKT (-1765328341L) +#define KRB5KRB_AP_ERR_BADKEYVER (-1765328340L) +#define KRB5KRB_AP_ERR_NOKEY (-1765328339L) +#define KRB5KRB_AP_ERR_MUT_FAIL (-1765328338L) +#define KRB5KRB_AP_ERR_BADDIRECTION (-1765328337L) +#define KRB5KRB_AP_ERR_METHOD (-1765328336L) +#define KRB5KRB_AP_ERR_BADSEQ (-1765328335L) +#define KRB5KRB_AP_ERR_INAPP_CKSUM (-1765328334L) +#define KRB5KRB_AP_PATH_NOT_ACCEPTED (-1765328333L) +#define KRB5KRB_ERR_RESPONSE_TOO_BIG (-1765328332L) +#define KRB5PLACEHOLD_53 (-1765328331L) +#define KRB5PLACEHOLD_54 (-1765328330L) +#define KRB5PLACEHOLD_55 (-1765328329L) +#define KRB5PLACEHOLD_56 (-1765328328L) +#define KRB5PLACEHOLD_57 (-1765328327L) +#define KRB5PLACEHOLD_58 (-1765328326L) +#define KRB5PLACEHOLD_59 (-1765328325L) +#define KRB5KRB_ERR_GENERIC (-1765328324L) +#define KRB5KRB_ERR_FIELD_TOOLONG (-1765328323L) +#define KRB5KDC_ERR_CLIENT_NOT_TRUSTED (-1765328322L) +#define KRB5KDC_ERR_KDC_NOT_TRUSTED (-1765328321L) +#define KRB5KDC_ERR_INVALID_SIG (-1765328320L) +#define KRB5KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED (-1765328319L) +#define KRB5KDC_ERR_CERTIFICATE_MISMATCH (-1765328318L) +#define KRB5KRB_AP_ERR_NO_TGT (-1765328317L) +#define KRB5KDC_ERR_WRONG_REALM (-1765328316L) +#define KRB5KRB_AP_ERR_USER_TO_USER_REQUIRED (-1765328315L) +#define KRB5KDC_ERR_CANT_VERIFY_CERTIFICATE (-1765328314L) +#define KRB5KDC_ERR_INVALID_CERTIFICATE (-1765328313L) +#define KRB5KDC_ERR_REVOKED_CERTIFICATE (-1765328312L) +#define KRB5KDC_ERR_REVOCATION_STATUS_UNKNOWN (-1765328311L) +#define KRB5KDC_ERR_REVOCATION_STATUS_UNAVAILABLE (-1765328310L) +#define KRB5KDC_ERR_CLIENT_NAME_MISMATCH (-1765328309L) +#define KRB5KDC_ERR_KDC_NAME_MISMATCH (-1765328308L) +#define KRB5KDC_ERR_INCONSISTENT_KEY_PURPOSE (-1765328307L) +#define KRB5KDC_ERR_DIGEST_IN_CERT_NOT_ACCEPTED (-1765328306L) +#define KRB5KDC_ERR_PA_CHECKSUM_MUST_BE_INCLUDED (-1765328305L) +#define KRB5KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED (-1765328304L) +#define KRB5KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED (-1765328303L) +#define KRB5PLACEHOLD_82 (-1765328302L) +#define KRB5PLACEHOLD_83 (-1765328301L) +#define KRB5PLACEHOLD_84 (-1765328300L) +#define KRB5PLACEHOLD_85 (-1765328299L) +#define KRB5PLACEHOLD_86 (-1765328298L) +#define KRB5PLACEHOLD_87 (-1765328297L) +#define KRB5PLACEHOLD_88 (-1765328296L) +#define KRB5PLACEHOLD_89 (-1765328295L) +#define KRB5PLACEHOLD_90 (-1765328294L) +#define KRB5PLACEHOLD_91 (-1765328293L) +#define KRB5PLACEHOLD_92 (-1765328292L) +#define KRB5PLACEHOLD_93 (-1765328291L) +#define KRB5PLACEHOLD_94 (-1765328290L) +#define KRB5PLACEHOLD_95 (-1765328289L) +#define KRB5PLACEHOLD_96 (-1765328288L) +#define KRB5PLACEHOLD_97 (-1765328287L) +#define KRB5PLACEHOLD_98 (-1765328286L) +#define KRB5PLACEHOLD_99 (-1765328285L) +#define KRB5PLACEHOLD_100 (-1765328284L) +#define KRB5PLACEHOLD_101 (-1765328283L) +#define KRB5PLACEHOLD_102 (-1765328282L) +#define KRB5PLACEHOLD_103 (-1765328281L) +#define KRB5PLACEHOLD_104 (-1765328280L) +#define KRB5PLACEHOLD_105 (-1765328279L) +#define KRB5PLACEHOLD_106 (-1765328278L) +#define KRB5PLACEHOLD_107 (-1765328277L) +#define KRB5PLACEHOLD_108 (-1765328276L) +#define KRB5PLACEHOLD_109 (-1765328275L) +#define KRB5PLACEHOLD_110 (-1765328274L) +#define KRB5PLACEHOLD_111 (-1765328273L) +#define KRB5PLACEHOLD_112 (-1765328272L) +#define KRB5PLACEHOLD_113 (-1765328271L) +#define KRB5PLACEHOLD_114 (-1765328270L) +#define KRB5PLACEHOLD_115 (-1765328269L) +#define KRB5PLACEHOLD_116 (-1765328268L) +#define KRB5PLACEHOLD_117 (-1765328267L) +#define KRB5PLACEHOLD_118 (-1765328266L) +#define KRB5PLACEHOLD_119 (-1765328265L) +#define KRB5PLACEHOLD_120 (-1765328264L) +#define KRB5PLACEHOLD_121 (-1765328263L) +#define KRB5PLACEHOLD_122 (-1765328262L) +#define KRB5PLACEHOLD_123 (-1765328261L) +#define KRB5PLACEHOLD_124 (-1765328260L) +#define KRB5PLACEHOLD_125 (-1765328259L) +#define KRB5PLACEHOLD_126 (-1765328258L) +#define KRB5PLACEHOLD_127 (-1765328257L) +#define KRB5_ERR_RCSID (-1765328256L) +#define KRB5_LIBOS_BADLOCKFLAG (-1765328255L) +#define KRB5_LIBOS_CANTREADPWD (-1765328254L) +#define KRB5_LIBOS_BADPWDMATCH (-1765328253L) +#define KRB5_LIBOS_PWDINTR (-1765328252L) +#define KRB5_PARSE_ILLCHAR (-1765328251L) +#define KRB5_PARSE_MALFORMED (-1765328250L) +#define KRB5_CONFIG_CANTOPEN (-1765328249L) +#define KRB5_CONFIG_BADFORMAT (-1765328248L) +#define KRB5_CONFIG_NOTENUFSPACE (-1765328247L) +#define KRB5_BADMSGTYPE (-1765328246L) +#define KRB5_CC_BADNAME (-1765328245L) +#define KRB5_CC_UNKNOWN_TYPE (-1765328244L) +#define KRB5_CC_NOTFOUND (-1765328243L) +#define KRB5_CC_END (-1765328242L) +#define KRB5_NO_TKT_SUPPLIED (-1765328241L) +#define KRB5KRB_AP_WRONG_PRINC (-1765328240L) +#define KRB5KRB_AP_ERR_TKT_INVALID (-1765328239L) +#define KRB5_PRINC_NOMATCH (-1765328238L) +#define KRB5_KDCREP_MODIFIED (-1765328237L) +#define KRB5_KDCREP_SKEW (-1765328236L) +#define KRB5_IN_TKT_REALM_MISMATCH (-1765328235L) +#define KRB5_PROG_ETYPE_NOSUPP (-1765328234L) +#define KRB5_PROG_KEYTYPE_NOSUPP (-1765328233L) +#define KRB5_WRONG_ETYPE (-1765328232L) +#define KRB5_PROG_SUMTYPE_NOSUPP (-1765328231L) +#define KRB5_REALM_UNKNOWN (-1765328230L) +#define KRB5_SERVICE_UNKNOWN (-1765328229L) +#define KRB5_KDC_UNREACH (-1765328228L) +#define KRB5_NO_LOCALNAME (-1765328227L) +#define KRB5_MUTUAL_FAILED (-1765328226L) +#define KRB5_RC_TYPE_EXISTS (-1765328225L) +#define KRB5_RC_MALLOC (-1765328224L) +#define KRB5_RC_TYPE_NOTFOUND (-1765328223L) +#define KRB5_RC_UNKNOWN (-1765328222L) +#define KRB5_RC_REPLAY (-1765328221L) +#define KRB5_RC_IO (-1765328220L) +#define KRB5_RC_NOIO (-1765328219L) +#define KRB5_RC_PARSE (-1765328218L) +#define KRB5_RC_IO_EOF (-1765328217L) +#define KRB5_RC_IO_MALLOC (-1765328216L) +#define KRB5_RC_IO_PERM (-1765328215L) +#define KRB5_RC_IO_IO (-1765328214L) +#define KRB5_RC_IO_UNKNOWN (-1765328213L) +#define KRB5_RC_IO_SPACE (-1765328212L) +#define KRB5_TRANS_CANTOPEN (-1765328211L) +#define KRB5_TRANS_BADFORMAT (-1765328210L) +#define KRB5_LNAME_CANTOPEN (-1765328209L) +#define KRB5_LNAME_NOTRANS (-1765328208L) +#define KRB5_LNAME_BADFORMAT (-1765328207L) +#define KRB5_CRYPTO_INTERNAL (-1765328206L) +#define KRB5_KT_BADNAME (-1765328205L) +#define KRB5_KT_UNKNOWN_TYPE (-1765328204L) +#define KRB5_KT_NOTFOUND (-1765328203L) +#define KRB5_KT_END (-1765328202L) +#define KRB5_KT_NOWRITE (-1765328201L) +#define KRB5_KT_IOERR (-1765328200L) +#define KRB5_NO_TKT_IN_RLM (-1765328199L) +#define KRB5DES_BAD_KEYPAR (-1765328198L) +#define KRB5DES_WEAK_KEY (-1765328197L) +#define KRB5_BAD_ENCTYPE (-1765328196L) +#define KRB5_BAD_KEYSIZE (-1765328195L) +#define KRB5_BAD_MSIZE (-1765328194L) +#define KRB5_CC_TYPE_EXISTS (-1765328193L) +#define KRB5_KT_TYPE_EXISTS (-1765328192L) +#define KRB5_CC_IO (-1765328191L) +#define KRB5_FCC_PERM (-1765328190L) +#define KRB5_FCC_NOFILE (-1765328189L) +#define KRB5_FCC_INTERNAL (-1765328188L) +#define KRB5_CC_WRITE (-1765328187L) +#define KRB5_CC_NOMEM (-1765328186L) +#define KRB5_CC_FORMAT (-1765328185L) +#define KRB5_CC_NOT_KTYPE (-1765328184L) +#define KRB5_INVALID_FLAGS (-1765328183L) +#define KRB5_NO_2ND_TKT (-1765328182L) +#define KRB5_NOCREDS_SUPPLIED (-1765328181L) +#define KRB5_SENDAUTH_BADAUTHVERS (-1765328180L) +#define KRB5_SENDAUTH_BADAPPLVERS (-1765328179L) +#define KRB5_SENDAUTH_BADRESPONSE (-1765328178L) +#define KRB5_SENDAUTH_REJECTED (-1765328177L) +#define KRB5_PREAUTH_BAD_TYPE (-1765328176L) +#define KRB5_PREAUTH_NO_KEY (-1765328175L) +#define KRB5_PREAUTH_FAILED (-1765328174L) +#define KRB5_RCACHE_BADVNO (-1765328173L) +#define KRB5_CCACHE_BADVNO (-1765328172L) +#define KRB5_KEYTAB_BADVNO (-1765328171L) +#define KRB5_PROG_ATYPE_NOSUPP (-1765328170L) +#define KRB5_RC_REQUIRED (-1765328169L) +#define KRB5_ERR_BAD_HOSTNAME (-1765328168L) +#define KRB5_ERR_HOST_REALM_UNKNOWN (-1765328167L) +#define KRB5_SNAME_UNSUPP_NAMETYPE (-1765328166L) +#define KRB5KRB_AP_ERR_V4_REPLY (-1765328165L) +#define KRB5_REALM_CANT_RESOLVE (-1765328164L) +#define KRB5_TKT_NOT_FORWARDABLE (-1765328163L) +#define KRB5_FWD_BAD_PRINCIPAL (-1765328162L) +#define KRB5_GET_IN_TKT_LOOP (-1765328161L) +#define KRB5_CONFIG_NODEFREALM (-1765328160L) +#define KRB5_SAM_UNSUPPORTED (-1765328159L) +#define KRB5_SAM_INVALID_ETYPE (-1765328158L) +#define KRB5_SAM_NO_CHECKSUM (-1765328157L) +#define KRB5_SAM_BAD_CHECKSUM (-1765328156L) +#define KRB5_KT_NAME_TOOLONG (-1765328155L) +#define KRB5_KT_KVNONOTFOUND (-1765328154L) +#define KRB5_APPL_EXPIRED (-1765328153L) +#define KRB5_LIB_EXPIRED (-1765328152L) +#define KRB5_CHPW_PWDNULL (-1765328151L) +#define KRB5_CHPW_FAIL (-1765328150L) +#define KRB5_KT_FORMAT (-1765328149L) +#define KRB5_NOPERM_ETYPE (-1765328148L) +#define KRB5_CONFIG_ETYPE_NOSUPP (-1765328147L) +#define KRB5_OBSOLETE_FN (-1765328146L) +#define KRB5_EAI_FAIL (-1765328145L) +#define KRB5_EAI_NODATA (-1765328144L) +#define KRB5_EAI_NONAME (-1765328143L) +#define KRB5_EAI_SERVICE (-1765328142L) +#define KRB5_ERR_NUMERIC_REALM (-1765328141L) +#define KRB5_ERR_BAD_S2K_PARAMS (-1765328140L) +#define KRB5_ERR_NO_SERVICE (-1765328139L) +#define KRB5_CC_READONLY (-1765328138L) +#define KRB5_CC_NOSUPP (-1765328137L) + +/* NOTE! error values should not collide */ +/* XXX Note KRB5_RC_BADNAME and KRB5_CONF_NOT_CONFIGURED are Solaris specific */ +#define KRB5_RC_BADNAME (-1765328136L) +#define KRB5_CONF_NOT_CONFIGURED (-1765328135L) +#ifdef _KERNEL +/* XXX Note KRB5_KEF_ERROR and PKCS_ERR are Solaris specific */ +#define KRB5_KEF_ERROR (-1765328134L) +#else +#define PKCS_ERR (-1765328134L) +#endif /* _KERNEL */ + +#define KRB5_DELTAT_BADFORMAT (-1765328133L) +#define KRB5_PLUGIN_NO_HANDLE (-1765328132L) +#define KRB5_PLUGIN_OP_NOTSUPP (-1765328131L) + +/* SUNW17PACresync */ +#define KRB5_ERR_INVALID_UTF8 (-1765328130L) +#define KRB5_ERR_FAST_REQUIRED (-1765328129L) +#define KRB5_LOCAL_ADDR_REQUIRED (-1765328128L) +#define KRB5_REMOTE_ADDR_REQUIRED (-1765328127L) + + +#define ERROR_TABLE_BASE_krb5 (-1765328384L) + +/* for compatibility with older versions... */ +#define krb5_err_base ERROR_TABLE_BASE_krb5 +/* + * kdb5_err.h: + * This file is automatically generated; please do not edit it. + */ +#define KRB5_KDB_RCSID (-1780008448L) +#define KRB5_KDB_INUSE (-1780008447L) +#define KRB5_KDB_UK_SERROR (-1780008446L) +#define KRB5_KDB_UK_RERROR (-1780008445L) +#define KRB5_KDB_UNAUTH (-1780008444L) +#define KRB5_KDB_NOENTRY (-1780008443L) +#define KRB5_KDB_ILL_WILDCARD (-1780008442L) +#define KRB5_KDB_DB_INUSE (-1780008441L) +#define KRB5_KDB_DB_CHANGED (-1780008440L) +#define KRB5_KDB_TRUNCATED_RECORD (-1780008439L) +#define KRB5_KDB_RECURSIVELOCK (-1780008438L) +#define KRB5_KDB_NOTLOCKED (-1780008437L) +#define KRB5_KDB_BADLOCKMODE (-1780008436L) +#define KRB5_KDB_DBNOTINITED (-1780008435L) +#define KRB5_KDB_DBINITED (-1780008434L) +#define KRB5_KDB_ILLDIRECTION (-1780008433L) +#define KRB5_KDB_NOMASTERKEY (-1780008432L) +#define KRB5_KDB_BADMASTERKEY (-1780008431L) +#define KRB5_KDB_INVALIDKEYSIZE (-1780008430L) +#define KRB5_KDB_CANTREAD_STORED (-1780008429L) +#define KRB5_KDB_BADSTORED_MKEY (-1780008428L) +#define KRB5_KDB_CANTLOCK_DB (-1780008427L) +#define KRB5_KDB_DB_CORRUPT (-1780008426L) +#define KRB5_KDB_BAD_VERSION (-1780008425L) +#define KRB5_KDB_BAD_SALTTYPE (-1780008424L) +#define KRB5_KDB_BAD_ENCTYPE (-1780008423L) +#define KRB5_KDB_BAD_CREATEFLAGS (-1780008422L) +#define KRB5_KDB_NO_PERMITTED_KEY (-1780008421L) +#define KRB5_KDB_NO_MATCHING_KEY (-1780008420L) +/* + * Incremental propagation error codes + */ +#define KRB5_LOG_CONV (-1780008419L) +#define KRB5_LOG_UNSTABLE (-1780008418L) +#define KRB5_LOG_CORRUPT (-1780008417L) +#define KRB5_LOG_ERROR (-1780008416L) +#define KRB5_KDB_DBTYPE_NOTFOUND (-1780008415L) +#define KRB5_KDB_DBTYPE_NOSUP (-1780008414L) +#define KRB5_KDB_DBTYPE_INIT (-1780008413L) +#define KRB5_KDB_SERVER_INTERNAL_ERR (-1780008412L) +#define KRB5_KDB_ACCESS_ERROR (-1780008411L) +#define KRB5_KDB_INTERNAL_ERROR (-1780008410L) +#define KRB5_KDB_CONSTRAINT_VIOLATION (-1780008409L) +#define ERROR_TABLE_BASE_kdb5 (-1780008448L) + +/* for compatibility with older versions... */ +#define kdb5_err_base ERROR_TABLE_BASE_kdb5 +/* + * kv5m_err.h: + * This file is automatically generated; please do not edit it. + */ +#define KV5M_NONE (-1760647424L) +#define KV5M_PRINCIPAL (-1760647423L) +#define KV5M_DATA (-1760647422L) +#define KV5M_KEYBLOCK (-1760647421L) +#define KV5M_CHECKSUM (-1760647420L) +#define KV5M_ENCRYPT_BLOCK (-1760647419L) +#define KV5M_ENC_DATA (-1760647418L) +#define KV5M_CRYPTOSYSTEM_ENTRY (-1760647417L) +#define KV5M_CS_TABLE_ENTRY (-1760647416L) +#define KV5M_CHECKSUM_ENTRY (-1760647415L) +#define KV5M_AUTHDATA (-1760647414L) +#define KV5M_TRANSITED (-1760647413L) +#define KV5M_ENC_TKT_PART (-1760647412L) +#define KV5M_TICKET (-1760647411L) +#define KV5M_AUTHENTICATOR (-1760647410L) +#define KV5M_TKT_AUTHENT (-1760647409L) +#define KV5M_CREDS (-1760647408L) +#define KV5M_LAST_REQ_ENTRY (-1760647407L) +#define KV5M_PA_DATA (-1760647406L) +#define KV5M_KDC_REQ (-1760647405L) +#define KV5M_ENC_KDC_REP_PART (-1760647404L) +#define KV5M_KDC_REP (-1760647403L) +#define KV5M_ERROR (-1760647402L) +#define KV5M_AP_REQ (-1760647401L) +#define KV5M_AP_REP (-1760647400L) +#define KV5M_AP_REP_ENC_PART (-1760647399L) +#define KV5M_RESPONSE (-1760647398L) +#define KV5M_SAFE (-1760647397L) +#define KV5M_PRIV (-1760647396L) +#define KV5M_PRIV_ENC_PART (-1760647395L) +#define KV5M_CRED (-1760647394L) +#define KV5M_CRED_INFO (-1760647393L) +#define KV5M_CRED_ENC_PART (-1760647392L) +#define KV5M_PWD_DATA (-1760647391L) +#define KV5M_ADDRESS (-1760647390L) +#define KV5M_KEYTAB_ENTRY (-1760647389L) +#define KV5M_CONTEXT (-1760647388L) +#define KV5M_OS_CONTEXT (-1760647387L) +#define KV5M_ALT_METHOD (-1760647386L) +#define KV5M_ETYPE_INFO_ENTRY (-1760647385L) +#define KV5M_DB_CONTEXT (-1760647384L) +#define KV5M_AUTH_CONTEXT (-1760647383L) +#define KV5M_KEYTAB (-1760647382L) +#define KV5M_RCACHE (-1760647381L) +#define KV5M_CCACHE (-1760647380L) +#define KV5M_PREAUTH_OPS (-1760647379L) +#define KV5M_SAM_CHALLENGE (-1760647378L) +#define KV5M_SAM_KEY (-1760647377L) +#define KV5M_ENC_SAM_RESPONSE_ENC (-1760647376L) +#define KV5M_ENC_SAM_RESPONSE_ENC_2 (-1760647374L) +#define KV5M_SAM_RESPONSE (-1760647373L) +#define KV5M_SAM_RESPONSE_2 (-1760647372L) +#define KV5M_PREDICTED_SAM_RESPONSE (-1760647371L) +#define KV5M_PASSWD_PHRASE_ELEMENT (-1760647370L) +#define KV5M_GSS_OID (-1760647369L) +#define KV5M_GSS_QUEUE (-1760647368L) +#define ERROR_TABLE_BASE_kv5m (-1760647424L) + +/* for compatibility with older versions... */ +#define kv5m_err_base ERROR_TABLE_BASE_kv5m +/* + * asn1_err.h: + * This file is automatically generated; please do not edit it. + */ +#define ASN1_BAD_TIMEFORMAT (1859794432L) +#define ASN1_MISSING_FIELD (1859794433L) +#define ASN1_MISPLACED_FIELD (1859794434L) +#define ASN1_TYPE_MISMATCH (1859794435L) +#define ASN1_OVERFLOW (1859794436L) +#define ASN1_OVERRUN (1859794437L) +#define ASN1_BAD_ID (1859794438L) +#define ASN1_BAD_LENGTH (1859794439L) +#define ASN1_BAD_FORMAT (1859794440L) +#define ASN1_PARSE_ERROR (1859794441L) +#define ASN1_BAD_GMTIME (1859794442L) +#define ASN1_MISMATCH_INDEF (1859794443L) +#define ASN1_MISSING_EOC (1859794444L) +#define ERROR_TABLE_BASE_asn1 (1859794432L) + +/* for compatibility with older versions... */ +#define asn1_err_base ERROR_TABLE_BASE_asn1 + +#endif /* _KRB5_H */ diff --git a/illumos-x86_64/usr/include/kerberosv5/locate_plugin.h b/illumos-x86_64/usr/include/kerberosv5/locate_plugin.h new file mode 100644 index 00000000..9e8c8ca6 --- /dev/null +++ b/illumos-x86_64/usr/include/kerberosv5/locate_plugin.h @@ -0,0 +1,61 @@ + +/* + * + * + * Copyright 2006 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * + * Service location plugin definitions for Kerberos 5. + */ + +#ifndef KRB5_LOCATE_PLUGIN_H_INCLUDED +#define KRB5_LOCATE_PLUGIN_H_INCLUDED +#include + +enum locate_service_type { + locate_service_kdc = 1, + locate_service_master_kdc, + locate_service_kadmin, + locate_service_krb524, + locate_service_kpasswd +}; + +typedef struct krb5plugin_service_locate_ftable { + int minor_version; /* currently 0 */ + /* Per-context setup and teardown. Returned void* blob is + private to the plugin. */ + krb5_error_code (*init)(krb5_context, void **); + void (*fini)(void *); + /* Callback function returns non-zero if the plugin function + should quit and return; this may be because of an error, or may + indicate we've already contacted the service, whatever. The + lookup function should only return an error if it detects a + problem, not if the callback function tells it to quit. */ + krb5_error_code (*lookup)(void *, + enum locate_service_type svc, const char *realm, + int socktype, int family, + int (*cbfunc)(void *,int,struct sockaddr *), + void *cbdata); +} krb5plugin_service_locate_ftable; +/* extern krb5plugin_service_locate_ftable service_locator; */ +#endif diff --git a/illumos-x86_64/usr/include/kerberosv5/mit-sipb-copyright.h b/illumos-x86_64/usr/include/kerberosv5/mit-sipb-copyright.h new file mode 100644 index 00000000..7e8f39b3 --- /dev/null +++ b/illumos-x86_64/usr/include/kerberosv5/mit-sipb-copyright.h @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _MIT_SIPB_COPYRIGHT_H +#define _MIT_SIPB_COPYRIGHT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * Copyright 1987 by the Student Information Processing Board + * of the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software + * and its documentation for any purpose and without fee is + * hereby granted, provided that the above copyright notice + * appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, + * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be + * used in advertising or publicity pertaining to distribution + * of the software without specific, written prior permission. + * M.I.T. and the M.I.T. S.I.P.B. make no representations about + * the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MIT_SIPB_COPYRIGHT_H */ diff --git a/illumos-x86_64/usr/include/kerberosv5/mit_copyright.h b/illumos-x86_64/usr/include/kerberosv5/mit_copyright.h new file mode 100644 index 00000000..b45d2557 --- /dev/null +++ b/illumos-x86_64/usr/include/kerberosv5/mit_copyright.h @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _MIT_COPYRIGHT_H +#define _MIT_COPYRIGHT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 1996 by the Massachusetts Institute of Technology + */ + +/* + * Copyright 1994 Cygnus Support + * Mark W. Eichin + */ + +/* + * Copyright (c) 1990 Regents of the University of Michigan. + * All Rights Reserved. + */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + */ + +/* + * Copyright 1987, 1998 by the Student Informatiion Processing Board + * of the Massachusetts Institute of Technology + */ + +/* + * Copyright (c) 1993, 1994 C Consortium + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation file (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OF OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the X Consortium shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from the X Consortium. + */ + +/* + * Copyright 1992 Network Computing Devices, Inc. + */ + +/* + * Copyright 1995 by Richard P. Basch. All Rights Reserved. + * Copyright 1995 by Lehman Brotchers, Inc. All Rights Reserved. + */ + +/* + * Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. + * + * License to copy and use this software is granted provided that + * it is identified as the "RSA Data Security, Inc. MD5 Message + * Digest Algorithm" in all material mentioning or referencing this + * software or this function. + * + * License is also granted to make and use derivative works + * provided that such works are identified as "derived from the RSA + * Data Security, Inc. MD4 Message Digest Algorithm" in all + * material mentioning or referencing the derived work. + * + * RSA Data Security, Inc. make no representations concerning + * either the merchantability of this software or the suitability + * of this software for any particular purpose. It is provided "as + * is" without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + * + */ + + + + +#ifdef __cplusplus +} +#endif + + +#endif /* _MIT_COPYRIGHT_H */ diff --git a/illumos-x86_64/usr/include/klpd.h b/illumos-x86_64/usr/include/klpd.h new file mode 100644 index 00000000..a566018a --- /dev/null +++ b/illumos-x86_64/usr/include/klpd.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _KLPD_H +#define _KLPD_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern void *klpd_create(boolean_t (*)(void *, const priv_set_t *, void *), + void *); +extern int klpd_register_id(const priv_set_t *, void *, idtype_t, id_t); +extern int klpd_register(const priv_set_t *, void *); +extern int klpd_unregister_id(void *, idtype_t, id_t); +extern int klpd_unregister(void *); +extern const char *klpd_getpath(void *); +extern int klpd_getport(void *, int *); +extern int klpd_getucred(ucred_t **, void *); + +#ifdef __cplusplus +} +#endif + +#endif /* _KLPD_H */ diff --git a/illumos-x86_64/usr/include/kmfapi.h b/illumos-x86_64/usr/include/kmfapi.h new file mode 100644 index 00000000..dbe09b2d --- /dev/null +++ b/illumos-x86_64/usr/include/kmfapi.h @@ -0,0 +1,364 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018, Joyent, Inc. + * + * Constant definitions and function prototypes for the KMF library. + * Commonly used data types are defined in "kmftypes.h". + */ + +#ifndef _KMFAPI_H +#define _KMFAPI_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Setup operations. + */ +extern KMF_RETURN kmf_initialize(KMF_HANDLE_T *, char *, char *); +extern KMF_RETURN kmf_configure_keystore(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_finalize(KMF_HANDLE_T); + +/* + * Key operations. + */ +extern KMF_RETURN kmf_create_keypair(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_delete_key_from_keystore(KMF_HANDLE_T, int, + KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_find_key(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_find_prikey_by_cert(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_store_key(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_create_sym_key(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_get_sym_key_value(KMF_HANDLE_T, KMF_KEY_HANDLE *, + KMF_RAW_SYM_KEY *); + +/* + * Certificate operations. + */ +extern KMF_RETURN kmf_find_cert(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_encode_cert_record(KMF_X509_CERTIFICATE *, KMF_DATA *); + +extern KMF_RETURN kmf_import_cert(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_store_cert(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_delete_cert_from_keystore(KMF_HANDLE_T, int, + KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_validate_cert(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_create_cert_file(const KMF_DATA *, KMF_ENCODE_FORMAT, + char *); + +extern KMF_RETURN kmf_download_cert(KMF_HANDLE_T, char *, char *, int, + unsigned int, char *, KMF_ENCODE_FORMAT *); + +extern KMF_RETURN kmf_is_cert_data(KMF_DATA *, KMF_ENCODE_FORMAT *); +extern KMF_RETURN kmf_is_cert_file(KMF_HANDLE_T, char *, KMF_ENCODE_FORMAT *); + +extern KMF_RETURN kmf_check_cert_date(KMF_HANDLE_T, const KMF_DATA *); + +/* + * Crypto operations with key or cert. + */ +extern KMF_RETURN kmf_encrypt(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_decrypt(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_sign_cert(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_sign_data(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_verify_cert(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_verify_data(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +/* + * CRL operations. + */ +extern KMF_RETURN kmf_import_crl(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_delete_crl(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_list_crl(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_find_crl(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_find_cert_in_crl(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_verify_crl_file(KMF_HANDLE_T, char *, KMF_DATA *); +extern KMF_RETURN kmf_check_crl_date(KMF_HANDLE_T, char *); +extern KMF_RETURN kmf_download_crl(KMF_HANDLE_T, char *, char *, + int, unsigned int, char *, KMF_ENCODE_FORMAT *); +extern KMF_RETURN kmf_is_crl_file(KMF_HANDLE_T, char *, KMF_ENCODE_FORMAT *); + +/* + * CSR operations. + */ +extern KMF_RETURN kmf_create_csr_file(KMF_DATA *, KMF_ENCODE_FORMAT, char *); +extern KMF_RETURN kmf_set_csr_pubkey(KMF_HANDLE_T, + KMF_KEY_HANDLE *, KMF_CSR_DATA *); +extern KMF_RETURN kmf_set_csr_version(KMF_CSR_DATA *, uint32_t); +extern KMF_RETURN kmf_set_csr_subject(KMF_CSR_DATA *, KMF_X509_NAME *); +extern KMF_RETURN kmf_set_csr_extn(KMF_CSR_DATA *, KMF_X509_EXTENSION *); +extern KMF_RETURN kmf_set_csr_sig_alg(KMF_CSR_DATA *, KMF_ALGORITHM_INDEX); +extern KMF_RETURN kmf_set_csr_subject_altname(KMF_CSR_DATA *, char *, + int, KMF_GENERALNAMECHOICES); +extern KMF_RETURN kmf_set_csr_ku(KMF_CSR_DATA *, int, uint16_t); +extern KMF_RETURN kmf_decode_csr(KMF_HANDLE_T, KMF_DATA *, KMF_CSR_DATA *); +extern KMF_RETURN kmf_verify_csr(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern KMF_RETURN kmf_sign_csr(KMF_HANDLE_T, const KMF_CSR_DATA *, + KMF_KEY_HANDLE *, KMF_DATA *); +extern KMF_RETURN kmf_add_csr_eku(KMF_CSR_DATA *, KMF_OID *, int); + +/* + * GetCert operations. + */ +extern KMF_RETURN kmf_get_cert_extn(const KMF_DATA *, KMF_OID *, + KMF_X509_EXTENSION *); + +extern KMF_RETURN kmf_get_cert_extns(const KMF_DATA *, KMF_FLAG_CERT_EXTN, + KMF_X509_EXTENSION **, int *); + +extern KMF_RETURN kmf_get_cert_ku(const KMF_DATA *, KMF_X509EXT_KEY_USAGE *); + +extern KMF_RETURN kmf_get_cert_eku(const KMF_DATA *, KMF_X509EXT_EKU *); + +extern KMF_RETURN kmf_get_cert_basic_constraint(const KMF_DATA *, + KMF_BOOL *, KMF_X509EXT_BASICCONSTRAINTS *); + +extern KMF_RETURN kmf_get_cert_policies(const KMF_DATA *, + KMF_BOOL *, KMF_X509EXT_CERT_POLICIES *); + +extern KMF_RETURN kmf_get_cert_auth_info_access(const KMF_DATA *, + KMF_X509EXT_AUTHINFOACCESS *); + +extern KMF_RETURN kmf_get_cert_crl_dist_pts(const KMF_DATA *, + KMF_X509EXT_CRLDISTPOINTS *); + +extern KMF_RETURN kmf_get_cert_version_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_subject_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_issuer_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_serial_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_start_date_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_end_date_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_pubkey_alg_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_sig_alg_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_pubkey_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_email_str(KMF_HANDLE_T, const KMF_DATA *, + char **); + +extern KMF_RETURN kmf_get_cert_extn_str(KMF_HANDLE_T, const KMF_DATA *, + KMF_PRINTABLE_ITEM, char **); + +extern KMF_RETURN kmf_get_cert_id_data(const KMF_DATA *, KMF_DATA *); + +extern KMF_RETURN kmf_get_cert_id_str(const KMF_DATA *, char **); + +extern KMF_RETURN kmf_get_cert_validity(const KMF_DATA *, time_t *, time_t *); + + +/* + * SetCert operations + */ +extern KMF_RETURN kmf_set_cert_pubkey(KMF_HANDLE_T, KMF_KEY_HANDLE *, + KMF_X509_CERTIFICATE *); + +extern KMF_RETURN kmf_set_cert_subject(KMF_X509_CERTIFICATE *, + KMF_X509_NAME *); + +extern KMF_RETURN kmf_set_cert_ku(KMF_X509_CERTIFICATE *, int, uint16_t); + +extern KMF_RETURN kmf_set_cert_issuer(KMF_X509_CERTIFICATE *, + KMF_X509_NAME *); + +extern KMF_RETURN kmf_set_cert_sig_alg(KMF_X509_CERTIFICATE *, + KMF_ALGORITHM_INDEX); + +extern KMF_RETURN kmf_set_cert_validity(KMF_X509_CERTIFICATE *, + time_t, uint32_t); + +extern KMF_RETURN kmf_set_cert_serial(KMF_X509_CERTIFICATE *, + KMF_BIGINT *); + +extern KMF_RETURN kmf_set_cert_version(KMF_X509_CERTIFICATE *, uint32_t); + +extern KMF_RETURN kmf_set_cert_issuer_altname(KMF_X509_CERTIFICATE *, + int, KMF_GENERALNAMECHOICES, char *); + +extern KMF_RETURN kmf_set_cert_subject_altname(KMF_X509_CERTIFICATE *, + int, KMF_GENERALNAMECHOICES, char *); + +extern KMF_RETURN kmf_add_cert_eku(KMF_X509_CERTIFICATE *, KMF_OID *, int); + +extern KMF_RETURN kmf_set_cert_extn(KMF_X509_CERTIFICATE *, + KMF_X509_EXTENSION *); + +extern KMF_RETURN kmf_set_cert_basic_constraint(KMF_X509_CERTIFICATE *, + KMF_BOOL, KMF_X509EXT_BASICCONSTRAINTS *); + + +/* + * PK12 operations + */ +extern KMF_RETURN kmf_export_pk12(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_build_pk12(KMF_HANDLE_T, int, KMF_X509_DER_CERT *, + int, KMF_KEY_HANDLE *, KMF_CREDENTIAL *, char *); + +extern KMF_RETURN kmf_import_objects(KMF_HANDLE_T, char *, KMF_CREDENTIAL *, + KMF_X509_DER_CERT **, int *, KMF_RAW_KEY_DATA **, int *); + +/* + * OCSP operations + */ +extern KMF_RETURN kmf_get_ocsp_for_cert(KMF_HANDLE_T, KMF_DATA *, KMF_DATA *, + KMF_DATA *); + +extern KMF_RETURN kmf_create_ocsp_request(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); + +extern KMF_RETURN kmf_get_encoded_ocsp_response(KMF_HANDLE_T, char *, + char *, int, char *, int, char *, unsigned int); + +extern KMF_RETURN kmf_get_ocsp_status_for_cert(KMF_HANDLE_T, int, + KMF_ATTRIBUTE *); + +/* + * Policy Operations + */ +extern KMF_RETURN kmf_set_policy(KMF_HANDLE_T, char *, char *); + +/* + * Error handling. + */ +extern KMF_RETURN kmf_get_plugin_error_str(KMF_HANDLE_T, char **); +extern KMF_RETURN kmf_get_kmf_error_str(KMF_RETURN, char **); + +/* + * Miscellaneous + */ +extern KMF_RETURN kmf_dn_parser(char *, KMF_X509_NAME *); +extern KMF_RETURN kmf_dn_to_string(KMF_X509_NAME *, char **); +extern KMF_RETURN kmf_read_input_file(KMF_HANDLE_T, char *, KMF_DATA *); +extern KMF_RETURN kmf_der_to_pem(KMF_OBJECT_TYPE, unsigned char *, + int, unsigned char **, int *); +extern KMF_RETURN kmf_pem_to_der(unsigned char *, int, unsigned char **, int *); +extern char *kmf_oid_to_string(KMF_OID *); +extern KMF_RETURN kmf_string_to_oid(char *, KMF_OID *); +extern int kmf_compare_rdns(KMF_X509_NAME *, KMF_X509_NAME *); +extern KMF_RETURN kmf_get_data_format(KMF_DATA *, KMF_ENCODE_FORMAT *); +extern KMF_RETURN kmf_get_file_format(char *, KMF_ENCODE_FORMAT *); +extern uint32_t kmf_string_to_ku(char *); +extern char *kmf_ku_to_string(uint32_t); +extern KMF_RETURN kmf_hexstr_to_bytes(unsigned char *, unsigned char **, + size_t *); + +extern KMF_RETURN kmf_get_plugin_info(KMF_HANDLE_T, char *, + KMF_KEYSTORE_TYPE *, char **); + +extern KMF_OID *kmf_ekuname_to_oid(char *); +extern char *kmf_oid_to_ekuname(KMF_OID *); + +#define KMF_CompareRDNs kmf_compare_rdns + +/* + * Memory cleanup operations + */ +extern void kmf_free_dn(KMF_X509_NAME *); +extern void kmf_free_kmf_cert(KMF_HANDLE_T, KMF_X509_DER_CERT *); +extern void kmf_free_data(KMF_DATA *); +extern void kmf_free_algoid(KMF_X509_ALGORITHM_IDENTIFIER *); +extern void kmf_free_extn(KMF_X509_EXTENSION *); +extern void kmf_free_tbs_csr(KMF_TBS_CSR *); +extern void kmf_free_signed_csr(KMF_CSR_DATA *); +extern void kmf_free_tbs_cert(KMF_X509_TBS_CERT *); +extern void kmf_free_signed_cert(KMF_X509_CERTIFICATE *); +extern void kmf_free_str(char *); +extern void kmf_free_eku(KMF_X509EXT_EKU *); +extern void kmf_free_spki(KMF_X509_SPKI *); +extern void kmf_free_kmf_key(KMF_HANDLE_T, KMF_KEY_HANDLE *); +extern void kmf_free_bigint(KMF_BIGINT *); +extern void kmf_free_raw_key(KMF_RAW_KEY_DATA *); +extern void kmf_free_raw_sym_key(KMF_RAW_SYM_KEY *); +extern void kmf_free_crl_dist_pts(KMF_X509EXT_CRLDISTPOINTS *); + +/* APIs for PKCS#11 token */ +extern KMF_RETURN kmf_pk11_token_lookup(KMF_HANDLE_T, char *, CK_SLOT_ID *); +extern KMF_RETURN kmf_pk11_init_token(KMF_HANDLE_T, + char *, char *, CK_UTF8CHAR_PTR, CK_ULONG); +extern KMF_RETURN kmf_set_token_pin(KMF_HANDLE_T, int, KMF_ATTRIBUTE *); +extern CK_SESSION_HANDLE kmf_get_pk11_handle(KMF_HANDLE_T); + +/* + * Attribute management routines. + */ +int kmf_find_attr(KMF_ATTR_TYPE, KMF_ATTRIBUTE *, int); +void *kmf_get_attr_ptr(KMF_ATTR_TYPE, KMF_ATTRIBUTE *, int); +KMF_RETURN kmf_get_attr(KMF_ATTR_TYPE, KMF_ATTRIBUTE *, int, void *, + uint32_t *); +KMF_RETURN kmf_get_string_attr(KMF_ATTR_TYPE, KMF_ATTRIBUTE *, int, char **); +KMF_RETURN kmf_set_attr(KMF_ATTRIBUTE *, int, KMF_ATTR_TYPE, void *, uint32_t); +void kmf_set_attr_at_index(KMF_ATTRIBUTE *, int, KMF_ATTR_TYPE, + void *, uint32_t); + +/* + * Certificate to name mapping functions. + */ +KMF_RETURN kmf_cert_to_name_mapping_initialize(KMF_HANDLE_T, int, + KMF_ATTRIBUTE *); +KMF_RETURN kmf_cert_to_name_mapping_finalize(KMF_HANDLE_T); +KMF_RETURN kmf_map_cert_to_name(KMF_HANDLE_T, KMF_DATA *, KMF_DATA *); +KMF_RETURN kmf_match_cert_to_name(KMF_HANDLE_T, KMF_DATA *, KMF_DATA *, + KMF_DATA *); +KMF_RETURN kmf_get_mapper_error_str(KMF_HANDLE_T, char **); +/* + * Helper functions for handling the mapper internal state. They are part of the + * public interface, too. + */ +void kmf_set_mapper_lasterror(KMF_HANDLE_T, uint32_t); +uint32_t kmf_get_mapper_lasterror(KMF_HANDLE_T); +void kmf_set_mapper_options(KMF_HANDLE_T, void *); +void *kmf_get_mapper_options(KMF_HANDLE_T); + +#ifdef __cplusplus +} +#endif +#endif /* _KMFAPI_H */ diff --git a/illumos-x86_64/usr/include/kmftypes.h b/illumos-x86_64/usr/include/kmftypes.h new file mode 100644 index 00000000..e881633e --- /dev/null +++ b/illumos-x86_64/usr/include/kmftypes.h @@ -0,0 +1,1308 @@ +/* + * Copyright (c) 1995-2000 Intel Corporation. All rights reserved. + */ +/* + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _KMFTYPES_H +#define _KMFTYPES_H + +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint32_t KMF_BOOL; + +#define KMF_FALSE (0) +#define KMF_TRUE (1) + +/* KMF_HANDLE_T is a pointer to an incomplete C struct for type safety. */ +typedef struct _kmf_handle *KMF_HANDLE_T; + +/* + * KMF_DATA + * The KMF_DATA structure is used to associate a length, in bytes, with + * an arbitrary block of contiguous memory. + */ +typedef struct kmf_data +{ + size_t Length; /* in bytes */ + uchar_t *Data; +} KMF_DATA; + +typedef struct { + uchar_t *val; + size_t len; +} KMF_BIGINT; + +/* + * KMF_OID + * The object identifier (OID) structure is used to hold a unique identifier for + * the atomic data fields and the compound substructure that comprise the fields + * of a certificate or CRL. + */ +typedef KMF_DATA KMF_OID; + +typedef struct kmf_x509_private { + int keystore_type; + int flags; /* see below */ + char *label; +#define KMF_FLAG_CERT_VALID 1 /* contains valid certificate */ +#define KMF_FLAG_CERT_SIGNED 2 /* this is a signed certificate */ +} KMF_X509_PRIVATE; + +/* + * KMF_X509_DER_CERT + * This structure associates packed DER certificate data. + * Also, it contains the private information internal used + * by KMF layer. + */ +typedef struct +{ + KMF_DATA certificate; + KMF_X509_PRIVATE kmf_private; +} KMF_X509_DER_CERT; + +typedef int KMF_KEYSTORE_TYPE; +#define KMF_KEYSTORE_NSS 1 +#define KMF_KEYSTORE_OPENSSL 2 +#define KMF_KEYSTORE_PK11TOKEN 3 + +#define VALID_DEFAULT_KEYSTORE_TYPE(t) ((t >= KMF_KEYSTORE_NSS) &&\ + (t <= KMF_KEYSTORE_PK11TOKEN)) + +typedef enum { + KMF_FORMAT_UNDEF = 0, + KMF_FORMAT_ASN1 = 1, /* DER */ + KMF_FORMAT_PEM = 2, + KMF_FORMAT_PKCS12 = 3, + KMF_FORMAT_RAWKEY = 4, /* For FindKey operation */ + KMF_FORMAT_PEM_KEYPAIR = 5 +} KMF_ENCODE_FORMAT; + +#define KMF_FORMAT_NATIVE KMF_FORMAT_UNDEF + +typedef enum { + KMF_ALL_CERTS = 0, + KMF_NONEXPIRED_CERTS = 1, + KMF_EXPIRED_CERTS = 2 +} KMF_CERT_VALIDITY; + + +typedef enum { + KMF_ALL_EXTNS = 0, + KMF_CRITICAL_EXTNS = 1, + KMF_NONCRITICAL_EXTNS = 2 +} KMF_FLAG_CERT_EXTN; + + +typedef enum { + KMF_KU_SIGN_CERT = 0, + KMF_KU_SIGN_DATA = 1, + KMF_KU_ENCRYPT_DATA = 2 +} KMF_KU_PURPOSE; + +/* + * Algorithms + * This type defines a set of constants used to identify cryptographic + * algorithms. + * + * When adding new ALGID, be careful not to rearrange existing + * values, doing so can cause problem in the STC test suite. + */ +typedef enum { + KMF_ALGID_NONE = 0, + KMF_ALGID_CUSTOM, + KMF_ALGID_SHA1, + KMF_ALGID_RSA, + KMF_ALGID_DSA, + KMF_ALGID_MD5WithRSA, + KMF_ALGID_MD2WithRSA, + KMF_ALGID_SHA1WithRSA, + KMF_ALGID_SHA1WithDSA, + + KMF_ALGID_ECDSA, + + KMF_ALGID_SHA256WithRSA, + KMF_ALGID_SHA384WithRSA, + KMF_ALGID_SHA512WithRSA, + + KMF_ALGID_SHA256WithDSA, + + KMF_ALGID_SHA1WithECDSA, + KMF_ALGID_SHA256WithECDSA, + KMF_ALGID_SHA384WithECDSA, + KMF_ALGID_SHA512WithECDSA +} KMF_ALGORITHM_INDEX; + +/* + * Generic credential structure used by other structures below + * to convey authentication information to the underlying + * mechanisms. + */ +typedef struct { + char *cred; + uint32_t credlen; +} KMF_CREDENTIAL; + +typedef enum { + KMF_KEYALG_NONE = 0, + KMF_RSA = 1, + KMF_DSA = 2, + KMF_AES = 3, + KMF_RC4 = 4, + KMF_DES = 5, + KMF_DES3 = 6, + KMF_GENERIC_SECRET = 7, + KMF_ECDSA = 8 +}KMF_KEY_ALG; + +typedef enum { + KMF_KEYCLASS_NONE = 0, + KMF_ASYM_PUB = 1, /* public key of an asymmetric keypair */ + KMF_ASYM_PRI = 2, /* private key of an asymmetric keypair */ + KMF_SYMMETRIC = 3 /* symmetric key */ +}KMF_KEY_CLASS; + +typedef enum { + KMF_CERT = 0, + KMF_CSR = 1, + KMF_CRL = 2 +}KMF_OBJECT_TYPE; + +typedef struct { + KMF_BIGINT mod; + KMF_BIGINT pubexp; + KMF_BIGINT priexp; + KMF_BIGINT prime1; + KMF_BIGINT prime2; + KMF_BIGINT exp1; + KMF_BIGINT exp2; + KMF_BIGINT coef; +} KMF_RAW_RSA_KEY; + +typedef struct { + KMF_BIGINT prime; + KMF_BIGINT subprime; + KMF_BIGINT base; + KMF_BIGINT value; + KMF_BIGINT pubvalue; +} KMF_RAW_DSA_KEY; + +typedef struct { + KMF_BIGINT keydata; +} KMF_RAW_SYM_KEY; + +typedef struct { + KMF_BIGINT value; + KMF_OID params; +} KMF_RAW_EC_KEY; + +typedef struct { + KMF_KEY_ALG keytype; + boolean_t sensitive; + boolean_t not_extractable; + union { + KMF_RAW_RSA_KEY rsa; + KMF_RAW_DSA_KEY dsa; + KMF_RAW_SYM_KEY sym; + KMF_RAW_EC_KEY ec; + }rawdata; + char *label; + KMF_DATA id; +} KMF_RAW_KEY_DATA; + +typedef struct { + KMF_KEYSTORE_TYPE kstype; + KMF_KEY_ALG keyalg; + KMF_KEY_CLASS keyclass; + boolean_t israw; + char *keylabel; + void *keyp; +} KMF_KEY_HANDLE; + +typedef struct { + KMF_KEYSTORE_TYPE kstype; + uint32_t errcode; +} KMF_ERROR; + +/* + * Typenames to use with subjectAltName + */ +typedef enum { + GENNAME_OTHERNAME = 0x00, + GENNAME_RFC822NAME, + GENNAME_DNSNAME, + GENNAME_X400ADDRESS, + GENNAME_DIRECTORYNAME, + GENNAME_EDIPARTYNAME, + GENNAME_URI, + GENNAME_IPADDRESS, + GENNAME_REGISTEREDID, + GENNAME_KRB5PRINC, + GENNAME_SCLOGON_UPN +} KMF_GENERALNAMECHOICES; + +/* + * KMF_FIELD + * This structure contains the OID/value pair for any item that can be + * identified by an OID. + */ +typedef struct +{ + KMF_OID FieldOid; + KMF_DATA FieldValue; +} KMF_FIELD; + +typedef enum { + KMF_OK = 0x00, + KMF_ERR_BAD_PARAMETER = 0x01, + KMF_ERR_BAD_KEY_FORMAT = 0x02, + KMF_ERR_BAD_ALGORITHM = 0x03, + KMF_ERR_MEMORY = 0x04, + KMF_ERR_ENCODING = 0x05, + KMF_ERR_PLUGIN_INIT = 0x06, + KMF_ERR_PLUGIN_NOTFOUND = 0x07, + KMF_ERR_INTERNAL = 0x0b, + KMF_ERR_BAD_CERT_FORMAT = 0x0c, + KMF_ERR_KEYGEN_FAILED = 0x0d, + KMF_ERR_UNINITIALIZED = 0x10, + KMF_ERR_ISSUER = 0x11, + KMF_ERR_NOT_REVOKED = 0x12, + KMF_ERR_CERT_NOT_FOUND = 0x13, + KMF_ERR_CRL_NOT_FOUND = 0x14, + KMF_ERR_RDN_PARSER = 0x15, + KMF_ERR_RDN_ATTR = 0x16, + KMF_ERR_SLOTNAME = 0x17, + KMF_ERR_EMPTY_CRL = 0x18, + KMF_ERR_BUFFER_SIZE = 0x19, + KMF_ERR_AUTH_FAILED = 0x1a, + KMF_ERR_TOKEN_SELECTED = 0x1b, + KMF_ERR_NO_TOKEN_SELECTED = 0x1c, + KMF_ERR_TOKEN_NOT_PRESENT = 0x1d, + KMF_ERR_EXTENSION_NOT_FOUND = 0x1e, + KMF_ERR_POLICY_ENGINE = 0x1f, + KMF_ERR_POLICY_DB_FORMAT = 0x20, + KMF_ERR_POLICY_NOT_FOUND = 0x21, + KMF_ERR_POLICY_DB_FILE = 0x22, + KMF_ERR_POLICY_NAME = 0x23, + KMF_ERR_OCSP_POLICY = 0x24, + KMF_ERR_TA_POLICY = 0x25, + KMF_ERR_KEY_NOT_FOUND = 0x26, + KMF_ERR_OPEN_FILE = 0x27, + KMF_ERR_OCSP_BAD_ISSUER = 0x28, + KMF_ERR_OCSP_BAD_CERT = 0x29, + KMF_ERR_OCSP_CREATE_REQUEST = 0x2a, + KMF_ERR_CONNECT_SERVER = 0x2b, + KMF_ERR_SEND_REQUEST = 0x2c, + KMF_ERR_OCSP_CERTID = 0x2d, + KMF_ERR_OCSP_MALFORMED_RESPONSE = 0x2e, + KMF_ERR_OCSP_RESPONSE_STATUS = 0x2f, + KMF_ERR_OCSP_NO_BASIC_RESPONSE = 0x30, + KMF_ERR_OCSP_BAD_SIGNER = 0x31, + + KMF_ERR_OCSP_RESPONSE_SIGNATURE = 0x32, + KMF_ERR_OCSP_UNKNOWN_CERT = 0x33, + KMF_ERR_OCSP_STATUS_TIME_INVALID = 0x34, + KMF_ERR_BAD_HTTP_RESPONSE = 0x35, + KMF_ERR_RECV_RESPONSE = 0x36, + KMF_ERR_RECV_TIMEOUT = 0x37, + KMF_ERR_DUPLICATE_KEYFILE = 0x38, + KMF_ERR_AMBIGUOUS_PATHNAME = 0x39, + KMF_ERR_FUNCTION_NOT_FOUND = 0x3a, + KMF_ERR_PKCS12_FORMAT = 0x3b, + KMF_ERR_BAD_KEY_TYPE = 0x3c, + KMF_ERR_BAD_KEY_CLASS = 0x3d, + KMF_ERR_BAD_KEY_SIZE = 0x3e, + KMF_ERR_BAD_HEX_STRING = 0x3f, + KMF_ERR_KEYUSAGE = 0x40, + KMF_ERR_VALIDITY_PERIOD = 0x41, + KMF_ERR_OCSP_REVOKED = 0x42, + KMF_ERR_CERT_MULTIPLE_FOUND = 0x43, + KMF_ERR_WRITE_FILE = 0x44, + KMF_ERR_BAD_URI = 0x45, + KMF_ERR_BAD_CRLFILE = 0x46, + KMF_ERR_BAD_CERTFILE = 0x47, + KMF_ERR_GETKEYVALUE_FAILED = 0x48, + KMF_ERR_BAD_KEYHANDLE = 0x49, + KMF_ERR_BAD_OBJECT_TYPE = 0x4a, + KMF_ERR_OCSP_RESPONSE_LIFETIME = 0x4b, + KMF_ERR_UNKNOWN_CSR_ATTRIBUTE = 0x4c, + KMF_ERR_UNINITIALIZED_TOKEN = 0x4d, + KMF_ERR_INCOMPLETE_TBS_CERT = 0x4e, + KMF_ERR_MISSING_ERRCODE = 0x4f, + KMF_KEYSTORE_ALREADY_INITIALIZED = 0x50, + KMF_ERR_SENSITIVE_KEY = 0x51, + KMF_ERR_UNEXTRACTABLE_KEY = 0x52, + KMF_ERR_KEY_MISMATCH = 0x53, + KMF_ERR_ATTR_NOT_FOUND = 0x54, + KMF_ERR_KMF_CONF = 0x55, + KMF_ERR_NAME_NOT_MATCHED = 0x56, + KMF_ERR_MAPPER_OPEN = 0x57, + KMF_ERR_MAPPER_NOT_FOUND = 0x58, + KMF_ERR_MAPPING_FAILED = 0x59, + KMF_ERR_CERT_VALIDATION = 0x60 +} KMF_RETURN; + +/* Data structures for OCSP support */ +typedef enum { + OCSP_GOOD = 0, + OCSP_REVOKED = 1, + OCSP_UNKNOWN = 2 +} KMF_OCSP_CERT_STATUS; + +typedef enum { + OCSP_SUCCESS = 0, + OCSP_MALFORMED_REQUEST = 1, + OCSP_INTERNAL_ERROR = 2, + OCSP_TRYLATER = 3, + OCSP_SIGREQUIRED = 4, + OCSP_UNAUTHORIZED = 5 +} KMF_OCSP_RESPONSE_STATUS; + +typedef enum { + OCSP_NOSTATUS = -1, + OCSP_UNSPECIFIED = 0, + OCSP_KEYCOMPROMISE = 1, + OCSP_CACOMPROMISE = 2, + OCSP_AFFILIATIONCHANGE = 3, + OCSP_SUPERCEDED = 4, + OCSP_CESSATIONOFOPERATION = 5, + OCSP_CERTIFICATEHOLD = 6, + OCSP_REMOVEFROMCRL = 7 +} KMF_OCSP_REVOKED_STATUS; + +typedef enum { + KMF_CERT_ISSUER = 1, + KMF_CERT_SUBJECT, + KMF_CERT_VERSION, + KMF_CERT_SERIALNUM, + KMF_CERT_NOTBEFORE, + KMF_CERT_NOTAFTER, + KMF_CERT_PUBKEY_ALG, + KMF_CERT_SIGNATURE_ALG, + KMF_CERT_EMAIL, + KMF_CERT_PUBKEY_DATA, + KMF_X509_EXT_PRIV_KEY_USAGE_PERIOD, + KMF_X509_EXT_CERT_POLICIES, + KMF_X509_EXT_SUBJ_ALTNAME, + KMF_X509_EXT_ISSUER_ALTNAME, + KMF_X509_EXT_BASIC_CONSTRAINTS, + KMF_X509_EXT_NAME_CONSTRAINTS, + KMF_X509_EXT_POLICY_CONSTRAINTS, + KMF_X509_EXT_EXT_KEY_USAGE, + KMF_X509_EXT_INHIBIT_ANY_POLICY, + KMF_X509_EXT_AUTH_KEY_ID, + KMF_X509_EXT_SUBJ_KEY_ID, + KMF_X509_EXT_POLICY_MAPPINGS, + KMF_X509_EXT_CRL_DIST_POINTS, + KMF_X509_EXT_FRESHEST_CRL, + KMF_X509_EXT_KEY_USAGE +} KMF_PRINTABLE_ITEM; + +/* + * KMF_X509_ALGORITHM_IDENTIFIER + * This structure holds an object identifier naming a + * cryptographic algorithm and an optional set of + * parameters to be used as input to that algorithm. + */ +typedef struct +{ + KMF_OID algorithm; + KMF_DATA parameters; +} KMF_X509_ALGORITHM_IDENTIFIER; + +/* + * KMF_X509_TYPE_VALUE_PAIR + * This structure contain an type-value pair. + */ +typedef struct +{ + KMF_OID type; + uint8_t valueType; /* The Tag to use when BER encoded */ + KMF_DATA value; +} KMF_X509_TYPE_VALUE_PAIR; + + +/* + * KMF_X509_RDN + * This structure contains a Relative Distinguished Name + * composed of an ordered set of type-value pairs. + */ +typedef struct +{ + uint32_t numberOfPairs; + KMF_X509_TYPE_VALUE_PAIR *AttributeTypeAndValue; +} KMF_X509_RDN; + +/* + * KMF_X509_NAME + * This structure contains a set of Relative Distinguished Names. + */ +typedef struct +{ + uint32_t numberOfRDNs; + KMF_X509_RDN *RelativeDistinguishedName; +} KMF_X509_NAME; + +/* + * KMF_X509_SPKI + * This structure contains the public key and the + * description of the verification algorithm + * appropriate for use with this key. + */ +typedef struct +{ + KMF_X509_ALGORITHM_IDENTIFIER algorithm; + KMF_DATA subjectPublicKey; +} KMF_X509_SPKI; + +/* + * KMF_X509_TIME + * Time is represented as a string according to the + * definitions of GeneralizedTime and UTCTime + * defined in RFC 2459. + */ +typedef struct +{ + uint8_t timeType; + KMF_DATA time; +} KMF_X509_TIME; + +/* + * KMF_X509_VALIDITY + */ +typedef struct +{ + KMF_X509_TIME notBefore; + KMF_X509_TIME notAfter; +} KMF_X509_VALIDITY; + +/* + * KMF_X509EXT_BASICCONSTRAINTS + */ +typedef struct +{ + KMF_BOOL cA; + KMF_BOOL pathLenConstraintPresent; + uint32_t pathLenConstraint; +} KMF_X509EXT_BASICCONSTRAINTS; + +/* + * KMF_X509EXT_DATA_FORMAT + * This list defines the valid formats for a certificate extension. + */ +typedef enum +{ + KMF_X509_DATAFORMAT_ENCODED = 0, + KMF_X509_DATAFORMAT_PARSED, + KMF_X509_DATAFORMAT_PAIR +} KMF_X509EXT_DATA_FORMAT; + + +/* + * KMF_X509EXT_TAGandVALUE + * This structure contains a BER/DER encoded + * extension value and the type of that value. + */ +typedef struct +{ + uint8_t type; + KMF_DATA value; +} KMF_X509EXT_TAGandVALUE; + + +/* + * KMF_X509EXT_PAIR + * This structure aggregates two extension representations: + * a tag and value, and a parsed X509 extension representation. + */ +typedef struct +{ + KMF_X509EXT_TAGandVALUE tagAndValue; + void *parsedValue; +} KMF_X509EXT_PAIR; + +/* + * KMF_X509_EXTENSION + * This structure contains a complete certificate extension. + */ +typedef struct +{ + KMF_OID extnId; + KMF_BOOL critical; + KMF_X509EXT_DATA_FORMAT format; + union + { + KMF_X509EXT_TAGandVALUE *tagAndValue; + void *parsedValue; + KMF_X509EXT_PAIR *valuePair; + } value; + KMF_DATA BERvalue; +} KMF_X509_EXTENSION; + + +/* + * KMF_X509_EXTENSIONS + * This structure contains the set of all certificate + * extensions contained in a certificate. + */ +typedef struct +{ + uint32_t numberOfExtensions; + KMF_X509_EXTENSION *extensions; +} KMF_X509_EXTENSIONS; + +/* + * KMF_X509_TBS_CERT + * This structure contains a complete X.509 certificate. + */ +typedef struct +{ + KMF_DATA version; + KMF_BIGINT serialNumber; + KMF_X509_ALGORITHM_IDENTIFIER signature; + KMF_X509_NAME issuer; + KMF_X509_VALIDITY validity; + KMF_X509_NAME subject; + KMF_X509_SPKI subjectPublicKeyInfo; + KMF_DATA issuerUniqueIdentifier; + KMF_DATA subjectUniqueIdentifier; + KMF_X509_EXTENSIONS extensions; +} KMF_X509_TBS_CERT; + +/* + * KMF_X509_SIGNATURE + * This structure contains a cryptographic digital signature. + */ +typedef struct +{ + KMF_X509_ALGORITHM_IDENTIFIER algorithmIdentifier; + KMF_DATA encrypted; +} KMF_X509_SIGNATURE; + +/* + * KMF_X509_CERTIFICATE + * This structure associates a set of decoded certificate + * values with the signature covering those values. + */ +typedef struct +{ + KMF_X509_TBS_CERT certificate; + KMF_X509_SIGNATURE signature; +} KMF_X509_CERTIFICATE; + +#define CERT_ALG_OID(c) &c->certificate.signature.algorithm +#define CERT_SIG_OID(c) &c->signature.algorithmIdentifier.algorithm + +/* + * KMF_TBS_CSR + * This structure contains a complete PKCS#10 certificate request + */ +typedef struct +{ + KMF_DATA version; + KMF_X509_NAME subject; + KMF_X509_SPKI subjectPublicKeyInfo; + KMF_X509_EXTENSIONS extensions; +} KMF_TBS_CSR; + +/* + * KMF_CSR_DATA + * This structure contains a complete PKCS#10 certificate signed request + */ +typedef struct +{ + KMF_TBS_CSR csr; + KMF_X509_SIGNATURE signature; +} KMF_CSR_DATA; + +/* + * KMF_X509EXT_POLICYQUALIFIERINFO + */ +typedef struct +{ + KMF_OID policyQualifierId; + KMF_DATA value; +} KMF_X509EXT_POLICYQUALIFIERINFO; + +/* + * KMF_X509EXT_POLICYQUALIFIERS + */ +typedef struct +{ + uint32_t numberOfPolicyQualifiers; + KMF_X509EXT_POLICYQUALIFIERINFO *policyQualifier; +} KMF_X509EXT_POLICYQUALIFIERS; + +/* + * KMF_X509EXT_POLICYINFO + */ +typedef struct +{ + KMF_OID policyIdentifier; + KMF_X509EXT_POLICYQUALIFIERS policyQualifiers; +} KMF_X509EXT_POLICYINFO; + +typedef struct +{ + uint32_t numberOfPolicyInfo; + KMF_X509EXT_POLICYINFO *policyInfo; +} KMF_X509EXT_CERT_POLICIES; + +typedef struct +{ + uchar_t critical; + uint16_t KeyUsageBits; +} KMF_X509EXT_KEY_USAGE; + +typedef struct +{ + uchar_t critical; + uint16_t nEKUs; + KMF_OID *keyPurposeIdList; +} KMF_X509EXT_EKU; + + +/* + * X509 AuthorityInfoAccess extension + */ +typedef struct +{ + KMF_OID AccessMethod; + KMF_DATA AccessLocation; +} KMF_X509EXT_ACCESSDESC; + +typedef struct +{ + uint32_t numberOfAccessDescription; + KMF_X509EXT_ACCESSDESC *AccessDesc; +} KMF_X509EXT_AUTHINFOACCESS; + + +/* + * X509 Crl Distribution Point extension + */ +typedef struct { + KMF_GENERALNAMECHOICES choice; + KMF_DATA name; +} KMF_GENERALNAME; + +typedef struct { + uint32_t number; + KMF_GENERALNAME *namelist; +} KMF_GENERALNAMES; + +typedef enum { + DP_GENERAL_NAME = 1, + DP_RELATIVE_NAME = 2 +} KMF_CRL_DIST_POINT_TYPE; + +typedef struct { + KMF_CRL_DIST_POINT_TYPE type; + union { + KMF_GENERALNAMES full_name; + KMF_DATA relative_name; + } name; + KMF_DATA reasons; + KMF_GENERALNAMES crl_issuer; +} KMF_CRL_DIST_POINT; + +typedef struct { + uint32_t number; + KMF_CRL_DIST_POINT *dplist; +} KMF_X509EXT_CRLDISTPOINTS; + +typedef enum { + KMF_DATA_ATTR, + KMF_OID_ATTR, + KMF_BIGINT_ATTR, + KMF_X509_DER_CERT_ATTR, + KMF_KEYSTORE_TYPE_ATTR, + KMF_ENCODE_FORMAT_ATTR, + KMF_CERT_VALIDITY_ATTR, + KMF_KU_PURPOSE_ATTR, + KMF_ALGORITHM_INDEX_ATTR, + KMF_TOKEN_LABEL_ATTR, + KMF_READONLY_ATTR, + KMF_DIRPATH_ATTR, + KMF_CERTPREFIX_ATTR, + KMF_KEYPREFIX_ATTR, + KMF_SECMODNAME_ATTR, + KMF_CREDENTIAL_ATTR, + KMF_TRUSTFLAG_ATTR, + KMF_CRL_FILENAME_ATTR, + KMF_CRL_CHECK_ATTR, + KMF_CRL_DATA_ATTR, + KMF_CRL_SUBJECT_ATTR, + KMF_CRL_ISSUER_ATTR, + KMF_CRL_NAMELIST_ATTR, + KMF_CRL_COUNT_ATTR, + KMF_CRL_OUTFILE_ATTR, + KMF_CERT_LABEL_ATTR, + KMF_SUBJECT_NAME_ATTR, + KMF_ISSUER_NAME_ATTR, + KMF_CERT_FILENAME_ATTR, + KMF_KEY_FILENAME_ATTR, + KMF_OUTPUT_FILENAME_ATTR, + KMF_IDSTR_ATTR, + KMF_CERT_DATA_ATTR, + KMF_OCSP_RESPONSE_DATA_ATTR, + KMF_OCSP_RESPONSE_STATUS_ATTR, + KMF_OCSP_RESPONSE_REASON_ATTR, + KMF_OCSP_RESPONSE_CERT_STATUS_ATTR, + KMF_OCSP_REQUEST_FILENAME_ATTR, + KMF_KEYALG_ATTR, + KMF_KEYCLASS_ATTR, + KMF_KEYLABEL_ATTR, + KMF_KEYLENGTH_ATTR, + KMF_RSAEXP_ATTR, + KMF_TACERT_DATA_ATTR, + KMF_SLOT_ID_ATTR, + KMF_PK12CRED_ATTR, + KMF_ISSUER_CERT_DATA_ATTR, + KMF_USER_CERT_DATA_ATTR, + KMF_SIGNER_CERT_DATA_ATTR, + KMF_IGNORE_RESPONSE_SIGN_ATTR, + KMF_RESPONSE_LIFETIME_ATTR, + KMF_KEY_HANDLE_ATTR, + KMF_PRIVKEY_HANDLE_ATTR, + KMF_PUBKEY_HANDLE_ATTR, + KMF_ERROR_ATTR, + KMF_X509_NAME_ATTR, + KMF_X509_SPKI_ATTR, + KMF_X509_CERTIFICATE_ATTR, + KMF_RAW_KEY_ATTR, + KMF_CSR_DATA_ATTR, + KMF_GENERALNAMECHOICES_ATTR, + KMF_STOREKEY_BOOL_ATTR, + KMF_SENSITIVE_BOOL_ATTR, + KMF_NON_EXTRACTABLE_BOOL_ATTR, + KMF_TOKEN_BOOL_ATTR, + KMF_PRIVATE_BOOL_ATTR, + KMF_NEWPIN_ATTR, + KMF_IN_SIGN_ATTR, + KMF_OUT_DATA_ATTR, + KMF_COUNT_ATTR, + KMF_DESTROY_BOOL_ATTR, + KMF_TBS_CERT_DATA_ATTR, + KMF_PLAINTEXT_DATA_ATTR, + KMF_CIPHERTEXT_DATA_ATTR, + KMF_VALIDATE_RESULT_ATTR, + KMF_KEY_DATA_ATTR, + KMF_PK11_USER_TYPE_ATTR, + KMF_ECC_CURVE_OID_ATTR, + KMF_MAPPER_NAME_ATTR, + KMF_MAPPER_PATH_ATTR, + KMF_MAPPER_OPTIONS_ATTR +} KMF_ATTR_TYPE; + +typedef struct { + KMF_ATTR_TYPE type; + void *pValue; + uint32_t valueLen; +} KMF_ATTRIBUTE; + +/* + * Definitions for common X.509v3 certificate attribute OIDs + */ +#define OID_ISO_MEMBER 42 /* Also in PKCS */ +#define OID_US OID_ISO_MEMBER, 134, 72 /* Also in PKCS */ +#define OID_CA OID_ISO_MEMBER, 124 + +#define OID_ISO_IDENTIFIED_ORG 43 +#define OID_OSINET OID_ISO_IDENTIFIED_ORG, 4 +#define OID_GOSIP OID_ISO_IDENTIFIED_ORG, 5 +#define OID_DOD OID_ISO_IDENTIFIED_ORG, 6 +#define OID_OIW OID_ISO_IDENTIFIED_ORG, 14 /* Also in x9.57 */ + +#define OID_ISO_CCITT_DIR_SERVICE 85 +#define OID_ISO_CCITT_COUNTRY 96 +#define OID_COUNTRY_US OID_ISO_CCITT_COUNTRY, 134, 72 +#define OID_COUNTRY_CA OID_ISO_CCITT_COUNTRY, 124 +#define OID_COUNTRY_US_ORG OID_COUNTRY_US, 1 +#define OID_COUNTRY_US_MHS_MD OID_COUNTRY_US, 2 +#define OID_COUNTRY_US_STATE OID_COUNTRY_US, 3 + +/* From the PKCS Standards */ +#define OID_ISO_MEMBER_LENGTH 1 +#define OID_US_LENGTH (OID_ISO_MEMBER_LENGTH + 2) + +#define OID_RSA OID_US, 134, 247, 13 +#define OID_RSA_LENGTH (OID_US_LENGTH + 3) + +#define OID_RSA_HASH OID_RSA, 2 +#define OID_RSA_HASH_LENGTH (OID_RSA_LENGTH + 1) + +#define OID_RSA_ENCRYPT OID_RSA, 3 +#define OID_RSA_ENCRYPT_LENGTH (OID_RSA_LENGTH + 1) + +#define OID_PKCS OID_RSA, 1 +#define OID_PKCS_LENGTH (OID_RSA_LENGTH + 1) + +#define OID_PKCS_1 OID_PKCS, 1 +#define OID_PKCS_1_LENGTH (OID_PKCS_LENGTH + 1) + +#define OID_PKCS_2 OID_PKCS, 2 +#define OID_PKCS_3 OID_PKCS, 3 +#define OID_PKCS_3_LENGTH (OID_PKCS_LENGTH + 1) + +#define OID_PKCS_4 OID_PKCS, 4 +#define OID_PKCS_5 OID_PKCS, 5 +#define OID_PKCS_5_LENGTH (OID_PKCS_LENGTH + 1) +#define OID_PKCS_6 OID_PKCS, 6 +#define OID_PKCS_7 OID_PKCS, 7 +#define OID_PKCS_7_LENGTH (OID_PKCS_LENGTH + 1) + +#define OID_PKCS_7_Data OID_PKCS_7, 1 +#define OID_PKCS_7_SignedData OID_PKCS_7, 2 +#define OID_PKCS_7_EnvelopedData OID_PKCS_7, 3 +#define OID_PKCS_7_SignedAndEnvelopedData OID_PKCS_7, 4 +#define OID_PKCS_7_DigestedData OID_PKCS_7, 5 +#define OID_PKCS_7_EncryptedData OID_PKCS_7, 6 + +#define OID_PKCS_8 OID_PKCS, 8 +#define OID_PKCS_9 OID_PKCS, 9 +#define OID_PKCS_9_LENGTH (OID_PKCS_LENGTH + 1) + +#define OID_PKCS_9_CONTENT_TYPE OID_PKCS_9, 3 +#define OID_PKCS_9_MESSAGE_DIGEST OID_PKCS_9, 4 +#define OID_PKCS_9_SIGNING_TIME OID_PKCS_9, 5 +#define OID_PKCS_9_COUNTER_SIGNATURE OID_PKCS_9, 6 +#define OID_PKCS_9_EXTENSION_REQUEST OID_PKCS_9, 14 + +#define OID_PKCS_10 OID_PKCS, 10 + +#define OID_PKCS_12 OID_PKCS, 12 +#define OID_PKCS_12_LENGTH (OID_PKCS_LENGTH + 1) + +#define PBEWithSHAAnd128BitRC4 OID_PKCS_12, 1, 1 +#define PBEWithSHAAnd40BitRC4 OID_PKCS_12, 1, 2 +#define PBEWithSHAAnd3KeyTripleDES_CBC OID_PKCS_12, 1, 3 +#define PBEWithSHAAnd2KeyTripleDES_CBC OID_PKCS_12, 1, 4 +#define PBEWithSHAAnd128BitRC2_CBC OID_PKCS_12, 1, 5 +#define PBEWithSHAAnd40BitRC2_CBC OID_PKCS_12, 1, 6 + +#define OID_BAG_TYPES OID_PKCS_12, 10, 1 +#define OID_KeyBag OID_BAG_TYPES, 1 +#define OID_PKCS8ShroudedKeyBag OID_BAG_TYPES, 2 +#define OID_CertBag OID_BAG_TYPES, 3 +#define OID_CrlBag OID_BAG_TYPES, 4 +#define OID_SecretBag OID_BAG_TYPES, 5 +#define OID_SafeContentsBag OID_BAG_TYPES, 6 + +#define OID_ContentInfo OID_PKCS_7, 0, 1 + +#define OID_CERT_TYPES OID_PKCS_9, 22 +#define OID_x509Certificate OID_CERT_TYPES, 1 +#define OID_sdsiCertificate OID_CERT_TYPES, 2 + +#define OID_CRL_TYPES OID_PKCS_9, 23 +#define OID_x509Crl OID_CRL_TYPES, 1 + +#define OID_DS OID_ISO_CCITT_DIR_SERVICE /* Also in X.501 */ +#define OID_DS_LENGTH 1 + +#define OID_ATTR_TYPE OID_DS, 4 /* Also in X.501 */ +#define OID_ATTR_TYPE_LENGTH (OID_DS_LENGTH + 1) + +#define OID_DSALG OID_DS, 8 /* Also in X.501 */ +#define OID_DSALG_LENGTH (OID_DS_LENGTH + 1) + +#define OID_EXTENSION OID_DS, 29 /* Also in X.501 */ +#define OID_EXTENSION_LENGTH (OID_DS_LENGTH + 1) + +/* + * From RFC 1274: + * {itu-t(0) data(9) pss(2342) ucl(19200300) pilot(100) pilotAttributeType(1) } + */ +#define OID_PILOT 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x1 +#define OID_PILOT_LENGTH 9 + +#define OID_USERID OID_PILOT 1 +#define OID_USERID_LENGTH (OID_PILOT_LENGTH + 1) + +/* + * From PKIX part1 + * { iso(1) identified-organization(3) dod(6) internet(1) + * security(5) mechanisms(5) pkix(7) } + */ +#define OID_PKIX 43, 6, 1, 5, 5, 7 +#define OID_PKIX_LENGTH 6 + +/* private certificate extensions, { id-pkix 1 } */ +#define OID_PKIX_PE OID_PKIX, 1 +#define OID_PKIX_PE_LENGTH (OID_PKIX_LENGTH + 1) + +/* policy qualifier types {id-pkix 2 } */ +#define OID_PKIX_QT OID_PKIX, 2 +#define OID_PKIX_QT_LENGTH (OID_PKIX_LENGTH + 1) + +/* CPS qualifier, { id-qt 1 } */ +#define OID_PKIX_QT_CPS OID_PKIX_QT, 1 +#define OID_PKIX_QT_CPS_LENGTH (OID_PKIX_QT_LENGTH + 1) +/* user notice qualifier, { id-qt 2 } */ +#define OID_PKIX_QT_UNOTICE OID_PKIX_QT, 2 +#define OID_PKIX_QT_UNOTICE_LENGTH (OID_PKIX_QT_LENGTH + 1) + +/* extended key purpose OIDs {id-pkix 3 } */ +#define OID_PKIX_KP OID_PKIX, 3 +#define OID_PKIX_KP_LENGTH (OID_PKIX_LENGTH + 1) + +/* access descriptors {id-pkix 4 } */ +#define OID_PKIX_AD OID_PKIX, 48 +#define OID_PKIX_AD_LENGTH (OID_PKIX_LENGTH + 1) + +/* access descriptors */ +/* OCSP */ +#define OID_PKIX_AD_OCSP OID_PKIX_AD, 1 +#define OID_PKIX_AD_OCSP_LENGTH (OID_PKIX_AD_LENGTH + 1) + +/* cAIssuers */ +#define OID_PKIX_AD_CAISSUERS OID_PKIX_AD, 2 +#define OID_PKIX_AD_CAISSUERS_LENGTH (OID_PKIX_AD_LENGTH + 1) + +/* end PKIX part1 */ + +/* + * From RFC4556 (PKINIT) + * + * pkinit = { iso(1) identified-organization(3) dod(6) internet(1) + * security(5) kerberosv5(2) pkinit(3) } + */ +#define OID_KRB5_PKINIT 43, 6, 1, 5, 2, 3 +#define OID_KRB5_PKINIT_LENGTH 6 + +#define OID_KRB5_PKINIT_KPCLIENTAUTH OID_KRB5_PKINIT, 4 +#define OID_KRB5_PKINIT_KPCLIENTAUTH_LENGTH (OID_KRB5_PKINIT_LENGTH + 1) + +#define OID_KRB5_PKINIT_KPKDC OID_KRB5_PKINIT, 5 +#define OID_KRB5_PKINIT_KPKDC_LENGTH (OID_KRB5_PKINIT_LENGTH + 1) + +#define OID_KRB5_SAN 43, 6, 1, 5, 2, 2 +#define OID_KRB5_SAN_LENGTH 6 + +/* + * Microsoft OIDs: + * id-ms-san-sc-logon-upn = + * {iso(1) identified-organization(3) dod(6) internet(1) private(4) + * enterprise(1) microsoft(311) 20 2 3} + * + * id-ms-kp-sc-logon = + * {iso(1) identified-organization(3) dod(6) internet(1) private(4) + * enterprise(1) microsoft(311) 20 2 2} + */ +#define OID_MS 43, 6, 1, 4, 1, 130, 55 +#define OID_MS_LENGTH 7 +#define OID_MS_KP_SC_LOGON OID_MS, 20, 2, 2 +#define OID_MS_KP_SC_LOGON_LENGTH (OID_MS_LENGTH + 3) + +#define OID_MS_KP_SC_LOGON_UPN OID_MS, 20, 2, 3 +#define OID_MS_KP_SC_LOGON_UPN_LENGTH (OID_MS_LENGTH + 3) + +#define OID_APPL_TCP_PROTO 43, 6, 1, 2, 1, 27, 4 +#define OID_APPL_TCP_PROTO_LENGTH 8 + +#define OID_DAP OID_DS, 3, 1 +#define OID_DAP_LENGTH (OID_DS_LENGTH + 2) + +/* From x9.57 */ +#define OID_OIW_LENGTH 2 + +#define OID_OIW_SECSIG OID_OIW, 3 +#define OID_OIW_SECSIG_LENGTH (OID_OIW_LENGTH + 1) + +#define OID_OIW_ALGORITHM OID_OIW_SECSIG, 2 +#define OID_OIW_ALGORITHM_LENGTH (OID_OIW_SECSIG_LENGTH + 1) + +#define OID_OIWDIR OID_OIW, 7, 2 +#define OID_OIWDIR_LENGTH (OID_OIW_LENGTH + 2) + +#define OID_OIWDIR_CRPT OID_OIWDIR, 1 + +#define OID_OIWDIR_HASH OID_OIWDIR, 2 +#define OID_OIWDIR_HASH_LENGTH (OID_OIWDIR_LENGTH + 1) + +#define OID_OIWDIR_SIGN OID_OIWDIR, 3 +#define OID_OIWDIR_SIGN_LENGTH (OID_OIWDIR_LENGTH + 1) + +#define OID_X9CM OID_US, 206, 56 +#define OID_X9CM_MODULE OID_X9CM, 1 +#define OID_X9CM_INSTRUCTION OID_X9CM, 2 +#define OID_X9CM_ATTR OID_X9CM, 3 +#define OID_X9CM_X9ALGORITHM OID_X9CM, 4 +#define OID_X9CM_X9ALGORITHM_LENGTH ((OID_US_LENGTH) + 2 + 1) + +#define INTEL 96, 134, 72, 1, 134, 248, 77 +#define INTEL_LENGTH 7 + +#define INTEL_SEC_FORMATS INTEL_CDSASECURITY, 1 +#define INTEL_SEC_FORMATS_LENGTH (INTEL_CDSASECURITY_LENGTH + 1) + +#define INTEL_SEC_ALGS INTEL_CDSASECURITY, 2, 5 +#define INTEL_SEC_ALGS_LENGTH (INTEL_CDSASECURITY_LENGTH + 2) + +extern const KMF_OID +KMFOID_AliasedEntryName, +KMFOID_AuthorityRevocationList, +KMFOID_BusinessCategory, +KMFOID_CACertificate, +KMFOID_CertificateRevocationList, +KMFOID_ChallengePassword, +KMFOID_CollectiveFacsimileTelephoneNumber, +KMFOID_CollectiveInternationalISDNNumber, +KMFOID_CollectiveOrganizationName, +KMFOID_CollectiveOrganizationalUnitName, +KMFOID_CollectivePhysicalDeliveryOfficeName, +KMFOID_CollectivePostOfficeBox, +KMFOID_CollectivePostalAddress, +KMFOID_CollectivePostalCode, +KMFOID_CollectiveStateProvinceName, +KMFOID_CollectiveStreetAddress, +KMFOID_CollectiveTelephoneNumber, +KMFOID_CollectiveTelexNumber, +KMFOID_CollectiveTelexTerminalIdentifier, +KMFOID_CommonName, +KMFOID_ContentType, +KMFOID_CounterSignature, +KMFOID_CountryName, +KMFOID_CrossCertificatePair, +KMFOID_DNQualifier, +KMFOID_Description, +KMFOID_DestinationIndicator, +KMFOID_DistinguishedName, +KMFOID_EmailAddress, +KMFOID_EnhancedSearchGuide, +KMFOID_ExtendedCertificateAttributes, +KMFOID_ExtensionRequest, +KMFOID_FacsimileTelephoneNumber, +KMFOID_GenerationQualifier, +KMFOID_GivenName, +KMFOID_HouseIdentifier, +KMFOID_Initials, +KMFOID_InternationalISDNNumber, +KMFOID_KnowledgeInformation, +KMFOID_LocalityName, +KMFOID_Member, +KMFOID_MessageDigest, +KMFOID_Name, +KMFOID_ObjectClass, +KMFOID_OrganizationName, +KMFOID_OrganizationalUnitName, +KMFOID_Owner, +KMFOID_PhysicalDeliveryOfficeName, +KMFOID_PostOfficeBox, +KMFOID_PostalAddress, +KMFOID_PostalCode, +KMFOID_PreferredDeliveryMethod, +KMFOID_PresentationAddress, +KMFOID_ProtocolInformation, +KMFOID_RFC822mailbox, +KMFOID_RegisteredAddress, +KMFOID_RoleOccupant, +KMFOID_SearchGuide, +KMFOID_SeeAlso, +KMFOID_SerialNumber, +KMFOID_SigningTime, +KMFOID_StateProvinceName, +KMFOID_StreetAddress, +KMFOID_SupportedApplicationContext, +KMFOID_Surname, +KMFOID_TelephoneNumber, +KMFOID_TelexNumber, +KMFOID_TelexTerminalIdentifier, +KMFOID_Title, +KMFOID_UniqueIdentifier, +KMFOID_UniqueMember, +KMFOID_UnstructuredAddress, +KMFOID_UnstructuredName, +KMFOID_UserCertificate, +KMFOID_UserPassword, +KMFOID_X_121Address, +KMFOID_domainComponent, +KMFOID_userid; + +extern const KMF_OID +KMFOID_AuthorityKeyID, +KMFOID_AuthorityInfoAccess, +KMFOID_VerisignCertificatePolicy, +KMFOID_KeyUsageRestriction, +KMFOID_SubjectDirectoryAttributes, +KMFOID_SubjectKeyIdentifier, +KMFOID_KeyUsage, +KMFOID_PrivateKeyUsagePeriod, +KMFOID_SubjectAltName, +KMFOID_IssuerAltName, +KMFOID_BasicConstraints, +KMFOID_CrlNumber, +KMFOID_CrlReason, +KMFOID_HoldInstructionCode, +KMFOID_InvalidityDate, +KMFOID_DeltaCrlIndicator, +KMFOID_IssuingDistributionPoints, +KMFOID_NameConstraints, +KMFOID_CrlDistributionPoints, +KMFOID_CertificatePolicies, +KMFOID_PolicyMappings, +KMFOID_PolicyConstraints, +KMFOID_AuthorityKeyIdentifier, +KMFOID_ExtendedKeyUsage, +KMFOID_PkixAdOcsp, +KMFOID_PkixAdCaIssuers, +KMFOID_PKIX_PQ_CPSuri, +KMFOID_PKIX_PQ_Unotice, +KMFOID_PKIX_KP_ServerAuth, +KMFOID_PKIX_KP_ClientAuth, +KMFOID_PKIX_KP_CodeSigning, +KMFOID_PKIX_KP_EmailProtection, +KMFOID_PKIX_KP_IPSecEndSystem, +KMFOID_PKIX_KP_IPSecTunnel, +KMFOID_PKIX_KP_IPSecUser, +KMFOID_PKIX_KP_TimeStamping, +KMFOID_PKIX_KP_OCSPSigning, +KMFOID_SHA1, +KMFOID_RSA, +KMFOID_DSA, +KMFOID_MD5, +KMFOID_MD5WithRSA, +KMFOID_MD2WithRSA, +KMFOID_SHA1WithRSA, +KMFOID_SHA256WithRSA, +KMFOID_SHA384WithRSA, +KMFOID_SHA512WithRSA, +KMFOID_SHA1WithDSA, +KMFOID_X9CM_DSA, +KMFOID_X9CM_DSAWithSHA1; + +/* For PKINIT support */ +extern const KMF_OID +KMFOID_PKINIT_san, +KMFOID_PKINIT_ClientAuth, +KMFOID_PKINIT_Kdc, +KMFOID_MS_KP_SCLogon, +KMFOID_MS_KP_SCLogon_UPN; + +/* For ECC support */ +extern const KMF_OID +KMFOID_EC_PUBLIC_KEY, +KMFOID_SHA1WithECDSA, +KMFOID_SHA224WithECDSA, +KMFOID_SHA256WithECDSA, +KMFOID_SHA384WithECDSA, +KMFOID_SHA512WithECDSA, +KMFOID_SHA224WithDSA, +KMFOID_SHA256WithDSA, +KMFOID_SHA224, +KMFOID_SHA256, +KMFOID_SHA384, +KMFOID_SHA512, +KMFOID_ECC_secp112r1, +KMFOID_ECC_secp112r2, +KMFOID_ECC_secp128r1, +KMFOID_ECC_secp128r2, +KMFOID_ECC_secp160k1, +KMFOID_ECC_secp160r1, +KMFOID_ECC_secp160r2, +KMFOID_ECC_secp192k1, +KMFOID_ECC_secp224k1, +KMFOID_ECC_secp224r1, +KMFOID_ECC_secp256k1, +KMFOID_ECC_secp384r1, +KMFOID_ECC_secp521r1, +KMFOID_ECC_sect113r1, +KMFOID_ECC_sect113r2, +KMFOID_ECC_sect131r1, +KMFOID_ECC_sect131r2, +KMFOID_ECC_sect163k1, +KMFOID_ECC_sect163r1, +KMFOID_ECC_sect163r2, +KMFOID_ECC_sect193r1, +KMFOID_ECC_sect193r2, +KMFOID_ECC_sect233k1, +KMFOID_ECC_sect233r1, +KMFOID_ECC_sect239k1, +KMFOID_ECC_sect283k1, +KMFOID_ECC_sect283r1, +KMFOID_ECC_sect409k1, +KMFOID_ECC_sect409r1, +KMFOID_ECC_sect571k1, +KMFOID_ECC_sect571r1, +KMFOID_ECC_c2pnb163v1, +KMFOID_ECC_c2pnb163v2, +KMFOID_ECC_c2pnb163v3, +KMFOID_ECC_c2pnb176v1, +KMFOID_ECC_c2tnb191v1, +KMFOID_ECC_c2tnb191v2, +KMFOID_ECC_c2tnb191v3, +KMFOID_ECC_c2pnb208w1, +KMFOID_ECC_c2tnb239v1, +KMFOID_ECC_c2tnb239v2, +KMFOID_ECC_c2tnb239v3, +KMFOID_ECC_c2pnb272w1, +KMFOID_ECC_c2pnb304w1, +KMFOID_ECC_c2tnb359v1, +KMFOID_ECC_c2pnb368w1, +KMFOID_ECC_c2tnb431r1, +KMFOID_ECC_prime192v2, +KMFOID_ECC_prime192v3, +KMFOID_ECC_secp192r1, +KMFOID_ECC_secp256r1; + +/* + * ANSI X9-62 prime192v1 is same as secp192r1 and + * ANSI X9-62 prime256v1 is same as secp256r1 + */ +#define KMFOID_ANSIX962_prime192v1 KMFOID_ECC_secp192r1 +#define KMFOID_ANSIX962_prime256v1 KMFOID_ECC_secp256r1 + +/* + * KMF Certificate validation codes. These may be masked together. + */ +#define KMF_CERT_VALIDATE_OK 0x00 +#define KMF_CERT_VALIDATE_ERR_TA 0x01 +#define KMF_CERT_VALIDATE_ERR_USER 0x02 +#define KMF_CERT_VALIDATE_ERR_SIGNATURE 0x04 +#define KMF_CERT_VALIDATE_ERR_KEYUSAGE 0x08 +#define KMF_CERT_VALIDATE_ERR_EXT_KEYUSAGE 0x10 +#define KMF_CERT_VALIDATE_ERR_TIME 0x20 +#define KMF_CERT_VALIDATE_ERR_CRL 0x40 +#define KMF_CERT_VALIDATE_ERR_OCSP 0x80 +#define KMF_CERT_VALIDATE_ERR_ISSUER 0x100 + +/* + * KMF Key Usage bitmasks + */ +#define KMF_digitalSignature 0x8000 +#define KMF_nonRepudiation 0x4000 +#define KMF_keyEncipherment 0x2000 +#define KMF_dataEncipherment 0x1000 +#define KMF_keyAgreement 0x0800 +#define KMF_keyCertSign 0x0400 +#define KMF_cRLSign 0x0200 +#define KMF_encipherOnly 0x0100 +#define KMF_decipherOnly 0x0080 + +#define KMF_KUBITMASK 0xFF80 + +/* + * KMF Extended KeyUsage OID definitions + */ +#define KMF_EKU_SERVERAUTH 0x01 +#define KMF_EKU_CLIENTAUTH 0x02 +#define KMF_EKU_CODESIGNING 0x04 +#define KMF_EKU_EMAIL 0x08 +#define KMF_EKU_TIMESTAMP 0x10 +#define KMF_EKU_OCSPSIGNING 0x20 + +#ifdef __cplusplus +} +#endif +#endif /* _KMFTYPES_H */ diff --git a/illumos-x86_64/usr/include/kstat.h b/illumos-x86_64/usr/include/kstat.h new file mode 100644 index 00000000..4996a4d1 --- /dev/null +++ b/illumos-x86_64/usr/include/kstat.h @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992 by Sun Microsystems, Inc. + * Copyright 2021 Oxide Computer Company + */ + +#ifndef _KSTAT_H +#define _KSTAT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * kstat_open() returns a pointer to a kstat_ctl_t. + * This is used for subsequent libkstat operations. + */ +typedef struct kstat_ctl { + kid_t kc_chain_id; /* current kstat chain ID */ + kstat_t *kc_chain; /* pointer to kstat chain */ + int kc_kd; /* /dev/kstat descriptor */ +} kstat_ctl_t; + +extern kstat_ctl_t *kstat_open(void); +extern int kstat_close(kstat_ctl_t *); +extern kid_t kstat_read(kstat_ctl_t *, kstat_t *, void *); +extern kid_t kstat_write(kstat_ctl_t *, kstat_t *, void *); +extern kid_t kstat_chain_update(kstat_ctl_t *); +extern kstat_t *kstat_lookup(kstat_ctl_t *, const char *, int, + const char *); +extern void *kstat_data_lookup(kstat_t *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _KSTAT_H */ diff --git a/illumos-x86_64/usr/include/kvm.h b/illumos-x86_64/usr/include/kvm.h new file mode 100644 index 00000000..348b0c2e --- /dev/null +++ b/illumos-x86_64/usr/include/kvm.h @@ -0,0 +1,102 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1987-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +#ifndef _KVM_H +#define _KVM_H + +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +/* define a 'cookie' to pass around between user code and the library */ +typedef struct _kvmd kvm_t; + +/* libkvm routine definitions */ + +#ifdef __STDC__ + +extern kvm_t *kvm_open(const char *, const char *, const char *, + int, const char *); +extern int kvm_close(kvm_t *); +extern int kvm_nlist(kvm_t *, struct nlist []); +extern ssize_t kvm_read(kvm_t *, uintptr_t, void *, size_t); +extern ssize_t kvm_kread(kvm_t *, uintptr_t, void *, size_t); +extern ssize_t kvm_uread(kvm_t *, uintptr_t, void *, size_t); +extern ssize_t kvm_aread(kvm_t *, uintptr_t, void *, size_t, struct as *); +extern ssize_t kvm_pread(kvm_t *, uint64_t, void *, size_t); +extern ssize_t kvm_write(kvm_t *, uintptr_t, const void *, size_t); +extern ssize_t kvm_kwrite(kvm_t *, uintptr_t, const void *, size_t); +extern ssize_t kvm_uwrite(kvm_t *, uintptr_t, const void *, size_t); +extern ssize_t kvm_awrite(kvm_t *, uintptr_t, const void *, size_t, + struct as *); +extern ssize_t kvm_pwrite(kvm_t *, uint64_t, const void *, size_t); +extern uint64_t kvm_physaddr(kvm_t *, struct as *, uintptr_t); +extern proc_t *kvm_getproc(kvm_t *, pid_t); +extern proc_t *kvm_nextproc(kvm_t *); +extern int kvm_setproc(kvm_t *); +extern user_t *kvm_getu(kvm_t *, struct proc *); +extern int kvm_getcmd(kvm_t *, proc_t *, user_t *, char ***, char ***); +extern const char *kvm_namelist(kvm_t *); + +#else + +extern kvm_t *kvm_open(); +extern int kvm_close(); +extern int kvm_nlist(); +extern ssize_t kvm_read(); +extern ssize_t kvm_kread(); +extern ssize_t kvm_uread(); +extern ssize_t kvm_aread(); +extern ssize_t kvm_pread(); +extern ssize_t kvm_write(); +extern ssize_t kvm_kwrite(); +extern ssize_t kvm_uwrite(); +extern ssize_t kvm_awrite(); +extern ssize_t kvm_pwrite(); +extern uint64_t Kvm_physaddr(); +extern proc_t *kvm_getproc(); +extern proc_t *kvm_nextproc(); +extern int kvm_setproc(); +extern user_t *kvm_getu(); +extern int kvm_getcmd(); + +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _KVM_H */ diff --git a/illumos-x86_64/usr/include/langinfo.h b/illumos-x86_64/usr/include/langinfo.h new file mode 100644 index 00000000..c7ff2b67 --- /dev/null +++ b/illumos-x86_64/usr/include/langinfo.h @@ -0,0 +1,162 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _LANGINFO_H +#define _LANGINFO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The seven days of the week in their full beauty + */ + +#define DAY_1 1 /* sunday */ +#define DAY_2 2 /* monday */ +#define DAY_3 3 /* tuesday */ +#define DAY_4 4 /* wednesday */ +#define DAY_5 5 /* thursday */ +#define DAY_6 6 /* friday */ +#define DAY_7 7 /* saturday */ + +/* + * The abbreviated seven days of the week + */ + +#define ABDAY_1 8 /* sun */ +#define ABDAY_2 9 /* mon */ +#define ABDAY_3 10 /* tue */ +#define ABDAY_4 11 /* wed */ +#define ABDAY_5 12 /* thu */ +#define ABDAY_6 13 /* fri */ +#define ABDAY_7 14 /* sat */ + +/* + * The full names of the twelve months... + */ + +#define MON_1 15 /* january */ +#define MON_2 16 /* february */ +#define MON_3 17 /* march */ +#define MON_4 18 /* april */ +#define MON_5 19 /* may */ +#define MON_6 20 /* june */ +#define MON_7 21 /* july */ +#define MON_8 22 /* august */ +#define MON_9 23 /* september */ +#define MON_10 24 /* october */ +#define MON_11 25 /* november */ +#define MON_12 26 /* december */ + +/* + * ... and their abbreviated form + */ + +#define ABMON_1 27 /* jan */ +#define ABMON_2 28 /* feb */ +#define ABMON_3 29 /* mar */ +#define ABMON_4 30 /* apr */ +#define ABMON_5 31 /* may */ +#define ABMON_6 32 /* jun */ +#define ABMON_7 33 /* jul */ +#define ABMON_8 34 /* aug */ +#define ABMON_9 35 /* sep */ +#define ABMON_10 36 /* oct */ +#define ABMON_11 37 /* nov */ +#define ABMON_12 38 /* dec */ + +/* + * plus some special strings you might need to know + */ + +#define RADIXCHAR 39 /* radix character */ +#define THOUSEP 40 /* separator for thousand */ +/* YESSTR and NOSTR marked as legacy in XPG5 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +#define YESSTR 41 /* affirmative response for yes/no queries */ +#define NOSTR 42 /* negative response for yes/no queries */ +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__ */ +#define CRNCYSTR 43 /* currency symbol */ + +/* + * Default string used to format date and time + * e.g. Sunday, August 24 21:08:38 MET 1986 + */ + +#define D_T_FMT 44 /* string for formatting date and time */ +#define D_FMT 45 /* date format */ +#define T_FMT 46 /* time format */ +#define AM_STR 47 /* am string */ +#define PM_STR 48 /* pm string */ + +/* + * Additions for XPG4 (XSH4) Compliance + */ + +#define CODESET 49 /* codeset name */ +#define T_FMT_AMPM 50 /* am or pm time format string */ +#define ERA 51 /* era description segments */ +#define ERA_D_FMT 52 /* era date format string */ +#define ERA_D_T_FMT 53 /* era date and time format string */ +#define ERA_T_FMT 54 /* era time format string */ +#define ALT_DIGITS 55 /* alternative symbols for digits */ +#define YESEXPR 56 /* affirmative response expression */ +#define NOEXPR 57 /* negative response expression */ +#define _DATE_FMT 58 /* strftime format for date(1) */ + +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) +#define MAXSTRMSG 58 /* Maximum number of strings in langinfo */ +#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */ + +/* + * and the definitions of functions nl_langinfo(3C) + */ +char *nl_langinfo(nl_item); /* get a string from the database */ + +#if defined(_XPG7) || !defined(_STRICT_SYMBOLS) +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +char *nl_langinfo_l(nl_item, locale_t); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _LANGINFO_H */ diff --git a/illumos-x86_64/usr/include/lber.h b/illumos-x86_64/usr/include/lber.h new file mode 100644 index 00000000..0d0ea70c --- /dev/null +++ b/illumos-x86_64/usr/include/lber.h @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0(the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http:/ /www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright(C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef _LBER_H +#define _LBER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _SOLARIS_SDK +#define _SOLARIS_SDK +#endif + +#include /* to pick up size_t typedef */ + +#ifdef _SOLARIS_SDK +#ifdef sunos4 +#define SAFEMEMCPY(d, s, n) bcopy(s, d, n) +#else /* sunos4 */ +#define SAFEMEMCPY(d, s, n) memmove(d, s, n) +#endif /* sunos4 */ +#endif /* _SOLARIS_SDK */ +/* + * Note that LBER_ERROR and LBER_DEFAULT are values that can never appear + * as valid BER tags, and so it is safe to use them to report errors. In + * fact, any tag for which the following is true is invalid: + * (( tag & 0x00000080 ) != 0 ) && (( tag & 0xFFFFFF00 ) != 0 ) + */ +#define LBER_ERROR 0xffffffffU +#define LBER_DEFAULT 0xffffffffU +#define LBER_END_OF_SEQORSET 0xfffffffeU +/* BER classes and mask */ +#define LBER_CLASS_UNIVERSAL 0x00 +#define LBER_CLASS_APPLICATION 0x40 +#define LBER_CLASS_CONTEXT 0x80 +#define LBER_CLASS_PRIVATE 0xc0 +#define LBER_CLASS_MASK 0xc0 + +/* BER encoding type and mask */ +#define LBER_PRIMITIVE 0x00 +#define LBER_CONSTRUCTED 0x20 +#define LBER_ENCODING_MASK 0x20 + +#define LBER_BIG_TAG_MASK 0x1f +#define LBER_MORE_TAG_MASK 0x80 + +/* general BER types we know about */ +#define LBER_BOOLEAN 0x01 +#define LBER_INTEGER 0x02 +#define LBER_BITSTRING 0x03 +#define LBER_OCTETSTRING 0x04 +#define LBER_NULL 0x05 +#define LBER_ENUMERATED 0x0a +#define LBER_SEQUENCE 0x30 +#define LBER_SET 0x31 + + +typedef unsigned int ber_len_t; /* for BER len */ +typedef unsigned int ber_tag_t; /* for BER tags */ +typedef int ber_int_t; /* for BER ints, enums, and Booleans */ +typedef unsigned int ber_uint_t; /* unsigned equivalent of ber_int_t */ +typedef int ber_slen_t; /* signed equivalent of ber_len_t */ + +typedef struct berval { + ber_len_t bv_len; + char *bv_val; +} BerValue; + +typedef struct berelement BerElement; + +#ifdef _SOLARIS_SDK +#define NULLBER ((BerElement *)NULL) +#endif + +typedef int (*BERTranslateProc)(char **bufp, ber_uint_t *buflenp, + int free_input); +#ifndef macintosh +#if defined(_WINDOWS) || defined(_WIN32) || defined(_CONSOLE) +#include /* for SOCKET */ +typedef SOCKET LBER_SOCKET; +#else +typedef int LBER_SOCKET; +#endif /* _WINDOWS */ +#else /* macintosh */ +typedef void *LBER_SOCKET; +#endif /* macintosh */ + +/* calling conventions used by library */ +#ifndef LDAP_CALL +#if defined(_WINDOWS) || defined(_WIN32) +#define LDAP_C __cdecl +#ifndef _WIN32 +#define __stdcall _far _pascal +#define LDAP_CALLBACK _loadds +#else +#define LDAP_CALLBACK +#endif /* _WIN32 */ +#define LDAP_PASCAL __stdcall +#define LDAP_CALL LDAP_PASCAL +#else /* _WINDOWS */ +#define LDAP_C +#define LDAP_CALLBACK +#define LDAP_PASCAL +#define LDAP_CALL +#endif /* _WINDOWS */ +#endif /* LDAP_CALL */ + +/* + * function prototypes for lber library + */ +#ifndef LDAP_API +#if defined(_WINDOWS) || defined(_WIN32) +#define LDAP_API(rt) rt +#else /* _WINDOWS */ +#define LDAP_API(rt) rt +#endif /* _WINDOWS */ +#endif /* LDAP_API */ + +/* + * decode routines + */ +ber_tag_t LDAP_CALL ber_get_tag(BerElement *ber); +ber_tag_t LDAP_CALL ber_skip_tag(BerElement *ber, + ber_len_t *len); +ber_tag_t LDAP_CALL ber_peek_tag(BerElement *ber, + ber_len_t *len); +ber_tag_t LDAP_CALL ber_get_int(BerElement *ber, ber_int_t *num); +ber_tag_t LDAP_CALL ber_get_stringb(BerElement *ber, char *buf, + ber_len_t *len); +ber_tag_t LDAP_CALL ber_get_stringa(BerElement *ber, + char **buf); +ber_tag_t LDAP_CALL ber_get_stringal(BerElement *ber, + struct berval **bv); +ber_tag_t ber_get_bitstringa(BerElement *ber, + char **buf, ber_len_t *len); +ber_tag_t LDAP_CALL ber_get_null(BerElement *ber); +ber_tag_t LDAP_CALL ber_get_boolean(BerElement *ber, + int *boolval); +ber_tag_t LDAP_CALL ber_first_element(BerElement *ber, + ber_len_t *len, char **last); +ber_tag_t LDAP_CALL ber_next_element(BerElement *ber, + ber_len_t *len, char *last); +ber_tag_t LDAP_C ber_scanf(BerElement *ber, const char *fmt, + ...); +LDAP_API(void) LDAP_CALL ber_bvfree(struct berval *bv); +LDAP_API(void) LDAP_CALL ber_bvecfree(struct berval **bv); +struct berval *LDAP_CALL ber_bvdup(const struct berval *bv); +LDAP_API(void) LDAP_CALL ber_set_string_translators(BerElement *ber, + BERTranslateProc encode_proc, BERTranslateProc decode_proc); +LDAP_API(BerElement *) LDAP_CALL ber_init(const struct berval *bv); + +/* + * encoding routines + */ +int LDAP_CALL ber_put_enum(BerElement *ber, ber_int_t num, + ber_tag_t tag); +int LDAP_CALL ber_put_int(BerElement *ber, ber_int_t num, + ber_tag_t tag); +int LDAP_CALL ber_put_ostring(BerElement *ber, char *str, + ber_len_t len, ber_tag_t tag); +int LDAP_CALL ber_put_string(BerElement *ber, char *str, + ber_tag_t tag); +int LDAP_CALL ber_put_bitstring(BerElement *ber, char *str, + ber_len_t bitlen, ber_tag_t tag); +int LDAP_CALL ber_put_null(BerElement *ber, ber_tag_t tag); +int LDAP_CALL ber_put_boolean(BerElement *ber, int boolval, + ber_tag_t tag); +int LDAP_CALL ber_start_seq(BerElement *ber, ber_tag_t tag); +int LDAP_CALL ber_start_set(BerElement *ber, ber_tag_t tag); +int LDAP_CALL ber_put_seq(BerElement *ber); +int LDAP_CALL ber_put_set(BerElement *ber); +int LDAP_C ber_printf(BerElement *ber, const char *fmt, ...); +int LDAP_CALL ber_flatten(BerElement *ber, + struct berval **bvPtr); + +/* + * miscellaneous routines + */ +LDAP_API(void) LDAP_CALL ber_free(BerElement *ber, int freebuf); +LDAP_API(BerElement*) LDAP_CALL ber_alloc(void); +LDAP_API(BerElement*) LDAP_CALL der_alloc(void); +LDAP_API(BerElement*) LDAP_CALL ber_alloc_t(int options); +LDAP_API(BerElement*) LDAP_CALL ber_dup(BerElement *ber); +ber_int_t LDAP_CALL ber_read(BerElement *ber, char *buf, + ber_len_t len); +ber_int_t LDAP_CALL ber_write(BerElement *ber, char *buf, + ber_len_t len, int nosos); +LDAP_API(void) LDAP_CALL ber_reset(BerElement *ber, int was_writing); + +#ifdef __cplusplus +} +#endif + +#endif /* _LBER_H */ diff --git a/illumos-x86_64/usr/include/ldap.h b/illumos-x86_64/usr/include/ldap.h new file mode 100644 index 00000000..84107821 --- /dev/null +++ b/illumos-x86_64/usr/include/ldap.h @@ -0,0 +1,1582 @@ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998-1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#ifndef _LDAP_H +#define _LDAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _SOLARIS_SDK +#define _SOLARIS_SDK +#endif + +#ifndef LDAP_TYPE_TIMEVAL_DEFINED +#include +#endif +#ifndef LDAP_TYPE_SOCKET_DEFINED /* API extension */ +#include +#include +#endif + +#include + +#define LDAP_PORT 389 +#define LDAPS_PORT 636 +#define LDAP_PORT_MAX 65535 /* API extension */ +#define LDAP_VERSION1 1 /* API extension */ +#define LDAP_VERSION2 2 +#define LDAP_VERSION3 3 +#define LDAP_VERSION LDAP_VERSION2 /* API extension */ +#define LDAP_VERSION_MIN LDAP_VERSION3 +#define LDAP_VERSION_MAX LDAP_VERSION3 + +#define LDAP_VENDOR_VERSION 500 /* version # * 100 */ +#define LDAP_VENDOR_NAME "Sun Microsystems Inc." +/* + * The following will be an RFC number once the LDAP C API Internet Draft + * is published as a Proposed Standard RFC. For now we use 2000 + the + * draft revision number (currently 5) since we are close to compliance + * with revision 5 of the draft. + */ +#define LDAP_API_VERSION 2005 + +/* + * C LDAP features we support that are not (yet) part of the LDAP C API + * Internet Draft. Use the ldap_get_option() call with an option value of + * LDAP_OPT_API_FEATURE_INFO to retrieve information about a feature. + * + * Note that this list is incomplete; it includes only the most widely + * used extensions. Also, the version is 1 for all of these for now. + */ +#define LDAP_API_FEATURE_SERVER_SIDE_SORT 1 +#define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 1 +#define LDAP_API_FEATURE_PERSISTENT_SEARCH 1 +#define LDAP_API_FEATURE_PROXY_AUTHORIZATION 1 +#define LDAP_API_FEATURE_X_LDERRNO 1 +#define LDAP_API_FEATURE_X_MEMCACHE 1 +#define LDAP_API_FEATURE_X_IO_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_EXTIO_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_DNS_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_THREAD_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_GETLANGVALUES 1 +#define LDAP_API_FEATURE_X_CLIENT_SIDE_SORT 1 +#define LDAP_API_FEATURE_X_URL_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_FILTER_FUNCTIONS 1 + +#define LDAP_ROOT_DSE "" /* API extension */ +#define LDAP_NO_ATTRS "1.1" +#define LDAP_ALL_USER_ATTRS "*" + +/* + * Standard options (used with ldap_set_option() and ldap_get_option): + */ +#define LDAP_OPT_API_INFO 0x00 /* 0 */ +#define LDAP_OPT_DESC 0x01 /* 1 */ +#define LDAP_OPT_DEREF 0x02 /* 2 */ +#define LDAP_OPT_SIZELIMIT 0x03 /* 3 */ +#define LDAP_OPT_TIMELIMIT 0x04 /* 4 */ +#define LDAP_OPT_REFERRALS 0x08 /* 8 */ +#define LDAP_OPT_RESTART 0x09 /* 9 */ +#define LDAP_OPT_PROTOCOL_VERSION 0x11 /* 17 */ +#define LDAP_OPT_SERVER_CONTROLS 0x12 /* 18 */ +#define LDAP_OPT_CLIENT_CONTROLS 0x13 /* 19 */ +#define LDAP_OPT_API_FEATURE_INFO 0x15 /* 21 */ +#define LDAP_OPT_HOST_NAME 0x30 /* 48 */ +#define LDAP_OPT_ERROR_NUMBER 0x31 /* 49 */ +#define LDAP_OPT_ERROR_STRING 0x32 /* 50 */ +#define LDAP_OPT_MATCHED_DN 0x33 /* 51 */ + +/* + * Well-behaved private and experimental extensions will use option values + * between 0x4000 (16384) and 0x7FFF (32767) inclusive. + */ +#define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x4000 /* to 0x7FFF inclusive */ +/* + * Special timeout values for poll and connect: + */ +#define LDAP_X_IO_TIMEOUT_NO_WAIT 0 /* return immediately */ +#define LDAP_X_IO_TIMEOUT_NO_TIMEOUT (-1) /* block indefinitely */ +/* + * Timeout value for nonblocking connect call + */ +#define LDAP_X_OPT_CONNECT_TIMEOUT (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F01) + /* 0x4000 + 0x0F01 = 0x4F01 = 20225 - API extension */ + +/* for on/off options */ +#define LDAP_OPT_ON ((void *)1) +#define LDAP_OPT_OFF ((void *)0) + +typedef struct ldap LDAP; /* opaque connection handle */ +typedef struct ldapmsg LDAPMessage; /* opaque result/entry handle */ + +#define NULLMSG ((LDAPMessage *)0) + +/* structure representing an LDAP modification */ +typedef struct ldapmod { + int mod_op; /* kind of mod + form of values */ +#define LDAP_MOD_ADD 0x00 +#define LDAP_MOD_DELETE 0x01 +#define LDAP_MOD_REPLACE 0x02 +#define LDAP_MOD_BVALUES 0x80 + char *mod_type; /* attribute name to modify */ + union mod_vals_u { + char **modv_strvals; + struct berval **modv_bvals; + } mod_vals; /* values to add/delete/replace */ +#define mod_values mod_vals.modv_strvals +#define mod_bvalues mod_vals.modv_bvals +} LDAPMod; + + +/* + * structure for holding ldapv3 controls + */ +typedef struct ldapcontrol { + char *ldctl_oid; + struct berval ldctl_value; + char ldctl_iscritical; +} LDAPControl; + + +/* + * LDAP API information. Can be retrieved by using a sequence like: + * + * LDAPAPIInfo ldai; + * ldai.ldapai_info_version = LDAP_API_INFO_VERSION; + * if ( ldap_get_option( NULL, LDAP_OPT_API_INFO, &ldia ) == 0 ) ... + */ +#define LDAP_API_INFO_VERSION 1 +typedef struct ldapapiinfo { + int ldapai_info_version; /* version of this struct (1) */ + int ldapai_api_version; /* revision of API supported */ + int ldapai_protocol_version; /* highest LDAP version supported */ + char **ldapai_extensions; /* names of API extensions */ + char *ldapai_vendor_name; /* name of supplier */ + int ldapai_vendor_version; /* supplier-specific version times 100 */ +} LDAPAPIInfo; + + +/* + * LDAP API extended features info. Can be retrieved by using a sequence like: + * + * LDAPAPIFeatureInfo ldfi; + * ldfi.ldapaif_info_version = LDAP_FEATURE_INFO_VERSION; + * ldfi.ldapaif_name = "VIRTUAL_LIST_VIEW"; + * if ( ldap_get_option( NULL, LDAP_OPT_API_FEATURE_INFO, &ldfi ) == 0 ) ... + */ +#define LDAP_FEATURE_INFO_VERSION 1 +typedef struct ldap_apifeature_info { + int ldapaif_info_version; /* version of this struct (1) */ + char *ldapaif_name; /* name of supported feature */ + int ldapaif_version; /* revision of supported feature */ +} LDAPAPIFeatureInfo; + + +/* possible result types a server can return */ +#define LDAP_RES_BIND 0x61 /* 97 */ +#define LDAP_RES_SEARCH_ENTRY 0x64 /* 100 */ +#define LDAP_RES_SEARCH_RESULT 0x65 /* 101 */ +#define LDAP_RES_MODIFY 0x67 /* 103 */ +#define LDAP_RES_ADD 0x69 /* 105 */ +#define LDAP_RES_DELETE 0x6b /* 107 */ +#define LDAP_RES_MODDN 0x6d /* 109 */ +#define LDAP_RES_COMPARE 0x6f /* 111 */ +#define LDAP_RES_SEARCH_REFERENCE 0x73 /* 115 */ +#define LDAP_RES_EXTENDED 0x78 /* 120 */ + +/* Special values for ldap_result() "msgid" parameter */ +#define LDAP_RES_ANY (-1) +#define LDAP_RES_UNSOLICITED 0 + +/* built-in SASL methods */ +#define LDAP_SASL_SIMPLE 0 /* special value used for simple bind */ +#define LDAP_SASL_EXTERNAL "EXTERNAL" /* TLS/SSL extension */ + +#ifdef _SOLARIS_SDK +#define LDAP_SASL_CRAM_MD5 "CRAM-MD5" +#define LDAP_SASL_DIGEST_MD5 "DIGEST-MD5" +#define LDAP_SASL_BIND_INPROGRESS 0x0e /* for backward compatibility */ +#endif + +/* search scopes */ +#define LDAP_SCOPE_BASE 0x00 +#define LDAP_SCOPE_ONELEVEL 0x01 +#define LDAP_SCOPE_SUBTREE 0x02 + +/* alias dereferencing */ +#define LDAP_DEREF_NEVER 0 +#define LDAP_DEREF_SEARCHING 1 +#define LDAP_DEREF_FINDING 2 +#define LDAP_DEREF_ALWAYS 3 + +/* predefined size/time limits */ +#define LDAP_NO_LIMIT 0 + +/* allowed values for "all" ldap_result() parameter */ +#define LDAP_MSG_ONE 0 +#define LDAP_MSG_ALL 1 +#define LDAP_MSG_RECEIVED 2 + +/* possible error codes we can be returned */ +#define LDAP_SUCCESS 0x00 /* 0 */ +#define LDAP_OPERATIONS_ERROR 0x01 /* 1 */ +#define LDAP_PROTOCOL_ERROR 0x02 /* 2 */ +#define LDAP_TIMELIMIT_EXCEEDED 0x03 /* 3 */ +#define LDAP_SIZELIMIT_EXCEEDED 0x04 /* 4 */ +#define LDAP_COMPARE_FALSE 0x05 /* 5 */ +#define LDAP_COMPARE_TRUE 0x06 /* 6 */ +#define LDAP_STRONG_AUTH_NOT_SUPPORTED 0x07 /* 7 */ +#define LDAP_STRONG_AUTH_REQUIRED 0x08 /* 8 */ +#define LDAP_PARTIAL_RESULTS 0x09 /* 9 (UMich LDAPv2 extn) */ +#define LDAP_REFERRAL 0x0a /* 10 - LDAPv3 */ +#define LDAP_ADMINLIMIT_EXCEEDED 0x0b /* 11 - LDAPv3 */ +#define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* 12 - LDAPv3 */ +#define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* 13 */ +#define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* 14 - LDAPv3 */ + +#define LDAP_NO_SUCH_ATTRIBUTE 0x10 /* 16 */ +#define LDAP_UNDEFINED_TYPE 0x11 /* 17 */ +#define LDAP_INAPPROPRIATE_MATCHING 0x12 /* 18 */ +#define LDAP_CONSTRAINT_VIOLATION 0x13 /* 19 */ +#define LDAP_TYPE_OR_VALUE_EXISTS 0x14 /* 20 */ +#define LDAP_INVALID_SYNTAX 0x15 /* 21 */ + +#define LDAP_NO_SUCH_OBJECT 0x20 /* 32 */ +#define LDAP_ALIAS_PROBLEM 0x21 /* 33 */ +#define LDAP_INVALID_DN_SYNTAX 0x22 /* 34 */ +#define LDAP_IS_LEAF 0x23 /* 35 (not used in LDAPv3) */ +#define LDAP_ALIAS_DEREF_PROBLEM 0x24 /* 36 */ + +#define NAME_ERROR(n) ((n & 0xf0) == 0x20) + +#define LDAP_INAPPROPRIATE_AUTH 0x30 /* 48 */ +#define LDAP_INVALID_CREDENTIALS 0x31 /* 49 */ +#define LDAP_INSUFFICIENT_ACCESS 0x32 /* 50 */ +#define LDAP_BUSY 0x33 /* 51 */ +#define LDAP_UNAVAILABLE 0x34 /* 52 */ +#define LDAP_UNWILLING_TO_PERFORM 0x35 /* 53 */ +#define LDAP_LOOP_DETECT 0x36 /* 54 */ + +#define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 (server side sort extn) */ +#define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 (VLV extn) */ + +#define LDAP_NAMING_VIOLATION 0x40 /* 64 */ +#define LDAP_OBJECT_CLASS_VIOLATION 0x41 /* 65 */ +#define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42 /* 66 */ +#define LDAP_NOT_ALLOWED_ON_RDN 0x43 /* 67 */ +#define LDAP_ALREADY_EXISTS 0x44 /* 68 */ +#define LDAP_NO_OBJECT_CLASS_MODS 0x45 /* 69 */ +#define LDAP_RESULTS_TOO_LARGE 0x46 /* 70 - CLDAP */ +#define LDAP_AFFECTS_MULTIPLE_DSAS 0x47 /* 71 */ + +#define LDAP_OTHER 0x50 /* 80 */ +#define LDAP_SERVER_DOWN 0x51 /* 81 */ +#define LDAP_LOCAL_ERROR 0x52 /* 82 */ +#define LDAP_ENCODING_ERROR 0x53 /* 83 */ +#define LDAP_DECODING_ERROR 0x54 /* 84 */ +#define LDAP_TIMEOUT 0x55 /* 85 */ +#define LDAP_AUTH_UNKNOWN 0x56 /* 86 */ +#define LDAP_FILTER_ERROR 0x57 /* 87 */ +#define LDAP_USER_CANCELLED 0x58 /* 88 */ +#define LDAP_PARAM_ERROR 0x59 /* 89 */ +#define LDAP_NO_MEMORY 0x5a /* 90 */ +#define LDAP_CONNECT_ERROR 0x5b /* 91 */ +#define LDAP_NOT_SUPPORTED 0x5c /* 92 - LDAPv3 */ +#define LDAP_CONTROL_NOT_FOUND 0x5d /* 93 - LDAPv3 */ +#define LDAP_NO_RESULTS_RETURNED 0x5e /* 94 - LDAPv3 */ +#define LDAP_MORE_RESULTS_TO_RETURN 0x5f /* 95 - LDAPv3 */ +#define LDAP_CLIENT_LOOP 0x60 /* 96 - LDAPv3 */ +#define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 /* 97 - LDAPv3 */ + +/* + * LDAPv3 unsolicited notification messages we know about + */ +#define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036" + +/* + * LDAPv3 server controls we know about + */ +#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" +#define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" +#define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" +#define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3" +#define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7" +#define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9" +#define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10" +#define LDAP_CONTROL_PROXYAUTH "2.16.840.1.113730.3.4.12" + /* version 1 */ +#define LDAP_CONTROL_PROXIEDAUTH "2.16.840.1.113730.3.4.18" + /* version 2 */ + +#ifdef _SOLARIS_SDK +/* + * Simple Page control OID + */ +#define LDAP_CONTROL_SIMPLE_PAGE "1.2.840.113556.1.4.319" + +/* + * Begin LDAP Display Template Definitions + */ +#define LDAP_TEMPLATE_VERSION 1 + +/* + * general types of items (confined to most significant byte) + */ +#define LDAP_SYN_TYPE_TEXT 0x01000000L +#define LDAP_SYN_TYPE_IMAGE 0x02000000L +#define LDAP_SYN_TYPE_BOOLEAN 0x04000000L +#define LDAP_SYN_TYPE_BUTTON 0x08000000L +#define LDAP_SYN_TYPE_ACTION 0x10000000L + +/* + * syntax options (confined to second most significant byte) + */ +#define LDAP_SYN_OPT_DEFER 0x00010000L + +/* + * display template item syntax ids (defined by common agreement) + * these are the valid values for the ti_syntaxid of the tmplitem + * struct (defined below). A general type is encoded in the + * most-significant 8 bits, and some options are encoded in the next + * 8 bits. The lower 16 bits are reserved for the distinct types. + */ +#define LDAP_SYN_CASEIGNORESTR (1 | LDAP_SYN_TYPE_TEXT) +#define LDAP_SYN_MULTILINESTR (2 | LDAP_SYN_TYPE_TEXT) +#define LDAP_SYN_DN (3 | LDAP_SYN_TYPE_TEXT) +#define LDAP_SYN_BOOLEAN (4 | LDAP_SYN_TYPE_BOOLEAN) +#define LDAP_SYN_JPEGIMAGE (5 | LDAP_SYN_TYPE_IMAGE) +#define LDAP_SYN_JPEGBUTTON (6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER) +#define LDAP_SYN_FAXIMAGE (7 | LDAP_SYN_TYPE_IMAGE) +#define LDAP_SYN_FAXBUTTON (8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER) +#define LDAP_SYN_AUDIOBUTTON (9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER) +#define LDAP_SYN_TIME (10 | LDAP_SYN_TYPE_TEXT) +#define LDAP_SYN_DATE (11 | LDAP_SYN_TYPE_TEXT) +#define LDAP_SYN_LABELEDURL (12 | LDAP_SYN_TYPE_TEXT) +#define LDAP_SYN_SEARCHACTION (13 | LDAP_SYN_TYPE_ACTION) +#define LDAP_SYN_LINKACTION (14 | LDAP_SYN_TYPE_ACTION) +#define LDAP_SYN_ADDDNACTION (15 | LDAP_SYN_TYPE_ACTION) +#define LDAP_SYN_VERIFYDNACTION (16 | LDAP_SYN_TYPE_ACTION) +#define LDAP_SYN_RFC822ADDR (17 | LDAP_SYN_TYPE_TEXT) + +/* + * handy macros + */ +#define LDAP_GET_SYN_TYPE(syid) ((syid) & 0xFF000000UL) +#define LDAP_GET_SYN_OPTIONS(syid) ((syid) & 0x00FF0000UL) + + +/* + * display options for output routines (used by entry2text and friends) + */ +/* + * use calculated label width (based on length of longest label in + * template) instead of contant width + */ +#define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001L +#define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L + +/* + * perform search actions (applies to ldap_entry2text_search only) + */ +#define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002L + +/* + * include additional info. relevant to "non leaf" entries only + * used by ldap_entry2html and ldap_entry2html_search to include "Browse" + * and "Move Up" HREFs + */ +#define LDAP_DISP_OPT_NONLEAF 0x00000004L + +/* + * display template item options (may not apply to all types) + * if this bit is set in ti_options, it applies. + */ +#define LDAP_DITEM_OPT_READONLY 0x00000001L +#define LDAP_DITEM_OPT_SORTVALUES 0x00000002L +#define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004L +#define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008L +#define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010L +#define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020L /* booleans only */ + +#endif /* _SOLARIS_SDK */ + +/* Authentication request and response controls */ +#define LDAP_CONTROL_AUTH_REQUEST "2.16.840.1.113730.3.4.16" +#define LDAP_CONTROL_AUTH_RESPONSE "2.16.840.1.113730.3.4.15" + +/* Password information sent back to client */ +#define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4" +#define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5" + + +/* + * Client controls we know about + */ +#define LDAP_CONTROL_REFERRALS "1.2.840.113556.1.4.616" + + +/* + * LDAP_API macro definition: + */ +#ifndef LDAP_API +#define LDAP_API(rt) rt +#endif /* LDAP_API */ + +#ifdef _SOLARIS_SDK +/* Simple Page Control functions for Solaris SDK */ +int ldap_create_page_control(LDAP *ld, unsigned int pagesize, + struct berval *cookie, char isCritical, LDAPControl **output); +int ldap_parse_page_control(LDAP *ld, LDAPControl **controls, + unsigned int *totalcount, struct berval **cookie); + +/* CRAM-MD5 functions */ +int ldap_sasl_cram_md5_bind_s(LDAP *ld, char *dn, + struct berval *cred, LDAPControl **serverctrls, + LDAPControl **clientctrls); +/* DIGEST-MD5 Function */ +int ldap_x_sasl_digest_md5_bind_s(LDAP *ld, char *dn, + struct berval *cred, LDAPControl **serverctrls, + LDAPControl **clientctrls); +int ldap_x_sasl_digest_md5_bind(LDAP *ld, char *dn, + struct berval *cred, LDAPControl **serverctrls, + LDAPControl **clientctrls, struct timeval *timeout, + LDAPMessage **result); + +#endif /* _SOLARIS_SDK */ + +LDAP_API(LDAP *) LDAP_CALL ldap_open(const char *host, int port); +LDAP_API(LDAP *) LDAP_CALL ldap_init(const char *defhost, int defport); +int LDAP_CALL ldap_set_option(LDAP *ld, int option, + const void *optdata); +int LDAP_CALL ldap_get_option(LDAP *ld, int option, void *optdata); +int LDAP_CALL ldap_unbind(LDAP *ld); +int LDAP_CALL ldap_unbind_s(LDAP *ld); + +/* + * perform ldap operations and obtain results + */ +int LDAP_CALL ldap_abandon(LDAP *ld, int msgid); +int LDAP_CALL ldap_add(LDAP *ld, const char *dn, LDAPMod **attrs); +int LDAP_CALL ldap_add_s(LDAP *ld, const char *dn, LDAPMod **attrs); +int LDAP_CALL ldap_simple_bind(LDAP *ld, const char *who, + const char *passwd); +int LDAP_CALL ldap_simple_bind_s(LDAP *ld, const char *who, + const char *passwd); +int LDAP_CALL ldap_modify(LDAP *ld, const char *dn, LDAPMod **mods); +int LDAP_CALL ldap_modify_s(LDAP *ld, const char *dn, + LDAPMod **mods); +int LDAP_CALL ldap_modrdn(LDAP *ld, const char *dn, + const char *newrdn); +int LDAP_CALL ldap_modrdn_s(LDAP *ld, const char *dn, + const char *newrdn); + +/* The following 2 functions are deprecated */ +int LDAP_CALL ldap_modrdn2(LDAP *ld, const char *dn, + const char *newrdn, int deleteoldrdn); +int LDAP_CALL ldap_modrdn2_s(LDAP *ld, const char *dn, + const char *newrdn, int deleteoldrdn); + +int LDAP_CALL ldap_compare(LDAP *ld, const char *dn, + const char *attr, const char *value); +int LDAP_CALL ldap_compare_s(LDAP *ld, const char *dn, + const char *attr, const char *value); +int LDAP_CALL ldap_delete(LDAP *ld, const char *dn); +int LDAP_CALL ldap_delete_s(LDAP *ld, const char *dn); +int LDAP_CALL ldap_search(LDAP *ld, const char *base, int scope, + const char *filter, char **attrs, int attrsonly); +int LDAP_CALL ldap_search_s(LDAP *ld, const char *base, int scope, + const char *filter, char **attrs, int attrsonly, LDAPMessage **res); +int LDAP_CALL ldap_search_st(LDAP *ld, const char *base, int scope, + const char *filter, char **attrs, int attrsonly, + struct timeval *timeout, LDAPMessage **res); +int LDAP_CALL ldap_result(LDAP *ld, int msgid, int all, + struct timeval *timeout, LDAPMessage **result); +int LDAP_CALL ldap_msgfree(LDAPMessage *lm); +int LDAP_CALL ldap_msgid(LDAPMessage *lm); +int LDAP_CALL ldap_msgtype(LDAPMessage *lm); + + +/* + * Routines to parse/deal with results and errors returned + */ +int LDAP_CALL ldap_result2error(LDAP *ld, LDAPMessage *r, + int freeit); +char *LDAP_CALL ldap_err2string(int err); +LDAP_API(void) LDAP_CALL ldap_perror(LDAP *ld, const char *s); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_entry(LDAP *ld, + LDAPMessage *chain); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_entry(LDAP *ld, + LDAPMessage *entry); +int LDAP_CALL ldap_count_entries(LDAP *ld, LDAPMessage *chain); +char *LDAP_CALL ldap_get_dn(LDAP *ld, LDAPMessage *entry); +char *LDAP_CALL ldap_dn2ufn(const char *dn); +char **LDAP_CALL ldap_explode_dn(const char *dn, + const int notypes); +char **LDAP_CALL ldap_explode_rdn(const char *rdn, + const int notypes); +char *LDAP_CALL ldap_first_attribute(LDAP *ld, LDAPMessage *entry, + BerElement **ber); +char *LDAP_CALL ldap_next_attribute(LDAP *ld, LDAPMessage *entry, + BerElement *ber); + +/* The following function is deprecated */ +LDAP_API(void) LDAP_CALL ldap_ber_free(BerElement *ber, int freebuf); + +char **LDAP_CALL ldap_get_values(LDAP *ld, LDAPMessage *entry, + const char *target); +struct berval **LDAP_CALL ldap_get_values_len(LDAP *ld, + LDAPMessage *entry, const char *target); +int LDAP_CALL ldap_count_values(char **vals); +int LDAP_CALL ldap_count_values_len(struct berval **vals); +LDAP_API(void) LDAP_CALL ldap_value_free(char **vals); +LDAP_API(void) LDAP_CALL ldap_value_free_len(struct berval **vals); +LDAP_API(void) LDAP_CALL ldap_memfree(void *p); + + +/* + * LDAPv3 extended operation calls + */ +/* + * Note: all of the new asynchronous calls return an LDAP error code, + * not a message id. A message id is returned via the int *msgidp + * parameter (usually the last parameter) if appropriate. + */ +int LDAP_CALL ldap_abandon_ext(LDAP *ld, int msgid, + LDAPControl **serverctrls, LDAPControl **clientctrls); +int LDAP_CALL ldap_add_ext(LDAP *ld, const char *dn, LDAPMod **attrs, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); +int LDAP_CALL ldap_add_ext_s(LDAP *ld, const char *dn, + LDAPMod **attrs, LDAPControl **serverctrls, LDAPControl **clientctrls); +int LDAP_CALL ldap_sasl_bind(LDAP *ld, const char *dn, + const char *mechanism, const struct berval *cred, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); +int LDAP_CALL ldap_sasl_bind_s(LDAP *ld, const char *dn, + const char *mechanism, const struct berval *cred, + LDAPControl **serverctrls, LDAPControl **clientctrls, + struct berval **servercredp); +int LDAP_CALL ldap_modify_ext(LDAP *ld, const char *dn, + LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls, + int *msgidp); +int LDAP_CALL ldap_modify_ext_s(LDAP *ld, const char *dn, + LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls); +int LDAP_CALL ldap_rename(LDAP *ld, const char *dn, + const char *newrdn, const char *newparent, int deleteoldrdn, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); +int LDAP_CALL ldap_rename_s(LDAP *ld, const char *dn, + const char *newrdn, const char *newparent, int deleteoldrdn, + LDAPControl **serverctrls, LDAPControl **clientctrls); +int LDAP_CALL ldap_compare_ext(LDAP *ld, const char *dn, + const char *attr, const struct berval *bvalue, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); +int LDAP_CALL ldap_compare_ext_s(LDAP *ld, const char *dn, + const char *attr, const struct berval *bvalue, + LDAPControl **serverctrls, LDAPControl **clientctrls); +int LDAP_CALL ldap_delete_ext(LDAP *ld, const char *dn, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); +int LDAP_CALL ldap_delete_ext_s(LDAP *ld, const char *dn, + LDAPControl **serverctrls, LDAPControl **clientctrls); +int LDAP_CALL ldap_search_ext(LDAP *ld, const char *base, + int scope, const char *filter, char **attrs, int attrsonly, + LDAPControl **serverctrls, LDAPControl **clientctrls, + struct timeval *timeoutp, int sizelimit, int *msgidp); +int LDAP_CALL ldap_search_ext_s(LDAP *ld, const char *base, + int scope, const char *filter, char **attrs, int attrsonly, + LDAPControl **serverctrls, LDAPControl **clientctrls, + struct timeval *timeoutp, int sizelimit, LDAPMessage **res); +int LDAP_CALL ldap_extended_operation(LDAP *ld, + const char *requestoid, const struct berval *requestdata, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); +int LDAP_CALL ldap_extended_operation_s(LDAP *ld, + const char *requestoid, const struct berval *requestdata, + LDAPControl **serverctrls, LDAPControl **clientctrls, + char **retoidp, struct berval **retdatap); +int LDAP_CALL ldap_unbind_ext(LDAP *ld, LDAPControl **serverctrls, + LDAPControl **clientctrls); + + +/* + * LDAPv3 extended parsing / result handling calls + */ +int LDAP_CALL ldap_parse_sasl_bind_result(LDAP *ld, + LDAPMessage *res, struct berval **servercredp, int freeit); +int LDAP_CALL ldap_parse_result(LDAP *ld, LDAPMessage *res, + int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp, + LDAPControl ***serverctrlsp, int freeit); +int LDAP_CALL ldap_parse_extended_result(LDAP *ld, LDAPMessage *res, + char **retoidp, struct berval **retdatap, int freeit); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_message(LDAP *ld, + LDAPMessage *res); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_message(LDAP *ld, + LDAPMessage *msg); +int LDAP_CALL ldap_count_messages(LDAP *ld, LDAPMessage *res); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_reference(LDAP *ld, + LDAPMessage *res); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_reference(LDAP *ld, + LDAPMessage *ref); +int LDAP_CALL ldap_count_references(LDAP *ld, LDAPMessage *res); +int LDAP_CALL ldap_parse_reference(LDAP *ld, LDAPMessage *ref, + char ***referralsp, LDAPControl ***serverctrlsp, int freeit); +int LDAP_CALL ldap_get_entry_controls(LDAP *ld, LDAPMessage *entry, + LDAPControl ***serverctrlsp); +LDAP_API(void) LDAP_CALL ldap_control_free(LDAPControl *ctrl); +LDAP_API(void) LDAP_CALL ldap_controls_free(LDAPControl **ctrls); + +#ifdef _SOLARIS_SDK +char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res); +#endif + +LDAP_API(void) LDAP_CALL ldap_add_result_entry( + LDAPMessage **list, LDAPMessage *e); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_delete_result_entry( + LDAPMessage **list, LDAPMessage *e); + + +/* End of core standard C LDAP API definitions */ + +/* + * Server side sorting of search results (an LDAPv3 extension -- + * LDAP_API_FEATURE_SERVER_SIDE_SORT) + */ +typedef struct LDAPsortkey { /* structure for a sort-key */ + char *sk_attrtype; + char *sk_matchruleoid; + int sk_reverseorder; +} LDAPsortkey; + +int LDAP_CALL ldap_create_sort_control(LDAP *ld, + LDAPsortkey **sortKeyList, const char ctl_iscritical, + LDAPControl **ctrlp); +int LDAP_CALL ldap_parse_sort_control(LDAP *ld, + LDAPControl **ctrls, unsigned long *result, char **attribute); + +LDAP_API(void) LDAP_CALL ldap_free_sort_keylist(LDAPsortkey **sortKeyList); +int LDAP_CALL ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, + const char *string_rep); + + +/* + * Virtual list view (an LDAPv3 extension -- LDAP_API_FEATURE_VIRTUAL_LIST_VIEW) + */ +/* + * structure that describes a VirtualListViewRequest control. + * note that ldvlist_index and ldvlist_size are only relevant to + * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL. + */ +typedef struct ldapvirtuallist { + unsigned long ldvlist_before_count; /* # entries before target */ + unsigned long ldvlist_after_count; /* # entries after target */ + char *ldvlist_attrvalue; /* jump to this value */ + unsigned long ldvlist_index; /* list offset */ + unsigned long ldvlist_size; /* number of items in vlist */ + void *ldvlist_extradata; /* for use by application */ +} LDAPVirtualList; + +/* + * VLV functions: + */ +int LDAP_CALL ldap_create_virtuallist_control(LDAP *ld, + LDAPVirtualList *ldvlistp, LDAPControl **ctrlp); + +int LDAP_CALL ldap_parse_virtuallist_control(LDAP *ld, + LDAPControl **ctrls, unsigned long *target_posp, + unsigned long *list_sizep, int *errcodep); + + +/* + * Routines for creating persistent search controls and for handling + * "entry changed notification" controls (an LDAPv3 extension -- + * LDAP_API_FEATURE_PERSISTENT_SEARCH) + */ +#define LDAP_CHANGETYPE_ADD 1 +#define LDAP_CHANGETYPE_DELETE 2 +#define LDAP_CHANGETYPE_MODIFY 4 +#define LDAP_CHANGETYPE_MODDN 8 +#define LDAP_CHANGETYPE_ANY (1|2|4|8) +int LDAP_CALL ldap_create_persistentsearch_control(LDAP *ld, + int changetypes, int changesonly, int return_echg_ctls, + char ctl_iscritical, LDAPControl **ctrlp); +int LDAP_CALL ldap_parse_entrychange_control(LDAP *ld, + LDAPControl **ctrls, int *chgtypep, char **prevdnp, + int *chgnumpresentp, ber_int_t *chgnump); + + +/* + * Routines for creating Proxied Authorization controls (an LDAPv3 + * extension -- LDAP_API_FEATURE_PROXY_AUTHORIZATION) + * ldap_create_proxyauth_control() is for the old (version 1) control. + * ldap_create_proxiedauth_control() is for the newer (version 2) control. + * Version 1 is supported by iPlanet Directory Server 4.1 and later. + * Version 2 is supported by iPlanet Directory Server 5.0 and later. + */ +int LDAP_CALL ldap_create_proxyauth_control(LDAP *ld, + const char *dn, const char ctl_iscritical, LDAPControl **ctrlp); +int LDAP_CALL ldap_create_proxiedauth_control(LDAP *ld, + const char *authzid, LDAPControl **ctrlp); + + +/* + * Functions to get and set LDAP error information (API extension -- + * LDAP_API_FEATURE_X_LDERRNO ) + */ +int LDAP_CALL ldap_get_lderrno(LDAP *ld, char **m, char **s); +int LDAP_CALL ldap_set_lderrno(LDAP *ld, int e, char *m, char *s); + + +/* + * LDAP URL functions and definitions (an API extension -- + * LDAP_API_FEATURE_X_URL_FUNCTIONS) + */ +/* + * types for ldap URL handling + */ +typedef struct ldap_url_desc { + char *lud_host; + int lud_port; + char *lud_dn; + char **lud_attrs; + int lud_scope; + char *lud_filter; + unsigned long lud_options; +#define LDAP_URL_OPT_SECURE 0x01 + char *lud_string; /* for internal use only */ +} LDAPURLDesc; + +#define NULLLDAPURLDESC ((LDAPURLDesc *)NULL) + +/* + * possible errors returned by ldap_url_parse() + */ +#define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */ +#define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */ +#define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */ +#define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */ +#define LDAP_URL_ERR_PARAM 5 /* bad parameter to an URL function */ +#define LDAP_URL_ERR_HOSTPORT 6 /* URL hostcode is invalid */ + +/* + * URL functions: + */ +int LDAP_CALL ldap_is_ldap_url(const char *url); +int LDAP_CALL ldap_url_parse(const char *url, LDAPURLDesc **ludpp); +int LDAP_CALL ldap_url_parse_nodn(const char *url, LDAPURLDesc **ludpp); +LDAP_API(void) LDAP_CALL ldap_free_urldesc(LDAPURLDesc *ludp); +int LDAP_CALL ldap_url_search(LDAP *ld, const char *url, + int attrsonly); +int LDAP_CALL ldap_url_search_s(LDAP *ld, const char *url, + int attrsonly, LDAPMessage **res); +int LDAP_CALL ldap_url_search_st(LDAP *ld, const char *url, + int attrsonly, struct timeval *timeout, LDAPMessage **res); + +#ifdef _SOLARIS_SDK +/* + * Additional URL functions plus Character set, Search Preference + * and Display Template functions moved from internal header files + */ + +/* + * URL functions + */ +char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs, + char *scope, char *filter); +char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts); + +/* + * Character set functions + */ +#ifdef STR_TRANSLATION +void ldap_set_string_translators(LDAP *ld, + BERTranslateProc encode_proc, BERTranslateProc decode_proc); +int ldap_translate_from_t61(LDAP *ld, char **bufp, + unsigned long *lenp, int free_input); +int ldap_translate_to_t61(LDAP *ld, char **bufp, + unsigned long *lenp, int free_input); +void ldap_enable_translation(LDAP *ld, LDAPMessage *entry, + int enable); +#ifdef LDAP_CHARSET_8859 +int ldap_t61_to_8859(char **bufp, unsigned long *buflenp, + int free_input); +int ldap_8859_to_t61(char **bufp, unsigned long *buflenp, + int free_input); +#endif /* LDAP_CHARSET_8859 */ +#endif /* STR_TRANSLATION */ + +/* + * Display Temple functions/structures + */ +/* + * display template item structure + */ +struct ldap_tmplitem { + unsigned long ti_syntaxid; + unsigned long ti_options; + char *ti_attrname; + char *ti_label; + char **ti_args; + struct ldap_tmplitem *ti_next_in_row; + struct ldap_tmplitem *ti_next_in_col; + void *ti_appdata; +}; + +#define NULLTMPLITEM ((struct ldap_tmplitem *)0) + +#define LDAP_SET_TMPLITEM_APPDATA(ti, datap) \ + (ti)->ti_appdata = (void *)(datap) + +#define LDAP_GET_TMPLITEM_APPDATA(ti, type) \ + (type)((ti)->ti_appdata) + +#define LDAP_IS_TMPLITEM_OPTION_SET(ti, option) \ + (((ti)->ti_options & option) != 0) + +/* + * object class array structure + */ +struct ldap_oclist { + char **oc_objclasses; + struct ldap_oclist *oc_next; +}; + +#define NULLOCLIST ((struct ldap_oclist *)0) + + +/* + * add defaults list + */ +struct ldap_adddeflist { + int ad_source; +#define LDAP_ADSRC_CONSTANTVALUE 1 +#define LDAP_ADSRC_ADDERSDN 2 + char *ad_attrname; + char *ad_value; + struct ldap_adddeflist *ad_next; +}; + +#define NULLADLIST ((struct ldap_adddeflist *)0) + + +/* + * display template global options + * if this bit is set in dt_options, it applies. + */ +/* + * users should be allowed to try to add objects of these entries + */ +#define LDAP_DTMPL_OPT_ADDABLE 0x00000001L + +/* + * users should be allowed to do "modify RDN" operation of these entries + */ +#define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L + +/* + * this template is an alternate view, not a primary view + */ +#define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L + + +/* + * display template structure + */ +struct ldap_disptmpl { + char *dt_name; + char *dt_pluralname; + char *dt_iconname; + unsigned long dt_options; + char *dt_authattrname; + char *dt_defrdnattrname; + char *dt_defaddlocation; + struct ldap_oclist *dt_oclist; + struct ldap_adddeflist *dt_adddeflist; + struct ldap_tmplitem *dt_items; + void *dt_appdata; + struct ldap_disptmpl *dt_next; +}; + +#define NULLDISPTMPL ((struct ldap_disptmpl *)0) + +#define LDAP_SET_DISPTMPL_APPDATA(dt, datap) \ + (dt)->dt_appdata = (void *)(datap) + +#define LDAP_GET_DISPTMPL_APPDATA(dt, type) \ + (type)((dt)->dt_appdata) + +#define LDAP_IS_DISPTMPL_OPTION_SET(dt, option) \ + (((dt)->dt_options & option) != 0) + +#define LDAP_TMPL_ERR_VERSION 1 +#define LDAP_TMPL_ERR_MEM 2 +#define LDAP_TMPL_ERR_SYNTAX 3 +#define LDAP_TMPL_ERR_FILE 4 + +/* + * buffer size needed for entry2text and vals2text + */ +#define LDAP_DTMPL_BUFSIZ 8192 + +typedef int (*writeptype)(void *writeparm, char *p, int len); + +LDAP_API(int) LDAP_CALL ldap_init_templates(char *file, + struct ldap_disptmpl **tmpllistp); + +LDAP_API(int) LDAP_CALL ldap_init_templates_buf(char *buf, long buflen, + struct ldap_disptmpl **tmpllistp); + +LDAP_API(void) LDAP_CALL ldap_free_templates(struct ldap_disptmpl *tmpllist); + +LDAP_API(struct ldap_disptmpl *) LDAP_CALL ldap_first_disptmpl( + struct ldap_disptmpl *tmpllist); + +LDAP_API(struct ldap_disptmpl *) LDAP_CALL ldap_next_disptmpl( + struct ldap_disptmpl *tmpllist, + struct ldap_disptmpl *tmpl); + +LDAP_API(struct ldap_disptmpl *) LDAP_CALL ldap_name2template(char *name, + struct ldap_disptmpl *tmpllist); + +LDAP_API(struct ldap_disptmpl *) LDAP_CALL ldap_oc2template(char **oclist, + struct ldap_disptmpl *tmpllist); + +LDAP_API(char **) LDAP_CALL ldap_tmplattrs(struct ldap_disptmpl *tmpl, + char **includeattrs, int exclude, + unsigned long syntaxmask); + +LDAP_API(struct ldap_tmplitem *) LDAP_CALL ldap_first_tmplrow( + struct ldap_disptmpl *tmpl); + +LDAP_API(struct ldap_tmplitem *) LDAP_CALL ldap_next_tmplrow( + struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row); + +LDAP_API(struct ldap_tmplitem *) LDAP_CALL ldap_first_tmplcol( + struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row); + +LDAP_API(struct ldap_tmplitem *) LDAP_CALL ldap_next_tmplcol( + struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, + struct ldap_tmplitem *col); + +LDAP_API(int) LDAP_CALL ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry, + struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, + writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts); + +LDAP_API(int) LDAP_CALL ldap_vals2text(LDAP *ld, char *buf, char **vals, + char *label, int labelwidth, + unsigned long syntaxid, writeptype writeproc, void *writeparm, + char *eol, int rdncount); + +LDAP_API(int) LDAP_CALL ldap_entry2text_search(LDAP *ld, char *dn, char *base, + LDAPMessage *entry, + struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, + writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts); + +LDAP_API(int) LDAP_CALL ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry, + struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, + writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts, char *urlprefix, char *base); + +LDAP_API(int) LDAP_CALL ldap_vals2html(LDAP *ld, char *buf, char **vals, + char *label, int labelwidth, + unsigned long syntaxid, writeptype writeproc, void *writeparm, + char *eol, int rdncount, char *urlprefix); + +LDAP_API(int) LDAP_CALL ldap_entry2html_search(LDAP *ld, char *dn, char *base, + LDAPMessage *entry, + struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, + writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts, char *urlprefix); + +/* + * Search Preference Definitions + */ + +struct ldap_searchattr { + char *sa_attrlabel; + char *sa_attr; + /* max 32 matchtypes for now */ + unsigned long sa_matchtypebitmap; + char *sa_selectattr; + char *sa_selecttext; + struct ldap_searchattr *sa_next; +}; + +struct ldap_searchmatch { + char *sm_matchprompt; + char *sm_filter; + struct ldap_searchmatch *sm_next; +}; + +struct ldap_searchobj { + char *so_objtypeprompt; + unsigned long so_options; + char *so_prompt; + short so_defaultscope; + char *so_filterprefix; + char *so_filtertag; + char *so_defaultselectattr; + char *so_defaultselecttext; + struct ldap_searchattr *so_salist; + struct ldap_searchmatch *so_smlist; + struct ldap_searchobj *so_next; +}; + +#define NULLSEARCHOBJ ((struct ldap_searchobj *)0) + +/* + * global search object options + */ +#define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001 + +#define LDAP_IS_SEARCHOBJ_OPTION_SET(so, option) \ + (((so)->so_options & option) != 0) + +#define LDAP_SEARCHPREF_VERSION_ZERO 0 +#define LDAP_SEARCHPREF_VERSION 1 + +#define LDAP_SEARCHPREF_ERR_VERSION 1 +#define LDAP_SEARCHPREF_ERR_MEM 2 +#define LDAP_SEARCHPREF_ERR_SYNTAX 3 +#define LDAP_SEARCHPREF_ERR_FILE 4 + +LDAP_API(int) LDAP_CALL ldap_init_searchprefs(char *file, + struct ldap_searchobj **solistp); + +LDAP_API(int) LDAP_CALL ldap_init_searchprefs_buf(char *buf, long buflen, + struct ldap_searchobj **solistp); + +LDAP_API(void) LDAP_CALL ldap_free_searchprefs(struct ldap_searchobj *solist); + +LDAP_API(struct ldap_searchobj *) LDAP_CALL ldap_first_searchobj( + struct ldap_searchobj *solist); + +LDAP_API(struct ldap_searchobj *) LDAP_CALL ldap_next_searchobj( + struct ldap_searchobj *sollist, struct ldap_searchobj *so); + +/* + * specific LDAP instantiations of BER types we know about + */ + +/* general stuff */ +#define LDAP_TAG_MESSAGE 0x30 /* tag is 16 + constructed bit */ +#define LDAP_TAG_MSGID 0x02 /* INTEGER */ +#define LDAP_TAG_CONTROLS 0xa0 /* context specific + constructed + 0 */ +#define LDAP_TAG_REFERRAL 0xa3 /* context specific + constructed + 3 */ +#define LDAP_TAG_NEWSUPERIOR 0x80 /* context specific + primitive + 0 */ +#define LDAP_TAG_SASL_RES_CREDS 0x87 /* context specific + primitive + 7 */ +#define LDAP_TAG_VLV_BY_INDEX 0xa0 /* context specific + constructed + 0 */ +#define LDAP_TAG_VLV_BY_VALUE 0x81 /* context specific + primitive + 1 */ +/* tag for sort control */ +#define LDAP_TAG_SK_MATCHRULE 0x80L /* context specific + primitive + 0 */ +#define LDAP_TAG_SK_REVERSE 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_SR_ATTRTYPE 0x80L /* context specific + primitive + 0 */ + +/* possible operations a client can invoke */ +#define LDAP_REQ_BIND 0x60 /* application + constructed + 0 */ +#define LDAP_REQ_UNBIND 0x42 /* application + primitive + 2 */ +#define LDAP_REQ_SEARCH 0x63 /* application + constructed + 3 */ +#define LDAP_REQ_MODIFY 0x66 /* application + constructed + 6 */ +#define LDAP_REQ_ADD 0x68 /* application + constructed + 8 */ +#define LDAP_REQ_DELETE 0x4a /* application + primitive + 10 */ +#define LDAP_REQ_MODRDN 0x6c /* application + constructed + 12 */ +#define LDAP_REQ_MODDN 0x6c /* application + constructed + 12 */ +#define LDAP_REQ_RENAME 0x6c /* application + constructed + 12 */ +#define LDAP_REQ_COMPARE 0x6e /* application + constructed + 14 */ +#define LDAP_REQ_ABANDON 0x50 /* application + primitive + 16 */ +#define LDAP_REQ_EXTENDED 0x77 /* application + constructed + 23 */ + +/* U-M LDAP release 3.0 compatibility stuff */ +#define LDAP_REQ_UNBIND_30 0x62 +#define LDAP_REQ_DELETE_30 0x6a +#define LDAP_REQ_ABANDON_30 0x70 + +/* U-M LDAP 3.0 compatibility auth methods */ +#define LDAP_AUTH_SIMPLE_30 0xa0 /* context specific + constructed */ +#define LDAP_AUTH_KRBV41_30 0xa1 /* context specific + constructed */ +#define LDAP_AUTH_KRBV42_30 0xa2 /* context specific + constructed */ + +/* filter types */ +#define LDAP_FILTER_AND 0xa0 /* context specific + constructed + 0 */ +#define LDAP_FILTER_OR 0xa1 /* context specific + constructed + 1 */ +#define LDAP_FILTER_NOT 0xa2 /* context specific + constructed + 2 */ +#define LDAP_FILTER_EQUALITY 0xa3 /* context specific + constructed + 3 */ +#define LDAP_FILTER_SUBSTRINGS 0xa4 /* context specific + constructed + 4 */ +#define LDAP_FILTER_GE 0xa5 /* context specific + constructed + 5 */ +#define LDAP_FILTER_LE 0xa6 /* context specific + constructed + 6 */ +#define LDAP_FILTER_PRESENT 0x87 /* context specific + primitive + 7 */ +#define LDAP_FILTER_APPROX 0xa8 /* context specific + constructed + 8 */ +#define LDAP_FILTER_EXTENDED 0xa9 /* context specific + constructed + 0 */ + +/* U-M LDAP 3.0 compatibility filter types */ +#define LDAP_FILTER_PRESENT_30 0xa7 /* context specific + constructed */ + +/* substring filter component types */ +#define LDAP_SUBSTRING_INITIAL 0x80 /* context specific + primitive + 0 */ +#define LDAP_SUBSTRING_ANY 0x81 /* context specific + primitive + 1 */ +#define LDAP_SUBSTRING_FINAL 0x82 /* context specific + primitive + 2 */ + +/* U-M LDAP 3.0 compatibility substring filter component types */ +#define LDAP_SUBSTRING_INITIAL_30 0xa0 /* context specific */ +#define LDAP_SUBSTRING_ANY_30 0xa1 /* context specific */ +#define LDAP_SUBSTRING_FINAL_30 0xa2 /* context specific */ + +#endif /* _SOLARIS_SDK */ + +/* + * Function to dispose of an array of LDAPMod structures (an API extension). + * Warning: don't use this unless the mods array was allocated using the + * same memory allocator as is being used by libldap. + */ +LDAP_API(void) LDAP_CALL ldap_mods_free(LDAPMod **mods, int freemods); + +/* + * Preferred language and get_lang_values (an API extension -- + * LDAP_API_FEATURE_X_GETLANGVALUES) + * + * The following two APIs are deprecated + */ + +char **LDAP_CALL ldap_get_lang_values(LDAP *ld, LDAPMessage *entry, + const char *target, char **type); +struct berval **LDAP_CALL ldap_get_lang_values_len(LDAP *ld, + LDAPMessage *entry, const char *target, char **type); + + +/* + * Rebind callback function (an API extension) + */ +#define LDAP_OPT_REBIND_FN 0x06 /* 6 - API extension */ +#define LDAP_OPT_REBIND_ARG 0x07 /* 7 - API extension */ +typedef int (LDAP_CALL LDAP_CALLBACK LDAP_REBINDPROC_CALLBACK)(LDAP *ld, + char **dnp, char **passwdp, int *authmethodp, int freeit, void *arg); +LDAP_API(void) LDAP_CALL ldap_set_rebind_proc(LDAP *ld, + LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg); + +/* + * Thread function callbacks (an API extension -- + * LDAP_API_FEATURE_X_THREAD_FUNCTIONS). + */ +#define LDAP_OPT_THREAD_FN_PTRS 0x05 /* 5 - API extension */ + +/* + * Thread callback functions: + */ +typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_ALLOC_CALLBACK)(void); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_FREE_CALLBACK)(void *m); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_LOCK_CALLBACK)(void *m); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_UNLOCK_CALLBACK)(void *m); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_ERRNO_CALLBACK)(void); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_ERRNO_CALLBACK)(int e); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_LDERRNO_CALLBACK)( + char **matchedp, char **errmsgp, void *arg); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_LDERRNO_CALLBACK)(int err, + char *matched, char *errmsg, void *arg); + +/* + * Structure to hold thread function pointers: + */ +struct ldap_thread_fns { + LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc; + LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free; + LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock; + LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock; + LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno; + LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno; + LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno; + LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno; + void *ltf_lderrno_arg; +}; + +/* + * Client side sorting of entries (an API extension -- + * LDAP_API_FEATURE_X_CLIENT_SIDE_SORT) + */ +/* + * Client side sorting callback functions: + */ +typedef const struct berval *(LDAP_C LDAP_CALLBACK + LDAP_KEYGEN_CALLBACK)(void *arg, LDAP *ld, LDAPMessage *entry); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_KEYCMP_CALLBACK)(void *arg, const struct berval *, + const struct berval *); +typedef void (LDAP_C LDAP_CALLBACK + LDAP_KEYFREE_CALLBACK)(void *arg, const struct berval *); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_CMP_CALLBACK)(const char *val1, const char *val2); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_VALCMP_CALLBACK)(const char **val1p, const char **val2p); + +/* + * Client side sorting functions: + */ +int LDAP_CALL ldap_multisort_entries(LDAP *ld, LDAPMessage **chain, + char **attr, LDAP_CMP_CALLBACK *cmp); +int LDAP_CALL ldap_sort_entries(LDAP *ld, LDAPMessage **chain, + char *attr, LDAP_CMP_CALLBACK *cmp); +int LDAP_CALL ldap_sort_values(LDAP *ld, char **vals, + LDAP_VALCMP_CALLBACK *cmp); +int LDAP_C LDAP_CALLBACK ldap_sort_strcasecmp(const char **a, + const char **b); + + +/* + * Filter functions and definitions (an API extension -- + * LDAP_API_FEATURE_X_FILTER_FUNCTIONS) + */ +/* + * Structures, constants, and types for filter utility routines: + */ +typedef struct ldap_filt_info { + char *lfi_filter; + char *lfi_desc; + int lfi_scope; /* LDAP_SCOPE_BASE, etc */ + int lfi_isexact; /* exact match filter? */ + struct ldap_filt_info *lfi_next; +} LDAPFiltInfo; + +#define LDAP_FILT_MAXSIZ 1024 + +typedef struct ldap_filt_list LDAPFiltList; /* opaque filter list handle */ +typedef struct ldap_filt_desc LDAPFiltDesc; /* opaque filter desc handle */ + +/* + * Filter utility functions: + */ +LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter(char *fname); +LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter_buf(char *buf, + ssize_t buflen); +LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getfirstfilter(LDAPFiltDesc *lfdp, + char *tagpat, char *value); +LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getnextfilter(LDAPFiltDesc *lfdp); +int LDAP_CALL ldap_set_filter_additions(LDAPFiltDesc *lfdp, + char *prefix, char *suffix); +int LDAP_CALL ldap_create_filter(char *buf, unsigned long buflen, + char *pattern, char *prefix, char *suffix, char *attr, + char *value, char **valwords); +LDAP_API(void) LDAP_CALL ldap_getfilter_free(LDAPFiltDesc *lfdp); + + +/* + * Friendly mapping structure and routines (an API extension) + */ +typedef struct friendly { + char *f_unfriendly; + char *f_friendly; +} *FriendlyMap; +char *LDAP_CALL ldap_friendly_name(char *filename, char *name, + FriendlyMap *map); +LDAP_API(void) LDAP_CALL ldap_free_friendlymap(FriendlyMap *map); + + +/* + * In Memory Cache (an API extension -- LDAP_API_FEATURE_X_MEMCACHE) + */ +typedef struct ldapmemcache LDAPMemCache; /* opaque in-memory cache handle */ + +int LDAP_CALL ldap_memcache_init(unsigned long ttl, + unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns, + LDAPMemCache **cachep); +int LDAP_CALL ldap_memcache_set(LDAP *ld, LDAPMemCache *cache); +int LDAP_CALL ldap_memcache_get(LDAP *ld, LDAPMemCache **cachep); +LDAP_API(void) LDAP_CALL ldap_memcache_flush(LDAPMemCache *cache, char *dn, + int scope); +LDAP_API(void) LDAP_CALL ldap_memcache_destroy(LDAPMemCache *cache); +LDAP_API(void) LDAP_CALL ldap_memcache_update(LDAPMemCache *cache); + +/* + * Server reconnect (an API extension). + */ +#define LDAP_OPT_RECONNECT 0x62 /* 98 - API extension */ + +/* + * Asynchronous I/O (an API extension). + */ +/* + * This option enables completely asynchronous IO. It works by using ioctl() + * on the fd, (or tlook()) + */ +#define LDAP_OPT_ASYNC_CONNECT 0x63 /* 99 - API extension */ + +/* + * I/O function callbacks option (an API extension -- + * LDAP_API_FEATURE_X_IO_FUNCTIONS). + * Use of the extended I/O functions instead is recommended; see above. + */ +#define LDAP_OPT_IO_FN_PTRS 0x0B /* 11 - API extension */ + +/* + * Extended I/O function callbacks option (an API extension -- + * LDAP_API_FEATURE_X_EXTIO_FUNCTIONS). + */ +#define LDAP_X_OPT_EXTIO_FN_PTRS (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F00) + /* 0x4000 + 0x0F00 = 0x4F00 = 20224 - API extension */ + + + +/* + * generalized bind + */ +/* + * Authentication methods: + */ +#define LDAP_AUTH_NONE 0x00 +#define LDAP_AUTH_SIMPLE 0x80 +#define LDAP_AUTH_SASL 0xa3 +int LDAP_CALL ldap_bind(LDAP *ld, const char *who, + const char *passwd, int authmethod); +int LDAP_CALL ldap_bind_s(LDAP *ld, const char *who, + const char *cred, int method); + +/* + * experimental DN format support + */ +char **LDAP_CALL ldap_explode_dns(const char *dn); +int LDAP_CALL ldap_is_dns_dn(const char *dn); + +#ifdef _SOLARIS_SDK +char *ldap_dns_to_dn(char *dns_name, int *nameparts); +#endif + + +/* + * user friendly naming/searching routines + */ +typedef int (LDAP_C LDAP_CALLBACK LDAP_CANCELPROC_CALLBACK)(void *cl); +int LDAP_CALL ldap_ufn_search_c(LDAP *ld, char *ufn, + char **attrs, int attrsonly, LDAPMessage **res, + LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm); +int LDAP_CALL ldap_ufn_search_ct(LDAP *ld, char *ufn, + char **attrs, int attrsonly, LDAPMessage **res, + LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, + char *tag1, char *tag2, char *tag3); +int LDAP_CALL ldap_ufn_search_s(LDAP *ld, char *ufn, + char **attrs, int attrsonly, LDAPMessage **res); +LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_ufn_setfilter(LDAP *ld, char *fname); +LDAP_API(void) LDAP_CALL ldap_ufn_setprefix(LDAP *ld, char *prefix); +int LDAP_C ldap_ufn_timeout(void *tvparam); + +/* + * functions and definitions that have been replaced by new improved ones + */ +/* + * Use ldap_get_option() with LDAP_OPT_API_INFO and an LDAPAPIInfo structure + * instead of ldap_version(). The use of this API is deprecated. + */ +typedef struct _LDAPVersion { + int sdk_version; /* Version of the SDK, * 100 */ + int protocol_version; /* Highest protocol version supported, * 100 */ + int SSL_version; /* SSL version if this SDK supports it, * 100 */ + int security_level; /* highest level available */ + int reserved[4]; +} LDAPVersion; +#define LDAP_SECURITY_NONE 0 +int LDAP_CALL ldap_version(LDAPVersion *ver); + +/* use ldap_create_filter() instead of ldap_build_filter() */ +LDAP_API(void) LDAP_CALL ldap_build_filter(char *buf, size_t buflen, + char *pattern, char *prefix, char *suffix, char *attr, + char *value, char **valwords); +/* use ldap_set_filter_additions() instead of ldap_setfilteraffixes() */ +LDAP_API(void) LDAP_CALL ldap_setfilteraffixes(LDAPFiltDesc *lfdp, + char *prefix, char *suffix); + +/* older result types a server can return -- use LDAP_RES_MODDN instead */ +#define LDAP_RES_MODRDN LDAP_RES_MODDN +#define LDAP_RES_RENAME LDAP_RES_MODDN + +/* older error messages */ +#define LDAP_AUTH_METHOD_NOT_SUPPORTED LDAP_STRONG_AUTH_NOT_SUPPORTED + +/* end of unsupported functions */ + +#ifdef _SOLARIS_SDK + +/* SSL Functions */ + +/* + * these three defines resolve the SSL strength + * setting auth weak, diables all cert checking + * the CNCHECK tests for the man in the middle hack + */ +#define LDAPSSL_AUTH_WEAK 0 +#define LDAPSSL_AUTH_CERT 1 +#define LDAPSSL_AUTH_CNCHECK 2 + +/* + * Initialize LDAP library for SSL + */ +LDAP * LDAP_CALL ldapssl_init(const char *defhost, int defport, + int defsecure); + +/* + * Install I/O routines to make SSL over LDAP possible. + * Use this after ldap_init() or just use ldapssl_init() instead. + */ +int LDAP_CALL ldapssl_install_routines(LDAP *ld); + + +/* + * The next three functions initialize the security code for SSL + * The first one ldapssl_client_init() does initialization for SSL only + * The next one supports ldapssl_clientauth_init() intializes security + * for SSL for client authentication. The third function initializes + * security for doing SSL with client authentication, and PKCS, that is, + * the third function initializes the security module database(secmod.db). + * The parameters are as follows: + * const char *certdbpath - path to the cert file. This can be a shortcut + * to the directory name, if so cert7.db will be postfixed to the string. + * void *certdbhandle - Normally this is NULL. This memory will need + * to be freed. + * int needkeydb - boolean. Must be ! = 0 if client Authentification + * is required + * char *keydbpath - path to the key database. This can be a shortcut + * to the directory name, if so key3.db will be postfixed to the string. + * void *keydbhandle - Normally this is NULL, This memory will need + * to be freed + * int needsecmoddb - boolean. Must be ! = 0 to assure that the correct + * security module is loaded into memory + * char *secmodpath - path to the secmod. This can be a shortcut to the + * directory name, if so secmod.db will be postfixed to the string. + * + * These three functions are mutually exclusive. You can only call + * one. This means that, for a given process, you must call the + * appropriate initialization function for the life of the process. + */ + + +/* + * Initialize the secure parts (Security and SSL) of the runtime for use + * by a client application. This is only called once. + */ +int LDAP_CALL ldapssl_client_init( + const char *certdbpath, void *certdbhandle); + +/* + * Initialize the secure parts (Security and SSL) of the runtime for use + * by a client application that may want to do SSL client authentication. + */ +int LDAP_CALL ldapssl_clientauth_init( + const char *certdbpath, void *certdbhandle, + const int needkeydb, const char *keydbpath, void *keydbhandle); + +/* + * Initialize the secure parts (Security and SSL) of the runtime for use + * by a client application that may want to do SSL client authentication. + */ +int LDAP_CALL ldapssl_advclientauth_init( + const char *certdbpath, void *certdbhandle, + const int needkeydb, const char *keydbpath, void *keydbhandle, + const int needsecmoddb, const char *secmoddbpath, + const int sslstrength); + +/* + * get a meaningful error string back from the security library + * this function should be called, if ldap_err2string doesn't + * identify the error code. + */ +const char *LDAP_CALL ldapssl_err2string(const int prerrno); + +/* + * Enable SSL client authentication on the given ld. + */ +int LDAP_CALL ldapssl_enable_clientauth(LDAP *ld, char *keynickname, + char *keypasswd, char *certnickname); + +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_TOKEN_CALLBACK) + (void *context, char **tokenname); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_PIN_CALLBACK) + (void *context, const char *tokenname, char **tokenpin); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTPATH_CALLBACK) + (void *context, char **certpath); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_KEYPATH_CALLBACK) + (void *context, char **keypath); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_MODPATH_CALLBACK) + (void *context, char **modulepath); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTNAME_CALLBACK) + (void *context, char **certname); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK) + (void *context, char **filename); + +#define PKCS_STRUCTURE_ID 1 +struct ldapssl_pkcs_fns { + int local_structure_id; + void *local_data; + LDAP_PKCS_GET_CERTPATH_CALLBACK *pkcs_getcertpath; + LDAP_PKCS_GET_CERTNAME_CALLBACK *pkcs_getcertname; + LDAP_PKCS_GET_KEYPATH_CALLBACK *pkcs_getkeypath; + LDAP_PKCS_GET_MODPATH_CALLBACK *pkcs_getmodpath; + LDAP_PKCS_GET_PIN_CALLBACK *pkcs_getpin; + LDAP_PKCS_GET_TOKEN_CALLBACK *pkcs_gettokenname; + LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK *pkcs_getdonglefilename; + +}; + + +int LDAP_CALL ldapssl_pkcs_init(const struct ldapssl_pkcs_fns *pfns); + +/* end of SSL functions */ +#endif /* _SOLARIS_SDK */ + +/* SASL options */ +#define LDAP_OPT_X_SASL_MECH 0x6100 +#define LDAP_OPT_X_SASL_REALM 0x6101 +#define LDAP_OPT_X_SASL_AUTHCID 0x6102 +#define LDAP_OPT_X_SASL_AUTHZID 0x6103 +#define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */ +#define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */ +#define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */ +#define LDAP_OPT_X_SASL_SSF_MIN 0x6107 +#define LDAP_OPT_X_SASL_SSF_MAX 0x6108 +#define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109 + +/* + * ldap_interactive_bind_s Interaction flags + * Interactive: prompt always - REQUIRED + */ +#define LDAP_SASL_INTERACTIVE 1U + +/* + * V3 SASL Interaction Function Callback Prototype + * when using SASL, interact is pointer to sasl_interact_t + * should likely passed in a control (and provided controls) + */ +typedef int (LDAP_SASL_INTERACT_PROC) + (LDAP *ld, unsigned flags, void* defaults, void *interact); + +int LDAP_CALL ldap_sasl_interactive_bind_s(LDAP *ld, const char *dn, + const char *saslMechanism, LDAPControl **serverControls, + LDAPControl **clientControls, unsigned flags, + LDAP_SASL_INTERACT_PROC *proc, void *defaults); + +#ifdef __cplusplus +} +#endif + +#endif /* _LDAP_H */ diff --git a/illumos-x86_64/usr/include/libbe.h b/illumos-x86_64/usr/include/libbe.h new file mode 100644 index 00000000..774fe1ef --- /dev/null +++ b/illumos-x86_64/usr/include/libbe.h @@ -0,0 +1,278 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Toomas Soome + * Copyright 2015 Gary Mills + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _LIBBE_H +#define _LIBBE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define BE_ATTR_ORIG_BE_NAME "orig_be_name" +#define BE_ATTR_ORIG_BE_POOL "orig_be_pool" +#define BE_ATTR_ORIG_BE_ROOT "orig_be_root" +#define BE_ATTR_SNAP_NAME "snap_name" + +#define BE_ATTR_NEW_BE_NAME "new_be_name" +#define BE_ATTR_NEW_BE_POOL "new_be_pool" +#define BE_ATTR_NEW_BE_DESC "new_be_desc" +#define BE_ATTR_POLICY "policy" +#define BE_ATTR_ZFS_PROPERTIES "zfs_properties" + +#define BE_ATTR_FS_NAMES "fs_names" +#define BE_ATTR_FS_NUM "fs_num" +#define BE_ATTR_SHARED_FS_NAMES "shared_fs_names" +#define BE_ATTR_SHARED_FS_NUM "shared_fs_num" + +#define BE_ATTR_MOUNTPOINT "mountpoint" +#define BE_ATTR_MOUNT_FLAGS "mount_flags" +#define BE_ATTR_UNMOUNT_FLAGS "unmount_flags" +#define BE_ATTR_DESTROY_FLAGS "destroy_flags" +#define BE_ATTR_INSTALL_FLAGS "install_flags" +#define BE_ATTR_ROOT_DS "root_ds" +#define BE_ATTR_UUID_STR "uuid_str" + +#define BE_ATTR_ACTIVE "active" +#define BE_ATTR_ACTIVE_ON_BOOT "active_boot" +#define BE_ATTR_ACTIVE_NEXTBOOT "active_nextboot" +#define BE_ATTR_GLOBAL_ACTIVE "global_active" +#define BE_ATTR_SPACE "space_used" +#define BE_ATTR_DATASET "dataset" +#define BE_ATTR_STATUS "status" +#define BE_ATTR_DATE "date" +#define BE_ATTR_MOUNTED "mounted" + +/* + * libbe error codes + * + * NOTE: there is a copy of this enum in beadm/messages.py. To keep these + * in sync please make sure to add any new error messages at the end + * of this enumeration. + */ +typedef enum { + BE_SUCCESS = 0, + BE_ERR_ACCESS = 4000, /* permission denied */ + BE_ERR_ACTIVATE_CURR, /* Activation of current BE failed */ + BE_ERR_AUTONAME, /* auto naming failed */ + BE_ERR_BE_NOENT, /* No such BE */ + BE_ERR_BUSY, /* mount busy */ + BE_ERR_CANCELED, /* operation canceled */ + BE_ERR_CLONE, /* BE clone failed */ + BE_ERR_COPY, /* BE copy failed */ + BE_ERR_CREATDS, /* dataset creation failed */ + BE_ERR_CURR_BE_NOT_FOUND, /* Can't find current BE */ + BE_ERR_DESTROY, /* failed to destroy BE or snapshot */ + BE_ERR_DEMOTE, /* BE demotion failed */ + BE_ERR_DSTYPE, /* invalid dataset type */ + BE_ERR_BE_EXISTS, /* BE exists */ + BE_ERR_INIT, /* be_zfs_init failed */ + BE_ERR_INTR, /* interupted system call */ + BE_ERR_INVAL, /* invalid argument */ + BE_ERR_INVALPROP, /* invalid property for dataset */ + BE_ERR_INVALMOUNTPOINT, /* Unexpected mountpoint */ + BE_ERR_MOUNT, /* mount failed */ + BE_ERR_MOUNTED, /* already mounted */ + BE_ERR_NAMETOOLONG, /* name > BUFSIZ */ + BE_ERR_NOENT, /* Doesn't exist */ + BE_ERR_POOL_NOENT, /* No such pool */ + BE_ERR_NODEV, /* No such device */ + BE_ERR_NOTMOUNTED, /* File system not mounted */ + BE_ERR_NOMEM, /* not enough memory */ + BE_ERR_NONINHERIT, /* property is not inheritable for BE dataset */ + BE_ERR_NXIO, /* No such device or address */ + BE_ERR_NOSPC, /* No space on device */ + BE_ERR_NOTSUP, /* Operation not supported */ + BE_ERR_OPEN, /* open failed */ + BE_ERR_PERM, /* Not owner */ + BE_ERR_UNAVAIL, /* The BE is currently unavailable */ + BE_ERR_PROMOTE, /* BE promotion failed */ + BE_ERR_ROFS, /* read only file system */ + BE_ERR_READONLYDS, /* read only dataset */ + BE_ERR_READONLYPROP, /* read only property */ + BE_ERR_SS_EXISTS, /* snapshot exists */ + BE_ERR_SS_NOENT, /* No such snapshot */ + BE_ERR_UMOUNT, /* unmount failed */ + BE_ERR_UMOUNT_CURR_BE, /* Can't unmount current BE */ + BE_ERR_UMOUNT_SHARED, /* unmount of shared File System failed */ + BE_ERR_UNKNOWN, /* Unknown error */ + BE_ERR_ZFS, /* ZFS returned an error */ + BE_ERR_DESTROY_CURR_BE, /* Cannot destroy current BE */ + BE_ERR_GEN_UUID, /* Failed to generate uuid */ + BE_ERR_PARSE_UUID, /* Failed to parse uuid */ + BE_ERR_NO_UUID, /* BE has no uuid */ + BE_ERR_ZONE_NO_PARENTBE, /* Zone root dataset has no parent uuid */ + BE_ERR_ZONE_MULTIPLE_ACTIVE, /* Zone has multiple active roots */ + BE_ERR_ZONE_NO_ACTIVE_ROOT, /* Zone has no active root for this BE */ + BE_ERR_ZONE_ROOT_NOT_LEGACY, /* Zone root dataset mntpt is not legacy */ + BE_ERR_NO_MOUNTED_ZONE, /* Zone not mounted in alternate BE */ + BE_ERR_MOUNT_ZONEROOT, /* Failed to mount a zone root */ + BE_ERR_UMOUNT_ZONEROOT, /* Failed to unmount a zone root */ + BE_ERR_ZONES_UNMOUNT, /* Unable to unmount a zone. */ + BE_ERR_FAULT, /* Bad Address */ + BE_ERR_RENAME_ACTIVE, /* Renaming the active BE is not supported */ + BE_ERR_NO_MENU, /* Missing boot menu file */ + BE_ERR_DEV_BUSY, /* Device is Busy */ + BE_ERR_BAD_MENU_PATH, /* Invalid path for menu.lst file */ + BE_ERR_ZONE_SS_EXISTS, /* zone snapshot already exists */ + BE_ERR_ADD_SPLASH_ICT, /* Add_splash_image ICT failed */ + BE_ERR_BOOTFILE_INST, /* Error installing boot files */ + BE_ERR_EXTCMD /* External command error */ +} be_errno_t; + +/* + * Data structures used to return the listing and information of BEs. + */ +typedef struct be_dataset_list { + uint64_t be_ds_space_used; + boolean_t be_ds_mounted; + char *be_dataset_name; + time_t be_ds_creation; /* Date/time stamp when created */ + char *be_ds_mntpt; + char *be_ds_plcy_type; /* cleanup policy type */ + struct be_dataset_list *be_next_dataset; +} be_dataset_list_t; + +typedef struct be_snapshot_list { + uint64_t be_snapshot_space_used; /* bytes of disk space used */ + char *be_snapshot_name; + time_t be_snapshot_creation; /* Date/time stamp when created */ + char *be_snapshot_type; /* cleanup policy type */ + struct be_snapshot_list *be_next_snapshot; +} be_snapshot_list_t; + +typedef struct be_node_list { + boolean_t be_mounted; /* is BE currently mounted */ + boolean_t be_active_next; /* is this BE active on next boot */ + boolean_t be_active_on_boot; /* is this BE active on boot */ + boolean_t be_active; /* is this BE active currently */ + boolean_t be_global_active; /* is zone's BE associated with */ + /* an active global BE */ + uint64_t be_space_used; + char *be_node_name; + char *be_rpool; + char *be_root_ds; + char *be_mntpt; + char *be_policy_type; /* cleanup policy type */ + char *be_uuid_str; /* string representation of uuid */ + time_t be_node_creation; /* Date/time stamp when created */ + struct be_dataset_list *be_node_datasets; + uint_t be_node_num_datasets; + struct be_snapshot_list *be_node_snapshots; + uint_t be_node_num_snapshots; + struct be_node_list *be_next_node; +} be_node_list_t; + +/* Flags used with mounting a BE */ +#define BE_MOUNT_FLAG_NULL 0x00000000 +#define BE_MOUNT_FLAG_SHARED_FS 0x00000001 +#define BE_MOUNT_FLAG_SHARED_RW 0x00000002 +#define BE_MOUNT_FLAG_NO_ZONES 0x00000004 + +/* Flags used with unmounting a BE */ +#define BE_UNMOUNT_FLAG_NULL 0x00000000 +#define BE_UNMOUNT_FLAG_FORCE 0x00000001 + +/* Flags used with destroying a BE */ +#define BE_DESTROY_FLAG_NULL 0x00000000 +#define BE_DESTROY_FLAG_SNAPSHOTS 0x00000001 +#define BE_DESTROY_FLAG_FORCE_UNMOUNT 0x00000002 + +/* Flags for installboot */ +#define BE_INSTALLBOOT_FLAG_NULL 0x00000000 +#define BE_INSTALLBOOT_FLAG_MBR 0x00000001 +#define BE_INSTALLBOOT_FLAG_FORCE 0x00000002 +#define BE_INSTALLBOOT_FLAG_VERBOSE 0x00000004 + +/* Flags for be_list() */ +#define BE_LIST_DEFAULT 0x00000000 +#define BE_LIST_SNAPSHOTS 0x00000001 +#define BE_LIST_ALL BE_LIST_SNAPSHOTS + +/* sort rules for be_sort() */ +typedef enum { + BE_SORT_UNSPECIFIED = -1, + BE_SORT_DATE = 0, + BE_SORT_DATE_REV, + BE_SORT_NAME, + BE_SORT_NAME_REV, + BE_SORT_SPACE, + BE_SORT_SPACE_REV +} be_sort_t; + +/* for fastboot arguments */ +#define BE_ENTRY_DEFAULT (-1) +/* + * BE functions + */ +int be_init(nvlist_t *); +int be_destroy(nvlist_t *); +int be_copy(nvlist_t *); + +int be_mount(nvlist_t *); +int be_unmount(nvlist_t *); + +int be_rename(nvlist_t *); + +int be_activate(nvlist_t *); + +int be_create_snapshot(nvlist_t *); +int be_destroy_snapshot(nvlist_t *); +int be_rollback(nvlist_t *); + +/* + * Functions for listing and getting information about existing BEs. + */ +int be_list(char *, be_node_list_t **, uint64_t); +void be_free_list(be_node_list_t *); +int be_max_avail(char *, uint64_t *); +char *be_err_to_str(int); +int be_sort(be_node_list_t **, int); +int be_get_boot_args(char **, int); +/* + * Installboot support + */ +int be_installboot(nvlist_t *); + +/* + * Library functions + */ +void libbe_print_errors(boolean_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBBE_H */ diff --git a/illumos-x86_64/usr/include/libcontract.h b/illumos-x86_64/usr/include/libcontract.h new file mode 100644 index 00000000..8be68c61 --- /dev/null +++ b/illumos-x86_64/usr/include/libcontract.h @@ -0,0 +1,142 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBCONTRACT_H +#define _LIBCONTRACT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *ct_stathdl_t; +typedef void *ct_evthdl_t; + +/* + * Common routines + */ +extern int ct_tmpl_activate(int); +extern int ct_tmpl_clear(int); +extern int ct_tmpl_create(int, ctid_t *); +extern int ct_tmpl_set_cookie(int, uint64_t); +extern int ct_tmpl_get_cookie(int, uint64_t *); +extern int ct_tmpl_set_critical(int, uint_t); +extern int ct_tmpl_get_critical(int, uint_t *); +extern int ct_tmpl_set_informative(int, uint_t); +extern int ct_tmpl_get_informative(int, uint_t *); + +extern int ct_ctl_adopt(int); +extern int ct_ctl_abandon(int); +extern int ct_ctl_ack(int, ctevid_t); +extern int ct_ctl_nack(int, ctevid_t); +extern int ct_ctl_qack(int, ctevid_t); +extern int ct_ctl_newct(int, ctevid_t, int); + +extern int ct_status_read(int, int, ct_stathdl_t *); +extern void ct_status_free(ct_stathdl_t); + +extern ctid_t ct_status_get_id(ct_stathdl_t); +extern zoneid_t ct_status_get_zoneid(ct_stathdl_t); +extern const char *ct_status_get_type(ct_stathdl_t); +extern id_t ct_status_get_holder(ct_stathdl_t); +extern ctstate_t ct_status_get_state(ct_stathdl_t); +extern int ct_status_get_nevents(ct_stathdl_t); +extern int ct_status_get_ntime(ct_stathdl_t); +extern int ct_status_get_qtime(ct_stathdl_t); +extern ctevid_t ct_status_get_nevid(ct_stathdl_t); +extern uint_t ct_status_get_informative(ct_stathdl_t); +extern uint_t ct_status_get_critical(ct_stathdl_t); +extern uint64_t ct_status_get_cookie(ct_stathdl_t); + +extern int ct_event_read(int, ct_evthdl_t *); +extern int ct_event_read_critical(int, ct_evthdl_t *); +extern int ct_event_reset(int); +extern int ct_event_reliable(int); +extern void ct_event_free(ct_evthdl_t); + +extern uint_t ct_event_get_flags(ct_evthdl_t); +extern ctid_t ct_event_get_ctid(ct_evthdl_t); +extern ctevid_t ct_event_get_evid(ct_evthdl_t); +extern uint_t ct_event_get_type(ct_evthdl_t); +extern int ct_event_get_nevid(ct_evthdl_t, ctevid_t *); +extern int ct_event_get_newct(ct_evthdl_t, ctid_t *); + +/* + * Process contract routines + */ +extern int ct_pr_tmpl_set_transfer(int, ctid_t); +extern int ct_pr_tmpl_set_fatal(int, uint_t); +extern int ct_pr_tmpl_set_param(int, uint_t); +extern int ct_pr_tmpl_set_svc_fmri(int, const char *); +extern int ct_pr_tmpl_set_svc_aux(int, const char *); + +extern int ct_pr_tmpl_get_transfer(int, ctid_t *); +extern int ct_pr_tmpl_get_fatal(int, uint_t *); +extern int ct_pr_tmpl_get_param(int, uint_t *); +extern int ct_pr_tmpl_get_svc_fmri(int, char *, size_t); +extern int ct_pr_tmpl_get_svc_aux(int, char *, size_t); + +extern int ct_pr_event_get_pid(ct_evthdl_t, pid_t *); +extern int ct_pr_event_get_ppid(ct_evthdl_t, pid_t *); +extern int ct_pr_event_get_signal(ct_evthdl_t, int *); +extern int ct_pr_event_get_sender(ct_evthdl_t, pid_t *); +extern int ct_pr_event_get_senderct(ct_evthdl_t, ctid_t *); +extern int ct_pr_event_get_exitstatus(ct_evthdl_t, int *); +extern int ct_pr_event_get_pcorefile(ct_evthdl_t, const char **); +extern int ct_pr_event_get_gcorefile(ct_evthdl_t, const char **); +extern int ct_pr_event_get_zcorefile(ct_evthdl_t, const char **); + +extern int ct_pr_status_get_param(ct_stathdl_t, uint_t *); +extern int ct_pr_status_get_fatal(ct_stathdl_t, uint_t *); +extern int ct_pr_status_get_members(ct_stathdl_t, pid_t **, uint_t *); +extern int ct_pr_status_get_contracts(ct_stathdl_t, ctid_t **, uint_t *); +extern int ct_pr_status_get_svc_fmri(ct_stathdl_t, char **); +extern int ct_pr_status_get_svc_aux(ct_stathdl_t, char **); +extern int ct_pr_status_get_svc_ctid(ct_stathdl_t, ctid_t *); +extern int ct_pr_status_get_svc_creator(ct_stathdl_t, char **); + +/* + * Device contract routines + */ +int ct_dev_tmpl_set_minor(int, char *); +int ct_dev_tmpl_set_aset(int, uint_t); +int ct_dev_tmpl_set_noneg(int); +int ct_dev_tmpl_clear_noneg(int); +int ct_dev_tmpl_get_minor(int, char *, size_t *); +int ct_dev_tmpl_get_aset(int, uint_t *); +int ct_dev_tmpl_get_noneg(int, uint_t *); +int ct_dev_status_get_aset(ct_stathdl_t, uint_t *); +int ct_dev_status_get_noneg(ct_stathdl_t, uint_t *); +int ct_dev_status_get_dev_state(ct_stathdl_t, uint_t *); +int ct_dev_status_get_minor(ct_stathdl_t, char **); + + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBCONTRACT_H */ diff --git a/illumos-x86_64/usr/include/libctf.h b/illumos-x86_64/usr/include/libctf.h new file mode 100644 index 00000000..9412143a --- /dev/null +++ b/illumos-x86_64/usr/include/libctf.h @@ -0,0 +1,152 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 2019, Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +/* + * This header file defines the interfaces available from the CTF debugger + * library, libctf. This library provides functions that a debugger can + * use to operate on data in the Compact ANSI-C Type Format (CTF). This + * is NOT a public interface, although it may eventually become one in + * the fullness of time after we gain more experience with the interfaces. + * + * In the meantime, be aware that any program linked with libctf in this + * release of illumos is almost guaranteed to break in the next release. + * + * In short, do not use this header file or libctf for any purpose. + */ + +#ifndef _LIBCTF_H +#define _LIBCTF_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This flag can be used to enable debug messages. + */ +extern int _libctf_debug; + +typedef enum ctf_diff_flag { + CTF_DIFF_F_IGNORE_INTNAMES = 0x01 +} ctf_diff_flag_t; + +typedef struct ctf_diff ctf_diff_t; +typedef void (*ctf_diff_type_f)(ctf_file_t *, ctf_id_t, boolean_t, ctf_file_t *, + ctf_id_t, void *); +typedef void (*ctf_diff_func_f)(ctf_file_t *, ulong_t, boolean_t, ctf_file_t *, + ulong_t, void *); +typedef void (*ctf_diff_obj_f)(ctf_file_t *, ulong_t, ctf_id_t, boolean_t, + ctf_file_t *, ulong_t, ctf_id_t, void *); + +extern int ctf_diff_init(ctf_file_t *, ctf_file_t *, ctf_diff_t **); +extern uint_t ctf_diff_getflags(ctf_diff_t *); +extern int ctf_diff_setflags(ctf_diff_t *, uint_t); +extern int ctf_diff_types(ctf_diff_t *, ctf_diff_type_f, void *); +extern int ctf_diff_functions(ctf_diff_t *, ctf_diff_func_f, void *); +extern int ctf_diff_objects(ctf_diff_t *, ctf_diff_obj_f, void *); +extern void ctf_diff_fini(ctf_diff_t *); + +#define CTF_CONVERT_DEFAULT_BATCHSIZE 256 +#define CTF_CONVERT_DEFAULT_NTHREADS 4 + +typedef enum ctf_convert_flag { + /* + * Normally, we return a failure if we find a C-derived compilation + * unit that lacks DWARF or CTF (as required). This flag over-rides + * this check. + */ + CTF_ALLOW_MISSING_DEBUG = 0x01, + /* + * Normally, we return a failure if we can't fully convert a structure + * to CTF format, such as an enum with too many values. This flag + * allows us to continue and convert what we can. + */ + CTF_ALLOW_TRUNCATION = 0x02, + /* + * Conversion is not usually attempted for objects that don't appear + * to be built from C sources. This flag overrides this and attempts + * conversion anyway. + */ + CTF_FORCE_CONVERSION = 0x04 +} ctf_convert_flag_t; + +#define CTF_CONVERT_ALL_FLAGS (CTF_ALLOW_MISSING_DEBUG | \ + CTF_ALLOW_TRUNCATION | \ + CTF_FORCE_CONVERSION) + +/* opaque handle for ctfconvert functions */ +struct ctf_convert_handle; +typedef struct ctf_convert_handle ctf_convert_t; + +extern ctf_convert_t *ctf_convert_init(int *); +extern void ctf_convert_fini(ctf_convert_t *); + +typedef void (*ctf_convert_warn_f)(void *, const char *, ...); +/* Any warning callback must be MT-Safe if multiple threads are used */ +extern int ctf_convert_set_warncb(ctf_convert_t *, ctf_convert_warn_f, void *); +extern int ctf_convert_set_batchsize(ctf_convert_t *, uint_t); +extern int ctf_convert_set_flags(ctf_convert_t *, ctf_convert_flag_t); +extern int ctf_convert_set_label(ctf_convert_t *, const char *); +extern int ctf_convert_set_nthreads(ctf_convert_t *, uint_t); +extern int ctf_convert_add_ignore(ctf_convert_t *, const char *); + +extern ctf_file_t *ctf_fdconvert(ctf_convert_t *, int, int *, char *, size_t); + + +typedef enum ctf_hsc_ret { + CHR_ERROR = -1, + CHR_NO_C_SOURCE = 0, + CHR_HAS_C_SOURCE = 1 +} ctf_hsc_ret_t; + +extern ctf_hsc_ret_t ctf_has_c_source(Elf *, char *, size_t); + +typedef struct ctf_merge_handle ctf_merge_t; +extern ctf_merge_t *ctf_merge_init(int, int *); +extern int ctf_merge_add(ctf_merge_t *, ctf_file_t *); +extern int ctf_merge_set_nthreads(ctf_merge_t *, const uint_t); +extern int ctf_merge_label(ctf_merge_t *, const char *); +extern int ctf_merge_uniquify(ctf_merge_t *, ctf_file_t *, const char *); +extern int ctf_merge_merge(ctf_merge_t *, ctf_file_t **); +extern int ctf_merge_dedup(ctf_merge_t *, ctf_file_t **); +extern void ctf_merge_fini(ctf_merge_t *); + +#define CTF_ELFWRITE_F_COMPRESS 0x1 +extern int ctf_elffdwrite(ctf_file_t *, int, int, int); +extern int ctf_elfwrite(ctf_file_t *, const char *, const char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBCTF_H */ diff --git a/illumos-x86_64/usr/include/libdevice.h b/illumos-x86_64/usr/include/libdevice.h new file mode 100644 index 00000000..3bf46965 --- /dev/null +++ b/illumos-x86_64/usr/include/libdevice.h @@ -0,0 +1,187 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBDEVICE_H +#define _LIBDEVICE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DC_EXCL 0x01 +#define DC_RDONLY 0x02 + +typedef struct devctl_dummy_struct *devctl_hdl_t; +typedef struct devctl_dummy_ddef *devctl_ddef_t; + + +devctl_hdl_t +devctl_device_acquire(char *devfs_path, uint_t flags); + +devctl_hdl_t +devctl_bus_acquire(char *devfs_path, uint_t flags); + +devctl_hdl_t +devctl_ap_acquire(char *devfs_path, uint_t flags); + +devctl_hdl_t +devctl_pm_dev_acquire(char *devfs_path, uint_t flags); + +devctl_hdl_t +devctl_pm_bus_acquire(char *devfs_path, uint_t flags); + +void +devctl_release(devctl_hdl_t hdl); + +int +devctl_device_offline(devctl_hdl_t hdl); + +int +devctl_device_remove(devctl_hdl_t hdl); + +int +devctl_pm_raisepower(devctl_hdl_t hdl); + +int +devctl_pm_changepowerlow(devctl_hdl_t hdl); + +int +devctl_pm_changepowerhigh(devctl_hdl_t hdl); + +int +devctl_pm_idlecomponent(devctl_hdl_t hdl); + +int +devctl_pm_busycomponent(devctl_hdl_t hdl); + +int +devctl_pm_testbusy(devctl_hdl_t hdl, uint_t *busyp); + +int +devctl_pm_failsuspend(devctl_hdl_t hdl); + +int +devctl_pm_bus_teststrict(devctl_hdl_t hdl, uint_t *strict); + +int +devctl_pm_device_changeonresume(devctl_hdl_t hdl); + +int +devctl_pm_device_no_lower_power(devctl_hdl_t hdl); + +int +devctl_pm_bus_no_invol(devctl_hdl_t hdl); + +int +devctl_pm_device_promprintf(devctl_hdl_t hdl); + +int +devctl_device_online(devctl_hdl_t hdl); + +int +devctl_device_reset(devctl_hdl_t hdl); + +int +devctl_device_getstate(devctl_hdl_t hdl, uint_t *statep); + +int +devctl_bus_quiesce(devctl_hdl_t hdl); + +int +devctl_bus_unquiesce(devctl_hdl_t hdl); + +int +devctl_bus_reset(devctl_hdl_t hdl); + +int +devctl_bus_resetall(devctl_hdl_t hdl); + +int +devctl_bus_getstate(devctl_hdl_t hdl, uint_t *statep); + +int +devctl_bus_configure(devctl_hdl_t hdl); + +int +devctl_bus_unconfigure(devctl_hdl_t hdl); + +int +devctl_ap_insert(devctl_hdl_t, nvlist_t *); + +int +devctl_ap_remove(devctl_hdl_t, nvlist_t *); + +int +devctl_ap_connect(devctl_hdl_t, nvlist_t *); + +int +devctl_ap_disconnect(devctl_hdl_t, nvlist_t *); + +int +devctl_ap_configure(devctl_hdl_t, nvlist_t *); + +int +devctl_ap_unconfigure(devctl_hdl_t, nvlist_t *); + +int +devctl_ap_getstate(devctl_hdl_t, nvlist_t *, devctl_ap_state_t *); + +devctl_ddef_t +devctl_ddef_alloc(char *, int); + +void +devctl_ddef_free(devctl_ddef_t); + +int +devctl_ddef_int(devctl_ddef_t, char *, int32_t); + +int +devctl_ddef_int_array(devctl_ddef_t, char *, int, int32_t *); + +int +devctl_ddef_string(devctl_ddef_t ddef_hdl, char *, char *); + +int +devctl_ddef_string_array(devctl_ddef_t, char *, int, char **); + +int +devctl_ddef_byte_array(devctl_ddef_t, char *, int, uchar_t *); + +int +devctl_bus_dev_create(devctl_hdl_t, devctl_ddef_t, uint_t, devctl_hdl_t *); + +char * +devctl_get_pathname(devctl_hdl_t, char *, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDEVICE_H */ diff --git a/illumos-x86_64/usr/include/libdevinfo.h b/illumos-x86_64/usr/include/libdevinfo.h new file mode 100644 index 00000000..8f685a15 --- /dev/null +++ b/illumos-x86_64/usr/include/libdevinfo.h @@ -0,0 +1,570 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBDEVINFO_H +#define _LIBDEVINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * flags for di_walk_node + */ +#define DI_WALK_CLDFIRST 0 +#define DI_WALK_SIBFIRST 1 +#define DI_WALK_LINKGEN 2 + +#define DI_WALK_MASK 0xf + +/* + * flags for di_walk_link + */ +#define DI_LINK_SRC 1 +#define DI_LINK_TGT 2 + +/* + * return code for node_callback + */ +#define DI_WALK_CONTINUE 0 +#define DI_WALK_PRUNESIB -1 +#define DI_WALK_PRUNECHILD -2 +#define DI_WALK_TERMINATE -3 + +/* + * flags for di_walk_minor + */ +#define DI_CHECK_ALIAS 0x10 +#define DI_CHECK_INTERNAL_PATH 0x20 + +#define DI_CHECK_MASK 0xf0 + +/* + * flags for di_walk_hp + */ +#define DI_HP_CONNECTOR 0x1 +#define DI_HP_PORT 0x2 + +/* nodeid types */ +#define DI_PSEUDO_NODEID -1 +#define DI_SID_NODEID -2 +#define DI_PROM_NODEID -3 + +/* node & device states */ +#define DI_DRIVER_DETACHED 0x8000 +#define DI_DEVICE_OFFLINE 0x1 +#define DI_DEVICE_DOWN 0x2 +#define DI_DEVICE_DEGRADED 0x4 +#define DI_DEVICE_REMOVED 0x8 +#define DI_BUS_QUIESCED 0x100 +#define DI_BUS_DOWN 0x200 + +/* property types */ +#define DI_PROP_TYPE_BOOLEAN 0 +#define DI_PROP_TYPE_INT 1 +#define DI_PROP_TYPE_STRING 2 +#define DI_PROP_TYPE_BYTE 3 +#define DI_PROP_TYPE_UNKNOWN 4 +#define DI_PROP_TYPE_UNDEF_IT 5 +#define DI_PROP_TYPE_INT64 6 + +/* private macro for checking if a prop type is valid */ +#define DI_PROP_TYPE_VALID(type) \ + ((((type) >= DI_PROP_TYPE_INT) && ((type) <= DI_PROP_TYPE_BYTE)) || \ + ((type) == DI_PROP_TYPE_INT64)) + +/* opaque handles */ +typedef struct di_node *di_node_t; /* node */ +typedef struct di_minor *di_minor_t; /* minor_node */ +typedef struct di_path *di_path_t; /* path_node */ +typedef struct di_link *di_link_t; /* link */ +typedef struct di_lnode *di_lnode_t; /* endpoint */ +typedef struct di_devlink *di_devlink_t; /* devlink */ +typedef struct di_hp *di_hp_t; /* hotplug */ + +typedef struct di_prop *di_prop_t; /* node property */ +typedef struct di_path_prop *di_path_prop_t; /* path property */ +typedef struct di_prom_prop *di_prom_prop_t; /* prom property */ + +typedef struct di_prom_handle *di_prom_handle_t; /* prom snapshot */ +typedef struct di_devlink_handle *di_devlink_handle_t; /* devlink snapshot */ + + +/* + * Null handles to make handles really opaque + */ +#define DI_NODE_NIL NULL +#define DI_MINOR_NIL NULL +#define DI_PATH_NIL NULL +#define DI_LINK_NIL NULL +#define DI_LNODE_NIL NULL +#define DI_PROP_NIL NULL +#define DI_PROM_PROP_NIL NULL +#define DI_PROM_HANDLE_NIL NULL +#define DI_HP_NIL NULL + +/* + * IEEE 1275 properties and other standardized property names + */ +#define DI_PROP_FIRST_CHAS "first-in-chassis" +#define DI_PROP_SLOT_NAMES "slot-names" +#define DI_PROP_PHYS_SLOT "physical-slot#" +#define DI_PROP_DEV_TYPE "device_type" +#define DI_PROP_BUS_RANGE "bus-range" +#define DI_PROP_SERID "serialid#" +#define DI_PROP_REG "reg" +#define DI_PROP_AP_NAMES "ap-names" + +/* Interface Prototypes */ + +/* + * Snapshot initialization and cleanup + */ +extern di_node_t di_init(const char *phys_path, uint_t flag); +extern void di_fini(di_node_t root); + +/* + * node: traversal, data access, and parameters + */ +extern int di_walk_node(di_node_t root, uint_t flag, void *arg, + int (*node_callback)(di_node_t node, void *arg)); + +extern di_node_t di_drv_first_node(const char *drv_name, di_node_t root); +extern di_node_t di_drv_next_node(di_node_t node); + +extern di_node_t di_parent_node(di_node_t node); +extern di_node_t di_sibling_node(di_node_t node); +extern di_node_t di_child_node(di_node_t node); + +extern char *di_node_name(di_node_t node); +extern char *di_bus_addr(di_node_t node); +extern char *di_binding_name(di_node_t node); +extern int di_compatible_names(di_node_t, char **names); +extern int di_instance(di_node_t node); +extern int di_nodeid(di_node_t node); +extern int di_driver_major(di_node_t node); +extern uint_t di_state(di_node_t node); +extern ddi_node_state_t di_node_state(di_node_t node); +extern ddi_devid_t di_devid(di_node_t node); +extern char *di_driver_name(di_node_t node); +extern uint_t di_driver_ops(di_node_t node); + +extern void di_node_private_set(di_node_t node, void *data); +extern void *di_node_private_get(di_node_t node); + +extern char *di_devfs_path(di_node_t node); +extern char *di_devfs_minor_path(di_minor_t minor); +extern void di_devfs_path_free(char *path_buf); + +/* + * path_node: traversal, data access, and parameters + */ +extern di_path_t di_path_phci_next_path(di_node_t node, di_path_t); +extern di_path_t di_path_client_next_path(di_node_t node, di_path_t); + +extern di_node_t di_path_phci_node(di_path_t path); +extern di_node_t di_path_client_node(di_path_t path); + +extern char *di_path_node_name(di_path_t path); +extern char *di_path_bus_addr(di_path_t path); +extern int di_path_instance(di_path_t path); +extern di_path_state_t di_path_state(di_path_t path); +extern uint_t di_path_flags(di_path_t path); + +extern char *di_path_devfs_path(di_path_t path); +extern char *di_path_client_devfs_path(di_path_t path); + +extern void di_path_private_set(di_path_t path, void *data); +extern void *di_path_private_get(di_path_t path); + +/* + * minor_node: traversal, data access, and parameters + */ +extern int di_walk_minor(di_node_t root, const char *minortype, + uint_t flag, void *arg, + int (*minor_callback)(di_node_t node, + di_minor_t minor, void *arg)); +extern di_minor_t di_minor_next(di_node_t node, di_minor_t minor); + +extern di_node_t di_minor_devinfo(di_minor_t minor); +extern ddi_minor_type di_minor_type(di_minor_t minor); +extern char *di_minor_name(di_minor_t minor); +extern dev_t di_minor_devt(di_minor_t minor); +extern int di_minor_spectype(di_minor_t minor); +extern char *di_minor_nodetype(di_minor_t node); + +extern void di_minor_private_set(di_minor_t minor, void *data); +extern void *di_minor_private_get(di_minor_t minor); + +/* + * node: property access + */ +extern di_prop_t di_prop_next(di_node_t node, di_prop_t prop); + +extern char *di_prop_name(di_prop_t prop); +extern int di_prop_type(di_prop_t prop); +extern dev_t di_prop_devt(di_prop_t prop); + +extern int di_prop_ints(di_prop_t prop, int **prop_data); +extern int di_prop_int64(di_prop_t prop, int64_t **prop_data); +extern int di_prop_strings(di_prop_t prop, char **prop_data); +extern int di_prop_bytes(di_prop_t prop, uchar_t **prop_data); + +extern int di_prop_lookup_bytes(dev_t dev, di_node_t node, + const char *prop_name, uchar_t **prop_data); +extern int di_prop_lookup_ints(dev_t dev, di_node_t node, + const char *prop_name, int **prop_data); +extern int di_prop_lookup_int64(dev_t dev, di_node_t node, + const char *prop_name, int64_t **prop_data); +extern int di_prop_lookup_strings(dev_t dev, di_node_t node, + const char *prop_name, char **prop_data); + +/* + * prom_node: property access + */ +extern di_prom_handle_t di_prom_init(void); +extern void di_prom_fini(di_prom_handle_t ph); + +extern di_prom_prop_t di_prom_prop_next(di_prom_handle_t ph, di_node_t node, + di_prom_prop_t prom_prop); + +extern char *di_prom_prop_name(di_prom_prop_t prom_prop); +extern int di_prom_prop_data(di_prom_prop_t prop, + uchar_t **prom_prop_data); + +extern int di_prom_prop_lookup_ints(di_prom_handle_t prom, + di_node_t node, const char *prom_prop_name, + int **prom_prop_data); +extern int di_prom_prop_lookup_strings(di_prom_handle_t prom, + di_node_t node, const char *prom_prop_name, + char **prom_prop_data); +extern int di_prom_prop_lookup_bytes(di_prom_handle_t prom, + di_node_t node, const char *prom_prop_name, + uchar_t **prom_prop_data); + +/* + * path_node: property access + */ +extern di_path_prop_t di_path_prop_next(di_path_t path, di_path_prop_t prop); + +extern char *di_path_prop_name(di_path_prop_t prop); +extern int di_path_prop_type(di_path_prop_t prop); +extern int di_path_prop_len(di_path_prop_t prop); + +extern int di_path_prop_bytes(di_path_prop_t prop, + uchar_t **prop_data); +extern int di_path_prop_ints(di_path_prop_t prop, + int **prop_data); +extern int di_path_prop_int64s(di_path_prop_t prop, + int64_t **prop_data); +extern int di_path_prop_strings(di_path_prop_t prop, + char **prop_data); + +extern int di_path_prop_lookup_bytes(di_path_t path, + const char *prop_name, uchar_t **prop_data); +extern int di_path_prop_lookup_ints(di_path_t path, + const char *prop_name, int **prop_data); +extern int di_path_prop_lookup_int64s(di_path_t path, + const char *prop_name, int64_t **prop_data); +extern int di_path_prop_lookup_strings(di_path_t path, + const char *prop_name, char **prop_data); + +/* + * layering link/lnode: traversal, data access, and parameters + */ +extern int di_walk_link(di_node_t root, uint_t flag, + uint_t endpoint, void *arg, + int (*link_callback)(di_link_t link, void *arg)); +extern int di_walk_lnode(di_node_t root, uint_t flag, void *arg, + int (*lnode_callback)(di_lnode_t lnode, void *arg)); + +extern di_link_t di_link_next_by_node(di_node_t node, + di_link_t link, uint_t endpoint); +extern di_link_t di_link_next_by_lnode(di_lnode_t lnode, + di_link_t link, uint_t endpoint); +extern di_lnode_t di_lnode_next(di_node_t node, di_lnode_t lnode); +extern char *di_lnode_name(di_lnode_t lnode); + +extern int di_link_spectype(di_link_t link); +extern di_lnode_t di_link_to_lnode(di_link_t link, uint_t endpoint); + +extern di_node_t di_lnode_devinfo(di_lnode_t lnode); +extern int di_lnode_devt(di_lnode_t lnode, dev_t *devt); + +extern void di_link_private_set(di_link_t link, void *data); +extern void *di_link_private_get(di_link_t link); +extern void di_lnode_private_set(di_lnode_t lnode, void *data); +extern void *di_lnode_private_get(di_lnode_t lnode); + +/* + * hp_node: traversal, data access, and parameters + */ +extern int di_walk_hp(di_node_t node, const char *type, + uint_t flag, void *arg, + int (*hp_callback)(di_node_t node, di_hp_t hp, + void *arg)); +extern di_hp_t di_hp_next(di_node_t node, di_hp_t hp); + +extern char *di_hp_name(di_hp_t hp); +extern int di_hp_connection(di_hp_t hp); +extern int di_hp_depends_on(di_hp_t hp); +extern int di_hp_state(di_hp_t hp); +extern int di_hp_type(di_hp_t hp); +extern char *di_hp_description(di_hp_t hp); +extern time_t di_hp_last_change(di_hp_t hp); +extern di_node_t di_hp_child(di_hp_t hp); + +/* + * Private interfaces + * + * The interfaces and structures below are private to this implementation + * of Solaris and are subject to change at any time without notice. + * + * Applications and drivers using these interfaces may fail + * to run on future releases. + */ +extern di_prop_t di_prop_find(dev_t match_dev, di_node_t node, + const char *name); +extern int di_devfs_path_match(const char *dp1, const char *dp2); + +extern di_node_t di_vhci_first_node(di_node_t root); +extern di_node_t di_vhci_next_node(di_node_t node); +extern di_node_t di_phci_first_node(di_node_t vhci_node); +extern di_node_t di_phci_next_node(di_node_t node); + +/* + * Interfaces for handling IEEE 1275 and other standardized properties + */ + +/* structure for a single slot */ +typedef struct di_slot_name { + int num; /* corresponding pci device number */ + char *name; +} di_slot_name_t; + +extern void di_slot_names_free(int count, di_slot_name_t *slot_names); +extern int di_slot_names_decode(uchar_t *rawdata, int rawlen, + di_slot_name_t **prop_data); +extern int di_prop_slot_names(di_prop_t prop, di_slot_name_t **prop_data); +extern int di_prom_prop_slot_names(di_prom_prop_t prom_prop, + di_slot_name_t **prop_data); +extern int di_prop_lookup_slot_names(dev_t dev, di_node_t node, + di_slot_name_t **prop_data); +extern int di_prom_prop_lookup_slot_names(di_prom_handle_t ph, di_node_t node, + di_slot_name_t **prop_data); + +/* + * XXX Remove the private di_path_(addr,next,next_phci,next_client) interfaces + * below after NWS consolidation switches to using di_path_bus_addr, + * di_path_phci_next_path, and di_path_client_next_path per CR6638521. + */ +extern char *di_path_addr(di_path_t path, char *buf); +extern di_path_t di_path_next(di_node_t node, di_path_t path); +extern di_path_t di_path_next_phci(di_node_t node, di_path_t path); +extern di_path_t di_path_next_client(di_node_t node, di_path_t path); + +/* + * Interfaces for private data + */ +extern di_node_t di_init_driver(const char *drv_name, uint_t flag); +extern di_node_t di_init_impl(const char *phys_path, uint_t flag, + struct di_priv_data *priv_data); + +/* + * Prtconf needs to know property lists, raw prop_data, and private data + */ +extern di_prop_t di_prop_drv_next(di_node_t node, di_prop_t prop); +extern di_prop_t di_prop_sys_next(di_node_t node, di_prop_t prop); +extern di_prop_t di_prop_global_next(di_node_t node, di_prop_t prop); +extern di_prop_t di_prop_hw_next(di_node_t node, di_prop_t prop); + +extern int di_prop_rawdata(di_prop_t prop, uchar_t **prop_data); +extern void *di_parent_private_data(di_node_t node); +extern void *di_driver_private_data(di_node_t node); + +/* + * The value of the dip's devi_flags field + */ +uint_t di_flags(di_node_t node); + +/* + * Types of links for devlink lookup + */ +#define DI_PRIMARY_LINK 0x01 +#define DI_SECONDARY_LINK 0x02 +#define DI_LINK_TYPES 0x03 + +/* + * Flag for di_devlink_init() + */ +#define DI_MAKE_LINK 0x01 + +/* + * Flag for di_devlink_close() + */ +#define DI_LINK_ERROR 0x01 + +/* + * For devfsadm synchronous link creation interfaces + */ +#define DEVFSADM_SYNCH_DOOR ".devfsadm_synch_door" + +/* + * devlink create argument + */ +struct dca_off { + uint32_t dca_root; + uint32_t dca_minor; + uint32_t dca_driver; + int dca_error; + int dca_flags; + char dca_name[PATH_MAX+MAXNAMELEN]; +}; + +extern di_devlink_handle_t di_devlink_init(const char *name, uint_t flags); +extern int di_devlink_walk(di_devlink_handle_t hdl, const char *re, + const char *minor_path, uint_t flags, void *arg, + int (*devlink_callback)(di_devlink_t, void *)); +extern const char *di_devlink_path(di_devlink_t devlink); +extern const char *di_devlink_content(di_devlink_t devlink); +extern int di_devlink_type(di_devlink_t devlink); +extern di_devlink_t di_devlink_dup(di_devlink_t devlink); +extern int di_devlink_free(di_devlink_t devlink); +extern int di_devlink_fini(di_devlink_handle_t *hdlp); + +extern di_devlink_handle_t di_devlink_open(const char *root_dir, uint_t flags); +extern int di_devlink_close(di_devlink_handle_t *pp, int flag); +extern int di_devlink_rm_link(di_devlink_handle_t hdp, const char *link); +extern int di_devlink_add_link(di_devlink_handle_t hdp, const char *link, + const char *content, int flags); +extern int di_devlink_update(di_devlink_handle_t hdp); +extern di_devlink_handle_t di_devlink_init_root(const char *root, + const char *name, uint_t flags); +extern int di_devlink_cache_walk(di_devlink_handle_t hdp, const char *re, + const char *path, uint_t flags, void *arg, + int (*devlink_callback)(di_devlink_t, void *)); + +/* + * Private interfaces for I/O retire + */ +typedef struct di_retire { + void *rt_hdl; + void (*rt_abort)(void *hdl, const char *format, ...); + void (*rt_debug)(void *hdl, const char *format, ...); +} di_retire_t; + +extern int di_retire_device(char *path, di_retire_t *dp, int flags); +extern int di_unretire_device(char *path, di_retire_t *dp); +extern uint_t di_retired(di_node_t node); + +/* + * Private interfaces for /etc/logindevperm + */ +extern int di_devperm_login(const char *, uid_t, gid_t, void (*)(char *)); +extern int di_devperm_logout(const char *); + +/* + * Private interface for looking up, by path string, a node/path/minor + * in a snapshot. + */ +extern di_path_t di_lookup_path(di_node_t root, char *path); +extern di_node_t di_lookup_node(di_node_t root, char *path); + +/* + * Private hotplug interfaces to be used between cfgadm pci plugin and + * devfsadm link generator. + */ +extern char *di_dli_name(char *); +extern int di_dli_openr(char *); +extern int di_dli_openw(char *); +extern void di_dli_close(int); + +/* + * Private interface for parsing path_to_inst binding file + */ +extern int devfs_parse_binding_file(const char *, + int (*)(void *, const char *, int, const char *), void *); +extern int devfs_walk_minor_nodes(const char *, + int (*)(void *, const char *), void *); + +/* + * finddev - alternate readdir to discover only /dev persisted device names + */ +typedef struct __finddevhdl *finddevhdl_t; + +extern int device_exists(const char *); +extern int finddev_readdir(const char *, finddevhdl_t *); +extern int finddev_emptydir(const char *); +extern void finddev_close(finddevhdl_t); +extern const char *finddev_next(finddevhdl_t); + + +/* + * Private interfaces for non-global /dev profile + */ +typedef struct __di_prof *di_prof_t; + +extern int di_prof_init(const char *mountpt, di_prof_t *); +extern void di_prof_fini(di_prof_t); +extern int di_prof_commit(di_prof_t); +extern int di_prof_add_dev(di_prof_t, const char *); +extern int di_prof_add_exclude(di_prof_t, const char *); +extern int di_prof_add_symlink(di_prof_t, const char *, const char *); +extern int di_prof_add_map(di_prof_t, const char *, const char *); + +/* + * Private interfaces for to path conversion. + * NOTE: These interfaces do not require or cause attach. The implementation + * uses the kernel instance-tree (/etc/path_to_inst) and the di_devlinks + * database information. + */ +typedef struct __di_dim *di_dim_t; + +extern di_dim_t di_dim_init(); +extern void di_dim_fini(di_dim_t); +extern char *di_dim_path_devices(di_dim_t, + char *drv_name, int instance, char *minor_name); +extern char *di_dim_path_dev(di_dim_t, + char *drv_name, int instance, char *minor_name); + +/* + * Alias related exported interfaces + */ +char *di_alias2curr(di_node_t anynode, char *alias); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDEVINFO_H */ diff --git a/illumos-x86_64/usr/include/libdladm.h b/illumos-x86_64/usr/include/libdladm.h new file mode 100644 index 00000000..90ecaa03 --- /dev/null +++ b/illumos-x86_64/usr/include/libdladm.h @@ -0,0 +1,326 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +/* + * Copyright 2015, Joyent, Inc. + * Copyright 2022 OmniOS Community Edition (OmniOSce) Association + */ + +#ifndef _LIBDLADM_H +#define _LIBDLADM_H + +#include +#include +#include +#include +#include + +/* + * This file includes structures, macros and common routines shared by all + * data-link administration, and routines which do not directly administrate + * links. For example, dladm_status2str(). + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define LINKID_STR_WIDTH 10 +#define DLADM_STRSIZE 2048 + +/* + * option flags taken by the libdladm functions + * + * - DLADM_OPT_ACTIVE: + * The function requests to bringup some configuration that only take + * effect on active system (not persistent). + * + * - DLADM_OPT_PERSIST: + * The function requests to persist some configuration. + * + * - DLADM_OPT_CREATE: + * Today, only used by dladm_set_secobj() - requests to create a secobj. + * + * - DLADM_OPT_FORCE: + * The function requests to execute a specific operation forcefully. + * + * - DLADM_OPT_PREFIX: + * The function requests to generate a link name using the specified prefix. + * + * - DLADM_OPT_VLAN: + * Signifies VLAN creation code path + * + * - DLADM_OPT_NOREFRESH: + * Do not refresh the daemon after setting parameter (used by STP mcheck). + * + * - DLADM_OPT_BOOT: + * Bypass check functions during boot (used by pool property since pools + * can come up after link properties are set) + * + * - DLADM_OPT_TRANSIENT: + * Indicates that the link assigned to a zone is transient and will be + * removed when the zone shuts down. + */ +#define DLADM_OPT_ACTIVE 0x00000001 +#define DLADM_OPT_PERSIST 0x00000002 +#define DLADM_OPT_CREATE 0x00000004 +#define DLADM_OPT_FORCE 0x00000008 +#define DLADM_OPT_PREFIX 0x00000010 +#define DLADM_OPT_ANCHOR 0x00000020 +#define DLADM_OPT_VLAN 0x00000040 +#define DLADM_OPT_NOREFRESH 0x00000080 +#define DLADM_OPT_BOOT 0x00000100 +#define DLADM_OPT_TRANSIENT 0x00000200 + +#define DLADM_WALK_TERMINATE 0 +#define DLADM_WALK_CONTINUE -1 + +#define DLADM_MAX_ARG_CNT 32 +#define DLADM_MAX_ARG_VALS 64 + +typedef enum { + DLADM_STATUS_OK = 0, + DLADM_STATUS_BADARG, + DLADM_STATUS_FAILED, + DLADM_STATUS_TOOSMALL, + DLADM_STATUS_NOTSUP, + DLADM_STATUS_NOTFOUND, + DLADM_STATUS_BADVAL, + DLADM_STATUS_NOMEM, + DLADM_STATUS_EXIST, + DLADM_STATUS_LINKINVAL, + DLADM_STATUS_PROPRDONLY, + DLADM_STATUS_BADVALCNT, + DLADM_STATUS_DBNOTFOUND, + DLADM_STATUS_DENIED, + DLADM_STATUS_IOERR, + DLADM_STATUS_TEMPONLY, + DLADM_STATUS_TIMEDOUT, + DLADM_STATUS_ISCONN, + DLADM_STATUS_NOTCONN, + DLADM_STATUS_REPOSITORYINVAL, + DLADM_STATUS_MACADDRINVAL, + DLADM_STATUS_KEYINVAL, + DLADM_STATUS_INVALIDMACADDRLEN, + DLADM_STATUS_INVALIDMACADDRTYPE, + DLADM_STATUS_LINKBUSY, + DLADM_STATUS_VIDINVAL, + DLADM_STATUS_NONOTIF, + DLADM_STATUS_TRYAGAIN, + DLADM_STATUS_IPTUNTYPE, + DLADM_STATUS_IPTUNTYPEREQD, + DLADM_STATUS_BADIPTUNLADDR, + DLADM_STATUS_BADIPTUNRADDR, + DLADM_STATUS_ADDRINUSE, + DLADM_STATUS_BADTIMEVAL, + DLADM_STATUS_INVALIDMACADDR, + DLADM_STATUS_INVALIDMACADDRNIC, + DLADM_STATUS_INVALIDMACADDRINUSE, + DLADM_STATUS_MACFACTORYSLOTINVALID, + DLADM_STATUS_MACFACTORYSLOTUSED, + DLADM_STATUS_MACFACTORYSLOTALLUSED, + DLADM_STATUS_MACFACTORYNOTSUP, + DLADM_STATUS_INVALIDMACPREFIX, + DLADM_STATUS_INVALIDMACPREFIXLEN, + DLADM_STATUS_BADCPUID, + DLADM_STATUS_CPUERR, + DLADM_STATUS_CPUNOTONLINE, + DLADM_STATUS_BADRANGE, + DLADM_STATUS_TOOMANYELEMENTS, + DLADM_STATUS_DB_NOTFOUND, + DLADM_STATUS_DB_PARSE_ERR, + DLADM_STATUS_PROP_PARSE_ERR, + DLADM_STATUS_ATTR_PARSE_ERR, + DLADM_STATUS_FLOW_DB_ERR, + DLADM_STATUS_FLOW_DB_OPEN_ERR, + DLADM_STATUS_FLOW_DB_PARSE_ERR, + DLADM_STATUS_FLOWPROP_DB_PARSE_ERR, + DLADM_STATUS_FLOW_ADD_ERR, + DLADM_STATUS_FLOW_WALK_ERR, + DLADM_STATUS_FLOW_IDENTICAL, + DLADM_STATUS_FLOW_INCOMPATIBLE, + DLADM_STATUS_FLOW_EXISTS, + DLADM_STATUS_PERSIST_FLOW_EXISTS, + DLADM_STATUS_INVALID_IP, + DLADM_STATUS_INVALID_PREFIXLEN, + DLADM_STATUS_INVALID_PROTOCOL, + DLADM_STATUS_INVALID_PORT, + DLADM_STATUS_INVALID_DSF, + DLADM_STATUS_INVALID_DSFMASK, + DLADM_STATUS_INVALID_MACMARGIN, + DLADM_STATUS_NOTDEFINED, + DLADM_STATUS_BADPROP, + DLADM_STATUS_MINMAXBW, + DLADM_STATUS_NO_HWRINGS, + DLADM_STATUS_PERMONLY, + DLADM_STATUS_OPTMISSING, + DLADM_STATUS_POOLCPU, + DLADM_STATUS_INVALID_PORT_INSTANCE, + DLADM_STATUS_PORT_IS_DOWN, + DLADM_STATUS_PKEY_NOT_PRESENT, + DLADM_STATUS_PARTITION_EXISTS, + DLADM_STATUS_INVALID_PKEY, + DLADM_STATUS_NO_IB_HW_RESOURCE, + DLADM_STATUS_INVALID_PKEY_TBL_SIZE, + DLADM_STATUS_PORT_NOPROTO, + DLADM_STATUS_INVALID_MTU, + DLADM_STATUS_PERSIST_ON_TEMP, + DLADM_STATUS_BAD_ENCAP, + DLADM_STATUS_ADDRNOTAVAIL +} dladm_status_t; + +typedef enum { + DLADM_TYPE_STR, + DLADM_TYPE_BOOLEAN, + DLADM_TYPE_UINT64 +} dladm_datatype_t; + +typedef struct { + boolean_t ds_readonly; + union { + int dsu_confid; + nvlist_t *dsu_nvl; + } ds_u; +} dladm_conf_t; + +#define ds_confid ds_u.dsu_confid +#define ds_nvl ds_u.dsu_nvl + +#define DLADM_INVALID_CONF 0 + +/* opaque dladm handle to libdladm functions */ +struct dladm_handle; +typedef struct dladm_handle *dladm_handle_t; + +/* open/close handle */ +extern dladm_status_t dladm_open(dladm_handle_t *); +extern void dladm_close(dladm_handle_t); + +/* + * retrieve the dld file descriptor from handle, only libdladm and + * dlmgmtd are given access to the door file descriptor. + */ +extern int dladm_dld_fd(dladm_handle_t); +/* + * Retrieve kstat_ctl_t* from handle.The libkstat handle is opened + * when the first caller needs it.This allows the library to share + * the kstat handle. + */ +extern kstat_ctl_t *dladm_dld_kcp(dladm_handle_t); + +typedef struct dladm_arg_info { + const char *ai_name; + char *ai_val[DLADM_MAX_ARG_VALS]; + uint_t ai_count; +} dladm_arg_info_t; + +typedef struct dladm_arg_list { + dladm_arg_info_t al_info[DLADM_MAX_ARG_CNT]; + uint_t al_count; + char *al_buf; +} dladm_arg_list_t; + +typedef struct dladm_errlist { + uint_t el_count; + uint_t el_alloc; + char **el_errs; +} dladm_errlist_t; + +typedef enum { + DLADM_LOGTYPE_LINK = 1, + DLADM_LOGTYPE_FLOW +} dladm_logtype_t; + +typedef struct dladm_usage { + char du_name[MAXLINKNAMELEN]; + uint64_t du_duration; + uint64_t du_stime; + uint64_t du_etime; + uint64_t du_ipackets; + uint64_t du_rbytes; + uint64_t du_opackets; + uint64_t du_obytes; + uint64_t du_bandwidth; + boolean_t du_last; +} dladm_usage_t; + +extern const char *dladm_status2str(dladm_status_t, char *); +extern dladm_status_t dladm_set_rootdir(const char *); +extern const char *dladm_class2str(datalink_class_t, char *); +extern const char *dladm_media2str(uint32_t, char *); +extern uint32_t dladm_str2media(const char *); +extern boolean_t dladm_valid_linkname(const char *); +extern boolean_t dladm_str2interval(char *, uint32_t *); +extern dladm_status_t dladm_str2bw(char *, uint64_t *); +extern const char *dladm_bw2str(int64_t, char *); +extern dladm_status_t dladm_str2pri(char *, mac_priority_level_t *); +extern const char *dladm_pri2str(mac_priority_level_t, char *); +extern dladm_status_t dladm_str2protect(char *, uint32_t *); +extern const char *dladm_protect2str(uint32_t, char *); +extern dladm_status_t dladm_str2ipv4addr(char *, void *); +extern const char *dladm_ipv4addr2str(void *, char *); +extern dladm_status_t dladm_str2ipv6addr(char *, void *); +extern const char *dladm_ipv6addr2str(void *, char *); + +extern dladm_status_t dladm_parse_flow_props(char *, dladm_arg_list_t **, + boolean_t); +extern dladm_status_t dladm_parse_link_props(char *, dladm_arg_list_t **, + boolean_t); +extern void dladm_free_props(dladm_arg_list_t *); +extern dladm_status_t dladm_parse_flow_attrs(char *, dladm_arg_list_t **, + boolean_t); +extern void dladm_free_attrs(dladm_arg_list_t *); + +extern dladm_status_t dladm_start_usagelog(dladm_handle_t, dladm_logtype_t, + uint_t); +extern dladm_status_t dladm_stop_usagelog(dladm_handle_t, dladm_logtype_t); +extern dladm_status_t dladm_walk_usage_res(int (*)(dladm_usage_t *, void *), + int, char *, char *, char *, char *, void *); +extern dladm_status_t dladm_walk_usage_time(int (*)(dladm_usage_t *, void *), + int, char *, char *, char *, void *); +extern dladm_status_t dladm_usage_summary(int (*)(dladm_usage_t *, void *), + int, char *, void *); +extern dladm_status_t dladm_usage_dates(int (*)(dladm_usage_t *, void *), + int, char *, char *, void *); +extern dladm_status_t dladm_zone_boot(dladm_handle_t, zoneid_t); +extern dladm_status_t dladm_zone_halt(dladm_handle_t, zoneid_t); + +extern dladm_status_t dladm_strs2range(char **, uint_t, mac_propval_type_t, + mac_propval_range_t **); +extern dladm_status_t dladm_range2list(const mac_propval_range_t *, void *, + uint_t *); +extern int dladm_range2strs(const mac_propval_range_t *, char **); +extern dladm_status_t dladm_list2range(void *, uint_t, mac_propval_type_t, + mac_propval_range_t **); + +extern uint_t dladm_errlist_count(dladm_errlist_t *); +extern void dladm_errlist_init(dladm_errlist_t *); +extern void dladm_errlist_reset(dladm_errlist_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDLADM_H */ diff --git a/illumos-x86_64/usr/include/libdlbridge.h b/illumos-x86_64/usr/include/libdlbridge.h new file mode 100644 index 00000000..b3e91a74 --- /dev/null +++ b/illumos-x86_64/usr/include/libdlbridge.h @@ -0,0 +1,137 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBDLBRIDGE_H +#define _LIBDLBRIDGE_H + +/* + * This file includes structures, macros and routines used by bridge + * administration. + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + DLADM_BRIDGE_PROT_UNKNOWN = 0, /* internal only */ + DLADM_BRIDGE_PROT_STP, + DLADM_BRIDGE_PROT_TRILL +} dladm_bridge_prot_t; + +/* Utility functions to accept bridge protection options */ +extern dladm_status_t dladm_bridge_str2prot(const char *, + dladm_bridge_prot_t *); +extern const char *dladm_bridge_prot2str(dladm_bridge_prot_t); + +/* Retrieve bridge properties from SMF */ +extern dladm_status_t dladm_bridge_get_properties(const char *, + UID_STP_CFG_T *, dladm_bridge_prot_t *); +extern dladm_status_t dladm_bridge_run_properties(const char *, + UID_STP_CFG_T *, dladm_bridge_prot_t *); + +/* Create new bridge and configure SMF properties */ +extern dladm_status_t dladm_bridge_configure(dladm_handle_t, const char *, + const UID_STP_CFG_T *, dladm_bridge_prot_t, uint32_t); + +/* Enable a newly created bridge in SMF */ +extern dladm_status_t dladm_bridge_enable(const char *); +/* Delete a previously created bridge */ +extern dladm_status_t dladm_bridge_delete(dladm_handle_t, const char *, + uint32_t); + +/* Retrieve bridge state from running bridge daemon and get bridge port list */ +extern dladm_status_t dladm_bridge_state(const char *, UID_STP_STATE_T *); +extern datalink_id_t *dladm_bridge_get_portlist(const char *, uint_t *); +extern void dladm_bridge_free_portlist(datalink_id_t *); + +/* Set/remove bridge link membership and retreive bridge from member link */ +extern dladm_status_t dladm_bridge_setlink(dladm_handle_t, datalink_id_t, + const char *); +extern dladm_status_t dladm_bridge_getlink(dladm_handle_t, datalink_id_t, + char *, size_t); + +/* Retrieve bridge port status */ +extern dladm_status_t dladm_bridge_link_state(dladm_handle_t, datalink_id_t, + UID_STP_PORT_STATE_T *); +/* Check valid bridge name */ +extern boolean_t dladm_valid_bridgename(const char *); +/* Convert bridge observability node name to bridge name */ +extern boolean_t dladm_observe_to_bridge(char *); +/* Retrieve bridge forwarding table entries */ +extern bridge_listfwd_t *dladm_bridge_get_fwdtable(dladm_handle_t, const char *, + uint_t *); +extern void dladm_bridge_free_fwdtable(bridge_listfwd_t *); + +/* Retrive TRILL nicknames list */ +extern trill_listnick_t *dladm_bridge_get_trillnick(const char *, uint_t *); +extern void dladm_bridge_free_trillnick(trill_listnick_t *); +/* Store and retrieve TRILL nickname from TRILL SMF service configuration */ +extern uint16_t dladm_bridge_get_nick(const char *); +extern void dladm_bridge_set_nick(const char *, uint16_t); +/* Retrieve undocumented private properties from bridge SMF service config */ +extern dladm_status_t dladm_bridge_get_privprop(const char *, + boolean_t *, uint32_t *); + +/* Internal to libdladm */ +extern dladm_status_t dladm_bridge_get_port_cfg(dladm_handle_t, datalink_id_t, + int, int *); +extern dladm_status_t dladm_bridge_get_forwarding(dladm_handle_t, + datalink_id_t, uint_t *); +extern dladm_status_t dladm_bridge_refresh(dladm_handle_t, datalink_id_t); + +/* Bridge connection; used only between libdladm and bridged for status */ +#define DOOR_DIRNAME "/var/run/bridge_door" +typedef enum bridge_door_type_e { + bdcBridgeGetConfig, + bdcBridgeGetState, + bdcBridgeGetPorts, + bdcBridgeGetRefreshCount, + bdcPortGetConfig, + bdcPortGetState, + bdcPortGetForwarding +} bridge_door_type_t; + +typedef struct bridge_door_cmd_s { + bridge_door_type_t bdc_type; + datalink_id_t bdc_linkid; +} bridge_door_cmd_t; + +typedef struct bridge_door_cfg_s { + UID_STP_CFG_T bdcf_cfg; + dladm_bridge_prot_t bdcf_prot; +} bridge_door_cfg_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDLBRIDGE_H */ diff --git a/illumos-x86_64/usr/include/libdlib.h b/illumos-x86_64/usr/include/libdlib.h new file mode 100644 index 00000000..3d7c32b5 --- /dev/null +++ b/illumos-x86_64/usr/include/libdlib.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBDLIB_H +#define _LIBDLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define MAXPKEYSTRSZ 968 +#define MAXPKEYLEN 6 +#define IBGUIDSTRLEN 16 +#define IBPORTSTRLEN 5 + +#define DLADM_PART_FORCE_CREATE 0x1 + +typedef struct dladm_ib_attr_s { + datalink_id_t dia_physlinkid; /* IB Phys link datalink ID */ + datalink_id_t dia_partlinkid; /* IB Partition datalink ID */ + ib_pkey_t dia_pkey; /* IB partitions P_Key */ + uint32_t dia_flags; + uint_t dia_portnum; /* IB Phys link's HCA port number */ + int dia_instance; /* IP over IB driver instance number */ + ib_guid_t dia_hca_guid; /* IB HCA GUID */ + ib_guid_t dia_port_guid; /* IB HCA Port GUID */ + uint_t dia_port_pkey_tbl_sz; + ib_pkey_t *dia_port_pkeys; /* Ptr to the P_Key table */ +} dladm_ib_attr_t; + +typedef struct dladm_ib_attr_s dladm_part_attr_t; + +typedef enum { + DLADM_PART_UD_MODE = 0, + DLADM_PART_CM_MODE +} dladm_part_linkmode_t; + +extern dladm_status_t dladm_part_create(dladm_handle_t, datalink_id_t, + ib_pkey_t, uint32_t, char *, datalink_id_t *, dladm_arg_list_t *); +extern dladm_status_t dladm_part_delete(dladm_handle_t, datalink_id_t, int); +extern dladm_status_t dladm_part_up(dladm_handle_t, datalink_id_t, uint32_t); +extern dladm_status_t dladm_part_info(dladm_handle_t, datalink_id_t, + dladm_part_attr_t *, uint32_t); +extern dladm_status_t dladm_ib_info(dladm_handle_t, datalink_id_t, + dladm_ib_attr_t *, uint32_t); +extern void dladm_free_ib_info(dladm_ib_attr_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDLIB_H */ diff --git a/illumos-x86_64/usr/include/libdllink.h b/illumos-x86_64/usr/include/libdllink.h new file mode 100644 index 00000000..a2830b5e --- /dev/null +++ b/illumos-x86_64/usr/include/libdllink.h @@ -0,0 +1,227 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBDLLINK_H +#define _LIBDLLINK_H + +/* + * This file includes structures, macros and routines used by general + * link administration (i.e. not limited to one specific type of link). + */ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct dladm_attr { + uint_t da_max_sdu; +} dladm_attr_t; + +typedef struct dladm_phys_attr { + char dp_dev[MAXLINKNAMELEN]; + /* + * Whether this physical link supports vanity naming (links with media + * types not supported by GLDv3 don't have vanity naming support). + */ + boolean_t dp_novanity; +} dladm_phys_attr_t; + +typedef enum { + DLADM_PROP_VAL_CURRENT = 1, + DLADM_PROP_VAL_DEFAULT, + DLADM_PROP_VAL_PERM, + DLADM_PROP_VAL_MODIFIABLE, + DLADM_PROP_VAL_PERSISTENT +} dladm_prop_type_t; + +/* + * Maximum size of secobj value. Note that it should not be greater than + * DLD_SECOBJ_VAL_MAX. + */ +#define DLADM_SECOBJ_VAL_MAX 256 + +/* + * Maximum size of secobj name. Note that it should not be greater than + * DLD_SECOBJ_NAME_MAX. + */ +#define DLADM_SECOBJ_NAME_MAX 32 + +#define DLADM_MAX_PROP_VALCNT 32 +/* + * Size of prop_val buffer passed to pd_get function must be at + * least DLADM_PROP_VAL_MAX + */ +#define DLADM_PROP_VAL_MAX 128 + +#define DLADM_SECOBJ_CLASS_WEP 0 +#define DLADM_SECOBJ_CLASS_WPA 1 +typedef int dladm_secobj_class_t; + +typedef int (dladm_walkcb_t)(const char *, void *); + +/* possible flags for ma_flags below */ +#define DLADM_MACADDR_USED 0x1 + +typedef enum { + DLADM_HWGRP_TYPE_RX = 0x1, + DLADM_HWGRP_TYPE_TX +} dladm_hwgrp_type_t; + +typedef struct dladm_hwgrp_attr { + char hg_link_name[MAXLINKNAMELEN]; + uint_t hg_grp_num; + dladm_hwgrp_type_t hg_grp_type; + uint_t hg_n_rings; + uint_t hg_rings[MAX_RINGS_PER_GROUP]; + uint_t hg_n_clnts; + char hg_client_names[MAXCLIENTNAMELEN]; +} dladm_hwgrp_attr_t; + +typedef struct dladm_macaddr_attr { + uint_t ma_slot; + uint_t ma_flags; + uchar_t ma_addr[MAXMACADDRLEN]; + uint_t ma_addrlen; + char ma_client_name[MAXNAMELEN]; + datalink_id_t ma_client_linkid; +} dladm_macaddr_attr_t; + +extern dladm_status_t dladm_walk(dladm_walkcb_t *, dladm_handle_t, void *, + datalink_class_t, datalink_media_t, uint32_t); +extern dladm_status_t dladm_mac_walk(dladm_walkcb_t *, void *); +extern dladm_status_t dladm_info(dladm_handle_t, datalink_id_t, + dladm_attr_t *); + +extern dladm_status_t dladm_rename_link(dladm_handle_t, const char *, + const char *); + +extern dladm_status_t dladm_set_linkprop(dladm_handle_t, datalink_id_t, + const char *, char **, uint_t, uint_t); +extern dladm_status_t dladm_get_linkprop(dladm_handle_t, datalink_id_t, + dladm_prop_type_t, const char *, char **, uint_t *); +extern dladm_status_t dladm_get_linkprop_values(dladm_handle_t, datalink_id_t, + dladm_prop_type_t, const char *, uint_t *, + uint_t *); +extern dladm_status_t dladm_walk_linkprop(dladm_handle_t, datalink_id_t, + void *, int (*)(dladm_handle_t, datalink_id_t, + const char *, void *)); +extern boolean_t dladm_attr_is_linkprop(const char *name); +extern dladm_status_t dladm_linkprop_is_set(dladm_handle_t, datalink_id_t, + dladm_prop_type_t, const char *, boolean_t *); + +extern dladm_status_t dladm_set_secobj(dladm_handle_t, const char *, + dladm_secobj_class_t, uint8_t *, uint_t, uint_t); +extern dladm_status_t dladm_get_secobj(dladm_handle_t, const char *, + dladm_secobj_class_t *, uint8_t *, uint_t *, + uint_t); +extern dladm_status_t dladm_unset_secobj(dladm_handle_t, const char *, + uint_t); +extern dladm_status_t dladm_walk_secobj(dladm_handle_t, void *, + boolean_t (*)(dladm_handle_t, void *, const char *), + uint_t); + +extern const char *dladm_linkstate2str(link_state_t, char *); +extern const char *dladm_linkduplex2str(link_duplex_t, char *); +extern const char *dladm_secobjclass2str(dladm_secobj_class_t, char *); +extern dladm_status_t dladm_str2secobjclass(const char *, + dladm_secobj_class_t *); + +extern dladm_status_t dladm_init_linkprop(dladm_handle_t, datalink_id_t, + boolean_t); +extern dladm_status_t dladm_init_secobj(dladm_handle_t); +extern boolean_t dladm_valid_secobj_name(const char *); + +extern dladm_status_t dladm_create_datalink_id(dladm_handle_t, const char *, + datalink_class_t, uint_t, uint32_t, + datalink_id_t *); +extern dladm_status_t dladm_destroy_datalink_id(dladm_handle_t, datalink_id_t, + uint32_t); +extern dladm_status_t dladm_remap_datalink_id(dladm_handle_t, datalink_id_t, + const char *); +extern dladm_status_t dladm_up_datalink_id(dladm_handle_t, datalink_id_t); +extern dladm_status_t dladm_name2info(dladm_handle_t, const char *, + datalink_id_t *, uint32_t *, datalink_class_t *, + uint32_t *); +extern dladm_status_t dladm_datalink_id2info(dladm_handle_t, datalink_id_t, + uint32_t *, datalink_class_t *, uint32_t *, char *, + size_t); +extern dladm_status_t dladm_walk_datalink_id(int (*)(dladm_handle_t, + datalink_id_t, void *), dladm_handle_t, void *, + datalink_class_t, datalink_media_t, uint32_t); +extern dladm_status_t dladm_create_conf(dladm_handle_t, const char *, + datalink_id_t, datalink_class_t, uint32_t, + dladm_conf_t *); +extern dladm_status_t dladm_open_conf(dladm_handle_t, datalink_id_t, + dladm_conf_t *); +extern dladm_status_t dladm_getsnap_conf(dladm_handle_t, datalink_id_t, + dladm_conf_t *); +extern dladm_status_t dladm_write_conf(dladm_handle_t, dladm_conf_t); +extern dladm_status_t dladm_remove_conf(dladm_handle_t, datalink_id_t); +extern void dladm_destroy_conf(dladm_handle_t, dladm_conf_t); +extern dladm_status_t dladm_get_conf_field(dladm_handle_t, dladm_conf_t, + const char *, void *, size_t); +extern dladm_status_t dladm_getnext_conf_linkprop(dladm_handle_t, + dladm_conf_t, const char *, char *, void *, + size_t, size_t *); +extern dladm_status_t dladm_set_conf_field(dladm_handle_t, dladm_conf_t, + const char *, dladm_datatype_t, const void *); +extern dladm_status_t dladm_unset_conf_field(dladm_handle_t, dladm_conf_t, + const char *); + +extern dladm_status_t dladm_dev2linkid(dladm_handle_t, const char *, + datalink_id_t *); +extern dladm_status_t dladm_linkid2legacyname(dladm_handle_t, datalink_id_t, + char *, size_t); +extern dladm_status_t dladm_phys_delete(dladm_handle_t, datalink_id_t); + +extern dladm_status_t dladm_phys_info(dladm_handle_t, datalink_id_t, + dladm_phys_attr_t *, uint32_t); +extern dladm_status_t dladm_parselink(const char *, char *, uint_t *); + +extern int dladm_walk_macaddr(dladm_handle_t, datalink_id_t, + void *, + boolean_t (*)(void *, dladm_macaddr_attr_t *)); +extern int dladm_walk_hwgrp(dladm_handle_t, datalink_id_t, void *, + boolean_t (*)(void *, dladm_hwgrp_attr_t *)); + +extern void dladm_sort_index_list(uint_t [], uint_t); + +extern dladm_status_t dladm_link_get_proplist(dladm_handle_t, datalink_id_t, + dladm_arg_list_t **); + +extern dladm_status_t i_dladm_set_link_proplist_db(char *, + dladm_arg_list_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDLLINK_H */ diff --git a/illumos-x86_64/usr/include/libdlpi.h b/illumos-x86_64/usr/include/libdlpi.h new file mode 100644 index 00000000..993ac1b7 --- /dev/null +++ b/illumos-x86_64/usr/include/libdlpi.h @@ -0,0 +1,220 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBDLPI_H +#define _LIBDLPI_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Maximum Physical (hardware) address length, in bytes. + * Must be as large as MAXMACADDRLEN (see ). + */ +#define DLPI_PHYSADDR_MAX 64 + +/* + * Maximum link name length, including terminating NUL, in bytes. + * Must be no larger than MAXLINKNAMELEN (see ). + */ +#define DLPI_LINKNAME_MAX 32 + +/* + * Constant used to indicate bind to any SAP value + */ +#define DLPI_ANY_SAP (uint_t)-1 + +/* + * Flag values for dlpi_open(); those not documented in dlpi_open(3DLPI) + * are Consolidation Private and subject to change or removal. + */ +#define DLPI_EXCL 0x0001 /* Exclusive open */ +#define DLPI_PASSIVE 0x0002 /* Open DLPI link in passive mode */ +#define DLPI_RAW 0x0004 /* Open DLPI link in raw mode */ +#define DLPI_SERIAL 0x0008 /* Synchronous serial line interface */ +#define DLPI_NOATTACH 0x0010 /* Do not attach PPA */ +#define DLPI_NATIVE 0x0020 /* Open DLPI link in native mode */ +#define DLPI_DEVONLY 0x0040 /* Open DLPI link under /dev only */ +#define DLPI_DEVIPNET 0x0080 /* Open IP DLPI link under /dev/ipnet */ +#define DLPI_IPNETINFO 0x0100 /* Request ipnetinfo headers */ +/* + * Timeout to be used in DLPI-related operations, in seconds. + */ +#define DLPI_DEF_TIMEOUT 5 + +/* + * Since this library returns error codes defined in either or + * , libdlpi specific error codes will start at value 10000 to + * avoid overlap. DLPI_SUCCESS cannot be 0 because 0 is already DL_BADSAP in + * . + */ +enum { + DLPI_SUCCESS = 10000, /* DLPI operation succeeded */ + DLPI_EINVAL, /* invalid argument */ + DLPI_ELINKNAMEINVAL, /* invalid DLPI linkname */ + DLPI_ENOLINK, /* DLPI link does not exist */ + DLPI_EBADLINK, /* bad DLPI link */ + DLPI_EINHANDLE, /* invalid DLPI handle */ + DLPI_ETIMEDOUT, /* DLPI operation timed out */ + DLPI_EVERNOTSUP, /* unsupported DLPI Version */ + DLPI_EMODENOTSUP, /* unsupported DLPI connection mode */ + DLPI_EUNAVAILSAP, /* unavailable DLPI SAP */ + DLPI_FAILURE, /* DLPI operation failed */ + DLPI_ENOTSTYLE2, /* DLPI style-2 node reports style-1 */ + DLPI_EBADMSG, /* bad DLPI message */ + DLPI_ERAWNOTSUP, /* DLPI raw mode not supported */ + DLPI_ENOTEINVAL, /* invalid DLPI notification type */ + DLPI_ENOTENOTSUP, /* DLPI notification not supported by link */ + DLPI_ENOTEIDINVAL, /* invalid DLPI notification id */ + DLPI_EIPNETINFONOTSUP, /* DLPI_IPNETINFO not supported */ + DLPI_ERRMAX /* Highest + 1 libdlpi error code */ +}; + +/* + * DLPI information; see dlpi_info(3DLPI). + */ +typedef struct { + uint_t di_opts; + uint_t di_max_sdu; + uint_t di_min_sdu; + uint_t di_state; + uint_t di_mactype; + char di_linkname[DLPI_LINKNAME_MAX]; + uchar_t di_physaddr[DLPI_PHYSADDR_MAX]; + uchar_t di_physaddrlen; + uchar_t di_bcastaddr[DLPI_PHYSADDR_MAX]; + uchar_t di_bcastaddrlen; + uint_t di_sap; + int di_timeout; + dl_qos_cl_sel1_t di_qos_sel; + dl_qos_cl_range1_t di_qos_range; +} dlpi_info_t; + +/* + * DLPI send information; see dlpi_send(3DLPI). + */ +typedef struct { + uint_t dsi_sap; + dl_priority_t dsi_prio; +} dlpi_sendinfo_t; + +/* + * Destination DLPI address type; see dlpi_recv(3DLPI). + */ +typedef enum { + DLPI_ADDRTYPE_UNICAST, + DLPI_ADDRTYPE_GROUP +} dlpi_addrtype_t; + +/* + * DLPI receive information; see dlpi_recv(3DLPI). + */ +typedef struct { + uchar_t dri_destaddr[DLPI_PHYSADDR_MAX]; + uchar_t dri_destaddrlen; + dlpi_addrtype_t dri_destaddrtype; + size_t dri_totmsglen; +} dlpi_recvinfo_t; + +/* + * DLPI notification, (DL_NOTIFY_IND) payload information; + * see dlpi_enabnotify(3DLPI). + */ +typedef struct { + uint_t dni_note; + union { + uint_t dniu_speed; + uint_t dniu_size; + struct { + uchar_t physaddr[DLPI_PHYSADDR_MAX]; + uchar_t physaddrlen; + } dniu_addr; + } dni_data; +} dlpi_notifyinfo_t; + +#define dni_speed dni_data.dniu_speed +#define dni_size dni_data.dniu_size +#define dni_physaddr dni_data.dniu_addr.physaddr +#define dni_physaddrlen dni_data.dniu_addr.physaddrlen + +typedef struct __dlpi_handle *dlpi_handle_t; + +/* + * dlpi_notifyid_t refers to a registered notification. Its value should + * not be interpreted by the interface consumer. + */ +typedef struct __dlpi_notifyid *dlpi_notifyid_t; + +/* + * Callback function invoked with arguments; see dlpi_enabnotify(3DLPI). + */ +typedef void dlpi_notifyfunc_t(dlpi_handle_t, dlpi_notifyinfo_t *, void *); + +extern const char *dlpi_mactype(uint_t); +extern const char *dlpi_strerror(int); +extern const char *dlpi_linkname(dlpi_handle_t); + +typedef boolean_t dlpi_walkfunc_t(const char *, void *); + +extern void dlpi_walk(dlpi_walkfunc_t *, void *, uint_t); +extern int dlpi_open(const char *, dlpi_handle_t *, uint_t); +extern void dlpi_close(dlpi_handle_t); +extern int dlpi_info(dlpi_handle_t, dlpi_info_t *, uint_t); +extern int dlpi_bind(dlpi_handle_t, uint_t, uint_t *); +extern int dlpi_unbind(dlpi_handle_t); +extern int dlpi_enabmulti(dlpi_handle_t, const void *, size_t); +extern int dlpi_disabmulti(dlpi_handle_t, const void *, size_t); +extern int dlpi_promiscon(dlpi_handle_t, uint_t); +extern int dlpi_promiscoff(dlpi_handle_t, uint_t); +extern int dlpi_get_physaddr(dlpi_handle_t, uint_t, void *, size_t *); +extern int dlpi_set_physaddr(dlpi_handle_t, uint_t, const void *, size_t); +extern int dlpi_recv(dlpi_handle_t, void *, size_t *, void *, size_t *, + int, dlpi_recvinfo_t *); +extern int dlpi_send(dlpi_handle_t, const void *, size_t, const void *, size_t, + const dlpi_sendinfo_t *); +extern int dlpi_enabnotify(dlpi_handle_t, uint_t, dlpi_notifyfunc_t *, + void *arg, dlpi_notifyid_t *); +extern int dlpi_disabnotify(dlpi_handle_t, dlpi_notifyid_t, void **); +extern int dlpi_fd(dlpi_handle_t); +extern int dlpi_set_timeout(dlpi_handle_t, int); +extern uint_t dlpi_arptype(uint_t); +extern uint_t dlpi_iftype(uint_t); + +/* + * These are Consolidation Private interfaces and are subject to change. + */ +extern int dlpi_parselink(const char *, char *, uint_t *); +extern int dlpi_makelink(char *, const char *, uint_t); +extern uint_t dlpi_style(dlpi_handle_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDLPI_H */ diff --git a/illumos-x86_64/usr/include/libdlvlan.h b/illumos-x86_64/usr/include/libdlvlan.h new file mode 100644 index 00000000..8e32a9ad --- /dev/null +++ b/illumos-x86_64/usr/include/libdlvlan.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBDLVLAN_H +#define _LIBDLVLAN_H + +/* + * This file includes structures, macros and routines used by VLAN link + * administration. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct dladm_vlan_attr { + uint16_t dv_vid; + datalink_id_t dv_linkid; + boolean_t dv_force; +} dladm_vlan_attr_t; + +extern dladm_status_t dladm_vlan_info(dladm_handle_t, datalink_id_t, + dladm_vlan_attr_t *, uint32_t); +extern dladm_status_t dladm_vlan_create(dladm_handle_t, const char *, + datalink_id_t, uint16_t, dladm_arg_list_t *, + uint32_t, datalink_id_t *); +extern dladm_status_t dladm_vlan_delete(dladm_handle_t, datalink_id_t, + uint32_t); +extern dladm_status_t dladm_vlan_up(dladm_handle_t, datalink_id_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBDLVLAN_H */ diff --git a/illumos-x86_64/usr/include/libelf.h b/illumos-x86_64/usr/include/libelf.h new file mode 100644 index 00000000..722d0cdc --- /dev/null +++ b/illumos-x86_64/usr/include/libelf.h @@ -0,0 +1,224 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2014 PALO, Richard. All rights reserved. + */ + +#ifndef _LIBELF_H +#define _LIBELF_H + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if defined(_ILP32) && (_FILE_OFFSET_BITS != 32) +#error "large files are not supported by libelf" +#endif + +typedef void Elf_Void; + +/* + * Commands + */ +typedef enum { + ELF_C_NULL = 0, /* must be first, 0 */ + ELF_C_READ, + ELF_C_WRITE, + ELF_C_CLR, + ELF_C_SET, + ELF_C_FDDONE, + ELF_C_FDREAD, + ELF_C_RDWR, + ELF_C_WRIMAGE, + ELF_C_IMAGE, + ELF_C_NUM /* must be last */ +} Elf_Cmd; + + +/* + * Flags + */ +#define ELF_F_DIRTY 0x1 +#define ELF_F_LAYOUT 0x4 + + +/* + * File types + */ +typedef enum { + ELF_K_NONE = 0, /* must be first, 0 */ + ELF_K_AR, + ELF_K_COFF, + ELF_K_ELF, + ELF_K_NUM /* must be last */ +} Elf_Kind; + + +/* + * Translation types + */ +typedef enum { + ELF_T_BYTE = 0, /* must be first, 0 */ + ELF_T_ADDR, + ELF_T_DYN, + ELF_T_EHDR, + ELF_T_HALF, + ELF_T_OFF, + ELF_T_PHDR, + ELF_T_RELA, + ELF_T_REL, + ELF_T_SHDR, + ELF_T_SWORD, + ELF_T_SYM, + ELF_T_WORD, + ELF_T_VDEF, + ELF_T_VNEED, + ELF_T_SXWORD, + ELF_T_XWORD, + ELF_T_SYMINFO, + ELF_T_NOTE, + ELF_T_MOVE, + ELF_T_MOVEP, + ELF_T_CAP, + ELF_T_NUM /* must be last */ +} Elf_Type; + + +typedef struct Elf Elf; +typedef struct Elf_Scn Elf_Scn; + + +/* + * Archive member header + */ +typedef struct { + char *ar_name; + time_t ar_date; + uid_t ar_uid; + gid_t ar_gid; + mode_t ar_mode; + off_t ar_size; + char *ar_rawname; +} Elf_Arhdr; + + +/* + * Archive symbol table + */ +typedef struct { + char *as_name; + size_t as_off; + unsigned long as_hash; +} Elf_Arsym; + + +/* + * Data descriptor + */ +typedef struct { + Elf_Void *d_buf; + Elf_Type d_type; + size_t d_size; + off_t d_off; /* offset into section */ + size_t d_align; /* alignment in section */ + unsigned d_version; /* elf version */ +} Elf_Data; + + +/* + * Function declarations + */ +Elf *elf_begin(int, Elf_Cmd, Elf *); +int elf_cntl(Elf *, Elf_Cmd); +int elf_end(Elf *); +const char *elf_errmsg(int); +int elf_errno(void); +void elf_fill(int); +unsigned elf_flagdata(Elf_Data *, Elf_Cmd, unsigned); +unsigned elf_flagehdr(Elf *, Elf_Cmd, unsigned); +unsigned elf_flagelf(Elf *, Elf_Cmd, unsigned); +unsigned elf_flagphdr(Elf *, Elf_Cmd, unsigned); +unsigned elf_flagscn(Elf_Scn *, Elf_Cmd, unsigned); +unsigned elf_flagshdr(Elf_Scn *, Elf_Cmd, unsigned); +size_t elf32_fsize(Elf_Type, size_t, unsigned); +Elf_Arhdr *elf_getarhdr(Elf *); +Elf_Arsym *elf_getarsym(Elf *, size_t *); +off_t elf_getbase(Elf *); +Elf_Data *elf_getdata(Elf_Scn *, Elf_Data *); +Elf32_Ehdr *elf32_getehdr(Elf *); +char *elf_getident(Elf *, size_t *); +Elf32_Phdr *elf32_getphdr(Elf *); +Elf_Scn *elf_getscn(Elf *elf, size_t); +Elf32_Shdr *elf32_getshdr(Elf_Scn *); +int elf_getphnum(Elf *, size_t *); +int elf_getphdrnum(Elf *, size_t *); +int elf_getshnum(Elf *, size_t *); +int elf_getshdrnum(Elf *, size_t *); +int elf_getshstrndx(Elf *, size_t *); +int elf_getshdrstrndx(Elf *, size_t *); +unsigned long elf_hash(const char *); +uint_t elf_sys_encoding(void); +long elf32_checksum(Elf *); +Elf_Kind elf_kind(Elf *); +Elf *elf_memory(char *, size_t); +size_t elf_ndxscn(Elf_Scn *); +Elf_Data *elf_newdata(Elf_Scn *); +Elf32_Ehdr *elf32_newehdr(Elf *); +Elf32_Phdr *elf32_newphdr(Elf *, size_t); +Elf_Scn *elf_newscn(Elf *); +Elf_Scn *elf_nextscn(Elf *, Elf_Scn *); +Elf_Cmd elf_next(Elf *); +size_t elf_rand(Elf *, size_t); +Elf_Data *elf_rawdata(Elf_Scn *, Elf_Data *); +char *elf_rawfile(Elf *, size_t *); +char *elf_strptr(Elf *, size_t, size_t); +off_t elf_update(Elf *, Elf_Cmd); +unsigned elf_version(unsigned); +Elf_Data *elf32_xlatetof(Elf_Data *, const Elf_Data *, unsigned); +Elf_Data *elf32_xlatetom(Elf_Data *, const Elf_Data *, unsigned); + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +size_t elf64_fsize(Elf_Type, size_t, unsigned); +Elf64_Ehdr *elf64_getehdr(Elf *); +Elf64_Phdr *elf64_getphdr(Elf *); +Elf64_Shdr *elf64_getshdr(Elf_Scn *); +long elf64_checksum(Elf *); +Elf64_Ehdr *elf64_newehdr(Elf *); +Elf64_Phdr *elf64_newphdr(Elf *, size_t); +Elf_Data *elf64_xlatetof(Elf_Data *, const Elf_Data *, unsigned); +Elf_Data *elf64_xlatetom(Elf_Data *, const Elf_Data *, unsigned); +#endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBELF_H */ diff --git a/illumos-x86_64/usr/include/libfcoe.h b/illumos-x86_64/usr/include/libfcoe.h new file mode 100644 index 00000000..62288769 --- /dev/null +++ b/illumos-x86_64/usr/include/libfcoe.h @@ -0,0 +1,167 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBFCOE_H +#define _LIBFCOE_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * FCoE Port Type + */ +#define FCOE_PORTTYPE_INITIATOR 0 +#define FCOE_PORTTYPE_TARGET 1 + +#define FCOE_MAX_MAC_NAME_LEN 32 + +#define FCOE_SCF_ADD 0 +#define FCOE_SCF_REMOVE 1 + +#define FCOE_SUCCESS 0 +#define FCOE_ERROR 1 +#define FCOE_ERROR_EXISTS 2 +#define FCOE_ERROR_SERVICE_NOT_FOUND 3 +#define FCOE_ERROR_NOMEM 4 +#define FCOE_ERROR_MEMBER_NOT_FOUND 5 +#define FCOE_ERROR_BUSY 6 + +#define FCOE_TARGET_SERVICE "system/fcoe_target" +#define FCOE_INITIATOR_SERVICE "system/fcoe_initiator" +#define FCOE_PG_NAME "fcoe-port-list-pg" +#define FCOE_PORT_LIST "port_list_p" + +#define FCOE_PORT_LIST_LENGTH 255 + +typedef unsigned char FCOE_UINT8; +typedef char FCOE_INT8; +typedef unsigned short FCOE_UINT16; +typedef short FCOE_INT16; +typedef unsigned int FCOE_UINT32; +typedef int FCOE_INT32; + +typedef unsigned int FCOE_STATUS; + +#define FCOE_STATUS_OK 0 +#define FCOE_STATUS_ERROR 1 +#define FCOE_STATUS_ERROR_INVAL_ARG 2 +#define FCOE_STATUS_ERROR_BUSY 3 +#define FCOE_STATUS_ERROR_ALREADY 4 +#define FCOE_STATUS_ERROR_PERM 5 +#define FCOE_STATUS_ERROR_OPEN_DEV 6 +#define FCOE_STATUS_ERROR_WWN_SAME 7 +#define FCOE_STATUS_ERROR_MAC_LEN 8 +#define FCOE_STATUS_ERROR_PWWN_CONFLICTED 9 +#define FCOE_STATUS_ERROR_NWWN_CONFLICTED 10 +#define FCOE_STATUS_ERROR_NEED_JUMBO_FRAME 11 +#define FCOE_STATUS_ERROR_CREATE_MAC 12 +#define FCOE_STATUS_ERROR_OPEN_MAC 13 +#define FCOE_STATUS_ERROR_CREATE_PORT 14 +#define FCOE_STATUS_ERROR_MAC_NOT_FOUND 15 +#define FCOE_STATUS_ERROR_OFFLINE_DEV 16 +#define FCOE_STATUS_ERROR_MORE_DATA 17 +#define FCOE_STATUS_ERROR_CLASS_UNSUPPORT 18 +#define FCOE_STATUS_ERROR_GET_LINKINFO 19 + +typedef struct fcoe_port_wwn { + uchar_t wwn[8]; +} FCOE_PORT_WWN, *PFCOE_PORT_WWN; + +typedef struct fcoe_port_attr { + FCOE_PORT_WWN port_wwn; + FCOE_UINT8 mac_link_name[MAXLINKNAMELEN]; + FCOE_UINT8 mac_factory_addr[ETHERADDRL]; + FCOE_UINT8 mac_current_addr[ETHERADDRL]; + FCOE_UINT8 port_type; + FCOE_UINT32 mtu_size; + FCOE_UINT8 mac_promisc; +} FCOE_PORT_ATTRIBUTE, *PFCOE_PORT_ATTRIBUTE; + +/* + * FCoE port instance in smf repository + */ +typedef struct fcoe_smf_port_instance { + FCOE_UINT8 mac_link_name[MAXLINKNAMELEN]; + FCOE_UINT8 port_type; + FCOE_PORT_WWN port_pwwn; + FCOE_PORT_WWN port_nwwn; + FCOE_UINT8 mac_promisc; +} FCOE_SMF_PORT_INSTANCE, *PFCOE_SMF_PORT_INSTANCE; + +/* + * FCoE port instance list + */ +typedef struct fcoe_smf_port_list { + FCOE_UINT32 port_num; + FCOE_SMF_PORT_INSTANCE ports[1]; +} FCOE_SMF_PORT_LIST, *PFCOE_SMF_PORT_LIST; + +/* + * macLinkName: mac name with maximum lenth 32 + * portType: 0 (Initiator)/ 1(Target) + * pwwn: Port WWN + * nwwn: Nodw WWN + * promiscous: to enable promisc mode for mac interface + */ +FCOE_STATUS FCOE_CreatePort( + const FCOE_UINT8 *macLinkName, /* maximum len: 32 */ + FCOE_UINT8 portType, + FCOE_PORT_WWN pwwn, + FCOE_PORT_WWN nwwn, + FCOE_UINT8 promiscusous +); + +FCOE_STATUS FCOE_DeletePort( + const FCOE_UINT8 *macLinkName +); + +/* + * Make sure to free the memory pointed by portlist + */ +FCOE_STATUS FCOE_GetPortList( + FCOE_UINT32 *port_num, + FCOE_PORT_ATTRIBUTE **portlist +); + +/* + * Make sure to free the memory pointed by portlist + */ +FCOE_STATUS FCOE_LoadConfig( + FCOE_UINT8 portType, + FCOE_SMF_PORT_LIST **portlist +); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBFCOE_H */ diff --git a/illumos-x86_64/usr/include/libfdisk.h b/illumos-x86_64/usr/include/libfdisk.h new file mode 100644 index 00000000..c94e2ddf --- /dev/null +++ b/illumos-x86_64/usr/include/libfdisk.h @@ -0,0 +1,304 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _LIBFDISK_H_ +#define _LIBFDISK_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_LOGDRIVE_OFFSET 63 + +#define FDISK_ERRNO 200 +#define FDISK_ETOOLONG (FDISK_ERRNO + 0) +#define FDISK_EOOBOUND (FDISK_ERRNO + 1) +#define FDISK_EZERO (FDISK_ERRNO + 2) +#define FDISK_EOVERLAP (FDISK_ERRNO + 3) +#define FDISK_ENOVGEOM (FDISK_ERRNO + 4) +#define FDISK_ENOPGEOM (FDISK_ERRNO + 5) +#define FDISK_ENOLGEOM (FDISK_ERRNO + 6) +#define FDISK_ENOLOGDRIVE (FDISK_ERRNO + 7) +#define FDISK_EBADLOGDRIVE (FDISK_ERRNO + 8) +#define FDISK_ENOEXTPART (FDISK_ERRNO + 9) +#define FDISK_EBADMAGIC (FDISK_ERRNO + 10) +#define FDISK_EMOUNTED (FDISK_ERRNO + 11) + +#define FDISK_SUCCESS 0 + +#define FDISK_READ_DISK 0x00000001 + +#define LINUX_SWAP_MAGIC_LENGTH 10 +enum { + PHYSGEOM = 0, + VIRTGEOM, + NCYL, + NHEADS, + NSECTPT, + SSIZE, + ACYL +}; + +enum { + FDISK_MINOR_WRITE = 1, + FDISK_MAJOR_WRITE +}; + +#define FDISK_SECTS_PER_CYL(epp) \ + (epp->disk_geom.phys_heads * epp->disk_geom.phys_sec) +#define FDISK_SECT_TO_CYL(epp, x) ((x) / (FDISK_SECTS_PER_CYL(epp))) +#define FDISK_CYL_TO_SECT(epp, x) ((x) * (FDISK_SECTS_PER_CYL(epp))) +#define FDISK_ABS_CYL_NUM(epp, x) (FDISK_SECT_TO_CYL(x) +\ + epp->ext_beg_cyl) + +#define FDISK_CYL_BNDRY_ALIGN(epp, x) (((x) % (FDISK_SECTS_PER_CYL(epp))) ? \ + (((x)/(FDISK_SECTS_PER_CYL(epp))) + 1) :\ + ((x)/(FDISK_SECTS_PER_CYL(epp)))) + +/* + * Extended partition structure : + * +--------------+ + * |+--+ | + * || |----------+---> structure at the beginning of the extended partition + * ||--| | ( Lets call it the EBR - Extended Boot Record ) + * || | +---+---> + * |+--+ | | Logical drive within the extended partition + * |+---------+--+| ( We will plainly call this a logical drive ) + * || || + * || || + * || || + * |+------------+| + * +--------------+ + * + * + * EBR is effectively "struct ipart parts[2]". + * The picture below shows what the EBR contains. The EBR has + * two important pieces of information. The first is the offset and the size + * of the logical drive in this extended partition. The second is the offset + * and size of the next extended partition. The offsets are relative to + * beginning of the first extended partition. These extended partitions are + * arranged like a linked list. + * Note that (currently) only one extended partition can exist in the MBR. + * The system ID of a logical drive within the extended partition cannot be + * that of an extended partition. + * + * +------+ + * | | + * +--------------+ | +-v------------+ + * |+--+ | | |+--+ | + * || |---+ | | || | | + * ||--| | | | ||--| | + * || |---|------+-+ || | | + * |+--+ | | |+--+ | + * |+------v-----+| |+------------+| + * || || || || + * || || || || + * || || || || + * |+------------+| |+------------+| + * +--------------+ +--------------+ + * + */ + +/* + * Main structure used to record changes to the partitions made. + * Changes are not written to disk everytime, but maintained in this structure. + * This information is used when the user chooses to commit the changes. + * A linked list of this structure represents the ondisk partitions. + */ +typedef struct logical_drive { + + /* structure holding the EBR data */ + struct ipart parts[2]; + + /* + * Absolute beginning sector of the extended partition, and hence an + * indicator of where the EBR for this logical drive would go on disk. + * NOTE : In case the first logical drive in this extended partition is + * out of (disk) order, this indicates the beginning of the logical + * drive. The EBR will anyway be at the first sector of the extended + * partition, for the first logical drive. + */ + uint32_t abs_secnum; + + /* + * Offset of the logical drive from the beginning of its extended + * partition + */ + uint32_t logdrive_offset; + + /* Size of the logical drive in sectors */ + uint32_t numsect; + + /* Beginning and ending cylinders of the extended partition */ + uint32_t begcyl, endcyl; + + /* + * Flag to indicate if this record is to be sync'ed to disk. + * It takes two values : FDISK_MAJOR_WRITE and FDISK_MINOR_WRITE + * If it is a minor write, there is no need to update the information + * in the kernel structures. Example of a minor write is correction of + * a corrupt boot signature. + */ + int modified; + + /* + * This pointer points to the next extended partition in the order + * found on disk. + */ + struct logical_drive *next; + + /* + * This pointer points to the next extended partition in a sorted list + * sorted in the ascending order of their beginning cylinders. + */ + struct logical_drive *sorted_next; + +} logical_drive_t; + +typedef struct fdisk_disk_geom { + ushort_t phys_cyl; + ushort_t phys_sec; + ushort_t phys_heads; + ushort_t alt_cyl; + ushort_t virt_cyl; + ushort_t virt_sec; + ushort_t virt_heads; + ushort_t sectsize; +} fdisk_disk_geom_t; + +typedef struct ext_part +{ + /* Structure holding geometry information about the device */ + fdisk_disk_geom_t disk_geom; + + struct ipart *mtable; + + char device_name[PATH_MAX]; + + int dev_fd; + + int op_flag; + + /* + * Head of the in memory structure (singly linked list) of extended + * partition information. + */ + logical_drive_t *ld_head; + logical_drive_t *sorted_ld_head; + + /* Beginning cylinder of the extended partition */ + uint32_t ext_beg_cyl; + + /* Ending cylinder of the extended partition */ + uint32_t ext_end_cyl; + + /* Beginning sector of the extended partition */ + uint32_t ext_beg_sec; + + /* Ending sector of the extended partition */ + uint32_t ext_end_sec; + + /* Count of the number of logical drives in the extended partition */ + int logical_drive_count; + + /* + * Flag to keep track of the update to be made to the Extended Boot + * Record (EBR) when all logical drives are deleted. The EBR is filled + * with zeroes in such a case. + */ + int first_ebr_is_null; + + /* + * Flag to indicate corrupt logical drives. Can happen when a partition + * manager creates an extended partition and does not null the first EBR + * or when important ondisk structures are overwritten by a bad program + */ + int corrupt_logical_drives; + + /* + * The boot block signature 0xAA55 might not be found on some of the + * EBRs. ( Even though the rest of the data might be good ) + * The following array is used to store the list of such logical drive + * numbers. + */ + uchar_t invalid_bb_sig[MAX_EXT_PARTS]; + + /* + * Can add a "next" pointer here in case support for multiple + * extended partitions becomes the standard someday. + * + * struct ext_part *next; + */ +} ext_part_t; + +#define fdisk_get_logical_drive_count(epp) ((epp)->logical_drive_count) +#define fdisk_corrupt_logical_drives(epp) ((epp)->corrupt_logical_drives) +#define fdisk_get_ext_beg_cyl(epp) ((epp)->ext_beg_cyl) +#define fdisk_get_ext_end_cyl(epp) ((epp)->ext_end_cyl) +#define fdisk_get_ext_beg_sec(epp) ((epp)->ext_beg_sec) +#define fdisk_get_ext_end_sec(epp) ((epp)->ext_end_sec) +#define fdisk_get_ld_head(epp) ((epp)->ld_head) +#define fdisk_is_solaris_part(id) (((id) == SUNIXOS) || ((id) == SUNIXOS2)) +#define fdisk_is_dos_extended(id) (((id) == EXTDOS) || ((id) == FDISK_EXTLBA)) + +extern int fdisk_is_linux_swap(ext_part_t *epp, uint32_t part_start, + uint64_t *lsm_offset); +extern int libfdisk_init(ext_part_t **epp, char *devstr, struct ipart *parttab, + int opflag); +extern int libfdisk_reset(ext_part_t *epp); +extern void libfdisk_fini(ext_part_t **epp); +extern int fdisk_ext_find_first_free_sec(ext_part_t *epp, + uint32_t *first_free_sec); +extern uint32_t fdisk_ext_find_last_free_sec(ext_part_t *epp, uint32_t begsec); +extern int fdisk_ext_part_exists(ext_part_t *epp); +extern int fdisk_validate_logical_drive(ext_part_t *epp, uint32_t begsec, + uint32_t offset, uint32_t numsec); +extern int fdisk_ext_validate_part_start(ext_part_t *epp, uint32_t begcyl, + uint32_t *begsec); +extern int fdisk_get_solaris_part(ext_part_t *epp, int *pnum, uint32_t *begsec, + uint32_t *numsec); +extern int fdisk_get_part_info(ext_part_t *epp, int pnum, uchar_t *sysid, + uint32_t *begsec, uint32_t *numsec); +extern int fdisk_commit_ext_part(ext_part_t *epp); +extern void fdisk_change_logical_drive_id(ext_part_t *epp, int pno, + uchar_t partid); +extern void fdisk_add_logical_drive(ext_part_t *epp, uint32_t begsec, + uint32_t endsec, uchar_t partid); +extern void fdisk_delete_logical_drive(ext_part_t *epp, int pno); +extern int fdisk_init_ext_part(ext_part_t *epp, uint32_t rsect, uint32_t nsect); +extern int fdisk_delete_ext_part(ext_part_t *epp); +extern int fdisk_get_disk_geom(ext_part_t *epp, int type, int what); +extern int fdisk_invalid_bb_sig(ext_part_t *epp, uchar_t **bbsig_arr); +extern int fdisk_mounted_logical_drives(ext_part_t *epp); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBFDISK_H_ */ diff --git a/illumos-x86_64/usr/include/libfstyp.h b/illumos-x86_64/usr/include/libfstyp.h new file mode 100644 index 00000000..2ac60caf --- /dev/null +++ b/illumos-x86_64/usr/include/libfstyp.h @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBFSTYP_H +#define _LIBFSTYP_H + +/* + * libfstyp: filesystem identification library + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef struct fstyp_handle *fstyp_handle_t; + +enum { + FSTYP_ERR_OK = 0, + FSTYP_ERR_NO_MATCH, /* no matches */ + FSTYP_ERR_MULT_MATCH, /* multiple matches */ + FSTYP_ERR_HANDLE, /* invalid handle */ + FSTYP_ERR_OFFSET, /* invalid or unsupported offset */ + FSTYP_ERR_NO_PARTITION, /* partition not found */ + FSTYP_ERR_NOP, /* no such operation */ + FSTYP_ERR_DEV_OPEN, /* cannot open device */ + FSTYP_ERR_IO, /* I/O error */ + FSTYP_ERR_NOMEM, /* out of memory */ + FSTYP_ERR_MOD_NOT_FOUND, /* requested fs module not found */ + FSTYP_ERR_MOD_DIR_OPEN, /* cannot open directory */ + FSTYP_ERR_MOD_OPEN, /* cannot open module */ + FSTYP_ERR_MOD_VERSION, /* invalid module version */ + FSTYP_ERR_MOD_INVALID, /* invalid module */ + FSTYP_ERR_NAME_TOO_LONG /* fs name exceeds FSTYPSZ */ +}; + +/* + * generic attribute names + * + * gen_clean (DATA_TYPE_BOOLEAN_VALUE) + * gen_guid (DATA_TYPE_STRING) + * gen_version (DATA_TYPE_STRING) + * gen_volume_label (DATA_TYPE_STRING) + */ + +int fstyp_init(int fd, off64_t offset, char *module_dir, + fstyp_handle_t *handle); +void fstyp_fini(fstyp_handle_t handle); +int fstyp_ident(fstyp_handle_t handle, const char *fsname, + const char **ident); +int fstyp_get_attr(fstyp_handle_t handle, nvlist_t **attr); +int fstyp_dump(fstyp_handle_t handle, FILE *fout, FILE *ferr); +const char *fstyp_strerror(fstyp_handle_t handle, int error); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBFSTYP_H */ diff --git a/illumos-x86_64/usr/include/libfstyp_module.h b/illumos-x86_64/usr/include/libfstyp_module.h new file mode 100644 index 00000000..3ad5a797 --- /dev/null +++ b/illumos-x86_64/usr/include/libfstyp_module.h @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBFSTYP_MODULE_H +#define _LIBFSTYP_MODULE_H + +/* + * libfstyp: module interface + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +typedef struct fstyp_mod_handle *fstyp_mod_handle_t; + +/* + * Modules are must to export these functions. + * fstyp_mod_dump() is optional. + */ +int fstyp_mod_init(int fd, off64_t offset, fstyp_mod_handle_t *handle); +void fstyp_mod_fini(fstyp_mod_handle_t handle); +int fstyp_mod_ident(fstyp_mod_handle_t handle); +int fstyp_mod_get_attr(fstyp_mod_handle_t handle, nvlist_t **attr); +int fstyp_mod_dump(fstyp_mod_handle_t handle, FILE *fout, FILE *ferr); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBFSTYP_MODULE_H */ diff --git a/illumos-x86_64/usr/include/libgen.h b/illumos-x86_64/usr/include/libgen.h new file mode 100644 index 00000000..ba3e1c60 --- /dev/null +++ b/illumos-x86_64/usr/include/libgen.h @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * declarations of functions found in libgen + */ + +#ifndef _LIBGEN_H +#define _LIBGEN_H + +#include + +#include +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include +#include +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char *basename(char *); +extern char *dirname(char *); + +#if !defined(_XPG6) || defined(__EXTENSIONS__) +extern char *regcmp(const char *, ...); +extern char *regex(const char *, const char *, ...); +#endif + +#ifdef _REENTRANT +extern char **____loc1(void); +#define __loc1 (*(____loc1())) +#elif !defined(_XPG6) || defined(__EXTENSIONS__) +extern char *__loc1; /* Marked LEGACY in XPG5 and removed in XPG6 */ +#endif /* _REENTRANT */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + +extern char *bgets(char *, size_t, FILE *, char *); +extern size_t bufsplit(char *, size_t, char **); + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname copylist copylist64 +#else +#define copylist copylist64 +#endif +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname copylist64 copylist +#else +#define copylist64 copylist +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern char *copylist(const char *, off_t *); +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern char *copylist64(const char *, off64_t *); +#endif /* _LARGEFILE64_SOURCE... */ + +extern int eaccess(const char *, int); +extern int gmatch(const char *, const char *); +extern int isencrypt(const char *, size_t); +extern int mkdirp(const char *, mode_t); +extern int p2open(const char *, FILE *[2]); +extern int p2close(FILE *[2]); +extern char *pathfind(const char *, const char *, const char *); + +#ifdef _REENTRANT +#define __i_size (*(___i_size())) +#else +extern int __i_size; +#endif + +extern int rmdirp(char *, char *); +extern char *strcadd(char *, const char *); +extern char *strccpy(char *, const char *); +extern char *streadd(char *, const char *, const char *); +extern char *strecpy(char *, const char *, const char *); +extern int strfind(const char *, const char *); +extern char *strrspn(const char *, const char *); +extern char *strtrns(const char *, const char *, const char *, char *); + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBGEN_H */ diff --git a/illumos-x86_64/usr/include/libgrubmgmt.h b/illumos-x86_64/usr/include/libgrubmgmt.h new file mode 100644 index 00000000..fb4d8876 --- /dev/null +++ b/illumos-x86_64/usr/include/libgrubmgmt.h @@ -0,0 +1,98 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBGRUBMGMT_H +#define _LIBGRUBMGMT_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define GRUB_ENTRY_DEFAULT -1 /* Use the default entry */ + +/* + * Data structure for describing the GRUB menu + */ +typedef struct grub_menu grub_menu_t; +typedef struct grub_line grub_line_t; +typedef struct grub_entry grub_entry_t; + +/* + * Data structure for describing the file system where the + * GRUB menu resides + */ +typedef struct grub_fsdesc { + int gfs_is_tmp_mounted; /* is temporary mounted */ + char gfs_dev[MAXNAMELEN]; /* device/zfs dataset to mount */ + char gfs_mountp[MAXPATHLEN]; /* mount point */ +} grub_fsdesc_t; + +/* + * Data structure for collecting data for Fast Reboot + */ +typedef struct grub_boot_args { + grub_fsdesc_t gba_fsd; + int gba_kernel_fd; + char gba_kernel[BOOTARGS_MAX]; + char gba_module[BOOTARGS_MAX]; + char gba_bootargs[BOOTARGS_MAX]; +} grub_boot_args_t; + +/* + * Wrapper functions for retriving boot arguments for Fast Reboot. + * grub_get_boot_args() calls grub_menu_init() and grub_menu_fini(). + * If menupath is NULL, it will use 'currently active' GRUB menu file. + * + * All _get_boot_args functions will mount the root file system for the + * given entry if not mounted, and open and validate the kernel file. + * Caller must allocate bargs, and call grub_cleanup_boot_args() to + * clean up mount points and open file handles when done. + * + * grub_get_boot_args: + * Collects boot argument from the specified GRUB menu entry. + * If entrynum == -1, default GRUB menu entry will be used. + * + * grub_cleanup_boot_args: + * Cleans up and releases all the resources allocated by + * grub_get_boot_args. Closes kernel file. Umounts root file + * system if temporarily mounted. + */ +extern int grub_get_boot_args(grub_boot_args_t *bargs, const char *menupath, + int entrynum); +extern void grub_cleanup_boot_args(grub_boot_args_t *bargs); + +extern const char *grub_strerror(int); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBGRUBMGMT_H */ diff --git a/illumos-x86_64/usr/include/libintl.h b/illumos-x86_64/usr/include/libintl.h new file mode 100644 index 00000000..262fa89a --- /dev/null +++ b/illumos-x86_64/usr/include/libintl.h @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _LIBINTL_H +#define _LIBINTL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * wchar_t is a built-in type in standard C++ and as such is not + * defined here when using standard C++. However, the GNU compiler + * fixincludes utility nonetheless creates its own version of this + * header for use by gcc and g++. In that version it adds a redundant + * guard for __cplusplus. To avoid the creation of a gcc/g++ specific + * header we need to include the following magic comment: + * + * we must use the C++ compiler's type + * + * The above comment should not be removed or changed until GNU + * gcc/fixinc/inclhack.def is updated to bypass this header. + */ +#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__)) +#ifndef _WCHAR_T +#define _WCHAR_T +#if defined(_LP64) +typedef int wchar_t; +#else +typedef long wchar_t; +#endif +#endif /* !_WCHAR_T */ +#endif /* !defined(__cplusplus) ... */ + +#define TEXTDOMAINMAX 256 + +#define __GNU_GETTEXT_SUPPORTED_REVISION(m) \ + ((((m) == 0) || ((m) == 1)) ? 1 : -1) + +extern char *dcgettext(const char *, const char *, const int); +extern char *dgettext(const char *, const char *); +extern char *gettext(const char *); +extern char *textdomain(const char *); +extern char *bindtextdomain(const char *, const char *); + +/* + * LI18NUX 2000 Globalization Specification Version 1.0 + * with Amendment 2 + */ +extern char *dcngettext(const char *, const char *, + const char *, unsigned long int, int); +extern char *dngettext(const char *, const char *, + const char *, unsigned long int); +extern char *ngettext(const char *, const char *, unsigned long int); +extern char *bind_textdomain_codeset(const char *, const char *); + +/* Word handling functions --- requires dynamic linking */ +/* Warning: these are experimental and subject to change. */ +extern int wdinit(void); +extern int wdchkind(wchar_t); +extern int wdbindf(wchar_t, wchar_t, int); +extern wchar_t *wddelim(wchar_t, wchar_t, int); +extern wchar_t mcfiller(void); +extern int mcwrap(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBINTL_H */ diff --git a/illumos-x86_64/usr/include/libipmi.h b/illumos-x86_64/usr/include/libipmi.h new file mode 100644 index 00000000..1e69e578 --- /dev/null +++ b/illumos-x86_64/usr/include/libipmi.h @@ -0,0 +1,1936 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. All rights reserved. + */ + +#ifndef _LIBIPMI_H +#define _LIBIPMI_H + +#include +#include +#include + +/* + * Private interfaces for communicating with attached services over IPMI. This + * library is designed for system software communicating with Illumos-supported + * service processors over /dev/ipmi0. It is not a generic IPMI library. + * + * Documentation references refer to "Intelligent Platform Management Interface + * Specification Second Generation v2.0", document revision 1.0 with Februrary + * 15, 2006 Markup from "IPMI v2.0 Addenda, Errata, and Clarifications Revision + * 3". + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ipmi_handle ipmi_handle_t; + +#pragma pack(1) + +/* + * Basic netfn definitions. See section 5.1. + */ +#define IPMI_NETFN_CHASSIS 0x0 +#define IPMI_NETFN_BRIDGE 0x2 +#define IPMI_NETFN_SE 0x4 +#define IPMI_NETFN_APP 0x6 +#define IPMI_NETFN_FIRMWARE 0x8 +#define IPMI_NETFN_STORAGE 0xa +#define IPMI_NETFN_TRANSPORT 0x0C +#define IPMI_NETFN_OEM 0x2e + +/* + * Error definitions + */ +#define EIPMI_BASE 2000 + +typedef enum { + EIPMI_NOMEM = EIPMI_BASE, /* memory allocation failure */ + EIPMI_BMC_OPEN_FAILED, /* failed to open /dev/ipmi0 */ + EIPMI_BMC_PUTMSG, /* failed to send message to /dev/ipmi0 */ + EIPMI_BMC_GETMSG, /* failed to read response from /dev/ipmi0 */ + EIPMI_BMC_RESPONSE, /* response from /dev/ipmi0 failed */ + EIPMI_INVALID_COMMAND, /* invalid command */ + EIPMI_COMMAND_TIMEOUT, /* command timeout */ + EIPMI_DATA_LENGTH_EXCEEDED, /* maximum data length exceeded */ + EIPMI_SEND_FAILED, /* failed to send BMC request */ + EIPMI_UNSPECIFIED, /* unspecified BMC error */ + EIPMI_UNKNOWN, /* unknown error */ + EIPMI_BAD_RESPONSE, /* received unexpected response */ + EIPMI_BAD_RESPONSE_LENGTH, /* unexpected response length */ + EIPMI_INVALID_RESERVATION, /* invalid or cancelled reservation */ + EIPMI_NOT_PRESENT, /* requested entity not present */ + EIPMI_INVALID_REQUEST, /* malformed request data */ + EIPMI_BUSY, /* service processor is busy */ + EIPMI_NOSPACE, /* service processor is out of space */ + EIPMI_UNAVAILABLE, /* service processor is unavailable */ + EIPMI_ACCESS, /* insufficient privileges */ + EIPMI_BADPARAM, /* parameter is not supported */ + EIPMI_READONLY, /* attempt to write read-only param */ + EIPMI_WRITEONLY, /* attempt to read write-only param */ + EIPMI_LAN_OPEN_FAILED, /* failed to open socket */ + EIPMI_LAN_PING_FAILED, /* RMCP Ping message failed */ + EIPMI_LAN_PASSWD_NOTSUP, /* password authentication not supported */ + EIPMI_LAN_CHALLENGE, /* failure getting challenge */ + EIPMI_LAN_SESSION, /* failure activating session */ + EIPMI_LAN_SETPRIV /* failure setting session privs */ +} ipmi_errno_t; + +/* + * Basic library functions. + * + * The ipmi_handle is the primary interface to the library. The library itself + * is not MT-safe, but it is safe within a single handle. Multithreaded clients + * should either open multiple handles, or otherwise synchronize access to the + * same handle. + * + * There is a single command response buffer that is stored with the handle, to + * simplify memory management in the caller. The memory referenced by a command + * response is only valid until the next command is issued. The caller is + * responsible for making a copy of the response if it is needed. + */ +extern ipmi_handle_t *ipmi_open(int *, char **, uint_t xport_type, nvlist_t *); + +/* + * Constants for nvpair names for the params nvlist that is passed to + * ipmi_open(). If the IPMI_TRANSPORT_BMC is desired, then it is sufficient + * to just specify NULL for the params nvlist. + * + * For IPMI_TRANSPORT_LAN, the params nvlist must contain the following + * nvpairs: + * + * IPMI_LAN_HOST, IPMI_LAN_USER, IPMI_LAN_PASSWD + * + * IPMI_LAN_PORT is optional and will default to 623 + * IPMI_LAN_PRIVLVL is optional and will default to admin + * IPMI_LAN_TIMEOUT is optional and will default to 3 seconds + * IPMI_LAN_NUM_RETIES is optional and will default to 5 + */ +#define IPMI_TRANSPORT_TYPE "transport-type" +#define IPMI_TRANSPORT_BMC 0x01 +#define IPMI_TRANSPORT_LAN 0x02 + +#define IPMI_LAN_HOST "lan-host" +#define IPMI_LAN_PORT "lan-port" +#define IPMI_LAN_USER "lan-user" +#define IPMI_LAN_PASSWD "lan-passwd" +#define IPMI_LAN_PRIVLVL "lan-privlvl" +#define IPMI_LAN_TIMEOUT "lan-timeout" +#define IPMI_LAN_NUM_RETRIES "lan-num-retries" + +extern void ipmi_close(ipmi_handle_t *); + +extern int ipmi_errno(ipmi_handle_t *); +extern const char *ipmi_errmsg(ipmi_handle_t *); + +/* + * Raw requests. See section 5. + */ +typedef struct ipmi_cmd { + uint8_t ic_netfn:6; + uint8_t ic_lun:2; + uint8_t ic_cmd; + uint16_t ic_dlen; + void *ic_data; +} ipmi_cmd_t; + +extern ipmi_cmd_t *ipmi_send(ipmi_handle_t *, ipmi_cmd_t *); + +/* + * Retrieve basic information about the IPMI device. See section 20.1 "Get + * Device ID Command". + */ +#define IPMI_CMD_GET_DEVICEID 0x01 + +typedef struct ipmi_deviceid { + uint8_t id_devid; + DECL_BITFIELD3( + id_dev_rev :4, + __reserved :3, + id_dev_sdrs :1); + DECL_BITFIELD2( + id_firm_major :7, + id_dev_available :1); + uint8_t id_firm_minor; + uint8_t id_ipmi_rev; + uint8_t id_dev_support; + uint8_t id_manufacturer[3]; + uint8_t id_product[2]; +} ipmi_deviceid_t; + +#define IPMI_OEM_SUN 0x2a +#define IPMI_PROD_SUN_ILOM 0x4701 + +ipmi_deviceid_t *ipmi_get_deviceid(ipmi_handle_t *); + +#define ipmi_devid_manufacturer(dp) \ + ((dp)->id_manufacturer[0] | \ + ((dp)->id_manufacturer[1] << 8) | \ + ((dp)->id_manufacturer[2] << 16)) + +#define ipmi_devid_product(dp) \ + ((dp)->id_product[0] | \ + ((dp)->id_product[1] << 8)) + +const char *ipmi_firmware_version(ipmi_handle_t *); + +/* + * Get Channel Auth Caps. See section 22.13. + */ +typedef struct ipmi_channel_auth_caps { + uint8_t cap_channel; + DECL_BITFIELD3( + cap_authtype :6, + __reserved1 :1, + cap_ipmirev2 :1); + DECL_BITFIELD5( + cap_anon :3, + cap_peruser :1, + cap_permesg :1, + cap_kgstatus :1, + __reserved2 :2); + uint8_t cap_ext; + uint8_t cap_oemid[3]; + uint8_t cap_oemaux; +} ipmi_channel_auth_caps_t; + +#define IPMI_CMD_GET_CHANNEL_AUTH_CAPS 0x38 +extern ipmi_channel_auth_caps_t *ipmi_get_channel_auth_caps(ipmi_handle_t *, + uint8_t, uint8_t); + +/* + * Get Channel Info. See section 22.24. + */ +typedef struct ipmi_channel_info { + DECL_BITFIELD2( + ici_number :4, + __reserved1 :4); + DECL_BITFIELD2( + ici_medium :7, + __reserved2 :1); + DECL_BITFIELD2( + ici_protocol :5, + __reserved3 :3); + DECL_BITFIELD3( + ici_session_count :6, + ici_single_session :1, + ici_multi_Session :1); + uint8_t ici_vendor[3]; + uint8_t ici_auxinfo[2]; +} ipmi_channel_info_t; + +#define IPMI_CMD_GET_CHANNEL_INFO 0x42 + +/* + * Channel Numbers. See section 6.3. + */ +#define IPMI_CHANNEL_PRIMARY 0x0 +#define IPMI_CHANNEL_MIN 0x1 +#define IPMI_CHANNEL_MAX 0xB +#define IPMI_CHANNEL_CURRENT 0xE +#define IPMI_CHANNEL_SYSTEM 0xF + +extern ipmi_channel_info_t *ipmi_get_channel_info(ipmi_handle_t *, int); + +/* + * Channel Protocol Types. See section 6.4. + */ +#define IPMI_PROTOCOL_IPMB 0x1 +#define IPMI_PROTOCOL_ICMB 0x2 +#define IPMI_PROTOCOL_SMBUS 0x4 +#define IPMI_PROTOCOL_KCS 0x5 +#define IPMI_PROTOCOL_SMIC 0x6 +#define IPMI_PROTOCOL_BT10 0x7 +#define IPMI_PROTOCOL_BT15 0x8 +#define IPMI_PROTOCOL_TMODE 0x9 +#define IPMI_PROTOCOL_OEM1 0xC +#define IPMI_PROTOCOL_OEM2 0xD +#define IPMI_PROTOCOL_OEM3 0xE +#define IPMI_PROTOCOL_OEM4 0xF + +/* + * Channel Medium Types. See section 6.5. + */ +#define IPMI_MEDIUM_IPMB 0x1 +#define IPMI_MEDIUM_ICMB10 0x2 +#define IPMI_MEDIUM_ICMB09 0x3 +#define IPMI_MEDIUM_8023LAN 0x4 +#define IPMI_MEDIUM_RS232 0x5 +#define IPMI_MEDIUM_OTHERLAN 0x6 +#define IPMI_MEDIUM_PCISMBUS 0x7 +#define IPMI_MEDIUM_SMBUS10 0x8 +#define IPMI_MEDIUM_SMBUS20 0x9 +#define IPMI_MEDIUM_USB1 0xA +#define IPMI_MEDIUM_USB2 0xB +#define IPMI_MEDIUM_SYSTEM 0xC + +/* + * LAN Configuration. See section 23. While the underlying mechanism is + * implemented via a sequence of get/set parameter commands, we assume that + * consumers prefer to get and set information in chunks, and therefore expose + * the configuration as a structure, with some of the less useful fields + * removed. When making changes, the consumer specifies which fields to apply + * along with the structure the library takes care of the rest of the work. + * + * This can be expanded in the future as needed. + */ + +typedef struct ipmi_lan_config { + boolean_t ilc_set_in_progress; + uint32_t ilc_ipaddr; + uint8_t ilc_ipaddr_source; + uint8_t ilc_macaddr[6]; + uint32_t ilc_subnet; + uint32_t ilc_gateway_addr; +} ipmi_lan_config_t; + +#define IPMI_LAN_SRC_UNSPECIFIED 0x0 +#define IPMI_LAN_SRC_STATIC 0x1 +#define IPMI_LAN_SRC_DHCP 0x2 +#define IPMI_LAN_SRC_BIOS 0x3 +#define IPMI_LAN_SRC_OTHER 0x4 + +#define IPMI_LAN_SET_IPADDR 0x01 +#define IPMI_LAN_SET_IPADDR_SOURCE 0x02 +#define IPMI_LAN_SET_MACADDR 0x04 +#define IPMI_LAN_SET_SUBNET 0x08 +#define IPMI_LAN_SET_GATEWAY_ADDR 0x10 + +#define IPMI_CMD_SET_LAN_CONFIG 0x01 +#define IPMI_CMD_GET_LAN_CONFIG 0x02 + +extern int ipmi_lan_get_config(ipmi_handle_t *, int, + ipmi_lan_config_t *); +extern int ipmi_lan_set_config(ipmi_handle_t *, int, ipmi_lan_config_t *, int); + +/* + * SEL (System Event Log) commands. Currently the library only provides + * commands for reading the SEL. + */ + +/* + * 31.2 Get SEL Info Command + */ +#define IPMI_CMD_GET_SEL_INFO 0x40 + +typedef struct ipmi_sel_info { + uint8_t isel_version; + uint16_t isel_entries; + uint16_t isel_free; + uint32_t isel_add_ts; + uint32_t isel_erase_ts; + DECL_BITFIELD6( + isel_supp_allocation :1, + isel_supp_reserve :1, + isel_supp_partial :1, + isel_supp_delete :1, + __reserved :3, + isel_overflow :1); +} ipmi_sel_info_t; + +extern ipmi_sel_info_t *ipmi_sel_get_info(ipmi_handle_t *); +extern boolean_t ipmi_sdr_changed(ipmi_handle_t *); +extern int ipmi_sdr_refresh(ipmi_handle_t *); + +/* + * 32.1 SEL Event Records + */ +typedef struct ipmi_sel_event { + uint16_t isel_ev_next; + uint16_t isel_ev_recid; + uint8_t isel_ev_rectype; + uint32_t isel_ev_ts; + DECL_BITFIELD2( + isel_ev_software :1, + isel_ev_addr_or_id :7); + DECL_BITFIELD3( + isel_ev_lun :2, + __reserved :2, + isel_ev_channel :4); + uint8_t isel_ev_rev; + uint8_t isel_ev_sensor_type; + uint8_t isel_ev_sensor_number; + DECL_BITFIELD2( + isel_ev_type :7, + isel_ev_dir :1); + uint8_t isel_ev_data[3]; +} ipmi_sel_event_t; + +#define IPMI_EV_REV15 0x04 +#define IPMI_EV_REV1 0x03 + +#define IPMI_SEL_SYSTEM 0x02 +#define IPMI_SEL_OEMTS_LO 0xC0 +#define IPMI_SEL_OEMTS_HI 0xDF +#define IPMI_SEL_OEM_LO 0xE0 +#define IPMI_SEL_OEM_HI 0xFF + +#define IPMI_EV_ASSERT 0x0 +#define IPMI_EV_DEASSERT 0x1 + +/* + * 32.2 OEM SEL Record (with timestamp) + */ +typedef struct ipmi_sel_oem_ts { + uint16_t isel_oem_next; + uint16_t isel_oem_id; + uint8_t isel_oem_type; + uint32_t isel_oem_ts; + uint8_t isel_oem_devid[3]; + uint8_t isel_oem_data[6]; +} ipmi_sel_oem_ts_t; + +/* + * 32.3 OEM SEL Record (no timestamp) + */ +typedef struct ipmi_sel_oem { + uint16_t isel_oem_next; + uint16_t isel_oem_id; + uint8_t isel_oem_type; + uint8_t isel_oem_data[13]; +} ipmi_sel_oem_t; + +/* + * 29.3 Platform Event Message Command. + */ +typedef struct ipmi_platform_event_message { + uint8_t ipem_generator; + uint8_t ipem_rev; + uint8_t ipem_sensor_type; + uint8_t ipem_sensor_num; + DECL_BITFIELD2( + ipem_event_type :7, + ipem_event_dir :1); + uint8_t ipem_event_data[3]; +} ipmi_platform_event_message_t; + +#define IPMI_CMD_PLATFORM_EVENT_MESSAGE 0x02 + +extern int ipmi_event_platform_message(ipmi_handle_t *, + ipmi_platform_event_message_t *); + +/* + * 29.7 Event Data Field Formats. Consumers can cast the data field of the + * event record to the appropriate type depending on the sensor class. + */ + +typedef struct ipmi_event_threshold { + DECL_BITFIELD3( + iev_offset :4, + iev_desc_byte3 :2, + iev_desc_byte2 :2); + uint8_t iev_reading; + uint8_t iev_threshold; +} ipmi_event_threshold_t; + +#define IPMI_EV_DESC_UNSPECIFIED 0x00 +#define IPMI_EV_DESC_TRIGGER 0x01 +#define IPMI_EV_DESC_OEM 0x02 +#define IPMI_EV_DESC_SPECIFIC 0x03 + +typedef struct ipmi_event_discrete { + DECL_BITFIELD3( + iev_offset :4, + iev_desc_byte3 :2, + iev_desc_byte2 :2); + DECL_BITFIELD2( + iev_offset_type :4, + iev_offset_severity :4); + uint8_t iev_oem_code; +} ipmi_event_discrete_t; + +#define IPMI_EV_DESC_PREVSTATE 0x01 +#define IPMI_EV_DESC_SPECIFIC 0x03 + +typedef struct ipmi_event_oem { + DECL_BITFIELD3( + iev_offset :4, + iev_desc_byte3 :2, + iev_desc_byte2 :2); + DECL_BITFIELD2( + iev_offset_type :4, + iev_offset_severity :4); + uint8_t iev_oem_code; +} ipmi_event_oem_t; + +/* + * Get SEL Entry Command. See section 31.5. We don't support partial reads, so + * this interface is quite a bit simpler than in the spec. We default to + * returning event records, though the consumer should check the type field and + * cast it to the appropriate type if it is no IPMI_SEL_SYSTEM. + */ +#define IPMI_CMD_GET_SEL_ENTRY 0x43 + +extern ipmi_sel_event_t *ipmi_sel_get_entry(ipmi_handle_t *, uint16_t); + +#define IPMI_SEL_FIRST_ENTRY 0x0000 +#define IPMI_SEL_LAST_ENTRY 0xFFFF + +/* + * SEL time management. See sections 31.10 and 31.11. + */ +#define IPMI_CMD_GET_SEL_TIME 0x48 +#define IPMI_CMD_SET_SEL_TIME 0x49 +#define IPMI_CMD_GET_SEL_UTC_OFFSET 0x5C +#define IPMI_CMD_SET_SEL_UTC_OFFSET 0x5D + +extern int ipmi_sel_get_time(ipmi_handle_t *, uint32_t *); +extern int ipmi_sel_set_time(ipmi_handle_t *, uint32_t); +extern int ipmi_sel_get_utc_offset(ipmi_handle_t *, int *); +extern int ipmi_sel_set_utc_offset(ipmi_handle_t *, int); + +/* + * SDR (Sensor Device Record) requests. A cache of the current SDR repository + * is kept as part of the IPMI handle and updated when necessary. This does the + * work of processing the SDR names and providing an easy way to lookup + * individual records and iterate over all records. + */ + +/* + * Get SDR Repository Info Command. See section 33.9. + */ +#define IPMI_CMD_GET_SDR_INFO 0x20 + +typedef struct ipmi_sdr_info { + uint8_t isi_version; + uint16_t isi_record_count; + uint16_t isi_free_space; + uint32_t isi_add_ts; + uint32_t isi_erase_ts; + DECL_BITFIELD7( + isi_supp_allocation :1, + isi_supp_reserve :1, + isi_supp_partial :1, + isi_supp_delete :1, + __reserved :1, + isi_modal :2, + isi_overflow :1); +} ipmi_sdr_info_t; + +extern ipmi_sdr_info_t *ipmi_sdr_get_info(ipmi_handle_t *); + +/* + * Reserve repository command. See section 33.11. + */ +#define IPMI_CMD_RESERVE_SDR_REPOSITORY 0x22 + +/* + * Get SDR command. See section 33.12. This command accesses the raw SDR + * repository. Clients can also use the lookup functions to retrieve a + * particular SDR record by name. + * + * The list of possible types is indicated in the sub-chapters of section 43. + */ +typedef struct ipmi_sdr { + uint16_t is_id; + uint8_t is_version; + uint8_t is_type; + uint8_t is_length; + uint8_t is_record[1]; +} ipmi_sdr_t; +#define IPMI_CMD_GET_SDR 0x23 + +#define IPMI_SDR_FIRST 0x0000 +#define IPMI_SDR_LAST 0xFFFF + +extern ipmi_sdr_t *ipmi_sdr_get(ipmi_handle_t *, uint16_t, uint16_t *); + +/* + * Full Sensor Record. See 43.1 + */ +#define IPMI_SDR_TYPE_FULL_SENSOR 0x01 + +typedef struct ipmi_sdr_full_sensor { + /* RECORD KEY BYTES */ + uint8_t is_fs_owner; + DECL_BITFIELD3( + is_fs_sensor_lun :2, + __reserved1 :2, + is_fs_channel :4); + uint8_t is_fs_number; + /* RECORD BODY BYTES */ + uint8_t is_fs_entity_id; + DECL_BITFIELD2( + is_fs_entity_instance :7, + is_fs_entity_logical :1); + DECL_BITFIELD8( + is_fs_sensor_scanning_enabled :1, + is_fs_event_generation_enabled :1, + is_fs_init_sensor_type :1, + is_fs_init_hysteresis :1, + is_fs_init_thresholds :1, + is_fs_init_events :1, + is_fs_init_scanning :1, + is_fs_settable :1); + DECL_BITFIELD5( + is_fs_event_support :2, + is_fs_threshold_support :2, + is_fs_hysteresis_support :2, + is_fs_rearm_support :1, + is_fs_ignore :1); + uint8_t is_fs_type; + uint8_t is_fs_reading_type; + uint16_t is_fs_assert_mask; + uint16_t is_fs_deassert_mask; + uint16_t is_fs_reading_mask; + DECL_BITFIELD4( + is_fs_units_isprcnt :1, + is_fs_mod_unit :2, + is_fs_rate_unit :3, + is_fs_analog_fmt :2); + uint8_t is_fs_unit2; + uint8_t is_fs_unit3; + /* Linearization */ + DECL_BITFIELD2( + is_fs_sensor_linear_type :7, + __reserved2 :1); + /* M, Tolerance */ + uint16_t is_fs_mtol; + /* B, Accuracy, R exp, B exp */ + uint32_t is_fs_bacc; + DECL_BITFIELD4( + is_fs_nominal_reading_spec :1, + is_fs_normal_max_spec :1, + is_fs_normal_min_spec :1, + __reserved3 :5); + uint8_t is_fs_nominal_reading; + uint8_t is_fs_normal_maximum; + uint8_t is_fs_normal_minimum; + uint8_t is_fs_max; + uint8_t is_fs_min; + uint8_t is_fs_upper_nonrecov; + uint8_t is_fs_upper_critical; + uint8_t is_fs_upper_noncrit; + uint8_t is_fs_lower_nonrecov; + uint8_t is_fs_lower_critical; + uint8_t is_fs_lower_noncrit; + uint8_t is_fs_hysteresis_positive; + uint8_t is_fs_hysteresis_negative; + uint16_t __reserved4; + uint8_t is_fs_oem; + DECL_BITFIELD3( + is_fs_idlen :5, + __reserved5 :1, + is_fs_idtype :2); + char is_fs_idstring[1]; +} ipmi_sdr_full_sensor_t; + +#define IPMI_SDR_TYPE_COMPACT_SENSOR 0x02 + +/* + * Compact Sensor Record. See section 43.2 + */ +typedef struct ipmi_sdr_compact_sensor { + /* RECORD KEY BYTES */ + uint8_t is_cs_owner; + DECL_BITFIELD3( + is_cs_sensor_lun :2, + is_cs_fru_lun :2, + is_cs_channel :4); + uint8_t is_cs_number; + /* RECORD BODY BYTES */ + uint8_t is_cs_entity_id; + DECL_BITFIELD2( + is_cs_entity_instance :7, + is_cs_entity_logical :1); + DECL_BITFIELD8( + is_cs_sensor_scanning_enabled :1, + is_cs_event_generation_enabled :1, + is_cs_init_sensor_type :1, + is_cs_init_hysteresis :1, + __reserved1 :1, + is_cs_init_events :1, + is_cs_init_scanning :1, + is_cs_settable :1); + DECL_BITFIELD5( + is_cs_event_support :2, + is_cs_threshold_support :2, + is_cs_hysteresis_support :2, + is_cs_rearm_support :1, + is_cs_ignore :1); + uint8_t is_cs_type; + uint8_t is_cs_reading_type; + uint16_t is_cs_assert_mask; + uint16_t is_cs_deassert_mask; + uint16_t is_cs_reading_mask; + DECL_BITFIELD4( + is_cs_units_isprcnt :1, + is_cs_mod_unit :2, + is_cs_rate_unit :3, + __reserved2 :2); + uint8_t is_cs_unit2; + uint8_t is_cs_unit3; + DECL_BITFIELD3( + is_cs_share_count :4, + is_cs_modifier_type :2, + is_cs_direction :2); + DECL_BITFIELD2( + is_cs_modifier_offset :7, + is_cs_sharing :1); + uint8_t is_cs_hysteresis_positive; + uint8_t is_cs_hysteresis_negative; + uint16_t __reserved3; + uint8_t __reserved4; + uint8_t is_cs_oem; + DECL_BITFIELD3( + is_cs_idlen :5, + __reserved5 :1, + is_cs_idtype :2); + char is_cs_idstring[1]; +} ipmi_sdr_compact_sensor_t; + +/* + * Threshold sensor masks for is_cs_assert_mask and is_cs_deassert_mask. + */ +#define IPMI_SENSOR_RETURN_NONRECOV 0x4000 +#define IPMI_SENSOR_RETURN_CRIT 0x2000 +#define IPMI_SENSOR_RETURN_NONCRIT 0x1000 + +#define IPMI_SENSOR_MASK_UPPER_NONRECOV_HI 0x0800 +#define IPMI_SENSOR_MASK_UPPER_NONRECOV_LO 0x0400 +#define IPMI_SENSOR_MASK_UPPER_CRIT_HI 0x0200 +#define IPMI_SENSOR_MASK_UPPER_CRIT_LO 0x0100 +#define IPMI_SENSOR_MASK_UPPER_NONCRIT_HI 0x0080 +#define IPMI_SENSOR_MASK_UPPER_NONCRIT_LO 0x0040 +#define IPMI_SENSOR_MASK_LOWER_NONRECOV_HI 0x0020 +#define IPMI_SENSOR_MASK_LOWER_NONRECOV_LO 0x0010 +#define IPMI_SENSOR_MASK_LOWER_CRIT_HI 0x0008 +#define IPMI_SENSOR_MASK_LOWER_CRIT_LO 0x0004 +#define IPMI_SENSOR_MASK_LOWER_NONCRIT_HI 0x0002 +#define IPMI_SENSOR_MASK_LOWER_NONCRIT_LO 0x0001 + +/* + * Threshold sensor masks for is_cs_reading_mask. + */ +#define IPMI_SENSOR_SETTABLE_UPPER_NONRECOV 0x2000 +#define IPMI_SENSOR_SETTABLE_UPPER_CRIT 0x1000 +#define IPMI_SENSOR_SETTABLE_UPPER_NONCRIT 0x0800 +#define IPMI_SENSOR_SETTABLE_LOWER_NONRECOV 0x0400 +#define IPMI_SENSOR_SETTABLE_LOWER_CRIT 0x0200 +#define IPMI_SENSOR_SETTABLE_LOWER_NONCRIT 0x0100 +#define IPMI_SENSOR_READABLE_UPPER_NONRECOV 0x0020 +#define IPMI_SENSOR_READABLE_UPPER_CRIT 0x0010 +#define IPMI_SENSOR_READABLE_UPPER_NONCRIT 0x0008 +#define IPMI_SENSOR_READABLE_LOWER_NONRECOV 0x0004 +#define IPMI_SENSOR_READABLE_LOWER_CRIT 0x0002 +#define IPMI_SENSOR_READABLE_LOWER_NONCRIT 0x0001 + +/* + * Values for is_cs_reading_type. See table 42-2. + */ +#define IPMI_RT_THRESHOLD 0x01 +#define IPMI_RT_USAGE 0x02 +#define IPMI_RT_STATE 0x03 +#define IPMI_RT_PREDFAIL 0x04 +#define IPMI_RT_LIMIT 0x05 +#define IPMI_RT_PERFORMANCE 0x06 +#define IPMI_RT_SEVERITY 0x07 +#define IPMI_RT_PRESENT 0x08 +#define IPMI_RT_ENABLED 0x09 +#define IPMI_RT_AVAILABILITY 0x0A +#define IPMI_RT_REDUNDANCY 0x0B +#define IPMI_RT_ACPI 0x0C +#define IPMI_RT_SPECIFIC 0x6F + +/* + * Bitmasks based on above reading types. See table 42-2 + */ +#define IPMI_SR_THRESHOLD_LOWER_NONCRIT_LOW 0x0001 +#define IPMI_SR_THRESHOLD_LOWER_NONCRIT_HIGH 0x0002 +#define IPMI_SR_THRESHOLD_LOWER_CRIT_LOW 0x0004 +#define IPMI_SR_THRESHOLD_LOWER_CRIT_HIGH 0x0008 +#define IPMI_SR_THRESHOLD_LOWER_NONRECOV_LOW 0x0010 +#define IPMI_SR_THRESHOLD_LOWER_NONRECOV_HIGH 0x0020 +#define IPMI_SR_THRESHOLD_UPPER_NONCRIT_LOW 0x0040 +#define IPMI_SR_THRESHOLD_UPPER_NONCRIT_HIGH 0x0080 +#define IPMI_SR_THRESHOLD_UPPER_CRIT_LOW 0x0100 +#define IPMI_SR_THRESHOLD_UPPER_CRIT_HIGH 0x0200 +#define IPMI_SR_THRESHOLD_UPPER_NONRECOV_LOW 0x0400 +#define IPMI_SR_THRESHOLD_UPPER_NONRECOV_HIGH 0x0800 + +#define IPMI_SR_USAGE_IDLE 0x0001 +#define IPMI_SR_USAGE_ACTIVE 0x0002 +#define IPMI_SR_USAGE_BUSY 0x0004 + +#define IPMI_SR_STATE_DEASSERT 0x0001 +#define IPMI_SR_STATE_ASSERT 0x0002 + +#define IPMI_SR_PREDFAIL_DEASSERT 0x0001 +#define IPMI_SR_PREDFAIL_ASSERT 0x0002 + +#define IPMI_SR_LIMIT_NOTEXCEEDED 0x0001 +#define IPMI_SR_LIMIT_EXCEEDED 0x0002 + +#define IPMI_SR_PERFORMANCE_MET 0x0001 +#define IPMI_SR_PERFORMANCE_LAGS 0x0002 + +#define IPMI_SR_SEVERITY_TO_OK 0x0001 +#define IPMI_SR_SEVERITY_OK_TO_NONCRIT 0x0002 +#define IPMI_SR_SEVERITY_LESS_TO_CRIT 0x0004 +#define IPMI_SR_SEVERITY_LESS_TO_NONRECOV 0x0008 +#define IPMI_SR_SEVERITY_MORE_TO_NONCRIT 0x0010 +#define IPMI_SR_SEVERITY_NONRECOV_TO_CRIT 0x0020 +#define IPMI_SR_SEVERITY_TO_NONRECOV 0x0040 +#define IPMI_SR_SEVERITY_MONITOR 0x0080 +#define IPMI_SR_SEVERITY_INFO 0x0100 + +#define IPMI_SR_PRESENT_DEASSERT 0x0001 +#define IPMI_SR_PRESENT_ASSERT 0x0002 + +#define IPMI_SR_ENABLED_DEASSERT 0x0001 +#define IPMI_SR_ENABLED_ASSERT 0x0002 + +#define IPMI_SR_AVAILABILITY_RUNNING 0x0001 +#define IPMI_SR_AVAILABILITY_INTEST 0x0002 +#define IPMI_SR_AVAILABILITY_POWEROFF 0x0004 +#define IPMI_SR_AVAILABILITY_ONLINE 0x0008 +#define IPMI_SR_AVAILABILITY_OFFLINE 0x0010 +#define IPMI_SR_AVAILABILITY_OFFDUTY 0x0020 +#define IPMI_SR_AVAILABILITY_DEGRADED 0x0040 +#define IPMI_SR_AVAILABILITY_POWERSAVE 0x0080 +#define IPMI_SR_AVAILABILITY_INSTALLERR 0x0100 + +#define IPMI_SR_REDUNDANCY_FULL 0x0001 +#define IPMI_SR_REDUNDANCY_LOST 0x0002 +#define IPMI_SR_REDUNDANCY_DEGRADED 0x0004 +#define IPMI_SR_REDUNDANCY_NONE_MINIMAL 0x0008 +#define IPMI_SR_REDUNDANCY_NONE_REGAINED 0x0010 +#define IPMI_SR_REDUNDANCY_NONE_INSUFFFICIENT 0x0020 +#define IPMI_SR_REDUNDANCY_DEG_FROM_FULL 0x0040 +#define IPMI_SR_REDUNDANCY_DEG_FROM_NON 0x0080 + +#define IPMI_SR_ACPI_DO 0x0001 +#define IPMI_SR_ACPI_D1 0x0002 +#define IPMI_SR_ACPI_D2 0x0004 +#define IPMI_SR_ACPI_D3 0x0008 + +/* + * Bitmasks for sensor-specific reading type (0x6F). See section 42.2. + */ +#define IPMI_ST_RESERVED 0x00 +#define IPMI_ST_TEMP 0x01 +#define IPMI_ST_VOLTAGE 0x02 +#define IPMI_ST_CURRENT 0x03 +#define IPMI_ST_FAN 0x04 +#define IPMI_ST_PHYSICAL 0x05 + +#define IPMI_EV_PHYSICAL_GENERAL 0x0001 +#define IPMI_EV_PHYSICAL_BAY 0x0002 +#define IPMI_EV_PHYSICAL_CARD 0x0004 +#define IPMI_EV_PHYSICAL_PROCESSOR 0x0008 +#define IPMI_EV_PHYSICAL_LAN 0x0010 +#define IPMI_EV_PHYSICAL_DOCK 0x0020 +#define IPMI_EV_PHYSICAL_FAN 0x0040 + +#define IPMI_ST_PLATFORM 0x06 + +#define IPMI_EV_PLATFORM_SECURE 0x0001 +#define IPMI_EV_PLATFORM_USER_PASS 0x0002 +#define IPMI_EV_PLATFORM_SETUP_PASS 0x0004 +#define IPMI_EV_PLATFORM_NETWORK_PASS 0x0008 +#define IPMI_EV_PLATFORM_OTHER_PASS 0x0010 +#define IPMI_EV_PLATFORM_OUT_OF_BAND 0x0020 + +#define IPMI_ST_PROCESSOR 0x07 + +#define IPMI_EV_PROCESSOR_IERR 0x0001 +#define IPMI_EV_PROCESSOR_THERMAL 0x0002 +#define IPMI_EV_PROCESSOR_FRB1 0x0004 +#define IPMI_EV_PROCESSOR_FRB2 0x0008 +#define IPMI_EV_PROCESSOR_FRB3 0x0010 +#define IPMI_EV_PROCESSOR_CONFIG 0x0020 +#define IPMI_EV_PROCESSOR_SMBIOS 0x0040 +#define IPMI_EV_PROCESSOR_PRESENT 0x0080 +#define IPMI_EV_PROCESSOR_DISABLED 0x0100 +#define IPMI_EV_PROCESSOR_TERMINATOR 0x0200 +#define IPMI_EV_PROCESSOR_THROTTLED 0x0400 + +#define IPMI_ST_POWER_SUPPLY 0x08 + +#define IPMI_EV_POWER_SUPPLY_PRESENT 0x0001 +#define IPMI_EV_POWER_SUPPLY_FAILURE 0x0002 +#define IPMI_EV_POWER_SUPPLY_PREDFAIL 0x0004 +#define IPMI_EV_POWER_SUPPLY_INPUT_LOST 0x0008 +#define IPMI_EV_POWER_SUPPLY_INPUT_RANGE 0x0010 +#define IPMI_EV_POWER_SUPPLY_INPUT_RANGE_PRES 0x0020 +#define IPMI_EV_POWER_SUPPLY_CONFIG_ERR 0x0040 + +#define IPMI_ST_POWER_UNIT 0x09 + +#define IPMI_EV_POWER_UNIT_OFF 0x0001 +#define IPMI_EV_POWER_UNIT_CYCLE 0x0002 +#define IPMI_EV_POWER_UNIT_240_DOWN 0x0004 +#define IPMI_EV_POWER_UNIT_INTERLOCK_DOWN 0x0008 +#define IPMI_EV_POWER_UNIT_AC_LOST 0x0010 +#define IPMI_EV_POWER_UNIT_SOFT_FAILURE 0x0020 +#define IPMI_EV_POWER_UNIT_FAIL 0x0040 +#define IPMI_EV_POWER_UNIT_PREDFAIL 0x0080 + +#define IPMI_ST_COOLING 0x0A +#define IPMI_ST_OTHER 0x0B +#define IPMI_ST_MEMORY 0x0C + +#define IPMI_EV_MEMORY_CE 0x0001 +#define IPMI_EV_MEMORY_UE 0x0002 +#define IPMI_EV_MEMORY_PARITY 0x0004 +#define IPMI_EV_MEMORY_SCRUB_FAIL 0x0008 +#define IPMI_EV_MEMORY_DISABLED 0x0010 +#define IPMI_EV_MEMORY_CE_LOG_LIMIT 0x0020 +#define IPMI_EV_MEMORY_PRESENT 0x0040 +#define IPMI_EV_MEMORY_CONFIG_ERR 0x0080 +#define IPMI_EV_MEMORY_SPARE 0x0100 +#define IPMI_EV_MEMORY_THROTTLED 0x0200 +#define IPMI_EV_MEMORY_OVERTEMP 0x0400 + +#define IPMI_ST_BAY 0x0D + +#define IPMI_EV_BAY_PRESENT 0x0001 +#define IPMI_EV_BAY_FAULT 0x0002 +#define IPMI_EV_BAY_PREDFAIL 0x0004 +#define IPMI_EV_BAY_SPARE 0x0008 +#define IPMI_EV_BAY_CHECK 0x0010 +#define IPMI_EV_BAY_CRITICAL 0x0020 +#define IPMI_EV_BAY_FAILED 0x0040 +#define IPMI_EV_BAY_REBUILDING 0x0080 +#define IPMI_EV_BAY_ABORTED 0x0100 + +#define IPMI_ST_POST_RESIZE 0x0E +#define IPMI_ST_FIRMWARE 0x0F + +#define IPMI_EV_FIRMWARE_ERROR 0x0001 +#define IPMI_EV_FIRMWARE_HANG 0x0002 +#define IPMI_EV_FIRMWARE_PROGRESS 0x0004 + +#define IPMI_ST_EVENT_LOG 0x10 + +#define IPMI_EV_EVENT_LOG_CE 0x0001 +#define IPMI_EV_EVENT_LOG_TYPE 0x0002 +#define IPMI_EV_EVENT_LOG_RESET 0x0004 +#define IPMI_EV_EVENT_LOG_ALL 0x0008 +#define IPMI_EV_EVENT_LOG_FULL 0x0010 +#define IPMI_EV_EVENT_LOG_ALMOST_FULL 0x0020 + +#define IPMI_ST_WATCHDOG1 0x11 + +#define IPMI_EV_WATCHDOG_BIOS_RESET 0x0001 +#define IPMI_EV_WATCHDOG_OS_RESET 0x0002 +#define IPMI_EV_WATCHDOG_OS_SHUTDOWN 0x0004 +#define IPMI_EV_WATCHDOG_OS_PWR_DOWN 0x0008 +#define IPMI_EV_WATCHDOG_OS_PWR_CYCLE 0x0010 +#define IPMI_EV_WATCHDOG_OS_NMI_DIAG 0x0020 +#define IPMI_EV_WATCHDOG_EXPIRED 0x0040 +#define IPMI_EV_WATCHDOG_PRE_TIMEOUT_INT 0x0080 + +#define IPMI_ST_SYSTEM 0x12 + +#define IPMI_EV_STSTEM_RECONF 0x0001 +#define IPMI_EV_STSTEM_BOOT 0x0002 +#define IPMI_EV_STSTEM_UNKNOWN_HW_FAILURE 0x0004 +#define IPMI_EV_STSTEM_AUX_LOG_UPDATED 0x0008 +#define IPMI_EV_STSTEM_PEF_ACTION 0x0010 +#define IPMI_EV_SYSTEM_TIMETAMP_CLOCKSYNC 0x0020 + +#define IPMI_ST_CRITICAL 0x13 + +#define IPMI_EV_CRITICAL_EXT_NMI 0x0001 +#define IPMI_EV_CRITICAL_BUS_TIMOEOUT 0x0002 +#define IPMI_EV_CRITICAL_IO_NMI 0x0004 +#define IPMI_EV_CRITICAL_SW_NMI 0x0008 +#define IPMI_EV_CRITICAL_PCI_PERR 0x0010 +#define IPMI_EV_CRITICAL_PCI_SERR 0x0020 +#define IPMI_EV_CRITICAL_EISA_FAILSAFE 0x0040 +#define IPMI_EV_CRITICAL_BUS_CE 0x0080 +#define IPMI_EV_CRITICAL_BUS_UE 0x0100 +#define IPMI_EV_CRITICAL_FATAL_NMI 0x0200 +#define IPMI_EV_CRITICAL_BUS_FATAL_ERR 0x0400 +#define IPMI_EV_CRITICAL_BUS_DEGRADED 0x0800 + +#define IPMI_ST_BUTTON 0x14 + +#define IPMI_EV_BUTTON_PWR 0x0001 +#define IPMI_EV_BUTTON_SLEEP 0x0002 +#define IPMI_EV_BUTTON_RESET 0x0004 +#define IPMI_EV_BUTTON_FRU_LATCH 0x0008 +#define IPMI_EV_BUTTON_FRU_SERVICE 0x0010 + +#define IPMI_ST_MODULE 0x15 +#define IPMI_ST_MICROCONTROLLER 0x16 +#define IPMI_ST_CARD 0x17 +#define IPMI_ST_CHASSIS 0x18 + +#define IPMI_ST_CHIPSET 0x19 + +#define IPMI_EV_CHIPSET_PWR_CTL_FAIL 0x0001 + +#define IPMI_ST_FRU 0x1A +#define IPMI_ST_CABLE 0x1B + +#define IPMI_EV_CABLE_CONNECTED 0x0001 +#define IPMI_EV_CABLE_CONFIG_ERR 0x0002 + +#define IPMI_ST_TERMINATOR 0x1C + +#define IPMI_ST_BOOT 0x1D + +#define IPMI_EV_BOOT_BIOS_PWR_UP 0x0001 +#define IPMI_EV_BOOT_BIOS_HARD_RESET 0x0002 +#define IPMI_EV_BOOT_BIOS_WARM_RESET 0x0004 +#define IPMI_EV_BOOT_PXE_BOOT 0x0008 +#define IPMI_EV_BOOT_DIAG_BOOT 0x0010 +#define IPMI_EV_BOOT_OS_HARD_RESET 0x0020 +#define IPMI_EV_BOOT_OS_WARM_RESET 0x0040 +#define IPMI_EV_BOOT_SYS_RESTART 0x0080 + +#define IPMI_ST_BOOT_ERROR 0x1E + +#define IPMI_EV_BOOT_ERROR_NOMEDIA 0x0001 +#define IPMI_EV_BOOT_ERROR_NON_BOOTABLE_DISK 0x0002 +#define IPMI_EV_BOOT_ERROR_NO_PXE_SERVER 0x0004 +#define IPMI_EV_BOOT_ERROR_INV_BOOT_SECT 0x0008 +#define IPMI_EV_BOOT_ERROR_USR_SELECT_TIMEOUT 0x0010 + +#define IPMI_ST_BOOT_OS 0x1F + +#define IPMI_EV_BOOT_OS_A_DRV_BOOT_COMPLETE 0x0001 +#define IPMI_EV_BOOT_OS_C_DRV_BOOT_COMPLETE 0x0002 +#define IPMI_EV_BOOT_OS_PXE_BOOT_COMPLETE 0x0004 +#define IPMI_EV_BOOT_OS_DIAG_BOOT_COMPLETE 0x0008 +#define IPMI_EV_BOOT_OS_CDROM_BOOT_COMPLETE 0x0010 +#define IPMI_EV_BOOT_OS_ROM_BOOT_COMPLETE 0x0020 +#define IPMI_EV_BOOT_OS_UNSPEC_BOOT_COMPLETE 0x0040 + +#define IPMI_ST_OS_SHUTDOWN 0x20 + +#define IPMI_EV_OS_SHUTDOWN_LOADING 0x0001 +#define IPMI_EV_OS_SHUTDOWN_CRASH 0x0002 +#define IPMI_EV_OS_STOP_GRACEFUL 0x0004 +#define IPMI_EV_OS_SHUTDOWN_GRACEFUL 0x0008 +#define IPMI_EV_OS_SHUTDOWN_PEF 0x0010 +#define IPMI_EV_OS_SHUTDOWN_BMC 0x0020 + +#define IPMI_ST_SLOT 0x21 + +#define IPMI_EV_SLOT_FAULT_ASSERTED 0x0001 +#define IPMI_EV_SLOT_IDENTIFY_ASSERTED 0x0002 +#define IPMI_EV_SLOT_CONNECTED 0x0004 +#define IPMI_EV_SLOT_INSTALL_READY 0x0008 +#define IPMI_EV_SLOT_REMOVE_READY 0x0010 +#define IPMI_EV_SLOT_PWR_OFF 0x0020 +#define IPMI_EV_SLOT_REMOVED 0x0040 +#define IPMI_EV_SLOT_INTERLOCK_ASSERTED 0x0080 +#define IPMI_EV_SLOT_DISABLED 0x0100 +#define IPMI_EV_SLOT_SPARE_DEVICE 0x0200 + +#define IPMI_ST_ACPI 0x22 + +#define IPMI_EV_ACPI_PSTATE_S0_G0 0x0001 +#define IPMI_EV_ACPI_PSTATE_S1 0x0002 +#define IPMI_EV_ACPI_PSTATE_S2 0x0004 +#define IPMI_EV_ACPI_PSTATE_S3 0x0008 +#define IPMI_EV_ACPI_PSTATE_S4 0x0010 +#define IPMI_EV_ACPI_PSTATE_S5_G2_SOFT_OFF 0x0020 +#define IPMI_EV_ACPI_PSTATE_S4_S5_SOFT_OFF 0x0040 +#define IPMI_EV_ACPI_PSATTE_G3_MECH_OFF 0x0080 +#define IPMI_EV_ACPI_PSTATE_S1_S2_S3_SLEEP 0x0100 +#define IPMI_EV_ACPI_PSTATE_G1_SLEEP 0x0200 +#define IPMI_EV_ACPI_PSTATE_S5_OVERRIDE 0x0400 +#define IPMI_EV_ACPI_PSTATE_LEGACY_ON 0x0800 +#define IPMI_EV_ACPI_PSTATE_LEGACY_OFF 0x1000 +#define IPMI_EV_ACPI_PSTATE_UNKNOWN 0x2000 + +#define IPMI_ST_WATCHDOG2 0x23 + +#define IPMI_EV_WATCHDOG2_EXPIRED 0x0001 +#define IPMI_EV_WATCHDOG2_HARD_RESET 0x0002 +#define IPMI_EV_WATCHDOG2_PWR_DOWN 0x0004 +#define IPMI_EV_WATCHDOG2_PWR_CYCLE 0x0008 +#define IPMI_EV_WATCHDOG2_RESERVED1 0x0010 +#define IPMI_EV_WATCHDOG2_RESERVED2 0x0020 +#define IPMI_EV_WATCHDOG2_RESERVED3 0x0040 +#define IPMI_EV_WATCHDOG2_RESERVED4 0x0080 +#define IPMI_EV_WATCHDOG2_TIMEOUT_INT 0x0100 + +#define IPMI_ST_ALERT 0x24 + +#define IPMI_EV_ALERT_PLAT_PAGE 0x0001 +#define IPMI_EV_ALERT_PLAT_LAN_ALERT 0x0002 +#define IPMI_EV_ALERT_PLAT_EVT_TRAP 0x0004 +#define IPMI_EV_ALERT_PLAT_SNMP_TRAP 0x0008 + +#define IPMI_ST_PRESENCE 0x25 + +#define IPMI_EV_PRESENCE_PRESENT 0x0001 +#define IPMI_EV_PRESENCE_ABSENT 0x0002 +#define IPMI_EV_PRESENCE_DISABLED 0x0004 + +#define IPMI_ST_ASIC 0x26 + +#define IPMI_ST_LAN 0x27 + +#define IPMI_EV_LAN_HEARTBEAT_LOST 0x0001 +#define IPMI_EV_LAN_HEARTBEAT 0x0002 + +#define IPMI_ST_HEALTH 0x28 + +#define IPMI_EV_HEALTH_SENSOR_ACC_DEGRADED 0x0001 +#define IPMI_EV_HEALTH_CNTLR_ACC_DEGRADED 0x0002 +#define IPMI_EV_HEALTH_CNTLR_OFFLINE 0x0004 +#define IPMI_EV_HEALTH_CNTLR_UNAVAIL 0x0008 +#define IPMI_EV_HEALTH_SENSOR_FAILURE 0x0010 +#define IPMI_EV_HEALTH_FRU_FAILURE 0x0020 + +#define IPMI_ST_BATTERY 0x29 + +#define IPMI_EV_BATTERY_LOW 0x0001 +#define IPMI_EV_BATTERY_FAILED 0x0002 +#define IPMI_EV_BATTERY_PRESENCE 0x0004 + +#define IPMI_ST_AUDIT 0x2A + +#define IPMI_EV_AUDIT_SESSION_ACTIVATED 0x0001 +#define IPMI_EV_AUDIT_SESSION_DEACTIVATED 0x0002 + +#define IPMI_ST_VERSION 0x2B + +#define IPMI_EV_VERSION_HW_CHANGE 0x0001 +#define IPMI_EV_VERSION_SW_CHANGE 0x0002 +#define IPMI_EV_VERSION_HW_INCOMPATIBLE 0x0004 +#define IPMI_EV_VERSION_SW_INCOMPATIBLE 0x0008 +#define IPMI_EV_VERSION_HW_INVAL 0x0010 +#define IPMI_EV_VERSION_SW_INVAL 0x0020 +#define IPMI_EV_VERSION_HW_CHANGE_SUCCESS 0x0040 +#define IPMI_EV_VERSION_SW_CHANGE_SUCCESS 0x0080 + +#define IPMI_ST_FRU_STATE 0x2C + +#define IPMI_EV_FRU_STATE_NOT_INSTALLED 0x0001 +#define IPMI_EV_FRU_STATE_INACTIVE 0x0002 +#define IPMI_EV_FRU_STATE_ACT_REQ 0x0004 +#define IPMI_EV_FRU_STATE_ACT_INPROGRESS 0x0008 +#define IPMI_EV_FRU_STATE_ACTIVE 0x0010 +#define IPMI_EV_FRU_STATE_DEACT_REQ 0x0020 +#define IPMI_EV_FRU_STATE_DEACT_INPROGRESS 0x0040 +#define IPMI_EV_FRU_STATE_COMM_LOST 0x0080 + +/* + * Constants for unit type codes. See Table 43-15. + */ +#define IPMI_UNITS_UNSPECIFIED 0x00 +#define IPMI_UNITS_DEGREES_C 0x01 +#define IPMI_UNITS_DEGREES_F 0x02 +#define IPMI_UNITS_DEGREES_K 0x03 +#define IPMI_UNITS_VOLTS 0x04 +#define IPMI_UNITS_AMPS 0x05 +#define IPMI_UNITS_WATTS 0x06 +#define IPMI_UNITS_JOULES 0x07 +#define IPMI_UNITS_COULOMBS 0x08 +#define IPMI_UNITS_VA 0x09 +#define IPMI_UNITS_NITS 0x0A +#define IPMI_UNITS_LUMEN 0x0B +#define IPMI_UNITS_LUX 0x0C +#define IPMI_UNITS_CANDELA 0x0D +#define IPMI_UNITS_KPA 0x0E +#define IPMI_UNITS_PSI 0x0F + +#define IPMI_UNITS_NEWTON 0x10 +#define IPMI_UNITS_CFM 0x11 +#define IPMI_UNITS_RPM 0x12 +#define IPMI_UNITS_HZ 0x13 +#define IPMI_UNITS_MICROSEC 0x14 +#define IPMI_UNITS_MILLISEC 0x15 +#define IPMI_UNITS_SECS 0x16 +#define IPMI_UNITS_MIN 0x17 +#define IPMI_UNITS_HOUR 0x18 +#define IPMI_UNITS_DAY 0x19 +#define IPMI_UNITS_WEEK 0x1A +#define IPMI_UNITS_MIL 0x1B +#define IPMI_UNITS_INCHES 0x1C +#define IPMI_UNITS_FEET 0x1D +#define IPMI_UNITS_CUB_INCH 0x1E +#define IPMI_UNITS_CUB_FEET 0x1F + +#define IPMI_UNITS_MM 0x20 +#define IPMI_UNITS_CM 0x21 +#define IPMI_UNITS_METERS 0x22 +#define IPMI_UNITS_CUB_CM 0x23 +#define IPMI_UNITS_CUB_METER 0x24 +#define IPMI_UNITS_LITERS 0x25 +#define IPMI_UNITS_FLUID_OUNCE 0x26 +#define IPMI_UNITS_RADIANS 0x27 +#define IPMI_UNITS_STERADIANS 0x28 +#define IPMI_UNITS_REVOLUTIONS 0x29 +#define IPMI_UNITS_CYCLES 0x2A +#define IPMI_UNITS_GRAVITIES 0x2B +#define IPMI_UNITS_OUNCE 0x2C +#define IPMI_UNITS_POUND 0x2D +#define IPMI_UNITS_FOOT_POUND 0x2E +#define IPMI_UNITS_OZ_INCH 0x2F + +#define IPMI_UNITS_GAUSS 0x30 +#define IPMI_UNITS_GILBERTS 0x31 +#define IPMI_UNITS_HENRY 0x32 +#define IPMI_UNITS_MILHENRY 0x33 +#define IPMI_UNITS_FARAD 0x34 +#define IPMI_UNITS_MICROFARAD 0x35 +#define IPMI_UNITS_OHMS 0x36 +#define IPMI_UNITS_SIEMENS 0x37 +#define IPMI_UNITS_MOLE 0x38 +#define IPMI_UNITS_BECQUEREL 0x39 +#define IPMI_UNITS_PPM 0x3A +/* 0x3B is reserved */ +#define IPMI_UNITS_DECIBELS 0x3C +#define IPMI_UNITS_DBA 0x3D +#define IPMI_UNITS_DBC 0x3E +#define IPMI_UNITS_GRAY 0x3F + +#define IPMI_UNITS_SIEVERT 0x40 +#define IPMI_UNITS_COLOR_TEMP_K 0x41 +#define IPMI_UNITS_BIT 0x42 +#define IPMI_UNITS_KILOBIT 0x43 +#define IPMI_UNITS_MEGABIT 0x44 +#define IPMI_UNITS_GIGABIT 0x45 +#define IPMI_UNITS_BYTE 0x46 +#define IPMI_UNITS_KILOBYTE 0x47 +#define IPMI_UNITS_MEGABYTE 0x48 +#define IPMI_UNITS_GIGABYTE 0x49 +#define IPMI_UNITS_WORD 0x4A +#define IPMI_UNITS_DWORD 0x4B +#define IPMI_UNITS_QWORD 0x4C +#define IPMI_UNITS_MEMLINE 0x4D +#define IPMI_UNITS_HIT 0x4E +#define IPMI_UNITS_MISS 0x4F + +#define IPMI_UNITS_RETRY 0x50 +#define IPMI_UNITS_RESET 0x51 +#define IPMI_UNITS_OVERFLOW 0x52 +#define IPMI_UNITS_UNDERRUN 0x53 +#define IPMI_UNITS_COLLISION 0x54 +#define IPMI_UNITS_PACKETS 0x55 +#define IPMI_UNITS_MESSAGES 0x56 +#define IPMI_UNITS_CHARACTERS 0x57 +#define IPMI_UNITS_ERROR 0x58 +#define IPMI_UNITS_CE 0x59 +#define IPMI_UNITS_UE 0x5A +#define IPMI_UNITS_FATAL_ERROR 0x5B +#define IPMI_UNITS_GRAMS 0x5C + +/* + * Event-Only Record. See section 43.3. + */ + +#define IPMI_SDR_TYPE_EVENT_ONLY 0x03 + +typedef struct ipmi_sdr_event_only { + /* RECORD KEY BYTES */ + uint8_t is_eo_owner; + DECL_BITFIELD3( + is_eo_sensor_lun :2, + is_eo_fru_lun :2, + is_eo_channel :4); + uint8_t is_eo_number; + /* RECORD BODY BYTES */ + uint8_t is_eo_entity_id; + DECL_BITFIELD2( + is_eo_entity_instance :7, + is_eo_entity_logical :1); + uint8_t is_eo_sensor_type; + uint8_t is_eo_reading_type; + DECL_BITFIELD3( + is_eo_share_count :4, + is_eo_modifier_type :2, + is_eo_direction :2); + DECL_BITFIELD2( + is_eo_modifier_offset :7, + is_eo_sharing :1); + uint8_t __reserved; + uint8_t is_eo_oem; + DECL_BITFIELD3( + is_eo_idlen :5, + __reserved1 :1, + is_eo_idtype :2); + char is_eo_idstring[1]; +} ipmi_sdr_event_only_t; + +/* + * Entity Association Record. See section 43.4. + */ + +#define IPMI_SDR_TYPE_ENTITY_ASSOCIATION 0x08 + +typedef struct ipmi_sdr_entity_association { + /* RECORD KEY BYTES */ + uint8_t is_ea_entity_id; + uint8_t is_ea_entity_instance; + DECL_BITFIELD4( + __reserved :5, + is_ea_presence :1, + is_ea_record_link :1, + is_ea_range :1); + /* RECORD BODY BYTES */ + struct { + uint8_t is_ea_sub_id; + uint8_t is_ea_sub_instance; + } is_ea_sub[4]; +} ipmi_sdr_entity_association_t; + +/* + * Device-relative Entity Association Record. See section 43.5. + */ + +#define IPMI_SDR_TYPE_DEVICE_RELATIVE 0x09 + +typedef struct ipmi_sdr_device_relative { + /* RECORD KEY BYTES */ + uint8_t is_dr_entity_id; + uint8_t is_dr_entity_instance; + DECL_BITFIELD2( + __reserved1 :1, + is_dr_slaveaddr :7); + DECL_BITFIELD2( + __reserved2 :4, + is_dr_channel :4); + DECL_BITFIELD4( + __reserved :5, + is_dr_presence :1, + is_dr_record_link :1, + is_dr_range :1); + /* RECORD BODY BYTES */ + struct { + DECL_BITFIELD2( + __reserved3 :1, + is_dr_sub_slaveaddr :7); + DECL_BITFIELD2( + __reserved4 :4, + is_dr_sub_channel :4); + uint8_t is_ea_sub_id; + uint8_t is_ea_sub_instance; + } is_ea_sub[4]; +} ipmi_sdr_device_relative_t; + +/* + * Generic Device Locator Record. See section 43.7. + */ + +#define IPMI_SDR_TYPE_GENERIC_LOCATOR 0x10 + +typedef struct ipmi_sdr_generic_locator { + /* RECORD KEY BYTES */ + DECL_BITFIELD2( + __reserved1 :1, + is_gl_accessaddr :7); + DECL_BITFIELD2( + is_gl_channel_msb :1, + is_gl_slaveaddr :7); + DECL_BITFIELD3( + is_gl_bus :3, + is_gl_lun :2, + is_gl_channel :3); + /* RECORD BODY BYTES */ + DECL_BITFIELD2( + is_gl_span :3, + __reserved2 :5); + uint8_t __reserved3; + uint8_t is_gl_type; + uint8_t is_gl_modifier; + uint8_t is_gl_entity; + uint8_t is_gl_instance; + uint8_t is_gl_oem; + DECL_BITFIELD3( + is_gl_idlen :5, + __reserved4 :1, + is_gl_idtype :2); + char is_gl_idstring[1]; +} ipmi_sdr_generic_locator_t; + +/* + * FRU Device Locator Record. See section 43.8. + */ + +#define IPMI_SDR_TYPE_FRU_LOCATOR 0x11 + +typedef struct ipmi_sdr_fru_locator { + /* RECORD KEY BYTES */ + DECL_BITFIELD2( + __reserved1 :1, + is_fl_accessaddr :7); + union { + struct { + uint8_t _is_fl_devid; + } _logical; + struct { + DECL_BITFIELD2( + __reserved :1, + _is_fl_slaveaddr :7); + } _nonintelligent; + } _devid_or_slaveaddr; + DECL_BITFIELD4( + is_fl_bus :3, + is_fl_lun :2, + __reserved2 :2, + is_fl_logical :1); + DECL_BITFIELD2( + __reserved3 :4, + is_fl_channel :4); + /* RECORD BODY BYTES */ + uint8_t __reserved4; + uint8_t is_fl_type; + uint8_t is_fl_modifier; + uint8_t is_fl_entity; + uint8_t is_fl_instance; + uint8_t is_fl_oem; + DECL_BITFIELD3( + is_fl_idlen :5, + __reserved5 :1, + is_fl_idtype :2); + char is_fl_idstring[1]; +} ipmi_sdr_fru_locator_t; + +#define is_fl_devid _devid_or_slaveaddr._logical._is_fl_devid +#define is_fl_slaveaddr _devid_or_slaveaddr._nonintelligent._is_fl_slaveaddr + +/* + * Management Controller Device Locator Record. See section 43.9 + */ + +#define IPMI_SDR_TYPE_MANAGEMENT_LOCATOR 0x12 + +typedef struct ipmi_sdr_management_locator { + /* RECORD KEY BYTES */ + DECL_BITFIELD2( + __reserved1 :1, + is_ml_devaddr :7); + DECL_BITFIELD2( + is_ml_channel :4, + __reserved2 :4); + /* RECORD BODY BYTES */ + DECL_BITFIELD7( + is_ml_init_message :2, + is_ml_init_log :1, + is_ml_init_controller_log :1, + __reserved3 :1, + is_ml_static :1, + is_ml_acpi_device :1, + is_ml_acpi_system :1); + DECL_BITFIELD8( + is_ml_supp_sensor :1, + is_ml_supp_sdr :1, + is_ml_supp_sel :1, + is_ml_supp_fru :1, + is_ml_supp_event_receiver :1, + is_ml_supp_event_generator :1, + is_ml_supp_bridge :1, + is_ml_supp_chassis :1); + uint8_t __reserved4; + uint16_t __reserved5; + uint8_t is_ml_entity_id; + uint8_t is_ml_entity_instance; + uint8_t is_ml_oem; + DECL_BITFIELD3( + is_ml_idlen :5, + __reserved6 :1, + is_ml_idtype :2); + char is_ml_idstring[1]; +} ipmi_sdr_management_locator_t; + +#define IPMI_MESSAGE_INIT_ENABLE 0x0 +#define IPMI_MESSAGE_INIT_DISABLE 0x1 +#define IPMI_MESSAGE_INIT_NONE 0x2 + +/* + * Management Controller Confirmation Record. See section 43.10 + */ + +#define IPMI_SDR_TYPE_MANAGEMENT_CONFIRMATION 0x13 + +typedef struct ipmi_sdr_management_confirmation { + /* RECORD KEY BYTES */ + DECL_BITFIELD2( + __reserved1 :1, + is_mc_slaveaddr :7); + uint8_t is_mc_deviceid; + DECL_BITFIELD2( + is_mc_dev_revision :4, + is_mc_channel :4); + /* RECORD BODY BYTES */ + DECL_BITFIELD2( + is_mc_major_rev :7, + __reserved2 :1); + uint8_t is_mc_minor_rev; + uint8_t is_mc_impi_ver; + uint8_t is_mc_manufacturer[3]; + uint16_t is_mc_product; + uint8_t is_mc_guid[16]; +} ipmi_sdr_management_confirmation_t; + +/* + * BMC Message Channel Info Record. See esction 43.11. + */ + +#define IPMI_SDR_TYPE_BMC_MESSAGE_CHANNEL 0x14 + +typedef struct ipmi_sdr_bmc_channel { + /* RECORD BODY BYTES */ + struct { + DECL_BITFIELD3( + is_bc_protocol :4, + is_bc_receive_lun :3, + is_bc_transmit :1); + } is_bc_channel[8]; + uint8_t is_bc_interrupt_type; + uint8_t is_bc_buffer_type; + uint8_t __reserved; +} ipmi_sdr_bmc_channel_t; + +/* + * OEM Record. See ction 43.12. + */ + +#define IPMI_SDR_TYPE_OEM 0xC0 + +typedef struct ipmi_sdr_oem { + uint8_t is_oem_manufacturer[3]; + uint8_t is_oem_data[1]; +} ipmi_sdr_oem_t; + +/* + * Iterate over the SDR repository. This function does the work of parsing the + * name when available, and keeping the repository in a consistent state. + */ +extern int ipmi_sdr_iter(ipmi_handle_t *, + int (*)(ipmi_handle_t *, const char *, ipmi_sdr_t *, void *), void *); + +/* + * Lookup the given sensor type by name or a combination of name and entity + * ID/instance. These functions automatically read in and cache the complete + * SDR repository. + */ +extern ipmi_sdr_t *ipmi_sdr_lookup(ipmi_handle_t *, const char *); +extern ipmi_sdr_t *ipmi_sdr_lookup_precise(ipmi_handle_t *, const char *, + uint8_t, uint8_t); +extern ipmi_sdr_fru_locator_t *ipmi_sdr_lookup_fru(ipmi_handle_t *, + const char *); +extern ipmi_sdr_generic_locator_t *ipmi_sdr_lookup_generic(ipmi_handle_t *, + const char *); +extern ipmi_sdr_compact_sensor_t *ipmi_sdr_lookup_compact_sensor( + ipmi_handle_t *, const char *); +extern ipmi_sdr_full_sensor_t *ipmi_sdr_lookup_full_sensor( + ipmi_handle_t *, const char *); + +/* + * Entity ID codes. See table 43.13. + */ +#define IPMI_ET_UNSPECIFIED 0x00 +#define IPMI_ET_OTHER 0x01 +#define IPMI_ET_UNKNOWN 0x02 +#define IPMI_ET_PROCESSOR 0x03 +#define IPMI_ET_DISK 0x04 +#define IPMI_ET_PERIPHERAL 0x05 +#define IPMI_ET_MANAGEMENT_MODULE 0x06 +#define IPMI_ET_MOTHERBOARD 0x07 +#define IPMI_ET_MEMORY_MODULE 0x08 +#define IPMI_ET_PROCESSOR_MODULE 0x09 +#define IPMI_ET_PSU 0x0A +#define IPMI_ET_CARD 0x0B +#define IPMI_ET_FRONT_PANEL 0x0C +#define IPMI_ET_BACK_PANEL 0x0D +#define IPMI_ET_POWER_BOARD 0x0E +#define IPMI_ET_BACKPLANE 0x0F +#define IPMI_ET_EXPANSION_BOARD 0x10 +#define IPMI_ET_OTHER_BOARD 0x11 +#define IPMI_ET_PROCESSOR_BOARD 0x12 +#define IPMI_ET_POWER_DOMAIN 0x13 +#define IPMI_ET_POWER_CONVERTER 0x14 +#define IPMI_ET_POWER_MANAGEMENT 0x15 +#define IPMI_ET_BACK_CHASSIS 0x16 +#define IPMI_ET_SYSTEM_CHASSIS 0x17 +#define IPMI_ET_SUB_CHASSIS 0x18 +#define IPMI_ET_OTHER_CHASSIS 0x19 +#define IPMI_ET_DISK_BAY 0x1A +#define IPMI_ET_PERIPHERAL_BAY 0x1B +#define IPMI_ET_DEVICE_BAY 0x1C +#define IPMI_ET_FAN 0x1D +#define IPMI_ET_COOLING_DOMAIN 0x1E +#define IPMI_ET_CABLE 0x1F +#define IPMI_ET_MEMORY_DEVICE 0x20 +#define IPMI_ET_MANAGEMENT_SOFTWARE 0x21 +#define IPMI_ET_SYSTEM_FIRMWARE 0x22 +#define IPMI_ET_OS 0x23 +#define IPMI_ET_SYSTEM_BUS 0x24 +#define IPMI_ET_GROUP 0x25 +#define IPMI_ET_REMOTE 0x26 +#define IPMI_ET_ENVIRONMENT 0x27 +#define IPMI_ET_BATTERY 0x28 +#define IPMI_ET_BLADE 0x29 +#define IPMI_ET_SWITCH 0x2A +#define IPMI_ET_PROCMEM_MODULE 0x2B +#define IPMI_ET_IO_MODULE 0x2C +#define IPMI_ET_PROCIO_MODULE 0x2D +#define IPMI_ET_CONTROLLER_FIRMWARE 0x2E +#define IPMI_ET_CHANNEL 0x2F +#define IPMI_ET_PCI 0x30 +#define IPMI_ET_PCIE 0x31 +#define IPMI_ET_SCSI 0x32 +#define IPMI_ET_SATA_SAS 0x33 +#define IPMI_ET_FSB 0x34 +#define IPMI_ET_RTC 0x35 + +/* + * Get Sensor Threshold. See section 35.9 + */ +#define IPMI_CMD_GET_SENSOR_THRESHOLDS 0x27 + +typedef struct ipmi_sensor_thresholds { + uint8_t ithr_readable_mask; + uint8_t ithr_lower_noncrit; + uint8_t ithr_lower_crit; + uint8_t ithr_lower_nonrec; + uint8_t ithr_upper_noncrit; + uint8_t ithr_upper_crit; + uint8_t ithr_upper_nonrec; +} ipmi_sensor_thresholds_t; + +extern int ipmi_get_sensor_thresholds(ipmi_handle_t *, + ipmi_sensor_thresholds_t *, uint8_t); + +/* + * Get Sensor Reading. See section 35.14. + */ + +#define IPMI_CMD_GET_SENSOR_READING 0x2d + +typedef struct ipmi_sensor_reading { + uint8_t isr_reading; + DECL_BITFIELD4( + __reserved1 :5, + isr_state_unavailable :1, + isr_scanning_enabled :1, + isr_event_enabled :1); + uint16_t isr_state; +} ipmi_sensor_reading_t; + +#define IPMI_SENSOR_THRESHOLD_LOWER_NONCRIT 0x0001 +#define IPMI_SENSOR_THRESHOLD_LOWER_CRIT 0x0002 +#define IPMI_SENSOR_THRESHOLD_LOWER_NONRECOV 0x0004 +#define IPMI_SENSOR_THRESHOLD_UPPER_NONCRIT 0x0008 +#define IPMI_SENSOR_THRESHOLD_UPPER_CRIT 0x0010 +#define IPMI_SENSOR_THRESHOLD_UPPER_NONRECOV 0x0020 + +extern ipmi_sensor_reading_t *ipmi_get_sensor_reading(ipmi_handle_t *, uint8_t); +extern int ipmi_sdr_conv_reading(ipmi_sdr_full_sensor_t *, uint8_t, + double *); +/* + * Set Sensor Reading. See section 35.14. + */ +#define IPMI_CMD_SET_SENSOR_READING 0x30 + +#define IPMI_SENSOR_OP_CLEAR 0x3 /* clear '0' bits */ +#define IPMI_SENSOR_OP_SET 0x2 /* set '1' bits */ +#define IPMI_SENSOR_OP_EXACT 0x1 /* set bits exactly */ + +typedef struct ipmi_set_sensor_reading { + uint8_t iss_id; + DECL_BITFIELD5( + iss_set_reading :1, + __reserved :1, + iss_deassrt_op :2, + iss_assert_op :2, + iss_data_bytes :2); + uint8_t iss_sensor_reading; + uint16_t iss_assert_state; /* optional */ + uint16_t iss_deassert_state; /* optional */ + uint8_t iss_event_data1; /* optional */ + uint8_t iss_event_data2; /* optional */ + uint8_t iss_event_data3; /* optional */ +} ipmi_set_sensor_reading_t; + +extern int ipmi_set_sensor_reading(ipmi_handle_t *, + ipmi_set_sensor_reading_t *); + +/* + * These IPMI message id/opcodes are documented in Appendix G in the IPMI spec. + * + * Payloads for these two commands are described in Sections 34.1 and 34.2 of + * the spec, respectively. + */ +#define IPMI_CMD_GET_FRU_INV_AREA 0x10 +#define IPMI_CMD_READ_FRU_DATA 0x11 + +/* + * Structs to hold the FRU Common Header and the FRU Product Info Area, as + * described in the IPMI Platform Management FRU Information Storage + * Definition (v1.1). + */ +typedef struct ipmi_fru_hdr +{ + uint8_t ifh_format; + uint8_t ifh_int_use_off; + uint8_t ifh_chassis_info_off; + uint8_t ifh_board_info_off; + uint8_t ifh_product_info_off; + uint8_t ifh_multi_rec_off; + uint8_t ifh_pad; + uint8_t ifh_chksum; +} ipmi_fru_hdr_t; + +/* + * Because only 6 bits are used to specify the length of each field in the FRU + * product and board info areas, the biggest string we would ever need to hold + * would be 63 chars plus a NULL. + */ +#define FRU_INFO_MAXLEN 64 + +typedef struct ipmi_fru_brd_info +{ + char ifbi_manuf_date[3]; + char ifbi_manuf_name[FRU_INFO_MAXLEN]; + char ifbi_board_name[FRU_INFO_MAXLEN]; + char ifbi_product_serial[FRU_INFO_MAXLEN]; + char ifbi_part_number[FRU_INFO_MAXLEN]; +} ipmi_fru_brd_info_t; + +typedef struct ipmi_fru_prod_info +{ + char ifpi_manuf_name[FRU_INFO_MAXLEN]; + char ifpi_product_name[FRU_INFO_MAXLEN]; + char ifpi_part_number[FRU_INFO_MAXLEN]; + char ifpi_product_version[FRU_INFO_MAXLEN]; + char ifpi_product_serial[FRU_INFO_MAXLEN]; + char ifpi_asset_tag[FRU_INFO_MAXLEN]; +} ipmi_fru_prod_info_t; + +extern int ipmi_fru_read(ipmi_handle_t *, ipmi_sdr_fru_locator_t *, char **); +extern int ipmi_fru_parse_board(ipmi_handle_t *, char *, ipmi_fru_brd_info_t *); +extern int ipmi_fru_parse_product(ipmi_handle_t *, char *, + ipmi_fru_prod_info_t *); + +/* + * Routines to convert from entity and sensors defines into text strings. + */ +void ipmi_entity_name(uint8_t, char *, size_t); +void ipmi_sensor_type_name(uint8_t, char *, size_t); +void ipmi_sensor_units_name(uint8_t, char *, size_t); +void ipmi_sensor_reading_name(uint8_t, uint8_t, char *, size_t); + +/* + * Entity management. IPMI has a notion of 'entities', but these are not + * directly accessible from any commands. Instead, their existence is inferred + * from examining the SDR repository. Since this is rather unwieldy, and + * iterating over entities is a common operation, libipmi provides an entity + * abstraction that hides the implementation details. This handles entity + * groupings as well as SDR associations. + */ +typedef struct ipmi_entity { + uint8_t ie_type; + uint8_t ie_instance; + uint8_t ie_children; + boolean_t ie_logical; +} ipmi_entity_t; + +extern int ipmi_entity_iter(ipmi_handle_t *, int (*)(ipmi_handle_t *, + ipmi_entity_t *, void *), void *); +extern int ipmi_entity_iter_sdr(ipmi_handle_t *, ipmi_entity_t *, + int (*)(ipmi_handle_t *, ipmi_entity_t *, const char *, ipmi_sdr_t *, + void *), void *); +extern int ipmi_entity_iter_children(ipmi_handle_t *, ipmi_entity_t *, + int (*)(ipmi_handle_t *, ipmi_entity_t *, void *), void *); +extern ipmi_entity_t *ipmi_entity_lookup(ipmi_handle_t *, uint8_t, + uint8_t); +extern ipmi_entity_t *ipmi_entity_lookup_sdr(ipmi_handle_t *, const char *); +extern ipmi_entity_t *ipmi_entity_parent(ipmi_handle_t *, ipmi_entity_t *); +extern int ipmi_entity_present(ipmi_handle_t *, ipmi_entity_t *, boolean_t *); +extern int ipmi_entity_present_sdr(ipmi_handle_t *, ipmi_sdr_t *, boolean_t *); + +/* + * User management. The raw functions are private to libipmi, and only the + * higher level abstraction (ipmi_user_t) is exported to consumers of the + * library. + */ + +#define IPMI_USER_PRIV_CALLBACK 0x1 +#define IPMI_USER_PRIV_USER 0x2 +#define IPMI_USER_PRIV_OPERATOR 0x3 +#define IPMI_USER_PRIV_ADMIN 0x4 +#define IPMI_USER_PRIV_OEM 0x5 +#define IPMI_USER_PRIV_NONE 0xf + +typedef struct ipmi_user { + uint8_t iu_uid; + char *iu_name; + boolean_t iu_enabled; + boolean_t iu_ipmi_msg_enable; + boolean_t iu_link_auth_enable; + uint8_t iu_priv; +} ipmi_user_t; + +extern int ipmi_user_iter(ipmi_handle_t *, + int (*)(ipmi_user_t *, void *), void *); +extern ipmi_user_t *ipmi_user_lookup_name(ipmi_handle_t *, const char *); +extern ipmi_user_t *ipmi_user_lookup_id(ipmi_handle_t *, uint8_t); +extern int ipmi_user_set_password(ipmi_handle_t *, uint8_t, const char *); + +/* + * The remaining functions are private to the implementation of the Sun ILOM + * service processor. These function first check the manufacturer from the IPMI + * device ID, and will return EIPMI_NOT_SUPPORTED if attempted for non-Sun + * devices. + */ +boolean_t ipmi_is_sun_ilom(ipmi_deviceid_t *); + +/* + * Sun OEM LED requests. + */ + +#define IPMI_SUNOEM_LED_MODE_OFF 0 +#define IPMI_SUNOEM_LED_MODE_ON 1 +#define IPMI_SUNOEM_LED_MODE_STANDBY 2 +#define IPMI_SUNOEM_LED_MODE_SLOW 3 +#define IPMI_SUNOEM_LED_MODE_FAST 4 + +/* + * These functions take a SDR record and construct the appropriate form of the + * above commands. + */ +extern int ipmi_sunoem_led_set(ipmi_handle_t *, + ipmi_sdr_generic_locator_t *, uint8_t); +extern int ipmi_sunoem_led_get(ipmi_handle_t *, + ipmi_sdr_generic_locator_t *, uint8_t *); + +/* + * Sun OEM uptime. Note that the underlying command returns the uptime in big + * endian form. This wrapper automatically converts to the appropriate native + * form. + */ + +#define IPMI_CMD_SUNOEM_UPTIME 0x08 + +extern int ipmi_sunoem_uptime(ipmi_handle_t *, uint32_t *, uint32_t *); + +/* + * Sun OEM FRU update. The FRU information is managed through a generic + * identifier, and then a type-specific data portion. The wrapper function will + * automatically fill in the data length field according to which type is + * specified. + */ + +#define IPMI_CMD_SUNOEM_FRU_UPDATE 0x16 + +#define IPMI_SUNOEM_FRU_DIMM 0x00 +#define IPMI_SUNOEM_FRU_CPU 0x01 +#define IPMI_SUNOEM_FRU_BIOS 0x02 +#define IPMI_SUNOEM_FRU_DISK 0x03 + +typedef struct ipmi_sunoem_fru { + uint8_t isf_type; + uint8_t isf_id; + uint8_t isf_datalen; + union { + struct { + uint8_t isf_data[128]; + } dimm; + struct { + uint32_t isf_thermtrip; + uint32_t isf_eax; + char isf_product[48]; + } cpu; + struct { + char isf_part[16]; + char isf_version[16]; + } bios; + struct { + char isf_manufacturer[16]; + char isf_model[28]; + char isf_serial[20]; + char isf_version[8]; + char isf_capacity[16]; + } disk; + } isf_data; +} ipmi_sunoem_fru_t; + +int ipmi_sunoem_update_fru(ipmi_handle_t *, ipmi_sunoem_fru_t *); + +/* + * See section 28.2 + */ +#define IPMI_CMD_GET_CHASSIS_STATUS 0x01 + +/* + * flags for ichs_current_pwr_state field + */ +#define IPMI_CURR_PWR_STATE_ON 0x01 +#define IPMI_CURR_PWR_STATE_OVERLOAD 0x02 +#define IPMI_CURR_PWR_STATE_INTERLOCK 0x04 +#define IPMI_CURR_PWR_STATE_FAULT 0x08 +#define IPMI_CURR_PWR_STATE_CNTL_FAULT 0x10 + +/* + * flags for ichs_last_pwr_state field + */ +#define IPMI_LAST_PWR_STATE_ACFAILED 0x01 +#define IPMI_LAST_PWR_STATE_OVERLOAD 0x02 +#define IPMI_LAST_PWR_STATE_INTERLOCK 0x04 +#define IPMI_LAST_PWR_STATE_FAULT 0x08 +#define IPMI_LAST_PWR_STATE_CMD_ON 0x10 + +/* + * flags for the ichs_pwr_restore_policy field + */ +#define IPMI_PWR_POLICY_REMAIN_OFF 0x0 +#define IPMI_PWR_POLICY_RESTORE 0x1 +#define IPMI_PWR_POLICY_POWER_ON 0x2 +#define IPMI_PWR_POLICY_UNKNOWN 0x3 + +typedef struct ipmi_chassis_status { + DECL_BITFIELD3( + ichs_current_pwr_state :5, + ichs_pwr_restore_policy :2, + __reserved1 :1); + DECL_BITFIELD2( + ichs_last_pwr_state :5, + __reserved2 :3); + DECL_BITFIELD7( + ichs_intrusion_asserted :1, + ichs_front_panel_disabled :1, + ichs_drive_fault_asserted :1, + ichs_fan_fault_asserted :1, + ichs_identify_state :2, + ichs_identify_supported :1, + __reserved3 :1); +} ipmi_chassis_status_t; + +extern ipmi_chassis_status_t *ipmi_chassis_status(ipmi_handle_t *); + +/* + * See section 28.5 + */ +#define IPMI_CMD_CHASSIS_IDENTIFY 0x04 +int ipmi_chassis_identify(ipmi_handle_t *, boolean_t); + +#pragma pack() + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBIPMI_H */ diff --git a/illumos-x86_64/usr/include/libipp.h b/illumos-x86_64/usr/include/libipp.h new file mode 100644 index 00000000..054842a6 --- /dev/null +++ b/illumos-x86_64/usr/include/libipp.h @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBIPP_H +#define _LIBIPP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef DEBUG + +#define DBG_ERR 0x00000001 +#define DBG_IO 0x00000002 + +#endif /* DEBUG */ + +/* + * interface functions + */ + +extern int ipp_action_create(const char *, const char *, nvlist_t **, + ipp_flags_t); +extern int ipp_action_destroy(const char *, ipp_flags_t); +extern int ipp_action_modify(const char *, nvlist_t **, ipp_flags_t); +extern int ipp_action_info(const char *, int (*)(nvlist_t *, void *), + void *, ipp_flags_t); +extern int ipp_action_mod(const char *, char **); +extern int ipp_list_mods(char ***, int *); +extern int ipp_mod_list_actions(const char *, char ***, int *); +extern void ipp_free(char *); +extern void ipp_free_array(char **, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBIPP_H */ diff --git a/illumos-x86_64/usr/include/libnvme.h b/illumos-x86_64/usr/include/libnvme.h new file mode 100644 index 00000000..19bb0c87 --- /dev/null +++ b/illumos-x86_64/usr/include/libnvme.h @@ -0,0 +1,1308 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _LIBNVME_H +#define _LIBNVME_H + +/* + * This contains an evolving set of interfaces for more programmatically + * interfacing with NVMe devices. For more information on why the library looks + * this way, please see lib/libnvme/common/libnvme.c. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +/* + * Right now everything relies on seeing various pieces that are in sys/nvme.h, + * unfortunately. This includes things like the identify, log page, and + * structure data structures, various constants, and other things that have + * accumulated. This must all be rejiggered prior to making this a committed + * interface as we're leaking through many things that software needs. + * Directionally splitting this out into headers that relate to the spec as + * , etc. would be useful and would address several of the + * places that we're passing in raw uint32_t's for items that come from the spec + * and could be a little more specific to help out consumers. + */ +#include + +/* + * General error classes that may be returned when operating on non-information + * snapshots. + */ +typedef enum { + NVME_ERR_OK = 0, + /* + * Indicates that a command failed due to a controller-specific error. + * The controller's SCT/SC are valid in the corresponding objects error + * data. + */ + NVME_ERR_CONTROLLER, + /* + * Indicates that there was a memory allocation error. The system error + * contains the specific errno. + */ + NVME_ERR_NO_MEM, + /* + * Indicates that an operation could not complete because the kernel did + * not have DMA resources available for us. + */ + NVME_ERR_NO_DMA_MEM, + /* + * Indicates that an error occurred while trying to use the devinfo + * library. + */ + NVME_ERR_LIBDEVINFO, + /* + * Indicates that an internal error condition occurred. + */ + NVME_ERR_INTERNAL, + /* + * Indicates that the function was given an invalid pointer argument. + */ + NVME_ERR_BAD_PTR, + /* + * Indicates that an unknown flag argument was given to us. + */ + NVME_ERR_BAD_FLAG, + /* + * Indicates that the devinfo node we were given doesn't correspond to + * an NVMe controller. + */ + NVME_ERR_BAD_DEVI, + /* + * Indicates that while we found a devinfo property successfully, + * something about it does not match our expectations. This could be the + * type, number of values, range, etc. + */ + NVME_ERR_BAD_DEVI_PROP, + /* + * Indicates that we were given an illegal instance (i.e. a negative + * instance). + */ + NVME_ERR_ILLEGAL_INSTANCE, + /* + * Indicates that a means of identifying a controller (name, instance, + * etc.) does not match any known NVMe device. + */ + NVME_ERR_BAD_CONTROLLER, + /* + * Indicates that a request could not proceed due to missing privileges. + */ + NVME_ERR_PRIVS, + /* + * Indicates a failure to open a device file. + */ + NVME_ERR_OPEN_DEV, + /* + * Indicates that the given restore data is not valid. + */ + NVME_ERR_BAD_RESTORE, + /* + * Indicates that a namespace (name, ID, etc.) passed in is not valid on + * the controller. This may be because it's outside the valid range or + * there was an attempt to use the broadcast namespace when it's not + * supported. + */ + NVME_ERR_NS_RANGE, + /* + * Indicates that a namespace ID is not usable in this context. For + * example, attempting to specify a namespace to an identify or log page + * that does not support them. + */ + NVME_ERR_NS_UNUSE, + /* + * Indicates that the value for a get log page field is invalid. This + * may happened due to alignment, just being too large, or something + * else. + */ + NVME_ERR_LOG_CSI_RANGE, + NVME_ERR_LOG_LID_RANGE, + NVME_ERR_LOG_LSP_RANGE, + NVME_ERR_LOG_LSI_RANGE, + NVME_ERR_LOG_RAE_RANGE, + NVME_ERR_LOG_SIZE_RANGE, + NVME_ERR_LOG_OFFSET_RANGE, + /* + * Indicates that the log field value given is not supported because the + * controller is not of a sufficient version or does not indicate that + * it is supported in the LPA field. + */ + NVME_ERR_LOG_CSI_UNSUP, + NVME_ERR_LOG_LSP_UNSUP, + NVME_ERR_LOG_LSI_UNSUP, + NVME_ERR_LOG_RAE_UNSUP, + NVME_ERR_LOG_OFFSET_UNSUP, + /* + * Indicates that the log field value is unusable. The specifics of our + * request indicate that this cannot be set. + */ + NVME_ERR_LOG_LSP_UNUSE, + NVME_ERR_LOG_LSI_UNUSE, + NVME_ERR_LOG_RAE_UNUSE, + /* + * Indicates that the log page's scope requires operating on something + * that isn't what was requested. This would happen if manually + * constructing a log page that operates on the controller, but passed a + * namespace (e.g. the firmware log page). + */ + NVME_ERR_LOG_SCOPE_MISMATCH, + /* + * Indicates that a log request can't be executed because required + * fields have not been set. + */ + NVME_ERR_LOG_REQ_MISSING_FIELDS, + /* + * Indicates that the named log is unknown to the library. + */ + NVME_ERR_LOG_NAME_UNKNOWN, + /* + * Indicates that the named log is not supported by the device. + */ + NVME_ERR_LOG_UNSUP_BY_DEV, + /* + * Indicates that the IDENTIFY command requested is unknown. + */ + NVME_ERR_IDENTIFY_UNKNOWN, + /* + * Indicates that the requested identify command is not supported by the + * device. + */ + NVME_ERR_IDENTIFY_UNSUP_BY_DEV, + /* + * Indicates that the identify command parameter is outside of the valid + * range for the field. + */ + NVME_ERR_IDENTIFY_CTRLID_RANGE, + NVME_ERR_IDENTIFY_OUTPUT_RANGE, + /* + * Indicates that the parameter given is not supported because the + * controller is not of a sufficient version or does not indicate that + * it is supported. + */ + NVME_ERR_IDENTIFY_CTRLID_UNSUP, + /* + * Indicates that the parameter given is not supported in the context of + * a given identify command. Namespaces are handled with the + * cross-command error code. + */ + NVME_ERR_IDENTIFY_CTRLID_UNUSE, + /* + * Indicates that an identify request can't be executed because required + * fields have not been set. + */ + NVME_ERR_IDENTIFY_REQ_MISSING_FIELDS, + /* + * Indicates that the controller doesn't support the NVMe standard + * vendor unique command. + */ + NVME_ERR_VUC_UNSUP_BY_DEV, + /* + * Indicates that the vendor unique command parameter is outside of the + * valid range for the field. + */ + NVME_ERR_VUC_TIMEOUT_RANGE, + NVME_ERR_VUC_OPCODE_RANGE, + NVME_ERR_VUC_IMPACT_RANGE, + NVME_ERR_VUC_NDT_RANGE, + /* + * Indicates that a vendor unique command already has an input or output + * buffer set and is being asked to set a separate one. + */ + NVME_ERR_VUC_CANNOT_RW, + /* + * Indicates that the vendor unique request does not have valid + * execution context. This may be because the command was never executed + * or the exec failed in a way such that the controller never exercised + * the command. + */ + NVME_ERR_VUC_NO_RESULTS, + /* + * Indicates that the named vendor unique command is not known to the + * library. + */ + NVME_ERR_VUC_UNKNOWN, + /* + * Indicates that a vendor unique command can't be executed because + * required fields have not been set. + */ + NVME_ERR_VUC_REQ_MISSING_FIELDS, + /* + * Indicates that the vendor-specific library operation could not + * proceed because it is not supported by the given device. + */ + NVME_ERR_VU_FUNC_UNSUP_BY_DEV, + /* + * WDC e6 dump specific invalid values + */ + NVME_ERR_WDC_E6_OFFSET_RANGE, + /* + * Indicates that the controller does not support firmware related + * operations. + */ + NVME_ERR_FW_UNSUP_BY_DEV, + /* + * Indicates that the constraints of the device and what the kernel can + * do make the firmware upgrade non-tenable. + */ + NVME_ERR_KERN_FW_IMPOS, + /* + * Indicates that a firmware download parameter is invalid. + */ + NVME_ERR_FW_LOAD_LEN_RANGE, + NVME_ERR_FW_LOAD_OFFSET_RANGE, + /* + * Indicates that the firmware commit command parameter is outside of + * the valid range for the field. + */ + NVME_ERR_FW_COMMIT_SLOT_RANGE, + NVME_ERR_FW_COMMIT_ACTION_RANGE, + /* + * Indicates that a firmware commit command can't be executed because + * required fields have not been set. + */ + NVME_ERR_FW_COMMIT_REQ_MISSING_FIELDS, + /* + * Indicates that the firmware commit could not occur because the + * requested slot is read-only. + */ + NVME_ERR_FW_SLOT_RO, + /* + * Indicates that the controller does not support NVM format operations. + */ + NVME_ERR_FORMAT_UNSUP_BY_DEV, + /* + * Indicates that the controller does not support cryptographic secure + * erase. + */ + NVME_ERR_CRYPTO_SE_UNSUP_BY_DEV, + /* + * Indicates that the NVM format command cannot be executed because it + * would target a specific namespace; however, the device does not allow + * a secure erase or a format to target an individual namespace. + */ + NVME_ERR_NS_FORMAT_UNSUP_BY_DEV, + /* + * Indicates that the kernel does not support formatting with the + * specified LBA format, generally due to something like the use of + * metadata in the namespace. + */ + NVME_ERR_KERN_FORMAT_UNSUP, + /* + * Indicates that the NVM format command parameter is outside of + * the valid range for the field. + */ + NVME_ERR_FORMAT_LBAF_RANGE, + NVME_ERR_FORMAT_SES_RANGE, + /* + * Indicates that the parameter and/or its value is not supported for a + * NVM format command. + */ + NVME_ERR_FORMAT_PARAM_UNSUP, + /* + * Indicates that a NVM format command can't be executed because + * required fields have not been set. + */ + NVME_ERR_FORMAT_REQ_MISSING_FIELDS, + /* + * Indicates that the WDC e6 log dump request could not be executed due + * to fields not being set. + */ + NVME_ERR_WDC_E6_REQ_MISSING_FIELDS, + /* + * Indicates that the named feature is unknown to the library. + */ + NVME_ERR_FEAT_NAME_UNKNOWN, + /* + * Indicates that the named feature is not supported by the device. + */ + NVME_ERR_FEAT_UNSUP_BY_DEV, + /* + * Indicates that the feature parameter is outside of the valid range + * for the field. + */ + NVME_ERR_FEAT_FID_RANGE, + NVME_ERR_FEAT_SEL_RANGE, + NVME_ERR_FEAT_CDW11_RANGE, + NVME_ERR_FEAT_DATA_RANGE, + /* + * Indicates that the feature parameter given is not supported because + * the controller is not of a sufficient version. + */ + NVME_ERR_FEAT_SEL_UNSUP, + /* + * Indicates that the get feature parameter given is not supported for + * the given feature. For example, passing in a cdw11 argument that is + * not needed. + */ + NVME_ERR_FEAT_CDW11_UNUSE, + NVME_ERR_FEAT_DATA_UNUSE, + /* + * Indicates that a feature request does not have valid output data. + * This may be because the command was never executed or it did not + * execute successfully. + */ + NVME_ERR_FEAT_NO_RESULTS, + /* + * Indicates that a get features request can't be executed because + * required fields have not been set. + */ + NVME_ERR_GET_FEAT_REQ_MISSING_FIELDS, + /* + * These indicate that the operation could not be executed because they + * require holding either a controller or namespace write lock and one + * is not held by the corresponding controller handle. + */ + NVME_ERR_NEED_CTRL_WRLOCK, + NVME_ERR_NEED_NS_WRLOCK, + /* + * These indicate that the operation could not be executed because the + * controller or namespace respectively currently have an exclusive + * write lock (or an equivalent future form) that blocks execution from + * others. + */ + NVME_ERR_CTRL_LOCKED, + NVME_ERR_NS_LOCKED, + /* + * Indicates that a fatal locking operation occurred that will terminate + * the process. This includes cases such as recursive enters on the same + * lock, attempting to unlock a lock that isn't owned, etc. + */ + NVME_ERR_LOCK_PROG, + /* + * Indicates that a lock order violation was attempted. This includes + * things like taking the controller lock while holding the namespace + * lock, attempting to take a second namespace lock, holding a + * controller write lock and trying to get a namespace lock, etc. + */ + NVME_ERR_LOCK_ORDER, + /* + * Indicates that a signal was encountered while attempting to take a + * lock. + */ + NVME_ERR_LOCK_WAIT_INTR, + /* + * Indicates that attempting to take the lock failed because the thread + * would be required to block, but it asked not to. + */ + NVME_ERR_LOCK_WOULD_BLOCK, + /* + * These indicate that the respective blkdev attach and detach + * operations failed to complete due to an error in the underlying + * kernel subsystems. For detach this might happen because of a disk + * being open, busy in a zpool, or something else. For attach, it may + * suggest an NDI or other issue. + */ + NVME_ERR_DETACH_KERN, + NVME_ERR_ATTACH_KERN, + /* + * Indicates that the kernel driver does not support some property of + * the requested namespace. + */ + NVME_ERR_ATTACH_UNSUP_KERN, + /* + * Indicates that the operation cannot proceed because a namespace is + * attached to blkdev and it must be detached to proceed. + */ + NVME_ERR_NS_BLKDEV_ATTACH, + /* + * Indicates that non-DMA kernel memory was not available for this + * request. + */ + NVME_ERR_NO_KERN_MEM, + /* + * These two codes represent internal device conditions that indicate + * the device is unusable or that it was physically removed (usually due + * to hotplug). + */ + NVME_ERR_CTRL_DEAD, + NVME_ERR_CTRL_GONE, + /* + * Indicates that the controller does not support namespace management + * operations including controller attach/detach and namespace + * create/delete. + */ + NVME_ERR_NS_MGMT_UNSUP_BY_DEV, + /* + * Indicates that the controller does not support thin provisioning. + */ + NVME_ERR_THIN_PROV_UNSUP_BY_DEV, + /* + * These indicate that the corresponding requests cannot be executed due + * to missing fields. + */ + NVME_ERR_NS_ATTACH_REQ_MISSING_FIELDS, + NVME_ERR_NS_CREATE_REQ_MISSING_FIELDS, + NVME_ERR_NS_DELETE_REQ_MISSING_FIELDS, + /* + * This specifically is used by the namespace creation functions to + * indicate that a requested CSI is not supported. Currently this could + * be because the CSI is invalid, the device doesn't support it, the + * kernel doesn't support it, etc. + * + * The namespace attach variant is the same logic, just applied to the + * selector. Both of these are phrased differently as the set of fields + * that may or may not be valid for a given request of these types can + * vary based on the type. + */ + NVME_ERR_NS_CREATE_BAD_CSI, + NVME_ERR_NS_ATTACH_BAD_SEL, + /* + * Indicates that the NSID result value is not valid because we have not + * yet executed a namespace create request. + */ + NVME_ERR_NS_CREATE_NO_RESULTS, + /* + * Indicates that the create namespace field is outside of the valid + * range for the field. + */ + NVME_ERR_NS_CREATE_NCAP_RANGE, + NVME_ERR_NS_CREATE_NSZE_RANGE, + NVME_ERR_NS_CREATE_NMIC_RANGE, + NVME_ERR_NS_CREATE_FLBAS_RANGE, + /* + * Indicates that the operation cannot proceed because the namespace is + * already attached or not attached to a controller respectively. + */ + NVME_ERR_NS_CTRL_ATTACHED, + NVME_ERR_NS_CTRL_NOT_ATTACHED, + /* + * Indicates that the namespace is unallocated and therefore the + * operation cannot proceed. + */ + NVME_ERR_NS_UNALLOC +} nvme_err_t; + +/* + * Errors used for the various information errors. This is shared between both + * controller and namespace information structures. + */ +typedef enum { + NVME_INFO_ERR_OK, + /* + * Indicates that the item is not supported because this is the wrong + * controller transport. For example, asking about a PCI ID for + * something that is not PCI-based. + */ + NVME_INFO_ERR_TRANSPORT, + /* + * Indicates that the item is not supported because the device version + * is too old to get this. + */ + NVME_INFO_ERR_VERSION, + /* + * Indicates that we could not get certain information because the + * device does not support a given capability. + */ + NVME_INFO_ERR_MISSING_CAP, + /* + * Indicates that the specified format value is unknown. + */ + NVME_INFO_ERR_BAD_LBA_FMT, + /* + * These errors only occur during attempts to persist information and + * indicate challenges allocating memory or otherwise challenges with + * libnvpair. + */ + NVME_INFO_ERR_PERSIST_NVL, + /* + * The first indicates that the index is invalid or if it is technically + * within the valid LBA format range, but there is no data size. The + * second indicates that we can't actually fully represent the data + * here. This happens because say the LBA size can't be represented by a + * uint64_t. + */ + NVME_INFO_ERR_BAD_FMT, + NVME_INFO_ERR_BAD_FMT_DATA, + /* + * Indicates that the information cannot be returned because the + * namespace's state does not allow us to answer this question. This may + * be because it's inactive as below or because blkdev is not attached. + */ + NVME_INFO_ERR_NS_INACTIVE, + NVME_INFO_ERR_NS_NO_BLKDEV +} nvme_info_err_t; + +typedef struct nvme nvme_t; +typedef struct nvme_ctrl nvme_ctrl_t; +typedef struct nvme_ctrl_iter nvme_ctrl_iter_t; +typedef struct nvme_ctrl_disc nvme_ctrl_disc_t; +typedef struct nvme_ctrl_info nvme_ctrl_info_t; +typedef struct nvme_ns nvme_ns_t; +typedef struct nvme_ns_iter nvme_ns_iter_t; +typedef struct nvme_ns_disc nvme_ns_disc_t; +typedef struct nvme_ns_info nvme_ns_info_t; +typedef struct nvme_nvm_lba_fmt nvme_nvm_lba_fmt_t; +typedef struct nvme_log_iter nvme_log_iter_t; +typedef struct nvme_log_disc nvme_log_disc_t; +typedef struct nvme_log_req nvme_log_req_t; +typedef struct nvme_id_req nvme_id_req_t; +typedef struct nvme_vuc_iter nvme_vuc_iter_t; +typedef struct nvme_vuc_disc nvme_vuc_disc_t; +typedef struct nvme_vuc_req nvme_vuc_req_t; +typedef struct nvme_fw_commit_req nvme_fw_commit_req_t; +typedef struct nvme_format_req nvme_format_req_t; +typedef struct nvme_feat_disc nvme_feat_disc_t; +typedef struct nvme_feat_iter nvme_feat_iter_t; +typedef struct nvme_get_feat_req nvme_get_feat_req_t; +typedef struct nvme_ns_attach_req nvme_ns_attach_req_t; +typedef struct nvme_ns_create_req nvme_ns_create_req_t; +typedef struct nvme_ns_delete_req nvme_ns_delete_req_t; + +/* + * Vendor-specific forwards. + */ +typedef struct nvme_wdc_e6_req nvme_wdc_e6_req_t; + +extern nvme_t *nvme_init(void); +extern void nvme_fini(nvme_t *); + +/* + * Error information. Operations that take an nvme_t, always set error + * information on the nvme_t. Operations that operate on a controller or are + * related to a request object or iterator that starts from the controller + * set error information on the nvme_ctrl_t. + */ +extern nvme_err_t nvme_err(nvme_t *); +extern int32_t nvme_syserr(nvme_t *); +extern const char *nvme_errmsg(nvme_t *); +extern size_t nvme_errlen(nvme_t *); +extern const char *nvme_errtostr(nvme_t *, nvme_err_t); + +extern nvme_err_t nvme_ctrl_err(nvme_ctrl_t *); +extern int32_t nvme_ctrl_syserr(nvme_ctrl_t *); +extern const char *nvme_ctrl_errmsg(nvme_ctrl_t *); +extern size_t nvme_ctrl_errlen(nvme_ctrl_t *); +extern void nvme_ctrl_deverr(nvme_ctrl_t *, uint32_t *, uint32_t *); +extern const char *nvme_ctrl_errtostr(nvme_ctrl_t *, nvme_err_t); + +/* + * Translations for NVMe spec error constants. These end up taking the + * nvme_ctrl_t so that way they can potentially translate vendor-specific errors + * if they are defined. A NULL controller is allowed, which will skip all such + * processing altogether. Both functions will always a return a string so there + * is no need to check for NULL (though it may just be a variant of "unknown + * ..."). + * + * If NULL is passed for the controller in nvme_sctostr(), we will assume that + * the controller's type is a traditional PCI I/O controller and not a fabric + * based controller, which further changes the way that command-specific status + * codes are interpreted. Due to the lack of support in the system for + * different controller types, this function will always assume a PCI I/O + * controller currently. + */ +extern const char *nvme_scttostr(nvme_ctrl_t *, uint32_t); +extern const char *nvme_sctostr(nvme_ctrl_t *, nvme_csi_t, uint32_t, uint32_t); + +typedef enum nvme_iter { + NVME_ITER_VALID, + NVME_ITER_DONE, + NVME_ITER_ERROR +} nvme_iter_t; + +/* + * NVMe Controller discovery. + */ +extern di_node_t nvme_ctrl_disc_devi(const nvme_ctrl_disc_t *); +extern di_minor_t nvme_ctrl_disc_minor(const nvme_ctrl_disc_t *); + +extern bool nvme_ctrl_discover_init(nvme_t *, nvme_ctrl_iter_t **); +extern nvme_iter_t nvme_ctrl_discover_step(nvme_ctrl_iter_t *, + const nvme_ctrl_disc_t **); +extern void nvme_ctrl_discover_fini(nvme_ctrl_iter_t *); + +typedef bool (*nvme_ctrl_disc_f)(nvme_t *, const nvme_ctrl_disc_t *, void *); +extern bool nvme_ctrl_discover(nvme_t *, nvme_ctrl_disc_f, void *); + +extern bool nvme_ctrl_init(nvme_t *, di_node_t, nvme_ctrl_t **); +extern bool nvme_ctrl_init_by_instance(nvme_t *, int32_t, nvme_ctrl_t **); +extern bool nvme_ctrl_devi(nvme_ctrl_t *, di_node_t *); +extern void nvme_ctrl_fini(nvme_ctrl_t *); + +/* + * Get information about a controller. This information about a controller is + * separate from the lifetime of the controller itself. This is done to + * facilitate the ability of saving and using this information on another + * system and make the management a bit easier. Errors appear on this object and + * not the nmve_t. + */ +extern bool nvme_ctrl_info_snap(nvme_ctrl_t *, nvme_ctrl_info_t **); +extern bool nvme_ctrl_info_restore(nvme_t *, nvlist_t *, nvme_ctrl_info_t **); +extern bool nvme_ctrl_info_persist(nvme_ctrl_info_t *, nvlist_t **); +extern void nvme_ctrl_info_free(nvme_ctrl_info_t *); + +extern nvme_info_err_t nvme_ctrl_info_err(nvme_ctrl_info_t *); +extern int32_t nvme_ctrl_info_syserr(nvme_ctrl_info_t *); +extern const char *nvme_ctrl_info_errmsg(nvme_ctrl_info_t *); +extern size_t nvme_ctrl_info_errlen(nvme_ctrl_info_t *); +extern const char *nvme_ctrl_info_errtostr(nvme_ctrl_info_t *, nvme_info_err_t); + +/* + * Information about an NVMe controller. This information is a combination of + * the identify data structure which can be retrieved directly by folks who + * would prefer to use it. Common fields that are used in something like nvmeadm + * or other utilities who would rather not need to know about the specifics of + * the data structure or have to think about the version can use that instead. + * + * NVMe 2.x has kept the identify controller data structure backwards + * compatible. If a future version were to invalidate that, then this could + * possibly return NULL. + */ +extern uint16_t nvme_ctrl_info_vendor(nvme_ctrl_info_t *); +extern const nvme_identify_ctrl_t *nvme_ctrl_info_identify(nvme_ctrl_info_t *); +extern const nvme_version_t *nvme_ctrl_info_version(nvme_ctrl_info_t *); +extern const char *nvme_ctrl_info_model(nvme_ctrl_info_t *); +extern const char *nvme_ctrl_info_serial(nvme_ctrl_info_t *); +extern uint32_t nvme_ctrl_info_fwgran(nvme_ctrl_info_t *); +extern const char *nvme_ctrl_info_fwrev(nvme_ctrl_info_t *); +extern uint32_t nvme_ctrl_info_nns(nvme_ctrl_info_t *); + +typedef enum { + NVME_CTRL_TRANSPORT_PCI, + NVME_CTRL_TRANSPORT_TCP, + NVME_CTRL_TRANSPORT_RDMA, +} nvme_ctrl_transport_t; + +typedef enum { + NVME_CTRL_TYPE_UNKNOWN, + NVME_CTRL_TYPE_IO, + NVME_CTRL_TYPE_ADMIN, + NVME_CTRL_TYPE_DISCOVERY, +} nvme_ctrl_type_t; + +/* + * Controller types were explicitly added in the NVMe 1.4 specification. Prior + * to that all controllers were required to support issuing I/O, hence we return + * them as NVME_CTRL_TYPE_IO, even though this isn't quite by the spec. In 1.4 + * this was added to the identify controller information. The 'UNKNOWN' type is + * for cases where we don't recognize the value based upon the standard. + */ +extern nvme_ctrl_type_t nvme_ctrl_info_type(nvme_ctrl_info_t *); +extern nvme_ctrl_transport_t nvme_ctrl_info_transport(nvme_ctrl_info_t *); + +/* + * The following pieces of information are specific to PCI NVMe controllers and + * are not from the common identify controller data structure. As such they are + * fallible. The first group come from configuration space while the others are + * information that comes from the actual controller capability registers. + */ +extern bool nvme_ctrl_info_pci_vid(nvme_ctrl_info_t *, uint16_t *); +extern bool nvme_ctrl_info_pci_did(nvme_ctrl_info_t *, uint16_t *); +extern bool nvme_ctrl_info_pci_rev(nvme_ctrl_info_t *, uint8_t *); +extern bool nvme_ctrl_info_pci_subvid(nvme_ctrl_info_t *, uint16_t *); +extern bool nvme_ctrl_info_pci_subsys(nvme_ctrl_info_t *, uint16_t *); + +extern bool nvme_ctrl_info_pci_mps_min(nvme_ctrl_info_t *, uint32_t *); +extern bool nvme_ctrl_info_pci_mps_max(nvme_ctrl_info_t *, uint32_t *); + +extern bool nvme_ctrl_info_pci_nintrs(nvme_ctrl_info_t *, uint32_t *); + +/* + * These three items are only present if the device supports Namespace + * Management. + */ +extern bool nvme_ctrl_info_cap(nvme_ctrl_info_t *, nvme_uint128_t *); +extern bool nvme_ctrl_info_unalloc_cap(nvme_ctrl_info_t *, nvme_uint128_t *); +extern bool nvme_ctrl_info_common_ns(nvme_ctrl_info_t *, + const nvme_identify_nsid_t **); + +/* + * The following information is specific to the NVM command set for controllers. + */ +extern uint32_t nvme_ctrl_info_nformats(nvme_ctrl_info_t *); +extern bool nvme_ctrl_info_format(nvme_ctrl_info_t *, uint32_t, + const nvme_nvm_lba_fmt_t **); +extern uint32_t nvme_nvm_lba_fmt_id(const nvme_nvm_lba_fmt_t *); +extern uint32_t nvme_nvm_lba_fmt_meta_size(const nvme_nvm_lba_fmt_t *); +extern uint64_t nvme_nvm_lba_fmt_data_size(const nvme_nvm_lba_fmt_t *); +extern uint32_t nvme_nvm_lba_fmt_rel_perf(const nvme_nvm_lba_fmt_t *); + +/* + * Identify Operations + * + * The basic controller and namespace identify operations are a part of the + * controller and namespace snapshot facilities. These functions are designed to + * help enumerate and iterate lists of active and inactive namespaces, + * controllers, and related. The initial interface is a basic form that allows + * folks to create a request based on one that the library knows about as the + * kernel doesn't allow unknown requests. + * + * Eventually, when the kernel allows for arbitrary identify commands to be + * issued we can add an nvme_id_req_init() and the ability to set the CSI and + * CNS. + */ +extern bool nvme_id_req_init_by_cns(nvme_ctrl_t *, nvme_csi_t, uint32_t, + nvme_id_req_t **); +extern void nvme_id_req_fini(nvme_id_req_t *); + +extern bool nvme_id_req_set_nsid(nvme_id_req_t *, uint32_t); +extern bool nvme_id_req_set_ctrlid(nvme_id_req_t *, uint32_t); +extern bool nvme_id_req_set_output(nvme_id_req_t *, void *, size_t); +extern bool nvme_id_req_clear_output(nvme_id_req_t *); +extern bool nvme_id_req_exec(nvme_id_req_t *); + +/* + * NVMe Namespace Discovery + * + * Namespaces come in various states. While the controller has a list of + * namespace IDs. The following enumeration describes namespace information with + * increasing specificity. + */ +typedef enum { + /* + * This returns all namespaces that are present on the device. This + * includes ones that may be ignored by the kernel or more. + */ + NVME_NS_DISC_F_ALL = 0, + /* + * Only return namespaces that the controller considers to be allocated. + */ + NVME_NS_DISC_F_ALLOCATED, + /* + * Only return namespaces that are active. If the controller does not + * support namespace management then all namespaces are considered + * active. + */ + NVME_NS_DISC_F_ACTIVE, + /* + * The kernel has a notion of a namespace is ignored or not. In general, + * this is a subset of active namespaces that can actually be supported. + * They may or may not have a blkdev instance attached. + */ + NVME_NS_DISC_F_NOT_IGNORED, + /* + * Only return namespaces that have blkdev actively attached. In other + * words these are disks that the OS can use. + */ + NVME_NS_DISC_F_BLKDEV +} nvme_ns_disc_level_t; + +typedef enum nvme_ns_disc_flags { + NVME_NS_DISC_F_EUI64_VALID = 1 << 0, + NVME_NS_DISC_F_NGUID_VALID = 1 << 1 +} nvme_ns_disc_flags_t; + +extern uint32_t nvme_ns_disc_nsid(const nvme_ns_disc_t *); +extern nvme_ns_disc_level_t nvme_ns_disc_level(const nvme_ns_disc_t *); +extern nvme_ns_disc_flags_t nvme_ns_disc_flags(const nvme_ns_disc_t *); +extern const uint8_t *nvme_ns_disc_eui64(const nvme_ns_disc_t *); +extern const uint8_t *nvme_ns_disc_nguid(const nvme_ns_disc_t *); + +extern bool nvme_ns_discover_init(nvme_ctrl_t *, nvme_ns_disc_level_t, + nvme_ns_iter_t **); +extern nvme_iter_t nvme_ns_discover_step(nvme_ns_iter_t *, + const nvme_ns_disc_t **); +extern void nvme_ns_discover_fini(nvme_ns_iter_t *); + +typedef bool (*nvme_ns_disc_f)(nvme_ctrl_t *, const nvme_ns_disc_t *, void *); +extern bool nvme_ns_discover(nvme_ctrl_t *, nvme_ns_disc_level_t, + nvme_ns_disc_f, void *); + +extern bool nvme_ns_init(nvme_ctrl_t *, uint32_t, nvme_ns_t **); +extern bool nvme_ns_init_by_name(nvme_ctrl_t *, const char *, nvme_ns_t **); +extern void nvme_ns_fini(nvme_ns_t *); + +/* + * This is a convenience routine for opening up an NVMe controller and/or + * namespace. Many utilities refer to things as /. As + * such, this will parse that apart. If no namespace is specified, it will be + * left as NULL. If the specified controller or namespace cannot be found, then + * the function will fail. + * + * Currently the only supported controller name is nvmeX, though we should + * support GUIDs at some point. The namespace id, EUI64, and NGUID are all + * supported for the namespace. + */ +extern bool nvme_ctrl_ns_init(nvme_t *, const char *, nvme_ctrl_t **, + nvme_ns_t **); + +/* + * NVMe Namespace Information. + * + * Namespace information is broken into a few groups. There is basic information + * about the LBA formats and capacities (which are provided in block sizes). + * There is information about the IDs. Note the NGUID/EUI64 are fallible + * because they are optional. + */ +extern bool nvme_ns_info_snap(nvme_ns_t *, nvme_ns_info_t **); +extern bool nvme_ctrl_ns_info_snap(nvme_ctrl_t *, uint32_t, nvme_ns_info_t **); +extern void nvme_ns_info_free(nvme_ns_info_t *); + +extern nvme_info_err_t nvme_ns_info_err(nvme_ns_info_t *); +extern int32_t nvme_ns_info_syserr(nvme_ns_info_t *); +extern const char *nvme_ns_info_errmsg(nvme_ns_info_t *); +extern size_t nvme_ns_info_errlen(nvme_ns_info_t *); +extern const char *nvme_ns_info_errtostr(nvme_ns_info_t *, nvme_info_err_t); + +extern uint32_t nvme_ns_info_nsid(nvme_ns_info_t *); +extern nvme_ns_disc_level_t nvme_ns_info_level(nvme_ns_info_t *); +extern const nvme_identify_nsid_t *nvme_ns_info_identify(nvme_ns_info_t *); + +extern bool nvme_ns_info_nguid(nvme_ns_info_t *, uint8_t [16]); +extern bool nvme_ns_info_eui64(nvme_ns_info_t *, uint8_t [8]); + +extern bool nvme_ns_info_size(nvme_ns_info_t *, uint64_t *); +extern bool nvme_ns_info_cap(nvme_ns_info_t *, uint64_t *); +extern bool nvme_ns_info_use(nvme_ns_info_t *, uint64_t *); + +extern bool nvme_ns_info_curformat(nvme_ns_info_t *, + const nvme_nvm_lba_fmt_t **); +extern bool nvme_ns_info_nformats(nvme_ns_info_t *, uint32_t *); +extern bool nvme_ns_info_format(nvme_ns_info_t *, uint32_t, + const nvme_nvm_lba_fmt_t **); + +extern bool nvme_ns_info_bd_addr(nvme_ns_info_t *, const char **); + +/* + * Controller and Namespace Locking + * + * A given controller can be active by several different parallel consumers. + */ +extern bool nvme_ctrl_lock(nvme_ctrl_t *, nvme_lock_level_t, nvme_lock_flags_t); +extern void nvme_ctrl_unlock(nvme_ctrl_t *); +extern bool nvme_ns_lock(nvme_ns_t *, nvme_lock_level_t, nvme_lock_flags_t); +extern void nvme_ns_unlock(nvme_ns_t *); + +/* + * Namespace Attach and Detach + * + * These operations are used to attach and detach a blkdev device from a given + * namespace. + */ +extern bool nvme_ns_bd_attach(nvme_ns_t *); +extern bool nvme_ns_bd_detach(nvme_ns_t *); + +/* + * NVMe Log Page Discovery + * + * NVMe Log Pages provide some complications around discovery. There are + * standard log pages, which are either mandatory or optional. There are also + * vendor-specific log pages that we may know about. While NVMe 2.0 introduced a + * way to list all of the supported log pages a device implements, that is not + * true for most devices. Pre 2.x devices sometimes have a vendor-specific way + * to list all the available logs. The NVMe 2.0 based mechanism also does not + * provide a means of getting additional information such as required fields, so + * we'll end up always needing the additional information this interface + * provides. + * + * The log page discovery functions here allow a caller to just ask for all the + * known IDs that exist for something. The discovery callback will fire once for + * each log page that may be implemented. Log pages we know that aren't + * implemented are never called back for. + */ +extern const char *nvme_log_disc_name(const nvme_log_disc_t *); +extern const char *nvme_log_disc_desc(const nvme_log_disc_t *); +extern nvme_csi_t nvme_log_disc_csi(const nvme_log_disc_t *); +extern uint32_t nvme_log_disc_lid(const nvme_log_disc_t *); +extern nvme_log_disc_kind_t nvme_log_disc_kind(const nvme_log_disc_t *); +extern nvme_log_disc_source_t nvme_log_disc_sources(const nvme_log_disc_t *); +extern nvme_log_disc_fields_t nvme_log_disc_fields(const nvme_log_disc_t *); +extern nvme_log_disc_scope_t nvme_log_disc_scopes(const nvme_log_disc_t *); +extern bool nvme_log_disc_impl(const nvme_log_disc_t *); + +typedef enum { + /* + * This indicates that the size of a log page is unknown. Instead, we + * will return a size that is reasonable enough to hopefully cover most + * things. + */ + NVME_LOG_SIZE_K_UNKNOWN = 0, + /* + * This indicates that there is a known fixed size for the log page and + * we have indicated what that is. + */ + NVME_LOG_SIZE_K_FIXED, + /* + * This indicates that the total log size is variable; however, it can + * be determined by reading the specified following number of bytes. + * Once that number of bytes has been read, that can be passed to the + * nvme_log_disc_cal_size() function, which will attempt to determine + * the actual number of bytes based on the returned data. + */ + NVME_LOG_SIZE_K_VAR +} nvme_log_size_kind_t; +extern nvme_log_size_kind_t nvme_log_disc_size(const nvme_log_disc_t *, + uint64_t *); +extern bool nvme_log_disc_calc_size(const nvme_log_disc_t *, uint64_t *, + const void *, size_t); + +/* + * Duplicate and free log discovery information. The free function should only + * be used when it is explicitly duplicated or obtained through something like + * nvme_log_req_init_by_name(). It must not be used on the constant data + * provided as part of the nvme_log_discover family of functions. + */ +extern bool nvme_log_disc_dup(nvme_ctrl_t *, const nvme_log_disc_t *, + nvme_log_disc_t **); +extern void nvme_log_disc_free(nvme_log_disc_t *); + +extern bool nvme_log_discover_init(nvme_ctrl_t *, nvme_log_disc_scope_t, + uint32_t, nvme_log_iter_t **); +extern nvme_iter_t nvme_log_discover_step(nvme_log_iter_t *, + const nvme_log_disc_t **); +extern void nvme_log_discover_fini(nvme_log_iter_t *); + +typedef bool (*nvme_log_disc_f)(nvme_ctrl_t *, const nvme_log_disc_t *, + void *); +extern bool nvme_log_discover(nvme_ctrl_t *, nvme_log_disc_scope_t, + uint32_t, nvme_log_disc_f, void *); + +/* + * One does not simply request a log page. There are a lot of parameters that + * are used to get a log page and these have been evolving over time. For + * example, the size has changed between 1.2 and 1.3, NVMe 1.0 never had UUIDs, + * LSP, LSIs, there are optional features around supporting offsets, etc. + * + * To deal with the fact that this keeps changing and an attempt to create a + * stable ABI, we instead have an opaque structure that allows various fields to + * be set and changed. To speed this up, this can be bootstrapped from the + * discovery information directly or indirectly by the log page short name. + * + * Once all of the appropriate fields are set on a log page request then it can + * be executed. A given request may be executed multiple times. + * + * When creating a raw log request, it will be up to the caller to fill in and + * set up the log ID (lid) and the output information. It is assumed that by + * default a log request should specify the NVM CSI. When using + * nvme_log_req_init_by_disc(), the log ID and command set will be filled in + * automatically. The discovery flags will indicate what other fields are still + * required. + */ +extern bool nvme_log_req_init(nvme_ctrl_t *, nvme_log_req_t **); +extern bool nvme_log_req_init_by_disc(nvme_ctrl_t *, const nvme_log_disc_t *, + nvme_log_req_t **); +extern bool nvme_log_req_init_by_name(nvme_ctrl_t *, const char *, + uint32_t, nvme_log_disc_t **, nvme_log_req_t **); +extern void nvme_log_req_fini(nvme_log_req_t *); + +extern bool nvme_log_req_set_lid(nvme_log_req_t *, uint32_t); +extern bool nvme_log_req_set_lsp(nvme_log_req_t *, uint32_t); +extern bool nvme_log_req_set_lsi(nvme_log_req_t *, uint32_t); +extern bool nvme_log_req_set_uuid(nvme_log_req_t *, uint32_t); +extern bool nvme_log_req_set_nsid(nvme_log_req_t *, uint32_t); +extern bool nvme_log_req_set_output(nvme_log_req_t *, void *, size_t); +extern bool nvme_log_req_clear_output(nvme_log_req_t *); +extern bool nvme_log_req_set_offset(nvme_log_req_t *, uint64_t); +extern bool nvme_log_req_set_rae(nvme_log_req_t *, bool); +extern bool nvme_log_req_set_csi(nvme_log_req_t *, nvme_csi_t); +extern bool nvme_log_req_exec(nvme_log_req_t *); + +/* + * Feature Discovery and Management + * + * Features are parts of the NVMe specification that can both be retrieved and + * set. Features are often either a uint32_t or a larger data payload. In + * addition, there are additional modifiers that are required to select + * information about features. For example, when getting or setting a + * temperature threshold feature, a temperature sensor ID is required. Much like + * with log pages this has changed and added new arguments to getting and + * setting a feature at the command level and the individual features have grown + * support for more configuration as well. + * + * We currently provide information in discovery to determine what is required + * to get a feature as well as the ability to fast path that. Currently we + * provide the raw feature getting API that works at the low level. There is no + * higher level API for specific features. This works okay for an nvmeadm(8) + * style implementation, but we should consider adding more here based on + * feedback from consumers. + * + * Currently the kernel does not support setting features, which is why there is + * not a set feature API exposed through here. When it is, there will be an + * analogues set feature API to the get feature API that allows for one to + * build this up generically. + */ +extern const char *nvme_feat_disc_short(const nvme_feat_disc_t *); +extern const char *nvme_feat_disc_spec(const nvme_feat_disc_t *); +extern uint32_t nvme_feat_disc_fid(const nvme_feat_disc_t *); +extern nvme_feat_scope_t nvme_feat_disc_scope(const nvme_feat_disc_t *); +extern nvme_feat_kind_t nvme_feat_disc_kind(const nvme_feat_disc_t *); +extern nvme_feat_csi_t nvme_feat_disc_csi(const nvme_feat_disc_t *); +extern nvme_feat_flags_t nvme_feat_disc_flags(const nvme_feat_disc_t *); +extern nvme_get_feat_fields_t nvme_feat_disc_fields_get( + const nvme_feat_disc_t *); +extern nvme_set_feat_fields_t nvme_feat_disc_fields_set( + const nvme_feat_disc_t *); +extern nvme_feat_output_t nvme_feat_disc_output_get(const nvme_feat_disc_t *); +extern nvme_feat_output_t nvme_feat_disc_output_set(const nvme_feat_disc_t *); +extern uint64_t nvme_feat_disc_data_size(const nvme_feat_disc_t *); +extern nvme_feat_impl_t nvme_feat_disc_impl(const nvme_feat_disc_t *); + +extern bool nvme_feat_discover_init(nvme_ctrl_t *, nvme_feat_scope_t, uint32_t, + nvme_feat_iter_t **); +extern nvme_iter_t nvme_feat_discover_step(nvme_feat_iter_t *, + const nvme_feat_disc_t **); +extern void nvme_feat_discover_fini(nvme_feat_iter_t *); + +extern bool nvme_feat_disc_dup(nvme_ctrl_t *, const nvme_feat_disc_t *, + nvme_feat_disc_t **); +extern void nvme_feat_disc_free(nvme_feat_disc_t *); + +typedef bool (*nvme_feat_disc_f)(nvme_ctrl_t *, const nvme_feat_disc_t *, + void *); +extern bool nvme_feat_discover(nvme_ctrl_t *, nvme_feat_scope_t, uint32_t, + nvme_feat_disc_f, void *); + +/* + * Get Feature Request + * + * The get feature request allows one to build up a get feature command. It is + * recommended to initiate a request based on discovery information or a + * feature's name. That will allow the system to perform better validation, know + * what fields are required or not, and pre-set parameters like the feature id + * (fid). By default, a get features request will always ask for the current + * value. Unless you want a saved or default value (and the controller is new + * enough), then there is no need to set the selector. The only required field + * when not using discovery information is the fid. + */ +extern bool nvme_get_feat_req_init(nvme_ctrl_t *, nvme_get_feat_req_t **); +extern bool nvme_get_feat_req_init_by_disc(nvme_ctrl_t *, + const nvme_feat_disc_t *, nvme_get_feat_req_t **); +extern bool nvme_get_feat_req_init_by_name(nvme_ctrl_t *, const char *, + uint32_t, nvme_feat_disc_t **, nvme_get_feat_req_t **); +extern void nvme_get_feat_req_fini(nvme_get_feat_req_t *); + +extern bool nvme_get_feat_req_set_fid(nvme_get_feat_req_t *, uint32_t); +extern bool nvme_get_feat_req_set_sel(nvme_get_feat_req_t *, uint32_t); +extern bool nvme_get_feat_req_set_nsid(nvme_get_feat_req_t *, uint32_t); +extern bool nvme_get_feat_req_set_cdw11(nvme_get_feat_req_t *, uint32_t); +extern bool nvme_get_feat_req_set_output(nvme_get_feat_req_t *, void *, size_t); +extern bool nvme_get_feat_req_clear_output(nvme_get_feat_req_t *); +extern bool nvme_get_feat_req_exec(nvme_get_feat_req_t *); +extern bool nvme_get_feat_req_get_cdw0(nvme_get_feat_req_t *, uint32_t *); + +/* + * NVMe Vendor Unique Command Discovery and Execution + * + * There is a standard form of vendor unique commands which are indicated in the + * identify controller datasheet. The first set of pieces here allows one to + * discover which vendor-specific commands are supported by a device that are + * known to the library. These generally have their own implementation + * function; however, that isn't really linked to from the discovery function. + * Tied into this is also asking if a given controller supports a given command + * and getting information about it. + * + * The second set of functions here is all around allocating a vendor unique + * command then executing it. Currently only admin commands are supported + * through this interface. + */ +extern bool nvme_vuc_discover_init(nvme_ctrl_t *, uint32_t, + nvme_vuc_iter_t **); +extern nvme_iter_t nvme_vuc_discover_step(nvme_vuc_iter_t *, + const nvme_vuc_disc_t **); +extern void nvme_vuc_discover_fini(nvme_vuc_iter_t *); + +typedef bool (*nvme_vuc_disc_f)(nvme_ctrl_t *, const nvme_vuc_disc_t *, void *); +extern bool nvme_vuc_discover(nvme_ctrl_t *, uint32_t, nvme_vuc_disc_f, void *); + +extern bool nvme_vuc_discover_by_name(nvme_ctrl_t *, const char *, uint32_t, + nvme_vuc_disc_t **); +extern bool nvme_vuc_disc_dup(nvme_ctrl_t *, const nvme_vuc_disc_t *, + nvme_vuc_disc_t **); +extern void nvme_vuc_disc_free(nvme_vuc_disc_t *); + +extern const char *nvme_vuc_disc_name(const nvme_vuc_disc_t *); +extern const char *nvme_vuc_disc_desc(const nvme_vuc_disc_t *); +extern uint32_t nvme_vuc_disc_opcode(const nvme_vuc_disc_t *); + +typedef enum { + /* + * Indicates that when this command is run, one should assume that all + * data is potentially erased. + */ + NVME_VUC_DISC_IMPACT_DATA = 1 << 0, + /* + * Indicates that when this command is run, one should assume that the + * list of namespaces and their attributes will change. + */ + NVME_VUC_DISC_IMPACT_NS = 1 << 1 +} nvme_vuc_disc_impact_t; +extern nvme_vuc_disc_impact_t nvme_vuc_disc_impact(const nvme_vuc_disc_t *); + +typedef enum { + NVME_VUC_DISC_IO_NONE = 0, + /* + * Indicates that this command needs additional data provided as input + * to the command. + */ + NVME_VUC_DISC_IO_INPUT = 1 << 0, + /* + * Indicates that this command writes output back to the host from the + * controller and a data buffer is required. + */ + NVME_VUC_DISC_IO_OUTPUT = 1 << 1 +} nvme_vuc_disc_io_t; +extern nvme_vuc_disc_io_t nvme_vuc_disc_dt(const nvme_vuc_disc_t *); + +typedef enum { + /* + * Indicates that the library has no opinion on whether a lock should be + * taken or not. + */ + NVME_VUC_DISC_LOCK_NONE = 0, + /* + * Indicates that a controller or namespace level read lock is + * recommended for this operation. + */ + NVME_VUC_DISC_LOCK_READ, + /* + * Indicates that a controller or namespace level write lock is + * recommended for this operation. + */ + NVME_VUC_DISC_LOCK_WRITE +} nvme_vuc_disc_lock_t; +extern nvme_vuc_disc_lock_t nvme_vuc_disc_lock(const nvme_vuc_disc_t *); + +extern bool nvme_vuc_req_init(nvme_ctrl_t *, nvme_vuc_req_t **); +extern void nvme_vuc_req_fini(nvme_vuc_req_t *); + +extern bool nvme_vuc_req_set_opcode(nvme_vuc_req_t *, uint32_t); +extern bool nvme_vuc_req_set_nsid(nvme_vuc_req_t *, uint32_t); +extern bool nvme_vuc_req_set_timeout(nvme_vuc_req_t *, uint32_t); +extern bool nvme_vuc_req_set_cdw12(nvme_vuc_req_t *, uint32_t); +extern bool nvme_vuc_req_set_cdw13(nvme_vuc_req_t *, uint32_t); +extern bool nvme_vuc_req_set_cdw14(nvme_vuc_req_t *, uint32_t); +extern bool nvme_vuc_req_set_cdw15(nvme_vuc_req_t *, uint32_t); +extern bool nvme_vuc_req_set_impact(nvme_vuc_req_t *, nvme_vuc_disc_impact_t); +extern bool nvme_vuc_req_set_input(nvme_vuc_req_t *, const void *, size_t); +extern bool nvme_vuc_req_set_output(nvme_vuc_req_t *, void *, size_t); +extern bool nvme_vuc_req_clear_output(nvme_vuc_req_t *); + +/* + * Execute a request. After a request is executed, the status information + * becomes available. A call to exec will invalidate any prior results. If the + * request does not make it to the controller for some reason or some other + * error occurs, then getting the results will fail. If the controller fails the + * command, that will set the NVME_ERR_CONTROLLER error and the corresponding + * SCT/SC values can be retrieved from the controller's error information for + * inspection. + */ +extern bool nvme_vuc_req_exec(nvme_vuc_req_t *); +extern bool nvme_vuc_req_get_cdw0(nvme_vuc_req_t *, uint32_t *); + +/* + * Firmware Download and Commit (Activation) + * + * NVMe devices have a buffer that is used to receive a firmware download. This + * can then be committed into a firmware slot or a boot slot through the commit + * action. The commit action may also change which firmware slot is activated on + * the next boot at the same time as installing an image or a commit can be used + * to just change the active image. The optional bootloader features will have a + * similar shape as to the firmware commit routines, but ultimately be different + * ones to make it more obvious what is being done. + * + * The firmware download command has to date not really changed through the NVMe + * 1.x and 2.0 standards, which is why it is not broken into a request and + * execution format like others at this time. + * + * Firmware must be loaded with a particular granularity and if blocks do not + * conform to that, nvme_fw_load() will return an error. + */ +extern bool nvme_fw_load(nvme_ctrl_t *, const void *, size_t, uint64_t); + +extern bool nvme_fw_commit_req_init(nvme_ctrl_t *, nvme_fw_commit_req_t **); +extern void nvme_fw_commit_req_fini(nvme_fw_commit_req_t *); +extern bool nvme_fw_commit_req_set_slot(nvme_fw_commit_req_t *, uint32_t); +extern bool nvme_fw_commit_req_set_action(nvme_fw_commit_req_t *, uint32_t); +extern bool nvme_fw_commit_req_exec(nvme_fw_commit_req_t *); + +/* + * Format NVM + * + * This is used to erase and reformat either all namespaces or a specific one. + * We currently do not support setting metadata or protection information for + * namespaces in the kernel which is why this is not present in the library. + */ +extern bool nvme_format_req_init(nvme_ctrl_t *, nvme_format_req_t **); +extern void nvme_format_req_fini(nvme_format_req_t *); +extern bool nvme_format_req_set_lbaf(nvme_format_req_t *, uint32_t); +extern bool nvme_format_req_set_ses(nvme_format_req_t *, uint32_t); +extern bool nvme_format_req_set_nsid(nvme_format_req_t *, uint32_t); +extern bool nvme_format_req_exec(nvme_format_req_t *); + +/* + * NVMe Namespace Attach + * + * This is used to attach or detach a collection of controllers to a namespace. + * Currently the only way to specify a controller is to use the self flag on + * here. In the future, we will likely have support for listing the explicit + * controllers to specify here. + */ +extern bool nvme_ns_attach_req_init_by_sel(nvme_ctrl_t *, uint32_t, + nvme_ns_attach_req_t **); +extern void nvme_ns_attach_req_fini(nvme_ns_attach_req_t *); +extern bool nvme_ns_attach_req_set_nsid(nvme_ns_attach_req_t *, uint32_t); +extern bool nvme_ns_attach_req_set_ctrlid_self(nvme_ns_attach_req_t *); +extern bool nvme_ns_attach_req_exec(nvme_ns_attach_req_t *); + +/* + * NVMe Namesapce Create and Delete + */ +extern bool nvme_ns_create_req_init_by_csi(nvme_ctrl_t *, nvme_csi_t, + nvme_ns_create_req_t **); +extern void nvme_ns_create_req_fini(nvme_ns_create_req_t *); +extern bool nvme_ns_create_req_set_flbas(nvme_ns_create_req_t *, uint32_t); +extern bool nvme_ns_create_req_set_nsze(nvme_ns_create_req_t *, uint64_t); +extern bool nvme_ns_create_req_set_ncap(nvme_ns_create_req_t *, uint64_t); +extern bool nvme_ns_create_req_set_nmic(nvme_ns_create_req_t *, uint32_t); +extern bool nvme_ns_create_req_exec(nvme_ns_create_req_t *); +extern bool nvme_ns_create_req_get_nsid(nvme_ns_create_req_t *, uint32_t *); + +extern bool nvme_ns_delete_req_init(nvme_ctrl_t *, nvme_ns_delete_req_t **); +extern void nvme_ns_delete_req_fini(nvme_ns_delete_req_t *); +extern bool nvme_ns_delete_req_set_nsid(nvme_ns_delete_req_t *, uint32_t); +extern bool nvme_ns_delete_req_exec(nvme_ns_delete_req_t *); + +/* + * Vendor-specific interfaces. + */ + +/* + * WDC resizing functions. These are interfaces supported in the SN840, SN650, + * SN655, etc. These end up allowing one to adjust the overprovisioning ratio, + * though this ends up reformatting the device and all namespaces in the + * process. The values passed and returned are in GB (not GiB). + */ +extern bool nvme_wdc_resize_set(nvme_ctrl_t *, uint32_t); +extern bool nvme_wdc_resize_get(nvme_ctrl_t *, uint32_t *); + +/* + * WDC e6 diagnostic log. The e6 log is a WDC-specific diagnostic log which + * contains information about the device itself. + */ +extern bool nvme_wdc_e6_req_init(nvme_ctrl_t *, nvme_wdc_e6_req_t **); +extern void nvme_wdc_e6_req_fini(nvme_wdc_e6_req_t *); +extern bool nvme_wdc_e6_req_set_offset(nvme_wdc_e6_req_t *, uint64_t); +extern bool nvme_wdc_e6_req_set_output(nvme_wdc_e6_req_t *, void *, + size_t); +extern bool nvme_wdc_e6_req_clear_output(nvme_wdc_e6_req_t *); +extern bool nvme_wdc_e6_req_exec(nvme_wdc_e6_req_t *); + +/* + * WDC assert injection and removal. + */ +extern bool nvme_wdc_assert_clear(nvme_ctrl_t *); +extern bool nvme_wdc_assert_inject(nvme_ctrl_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBNVME_H */ diff --git a/illumos-x86_64/usr/include/libnvpair.h b/illumos-x86_64/usr/include/libnvpair.h new file mode 100644 index 00000000..197ec37f --- /dev/null +++ b/illumos-x86_64/usr/include/libnvpair.h @@ -0,0 +1,198 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +#ifndef _LIBNVPAIR_H +#define _LIBNVPAIR_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * All interfaces described in this file are private to Solaris, and + * are subject to change at any time and without notice. The public + * nvlist/nvpair interfaces, as documented in manpage sections 3NVPAIR, + * are all imported from included above. + */ + +extern int nvpair_value_match(nvpair_t *, int, char *, char **); +extern int nvpair_value_match_regex(nvpair_t *, int, char *, regex_t *, + char **); + +extern void nvlist_print(FILE *, nvlist_t *); +extern int nvlist_print_json(FILE *, nvlist_t *); +extern void dump_nvlist(nvlist_t *, int); +extern int nvlist_dump_json(nvlist_t *, char **); +extern void nvlist_dump_json_free(nvlist_t *, char *); + +/* + * Private nvlist printing interface that allows the caller some control + * over output rendering (as opposed to nvlist_print and dump_nvlist). + * + * Obtain an opaque nvlist_prtctl_t cookie using nvlist_prtctl_alloc + * (NULL on failure); on return the cookie is set up for default formatting + * and rendering. Quote the cookie in subsequent customisation functions and + * then pass the cookie to nvlist_prt to render the nvlist. Finally, + * use nvlist_prtctl_free to release the cookie. + * + * For all nvlist_lookup_xxx and nvlist_lookup_xxx_array functions + * we have a corresponding brace of functions that appoint replacement + * rendering functions: + * + * extern void nvlist_prtctl_xxx(nvlist_prtctl_t, + * void (*)(nvlist_prtctl_t ctl, void *private, const char *name, + * xxxtype value)) + * + * and + * + * extern void nvlist_prtctl_xxx_array(nvlist_prtctl_t, + * void (*)(nvlist_prtctl_t ctl, void *private, const char *name, + * xxxtype value, uint_t count)) + * + * where xxxtype is the C datatype corresponding to xxx, eg int8_t for "int8" + * and char * for "string". The function that is appointed to render the + * specified datatype receives as arguments the cookie, the nvlist + * member name, the value of that member (or a pointer for array function), + * and (for array rendering functions) a count of the number of elements. + */ + +typedef struct nvlist_prtctl *nvlist_prtctl_t; /* opaque */ + +enum nvlist_indent_mode { + NVLIST_INDENT_ABS, /* Absolute indentation */ + NVLIST_INDENT_TABBED /* Indent with tabstops */ +}; + +extern nvlist_prtctl_t nvlist_prtctl_alloc(void); +extern void nvlist_prtctl_free(nvlist_prtctl_t); +extern void nvlist_prt(nvlist_t *, nvlist_prtctl_t); + +/* Output stream */ +extern void nvlist_prtctl_setdest(nvlist_prtctl_t, FILE *); +extern FILE *nvlist_prtctl_getdest(nvlist_prtctl_t); + +/* Indentation mode, start indent, indent increment; default tabbed/0/1 */ +extern void nvlist_prtctl_setindent(nvlist_prtctl_t, enum nvlist_indent_mode, + int, int); +extern void nvlist_prtctl_doindent(nvlist_prtctl_t, int); + +enum nvlist_prtctl_fmt { + NVLIST_FMT_MEMBER_NAME, /* name fmt; default "%s = " */ + NVLIST_FMT_MEMBER_POSTAMBLE, /* after nvlist member; default "\n" */ + NVLIST_FMT_BTWN_ARRAY /* between array members; default " " */ +}; + +extern void nvlist_prtctl_setfmt(nvlist_prtctl_t, enum nvlist_prtctl_fmt, + const char *); +extern void nvlist_prtctl_dofmt(nvlist_prtctl_t, enum nvlist_prtctl_fmt, ...); + +/* + * Function prototypes for interfaces that appoint a new rendering function + * for single-valued nvlist members. + * + * A replacement function receives arguments as follows: + * + * nvlist_prtctl_t Print control structure; do not change preferences + * for this object from a print callback function. + * + * void * The function-private cookie argument registered + * when the replacement function was appointed. + * + * nvlist_t * The full nvlist that is being processed. The + * rendering function is called to render a single + * member (name and value passed as below) but it may + * want to reference or incorporate other aspects of + * the full nvlist. + * + * const char * Member name to render + * + * valtype Value of the member to render + * + * The function must return non-zero if it has rendered output for this + * member, or 0 if it wants to default to standard rendering for this + * one member. + */ + +#define NVLIST_PRINTCTL_SVDECL(funcname, valtype) \ + extern void funcname(nvlist_prtctl_t, \ + int (*)(nvlist_prtctl_t, void *, nvlist_t *, const char *, valtype), \ + void *) + +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_boolean, int); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_boolean_value, boolean_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_byte, uchar_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int8, int8_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint8, uint8_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int16, int16_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint16, uint16_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int32, int32_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint32, uint32_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int64, int64_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint64, uint64_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_double, double); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_string, char *); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_hrtime, hrtime_t); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_nvlist, nvlist_t *); + +#undef NVLIST_PRINTCTL_SVDECL /* was just for "clarity" above */ + +/* + * Function prototypes for interfaces that appoint a new rendering function + * for array-valued nvlist members. + * + * One additional argument is taken: uint_t for the number of array elements + * + * Return values as above. + */ +#define NVLIST_PRINTCTL_AVDECL(funcname, vtype) \ + extern void funcname(nvlist_prtctl_t, \ + int (*)(nvlist_prtctl_t, void *, nvlist_t *, const char *, vtype, uint_t), \ + void *) + +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_boolean_array, boolean_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_byte_array, uchar_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int8_array, int8_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint8_array, uint8_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int16_array, int16_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint16_array, uint16_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int32_array, int32_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint32_array, uint32_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int64_array, int64_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint64_array, uint64_t *); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_string_array, char **); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_nvlist_array, nvlist_t **); + +#undef NVLIST_PRINTCTL_AVDECL /* was just for "clarity" above */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBNVPAIR_H */ diff --git a/illumos-x86_64/usr/include/libnwam.h b/illumos-x86_64/usr/include/libnwam.h new file mode 100644 index 00000000..26315a9a --- /dev/null +++ b/illumos-x86_64/usr/include/libnwam.h @@ -0,0 +1,1070 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Chris Fraire . + */ + +/* + * This file contains data structures and APIs of libnwam. + * Implementation is MT safe. + */ +#ifndef _LIBNWAM_H +#define _LIBNWAM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include + +/* + * Note - several interface functions below are not utilized in ON, but are + * used by the GNOME nwam-manager. One example is nwam_enm_get_name(). + */ + +/* + * Common definitions + */ + +/* nwam FMRI and properties */ +#define NWAM_FMRI "svc:/network/physical:nwam" +#define NWAM_PG "nwamd" +#define NWAM_PROP_ACTIVE_NCP "active_ncp" + +/* nwam flags used for read/commit */ +/* Block waiting for commit if necessary */ +#define NWAM_FLAG_BLOCKING 0x00000001 +/* Committed object must be new */ +#define NWAM_FLAG_CREATE 0x00000002 +/* Tell destroy functions not to free handle */ +#define NWAM_FLAG_DO_NOT_FREE 0x00000004 +/* Object is being enabled/disabled */ +#define NWAM_FLAG_ENTITY_ENABLE 0x00000008 +/* Known WLAN being read, committed or destroyed */ +#define NWAM_FLAG_ENTITY_KNOWN_WLAN 0x00000010 + +/* nwam flags used for selecting ncu type for walk */ +#define NWAM_FLAG_NCU_TYPE_LINK 0x00000001ULL << 32 +#define NWAM_FLAG_NCU_TYPE_INTERFACE 0x00000002ULL << 32 +#define NWAM_FLAG_NCU_TYPE_ALL (NWAM_FLAG_NCU_TYPE_LINK | \ + NWAM_FLAG_NCU_TYPE_INTERFACE) + +/* nwam flags used for selecting ncu class for walk */ +#define NWAM_FLAG_NCU_CLASS_PHYS 0x00000100ULL << 32 +#define NWAM_FLAG_NCU_CLASS_IP 0x00010000ULL << 32 +#define NWAM_FLAG_NCU_CLASS_ALL_LINK NWAM_FLAG_NCU_CLASS_PHYS +#define NWAM_FLAG_NCU_CLASS_ALL_INTERFACE NWAM_FLAG_NCU_CLASS_IP +#define NWAM_FLAG_NCU_CLASS_ALL (NWAM_FLAG_NCU_CLASS_ALL_INTERFACE | \ + NWAM_FLAG_NCU_CLASS_ALL_LINK) +#define NWAM_FLAG_NCU_TYPE_CLASS_ALL (NWAM_FLAG_NCU_CLASS_ALL | \ + NWAM_FLAG_NCU_TYPE_ALL) + +/* flags used for selecting activation for walk */ +#define NWAM_FLAG_ACTIVATION_MODE_MANUAL 0x000000001ULL << 32 +#define NWAM_FLAG_ACTIVATION_MODE_SYSTEM 0x000000002ULL << 32 +#define NWAM_FLAG_ACTIVATION_MODE_PRIORITIZED 0x000000004ULL << 32 +#define NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ANY 0x000000008ULL << 32 +#define NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ALL 0x000000010ULL << 32 +#define NWAM_FLAG_ACTIVATION_MODE_ALL (NWAM_FLAG_ACTIVATION_MODE_MANUAL |\ + NWAM_FLAG_ACTIVATION_MODE_SYSTEM |\ + NWAM_FLAG_ACTIVATION_MODE_PRIORITIZED |\ + NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ANY |\ + NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ALL) + +/* Walk known WLANs in order of priority (lowest first) */ +#define NWAM_FLAG_KNOWN_WLAN_WALK_PRIORITY_ORDER 0x000010000ULL << 32 +/* Do not perform priority collision checking for known WLANs */ +#define NWAM_FLAG_KNOWN_WLAN_NO_COLLISION_CHECK 0x000020000ULL << 32 + +/* nwam return codes */ +typedef enum { + NWAM_SUCCESS, /* No error occured */ + NWAM_LIST_END, /* End of list reached */ + NWAM_INVALID_HANDLE, /* Entity handle is invalid */ + NWAM_HANDLE_UNBOUND, /* Handle not bound to entity */ + NWAM_INVALID_ARG, /* Argument is invalid */ + NWAM_PERMISSION_DENIED, /* Insufficient privileges for action */ + NWAM_NO_MEMORY, /* Out of memory */ + NWAM_ENTITY_EXISTS, /* Entity already exists */ + NWAM_ENTITY_IN_USE, /* Entity in use */ + NWAM_ENTITY_COMMITTED, /* Entity already committed */ + NWAM_ENTITY_NOT_FOUND, /* Entity not found */ + NWAM_ENTITY_TYPE_MISMATCH, /* Entity type mismatch */ + NWAM_ENTITY_INVALID, /* Validation of entity failed */ + NWAM_ENTITY_INVALID_MEMBER, /* Entity member invalid */ + NWAM_ENTITY_INVALID_STATE, /* Entity is not in appropriate state */ + NWAM_ENTITY_INVALID_VALUE, /* Validation of entity value failed */ + NWAM_ENTITY_MISSING_MEMBER, /* Required member is missing */ + NWAM_ENTITY_NO_VALUE, /* No value associated with entity */ + NWAM_ENTITY_MULTIPLE_VALUES, /* Multiple values for entity */ + NWAM_ENTITY_READ_ONLY, /* Entity is marked read only */ + NWAM_ENTITY_NOT_DESTROYABLE, /* Entity cannot be destroyed */ + NWAM_ENTITY_NOT_MANUAL, /* Entity cannot be manually enabled/disabled */ + NWAM_WALK_HALTED, /* Callback function returned nonzero */ + NWAM_ERROR_BIND, /* Could not bind to backend */ + NWAM_ERROR_BACKEND_INIT, /* Could not initialize backend */ + NWAM_ERROR_INTERNAL /* Internal error */ +} nwam_error_t; + +#define NWAM_MAX_NAME_LEN 128 +#define NWAM_MAX_VALUE_LEN 256 +#define NWAM_MAX_FMRI_LEN NWAM_MAX_VALUE_LEN +#define NWAM_MAX_NUM_VALUES 32 +#define NWAM_MAX_NUM_PROPERTIES 32 + +/* used for getting and setting of properties */ +typedef enum { + NWAM_VALUE_TYPE_BOOLEAN, + NWAM_VALUE_TYPE_INT64, + NWAM_VALUE_TYPE_UINT64, + NWAM_VALUE_TYPE_STRING, + NWAM_VALUE_TYPE_UNKNOWN +} nwam_value_type_t; + +/* Holds values of various types for getting and setting of properties */ +/* Forward definition */ +struct nwam_value; +typedef struct nwam_value *nwam_value_t; + +/* Value-related functions. */ +extern nwam_error_t nwam_value_create_boolean(boolean_t, nwam_value_t *); +extern nwam_error_t nwam_value_create_boolean_array(boolean_t *, uint_t, + nwam_value_t *); +extern nwam_error_t nwam_value_create_int64(int64_t, nwam_value_t *); +extern nwam_error_t nwam_value_create_int64_array(int64_t *, uint_t, + nwam_value_t *); +extern nwam_error_t nwam_value_create_uint64(uint64_t, nwam_value_t *); +extern nwam_error_t nwam_value_create_uint64_array(uint64_t *, uint_t, + nwam_value_t *); +extern nwam_error_t nwam_value_create_string(char *, nwam_value_t *); +extern nwam_error_t nwam_value_create_string_array(char **, uint_t, + nwam_value_t *); + +extern nwam_error_t nwam_value_get_boolean(nwam_value_t, boolean_t *); +extern nwam_error_t nwam_value_get_boolean_array(nwam_value_t, boolean_t **, + uint_t *); +extern nwam_error_t nwam_value_get_int64(nwam_value_t, int64_t *); +extern nwam_error_t nwam_value_get_int64_array(nwam_value_t, int64_t **, + uint_t *); +extern nwam_error_t nwam_value_get_uint64(nwam_value_t, uint64_t *); +extern nwam_error_t nwam_value_get_uint64_array(nwam_value_t, uint64_t **, + uint_t *); +extern nwam_error_t nwam_value_get_string(nwam_value_t, char **); +extern nwam_error_t nwam_value_get_string_array(nwam_value_t, char ***, + uint_t *); + +extern nwam_error_t nwam_value_get_type(nwam_value_t, nwam_value_type_t *); +extern nwam_error_t nwam_value_get_numvalues(nwam_value_t, uint_t *); + +extern void nwam_value_free(nwam_value_t); +extern nwam_error_t nwam_value_copy(nwam_value_t, nwam_value_t *); + +extern nwam_error_t nwam_uint64_get_value_string(const char *, uint64_t, + const char **); +extern nwam_error_t nwam_value_string_get_uint64(const char *, const char *, + uint64_t *); + +/* + * To retrieve a localized error string + */ +extern const char *nwam_strerror(nwam_error_t); + +/* + * State and auxiliary state describe the state of ENMs, NCUs and locations. + */ +typedef enum { + NWAM_STATE_UNINITIALIZED = 0x0, + NWAM_STATE_INITIALIZED = 0x1, + NWAM_STATE_OFFLINE = 0x2, + NWAM_STATE_OFFLINE_TO_ONLINE = 0x4, + NWAM_STATE_ONLINE_TO_OFFLINE = 0x8, + NWAM_STATE_ONLINE = 0x10, + NWAM_STATE_MAINTENANCE = 0x20, + NWAM_STATE_DEGRADED = 0x40, + NWAM_STATE_DISABLED = 0x80 +} nwam_state_t; + +#define NWAM_STATE_ANY (NWAM_STATE_UNINITIALIZED | \ + NWAM_STATE_INITIALIZED | \ + NWAM_STATE_OFFLINE | \ + NWAM_STATE_OFFLINE_TO_ONLINE | \ + NWAM_STATE_ONLINE_TO_OFFLINE | \ + NWAM_STATE_ONLINE | \ + NWAM_STATE_MAINTENANCE | \ + NWAM_STATE_DEGRADED | \ + NWAM_STATE_DISABLED) + +/* + * The auxiliary state denotes specific reasons why an object is in a particular + * state (e.g. "script failed", "disabled by administrator", "waiting for DHCP + * response"). + */ +typedef enum { + /* General auxiliary states */ + NWAM_AUX_STATE_UNINITIALIZED, + NWAM_AUX_STATE_INITIALIZED, + NWAM_AUX_STATE_CONDITIONS_NOT_MET, + NWAM_AUX_STATE_MANUAL_DISABLE, + NWAM_AUX_STATE_METHOD_FAILED, + NWAM_AUX_STATE_METHOD_MISSING, + NWAM_AUX_STATE_METHOD_RUNNING, + NWAM_AUX_STATE_INVALID_CONFIG, + NWAM_AUX_STATE_ACTIVE, + /* Link-specific auxiliary states */ + NWAM_AUX_STATE_LINK_WIFI_SCANNING, + NWAM_AUX_STATE_LINK_WIFI_NEED_SELECTION, + NWAM_AUX_STATE_LINK_WIFI_NEED_KEY, + NWAM_AUX_STATE_LINK_WIFI_CONNECTING, + /* IP interface-specific auxiliary states */ + NWAM_AUX_STATE_IF_WAITING_FOR_ADDR, + NWAM_AUX_STATE_IF_DHCP_TIMED_OUT, + NWAM_AUX_STATE_IF_DUPLICATE_ADDR, + /* Common link/interface auxiliary states */ + NWAM_AUX_STATE_UP, + NWAM_AUX_STATE_DOWN, + NWAM_AUX_STATE_NOT_FOUND +} nwam_aux_state_t; + +/* Activation modes */ +typedef enum { + NWAM_ACTIVATION_MODE_MANUAL, + NWAM_ACTIVATION_MODE_SYSTEM, + NWAM_ACTIVATION_MODE_CONDITIONAL_ANY, + NWAM_ACTIVATION_MODE_CONDITIONAL_ALL, + NWAM_ACTIVATION_MODE_PRIORITIZED +} nwam_activation_mode_t; + +/* + * Conditions are of the form + * + * ncu|enm|loc name is|is-not active + * ip-address is|is-not|is-in-range|is-not-in-range ipaddr[/prefixlen] + * advertised-domain is|is-not|contains|does-not-contain string + * system-domain is|is-not|contains|does-not-contain string + * essid is|is-not|contains|does-not-contain string + * bssid is|is-not + */ + +typedef enum { + NWAM_CONDITION_IS, + NWAM_CONDITION_IS_NOT, + NWAM_CONDITION_IS_IN_RANGE, + NWAM_CONDITION_IS_NOT_IN_RANGE, + NWAM_CONDITION_CONTAINS, + NWAM_CONDITION_DOES_NOT_CONTAIN +} nwam_condition_t; + +typedef enum { + NWAM_CONDITION_OBJECT_TYPE_NCP, + NWAM_CONDITION_OBJECT_TYPE_NCU, + NWAM_CONDITION_OBJECT_TYPE_ENM, + NWAM_CONDITION_OBJECT_TYPE_LOC, + NWAM_CONDITION_OBJECT_TYPE_IP_ADDRESS, + NWAM_CONDITION_OBJECT_TYPE_ADV_DOMAIN, + NWAM_CONDITION_OBJECT_TYPE_SYS_DOMAIN, + NWAM_CONDITION_OBJECT_TYPE_ESSID, + NWAM_CONDITION_OBJECT_TYPE_BSSID +} nwam_condition_object_type_t; + +/* + * Activation condition-related functions that convert activation + * values to an appropriate string and back. + */ +extern nwam_error_t nwam_condition_to_condition_string( + nwam_condition_object_type_t, nwam_condition_t, const char *, char **); +extern nwam_error_t nwam_condition_string_to_condition(const char *, + nwam_condition_object_type_t *, nwam_condition_t *, char **); + +/* + * Only one location can be active at one time. As a + * consequence, if the activation conditions of multiple + * locations are satisfied, we need to compare activation + * conditions to see if one is more specific than another. + * + * The following heuristics are applied to rate an + * activation condition: + * - "is" is the most specific condition + * - it is followed by "is-in-range" and "contains" + * - "is-not-in-range" and "does-not-contain" are next + * - finally "is-not" is least specific + * + * Regarding the objects these conditions apply to: + * - NCU, ENM and locations are most specific + * - system-domain is next + * - advertised-domain is next + * - IP address is next + * - wireless BSSID is next + * - wireless ESSID is least specific + * + */ +extern nwam_error_t nwam_condition_rate(nwam_condition_object_type_t, + nwam_condition_t, uint64_t *); + +/* + * Location definitions. + */ + +#define NWAM_LOC_NAME_AUTOMATIC "Automatic" +#define NWAM_LOC_NAME_NO_NET "NoNet" +#define NWAM_LOC_NAME_LEGACY "Legacy" + +#define NWAM_LOC_NAME_PRE_DEFINED(name) \ + (strcasecmp(name, NWAM_LOC_NAME_AUTOMATIC) == 0 || \ + strcasecmp(name, NWAM_LOC_NAME_NO_NET) == 0 || \ + strcasecmp(name, NWAM_LOC_NAME_LEGACY) == 0) + +/* Forward definition */ +struct nwam_handle; + +typedef struct nwam_handle *nwam_loc_handle_t; + +/* Location properties */ + +typedef enum { + NWAM_NAMESERVICES_DNS, + NWAM_NAMESERVICES_FILES, + NWAM_NAMESERVICES_NIS, + NWAM_NAMESERVICES_LDAP +} nwam_nameservices_t; + +typedef enum { + NWAM_CONFIGSRC_MANUAL, + NWAM_CONFIGSRC_DHCP +} nwam_configsrc_t; + +#define NWAM_LOC_PROP_ACTIVATION_MODE "activation-mode" +#define NWAM_LOC_PROP_CONDITIONS "conditions" +#define NWAM_LOC_PROP_ENABLED "enabled" + +/* Nameservice location properties */ +#define NWAM_LOC_PROP_NAMESERVICES "nameservices" +#define NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE "nameservices-config-file" +#define NWAM_LOC_PROP_DNS_NAMESERVICE_CONFIGSRC "dns-nameservice-configsrc" +#define NWAM_LOC_PROP_DNS_NAMESERVICE_DOMAIN "dns-nameservice-domain" +#define NWAM_LOC_PROP_DNS_NAMESERVICE_SERVERS "dns-nameservice-servers" +#define NWAM_LOC_PROP_DNS_NAMESERVICE_SEARCH "dns-nameservice-search" +#define NWAM_LOC_PROP_NIS_NAMESERVICE_CONFIGSRC "nis-nameservice-configsrc" +#define NWAM_LOC_PROP_NIS_NAMESERVICE_SERVERS "nis-nameservice-servers" +#define NWAM_LOC_PROP_LDAP_NAMESERVICE_CONFIGSRC "ldap-nameservice-configsrc" +#define NWAM_LOC_PROP_LDAP_NAMESERVICE_SERVERS "ldap-nameservice-servers" +#define NWAM_LOC_PROP_DEFAULT_DOMAIN "default-domain" + +/* NFSv4 domain */ +#define NWAM_LOC_PROP_NFSV4_DOMAIN "nfsv4-domain" + +/* IPfilter configuration */ +#define NWAM_LOC_PROP_IPFILTER_CONFIG_FILE "ipfilter-config-file" +#define NWAM_LOC_PROP_IPFILTER_V6_CONFIG_FILE "ipfilter-v6-config-file" +#define NWAM_LOC_PROP_IPNAT_CONFIG_FILE "ipnat-config-file" +#define NWAM_LOC_PROP_IPPOOL_CONFIG_FILE "ippool-config-file" + +/* IPsec configuration */ +#define NWAM_LOC_PROP_IKE_CONFIG_FILE "ike-config-file" +#define NWAM_LOC_PROP_IPSECPOLICY_CONFIG_FILE "ipsecpolicy-config-file" + +/* + * NCP/NCU definitions. + */ + +#define NWAM_NCP_NAME_AUTOMATIC "Automatic" +#define NWAM_NCP_NAME_USER "User" + +#define NWAM_NCP_AUTOMATIC(name) \ + (strcasecmp(name, NWAM_NCP_NAME_AUTOMATIC) == 0) + +typedef struct nwam_handle *nwam_ncp_handle_t; + +typedef struct nwam_handle *nwam_ncu_handle_t; + +typedef enum { + NWAM_NCU_TYPE_UNKNOWN = -1, + NWAM_NCU_TYPE_LINK, + NWAM_NCU_TYPE_INTERFACE, + NWAM_NCU_TYPE_ANY +} nwam_ncu_type_t; + +typedef enum { + NWAM_NCU_CLASS_UNKNOWN = -1, + NWAM_NCU_CLASS_PHYS, + NWAM_NCU_CLASS_IP, + NWAM_NCU_CLASS_ANY +} nwam_ncu_class_t; + +typedef enum { + NWAM_ADDRSRC_DHCP, + NWAM_ADDRSRC_AUTOCONF, + NWAM_ADDRSRC_STATIC +} nwam_addrsrc_t; + +typedef enum { + NWAM_PRIORITY_MODE_EXCLUSIVE, + NWAM_PRIORITY_MODE_SHARED, + NWAM_PRIORITY_MODE_ALL +} nwam_priority_mode_t; + +/* NCU properties common to all type/classes */ +#define NWAM_NCU_PROP_TYPE "type" +#define NWAM_NCU_PROP_CLASS "class" +#define NWAM_NCU_PROP_PARENT_NCP "parent" +#define NWAM_NCU_PROP_ACTIVATION_MODE "activation-mode" +#define NWAM_NCU_PROP_ENABLED "enabled" +#define NWAM_NCU_PROP_PRIORITY_GROUP "priority-group" +#define NWAM_NCU_PROP_PRIORITY_MODE "priority-mode" + +/* Link NCU properties */ +#define NWAM_NCU_PROP_LINK_MAC_ADDR "link-mac-addr" +#define NWAM_NCU_PROP_LINK_AUTOPUSH "link-autopush" +#define NWAM_NCU_PROP_LINK_MTU "link-mtu" + +/* IP NCU properties */ +#define NWAM_NCU_PROP_IP_VERSION "ip-version" +#define NWAM_NCU_PROP_IPV4_ADDRSRC "ipv4-addrsrc" +#define NWAM_NCU_PROP_IPV4_ADDR "ipv4-addr" +#define NWAM_NCU_PROP_IPV4_DEFAULT_ROUTE "ipv4-default-route" +#define NWAM_NCU_PROP_IPV6_ADDRSRC "ipv6-addrsrc" +#define NWAM_NCU_PROP_IPV6_ADDR "ipv6-addr" +#define NWAM_NCU_PROP_IPV6_DEFAULT_ROUTE "ipv6-default-route" +#define NWAM_NCU_PROP_IP_PRIMARY "ip-primary" +#define NWAM_NCU_PROP_IP_REQHOST "ip-reqhost" + +/* Some properties should only be set on creation */ +#define NWAM_NCU_PROP_SETONCE(prop) \ + (strcmp(prop, NWAM_NCU_PROP_TYPE) == 0 || \ + strcmp(prop, NWAM_NCU_PROP_CLASS) == 0 || \ + strcmp(prop, NWAM_NCU_PROP_PARENT_NCP) == 0) +/* + * ENM definitions + */ + +typedef struct nwam_handle *nwam_enm_handle_t; + +#define NWAM_ENM_PROP_ACTIVATION_MODE "activation-mode" +#define NWAM_ENM_PROP_CONDITIONS "conditions" +#define NWAM_ENM_PROP_ENABLED "enabled" + +/* FMRI associated with ENM */ +#define NWAM_ENM_PROP_FMRI "fmri" + +/* Start/stop scripts associated with ENM */ +#define NWAM_ENM_PROP_START "start" +#define NWAM_ENM_PROP_STOP "stop" + +/* + * Known Wireless LAN info (known WLAN) definitions. + */ + +typedef struct nwam_handle *nwam_known_wlan_handle_t; + +#define NWAM_KNOWN_WLAN_PROP_BSSIDS "bssids" +#define NWAM_KNOWN_WLAN_PROP_PRIORITY "priority" +#define NWAM_KNOWN_WLAN_PROP_KEYNAME "keyname" +#define NWAM_KNOWN_WLAN_PROP_KEYSLOT "keyslot" +#define NWAM_KNOWN_WLAN_PROP_SECURITY_MODE "security-mode" + +/* + * Location Functions + */ + +/* Create a location */ +extern nwam_error_t nwam_loc_create(const char *, nwam_loc_handle_t *); + +/* Copy a location */ +extern nwam_error_t nwam_loc_copy(nwam_loc_handle_t, const char *, + nwam_loc_handle_t *); + +/* Read a location from persistent storage */ +extern nwam_error_t nwam_loc_read(const char *, uint64_t, + nwam_loc_handle_t *); + +/* Validate in-memory representation of a location */ +extern nwam_error_t nwam_loc_validate(nwam_loc_handle_t, const char **); + +/* Commit in-memory representation of a location to persistent storage */ +extern nwam_error_t nwam_loc_commit(nwam_loc_handle_t, uint64_t); + +/* Destroy a location in persistent storage */ +extern nwam_error_t nwam_loc_destroy(nwam_loc_handle_t, uint64_t); + +/* Free in-memory representation of a location */ +extern void nwam_loc_free(nwam_loc_handle_t); + +/* read all locs from persistent storage and walk through each at a time */ +extern nwam_error_t nwam_walk_locs(int (*)(nwam_loc_handle_t, void *), void *, + uint64_t, int *); + +/* get/set loc name */ +extern nwam_error_t nwam_loc_get_name(nwam_loc_handle_t, char **); +extern nwam_error_t nwam_loc_set_name(nwam_loc_handle_t, const char *); +extern boolean_t nwam_loc_can_set_name(nwam_loc_handle_t); + +/* activate/deactivate loc */ +extern nwam_error_t nwam_loc_enable(nwam_loc_handle_t); +extern nwam_error_t nwam_loc_disable(nwam_loc_handle_t); + +/* walk all properties of an in-memory loc */ +extern nwam_error_t nwam_loc_walk_props(nwam_loc_handle_t, + int (*)(const char *, nwam_value_t, void *), + void *, uint64_t, int *); + +/* delete/get/set validate loc property */ +extern nwam_error_t nwam_loc_delete_prop(nwam_loc_handle_t, + const char *); +extern nwam_error_t nwam_loc_get_prop_value(nwam_loc_handle_t, + const char *, nwam_value_t *); +extern nwam_error_t nwam_loc_set_prop_value(nwam_loc_handle_t, + const char *, nwam_value_t); +extern nwam_error_t nwam_loc_validate_prop(nwam_loc_handle_t, const char *, + nwam_value_t); + +/* Get the read-only value for a particular loc property */ +extern nwam_error_t nwam_loc_prop_read_only(const char *, boolean_t *); + +/* Whether the property is multi-valued or not */ +extern nwam_error_t nwam_loc_prop_multivalued(const char *, boolean_t *); + +/* Retrieve data type */ +extern nwam_error_t nwam_loc_get_prop_type(const char *, nwam_value_type_t *); + +/* Retrieve description */ +extern nwam_error_t nwam_loc_get_prop_description(const char *, const char **); + +/* get default loc props */ +extern nwam_error_t nwam_loc_get_default_proplist(const char ***, uint_t *); + +/* get sstate of loc from nwamd */ +extern nwam_error_t nwam_loc_get_state(nwam_loc_handle_t, nwam_state_t *, + nwam_aux_state_t *); + +/* Get whether the loc has manual activation-mode or not */ +extern nwam_error_t nwam_loc_is_manual(nwam_loc_handle_t, boolean_t *); + +/* + * NCP/NCU functions + */ + +/* Create an ncp */ +extern nwam_error_t nwam_ncp_create(const char *, uint64_t, + nwam_ncp_handle_t *); + +/* Read an ncp from persistent storage */ +extern nwam_error_t nwam_ncp_read(const char *, uint64_t, nwam_ncp_handle_t *); + +/* Make a copy of existing ncp */ +extern nwam_error_t nwam_ncp_copy(nwam_ncp_handle_t, const char *, + nwam_ncp_handle_t *); + +/* Walk ncps */ +extern nwam_error_t nwam_walk_ncps(int (*)(nwam_ncp_handle_t, void *), + void *, uint64_t, int *); + +/* Get ncp name */ +extern nwam_error_t nwam_ncp_get_name(nwam_ncp_handle_t, char **); + +/* Get the read-only value for this ncp */ +extern nwam_error_t nwam_ncp_get_read_only(nwam_ncp_handle_t, boolean_t *); + +/* Destroy ncp */ +extern nwam_error_t nwam_ncp_destroy(nwam_ncp_handle_t, uint64_t); + +/* + * Walk all ncus associated with ncp. Specific types/classes of ncu can + * be selected via flags, or all via NWAM_FLAG_ALL. + */ +extern nwam_error_t nwam_ncp_walk_ncus(nwam_ncp_handle_t, + int(*)(nwam_ncu_handle_t, void *), void *, uint64_t, int *); + +/* Activate ncp */ +extern nwam_error_t nwam_ncp_enable(nwam_ncp_handle_t); + +/* Free in-memory representation of ncp */ +extern void nwam_ncp_free(nwam_ncp_handle_t); + +/* Get state of NCP from nwamd */ +extern nwam_error_t nwam_ncp_get_state(nwam_ncp_handle_t, nwam_state_t *, + nwam_aux_state_t *); + +/* Get the active priority-group */ +extern nwam_error_t nwam_ncp_get_active_priority_group(int64_t *); + +/* Create an ncu or read it from persistent storage */ +extern nwam_error_t nwam_ncu_create(nwam_ncp_handle_t, const char *, + nwam_ncu_type_t, nwam_ncu_class_t, nwam_ncu_handle_t *); +extern nwam_error_t nwam_ncu_read(nwam_ncp_handle_t, const char *, + nwam_ncu_type_t, uint64_t, nwam_ncu_handle_t *); + +/* Destroy an ncu in persistent storage or free the in-memory representation */ +extern nwam_error_t nwam_ncu_destroy(nwam_ncu_handle_t, uint64_t); +extern void nwam_ncu_free(nwam_ncu_handle_t); + +/* make a copy of existing ncu */ +extern nwam_error_t nwam_ncu_copy(nwam_ncu_handle_t, const char *, + nwam_ncu_handle_t *); + +/* Commit ncu changes to persistent storage */ +extern nwam_error_t nwam_ncu_commit(nwam_ncu_handle_t, uint64_t); + +/* activate/deactivate an individual NCU (must be part of the active NCP) */ +extern nwam_error_t nwam_ncu_enable(nwam_ncu_handle_t); +extern nwam_error_t nwam_ncu_disable(nwam_ncu_handle_t); + +/* Get state of NCU from nwamd */ +extern nwam_error_t nwam_ncu_get_state(nwam_ncu_handle_t, nwam_state_t *, + nwam_aux_state_t *); + +/* Get NCU type */ +extern nwam_error_t nwam_ncu_get_ncu_type(nwam_ncu_handle_t, nwam_ncu_type_t *); + +/* Get NCU class */ +extern nwam_error_t nwam_ncu_get_ncu_class(nwam_ncu_handle_t, + nwam_ncu_class_t *); + +/* Validate ncu content */ +extern nwam_error_t nwam_ncu_validate(nwam_ncu_handle_t, const char **); + +/* Walk all properties in in-memory representation of ncu */ +extern nwam_error_t nwam_ncu_walk_props(nwam_ncu_handle_t, + int (*)(const char *, nwam_value_t, void *), + void *, uint64_t, int *); + +/* Get/set name of ncu, get parent ncp */ +extern nwam_error_t nwam_ncu_get_name(nwam_ncu_handle_t, char **); +extern nwam_error_t nwam_ncu_name_to_typed_name(const char *, nwam_ncu_type_t, + char **); +extern nwam_error_t nwam_ncu_typed_name_to_name(const char *, nwam_ncu_type_t *, + char **); +extern nwam_error_t nwam_ncu_get_default_proplist(nwam_ncu_type_t, + nwam_ncu_class_t, const char ***, uint_t *); +extern nwam_error_t nwam_ncu_get_ncp(nwam_ncu_handle_t, nwam_ncp_handle_t *); + +/* delete/get/set/validate property from/in in-memory representation of ncu */ +extern nwam_error_t nwam_ncu_delete_prop(nwam_ncu_handle_t, + const char *); +extern nwam_error_t nwam_ncu_get_prop_value(nwam_ncu_handle_t, + const char *, nwam_value_t *); +extern nwam_error_t nwam_ncu_set_prop_value(nwam_ncu_handle_t, + const char *, nwam_value_t); + +extern nwam_error_t nwam_ncu_validate_prop(nwam_ncu_handle_t, const char *, + nwam_value_t); + +/* Retrieve data type */ +extern nwam_error_t nwam_ncu_get_prop_type(const char *, nwam_value_type_t *); +/* Retrieve prop description */ +extern nwam_error_t nwam_ncu_get_prop_description(const char *, const char **); + +/* Get the read-only value from the handle or parent NCP */ +extern nwam_error_t nwam_ncu_get_read_only(nwam_ncu_handle_t, boolean_t *); + +/* Get the read-only value for a particular NCU property */ +extern nwam_error_t nwam_ncu_prop_read_only(const char *, boolean_t *); + +/* Whether the property is multi-valued or not */ +extern nwam_error_t nwam_ncu_prop_multivalued(const char *, boolean_t *); + +/* Get whether the NCU has manual activation-mode or not */ +extern nwam_error_t nwam_ncu_is_manual(nwam_ncu_handle_t, boolean_t *); + +/* Get the flag from the given class for walks */ +extern uint64_t nwam_ncu_class_to_flag(nwam_ncu_class_t); + +/* Get the NCU type from the given class */ +extern nwam_ncu_type_t nwam_ncu_class_to_type(nwam_ncu_class_t); + +/* ENM functions */ +/* + * Obtain a specific enm handle, either be creating a new enm + * or reading an existing one from persistent storage. + */ +extern nwam_error_t nwam_enm_create(const char *, const char *, + nwam_enm_handle_t *); +extern nwam_error_t nwam_enm_read(const char *, uint64_t, nwam_enm_handle_t *); + +/* Make a copy of existing enm */ +extern nwam_error_t nwam_enm_copy(nwam_enm_handle_t, const char *, + nwam_enm_handle_t *); + +/* + * Obtain handles for all existing enms. Caller-specified callback + * function will be called once for each enm, passing the handle and + * the caller-specified arg. + */ +extern nwam_error_t nwam_walk_enms(int (*)(nwam_enm_handle_t, void *), void *, + uint64_t, int *); + +/* + * Commit an enm to persistent storage. Does not free the handle. + */ +extern nwam_error_t nwam_enm_commit(nwam_enm_handle_t, uint64_t); + +/* + * Remove an enm from persistent storage. + */ +extern nwam_error_t nwam_enm_destroy(nwam_enm_handle_t, uint64_t); + +/* + * Free an enm handle + */ +extern void nwam_enm_free(nwam_enm_handle_t); + +/* + * Validate an enm, or a specific enm property. If validating + * an entire enm, the invalid property type is returned. + */ +extern nwam_error_t nwam_enm_validate(nwam_enm_handle_t, const char **); +extern nwam_error_t nwam_enm_validate_prop(nwam_enm_handle_t, const char *, + nwam_value_t); + +/* Retrieve data type */ +extern nwam_error_t nwam_enm_get_prop_type(const char *, nwam_value_type_t *); +/* Retrieve prop description */ +extern nwam_error_t nwam_enm_get_prop_description(const char *, const char **); + +/* + * Delete/get/set enm property values. + */ +extern nwam_error_t nwam_enm_delete_prop(nwam_enm_handle_t, + const char *); +extern nwam_error_t nwam_enm_get_prop_value(nwam_enm_handle_t, + const char *, nwam_value_t *); +extern nwam_error_t nwam_enm_set_prop_value(nwam_enm_handle_t, + const char *, nwam_value_t); + +extern nwam_error_t nwam_enm_get_default_proplist(const char ***, uint_t *); + +/* Get the read-only value for a particular ENM property */ +extern nwam_error_t nwam_enm_prop_read_only(const char *, boolean_t *); + +/* Whether the property is multi-valued or not */ +extern nwam_error_t nwam_enm_prop_multivalued(const char *, boolean_t *); + +/* + * Walk all properties of a specific enm. For each property, specified + * callback function is called. Caller is responsible for freeing memory + * allocated for each property. + */ +extern nwam_error_t nwam_enm_walk_props(nwam_enm_handle_t, + int (*)(const char *, nwam_value_t, void *), + void *, uint64_t, int *); + +/* + * Get/set the name of an enm. When getting the name, the library will + * allocate a buffer; the caller is responsible for freeing the memory. + */ +extern nwam_error_t nwam_enm_get_name(nwam_enm_handle_t, char **); +extern nwam_error_t nwam_enm_set_name(nwam_enm_handle_t, const char *); +extern boolean_t nwam_enm_can_set_name(nwam_enm_handle_t); + +/* + * Start/stop an enm. + */ +extern nwam_error_t nwam_enm_enable(nwam_enm_handle_t); +extern nwam_error_t nwam_enm_disable(nwam_enm_handle_t); + +/* + * Get state of ENM from nwamd. + */ +extern nwam_error_t nwam_enm_get_state(nwam_enm_handle_t, nwam_state_t *, + nwam_aux_state_t *); + +/* + * Get whether the ENM has manual activation-mode or not. + */ +extern nwam_error_t nwam_enm_is_manual(nwam_enm_handle_t, boolean_t *); + +/* + * Known Wireless LAN (WLAN) info. + */ + +/* Create a known WLAN */ +extern nwam_error_t nwam_known_wlan_create(const char *, + nwam_known_wlan_handle_t *); + +/* Read a known WLAN from persistent storage */ +extern nwam_error_t nwam_known_wlan_read(const char *, uint64_t, + nwam_known_wlan_handle_t *); + +/* + * Destroy a known WLAN in persistent storage or free the in-memory + * representation. + */ +extern nwam_error_t nwam_known_wlan_destroy(nwam_known_wlan_handle_t, uint64_t); +extern void nwam_known_wlan_free(nwam_known_wlan_handle_t); + +/* make a copy of existing known WLAN */ +extern nwam_error_t nwam_known_wlan_copy(nwam_known_wlan_handle_t, const char *, + nwam_known_wlan_handle_t *); + +/* Commit known WLAN changes to persistent storage */ +extern nwam_error_t nwam_known_wlan_commit(nwam_known_wlan_handle_t, uint64_t); + +/* Validate known WLAN content */ +extern nwam_error_t nwam_known_wlan_validate(nwam_known_wlan_handle_t, + const char **); + +/* Walk known WLANs */ +extern nwam_error_t nwam_walk_known_wlans + (int(*)(nwam_known_wlan_handle_t, void *), void *, uint64_t, int *); + +/* get/set known WLAN name */ +extern nwam_error_t nwam_known_wlan_get_name(nwam_known_wlan_handle_t, char **); +extern nwam_error_t nwam_known_wlan_set_name(nwam_known_wlan_handle_t, + const char *); +extern boolean_t nwam_known_wlan_can_set_name(nwam_known_wlan_handle_t); + +/* walk all properties of an in-memory known WLAN */ +extern nwam_error_t nwam_known_wlan_walk_props(nwam_known_wlan_handle_t, + int (*)(const char *, nwam_value_t, void *), + void *, uint64_t, int *); + +/* delete/get/set/validate known WLAN property */ +extern nwam_error_t nwam_known_wlan_delete_prop(nwam_known_wlan_handle_t, + const char *); +extern nwam_error_t nwam_known_wlan_get_prop_value(nwam_known_wlan_handle_t, + const char *, nwam_value_t *); +extern nwam_error_t nwam_known_wlan_set_prop_value(nwam_known_wlan_handle_t, + const char *, nwam_value_t); +extern nwam_error_t nwam_known_wlan_validate_prop(nwam_known_wlan_handle_t, + const char *, nwam_value_t); + +/* Retrieve data type */ +extern nwam_error_t nwam_known_wlan_get_prop_type(const char *, + nwam_value_type_t *); +/* Retrieve prop description */ +extern nwam_error_t nwam_known_wlan_get_prop_description(const char *, + const char **); + +/* get default known WLAN props */ +extern nwam_error_t nwam_known_wlan_get_default_proplist(const char ***, + uint_t *); + +/* Whether the property is multi-valued or not */ +extern nwam_error_t nwam_known_wlan_prop_multivalued(const char *, boolean_t *); + +/* Add a bssid to the known WLANs */ +extern nwam_error_t nwam_known_wlan_add_to_known_wlans(const char *, + const char *, uint32_t, uint_t, const char *); + +/* Remove a bssid from known WLANs */ +extern nwam_error_t nwam_known_wlan_remove_from_known_wlans(const char *, + const char *, const char *); + +/* + * nwam_wlan_t is used for scan/need choice/need key events and by + * nwam_wlan_get_scan_results(). The following fields are valid: + * + * - for scan and need choice event, ESSID, BSSID, signal strength, security + * mode, speed, channel, bsstype, key index, and if we already have a key + * (have_key), if the WLAN is the current selection (selected) and + * if the current WLAN is connected (connected). + * - for need key events, ESSID, security mode, have_key, selected and connected + * values are set. The rest of the fields are not set since multiple WLANs + * may match the ESSID and have different speeds, channels etc. If an + * ESSID/BSSID selection is specified, the BSSID will be set also. + * + */ +typedef struct { + char nww_essid[NWAM_MAX_NAME_LEN]; + char nww_bssid[NWAM_MAX_NAME_LEN]; + char nww_signal_strength[NWAM_MAX_NAME_LEN]; + uint32_t nww_security_mode; /* a dladm_wlan_secmode_t */ + uint32_t nww_speed; /* a dladm_wlan_speed_t */ + uint32_t nww_channel; /* a dladm_wlan_channel_t */ + uint32_t nww_bsstype; /* a dladm_wlan_bsstype_t */ + uint_t nww_keyindex; + boolean_t nww_have_key; + boolean_t nww_selected; + boolean_t nww_connected; +} nwam_wlan_t; + +/* + * Active WLAN definitions. Used to scan WLANs/choose a WLAN/set a WLAN key. + */ +extern nwam_error_t nwam_wlan_scan(const char *); +extern nwam_error_t nwam_wlan_get_scan_results(const char *, uint_t *, + nwam_wlan_t **); +extern nwam_error_t nwam_wlan_select(const char *, const char *, const char *, + uint32_t, boolean_t); +extern nwam_error_t nwam_wlan_set_key(const char *, const char *, const char *, + uint32_t, uint_t, const char *); + +/* + * Event notification definitions + */ +#define NWAM_EVENT_TYPE_NOOP 0 +#define NWAM_EVENT_TYPE_INIT 1 +#define NWAM_EVENT_TYPE_SHUTDOWN 2 +#define NWAM_EVENT_TYPE_OBJECT_ACTION 3 +#define NWAM_EVENT_TYPE_OBJECT_STATE 4 +#define NWAM_EVENT_TYPE_PRIORITY_GROUP 5 +#define NWAM_EVENT_TYPE_INFO 6 +#define NWAM_EVENT_TYPE_WLAN_SCAN_REPORT 7 +#define NWAM_EVENT_TYPE_WLAN_NEED_CHOICE 8 +#define NWAM_EVENT_TYPE_WLAN_NEED_KEY 9 +#define NWAM_EVENT_TYPE_WLAN_CONNECTION_REPORT 10 +#define NWAM_EVENT_TYPE_IF_ACTION 11 +#define NWAM_EVENT_TYPE_IF_STATE 12 +#define NWAM_EVENT_TYPE_LINK_ACTION 13 +#define NWAM_EVENT_TYPE_LINK_STATE 14 +#define NWAM_EVENT_MAX NWAM_EVENT_TYPE_LINK_STATE + +#define NWAM_EVENT_STATUS_OK 0 +#define NWAM_EVENT_STATUS_NOT_HANDLED 1 + +#define NWAM_EVENT_NETWORK_OBJECT_UNDEFINED 0 +#define NWAM_EVENT_NETWORK_OBJECT_LINK 1 +#define NWAM_EVENT_NETWORK_OBJECT_INTERFACE 2 + +#define NWAM_EVENT_REQUEST_UNDEFINED 0 +#define NWAM_EVENT_REQUEST_WLAN 1 +#define NWAM_EVENT_REQUEST_KEY 2 + +/* + * Actions for nwamd to perform, used in conjunction with + * nwam_request_type_t in nwam_door_arg_t. + * Add string representations to nwam_action_to_string() in libnwam_util.c. + */ +typedef enum { + NWAM_ACTION_UNKNOWN = -1, + NWAM_ACTION_ADD, + NWAM_ACTION_REMOVE, + NWAM_ACTION_REFRESH, + NWAM_ACTION_ENABLE, + NWAM_ACTION_DISABLE, + NWAM_ACTION_DESTROY +} nwam_action_t; + +typedef enum { + NWAM_OBJECT_TYPE_UNKNOWN = -1, + NWAM_OBJECT_TYPE_NCP = 0, + NWAM_OBJECT_TYPE_NCU = 1, + NWAM_OBJECT_TYPE_LOC = 2, + NWAM_OBJECT_TYPE_ENM = 3, + NWAM_OBJECT_TYPE_KNOWN_WLAN = 4 +} nwam_object_type_t; + +typedef struct nwam_event *nwam_event_t; +/* + * Be aware the first element have to be of type long! See msgsnd(2). + * Different size of long in 32-bit and 64-bit will be handled by kernel system + * call. Data followed the long have to be the same in 32-bit and 64-bit. + */ +struct nwam_event { + long nwe_type; + uint32_t nwe_size; + uint32_t nwe_pad1; + union { + struct nwam_event_object_action { + nwam_object_type_t nwe_object_type; + char nwe_name[NWAM_MAX_NAME_LEN]; + char nwe_parent[NWAM_MAX_NAME_LEN]; + nwam_action_t nwe_action; + } nwe_object_action; + + struct nwam_event_object_state { + nwam_object_type_t nwe_object_type; + char nwe_name[NWAM_MAX_NAME_LEN]; + char nwe_parent[NWAM_MAX_NAME_LEN]; + nwam_state_t nwe_state; + nwam_aux_state_t nwe_aux_state; + } nwe_object_state; + + struct nwam_event_priority_group_info { + int64_t nwe_priority; + } nwe_priority_group_info; + + struct nwam_event_info { + char nwe_message[NWAM_MAX_VALUE_LEN]; + } nwe_info; + + /* + * wlan_info stores both scan results and the single + * WLAN we require a key for in the case of _WLAN_NEED_KEY + * events. For _WLAN_CONNECTION_REPORT events, it stores + * the WLAN the connection succeeded/failed for, indicating + * success/failure using the 'connected' boolean. + */ + struct nwam_event_wlan_info { + char nwe_name[NWAM_MAX_NAME_LEN]; + boolean_t nwe_connected; + uint16_t nwe_num_wlans; + nwam_wlan_t nwe_wlans[1]; + /* + * space may be allocated by user here for the + * number of wlans + */ + } nwe_wlan_info; + + struct nwam_event_if_action { + char nwe_name[NWAM_MAX_NAME_LEN]; + nwam_action_t nwe_action; + } nwe_if_action; + + struct nwam_event_if_state { + char nwe_name[NWAM_MAX_NAME_LEN]; + uint32_t nwe_flags; + uint32_t nwe_addr_valid; /* boolean */ + uint32_t nwe_addr_added; /* boolean */ + struct sockaddr_storage nwe_addr; + struct sockaddr_storage nwe_netmask; + } nwe_if_state; + + struct nwam_event_link_state { + char nwe_name[NWAM_MAX_NAME_LEN]; + boolean_t nwe_link_up; + /* link_state_t from sys/mac.h */ + } nwe_link_state; + + struct nwam_event_link_action { + char nwe_name[NWAM_MAX_NAME_LEN]; + nwam_action_t nwe_action; + } nwe_link_action; + } nwe_data; +}; + +/* NWAM client functions, used to register/unregister and receive events */ +extern nwam_error_t nwam_events_init(void); +extern void nwam_events_fini(void); +extern nwam_error_t nwam_event_wait(nwam_event_t *); +extern void nwam_event_free(nwam_event_t); + +/* Event-related string conversion functions */ +extern const char *nwam_action_to_string(nwam_action_t); +extern const char *nwam_event_type_to_string(int); +extern const char *nwam_state_to_string(nwam_state_t); +extern const char *nwam_aux_state_to_string(nwam_aux_state_t); + +extern const char *nwam_object_type_to_string(nwam_object_type_t); +extern nwam_object_type_t nwam_string_to_object_type(const char *); + +/* Utility strtok_r-like function */ +extern char *nwam_tokenize_by_unescaped_delim(char *, char, char **); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBNWAM_H */ diff --git a/illumos-x86_64/usr/include/libpolkit/libpolkit.h b/illumos-x86_64/usr/include/libpolkit/libpolkit.h new file mode 100644 index 00000000..b0dd2fc9 --- /dev/null +++ b/illumos-x86_64/usr/include/libpolkit/libpolkit.h @@ -0,0 +1,77 @@ +/*************************************************************************** + * + * libpolkit.h : Wraps a subset of methods on the PolicyKit daemon + * + * Copyright (C) 2006 David Zeuthen, + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + **************************************************************************/ + +#ifndef LIBPOLKIT_H +#define LIBPOLKIT_H + +#include +#include +#include +#include +#include + +typedef enum { + LIBPOLKIT_RESULT_OK, + LIBPOLKIT_RESULT_ERROR, + LIBPOLKIT_RESULT_INVALID_CONTEXT, + LIBPOLKIT_RESULT_NOT_PRIVILEGED, + LIBPOLKIT_RESULT_NO_SUCH_PRIVILEGE, + LIBPOLKIT_RESULT_NO_SUCH_USER +} LibPolKitResult; + +struct LibPolKitContext_s; +typedef struct LibPolKitContext_s LibPolKitContext; + +LibPolKitContext *libpolkit_new_context (DBusConnection *connection); + +gboolean libpolkit_free_context (LibPolKitContext *ctx); + +LibPolKitResult libpolkit_get_privilege_list (LibPolKitContext *ctx, + GList **result); + +LibPolKitResult libpolkit_is_uid_allowed_for_privilege (LibPolKitContext *ctx, + const char *system_bus_unique_name, + const char *user, + const char *privilege, + const char *resource, + gboolean *out_is_allowed, + gboolean *out_is_temporary, + char **out_is_privileged_but_restricted_to_system_bus_unique_name); + +LibPolKitResult libpolkit_revoke_temporary_privilege (LibPolKitContext *ctx, + const char *user, + const char *privilege, + const char *resource, + gboolean *result); + +LibPolKitResult libpolkit_get_allowed_resources_for_privilege_for_uid (LibPolKitContext *ctx, + const char *user, + const char *privilege, + GList **resources, + GList **restrictions, + int *num_non_temporary); + +#endif /* LIBPOLKIT_H */ + + diff --git a/illumos-x86_64/usr/include/libproc.h b/illumos-x86_64/usr/include/libproc.h new file mode 100644 index 00000000..5f303887 --- /dev/null +++ b/illumos-x86_64/usr/include/libproc.h @@ -0,0 +1,825 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Portions Copyright 2007 Chad Mynhier + * Copyright 2012 DEY Storage Systems, Inc. All rights reserved. + * Copyright 2019 Joyent, Inc. + * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2019, Carlos Neira + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2024 Oxide Computer Company + */ + +/* + * Interfaces available from the process control library, libproc. + */ + +#ifndef _LIBPROC_H +#define _LIBPROC_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(__i386) || defined(__amd64) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Opaque structure tag reference to a process control structure. + * Clients of libproc cannot look inside the process control structure. + * The implementation of struct ps_prochandle can change w/o affecting clients. + */ +struct ps_prochandle; + +/* + * Opaque structure tag reference to an lwp control structure. + */ +struct ps_lwphandle; + +extern int _libproc_debug; /* set non-zero to enable debugging fprintfs */ +extern int _libproc_no_qsort; /* set non-zero to inhibit sorting */ + /* of symbol tables */ +extern int _libproc_incore_elf; /* only use in-core elf data */ + +#if defined(__sparc) +#define R_RVAL1 R_O0 /* register holding a function return value */ +#define R_RVAL2 R_O1 /* 32 more bits for a 64-bit return value */ +#endif /* __sparc */ + +#if defined(__amd64) +#define R_PC REG_RIP +#define R_SP REG_RSP +#define R_RVAL1 REG_RAX /* register holding a function return value */ +#define R_RVAL2 REG_RDX /* 32 more bits for a 64-bit return value */ +#elif defined(__i386) +#define R_PC EIP +#define R_SP UESP +#define R_RVAL1 EAX /* register holding a function return value */ +#define R_RVAL2 EDX /* 32 more bits for a 64-bit return value */ +#endif /* __amd64 || __i386 */ + +#define R_RVAL R_RVAL1 /* simple function return value register */ + +/* maximum sizes of things */ +#define PRMAXSIG (32 * sizeof (sigset_t) / sizeof (uint32_t)) +#define PRMAXFAULT (32 * sizeof (fltset_t) / sizeof (uint32_t)) +#define PRMAXSYS (32 * sizeof (sysset_t) / sizeof (uint32_t)) + +/* State values returned by Pstate() */ +#define PS_RUN 1 /* process is running */ +#define PS_STOP 2 /* process is stopped */ +#define PS_LOST 3 /* process is lost to control (EAGAIN) */ +#define PS_UNDEAD 4 /* process is terminated (zombie) */ +#define PS_DEAD 5 /* process is terminated (core file) */ +#define PS_IDLE 6 /* process has not been run */ + +/* Flags accepted by Pgrab() */ +#define PGRAB_RETAIN 0x01 /* Retain tracing flags, else clear flags */ +#define PGRAB_FORCE 0x02 /* Open the process w/o O_EXCL */ +#define PGRAB_RDONLY 0x04 /* Open the process or core w/ O_RDONLY */ +#define PGRAB_NOSTOP 0x08 /* Open the process but do not stop it */ +#define PGRAB_INCORE 0x10 /* Use in-core data to build symbol tables */ + +/* Error codes from Pcreate() */ +#define C_STRANGE -1 /* Unanticipated error, errno is meaningful */ +#define C_FORK 1 /* Unable to fork */ +#define C_PERM 2 /* No permission (file set-id or unreadable) */ +#define C_NOEXEC 3 /* Cannot execute file */ +#define C_INTR 4 /* Interrupt received while creating */ +#define C_LP64 5 /* Program is _LP64, self is _ILP32 */ +#define C_NOENT 6 /* Cannot find executable file */ + +/* Error codes from Pgrab(), Pfgrab_core(), and Pgrab_core() */ +#define G_STRANGE -1 /* Unanticipated error, errno is meaningful */ +#define G_NOPROC 1 /* No such process */ +#define G_NOCORE 2 /* No such core file */ +#define G_NOPROCORCORE 3 /* No such proc or core (for proc_arg_grab) */ +#define G_NOEXEC 4 /* Cannot locate executable file */ +#define G_ZOMB 5 /* Zombie process */ +#define G_PERM 6 /* No permission */ +#define G_BUSY 7 /* Another process has control */ +#define G_SYS 8 /* System process */ +#define G_SELF 9 /* Process is self */ +#define G_INTR 10 /* Interrupt received while grabbing */ +#define G_LP64 11 /* Process is _LP64, self is ILP32 */ +#define G_FORMAT 12 /* File is not an ELF format core file */ +#define G_ELF 13 /* Libelf error, elf_errno() is meaningful */ +#define G_NOTE 14 /* Required PT_NOTE Phdr not present in core */ +#define G_ISAINVAL 15 /* Wrong ELF machine type */ +#define G_BADLWPS 16 /* Bad '/lwps' specification */ +#define G_NOFD 17 /* No more file descriptors */ + + +/* Flags accepted by Prelease */ +#define PRELEASE_CLEAR 0x10 /* Clear all tracing flags */ +#define PRELEASE_RETAIN 0x20 /* Retain final tracing flags */ +#define PRELEASE_HANG 0x40 /* Leave the process stopped */ +#define PRELEASE_KILL 0x80 /* Terminate the process */ + +typedef struct { /* argument descriptor for system call (Psyscall) */ + long arg_value; /* value of argument given to system call */ + void *arg_object; /* pointer to object in controlling process */ + char arg_type; /* AT_BYVAL, AT_BYREF */ + char arg_inout; /* AI_INPUT, AI_OUTPUT, AI_INOUT */ + ushort_t arg_size; /* if AT_BYREF, size of object in bytes */ +} argdes_t; + +/* values for type */ +#define AT_BYVAL 1 +#define AT_BYREF 2 + +/* values for inout */ +#define AI_INPUT 1 +#define AI_OUTPUT 2 +#define AI_INOUT 3 + +/* maximum number of syscall arguments */ +#define MAXARGS 8 + +/* maximum size in bytes of a BYREF argument */ +#define MAXARGL (4*1024) + +/* + * Ops vector definition for the Pgrab_ops(). + */ +typedef ssize_t (*pop_pread_t)(struct ps_prochandle *, void *, size_t, + uintptr_t, void *); +typedef ssize_t (*pop_pwrite_t)(struct ps_prochandle *, const void *, size_t, + uintptr_t, void *); +typedef int (*pop_read_maps_t)(struct ps_prochandle *, prmap_t **, ssize_t *, + void *); +typedef void (*pop_read_aux_t)(struct ps_prochandle *, auxv_t **, int *, + void *); +typedef int (*pop_cred_t)(struct ps_prochandle *, prcred_t *, int, + void *); +typedef int (*pop_priv_t)(struct ps_prochandle *, prpriv_t **, void *); +typedef int (*pop_secflags_t)(struct ps_prochandle *, prsecflags_t **, void *); +typedef const psinfo_t *(*pop_psinfo_t)(struct ps_prochandle *, psinfo_t *, + void *); +typedef void (*pop_status_t)(struct ps_prochandle *, pstatus_t *, void *); +typedef prheader_t *(*pop_lstatus_t)(struct ps_prochandle *, void *); +typedef prheader_t *(*pop_lpsinfo_t)(struct ps_prochandle *, void *); +typedef void (*pop_fini_t)(struct ps_prochandle *, void *); +typedef char *(*pop_platform_t)(struct ps_prochandle *, char *, size_t, void *); +typedef int (*pop_uname_t)(struct ps_prochandle *, struct utsname *, void *); +typedef char *(*pop_zonename_t)(struct ps_prochandle *, char *, size_t, void *); +typedef char *(*pop_execname_t)(struct ps_prochandle *, char *, size_t, void *); +typedef int (*pop_cwd_t)(struct ps_prochandle *, prcwd_t **, void *); +#if defined(__i386) || defined(__amd64) +typedef int (*pop_ldt_t)(struct ps_prochandle *, struct ssd *, int, void *); +#endif + +typedef struct ps_ops { + pop_pread_t pop_pread; + pop_pwrite_t pop_pwrite; + pop_read_maps_t pop_read_maps; + pop_read_aux_t pop_read_aux; + pop_cred_t pop_cred; + pop_priv_t pop_priv; + pop_psinfo_t pop_psinfo; + pop_status_t pop_status; + pop_lstatus_t pop_lstatus; + pop_lpsinfo_t pop_lpsinfo; + pop_fini_t pop_fini; + pop_platform_t pop_platform; + pop_uname_t pop_uname; + pop_zonename_t pop_zonename; + pop_execname_t pop_execname; + pop_secflags_t pop_secflags; + pop_cwd_t pop_cwd; +#if defined(__i386) || defined(__amd64) + pop_ldt_t pop_ldt; +#endif +} ps_ops_t; + +/* + * Function prototypes for routines in the process control package. + */ +extern struct ps_prochandle *Pcreate(const char *, char *const *, + int *, char *, size_t); +extern struct ps_prochandle *Pxcreate(const char *, char *const *, + char *const *, int *, char *, size_t); + +extern const char *Pcreate_error(int); + +extern struct ps_prochandle *Pgrab(pid_t, int, int *); +extern struct ps_prochandle *Pgrab_core(const char *, const char *, int, int *); +extern struct ps_prochandle *Pfgrab_core(int, const char *, int *); +extern struct ps_prochandle *Pgrab_file(const char *, int *); +extern struct ps_prochandle *Pgrab_ops(pid_t, void *, const ps_ops_t *, int); +extern const char *Pgrab_error(int); + +extern int Preopen(struct ps_prochandle *); +extern void Prelease(struct ps_prochandle *, int); +extern void Pfree(struct ps_prochandle *); + +extern int Pasfd(struct ps_prochandle *); +extern char *Pbrandname(struct ps_prochandle *, char *, size_t); +extern int Pctlfd(struct ps_prochandle *); +extern int Pcreate_agent(struct ps_prochandle *); +extern void Pdestroy_agent(struct ps_prochandle *); +extern int Pstopstatus(struct ps_prochandle *, long, uint_t); +extern int Pwait(struct ps_prochandle *, uint_t); +extern int Pstop(struct ps_prochandle *, uint_t); +extern int Pdstop(struct ps_prochandle *); +extern int Pstate(struct ps_prochandle *); +extern const psinfo_t *Ppsinfo(struct ps_prochandle *); +extern const pstatus_t *Pstatus(struct ps_prochandle *); +extern int Pcred(struct ps_prochandle *, prcred_t *, int); +extern int Psetcred(struct ps_prochandle *, const prcred_t *); +extern int Ppriv(struct ps_prochandle *, prpriv_t **); +extern void Ppriv_free(struct ps_prochandle *, prpriv_t *); +extern int Psetpriv(struct ps_prochandle *, prpriv_t *); +extern void *Pprivinfo(struct ps_prochandle *); +extern int Psetzoneid(struct ps_prochandle *, zoneid_t); +extern int Pgetareg(struct ps_prochandle *, int, prgreg_t *); +extern int Pputareg(struct ps_prochandle *, int, prgreg_t); +extern int Psetrun(struct ps_prochandle *, int, int); +extern int Psecflags(struct ps_prochandle *, prsecflags_t **); +extern void Psecflags_free(prsecflags_t *); +extern ssize_t Pread(struct ps_prochandle *, void *, size_t, uintptr_t); +extern ssize_t Pread_string(struct ps_prochandle *, char *, size_t, uintptr_t); +extern ssize_t Pwrite(struct ps_prochandle *, const void *, size_t, uintptr_t); +extern int Pclearsig(struct ps_prochandle *); +extern int Pclearfault(struct ps_prochandle *); +extern int Psetbkpt(struct ps_prochandle *, uintptr_t, ulong_t *); +extern int Pdelbkpt(struct ps_prochandle *, uintptr_t, ulong_t); +extern int Pxecbkpt(struct ps_prochandle *, ulong_t); +extern int Psetwapt(struct ps_prochandle *, const prwatch_t *); +extern int Pdelwapt(struct ps_prochandle *, const prwatch_t *); +extern int Pxecwapt(struct ps_prochandle *, const prwatch_t *); +extern int Psetflags(struct ps_prochandle *, long); +extern int Punsetflags(struct ps_prochandle *, long); +extern int Psignal(struct ps_prochandle *, int, int); +extern int Pfault(struct ps_prochandle *, int, int); +extern int Psysentry(struct ps_prochandle *, int, int); +extern int Psysexit(struct ps_prochandle *, int, int); +extern void Psetsignal(struct ps_prochandle *, const sigset_t *); +extern void Psetfault(struct ps_prochandle *, const fltset_t *); +extern void Psetsysentry(struct ps_prochandle *, const sysset_t *); +extern void Psetsysexit(struct ps_prochandle *, const sysset_t *); + +extern void Psync(struct ps_prochandle *); +extern int Psyscall(struct ps_prochandle *, sysret_t *, + int, uint_t, argdes_t *); +extern int Pisprocdir(struct ps_prochandle *, const char *); + +/* + * Function prototypes for lwp-specific operations. + */ +extern struct ps_lwphandle *Lgrab(struct ps_prochandle *, lwpid_t, int *); +extern const char *Lgrab_error(int); + +extern struct ps_prochandle *Lprochandle(struct ps_lwphandle *); +extern void Lfree(struct ps_lwphandle *); + +extern int Lctlfd(struct ps_lwphandle *); +extern int Lwait(struct ps_lwphandle *, uint_t); +extern int Lstop(struct ps_lwphandle *, uint_t); +extern int Ldstop(struct ps_lwphandle *); +extern int Lstate(struct ps_lwphandle *); +extern const lwpsinfo_t *Lpsinfo(struct ps_lwphandle *); +extern const lwpstatus_t *Lstatus(struct ps_lwphandle *); +extern int Lgetareg(struct ps_lwphandle *, int, prgreg_t *); +extern int Lputareg(struct ps_lwphandle *, int, prgreg_t); +extern int Lsetrun(struct ps_lwphandle *, int, int); +extern int Lclearsig(struct ps_lwphandle *); +extern int Lclearfault(struct ps_lwphandle *); +extern int Lxecbkpt(struct ps_lwphandle *, ulong_t); +extern int Lxecwapt(struct ps_lwphandle *, const prwatch_t *); +extern void Lsync(struct ps_lwphandle *); + +extern int Lstack(struct ps_lwphandle *, stack_t *); +extern int Lmain_stack(struct ps_lwphandle *, stack_t *); +extern int Lalt_stack(struct ps_lwphandle *, stack_t *); + +extern int Lgetregs(struct ps_lwphandle *, prgregset_t *); +extern int Lsetregs(struct ps_lwphandle *, const prgregset_t *); +extern int Lgetfpregs(struct ps_lwphandle *, prfpregset_t *); +extern int Lsetfpregs(struct ps_lwphandle *, const prfpregset_t *); +extern int Lgetxregs(struct ps_lwphandle *, prxregset_t **, size_t *); +extern int Lsetxregs(struct ps_lwphandle *, const prxregset_t *, size_t); + +/* + * Function prototypes for system calls forced on the victim process. + */ +extern int pr_open(struct ps_prochandle *, const char *, int, mode_t); +extern int pr_creat(struct ps_prochandle *, const char *, mode_t); +extern int pr_close(struct ps_prochandle *, int); +extern int pr_access(struct ps_prochandle *, const char *, int); +extern int pr_door_info(struct ps_prochandle *, int, struct door_info *); +extern void *pr_mmap(struct ps_prochandle *, + void *, size_t, int, int, int, off_t); +extern void *pr_zmap(struct ps_prochandle *, + void *, size_t, int, int); +extern int pr_munmap(struct ps_prochandle *, void *, size_t); +extern int pr_memcntl(struct ps_prochandle *, + caddr_t, size_t, int, caddr_t, int, int); +extern int pr_meminfo(struct ps_prochandle *, const uint64_t *addrs, + int addr_count, const uint_t *info, int info_count, + uint64_t *outdata, uint_t *validity); +extern int pr_sigaction(struct ps_prochandle *, + int, const struct sigaction *, struct sigaction *); +extern int pr_getitimer(struct ps_prochandle *, + int, struct itimerval *); +extern int pr_setitimer(struct ps_prochandle *, + int, const struct itimerval *, struct itimerval *); +extern int pr_ioctl(struct ps_prochandle *, int, int, void *, size_t); +extern int pr_fcntl(struct ps_prochandle *, int, int, void *, void *); +extern int pr_stat(struct ps_prochandle *, const char *, struct stat *); +extern int pr_lstat(struct ps_prochandle *, const char *, struct stat *); +extern int pr_fstat(struct ps_prochandle *, int, struct stat *); +extern int pr_stat64(struct ps_prochandle *, const char *, + struct stat64 *); +extern int pr_lstat64(struct ps_prochandle *, const char *, + struct stat64 *); +extern int pr_fstat64(struct ps_prochandle *, int, struct stat64 *); +extern int pr_statvfs(struct ps_prochandle *, const char *, statvfs_t *); +extern int pr_fstatvfs(struct ps_prochandle *, int, statvfs_t *); +extern projid_t pr_getprojid(struct ps_prochandle *Pr); +extern taskid_t pr_gettaskid(struct ps_prochandle *Pr); +extern taskid_t pr_settaskid(struct ps_prochandle *Pr, projid_t project, + int flags); +extern zoneid_t pr_getzoneid(struct ps_prochandle *Pr); +extern int pr_getrctl(struct ps_prochandle *, + const char *, rctlblk_t *, rctlblk_t *, int); +extern int pr_setrctl(struct ps_prochandle *, + const char *, rctlblk_t *, rctlblk_t *, int); +extern int pr_getrlimit(struct ps_prochandle *, + int, struct rlimit *); +extern int pr_setrlimit(struct ps_prochandle *, + int, const struct rlimit *); +extern int pr_setprojrctl(struct ps_prochandle *, const char *, + rctlblk_t *, size_t, int); +#if defined(_LARGEFILE64_SOURCE) +extern int pr_getrlimit64(struct ps_prochandle *, + int, struct rlimit64 *); +extern int pr_setrlimit64(struct ps_prochandle *, + int, const struct rlimit64 *); +#endif /* _LARGEFILE64_SOURCE */ +extern int pr_lwp_exit(struct ps_prochandle *); +extern int pr_exit(struct ps_prochandle *, int); +extern int pr_waitid(struct ps_prochandle *, + idtype_t, id_t, siginfo_t *, int); +extern off_t pr_lseek(struct ps_prochandle *, int, off_t, int); +extern offset_t pr_llseek(struct ps_prochandle *, int, offset_t, int); +extern int pr_rename(struct ps_prochandle *, const char *, const char *); +extern int pr_link(struct ps_prochandle *, const char *, const char *); +extern int pr_unlink(struct ps_prochandle *, const char *); +extern int pr_getpeerucred(struct ps_prochandle *, int, ucred_t **); +extern int pr_getpeername(struct ps_prochandle *, + int, struct sockaddr *, socklen_t *); +extern int pr_getsockname(struct ps_prochandle *, + int, struct sockaddr *, socklen_t *); +extern int pr_getsockopt(struct ps_prochandle *, + int, int, int, void *, int *); +extern int pr_processor_bind(struct ps_prochandle *, + idtype_t, id_t, int, int *); + +/* + * Function prototypes for accessing per-LWP register information. + */ +extern int Plwp_getregs(struct ps_prochandle *, lwpid_t, prgregset_t); +extern int Plwp_setregs(struct ps_prochandle *, lwpid_t, const prgregset_t); + +extern int Plwp_getfpregs(struct ps_prochandle *, lwpid_t, prfpregset_t *); +extern int Plwp_setfpregs(struct ps_prochandle *, lwpid_t, + const prfpregset_t *); + +extern int Plwp_getxregs(struct ps_prochandle *, lwpid_t, prxregset_t **, + size_t *); +extern void Plwp_freexregs(struct ps_prochandle *, prxregset_t *, size_t); +extern int Plwp_setxregs(struct ps_prochandle *, lwpid_t, const prxregset_t *, + size_t); + +#if defined(__sparc) +extern int Plwp_getgwindows(struct ps_prochandle *, lwpid_t, gwindows_t *); + +#if defined(__sparcv9) +extern int Plwp_getasrs(struct ps_prochandle *, lwpid_t, asrset_t); +extern int Plwp_setasrs(struct ps_prochandle *, lwpid_t, const asrset_t); +#endif /* __sparcv9 */ + +#endif /* __sparc */ + +#if defined(__i386) || defined(__amd64) +extern int Pldt(struct ps_prochandle *, struct ssd *, int); +extern int proc_get_ldt(pid_t, struct ssd *, int); +#endif /* __i386 || __amd64 */ + +extern int Plwp_getname(struct ps_prochandle *, lwpid_t, char *, size_t); +extern int Plwp_getpsinfo(struct ps_prochandle *, lwpid_t, lwpsinfo_t *); +extern int Plwp_getspymaster(struct ps_prochandle *, lwpid_t, psinfo_t *); + +extern int Plwp_stack(struct ps_prochandle *, lwpid_t, stack_t *); +extern int Plwp_main_stack(struct ps_prochandle *, lwpid_t, stack_t *); +extern int Plwp_alt_stack(struct ps_prochandle *, lwpid_t, stack_t *); + +/* + * LWP iteration interface; iterate over all active LWPs. + */ +typedef int proc_lwp_f(void *, const lwpstatus_t *); +extern int Plwp_iter(struct ps_prochandle *, proc_lwp_f *, void *); + +/* + * LWP iteration interface; iterate over all LWPs, active and zombie. + */ +typedef int proc_lwp_all_f(void *, const lwpstatus_t *, const lwpsinfo_t *); +extern int Plwp_iter_all(struct ps_prochandle *, proc_lwp_all_f *, void *); + +/* + * Process iteration interface; iterate over all non-system processes. + */ +typedef int proc_walk_f(psinfo_t *, lwpsinfo_t *, void *); +extern int proc_walk(proc_walk_f *, void *, int); + +#define PR_WALK_PROC 0 /* walk processes only */ +#define PR_WALK_LWP 1 /* walk all lwps */ +#define PR_WALK_INCLUDE_SYS 0x80000000 /* include SSYS processes */ + +/* + * File descriptor iteration. + */ +typedef int proc_fdwalk_f(const prfdinfo_t *, void *); +extern int proc_fdwalk(pid_t, proc_fdwalk_f *, void *); + +/* + * fdinfo iteration. + */ +typedef int proc_fdinfowalk_f(uint_t, const void *, size_t, void *); +extern int proc_fdinfowalk(const prfdinfo_t *, proc_fdinfowalk_f *, void *); + +/* + * Determine if an lwp is in a set as returned from proc_arg_xgrab(). + */ +extern int proc_lwp_in_set(const char *, lwpid_t); +extern int proc_lwp_range_valid(const char *); + +/* + * Symbol table interfaces. + */ + +/* + * Pseudo-names passed to Plookup_by_name() for well-known load objects. + * NOTE: It is required that PR_OBJ_EXEC and PR_OBJ_LDSO exactly match + * the definitions of PS_OBJ_EXEC and PS_OBJ_LDSO from . + */ +#define PR_OBJ_EXEC ((const char *)0) /* search the executable file */ +#define PR_OBJ_LDSO ((const char *)1) /* search ld.so.1 */ +#define PR_OBJ_EVERY ((const char *)-1) /* search every load object */ + +/* + * Special Lmid_t passed to Plookup_by_lmid() to search all link maps. The + * special values LM_ID_BASE and LM_ID_LDSO from may also be used. + * If PR_OBJ_EXEC is used as the object name, the lmid must be PR_LMID_EVERY + * or LM_ID_BASE in order to return a match. If PR_OBJ_LDSO is used as the + * object name, the lmid must be PR_LMID_EVERY or LM_ID_LDSO to return a match. + */ +#define PR_LMID_EVERY ((Lmid_t)-1UL) /* search every link map */ + +/* + * 'object_name' is the name of a load object obtained from an + * iteration over the process's address space mappings (Pmapping_iter), + * or an iteration over the process's mapped objects (Pobject_iter), + * or else it is one of the special PR_OBJ_* values above. + */ +extern int Plookup_by_name(struct ps_prochandle *, + const char *, const char *, GElf_Sym *); + +extern int Plookup_by_addr(struct ps_prochandle *, + uintptr_t, char *, size_t, GElf_Sym *); + +typedef struct prsyminfo { + const char *prs_object; /* object name */ + const char *prs_name; /* symbol name */ + Lmid_t prs_lmid; /* link map id */ + uint_t prs_id; /* symbol id */ + uint_t prs_table; /* symbol table id */ +} prsyminfo_t; + +extern int Pxlookup_by_name(struct ps_prochandle *, + Lmid_t, const char *, const char *, GElf_Sym *, prsyminfo_t *); + +extern int Pxlookup_by_addr(struct ps_prochandle *, + uintptr_t, char *, size_t, GElf_Sym *, prsyminfo_t *); +extern int Pxlookup_by_addr_resolved(struct ps_prochandle *, + uintptr_t, char *, size_t, GElf_Sym *, prsyminfo_t *); + +typedef int proc_map_f(void *, const prmap_t *, const char *); + +extern int Pmapping_iter(struct ps_prochandle *, proc_map_f *, void *); +extern int Pmapping_iter_resolved(struct ps_prochandle *, proc_map_f *, void *); +extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *); +extern int Pobject_iter_resolved(struct ps_prochandle *, proc_map_f *, void *); + +extern const prmap_t *Paddr_to_map(struct ps_prochandle *, uintptr_t); +extern const prmap_t *Paddr_to_text_map(struct ps_prochandle *, uintptr_t); +extern const prmap_t *Pname_to_map(struct ps_prochandle *, const char *); +extern const prmap_t *Plmid_to_map(struct ps_prochandle *, + Lmid_t, const char *); + +extern const rd_loadobj_t *Paddr_to_loadobj(struct ps_prochandle *, uintptr_t); +extern const rd_loadobj_t *Pname_to_loadobj(struct ps_prochandle *, + const char *); +extern const rd_loadobj_t *Plmid_to_loadobj(struct ps_prochandle *, + Lmid_t, const char *); + +extern ctf_file_t *Paddr_to_ctf(struct ps_prochandle *, uintptr_t); +extern ctf_file_t *Pname_to_ctf(struct ps_prochandle *, const char *); + +extern char *Pplatform(struct ps_prochandle *, char *, size_t); +extern int Puname(struct ps_prochandle *, struct utsname *); +extern char *Pzonename(struct ps_prochandle *, char *, size_t); +extern char *Pfindobj(struct ps_prochandle *, const char *, char *, size_t); + +extern char *Pexecname(struct ps_prochandle *, char *, size_t); +extern char *Pobjname(struct ps_prochandle *, uintptr_t, char *, size_t); +extern char *Pobjname_resolved(struct ps_prochandle *, uintptr_t, char *, + size_t); +extern int Plmid(struct ps_prochandle *, uintptr_t, Lmid_t *); + +typedef int proc_env_f(void *, struct ps_prochandle *, uintptr_t, const char *); +extern int Penv_iter(struct ps_prochandle *, proc_env_f *, void *); +extern char *Pgetenv(struct ps_prochandle *, const char *, char *, size_t); +extern long Pgetauxval(struct ps_prochandle *, int); +extern const auxv_t *Pgetauxvec(struct ps_prochandle *); + +extern void Pset_procfs_path(const char *); + +/* + * Symbol table iteration interface. The special lmid constants LM_ID_BASE, + * LM_ID_LDSO, and PR_LMID_EVERY may be used with Psymbol_iter_by_lmid. + */ +typedef int proc_sym_f(void *, const GElf_Sym *, const char *); +typedef int proc_xsym_f(void *, const GElf_Sym *, const char *, + const prsyminfo_t *); + +extern int Psymbol_iter(struct ps_prochandle *, + const char *, int, int, proc_sym_f *, void *); +extern int Psymbol_iter_by_addr(struct ps_prochandle *, + const char *, int, int, proc_sym_f *, void *); +extern int Psymbol_iter_by_name(struct ps_prochandle *, + const char *, int, int, proc_sym_f *, void *); + +extern int Psymbol_iter_by_lmid(struct ps_prochandle *, + Lmid_t, const char *, int, int, proc_sym_f *, void *); + +extern int Pxsymbol_iter(struct ps_prochandle *, + Lmid_t, const char *, int, int, proc_xsym_f *, void *); + +/* + * 'which' selects which symbol table and can be one of the following. + */ +#define PR_SYMTAB 1 +#define PR_DYNSYM 2 +/* + * 'type' selects the symbols of interest by binding and type. It is a bit- + * mask of one or more of the following flags, whose order MUST match the + * order of STB and STT constants in . + */ +#define BIND_LOCAL 0x0001 +#define BIND_GLOBAL 0x0002 +#define BIND_WEAK 0x0004 +#define BIND_ANY (BIND_LOCAL|BIND_GLOBAL|BIND_WEAK) +#define TYPE_NOTYPE 0x0100 +#define TYPE_OBJECT 0x0200 +#define TYPE_FUNC 0x0400 +#define TYPE_SECTION 0x0800 +#define TYPE_FILE 0x1000 +#define TYPE_ANY (TYPE_NOTYPE|TYPE_OBJECT|TYPE_FUNC|TYPE_SECTION|TYPE_FILE) + +/* + * This returns the rtld_db agent handle for the process. + * The handle will become invalid at the next successful exec() and + * must not be used beyond that point (see Preset_maps(), below). + */ +extern rd_agent_t *Prd_agent(struct ps_prochandle *); + +/* + * This should be called when an RD_DLACTIVITY event with the + * RD_CONSISTENT state occurs via librtld_db's event mechanism. + * This makes libproc's address space mappings and symbol tables current. + * The variant Pupdate_syms() can be used to preload all symbol tables as well. + */ +extern void Pupdate_maps(struct ps_prochandle *); +extern void Pupdate_syms(struct ps_prochandle *); + +/* + * This must be called after the victim process performs a successful + * exec() if any of the symbol table interface functions have been called + * prior to that point. This is essential because an exec() invalidates + * all previous symbol table and address space mapping information. + * It is always safe to call, but if it is called other than after an + * exec() by the victim process it just causes unnecessary overhead. + * + * The rtld_db agent handle obtained from a previous call to Prd_agent() is + * made invalid by Preset_maps() and Prd_agent() must be called again to get + * the new handle. + */ +extern void Preset_maps(struct ps_prochandle *); + +/* + * Given an address, Ppltdest() determines if this is part of a PLT, and if + * so returns a pointer to the symbol name that will be used for resolution. + * If the specified address is not part of a PLT, the function returns NULL. + */ +extern const char *Ppltdest(struct ps_prochandle *, uintptr_t); + +/* + * See comments for Pissyscall(), in Pisadep.h + */ +extern int Pissyscall_prev(struct ps_prochandle *, uintptr_t, uintptr_t *); + +/* + * Stack frame iteration interface. + */ +typedef int proc_stack_f(void *, prgregset_t, uint_t, const long *); + +extern int Pstack_iter(struct ps_prochandle *, + const prgregset_t, proc_stack_f *, void *); + +/* + * The following functions define a set of passive interfaces: libproc provides + * default, empty definitions that are called internally. If a client wishes + * to override these definitions, it can simply provide its own version with + * the same signature that interposes on the libproc definition. + * + * If the client program wishes to report additional error information, it + * can provide its own version of Perror_printf. + * + * If the client program wishes to receive a callback after Pcreate forks + * but before it execs, it can provide its own version of Pcreate_callback. + */ +extern void Perror_printf(struct ps_prochandle *P, const char *format, ...); +extern void Pcreate_callback(struct ps_prochandle *); + +/* + * Remove unprintable characters from psinfo.pr_psargs and replace with + * whitespace characters so it is safe for printing. + */ +extern void proc_unctrl_psinfo(psinfo_t *); + +/* + * Utility functions for processing arguments which should be /proc files, + * pids, and/or core files. The returned error code can be passed to + * Pgrab_error() in order to convert it to an error string. + */ +#define PR_ARG_PIDS 0x1 /* Allow pid and /proc file arguments */ +#define PR_ARG_CORES 0x2 /* Allow core file arguments */ + +#define PR_ARG_ANY (PR_ARG_PIDS | PR_ARG_CORES) + +extern struct ps_prochandle *proc_arg_grab(const char *, int, int, int *); +extern struct ps_prochandle *proc_arg_xgrab(const char *, const char *, int, + int, int *, const char **); +extern pid_t proc_arg_psinfo(const char *, int, psinfo_t *, int *); +extern pid_t proc_arg_xpsinfo(const char *, int, psinfo_t *, int *, + const char **); + +/* + * Utility functions for obtaining information via /proc without actually + * performing a Pcreate() or Pgrab(): + */ +extern int proc_get_auxv(pid_t, auxv_t *, int); +extern int proc_get_cred(pid_t, prcred_t *, int); +extern prpriv_t *proc_get_priv(pid_t); +extern void proc_free_priv(prpriv_t *); +extern int proc_get_psinfo(pid_t, psinfo_t *); +extern int proc_get_status(pid_t, pstatus_t *); +extern int proc_get_secflags(pid_t, prsecflags_t **); +extern prfdinfo_t *proc_get_fdinfo(pid_t, int); +extern const void *proc_fdinfo_misc(const prfdinfo_t *, uint_t, size_t *); +extern void proc_fdinfo_free(prfdinfo_t *); +extern int proc_get_lwpsinfo(pid_t, uint_t, lwpsinfo_t *); +extern int proc_get_lwpstatus(pid_t, uint_t, lwpstatus_t *); + +/* + * Utility functions for debugging tools to convert numeric fault, + * signal, and system call numbers to symbolic names: + */ +#define FLT2STR_MAX 32 /* max. string length of faults (like SIG2STR_MAX) */ +#define SYS2STR_MAX 32 /* max. string length of syscalls (like SIG2STR_MAX) */ +#define DMODELSTR_MAX 32 /* max. string length of data model names */ + +extern char *proc_fltname(int, char *, size_t); +extern char *proc_signame(int, char *, size_t); +extern char *proc_sysname(int, char *, size_t); +extern char *proc_dmodelname(int, char *, size_t); + +/* + * Utility functions for debugging tools to convert fault, signal, and system + * call names back to the numeric constants: + */ +extern int proc_str2flt(const char *, int *); +extern int proc_str2sig(const char *, int *); +extern int proc_str2sys(const char *, int *); + +/* + * Utility functions for debugging tools to convert a fault, signal or system + * call set to a string representation (e.g. "BUS,SEGV" or "open,close,read"). + */ +#define PRSIGBUFSZ 1024 /* buffer size for proc_sigset2str() */ + +extern char *proc_fltset2str(const fltset_t *, const char *, int, + char *, size_t); +extern char *proc_sigset2str(const sigset_t *, const char *, int, + char *, size_t); +extern char *proc_sysset2str(const sysset_t *, const char *, int, + char *, size_t); + +extern int Pgcore(struct ps_prochandle *, const char *, core_content_t); +extern int Pfgcore(struct ps_prochandle *, int, core_content_t); +extern core_content_t Pcontent(struct ps_prochandle *); + +/* + * Utility functions for debugging tools to convert a string representation of + * a fault, signal or system call set back to the numeric value of the + * corresponding set type. + */ +extern char *proc_str2fltset(const char *, const char *, int, fltset_t *); +extern char *proc_str2sigset(const char *, const char *, int, sigset_t *); +extern char *proc_str2sysset(const char *, const char *, int, sysset_t *); + +/* + * Utility functions for converting between strings and core_content_t. + */ +#define PRCONTENTBUFSZ 80 /* buffer size for proc_content2str() */ + +extern int proc_str2content(const char *, core_content_t *); +extern int proc_content2str(core_content_t, char *, size_t); + +/* + * Utility functions for buffering output to stdout, stderr while + * process is grabbed. Prevents deadlocks due to pfiles `pgrep xterm` + * and other varients. + */ +extern int proc_initstdio(void); +extern int proc_flushstdio(void); +extern int proc_finistdio(void); + +/* + * Iterate over all open files. + */ +typedef int proc_fdinfo_f(void *, const prfdinfo_t *); +extern int Pfdinfo_iter(struct ps_prochandle *, proc_fdinfo_f *, void *); + +/* + * NT_UPANIC information. + */ +extern int Pupanic(struct ps_prochandle *, prupanic_t **); +extern void Pupanic_free(prupanic_t *); + +/* + * NT_CWD information. + */ +extern int Pcwd(struct ps_prochandle *, prcwd_t **); +extern void Pcwd_free(prcwd_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBPROC_H */ diff --git a/illumos-x86_64/usr/include/libpsl.h b/illumos-x86_64/usr/include/libpsl.h new file mode 100644 index 00000000..d7946e5c --- /dev/null +++ b/illumos-x86_64/usr/include/libpsl.h @@ -0,0 +1,210 @@ +/* + * Copyright(c) 2014-2024 Tim Ruehsen + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * This file is part of libpsl. + * + * Header file for libpsl library routines + * + * Changelog + * 20.03.2014 Tim Ruehsen created + * + */ + +#ifndef LIBPSL_LIBPSL_H +#define LIBPSL_LIBPSL_H + +#include +#include + +#define PSL_VERSION "0.21.5" +#define PSL_VERSION_MAJOR 0 +#define PSL_VERSION_MINOR 21 +#define PSL_VERSION_PATCH 5 +#define PSL_VERSION_NUMBER 0x001505 + +/* support clang's __has_declspec_attribute attribute */ +#ifndef __has_declspec_attribute +# define __has_declspec_attribute(x) 0 +#endif + +#ifndef PSL_API +#if defined BUILDING_PSL && HAVE_VISIBILITY +# define PSL_API __attribute__ ((__visibility__("default"))) +#elif defined BUILDING_PSL && (defined _MSC_VER || __has_declspec_attribute(dllexport)) && !defined PSL_STATIC +# define PSL_API __declspec(dllexport) +#elif (defined _MSC_VER || __has_declspec_attribute(dllimport)) && !defined PSL_STATIC +# define PSL_API __declspec(dllimport) +#else +# define PSL_API +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* types for psl_is_public_suffix2() */ +#define PSL_TYPE_ICANN (1<<0) +#define PSL_TYPE_PRIVATE (1<<1) +#define PSL_TYPE_NO_STAR_RULE (1<<2) +#define PSL_TYPE_ANY (PSL_TYPE_ICANN | PSL_TYPE_PRIVATE) + +/** + * psl_error_t: + * @PSL_SUCCESS: Successful return. + * @PSL_ERR_INVALID_ARG: Invalid argument. + * @PSL_ERR_CONVERTER: Failed to open libicu utf-16 converter. + * @PSL_ERR_TO_UTF16: Failed to convert to utf-16. + * @PSL_ERR_TO_LOWER: Failed to convert utf-16 to lowercase. + * @PSL_ERR_TO_UTF8: Failed to convert utf-16 to utf-8. + * @PSL_ERR_NO_MEM: Failed to allocate memory. + * + * Return codes for PSL functions. + * Negative return codes mean failure. + * Positive values are reserved for non-error return codes. + */ +typedef enum { + PSL_SUCCESS = 0, + PSL_ERR_INVALID_ARG = -1, + PSL_ERR_CONVERTER = -2, /* failed to open libicu utf-16 converter */ + PSL_ERR_TO_UTF16 = -3, /* failed to convert to utf-16 */ + PSL_ERR_TO_LOWER = -4, /* failed to convert utf-16 to lowercase */ + PSL_ERR_TO_UTF8 = -5, /* failed to convert utf-16 to utf-8 */ + PSL_ERR_NO_MEM = -6 /* failed to allocate memory */ +} psl_error_t; + +typedef struct psl_ctx_st psl_ctx_t; + +/* frees PSL context */ +PSL_API +void + psl_free(psl_ctx_t *psl); + +/* frees memory allocated by libpsl routines */ +PSL_API +void + psl_free_string(char *str); + +/* loads PSL data from file */ +PSL_API +psl_ctx_t * + psl_load_file(const char *fname); + +/* loads PSL data from FILE pointer */ +PSL_API +psl_ctx_t * + psl_load_fp(FILE *fp); + +/* retrieves builtin PSL data */ +PSL_API +const psl_ctx_t * + psl_builtin(void); + +/* retrieves most recent PSL data */ +PSL_API +psl_ctx_t * + psl_latest(const char *fname); + +/* checks whether domain is a public suffix or not */ +PSL_API +int + psl_is_public_suffix(const psl_ctx_t *psl, const char *domain); + +/* checks whether domain is a public suffix regarding the type or not */ +PSL_API +int + psl_is_public_suffix2(const psl_ctx_t *psl, const char *domain, int type); + +/* checks whether cookie_domain is acceptable for domain or not */ +PSL_API +int + psl_is_cookie_domain_acceptable(const psl_ctx_t *psl, const char *hostname, const char *cookie_domain); + +/* returns the longest not registrable domain within 'domain' or NULL if none found */ +PSL_API +const char * + psl_unregistrable_domain(const psl_ctx_t *psl, const char *domain); + +/* returns the shortest possible registrable domain part or NULL if domain is not registrable at all */ +PSL_API +const char * + psl_registrable_domain(const psl_ctx_t *psl, const char *domain); + +/* convert a string into lowercase UTF-8 */ +PSL_API +psl_error_t + psl_str_to_utf8lower(const char *str, const char *encoding, const char *locale, char **lower); + +/* does not include exceptions */ +PSL_API +int + psl_suffix_count(const psl_ctx_t *psl); + +/* just counts exceptions */ +PSL_API +int + psl_suffix_exception_count(const psl_ctx_t *psl); + +/* just counts wildcards */ +PSL_API +int + psl_suffix_wildcard_count(const psl_ctx_t *psl); + +/* returns mtime of PSL source file */ +PSL_API +time_t + psl_builtin_file_time(void); + +/* returns SHA1 checksum (hex-encoded, lowercase) of PSL source file */ +PSL_API +const char * + psl_builtin_sha1sum(void); + +/* returns file name of PSL source file */ +PSL_API +const char * + psl_builtin_filename(void); + +/* returns name of distribution PSL data file */ +PSL_API +const char * + psl_dist_filename(void); + +/* returns library version string */ +PSL_API +const char * + psl_get_version(void); + +/* checks library version number */ +PSL_API +int + psl_check_version_number(int version); + +/* returns whether the built-in data is outdated or not */ +PSL_API +int + psl_builtin_outdated(void); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBPSL_LIBPSL_H */ diff --git a/illumos-x86_64/usr/include/librcm.h b/illumos-x86_64/usr/include/librcm.h new file mode 100644 index 00000000..5c105fd1 --- /dev/null +++ b/illumos-x86_64/usr/include/librcm.h @@ -0,0 +1,167 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBRCM_H +#define _LIBRCM_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flags for rcm requests + */ +#define RCM_INCLUDE_SUBTREE 0x0001 +#define RCM_INCLUDE_DEPENDENT 0x0002 +#define RCM_QUERY 0x0004 +#define RCM_FORCE 0x0008 +#define RCM_FILESYS 0x0010 /* private to filesys module */ +#define RCM_NOPID 0x0020 +#define RCM_DR_OPERATION 0x0040 +#define RCM_MOD_INFO 0x0080 /* private */ +#define RCM_CAPACITY_ADD 0x0100 +#define RCM_CAPACITY_DELETE 0x0200 +#define RCM_QUERY_CANCEL 0x0400 /* private */ +#define RCM_SCOPE 0x0800 +#define RCM_REGISTER_DR 0x1000 /* private */ +#define RCM_REGISTER_EVENT 0x2000 /* private */ +#define RCM_REGISTER_CAPACITY 0x4000 /* private */ +#define RCM_SUSPENDED 0x8000 /* private */ +#define RCM_RETIRE_REQUEST 0x10000 +#define RCM_RETIRE_NOTIFY 0x20000 + +/* + * RCM return values + */ +#define RCM_SUCCESS 0 +#define RCM_FAILURE -1 +#define RCM_CONFLICT -2 +#define RCM_NO_CONSTRAINT -3 + +/* + * RCM resource states + */ +#define RCM_STATE_UNKNOWN 0 +#define RCM_STATE_ONLINE 1 +#define RCM_STATE_ONLINING 2 +#define RCM_STATE_OFFLINE_FAIL 3 +#define RCM_STATE_OFFLINING 4 +#define RCM_STATE_OFFLINE 5 +#define RCM_STATE_REMOVING 6 +#define RCM_STATE_RESUMING 10 +#define RCM_STATE_SUSPEND_FAIL 11 +#define RCM_STATE_SUSPENDING 12 +#define RCM_STATE_SUSPEND 13 +#define RCM_STATE_REMOVE 14 /* private to rcm_daemon */ +#define RCM_STATE_OFFLINE_QUERYING 15 +#define RCM_STATE_OFFLINE_QUERY_FAIL 16 +#define RCM_STATE_OFFLINE_QUERY 17 +#define RCM_STATE_SUSPEND_QUERYING 18 +#define RCM_STATE_SUSPEND_QUERY_FAIL 19 +#define RCM_STATE_SUSPEND_QUERY 20 + +/* + * RCM event attr and properties + */ +#define RCM_RSRCNAME "rcm.rsrcname" +#define RCM_CLIENT_NAME "rcm.client_name" +#define RCM_CLIENT_EXPORTS "rcm.client_exports" + +/* Resource name to register for new links reconfigured */ +#define RCM_RESOURCE_LINK_NEW "SUNW_event/resource/new/link" + +/* Resource name to register for new physical data-links */ +#define RCM_RESOURCE_PHYSLINK_NEW "SUNW_event/resource/new/physlink" + +/* name-value pair definitions for rcm_notify_event() */ +#define RCM_NV_LINKID "linkid" +#define RCM_NV_RECONFIGURED "reconfigured" + +/* + * rcm handles + */ +typedef struct rcm_handle rcm_handle_t; +typedef struct rcm_info rcm_info_t; +typedef rcm_info_t rcm_info_tuple_t; + +/* + * Interface definitions + */ +int rcm_alloc_handle(char *, uint_t, void *, rcm_handle_t **); +int rcm_free_handle(rcm_handle_t *); +int rcm_get_info(rcm_handle_t *, char *, uint_t, rcm_info_t **); +int rcm_get_info_list(rcm_handle_t *, char **, uint_t, rcm_info_t **); +void rcm_free_info(rcm_info_t *); +int rcm_append_info(rcm_info_t **, rcm_info_t *); +rcm_info_tuple_t *rcm_info_next(rcm_info_t *, rcm_info_tuple_t *); +const char *rcm_info_rsrc(rcm_info_tuple_t *); +const char *rcm_info_info(rcm_info_tuple_t *); +const char *rcm_info_error(rcm_info_tuple_t *); +const char *rcm_info_modname(rcm_info_tuple_t *); +pid_t rcm_info_pid(rcm_info_tuple_t *); +int rcm_info_state(rcm_info_tuple_t *); +int rcm_info_seqnum(rcm_info_tuple_t *); +nvlist_t *rcm_info_properties(rcm_info_tuple_t *); + +int rcm_request_offline(rcm_handle_t *, char *, uint_t, rcm_info_t **); +int rcm_request_offline_list(rcm_handle_t *, char **, uint_t, rcm_info_t **); +int rcm_notify_online(rcm_handle_t *, char *, uint_t, rcm_info_t **); +int rcm_notify_online_list(rcm_handle_t *, char **, uint_t, rcm_info_t **); +int rcm_notify_remove(rcm_handle_t *, char *, uint_t, rcm_info_t **); +int rcm_notify_remove_list(rcm_handle_t *, char **, uint_t, rcm_info_t **); +int rcm_request_suspend(rcm_handle_t *, char *, uint_t, timespec_t *, + rcm_info_t **); +int rcm_request_suspend_list(rcm_handle_t *, char **, uint_t, timespec_t *, + rcm_info_t **); +int rcm_notify_resume(rcm_handle_t *, char *, uint_t, rcm_info_t **); +int rcm_notify_resume_list(rcm_handle_t *, char **, uint_t, rcm_info_t **); +int rcm_notify_capacity_change(rcm_handle_t *, char *, uint_t, nvlist_t *, + rcm_info_t **); +int rcm_request_capacity_change(rcm_handle_t *, char *, uint_t, nvlist_t *, + rcm_info_t **); +int rcm_notify_event(rcm_handle_t *, char *, uint_t, nvlist_t *, rcm_info_t **); + +int rcm_register_event(rcm_handle_t *, char *, uint_t, rcm_info_t **); +int rcm_register_capacity(rcm_handle_t *, char *, uint_t, rcm_info_t **); +int rcm_register_interest(rcm_handle_t *, char *, uint_t, rcm_info_t **); +int rcm_unregister_event(rcm_handle_t *, char *, uint_t); +int rcm_unregister_capacity(rcm_handle_t *, char *, uint_t); +int rcm_unregister_interest(rcm_handle_t *, char *, uint_t); + +int rcm_get_rsrcstate(rcm_handle_t *, char *, int *); +int rcm_exec_cmd(char *); +const char *rcm_get_client_name(rcm_handle_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBRCM_H */ diff --git a/illumos-x86_64/usr/include/libscf.h b/illumos-x86_64/usr/include/libscf.h new file mode 100644 index 00000000..b2730eb8 --- /dev/null +++ b/illumos-x86_64/usr/include/libscf.h @@ -0,0 +1,889 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 RackTop Systems. + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _LIBSCF_H +#define _LIBSCF_H + + +#include +#include + +#ifndef NATIVE_BUILD +#include +#endif /* NATIVE_BUILD */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned long scf_version_t; +#define SCF_VERSION 1UL + +/* + * Opaque structures + */ +typedef struct scf_handle scf_handle_t; +typedef struct scf_scope scf_scope_t; +typedef struct scf_service scf_service_t; +typedef struct scf_instance scf_instance_t; +typedef struct scf_propertygroup scf_propertygroup_t; +typedef struct scf_property scf_property_t; + +typedef struct scf_snapshot scf_snapshot_t; +typedef struct scf_snaplevel scf_snaplevel_t; + +typedef struct scf_transaction scf_transaction_t; +typedef struct scf_transaction_entry scf_transaction_entry_t; +typedef struct scf_value scf_value_t; + +typedef struct scf_iter scf_iter_t; + +typedef struct scf_pg_tmpl scf_pg_tmpl_t; +typedef struct scf_prop_tmpl scf_prop_tmpl_t; +typedef struct scf_tmpl_errors scf_tmpl_errors_t; + +typedef struct scf_simple_app_props scf_simple_app_props_t; +typedef struct scf_simple_prop scf_simple_prop_t; + +/* + * Types + */ +typedef enum { + SCF_TYPE_INVALID = 0, + + SCF_TYPE_BOOLEAN, + SCF_TYPE_COUNT, + SCF_TYPE_INTEGER, + SCF_TYPE_TIME, + SCF_TYPE_ASTRING, + SCF_TYPE_OPAQUE, + + SCF_TYPE_USTRING = 100, + + SCF_TYPE_URI = 200, + SCF_TYPE_FMRI, + + SCF_TYPE_HOST = 300, + SCF_TYPE_HOSTNAME, + SCF_TYPE_NET_ADDR_V4, + SCF_TYPE_NET_ADDR_V6, + SCF_TYPE_NET_ADDR +} scf_type_t; + +/* + * Values returned by scf_type_to_string + */ +#define SCF_TYPE_STRING_BOOLEAN "boolean" +#define SCF_TYPE_STRING_COUNT "count" +#define SCF_TYPE_STRING_INTEGER "integer" +#define SCF_TYPE_STRING_TIME "time" +#define SCF_TYPE_STRING_ASTRING "astring" +#define SCF_TYPE_STRING_OPAQUE "opaque" +#define SCF_TYPE_STRING_USTRING "ustring" +#define SCF_TYPE_STRING_URI "uri" +#define SCF_TYPE_STRING_FMRI "fmri" +#define SCF_TYPE_STRING_HOST "host" +#define SCF_TYPE_STRING_HOSTNAME "hostname" +#define SCF_TYPE_STRING_NET_ADDR "net_address" +#define SCF_TYPE_STRING_NET_ADDR_V4 "net_address_v4" +#define SCF_TYPE_STRING_NET_ADDR_V6 "net_address_v6" + +typedef struct scf_time { + int64_t t_seconds; + int32_t t_ns; +} scf_time_t; + +/* + * There is no explicit initializer for this structure. Functions + * which set or populate this structure assume that it is either + * uninitialized or destroyed. + */ +typedef struct scf_values { + scf_type_t value_type; + void *reserved; /* reserved for future use */ + int value_count; + char **values_as_strings; + union { + uint64_t *v_count; + uint8_t *v_boolean; + int64_t *v_integer; + char **v_astring; + char **v_ustring; + char **v_opaque; + scf_time_t *v_time; + } values; +} scf_values_t; + +typedef struct scf_count_ranges { + int scr_num_ranges; + uint64_t *scr_min; + uint64_t *scr_max; +} scf_count_ranges_t; + +typedef struct scf_int_ranges { + int sir_num_ranges; + int64_t *sir_min; + int64_t *sir_max; +} scf_int_ranges_t; + +/* + * Return codes + */ +#define SCF_SUCCESS 0 +#define SCF_COMPLETE 1 +#define SCF_FAILED -1 + +typedef enum scf_error { + SCF_ERROR_NONE = 1000, /* no error */ + SCF_ERROR_NOT_BOUND, /* handle not bound */ + SCF_ERROR_NOT_SET, /* cannot use unset argument */ + SCF_ERROR_NOT_FOUND, /* nothing of that name found */ + SCF_ERROR_TYPE_MISMATCH, /* type does not match value */ + SCF_ERROR_IN_USE, /* cannot modify while in-use */ + SCF_ERROR_CONNECTION_BROKEN, /* repository connection gone */ + SCF_ERROR_INVALID_ARGUMENT, /* bad argument */ + SCF_ERROR_NO_MEMORY, /* no memory available */ + SCF_ERROR_CONSTRAINT_VIOLATED, /* required constraint not met */ + SCF_ERROR_EXISTS, /* object already exists */ + SCF_ERROR_NO_SERVER, /* repository server unavailable */ + SCF_ERROR_NO_RESOURCES, /* server has insufficient resources */ + SCF_ERROR_PERMISSION_DENIED, /* insufficient privileges for action */ + SCF_ERROR_BACKEND_ACCESS, /* backend refused access */ + SCF_ERROR_HANDLE_MISMATCH, /* mismatched SCF handles */ + SCF_ERROR_HANDLE_DESTROYED, /* object bound to destroyed handle */ + SCF_ERROR_VERSION_MISMATCH, /* incompatible SCF version */ + SCF_ERROR_BACKEND_READONLY, /* backend is read-only */ + SCF_ERROR_DELETED, /* object has been deleted */ + SCF_ERROR_TEMPLATE_INVALID, /* template data is invalid */ + + SCF_ERROR_CALLBACK_FAILED = 1080, /* user callback function failed */ + + SCF_ERROR_INTERNAL = 1101 /* internal error */ +} scf_error_t; + +/* + * This enum MUST be kept in sync with + * struct _scf_tmpl_error_desc em_desc() in scf_tmpl.c + */ +typedef enum scf_tmpl_error_type { + SCF_TERR_MISSING_PG, /* property group missing */ + SCF_TERR_WRONG_PG_TYPE, /* property group type incorrect */ + SCF_TERR_MISSING_PROP, /* missing required property */ + SCF_TERR_WRONG_PROP_TYPE, /* property type incorrect */ + SCF_TERR_CARDINALITY_VIOLATION, /* wrong number of values */ + SCF_TERR_VALUE_CONSTRAINT_VIOLATED, /* constraint violated for value */ + SCF_TERR_RANGE_VIOLATION, /* value violated specified range */ + SCF_TERR_PG_REDEFINE, /* global or restarter pg_pattern */ + /* redefined by the instance */ + SCF_TERR_PROP_TYPE_MISMATCH, /* property and value type mismatch */ + SCF_TERR_VALUE_OUT_OF_RANGE, /* value is out of range in template */ + SCF_TERR_INVALID_VALUE, /* value is not valid for the */ + /* template */ + SCF_TERR_PG_PATTERN_CONFLICT, /* pg_pattern conflicts with higher */ + /* level definition */ + SCF_TERR_PROP_PATTERN_CONFLICT, /* prop_pattern conflicts with higher */ + /* level definition */ + SCF_TERR_GENERAL_REDEFINE, /* global or restarter template */ + /* redefined */ + SCF_TERR_INCLUDE_VALUES, /* No supporting constraints or */ + /* values for include_values */ + SCF_TERR_PG_PATTERN_INCOMPLETE, /* Required pg_pattern is missing */ + /* name or type attribute. */ + SCF_TERR_PROP_PATTERN_INCOMPLETE /* Required prop_pattern is */ + /* missing a type attribute. */ +} scf_tmpl_error_type_t; + +typedef struct scf_tmpl_error scf_tmpl_error_t; + +/* + * This unfortunately needs to be public, because consumers of librestart must + * deal with it + */ +typedef struct { +#ifndef NATIVE_BUILD + secflagdelta_t ss_default; + secflagdelta_t ss_lower; + secflagdelta_t ss_upper; +#else + /* + * This is never used, but is necessary for bootstrapping. + * Not even the size matters. + */ + void *ss_default; + void *ss_lower; + void *ss_upper; +#endif /* NATIVE_BUILD */ +} scf_secflags_t; + +/* + * scf_tmpl_strerror() human readable flag + */ +#define SCF_TMPL_STRERROR_HUMAN 0x1 + +/* + * Standard services + */ +#define SCF_SERVICE_CONFIGD "svc:/system/svc/repository:default" +#define SCF_INSTANCE_GLOBAL "svc:/system/svc/global:default" +#define SCF_SERVICE_GLOBAL "svc:/system/svc/global" +#define SCF_SERVICE_STARTD "svc:/system/svc/restarter:default" +#define SCF_INSTANCE_EMI "svc:/system/early-manifest-import:default" +#define SCF_INSTANCE_FS_MINIMAL "svc:/system/filesystem/minimal:default" +#define SCF_INSTANCE_MI "svc:/system/manifest-import:default" + +/* + * Major milestones + */ +#define SCF_MILESTONE_SINGLE_USER "svc:/milestone/single-user:default" +#define SCF_MILESTONE_MULTI_USER "svc:/milestone/multi-user:default" +#define SCF_MILESTONE_MULTI_USER_SERVER \ + "svc:/milestone/multi-user-server:default" + +/* + * standard scope names + */ +#define SCF_SCOPE_LOCAL "localhost" + +/* + * Property group types + */ +#define SCF_GROUP_APPLICATION "application" +#define SCF_GROUP_FRAMEWORK "framework" +#define SCF_GROUP_DEPENDENCY "dependency" +#define SCF_GROUP_METHOD "method" +#define SCF_GROUP_TEMPLATE "template" +#define SCF_GROUP_TEMPLATE_PG_PATTERN "template_pg_pattern" +#define SCF_GROUP_TEMPLATE_PROP_PATTERN "template_prop_pattern" + +/* + * Dependency types + */ +#define SCF_DEP_REQUIRE_ALL "require_all" +#define SCF_DEP_REQUIRE_ANY "require_any" +#define SCF_DEP_EXCLUDE_ALL "exclude_all" +#define SCF_DEP_OPTIONAL_ALL "optional_all" + +#define SCF_DEP_RESET_ON_ERROR "error" +#define SCF_DEP_RESET_ON_RESTART "restart" +#define SCF_DEP_RESET_ON_REFRESH "refresh" +#define SCF_DEP_RESET_ON_NONE "none" + +/* + * Standard property group names + */ +#define SCF_PG_GENERAL "general" +#define SCF_PG_GENERAL_OVR "general_ovr" +#define SCF_PG_RESTARTER "restarter" +#define SCF_PG_RESTARTER_ACTIONS "restarter_actions" +#define SCF_PG_METHOD_CONTEXT "method_context" +#define SCF_PG_APP_DEFAULT "application" +#define SCF_PG_DEPENDENTS "dependents" +#define SCF_PG_OPTIONS "options" +#define SCF_PG_OPTIONS_OVR "options_ovr" +#define SCF_PG_STARTD "startd" +#define SCF_PG_STARTD_PRIVATE "svc-startd-private" +#define SCF_PG_DEATHROW "deathrow" +#define SCF_PG_MANIFESTFILES "manifestfiles" + +/* + * Template property group names and prefixes + */ +#define SCF_PG_TM_COMMON_NAME "tm_common_name" +#define SCF_PG_TM_DESCRIPTION "tm_description" + +#define SCF_PG_TM_MAN_PREFIX "tm_man_" +#define SCF_PG_TM_DOC_PREFIX "tm_doc_" + +/* + * Standard property names + */ +#define SCF_PROPERTY_ACTIVE_POSTFIX "active" +#define SCF_PROPERTY_AUX_STATE "auxiliary_state" +#define SCF_PROPERTY_AUX_FMRI "auxiliary_fmri" +#define SCF_PROPERTY_AUX_TTY "auxiliary_tty" +#define SCF_PROPERTY_COMMENT "comment" +#define SCF_PROPERTY_CONTRACT "contract" +#define SCF_PROPERTY_COREFILE_PATTERN "corefile_pattern" +#define SCF_PROPERTY_DEGRADED "degraded" +#define SCF_PROPERTY_DEGRADE_IMMEDIATE "degrade_immediate" +#define SCF_PROPERTY_DODUMP "do_dump" +#define SCF_PROPERTY_DURATION "duration" +#define SCF_PROPERTY_ENABLED "enabled" +#define SCF_PROPERTY_DEATHROW "deathrow" +#define SCF_PROPERTY_ENTITY_STABILITY "entity_stability" +#define SCF_PROPERTY_ENTITIES "entities" +#define SCF_PROPERTY_EXEC "exec" +#define SCF_PROPERTY_GROUP "group" +#define SCF_PROPERTY_GROUPING "grouping" +#define SCF_PROPERTY_IGNORE "ignore_error" +#define SCF_PROPERTY_INTERNAL_SEPARATORS "internal_separators" +#define SCF_PROPERTY_LIMIT_PRIVILEGES "limit_privileges" +#define SCF_PROPERTY_MAINT_OFF "maint_off" +#define SCF_PROPERTY_MAINT_ON "maint_on" +#define SCF_PROPERTY_MAINT_ON_IMMEDIATE "maint_on_immediate" +#define SCF_PROPERTY_MAINT_ON_IMMTEMP "maint_on_immtemp" +#define SCF_PROPERTY_MAINT_ON_TEMPORARY "maint_on_temporary" +#define SCF_PROPERTY_METHOD_PID "method_pid" +#define SCF_PROPERTY_MILESTONE "milestone" +#define SCF_PROPERTY_NEED_SESSION "need_session" +#define SCF_PROPERTY_NEXT_STATE "next_state" +#define SCF_PROPERTY_PACKAGE "package" +#define SCF_PROPERTY_PRIVILEGES "privileges" +#define SCF_PROPERTY_PROFILE "profile" +#define SCF_PROPERTY_PROJECT "project" +#define SCF_PROPERTY_REFRESH "refresh" +#define SCF_PROPERTY_RESOURCE_POOL "resource_pool" +#define SCF_PROPERTY_ENVIRONMENT "environment" +#define SCF_PROPERTY_RESTART "restart" +#define SCF_PROPERTY_RESTARTER "restarter" +#define SCF_PROPERTY_RESTART_INTERVAL "restart_interval" +#define SCF_PROPERTY_RESTART_ON "restart_on" +#define SCF_PROPERTY_RESTORE "restore" +#define SCF_PROPERTY_SECFLAGS "security_flags" +#define SCF_PROPERTY_SINGLE_INSTANCE "single_instance" +#define SCF_PROPERTY_START_METHOD_TIMESTAMP "start_method_timestamp" +#define SCF_PROPERTY_START_METHOD_WAITSTATUS "start_method_waitstatus" +#define SCF_PROPERTY_START_PID "start_pid" +#define SCF_PROPERTY_STATE "state" +#define SCF_PROPERTY_STABILITY "stability" +#define SCF_PROPERTY_STATE_TIMESTAMP "state_timestamp" +#define SCF_PROPERTY_SUPP_GROUPS "supp_groups" +#define SCF_PROPERTY_TIMEOUT "timeout_seconds" +#define SCF_PROPERTY_TIMEOUT_RETRY "timeout_retry" +#define SCF_PROPERTY_TRANSIENT_CONTRACT "transient_contract" +#define SCF_PROPERTY_TYPE "type" +#define SCF_PROPERTY_USE_PROFILE "use_profile" +#define SCF_PROPERTY_USER "user" +#define SCF_PROPERTY_UTMPX_PREFIX "utmpx_prefix" +#define SCF_PROPERTY_WORKING_DIRECTORY "working_directory" + +/* + * Template property names + */ +#define SCF_PROPERTY_TM_CARDINALITY_MIN "cardinality_min" +#define SCF_PROPERTY_TM_CARDINALITY_MAX "cardinality_max" +#define SCF_PROPERTY_TM_CHOICES_INCLUDE_VALUES "choices_include_values" +#define SCF_PROPERTY_TM_CHOICES_NAME "choices_name" +#define SCF_PROPERTY_TM_CHOICES_RANGE "choices_range" +#define SCF_PROPERTY_TM_CONSTRAINT_NAME "constraint_name" +#define SCF_PROPERTY_TM_CONSTRAINT_RANGE "constraint_range" +#define SCF_PROPERTY_TM_MANPATH "manpath" +#define SCF_PROPERTY_TM_NAME "name" +#define SCF_PROPERTY_TM_PG_PATTERN "pg_pattern" +#define SCF_PROPERTY_TM_REQUIRED "required" +#define SCF_PROPERTY_TM_SECTION "section" +#define SCF_PROPERTY_TM_TARGET "target" +#define SCF_PROPERTY_TM_TITLE "title" +#define SCF_PROPERTY_TM_TYPE "type" +#define SCF_PROPERTY_TM_URI "uri" +#define SCF_PROPERTY_TM_VALUE_PREFIX "value_" +#define SCF_PROPERTY_TM_VALUES_NAME "values_name" +#define SCF_PROPERTY_TM_VISIBILITY "visibility" +#define SCF_PROPERTY_TM_COMMON_NAME_PREFIX "common_name_" +#define SCF_PROPERTY_TM_DESCRIPTION_PREFIX "description_" +#define SCF_PROPERTY_TM_UNITS_PREFIX "units_" + +/* + * Templates wildcard string + */ +#define SCF_TMPL_WILDCARD "*" + +/* + * Strings used by restarters for state and next_state properties. + * MAX_SCF_STATE_STRING holds the max length of a state string, including the + * terminating null. + */ + +#define MAX_SCF_STATE_STRING_SZ 14 + +#define SCF_STATE_STRING_NONE "none" +#define SCF_STATE_STRING_UNINIT "uninitialized" +#define SCF_STATE_STRING_MAINT "maintenance" +#define SCF_STATE_STRING_OFFLINE "offline" +#define SCF_STATE_STRING_DISABLED "disabled" +#define SCF_STATE_STRING_ONLINE "online" +#define SCF_STATE_STRING_DEGRADED "degraded" +#define SCF_STATE_STRING_LEGACY "legacy_run" + +#define SCF_STATE_UNINIT 0x00000001 +#define SCF_STATE_MAINT 0x00000002 +#define SCF_STATE_OFFLINE 0x00000004 +#define SCF_STATE_DISABLED 0x00000008 +#define SCF_STATE_ONLINE 0x00000010 +#define SCF_STATE_DEGRADED 0x00000020 +#define SCF_STATE_ALL 0x0000003F + +/* + * software fma svc-transition class + */ +#define SCF_NOTIFY_PARAMS_VERSION 0X0 +#define SCF_NOTIFY_NAME_FMRI "fmri" +#define SCF_NOTIFY_NAME_VERSION "version" +#define SCF_NOTIFY_NAME_TSET "tset" +#define SCF_NOTIFY_PG_POSTFIX "fmnotify" +#define SCF_NOTIFY_PARAMS "notify-params" +#define SCF_NOTIFY_PARAMS_INST "svc:/system/fm/notify-params:default" +#define SCF_SVC_TRANSITION_CLASS "ireport.os.smf.state-transition" +#define SCF_NOTIFY_PARAMS_PG_TYPE "notify_params" + +/* + * Useful transition macros + */ +#define SCF_TRANS_SHIFT_INITIAL_STATE(s) ((s) << 16) +#define SCF_TRANSITION_ALL \ + (SCF_TRANS_SHIFT_INITIAL_STATE(SCF_STATE_ALL) | SCF_STATE_ALL) +#define SCF_TRANS(f, t) (SCF_TRANS_SHIFT_INITIAL_STATE(f) | (t)) +#define SCF_TRANS_VALID(t) (!((t) & ~SCF_TRANSITION_ALL)) +#define SCF_TRANS_INITIAL_STATE(t) ((t) >> 16 & SCF_STATE_ALL) +#define SCF_TRANS_FINAL_STATE(t) ((t) & SCF_STATE_ALL) + +/* + * Prefixes for states in state transition notification + */ +#define SCF_STN_PREFIX_FROM "from-" +#define SCF_STN_PREFIX_TO "to-" + +#define SCF_PG_FLAG_NONPERSISTENT 0x1 + +#define SCF_TRACE_LIBRARY 0x1 +#define SCF_TRACE_DAEMON 0x2 + +#define SMF_IMMEDIATE 0x1 +#define SMF_TEMPORARY 0x2 +#define SMF_AT_NEXT_BOOT 0x4 + +scf_error_t scf_error(void); +const char *scf_strerror(scf_error_t); + +ssize_t scf_limit(uint32_t code); +#define SCF_LIMIT_MAX_NAME_LENGTH -2000U +#define SCF_LIMIT_MAX_VALUE_LENGTH -2001U +#define SCF_LIMIT_MAX_PG_TYPE_LENGTH -2002U +#define SCF_LIMIT_MAX_FMRI_LENGTH -2003U + + +#define SCF_COMMENT_MAX_LENGTH (1024) + +scf_handle_t *scf_handle_create(scf_version_t); + +int scf_handle_decorate(scf_handle_t *, const char *, scf_value_t *); +#define SCF_DECORATE_CLEAR ((scf_value_t *)0) + +int scf_handle_bind(scf_handle_t *); +int scf_handle_unbind(scf_handle_t *); +void scf_handle_destroy(scf_handle_t *); + +int scf_type_base_type(scf_type_t type, scf_type_t *out); +const char *scf_type_to_string(scf_type_t); +scf_type_t scf_string_to_type(const char *); + +/* values */ +scf_value_t *scf_value_create(scf_handle_t *); +scf_handle_t *scf_value_handle(const scf_value_t *); +void scf_value_destroy(scf_value_t *); + +scf_type_t scf_value_base_type(const scf_value_t *); +scf_type_t scf_value_type(const scf_value_t *); +int scf_value_is_type(const scf_value_t *, scf_type_t); + +void scf_value_reset(scf_value_t *); + +int scf_value_get_boolean(const scf_value_t *, uint8_t *); +int scf_value_get_count(const scf_value_t *, uint64_t *); +int scf_value_get_integer(const scf_value_t *, int64_t *); +int scf_value_get_time(const scf_value_t *, int64_t *, int32_t *); +ssize_t scf_value_get_astring(const scf_value_t *, char *, size_t); +ssize_t scf_value_get_ustring(const scf_value_t *, char *, size_t); +ssize_t scf_value_get_opaque(const scf_value_t *, void *, size_t); + +void scf_value_set_boolean(scf_value_t *, uint8_t); +void scf_value_set_count(scf_value_t *, uint64_t); +void scf_value_set_integer(scf_value_t *, int64_t); +int scf_value_set_time(scf_value_t *, int64_t, int32_t); +int scf_value_set_astring(scf_value_t *, const char *); +int scf_value_set_ustring(scf_value_t *, const char *); +int scf_value_set_opaque(scf_value_t *, const void *, size_t); + +ssize_t scf_value_get_as_string(const scf_value_t *, char *, size_t); +ssize_t scf_value_get_as_string_typed(const scf_value_t *, scf_type_t, + char *, size_t); +int scf_value_set_from_string(scf_value_t *, scf_type_t, const char *); + +scf_iter_t *scf_iter_create(scf_handle_t *); +scf_handle_t *scf_iter_handle(const scf_iter_t *); +void scf_iter_reset(scf_iter_t *); +void scf_iter_destroy(scf_iter_t *); + +int scf_iter_handle_scopes(scf_iter_t *, const scf_handle_t *); +int scf_iter_scope_services(scf_iter_t *, const scf_scope_t *); +int scf_iter_service_instances(scf_iter_t *, const scf_service_t *); +int scf_iter_service_pgs(scf_iter_t *, const scf_service_t *); +int scf_iter_instance_pgs(scf_iter_t *, const scf_instance_t *); +int scf_iter_instance_pgs_composed(scf_iter_t *, const scf_instance_t *, + const scf_snapshot_t *); +int scf_iter_service_pgs_typed(scf_iter_t *, const scf_service_t *, + const char *); +int scf_iter_instance_pgs_typed(scf_iter_t *, const scf_instance_t *, + const char *); +int scf_iter_instance_pgs_typed_composed(scf_iter_t *, const scf_instance_t *, + const scf_snapshot_t *, const char *); +int scf_iter_snaplevel_pgs(scf_iter_t *, const scf_snaplevel_t *); +int scf_iter_snaplevel_pgs_typed(scf_iter_t *, const scf_snaplevel_t *, + const char *); +int scf_iter_instance_snapshots(scf_iter_t *, const scf_instance_t *); +int scf_iter_pg_properties(scf_iter_t *, const scf_propertygroup_t *); +int scf_iter_property_values(scf_iter_t *, const scf_property_t *); + +int scf_iter_next_scope(scf_iter_t *, scf_scope_t *); +int scf_iter_next_service(scf_iter_t *, scf_service_t *); +int scf_iter_next_instance(scf_iter_t *, scf_instance_t *); +int scf_iter_next_pg(scf_iter_t *, scf_propertygroup_t *); +int scf_iter_next_property(scf_iter_t *, scf_property_t *); +int scf_iter_next_snapshot(scf_iter_t *, scf_snapshot_t *); +int scf_iter_next_value(scf_iter_t *, scf_value_t *); + +scf_scope_t *scf_scope_create(scf_handle_t *); +scf_handle_t *scf_scope_handle(const scf_scope_t *); + +/* XXX eventually remove this */ +#define scf_handle_get_local_scope(h, s) \ + scf_handle_get_scope((h), SCF_SCOPE_LOCAL, (s)) + +int scf_handle_get_scope(scf_handle_t *, const char *, scf_scope_t *); +void scf_scope_destroy(scf_scope_t *); +ssize_t scf_scope_get_name(const scf_scope_t *, char *, size_t); + +ssize_t scf_scope_to_fmri(const scf_scope_t *, char *, size_t); + +scf_service_t *scf_service_create(scf_handle_t *); +scf_handle_t *scf_service_handle(const scf_service_t *); +void scf_service_destroy(scf_service_t *); +int scf_scope_get_parent(const scf_scope_t *, scf_scope_t *); +ssize_t scf_service_get_name(const scf_service_t *, char *, size_t); +ssize_t scf_service_to_fmri(const scf_service_t *, char *, size_t); +int scf_service_get_parent(const scf_service_t *, scf_scope_t *); +int scf_scope_get_service(const scf_scope_t *, const char *, scf_service_t *); +int scf_scope_add_service(const scf_scope_t *, const char *, scf_service_t *); +int scf_service_delete(scf_service_t *); + +scf_instance_t *scf_instance_create(scf_handle_t *); +scf_handle_t *scf_instance_handle(const scf_instance_t *); +void scf_instance_destroy(scf_instance_t *); +ssize_t scf_instance_get_name(const scf_instance_t *, char *, size_t); +ssize_t scf_instance_to_fmri(const scf_instance_t *, char *, size_t); +int scf_service_get_instance(const scf_service_t *, const char *, + scf_instance_t *); +int scf_service_add_instance(const scf_service_t *, const char *, + scf_instance_t *); +int scf_instance_delete(scf_instance_t *); + +scf_snapshot_t *scf_snapshot_create(scf_handle_t *); +scf_handle_t *scf_snapshot_handle(const scf_snapshot_t *); +void scf_snapshot_destroy(scf_snapshot_t *); +ssize_t scf_snapshot_get_name(const scf_snapshot_t *, char *, size_t); +int scf_snapshot_get_parent(const scf_snapshot_t *, scf_instance_t *); +int scf_instance_get_snapshot(const scf_instance_t *, const char *, + scf_snapshot_t *); +int scf_snapshot_update(scf_snapshot_t *); + +scf_snaplevel_t *scf_snaplevel_create(scf_handle_t *); +scf_handle_t *scf_snaplevel_handle(const scf_snaplevel_t *); +void scf_snaplevel_destroy(scf_snaplevel_t *); +int scf_snaplevel_get_parent(const scf_snaplevel_t *, scf_snapshot_t *); +ssize_t scf_snaplevel_get_scope_name(const scf_snaplevel_t *, char *, size_t); +ssize_t scf_snaplevel_get_service_name(const scf_snaplevel_t *, char *, size_t); +ssize_t scf_snaplevel_get_instance_name(const scf_snaplevel_t *, char *, + size_t); +int scf_snaplevel_get_pg(const scf_snaplevel_t *, const char *, + scf_propertygroup_t *pg); +int scf_snapshot_get_base_snaplevel(const scf_snapshot_t *, scf_snaplevel_t *); +int scf_snaplevel_get_next_snaplevel(const scf_snaplevel_t *, + scf_snaplevel_t *); + +scf_propertygroup_t *scf_pg_create(scf_handle_t *); +scf_handle_t *scf_pg_handle(const scf_propertygroup_t *); +void scf_pg_destroy(scf_propertygroup_t *); +ssize_t scf_pg_to_fmri(const scf_propertygroup_t *, char *, size_t); +ssize_t scf_pg_get_name(const scf_propertygroup_t *, char *, size_t); +ssize_t scf_pg_get_type(const scf_propertygroup_t *, char *, size_t); +int scf_pg_get_flags(const scf_propertygroup_t *, uint32_t *); +int scf_pg_get_parent_service(const scf_propertygroup_t *, scf_service_t *); +int scf_pg_get_parent_instance(const scf_propertygroup_t *, scf_instance_t *); +int scf_pg_get_parent_snaplevel(const scf_propertygroup_t *, scf_snaplevel_t *); +int scf_service_get_pg(const scf_service_t *, const char *, + scf_propertygroup_t *); +int scf_instance_get_pg(const scf_instance_t *, const char *, + scf_propertygroup_t *); +int scf_instance_get_pg_composed(const scf_instance_t *, const scf_snapshot_t *, + const char *, scf_propertygroup_t *); +int scf_service_add_pg(const scf_service_t *, const char *, const char *, + uint32_t, scf_propertygroup_t *); +int scf_instance_add_pg(const scf_instance_t *, const char *, const char *, + uint32_t, scf_propertygroup_t *); +int scf_pg_delete(scf_propertygroup_t *); + +int scf_pg_get_underlying_pg(const scf_propertygroup_t *, + scf_propertygroup_t *); +int scf_instance_get_parent(const scf_instance_t *, scf_service_t *); + +int scf_pg_update(scf_propertygroup_t *); + +scf_property_t *scf_property_create(scf_handle_t *); +scf_handle_t *scf_property_handle(const scf_property_t *); +void scf_property_destroy(scf_property_t *); +int scf_property_is_type(const scf_property_t *, scf_type_t); +int scf_property_type(const scf_property_t *, scf_type_t *); +ssize_t scf_property_get_name(const scf_property_t *, char *, size_t); +int scf_property_get_value(const scf_property_t *, scf_value_t *); +ssize_t scf_property_to_fmri(const scf_property_t *, char *, size_t); +int scf_pg_get_property(const scf_propertygroup_t *, const char *, + scf_property_t *); + +scf_transaction_t *scf_transaction_create(scf_handle_t *); +scf_handle_t *scf_transaction_handle(const scf_transaction_t *); +int scf_transaction_start(scf_transaction_t *, scf_propertygroup_t *); +void scf_transaction_destroy(scf_transaction_t *); +void scf_transaction_destroy_children(scf_transaction_t *); + +void scf_transaction_reset(scf_transaction_t *); +void scf_transaction_reset_all(scf_transaction_t *); + +int scf_transaction_commit(scf_transaction_t *); + +scf_transaction_entry_t *scf_entry_create(scf_handle_t *); +scf_handle_t *scf_entry_handle(const scf_transaction_entry_t *); +void scf_entry_reset(scf_transaction_entry_t *); +void scf_entry_destroy(scf_transaction_entry_t *); +void scf_entry_destroy_children(scf_transaction_entry_t *); + +int scf_transaction_property_change(scf_transaction_t *, + scf_transaction_entry_t *, const char *, scf_type_t); +int scf_transaction_property_delete(scf_transaction_t *, + scf_transaction_entry_t *, const char *); +int scf_transaction_property_new(scf_transaction_t *, + scf_transaction_entry_t *, const char *, scf_type_t); +int scf_transaction_property_change_type(scf_transaction_t *, + scf_transaction_entry_t *, const char *, scf_type_t); + +int scf_entry_add_value(scf_transaction_entry_t *, scf_value_t *); + +int scf_handle_decode_fmri(scf_handle_t *, const char *, scf_scope_t *, + scf_service_t *, scf_instance_t *, scf_propertygroup_t *, scf_property_t *, + int); +#define SCF_DECODE_FMRI_EXACT 0x00000001 +#define SCF_DECODE_FMRI_TRUNCATE 0x00000002 +#define SCF_DECODE_FMRI_REQUIRE_INSTANCE 0x00000004 +#define SCF_DECODE_FMRI_REQUIRE_NO_INSTANCE 0x00000008 + +ssize_t scf_myname(scf_handle_t *, char *, size_t); + +/* + * Property group template interfaces. + */ +scf_pg_tmpl_t *scf_tmpl_pg_create(scf_handle_t *); +void scf_tmpl_pg_destroy(scf_pg_tmpl_t *); +void scf_tmpl_pg_reset(scf_pg_tmpl_t *); +int scf_tmpl_get_by_pg(scf_propertygroup_t *, scf_pg_tmpl_t *, int); +int scf_tmpl_get_by_pg_name(const char *, const char *, + const char *, const char *, scf_pg_tmpl_t *, int); +int scf_tmpl_iter_pgs(scf_pg_tmpl_t *, const char *, const char *, + const char *, int); +#define SCF_PG_TMPL_FLAG_REQUIRED 0x1 +#define SCF_PG_TMPL_FLAG_EXACT 0x2 +#define SCF_PG_TMPL_FLAG_CURRENT 0x4 + +ssize_t scf_tmpl_pg_name(const scf_pg_tmpl_t *, char **); +ssize_t scf_tmpl_pg_common_name(const scf_pg_tmpl_t *, const char *, char **); +ssize_t scf_tmpl_pg_description(const scf_pg_tmpl_t *, const char *, char **); +ssize_t scf_tmpl_pg_type(const scf_pg_tmpl_t *, char **); + +ssize_t scf_tmpl_pg_target(const scf_pg_tmpl_t *, char **); +#define SCF_TM_TARGET_ALL ((const char *)"all") +#define SCF_TM_TARGET_DELEGATE ((const char *)"delegate") +#define SCF_TM_TARGET_INSTANCE ((const char *)"instance") +#define SCF_TM_TARGET_THIS ((const char *)"this") + +int scf_tmpl_pg_required(const scf_pg_tmpl_t *, uint8_t *); + +/* + * Property template interfaces. + */ +scf_prop_tmpl_t *scf_tmpl_prop_create(scf_handle_t *); +void scf_tmpl_prop_destroy(scf_prop_tmpl_t *); +void scf_tmpl_prop_reset(scf_prop_tmpl_t *); +int scf_tmpl_get_by_prop(scf_pg_tmpl_t *, const char *, + scf_prop_tmpl_t *, int); +int scf_tmpl_iter_props(scf_pg_tmpl_t *, scf_prop_tmpl_t *, int); +#define SCF_PROP_TMPL_FLAG_REQUIRED 0x1 + +ssize_t scf_tmpl_prop_name(const scf_prop_tmpl_t *, char **); +int scf_tmpl_prop_type(const scf_prop_tmpl_t *, scf_type_t *); +int scf_tmpl_prop_required(const scf_prop_tmpl_t *, uint8_t *); +ssize_t scf_tmpl_prop_common_name(const scf_prop_tmpl_t *, const char *, + char **); +ssize_t scf_tmpl_prop_description(const scf_prop_tmpl_t *, const char *, + char **); +ssize_t scf_tmpl_prop_units(const scf_prop_tmpl_t *, const char *, char **); +int scf_tmpl_prop_cardinality(const scf_prop_tmpl_t *prop, uint64_t *, + uint64_t *); +int scf_tmpl_prop_internal_seps(const scf_prop_tmpl_t *, scf_values_t *); + +int scf_tmpl_prop_visibility(const scf_prop_tmpl_t *, uint8_t *); +#define SCF_TMPL_VISIBILITY_HIDDEN 1 +#define SCF_TMPL_VISIBILITY_READONLY 2 +#define SCF_TMPL_VISIBILITY_READWRITE 3 + +const char *scf_tmpl_visibility_to_string(uint8_t); +#define SCF_TM_VISIBILITY_HIDDEN ((const char *)"hidden") +#define SCF_TM_VISIBILITY_READONLY ((const char *)"readonly") +#define SCF_TM_VISIBILITY_READWRITE ((const char *)"readwrite") + +int scf_tmpl_value_name_constraints(const scf_prop_tmpl_t *prop, + scf_values_t *vals); +void scf_count_ranges_destroy(scf_count_ranges_t *); +void scf_int_ranges_destroy(scf_int_ranges_t *); +int scf_tmpl_value_count_range_constraints(const scf_prop_tmpl_t *, + scf_count_ranges_t *); +int scf_tmpl_value_int_range_constraints(const scf_prop_tmpl_t *, + scf_int_ranges_t *); +int scf_tmpl_value_count_range_choices(const scf_prop_tmpl_t *, + scf_count_ranges_t *); +int scf_tmpl_value_int_range_choices(const scf_prop_tmpl_t *, + scf_int_ranges_t *); +int scf_tmpl_value_name_choices(const scf_prop_tmpl_t *prop, + scf_values_t *vals); + +void scf_values_destroy(scf_values_t *); + +ssize_t scf_tmpl_value_common_name(const scf_prop_tmpl_t *, const char *, + const char *, char **); +ssize_t scf_tmpl_value_description(const scf_prop_tmpl_t *, const char *, + const char *, char **); + +int scf_tmpl_value_in_constraint(const scf_prop_tmpl_t *pt, scf_value_t *value, + scf_tmpl_errors_t **errs); + +/* + * Template validation interfaces + */ +int scf_tmpl_validate_fmri(scf_handle_t *, const char *, + const char *, scf_tmpl_errors_t **, int); +#define SCF_TMPL_VALIDATE_FLAG_CURRENT 0x1 + +void scf_tmpl_errors_destroy(scf_tmpl_errors_t *errs); +scf_tmpl_error_t *scf_tmpl_next_error(scf_tmpl_errors_t *); +void scf_tmpl_reset_errors(scf_tmpl_errors_t *errs); +int scf_tmpl_strerror(scf_tmpl_error_t *err, char *s, size_t n, int flag); +int scf_tmpl_error_source_fmri(const scf_tmpl_error_t *, char **); +int scf_tmpl_error_type(const scf_tmpl_error_t *, scf_tmpl_error_type_t *); +int scf_tmpl_error_pg_tmpl(const scf_tmpl_error_t *, char **, char **); +int scf_tmpl_error_pg(const scf_tmpl_error_t *, char **, char **); +int scf_tmpl_error_prop_tmpl(const scf_tmpl_error_t *, char **, char **); +int scf_tmpl_error_prop(const scf_tmpl_error_t *, char **, char **); +int scf_tmpl_error_value(const scf_tmpl_error_t *, char **); + +/* + * Simplified calls + */ +int smf_enable_instance(const char *, int); +int smf_disable_instance_with_comment(const char *, int, const char *); +int smf_disable_instance(const char *, int); +int smf_refresh_instance(const char *); +int smf_restart_instance(const char *); +int smf_maintain_instance(const char *, int); +int smf_degrade_instance(const char *, int); +int smf_restore_instance(const char *); +char *smf_get_state(const char *); + +int scf_simple_walk_instances(uint_t, void *, + int (*inst_callback)(scf_handle_t *, scf_instance_t *, void *)); + +scf_simple_prop_t *scf_simple_prop_get(scf_handle_t *, const char *, + const char *, const char *); +void scf_simple_prop_free(scf_simple_prop_t *); +scf_simple_app_props_t *scf_simple_app_props_get(scf_handle_t *, const char *); +void scf_simple_app_props_free(scf_simple_app_props_t *); +const scf_simple_prop_t *scf_simple_app_props_next( + const scf_simple_app_props_t *, scf_simple_prop_t *); +const scf_simple_prop_t *scf_simple_app_props_search( + const scf_simple_app_props_t *, const char *, const char *); +ssize_t scf_simple_prop_numvalues(const scf_simple_prop_t *); +scf_type_t scf_simple_prop_type(const scf_simple_prop_t *); +char *scf_simple_prop_name(const scf_simple_prop_t *); +char *scf_simple_prop_pgname(const scf_simple_prop_t *); +uint8_t *scf_simple_prop_next_boolean(scf_simple_prop_t *); +uint64_t *scf_simple_prop_next_count(scf_simple_prop_t *); +int64_t *scf_simple_prop_next_integer(scf_simple_prop_t *); +int64_t *scf_simple_prop_next_time(scf_simple_prop_t *, int32_t *); +char *scf_simple_prop_next_astring(scf_simple_prop_t *); +char *scf_simple_prop_next_ustring(scf_simple_prop_t *); +void *scf_simple_prop_next_opaque(scf_simple_prop_t *, size_t *); +void scf_simple_prop_next_reset(scf_simple_prop_t *); + +/* + * smf_state_from_string() + * return SCF_STATE_* value for the input + * -1 on error. String "all" maps to SCF_STATE_ALL macro + */ +int32_t smf_state_from_string(const char *); + +/* + * smf_state_to_string() + * return SCF_STATE_STRING* value for the input + * NULL on error. + */ +const char *smf_state_to_string(int32_t); + +/* + * Notification interfaces + */ +int smf_notify_set_params(const char *, nvlist_t *); +int smf_notify_get_params(nvlist_t **, nvlist_t *); +int smf_notify_del_params(const char *, const char *, int32_t); + +/* + * SMF exit status definitions + * + * The SMF_EXIT_NODAEMON exit status should be used when a method does not + * need to run any persistent process. This indicates success, abandons the + * contract, and allows dependencies to be met. + */ +#define SMF_EXIT_OK 0 +#define SMF_EXIT_NODAEMON 94 +#define SMF_EXIT_ERR_FATAL 95 +#define SMF_EXIT_ERR_CONFIG 96 +#define SMF_EXIT_MON_DEGRADE 97 +#define SMF_EXIT_MON_OFFLINE 98 +#define SMF_EXIT_ERR_NOSMF 99 +#define SMF_EXIT_ERR_PERM 100 + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSCF_H */ diff --git a/illumos-x86_64/usr/include/libscf_priv.h b/illumos-x86_64/usr/include/libscf_priv.h new file mode 100644 index 00000000..3ad25643 --- /dev/null +++ b/illumos-x86_64/usr/include/libscf_priv.h @@ -0,0 +1,608 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2013, Joyent, Inc. All rights reserved. + */ + +#ifndef _LIBSCF_PRIV_H +#define _LIBSCF_PRIV_H + + +#include +#include +#if !defined(NATIVE_BUILD) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NOTE + * + * The contents of this file are private to the implementation of Solaris + * and are subject to change at any time without notice. + */ + +#define SCF_PG_GENERAL_TYPE SCF_GROUP_FRAMEWORK +#define SCF_PG_GENERAL_FLAGS 0 + +#define SCF_PG_GENERAL_OVR_TYPE SCF_GROUP_FRAMEWORK +#define SCF_PG_GENERAL_OVR_FLAGS SCF_PG_FLAG_NONPERSISTENT + +#define SCF_PG_DEATHROW_TYPE SCF_GROUP_FRAMEWORK +#define SCF_PG_DEATHROW_FLAGS SCF_PG_FLAG_NONPERSISTENT + +#define SCF_PG_OPTIONS_TYPE SCF_GROUP_FRAMEWORK +#define SCF_PG_OPTIONS_FLAGS 0 + +#define SCF_PG_OPTIONS_OVR_TYPE SCF_GROUP_FRAMEWORK +#define SCF_PG_OPTIONS_OVR_FLAGS SCF_PG_FLAG_NONPERSISTENT + +#define SCF_PG_RESTARTER_TYPE SCF_GROUP_FRAMEWORK +#define SCF_PG_RESTARTER_FLAGS SCF_PG_FLAG_NONPERSISTENT + +#define SCF_PG_RESTARTER_ACTIONS_TYPE SCF_GROUP_FRAMEWORK +#define SCF_PG_RESTARTER_ACTIONS_FLAGS SCF_PG_FLAG_NONPERSISTENT + +#define SCF_PROPERTY_CLEAR ((const char *)"maint_off") +#define SCF_PROPERTY_MAINTENANCE ((const char *)"maint_on") + +#define SCF_PROPERTY_LOGFILE ((const char *)"logfile") +#define SCF_PROPERTY_ALT_LOGFILE ((const char *)"alt_logfile") + +#define SCF_LEGACY_SERVICE ((const char *)"smf/legacy_run") + +#define SCF_LEGACY_PROPERTY_NAME ((const char *)"name") +#define SCF_LEGACY_PROPERTY_INODE ((const char *)"inode") +#define SCF_LEGACY_PROPERTY_SUFFIX ((const char *)"suffix") + +#define SCF_FMRI_TYPE_SVC 0x1 +#define SCF_FMRI_TYPE_FILE 0x2 + +/* + * Strings for use in constructing FMRIs + */ +#define SCF_FMRI_SVC_PREFIX "svc:" +#define SCF_FMRI_FILE_PREFIX "file:" +#define SCF_FMRI_SCOPE_PREFIX "//" +#define SCF_FMRI_LOCAL_SCOPE "localhost" +#define SCF_FMRI_SCOPE_SUFFIX "@localhost" +#define SCF_FMRI_SERVICE_PREFIX "/" +#define SCF_FMRI_INSTANCE_PREFIX ":" +#define SCF_FMRI_PROPERTYGRP_PREFIX "/:properties/" +#define SCF_FMRI_PROPERTY_PREFIX "/" +#define SCF_FMRI_LEGACY_PREFIX "lrc:" + +/* + * sulogin Service FMRI + */ +#define SVC_SULOGIN_FMRI ((const char *)"svc:/system/sulogin") + +typedef struct scf_decoration_info { + const char *sdi_name; + scf_type_t sdi_type; + scf_value_t *sdi_value; /* can be SCF_DECORATE_CLEAR */ +} scf_decoration_info_t; + +typedef int (*scf_decoration_func)(const scf_decoration_info_t *, void *); + +/* + * calls a callback function for each decoration on the handle. If the + * callback returns 0, the iteration stops and returns 0. If the callback + * returns a non-zero value, the iteration continues. After full completion, + * 1 is returned. On error, -1 is returned. + */ +int _scf_handle_decorations(scf_handle_t *, scf_decoration_func *, + scf_value_t *, void *); + +/* + * wait for a change to the propertygroup -- may return early. + * For now, only one of these can be outstanding at a time. + * + * The second argument is how long, in seconds, to wait for a response. + * + * Returns SCF_COMPLETE on timeout, -1 on error, and SCF_SUCCESS in every + * other case. You must call scf_pg_update() to see if the object has + * actually changed. + */ +int _scf_pg_wait(scf_propertygroup_t *, int); + +/* + * set up notifications for changes to a class of property groups (by name + * and type) + * + * Only one thread can be sleeping in _scf_notify_wait() -- others will + * fail. Deletions give an fmri in the output path. + * + * These do not survive unbind()->bind() -- in fact, that is currently the + * only way to clear them. + */ +int _scf_notify_add_pgname(scf_handle_t *, const char *); +int _scf_notify_add_pgtype(scf_handle_t *, const char *); +int _scf_notify_wait(scf_propertygroup_t *, char *, size_t); + +/* + * Internal interfaces for snapshot creation: + * _scf_snapshot_take_new(), _scf_snapshot_take_new_named(), and + * _scf_snapshot_take_attach() create a set of snaplevels + * containing frozen versions of both the instance's property groups and + * its parent service's property groups. _scf_snapshot_take_new() and + * _scf_snapshot_take_new_named() create a new snapshot to which the + * new snaplevels are attached, while _scf_snapshot_take_attach() + * attaches the new snaplevels to a pre-existing snapshot. + * + * _scf_snapshot_take_new_named() records the passed in names into the + * snaplevel instead of the instance and service name. This creates + * an inconsistency, which should be resolved by using + * _scf_snapshot_attach() to attach the new snaplevels to a snapshot + * underneath the appropriate instance. The first snapshot can + * then be deleted. + * + * _scf_snapshot_attach(snap1, snap2) points snap2 at the snaplevels + * pointed to by snap1. After a call to either + * _scf_snapshot_take_attach(snap1, snap2) or + * _scf_snapshot_attach(inst, snap), scf_snapshot_update() will be + * required for any open references to snap or snap2 to see the new + * snaplevels. + * + * _scf_snapshot_delete() deletes the snapshot object. While + * snaplevels, being only loosely connected to snapshots, stay + * around until they are no longer referenced, any references *through + * this snapshot object* will be invalidated. + * + * _scf_snapshot_take_new() can fail with at least _HANDLE_MISMATCH, + * _CONNECTION_BROKEN, _INVALID_ARGUMENT, _NO_RESOURCES, _PERMISSION_DENIED, + * _NOT_SET, _EXISTS. + * + * _scf_snapshot_take_new_named() can fail with at least _HANDLE_MISMATCH, + * _CONNECTION_BROKEN, _INVALID_ARGUMENT, _NO_RESOURCES, _PERMISSION_DENIED, + * _NOT_SET, _EXISTS. + * + * _scf_snapshot_take_attach() can fail with _CONNECTION_BROKEN, _NOT_SET, + * _PERMISSION_DENIED, _NO_RESOURCES, _INVALID_ARGUMENT. + * + * _scf_snapshot_attach() can fail with _HANDLE_MISMATCH, _CONNECTION_BROKEN, + * _NOT_SET, _NO_RESOURCES, _PERMISSION_DENIED. + */ +int _scf_snapshot_take_new(scf_instance_t *, const char *, scf_snapshot_t *); +int _scf_snapshot_take_new_named(scf_instance_t *, + const char *, const char *, const char *, scf_snapshot_t *); +int _scf_snapshot_take_attach(scf_instance_t *, scf_snapshot_t *); +int _scf_snapshot_attach(scf_snapshot_t *, scf_snapshot_t *); +int _scf_snapshot_delete(scf_snapshot_t *); + +/* + * Destructively portions up the first argument into the different portions + * of a svc: fmri, and returns pointers to the applicable portions. Omitted + * portions are set to NULL, except for the scope, which is set to the + * default local scope if not specified. + * + * Parsing is attempted in the order of: svc:, file:. The identified type + * of the service is returned in the second argument and may take a value + * of: SCF_FMRI_TYPE_SVC or SCF_FMRI_TYPE_FILE. + * + * Note that some of the returned pointers (in particular the scope) may not + * point into the passed buffer. + */ +int scf_parse_fmri(char *, int *, const char **, const char **, const char **, + const char **, const char **); + +int scf_parse_svc_fmri(char *, const char **, const char **, const char **, + const char **, const char **); + +int scf_parse_file_fmri(char *fmri, const char **scope, const char **path); + +ssize_t scf_canonify_fmri(const char *, char *, size_t); + +int _smf_refresh_instance_i(scf_instance_t *); + +typedef struct scf_simple_handle { + scf_handle_t *h; + scf_snapshot_t *snap; + scf_instance_t *inst; + scf_propertygroup_t *running_pg; + scf_propertygroup_t *editing_pg; +} scf_simple_handle_t; + +void scf_simple_handle_destroy(scf_simple_handle_t *); +scf_simple_handle_t *scf_general_pg_setup(const char *, const char *); +scf_transaction_t *scf_transaction_setup(scf_simple_handle_t *); +int scf_transaction_restart(scf_simple_handle_t *, scf_transaction_t *); +int scf_read_count_property(scf_simple_handle_t *, char *, uint64_t *); +int scf_set_count_property(scf_transaction_t *, char *, uint64_t, boolean_t); + +/* + * Walks all the instances matching a given fmri list. Each fmri in the array + * can be one of the following: + * + * - Full instance name + * - Full service name + * - Full property group or property name + * - Partial service or instance name + * - A globbed pattern + * + * The matching rules for partial fmris are a slightly more complex. We allow + * for any substring anchored at the end of the instance or service name, + * provided it begins with a complete element in the fmri. For example, given + * the fmri "svc:/system/filesystem/local:default", any of the following would + * be acceptable matches: 'default', 'local', 'local:default', + * 'filesystem/local'. The following would not be acceptable: + * 'system/filesystem', 'filesystem/loc', 'system/local'. Possible flag values: + * + * SCF_WALK_MULTIPLE Allow individual arguments to correspond to + * multiple instances. + * + * SCF_WALK_LEGACY Walk legacy services (indicated by a non-NULL + * propery group). + * + * SCF_WALK_SERVICE If the user specifies a service, pass the + * service to the callback without iterating over + * its instances. + * + * SCF_WALK_PROPERTY Allow FMRIs which match property groups or + * individual properties. Incompatible with + * SCF_WALK_LEGACY. + * + * SCF_WALK_NOINSTANCE Walk only services. Must be used in + * conjunction with SCF_WALK_SERVICE. + * + * SCF_WALK_EXPLICIT Walk only services if the match is exact + * else return instances. Must be used in + * conjunction with SCF_WALK_SERVICE. + * + * SCF_WALK_UNIPARTIAL Can be combined with SCF_WALK_MULTIPLE + * so that an error is returned if a partial + * fmri matches multiple instances, unless + * a wildcard match is also used. + * + * If no arguments are given, then all instances in the service graph are + * walked. + * + * The second to last parameter is set to UU_EXIT_FATAL if one of the arguments + * is an invalid FMRI or matches multiple FMRIs when SCF_WALK_MULTIPLE is not + * set. + * + * The last parameter is a user-supplied error function that is called when + * reporting invalid arguments. + */ + +#define SCF_WALK_MULTIPLE 0x01 +#define SCF_WALK_LEGACY 0x02 +#define SCF_WALK_SERVICE 0x04 +#define SCF_WALK_PROPERTY 0x08 +#define SCF_WALK_NOINSTANCE 0x10 +#define SCF_WALK_EXPLICIT 0x20 +#define SCF_WALK_UNIPARTIAL 0x40 + +/* + * The default locations of the repository dbs + */ +#define REPOSITORY_DB "/etc/svc/repository.db" +#define NONPERSIST_DB "/etc/svc/volatile/svc_nonpersist.db" +#define FAST_REPOSITORY_DB "/etc/svc/volatile/fast_repository.db" +#define REPOSITORY_CHECKPOINT "/etc/svc/volatile/checkpoint_repository.db" + + +typedef struct scf_walkinfo { + const char *fmri; + scf_scope_t *scope; + scf_service_t *svc; + scf_instance_t *inst; + scf_propertygroup_t *pg; + scf_property_t *prop; + int count; /* svcprop special */ +} scf_walkinfo_t; + +typedef int (*scf_walk_callback)(void *, scf_walkinfo_t *); + +scf_error_t scf_walk_fmri(scf_handle_t *, int, char **, int, + scf_walk_callback, void *, int *, void (*)(const char *, ...)); + +/* + * Requests a backup of the repository with a particular name, which + * can be any alphabetic string. Only privileged users can do this. + * + * Can fail with: + * _NOT_BOUND, _CONNECTION_BROKEN, _PERMISSION_DENIED, _INVALID_ARGUMENT, + * _INTERNAL (path too long, or the backup failed for an odd reason), + * _BACKEND_READONLY (filesystem is still read-only) + */ +int _scf_request_backup(scf_handle_t *, const char *); + +/* + * Repository switch client + */ +int _scf_repository_switch(scf_handle_t *, int); + +/* + * Determines whether a property group requires authorization to read; this + * does not in any way reflect whether the caller has that authorization. + * To determine that, the caller must attempt to read the value of one of the + * group's properties. + * + * Can fail with: + * _NOT_BOUND, _CONNECTION_BROKEN, _INVALID_ARGUMENT, _INTERNAL, + * _NO_RESOURCES, _CONSTRAINT_VIOLATED, _DELETED. + */ +int _scf_pg_is_read_protected(const scf_propertygroup_t *, boolean_t *); + +/* + * Sets annotation data for SMF audit logging. Once this function has been + * set, the next audit record will be preceded by an ADT_smf_annotation + * with the information provided in this function. This function is used + * to mark operations which comprise multiple primitive operations such as + * svccfg import. + */ +int _scf_set_annotation(scf_handle_t *h, const char *operation, + const char *file); + +/* + * scf_pattern_t + */ +typedef struct scf_pattern { + enum { + PATTERN_INVALID, /* Uninitialized state */ + PATTERN_EXACT, + PATTERN_GLOB, + PATTERN_PARTIAL + } sp_type; + char *sp_arg; /* Original argument */ + struct scf_match *sp_matches; /* List of matches */ + int sp_matchcount; /* # of matches */ +} scf_pattern_t; + +int scf_cmp_pattern(char *, scf_pattern_t *); + +int gen_filenms_from_fmri(const char *, const char *, char *, char *); + +/* + * Interfaces for bulk access to SMF-stored configuration. + * + * Each scf_propvec_t represents a single property to be read (with + * scf_read_propvec) or written (with scf_write_propvec). + * + * The fields of a scf_propvec_t have the following meanings: + * + * pv_prop - the name of the property + * pv_desc - a description string (optional; to be consumed by the caller) + * pv_type - the type of the property + * pv_ptr - where to store the data read, or a pointer to the data to + * be written + * pv_aux - additional data influencing the interpretation of pv_ptr + * + * The meaning of pv_ptr and pv_aux depends on the type of property. For: + * + * boolean - if pv_aux is 0, pv_ptr is a pointer to a boolean_t + * if pv_aux is non-0, pv_ptr is a pointer to a uint64_t, + * where pv_aux indicates the bit holding the truth value. + * count - pv_ptr is a pointer to a uint64_t; pv_aux is unused + * integer - pv_ptr is a pointer to an int64_t; pv_aux is unused + * time - pv_ptr is a pointer to an scf_time_t; pv_aux is unused + * opaque - pv_ptr is a pointer to an scf_opaque_t; pv_aux is unused + * strings - (scf_read_propvec) pv_ptr is a pointer to a char * + * (scf_write_propvec) pv_ptr is a pointer to an array of char + * (both) pv_aux is unused + */ +typedef struct { + void *so_addr; + size_t so_size; +} scf_opaque_t; + +typedef struct { + const char *pv_prop; + const char *pv_desc; + scf_type_t pv_type; + void *pv_ptr; + uint64_t pv_aux; +} scf_propvec_t; + +void scf_clean_propvec(scf_propvec_t *); +int scf_read_propvec(const char *, const char *, boolean_t, scf_propvec_t *, + scf_propvec_t **); +int scf_write_propvec(const char *, const char *, scf_propvec_t *, + scf_propvec_t **); + +scf_tmpl_errors_t *_scf_create_errors(const char *, int); +int _scf_tmpl_add_error(scf_tmpl_errors_t *errs, scf_tmpl_error_type_t type, + const char *pg_name, const char *prop_name, + const char *ev1, const char *ev2, const char *actual, + const char *tmpl_fmri, const char *tmpl_pg_name, const char *tmpl_pg_type, + const char *tmpl_prop_name, const char *tmpl_prop_type); +int _scf_tmpl_error_set_prefix(scf_tmpl_errors_t *, const char *); + +/* + * Templates definitions + */ + +/* + * For CARDINALITY_VIOLATION and RANGE_VIOLATION, te_ev1 holds + * the min value and te_ev2 holds the max value + * + * For MISSING_PG te_ev1 should hold the expected pg_name and + * expected2 holds the expected pg_type. + * + * For SCF_TERR_PG_PATTERN_CONFLICT and SCF_TERR_GENERAL_REDEFINE te_ev1 is + * the FMRI holding the conflicting pg_pattern. te_ev2 is the name of the + * conflicting pg_pattern, and actual is the type of the conflicting + * pg_pattern. + * + * SCF_TERR_PROP_PATTERN_CONFLICT te_ev1 is the FMRI holding the + * conflicting prop_pattern. te_ev2 is the name of the conflicting + * prop_pattern, and actual is the type of the conflicting prop_pattern. + * + * For SCF_TERR_INCLUDE_VALUES te_ev1 is the type specified for the + * include_values element. + * + * For all other errors, te_ev1 should hold the expected value and + * te_ev2 is ignored + * + * te_actual holds the current value of the property + */ + +struct scf_tmpl_error { + scf_tmpl_errors_t *te_errs; + scf_tmpl_error_type_t te_type; + const char *te_pg_name; + const char *te_prop_name; + const char *te_ev1; + const char *te_ev2; + const char *te_actual; + const char *te_tmpl_fmri; + const char *te_tmpl_pg_name; + const char *te_tmpl_pg_type; + const char *te_tmpl_prop_name; + const char *te_tmpl_prop_type; +}; + +/* + * The pg_pattern element has two optional attributes that play a part in + * selecting the appropriate prefix for the name of the pg_pattern property + * group. The two attributes are name and type. The appropriate prefix + * encodes the presence are absence of these attributes. + * + * SCF_PG_TM_PG_PATTERN_PREFIX neither attribute + * SCF_PG_TM_PG_PATTERN_N_PREFIX name only + * SCF_PG_TM_PG_PATTERN_T_PREFIX type only + * SCF_PG_TM_PG_PATTERN_NT_PREFIX both name and type + */ +#define SCF_PG_TM_PG_PAT_BASE "tm_pgpat" +#define SCF_PG_TM_PG_PATTERN_PREFIX ((const char *)SCF_PG_TM_PG_PAT_BASE \ + "_") +#define SCF_PG_TM_PG_PATTERN_N_PREFIX ((const char *)SCF_PG_TM_PG_PAT_BASE \ + "n_") +#define SCF_PG_TM_PG_PATTERN_T_PREFIX ((const char *)SCF_PG_TM_PG_PAT_BASE \ + "t_") +#define SCF_PG_TM_PG_PATTERN_NT_PREFIX ((const char *)SCF_PG_TM_PG_PAT_BASE \ + "nt_") +#define SCF_PG_TM_PROP_PATTERN_PREFIX ((const char *)"tm_proppat_") + +/* + * Pad character to use when encoding strings for property names. + */ +#define SCF_ENCODE32_PAD ('-') + +/* + * Functions for base 32 encoding/decoding + */ +int scf_decode32(const char *, size_t, char *, size_t, size_t *, char); +int scf_encode32(const char *, size_t, char *, size_t, size_t *, char); + +/* + * handy functions + */ +/* + * _scf_sanitize_locale + * Make sure a locale string has only alpha-numeric or '_' characters + */ +void _scf_sanitize_locale(char *); + +/* + * _scf_read_tmpl_prop_type_as_string() + * Handy function to get template property type as a string + */ +char *_scf_read_tmpl_prop_type_as_string(const scf_prop_tmpl_t *); +/* + * _scf_read_single_astring_from_pg() + * Given a property group (pg) and a property name (pn), this function + * retrives an astring value from pg/pn. + */ +char *_scf_read_single_astring_from_pg(scf_propertygroup_t *, const char *); + +/* + * scf_instance_delete_prop() + * Given instance, property group, and property, delete the property. + */ +int +scf_instance_delete_prop(scf_instance_t *, const char *, const char *); + +/* + * Functions to extract boot config information from FMRI_BOOT_CONFIG + */ +void scf_get_boot_config(uint8_t *); +void scf_get_boot_config_ovr(uint8_t *); +int scf_is_fastboot_default(void); + +/* + * Set value of "config_ovr/fastreboot_default". + */ +int scf_fastreboot_default_set_transient(boolean_t); + +/* + * scf_is_compatible_type() + * Return true if the second type is the same type, or a subtype of the + * first. + */ +int scf_is_compatible_type(scf_type_t, scf_type_t); + +/* + * Check an array of services and enable any that don't have the + * "application/auto_enable" property set to "false", which is + * the interface to turn off this behaviour (see PSARC 2004/739). + */ +void _check_services(char **); + +/* + * _scf_handle_create_and_bind() + * convenience function that creates and binds a handle + */ +scf_handle_t *_scf_handle_create_and_bind(scf_version_t); + +/* + * _smf_refresh_all_instances() + * refresh all intances of a service + * return SCF_SUCCESS or SCF_FAILED on _PERMISSION_DENIED, _BACKEND_ACCESS + * or _BACKEND_READONLY. + */ +int _smf_refresh_all_instances(scf_service_t *); + +/* + * _scf_get_fma_notify_params() + * Specialized fuction to get fma notifitation parameters + */ +int _scf_get_fma_notify_params(const char *, nvlist_t *, int); + +/* + * _scf_get_svc_notify_params() + * Specialized function to get SMF state transition notification parameters + */ +int _scf_get_svc_notify_params(const char *, nvlist_t *, int32_t, int, int); + +/* + * _scf_notify_get_params() + * Specialized function to get notification parametes from a pg into an + * nvlist_t + */ +int _scf_notify_get_params(scf_propertygroup_t *, nvlist_t *); + +#if !defined(NATIVE_BUILD) +int scf_default_secflags(scf_handle_t *, scf_secflags_t *); +#endif + +#define SCF_NOTIFY_PARAMS_SOURCE_NAME ((const char *)"preference_source") + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSCF_PRIV_H */ diff --git a/illumos-x86_64/usr/include/libshare.h b/illumos-x86_64/usr/include/libshare.h new file mode 100644 index 00000000..042a6f8c --- /dev/null +++ b/illumos-x86_64/usr/include/libshare.h @@ -0,0 +1,310 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2016 by Delphix. All rights reserved. + */ + +/* + * basic API declarations for share management + */ + +#ifndef _LIBSHARE_H +#define _LIBSHARE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * Basic datatypes for most functions + */ +typedef void *sa_group_t; +typedef void *sa_share_t; +typedef void *sa_property_t; +typedef void *sa_optionset_t; +typedef void *sa_security_t; +typedef void *sa_protocol_properties_t; +typedef void *sa_resource_t; + +typedef void *sa_handle_t; /* opaque handle to access core functions */ + +/* + * defined error values + */ + +#define SA_OK 0 +#define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */ +#define SA_NO_MEMORY 2 /* no memory for data structures */ +#define SA_DUPLICATE_NAME 3 /* object name is already in use */ +#define SA_BAD_PATH 4 /* not a full path */ +#define SA_NO_SUCH_GROUP 5 /* group is not defined */ +#define SA_CONFIG_ERR 6 /* system configuration error */ +#define SA_SYSTEM_ERR 7 /* system error, use errno */ +#define SA_SYNTAX_ERR 8 /* syntax error on command line */ +#define SA_NO_PERMISSION 9 /* no permission for operation */ +#define SA_BUSY 10 /* resource is busy */ +#define SA_NO_SUCH_PROP 11 /* property doesn't exist */ +#define SA_INVALID_NAME 12 /* name of object is invalid */ +#define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */ +#define SA_NOT_ALLOWED 14 /* operation not allowed */ +#define SA_BAD_VALUE 15 /* bad value for property */ +#define SA_INVALID_SECURITY 16 /* invalid security type */ +#define SA_NO_SUCH_SECURITY 17 /* security set not found */ +#define SA_VALUE_CONFLICT 18 /* property value conflict */ +#define SA_NOT_IMPLEMENTED 19 /* plugin interface not implemented */ +#define SA_INVALID_PATH 20 /* path is sub-dir of existing share */ +#define SA_NOT_SUPPORTED 21 /* operation not supported for proto */ +#define SA_PROP_SHARE_ONLY 22 /* property valid on share only */ +#define SA_NOT_SHARED 23 /* path is not shared */ +#define SA_NO_SUCH_RESOURCE 24 /* resource not found */ +#define SA_RESOURCE_REQUIRED 25 /* resource name is required */ +#define SA_MULTIPLE_ERROR 26 /* multiple protocols reported error */ +#define SA_PATH_IS_SUBDIR 27 /* check_path found path is subdir */ +#define SA_PATH_IS_PARENTDIR 28 /* check_path found path is parent */ +#define SA_NO_SECTION 29 /* protocol requires section info */ +#define SA_NO_SUCH_SECTION 30 /* no section found */ +#define SA_NO_PROPERTIES 31 /* no properties found */ +#define SA_PASSWORD_ENC 32 /* passwords must be encrypted */ +#define SA_SHARE_EXISTS 33 /* path or file is already shared */ + +/* API Initialization */ +/* Both of these do not care about the value of arg in sa_init_arg */ +#define SA_INIT_SHARE_API 0x0001 /* init share specific interface */ +#define SA_INIT_CONTROL_API 0x0002 /* init control specific interface */ + +/* expects an sa_init_selective_arg_t as an argument */ +#define SA_INIT_SHARE_API_SELECTIVE 0x0004 /* only some shares */ +struct sa_init_selective_arg { + zfs_handle_t **zhandle_arr; + size_t zhandle_len; +}; +typedef struct sa_init_selective_arg sa_init_selective_arg_t; + + +/* + * The SA_INIT_ONE_SHARE* initialization options to sa_init* will cause + * sa_needs_refrsh() to return true even if nothing else in the system has + * changed. If writing code that could possibly need to share/unshare multiple + * shares, it is recommended to use SA_INIT_SHARE_API_SELECTIVE. + */ +/* Expects a single char * as input, the name of the share. */ +#define SA_INIT_ONE_SHARE_FROM_NAME 0x0008 + +/* Expects a single zfs_handle_t as input, the handle of the share. */ +#define SA_INIT_ONE_SHARE_FROM_HANDLE 0x0010 + +/* not part of API returns */ +#define SA_LEGACY_ERR 32 /* share/unshare error return */ + +/* + * other defined values + */ + +#define SA_MAX_NAME_LEN 100 /* must fit service instance name */ +#define SA_MAX_RESOURCE_NAME 255 /* Maximum length of resource name */ + +/* Used in calls to sa_add_share() and sa_add_resource() */ +#define SA_SHARE_TRANSIENT 0 /* shared but not across reboot */ +#define SA_SHARE_LEGACY 1 /* share is in dfstab only */ +#define SA_SHARE_PERMANENT 2 /* share goes to repository */ + +/* sa_check_path() related */ +#define SA_CHECK_NORMAL 0 /* only check against active shares */ +#define SA_CHECK_STRICT 1 /* check against all shares */ + +/* RBAC related */ +#define SA_RBAC_MANAGE "solaris.smf.manage.shares" +#define SA_RBAC_VALUE "solaris.smf.value.shares" + +/* + * Feature set bit definitions + */ + +#define SA_FEATURE_NONE 0x0000 /* no feature flags set */ +#define SA_FEATURE_RESOURCE 0x0001 /* resource names are required */ +#define SA_FEATURE_DFSTAB 0x0002 /* need to manage in dfstab */ +#define SA_FEATURE_ALLOWSUBDIRS 0x0004 /* allow subdirs to be shared */ +#define SA_FEATURE_ALLOWPARDIRS 0x0008 /* allow parent dirs to be shared */ +#define SA_FEATURE_HAS_SECTIONS 0x0010 /* protocol supports sections */ +#define SA_FEATURE_ADD_PROPERTIES 0x0020 /* can add properties */ +#define SA_FEATURE_SERVER 0x0040 /* protocol supports server mode */ + +/* + * legacy files + */ + +#define SA_LEGACY_DFSTAB "/etc/dfs/dfstab" +#define SA_LEGACY_SHARETAB "/etc/dfs/sharetab" + +/* + * SMF related + */ + +#define SA_SVC_FMRI_BASE "svc:/network/shares/group" + +/* initialization */ +extern sa_handle_t sa_init(int); +extern sa_handle_t sa_init_arg(int, void *); +extern void sa_fini(sa_handle_t); +extern int sa_service(sa_handle_t); + +extern int sa_update_config(sa_handle_t); +extern boolean_t sa_needs_refresh(sa_handle_t); +extern char *sa_errorstr(int); + +/* protocol names */ +extern int sa_get_protocols(char ***); +extern int sa_valid_protocol(char *); + +/* group control (create, remove, etc) */ +extern sa_group_t sa_create_group(sa_handle_t, char *, int *); +extern int sa_remove_group(sa_group_t); +extern sa_group_t sa_get_group(sa_handle_t, char *); +extern sa_group_t sa_get_next_group(sa_group_t); +extern char *sa_get_group_attr(sa_group_t, char *); +extern int sa_set_group_attr(sa_group_t, char *, char *); +extern sa_group_t sa_get_sub_group(sa_group_t); +extern int sa_valid_group_name(char *); + +/* share control */ +extern sa_share_t sa_add_share(sa_group_t, char *, int, int *); +extern int sa_check_path(sa_group_t, char *, int); +extern int sa_move_share(sa_group_t, sa_share_t); +extern int sa_remove_share(sa_share_t); +extern sa_share_t sa_get_share(sa_group_t, char *); +extern sa_share_t sa_find_share(sa_handle_t, char *); +extern sa_share_t sa_get_next_share(sa_share_t); +extern char *sa_get_share_attr(sa_share_t, char *); +extern char *sa_get_share_description(sa_share_t); +extern sa_group_t sa_get_parent_group(sa_share_t); +extern int sa_set_share_attr(sa_share_t, char *, char *); +extern int sa_set_share_description(sa_share_t, char *); +extern int sa_enable_share(sa_group_t, char *); +extern int sa_disable_share(sa_share_t, char *); +extern int sa_is_share(void *); + +/* resource name related */ +extern sa_resource_t sa_find_resource(sa_handle_t, char *); +extern sa_resource_t sa_get_resource(sa_group_t, char *); +extern sa_resource_t sa_get_next_resource(sa_resource_t); +extern sa_share_t sa_get_resource_parent(sa_resource_t); +extern sa_resource_t sa_get_share_resource(sa_share_t, char *); +extern sa_resource_t sa_add_resource(sa_share_t, char *, int, int *); +extern int sa_remove_resource(sa_resource_t); +extern char *sa_get_resource_attr(sa_resource_t, char *); +extern int sa_set_resource_attr(sa_resource_t, char *, char *); +extern int sa_set_resource_description(sa_resource_t, char *); +extern char *sa_get_resource_description(sa_resource_t); +extern int sa_enable_resource(sa_resource_t, char *); +extern int sa_disable_resource(sa_resource_t, char *); +extern int sa_rename_resource(sa_resource_t, char *); +extern void sa_fix_resource_name(char *); + +/* data structure free calls */ +extern void sa_free_attr_string(char *); +extern void sa_free_share_description(char *); + +/* optionset control */ +extern sa_optionset_t sa_get_optionset(sa_group_t, char *); +extern sa_optionset_t sa_get_next_optionset(sa_group_t); +extern char *sa_get_optionset_attr(sa_optionset_t, char *); +extern void sa_set_optionset_attr(sa_optionset_t, char *, char *); +extern sa_optionset_t sa_create_optionset(sa_group_t, char *); +extern int sa_destroy_optionset(sa_optionset_t); +extern sa_optionset_t sa_get_derived_optionset(void *, char *, int); +extern void sa_free_derived_optionset(sa_optionset_t); + +/* property functions */ +extern sa_property_t sa_get_property(sa_optionset_t, char *); +extern sa_property_t sa_get_next_property(sa_group_t); +extern char *sa_get_property_attr(sa_property_t, char *); +extern sa_property_t sa_create_section(char *, char *); +extern void sa_set_section_attr(sa_property_t, char *, char *); +extern sa_property_t sa_create_property(char *, char *); +extern int sa_add_property(void *, sa_property_t); +extern int sa_update_property(sa_property_t, char *); +extern int sa_remove_property(sa_property_t); +extern int sa_commit_properties(sa_optionset_t, int); +extern int sa_valid_property(sa_handle_t, void *, char *, sa_property_t); +extern int sa_is_persistent(void *); + +/* security control */ +extern sa_security_t sa_get_security(sa_group_t, char *, char *); +extern sa_security_t sa_get_next_security(sa_security_t); +extern char *sa_get_security_attr(sa_optionset_t, char *); +extern sa_security_t sa_create_security(sa_group_t, char *, char *); +extern int sa_destroy_security(sa_security_t); +extern void sa_set_security_attr(sa_security_t, char *, char *); +extern sa_optionset_t sa_get_all_security_types(void *, char *, int); +extern sa_security_t sa_get_derived_security(void *, char *, char *, int); +extern void sa_free_derived_security(sa_security_t); + +/* protocol specific interfaces */ +extern int sa_parse_legacy_options(sa_group_t, char *, char *); +extern char *sa_proto_legacy_format(char *, sa_group_t, int); +extern int sa_is_security(char *, char *); +extern sa_protocol_properties_t sa_proto_get_properties(char *); +extern uint64_t sa_proto_get_featureset(char *); +extern sa_property_t sa_get_protocol_section(sa_protocol_properties_t, char *); +extern sa_property_t sa_get_next_protocol_section(sa_property_t, char *); +extern sa_property_t sa_get_protocol_property(sa_protocol_properties_t, char *); +extern sa_property_t sa_get_next_protocol_property(sa_property_t, char *); +extern int sa_set_protocol_property(sa_property_t, char *, char *); +extern char *sa_get_protocol_status(char *); +extern void sa_format_free(char *); +extern sa_protocol_properties_t sa_create_protocol_properties(char *); +extern int sa_add_protocol_property(sa_protocol_properties_t, sa_property_t); +extern int sa_proto_valid_prop(sa_handle_t, char *, sa_property_t, + sa_optionset_t); +extern int sa_proto_valid_space(char *, char *); +extern char *sa_proto_space_alias(char *, char *); +extern int sa_proto_get_transients(sa_handle_t, char *); +extern int sa_proto_notify_resource(sa_resource_t, char *); +extern int sa_proto_change_notify(sa_share_t, char *); +extern int sa_proto_delete_section(char *, char *); + +/* handle legacy (dfstab/sharetab) files */ +extern int sa_delete_legacy(sa_share_t, char *); +extern int sa_update_legacy(sa_share_t, char *); +extern int sa_update_sharetab(sa_share_t, char *); +extern int sa_delete_sharetab(sa_handle_t, char *, char *); + +/* ZFS functions */ +extern int sa_zfs_is_shared(sa_handle_t, char *); +extern int sa_group_is_zfs(sa_group_t); +extern int sa_path_is_zfs(char *); +extern int sa_zfs_setprop(sa_handle_t, char *, nvlist_t *); + +/* SA Handle specific functions */ +extern sa_handle_t sa_find_group_handle(sa_group_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSHARE_H */ diff --git a/illumos-x86_64/usr/include/libstmf.h b/illumos-x86_64/usr/include/libstmf.h new file mode 100644 index 00000000..f9d05adb --- /dev/null +++ b/illumos-x86_64/usr/include/libstmf.h @@ -0,0 +1,392 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBSTMF_H +#define _LIBSTMF_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Constants and Types */ + +/* LU and Local Port states */ +#define STMF_LOGICAL_UNIT_OFFLINE 0 +#define STMF_LOGICAL_UNIT_OFFLINING 1 +#define STMF_LOGICAL_UNIT_ONLINE 2 +#define STMF_LOGICAL_UNIT_ONLINING 3 +#define STMF_LOGICAL_UNIT_UNREGISTERED 4 +#define STMF_TARGET_PORT_OFFLINE 5 +#define STMF_TARGET_PORT_OFFLINING 6 +#define STMF_TARGET_PORT_ONLINE 7 +#define STMF_TARGET_PORT_ONLINING 8 +#define STMF_SERVICE_STATE_ONLINE 9 +#define STMF_SERVICE_STATE_OFFLINE 10 +#define STMF_SERVICE_STATE_ONLINING 11 +#define STMF_SERVICE_STATE_OFFLINING 12 +#define STMF_SERVICE_STATE_UNKNOWN 13 +#define STMF_CONFIG_STATE_NONE 14 +#define STMF_CONFIG_STATE_INIT 15 +#define STMF_CONFIG_STATE_INIT_DONE 16 +#define STMF_CONFIG_STATE_UNKNOWN 17 +#define STMF_DEFAULT_LU_STATE 18 +#define STMF_DEFAULT_TARGET_PORT_STATE 19 + +#define STMF_IDENT_LENGTH 255 + +/* API status return values */ +#define STMF_STATUS_SUCCESS 0x0000 +#define STMF_STATUS_ERROR 0x8000 +#define STMF_ERROR_BUSY (STMF_STATUS_ERROR | 0x01) +#define STMF_ERROR_NOT_FOUND (STMF_STATUS_ERROR | 0x02) +#define STMF_ERROR_MEMBER_NOT_FOUND (STMF_STATUS_ERROR | 0x03) +#define STMF_ERROR_GROUP_NOT_FOUND (STMF_STATUS_ERROR | 0x04) +#define STMF_ERROR_PERM (STMF_STATUS_ERROR | 0x05) +#define STMF_ERROR_NOMEM (STMF_STATUS_ERROR | 0x06) +#define STMF_ERROR_INVALID_ARG (STMF_STATUS_ERROR | 0x07) +#define STMF_ERROR_EXISTS (STMF_STATUS_ERROR | 0x08) +#define STMF_ERROR_SERVICE_NOT_FOUND (STMF_STATUS_ERROR | 0x09) +#define STMF_ERROR_SERVICE_ONLINE (STMF_STATUS_ERROR | 0x0a) +#define STMF_ERROR_SERVICE_OFFLINE (STMF_STATUS_ERROR | 0x0b) +#define STMF_ERROR_GROUP_IN_USE (STMF_STATUS_ERROR | 0x0c) +#define STMF_ERROR_LUN_IN_USE (STMF_STATUS_ERROR | 0x0d) +#define STMF_ERROR_VE_CONFLICT (STMF_STATUS_ERROR | 0x0e) +#define STMF_ERROR_CONFIG_NONE (STMF_STATUS_ERROR | 0x0f) +#define STMF_ERROR_SERVICE_DATA_VERSION (STMF_STATUS_ERROR | 0x10) +#define STMF_ERROR_INVALID_HG (STMF_STATUS_ERROR | 0x11) +#define STMF_ERROR_INVALID_TG (STMF_STATUS_ERROR | 0x12) +#define STMF_ERROR_PROV_DATA_STALE (STMF_STATUS_ERROR | 0x13) +#define STMF_ERROR_NO_PROP (STMF_STATUS_ERROR | 0x14) +#define STMF_ERROR_NO_PROP_VAL (STMF_STATUS_ERROR | 0x15) +#define STMF_ERROR_MISSING_PROP_VAL (STMF_STATUS_ERROR | 0x16) +#define STMF_ERROR_INVALID_BLOCKSIZE (STMF_STATUS_ERROR | 0x17) +#define STMF_ERROR_FILE_ALREADY (STMF_STATUS_ERROR | 0x18) +#define STMF_ERROR_INVALID_PROPSIZE (STMF_STATUS_ERROR | 0x19) +#define STMF_ERROR_INVALID_PROP (STMF_STATUS_ERROR | 0x20) +#define STMF_ERROR_PERSIST_TYPE (STMF_STATUS_ERROR | 0x21) +#define STMF_ERROR_TG_ONLINE (STMF_STATUS_ERROR | 0x22) +#define STMF_ERROR_ACCESS_STATE_SET (STMF_STATUS_ERROR | 0x23) +#define STMF_ERROR_NO_PROP_STANDBY (STMF_STATUS_ERROR | 0x24) +#define STMF_ERROR_POST_MSG_FAILED (STMF_STATUS_ERROR | 0x25) +#define STMF_ERROR_DOOR_INSTALLED (STMF_STATUS_ERROR | 0x26) + +/* Failures for stmfCreateLu */ +#define STMF_ERROR_FILE_IN_USE (STMF_STATUS_ERROR | 0x100) +#define STMF_ERROR_INVALID_BLKSIZE (STMF_STATUS_ERROR | 0x101) +#define STMF_ERROR_GUID_IN_USE (STMF_STATUS_ERROR | 0x102) +#define STMF_ERROR_META_FILE_NAME (STMF_STATUS_ERROR | 0x103) +#define STMF_ERROR_DATA_FILE_NAME (STMF_STATUS_ERROR | 0x104) +#define STMF_ERROR_SIZE_OUT_OF_RANGE (STMF_STATUS_ERROR | 0x105) +#define STMF_ERROR_LU_BUSY (STMF_STATUS_ERROR | 0x106) +#define STMF_ERROR_META_CREATION (STMF_STATUS_ERROR | 0x107) +#define STMF_ERROR_FILE_SIZE_INVALID (STMF_STATUS_ERROR | 0x108) +#define STMF_ERROR_WRITE_CACHE_SET (STMF_STATUS_ERROR | 0x109) + +/* Initiator Name Types */ +#define STMF_FC_PORT_WWN 1 +#define STMF_ISCSI_NAME 2 + + +/* provider types */ +#define STMF_LU_PROVIDER_TYPE 1 +#define STMF_PORT_PROVIDER_TYPE 2 + +/* LU Resource types */ +#define STMF_DISK 0 + +/* Persistence methods */ +#define STMF_PERSIST_SMF 1 +#define STMF_PERSIST_NONE 2 + +/* Logical unit access states */ +#define STMF_ACCESS_ACTIVE "0" +#define STMF_ACCESS_ACTIVE_TO_STANDBY "1" +#define STMF_ACCESS_STANDBY "2" +#define STMF_ACCESS_STANDBY_TO_ACTIVE "3" + +/* + * LU Disk Properties + */ + +enum { + STMF_LU_PROP_ALIAS = 1, + STMF_LU_PROP_BLOCK_SIZE, + STMF_LU_PROP_COMPANY_ID, + STMF_LU_PROP_FILENAME, + STMF_LU_PROP_GUID, + STMF_LU_PROP_META_FILENAME, + STMF_LU_PROP_MGMT_URL, + STMF_LU_PROP_NEW, + STMF_LU_PROP_SIZE, + STMF_LU_PROP_WRITE_PROTECT, + STMF_LU_PROP_WRITE_CACHE_DISABLE, + STMF_LU_PROP_VID, + STMF_LU_PROP_PID, + STMF_LU_PROP_SERIAL_NUM, + STMF_LU_PROP_ACCESS_STATE, + STMF_LU_PROP_HOST_ID +}; + + +/* devid code set and name types */ +#define EUI_64_TYPE 2 +#define NAA_TYPE 3 +#define SCSI_NAME_TYPE 8 + +#define BINARY_CODE_SET 1 +#define ASCII_CODE_SET 2 +#define UTF_8_CODE_SET 3 + +typedef enum _stmfProtocol +{ + STMF_PROTOCOL_FIBRE_CHANNEL = 0, + STMF_PROTOCOL_SCSI = 1, + STMF_PROTOCOL_SSA = 2, + STMF_PROTOCOL_IEEE_1394 = 3, + STMF_PROTOCOL_SRP = 4, + STMF_PROTOCOL_ISCSI = 5, + STMF_PROTOCOL_SAS = 6 +} stmfProtocol; + + +typedef struct _stmfGuid +{ + uchar_t guid[16]; +} stmfGuid; + +typedef struct _stmfGuidList +{ + uint32_t cnt; + stmfGuid guid[1]; +} stmfGuidList; + +typedef struct _stmfState +{ + int operationalState; + int configState; +} stmfState; + +typedef struct _stmfDevid +{ + uint8_t identLength; /* length of ident */ + uint8_t ident[STMF_IDENT_LENGTH]; /* SCSI name string ident */ +} stmfDevid; + +typedef struct _stmfDevidList +{ + uint32_t cnt; + stmfDevid devid[1]; +} stmfDevidList; + +typedef char stmfGroupName[256]; +typedef char stmfProviderName[256]; + +typedef struct _stmfGroupList +{ + uint32_t cnt; + stmfGroupName name[1]; +} stmfGroupList; + +typedef struct _stmfProvider +{ + int providerType; + stmfProviderName name; +} stmfProvider; + +typedef struct _stmfProviderList +{ + uint32_t cnt; + stmfProvider provider[1]; +} stmfProviderList; + +typedef struct _stmfSession +{ + stmfDevid initiator; + char alias[256]; + time_t creationTime; +} stmfSession; + +typedef struct _stmfSessionList +{ + uint32_t cnt; + stmfSession session[1]; +} stmfSessionList; + + +typedef struct _stmfViewEntry +{ + boolean_t veIndexValid; /* if B_TRUE, veIndex is valid value */ + uint32_t veIndex; /* View Entry index */ + boolean_t allHosts; /* all initiator ports */ + stmfGroupName hostGroup; /* Host Group Name */ + boolean_t allTargets; /* B_TRUE = targetGroup is invalid */ + stmfGroupName targetGroup; /* Target Group Name */ + boolean_t luNbrValid; /* if B_TRUE, luNbr is a valid value */ + uchar_t luNbr[8]; /* LU number for this view entry */ +} stmfViewEntry; + +typedef struct _stmfViewEntryList +{ + uint32_t cnt; + stmfViewEntry ve[1]; +} stmfViewEntryList; + +typedef struct _stmfViewEntryProperties +{ + stmfGuid associatedLogicalUnitGuid; + stmfViewEntry viewEntry; +} stmfViewEntryProperties; + +typedef struct _stmfGroupProperties +{ + uint32_t cnt; + stmfDevid name[1]; +} stmfGroupProperties; + +typedef struct _stmfTargetProperties +{ + stmfProviderName providerName; + char alias[256]; + uint16_t status; + stmfProtocol protocol; + stmfDevid devid; +} stmfTargetProperties; + +typedef struct _stmfLogicalUnitProperties +{ + char alias[256]; + uchar_t vendor[8]; + uchar_t product[16]; + uchar_t revision[4]; + uint32_t status; + char providerName[256]; + stmfGuid luid; +} stmfLogicalUnitProperties; + +typedef void * luResource; + +typedef struct _stmfLogicalUnitProviderProperties +{ + char providerName[MAXPATHLEN]; + uint32_t instance; + uint32_t status; + uchar_t rsvd[64]; +} stmfLogicalUnitProviderProperties; + +typedef struct _stmfLocalPortProviderProperties +{ + char providerName[MAXPATHLEN]; + uint32_t instance; + uint32_t status; + uchar_t rsvd[64]; +} stmfLocalPortProviderProperties; + +/* API prototypes */ +int stmfAddToHostGroup(stmfGroupName *hostGroupName, stmfDevid *name); +int stmfAddToTargetGroup(stmfGroupName *targetGroupName, stmfDevid *targetName); +int stmfAddViewEntry(stmfGuid *lu, stmfViewEntry *viewEntry); +int stmfClearProviderData(char *providerName, int providerType); +int stmfCreateHostGroup(stmfGroupName *hostGroupName); +int stmfCreateLu(luResource hdl, stmfGuid *luGuid); +int stmfCreateLuResource(uint16_t dType, luResource *hdl); +int stmfCreateTargetGroup(stmfGroupName *targetGroupName); +int stmfDeleteHostGroup(stmfGroupName *hostGroupName); +int stmfDeleteLu(stmfGuid *luGuid); +int stmfDeleteTargetGroup(stmfGroupName *targetGroupName); +void stmfDestroyProxyDoor(int hdl); +int stmfDevidFromIscsiName(char *iscsiName, stmfDevid *devid); +int stmfDevidFromWwn(uchar_t wwn[8], stmfDevid *devid); +int stmfFreeLuResource(luResource hdl); +void stmfFreeMemory(void *); +int stmfGetAluaState(boolean_t *enabled, uint32_t *node); +int stmfGetGlobalLuProp(uint16_t dType, uint32_t prop, char *propVal, + size_t *propLen); +int stmfGetHostGroupList(stmfGroupList **initiatorGroupList); +int stmfGetHostGroupMembers(stmfGroupName *hostGroupName, + stmfGroupProperties **groupProperties); +int stmfGetLocalPortProviderList(stmfProviderList **localPortProviderList); +int stmfGetLocalPortProviderProperties(stmfProviderName *providerName, + stmfLocalPortProviderProperties *providerProperties); +int stmfGetLogicalUnitList(stmfGuidList **logicalUnitList); +int stmfGetLogicalUnitProperties(stmfGuid *logicalUnit, + stmfLogicalUnitProperties *logicalUnitProps); +int stmfGetLogicalUnitProviderList(stmfProviderList **logicalUnitProviderList); +int stmfGetLogicalUnitProviderProperties(stmfProviderName *providerName, + stmfLogicalUnitProviderProperties *providerProperties); +int stmfGetLuProp(luResource hdl, uint32_t propType, char *prop, + size_t *propLen); +int stmfGetLuResource(stmfGuid *luGuid, luResource *hdl); +int stmfGetPersistMethod(uint8_t *persistType, boolean_t serviceState); +int stmfGetProviderData(char *providerName, nvlist_t **nvl, int providerType); +int stmfGetProviderDataProt(char *providerName, nvlist_t **nvl, + int providerType, uint64_t *setToken); +int stmfGetSessionList(stmfDevid *target, stmfSessionList **sessionList); +int stmfGetState(stmfState *); +int stmfGetTargetGroupList(stmfGroupList **targetGroupList); +int stmfGetTargetGroupMembers(stmfGroupName *targetGroupName, + stmfGroupProperties **groupProperties); +int stmfGetTargetList(stmfDevidList **targetList); +int stmfGetTargetProperties(stmfDevid *target, + stmfTargetProperties *targetProps); +int stmfGetViewEntryList(stmfGuid *lu, stmfViewEntryList **viewEntryList); +int stmfImportLu(uint16_t dType, char *fname, stmfGuid *luGuid); +int stmfInitProxyDoor(int *hdl, int fd); +int stmfLoadConfig(void); +int stmfLuStandby(stmfGuid *luGuid); +int stmfModifyLu(stmfGuid *luGuid, uint32_t prop, const char *propVal); +int stmfModifyLuByFname(uint16_t dType, const char *fname, uint32_t prop, + const char *propVal); +int stmfOffline(void); +int stmfOfflineTarget(stmfDevid *devid); +int stmfOfflineLogicalUnit(stmfGuid *logicalUnit); +int stmfOnline(void); +int stmfOnlineTarget(stmfDevid *devid); +int stmfOnlineLogicalUnit(stmfGuid *logicalUnit); +int stmfPostProxyMsg(int hdl, void *buf, uint32_t buflen); +int stmfRemoveFromHostGroup(stmfGroupName *hostGroupName, + stmfDevid *initiatorName); +int stmfRemoveFromTargetGroup(stmfGroupName *targetGroupName, + stmfDevid *targetName); +int stmfRemoveViewEntry(stmfGuid *lu, uint32_t viewEntryIndex); +int stmfSetAluaState(boolean_t enabled, uint32_t node); +int stmfSetGlobalLuProp(uint16_t dType, uint32_t propType, const char *propVal); +int stmfSetLuProp(luResource hdl, uint32_t propType, const char *propVal); +int stmfSetPersistMethod(uint8_t persistType, boolean_t serviceSet); +int stmfSetProviderData(char *providerName, nvlist_t *nvl, int providerType); +int stmfSetProviderDataProt(char *providerName, nvlist_t *nvl, + int providerType, uint64_t *setToken); +int stmfValidateView(stmfViewEntry *viewEntry); +int stmfSetStmfProp(uint8_t propType, char *propVal); +int stmfGetStmfProp(uint8_t propType, char *propVal, size_t *propLen); +int stmfLoadStmfProps(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSTMF_H */ diff --git a/illumos-x86_64/usr/include/libstmfproxy.h b/illumos-x86_64/usr/include/libstmfproxy.h new file mode 100644 index 00000000..1a7e764e --- /dev/null +++ b/illumos-x86_64/usr/include/libstmfproxy.h @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBSTMFPROXY_H +#define _LIBSTMFPROXY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct _pt_ops { + void *(*stmf_proxy_connect)(int server_node, char *server); + ssize_t (*stmf_proxy_send)(void *, void *, size_t); + ssize_t (*stmf_proxy_recv)(void *, void *, size_t); +}; + +typedef struct _pt_ops pt_ops_t; + +int +stmf_proxy_transport_init(char *transport, pt_ops_t **pt_ops); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSTMFPROXY_H */ diff --git a/illumos-x86_64/usr/include/libsun_ima.h b/illumos-x86_64/usr/include/libsun_ima.h new file mode 100644 index 00000000..f11792bc --- /dev/null +++ b/illumos-x86_64/usr/include/libsun_ima.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* header file for iSCSI tunable parameters properties function */ + +#ifndef _LIBSUN_IMA_H +#define _LIBSUN_IMA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef enum { + ISCSI_RX_TIMEOUT_VALUE = 1, + ISCSI_CONN_DEFAULT_LOGIN_MAX = 2, + ISCSI_LOGIN_POLLING_DELAY = 3 +} ISCSI_TUNABLE_OBJECT_TYPE; + +typedef struct _ISCSI_TUNABLE_PARAM { + ISCSI_TUNABLE_OBJECT_TYPE tunable_objectType; + IMA_CHAR *tunable_objectValue; +} ISCSI_TUNABLE_PARAM; + +IMA_API IMA_STATUS SUN_IMA_SetTunableProperties( + IMA_OID oid, + ISCSI_TUNABLE_PARAM *param +); + +IMA_API IMA_STATUS SUN_IMA_GetTunableProperties( + IMA_OID oid, + ISCSI_TUNABLE_PARAM *param +); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSUN_IMA_H */ diff --git a/illumos-x86_64/usr/include/libsysevent.h b/illumos-x86_64/usr/include/libsysevent.h new file mode 100644 index 00000000..54e5ef2a --- /dev/null +++ b/illumos-x86_64/usr/include/libsysevent.h @@ -0,0 +1,119 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBSYSEVENT_H +#define _LIBSYSEVENT_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SYSEVENTD_CHAN "syseventd_channel" + +/* sysevent loadable module ops structure and related defines */ +#define SE_MAX_RETRY_LIMIT 3 +#define SE_RETRY_TIME 1 /* seconds */ +#define SE_NO_RETRY 1 +#define SE_MAJOR_VERSION 0 +#define SE_MINOR_VERSION 0 + +struct slm_mod_ops { + int major_version; + int minor_version; + int retry_limit; + int (*deliver_event)(); +}; + +typedef void *sysevent_handle_t; +typedef void *subscriber_t; + +int sysevent_post_event(char *event_class, char *event_subclass, char *vendor, + char *pub_name, nvlist_t *attr_list, sysevent_id_t *eid); +sysevent_t *sysevent_dup(sysevent_t *ev); +void sysevent_free(sysevent_t *ev); +int sysevent_get_attr_list(sysevent_t *ev, nvlist_t **nvlist); +int sysevent_lookup_attr(sysevent_t *ev, char *name, int datatype, + sysevent_value_t *se_value); +sysevent_attr_t *sysevent_attr_next(sysevent_t *ev, sysevent_attr_t *attr); +char *sysevent_attr_name(sysevent_attr_t *attr); +int sysevent_attr_value(sysevent_attr_t *attr, sysevent_value_t *se_value); +int sysevent_get_class(sysevent_t *ev); +char *sysevent_get_class_name(sysevent_t *ev); +int sysevent_get_subclass(sysevent_t *ev); +char *sysevent_get_subclass_name(sysevent_t *ev); +char *sysevent_get_pub(sysevent_t *ev); +char *sysevent_get_vendor_name(sysevent_t *ev); +char *sysevent_get_pub_name(sysevent_t *ev); +void sysevent_get_pid(sysevent_t *ev, pid_t *pid); +uint64_t sysevent_get_seq(sysevent_t *ev); +void sysevent_get_time(sysevent_t *ev, hrtime_t *etime); +size_t sysevent_get_size(sysevent_t *ev); + +/* syseventd subscriber interfaces */ +sysevent_handle_t *sysevent_bind_handle(void (*event_handler)(sysevent_t *ev)); +sysevent_handle_t *sysevent_bind_xhandle(void (*event_handler)(sysevent_t *ev), + sysevent_subattr_t *); +void sysevent_unbind_handle(sysevent_handle_t *sysevent_hdl); +int sysevent_subscribe_event(sysevent_handle_t *sysevent_hdl, + const char *event_class, const char **event_subclass_list, + int num_subclasses); +void sysevent_unsubscribe_event(sysevent_handle_t *sysevent_hdl, + const char *event_class); + +/* Subscriber private interfaces */ +sysevent_t *sysevent_alloc_event(char *event_class, char *event_subclass, + char *vendor, char *pub_name, nvlist_t *attr_list); +int sysevent_send_event(sysevent_handle_t *shp, sysevent_t *ev); +sysevent_handle_t *sysevent_open_channel(const char *channel); +sysevent_handle_t *sysevent_open_channel_alt(const char *channel_path); +void sysevent_close_channel(sysevent_handle_t *shp); +int sysevent_bind_subscriber(sysevent_handle_t *shp, + void (*event_handler)(sysevent_t *ev)); +int sysevent_bind_xsubscriber(sysevent_handle_t *shp, + void (*event_handler)(sysevent_t *ev), sysevent_subattr_t *); +void sysevent_unbind_subscriber(sysevent_handle_t *shp); +int sysevent_bind_publisher(sysevent_handle_t *shp); +void sysevent_unbind_publisher(sysevent_handle_t *shp); +int sysevent_register_event(sysevent_handle_t *shp, const char *event_class, + const char **event_subclass_list, int num_subclasses); +void sysevent_unregister_event(sysevent_handle_t *shp, + const char *event_class); +void sysevent_cleanup_subscribers(sysevent_handle_t *shp); +void sysevent_cleanup_publishers(sysevent_handle_t *shp); + +/* Debug interfaces */ +void se_print(FILE *fp, sysevent_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSYSEVENT_H */ diff --git a/illumos-x86_64/usr/include/libsysevent_impl.h b/illumos-x86_64/usr/include/libsysevent_impl.h new file mode 100644 index 00000000..edd69881 --- /dev/null +++ b/illumos-x86_64/usr/include/libsysevent_impl.h @@ -0,0 +1,175 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBSYSEVENT_IMPL_H +#define _LIBSYSEVENT_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * libsysevent implementation-specific structures + */ + +/* sysevent publisher/subscriber handle and related data structures */ + +#define CHAN_PATH "/var/run/sysevent_channels" +#define REG_DOOR "reg_door" + +/* Subscription size values */ +#define MAX_SUBSCRIPTION_SZ 1024 + +/* Sysevent Channel Handle */ +typedef struct sysevent_impl_handle { + int sh_bound; /* Channel bind status */ + int sh_type; /* pub/sub channel binding */ + uint32_t sh_id; /* pub/sub within channel */ + int sh_door_desc; /* Service door descrip */ + char *sh_door_name; /* Service door */ + char *sh_channel_name; /* Event Channel name */ + char *sh_channel_path; /* Full path to Event Chan */ + void *sh_priv_data; /* Pub/Sub private data */ + mutex_t sh_lock; /* lock to protect access */ +} sysevent_impl_hdl_t; + +/* Sysevent queue for subscriber delivery */ +typedef struct sysevent_queue { + struct sysevent_queue *sq_next; + sysevent_t *sq_ev; +} sysevent_queue_t; + +/* + * Subscriber private data stored in the sysevent channel handle + */ +typedef struct subscriber_priv { + cond_t sp_cv; /* cv for event synch */ + mutex_t sp_qlock; /* event queue lock */ + char *sp_door_name; /* Publisher reg door */ + thread_t sp_handler_tid; /* delivery handler thread id */ + struct sysevent_queue *sp_evq_head; /* event q head */ + struct sysevent_queue *sp_evq_tail; /* event q tail */ + void (*sp_func)(sysevent_t *ev); /* deliver func */ +} subscriber_priv_t; + +/* Subscriber information stored on the publisher side */ +typedef struct subscriber_data { + int sd_flag; /* flag */ + char *sd_door_name; /* Client door name */ +} subscriber_data_t; + +/* Publisher private data stored in the sysevent channel handle */ +typedef struct publisher_priv { + struct class_lst *pp_class_hash[CLASS_HASH_SZ + 1]; + subscriber_data_t *pp_subscriber_list[MAX_SUBSCRIBERS + 1]; +} publisher_priv_t; + +/* Subscriber flag values */ +#define ACTIVE 1 /* Active subscriber */ +#define SEND_AGAIN 2 /* Resend of event requested */ + +/* Sysevent handle access */ +#define SYSEVENT_IMPL_HNDL(sehp) ((sysevent_impl_hdl_t *)(void *)(sehp)) +#define SH_BOUND(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_bound) +#define SH_TYPE(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_type) +#define SH_RESULT(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_result) +#define SH_ID(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_id) +#define SH_DOOR_DESC(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_door_desc) +#define SH_DOOR_NAME(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_door_name) +#define SH_CHANNEL_NAME(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_channel_name) +#define SH_CHANNEL_PATH(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_channel_path) +#define SH_LOCK(sehp) (&(SYSEVENT_IMPL_HNDL(sehp)->sh_lock)) +#define SH_PRIV_DATA(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_priv_data) + +#define SH_CLASS_HASH(sehp) (((publisher_priv_t *) \ + SH_PRIV_DATA(sehp))->pp_class_hash) +#define SH_SUBSCRIBER(sehp, id) (((publisher_priv_t *) \ + SH_PRIV_DATA(sehp))->pp_subscriber_list[id]) + +/* + * GPEC Interface definitions + */ + +typedef struct evchan_subscriber evchan_subscr_t; + +typedef struct evchan_sub_head { + evchan_subscr_t *evchan_sub_next; +} evchan_sub_head_t; + +/* Event channel handle */ +typedef struct evchan_impl_handle { + pid_t ev_pid; /* verify descend via fork() */ + int ev_fd; /* descriptor for sev driver */ + mutex_t ev_lock; /* lock to protect this structure */ + evchan_sub_head_t ev_sub; /* anchor of subscriber list */ +} evchan_impl_hdl_t; + +/* Evchan handle access */ +#define EVCHAN_IMPL_HNDL(evcp) ((evchan_impl_hdl_t *)(void *)(evcp)) +#define EV_PID(evcp) (EVCHAN_IMPL_HNDL(evcp)->ev_pid) +#define EV_FD(evcp) (EVCHAN_IMPL_HNDL(evcp)->ev_fd) +#define EV_LOCK(evcp) (&(EVCHAN_IMPL_HNDL(evcp)->ev_lock)) +#define EV_SUB(evcp) (&(EVCHAN_IMPL_HNDL(evcp)->ev_sub)) +#define EV_SUB_NEXT(evcp) (EVCHAN_IMPL_HNDL(evcp)->ev_sub.evchan_sub_next) + +struct sysevent_subattr_impl { + door_xcreate_server_func_t *xs_thrcreate; + void *xs_thrcreate_cookie; + door_xcreate_thrsetup_func_t *xs_thrsetup; + void *xs_thrsetup_cookie; + pthread_attr_t *xs_thrattr; + sigset_t xs_sigmask; +}; + +/* + * Subscriber private data + */ +struct evchan_subscriber { + evchan_subscr_t *evsub_next; /* list of subscribers */ + evchan_impl_hdl_t *ev_subhead; /* link back to channel data */ + int evsub_door_desc; /* Service door descriptor */ + char *evsub_sid; /* identifier of subscriber */ + void *evsub_cookie; /* subscriber cookie */ + int (*evsub_func)(sysevent_t *, void *); /* subscriber event handler */ + struct sysevent_subattr_impl *evsub_attr; + uint32_t evsub_state; +}; + +#define EVCHAN_SUB_STATE_ACTIVE 1 +#define EVCHAN_SUB_STATE_CLOSING 2 + +/* Access to subscriber data */ +#define EVCHAN_SUBSCR(subp) ((evchan_subscr_t *)(subp)) + +/* Characters for channel name syntax */ +#define EVCH_ISCHANCHAR(c) (isalnum(c) || (c) == '.' || (c) == ':' || \ + (c) == '-' || (c) == '_') + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSYSEVENT_IMPL_H */ diff --git a/illumos-x86_64/usr/include/libtecla.h b/illumos-x86_64/usr/include/libtecla.h new file mode 100644 index 00000000..dd3bf86f --- /dev/null +++ b/illumos-x86_64/usr/include/libtecla.h @@ -0,0 +1,1834 @@ +#ifndef libtecla_h +#define libtecla_h + +/* + * Copyright (c) 2000, 2001, 2002, 2003, 2004 by Martin C. Shepherd. + * + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include /* FILE * */ +#include /* size_t */ +#include /* time_t */ +#include /* struct sigaction */ + +/* + * The following are the three components of the libtecla version number. + * Note that it is better to use the libtecla_version() function than these + * macros since the macros only tell you which version of the library your + * code was compiled against, whereas the libtecla_version() function + * tells you which version of the shared tecla library your program is + * actually linked to. + */ +#define TECLA_MAJOR_VER 1 +#define TECLA_MINOR_VER 6 +#define TECLA_MICRO_VER 0 + +/*....................................................................... + * Query the version number of the tecla library. + * + * Input: + * major int * The major version number of the library + * will be assigned to *major. This number is + * only incremented when a change to the library is + * made that breaks binary (shared library) and/or + * compilation backwards compatibility. + * minor int * The minor version number of the library + * will be assigned to *minor. This number is + * incremented whenever new functions are added to + * the public API. + * micro int * The micro version number of the library will be + * assigned to *micro. This number is incremented + * whenever internal changes are made that don't + * change the public API, such as bug fixes and + * performance enhancements. + */ +void libtecla_version(int *major, int *minor, int *micro); + +/*----------------------------------------------------------------------- + * The getline module provides interactive command-line input, recall and + * editing by users at terminals. See the gl_get_line(3TECLA) man page for + * more details. + *-----------------------------------------------------------------------*/ + +/* + * Provide an opaque handle for the resource object that is defined in + * getline.h. + */ +typedef struct GetLine GetLine; + +/* + * The following two functions are used to create and delete the + * resource objects that are used by the gl_get_line() function. + */ +GetLine *new_GetLine(size_t linelen, size_t histlen); +GetLine *del_GetLine(GetLine *gl); + +/* + * Read a line into an internal buffer of gl. + */ +char *gl_get_line(GetLine *gl, const char *prompt, const char *start_line, + int start_pos); + +/*....................................................................... + * Prompt the user for a single-character reply. + * + * Input: + * gl GetLine * A resource object returned by new_GetLine(). + * prompt char * The prompt to prefix the query with, or NULL + * to reuse the previous prompt. + * defchar char The character to substitute if the + * user simply hits return, or '\n' if you don't + * need to substitute anything. + * Output: + * return int The character that was read, or EOF if the read + * had to be aborted (in which case you can call + * gl_return_status() to find out why). + */ +int gl_query_char(GetLine *gl, const char *prompt, char defchar); + +/*....................................................................... + * Read a single uninterpretted character from the user, without + * displaying anything. + * + * Input: + * gl GetLine * A resource object previously returned by + * new_GetLine(). + * Output: + * return int The character that was read, or EOF if the read + * had to be aborted (in which case you can call + * gl_return_status() to find out why). + */ +int gl_read_char(GetLine *gl); + +/* + * Configure the application specific and/or user-specific behavior of + * gl_get_line(). + */ +int gl_configure_getline(GetLine *gl, const char *app_string, + const char *app_file, const char *user_file); + +/* + * The following enumerators specify the origin of a key binding, and + * are listed in order of decreasing priority, such that user-specified + * key-bindings take precedence over application default bindings. + */ +typedef enum { + GL_USER_KEY, /* A key-binding specified by the user */ + GL_APP_KEY /* A key-binding specified by the application */ +} GlKeyOrigin; + +/* + * Bind a key sequence to a given action. If action==NULL, unbind the + * key-sequence. + */ +int gl_bind_keyseq(GetLine *gl, GlKeyOrigin origin, const char *keyseq, + const char *action); + +/*----------------------------------------------------------------------- + * The file-expansion module provides facilities for expanding ~user/ and + * $envvar expressions, and for expanding glob-style wildcards. + * See the ef_expand_file(3) man page for more details. + *-----------------------------------------------------------------------*/ + +/* + * ExpandFile objects contain the resources needed to expand pathnames. + */ +typedef struct ExpandFile ExpandFile; + +/* + * The following functions are used to create and delete the resource + * objects that are used by the ef_expand_file() function. + */ +ExpandFile *new_ExpandFile(void); +ExpandFile *del_ExpandFile(ExpandFile *ef); + +/* + * A container of the following type is returned by ef_expand_file(). + */ +typedef struct { + int exists; /* True if the files in files[] currently exist. */ + /* This only time that this may not be true is if */ + /* the input filename didn't contain any wildcards */ + /* and thus wasn't matched against existing files. */ + /* In this case the single entry in 'nfile' may not */ + /* refer to an existing file. */ + int nfile; /* The number of files in files[] */ + char **files; /* An array of 'nfile' filenames. */ +} FileExpansion; + +/* + * The ef_expand_file() function expands a specified pathname, converting + * ~user/ and ~/ patterns at the start of the pathname to the + * corresponding home directories, replacing $envvar with the value of + * the corresponding environment variable, and then, if there are any + * wildcards, matching these against existing filenames. + * + * If no errors occur, a container is returned containing the array of + * files that resulted from the expansion. If there were no wildcards + * in the input pathname, this will contain just the original pathname + * after expansion of ~ and $ expressions. If there were any wildcards, + * then the array will contain the files that matched them. Note that + * if there were any wildcards but no existing files match them, this + * is counted as an error and NULL is returned. + * + * The supported wildcards and their meanings are: + * * - Match any sequence of zero or more characters. + * ? - Match any single character. + * [chars] - Match any single character that appears in 'chars'. + * If 'chars' contains an expression of the form a-b, + * then any character between a and b, including a and b, + * matches. The '-' character looses its special meaning + * as a range specifier when it appears at the start + * of the sequence of characters. + * [^chars] - The same as [chars] except that it matches any single + * character that doesn't appear in 'chars'. + * + * Wildcard expressions are applied to individual filename components. + * They don't match across directory separators. A '.' character at + * the beginning of a filename component must also be matched + * explicitly by a '.' character in the input pathname, since these + * are UNIX's hidden files. + * + * Input: + * fe ExpandFile * The pathname expansion resource object. + * path const char * The path name to be expanded. + * pathlen int The length of the suffix of path[] that + * constitutes the filename to be expanded, + * or -1 to specify that the whole of the + * path string should be used. + * Output: + * return FileExpansion * A pointer to a results container within the + * given ExpandFile object. This contains an + * array of the pathnames that resulted from + * expanding ~ and $ expressions and from + * matching any wildcards, sorted into lexical + * order. + * + * This container and its contents will be + * recycled on subsequent calls, so if you need + * to keep the results of two successive runs, + * you will either have to allocate a private + * copy of the array, or use two ExpandFile + * objects. + * + * On error, NULL is returned. A description + * of the error can be acquired by calling the + * ef_last_error() function. + */ +FileExpansion *ef_expand_file(ExpandFile *ef, const char *path, int pathlen); + +/*....................................................................... + * Print out an array of matching files. + * + * Input: + * result FileExpansion * The container of the sorted array of + * expansions. + * fp FILE * The output stream to write to. + * term_width int The width of the terminal. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int ef_list_expansions(FileExpansion *result, FILE *fp, int term_width); + +/* + * The ef_last_error() function returns a description of the last error + * that occurred in a call ef_expand_file(). Note that this message is + * contained in an array which is allocated as part of *ef, and its + * contents thus potentially change on every call to ef_expand_file(). + */ +const char *ef_last_error(ExpandFile *ef); + +/*----------------------------------------------------------------------- + * The WordCompletion module is used for completing incomplete words, such + * as filenames. Programs can use functions within this module to register + * their own customized completion functions. + *-----------------------------------------------------------------------*/ + +/* + * Ambiguous completion matches are recorded in objects of the + * following type. + */ +typedef struct WordCompletion WordCompletion; + +/* + * Create a new completion object. + */ +WordCompletion *new_WordCompletion(void); + +/* + * Delete a redundant completion object. + */ +WordCompletion *del_WordCompletion(WordCompletion *cpl); + +/*....................................................................... + * Callback functions declared and prototyped using the following macro + * are called upon to return an array of possible completion suffixes + * for the token that precedes a specified location in the given + * input line. It is up to this function to figure out where the token + * starts, and to call cpl_add_completion() to register each possible + * completion before returning. + * + * Input: + * cpl WordCompletion * An opaque pointer to the object that will + * contain the matches. This should be filled + * via zero or more calls to cpl_add_completion(). + * data void * The anonymous 'data' argument that was + * passed to cpl_complete_word() or + * gl_customize_completion()). + * line const char * The current input line. + * word_end int The index of the character in line[] which + * follows the end of the token that is being + * completed. + * Output + * return int 0 - OK. + * 1 - Error. + */ +#define CPL_MATCH_FN(fn) int (fn)(WordCompletion *cpl, void *data, \ + const char *line, int word_end) +typedef CPL_MATCH_FN(CplMatchFn); + +/*....................................................................... + * Optional callback functions declared and prototyped using the + * following macro are called upon to return non-zero if a given + * file, specified by its pathname, is to be included in a list of + * completions. + * + * Input: + * data void * The application specified pointer which + * was specified when this callback function + * was registered. This can be used to have + * anything you like passed to your callback. + * pathname const char * The pathname of the file to be checked to + * see if it should be included in the list + * of completions. + * Output + * return int 0 - Ignore this file. + * 1 - Do include this file in the list + * of completions. + */ +#define CPL_CHECK_FN(fn) int (fn)(void *data, const char *pathname) +typedef CPL_CHECK_FN(CplCheckFn); + +/* + * You can use the following CplCheckFn callback function to only + * have executables included in a list of completions. + */ +CPL_CHECK_FN(cpl_check_exe); + +/* + * cpl_file_completions() is the builtin filename completion callback + * function. This can also be called by your own custom CPL_MATCH_FN() + * callback functions. To do this pass on all of the arguments of your + * custom callback function to cpl_file_completions(), with the exception + * of the (void *data) argument. The data argument should either be passed + * NULL to request the default behaviour of the file-completion function, + * or be passed a pointer to a CplFileConf structure (see below). In the + * latter case the contents of the structure modify the behavior of the + * file-completer. + */ +CPL_MATCH_FN(cpl_file_completions); + +/* + * Objects of the following type can be used to change the default + * behavior of the cpl_file_completions() callback function. + */ +typedef struct CplFileConf CplFileConf; + +/* + * If you want to change the behavior of the cpl_file_completions() + * callback function, call the following function to allocate a + * configuration object, then call one or more of the subsequent + * functions to change any of the default configuration parameters + * that you don't want. This function returns NULL when there is + * insufficient memory. + */ +CplFileConf *new_CplFileConf(void); + +/* + * If backslashes in the prefix being passed to cpl_file_completions() + * should be treated as literal characters, call the following function + * with literal=1. Otherwise the default is to treat them as escape + * characters which remove the special meanings of spaces etc.. + */ +void cfc_literal_escapes(CplFileConf *cfc, int literal); + +/* + * Before calling cpl_file_completions(), call this function if you + * know the index at which the filename prefix starts in the input line. + * Otherwise by default, or if you specify start_index to be -1, the + * filename is taken to start after the first unescaped space preceding + * the cursor, or the start of the line, which ever comes first. + */ +void cfc_file_start(CplFileConf *cfc, int start_index); + +/* + * If you only want certain types of files to be included in the + * list of completions, use the following function to specify a + * callback function which will be called to ask whether a given file + * should be included. The chk_data argument is will be passed to the + * callback function whenever it is called and can be anything you want. + */ +void cfc_set_check_fn(CplFileConf *cfc, CplCheckFn *chk_fn, void *chk_data); + +/* + * The following function deletes a CplFileConf objects previously + * returned by new_CplFileConf(). It always returns NULL. + */ +CplFileConf *del_CplFileConf(CplFileConf *cfc); + +/* + * The following configuration structure is deprecated. Do not change + * its contents, since this will break any programs that still use it, + * and don't use it in new programs. Instead use opaque CplFileConf + * objects as described above. cpl_file_completions() figures out + * what type of structure you pass it, by virtue of a magic int code + * placed at the start of CplFileConf object by new_CplFileConf(). + */ +typedef struct { + int escaped; /* Opposite to the argument of cfc_literal_escapes() */ + int file_start; /* Equivalent to the argument of cfc_file_start() */ +} CplFileArgs; +/* + * This initializes the deprecated CplFileArgs structures. + */ +void cpl_init_FileArgs(CplFileArgs *cfa); + +/*....................................................................... + * When an error occurs while performing a completion, custom completion + * callback functions should register a terse description of the error + * by calling cpl_record_error(). This message will then be returned on + * the next call to cpl_last_error() and used by getline to display an + * error message to the user. + * + * Input: + * cpl WordCompletion * The string-completion resource object that was + * originally passed to the callback. + * errmsg const char * The description of the error. + */ +void cpl_record_error(WordCompletion *cpl, const char *errmsg); + +/*....................................................................... + * This function can be used to replace the builtin filename-completion + * function with one of the user's choice. The user's completion function + * has the option of calling the builtin filename-completion function + * if it believes that the token that it has been presented with is a + * filename (see cpl_file_completions() above). + * + * Input: + * gl GetLine * The resource object of the command-line input + * module. + * data void * This is passed to match_fn() whenever it is + * called. It could, for example, point to a + * symbol table that match_fn() would look up + * matches in. + * match_fn CplMatchFn * The function that will identify the prefix + * to be completed from the input line, and + * report matching symbols. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_customize_completion(GetLine *gl, void *data, CplMatchFn *match_fn); + +/*....................................................................... + * This function allows you to install alternate completion action + * functions or completion listing functions, or to change the + * completion function of an existing action of the same type. This + * should preferably be called before the first call to gl_get_line() + * so that the name of the action becomes defined before the user's + * configuration file is read. + * + * Input: + * gl GetLine * The resource object of the command-line input + * module. + * data void * This is passed to match_fn() whenever it is + * called. It could, for example, point to a + * symbol table that match_fn() would look up + * matches in. + * match_fn CplMatchFn * The function that will identify the prefix + * to be completed from the input line, and + * report matching symbols. + * list_only int If non-zero, install an action that only lists + * possible completions, rather than attempting + * to perform the completion. + * name const char * The name with which users can refer to the + * binding in tecla configuration files. + * keyseq const char * The key sequence with which to invoke + * the binding. This should be specified in the + * same manner as key-sequences in tecla + * configuration files (eg. "M-^I"). + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_completion_action(GetLine *gl, void *data, CplMatchFn *match_fn, + int list_only, const char *name, const char *keyseq); + +/*....................................................................... + * Change the terminal (or stream) that getline interacts with. + * + * Input: + * gl GetLine * The resource object of the command-line input + * module. + * input_fp FILE * The stdio stream to read from. + * output_fp FILE * The stdio stream to write to. + * term const char * The terminal type. This can be NULL if + * either or both of input_fp and output_fp don't + * refer to a terminal. Otherwise it should refer + * to an entry in the terminal information database. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_change_terminal(GetLine *gl, FILE *input_fp, FILE *output_fp, + const char *term); + +/*....................................................................... + * The following functions can be used to save and restore the contents + * of the history buffer. + * + * Input: + * gl GetLine * The resource object of the command-line input + * module. + * filename const char * The name of the new file to write to. + * comment const char * Extra information such as timestamps will + * be recorded on a line started with this + * string, the idea being that the file can + * double as a command file. Specify "" if + * you don't care. Be sure to specify the + * same string to both functions. + * max_lines int The maximum number of lines to save, or -1 + * to save all of the lines in the history + * list. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_save_history(GetLine *gl, const char *filename, const char *comment, + int max_lines); +int gl_load_history(GetLine *gl, const char *filename, const char *comment); + +/* + * Enumerate file-descriptor events that can be waited for. + */ +typedef enum { + GLFD_READ, /* Watch for data waiting to be read from a file descriptor */ + GLFD_WRITE, /* Watch for ability to write to a file descriptor */ + GLFD_URGENT /* Watch for urgent out-of-band data on the file descriptor */ +} GlFdEvent; + +/* + * The following enumeration is used for the return status of file + * descriptor event callbacks. + */ +typedef enum { + GLFD_ABORT, /* Cause gl_get_line() to abort with an error */ + GLFD_REFRESH, /* Redraw the input line and continue waiting for input */ + GLFD_CONTINUE /* Continue to wait for input, without redrawing the line */ +} GlFdStatus; + +/*....................................................................... + * On systems that have the select() system call, while gl_get_line() + * is waiting for terminal input, it can also be asked to listen for + * activity on arbitrary file descriptors. Callback functions of the + * following type can be registered to be called when activity is + * seen. If your callback needs to write to the terminal or use + * signals, please see the gl_get_line(3) man page. + * + * Input: + * gl GetLine * The gl_get_line() resource object. You can use + * this safely to call gl_watch_fd() or + * gl_inactivity_timeout(). The effect of calling other + * functions that take a gl argument is undefined, + * and must be avoided. + * data void * A pointer to arbitrary callback data, as originally + * registered with gl_watch_fd(). + * fd int The file descriptor that has activity. + * event GlFdEvent The activity seen on the file descriptor. The + * inclusion of this argument allows the same + * callback to be registered for multiple events. + * Output: + * return GlFdStatus GLFD_ABORT - Cause gl_get_line() to abort with + * an error (set errno if you need it). + * GLFD_REFRESH - Redraw the input line and continue + * waiting for input. Use this if you + * wrote something to the terminal. + * GLFD_CONTINUE - Continue to wait for input, without + * redrawing the line. + */ +#define GL_FD_EVENT_FN(fn) GlFdStatus (fn)(GetLine *gl, void *data, int fd, \ + GlFdEvent event) +typedef GL_FD_EVENT_FN(GlFdEventFn); + +/*....................................................................... + * Where possible, register a function and associated data to be called + * whenever a specified event is seen on a file descriptor. + * + * Input: + * gl GetLine * The resource object of the command-line input + * module. + * fd int The file descriptor to watch. + * event GlFdEvent The type of activity to watch for. + * callback GlFdEventFn * The function to call when the specified + * event occurs. Setting this to 0 removes + * any existing callback. + * data void * A pointer to arbitrary data to pass to the + * callback function. + * Output: + * return int 0 - OK. + * 1 - Either gl==NULL, or this facility isn't + * available on the the host system + * (ie. select() isn't available). No + * error message is generated in the latter + * case. + */ +int gl_watch_fd(GetLine *gl, int fd, GlFdEvent event, + GlFdEventFn *callback, void *data); + +/* + * Enumerators from the following list are returned by activity + * timeout callbacks registered by gl_inactivity_timeout(). They tell + * gl_get_line() whether and how to procede. + */ +typedef enum { + GLTO_ABORT, /* Cause gl_get_line() to abort with an error */ + GLTO_REFRESH, /* Redraw the input line and continue waiting for input */ + GLTO_CONTINUE /* Continue to wait for input, without redrawing the line */ +} GlAfterTimeout; + +/*....................................................................... + * On systems that have the select() system call, the application has + * the option of providing a callback function of the following type, + * which is called whenever no terminal input or other I/O activity is + * seen for the timeout duration specified in the last call to + * gl_inactivity_timeout(). + * + * Input: + * gl GetLine * The gl_get_line() resource object. You can use + * this safely to call gl_watch_fd() or + * gl_inactivity_timeout(). The effect of calling other + * functions that take a gl argument is undefined, + * and must be avoided. + * data void * A pointer to arbitrary callback data, as + * originally registered with gl_inactivity_timeout(). + * Output: + * return GlAfterTimeout GLTO_ABORT - Cause gl_get_line() to + * abort with an error (set + * errno if you need it). + * GLTO_REFRESH - Redraw the input line and + * continue waiting for + * input. Use this if you + * wrote something to the + * terminal. + * GLTO_CONTINUE - Continue to wait for + * input, without redrawing + * the line. + */ +#define GL_TIMEOUT_FN(fn) GlAfterTimeout (fn)(GetLine *gl, void *data) +typedef GL_TIMEOUT_FN(GlTimeoutFn); + +/*....................................................................... + * On systems with the select() system call, the gl_inactivity_timeout() + * function provides the option of setting (or cancelling) an + * inactivity timeout. Inactivity, in this case, refers both to + * terminal input received from the user, and to I/O on any file + * descriptors registered by calls to gl_watch_fd(). If at any time, + * no activity is seen for the requested time period, the specified + * timeout callback function is called. On returning, this callback + * returns a code which tells gl_get_line() what to do next. Note that + * each call to gl_inactivity_timeout() replaces any previously installed + * timeout callback, and that specifying a callback of 0, turns off + * inactivity timing. + * + * Beware that although the timeout argument includes a nano-second + * component, few computer clocks presently have resolutions finer + * than a few milliseconds, so asking for less than a few milliseconds + * is equivalent to zero on a lot of systems. + * + * Input: + * gl GetLine * The resource object of the command-line input + * module. + * callback GlTimeoutFn * The function to call when the inactivity + * timeout is exceeded. To turn off + * inactivity timeouts altogether, send 0. + * data void * A pointer to arbitrary data to pass to the + * callback function. + * sec unsigned long The number of whole seconds in the timeout. + * nsec unsigned long The fractional number of seconds in the + * timeout, expressed in nano-seconds (see + * the caveat above). + * Output: + * return int 0 - OK. + * 1 - Either gl==NULL, or this facility isn't + * available on the the host system + * (ie. select() isn't available). No + * error message is generated in the latter + * case. + */ +int gl_inactivity_timeout(GetLine *gl, GlTimeoutFn *timeout_fn, void *data, + unsigned long sec, unsigned long nsec); + +/*....................................................................... + * Switch history streams. History streams represent separate history + * lists recorded within a single history buffer. Different streams + * are distinguished by integer identifiers chosen by the calling + * appplicaton. Initially new_GetLine() sets the stream identifier to + * 0. Whenever a new line is appended to the history list, the current + * stream identifier is recorded with it, and history lookups only + * consider lines marked with the current stream identifier. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * id unsigned The new history stream identifier. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_group_history(GetLine *gl, unsigned id); + +/*....................................................................... + * Display the contents of the history list. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * fp FILE * The stdio output stream to write to. + * fmt const char * A format string. This containing characters to be + * written verbatim, plus any of the following + * format directives: + * %D - The date, formatted like 2001-11-20 + * %T - The time of day, formatted like 23:59:59 + * %N - The sequential entry number of the + * line in the history buffer. + * %G - The number of the history group that + * the line belongs to. + * %% - A literal % character. + * %H - The history line itself. + * Note that a '\n' newline character is not + * appended by default. + * all_groups int If true, display history lines from all + * history groups. Otherwise only display + * those of the current history group. + * max_lines int If max_lines is < 0, all available lines + * are displayed. Otherwise only the most + * recent max_lines lines will be displayed. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_show_history(GetLine *gl, FILE *fp, const char *fmt, int all_groups, + int max_lines); + +/*....................................................................... + * Resize or delete the history buffer. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * bufsize size_t The number of bytes in the history buffer, or 0 + * to delete the buffer completely. + * Output: + * return int 0 - OK. + * 1 - Insufficient memory (the previous buffer + * will have been retained). No error message + * will be displayed. + */ +int gl_resize_history(GetLine *gl, size_t bufsize); + +/*....................................................................... + * Set an upper limit to the number of lines that can be recorded in the + * history list, or remove a previously specified limit. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * max_lines int The maximum number of lines to allow, or -1 to + * cancel a previous limit and allow as many lines + * as will fit in the current history buffer size. + */ +void gl_limit_history(GetLine *gl, int max_lines); + +/*....................................................................... + * Discard either all historical lines, or just those associated with the + * current history group. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * all_groups int If true, clear all of the history. If false, + * clear only the stored lines associated with the + * currently selected history group. + */ +void gl_clear_history(GetLine *gl, int all_groups); + +/*....................................................................... + * Temporarily enable or disable the gl_get_line() history mechanism. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * enable int If true, turn on the history mechanism. If + * false, disable it. + */ +void gl_toggle_history(GetLine *gl, int enable); + +/* + * Objects of the following type are returned by gl_terminal_size(). + */ +typedef struct { + int nline; /* The terminal has nline lines */ + int ncolumn; /* The terminal has ncolumn columns */ +} GlTerminalSize; + +/*....................................................................... + * Update if necessary, and return the current size of the terminal. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * def_ncolumn int If the number of columns in the terminal + * can't be determined, substitute this number. + * def_nline int If the number of lines in the terminal can't + * be determined, substitute this number. + * Output: + * return GlTerminalSize The current terminal size. + */ +GlTerminalSize gl_terminal_size(GetLine *gl, int def_ncolumn, int def_nline); + +/*....................................................................... + * Tell gl_get_line() the current terminal size. Note that this is only + * necessary on systems where changes in terminal size aren't reported + * via SIGWINCH. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * ncolumn int The number of columns in the terminal. + * nline int The number of rows in the terminal. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_set_term_size(GetLine *gl, int ncolumn, int nline); + +/* + * The gl_lookup_history() function returns information in an + * argument of the following type. + */ +typedef struct { + const char *line; /* The requested history line */ + unsigned group; /* The history group to which the */ + /* line belongs. */ + time_t timestamp; /* The date and time at which the */ + /* line was originally entered. */ +} GlHistoryLine; + +/*....................................................................... + * Lookup a history line by its sequential number of entry in the + * history buffer. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * id unsigned long The identification number of the line to + * be returned, where 0 denotes the first line + * that was entered in the history list, and + * each subsequently added line has a number + * one greater than the previous one. For + * the range of lines currently in the list, + * see the gl_range_of_history() function. + * Input/Output: + * line GlHistoryLine * A pointer to the variable in which to + * return the details of the line. + * Output: + * return int 0 - The line is no longer in the history + * list, and *line has not been changed. + * 1 - The requested line can be found in + * *line. Note that the string in + * line->line is part of the history + * buffer and will change, so a private + * copy should be made if you wish to + * use it after subsequent calls to any + * functions that take gl as an argument. + */ +int gl_lookup_history(GetLine *gl, unsigned long id, GlHistoryLine *line); + +/* + * The gl_state_of_history() function returns information in an argument + * of the following type. + */ +typedef struct { + int enabled; /* True if history is enabled */ + unsigned group; /* The current history group */ + int max_lines; /* The current upper limit on the number of lines */ + /* in the history list, or -1 if unlimited. */ +} GlHistoryState; + +/*....................................................................... + * Query the state of the history list. Note that any of the input/output + * pointers can be specified as NULL. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * Input/Output: + * state GlHistoryState * A pointer to the variable in which to record + * the return values. + */ +void gl_state_of_history(GetLine *gl, GlHistoryState *state); + +/* + * The gl_range_of_history() function returns information in an argument + * of the following type. + */ +typedef struct { + unsigned long oldest; /* The sequential entry number of the oldest */ + /* line in the history list. */ + unsigned long newest; /* The sequential entry number of the newest */ + /* line in the history list. */ + int nlines; /* The number of lines in the history list */ +} GlHistoryRange; + +/*....................................................................... + * Query the number and range of lines in the history buffer. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * range GlHistoryRange * A pointer to the variable in which to record + * the return values. If range->nline=0, the + * range of lines will be given as 0-0. + */ +void gl_range_of_history(GetLine *gl, GlHistoryRange *range); + +/* + * The gl_size_of_history() function returns information in an argument + * of the following type. + */ +typedef struct { + size_t size; /* The size of the history buffer (bytes) */ + size_t used; /* The number of bytes of the history buffer */ + /* that are currently occupied. */ +} GlHistorySize; + +/*....................................................................... + * Return the size of the history buffer and the amount of the + * buffer that is currently in use. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * Input/Output: + * GlHistorySize size * A pointer to the variable in which to return + * the results. + */ +void gl_size_of_history(GetLine *gl, GlHistorySize *size); + +/*....................................................................... + * Enable or disable the automatic addition of newly entered lines to the + * history list. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * enable int If true, subsequently entered lines will + * automatically be added to the history list + * before they are returned to the caller of + * gl_get_line(). If 0, the choice of how and + * when to archive lines in the history list, + * is left up to the calling application, which + * can do so via calls to gl_append_history(). + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_automatic_history(GetLine *gl, int enable); + +/*....................................................................... + * Append a specified line to the history list. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * line const char * The line to be added. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_append_history(GetLine *gl, const char *line); + +/*....................................................................... + * Specify whether text that users type should be displayed or hidden. + * In the latter case, only the prompt is displayed, and the final + * input line is not archived in the history list. + * + * Input: + * gl GetLine * The input-line history maintenance object. + * enable int 0 - Disable echoing. + * 1 - Enable echoing. + * -1 - Just query the mode without changing it. + * Output: + * return int The echoing disposition that was in effect + * before this function was called: + * 0 - Echoing was disabled. + * 1 - Echoing was enabled. + */ +int gl_echo_mode(GetLine *gl, int enable); + +/*....................................................................... + * This function can be called from gl_get_line() callbacks to have + * the prompt changed when they return. It has no effect if gl_get_line() + * is not currently being invoked. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * prompt const char * The new prompt. + */ +void gl_replace_prompt(GetLine *gl, const char *prompt); + +/* + * Enumerate the available prompt formatting styles. + */ +typedef enum { + GL_LITERAL_PROMPT, /* Display the prompt string literally */ + GL_FORMAT_PROMPT /* The prompt string can contain any of the */ + /* following formatting directives: */ + /* %B - Display subsequent characters */ + /* with a bold font. */ + /* %b - Stop displaying characters */ + /* with the bold font. */ + /* %U - Underline subsequent characters. */ + /* %u - Stop underlining characters. */ + /* %S - Highlight subsequent characters */ + /* (also known as standout mode). */ + /* %s - Stop highlighting characters */ + /* %% - Display a single % character. */ +} GlPromptStyle; + +/*....................................................................... + * Specify whether to heed text attribute directives within prompt + * strings. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * style GlPromptStyle The style of prompt (see the definition of + * GlPromptStyle in libtecla.h for details). + */ +void gl_prompt_style(GetLine *gl, GlPromptStyle style); + +/*....................................................................... + * Remove a signal from the list of signals that gl_get_line() traps. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * signo int The number of the signal to be ignored. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_ignore_signal(GetLine *gl, int signo); + +/* + * A bitwise union of the following enumerators is passed to + * gl_trap_signal() to specify the environment in which the + * application's signal handler is to be called. + */ +typedef enum { + GLS_RESTORE_SIG=1, /* Restore the caller's signal environment */ + /* while handling the signal. */ + GLS_RESTORE_TTY=2, /* Restore the caller's terminal settings */ + /* while handling the signal. */ + GLS_RESTORE_LINE=4, /* Move the cursor to the start of the next line */ + GLS_REDRAW_LINE=8, /* Redraw the input line when the signal handler */ + /* returns. */ + GLS_UNBLOCK_SIG=16, /* Normally a signal who's delivery is found to */ + /* be blocked by the calling application is not */ + /* trapped by gl_get_line(). Including this flag */ + /* causes it to be temporarily unblocked and */ + /* trapped while gl_get_line() is executing. */ + GLS_DONT_FORWARD=32,/* Don't forward the signal to the signal handler */ + /* of the calling program. */ + GLS_RESTORE_ENV = GLS_RESTORE_SIG | GLS_RESTORE_TTY | GLS_REDRAW_LINE, + GLS_SUSPEND_INPUT = GLS_RESTORE_ENV | GLS_RESTORE_LINE +} GlSignalFlags; + +/* + * The following enumerators are passed to gl_trap_signal() to tell + * it what to do after the application's signal handler has been called. + */ +typedef enum { + GLS_RETURN, /* Return the line as though the user had pressed the */ + /* return key. */ + GLS_ABORT, /* Cause gl_get_line() to return NULL */ + GLS_CONTINUE /* After handling the signal, resume command line editing */ +} GlAfterSignal; + +/*....................................................................... + * Tell gl_get_line() how to respond to a given signal. This can be used + * both to override the default responses to signals that gl_get_line() + * normally catches and to add new signals to the list that are to be + * caught. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * signo int The number of the signal to be caught. + * flags unsigned A bitwise union of GlSignalFlags enumerators. + * after GlAfterSignal What to do after the application's signal + * handler has been called. + * errno_value int The value to set errno to. + * Output: + * return int 0 - OK. + * 1 - Insufficient memory to record the + * new signal disposition. + */ +int gl_trap_signal(GetLine *gl, int signo, unsigned flags, + GlAfterSignal after, int errno_value); + +/*....................................................................... + * By default, gl_get_line() doesn't trap signals that are blocked + * when it is called. This default can be changed either on a + * per-signal basis by calling gl_trap_signal(), or on a global basis + * by calling this function. What this function does is add the + * GLS_UNBLOCK_SIG flag to all signals that are currently configured + * to be trapped by gl_get_line(), such that when subsequent calls to + * gl_get_line() wait for I/O, these signals are temporarily + * unblocked. This behavior is useful in non-blocking server-I/O mode, + * where it is used to avoid race conditions related to handling these + * signals externally to gl_get_line(). See the demonstration code in + * demo3.c, or the gl_handle_signal() man page for further + * information. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + */ +void gl_catch_blocked(GetLine *gl); + +/*....................................................................... + * In server-I/O mode the terminal is left in raw mode between calls + * to gl_get_line(), so it is necessary for the application to install + * terminal restoring signal handlers for signals that could terminate + * or suspend the process, plus a terminal reconfiguration handler to + * be called when a process resumption signal is received, and finally + * a handler to be called when a terminal-resize signal is received. + * + * Since there are many signals that by default terminate or suspend + * processes, and different systems support different sub-sets of + * these signals, this function provides a convenient wrapper around + * sigaction() for assigning the specified handlers to all appropriate + * signals. It also arranges that when any one of these signals is + * being handled, all other catchable signals are blocked. This is + * necessary so that the specified signal handlers can safely call + * gl_raw_io(), gl_normal_io() and gl_update_size() without reentrancy + * issues. + * + * Input: + * term_handler void (*)(int) The signal handler to invoke when + * a process terminating signal is + * received. + * susp_handler void (*)(int) The signal handler to invoke when + * a process suspending signal is + * received. + * cont_handler void (*)(int) The signal handler to invoke when + * a process resumption signal is + * received (ie. SIGCONT). + * size_handler void (*)(int) The signal handler to invoke when + * a terminal-resize signal (ie. SIGWINCH) + * is received. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_tty_signals(void (*term_handler)(int), void (*susp_handler)(int), + void (*cont_handler)(int), void (*size_handler)(int)); + +/*....................................................................... + * Return the last signal that was caught by the most recent call to + * gl_get_line(), or -1 if no signals were caught. This is useful if + * gl_get_line() returns errno=EINTR and you need to find out what signal + * caused it to abort. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * Output: + * return int The last signal caught by the most recent + * call to gl_get_line(), or -1 if no signals + * were caught. + */ +int gl_last_signal(GetLine *gl); + +/*....................................................................... + * Return the signal mask used by gl_get_line(). This is the set of + * signals that gl_get_line() is currently configured to trap. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * Input/Output: + * set sigset_t * The set of signals will be returned in *set, + * in the form of a signal process mask, as + * used by sigaction(), sigprocmask(), + * sigpending(), sigsuspend(), sigsetjmp() and + * other standard POSIX signal-aware + * functions. + * Output: + * return int 0 - OK. + * 1 - Error (examine errno for reason). + */ +int gl_list_signals(GetLine *gl, sigset_t *set); + +/*....................................................................... + * Respond to signals who's default effects have important + * consequences to gl_get_line(). This is intended for use in + * non-blocking server mode, where the external event loop is + * responsible for catching signals. Signals that are handled include + * those that by default terminate or suspend the process, and the + * signal that indicates that the terminal size has changed. Note that + * this function is not signal safe and should thus not be called from + * a signal handler itself. See the gl_io_mode() man page for how it + * should be used. + * + * In the case of signals that by default terminate or suspend + * processes, command-line editing will be suspended, the terminal + * returned to a usable state, then the default disposition of the + * signal restored and the signal resent, in order to suspend or + * terminate the process. If the process subsequently resumes, + * command-line editing is resumed. + * + * In the case of signals that indicate that the terminal has been + * resized, the new size will be queried, and any input line that is + * being edited will be redrawn to fit the new dimensions of the + * terminal. + * + * Input: + * signo int The number of the signal to respond to. + * gl GetLine * The first element of an array of 'ngl' GetLine + * objects. + * ngl int The number of elements in the gl[] array. Normally + * this will be one. + */ +void gl_handle_signal(int signo, GetLine *gl, int ngl); + +/*....................................................................... + * Return extra information (ie. in addition to that provided by errno) + * about the last error to occur in either gl_get_line() or its + * associated public functions. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * Input/Output: + * buff char * An optional output buffer. Note that if the + * calling application calls any gl_*() + * functions from signal handlers, it should + * provide a buffer here, so that a copy of + * the latest error message can safely be made + * while signals are blocked. + * n size_t The allocated size of buff[]. + * Output: + * return const char * A pointer to the error message. This will + * be the buff argument, unless buff==NULL, in + * which case it will be a pointer to an + * internal error buffer. In the latter case, + * note that the contents of the returned buffer + * will change on subsequent calls to any gl_*() + * functions. + */ +const char *gl_error_message(GetLine *gl, char *buff, size_t n); + +/*....................................................................... + * Clear the terminal and leave the cursor at the home position. In + * server I/O mode, arrange for the input line to be redrawn from scratch + * when gl_get_line() is next called. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_erase_terminal(GetLine *gl); + +/*....................................................................... + * Display a left-justified string over multiple terminal lines, + * taking account of the current width of the terminal. Optional + * indentation and an optional prefix string can be specified to be + * displayed at the start of each new terminal line used. Similarly, + * an optional suffix can be specified to be displayed at the end of + * each terminal line. If needed, a single paragraph can be broken + * across multiple calls. Note that literal newlines in the input + * string can be used to force a newline at any point and that you + * should use this feature to explicitly end all paragraphs, including + * at the end of the last string that you write. Note that when a new + * line is started between two words that are separated by spaces, + * those spaces are not output, whereas when a new line is started + * because a newline character was found in the string, only the + * spaces before the newline character are discarded. + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * indentation int The number of spaces of indentation to write + * at the beginning of each new terminal line. + * prefix const char * An optional prefix string to write after the + * indentation margin at the start of each new + * terminal line. You can specify NULL if no + * prefix is required. + * suffix const char * An optional suffix string to draw at the end + * of the terminal line. Spaces will be added + * where necessary to ensure that the suffix ends + * in the last column of the terminal line. If + * no suffix is desired, specify NULL. + * fill_char int The padding character to use when indenting + * the line or padding up to the suffix. + * def_width int If the terminal width isn't known, such as when + * writing to a pipe or redirecting to a file, + * this number specifies what width to assume. + * start int The number of characters already written to + * the start of the current terminal line. This + * is primarily used to allow individual + * paragraphs to be written over multiple calls + * to this function, but can also be used to + * allow you to start the first line of a + * paragraph with a different prefix or + * indentation than those specified above. + * string const char * The string to be written. + * Output: + * return int On error -1 is returned. Otherwise the + * return value is the terminal column index at + * which the cursor was left after writing the + * final word in the string. Successful return + * values can thus be passed verbatim to the + * 'start' arguments of subsequent calls to + * gl_display_text() to allow the printing of a + * paragraph to be broken across multiple calls + * to gl_display_text(). + */ +int gl_display_text(GetLine *gl, int indentation, const char *prefix, + const char *suffix, int fill_char, int def_width, + int start, const char *string); + + +/* + * Enumerate the I/O modes supported by gl_get_line(). + */ +typedef enum { + GL_NORMAL_MODE, /* Normal line-at-a-time mode using gl_get_line()'s */ + /* internal event loop. */ + GL_SERVER_MODE /* Non-blocking server mode, driven by an external */ + /* event loop. */ +} GlIOMode; + +/*....................................................................... + * Select the I/O mode to be used by gl_get_line(). + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * mode GlIOMode The I/O mode to establish. Note that + * when server mode, the terminal is placed + * in raw mode, as though gl_raw_io() had + * been called. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_io_mode(GetLine *gl, GlIOMode mode); + +/*....................................................................... + * In server mode, this function configures the terminal for non-blocking + * raw terminal I/O. In normal I/O mode it does nothing. + * + * Callers of this function must be careful to trap all signals that + * terminate or suspend the program, and call gl_normal_io() + * from the corresponding signal handlers in order to restore the + * terminal to its original settings before the program is terminated + * or suspended. They should also trap the SIGCONT signal to detect + * when the program resumes, and ensure that its signal handler + * call gl_raw_io() to redisplay the line and resume editing. + * + * Input: + * gl GetLine * The line editor resource object. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_raw_io(GetLine *gl); + +/*....................................................................... + * Restore the terminal to the state that it had when gl_raw_io() was + * last called. After calling gl_raw_io(), this function must be called + * before terminating or suspending the program, and before attempting + * other uses of the terminal from within the program. See gl_raw_io() + * for more details. + * + * Input: + * gl GetLine * The line editor resource object. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_normal_io(GetLine *gl); + +/*....................................................................... + * When in non-blocking server mode, this function can be used to abandon + * the current incompletely entered input line, and prepare to start + * editing a new line on the next call to gl_get_line(). + * + * Input: + * gl GetLine * The line editor resource object. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +void gl_abandon_line(GetLine *gl); + +/* + * Enumerators of the following type are used to report why + * gl_get_line() returned. This is most useful in non-blocking + * server mode, since in that mode a NULL return value can mean + * either that an error occurred, or that I/O blocked. + */ +typedef enum { + GLR_NEWLINE, /* A new input line was returned */ + GLR_BLOCKED, /* The terminal was in non-blocking mode, and input */ + /* or output would have blocked. */ + GLR_SIGNAL, /* A signal caused gl_get_line() to return. */ + GLR_TIMEOUT, /* An application timeout callback returned GLTO_ABORT */ + GLR_FDABORT, /* An application I/O callack returned GLFD_ABORT */ + GLR_EOF, /* End of file reached */ + GLR_ERROR /* An unexpected error caused gl_get_line() to abort */ +} GlReturnStatus; + +/*....................................................................... + * Ask gl_get_line() what caused it to return. + * + * Input: + * gl GetLine * The line editor resource object. + * Output: + * return GlReturnStatus The return status of the last call to + * gl_get_line(). + */ +GlReturnStatus gl_return_status(GetLine *gl); + +/* + * Enumerate the types of I/O that gl_get_line() can be waiting for + * in non-blocking sedrver I/O mode. + */ +typedef enum { + GLP_READ, /* gl_get_line() is waiting to write to the terminal */ + GLP_WRITE /* gl_get_line() is waiting to read from the terminal */ +} GlPendingIO; + +/*....................................................................... + * In non-blocking server-I/O mode, this function should be called + * from the application's external event loop to see what type of + * terminal I/O is being waited for by gl_get_line(), and thus what + * direction of I/O to wait for with select() or poll(). + * + * Input: + * gl GetLine * The resource object of gl_get_line(). + * Output: + * return GlPendingIO The type of pending I/O being waited for. + */ +GlPendingIO gl_pending_io(GetLine *gl); + +/* + * The following enumerators are returned by externally defined action + * functions to tell gl_get_line() how to procede after the action + * function returns. + */ +typedef enum { + GLA_ABORT, /* Cause gl_get_line() to return NULL */ + GLA_RETURN, /* Return the line as though the user had pressed the */ + /* return key. */ + GLA_CONTINUE /* Resume command-line editing */ +} GlAfterAction; + +/*....................................................................... + * Functions of the following form implement external + * application-specific action functions, which can then be bound to + * sequences of terminal keys. + * + * Input: + * gl GetLine * The line editor resource object. + * data void * The anonymous 'data' argument that was + * passed to gl_external_action() when the + * callback function was registered. + * count int A positive repeat count specified by the user, + * or 1 if not specified. Action functions should + * ignore this if repeating the action multiple + * times isn't appropriate. Alternatively they + * can interpret it as a general numeric + * argument. + * curpos size_t The position of the cursor within the input + * line, expressed as the index of the + * corresponding character within the line[] + * array. + * line const char * A read-only copy of the current input line. + * Output + * return GlAfterAction What should gl_get_line() do when the action + * function returns? + * GLA_ABORT - Cause gl_get_line() to + * abort with an error (set + * errno if you need it). + * GLA_RETURN - Return the input line as + * though the user had typed + * the return key. + * GLA_CONTINUE - Resume waiting for keyboard + * input. + */ +#define GL_ACTION_FN(fn) GlAfterAction (fn)(GetLine *gl, void *data, \ + int count, size_t curpos, const char *line) + +typedef GL_ACTION_FN(GlActionFn); + +/*....................................................................... + * Register an application-provided function as an action function. + * This should preferably be called before the first call to gl_get_line() + * so that the name of the action becomes defined before the user's + * configuration file is read. + * + * Input: + * gl GetLine * The resource object of the command-line input + * module. + * data void * Arbitrary application-specific callback + * data to be passed to the callback + * function, fn(). + * fn GlActionFn * The application-specific function that + * implements the action. This will be invoked + * whenever the user presses any + * key-sequence which is bound to this action. + * name const char * The name with which users can refer to the + * binding in tecla configuration files. + * keyseq const char * The key sequence with which to invoke + * the binding. This should be specified in the + * same manner as key-sequences in tecla + * configuration files (eg. "M-^I"). + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int gl_register_action(GetLine *gl, void *data, GlActionFn *fn, + const char *name, const char *keyseq); + +/*....................................................................... + * This function is designed to be called by CPL_MATCH_FN() callback + * functions. It adds one possible completion of the token that is being + * completed to an array of completions. If the completion needs any + * special quoting to be valid when displayed in the input line, this + * quoting must be included in the string. + * + * Input: + * cpl WordCompletion * The argument of the same name that was passed + * to the calling CPL_MATCH_FN() callback function. + * line const char * The input line, as received by the callback + * function. + * word_start int The index within line[] of the start of the + * word that is being completed. If an empty + * string is being completed, set this to be + * the same as word_end. + * word_end int The index within line[] of the character which + * follows the incomplete word, as received by the + * callback function. + * suffix const char * The appropriately quoted string that could + * be appended to the incomplete token to complete + * it. A copy of this string will be allocated + * internally. + * type_suffix const char * When listing multiple completions, gl_get_line() + * appends this string to the completion to indicate + * its type to the user. If not pertinent pass "". + * Otherwise pass a literal or static string. + * cont_suffix const char * If this turns out to be the only completion, + * gl_get_line() will append this string as + * a continuation. For example, the builtin + * file-completion callback registers a directory + * separator here for directory matches, and a + * space otherwise. If the match were a function + * name you might want to append an open + * parenthesis, etc.. If not relevant pass "". + * Otherwise pass a literal or static string. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int cpl_add_completion(WordCompletion *cpl, const char *line, + int word_start, int word_end, const char *suffix, + const char *type_suffix, const char *cont_suffix); + +/* + * Each possible completion string is recorded in an array element of + * the following type. + */ +typedef struct { + char *completion; /* The matching completion string */ + char *suffix; /* The pointer into completion[] at which the */ + /* string was extended. */ + const char *type_suffix; /* A suffix to be added when listing completions */ + /* to indicate the type of the completion. */ +} CplMatch; + +/* + * Completions are returned in a container of the following form. + */ +typedef struct { + char *suffix; /* The common initial part of all of the */ + /* completion suffixes. */ + const char *cont_suffix; /* Optional continuation string to be appended to */ + /* the sole completion when nmatch==1. */ + CplMatch *matches; /* The array of possible completion strings, */ + /* sorted into lexical order. */ + int nmatch; /* The number of elements in matches[] */ +} CplMatches; + +/*....................................................................... + * Given an input line and the point at which completion is to be + * attempted, return an array of possible completions. + * + * Input: + * cpl WordCompletion * The word-completion resource object. + * line const char * The current input line. + * word_end int The index of the character in line[] which + * follows the end of the token that is being + * completed. + * data void * Anonymous 'data' to be passed to match_fn(). + * match_fn CplMatchFn * The function that will identify the prefix + * to be completed from the input line, and + * record completion suffixes. + * Output: + * return CplMatches * The container of the array of possible + * completions. The returned pointer refers + * to a container owned by the parent Completion + * object, and its contents thus potentially + * change on every call to cpl_complete_word(). + */ +CplMatches *cpl_complete_word(WordCompletion *cpl, const char *line, + int word_end, void *data, + CplMatchFn *match_fn); + +/*....................................................................... + * Recall the return value of the last call to cpl_complete_word(). + * + * Input: + * cpl WordCompletion * The completion resource object. + * Output: + * return CplMatches * The container of the array of possible + * completions, as returned by the last call to + * cpl_complete_word(). The returned pointer refers + * to a container owned by the parent WordCompletion + * object, and its contents thus potentially + * change on every call to cpl_complete_word(). + * On error, either in the execution of this + * function, or in the last call to + * cpl_complete_word(), NULL is returned, and a + * description of the error can be acquired by + * calling cpl_last_error(cpl). + */ +CplMatches *cpl_recall_matches(WordCompletion *cpl); + +/*....................................................................... + * Print out an array of matching completions. + * + * Input: + * result CplMatches * The container of the sorted array of + * completions. + * fp FILE * The output stream to write to. + * term_width int The width of the terminal. + * Output: + * return int 0 - OK. + * 1 - Error. + */ +int cpl_list_completions(CplMatches *result, FILE *fp, int term_width); + +/*....................................................................... + * Return a description of the error that occurred on the last call to + * cpl_complete_word() or cpl_add_completion(). + * + * Input: + * cpl WordCompletion * The string-completion resource object. + * Output: + * return const char * The description of the last error. + */ +const char *cpl_last_error(WordCompletion *cpl); + +/* + * PathCache objects encapsulate the resources needed to record + * files of interest from comma-separated lists of directories. + */ +typedef struct PathCache PathCache; + +/*....................................................................... + * Create an object who's function is to maintain a cache of filenames + * found within a list of directories, and provide quick lookup and + * completion of selected files in this cache. + * + * Output: + * return PathCache * The new, initially empty cache, or NULL + * on error. + */ +PathCache *new_PathCache(void); + +/*....................................................................... + * Delete a given cache of files, returning the resources that it + * was using to the system. + * + * Input: + * pc PathCache * The cache to be deleted (can be NULL). + * Output: + * return PathCache * The deleted object (ie. allways NULL). + */ +PathCache *del_PathCache(PathCache *pc); + +/*....................................................................... + * Return a description of the last path-caching error that occurred. + * + * Input: + * pc PathCache * The filename cache that suffered the error. + * Output: + * return char * The description of the last error. + */ +const char *pca_last_error(PathCache *pc); + +/*....................................................................... + * Build the list of files of interest contained in a given + * colon-separated list of directories. + * + * Input: + * pc PathCache * The cache in which to store the names of + * the files that are found in the list of + * directories. + * path const char * A colon-separated list of directory + * paths. Under UNIX, when searching for + * executables, this should be the return + * value of getenv("PATH"). + * Output: + * return int 0 - OK. + * 1 - An error occurred. + */ +int pca_scan_path(PathCache *pc, const char *path); + +/*....................................................................... + * If you want subsequent calls to pca_lookup_file() and + * pca_path_completions() to only return the filenames of certain + * types of files, for example executables, or filenames ending in + * ".ps", call this function to register a file-selection callback + * function. This callback function takes the full pathname of a file, + * plus application-specific data, and returns 1 if the file is of + * interest, and zero otherwise. + * + * Input: + * pc PathCache * The filename cache. + * check_fn CplCheckFn * The function to call to see if the name of + * a given file should be included in the + * cache. This determines what type of files + * will reside in the cache. To revert to + * selecting all files, regardless of type, + * pass 0 here. + * data void * You can pass a pointer to anything you + * like here, including NULL. It will be + * passed to your check_fn() callback + * function, for its private use. + */ +void pca_set_check_fn(PathCache *pc, CplCheckFn *check_fn, void *data); + +/*....................................................................... + * Given the simple name of a file, search the cached list of files + * in the order in which they where found in the list of directories + * previously presented to pca_scan_path(), and return the pathname + * of the first file which has this name. + * + * Input: + * pc PathCache * The cached list of files. + * name const char * The name of the file to lookup. + * name_len int The length of the filename substring at the + * beginning of name[], or -1 to assume that the + * filename occupies the whole of the string. + * literal int If this argument is zero, lone backslashes + * in name[] are ignored during comparison + * with filenames in the cache, under the + * assumption that they were in the input line + * soley to escape the special significance of + * characters like spaces. To have them treated + * as normal characters, give this argument a + * non-zero value, such as 1. + * Output: + * return char * The pathname of the first matching file, + * or NULL if not found. Note that the returned + * pointer points to memory owned by *pc, and + * will become invalid on the next call. + */ +char *pca_lookup_file(PathCache *pc, const char *name, int name_len, + int literal); + +/* + * Objects of the following type can be used to change the default + * behavior of the pca_path_completions() callback function. + */ +typedef struct PcaPathConf PcaPathConf; + +/* + * pca_path_completions() is a completion callback function for use directly + * with cpl_complete_word() or gl_customize_completions(), or indirectly + * from your own completion callback function. It requires that a PcaPathConf + * object be passed via its 'void *data' argument (see below). + */ +CPL_MATCH_FN(pca_path_completions); + +/*....................................................................... + * Allocate and initialize a pca_path_completions() configuration object. + * + * Input: + * pc PathCache * The filename cache in which to look for + * file name completions. + * Output: + * return PcaPathConf * The new configuration structure, or NULL + * on error. + */ +PcaPathConf *new_PcaPathConf(PathCache *pc); + +/*....................................................................... + * Deallocate memory, previously allocated by new_PcaPathConf(). + * + * Input: + * ppc PcaPathConf * Any pointer previously returned by + * new_PcaPathConf() [NULL is allowed]. + * Output: + * return PcaPathConf * The deleted structure (always NULL). + */ +PcaPathConf *del_PcaPathConf(PcaPathConf *ppc); + +/* + * If backslashes in the prefix being passed to pca_path_completions() + * should be treated as literal characters, call the following function + * with literal=1. Otherwise the default is to treat them as escape + * characters which remove the special meanings of spaces etc.. + */ +void ppc_literal_escapes(PcaPathConf *ppc, int literal); + +/* + * Before calling pca_path_completions, call this function if you know + * the index at which the filename prefix starts in the input line. + * Otherwise by default, or if you specify start_index to be -1, the + * filename is taken to start after the first unescaped space preceding + * the cursor, or the start of the line, whichever comes first. + */ +void ppc_file_start(PcaPathConf *ppc, int start_index); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/libtsnet.h b/illumos-x86_64/usr/include/libtsnet.h new file mode 100644 index 00000000..091a3bfe --- /dev/null +++ b/illumos-x86_64/usr/include/libtsnet.h @@ -0,0 +1,147 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * All symbols and functions in this header file and library are private to Sun + * Microsystems. The only guarantee that is made is that if your application + * uses them, it will break on upgrade. + */ + +#ifndef _LIBTSNET_H +#define _LIBTSNET_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TNRHTP_PATH "/etc/security/tsol/tnrhtp" +#define TNRHDB_PATH "/etc/security/tsol/tnrhdb" +#define TNZONECFG_PATH "/etc/security/tsol/tnzonecfg" + +#define TNDB_COMMA ", \t" +#define TN_RESERVED ",#;" + +/* + * String parsing routines + * + * These functions are in four logical groups: one for template (tnrhtp) + * entries, one for remote host (tnrhdb) entries, one for zone configuration + * (tnzonecfg) entries, and a fourth for routing attributes. + * + * In each group, there are functions that parse from a string or database, and + * a function to free returned entries. The parsing functions all take a + * pointer to an integer and a pointer to a character pointer for returning + * errors. On error, the returned entry pointer is NULL, the integer is set to + * one of the LTSNET_* errors below, and the character pointer points to the + * location of the error. (For the functions that iterate on a database, this + * points into static storage in the library. This storage is associated with + * the iterator.) + * + * The functions that do look-ups based on a value (name or address) do not + * return errors other than "not found," which is signaled by a return value of + * NULL. + */ + +/* Template entry parsing */ +extern tsol_tpent_t *tsol_gettpbyname(const char *); +extern tsol_tpent_t *tsol_gettpent(void); +extern tsol_tpent_t *tsol_fgettpent(FILE *, boolean_t *); +extern void tsol_freetpent(tsol_tpent_t *); +extern void tsol_settpent(int); +extern void tsol_endtpent(void); +extern int str_to_tpstr(const char *, int, void *, char *, int); +extern tsol_tpent_t *tpstr_to_ent(tsol_tpstr_t *, int *, char **); + +/* Remote host entry parsing */ +extern tsol_rhent_t *tsol_getrhbyaddr(const void *, size_t, int); +extern tsol_rhent_t *tsol_getrhent(void); +extern tsol_rhent_t *tsol_fgetrhent(FILE *, boolean_t *); +extern void tsol_freerhent(tsol_rhent_t *); +extern void tsol_setrhent(int); +extern void tsol_endrhent(void); +extern int str_to_rhstr(const char *, int, void *, char *, int); +extern tsol_rhent_t *rhstr_to_ent(tsol_rhstr_t *, int *, char **); +extern tsol_host_type_t tsol_getrhtype(char *); + + +/* Zone configuration parsing */ +extern tsol_zcent_t *tsol_sgetzcent(const char *, int *, char **); +extern void tsol_freezcent(tsol_zcent_t *); + +/* Routing attribute parsing */ +extern char *sl_to_str(const m_label_t *); +struct rtsa_s; +extern const char *rtsa_to_str(const struct rtsa_s *, char *, size_t); +extern boolean_t rtsa_keyword(const char *, struct rtsa_s *, int *, char **); +extern const char *parse_entry(char *, size_t, const char *, const char *); + +/* Convert LTSNET_* to a printable string */ +extern const char *tsol_strerror(int, int); + +/* System calls; these return -1 on error and set errno */ +extern int tnrhtp(int, tsol_tpent_t *); +extern int tnrh(int, tsol_rhent_t *); +extern int tnmlp(int, tsol_mlpent_t *); + +/* + * Errors that can occur in the parsing routines. Note that not all errors are + * possible with every routine. Must be kept in sync with list in misc.c. + */ +#define LTSNET_NONE 0 /* No error */ +#define LTSNET_SYSERR 1 /* System error; see errno */ +#define LTSNET_EMPTY 2 /* Empty string or end of list */ +#define LTSNET_ILL_ENTRY 3 /* Entry is malformed */ +#define LTSNET_NO_NAME 4 /* Missing name */ +#define LTSNET_NO_ATTRS 5 /* Missing template attributes */ +#define LTSNET_ILL_NAME 6 /* Illegal name */ +#define LTSNET_ILL_KEYDELIM 7 /* Illegal keyword delimiter */ +#define LTSNET_ILL_KEY 8 /* Unknown keyword */ +#define LTSNET_DUP_KEY 9 /* Duplicate keyword */ +#define LTSNET_ILL_VALDELIM 10 /* Illegal value delimiter */ +#define LTSNET_NO_HOSTTYPE 11 /* Missing host type */ +#define LTSNET_ILL_HOSTTYPE 12 /* Illegal host type */ +#define LTSNET_NO_LABEL 13 /* Missing label */ +#define LTSNET_ILL_LABEL 14 /* Illegal label */ +#define LTSNET_NO_RANGE 15 /* Missing label range */ +#define LTSNET_ILL_RANGE 16 /* Illegal label range */ +#define LTSNET_NO_LOWERBOUND 17 /* No lower bound in range */ +#define LTSNET_ILL_LOWERBOUND 18 /* Illegal lower bound in range */ +#define LTSNET_NO_UPPERBOUND 19 /* No upper bound in range */ +#define LTSNET_ILL_UPPERBOUND 20 /* Illegal upper bound in range */ +#define LTSNET_NO_DOI 21 /* Missing DOI */ +#define LTSNET_ILL_DOI 22 /* Illegal DOI */ +#define LTSNET_SET_TOO_BIG 23 /* Too many entries in set */ +#define LTSNET_NO_ADDR 24 /* Missing address/network */ +#define LTSNET_ILL_ADDR 25 /* Illegal address/network */ +#define LTSNET_ILL_FLAG 26 /* Illegal flag */ +#define LTSNET_ILL_MLP 27 /* Illegal MLP specification */ +#define LTSNET_BAD_TYPE 28 /* Unacceptable keyword for type */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBTSNET_H */ diff --git a/illumos-x86_64/usr/include/libw.h b/illumos-x86_64/usr/include/libw.h new file mode 100644 index 00000000..43102a4b --- /dev/null +++ b/illumos-x86_64/usr/include/libw.h @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _LIBW_H +#define _LIBW_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _EUCWIDTH_T +#define _EUCWIDTH_T +typedef struct { + short int _eucw1, _eucw2, _eucw3; /* EUC width */ + short int _scrw1, _scrw2, _scrw3; /* screen width */ + short int _pcw; /* WIDE_CHAR width */ + char _multibyte; /* 1=multi-byte, 0=single-byte */ +} eucwidth_t; +#endif + +void getwidth(eucwidth_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBW_H */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/HTMLparser.h b/illumos-x86_64/usr/include/libxml2/libxml/HTMLparser.h new file mode 100644 index 00000000..cfe378a7 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/HTMLparser.h @@ -0,0 +1,339 @@ +/* + * Summary: interface for an HTML 4.0 non-verifying parser + * Description: this module implements an HTML 4.0 non-verifying parser + * with API compatible with the XML parser ones. It should + * be able to parse "real world" HTML, even if severely + * broken from a specification point of view. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __HTML_PARSER_H__ +#define __HTML_PARSER_H__ +#include +#include + +#ifdef LIBXML_HTML_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Backward compatibility + */ +#define UTF8ToHtml htmlUTF8ToHtml + +/* + * Most of the back-end structures from XML and HTML are shared. + */ +typedef xmlParserCtxt htmlParserCtxt; +typedef xmlParserCtxtPtr htmlParserCtxtPtr; +typedef xmlParserNodeInfo htmlParserNodeInfo; +typedef xmlSAXHandler htmlSAXHandler; +typedef xmlSAXHandlerPtr htmlSAXHandlerPtr; +typedef xmlParserInput htmlParserInput; +typedef xmlParserInputPtr htmlParserInputPtr; +typedef xmlDocPtr htmlDocPtr; +typedef xmlNodePtr htmlNodePtr; + +/* + * Internal description of an HTML element, representing HTML 4.01 + * and XHTML 1.0 (which share the same structure). + */ +typedef struct _htmlElemDesc htmlElemDesc; +typedef htmlElemDesc *htmlElemDescPtr; +struct _htmlElemDesc { + const char *name; /* The tag name */ + char startTag; /* unused */ + char endTag; /* Whether the end tag can be implied */ + char saveEndTag; /* Whether the end tag should be saved */ + char empty; /* Is this an empty element ? */ + char depr; /* unused */ + char dtd; /* unused */ + char isinline; /* is this a block 0 or inline 1 element */ + const char *desc; /* the description */ + + const char** subelts XML_DEPRECATED_MEMBER; + const char* defaultsubelt XML_DEPRECATED_MEMBER; + const char** attrs_opt XML_DEPRECATED_MEMBER; + const char** attrs_depr XML_DEPRECATED_MEMBER; + const char** attrs_req XML_DEPRECATED_MEMBER; + + int dataMode; +}; + +/* + * Internal description of an HTML entity. + */ +typedef struct _htmlEntityDesc htmlEntityDesc; +typedef htmlEntityDesc *htmlEntityDescPtr; +struct _htmlEntityDesc { + unsigned int value; /* the UNICODE value for the character */ + const char *name; /* The entity name */ + const char *desc; /* the description */ +}; + +#ifdef LIBXML_SAX1_ENABLED + +XML_DEPRECATED +XMLPUBVAR const xmlSAXHandlerV1 htmlDefaultSAXHandler; + +#endif /* LIBXML_SAX1_ENABLED */ + +/* + * There is only few public functions. + */ +XML_DEPRECATED +XMLPUBFUN void + htmlInitAutoClose (void); +XMLPUBFUN const htmlElemDesc * + htmlTagLookup (const xmlChar *tag); +XMLPUBFUN const htmlEntityDesc * + htmlEntityLookup(const xmlChar *name); +XMLPUBFUN const htmlEntityDesc * + htmlEntityValueLookup(unsigned int value); + +XML_DEPRECATED +XMLPUBFUN int + htmlIsAutoClosed(htmlDocPtr doc, + htmlNodePtr elem); +XML_DEPRECATED +XMLPUBFUN int + htmlAutoCloseTag(htmlDocPtr doc, + const xmlChar *name, + htmlNodePtr elem); +XML_DEPRECATED +XMLPUBFUN const htmlEntityDesc * + htmlParseEntityRef(htmlParserCtxtPtr ctxt, + const xmlChar **str); +XML_DEPRECATED +XMLPUBFUN int + htmlParseCharRef(htmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + htmlParseElement(htmlParserCtxtPtr ctxt); + +XMLPUBFUN htmlParserCtxtPtr + htmlNewParserCtxt(void); +XMLPUBFUN htmlParserCtxtPtr + htmlNewSAXParserCtxt(const htmlSAXHandler *sax, + void *userData); + +XMLPUBFUN htmlParserCtxtPtr + htmlCreateMemoryParserCtxt(const char *buffer, + int size); + +XMLPUBFUN int + htmlParseDocument(htmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN htmlDocPtr + htmlSAXParseDoc (const xmlChar *cur, + const char *encoding, + htmlSAXHandlerPtr sax, + void *userData); +XMLPUBFUN htmlDocPtr + htmlParseDoc (const xmlChar *cur, + const char *encoding); +XMLPUBFUN htmlParserCtxtPtr + htmlCreateFileParserCtxt(const char *filename, + const char *encoding); +XML_DEPRECATED +XMLPUBFUN htmlDocPtr + htmlSAXParseFile(const char *filename, + const char *encoding, + htmlSAXHandlerPtr sax, + void *userData); +XMLPUBFUN htmlDocPtr + htmlParseFile (const char *filename, + const char *encoding); +XMLPUBFUN int + htmlUTF8ToHtml (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +XMLPUBFUN int + htmlEncodeEntities(unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen, int quoteChar); +XMLPUBFUN int + htmlIsScriptAttribute(const xmlChar *name); +XML_DEPRECATED +XMLPUBFUN int + htmlHandleOmittedElem(int val); + +#ifdef LIBXML_PUSH_ENABLED +/** + * Interfaces for the Push mode. + */ +XMLPUBFUN htmlParserCtxtPtr + htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename, + xmlCharEncoding enc); +XMLPUBFUN int + htmlParseChunk (htmlParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +#endif /* LIBXML_PUSH_ENABLED */ + +XMLPUBFUN void + htmlFreeParserCtxt (htmlParserCtxtPtr ctxt); + +/* + * New set of simpler/more flexible APIs + */ +/** + * xmlParserOption: + * + * This is the set of XML parser options that can be passed down + * to the xmlReadDoc() and similar calls. + */ +typedef enum { + HTML_PARSE_RECOVER = 1<<0, /* No effect */ + HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */ + HTML_PARSE_NOERROR = 1<<5, /* suppress error reports */ + HTML_PARSE_NOWARNING= 1<<6, /* suppress warning reports */ + HTML_PARSE_PEDANTIC = 1<<7, /* No effect */ + HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ + HTML_PARSE_NONET = 1<<11,/* No effect */ + HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */ + HTML_PARSE_COMPACT = 1<<16,/* compact small text nodes */ + HTML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */ + HTML_PARSE_IGNORE_ENC=1<<21,/* ignore internal document encoding hint */ + HTML_PARSE_BIG_LINES= 1<<22,/* Store big lines numbers in text PSVI field */ + HTML_PARSE_HTML5 = 1<<26 /* HTML5 support */ +} htmlParserOption; + +XMLPUBFUN void + htmlCtxtReset (htmlParserCtxtPtr ctxt); +XMLPUBFUN int + htmlCtxtSetOptions (htmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN int + htmlCtxtUseOptions (htmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN htmlDocPtr + htmlReadDoc (const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlReadFile (const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlReadMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlReadFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlCtxtParseDocument (htmlParserCtxtPtr ctxt, + xmlParserInputPtr input); +XMLPUBFUN htmlDocPtr + htmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr + htmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +/* deprecated content model + */ +typedef enum { + HTML_NA = 0 , /* something we don't check at all */ + HTML_INVALID = 0x1 , + HTML_DEPRECATED = 0x2 , + HTML_VALID = 0x4 , + HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */ +} htmlStatus ; + +/* Using htmlElemDesc rather than name here, to emphasise the fact + that otherwise there's a lookup overhead +*/ +XML_DEPRECATED +XMLPUBFUN htmlStatus htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ; +XML_DEPRECATED +XMLPUBFUN int htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ; +XML_DEPRECATED +XMLPUBFUN htmlStatus htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ; +XML_DEPRECATED +XMLPUBFUN htmlStatus htmlNodeStatus(htmlNodePtr, int) ; +/** + * htmlDefaultSubelement: + * @elt: HTML element + * + * Returns the default subelement for this element + */ +#define htmlDefaultSubelement(elt) elt->defaultsubelt +/** + * htmlElementAllowedHereDesc: + * @parent: HTML parent element + * @elt: HTML element + * + * Checks whether an HTML element description may be a + * direct child of the specified element. + * + * Returns 1 if allowed; 0 otherwise. + */ +#define htmlElementAllowedHereDesc(parent,elt) \ + htmlElementAllowedHere((parent), (elt)->name) +/** + * htmlRequiredAttrs: + * @elt: HTML element + * + * Returns the attributes required for the specified element. + */ +#define htmlRequiredAttrs(elt) (elt)->attrs_req + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTML_ENABLED */ +#endif /* __HTML_PARSER_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/HTMLtree.h b/illumos-x86_64/usr/include/libxml2/libxml/HTMLtree.h new file mode 100644 index 00000000..065254f4 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/HTMLtree.h @@ -0,0 +1,148 @@ +/* + * Summary: specific APIs to process HTML tree, especially serialization + * Description: this module implements a few function needed to process + * tree in an HTML specific way. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __HTML_TREE_H__ +#define __HTML_TREE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_HTML_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * HTML_TEXT_NODE: + * + * Macro. A text node in a HTML document is really implemented + * the same way as a text node in an XML document. + */ +#define HTML_TEXT_NODE XML_TEXT_NODE +/** + * HTML_ENTITY_REF_NODE: + * + * Macro. An entity reference in a HTML document is really implemented + * the same way as an entity reference in an XML document. + */ +#define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE +/** + * HTML_COMMENT_NODE: + * + * Macro. A comment in a HTML document is really implemented + * the same way as a comment in an XML document. + */ +#define HTML_COMMENT_NODE XML_COMMENT_NODE +/** + * HTML_PRESERVE_NODE: + * + * Macro. A preserved node in a HTML document is really implemented + * the same way as a CDATA section in an XML document. + */ +#define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE +/** + * HTML_PI_NODE: + * + * Macro. A processing instruction in a HTML document is really implemented + * the same way as a processing instruction in an XML document. + */ +#define HTML_PI_NODE XML_PI_NODE + +XMLPUBFUN htmlDocPtr + htmlNewDoc (const xmlChar *URI, + const xmlChar *ExternalID); +XMLPUBFUN htmlDocPtr + htmlNewDocNoDtD (const xmlChar *URI, + const xmlChar *ExternalID); +XMLPUBFUN const xmlChar * + htmlGetMetaEncoding (htmlDocPtr doc); +XMLPUBFUN int + htmlSetMetaEncoding (htmlDocPtr doc, + const xmlChar *encoding); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void + htmlDocDumpMemory (xmlDocPtr cur, + xmlChar **mem, + int *size); +XMLPUBFUN void + htmlDocDumpMemoryFormat (xmlDocPtr cur, + xmlChar **mem, + int *size, + int format); +XMLPUBFUN int + htmlDocDump (FILE *f, + xmlDocPtr cur); +XMLPUBFUN int + htmlSaveFile (const char *filename, + xmlDocPtr cur); +XMLPUBFUN int + htmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN void + htmlNodeDumpFile (FILE *out, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN int + htmlNodeDumpFileFormat (FILE *out, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding, + int format); +XMLPUBFUN int + htmlSaveFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN int + htmlSaveFileFormat (const char *filename, + xmlDocPtr cur, + const char *encoding, + int format); + +XMLPUBFUN void + htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding, + int format); +XMLPUBFUN void + htmlDocContentDumpOutput(xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN void + htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding, + int format); +XMLPUBFUN void + htmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding); + +#endif /* LIBXML_OUTPUT_ENABLED */ + +XML_DEPRECATED +XMLPUBFUN int + htmlIsBooleanAttr (const xmlChar *name); + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTML_ENABLED */ + +#endif /* __HTML_TREE_H__ */ + diff --git a/illumos-x86_64/usr/include/libxml2/libxml/SAX.h b/illumos-x86_64/usr/include/libxml2/libxml/SAX.h new file mode 100644 index 00000000..c1ab58d7 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/SAX.h @@ -0,0 +1,18 @@ +/* + * Summary: Old SAX version 1 handler, deprecated + * Description: DEPRECATED set of SAX version 1 interfaces used to + * build the DOM tree. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_SAX_H__ +#define __XML_SAX_H__ + +#ifdef __GNUC__ + #warning "libxml/SAX.h is deprecated" +#endif + +#endif /* __XML_SAX_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/SAX2.h b/illumos-x86_64/usr/include/libxml2/libxml/SAX2.h new file mode 100644 index 00000000..657acb02 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/SAX2.h @@ -0,0 +1,170 @@ +/* + * Summary: SAX2 parser interface used to build the DOM tree + * Description: those are the default SAX2 interfaces used by + * the library when building DOM tree. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SAX2_H__ +#define __XML_SAX2_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN const xmlChar * + xmlSAX2GetPublicId (void *ctx); +XMLPUBFUN const xmlChar * + xmlSAX2GetSystemId (void *ctx); +XMLPUBFUN void + xmlSAX2SetDocumentLocator (void *ctx, + xmlSAXLocatorPtr loc); + +XMLPUBFUN int + xmlSAX2GetLineNumber (void *ctx); +XMLPUBFUN int + xmlSAX2GetColumnNumber (void *ctx); + +XMLPUBFUN int + xmlSAX2IsStandalone (void *ctx); +XMLPUBFUN int + xmlSAX2HasInternalSubset (void *ctx); +XMLPUBFUN int + xmlSAX2HasExternalSubset (void *ctx); + +XMLPUBFUN void + xmlSAX2InternalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN void + xmlSAX2ExternalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlEntityPtr + xmlSAX2GetEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr + xmlSAX2GetParameterEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlParserInputPtr + xmlSAX2ResolveEntity (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); + +XMLPUBFUN void + xmlSAX2EntityDecl (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +XMLPUBFUN void + xmlSAX2AttributeDecl (void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XMLPUBFUN void + xmlSAX2ElementDecl (void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +XMLPUBFUN void + xmlSAX2NotationDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +XMLPUBFUN void + xmlSAX2UnparsedEntityDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); + +XMLPUBFUN void + xmlSAX2StartDocument (void *ctx); +XMLPUBFUN void + xmlSAX2EndDocument (void *ctx); +XML_DEPRECATED +XMLPUBFUN void + xmlSAX2StartElement (void *ctx, + const xmlChar *fullname, + const xmlChar **atts); +XML_DEPRECATED +XMLPUBFUN void + xmlSAX2EndElement (void *ctx, + const xmlChar *name); +XMLPUBFUN void + xmlSAX2StartElementNs (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); +XMLPUBFUN void + xmlSAX2EndElementNs (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); +XMLPUBFUN void + xmlSAX2Reference (void *ctx, + const xmlChar *name); +XMLPUBFUN void + xmlSAX2Characters (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void + xmlSAX2IgnorableWhitespace (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void + xmlSAX2ProcessingInstruction (void *ctx, + const xmlChar *target, + const xmlChar *data); +XMLPUBFUN void + xmlSAX2Comment (void *ctx, + const xmlChar *value); +XMLPUBFUN void + xmlSAX2CDataBlock (void *ctx, + const xmlChar *value, + int len); + +#ifdef LIBXML_SAX1_ENABLED +XML_DEPRECATED +XMLPUBFUN int + xmlSAXDefaultVersion (int version); +#endif /* LIBXML_SAX1_ENABLED */ + +XMLPUBFUN int + xmlSAXVersion (xmlSAXHandler *hdlr, + int version); +XMLPUBFUN void + xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, + int warning); +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN void + xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr); +XML_DEPRECATED +XMLPUBFUN void + htmlDefaultSAXHandlerInit (void); +#endif +XML_DEPRECATED +XMLPUBFUN void + xmlDefaultSAXHandlerInit (void); +#ifdef __cplusplus +} +#endif +#endif /* __XML_SAX2_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/c14n.h b/illumos-x86_64/usr/include/libxml2/libxml/c14n.h new file mode 100644 index 00000000..8ccd1cef --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/c14n.h @@ -0,0 +1,115 @@ +/* + * Summary: Provide Canonical XML and Exclusive XML Canonicalization + * Description: the c14n modules provides a + * + * "Canonical XML" implementation + * http://www.w3.org/TR/xml-c14n + * + * and an + * + * "Exclusive XML Canonicalization" implementation + * http://www.w3.org/TR/xml-exc-c14n + + * Copy: See Copyright for the status of this software. + * + * Author: Aleksey Sanin + */ +#ifndef __XML_C14N_H__ +#define __XML_C14N_H__ + +#include + +#ifdef LIBXML_C14N_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * XML Canonicalization + * http://www.w3.org/TR/xml-c14n + * + * Exclusive XML Canonicalization + * http://www.w3.org/TR/xml-exc-c14n + * + * Canonical form of an XML document could be created if and only if + * a) default attributes (if any) are added to all nodes + * b) all character and parsed entity references are resolved + * In order to achieve this in libxml2 the document MUST be loaded with + * following options: XML_PARSE_DTDATTR | XML_PARSE_NOENT + */ + +/* + * xmlC14NMode: + * + * Predefined values for C14N modes + * + */ +typedef enum { + XML_C14N_1_0 = 0, /* Original C14N 1.0 spec */ + XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */ + XML_C14N_1_1 = 2 /* C14N 1.1 spec */ +} xmlC14NMode; + +XMLPUBFUN int + xmlC14NDocSaveTo (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int mode, /* a xmlC14NMode */ + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlOutputBufferPtr buf); + +XMLPUBFUN int + xmlC14NDocDumpMemory (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int mode, /* a xmlC14NMode */ + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlChar **doc_txt_ptr); + +XMLPUBFUN int + xmlC14NDocSave (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int mode, /* a xmlC14NMode */ + xmlChar **inclusive_ns_prefixes, + int with_comments, + const char* filename, + int compression); + + +/** + * This is the core C14N function + */ +/** + * xmlC14NIsVisibleCallback: + * @user_data: user data + * @node: the current node + * @parent: the parent node + * + * Signature for a C14N callback on visible nodes + * + * Returns 1 if the node should be included + */ +typedef int (*xmlC14NIsVisibleCallback) (void* user_data, + xmlNodePtr node, + xmlNodePtr parent); + +XMLPUBFUN int + xmlC14NExecute (xmlDocPtr doc, + xmlC14NIsVisibleCallback is_visible_callback, + void* user_data, + int mode, /* a xmlC14NMode */ + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlOutputBufferPtr buf); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LIBXML_C14N_ENABLED */ +#endif /* __XML_C14N_H__ */ + diff --git a/illumos-x86_64/usr/include/libxml2/libxml/catalog.h b/illumos-x86_64/usr/include/libxml2/libxml/catalog.h new file mode 100644 index 00000000..442092a4 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/catalog.h @@ -0,0 +1,183 @@ +/** + * Summary: interfaces to the Catalog handling system + * Description: the catalog module implements the support for + * XML Catalogs and SGML catalogs + * + * SGML Open Technical Resolution TR9401:1997. + * http://www.jclark.com/sp/catalog.htm + * + * XML Catalogs Working Draft 06 August 2001 + * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_CATALOG_H__ +#define __XML_CATALOG_H__ + +#include + +#include +#include +#include + +#ifdef LIBXML_CATALOG_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XML_CATALOGS_NAMESPACE: + * + * The namespace for the XML Catalogs elements. + */ +#define XML_CATALOGS_NAMESPACE \ + (const xmlChar *) "urn:oasis:names:tc:entity:xmlns:xml:catalog" +/** + * XML_CATALOG_PI: + * + * The specific XML Catalog Processing Instruction name. + */ +#define XML_CATALOG_PI \ + (const xmlChar *) "oasis-xml-catalog" + +/* + * The API is voluntarily limited to general cataloging. + */ +typedef enum { + XML_CATA_PREFER_NONE = 0, + XML_CATA_PREFER_PUBLIC = 1, + XML_CATA_PREFER_SYSTEM +} xmlCatalogPrefer; + +typedef enum { + XML_CATA_ALLOW_NONE = 0, + XML_CATA_ALLOW_GLOBAL = 1, + XML_CATA_ALLOW_DOCUMENT = 2, + XML_CATA_ALLOW_ALL = 3 +} xmlCatalogAllow; + +typedef struct _xmlCatalog xmlCatalog; +typedef xmlCatalog *xmlCatalogPtr; + +/* + * Operations on a given catalog. + */ +XMLPUBFUN xmlCatalogPtr + xmlNewCatalog (int sgml); +XMLPUBFUN xmlCatalogPtr + xmlLoadACatalog (const char *filename); +XMLPUBFUN xmlCatalogPtr + xmlLoadSGMLSuperCatalog (const char *filename); +XMLPUBFUN int + xmlConvertSGMLCatalog (xmlCatalogPtr catal); +XMLPUBFUN int + xmlACatalogAdd (xmlCatalogPtr catal, + const xmlChar *type, + const xmlChar *orig, + const xmlChar *replace); +XMLPUBFUN int + xmlACatalogRemove (xmlCatalogPtr catal, + const xmlChar *value); +XMLPUBFUN xmlChar * + xmlACatalogResolve (xmlCatalogPtr catal, + const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * + xmlACatalogResolveSystem(xmlCatalogPtr catal, + const xmlChar *sysID); +XMLPUBFUN xmlChar * + xmlACatalogResolvePublic(xmlCatalogPtr catal, + const xmlChar *pubID); +XMLPUBFUN xmlChar * + xmlACatalogResolveURI (xmlCatalogPtr catal, + const xmlChar *URI); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void + xmlACatalogDump (xmlCatalogPtr catal, + FILE *out); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN void + xmlFreeCatalog (xmlCatalogPtr catal); +XMLPUBFUN int + xmlCatalogIsEmpty (xmlCatalogPtr catal); + +/* + * Global operations. + */ +XMLPUBFUN void + xmlInitializeCatalog (void); +XMLPUBFUN int + xmlLoadCatalog (const char *filename); +XMLPUBFUN void + xmlLoadCatalogs (const char *paths); +XMLPUBFUN void + xmlCatalogCleanup (void); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void + xmlCatalogDump (FILE *out); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN xmlChar * + xmlCatalogResolve (const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * + xmlCatalogResolveSystem (const xmlChar *sysID); +XMLPUBFUN xmlChar * + xmlCatalogResolvePublic (const xmlChar *pubID); +XMLPUBFUN xmlChar * + xmlCatalogResolveURI (const xmlChar *URI); +XMLPUBFUN int + xmlCatalogAdd (const xmlChar *type, + const xmlChar *orig, + const xmlChar *replace); +XMLPUBFUN int + xmlCatalogRemove (const xmlChar *value); +XMLPUBFUN xmlDocPtr + xmlParseCatalogFile (const char *filename); +XMLPUBFUN int + xmlCatalogConvert (void); + +/* + * Strictly minimal interfaces for per-document catalogs used + * by the parser. + */ +XMLPUBFUN void + xmlCatalogFreeLocal (void *catalogs); +XMLPUBFUN void * + xmlCatalogAddLocal (void *catalogs, + const xmlChar *URL); +XMLPUBFUN xmlChar * + xmlCatalogLocalResolve (void *catalogs, + const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * + xmlCatalogLocalResolveURI(void *catalogs, + const xmlChar *URI); +/* + * Preference settings. + */ +XMLPUBFUN int + xmlCatalogSetDebug (int level); +XML_DEPRECATED +XMLPUBFUN xmlCatalogPrefer + xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer); +XMLPUBFUN void + xmlCatalogSetDefaults (xmlCatalogAllow allow); +XMLPUBFUN xmlCatalogAllow + xmlCatalogGetDefaults (void); + + +/* DEPRECATED interfaces */ +XMLPUBFUN const xmlChar * + xmlCatalogGetSystem (const xmlChar *sysID); +XMLPUBFUN const xmlChar * + xmlCatalogGetPublic (const xmlChar *pubID); + +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_CATALOG_ENABLED */ +#endif /* __XML_CATALOG_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/chvalid.h b/illumos-x86_64/usr/include/libxml2/libxml/chvalid.h new file mode 100644 index 00000000..8225c95e --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/chvalid.h @@ -0,0 +1,230 @@ +/* + * Summary: Unicode character range checking + * Description: this module exports interfaces for the character + * range validation APIs + * + * This file is automatically generated from the cvs source + * definition files using the genChRanges.py Python script + * + * Generation date: Mon Mar 27 11:09:48 2006 + * Sources: chvalid.def + * Author: William Brack + */ + +#ifndef __XML_CHVALID_H__ +#define __XML_CHVALID_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Define our typedefs and structures + * + */ +typedef struct _xmlChSRange xmlChSRange; +typedef xmlChSRange *xmlChSRangePtr; +struct _xmlChSRange { + unsigned short low; + unsigned short high; +}; + +typedef struct _xmlChLRange xmlChLRange; +typedef xmlChLRange *xmlChLRangePtr; +struct _xmlChLRange { + unsigned int low; + unsigned int high; +}; + +typedef struct _xmlChRangeGroup xmlChRangeGroup; +typedef xmlChRangeGroup *xmlChRangeGroupPtr; +struct _xmlChRangeGroup { + int nbShortRange; + int nbLongRange; + const xmlChSRange *shortRange; /* points to an array of ranges */ + const xmlChLRange *longRange; +}; + +/** + * Range checking routine + */ +XMLPUBFUN int + xmlCharInRange(unsigned int val, const xmlChRangeGroup *group); + + +/** + * xmlIsBaseChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBaseChar_ch(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \ + ((0x61 <= (c)) && ((c) <= 0x7a)) || \ + ((0xc0 <= (c)) && ((c) <= 0xd6)) || \ + ((0xd8 <= (c)) && ((c) <= 0xf6)) || \ + (0xf8 <= (c))) + +/** + * xmlIsBaseCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBaseCharQ(c) (((c) < 0x100) ? \ + xmlIsBaseChar_ch((c)) : \ + xmlCharInRange((c), &xmlIsBaseCharGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup; + +/** + * xmlIsBlank_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBlank_ch(c) (((c) == 0x20) || \ + ((0x9 <= (c)) && ((c) <= 0xa)) || \ + ((c) == 0xd)) + +/** + * xmlIsBlankQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBlankQ(c) (((c) < 0x100) ? \ + xmlIsBlank_ch((c)) : 0) + + +/** + * xmlIsChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsChar_ch(c) (((0x9 <= (c)) && ((c) <= 0xa)) || \ + ((c) == 0xd) || \ + (0x20 <= (c))) + +/** + * xmlIsCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsCharQ(c) (((c) < 0x100) ? \ + xmlIsChar_ch((c)) :\ + (((0x100 <= (c)) && ((c) <= 0xd7ff)) || \ + ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \ + ((0x10000 <= (c)) && ((c) <= 0x10ffff)))) + +XMLPUBVAR const xmlChRangeGroup xmlIsCharGroup; + +/** + * xmlIsCombiningQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsCombiningQ(c) (((c) < 0x100) ? \ + 0 : \ + xmlCharInRange((c), &xmlIsCombiningGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup; + +/** + * xmlIsDigit_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsDigit_ch(c) (((0x30 <= (c)) && ((c) <= 0x39))) + +/** + * xmlIsDigitQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsDigitQ(c) (((c) < 0x100) ? \ + xmlIsDigit_ch((c)) : \ + xmlCharInRange((c), &xmlIsDigitGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup; + +/** + * xmlIsExtender_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsExtender_ch(c) (((c) == 0xb7)) + +/** + * xmlIsExtenderQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsExtenderQ(c) (((c) < 0x100) ? \ + xmlIsExtender_ch((c)) : \ + xmlCharInRange((c), &xmlIsExtenderGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup; + +/** + * xmlIsIdeographicQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsIdeographicQ(c) (((c) < 0x100) ? \ + 0 :\ + (((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \ + ((c) == 0x3007) || \ + ((0x3021 <= (c)) && ((c) <= 0x3029)))) + +XMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup; +XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256]; + +/** + * xmlIsPubidChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsPubidChar_ch(c) (xmlIsPubidChar_tab[(c)]) + +/** + * xmlIsPubidCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsPubidCharQ(c) (((c) < 0x100) ? \ + xmlIsPubidChar_ch((c)) : 0) + +XMLPUBFUN int + xmlIsBaseChar(unsigned int ch); +XMLPUBFUN int + xmlIsBlank(unsigned int ch); +XMLPUBFUN int + xmlIsChar(unsigned int ch); +XMLPUBFUN int + xmlIsCombining(unsigned int ch); +XMLPUBFUN int + xmlIsDigit(unsigned int ch); +XMLPUBFUN int + xmlIsExtender(unsigned int ch); +XMLPUBFUN int + xmlIsIdeographic(unsigned int ch); +XMLPUBFUN int + xmlIsPubidChar(unsigned int ch); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_CHVALID_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/debugXML.h b/illumos-x86_64/usr/include/libxml2/libxml/debugXML.h new file mode 100644 index 00000000..55148d9d --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/debugXML.h @@ -0,0 +1,79 @@ +/* + * Summary: Tree debugging APIs + * Description: Interfaces to a set of routines used for debugging the tree + * produced by the XML parser. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __DEBUG_XML__ +#define __DEBUG_XML__ +#include +#include +#include + +#ifdef LIBXML_DEBUG_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The standard Dump routines. + */ +XMLPUBFUN void + xmlDebugDumpString (FILE *output, + const xmlChar *str); +XMLPUBFUN void + xmlDebugDumpAttr (FILE *output, + xmlAttrPtr attr, + int depth); +XMLPUBFUN void + xmlDebugDumpAttrList (FILE *output, + xmlAttrPtr attr, + int depth); +XMLPUBFUN void + xmlDebugDumpOneNode (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void + xmlDebugDumpNode (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void + xmlDebugDumpNodeList (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void + xmlDebugDumpDocumentHead(FILE *output, + xmlDocPtr doc); +XMLPUBFUN void + xmlDebugDumpDocument (FILE *output, + xmlDocPtr doc); +XMLPUBFUN void + xmlDebugDumpDTD (FILE *output, + xmlDtdPtr dtd); +XMLPUBFUN void + xmlDebugDumpEntities (FILE *output, + xmlDocPtr doc); + +/**************************************************************** + * * + * Checking routines * + * * + ****************************************************************/ + +XMLPUBFUN int + xmlDebugCheckDocument (FILE * output, + xmlDocPtr doc); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_DEBUG_ENABLED */ +#endif /* __DEBUG_XML__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/dict.h b/illumos-x86_64/usr/include/libxml2/libxml/dict.h new file mode 100644 index 00000000..22aa3d9d --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/dict.h @@ -0,0 +1,82 @@ +/* + * Summary: string dictionary + * Description: dictionary of reusable strings, just used to avoid allocation + * and freeing operations. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_DICT_H__ +#define __XML_DICT_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The dictionary. + */ +typedef struct _xmlDict xmlDict; +typedef xmlDict *xmlDictPtr; + +/* + * Initializer + */ +XML_DEPRECATED +XMLPUBFUN int xmlInitializeDict(void); + +/* + * Constructor and destructor. + */ +XMLPUBFUN xmlDictPtr + xmlDictCreate (void); +XMLPUBFUN size_t + xmlDictSetLimit (xmlDictPtr dict, + size_t limit); +XMLPUBFUN size_t + xmlDictGetUsage (xmlDictPtr dict); +XMLPUBFUN xmlDictPtr + xmlDictCreateSub(xmlDictPtr sub); +XMLPUBFUN int + xmlDictReference(xmlDictPtr dict); +XMLPUBFUN void + xmlDictFree (xmlDictPtr dict); + +/* + * Lookup of entry in the dictionary. + */ +XMLPUBFUN const xmlChar * + xmlDictLookup (xmlDictPtr dict, + const xmlChar *name, + int len); +XMLPUBFUN const xmlChar * + xmlDictExists (xmlDictPtr dict, + const xmlChar *name, + int len); +XMLPUBFUN const xmlChar * + xmlDictQLookup (xmlDictPtr dict, + const xmlChar *prefix, + const xmlChar *name); +XMLPUBFUN int + xmlDictOwns (xmlDictPtr dict, + const xmlChar *str); +XMLPUBFUN int + xmlDictSize (xmlDictPtr dict); + +/* + * Cleanup function + */ +XML_DEPRECATED +XMLPUBFUN void + xmlDictCleanup (void); + +#ifdef __cplusplus +} +#endif +#endif /* ! __XML_DICT_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/encoding.h b/illumos-x86_64/usr/include/libxml2/libxml/encoding.h new file mode 100644 index 00000000..9a358dbb --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/encoding.h @@ -0,0 +1,307 @@ +/* + * Summary: interface for the encoding conversion functions + * Description: interface for the encoding conversion functions needed for + * XML basic encoding and iconv() support. + * + * Related specs are + * rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies + * [ISO-10646] UTF-8 and UTF-16 in Annexes + * [ISO-8859-1] ISO Latin-1 characters codes. + * [UNICODE] The Unicode Consortium, "The Unicode Standard -- + * Worldwide Character Encoding -- Version 1.0", Addison- + * Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is + * described in Unicode Technical Report #4. + * [US-ASCII] Coded Character Set--7-bit American Standard Code for + * Information Interchange, ANSI X3.4-1986. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_CHAR_ENCODING_H__ +#define __XML_CHAR_ENCODING_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Backward compatibility + */ +#define UTF8Toisolat1 xmlUTF8ToIsolat1 +#define isolat1ToUTF8 xmlIsolat1ToUTF8 + +typedef enum { + XML_ENC_ERR_SUCCESS = 0, + XML_ENC_ERR_INTERNAL = -1, + XML_ENC_ERR_INPUT = -2, + XML_ENC_ERR_SPACE = -3, + XML_ENC_ERR_MEMORY = -4 +} xmlCharEncError; + +/* + * xmlCharEncoding: + * + * Predefined values for some standard encodings. + */ +typedef enum { + XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */ + XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */ + XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */ + XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */ + XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */ + XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */ + XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */ + XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */ + XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */ + XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */ + XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */ + XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */ + XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */ + XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */ + XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */ + XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */ + XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */ + XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */ + XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */ + XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */ + XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */ + XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */ + XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */ + XML_CHAR_ENCODING_ASCII= 22,/* pure ASCII */ + /* Available since 2.14.0 */ + XML_CHAR_ENCODING_UTF16= 23,/* UTF-16 native */ + XML_CHAR_ENCODING_HTML= 24,/* HTML (output only) */ + XML_CHAR_ENCODING_8859_10= 25,/* ISO-8859-10 */ + XML_CHAR_ENCODING_8859_11= 26,/* ISO-8859-11 */ + XML_CHAR_ENCODING_8859_13= 27,/* ISO-8859-13 */ + XML_CHAR_ENCODING_8859_14= 28,/* ISO-8859-14 */ + XML_CHAR_ENCODING_8859_15= 29,/* ISO-8859-15 */ + XML_CHAR_ENCODING_8859_16= 30 /* ISO-8859-16 */ +} xmlCharEncoding; + +typedef enum { + XML_ENC_INPUT = (1 << 0), + XML_ENC_OUTPUT = (1 << 1) +} xmlCharEncFlags; + +/** + * xmlCharEncodingInputFunc: + * @out: a pointer to an array of bytes to store the UTF-8 result + * @outlen: the length of @out + * @in: a pointer to an array of chars in the original encoding + * @inlen: the length of @in + * + * Convert characters to UTF-8. + * + * On success, the value of @inlen after return is the number of + * bytes consumed and @outlen is the number of bytes produced. + * + * Returns the number of bytes written or an XML_ENC_ERR code. + */ +typedef int (*xmlCharEncodingInputFunc)(unsigned char *out, int *outlen, + const unsigned char *in, int *inlen); + + +/** + * xmlCharEncodingOutputFunc: + * @out: a pointer to an array of bytes to store the result + * @outlen: the length of @out + * @in: a pointer to an array of UTF-8 chars + * @inlen: the length of @in + * + * Convert characters from UTF-8. + * + * On success, the value of @inlen after return is the number of + * bytes consumed and @outlen is the number of bytes produced. + * + * Returns the number of bytes written or an XML_ENC_ERR code. + */ +typedef int (*xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen, + const unsigned char *in, int *inlen); + + +/** + * xmlCharEncConvFunc: + * @vctxt: conversion context + * @out: a pointer to an array of bytes to store the result + * @outlen: the length of @out + * @in: a pointer to an array of input bytes + * @inlen: the length of @in + * @flush: end of input + * + * Convert between character encodings. + * + * The value of @inlen after return is the number of bytes consumed + * and @outlen is the number of bytes produced. + * + * If the converter can consume partial multi-byte sequences, the + * @flush flag can be used to detect truncated sequences at EOF. + * Otherwise, the flag can be ignored. + * + * Returns an XML_ENC_ERR code. + */ +typedef xmlCharEncError +(*xmlCharEncConvFunc)(void *vctxt, unsigned char *out, int *outlen, + const unsigned char *in, int *inlen, int flush); + +/** + * xmlCharEncConvCtxtDtor: + * @vctxt: conversion context + * + * Free a conversion context. + */ +typedef void +(*xmlCharEncConvCtxtDtor)(void *vctxt); + +/* + * Block defining the handlers for non UTF-8 encodings. + * + * This structure will be made private. + */ +typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler; +typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr; +struct _xmlCharEncodingHandler { + char *name XML_DEPRECATED_MEMBER; + union { + xmlCharEncConvFunc func; + xmlCharEncodingInputFunc legacyFunc; + } input XML_DEPRECATED_MEMBER; + union { + xmlCharEncConvFunc func; + xmlCharEncodingOutputFunc legacyFunc; + } output XML_DEPRECATED_MEMBER; + void *inputCtxt XML_DEPRECATED_MEMBER; + void *outputCtxt XML_DEPRECATED_MEMBER; + xmlCharEncConvCtxtDtor ctxtDtor XML_DEPRECATED_MEMBER; + int flags XML_DEPRECATED_MEMBER; +}; + +/** + * xmlCharEncConvImpl: + * @vctxt: user data + * @name: encoding name + * @flags: bit mask of flags + * @out: pointer to resulting handler + * + * If this function returns XML_ERR_OK, it must fill the @out + * pointer with an encoding handler. The handler can be obtained + * from xmlCharEncNewCustomHandler. + * + * @flags can contain XML_ENC_INPUT, XML_ENC_OUTPUT or both. + * + * Returns an xmlParserErrors code. + */ +typedef xmlParserErrors +(*xmlCharEncConvImpl)(void *vctxt, const char *name, xmlCharEncFlags flags, + xmlCharEncodingHandler **out); + +/* + * Interfaces for encoding handlers. + */ +XML_DEPRECATED +XMLPUBFUN void + xmlInitCharEncodingHandlers (void); +XML_DEPRECATED +XMLPUBFUN void + xmlCleanupCharEncodingHandlers (void); +XMLPUBFUN void + xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); +XMLPUBFUN xmlParserErrors + xmlLookupCharEncodingHandler (xmlCharEncoding enc, + xmlCharEncodingHandlerPtr *out); +XMLPUBFUN xmlParserErrors + xmlOpenCharEncodingHandler (const char *name, + int output, + xmlCharEncodingHandlerPtr *out); +XMLPUBFUN xmlParserErrors + xmlCreateCharEncodingHandler (const char *name, + xmlCharEncFlags flags, + xmlCharEncConvImpl impl, + void *implCtxt, + xmlCharEncodingHandlerPtr *out); +XMLPUBFUN xmlCharEncodingHandlerPtr + xmlGetCharEncodingHandler (xmlCharEncoding enc); +XMLPUBFUN xmlCharEncodingHandlerPtr + xmlFindCharEncodingHandler (const char *name); +XMLPUBFUN xmlCharEncodingHandlerPtr + xmlNewCharEncodingHandler (const char *name, + xmlCharEncodingInputFunc input, + xmlCharEncodingOutputFunc output); +XMLPUBFUN xmlParserErrors + xmlCharEncNewCustomHandler (const char *name, + xmlCharEncConvFunc input, + xmlCharEncConvFunc output, + xmlCharEncConvCtxtDtor ctxtDtor, + void *inputCtxt, + void *outputCtxt, + xmlCharEncodingHandler **out); + +/* + * Interfaces for encoding names and aliases. + */ +XMLPUBFUN int + xmlAddEncodingAlias (const char *name, + const char *alias); +XMLPUBFUN int + xmlDelEncodingAlias (const char *alias); +XMLPUBFUN const char * + xmlGetEncodingAlias (const char *alias); +XMLPUBFUN void + xmlCleanupEncodingAliases (void); +XMLPUBFUN xmlCharEncoding + xmlParseCharEncoding (const char *name); +XMLPUBFUN const char * + xmlGetCharEncodingName (xmlCharEncoding enc); + +/* + * Interfaces directly used by the parsers. + */ +XMLPUBFUN xmlCharEncoding + xmlDetectCharEncoding (const unsigned char *in, + int len); + +/** DOC_DISABLE */ +struct _xmlBuffer; +/** DOC_ENABLE */ +XMLPUBFUN int + xmlCharEncOutFunc (xmlCharEncodingHandler *handler, + struct _xmlBuffer *out, + struct _xmlBuffer *in); + +XMLPUBFUN int + xmlCharEncInFunc (xmlCharEncodingHandler *handler, + struct _xmlBuffer *out, + struct _xmlBuffer *in); +XML_DEPRECATED +XMLPUBFUN int + xmlCharEncFirstLine (xmlCharEncodingHandler *handler, + struct _xmlBuffer *out, + struct _xmlBuffer *in); +XMLPUBFUN int + xmlCharEncCloseFunc (xmlCharEncodingHandler *handler); + +/* + * Export a few useful functions + */ +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN int + xmlUTF8ToIsolat1 (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN int + xmlIsolat1ToUTF8 (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +#ifdef __cplusplus +} +#endif + +#endif /* __XML_CHAR_ENCODING_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/entities.h b/illumos-x86_64/usr/include/libxml2/libxml/entities.h new file mode 100644 index 00000000..d17c36be --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/entities.h @@ -0,0 +1,147 @@ +/* + * Summary: interface for the XML entities handling + * Description: this module provides some of the entity API needed + * for the parser and applications. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_ENTITIES_H__ +#define __XML_ENTITIES_H__ + +/** DOC_DISABLE */ +#include +#define XML_TREE_INTERNALS +#include +#undef XML_TREE_INTERNALS +/** DOC_ENABLE */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The different valid entity types. + */ +typedef enum { + XML_INTERNAL_GENERAL_ENTITY = 1, + XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2, + XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3, + XML_INTERNAL_PARAMETER_ENTITY = 4, + XML_EXTERNAL_PARAMETER_ENTITY = 5, + XML_INTERNAL_PREDEFINED_ENTITY = 6 +} xmlEntityType; + +/* + * An unit of storage for an entity, contains the string, the value + * and the linkind data needed for the linking in the hash table. + */ + +struct _xmlEntity { + void *_private; /* application data */ + xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ + const xmlChar *name; /* Entity name */ + struct _xmlNode *children; /* First child link */ + struct _xmlNode *last; /* Last child link */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + xmlChar *orig; /* content without ref substitution */ + xmlChar *content; /* content or ndata if unparsed */ + int length; /* the content length */ + xmlEntityType etype; /* The entity type */ + const xmlChar *ExternalID; /* External identifier for PUBLIC */ + const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */ + + struct _xmlEntity *nexte; /* unused */ + const xmlChar *URI; /* the full URI as computed */ + int owner; /* unused */ + int flags; /* various flags */ + unsigned long expandedSize; /* expanded size */ +}; + +/* + * All entities are stored in an hash table. + * There is 2 separate hash tables for global and parameter entities. + */ + +typedef struct _xmlHashTable xmlEntitiesTable; +typedef xmlEntitiesTable *xmlEntitiesTablePtr; + +/* + * External functions: + */ + +XMLPUBFUN xmlEntityPtr + xmlNewEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN void + xmlFreeEntity (xmlEntityPtr entity); +XMLPUBFUN int + xmlAddEntity (xmlDocPtr doc, + int extSubset, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content, + xmlEntityPtr *out); +XMLPUBFUN xmlEntityPtr + xmlAddDocEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr + xmlAddDtdEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr + xmlGetPredefinedEntity (const xmlChar *name); +XMLPUBFUN xmlEntityPtr + xmlGetDocEntity (const xmlDoc *doc, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr + xmlGetDtdEntity (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr + xmlGetParameterEntity (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlChar * + xmlEncodeEntitiesReentrant(xmlDocPtr doc, + const xmlChar *input); +XMLPUBFUN xmlChar * + xmlEncodeSpecialChars (const xmlDoc *doc, + const xmlChar *input); +XMLPUBFUN xmlEntitiesTablePtr + xmlCreateEntitiesTable (void); +XMLPUBFUN xmlEntitiesTablePtr + xmlCopyEntitiesTable (xmlEntitiesTablePtr table); +XMLPUBFUN void + xmlFreeEntitiesTable (xmlEntitiesTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void + xmlDumpEntitiesTable (xmlBufferPtr buf, + xmlEntitiesTablePtr table); +XMLPUBFUN void + xmlDumpEntityDecl (xmlBufferPtr buf, + xmlEntityPtr ent); +#endif /* LIBXML_OUTPUT_ENABLED */ + +#ifdef __cplusplus +} +#endif + +# endif /* __XML_ENTITIES_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/globals.h b/illumos-x86_64/usr/include/libxml2/libxml/globals.h new file mode 100644 index 00000000..a5db8026 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/globals.h @@ -0,0 +1,25 @@ +/* + * Summary: interface for all global variables of the library + * Description: Deprecated, don't use + * + * Copy: See Copyright for the status of this software. + */ + +#ifndef __XML_GLOBALS_H +#define __XML_GLOBALS_H + +#include + +/* + * This file was required to access global variables until version v2.12.0. + * + * These includes are for backward compatibility. + */ +#include +#include +#include +#include +#include +#include + +#endif /* __XML_GLOBALS_H */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/hash.h b/illumos-x86_64/usr/include/libxml2/libxml/hash.h new file mode 100644 index 00000000..135b6966 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/hash.h @@ -0,0 +1,251 @@ +/* + * Summary: Chained hash tables + * Description: This module implements the hash table support used in + * various places in the library. + * + * Copy: See Copyright for the status of this software. + * + * Author: Bjorn Reese + */ + +#ifndef __XML_HASH_H__ +#define __XML_HASH_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The hash table. + */ +typedef struct _xmlHashTable xmlHashTable; +typedef xmlHashTable *xmlHashTablePtr; + +/* + * Recent version of gcc produce a warning when a function pointer is assigned + * to an object pointer, or vice versa. The following macro is a dirty hack + * to allow suppression of the warning. If your architecture has function + * pointers which are a different size than a void pointer, there may be some + * serious trouble within the library. + */ +/** + * XML_CAST_FPTR: + * @fptr: pointer to a function + * + * Macro to do a casting from an object pointer to a + * function pointer without encountering a warning from + * gcc + * + * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr)) + * This macro violated ISO C aliasing rules (gcc4 on s390 broke) + * so it is disabled now + */ + +#define XML_CAST_FPTR(fptr) fptr + +/* + * function types: + */ +/** + * xmlHashDeallocator: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to free data from a hash. + */ +typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name); +/** + * xmlHashCopier: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to copy data from a hash. + * + * Returns a copy of the data or NULL in case of error. + */ +typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name); +/** + * xmlHashScanner: + * @payload: the data in the hash + * @data: extra scanner data + * @name: the name associated + * + * Callback when scanning data in a hash with the simple scanner. + */ +typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name); +/** + * xmlHashScannerFull: + * @payload: the data in the hash + * @data: extra scanner data + * @name: the name associated + * @name2: the second name associated + * @name3: the third name associated + * + * Callback when scanning data in a hash with the full scanner. + */ +typedef void (*xmlHashScannerFull)(void *payload, void *data, + const xmlChar *name, const xmlChar *name2, + const xmlChar *name3); + +/* + * Constructor and destructor. + */ +XMLPUBFUN xmlHashTablePtr + xmlHashCreate (int size); +XMLPUBFUN xmlHashTablePtr + xmlHashCreateDict (int size, + xmlDictPtr dict); +XMLPUBFUN void + xmlHashFree (xmlHashTablePtr hash, + xmlHashDeallocator dealloc); +XMLPUBFUN void + xmlHashDefaultDeallocator(void *entry, + const xmlChar *name); + +/* + * Add a new entry to the hash table. + */ +XMLPUBFUN int + xmlHashAdd (xmlHashTablePtr hash, + const xmlChar *name, + void *userdata); +XMLPUBFUN int + xmlHashAddEntry (xmlHashTablePtr hash, + const xmlChar *name, + void *userdata); +XMLPUBFUN int + xmlHashUpdateEntry (xmlHashTablePtr hash, + const xmlChar *name, + void *userdata, + xmlHashDeallocator dealloc); +XMLPUBFUN int + xmlHashAdd2 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + void *userdata); +XMLPUBFUN int + xmlHashAddEntry2 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + void *userdata); +XMLPUBFUN int + xmlHashUpdateEntry2 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + void *userdata, + xmlHashDeallocator dealloc); +XMLPUBFUN int + xmlHashAdd3 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata); +XMLPUBFUN int + xmlHashAddEntry3 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata); +XMLPUBFUN int + xmlHashUpdateEntry3 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata, + xmlHashDeallocator dealloc); + +/* + * Remove an entry from the hash table. + */ +XMLPUBFUN int + xmlHashRemoveEntry (xmlHashTablePtr hash, + const xmlChar *name, + xmlHashDeallocator dealloc); +XMLPUBFUN int + xmlHashRemoveEntry2 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + xmlHashDeallocator dealloc); +XMLPUBFUN int + xmlHashRemoveEntry3 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashDeallocator dealloc); + +/* + * Retrieve the payload. + */ +XMLPUBFUN void * + xmlHashLookup (xmlHashTablePtr hash, + const xmlChar *name); +XMLPUBFUN void * + xmlHashLookup2 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2); +XMLPUBFUN void * + xmlHashLookup3 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3); +XMLPUBFUN void * + xmlHashQLookup (xmlHashTablePtr hash, + const xmlChar *prefix, + const xmlChar *name); +XMLPUBFUN void * + xmlHashQLookup2 (xmlHashTablePtr hash, + const xmlChar *prefix, + const xmlChar *name, + const xmlChar *prefix2, + const xmlChar *name2); +XMLPUBFUN void * + xmlHashQLookup3 (xmlHashTablePtr hash, + const xmlChar *prefix, + const xmlChar *name, + const xmlChar *prefix2, + const xmlChar *name2, + const xmlChar *prefix3, + const xmlChar *name3); + +/* + * Helpers. + */ +XMLPUBFUN xmlHashTablePtr + xmlHashCopySafe (xmlHashTablePtr hash, + xmlHashCopier copy, + xmlHashDeallocator dealloc); +XMLPUBFUN xmlHashTablePtr + xmlHashCopy (xmlHashTablePtr hash, + xmlHashCopier copy); +XMLPUBFUN int + xmlHashSize (xmlHashTablePtr hash); +XMLPUBFUN void + xmlHashScan (xmlHashTablePtr hash, + xmlHashScanner scan, + void *data); +XMLPUBFUN void + xmlHashScan3 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashScanner scan, + void *data); +XMLPUBFUN void + xmlHashScanFull (xmlHashTablePtr hash, + xmlHashScannerFull scan, + void *data); +XMLPUBFUN void + xmlHashScanFull3 (xmlHashTablePtr hash, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashScannerFull scan, + void *data); +#ifdef __cplusplus +} +#endif +#endif /* ! __XML_HASH_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/list.h b/illumos-x86_64/usr/include/libxml2/libxml/list.h new file mode 100644 index 00000000..1fa76aff --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/list.h @@ -0,0 +1,137 @@ +/* + * Summary: lists interfaces + * Description: this module implement the list support used in + * various place in the library. + * + * Copy: See Copyright for the status of this software. + * + * Author: Gary Pennington + */ + +#ifndef __XML_LINK_INCLUDE__ +#define __XML_LINK_INCLUDE__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlLink xmlLink; +typedef xmlLink *xmlLinkPtr; + +typedef struct _xmlList xmlList; +typedef xmlList *xmlListPtr; + +/** + * xmlListDeallocator: + * @lk: the data to deallocate + * + * Callback function used to free data from a list. + */ +typedef void (*xmlListDeallocator) (xmlLinkPtr lk); +/** + * xmlListDataCompare: + * @data0: the first data + * @data1: the second data + * + * Callback function used to compare 2 data. + * + * Returns 0 is equality, -1 or 1 otherwise depending on the ordering. + */ +typedef int (*xmlListDataCompare) (const void *data0, const void *data1); +/** + * xmlListWalker: + * @data: the data found in the list + * @user: extra user provided data to the walker + * + * Callback function used when walking a list with xmlListWalk(). + * + * Returns 0 to stop walking the list, 1 otherwise. + */ +typedef int (*xmlListWalker) (const void *data, void *user); + +/* Creation/Deletion */ +XMLPUBFUN xmlListPtr + xmlListCreate (xmlListDeallocator deallocator, + xmlListDataCompare compare); +XMLPUBFUN void + xmlListDelete (xmlListPtr l); + +/* Basic Operators */ +XMLPUBFUN void * + xmlListSearch (xmlListPtr l, + void *data); +XMLPUBFUN void * + xmlListReverseSearch (xmlListPtr l, + void *data); +XMLPUBFUN int + xmlListInsert (xmlListPtr l, + void *data) ; +XMLPUBFUN int + xmlListAppend (xmlListPtr l, + void *data) ; +XMLPUBFUN int + xmlListRemoveFirst (xmlListPtr l, + void *data); +XMLPUBFUN int + xmlListRemoveLast (xmlListPtr l, + void *data); +XMLPUBFUN int + xmlListRemoveAll (xmlListPtr l, + void *data); +XMLPUBFUN void + xmlListClear (xmlListPtr l); +XMLPUBFUN int + xmlListEmpty (xmlListPtr l); +XMLPUBFUN xmlLinkPtr + xmlListFront (xmlListPtr l); +XMLPUBFUN xmlLinkPtr + xmlListEnd (xmlListPtr l); +XMLPUBFUN int + xmlListSize (xmlListPtr l); + +XMLPUBFUN void + xmlListPopFront (xmlListPtr l); +XMLPUBFUN void + xmlListPopBack (xmlListPtr l); +XMLPUBFUN int + xmlListPushFront (xmlListPtr l, + void *data); +XMLPUBFUN int + xmlListPushBack (xmlListPtr l, + void *data); + +/* Advanced Operators */ +XMLPUBFUN void + xmlListReverse (xmlListPtr l); +XMLPUBFUN void + xmlListSort (xmlListPtr l); +XMLPUBFUN void + xmlListWalk (xmlListPtr l, + xmlListWalker walker, + void *user); +XMLPUBFUN void + xmlListReverseWalk (xmlListPtr l, + xmlListWalker walker, + void *user); +XMLPUBFUN void + xmlListMerge (xmlListPtr l1, + xmlListPtr l2); +XMLPUBFUN xmlListPtr + xmlListDup (xmlListPtr old); +XMLPUBFUN int + xmlListCopy (xmlListPtr cur, + xmlListPtr old); +/* Link operators */ +XMLPUBFUN void * + xmlLinkGetData (xmlLinkPtr lk); + +/* xmlListUnique() */ +/* xmlListSwap */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_LINK_INCLUDE__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/nanoftp.h b/illumos-x86_64/usr/include/libxml2/libxml/nanoftp.h new file mode 100644 index 00000000..5dda6349 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/nanoftp.h @@ -0,0 +1,16 @@ +/* + * Summary: Removed legacy symbols for an outdated FTP client + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __NANO_FTP_H__ +#define __NANO_FTP_H__ + +#ifdef __GNUC__ + #warning "libxml/nanoftp.h is deprecated" +#endif + +#endif /* __NANO_FTP_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/nanohttp.h b/illumos-x86_64/usr/include/libxml2/libxml/nanohttp.h new file mode 100644 index 00000000..c70d1c26 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/nanohttp.h @@ -0,0 +1,98 @@ +/* + * Summary: minimal HTTP implementation + * Description: minimal HTTP implementation allowing to fetch resources + * like external subset. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __NANO_HTTP_H__ +#define __NANO_HTTP_H__ + +#include + +#ifdef LIBXML_HTTP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif +XML_DEPRECATED +XMLPUBFUN void + xmlNanoHTTPInit (void); +XML_DEPRECATED +XMLPUBFUN void + xmlNanoHTTPCleanup (void); +XML_DEPRECATED +XMLPUBFUN void + xmlNanoHTTPScanProxy (const char *URL); +XML_DEPRECATED +XMLPUBFUN int + xmlNanoHTTPFetch (const char *URL, + const char *filename, + char **contentType); +XML_DEPRECATED +XMLPUBFUN void * + xmlNanoHTTPMethod (const char *URL, + const char *method, + const char *input, + char **contentType, + const char *headers, + int ilen); +XML_DEPRECATED +XMLPUBFUN void * + xmlNanoHTTPMethodRedir (const char *URL, + const char *method, + const char *input, + char **contentType, + char **redir, + const char *headers, + int ilen); +XML_DEPRECATED +XMLPUBFUN void * + xmlNanoHTTPOpen (const char *URL, + char **contentType); +XML_DEPRECATED +XMLPUBFUN void * + xmlNanoHTTPOpenRedir (const char *URL, + char **contentType, + char **redir); +XML_DEPRECATED +XMLPUBFUN int + xmlNanoHTTPReturnCode (void *ctx); +XML_DEPRECATED +XMLPUBFUN const char * + xmlNanoHTTPAuthHeader (void *ctx); +XML_DEPRECATED +XMLPUBFUN const char * + xmlNanoHTTPRedir (void *ctx); +XML_DEPRECATED +XMLPUBFUN int + xmlNanoHTTPContentLength( void * ctx ); +XML_DEPRECATED +XMLPUBFUN const char * + xmlNanoHTTPEncoding (void *ctx); +XML_DEPRECATED +XMLPUBFUN const char * + xmlNanoHTTPMimeType (void *ctx); +XML_DEPRECATED +XMLPUBFUN int + xmlNanoHTTPRead (void *ctx, + void *dest, + int len); +#ifdef LIBXML_OUTPUT_ENABLED +XML_DEPRECATED +XMLPUBFUN int + xmlNanoHTTPSave (void *ctxt, + const char *filename); +#endif /* LIBXML_OUTPUT_ENABLED */ +XML_DEPRECATED +XMLPUBFUN void + xmlNanoHTTPClose (void *ctx); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTTP_ENABLED */ +#endif /* __NANO_HTTP_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/parser.h b/illumos-x86_64/usr/include/libxml2/libxml/parser.h new file mode 100644 index 00000000..338cab87 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/parser.h @@ -0,0 +1,1633 @@ +/* + * Summary: the core parser module + * Description: Interfaces, constants and types related to the XML parser + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PARSER_H__ +#define __XML_PARSER_H__ + +/** DOC_DISABLE */ +#include +#define XML_TREE_INTERNALS +#include +#undef XML_TREE_INTERNALS +#include +#include +#include +#include +#include +#include +#include +#include +#include +/* for compatibility */ +#include +#include +/** DOC_ENABLE */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XML_DEFAULT_VERSION: + * + * The default version of XML used: 1.0 + */ +#define XML_DEFAULT_VERSION "1.0" + +typedef enum { + XML_STATUS_NOT_WELL_FORMED = (1 << 0), + XML_STATUS_NOT_NS_WELL_FORMED = (1 << 1), + XML_STATUS_DTD_VALIDATION_FAILED = (1 << 2), + XML_STATUS_CATASTROPHIC_ERROR = (1 << 3) +} xmlParserStatus; + +typedef enum { + XML_RESOURCE_UNKNOWN = 0, + XML_RESOURCE_MAIN_DOCUMENT, + XML_RESOURCE_DTD, + XML_RESOURCE_GENERAL_ENTITY, + XML_RESOURCE_PARAMETER_ENTITY, + XML_RESOURCE_XINCLUDE, + XML_RESOURCE_XINCLUDE_TEXT +} xmlResourceType; + +typedef enum { + XML_INPUT_BUF_STATIC = (1 << 1), + XML_INPUT_BUF_ZERO_TERMINATED = (1 << 2), + XML_INPUT_UNZIP = (1 << 3), + XML_INPUT_NETWORK = (1 << 4) +} xmlParserInputFlags; + +/** + * xmlParserInput: + * + * An xmlParserInput is an input flow for the XML processor. + * Each entity parsed is associated an xmlParserInput (except the + * few predefined ones). This is the case both for internal entities + * - in which case the flow is already completely in memory - or + * external entities - in which case we use the buf structure for + * progressive reading and I18N conversions to the internal UTF-8 format. + */ + +/** + * xmlParserInputDeallocate: + * @str: the string to deallocate + * + * Callback for freeing some parser input allocations. + */ +typedef void (* xmlParserInputDeallocate)(xmlChar *str); + +struct _xmlParserInput { + /* Input buffer */ + xmlParserInputBufferPtr buf; + /* The file analyzed, if any */ + const char *filename; + /* unused */ + const char *directory XML_DEPRECATED_MEMBER; + /* Base of the array to parse */ + const xmlChar *base; + /* Current char being parsed */ + const xmlChar *cur; + /* end of the array to parse */ + const xmlChar *end; + /* unused */ + int length XML_DEPRECATED_MEMBER; + /* Current line */ + int line; + /* Current column */ + int col; + /* How many xmlChars already consumed */ + unsigned long consumed; + /* function to deallocate the base */ + xmlParserInputDeallocate free XML_DEPRECATED_MEMBER; + /* unused */ + const xmlChar *encoding XML_DEPRECATED_MEMBER; + /* the version string for entity */ + const xmlChar *version XML_DEPRECATED_MEMBER; + /* Flags */ + int flags XML_DEPRECATED_MEMBER; + /* an unique identifier for the entity */ + int id XML_DEPRECATED_MEMBER; + /* unused */ + unsigned long parentConsumed XML_DEPRECATED_MEMBER; + /* entity, if any */ + xmlEntityPtr entity XML_DEPRECATED_MEMBER; +}; + +/** + * xmlParserNodeInfo: + * + * The parser can be asked to collect Node information, i.e. at what + * place in the file they were detected. + * NOTE: This is off by default and not very well tested. + */ +typedef struct _xmlParserNodeInfo xmlParserNodeInfo; +typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; + +struct _xmlParserNodeInfo { + const struct _xmlNode* node; + /* Position & line # that text that created the node begins & ends on */ + unsigned long begin_pos; + unsigned long begin_line; + unsigned long end_pos; + unsigned long end_line; +}; + +typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; +typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; +struct _xmlParserNodeInfoSeq { + unsigned long maximum; + unsigned long length; + xmlParserNodeInfo* buffer; +}; + +/** + * xmlParserInputState: + * + * The parser is now working also as a state based parser. + * The recursive one use the state info for entities processing. + */ +typedef enum { + XML_PARSER_EOF = -1, /* nothing is to be parsed */ + XML_PARSER_START = 0, /* nothing has been parsed */ + XML_PARSER_MISC, /* Misc* before int subset */ + XML_PARSER_PI, /* Within a processing instruction */ + XML_PARSER_DTD, /* within some DTD content */ + XML_PARSER_PROLOG, /* Misc* after internal subset */ + XML_PARSER_COMMENT, /* within a comment */ + XML_PARSER_START_TAG, /* within a start tag */ + XML_PARSER_CONTENT, /* within the content */ + XML_PARSER_CDATA_SECTION, /* within a CDATA section */ + XML_PARSER_END_TAG, /* within a closing tag */ + XML_PARSER_ENTITY_DECL, /* within an entity declaration */ + XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ + XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ + XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ + XML_PARSER_EPILOG, /* the Misc* after the last end tag */ + XML_PARSER_IGNORE, /* within an IGNORED section */ + XML_PARSER_PUBLIC_LITERAL, /* within a PUBLIC value */ + XML_PARSER_XML_DECL /* before XML decl (but after BOM) */ +} xmlParserInputState; + +/** DOC_DISABLE */ +/* + * Internal bits in the 'loadsubset' context member + */ +#define XML_DETECT_IDS 2 +#define XML_COMPLETE_ATTRS 4 +#define XML_SKIP_IDS 8 +/** DOC_ENABLE */ + +/** + * xmlParserMode: + * + * A parser can operate in various modes + */ +typedef enum { + XML_PARSE_UNKNOWN = 0, + XML_PARSE_DOM = 1, + XML_PARSE_SAX = 2, + XML_PARSE_PUSH_DOM = 3, + XML_PARSE_PUSH_SAX = 4, + XML_PARSE_READER = 5 +} xmlParserMode; + +typedef struct _xmlStartTag xmlStartTag; +typedef struct _xmlParserNsData xmlParserNsData; +typedef struct _xmlAttrHashBucket xmlAttrHashBucket; + +/** + * xmlResourceLoader: + * @ctxt: parser context + * @url: URL to load + * @publicId: publid ID from DTD (optional) + * @type: resource type + * @flags: flags + * @out: result pointer + * + * Callback for custom resource loaders. + * + * @flags can contain XML_INPUT_UNZIP and XML_INPUT_NETWORK. + * + * On success, @out should be set to a new parser input object and + * XML_ERR_OK should be returned. + * + * Returns an xmlParserErrors code. + */ +typedef xmlParserErrors +(*xmlResourceLoader)(void *ctxt, const char *url, const char *publicId, + xmlResourceType type, xmlParserInputFlags flags, + xmlParserInputPtr *out); + +/** + * xmlParserCtxt: + * + * The parser context. + * NOTE This doesn't completely define the parser state, the (current ?) + * design of the parser uses recursive function calls since this allow + * and easy mapping from the production rules of the specification + * to the actual code. The drawback is that the actual function call + * also reflect the parser state. However most of the parsing routines + * takes as the only argument the parser context pointer, so migrating + * to a state based parser for progressive parsing shouldn't be too hard. + */ +struct _xmlParserCtxt { + /* The SAX handler */ + struct _xmlSAXHandler *sax; + /* For SAX interface only, used by DOM build */ + void *userData; + /* the document being built */ + xmlDocPtr myDoc; + /* is the document well formed */ + int wellFormed; + /* shall we replace entities ? */ + int replaceEntities XML_DEPRECATED_MEMBER; + /* the XML version string */ + const xmlChar *version; + /* the declared encoding, if any */ + const xmlChar *encoding; + /* standalone document */ + int standalone; + + /* an HTML(1) document + * 3 is HTML after + * 10 is HTML after + */ + int html; + + /* Input stream stack */ + + /* Current input stream */ + xmlParserInputPtr input; + /* Number of current input streams */ + int inputNr; + /* Max number of input streams */ + int inputMax XML_DEPRECATED_MEMBER; + /* stack of inputs */ + xmlParserInputPtr *inputTab; + + /* Node analysis stack only used for DOM building */ + + /* Current parsed Node */ + xmlNodePtr node; + /* Depth of the parsing stack */ + int nodeNr XML_DEPRECATED_MEMBER; + /* Max depth of the parsing stack */ + int nodeMax XML_DEPRECATED_MEMBER; + /* array of nodes */ + xmlNodePtr *nodeTab XML_DEPRECATED_MEMBER; + + /* Whether node info should be kept */ + int record_info; + /* info about each node parsed */ + xmlParserNodeInfoSeq node_seq XML_DEPRECATED_MEMBER; + + /* error code */ + int errNo; + + /* reference and external subset */ + int hasExternalSubset XML_DEPRECATED_MEMBER; + /* the internal subset has PE refs */ + int hasPErefs XML_DEPRECATED_MEMBER; + /* unused */ + int external XML_DEPRECATED_MEMBER; + + /* is the document valid */ + int valid; + /* shall we try to validate ? */ + int validate XML_DEPRECATED_MEMBER; + /* The validity context */ + xmlValidCtxt vctxt; + + /* push parser state */ + xmlParserInputState instate XML_DEPRECATED_MEMBER; + /* unused */ + int token XML_DEPRECATED_MEMBER; + + /* unused internally, still used downstream */ + char *directory; + + /* Node name stack */ + + /* Current parsed Node */ + const xmlChar *name XML_DEPRECATED_MEMBER; + /* Depth of the parsing stack */ + int nameNr XML_DEPRECATED_MEMBER; + /* Max depth of the parsing stack */ + int nameMax XML_DEPRECATED_MEMBER; + /* array of nodes */ + const xmlChar **nameTab XML_DEPRECATED_MEMBER; + + /* unused */ + long nbChars XML_DEPRECATED_MEMBER; + /* used by progressive parsing lookup */ + long checkIndex XML_DEPRECATED_MEMBER; + /* ugly but ... */ + int keepBlanks XML_DEPRECATED_MEMBER; + /* SAX callbacks are disabled */ + int disableSAX; + /* Parsing is in int 1/ext 2 subset */ + int inSubset; + /* name of subset */ + const xmlChar *intSubName; + /* URI of external subset */ + xmlChar *extSubURI; + /* SYSTEM ID of external subset */ + xmlChar *extSubSystem; + + /* xml:space values */ + + /* Should the parser preserve spaces */ + int *space XML_DEPRECATED_MEMBER; + /* Depth of the parsing stack */ + int spaceNr XML_DEPRECATED_MEMBER; + /* Max depth of the parsing stack */ + int spaceMax XML_DEPRECATED_MEMBER; + /* array of space infos */ + int *spaceTab XML_DEPRECATED_MEMBER; + + /* to prevent entity substitution loops */ + int depth XML_DEPRECATED_MEMBER; + /* unused */ + xmlParserInputPtr entity XML_DEPRECATED_MEMBER; + /* unused */ + int charset XML_DEPRECATED_MEMBER; + /* Those two fields are there to */ + int nodelen XML_DEPRECATED_MEMBER; + /* Speed up large node parsing */ + int nodemem XML_DEPRECATED_MEMBER; + /* signal pedantic warnings */ + int pedantic XML_DEPRECATED_MEMBER; + /* For user data, libxml won't touch it */ + void *_private; + + /* should the external subset be loaded */ + int loadsubset; + /* set line number in element content */ + int linenumbers XML_DEPRECATED_MEMBER; + /* document's own catalog */ + void *catalogs XML_DEPRECATED_MEMBER; + /* run in recovery mode */ + int recovery XML_DEPRECATED_MEMBER; + /* unused */ + int progressive XML_DEPRECATED_MEMBER; + /* dictionary for the parser */ + xmlDictPtr dict; + /* array for the attributes callbacks */ + const xmlChar **atts XML_DEPRECATED_MEMBER; + /* the size of the array */ + int maxatts XML_DEPRECATED_MEMBER; + /* unused */ + int docdict XML_DEPRECATED_MEMBER; + + /* + * pre-interned strings + */ + const xmlChar *str_xml XML_DEPRECATED_MEMBER; + const xmlChar *str_xmlns XML_DEPRECATED_MEMBER; + const xmlChar *str_xml_ns XML_DEPRECATED_MEMBER; + + /* + * Everything below is used only by the new SAX mode + */ + + /* operating in the new SAX mode */ + int sax2 XML_DEPRECATED_MEMBER; + /* the number of inherited namespaces */ + int nsNr XML_DEPRECATED_MEMBER; + /* the size of the arrays */ + int nsMax XML_DEPRECATED_MEMBER; + /* the array of prefix/namespace name */ + const xmlChar **nsTab XML_DEPRECATED_MEMBER; + /* which attribute were allocated */ + unsigned *attallocs XML_DEPRECATED_MEMBER; + /* array of data for push */ + xmlStartTag *pushTab XML_DEPRECATED_MEMBER; + /* defaulted attributes if any */ + xmlHashTablePtr attsDefault XML_DEPRECATED_MEMBER; + /* non-CDATA attributes if any */ + xmlHashTablePtr attsSpecial XML_DEPRECATED_MEMBER; + /* is the document XML Namespace okay */ + int nsWellFormed; + /* Extra options */ + int options; + + /* + * Those fields are needed only for streaming parsing so far + */ + + /* Use dictionary names for the tree */ + int dictNames XML_DEPRECATED_MEMBER; + /* number of freed element nodes */ + int freeElemsNr XML_DEPRECATED_MEMBER; + /* List of freed element nodes */ + xmlNodePtr freeElems XML_DEPRECATED_MEMBER; + /* number of freed attributes nodes */ + int freeAttrsNr XML_DEPRECATED_MEMBER; + /* List of freed attributes nodes */ + xmlAttrPtr freeAttrs XML_DEPRECATED_MEMBER; + + /* + * the complete error information for the last error. + */ + xmlError lastError XML_DEPRECATED_MEMBER; + /* the parser mode */ + xmlParserMode parseMode XML_DEPRECATED_MEMBER; + /* unused */ + unsigned long nbentities XML_DEPRECATED_MEMBER; + /* size of external entities */ + unsigned long sizeentities XML_DEPRECATED_MEMBER; + + /* for use by HTML non-recursive parser */ + /* Current NodeInfo */ + xmlParserNodeInfo *nodeInfo XML_DEPRECATED_MEMBER; + /* Depth of the parsing stack */ + int nodeInfoNr XML_DEPRECATED_MEMBER; + /* Max depth of the parsing stack */ + int nodeInfoMax XML_DEPRECATED_MEMBER; + /* array of nodeInfos */ + xmlParserNodeInfo *nodeInfoTab XML_DEPRECATED_MEMBER; + + /* we need to label inputs */ + int input_id XML_DEPRECATED_MEMBER; + /* volume of entity copy */ + unsigned long sizeentcopy XML_DEPRECATED_MEMBER; + + /* quote state for push parser */ + int endCheckState XML_DEPRECATED_MEMBER; + /* number of errors */ + unsigned short nbErrors XML_DEPRECATED_MEMBER; + /* number of warnings */ + unsigned short nbWarnings XML_DEPRECATED_MEMBER; + /* maximum amplification factor */ + unsigned maxAmpl XML_DEPRECATED_MEMBER; + + /* namespace database */ + xmlParserNsData *nsdb XML_DEPRECATED_MEMBER; + /* allocated size */ + unsigned attrHashMax XML_DEPRECATED_MEMBER; + /* atttribute hash table */ + xmlAttrHashBucket *attrHash XML_DEPRECATED_MEMBER; + + xmlStructuredErrorFunc errorHandler XML_DEPRECATED_MEMBER; + void *errorCtxt XML_DEPRECATED_MEMBER; + + xmlResourceLoader resourceLoader XML_DEPRECATED_MEMBER; + void *resourceCtxt XML_DEPRECATED_MEMBER; + + xmlCharEncConvImpl convImpl XML_DEPRECATED_MEMBER; + void *convCtxt XML_DEPRECATED_MEMBER; +}; + +/** + * xmlSAXLocator: + * + * A SAX Locator. + */ +struct _xmlSAXLocator { + const xmlChar *(*getPublicId)(void *ctx); + const xmlChar *(*getSystemId)(void *ctx); + int (*getLineNumber)(void *ctx); + int (*getColumnNumber)(void *ctx); +}; + +/** + * xmlSAXHandler: + * + * A SAX handler is bunch of callbacks called by the parser when processing + * of the input generate data or structure information. + */ + +/** + * resolveEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * Callback: + * The entity loader, to control the loading of external entities, + * the application can either: + * - override this resolveEntity() callback in the SAX block + * - or better use the xmlSetExternalEntityLoader() function to + * set up it's own entity resolution routine + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); +/** + * internalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the root element name + * @ExternalID: the external ID + * @SystemID: the SYSTEM ID (e.g. filename or URL) + * + * Callback on internal subset declaration. + */ +typedef void (*internalSubsetSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * externalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the root element name + * @ExternalID: the external ID + * @SystemID: the SYSTEM ID (e.g. filename or URL) + * + * Callback on external subset declaration. + */ +typedef void (*externalSubsetSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * getEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Get an entity by name. + * + * Returns the xmlEntityPtr if found. + */ +typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, + const xmlChar *name); +/** + * getParameterEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Get a parameter entity by name. + * + * Returns the xmlEntityPtr if found. + */ +typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, + const xmlChar *name); +/** + * entityDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the entity name + * @type: the entity type + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @content: the entity value (without processing). + * + * An entity definition has been parsed. + */ +typedef void (*entityDeclSAXFunc) (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +/** + * notationDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The name of the notation + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * What to do when a notation declaration has been parsed. + */ +typedef void (*notationDeclSAXFunc)(void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +/** + * attributeDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @elem: the name of the element + * @fullname: the attribute name + * @type: the attribute type + * @def: the type of default value + * @defaultValue: the attribute default value + * @tree: the tree of enumerated value set + * + * An attribute definition has been parsed. + */ +typedef void (*attributeDeclSAXFunc)(void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +/** + * elementDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the element name + * @type: the element type + * @content: the element value tree + * + * An element definition has been parsed. + */ +typedef void (*elementDeclSAXFunc)(void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +/** + * unparsedEntityDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The name of the entity + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @notationName: the name of the notation + * + * What to do when an unparsed entity declaration is parsed. + */ +typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); +/** + * setDocumentLocatorSAXFunc: + * @ctx: the user data (XML parser context) + * @loc: A SAX Locator + * + * Receive the document locator at startup, actually xmlDefaultSAXLocator. + * Everything is available on the context, so this is useless in our case. + */ +typedef void (*setDocumentLocatorSAXFunc) (void *ctx, + xmlSAXLocatorPtr loc); +/** + * startDocumentSAXFunc: + * @ctx: the user data (XML parser context) + * + * Called when the document start being processed. + */ +typedef void (*startDocumentSAXFunc) (void *ctx); +/** + * endDocumentSAXFunc: + * @ctx: the user data (XML parser context) + * + * Called when the document end has been detected. + */ +typedef void (*endDocumentSAXFunc) (void *ctx); +/** + * startElementSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The element name, including namespace prefix + * @atts: An array of name/value attributes pairs, NULL terminated + * + * Called when an opening tag has been processed. + */ +typedef void (*startElementSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar **atts); +/** + * endElementSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The element name + * + * Called when the end of an element has been detected. + */ +typedef void (*endElementSAXFunc) (void *ctx, + const xmlChar *name); +/** + * attributeSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The attribute name, including namespace prefix + * @value: The attribute value + * + * Handle an attribute that has been read by the parser. + * The default handling is to convert the attribute into an + * DOM subtree and past it in a new xmlAttr element added to + * the element. + */ +typedef void (*attributeSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *value); +/** + * referenceSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Called when an entity reference is detected. + */ +typedef void (*referenceSAXFunc) (void *ctx, + const xmlChar *name); +/** + * charactersSAXFunc: + * @ctx: the user data (XML parser context) + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * Receiving some chars from the parser. + */ +typedef void (*charactersSAXFunc) (void *ctx, + const xmlChar *ch, + int len); +/** + * ignorableWhitespaceSAXFunc: + * @ctx: the user data (XML parser context) + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * Receiving some ignorable whitespaces from the parser. + * UNUSED: by default the DOM building will use characters. + */ +typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, + const xmlChar *ch, + int len); +/** + * processingInstructionSAXFunc: + * @ctx: the user data (XML parser context) + * @target: the target name + * @data: the PI data's + * + * A processing instruction has been parsed. + */ +typedef void (*processingInstructionSAXFunc) (void *ctx, + const xmlChar *target, + const xmlChar *data); +/** + * commentSAXFunc: + * @ctx: the user data (XML parser context) + * @value: the comment content + * + * A comment has been parsed. + */ +typedef void (*commentSAXFunc) (void *ctx, + const xmlChar *value); +/** + * cdataBlockSAXFunc: + * @ctx: the user data (XML parser context) + * @value: The pcdata content + * @len: the block length + * + * Called when a pcdata block has been parsed. + */ +typedef void (*cdataBlockSAXFunc) ( + void *ctx, + const xmlChar *value, + int len); +/** + * warningSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format a warning messages, callback. + */ +typedef void (*warningSAXFunc) (void *ctx, + const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); +/** + * errorSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format an error messages, callback. + */ +typedef void (*errorSAXFunc) (void *ctx, + const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); +/** + * fatalErrorSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format fatal error messages, callback. + * Note: so far fatalError() SAX callbacks are not used, error() + * get all the callbacks for errors. + */ +typedef void (*fatalErrorSAXFunc) (void *ctx, + const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); +/** + * isStandaloneSAXFunc: + * @ctx: the user data (XML parser context) + * + * Is this document tagged standalone? + * + * Returns 1 if true + */ +typedef int (*isStandaloneSAXFunc) (void *ctx); +/** + * hasInternalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * + * Does this document has an internal subset. + * + * Returns 1 if true + */ +typedef int (*hasInternalSubsetSAXFunc) (void *ctx); + +/** + * hasExternalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * + * Does this document has an external subset? + * + * Returns 1 if true + */ +typedef int (*hasExternalSubsetSAXFunc) (void *ctx); + +/************************************************************************ + * * + * The SAX version 2 API extensions * + * * + ************************************************************************/ +/** + * XML_SAX2_MAGIC: + * + * Special constant found in SAX2 blocks initialized fields + */ +#define XML_SAX2_MAGIC 0xDEEDBEAF + +/** + * startElementNsSAX2Func: + * @ctx: the user data (XML parser context) + * @localname: the local name of the element + * @prefix: the element namespace prefix if available + * @URI: the element namespace name if available + * @nb_namespaces: number of namespace definitions on that node + * @namespaces: pointer to the array of prefix/URI pairs namespace definitions + * @nb_attributes: the number of attributes on that node + * @nb_defaulted: the number of defaulted attributes. The defaulted + * ones are at the end of the array + * @attributes: pointer to the array of (localname/prefix/URI/value/end) + * attribute values. + * + * SAX2 callback when an element start has been detected by the parser. + * It provides the namespace information for the element, as well as + * the new namespace declarations on the element. + */ + +typedef void (*startElementNsSAX2Func) (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +/** + * endElementNsSAX2Func: + * @ctx: the user data (XML parser context) + * @localname: the local name of the element + * @prefix: the element namespace prefix if available + * @URI: the element namespace name if available + * + * SAX2 callback when an element end has been detected by the parser. + * It provides the namespace information for the element. + */ + +typedef void (*endElementNsSAX2Func) (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + + +struct _xmlSAXHandler { + /* + * For DTD-related handlers, it's recommended to either use the + * original libxml2 handler or set them to NULL if DTDs can be + * ignored. + */ + internalSubsetSAXFunc internalSubset; /* DTD */ + isStandaloneSAXFunc isStandalone; /* unused */ + hasInternalSubsetSAXFunc hasInternalSubset; /* DTD */ + hasExternalSubsetSAXFunc hasExternalSubset; /* DTD */ + resolveEntitySAXFunc resolveEntity; /* DTD */ + getEntitySAXFunc getEntity; /* DTD */ + entityDeclSAXFunc entityDecl; /* DTD */ + notationDeclSAXFunc notationDecl; /* DTD */ + attributeDeclSAXFunc attributeDecl; /* DTD */ + elementDeclSAXFunc elementDecl; /* DTD */ + unparsedEntityDeclSAXFunc unparsedEntityDecl; /* DTD */ + setDocumentLocatorSAXFunc setDocumentLocator; /* deprecated */ + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + /* + * `startElement` and `endElement` are only used by the legacy SAX1 + * interface and should not be used in new software. If you really + * have to enable SAX1, the preferred way is set the `initialized` + * member to 1 instead of XML_SAX2_MAGIC. + * + * For backward compatibility, it's also possible to set the + * `startElementNs` and `endElementNs` handlers to NULL. + * + * You can also set the XML_PARSE_SAX1 parser option, but versions + * older than 2.12.0 will probably crash if this option is provided + * together with custom SAX callbacks. + */ + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + /* + * `ignorableWhitespace` should always be set to the same value + * as `characters`. Otherwise, the parser will try to detect + * whitespace which is unreliable. + */ + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; /* unused, `error` gets all the errors */ + getParameterEntitySAXFunc getParameterEntity; /* DTD */ + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; /* DTD */ + /* + * `initialized` should always be set to XML_SAX2_MAGIC to enable the + * modern SAX2 interface. + */ + unsigned int initialized; + /* + * The following members are only used by the SAX2 interface. + */ + void *_private; + startElementNsSAX2Func startElementNs; + endElementNsSAX2Func endElementNs; + /* + * Takes precedence over `error` or `warning`, but modern code + * should use xmlCtxtSetErrorHandler. + */ + xmlStructuredErrorFunc serror; +}; + +/* + * SAX Version 1 + */ +typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; +typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; +struct _xmlSAXHandlerV1 { + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; +}; + + +/** + * xmlExternalEntityLoader: + * @URL: The System ID of the resource requested + * @ID: The Public ID of the resource requested + * @context: the XML parser context + * + * External entity loaders types. + * + * Returns the entity input parser. + */ +typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, + const char *ID, + xmlParserCtxtPtr context); + +/* + * Variables + */ + +XMLPUBVAR const char *const xmlParserVersion; + +/** DOC_DISABLE */ +XML_DEPRECATED +XMLPUBVAR const xmlSAXLocator xmlDefaultSAXLocator; +#ifdef LIBXML_SAX1_ENABLED +XML_DEPRECATED +XMLPUBVAR const xmlSAXHandlerV1 xmlDefaultSAXHandler; +#endif + +XML_DEPRECATED +XMLPUBFUN int *__xmlDoValidityCheckingDefaultValue(void); +XML_DEPRECATED +XMLPUBFUN int *__xmlGetWarningsDefaultValue(void); +XML_DEPRECATED +XMLPUBFUN int *__xmlKeepBlanksDefaultValue(void); +XML_DEPRECATED +XMLPUBFUN int *__xmlLineNumbersDefaultValue(void); +XML_DEPRECATED +XMLPUBFUN int *__xmlLoadExtDtdDefaultValue(void); +XML_DEPRECATED +XMLPUBFUN int *__xmlPedanticParserDefaultValue(void); +XML_DEPRECATED +XMLPUBFUN int *__xmlSubstituteEntitiesDefaultValue(void); + +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN int *__xmlIndentTreeOutput(void); +XMLPUBFUN const char **__xmlTreeIndentString(void); +XMLPUBFUN int *__xmlSaveNoEmptyTags(void); +#endif + +#ifndef XML_GLOBALS_NO_REDEFINITION + #define xmlDoValidityCheckingDefaultValue \ + (*__xmlDoValidityCheckingDefaultValue()) + #define xmlGetWarningsDefaultValue \ + (*__xmlGetWarningsDefaultValue()) + #define xmlKeepBlanksDefaultValue (*__xmlKeepBlanksDefaultValue()) + #define xmlLineNumbersDefaultValue \ + (*__xmlLineNumbersDefaultValue()) + #define xmlLoadExtDtdDefaultValue (*__xmlLoadExtDtdDefaultValue()) + #define xmlPedanticParserDefaultValue \ + (*__xmlPedanticParserDefaultValue()) + #define xmlSubstituteEntitiesDefaultValue \ + (*__xmlSubstituteEntitiesDefaultValue()) + #ifdef LIBXML_OUTPUT_ENABLED + #define xmlIndentTreeOutput (*__xmlIndentTreeOutput()) + #define xmlTreeIndentString (*__xmlTreeIndentString()) + #define xmlSaveNoEmptyTags (*__xmlSaveNoEmptyTags()) + #endif +#endif +/** DOC_ENABLE */ + +/* + * Init/Cleanup + */ +XMLPUBFUN void + xmlInitParser (void); +XMLPUBFUN void + xmlCleanupParser (void); +XML_DEPRECATED +XMLPUBFUN void + xmlInitGlobals (void); +XML_DEPRECATED +XMLPUBFUN void + xmlCleanupGlobals (void); + +/* + * Input functions + */ +XML_DEPRECATED +XMLPUBFUN int + xmlParserInputRead (xmlParserInputPtr in, + int len); +XMLPUBFUN int + xmlParserInputGrow (xmlParserInputPtr in, + int len); + +/* + * Basic parsing Interfaces + */ +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN xmlDocPtr + xmlParseDoc (const xmlChar *cur); +XMLPUBFUN xmlDocPtr + xmlParseFile (const char *filename); +XMLPUBFUN xmlDocPtr + xmlParseMemory (const char *buffer, + int size); +#endif /* LIBXML_SAX1_ENABLED */ +XML_DEPRECATED +XMLPUBFUN int + xmlSubstituteEntitiesDefault(int val); +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefSubstituteEntitiesDefaultValue(int v); +XMLPUBFUN int + xmlKeepBlanksDefault (int val); +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefKeepBlanksDefaultValue(int v); +XMLPUBFUN void + xmlStopParser (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int + xmlPedanticParserDefault(int val); +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefPedanticParserDefaultValue(int v); +XML_DEPRECATED +XMLPUBFUN int + xmlLineNumbersDefault (int val); +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefLineNumbersDefaultValue(int v); +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefDoValidityCheckingDefaultValue(int v); +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefGetWarningsDefaultValue(int v); +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefLoadExtDtdDefaultValue(int v); + +#ifdef LIBXML_SAX1_ENABLED +/* + * Recovery mode + */ +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlRecoverDoc (const xmlChar *cur); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlRecoverMemory (const char *buffer, + int size); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlRecoverFile (const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ + +/* + * Less common routines and SAX interfaces + */ +XMLPUBFUN int + xmlParseDocument (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int + xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XML_DEPRECATED +XMLPUBFUN int + xmlSAXUserParseFile (xmlSAXHandlerPtr sax, + void *user_data, + const char *filename); +XML_DEPRECATED +XMLPUBFUN int + xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, + void *user_data, + const char *buffer, + int size); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlSAXParseDoc (xmlSAXHandlerPtr sax, + const xmlChar *cur, + int recovery); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlSAXParseMemory (xmlSAXHandlerPtr sax, + const char *buffer, + int size, + int recovery); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, + const char *buffer, + int size, + int recovery, + void *data); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlSAXParseFile (xmlSAXHandlerPtr sax, + const char *filename, + int recovery); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, + const char *filename, + int recovery, + void *data); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlSAXParseEntity (xmlSAXHandlerPtr sax, + const char *filename); +XML_DEPRECATED +XMLPUBFUN xmlDocPtr + xmlParseEntity (const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ + +#ifdef LIBXML_VALID_ENABLED +XMLPUBFUN xmlDtdPtr + xmlCtxtParseDtd (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN int + xmlCtxtValidateDocument (xmlParserCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int + xmlCtxtValidateDtd (xmlParserCtxtPtr ctxt, + xmlDocPtr doc, + xmlDtdPtr dtd); +XML_DEPRECATED +XMLPUBFUN xmlDtdPtr + xmlSAXParseDTD (xmlSAXHandlerPtr sax, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr + xmlParseDTD (const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr + xmlIOParseDTD (xmlSAXHandlerPtr sax, + xmlParserInputBufferPtr input, + xmlCharEncoding enc); +#endif /* LIBXML_VALID_ENABLE */ +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int + xmlParseBalancedChunkMemory(xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *string, + xmlNodePtr *lst); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN xmlParserErrors + xmlParseInNodeContext (xmlNodePtr node, + const char *data, + int datalen, + int options, + xmlNodePtr *lst); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int + xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *string, + xmlNodePtr *lst, + int recover); +XML_DEPRECATED +XMLPUBFUN int + xmlParseExternalEntity (xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *URL, + const xmlChar *ID, + xmlNodePtr *lst); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN int + xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, + const xmlChar *URL, + const xmlChar *ID, + xmlNodePtr *lst); + +/* + * Parser contexts handling. + */ +XMLPUBFUN xmlParserCtxtPtr + xmlNewParserCtxt (void); +XMLPUBFUN xmlParserCtxtPtr + xmlNewSAXParserCtxt (const xmlSAXHandler *sax, + void *userData); +XMLPUBFUN int + xmlInitParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void + xmlClearParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void + xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XML_DEPRECATED +XMLPUBFUN void + xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, + const xmlChar* buffer, + const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN xmlParserCtxtPtr + xmlCreateDocParserCtxt (const xmlChar *cur); + +#ifdef LIBXML_PUSH_ENABLED +/* + * Interfaces for the Push mode. + */ +XMLPUBFUN xmlParserCtxtPtr + xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename); +XMLPUBFUN int + xmlParseChunk (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +#endif /* LIBXML_PUSH_ENABLED */ + +/* + * Special I/O mode. + */ + +XMLPUBFUN xmlParserCtxtPtr + xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, + void *user_data, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + xmlCharEncoding enc); + +XMLPUBFUN xmlParserInputPtr + xmlNewIOInputStream (xmlParserCtxtPtr ctxt, + xmlParserInputBufferPtr input, + xmlCharEncoding enc); + +/* + * Node infos. + */ +XML_DEPRECATED +XMLPUBFUN const xmlParserNodeInfo* + xmlParserFindNodeInfo (xmlParserCtxtPtr ctxt, + xmlNodePtr node); +XML_DEPRECATED +XMLPUBFUN void + xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +XML_DEPRECATED +XMLPUBFUN void + xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +XML_DEPRECATED +XMLPUBFUN unsigned long + xmlParserFindNodeInfoIndex(xmlParserNodeInfoSeqPtr seq, + xmlNodePtr node); +XML_DEPRECATED +XMLPUBFUN void + xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, + xmlParserNodeInfoPtr info); + +/* + * External entities handling actually implemented in xmlIO. + */ + +XMLPUBFUN void + xmlSetExternalEntityLoader(xmlExternalEntityLoader f); +XMLPUBFUN xmlExternalEntityLoader + xmlGetExternalEntityLoader(void); +XMLPUBFUN xmlParserInputPtr + xmlLoadExternalEntity (const char *URL, + const char *ID, + xmlParserCtxtPtr ctxt); + +XML_DEPRECATED +XMLPUBFUN long + xmlByteConsumed (xmlParserCtxtPtr ctxt); + +/* + * New set of simpler/more flexible APIs + */ +/** + * xmlParserOption: + * + * This is the set of XML parser options that can be passed down + * to the xmlReadDoc() and similar calls. + */ +typedef enum { + XML_PARSE_RECOVER = 1<<0, /* recover on errors */ + XML_PARSE_NOENT = 1<<1, /* substitute entities */ + XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */ + XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */ + XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */ + XML_PARSE_NOERROR = 1<<5, /* suppress error reports */ + XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */ + XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ + XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ + XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ + XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitution */ + XML_PARSE_NONET = 1<<11,/* Forbid network access */ + XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */ + XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ + XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */ + XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */ + XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of + the tree allowed afterwards (will possibly + crash if you try to modify the tree) */ + XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */ + XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */ + XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */ + XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */ + XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */ + XML_PARSE_BIG_LINES = 1<<22,/* Store big lines numbers in text PSVI field */ + /* since 2.13.0 */ + XML_PARSE_NO_XXE = 1<<23,/* disable loading of external content */ + /* since 2.14.0 */ + XML_PARSE_UNZIP = 1<<24,/* allow compressed content */ + XML_PARSE_NO_SYS_CATALOG = 1<<25,/* disable global system catalog */ + XML_PARSE_CATALOG_PI = 1<<26 /* allow catalog PIs */ +} xmlParserOption; + +XMLPUBFUN void + xmlCtxtReset (xmlParserCtxtPtr ctxt); +XMLPUBFUN int + xmlCtxtResetPush (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + const char *filename, + const char *encoding); +XMLPUBFUN int + xmlCtxtGetOptions (xmlParserCtxtPtr ctxt); +XMLPUBFUN int + xmlCtxtSetOptions (xmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN int + xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN void * + xmlCtxtGetPrivate (xmlParserCtxtPtr ctxt); +XMLPUBFUN void + xmlCtxtSetPrivate (xmlParserCtxtPtr ctxt, + void *priv); +XMLPUBFUN void * + xmlCtxtGetCatalogs (xmlParserCtxtPtr ctxt); +XMLPUBFUN void + xmlCtxtSetCatalogs (xmlParserCtxtPtr ctxt, + void *catalogs); +XMLPUBFUN xmlDictPtr + xmlCtxtGetDict (xmlParserCtxtPtr ctxt); +XMLPUBFUN void + xmlCtxtSetDict (xmlParserCtxtPtr ctxt, + xmlDictPtr); +XMLPUBFUN xmlSAXHandler * + xmlCtxtGetSaxHandler (xmlParserCtxtPtr ctxt); +XMLPUBFUN int + xmlCtxtSetSaxHandler (xmlParserCtxtPtr ctxt, + const xmlSAXHandler *sax); +XMLPUBFUN xmlDocPtr + xmlCtxtGetDocument (xmlParserCtxtPtr ctxt); +XMLPUBFUN int + xmlCtxtIsHtml (xmlParserCtxtPtr ctxt); +XMLPUBFUN int + xmlCtxtIsStopped (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_VALID_ENABLED +XMLPUBFUN xmlValidCtxtPtr + xmlCtxtGetValidCtxt (xmlParserCtxtPtr ctxt); +#endif +XMLPUBFUN const xmlChar * + xmlCtxtGetVersion (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * + xmlCtxtGetDeclaredEncoding(xmlParserCtxtPtr ctxt); +XMLPUBFUN int + xmlCtxtGetStandalone (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlParserStatus + xmlCtxtGetStatus (xmlParserCtxtPtr ctxt); +XMLPUBFUN void + xmlCtxtSetErrorHandler (xmlParserCtxtPtr ctxt, + xmlStructuredErrorFunc handler, + void *data); +XMLPUBFUN void + xmlCtxtSetResourceLoader(xmlParserCtxtPtr ctxt, + xmlResourceLoader loader, + void *vctxt); +XMLPUBFUN void + xmlCtxtSetCharEncConvImpl(xmlParserCtxtPtr ctxt, + xmlCharEncConvImpl impl, + void *vctxt); +XMLPUBFUN void + xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt, + unsigned maxAmpl); +XMLPUBFUN xmlDocPtr + xmlReadDoc (const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlReadFile (const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlReadMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlReadFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlCtxtParseDocument (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input); +XMLPUBFUN xmlNodePtr + xmlCtxtParseContent (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input, + xmlNodePtr node, + int hasTextDecl); +XMLPUBFUN xmlDocPtr + xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr + xmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +/** + * New input API + */ + +XMLPUBFUN xmlParserErrors +xmlNewInputFromUrl(const char *url, xmlParserInputFlags flags, + xmlParserInputPtr *out); +XMLPUBFUN xmlParserInputPtr +xmlNewInputFromMemory(const char *url, const void *mem, size_t size, + xmlParserInputFlags flags); +XMLPUBFUN xmlParserInputPtr +xmlNewInputFromString(const char *url, const char *str, + xmlParserInputFlags flags); +XMLPUBFUN xmlParserInputPtr +xmlNewInputFromFd(const char *url, int fd, xmlParserInputFlags flags); +XMLPUBFUN xmlParserInputPtr +xmlNewInputFromIO(const char *url, xmlInputReadCallback ioRead, + xmlInputCloseCallback ioClose, void *ioCtxt, + xmlParserInputFlags flags); +XMLPUBFUN xmlParserErrors +xmlInputSetEncodingHandler(xmlParserInputPtr input, + xmlCharEncodingHandlerPtr handler); + +/* + * Library wide options + */ +/** + * xmlFeature: + * + * Used to examine the existence of features that can be enabled + * or disabled at compile-time. + * They used to be called XML_FEATURE_xxx but this clashed with Expat + */ +typedef enum { + XML_WITH_THREAD = 1, + XML_WITH_TREE = 2, + XML_WITH_OUTPUT = 3, + XML_WITH_PUSH = 4, + XML_WITH_READER = 5, + XML_WITH_PATTERN = 6, + XML_WITH_WRITER = 7, + XML_WITH_SAX1 = 8, + XML_WITH_FTP = 9, + XML_WITH_HTTP = 10, + XML_WITH_VALID = 11, + XML_WITH_HTML = 12, + XML_WITH_LEGACY = 13, + XML_WITH_C14N = 14, + XML_WITH_CATALOG = 15, + XML_WITH_XPATH = 16, + XML_WITH_XPTR = 17, + XML_WITH_XINCLUDE = 18, + XML_WITH_ICONV = 19, + XML_WITH_ISO8859X = 20, + XML_WITH_UNICODE = 21, + XML_WITH_REGEXP = 22, + XML_WITH_AUTOMATA = 23, + XML_WITH_EXPR = 24, + XML_WITH_SCHEMAS = 25, + XML_WITH_SCHEMATRON = 26, + XML_WITH_MODULES = 27, + XML_WITH_DEBUG = 28, + XML_WITH_DEBUG_MEM = 29, + XML_WITH_DEBUG_RUN = 30, /* unused */ + XML_WITH_ZLIB = 31, + XML_WITH_ICU = 32, + XML_WITH_LZMA = 33, + XML_WITH_RELAXNG = 34, /* since 2.14.0 */ + XML_WITH_NONE = 99999 /* just to be sure of allocation size */ +} xmlFeature; + +XMLPUBFUN int + xmlHasFeature (xmlFeature feature); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_PARSER_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/parserInternals.h b/illumos-x86_64/usr/include/libxml2/libxml/parserInternals.h new file mode 100644 index 00000000..3d259fc1 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/parserInternals.h @@ -0,0 +1,591 @@ +/* + * Summary: internals routines and limits exported by the parser. + * Description: this module exports a number of internal parsing routines + * they are not really all intended for applications but + * can prove useful doing low level processing. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PARSER_INTERNALS_H__ +#define __XML_PARSER_INTERNALS_H__ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Backward compatibility + */ +#define inputPush xmlCtxtPushInput +#define inputPop xmlCtxtPopInput +#define xmlParserMaxDepth 256 + +/** + * XML_MAX_TEXT_LENGTH: + * + * Maximum size allowed for a single text node when building a tree. + * This is not a limitation of the parser but a safety boundary feature, + * use XML_PARSE_HUGE option to override it. + * Introduced in 2.9.0 + */ +#define XML_MAX_TEXT_LENGTH 10000000 + +/** + * XML_MAX_HUGE_LENGTH: + * + * Maximum size allowed when XML_PARSE_HUGE is set. + */ +#define XML_MAX_HUGE_LENGTH 1000000000 + +/** + * XML_MAX_NAME_LENGTH: + * + * Maximum size allowed for a markup identifier. + * This is not a limitation of the parser but a safety boundary feature, + * use XML_PARSE_HUGE option to override it. + * Note that with the use of parsing dictionaries overriding the limit + * may result in more runtime memory usage in face of "unfriendly' content + * Introduced in 2.9.0 + */ +#define XML_MAX_NAME_LENGTH 50000 + +/** + * XML_MAX_DICTIONARY_LIMIT: + * + * Maximum size allowed by the parser for a dictionary by default + * This is not a limitation of the parser but a safety boundary feature, + * use XML_PARSE_HUGE option to override it. + * Introduced in 2.9.0 + */ +#define XML_MAX_DICTIONARY_LIMIT 100000000 + +/** + * XML_MAX_LOOKUP_LIMIT: + * + * Maximum size allowed by the parser for ahead lookup + * This is an upper boundary enforced by the parser to avoid bad + * behaviour on "unfriendly' content + * Introduced in 2.9.0 + */ +#define XML_MAX_LOOKUP_LIMIT 10000000 + +/** + * XML_MAX_NAMELEN: + * + * Identifiers can be longer, but this will be more costly + * at runtime. + */ +#define XML_MAX_NAMELEN 100 + +/************************************************************************ + * * + * UNICODE version of the macros. * + * * + ************************************************************************/ +/** + * IS_BYTE_CHAR: + * @c: an byte value (int) + * + * Macro to check the following production in the XML spec: + * + * [2] Char ::= #x9 | #xA | #xD | [#x20...] + * any byte character in the accepted range + */ +#define IS_BYTE_CHAR(c) xmlIsChar_ch(c) + +/** + * IS_CHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] + * | [#x10000-#x10FFFF] + * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. + */ +#define IS_CHAR(c) xmlIsCharQ(c) + +/** + * IS_CHAR_CH: + * @c: an xmlChar (usually an unsigned char) + * + * Behaves like IS_CHAR on single-byte value + */ +#define IS_CHAR_CH(c) xmlIsChar_ch(c) + +/** + * IS_BLANK: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [3] S ::= (#x20 | #x9 | #xD | #xA)+ + */ +#define IS_BLANK(c) xmlIsBlankQ(c) + +/** + * IS_BLANK_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Behaviour same as IS_BLANK + */ +#define IS_BLANK_CH(c) xmlIsBlank_ch(c) + +/** + * IS_BASECHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [85] BaseChar ::= ... long list see REC ... + */ +#define IS_BASECHAR(c) xmlIsBaseCharQ(c) + +/** + * IS_DIGIT: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [88] Digit ::= ... long list see REC ... + */ +#define IS_DIGIT(c) xmlIsDigitQ(c) + +/** + * IS_DIGIT_CH: + * @c: an xmlChar value (usually an unsigned char) + * + * Behaves like IS_DIGIT but with a single byte argument + */ +#define IS_DIGIT_CH(c) xmlIsDigit_ch(c) + +/** + * IS_COMBINING: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [87] CombiningChar ::= ... long list see REC ... + */ +#define IS_COMBINING(c) xmlIsCombiningQ(c) + +/** + * IS_COMBINING_CH: + * @c: an xmlChar (usually an unsigned char) + * + * Always false (all combining chars > 0xff) + */ +#define IS_COMBINING_CH(c) 0 + +/** + * IS_EXTENDER: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | + * #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | + * [#x309D-#x309E] | [#x30FC-#x30FE] + */ +#define IS_EXTENDER(c) xmlIsExtenderQ(c) + +/** + * IS_EXTENDER_CH: + * @c: an xmlChar value (usually an unsigned char) + * + * Behaves like IS_EXTENDER but with a single-byte argument + */ +#define IS_EXTENDER_CH(c) xmlIsExtender_ch(c) + +/** + * IS_IDEOGRAPHIC: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029] + */ +#define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c) + +/** + * IS_LETTER: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [84] Letter ::= BaseChar | Ideographic + */ +#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c)) + +/** + * IS_LETTER_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Macro behaves like IS_LETTER, but only check base chars + * + */ +#define IS_LETTER_CH(c) xmlIsBaseChar_ch(c) + +/** + * IS_ASCII_LETTER: + * @c: an xmlChar value + * + * Macro to check [a-zA-Z] + * + */ +#define IS_ASCII_LETTER(c) ((0x61 <= ((c) | 0x20)) && \ + (((c) | 0x20) <= 0x7a)) + +/** + * IS_ASCII_DIGIT: + * @c: an xmlChar value + * + * Macro to check [0-9] + * + */ +#define IS_ASCII_DIGIT(c) ((0x30 <= (c)) && ((c) <= 0x39)) + +/** + * IS_PUBIDCHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] + */ +#define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c) + +/** + * IS_PUBIDCHAR_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Same as IS_PUBIDCHAR but for single-byte value + */ +#define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c) + +/** + * Global variables used for predefined strings. + */ +XMLPUBVAR const xmlChar xmlStringText[]; +XMLPUBVAR const xmlChar xmlStringTextNoenc[]; +XML_DEPRECATED +XMLPUBVAR const xmlChar xmlStringComment[]; + +XML_DEPRECATED +XMLPUBFUN int xmlIsLetter (int c); + +/** + * Parser context. + */ +XMLPUBFUN xmlParserCtxtPtr + xmlCreateFileParserCtxt (const char *filename); +XMLPUBFUN xmlParserCtxtPtr + xmlCreateURLParserCtxt (const char *filename, + int options); +XMLPUBFUN xmlParserCtxtPtr + xmlCreateMemoryParserCtxt(const char *buffer, + int size); +XML_DEPRECATED +XMLPUBFUN xmlParserCtxtPtr + xmlCreateEntityParserCtxt(const xmlChar *URL, + const xmlChar *ID, + const xmlChar *base); +XMLPUBFUN void + xmlCtxtErrMemory (xmlParserCtxtPtr ctxt); +XMLPUBFUN int + xmlSwitchEncoding (xmlParserCtxtPtr ctxt, + xmlCharEncoding enc); +XMLPUBFUN int + xmlSwitchEncodingName (xmlParserCtxtPtr ctxt, + const char *encoding); +XMLPUBFUN int + xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, + xmlCharEncodingHandlerPtr handler); +XML_DEPRECATED +XMLPUBFUN int + xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input, + xmlCharEncodingHandlerPtr handler); + +/** + * Input Streams. + */ +XMLPUBFUN xmlParserInputPtr + xmlNewStringInputStream (xmlParserCtxtPtr ctxt, + const xmlChar *buffer); +XML_DEPRECATED +XMLPUBFUN xmlParserInputPtr + xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, + xmlEntityPtr entity); +XMLPUBFUN int + xmlCtxtPushInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input); +XMLPUBFUN xmlParserInputPtr + xmlCtxtPopInput (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int + xmlPushInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input); +XML_DEPRECATED +XMLPUBFUN xmlChar + xmlPopInput (xmlParserCtxtPtr ctxt); +XMLPUBFUN void + xmlFreeInputStream (xmlParserInputPtr input); +XMLPUBFUN xmlParserInputPtr + xmlNewInputFromFile (xmlParserCtxtPtr ctxt, + const char *filename); +XMLPUBFUN xmlParserInputPtr + xmlNewInputStream (xmlParserCtxtPtr ctxt); + +/** + * Namespaces. + */ +XMLPUBFUN xmlChar * + xmlSplitQName (xmlParserCtxtPtr ctxt, + const xmlChar *name, + xmlChar **prefix); + +/** + * Generic production rules. + */ +XML_DEPRECATED +XMLPUBFUN const xmlChar * + xmlParseName (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParseNmtoken (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParseEntityValue (xmlParserCtxtPtr ctxt, + xmlChar **orig); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParseAttValue (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParseSystemLiteral (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParsePubidLiteral (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseCharData (xmlParserCtxtPtr ctxt, + int cdata); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParseExternalID (xmlParserCtxtPtr ctxt, + xmlChar **publicID, + int strict); +XML_DEPRECATED +XMLPUBFUN void + xmlParseComment (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN const xmlChar * + xmlParsePITarget (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParsePI (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseNotationDecl (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseEntityDecl (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int + xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, + xmlChar **value); +XML_DEPRECATED +XMLPUBFUN xmlEnumerationPtr + xmlParseNotationType (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlEnumerationPtr + xmlParseEnumerationType (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int + xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, + xmlEnumerationPtr *tree); +XML_DEPRECATED +XMLPUBFUN int + xmlParseAttributeType (xmlParserCtxtPtr ctxt, + xmlEnumerationPtr *tree); +XML_DEPRECATED +XMLPUBFUN void + xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlElementContentPtr + xmlParseElementMixedContentDecl + (xmlParserCtxtPtr ctxt, + int inputchk); +XML_DEPRECATED +XMLPUBFUN xmlElementContentPtr + xmlParseElementChildrenContentDecl + (xmlParserCtxtPtr ctxt, + int inputchk); +XML_DEPRECATED +XMLPUBFUN int + xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, + const xmlChar *name, + xmlElementContentPtr *result); +XML_DEPRECATED +XMLPUBFUN int + xmlParseElementDecl (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseMarkupDecl (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int + xmlParseCharRef (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlEntityPtr + xmlParseEntityRef (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseReference (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParsePEReference (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XML_DEPRECATED +XMLPUBFUN const xmlChar * + xmlParseAttribute (xmlParserCtxtPtr ctxt, + xmlChar **value); +XML_DEPRECATED +XMLPUBFUN const xmlChar * + xmlParseStartTag (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseEndTag (xmlParserCtxtPtr ctxt); +#endif /* LIBXML_SAX1_ENABLED */ +XML_DEPRECATED +XMLPUBFUN void + xmlParseCDSect (xmlParserCtxtPtr ctxt); +XMLPUBFUN void + xmlParseContent (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseElement (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParseVersionNum (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParseVersionInfo (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlParseEncName (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN const xmlChar * + xmlParseEncodingDecl (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int + xmlParseSDDecl (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseXMLDecl (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseTextDecl (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseMisc (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlParseExternalSubset (xmlParserCtxtPtr ctxt, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * XML_SUBSTITUTE_NONE: + * + * If no entities need to be substituted. + */ +#define XML_SUBSTITUTE_NONE 0 +/** + * XML_SUBSTITUTE_REF: + * + * Whether general entities need to be substituted. + */ +#define XML_SUBSTITUTE_REF 1 +/** + * XML_SUBSTITUTE_PEREF: + * + * Whether parameter entities need to be substituted. + */ +#define XML_SUBSTITUTE_PEREF 2 +/** + * XML_SUBSTITUTE_BOTH: + * + * Both general and parameter entities need to be substituted. + */ +#define XML_SUBSTITUTE_BOTH 3 + +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlStringDecodeEntities (xmlParserCtxtPtr ctxt, + const xmlChar *str, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, + const xmlChar *str, + int len, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); + +/* + * other commodities shared between parser.c and parserInternals. + */ +XML_DEPRECATED +XMLPUBFUN int xmlSkipBlankChars (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int xmlStringCurrentChar (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + int *len); +XML_DEPRECATED +XMLPUBFUN void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN int xmlCheckLanguageID (const xmlChar *lang); + +/* + * Really core function shared with HTML parser. + */ +XML_DEPRECATED +XMLPUBFUN int xmlCurrentChar (xmlParserCtxtPtr ctxt, + int *len); +XML_DEPRECATED +XMLPUBFUN int xmlCopyCharMultiByte (xmlChar *out, + int val); +XML_DEPRECATED +XMLPUBFUN int xmlCopyChar (int len, + xmlChar *out, + int val); +XML_DEPRECATED +XMLPUBFUN void xmlNextChar (xmlParserCtxtPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void xmlParserInputShrink (xmlParserInputPtr in); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_PARSER_INTERNALS_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/pattern.h b/illumos-x86_64/usr/include/libxml2/libxml/pattern.h new file mode 100644 index 00000000..947f0900 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/pattern.h @@ -0,0 +1,106 @@ +/* + * Summary: pattern expression handling + * Description: allows to compile and test pattern expressions for nodes + * either in a tree or based on a parser state. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PATTERN_H__ +#define __XML_PATTERN_H__ + +#include +#include +#include + +#ifdef LIBXML_PATTERN_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlPattern: + * + * A compiled (XPath based) pattern to select nodes + */ +typedef struct _xmlPattern xmlPattern; +typedef xmlPattern *xmlPatternPtr; + +/** + * xmlPatternFlags: + * + * This is the set of options affecting the behaviour of pattern + * matching with this module + * + */ +typedef enum { + XML_PATTERN_DEFAULT = 0, /* simple pattern match */ + XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */ + XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */ + XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */ +} xmlPatternFlags; + +XMLPUBFUN void + xmlFreePattern (xmlPatternPtr comp); + +XMLPUBFUN void + xmlFreePatternList (xmlPatternPtr comp); + +XMLPUBFUN xmlPatternPtr + xmlPatterncompile (const xmlChar *pattern, + xmlDict *dict, + int flags, + const xmlChar **namespaces); +XMLPUBFUN int + xmlPatternCompileSafe (const xmlChar *pattern, + xmlDict *dict, + int flags, + const xmlChar **namespaces, + xmlPatternPtr *patternOut); +XMLPUBFUN int + xmlPatternMatch (xmlPatternPtr comp, + xmlNodePtr node); + +/* streaming interfaces */ +typedef struct _xmlStreamCtxt xmlStreamCtxt; +typedef xmlStreamCtxt *xmlStreamCtxtPtr; + +XMLPUBFUN int + xmlPatternStreamable (xmlPatternPtr comp); +XMLPUBFUN int + xmlPatternMaxDepth (xmlPatternPtr comp); +XMLPUBFUN int + xmlPatternMinDepth (xmlPatternPtr comp); +XMLPUBFUN int + xmlPatternFromRoot (xmlPatternPtr comp); +XMLPUBFUN xmlStreamCtxtPtr + xmlPatternGetStreamCtxt (xmlPatternPtr comp); +XMLPUBFUN void + xmlFreeStreamCtxt (xmlStreamCtxtPtr stream); +XMLPUBFUN int + xmlStreamPushNode (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns, + int nodeType); +XMLPUBFUN int + xmlStreamPush (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int + xmlStreamPushAttr (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int + xmlStreamPop (xmlStreamCtxtPtr stream); +XMLPUBFUN int + xmlStreamWantsAnyNode (xmlStreamCtxtPtr stream); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_PATTERN_ENABLED */ + +#endif /* __XML_PATTERN_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/relaxng.h b/illumos-x86_64/usr/include/libxml2/libxml/relaxng.h new file mode 100644 index 00000000..e9cb1ec9 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/relaxng.h @@ -0,0 +1,224 @@ +/* + * Summary: implementation of the Relax-NG validation + * Description: implementation of the Relax-NG validation + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_RELAX_NG__ +#define __XML_RELAX_NG__ + +#include +#include +#include +#include +#include + +#ifdef LIBXML_RELAXNG_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlRelaxNG xmlRelaxNG; +typedef xmlRelaxNG *xmlRelaxNGPtr; + + +/** + * xmlRelaxNGValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from a Relax-NG validation + */ +typedef void (*xmlRelaxNGValidityErrorFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * xmlRelaxNGValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from a Relax-NG validation + */ +typedef void (*xmlRelaxNGValidityWarningFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * A schemas validation context + */ +typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt; +typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr; + +typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt; +typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr; + +/* + * xmlRelaxNGValidErr: + * + * List of possible Relax NG validation errors + */ +typedef enum { + XML_RELAXNG_OK = 0, + XML_RELAXNG_ERR_MEMORY, + XML_RELAXNG_ERR_TYPE, + XML_RELAXNG_ERR_TYPEVAL, + XML_RELAXNG_ERR_DUPID, + XML_RELAXNG_ERR_TYPECMP, + XML_RELAXNG_ERR_NOSTATE, + XML_RELAXNG_ERR_NODEFINE, + XML_RELAXNG_ERR_LISTEXTRA, + XML_RELAXNG_ERR_LISTEMPTY, + XML_RELAXNG_ERR_INTERNODATA, + XML_RELAXNG_ERR_INTERSEQ, + XML_RELAXNG_ERR_INTEREXTRA, + XML_RELAXNG_ERR_ELEMNAME, + XML_RELAXNG_ERR_ATTRNAME, + XML_RELAXNG_ERR_ELEMNONS, + XML_RELAXNG_ERR_ATTRNONS, + XML_RELAXNG_ERR_ELEMWRONGNS, + XML_RELAXNG_ERR_ATTRWRONGNS, + XML_RELAXNG_ERR_ELEMEXTRANS, + XML_RELAXNG_ERR_ATTREXTRANS, + XML_RELAXNG_ERR_ELEMNOTEMPTY, + XML_RELAXNG_ERR_NOELEM, + XML_RELAXNG_ERR_NOTELEM, + XML_RELAXNG_ERR_ATTRVALID, + XML_RELAXNG_ERR_CONTENTVALID, + XML_RELAXNG_ERR_EXTRACONTENT, + XML_RELAXNG_ERR_INVALIDATTR, + XML_RELAXNG_ERR_DATAELEM, + XML_RELAXNG_ERR_VALELEM, + XML_RELAXNG_ERR_LISTELEM, + XML_RELAXNG_ERR_DATATYPE, + XML_RELAXNG_ERR_VALUE, + XML_RELAXNG_ERR_LIST, + XML_RELAXNG_ERR_NOGRAMMAR, + XML_RELAXNG_ERR_EXTRADATA, + XML_RELAXNG_ERR_LACKDATA, + XML_RELAXNG_ERR_INTERNAL, + XML_RELAXNG_ERR_ELEMWRONG, + XML_RELAXNG_ERR_TEXTWRONG +} xmlRelaxNGValidErr; + +/* + * xmlRelaxNGParserFlags: + * + * List of possible Relax NG Parser flags + */ +typedef enum { + XML_RELAXNGP_NONE = 0, + XML_RELAXNGP_FREE_DOC = 1, + XML_RELAXNGP_CRNG = 2 +} xmlRelaxNGParserFlag; + +XMLPUBFUN int + xmlRelaxNGInitTypes (void); +XML_DEPRECATED +XMLPUBFUN void + xmlRelaxNGCleanupTypes (void); + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlRelaxNGParserCtxtPtr + xmlRelaxNGNewParserCtxt (const char *URL); +XMLPUBFUN xmlRelaxNGParserCtxtPtr + xmlRelaxNGNewMemParserCtxt (const char *buffer, + int size); +XMLPUBFUN xmlRelaxNGParserCtxtPtr + xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc); + +XMLPUBFUN int + xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt, + int flag); + +XMLPUBFUN void + xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt); +XMLPUBFUN void + xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc err, + xmlRelaxNGValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int + xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc *err, + xmlRelaxNGValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN void + xmlRelaxNGSetParserStructuredErrors( + xmlRelaxNGParserCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN void + xmlRelaxNGSetResourceLoader (xmlRelaxNGParserCtxtPtr ctxt, + xmlResourceLoader loader, + void *vctxt); +XMLPUBFUN xmlRelaxNGPtr + xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt); +XMLPUBFUN void + xmlRelaxNGFree (xmlRelaxNGPtr schema); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void + xmlRelaxNGDump (FILE *output, + xmlRelaxNGPtr schema); +XMLPUBFUN void + xmlRelaxNGDumpTree (FILE * output, + xmlRelaxNGPtr schema); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * Interfaces for validating + */ +XMLPUBFUN void + xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc err, + xmlRelaxNGValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int + xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc *err, + xmlRelaxNGValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN void + xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, void *ctx); +XMLPUBFUN xmlRelaxNGValidCtxtPtr + xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema); +XMLPUBFUN void + xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt); +XMLPUBFUN int + xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc); +/* + * Interfaces for progressive validation when possible + */ +XMLPUBFUN int + xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int + xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt, + const xmlChar *data, + int len); +XMLPUBFUN int + xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int + xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_RELAXNG_ENABLED */ + +#endif /* __XML_RELAX_NG__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/schemasInternals.h b/illumos-x86_64/usr/include/libxml2/libxml/schemasInternals.h new file mode 100644 index 00000000..e9d3b3c7 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/schemasInternals.h @@ -0,0 +1,959 @@ +/* + * Summary: internal interfaces for XML Schemas + * Description: internal interfaces for the XML Schemas handling + * and schema validity checking + * The Schemas development is a Work In Progress. + * Some of those interfaces are not guaranteed to be API or ABI stable ! + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_INTERNALS_H__ +#define __XML_SCHEMA_INTERNALS_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMAS_UNKNOWN = 0, + XML_SCHEMAS_STRING = 1, + XML_SCHEMAS_NORMSTRING = 2, + XML_SCHEMAS_DECIMAL = 3, + XML_SCHEMAS_TIME = 4, + XML_SCHEMAS_GDAY = 5, + XML_SCHEMAS_GMONTH = 6, + XML_SCHEMAS_GMONTHDAY = 7, + XML_SCHEMAS_GYEAR = 8, + XML_SCHEMAS_GYEARMONTH = 9, + XML_SCHEMAS_DATE = 10, + XML_SCHEMAS_DATETIME = 11, + XML_SCHEMAS_DURATION = 12, + XML_SCHEMAS_FLOAT = 13, + XML_SCHEMAS_DOUBLE = 14, + XML_SCHEMAS_BOOLEAN = 15, + XML_SCHEMAS_TOKEN = 16, + XML_SCHEMAS_LANGUAGE = 17, + XML_SCHEMAS_NMTOKEN = 18, + XML_SCHEMAS_NMTOKENS = 19, + XML_SCHEMAS_NAME = 20, + XML_SCHEMAS_QNAME = 21, + XML_SCHEMAS_NCNAME = 22, + XML_SCHEMAS_ID = 23, + XML_SCHEMAS_IDREF = 24, + XML_SCHEMAS_IDREFS = 25, + XML_SCHEMAS_ENTITY = 26, + XML_SCHEMAS_ENTITIES = 27, + XML_SCHEMAS_NOTATION = 28, + XML_SCHEMAS_ANYURI = 29, + XML_SCHEMAS_INTEGER = 30, + XML_SCHEMAS_NPINTEGER = 31, + XML_SCHEMAS_NINTEGER = 32, + XML_SCHEMAS_NNINTEGER = 33, + XML_SCHEMAS_PINTEGER = 34, + XML_SCHEMAS_INT = 35, + XML_SCHEMAS_UINT = 36, + XML_SCHEMAS_LONG = 37, + XML_SCHEMAS_ULONG = 38, + XML_SCHEMAS_SHORT = 39, + XML_SCHEMAS_USHORT = 40, + XML_SCHEMAS_BYTE = 41, + XML_SCHEMAS_UBYTE = 42, + XML_SCHEMAS_HEXBINARY = 43, + XML_SCHEMAS_BASE64BINARY = 44, + XML_SCHEMAS_ANYTYPE = 45, + XML_SCHEMAS_ANYSIMPLETYPE = 46 +} xmlSchemaValType; + +/* + * XML Schemas defines multiple type of types. + */ +typedef enum { + XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */ + XML_SCHEMA_TYPE_ANY, + XML_SCHEMA_TYPE_FACET, + XML_SCHEMA_TYPE_SIMPLE, + XML_SCHEMA_TYPE_COMPLEX, + XML_SCHEMA_TYPE_SEQUENCE = 6, + XML_SCHEMA_TYPE_CHOICE, + XML_SCHEMA_TYPE_ALL, + XML_SCHEMA_TYPE_SIMPLE_CONTENT, + XML_SCHEMA_TYPE_COMPLEX_CONTENT, + XML_SCHEMA_TYPE_UR, + XML_SCHEMA_TYPE_RESTRICTION, + XML_SCHEMA_TYPE_EXTENSION, + XML_SCHEMA_TYPE_ELEMENT, + XML_SCHEMA_TYPE_ATTRIBUTE, + XML_SCHEMA_TYPE_ATTRIBUTEGROUP, + XML_SCHEMA_TYPE_GROUP, + XML_SCHEMA_TYPE_NOTATION, + XML_SCHEMA_TYPE_LIST, + XML_SCHEMA_TYPE_UNION, + XML_SCHEMA_TYPE_ANY_ATTRIBUTE, + XML_SCHEMA_TYPE_IDC_UNIQUE, + XML_SCHEMA_TYPE_IDC_KEY, + XML_SCHEMA_TYPE_IDC_KEYREF, + XML_SCHEMA_TYPE_PARTICLE = 25, + XML_SCHEMA_TYPE_ATTRIBUTE_USE, + XML_SCHEMA_FACET_MININCLUSIVE = 1000, + XML_SCHEMA_FACET_MINEXCLUSIVE, + XML_SCHEMA_FACET_MAXINCLUSIVE, + XML_SCHEMA_FACET_MAXEXCLUSIVE, + XML_SCHEMA_FACET_TOTALDIGITS, + XML_SCHEMA_FACET_FRACTIONDIGITS, + XML_SCHEMA_FACET_PATTERN, + XML_SCHEMA_FACET_ENUMERATION, + XML_SCHEMA_FACET_WHITESPACE, + XML_SCHEMA_FACET_LENGTH, + XML_SCHEMA_FACET_MAXLENGTH, + XML_SCHEMA_FACET_MINLENGTH, + XML_SCHEMA_EXTRA_QNAMEREF = 2000, + XML_SCHEMA_EXTRA_ATTR_USE_PROHIB +} xmlSchemaTypeType; + +typedef enum { + XML_SCHEMA_CONTENT_UNKNOWN = 0, + XML_SCHEMA_CONTENT_EMPTY = 1, + XML_SCHEMA_CONTENT_ELEMENTS, + XML_SCHEMA_CONTENT_MIXED, + XML_SCHEMA_CONTENT_SIMPLE, + XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */ + XML_SCHEMA_CONTENT_BASIC, + XML_SCHEMA_CONTENT_ANY +} xmlSchemaContentType; + +typedef struct _xmlSchemaVal xmlSchemaVal; +typedef xmlSchemaVal *xmlSchemaValPtr; + +typedef struct _xmlSchemaType xmlSchemaType; +typedef xmlSchemaType *xmlSchemaTypePtr; + +typedef struct _xmlSchemaFacet xmlSchemaFacet; +typedef xmlSchemaFacet *xmlSchemaFacetPtr; + +/** + * Annotation + */ +typedef struct _xmlSchemaAnnot xmlSchemaAnnot; +typedef xmlSchemaAnnot *xmlSchemaAnnotPtr; +struct _xmlSchemaAnnot { + struct _xmlSchemaAnnot *next; + xmlNodePtr content; /* the annotation */ +}; + +/** + * XML_SCHEMAS_ANYATTR_SKIP: + * + * Skip unknown attribute from validation + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_SKIP 1 +/** + * XML_SCHEMAS_ANYATTR_LAX: + * + * Ignore validation non definition on attributes + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_LAX 2 +/** + * XML_SCHEMAS_ANYATTR_STRICT: + * + * Apply strict validation rules on attributes + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_STRICT 3 +/** + * XML_SCHEMAS_ANY_SKIP: + * + * Skip unknown attribute from validation + */ +#define XML_SCHEMAS_ANY_SKIP 1 +/** + * XML_SCHEMAS_ANY_LAX: + * + * Used by wildcards. + * Validate if type found, don't worry if not found + */ +#define XML_SCHEMAS_ANY_LAX 2 +/** + * XML_SCHEMAS_ANY_STRICT: + * + * Used by wildcards. + * Apply strict validation rules + */ +#define XML_SCHEMAS_ANY_STRICT 3 +/** + * XML_SCHEMAS_ATTR_USE_PROHIBITED: + * + * Used by wildcards. + * The attribute is prohibited. + */ +#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0 +/** + * XML_SCHEMAS_ATTR_USE_REQUIRED: + * + * The attribute is required. + */ +#define XML_SCHEMAS_ATTR_USE_REQUIRED 1 +/** + * XML_SCHEMAS_ATTR_USE_OPTIONAL: + * + * The attribute is optional. + */ +#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2 +/** + * XML_SCHEMAS_ATTR_GLOBAL: + * + * allow elements in no namespace + */ +#define XML_SCHEMAS_ATTR_GLOBAL 1 << 0 +/** + * XML_SCHEMAS_ATTR_NSDEFAULT: + * + * allow elements in no namespace + */ +#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7 +/** + * XML_SCHEMAS_ATTR_INTERNAL_RESOLVED: + * + * this is set when the "type" and "ref" references + * have been resolved. + */ +#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8 +/** + * XML_SCHEMAS_ATTR_FIXED: + * + * the attribute has a fixed value + */ +#define XML_SCHEMAS_ATTR_FIXED 1 << 9 + +/** + * xmlSchemaAttribute: + * An attribute definition. + */ + +typedef struct _xmlSchemaAttribute xmlSchemaAttribute; +typedef xmlSchemaAttribute *xmlSchemaAttributePtr; +struct _xmlSchemaAttribute { + xmlSchemaTypeType type; + struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */ + const xmlChar *name; /* the name of the declaration */ + const xmlChar *id; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + const xmlChar *typeName; /* the local name of the type definition */ + const xmlChar *typeNs; /* the ns URI of the type definition */ + xmlSchemaAnnotPtr annot; + + xmlSchemaTypePtr base; /* Deprecated; not used */ + int occurs; /* Deprecated; not used */ + const xmlChar *defValue; /* The initial value of the value constraint */ + xmlSchemaTypePtr subtypes; /* the type definition */ + xmlNodePtr node; + const xmlChar *targetNamespace; + int flags; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaValPtr defVal; /* The compiled value constraint */ + xmlSchemaAttributePtr refDecl; /* Deprecated; not used */ +}; + +/** + * xmlSchemaAttributeLink: + * Used to build a list of attribute uses on complexType definitions. + * WARNING: Deprecated; not used. + */ +typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink; +typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr; +struct _xmlSchemaAttributeLink { + struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */ + struct _xmlSchemaAttribute *attr;/* the linked attribute */ +}; + +/** + * XML_SCHEMAS_WILDCARD_COMPLETE: + * + * If the wildcard is complete. + */ +#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0 + +/** + * xmlSchemaCharValueLink: + * Used to build a list of namespaces on wildcards. + */ +typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs; +typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr; +struct _xmlSchemaWildcardNs { + struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */ + const xmlChar *value;/* the value */ +}; + +/** + * xmlSchemaWildcard. + * A wildcard. + */ +typedef struct _xmlSchemaWildcard xmlSchemaWildcard; +typedef xmlSchemaWildcard *xmlSchemaWildcardPtr; +struct _xmlSchemaWildcard { + xmlSchemaTypeType type; /* The kind of type */ + const xmlChar *id; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + int processContents; + int any; /* Indicates if the ns constraint is of ##any */ + xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */ + xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */ + int flags; +}; + +/** + * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED: + * + * The attribute wildcard has been built. + */ +#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0 +/** + * XML_SCHEMAS_ATTRGROUP_GLOBAL: + * + * The attribute group has been defined. + */ +#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1 +/** + * XML_SCHEMAS_ATTRGROUP_MARKED: + * + * Marks the attr group as marked; used for circular checks. + */ +#define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2 + +/** + * XML_SCHEMAS_ATTRGROUP_REDEFINED: + * + * The attr group was redefined. + */ +#define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3 +/** + * XML_SCHEMAS_ATTRGROUP_HAS_REFS: + * + * Whether this attr. group contains attr. group references. + */ +#define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4 + +/** + * An attribute group definition. + * + * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures + * must be kept similar + */ +typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup; +typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr; +struct _xmlSchemaAttributeGroup { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */ + const xmlChar *name; + const xmlChar *id; + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + + xmlSchemaAttributePtr attributes; /* Deprecated; not used */ + xmlNodePtr node; + int flags; + xmlSchemaWildcardPtr attributeWildcard; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */ + const xmlChar *targetNamespace; + void *attrUses; +}; + +/** + * xmlSchemaTypeLink: + * Used to build a list of types (e.g. member types of + * simpleType with variety "union"). + */ +typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink; +typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr; +struct _xmlSchemaTypeLink { + struct _xmlSchemaTypeLink *next;/* the next type link ... */ + xmlSchemaTypePtr type;/* the linked type */ +}; + +/** + * xmlSchemaFacetLink: + * Used to build a list of facets. + */ +typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink; +typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr; +struct _xmlSchemaFacetLink { + struct _xmlSchemaFacetLink *next;/* the next facet link ... */ + xmlSchemaFacetPtr facet;/* the linked facet */ +}; + +/** + * XML_SCHEMAS_TYPE_MIXED: + * + * the element content type is mixed + */ +#define XML_SCHEMAS_TYPE_MIXED 1 << 0 +/** + * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION: + * + * the simple or complex type has a derivation method of "extension". + */ +#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1 +/** + * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION: + * + * the simple or complex type has a derivation method of "restriction". + */ +#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2 +/** + * XML_SCHEMAS_TYPE_GLOBAL: + * + * the type is global + */ +#define XML_SCHEMAS_TYPE_GLOBAL 1 << 3 +/** + * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD: + * + * the complexType owns an attribute wildcard, i.e. + * it can be freed by the complexType + */ +#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4 /* Obsolete. */ +/** + * XML_SCHEMAS_TYPE_VARIETY_ABSENT: + * + * the simpleType has a variety of "absent". + * TODO: Actually not necessary :-/, since if + * none of the variety flags occur then it's + * automatically absent. + */ +#define XML_SCHEMAS_TYPE_VARIETY_ABSENT 1 << 5 +/** + * XML_SCHEMAS_TYPE_VARIETY_LIST: + * + * the simpleType has a variety of "list". + */ +#define XML_SCHEMAS_TYPE_VARIETY_LIST 1 << 6 +/** + * XML_SCHEMAS_TYPE_VARIETY_UNION: + * + * the simpleType has a variety of "union". + */ +#define XML_SCHEMAS_TYPE_VARIETY_UNION 1 << 7 +/** + * XML_SCHEMAS_TYPE_VARIETY_ATOMIC: + * + * the simpleType has a variety of "union". + */ +#define XML_SCHEMAS_TYPE_VARIETY_ATOMIC 1 << 8 +/** + * XML_SCHEMAS_TYPE_FINAL_EXTENSION: + * + * the complexType has a final of "extension". + */ +#define XML_SCHEMAS_TYPE_FINAL_EXTENSION 1 << 9 +/** + * XML_SCHEMAS_TYPE_FINAL_RESTRICTION: + * + * the simpleType/complexType has a final of "restriction". + */ +#define XML_SCHEMAS_TYPE_FINAL_RESTRICTION 1 << 10 +/** + * XML_SCHEMAS_TYPE_FINAL_LIST: + * + * the simpleType has a final of "list". + */ +#define XML_SCHEMAS_TYPE_FINAL_LIST 1 << 11 +/** + * XML_SCHEMAS_TYPE_FINAL_UNION: + * + * the simpleType has a final of "union". + */ +#define XML_SCHEMAS_TYPE_FINAL_UNION 1 << 12 +/** + * XML_SCHEMAS_TYPE_FINAL_DEFAULT: + * + * the simpleType has a final of "default". + */ +#define XML_SCHEMAS_TYPE_FINAL_DEFAULT 1 << 13 +/** + * XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE: + * + * Marks the item as a builtin primitive. + */ +#define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE 1 << 14 +/** + * XML_SCHEMAS_TYPE_MARKED: + * + * Marks the item as marked; used for circular checks. + */ +#define XML_SCHEMAS_TYPE_MARKED 1 << 16 +/** + * XML_SCHEMAS_TYPE_BLOCK_DEFAULT: + * + * the complexType did not specify 'block' so use the default of the + * item. + */ +#define XML_SCHEMAS_TYPE_BLOCK_DEFAULT 1 << 17 +/** + * XML_SCHEMAS_TYPE_BLOCK_EXTENSION: + * + * the complexType has a 'block' of "extension". + */ +#define XML_SCHEMAS_TYPE_BLOCK_EXTENSION 1 << 18 +/** + * XML_SCHEMAS_TYPE_BLOCK_RESTRICTION: + * + * the complexType has a 'block' of "restriction". + */ +#define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION 1 << 19 +/** + * XML_SCHEMAS_TYPE_ABSTRACT: + * + * the simple/complexType is abstract. + */ +#define XML_SCHEMAS_TYPE_ABSTRACT 1 << 20 +/** + * XML_SCHEMAS_TYPE_FACETSNEEDVALUE: + * + * indicates if the facets need a computed value + */ +#define XML_SCHEMAS_TYPE_FACETSNEEDVALUE 1 << 21 +/** + * XML_SCHEMAS_TYPE_INTERNAL_RESOLVED: + * + * indicates that the type was typefixed + */ +#define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED 1 << 22 +/** + * XML_SCHEMAS_TYPE_INTERNAL_INVALID: + * + * indicates that the type is invalid + */ +#define XML_SCHEMAS_TYPE_INTERNAL_INVALID 1 << 23 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE: + * + * a whitespace-facet value of "preserve" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE 1 << 24 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_REPLACE: + * + * a whitespace-facet value of "replace" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE 1 << 25 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE: + * + * a whitespace-facet value of "collapse" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE 1 << 26 +/** + * XML_SCHEMAS_TYPE_HAS_FACETS: + * + * has facets + */ +#define XML_SCHEMAS_TYPE_HAS_FACETS 1 << 27 +/** + * XML_SCHEMAS_TYPE_NORMVALUENEEDED: + * + * indicates if the facets (pattern) need a normalized value + */ +#define XML_SCHEMAS_TYPE_NORMVALUENEEDED 1 << 28 + +/** + * XML_SCHEMAS_TYPE_FIXUP_1: + * + * First stage of fixup was done. + */ +#define XML_SCHEMAS_TYPE_FIXUP_1 1 << 29 + +/** + * XML_SCHEMAS_TYPE_REDEFINED: + * + * The type was redefined. + */ +#define XML_SCHEMAS_TYPE_REDEFINED 1 << 30 +/** + * XML_SCHEMAS_TYPE_REDEFINING: + * + * The type redefines an other type. + */ +/* #define XML_SCHEMAS_TYPE_REDEFINING 1 << 31 */ + +/** + * _xmlSchemaType: + * + * Schemas type definition. + */ +struct _xmlSchemaType { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaType *next; /* the next type if in a sequence ... */ + const xmlChar *name; + const xmlChar *id ; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlSchemaTypePtr subtypes; + xmlSchemaAttributePtr attributes; /* Deprecated; not used */ + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + + int flags; + xmlSchemaContentType contentType; + const xmlChar *base; /* Base type's local name */ + const xmlChar *baseNs; /* Base type's target namespace */ + xmlSchemaTypePtr baseType; /* The base type component */ + xmlSchemaFacetPtr facets; /* Local facets */ + struct _xmlSchemaType *redef; /* Deprecated; not used */ + int recurse; /* Obsolete */ + xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */ + xmlSchemaWildcardPtr attributeWildcard; + int builtInType; /* Type of built-in types. */ + xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */ + xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */ + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types. + Could we use @subtypes for this? */ + xmlRegexpPtr contModel; /* Holds the automaton of the content model */ + const xmlChar *targetNamespace; + void *attrUses; +}; + +/* + * xmlSchemaElement: + * An element definition. + * + * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of + * structures must be kept similar + */ +/** + * XML_SCHEMAS_ELEM_NILLABLE: + * + * the element is nillable + */ +#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0 +/** + * XML_SCHEMAS_ELEM_GLOBAL: + * + * the element is global + */ +#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1 +/** + * XML_SCHEMAS_ELEM_DEFAULT: + * + * the element has a default value + */ +#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2 +/** + * XML_SCHEMAS_ELEM_FIXED: + * + * the element has a fixed value + */ +#define XML_SCHEMAS_ELEM_FIXED 1 << 3 +/** + * XML_SCHEMAS_ELEM_ABSTRACT: + * + * the element is abstract + */ +#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4 +/** + * XML_SCHEMAS_ELEM_TOPLEVEL: + * + * the element is top level + * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead + */ +#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5 +/** + * XML_SCHEMAS_ELEM_REF: + * + * the element is a reference to a type + */ +#define XML_SCHEMAS_ELEM_REF 1 << 6 +/** + * XML_SCHEMAS_ELEM_NSDEFAULT: + * + * allow elements in no namespace + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7 +/** + * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED: + * + * this is set when "type", "ref", "substitutionGroup" + * references have been resolved. + */ +#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8 + /** + * XML_SCHEMAS_ELEM_CIRCULAR: + * + * a helper flag for the search of circular references. + */ +#define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9 +/** + * XML_SCHEMAS_ELEM_BLOCK_ABSENT: + * + * the "block" attribute is absent + */ +#define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10 +/** + * XML_SCHEMAS_ELEM_BLOCK_EXTENSION: + * + * disallowed substitutions are absent + */ +#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11 +/** + * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION: + * + * disallowed substitutions: "restriction" + */ +#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12 +/** + * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION: + * + * disallowed substitutions: "substitution" + */ +#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13 +/** + * XML_SCHEMAS_ELEM_FINAL_ABSENT: + * + * substitution group exclusions are absent + */ +#define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14 +/** + * XML_SCHEMAS_ELEM_FINAL_EXTENSION: + * + * substitution group exclusions: "extension" + */ +#define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15 +/** + * XML_SCHEMAS_ELEM_FINAL_RESTRICTION: + * + * substitution group exclusions: "restriction" + */ +#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16 +/** + * XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD: + * + * the declaration is a substitution group head + */ +#define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD 1 << 17 +/** + * XML_SCHEMAS_ELEM_INTERNAL_CHECKED: + * + * this is set when the elem decl has been checked against + * all constraints + */ +#define XML_SCHEMAS_ELEM_INTERNAL_CHECKED 1 << 18 + +typedef struct _xmlSchemaElement xmlSchemaElement; +typedef xmlSchemaElement *xmlSchemaElementPtr; +struct _xmlSchemaElement { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaType *next; /* Not used? */ + const xmlChar *name; + const xmlChar *id; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlSchemaTypePtr subtypes; /* the type definition */ + xmlSchemaAttributePtr attributes; + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + + int flags; + const xmlChar *targetNamespace; + const xmlChar *namedType; + const xmlChar *namedTypeNs; + const xmlChar *substGroup; + const xmlChar *substGroupNs; + const xmlChar *scope; + const xmlChar *value; /* The original value of the value constraint. */ + struct _xmlSchemaElement *refDecl; /* This will now be used for the + substitution group affiliation */ + xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */ + xmlSchemaContentType contentType; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaValPtr defVal; /* The compiled value constraint. */ + void *idcs; /* The identity-constraint defs */ +}; + +/* + * XML_SCHEMAS_FACET_UNKNOWN: + * + * unknown facet handling + */ +#define XML_SCHEMAS_FACET_UNKNOWN 0 +/* + * XML_SCHEMAS_FACET_PRESERVE: + * + * preserve the type of the facet + */ +#define XML_SCHEMAS_FACET_PRESERVE 1 +/* + * XML_SCHEMAS_FACET_REPLACE: + * + * replace the type of the facet + */ +#define XML_SCHEMAS_FACET_REPLACE 2 +/* + * XML_SCHEMAS_FACET_COLLAPSE: + * + * collapse the types of the facet + */ +#define XML_SCHEMAS_FACET_COLLAPSE 3 +/** + * A facet definition. + */ +struct _xmlSchemaFacet { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */ + const xmlChar *value; /* The original value */ + const xmlChar *id; /* Obsolete */ + xmlSchemaAnnotPtr annot; + xmlNodePtr node; + int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */ + int whitespace; + xmlSchemaValPtr val; /* The compiled value */ + xmlRegexpPtr regexp; /* The regex for patterns */ +}; + +/** + * A notation definition. + */ +typedef struct _xmlSchemaNotation xmlSchemaNotation; +typedef xmlSchemaNotation *xmlSchemaNotationPtr; +struct _xmlSchemaNotation { + xmlSchemaTypeType type; /* The kind of type */ + const xmlChar *name; + xmlSchemaAnnotPtr annot; + const xmlChar *identifier; + const xmlChar *targetNamespace; +}; + +/* +* TODO: Actually all those flags used for the schema should sit +* on the schema parser context, since they are used only +* during parsing an XML schema document, and not available +* on the component level as per spec. +*/ +/** + * XML_SCHEMAS_QUALIF_ELEM: + * + * Reflects elementFormDefault == qualified in + * an XML schema document. + */ +#define XML_SCHEMAS_QUALIF_ELEM 1 << 0 +/** + * XML_SCHEMAS_QUALIF_ATTR: + * + * Reflects attributeFormDefault == qualified in + * an XML schema document. + */ +#define XML_SCHEMAS_QUALIF_ATTR 1 << 1 +/** + * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION: + * + * the schema has "extension" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2 +/** + * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION: + * + * the schema has "restriction" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3 +/** + * XML_SCHEMAS_FINAL_DEFAULT_LIST: + * + * the schema has "list" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4 +/** + * XML_SCHEMAS_FINAL_DEFAULT_UNION: + * + * the schema has "union" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION: + * + * the schema has "extension" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION: + * + * the schema has "restriction" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION: + * + * the schema has "substitution" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8 +/** + * XML_SCHEMAS_INCLUDING_CONVERT_NS: + * + * the schema is currently including an other schema with + * no target namespace. + */ +#define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9 +/** + * _xmlSchema: + * + * A Schemas definition + */ +struct _xmlSchema { + const xmlChar *name; /* schema name */ + const xmlChar *targetNamespace; /* the target namespace */ + const xmlChar *version; + const xmlChar *id; /* Obsolete */ + xmlDocPtr doc; + xmlSchemaAnnotPtr annot; + int flags; + + xmlHashTablePtr typeDecl; + xmlHashTablePtr attrDecl; + xmlHashTablePtr attrgrpDecl; + xmlHashTablePtr elemDecl; + xmlHashTablePtr notaDecl; + + xmlHashTablePtr schemasImports; + + void *_private; /* unused by the library for users or bindings */ + xmlHashTablePtr groupDecl; + xmlDictPtr dict; + void *includes; /* the includes, this is opaque for now */ + int preserve; /* whether to free the document */ + int counter; /* used to give anonymous components unique names */ + xmlHashTablePtr idcDef; /* All identity-constraint defs. */ + void *volatiles; /* Obsolete */ +}; + +XMLPUBFUN void xmlSchemaFreeType (xmlSchemaTypePtr type); +XMLPUBFUN void xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_INTERNALS_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/schematron.h b/illumos-x86_64/usr/include/libxml2/libxml/schematron.h new file mode 100644 index 00000000..8dd8d25c --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/schematron.h @@ -0,0 +1,143 @@ +/* + * Summary: XML Schematron implementation + * Description: interface to the XML Schematron validity checking. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMATRON_H__ +#define __XML_SCHEMATRON_H__ + +#include + +#ifdef LIBXML_SCHEMATRON_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */ + XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */ + XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */ + XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */ + XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */ + XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */ + XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */ +} xmlSchematronValidOptions; + +/** + * The schemas related types are kept internal + */ +typedef struct _xmlSchematron xmlSchematron; +typedef xmlSchematron *xmlSchematronPtr; + +/** + * xmlSchematronValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from a Schematron validation + */ +typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...); + +/** + * xmlSchematronValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from a Schematron validation + */ +typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...); + +/** + * A schemas validation context + */ +typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt; +typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr; + +typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt; +typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr; + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlSchematronParserCtxtPtr + xmlSchematronNewParserCtxt (const char *URL); +XMLPUBFUN xmlSchematronParserCtxtPtr + xmlSchematronNewMemParserCtxt(const char *buffer, + int size); +XMLPUBFUN xmlSchematronParserCtxtPtr + xmlSchematronNewDocParserCtxt(xmlDocPtr doc); +XMLPUBFUN void + xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt); +/***** +XMLPUBFUN void + xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt, + xmlSchematronValidityErrorFunc err, + xmlSchematronValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int + xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt, + xmlSchematronValidityErrorFunc * err, + xmlSchematronValidityWarningFunc * warn, + void **ctx); +XMLPUBFUN int + xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt); + *****/ +XMLPUBFUN xmlSchematronPtr + xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt); +XMLPUBFUN void + xmlSchematronFree (xmlSchematronPtr schema); +/* + * Interfaces for validating + */ +XMLPUBFUN void + xmlSchematronSetValidStructuredErrors( + xmlSchematronValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +/****** +XMLPUBFUN void + xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt, + xmlSchematronValidityErrorFunc err, + xmlSchematronValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int + xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt, + xmlSchematronValidityErrorFunc *err, + xmlSchematronValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN int + xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt, + int options); +XMLPUBFUN int + xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt); +XMLPUBFUN int + xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt, + xmlNodePtr elem); + *******/ + +XMLPUBFUN xmlSchematronValidCtxtPtr + xmlSchematronNewValidCtxt (xmlSchematronPtr schema, + int options); +XMLPUBFUN void + xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt); +XMLPUBFUN int + xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt, + xmlDocPtr instance); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMATRON_ENABLED */ +#endif /* __XML_SCHEMATRON_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/threads.h b/illumos-x86_64/usr/include/libxml2/libxml/threads.h new file mode 100644 index 00000000..ec2b16b1 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/threads.h @@ -0,0 +1,81 @@ +/** + * Summary: interfaces for thread handling + * Description: set of generic threading related routines + * should work with pthreads, Windows native or TLS threads + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_THREADS_H__ +#define __XML_THREADS_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * xmlMutex are a simple mutual exception locks. + */ +typedef struct _xmlMutex xmlMutex; +typedef xmlMutex *xmlMutexPtr; + +/* + * xmlRMutex are reentrant mutual exception locks. + */ +typedef struct _xmlRMutex xmlRMutex; +typedef xmlRMutex *xmlRMutexPtr; + +XMLPUBFUN int + xmlCheckThreadLocalStorage(void); + +XMLPUBFUN xmlMutexPtr + xmlNewMutex (void); +XMLPUBFUN void + xmlMutexLock (xmlMutexPtr tok); +XMLPUBFUN void + xmlMutexUnlock (xmlMutexPtr tok); +XMLPUBFUN void + xmlFreeMutex (xmlMutexPtr tok); + +XMLPUBFUN xmlRMutexPtr + xmlNewRMutex (void); +XMLPUBFUN void + xmlRMutexLock (xmlRMutexPtr tok); +XMLPUBFUN void + xmlRMutexUnlock (xmlRMutexPtr tok); +XMLPUBFUN void + xmlFreeRMutex (xmlRMutexPtr tok); + +/* + * Library wide APIs. + */ +XML_DEPRECATED +XMLPUBFUN void + xmlInitThreads (void); +XMLPUBFUN void + xmlLockLibrary (void); +XMLPUBFUN void + xmlUnlockLibrary(void); +XML_DEPRECATED +XMLPUBFUN void + xmlCleanupThreads(void); + +/** DOC_DISABLE */ +#if defined(LIBXML_THREAD_ENABLED) && defined(_WIN32) && \ + defined(LIBXML_STATIC_FOR_DLL) +int +xmlDllMain(void *hinstDLL, unsigned long fdwReason, + void *lpvReserved); +#endif +/** DOC_ENABLE */ + +#ifdef __cplusplus +} +#endif + + +#endif /* __XML_THREADS_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/tree.h b/illumos-x86_64/usr/include/libxml2/libxml/tree.h new file mode 100644 index 00000000..e5a8fb70 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/tree.h @@ -0,0 +1,1326 @@ +/* + * Summary: interfaces for tree manipulation + * Description: this module describes the structures found in an tree resulting + * from an XML or HTML parsing, as well as the API provided for + * various processing on that tree + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef XML_TREE_INTERNALS + +/* + * Emulate circular dependency for backward compatibility + */ +#include + +#else /* XML_TREE_INTERNALS */ + +#ifndef __XML_TREE_H__ +#define __XML_TREE_H__ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Backward compatibility + */ +#define xmlBufferAllocScheme XML_BUFFER_ALLOC_EXACT +#define xmlDefaultBufferSize 4096 + +/* + * Some of the basic types pointer to structures: + */ +/* xmlIO.h */ +typedef struct _xmlParserInputBuffer xmlParserInputBuffer; +typedef xmlParserInputBuffer *xmlParserInputBufferPtr; + +typedef struct _xmlOutputBuffer xmlOutputBuffer; +typedef xmlOutputBuffer *xmlOutputBufferPtr; + +/* parser.h */ +typedef struct _xmlParserInput xmlParserInput; +typedef xmlParserInput *xmlParserInputPtr; + +typedef struct _xmlParserCtxt xmlParserCtxt; +typedef xmlParserCtxt *xmlParserCtxtPtr; + +typedef struct _xmlSAXLocator xmlSAXLocator; +typedef xmlSAXLocator *xmlSAXLocatorPtr; + +typedef struct _xmlSAXHandler xmlSAXHandler; +typedef xmlSAXHandler *xmlSAXHandlerPtr; + +/* entities.h */ +typedef struct _xmlEntity xmlEntity; +typedef xmlEntity *xmlEntityPtr; + +/** + * LIBXML_NAMESPACE_DICT: + * + * Defines experimental behaviour: + * 1) xmlNs gets an additional field @context (a xmlDoc) + * 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc. + */ +/* #define LIBXML_NAMESPACE_DICT */ + +/** + * xmlBufferAllocationScheme: + * + * A buffer allocation scheme can be defined to either match exactly the + * need or double it's allocated size each time it is found too small. + */ + +typedef enum { + XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */ + XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */ + XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer, deprecated */ + XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */ + XML_BUFFER_ALLOC_HYBRID, /* exact up to a threshold, and doubleit thereafter */ + XML_BUFFER_ALLOC_BOUNDED /* limit the upper size of the buffer */ +} xmlBufferAllocationScheme; + +/** + * xmlBuffer: + * + * A buffer structure, this old construct is limited to 2GB and + * is being deprecated, use API with xmlBuf instead + */ +typedef struct _xmlBuffer xmlBuffer; +typedef xmlBuffer *xmlBufferPtr; +struct _xmlBuffer { + /* The buffer content UTF8 */ + xmlChar *content XML_DEPRECATED_MEMBER; + /* The buffer size used */ + unsigned int use XML_DEPRECATED_MEMBER; + /* The buffer size */ + unsigned int size XML_DEPRECATED_MEMBER; + /* The realloc method */ + xmlBufferAllocationScheme alloc XML_DEPRECATED_MEMBER; + /* in IO mode we may have a different base */ + xmlChar *contentIO XML_DEPRECATED_MEMBER; +}; + +/** + * xmlBuf: + * + * A buffer structure, new one, the actual structure internals are not public + */ + +typedef struct _xmlBuf xmlBuf; + +/** + * xmlBufPtr: + * + * A pointer to a buffer structure, the actual structure internals are not + * public + */ + +typedef xmlBuf *xmlBufPtr; + +/* + * A few public routines for xmlBuf. As those are expected to be used + * mostly internally the bulk of the routines are internal in buf.h + */ +XMLPUBFUN xmlChar* xmlBufContent (const xmlBuf* buf); +XMLPUBFUN xmlChar* xmlBufEnd (xmlBufPtr buf); +XMLPUBFUN size_t xmlBufUse (const xmlBufPtr buf); +XMLPUBFUN size_t xmlBufShrink (xmlBufPtr buf, size_t len); + +/* + * LIBXML2_NEW_BUFFER: + * + * Macro used to express that the API use the new buffers for + * xmlParserInputBuffer and xmlOutputBuffer. The change was + * introduced in 2.9.0. + */ +#define LIBXML2_NEW_BUFFER + +/** + * XML_XML_NAMESPACE: + * + * This is the namespace for the special xml: prefix predefined in the + * XML Namespace specification. + */ +#define XML_XML_NAMESPACE \ + (const xmlChar *) "http://www.w3.org/XML/1998/namespace" + +/** + * XML_XML_ID: + * + * This is the name for the special xml:id attribute + */ +#define XML_XML_ID (const xmlChar *) "xml:id" + +/* + * The different element types carried by an XML tree. + * + * NOTE: This is synchronized with DOM Level1 values + * See http://www.w3.org/TR/REC-DOM-Level-1/ + * + * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should + * be deprecated to use an XML_DTD_NODE. + */ +typedef enum { + XML_ELEMENT_NODE= 1, + XML_ATTRIBUTE_NODE= 2, + XML_TEXT_NODE= 3, + XML_CDATA_SECTION_NODE= 4, + XML_ENTITY_REF_NODE= 5, + XML_ENTITY_NODE= 6, /* unused */ + XML_PI_NODE= 7, + XML_COMMENT_NODE= 8, + XML_DOCUMENT_NODE= 9, + XML_DOCUMENT_TYPE_NODE= 10, /* unused */ + XML_DOCUMENT_FRAG_NODE= 11, + XML_NOTATION_NODE= 12, /* unused */ + XML_HTML_DOCUMENT_NODE= 13, + XML_DTD_NODE= 14, + XML_ELEMENT_DECL= 15, + XML_ATTRIBUTE_DECL= 16, + XML_ENTITY_DECL= 17, + XML_NAMESPACE_DECL= 18, + XML_XINCLUDE_START= 19, + XML_XINCLUDE_END= 20 + /* XML_DOCB_DOCUMENT_NODE= 21 */ /* removed */ +} xmlElementType; + +/** DOC_DISABLE */ +/* For backward compatibility */ +#define XML_DOCB_DOCUMENT_NODE 21 +/** DOC_ENABLE */ + +/** + * xmlNotation: + * + * A DTD Notation definition. + */ + +typedef struct _xmlNotation xmlNotation; +typedef xmlNotation *xmlNotationPtr; +struct _xmlNotation { + const xmlChar *name; /* Notation name */ + const xmlChar *PublicID; /* Public identifier, if any */ + const xmlChar *SystemID; /* System identifier, if any */ +}; + +/** + * xmlAttributeType: + * + * A DTD Attribute type definition. + */ + +typedef enum { + XML_ATTRIBUTE_CDATA = 1, + XML_ATTRIBUTE_ID, + XML_ATTRIBUTE_IDREF , + XML_ATTRIBUTE_IDREFS, + XML_ATTRIBUTE_ENTITY, + XML_ATTRIBUTE_ENTITIES, + XML_ATTRIBUTE_NMTOKEN, + XML_ATTRIBUTE_NMTOKENS, + XML_ATTRIBUTE_ENUMERATION, + XML_ATTRIBUTE_NOTATION +} xmlAttributeType; + +/** + * xmlAttributeDefault: + * + * A DTD Attribute default definition. + */ + +typedef enum { + XML_ATTRIBUTE_NONE = 1, + XML_ATTRIBUTE_REQUIRED, + XML_ATTRIBUTE_IMPLIED, + XML_ATTRIBUTE_FIXED +} xmlAttributeDefault; + +/** + * xmlEnumeration: + * + * List structure used when there is an enumeration in DTDs. + */ + +typedef struct _xmlEnumeration xmlEnumeration; +typedef xmlEnumeration *xmlEnumerationPtr; +struct _xmlEnumeration { + struct _xmlEnumeration *next; /* next one */ + const xmlChar *name; /* Enumeration name */ +}; + +/** + * xmlAttribute: + * + * An Attribute declaration in a DTD. + */ + +typedef struct _xmlAttribute xmlAttribute; +typedef xmlAttribute *xmlAttributePtr; +struct _xmlAttribute { + void *_private; /* application data */ + xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */ + const xmlChar *name; /* Attribute name */ + struct _xmlNode *children; /* NULL */ + struct _xmlNode *last; /* NULL */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + struct _xmlAttribute *nexth; /* next in hash table */ + xmlAttributeType atype; /* The attribute type */ + xmlAttributeDefault def; /* the default */ + const xmlChar *defaultValue; /* or the default value */ + xmlEnumerationPtr tree; /* or the enumeration tree if any */ + const xmlChar *prefix; /* the namespace prefix if any */ + const xmlChar *elem; /* Element holding the attribute */ +}; + +/** + * xmlElementContentType: + * + * Possible definitions of element content types. + */ +typedef enum { + XML_ELEMENT_CONTENT_PCDATA = 1, + XML_ELEMENT_CONTENT_ELEMENT, + XML_ELEMENT_CONTENT_SEQ, + XML_ELEMENT_CONTENT_OR +} xmlElementContentType; + +/** + * xmlElementContentOccur: + * + * Possible definitions of element content occurrences. + */ +typedef enum { + XML_ELEMENT_CONTENT_ONCE = 1, + XML_ELEMENT_CONTENT_OPT, + XML_ELEMENT_CONTENT_MULT, + XML_ELEMENT_CONTENT_PLUS +} xmlElementContentOccur; + +/** + * xmlElementContent: + * + * An XML Element content as stored after parsing an element definition + * in a DTD. + */ + +typedef struct _xmlElementContent xmlElementContent; +typedef xmlElementContent *xmlElementContentPtr; +struct _xmlElementContent { + xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ + xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ + const xmlChar *name; /* Element name */ + struct _xmlElementContent *c1; /* first child */ + struct _xmlElementContent *c2; /* second child */ + struct _xmlElementContent *parent; /* parent */ + const xmlChar *prefix; /* Namespace prefix */ +}; + +/** + * xmlElementTypeVal: + * + * The different possibilities for an element content type. + */ + +typedef enum { + XML_ELEMENT_TYPE_UNDEFINED = 0, + XML_ELEMENT_TYPE_EMPTY = 1, + XML_ELEMENT_TYPE_ANY, + XML_ELEMENT_TYPE_MIXED, + XML_ELEMENT_TYPE_ELEMENT +} xmlElementTypeVal; + +/** + * xmlElement: + * + * An XML Element declaration from a DTD. + */ + +typedef struct _xmlElement xmlElement; +typedef xmlElement *xmlElementPtr; +struct _xmlElement { + void *_private; /* application data */ + xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */ + const xmlChar *name; /* Element name */ + struct _xmlNode *children; /* NULL */ + struct _xmlNode *last; /* NULL */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + xmlElementTypeVal etype; /* The type */ + xmlElementContentPtr content; /* the allowed element content */ + xmlAttributePtr attributes; /* List of the declared attributes */ + const xmlChar *prefix; /* the namespace prefix if any */ +#ifdef LIBXML_REGEXP_ENABLED + xmlRegexpPtr contModel; /* the validating regexp */ +#else + void *contModel; +#endif +}; + + +/** + * XML_LOCAL_NAMESPACE: + * + * A namespace declaration node. + */ +#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL +typedef xmlElementType xmlNsType; + +/** + * xmlNs: + * + * An XML namespace. + * Note that prefix == NULL is valid, it defines the default namespace + * within the subtree (until overridden). + * + * xmlNsType is unified with xmlElementType. + */ + +typedef struct _xmlNs xmlNs; +typedef xmlNs *xmlNsPtr; +struct _xmlNs { + struct _xmlNs *next; /* next Ns link for this node */ + xmlNsType type; /* global or local */ + const xmlChar *href; /* URL for the namespace */ + const xmlChar *prefix; /* prefix for the namespace */ + void *_private; /* application data */ + struct _xmlDoc *context; /* normally an xmlDoc */ +}; + +/** + * xmlDtd: + * + * An XML DTD, as defined by parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + /* End of common part */ + void *notations; /* Hash table for notations if any */ + void *elements; /* Hash table for elements if any */ + void *attributes; /* Hash table for attributes if any */ + void *entities; /* Hash table for entities if any */ + const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ + const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ + void *pentities; /* Hash table for param entities if any */ +}; + +/** + * xmlAttr: + * + * An attribute on an XML node. + */ +typedef struct _xmlAttr xmlAttr; +typedef xmlAttr *xmlAttrPtr; +struct _xmlAttr { + void *_private; /* application data */ + xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */ + const xmlChar *name; /* the name of the property */ + struct _xmlNode *children; /* the value of the property */ + struct _xmlNode *last; /* NULL */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlAttr *next; /* next sibling link */ + struct _xmlAttr *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + xmlNs *ns; /* pointer to the associated namespace */ + xmlAttributeType atype; /* the attribute type if validating */ + void *psvi; /* for type/PSVI information */ + struct _xmlID *id; /* the ID struct */ +}; + +/** + * xmlID: + * + * An XML ID instance. + */ + +typedef struct _xmlID xmlID; +typedef xmlID *xmlIDPtr; +struct _xmlID { + struct _xmlID *next; /* next ID */ + const xmlChar *value; /* The ID name */ + xmlAttrPtr attr; /* The attribute holding it */ + const xmlChar *name; /* The attribute if attr is not available */ + int lineno; /* The line number if attr is not available */ + struct _xmlDoc *doc; /* The document holding the ID */ +}; + +/** + * xmlRef: + * + * An XML IDREF instance. + */ + +typedef struct _xmlRef xmlRef; +typedef xmlRef *xmlRefPtr; +struct _xmlRef { + struct _xmlRef *next; /* next Ref */ + const xmlChar *value; /* The Ref name */ + xmlAttrPtr attr; /* The attribute holding it */ + const xmlChar *name; /* The attribute if attr is not available */ + int lineno; /* The line number if attr is not available */ +}; + +/** + * xmlNode: + * + * A node in an XML tree. + */ +typedef struct _xmlNode xmlNode; +typedef xmlNode *xmlNodePtr; +struct _xmlNode { + void *_private; /* application data */ + xmlElementType type; /* type number, must be second ! */ + const xmlChar *name; /* the name of the node, or the entity */ + struct _xmlNode *children; /* parent->childs link */ + struct _xmlNode *last; /* last child link */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + /* End of common part */ + xmlNs *ns; /* pointer to the associated namespace */ + xmlChar *content; /* the content */ + struct _xmlAttr *properties;/* properties list */ + xmlNs *nsDef; /* namespace definitions on this node */ + void *psvi; /* for type/PSVI information */ + unsigned short line; /* line number */ + unsigned short extra; /* extra data for XPath/XSLT */ +}; + +/** + * XML_GET_CONTENT: + * + * Macro to extract the content pointer of a node. + */ +#define XML_GET_CONTENT(n) \ + ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content) + +/** + * XML_GET_LINE: + * + * Macro to extract the line number of an element node. + */ +#define XML_GET_LINE(n) \ + (xmlGetLineNo(n)) + +/** + * xmlDocProperty + * + * Set of properties of the document as found by the parser + * Some of them are linked to similarly named xmlParserOption + */ +typedef enum { + XML_DOC_WELLFORMED = 1<<0, /* document is XML well formed */ + XML_DOC_NSVALID = 1<<1, /* document is Namespace valid */ + XML_DOC_OLD10 = 1<<2, /* parsed with old XML-1.0 parser */ + XML_DOC_DTDVALID = 1<<3, /* DTD validation was successful */ + XML_DOC_XINCLUDE = 1<<4, /* XInclude substitution was done */ + XML_DOC_USERBUILT = 1<<5, /* Document was built using the API + and not by parsing an instance */ + XML_DOC_INTERNAL = 1<<6, /* built for internal processing */ + XML_DOC_HTML = 1<<7 /* parsed or built HTML document */ +} xmlDocProperties; + +/** + * xmlDoc: + * + * An XML document. + */ +typedef struct _xmlDoc xmlDoc; +typedef xmlDoc *xmlDocPtr; +struct _xmlDoc { + void *_private; /* application data */ + xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ + char *name; /* name/filename/URI of the document */ + struct _xmlNode *children; /* the document tree */ + struct _xmlNode *last; /* last child link */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* autoreference to itself */ + + /* End of common part */ + int compression;/* level of zlib compression */ + int standalone; /* standalone document (no external refs) + 1 if standalone="yes" + 0 if standalone="no" + -1 if there is no XML declaration + -2 if there is an XML declaration, but no + standalone attribute was specified */ + struct _xmlDtd *intSubset; /* the document internal subset */ + struct _xmlDtd *extSubset; /* the document external subset */ + struct _xmlNs *oldNs; /* Global namespace, the old way */ + const xmlChar *version; /* the XML version string */ + const xmlChar *encoding; /* actual encoding, if any */ + void *ids; /* Hash table for ID attributes if any */ + void *refs; /* Hash table for IDREFs attributes if any */ + const xmlChar *URL; /* The URI for that document */ + int charset; /* unused */ + struct _xmlDict *dict; /* dict used to allocate names or NULL */ + void *psvi; /* for type/PSVI information */ + int parseFlags; /* set of xmlParserOption used to parse the + document */ + int properties; /* set of xmlDocProperties for this document + set at the end of parsing */ +}; + + +typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt; +typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr; + +/** + * xmlDOMWrapAcquireNsFunction: + * @ctxt: a DOM wrapper context + * @node: the context node (element or attribute) + * @nsName: the requested namespace name + * @nsPrefix: the requested namespace prefix + * + * A function called to acquire namespaces (xmlNs) from the wrapper. + * + * Returns an xmlNsPtr or NULL in case of an error. + */ +typedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt, + xmlNodePtr node, + const xmlChar *nsName, + const xmlChar *nsPrefix); + +/** + * xmlDOMWrapCtxt: + * + * Context for DOM wrapper-operations. + */ +struct _xmlDOMWrapCtxt { + void * _private; + /* + * The type of this context, just in case we need specialized + * contexts in the future. + */ + int type; + /* + * Internal namespace map used for various operations. + */ + void * namespaceMap; + /* + * Use this one to acquire an xmlNsPtr intended for node->ns. + * (Note that this is not intended for elem->nsDef). + */ + xmlDOMWrapAcquireNsFunction getNsForNodeFunc; +}; + +/** + * xmlRegisterNodeFunc: + * @node: the current node + * + * Signature for the registration callback of a created node + */ +typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node); + +/** + * xmlDeregisterNodeFunc: + * @node: the current node + * + * Signature for the deregistration callback of a discarded node + */ +typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node); + +/** + * xmlChildrenNode: + * + * Macro for compatibility naming layer with libxml1. Maps + * to "children." + */ +#ifndef xmlChildrenNode +#define xmlChildrenNode children +#endif + +/** + * xmlRootNode: + * + * Macro for compatibility naming layer with libxml1. Maps + * to "children". + */ +#ifndef xmlRootNode +#define xmlRootNode children +#endif + +/* + * Variables. + */ + +/** DOC_DISABLE */ +XML_DEPRECATED +XMLPUBFUN xmlRegisterNodeFunc *__xmlRegisterNodeDefaultValue(void); +XML_DEPRECATED +XMLPUBFUN xmlDeregisterNodeFunc *__xmlDeregisterNodeDefaultValue(void); + +#ifndef XML_GLOBALS_NO_REDEFINITION + #define xmlRegisterNodeDefaultValue \ + (*__xmlRegisterNodeDefaultValue()) + #define xmlDeregisterNodeDefaultValue \ + (*__xmlDeregisterNodeDefaultValue()) +#endif +/** DOC_ENABLE */ + +/* + * Some helper functions + */ +XMLPUBFUN int + xmlValidateNCName (const xmlChar *value, + int space); + +XMLPUBFUN int + xmlValidateQName (const xmlChar *value, + int space); +XMLPUBFUN int + xmlValidateName (const xmlChar *value, + int space); +XMLPUBFUN int + xmlValidateNMToken (const xmlChar *value, + int space); + +XMLPUBFUN xmlChar * + xmlBuildQName (const xmlChar *ncname, + const xmlChar *prefix, + xmlChar *memory, + int len); +XMLPUBFUN xmlChar * + xmlSplitQName2 (const xmlChar *name, + xmlChar **prefix); +XMLPUBFUN const xmlChar * + xmlSplitQName3 (const xmlChar *name, + int *len); + +/* + * Handling Buffers, the old ones see @xmlBuf for the new ones. + */ + +XML_DEPRECATED +XMLPUBFUN void + xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme); +XML_DEPRECATED +XMLPUBFUN xmlBufferAllocationScheme + xmlGetBufferAllocationScheme(void); + +XMLPUBFUN xmlBufferPtr + xmlBufferCreate (void); +XMLPUBFUN xmlBufferPtr + xmlBufferCreateSize (size_t size); +XMLPUBFUN xmlBufferPtr + xmlBufferCreateStatic (void *mem, + size_t size); +XML_DEPRECATED +XMLPUBFUN int + xmlBufferResize (xmlBufferPtr buf, + unsigned int size); +XMLPUBFUN void + xmlBufferFree (xmlBufferPtr buf); +XMLPUBFUN int + xmlBufferDump (FILE *file, + xmlBufferPtr buf); +XMLPUBFUN int + xmlBufferAdd (xmlBufferPtr buf, + const xmlChar *str, + int len); +XMLPUBFUN int + xmlBufferAddHead (xmlBufferPtr buf, + const xmlChar *str, + int len); +XMLPUBFUN int + xmlBufferCat (xmlBufferPtr buf, + const xmlChar *str); +XMLPUBFUN int + xmlBufferCCat (xmlBufferPtr buf, + const char *str); +XML_DEPRECATED +XMLPUBFUN int + xmlBufferShrink (xmlBufferPtr buf, + unsigned int len); +XML_DEPRECATED +XMLPUBFUN int + xmlBufferGrow (xmlBufferPtr buf, + unsigned int len); +XMLPUBFUN void + xmlBufferEmpty (xmlBufferPtr buf); +XMLPUBFUN const xmlChar* + xmlBufferContent (const xmlBuffer *buf); +XMLPUBFUN xmlChar* + xmlBufferDetach (xmlBufferPtr buf); +XMLPUBFUN void + xmlBufferSetAllocationScheme(xmlBufferPtr buf, + xmlBufferAllocationScheme scheme); +XMLPUBFUN int + xmlBufferLength (const xmlBuffer *buf); + +/* + * Creating/freeing new structures. + */ +XMLPUBFUN xmlDtdPtr + xmlCreateIntSubset (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr + xmlNewDtd (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr + xmlGetIntSubset (const xmlDoc *doc); +XMLPUBFUN void + xmlFreeDtd (xmlDtdPtr cur); +XMLPUBFUN xmlNsPtr + xmlNewNs (xmlNodePtr node, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void + xmlFreeNs (xmlNsPtr cur); +XMLPUBFUN void + xmlFreeNsList (xmlNsPtr cur); +XMLPUBFUN xmlDocPtr + xmlNewDoc (const xmlChar *version); +XMLPUBFUN void + xmlFreeDoc (xmlDocPtr cur); +XMLPUBFUN xmlAttrPtr + xmlNewDocProp (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr + xmlNewProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr + xmlNewNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr + xmlNewNsPropEatName (xmlNodePtr node, + xmlNsPtr ns, + xmlChar *name, + const xmlChar *value); +XMLPUBFUN void + xmlFreePropList (xmlAttrPtr cur); +XMLPUBFUN void + xmlFreeProp (xmlAttrPtr cur); +XMLPUBFUN xmlAttrPtr + xmlCopyProp (xmlNodePtr target, + xmlAttrPtr cur); +XMLPUBFUN xmlAttrPtr + xmlCopyPropList (xmlNodePtr target, + xmlAttrPtr cur); +XMLPUBFUN xmlDtdPtr + xmlCopyDtd (xmlDtdPtr dtd); +XMLPUBFUN xmlDocPtr + xmlCopyDoc (xmlDocPtr doc, + int recursive); +/* + * Creating new nodes. + */ +XMLPUBFUN xmlNodePtr + xmlNewDocNode (xmlDocPtr doc, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewDocNodeEatName (xmlDocPtr doc, + xmlNsPtr ns, + xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewNode (xmlNsPtr ns, + const xmlChar *name); +XMLPUBFUN xmlNodePtr + xmlNewNodeEatName (xmlNsPtr ns, + xmlChar *name); +XMLPUBFUN xmlNodePtr + xmlNewChild (xmlNodePtr parent, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewDocText (const xmlDoc *doc, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewText (const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewDocPI (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewPI (const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewDocTextLen (xmlDocPtr doc, + const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr + xmlNewTextLen (const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr + xmlNewDocComment (xmlDocPtr doc, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewComment (const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewCDataBlock (xmlDocPtr doc, + const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr + xmlNewCharRef (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlNodePtr + xmlNewReference (const xmlDoc *doc, + const xmlChar *name); +XMLPUBFUN xmlNodePtr + xmlCopyNode (xmlNodePtr node, + int recursive); +XMLPUBFUN xmlNodePtr + xmlDocCopyNode (xmlNodePtr node, + xmlDocPtr doc, + int recursive); +XMLPUBFUN xmlNodePtr + xmlDocCopyNodeList (xmlDocPtr doc, + xmlNodePtr node); +XMLPUBFUN xmlNodePtr + xmlCopyNodeList (xmlNodePtr node); +XMLPUBFUN xmlNodePtr + xmlNewTextChild (xmlNodePtr parent, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewDocRawNode (xmlDocPtr doc, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr + xmlNewDocFragment (xmlDocPtr doc); + +/* + * Navigating. + */ +XMLPUBFUN long + xmlGetLineNo (const xmlNode *node); +XMLPUBFUN xmlChar * + xmlGetNodePath (const xmlNode *node); +XMLPUBFUN xmlNodePtr + xmlDocGetRootElement (const xmlDoc *doc); +XMLPUBFUN xmlNodePtr + xmlGetLastChild (const xmlNode *parent); +XMLPUBFUN int + xmlNodeIsText (const xmlNode *node); +XMLPUBFUN int + xmlIsBlankNode (const xmlNode *node); + +/* + * Changing the structure. + */ +XMLPUBFUN xmlNodePtr + xmlDocSetRootElement (xmlDocPtr doc, + xmlNodePtr root); +XMLPUBFUN void + xmlNodeSetName (xmlNodePtr cur, + const xmlChar *name); +XMLPUBFUN xmlNodePtr + xmlAddChild (xmlNodePtr parent, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr + xmlAddChildList (xmlNodePtr parent, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr + xmlReplaceNode (xmlNodePtr old, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr + xmlAddPrevSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN xmlNodePtr + xmlAddSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN xmlNodePtr + xmlAddNextSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN void + xmlUnlinkNode (xmlNodePtr cur); +XMLPUBFUN xmlNodePtr + xmlTextMerge (xmlNodePtr first, + xmlNodePtr second); +XMLPUBFUN int + xmlTextConcat (xmlNodePtr node, + const xmlChar *content, + int len); +XMLPUBFUN void + xmlFreeNodeList (xmlNodePtr cur); +XMLPUBFUN void + xmlFreeNode (xmlNodePtr cur); +XMLPUBFUN int + xmlSetTreeDoc (xmlNodePtr tree, + xmlDocPtr doc); +XMLPUBFUN int + xmlSetListDoc (xmlNodePtr list, + xmlDocPtr doc); +/* + * Namespaces. + */ +XMLPUBFUN xmlNsPtr + xmlSearchNs (xmlDocPtr doc, + xmlNodePtr node, + const xmlChar *nameSpace); +XMLPUBFUN xmlNsPtr + xmlSearchNsByHref (xmlDocPtr doc, + xmlNodePtr node, + const xmlChar *href); +XMLPUBFUN int + xmlGetNsListSafe (const xmlDoc *doc, + const xmlNode *node, + xmlNsPtr **out); +XMLPUBFUN xmlNsPtr * + xmlGetNsList (const xmlDoc *doc, + const xmlNode *node); + +XMLPUBFUN void + xmlSetNs (xmlNodePtr node, + xmlNsPtr ns); +XMLPUBFUN xmlNsPtr + xmlCopyNamespace (xmlNsPtr cur); +XMLPUBFUN xmlNsPtr + xmlCopyNamespaceList (xmlNsPtr cur); + +/* + * Changing the content. + */ +XMLPUBFUN xmlAttrPtr + xmlSetProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr + xmlSetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN int + xmlNodeGetAttrValue (const xmlNode *node, + const xmlChar *name, + const xmlChar *nsUri, + xmlChar **out); +XMLPUBFUN xmlChar * + xmlGetNoNsProp (const xmlNode *node, + const xmlChar *name); +XMLPUBFUN xmlChar * + xmlGetProp (const xmlNode *node, + const xmlChar *name); +XMLPUBFUN xmlAttrPtr + xmlHasProp (const xmlNode *node, + const xmlChar *name); +XMLPUBFUN xmlAttrPtr + xmlHasNsProp (const xmlNode *node, + const xmlChar *name, + const xmlChar *nameSpace); +XMLPUBFUN xmlChar * + xmlGetNsProp (const xmlNode *node, + const xmlChar *name, + const xmlChar *nameSpace); +XMLPUBFUN xmlNodePtr + xmlStringGetNodeList (const xmlDoc *doc, + const xmlChar *value); +XMLPUBFUN xmlNodePtr + xmlStringLenGetNodeList (const xmlDoc *doc, + const xmlChar *value, + int len); +XMLPUBFUN xmlChar * + xmlNodeListGetString (xmlDocPtr doc, + const xmlNode *list, + int inLine); +XMLPUBFUN xmlChar * + xmlNodeListGetRawString (const xmlDoc *doc, + const xmlNode *list, + int inLine); +XMLPUBFUN int + xmlNodeSetContent (xmlNodePtr cur, + const xmlChar *content); +XMLPUBFUN int + xmlNodeSetContentLen (xmlNodePtr cur, + const xmlChar *content, + int len); +XMLPUBFUN int + xmlNodeAddContent (xmlNodePtr cur, + const xmlChar *content); +XMLPUBFUN int + xmlNodeAddContentLen (xmlNodePtr cur, + const xmlChar *content, + int len); +XMLPUBFUN xmlChar * + xmlNodeGetContent (const xmlNode *cur); + +XMLPUBFUN int + xmlNodeBufGetContent (xmlBufferPtr buffer, + const xmlNode *cur); +XMLPUBFUN int + xmlBufGetNodeContent (xmlBufPtr buf, + const xmlNode *cur); + +XMLPUBFUN xmlChar * + xmlNodeGetLang (const xmlNode *cur); +XMLPUBFUN int + xmlNodeGetSpacePreserve (const xmlNode *cur); +XMLPUBFUN int + xmlNodeSetLang (xmlNodePtr cur, + const xmlChar *lang); +XMLPUBFUN int + xmlNodeSetSpacePreserve (xmlNodePtr cur, + int val); +XMLPUBFUN int + xmlNodeGetBaseSafe (const xmlDoc *doc, + const xmlNode *cur, + xmlChar **baseOut); +XMLPUBFUN xmlChar * + xmlNodeGetBase (const xmlDoc *doc, + const xmlNode *cur); +XMLPUBFUN int + xmlNodeSetBase (xmlNodePtr cur, + const xmlChar *uri); + +/* + * Removing content. + */ +XMLPUBFUN int + xmlRemoveProp (xmlAttrPtr cur); +XMLPUBFUN int + xmlUnsetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name); +XMLPUBFUN int + xmlUnsetProp (xmlNodePtr node, + const xmlChar *name); + +/* + * Internal, don't use. + */ +XMLPUBFUN void + xmlBufferWriteCHAR (xmlBufferPtr buf, + const xmlChar *string); +XMLPUBFUN void + xmlBufferWriteChar (xmlBufferPtr buf, + const char *string); +XMLPUBFUN void + xmlBufferWriteQuotedString(xmlBufferPtr buf, + const xmlChar *string); + +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf, + xmlDocPtr doc, + xmlAttrPtr attr, + const xmlChar *string); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* + * Namespace handling. + */ +XMLPUBFUN int + xmlReconciliateNs (xmlDocPtr doc, + xmlNodePtr tree); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Saving. + */ +XMLPUBFUN void + xmlDocDumpFormatMemory (xmlDocPtr cur, + xmlChar **mem, + int *size, + int format); +XMLPUBFUN void + xmlDocDumpMemory (xmlDocPtr cur, + xmlChar **mem, + int *size); +XMLPUBFUN void + xmlDocDumpMemoryEnc (xmlDocPtr out_doc, + xmlChar **doc_txt_ptr, + int * doc_txt_len, + const char *txt_encoding); +XMLPUBFUN void + xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, + xmlChar **doc_txt_ptr, + int * doc_txt_len, + const char *txt_encoding, + int format); +XMLPUBFUN int + xmlDocFormatDump (FILE *f, + xmlDocPtr cur, + int format); +XMLPUBFUN int + xmlDocDump (FILE *f, + xmlDocPtr cur); +XMLPUBFUN void + xmlElemDump (FILE *f, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN int + xmlSaveFile (const char *filename, + xmlDocPtr cur); +XMLPUBFUN int + xmlSaveFormatFile (const char *filename, + xmlDocPtr cur, + int format); +XMLPUBFUN size_t + xmlBufNodeDump (xmlBufPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format); +XMLPUBFUN int + xmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format); + +XMLPUBFUN int + xmlSaveFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN int + xmlSaveFormatFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding, + int format); +XMLPUBFUN void + xmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format, + const char *encoding); + +XMLPUBFUN int + xmlSaveFormatFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding, + int format); + +XMLPUBFUN int + xmlSaveFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding); + +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * XHTML + */ +XMLPUBFUN int + xmlIsXHTML (const xmlChar *systemID, + const xmlChar *publicID); + +/* + * Compression. + */ +XMLPUBFUN int + xmlGetDocCompressMode (const xmlDoc *doc); +XMLPUBFUN void + xmlSetDocCompressMode (xmlDocPtr doc, + int mode); +XML_DEPRECATED +XMLPUBFUN int + xmlGetCompressMode (void); +XML_DEPRECATED +XMLPUBFUN void + xmlSetCompressMode (int mode); + +/* +* DOM-wrapper helper functions. +*/ +XMLPUBFUN xmlDOMWrapCtxtPtr + xmlDOMWrapNewCtxt (void); +XMLPUBFUN void + xmlDOMWrapFreeCtxt (xmlDOMWrapCtxtPtr ctxt); +XMLPUBFUN int + xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt, + xmlNodePtr elem, + int options); +XMLPUBFUN int + xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int options); +XMLPUBFUN int + xmlDOMWrapRemoveNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr node, + int options); +XMLPUBFUN int + xmlDOMWrapCloneNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlNodePtr *clonedNode, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int deep, + int options); + +/* + * 5 interfaces from DOM ElementTraversal, but different in entities + * traversal. + */ +XMLPUBFUN unsigned long + xmlChildElementCount (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr + xmlNextElementSibling (xmlNodePtr node); +XMLPUBFUN xmlNodePtr + xmlFirstElementChild (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr + xmlLastElementChild (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr + xmlPreviousElementSibling (xmlNodePtr node); + +XML_DEPRECATED +XMLPUBFUN xmlRegisterNodeFunc + xmlRegisterNodeDefault (xmlRegisterNodeFunc func); +XML_DEPRECATED +XMLPUBFUN xmlDeregisterNodeFunc + xmlDeregisterNodeDefault (xmlDeregisterNodeFunc func); +XML_DEPRECATED +XMLPUBFUN xmlRegisterNodeFunc + xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func); +XML_DEPRECATED +XMLPUBFUN xmlDeregisterNodeFunc + xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func); + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_TREE_H__ */ + +#endif /* XML_TREE_INTERNALS */ + diff --git a/illumos-x86_64/usr/include/libxml2/libxml/uri.h b/illumos-x86_64/usr/include/libxml2/libxml/uri.h new file mode 100644 index 00000000..19980b71 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/uri.h @@ -0,0 +1,106 @@ +/** + * Summary: library of generic URI related routines + * Description: library of generic URI related routines + * Implements RFC 2396 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_URI_H__ +#define __XML_URI_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlURI: + * + * A parsed URI reference. This is a struct containing the various fields + * as described in RFC 2396 but separated for further processing. + * + * Note: query is a deprecated field which is incorrectly unescaped. + * query_raw takes precedence over query if the former is set. + * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127 + */ +typedef struct _xmlURI xmlURI; +typedef xmlURI *xmlURIPtr; +struct _xmlURI { + char *scheme; /* the URI scheme */ + char *opaque; /* opaque part */ + char *authority; /* the authority part */ + char *server; /* the server part */ + char *user; /* the user part */ + int port; /* the port number */ + char *path; /* the path string */ + char *query; /* the query string (deprecated - use with caution) */ + char *fragment; /* the fragment identifier */ + int cleanup; /* parsing potentially unclean URI */ + char *query_raw; /* the query string (as it appears in the URI) */ +}; + +/* + * This function is in tree.h: + * xmlChar * xmlNodeGetBase (xmlDocPtr doc, + * xmlNodePtr cur); + */ +XMLPUBFUN xmlURIPtr + xmlCreateURI (void); +XMLPUBFUN int + xmlBuildURISafe (const xmlChar *URI, + const xmlChar *base, + xmlChar **out); +XMLPUBFUN xmlChar * + xmlBuildURI (const xmlChar *URI, + const xmlChar *base); +XMLPUBFUN int + xmlBuildRelativeURISafe (const xmlChar *URI, + const xmlChar *base, + xmlChar **out); +XMLPUBFUN xmlChar * + xmlBuildRelativeURI (const xmlChar *URI, + const xmlChar *base); +XMLPUBFUN xmlURIPtr + xmlParseURI (const char *str); +XMLPUBFUN int + xmlParseURISafe (const char *str, + xmlURIPtr *uri); +XMLPUBFUN xmlURIPtr + xmlParseURIRaw (const char *str, + int raw); +XMLPUBFUN int + xmlParseURIReference (xmlURIPtr uri, + const char *str); +XMLPUBFUN xmlChar * + xmlSaveUri (xmlURIPtr uri); +XMLPUBFUN void + xmlPrintURI (FILE *stream, + xmlURIPtr uri); +XMLPUBFUN xmlChar * + xmlURIEscapeStr (const xmlChar *str, + const xmlChar *list); +XMLPUBFUN char * + xmlURIUnescapeString (const char *str, + int len, + char *target); +XMLPUBFUN int + xmlNormalizeURIPath (char *path); +XMLPUBFUN xmlChar * + xmlURIEscape (const xmlChar *str); +XMLPUBFUN void + xmlFreeURI (xmlURIPtr uri); +XMLPUBFUN xmlChar* + xmlCanonicPath (const xmlChar *path); +XMLPUBFUN xmlChar* + xmlPathToURI (const xmlChar *path); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_URI_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/valid.h b/illumos-x86_64/usr/include/libxml2/libxml/valid.h new file mode 100644 index 00000000..cd40561d --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/valid.h @@ -0,0 +1,482 @@ +/* + * Summary: The DTD validation + * Description: API for the DTD handling and the validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_VALID_H__ +#define __XML_VALID_H__ + +/** DOC_DISABLE */ +#include +#include +#define XML_TREE_INTERNALS +#include +#undef XML_TREE_INTERNALS +#include +#include +#include +/** DOC_ENABLE */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Validation state added for non-determinist content model. + */ +typedef struct _xmlValidState xmlValidState; +typedef xmlValidState *xmlValidStatePtr; + +/** + * xmlValidityErrorFunc: + * @ctx: usually an xmlValidCtxtPtr to a validity error context, + * but comes from ctxt->userData (which normally contains such + * a pointer); ctxt->userData can be changed by the user. + * @msg: the string to format *printf like vararg + * @...: remaining arguments to the format + * + * Callback called when a validity error is found. This is a message + * oriented function similar to an *printf function. + */ +typedef void (*xmlValidityErrorFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * xmlValidityWarningFunc: + * @ctx: usually an xmlValidCtxtPtr to a validity error context, + * but comes from ctxt->userData (which normally contains such + * a pointer); ctxt->userData can be changed by the user. + * @msg: the string to format *printf like vararg + * @...: remaining arguments to the format + * + * Callback called when a validity warning is found. This is a message + * oriented function similar to an *printf function. + */ +typedef void (*xmlValidityWarningFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); + +/* + * xmlValidCtxt: + * An xmlValidCtxt is used for error reporting when validating. + */ +typedef struct _xmlValidCtxt xmlValidCtxt; +typedef xmlValidCtxt *xmlValidCtxtPtr; +struct _xmlValidCtxt { + void *userData; /* user specific data block */ + xmlValidityErrorFunc error; /* the callback in case of errors */ + xmlValidityWarningFunc warning; /* the callback in case of warning */ + + /* Node analysis stack used when validating within entities */ + xmlNodePtr node; /* Current parsed Node */ + int nodeNr; /* Depth of the parsing stack */ + int nodeMax; /* Max depth of the parsing stack */ + xmlNodePtr *nodeTab; /* array of nodes */ + + unsigned int flags; /* internal flags */ + xmlDocPtr doc; /* the document */ + int valid; /* temporary validity check result */ + + /* state state used for non-determinist content validation */ + xmlValidState *vstate; /* current state */ + int vstateNr; /* Depth of the validation stack */ + int vstateMax; /* Max depth of the validation stack */ + xmlValidState *vstateTab; /* array of validation states */ + +#ifdef LIBXML_REGEXP_ENABLED + xmlAutomataPtr am; /* the automata */ + xmlAutomataStatePtr state; /* used to build the automata */ +#else + void *am; + void *state; +#endif +}; + +/* + * ALL notation declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlNotationTable; +typedef xmlNotationTable *xmlNotationTablePtr; + +/* + * ALL element declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlElementTable; +typedef xmlElementTable *xmlElementTablePtr; + +/* + * ALL attribute declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlAttributeTable; +typedef xmlAttributeTable *xmlAttributeTablePtr; + +/* + * ALL IDs attributes are stored in a table. + * There is one table per document. + */ + +typedef struct _xmlHashTable xmlIDTable; +typedef xmlIDTable *xmlIDTablePtr; + +/* + * ALL Refs attributes are stored in a table. + * There is one table per document. + */ + +typedef struct _xmlHashTable xmlRefTable; +typedef xmlRefTable *xmlRefTablePtr; + +/* Notation */ +XMLPUBFUN xmlNotationPtr + xmlAddNotationDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *PublicID, + const xmlChar *SystemID); +XML_DEPRECATED +XMLPUBFUN xmlNotationTablePtr + xmlCopyNotationTable (xmlNotationTablePtr table); +XML_DEPRECATED +XMLPUBFUN void + xmlFreeNotationTable (xmlNotationTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XML_DEPRECATED +XMLPUBFUN void + xmlDumpNotationDecl (xmlBufferPtr buf, + xmlNotationPtr nota); +/* XML_DEPRECATED, still used in lxml */ +XMLPUBFUN void + xmlDumpNotationTable (xmlBufferPtr buf, + xmlNotationTablePtr table); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Element Content */ +/* the non Doc version are being deprecated */ +XML_DEPRECATED +XMLPUBFUN xmlElementContentPtr + xmlNewElementContent (const xmlChar *name, + xmlElementContentType type); +XML_DEPRECATED +XMLPUBFUN xmlElementContentPtr + xmlCopyElementContent (xmlElementContentPtr content); +XML_DEPRECATED +XMLPUBFUN void + xmlFreeElementContent (xmlElementContentPtr cur); +/* the new versions with doc argument */ +XML_DEPRECATED +XMLPUBFUN xmlElementContentPtr + xmlNewDocElementContent (xmlDocPtr doc, + const xmlChar *name, + xmlElementContentType type); +XML_DEPRECATED +XMLPUBFUN xmlElementContentPtr + xmlCopyDocElementContent(xmlDocPtr doc, + xmlElementContentPtr content); +XML_DEPRECATED +XMLPUBFUN void + xmlFreeDocElementContent(xmlDocPtr doc, + xmlElementContentPtr cur); +XML_DEPRECATED +XMLPUBFUN void + xmlSnprintfElementContent(char *buf, + int size, + xmlElementContentPtr content, + int englob); +#ifdef LIBXML_OUTPUT_ENABLED +XML_DEPRECATED +XMLPUBFUN void + xmlSprintfElementContent(char *buf, + xmlElementContentPtr content, + int englob); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Element */ +XMLPUBFUN xmlElementPtr + xmlAddElementDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *name, + xmlElementTypeVal type, + xmlElementContentPtr content); +XML_DEPRECATED +XMLPUBFUN xmlElementTablePtr + xmlCopyElementTable (xmlElementTablePtr table); +XML_DEPRECATED +XMLPUBFUN void + xmlFreeElementTable (xmlElementTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XML_DEPRECATED +XMLPUBFUN void + xmlDumpElementTable (xmlBufferPtr buf, + xmlElementTablePtr table); +XML_DEPRECATED +XMLPUBFUN void + xmlDumpElementDecl (xmlBufferPtr buf, + xmlElementPtr elem); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Enumeration */ +XML_DEPRECATED +XMLPUBFUN xmlEnumerationPtr + xmlCreateEnumeration (const xmlChar *name); +/* XML_DEPRECATED, needed for custom attributeDecl SAX handler */ +XMLPUBFUN void + xmlFreeEnumeration (xmlEnumerationPtr cur); +XML_DEPRECATED +XMLPUBFUN xmlEnumerationPtr + xmlCopyEnumeration (xmlEnumerationPtr cur); + +/* Attribute */ +XMLPUBFUN xmlAttributePtr + xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name, + const xmlChar *ns, + xmlAttributeType type, + xmlAttributeDefault def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XML_DEPRECATED +XMLPUBFUN xmlAttributeTablePtr + xmlCopyAttributeTable (xmlAttributeTablePtr table); +XML_DEPRECATED +XMLPUBFUN void + xmlFreeAttributeTable (xmlAttributeTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XML_DEPRECATED +XMLPUBFUN void + xmlDumpAttributeTable (xmlBufferPtr buf, + xmlAttributeTablePtr table); +XML_DEPRECATED +XMLPUBFUN void + xmlDumpAttributeDecl (xmlBufferPtr buf, + xmlAttributePtr attr); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* IDs */ +XMLPUBFUN int + xmlAddIDSafe (xmlAttrPtr attr, + const xmlChar *value); +XMLPUBFUN xmlIDPtr + xmlAddID (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *value, + xmlAttrPtr attr); +XMLPUBFUN void + xmlFreeIDTable (xmlIDTablePtr table); +XMLPUBFUN xmlAttrPtr + xmlGetID (xmlDocPtr doc, + const xmlChar *ID); +XMLPUBFUN int + xmlIsID (xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr); +XMLPUBFUN int + xmlRemoveID (xmlDocPtr doc, + xmlAttrPtr attr); + +/* IDREFs */ +XML_DEPRECATED +XMLPUBFUN xmlRefPtr + xmlAddRef (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *value, + xmlAttrPtr attr); +XML_DEPRECATED +XMLPUBFUN void + xmlFreeRefTable (xmlRefTablePtr table); +XML_DEPRECATED +XMLPUBFUN int + xmlIsRef (xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr); +XML_DEPRECATED +XMLPUBFUN int + xmlRemoveRef (xmlDocPtr doc, + xmlAttrPtr attr); +XML_DEPRECATED +XMLPUBFUN xmlListPtr + xmlGetRefs (xmlDocPtr doc, + const xmlChar *ID); + +/** + * The public function calls related to validity checking. + */ +#ifdef LIBXML_VALID_ENABLED +/* Allocate/Release Validation Contexts */ +XMLPUBFUN xmlValidCtxtPtr + xmlNewValidCtxt(void); +XMLPUBFUN void + xmlFreeValidCtxt(xmlValidCtxtPtr); + +XML_DEPRECATED +XMLPUBFUN int + xmlValidateRoot (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateElementDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlElementPtr elem); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlValidNormalizeAttributeValue(xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *name, + const xmlChar *value); +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *name, + const xmlChar *value); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlAttributePtr attr); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateAttributeValue(xmlAttributeType type, + const xmlChar *value); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNotationPtr nota); +XMLPUBFUN int + xmlValidateDtd (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlDtdPtr dtd); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateDtdFinal (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int + xmlValidateDocument (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int + xmlValidateElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateOneElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr, + const xmlChar *value); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateOneNamespace (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *prefix, + xmlNsPtr ns, + const xmlChar *value); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XML_DEPRECATED +XMLPUBFUN int + xmlValidateNotationUse (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *notationName); +#endif /* LIBXML_VALID_ENABLED */ + +XMLPUBFUN int + xmlIsMixedElement (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlAttributePtr + xmlGetDtdAttrDesc (xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name); +XMLPUBFUN xmlAttributePtr + xmlGetDtdQAttrDesc (xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN xmlNotationPtr + xmlGetDtdNotationDesc (xmlDtdPtr dtd, + const xmlChar *name); +XMLPUBFUN xmlElementPtr + xmlGetDtdQElementDesc (xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN xmlElementPtr + xmlGetDtdElementDesc (xmlDtdPtr dtd, + const xmlChar *name); + +#ifdef LIBXML_VALID_ENABLED + +XMLPUBFUN int + xmlValidGetPotentialChildren(xmlElementContent *ctree, + const xmlChar **names, + int *len, + int max); + +XMLPUBFUN int + xmlValidGetValidElements(xmlNode *prev, + xmlNode *next, + const xmlChar **names, + int max); +XMLPUBFUN int + xmlValidateNameValue (const xmlChar *value); +XMLPUBFUN int + xmlValidateNamesValue (const xmlChar *value); +XMLPUBFUN int + xmlValidateNmtokenValue (const xmlChar *value); +XMLPUBFUN int + xmlValidateNmtokensValue(const xmlChar *value); + +#ifdef LIBXML_REGEXP_ENABLED +/* + * Validation based on the regexp support + */ +XML_DEPRECATED +XMLPUBFUN int + xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, + xmlElementPtr elem); + +XML_DEPRECATED +XMLPUBFUN int + xmlValidatePushElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *qname); +XML_DEPRECATED +XMLPUBFUN int + xmlValidatePushCData (xmlValidCtxtPtr ctxt, + const xmlChar *data, + int len); +XML_DEPRECATED +XMLPUBFUN int + xmlValidatePopElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *qname); +#endif /* LIBXML_REGEXP_ENABLED */ +#endif /* LIBXML_VALID_ENABLED */ +#ifdef __cplusplus +} +#endif +#endif /* __XML_VALID_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xinclude.h b/illumos-x86_64/usr/include/libxml2/libxml/xinclude.h new file mode 100644 index 00000000..e1cb39fe --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xinclude.h @@ -0,0 +1,141 @@ +/* + * Summary: implementation of XInclude + * Description: API to handle XInclude processing, + * implements the + * World Wide Web Consortium Last Call Working Draft 10 November 2003 + * http://www.w3.org/TR/2003/WD-xinclude-20031110 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XINCLUDE_H__ +#define __XML_XINCLUDE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_XINCLUDE_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XINCLUDE_NS: + * + * Macro defining the Xinclude namespace: http://www.w3.org/2003/XInclude + */ +#define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/2003/XInclude" +/** + * XINCLUDE_OLD_NS: + * + * Macro defining the draft Xinclude namespace: http://www.w3.org/2001/XInclude + */ +#define XINCLUDE_OLD_NS (const xmlChar *) "http://www.w3.org/2001/XInclude" +/** + * XINCLUDE_NODE: + * + * Macro defining "include" + */ +#define XINCLUDE_NODE (const xmlChar *) "include" +/** + * XINCLUDE_FALLBACK: + * + * Macro defining "fallback" + */ +#define XINCLUDE_FALLBACK (const xmlChar *) "fallback" +/** + * XINCLUDE_HREF: + * + * Macro defining "href" + */ +#define XINCLUDE_HREF (const xmlChar *) "href" +/** + * XINCLUDE_PARSE: + * + * Macro defining "parse" + */ +#define XINCLUDE_PARSE (const xmlChar *) "parse" +/** + * XINCLUDE_PARSE_XML: + * + * Macro defining "xml" + */ +#define XINCLUDE_PARSE_XML (const xmlChar *) "xml" +/** + * XINCLUDE_PARSE_TEXT: + * + * Macro defining "text" + */ +#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text" +/** + * XINCLUDE_PARSE_ENCODING: + * + * Macro defining "encoding" + */ +#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding" +/** + * XINCLUDE_PARSE_XPOINTER: + * + * Macro defining "xpointer" + */ +#define XINCLUDE_PARSE_XPOINTER (const xmlChar *) "xpointer" + +typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt; +typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr; + +/* + * standalone processing + */ +XMLPUBFUN int + xmlXIncludeProcess (xmlDocPtr doc); +XMLPUBFUN int + xmlXIncludeProcessFlags (xmlDocPtr doc, + int flags); +XMLPUBFUN int + xmlXIncludeProcessFlagsData(xmlDocPtr doc, + int flags, + void *data); +XMLPUBFUN int + xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, + int flags, + void *data); +XMLPUBFUN int + xmlXIncludeProcessTree (xmlNodePtr tree); +XMLPUBFUN int + xmlXIncludeProcessTreeFlags(xmlNodePtr tree, + int flags); +/* + * contextual processing + */ +XMLPUBFUN xmlXIncludeCtxtPtr + xmlXIncludeNewContext (xmlDocPtr doc); +XMLPUBFUN int + xmlXIncludeSetFlags (xmlXIncludeCtxtPtr ctxt, + int flags); +XMLPUBFUN void + xmlXIncludeSetErrorHandler(xmlXIncludeCtxtPtr ctxt, + xmlStructuredErrorFunc handler, + void *data); +XMLPUBFUN void + xmlXIncludeSetResourceLoader(xmlXIncludeCtxtPtr ctxt, + xmlResourceLoader loader, + void *data); +XMLPUBFUN int + xmlXIncludeGetLastError (xmlXIncludeCtxtPtr ctxt); +XMLPUBFUN void + xmlXIncludeFreeContext (xmlXIncludeCtxtPtr ctxt); +XMLPUBFUN int + xmlXIncludeProcessNode (xmlXIncludeCtxtPtr ctxt, + xmlNodePtr tree); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XINCLUDE_ENABLED */ + +#endif /* __XML_XINCLUDE_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xlink.h b/illumos-x86_64/usr/include/libxml2/libxml/xlink.h new file mode 100644 index 00000000..3ec83e42 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xlink.h @@ -0,0 +1,193 @@ +/* + * Summary: unfinished XLink detection module + * Description: unfinished XLink detection module + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XLINK_H__ +#define __XML_XLINK_H__ + +#include +#include + +#ifdef LIBXML_XPTR_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Various defines for the various Link properties. + * + * NOTE: the link detection layer will try to resolve QName expansion + * of namespaces. If "foo" is the prefix for "http://foo.com/" + * then the link detection layer will expand role="foo:myrole" + * to "http://foo.com/:myrole". + * NOTE: the link detection layer will expand URI-References found on + * href attributes by using the base mechanism if found. + */ +typedef xmlChar *xlinkHRef; +typedef xmlChar *xlinkRole; +typedef xmlChar *xlinkTitle; + +typedef enum { + XLINK_TYPE_NONE = 0, + XLINK_TYPE_SIMPLE, + XLINK_TYPE_EXTENDED, + XLINK_TYPE_EXTENDED_SET +} xlinkType; + +typedef enum { + XLINK_SHOW_NONE = 0, + XLINK_SHOW_NEW, + XLINK_SHOW_EMBED, + XLINK_SHOW_REPLACE +} xlinkShow; + +typedef enum { + XLINK_ACTUATE_NONE = 0, + XLINK_ACTUATE_AUTO, + XLINK_ACTUATE_ONREQUEST +} xlinkActuate; + +/** + * xlinkNodeDetectFunc: + * @ctx: user data pointer + * @node: the node to check + * + * This is the prototype for the link detection routine. + * It calls the default link detection callbacks upon link detection. + */ +typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node); + +/* + * The link detection module interact with the upper layers using + * a set of callback registered at parsing time. + */ + +/** + * xlinkSimpleLinkFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @href: the target of the link + * @role: the role string + * @title: the link title + * + * This is the prototype for a simple link detection callback. + */ +typedef void +(*xlinkSimpleLinkFunk) (void *ctx, + xmlNodePtr node, + const xlinkHRef href, + const xlinkRole role, + const xlinkTitle title); + +/** + * xlinkExtendedLinkFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @nbLocators: the number of locators detected on the link + * @hrefs: pointer to the array of locator hrefs + * @roles: pointer to the array of locator roles + * @nbArcs: the number of arcs detected on the link + * @from: pointer to the array of source roles found on the arcs + * @to: pointer to the array of target roles found on the arcs + * @show: array of values for the show attributes found on the arcs + * @actuate: array of values for the actuate attributes found on the arcs + * @nbTitles: the number of titles detected on the link + * @title: array of titles detected on the link + * @langs: array of xml:lang values for the titles + * + * This is the prototype for a extended link detection callback. + */ +typedef void +(*xlinkExtendedLinkFunk)(void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef *hrefs, + const xlinkRole *roles, + int nbArcs, + const xlinkRole *from, + const xlinkRole *to, + xlinkShow *show, + xlinkActuate *actuate, + int nbTitles, + const xlinkTitle *titles, + const xmlChar **langs); + +/** + * xlinkExtendedLinkSetFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @nbLocators: the number of locators detected on the link + * @hrefs: pointer to the array of locator hrefs + * @roles: pointer to the array of locator roles + * @nbTitles: the number of titles detected on the link + * @title: array of titles detected on the link + * @langs: array of xml:lang values for the titles + * + * This is the prototype for a extended link set detection callback. + */ +typedef void +(*xlinkExtendedLinkSetFunk) (void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef *hrefs, + const xlinkRole *roles, + int nbTitles, + const xlinkTitle *titles, + const xmlChar **langs); + +/** + * This is the structure containing a set of Links detection callbacks. + * + * There is no default xlink callbacks, if one want to get link + * recognition activated, those call backs must be provided before parsing. + */ +typedef struct _xlinkHandler xlinkHandler; +typedef xlinkHandler *xlinkHandlerPtr; +struct _xlinkHandler { + xlinkSimpleLinkFunk simple; + xlinkExtendedLinkFunk extended; + xlinkExtendedLinkSetFunk set; +}; + +/* + * The default detection routine, can be overridden, they call the default + * detection callbacks. + */ + +XML_DEPRECATED +XMLPUBFUN xlinkNodeDetectFunc + xlinkGetDefaultDetect (void); +XML_DEPRECATED +XMLPUBFUN void + xlinkSetDefaultDetect (xlinkNodeDetectFunc func); + +/* + * Routines to set/get the default handlers. + */ +XML_DEPRECATED +XMLPUBFUN xlinkHandlerPtr + xlinkGetDefaultHandler (void); +XML_DEPRECATED +XMLPUBFUN void + xlinkSetDefaultHandler (xlinkHandlerPtr handler); + +/* + * Link detection module itself. + */ +XMLPUBFUN xlinkType + xlinkIsLink (xmlDocPtr doc, + xmlNodePtr node); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPTR_ENABLED */ + +#endif /* __XML_XLINK_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlIO.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlIO.h new file mode 100644 index 00000000..c46ccd93 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlIO.h @@ -0,0 +1,419 @@ +/* + * Summary: interface for the I/O interfaces used by the parser + * Description: interface for the I/O interfaces used by the parser + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_IO_H__ +#define __XML_IO_H__ + +/** DOC_DISABLE */ +#include +#include +#include +#define XML_TREE_INTERNALS +#include +#undef XML_TREE_INTERNALS +/** DOC_ENABLE */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Those are the functions and datatypes for the parser input + * I/O structures. + */ + +/** + * xmlInputMatchCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Input API to detect if the current handler + * can provide input functionality for this resource. + * + * Returns 1 if yes and 0 if another Input module should be used + */ +typedef int (*xmlInputMatchCallback) (char const *filename); +/** + * xmlInputOpenCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Input API to open the resource + * + * Returns an Input context or NULL in case or error + */ +typedef void * (*xmlInputOpenCallback) (char const *filename); +/** + * xmlInputReadCallback: + * @context: an Input context + * @buffer: the buffer to store data read + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Input API to read the resource + * + * Returns the number of bytes read or -1 in case of error + */ +typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len); +/** + * xmlInputCloseCallback: + * @context: an Input context + * + * Callback used in the I/O Input API to close the resource + * + * Returns 0 or -1 in case of error + */ +typedef int (*xmlInputCloseCallback) (void * context); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Those are the functions and datatypes for the library output + * I/O structures. + */ + +/** + * xmlOutputMatchCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Output API to detect if the current handler + * can provide output functionality for this resource. + * + * Returns 1 if yes and 0 if another Output module should be used + */ +typedef int (*xmlOutputMatchCallback) (char const *filename); +/** + * xmlOutputOpenCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Output API to open the resource + * + * Returns an Output context or NULL in case or error + */ +typedef void * (*xmlOutputOpenCallback) (char const *filename); +/** + * xmlOutputWriteCallback: + * @context: an Output context + * @buffer: the buffer of data to write + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Output API to write to the resource + * + * Returns the number of bytes written or -1 in case of error + */ +typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer, + int len); +/** + * xmlOutputCloseCallback: + * @context: an Output context + * + * Callback used in the I/O Output API to close the resource + * + * Returns 0 or -1 in case of error + */ +typedef int (*xmlOutputCloseCallback) (void * context); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/** + * xmlParserInputBufferCreateFilenameFunc: + * @URI: the URI to read from + * @enc: the requested source encoding + * + * Signature for the function doing the lookup for a suitable input method + * corresponding to an URI. + * + * Returns the new xmlParserInputBufferPtr in case of success or NULL if no + * method was found. + */ +typedef xmlParserInputBufferPtr +(*xmlParserInputBufferCreateFilenameFunc)(const char *URI, xmlCharEncoding enc); + +/** + * xmlOutputBufferCreateFilenameFunc: + * @URI: the URI to write to + * @enc: the requested target encoding + * + * Signature for the function doing the lookup for a suitable output method + * corresponding to an URI. + * + * Returns the new xmlOutputBufferPtr in case of success or NULL if no + * method was found. + */ +typedef xmlOutputBufferPtr +(*xmlOutputBufferCreateFilenameFunc)(const char *URI, + xmlCharEncodingHandlerPtr encoder, int compression); + +struct _xmlParserInputBuffer { + void* context; + xmlInputReadCallback readcallback; + xmlInputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ + + xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */ + xmlBufPtr raw; /* if encoder != NULL buffer for raw input */ + int compressed; /* -1=unknown, 0=not compressed, 1=compressed */ + int error; + unsigned long rawconsumed;/* amount consumed from raw */ +}; + + +#ifdef LIBXML_OUTPUT_ENABLED +struct _xmlOutputBuffer { + void* context; + xmlOutputWriteCallback writecallback; + xmlOutputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ + + xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */ + xmlBufPtr conv; /* if encoder != NULL buffer for output */ + int written; /* total number of byte written */ + int error; +}; +#endif /* LIBXML_OUTPUT_ENABLED */ + +/** DOC_DISABLE */ +XML_DEPRECATED +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * +__xmlParserInputBufferCreateFilenameValue(void); +XML_DEPRECATED +XMLPUBFUN xmlOutputBufferCreateFilenameFunc * +__xmlOutputBufferCreateFilenameValue(void); + +#ifndef XML_GLOBALS_NO_REDEFINITION + #define xmlParserInputBufferCreateFilenameValue \ + (*__xmlParserInputBufferCreateFilenameValue()) + #define xmlOutputBufferCreateFilenameValue \ + (*__xmlOutputBufferCreateFilenameValue()) +#endif +/** DOC_ENABLE */ + +/* + * Interfaces for input + */ +XMLPUBFUN void + xmlCleanupInputCallbacks (void); + +XMLPUBFUN int + xmlPopInputCallbacks (void); + +XMLPUBFUN void + xmlRegisterDefaultInputCallbacks (void); +XMLPUBFUN xmlParserInputBufferPtr + xmlAllocParserInputBuffer (xmlCharEncoding enc); + +XMLPUBFUN xmlParserInputBufferPtr + xmlParserInputBufferCreateFilename (const char *URI, + xmlCharEncoding enc); +XML_DEPRECATED +XMLPUBFUN xmlParserInputBufferPtr + xmlParserInputBufferCreateFile (FILE *file, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr + xmlParserInputBufferCreateFd (int fd, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr + xmlParserInputBufferCreateMem (const char *mem, int size, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr + xmlParserInputBufferCreateStatic (const char *mem, int size, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr + xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + xmlCharEncoding enc); +XML_DEPRECATED +XMLPUBFUN int + xmlParserInputBufferRead (xmlParserInputBufferPtr in, + int len); +XML_DEPRECATED +XMLPUBFUN int + xmlParserInputBufferGrow (xmlParserInputBufferPtr in, + int len); +XML_DEPRECATED +XMLPUBFUN int + xmlParserInputBufferPush (xmlParserInputBufferPtr in, + int len, + const char *buf); +XMLPUBFUN void + xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); +XMLPUBFUN char * + xmlParserGetDirectory (const char *filename); + +XMLPUBFUN int + xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc, + xmlInputOpenCallback openFunc, + xmlInputReadCallback readFunc, + xmlInputCloseCallback closeFunc); + +XMLPUBFUN xmlParserInputBufferPtr + __xmlParserInputBufferCreateFilename(const char *URI, + xmlCharEncoding enc); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Interfaces for output + */ +XMLPUBFUN void + xmlCleanupOutputCallbacks (void); +XMLPUBFUN int + xmlPopOutputCallbacks (void); +XMLPUBFUN void + xmlRegisterDefaultOutputCallbacks(void); +XMLPUBFUN xmlOutputBufferPtr + xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr + xmlOutputBufferCreateFilename (const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +XMLPUBFUN xmlOutputBufferPtr + xmlOutputBufferCreateFile (FILE *file, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr + xmlOutputBufferCreateBuffer (xmlBufferPtr buffer, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr + xmlOutputBufferCreateFd (int fd, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr + xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, + xmlCharEncodingHandlerPtr encoder); + +/* Couple of APIs to get the output without digging into the buffers */ +XMLPUBFUN const xmlChar * + xmlOutputBufferGetContent (xmlOutputBufferPtr out); +XMLPUBFUN size_t + xmlOutputBufferGetSize (xmlOutputBufferPtr out); + +XMLPUBFUN int + xmlOutputBufferWrite (xmlOutputBufferPtr out, + int len, + const char *buf); +XMLPUBFUN int + xmlOutputBufferWriteString (xmlOutputBufferPtr out, + const char *str); +XMLPUBFUN int + xmlOutputBufferWriteEscape (xmlOutputBufferPtr out, + const xmlChar *str, + xmlCharEncodingOutputFunc escaping); + +XMLPUBFUN int + xmlOutputBufferFlush (xmlOutputBufferPtr out); +XMLPUBFUN int + xmlOutputBufferClose (xmlOutputBufferPtr out); + +XMLPUBFUN int + xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc, + xmlOutputOpenCallback openFunc, + xmlOutputWriteCallback writeFunc, + xmlOutputCloseCallback closeFunc); + +XMLPUBFUN xmlOutputBufferPtr + __xmlOutputBufferCreateFilename(const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +#ifdef LIBXML_HTTP_ENABLED +/* This function only exists if HTTP support built into the library */ +XML_DEPRECATED +XMLPUBFUN void + xmlRegisterHTTPPostCallbacks (void ); +#endif /* LIBXML_HTTP_ENABLED */ + +#endif /* LIBXML_OUTPUT_ENABLED */ + +XML_DEPRECATED +XMLPUBFUN xmlParserInputPtr + xmlCheckHTTPInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr ret); + +/* + * A predefined entity loader disabling network accesses + */ +XMLPUBFUN xmlParserInputPtr + xmlNoNetExternalEntityLoader (const char *URL, + const char *ID, + xmlParserCtxtPtr ctxt); + +XML_DEPRECATED +XMLPUBFUN xmlChar * + xmlNormalizeWindowsPath (const xmlChar *path); + +XML_DEPRECATED +XMLPUBFUN int + xmlCheckFilename (const char *path); +/** + * Default 'file://' protocol callbacks + */ +XML_DEPRECATED +XMLPUBFUN int + xmlFileMatch (const char *filename); +XML_DEPRECATED +XMLPUBFUN void * + xmlFileOpen (const char *filename); +XML_DEPRECATED +XMLPUBFUN int + xmlFileRead (void * context, + char * buffer, + int len); +XML_DEPRECATED +XMLPUBFUN int + xmlFileClose (void * context); + +/** + * Default 'http://' protocol callbacks + */ +#ifdef LIBXML_HTTP_ENABLED +XML_DEPRECATED +XMLPUBFUN int + xmlIOHTTPMatch (const char *filename); +XML_DEPRECATED +XMLPUBFUN void * + xmlIOHTTPOpen (const char *filename); +#ifdef LIBXML_OUTPUT_ENABLED +XML_DEPRECATED +XMLPUBFUN void * + xmlIOHTTPOpenW (const char * post_uri, + int compression ); +#endif /* LIBXML_OUTPUT_ENABLED */ +XML_DEPRECATED +XMLPUBFUN int + xmlIOHTTPRead (void * context, + char * buffer, + int len); +XML_DEPRECATED +XMLPUBFUN int + xmlIOHTTPClose (void * context); +#endif /* LIBXML_HTTP_ENABLED */ + +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc + xmlParserInputBufferCreateFilenameDefault( + xmlParserInputBufferCreateFilenameFunc func); +XMLPUBFUN xmlOutputBufferCreateFilenameFunc + xmlOutputBufferCreateFilenameDefault( + xmlOutputBufferCreateFilenameFunc func); +XML_DEPRECATED +XMLPUBFUN xmlOutputBufferCreateFilenameFunc + xmlThrDefOutputBufferCreateFilenameDefault( + xmlOutputBufferCreateFilenameFunc func); +XML_DEPRECATED +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc + xmlThrDefParserInputBufferCreateFilenameDefault( + xmlParserInputBufferCreateFilenameFunc func); + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_IO_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlautomata.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlautomata.h new file mode 100644 index 00000000..97d0abf9 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlautomata.h @@ -0,0 +1,163 @@ +/* + * Summary: API to build regexp automata + * Description: the API to build regexp automata + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_AUTOMATA_H__ +#define __XML_AUTOMATA_H__ + +#include + +#ifdef LIBXML_REGEXP_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlAutomataPtr: + * + * A libxml automata description, It can be compiled into a regexp + */ +typedef struct _xmlAutomata xmlAutomata; +typedef xmlAutomata *xmlAutomataPtr; + +/** + * xmlAutomataStatePtr: + * + * A state int the automata description, + */ +typedef struct _xmlAutomataState xmlAutomataState; +typedef xmlAutomataState *xmlAutomataStatePtr; + +/* + * Building API + */ +XML_DEPRECATED +XMLPUBFUN xmlAutomataPtr + xmlNewAutomata (void); +XML_DEPRECATED +XMLPUBFUN void + xmlFreeAutomata (xmlAutomataPtr am); + +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataGetInitState (xmlAutomataPtr am); +XML_DEPRECATED +XMLPUBFUN int + xmlAutomataSetFinalState (xmlAutomataPtr am, + xmlAutomataStatePtr state); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewState (xmlAutomataPtr am); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewTransition (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + void *data); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewTransition2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + void *data); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewNegTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + void *data); + +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewCountTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + int min, + int max, + void *data); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewCountTrans2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + int min, + int max, + void *data); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewOnceTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + int min, + int max, + void *data); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewOnceTrans2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + int min, + int max, + void *data); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewAllTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int lax); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewEpsilon (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewCountedTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +XML_DEPRECATED +XMLPUBFUN xmlAutomataStatePtr + xmlAutomataNewCounterTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +XML_DEPRECATED +XMLPUBFUN int + xmlAutomataNewCounter (xmlAutomataPtr am, + int min, + int max); + +XML_DEPRECATED +XMLPUBFUN struct _xmlRegexp * + xmlAutomataCompile (xmlAutomataPtr am); +XML_DEPRECATED +XMLPUBFUN int + xmlAutomataIsDeterminist (xmlAutomataPtr am); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_REGEXP_ENABLED */ + +#endif /* __XML_AUTOMATA_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlerror.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlerror.h new file mode 100644 index 00000000..cefd8f71 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlerror.h @@ -0,0 +1,962 @@ +/* + * Summary: error handling + * Description: the API used to report errors + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_ERROR_H__ +#define __XML_ERROR_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Backward compatibility + */ +#define initGenericErrorDefaultFunc(h) \ + xmlSetGenericErrorFunc(NULL, (h) ? *((xmlGenericErrorFunc *) (h)) : NULL) + +/** + * xmlErrorLevel: + * + * Indicates the level of an error + */ +typedef enum { + XML_ERR_NONE = 0, + XML_ERR_WARNING = 1, /* A simple warning */ + XML_ERR_ERROR = 2, /* A recoverable error */ + XML_ERR_FATAL = 3 /* A fatal error */ +} xmlErrorLevel; + +/** + * xmlErrorDomain: + * + * Indicates where an error may have come from + */ +typedef enum { + XML_FROM_NONE = 0, + XML_FROM_PARSER, /* The XML parser */ + XML_FROM_TREE, /* The tree module */ + XML_FROM_NAMESPACE, /* The XML Namespace module */ + XML_FROM_DTD, /* The XML DTD validation with parser context*/ + XML_FROM_HTML, /* The HTML parser */ + XML_FROM_MEMORY, /* The memory allocator */ + XML_FROM_OUTPUT, /* The serialization code */ + XML_FROM_IO, /* The Input/Output stack */ + XML_FROM_FTP, /* The FTP module */ + XML_FROM_HTTP, /* The HTTP module */ + XML_FROM_XINCLUDE, /* The XInclude processing */ + XML_FROM_XPATH, /* The XPath module */ + XML_FROM_XPOINTER, /* The XPointer module */ + XML_FROM_REGEXP, /* The regular expressions module */ + XML_FROM_DATATYPE, /* The W3C XML Schemas Datatype module */ + XML_FROM_SCHEMASP, /* The W3C XML Schemas parser module */ + XML_FROM_SCHEMASV, /* The W3C XML Schemas validation module */ + XML_FROM_RELAXNGP, /* The Relax-NG parser module */ + XML_FROM_RELAXNGV, /* The Relax-NG validator module */ + XML_FROM_CATALOG, /* The Catalog module */ + XML_FROM_C14N, /* The Canonicalization module */ + XML_FROM_XSLT, /* The XSLT engine from libxslt */ + XML_FROM_VALID, /* The XML DTD validation with valid context */ + XML_FROM_CHECK, /* The error checking module */ + XML_FROM_WRITER, /* The xmlwriter module */ + XML_FROM_MODULE, /* The dynamically loaded module module*/ + XML_FROM_I18N, /* The module handling character conversion */ + XML_FROM_SCHEMATRONV,/* The Schematron validator module */ + XML_FROM_BUFFER, /* The buffers module */ + XML_FROM_URI /* The URI module */ +} xmlErrorDomain; + +/** + * xmlError: + * + * An XML Error instance. + */ + +typedef struct _xmlError xmlError; +typedef xmlError *xmlErrorPtr; +struct _xmlError { + int domain; /* What part of the library raised this error */ + int code; /* The error code, e.g. an xmlParserError */ + char *message;/* human-readable informative error message */ + xmlErrorLevel level;/* how consequent is the error */ + char *file; /* the filename */ + int line; /* the line number if available */ + char *str1; /* extra string information */ + char *str2; /* extra string information */ + char *str3; /* extra string information */ + int int1; /* extra number information */ + int int2; /* error column # or 0 if N/A (todo: rename field when we would brk ABI) */ + void *ctxt; /* the parser context if available */ + void *node; /* the node in the tree */ +}; + +/** + * xmlParserError: + * + * This is an error that the XML (or HTML) parser can generate + */ +typedef enum { + XML_ERR_OK = 0, + XML_ERR_INTERNAL_ERROR, /* 1 */ + XML_ERR_NO_MEMORY, /* 2 */ + XML_ERR_DOCUMENT_START, /* 3 */ + XML_ERR_DOCUMENT_EMPTY, /* 4 */ + XML_ERR_DOCUMENT_END, /* 5 */ + XML_ERR_INVALID_HEX_CHARREF, /* 6 */ + XML_ERR_INVALID_DEC_CHARREF, /* 7 */ + XML_ERR_INVALID_CHARREF, /* 8 */ + XML_ERR_INVALID_CHAR, /* 9 */ + XML_ERR_CHARREF_AT_EOF, /* 10 */ + XML_ERR_CHARREF_IN_PROLOG, /* 11 */ + XML_ERR_CHARREF_IN_EPILOG, /* 12 */ + XML_ERR_CHARREF_IN_DTD, /* 13 */ + XML_ERR_ENTITYREF_AT_EOF, /* 14 */ + XML_ERR_ENTITYREF_IN_PROLOG, /* 15 */ + XML_ERR_ENTITYREF_IN_EPILOG, /* 16 */ + XML_ERR_ENTITYREF_IN_DTD, /* 17 */ + XML_ERR_PEREF_AT_EOF, /* 18 */ + XML_ERR_PEREF_IN_PROLOG, /* 19 */ + XML_ERR_PEREF_IN_EPILOG, /* 20 */ + XML_ERR_PEREF_IN_INT_SUBSET, /* 21 */ + XML_ERR_ENTITYREF_NO_NAME, /* 22 */ + XML_ERR_ENTITYREF_SEMICOL_MISSING, /* 23 */ + XML_ERR_PEREF_NO_NAME, /* 24 */ + XML_ERR_PEREF_SEMICOL_MISSING, /* 25 */ + XML_ERR_UNDECLARED_ENTITY, /* 26 */ + XML_WAR_UNDECLARED_ENTITY, /* 27 */ + XML_ERR_UNPARSED_ENTITY, /* 28 */ + XML_ERR_ENTITY_IS_EXTERNAL, /* 29 */ + XML_ERR_ENTITY_IS_PARAMETER, /* 30 */ + XML_ERR_UNKNOWN_ENCODING, /* 31 */ + XML_ERR_UNSUPPORTED_ENCODING, /* 32 */ + XML_ERR_STRING_NOT_STARTED, /* 33 */ + XML_ERR_STRING_NOT_CLOSED, /* 34 */ + XML_ERR_NS_DECL_ERROR, /* 35 */ + XML_ERR_ENTITY_NOT_STARTED, /* 36 */ + XML_ERR_ENTITY_NOT_FINISHED, /* 37 */ + XML_ERR_LT_IN_ATTRIBUTE, /* 38 */ + XML_ERR_ATTRIBUTE_NOT_STARTED, /* 39 */ + XML_ERR_ATTRIBUTE_NOT_FINISHED, /* 40 */ + XML_ERR_ATTRIBUTE_WITHOUT_VALUE, /* 41 */ + XML_ERR_ATTRIBUTE_REDEFINED, /* 42 */ + XML_ERR_LITERAL_NOT_STARTED, /* 43 */ + XML_ERR_LITERAL_NOT_FINISHED, /* 44 */ + XML_ERR_COMMENT_NOT_FINISHED, /* 45 */ + XML_ERR_PI_NOT_STARTED, /* 46 */ + XML_ERR_PI_NOT_FINISHED, /* 47 */ + XML_ERR_NOTATION_NOT_STARTED, /* 48 */ + XML_ERR_NOTATION_NOT_FINISHED, /* 49 */ + XML_ERR_ATTLIST_NOT_STARTED, /* 50 */ + XML_ERR_ATTLIST_NOT_FINISHED, /* 51 */ + XML_ERR_MIXED_NOT_STARTED, /* 52 */ + XML_ERR_MIXED_NOT_FINISHED, /* 53 */ + XML_ERR_ELEMCONTENT_NOT_STARTED, /* 54 */ + XML_ERR_ELEMCONTENT_NOT_FINISHED, /* 55 */ + XML_ERR_XMLDECL_NOT_STARTED, /* 56 */ + XML_ERR_XMLDECL_NOT_FINISHED, /* 57 */ + XML_ERR_CONDSEC_NOT_STARTED, /* 58 */ + XML_ERR_CONDSEC_NOT_FINISHED, /* 59 */ + XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 60 */ + XML_ERR_DOCTYPE_NOT_FINISHED, /* 61 */ + XML_ERR_MISPLACED_CDATA_END, /* 62 */ + XML_ERR_CDATA_NOT_FINISHED, /* 63 */ + XML_ERR_RESERVED_XML_NAME, /* 64 */ + XML_ERR_SPACE_REQUIRED, /* 65 */ + XML_ERR_SEPARATOR_REQUIRED, /* 66 */ + XML_ERR_NMTOKEN_REQUIRED, /* 67 */ + XML_ERR_NAME_REQUIRED, /* 68 */ + XML_ERR_PCDATA_REQUIRED, /* 69 */ + XML_ERR_URI_REQUIRED, /* 70 */ + XML_ERR_PUBID_REQUIRED, /* 71 */ + XML_ERR_LT_REQUIRED, /* 72 */ + XML_ERR_GT_REQUIRED, /* 73 */ + XML_ERR_LTSLASH_REQUIRED, /* 74 */ + XML_ERR_EQUAL_REQUIRED, /* 75 */ + XML_ERR_TAG_NAME_MISMATCH, /* 76 */ + XML_ERR_TAG_NOT_FINISHED, /* 77 */ + XML_ERR_STANDALONE_VALUE, /* 78 */ + XML_ERR_ENCODING_NAME, /* 79 */ + XML_ERR_HYPHEN_IN_COMMENT, /* 80 */ + XML_ERR_INVALID_ENCODING, /* 81 */ + XML_ERR_EXT_ENTITY_STANDALONE, /* 82 */ + XML_ERR_CONDSEC_INVALID, /* 83 */ + XML_ERR_VALUE_REQUIRED, /* 84 */ + XML_ERR_NOT_WELL_BALANCED, /* 85 */ + XML_ERR_EXTRA_CONTENT, /* 86 */ + XML_ERR_ENTITY_CHAR_ERROR, /* 87 */ + XML_ERR_ENTITY_PE_INTERNAL, /* 88 */ + XML_ERR_ENTITY_LOOP, /* 89 */ + XML_ERR_ENTITY_BOUNDARY, /* 90 */ + XML_ERR_INVALID_URI, /* 91 */ + XML_ERR_URI_FRAGMENT, /* 92 */ + XML_WAR_CATALOG_PI, /* 93 */ + XML_ERR_NO_DTD, /* 94 */ + XML_ERR_CONDSEC_INVALID_KEYWORD, /* 95 */ + XML_ERR_VERSION_MISSING, /* 96 */ + XML_WAR_UNKNOWN_VERSION, /* 97 */ + XML_WAR_LANG_VALUE, /* 98 */ + XML_WAR_NS_URI, /* 99 */ + XML_WAR_NS_URI_RELATIVE, /* 100 */ + XML_ERR_MISSING_ENCODING, /* 101 */ + XML_WAR_SPACE_VALUE, /* 102 */ + XML_ERR_NOT_STANDALONE, /* 103 */ + XML_ERR_ENTITY_PROCESSING, /* 104 */ + XML_ERR_NOTATION_PROCESSING, /* 105 */ + XML_WAR_NS_COLUMN, /* 106 */ + XML_WAR_ENTITY_REDEFINED, /* 107 */ + XML_ERR_UNKNOWN_VERSION, /* 108 */ + XML_ERR_VERSION_MISMATCH, /* 109 */ + XML_ERR_NAME_TOO_LONG, /* 110 */ + XML_ERR_USER_STOP, /* 111 */ + XML_ERR_COMMENT_ABRUPTLY_ENDED, /* 112 */ + XML_WAR_ENCODING_MISMATCH, /* 113 */ + XML_ERR_RESOURCE_LIMIT, /* 114 */ + XML_ERR_ARGUMENT, /* 115 */ + XML_ERR_SYSTEM, /* 116 */ + XML_ERR_REDECL_PREDEF_ENTITY, /* 117 */ + XML_ERR_INT_SUBSET_NOT_FINISHED, /* 118 */ + XML_NS_ERR_XML_NAMESPACE = 200, + XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */ + XML_NS_ERR_QNAME, /* 202 */ + XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */ + XML_NS_ERR_EMPTY, /* 204 */ + XML_NS_ERR_COLON, /* 205 */ + XML_DTD_ATTRIBUTE_DEFAULT = 500, + XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */ + XML_DTD_ATTRIBUTE_VALUE, /* 502 */ + XML_DTD_CONTENT_ERROR, /* 503 */ + XML_DTD_CONTENT_MODEL, /* 504 */ + XML_DTD_CONTENT_NOT_DETERMINIST, /* 505 */ + XML_DTD_DIFFERENT_PREFIX, /* 506 */ + XML_DTD_ELEM_DEFAULT_NAMESPACE, /* 507 */ + XML_DTD_ELEM_NAMESPACE, /* 508 */ + XML_DTD_ELEM_REDEFINED, /* 509 */ + XML_DTD_EMPTY_NOTATION, /* 510 */ + XML_DTD_ENTITY_TYPE, /* 511 */ + XML_DTD_ID_FIXED, /* 512 */ + XML_DTD_ID_REDEFINED, /* 513 */ + XML_DTD_ID_SUBSET, /* 514 */ + XML_DTD_INVALID_CHILD, /* 515 */ + XML_DTD_INVALID_DEFAULT, /* 516 */ + XML_DTD_LOAD_ERROR, /* 517 */ + XML_DTD_MISSING_ATTRIBUTE, /* 518 */ + XML_DTD_MIXED_CORRUPT, /* 519 */ + XML_DTD_MULTIPLE_ID, /* 520 */ + XML_DTD_NO_DOC, /* 521 */ + XML_DTD_NO_DTD, /* 522 */ + XML_DTD_NO_ELEM_NAME, /* 523 */ + XML_DTD_NO_PREFIX, /* 524 */ + XML_DTD_NO_ROOT, /* 525 */ + XML_DTD_NOTATION_REDEFINED, /* 526 */ + XML_DTD_NOTATION_VALUE, /* 527 */ + XML_DTD_NOT_EMPTY, /* 528 */ + XML_DTD_NOT_PCDATA, /* 529 */ + XML_DTD_NOT_STANDALONE, /* 530 */ + XML_DTD_ROOT_NAME, /* 531 */ + XML_DTD_STANDALONE_WHITE_SPACE, /* 532 */ + XML_DTD_UNKNOWN_ATTRIBUTE, /* 533 */ + XML_DTD_UNKNOWN_ELEM, /* 534 */ + XML_DTD_UNKNOWN_ENTITY, /* 535 */ + XML_DTD_UNKNOWN_ID, /* 536 */ + XML_DTD_UNKNOWN_NOTATION, /* 537 */ + XML_DTD_STANDALONE_DEFAULTED, /* 538 */ + XML_DTD_XMLID_VALUE, /* 539 */ + XML_DTD_XMLID_TYPE, /* 540 */ + XML_DTD_DUP_TOKEN, /* 541 */ + XML_HTML_STRUCURE_ERROR = 800, + XML_HTML_UNKNOWN_TAG, /* 801 */ + XML_HTML_INCORRECTLY_OPENED_COMMENT, /* 802 */ + XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000, + XML_RNGP_ATTR_CONFLICT, /* 1001 */ + XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */ + XML_RNGP_ATTRIBUTE_CONTENT, /* 1003 */ + XML_RNGP_ATTRIBUTE_EMPTY, /* 1004 */ + XML_RNGP_ATTRIBUTE_NOOP, /* 1005 */ + XML_RNGP_CHOICE_CONTENT, /* 1006 */ + XML_RNGP_CHOICE_EMPTY, /* 1007 */ + XML_RNGP_CREATE_FAILURE, /* 1008 */ + XML_RNGP_DATA_CONTENT, /* 1009 */ + XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, /* 1010 */ + XML_RNGP_DEFINE_CREATE_FAILED, /* 1011 */ + XML_RNGP_DEFINE_EMPTY, /* 1012 */ + XML_RNGP_DEFINE_MISSING, /* 1013 */ + XML_RNGP_DEFINE_NAME_MISSING, /* 1014 */ + XML_RNGP_ELEM_CONTENT_EMPTY, /* 1015 */ + XML_RNGP_ELEM_CONTENT_ERROR, /* 1016 */ + XML_RNGP_ELEMENT_EMPTY, /* 1017 */ + XML_RNGP_ELEMENT_CONTENT, /* 1018 */ + XML_RNGP_ELEMENT_NAME, /* 1019 */ + XML_RNGP_ELEMENT_NO_CONTENT, /* 1020 */ + XML_RNGP_ELEM_TEXT_CONFLICT, /* 1021 */ + XML_RNGP_EMPTY, /* 1022 */ + XML_RNGP_EMPTY_CONSTRUCT, /* 1023 */ + XML_RNGP_EMPTY_CONTENT, /* 1024 */ + XML_RNGP_EMPTY_NOT_EMPTY, /* 1025 */ + XML_RNGP_ERROR_TYPE_LIB, /* 1026 */ + XML_RNGP_EXCEPT_EMPTY, /* 1027 */ + XML_RNGP_EXCEPT_MISSING, /* 1028 */ + XML_RNGP_EXCEPT_MULTIPLE, /* 1029 */ + XML_RNGP_EXCEPT_NO_CONTENT, /* 1030 */ + XML_RNGP_EXTERNALREF_EMTPY, /* 1031 */ + XML_RNGP_EXTERNAL_REF_FAILURE, /* 1032 */ + XML_RNGP_EXTERNALREF_RECURSE, /* 1033 */ + XML_RNGP_FORBIDDEN_ATTRIBUTE, /* 1034 */ + XML_RNGP_FOREIGN_ELEMENT, /* 1035 */ + XML_RNGP_GRAMMAR_CONTENT, /* 1036 */ + XML_RNGP_GRAMMAR_EMPTY, /* 1037 */ + XML_RNGP_GRAMMAR_MISSING, /* 1038 */ + XML_RNGP_GRAMMAR_NO_START, /* 1039 */ + XML_RNGP_GROUP_ATTR_CONFLICT, /* 1040 */ + XML_RNGP_HREF_ERROR, /* 1041 */ + XML_RNGP_INCLUDE_EMPTY, /* 1042 */ + XML_RNGP_INCLUDE_FAILURE, /* 1043 */ + XML_RNGP_INCLUDE_RECURSE, /* 1044 */ + XML_RNGP_INTERLEAVE_ADD, /* 1045 */ + XML_RNGP_INTERLEAVE_CREATE_FAILED, /* 1046 */ + XML_RNGP_INTERLEAVE_EMPTY, /* 1047 */ + XML_RNGP_INTERLEAVE_NO_CONTENT, /* 1048 */ + XML_RNGP_INVALID_DEFINE_NAME, /* 1049 */ + XML_RNGP_INVALID_URI, /* 1050 */ + XML_RNGP_INVALID_VALUE, /* 1051 */ + XML_RNGP_MISSING_HREF, /* 1052 */ + XML_RNGP_NAME_MISSING, /* 1053 */ + XML_RNGP_NEED_COMBINE, /* 1054 */ + XML_RNGP_NOTALLOWED_NOT_EMPTY, /* 1055 */ + XML_RNGP_NSNAME_ATTR_ANCESTOR, /* 1056 */ + XML_RNGP_NSNAME_NO_NS, /* 1057 */ + XML_RNGP_PARAM_FORBIDDEN, /* 1058 */ + XML_RNGP_PARAM_NAME_MISSING, /* 1059 */ + XML_RNGP_PARENTREF_CREATE_FAILED, /* 1060 */ + XML_RNGP_PARENTREF_NAME_INVALID, /* 1061 */ + XML_RNGP_PARENTREF_NO_NAME, /* 1062 */ + XML_RNGP_PARENTREF_NO_PARENT, /* 1063 */ + XML_RNGP_PARENTREF_NOT_EMPTY, /* 1064 */ + XML_RNGP_PARSE_ERROR, /* 1065 */ + XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, /* 1066 */ + XML_RNGP_PAT_ATTR_ATTR, /* 1067 */ + XML_RNGP_PAT_ATTR_ELEM, /* 1068 */ + XML_RNGP_PAT_DATA_EXCEPT_ATTR, /* 1069 */ + XML_RNGP_PAT_DATA_EXCEPT_ELEM, /* 1070 */ + XML_RNGP_PAT_DATA_EXCEPT_EMPTY, /* 1071 */ + XML_RNGP_PAT_DATA_EXCEPT_GROUP, /* 1072 */ + XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, /* 1073 */ + XML_RNGP_PAT_DATA_EXCEPT_LIST, /* 1074 */ + XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, /* 1075 */ + XML_RNGP_PAT_DATA_EXCEPT_REF, /* 1076 */ + XML_RNGP_PAT_DATA_EXCEPT_TEXT, /* 1077 */ + XML_RNGP_PAT_LIST_ATTR, /* 1078 */ + XML_RNGP_PAT_LIST_ELEM, /* 1079 */ + XML_RNGP_PAT_LIST_INTERLEAVE, /* 1080 */ + XML_RNGP_PAT_LIST_LIST, /* 1081 */ + XML_RNGP_PAT_LIST_REF, /* 1082 */ + XML_RNGP_PAT_LIST_TEXT, /* 1083 */ + XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, /* 1084 */ + XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, /* 1085 */ + XML_RNGP_PAT_ONEMORE_GROUP_ATTR, /* 1086 */ + XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, /* 1087 */ + XML_RNGP_PAT_START_ATTR, /* 1088 */ + XML_RNGP_PAT_START_DATA, /* 1089 */ + XML_RNGP_PAT_START_EMPTY, /* 1090 */ + XML_RNGP_PAT_START_GROUP, /* 1091 */ + XML_RNGP_PAT_START_INTERLEAVE, /* 1092 */ + XML_RNGP_PAT_START_LIST, /* 1093 */ + XML_RNGP_PAT_START_ONEMORE, /* 1094 */ + XML_RNGP_PAT_START_TEXT, /* 1095 */ + XML_RNGP_PAT_START_VALUE, /* 1096 */ + XML_RNGP_PREFIX_UNDEFINED, /* 1097 */ + XML_RNGP_REF_CREATE_FAILED, /* 1098 */ + XML_RNGP_REF_CYCLE, /* 1099 */ + XML_RNGP_REF_NAME_INVALID, /* 1100 */ + XML_RNGP_REF_NO_DEF, /* 1101 */ + XML_RNGP_REF_NO_NAME, /* 1102 */ + XML_RNGP_REF_NOT_EMPTY, /* 1103 */ + XML_RNGP_START_CHOICE_AND_INTERLEAVE, /* 1104 */ + XML_RNGP_START_CONTENT, /* 1105 */ + XML_RNGP_START_EMPTY, /* 1106 */ + XML_RNGP_START_MISSING, /* 1107 */ + XML_RNGP_TEXT_EXPECTED, /* 1108 */ + XML_RNGP_TEXT_HAS_CHILD, /* 1109 */ + XML_RNGP_TYPE_MISSING, /* 1110 */ + XML_RNGP_TYPE_NOT_FOUND, /* 1111 */ + XML_RNGP_TYPE_VALUE, /* 1112 */ + XML_RNGP_UNKNOWN_ATTRIBUTE, /* 1113 */ + XML_RNGP_UNKNOWN_COMBINE, /* 1114 */ + XML_RNGP_UNKNOWN_CONSTRUCT, /* 1115 */ + XML_RNGP_UNKNOWN_TYPE_LIB, /* 1116 */ + XML_RNGP_URI_FRAGMENT, /* 1117 */ + XML_RNGP_URI_NOT_ABSOLUTE, /* 1118 */ + XML_RNGP_VALUE_EMPTY, /* 1119 */ + XML_RNGP_VALUE_NO_CONTENT, /* 1120 */ + XML_RNGP_XMLNS_NAME, /* 1121 */ + XML_RNGP_XML_NS, /* 1122 */ + XML_XPATH_EXPRESSION_OK = 1200, + XML_XPATH_NUMBER_ERROR, /* 1201 */ + XML_XPATH_UNFINISHED_LITERAL_ERROR, /* 1202 */ + XML_XPATH_START_LITERAL_ERROR, /* 1203 */ + XML_XPATH_VARIABLE_REF_ERROR, /* 1204 */ + XML_XPATH_UNDEF_VARIABLE_ERROR, /* 1205 */ + XML_XPATH_INVALID_PREDICATE_ERROR, /* 1206 */ + XML_XPATH_EXPR_ERROR, /* 1207 */ + XML_XPATH_UNCLOSED_ERROR, /* 1208 */ + XML_XPATH_UNKNOWN_FUNC_ERROR, /* 1209 */ + XML_XPATH_INVALID_OPERAND, /* 1210 */ + XML_XPATH_INVALID_TYPE, /* 1211 */ + XML_XPATH_INVALID_ARITY, /* 1212 */ + XML_XPATH_INVALID_CTXT_SIZE, /* 1213 */ + XML_XPATH_INVALID_CTXT_POSITION, /* 1214 */ + XML_XPATH_MEMORY_ERROR, /* 1215 */ + XML_XPTR_SYNTAX_ERROR, /* 1216 */ + XML_XPTR_RESOURCE_ERROR, /* 1217 */ + XML_XPTR_SUB_RESOURCE_ERROR, /* 1218 */ + XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */ + XML_XPATH_ENCODING_ERROR, /* 1220 */ + XML_XPATH_INVALID_CHAR_ERROR, /* 1221 */ + XML_TREE_INVALID_HEX = 1300, + XML_TREE_INVALID_DEC, /* 1301 */ + XML_TREE_UNTERMINATED_ENTITY, /* 1302 */ + XML_TREE_NOT_UTF8, /* 1303 */ + XML_SAVE_NOT_UTF8 = 1400, + XML_SAVE_CHAR_INVALID, /* 1401 */ + XML_SAVE_NO_DOCTYPE, /* 1402 */ + XML_SAVE_UNKNOWN_ENCODING, /* 1403 */ + XML_REGEXP_COMPILE_ERROR = 1450, + XML_IO_UNKNOWN = 1500, + XML_IO_EACCES, /* 1501 */ + XML_IO_EAGAIN, /* 1502 */ + XML_IO_EBADF, /* 1503 */ + XML_IO_EBADMSG, /* 1504 */ + XML_IO_EBUSY, /* 1505 */ + XML_IO_ECANCELED, /* 1506 */ + XML_IO_ECHILD, /* 1507 */ + XML_IO_EDEADLK, /* 1508 */ + XML_IO_EDOM, /* 1509 */ + XML_IO_EEXIST, /* 1510 */ + XML_IO_EFAULT, /* 1511 */ + XML_IO_EFBIG, /* 1512 */ + XML_IO_EINPROGRESS, /* 1513 */ + XML_IO_EINTR, /* 1514 */ + XML_IO_EINVAL, /* 1515 */ + XML_IO_EIO, /* 1516 */ + XML_IO_EISDIR, /* 1517 */ + XML_IO_EMFILE, /* 1518 */ + XML_IO_EMLINK, /* 1519 */ + XML_IO_EMSGSIZE, /* 1520 */ + XML_IO_ENAMETOOLONG, /* 1521 */ + XML_IO_ENFILE, /* 1522 */ + XML_IO_ENODEV, /* 1523 */ + XML_IO_ENOENT, /* 1524 */ + XML_IO_ENOEXEC, /* 1525 */ + XML_IO_ENOLCK, /* 1526 */ + XML_IO_ENOMEM, /* 1527 */ + XML_IO_ENOSPC, /* 1528 */ + XML_IO_ENOSYS, /* 1529 */ + XML_IO_ENOTDIR, /* 1530 */ + XML_IO_ENOTEMPTY, /* 1531 */ + XML_IO_ENOTSUP, /* 1532 */ + XML_IO_ENOTTY, /* 1533 */ + XML_IO_ENXIO, /* 1534 */ + XML_IO_EPERM, /* 1535 */ + XML_IO_EPIPE, /* 1536 */ + XML_IO_ERANGE, /* 1537 */ + XML_IO_EROFS, /* 1538 */ + XML_IO_ESPIPE, /* 1539 */ + XML_IO_ESRCH, /* 1540 */ + XML_IO_ETIMEDOUT, /* 1541 */ + XML_IO_EXDEV, /* 1542 */ + XML_IO_NETWORK_ATTEMPT, /* 1543 */ + XML_IO_ENCODER, /* 1544 */ + XML_IO_FLUSH, /* 1545 */ + XML_IO_WRITE, /* 1546 */ + XML_IO_NO_INPUT, /* 1547 */ + XML_IO_BUFFER_FULL, /* 1548 */ + XML_IO_LOAD_ERROR, /* 1549 */ + XML_IO_ENOTSOCK, /* 1550 */ + XML_IO_EISCONN, /* 1551 */ + XML_IO_ECONNREFUSED, /* 1552 */ + XML_IO_ENETUNREACH, /* 1553 */ + XML_IO_EADDRINUSE, /* 1554 */ + XML_IO_EALREADY, /* 1555 */ + XML_IO_EAFNOSUPPORT, /* 1556 */ + XML_IO_UNSUPPORTED_PROTOCOL, /* 1557 */ + XML_XINCLUDE_RECURSION=1600, + XML_XINCLUDE_PARSE_VALUE, /* 1601 */ + XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */ + XML_XINCLUDE_NO_HREF, /* 1603 */ + XML_XINCLUDE_NO_FALLBACK, /* 1604 */ + XML_XINCLUDE_HREF_URI, /* 1605 */ + XML_XINCLUDE_TEXT_FRAGMENT, /* 1606 */ + XML_XINCLUDE_TEXT_DOCUMENT, /* 1607 */ + XML_XINCLUDE_INVALID_CHAR, /* 1608 */ + XML_XINCLUDE_BUILD_FAILED, /* 1609 */ + XML_XINCLUDE_UNKNOWN_ENCODING, /* 1610 */ + XML_XINCLUDE_MULTIPLE_ROOT, /* 1611 */ + XML_XINCLUDE_XPTR_FAILED, /* 1612 */ + XML_XINCLUDE_XPTR_RESULT, /* 1613 */ + XML_XINCLUDE_INCLUDE_IN_INCLUDE, /* 1614 */ + XML_XINCLUDE_FALLBACKS_IN_INCLUDE, /* 1615 */ + XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, /* 1616 */ + XML_XINCLUDE_DEPRECATED_NS, /* 1617 */ + XML_XINCLUDE_FRAGMENT_ID, /* 1618 */ + XML_CATALOG_MISSING_ATTR = 1650, + XML_CATALOG_ENTRY_BROKEN, /* 1651 */ + XML_CATALOG_PREFER_VALUE, /* 1652 */ + XML_CATALOG_NOT_CATALOG, /* 1653 */ + XML_CATALOG_RECURSION, /* 1654 */ + XML_SCHEMAP_PREFIX_UNDEFINED = 1700, + XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, /* 1701 */ + XML_SCHEMAP_ATTRGRP_NONAME_NOREF, /* 1702 */ + XML_SCHEMAP_ATTR_NONAME_NOREF, /* 1703 */ + XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, /* 1704 */ + XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, /* 1705 */ + XML_SCHEMAP_ELEM_NONAME_NOREF, /* 1706 */ + XML_SCHEMAP_EXTENSION_NO_BASE, /* 1707 */ + XML_SCHEMAP_FACET_NO_VALUE, /* 1708 */ + XML_SCHEMAP_FAILED_BUILD_IMPORT, /* 1709 */ + XML_SCHEMAP_GROUP_NONAME_NOREF, /* 1710 */ + XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, /* 1711 */ + XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, /* 1712 */ + XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, /* 1713 */ + XML_SCHEMAP_INVALID_BOOLEAN, /* 1714 */ + XML_SCHEMAP_INVALID_ENUM, /* 1715 */ + XML_SCHEMAP_INVALID_FACET, /* 1716 */ + XML_SCHEMAP_INVALID_FACET_VALUE, /* 1717 */ + XML_SCHEMAP_INVALID_MAXOCCURS, /* 1718 */ + XML_SCHEMAP_INVALID_MINOCCURS, /* 1719 */ + XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, /* 1720 */ + XML_SCHEMAP_INVALID_WHITE_SPACE, /* 1721 */ + XML_SCHEMAP_NOATTR_NOREF, /* 1722 */ + XML_SCHEMAP_NOTATION_NO_NAME, /* 1723 */ + XML_SCHEMAP_NOTYPE_NOREF, /* 1724 */ + XML_SCHEMAP_REF_AND_SUBTYPE, /* 1725 */ + XML_SCHEMAP_RESTRICTION_NONAME_NOREF, /* 1726 */ + XML_SCHEMAP_SIMPLETYPE_NONAME, /* 1727 */ + XML_SCHEMAP_TYPE_AND_SUBTYPE, /* 1728 */ + XML_SCHEMAP_UNKNOWN_ALL_CHILD, /* 1729 */ + XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, /* 1730 */ + XML_SCHEMAP_UNKNOWN_ATTR_CHILD, /* 1731 */ + XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, /* 1732 */ + XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, /* 1733 */ + XML_SCHEMAP_UNKNOWN_BASE_TYPE, /* 1734 */ + XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, /* 1735 */ + XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, /* 1736 */ + XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, /* 1737 */ + XML_SCHEMAP_UNKNOWN_ELEM_CHILD, /* 1738 */ + XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, /* 1739 */ + XML_SCHEMAP_UNKNOWN_FACET_CHILD, /* 1740 */ + XML_SCHEMAP_UNKNOWN_FACET_TYPE, /* 1741 */ + XML_SCHEMAP_UNKNOWN_GROUP_CHILD, /* 1742 */ + XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, /* 1743 */ + XML_SCHEMAP_UNKNOWN_LIST_CHILD, /* 1744 */ + XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, /* 1745 */ + XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, /* 1746 */ + XML_SCHEMAP_UNKNOWN_REF, /* 1747 */ + XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, /* 1748 */ + XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, /* 1749 */ + XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, /* 1750 */ + XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, /* 1751 */ + XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, /* 1752 */ + XML_SCHEMAP_UNKNOWN_TYPE, /* 1753 */ + XML_SCHEMAP_UNKNOWN_UNION_CHILD, /* 1754 */ + XML_SCHEMAP_ELEM_DEFAULT_FIXED, /* 1755 */ + XML_SCHEMAP_REGEXP_INVALID, /* 1756 */ + XML_SCHEMAP_FAILED_LOAD, /* 1757 */ + XML_SCHEMAP_NOTHING_TO_PARSE, /* 1758 */ + XML_SCHEMAP_NOROOT, /* 1759 */ + XML_SCHEMAP_REDEFINED_GROUP, /* 1760 */ + XML_SCHEMAP_REDEFINED_TYPE, /* 1761 */ + XML_SCHEMAP_REDEFINED_ELEMENT, /* 1762 */ + XML_SCHEMAP_REDEFINED_ATTRGROUP, /* 1763 */ + XML_SCHEMAP_REDEFINED_ATTR, /* 1764 */ + XML_SCHEMAP_REDEFINED_NOTATION, /* 1765 */ + XML_SCHEMAP_FAILED_PARSE, /* 1766 */ + XML_SCHEMAP_UNKNOWN_PREFIX, /* 1767 */ + XML_SCHEMAP_DEF_AND_PREFIX, /* 1768 */ + XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, /* 1769 */ + XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, /* 1770 */ + XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, /* 1771 */ + XML_SCHEMAP_NOT_SCHEMA, /* 1772 */ + XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, /* 1773 */ + XML_SCHEMAP_INVALID_ATTR_USE, /* 1774 */ + XML_SCHEMAP_RECURSIVE, /* 1775 */ + XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, /* 1776 */ + XML_SCHEMAP_INVALID_ATTR_COMBINATION, /* 1777 */ + XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, /* 1778 */ + XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1779 */ + XML_SCHEMAP_INVALID_ATTR_NAME, /* 1780 */ + XML_SCHEMAP_REF_AND_CONTENT, /* 1781 */ + XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1782 */ + XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1783 */ + XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1784 */ + XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1785 */ + XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1786 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1787 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1788 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1789 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1790 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1791 */ + XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1792 */ + XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1793 */ + XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1794 */ + XML_SCHEMAP_SRC_IMPORT_3_1, /* 1795 */ + XML_SCHEMAP_SRC_IMPORT_3_2, /* 1796 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, /* 1797 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, /* 1798 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, /* 1799 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_3, /* 1800 */ + XML_SCHEMAV_NOROOT = 1801, + XML_SCHEMAV_UNDECLAREDELEM, /* 1802 */ + XML_SCHEMAV_NOTTOPLEVEL, /* 1803 */ + XML_SCHEMAV_MISSING, /* 1804 */ + XML_SCHEMAV_WRONGELEM, /* 1805 */ + XML_SCHEMAV_NOTYPE, /* 1806 */ + XML_SCHEMAV_NOROLLBACK, /* 1807 */ + XML_SCHEMAV_ISABSTRACT, /* 1808 */ + XML_SCHEMAV_NOTEMPTY, /* 1809 */ + XML_SCHEMAV_ELEMCONT, /* 1810 */ + XML_SCHEMAV_HAVEDEFAULT, /* 1811 */ + XML_SCHEMAV_NOTNILLABLE, /* 1812 */ + XML_SCHEMAV_EXTRACONTENT, /* 1813 */ + XML_SCHEMAV_INVALIDATTR, /* 1814 */ + XML_SCHEMAV_INVALIDELEM, /* 1815 */ + XML_SCHEMAV_NOTDETERMINIST, /* 1816 */ + XML_SCHEMAV_CONSTRUCT, /* 1817 */ + XML_SCHEMAV_INTERNAL, /* 1818 */ + XML_SCHEMAV_NOTSIMPLE, /* 1819 */ + XML_SCHEMAV_ATTRUNKNOWN, /* 1820 */ + XML_SCHEMAV_ATTRINVALID, /* 1821 */ + XML_SCHEMAV_VALUE, /* 1822 */ + XML_SCHEMAV_FACET, /* 1823 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, /* 1824 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, /* 1825 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, /* 1826 */ + XML_SCHEMAV_CVC_TYPE_3_1_1, /* 1827 */ + XML_SCHEMAV_CVC_TYPE_3_1_2, /* 1828 */ + XML_SCHEMAV_CVC_FACET_VALID, /* 1829 */ + XML_SCHEMAV_CVC_LENGTH_VALID, /* 1830 */ + XML_SCHEMAV_CVC_MINLENGTH_VALID, /* 1831 */ + XML_SCHEMAV_CVC_MAXLENGTH_VALID, /* 1832 */ + XML_SCHEMAV_CVC_MININCLUSIVE_VALID, /* 1833 */ + XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, /* 1834 */ + XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, /* 1835 */ + XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, /* 1836 */ + XML_SCHEMAV_CVC_TOTALDIGITS_VALID, /* 1837 */ + XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, /* 1838 */ + XML_SCHEMAV_CVC_PATTERN_VALID, /* 1839 */ + XML_SCHEMAV_CVC_ENUMERATION_VALID, /* 1840 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, /* 1841 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, /* 1842 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, /* 1843 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, /* 1844 */ + XML_SCHEMAV_CVC_ELT_1, /* 1845 */ + XML_SCHEMAV_CVC_ELT_2, /* 1846 */ + XML_SCHEMAV_CVC_ELT_3_1, /* 1847 */ + XML_SCHEMAV_CVC_ELT_3_2_1, /* 1848 */ + XML_SCHEMAV_CVC_ELT_3_2_2, /* 1849 */ + XML_SCHEMAV_CVC_ELT_4_1, /* 1850 */ + XML_SCHEMAV_CVC_ELT_4_2, /* 1851 */ + XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */ + XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */ + XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */ + XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */ + XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */ + XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */ + XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */ + XML_SCHEMAV_CVC_ELT_6, /* 1859 */ + XML_SCHEMAV_CVC_ELT_7, /* 1860 */ + XML_SCHEMAV_CVC_ATTRIBUTE_1, /* 1861 */ + XML_SCHEMAV_CVC_ATTRIBUTE_2, /* 1862 */ + XML_SCHEMAV_CVC_ATTRIBUTE_3, /* 1863 */ + XML_SCHEMAV_CVC_ATTRIBUTE_4, /* 1864 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, /* 1865 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, /* 1866 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, /* 1867 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_4, /* 1868 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, /* 1869 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, /* 1870 */ + XML_SCHEMAV_ELEMENT_CONTENT, /* 1871 */ + XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* 1872 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_1, /* 1873 */ + XML_SCHEMAV_CVC_AU, /* 1874 */ + XML_SCHEMAV_CVC_TYPE_1, /* 1875 */ + XML_SCHEMAV_CVC_TYPE_2, /* 1876 */ + XML_SCHEMAV_CVC_IDC, /* 1877 */ + XML_SCHEMAV_CVC_WILDCARD, /* 1878 */ + XML_SCHEMAV_MISC, /* 1879 */ + XML_XPTR_UNKNOWN_SCHEME = 1900, + XML_XPTR_CHILDSEQ_START, /* 1901 */ + XML_XPTR_EVAL_FAILED, /* 1902 */ + XML_XPTR_EXTRA_OBJECTS, /* 1903 */ + XML_C14N_CREATE_CTXT = 1950, + XML_C14N_REQUIRES_UTF8, /* 1951 */ + XML_C14N_CREATE_STACK, /* 1952 */ + XML_C14N_INVALID_NODE, /* 1953 */ + XML_C14N_UNKNOW_NODE, /* 1954 */ + XML_C14N_RELATIVE_NAMESPACE, /* 1955 */ + XML_FTP_PASV_ANSWER = 2000, + XML_FTP_EPSV_ANSWER, /* 2001 */ + XML_FTP_ACCNT, /* 2002 */ + XML_FTP_URL_SYNTAX, /* 2003 */ + XML_HTTP_URL_SYNTAX = 2020, + XML_HTTP_USE_IP, /* 2021 */ + XML_HTTP_UNKNOWN_HOST, /* 2022 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000, + XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */ + XML_SCHEMAP_SRC_RESOLVE, /* 3004 */ + XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */ + XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */ + XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */ + XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */ + XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */ + XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, /* 3016 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, /* 3017 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, /* 3018 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, /* 3019 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, /* 3020 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, /* 3021 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, /* 3022 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_1, /* 3023 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, /* 3024 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, /* 3025 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, /* 3026 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, /* 3027 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */ + XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */ + XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */ + XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */ + XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */ + XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, /* 3035 */ + XML_SCHEMAP_S4S_ATTR_MISSING, /* 3036 */ + XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, /* 3037 */ + XML_SCHEMAP_SRC_ELEMENT_1, /* 3038 */ + XML_SCHEMAP_SRC_ELEMENT_2_1, /* 3039 */ + XML_SCHEMAP_SRC_ELEMENT_2_2, /* 3040 */ + XML_SCHEMAP_SRC_ELEMENT_3, /* 3041 */ + XML_SCHEMAP_P_PROPS_CORRECT_1, /* 3042 */ + XML_SCHEMAP_P_PROPS_CORRECT_2_1, /* 3043 */ + XML_SCHEMAP_P_PROPS_CORRECT_2_2, /* 3044 */ + XML_SCHEMAP_E_PROPS_CORRECT_2, /* 3045 */ + XML_SCHEMAP_E_PROPS_CORRECT_3, /* 3046 */ + XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */ + XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */ + XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */ + XML_SCHEMAP_SRC_INCLUDE, /* 3050 */ + XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */ + XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */ + XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */ + XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */ + XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */ + XML_SCHEMAP_NO_XMLNS, /* 3056 */ + XML_SCHEMAP_NO_XSI, /* 3057 */ + XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, /* 3061 */ + XML_SCHEMAP_CVC_SIMPLE_TYPE, /* 3062 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_1, /* 3063 */ + XML_SCHEMAP_SRC_IMPORT_1_1, /* 3064 */ + XML_SCHEMAP_SRC_IMPORT_1_2, /* 3065 */ + XML_SCHEMAP_SRC_IMPORT_2, /* 3066 */ + XML_SCHEMAP_SRC_IMPORT_2_1, /* 3067 */ + XML_SCHEMAP_SRC_IMPORT_2_2, /* 3068 */ + XML_SCHEMAP_INTERNAL, /* 3069 non-W3C */ + XML_SCHEMAP_NOT_DETERMINISTIC, /* 3070 non-W3C */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1, /* 3071 */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, /* 3072 */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, /* 3073 */ + XML_SCHEMAP_MG_PROPS_CORRECT_1, /* 3074 */ + XML_SCHEMAP_MG_PROPS_CORRECT_2, /* 3075 */ + XML_SCHEMAP_SRC_CT_1, /* 3076 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */ + XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */ + XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */ + XML_SCHEMAP_C_PROPS_CORRECT, /* 3080 */ + XML_SCHEMAP_SRC_REDEFINE, /* 3081 */ + XML_SCHEMAP_SRC_IMPORT, /* 3082 */ + XML_SCHEMAP_WARN_SKIP_SCHEMA, /* 3083 */ + XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, /* 3084 */ + XML_SCHEMAP_WARN_ATTR_REDECL_PROH, /* 3085 */ + XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, /* 3085 */ + XML_SCHEMAP_AG_PROPS_CORRECT, /* 3086 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_2, /* 3087 */ + XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */ + XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */ + XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */ + XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */ + XML_SCHEMATRONV_REPORT, + XML_MODULE_OPEN = 4900, /* 4900 */ + XML_MODULE_CLOSE, /* 4901 */ + XML_CHECK_FOUND_ELEMENT = 5000, + XML_CHECK_FOUND_ATTRIBUTE, /* 5001 */ + XML_CHECK_FOUND_TEXT, /* 5002 */ + XML_CHECK_FOUND_CDATA, /* 5003 */ + XML_CHECK_FOUND_ENTITYREF, /* 5004 */ + XML_CHECK_FOUND_ENTITY, /* 5005 */ + XML_CHECK_FOUND_PI, /* 5006 */ + XML_CHECK_FOUND_COMMENT, /* 5007 */ + XML_CHECK_FOUND_DOCTYPE, /* 5008 */ + XML_CHECK_FOUND_FRAGMENT, /* 5009 */ + XML_CHECK_FOUND_NOTATION, /* 5010 */ + XML_CHECK_UNKNOWN_NODE, /* 5011 */ + XML_CHECK_ENTITY_TYPE, /* 5012 */ + XML_CHECK_NO_PARENT, /* 5013 */ + XML_CHECK_NO_DOC, /* 5014 */ + XML_CHECK_NO_NAME, /* 5015 */ + XML_CHECK_NO_ELEM, /* 5016 */ + XML_CHECK_WRONG_DOC, /* 5017 */ + XML_CHECK_NO_PREV, /* 5018 */ + XML_CHECK_WRONG_PREV, /* 5019 */ + XML_CHECK_NO_NEXT, /* 5020 */ + XML_CHECK_WRONG_NEXT, /* 5021 */ + XML_CHECK_NOT_DTD, /* 5022 */ + XML_CHECK_NOT_ATTR, /* 5023 */ + XML_CHECK_NOT_ATTR_DECL, /* 5024 */ + XML_CHECK_NOT_ELEM_DECL, /* 5025 */ + XML_CHECK_NOT_ENTITY_DECL, /* 5026 */ + XML_CHECK_NOT_NS_DECL, /* 5027 */ + XML_CHECK_NO_HREF, /* 5028 */ + XML_CHECK_WRONG_PARENT,/* 5029 */ + XML_CHECK_NS_SCOPE, /* 5030 */ + XML_CHECK_NS_ANCESTOR, /* 5031 */ + XML_CHECK_NOT_UTF8, /* 5032 */ + XML_CHECK_NO_DICT, /* 5033 */ + XML_CHECK_NOT_NCNAME, /* 5034 */ + XML_CHECK_OUTSIDE_DICT, /* 5035 */ + XML_CHECK_WRONG_NAME, /* 5036 */ + XML_CHECK_NAME_NOT_NULL, /* 5037 */ + XML_I18N_NO_NAME = 6000, + XML_I18N_NO_HANDLER, /* 6001 */ + XML_I18N_EXCESS_HANDLER, /* 6002 */ + XML_I18N_CONV_FAILED, /* 6003 */ + XML_I18N_NO_OUTPUT, /* 6004 */ + XML_BUF_OVERFLOW = 7000 +} xmlParserErrors; + +/** + * xmlGenericErrorFunc: + * @ctx: a parsing context + * @msg: the message + * @...: the extra arguments of the varargs to format the message + * + * Signature of the function to use when there is an error and + * no parsing or validity context available . + */ +typedef void (*xmlGenericErrorFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +/** + * xmlStructuredErrorFunc: + * @userData: user provided data for the error callback + * @error: the error being raised. + * + * Signature of the function to use when there is an error and + * the module handles the new error reporting mechanism. + */ +typedef void (*xmlStructuredErrorFunc) (void *userData, const xmlError *error); + +/** DOC_DISABLE */ +XML_DEPRECATED +XMLPUBFUN const xmlError *__xmlLastError(void); + +XMLPUBFUN xmlGenericErrorFunc *__xmlGenericError(void); +XMLPUBFUN void **__xmlGenericErrorContext(void); +XMLPUBFUN xmlStructuredErrorFunc *__xmlStructuredError(void); +XMLPUBFUN void **__xmlStructuredErrorContext(void); + +#ifndef XML_GLOBALS_NO_REDEFINITION + #define xmlLastError (*__xmlLastError()) + #define xmlGenericError (*__xmlGenericError()) + #define xmlGenericErrorContext (*__xmlGenericErrorContext()) + #define xmlStructuredError (*__xmlStructuredError()) + #define xmlStructuredErrorContext (*__xmlStructuredErrorContext()) +#endif +/** DOC_ENABLE */ + +/* + * Use the following function to reset the two global variables + * xmlGenericError and xmlGenericErrorContext. + */ +XMLPUBFUN void + xmlSetGenericErrorFunc (void *ctx, + xmlGenericErrorFunc handler); +XML_DEPRECATED +XMLPUBFUN void + xmlThrDefSetGenericErrorFunc(void *ctx, + xmlGenericErrorFunc handler); + +XMLPUBFUN void + xmlSetStructuredErrorFunc (void *ctx, + xmlStructuredErrorFunc handler); +XML_DEPRECATED +XMLPUBFUN void + xmlThrDefSetStructuredErrorFunc(void *ctx, + xmlStructuredErrorFunc handler); +/* + * Default message routines used by SAX and Valid context for error + * and warning reporting. + */ +XMLPUBFUN void + xmlParserError (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +XMLPUBFUN void + xmlParserWarning (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +XMLPUBFUN void + xmlParserValidityError (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +XMLPUBFUN void + xmlParserValidityWarning (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +/** DOC_DISABLE */ +struct _xmlParserInput; +/** DOC_ENABLE */ +XMLPUBFUN void + xmlParserPrintFileInfo (struct _xmlParserInput *input); +XMLPUBFUN void + xmlParserPrintFileContext (struct _xmlParserInput *input); +XMLPUBFUN void +xmlFormatError (const xmlError *err, + xmlGenericErrorFunc channel, + void *data); + +/* + * Extended error information routines + */ +XMLPUBFUN const xmlError * + xmlGetLastError (void); +XMLPUBFUN void + xmlResetLastError (void); +XMLPUBFUN const xmlError * + xmlCtxtGetLastError (void *ctx); +XMLPUBFUN void + xmlCtxtResetLastError (void *ctx); +XMLPUBFUN void + xmlResetError (xmlErrorPtr err); +XMLPUBFUN int + xmlCopyError (const xmlError *from, + xmlErrorPtr to); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_ERROR_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlexports.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlexports.h new file mode 100644 index 00000000..c4b74810 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlexports.h @@ -0,0 +1,96 @@ +/* + * Summary: macros for marking symbols as exportable/importable. + * Description: macros for marking symbols as exportable/importable. + * + * Copy: See Copyright for the status of this software. + */ + +#ifndef __XML_EXPORTS_H__ +#define __XML_EXPORTS_H__ + +/** DOC_DISABLE */ + +/* + * Symbol visibility + */ + +#if defined(_WIN32) || defined(__CYGWIN__) + #ifdef LIBXML_STATIC + #define XMLPUBLIC + #elif defined(IN_LIBXML) + #define XMLPUBLIC __declspec(dllexport) + #else + #define XMLPUBLIC __declspec(dllimport) + #endif +#else /* not Windows */ + #define XMLPUBLIC +#endif /* platform switch */ + +#define XMLPUBFUN XMLPUBLIC + +#define XMLPUBVAR XMLPUBLIC extern + +/* Compatibility */ +#define XMLCALL +#define XMLCDECL +#ifndef LIBXML_DLL_IMPORT + #define LIBXML_DLL_IMPORT XMLPUBVAR +#endif + +/* + * Attributes + */ + +#if !defined(__clang__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403) + #define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x))) +#else + #define LIBXML_ATTR_ALLOC_SIZE(x) +#endif + +#if __GNUC__ * 100 + __GNUC_MINOR__ >= 303 + #define LIBXML_ATTR_FORMAT(fmt,args) \ + __attribute__((__format__(__printf__,fmt,args))) +#else + #define LIBXML_ATTR_FORMAT(fmt,args) +#endif + +#ifndef XML_DEPRECATED + #if defined(IN_LIBXML) + #define XML_DEPRECATED + #elif __GNUC__ * 100 + __GNUC_MINOR__ >= 301 + #define XML_DEPRECATED __attribute__((deprecated)) + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + /* Available since Visual Studio 2005 */ + #define XML_DEPRECATED __declspec(deprecated) + #else + #define XML_DEPRECATED + #endif +#endif + +#ifndef XML_DEPRECATED_MEMBER + #if defined(IN_LIBXML) + #define XML_DEPRECATED_MEMBER + #elif __GNUC__ * 100 + __GNUC_MINOR__ >= 301 + #define XML_DEPRECATED_MEMBER __attribute__((deprecated)) + #else + #define XML_DEPRECATED_MEMBER + #endif +#endif + +/* + * Originally declared in xmlversion.h which is generated + */ + +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN void xmlCheckVersion(int version); + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_EXPORTS_H__ */ + + diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlmemory.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlmemory.h new file mode 100644 index 00000000..2b8c3aa8 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlmemory.h @@ -0,0 +1,188 @@ +/* + * Summary: interface for the memory allocator + * Description: provides interfaces for the memory allocator, + * including debugging capabilities. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __DEBUG_MEMORY_ALLOC__ +#define __DEBUG_MEMORY_ALLOC__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The XML memory wrapper support 4 basic overloadable functions. + */ +/** + * xmlFreeFunc: + * @mem: an already allocated block of memory + * + * Signature for a free() implementation. + */ +typedef void (*xmlFreeFunc)(void *mem); +/** + * xmlMallocFunc: + * @size: the size requested in bytes + * + * Signature for a malloc() implementation. + * + * Returns a pointer to the newly allocated block or NULL in case of error. + */ +typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) *xmlMallocFunc)(size_t size); + +/** + * xmlReallocFunc: + * @mem: an already allocated block of memory + * @size: the new size requested in bytes + * + * Signature for a realloc() implementation. + * + * Returns a pointer to the newly reallocated block or NULL in case of error. + */ +typedef void *(*xmlReallocFunc)(void *mem, size_t size); + +/** + * xmlStrdupFunc: + * @str: a zero terminated string + * + * Signature for an strdup() implementation. + * + * Returns the copy of the string or NULL in case of error. + */ +typedef char *(*xmlStrdupFunc)(const char *str); + +/* + * In general the memory allocation entry points are not kept + * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED + * - xmlMalloc + * - xmlMallocAtomic + * - xmlRealloc + * - xmlMemStrdup + * - xmlFree + */ +#ifdef LIBXML_THREAD_ALLOC_ENABLED + +/** DOC_DISABLE */ +XMLPUBFUN xmlMallocFunc *__xmlMalloc(void); +XMLPUBFUN xmlMallocFunc *__xmlMallocAtomic(void); +XMLPUBFUN xmlReallocFunc *__xmlRealloc(void); +XMLPUBFUN xmlFreeFunc *__xmlFree(void); +XMLPUBFUN xmlStrdupFunc *__xmlMemStrdup(void); + +#ifndef XML_GLOBALS_NO_REDEFINITION + #define xmlMalloc (*__xmlMalloc()) + #define xmlMallocAtomic (*__xmlMallocAtomic()) + #define xmlRealloc (*__xmlRealloc()) + #define xmlFree (*__xmlFree()) + #define xmlMemStrdup (*__xmlMemStrdup()) +#endif +/** DOC_ENABLE */ + +#else + XMLPUBVAR xmlMallocFunc xmlMalloc; + XMLPUBVAR xmlMallocFunc xmlMallocAtomic; + XMLPUBVAR xmlReallocFunc xmlRealloc; + XMLPUBVAR xmlFreeFunc xmlFree; + XMLPUBVAR xmlStrdupFunc xmlMemStrdup; +#endif + +/* + * The way to overload the existing functions. + * The xmlGc function have an extra entry for atomic block + * allocations useful for garbage collected memory allocators + */ +XMLPUBFUN int + xmlMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlReallocFunc reallocFunc, + xmlStrdupFunc strdupFunc); +XMLPUBFUN int + xmlMemGet (xmlFreeFunc *freeFunc, + xmlMallocFunc *mallocFunc, + xmlReallocFunc *reallocFunc, + xmlStrdupFunc *strdupFunc); +XML_DEPRECATED +XMLPUBFUN int + xmlGcMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlMallocFunc mallocAtomicFunc, + xmlReallocFunc reallocFunc, + xmlStrdupFunc strdupFunc); +XML_DEPRECATED +XMLPUBFUN int + xmlGcMemGet (xmlFreeFunc *freeFunc, + xmlMallocFunc *mallocFunc, + xmlMallocFunc *mallocAtomicFunc, + xmlReallocFunc *reallocFunc, + xmlStrdupFunc *strdupFunc); + +/* + * Initialization of the memory layer. + */ +XML_DEPRECATED +XMLPUBFUN int + xmlInitMemory (void); + +/* + * Cleanup of the memory layer. + */ +XML_DEPRECATED +XMLPUBFUN void + xmlCleanupMemory (void); +/* + * These are specific to the XML debug memory wrapper. + */ +XMLPUBFUN size_t + xmlMemSize (void *ptr); +XMLPUBFUN int + xmlMemUsed (void); +XMLPUBFUN int + xmlMemBlocks (void); +XML_DEPRECATED +XMLPUBFUN void + xmlMemDisplay (FILE *fp); +XML_DEPRECATED +XMLPUBFUN void + xmlMemDisplayLast(FILE *fp, long nbBytes); +XML_DEPRECATED +XMLPUBFUN void + xmlMemShow (FILE *fp, int nr); +XML_DEPRECATED +XMLPUBFUN void + xmlMemoryDump (void); +XMLPUBFUN void * + xmlMemMalloc (size_t size) LIBXML_ATTR_ALLOC_SIZE(1); +XMLPUBFUN void * + xmlMemRealloc (void *ptr,size_t size); +XMLPUBFUN void + xmlMemFree (void *ptr); +XMLPUBFUN char * + xmlMemoryStrdup (const char *str); +XML_DEPRECATED +XMLPUBFUN void * + xmlMallocLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1); +XML_DEPRECATED +XMLPUBFUN void * + xmlReallocLoc (void *ptr, size_t size, const char *file, int line); +XML_DEPRECATED +XMLPUBFUN void * + xmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1); +XML_DEPRECATED +XMLPUBFUN char * + xmlMemStrdupLoc (const char *str, const char *file, int line); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __DEBUG_MEMORY_ALLOC__ */ + diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlmodule.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlmodule.h new file mode 100644 index 00000000..5db55856 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlmodule.h @@ -0,0 +1,61 @@ +/* + * Summary: dynamic module loading + * Description: basic API for dynamic module loading, used by + * libexslt added in 2.6.17 + * + * Copy: See Copyright for the status of this software. + * + * Author: Joel W. Reed + */ + +#ifndef __XML_MODULE_H__ +#define __XML_MODULE_H__ + +#include + +#ifdef LIBXML_MODULES_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlModulePtr: + * + * A handle to a dynamically loaded module + */ +typedef struct _xmlModule xmlModule; +typedef xmlModule *xmlModulePtr; + +/** + * xmlModuleOption: + * + * enumeration of options that can be passed down to xmlModuleOpen() + */ +typedef enum { + XML_MODULE_LAZY = 1, /* lazy binding */ + XML_MODULE_LOCAL= 2 /* local binding */ +} xmlModuleOption; + +XML_DEPRECATED +XMLPUBFUN xmlModulePtr xmlModuleOpen (const char *filename, + int options); + +XML_DEPRECATED +XMLPUBFUN int xmlModuleSymbol (xmlModulePtr module, + const char* name, + void **result); + +XML_DEPRECATED +XMLPUBFUN int xmlModuleClose (xmlModulePtr module); + +XML_DEPRECATED +XMLPUBFUN int xmlModuleFree (xmlModulePtr module); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_MODULES_ENABLED */ + +#endif /*__XML_MODULE_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlreader.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlreader.h new file mode 100644 index 00000000..2344901d --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlreader.h @@ -0,0 +1,444 @@ +/* + * Summary: the XMLReader implementation + * Description: API of the XML streaming API based on C# interfaces. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XMLREADER_H__ +#define __XML_XMLREADER_H__ + +#include +#include +#include +#include +#ifdef LIBXML_RELAXNG_ENABLED +#include +#endif +#ifdef LIBXML_SCHEMAS_ENABLED +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlParserSeverities: + * + * How severe an error callback is when the per-reader error callback API + * is used. + */ +typedef enum { + XML_PARSER_SEVERITY_VALIDITY_WARNING = 1, + XML_PARSER_SEVERITY_VALIDITY_ERROR = 2, + XML_PARSER_SEVERITY_WARNING = 3, + XML_PARSER_SEVERITY_ERROR = 4 +} xmlParserSeverities; + +#ifdef LIBXML_READER_ENABLED + +/** + * xmlTextReaderMode: + * + * Internal state values for the reader. + */ +typedef enum { + XML_TEXTREADER_MODE_INITIAL = 0, + XML_TEXTREADER_MODE_INTERACTIVE = 1, + XML_TEXTREADER_MODE_ERROR = 2, + XML_TEXTREADER_MODE_EOF =3, + XML_TEXTREADER_MODE_CLOSED = 4, + XML_TEXTREADER_MODE_READING = 5 +} xmlTextReaderMode; + +/** + * xmlParserProperties: + * + * Some common options to use with xmlTextReaderSetParserProp, but it + * is better to use xmlParserOption and the xmlReaderNewxxx and + * xmlReaderForxxx APIs now. + */ +typedef enum { + XML_PARSER_LOADDTD = 1, + XML_PARSER_DEFAULTATTRS = 2, + XML_PARSER_VALIDATE = 3, + XML_PARSER_SUBST_ENTITIES = 4 +} xmlParserProperties; + +/** + * xmlReaderTypes: + * + * Predefined constants for the different types of nodes. + */ +typedef enum { + XML_READER_TYPE_NONE = 0, + XML_READER_TYPE_ELEMENT = 1, + XML_READER_TYPE_ATTRIBUTE = 2, + XML_READER_TYPE_TEXT = 3, + XML_READER_TYPE_CDATA = 4, + XML_READER_TYPE_ENTITY_REFERENCE = 5, + XML_READER_TYPE_ENTITY = 6, + XML_READER_TYPE_PROCESSING_INSTRUCTION = 7, + XML_READER_TYPE_COMMENT = 8, + XML_READER_TYPE_DOCUMENT = 9, + XML_READER_TYPE_DOCUMENT_TYPE = 10, + XML_READER_TYPE_DOCUMENT_FRAGMENT = 11, + XML_READER_TYPE_NOTATION = 12, + XML_READER_TYPE_WHITESPACE = 13, + XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14, + XML_READER_TYPE_END_ELEMENT = 15, + XML_READER_TYPE_END_ENTITY = 16, + XML_READER_TYPE_XML_DECLARATION = 17 +} xmlReaderTypes; + +/** + * xmlTextReader: + * + * Structure for an xmlReader context. + */ +typedef struct _xmlTextReader xmlTextReader; + +/** + * xmlTextReaderPtr: + * + * Pointer to an xmlReader context. + */ +typedef xmlTextReader *xmlTextReaderPtr; + +/* + * Constructors & Destructor + */ +XMLPUBFUN xmlTextReaderPtr + xmlNewTextReader (xmlParserInputBufferPtr input, + const char *URI); +XMLPUBFUN xmlTextReaderPtr + xmlNewTextReaderFilename(const char *URI); + +XMLPUBFUN void + xmlFreeTextReader (xmlTextReaderPtr reader); + +XMLPUBFUN int + xmlTextReaderSetup(xmlTextReaderPtr reader, + xmlParserInputBufferPtr input, const char *URL, + const char *encoding, int options); +XMLPUBFUN void + xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader, + unsigned maxAmpl); +XMLPUBFUN const xmlError * + xmlTextReaderGetLastError(xmlTextReaderPtr reader); + +/* + * Iterators + */ +XMLPUBFUN int + xmlTextReaderRead (xmlTextReaderPtr reader); + +#ifdef LIBXML_WRITER_ENABLED +XMLPUBFUN xmlChar * + xmlTextReaderReadInnerXml(xmlTextReaderPtr reader); + +XMLPUBFUN xmlChar * + xmlTextReaderReadOuterXml(xmlTextReaderPtr reader); +#endif + +XMLPUBFUN xmlChar * + xmlTextReaderReadString (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader); + +/* + * Attributes of the node + */ +XMLPUBFUN int + xmlTextReaderAttributeCount(xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderDepth (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderHasAttributes(xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderHasValue(xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderIsDefault (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderNodeType (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderQuoteChar (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderReadState (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader); + +XMLPUBFUN const xmlChar * + xmlTextReaderConstBaseUri (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * + xmlTextReaderConstLocalName (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * + xmlTextReaderConstName (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * + xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * + xmlTextReaderConstPrefix (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * + xmlTextReaderConstXmlLang (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * + xmlTextReaderConstString (xmlTextReaderPtr reader, + const xmlChar *str); +XMLPUBFUN const xmlChar * + xmlTextReaderConstValue (xmlTextReaderPtr reader); + +/* + * use the Const version of the routine for + * better performance and simpler code + */ +XMLPUBFUN xmlChar * + xmlTextReaderBaseUri (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * + xmlTextReaderLocalName (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * + xmlTextReaderName (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * + xmlTextReaderNamespaceUri(xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * + xmlTextReaderPrefix (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * + xmlTextReaderXmlLang (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * + xmlTextReaderValue (xmlTextReaderPtr reader); + +/* + * Methods of the XmlTextReader + */ +XMLPUBFUN int + xmlTextReaderClose (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * + xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader, + int no); +XMLPUBFUN xmlChar * + xmlTextReaderGetAttribute (xmlTextReaderPtr reader, + const xmlChar *name); +XMLPUBFUN xmlChar * + xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader, + const xmlChar *localName, + const xmlChar *namespaceURI); +XMLPUBFUN xmlParserInputBufferPtr + xmlTextReaderGetRemainder (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * + xmlTextReaderLookupNamespace(xmlTextReaderPtr reader, + const xmlChar *prefix); +XMLPUBFUN int + xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, + int no); +XMLPUBFUN int + xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, + const xmlChar *name); +XMLPUBFUN int + xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader, + const xmlChar *localName, + const xmlChar *namespaceURI); +XMLPUBFUN int + xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderMoveToElement (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderNormalization (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * + xmlTextReaderConstEncoding (xmlTextReaderPtr reader); + +/* + * Extensions + */ +XMLPUBFUN int + xmlTextReaderSetParserProp (xmlTextReaderPtr reader, + int prop, + int value); +XMLPUBFUN int + xmlTextReaderGetParserProp (xmlTextReaderPtr reader, + int prop); +XMLPUBFUN xmlNodePtr + xmlTextReaderCurrentNode (xmlTextReaderPtr reader); + +XMLPUBFUN int + xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader); + +XMLPUBFUN int + xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader); + +XMLPUBFUN xmlNodePtr + xmlTextReaderPreserve (xmlTextReaderPtr reader); +#ifdef LIBXML_PATTERN_ENABLED +XMLPUBFUN int + xmlTextReaderPreservePattern(xmlTextReaderPtr reader, + const xmlChar *pattern, + const xmlChar **namespaces); +#endif /* LIBXML_PATTERN_ENABLED */ +XMLPUBFUN xmlDocPtr + xmlTextReaderCurrentDoc (xmlTextReaderPtr reader); +XMLPUBFUN xmlNodePtr + xmlTextReaderExpand (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderNext (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderNextSibling (xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderIsValid (xmlTextReaderPtr reader); +#ifdef LIBXML_RELAXNG_ENABLED +XMLPUBFUN int + xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, + const char *rng); +XMLPUBFUN int + xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader, + xmlRelaxNGValidCtxtPtr ctxt, + int options); + +XMLPUBFUN int + xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, + xmlRelaxNGPtr schema); +#endif +#ifdef LIBXML_SCHEMAS_ENABLED +XMLPUBFUN int + xmlTextReaderSchemaValidate (xmlTextReaderPtr reader, + const char *xsd); +XMLPUBFUN int + xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader, + xmlSchemaValidCtxtPtr ctxt, + int options); +XMLPUBFUN int + xmlTextReaderSetSchema (xmlTextReaderPtr reader, + xmlSchemaPtr schema); +#endif +XMLPUBFUN const xmlChar * + xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader); +XMLPUBFUN int + xmlTextReaderStandalone (xmlTextReaderPtr reader); + + +/* + * Index lookup + */ +XMLPUBFUN long + xmlTextReaderByteConsumed (xmlTextReaderPtr reader); + +/* + * New more complete APIs for simpler creation and reuse of readers + */ +XMLPUBFUN xmlTextReaderPtr + xmlReaderWalker (xmlDocPtr doc); +XMLPUBFUN xmlTextReaderPtr + xmlReaderForDoc (const xmlChar * cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr + xmlReaderForFile (const char *filename, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr + xmlReaderForMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr + xmlReaderForFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr + xmlReaderForIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +XMLPUBFUN int + xmlReaderNewWalker (xmlTextReaderPtr reader, + xmlDocPtr doc); +XMLPUBFUN int + xmlReaderNewDoc (xmlTextReaderPtr reader, + const xmlChar * cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int + xmlReaderNewFile (xmlTextReaderPtr reader, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN int + xmlReaderNewMemory (xmlTextReaderPtr reader, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int + xmlReaderNewFd (xmlTextReaderPtr reader, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int + xmlReaderNewIO (xmlTextReaderPtr reader, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +/* + * Error handling extensions + */ +typedef void * xmlTextReaderLocatorPtr; + +/** + * xmlTextReaderErrorFunc: + * @arg: the user argument + * @msg: the message + * @severity: the severity of the error + * @locator: a locator indicating where the error occurred + * + * Signature of an error callback from a reader parser + */ +typedef void (*xmlTextReaderErrorFunc)(void *arg, + const char *msg, + xmlParserSeverities severity, + xmlTextReaderLocatorPtr locator); +XMLPUBFUN int + xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator); +XMLPUBFUN xmlChar * + xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator); +XMLPUBFUN void + xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, + xmlTextReaderErrorFunc f, + void *arg); +XMLPUBFUN void + xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, + xmlStructuredErrorFunc f, + void *arg); +XMLPUBFUN void + xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, + xmlTextReaderErrorFunc *f, + void **arg); + +XMLPUBFUN void + xmlTextReaderSetResourceLoader(xmlTextReaderPtr reader, + xmlResourceLoader loader, + void *data); + +#endif /* LIBXML_READER_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_XMLREADER_H__ */ + diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlregexp.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlregexp.h new file mode 100644 index 00000000..f7e10c32 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlregexp.h @@ -0,0 +1,116 @@ +/* + * Summary: regular expressions handling + * Description: basic API for libxml regular expressions handling used + * for XML Schemas and validation. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_REGEXP_H__ +#define __XML_REGEXP_H__ + +#include +#include +#include + +#ifdef LIBXML_REGEXP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlRegexpPtr: + * + * A libxml regular expression, they can actually be far more complex + * thank the POSIX regex expressions. + */ +typedef struct _xmlRegexp xmlRegexp; +typedef xmlRegexp *xmlRegexpPtr; + +/** + * xmlRegExecCtxtPtr: + * + * A libxml progressive regular expression evaluation context + */ +typedef struct _xmlRegExecCtxt xmlRegExecCtxt; +typedef xmlRegExecCtxt *xmlRegExecCtxtPtr; + +/* + * The POSIX like API + */ +XMLPUBFUN xmlRegexpPtr + xmlRegexpCompile (const xmlChar *regexp); +XMLPUBFUN void xmlRegFreeRegexp(xmlRegexpPtr regexp); +XMLPUBFUN int + xmlRegexpExec (xmlRegexpPtr comp, + const xmlChar *value); +XML_DEPRECATED +XMLPUBFUN void + xmlRegexpPrint (FILE *output, + xmlRegexpPtr regexp); +XMLPUBFUN int + xmlRegexpIsDeterminist(xmlRegexpPtr comp); + +/** + * xmlRegExecCallbacks: + * @exec: the regular expression context + * @token: the current token string + * @transdata: transition data + * @inputdata: input data + * + * Callback function when doing a transition in the automata + */ +typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec, + const xmlChar *token, + void *transdata, + void *inputdata); + +/* + * The progressive API + */ +XML_DEPRECATED +XMLPUBFUN xmlRegExecCtxtPtr + xmlRegNewExecCtxt (xmlRegexpPtr comp, + xmlRegExecCallbacks callback, + void *data); +XML_DEPRECATED +XMLPUBFUN void + xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec); +XML_DEPRECATED +XMLPUBFUN int + xmlRegExecPushString(xmlRegExecCtxtPtr exec, + const xmlChar *value, + void *data); +XML_DEPRECATED +XMLPUBFUN int + xmlRegExecPushString2(xmlRegExecCtxtPtr exec, + const xmlChar *value, + const xmlChar *value2, + void *data); + +XML_DEPRECATED +XMLPUBFUN int + xmlRegExecNextValues(xmlRegExecCtxtPtr exec, + int *nbval, + int *nbneg, + xmlChar **values, + int *terminal); +XML_DEPRECATED +XMLPUBFUN int + xmlRegExecErrInfo (xmlRegExecCtxtPtr exec, + const xmlChar **string, + int *nbval, + int *nbneg, + xmlChar **values, + int *terminal); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_REGEXP_ENABLED */ + +#endif /*__XML_REGEXP_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlsave.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlsave.h new file mode 100644 index 00000000..91d6ef9f --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlsave.h @@ -0,0 +1,111 @@ +/* + * Summary: the XML document serializer + * Description: API to save document or subtree of document + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XMLSAVE_H__ +#define __XML_XMLSAVE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_OUTPUT_ENABLED +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlSaveOption: + * + * This is the set of XML save options that can be passed down + * to the xmlSaveToFd() and similar calls. + */ +typedef enum { + XML_SAVE_FORMAT = 1<<0, /* format save output */ + XML_SAVE_NO_DECL = 1<<1, /* drop the xml declaration */ + XML_SAVE_NO_EMPTY = 1<<2, /* no empty tags */ + XML_SAVE_NO_XHTML = 1<<3, /* disable XHTML1 specific rules */ + XML_SAVE_XHTML = 1<<4, /* force XHTML1 specific rules */ + XML_SAVE_AS_XML = 1<<5, /* force XML serialization on HTML doc */ + XML_SAVE_AS_HTML = 1<<6, /* force HTML serialization on XML doc */ + XML_SAVE_WSNONSIG = 1<<7, /* format with non-significant whitespace */ + /* Available since 2.14.0 */ + XML_SAVE_EMPTY = 1<<8, /* force empty tags, overriding global */ + XML_SAVE_NO_INDENT = 1<<9, /* disable indenting */ + XML_SAVE_INDENT = 1<<10 /* force indenting, overriding global */ +} xmlSaveOption; + + +typedef struct _xmlSaveCtxt xmlSaveCtxt; +typedef xmlSaveCtxt *xmlSaveCtxtPtr; + +XMLPUBFUN xmlSaveCtxtPtr + xmlSaveToFd (int fd, + const char *encoding, + int options); +XMLPUBFUN xmlSaveCtxtPtr + xmlSaveToFilename (const char *filename, + const char *encoding, + int options); + +XMLPUBFUN xmlSaveCtxtPtr + xmlSaveToBuffer (xmlBufferPtr buffer, + const char *encoding, + int options); + +XMLPUBFUN xmlSaveCtxtPtr + xmlSaveToIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, + const char *encoding, + int options); + +XMLPUBFUN long + xmlSaveDoc (xmlSaveCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN long + xmlSaveTree (xmlSaveCtxtPtr ctxt, + xmlNodePtr node); + +XMLPUBFUN int + xmlSaveFlush (xmlSaveCtxtPtr ctxt); +XMLPUBFUN int + xmlSaveClose (xmlSaveCtxtPtr ctxt); +XMLPUBFUN xmlParserErrors + xmlSaveFinish (xmlSaveCtxtPtr ctxt); +XMLPUBFUN int + xmlSaveSetIndentString (xmlSaveCtxtPtr ctxt, + const char *indent); +XML_DEPRECATED +XMLPUBFUN int + xmlSaveSetEscape (xmlSaveCtxtPtr ctxt, + xmlCharEncodingOutputFunc escape); +XML_DEPRECATED +XMLPUBFUN int + xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt, + xmlCharEncodingOutputFunc escape); + +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefIndentTreeOutput(int v); +XML_DEPRECATED +XMLPUBFUN const char * + xmlThrDefTreeIndentString(const char * v); +XML_DEPRECATED +XMLPUBFUN int + xmlThrDefSaveNoEmptyTags(int v); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_OUTPUT_ENABLED */ +#endif /* __XML_XMLSAVE_H__ */ + + diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlschemas.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlschemas.h new file mode 100644 index 00000000..78073cd2 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlschemas.h @@ -0,0 +1,254 @@ +/* + * Summary: incomplete XML Schemas structure implementation + * Description: interface to the XML Schemas handling and schema validity + * checking, it is incomplete right now. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_H__ +#define __XML_SCHEMA_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This error codes are obsolete; not used any more. + */ +typedef enum { + XML_SCHEMAS_ERR_OK = 0, + XML_SCHEMAS_ERR_NOROOT = 1, + XML_SCHEMAS_ERR_UNDECLAREDELEM, + XML_SCHEMAS_ERR_NOTTOPLEVEL, + XML_SCHEMAS_ERR_MISSING, + XML_SCHEMAS_ERR_WRONGELEM, + XML_SCHEMAS_ERR_NOTYPE, + XML_SCHEMAS_ERR_NOROLLBACK, + XML_SCHEMAS_ERR_ISABSTRACT, + XML_SCHEMAS_ERR_NOTEMPTY, + XML_SCHEMAS_ERR_ELEMCONT, + XML_SCHEMAS_ERR_HAVEDEFAULT, + XML_SCHEMAS_ERR_NOTNILLABLE, + XML_SCHEMAS_ERR_EXTRACONTENT, + XML_SCHEMAS_ERR_INVALIDATTR, + XML_SCHEMAS_ERR_INVALIDELEM, + XML_SCHEMAS_ERR_NOTDETERMINIST, + XML_SCHEMAS_ERR_CONSTRUCT, + XML_SCHEMAS_ERR_INTERNAL, + XML_SCHEMAS_ERR_NOTSIMPLE, + XML_SCHEMAS_ERR_ATTRUNKNOWN, + XML_SCHEMAS_ERR_ATTRINVALID, + XML_SCHEMAS_ERR_VALUE, + XML_SCHEMAS_ERR_FACET, + XML_SCHEMAS_ERR_, + XML_SCHEMAS_ERR_XXX +} xmlSchemaValidError; + +/* +* ATTENTION: Change xmlSchemaSetValidOptions's check +* for invalid values, if adding to the validation +* options below. +*/ +/** + * xmlSchemaValidOption: + * + * This is the set of XML Schema validation options. + */ +typedef enum { + XML_SCHEMA_VAL_VC_I_CREATE = 1<<0 + /* Default/fixed: create an attribute node + * or an element's text node on the instance. + */ +} xmlSchemaValidOption; + +/* + XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1, + * assemble schemata using + * xsi:schemaLocation and + * xsi:noNamespaceSchemaLocation +*/ + +/** + * The schemas related types are kept internal + */ +typedef struct _xmlSchema xmlSchema; +typedef xmlSchema *xmlSchemaPtr; + +/** + * xmlSchemaValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from an XSD validation + */ +typedef void (*xmlSchemaValidityErrorFunc) + (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * xmlSchemaValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from an XSD validation + */ +typedef void (*xmlSchemaValidityWarningFunc) + (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * A schemas validation context + */ +typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt; +typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr; + +typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt; +typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr; + +/** + * xmlSchemaValidityLocatorFunc: + * @ctx: user provided context + * @file: returned file information + * @line: returned line information + * + * A schemas validation locator, a callback called by the validator. + * This is used when file or node information are not available + * to find out what file and line number are affected + * + * Returns: 0 in case of success and -1 in case of error + */ + +typedef int (*xmlSchemaValidityLocatorFunc) (void *ctx, + const char **file, unsigned long *line); + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlSchemaParserCtxtPtr + xmlSchemaNewParserCtxt (const char *URL); +XMLPUBFUN xmlSchemaParserCtxtPtr + xmlSchemaNewMemParserCtxt (const char *buffer, + int size); +XMLPUBFUN xmlSchemaParserCtxtPtr + xmlSchemaNewDocParserCtxt (xmlDocPtr doc); +XMLPUBFUN void + xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt); +XMLPUBFUN void + xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt, + xmlSchemaValidityErrorFunc err, + xmlSchemaValidityWarningFunc warn, + void *ctx); +XMLPUBFUN void + xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN int + xmlSchemaGetParserErrors (xmlSchemaParserCtxtPtr ctxt, + xmlSchemaValidityErrorFunc * err, + xmlSchemaValidityWarningFunc * warn, + void **ctx); +XMLPUBFUN void + xmlSchemaSetResourceLoader (xmlSchemaParserCtxtPtr ctxt, + xmlResourceLoader loader, + void *data); +XMLPUBFUN int + xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt); + +XMLPUBFUN xmlSchemaPtr + xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt); +XMLPUBFUN void + xmlSchemaFree (xmlSchemaPtr schema); +#ifdef LIBXML_DEBUG_ENABLED +XMLPUBFUN void + xmlSchemaDump (FILE *output, + xmlSchemaPtr schema); +#endif /* LIBXML_DEBUG_ENABLED */ +/* + * Interfaces for validating + */ +XMLPUBFUN void + xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt, + xmlSchemaValidityErrorFunc err, + xmlSchemaValidityWarningFunc warn, + void *ctx); +XMLPUBFUN void + xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN int + xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt, + xmlSchemaValidityErrorFunc *err, + xmlSchemaValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN int + xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt, + int options); +XMLPUBFUN void + xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt, + const char *filename); +XMLPUBFUN int + xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt); + +XMLPUBFUN xmlSchemaValidCtxtPtr + xmlSchemaNewValidCtxt (xmlSchemaPtr schema); +XMLPUBFUN void + xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt); +XMLPUBFUN int + xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt, + xmlDocPtr instance); +XMLPUBFUN int + xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt, + xmlNodePtr elem); +XMLPUBFUN int + xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt, + xmlParserInputBufferPtr input, + xmlCharEncoding enc, + const xmlSAXHandler *sax, + void *user_data); +XMLPUBFUN int + xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt, + const char * filename, + int options); + +XMLPUBFUN xmlParserCtxtPtr + xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt); + +/* + * Interface to insert Schemas SAX validation in a SAX stream + */ +typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct; +typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr; + +XMLPUBFUN xmlSchemaSAXPlugPtr + xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt, + xmlSAXHandlerPtr *sax, + void **user_data); +XMLPUBFUN int + xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug); + + +XMLPUBFUN void + xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt, + xmlSchemaValidityLocatorFunc f, + void *ctxt); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlschemastypes.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlschemastypes.h new file mode 100644 index 00000000..e2cde357 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlschemastypes.h @@ -0,0 +1,152 @@ +/* + * Summary: implementation of XML Schema Datatypes + * Description: module providing the XML Schema Datatypes implementation + * both definition and validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_TYPES_H__ +#define __XML_SCHEMA_TYPES_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMA_WHITESPACE_UNKNOWN = 0, + XML_SCHEMA_WHITESPACE_PRESERVE = 1, + XML_SCHEMA_WHITESPACE_REPLACE = 2, + XML_SCHEMA_WHITESPACE_COLLAPSE = 3 +} xmlSchemaWhitespaceValueType; + +XMLPUBFUN int + xmlSchemaInitTypes (void); +XML_DEPRECATED +XMLPUBFUN void + xmlSchemaCleanupTypes (void); +XMLPUBFUN xmlSchemaTypePtr + xmlSchemaGetPredefinedType (const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int + xmlSchemaValidatePredefinedType (xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val); +XMLPUBFUN int + xmlSchemaValPredefTypeNode (xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val, + xmlNodePtr node); +XMLPUBFUN int + xmlSchemaValidateFacet (xmlSchemaTypePtr base, + xmlSchemaFacetPtr facet, + const xmlChar *value, + xmlSchemaValPtr val); +XMLPUBFUN int + xmlSchemaValidateFacetWhtsp (xmlSchemaFacetPtr facet, + xmlSchemaWhitespaceValueType fws, + xmlSchemaValType valType, + const xmlChar *value, + xmlSchemaValPtr val, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN void + xmlSchemaFreeValue (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaFacetPtr + xmlSchemaNewFacet (void); +XMLPUBFUN int + xmlSchemaCheckFacet (xmlSchemaFacetPtr facet, + xmlSchemaTypePtr typeDecl, + xmlSchemaParserCtxtPtr ctxt, + const xmlChar *name); +XMLPUBFUN void + xmlSchemaFreeFacet (xmlSchemaFacetPtr facet); +XMLPUBFUN int + xmlSchemaCompareValues (xmlSchemaValPtr x, + xmlSchemaValPtr y); +XMLPUBFUN xmlSchemaTypePtr + xmlSchemaGetBuiltInListSimpleTypeItemType (xmlSchemaTypePtr type); +XMLPUBFUN int + xmlSchemaValidateListSimpleTypeFacet (xmlSchemaFacetPtr facet, + const xmlChar *value, + unsigned long actualLen, + unsigned long *expectedLen); +XMLPUBFUN xmlSchemaTypePtr + xmlSchemaGetBuiltInType (xmlSchemaValType type); +XMLPUBFUN int + xmlSchemaIsBuiltInTypeFacet (xmlSchemaTypePtr type, + int facetType); +XMLPUBFUN xmlChar * + xmlSchemaCollapseString (const xmlChar *value); +XMLPUBFUN xmlChar * + xmlSchemaWhiteSpaceReplace (const xmlChar *value); +XMLPUBFUN unsigned long + xmlSchemaGetFacetValueAsULong (xmlSchemaFacetPtr facet); +XMLPUBFUN int + xmlSchemaValidateLengthFacet (xmlSchemaTypePtr type, + xmlSchemaFacetPtr facet, + const xmlChar *value, + xmlSchemaValPtr val, + unsigned long *length); +XMLPUBFUN int + xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet, + xmlSchemaValType valType, + const xmlChar *value, + xmlSchemaValPtr val, + unsigned long *length, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN int + xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val, + xmlNodePtr node); +XMLPUBFUN int + xmlSchemaGetCanonValue (xmlSchemaValPtr val, + const xmlChar **retValue); +XMLPUBFUN int + xmlSchemaGetCanonValueWhtsp (xmlSchemaValPtr val, + const xmlChar **retValue, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN int + xmlSchemaValueAppend (xmlSchemaValPtr prev, + xmlSchemaValPtr cur); +XMLPUBFUN xmlSchemaValPtr + xmlSchemaValueGetNext (xmlSchemaValPtr cur); +XMLPUBFUN const xmlChar * + xmlSchemaValueGetAsString (xmlSchemaValPtr val); +XMLPUBFUN int + xmlSchemaValueGetAsBoolean (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaValPtr + xmlSchemaNewStringValue (xmlSchemaValType type, + const xmlChar *value); +XMLPUBFUN xmlSchemaValPtr + xmlSchemaNewNOTATIONValue (const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN xmlSchemaValPtr + xmlSchemaNewQNameValue (const xmlChar *namespaceName, + const xmlChar *localName); +XMLPUBFUN int + xmlSchemaCompareValuesWhtsp (xmlSchemaValPtr x, + xmlSchemaWhitespaceValueType xws, + xmlSchemaValPtr y, + xmlSchemaWhitespaceValueType yws); +XMLPUBFUN xmlSchemaValPtr + xmlSchemaCopyValue (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaValType + xmlSchemaGetValType (xmlSchemaValPtr val); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_TYPES_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlstring.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlstring.h new file mode 100644 index 00000000..db11a0b0 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlstring.h @@ -0,0 +1,140 @@ +/* + * Summary: set of routines to process strings + * Description: type and interfaces needed for the internal string handling + * of the library, especially UTF8 processing. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_STRING_H__ +#define __XML_STRING_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlChar: + * + * This is a basic byte in an UTF-8 encoded string. + * It's unsigned allowing to pinpoint case where char * are assigned + * to xmlChar * (possibly making serialization back impossible). + */ +typedef unsigned char xmlChar; + +/** + * BAD_CAST: + * + * Macro to cast a string to an xmlChar * when one know its safe. + */ +#define BAD_CAST (xmlChar *) + +/* + * xmlChar handling + */ +XMLPUBFUN xmlChar * + xmlStrdup (const xmlChar *cur); +XMLPUBFUN xmlChar * + xmlStrndup (const xmlChar *cur, + int len); +XMLPUBFUN xmlChar * + xmlCharStrndup (const char *cur, + int len); +XMLPUBFUN xmlChar * + xmlCharStrdup (const char *cur); +XMLPUBFUN xmlChar * + xmlStrsub (const xmlChar *str, + int start, + int len); +XMLPUBFUN const xmlChar * + xmlStrchr (const xmlChar *str, + xmlChar val); +XMLPUBFUN const xmlChar * + xmlStrstr (const xmlChar *str, + const xmlChar *val); +XMLPUBFUN const xmlChar * + xmlStrcasestr (const xmlChar *str, + const xmlChar *val); +XMLPUBFUN int + xmlStrcmp (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int + xmlStrncmp (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int + xmlStrcasecmp (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int + xmlStrncasecmp (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int + xmlStrEqual (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int + xmlStrQEqual (const xmlChar *pref, + const xmlChar *name, + const xmlChar *str); +XMLPUBFUN int + xmlStrlen (const xmlChar *str); +XMLPUBFUN xmlChar * + xmlStrcat (xmlChar *cur, + const xmlChar *add); +XMLPUBFUN xmlChar * + xmlStrncat (xmlChar *cur, + const xmlChar *add, + int len); +XMLPUBFUN xmlChar * + xmlStrncatNew (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int + xmlStrPrintf (xmlChar *buf, + int len, + const char *msg, + ...) LIBXML_ATTR_FORMAT(3,4); +XMLPUBFUN int + xmlStrVPrintf (xmlChar *buf, + int len, + const char *msg, + va_list ap) LIBXML_ATTR_FORMAT(3,0); + +XMLPUBFUN int + xmlGetUTF8Char (const unsigned char *utf, + int *len); +XMLPUBFUN int + xmlCheckUTF8 (const unsigned char *utf); +XMLPUBFUN int + xmlUTF8Strsize (const xmlChar *utf, + int len); +XMLPUBFUN xmlChar * + xmlUTF8Strndup (const xmlChar *utf, + int len); +XMLPUBFUN const xmlChar * + xmlUTF8Strpos (const xmlChar *utf, + int pos); +XMLPUBFUN int + xmlUTF8Strloc (const xmlChar *utf, + const xmlChar *utfchar); +XMLPUBFUN xmlChar * + xmlUTF8Strsub (const xmlChar *utf, + int start, + int len); +XMLPUBFUN int + xmlUTF8Strlen (const xmlChar *utf); +XMLPUBFUN int + xmlUTF8Size (const xmlChar *utf); +XMLPUBFUN int + xmlUTF8Charcmp (const xmlChar *utf1, + const xmlChar *utf2); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_STRING_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlunicode.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlunicode.h new file mode 100644 index 00000000..efda81b2 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlunicode.h @@ -0,0 +1,15 @@ +/* + * Summary: Unicode character APIs + * Description: API for the Unicode character APIs + * + * Deprecated, don't use. + */ + +#ifndef __XML_UNICODE_H__ +#define __XML_UNICODE_H__ + +#ifdef __GNUC__ + #warning "libxml/xmlunicode.h is deprecated" +#endif + +#endif /* __XML_UNICODE_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlversion.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlversion.h new file mode 100644 index 00000000..66d78ed2 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlversion.h @@ -0,0 +1,332 @@ +/* + * Summary: compile-time version information + * Description: compile-time version information for the XML library + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_VERSION_H__ +#define __XML_VERSION_H__ + +/** + * LIBXML_DOTTED_VERSION: + * + * the version string like "1.2.3" + */ +#define LIBXML_DOTTED_VERSION "2.14.6" + +/** + * LIBXML_VERSION: + * + * the version number: 1.2.3 value is 10203 + */ +#define LIBXML_VERSION 21406 + +/** + * LIBXML_VERSION_STRING: + * + * the version number string, 1.2.3 value is "10203" + */ +#define LIBXML_VERSION_STRING "21406" + +/** + * LIBXML_VERSION_EXTRA: + * + * extra version information, used to show a git commit description + */ +#define LIBXML_VERSION_EXTRA "" + +/** + * LIBXML_TEST_VERSION: + * + * Macro to check that the libxml version in use is compatible with + * the version the software has been compiled against + */ +#define LIBXML_TEST_VERSION xmlCheckVersion(21406); + +/** + * LIBXML_THREAD_ENABLED: + * + * Whether the thread support is configured in + */ +#if 1 +#define LIBXML_THREAD_ENABLED +#endif + +/** + * LIBXML_THREAD_ALLOC_ENABLED: + * + * Whether the allocation hooks are per-thread + */ +#if 0 +#define LIBXML_THREAD_ALLOC_ENABLED +#endif + +/** + * LIBXML_TREE_ENABLED: + * + * Always enabled since 2.14.0 + */ +#define LIBXML_TREE_ENABLED + +/** + * LIBXML_OUTPUT_ENABLED: + * + * Whether the serialization/saving support is configured in + */ +#if 1 +#define LIBXML_OUTPUT_ENABLED +#endif + +/** + * LIBXML_PUSH_ENABLED: + * + * Whether the push parsing interfaces are configured in + */ +#if 1 +#define LIBXML_PUSH_ENABLED +#endif + +/** + * LIBXML_READER_ENABLED: + * + * Whether the xmlReader parsing interface is configured in + */ +#if 1 +#define LIBXML_READER_ENABLED +#endif + +/** + * LIBXML_PATTERN_ENABLED: + * + * Whether the xmlPattern node selection interface is configured in + */ +#if 1 +#define LIBXML_PATTERN_ENABLED +#endif + +/** + * LIBXML_WRITER_ENABLED: + * + * Whether the xmlWriter saving interface is configured in + */ +#if 1 +#define LIBXML_WRITER_ENABLED +#endif + +/** + * LIBXML_SAX1_ENABLED: + * + * Whether the older SAX1 interface is configured in + */ +#if 1 +#define LIBXML_SAX1_ENABLED +#endif + +/** + * LIBXML_HTTP_ENABLED: + * + * Whether the HTTP support is configured in + */ +#if 0 +#define LIBXML_HTTP_ENABLED +#endif + +/** + * LIBXML_VALID_ENABLED: + * + * Whether the DTD validation support is configured in + */ +#if 1 +#define LIBXML_VALID_ENABLED +#endif + +/** + * LIBXML_HTML_ENABLED: + * + * Whether the HTML support is configured in + */ +#if 1 +#define LIBXML_HTML_ENABLED +#endif + +/** + * LIBXML_LEGACY_ENABLED: + * + * Removed in 2.14 + */ +#undef LIBXML_LEGACY_ENABLED + +/** + * LIBXML_C14N_ENABLED: + * + * Whether the Canonicalization support is configured in + */ +#if 1 +#define LIBXML_C14N_ENABLED +#endif + +/** + * LIBXML_CATALOG_ENABLED: + * + * Whether the Catalog support is configured in + */ +#if 1 +#define LIBXML_CATALOG_ENABLED +#endif + +/** + * LIBXML_XPATH_ENABLED: + * + * Whether XPath is configured in + */ +#if 1 +#define LIBXML_XPATH_ENABLED +#endif + +/** + * LIBXML_XPTR_ENABLED: + * + * Whether XPointer is configured in + */ +#if 1 +#define LIBXML_XPTR_ENABLED +#endif + +/** + * LIBXML_XINCLUDE_ENABLED: + * + * Whether XInclude is configured in + */ +#if 1 +#define LIBXML_XINCLUDE_ENABLED +#endif + +/** + * LIBXML_ICONV_ENABLED: + * + * Whether iconv support is available + */ +#if 1 +#define LIBXML_ICONV_ENABLED +#endif + +/** + * LIBXML_ICU_ENABLED: + * + * Whether icu support is available + */ +#if 0 +#define LIBXML_ICU_ENABLED +#endif + +/** + * LIBXML_ISO8859X_ENABLED: + * + * Whether ISO-8859-* support is made available in case iconv is not + */ +#if 1 +#define LIBXML_ISO8859X_ENABLED +#endif + +/** + * LIBXML_DEBUG_ENABLED: + * + * Whether Debugging module is configured in + */ +#if 1 +#define LIBXML_DEBUG_ENABLED +#endif + +/** + * LIBXML_UNICODE_ENABLED: + * + * Removed in 2.14 + */ +#undef LIBXML_UNICODE_ENABLED + +/** + * LIBXML_REGEXP_ENABLED: + * + * Whether the regular expressions interfaces are compiled in + */ +#if 1 +#define LIBXML_REGEXP_ENABLED +#endif + +/** + * LIBXML_AUTOMATA_ENABLED: + * + * Whether the automata interfaces are compiled in + */ +#if 1 +#define LIBXML_AUTOMATA_ENABLED +#endif + +/** + * LIBXML_RELAXNG_ENABLED: + * + * Whether the RelaxNG validation interfaces are compiled in + */ +#if 1 +#define LIBXML_RELAXNG_ENABLED +#endif + +/** + * LIBXML_SCHEMAS_ENABLED: + * + * Whether the Schemas validation interfaces are compiled in + */ +#if 1 +#define LIBXML_SCHEMAS_ENABLED +#endif + +/** + * LIBXML_SCHEMATRON_ENABLED: + * + * Whether the Schematron validation interfaces are compiled in + */ +#if 1 +#define LIBXML_SCHEMATRON_ENABLED +#endif + +/** + * LIBXML_MODULES_ENABLED: + * + * Whether the module interfaces are compiled in + */ +#if 1 +#define LIBXML_MODULES_ENABLED +/** + * LIBXML_MODULE_EXTENSION: + * + * the string suffix used by dynamic modules (usually shared libraries) + */ +#define LIBXML_MODULE_EXTENSION ".so" +#endif + +/** + * LIBXML_ZLIB_ENABLED: + * + * Whether the Zlib support is compiled in + */ +#if 0 +#define LIBXML_ZLIB_ENABLED +#endif + +/** + * LIBXML_LZMA_ENABLED: + * + * Whether the Lzma support is compiled in + */ +#if 0 +#define LIBXML_LZMA_ENABLED +#endif + +#include + +#endif + + diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xmlwriter.h b/illumos-x86_64/usr/include/libxml2/libxml/xmlwriter.h new file mode 100644 index 00000000..55f88bc7 --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xmlwriter.h @@ -0,0 +1,489 @@ +/* + * Summary: text writing API for XML + * Description: text writing API for XML + * + * Copy: See Copyright for the status of this software. + * + * Author: Alfred Mickautsch + */ + +#ifndef __XML_XMLWRITER_H__ +#define __XML_XMLWRITER_H__ + +#include + +#ifdef LIBXML_WRITER_ENABLED + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct _xmlTextWriter xmlTextWriter; + typedef xmlTextWriter *xmlTextWriterPtr; + +/* + * Constructors & Destructor + */ + XMLPUBFUN xmlTextWriterPtr + xmlNewTextWriter(xmlOutputBufferPtr out); + XMLPUBFUN xmlTextWriterPtr + xmlNewTextWriterFilename(const char *uri, int compression); + XMLPUBFUN xmlTextWriterPtr + xmlNewTextWriterMemory(xmlBufferPtr buf, int compression); + XMLPUBFUN xmlTextWriterPtr + xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression); + XMLPUBFUN xmlTextWriterPtr + xmlNewTextWriterDoc(xmlDocPtr * doc, int compression); + XMLPUBFUN xmlTextWriterPtr + xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, + int compression); + XMLPUBFUN void xmlFreeTextWriter(xmlTextWriterPtr writer); + +/* + * Functions + */ + + +/* + * Document + */ + XMLPUBFUN int + xmlTextWriterStartDocument(xmlTextWriterPtr writer, + const char *version, + const char *encoding, + const char *standalone); + XMLPUBFUN int xmlTextWriterEndDocument(xmlTextWriterPtr + writer); + +/* + * Comments + */ + XMLPUBFUN int xmlTextWriterStartComment(xmlTextWriterPtr + writer); + XMLPUBFUN int xmlTextWriterEndComment(xmlTextWriterPtr writer); + XMLPUBFUN int + xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer, + const char *format, ...) + LIBXML_ATTR_FORMAT(2,3); + XMLPUBFUN int + xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(2,0); + XMLPUBFUN int xmlTextWriterWriteComment(xmlTextWriterPtr + writer, + const xmlChar * + content); + +/* + * Elements + */ + XMLPUBFUN int + xmlTextWriterStartElement(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int xmlTextWriterStartElementNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * name, + const xmlChar * + namespaceURI); + XMLPUBFUN int xmlTextWriterEndElement(xmlTextWriterPtr writer); + XMLPUBFUN int xmlTextWriterFullEndElement(xmlTextWriterPtr + writer); + +/* + * Elements conveniency functions + */ + XMLPUBFUN int + xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int + xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int xmlTextWriterWriteElement(xmlTextWriterPtr + writer, + const xmlChar * name, + const xmlChar * + content); + XMLPUBFUN int + xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, ...) + LIBXML_ATTR_FORMAT(5,6); + XMLPUBFUN int + xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(5,0); + XMLPUBFUN int xmlTextWriterWriteElementNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * name, + const xmlChar * + namespaceURI, + const xmlChar * + content); + +/* + * Text + */ + XMLPUBFUN int + xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, + const char *format, ...) + LIBXML_ATTR_FORMAT(2,3); + XMLPUBFUN int + xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, + const char *format, va_list argptr) + LIBXML_ATTR_FORMAT(2,0); + XMLPUBFUN int + xmlTextWriterWriteRawLen(xmlTextWriterPtr writer, + const xmlChar * content, int len); + XMLPUBFUN int + xmlTextWriterWriteRaw(xmlTextWriterPtr writer, + const xmlChar * content); + XMLPUBFUN int xmlTextWriterWriteFormatString(xmlTextWriterPtr + writer, + const char + *format, ...) + LIBXML_ATTR_FORMAT(2,3); + XMLPUBFUN int xmlTextWriterWriteVFormatString(xmlTextWriterPtr + writer, + const char + *format, + va_list argptr) + LIBXML_ATTR_FORMAT(2,0); + XMLPUBFUN int xmlTextWriterWriteString(xmlTextWriterPtr writer, + const xmlChar * + content); + XMLPUBFUN int xmlTextWriterWriteBase64(xmlTextWriterPtr writer, + const char *data, + int start, int len); + XMLPUBFUN int xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, + const char *data, + int start, int len); + +/* + * Attributes + */ + XMLPUBFUN int + xmlTextWriterStartAttribute(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int xmlTextWriterStartAttributeNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * + name, + const xmlChar * + namespaceURI); + XMLPUBFUN int xmlTextWriterEndAttribute(xmlTextWriterPtr + writer); + +/* + * Attributes conveniency functions + */ + XMLPUBFUN int + xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int + xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int xmlTextWriterWriteAttribute(xmlTextWriterPtr + writer, + const xmlChar * name, + const xmlChar * + content); + XMLPUBFUN int + xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, ...) + LIBXML_ATTR_FORMAT(5,6); + XMLPUBFUN int + xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(5,0); + XMLPUBFUN int xmlTextWriterWriteAttributeNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * + name, + const xmlChar * + namespaceURI, + const xmlChar * + content); + +/* + * PI's + */ + XMLPUBFUN int + xmlTextWriterStartPI(xmlTextWriterPtr writer, + const xmlChar * target); + XMLPUBFUN int xmlTextWriterEndPI(xmlTextWriterPtr writer); + +/* + * PI conveniency functions + */ + XMLPUBFUN int + xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, + const xmlChar * target, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int + xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer, + const xmlChar * target, + const char *format, va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int + xmlTextWriterWritePI(xmlTextWriterPtr writer, + const xmlChar * target, + const xmlChar * content); + +/** + * xmlTextWriterWriteProcessingInstruction: + * + * This macro maps to xmlTextWriterWritePI + */ +#define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI + +/* + * CDATA + */ + XMLPUBFUN int xmlTextWriterStartCDATA(xmlTextWriterPtr writer); + XMLPUBFUN int xmlTextWriterEndCDATA(xmlTextWriterPtr writer); + +/* + * CDATA conveniency functions + */ + XMLPUBFUN int + xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, + const char *format, ...) + LIBXML_ATTR_FORMAT(2,3); + XMLPUBFUN int + xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, + const char *format, va_list argptr) + LIBXML_ATTR_FORMAT(2,0); + XMLPUBFUN int + xmlTextWriterWriteCDATA(xmlTextWriterPtr writer, + const xmlChar * content); + +/* + * DTD + */ + XMLPUBFUN int + xmlTextWriterStartDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid); + XMLPUBFUN int xmlTextWriterEndDTD(xmlTextWriterPtr writer); + +/* + * DTD conveniency functions + */ + XMLPUBFUN int + xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const char *format, ...) + LIBXML_ATTR_FORMAT(5,6); + XMLPUBFUN int + xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const char *format, va_list argptr) + LIBXML_ATTR_FORMAT(5,0); + XMLPUBFUN int + xmlTextWriterWriteDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * subset); + +/** + * xmlTextWriterWriteDocType: + * + * this macro maps to xmlTextWriterWriteDTD + */ +#define xmlTextWriterWriteDocType xmlTextWriterWriteDTD + +/* + * DTD element definition + */ + XMLPUBFUN int + xmlTextWriterStartDTDElement(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int xmlTextWriterEndDTDElement(xmlTextWriterPtr + writer); + +/* + * DTD element definition conveniency functions + */ + XMLPUBFUN int + xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int + xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int xmlTextWriterWriteDTDElement(xmlTextWriterPtr + writer, + const xmlChar * + name, + const xmlChar * + content); + +/* + * DTD attribute list definition + */ + XMLPUBFUN int + xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int xmlTextWriterEndDTDAttlist(xmlTextWriterPtr + writer); + +/* + * DTD attribute list definition conveniency functions + */ + XMLPUBFUN int + xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int + xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr + writer, + const xmlChar * + name, + const xmlChar * + content); + +/* + * DTD entity definition + */ + XMLPUBFUN int + xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer, + int pe, const xmlChar * name); + XMLPUBFUN int xmlTextWriterEndDTDEntity(xmlTextWriterPtr + writer); + +/* + * DTD entity definition conveniency functions + */ + XMLPUBFUN int + xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(4,5); + XMLPUBFUN int + xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(4,0); + XMLPUBFUN int + xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const xmlChar * content); + XMLPUBFUN int + xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * ndataid); + XMLPUBFUN int + xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr + writer, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * + ndataid); + XMLPUBFUN int xmlTextWriterWriteDTDEntity(xmlTextWriterPtr + writer, int pe, + const xmlChar * name, + const xmlChar * + pubid, + const xmlChar * + sysid, + const xmlChar * + ndataid, + const xmlChar * + content); + +/* + * DTD notation definition + */ + XMLPUBFUN int + xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid); + +/* + * Indentation + */ + XMLPUBFUN int + xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent); + XMLPUBFUN int + xmlTextWriterSetIndentString(xmlTextWriterPtr writer, + const xmlChar * str); + + XMLPUBFUN int + xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar); + + +/* + * misc + */ + XMLPUBFUN int xmlTextWriterFlush(xmlTextWriterPtr writer); + XMLPUBFUN int xmlTextWriterClose(xmlTextWriterPtr writer); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_WRITER_ENABLED */ + +#endif /* __XML_XMLWRITER_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xpath.h b/illumos-x86_64/usr/include/libxml2/libxml/xpath.h new file mode 100644 index 00000000..e03e97df --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xpath.h @@ -0,0 +1,569 @@ +/* + * Summary: XML Path Language implementation + * Description: API for the XML Path Language implementation + * + * XML Path Language implementation + * XPath is a language for addressing parts of an XML document, + * designed to be used by both XSLT and XPointer + * http://www.w3.org/TR/xpath + * + * Implements + * W3C Recommendation 16 November 1999 + * http://www.w3.org/TR/1999/REC-xpath-19991116 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPATH_H__ +#define __XML_XPATH_H__ + +#include + +#ifdef LIBXML_XPATH_ENABLED + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlXPathContext xmlXPathContext; +typedef xmlXPathContext *xmlXPathContextPtr; +typedef struct _xmlXPathParserContext xmlXPathParserContext; +typedef xmlXPathParserContext *xmlXPathParserContextPtr; + +/** + * The set of XPath error codes. + */ + +typedef enum { + XPATH_EXPRESSION_OK = 0, + XPATH_NUMBER_ERROR, + XPATH_UNFINISHED_LITERAL_ERROR, + XPATH_START_LITERAL_ERROR, + XPATH_VARIABLE_REF_ERROR, + XPATH_UNDEF_VARIABLE_ERROR, + XPATH_INVALID_PREDICATE_ERROR, + XPATH_EXPR_ERROR, + XPATH_UNCLOSED_ERROR, + XPATH_UNKNOWN_FUNC_ERROR, + XPATH_INVALID_OPERAND, + XPATH_INVALID_TYPE, + XPATH_INVALID_ARITY, + XPATH_INVALID_CTXT_SIZE, + XPATH_INVALID_CTXT_POSITION, + XPATH_MEMORY_ERROR, + XPTR_SYNTAX_ERROR, + XPTR_RESOURCE_ERROR, + XPTR_SUB_RESOURCE_ERROR, + XPATH_UNDEF_PREFIX_ERROR, + XPATH_ENCODING_ERROR, + XPATH_INVALID_CHAR_ERROR, + XPATH_INVALID_CTXT, + XPATH_STACK_ERROR, + XPATH_FORBID_VARIABLE_ERROR, + XPATH_OP_LIMIT_EXCEEDED, + XPATH_RECURSION_LIMIT_EXCEEDED +} xmlXPathError; + +/* + * A node-set (an unordered collection of nodes without duplicates). + */ +typedef struct _xmlNodeSet xmlNodeSet; +typedef xmlNodeSet *xmlNodeSetPtr; +struct _xmlNodeSet { + int nodeNr; /* number of nodes in the set */ + int nodeMax; /* size of the array as allocated */ + xmlNodePtr *nodeTab; /* array of nodes in no particular order */ + /* @@ with_ns to check whether namespace nodes should be looked at @@ */ +}; + +/* + * An expression is evaluated to yield an object, which + * has one of the following four basic types: + * - node-set + * - boolean + * - number + * - string + * + * @@ XPointer will add more types ! + */ + +typedef enum { + XPATH_UNDEFINED = 0, + XPATH_NODESET = 1, + XPATH_BOOLEAN = 2, + XPATH_NUMBER = 3, + XPATH_STRING = 4, + XPATH_USERS = 8, + XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */ +} xmlXPathObjectType; + +/** DOC_DISABLE */ +#define XPATH_POINT 5 +#define XPATH_RANGE 6 +#define XPATH_LOCATIONSET 7 +/** DOC_ENABLE */ + +typedef struct _xmlXPathObject xmlXPathObject; +typedef xmlXPathObject *xmlXPathObjectPtr; +struct _xmlXPathObject { + xmlXPathObjectType type; + xmlNodeSetPtr nodesetval; + int boolval; + double floatval; + xmlChar *stringval; + void *user; + int index; + void *user2; + int index2; +}; + +/** + * xmlXPathConvertFunc: + * @obj: an XPath object + * @type: the number of the target type + * + * A conversion function is associated to a type and used to cast + * the new type to primitive values. + * + * Returns -1 in case of error, 0 otherwise + */ +typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type); + +/* + * Extra type: a name and a conversion function. + */ + +typedef struct _xmlXPathType xmlXPathType; +typedef xmlXPathType *xmlXPathTypePtr; +struct _xmlXPathType { + const xmlChar *name; /* the type name */ + xmlXPathConvertFunc func; /* the conversion function */ +}; + +/* + * Extra variable: a name and a value. + */ + +typedef struct _xmlXPathVariable xmlXPathVariable; +typedef xmlXPathVariable *xmlXPathVariablePtr; +struct _xmlXPathVariable { + const xmlChar *name; /* the variable name */ + xmlXPathObjectPtr value; /* the value */ +}; + +/** + * xmlXPathEvalFunc: + * @ctxt: an XPath parser context + * @nargs: the number of arguments passed to the function + * + * An XPath evaluation function, the parameters are on the XPath context stack. + */ + +typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt, + int nargs); + +/* + * Extra function: a name and a evaluation function. + */ + +typedef struct _xmlXPathFunct xmlXPathFunct; +typedef xmlXPathFunct *xmlXPathFuncPtr; +struct _xmlXPathFunct { + const xmlChar *name; /* the function name */ + xmlXPathEvalFunc func; /* the evaluation function */ +}; + +/** + * xmlXPathAxisFunc: + * @ctxt: the XPath interpreter context + * @cur: the previous node being explored on that axis + * + * An axis traversal function. To traverse an axis, the engine calls + * the first time with cur == NULL and repeat until the function returns + * NULL indicating the end of the axis traversal. + * + * Returns the next node in that axis or NULL if at the end of the axis. + */ + +typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr cur); + +/* + * Extra axis: a name and an axis function. + */ + +typedef struct _xmlXPathAxis xmlXPathAxis; +typedef xmlXPathAxis *xmlXPathAxisPtr; +struct _xmlXPathAxis { + const xmlChar *name; /* the axis name */ + xmlXPathAxisFunc func; /* the search function */ +}; + +/** + * xmlXPathFunction: + * @ctxt: the XPath interprestation context + * @nargs: the number of arguments + * + * An XPath function. + * The arguments (if any) are popped out from the context stack + * and the result is pushed on the stack. + */ + +typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs); + +/* + * Function and Variable Lookup. + */ + +/** + * xmlXPathVariableLookupFunc: + * @ctxt: an XPath context + * @name: name of the variable + * @ns_uri: the namespace name hosting this variable + * + * Prototype for callbacks used to plug variable lookup in the XPath + * engine. + * + * Returns the XPath object value or NULL if not found. + */ +typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt, + const xmlChar *name, + const xmlChar *ns_uri); + +/** + * xmlXPathFuncLookupFunc: + * @ctxt: an XPath context + * @name: name of the function + * @ns_uri: the namespace name hosting this function + * + * Prototype for callbacks used to plug function lookup in the XPath + * engine. + * + * Returns the XPath function or NULL if not found. + */ +typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt, + const xmlChar *name, + const xmlChar *ns_uri); + +/** + * xmlXPathFlags: + * Flags for XPath engine compilation and runtime + */ +/** + * XML_XPATH_CHECKNS: + * + * check namespaces at compilation + */ +#define XML_XPATH_CHECKNS (1<<0) +/** + * XML_XPATH_NOVAR: + * + * forbid variables in expression + */ +#define XML_XPATH_NOVAR (1<<1) + +/** + * xmlXPathContext: + * + * Expression evaluation occurs with respect to a context. + * he context consists of: + * - a node (the context node) + * - a node list (the context node list) + * - a set of variable bindings + * - a function library + * - the set of namespace declarations in scope for the expression + * Following the switch to hash tables, this need to be trimmed up at + * the next binary incompatible release. + * The node may be modified when the context is passed to libxml2 + * for an XPath evaluation so you may need to initialize it again + * before the next call. + */ + +struct _xmlXPathContext { + xmlDocPtr doc; /* The current document */ + xmlNodePtr node; /* The current node */ + + int nb_variables_unused; /* unused (hash table) */ + int max_variables_unused; /* unused (hash table) */ + xmlHashTablePtr varHash; /* Hash table of defined variables */ + + int nb_types; /* number of defined types */ + int max_types; /* max number of types */ + xmlXPathTypePtr types; /* Array of defined types */ + + int nb_funcs_unused; /* unused (hash table) */ + int max_funcs_unused; /* unused (hash table) */ + xmlHashTablePtr funcHash; /* Hash table of defined funcs */ + + int nb_axis; /* number of defined axis */ + int max_axis; /* max number of axis */ + xmlXPathAxisPtr axis; /* Array of defined axis */ + + /* the namespace nodes of the context node */ + xmlNsPtr *namespaces; /* Array of namespaces */ + int nsNr; /* number of namespace in scope */ + void *user; /* function to free */ + + /* extra variables */ + int contextSize; /* the context size */ + int proximityPosition; /* the proximity position */ + + /* extra stuff for XPointer */ + int xptr; /* is this an XPointer context? */ + xmlNodePtr here; /* for here() */ + xmlNodePtr origin; /* for origin() */ + + /* the set of namespace declarations in scope for the expression */ + xmlHashTablePtr nsHash; /* The namespaces hash table */ + xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */ + void *varLookupData; /* variable lookup data */ + + /* Possibility to link in an extra item */ + void *extra; /* needed for XSLT */ + + /* The function name and URI when calling a function */ + const xmlChar *function; + const xmlChar *functionURI; + + /* function lookup function and data */ + xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */ + void *funcLookupData; /* function lookup data */ + + /* temporary namespace lists kept for walking the namespace axis */ + xmlNsPtr *tmpNsList; /* Array of namespaces */ + int tmpNsNr; /* number of namespaces in scope */ + + /* error reporting mechanism */ + void *userData; /* user specific data block */ + xmlStructuredErrorFunc error; /* the callback in case of errors */ + xmlError lastError; /* the last error */ + xmlNodePtr debugNode; /* the source node XSLT */ + + /* dictionary */ + xmlDictPtr dict; /* dictionary if any */ + + int flags; /* flags to control compilation */ + + /* Cache for reusal of XPath objects */ + void *cache; + + /* Resource limits */ + unsigned long opLimit; + unsigned long opCount; + int depth; +}; + +/* + * The structure of a compiled expression form is not public. + */ + +typedef struct _xmlXPathCompExpr xmlXPathCompExpr; +typedef xmlXPathCompExpr *xmlXPathCompExprPtr; + +/** + * xmlXPathParserContext: + * + * An XPath parser context. It contains pure parsing information, + * an xmlXPathContext, and the stack of objects. + */ +struct _xmlXPathParserContext { + const xmlChar *cur; /* the current char being parsed */ + const xmlChar *base; /* the full expression */ + + int error; /* error code */ + + xmlXPathContextPtr context; /* the evaluation context */ + xmlXPathObjectPtr value; /* the current value */ + int valueNr; /* number of values stacked */ + int valueMax; /* max number of values stacked */ + xmlXPathObjectPtr *valueTab; /* stack of values */ + + xmlXPathCompExprPtr comp; /* the precompiled expression */ + int xptr; /* it this an XPointer expression */ + xmlNodePtr ancestor; /* used for walking preceding axis */ + + int valueFrame; /* always zero for compatibility */ +}; + +/************************************************************************ + * * + * Public API * + * * + ************************************************************************/ + +/** + * Objects and Nodesets handling + */ + +XML_DEPRECATED +XMLPUBVAR double xmlXPathNAN; +XML_DEPRECATED +XMLPUBVAR double xmlXPathPINF; +XML_DEPRECATED +XMLPUBVAR double xmlXPathNINF; + +/* These macros may later turn into functions */ +/** + * xmlXPathNodeSetGetLength: + * @ns: a node-set + * + * Implement a functionality similar to the DOM NodeList.length. + * + * Returns the number of nodes in the node-set. + */ +#define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0) +/** + * xmlXPathNodeSetItem: + * @ns: a node-set + * @index: index of a node in the set + * + * Implements a functionality similar to the DOM NodeList.item(). + * + * Returns the xmlNodePtr at the given @index in @ns or NULL if + * @index is out of range (0 to length-1) + */ +#define xmlXPathNodeSetItem(ns, index) \ + ((((ns) != NULL) && \ + ((index) >= 0) && ((index) < (ns)->nodeNr)) ? \ + (ns)->nodeTab[(index)] \ + : NULL) +/** + * xmlXPathNodeSetIsEmpty: + * @ns: a node-set + * + * Checks whether @ns is empty or not. + * + * Returns %TRUE if @ns is an empty node-set. + */ +#define xmlXPathNodeSetIsEmpty(ns) \ + (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL)) + + +XMLPUBFUN void + xmlXPathFreeObject (xmlXPathObjectPtr obj); +XMLPUBFUN xmlNodeSetPtr + xmlXPathNodeSetCreate (xmlNodePtr val); +XMLPUBFUN void + xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj); +XMLPUBFUN void + xmlXPathFreeNodeSet (xmlNodeSetPtr obj); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathObjectCopy (xmlXPathObjectPtr val); +XMLPUBFUN int + xmlXPathCmpNodes (xmlNodePtr node1, + xmlNodePtr node2); +/** + * Conversion functions to basic types. + */ +XMLPUBFUN int + xmlXPathCastNumberToBoolean (double val); +XMLPUBFUN int + xmlXPathCastStringToBoolean (const xmlChar * val); +XMLPUBFUN int + xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns); +XMLPUBFUN int + xmlXPathCastToBoolean (xmlXPathObjectPtr val); + +XMLPUBFUN double + xmlXPathCastBooleanToNumber (int val); +XMLPUBFUN double + xmlXPathCastStringToNumber (const xmlChar * val); +XMLPUBFUN double + xmlXPathCastNodeToNumber (xmlNodePtr node); +XMLPUBFUN double + xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns); +XMLPUBFUN double + xmlXPathCastToNumber (xmlXPathObjectPtr val); + +XMLPUBFUN xmlChar * + xmlXPathCastBooleanToString (int val); +XMLPUBFUN xmlChar * + xmlXPathCastNumberToString (double val); +XMLPUBFUN xmlChar * + xmlXPathCastNodeToString (xmlNodePtr node); +XMLPUBFUN xmlChar * + xmlXPathCastNodeSetToString (xmlNodeSetPtr ns); +XMLPUBFUN xmlChar * + xmlXPathCastToString (xmlXPathObjectPtr val); + +XMLPUBFUN xmlXPathObjectPtr + xmlXPathConvertBoolean (xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathConvertNumber (xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathConvertString (xmlXPathObjectPtr val); + +/** + * Context handling. + */ +XMLPUBFUN xmlXPathContextPtr + xmlXPathNewContext (xmlDocPtr doc); +XMLPUBFUN void + xmlXPathFreeContext (xmlXPathContextPtr ctxt); +XMLPUBFUN void + xmlXPathSetErrorHandler(xmlXPathContextPtr ctxt, + xmlStructuredErrorFunc handler, + void *context); +XMLPUBFUN int + xmlXPathContextSetCache(xmlXPathContextPtr ctxt, + int active, + int value, + int options); +/** + * Evaluation functions. + */ +XMLPUBFUN long + xmlXPathOrderDocElems (xmlDocPtr doc); +XMLPUBFUN int + xmlXPathSetContextNode (xmlNodePtr node, + xmlXPathContextPtr ctx); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathNodeEval (xmlNodePtr node, + const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathEval (const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathEvalExpression (const xmlChar *str, + xmlXPathContextPtr ctxt); +XMLPUBFUN int + xmlXPathEvalPredicate (xmlXPathContextPtr ctxt, + xmlXPathObjectPtr res); +/** + * Separate compilation/evaluation entry points. + */ +XMLPUBFUN xmlXPathCompExprPtr + xmlXPathCompile (const xmlChar *str); +XMLPUBFUN xmlXPathCompExprPtr + xmlXPathCtxtCompile (xmlXPathContextPtr ctxt, + const xmlChar *str); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathCompiledEval (xmlXPathCompExprPtr comp, + xmlXPathContextPtr ctx); +XMLPUBFUN int + xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp, + xmlXPathContextPtr ctxt); +XMLPUBFUN void + xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp); + +XML_DEPRECATED +XMLPUBFUN void + xmlXPathInit (void); +XMLPUBFUN int + xmlXPathIsNaN (double val); +XMLPUBFUN int + xmlXPathIsInf (double val); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPATH_ENABLED */ +#endif /* ! __XML_XPATH_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xpathInternals.h b/illumos-x86_64/usr/include/libxml2/libxml/xpathInternals.h new file mode 100644 index 00000000..88b487af --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xpathInternals.h @@ -0,0 +1,639 @@ +/* + * Summary: internal interfaces for XML Path Language implementation + * Description: internal interfaces for XML Path Language implementation + * used to build new modules on top of XPath like XPointer and + * XSLT + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPATH_INTERNALS_H__ +#define __XML_XPATH_INTERNALS_H__ + +#include +#include +#include + +#ifdef LIBXML_XPATH_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Backward compatibility + */ +#define valuePush xmlXPathValuePush +#define valuePop xmlXPathValuePop + +/************************************************************************ + * * + * Helpers * + * * + ************************************************************************/ + +/* + * Many of these macros may later turn into functions. They + * shouldn't be used in #ifdef's preprocessor instructions. + */ +/** + * xmlXPathSetError: + * @ctxt: an XPath parser context + * @err: an xmlXPathError code + * + * Raises an error. + */ +#define xmlXPathSetError(ctxt, err) \ + { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \ + if ((ctxt) != NULL) (ctxt)->error = (err); } + +/** + * xmlXPathSetArityError: + * @ctxt: an XPath parser context + * + * Raises an XPATH_INVALID_ARITY error. + */ +#define xmlXPathSetArityError(ctxt) \ + xmlXPathSetError((ctxt), XPATH_INVALID_ARITY) + +/** + * xmlXPathSetTypeError: + * @ctxt: an XPath parser context + * + * Raises an XPATH_INVALID_TYPE error. + */ +#define xmlXPathSetTypeError(ctxt) \ + xmlXPathSetError((ctxt), XPATH_INVALID_TYPE) + +/** + * xmlXPathGetError: + * @ctxt: an XPath parser context + * + * Get the error code of an XPath context. + * + * Returns the context error. + */ +#define xmlXPathGetError(ctxt) ((ctxt)->error) + +/** + * xmlXPathCheckError: + * @ctxt: an XPath parser context + * + * Check if an XPath error was raised. + * + * Returns true if an error has been raised, false otherwise. + */ +#define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK) + +/** + * xmlXPathGetDocument: + * @ctxt: an XPath parser context + * + * Get the document of an XPath context. + * + * Returns the context document. + */ +#define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc) + +/** + * xmlXPathGetContextNode: + * @ctxt: an XPath parser context + * + * Get the context node of an XPath context. + * + * Returns the context node. + */ +#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node) + +XMLPUBFUN int + xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt); +XMLPUBFUN double + xmlXPathPopNumber (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * + xmlXPathPopString (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlNodeSetPtr + xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt); +XMLPUBFUN void * + xmlXPathPopExternal (xmlXPathParserContextPtr ctxt); + +/** + * xmlXPathReturnBoolean: + * @ctxt: an XPath parser context + * @val: a boolean + * + * Pushes the boolean @val on the context stack. + */ +#define xmlXPathReturnBoolean(ctxt, val) \ + valuePush((ctxt), xmlXPathNewBoolean(val)) + +/** + * xmlXPathReturnTrue: + * @ctxt: an XPath parser context + * + * Pushes true on the context stack. + */ +#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1) + +/** + * xmlXPathReturnFalse: + * @ctxt: an XPath parser context + * + * Pushes false on the context stack. + */ +#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0) + +/** + * xmlXPathReturnNumber: + * @ctxt: an XPath parser context + * @val: a double + * + * Pushes the double @val on the context stack. + */ +#define xmlXPathReturnNumber(ctxt, val) \ + valuePush((ctxt), xmlXPathNewFloat(val)) + +/** + * xmlXPathReturnString: + * @ctxt: an XPath parser context + * @str: a string + * + * Pushes the string @str on the context stack. + */ +#define xmlXPathReturnString(ctxt, str) \ + valuePush((ctxt), xmlXPathWrapString(str)) + +/** + * xmlXPathReturnEmptyString: + * @ctxt: an XPath parser context + * + * Pushes an empty string on the stack. + */ +#define xmlXPathReturnEmptyString(ctxt) \ + valuePush((ctxt), xmlXPathNewCString("")) + +/** + * xmlXPathReturnNodeSet: + * @ctxt: an XPath parser context + * @ns: a node-set + * + * Pushes the node-set @ns on the context stack. + */ +#define xmlXPathReturnNodeSet(ctxt, ns) \ + valuePush((ctxt), xmlXPathWrapNodeSet(ns)) + +/** + * xmlXPathReturnEmptyNodeSet: + * @ctxt: an XPath parser context + * + * Pushes an empty node-set on the context stack. + */ +#define xmlXPathReturnEmptyNodeSet(ctxt) \ + valuePush((ctxt), xmlXPathNewNodeSet(NULL)) + +/** + * xmlXPathReturnExternal: + * @ctxt: an XPath parser context + * @val: user data + * + * Pushes user data on the context stack. + */ +#define xmlXPathReturnExternal(ctxt, val) \ + valuePush((ctxt), xmlXPathWrapExternal(val)) + +/** + * xmlXPathStackIsNodeSet: + * @ctxt: an XPath parser context + * + * Check if the current value on the XPath stack is a node set or + * an XSLT value tree. + * + * Returns true if the current object on the stack is a node-set. + */ +#define xmlXPathStackIsNodeSet(ctxt) \ + (((ctxt)->value != NULL) \ + && (((ctxt)->value->type == XPATH_NODESET) \ + || ((ctxt)->value->type == XPATH_XSLT_TREE))) + +/** + * xmlXPathStackIsExternal: + * @ctxt: an XPath parser context + * + * Checks if the current value on the XPath stack is an external + * object. + * + * Returns true if the current object on the stack is an external + * object. + */ +#define xmlXPathStackIsExternal(ctxt) \ + ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS)) + +/** + * xmlXPathEmptyNodeSet: + * @ns: a node-set + * + * Empties a node-set. + */ +#define xmlXPathEmptyNodeSet(ns) \ + { while ((ns)->nodeNr > 0) (ns)->nodeTab[--(ns)->nodeNr] = NULL; } + +/** + * CHECK_ERROR: + * + * Macro to return from the function if an XPath error was detected. + */ +#define CHECK_ERROR \ + if (ctxt->error != XPATH_EXPRESSION_OK) return + +/** + * CHECK_ERROR0: + * + * Macro to return 0 from the function if an XPath error was detected. + */ +#define CHECK_ERROR0 \ + if (ctxt->error != XPATH_EXPRESSION_OK) return(0) + +/** + * XP_ERROR: + * @X: the error code + * + * Macro to raise an XPath error and return. + */ +#define XP_ERROR(X) \ + { xmlXPathErr(ctxt, X); return; } + +/** + * XP_ERROR0: + * @X: the error code + * + * Macro to raise an XPath error and return 0. + */ +#define XP_ERROR0(X) \ + { xmlXPathErr(ctxt, X); return(0); } + +/** + * CHECK_TYPE: + * @typeval: the XPath type + * + * Macro to check that the value on top of the XPath stack is of a given + * type. + */ +#define CHECK_TYPE(typeval) \ + if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ + XP_ERROR(XPATH_INVALID_TYPE) + +/** + * CHECK_TYPE0: + * @typeval: the XPath type + * + * Macro to check that the value on top of the XPath stack is of a given + * type. Return(0) in case of failure + */ +#define CHECK_TYPE0(typeval) \ + if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ + XP_ERROR0(XPATH_INVALID_TYPE) + +/** + * CHECK_ARITY: + * @x: the number of expected args + * + * Macro to check that the number of args passed to an XPath function matches. + */ +#define CHECK_ARITY(x) \ + if (ctxt == NULL) return; \ + if (nargs != (x)) \ + XP_ERROR(XPATH_INVALID_ARITY); \ + if (ctxt->valueNr < (x)) \ + XP_ERROR(XPATH_STACK_ERROR); + +/** + * CAST_TO_STRING: + * + * Macro to try to cast the value on the top of the XPath stack to a string. + */ +#define CAST_TO_STRING \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \ + xmlXPathStringFunction(ctxt, 1); + +/** + * CAST_TO_NUMBER: + * + * Macro to try to cast the value on the top of the XPath stack to a number. + */ +#define CAST_TO_NUMBER \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \ + xmlXPathNumberFunction(ctxt, 1); + +/** + * CAST_TO_BOOLEAN: + * + * Macro to try to cast the value on the top of the XPath stack to a boolean. + */ +#define CAST_TO_BOOLEAN \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \ + xmlXPathBooleanFunction(ctxt, 1); + +/* + * Variable Lookup forwarding. + */ + +XMLPUBFUN void + xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt, + xmlXPathVariableLookupFunc f, + void *data); + +/* + * Function Lookup forwarding. + */ + +XMLPUBFUN void + xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt, + xmlXPathFuncLookupFunc f, + void *funcCtxt); + +/* + * Error reporting. + */ +XMLPUBFUN void + xmlXPatherror (xmlXPathParserContextPtr ctxt, + const char *file, + int line, + int no); + +XMLPUBFUN void + xmlXPathErr (xmlXPathParserContextPtr ctxt, + int error); + +#ifdef LIBXML_DEBUG_ENABLED +XMLPUBFUN void + xmlXPathDebugDumpObject (FILE *output, + xmlXPathObjectPtr cur, + int depth); +XMLPUBFUN void + xmlXPathDebugDumpCompExpr(FILE *output, + xmlXPathCompExprPtr comp, + int depth); +#endif +/** + * NodeSet handling. + */ +XMLPUBFUN int + xmlXPathNodeSetContains (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN xmlNodeSetPtr + xmlXPathDifference (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr + xmlXPathIntersection (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr + xmlXPathDistinctSorted (xmlNodeSetPtr nodes); +XMLPUBFUN xmlNodeSetPtr + xmlXPathDistinct (xmlNodeSetPtr nodes); + +XMLPUBFUN int + xmlXPathHasSameNodes (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr + xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr + xmlXPathLeadingSorted (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr + xmlXPathNodeLeading (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr + xmlXPathLeading (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr + xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr + xmlXPathTrailingSorted (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr + xmlXPathNodeTrailing (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr + xmlXPathTrailing (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + + +/** + * Extending a context. + */ + +XMLPUBFUN int + xmlXPathRegisterNs (xmlXPathContextPtr ctxt, + const xmlChar *prefix, + const xmlChar *ns_uri); +XMLPUBFUN const xmlChar * + xmlXPathNsLookup (xmlXPathContextPtr ctxt, + const xmlChar *prefix); +XMLPUBFUN void + xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt); + +XMLPUBFUN int + xmlXPathRegisterFunc (xmlXPathContextPtr ctxt, + const xmlChar *name, + xmlXPathFunction f); +XMLPUBFUN int + xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri, + xmlXPathFunction f); +XMLPUBFUN int + xmlXPathRegisterVariable (xmlXPathContextPtr ctxt, + const xmlChar *name, + xmlXPathObjectPtr value); +XMLPUBFUN int + xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri, + xmlXPathObjectPtr value); +XMLPUBFUN xmlXPathFunction + xmlXPathFunctionLookup (xmlXPathContextPtr ctxt, + const xmlChar *name); +XMLPUBFUN xmlXPathFunction + xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri); +XMLPUBFUN void + xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathVariableLookup (xmlXPathContextPtr ctxt, + const xmlChar *name); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri); +XMLPUBFUN void + xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt); + +/** + * Utilities to extend XPath. + */ +XMLPUBFUN xmlXPathParserContextPtr + xmlXPathNewParserContext (const xmlChar *str, + xmlXPathContextPtr ctxt); +XMLPUBFUN void + xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); + +XMLPUBFUN xmlXPathObjectPtr + xmlXPathValuePop (xmlXPathParserContextPtr ctxt); +XMLPUBFUN int + xmlXPathValuePush (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr value); + +XMLPUBFUN xmlXPathObjectPtr + xmlXPathNewString (const xmlChar *val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathNewCString (const char *val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathWrapString (xmlChar *val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathWrapCString (char * val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathNewFloat (double val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathNewBoolean (int val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathNewNodeSet (xmlNodePtr val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathNewValueTree (xmlNodePtr val); +XMLPUBFUN int + xmlXPathNodeSetAdd (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN int + xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN int + xmlXPathNodeSetAddNs (xmlNodeSetPtr cur, + xmlNodePtr node, + xmlNsPtr ns); +XMLPUBFUN void + xmlXPathNodeSetSort (xmlNodeSetPtr set); + +XMLPUBFUN void + xmlXPathRoot (xmlXPathParserContextPtr ctxt); +XML_DEPRECATED +XMLPUBFUN void + xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * + xmlXPathParseName (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * + xmlXPathParseNCName (xmlXPathParserContextPtr ctxt); + +/* + * Existing functions. + */ +XMLPUBFUN double + xmlXPathStringEvalNumber (const xmlChar *str); +XMLPUBFUN int + xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr res); +XMLPUBFUN void + xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt); +XMLPUBFUN xmlNodeSetPtr + xmlXPathNodeSetMerge (xmlNodeSetPtr val1, + xmlNodeSetPtr val2); +XMLPUBFUN void + xmlXPathNodeSetDel (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN void + xmlXPathNodeSetRemove (xmlNodeSetPtr cur, + int val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathNewNodeSetList (xmlNodeSetPtr val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathWrapNodeSet (xmlNodeSetPtr val); +XMLPUBFUN xmlXPathObjectPtr + xmlXPathWrapExternal (void *val); + +XMLPUBFUN int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN int xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict); +XMLPUBFUN void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void xmlXPathAddValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void xmlXPathSubValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void xmlXPathMultValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void xmlXPathDivValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void xmlXPathModValues(xmlXPathParserContextPtr ctxt); + +XMLPUBFUN int xmlXPathIsNodeType(const xmlChar *name); + +/* + * Some of the axis navigation routines. + */ +XMLPUBFUN xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +/* + * The official core of XPath functions. + */ +XMLPUBFUN void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs); + +/** + * Really internal functions + */ +XMLPUBFUN void xmlXPathNodeSetFreeNs(xmlNsPtr ns); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPATH_ENABLED */ +#endif /* ! __XML_XPATH_INTERNALS_H__ */ diff --git a/illumos-x86_64/usr/include/libxml2/libxml/xpointer.h b/illumos-x86_64/usr/include/libxml2/libxml/xpointer.h new file mode 100644 index 00000000..16bd5b9f --- /dev/null +++ b/illumos-x86_64/usr/include/libxml2/libxml/xpointer.h @@ -0,0 +1,48 @@ +/* + * Summary: API to handle XML Pointers + * Description: API to handle XML Pointers + * Base implementation was made accordingly to + * W3C Candidate Recommendation 7 June 2000 + * http://www.w3.org/TR/2000/CR-xptr-20000607 + * + * Added support for the element() scheme described in: + * W3C Proposed Recommendation 13 November 2002 + * http://www.w3.org/TR/2002/PR-xptr-element-20021113/ + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPTR_H__ +#define __XML_XPTR_H__ + +#include + +#ifdef LIBXML_XPTR_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Functions. + */ +XML_DEPRECATED +XMLPUBFUN xmlXPathContextPtr + xmlXPtrNewContext (xmlDocPtr doc, + xmlNodePtr here, + xmlNodePtr origin); +XMLPUBFUN xmlXPathObjectPtr + xmlXPtrEval (const xmlChar *str, + xmlXPathContextPtr ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPTR_ENABLED */ +#endif /* __XML_XPTR_H__ */ diff --git a/illumos-x86_64/usr/include/libzfs.h b/illumos-x86_64/usr/include/libzfs.h new file mode 100644 index 00000000..df89daf1 --- /dev/null +++ b/illumos-x86_64/usr/include/libzfs.h @@ -0,0 +1,877 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved. + * Copyright (c) 2011, 2018 by Delphix. All rights reserved. + * Copyright 2020 Joyent, Inc. + * Copyright (c) 2013 Steven Hartland. All rights reserved. + * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Nexenta Systems, Inc. + * Copyright (c) 2017 Datto Inc. + */ + +#ifndef _LIBZFS_H +#define _LIBZFS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Miscellaneous ZFS constants + */ +#define ZFS_MAXPROPLEN MAXPATHLEN +#define ZPOOL_MAXPROPLEN MAXPATHLEN + +/* + * libzfs errors + */ +typedef enum zfs_error { + EZFS_SUCCESS = 0, /* no error -- success */ + EZFS_NOMEM = 2000, /* out of memory */ + EZFS_BADPROP, /* invalid property value */ + EZFS_PROPREADONLY, /* cannot set readonly property */ + EZFS_PROPTYPE, /* property does not apply to dataset type */ + EZFS_PROPNONINHERIT, /* property is not inheritable */ + EZFS_PROPSPACE, /* bad quota or reservation */ + EZFS_BADTYPE, /* dataset is not of appropriate type */ + EZFS_BUSY, /* pool or dataset is busy */ + EZFS_EXISTS, /* pool or dataset already exists */ + EZFS_NOENT, /* no such pool or dataset */ + EZFS_BADSTREAM, /* bad backup stream */ + EZFS_DSREADONLY, /* dataset is readonly */ + EZFS_VOLTOOBIG, /* volume is too large for 32-bit system */ + EZFS_INVALIDNAME, /* invalid dataset name */ + EZFS_BADRESTORE, /* unable to restore to destination */ + EZFS_BADBACKUP, /* backup failed */ + EZFS_BADTARGET, /* bad attach/detach/replace target */ + EZFS_NODEVICE, /* no such device in pool */ + EZFS_BADDEV, /* invalid device to add */ + EZFS_NOREPLICAS, /* no valid replicas */ + EZFS_RESILVERING, /* currently resilvering */ + EZFS_BADVERSION, /* unsupported version */ + EZFS_POOLUNAVAIL, /* pool is currently unavailable */ + EZFS_DEVOVERFLOW, /* too many devices in one vdev */ + EZFS_BADPATH, /* must be an absolute path */ + EZFS_CROSSTARGET, /* rename or clone across pool or dataset */ + EZFS_ZONED, /* used improperly in local zone */ + EZFS_MOUNTFAILED, /* failed to mount dataset */ + EZFS_UMOUNTFAILED, /* failed to unmount dataset */ + EZFS_UNSHARENFSFAILED, /* unshare(8) failed */ + EZFS_SHARENFSFAILED, /* share(8) failed */ + EZFS_PERM, /* permission denied */ + EZFS_NOSPC, /* out of space */ + EZFS_FAULT, /* bad address */ + EZFS_IO, /* I/O error */ + EZFS_INTR, /* signal received */ + EZFS_ISSPARE, /* device is a hot spare */ + EZFS_INVALCONFIG, /* invalid vdev configuration */ + EZFS_RECURSIVE, /* recursive dependency */ + EZFS_NOHISTORY, /* no history object */ + EZFS_POOLPROPS, /* couldn't retrieve pool props */ + EZFS_POOL_NOTSUP, /* ops not supported for this type of pool */ + EZFS_POOL_INVALARG, /* invalid argument for this pool operation */ + EZFS_NAMETOOLONG, /* dataset name is too long */ + EZFS_OPENFAILED, /* open of device failed */ + EZFS_NOCAP, /* couldn't get capacity */ + EZFS_LABELFAILED, /* write of label failed */ + EZFS_BADWHO, /* invalid permission who */ + EZFS_BADPERM, /* invalid permission */ + EZFS_BADPERMSET, /* invalid permission set name */ + EZFS_NODELEGATION, /* delegated administration is disabled */ + EZFS_UNSHARESMBFAILED, /* failed to unshare over smb */ + EZFS_SHARESMBFAILED, /* failed to share over smb */ + EZFS_BADCACHE, /* bad cache file */ + EZFS_ISL2CACHE, /* device is for the level 2 ARC */ + EZFS_VDEVNOTSUP, /* unsupported vdev type */ + EZFS_NOTSUP, /* ops not supported on this dataset */ + EZFS_ACTIVE_SPARE, /* pool has active shared spare devices */ + EZFS_UNPLAYED_LOGS, /* log device has unplayed logs */ + EZFS_REFTAG_RELE, /* snapshot release: tag not found */ + EZFS_REFTAG_HOLD, /* snapshot hold: tag already exists */ + EZFS_TAGTOOLONG, /* snapshot hold/rele: tag too long */ + EZFS_PIPEFAILED, /* pipe create failed */ + EZFS_THREADCREATEFAILED, /* thread create failed */ + EZFS_POSTSPLIT_ONLINE, /* onlining a disk after splitting it */ + EZFS_SCRUBBING, /* currently scrubbing */ + EZFS_NO_SCRUB, /* no active scrub */ + EZFS_DIFF, /* general failure of zfs diff */ + EZFS_DIFFDATA, /* bad zfs diff data */ + EZFS_POOLREADONLY, /* pool is in read-only mode */ + EZFS_SCRUB_PAUSED, /* scrub currently paused */ + EZFS_ACTIVE_POOL, /* pool is imported on a different system */ + EZFS_CRYPTOFAILED, /* failed to setup encryption */ + EZFS_NO_PENDING, /* cannot cancel, no operation is pending */ + EZFS_CHECKPOINT_EXISTS, /* checkpoint exists */ + EZFS_DISCARDING_CHECKPOINT, /* currently discarding a checkpoint */ + EZFS_NO_CHECKPOINT, /* pool has no checkpoint */ + EZFS_DEVRM_IN_PROGRESS, /* a device is currently being removed */ + EZFS_VDEV_TOO_BIG, /* a device is too big to be used */ + EZFS_TOOMANY, /* argument list too long */ + EZFS_INITIALIZING, /* currently initializing */ + EZFS_NO_INITIALIZE, /* no active initialize */ + EZFS_WRONG_PARENT, /* invalid parent dataset (e.g ZVOL) */ + EZFS_TRIMMING, /* currently trimming */ + EZFS_NO_TRIM, /* no active trim */ + EZFS_TRIM_NOTSUP, /* device does not support trim */ + EZFS_NO_RESILVER_DEFER, /* pool doesn't support resilver_defer */ + EZFS_IOC_NOTSUPPORTED, /* operation not supported by zfs module */ + EZFS_UNKNOWN +} zfs_error_t; + +/* + * UEFI boot support parameters. When creating whole disk boot pool, + * zpool create should allow to create EFI System partition for UEFI boot + * program. In case of BIOS, the EFI System partition is not used + * even if it does exist. + */ +typedef enum zpool_boot_label { + ZPOOL_NO_BOOT_LABEL = 0, + ZPOOL_CREATE_BOOT_LABEL, + ZPOOL_COPY_BOOT_LABEL +} zpool_boot_label_t; + +/* + * The following data structures are all part + * of the zfs_allow_t data structure which is + * used for printing 'allow' permissions. + * It is a linked list of zfs_allow_t's which + * then contain avl tree's for user/group/sets/... + * and each one of the entries in those trees have + * avl tree's for the permissions they belong to and + * whether they are local,descendent or local+descendent + * permissions. The AVL trees are used primarily for + * sorting purposes, but also so that we can quickly find + * a given user and or permission. + */ +typedef struct zfs_perm_node { + avl_node_t z_node; + char z_pname[MAXPATHLEN]; +} zfs_perm_node_t; + +typedef struct zfs_allow_node { + avl_node_t z_node; + char z_key[MAXPATHLEN]; /* name, such as joe */ + avl_tree_t z_localdescend; /* local+descendent perms */ + avl_tree_t z_local; /* local permissions */ + avl_tree_t z_descend; /* descendent permissions */ +} zfs_allow_node_t; + +typedef struct zfs_allow { + struct zfs_allow *z_next; + char z_setpoint[MAXPATHLEN]; + avl_tree_t z_sets; + avl_tree_t z_crperms; + avl_tree_t z_user; + avl_tree_t z_group; + avl_tree_t z_everyone; +} zfs_allow_t; + +/* + * Basic handle types + */ +typedef struct zfs_handle zfs_handle_t; +typedef struct zpool_handle zpool_handle_t; +typedef struct libzfs_handle libzfs_handle_t; + +/* + * Library initialization + */ +extern libzfs_handle_t *libzfs_init(void); +extern void libzfs_fini(libzfs_handle_t *); + +extern libzfs_handle_t *zpool_get_handle(zpool_handle_t *); +extern libzfs_handle_t *zfs_get_handle(zfs_handle_t *); + +extern void libzfs_print_on_error(libzfs_handle_t *, boolean_t); + +extern void zfs_save_arguments(int argc, char **, char *, int); +extern int zpool_log_history(libzfs_handle_t *, const char *); + +extern int libzfs_errno(libzfs_handle_t *); +extern const char *libzfs_error_action(libzfs_handle_t *); +extern const char *libzfs_error_description(libzfs_handle_t *); +extern int zfs_standard_error(libzfs_handle_t *, int, const char *); +extern void libzfs_mnttab_init(libzfs_handle_t *); +extern void libzfs_mnttab_fini(libzfs_handle_t *); +extern void libzfs_mnttab_cache(libzfs_handle_t *, boolean_t); +extern int libzfs_mnttab_find(libzfs_handle_t *, const char *, + struct mnttab *); +extern void libzfs_mnttab_add(libzfs_handle_t *, const char *, + const char *, const char *); +extern void libzfs_mnttab_remove(libzfs_handle_t *, const char *); + +/* + * Basic handle functions + */ +extern zpool_handle_t *zpool_open(libzfs_handle_t *, const char *); +extern zpool_handle_t *zpool_open_canfail(libzfs_handle_t *, const char *); +extern void zpool_close(zpool_handle_t *); +extern const char *zpool_get_name(zpool_handle_t *); +extern int zpool_get_state(zpool_handle_t *); +extern const char *zpool_state_to_name(vdev_state_t, vdev_aux_t); +extern const char *zpool_pool_state_to_name(pool_state_t); +extern void zpool_free_handles(libzfs_handle_t *); + +/* + * Iterate over all active pools in the system. + */ +typedef int (*zpool_iter_f)(zpool_handle_t *, void *); +extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *); +extern boolean_t zpool_skip_pool(const char *); + +/* + * Functions to create and destroy pools + */ +extern int zpool_create(libzfs_handle_t *, const char *, nvlist_t *, + nvlist_t *, nvlist_t *); +extern int zpool_destroy(zpool_handle_t *, const char *); +extern int zpool_add(zpool_handle_t *, nvlist_t *); + +typedef struct splitflags { + /* do not split, but return the config that would be split off */ + int dryrun : 1; + + /* after splitting, import the pool */ + int import : 1; + int name_flags; +} splitflags_t; + +typedef struct trimflags { + /* requested vdevs are for the entire pool */ + boolean_t fullpool; + + /* request a secure trim, requires support from device */ + boolean_t secure; + + /* trim at the requested rate in bytes/second */ + uint64_t rate; +} trimflags_t; + +/* + * Functions to manipulate pool and vdev state + */ +extern int zpool_scan(zpool_handle_t *, pool_scan_func_t, pool_scrub_cmd_t); +extern int zpool_initialize(zpool_handle_t *, pool_initialize_func_t, + nvlist_t *); +extern int zpool_trim(zpool_handle_t *, pool_trim_func_t, nvlist_t *, + trimflags_t *); + +extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *); +extern int zpool_reguid(zpool_handle_t *); +extern int zpool_reopen(zpool_handle_t *); + +extern int zpool_sync_one(zpool_handle_t *, void *); + +extern int zpool_vdev_online(zpool_handle_t *, const char *, int, + vdev_state_t *); +extern int zpool_vdev_offline(zpool_handle_t *, const char *, boolean_t); +extern int zpool_vdev_attach(zpool_handle_t *, const char *, + const char *, nvlist_t *, int); +extern int zpool_vdev_detach(zpool_handle_t *, const char *); +extern int zpool_vdev_remove(zpool_handle_t *, const char *); +extern int zpool_vdev_remove_cancel(zpool_handle_t *); +extern int zpool_vdev_indirect_size(zpool_handle_t *, const char *, uint64_t *); +extern int zpool_vdev_split(zpool_handle_t *, char *, nvlist_t **, nvlist_t *, + splitflags_t); + +extern int zpool_vdev_fault(zpool_handle_t *, uint64_t, vdev_aux_t); +extern int zpool_vdev_degrade(zpool_handle_t *, uint64_t, vdev_aux_t); +extern int zpool_vdev_clear(zpool_handle_t *, uint64_t); + +extern nvlist_t *zpool_find_vdev(zpool_handle_t *, const char *, boolean_t *, + boolean_t *, boolean_t *); +extern nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *, + boolean_t *, boolean_t *, boolean_t *); +extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, const char *, + zpool_boot_label_t, uint64_t, int *); +extern void zpool_vdev_refresh_path(libzfs_handle_t *, zpool_handle_t *, + nvlist_t *); + +/* + * Functions to manage pool properties + */ +extern int zpool_set_prop(zpool_handle_t *, const char *, const char *); +extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *, + size_t proplen, zprop_source_t *, boolean_t); +extern uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t, + zprop_source_t *); + +extern const char *zpool_prop_to_name(zpool_prop_t); +extern const char *zpool_prop_values(zpool_prop_t); + +/* + * Pool health statistics. + */ +typedef enum { + /* + * The following correspond to faults as defined in the (fault.fs.zfs.*) + * event namespace. Each is associated with a corresponding message ID. + * This must be kept in sync with the zfs_msgid_table in + * lib/libzfs/libzfs_status.c. + */ + ZPOOL_STATUS_CORRUPT_CACHE, /* corrupt /kernel/drv/zpool.cache */ + ZPOOL_STATUS_MISSING_DEV_R, /* missing device with replicas */ + ZPOOL_STATUS_MISSING_DEV_NR, /* missing device with no replicas */ + ZPOOL_STATUS_CORRUPT_LABEL_R, /* bad device label with replicas */ + ZPOOL_STATUS_CORRUPT_LABEL_NR, /* bad device label with no replicas */ + ZPOOL_STATUS_BAD_GUID_SUM, /* sum of device guids didn't match */ + ZPOOL_STATUS_CORRUPT_POOL, /* pool metadata is corrupted */ + ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */ + ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */ + ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */ + ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */ + ZPOOL_STATUS_HOSTID_ACTIVE, /* currently active on another system */ + ZPOOL_STATUS_HOSTID_REQUIRED, /* multihost=on and hostid=0 */ + ZPOOL_STATUS_IO_FAILURE_WAIT, /* failed I/O, failmode 'wait' */ + ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */ + ZPOOL_STATUS_IO_FAILURE_MMP, /* failed MMP, failmode not 'panic' */ + ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */ + ZPOOL_STATUS_ERRATA, /* informational errata available */ + + /* + * If the pool has unsupported features but can still be opened in + * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the + * pool has unsupported features but cannot be opened at all, its + * status is ZPOOL_STATUS_UNSUP_FEAT_READ. + */ + ZPOOL_STATUS_UNSUP_FEAT_READ, /* unsupported features for read */ + ZPOOL_STATUS_UNSUP_FEAT_WRITE, /* unsupported features for write */ + + /* + * These faults have no corresponding message ID. At the time we are + * checking the status, the original reason for the FMA fault (I/O or + * checksum errors) has been lost. + */ + ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */ + ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */ + + /* + * The following are not faults per se, but still an error possibly + * requiring administrative attention. There is no corresponding + * message ID. + */ + ZPOOL_STATUS_VERSION_OLDER, /* older legacy on-disk version */ + ZPOOL_STATUS_FEAT_DISABLED, /* supported features are disabled */ + ZPOOL_STATUS_RESILVERING, /* device being resilvered */ + ZPOOL_STATUS_OFFLINE_DEV, /* device offline */ + ZPOOL_STATUS_REMOVED_DEV, /* removed device */ + + /* + * Finally, the following indicates a healthy pool. + */ + ZPOOL_STATUS_OK +} zpool_status_t; + +extern zpool_status_t zpool_get_status(zpool_handle_t *, char **, + zpool_errata_t *); +extern zpool_status_t zpool_import_status(nvlist_t *, char **, + zpool_errata_t *); + +/* + * Statistics and configuration functions. + */ +extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **); +extern nvlist_t *zpool_get_features(zpool_handle_t *); +extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *); +extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **); +extern boolean_t zpool_is_bootable(zpool_handle_t *); + +/* + * Import and export functions + */ +extern int zpool_export(zpool_handle_t *, boolean_t, const char *); +extern int zpool_export_force(zpool_handle_t *, const char *); +extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *, + char *altroot); +extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *, + nvlist_t *, int); +extern void zpool_print_unsup_feat(nvlist_t *config); + +/* + * Miscellaneous pool functions + */ +struct zfs_cmd; + +extern const char *zfs_history_event_names[]; + +typedef enum { + VDEV_NAME_PATH = 1 << 0, + VDEV_NAME_GUID = 1 << 1, + VDEV_NAME_FOLLOW_LINKS = 1 << 2, + VDEV_NAME_TYPE_ID = 1 << 3, +} vdev_name_t; + +extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *, + int name_flags); +extern int zpool_upgrade(zpool_handle_t *, uint64_t); +extern int zpool_get_history(zpool_handle_t *, nvlist_t **, uint64_t *, + boolean_t *); +extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *, + size_t len); +extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *); +extern int zpool_get_physpath(zpool_handle_t *, char *, size_t); +extern void zpool_explain_recover(libzfs_handle_t *, const char *, int, + nvlist_t *); +extern int zpool_checkpoint(zpool_handle_t *); +extern int zpool_discard_checkpoint(zpool_handle_t *); + +/* + * Basic handle manipulations. These functions do not create or destroy the + * underlying datasets, only the references to them. + */ +extern zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int); +extern zfs_handle_t *zfs_handle_dup(zfs_handle_t *); +extern void zfs_close(zfs_handle_t *); +extern zfs_type_t zfs_get_type(const zfs_handle_t *); +extern const char *zfs_get_name(const zfs_handle_t *); +extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *); +extern const char *zfs_get_pool_name(const zfs_handle_t *); + +/* + * Property management functions. Some functions are shared with the kernel, + * and are found in sys/fs/zfs.h. + */ + +/* + * zfs dataset property management + */ +extern const char *zfs_prop_default_string(zfs_prop_t); +extern uint64_t zfs_prop_default_numeric(zfs_prop_t); +extern const char *zfs_prop_column_name(zfs_prop_t); +extern boolean_t zfs_prop_align_right(zfs_prop_t); + +extern nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t, nvlist_t *, + uint64_t, zfs_handle_t *, zpool_handle_t *, boolean_t, const char *); + +extern const char *zfs_prop_to_name(zfs_prop_t); +extern int zfs_prop_set(zfs_handle_t *, const char *, const char *); +extern int zfs_prop_set_list(zfs_handle_t *, nvlist_t *); +extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t, + zprop_source_t *, char *, size_t, boolean_t); +extern int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t, + boolean_t); +extern int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *, + zprop_source_t *, char *, size_t); +extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname, + uint64_t *propvalue); +extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname, + char *propbuf, int proplen, boolean_t literal); +extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname, + uint64_t *propvalue); +extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname, + char *propbuf, int proplen, boolean_t literal); +extern int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname, + char *buf, size_t len); +extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t); +extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t); +extern const char *zfs_prop_values(zfs_prop_t); +extern int zfs_prop_is_string(zfs_prop_t prop); +extern nvlist_t *zfs_get_user_props(zfs_handle_t *); +extern nvlist_t *zfs_get_recvd_props(zfs_handle_t *); +extern nvlist_t *zfs_get_clones_nvl(zfs_handle_t *); + + +/* + * zfs encryption management + */ +extern int zfs_crypto_get_encryption_root(zfs_handle_t *, boolean_t *, char *); +extern int zfs_crypto_create(libzfs_handle_t *, char *, nvlist_t *, nvlist_t *, + boolean_t stdin_available, uint8_t **, uint_t *); +extern int zfs_crypto_clone_check(libzfs_handle_t *, zfs_handle_t *, char *, + nvlist_t *); +extern int zfs_crypto_attempt_load_keys(libzfs_handle_t *, char *); +extern int zfs_crypto_load_key(zfs_handle_t *, boolean_t, char *); +extern int zfs_crypto_unload_key(zfs_handle_t *); +extern int zfs_crypto_rewrap(zfs_handle_t *, nvlist_t *, boolean_t); + +typedef struct zprop_list { + int pl_prop; + char *pl_user_prop; + struct zprop_list *pl_next; + boolean_t pl_all; + size_t pl_width; + size_t pl_recvd_width; + boolean_t pl_fixed; +} zprop_list_t; + +extern int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **, boolean_t, + boolean_t); +extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *); + +#define ZFS_MOUNTPOINT_NONE "none" +#define ZFS_MOUNTPOINT_LEGACY "legacy" + +#define ZFS_FEATURE_DISABLED "disabled" +#define ZFS_FEATURE_ENABLED "enabled" +#define ZFS_FEATURE_ACTIVE "active" + +#define ZFS_UNSUPPORTED_INACTIVE "inactive" +#define ZFS_UNSUPPORTED_READONLY "readonly" + +/* + * zpool property management + */ +extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **); +extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *, + size_t); +extern const char *zpool_prop_default_string(zpool_prop_t); +extern uint64_t zpool_prop_default_numeric(zpool_prop_t); +extern const char *zpool_prop_column_name(zpool_prop_t); +extern boolean_t zpool_prop_align_right(zpool_prop_t); + +/* + * Functions shared by zfs and zpool property management. + */ +extern int zprop_iter(zprop_func func, void *cb, boolean_t show_all, + boolean_t ordered, zfs_type_t type); +extern int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **, + zfs_type_t); +extern void zprop_free_list(zprop_list_t *); + +#define ZFS_GET_NCOLS 5 + +typedef enum { + GET_COL_NONE, + GET_COL_NAME, + GET_COL_PROPERTY, + GET_COL_VALUE, + GET_COL_RECVD, + GET_COL_SOURCE +} zfs_get_column_t; + +/* + * Functions for printing zfs or zpool properties + */ +typedef struct zprop_get_cbdata { + int cb_sources; + zfs_get_column_t cb_columns[ZFS_GET_NCOLS]; + int cb_colwidths[ZFS_GET_NCOLS + 1]; + boolean_t cb_scripted; + boolean_t cb_literal; + boolean_t cb_first; + zprop_list_t *cb_proplist; + zfs_type_t cb_type; +} zprop_get_cbdata_t; + +void zprop_print_one_property(const char *, zprop_get_cbdata_t *, + const char *, const char *, zprop_source_t, const char *, + const char *); + +/* + * Iterator functions. + */ +typedef int (*zfs_iter_f)(zfs_handle_t *, void *); +extern int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *); +extern int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *); +extern int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, void *); +extern int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *); +extern int zfs_iter_snapshots(zfs_handle_t *, boolean_t, zfs_iter_f, void *); +extern int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *); +extern int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, void *); +extern int zfs_iter_bookmarks(zfs_handle_t *, zfs_iter_f, void *); + +typedef struct get_all_cb { + zfs_handle_t **cb_handles; + size_t cb_alloc; + size_t cb_used; +} get_all_cb_t; + +void zfs_foreach_mountpoint(libzfs_handle_t *, zfs_handle_t **, size_t, + zfs_iter_f, void *, boolean_t); +void libzfs_add_handle(get_all_cb_t *, zfs_handle_t *); + +/* + * Functions to create and destroy datasets. + */ +extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t, + nvlist_t *); +extern int zfs_create_ancestors(libzfs_handle_t *, const char *); +extern int zfs_destroy(zfs_handle_t *, boolean_t); +extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t); +extern int zfs_destroy_snaps_nvl(libzfs_handle_t *, nvlist_t *, boolean_t); +extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *); +extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, nvlist_t *); +extern int zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, + nvlist_t *props); +extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t); +extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t); + +typedef struct sendflags { + /* print informational messages (ie, -v was specified) */ + boolean_t verbose; + + /* recursive send (ie, -R) */ + boolean_t replicate; + + /* for incrementals, do all intermediate snapshots */ + boolean_t doall; + + /* if dataset is a clone, do incremental from its origin */ + boolean_t fromorigin; + + /* do deduplication */ + boolean_t dedup; + + /* send properties (ie, -p) */ + boolean_t props; + + /* do not send (no-op, ie. -n) */ + boolean_t dryrun; + + /* parsable verbose output (ie. -P) */ + boolean_t parsable; + + /* show progress (ie. -v) */ + boolean_t progress; + + /* large blocks (>128K) are permitted */ + boolean_t largeblock; + + /* WRITE_EMBEDDED records of type DATA are permitted */ + boolean_t embed_data; + + /* compressed WRITE records are permitted */ + boolean_t compress; + + /* raw encrypted records are permitted */ + boolean_t raw; + + /* only send received properties (ie. -b) */ + boolean_t backup; + + /* include snapshot holds in send stream */ + boolean_t holds; +} sendflags_t; + +typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *); + +extern int zfs_send(zfs_handle_t *, const char *, const char *, + sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **); +extern int zfs_send_one(zfs_handle_t *, const char *, int, enum lzc_send_flags); +extern int zfs_send_resume(libzfs_handle_t *, sendflags_t *, int outfd, + const char *); +extern nvlist_t *zfs_send_resume_token_to_nvlist(libzfs_handle_t *hdl, + const char *token); + +extern int zfs_promote(zfs_handle_t *); +extern int zfs_hold(zfs_handle_t *, const char *, const char *, + boolean_t, int); +extern int zfs_hold_nvl(zfs_handle_t *, int, nvlist_t *); +extern int zfs_release(zfs_handle_t *, const char *, const char *, boolean_t); +extern int zfs_get_holds(zfs_handle_t *, nvlist_t **); +extern uint64_t zvol_volsize_to_reservation(zpool_handle_t *, uint64_t, + nvlist_t *); + +typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain, + uid_t rid, uint64_t space); + +extern int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t, + zfs_userspace_cb_t, void *); + +extern int zfs_get_fsacl(zfs_handle_t *, nvlist_t **); +extern int zfs_set_fsacl(zfs_handle_t *, boolean_t, nvlist_t *); + +typedef struct recvflags { + /* print informational messages (ie, -v was specified) */ + boolean_t verbose; + + /* the destination is a prefix, not the exact fs (ie, -d) */ + boolean_t isprefix; + + /* + * Only the tail of the sent snapshot path is appended to the + * destination to determine the received snapshot name (ie, -e). + */ + boolean_t istail; + + /* do not actually do the recv, just check if it would work (ie, -n) */ + boolean_t dryrun; + + /* rollback/destroy filesystems as necessary (eg, -F) */ + boolean_t force; + + /* set "canmount=off" on all modified filesystems */ + boolean_t canmountoff; + + /* + * Mark the file systems as "resumable" and do not destroy them if the + * receive is interrupted + */ + boolean_t resumable; + + /* byteswap flag is used internally; callers need not specify */ + boolean_t byteswap; + + /* do not mount file systems as they are extracted (private) */ + boolean_t nomount; + + /* Was holds flag set in the compound header? */ + boolean_t holds; + + /* skip receive of snapshot holds */ + boolean_t skipholds; +} recvflags_t; + +extern int zfs_receive(libzfs_handle_t *, const char *, nvlist_t *, + recvflags_t *, int, avl_tree_t *); + +typedef enum diff_flags { + ZFS_DIFF_PARSEABLE = 0x1, + ZFS_DIFF_TIMESTAMP = 0x2, + ZFS_DIFF_CLASSIFY = 0x4 +} diff_flags_t; + +extern int zfs_show_diffs(zfs_handle_t *, int, const char *, const char *, + int); + +/* + * Miscellaneous functions. + */ +extern const char *zfs_type_to_name(zfs_type_t); +extern void zfs_refresh_properties(zfs_handle_t *); +extern int zfs_name_valid(const char *, zfs_type_t); +extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, char *, zfs_type_t); +extern int zfs_parent_name(zfs_handle_t *, char *, size_t); +extern boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *, + zfs_type_t); +extern int zfs_spa_version(zfs_handle_t *, int *); +extern boolean_t zfs_bookmark_exists(const char *path); + +/* + * Mount support functions. + */ +extern boolean_t is_mounted(libzfs_handle_t *, const char *special, char **); +extern boolean_t zfs_is_mounted(zfs_handle_t *, char **); +extern int zfs_mount(zfs_handle_t *, const char *, int); +extern int zfs_unmount(zfs_handle_t *, const char *, int); +extern int zfs_unmountall(zfs_handle_t *, int); + +/* + * Share support functions. + */ +extern boolean_t zfs_is_shared(zfs_handle_t *); +extern int zfs_share(zfs_handle_t *); +extern int zfs_unshare(zfs_handle_t *); + +/* + * Protocol-specific share support functions. + */ +extern boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **); +extern boolean_t zfs_is_shared_smb(zfs_handle_t *, char **); +extern int zfs_share_nfs(zfs_handle_t *); +extern int zfs_share_smb(zfs_handle_t *); +extern int zfs_shareall(zfs_handle_t *); +extern int zfs_unshare_nfs(zfs_handle_t *, const char *); +extern int zfs_unshare_smb(zfs_handle_t *, const char *); +extern int zfs_unshareall_nfs(zfs_handle_t *); +extern int zfs_unshareall_smb(zfs_handle_t *); +extern int zfs_unshareall_bypath(zfs_handle_t *, const char *); +extern int zfs_unshareall(zfs_handle_t *); +extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *, + void *, void *, int, zfs_share_op_t); + +/* + * When dealing with nvlists, verify() is extremely useful + */ +#ifdef NDEBUG +#define verify(EX) ((void)(EX)) +#else +#define verify(EX) assert(EX) +#endif + +extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *); + +/* + * Given a device or file, determine if it is part of a pool. + */ +extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **, + boolean_t *); + +/* + * Label manipulation. + */ +extern int zpool_clear_label(int); +extern int zpool_set_bootenv(zpool_handle_t *, const nvlist_t *); +extern int zpool_get_bootenv(zpool_handle_t *, nvlist_t **); + +/* is this zvol valid for use as a dump device? */ +extern int zvol_check_dump_config(char *); + +/* + * Management interfaces for SMB ACL files + */ + +int zfs_smb_acl_add(libzfs_handle_t *, char *, char *, char *); +int zfs_smb_acl_remove(libzfs_handle_t *, char *, char *, char *); +int zfs_smb_acl_purge(libzfs_handle_t *, char *, char *); +int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, char *); + +/* + * Enable and disable datasets within a pool by mounting/unmounting and + * sharing/unsharing them. + */ +extern int zpool_enable_datasets(zpool_handle_t *, const char *, int); +extern int zpool_disable_datasets(zpool_handle_t *, boolean_t); + +/* + * Mappings between vdev and FRU. + */ +extern void libzfs_fru_refresh(libzfs_handle_t *); +extern const char *libzfs_fru_lookup(libzfs_handle_t *, const char *); +extern const char *libzfs_fru_devpath(libzfs_handle_t *, const char *); +extern boolean_t libzfs_fru_compare(libzfs_handle_t *, const char *, + const char *); +extern boolean_t libzfs_fru_notself(libzfs_handle_t *, const char *); +extern int zpool_fru_set(zpool_handle_t *, uint64_t, const char *); + +extern int zfs_get_hole_count(const char *, uint64_t *, uint64_t *); +extern int zfs_remap_indirects(libzfs_handle_t *hdl, const char *); + +/* Allow consumers to initialize libshare externally for optimal performance */ +extern int zfs_init_libshare_arg(libzfs_handle_t *, int, void *); +/* + * For most consumers, zfs_init_libshare_arg is sufficient on its own, and + * zfs_uninit_libshare is unnecessary. zfs_uninit_libshare should only be called + * if the caller has already initialized libshare for one set of zfs handles, + * and wishes to share or unshare filesystems outside of that set. In that case, + * the caller should uninitialize libshare, and then re-initialize it with the + * new handles being shared or unshared. + */ +extern void zfs_uninit_libshare(libzfs_handle_t *); +#ifdef __cplusplus +} +#endif + +#endif /* _LIBZFS_H */ diff --git a/illumos-x86_64/usr/include/libzfs_core.h b/illumos-x86_64/usr/include/libzfs_core.h new file mode 100644 index 00000000..4b408cbb --- /dev/null +++ b/illumos-x86_64/usr/include/libzfs_core.h @@ -0,0 +1,127 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012, 2020 by Delphix. All rights reserved. + * Copyright (c) 2014 Integros [integros.com] + * Copyright 2017 RackTop Systems. + * Copyright (c) 2017 Datto Inc. + */ + +#ifndef _LIBZFS_CORE_H +#define _LIBZFS_CORE_H + +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +int libzfs_core_init(void); +void libzfs_core_fini(void); + +/* + * NB: this type should be kept binary compatible with dmu_objset_type_t. + */ +enum lzc_dataset_type { + LZC_DATSET_TYPE_ZFS = 2, + LZC_DATSET_TYPE_ZVOL +}; + +int lzc_remap(const char *fsname); +int lzc_snapshot(nvlist_t *, nvlist_t *, nvlist_t **); +int lzc_create(const char *, enum lzc_dataset_type, nvlist_t *, uint8_t *, + uint_t); +int lzc_clone(const char *, const char *, nvlist_t *); +int lzc_promote(const char *, char *, int); +int lzc_destroy_snaps(nvlist_t *, boolean_t, nvlist_t **); +int lzc_bookmark(nvlist_t *, nvlist_t **); +int lzc_get_bookmarks(const char *, nvlist_t *, nvlist_t **); +int lzc_destroy_bookmarks(nvlist_t *, nvlist_t **); +int lzc_initialize(const char *, pool_initialize_func_t, nvlist_t *, + nvlist_t **); +int lzc_trim(const char *, pool_trim_func_t, uint64_t, boolean_t, + nvlist_t *, nvlist_t **); + +int lzc_load_key(const char *, boolean_t, uint8_t *, uint_t); +int lzc_unload_key(const char *); +int lzc_change_key(const char *, uint64_t, nvlist_t *, uint8_t *, uint_t); + +int lzc_snaprange_space(const char *, const char *, uint64_t *); + +int lzc_hold(nvlist_t *, int, nvlist_t **); +int lzc_release(nvlist_t *, nvlist_t **); +int lzc_get_holds(const char *, nvlist_t **); + +enum lzc_send_flags { + LZC_SEND_FLAG_EMBED_DATA = 1 << 0, + LZC_SEND_FLAG_LARGE_BLOCK = 1 << 1, + LZC_SEND_FLAG_COMPRESS = 1 << 2, + LZC_SEND_FLAG_RAW = 1 << 3 +}; + +int lzc_send(const char *, const char *, int, enum lzc_send_flags); +int lzc_send_resume(const char *, const char *, int, + enum lzc_send_flags, uint64_t, uint64_t); +int lzc_send_space(const char *, const char *, enum lzc_send_flags, uint64_t *); + +struct dmu_replay_record; + +int lzc_receive(const char *, nvlist_t *, const char *, boolean_t, + boolean_t, int); +int lzc_receive_resumable(const char *, nvlist_t *, const char *, + boolean_t, boolean_t, int); +int lzc_receive_with_header(const char *, nvlist_t *, const char *, boolean_t, + boolean_t, boolean_t, int, const struct dmu_replay_record *); +int lzc_receive_with_cmdprops(const char *, nvlist_t *, nvlist_t *, + uint8_t *, uint_t, const char *, boolean_t, boolean_t, boolean_t, int, + const struct dmu_replay_record *, int, uint64_t *, uint64_t *, + uint64_t *, nvlist_t **); + +boolean_t lzc_exists(const char *); + +int lzc_rollback(const char *, char *, int); +int lzc_rollback_to(const char *, const char *); + +int lzc_sync(const char *, nvlist_t *, nvlist_t **); + +int lzc_rename(const char *, const char *); +int lzc_destroy(const char *); + +int lzc_channel_program(const char *, const char *, uint64_t, + uint64_t, nvlist_t *, nvlist_t **); +int lzc_channel_program_nosync(const char *, const char *, uint64_t, + uint64_t, nvlist_t *, nvlist_t **); + +int lzc_pool_checkpoint(const char *); +int lzc_pool_checkpoint_discard(const char *); + +int lzc_set_bootenv(const char *, const nvlist_t *); +int lzc_get_bootenv(const char *, nvlist_t **); +#ifdef __cplusplus +} +#endif + +#endif /* _LIBZFS_CORE_H */ diff --git a/illumos-x86_64/usr/include/libzfsbootenv.h b/illumos-x86_64/usr/include/libzfsbootenv.h new file mode 100644 index 00000000..9d0422fa --- /dev/null +++ b/illumos-x86_64/usr/include/libzfsbootenv.h @@ -0,0 +1,41 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2020 Toomas Soome + */ + +#ifndef _LIBZFSBOOTENV_H +#define _LIBZFSBOOTENV_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum lzbe_flags { + lzbe_add, /* add data to existing nvlist */ + lzbe_replace /* replace current nvlist */ +} lzbe_flags_t; + +extern int lzbe_nvlist_get(const char *, const char *, void **); +extern int lzbe_nvlist_set(const char *, const char *, void *); +extern void lzbe_nvlist_free(void *); +extern int lzbe_add_pair(void *, const char *, const char *, void *, size_t); +extern int lzbe_remove_pair(void *, const char *); +extern int lzbe_set_boot_device(const char *, lzbe_flags_t, const char *); +extern int lzbe_get_boot_device(const char *, char **); +extern int lzbe_bootenv_print(const char *, const char *, FILE *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBZFSBOOTENV_H */ diff --git a/illumos-x86_64/usr/include/libzoneinfo.h b/illumos-x86_64/usr/include/libzoneinfo.h new file mode 100644 index 00000000..149889ae --- /dev/null +++ b/illumos-x86_64/usr/include/libzoneinfo.h @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBZONEINFO_H +#define _LIBZONEINFO_H + +/* + * WARNING: + * + * The interfaces defined in this header file are for Sun private use only. + * The contents of this file are subject to change without notice for the + * future releases. + */ + +/* + * Declarations for the functions in libzoneinfo + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define _TZBUFLEN 128 /* timezone name buffer length */ +#define _CCBUFLEN 32 /* country code buffer length */ + +#define _GMT_MAX (12*60*60) /* The maximum GMT offset */ +#define _GMT_MIN (-13*60*60) /* The minimum GMT offset */ + +#define _VTZ_INSTALL 0 /* zoneinfo or POSIX offset-from-GMT */ +#define _VTZ_ALL 1 /* zoneinfo or POSIX */ +#define _VTZ_POSIX 2 /* POSIX timezone */ +#define _VTZ_ZONEINFO 3 /* zoneinfo timezone */ + +struct tz_timezone { + char tz_name[_TZBUFLEN]; /* timezone name */ + char tz_oname[_TZBUFLEN]; + char *tz_id_desc; /* timezone description */ + char *tz_display_desc; /* l10n timezone description */ + struct tz_coord { /* coordinates */ + int lat_sign; + unsigned int lat_degree; + unsigned int lat_minute; + unsigned int lat_second; + int long_sign; + unsigned int long_degree; + unsigned int long_minute; + unsigned int long_second; + } tz_coord; + struct tz_timezone *tz_next; /* pointer to next element */ + void *tz_reserved; /* reserved */ +}; + +struct tz_continent { + char ctnt_name[_TZBUFLEN]; /* continent name */ + char *ctnt_id_desc; /* continent name (descriptive) */ + char *ctnt_display_desc; /* localized continent name */ + struct tz_continent *ctnt_next; /* pointer to next element */ + void *ctnt_reserved; /* reserved */ +}; + +struct tz_country { + char ctry_code[_CCBUFLEN]; /* country code */ + char *ctry_id_desc; /* country name (descriptive) */ + char *ctry_display_desc; /* localized country name */ + int ctry_status; /* private use */ + struct tz_country *ctry_next; /* pointer to next element */ + void *ctry_reserved; /* reserved */ +}; + +extern int get_tz_continents(struct tz_continent **); +extern int get_tz_countries(struct tz_country **, struct tz_continent *); +extern int get_timezones_by_country(struct tz_timezone **, struct tz_country *); +extern int free_tz_continents(struct tz_continent *); +extern int free_tz_countries(struct tz_country *); +extern int free_timezones(struct tz_timezone *); +extern char *conv_gmt(int, int); +extern char *get_system_tz(char *); +extern int set_system_tz(char *, char *); +extern int isvalid_tz(char *, char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBZONEINFO_H */ diff --git a/illumos-x86_64/usr/include/limits.h b/illumos-x86_64/usr/include/limits.h new file mode 100644 index 00000000..6dfcc9b6 --- /dev/null +++ b/illumos-x86_64/usr/include/limits.h @@ -0,0 +1,339 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2013 Gary Mills + * Copyright 2017 RackTop Systems. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _LIMITS_H +#define _LIMITS_H + +#include +#include +#include +#include + +/* + * Include fixed width type limits as proposed by the ISO/JTC1/SC22/WG14 C + * committee's working draft for the revision of the current ISO C standard, + * ISO/IEC 9899:1990 Programming language - C. These are not currently + * required by any standard but constitute a useful, general purpose set + * of type definitions and limits which is namespace clean with respect to + * all standards. + */ +#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \ + defined(__XOPEN_OR_POSIX) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \ + defined(__XOPEN_OR_POSIX) + +#define SSIZE_MAX LONG_MAX /* max value of an "ssize_t" */ + +/* + * ARG_MAX is calculated as follows: + * NCARGS - space for other stuff on initial stack + * like aux vectors, saved registers, etc.. + */ +#define _ARG_MAX32 1048320 /* max length of args to exec 32-bit program */ +#define _ARG_MAX64 2096640 /* max length of args to exec 64-bit program */ +#ifdef _LP64 +#define ARG_MAX _ARG_MAX64 /* max length of arguments to exec */ +#else /* _LP64 */ +#define ARG_MAX _ARG_MAX32 /* max length of arguments to exec */ +#endif /* _LP64 */ + + +/* + * These two symbols have their historical values, the actual buffer is + * larger. + */ +#ifndef MAX_CANON +#define MAX_CANON 256 /* max bytes in line for canonical processing */ +#endif + +#ifndef MAX_INPUT +#define MAX_INPUT 512 /* max size of a char input buffer */ +#endif + +#define NGROUPS_MAX 16 /* max number of groups for a user */ + +#ifndef PATH_MAX +#define PATH_MAX 1024 /* max # of characters in a path name */ +#endif + +#define SYMLINK_MAX 1024 /* max # of characters a symlink can contain */ + +#define PIPE_BUF 5120 /* max # bytes atomic in write to a pipe */ + +#ifndef TMP_MAX +#define TMP_MAX 17576 /* 26 * 26 * 26 */ +#endif + +/* + * POSIX conformant definitions - An implementation may define + * other symbols which reflect the actual implementation. Alternate + * definitions may not be as restrictive as the POSIX definitions. + */ +#define _POSIX_AIO_LISTIO_MAX 2 +#define _POSIX_AIO_MAX 1 +#define _POSIX_ARG_MAX 4096 +#ifdef _XPG6 +#define _POSIX_CHILD_MAX 25 +#else +#define _POSIX_CHILD_MAX 6 /* POSIX.1-1990 default */ +#endif +#define _POSIX_CLOCKRES_MIN 20000000 +#define _POSIX_DELAYTIMER_MAX 32 +#define _POSIX_LINK_MAX 8 +#define _POSIX_MAX_CANON 255 +#define _POSIX_MAX_INPUT 255 +#define _POSIX_MQ_OPEN_MAX 8 +#define _POSIX_MQ_PRIO_MAX 32 +#define _POSIX_NAME_MAX 14 +#ifdef _XPG6 +#define _POSIX_NGROUPS_MAX 8 +#define _POSIX_OPEN_MAX 20 +#define _POSIX_PATH_MAX 256 +#else /* POSIX.1-1990 defaults */ +#define _POSIX_NGROUPS_MAX 0 +#define _POSIX_OPEN_MAX 16 +#define _POSIX_PATH_MAX 255 +#endif +#define _POSIX_PIPE_BUF 512 +#define _POSIX_RTSIG_MAX 8 +#define _POSIX_SEM_NSEMS_MAX 256 +#define _POSIX_SEM_VALUE_MAX 32767 +#define _POSIX_SIGQUEUE_MAX 32 +#define _POSIX_SSIZE_MAX 32767 +#define _POSIX_STREAM_MAX 8 +#define _POSIX_TIMER_MAX 32 +#ifdef _XPG6 +#define _POSIX_TZNAME_MAX 6 +#else +#define _POSIX_TZNAME_MAX 3 /* POSIX.1-1990 default */ +#endif +/* POSIX.1c conformant */ +#define _POSIX_LOGIN_NAME_MAX 9 +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 +#define _POSIX_THREAD_KEYS_MAX 128 +#define _POSIX_THREAD_THREADS_MAX 64 +#define _POSIX_TTY_NAME_MAX 9 +/* UNIX 03 conformant */ +#define _POSIX_HOST_NAME_MAX 255 +#define _POSIX_RE_DUP_MAX 255 +#define _POSIX_SYMLINK_MAX 255 +#define _POSIX_SYMLOOP_MAX 8 + +/* + * POSIX.2 and XPG4-XSH4 conformant definitions + */ + +#define _POSIX2_BC_BASE_MAX 99 +#define _POSIX2_BC_DIM_MAX 2048 +#define _POSIX2_BC_SCALE_MAX 99 +#define _POSIX2_BC_STRING_MAX 1000 +#define _POSIX2_COLL_WEIGHTS_MAX 2 +#define _POSIX2_EXPR_NEST_MAX 32 +#define _POSIX2_LINE_MAX 2048 +#define _POSIX2_RE_DUP_MAX 255 +/* UNIX 03 conformant */ +#define _POSIX2_CHARCLASS_NAME_MAX 14 + +#define BC_BASE_MAX _POSIX2_BC_BASE_MAX +#define BC_DIM_MAX _POSIX2_BC_DIM_MAX +#define BC_SCALE_MAX _POSIX2_BC_SCALE_MAX +#define BC_STRING_MAX _POSIX2_BC_STRING_MAX +#define COLL_WEIGHTS_MAX 10 +#define EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX +#define LINE_MAX _POSIX2_LINE_MAX +#if !defined(_XPG6) +#define RE_DUP_MAX _POSIX2_RE_DUP_MAX +#else +#define RE_DUP_MAX _POSIX_RE_DUP_MAX +#endif /* !defined(_XPG6) */ + +#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \ + defined(_XOPEN_SOURCE) + +/* + * For dual definitions for PASS_MAX and sysconf.c + */ +#define _PASS_MAX_XPG 8 /* old standards PASS_MAX */ +#define _PASS_MAX 256 /* modern Solaris PASS_MAX */ + +#if defined(_XPG3) && !defined(_XPG6) +#define PASS_MAX _PASS_MAX_XPG /* max # of characters in a password */ +#else /* XPG6 or just Solaris */ +#define PASS_MAX _PASS_MAX /* max # of characters in a password */ +#endif /* defined(_XPG3) && !defined(_XPG6) */ + +#define CHARCLASS_NAME_MAX _POSIX2_CHARCLASS_NAME_MAX + +#define NL_ARGMAX 9 /* max value of "digit" in calls to the */ + /* NLS printf() and scanf() */ +#define NL_LANGMAX 14 /* max # of bytes in a LANG name */ +#define NL_MSGMAX 32767 /* max message number */ +#define NL_NMAX 1 /* max # bytes in N-to-1 mapping characters */ +#define NL_SETMAX 255 /* max set number */ +#define NL_TEXTMAX 2048 /* max set number */ +#define NZERO 20 /* default process priority */ + +#define WORD_BIT 32 /* # of bits in a "word" or "int" */ +#if defined(_LP64) +#define LONG_BIT 64 /* # of bits in a "long" */ +#else /* _ILP32 */ +#define LONG_BIT 32 /* # of bits in a "long" */ +#endif + +/* Marked as LEGACY in SUSv2 and removed in UNIX 03 */ +#ifndef _XPG6 +#define DBL_DIG 15 /* digits of precision of a "double" */ +#define DBL_MAX 1.7976931348623157081452E+308 /* max decimal value */ + /* of a double */ +#define FLT_DIG 6 /* digits of precision of a "float" */ +#define FLT_MAX 3.4028234663852885981170E+38F /* max decimal value */ + /* of a "float" */ +#endif + +/* Marked as LEGACY in SUSv1 and removed in SUSv2 */ +#ifndef _XPG5 +#define DBL_MIN 2.2250738585072013830903E-308 /* min decimal value */ + /* of a double */ +#define FLT_MIN 1.1754943508222875079688E-38F /* min decimal value */ + /* of a float */ +#endif + +#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */ + +#define _XOPEN_IOV_MAX 16 /* max # iovec/process with readv()/writev() */ +#define _XOPEN_NAME_MAX 255 /* max # bytes in filename excluding null */ +#define _XOPEN_PATH_MAX 1024 /* max # bytes in a pathname */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + +#define FCHR_MAX 1048576 /* max size of a file in bytes */ +#define PID_MAX 999999 /* max value for a process ID */ + +/* + * POSIX 1003.1a, section 2.9.5, table 2-5 contains [NAME_MAX] and the + * related text states: + * + * A definition of one of the values from Table 2-5 shall be omitted from the + * on specific implementations where the corresponding value is + * equal to or greater than the stated minimum, but where the value can vary + * depending on the file to which it is applied. The actual value supported for + * a specific pathname shall be provided by the pathconf() (5.7.1) function. + * + * This is clear that any machine supporting multiple file system types + * and/or a network should not include this define, regardless of protection + * by the _POSIX_SOURCE and _POSIX_C_SOURCE flags. We chose to ignore that + * and provide it anyway for compatibility with other platforms that don't + * follow the spec as precisely as they should. Its usage is discouraged. + */ +#define NAME_MAX 255 + +#define CHILD_MAX 25 /* max # of processes per user id */ +#ifndef OPEN_MAX +#define OPEN_MAX 256 /* max # of files a process can have open */ +#endif + +#define PIPE_MAX 5120 /* max # bytes written to a pipe in a write */ + +#define STD_BLK 1024 /* # bytes in a physical I/O block */ +#define UID_MAX 2147483647 /* max value for a user or group ID */ +#define USI_MAX 4294967295 /* max decimal value of an "unsigned" */ +#define SYSPID_MAX 1 /* max pid of system processes */ + +#ifndef SYS_NMLN /* also defined in sys/utsname.h */ +#define SYS_NMLN 257 /* 4.0 size of utsname elements */ +#endif + +#ifndef CLK_TCK + +#if !defined(_CLOCK_T) || __cplusplus >= 199711L +#define _CLOCK_T +typedef long clock_t; +#endif /* !_CLOCK_T */ + +extern long _sysconf(int); /* System Private interface to sysconf() */ +#define CLK_TCK ((clock_t)_sysconf(3)) /* 3 is _SC_CLK_TCK */ + +#endif /* CLK_TCK */ + +#ifdef __USE_LEGACY_LOGNAME__ +#define LOGNAME_MAX 8 /* max # of characters in a login name */ +#else /* __USE_LEGACY_LOGNAME__ */ +#define LOGNAME_MAX 32 /* max # of characters in a login name */ + /* Increased for illumos */ +#endif /* __USE_LEGACY_LOGNAME__ */ +#define LOGIN_NAME_MAX (LOGNAME_MAX + 1) /* max buffer size */ +#define LOGNAME_MAX_TRAD 8 /* traditional length */ +#define LOGIN_NAME_MAX_TRAD (LOGNAME_MAX_TRAD + 1) /* and size */ + +#define TTYNAME_MAX 128 /* max # of characters in a tty name */ + +#endif /* if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */ + +#if defined(__EXTENSIONS__) || (_POSIX_C_SOURCE >= 199506L) +#include + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* _SIZE_T */ + +extern long _sysconf(int); /* System Private interface to sysconf() */ + +#define PTHREAD_STACK_MIN ((size_t)_sysconf(_SC_THREAD_STACK_MIN)) +/* Added for UNIX98 conformance */ +#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS +#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX +#define PTHREAD_THREADS_MAX _POSIX_THREAD_THREADS_MAX +#endif /* defined(__EXTENSIONS__) || (_POSIX_C_SOURCE >= 199506L) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIMITS_H */ diff --git a/illumos-x86_64/usr/include/linenum.h b/illumos-x86_64/usr/include/linenum.h new file mode 100644 index 00000000..dd117723 --- /dev/null +++ b/illumos-x86_64/usr/include/linenum.h @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _LINENUM_H +#define _LINENUM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * There is one line number entry for every + * "breakpointable" source line in a section. + * Line numbers are grouped on a per function + * basis; the first entry in a function grouping + * will have l_lnno = 0 and in place of physical + * address will be the symbol table index of + * the function name. + */ +struct lineno +{ + union + { + long l_symndx; /* sym. table index of function name */ + /* iff l_lnno == 0 */ + long l_paddr; /* (physical) address of line number */ + } l_addr; + unsigned short l_lnno; /* line number */ +}; + +#define LINENO struct lineno +#define LINESZ 6 /* sizeof(LINENO) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LINENUM_H */ diff --git a/illumos-x86_64/usr/include/link.h b/illumos-x86_64/usr/include/link.h new file mode 100644 index 00000000..bff28922 --- /dev/null +++ b/illumos-x86_64/usr/include/link.h @@ -0,0 +1,298 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LINK_H +#define _LINK_H + +#include + +#ifndef _ASM +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM +/* + * ld support library calls. + * + * These cannot be used in a 32bit large file capable environment because + * libelf is not large-file safe. Only define these interfaces if we are not + * 32bit, or not in the large file environment. + */ +#if !defined(_ILP32) || _FILE_OFFSET_BITS != 64 +#include +extern uint_t ld_version(uint_t); +extern void ld_input_done(uint_t *); + +extern void ld_start(const char *, const Elf32_Half, const char *); +extern void ld_atexit(int); +extern void ld_open(const char **, const char **, int *, int, Elf **, + Elf *, size_t, const Elf_Kind); +extern void ld_file(const char *, const Elf_Kind, int, Elf *); +extern void ld_input_section(const char *, Elf32_Shdr **, Elf32_Word, + Elf_Data *, Elf *, uint_t *); +extern void ld_section(const char *, Elf32_Shdr *, Elf32_Word, + Elf_Data *, Elf *); + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +extern void ld_start64(const char *, const Elf64_Half, const char *); +extern void ld_atexit64(int); +extern void ld_open64(const char **, const char **, int *, int, Elf **, + Elf *, size_t, const Elf_Kind); +extern void ld_file64(const char *, const Elf_Kind, int, Elf *); +extern void ld_input_section64(const char *, Elf64_Shdr **, Elf64_Word, + Elf_Data *, Elf *, uint_t *); +extern void ld_section64(const char *, Elf64_Shdr *, Elf64_Word, + Elf_Data *, Elf *); + +#endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */ +#endif /* !defined(_ILP32) || _FILE_OFFSET_BITS != 64 */ + +/* + * ld_version() version values. + */ +#define LD_SUP_VNONE 0 +#define LD_SUP_VERSION1 1 +#define LD_SUP_VERSION2 2 +#define LD_SUP_VERSION3 3 +#define LD_SUP_VCURRENT LD_SUP_VERSION3 + +/* + * Flags passed to ld support calls. + */ +#define LD_SUP_DERIVED 0x1 /* derived filename */ +#define LD_SUP_INHERITED 0x2 /* file inherited from .so DT_NEEDED */ +#define LD_SUP_EXTRACTED 0x4 /* file extracted from archive */ +#endif + +/* + * Runtime link-map identifiers. + */ +#define LM_ID_BASE 0x00 +#define LM_ID_LDSO 0x01 +#define LM_ID_NUM 2 + +#define LM_ID_BRAND 0xfd /* brand emulation linkmap objs */ +#define LM_ID_NONE 0xfe /* no link map specified */ +#define LM_ID_NEWLM 0xff /* create a new link-map */ + +/* + * Runtime Link-Edit Auditing. + */ +#define LAV_NONE 0 +#define LAV_VERSION1 1 +#define LAV_VERSION2 2 +#define LAV_VERSION3 3 +#define LAV_VERSION4 4 +#define LAV_VERSION5 5 +#define LAV_CURRENT LAV_VERSION5 +#define LAV_NUM 6 + +/* + * Flags that can be or'd into the la_objopen() return code + */ +#define LA_FLG_BINDTO 0x0001 /* audit symbinds TO this object */ +#define LA_FLG_BINDFROM 0x0002 /* audit symbinding FROM this object */ + +/* + * Flags that can be or'd into the 'flags' argument of la_symbind() + */ +#define LA_SYMB_NOPLTENTER 0x0001 /* disable pltenter for this symbol */ +#define LA_SYMB_NOPLTEXIT 0x0002 /* disable pltexit for this symbol */ +#define LA_SYMB_STRUCTCALL 0x0004 /* this function call passes a */ + /* structure as it's return code */ +#define LA_SYMB_DLSYM 0x0008 /* this symbol bindings is due to */ + /* a call to dlsym() */ +#define LA_SYMB_ALTVALUE 0x0010 /* alternate symbol binding returned */ + /* by la_symbind() */ + +/* + * Flags that describe the object passed to la_objsearch() + */ +#define LA_SER_ORIG 0x001 /* original (needed) name */ +#define LA_SER_LIBPATH 0x002 /* LD_LIBRARY_PATH entry prepended */ +#define LA_SER_RUNPATH 0x004 /* runpath entry prepended */ +#define LA_SER_CONFIG 0x008 /* configuration entry prepended */ +#define LA_SER_DEFAULT 0x040 /* default path prepended */ +#define LA_SER_SECURE 0x080 /* default (secure) path prepended */ + +#define LA_SER_MASK 0xfff /* mask of known flags */ + +/* + * Flags that describe the la_activity() + */ +#define LA_ACT_CONSISTENT 0x00 /* add/deletion of objects complete */ +#define LA_ACT_ADD 0x01 /* objects being added */ +#define LA_ACT_DELETE 0x02 /* objects being deleted */ +#define LA_ACT_MAX 3 + + +#ifndef _KERNEL +#ifndef _ASM + +#if defined(_LP64) +typedef long lagreg_t; +#else +typedef int lagreg_t; +#endif + +struct _la_sparc_regs { + lagreg_t lr_rego0; + lagreg_t lr_rego1; + lagreg_t lr_rego2; + lagreg_t lr_rego3; + lagreg_t lr_rego4; + lagreg_t lr_rego5; + lagreg_t lr_rego6; + lagreg_t lr_rego7; +}; + +#if defined(_LP64) +typedef struct _la_sparc_regs La_sparcv9_regs; +typedef struct { + lagreg_t lr_rsp; + lagreg_t lr_rbp; + lagreg_t lr_rdi; /* arg1 */ + lagreg_t lr_rsi; /* arg2 */ + lagreg_t lr_rdx; /* arg3 */ + lagreg_t lr_rcx; /* arg4 */ + lagreg_t lr_r8; /* arg5 */ + lagreg_t lr_r9; /* arg6 */ +} La_amd64_regs; +#else +typedef struct _la_sparc_regs La_sparcv8_regs; +typedef struct { + lagreg_t lr_esp; + lagreg_t lr_ebp; +} La_i86_regs; +#endif + +#if !defined(_SYS_INT_TYPES_H) +#if defined(_LP64) +typedef unsigned long uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#endif + + +extern uint_t la_version(uint_t); +extern void la_activity(uintptr_t *, uint_t); +extern void la_preinit(uintptr_t *); +extern char *la_objsearch(const char *, uintptr_t *, uint_t); +extern uint_t la_objopen(Link_map *, Lmid_t, uintptr_t *); +extern uint_t la_objclose(uintptr_t *); +extern int la_objfilter(uintptr_t *, const char *, uintptr_t *, + uint_t); +#if defined(_LP64) +extern uintptr_t la_amd64_pltenter(Elf64_Sym *, uint_t, uintptr_t *, + uintptr_t *, La_amd64_regs *, uint_t *, + const char *); +extern uintptr_t la_symbind64(Elf64_Sym *, uint_t, uintptr_t *, + uintptr_t *, uint_t *, const char *); +extern uintptr_t la_sparcv9_pltenter(Elf64_Sym *, uint_t, uintptr_t *, + uintptr_t *, La_sparcv9_regs *, uint_t *, + const char *); +extern uintptr_t la_pltexit64(Elf64_Sym *, uint_t, uintptr_t *, + uintptr_t *, uintptr_t, const char *); +#else /* !defined(_LP64) */ +extern uintptr_t la_symbind32(Elf32_Sym *, uint_t, uintptr_t *, + uintptr_t *, uint_t *); +extern uintptr_t la_sparcv8_pltenter(Elf32_Sym *, uint_t, uintptr_t *, + uintptr_t *, La_sparcv8_regs *, uint_t *); +extern uintptr_t la_i86_pltenter(Elf32_Sym *, uint_t, uintptr_t *, + uintptr_t *, La_i86_regs *, uint_t *); +extern uintptr_t la_pltexit(Elf32_Sym *, uint_t, uintptr_t *, + uintptr_t *, uintptr_t); +#endif /* _LP64 */ + +/* + * The ElfW() macro is a GNU/Linux feature, provided as support for + * the dl_phdr_info structure used by dl_phdr_iterate(), which also + * originated under Linux. Given an ELF data type, without the ElfXX_ + * prefix, it supplies the appropriate prefix (Elf32_ or Elf64_) for + * the ELFCLASS of the code being compiled. + * + * Note that ElfW() is not suitable in situations in which the ELFCLASS + * of the code being compiled does not match that of the objects that + * code is intended to operate on (e.g. a 32-bit link-editor building + * a 64-bit object). The macros defined in are + * recommended in such cases. + */ +#ifdef _LP64 +#define ElfW(type) Elf64_ ## type +#else +#define ElfW(type) Elf32_ ## type +#endif + +/* + * The callback function to dl_interate_phdr() receives a pointer + * to a structure of this type. + * + * dlpi_addr is defined such that the address of any segment in + * the program header array can be calculated as: + * + * addr == info->dlpi_addr + info->dlpi_phdr[x].p_vaddr; + * + * It is therefore 0 for ET_EXEC objects, and the base address at + * which the object is mapped otherwise. + */ +struct dl_phdr_info { + ElfW(Addr) dlpi_addr; /* Base address of object */ + const char *dlpi_name; /* Null-terminated obj name */ + const ElfW(Phdr) *dlpi_phdr; /* Ptr to ELF program hdr arr */ + ElfW(Half) dlpi_phnum; /* # of items in dlpi_phdr[] */ + + /* + * Note: Following members were introduced after the first version + * of this structure was available. The dl_iterate_phdr() callback + * function is passed a 'size' argument giving the size of the info + * structure, and must compare that size to the offset of these fields + * before accessing them to ensure that they are present. + */ + + /* Incremented when a new object is mapped into the process */ + u_longlong_t dlpi_adds; + /* Incremented when an object is unmapped from the process */ + u_longlong_t dlpi_subs; +}; + +extern int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), + void *); + +#endif /* _ASM */ +#endif /* _KERNEL */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _LINK_H */ diff --git a/illumos-x86_64/usr/include/listen.h b/illumos-x86_64/usr/include/listen.h new file mode 100644 index 00000000..59231ec0 --- /dev/null +++ b/illumos-x86_64/usr/include/listen.h @@ -0,0 +1,136 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _LISTEN_H +#define _LISTEN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * listen.h: Include file for network listener related user programs + * + */ + +/* + * The NLPS (Network Listener Process Service) + * protocol message sent by client machines to + * a listener process to request a service on the listener's + * machine. The message is sent to "netnodename(r_nodename)" + * where r_nodename is the nodename (see uname(2)) of the + * remote host. Note that client's need not know (or care) + * about the details of this message. They use the "nls_connect(3)" + * library routine which uses this message. + * + * msg format: + * + * "id:low:high:service_code" + * + * id = "NLPS" + * low:high = version number of listener (see prot msg) + * service_code is ASCII/decimal + * + * the following prot string can be run through sprintf with a service code + * to generate the message: + * + * len = sprintf(buf,nls_prot_msg,svc_code); + * t_snd(fd, buf, len, ...); + * + * See also: listen(1), nlsrequest(3) + * + * and on the UNIX PC STARLAN NETWORK: + * See also: nlsname(3), nlsconnect(3), nlsestablish(3) + */ + +/* + * defines for compatability purposes + */ + +#define nls_prot_msg nls_v0_d +#define nls_v2_msg nls_v2_s + +static char *nls_v0_d = "NLPS:000:001:%d"; +static char *nls_v0_s = "NLPS:000:001:%s"; +static char *nls_v2_d = "NLPS:002:002:%d"; +static char *nls_v2_s = "NLPS:002:002:%s"; + +#define NLSSTART 0 +#define NLSFORMAT 2 +#define NLSUNKNOWN 3 +#define NLSDISABLED 4 + +#define SVC_CODE_SZ 14 + +/* + * Structure for handling multiple connection requests on the same stream. + */ + +struct callsave { + struct t_call *c_cp; + struct callsave *c_np; +}; + +struct call_list { + struct callsave *cl_head; + struct callsave *cl_tail; +}; + + +#define EMPTYLIST(p) (p->cl_head == (struct callsave *)NULL) + +/* + * Ridiculously high value for maximum number of connects per stream. + * Transport Provider will determine actual maximum to be used. + */ + +#define MAXCON 100 + +/* + * these are names of environment variables that the listener + * adds to the servers environment before the exec(2). + * + * the variables should be accessed via library routines. + * + * see nlsgetcall(3NSL) and nlsprovider(3NSL). + */ + +#define NLSADDR "NLSADDR" +#define NLSOPT "NLSOPT" +#define NLSUDATA "NLSUDATA" +#define NLSPROVIDER "NLSPROVIDER" + +/* + * the following variables can be accessed "normally" + */ + +#define HOME "HOME" +#define PATH "PATH" + +#ifdef __cplusplus +} +#endif + +#endif /* _LISTEN_H */ diff --git a/illumos-x86_64/usr/include/locale.h b/illumos-x86_64/usr/include/locale.h new file mode 100644 index 00000000..2be53693 --- /dev/null +++ b/illumos-x86_64/usr/include/locale.h @@ -0,0 +1,105 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Portions of this file developed by Garrett D'Amore are licensed + * under the terms of the Common Development and Distribution License (CDDL) + * version 1.0 only. The use of subsequent versions of the License are + * is specifically prohibited unless those terms are not in conflict with + * version 1.0 of the License. You can find this license on-line at + * http://www.illumos.org/license/CDDL + */ + +#ifndef _LOCALE_H +#define _LOCALE_H + +#include + +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(__EXTENSIONS__) +#include +#endif + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::lconv; +using std::setlocale; +using std::localeconv; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define _LastCategory LC_MESSAGES /* This must be last category */ + +#define _ValidCategory(c) \ + (((int)(c) >= LC_CTYPE) && ((int)(c) <= _LastCategory) || \ + ((int)c == LC_ALL)) + + +#if defined(_XPG7) || !defined(_STRICT_SYMBOLS) + +/* + * These were added in POSIX 2008 as part of the newlocale() specification. + */ +#define LC_CTYPE_MASK (1 << LC_CTYPE) +#define LC_NUMERIC_MASK (1 << LC_NUMERIC) +#define LC_TIME_MASK (1 << LC_TIME) +#define LC_COLLATE_MASK (1 << LC_COLLATE) +#define LC_MONETARY_MASK (1 << LC_MONETARY) +#define LC_MESSAGES_MASK (1 << LC_MESSAGES) +#define LC_ALL_MASK (0x3f) + +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +extern locale_t duplocale(locale_t); +extern void freelocale(locale_t); +extern locale_t newlocale(int, const char *, locale_t); +extern locale_t uselocale(locale_t); + +#define LC_GLOBAL_LOCALE (__global_locale()) +extern locale_t __global_locale(void); + +#endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */ + +#if defined(_XPG8) || !defined(_STRICT_SYMBOLS) +extern const char *getlocalename_l(int, locale_t); +#endif /* _XPG8 || !_STRICT_SYMBOLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LOCALE_H */ diff --git a/illumos-x86_64/usr/include/lz4.h b/illumos-x86_64/usr/include/lz4.h new file mode 100644 index 00000000..80e3e5ca --- /dev/null +++ b/illumos-x86_64/usr/include/lz4.h @@ -0,0 +1,884 @@ +/* + * LZ4 - Fast LZ compression algorithm + * Header File + * Copyright (C) 2011-2023, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - LZ4 homepage : http://www.lz4.org + - LZ4 source repository : https://github.com/lz4/lz4 +*/ +#if defined (__cplusplus) +extern "C" { +#endif + +#ifndef LZ4_H_2983827168210 +#define LZ4_H_2983827168210 + +/* --- Dependency --- */ +#include /* size_t */ + + +/** + Introduction + + LZ4 is lossless compression algorithm, providing compression speed >500 MB/s per core, + scalable with multi-cores CPU. It features an extremely fast decoder, with speed in + multiple GB/s per core, typically reaching RAM speed limits on multi-core systems. + + The LZ4 compression library provides in-memory compression and decompression functions. + It gives full buffer control to user. + Compression can be done in: + - a single step (described as Simple Functions) + - a single step, reusing a context (described in Advanced Functions) + - unbounded multiple steps (described as Streaming compression) + + lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md). + Decompressing such a compressed block requires additional metadata. + Exact metadata depends on exact decompression function. + For the typical case of LZ4_decompress_safe(), + metadata includes block's compressed size, and maximum bound of decompressed size. + Each application is free to encode and pass such metadata in whichever way it wants. + + lz4.h only handle blocks, it can not generate Frames. + + Blocks are different from Frames (doc/lz4_Frame_format.md). + Frames bundle both blocks and metadata in a specified manner. + Embedding metadata is required for compressed data to be self-contained and portable. + Frame format is delivered through a companion API, declared in lz4frame.h. + The `lz4` CLI can only manage frames. +*/ + +/*^*************************************************************** +* Export parameters +*****************************************************************/ +/* +* LZ4_DLL_EXPORT : +* Enable exporting of functions when building a Windows DLL +* LZ4LIB_VISIBILITY : +* Control library symbols visibility. +*/ +#ifndef LZ4LIB_VISIBILITY +# if defined(__GNUC__) && (__GNUC__ >= 4) +# define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default"))) +# else +# define LZ4LIB_VISIBILITY +# endif +#endif +#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) +# define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY +#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1) +# define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ +#else +# define LZ4LIB_API LZ4LIB_VISIBILITY +#endif + +/*! LZ4_FREESTANDING : + * When this macro is set to 1, it enables "freestanding mode" that is + * suitable for typical freestanding environment which doesn't support + * standard C library. + * + * - LZ4_FREESTANDING is a compile-time switch. + * - It requires the following macros to be defined: + * LZ4_memcpy, LZ4_memmove, LZ4_memset. + * - It only enables LZ4/HC functions which don't use heap. + * All LZ4F_* functions are not supported. + * - See tests/freestanding.c to check its basic setup. + */ +#if defined(LZ4_FREESTANDING) && (LZ4_FREESTANDING == 1) +# define LZ4_HEAPMODE 0 +# define LZ4HC_HEAPMODE 0 +# define LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION 1 +# if !defined(LZ4_memcpy) +# error "LZ4_FREESTANDING requires macro 'LZ4_memcpy'." +# endif +# if !defined(LZ4_memset) +# error "LZ4_FREESTANDING requires macro 'LZ4_memset'." +# endif +# if !defined(LZ4_memmove) +# error "LZ4_FREESTANDING requires macro 'LZ4_memmove'." +# endif +#elif ! defined(LZ4_FREESTANDING) +# define LZ4_FREESTANDING 0 +#endif + + +/*------ Version ------*/ +#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ +#define LZ4_VERSION_MINOR 10 /* for new (non-breaking) interface capabilities */ +#define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */ + +#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) + +#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE +#define LZ4_QUOTE(str) #str +#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str) +#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) /* requires v1.7.3+ */ + +LZ4LIB_API int LZ4_versionNumber (void); /**< library version number; useful to check dll version; requires v1.3.0+ */ +LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; useful to check dll version; requires v1.7.5+ */ + + +/*-************************************ +* Tuning memory usage +**************************************/ +/*! + * LZ4_MEMORY_USAGE : + * Can be selected at compile time, by setting LZ4_MEMORY_USAGE. + * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB) + * Increasing memory usage improves compression ratio, generally at the cost of speed. + * Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality. + * Default value is 14, for 16KB, which nicely fits into most L1 caches. + */ +#ifndef LZ4_MEMORY_USAGE +# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT +#endif + +/* These are absolute limits, they should not be changed by users */ +#define LZ4_MEMORY_USAGE_MIN 10 +#define LZ4_MEMORY_USAGE_DEFAULT 14 +#define LZ4_MEMORY_USAGE_MAX 20 + +#if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN) +# error "LZ4_MEMORY_USAGE is too small !" +#endif + +#if (LZ4_MEMORY_USAGE > LZ4_MEMORY_USAGE_MAX) +# error "LZ4_MEMORY_USAGE is too large !" +#endif + +/*-************************************ +* Simple Functions +**************************************/ +/*! LZ4_compress_default() : + * Compresses 'srcSize' bytes from buffer 'src' + * into already allocated 'dst' buffer of size 'dstCapacity'. + * Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize). + * It also runs faster, so it's a recommended setting. + * If the function cannot compress 'src' into a more limited 'dst' budget, + * compression stops *immediately*, and the function result is zero. + * In which case, 'dst' content is undefined (invalid). + * srcSize : max supported value is LZ4_MAX_INPUT_SIZE. + * dstCapacity : size of buffer 'dst' (which must be already allocated) + * @return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity) + * or 0 if compression fails + * Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer). + */ +LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity); + +/*! LZ4_decompress_safe() : + * @compressedSize : is the exact complete size of the compressed block. + * @dstCapacity : is the size of destination buffer (which must be already allocated), + * presumed an upper bound of decompressed size. + * @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity) + * If destination buffer is not large enough, decoding will stop and output an error code (negative value). + * If the source stream is detected malformed, the function will stop decoding and return a negative result. + * Note 1 : This function is protected against malicious data packets : + * it will never writes outside 'dst' buffer, nor read outside 'source' buffer, + * even if the compressed block is maliciously modified to order the decoder to do these actions. + * In such case, the decoder stops immediately, and considers the compressed block malformed. + * Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them. + * The implementation is free to send / store / derive this information in whichever way is most beneficial. + * If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead. + */ +LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity); + + +/*-************************************ +* Advanced Functions +**************************************/ +#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */ +#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) + +/*! LZ4_compressBound() : + Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible) + This function is primarily useful for memory allocation purposes (destination buffer size). + Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example). + Note that LZ4_compress_default() compresses faster when dstCapacity is >= LZ4_compressBound(srcSize) + inputSize : max supported value is LZ4_MAX_INPUT_SIZE + return : maximum output size in a "worst case" scenario + or 0, if input size is incorrect (too large or negative) +*/ +LZ4LIB_API int LZ4_compressBound(int inputSize); + +/*! LZ4_compress_fast() : + Same as LZ4_compress_default(), but allows selection of "acceleration" factor. + The larger the acceleration value, the faster the algorithm, but also the lesser the compression. + It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed. + An acceleration value of "1" is the same as regular LZ4_compress_default() + Values <= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c). + Values > LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c). +*/ +LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); + + +/*! LZ4_compress_fast_extState() : + * Same as LZ4_compress_fast(), using an externally allocated memory space for its state. + * Use LZ4_sizeofState() to know how much memory must be allocated, + * and allocate it on 8-bytes boundaries (using `malloc()` typically). + * Then, provide this buffer as `void* state` to compression function. + */ +LZ4LIB_API int LZ4_sizeofState(void); +LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); + +/*! LZ4_compress_destSize() : + * Reverse the logic : compresses as much data as possible from 'src' buffer + * into already allocated buffer 'dst', of size >= 'dstCapacity'. + * This function either compresses the entire 'src' content into 'dst' if it's large enough, + * or fill 'dst' buffer completely with as much data as possible from 'src'. + * note: acceleration parameter is fixed to "default". + * + * *srcSizePtr : in+out parameter. Initially contains size of input. + * Will be modified to indicate how many bytes where read from 'src' to fill 'dst'. + * New value is necessarily <= input value. + * @return : Nb bytes written into 'dst' (necessarily <= dstCapacity) + * or 0 if compression fails. + * + * Note : from v1.8.2 to v1.9.1, this function had a bug (fixed in v1.9.2+): + * the produced compressed content could, in specific circumstances, + * require to be decompressed into a destination buffer larger + * by at least 1 byte than the content to decompress. + * If an application uses `LZ4_compress_destSize()`, + * it's highly recommended to update liblz4 to v1.9.2 or better. + * If this can't be done or ensured, + * the receiving decompression function should provide + * a dstCapacity which is > decompressedSize, by at least 1 byte. + * See https://github.com/lz4/lz4/issues/859 for details + */ +LZ4LIB_API int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targetDstSize); + +/*! LZ4_decompress_safe_partial() : + * Decompress an LZ4 compressed block, of size 'srcSize' at position 'src', + * into destination buffer 'dst' of size 'dstCapacity'. + * Up to 'targetOutputSize' bytes will be decoded. + * The function stops decoding on reaching this objective. + * This can be useful to boost performance + * whenever only the beginning of a block is required. + * + * @return : the number of bytes decoded in `dst` (necessarily <= targetOutputSize) + * If source stream is detected malformed, function returns a negative result. + * + * Note 1 : @return can be < targetOutputSize, if compressed block contains less data. + * + * Note 2 : targetOutputSize must be <= dstCapacity + * + * Note 3 : this function effectively stops decoding on reaching targetOutputSize, + * so dstCapacity is kind of redundant. + * This is because in older versions of this function, + * decoding operation would still write complete sequences. + * Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize, + * it could write more bytes, though only up to dstCapacity. + * Some "margin" used to be required for this operation to work properly. + * Thankfully, this is no longer necessary. + * The function nonetheless keeps the same signature, in an effort to preserve API compatibility. + * + * Note 4 : If srcSize is the exact size of the block, + * then targetOutputSize can be any value, + * including larger than the block's decompressed size. + * The function will, at most, generate block's decompressed size. + * + * Note 5 : If srcSize is _larger_ than block's compressed size, + * then targetOutputSize **MUST** be <= block's decompressed size. + * Otherwise, *silent corruption will occur*. + */ +LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity); + + +/*-********************************************* +* Streaming Compression Functions +***********************************************/ +typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */ + +/*! + Note about RC_INVOKED + + - RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is part of MSVC/Visual Studio). + https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros + + - Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars) + and reports warning "RC4011: identifier truncated". + + - To eliminate the warning, we surround long preprocessor symbol with + "#if !defined(RC_INVOKED) ... #endif" block that means + "skip this block when rc.exe is trying to read it". +*/ +#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */ +#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) +LZ4LIB_API LZ4_stream_t* LZ4_createStream(void); +LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr); +#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */ +#endif + +/*! LZ4_resetStream_fast() : v1.9.0+ + * Use this to prepare an LZ4_stream_t for a new chain of dependent blocks + * (e.g., LZ4_compress_fast_continue()). + * + * An LZ4_stream_t must be initialized once before usage. + * This is automatically done when created by LZ4_createStream(). + * However, should the LZ4_stream_t be simply declared on stack (for example), + * it's necessary to initialize it first, using LZ4_initStream(). + * + * After init, start any new stream with LZ4_resetStream_fast(). + * A same LZ4_stream_t can be re-used multiple times consecutively + * and compress multiple streams, + * provided that it starts each new stream with LZ4_resetStream_fast(). + * + * LZ4_resetStream_fast() is much faster than LZ4_initStream(), + * but is not compatible with memory regions containing garbage data. + * + * Note: it's only useful to call LZ4_resetStream_fast() + * in the context of streaming compression. + * The *extState* functions perform their own resets. + * Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive. + */ +LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr); + +/*! LZ4_loadDict() : + * Use this function to reference a static dictionary into LZ4_stream_t. + * The dictionary must remain available during compression. + * LZ4_loadDict() triggers a reset, so any previous data will be forgotten. + * The same dictionary will have to be loaded on decompression side for successful decoding. + * Dictionary are useful for better compression of small data (KB range). + * While LZ4 itself accepts any input as dictionary, dictionary efficiency is also a topic. + * When in doubt, employ the Zstandard's Dictionary Builder. + * Loading a size of 0 is allowed, and is the same as reset. + * @return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded) + */ +LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); + +/*! LZ4_loadDictSlow() : v1.10.0+ + * Same as LZ4_loadDict(), + * but uses a bit more cpu to reference the dictionary content more thoroughly. + * This is expected to slightly improve compression ratio. + * The extra-cpu cost is likely worth it if the dictionary is re-used across multiple sessions. + * @return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded) + */ +LZ4LIB_API int LZ4_loadDictSlow(LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); + +/*! LZ4_attach_dictionary() : stable since v1.10.0 + * + * This allows efficient re-use of a static dictionary multiple times. + * + * Rather than re-loading the dictionary buffer into a working context before + * each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a + * working LZ4_stream_t, this function introduces a no-copy setup mechanism, + * in which the working stream references @dictionaryStream in-place. + * + * Several assumptions are made about the state of @dictionaryStream. + * Currently, only states which have been prepared by LZ4_loadDict() or + * LZ4_loadDictSlow() should be expected to work. + * + * Alternatively, the provided @dictionaryStream may be NULL, + * in which case any existing dictionary stream is unset. + * + * If a dictionary is provided, it replaces any pre-existing stream history. + * The dictionary contents are the only history that can be referenced and + * logically immediately precede the data compressed in the first subsequent + * compression call. + * + * The dictionary will only remain attached to the working stream through the + * first compression call, at the end of which it is cleared. + * @dictionaryStream stream (and source buffer) must remain in-place / accessible / unchanged + * through the completion of the compression session. + * + * Note: there is no equivalent LZ4_attach_*() method on the decompression side + * because there is no initialization cost, hence no need to share the cost across multiple sessions. + * To decompress LZ4 blocks using dictionary, attached or not, + * just employ the regular LZ4_setStreamDecode() for streaming, + * or the stateless LZ4_decompress_safe_usingDict() for one-shot decompression. + */ +LZ4LIB_API void +LZ4_attach_dictionary(LZ4_stream_t* workingStream, + const LZ4_stream_t* dictionaryStream); + +/*! LZ4_compress_fast_continue() : + * Compress 'src' content using data from previously compressed blocks, for better compression ratio. + * 'dst' buffer must be already allocated. + * If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. + * + * @return : size of compressed block + * or 0 if there is an error (typically, cannot fit into 'dst'). + * + * Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block. + * Each block has precise boundaries. + * Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata. + * It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together. + * + * Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory ! + * + * Note 3 : When input is structured as a double-buffer, each buffer can have any size, including < 64 KB. + * Make sure that buffers are separated, by at least one byte. + * This construction ensures that each block only depends on previous block. + * + * Note 4 : If input buffer is a ring-buffer, it can have any size, including < 64 KB. + * + * Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed. + */ +LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); + +/*! LZ4_saveDict() : + * If last 64KB data cannot be guaranteed to remain available at its current memory location, + * save it into a safer place (char* safeBuffer). + * This is schematically equivalent to a memcpy() followed by LZ4_loadDict(), + * but is much faster, because LZ4_saveDict() doesn't need to rebuild tables. + * @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error. + */ +LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize); + + +/*-********************************************** +* Streaming Decompression Functions +* Bufferless synchronous API +************************************************/ +typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */ + +/*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() : + * creation / destruction of streaming decompression tracking context. + * A tracking context can be re-used multiple times. + */ +#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */ +#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) +LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void); +LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream); +#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */ +#endif + +/*! LZ4_setStreamDecode() : + * An LZ4_streamDecode_t context can be allocated once and re-used multiple times. + * Use this function to start decompression of a new stream of blocks. + * A dictionary can optionally be set. Use NULL or size 0 for a reset order. + * Dictionary is presumed stable : it must remain accessible and unmodified during next decompression. + * @return : 1 if OK, 0 if error + */ +LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize); + +/*! LZ4_decoderRingBufferSize() : v1.8.2+ + * Note : in a ring buffer scenario (optional), + * blocks are presumed decompressed next to each other + * up to the moment there is not enough remaining space for next block (remainingSize < maxBlockSize), + * at which stage it resumes from beginning of ring buffer. + * When setting such a ring buffer for streaming decompression, + * provides the minimum size of this ring buffer + * to be compatible with any source respecting maxBlockSize condition. + * @return : minimum ring buffer size, + * or 0 if there is an error (invalid maxBlockSize). + */ +LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize); +#define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */ + +/*! LZ4_decompress_safe_continue() : + * This decoding function allows decompression of consecutive blocks in "streaming" mode. + * The difference with the usual independent blocks is that + * new blocks are allowed to find references into former blocks. + * A block is an unsplittable entity, and must be presented entirely to the decompression function. + * LZ4_decompress_safe_continue() only accepts one block at a time. + * It's modeled after `LZ4_decompress_safe()` and behaves similarly. + * + * @LZ4_streamDecode : decompression state, tracking the position in memory of past data + * @compressedSize : exact complete size of one compressed block. + * @dstCapacity : size of destination buffer (which must be already allocated), + * must be an upper bound of decompressed size. + * @return : number of bytes decompressed into destination buffer (necessarily <= dstCapacity) + * If destination buffer is not large enough, decoding will stop and output an error code (negative value). + * If the source stream is detected malformed, the function will stop decoding and return a negative result. + * + * The last 64KB of previously decoded data *must* remain available and unmodified + * at the memory position where they were previously decoded. + * If less than 64KB of data has been decoded, all the data must be present. + * + * Special : if decompression side sets a ring buffer, it must respect one of the following conditions : + * - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize). + * maxBlockSize is the maximum size of any single block. It can have any value > 16 bytes. + * In which case, encoding and decoding buffers do not need to be synchronized. + * Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize. + * - Synchronized mode : + * Decompression buffer size is _exactly_ the same as compression buffer size, + * and follows exactly same update rule (block boundaries at same positions), + * and decoding function is provided with exact decompressed size of each block (exception for last block of the stream), + * _then_ decoding & encoding ring buffer can have any size, including small ones ( < 64 KB). + * - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes. + * In which case, encoding and decoding buffers do not need to be synchronized, + * and encoding ring buffer can have any size, including small ones ( < 64 KB). + * + * Whenever these conditions are not possible, + * save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression, + * then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block. +*/ +LZ4LIB_API int +LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, + const char* src, char* dst, + int srcSize, int dstCapacity); + + +/*! LZ4_decompress_safe_usingDict() : + * Works the same as + * a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue() + * However, it's stateless: it doesn't need any LZ4_streamDecode_t state. + * Dictionary is presumed stable : it must remain accessible and unmodified during decompression. + * Performance tip : Decompression speed can be substantially increased + * when dst == dictStart + dictSize. + */ +LZ4LIB_API int +LZ4_decompress_safe_usingDict(const char* src, char* dst, + int srcSize, int dstCapacity, + const char* dictStart, int dictSize); + +/*! LZ4_decompress_safe_partial_usingDict() : + * Behaves the same as LZ4_decompress_safe_partial() + * with the added ability to specify a memory segment for past data. + * Performance tip : Decompression speed can be substantially increased + * when dst == dictStart + dictSize. + */ +LZ4LIB_API int +LZ4_decompress_safe_partial_usingDict(const char* src, char* dst, + int compressedSize, + int targetOutputSize, int maxOutputSize, + const char* dictStart, int dictSize); + +#endif /* LZ4_H_2983827168210 */ + + +/*^************************************* + * !!!!!! STATIC LINKING ONLY !!!!!! + ***************************************/ + +/*-**************************************************************************** + * Experimental section + * + * Symbols declared in this section must be considered unstable. Their + * signatures or semantics may change, or they may be removed altogether in the + * future. They are therefore only safe to depend on when the caller is + * statically linked against the library. + * + * To protect against unsafe usage, not only are the declarations guarded, + * the definitions are hidden by default + * when building LZ4 as a shared/dynamic library. + * + * In order to access these declarations, + * define LZ4_STATIC_LINKING_ONLY in your application + * before including LZ4's headers. + * + * In order to make their implementations accessible dynamically, you must + * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library. + ******************************************************************************/ + +#ifdef LZ4_STATIC_LINKING_ONLY + +#ifndef LZ4_STATIC_3504398509 +#define LZ4_STATIC_3504398509 + +#ifdef LZ4_PUBLISH_STATIC_FUNCTIONS +# define LZ4LIB_STATIC_API LZ4LIB_API +#else +# define LZ4LIB_STATIC_API +#endif + + +/*! LZ4_compress_fast_extState_fastReset() : + * A variant of LZ4_compress_fast_extState(). + * + * Using this variant avoids an expensive initialization step. + * It is only safe to call if the state buffer is known to be correctly initialized already + * (see above comment on LZ4_resetStream_fast() for a definition of "correctly initialized"). + * From a high level, the difference is that + * this function initializes the provided state with a call to something like LZ4_resetStream_fast() + * while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream(). + */ +LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); + +/*! LZ4_compress_destSize_extState() : introduced in v1.10.0 + * Same as LZ4_compress_destSize(), but using an externally allocated state. + * Also: exposes @acceleration + */ +int LZ4_compress_destSize_extState(void* state, const char* src, char* dst, int* srcSizePtr, int targetDstSize, int acceleration); + +/*! In-place compression and decompression + * + * It's possible to have input and output sharing the same buffer, + * for highly constrained memory environments. + * In both cases, it requires input to lay at the end of the buffer, + * and decompression to start at beginning of the buffer. + * Buffer size must feature some margin, hence be larger than final size. + * + * |<------------------------buffer--------------------------------->| + * |<-----------compressed data--------->| + * |<-----------decompressed size------------------>| + * |<----margin---->| + * + * This technique is more useful for decompression, + * since decompressed size is typically larger, + * and margin is short. + * + * In-place decompression will work inside any buffer + * which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize). + * This presumes that decompressedSize > compressedSize. + * Otherwise, it means compression actually expanded data, + * and it would be more efficient to store such data with a flag indicating it's not compressed. + * This can happen when data is not compressible (already compressed, or encrypted). + * + * For in-place compression, margin is larger, as it must be able to cope with both + * history preservation, requiring input data to remain unmodified up to LZ4_DISTANCE_MAX, + * and data expansion, which can happen when input is not compressible. + * As a consequence, buffer size requirements are much higher, + * and memory savings offered by in-place compression are more limited. + * + * There are ways to limit this cost for compression : + * - Reduce history size, by modifying LZ4_DISTANCE_MAX. + * Note that it is a compile-time constant, so all compressions will apply this limit. + * Lower values will reduce compression ratio, except when input_size < LZ4_DISTANCE_MAX, + * so it's a reasonable trick when inputs are known to be small. + * - Require the compressor to deliver a "maximum compressed size". + * This is the `dstCapacity` parameter in `LZ4_compress*()`. + * When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can fail, + * in which case, the return code will be 0 (zero). + * The caller must be ready for these cases to happen, + * and typically design a backup scheme to send data uncompressed. + * The combination of both techniques can significantly reduce + * the amount of margin required for in-place compression. + * + * In-place compression can work in any buffer + * which size is >= (maxCompressedSize) + * with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed compression success. + * LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both maxCompressedSize and LZ4_DISTANCE_MAX, + * so it's possible to reduce memory requirements by playing with them. + */ + +#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32) +#define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize)) /**< note: presumes that compressedSize < decompressedSize. note2: margin is overestimated a bit, since it could use compressedSize instead */ + +#ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */ +# define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */ +#endif + +#define LZ4_COMPRESS_INPLACE_MARGIN (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */ +#define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN) /**< maxCompressedSize is generally LZ4_COMPRESSBOUND(inputSize), but can be set to any lower value, with the risk that compression can fail (return code 0(zero)) */ + +#endif /* LZ4_STATIC_3504398509 */ +#endif /* LZ4_STATIC_LINKING_ONLY */ + + + +#ifndef LZ4_H_98237428734687 +#define LZ4_H_98237428734687 + +/*-************************************************************ + * Private Definitions + ************************************************************** + * Do not use these definitions directly. + * They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`. + * Accessing members will expose user code to API and/or ABI break in future versions of the library. + **************************************************************/ +#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2) +#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE) +#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */ + +#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) +# include + typedef int8_t LZ4_i8; + typedef uint8_t LZ4_byte; + typedef uint16_t LZ4_u16; + typedef uint32_t LZ4_u32; +#else + typedef signed char LZ4_i8; + typedef unsigned char LZ4_byte; + typedef unsigned short LZ4_u16; + typedef unsigned int LZ4_u32; +#endif + +/*! LZ4_stream_t : + * Never ever use below internal definitions directly ! + * These definitions are not API/ABI safe, and may change in future versions. + * If you need static allocation, declare or allocate an LZ4_stream_t object. +**/ + +typedef struct LZ4_stream_t_internal LZ4_stream_t_internal; +struct LZ4_stream_t_internal { + LZ4_u32 hashTable[LZ4_HASH_SIZE_U32]; + const LZ4_byte* dictionary; + const LZ4_stream_t_internal* dictCtx; + LZ4_u32 currentOffset; + LZ4_u32 tableType; + LZ4_u32 dictSize; + /* Implicit padding to ensure structure is aligned */ +}; + +#define LZ4_STREAM_MINSIZE ((1UL << (LZ4_MEMORY_USAGE)) + 32) /* static size, for inter-version compatibility */ +union LZ4_stream_u { + char minStateSize[LZ4_STREAM_MINSIZE]; + LZ4_stream_t_internal internal_donotuse; +}; /* previously typedef'd to LZ4_stream_t */ + + +/*! LZ4_initStream() : v1.9.0+ + * An LZ4_stream_t structure must be initialized at least once. + * This is automatically done when invoking LZ4_createStream(), + * but it's not when the structure is simply declared on stack (for example). + * + * Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t. + * It can also initialize any arbitrary buffer of sufficient size, + * and will @return a pointer of proper type upon initialization. + * + * Note : initialization fails if size and alignment conditions are not respected. + * In which case, the function will @return NULL. + * Note2: An LZ4_stream_t structure guarantees correct alignment and size. + * Note3: Before v1.9.0, use LZ4_resetStream() instead +**/ +LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* stateBuffer, size_t size); + + +/*! LZ4_streamDecode_t : + * Never ever use below internal definitions directly ! + * These definitions are not API/ABI safe, and may change in future versions. + * If you need static allocation, declare or allocate an LZ4_streamDecode_t object. +**/ +typedef struct { + const LZ4_byte* externalDict; + const LZ4_byte* prefixEnd; + size_t extDictSize; + size_t prefixSize; +} LZ4_streamDecode_t_internal; + +#define LZ4_STREAMDECODE_MINSIZE 32 +union LZ4_streamDecode_u { + char minStateSize[LZ4_STREAMDECODE_MINSIZE]; + LZ4_streamDecode_t_internal internal_donotuse; +} ; /* previously typedef'd to LZ4_streamDecode_t */ + + + +/*-************************************ +* Obsolete Functions +**************************************/ + +/*! Deprecation warnings + * + * Deprecated functions make the compiler generate a warning when invoked. + * This is meant to invite users to update their source code. + * Should deprecation warnings be a problem, it is generally possible to disable them, + * typically with -Wno-deprecated-declarations for gcc + * or _CRT_SECURE_NO_WARNINGS in Visual. + * + * Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS + * before including the header file. + */ +#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS +# define LZ4_DEPRECATED(message) /* disable deprecation warnings */ +#else +# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */ +# define LZ4_DEPRECATED(message) [[deprecated(message)]] +# elif defined(_MSC_VER) +# define LZ4_DEPRECATED(message) __declspec(deprecated(message)) +# elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45)) +# define LZ4_DEPRECATED(message) __attribute__((deprecated(message))) +# elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31) +# define LZ4_DEPRECATED(message) __attribute__((deprecated)) +# else +# pragma message("WARNING: LZ4_DEPRECATED needs custom implementation for this compiler") +# define LZ4_DEPRECATED(message) /* disabled */ +# endif +#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */ + +/*! Obsolete compression functions (since v1.7.3) */ +LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* src, char* dest, int srcSize); +LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput (const char* src, char* dest, int srcSize, int maxOutputSize); +LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); +LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); +LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); +LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); + +/*! Obsolete decompression functions (since v1.8.0) */ +LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize); +LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); + +/* Obsolete streaming functions (since v1.7.0) + * degraded functionality; do not use! + * + * In order to perform streaming compression, these functions depended on data + * that is no longer tracked in the state. They have been preserved as well as + * possible: using them will still produce a correct output. However, they don't + * actually retain any history between compression calls. The compression ratio + * achieved will therefore be no better than compressing each chunk + * independently. + */ +LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer); +LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void); +LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer); +LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer (void* state); + +/*! Obsolete streaming decoding functions (since v1.7.0) */ +LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize); +LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize); + +/*! Obsolete LZ4_decompress_fast variants (since v1.9.0) : + * These functions used to be faster than LZ4_decompress_safe(), + * but this is no longer the case. They are now slower. + * This is because LZ4_decompress_fast() doesn't know the input size, + * and therefore must progress more cautiously into the input buffer to not read beyond the end of block. + * On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability. + * As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated. + * + * The last remaining LZ4_decompress_fast() specificity is that + * it can decompress a block without knowing its compressed size. + * Such functionality can be achieved in a more secure manner + * by employing LZ4_decompress_safe_partial(). + * + * Parameters: + * originalSize : is the uncompressed size to regenerate. + * `dst` must be already allocated, its size must be >= 'originalSize' bytes. + * @return : number of bytes read from source buffer (== compressed size). + * The function expects to finish at block's end exactly. + * If the source stream is detected malformed, the function stops decoding and returns a negative result. + * note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer. + * However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds. + * Also, since match offsets are not validated, match reads from 'src' may underflow too. + * These issues never happen if input (compressed) data is correct. + * But they may happen if input data is invalid (error or intentional tampering). + * As a consequence, use these functions in trusted environments with trusted data **only**. + */ +LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_partial() instead") +LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize); +LZ4_DEPRECATED("This function is deprecated and unsafe. Consider migrating towards LZ4_decompress_safe_continue() instead. " + "Note that the contract will change (requires block's compressed size, instead of decompressed size)") +LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize); +LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_partial_usingDict() instead") +LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize); + +/*! LZ4_resetStream() : + * An LZ4_stream_t structure must be initialized at least once. + * This is done with LZ4_initStream(), or LZ4_resetStream(). + * Consider switching to LZ4_initStream(), + * invoking LZ4_resetStream() will trigger deprecation warnings in the future. + */ +LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr); + + +#endif /* LZ4_H_98237428734687 */ + + +#if defined (__cplusplus) +} +#endif diff --git a/illumos-x86_64/usr/include/lz4file.h b/illumos-x86_64/usr/include/lz4file.h new file mode 100644 index 00000000..598ad705 --- /dev/null +++ b/illumos-x86_64/usr/include/lz4file.h @@ -0,0 +1,93 @@ +/* + LZ4 file library + Header File + Copyright (C) 2022, Xiaomi Inc. + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - LZ4 source repository : https://github.com/lz4/lz4 + - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +*/ +#if defined (__cplusplus) +extern "C" { +#endif + +#ifndef LZ4FILE_H +#define LZ4FILE_H + +#include /* FILE* */ +#include "lz4frame_static.h" + +typedef struct LZ4_readFile_s LZ4_readFile_t; +typedef struct LZ4_writeFile_s LZ4_writeFile_t; + +/*! LZ4F_readOpen() : + * Set read lz4file handle. + * `lz4f` will set a lz4file handle. + * `fp` must be the return value of the lz4 file opened by fopen. + */ +LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_readOpen(LZ4_readFile_t** lz4fRead, FILE* fp); + +/*! LZ4F_read() : + * Read lz4file content to buffer. + * `lz4f` must use LZ4_readOpen to set first. + * `buf` read data buffer. + * `size` read data buffer size. + */ +LZ4FLIB_STATIC_API size_t LZ4F_read(LZ4_readFile_t* lz4fRead, void* buf, size_t size); + +/*! LZ4F_readClose() : + * Close lz4file handle. + * `lz4f` must use LZ4_readOpen to set first. + */ +LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_readClose(LZ4_readFile_t* lz4fRead); + +/*! LZ4F_writeOpen() : + * Set write lz4file handle. + * `lz4f` will set a lz4file handle. + * `fp` must be the return value of the lz4 file opened by fopen. + */ +LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_writeOpen(LZ4_writeFile_t** lz4fWrite, FILE* fp, const LZ4F_preferences_t* prefsPtr); + +/*! LZ4F_write() : + * Write buffer to lz4file. + * `lz4f` must use LZ4F_writeOpen to set first. + * `buf` write data buffer. + * `size` write data buffer size. + */ +LZ4FLIB_STATIC_API size_t LZ4F_write(LZ4_writeFile_t* lz4fWrite, const void* buf, size_t size); + +/*! LZ4F_writeClose() : + * Close lz4file handle. + * `lz4f` must use LZ4F_writeOpen to set first. + */ +LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_writeClose(LZ4_writeFile_t* lz4fWrite); + +#endif /* LZ4FILE_H */ + +#if defined (__cplusplus) +} +#endif diff --git a/illumos-x86_64/usr/include/lz4frame.h b/illumos-x86_64/usr/include/lz4frame.h new file mode 100644 index 00000000..b8ae3227 --- /dev/null +++ b/illumos-x86_64/usr/include/lz4frame.h @@ -0,0 +1,751 @@ +/* + LZ4F - LZ4-Frame library + Header File + Copyright (C) 2011-2020, Yann Collet. + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - LZ4 source repository : https://github.com/lz4/lz4 + - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +*/ + +/* LZ4F is a stand-alone API able to create and decode LZ4 frames + * conformant with specification v1.6.1 in doc/lz4_Frame_format.md . + * Generated frames are compatible with `lz4` CLI. + * + * LZ4F also offers streaming capabilities. + * + * lz4.h is not required when using lz4frame.h, + * except to extract common constants such as LZ4_VERSION_NUMBER. + * */ + +#ifndef LZ4F_H_09782039843 +#define LZ4F_H_09782039843 + +#if defined (__cplusplus) +extern "C" { +#endif + +/* --- Dependency --- */ +#include /* size_t */ + + +/** + * Introduction + * + * lz4frame.h implements LZ4 frame specification: see doc/lz4_Frame_format.md . + * LZ4 Frames are compatible with `lz4` CLI, + * and designed to be interoperable with any system. +**/ + +/*-*************************************************************** + * Compiler specifics + *****************************************************************/ +/* LZ4_DLL_EXPORT : + * Enable exporting of functions when building a Windows DLL + * LZ4FLIB_VISIBILITY : + * Control library symbols visibility. + */ +#ifndef LZ4FLIB_VISIBILITY +# if defined(__GNUC__) && (__GNUC__ >= 4) +# define LZ4FLIB_VISIBILITY __attribute__ ((visibility ("default"))) +# else +# define LZ4FLIB_VISIBILITY +# endif +#endif +#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) +# define LZ4FLIB_API __declspec(dllexport) LZ4FLIB_VISIBILITY +#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1) +# define LZ4FLIB_API __declspec(dllimport) LZ4FLIB_VISIBILITY +#else +# define LZ4FLIB_API LZ4FLIB_VISIBILITY +#endif + +#ifdef LZ4F_DISABLE_DEPRECATE_WARNINGS +# define LZ4F_DEPRECATE(x) x +#else +# if defined(_MSC_VER) +# define LZ4F_DEPRECATE(x) x /* __declspec(deprecated) x - only works with C++ */ +# elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6)) +# define LZ4F_DEPRECATE(x) x __attribute__((deprecated)) +# else +# define LZ4F_DEPRECATE(x) x /* no deprecation warning for this compiler */ +# endif +#endif + + +/*-************************************ + * Error management + **************************************/ +typedef size_t LZ4F_errorCode_t; + +LZ4FLIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code); /**< tells when a function result is an error code */ +LZ4FLIB_API const char* LZ4F_getErrorName(LZ4F_errorCode_t code); /**< return error code string; for debugging */ + + +/*-************************************ + * Frame compression types + ************************************* */ +/* #define LZ4F_ENABLE_OBSOLETE_ENUMS // uncomment to enable obsolete enums */ +#ifdef LZ4F_ENABLE_OBSOLETE_ENUMS +# define LZ4F_OBSOLETE_ENUM(x) , LZ4F_DEPRECATE(x) = LZ4F_##x +#else +# define LZ4F_OBSOLETE_ENUM(x) +#endif + +/* The larger the block size, the (slightly) better the compression ratio, + * though there are diminishing returns. + * Larger blocks also increase memory usage on both compression and decompression sides. + */ +typedef enum { + LZ4F_default=0, + LZ4F_max64KB=4, + LZ4F_max256KB=5, + LZ4F_max1MB=6, + LZ4F_max4MB=7 + LZ4F_OBSOLETE_ENUM(max64KB) + LZ4F_OBSOLETE_ENUM(max256KB) + LZ4F_OBSOLETE_ENUM(max1MB) + LZ4F_OBSOLETE_ENUM(max4MB) +} LZ4F_blockSizeID_t; + +/* Linked blocks sharply reduce inefficiencies when using small blocks, + * they compress better. + * However, some LZ4 decoders are only compatible with independent blocks */ +typedef enum { + LZ4F_blockLinked=0, + LZ4F_blockIndependent + LZ4F_OBSOLETE_ENUM(blockLinked) + LZ4F_OBSOLETE_ENUM(blockIndependent) +} LZ4F_blockMode_t; + +typedef enum { + LZ4F_noContentChecksum=0, + LZ4F_contentChecksumEnabled + LZ4F_OBSOLETE_ENUM(noContentChecksum) + LZ4F_OBSOLETE_ENUM(contentChecksumEnabled) +} LZ4F_contentChecksum_t; + +typedef enum { + LZ4F_noBlockChecksum=0, + LZ4F_blockChecksumEnabled +} LZ4F_blockChecksum_t; + +typedef enum { + LZ4F_frame=0, + LZ4F_skippableFrame + LZ4F_OBSOLETE_ENUM(skippableFrame) +} LZ4F_frameType_t; + +#ifdef LZ4F_ENABLE_OBSOLETE_ENUMS +typedef LZ4F_blockSizeID_t blockSizeID_t; +typedef LZ4F_blockMode_t blockMode_t; +typedef LZ4F_frameType_t frameType_t; +typedef LZ4F_contentChecksum_t contentChecksum_t; +#endif + +/*! LZ4F_frameInfo_t : + * makes it possible to set or read frame parameters. + * Structure must be first init to 0, using memset() or LZ4F_INIT_FRAMEINFO, + * setting all parameters to default. + * It's then possible to update selectively some parameters */ +typedef struct { + LZ4F_blockSizeID_t blockSizeID; /* max64KB, max256KB, max1MB, max4MB; 0 == default (LZ4F_max64KB) */ + LZ4F_blockMode_t blockMode; /* LZ4F_blockLinked, LZ4F_blockIndependent; 0 == default (LZ4F_blockLinked) */ + LZ4F_contentChecksum_t contentChecksumFlag; /* 1: add a 32-bit checksum of frame's decompressed data; 0 == default (disabled) */ + LZ4F_frameType_t frameType; /* read-only field : LZ4F_frame or LZ4F_skippableFrame */ + unsigned long long contentSize; /* Size of uncompressed content ; 0 == unknown */ + unsigned dictID; /* Dictionary ID, sent by compressor to help decoder select correct dictionary; 0 == no dictID provided */ + LZ4F_blockChecksum_t blockChecksumFlag; /* 1: each block followed by a checksum of block's compressed data; 0 == default (disabled) */ +} LZ4F_frameInfo_t; + +#define LZ4F_INIT_FRAMEINFO { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum } /* v1.8.3+ */ + +/*! LZ4F_preferences_t : + * makes it possible to supply advanced compression instructions to streaming interface. + * Structure must be first init to 0, using memset() or LZ4F_INIT_PREFERENCES, + * setting all parameters to default. + * All reserved fields must be set to zero. */ +typedef struct { + LZ4F_frameInfo_t frameInfo; + int compressionLevel; /* 0: default (fast mode); values > LZ4HC_CLEVEL_MAX count as LZ4HC_CLEVEL_MAX; values < 0 trigger "fast acceleration" */ + unsigned autoFlush; /* 1: always flush; reduces usage of internal buffers */ + unsigned favorDecSpeed; /* 1: parser favors decompression speed vs compression ratio. Only works for high compression modes (>= LZ4HC_CLEVEL_OPT_MIN) */ /* v1.8.2+ */ + unsigned reserved[3]; /* must be zero for forward compatibility */ +} LZ4F_preferences_t; + +#define LZ4F_INIT_PREFERENCES { LZ4F_INIT_FRAMEINFO, 0, 0u, 0u, { 0u, 0u, 0u } } /* v1.8.3+ */ + + +/*-********************************* +* Simple compression function +***********************************/ + +/*! LZ4F_compressFrame() : + * Compress srcBuffer content into an LZ4-compressed frame. + * It's a one shot operation, all input content is consumed, and all output is generated. + * + * Note : it's a stateless operation (no LZ4F_cctx state needed). + * In order to reduce load on the allocator, LZ4F_compressFrame(), by default, + * uses the stack to allocate space for the compression state and some table. + * If this usage of the stack is too much for your application, + * consider compiling `lz4frame.c` with compile-time macro LZ4F_HEAPMODE set to 1 instead. + * All state allocations will use the Heap. + * It also means each invocation of LZ4F_compressFrame() will trigger several internal alloc/free invocations. + * + * @dstCapacity MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). + * @preferencesPtr is optional : one can provide NULL, in which case all preferences are set to default. + * @return : number of bytes written into dstBuffer. + * or an error code if it fails (can be tested using LZ4F_isError()) + */ +LZ4FLIB_API size_t LZ4F_compressFrame(void* dstBuffer, size_t dstCapacity, + const void* srcBuffer, size_t srcSize, + const LZ4F_preferences_t* preferencesPtr); + +/*! LZ4F_compressFrameBound() : + * Returns the maximum possible compressed size with LZ4F_compressFrame() given srcSize and preferences. + * `preferencesPtr` is optional. It can be replaced by NULL, in which case, the function will assume default preferences. + * Note : this result is only usable with LZ4F_compressFrame(). + * It may also be relevant to LZ4F_compressUpdate() _only if_ no flush() operation is ever performed. + */ +LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr); + + +/*! LZ4F_compressionLevel_max() : + * @return maximum allowed compression level (currently: 12) + */ +LZ4FLIB_API int LZ4F_compressionLevel_max(void); /* v1.8.0+ */ + + +/*-*********************************** +* Advanced compression functions +*************************************/ +typedef struct LZ4F_cctx_s LZ4F_cctx; /* incomplete type */ +typedef LZ4F_cctx* LZ4F_compressionContext_t; /* for compatibility with older APIs, prefer using LZ4F_cctx */ + +typedef struct { + unsigned stableSrc; /* 1 == src content will remain present on future calls to LZ4F_compress(); skip copying src content within tmp buffer */ + unsigned reserved[3]; +} LZ4F_compressOptions_t; + +/*--- Resource Management ---*/ + +#define LZ4F_VERSION 100 /* This number can be used to check for an incompatible API breaking change */ +LZ4FLIB_API unsigned LZ4F_getVersion(void); + +/*! LZ4F_createCompressionContext() : + * The first thing to do is to create a compressionContext object, + * which will keep track of operation state during streaming compression. + * This is achieved using LZ4F_createCompressionContext(), which takes as argument a version, + * and a pointer to LZ4F_cctx*, to write the resulting pointer into. + * @version provided MUST be LZ4F_VERSION. It is intended to track potential version mismatch, notably when using DLL. + * The function provides a pointer to a fully allocated LZ4F_cctx object. + * @cctxPtr MUST be != NULL. + * If @return != zero, context creation failed. + * A created compression context can be employed multiple times for consecutive streaming operations. + * Once all streaming compression jobs are completed, + * the state object can be released using LZ4F_freeCompressionContext(). + * Note1 : LZ4F_freeCompressionContext() is always successful. Its return value can be ignored. + * Note2 : LZ4F_freeCompressionContext() works fine with NULL input pointers (do nothing). +**/ +LZ4FLIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx** cctxPtr, unsigned version); +LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx* cctx); + + +/*---- Compression ----*/ + +#define LZ4F_HEADER_SIZE_MIN 7 /* LZ4 Frame header size can vary, depending on selected parameters */ +#define LZ4F_HEADER_SIZE_MAX 19 + +/* Size in bytes of a block header in little-endian format. Highest bit indicates if block data is uncompressed */ +#define LZ4F_BLOCK_HEADER_SIZE 4 + +/* Size in bytes of a block checksum footer in little-endian format. */ +#define LZ4F_BLOCK_CHECKSUM_SIZE 4 + +/* Size in bytes of the content checksum. */ +#define LZ4F_CONTENT_CHECKSUM_SIZE 4 + +/*! LZ4F_compressBegin() : + * will write the frame header into dstBuffer. + * dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. + * `prefsPtr` is optional : NULL can be provided to set all preferences to default. + * @return : number of bytes written into dstBuffer for the header + * or an error code (which can be tested using LZ4F_isError()) + */ +LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx* cctx, + void* dstBuffer, size_t dstCapacity, + const LZ4F_preferences_t* prefsPtr); + +/*! LZ4F_compressBound() : + * Provides minimum dstCapacity required to guarantee success of + * LZ4F_compressUpdate(), given a srcSize and preferences, for a worst case scenario. + * When srcSize==0, LZ4F_compressBound() provides an upper bound for LZ4F_flush() and LZ4F_compressEnd() instead. + * Note that the result is only valid for a single invocation of LZ4F_compressUpdate(). + * When invoking LZ4F_compressUpdate() multiple times, + * if the output buffer is gradually filled up instead of emptied and re-used from its start, + * one must check if there is enough remaining capacity before each invocation, using LZ4F_compressBound(). + * @return is always the same for a srcSize and prefsPtr. + * prefsPtr is optional : when NULL is provided, preferences will be set to cover worst case scenario. + * tech details : + * @return if automatic flushing is not enabled, includes the possibility that internal buffer might already be filled by up to (blockSize-1) bytes. + * It also includes frame footer (ending + checksum), since it might be generated by LZ4F_compressEnd(). + * @return doesn't include frame header, as it was already generated by LZ4F_compressBegin(). + */ +LZ4FLIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr); + +/*! LZ4F_compressUpdate() : + * LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. + * Important rule: dstCapacity MUST be large enough to ensure operation success even in worst case situations. + * This value is provided by LZ4F_compressBound(). + * If this condition is not respected, LZ4F_compress() will fail (result is an errorCode). + * After an error, the state is left in a UB state, and must be re-initialized or freed. + * If previously an uncompressed block was written, buffered data is flushed + * before appending compressed data is continued. + * `cOptPtr` is optional : NULL can be provided, in which case all options are set to default. + * @return : number of bytes written into `dstBuffer` (it can be zero, meaning input data was just buffered). + * or an error code if it fails (which can be tested using LZ4F_isError()) + */ +LZ4FLIB_API size_t LZ4F_compressUpdate(LZ4F_cctx* cctx, + void* dstBuffer, size_t dstCapacity, + const void* srcBuffer, size_t srcSize, + const LZ4F_compressOptions_t* cOptPtr); + +/*! LZ4F_flush() : + * When data must be generated and sent immediately, without waiting for a block to be completely filled, + * it's possible to call LZ4_flush(). It will immediately compress any data buffered within cctx. + * `dstCapacity` must be large enough to ensure the operation will be successful. + * `cOptPtr` is optional : it's possible to provide NULL, all options will be set to default. + * @return : nb of bytes written into dstBuffer (can be zero, when there is no data stored within cctx) + * or an error code if it fails (which can be tested using LZ4F_isError()) + * Note : LZ4F_flush() is guaranteed to be successful when dstCapacity >= LZ4F_compressBound(0, prefsPtr). + */ +LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx* cctx, + void* dstBuffer, size_t dstCapacity, + const LZ4F_compressOptions_t* cOptPtr); + +/*! LZ4F_compressEnd() : + * To properly finish an LZ4 frame, invoke LZ4F_compressEnd(). + * It will flush whatever data remained within `cctx` (like LZ4_flush()) + * and properly finalize the frame, with an endMark and a checksum. + * `cOptPtr` is optional : NULL can be provided, in which case all options will be set to default. + * @return : nb of bytes written into dstBuffer, necessarily >= 4 (endMark), + * or an error code if it fails (which can be tested using LZ4F_isError()) + * Note : LZ4F_compressEnd() is guaranteed to be successful when dstCapacity >= LZ4F_compressBound(0, prefsPtr). + * A successful call to LZ4F_compressEnd() makes `cctx` available again for another compression task. + */ +LZ4FLIB_API size_t LZ4F_compressEnd(LZ4F_cctx* cctx, + void* dstBuffer, size_t dstCapacity, + const LZ4F_compressOptions_t* cOptPtr); + + +/*-********************************* +* Decompression functions +***********************************/ +typedef struct LZ4F_dctx_s LZ4F_dctx; /* incomplete type */ +typedef LZ4F_dctx* LZ4F_decompressionContext_t; /* compatibility with previous API versions */ + +typedef struct { + unsigned stableDst; /* pledges that last 64KB decompressed data is present right before @dstBuffer pointer. + * This optimization skips internal storage operations. + * Once set, this pledge must remain valid up to the end of current frame. */ + unsigned skipChecksums; /* disable checksum calculation and verification, even when one is present in frame, to save CPU time. + * Setting this option to 1 once disables all checksums for the rest of the frame. */ + unsigned reserved1; /* must be set to zero for forward compatibility */ + unsigned reserved0; /* idem */ +} LZ4F_decompressOptions_t; + + +/* Resource management */ + +/*! LZ4F_createDecompressionContext() : + * Create an LZ4F_dctx object, to track all decompression operations. + * @version provided MUST be LZ4F_VERSION. + * @dctxPtr MUST be valid. + * The function fills @dctxPtr with the value of a pointer to an allocated and initialized LZ4F_dctx object. + * The @return is an errorCode, which can be tested using LZ4F_isError(). + * dctx memory can be released using LZ4F_freeDecompressionContext(); + * Result of LZ4F_freeDecompressionContext() indicates current state of decompressionContext when being released. + * That is, it should be == 0 if decompression has been completed fully and correctly. + */ +LZ4FLIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx** dctxPtr, unsigned version); +LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx* dctx); + + +/*-*********************************** +* Streaming decompression functions +*************************************/ + +#define LZ4F_MAGICNUMBER 0x184D2204U +#define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U +#define LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH 5 + +/*! LZ4F_headerSize() : v1.9.0+ + * Provide the header size of a frame starting at `src`. + * `srcSize` must be >= LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH, + * which is enough to decode the header length. + * @return : size of frame header + * or an error code, which can be tested using LZ4F_isError() + * note : Frame header size is variable, but is guaranteed to be + * >= LZ4F_HEADER_SIZE_MIN bytes, and <= LZ4F_HEADER_SIZE_MAX bytes. + */ +LZ4FLIB_API size_t LZ4F_headerSize(const void* src, size_t srcSize); + +/*! LZ4F_getFrameInfo() : + * This function extracts frame parameters (max blockSize, dictID, etc.). + * Its usage is optional: user can also invoke LZ4F_decompress() directly. + * + * Extracted information will fill an existing LZ4F_frameInfo_t structure. + * This can be useful for allocation and dictionary identification purposes. + * + * LZ4F_getFrameInfo() can work in the following situations : + * + * 1) At the beginning of a new frame, before any invocation of LZ4F_decompress(). + * It will decode header from `srcBuffer`, + * consuming the header and starting the decoding process. + * + * Input size must be large enough to contain the full frame header. + * Frame header size can be known beforehand by LZ4F_headerSize(). + * Frame header size is variable, but is guaranteed to be >= LZ4F_HEADER_SIZE_MIN bytes, + * and not more than <= LZ4F_HEADER_SIZE_MAX bytes. + * Hence, blindly providing LZ4F_HEADER_SIZE_MAX bytes or more will always work. + * It's allowed to provide more input data than the header size, + * LZ4F_getFrameInfo() will only consume the header. + * + * If input size is not large enough, + * aka if it's smaller than header size, + * function will fail and return an error code. + * + * 2) After decoding has been started, + * it's possible to invoke LZ4F_getFrameInfo() anytime + * to extract already decoded frame parameters stored within dctx. + * + * Note that, if decoding has barely started, + * and not yet read enough information to decode the header, + * LZ4F_getFrameInfo() will fail. + * + * The number of bytes consumed from srcBuffer will be updated in *srcSizePtr (necessarily <= original value). + * LZ4F_getFrameInfo() only consumes bytes when decoding has not yet started, + * and when decoding the header has been successful. + * Decompression must then resume from (srcBuffer + *srcSizePtr). + * + * @return : a hint about how many srcSize bytes LZ4F_decompress() expects for next call, + * or an error code which can be tested using LZ4F_isError(). + * note 1 : in case of error, dctx is not modified. Decoding operation can resume from beginning safely. + * note 2 : frame parameters are *copied into* an already allocated LZ4F_frameInfo_t structure. + */ +LZ4FLIB_API size_t +LZ4F_getFrameInfo(LZ4F_dctx* dctx, + LZ4F_frameInfo_t* frameInfoPtr, + const void* srcBuffer, size_t* srcSizePtr); + +/*! LZ4F_decompress() : + * Call this function repetitively to regenerate data compressed in `srcBuffer`. + * + * The function requires a valid dctx state. + * It will read up to *srcSizePtr bytes from srcBuffer, + * and decompress data into dstBuffer, of capacity *dstSizePtr. + * + * The nb of bytes consumed from srcBuffer will be written into *srcSizePtr (necessarily <= original value). + * The nb of bytes decompressed into dstBuffer will be written into *dstSizePtr (necessarily <= original value). + * + * The function does not necessarily read all input bytes, so always check value in *srcSizePtr. + * Unconsumed source data must be presented again in subsequent invocations. + * + * `dstBuffer` can freely change between each consecutive function invocation. + * `dstBuffer` content will be overwritten. + * + * Note: if `LZ4F_getFrameInfo()` is called before `LZ4F_decompress()`, srcBuffer must be updated to reflect + * the number of bytes consumed after reading the frame header. Failure to update srcBuffer before calling + * `LZ4F_decompress()` will cause decompression failure or, even worse, successful but incorrect decompression. + * See the `LZ4F_getFrameInfo()` docs for details. + * + * @return : an hint of how many `srcSize` bytes LZ4F_decompress() expects for next call. + * Schematically, it's the size of the current (or remaining) compressed block + header of next block. + * Respecting the hint provides some small speed benefit, because it skips intermediate buffers. + * This is just a hint though, it's always possible to provide any srcSize. + * + * When a frame is fully decoded, @return will be 0 (no more data expected). + * When provided with more bytes than necessary to decode a frame, + * LZ4F_decompress() will stop reading exactly at end of current frame, and @return 0. + * + * If decompression failed, @return is an error code, which can be tested using LZ4F_isError(). + * After a decompression error, the `dctx` context is not resumable. + * Use LZ4F_resetDecompressionContext() to return to clean state. + * + * After a frame is fully decoded, dctx can be used again to decompress another frame. + */ +LZ4FLIB_API size_t +LZ4F_decompress(LZ4F_dctx* dctx, + void* dstBuffer, size_t* dstSizePtr, + const void* srcBuffer, size_t* srcSizePtr, + const LZ4F_decompressOptions_t* dOptPtr); + + +/*! LZ4F_resetDecompressionContext() : added in v1.8.0 + * In case of an error, the context is left in "undefined" state. + * In which case, it's necessary to reset it, before re-using it. + * This method can also be used to abruptly stop any unfinished decompression, + * and start a new one using same context resources. */ +LZ4FLIB_API void LZ4F_resetDecompressionContext(LZ4F_dctx* dctx); /* always successful */ + + +/********************************** + * Dictionary compression API + *********************************/ + +/* A Dictionary is useful for the compression of small messages (KB range). + * It dramatically improves compression efficiency. + * + * LZ4 can ingest any input as dictionary, though only the last 64 KB are useful. + * Better results are generally achieved by using Zstandard's Dictionary Builder + * to generate a high-quality dictionary from a set of samples. + * + * The same dictionary will have to be used on the decompression side + * for decoding to be successful. + * To help identify the correct dictionary at decoding stage, + * the frame header allows optional embedding of a dictID field. + */ + +/*! LZ4F_compressBegin_usingDict() : stable since v1.10 + * Inits dictionary compression streaming, and writes the frame header into dstBuffer. + * @dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. + * @prefsPtr is optional : one may provide NULL as argument, + * however, it's the only way to provide dictID in the frame header. + * @dictBuffer must outlive the compression session. + * @return : number of bytes written into dstBuffer for the header, + * or an error code (which can be tested using LZ4F_isError()) + * NOTE: The LZ4Frame spec allows each independent block to be compressed with the dictionary, + * but this entry supports a more limited scenario, where only the first block uses the dictionary. + * This is still useful for small data, which only need one block anyway. + * For larger inputs, one may be more interested in LZ4F_compressFrame_usingCDict() below. + */ +LZ4FLIB_API size_t +LZ4F_compressBegin_usingDict(LZ4F_cctx* cctx, + void* dstBuffer, size_t dstCapacity, + const void* dictBuffer, size_t dictSize, + const LZ4F_preferences_t* prefsPtr); + +/*! LZ4F_decompress_usingDict() : stable since v1.10 + * Same as LZ4F_decompress(), using a predefined dictionary. + * Dictionary is used "in place", without any preprocessing. +** It must remain accessible throughout the entire frame decoding. */ +LZ4FLIB_API size_t +LZ4F_decompress_usingDict(LZ4F_dctx* dctxPtr, + void* dstBuffer, size_t* dstSizePtr, + const void* srcBuffer, size_t* srcSizePtr, + const void* dict, size_t dictSize, + const LZ4F_decompressOptions_t* decompressOptionsPtr); + +/***************************************** + * Bulk processing dictionary compression + *****************************************/ + +/* Loading a dictionary has a cost, since it involves construction of tables. + * The Bulk processing dictionary API makes it possible to share this cost + * over an arbitrary number of compression jobs, even concurrently, + * markedly improving compression latency for these cases. + * + * Note that there is no corresponding bulk API for the decompression side, + * because dictionary does not carry any initialization cost for decompression. + * Use the regular LZ4F_decompress_usingDict() there. + */ +typedef struct LZ4F_CDict_s LZ4F_CDict; + +/*! LZ4_createCDict() : stable since v1.10 + * When compressing multiple messages / blocks using the same dictionary, it's recommended to initialize it just once. + * LZ4_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay. + * LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. + * @dictBuffer can be released after LZ4_CDict creation, since its content is copied within CDict. */ +LZ4FLIB_API LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize); +LZ4FLIB_API void LZ4F_freeCDict(LZ4F_CDict* CDict); + +/*! LZ4_compressFrame_usingCDict() : stable since v1.10 + * Compress an entire srcBuffer into a valid LZ4 frame using a digested Dictionary. + * @cctx must point to a context created by LZ4F_createCompressionContext(). + * If @cdict==NULL, compress without a dictionary. + * @dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). + * If this condition is not respected, function will fail (@return an errorCode). + * The LZ4F_preferences_t structure is optional : one may provide NULL as argument, + * but it's not recommended, as it's the only way to provide @dictID in the frame header. + * @return : number of bytes written into dstBuffer. + * or an error code if it fails (can be tested using LZ4F_isError()) + * Note: for larger inputs generating multiple independent blocks, + * this entry point uses the dictionary for each block. */ +LZ4FLIB_API size_t +LZ4F_compressFrame_usingCDict(LZ4F_cctx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const LZ4F_CDict* cdict, + const LZ4F_preferences_t* preferencesPtr); + +/*! LZ4F_compressBegin_usingCDict() : stable since v1.10 + * Inits streaming dictionary compression, and writes the frame header into dstBuffer. + * @dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. + * @prefsPtr is optional : one may provide NULL as argument, + * note however that it's the only way to insert a @dictID in the frame header. + * @cdict must outlive the compression session. + * @return : number of bytes written into dstBuffer for the header, + * or an error code, which can be tested using LZ4F_isError(). */ +LZ4FLIB_API size_t +LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctx, + void* dstBuffer, size_t dstCapacity, + const LZ4F_CDict* cdict, + const LZ4F_preferences_t* prefsPtr); + + +#if defined (__cplusplus) +} +#endif + +#endif /* LZ4F_H_09782039843 */ + +#if defined(LZ4F_STATIC_LINKING_ONLY) && !defined(LZ4F_H_STATIC_09782039843) +#define LZ4F_H_STATIC_09782039843 + +/* Note : + * The below declarations are not stable and may change in the future. + * They are therefore only safe to depend on + * when the caller is statically linked against the library. + * To access their declarations, define LZ4F_STATIC_LINKING_ONLY. + * + * By default, these symbols aren't published into shared/dynamic libraries. + * You can override this behavior and force them to be published + * by defining LZ4F_PUBLISH_STATIC_FUNCTIONS. + * Use at your own risk. + */ + +#if defined (__cplusplus) +extern "C" { +#endif + +#ifdef LZ4F_PUBLISH_STATIC_FUNCTIONS +# define LZ4FLIB_STATIC_API LZ4FLIB_API +#else +# define LZ4FLIB_STATIC_API +#endif + + +/* --- Error List --- */ +#define LZ4F_LIST_ERRORS(ITEM) \ + ITEM(OK_NoError) \ + ITEM(ERROR_GENERIC) \ + ITEM(ERROR_maxBlockSize_invalid) \ + ITEM(ERROR_blockMode_invalid) \ + ITEM(ERROR_parameter_invalid) \ + ITEM(ERROR_compressionLevel_invalid) \ + ITEM(ERROR_headerVersion_wrong) \ + ITEM(ERROR_blockChecksum_invalid) \ + ITEM(ERROR_reservedFlag_set) \ + ITEM(ERROR_allocation_failed) \ + ITEM(ERROR_srcSize_tooLarge) \ + ITEM(ERROR_dstMaxSize_tooSmall) \ + ITEM(ERROR_frameHeader_incomplete) \ + ITEM(ERROR_frameType_unknown) \ + ITEM(ERROR_frameSize_wrong) \ + ITEM(ERROR_srcPtr_wrong) \ + ITEM(ERROR_decompressionFailed) \ + ITEM(ERROR_headerChecksum_invalid) \ + ITEM(ERROR_contentChecksum_invalid) \ + ITEM(ERROR_frameDecoding_alreadyStarted) \ + ITEM(ERROR_compressionState_uninitialized) \ + ITEM(ERROR_parameter_null) \ + ITEM(ERROR_io_write) \ + ITEM(ERROR_io_read) \ + ITEM(ERROR_maxCode) + +#define LZ4F_GENERATE_ENUM(ENUM) LZ4F_##ENUM, + +/* enum list is exposed, to handle specific errors */ +typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) + _LZ4F_dummy_error_enum_for_c89_never_used } LZ4F_errorCodes; + +LZ4FLIB_STATIC_API LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult); + +/********************************** + * Advanced compression operations + *********************************/ + +/*! LZ4F_getBlockSize() : + * @return, in scalar format (size_t), + * the maximum block size associated with @blockSizeID, + * or an error code (can be tested using LZ4F_isError()) if @blockSizeID is invalid. +**/ +LZ4FLIB_STATIC_API size_t LZ4F_getBlockSize(LZ4F_blockSizeID_t blockSizeID); + +/*! LZ4F_uncompressedUpdate() : + * LZ4F_uncompressedUpdate() can be called repetitively to add data stored as uncompressed blocks. + * Important rule: dstCapacity MUST be large enough to store the entire source buffer as + * no compression is done for this operation + * If this condition is not respected, LZ4F_uncompressedUpdate() will fail (result is an errorCode). + * After an error, the state is left in a UB state, and must be re-initialized or freed. + * If previously a compressed block was written, buffered data is flushed first, + * before appending uncompressed data is continued. + * This operation is only supported when LZ4F_blockIndependent is used. + * `cOptPtr` is optional : NULL can be provided, in which case all options are set to default. + * @return : number of bytes written into `dstBuffer` (it can be zero, meaning input data was just buffered). + * or an error code if it fails (which can be tested using LZ4F_isError()) + */ +LZ4FLIB_STATIC_API size_t +LZ4F_uncompressedUpdate(LZ4F_cctx* cctx, + void* dstBuffer, size_t dstCapacity, + const void* srcBuffer, size_t srcSize, + const LZ4F_compressOptions_t* cOptPtr); + +/********************************** + * Custom memory allocation + *********************************/ + +/*! Custom memory allocation : v1.9.4+ + * These prototypes make it possible to pass custom allocation/free functions. + * LZ4F_customMem is provided at state creation time, using LZ4F_create*_advanced() listed below. + * All allocation/free operations will be completed using these custom variants instead of regular ones. + */ +typedef void* (*LZ4F_AllocFunction) (void* opaqueState, size_t size); +typedef void* (*LZ4F_CallocFunction) (void* opaqueState, size_t size); +typedef void (*LZ4F_FreeFunction) (void* opaqueState, void* address); +typedef struct { + LZ4F_AllocFunction customAlloc; + LZ4F_CallocFunction customCalloc; /* optional; when not defined, uses customAlloc + memset */ + LZ4F_FreeFunction customFree; + void* opaqueState; +} LZ4F_CustomMem; +static +#ifdef __GNUC__ +__attribute__((__unused__)) +#endif +LZ4F_CustomMem const LZ4F_defaultCMem = { NULL, NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */ + +LZ4FLIB_STATIC_API LZ4F_cctx* LZ4F_createCompressionContext_advanced(LZ4F_CustomMem customMem, unsigned version); +LZ4FLIB_STATIC_API LZ4F_dctx* LZ4F_createDecompressionContext_advanced(LZ4F_CustomMem customMem, unsigned version); +LZ4FLIB_STATIC_API LZ4F_CDict* LZ4F_createCDict_advanced(LZ4F_CustomMem customMem, const void* dictBuffer, size_t dictSize); + + +#if defined (__cplusplus) +} +#endif + +#endif /* defined(LZ4F_STATIC_LINKING_ONLY) && !defined(LZ4F_H_STATIC_09782039843) */ diff --git a/illumos-x86_64/usr/include/lz4frame_static.h b/illumos-x86_64/usr/include/lz4frame_static.h new file mode 100644 index 00000000..2b44a631 --- /dev/null +++ b/illumos-x86_64/usr/include/lz4frame_static.h @@ -0,0 +1,47 @@ +/* + LZ4 auto-framing library + Header File for static linking only + Copyright (C) 2011-2020, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - LZ4 source repository : https://github.com/lz4/lz4 + - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +*/ + +#ifndef LZ4FRAME_STATIC_H_0398209384 +#define LZ4FRAME_STATIC_H_0398209384 + +/* The declarations that formerly were made here have been merged into + * lz4frame.h, protected by the LZ4F_STATIC_LINKING_ONLY macro. Going forward, + * it is recommended to simply include that header directly. + */ + +#define LZ4F_STATIC_LINKING_ONLY +#include "lz4frame.h" + +#endif /* LZ4FRAME_STATIC_H_0398209384 */ diff --git a/illumos-x86_64/usr/include/lz4hc.h b/illumos-x86_64/usr/include/lz4hc.h new file mode 100644 index 00000000..992bc8cd --- /dev/null +++ b/illumos-x86_64/usr/include/lz4hc.h @@ -0,0 +1,414 @@ +/* + LZ4 HC - High Compression Mode of LZ4 + Header File + Copyright (C) 2011-2020, Yann Collet. + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - LZ4 source repository : https://github.com/lz4/lz4 + - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +*/ +#ifndef LZ4_HC_H_19834876238432 +#define LZ4_HC_H_19834876238432 + +#if defined (__cplusplus) +extern "C" { +#endif + +/* --- Dependency --- */ +/* note : lz4hc requires lz4.h/lz4.c for compilation */ +#include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */ + + +/* --- Useful constants --- */ +#define LZ4HC_CLEVEL_MIN 2 +#define LZ4HC_CLEVEL_DEFAULT 9 +#define LZ4HC_CLEVEL_OPT_MIN 10 +#define LZ4HC_CLEVEL_MAX 12 + + +/*-************************************ + * Block Compression + **************************************/ +/*! LZ4_compress_HC() : + * Compress data from `src` into `dst`, using the powerful but slower "HC" algorithm. + * `dst` must be already allocated. + * Compression is guaranteed to succeed if `dstCapacity >= LZ4_compressBound(srcSize)` (see "lz4.h") + * Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see "lz4.h") + * `compressionLevel` : any value between 1 and LZ4HC_CLEVEL_MAX will work. + * Values > LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX. + * @return : the number of bytes written into 'dst' + * or 0 if compression fails. + */ +LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel); + + +/* Note : + * Decompression functions are provided within "lz4.h" (BSD license) + */ + + +/*! LZ4_compress_HC_extStateHC() : + * Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`. + * `state` size is provided by LZ4_sizeofStateHC(). + * Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly). + */ +LZ4LIB_API int LZ4_sizeofStateHC(void); +LZ4LIB_API int LZ4_compress_HC_extStateHC(void* stateHC, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); + + +/*! LZ4_compress_HC_destSize() : v1.9.0+ + * Will compress as much data as possible from `src` + * to fit into `targetDstSize` budget. + * Result is provided in 2 parts : + * @return : the number of bytes written into 'dst' (necessarily <= targetDstSize) + * or 0 if compression fails. + * `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src` + */ +LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC, + const char* src, char* dst, + int* srcSizePtr, int targetDstSize, + int compressionLevel); + + +/*-************************************ + * Streaming Compression + * Bufferless synchronous API + **************************************/ + typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */ + +/*! LZ4_createStreamHC() and LZ4_freeStreamHC() : + * These functions create and release memory for LZ4 HC streaming state. + * Newly created states are automatically initialized. + * A same state can be used multiple times consecutively, + * starting with LZ4_resetStreamHC_fast() to start a new stream of blocks. + */ +LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void); +LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr); + +/* + These functions compress data in successive blocks of any size, + using previous blocks as dictionary, to improve compression ratio. + One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks. + There is an exception for ring buffers, which can be smaller than 64 KB. + Ring-buffer scenario is automatically detected and handled within LZ4_compress_HC_continue(). + + Before starting compression, state must be allocated and properly initialized. + LZ4_createStreamHC() does both, though compression level is set to LZ4HC_CLEVEL_DEFAULT. + + Selecting the compression level can be done with LZ4_resetStreamHC_fast() (starts a new stream) + or LZ4_setCompressionLevel() (anytime, between blocks in the same stream) (experimental). + LZ4_resetStreamHC_fast() only works on states which have been properly initialized at least once, + which is automatically the case when state is created using LZ4_createStreamHC(). + + After reset, a first "fictional block" can be designated as initial dictionary, + using LZ4_loadDictHC() (Optional). + Note: In order for LZ4_loadDictHC() to create the correct data structure, + it is essential to set the compression level _before_ loading the dictionary. + + Invoke LZ4_compress_HC_continue() to compress each successive block. + The number of blocks is unlimited. + Previous input blocks, including initial dictionary when present, + must remain accessible and unmodified during compression. + + It's allowed to update compression level anytime between blocks, + using LZ4_setCompressionLevel() (experimental). + + @dst buffer should be sized to handle worst case scenarios + (see LZ4_compressBound(), it ensures compression success). + In case of failure, the API does not guarantee recovery, + so the state _must_ be reset. + To ensure compression success + whenever @dst buffer size cannot be made >= LZ4_compressBound(), + consider using LZ4_compress_HC_continue_destSize(). + + Whenever previous input blocks can't be preserved unmodified in-place during compression of next blocks, + it's possible to copy the last blocks into a more stable memory space, using LZ4_saveDictHC(). + Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer' (<= 64 KB) + + After completing a streaming compression, + it's possible to start a new stream of blocks, using the same LZ4_streamHC_t state, + just by resetting it, using LZ4_resetStreamHC_fast(). +*/ + +LZ4LIB_API void LZ4_resetStreamHC_fast(LZ4_streamHC_t* streamHCPtr, int compressionLevel); /* v1.9.0+ */ +LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize); + +LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, + const char* src, char* dst, + int srcSize, int maxDstSize); + +/*! LZ4_compress_HC_continue_destSize() : v1.9.0+ + * Similar to LZ4_compress_HC_continue(), + * but will read as much data as possible from `src` + * to fit into `targetDstSize` budget. + * Result is provided into 2 parts : + * @return : the number of bytes written into 'dst' (necessarily <= targetDstSize) + * or 0 if compression fails. + * `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`. + * Note that this function may not consume the entire input. + */ +LZ4LIB_API int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr, + const char* src, char* dst, + int* srcSizePtr, int targetDstSize); + +LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize); + + +/*! LZ4_attach_HC_dictionary() : stable since v1.10.0 + * This API allows for the efficient re-use of a static dictionary many times. + * + * Rather than re-loading the dictionary buffer into a working context before + * each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a + * working LZ4_streamHC_t, this function introduces a no-copy setup mechanism, + * in which the working stream references the dictionary stream in-place. + * + * Several assumptions are made about the state of the dictionary stream. + * Currently, only streams which have been prepared by LZ4_loadDictHC() should + * be expected to work. + * + * Alternatively, the provided dictionary stream pointer may be NULL, in which + * case any existing dictionary stream is unset. + * + * A dictionary should only be attached to a stream without any history (i.e., + * a stream that has just been reset). + * + * The dictionary will remain attached to the working stream only for the + * current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the + * dictionary context association from the working stream. The dictionary + * stream (and source buffer) must remain in-place / accessible / unchanged + * through the lifetime of the stream session. + */ +LZ4LIB_API void +LZ4_attach_HC_dictionary(LZ4_streamHC_t* working_stream, + const LZ4_streamHC_t* dictionary_stream); + + +/*^********************************************** + * !!!!!! STATIC LINKING ONLY !!!!!! + ***********************************************/ + +/*-****************************************************************** + * PRIVATE DEFINITIONS : + * Do not use these definitions directly. + * They are merely exposed to allow static allocation of `LZ4_streamHC_t`. + * Declare an `LZ4_streamHC_t` directly, rather than any type below. + * Even then, only do so in the context of static linking, as definitions may change between versions. + ********************************************************************/ + +#define LZ4HC_DICTIONARY_LOGSIZE 16 +#define LZ4HC_MAXD (1<= LZ4HC_CLEVEL_OPT_MIN. + */ +LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed( + LZ4_streamHC_t* LZ4_streamHCPtr, int favor); + +/*! LZ4_resetStreamHC_fast() : v1.9.0+ + * When an LZ4_streamHC_t is known to be in a internally coherent state, + * it can often be prepared for a new compression with almost no work, only + * sometimes falling back to the full, expensive reset that is always required + * when the stream is in an indeterminate state (i.e., the reset performed by + * LZ4_resetStreamHC()). + * + * LZ4_streamHCs are guaranteed to be in a valid state when: + * - returned from LZ4_createStreamHC() + * - reset by LZ4_resetStreamHC() + * - memset(stream, 0, sizeof(LZ4_streamHC_t)) + * - the stream was in a valid state and was reset by LZ4_resetStreamHC_fast() + * - the stream was in a valid state and was then used in any compression call + * that returned success + * - the stream was in an indeterminate state and was used in a compression + * call that fully reset the state (LZ4_compress_HC_extStateHC()) and that + * returned success + * + * Note: + * A stream that was last used in a compression call that returned an error + * may be passed to this function. However, it will be fully reset, which will + * clear any existing history and settings from the context. + */ +LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast( + LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel); + +/*! LZ4_compress_HC_extStateHC_fastReset() : + * A variant of LZ4_compress_HC_extStateHC(). + * + * Using this variant avoids an expensive initialization step. It is only safe + * to call if the state buffer is known to be correctly initialized already + * (see above comment on LZ4_resetStreamHC_fast() for a definition of + * "correctly initialized"). From a high level, the difference is that this + * function initializes the provided state with a call to + * LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a + * call to LZ4_resetStreamHC(). + */ +LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset ( + void* state, + const char* src, char* dst, + int srcSize, int dstCapacity, + int compressionLevel); + +#if defined (__cplusplus) +} +#endif + +#endif /* LZ4_HC_SLO_098092834 */ +#endif /* LZ4_HC_STATIC_LINKING_ONLY */ diff --git a/illumos-x86_64/usr/include/lzlib.h b/illumos-x86_64/usr/include/lzlib.h new file mode 100644 index 00000000..926124a9 --- /dev/null +++ b/illumos-x86_64/usr/include/lzlib.h @@ -0,0 +1,111 @@ +/* Lzlib - Compression library for the lzip format + Copyright (C) 2009-2025 Antonio Diaz Diaz. + + This library is free software. Redistribution and use in source and + binary forms, with or without modification, are permitted provided + that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* LZ_API_VERSION was first defined in lzlib 1.8 to 1. + Since lzlib 1.12, LZ_API_VERSION is defined as (major * 1000 + minor). */ + +#define LZ_API_VERSION 1015 + +static const char * const LZ_version_string = "1.15"; + +typedef enum LZ_Errno + { LZ_ok = 0, LZ_bad_argument, LZ_mem_error, + LZ_sequence_error, LZ_header_error, LZ_unexpected_eof, + LZ_data_error, LZ_library_error } LZ_Errno; + + +int LZ_api_version( void ); /* new in 1.12 */ +const char * LZ_version( void ); +const char * LZ_strerror( const LZ_Errno lz_errno ); + +int LZ_min_dictionary_bits( void ); +int LZ_min_dictionary_size( void ); +int LZ_max_dictionary_bits( void ); +int LZ_max_dictionary_size( void ); +int LZ_min_match_len_limit( void ); +int LZ_max_match_len_limit( void ); + + +/* --------------------- Compression Functions --------------------- */ + +typedef struct LZ_Encoder LZ_Encoder; + +LZ_Encoder * LZ_compress_open( const int dictionary_size, + const int match_len_limit, + const unsigned long long member_size ); +int LZ_compress_close( LZ_Encoder * const encoder ); + +int LZ_compress_finish( LZ_Encoder * const encoder ); +int LZ_compress_restart_member( LZ_Encoder * const encoder, + const unsigned long long member_size ); +int LZ_compress_sync_flush( LZ_Encoder * const encoder ); + +int LZ_compress_read( LZ_Encoder * const encoder, + uint8_t * const buffer, const int size ); +int LZ_compress_write( LZ_Encoder * const encoder, + const uint8_t * const buffer, const int size ); +int LZ_compress_write_size( LZ_Encoder * const encoder ); + +LZ_Errno LZ_compress_errno( LZ_Encoder * const encoder ); +int LZ_compress_finished( LZ_Encoder * const encoder ); +int LZ_compress_member_finished( LZ_Encoder * const encoder ); + +unsigned long long LZ_compress_data_position( LZ_Encoder * const encoder ); +unsigned long long LZ_compress_member_position( LZ_Encoder * const encoder ); +unsigned long long LZ_compress_total_in_size( LZ_Encoder * const encoder ); +unsigned long long LZ_compress_total_out_size( LZ_Encoder * const encoder ); + + +/* -------------------- Decompression Functions -------------------- */ + +typedef struct LZ_Decoder LZ_Decoder; + +LZ_Decoder * LZ_decompress_open( void ); +int LZ_decompress_close( LZ_Decoder * const decoder ); + +int LZ_decompress_finish( LZ_Decoder * const decoder ); +int LZ_decompress_reset( LZ_Decoder * const decoder ); +int LZ_decompress_sync_to_member( LZ_Decoder * const decoder ); + +int LZ_decompress_read( LZ_Decoder * const decoder, + uint8_t * const buffer, const int size ); +int LZ_decompress_write( LZ_Decoder * const decoder, + const uint8_t * const buffer, const int size ); +int LZ_decompress_write_size( LZ_Decoder * const decoder ); + +LZ_Errno LZ_decompress_errno( LZ_Decoder * const decoder ); +int LZ_decompress_finished( LZ_Decoder * const decoder ); +int LZ_decompress_member_finished( LZ_Decoder * const decoder ); + +int LZ_decompress_member_version( LZ_Decoder * const decoder ); +int LZ_decompress_dictionary_size( LZ_Decoder * const decoder ); +unsigned LZ_decompress_data_crc( LZ_Decoder * const decoder ); + +unsigned long long LZ_decompress_data_position( LZ_Decoder * const decoder ); +unsigned long long LZ_decompress_member_position( LZ_Decoder * const decoder ); +unsigned long long LZ_decompress_total_in_size( LZ_Decoder * const decoder ); +unsigned long long LZ_decompress_total_out_size( LZ_Decoder * const decoder ); + +#ifdef __cplusplus +} +#endif diff --git a/illumos-x86_64/usr/include/lzma.h b/illumos-x86_64/usr/include/lzma.h new file mode 100644 index 00000000..6ca6e503 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma.h @@ -0,0 +1,327 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file api/lzma.h + * \brief The public API of liblzma data compression library + * \mainpage + * + * liblzma is a general-purpose data compression library with a zlib-like API. + * The native file format is .xz, but also the old .lzma format and raw (no + * headers) streams are supported. Multiple compression algorithms (filters) + * are supported. Currently LZMA2 is the primary filter. + * + * liblzma is part of XZ Utils . XZ Utils + * includes a gzip-like command line tool named xz and some other tools. + * XZ Utils is developed and maintained by Lasse Collin. + * + * Major parts of liblzma are based on code written by Igor Pavlov, + * specifically the LZMA SDK . + * + * The SHA-256 implementation in liblzma is based on code written by + * Wei Dai in Crypto++ Library . + * + * liblzma is distributed under the BSD Zero Clause License (0BSD). + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H +#define LZMA_H + +/***************************** + * Required standard headers * + *****************************/ + +/* + * liblzma API headers need some standard types and macros. To allow + * including lzma.h without requiring the application to include other + * headers first, lzma.h includes the required standard headers unless + * they already seem to be included already or if LZMA_MANUAL_HEADERS + * has been defined. + * + * Here's what types and macros are needed and from which headers: + * - stddef.h: size_t, NULL + * - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n), + * UINT32_MAX, UINT64_MAX + * + * However, inttypes.h is a little more portable than stdint.h, although + * inttypes.h declares some unneeded things compared to plain stdint.h. + * + * The hacks below aren't perfect, specifically they assume that inttypes.h + * exists and that it typedefs at least uint8_t, uint32_t, and uint64_t, + * and that, in case of incomplete inttypes.h, unsigned int is 32-bit. + * If the application already takes care of setting up all the types and + * macros properly (for example by using gnulib's stdint.h or inttypes.h), + * we try to detect that the macros are already defined and don't include + * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to + * force this file to never include any system headers. + * + * Some could argue that liblzma API should provide all the required types, + * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was + * seen as an unnecessary mess, since most systems already provide all the + * necessary types and macros in the standard headers. + * + * Note that liblzma API still has lzma_bool, because using stdbool.h would + * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't + * necessarily the same as sizeof(bool) in C++. + */ + +#ifndef LZMA_MANUAL_HEADERS + /* + * I suppose this works portably also in C++. Note that in C++, + * we need to get size_t into the global namespace. + */ +# include + + /* + * Skip inttypes.h if we already have all the required macros. If we + * have the macros, we assume that we have the matching typedefs too. + */ +# if !defined(UINT32_C) || !defined(UINT64_C) \ + || !defined(UINT32_MAX) || !defined(UINT64_MAX) + /* + * MSVC versions older than 2013 have no C99 support, and + * thus they cannot be used to compile liblzma. Using an + * existing liblzma.dll with old MSVC can work though(*), + * but we need to define the required standard integer + * types here in a MSVC-specific way. + * + * (*) If you do this, the existing liblzma.dll probably uses + * a different runtime library than your MSVC-built + * application. Mixing runtimes is generally bad, but + * in this case it should work as long as you avoid + * the few rarely-needed liblzma functions that allocate + * memory and expect the caller to free it using free(). + */ +# if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1800 + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + typedef unsigned __int64 uint64_t; +# else + /* Use the standard inttypes.h. */ +# ifdef __cplusplus + /* + * C99 sections 7.18.2 and 7.18.4 specify + * that C++ implementations define the limit + * and constant macros only if specifically + * requested. Note that if you want the + * format macros (PRIu64 etc.) too, you need + * to define __STDC_FORMAT_MACROS before + * including lzma.h, since re-including + * inttypes.h with __STDC_FORMAT_MACROS + * defined doesn't necessarily work. + */ +# ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS 1 +# endif +# ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS 1 +# endif +# endif + +# include +# endif + + /* + * Some old systems have only the typedefs in inttypes.h, and + * lack all the macros. For those systems, we need a few more + * hacks. We assume that unsigned int is 32-bit and unsigned + * long is either 32-bit or 64-bit. If these hacks aren't + * enough, the application has to setup the types manually + * before including lzma.h. + */ +# ifndef UINT32_C +# if defined(_WIN32) && defined(_MSC_VER) +# define UINT32_C(n) n ## UI32 +# else +# define UINT32_C(n) n ## U +# endif +# endif + +# ifndef UINT64_C +# if defined(_WIN32) && defined(_MSC_VER) +# define UINT64_C(n) n ## UI64 +# else + /* Get ULONG_MAX. */ +# include +# if ULONG_MAX == 4294967295UL +# define UINT64_C(n) n ## ULL +# else +# define UINT64_C(n) n ## UL +# endif +# endif +# endif + +# ifndef UINT32_MAX +# define UINT32_MAX (UINT32_C(4294967295)) +# endif + +# ifndef UINT64_MAX +# define UINT64_MAX (UINT64_C(18446744073709551615)) +# endif +# endif +#endif /* ifdef LZMA_MANUAL_HEADERS */ + + +/****************** + * LZMA_API macro * + ******************/ + +/* + * Some systems require that the functions and function pointers are + * declared specially in the headers. LZMA_API_IMPORT is for importing + * symbols and LZMA_API_CALL is to specify the calling convention. + * + * By default it is assumed that the application will link dynamically + * against liblzma. #define LZMA_API_STATIC in your application if you + * want to link against static liblzma. If you don't care about portability + * to operating systems like Windows, or at least don't care about linking + * against static liblzma on them, don't worry about LZMA_API_STATIC. That + * is, most developers will never need to use LZMA_API_STATIC. + * + * The GCC variants are a special case on Windows (Cygwin and MinGW-w64). + * We rely on GCC doing the right thing with its auto-import feature, + * and thus don't use __declspec(dllimport). This way developers don't + * need to worry about LZMA_API_STATIC. Also the calling convention is + * omitted on Cygwin but not on MinGW-w64. + */ +#ifndef LZMA_API_IMPORT +# if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__) +# define LZMA_API_IMPORT __declspec(dllimport) +# else +# define LZMA_API_IMPORT +# endif +#endif + +#ifndef LZMA_API_CALL +# if defined(_WIN32) && !defined(__CYGWIN__) +# define LZMA_API_CALL __cdecl +# else +# define LZMA_API_CALL +# endif +#endif + +#ifndef LZMA_API +# define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL +#endif + + +/*********** + * nothrow * + ***********/ + +/* + * None of the functions in liblzma may throw an exception. Even + * the functions that use callback functions won't throw exceptions, + * because liblzma would break if a callback function threw an exception. + */ +#ifndef lzma_nothrow +# if defined(__cplusplus) +# if __cplusplus >= 201103L || (defined(_MSVC_LANG) \ + && _MSVC_LANG >= 201103L) +# define lzma_nothrow noexcept +# else +# define lzma_nothrow throw() +# endif +# elif defined(__GNUC__) && (__GNUC__ > 3 \ + || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +# define lzma_nothrow __attribute__((__nothrow__)) +# else +# define lzma_nothrow +# endif +#endif + + +/******************** + * GNU C extensions * + ********************/ + +/* + * GNU C extensions are used conditionally in the public API. It doesn't + * break anything if these are sometimes enabled and sometimes not, only + * affects warnings and optimizations. + */ +#if defined(__GNUC__) && __GNUC__ >= 3 +# ifndef lzma_attribute +# define lzma_attribute(attr) __attribute__(attr) +# endif + + /* warn_unused_result was added in GCC 3.4. */ +# ifndef lzma_attr_warn_unused_result +# if __GNUC__ == 3 && __GNUC_MINOR__ < 4 +# define lzma_attr_warn_unused_result +# endif +# endif + +#else +# ifndef lzma_attribute +# define lzma_attribute(attr) +# endif +#endif + + +#ifndef lzma_attr_pure +# define lzma_attr_pure lzma_attribute((__pure__)) +#endif + +#ifndef lzma_attr_const +# define lzma_attr_const lzma_attribute((__const__)) +#endif + +#ifndef lzma_attr_warn_unused_result +# define lzma_attr_warn_unused_result \ + lzma_attribute((__warn_unused_result__)) +#endif + + +/************** + * Subheaders * + **************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Subheaders check that this is defined. It is to prevent including + * them directly from applications. + */ +#define LZMA_H_INTERNAL 1 + +/* Basic features */ +#include "lzma/version.h" +#include "lzma/base.h" +#include "lzma/vli.h" +#include "lzma/check.h" + +/* Filters */ +#include "lzma/filter.h" +#include "lzma/bcj.h" +#include "lzma/delta.h" +#include "lzma/lzma12.h" + +/* Container formats */ +#include "lzma/container.h" + +/* Advanced features */ +#include "lzma/stream_flags.h" +#include "lzma/block.h" +#include "lzma/index.h" +#include "lzma/index_hash.h" + +/* Hardware information */ +#include "lzma/hardware.h" + +/* + * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications + * re-including the subheaders. + */ +#undef LZMA_H_INTERNAL + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef LZMA_H */ diff --git a/illumos-x86_64/usr/include/lzma/base.h b/illumos-x86_64/usr/include/lzma/base.h new file mode 100644 index 00000000..590e1d22 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/base.h @@ -0,0 +1,747 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/base.h + * \brief Data types and functions used in many places in liblzma API + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Boolean + * + * This is here because C89 doesn't have stdbool.h. To set a value for + * variables having type lzma_bool, you can use + * - C99's 'true' and 'false' from stdbool.h; + * - C++'s internal 'true' and 'false'; or + * - integers one (true) and zero (false). + */ +typedef unsigned char lzma_bool; + + +/** + * \brief Type of reserved enumeration variable in structures + * + * To avoid breaking library ABI when new features are added, several + * structures contain extra variables that may be used in future. Since + * sizeof(enum) can be different than sizeof(int), and sizeof(enum) may + * even vary depending on the range of enumeration constants, we specify + * a separate type to be used for reserved enumeration variables. All + * enumeration constants in liblzma API will be non-negative and less + * than 128, which should guarantee that the ABI won't break even when + * new constants are added to existing enumerations. + */ +typedef enum { + LZMA_RESERVED_ENUM = 0 +} lzma_reserved_enum; + + +/** + * \brief Return values used by several functions in liblzma + * + * Check the descriptions of specific functions to find out which return + * values they can return. With some functions the return values may have + * more specific meanings than described here; those differences are + * described per-function basis. + */ +typedef enum { + LZMA_OK = 0, + /**< + * \brief Operation completed successfully + */ + + LZMA_STREAM_END = 1, + /**< + * \brief End of stream was reached + * + * In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or + * LZMA_FINISH was finished. In decoder, this indicates + * that all the data was successfully decoded. + * + * In all cases, when LZMA_STREAM_END is returned, the last + * output bytes should be picked from strm->next_out. + */ + + LZMA_NO_CHECK = 2, + /**< + * \brief Input stream has no integrity check + * + * This return value can be returned only if the + * LZMA_TELL_NO_CHECK flag was used when initializing + * the decoder. LZMA_NO_CHECK is just a warning, and + * the decoding can be continued normally. + * + * It is possible to call lzma_get_check() immediately after + * lzma_code has returned LZMA_NO_CHECK. The result will + * naturally be LZMA_CHECK_NONE, but the possibility to call + * lzma_get_check() may be convenient in some applications. + */ + + LZMA_UNSUPPORTED_CHECK = 3, + /**< + * \brief Cannot calculate the integrity check + * + * The usage of this return value is different in encoders + * and decoders. + * + * Encoders can return this value only from the initialization + * function. If initialization fails with this value, the + * encoding cannot be done, because there's no way to produce + * output with the correct integrity check. + * + * Decoders can return this value only from lzma_code() and + * only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when + * initializing the decoder. The decoding can still be + * continued normally even if the check type is unsupported, + * but naturally the check will not be validated, and possible + * errors may go undetected. + * + * With decoder, it is possible to call lzma_get_check() + * immediately after lzma_code() has returned + * LZMA_UNSUPPORTED_CHECK. This way it is possible to find + * out what the unsupported Check ID was. + */ + + LZMA_GET_CHECK = 4, + /**< + * \brief Integrity check type is now available + * + * This value can be returned only by the lzma_code() function + * and only if the decoder was initialized with the + * LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the + * application that it may now call lzma_get_check() to find + * out the Check ID. This can be used, for example, to + * implement a decoder that accepts only files that have + * strong enough integrity check. + */ + + LZMA_MEM_ERROR = 5, + /**< + * \brief Cannot allocate memory + * + * Memory allocation failed, or the size of the allocation + * would be greater than SIZE_MAX. + * + * Due to internal implementation reasons, the coding cannot + * be continued even if more memory were made available after + * LZMA_MEM_ERROR. + */ + + LZMA_MEMLIMIT_ERROR = 6, + /**< + * \brief Memory usage limit was reached + * + * Decoder would need more memory than allowed by the + * specified memory usage limit. To continue decoding, + * the memory usage limit has to be increased with + * lzma_memlimit_set(). + * + * liblzma 5.2.6 and earlier had a bug in single-threaded .xz + * decoder (lzma_stream_decoder()) which made it impossible + * to continue decoding after LZMA_MEMLIMIT_ERROR even if + * the limit was increased using lzma_memlimit_set(). + * Other decoders worked correctly. + */ + + LZMA_FORMAT_ERROR = 7, + /**< + * \brief File format not recognized + * + * The decoder did not recognize the input as supported file + * format. This error can occur, for example, when trying to + * decode .lzma format file with lzma_stream_decoder, + * because lzma_stream_decoder accepts only the .xz format. + */ + + LZMA_OPTIONS_ERROR = 8, + /**< + * \brief Invalid or unsupported options + * + * Invalid or unsupported options, for example + * - unsupported filter(s) or filter options; or + * - reserved bits set in headers (decoder only). + * + * Rebuilding liblzma with more features enabled, or + * upgrading to a newer version of liblzma may help. + */ + + LZMA_DATA_ERROR = 9, + /**< + * \brief Data is corrupt + * + * The usage of this return value is different in encoders + * and decoders. In both encoder and decoder, the coding + * cannot continue after this error. + * + * Encoders return this if size limits of the target file + * format would be exceeded. These limits are huge, thus + * getting this error from an encoder is mostly theoretical. + * For example, the maximum compressed and uncompressed + * size of a .xz Stream is roughly 8 EiB (2^63 bytes). + * + * Decoders return this error if the input data is corrupt. + * This can mean, for example, invalid CRC32 in headers + * or invalid check of uncompressed data. + */ + + LZMA_BUF_ERROR = 10, + /**< + * \brief No progress is possible + * + * This error code is returned when the coder cannot consume + * any new input and produce any new output. The most common + * reason for this error is that the input stream being + * decoded is truncated or corrupt. + * + * This error is not fatal. Coding can be continued normally + * by providing more input and/or more output space, if + * possible. + * + * Typically the first call to lzma_code() that can do no + * progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only + * the second consecutive call doing no progress will return + * LZMA_BUF_ERROR. This is intentional. + * + * With zlib, Z_BUF_ERROR may be returned even if the + * application is doing nothing wrong, so apps will need + * to handle Z_BUF_ERROR specially. The above hack + * guarantees that liblzma never returns LZMA_BUF_ERROR + * to properly written applications unless the input file + * is truncated or corrupt. This should simplify the + * applications a little. + */ + + LZMA_PROG_ERROR = 11, + /**< + * \brief Programming error + * + * This indicates that the arguments given to the function are + * invalid or the internal state of the decoder is corrupt. + * - Function arguments are invalid or the structures + * pointed by the argument pointers are invalid + * e.g. if strm->next_out has been set to NULL and + * strm->avail_out > 0 when calling lzma_code(). + * - lzma_* functions have been called in wrong order + * e.g. lzma_code() was called right after lzma_end(). + * - If errors occur randomly, the reason might be flaky + * hardware. + * + * If you think that your code is correct, this error code + * can be a sign of a bug in liblzma. See the documentation + * how to report bugs. + */ + + LZMA_SEEK_NEEDED = 12, + /**< + * \brief Request to change the input file position + * + * Some coders can do random access in the input file. The + * initialization functions of these coders take the file size + * as an argument. No other coders can return LZMA_SEEK_NEEDED. + * + * When this value is returned, the application must seek to + * the file position given in lzma_stream.seek_pos. This value + * is guaranteed to never exceed the file size that was + * specified at the coder initialization. + * + * After seeking the application should read new input and + * pass it normally via lzma_stream.next_in and .avail_in. + */ + + /* + * These enumerations may be used internally by liblzma + * but they will never be returned to applications. + */ + LZMA_RET_INTERNAL1 = 101, + LZMA_RET_INTERNAL2 = 102, + LZMA_RET_INTERNAL3 = 103, + LZMA_RET_INTERNAL4 = 104, + LZMA_RET_INTERNAL5 = 105, + LZMA_RET_INTERNAL6 = 106, + LZMA_RET_INTERNAL7 = 107, + LZMA_RET_INTERNAL8 = 108 +} lzma_ret; + + +/** + * \brief The 'action' argument for lzma_code() + * + * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER, + * or LZMA_FINISH, the same 'action' must be used until lzma_code() returns + * LZMA_STREAM_END. Also, the amount of input (that is, strm->avail_in) must + * not be modified by the application until lzma_code() returns + * LZMA_STREAM_END. Changing the 'action' or modifying the amount of input + * will make lzma_code() return LZMA_PROG_ERROR. + */ +typedef enum { + LZMA_RUN = 0, + /**< + * \brief Continue coding + * + * Encoder: Encode as much input as possible. Some internal + * buffering will probably be done (depends on the filter + * chain in use), which causes latency: the input used won't + * usually be decodeable from the output of the same + * lzma_code() call. + * + * Decoder: Decode as much input as possible and produce as + * much output as possible. + */ + + LZMA_SYNC_FLUSH = 1, + /**< + * \brief Make all the input available at output + * + * Normally the encoder introduces some latency. + * LZMA_SYNC_FLUSH forces all the buffered data to be + * available at output without resetting the internal + * state of the encoder. This way it is possible to use + * compressed stream for example for communication over + * network. + * + * Only some filters support LZMA_SYNC_FLUSH. Trying to use + * LZMA_SYNC_FLUSH with filters that don't support it will + * make lzma_code() return LZMA_OPTIONS_ERROR. For example, + * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does. + * + * Using LZMA_SYNC_FLUSH very often can dramatically reduce + * the compression ratio. With some filters (for example, + * LZMA2), fine-tuning the compression options may help + * mitigate this problem significantly (for example, + * match finder with LZMA2). + * + * Decoders don't support LZMA_SYNC_FLUSH. + */ + + LZMA_FULL_FLUSH = 2, + /**< + * \brief Finish encoding of the current Block + * + * All the input data going to the current Block must have + * been given to the encoder (the last bytes can still be + * pending in *next_in). Call lzma_code() with LZMA_FULL_FLUSH + * until it returns LZMA_STREAM_END. Then continue normally + * with LZMA_RUN or finish the Stream with LZMA_FINISH. + * + * This action is currently supported only by Stream encoder + * and easy encoder (which uses Stream encoder). If there is + * no unfinished Block, no empty Block is created. + */ + + LZMA_FULL_BARRIER = 4, + /**< + * \brief Finish encoding of the current Block + * + * This is like LZMA_FULL_FLUSH except that this doesn't + * necessarily wait until all the input has been made + * available via the output buffer. That is, lzma_code() + * might return LZMA_STREAM_END as soon as all the input + * has been consumed (avail_in == 0). + * + * LZMA_FULL_BARRIER is useful with a threaded encoder if + * one wants to split the .xz Stream into Blocks at specific + * offsets but doesn't care if the output isn't flushed + * immediately. Using LZMA_FULL_BARRIER allows keeping + * the threads busy while LZMA_FULL_FLUSH would make + * lzma_code() wait until all the threads have finished + * until more data could be passed to the encoder. + * + * With a lzma_stream initialized with the single-threaded + * lzma_stream_encoder() or lzma_easy_encoder(), + * LZMA_FULL_BARRIER is an alias for LZMA_FULL_FLUSH. + */ + + LZMA_FINISH = 3 + /**< + * \brief Finish the coding operation + * + * All the input data must have been given to the encoder + * (the last bytes can still be pending in next_in). + * Call lzma_code() with LZMA_FINISH until it returns + * LZMA_STREAM_END. Once LZMA_FINISH has been used, + * the amount of input must no longer be changed by + * the application. + * + * When decoding, using LZMA_FINISH is optional unless the + * LZMA_CONCATENATED flag was used when the decoder was + * initialized. When LZMA_CONCATENATED was not used, the only + * effect of LZMA_FINISH is that the amount of input must not + * be changed just like in the encoder. + */ +} lzma_action; + + +/** + * \brief Custom functions for memory handling + * + * A pointer to lzma_allocator may be passed via lzma_stream structure + * to liblzma, and some advanced functions take a pointer to lzma_allocator + * as a separate function argument. The library will use the functions + * specified in lzma_allocator for memory handling instead of the default + * malloc() and free(). C++ users should note that the custom memory + * handling functions must not throw exceptions. + * + * Single-threaded mode only: liblzma doesn't make an internal copy of + * lzma_allocator. Thus, it is OK to change these function pointers in + * the middle of the coding process, but obviously it must be done + * carefully to make sure that the replacement 'free' can deallocate + * memory allocated by the earlier 'alloc' function(s). + * + * Multithreaded mode: liblzma might internally store pointers to the + * lzma_allocator given via the lzma_stream structure. The application + * must not change the allocator pointer in lzma_stream or the contents + * of the pointed lzma_allocator structure until lzma_end() has been used + * to free the memory associated with that lzma_stream. The allocation + * functions might be called simultaneously from multiple threads, and + * thus they must be thread safe. + */ +typedef struct { + /** + * \brief Pointer to a custom memory allocation function + * + * If you don't want a custom allocator, but still want + * custom free(), set this to NULL and liblzma will use + * the standard malloc(). + * + * \param opaque lzma_allocator.opaque (see below) + * \param nmemb Number of elements like in calloc(). liblzma + * will always set nmemb to 1, so it is safe to + * ignore nmemb in a custom allocator if you like. + * The nmemb argument exists only for + * compatibility with zlib and libbzip2. + * \param size Size of an element in bytes. + * liblzma never sets this to zero. + * + * \return Pointer to the beginning of a memory block of + * 'size' bytes, or NULL if allocation fails + * for some reason. When allocation fails, functions + * of liblzma return LZMA_MEM_ERROR. + * + * The allocator should not waste time zeroing the allocated buffers. + * This is not only about speed, but also memory usage, since the + * operating system kernel doesn't necessarily allocate the requested + * memory in physical memory until it is actually used. With small + * input files, liblzma may actually need only a fraction of the + * memory that it requested for allocation. + * + * \note LZMA_MEM_ERROR is also used when the size of the + * allocation would be greater than SIZE_MAX. Thus, + * don't assume that the custom allocator must have + * returned NULL if some function from liblzma + * returns LZMA_MEM_ERROR. + */ + void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size); + + /** + * \brief Pointer to a custom memory freeing function + * + * If you don't want a custom freeing function, but still + * want a custom allocator, set this to NULL and liblzma + * will use the standard free(). + * + * \param opaque lzma_allocator.opaque (see below) + * \param ptr Pointer returned by lzma_allocator.alloc(), + * or when it is set to NULL, a pointer returned + * by the standard malloc(). + */ + void (LZMA_API_CALL *free)(void *opaque, void *ptr); + + /** + * \brief Pointer passed to .alloc() and .free() + * + * opaque is passed as the first argument to lzma_allocator.alloc() + * and lzma_allocator.free(). This intended to ease implementing + * custom memory allocation functions for use with liblzma. + * + * If you don't need this, you should set this to NULL. + */ + void *opaque; + +} lzma_allocator; + + +/** + * \brief Internal data structure + * + * The contents of this structure is not visible outside the library. + */ +typedef struct lzma_internal_s lzma_internal; + + +/** + * \brief Passing data to and from liblzma + * + * The lzma_stream structure is used for + * - passing pointers to input and output buffers to liblzma; + * - defining custom memory handler functions; and + * - holding a pointer to coder-specific internal data structures. + * + * Typical usage: + * + * - After allocating lzma_stream (on stack or with malloc()), it must be + * initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details). + * + * - Initialize a coder to the lzma_stream, for example by using + * lzma_easy_encoder() or lzma_auto_decoder(). Some notes: + * - In contrast to zlib, strm->next_in and strm->next_out are + * ignored by all initialization functions, thus it is safe + * to not initialize them yet. + * - The initialization functions always set strm->total_in and + * strm->total_out to zero. + * - If the initialization function fails, no memory is left allocated + * that would require freeing with lzma_end() even if some memory was + * associated with the lzma_stream structure when the initialization + * function was called. + * + * - Use lzma_code() to do the actual work. + * + * - Once the coding has been finished, the existing lzma_stream can be + * reused. It is OK to reuse lzma_stream with different initialization + * function without calling lzma_end() first. Old allocations are + * automatically freed. + * + * - Finally, use lzma_end() to free the allocated memory. lzma_end() never + * frees the lzma_stream structure itself. + * + * Application may modify the values of total_in and total_out as it wants. + * They are updated by liblzma to match the amount of data read and + * written but aren't used for anything else except as a possible return + * values from lzma_get_progress(). + */ +typedef struct { + const uint8_t *next_in; /**< Pointer to the next input byte. */ + size_t avail_in; /**< Number of available input bytes in next_in. */ + uint64_t total_in; /**< Total number of bytes read by liblzma. */ + + uint8_t *next_out; /**< Pointer to the next output position. */ + size_t avail_out; /**< Amount of free space in next_out. */ + uint64_t total_out; /**< Total number of bytes written by liblzma. */ + + /** + * \brief Custom memory allocation functions + * + * In most cases this is NULL which makes liblzma use + * the standard malloc() and free(). + * + * \note In 5.0.x this is not a const pointer. + */ + const lzma_allocator *allocator; + + /** Internal state is not visible to applications. */ + lzma_internal *internal; + + /* + * Reserved space to allow possible future extensions without + * breaking the ABI. Excluding the initialization of this structure, + * you should not touch these, because the names of these variables + * may change. + */ + + /** \private Reserved member. */ + void *reserved_ptr1; + + /** \private Reserved member. */ + void *reserved_ptr2; + + /** \private Reserved member. */ + void *reserved_ptr3; + + /** \private Reserved member. */ + void *reserved_ptr4; + + /** + * \brief New seek input position for LZMA_SEEK_NEEDED + * + * When lzma_code() returns LZMA_SEEK_NEEDED, the new input position + * needed by liblzma will be available seek_pos. The value is + * guaranteed to not exceed the file size that was specified when + * this lzma_stream was initialized. + * + * In all other situations the value of this variable is undefined. + */ + uint64_t seek_pos; + + /** \private Reserved member. */ + uint64_t reserved_int2; + + /** \private Reserved member. */ + size_t reserved_int3; + + /** \private Reserved member. */ + size_t reserved_int4; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum2; + +} lzma_stream; + + +/** + * \brief Initialization for lzma_stream + * + * When you declare an instance of lzma_stream, you can immediately + * initialize it so that initialization functions know that no memory + * has been allocated yet: + * + * lzma_stream strm = LZMA_STREAM_INIT; + * + * If you need to initialize a dynamically allocated lzma_stream, you can use + * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this + * violates the C standard since NULL may have different internal + * representation than zero, but it should be portable enough in practice. + * Anyway, for maximum portability, you can use something like this: + * + * lzma_stream tmp = LZMA_STREAM_INIT; + * *strm = tmp; + */ +#define LZMA_STREAM_INIT \ + { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \ + NULL, NULL, NULL, NULL, 0, 0, 0, 0, \ + LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM } + + +/** + * \brief Encode or decode data + * + * Once the lzma_stream has been successfully initialized (e.g. with + * lzma_stream_encoder()), the actual encoding or decoding is done + * using this function. The application has to update strm->next_in, + * strm->avail_in, strm->next_out, and strm->avail_out to pass input + * to and get output from liblzma. + * + * See the description of the coder-specific initialization function to find + * out what 'action' values are supported by the coder. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param action Action for this function to take. Must be a valid + * lzma_action enum value. + * + * \return Any valid lzma_ret. See the lzma_ret enum description for more + * information. + */ +extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Free memory allocated for the coder data structures + * + * After lzma_end(strm), strm->internal is guaranteed to be NULL. No other + * members of the lzma_stream structure are touched. + * + * \note zlib indicates an error if application end()s unfinished + * stream structure. liblzma doesn't do this, and assumes that + * application knows what it is doing. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + */ +extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow; + + +/** + * \brief Get progress information + * + * In single-threaded mode, applications can get progress information from + * strm->total_in and strm->total_out. In multi-threaded mode this is less + * useful because a significant amount of both input and output data gets + * buffered internally by liblzma. This makes total_in and total_out give + * misleading information and also makes the progress indicator updates + * non-smooth. + * + * This function gives realistic progress information also in multi-threaded + * mode by taking into account the progress made by each thread. In + * single-threaded mode *progress_in and *progress_out are set to + * strm->total_in and strm->total_out, respectively. + * + * \param strm Pointer to lzma_stream that is at least + * initialized with LZMA_STREAM_INIT. + * \param[out] progress_in Pointer to the number of input bytes processed. + * \param[out] progress_out Pointer to the number of output bytes processed. + */ +extern LZMA_API(void) lzma_get_progress(lzma_stream *strm, + uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow; + + +/** + * \brief Get the memory usage of decoder filter chain + * + * This function is currently supported only when *strm has been initialized + * with a function that takes a memlimit argument. With other functions, you + * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage() + * to estimate the memory requirements. + * + * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big + * the memory usage limit should have been to decode the input. Note that + * this may give misleading information if decoding .xz Streams that have + * multiple Blocks, because each Block can have different memory requirements. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * + * \return How much memory is currently allocated for the filter + * decoders. If no filter chain is currently allocated, + * some non-zero value is still returned, which is less than + * or equal to what any filter chain would indicate as its + * memory requirement. + * + * If this function isn't supported by *strm or some other error + * occurs, zero is returned. + */ +extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Get the current memory usage limit + * + * This function is supported only when *strm has been initialized with + * a function that takes a memlimit argument. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * + * \return On success, the current memory usage limit is returned + * (always non-zero). On error, zero is returned. + */ +extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Set the memory usage limit + * + * This function is supported only when *strm has been initialized with + * a function that takes a memlimit argument. + * + * liblzma 5.2.3 and earlier has a bug where memlimit value of 0 causes + * this function to do nothing (leaving the limit unchanged) and still + * return LZMA_OK. Later versions treat 0 as if 1 had been specified (so + * lzma_memlimit_get() will return 1 even if you specify 0 here). + * + * liblzma 5.2.6 and earlier had a bug in single-threaded .xz decoder + * (lzma_stream_decoder()) which made it impossible to continue decoding + * after LZMA_MEMLIMIT_ERROR even if the limit was increased using + * lzma_memlimit_set(). Other decoders worked correctly. + * + * \return Possible lzma_ret values: + * - LZMA_OK: New memory usage limit successfully set. + * - LZMA_MEMLIMIT_ERROR: The new limit is too small. + * The limit was not changed. + * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't + * support memory usage limit. + */ +extern LZMA_API(lzma_ret) lzma_memlimit_set( + lzma_stream *strm, uint64_t memlimit) lzma_nothrow; diff --git a/illumos-x86_64/usr/include/lzma/bcj.h b/illumos-x86_64/usr/include/lzma/bcj.h new file mode 100644 index 00000000..fb737cbb --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/bcj.h @@ -0,0 +1,195 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/bcj.h + * \brief Branch/Call/Jump conversion filters + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/* Filter IDs for lzma_filter.id */ + +/** + * \brief Filter for x86 binaries + */ +#define LZMA_FILTER_X86 LZMA_VLI_C(0x04) + +/** + * \brief Filter for Big endian PowerPC binaries + */ +#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05) + +/** + * \brief Filter for IA-64 (Itanium) binaries + */ +#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06) + +/** + * \brief Filter for ARM binaries + */ +#define LZMA_FILTER_ARM LZMA_VLI_C(0x07) + +/** + * \brief Filter for ARM-Thumb binaries + */ +#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08) + +/** + * \brief Filter for SPARC binaries + */ +#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09) + +/** + * \brief Filter for ARM64 binaries + */ +#define LZMA_FILTER_ARM64 LZMA_VLI_C(0x0A) + +/** + * \brief Filter for RISC-V binaries + */ +#define LZMA_FILTER_RISCV LZMA_VLI_C(0x0B) + + +/** + * \brief Options for BCJ filters + * + * The BCJ filters never change the size of the data. Specifying options + * for them is optional: if pointer to options is NULL, default value is + * used. You probably never need to specify options to BCJ filters, so just + * set the options pointer to NULL and be happy. + * + * If options with non-default values have been specified when encoding, + * the same options must also be specified when decoding. + * + * \note At the moment, none of the BCJ filters support + * LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified, + * LZMA_OPTIONS_ERROR will be returned. If there is need, + * partial support for LZMA_SYNC_FLUSH can be added in future. + * Partial means that flushing would be possible only at + * offsets that are multiple of 2, 4, or 16 depending on + * the filter, except x86 which cannot be made to support + * LZMA_SYNC_FLUSH predictably. + */ +typedef struct { + /** + * \brief Start offset for conversions + * + * This setting is useful only when the same filter is used + * _separately_ for multiple sections of the same executable file, + * and the sections contain cross-section branch/call/jump + * instructions. In that case it is beneficial to set the start + * offset of the non-first sections so that the relative addresses + * of the cross-section branch/call/jump instructions will use the + * same absolute addresses as in the first section. + * + * When the pointer to options is NULL, the default value (zero) + * is used. + */ + uint32_t start_offset; + +} lzma_options_bcj; + + +/** + * \brief Raw ARM64 BCJ encoder + * + * This is for special use cases only. + * + * \param start_offset The lowest 32 bits of the offset in the + * executable being filtered. For the ARM64 + * filter, this must be a multiple of four. + * For the very best results, this should also + * be in sync with 4096-byte page boundaries + * in the executable due to how ARM64's ADRP + * instruction works. + * \param buf Buffer to be filtered in place + * \param size Size of the buffer + * + * \return Number of bytes that were processed in `buf`. This is at most + * `size`. With the ARM64 filter, the return value is always + * a multiple of 4, and at most 3 bytes are left unfiltered. + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_arm64_encode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + +/** + * \brief Raw ARM64 BCJ decoder + * + * See lzma_bcj_arm64_encode(). + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_arm64_decode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + + +/** + * \brief Raw RISC-V BCJ encoder + * + * This is for special use cases only. + * + * \param start_offset The lowest 32 bits of the offset in the + * executable being filtered. For the RISC-V + * filter, this must be a multiple of 2. + * \param buf Buffer to be filtered in place + * \param size Size of the buffer + * + * \return Number of bytes that were processed in `buf`. This is at most + * `size`. With the RISC-V filter, the return value is always + * a multiple of 2, and at most 7 bytes are left unfiltered. + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_riscv_encode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + +/** + * \brief Raw RISC-V BCJ decoder + * + * See lzma_bcj_riscv_encode(). + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_riscv_decode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + + +/** + * \brief Raw x86 BCJ encoder + * + * This is for special use cases only. + * + * \param start_offset The lowest 32 bits of the offset in the + * executable being filtered. For the x86 + * filter, all values are valid. + * \param buf Buffer to be filtered in place + * \param size Size of the buffer + * + * \return Number of bytes that were processed in `buf`. This is at most + * `size`. For the x86 filter, the return value is always + * a multiple of 1, and at most 4 bytes are left unfiltered. + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_x86_encode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + +/** + * \brief Raw x86 BCJ decoder + * + * See lzma_bcj_x86_encode(). + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_x86_decode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; diff --git a/illumos-x86_64/usr/include/lzma/block.h b/illumos-x86_64/usr/include/lzma/block.h new file mode 100644 index 00000000..05b77e59 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/block.h @@ -0,0 +1,694 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/block.h + * \brief .xz Block handling + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Options for the Block and Block Header encoders and decoders + * + * Different Block handling functions use different parts of this structure. + * Some read some members, other functions write, and some do both. Only the + * members listed for reading need to be initialized when the specified + * functions are called. The members marked for writing will be assigned + * new values at some point either by calling the given function or by + * later calls to lzma_code(). + */ +typedef struct { + /** + * \brief Block format version + * + * To prevent API and ABI breakages when new features are needed, + * a version number is used to indicate which members in this + * structure are in use: + * - liblzma >= 5.0.0: version = 0 is supported. + * - liblzma >= 5.1.4beta: Support for version = 1 was added, + * which adds the ignore_check member. + * + * If version is greater than one, most Block related functions + * will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works + * with any version value). + * + * Read by: + * - lzma_block_header_size() + * - lzma_block_header_encode() + * - lzma_block_header_decode() + * - lzma_block_compressed_size() + * - lzma_block_unpadded_size() + * - lzma_block_total_size() + * - lzma_block_encoder() + * - lzma_block_decoder() + * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() + * - lzma_block_buffer_decode() + * + * Written by: + * - lzma_block_header_decode() + */ + uint32_t version; + + /** + * \brief Size of the Block Header field in bytes + * + * This is always a multiple of four. + * + * Read by: + * - lzma_block_header_encode() + * - lzma_block_header_decode() + * - lzma_block_compressed_size() + * - lzma_block_unpadded_size() + * - lzma_block_total_size() + * - lzma_block_decoder() + * - lzma_block_buffer_decode() + * + * Written by: + * - lzma_block_header_size() + * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() + */ + uint32_t header_size; +# define LZMA_BLOCK_HEADER_SIZE_MIN 8 +# define LZMA_BLOCK_HEADER_SIZE_MAX 1024 + + /** + * \brief Type of integrity Check + * + * The Check ID is not stored into the Block Header, thus its value + * must be provided also when decoding. + * + * Read by: + * - lzma_block_header_encode() + * - lzma_block_header_decode() + * - lzma_block_compressed_size() + * - lzma_block_unpadded_size() + * - lzma_block_total_size() + * - lzma_block_encoder() + * - lzma_block_decoder() + * - lzma_block_buffer_encode() + * - lzma_block_buffer_decode() + */ + lzma_check check; + + /** + * \brief Size of the Compressed Data in bytes + * + * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder + * will store this value to the Block Header. Block encoder doesn't + * care about this value, but will set it once the encoding has been + * finished. + * + * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will + * verify that the size of the Compressed Data field matches + * compressed_size. + * + * Usually you don't know this value when encoding in streamed mode, + * and thus cannot write this field into the Block Header. + * + * In non-streamed mode you can reserve space for this field before + * encoding the actual Block. After encoding the data, finish the + * Block by encoding the Block Header. Steps in detail: + * + * - Set compressed_size to some big enough value. If you don't know + * better, use LZMA_VLI_MAX, but remember that bigger values take + * more space in Block Header. + * + * - Call lzma_block_header_size() to see how much space you need to + * reserve for the Block Header. + * + * - Encode the Block using lzma_block_encoder() and lzma_code(). + * It sets compressed_size to the correct value. + * + * - Use lzma_block_header_encode() to encode the Block Header. + * Because space was reserved in the first step, you don't need + * to call lzma_block_header_size() anymore, because due to + * reserving, header_size has to be big enough. If it is "too big", + * lzma_block_header_encode() will add enough Header Padding to + * make Block Header to match the size specified by header_size. + * + * Read by: + * - lzma_block_header_size() + * - lzma_block_header_encode() + * - lzma_block_compressed_size() + * - lzma_block_unpadded_size() + * - lzma_block_total_size() + * - lzma_block_decoder() + * - lzma_block_buffer_decode() + * + * Written by: + * - lzma_block_header_decode() + * - lzma_block_compressed_size() + * - lzma_block_encoder() + * - lzma_block_decoder() + * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() + * - lzma_block_buffer_decode() + */ + lzma_vli compressed_size; + + /** + * \brief Uncompressed Size in bytes + * + * This is handled very similarly to compressed_size above. + * + * uncompressed_size is needed by fewer functions than + * compressed_size. This is because uncompressed_size isn't + * needed to validate that Block stays within proper limits. + * + * Read by: + * - lzma_block_header_size() + * - lzma_block_header_encode() + * - lzma_block_decoder() + * - lzma_block_buffer_decode() + * + * Written by: + * - lzma_block_header_decode() + * - lzma_block_encoder() + * - lzma_block_decoder() + * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() + * - lzma_block_buffer_decode() + */ + lzma_vli uncompressed_size; + + /** + * \brief Array of filters + * + * There can be 1-4 filters. The end of the array is marked with + * .id = LZMA_VLI_UNKNOWN. + * + * Read by: + * - lzma_block_header_size() + * - lzma_block_header_encode() + * - lzma_block_encoder() + * - lzma_block_decoder() + * - lzma_block_buffer_encode() + * - lzma_block_buffer_decode() + * + * Written by: + * - lzma_block_header_decode(): Note that this does NOT free() + * the old filter options structures. All unused filters[] will + * have .id == LZMA_VLI_UNKNOWN and .options == NULL. If + * decoding fails, all filters[] are guaranteed to be + * LZMA_VLI_UNKNOWN and NULL. + * + * \note Because of the array is terminated with + * .id = LZMA_VLI_UNKNOWN, the actual array must + * have LZMA_FILTERS_MAX + 1 members or the Block + * Header decoder will overflow the buffer. + */ + lzma_filter *filters; + + /** + * \brief Raw value stored in the Check field + * + * After successful coding, the first lzma_check_size(check) bytes + * of this array contain the raw value stored in the Check field. + * + * Note that CRC32 and CRC64 are stored in little endian byte order. + * Take it into account if you display the Check values to the user. + * + * Written by: + * - lzma_block_encoder() + * - lzma_block_decoder() + * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() + * - lzma_block_buffer_decode() + */ + uint8_t raw_check[LZMA_CHECK_SIZE_MAX]; + + /* + * Reserved space to allow possible future extensions without + * breaking the ABI. You should not touch these, because the names + * of these variables may change. These are and will never be used + * with the currently supported options, so it is safe to leave these + * uninitialized. + */ + + /** \private Reserved member. */ + void *reserved_ptr1; + + /** \private Reserved member. */ + void *reserved_ptr2; + + /** \private Reserved member. */ + void *reserved_ptr3; + + /** \private Reserved member. */ + uint32_t reserved_int1; + + /** \private Reserved member. */ + uint32_t reserved_int2; + + /** \private Reserved member. */ + lzma_vli reserved_int3; + + /** \private Reserved member. */ + lzma_vli reserved_int4; + + /** \private Reserved member. */ + lzma_vli reserved_int5; + + /** \private Reserved member. */ + lzma_vli reserved_int6; + + /** \private Reserved member. */ + lzma_vli reserved_int7; + + /** \private Reserved member. */ + lzma_vli reserved_int8; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum2; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum3; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum4; + + /** + * \brief A flag to Block decoder to not verify the Check field + * + * This member is supported by liblzma >= 5.1.4beta if .version >= 1. + * + * If this is set to true, the integrity check won't be calculated + * and verified. Unless you know what you are doing, you should + * leave this to false. (A reason to set this to true is when the + * file integrity is verified externally anyway and you want to + * speed up the decompression, which matters mostly when using + * SHA-256 as the integrity check.) + * + * If .version >= 1, read by: + * - lzma_block_decoder() + * - lzma_block_buffer_decode() + * + * Written by (.version is ignored): + * - lzma_block_header_decode() always sets this to false + */ + lzma_bool ignore_check; + + /** \private Reserved member. */ + lzma_bool reserved_bool2; + + /** \private Reserved member. */ + lzma_bool reserved_bool3; + + /** \private Reserved member. */ + lzma_bool reserved_bool4; + + /** \private Reserved member. */ + lzma_bool reserved_bool5; + + /** \private Reserved member. */ + lzma_bool reserved_bool6; + + /** \private Reserved member. */ + lzma_bool reserved_bool7; + + /** \private Reserved member. */ + lzma_bool reserved_bool8; + +} lzma_block; + + +/** + * \brief Decode the Block Header Size field + * + * To decode Block Header using lzma_block_header_decode(), the size of the + * Block Header has to be known and stored into lzma_block.header_size. + * The size can be calculated from the first byte of a Block using this macro. + * Note that if the first byte is 0x00, it indicates beginning of Index; use + * this macro only when the byte is not 0x00. + * + * There is no encoding macro because lzma_block_header_size() and + * lzma_block_header_encode() should be used. + */ +#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4) + + +/** + * \brief Calculate Block Header Size + * + * Calculate the minimum size needed for the Block Header field using the + * settings specified in the lzma_block structure. Note that it is OK to + * increase the calculated header_size value as long as it is a multiple of + * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size + * just means that lzma_block_header_encode() will add Header Padding. + * + * \note This doesn't check that all the options are valid i.e. this + * may return LZMA_OK even if lzma_block_header_encode() or + * lzma_block_encoder() would fail. If you want to validate the + * filter chain, consider using lzma_memlimit_encoder() which as + * a side-effect validates the filter chain. + * + * \param block Block options + * + * \return Possible lzma_ret values: + * - LZMA_OK: Size calculated successfully and stored to + * block->header_size. + * - LZMA_OPTIONS_ERROR: Unsupported version, filters or + * filter options. + * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0. + */ +extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Encode Block Header + * + * The caller must have calculated the size of the Block Header already with + * lzma_block_header_size(). If a value larger than the one calculated by + * lzma_block_header_size() is used, the Block Header will be padded to the + * specified size. + * + * \param block Block options to be encoded. + * \param[out] out Beginning of the output buffer. This must be + * at least block->header_size bytes. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. block->header_size + * bytes were written to output buffer. + * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. + * - LZMA_PROG_ERROR: Invalid arguments, for example + * block->header_size is invalid or block->filters is NULL. + */ +extern LZMA_API(lzma_ret) lzma_block_header_encode( + const lzma_block *block, uint8_t *out) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Decode Block Header + * + * block->version should (usually) be set to the highest value supported + * by the application. If the application sets block->version to a value + * higher than supported by the current liblzma version, this function will + * downgrade block->version to the highest value supported by it. Thus one + * should check the value of block->version after calling this function if + * block->version was set to a non-zero value and the application doesn't + * otherwise know that the liblzma version being used is new enough to + * support the specified block->version. + * + * The size of the Block Header must have already been decoded with + * lzma_block_header_size_decode() macro and stored to block->header_size. + * + * The integrity check type from Stream Header must have been stored + * to block->check. + * + * block->filters must have been allocated, but they don't need to be + * initialized (possible existing filter options are not freed). + * + * \param[out] block Destination for Block options + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() (and also free() + * if an error occurs). + * \param in Beginning of the input buffer. This must be + * at least block->header_size bytes. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. block->header_size + * bytes were read from the input buffer. + * - LZMA_OPTIONS_ERROR: The Block Header specifies some + * unsupported options such as unsupported filters. This can + * happen also if block->version was set to a too low value + * compared to what would be required to properly represent + * the information stored in the Block Header. + * - LZMA_DATA_ERROR: Block Header is corrupt, for example, + * the CRC32 doesn't match. + * - LZMA_PROG_ERROR: Invalid arguments, for example + * block->header_size is invalid or block->filters is NULL. + */ +extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block, + const lzma_allocator *allocator, const uint8_t *in) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Validate and set Compressed Size according to Unpadded Size + * + * Block Header stores Compressed Size, but Index has Unpadded Size. If the + * application has already parsed the Index and is now decoding Blocks, + * it can calculate Compressed Size from Unpadded Size. This function does + * exactly that with error checking: + * + * - Compressed Size calculated from Unpadded Size must be positive integer, + * that is, Unpadded Size must be big enough that after Block Header and + * Check fields there's still at least one byte for Compressed Size. + * + * - If Compressed Size was present in Block Header, the new value + * calculated from Unpadded Size is compared against the value + * from Block Header. + * + * \note This function must be called _after_ decoding the Block Header + * field so that it can properly validate Compressed Size if it + * was present in Block Header. + * + * \param block Block options: block->header_size must + * already be set with lzma_block_header_size(). + * \param unpadded_size Unpadded Size from the Index field in bytes + * + * \return Possible lzma_ret values: + * - LZMA_OK: block->compressed_size was set successfully. + * - LZMA_DATA_ERROR: unpadded_size is too small compared to + * block->header_size and lzma_check_size(block->check). + * - LZMA_PROG_ERROR: Some values are invalid. For example, + * block->header_size must be a multiple of four and + * between 8 and 1024 inclusive. + */ +extern LZMA_API(lzma_ret) lzma_block_compressed_size( + lzma_block *block, lzma_vli unpadded_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Calculate Unpadded Size + * + * The Index field stores Unpadded Size and Uncompressed Size. The latter + * can be taken directly from the lzma_block structure after coding a Block, + * but Unpadded Size needs to be calculated from Block Header Size, + * Compressed Size, and size of the Check field. This is where this function + * is needed. + * + * \param block Block options: block->header_size must already be + * set with lzma_block_header_size(). + * + * \return Unpadded Size on success, or zero on error. + */ +extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Calculate the total encoded size of a Block + * + * This is equivalent to lzma_block_unpadded_size() except that the returned + * value includes the size of the Block Padding field. + * + * \param block Block options: block->header_size must already be + * set with lzma_block_header_size(). + * + * \return On success, total encoded size of the Block. On error, + * zero is returned. + */ +extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Initialize .xz Block encoder + * + * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the + * filter chain supports it), and LZMA_FINISH. + * + * The Block encoder encodes the Block Data, Block Padding, and Check value. + * It does NOT encode the Block Header which can be encoded with + * lzma_block_header_encode(). + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param block Block options: block->version, block->check, + * and block->filters must have been initialized. + * + * \return Possible lzma_ret values: + * - LZMA_OK: All good, continue with lzma_code(). + * - LZMA_MEM_ERROR + * - LZMA_OPTIONS_ERROR + * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID + * that is not supported by this build of liblzma. Initializing + * the encoder failed. + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_block_encoder( + lzma_stream *strm, lzma_block *block) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Initialize .xz Block decoder + * + * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using + * LZMA_FINISH is not required. It is supported only for convenience. + * + * The Block decoder decodes the Block Data, Block Padding, and Check value. + * It does NOT decode the Block Header which can be decoded with + * lzma_block_header_decode(). + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param block Block options + * + * \return Possible lzma_ret values: + * - LZMA_OK: All good, continue with lzma_code(). + * - LZMA_PROG_ERROR + * - LZMA_MEM_ERROR + */ +extern LZMA_API(lzma_ret) lzma_block_decoder( + lzma_stream *strm, lzma_block *block) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Calculate maximum output size for single-call Block encoding + * + * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. + * See the documentation of lzma_stream_buffer_bound(). + * + * \param uncompressed_size Size of the data to be encoded with the + * single-call Block encoder. + * + * \return Maximum output size in bytes for single-call Block encoding. + */ +extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size) + lzma_nothrow; + + +/** + * \brief Single-call .xz Block encoder + * + * In contrast to the multi-call encoder initialized with + * lzma_block_encoder(), this function encodes also the Block Header. This + * is required to make it possible to write appropriate Block Header also + * in case the data isn't compressible, and different filter chain has to be + * used to encode the data in uncompressed form using uncompressed chunks + * of the LZMA2 filter. + * + * When the data isn't compressible, header_size, compressed_size, and + * uncompressed_size are set just like when the data was compressible, but + * it is possible that header_size is too small to hold the filter chain + * specified in block->filters, because that isn't necessarily the filter + * chain that was actually used to encode the data. lzma_block_unpadded_size() + * still works normally, because it doesn't read the filters array. + * + * \param block Block options: block->version, block->check, + * and block->filters must have been initialized. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param in_size Size of the input buffer + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_BUF_ERROR: Not enough output buffer space. + * - LZMA_UNSUPPORTED_CHECK + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_block_buffer_encode( + lzma_block *block, const lzma_allocator *allocator, + const uint8_t *in, size_t in_size, + uint8_t *out, size_t *out_pos, size_t out_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Single-call uncompressed .xz Block encoder + * + * This is like lzma_block_buffer_encode() except this doesn't try to + * compress the data and instead encodes the data using LZMA2 uncompressed + * chunks. The required output buffer size can be determined with + * lzma_block_buffer_bound(). + * + * Since the data won't be compressed, this function ignores block->filters. + * This function doesn't take lzma_allocator because this function doesn't + * allocate any memory from the heap. + * + * \param block Block options: block->version, block->check, + * and block->filters must have been initialized. + * \param in Beginning of the input buffer + * \param in_size Size of the input buffer + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_BUF_ERROR: Not enough output buffer space. + * - LZMA_UNSUPPORTED_CHECK + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block, + const uint8_t *in, size_t in_size, + uint8_t *out, size_t *out_pos, size_t out_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Single-call .xz Block decoder + * + * This is single-call equivalent of lzma_block_decoder(), and requires that + * the caller has already decoded Block Header and checked its memory usage. + * + * \param block Block options + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param in_pos The next byte will be read from in[*in_pos]. + * *in_pos is updated only if decoding succeeds. + * \param in_size Size of the input buffer; the first byte that + * won't be read is in[in_size]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. + * - LZMA_OPTIONS_ERROR + * - LZMA_DATA_ERROR + * - LZMA_MEM_ERROR + * - LZMA_BUF_ERROR: Output buffer was too small. + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_block_buffer_decode( + lzma_block *block, const lzma_allocator *allocator, + const uint8_t *in, size_t *in_pos, size_t in_size, + uint8_t *out, size_t *out_pos, size_t out_size) + lzma_nothrow; diff --git a/illumos-x86_64/usr/include/lzma/check.h b/illumos-x86_64/usr/include/lzma/check.h new file mode 100644 index 00000000..e7a50ed3 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/check.h @@ -0,0 +1,163 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/check.h + * \brief Integrity checks + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Type of the integrity check (Check ID) + * + * The .xz format supports multiple types of checks that are calculated + * from the uncompressed data. They vary in both speed and ability to + * detect errors. + */ +typedef enum { + LZMA_CHECK_NONE = 0, + /**< + * No Check is calculated. + * + * Size of the Check field: 0 bytes + */ + + LZMA_CHECK_CRC32 = 1, + /**< + * CRC32 using the polynomial from the IEEE 802.3 standard + * + * Size of the Check field: 4 bytes + */ + + LZMA_CHECK_CRC64 = 4, + /**< + * CRC64 using the polynomial from the ECMA-182 standard + * + * Size of the Check field: 8 bytes + */ + + LZMA_CHECK_SHA256 = 10 + /**< + * SHA-256 + * + * Size of the Check field: 32 bytes + */ +} lzma_check; + + +/** + * \brief Maximum valid Check ID + * + * The .xz file format specification specifies 16 Check IDs (0-15). Some + * of them are only reserved, that is, no actual Check algorithm has been + * assigned. When decoding, liblzma still accepts unknown Check IDs for + * future compatibility. If a valid but unsupported Check ID is detected, + * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK, + * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h. + */ +#define LZMA_CHECK_ID_MAX 15 + + +/** + * \brief Test if the given Check ID is supported + * + * LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always supported (even if + * liblzma is built with limited features). + * + * \note It is safe to call this with a value that is not in the + * range [0, 15]; in that case the return value is always false. + * + * \param check Check ID + * + * \return lzma_bool: + * - true if Check ID is supported by this liblzma build. + * - false otherwise. + */ +extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check) + lzma_nothrow lzma_attr_const; + + +/** + * \brief Get the size of the Check field with the given Check ID + * + * Although not all Check IDs have a check algorithm associated, the size of + * every Check is already frozen. This function returns the size (in bytes) of + * the Check field with the specified Check ID. The values are: + * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 } + * + * \param check Check ID + * + * \return Size of the Check field in bytes. If the argument is not in + * the range [0, 15], UINT32_MAX is returned. + */ +extern LZMA_API(uint32_t) lzma_check_size(lzma_check check) + lzma_nothrow lzma_attr_const; + + +/** + * \brief Maximum size of a Check field + */ +#define LZMA_CHECK_SIZE_MAX 64 + + +/** + * \brief Calculate CRC32 + * + * Calculate CRC32 using the polynomial from the IEEE 802.3 standard. + * + * \param buf Pointer to the input buffer + * \param size Size of the input buffer + * \param crc Previously returned CRC value. This is used to + * calculate the CRC of a big buffer in smaller chunks. + * Set to zero when starting a new calculation. + * + * \return Updated CRC value, which can be passed to this function + * again to continue CRC calculation. + */ +extern LZMA_API(uint32_t) lzma_crc32( + const uint8_t *buf, size_t size, uint32_t crc) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Calculate CRC64 + * + * Calculate CRC64 using the polynomial from the ECMA-182 standard. + * + * This function is used similarly to lzma_crc32(). + * + * \param buf Pointer to the input buffer + * \param size Size of the input buffer + * \param crc Previously returned CRC value. This is used to + * calculate the CRC of a big buffer in smaller chunks. + * Set to zero when starting a new calculation. + * + * \return Updated CRC value, which can be passed to this function + * again to continue CRC calculation. + */ +extern LZMA_API(uint64_t) lzma_crc64( + const uint8_t *buf, size_t size, uint64_t crc) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Get the type of the integrity check + * + * This function can be called only immediately after lzma_code() has + * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK. + * Calling this function in any other situation has undefined behavior. + * + * \param strm Pointer to lzma_stream meeting the above conditions. + * + * \return Check ID in the lzma_stream, or undefined if called improperly. + */ +extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm) + lzma_nothrow; diff --git a/illumos-x86_64/usr/include/lzma/container.h b/illumos-x86_64/usr/include/lzma/container.h new file mode 100644 index 00000000..dbd414cb --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/container.h @@ -0,0 +1,995 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/container.h + * \brief File formats + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/************ + * Encoding * + ************/ + +/** + * \brief Default compression preset + * + * It's not straightforward to recommend a default preset, because in some + * cases keeping the resource usage relatively low is more important that + * getting the maximum compression ratio. + */ +#define LZMA_PRESET_DEFAULT UINT32_C(6) + + +/** + * \brief Mask for preset level + * + * This is useful only if you need to extract the level from the preset + * variable. That should be rare. + */ +#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F) + + +/* + * Preset flags + * + * Currently only one flag is defined. + */ + +/** + * \brief Extreme compression preset + * + * This flag modifies the preset to make the encoding significantly slower + * while improving the compression ratio only marginally. This is useful + * when you don't mind spending time to get as small result as possible. + * + * This flag doesn't affect the memory usage requirements of the decoder (at + * least not significantly). The memory usage of the encoder may be increased + * a little but only at the lowest preset levels (0-3). + */ +#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31) + + +/** + * \brief Multithreading options + */ +typedef struct { + /** + * \brief Flags + * + * Set this to zero if no flags are wanted. + * + * Encoder: No flags are currently supported. + * + * Decoder: Bitwise-or of zero or more of the decoder flags: + * - LZMA_TELL_NO_CHECK + * - LZMA_TELL_UNSUPPORTED_CHECK + * - LZMA_TELL_ANY_CHECK + * - LZMA_IGNORE_CHECK + * - LZMA_CONCATENATED + * - LZMA_FAIL_FAST + */ + uint32_t flags; + + /** + * \brief Number of worker threads to use + */ + uint32_t threads; + + /** + * \brief Encoder only: Maximum uncompressed size of a Block + * + * The encoder will start a new .xz Block every block_size bytes. + * Using LZMA_FULL_FLUSH or LZMA_FULL_BARRIER with lzma_code() + * the caller may tell liblzma to start a new Block earlier. + * + * With LZMA2, a recommended block size is 2-4 times the LZMA2 + * dictionary size. With very small dictionaries, it is recommended + * to use at least 1 MiB block size for good compression ratio, even + * if this is more than four times the dictionary size. Note that + * these are only recommendations for typical use cases; feel free + * to use other values. Just keep in mind that using a block size + * less than the LZMA2 dictionary size is waste of RAM. + * + * Set this to 0 to let liblzma choose the block size depending + * on the compression options. For LZMA2 it will be 3*dict_size + * or 1 MiB, whichever is more. + * + * For each thread, about 3 * block_size bytes of memory will be + * allocated. This may change in later liblzma versions. If so, + * the memory usage will probably be reduced, not increased. + */ + uint64_t block_size; + + /** + * \brief Timeout to allow lzma_code() to return early + * + * Multithreading can make liblzma consume input and produce + * output in a very bursty way: it may first read a lot of input + * to fill internal buffers, then no input or output occurs for + * a while. + * + * In single-threaded mode, lzma_code() won't return until it has + * either consumed all the input or filled the output buffer. If + * this is done in multithreaded mode, it may cause a call + * lzma_code() to take even tens of seconds, which isn't acceptable + * in all applications. + * + * To avoid very long blocking times in lzma_code(), a timeout + * (in milliseconds) may be set here. If lzma_code() would block + * longer than this number of milliseconds, it will return with + * LZMA_OK. Reasonable values are 100 ms or more. The xz command + * line tool uses 300 ms. + * + * If long blocking times are acceptable, set timeout to a special + * value of 0. This will disable the timeout mechanism and will make + * lzma_code() block until all the input is consumed or the output + * buffer has been filled. + * + * \note Even with a timeout, lzma_code() might sometimes take + * a long time to return. No timing guarantees are made. + */ + uint32_t timeout; + + /** + * \brief Encoder only: Compression preset + * + * The preset is set just like with lzma_easy_encoder(). + * The preset is ignored if filters below is non-NULL. + */ + uint32_t preset; + + /** + * \brief Encoder only: Filter chain (alternative to a preset) + * + * If this is NULL, the preset above is used. Otherwise the preset + * is ignored and the filter chain specified here is used. + */ + const lzma_filter *filters; + + /** + * \brief Encoder only: Integrity check type + * + * See check.h for available checks. The xz command line tool + * defaults to LZMA_CHECK_CRC64, which is a good choice if you + * are unsure. + */ + lzma_check check; + + /* + * Reserved space to allow possible future extensions without + * breaking the ABI. You should not touch these, because the names + * of these variables may change. These are and will never be used + * with the currently supported options, so it is safe to leave these + * uninitialized. + */ + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum2; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum3; + + /** \private Reserved member. */ + uint32_t reserved_int1; + + /** \private Reserved member. */ + uint32_t reserved_int2; + + /** \private Reserved member. */ + uint32_t reserved_int3; + + /** \private Reserved member. */ + uint32_t reserved_int4; + + /** + * \brief Memory usage limit to reduce the number of threads + * + * Encoder: Ignored. + * + * Decoder: + * + * If the number of threads has been set so high that more than + * memlimit_threading bytes of memory would be needed, the number + * of threads will be reduced so that the memory usage will not exceed + * memlimit_threading bytes. However, if memlimit_threading cannot + * be met even in single-threaded mode, then decoding will continue + * in single-threaded mode and memlimit_threading may be exceeded + * even by a large amount. That is, memlimit_threading will never make + * lzma_code() return LZMA_MEMLIMIT_ERROR. To truly cap the memory + * usage, see memlimit_stop below. + * + * Setting memlimit_threading to UINT64_MAX or a similar huge value + * means that liblzma is allowed to keep the whole compressed file + * and the whole uncompressed file in memory in addition to the memory + * needed by the decompressor data structures used by each thread! + * In other words, a reasonable value limit must be set here or it + * will cause problems sooner or later. If you have no idea what + * a reasonable value could be, try lzma_physmem() / 4 as a starting + * point. Setting this limit will never prevent decompression of + * a file; this will only reduce the number of threads. + * + * If memlimit_threading is greater than memlimit_stop, then the value + * of memlimit_stop will be used for both. + */ + uint64_t memlimit_threading; + + /** + * \brief Memory usage limit that should never be exceeded + * + * Encoder: Ignored. + * + * Decoder: If decompressing will need more than this amount of + * memory even in the single-threaded mode, then lzma_code() will + * return LZMA_MEMLIMIT_ERROR. + */ + uint64_t memlimit_stop; + + /** \private Reserved member. */ + uint64_t reserved_int7; + + /** \private Reserved member. */ + uint64_t reserved_int8; + + /** \private Reserved member. */ + void *reserved_ptr1; + + /** \private Reserved member. */ + void *reserved_ptr2; + + /** \private Reserved member. */ + void *reserved_ptr3; + + /** \private Reserved member. */ + void *reserved_ptr4; + +} lzma_mt; + + +/** + * \brief Calculate approximate memory usage of easy encoder + * + * This function is a wrapper for lzma_raw_encoder_memusage(). + * + * \param preset Compression preset (level and possible flags) + * + * \return Number of bytes of memory required for the given + * preset when encoding or UINT64_MAX on error. + */ +extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Calculate approximate decoder memory usage of a preset + * + * This function is a wrapper for lzma_raw_decoder_memusage(). + * + * \param preset Compression preset (level and possible flags) + * + * \return Number of bytes of memory required to decompress a file + * that was compressed using the given preset or UINT64_MAX + * on error. + */ +extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Initialize .xz Stream encoder using a preset number + * + * This function is intended for those who just want to use the basic features + * of liblzma (that is, most developers out there). + * + * If initialization fails (return value is not LZMA_OK), all the memory + * allocated for *strm by liblzma is always freed. Thus, there is no need + * to call lzma_end() after failed initialization. + * + * If initialization succeeds, use lzma_code() to do the actual encoding. + * Valid values for 'action' (the second argument of lzma_code()) are + * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future, + * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param preset Compression preset to use. A preset consist of level + * number and zero or more flags. Usually flags aren't + * used, so preset is simply a number [0, 9] which match + * the options -0 ... -9 of the xz command line tool. + * Additional flags can be set using bitwise-or with + * the preset level number, e.g. 6 | LZMA_PRESET_EXTREME. + * \param check Integrity check type to use. See check.h for available + * checks. The xz command line tool defaults to + * LZMA_CHECK_CRC64, which is a good choice if you are + * unsure. LZMA_CHECK_CRC32 is good too as long as the + * uncompressed file is not many gigabytes. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization succeeded. Use lzma_code() to + * encode your data. + * - LZMA_MEM_ERROR: Memory allocation failed. + * - LZMA_OPTIONS_ERROR: The given compression preset is not + * supported by this build of liblzma. + * - LZMA_UNSUPPORTED_CHECK: The given check type is not + * supported by this liblzma build. + * - LZMA_PROG_ERROR: One or more of the parameters have values + * that will never be valid. For example, strm == NULL. + */ +extern LZMA_API(lzma_ret) lzma_easy_encoder( + lzma_stream *strm, uint32_t preset, lzma_check check) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Single-call .xz Stream encoding using a preset number + * + * The maximum required output buffer size can be calculated with + * lzma_stream_buffer_bound(). + * + * \param preset Compression preset to use. See the description + * in lzma_easy_encoder(). + * \param check Type of the integrity check to calculate from + * uncompressed data. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param in_size Size of the input buffer + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_BUF_ERROR: Not enough output buffer space. + * - LZMA_UNSUPPORTED_CHECK + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_easy_buffer_encode( + uint32_t preset, lzma_check check, + const lzma_allocator *allocator, + const uint8_t *in, size_t in_size, + uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; + + +/** + * \brief Initialize .xz Stream encoder using a custom filter chain + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. See filters.h for more + * information. + * \param check Type of the integrity check to calculate from + * uncompressed data. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. + * - LZMA_MEM_ERROR + * - LZMA_UNSUPPORTED_CHECK + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm, + const lzma_filter *filters, lzma_check check) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Calculate approximate memory usage of multithreaded .xz encoder + * + * Since doing the encoding in threaded mode doesn't affect the memory + * requirements of single-threaded decompressor, you can use + * lzma_easy_decoder_memusage(options->preset) or + * lzma_raw_decoder_memusage(options->filters) to calculate + * the decompressor memory requirements. + * + * \param options Compression options + * + * \return Number of bytes of memory required for encoding with the + * given options. If an error occurs, for example due to + * unsupported preset or filter chain, UINT64_MAX is returned. + */ +extern LZMA_API(uint64_t) lzma_stream_encoder_mt_memusage( + const lzma_mt *options) lzma_nothrow lzma_attr_pure; + + +/** + * \brief Initialize multithreaded .xz Stream encoder + * + * This provides the functionality of lzma_easy_encoder() and + * lzma_stream_encoder() as a single function for multithreaded use. + * + * The supported actions for lzma_code() are LZMA_RUN, LZMA_FULL_FLUSH, + * LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be + * added in the future. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param options Pointer to multithreaded compression options + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_UNSUPPORTED_CHECK + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_stream_encoder_mt( + lzma_stream *strm, const lzma_mt *options) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Calculate recommended Block size for multithreaded .xz encoder + * + * This calculates a recommended Block size for multithreaded encoding given + * a filter chain. This is used internally by lzma_stream_encoder_mt() to + * determine the Block size if the block_size member is not set to the + * special value of 0 in the lzma_mt options struct. + * + * If one wishes to change the filters between Blocks, this function is + * helpful to set the block_size member of the lzma_mt struct before calling + * lzma_stream_encoder_mt(). Since the block_size member represents the + * maximum possible Block size for the multithreaded .xz encoder, one can + * use this function to find the maximum recommended Block size based on + * all planned filter chains. Otherwise, the multithreaded encoder will + * base its maximum Block size on the first filter chain used (if the + * block_size member is not set), which may unnecessarily limit the Block + * size for a later filter chain. + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Recommended Block size in bytes, or UINT64_MAX if + * an error occurred. + */ +extern LZMA_API(uint64_t) lzma_mt_block_size(const lzma_filter *filters) + lzma_nothrow; + + +/** + * \brief Initialize .lzma encoder (legacy file format) + * + * The .lzma format is sometimes called the LZMA_Alone format, which is the + * reason for the name of this function. The .lzma format supports only the + * LZMA1 filter. There is no support for integrity checks like CRC32. + * + * Use this function if and only if you need to create files readable by + * legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format + * is strongly recommended. + * + * The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH. + * No kind of flushing is supported, because the file format doesn't make + * it possible. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param options Pointer to encoder options + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_alone_encoder( + lzma_stream *strm, const lzma_options_lzma *options) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Calculate output buffer size for single-call Stream encoder + * + * When trying to compress incompressible data, the encoded size will be + * slightly bigger than the input data. This function calculates how much + * output buffer space is required to be sure that lzma_stream_buffer_encode() + * doesn't return LZMA_BUF_ERROR. + * + * The calculated value is not exact, but it is guaranteed to be big enough. + * The actual maximum output space required may be slightly smaller (up to + * about 100 bytes). This should not be a problem in practice. + * + * If the calculated maximum size doesn't fit into size_t or would make the + * Stream grow past LZMA_VLI_MAX (which should never happen in practice), + * zero is returned to indicate the error. + * + * \note The limit calculated by this function applies only to + * single-call encoding. Multi-call encoding may (and probably + * will) have larger maximum expansion when encoding + * incompressible data. Currently there is no function to + * calculate the maximum expansion of multi-call encoding. + * + * \param uncompressed_size Size in bytes of the uncompressed + * input data + * + * \return Maximum number of bytes needed to store the compressed data. + */ +extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size) + lzma_nothrow; + + +/** + * \brief Single-call .xz Stream encoder + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. See filters.h for more + * information. + * \param check Type of the integrity check to calculate from + * uncompressed data. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param in_size Size of the input buffer + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_BUF_ERROR: Not enough output buffer space. + * - LZMA_UNSUPPORTED_CHECK + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( + lzma_filter *filters, lzma_check check, + const lzma_allocator *allocator, + const uint8_t *in, size_t in_size, + uint8_t *out, size_t *out_pos, size_t out_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief MicroLZMA encoder + * + * The MicroLZMA format is a raw LZMA stream whose first byte (always 0x00) + * has been replaced with bitwise-negation of the LZMA properties (lc/lp/pb). + * This encoding ensures that the first byte of MicroLZMA stream is never + * 0x00. There is no end of payload marker and thus the uncompressed size + * must be stored separately. For the best error detection the dictionary + * size should be stored separately as well but alternatively one may use + * the uncompressed size as the dictionary size when decoding. + * + * With the MicroLZMA encoder, lzma_code() behaves slightly unusually. + * The action argument must be LZMA_FINISH and the return value will never be + * LZMA_OK. Thus the encoding is always done with a single lzma_code() after + * the initialization. The benefit of the combination of initialization + * function and lzma_code() is that memory allocations can be reused for + * better performance. + * + * lzma_code() will try to encode as much input as is possible to fit into + * the given output buffer. If not all input can be encoded, the stream will + * be finished without encoding all the input. The caller must check both + * input and output buffer usage after lzma_code() (total_in and total_out + * in lzma_stream can be convenient). Often lzma_code() can fill the output + * buffer completely if there is a lot of input, but sometimes a few bytes + * may remain unused because the next LZMA symbol would require more space. + * + * lzma_stream.avail_out must be at least 6. Otherwise LZMA_PROG_ERROR + * will be returned. + * + * The LZMA dictionary should be reasonably low to speed up the encoder + * re-initialization. A good value is bigger than the resulting + * uncompressed size of most of the output chunks. For example, if output + * size is 4 KiB, dictionary size of 32 KiB or 64 KiB is good. If the + * data compresses extremely well, even 128 KiB may be useful. + * + * The MicroLZMA format and this encoder variant were made with the EROFS + * file system in mind. This format may be convenient in other embedded + * uses too where many small streams are needed. XZ Embedded includes a + * decoder for this format. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param options Pointer to encoder options + * + * \return Possible lzma_ret values: + * - LZMA_STREAM_END: All good. Check the amounts of input used + * and output produced. Store the amount of input used + * (uncompressed size) as it needs to be known to decompress + * the data. + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR: In addition to the generic reasons for this + * error code, this may also be returned if there isn't enough + * output space (6 bytes) to create a valid MicroLZMA stream. + */ +extern LZMA_API(lzma_ret) lzma_microlzma_encoder( + lzma_stream *strm, const lzma_options_lzma *options) + lzma_nothrow; + + +/************ + * Decoding * + ************/ + +/** + * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream + * being decoded has no integrity check. Note that when used with + * lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK + * if LZMA_TELL_NO_CHECK is used. + */ +#define LZMA_TELL_NO_CHECK UINT32_C(0x01) + + +/** + * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input + * stream has an integrity check, but the type of the integrity check is not + * supported by this liblzma version or build. Such files can still be + * decoded, but the integrity check cannot be verified. + */ +#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02) + + +/** + * This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type + * of the integrity check is known. The type can then be got with + * lzma_get_check(). + */ +#define LZMA_TELL_ANY_CHECK UINT32_C(0x04) + + +/** + * This flag makes lzma_code() not calculate and verify the integrity check + * of the compressed data in .xz files. This means that invalid integrity + * check values won't be detected and LZMA_DATA_ERROR won't be returned in + * such cases. + * + * This flag only affects the checks of the compressed data itself; the CRC32 + * values in the .xz headers will still be verified normally. + * + * Don't use this flag unless you know what you are doing. Possible reasons + * to use this flag: + * + * - Trying to recover data from a corrupt .xz file. + * + * - Speeding up decompression, which matters mostly with SHA-256 + * or with files that have compressed extremely well. It's recommended + * to not use this flag for this purpose unless the file integrity is + * verified externally in some other way. + * + * Support for this flag was added in liblzma 5.1.4beta. + */ +#define LZMA_IGNORE_CHECK UINT32_C(0x10) + + +/** + * This flag enables decoding of concatenated files with file formats that + * allow concatenating compressed files as is. From the formats currently + * supported by liblzma, only the .xz and .lz formats allow concatenated + * files. Concatenated files are not allowed with the legacy .lzma format. + * + * This flag also affects the usage of the 'action' argument for lzma_code(). + * When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END + * unless LZMA_FINISH is used as 'action'. Thus, the application has to set + * LZMA_FINISH in the same way as it does when encoding. + * + * If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH + * as 'action' for lzma_code(), but the usage of LZMA_FINISH isn't required. + */ +#define LZMA_CONCATENATED UINT32_C(0x08) + + +/** + * This flag makes the threaded decoder report errors (like LZMA_DATA_ERROR) + * as soon as they are detected. This saves time when the application has no + * interest in a partially decompressed truncated or corrupt file. Note that + * due to timing randomness, if the same truncated or corrupt input is + * decompressed multiple times with this flag, a different amount of output + * may be produced by different runs, and even the error code might vary. + * + * When using LZMA_FAIL_FAST, it is recommended to use LZMA_FINISH to tell + * the decoder when no more input will be coming because it can help fast + * detection and reporting of truncated files. Note that in this situation + * truncated files might be diagnosed with LZMA_DATA_ERROR instead of + * LZMA_OK or LZMA_BUF_ERROR! + * + * Without this flag the threaded decoder will provide as much output as + * possible at first and then report the pending error. This default behavior + * matches the single-threaded decoder and provides repeatable behavior + * with truncated or corrupt input. There are a few special cases where the + * behavior can still differ like memory allocation failures (LZMA_MEM_ERROR). + * + * Single-threaded decoders currently ignore this flag. + * + * Support for this flag was added in liblzma 5.3.3alpha. Note that in older + * versions this flag isn't supported (LZMA_OPTIONS_ERROR) even by functions + * that ignore this flag in newer liblzma versions. + */ +#define LZMA_FAIL_FAST UINT32_C(0x20) + + +/** + * \brief Initialize .xz Stream decoder + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param memlimit Memory usage limit as bytes. Use UINT64_MAX + * to effectively disable the limiter. liblzma + * 5.2.3 and earlier don't allow 0 here and return + * LZMA_PROG_ERROR; later versions treat 0 as if 1 + * had been specified. + * \param flags Bitwise-or of zero or more of the decoder flags: + * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, + * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, + * LZMA_CONCATENATED, LZMA_FAIL_FAST + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. + * - LZMA_MEM_ERROR: Cannot allocate memory. + * - LZMA_OPTIONS_ERROR: Unsupported flags + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_stream_decoder( + lzma_stream *strm, uint64_t memlimit, uint32_t flags) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Initialize multithreaded .xz Stream decoder + * + * The decoder can decode multiple Blocks in parallel. This requires that each + * Block Header contains the Compressed Size and Uncompressed size fields + * which are added by the multi-threaded encoder, see lzma_stream_encoder_mt(). + * + * A Stream with one Block will only utilize one thread. A Stream with multiple + * Blocks but without size information in Block Headers will be processed in + * single-threaded mode in the same way as done by lzma_stream_decoder(). + * Concatenated Streams are processed one Stream at a time; no inter-Stream + * parallelization is done. + * + * This function behaves like lzma_stream_decoder() when options->threads == 1 + * and options->memlimit_threading <= 1. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param options Pointer to multithreaded compression options + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. + * - LZMA_MEM_ERROR: Cannot allocate memory. + * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. + * - LZMA_OPTIONS_ERROR: Unsupported flags. + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_stream_decoder_mt( + lzma_stream *strm, const lzma_mt *options) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Decode .xz, .lzma, and .lz (lzip) files with autodetection + * + * This decoder autodetects between the .xz, .lzma, and .lz file formats, + * and calls lzma_stream_decoder(), lzma_alone_decoder(), or + * lzma_lzip_decoder() once the type of the input file has been detected. + * + * Support for .lz was added in 5.4.0. + * + * If the flag LZMA_CONCATENATED is used and the input is a .lzma file: + * For historical reasons concatenated .lzma files aren't supported. + * If there is trailing data after one .lzma stream, lzma_code() will + * return LZMA_DATA_ERROR. (lzma_alone_decoder() doesn't have such a check + * as it doesn't support any decoder flags. It will return LZMA_STREAM_END + * after one .lzma stream.) + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param memlimit Memory usage limit as bytes. Use UINT64_MAX + * to effectively disable the limiter. liblzma + * 5.2.3 and earlier don't allow 0 here and return + * LZMA_PROG_ERROR; later versions treat 0 as if 1 + * had been specified. + * \param flags Bitwise-or of zero or more of the decoder flags: + * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, + * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, + * LZMA_CONCATENATED, LZMA_FAIL_FAST + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. + * - LZMA_MEM_ERROR: Cannot allocate memory. + * - LZMA_OPTIONS_ERROR: Unsupported flags + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_auto_decoder( + lzma_stream *strm, uint64_t memlimit, uint32_t flags) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Initialize .lzma decoder (legacy file format) + * + * Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. + * There is no need to use LZMA_FINISH, but it's allowed because it may + * simplify certain types of applications. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param memlimit Memory usage limit as bytes. Use UINT64_MAX + * to effectively disable the limiter. liblzma + * 5.2.3 and earlier don't allow 0 here and return + * LZMA_PROG_ERROR; later versions treat 0 as if 1 + * had been specified. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_alone_decoder( + lzma_stream *strm, uint64_t memlimit) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Initialize .lz (lzip) decoder (a foreign file format) + * + * This decoder supports the .lz format version 0 and the unextended .lz + * format version 1: + * + * - Files in the format version 0 were produced by lzip 1.3 and older. + * Such files aren't common but may be found from file archives + * as a few source packages were released in this format. People + * might have old personal files in this format too. Decompression + * support for the format version 0 was removed in lzip 1.18. + * + * - lzip 1.3 added decompression support for .lz format version 1 files. + * Compression support was added in lzip 1.4. In lzip 1.6 the .lz format + * version 1 was extended to support the Sync Flush marker. This extension + * is not supported by liblzma. lzma_code() will return LZMA_DATA_ERROR + * at the location of the Sync Flush marker. In practice files with + * the Sync Flush marker are very rare and thus liblzma can decompress + * almost all .lz files. + * + * Just like with lzma_stream_decoder() for .xz files, LZMA_CONCATENATED + * should be used when decompressing normal standalone .lz files. + * + * The .lz format allows putting non-.lz data at the end of a file after at + * least one valid .lz member. That is, one can append custom data at the end + * of a .lz file and the decoder is required to ignore it. In liblzma this + * is relevant only when LZMA_CONCATENATED is used. In that case lzma_code() + * will return LZMA_STREAM_END and leave lzma_stream.next_in pointing to + * the first byte of the non-.lz data. An exception to this is if the first + * 1-3 bytes of the non-.lz data are identical to the .lz magic bytes + * (0x4C, 0x5A, 0x49, 0x50; "LZIP" in US-ASCII). In such a case the 1-3 bytes + * will have been ignored by lzma_code(). If one wishes to locate the non-.lz + * data reliably, one must ensure that the first byte isn't 0x4C. Actually + * one should ensure that none of the first four bytes of trailing data are + * equal to the magic bytes because lzip >= 1.20 requires it by default. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param memlimit Memory usage limit as bytes. Use UINT64_MAX + * to effectively disable the limiter. + * \param flags Bitwise-or of flags, or zero for no flags. + * All decoder flags listed above are supported + * although only LZMA_CONCATENATED and (in very rare + * cases) LZMA_IGNORE_CHECK are actually useful. + * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, + * and LZMA_FAIL_FAST do nothing. LZMA_TELL_ANY_CHECK + * is supported for consistency only as CRC32 is + * always used in the .lz format. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. + * - LZMA_MEM_ERROR: Cannot allocate memory. + * - LZMA_OPTIONS_ERROR: Unsupported flags + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_lzip_decoder( + lzma_stream *strm, uint64_t memlimit, uint32_t flags) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Single-call .xz Stream decoder + * + * \param memlimit Pointer to how much memory the decoder is allowed + * to allocate. The value pointed by this pointer is + * modified if and only if LZMA_MEMLIMIT_ERROR is + * returned. + * \param flags Bitwise-or of zero or more of the decoder flags: + * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, + * LZMA_IGNORE_CHECK, LZMA_CONCATENATED, + * LZMA_FAIL_FAST. Note that LZMA_TELL_ANY_CHECK + * is not allowed and will return LZMA_PROG_ERROR. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param in_pos The next byte will be read from in[*in_pos]. + * *in_pos is updated only if decoding succeeds. + * \param in_size Size of the input buffer; the first byte that + * won't be read is in[in_size]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if decoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. + * - LZMA_FORMAT_ERROR + * - LZMA_OPTIONS_ERROR + * - LZMA_DATA_ERROR + * - LZMA_NO_CHECK: This can be returned only if using + * the LZMA_TELL_NO_CHECK flag. + * - LZMA_UNSUPPORTED_CHECK: This can be returned only if using + * the LZMA_TELL_UNSUPPORTED_CHECK flag. + * - LZMA_MEM_ERROR + * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. + * The minimum required memlimit value was stored to *memlimit. + * - LZMA_BUF_ERROR: Output buffer was too small. + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( + uint64_t *memlimit, uint32_t flags, + const lzma_allocator *allocator, + const uint8_t *in, size_t *in_pos, size_t in_size, + uint8_t *out, size_t *out_pos, size_t out_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief MicroLZMA decoder + * + * See lzma_microlzma_encoder() for more information. + * + * The lzma_code() usage with this decoder is completely normal. The + * special behavior of lzma_code() applies to lzma_microlzma_encoder() only. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param comp_size Compressed size of the MicroLZMA stream. + * The caller must somehow know this exactly. + * \param uncomp_size Uncompressed size of the MicroLZMA stream. + * If the exact uncompressed size isn't known, this + * can be set to a value that is at most as big as + * the exact uncompressed size would be, but then the + * next argument uncomp_size_is_exact must be false. + * \param uncomp_size_is_exact + * If true, uncomp_size must be exactly correct. + * This will improve error detection at the end of + * the stream. If the exact uncompressed size isn't + * known, this must be false. uncomp_size must still + * be at most as big as the exact uncompressed size + * is. Setting this to false when the exact size is + * known will work but error detection at the end of + * the stream will be weaker. + * \param dict_size LZMA dictionary size that was used when + * compressing the data. It is OK to use a bigger + * value too but liblzma will then allocate more + * memory than would actually be required and error + * detection will be slightly worse. (Note that with + * the implementation in XZ Embedded it doesn't + * affect the memory usage if one specifies bigger + * dictionary than actually required.) + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_microlzma_decoder( + lzma_stream *strm, uint64_t comp_size, + uint64_t uncomp_size, lzma_bool uncomp_size_is_exact, + uint32_t dict_size) lzma_nothrow; diff --git a/illumos-x86_64/usr/include/lzma/delta.h b/illumos-x86_64/usr/include/lzma/delta.h new file mode 100644 index 00000000..5ebacef8 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/delta.h @@ -0,0 +1,95 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/delta.h + * \brief Delta filter + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Filter ID + * + * Filter ID of the Delta filter. This is used as lzma_filter.id. + */ +#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03) + + +/** + * \brief Type of the delta calculation + * + * Currently only byte-wise delta is supported. Other possible types could + * be, for example, delta of 16/32/64-bit little/big endian integers, but + * these are not currently planned since byte-wise delta is almost as good. + */ +typedef enum { + LZMA_DELTA_TYPE_BYTE +} lzma_delta_type; + + +/** + * \brief Options for the Delta filter + * + * These options are needed by both encoder and decoder. + */ +typedef struct { + /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */ + lzma_delta_type type; + + /** + * \brief Delta distance + * + * With the only currently supported type, LZMA_DELTA_TYPE_BYTE, + * the distance is as bytes. + * + * Examples: + * - 16-bit stereo audio: distance = 4 bytes + * - 24-bit RGB image data: distance = 3 bytes + */ + uint32_t dist; + + /** + * \brief Minimum value for lzma_options_delta.dist. + */ +# define LZMA_DELTA_DIST_MIN 1 + + /** + * \brief Maximum value for lzma_options_delta.dist. + */ +# define LZMA_DELTA_DIST_MAX 256 + + /* + * Reserved space to allow possible future extensions without + * breaking the ABI. You should not touch these, because the names + * of these variables may change. These are and will never be used + * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these + * uninitialized. + */ + + /** \private Reserved member. */ + uint32_t reserved_int1; + + /** \private Reserved member. */ + uint32_t reserved_int2; + + /** \private Reserved member. */ + uint32_t reserved_int3; + + /** \private Reserved member. */ + uint32_t reserved_int4; + + /** \private Reserved member. */ + void *reserved_ptr1; + + /** \private Reserved member. */ + void *reserved_ptr2; + +} lzma_options_delta; diff --git a/illumos-x86_64/usr/include/lzma/filter.h b/illumos-x86_64/usr/include/lzma/filter.h new file mode 100644 index 00000000..e86809c4 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/filter.h @@ -0,0 +1,769 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/filter.h + * \brief Common filter related types and functions + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Maximum number of filters in a chain + * + * A filter chain can have 1-4 filters, of which three are allowed to change + * the size of the data. Usually only one or two filters are needed. + */ +#define LZMA_FILTERS_MAX 4 + + +/** + * \brief Filter options + * + * This structure is used to pass a Filter ID and a pointer to the filter's + * options to liblzma. A few functions work with a single lzma_filter + * structure, while most functions expect a filter chain. + * + * A filter chain is indicated with an array of lzma_filter structures. + * The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter + * array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to + * be able to hold any arbitrary filter chain. This is important when + * using lzma_block_header_decode() from block.h, because a filter array + * that is too small would make liblzma write past the end of the array. + */ +typedef struct { + /** + * \brief Filter ID + * + * Use constants whose name begin with 'LZMA_FILTER_' to specify + * different filters. In an array of lzma_filter structures, use + * LZMA_VLI_UNKNOWN to indicate end of filters. + * + * \note This is not an enum, because on some systems enums + * cannot be 64-bit. + */ + lzma_vli id; + + /** + * \brief Pointer to filter-specific options structure + * + * If the filter doesn't need options, set this to NULL. If id is + * set to LZMA_VLI_UNKNOWN, options is ignored, and thus + * doesn't need be initialized. + */ + void *options; + +} lzma_filter; + + +/** + * \brief Test if the given Filter ID is supported for encoding + * + * \param id Filter ID + * + * \return lzma_bool: + * - true if the Filter ID is supported for encoding by this + * liblzma build. + * - false otherwise. + */ +extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id) + lzma_nothrow lzma_attr_const; + + +/** + * \brief Test if the given Filter ID is supported for decoding + * + * \param id Filter ID + * + * \return lzma_bool: + * - true if the Filter ID is supported for decoding by this + * liblzma build. + * - false otherwise. + */ +extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id) + lzma_nothrow lzma_attr_const; + + +/** + * \brief Copy the filters array + * + * Copy the Filter IDs and filter-specific options from src to dest. + * Up to LZMA_FILTERS_MAX filters are copied, plus the terminating + * .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least + * LZMA_FILTERS_MAX + 1 elements space unless the caller knows that + * src is smaller than that. + * + * Unless the filter-specific options is NULL, the Filter ID has to be + * supported by liblzma, because liblzma needs to know the size of every + * filter-specific options structure. The filter-specific options are not + * validated. If options is NULL, any unsupported Filter IDs are copied + * without returning an error. + * + * Old filter-specific options in dest are not freed, so dest doesn't + * need to be initialized by the caller in any way. + * + * If an error occurs, memory possibly already allocated by this function + * is always freed. liblzma versions older than 5.2.7 may modify the dest + * array and leave its contents in an undefined state if an error occurs. + * liblzma 5.2.7 and newer only modify the dest array when returning LZMA_OK. + * + * \param src Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * \param[out] dest Destination filter array + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options + * is not NULL. + * - LZMA_PROG_ERROR: src or dest is NULL. + */ +extern LZMA_API(lzma_ret) lzma_filters_copy( + const lzma_filter *src, lzma_filter *dest, + const lzma_allocator *allocator) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Free the options in the array of lzma_filter structures + * + * This frees the filter chain options. The filters array itself is not freed. + * + * The filters array must have at most LZMA_FILTERS_MAX + 1 elements + * including the terminating element which must have .id = LZMA_VLI_UNKNOWN. + * For all elements before the terminating element: + * - options will be freed using the given lzma_allocator or, + * if allocator is NULL, using free(). + * - options will be set to NULL. + * - id will be set to LZMA_VLI_UNKNOWN. + * + * If filters is NULL, this does nothing. Again, this never frees the + * filters array itself. + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + */ +extern LZMA_API(void) lzma_filters_free( + lzma_filter *filters, const lzma_allocator *allocator) + lzma_nothrow; + + +/** + * \brief Calculate approximate memory requirements for raw encoder + * + * This function can be used to calculate the memory requirements for + * Block and Stream encoders too because Block and Stream encoders don't + * need significantly more memory than raw encoder. + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Number of bytes of memory required for the given + * filter chain when encoding or UINT64_MAX on error. + */ +extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Calculate approximate memory requirements for raw decoder + * + * This function can be used to calculate the memory requirements for + * Block and Stream decoders too because Block and Stream decoders don't + * need significantly more memory than raw decoder. + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Number of bytes of memory required for the given + * filter chain when decoding or UINT64_MAX on error. + */ +extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Initialize raw encoder + * + * This function may be useful when implementing custom file formats. + * + * The 'action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the + * filter chain supports it), or LZMA_FINISH. + * + * \param strm Pointer to lzma_stream that is at least + * initialized with LZMA_STREAM_INIT. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_raw_encoder( + lzma_stream *strm, const lzma_filter *filters) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Initialize raw decoder + * + * The initialization of raw decoder goes similarly to raw encoder. + * + * The 'action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using + * LZMA_FINISH is not required, it is supported just for convenience. + * + * \param strm Pointer to lzma_stream that is at least + * initialized with LZMA_STREAM_INIT. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_raw_decoder( + lzma_stream *strm, const lzma_filter *filters) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Update the filter chain in the encoder + * + * This function may be called after lzma_code() has returned LZMA_STREAM_END + * when LZMA_FULL_BARRIER, LZMA_FULL_FLUSH, or LZMA_SYNC_FLUSH was used: + * + * - After LZMA_FULL_BARRIER or LZMA_FULL_FLUSH: Single-threaded .xz Stream + * encoder (lzma_stream_encoder()) and (since liblzma 5.4.0) multi-threaded + * Stream encoder (lzma_stream_encoder_mt()) allow setting a new filter + * chain to be used for the next Block(s). + * + * - After LZMA_SYNC_FLUSH: Raw encoder (lzma_raw_encoder()), + * Block encoder (lzma_block_encoder()), and single-threaded .xz Stream + * encoder (lzma_stream_encoder()) allow changing certain filter-specific + * options in the middle of encoding. The actual filters in the chain + * (Filter IDs) must not be changed! Currently only the lc, lp, and pb + * options of LZMA2 (not LZMA1) can be changed this way. + * + * - In the future some filters might allow changing some of their options + * without any barrier or flushing but currently such filters don't exist. + * + * This function may also be called when no data has been compressed yet + * although this is rarely useful. In that case, this function will behave + * as if LZMA_FULL_FLUSH (Stream encoders) or LZMA_SYNC_FLUSH (Raw or Block + * encoder) had been used right before calling this function. + * + * \param strm Pointer to lzma_stream that is at least + * initialized with LZMA_STREAM_INIT. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_MEMLIMIT_ERROR + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_filters_update( + lzma_stream *strm, const lzma_filter *filters) lzma_nothrow; + + +/** + * \brief Single-call raw encoder + * + * \note There is no function to calculate how big output buffer + * would surely be big enough. (lzma_stream_buffer_bound() + * works only for lzma_stream_buffer_encode(); raw encoder + * won't necessarily meet that bound.) + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param in_size Size of the input buffer + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_BUF_ERROR: Not enough output buffer space. + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_raw_buffer_encode( + const lzma_filter *filters, const lzma_allocator *allocator, + const uint8_t *in, size_t in_size, uint8_t *out, + size_t *out_pos, size_t out_size) lzma_nothrow; + + +/** + * \brief Single-call raw decoder + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param in_pos The next byte will be read from in[*in_pos]. + * *in_pos is updated only if decoding succeeds. + * \param in_size Size of the input buffer; the first byte that + * won't be read is in[in_size]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. + * - LZMA_BUF_ERROR: Not enough output buffer space. + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_raw_buffer_decode( + const lzma_filter *filters, const lzma_allocator *allocator, + const uint8_t *in, size_t *in_pos, size_t in_size, + uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; + + +/** + * \brief Get the size of the Filter Properties field + * + * This function may be useful when implementing custom file formats + * using the raw encoder and decoder. + * + * \note This function validates the Filter ID, but does not + * necessarily validate the options. Thus, it is possible + * that this returns LZMA_OK while the following call to + * lzma_properties_encode() returns LZMA_OPTIONS_ERROR. + * + * \param[out] size Pointer to uint32_t to hold the size of the properties + * \param filter Filter ID and options (the size of the properties may + * vary depending on the options) + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_properties_size( + uint32_t *size, const lzma_filter *filter) lzma_nothrow; + + +/** + * \brief Encode the Filter Properties field + * + * \note Even this function won't validate more options than actually + * necessary. Thus, it is possible that encoding the properties + * succeeds but using the same options to initialize the encoder + * will fail. + * + * \note If lzma_properties_size() indicated that the size + * of the Filter Properties field is zero, calling + * lzma_properties_encode() is not required, but it + * won't do any harm either. + * + * \param filter Filter ID and options + * \param[out] props Buffer to hold the encoded options. The size of + * the buffer must have been already determined with + * lzma_properties_size(). + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_properties_encode( + const lzma_filter *filter, uint8_t *props) lzma_nothrow; + + +/** + * \brief Decode the Filter Properties field + * + * \param filter filter->id must have been set to the correct + * Filter ID. filter->options doesn't need to be + * initialized (it's not freed by this function). The + * decoded options will be stored in filter->options; + * it's application's responsibility to free it when + * appropriate. filter->options is set to NULL if + * there are no properties or if an error occurs. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * and in case of an error, also free(). + * \param props Input buffer containing the properties. + * \param props_size Size of the properties. This must be the exact + * size; giving too much or too little input will + * return LZMA_OPTIONS_ERROR. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + */ +extern LZMA_API(lzma_ret) lzma_properties_decode( + lzma_filter *filter, const lzma_allocator *allocator, + const uint8_t *props, size_t props_size) lzma_nothrow; + + +/** + * \brief Calculate encoded size of a Filter Flags field + * + * Knowing the size of Filter Flags is useful to know when allocating + * memory to hold the encoded Filter Flags. + * + * \note If you need to calculate size of List of Filter Flags, + * you need to loop over every lzma_filter entry. + * + * \param[out] size Pointer to integer to hold the calculated size + * \param filter Filter ID and associated options whose encoded + * size is to be calculated + * + * \return Possible lzma_ret values: + * - LZMA_OK: *size set successfully. Note that this doesn't + * guarantee that filter->options is valid, thus + * lzma_filter_flags_encode() may still fail. + * - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options. + * - LZMA_PROG_ERROR: Invalid options + */ +extern LZMA_API(lzma_ret) lzma_filter_flags_size( + uint32_t *size, const lzma_filter *filter) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Encode Filter Flags into given buffer + * + * In contrast to some functions, this doesn't allocate the needed buffer. + * This is due to how this function is used internally by liblzma. + * + * \param filter Filter ID and options to be encoded + * \param[out] out Beginning of the output buffer + * \param[out] out_pos out[*out_pos] is the next write position. This + * is updated by the encoder. + * \param out_size out[out_size] is the first byte to not write. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. + * - LZMA_PROG_ERROR: Invalid options or not enough output + * buffer space (you should have checked it with + * lzma_filter_flags_size()). + */ +extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter, + uint8_t *out, size_t *out_pos, size_t out_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Decode Filter Flags from given buffer + * + * The decoded result is stored into *filter. The old value of + * filter->options is not free()d. If anything other than LZMA_OK + * is returned, filter->options is set to NULL. + * + * \param[out] filter Destination filter. The decoded Filter ID will + * be stored in filter->id. If options are needed + * they will be allocated and the pointer will be + * stored in filter->options. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param[out] in_pos The next byte will be read from in[*in_pos]. + * *in_pos is updated only if decoding succeeds. + * \param in_size Size of the input buffer; the first byte that + * won't be read is in[in_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_filter_flags_decode( + lzma_filter *filter, const lzma_allocator *allocator, + const uint8_t *in, size_t *in_pos, size_t in_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/*********** + * Strings * + ***********/ + +/** + * \brief Allow or show all filters + * + * By default only the filters supported in the .xz format are accept by + * lzma_str_to_filters() or shown by lzma_str_list_filters(). + */ +#define LZMA_STR_ALL_FILTERS UINT32_C(0x01) + + +/** + * \brief Do not validate the filter chain in lzma_str_to_filters() + * + * By default lzma_str_to_filters() can return an error if the filter chain + * as a whole isn't usable in the .xz format or in the raw encoder or decoder. + * With this flag, this validation is skipped. This flag doesn't affect the + * handling of the individual filter options. To allow non-.xz filters also + * LZMA_STR_ALL_FILTERS is needed. + */ +#define LZMA_STR_NO_VALIDATION UINT32_C(0x02) + + +/** + * \brief Stringify encoder options + * + * Show the filter-specific options that the encoder will use. + * This may be useful for verbose diagnostic messages. + * + * Note that if options were decoded from .xz headers then the encoder options + * may be undefined. This flag shouldn't be used in such a situation. + */ +#define LZMA_STR_ENCODER UINT32_C(0x10) + + +/** + * \brief Stringify decoder options + * + * Show the filter-specific options that the decoder will use. + * This may be useful for showing what filter options were decoded + * from file headers. + */ +#define LZMA_STR_DECODER UINT32_C(0x20) + + +/** + * \brief Produce xz-compatible getopt_long() syntax + * + * That is, "delta:dist=2 lzma2:dict=4MiB,pb=1,lp=1" becomes + * "--delta=dist=2 --lzma2=dict=4MiB,pb=1,lp=1". + * + * This syntax is compatible with xz 5.0.0 as long as the filters and + * their options are supported too. + */ +#define LZMA_STR_GETOPT_LONG UINT32_C(0x40) + + +/** + * \brief Use two dashes "--" instead of a space to separate filters + * + * That is, "delta:dist=2 lzma2:pb=1,lp=1" becomes + * "delta:dist=2--lzma2:pb=1,lp=1". This looks slightly odd but this + * kind of strings should be usable on the command line without quoting. + * However, it is possible that future versions with new filter options + * might produce strings that require shell quoting anyway as the exact + * set of possible characters isn't frozen for now. + * + * It is guaranteed that the single quote (') will never be used in + * filter chain strings (even if LZMA_STR_NO_SPACES isn't used). + */ +#define LZMA_STR_NO_SPACES UINT32_C(0x80) + + +/** + * \brief Convert a string to a filter chain + * + * This tries to make it easier to write applications that allow users + * to set custom compression options. This only handles the filter + * configuration (including presets) but not the number of threads, + * block size, check type, or memory limits. + * + * The input string can be either a preset or a filter chain. Presets + * begin with a digit 0-9 and may be followed by zero or more flags + * which are lower-case letters. Currently only "e" is supported, matching + * LZMA_PRESET_EXTREME. For partial xz command line syntax compatibility, + * a preset string may start with a single dash "-". + * + * A filter chain consists of one or more "filtername:opt1=value1,opt2=value2" + * strings separated by one or more spaces. Leading and trailing spaces are + * ignored. All names and values must be lower-case. Extra commas in the + * option list are ignored. The order of filters is significant: when + * encoding, the uncompressed input data goes to the leftmost filter first. + * Normally "lzma2" is the last filter in the chain. + * + * If one wishes to avoid spaces, for example, to avoid shell quoting, + * it is possible to use two dashes "--" instead of spaces to separate + * the filters. + * + * For xz command line compatibility, each filter may be prefixed with + * two dashes "--" and the colon ":" separating the filter name from + * the options may be replaced with an equals sign "=". + * + * By default, only filters that can be used in the .xz format are accepted. + * To allow all filters (LZMA1) use the flag LZMA_STR_ALL_FILTERS. + * + * By default, very basic validation is done for the filter chain as a whole, + * for example, that LZMA2 is only used as the last filter in the chain. + * The validation isn't perfect though and it's possible that this function + * succeeds but using the filter chain for encoding or decoding will still + * result in LZMA_OPTIONS_ERROR. To disable this validation, use the flag + * LZMA_STR_NO_VALIDATION. + * + * The available filter names and their options are available via + * lzma_str_list_filters(). See the xz man page for the description + * of filter names and options. + * + * For command line applications, below is an example how an error message + * can be displayed. Note the use of an empty string for the field width. + * If "^" was used there it would create an off-by-one error except at + * the very beginning of the line. + * + * \code{.c} + * const char *str = ...; // From user + * lzma_filter filters[LZMA_FILTERS_MAX + 1]; + * int pos; + * const char *msg = lzma_str_to_filters(str, &pos, filters, 0, NULL); + * if (msg != NULL) { + * printf("%s: Error in XZ compression options:\n", argv[0]); + * printf("%s: %s\n", argv[0], str); + * printf("%s: %*s^\n", argv[0], errpos, ""); + * printf("%s: %s\n", argv[0], msg); + * } + * \endcode + * + * \param str User-supplied string describing a preset or + * a filter chain. If a default value is needed and + * you don't know what would be good, use "6" since + * that is the default preset in xz too. + * \param[out] error_pos If this isn't NULL, this value will be set on + * both success and on all errors. This tells the + * location of the error in the string. This is + * an int to make it straightforward to use this + * as printf() field width. The value is guaranteed + * to be in the range [0, INT_MAX] even if strlen(str) + * somehow was greater than INT_MAX. + * \param[out] filters An array of lzma_filter structures. There must + * be LZMA_FILTERS_MAX + 1 (that is, five) elements + * in the array. The old contents are ignored so it + * doesn't need to be initialized. This array is + * modified only if this function returns NULL. + * Once the allocated filter options are no longer + * needed, lzma_filters_free() can be used to free the + * options (it doesn't free the filters array itself). + * \param flags Bitwise-or of zero or more of the flags + * LZMA_STR_ALL_FILTERS and LZMA_STR_NO_VALIDATION. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return On success, NULL is returned. On error, a statically-allocated + * error message is returned which together with the error_pos + * should give some idea what is wrong. + */ +extern LZMA_API(const char *) lzma_str_to_filters( + const char *str, int *error_pos, lzma_filter *filters, + uint32_t flags, const lzma_allocator *allocator) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Convert a filter chain to a string + * + * Use cases: + * + * - Verbose output showing the full encoder options to the user + * (use LZMA_STR_ENCODER in flags) + * + * - Showing the filters and options that are required to decode a file + * (use LZMA_STR_DECODER in flags) + * + * - Showing the filter names without any options in informational messages + * where the technical details aren't important (no flags). In this case + * the .options in the filters array are ignored and may be NULL even if + * a filter has a mandatory options structure. + * + * Note that even if the filter chain was specified using a preset, + * the resulting filter chain isn't reversed to a preset. So if you + * specify "6" to lzma_str_to_filters() then lzma_str_from_filters() + * will produce a string containing "lzma2". + * + * \param[out] str On success *str will be set to point to an + * allocated string describing the given filter + * chain. Old value is ignored. On error *str is + * always set to NULL. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * \param flags Bitwise-or of zero or more of the flags + * LZMA_STR_ENCODER, LZMA_STR_DECODER, + * LZMA_STR_GETOPT_LONG, and LZMA_STR_NO_SPACES. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_OPTIONS_ERROR: Empty filter chain + * (filters[0].id == LZMA_VLI_UNKNOWN) or the filter chain + * includes a Filter ID that is not supported by this function. + * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_str_from_filters( + char **str, const lzma_filter *filters, uint32_t flags, + const lzma_allocator *allocator) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief List available filters and/or their options (for help message) + * + * If a filter_id is given then only one line is created which contains the + * filter name. If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then the + * options read by the encoder or decoder are printed on the same line. + * + * If filter_id is LZMA_VLI_UNKNOWN then all supported .xz-compatible filters + * are listed: + * + * - If neither LZMA_STR_ENCODER nor LZMA_STR_DECODER is used then + * the supported filter names are listed on a single line separated + * by spaces. + * + * - If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then filters and + * the supported options are listed one filter per line. There won't + * be a newline after the last filter. + * + * - If LZMA_STR_ALL_FILTERS is used then the list will include also + * those filters that cannot be used in the .xz format (LZMA1). + * + * \param str On success *str will be set to point to an + * allocated string listing the filters and options. + * Old value is ignored. On error *str is always set + * to NULL. + * \param filter_id Filter ID or LZMA_VLI_UNKNOWN. + * \param flags Bitwise-or of zero or more of the flags + * LZMA_STR_ALL_FILTERS, LZMA_STR_ENCODER, + * LZMA_STR_DECODER, and LZMA_STR_GETOPT_LONG. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_OPTIONS_ERROR: Unsupported filter_id or flags + * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_str_list_filters( + char **str, lzma_vli filter_id, uint32_t flags, + const lzma_allocator *allocator) + lzma_nothrow lzma_attr_warn_unused_result; diff --git a/illumos-x86_64/usr/include/lzma/hardware.h b/illumos-x86_64/usr/include/lzma/hardware.h new file mode 100644 index 00000000..7a1a84fc --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/hardware.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/hardware.h + * \brief Hardware information + * \note Never include this file directly. Use instead. + * + * Since liblzma can consume a lot of system resources, it also provides + * ways to limit the resource usage. Applications linking against liblzma + * need to do the actual decisions how much resources to let liblzma to use. + * To ease making these decisions, liblzma provides functions to find out + * the relevant capabilities of the underlying hardware. Currently there + * is only a function to find out the amount of RAM, but in the future there + * will be also a function to detect how many concurrent threads the system + * can run. + * + * \note On some operating systems, these function may temporarily + * load a shared library or open file descriptor(s) to find out + * the requested hardware information. Unless the application + * assumes that specific file descriptors are not touched by + * other threads, this should have no effect on thread safety. + * Possible operations involving file descriptors will restart + * the syscalls if they return EINTR. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Get the total amount of physical memory (RAM) in bytes + * + * This function may be useful when determining a reasonable memory + * usage limit for decompressing or how much memory it is OK to use + * for compressing. + * + * \return On success, the total amount of physical memory in bytes + * is returned. If the amount of RAM cannot be determined, + * zero is returned. This can happen if an error occurs + * or if there is no code in liblzma to detect the amount + * of RAM on the specific operating system. + */ +extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; + + +/** + * \brief Get the number of processor cores or threads + * + * This function may be useful when determining how many threads to use. + * If the hardware supports more than one thread per CPU core, the number + * of hardware threads is returned if that information is available. + * + * \return On success, the number of available CPU threads or cores is + * returned. If this information isn't available or an error + * occurs, zero is returned. + */ +extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow; diff --git a/illumos-x86_64/usr/include/lzma/index.h b/illumos-x86_64/usr/include/lzma/index.h new file mode 100644 index 00000000..b17025e3 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/index.h @@ -0,0 +1,882 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/index.h + * \brief Handling of .xz Index and related information + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Opaque data type to hold the Index(es) and other information + * + * lzma_index often holds just one .xz Index and possibly the Stream Flags + * of the same Stream and size of the Stream Padding field. However, + * multiple lzma_indexes can be concatenated with lzma_index_cat() and then + * there may be information about multiple Streams in the same lzma_index. + * + * Notes about thread safety: Only one thread may modify lzma_index at + * a time. All functions that take non-const pointer to lzma_index + * modify it. As long as no thread is modifying the lzma_index, getting + * information from the same lzma_index can be done from multiple threads + * at the same time with functions that take a const pointer to + * lzma_index or use lzma_index_iter. The same iterator must be used + * only by one thread at a time, of course, but there can be as many + * iterators for the same lzma_index as needed. + */ +typedef struct lzma_index_s lzma_index; + + +/** + * \brief Iterator to get information about Blocks and Streams + */ +typedef struct { + struct { + /** + * \brief Pointer to Stream Flags + * + * This is NULL if Stream Flags have not been set for + * this Stream with lzma_index_stream_flags(). + */ + const lzma_stream_flags *flags; + + /** \private Reserved member. */ + const void *reserved_ptr1; + + /** \private Reserved member. */ + const void *reserved_ptr2; + + /** \private Reserved member. */ + const void *reserved_ptr3; + + /** + * \brief Stream number in the lzma_index + * + * The first Stream is 1. + */ + lzma_vli number; + + /** + * \brief Number of Blocks in the Stream + * + * If this is zero, the block structure below has + * undefined values. + */ + lzma_vli block_count; + + /** + * \brief Compressed start offset of this Stream + * + * The offset is relative to the beginning of the lzma_index + * (i.e. usually the beginning of the .xz file). + */ + lzma_vli compressed_offset; + + /** + * \brief Uncompressed start offset of this Stream + * + * The offset is relative to the beginning of the lzma_index + * (i.e. usually the beginning of the .xz file). + */ + lzma_vli uncompressed_offset; + + /** + * \brief Compressed size of this Stream + * + * This includes all headers except the possible + * Stream Padding after this Stream. + */ + lzma_vli compressed_size; + + /** + * \brief Uncompressed size of this Stream + */ + lzma_vli uncompressed_size; + + /** + * \brief Size of Stream Padding after this Stream + * + * If it hasn't been set with lzma_index_stream_padding(), + * this defaults to zero. Stream Padding is always + * a multiple of four bytes. + */ + lzma_vli padding; + + + /** \private Reserved member. */ + lzma_vli reserved_vli1; + + /** \private Reserved member. */ + lzma_vli reserved_vli2; + + /** \private Reserved member. */ + lzma_vli reserved_vli3; + + /** \private Reserved member. */ + lzma_vli reserved_vli4; + } stream; + + struct { + /** + * \brief Block number in the file + * + * The first Block is 1. + */ + lzma_vli number_in_file; + + /** + * \brief Compressed start offset of this Block + * + * This offset is relative to the beginning of the + * lzma_index (i.e. usually the beginning of the .xz file). + * Normally this is where you should seek in the .xz file + * to start decompressing this Block. + */ + lzma_vli compressed_file_offset; + + /** + * \brief Uncompressed start offset of this Block + * + * This offset is relative to the beginning of the lzma_index + * (i.e. usually the beginning of the .xz file). + * + * When doing random-access reading, it is possible that + * the target offset is not exactly at Block boundary. One + * will need to compare the target offset against + * uncompressed_file_offset or uncompressed_stream_offset, + * and possibly decode and throw away some amount of data + * before reaching the target offset. + */ + lzma_vli uncompressed_file_offset; + + /** + * \brief Block number in this Stream + * + * The first Block is 1. + */ + lzma_vli number_in_stream; + + /** + * \brief Compressed start offset of this Block + * + * This offset is relative to the beginning of the Stream + * containing this Block. + */ + lzma_vli compressed_stream_offset; + + /** + * \brief Uncompressed start offset of this Block + * + * This offset is relative to the beginning of the Stream + * containing this Block. + */ + lzma_vli uncompressed_stream_offset; + + /** + * \brief Uncompressed size of this Block + * + * You should pass this to the Block decoder if you will + * decode this Block. It will allow the Block decoder to + * validate the uncompressed size. + */ + lzma_vli uncompressed_size; + + /** + * \brief Unpadded size of this Block + * + * You should pass this to the Block decoder if you will + * decode this Block. It will allow the Block decoder to + * validate the unpadded size. + */ + lzma_vli unpadded_size; + + /** + * \brief Total compressed size + * + * This includes all headers and padding in this Block. + * This is useful if you need to know how many bytes + * the Block decoder will actually read. + */ + lzma_vli total_size; + + /** \private Reserved member. */ + lzma_vli reserved_vli1; + + /** \private Reserved member. */ + lzma_vli reserved_vli2; + + /** \private Reserved member. */ + lzma_vli reserved_vli3; + + /** \private Reserved member. */ + lzma_vli reserved_vli4; + + /** \private Reserved member. */ + const void *reserved_ptr1; + + /** \private Reserved member. */ + const void *reserved_ptr2; + + /** \private Reserved member. */ + const void *reserved_ptr3; + + /** \private Reserved member. */ + const void *reserved_ptr4; + } block; + + /** + * \private Internal data + * + * Internal data which is used to store the state of the iterator. + * The exact format may vary between liblzma versions, so don't + * touch these in any way. + */ + union { + /** \private Internal member. */ + const void *p; + + /** \private Internal member. */ + size_t s; + + /** \private Internal member. */ + lzma_vli v; + } internal[6]; +} lzma_index_iter; + + +/** + * \brief Operation mode for lzma_index_iter_next() + */ +typedef enum { + LZMA_INDEX_ITER_ANY = 0, + /**< + * \brief Get the next Block or Stream + * + * Go to the next Block if the current Stream has at least + * one Block left. Otherwise go to the next Stream even if + * it has no Blocks. If the Stream has no Blocks + * (lzma_index_iter.stream.block_count == 0), + * lzma_index_iter.block will have undefined values. + */ + + LZMA_INDEX_ITER_STREAM = 1, + /**< + * \brief Get the next Stream + * + * Go to the next Stream even if the current Stream has + * unread Blocks left. If the next Stream has at least one + * Block, the iterator will point to the first Block. + * If there are no Blocks, lzma_index_iter.block will have + * undefined values. + */ + + LZMA_INDEX_ITER_BLOCK = 2, + /**< + * \brief Get the next Block + * + * Go to the next Block if the current Stream has at least + * one Block left. If the current Stream has no Blocks left, + * the next Stream with at least one Block is located and + * the iterator will be made to point to the first Block of + * that Stream. + */ + + LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3 + /**< + * \brief Get the next non-empty Block + * + * This is like LZMA_INDEX_ITER_BLOCK except that it will + * skip Blocks whose Uncompressed Size is zero. + */ + +} lzma_index_iter_mode; + + +/** + * \brief Mask for return value from lzma_index_checks() for check none + * + * \note This and the other CHECK_MASK macros were added in 5.5.1alpha. + */ +#define LZMA_INDEX_CHECK_MASK_NONE (UINT32_C(1) << LZMA_CHECK_NONE) + +/** + * \brief Mask for return value from lzma_index_checks() for check CRC32 + */ +#define LZMA_INDEX_CHECK_MASK_CRC32 (UINT32_C(1) << LZMA_CHECK_CRC32) + +/** + * \brief Mask for return value from lzma_index_checks() for check CRC64 + */ +#define LZMA_INDEX_CHECK_MASK_CRC64 (UINT32_C(1) << LZMA_CHECK_CRC64) + +/** + * \brief Mask for return value from lzma_index_checks() for check SHA256 + */ +#define LZMA_INDEX_CHECK_MASK_SHA256 (UINT32_C(1) << LZMA_CHECK_SHA256) + +/** + * \brief Calculate memory usage of lzma_index + * + * On disk, the size of the Index field depends on both the number of Records + * stored and the size of the Records (due to variable-length integer + * encoding). When the Index is kept in lzma_index structure, the memory usage + * depends only on the number of Records/Blocks stored in the Index(es), and + * in case of concatenated lzma_indexes, the number of Streams. The size in + * RAM is almost always significantly bigger than in the encoded form on disk. + * + * This function calculates an approximate amount of memory needed to hold + * the given number of Streams and Blocks in lzma_index structure. This + * value may vary between CPU architectures and also between liblzma versions + * if the internal implementation is modified. + * + * \param streams Number of Streams + * \param blocks Number of Blocks + * + * \return Approximate memory in bytes needed in a lzma_index structure. + */ +extern LZMA_API(uint64_t) lzma_index_memusage( + lzma_vli streams, lzma_vli blocks) lzma_nothrow; + + +/** + * \brief Calculate the memory usage of an existing lzma_index + * + * This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i), + * lzma_index_block_count(i)). + * + * \param i Pointer to lzma_index structure + * + * \return Approximate memory in bytes used by the lzma_index structure. + */ +extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i) + lzma_nothrow; + + +/** + * \brief Allocate and initialize a new lzma_index structure + * + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return On success, a pointer to an empty initialized lzma_index is + * returned. If allocation fails, NULL is returned. + */ +extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator) + lzma_nothrow; + + +/** + * \brief Deallocate lzma_index + * + * If i is NULL, this does nothing. + * + * \param i Pointer to lzma_index structure to deallocate + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + */ +extern LZMA_API(void) lzma_index_end( + lzma_index *i, const lzma_allocator *allocator) lzma_nothrow; + + +/** + * \brief Add a new Block to lzma_index + * + * \param i Pointer to a lzma_index structure + * \param allocator lzma_allocator for custom allocator + * functions. Set to NULL to use malloc() + * and free(). + * \param unpadded_size Unpadded Size of a Block. This can be + * calculated with lzma_block_unpadded_size() + * after encoding or decoding the Block. + * \param uncompressed_size Uncompressed Size of a Block. This can be + * taken directly from lzma_block structure + * after encoding or decoding the Block. + * + * Appending a new Block does not invalidate iterators. For example, + * if an iterator was pointing to the end of the lzma_index, after + * lzma_index_append() it is possible to read the next Block with + * an existing iterator. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR: Compressed or uncompressed size of the + * Stream or size of the Index field would grow too big. + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_index_append( + lzma_index *i, const lzma_allocator *allocator, + lzma_vli unpadded_size, lzma_vli uncompressed_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Set the Stream Flags + * + * Set the Stream Flags of the last (and typically the only) Stream + * in lzma_index. This can be useful when reading information from the + * lzma_index, because to decode Blocks, knowing the integrity check type + * is needed. + * + * \param i Pointer to lzma_index structure + * \param stream_flags Pointer to lzma_stream_flags structure. This + * is copied into the internal preallocated + * structure, so the caller doesn't need to keep + * the flags' data available after calling this + * function. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version. + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_index_stream_flags( + lzma_index *i, const lzma_stream_flags *stream_flags) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Get the types of integrity Checks + * + * If lzma_index_stream_flags() is used to set the Stream Flags for + * every Stream, lzma_index_checks() can be used to get a bitmask to + * indicate which Check types have been used. It can be useful e.g. if + * showing the Check types to the user. + * + * The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10. + * These masks are defined for convenience as LZMA_INDEX_CHECK_MASK_XXX + * + * \param i Pointer to lzma_index structure + * + * \return Bitmask indicating which Check types are used in the lzma_index + */ +extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Set the amount of Stream Padding + * + * Set the amount of Stream Padding of the last (and typically the only) + * Stream in the lzma_index. This is needed when planning to do random-access + * reading within multiple concatenated Streams. + * + * By default, the amount of Stream Padding is assumed to be zero bytes. + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_DATA_ERROR: The file size would grow too big. + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_index_stream_padding( + lzma_index *i, lzma_vli stream_padding) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Get the number of Streams + * + * \param i Pointer to lzma_index structure + * + * \return Number of Streams in the lzma_index + */ +extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Get the number of Blocks + * + * This returns the total number of Blocks in lzma_index. To get number + * of Blocks in individual Streams, use lzma_index_iter. + * + * \param i Pointer to lzma_index structure + * + * \return Number of blocks in the lzma_index + */ +extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Get the size of the Index field as bytes + * + * This is needed to verify the Backward Size field in the Stream Footer. + * + * \param i Pointer to lzma_index structure + * + * \return Size in bytes of the Index + */ +extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Get the total size of the Stream + * + * If multiple lzma_indexes have been combined, this works as if the Blocks + * were in a single Stream. This is useful if you are going to combine + * Blocks from multiple Streams into a single new Stream. + * + * \param i Pointer to lzma_index structure + * + * \return Size in bytes of the Stream (if all Blocks are combined + * into one Stream). + */ +extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Get the total size of the Blocks + * + * This doesn't include the Stream Header, Stream Footer, Stream Padding, + * or Index fields. + * + * \param i Pointer to lzma_index structure + * + * \return Size in bytes of all Blocks in the Stream(s) + */ +extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Get the total size of the file + * + * When no lzma_indexes have been combined with lzma_index_cat() and there is + * no Stream Padding, this function is identical to lzma_index_stream_size(). + * If multiple lzma_indexes have been combined, this includes also the headers + * of each separate Stream and the possible Stream Padding fields. + * + * \param i Pointer to lzma_index structure + * + * \return Total size of the .xz file in bytes + */ +extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Get the uncompressed size of the file + * + * \param i Pointer to lzma_index structure + * + * \return Size in bytes of the uncompressed data in the file + */ +extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i) + lzma_nothrow lzma_attr_pure; + + +/** + * \brief Initialize an iterator + * + * This function associates the iterator with the given lzma_index, and calls + * lzma_index_iter_rewind() on the iterator. + * + * This function doesn't allocate any memory, thus there is no + * lzma_index_iter_end(). The iterator is valid as long as the + * associated lzma_index is valid, that is, until lzma_index_end() or + * using it as source in lzma_index_cat(). Specifically, lzma_index doesn't + * become invalid if new Blocks are added to it with lzma_index_append() or + * if it is used as the destination in lzma_index_cat(). + * + * It is safe to make copies of an initialized lzma_index_iter, for example, + * to easily restart reading at some particular position. + * + * \param iter Pointer to a lzma_index_iter structure + * \param i lzma_index to which the iterator will be associated + */ +extern LZMA_API(void) lzma_index_iter_init( + lzma_index_iter *iter, const lzma_index *i) lzma_nothrow; + + +/** + * \brief Rewind the iterator + * + * Rewind the iterator so that next call to lzma_index_iter_next() will + * return the first Block or Stream. + * + * \param iter Pointer to a lzma_index_iter structure + */ +extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter) + lzma_nothrow; + + +/** + * \brief Get the next Block or Stream + * + * \param iter Iterator initialized with lzma_index_iter_init() + * \param mode Specify what kind of information the caller wants + * to get. See lzma_index_iter_mode for details. + * + * \return lzma_bool: + * - true if no Block or Stream matching the mode is found. + * *iter is not updated (failure). + * - false if the next Block or Stream matching the mode was + * found. *iter is updated (success). + */ +extern LZMA_API(lzma_bool) lzma_index_iter_next( + lzma_index_iter *iter, lzma_index_iter_mode mode) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Locate a Block + * + * If it is possible to seek in the .xz file, it is possible to parse + * the Index field(s) and use lzma_index_iter_locate() to do random-access + * reading with granularity of Block size. + * + * If the target is smaller than the uncompressed size of the Stream (can be + * checked with lzma_index_uncompressed_size()): + * - Information about the Stream and Block containing the requested + * uncompressed offset is stored into *iter. + * - Internal state of the iterator is adjusted so that + * lzma_index_iter_next() can be used to read subsequent Blocks or Streams. + * + * If the target is greater than the uncompressed size of the Stream, *iter + * is not modified. + * + * \param iter Iterator that was earlier initialized with + * lzma_index_iter_init(). + * \param target Uncompressed target offset which the caller would + * like to locate from the Stream + * + * \return lzma_bool: + * - true if the target is greater than or equal to the + * uncompressed size of the Stream (failure) + * - false if the target is smaller than the uncompressed size + * of the Stream (success) + */ +extern LZMA_API(lzma_bool) lzma_index_iter_locate( + lzma_index_iter *iter, lzma_vli target) lzma_nothrow; + + +/** + * \brief Concatenate lzma_indexes + * + * Concatenating lzma_indexes is useful when doing random-access reading in + * multi-Stream .xz file, or when combining multiple Streams into single + * Stream. + * + * \param[out] dest lzma_index after which src is appended + * \param src lzma_index to be appended after dest. If this + * function succeeds, the memory allocated for src + * is freed or moved to be part of dest, and all + * iterators pointing to src will become invalid. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return Possible lzma_ret values: + * - LZMA_OK: lzma_indexes were concatenated successfully. + * src is now a dangling pointer. + * - LZMA_DATA_ERROR: *dest would grow too big. + * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src, + const lzma_allocator *allocator) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Duplicate lzma_index + * + * \param i Pointer to lzma_index structure to be duplicated + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return A copy of the lzma_index, or NULL if memory allocation failed. + */ +extern LZMA_API(lzma_index *) lzma_index_dup( + const lzma_index *i, const lzma_allocator *allocator) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Initialize .xz Index encoder + * + * \param strm Pointer to properly prepared lzma_stream + * \param i Pointer to lzma_index which should be encoded. + * + * The valid 'action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. + * It is enough to use only one of them (you can choose freely). + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization succeeded, continue with lzma_code(). + * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_index_encoder( + lzma_stream *strm, const lzma_index *i) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Initialize .xz Index decoder + * + * \param strm Pointer to properly prepared lzma_stream + * \param[out] i The decoded Index will be made available via + * this pointer. Initially this function will + * set *i to NULL (the old value is ignored). If + * decoding succeeds (lzma_code() returns + * LZMA_STREAM_END), *i will be set to point + * to a new lzma_index, which the application + * has to later free with lzma_index_end(). + * \param memlimit How much memory the resulting lzma_index is + * allowed to require. liblzma 5.2.3 and earlier + * don't allow 0 here and return LZMA_PROG_ERROR; + * later versions treat 0 as if 1 had been specified. + * + * Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. + * There is no need to use LZMA_FINISH, but it's allowed because it may + * simplify certain types of applications. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization succeeded, continue with lzma_code(). + * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR + * + * \note liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here + * but that error code has never been possible from this + * initialization function. + */ +extern LZMA_API(lzma_ret) lzma_index_decoder( + lzma_stream *strm, lzma_index **i, uint64_t memlimit) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Single-call .xz Index encoder + * + * \note This function doesn't take allocator argument since all + * the internal data is allocated on stack. + * + * \param i lzma_index to be encoded + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_BUF_ERROR: Output buffer is too small. Use + * lzma_index_size() to find out how much output + * space is needed. + * - LZMA_PROG_ERROR + * + */ +extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i, + uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; + + +/** + * \brief Single-call .xz Index decoder + * + * \param[out] i If decoding succeeds, *i will point to a new + * lzma_index, which the application has to + * later free with lzma_index_end(). If an error + * occurs, *i will be NULL. The old value of *i + * is always ignored and thus doesn't need to be + * initialized by the caller. + * \param[out] memlimit Pointer to how much memory the resulting + * lzma_index is allowed to require. The value + * pointed by this pointer is modified if and only + * if LZMA_MEMLIMIT_ERROR is returned. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param in_pos The next byte will be read from in[*in_pos]. + * *in_pos is updated only if decoding succeeds. + * \param in_size Size of the input buffer; the first byte that + * won't be read is in[in_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. + * - LZMA_MEM_ERROR + * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. + * The minimum required memlimit value was stored to *memlimit. + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i, + uint64_t *memlimit, const lzma_allocator *allocator, + const uint8_t *in, size_t *in_pos, size_t in_size) + lzma_nothrow; + + +/** + * \brief Initialize a .xz file information decoder + * + * This decoder decodes the Stream Header, Stream Footer, Index, and + * Stream Padding field(s) from the input .xz file and stores the resulting + * combined index in *dest_index. This information can be used to get the + * uncompressed file size with lzma_index_uncompressed_size(*dest_index) or, + * for example, to implement random access reading by locating the Blocks + * in the Streams. + * + * To get the required information from the .xz file, lzma_code() may ask + * the application to seek in the input file by returning LZMA_SEEK_NEEDED + * and having the target file position specified in lzma_stream.seek_pos. + * The number of seeks required depends on the input file and how big buffers + * the application provides. When possible, the decoder will seek backward + * and forward in the given buffer to avoid useless seek requests. Thus, if + * the application provides the whole file at once, no external seeking will + * be required (that is, lzma_code() won't return LZMA_SEEK_NEEDED). + * + * The value in lzma_stream.total_in can be used to estimate how much data + * liblzma had to read to get the file information. However, due to seeking + * and the way total_in is updated, the value of total_in will be somewhat + * inaccurate (a little too big). Thus, total_in is a good estimate but don't + * expect to see the same exact value for the same file if you change the + * input buffer size or switch to a different liblzma version. + * + * Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. + * You only need to use LZMA_RUN; LZMA_FINISH is only supported because it + * might be convenient for some applications. If you use LZMA_FINISH and if + * lzma_code() asks the application to seek, remember to reset 'action' back + * to LZMA_RUN unless you hit the end of the file again. + * + * Possible return values from lzma_code(): + * - LZMA_OK: All OK so far, more input needed + * - LZMA_SEEK_NEEDED: Provide more input starting from the absolute + * file position strm->seek_pos + * - LZMA_STREAM_END: Decoding was successful, *dest_index has been set + * - LZMA_FORMAT_ERROR: The input file is not in the .xz format (the + * expected magic bytes were not found from the beginning of the file) + * - LZMA_OPTIONS_ERROR: File looks valid but contains headers that aren't + * supported by this version of liblzma + * - LZMA_DATA_ERROR: File is corrupt + * - LZMA_BUF_ERROR + * - LZMA_MEM_ERROR + * - LZMA_MEMLIMIT_ERROR + * - LZMA_PROG_ERROR + * + * \param strm Pointer to a properly prepared lzma_stream + * \param[out] dest_index Pointer to a pointer where the decoder will put + * the decoded lzma_index. The old value + * of *dest_index is ignored (not freed). + * \param memlimit How much memory the resulting lzma_index is + * allowed to require. Use UINT64_MAX to + * effectively disable the limiter. + * \param file_size Size of the input .xz file + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_file_info_decoder( + lzma_stream *strm, lzma_index **dest_index, + uint64_t memlimit, uint64_t file_size) + lzma_nothrow; diff --git a/illumos-x86_64/usr/include/lzma/index_hash.h b/illumos-x86_64/usr/include/lzma/index_hash.h new file mode 100644 index 00000000..68f9024e --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/index_hash.h @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/index_hash.h + * \brief Validate Index by using a hash function + * \note Never include this file directly. Use instead. + * + * Hashing makes it possible to use constant amount of memory to validate + * Index of arbitrary size. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + +/** + * \brief Opaque data type to hold the Index hash + */ +typedef struct lzma_index_hash_s lzma_index_hash; + + +/** + * \brief Allocate and initialize a new lzma_index_hash structure + * + * If index_hash is NULL, this function allocates and initializes a new + * lzma_index_hash structure and returns a pointer to it. If allocation + * fails, NULL is returned. + * + * If index_hash is non-NULL, this function reinitializes the lzma_index_hash + * structure and returns the same pointer. In this case, return value cannot + * be NULL or a different pointer than the index_hash that was given as + * an argument. + * + * \param index_hash Pointer to a lzma_index_hash structure or NULL. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return Initialized lzma_index_hash structure on success or + * NULL on failure. + */ +extern LZMA_API(lzma_index_hash *) lzma_index_hash_init( + lzma_index_hash *index_hash, const lzma_allocator *allocator) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Deallocate lzma_index_hash structure + * + * \param index_hash Pointer to a lzma_index_hash structure to free. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + */ +extern LZMA_API(void) lzma_index_hash_end( + lzma_index_hash *index_hash, const lzma_allocator *allocator) + lzma_nothrow; + + +/** + * \brief Add a new Record to an Index hash + * + * \param index_hash Pointer to a lzma_index_hash structure + * \param unpadded_size Unpadded Size of a Block + * \param uncompressed_size Uncompressed Size of a Block + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_DATA_ERROR: Compressed or uncompressed size of the + * Stream or size of the Index field would grow too big. + * - LZMA_PROG_ERROR: Invalid arguments or this function is being + * used when lzma_index_hash_decode() has already been used. + */ +extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash, + lzma_vli unpadded_size, lzma_vli uncompressed_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Decode and validate the Index field + * + * After telling the sizes of all Blocks with lzma_index_hash_append(), + * the actual Index field is decoded with this function. Specifically, + * once decoding of the Index field has been started, no more Records + * can be added using lzma_index_hash_append(). + * + * This function doesn't use lzma_stream structure to pass the input data. + * Instead, the input buffer is specified using three arguments. This is + * because it matches better the internal APIs of liblzma. + * + * \param index_hash Pointer to a lzma_index_hash structure + * \param in Pointer to the beginning of the input buffer + * \param[out] in_pos in[*in_pos] is the next byte to process + * \param in_size in[in_size] is the first byte not to process + * + * \return Possible lzma_ret values: + * - LZMA_OK: So far good, but more input is needed. + * - LZMA_STREAM_END: Index decoded successfully and it matches + * the Records given with lzma_index_hash_append(). + * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the + * information given with lzma_index_hash_append(). + * - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size. + * - LZMA_PROG_ERROR + */ +extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash, + const uint8_t *in, size_t *in_pos, size_t in_size) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Get the size of the Index field as bytes + * + * This is needed to verify the Backward Size field in the Stream Footer. + * + * \param index_hash Pointer to a lzma_index_hash structure + * + * \return Size of the Index field in bytes. + */ +extern LZMA_API(lzma_vli) lzma_index_hash_size( + const lzma_index_hash *index_hash) + lzma_nothrow lzma_attr_pure; diff --git a/illumos-x86_64/usr/include/lzma/lzma12.h b/illumos-x86_64/usr/include/lzma/lzma12.h new file mode 100644 index 00000000..fec3e0da --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/lzma12.h @@ -0,0 +1,568 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/lzma12.h + * \brief LZMA1 and LZMA2 filters + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief LZMA1 Filter ID (for raw encoder/decoder only, not in .xz) + * + * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils, + * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from + * accidentally using LZMA when they actually want LZMA2. + */ +#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001) + +/** + * \brief LZMA1 Filter ID with extended options (for raw encoder/decoder) + * + * This is like LZMA_FILTER_LZMA1 but with this ID a few extra options + * are supported in the lzma_options_lzma structure: + * + * - A flag to tell the encoder if the end of payload marker (EOPM) alias + * end of stream (EOS) marker must be written at the end of the stream. + * In contrast, LZMA_FILTER_LZMA1 always writes the end marker. + * + * - Decoder needs to be told the uncompressed size of the stream + * or that it is unknown (using the special value UINT64_MAX). + * If the size is known, a flag can be set to allow the presence of + * the end marker anyway. In contrast, LZMA_FILTER_LZMA1 always + * behaves as if the uncompressed size was unknown. + * + * This allows handling file formats where LZMA1 streams are used but where + * the end marker isn't allowed or where it might not (always) be present. + * This extended LZMA1 functionality is provided as a Filter ID for raw + * encoder and decoder instead of adding new encoder and decoder initialization + * functions because this way it is possible to also use extra filters, + * for example, LZMA_FILTER_X86 in a filter chain with LZMA_FILTER_LZMA1EXT, + * which might be needed to handle some file formats. + */ +#define LZMA_FILTER_LZMA1EXT LZMA_VLI_C(0x4000000000000002) + +/** + * \brief LZMA2 Filter ID + * + * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds + * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion + * when trying to compress incompressible data), possibility to change + * lc/lp/pb in the middle of encoding, and some other internal improvements. + */ +#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21) + + +/** + * \brief Match finders + * + * Match finder has major effect on both speed and compression ratio. + * Usually hash chains are faster than binary trees. + * + * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better + * choice, because binary trees get much higher compression ratio penalty + * with LZMA_SYNC_FLUSH. + * + * The memory usage formulas are only rough estimates, which are closest to + * reality when dict_size is a power of two. The formulas are more complex + * in reality, and can also change a little between liblzma versions. Use + * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage. + */ +typedef enum { + LZMA_MF_HC3 = 0x03, + /**< + * \brief Hash Chain with 2- and 3-byte hashing + * + * Minimum nice_len: 3 + * + * Memory usage: + * - dict_size <= 16 MiB: dict_size * 7.5 + * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB + */ + + LZMA_MF_HC4 = 0x04, + /**< + * \brief Hash Chain with 2-, 3-, and 4-byte hashing + * + * Minimum nice_len: 4 + * + * Memory usage: + * - dict_size <= 32 MiB: dict_size * 7.5 + * - dict_size > 32 MiB: dict_size * 6.5 + */ + + LZMA_MF_BT2 = 0x12, + /**< + * \brief Binary Tree with 2-byte hashing + * + * Minimum nice_len: 2 + * + * Memory usage: dict_size * 9.5 + */ + + LZMA_MF_BT3 = 0x13, + /**< + * \brief Binary Tree with 2- and 3-byte hashing + * + * Minimum nice_len: 3 + * + * Memory usage: + * - dict_size <= 16 MiB: dict_size * 11.5 + * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB + */ + + LZMA_MF_BT4 = 0x14 + /**< + * \brief Binary Tree with 2-, 3-, and 4-byte hashing + * + * Minimum nice_len: 4 + * + * Memory usage: + * - dict_size <= 32 MiB: dict_size * 11.5 + * - dict_size > 32 MiB: dict_size * 10.5 + */ +} lzma_match_finder; + + +/** + * \brief Test if given match finder is supported + * + * It is safe to call this with a value that isn't listed in + * lzma_match_finder enumeration; the return value will be false. + * + * There is no way to list which match finders are available in this + * particular liblzma version and build. It would be useless, because + * a new match finder, which the application developer wasn't aware, + * could require giving additional options to the encoder that the older + * match finders don't need. + * + * \param match_finder Match finder ID + * + * \return lzma_bool: + * - true if the match finder is supported by this liblzma build. + * - false otherwise. + */ +extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder) + lzma_nothrow lzma_attr_const; + + +/** + * \brief Compression modes + * + * This selects the function used to analyze the data produced by the match + * finder. + */ +typedef enum { + LZMA_MODE_FAST = 1, + /**< + * \brief Fast compression + * + * Fast mode is usually at its best when combined with + * a hash chain match finder. + */ + + LZMA_MODE_NORMAL = 2 + /**< + * \brief Normal compression + * + * This is usually notably slower than fast mode. Use this + * together with binary tree match finders to expose the + * full potential of the LZMA1 or LZMA2 encoder. + */ +} lzma_mode; + + +/** + * \brief Test if given compression mode is supported + * + * It is safe to call this with a value that isn't listed in lzma_mode + * enumeration; the return value will be false. + * + * There is no way to list which modes are available in this particular + * liblzma version and build. It would be useless, because a new compression + * mode, which the application developer wasn't aware, could require giving + * additional options to the encoder that the older modes don't need. + * + * \param mode Mode ID. + * + * \return lzma_bool: + * - true if the compression mode is supported by this liblzma + * build. + * - false otherwise. + */ +extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode) + lzma_nothrow lzma_attr_const; + + +/** + * \brief Options specific to the LZMA1 and LZMA2 filters + * + * Since LZMA1 and LZMA2 share most of the code, it's simplest to share + * the options structure too. For encoding, all but the reserved variables + * need to be initialized unless specifically mentioned otherwise. + * lzma_lzma_preset() can be used to get a good starting point. + * + * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and + * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb. + */ +typedef struct { + /** + * \brief Dictionary size in bytes + * + * Dictionary size indicates how many bytes of the recently processed + * uncompressed data is kept in memory. One method to reduce size of + * the uncompressed data is to store distance-length pairs, which + * indicate what data to repeat from the dictionary buffer. Thus, + * the bigger the dictionary, the better the compression ratio + * usually is. + * + * Maximum size of the dictionary depends on multiple things: + * - Memory usage limit + * - Available address space (not a problem on 64-bit systems) + * - Selected match finder (encoder only) + * + * Currently the maximum dictionary size for encoding is 1.5 GiB + * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit + * systems for certain match finder implementation reasons. In the + * future, there may be match finders that support bigger + * dictionaries. + * + * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e. + * UINT32_MAX), so increasing the maximum dictionary size of the + * encoder won't cause problems for old decoders. + * + * Because extremely small dictionaries sizes would have unneeded + * overhead in the decoder, the minimum dictionary size is 4096 bytes. + * + * \note When decoding, too big dictionary does no other harm + * than wasting memory. + */ + uint32_t dict_size; +# define LZMA_DICT_SIZE_MIN UINT32_C(4096) +# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23) + + /** + * \brief Pointer to an initial dictionary + * + * It is possible to initialize the LZ77 history window using + * a preset dictionary. It is useful when compressing many + * similar, relatively small chunks of data independently from + * each other. The preset dictionary should contain typical + * strings that occur in the files being compressed. The most + * probable strings should be near the end of the preset dictionary. + * + * This feature should be used only in special situations. For + * now, it works correctly only with raw encoding and decoding. + * Currently none of the container formats supported by + * liblzma allow preset dictionary when decoding, thus if + * you create a .xz or .lzma file with preset dictionary, it + * cannot be decoded with the regular decoder functions. In the + * future, the .xz format will likely get support for preset + * dictionary though. + */ + const uint8_t *preset_dict; + + /** + * \brief Size of the preset dictionary + * + * Specifies the size of the preset dictionary. If the size is + * bigger than dict_size, only the last dict_size bytes are + * processed. + * + * This variable is read only when preset_dict is not NULL. + * If preset_dict is not NULL but preset_dict_size is zero, + * no preset dictionary is used (identical to only setting + * preset_dict to NULL). + */ + uint32_t preset_dict_size; + + /** + * \brief Number of literal context bits + * + * How many of the highest bits of the previous uncompressed + * eight-bit byte (also known as 'literal') are taken into + * account when predicting the bits of the next literal. + * + * E.g. in typical English text, an upper-case letter is + * often followed by a lower-case letter, and a lower-case + * letter is usually followed by another lower-case letter. + * In the US-ASCII character set, the highest three bits are 010 + * for upper-case letters and 011 for lower-case letters. + * When lc is at least 3, the literal coding can take advantage of + * this property in the uncompressed data. + * + * There is a limit that applies to literal context bits and literal + * position bits together: lc + lp <= 4. Without this limit the + * decoding could become very slow, which could have security related + * results in some cases like email servers doing virus scanning. + * This limit also simplifies the internal implementation in liblzma. + * + * There may be LZMA1 streams that have lc + lp > 4 (maximum possible + * lc would be 8). It is not possible to decode such streams with + * liblzma. + */ + uint32_t lc; +# define LZMA_LCLP_MIN 0 +# define LZMA_LCLP_MAX 4 +# define LZMA_LC_DEFAULT 3 + + /** + * \brief Number of literal position bits + * + * lp affects what kind of alignment in the uncompressed data is + * assumed when encoding literals. A literal is a single 8-bit byte. + * See pb below for more information about alignment. + */ + uint32_t lp; +# define LZMA_LP_DEFAULT 0 + + /** + * \brief Number of position bits + * + * pb affects what kind of alignment in the uncompressed data is + * assumed in general. The default means four-byte alignment + * (2^ pb =2^2=4), which is often a good choice when there's + * no better guess. + * + * When the alignment is known, setting pb accordingly may reduce + * the file size a little. E.g. with text files having one-byte + * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can + * improve compression slightly. For UTF-16 text, pb=1 is a good + * choice. If the alignment is an odd number like 3 bytes, pb=0 + * might be the best choice. + * + * Even though the assumed alignment can be adjusted with pb and + * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment. + * It might be worth taking into account when designing file formats + * that are likely to be often compressed with LZMA1 or LZMA2. + */ + uint32_t pb; +# define LZMA_PB_MIN 0 +# define LZMA_PB_MAX 4 +# define LZMA_PB_DEFAULT 2 + + /** Compression mode */ + lzma_mode mode; + + /** + * \brief Nice length of a match + * + * This determines how many bytes the encoder compares from the match + * candidates when looking for the best match. Once a match of at + * least nice_len bytes long is found, the encoder stops looking for + * better candidates and encodes the match. (Naturally, if the found + * match is actually longer than nice_len, the actual length is + * encoded; it's not truncated to nice_len.) + * + * Bigger values usually increase the compression ratio and + * compression time. For most files, 32 to 128 is a good value, + * which gives very good compression ratio at good speed. + * + * The exact minimum value depends on the match finder. The maximum + * is 273, which is the maximum length of a match that LZMA1 and + * LZMA2 can encode. + */ + uint32_t nice_len; + + /** Match finder ID */ + lzma_match_finder mf; + + /** + * \brief Maximum search depth in the match finder + * + * For every input byte, match finder searches through the hash chain + * or binary tree in a loop, each iteration going one step deeper in + * the chain or tree. The searching stops if + * - a match of at least nice_len bytes long is found; + * - all match candidates from the hash chain or binary tree have + * been checked; or + * - maximum search depth is reached. + * + * Maximum search depth is needed to prevent the match finder from + * wasting too much time in case there are lots of short match + * candidates. On the other hand, stopping the search before all + * candidates have been checked can reduce compression ratio. + * + * Setting depth to zero tells liblzma to use an automatic default + * value, that depends on the selected match finder and nice_len. + * The default is in the range [4, 200] or so (it may vary between + * liblzma versions). + * + * Using a bigger depth value than the default can increase + * compression ratio in some cases. There is no strict maximum value, + * but high values (thousands or millions) should be used with care: + * the encoder could remain fast enough with typical input, but + * malicious input could cause the match finder to slow down + * dramatically, possibly creating a denial of service attack. + */ + uint32_t depth; + + /** + * \brief For LZMA_FILTER_LZMA1EXT: Extended flags + * + * This is used only with LZMA_FILTER_LZMA1EXT. + * + * Currently only one flag is supported, LZMA_LZMA1EXT_ALLOW_EOPM: + * + * - Encoder: If the flag is set, then end marker is written just + * like it is with LZMA_FILTER_LZMA1. Without this flag the + * end marker isn't written and the application has to store + * the uncompressed size somewhere outside the compressed stream. + * To decompress streams without the end marker, the application + * has to set the correct uncompressed size in ext_size_low and + * ext_size_high. + * + * - Decoder: If the uncompressed size in ext_size_low and + * ext_size_high is set to the special value UINT64_MAX + * (indicating unknown uncompressed size) then this flag is + * ignored and the end marker must always be present, that is, + * the behavior is identical to LZMA_FILTER_LZMA1. + * + * Otherwise, if this flag isn't set, then the input stream + * must not have the end marker; if the end marker is detected + * then it will result in LZMA_DATA_ERROR. This is useful when + * it is known that the stream must not have the end marker and + * strict validation is wanted. + * + * If this flag is set, then it is autodetected if the end marker + * is present after the specified number of uncompressed bytes + * has been decompressed (ext_size_low and ext_size_high). The + * end marker isn't allowed in any other position. This behavior + * is useful when uncompressed size is known but the end marker + * may or may not be present. This is the case, for example, + * in .7z files (valid .7z files that have the end marker in + * LZMA1 streams are rare but they do exist). + */ + uint32_t ext_flags; +# define LZMA_LZMA1EXT_ALLOW_EOPM UINT32_C(0x01) + + /** + * \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (low bits) + * + * The 64-bit uncompressed size is needed for decompression with + * LZMA_FILTER_LZMA1EXT. The size is ignored by the encoder. + * + * The special value UINT64_MAX indicates that the uncompressed size + * is unknown and that the end of payload marker (also known as + * end of stream marker) must be present to indicate the end of + * the LZMA1 stream. Any other value indicates the expected + * uncompressed size of the LZMA1 stream. (If LZMA1 was used together + * with filters that change the size of the data then the uncompressed + * size of the LZMA1 stream could be different than the final + * uncompressed size of the filtered stream.) + * + * ext_size_low holds the least significant 32 bits of the + * uncompressed size. The most significant 32 bits must be set + * in ext_size_high. The macro lzma_set_ext_size(opt_lzma, u64size) + * can be used to set these members. + * + * The 64-bit uncompressed size is split into two uint32_t variables + * because there were no reserved uint64_t members and using the + * same options structure for LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA1EXT, + * and LZMA_FILTER_LZMA2 was otherwise more convenient than having + * a new options structure for LZMA_FILTER_LZMA1EXT. (Replacing two + * uint32_t members with one uint64_t changes the ABI on some systems + * as the alignment of this struct can increase from 4 bytes to 8.) + */ + uint32_t ext_size_low; + + /** + * \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (high bits) + * + * This holds the most significant 32 bits of the uncompressed size. + */ + uint32_t ext_size_high; + + /* + * Reserved space to allow possible future extensions without + * breaking the ABI. You should not touch these, because the names + * of these variables may change. These are and will never be used + * with the currently supported options, so it is safe to leave these + * uninitialized. + */ + + /** \private Reserved member. */ + uint32_t reserved_int4; + + /** \private Reserved member. */ + uint32_t reserved_int5; + + /** \private Reserved member. */ + uint32_t reserved_int6; + + /** \private Reserved member. */ + uint32_t reserved_int7; + + /** \private Reserved member. */ + uint32_t reserved_int8; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum2; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum3; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum4; + + /** \private Reserved member. */ + void *reserved_ptr1; + + /** \private Reserved member. */ + void *reserved_ptr2; + +} lzma_options_lzma; + + +/** + * \brief Macro to set the 64-bit uncompressed size in ext_size_* + * + * This might be convenient when decoding using LZMA_FILTER_LZMA1EXT. + * This isn't used with LZMA_FILTER_LZMA1 or LZMA_FILTER_LZMA2. + */ +#define lzma_set_ext_size(opt_lzma2, u64size) \ +do { \ + (opt_lzma2).ext_size_low = (uint32_t)(u64size); \ + (opt_lzma2).ext_size_high = (uint32_t)((uint64_t)(u64size) >> 32); \ +} while (0) + + +/** + * \brief Set a compression preset to lzma_options_lzma structure + * + * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9 + * of the xz command line tool. In addition, it is possible to bitwise-or + * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported. + * The flags are defined in container.h, because the flags are used also + * with lzma_easy_encoder(). + * + * The preset levels are subject to changes between liblzma versions. + * + * This function is available only if LZMA1 or LZMA2 encoder has been enabled + * when building liblzma. + * + * If features (like certain match finders) have been disabled at build time, + * then the function may return success (false) even though the resulting + * LZMA1/LZMA2 options may not be usable for encoder initialization + * (LZMA_OPTIONS_ERROR). + * + * \param[out] options Pointer to LZMA1 or LZMA2 options to be filled + * \param preset Preset level bitwse-ORed with preset flags + * + * \return lzma_bool: + * - true if the preset is not supported (failure). + * - false otherwise (success). + */ +extern LZMA_API(lzma_bool) lzma_lzma_preset( + lzma_options_lzma *options, uint32_t preset) lzma_nothrow; diff --git a/illumos-x86_64/usr/include/lzma/stream_flags.h b/illumos-x86_64/usr/include/lzma/stream_flags.h new file mode 100644 index 00000000..a33fe468 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/stream_flags.h @@ -0,0 +1,265 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/stream_flags.h + * \brief .xz Stream Header and Stream Footer encoder and decoder + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Size of Stream Header and Stream Footer + * + * Stream Header and Stream Footer have the same size and they are not + * going to change even if a newer version of the .xz file format is + * developed in future. + */ +#define LZMA_STREAM_HEADER_SIZE 12 + + +/** + * \brief Options for encoding/decoding Stream Header and Stream Footer + */ +typedef struct { + /** + * \brief Stream Flags format version + * + * To prevent API and ABI breakages if new features are needed in + * Stream Header or Stream Footer, a version number is used to + * indicate which members in this structure are in use. For now, + * version must always be zero. With non-zero version, the + * lzma_stream_header_encode() and lzma_stream_footer_encode() + * will return LZMA_OPTIONS_ERROR. + * + * lzma_stream_header_decode() and lzma_stream_footer_decode() + * will always set this to the lowest value that supports all the + * features indicated by the Stream Flags field. The application + * must check that the version number set by the decoding functions + * is supported by the application. Otherwise it is possible that + * the application will decode the Stream incorrectly. + */ + uint32_t version; + + /** + * \brief Backward Size + * + * Backward Size must be a multiple of four bytes. In this Stream + * format version, Backward Size is the size of the Index field. + * + * Backward Size isn't actually part of the Stream Flags field, but + * it is convenient to include in this structure anyway. Backward + * Size is present only in the Stream Footer. There is no need to + * initialize backward_size when encoding Stream Header. + * + * lzma_stream_header_decode() always sets backward_size to + * LZMA_VLI_UNKNOWN so that it is convenient to use + * lzma_stream_flags_compare() when both Stream Header and Stream + * Footer have been decoded. + */ + lzma_vli backward_size; + + /** + * \brief Minimum value for lzma_stream_flags.backward_size + */ +# define LZMA_BACKWARD_SIZE_MIN 4 + + /** + * \brief Maximum value for lzma_stream_flags.backward_size + */ +# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34) + + /** + * \brief Check ID + * + * This indicates the type of the integrity check calculated from + * uncompressed data. + */ + lzma_check check; + + /* + * Reserved space to allow possible future extensions without + * breaking the ABI. You should not touch these, because the + * names of these variables may change. + * + * (We will never be able to use all of these since Stream Flags + * is just two bytes plus Backward Size of four bytes. But it's + * nice to have the proper types when they are needed.) + */ + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum2; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum3; + + /** \private Reserved member. */ + lzma_reserved_enum reserved_enum4; + + /** \private Reserved member. */ + lzma_bool reserved_bool1; + + /** \private Reserved member. */ + lzma_bool reserved_bool2; + + /** \private Reserved member. */ + lzma_bool reserved_bool3; + + /** \private Reserved member. */ + lzma_bool reserved_bool4; + + /** \private Reserved member. */ + lzma_bool reserved_bool5; + + /** \private Reserved member. */ + lzma_bool reserved_bool6; + + /** \private Reserved member. */ + lzma_bool reserved_bool7; + + /** \private Reserved member. */ + lzma_bool reserved_bool8; + + /** \private Reserved member. */ + uint32_t reserved_int1; + + /** \private Reserved member. */ + uint32_t reserved_int2; + +} lzma_stream_flags; + + +/** + * \brief Encode Stream Header + * + * \param options Stream Header options to be encoded. + * options->backward_size is ignored and doesn't + * need to be initialized. + * \param[out] out Beginning of the output buffer of + * LZMA_STREAM_HEADER_SIZE bytes. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_OPTIONS_ERROR: options->version is not supported by + * this liblzma version. + * - LZMA_PROG_ERROR: Invalid options. + */ +extern LZMA_API(lzma_ret) lzma_stream_header_encode( + const lzma_stream_flags *options, uint8_t *out) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Encode Stream Footer + * + * \param options Stream Footer options to be encoded. + * \param[out] out Beginning of the output buffer of + * LZMA_STREAM_HEADER_SIZE bytes. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_OPTIONS_ERROR: options->version is not supported by + * this liblzma version. + * - LZMA_PROG_ERROR: Invalid options. + */ +extern LZMA_API(lzma_ret) lzma_stream_footer_encode( + const lzma_stream_flags *options, uint8_t *out) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Decode Stream Header + * + * options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to + * help comparing Stream Flags from Stream Header and Stream Footer with + * lzma_stream_flags_compare(). + * + * \note When decoding .xz files that contain multiple Streams, it may + * make sense to print "file format not recognized" only if + * decoding of the Stream Header of the \a first Stream gives + * LZMA_FORMAT_ERROR. If non-first Stream Header gives + * LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is + * probably more appropriate. + * For example, the Stream decoder in liblzma uses + * LZMA_DATA_ERROR if LZMA_FORMAT_ERROR is returned by + * lzma_stream_header_decode() when decoding non-first Stream. + * + * \param[out] options Target for the decoded Stream Header options. + * \param in Beginning of the input buffer of + * LZMA_STREAM_HEADER_SIZE bytes. + * + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. + * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given + * buffer cannot be Stream Header. + * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header + * is corrupt. + * - LZMA_OPTIONS_ERROR: Unsupported options are present + * in the header. + */ +extern LZMA_API(lzma_ret) lzma_stream_header_decode( + lzma_stream_flags *options, const uint8_t *in) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Decode Stream Footer + * + * \note If Stream Header was already decoded successfully, but + * decoding Stream Footer returns LZMA_FORMAT_ERROR, the + * application should probably report some other error message + * than "file format not recognized". The file likely + * is corrupt (possibly truncated). The Stream decoder in liblzma + * uses LZMA_DATA_ERROR in this situation. + * + * \param[out] options Target for the decoded Stream Footer options. + * \param in Beginning of the input buffer of + * LZMA_STREAM_HEADER_SIZE bytes. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. + * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given + * buffer cannot be Stream Footer. + * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer + * is corrupt. + * - LZMA_OPTIONS_ERROR: Unsupported options are present + * in Stream Footer. + */ +extern LZMA_API(lzma_ret) lzma_stream_footer_decode( + lzma_stream_flags *options, const uint8_t *in) + lzma_nothrow lzma_attr_warn_unused_result; + + +/** + * \brief Compare two lzma_stream_flags structures + * + * backward_size values are compared only if both are not + * LZMA_VLI_UNKNOWN. + * + * \param a Pointer to lzma_stream_flags structure + * \param b Pointer to lzma_stream_flags structure + * + * \return Possible lzma_ret values: + * - LZMA_OK: Both are equal. If either had backward_size set + * to LZMA_VLI_UNKNOWN, backward_size values were not + * compared or validated. + * - LZMA_DATA_ERROR: The structures differ. + * - LZMA_OPTIONS_ERROR: version in either structure is greater + * than the maximum supported version (currently zero). + * - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or + * backward_size. + */ +extern LZMA_API(lzma_ret) lzma_stream_flags_compare( + const lzma_stream_flags *a, const lzma_stream_flags *b) + lzma_nothrow lzma_attr_pure; diff --git a/illumos-x86_64/usr/include/lzma/version.h b/illumos-x86_64/usr/include/lzma/version.h new file mode 100644 index 00000000..86b35563 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/version.h @@ -0,0 +1,134 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/version.h + * \brief Version number + * \note Never include this file directly. Use instead. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** \brief Major version number of the liblzma release. */ +#define LZMA_VERSION_MAJOR 5 + +/** \brief Minor version number of the liblzma release. */ +#define LZMA_VERSION_MINOR 8 + +/** \brief Patch version number of the liblzma release. */ +#define LZMA_VERSION_PATCH 1 + +/** + * \brief Version stability marker + * + * This will always be one of three values: + * - LZMA_VERSION_STABILITY_ALPHA + * - LZMA_VERSION_STABILITY_BETA + * - LZMA_VERSION_STABILITY_STABLE + */ +#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE + +/** \brief Commit version number of the liblzma release */ +#ifndef LZMA_VERSION_COMMIT +# define LZMA_VERSION_COMMIT "" +#endif + + +/* + * Map symbolic stability levels to integers. + */ +#define LZMA_VERSION_STABILITY_ALPHA 0 +#define LZMA_VERSION_STABILITY_BETA 1 +#define LZMA_VERSION_STABILITY_STABLE 2 + + +/** + * \brief Compile-time version number + * + * The version number is of format xyyyzzzs where + * - x = major + * - yyy = minor + * - zzz = revision + * - s indicates stability: 0 = alpha, 1 = beta, 2 = stable + * + * The same xyyyzzz triplet is never reused with different stability levels. + * For example, if 5.1.0alpha has been released, there will never be 5.1.0beta + * or 5.1.0 stable. + * + * \note The version number of liblzma has nothing to with + * the version number of Igor Pavlov's LZMA SDK. + */ +#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \ + + LZMA_VERSION_MINOR * UINT32_C(10000) \ + + LZMA_VERSION_PATCH * UINT32_C(10) \ + + LZMA_VERSION_STABILITY) + + +/* + * Macros to construct the compile-time version string + */ +#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA +# define LZMA_VERSION_STABILITY_STRING "alpha" +#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA +# define LZMA_VERSION_STABILITY_STRING "beta" +#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE +# define LZMA_VERSION_STABILITY_STRING "" +#else +# error Incorrect LZMA_VERSION_STABILITY +#endif + +#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \ + #major "." #minor "." #patch stability commit + +#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \ + LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) + + +/** + * \brief Compile-time version as a string + * + * This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable + * versions don't have any "stable" suffix). In future, a snapshot built + * from source code repository may include an additional suffix, for example + * "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form + * in LZMA_VERSION macro. + */ +#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \ + LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \ + LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \ + LZMA_VERSION_COMMIT) + + +/* #ifndef is needed for use with windres (MinGW-w64 or Cygwin). */ +#ifndef LZMA_H_INTERNAL_RC + +/** + * \brief Run-time version number as an integer + * + * This allows an application to compare if it was built against the same, + * older, or newer version of liblzma that is currently running. + * + * \return The value of LZMA_VERSION macro at the compile time of liblzma + */ +extern LZMA_API(uint32_t) lzma_version_number(void) + lzma_nothrow lzma_attr_const; + + +/** + * \brief Run-time version as a string + * + * This function may be useful to display which version of liblzma an + * application is currently using. + * + * \return Run-time version of liblzma + */ +extern LZMA_API(const char *) lzma_version_string(void) + lzma_nothrow lzma_attr_const; + +#endif diff --git a/illumos-x86_64/usr/include/lzma/vli.h b/illumos-x86_64/usr/include/lzma/vli.h new file mode 100644 index 00000000..6b049021 --- /dev/null +++ b/illumos-x86_64/usr/include/lzma/vli.h @@ -0,0 +1,166 @@ +/* SPDX-License-Identifier: 0BSD */ + +/** + * \file lzma/vli.h + * \brief Variable-length integer handling + * \note Never include this file directly. Use instead. + * + * In the .xz format, most integers are encoded in a variable-length + * representation, which is sometimes called little endian base-128 encoding. + * This saves space when smaller values are more likely than bigger values. + * + * The encoding scheme encodes seven bits to every byte, using minimum + * number of bytes required to represent the given value. Encodings that use + * non-minimum number of bytes are invalid, thus every integer has exactly + * one encoded representation. The maximum number of bits in a VLI is 63, + * thus the vli argument must be less than or equal to UINT64_MAX / 2. You + * should use LZMA_VLI_MAX for clarity. + */ + +/* + * Author: Lasse Collin + */ + +#ifndef LZMA_H_INTERNAL +# error Never include this file directly. Use instead. +#endif + + +/** + * \brief Maximum supported value of a variable-length integer + */ +#define LZMA_VLI_MAX (UINT64_MAX / 2) + +/** + * \brief VLI value to denote that the value is unknown + */ +#define LZMA_VLI_UNKNOWN UINT64_MAX + +/** + * \brief Maximum supported encoded length of variable length integers + */ +#define LZMA_VLI_BYTES_MAX 9 + +/** + * \brief VLI constant suffix + */ +#define LZMA_VLI_C(n) UINT64_C(n) + + +/** + * \brief Variable-length integer type + * + * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is + * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the + * underlying integer type. + * + * lzma_vli will be uint64_t for the foreseeable future. If a bigger size + * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will + * not overflow lzma_vli. This simplifies integer overflow detection. + */ +typedef uint64_t lzma_vli; + + +/** + * \brief Validate a variable-length integer + * + * This is useful to test that application has given acceptable values + * for example in the uncompressed_size and compressed_size variables. + * + * \return True if the integer is representable as a VLI or if it + * indicates an unknown value. False otherwise. + */ +#define lzma_vli_is_valid(vli) \ + ((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN) + + +/** + * \brief Encode a variable-length integer + * + * This function has two modes: single-call and multi-call. Single-call mode + * encodes the whole integer at once; it is an error if the output buffer is + * too small. Multi-call mode saves the position in *vli_pos, and thus it is + * possible to continue encoding if the buffer becomes full before the whole + * integer has been encoded. + * + * \param vli Integer to be encoded + * \param[out] vli_pos How many VLI-encoded bytes have already been written + * out. When starting to encode a new integer in + * multi-call mode, *vli_pos must be set to zero. + * To use single-call encoding, set vli_pos to NULL. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Slightly different return values are used in multi-call and + * single-call modes. + * + * Single-call (vli_pos == NULL): + * - LZMA_OK: Integer successfully encoded. + * - LZMA_PROG_ERROR: Arguments are not sane. This can be due + * to too little output space; single-call mode doesn't use + * LZMA_BUF_ERROR, since the application should have checked + * the encoded size with lzma_vli_size(). + * + * Multi-call (vli_pos != NULL): + * - LZMA_OK: So far all OK, but the integer is not + * completely written out yet. + * - LZMA_STREAM_END: Integer successfully encoded. + * - LZMA_BUF_ERROR: No output space was provided. + * - LZMA_PROG_ERROR: Arguments are not sane. + */ +extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos, + uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; + + +/** + * \brief Decode a variable-length integer + * + * Like lzma_vli_encode(), this function has single-call and multi-call modes. + * + * \param[out] vli Pointer to decoded integer. The decoder will + * initialize it to zero when *vli_pos == 0, so + * application isn't required to initialize *vli. + * \param[out] vli_pos How many bytes have already been decoded. When + * starting to decode a new integer in multi-call + * mode, *vli_pos must be initialized to zero. To + * use single-call decoding, set vli_pos to NULL. + * \param in Beginning of the input buffer + * \param[out] in_pos The next byte will be read from in[*in_pos]. + * \param in_size Size of the input buffer; the first byte that + * won't be read is in[in_size]. + * + * \return Slightly different return values are used in multi-call and + * single-call modes. + * + * Single-call (vli_pos == NULL): + * - LZMA_OK: Integer successfully decoded. + * - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting + * the end of the input buffer before the whole integer was + * decoded; providing no input at all will use LZMA_DATA_ERROR. + * - LZMA_PROG_ERROR: Arguments are not sane. + * + * Multi-call (vli_pos != NULL): + * - LZMA_OK: So far all OK, but the integer is not + * completely decoded yet. + * - LZMA_STREAM_END: Integer successfully decoded. + * - LZMA_DATA_ERROR: Integer is corrupt. + * - LZMA_BUF_ERROR: No input was provided. + * - LZMA_PROG_ERROR: Arguments are not sane. + */ +extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos, + const uint8_t *in, size_t *in_pos, size_t in_size) + lzma_nothrow; + + +/** + * \brief Get the number of bytes required to encode a VLI + * + * \param vli Integer whose encoded size is to be determined + * + * \return Number of bytes on success (1-9). If vli isn't valid, + * zero is returned. + */ +extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli) + lzma_nothrow lzma_attr_pure; diff --git a/illumos-x86_64/usr/include/macros.h b/illumos-x86_64/usr/include/macros.h new file mode 100644 index 00000000..ed4f9226 --- /dev/null +++ b/illumos-x86_64/usr/include/macros.h @@ -0,0 +1,103 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _MACROS_H +#define _MACROS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * numeric() is useful in while's, if's, etc., but don't use *p++ + * max() and min() depend on the types of the operands + * abs() is absolute value + */ +#define numeric(c) ((c) >= '0' && (c) <= '9') +#define max(a, b) ((a) < (b) ? (b) : (a)) +#define min(a, b) ((a) > (b) ? (b) : (a)) +#define abs(x) ((x) >= 0 ? (x) : -(x)) + +#define compare(str1, str2) strcmp((str1), (str2)) +#define equal(str1, str2) (strcmp((str1), (str2)) == 0) +#define length(str) strlen(str) +#define size(str) (strlen(str) + 1) + +/* + * The global variable Statbuf is available for use as a stat(II) + * structure. Note that "stat.h" is included here and should + * not be included elsewhere. + * Exists(file) returns 0 if the file does not exist; + * the flags word if it does (the flags word is always non-zero). + */ + +extern struct stat Statbuf; +#define exists(file) (stat(file, &Statbuf) < 0 ? 0 : Statbuf.st_mode) + +/* + * SAVE() and RSTR() use local data in nested blocks. + * Make sure that they nest cleanly. + */ +#define SAVE(name, place) { int place = name; +#define RSTR(name, place) name = place; } + +/* + * Use: DEBUG(sum,d) which becomes fprintf(stderr,"sum = %d\n",sum) + */ +#define DEBUG(var, type) fprintf(stderr, #var "= %" #type "\n", var) + +/* + * Use of ERRABORT() will cause libS.a internal + * errors to cause aborts + */ +#define ERRABORT() _error() { abort(); } + +/* + * Use of USXALLOC() is required to force all calls to alloc() + * (e.g., from libS.a) to call xalloc(). + */ +#define NONBLANK(p) while (*(p) == ' ' || *(p) == '\t') (p)++ + +/* + * A global null string. + */ +extern char Null[1]; + +/* + * A global error message string. + */ +extern char Error[128]; + +#ifdef __cplusplus +} +#endif + +#endif /* _MACROS_H */ diff --git a/illumos-x86_64/usr/include/maillock.h b/illumos-x86_64/usr/include/maillock.h new file mode 100644 index 00000000..ed59a1e5 --- /dev/null +++ b/illumos-x86_64/usr/include/maillock.h @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright (c) 1999, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _MAILLOCK_H +#define _MAILLOCK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAILDIR "/var/mail/" +#define SAVEDIR "/var/mail/:saved/" + +#define PATHSIZE 1024 /* maximum path length of a lock file */ +#define L_SUCCESS 0 +#define L_NAMELEN 1 /* recipient name > 13 chars */ +#define L_TMPLOCK 2 /* problem creating temp lockfile */ +#define L_TMPWRITE 3 /* problem writing pid into temp lockfile */ +#define L_MAXTRYS 4 /* cannot link to lockfile after N tries */ +#define L_ERROR 5 /* Something other than EEXIST happened */ +#define L_MANLOCK 6 /* cannot set mandatory lock on temp lockfile */ + +#if defined(__STDC__) +extern int maillock(char *user, int retrycnt); +extern void mailunlock(void); +extern void touchlock(void); +#else +extern int maillock(); +extern void mailunlock(); +extern void touchlock(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _MAILLOCK_H */ diff --git a/illumos-x86_64/usr/include/malloc.h b/illumos-x86_64/usr/include/malloc.h new file mode 100644 index 00000000..67dd7171 --- /dev/null +++ b/illumos-x86_64/usr/include/malloc.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _MALLOC_H +#define _MALLOC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Constants defining mallopt operations + */ +#define M_MXFAST 1 /* set size of blocks to be fast */ +#define M_NLBLKS 2 /* set number of block in a holding block */ +#define M_GRAIN 3 /* set number of sizes mapped to one, for */ + /* small blocks */ +#define M_KEEP 4 /* retain contents of block after a free */ + /* until another allocation */ +/* + * structure filled by + */ +struct mallinfo { + unsigned long arena; /* total space in arena */ + unsigned long ordblks; /* number of ordinary blocks */ + unsigned long smblks; /* number of small blocks */ + unsigned long hblks; /* number of holding blocks */ + unsigned long hblkhd; /* space in holding block headers */ + unsigned long usmblks; /* space in small blocks in use */ + unsigned long fsmblks; /* space in free small blocks */ + unsigned long uordblks; /* space in ordinary blocks in use */ + unsigned long fordblks; /* space in free ordinary blocks */ + unsigned long keepcost; /* cost of enabling keep option */ +}; + +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG3) +#if __cplusplus >= 199711L +namespace std { +#endif + +void *malloc(size_t); +void free(void *); +void *realloc(void *, size_t); +void *calloc(size_t, size_t); + +#if __cplusplus >= 199711L +} /* end of namespace std */ + +using std::malloc; +using std::free; +using std::realloc; +using std::calloc; +#endif /* __cplusplus >= 199711L */ +#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || ... */ + +int mallopt(int, int); +struct mallinfo mallinfo(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _MALLOC_H */ diff --git a/illumos-x86_64/usr/include/math.h b/illumos-x86_64/usr/include/math.h new file mode 100644 index 00000000..3cf2d965 --- /dev/null +++ b/illumos-x86_64/usr/include/math.h @@ -0,0 +1,348 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2014 Garrett D'Amore + */ + +#ifndef _MATH_H +#define _MATH_H + +#include +#include + +#if __cplusplus >= 199711L +using std::abs; +using std::acos; +using std::asin; +using std::atan2; +using std::atan; +using std::ceil; +using std::cos; +using std::cosh; +using std::exp; +using std::fabs; +using std::floor; +using std::fmod; +using std::frexp; +using std::ldexp; +using std::log10; +using std::log; +using std::modf; +using std::pow; +using std::sin; +using std::sinh; +using std::sqrt; +using std::tan; +using std::tanh; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__cplusplus) +#define exception __math_exception +#endif + +#if defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) || \ + !defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE) +/* + * SVID & X/Open + */ +#define M_E 2.7182818284590452354 +#define M_LOG2E 1.4426950408889634074 +#define M_LOG10E 0.43429448190325182765 +#define M_LN2 0.69314718055994530942 +#define M_LN10 2.30258509299404568402 +#define M_PI 3.14159265358979323846 +#define M_PI_2 1.57079632679489661923 +#define M_PI_4 0.78539816339744830962 +#define M_1_PI 0.31830988618379067154 +#define M_2_PI 0.63661977236758134308 +#define M_2_SQRTPI 1.12837916709551257390 +#define M_SQRT2 1.41421356237309504880 +#define M_SQRT1_2 0.70710678118654752440 + +extern int signgam; + +#define MAXFLOAT ((float)3.40282346638528860e+38) + +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) +/* + * SVID + */ +enum version {libm_ieee = -1, c_issue_4, ansi_1, strict_ansi}; + +#ifdef __STDC__ +extern const enum version _lib_version; +#else +extern enum version _lib_version; +#endif + +struct exception { + int type; + char *name; + double arg1; + double arg2; + double retval; +}; + +#define HUGE MAXFLOAT + +#define _ABS(x) ((x) < 0 ? -(x) : (x)) + +#define _REDUCE(TYPE, X, XN, C1, C2) { \ + double x1 = (double)(TYPE)X, x2 = X - x1; \ + X = x1 - (XN) * (C1); X += x2; X -= (XN) * (C2); } + +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +#define _POLY1(x, c) ((c)[0] * (x) + (c)[1]) +#define _POLY2(x, c) (_POLY1((x), (c)) * (x) + (c)[2]) +#define _POLY3(x, c) (_POLY2((x), (c)) * (x) + (c)[3]) +#define _POLY4(x, c) (_POLY3((x), (c)) * (x) + (c)[4]) +#define _POLY5(x, c) (_POLY4((x), (c)) * (x) + (c)[5]) +#define _POLY6(x, c) (_POLY5((x), (c)) * (x) + (c)[6]) +#define _POLY7(x, c) (_POLY6((x), (c)) * (x) + (c)[7]) +#define _POLY8(x, c) (_POLY7((x), (c)) * (x) + (c)[8]) +#define _POLY9(x, c) (_POLY8((x), (c)) * (x) + (c)[9]) +#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */ + +/* + * SVID & X/Open + */ +/* BEGIN adopted by C99 */ +extern double erf(double); +extern double erfc(double); +extern double hypot(double, double); +extern double lgamma(double); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(erf, erfc, hypot) +#pragma does_not_write_global_data(erf, erfc, hypot) +#pragma no_side_effect(erf, erfc, hypot) +#endif + +#if !defined(_STDC_C99) && _XOPEN_SOURCE - 0 < 600 && !defined(__C99FEATURES__) +extern int isnan(double); + +#pragma does_not_read_global_data(isnan) +#pragma does_not_write_global_data(isnan) +#pragma no_side_effect(isnan) +#endif +/* END adopted by C99 */ + +#if defined(__EXTENSIONS__) || _XOPEN_SOURCE - 0 < 600 +extern double gamma(double); /* deprecated; use lgamma */ +#endif +extern double j0(double); +extern double j1(double); +extern double jn(int, double); +extern double y0(double); +extern double y1(double); +extern double yn(int, double); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(j0, j1, jn, y0, y1, yn) +#pragma does_not_write_global_data(j0, j1, jn, y0, y1, yn) +#pragma no_side_effect(j0, j1, jn, y0, y1, yn) +#endif +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || \ + _XOPEN_SOURCE - 0 >= 500 || \ + defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1 +/* + * SVID & XPG 4.2/5 - removed from XPG7. + */ +#if !defined(_STRICT_SYMBOLS) || !defined(_XPG7) +extern double scalb(double, double); +#endif + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(scalb) +#pragma does_not_write_global_data(scalb) +#pragma no_side_effect(scalb) +#endif + +/* BEGIN adopted by C99 */ +extern double acosh(double); +extern double asinh(double); +extern double atanh(double); +extern double cbrt(double); +extern double logb(double); +extern double nextafter(double, double); +extern double remainder(double, double); + +/* + * XPG 4.2/5 + */ +extern double expm1(double); +extern int ilogb(double); +extern double log1p(double); +extern double rint(double); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(acosh, asinh, atanh, cbrt) +#pragma does_not_read_global_data(logb, nextafter, remainder) +#pragma does_not_read_global_data(expm1, ilogb, log1p, rint) +#pragma does_not_write_global_data(acosh, asinh, atanh, cbrt) +#pragma does_not_write_global_data(logb, nextafter, remainder) +#pragma does_not_write_global_data(expm1, ilogb, log1p, rint) +#pragma no_side_effect(acosh, asinh, atanh, cbrt) +#pragma no_side_effect(logb, nextafter, remainder) +#pragma no_side_effect(expm1, ilogb, log1p, rint) +#endif +/* END adopted by C99 */ +#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || ... */ + +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) +/* + * SVID + */ +extern int matherr(struct exception *); + +/* + * IEEE Test Vector + */ +extern double significand(double); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(significand) +#pragma does_not_write_global_data(significand) +#pragma no_side_effect(significand) +#endif + +extern int signgamf; /* deprecated; use signgam */ +extern int signgaml; /* deprecated; use signgam */ + +extern int isnanf(float); +extern int isnanl(long double); +extern float gammaf(float); /* deprecated; use lgammaf */ +extern float gammaf_r(float, int *); /* deprecated; use lgammaf_r */ +extern float j0f(float); +extern float j1f(float); +extern float jnf(int, float); +extern float lgammaf_r(float, int *); +extern float scalbf(float, float); +extern float significandf(float); +extern float y0f(float); +extern float y1f(float); +extern float ynf(int, float); +extern long double gammal(long double); /* deprecated; use lgammal */ +extern long double gammal_r(long double, int *); /* deprecated */ +extern long double j0l(long double); +extern long double j1l(long double); +extern long double jnl(int, long double); +extern long double lgammal_r(long double, int *); +extern long double scalbl(long double, long double); +extern long double significandl(long double); +extern long double y0l(long double); +extern long double y1l(long double); +extern long double ynl(int, long double); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(isnanf, isnanl) +#pragma does_not_write_global_data(isnanf, isnanl) +#pragma no_side_effect(isnanf, isnanl) +#pragma does_not_read_global_data(gammaf_r, j0f, j1f, jnf, lgammaf_r, scalbf) +#pragma does_not_read_global_data(significandf, y0f, y1f, ynf) +#pragma does_not_write_global_data(j0f, j1f, jnf, scalbf) +#pragma does_not_write_global_data(significandf, y0f, y1f, ynf) +#pragma no_side_effect(j0f, j1f, jnf, scalbf) +#pragma no_side_effect(significandf, y0f, y1f, ynf) +#pragma does_not_read_global_data(gammal_r, j0l, j1l, jnl, lgammal_r, scalbl) +#pragma does_not_read_global_data(significandl, y0l, y1l, ynl) +#pragma does_not_write_global_data(j0l, j1l, jnl, scalbl) +#pragma does_not_write_global_data(significandl, y0l, y1l, ynl) +#pragma no_side_effect(j0l, j1l, jnl, scalbl) +#pragma no_side_effect(significandl, y0l, y1l, ynl) +#endif + +/* + * for sin+cos->sincos transformation + */ +extern void sincos(double, double *, double *); +extern void sincosf(float, float *, float *); +extern void sincosl(long double, long double *, long double *); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(sincos, sincosf, sincosl) +#endif + +/* BEGIN adopted by C99 */ +/* + * Functions callable from C, intended to support IEEE arithmetic. + */ +extern double copysign(double, double); +extern double scalbn(double, int); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(copysign, scalbn) +#pragma does_not_write_global_data(copysign, scalbn) +#pragma no_side_effect(copysign, scalbn) +#endif +/* END adopted by C99 */ + +/* + * Reentrant version of gamma & lgamma; passes signgam back by reference + * as the second argument; user must allocate space for signgam. + */ +extern double gamma_r(double, int *); /* deprecated; use lgamma_r */ +extern double lgamma_r(double, int *); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(gamma_r, lgamma_r) +#endif + +/* BEGIN adopted by C99 */ +extern float modff(float, float *); + +#if defined(__MATHERR_ERRNO_DONTCARE) +#pragma does_not_read_global_data(modff) +#endif +/* END adopted by C99 */ + +#if defined(__EXTENSIONS__) || !defined(__cplusplus) +#include +#endif +#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */ +#endif /* defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) || ... */ + +#if defined(__cplusplus) && defined(__GNUC__) +#undef exception +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _MATH_H */ diff --git a/illumos-x86_64/usr/include/md4.h b/illumos-x86_64/usr/include/md4.h new file mode 100644 index 00000000..f87ffce1 --- /dev/null +++ b/illumos-x86_64/usr/include/md4.h @@ -0,0 +1,32 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MD4_H +#define _MD4_H + +#include + +#endif /* _MD4_H */ diff --git a/illumos-x86_64/usr/include/md5.h b/illumos-x86_64/usr/include/md5.h new file mode 100644 index 00000000..dd0c249c --- /dev/null +++ b/illumos-x86_64/usr/include/md5.h @@ -0,0 +1,48 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MD5_H +#define _MD5_H + +/* + * MD5.H - header file for MD5C.C + */ + +/* + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD5 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD5 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void md5_calc(void *, const void*, unsigned int); + +#ifdef __cplusplus +} +#endif + +#endif /* _MD5_H */ diff --git a/illumos-x86_64/usr/include/memory.h b/illumos-x86_64/usr/include/memory.h new file mode 100644 index 00000000..7ebdfd92 --- /dev/null +++ b/illumos-x86_64/usr/include/memory.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _MEMORY_H +#define _MEMORY_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern void *memccpy(void *, const void *, int, size_t); +#if __cplusplus >= 199711L +namespace std { +extern const void *memchr(const void *, int, size_t); +#ifndef _MEMCHR_INLINE +#define _MEMCHR_INLINE +extern "C++" { + inline void *memchr(void * __s, int __c, size_t __n) { + return (void*)memchr((const void *) __s, __c, __n); + } +} +#endif /* _MEMCHR_INLINE */ +} /* end of namespace std */ +using std::memchr; +#else +extern void *memchr(const void *, int, size_t); +#endif +extern void *memcpy(void *, const void *, size_t); +extern void *memset(void *, int, size_t); +extern int memcmp(const void *, const void *, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _MEMORY_H */ diff --git a/illumos-x86_64/usr/include/menu.h b/illumos-x86_64/usr/include/menu.h new file mode 100644 index 00000000..7117fef1 --- /dev/null +++ b/illumos-x86_64/usr/include/menu.h @@ -0,0 +1,265 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright (c) 1997, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _MENU_H +#define _MENU_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Menu options: */ +#define O_ONEVALUE 0x01 +#define O_SHOWDESC 0x02 +#define O_ROWMAJOR 0x04 +#define O_IGNORECASE 0x08 +#define O_SHOWMATCH 0x10 +#define O_NONCYCLIC 0x20 + +/* Item options: */ +#define O_SELECTABLE 0x01 + +typedef struct { + char *str; + int length; +} TEXT; + +typedef struct ITEM { + TEXT name; + TEXT description; + int index; /* Item number */ + struct MENU *imenu; /* Pointer to parent menu */ + int value; + char *userptr; + OPTIONS opt; + int status; + short y; /* y and x location of item in menu */ + short x; + struct ITEM *left; + struct ITEM *right; + struct ITEM *up; + struct ITEM *down; +} ITEM; + +#define _POSTED 0x1 +#define _IN_DRIVER 0x2 +#define _LINK_NEEDED 0x4 + +typedef struct MENU { + int height; /* Number of chars high */ + int width; /* Number of chars wide */ + int rows; /* Number of items high */ + int cols; /* Number of items wide */ + int frows; /* Number of formated items high */ + int fcols; /* Number of formated items wide */ + int namelen; /* Length of widest name */ + int desclen; /* Length of widest description */ + int marklen; /* Length of mark */ + int itemlen; /* Length of an one item */ + char *pattern; /* Buffer used to store match chars */ + int pindex; /* Index into pattern buffer */ + WINDOW *win; /* Window containing entire menu */ + WINDOW *sub; /* Portion of menu displayed */ + WINDOW *userwin; /* User's window */ + WINDOW *usersub; /* User's subwindow */ + ITEM **items; + int nitems; /* Total number of items in menu */ + ITEM *curitem; /* Current item */ + int toprow; /* Top row of menu */ + int pad; /* Pad character */ + chtype fore; /* Attribute for selection */ + chtype back; /* Attribute for nonselection */ + chtype grey; /* Attribute for inactive */ + PTF_void menuinit; + PTF_void menuterm; + PTF_void iteminit; + PTF_void itemterm; + char *userptr; + char *mark; + OPTIONS opt; + int status; +} MENU; + +/* Define keys */ + +#define REQ_LEFT_ITEM KEY_MAX+1 +#define REQ_RIGHT_ITEM KEY_MAX+2 +#define REQ_UP_ITEM KEY_MAX+3 +#define REQ_DOWN_ITEM KEY_MAX+4 +#define REQ_SCR_ULINE KEY_MAX+5 +#define REQ_SCR_DLINE KEY_MAX+6 +#define REQ_SCR_DPAGE KEY_MAX+7 +#define REQ_SCR_UPAGE KEY_MAX+8 +#define REQ_FIRST_ITEM KEY_MAX+9 +#define REQ_LAST_ITEM KEY_MAX+10 +#define REQ_NEXT_ITEM KEY_MAX+11 +#define REQ_PREV_ITEM KEY_MAX+12 +#define REQ_TOGGLE_ITEM KEY_MAX+13 +#define REQ_CLEAR_PATTERN KEY_MAX+14 +#define REQ_BACK_PATTERN KEY_MAX+15 +#define REQ_NEXT_MATCH KEY_MAX+16 +#define REQ_PREV_MATCH KEY_MAX+17 + +#ifdef __STDC__ + +extern ITEM **menu_items(MENU *), + *current_item(MENU *), + *new_item(char *, char *); +extern MENU *new_menu(ITEM **); +extern OPTIONS item_opts(ITEM *), + menu_opts(MENU *); +extern PTF_void item_init(MENU *), + item_term(MENU *), + menu_init(MENU *), + menu_term(MENU *); +extern WINDOW *menu_sub(MENU *), + *menu_win(MENU *); +extern char *item_description(ITEM *), + *item_name(ITEM *), + *item_userptr(ITEM *), + *menu_mark(MENU *), + *menu_pattern(MENU *), + *menu_userptr(MENU *); +extern chtype menu_back(MENU *), + menu_fore(MENU *), + menu_grey(MENU *); +extern int free_item(ITEM *), + free_menu(MENU *), + item_count(MENU *), + item_index(ITEM *), + item_opts_off(ITEM *, OPTIONS), + item_opts_on(ITEM *, OPTIONS), + item_value(ITEM *), + item_visible(ITEM *), + menu_driver(MENU *, int), + menu_opts_off(MENU *, OPTIONS), + menu_opts_on(MENU *, OPTIONS), + menu_pad(MENU *), + pos_menu_cursor(MENU *), + post_menu(MENU *), + scale_menu(MENU *, int *, int *), + set_current_item(MENU *, ITEM *), + set_item_init(MENU *, PTF_void), + set_item_opts(ITEM *, OPTIONS), + set_item_term(MENU *, PTF_void), + set_item_userptr(ITEM *, char *), + set_item_value(ITEM *, int), + set_menu_back(MENU *, chtype), + set_menu_fore(MENU *, chtype), + set_menu_format(MENU *, int, int), + set_menu_grey(MENU *, chtype), + set_menu_init(MENU *, PTF_void), + set_menu_items(MENU *, ITEM **), + set_menu_mark(MENU *, char *), + set_menu_opts(MENU *, OPTIONS), + set_menu_pad(MENU *, int), + set_menu_pattern(MENU *, char *), + set_menu_sub(MENU *, WINDOW *), + set_menu_term(MENU *, PTF_void), + set_menu_userptr(MENU *, char *), + set_menu_win(MENU *, WINDOW *), + set_top_row(MENU *, int), + top_row(MENU *), + unpost_menu(MENU *); +void menu_format(MENU *, int *, int *); + +#else /* old style extern's */ + +extern ITEM **menu_items(), + *current_item(), + *new_item(); +extern MENU *new_menu(); +extern OPTIONS item_opts(), + menu_opts(); +extern PTF_void item_init(), + item_term(), + menu_init(), + menu_term(); +extern WINDOW *menu_sub(), + *menu_win(); +extern char *item_description(), + *item_name(), + *item_userptr(), + *menu_mark(), + *menu_pattern(), + *menu_userptr(); +extern chtype menu_back(), + menu_fore(), + menu_grey(); +extern int free_item(), + free_menu(), + item_count(), + item_index(), + item_opts_off(), + item_opts_on(), + item_value(), + item_visible(), + menu_driver(), + menu_opts_off(), + menu_opts_on(), + menu_pad(), + pos_menu_cursor(), + post_menu(), + scale_menu(), + set_current_item(), + set_item_init(), + set_item_opts(), + set_item_term(), + set_item_userptr(), + set_item_value(), + set_menu_back(), + set_menu_fore(), + set_menu_format(), + set_menu_grey(), + set_menu_init(), + set_menu_items(), + set_menu_mark(), + set_menu_opts(), + set_menu_pad(), + set_menu_pattern(), + set_menu_sub(), + set_menu_term(), + set_menu_userptr(), + set_menu_win(), + set_top_row(), + top_row(), + unpost_menu(); +void menu_format(); + +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MENU_H */ diff --git a/illumos-x86_64/usr/include/mon.h b/illumos-x86_64/usr/include/mon.h new file mode 100644 index 00000000..47c6b7cc --- /dev/null +++ b/illumos-x86_64/usr/include/mon.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2014 PALO, Richard. + * + * Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MON_H +#define _MON_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Inclusion of will break SVID namespace, hence only + * the size_t type is defined in this header. + */ +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* _SIZE_T */ + +struct hdr { + char *lpc; + char *hpc; + size_t nfns; +}; + +struct cnt { + char *fnpc; + long mcnt; +}; + +typedef unsigned short WORD; + +#define MON_OUT "mon.out" +#define MPROGS0 (150 * sizeof (WORD)) /* 300 for pdp11, 600 for 32-bits */ +#define MSCALE0 4 + +extern void monitor(int (*)(void), int (*)(void), WORD *, size_t, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _MON_H */ diff --git a/illumos-x86_64/usr/include/monetary.h b/illumos-x86_64/usr/include/monetary.h new file mode 100644 index 00000000..6dbf32cf --- /dev/null +++ b/illumos-x86_64/usr/include/monetary.h @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MONETARY_H +#define _MONETARY_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern ssize_t strfmon(char *_RESTRICT_KYWD, size_t, + const char *_RESTRICT_KYWD, ...); + +#if defined(_XPG7) || (!defined(_STRICT_STRICT_SYMBOLS)) + +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +extern ssize_t strfmon_l(char *_RESTRICT_KYWD, size_t, locale_t, + const char *_RESTRICT_KYWD, ...); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _MONETARY_H */ diff --git a/illumos-x86_64/usr/include/mp.h b/illumos-x86_64/usr/include/mp.h new file mode 100644 index 00000000..6e0dcbc3 --- /dev/null +++ b/illumos-x86_64/usr/include/mp.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1989 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _MP_H +#define _MP_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct mint { + int len; + short *val; +}; +typedef struct mint MINT; + + +extern void mp_gcd(MINT *, MINT *, MINT *); +extern void mp_madd(MINT *, MINT *, MINT *); +extern void mp_msub(MINT *, MINT *, MINT *); +extern void mp_mdiv(MINT *, MINT *, MINT *, MINT *); +extern void mp_sdiv(MINT *, short, MINT *, short *); +extern int mp_min(MINT *); +extern void mp_mout(MINT *); +extern int mp_msqrt(MINT *, MINT *, MINT *); +extern void mp_mult(MINT *, MINT *, MINT *); +extern void mp_pow(MINT *, MINT *, MINT *, MINT *); +extern void mp_rpow(MINT *, short, MINT *); +extern MINT *mp_itom(short); +extern int mp_mcmp(MINT *, MINT *); +extern MINT *mp_xtom(char *); +extern char *mp_mtox(MINT *); +extern void mp_mfree(MINT *); + +#define FREE(x) _mp_xfree(&(x)) /* Compatibility */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MP_H */ diff --git a/illumos-x86_64/usr/include/mpapi-sun.h b/illumos-x86_64/usr/include/mpapi-sun.h new file mode 100644 index 00000000..f8f625fe --- /dev/null +++ b/illumos-x86_64/usr/include/mpapi-sun.h @@ -0,0 +1,71 @@ + +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * + * Description + * mpapi-sun.h - general header file for Sun extension to the Multipath + * Management API Version 1.0 client + * + */ + +#ifndef _MPAPI_SUN_H +#define _MPAPI_SUN_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef MPAPI_SUN_H +#define MPAPI_SUN_H + +/** + ****************************************************************************** + * + * The APIs for path management. + * + * - Sun_MP_SendScsiCmd + * + ****************************************************************************** + */ + + +MP_STATUS Sun_MP_SendScsiCmd( + MP_OID pathOid, + struct uscsi_cmd *cmd +); + + +#endif + +#ifdef __cplusplus +}; +#endif + +#endif /* _MPAPI_SUN_H */ diff --git a/illumos-x86_64/usr/include/mpapi.h b/illumos-x86_64/usr/include/mpapi.h new file mode 100644 index 00000000..84a7fb0c --- /dev/null +++ b/illumos-x86_64/usr/include/mpapi.h @@ -0,0 +1,2593 @@ +/****************************************************************************** + * + * Description + * mpapi.h - general header file for Multipath Management API Version 1.0 + * client + * + * License: + * The contents of this file are subject to the SNIA Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://mp-mgmt-api.sourceforge.net + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is SNIA iSCSI Management API and Multipath Management API + * general header file + * + * The Initial Developer of the Original Code is: + * Benjamin F. Kuo Troika Networks, Inc. (benk@troikanetworks.com) + * David Dillard VERITAS Software(david.dillard@veritas.com) + * Jeff Ding Adaptec, Inc. (jding@corp.adaptec.com) + * Dave Wysochanski Network Appliance, Inc. (davidw@netapp.com) + * Hyon Kim Sun Microsystems(hyon.kim@sun.com) + * + * Contributor(s): + * Paul von Behren Sun Microsystems(paul.vonbehren@sun.com) + * + ****************************************************************************** + * + * Changes: + * 1/15/2005 Implemented SNIA MP API specification 1.0 + * 10/11/2005 + * - Added the license location in the header comment. + * - Added an implementation note in constants and macros + * declarations section. + * - Fixed field name value in struct _MP_PROPRIETARY_PROPERTY. + * - Fixed typo in logicalUnitGroupID in + * _MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES + * - Fixed typo in desiredState in struct _MP_TPG_STATE_PAIR. + * - Fixed typo in API name MP_GetTargetPortGroupProperties. + * - Clarified description of MP_STATUS_INVALID_PARAMETER error + * in MP_GetObjectType(). + * - Fixed typo in API name + * MP_GetProprietaryLoadBalanceProperties(). + * 3/6/2006 + * - mpapi.h header file is updated for + * MP_LOAD_BALANCE_TYPE change in the spec. + *****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef MPAPI_H +#define MPAPI_H + +#include +#include +#include +#include + + +/* Library version string */ +#define MP_LIBVERSION 1 + +/** + ******************************************************************************* + * + * Generic MP Constant Definitions + * + ******************************************************************************* + */ +#define RL_LIBRARY_SEQNUM 0 + +/** +* Value which can be assigned to an MP_BOOL and or an MP_XBOOL. +*/ +#define MP_TRUE 1 + +/** +* Value which can be assigned to an MP_BOOL and or an MP_XBOOL. +*/ +#define MP_FALSE 0 + +/** +* Value which can be assigned to an MP_XBOOL. +*/ +#define MP_UNKNOWN 0xFFFFFFFF + +#define MP_MAX_NUM_PLUGINS 64 +#define MP_OBJECT_TYPE_MATCH 1 +#define MP_OBJECT_TYPE_ANY 2 +#define MAX_NAME_SIZE 256 +#define MAX_LINE_SIZE 515 + + +/** + ****************************************************************************** + * + * Base MP API Type Definitions + * + ****************************************************************************** + */ + +typedef unsigned char MP_UINT8; /* unsigned 8 bits */ +typedef char MP_INT8; /* signed 8 bits */ +typedef unsigned short MP_UINT16; /* unsigned 16 bits */ +typedef short MP_INT16; /* signed 16 bits */ +typedef unsigned int MP_UINT32; /* unsigned 32 bits */ +typedef int MP_INT32; /* signed 32 bits */ +typedef void* MP_PVOID; /* pointer to void */ +typedef MP_UINT32 MP_VOID32; /* opaque 32 bits */ +typedef long long MP_INT64; /* signed 64 bits */ +typedef unsigned long long MP_UINT64; /* unsigned 64 bits */ + +/** + * A character. + */ +typedef char MP_CHAR; + +/** + * A wide character. + */ +typedef wchar_t MP_WCHAR; + +/** + * An unsigned character. + */ +typedef unsigned char MP_BYTE; + +/** + * A boolean. + */ +typedef MP_UINT32 MP_BOOL; + +/** + * An extended boolean: can have the values @ref MP_TRUE, @ref MP_FALSE, and + * @ref MP_UNKNOWN. + */ +typedef MP_UINT32 MP_XBOOL; + +/** + ****************************************************************************** + * + * Constants and macros declarations related to MP_STATUS + * Implementation Notes: This library does validation for OID argument and + * returns the following errors. + * + * 1. MP_STATUS_INVALID_OBJECT_TYPE when input OID type is not + * one of legitimate types defined SNIA Multipath Management + * Spec. + * 2. MP_STATUS_INVALID_PARAMETER when input OID type is + * legitimate but not a proper type for API. + * 3. MP_STATUS_OBJECT_NOT_FOUND when the ownerId of input OID is + * not found or no object instance with matching + * sequenceNumber is found. + * The ownerId is validated by the common library and the + * sequence number is validated by the plugin library. + * + ****************************************************************************** + */ +typedef enum { + MP_STATUS_SUCCESS = 0, + MP_STATUS_INVALID_PARAMETER = 1, + MP_STATUS_UNKNOWN_FN = 2, + MP_STATUS_FAILED = 3, + MP_STATUS_INSUFFICIENT_MEMORY = 4, + MP_STATUS_INVALID_OBJECT_TYPE = 5, + MP_STATUS_OBJECT_NOT_FOUND = 6, + MP_STATUS_UNSUPPORTED = 7, + MP_STATUS_FN_REPLACED = 8, + MP_STATUS_ACCESS_STATE_INVALID = 9, + MP_STATUS_INVALID_WEIGHT = 10, + MP_STATUS_PATH_NONOPERATIONAL = 11, + MP_STATUS_TRY_AGAIN = 12, + MP_STATUS_NOT_PERMITTED = 13 + +} MP_STATUS; + +/** + ****************************************************************************** + * + * Declaration of the MP_PATH_STATE constants + * + ****************************************************************************** + */ +#define MP_PATH_STATE_OKAY 0 +#define MP_PATH_STATE_PATH_ERR 1 +#define MP_PATH_STATE_LU_ERR 2 +#define MP_PATH_STATE_RESERVED 3 +#define MP_PATH_STATE_REMOVED 4 +#define MP_PATH_STATE_TRANSITIONING 5 +#define MP_PATH_STATE_OPERATIONAL_CLOSED 6 +#define MP_PATH_STATE_INVALID_CLOSED 7 +#define MP_PATH_STATE_OFFLINE_CLOSED 8 +#define MP_PATH_STATE_UNKNOWN 9 + +typedef MP_UINT32 MP_PATH_STATE; + +/** + ******************************************************************************* + * + * Declaration of the MP_OBJECT_TYPE constants + * + ******************************************************************************* + */ +#define MP_OBJECT_TYPE_UNKNOWN 0 +#define MP_OBJECT_TYPE_PLUGIN 1 +#define MP_OBJECT_TYPE_INITIATOR_PORT 2 +#define MP_OBJECT_TYPE_TARGET_PORT 3 +#define MP_OBJECT_TYPE_MULTIPATH_LU 4 +#define MP_OBJECT_TYPE_PATH_LU 5 +#define MP_OBJECT_TYPE_DEVICE_PRODUCT 6 +#define MP_OBJECT_TYPE_TARGET_PORT_GROUP 7 +#define MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE 8 + +/* set to the highest constant of object type. */ +#define MP_OBJECT_TYPE_MAX 8 + +typedef MP_UINT32 MP_OBJECT_TYPE; + +/** + ******************************************************************************* + * + * Declaration of the MP_PORT_TRANSPORT_TYPE + * + ******************************************************************************* + */ +#define MP_PORT_TRANSPORT_TYPE_UNKNOWN 0 +#define MP_PORT_TRANSPORT_TYPE_MPNODE 1 +#define MP_PORT_TRANSPORT_TYPE_FC 2 +#define MP_PORT_TRANSPORT_TYPE_SPI 3 +#define MP_PORT_TRANSPORT_TYPE_ISCSI 4 +#define MP_PORT_TRANSPORT_TYPE_IFB 5 + +typedef MP_UINT32 MP_PORT_TRANSPORT_TYPE; + +/** + ******************************************************************************* + * + * Declaration of the MP_ACCESS_STATE_TYPE constants + * + ******************************************************************************* + */ +#define MP_ACCESS_STATE_ACTIVE_OPTIMIZED (0x0) +#define MP_ACCESS_STATE_ACTIVE_NONOPTIMIZED (0x1) +#define MP_ACCESS_STATE_STANDBY (0x2) +#define MP_ACCESS_STATE_UNAVAILABLE (0x3) +#define MP_ACCESS_STATE_TRANSITIONING (0xF) +#define MP_ACCESS_STATE_ACTIVE (0x10) + +typedef MP_UINT32 MP_ACCESS_STATE_TYPE; + +/** + ******************************************************************************* + * + * Declaration of the MP_LOAD_BALANCE_TYPE constants + * + ******************************************************************************* + */ +#define MP_LOAD_BALANCE_TYPE_UNKNOWN (1<<0) +#define MP_LOAD_BALANCE_TYPE_ROUNDROBIN (1<<1) +#define MP_LOAD_BALANCE_TYPE_LEASTBLOCKS (1<<2) +#define MP_LOAD_BALANCE_TYPE_LEASTIO (1<<3) +#define MP_LOAD_BALANCE_TYPE_DEVICE_PRODUCT (1<<4) +#define MP_LOAD_BALANCE_TYPE_LBA_REGION (1<<5) +#define MP_LOAD_BALANCE_TYPE_FAILOVER_ONLY (1<<6) +/** + * Proprietary load balance type should start from 0x10000(1<<16) or greater. + * It is exposed through API MP_GetProprietaryLoadBalanceProperties if exists. + */ + +typedef MP_UINT32 MP_LOAD_BALANCE_TYPE; + +typedef struct mpPluginInfo { + MP_WCHAR pluginName[MAX_NAME_SIZE]; + MP_CHAR pluginPath[MAX_NAME_SIZE]; + void* hdlPlugin; + MP_UINT32 ownerId; +} MPPLUGININFO_T; + + +/** + ******************************************************************************* + * + * Declaration of the MP_PROPRIETARY_PROPERTY + * + ******************************************************************************* + */ +typedef struct _MP_PROPRIETARY_PROPERTY +{ + MP_WCHAR name[16]; + MP_WCHAR value[48]; + +} MP_PROPRIETARY_PROPERTY; + +/** + ******************************************************************************* + * + * Declaration of the MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES + * + ******************************************************************************* + */ +typedef struct _MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES +{ + MP_LOAD_BALANCE_TYPE typeIndex; + MP_WCHAR name[256]; + MP_WCHAR vendorName[256]; + MP_UINT32 proprietaryPropertyCount; + MP_PROPRIETARY_PROPERTY proprietaryProperties[8]; + +} MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_UINT32 MP_LOGICAL_UNIT_NAME_TYPE constants + * + ******************************************************************************* + */ +#define MP_LU_NAME_TYPE_UNKNOWN 0 +#define MP_LU_NAME_TYPE_VPD83_TYPE1 1 +#define MP_LU_NAME_TYPE_VPD83_TYPE2 2 +#define MP_LU_NAME_TYPE_VPD83_TYPE3 3 +#define MP_LU_NAME_TYPE_DEVICE_SPECIFIC 4 + +typedef MP_UINT32 MP_LOGICAL_UNIT_NAME_TYPE; + +/** + ******************************************************************************* + * + * Declaration of the MP_UINT32 MP_AUTOFAILBACK_SUPPORT constants + * + ******************************************************************************* + */ +#define MP_AUTOFAILBACK_SUPPORT_NONE 0 +#define MP_AUTOFAILBACK_SUPPORT_PLUGIN 1 +#define MP_AUTOFAILBACK_SUPPORT_MPLU 2 +#define MP_AUTOFAILBACK_SUPPORT_PLUGINANDMPLU 3 + +typedef MP_UINT32 MP_AUTOFAILBACK_SUPPORT; + +/** + ******************************************************************************* + * + * Declaration of the MP_UINT32 MP_AUTOPROBING_SUPPORT constants + * + ******************************************************************************* + */ +#define MP_AUTOPROBING_SUPPORT_NONE 0 +#define MP_AUTOPROBING_SUPPORT_PLUGIN 1 +#define MP_AUTORPOBING_SUPPORT_MPLU 2 +#define MP_AUTORPOBING_SUPPORT_PLUGINANDMPLU 3 + +typedef MP_UINT32 MP_AUTOPROBING_SUPPORT; + +/** + ******************************************************************************* + * + * Declaration of the MP_OID structure + * + * This structure should be treated as opaque by clients of the API. + * Appropriate APIs should be used to extract information from the structure. + * + * Also ZERO_OID is defined for APIs that may handle multiple plugin OIDs. + * + ******************************************************************************* + */ +typedef struct _MP_OID +{ + /** + * The type of the object. When an object ID is supplied as a parameter + * to an API the library uses this value to insure that the supplied + * object ID's type is appropriate for the API. + */ + MP_OBJECT_TYPE objectType; + + /** + * A value determined by the library which it uses to uniquely identify the + * owner of an object. The owner of an object is either the library itself + * or a plugin. When an object ID is supplied as a parameter to an API the + * library uses this value to determine if it should handle the call itself + * or direct the call to one or more plugins. + */ + MP_UINT32 ownerId; + + /** + * A value determined by a plugin which a plugin uses, perhaps in + * combination with the object type, to uniquely identify one of its + * objects. + */ + MP_UINT64 objectSequenceNumber; + +} MP_OID; + +#define ZERO_OID ((const MP_OID){MP_OBJECT_TYPE_UNKNOWN,0,0}) + +/** + ******************************************************************************* + * + * Declaration of the MP_OID_LIST structure + * + * This structure is used by a number of APIs to return lists of objects. Any + * instance of this structure returned by an API must be freed by a client + * using the MP_FreeOidList API. Although oids is declared to be an + * array of one + * @ref MP_OID structure it can in fact contain any number of + * @ref MP_OID structures. The oidCount indicates the number of @ref MP_OID + * structures in the oids array. + * + * @note The @a oids array is a variable length array, despite its declaration + * below it can be of any length. + * + ******************************************************************************* + */ +typedef struct _MP_OID_LIST +{ + /** + * The number of object IDs in the @a oids array. + */ + MP_UINT32 oidCount; + + /** + * A variable length array of zero or more object IDs. There are + * 'oidCount' object IDs in this array. + */ + MP_OID oids[1]; + +} MP_OID_LIST; + +/** + ******************************************************************************* + * + * Declaration of the MP_LIBRARY_PROPERTIES structure + * + * This structure is returned by the MP_GetLibraryProperties() API. + * + ******************************************************************************* + */ +typedef struct _MP_LIBRARY_PROPERTIES +{ + /** + * The version of the Multipath Management API implemented by the library. + */ + MP_UINT32 supportedMpVersion; + + /** + * A null terminated ASCII string containing the name of the vendor that + * created the binary version of the library. + */ + MP_WCHAR vendor[256]; + + /** + * A null terminated ASCII string containing the implementation version + * of the library from the vendor specified in the 'vendor' field. + */ + MP_WCHAR implementationVersion[256]; + + /** + * A null terminated ASCII string ideally containing the path and file + * name of the library that is being used by the currently executing + * process can be found. If the path cannot be determined then it is + * acceptable to fill this field with only the name (and extension if + * applicable) of the file of the library. If this cannot be determined + * then this field should be an empty string. + */ + MP_CHAR fileName[256]; + + /** + * The time and date that the library that is executing was built. + */ + MP_WCHAR buildTime[256]; + +} MP_LIBRARY_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_PLUGIN_PROPERTIES structure + * + * This structure is returned by the MP_GetPluginProperties() API. + * + ******************************************************************************* + */ +typedef struct _MP_PLUGIN_PROPERTIES +{ + /** + * The version of the Multipath Management API implemented by a plugin. + */ + MP_UINT32 supportedMpVersion; + + /** + * A null terminated Unicode string containing the name of the vendor that + * created the binary version of the plugin. + */ + MP_WCHAR vendor[256]; + + /** + * A null terminated Unicode string containing the implementation version + * of the plugin from the vendor specified in vendor. + */ + MP_WCHAR implementationVersion[256]; + + /** + * A null terminated ASCII string ideally containing the path and file + * name of the plugin that is filling in this structure. + */ + MP_CHAR fileName[256]; + + /** + * The time and date that the plugin that is executing was built. + */ + MP_WCHAR buildTime[256]; + + /** + * A null terminated Unicode string containing the name of the multipath + * driver vendor associated with this plugin. + */ + MP_WCHAR driverVendor[256]; + + /** + * A null terminated Unicode string ideally containing the path and file + * name of the plugin that is filling in this structure. + */ + MP_CHAR driverName[256]; + + /** + * A null terminated Unicode string containing the version number of + * the multipath driver. + */ + MP_WCHAR driverVersion[256]; + + /** + * A set of flags representing the load balance types + * (MP_LOAD_BALANCE_TYPES) supported by the plugin/driver as a plugin-wide + * property. + */ + MP_UINT32 supportedLoadBalanceTypes; + + /** + * boolean indicating whether the implementation supports activating target + * port groups. + */ + MP_BOOL canSetTPGAccess; + + /** + * A Boolean indicating whether the implementations supports overriding + * paths. Setting this to true indicates MP_SetOverridePath and + * MP_CancelOverridePath are supported. + */ + MP_BOOL canOverridePaths; + + /** + * A boolean indicating whether the implementation exposes (or leaves + * exposed) device files for the individual paths encapsulated by the + * multipath device file. This is typically true for MP drivers that sit + * near the top of the driver stack.. + */ + MP_BOOL exposesPathDeviceFiles; + + /** + * A string representing the primary file names the driver uses for + * multipath logical units. + */ + MP_CHAR deviceFileNamespace[256]; + + /** + * A boolean indicating whether the driver limits multipath capabilities + * to certain device types. If true, then the driver only provides multipath + * support to devices exposed through MP_DEVICE_PRODUCT_PROPERTIES + * instances. If false, then the driver supports any device that provides + * standard SCSI logical unit identifiers. + */ + MP_BOOL onlySupportsSpecifiedProducts; + + /** + * Describes the range of administer settable path weights supported by the + * driver. A driver with no path preference capabilities should set + * this property to zero. A driver with the ability to enable/disable + * paths should set this property to 1. Drivers with more weight settings + * can set the property appropriately. + */ + MP_UINT32 maximumWeight; + + /** + * The autofailback support indicates whether the implementation supports + * auto-failback (to reenable paths that revert to a good state) at the + * plugin level, the multipath logical unit level, both levels or whether + * auto-failback is unsupported. + */ + MP_AUTOFAILBACK_SUPPORT autoFailbackSupport; + + /** + * A Boolean indicating whether plugin-wide autofailback is currently + * enabled. This parameter is undefined if autoFailbackSupport is + * MP_AUTOFAILBACK_SUPPORT_NONE or MP_AUTOFAILBACK_SUPPORT_MPLU. + */ + MP_BOOL pluginAutoFailbackEnabled; + + /** + * The maximum plugin-wide polling rate (in seconds) for auto-failback + * supported by the driver. A value of zero indicates the driver/plugin + * does not support polling. Undefined if autoFailbackSupport is + * MP_AUTOFAILBACK_SUPPORT_NONE or MP_AUTOFAILBACK_SUPPORT_MPLU. If the + * plugin/driver supports auto-failback without polling or does not provide + * a way to set the polling rate, then this must be set to zero (0). + * This value is set by the plugin and cannot be modified by users. + */ + MP_UINT32 failbackPollingRateMax; + + /** + * The current plugin-wide auto-failback polling rate (in seconds). + * Undefined if autofailbackSupport is MP_AUTOFAILBACK_SUPPORT_NONE or + * MP_AUTOFAILBACK_SUPPORT_MPLU. Cannot be more that plooingRateMax. + */ + MP_UINT32 currentFailbackPollingRate; + + /** + * An enumerated type indicating whether the implementation supports + * auto-probing at the plugin level, the multipath logical unit level, both + * levels or whether auto-probing is unsupported. + */ + MP_AUTOPROBING_SUPPORT autoProbingSupport; + + /** + * A boolean indicating that plugin-wide auto-probing is enabled. This + * property is undefined if autoProbingSupport is + * MP_AUTOPROBING_SUPPORT_NONE or MP_AUTOPROBING_SUPPORT_MPLU. + */ + MP_BOOL pluginAutoProbingEnabled; + + /** + * The maximum plugin-wide polling rate (in seconds) for auto-probing + * supported by the driver. Undefined if autoProbingSupport is + * MP_AUTOPROBING_SUPPORT_NONE or MP_AUTOPROBING_SUPPORT_MPLU. If the + * plugin/driver supports auto-probing without polling or does not provide a + * way to set the probing polling rate, then this must be set to zero (0). + * This value is set by the plugin and cannot be modified by users. + */ + MP_UINT32 probingPollingRateMax; + + /** + * The current plugin-wide auto-probing polling rate (in seconds). + * Undefined if autoProbingSupport is MP_AUTOPROBING_SUPPORT_NONE or + * MP_AUTOPROBING_SUPPORT_MPLU. Cannot be more that probingPollingRateMax. + */ + MP_UINT32 currentProbingPollingRate; + + /** + * The load balance type that will be used by the driver for devices + * (without a corresponding MP_DEVICE_PRODUCT_PROPERTIES instance) unless + * overridden by the administrator. Any logical unit with vendor, product, + * and revision properties matching a MP_DEVICE_PRODUCT_PROPERTIES instance + * will default to a device-specific load balance type. + */ + MP_LOAD_BALANCE_TYPE defaultloadBalanceType; + + /** + * The count of proprietary properties (less that or equal to eight) + * supported. + */ + MP_UINT32 proprietaryPropertyCount; + + /** + * A list of proprietary property name/value pairs. + */ + MP_PROPRIETARY_PROPERTY proprietaryProperties[8]; + +} MP_PLUGIN_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_DEVICE_PRODUCT_PROPERTIES structure. + * + * This structure is returned by the MP_GetDeviceProductProperties() API. + * + ******************************************************************************* + */ +typedef struct _MP_DEVICE_PRODUCT_PROPERTIES +{ + MP_CHAR vendor[8]; + MP_CHAR product[16]; + MP_CHAR revision[4]; + MP_UINT32 supportedLoadBalanceTypes; + +} MP_DEVICE_PRODUCT_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES structure. + * + * This structure is returned by the MP_GetMPLogicalUnitProperties() API. + * + ******************************************************************************* + */ +typedef struct _MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES +{ + MP_CHAR vendor[8]; + MP_CHAR product[16]; + MP_CHAR revision[4]; + MP_CHAR name[256]; + MP_LOGICAL_UNIT_NAME_TYPE nameType; + MP_CHAR deviceFileName[256]; + MP_BOOL asymmetric; + MP_OID overridePath; + MP_LOAD_BALANCE_TYPE currentLoadBalanceType; + MP_UINT32 logicalUnitGroupID; + MP_XBOOL autoFailbackEnabled; + MP_UINT32 failbackPollingRateMax; + MP_UINT32 currentFailbackPollingRate; + MP_XBOOL autoProbingEnabled; + MP_UINT32 probingPollingRateMax; + MP_UINT32 currentProbingPollingRate; + MP_UINT32 proprietaryPropertyCount; + MP_PROPRIETARY_PROPERTY proprietaryProperties[8]; + +} MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_PATH_LOGICAL_UNIT_PROPERTIES structure. + * + * This structure is returned by the MP_GetPathLogicalUnitProperties() API. + * + ******************************************************************************* + */ +typedef struct _MP_PATH_LOGICAL_UNIT_PROPERTIES +{ + MP_UINT32 weight; + MP_PATH_STATE pathState; + MP_BOOL disabled; + MP_OID initiatorPortOid; + MP_OID targetPortOid; + MP_OID logicalUnitOid; + MP_UINT64 logicalUnitNumber; + MP_CHAR deviceFileName[256]; + MP_UINT32 busNumber; + MP_UINT32 portNumber; + +} MP_PATH_LOGICAL_UNIT_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_INITIATOR_PORT_PROPERTIES structure. + * + * This structure is returned by the MP_GetInitiatorPortProperties() API. + * + ******************************************************************************* + */ +typedef struct _MP_INITIATOR_PORT_PROPERTIES +{ + MP_CHAR portID[256]; + MP_PORT_TRANSPORT_TYPE portType; + MP_CHAR osDeviceFile[256]; + MP_WCHAR osFriendlyName[256]; + +} MP_INITIATOR_PORT_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_TARGET_PORT_PROPERTIES structure. + * + * This structure is returned by the MP_GetTargetPortProperties() API. + * + ******************************************************************************* + */ +typedef struct _MP_TARGET_PORT_PROPERTIES +{ + MP_CHAR portID[256]; + MP_UINT32 relativePortID; + +} MP_TARGET_PORT_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_TARGET_PORT_GROUP_PROPERTIES structure. + * + * This structure is returned by the MP_GetTargetPortGroupProperties() API. + * + ******************************************************************************* + */ +typedef struct _MP_TARGET_PORT_GROUP_PROPERTIES +{ + MP_ACCESS_STATE_TYPE accessState; + MP_BOOL explicitFailover; + MP_BOOL supportsLuAssignment; + MP_BOOL preferredLuPath; + MP_UINT32 tpgID; + +} MP_TARGET_PORT_GROUP_PROPERTIES; + +/** + ******************************************************************************* + * + * Declaration of the MP_TPG_STATE_PAIR structure. + * + * This structure is used as an argument for the MP_SetTPGAcess() API. + * + ******************************************************************************* + */ +typedef struct _MP_TPG_STATE_PAIR +{ + MP_OID tpgOid; + MP_ACCESS_STATE_TYPE desiredState; + +} MP_TPG_STATE_PAIR; + +/** + ******************************************************************************* + * + * Declaration of call back function type for event support + * + ******************************************************************************* + */ +typedef void (* MP_OBJECT_PROPERTY_FN) ( + MP_OID_LIST *pOidList, void *pCallerData +); + +typedef void (* MP_OBJECT_VISIBILITY_FN) ( + MP_BOOL becomingVisible, MP_OID_LIST *pOidList, void *pCallerData +); + +void InitLibrary(); +void ExitLibrary(); + +/** + ****************************************************************************** + * + * The APIs for property and object related discovery. + * + * - MP_GetLibraryProperties + * - MP_GetPluginOidList + * - MP_GetPluginProperties + * - MP_GetAssociatedPluginOid + * - MP_GetObjectType + * - MP_GetDeviceProductOidList + * - MP_GetDeviceProductProperties + * - MP_GetInitiatorPortOidList + * - MP_GetInitiatorPortProperties + * - MP_GetMultipathLus + * - MP_GetMPLogicalUnitProperties + * - MP_GetAssociatedPathOidList + * - MP_GetPathLogicalUnitProperties + * - MP_GetAssociatedTPGOidList + * - MP_GetTargetPortGroupProperties + * - MP_GetMPLuOidListFromTPG + * - MP_GetProprietaryLoadBalanceOidList + * - MP_GetProprietaryLoadBalanceProperties + * - MP_GetTargetPortOidList + * - MP_GetTargetPortProperties + * + ****************************************************************************** + */ + +/** + ******************************************************************************* + * + * Gets the properties of the MP API library that is being used. + * + * @param pProps + * A pointer to an MP_LIBRARY_PROPERTIES structure allocated by + * the caller. On successful return this structure will contain the + * properties of the MP API library. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned if the library properties were successfully returned. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding the + * library properties is found to be invalid. + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the implementation does not support the API. + * + ****************************************************************************** + */ +MP_STATUS MP_GetLibraryProperties( + MP_LIBRARY_PROPERTIES *pProps +); + +/** + ****************************************************************************** + * + * Gets a list of the object IDs of all currently loaded plugins. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST. On successful + * return this will contain a pointer to an @ref MP_OID_LIST + * which contains the object IDs of all of the plugins currently + * loaded by the library. + * + * @return MP_STATUS indicating if the operation was successful or + * if an error occurred. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. This is + * most likely to happen if an uninitialized object ID is passed to + * the API. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList is NULL or specifies a memory area to which data + * cannot be written. MP_STATUS_SUCCESS Returned when the operation is + * successful. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs* + * + * @retval MP_STATUS_SUCCESS + * Returned if the plugin ID list was successfully returned. + * + ****************************************************************************** + */ +MP_STATUS MP_GetPluginOidList( + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets the properties of the specified vendor plugin. + * + * @param oid + * The ID of the plugin whose properties are being retrieved. + * + * @param pProps + * A pointer to an @ref MP_PLUGIN_PROPERTIES structure allocated by + * the caller. On successful return this will contain the properties + * of the plugin specified by pluginOid. + * + * @return An MP_STATUS indicating if the operation was successful or if an + * error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned if the plugin properties were successfully returned. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if 'pProps' is NULL or specifies a memory area to + * which data cannot be written. + * + ******************************************************************************* + */ +MP_STATUS MP_GetPluginProperties( + MP_OID oid, + MP_PLUGIN_PROPERTIES *pProps +); + + +/** + ******************************************************************************* + * + * Gets the object ID for the plugin associated with the specified object ID. + * + * @param oid + * The object ID of an object that has been received from a previous + * library call. + * + * @param pPluginOid + * A pointer to an MP_OID structure allocated by the caller. On + * successful return this will contain the object ID of the plugin + * associated with the object specified by @a objectId. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned if the associated plugin ID was successfully returned. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid does not specify a plugin that is currently known to + * the system. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if 'oid' specifies an object not owned by a plugin or + * if pPluginOid is NULL or specifies a memory area to which data + * cannot be written. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if 'oid' specifies an object with an invalid type. + * + ******************************************************************************* + */ +MP_STATUS MP_GetAssociatedPluginOid( + MP_OID oid, + MP_OID *pPluginOid +); + + +/** + ******************************************************************************* + * + * Gets the object type of an initialized object ID. + * + * @param oid + * The object ID of an object that has been received from a previous + * library call. + * + * @param pObjectType + * A pointer to an MP_OBJECT_TYPE variable allocated by the caller. + * On successful return this will contain the object type of oid. + * + * @return An MP_STATUS indicating if the operation was successful or + * if an error occurred. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + ******************************************************************************* + */ +MP_STATUS MP_GetObjectType( + MP_OID oid, + MP_OBJECT_TYPE *pObjectType +); + + +/** + ******************************************************************************* + * + * Gets a list of the object IDs of all the device product properties + * associated with this plugin. + * + * @param oid + * The object ID of plugin. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST structure. + * On a successful return, this will contain a pointer to + * an MP_OID_LIST that contains the object IDs of all the device + * product descriptors associated with the specified plugin. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding + * the device product list is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the API is not supported. + * + ******************************************************************************* + */ +MP_STATUS MP_GetDeviceProductOidList( + MP_OID oid, + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets the device product properties of the specified plugin oid. + * + * @param oid + * The object ID of the plugin. + * + * @param ppProps + * A pointer to an MP_DEVICE_PRODUCT_PROPERTIES structure + * allocated by the caller. On successful return it will contain + * a pointer to an MP_DEVICE_PRODUCT_PROPERTIES structure allocated + * by the library. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppProps pointer passed as placeholder for holding + * the device product properties is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the API is not supported. + * + ******************************************************************************* + */ +MP_STATUS MP_GetDeviceProductProperties( + MP_OID oid, + MP_DEVICE_PRODUCT_PROPERTIES *pProps +); + +/** + ******************************************************************************* + * + * Gets a list of the object IDs of all the initiator ports associated + * with this plugin. + * + * @param oid + * The object ID of plugin. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST structure. + * On a successful return, this will contain a pointer to + * an MP_OID_LIST that contains the object IDs of all the initiator + * ports associated with the specified plugin. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding + * the initiator port list is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the API is not supported. + * + ******************************************************************************* + */ +MP_STATUS MP_GetInitiatorPortOidList( + MP_OID oid, + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets the properties of the specified initiator port. + * + * @param oid + * The object ID of the initiator port. + * + * @param pProps + * A pointer to an MP_INITIATOR_PORT_PROPERTIES structure + * allocated by the caller. On successful return, this structure + * will contain the properties of the port specified by oid. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pProps is NULL or specifies a memory area to + * which data cannot be written. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_GetInitiatorPortProperties( + MP_OID oid, + MP_INITIATOR_PORT_PROPERTIES *pProps +); + +/** + ******************************************************************************* + * + * Gets a list of multipath logical units associated to a plugin. + * + * @param oid + * The object ID of plugin. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST structure. + * On a successful return, this will contain a pointer to + * an MP_OID_LIST that contains the object IDs of all the multipath + * logical units associated with the specified plugin. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding + * the multipath logical unit list is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the API is not supported. + * + ******************************************************************************* + */ +MP_STATUS MP_GetMultipathLus( + MP_OID oid, + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets the properties of the specified logical unit. + * + * @param oid + * The object ID of the multipath logical unit. + * + * @param pProps + * A pointer to an MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES structure + * allocated by the caller. On successful return, this structure + * will contain the properties of the port specified by oid. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pProps is NULL or specifies a memory area to + * which data cannot be written. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_GetMPLogicalUnitProperties( + MP_OID oid, + MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES *pProps +); + +/** + ******************************************************************************* + * + * Gets a list of the object IDs of all the path logical units associated + * with the specified multipath logical unit, initiator port, or target port. + * + * @param oid + * The object ID of multipath logical unit, initiator port, or + * target port. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST structure. + * On a successful return, this will contain a pointer to + * an MP_OID_LIST that contains the object IDs of all the mp path + * logical units associated with the specified OID. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding + * the device product list is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_GetAssociatedPathOidList( + MP_OID oid, + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets the properties of the specified path logical unit. + * + * @param oid + * The object ID of the path logical unit. + * + * @param pProps + * A pointer to an MP_PATH_LOGICAL_UNIT_PROPERTIES structure + * allocated by the caller. On successful return, this structure + * will contain the properties of the port specified by oid. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pProps is NULL or specifies a memory area to + * which data cannot be written. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_GetPathLogicalUnitProperties( + MP_OID oid, + MP_PATH_LOGICAL_UNIT_PROPERTIES *pProps +); + +/** + ******************************************************************************* + * + * Gets a list of the object IDs of all the target port group associated + * with the specified multipath logical unit. + * + * @param oid + * The object ID of the multiple logical unit. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST structure. + * On a successful return, this will contain a pointer to + * an MP_OID_LIST that contains the object IDs of all the target + * port group associated with the specified multipath logical unit. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding + * the target port group list is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + * + ******************************************************************************* + */ +MP_STATUS MP_GetAssociatedTPGOidList( + MP_OID oid, + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets the properties of the specified target port group. + * + * @param oid + * The object ID of the target port group. + * + * @param pProps + * A pointer to an MP_TARGET_PORT_GROUP_PROPERTIES structure + * allocated by the caller. On successful return, this structure + * will contain the properties of the port specified by oid. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pProps is NULL or specifies a memory area to + * which data cannot be written. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_GetTargetPortGroupProperties( + MP_OID oid, + MP_TARGET_PORT_GROUP_PROPERTIES *pProps +); + +/** + ******************************************************************************* + * + * Gets a list of multipath logical units associated with the specific target + * port group. + * + * @param oid + * The object ID of the target port group. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST structure. + * On a successful return, this will contain a pointer to + * an MP_OID_LIST that contains the object IDs of all the multipath + * logical units associated with the specified target port group. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding + * the multipath logical unit list is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + ******************************************************************************* + */ +MP_STATUS MP_GetMPLuOidListFromTPG( + MP_OID oid, + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets a list of the object IDs of all the proprietary load balance + * algorithms associated with this plugin. + * + * @param oid + * The object ID of the plugin. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST structure. + * On a successful return, this will contain a pointer to + * an MP_OID_LIST that contains the object IDs of all the proprietary + * load balance algorithms associated with the specified plugin. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding + * the proprietary load balance oid list is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the API is not supported. + * + ******************************************************************************* + */ +MP_STATUS MP_GetProprietaryLoadBalanceOidList( + MP_OID oid, + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets the properties of the specified load balance properties structure. + * + * @param oid + * The object ID of the proprietary load balance structure. + * + * @param pProps + * A pointer to an MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES structure + * allocated by the caller. On successful return, this structure + * will contain the properties of the port specified by oid. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pProps is NULL or specifies a memory area to + * which data cannot be written. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_GetProprietaryLoadBalanceProperties( + MP_OID oid, + MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES *pProps +); + +/** + ******************************************************************************* + * + * Gets a list of the object IDs of the target ports in the specified target + * port group. + * + * @param oid + * The object ID of the target port group. + * + * @param ppList + * A pointer to a pointer to an MP_OID_LIST structure. + * On a successful return, this will contain a pointer to + * an MP_OID_LIST that contains the object IDs of all the target ports + * associated with the specified target port group. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if ppList pointer passed as placeholder for holding + * the multipath logical unit list is found to be invalid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the plugin for the specified oid is not found. + * + * @retval MP_STATUS_INSUFFICIENT_MEMORY + * Returned when memory allocation failure occurs + * + ******************************************************************************* + */ +MP_STATUS MP_GetTargetPortOidList( + MP_OID oid, + MP_OID_LIST **ppList +); + +/** + ******************************************************************************* + * + * Gets the properties of the specified target port. + * + * @param oid + * The object ID of the target port. + * + * @param pProps + * A pointer to an MP_TARGET_PORT_PROPERTIES structure + * allocated by the caller. On successful return, this structure + * will contain the properties of the port specified by oid. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pProps is NULL or specifies a memory area to + * which data cannot be written. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_GetTargetPortProperties( + MP_OID oid, + MP_TARGET_PORT_PROPERTIES *pProps +); + +/** + ****************************************************************************** + * + * The APIs for path management. + * + * - MP_AssignLogicalUnitToTPG + * - MP_SetOverridePath + * - MP_CancelOverridePath + * - MP_EnableAutoFailback + * - MP_DisableAutoFailback + * - MP_EnableAutoProbing + * - MP_DisableAutoProbing + * - MP_EnablePath + * - MP_DisablePath + * - MP_SetLogicalUnitLoadBalanceType + * - MP_SetPluginLoadBalanceType + * - MP_SetPathWeight + * - MP_SetFailbackPollingRates + * - MP_SetProbingPollingRates + * - MP_SetProprietaryProperties + * - MP_SetTPGAccess + * + ****************************************************************************** + */ + +/** + ******************************************************************************* + * + * Assign a multipath logical unit to a target port group. + * + * @param tpgOid + * An MP_TARGET_PORT_GROUP oid. The target port group currently in + * active access state that the administrator would like the LU + * assigned to. + * + * @param luOid + * An MP_MULTIPATH_LOGICAL_UNIT oid. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned when luOid is not associated with tpgOid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_AssignLogicalUnitToTPG( + MP_OID tpgOid, + MP_OID luOid +); + +/** + ******************************************************************************* + * + * Manually override the path for a logical unit. The path exclusively used to + * access the logical unit until cleared. + * + * @param logicalUnitOid + * The object ID of the multipath logical unit. + * + * @param pathOid + * The object ID of the path logical unit. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if the oid of the object is not valid + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the implementation does not support the API + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_PATH_NONOPERATIONAL + * Returned when the driver cannot communicate through selected path. + * + ******************************************************************************* + */ +MP_STATUS MP_SetOverridePath( + MP_OID logicalUnitOid, + MP_OID pathOid +); + +/** + ******************************************************************************* + * + * Cancel a path override and re-enable load balancing. + * + * @param luOid + * An MP_MULTIPATH_LOGICAL_UNIT oid. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if MP_MULTIPATH_LOGICAL_UNIT with the luOid is not found. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned if oid has an owner that is not currently known to + * the system. + * + ******************************************************************************* + */ +MP_STATUS MP_CancelOverridePath( + MP_OID logicalUnitOid +); + +/** + ******************************************************************************* + * + * Enables Auto-failback. + * + * @param oid + * The oid of the plugin or the multipath logical unit. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if oid is NULL or specifies a memory area that is not + * a valid plugin oid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_EnableAutoFailback( + MP_OID oid +); + +/** + ******************************************************************************* + * + * Disables Auto-failback. + * + * @param oid + * The oid of the plugin or the multipath logical unit.. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if oid is NULL or specifies a memory area that is not + * a valid plugin oid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_DisableAutoFailback( + MP_OID oid +); + +/** + ******************************************************************************* + * + * Enables Auto-probing. + * + * @param oid + * The oid of the plugin or the multipath logical unit. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if oid is NULL or specifies a memory area that is not + * a valid plugin oid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_EnableAutoProbing( + MP_OID oid +); + +/** + ******************************************************************************* + * + * Disables Auto-probing. + * + * @param oid + * The oid of the plugin or the multipath logical unit. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if oid is NULL or specifies a memory area that is not + * a valid plugin oid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_DisableAutoProbing( + MP_OID oid +); + +/** + ******************************************************************************* + * + * Enables a path. This API may cause failover in a logical unit with + * asymmetric access. + * + * @param oid + * The oid of the path. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if oid is NULL or specifies a memory area that is not + * a valid path oid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_EnablePath( + MP_OID oid +); + +/** + ******************************************************************************* + * + * Disables a path. This API may cause failover in a logical unit with + * asymmetric access. This API may cause a logical unit to become unavailable. + * + * @param oid + * The oid of the path. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if oid is NULL or specifies a memory area that is not + * a valid path oid. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the API is not supported. + * + * @retval MP_STATUS_TRY_AGAIN + * Returned when path cannot be disabled at this time. + * + * @retval MP_STATUS_NOT_PERMITTED + * Returned when disabling thsi path would cause the login unit to + * become unavailable. + * + ******************************************************************************* + */ +MP_STATUS MP_DisablePath( + MP_OID oid +); + +/** + ******************************************************************************* + * + * Set the multipath logical unit s load balancing policy. + * + * @param logicalUnitoid + * The object ID of the multipath logical unit. + * + * @param loadBanlance + * The desired load balance policy for the specified logical unit. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if no MP_MULTIPATH_LOGICAL_UNIT associated with + * @ref ligicalUnitrOid is found or invalid MP_LOAD_BALANCE_TYPE is + * specified. + * + * @retval MP_STATUS_FAILED + * Returned when the specified loadBalance type cannot be handled + * by the plugin. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_SetLogicalUnitLoadBalanceType( + MP_OID logicalUnitOid, + MP_LOAD_BALANCE_TYPE loadBalance +); + +/** + ******************************************************************************* + * + * Set the weight to be assigned to a particular path. + * + * @param pathOid + * The object ID of the path logical unit. + * + * @param weight + * weight that will be assigned to the path logical unit. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned when the MP Path specified by the PathOid could not be + * found. + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the implementation does not support the API + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the operation failed. + * + * @retval MP_STATUS_INVALID_WEIGHT + * Returned when the weight parameter is greater than the plugin's + * maxWeight property. + * + ******************************************************************************* + */ +MP_STATUS MP_SetPathWeight( + MP_OID pathOid, + MP_UINT32 weight +); + +/** + ******************************************************************************* + * + * Set the default load balance policy for the plugin. + * + * @param oid + * The object ID of the plugin + * + * @param loadBalance + * The desired default load balance policy for the specified plugin. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned when the the plugin specified by @ref oid could not be + * found. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if the oid of the object is not valid. + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the implementation does not support the API + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned when the specified loadBalance type cannot be handled + * by the plugin. + * + ******************************************************************************* + */ +MP_STATUS MP_SetPluginLoadBalanceType( + MP_OID oid, + MP_LOAD_BALANCE_TYPE loadBalance +); + +/** + ******************************************************************************* + * + * Set the failback polling rates. Setting both rates to zero disables polling. + * + * @param pluginOid + * The object ID of either the plugin or a multipath logical unit. + * + * @param pollingRate + * The value to be set in MP_PLUGIN_PROPERTIES current pollingRate or + * MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES pollingRate. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned when the the plugin specified by @ref oid could not be + * found. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if one of the polling values is outside the range + * supported by the driver. + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the implementation does not support the API + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_SetFailbackPollingRate( + MP_OID oid, + MP_UINT32 pollingRate +); + +/** + ******************************************************************************* + * + * Set the probing polling rates. Setting both rates to zero disables polling. + * + * @param pluginOid + * The object ID of either the plugin or a multipath logical unit. + * + * @param pollingRate + * The value to be set in MP_PLUGIN_PROPERTIES current pollingRate or + * MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES pollingRate. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned when the the plugin specified by @ref oid could not be + * found. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if one of the polling values is outside the range + * supported by the driver. + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the implementation does not support the API + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_SetProbingPollingRate( + MP_OID oid, + MP_UINT32 pollingRate +); + +/** + ******************************************************************************* + * + * Set proprietary properties in supported object instances. + * + * @param pluginOid + * The object ID of MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES, + * MP_PLUGIN_PROPERTIES or MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES. + * + * @param count + * The number of valid items in pPropertyList. + * + * @param pPropertyList + * A pointer to an array of property name/value pairs. This array must + * contain the same number of elements as count. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned when the the plugin specified by @ref oid could not be + * found. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if one of the polling values is outside the range + * supported by the driver. + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the implementation does not support the API + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_SetProprietaryProperties( + MP_OID oid, + MP_UINT32 count, + MP_PROPRIETARY_PROPERTY *pPropertyList +); + +/** + ******************************************************************************* + * + * Set the access state for a list of target port groups. This allows + * a client to force a failover or failback to a desired set of target port + * groups. + * + * @param luOid + * The object ID of the logical unit where the command is sent. + * + * @param count + * The number of valid items in the pTpgStateList. + * + * @param pTpgStateList + * A pointer to an array of TPG/access-state values. This array must + * contain the same number of elements as @ref count. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_OBJECT_NOT_FOUND + * Returned when the MP_MULTIPATH_LOGICAL_UNIT associated with @ref + * oid could not be found. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pTpgStateList is null or if one of the TPGs referenced + * in the list is not associated with the specified MP logical unit. + * + * @retval MP_STATUS_UNSUPPORTED + * Returned when the implementation does not support the API + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if oid does not specify any valid object type. + * + * @retval MP_STATUS_ACCESS_STATE_INVALID + * Returned if the target device returns a status indicating the caller + * is attempting to establish an illegal combination of access states. + * + * @retval MP_STATUS_FAILED + * Returned if the underlying interface failed the commend for some + * reason other than MP_STATUS_ACCESS_STATE_INVALID + * + ******************************************************************************* + */ +MP_STATUS MP_SetTPGAccess( + MP_OID luOid, + MP_UINT32 count, + MP_TPG_STATE_PAIR *pTpgStateList +); + +/** + ****************************************************************************** + * + * The APIs that are associated with event support. + * + * - MP_RegisterForObjectPropertyChanges + * - MP_DeregisterForObjectPropertyChanges + * - MP_RegisterForObjectVisibilityChanges + * - MP_DeregisterForObjectVisibilityChanges + * + ****************************************************************************** + */ + +/** + ******************************************************************************* + * + * Registers a client function that is to be called + * whenever the property of an an object changes. + * + * @param pClientFn, + * A pointer to an MP_OBJECT_PROPERTY_FN function defined by the + * client. On successful return this function will be called to + * inform the client of objects that have had one or more properties + * change. + * + * @param objectType + * The type of object the client wishes to deregister for + * property change callbacks. If null, then all objects types are + * deregistered. + * + * @param pCallerData + * A pointer that is passed to the callback routine with each event. + * This may be used by the caller to correlate the event to source of + * the registration. + * + * @param pluginOid + * A plugin oid that the client wishes to deregister for property change. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pClientFn is NULL or specifies a memory area + * that is not executable. + * + * @retval MP_STATUS_FN_REPLACED + * Returned when an existing client function is replaced with the one + * specified in pClientFn. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if objectType does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_RegisterForObjectPropertyChanges( + MP_OBJECT_PROPERTY_FN pClientFn, + MP_OBJECT_TYPE objectType, + void *pCallerData, + MP_OID pluginOid +); + +/** + ******************************************************************************* + * + * Deregisters a previously registered client function that is to be invoked + * whenever an object's property changes. + * + * @param pClientFn, + * A pointer to an MP_OBJECT_PROPERTY_FN function defined by the + * client that was previously registered using + * the MP_RegisterForObjectPropertyChanges API. On successful return + * this function will no longer be called to inform the client of + * object property changes. + * + * @param objectType + * The type of object the client wishes to deregister for + * property change callbacks. If null, then all objects types are + * deregistered. + * + * @param pluginOid + * A plugin oid that the client wishes to deregister for property change. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pClientFn is NULL or specifies a memory area + * that is not executable. + * + * @retval MP_STATUS_UNKNOWN_FN + * Returned if pClientFn is not the same as the previously registered + * function. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if objectType does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned if pClientFn deregistration is not possible at this time. + * + ******************************************************************************* + */ +MP_STATUS MP_DeregisterForObjectPropertyChanges( + MP_OBJECT_PROPERTY_FN pClientFn, + MP_OBJECT_TYPE objectType, + MP_OID pluginOid +); + +/** + ******************************************************************************* + * + * Registers a client function that is to be called + * whenever a high level object appears or disappears. + * + * @param pClientFn, + * A pointer to an MP_OBJECT_VISIBILITY_FN function defined by the + * client. On successful return this function will be called to + * inform the client of objects whose visibility has changed. + * + * @param objectType + * The type of object the client wishes to deregister for + * property change callbacks. If null, then all objects types are + * deregistered. + * + * @param pCallerData + * A pointer that is passed to the callback routine with each event. + * This may be used by the caller to correlate the event to source of + * the registration. + * + * @param pluginOid + * A plugin oid that the client wishes to deregister for property change. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pClientFn is NULL or specifies a memory area + * that is not executable. + * + * @retval MP_STATUS_FN_REPLACED + * Returned when an existing client function is replaced with the one + * specified in pClientFn. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if objectType does not specify any valid object type. + * + ******************************************************************************* + */ +MP_STATUS MP_RegisterForObjectVisibilityChanges( + MP_OBJECT_VISIBILITY_FN pClientFn, + MP_OBJECT_TYPE objectType, + void *pCallerData, + MP_OID pluginOid +); + +/** + ******************************************************************************* + * + * Deregisters a previously registered client function that is to be invoked + * whenever a high level object appears or disappears. + * + * @param pClientFn, + * A pointer to an MP_OBJECT_VISIBILITY_FN function defined by the + * client that was previously registered using + * the MP_RegisterForObjectVisibilityChanges API. On successful return + * this function will no longer be called to inform the client of + * object property changes. + * + * @param objectType + * The type of object the client wishes to deregister for visibility + * change callbacks. If null, then all objects types are + * deregistered. + * + * @param pluginOid + * A plugin oid that the client wishes to deregister for property change. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the operation is successful. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pClientFn is NULL or specifies a memory area + * that is not executable. + * + * @retval MP_STATUS_UNKNOWN_FN + * Returned if pClientFn is not the same as the previously registered + * function. + * + * @retval MP_STATUS_INVALID_OBJECT_TYPE + * Returned if objectType does not specify any valid object type. + * + * @retval MP_STATUS_FAILED + * Returned if pClientFn deregistration is not possible at this time. + * + ******************************************************************************* + */ +MP_STATUS MP_DeregisterForObjectVisibilityChanges( + MP_OBJECT_VISIBILITY_FN pClientFn, + MP_OBJECT_TYPE objectType, + MP_OID pluginOid +); + +/** + ****************************************************************************** + * + * The utility APIs + * + * - MP_CompareOIDs + * - MP_FreeOidList + * - MP_RegisterPlugin + * - MP_DeregisterPlugin + * + ****************************************************************************** + */ + +/** + ******************************************************************************* + * + * Compare two Oids for equality to see whether they refer to the same object. + * + * @param oid1 + * Oid to compare. + * + * @param oid2 + * Oid to compare. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when the two Oids do refer to the same object. + * + * @retval MP_STATUS_FAILED + * Returned if the Oids don't compare. + * + ******************************************************************************* + */ +MP_STATUS MP_CompareOIDs( + MP_OID oid1, + MP_OID oid2 +); + +/** + ******************************************************************************* + * + * Frees memory returned by an MP API. + * + * @param pMemory + * A pointer to the memory returned by an MP API. On successful + return, the allocated memory is freed. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when pPluginId is deregistered successfully. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pMemory is NULL or specifies a memory area to which + * data cannot be written. + * + ******************************************************************************* + */ +MP_STATUS MP_FreeOidList( + MP_OID_LIST *pOidList +); + +/** + ******************************************************************************* + * + * Registers a plugin with common library. The implementation of this routine + * is based on configuration file /etc/mpapi.conf that contains a list of + * plugin libraries. + * + * @param pPluginId + * A pointer to the key name shall be the reversed domain name of + * the vendor followed by followed by the vendor specific name for + * the plugin that uniquely identifies the plugin. + * + * @param pFileName + * The full path to the plugin library. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when pPluginId is deregistered successfully. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pPluginId is NULL or specifies a memory area that + * is not executable. + * + * @retval MP_STATUS_FAILED + * Returned if pClientFn deregistration is not possible at this time. + * + ******************************************************************************* + */ +MP_STATUS MP_RegisterPlugin( + MP_WCHAR *pPluginId, + MP_CHAR *pFileName +); + +/** + ******************************************************************************* + * + * Deregisters a plugin from the common library. + * + * @param pPluginId + * A pointer to a Plugin ID previously registered using + * the MP_RegisterPlugin API.. + * + * @return An MP_STATUS indicating if the operation was successful or if + * an error occurred. + * + * @retval MP_STATUS_SUCCESS + * Returned when pPluginId is deregistered successfully. + * + * @retval MP_STATUS_INVALID_PARAMETER + * Returned if pPluginId is NULL or specifies a memory area that + * is not executable. + * + * @retval MP_STATUS_FAILED + * Returned if pClientFn deregistration is not possible at this time. + * + ******************************************************************************* + */ +MP_STATUS MP_DeregisterPlugin( + MP_WCHAR *pPluginId +); + +#endif + +#ifdef __cplusplus +}; +#endif + diff --git a/illumos-x86_64/usr/include/mpc.h b/illumos-x86_64/usr/include/mpc.h new file mode 100644 index 00000000..b4cd27c6 --- /dev/null +++ b/illumos-x86_64/usr/include/mpc.h @@ -0,0 +1,357 @@ +/* mpc.h -- Include file for mpc. + +Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012, 2016, 2017, 2018, 2020, 2021, 2022 INRIA + +This file is part of GNU MPC. + +GNU MPC is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see http://www.gnu.org/licenses/ . +*/ + +#ifndef __MPC_H +#define __MPC_H + +#include +#include "gmp.h" +#include "mpfr.h" + +/* Define MPC version number */ +#define MPC_VERSION_MAJOR 1 +#define MPC_VERSION_MINOR 3 +#define MPC_VERSION_PATCHLEVEL 1 +#define MPC_VERSION_STRING "1.3.1" + +/* Macros dealing with MPC VERSION */ +#define MPC_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +#define MPC_VERSION \ + MPC_VERSION_NUM(MPC_VERSION_MAJOR,MPC_VERSION_MINOR,MPC_VERSION_PATCHLEVEL) + +/* Check if stdint.h/inttypes.h is included */ +#if defined (INTMAX_C) && defined (UINTMAX_C) +#define _MPC_H_HAVE_INTMAX_T 1 +#endif + +/* Return values */ + +/* Transform negative to 2, positive to 1, leave 0 unchanged. + Warning: since inex is evaluated two times, we should avoid + MPC_INEX(mpc_mul (...), mpc_mul (...)) */ +#define MPC_INEX_POS(inex) (((inex) < 0) ? 2 : ((inex) == 0) ? 0 : 1) +/* Transform 2 to negative, 1 to positive, leave 0 unchanged */ +#define MPC_INEX_NEG(inex) (((inex) == 2) ? -1 : ((inex) == 0) ? 0 : 1) + +/* The global inexact flag is made of (real flag) + 4 * (imaginary flag), where + each of the real and imaginary inexact flag are: + 0 when the result is exact (no rounding error) + 1 when the result is larger than the exact value + 2 when the result is smaller than the exact value */ +#define MPC_INEX(inex_re, inex_im) \ + (MPC_INEX_POS(inex_re) | (MPC_INEX_POS(inex_im) << 2)) +#define MPC_INEX_RE(inex) MPC_INEX_NEG((inex) & 3) +#define MPC_INEX_IM(inex) MPC_INEX_NEG((inex) >> 2) + +/* For functions computing two results, the return value is + inexact1+16*inexact2, which is 0 iif both results are exact. */ +#define MPC_INEX12(inex1, inex2) (inex1 | (inex2 << 4)) +#define MPC_INEX1(inex) (inex & 15) +#define MPC_INEX2(inex) (inex >> 4) + +/* Definition of rounding modes */ + +/* a complex rounding mode is just a pair of two real rounding modes + we reserve four bits for a real rounding mode. */ +typedef int mpc_rnd_t; + +#define MPC_RND(r1,r2) (((int)(r1)) + ((int)(r2) << 4)) +#define MPC_RND_RE(x) ((mpfr_rnd_t)((x) & 0x0F)) +#define MPC_RND_IM(x) ((mpfr_rnd_t)((x) >> 4)) + +#define MPC_RNDNN MPC_RND (MPFR_RNDN,MPFR_RNDN) +#define MPC_RNDNZ MPC_RND (MPFR_RNDN,MPFR_RNDZ) +#define MPC_RNDNU MPC_RND (MPFR_RNDN,MPFR_RNDU) +#define MPC_RNDND MPC_RND (MPFR_RNDN,MPFR_RNDD) +#define MPC_RNDNA MPC_RND (MPFR_RNDN,MPFR_RNDA) + +#define MPC_RNDZN MPC_RND (MPFR_RNDZ,MPFR_RNDN) +#define MPC_RNDZZ MPC_RND (MPFR_RNDZ,MPFR_RNDZ) +#define MPC_RNDZU MPC_RND (MPFR_RNDZ,MPFR_RNDU) +#define MPC_RNDZD MPC_RND (MPFR_RNDZ,MPFR_RNDD) +#define MPC_RNDZA MPC_RND (MPFR_RNDZ,MPFR_RNDA) + +#define MPC_RNDUN MPC_RND (MPFR_RNDU,MPFR_RNDN) +#define MPC_RNDUZ MPC_RND (MPFR_RNDU,MPFR_RNDZ) +#define MPC_RNDUU MPC_RND (MPFR_RNDU,MPFR_RNDU) +#define MPC_RNDUD MPC_RND (MPFR_RNDU,MPFR_RNDD) +#define MPC_RNDUA MPC_RND (MPFR_RNDU,MPFR_RNDA) + +#define MPC_RNDDN MPC_RND (MPFR_RNDD,MPFR_RNDN) +#define MPC_RNDDZ MPC_RND (MPFR_RNDD,MPFR_RNDZ) +#define MPC_RNDDU MPC_RND (MPFR_RNDD,MPFR_RNDU) +#define MPC_RNDDD MPC_RND (MPFR_RNDD,MPFR_RNDD) +#define MPC_RNDDA MPC_RND (MPFR_RNDD,MPFR_RNDA) + +#define MPC_RNDAN MPC_RND (MPFR_RNDA,MPFR_RNDN) +#define MPC_RNDAZ MPC_RND (MPFR_RNDA,MPFR_RNDZ) +#define MPC_RNDAU MPC_RND (MPFR_RNDA,MPFR_RNDU) +#define MPC_RNDAD MPC_RND (MPFR_RNDA,MPFR_RNDD) +#define MPC_RNDAA MPC_RND (MPFR_RNDA,MPFR_RNDA) + + +/* Definitions of types and their semantics */ + +typedef struct { + mpfr_t re; + mpfr_t im; +} +__mpc_struct; + +typedef __mpc_struct mpc_t[1]; +typedef __mpc_struct *mpc_ptr; +typedef const __mpc_struct *mpc_srcptr; + +typedef struct { + int64_t mant; + int64_t exp; +} +__mpcr_struct; + +typedef __mpcr_struct mpcr_t [1]; +typedef __mpcr_struct *mpcr_ptr; +typedef const __mpcr_struct *mpcr_srcptr; + +typedef struct { + mpc_t c; + mpcr_t r; +} +__mpcb_struct; + +typedef __mpcb_struct mpcb_t [1]; +typedef __mpcb_struct *mpcb_ptr; +typedef const __mpcb_struct *mpcb_srcptr; + +/* Support for WINDOWS DLL, see + https://sympa.inria.fr/sympa/arc/mpc-discuss/2011-11/ ; + when building the DLL, export symbols, otherwise behave as GMP */ +#if defined (__MPC_LIBRARY_BUILD) && __GMP_LIBGMP_DLL +#define __MPC_DECLSPEC __GMP_DECLSPEC_EXPORT +#else +#define __MPC_DECLSPEC __GMP_DECLSPEC +#endif + +#if defined (__cplusplus) +extern "C" { +#endif + +__MPC_DECLSPEC int mpc_add (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_add_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_add_si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_add_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_sub (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_sub_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_fr_sub (mpc_ptr, mpfr_srcptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_sub_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_ui_ui_sub (mpc_ptr, unsigned long int, unsigned long int, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_mul (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_mul_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_mul_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_mul_si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_mul_i (mpc_ptr, mpc_srcptr, int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_sqr (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_div (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_pow (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_pow_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_pow_ld (mpc_ptr, mpc_srcptr, long double, mpc_rnd_t); +__MPC_DECLSPEC int mpc_pow_d (mpc_ptr, mpc_srcptr, double, mpc_rnd_t); +__MPC_DECLSPEC int mpc_pow_si (mpc_ptr, mpc_srcptr, long, mpc_rnd_t); +__MPC_DECLSPEC int mpc_pow_ui (mpc_ptr, mpc_srcptr, unsigned long, mpc_rnd_t); +__MPC_DECLSPEC int mpc_pow_z (mpc_ptr, mpc_srcptr, mpz_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_div_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_fr_div (mpc_ptr, mpfr_srcptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_div_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_ui_div (mpc_ptr, unsigned long int, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_div_2ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_mul_2ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_div_2si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_mul_2si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_conj (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_neg (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_sum (mpc_ptr, const mpc_ptr *, unsigned long, mpc_rnd_t); +__MPC_DECLSPEC int mpc_dot (mpc_ptr, const mpc_ptr *, const mpc_ptr *, unsigned long, mpc_rnd_t); +__MPC_DECLSPEC int mpc_norm (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); +__MPC_DECLSPEC int mpc_abs (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); +__MPC_DECLSPEC int mpc_sqrt (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_d (mpc_ptr, double, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_d_d (mpc_ptr, double, double, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_ld (mpc_ptr, long double, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_ld_ld (mpc_ptr, long double, long double, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_f (mpc_ptr, mpf_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_f_f (mpc_ptr, mpf_srcptr, mpf_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_fr (mpc_ptr, mpfr_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_fr_fr (mpc_ptr, mpfr_srcptr, mpfr_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_q (mpc_ptr, mpq_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_q_q (mpc_ptr, mpq_srcptr, mpq_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_si (mpc_ptr, long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_si_si (mpc_ptr, long int, long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_ui (mpc_ptr, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_ui_ui (mpc_ptr, unsigned long int, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_z (mpc_ptr, mpz_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_z_z (mpc_ptr, mpz_srcptr, mpz_srcptr, mpc_rnd_t); +__MPC_DECLSPEC void mpc_swap (mpc_ptr, mpc_ptr); +__MPC_DECLSPEC int mpc_fma (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); + +__MPC_DECLSPEC void mpc_set_nan (mpc_ptr); + +__MPC_DECLSPEC int mpc_real (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); +__MPC_DECLSPEC int mpc_imag (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); +__MPC_DECLSPEC int mpc_arg (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); +__MPC_DECLSPEC int mpc_proj (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_cmp (mpc_srcptr, mpc_srcptr); +__MPC_DECLSPEC int mpc_cmp_si_si (mpc_srcptr, long int, long int); +__MPC_DECLSPEC int mpc_cmp_abs (mpc_srcptr, mpc_srcptr); +__MPC_DECLSPEC int mpc_exp (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_log (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_log10 (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_agm (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_sin (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_cos (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_sin_cos (mpc_ptr, mpc_ptr, mpc_srcptr, mpc_rnd_t, mpc_rnd_t); +__MPC_DECLSPEC int mpc_tan (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_sinh (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_cosh (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_tanh (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_asin (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_acos (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_atan (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_asinh (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_acosh (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_atanh (mpc_ptr, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_rootofunity (mpc_ptr, unsigned long int, unsigned long int, mpc_rnd_t); +__MPC_DECLSPEC void mpc_clear (mpc_ptr); +__MPC_DECLSPEC int mpc_urandom (mpc_ptr, gmp_randstate_t); +__MPC_DECLSPEC void mpc_init2 (mpc_ptr, mpfr_prec_t); +__MPC_DECLSPEC void mpc_init3 (mpc_ptr, mpfr_prec_t, mpfr_prec_t); +__MPC_DECLSPEC mpfr_prec_t mpc_get_prec (mpc_srcptr x); +__MPC_DECLSPEC void mpc_get_prec2 (mpfr_prec_t *pr, mpfr_prec_t *pi, mpc_srcptr x); +__MPC_DECLSPEC void mpc_set_prec (mpc_ptr, mpfr_prec_t); +__MPC_DECLSPEC const char * mpc_get_version (void); + +__MPC_DECLSPEC int mpc_strtoc (mpc_ptr, const char *, char **, int, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_str (mpc_ptr, const char *, int, mpc_rnd_t); +__MPC_DECLSPEC char * mpc_get_str (int, size_t, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC void mpc_free_str (char *); + +/* declare certain functions only if appropriate headers have been included */ +#ifdef _MPC_H_HAVE_INTMAX_T +__MPC_DECLSPEC int mpc_set_sj (mpc_ptr, intmax_t, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_uj (mpc_ptr, uintmax_t, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_sj_sj (mpc_ptr, intmax_t, intmax_t, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_uj_uj (mpc_ptr, uintmax_t, uintmax_t, mpc_rnd_t); +#endif + +#ifdef _Complex_I +__MPC_DECLSPEC int mpc_set_dc (mpc_ptr, double _Complex, mpc_rnd_t); +__MPC_DECLSPEC int mpc_set_ldc (mpc_ptr, long double _Complex, mpc_rnd_t); +__MPC_DECLSPEC double _Complex mpc_get_dc (mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC long double _Complex mpc_get_ldc (mpc_srcptr, mpc_rnd_t); +#endif + +#ifdef _GMP_H_HAVE_FILE +__MPC_DECLSPEC int mpc_inp_str (mpc_ptr, FILE *, size_t *, int, mpc_rnd_t); +__MPC_DECLSPEC size_t mpc_out_str (FILE *, int, size_t, mpc_srcptr, mpc_rnd_t); +__MPC_DECLSPEC void mpcb_out_str (FILE *f, mpcb_srcptr); +__MPC_DECLSPEC void mpcr_out_str (FILE *f, mpcr_srcptr r); +#endif + +__MPC_DECLSPEC int mpcr_inf_p (mpcr_srcptr r); +__MPC_DECLSPEC int mpcr_zero_p (mpcr_srcptr r); +__MPC_DECLSPEC int mpcr_lt_half_p (mpcr_srcptr r); +__MPC_DECLSPEC int mpcr_cmp (mpcr_srcptr r, mpcr_srcptr s); +__MPC_DECLSPEC void mpcr_set_inf (mpcr_ptr r); +__MPC_DECLSPEC void mpcr_set_zero (mpcr_ptr r); +__MPC_DECLSPEC void mpcr_set_one (mpcr_ptr r); +__MPC_DECLSPEC void mpcr_set (mpcr_ptr r, mpcr_srcptr s); +__MPC_DECLSPEC void mpcr_set_ui64_2si64 (mpcr_ptr r, uint64_t mant, + int64_t exp); +__MPC_DECLSPEC void mpcr_max (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); +__MPC_DECLSPEC int64_t mpcr_get_exp (mpcr_srcptr r); +__MPC_DECLSPEC void mpcr_mul (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); +__MPC_DECLSPEC void mpcr_mul_2ui (mpcr_ptr r, mpcr_srcptr s, + unsigned long int e); +__MPC_DECLSPEC void mpcr_sqr (mpcr_ptr r, mpcr_srcptr s); +__MPC_DECLSPEC void mpcr_add (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); +__MPC_DECLSPEC void mpcr_sub (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); +__MPC_DECLSPEC void mpcr_sub_rnd (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t, + mpfr_rnd_t rnd); +__MPC_DECLSPEC void mpcr_div (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); +__MPC_DECLSPEC void mpcr_div_2ui (mpcr_ptr r, mpcr_srcptr s, + unsigned long int e); +__MPC_DECLSPEC int64_t sqrt_int64 (int64_t n); +__MPC_DECLSPEC void mpcr_sqrt (mpcr_ptr r, mpcr_srcptr s); +__MPC_DECLSPEC void mpcr_add_rounding_error (mpcr_ptr r, mpfr_prec_t p, + mpfr_rnd_t rnd); +__MPC_DECLSPEC void mpcr_c_abs_rnd (mpcr_ptr r, mpc_srcptr z, + mpfr_rnd_t rnd); + +__MPC_DECLSPEC void mpcb_init (mpcb_ptr); +__MPC_DECLSPEC void mpcb_clear (mpcb_ptr); +__MPC_DECLSPEC mpfr_prec_t mpcb_get_prec (mpcb_srcptr); +__MPC_DECLSPEC void mpcb_set_prec (mpcb_ptr, mpfr_prec_t); +__MPC_DECLSPEC void mpcb_set (mpcb_ptr, mpcb_srcptr); +__MPC_DECLSPEC void mpcb_set_inf (mpcb_ptr); +__MPC_DECLSPEC void mpcb_set_c (mpcb_ptr, mpc_srcptr, mpfr_prec_t, + unsigned long int, unsigned long int); +__MPC_DECLSPEC void mpcb_set_ui_ui (mpcb_ptr, unsigned long int, + unsigned long int, mpfr_prec_t); +__MPC_DECLSPEC void mpcb_neg (mpcb_ptr, mpcb_srcptr); +__MPC_DECLSPEC void mpcb_mul (mpcb_ptr, mpcb_srcptr, mpcb_srcptr); +__MPC_DECLSPEC void mpcb_sqr (mpcb_ptr, mpcb_srcptr); +__MPC_DECLSPEC void mpcb_pow_ui (mpcb_ptr, mpcb_srcptr, unsigned long int); +__MPC_DECLSPEC void mpcb_add (mpcb_ptr, mpcb_srcptr, mpcb_srcptr); +__MPC_DECLSPEC void mpcb_sqrt (mpcb_ptr, mpcb_srcptr); +__MPC_DECLSPEC void mpcb_div (mpcb_ptr, mpcb_srcptr, mpcb_srcptr); +__MPC_DECLSPEC void mpcb_div_2ui (mpcb_ptr, mpcb_srcptr, unsigned long int); +__MPC_DECLSPEC int mpcb_can_round (mpcb_srcptr, mpfr_prec_t, mpfr_prec_t, + mpc_rnd_t); +__MPC_DECLSPEC int mpcb_round (mpc_ptr, mpcb_srcptr, mpc_rnd_t); +__MPC_DECLSPEC int mpc_eta_fund (mpc_ptr, mpc_srcptr, mpc_rnd_t); + +#if defined (__cplusplus) +} +#endif + +#define mpc_realref(x) ((x)->re) +#define mpc_imagref(x) ((x)->im) + +#define mpc_cmp_si(x, y) \ + ( mpc_cmp_si_si ((x), (y), 0l) ) +#define mpc_ui_sub(x, y, z, r) mpc_ui_ui_sub (x, y, 0ul, z, r) + +/* + Define a fake mpfr_set_fr so that, for instance, mpc_set_fr_z would + be defined as follows: + mpc_set_fr_z (mpc_t rop, mpfr_t x, mpz_t y, mpc_rnd_t rnd) + MPC_SET_X_Y (fr, z, rop, x, y, rnd) +*/ +#ifndef mpfr_set_fr +#define mpfr_set_fr mpfr_set +#endif +#define MPC_SET_X_Y(real_t, imag_t, z, real_value, imag_value, rnd) \ + { \ + int _inex_re, _inex_im; \ + _inex_re = (mpfr_set_ ## real_t) (mpc_realref (z), (real_value), MPC_RND_RE (rnd)); \ + _inex_im = (mpfr_set_ ## imag_t) (mpc_imagref (z), (imag_value), MPC_RND_IM (rnd)); \ + return MPC_INEX (_inex_re, _inex_im); \ + } + +#endif /* ifndef __MPC_H */ diff --git a/illumos-x86_64/usr/include/mpf2mpfr.h b/illumos-x86_64/usr/include/mpf2mpfr.h new file mode 100644 index 00000000..a47c51ae --- /dev/null +++ b/illumos-x86_64/usr/include/mpf2mpfr.h @@ -0,0 +1,187 @@ +/* mpf2mpfr.h -- Compatibility include file with mpf. + +Copyright 1999-2002, 2004-2025 Free Software Foundation, Inc. +Contributed by the Pascaline and Caramba projects, INRIA. + +This file is part of the GNU MPFR Library. + +The GNU MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +The GNU MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MPFR Library; see the file COPYING.LESSER. +If not, see . */ + +#ifndef __MPFR_FROM_MPF__ +#define __MPFR_FROM_MPF__ + +/* types */ +#define mpf_t mpfr_t +#define mpf_srcptr mpfr_srcptr +#define mpf_ptr mpfr_ptr + +/* Get current Rounding Mode */ +#ifndef MPFR_DEFAULT_RND +# define MPFR_DEFAULT_RND mpfr_get_default_rounding_mode () +#endif + +/* mpf_init initializes at 0 */ +#undef mpf_init +#define mpf_init(x) mpfr_init_set_ui ((x), 0, MPFR_DEFAULT_RND) +#undef mpf_init2 +#define mpf_init2(x,p) (mpfr_init2((x),(p)), mpfr_set_ui ((x), 0, MPFR_DEFAULT_RND)) + +/* Warning! This assumes that all pointer types have the same representation. */ +#undef mpf_inits +#define mpf_inits mpfr_inits +#undef mpf_clears +#define mpf_clears mpfr_clears + +/* functions which don't take as argument the rounding mode */ +#undef mpf_ceil +#define mpf_ceil mpfr_ceil +#undef mpf_clear +#define mpf_clear mpfr_clear +#undef mpf_cmp +#define mpf_cmp mpfr_cmp +#undef mpf_cmp_si +#define mpf_cmp_si mpfr_cmp_si +#undef mpf_cmp_ui +#define mpf_cmp_ui mpfr_cmp_ui +#undef mpf_cmp_d +#define mpf_cmp_d mpfr_cmp_d +/* mpf_cmp_z appeared in GMP 6.1.0 */ +#if __GNU_MP_VERSION > 6 || (__GNU_MP_VERSION == 6 && __GNU_MP_VERSION_MINOR >= 1) +#undef mpf_cmp_z +#define mpf_cmp_z mpfr_cmp_z +#endif +#undef mpf_eq +#define mpf_eq mpfr_eq +#undef mpf_floor +#define mpf_floor mpfr_floor +#undef mpf_get_prec +#define mpf_get_prec mpfr_get_prec +#undef mpf_integer_p +#define mpf_integer_p mpfr_integer_p +#undef mpf_random2 +#define mpf_random2 mpfr_random2 +#undef mpf_set_default_prec +#define mpf_set_default_prec mpfr_set_default_prec +#undef mpf_get_default_prec +#define mpf_get_default_prec mpfr_get_default_prec +#undef mpf_set_prec +#define mpf_set_prec mpfr_set_prec +#undef mpf_set_prec_raw +#define mpf_set_prec_raw(x,p) mpfr_prec_round(x,p,MPFR_DEFAULT_RND) +#undef mpf_trunc +#define mpf_trunc mpfr_trunc +#undef mpf_sgn +#define mpf_sgn mpfr_sgn +#undef mpf_swap +#define mpf_swap mpfr_swap +#undef mpf_dump +#define mpf_dump mpfr_dump + +/* functions which take as argument the rounding mode */ +#undef mpf_abs +#define mpf_abs(x,y) mpfr_abs(x,y,MPFR_DEFAULT_RND) +#undef mpf_add +#define mpf_add(x,y,z) mpfr_add(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_add_ui +#define mpf_add_ui(x,y,z) mpfr_add_ui(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_div +#define mpf_div(x,y,z) mpfr_div(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_div_ui +#define mpf_div_ui(x,y,z) mpfr_div_ui(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_div_2exp +#define mpf_div_2exp(x,y,z) mpfr_div_2exp(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_fits_slong_p +#define mpf_fits_slong_p(x) mpfr_fits_slong_p(x,MPFR_DEFAULT_RND) +#undef mpf_fits_ulong_p +#define mpf_fits_ulong_p(x) mpfr_fits_ulong_p(x,MPFR_DEFAULT_RND) +#undef mpf_fits_sint_p +#define mpf_fits_sint_p(x) mpfr_fits_sint_p(x,MPFR_DEFAULT_RND) +#undef mpf_fits_uint_p +#define mpf_fits_uint_p(x) mpfr_fits_uint_p(x,MPFR_DEFAULT_RND) +#undef mpf_fits_sshort_p +#define mpf_fits_sshort_p(x) mpfr_fits_sshort_p(x,MPFR_DEFAULT_RND) +#undef mpf_fits_ushort_p +#define mpf_fits_ushort_p(x) mpfr_fits_ushort_p(x,MPFR_DEFAULT_RND) +#undef mpf_get_str +#define mpf_get_str(x,y,z,t,u) mpfr_get_str(x,y,z,t,u,MPFR_DEFAULT_RND) +#undef mpf_get_d +#define mpf_get_d(x) mpfr_get_d(x,MPFR_DEFAULT_RND) +#undef mpf_get_d_2exp +#define mpf_get_d_2exp(e,x) mpfr_get_d_2exp(e,x,MPFR_DEFAULT_RND) +#undef mpf_get_ui +#define mpf_get_ui(x) mpfr_get_ui(x,MPFR_DEFAULT_RND) +#undef mpf_get_si +#define mpf_get_si(x) mpfr_get_si(x,MPFR_DEFAULT_RND) +#undef mpf_inp_str +#define mpf_inp_str(x,y,z) mpfr_inp_str(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_set_str +#define mpf_set_str(x,y,z) mpfr_set_str(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_init_set +#define mpf_init_set(x,y) mpfr_init_set(x,y,MPFR_DEFAULT_RND) +#undef mpf_init_set_d +#define mpf_init_set_d(x,y) mpfr_init_set_d(x,y,MPFR_DEFAULT_RND) +#undef mpf_init_set_si +#define mpf_init_set_si(x,y) mpfr_init_set_si(x,y,MPFR_DEFAULT_RND) +#undef mpf_init_set_str +#define mpf_init_set_str(x,y,z) mpfr_init_set_str(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_init_set_ui +#define mpf_init_set_ui(x,y) mpfr_init_set_ui(x,y,MPFR_DEFAULT_RND) +#undef mpf_mul +#define mpf_mul(x,y,z) mpfr_mul(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_mul_2exp +#define mpf_mul_2exp(x,y,z) mpfr_mul_2exp(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_mul_ui +#define mpf_mul_ui(x,y,z) mpfr_mul_ui(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_neg +#define mpf_neg(x,y) mpfr_neg(x,y,MPFR_DEFAULT_RND) +#undef mpf_out_str +#define mpf_out_str(x,y,z,t) mpfr_out_str(x,y,z,t,MPFR_DEFAULT_RND) +#undef mpf_pow_ui +#define mpf_pow_ui(x,y,z) mpfr_pow_ui(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_reldiff +#define mpf_reldiff(x,y,z) mpfr_reldiff(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_set +#define mpf_set(x,y) mpfr_set(x,y,MPFR_DEFAULT_RND) +#undef mpf_set_d +#define mpf_set_d(x,y) mpfr_set_d(x,y,MPFR_DEFAULT_RND) +#undef mpf_set_q +#define mpf_set_q(x,y) mpfr_set_q(x,y,MPFR_DEFAULT_RND) +#undef mpf_set_si +#define mpf_set_si(x,y) mpfr_set_si(x,y,MPFR_DEFAULT_RND) +#undef mpf_set_ui +#define mpf_set_ui(x,y) mpfr_set_ui(x,y,MPFR_DEFAULT_RND) +#undef mpf_set_z +#define mpf_set_z(x,y) mpfr_set_z(x,y,MPFR_DEFAULT_RND) +#undef mpf_sqrt +#define mpf_sqrt(x,y) mpfr_sqrt(x,y,MPFR_DEFAULT_RND) +#undef mpf_sqrt_ui +#define mpf_sqrt_ui(x,y) mpfr_sqrt_ui(x,y,MPFR_DEFAULT_RND) +#undef mpf_sub +#define mpf_sub(x,y,z) mpfr_sub(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_sub_ui +#define mpf_sub_ui(x,y,z) mpfr_sub_ui(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_ui_div +#define mpf_ui_div(x,y,z) mpfr_ui_div(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_ui_sub +#define mpf_ui_sub(x,y,z) mpfr_ui_sub(x,y,z,MPFR_DEFAULT_RND) +#undef mpf_urandomb +#define mpf_urandomb(x,y,n) mpfr_urandomb(x,y) + +#undef mpz_set_f +#define mpz_set_f(z,f) mpfr_get_z(z,f,MPFR_DEFAULT_RND) +#undef mpq_set_f +#define mpq_set_f(q,f) mpfr_get_q(q,f) + +#endif /* __MPFR_FROM_MPF__ */ diff --git a/illumos-x86_64/usr/include/mpfr.h b/illumos-x86_64/usr/include/mpfr.h new file mode 100644 index 00000000..117673b2 --- /dev/null +++ b/illumos-x86_64/usr/include/mpfr.h @@ -0,0 +1,1269 @@ +/* mpfr.h -- Include file for mpfr. + +Copyright 1999-2025 Free Software Foundation, Inc. +Contributed by the Pascaline and Caramba projects, INRIA. + +This file is part of the GNU MPFR Library. + +The GNU MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +The GNU MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MPFR Library; see the file COPYING.LESSER. +If not, see . */ + +#ifndef __MPFR_H +#define __MPFR_H + +/* Define MPFR version number */ +#define MPFR_VERSION_MAJOR 4 +#define MPFR_VERSION_MINOR 2 +#define MPFR_VERSION_PATCHLEVEL 2 +#define MPFR_VERSION_STRING "4.2.2" + +/* User macros: + MPFR_USE_FILE: Define it to make MPFR define functions dealing + with FILE* (auto-detect). + MPFR_USE_INTMAX_T: Define it to make MPFR define functions dealing + with intmax_t (auto-detect). + MPFR_USE_VA_LIST: Define it to make MPFR define functions dealing + with va_list (auto-detect). + MPFR_USE_C99_FEATURE: Define it to 1 to make MPFR support C99-feature + (auto-detect), to 0 to bypass the detection. + MPFR_USE_EXTENSION: Define it to make MPFR use GCC extension to + reduce warnings. + MPFR_USE_NO_MACRO: Define it to make MPFR remove any overriding + function macro. +*/ + +/* Macros dealing with MPFR VERSION */ +#define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +#define MPFR_VERSION \ +MPFR_VERSION_NUM(MPFR_VERSION_MAJOR,MPFR_VERSION_MINOR,MPFR_VERSION_PATCHLEVEL) + +#ifndef MPFR_USE_MINI_GMP +#include +#else +#include +#endif + +/* Avoid some problems with macro expansion if the user defines macros + with the same name as keywords. By convention, identifiers and macro + names starting with mpfr_ are reserved by MPFR. */ +typedef void mpfr_void; +typedef int mpfr_int; +typedef unsigned int mpfr_uint; +typedef long mpfr_long; +typedef unsigned long mpfr_ulong; +typedef size_t mpfr_size_t; + +/* Global (possibly TLS) flags. Might also be used in an mpfr_t in the + future (there would be room as mpfr_sign_t just needs 1 byte). + TODO: The tests currently assume that the flags fits in an unsigned int; + this should be cleaned up, e.g. by defining a function that outputs the + flags as a string or by using the flags_out function (from tests/tests.c + directly). */ +typedef unsigned int mpfr_flags_t; + +/* Flags macros (in the public API) */ +#define MPFR_FLAGS_UNDERFLOW 1 +#define MPFR_FLAGS_OVERFLOW 2 +#define MPFR_FLAGS_NAN 4 +#define MPFR_FLAGS_INEXACT 8 +#define MPFR_FLAGS_ERANGE 16 +#define MPFR_FLAGS_DIVBY0 32 +#define MPFR_FLAGS_ALL (MPFR_FLAGS_UNDERFLOW | \ + MPFR_FLAGS_OVERFLOW | \ + MPFR_FLAGS_NAN | \ + MPFR_FLAGS_INEXACT | \ + MPFR_FLAGS_ERANGE | \ + MPFR_FLAGS_DIVBY0) + +/* Definition of rounding modes (DON'T USE MPFR_RNDNA!). + Warning! Changing the contents of this enum should be seen as an + interface change since the old and the new types are not compatible + (the integer type compatible with the enumerated type can even change, + see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0. + + MPFR_RNDU must appear just before MPFR_RNDD (see + MPFR_IS_RNDUTEST_OR_RNDDNOTTEST in mpfr-impl.h). + + If you change the order of the rounding modes, please update the routines + in texceptions.c which assume 0=RNDN, 1=RNDZ, 2=RNDU, 3=RNDD, 4=RNDA. +*/ +typedef enum { + MPFR_RNDN=0, /* round to nearest, with ties to even */ + MPFR_RNDZ, /* round toward zero */ + MPFR_RNDU, /* round toward +Inf */ + MPFR_RNDD, /* round toward -Inf */ + MPFR_RNDA, /* round away from zero */ + MPFR_RNDF, /* faithful rounding */ + MPFR_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */ +} mpfr_rnd_t; + +/* kept for compatibility with MPFR 2.4.x and before */ +#define GMP_RNDN MPFR_RNDN +#define GMP_RNDZ MPFR_RNDZ +#define GMP_RNDU MPFR_RNDU +#define GMP_RNDD MPFR_RNDD + +/* The _MPFR_PREC_FORMAT and _MPFR_EXP_FORMAT values are automatically + defined below. You MUST NOT force a value (this will break the ABI), + possibly except for a very particular use, in which case you also need + to rebuild the MPFR library with the chosen values; do not install this + rebuilt library in a path that is searched by default, otherwise this + will break applications that are dynamically linked with MPFR. + + Using non-default values is not guaranteed to work. + + Note: With the following default choices for _MPFR_PREC_FORMAT and + _MPFR_EXP_FORMAT, mpfr_exp_t will be the same as [mp_exp_t] (at least + up to GMP 6). */ + +/* Define precision: 1 (short), 2 (int) or 3 (long). + DON'T FORCE A VALUE (see above). */ +#ifndef _MPFR_PREC_FORMAT +# if __GMP_MP_SIZE_T_INT +# define _MPFR_PREC_FORMAT 2 +# else +# define _MPFR_PREC_FORMAT 3 +# endif +#endif + +/* Define exponent: 1 (short), 2 (int), 3 (long) or 4 (intmax_t). + DON'T FORCE A VALUE (see above). */ +#ifndef _MPFR_EXP_FORMAT +# define _MPFR_EXP_FORMAT _MPFR_PREC_FORMAT +#endif + +#if _MPFR_PREC_FORMAT > _MPFR_EXP_FORMAT +# error "mpfr_prec_t must not be larger than mpfr_exp_t" +#endif + +/* Let's make mpfr_prec_t signed in order to avoid problems due to the + usual arithmetic conversions when mixing mpfr_prec_t and mpfr_exp_t + in an expression (for error analysis) if casts are forgotten. + Note: mpfr_prec_t is currently limited to "long". This means that + under MS Windows, the precisions are limited to about 2^31; however, + these are already huge precisions, probably sufficient in practice + on this platform. */ +#if _MPFR_PREC_FORMAT == 1 +typedef short mpfr_prec_t; +typedef unsigned short mpfr_uprec_t; +#elif _MPFR_PREC_FORMAT == 2 +typedef int mpfr_prec_t; +typedef unsigned int mpfr_uprec_t; +#elif _MPFR_PREC_FORMAT == 3 +typedef long mpfr_prec_t; +typedef unsigned long mpfr_uprec_t; +#else +# error "Invalid MPFR Prec format" +#endif + +/* Definition of precision limits without needing */ +/* Note: The casts allows the expression to yield the wanted behavior + for _MPFR_PREC_FORMAT == 1 (due to integer promotion rules). We + also make sure that MPFR_PREC_MIN and MPFR_PREC_MAX have a signed + integer type. The "- 256" allows more security, avoiding some + integer overflows in extreme cases; ideally it should be useless. */ +#define MPFR_PREC_MIN 1 +#define MPFR_PREC_MAX ((mpfr_prec_t) ((((mpfr_uprec_t) -1) >> 1) - 256)) + +/* Definition of sign */ +typedef int mpfr_sign_t; + +/* Definition of the exponent. _MPFR_EXP_FORMAT must be large enough + so that mpfr_exp_t has at least 32 bits. */ +#if _MPFR_EXP_FORMAT == 1 +typedef short mpfr_exp_t; +typedef unsigned short mpfr_uexp_t; +#elif _MPFR_EXP_FORMAT == 2 +typedef int mpfr_exp_t; +typedef unsigned int mpfr_uexp_t; +#elif _MPFR_EXP_FORMAT == 3 +typedef long mpfr_exp_t; +typedef unsigned long mpfr_uexp_t; +#elif _MPFR_EXP_FORMAT == 4 +/* Note: in this case, intmax_t and uintmax_t must be defined before + the inclusion of mpfr.h (we do not include here due to + potential issues with non-ISO implementations, on which there are + alternative ways to define these types). + In all known implementations, intmax_t has exactly 64 bits and is + equivalent to long long when defined, but when long has 64 bits, + it may be defined as long by for better portability + with old compilers, thus offers more flexibility than long long. + This may change in the future. + This _MPFR_EXP_FORMAT value is currently not supported since the + MPFR code assumes that mpfr_exp_t fits in a long. Some examples + of problematic code can be obtained with: + grep -E 'mpfr_cmp_[su]i *\(.*__gmpfr_em' *.c +*/ +typedef intmax_t mpfr_exp_t; +typedef uintmax_t mpfr_uexp_t; +#else +# error "Invalid MPFR Exp format" +#endif + +/* Definition of the standard exponent limits */ +#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1)) +#define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT)) + +/* DON'T USE THIS! (For MPFR-public macros only, see below.) + The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO + are the smallest values. For a n-bit type, EXP_MAX is 2^(n-1)-1, + EXP_ZERO is 1-2^(n-1), EXP_NAN is 2-2^(n-1), EXP_INF is 3-2^(n-1). + This may change in the future. MPFR code should not be based on these + representations (but if this is absolutely needed, protect the code + with a static assertion). */ +#define __MPFR_EXP_MAX ((mpfr_exp_t) (((mpfr_uexp_t) -1) >> 1)) +#define __MPFR_EXP_NAN (1 - __MPFR_EXP_MAX) +#define __MPFR_EXP_ZERO (0 - __MPFR_EXP_MAX) +#define __MPFR_EXP_INF (2 - __MPFR_EXP_MAX) + +/* Definition of the main structure */ +typedef struct { + mpfr_prec_t _mpfr_prec; + mpfr_sign_t _mpfr_sign; + mpfr_exp_t _mpfr_exp; + mp_limb_t *_mpfr_d; +} __mpfr_struct; + +/* Compatibility with previous types of MPFR */ +#ifndef mp_rnd_t +# define mp_rnd_t mpfr_rnd_t +#endif +#ifndef mp_prec_t +# define mp_prec_t mpfr_prec_t +#endif + +/* + The represented number is + _sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp + where k=ceil(_mp_prec/GMP_NUMB_BITS) and B=2^GMP_NUMB_BITS. + + For the msb (most significant bit) normalized representation, we must have + _d[k-1]>=B/2, unless the number is singular. + + We must also have the last k*GMP_NUMB_BITS-_prec bits set to zero. +*/ + +typedef __mpfr_struct mpfr_t[1]; +typedef __mpfr_struct *mpfr_ptr; +typedef const __mpfr_struct *mpfr_srcptr; + +/* For those who need a direct and fast access to the sign field. + However, it is not in the API, thus use it at your own risk: it + might not be supported, or change name, in further versions! + Unfortunately, it must be defined here (instead of MPFR's internal + header file mpfr-impl.h) because it is used by some macros below. +*/ +#define MPFR_SIGN(x) ((x)->_mpfr_sign) + +/* Custom interface */ +typedef enum { + MPFR_NAN_KIND = 0, + MPFR_INF_KIND = 1, + MPFR_ZERO_KIND = 2, + MPFR_REGULAR_KIND = 3 +} mpfr_kind_t; + +/* Free cache policy */ +typedef enum { + MPFR_FREE_LOCAL_CACHE = 1, /* 1 << 0 */ + MPFR_FREE_GLOBAL_CACHE = 2 /* 1 << 1 */ +} mpfr_free_cache_t; + +/* GMP defines: + + size_t: Standard size_t + + __GMP_NOTHROW For C++: can't throw . + + __GMP_EXTERN_INLINE Attribute for inline function. + + __GMP_DECLSPEC_EXPORT compiling to go into a DLL + + __GMP_DECLSPEC_IMPORT compiling to go into a application +*/ +/* Extra MPFR defines */ +#define __MPFR_SENTINEL_ATTR +#if defined (__GNUC__) +# if __GNUC__ >= 4 +# undef __MPFR_SENTINEL_ATTR +# define __MPFR_SENTINEL_ATTR __attribute__ ((__sentinel__)) +# endif +#endif + +/* If the user hasn't requested his/her preference + and if the intention of support by the compiler is C99 + and if the compiler is known to support the C99 feature + then we can auto-detect the C99 support as OK. + __GNUC__ is used to detect GNU-C, ICC & CLANG compilers. + Currently we need only variadic macros, and they are present + since GCC >= 3. We don't test library version since we don't + use any feature present in the library too (except intmax_t, + but they use another detection).*/ +#ifndef MPFR_USE_C99_FEATURE +# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +# if defined (__GNUC__) +# if __GNUC__ >= 3 +# define MPFR_USE_C99_FEATURE 1 +# endif +# endif +# endif +# ifndef MPFR_USE_C99_FEATURE +# define MPFR_USE_C99_FEATURE 0 +# endif +#endif + +/* Support for WINDOWS Dll: + Check if we are inside a MPFR build, and if so export the functions. + Otherwise does the same thing as GMP */ +#if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL +# define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT +#else +# ifndef __GMP_DECLSPEC +# define __GMP_DECLSPEC +# endif +# define __MPFR_DECLSPEC __GMP_DECLSPEC +#endif + +/* Use MPFR_DEPRECATED to mark MPFR functions, types or variables as + deprecated. Code inspired by Apache Subversion's svn_types.h file. + For compatibility with MSVC, MPFR_DEPRECATED must be put before + __MPFR_DECLSPEC (not at the end of the function declaration as + documented in the GCC manual); GCC does not seem to care. + Moreover, in order to avoid a warning when testing such functions, + do something like: + +------------------------------------------ + |#ifndef _MPFR_NO_DEPRECATED_funcname + |MPFR_DEPRECATED + |#endif + |__MPFR_DECLSPEC int mpfr_funcname (...); + +------------------------------------------ + and in the corresponding test program: + +------------------------------------------ + |#define _MPFR_NO_DEPRECATED_funcname + |#include "mpfr-test.h" + +------------------------------------------ +*/ +#if defined(__GNUC__) && \ + (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +# define MPFR_DEPRECATED __attribute__ ((__deprecated__)) +#elif defined(_MSC_VER) && _MSC_VER >= 1300 +# define MPFR_DEPRECATED __declspec(deprecated) +#else +# define MPFR_DEPRECATED +#endif +/* TODO: Also define MPFR_EXPERIMENTAL for experimental functions? + See SVN_EXPERIMENTAL in Subversion 1.9+ as an example: + __attribute__((__warning__("..."))) can be used with GCC 4.3.1+ but + not __llvm__, and __declspec(deprecated("...")) can be used with + MSC as above. */ + +/* ICC up to 19.1.3.304 at least declares itself as interoperable with + GCC 4.9, but does not support the returns_nonnull attribute, thus + outputs warning #1292. This minor issue has been reported in 2019-04: + https://community.intel.com/t5/Intel-C-Compiler/Missing-support-for-returns-nonnull-attribute/td-p/1183013 */ +#if defined(__GNUC__) && \ + (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) +# define MPFR_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) +#else +# define MPFR_RETURNS_NONNULL +#endif + +/* Note: In order to be declared, some functions need a specific + system header to be included *before* "mpfr.h". If the user + forgets to include the header, the MPFR function prototype in + the user object file is not correct. To avoid wrong results, + we raise a linker error in that case by changing their internal + name in the library (prefixed by __gmpfr instead of mpfr). See + the lines of the form "#define mpfr_xxx __gmpfr_xxx" below. */ + +#if defined (__cplusplus) +extern "C" { +#endif + +__MPFR_DECLSPEC MPFR_RETURNS_NONNULL const char * mpfr_get_version (void); +__MPFR_DECLSPEC MPFR_RETURNS_NONNULL const char * mpfr_get_patches (void); + +__MPFR_DECLSPEC int mpfr_buildopt_tls_p (void); +__MPFR_DECLSPEC int mpfr_buildopt_float128_p (void); +__MPFR_DECLSPEC int mpfr_buildopt_decimal_p (void); +__MPFR_DECLSPEC int mpfr_buildopt_gmpinternals_p (void); +__MPFR_DECLSPEC int mpfr_buildopt_sharedcache_p (void); +__MPFR_DECLSPEC MPFR_RETURNS_NONNULL const char * + mpfr_buildopt_tune_case (void); + +__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin (void); +__MPFR_DECLSPEC int mpfr_set_emin (mpfr_exp_t); +__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_min (void); +__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_max (void); +__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax (void); +__MPFR_DECLSPEC int mpfr_set_emax (mpfr_exp_t); +__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_min (void); +__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_max (void); + +__MPFR_DECLSPEC void mpfr_set_default_rounding_mode (mpfr_rnd_t); +__MPFR_DECLSPEC mpfr_rnd_t mpfr_get_default_rounding_mode (void); +__MPFR_DECLSPEC const char * mpfr_print_rnd_mode (mpfr_rnd_t); + +__MPFR_DECLSPEC void mpfr_clear_flags (void); +__MPFR_DECLSPEC void mpfr_clear_underflow (void); +__MPFR_DECLSPEC void mpfr_clear_overflow (void); +__MPFR_DECLSPEC void mpfr_clear_divby0 (void); +__MPFR_DECLSPEC void mpfr_clear_nanflag (void); +__MPFR_DECLSPEC void mpfr_clear_inexflag (void); +__MPFR_DECLSPEC void mpfr_clear_erangeflag (void); + +__MPFR_DECLSPEC void mpfr_set_underflow (void); +__MPFR_DECLSPEC void mpfr_set_overflow (void); +__MPFR_DECLSPEC void mpfr_set_divby0 (void); +__MPFR_DECLSPEC void mpfr_set_nanflag (void); +__MPFR_DECLSPEC void mpfr_set_inexflag (void); +__MPFR_DECLSPEC void mpfr_set_erangeflag (void); + +__MPFR_DECLSPEC int mpfr_underflow_p (void); +__MPFR_DECLSPEC int mpfr_overflow_p (void); +__MPFR_DECLSPEC int mpfr_divby0_p (void); +__MPFR_DECLSPEC int mpfr_nanflag_p (void); +__MPFR_DECLSPEC int mpfr_inexflag_p (void); +__MPFR_DECLSPEC int mpfr_erangeflag_p (void); + +__MPFR_DECLSPEC void mpfr_flags_clear (mpfr_flags_t); +__MPFR_DECLSPEC void mpfr_flags_set (mpfr_flags_t); +__MPFR_DECLSPEC mpfr_flags_t mpfr_flags_test (mpfr_flags_t); +__MPFR_DECLSPEC mpfr_flags_t mpfr_flags_save (void); +__MPFR_DECLSPEC void mpfr_flags_restore (mpfr_flags_t, + mpfr_flags_t); + +__MPFR_DECLSPEC int mpfr_check_range (mpfr_ptr, int, mpfr_rnd_t); + +__MPFR_DECLSPEC void mpfr_init2 (mpfr_ptr, mpfr_prec_t); +__MPFR_DECLSPEC void mpfr_init (mpfr_ptr); +__MPFR_DECLSPEC void mpfr_clear (mpfr_ptr); + +__MPFR_DECLSPEC void + mpfr_inits2 (mpfr_prec_t, mpfr_ptr, ...) __MPFR_SENTINEL_ATTR; +__MPFR_DECLSPEC void + mpfr_inits (mpfr_ptr, ...) __MPFR_SENTINEL_ATTR; +__MPFR_DECLSPEC void + mpfr_clears (mpfr_ptr, ...) __MPFR_SENTINEL_ATTR; + +__MPFR_DECLSPEC int mpfr_prec_round (mpfr_ptr, mpfr_prec_t, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_can_round (mpfr_srcptr, mpfr_exp_t, mpfr_rnd_t, + mpfr_rnd_t, mpfr_prec_t); +__MPFR_DECLSPEC mpfr_prec_t mpfr_min_prec (mpfr_srcptr); + +__MPFR_DECLSPEC mpfr_exp_t mpfr_get_exp (mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_set_exp (mpfr_ptr, mpfr_exp_t); +__MPFR_DECLSPEC mpfr_prec_t mpfr_get_prec (mpfr_srcptr); +__MPFR_DECLSPEC void mpfr_set_prec (mpfr_ptr, mpfr_prec_t); +__MPFR_DECLSPEC void mpfr_set_prec_raw (mpfr_ptr, mpfr_prec_t); +__MPFR_DECLSPEC void mpfr_set_default_prec (mpfr_prec_t); +__MPFR_DECLSPEC mpfr_prec_t mpfr_get_default_prec (void); + +__MPFR_DECLSPEC int mpfr_set_d (mpfr_ptr, double, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_flt (mpfr_ptr, float, mpfr_rnd_t); +#ifdef MPFR_WANT_DECIMAL_FLOATS +/* _Decimal64 is not defined in C++, + cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51364 */ +__MPFR_DECLSPEC int mpfr_set_decimal64 (mpfr_ptr, _Decimal64, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_decimal128 (mpfr_ptr, _Decimal128, mpfr_rnd_t); +#endif +__MPFR_DECLSPEC int mpfr_set_ld (mpfr_ptr, long double, mpfr_rnd_t); +#ifdef MPFR_WANT_FLOAT128 +/* The user is free to define mpfr_float128 as another equivalent type, + such as __float128 if this one is supported by the current compiler + but _Float128 isn't. */ +# ifndef mpfr_float128 +# define mpfr_float128 _Float128 +# endif +__MPFR_DECLSPEC int mpfr_set_float128 (mpfr_ptr, mpfr_float128, mpfr_rnd_t); +__MPFR_DECLSPEC mpfr_float128 mpfr_get_float128 (mpfr_srcptr, mpfr_rnd_t); +#endif +__MPFR_DECLSPEC int mpfr_set_z (mpfr_ptr, mpz_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_z_2exp (mpfr_ptr, mpz_srcptr, mpfr_exp_t, + mpfr_rnd_t); +__MPFR_DECLSPEC void mpfr_set_nan (mpfr_ptr); +__MPFR_DECLSPEC void mpfr_set_inf (mpfr_ptr, int); +__MPFR_DECLSPEC void mpfr_set_zero (mpfr_ptr, int); + +#ifndef MPFR_USE_MINI_GMP + /* mini-gmp does not provide mpf_t, we disable the following functions */ +__MPFR_DECLSPEC int mpfr_set_f (mpfr_ptr, mpf_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cmp_f (mpfr_srcptr, mpf_srcptr); +__MPFR_DECLSPEC int mpfr_get_f (mpf_ptr, mpfr_srcptr, mpfr_rnd_t); +#endif +__MPFR_DECLSPEC int mpfr_set_si (mpfr_ptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_si_2exp (mpfr_ptr, long, mpfr_exp_t, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_ui_2exp (mpfr_ptr, unsigned long, mpfr_exp_t, + mpfr_rnd_t); +#ifndef MPFR_USE_MINI_GMP + /* mini-gmp does not provide mpq_t, we disable the following functions */ +__MPFR_DECLSPEC int mpfr_set_q (mpfr_ptr, mpq_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_mul_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_add_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sub_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cmp_q (mpfr_srcptr, mpq_srcptr); +__MPFR_DECLSPEC void mpfr_get_q (mpq_ptr q, mpfr_srcptr f); +#endif +__MPFR_DECLSPEC int mpfr_set_str (mpfr_ptr, const char *, int, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_init_set_str (mpfr_ptr, const char *, int, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set4 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int); +__MPFR_DECLSPEC int mpfr_abs (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_neg (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_signbit (mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_setsign (mpfr_ptr, mpfr_srcptr, int, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_copysign (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, + mpfr_rnd_t); + +__MPFR_DECLSPEC mpfr_exp_t mpfr_get_z_2exp (mpz_ptr, mpfr_srcptr); +__MPFR_DECLSPEC float mpfr_get_flt (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC double mpfr_get_d (mpfr_srcptr, mpfr_rnd_t); +#ifdef MPFR_WANT_DECIMAL_FLOATS +__MPFR_DECLSPEC _Decimal64 mpfr_get_decimal64 (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC _Decimal128 mpfr_get_decimal128 (mpfr_srcptr, mpfr_rnd_t); +#endif +__MPFR_DECLSPEC long double mpfr_get_ld (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC double mpfr_get_d1 (mpfr_srcptr); +__MPFR_DECLSPEC double mpfr_get_d_2exp (long*, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC long double mpfr_get_ld_2exp (long*, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_frexp (mpfr_exp_t*, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC long mpfr_get_si (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC unsigned long mpfr_get_ui (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC size_t mpfr_get_str_ndigits (int, mpfr_prec_t); +__MPFR_DECLSPEC char * mpfr_get_str (char*, mpfr_exp_t*, int, size_t, + mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mpfr_rnd_t); + +__MPFR_DECLSPEC void mpfr_free_str (char *); + +__MPFR_DECLSPEC int mpfr_urandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t); +#ifndef _MPFR_NO_DEPRECATED_GRANDOM /* for the test of this function */ +MPFR_DEPRECATED +#endif +__MPFR_DECLSPEC int mpfr_grandom (mpfr_ptr, mpfr_ptr, gmp_randstate_t, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_nrandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_erandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_urandomb (mpfr_ptr, gmp_randstate_t); + +__MPFR_DECLSPEC void mpfr_nextabove (mpfr_ptr); +__MPFR_DECLSPEC void mpfr_nextbelow (mpfr_ptr); +__MPFR_DECLSPEC void mpfr_nexttoward (mpfr_ptr, mpfr_srcptr); + +#ifndef MPFR_USE_MINI_GMP +__MPFR_DECLSPEC int mpfr_printf (const char*, ...); +__MPFR_DECLSPEC int mpfr_asprintf (char**, const char*, ...); +__MPFR_DECLSPEC int mpfr_sprintf (char*, const char*, ...); +__MPFR_DECLSPEC int mpfr_snprintf (char*, size_t, const char*, ...); +#endif + +__MPFR_DECLSPEC int mpfr_pow (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_powr (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_pow_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_compound_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_pow_ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_ui_pow_ui (mpfr_ptr, unsigned long, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_ui_pow (mpfr_ptr, unsigned long, mpfr_srcptr, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_pow_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_sqrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sqrt_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_rec_sqrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_add (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sub (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_mul (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_add_ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sub_ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_ui_sub (mpfr_ptr, unsigned long, mpfr_srcptr, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_mul_ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div_ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_ui_div (mpfr_ptr, unsigned long, mpfr_srcptr, + mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_add_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sub_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_si_sub (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_mul_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_si_div (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_add_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sub_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_d_sub (mpfr_ptr, double, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_mul_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_d_div (mpfr_ptr, double, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_sqr (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_const_pi (mpfr_ptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_const_log2 (mpfr_ptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_const_euler (mpfr_ptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_const_catalan (mpfr_ptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_agm (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_log (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_log2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_log10 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_log1p (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_log2p1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_log10p1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_log_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_exp (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_exp2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_exp10 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_expm1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_exp2m1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_exp10m1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_eint (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_li2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_cmp (mpfr_srcptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_cmp3 (mpfr_srcptr, mpfr_srcptr, int); +__MPFR_DECLSPEC int mpfr_cmp_d (mpfr_srcptr, double); +__MPFR_DECLSPEC int mpfr_cmp_ld (mpfr_srcptr, long double); +__MPFR_DECLSPEC int mpfr_cmp_ui (mpfr_srcptr, unsigned long); +__MPFR_DECLSPEC int mpfr_cmp_si (mpfr_srcptr, long); +__MPFR_DECLSPEC int mpfr_cmp_ui_2exp (mpfr_srcptr, unsigned long, mpfr_exp_t); +__MPFR_DECLSPEC int mpfr_cmp_si_2exp (mpfr_srcptr, long, mpfr_exp_t); +__MPFR_DECLSPEC int mpfr_cmpabs (mpfr_srcptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_cmpabs_ui (mpfr_srcptr, unsigned long); +__MPFR_DECLSPEC void mpfr_reldiff (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_eq (mpfr_srcptr, mpfr_srcptr, unsigned long); +__MPFR_DECLSPEC int mpfr_sgn (mpfr_srcptr); + +__MPFR_DECLSPEC int mpfr_mul_2exp (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div_2exp (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_mul_2ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div_2ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_mul_2si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div_2si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_rint (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_roundeven (mpfr_ptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_round (mpfr_ptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_trunc (mpfr_ptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_ceil (mpfr_ptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_floor (mpfr_ptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_rint_roundeven (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_rint_round (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_rint_trunc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_rint_ceil (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_rint_floor (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_frac (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_modf (mpfr_ptr, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_remquo (mpfr_ptr, long*, mpfr_srcptr, mpfr_srcptr, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_remainder (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fmod (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fmod_ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fmodquo (mpfr_ptr, long*, mpfr_srcptr, mpfr_srcptr, + mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_fits_ulong_p (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fits_slong_p (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fits_uint_p (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fits_sint_p (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fits_ushort_p (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fits_sshort_p (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fits_uintmax_p (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fits_intmax_p (mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC void mpfr_extract (mpz_ptr, mpfr_srcptr, unsigned int); +__MPFR_DECLSPEC void mpfr_swap (mpfr_ptr, mpfr_ptr); +__MPFR_DECLSPEC void mpfr_dump (mpfr_srcptr); + +__MPFR_DECLSPEC int mpfr_nan_p (mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_inf_p (mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_number_p (mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_integer_p (mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_zero_p (mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_regular_p (mpfr_srcptr); + +__MPFR_DECLSPEC int mpfr_greater_p (mpfr_srcptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_greaterequal_p (mpfr_srcptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_less_p (mpfr_srcptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_lessequal_p (mpfr_srcptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_lessgreater_p (mpfr_srcptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_equal_p (mpfr_srcptr, mpfr_srcptr); +__MPFR_DECLSPEC int mpfr_unordered_p (mpfr_srcptr, mpfr_srcptr); + +__MPFR_DECLSPEC int mpfr_atanh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_acosh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_asinh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cosh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sinh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_tanh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sinh_cosh (mpfr_ptr, mpfr_ptr, mpfr_srcptr, + mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_sech (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_csch (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_coth (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_acos (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_asin (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_atan (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sin (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sin_cos (mpfr_ptr, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cos (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_tan (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_atan2 (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sec (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_csc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cot (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_sinu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cosu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_tanu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_acosu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_asinu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_atanu (mpfr_ptr, mpfr_srcptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_atan2u (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_acospi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_asinpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_atanpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_atan2pi (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_sinpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cospi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_tanpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_hypot (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_erf (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_erfc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cbrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +#ifndef _MPFR_NO_DEPRECATED_ROOT /* for the test of this function */ +MPFR_DEPRECATED +#endif +__MPFR_DECLSPEC int mpfr_root (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_rootn_ui (mpfr_ptr, mpfr_srcptr, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_rootn_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_gamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_gamma_inc (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_beta (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_lngamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_lgamma (mpfr_ptr, int *, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_digamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_zeta (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_zeta_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fac_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_j0 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_j1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_jn (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_y0 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_y1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_yn (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_ai (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_min (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_max (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_dim (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_mul_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_div_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_add_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sub_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_z_sub (mpfr_ptr, mpz_srcptr, mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_cmp_z (mpfr_srcptr, mpz_srcptr); + +__MPFR_DECLSPEC int mpfr_fma (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fms (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fmma (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, + mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_fmms (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, + mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_sum (mpfr_ptr, const mpfr_ptr *, unsigned long, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_dot (mpfr_ptr, const mpfr_ptr *, const mpfr_ptr *, + unsigned long, mpfr_rnd_t); + +__MPFR_DECLSPEC void mpfr_free_cache (void); +__MPFR_DECLSPEC void mpfr_free_cache2 (mpfr_free_cache_t); +__MPFR_DECLSPEC void mpfr_free_pool (void); +__MPFR_DECLSPEC int mpfr_mp_memory_cleanup (void); + +__MPFR_DECLSPEC int mpfr_subnormalize (mpfr_ptr, int, mpfr_rnd_t); + +__MPFR_DECLSPEC int mpfr_strtofr (mpfr_ptr, const char *, char **, int, + mpfr_rnd_t); + +__MPFR_DECLSPEC void mpfr_round_nearest_away_begin (mpfr_ptr); +__MPFR_DECLSPEC int mpfr_round_nearest_away_end (mpfr_ptr, int); + +__MPFR_DECLSPEC size_t mpfr_custom_get_size (mpfr_prec_t); +__MPFR_DECLSPEC void mpfr_custom_init (void *, mpfr_prec_t); +__MPFR_DECLSPEC MPFR_RETURNS_NONNULL void * + mpfr_custom_get_significand (mpfr_srcptr); +__MPFR_DECLSPEC mpfr_exp_t mpfr_custom_get_exp (mpfr_srcptr); +__MPFR_DECLSPEC void mpfr_custom_move (mpfr_ptr, void *); +__MPFR_DECLSPEC void mpfr_custom_init_set (mpfr_ptr, int, mpfr_exp_t, + mpfr_prec_t, void *); +__MPFR_DECLSPEC int mpfr_custom_get_kind (mpfr_srcptr); + +__MPFR_DECLSPEC int mpfr_total_order_p (mpfr_srcptr, mpfr_srcptr); + +#if defined (__cplusplus) +} +#endif + +/* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */ +#ifndef MPFR_EXTENSION +# if defined(MPFR_USE_EXTENSION) +# define MPFR_EXTENSION __extension__ +# else +# define MPFR_EXTENSION +# endif +#endif + +/* Warning! This macro doesn't work with K&R C (e.g., compare the "gcc -E" + output with and without -traditional) and shouldn't be used internally. + For public use only, but see the MPFR manual. */ +#define MPFR_DECL_INIT(_x, _p) \ + MPFR_EXTENSION mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \ + MPFR_EXTENSION mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}} + +#if MPFR_USE_C99_FEATURE +/* C99 & C11 version: functions with multiple inputs supported */ +#define mpfr_round_nearest_away(func, rop, ...) \ + (mpfr_round_nearest_away_begin(rop), \ + mpfr_round_nearest_away_end((rop), func((rop), __VA_ARGS__, MPFR_RNDN))) +#else +/* C90 version: function with one input supported */ +#define mpfr_round_nearest_away(func, rop, op) \ + (mpfr_round_nearest_away_begin(rop), \ + mpfr_round_nearest_away_end((rop), func((rop), (op), MPFR_RNDN))) +#endif + +/* Fast access macros to replace function interface. + If the user doesn't want to use the macro interface, let him make happy + even if it produces faster and smaller code. */ +#ifndef MPFR_USE_NO_MACRO + +/* In the implementation of these macros, we need to make sure that the + arguments are evaluated one time exactly and that type conversion is + done as it would be with a function. Tests should be added to ensure + that. */ + +/* Prevent x from being used as an lvalue. + Thanks to Wojtek Lerch and Tim Rentsch for the idea. */ +#define MPFR_VALUE_OF(x) (0 ? (x) : (x)) + +/* The following macro converts the argument to mpfr_srcptr, as in type + conversion for function parameters. But it will detect disallowed + implicit conversions, e.g. when the argument has an integer type. */ +#define MPFR_SRCPTR(x) ((mpfr_srcptr) (0 ? (x) : (mpfr_srcptr) (x))) +#define MPFR_GET_SIGN(_x) MPFR_VALUE_OF(MPFR_SIGN(MPFR_SRCPTR(_x))) + +#define mpfr_nan_p(_x) (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_NAN) +#define mpfr_inf_p(_x) (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_INF) +#define mpfr_zero_p(_x) (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_ZERO) +#define mpfr_regular_p(_x) (MPFR_SRCPTR(_x)->_mpfr_exp > __MPFR_EXP_INF) + +/* mpfr_sgn is documented as a macro, thus the following code is fine. + But it would be safer to regard it as a function in some future + MPFR version. */ +#define mpfr_sgn(_x) \ + ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \ + (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \ + MPFR_SIGN (_x)) + +#define mpfr_get_prec(_x) MPFR_VALUE_OF(MPFR_SRCPTR(_x)->_mpfr_prec) +#define mpfr_get_exp(_x) MPFR_VALUE_OF(MPFR_SRCPTR(_x)->_mpfr_exp) +/* Note: Defining mpfr_get_exp() as a macro has the effect to disable + the check that the argument is a pure FP number (done in the function); + this increases the risk of undetected error and makes debugging more + complex. Is it really worth in practice? (Potential FIXME) */ + +#define mpfr_round(a,b) mpfr_rint((a), (b), MPFR_RNDNA) +#define mpfr_trunc(a,b) mpfr_rint((a), (b), MPFR_RNDZ) +#define mpfr_ceil(a,b) mpfr_rint((a), (b), MPFR_RNDU) +#define mpfr_floor(a,b) mpfr_rint((a), (b), MPFR_RNDD) + +#define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0) +#define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0) +#if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 +#define mpfr_set(a,b,r) \ + __extension__ ({ \ + mpfr_srcptr _p = (b); \ + mpfr_set4(a,_p,r,MPFR_SIGN(_p)); \ + }) +#endif +#define mpfr_abs(a,b,r) mpfr_set4(a,b,r,1) +#define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_GET_SIGN(c)) +#define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1) +#define mpfr_signbit(x) (MPFR_GET_SIGN(x) < 0) +#define mpfr_cmp(b, c) mpfr_cmp3(b, c, 1) +#define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r)) +#define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r)) + + +/* When using GCC or ICC, optimize certain common comparisons and affectations. + Added casts to improve robustness in case of undefined behavior and + compiler extensions based on UB (in particular -fwrapv). MPFR doesn't + use such extensions, but these macros will be used by 3rd-party code, + where such extensions may be required. + Moreover casts to unsigned long have been added to avoid warnings in + programs that use MPFR and are compiled with -Wconversion; such casts + are OK since if X is a constant expression, then (unsigned long) X is + also a constant expression, so that the optimizations still work. The + warnings are probably related to the following two bugs: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant) + and the casts could be removed once these bugs are fixed. + Casts shouldn't be used on the generic calls (to the ..._2exp functions), + where implicit conversions are performed. Indeed, having at least one + implicit conversion in the macro allows the compiler to emit diagnostics + when normally expected, for instance in the following call: + mpfr_set_ui (x, "foo", MPFR_RNDN); + If this is not possible (for future macros), one of the tricks described on + https://groups.google.com/g/comp.std.c/c/9Jl0giNILfg/m/e6-evyS9KukJ?pli=1 + could be used. */ +#if defined (__GNUC__) && !defined(__cplusplus) +#if (__GNUC__ >= 2) + +#undef mpfr_cmp_ui +/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. + But warning! mpfr_sgn is specified as a macro in the API, thus the macro + mustn't be used if side effects are possible, like here. */ +#define mpfr_cmp_ui(_f,_u) \ + (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \ + (mpfr_sgn) (_f) : \ + mpfr_cmp_ui_2exp ((_f), (_u), 0)) + +#undef mpfr_cmp_si +#define mpfr_cmp_si(_f,_s) \ + (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ + mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) : \ + mpfr_cmp_si_2exp ((_f), (_s), 0)) + +#if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 +#undef mpfr_set_ui +#define mpfr_set_ui(_f,_u,_r) \ + (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \ + __extension__ ({ \ + mpfr_ptr _p = (_f); \ + _p->_mpfr_sign = 1; \ + _p->_mpfr_exp = __MPFR_EXP_ZERO; \ + (mpfr_void) (_r); 0; }) : \ + mpfr_set_ui_2exp ((_f), (_u), 0, (_r))) +#endif + +#undef mpfr_set_si +#define mpfr_set_si(_f,_s,_r) \ + (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ + mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \ + mpfr_set_si_2exp ((_f), (_s), 0, (_r))) + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +/* If the source is a constant number that is a power of 2, + optimize the call */ +#undef mpfr_mul_ui +#define mpfr_mul_ui(_f, _g, _u,_r) \ + (__builtin_constant_p (_u) && (mpfr_ulong) (_u) >= 1 && \ + ((mpfr_ulong) (_u) & ((mpfr_ulong) (_u) - 1)) == 0 ? \ + mpfr_mul_2si((_f), (_g), __builtin_ctzl (_u), (_r)) : \ + mpfr_mul_ui ((_f), (_g), (_u), (_r))) +#undef mpfr_div_ui +#define mpfr_div_ui(_f, _g, _u,_r) \ + (__builtin_constant_p (_u) && (mpfr_ulong) (_u) >= 1 && \ + ((mpfr_ulong) (_u) & ((mpfr_ulong) (_u) - 1)) == 0 ? \ + mpfr_mul_2si((_f), (_g), - __builtin_ctzl (_u), (_r)) : \ + mpfr_div_ui ((_f), (_g), (_u), (_r))) +#endif + +/* If the source is a constant number that is non-negative, + optimize the call */ +#undef mpfr_mul_si +#define mpfr_mul_si(_f, _g, _s,_r) \ + (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ + mpfr_mul_ui ((_f), (_g), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \ + mpfr_mul_si ((_f), (_g), (_s), (_r))) +#undef mpfr_div_si +#define mpfr_div_si(_f, _g, _s,_r) \ + (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ + mpfr_div_ui ((_f), (_g), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \ + mpfr_div_si ((_f), (_g), (_s), (_r))) + +#endif +#endif + +/* Macro versions of the custom interface for fast access. */ + +/* The internal cast to mpfr_size_t will silent a warning with + GCC's -Wsign-conversion that could occur with user code, as + sizeof is of type size_t, which is unsigned. */ +#define mpfr_custom_get_size(p) \ + ((mpfr_size_t) \ + ((mpfr_size_t) (((mpfr_prec_t)(p) + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS) \ + * sizeof (mp_limb_t))) + +#define mpfr_custom_init(m,p) ((void) (m), (void) (p)) + +#define mpfr_custom_get_significand(x) \ + ((mpfr_void *) MPFR_VALUE_OF(MPFR_SRCPTR(x)->_mpfr_d)) + +#define mpfr_custom_get_exp(x) MPFR_VALUE_OF(MPFR_SRCPTR(x)->_mpfr_exp) + +#define mpfr_custom_move(x,m) (((mpfr_ptr) (x))->_mpfr_d = (mp_limb_t *) (m)) + +/* Note: the following macro is not usable in contexts where an expression + is expected. */ +#define mpfr_custom_init_set(x,k,e,p,m) do { \ + mpfr_ptr _x = (x); \ + mpfr_exp_t _e = (e); \ + mpfr_kind_t _t; \ + mpfr_int _s, _k; \ + _k = (k); \ + if (_k >= 0) { \ + _t = (mpfr_kind_t) _k; \ + _s = 1; \ + } else { \ + _t = (mpfr_kind_t) - _k; \ + _s = -1; \ + } \ + _e = _t == MPFR_REGULAR_KIND ? _e : \ + _t == MPFR_NAN_KIND ? __MPFR_EXP_NAN : \ + _t == MPFR_INF_KIND ? __MPFR_EXP_INF : __MPFR_EXP_ZERO; \ + _x->_mpfr_prec = (p); \ + _x->_mpfr_sign = _s; \ + _x->_mpfr_exp = _e; \ + _x->_mpfr_d = (mp_limb_t*) (m); \ + } while (0) + +#if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 +#define mpfr_custom_get_kind(x) \ + __extension__ ({ \ + mpfr_srcptr _x = (x); \ + _x->_mpfr_exp > __MPFR_EXP_INF ? \ + (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (_x) \ + : _x->_mpfr_exp == __MPFR_EXP_INF ? \ + (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (_x) \ + : _x->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND \ + : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (_x); \ + }) +#else +#define mpfr_custom_get_kind(x) ((mpfr_custom_get_kind)(x)) +#endif + +/* End of the macro versions of the custom interface. */ + +#endif /* MPFR_USE_NO_MACRO */ + +/* These are defined to be macros */ +#define mpfr_init_set_si(x, i, rnd) \ + ( mpfr_init(x), mpfr_set_si((x), (i), (rnd)) ) +#define mpfr_init_set_ui(x, i, rnd) \ + ( mpfr_init(x), mpfr_set_ui((x), (i), (rnd)) ) +#define mpfr_init_set_d(x, d, rnd) \ + ( mpfr_init(x), mpfr_set_d((x), (d), (rnd)) ) +#define mpfr_init_set_ld(x, d, rnd) \ + ( mpfr_init(x), mpfr_set_ld((x), (d), (rnd)) ) +#define mpfr_init_set_z(x, i, rnd) \ + ( mpfr_init(x), mpfr_set_z((x), (i), (rnd)) ) +#ifndef MPFR_USE_MINI_GMP +#define mpfr_init_set_q(x, i, rnd) \ + ( mpfr_init(x), mpfr_set_q((x), (i), (rnd)) ) +#define mpfr_init_set_f(x, y, rnd) \ + ( mpfr_init(x), mpfr_set_f((x), (y), (rnd)) ) +#endif +#define mpfr_init_set(x, y, rnd) \ + ( mpfr_init(x), mpfr_set((x), (y), (rnd)) ) + +/* Compatibility layer -- obsolete functions and macros */ +/* Note: it is not possible to output warnings, unless one defines + * a deprecated variable and uses it, e.g. + * MPFR_DEPRECATED extern int mpfr_deprecated_feature; + * #define MPFR_EMIN_MIN ((void)mpfr_deprecated_feature,mpfr_get_emin_min()) + * (the cast to void avoids a warning because the left-hand operand + * has no effect). + */ +#define mpfr_cmp_abs mpfr_cmpabs +#define mpfr_round_prec(x,r,p) mpfr_prec_round(x,p,r) +#define __gmp_default_rounding_mode (mpfr_get_default_rounding_mode()) +#define __mpfr_emin (mpfr_get_emin()) +#define __mpfr_emax (mpfr_get_emax()) +#define __mpfr_default_fp_bit_precision (mpfr_get_default_fp_bit_precision()) +#define MPFR_EMIN_MIN mpfr_get_emin_min() +#define MPFR_EMIN_MAX mpfr_get_emin_max() +#define MPFR_EMAX_MIN mpfr_get_emax_min() +#define MPFR_EMAX_MAX mpfr_get_emax_max() +#define mpfr_version (mpfr_get_version()) +#ifndef mpz_set_fr +# define mpz_set_fr mpfr_get_z +#endif +#define mpfr_get_z_exp mpfr_get_z_2exp +#define mpfr_custom_get_mantissa mpfr_custom_get_significand + +#endif /* __MPFR_H */ + + +/* Check if / is included or if the user + explicitly wants intmax_t. Automatic detection is done by + checking: + - INTMAX_C and UINTMAX_C, but not if the compiler is a C++ one + (as suggested by Patrick Pelissier) because the test does not + work well in this case. See: + https://sympa.inria.fr/sympa/arc/mpfr/2010-02/msg00025.html + We do not check INTMAX_MAX and UINTMAX_MAX because under Solaris, + these macros are always defined by (i.e. even when + and are not included). + - _STDINT_H (defined by the glibc), _STDINT_H_ (defined under + Mac OS X) and _STDINT (defined under MS Visual Studio), but + this test may not work with all implementations. + Portable software should not rely on these tests. +*/ +#if (defined (INTMAX_C) && defined (UINTMAX_C) && !defined(__cplusplus)) || \ + defined (MPFR_USE_INTMAX_T) || \ + defined (_STDINT_H) || defined (_STDINT_H_) || defined (_STDINT) || \ + defined (_SYS_STDINT_H_) /* needed for FreeBSD */ +# ifndef _MPFR_H_HAVE_INTMAX_T +# define _MPFR_H_HAVE_INTMAX_T 1 + +#if defined (__cplusplus) +extern "C" { +#endif + +#define mpfr_set_sj __gmpfr_set_sj +#define mpfr_set_sj_2exp __gmpfr_set_sj_2exp +#define mpfr_set_uj __gmpfr_set_uj +#define mpfr_set_uj_2exp __gmpfr_set_uj_2exp +#define mpfr_get_sj __gmpfr_mpfr_get_sj +#define mpfr_get_uj __gmpfr_mpfr_get_uj +#define mpfr_pow_uj __gmpfr_mpfr_pow_uj +#define mpfr_pow_sj __gmpfr_mpfr_pow_sj +__MPFR_DECLSPEC int mpfr_set_sj (mpfr_ptr, intmax_t, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_sj_2exp (mpfr_ptr, intmax_t, intmax_t, + mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_uj (mpfr_ptr, uintmax_t, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_set_uj_2exp (mpfr_ptr, uintmax_t, intmax_t, + mpfr_rnd_t); +__MPFR_DECLSPEC intmax_t mpfr_get_sj (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC uintmax_t mpfr_get_uj (mpfr_srcptr, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_pow_uj (mpfr_ptr, mpfr_srcptr, uintmax_t, mpfr_rnd_t); +__MPFR_DECLSPEC int mpfr_pow_sj (mpfr_ptr, mpfr_srcptr, intmax_t, mpfr_rnd_t); +/* define mpfr_pown (defined in IEEE 754-2019) as an alias for mpfr_pow_sj. + It is currently implemented as a macro, but this may change in the future + (it could be implemented as an inline function); in case of change, update + the manual. */ +#define mpfr_pown mpfr_pow_sj + +#if defined (__cplusplus) +} +#endif + +# endif /* _MPFR_H_HAVE_INTMAX_T */ +#endif + + +/* Check if has been included or if the user wants FILE */ +#if defined (_GMP_H_HAVE_FILE) || defined (MPFR_USE_FILE) +# ifndef _MPFR_H_HAVE_FILE +# define _MPFR_H_HAVE_FILE 1 + +#if defined (__cplusplus) +extern "C" { +#endif + +#define mpfr_inp_str __gmpfr_inp_str +#define mpfr_out_str __gmpfr_out_str +__MPFR_DECLSPEC size_t mpfr_inp_str (mpfr_ptr, FILE*, int, mpfr_rnd_t); +__MPFR_DECLSPEC size_t mpfr_out_str (FILE*, int, size_t, mpfr_srcptr, + mpfr_rnd_t); +#ifndef MPFR_USE_MINI_GMP +#define mpfr_fprintf __gmpfr_fprintf +__MPFR_DECLSPEC int mpfr_fprintf (FILE*, const char*, ...); +#endif +#define mpfr_fpif_export __gmpfr_fpif_export +#define mpfr_fpif_import __gmpfr_fpif_import +__MPFR_DECLSPEC int mpfr_fpif_export (FILE*, mpfr_ptr); +__MPFR_DECLSPEC int mpfr_fpif_import (mpfr_ptr, FILE*); + +#if defined (__cplusplus) +} +#endif + +# endif /* _MPFR_H_HAVE_FILE */ +#endif + + +/* check if has been included or if the user wants va_list */ +#if defined (_GMP_H_HAVE_VA_LIST) || defined (MPFR_USE_VA_LIST) +# ifndef _MPFR_H_HAVE_VA_LIST +# define _MPFR_H_HAVE_VA_LIST 1 + +#if defined (__cplusplus) +extern "C" { +#endif + +#define mpfr_vprintf __gmpfr_vprintf +#define mpfr_vasprintf __gmpfr_vasprintf +#define mpfr_vsprintf __gmpfr_vsprintf +#define mpfr_vsnprintf __gmpfr_vsnprintf +__MPFR_DECLSPEC int mpfr_vprintf (const char*, va_list); +__MPFR_DECLSPEC int mpfr_vasprintf (char**, const char*, va_list); +__MPFR_DECLSPEC int mpfr_vsprintf (char*, const char*, va_list); +__MPFR_DECLSPEC int mpfr_vsnprintf (char*, size_t, const char*, va_list); + +#if defined (__cplusplus) +} +#endif + +# endif /* _MPFR_H_HAVE_VA_LIST */ +#endif + + +/* check if has been included and if FILE is available + (see above) */ +#if defined (_MPFR_H_HAVE_VA_LIST) && defined (_MPFR_H_HAVE_FILE) +# ifndef _MPFR_H_HAVE_VA_LIST_FILE +# define _MPFR_H_HAVE_VA_LIST_FILE 1 + +#if defined (__cplusplus) +extern "C" { +#endif + +#define mpfr_vfprintf __gmpfr_vfprintf +__MPFR_DECLSPEC int mpfr_vfprintf (FILE*, const char*, va_list); + +#if defined (__cplusplus) +} +#endif + +# endif /* _MPFR_H_HAVE_VA_LIST_FILE */ +#endif diff --git a/illumos-x86_64/usr/include/mps/base64.h b/illumos-x86_64/usr/include/mps/base64.h new file mode 100644 index 00000000..ddc2db60 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/base64.h @@ -0,0 +1,41 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * base64.h - prototypes for base64 encoding/decoding + * Note: These functions are deprecated; see nssb64.h for new routines. + */ +#ifndef _BASE64_H_ +#define _BASE64_H_ + +#include "utilrename.h" +#include "seccomon.h" + +SEC_BEGIN_PROTOS + +/* +** Return an PORT_Alloc'd ascii string which is the base64 encoded +** version of the input string. +*/ +extern char *BTOA_DataToAscii(const unsigned char *data, unsigned int len); + +/* +** Return an PORT_Alloc'd string which is the base64 decoded version +** of the input string; set *lenp to the length of the returned data. +*/ +extern unsigned char *ATOB_AsciiToData(const char *string, unsigned int *lenp); + +/* +** Convert from ascii to binary encoding of an item. +*/ +extern SECStatus ATOB_ConvertAsciiToItem(SECItem *binary_item, const char *ascii); + +/* +** Convert from binary encoding of an item to ascii. +*/ +extern char *BTOA_ConvertItemToAscii(SECItem *binary_item); + +SEC_END_PROTOS + +#endif /* _BASE64_H_ */ diff --git a/illumos-x86_64/usr/include/mps/blapit.h b/illumos-x86_64/usr/include/mps/blapit.h new file mode 100644 index 00000000..c22eee24 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/blapit.h @@ -0,0 +1,483 @@ +/* + * blapit.h - public data structures for the freebl library + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _BLAPIT_H_ +#define _BLAPIT_H_ + +#include "seccomon.h" +#include "prlink.h" +#include "plarena.h" +#include "ecl-exp.h" + +/* RC2 operation modes */ +#define NSS_RC2 0 +#define NSS_RC2_CBC 1 + +/* RC5 operation modes */ +#define NSS_RC5 0 +#define NSS_RC5_CBC 1 + +/* DES operation modes */ +#define NSS_DES 0 +#define NSS_DES_CBC 1 +#define NSS_DES_EDE3 2 +#define NSS_DES_EDE3_CBC 3 + +#define DES_KEY_LENGTH 8 /* Bytes */ + +#define ED25519_SIGN_LEN 64U /* Bytes */ + +/* AES operation modes */ +#define NSS_AES 0 +#define NSS_AES_CBC 1 +#define NSS_AES_CTS 2 +#define NSS_AES_CTR 3 +#define NSS_AES_GCM 4 + +/* Camellia operation modes */ +#define NSS_CAMELLIA 0 +#define NSS_CAMELLIA_CBC 1 + +/* SEED operation modes */ +#define NSS_SEED 0 +#define NSS_SEED_CBC 1 + +#define DSA1_SUBPRIME_LEN 20 /* Bytes */ +#define DSA1_SIGNATURE_LEN (DSA1_SUBPRIME_LEN * 2) /* Bytes */ +#define DSA_MAX_SUBPRIME_LEN 32 /* Bytes */ +#define DSA_MAX_SIGNATURE_LEN (DSA_MAX_SUBPRIME_LEN * 2) /* Bytes */ + +/* + * Mark the old defines as deprecated. This will warn code that expected + * DSA1 only that they need to change if the are to support DSA2. + */ +#if defined(__GNUC__) && (__GNUC__ > 3) +/* make GCC warn when we use these #defines */ +typedef int __BLAPI_DEPRECATED __attribute__((deprecated)); +#define DSA_SUBPRIME_LEN ((__BLAPI_DEPRECATED)DSA1_SUBPRIME_LEN) +#define DSA_SIGNATURE_LEN ((__BLAPI_DEPRECATED)DSA1_SIGNATURE_LEN) +#define DSA_Q_BITS ((__BLAPI_DEPRECATED)(DSA1_SUBPRIME_LEN * 8)) +#else +#ifdef _WIN32 +/* This magic gets the windows compiler to give us a deprecation + * warning */ +#pragma deprecated(DSA_SUBPRIME_LEN, DSA_SIGNATURE_LEN, DSA_QBITS) +#endif +#define DSA_SUBPRIME_LEN DSA1_SUBPRIME_LEN +#define DSA_SIGNATURE_LEN DSA1_SIGNATURE_LEN +#define DSA_Q_BITS (DSA1_SUBPRIME_LEN * 8) +#endif + +/* XXX We shouldn't have to hard code this limit. For + * now, this is the quickest way to support ECDSA signature + * processing (ECDSA signature lengths depend on curve + * size). This limit is sufficient for curves upto + * 576 bits. + */ +#define MAX_ECKEY_LEN 72 /* Bytes */ + +#define EC_MAX_KEY_BITS 521 /* in bits */ +#define EC_MIN_KEY_BITS 256 /* in bits */ + +#define ECD_MAX_KEY_BITS 255 /* in bits */ +#define ECD_MIN_KEY_BITS 255 /* in bits */ + +/* EC point compression format */ +#define EC_POINT_FORM_COMPRESSED_Y0 0x02 +#define EC_POINT_FORM_COMPRESSED_Y1 0x03 +#define EC_POINT_FORM_UNCOMPRESSED 0x04 +#define EC_POINT_FORM_HYBRID_Y0 0x06 +#define EC_POINT_FORM_HYBRID_Y1 0x07 + +/* + * Number of bytes each hash algorithm produces + */ +#define MD2_LENGTH 16 /* Bytes */ +#define MD5_LENGTH 16 /* Bytes */ +#define SHA1_LENGTH 20 /* Bytes */ +#define SHA256_LENGTH 32 /* bytes */ +#define SHA384_LENGTH 48 /* bytes */ +#define SHA512_LENGTH 64 /* bytes */ +#define SHA3_224_LENGTH 28 /* bytes */ +#define SHA3_256_LENGTH 32 /* bytes */ +#define SHA3_384_LENGTH 48 /* bytes */ +#define SHA3_512_LENGTH 64 /* bytes */ +#define BLAKE2B512_LENGTH 64 /* Bytes */ +#define HASH_LENGTH_MAX SHA512_LENGTH + +/* + * Input block size for each hash algorithm. + */ + +#define MD2_BLOCK_LENGTH 64 /* bytes */ +#define MD5_BLOCK_LENGTH 64 /* bytes */ +#define SHA1_BLOCK_LENGTH 64 /* bytes */ +#define SHA224_BLOCK_LENGTH 64 /* bytes */ +#define SHA256_BLOCK_LENGTH 64 /* bytes */ +#define SHA384_BLOCK_LENGTH 128 /* bytes */ +#define SHA512_BLOCK_LENGTH 128 /* bytes */ +#define SHA3_224_BLOCK_LENGTH 144 /* bytes */ +#define SHA3_256_BLOCK_LENGTH 136 /* bytes */ +#define SHA3_384_BLOCK_LENGTH 104 /* bytes */ +#define SHA3_512_BLOCK_LENGTH 72 /* bytes */ +#define BLAKE2B_BLOCK_LENGTH 128 /* Bytes */ +#define HASH_BLOCK_LENGTH_MAX SHA3_224_BLOCK_LENGTH + +#define AES_BLOCK_SIZE 16 /* bytes */ +#define AES_KEY_WRAP_BLOCK_SIZE (AES_BLOCK_SIZE / 2) +#define AES_KEY_WRAP_IV_BYTES AES_KEY_WRAP_BLOCK_SIZE + +#define AES_128_KEY_LENGTH 16 /* bytes */ +#define AES_192_KEY_LENGTH 24 /* bytes */ +#define AES_256_KEY_LENGTH 32 /* bytes */ + +#define CAMELLIA_BLOCK_SIZE 16 /* bytes */ + +#define SEED_BLOCK_SIZE 16 /* bytes */ +#define SEED_KEY_LENGTH 16 /* bytes */ + +#define NSS_FREEBL_DEFAULT_CHUNKSIZE 2048 + +#define BLAKE2B_KEY_SIZE 64 + +/* + * These values come from the initial key size limits from the PKCS #11 + * module. They may be arbitrarily adjusted to any value freebl supports. + */ +#define RSA_MIN_MODULUS_BITS 128 +#define RSA_MAX_MODULUS_BITS 16384 +#define RSA_MAX_EXPONENT_BITS 64 +#define DH_MIN_P_BITS 128 +#define DH_MAX_P_BITS 16384 + +/* max signature for all our supported signatures */ +/* currently RSA is the biggest */ +#define MAX_SIGNATURE_LEN ((RSA_MAX_MODULUS_BITS + 7) / 8) + +/* + * The FIPS 186-1 algorithm for generating primes P and Q allows only 9 + * distinct values for the length of P, and only one value for the + * length of Q. + * The algorithm uses a variable j to indicate which of the 9 lengths + * of P is to be used. + * The following table relates j to the lengths of P and Q in bits. + * + * j bits in P bits in Q + * _ _________ _________ + * 0 512 160 + * 1 576 160 + * 2 640 160 + * 3 704 160 + * 4 768 160 + * 5 832 160 + * 6 896 160 + * 7 960 160 + * 8 1024 160 + * + * The FIPS-186-1 compliant PQG generator takes j as an input parameter. + * + * FIPS 186-3 algorithm specifies 4 distinct P and Q sizes: + * + * bits in P bits in Q + * _________ _________ + * 1024 160 + * 2048 224 + * 2048 256 + * 3072 256 + * + * The FIPS-186-3 complaiant PQG generator (PQG V2) takes arbitrary p and q + * lengths as input and returns an error if they aren't in this list. + */ + +#define DSA1_Q_BITS 160 +#define DSA_MAX_P_BITS 3072 +#define DSA_MIN_P_BITS 512 +#define DSA_MAX_Q_BITS 256 +#define DSA_MIN_Q_BITS 160 + +#if DSA_MAX_Q_BITS != DSA_MAX_SUBPRIME_LEN * 8 +#error "Inconsistent declaration of DSA SUBPRIME/Q parameters in blapit.h" +#endif + +/* + * function takes desired number of bits in P, + * returns index (0..8) or -1 if number of bits is invalid. + */ +#define PQG_PBITS_TO_INDEX(bits) \ + (((bits) < 512 || (bits) > 1024 || (bits) % 64) ? -1 : (int)((bits)-512) / 64) + +/* + * function takes index (0-8) + * returns number of bits in P for that index, or -1 if index is invalid. + */ +#define PQG_INDEX_TO_PBITS(j) (((unsigned)(j) > 8) ? -1 : (512 + 64 * (j))) + +/* When we are generating a gcm iv from a random number, we need to calculate + * an acceptable iteration count to avoid birthday attacks. (randomly + * generating the same IV twice). + * + * We use the approximation n = sqrt(2*m*p) to find an acceptable n given m + * and p. + * where n is the number of iterations. + * m is the number of possible random values. + * p is the probability of collision (0-1). + * + * We want to calculate the constant number GCM_IV_RANDOM_BIRTHDAY_BITS, which + * is the number of bits we subtract off of the length of the iv (in bits) to + * get a safe count value (log2). + * + * Since we do the calculation in bits, so we need to take the whole + * equation log2: + * log2 n = (1+(log2 m)+(log2 p))/2 + * Since p < 1, log2 p is negative. Also note that the length of the iv in + * bits is log2 m, so if we set GCMIV_RANDOM_BIRTHDAY_BITS =- log2 p - 1. + * then we can calculate a safe counter value with: + * n = 2^((ivLenBits - GCMIV_RANDOM_BIRTHDAY_BITS)/2) + * + * If we arbitrarily set p = 10^-18 (1 chance in trillion trillion operation) + * we get GCMIV_RANDOM_BIRTHDAY_BITS = -(-18)/.301 -1 = 59 (.301 = log10 2) + * GCMIV_RANDOM_BIRTHDAY_BITS should be at least 59, call it a round 64. NOTE: + * the variable IV size for TLS is 64 bits, which explains why it's not safe + * to use a random value for the nonce in TLS. */ +#define GCMIV_RANDOM_BIRTHDAY_BITS 64 + +/* flag to tell BLAPI_Verify* to rerun the post and integrity tests */ +#define BLAPI_FIPS_RERUN_FLAG '\377' /* 0xff, 255 invalide code for UFT8/ASCII */ +#define BLAPI_FIPS_RERUN_FLAG_STRING "\377" /* The above as a C string */ + +/*************************************************************************** +** Opaque objects +*/ + +struct DESContextStr; +struct RC2ContextStr; +struct RC4ContextStr; +struct RC5ContextStr; +struct AESContextStr; +struct CamelliaContextStr; +struct MD2ContextStr; +struct MD5ContextStr; +struct SHA1ContextStr; +struct SHA256ContextStr; +struct SHA512ContextStr; +struct SHA3ContextStr; +struct SHAKEContextStr; +struct AESKeyWrapContextStr; +struct SEEDContextStr; +struct ChaCha20ContextStr; +struct ChaCha20Poly1305ContextStr; +struct Blake2bContextStr; + +typedef struct DESContextStr DESContext; +typedef struct RC2ContextStr RC2Context; +typedef struct RC4ContextStr RC4Context; +typedef struct RC5ContextStr RC5Context; +typedef struct AESContextStr AESContext; +typedef struct CamelliaContextStr CamelliaContext; +typedef struct MD2ContextStr MD2Context; +typedef struct MD5ContextStr MD5Context; +typedef struct SHA1ContextStr SHA1Context; +typedef struct SHA256ContextStr SHA256Context; +/* SHA224Context is really a SHA256ContextStr. This is not a mistake. */ +typedef struct SHA256ContextStr SHA224Context; +typedef struct SHA512ContextStr SHA512Context; +/* SHA384Context is really a SHA512ContextStr. This is not a mistake. */ +typedef struct SHA512ContextStr SHA384Context; +/* All SHA3_*Contexts are the same. This is not a mistake. */ +typedef struct SHA3ContextStr SHA3_224Context; +typedef struct SHA3ContextStr SHA3_256Context; +typedef struct SHA3ContextStr SHA3_384Context; +typedef struct SHA3ContextStr SHA3_512Context; +typedef struct SHAKEContextStr SHAKE_128Context; +typedef struct SHAKEContextStr SHAKE_256Context; +typedef struct AESKeyWrapContextStr AESKeyWrapContext; +typedef struct SEEDContextStr SEEDContext; +typedef struct ChaCha20ContextStr ChaCha20Context; +typedef struct ChaCha20Poly1305ContextStr ChaCha20Poly1305Context; +typedef struct Blake2bContextStr BLAKE2BContext; + +/*************************************************************************** +** RSA Public and Private Key structures +*/ + +/* member names from PKCS#1, section 7.1 */ +struct RSAPublicKeyStr { + PLArenaPool *arena; + SECItem modulus; + SECItem publicExponent; +}; +typedef struct RSAPublicKeyStr RSAPublicKey; + +/* member names from PKCS#1, section 7.2 */ +struct RSAPrivateKeyStr { + PLArenaPool *arena; + SECItem version; + SECItem modulus; + SECItem publicExponent; + SECItem privateExponent; + SECItem prime1; + SECItem prime2; + SECItem exponent1; + SECItem exponent2; + SECItem coefficient; +}; +typedef struct RSAPrivateKeyStr RSAPrivateKey; + +/*************************************************************************** +** DSA Public and Private Key and related structures +*/ + +struct PQGParamsStr { + PLArenaPool *arena; + SECItem prime; /* p */ + SECItem subPrime; /* q */ + SECItem base; /* g */ + /* XXX chrisk: this needs to be expanded to hold j and validationParms (RFC2459 7.3.2) */ +}; +typedef struct PQGParamsStr PQGParams; + +struct PQGVerifyStr { + PLArenaPool *arena; /* includes this struct, seed, & h. */ + unsigned int counter; + SECItem seed; + SECItem h; +}; +typedef struct PQGVerifyStr PQGVerify; + +struct DSAPublicKeyStr { + PQGParams params; + SECItem publicValue; +}; +typedef struct DSAPublicKeyStr DSAPublicKey; + +struct DSAPrivateKeyStr { + PQGParams params; + SECItem publicValue; + SECItem privateValue; +}; +typedef struct DSAPrivateKeyStr DSAPrivateKey; + +/*************************************************************************** +** Diffie-Hellman Public and Private Key and related structures +** Structure member names suggested by PKCS#3. +*/ + +struct DHParamsStr { + PLArenaPool *arena; + SECItem prime; /* p */ + SECItem base; /* g */ +}; +typedef struct DHParamsStr DHParams; + +struct DHPublicKeyStr { + PLArenaPool *arena; + SECItem prime; + SECItem base; + SECItem publicValue; +}; +typedef struct DHPublicKeyStr DHPublicKey; + +struct DHPrivateKeyStr { + PLArenaPool *arena; + SECItem prime; + SECItem base; + SECItem publicValue; + SECItem privateValue; +}; +typedef struct DHPrivateKeyStr DHPrivateKey; + +/*************************************************************************** +** Data structures used for elliptic curve parameters and +** public and private keys. +*/ + +/* +** The ECParams data structures can encode elliptic curve +** parameters for both GFp and GF2m curves. +*/ + +typedef enum { ec_params_explicit, + ec_params_named, + ec_params_edwards_named, + ec_params_montgomery_named, +} ECParamsType; + +typedef enum { ec_field_GFp = 1, + ec_field_GF2m, + ec_field_plain +} ECFieldType; + +struct ECFieldIDStr { + int size; /* field size in bits */ + ECFieldType type; + union { + SECItem prime; /* prime p for (GFp) */ + SECItem poly; /* irreducible binary polynomial for (GF2m) */ + } u; + int k1; /* first coefficient of pentanomial or + * the only coefficient of trinomial + */ + int k2; /* two remaining coefficients of pentanomial */ + int k3; +}; +typedef struct ECFieldIDStr ECFieldID; + +struct ECCurveStr { + SECItem a; /* contains octet stream encoding of + * field element (X9.62 section 4.3.3) + */ + SECItem b; + SECItem seed; +}; +typedef struct ECCurveStr ECCurve; + +struct ECParamsStr { + PLArenaPool *arena; + ECParamsType type; + ECFieldID fieldID; + ECCurve curve; + SECItem base; + SECItem order; + int cofactor; + SECItem DEREncoding; + ECCurveName name; + SECItem curveOID; +}; +typedef struct ECParamsStr ECParams; + +struct ECPublicKeyStr { + ECParams ecParams; + SECItem publicValue; /* elliptic curve point encoded as + * octet stream. + */ +}; +typedef struct ECPublicKeyStr ECPublicKey; + +struct ECPrivateKeyStr { + ECParams ecParams; + SECItem publicValue; /* encoded ec point */ + SECItem privateValue; /* private big integer */ + SECItem version; /* As per SEC 1, Appendix C, Section C.4 */ +}; +typedef struct ECPrivateKeyStr ECPrivateKey; + +typedef void *(*BLapiAllocateFunc)(void); +typedef void (*BLapiDestroyContextFunc)(void *cx, PRBool freeit); +typedef SECStatus (*BLapiInitContextFunc)(void *cx, + const unsigned char *key, + unsigned int keylen, + const unsigned char *, + int, + unsigned int, + unsigned int); +typedef SECStatus (*BLapiEncrypt)(void *cx, unsigned char *output, + unsigned int *outputLen, + unsigned int maxOutputLen, + const unsigned char *input, + unsigned int inputLen); + +#endif /* _BLAPIT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/cert.h b/illumos-x86_64/usr/include/mps/cert.h new file mode 100644 index 00000000..33d37b39 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/cert.h @@ -0,0 +1,1606 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * cert.h - public data structures and prototypes for the certificate library + */ + +#ifndef _CERT_H_ +#define _CERT_H_ + +#include "utilrename.h" +#include "plarena.h" +#include "plhash.h" +#include "prlong.h" +#include "prlog.h" + +#include "seccomon.h" +#include "secdert.h" +#include "secoidt.h" +#include "keythi.h" +#include "certt.h" + +SEC_BEGIN_PROTOS + +/**************************************************************************** + * + * RFC1485 ascii to/from X.? RelativeDistinguishedName (aka CERTName) + * + ****************************************************************************/ + +/* +** Convert an ascii RFC1485 encoded name into its CERTName equivalent. +*/ +extern CERTName *CERT_AsciiToName(const char *string); + +/* +** Convert an CERTName into its RFC1485 encoded equivalent. +** Returns a string that must be freed with PORT_Free(). +** This version produces a string for maximum human readability, +** not for strict RFC compliance. +*/ +extern char *CERT_NameToAscii(CERTName *name); + +/* +** Convert an CERTName into its RFC1485 encoded equivalent. +** Returns a string that must be freed with PORT_Free(). +** Caller chooses encoding rules. +*/ +extern char *CERT_NameToAsciiInvertible(CERTName *name, + CertStrictnessLevel strict); + +extern CERTAVA *CERT_CopyAVA(PLArenaPool *arena, CERTAVA *src); + +/* convert an OID to dotted-decimal representation */ +/* Returns a string that must be freed with PR_smprintf_free(). */ +extern char *CERT_GetOidString(const SECItem *oid); + +/* +** Examine an AVA and return the tag that refers to it. The AVA tags are +** defined as SEC_OID_AVA*. +*/ +extern SECOidTag CERT_GetAVATag(CERTAVA *ava); + +/* +** Compare two AVA's, returning the difference between them. +*/ +extern SECComparison CERT_CompareAVA(const CERTAVA *a, const CERTAVA *b); + +/* +** Create an RDN (relative-distinguished-name). The argument list is a +** NULL terminated list of AVA's. +*/ +extern CERTRDN *CERT_CreateRDN(PLArenaPool *arena, CERTAVA *avas, ...); + +/* +** Make a copy of "src" storing it in "dest". +*/ +extern SECStatus CERT_CopyRDN(PLArenaPool *arena, CERTRDN *dest, CERTRDN *src); + +/* +** Add an AVA to an RDN. +** "rdn" the RDN to add to +** "ava" the AVA to add +*/ +extern SECStatus CERT_AddAVA(PLArenaPool *arena, CERTRDN *rdn, CERTAVA *ava); + +/* +** Compare two RDN's, returning the difference between them. +*/ +extern SECComparison CERT_CompareRDN(const CERTRDN *a, const CERTRDN *b); + +/* +** Create an X.500 style name using a NULL terminated list of RDN's. +*/ +extern CERTName *CERT_CreateName(CERTRDN *rdn, ...); + +/* +** Make a copy of "src" storing it in "dest". Memory is allocated in +** "dest" for each of the appropriate sub objects. Memory is not freed in +** "dest" before allocation is done (use CERT_DestroyName(dest, PR_FALSE) to +** do that). +*/ +extern SECStatus CERT_CopyName(PLArenaPool *arena, CERTName *dest, + const CERTName *src); + +/* +** Destroy a Name object. +** "name" the CERTName to destroy +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void CERT_DestroyName(CERTName *name); + +/* +** Add an RDN to a name. +** "name" the name to add the RDN to +** "rdn" the RDN to add to name +*/ +extern SECStatus CERT_AddRDN(CERTName *name, CERTRDN *rdn); + +/* +** Compare two names, returning the difference between them. +*/ +extern SECComparison CERT_CompareName(const CERTName *a, const CERTName *b); + +/* +** Convert a CERTName into something readable +*/ +extern char *CERT_FormatName(CERTName *name); + +/* +** Convert a der-encoded integer to a hex printable string form. +** Perhaps this should be a SEC function but it's only used for certs. +*/ +extern char *CERT_Hexify(SECItem *i, int do_colon); + +/* +** Converts DER string (with explicit length) into zString, if destination +** buffer is big enough to receive it. Does quoting and/or escaping as +** specified in RFC 1485. Input string must be single or multi-byte DER +** character set, (ASCII, UTF8, or ISO 8851-x) not a wide character set. +** Returns SECSuccess or SECFailure with error code set. If output buffer +** is too small, sets error code SEC_ERROR_OUTPUT_LEN. +*/ +extern SECStatus CERT_RFC1485_EscapeAndQuote(char *dst, int dstlen, char *src, + int srclen); + +/****************************************************************************** + * + * Certificate handling operations + * + *****************************************************************************/ + +/* +** Create a new validity object given two unix time values. +** "notBefore" the time before which the validity is not valid +** "notAfter" the time after which the validity is not valid +*/ +extern CERTValidity *CERT_CreateValidity(PRTime notBefore, PRTime notAfter); + +/* +** Destroy a validity object. +** "v" the validity to destroy +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void CERT_DestroyValidity(CERTValidity *v); + +/* +** Copy the "src" object to "dest". Memory is allocated in "dest" for +** each of the appropriate sub-objects. Memory in "dest" is not freed +** before memory is allocated (use CERT_DestroyValidity(v, PR_FALSE) to do +** that). +*/ +extern SECStatus CERT_CopyValidity(PLArenaPool *arena, CERTValidity *dest, + CERTValidity *src); + +/* +** The cert lib considers a cert or CRL valid if the "notBefore" time is +** in the not-too-distant future, e.g. within the next 24 hours. This +** prevents freshly issued certificates from being considered invalid +** because the local system's time zone is incorrectly set. +** The amount of "pending slop time" is adjustable by the application. +** Units of SlopTime are seconds. Default is 86400 (24 hours). +** Negative SlopTime values are not allowed. +*/ +PRInt32 CERT_GetSlopTime(void); + +SECStatus CERT_SetSlopTime(PRInt32 slop); + +/* +** Create a new certificate object. The result must be wrapped with an +** CERTSignedData to create a signed certificate. +** "serialNumber" the serial number +** "issuer" the name of the certificate issuer +** "validity" the validity period of the certificate +** "req" the certificate request that prompted the certificate issuance +*/ +extern CERTCertificate *CERT_CreateCertificate(unsigned long serialNumber, + CERTName *issuer, + CERTValidity *validity, + CERTCertificateRequest *req); + +/* +** Destroy a certificate object +** "cert" the certificate to destroy +** NOTE: certificate's are reference counted. This call decrements the +** reference count, and if the result is zero, then the object is destroyed +** and optionally freed. +*/ +extern void CERT_DestroyCertificate(CERTCertificate *cert); + +/* +** Make a shallow copy of a certificate "c". Just increments the +** reference count on "c". +*/ +extern CERTCertificate *CERT_DupCertificate(CERTCertificate *c); + +/* Access the DER of the certificate. This only creates a reference to the DER + * in the outparam not a copy. To avoid the pointer becoming invalid, use + * CERT_DupCertificate() and keep a reference to the duplicate alive. + */ +extern SECStatus CERT_GetCertificateDer(const CERTCertificate *c, SECItem *der); + +/* +** Create a new certificate request. This result must be wrapped with an +** CERTSignedData to create a signed certificate request. +** "name" the subject name (who the certificate request is from) +** "spki" describes/defines the public key the certificate is for +** "attributes" if non-zero, some optional attribute data +*/ +extern CERTCertificateRequest *CERT_CreateCertificateRequest( + CERTName *name, CERTSubjectPublicKeyInfo *spki, SECItem **attributes); + +/* +** Destroy a certificate-request object +** "r" the certificate-request to destroy +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void CERT_DestroyCertificateRequest(CERTCertificateRequest *r); + +/* +** Start adding extensions to a certificate request. +*/ +void *CERT_StartCertificateRequestAttributes(CERTCertificateRequest *req); + +/* +** Reformat the certificate extension list into a CertificateRequest +** attribute list. +*/ +SECStatus CERT_FinishCertificateRequestAttributes(CERTCertificateRequest *req); + +/* +** Extract the Extension Requests from a DER CertRequest attribute list. +*/ +SECStatus CERT_GetCertificateRequestExtensions(CERTCertificateRequest *req, + CERTCertExtension ***exts); + +/* +** Extract a public key object from a certificate +*/ +extern SECKEYPublicKey *CERT_ExtractPublicKey(CERTCertificate *cert); + +/* +** Retrieve the Key Type associated with the cert we're dealing with +*/ + +extern KeyType CERT_GetCertKeyType(const CERTSubjectPublicKeyInfo *spki); + +/* +** Initialize the certificate database. This is called to create +** the initial list of certificates in the database. +*/ +extern SECStatus CERT_InitCertDB(CERTCertDBHandle *handle); + +extern int CERT_GetDBContentVersion(CERTCertDBHandle *handle); + +/* +** Default certificate database routines +*/ +extern void CERT_SetDefaultCertDB(CERTCertDBHandle *handle); + +extern CERTCertDBHandle *CERT_GetDefaultCertDB(void); + +extern CERTCertList *CERT_GetCertChainFromCert(CERTCertificate *cert, + PRTime time, SECCertUsage usage); +extern CERTCertificate *CERT_NewTempCertificate(CERTCertDBHandle *handle, + SECItem *derCert, + char *nickname, PRBool isperm, + PRBool copyDER); + +/****************************************************************************** + * + * X.500 Name handling operations + * + *****************************************************************************/ + +/* +** Create an AVA (attribute-value-assertion) +** "arena" the memory arena to alloc from +** "kind" is one of SEC_OID_AVA_* +** "valueType" is one of DER_PRINTABLE_STRING, DER_IA5_STRING, or +** DER_T61_STRING +** "value" is the null terminated string containing the value +*/ +extern CERTAVA *CERT_CreateAVA(PLArenaPool *arena, SECOidTag kind, + int valueType, char *value); + +/* +** Extract the Distinguished Name from a DER encoded certificate +** "derCert" is the DER encoded certificate +** "derName" is the SECItem that the name is returned in +*/ +extern SECStatus CERT_NameFromDERCert(SECItem *derCert, SECItem *derName); + +/* +** Extract the Issuers Distinguished Name from a DER encoded certificate +** "derCert" is the DER encoded certificate +** "derName" is the SECItem that the name is returned in +*/ +extern SECStatus CERT_IssuerNameFromDERCert(SECItem *derCert, SECItem *derName); + +extern SECItem *CERT_EncodeGeneralName(CERTGeneralName *genName, SECItem *dest, + PLArenaPool *arena); + +extern CERTGeneralName *CERT_DecodeGeneralName(PLArenaPool *reqArena, + SECItem *encodedName, + CERTGeneralName *genName); + +/* +** Generate a database search key for a certificate, based on the +** issuer and serial number. +** "arena" the memory arena to alloc from +** "derCert" the DER encoded certificate +** "key" the returned key +*/ +extern SECStatus CERT_KeyFromDERCert(PLArenaPool *reqArena, SECItem *derCert, + SECItem *key); + +extern SECStatus CERT_KeyFromIssuerAndSN(PLArenaPool *arena, SECItem *issuer, + SECItem *sn, SECItem *key); + +extern SECStatus CERT_SerialNumberFromDERCert(SECItem *derCert, + SECItem *derName); + +/* +** Generate a database search key for a crl, based on the +** issuer. +** "arena" the memory arena to alloc from +** "derCrl" the DER encoded crl +** "key" the returned key +*/ +extern SECStatus CERT_KeyFromDERCrl(PLArenaPool *arena, SECItem *derCrl, + SECItem *key); + +/* +** Open the certificate database. Use callback to get name of database. +*/ +extern SECStatus CERT_OpenCertDB(CERTCertDBHandle *handle, PRBool readOnly, + CERTDBNameFunc namecb, void *cbarg); + +/* Open the certificate database. Use given filename for database. */ +extern SECStatus CERT_OpenCertDBFilename(CERTCertDBHandle *handle, + char *certdbname, PRBool readOnly); + +/* +** Open and initialize a cert database that is entirely in memory. This +** can be used when the permanent database can not be opened or created. +*/ +extern SECStatus CERT_OpenVolatileCertDB(CERTCertDBHandle *handle); + +/* +** Extract the list of host names, host name patters, IP address strings +** this cert is valid for. +** This function does NOT return nicknames. +** Type CERTCertNicknames is being used because it's a convenient +** data structure to carry a list of strings and its count. +*/ +extern CERTCertNicknames *CERT_GetValidDNSPatternsFromCert( + CERTCertificate *cert); + +/* +** Check the hostname to make sure that it matches the shexp that +** is given in the common name of the certificate. +*/ +extern SECStatus CERT_VerifyCertName(const CERTCertificate *cert, + const char *hostname); + +/* +** Add a domain name to the list of names that the user has explicitly +** allowed (despite cert name mismatches) for use with a server cert. +*/ +extern SECStatus CERT_AddOKDomainName(CERTCertificate *cert, + const char *hostname); + +/* +** Decode a DER encoded certificate into an CERTCertificate structure +** "derSignedCert" is the DER encoded signed certificate +** "copyDER" is true if the DER should be copied, false if the +** existing copy should be referenced +** "nickname" is the nickname to use in the database. If it is NULL +** then a temporary nickname is generated. +*/ +extern CERTCertificate *CERT_DecodeDERCertificate(SECItem *derSignedCert, + PRBool copyDER, + char *nickname); +/* +** Decode a DER encoded CRL into a CERTSignedCrl structure +** "derSignedCrl" is the DER encoded signed CRL. +** "type" must be SEC_CRL_TYPE. +*/ +#define SEC_CRL_TYPE 1 +#define SEC_KRL_TYPE 0 /* deprecated */ + +extern CERTSignedCrl *CERT_DecodeDERCrl(PLArenaPool *arena, + SECItem *derSignedCrl, int type); + +/* + * same as CERT_DecodeDERCrl, plus allow options to be passed in + */ + +extern CERTSignedCrl *CERT_DecodeDERCrlWithFlags(PLArenaPool *narena, + SECItem *derSignedCrl, + int type, PRInt32 options); + +/* CRL options to pass */ + +#define CRL_DECODE_DEFAULT_OPTIONS 0x00000000 + +/* when CRL_DECODE_DONT_COPY_DER is set, the DER is not copied . The + application must then keep derSignedCrl until it destroys the + CRL . Ideally, it should allocate derSignedCrl in an arena + and pass that arena in as the first argument to + CERT_DecodeDERCrlWithFlags */ + +#define CRL_DECODE_DONT_COPY_DER 0x00000001 +#define CRL_DECODE_SKIP_ENTRIES 0x00000002 +#define CRL_DECODE_KEEP_BAD_CRL 0x00000004 +#define CRL_DECODE_ADOPT_HEAP_DER 0x00000008 + +/* complete the decoding of a partially decoded CRL, ie. decode the + entries. Note that entries is an optional field in a CRL, so the + "entries" pointer in CERTCrlStr may still be NULL even after + function returns SECSuccess */ + +extern SECStatus CERT_CompleteCRLDecodeEntries(CERTSignedCrl *crl); + +/* Validate CRL then import it to the dbase. If there is already a CRL with the + * same CA in the dbase, it will be replaced if derCRL is more up to date. + * If the process successes, a CRL will be returned. Otherwise, a NULL will + * be returned. The caller should call PORT_GetError() for the exactly error + * code. + */ +extern CERTSignedCrl *CERT_ImportCRL(CERTCertDBHandle *handle, SECItem *derCRL, + char *url, int type, void *wincx); + +extern void CERT_DestroyCrl(CERTSignedCrl *crl); + +/* this is a hint to flush the CRL cache. crlKey is the DER subject of + the issuer (CA). */ +void CERT_CRLCacheRefreshIssuer(CERTCertDBHandle *dbhandle, SECItem *crlKey); + +/* add the specified DER CRL object to the CRL cache. Doing so will allow + certificate verification functions (such as CERT_VerifyCertificate) + to automatically find and make use of this CRL object. + Once a CRL is added to the CRL cache, the application must hold on to + the object's memory, because the cache will reference it directly. The + application can only free the object after it calls CERT_UncacheCRL to + remove it from the CRL cache. +*/ +SECStatus CERT_CacheCRL(CERTCertDBHandle *dbhandle, SECItem *newcrl); + +/* remove a previously added CRL object from the CRL cache. It is OK + for the application to free the memory after a successful removal +*/ +SECStatus CERT_UncacheCRL(CERTCertDBHandle *dbhandle, SECItem *oldcrl); + +/* +** Find a certificate in the database +** "key" is the database key to look for +*/ +extern CERTCertificate *CERT_FindCertByKey(CERTCertDBHandle *handle, + SECItem *key); + +/* +** Find a certificate in the database by name +** "name" is the distinguished name to look up +*/ +extern CERTCertificate *CERT_FindCertByName(CERTCertDBHandle *handle, + SECItem *name); + +/* +** Find a certificate in the database by name +** "name" is the distinguished name to look up (in ascii) +*/ +extern CERTCertificate *CERT_FindCertByNameString(CERTCertDBHandle *handle, + char *name); + +/* +** Find a certificate in the database by name and keyid +** "name" is the distinguished name to look up +** "keyID" is the value of the subjectKeyID to match +*/ +extern CERTCertificate *CERT_FindCertByKeyID(CERTCertDBHandle *handle, + SECItem *name, SECItem *keyID); + +/* +** Generate a certificate key from the issuer and serialnumber, then look it +** up in the database. Return the cert if found. +** "issuerAndSN" is the issuer and serial number to look for +*/ +extern CERTCertificate *CERT_FindCertByIssuerAndSN( + CERTCertDBHandle *handle, CERTIssuerAndSN *issuerAndSN); +extern CERTCertificate *CERT_FindCertByIssuerAndSNCX( + CERTCertDBHandle *handle, CERTIssuerAndSN *issuerAndSN, void *wincx); + +/* +** Find a certificate in the database by a subject key ID +** "subjKeyID" is the subject Key ID to look for +*/ +extern CERTCertificate *CERT_FindCertBySubjectKeyID(CERTCertDBHandle *handle, + SECItem *subjKeyID); + +/* +** Encode Certificate SKID (Subject Key ID) extension. +** +*/ +extern SECStatus CERT_EncodeSubjectKeyID(PLArenaPool *arena, + const SECItem *srcString, + SECItem *encodedValue); + +/* +** Find a certificate in the database by a nickname +** "nickname" is the ascii string nickname to look for +*/ +extern CERTCertificate *CERT_FindCertByNickname(CERTCertDBHandle *handle, + const char *nickname); + +/* +** Find a certificate in the database by a DER encoded certificate +** "derCert" is the DER encoded certificate +*/ +extern CERTCertificate *CERT_FindCertByDERCert(CERTCertDBHandle *handle, + SECItem *derCert); + +/* +** Find a certificate in the database by a email address +** "emailAddr" is the email address to look up +*/ +CERTCertificate *CERT_FindCertByEmailAddr(CERTCertDBHandle *handle, + char *emailAddr); + +/* +** Find a certificate in the database by a email address or nickname +** "name" is the email address or nickname to look up +*/ +CERTCertificate *CERT_FindCertByNicknameOrEmailAddr(CERTCertDBHandle *handle, + const char *name); +CERTCertificate *CERT_FindCertByNicknameOrEmailAddrCX(CERTCertDBHandle *handle, + const char *name, + void *wincx); + +/* +** Find a certificate in the database by a email address or nickname +** and require it to have the given usage. +** "name" is the email address or nickname to look up +*/ +CERTCertificate *CERT_FindCertByNicknameOrEmailAddrForUsage( + CERTCertDBHandle *handle, const char *name, SECCertUsage lookingForUsage); +CERTCertificate *CERT_FindCertByNicknameOrEmailAddrForUsageCX( + CERTCertDBHandle *handle, const char *name, SECCertUsage lookingForUsage, + void *wincx); + +/* +** Find a certificate in the database by a digest of a subject public key +** "spkDigest" is the digest to look up +*/ +extern CERTCertificate *CERT_FindCertBySPKDigest(CERTCertDBHandle *handle, + SECItem *spkDigest); + +/* + * Find the issuer of a cert + */ +CERTCertificate *CERT_FindCertIssuer(CERTCertificate *cert, PRTime validTime, + SECCertUsage usage); + +/* +** Check the validity times of a certificate vs. time 't', allowing +** some slop for broken clocks and stuff. +** "cert" is the certificate to be checked +** "t" is the time to check against +** "allowOverride" if true then check to see if the invalidity has +** been overridden by the user. +*/ +extern SECCertTimeValidity CERT_CheckCertValidTimes(const CERTCertificate *cert, + PRTime t, + PRBool allowOverride); + +/* +** WARNING - this function is deprecated, and will either go away or have +** a new API in the near future. +** +** Check the validity times of a certificate vs. the current time, allowing +** some slop for broken clocks and stuff. +** "cert" is the certificate to be checked +*/ +extern SECStatus CERT_CertTimesValid(CERTCertificate *cert); + +/* +** Extract the validity times from a certificate +** "c" is the certificate +** "notBefore" is the start of the validity period +** "notAfter" is the end of the validity period +*/ +extern SECStatus CERT_GetCertTimes(const CERTCertificate *c, PRTime *notBefore, + PRTime *notAfter); + +/* +** Extract the issuer and serial number from a certificate +*/ +extern CERTIssuerAndSN *CERT_GetCertIssuerAndSN(PLArenaPool *, + CERTCertificate *); + +/* +** verify the signature of a signed data object with a given certificate +** "sd" the signed data object to be verified +** "cert" the certificate to use to check the signature +*/ +extern SECStatus CERT_VerifySignedData(CERTSignedData *sd, + CERTCertificate *cert, PRTime t, + void *wincx); +/* +** verify the signature of a signed data object with the given DER publickey +*/ +extern SECStatus CERT_VerifySignedDataWithPublicKeyInfo( + CERTSignedData *sd, CERTSubjectPublicKeyInfo *pubKeyInfo, void *wincx); + +/* +** verify the signature of a signed data object with a SECKEYPublicKey. +*/ +extern SECStatus CERT_VerifySignedDataWithPublicKey(const CERTSignedData *sd, + SECKEYPublicKey *pubKey, + void *wincx); + +/* +** NEW FUNCTIONS with new bit-field-FIELD SECCertificateUsage - please use +** verify a certificate by checking validity times against a certain time, +** that we trust the issuer, and that the signature on the certificate is +** valid. +** "cert" the certificate to verify +** "checkSig" only check signatures if true +*/ +extern SECStatus CERT_VerifyCertificate(CERTCertDBHandle *handle, + CERTCertificate *cert, PRBool checkSig, + SECCertificateUsage requiredUsages, + PRTime t, void *wincx, + CERTVerifyLog *log, + SECCertificateUsage *returnedUsages); + +/* same as above, but uses current time */ +extern SECStatus CERT_VerifyCertificateNow(CERTCertDBHandle *handle, + CERTCertificate *cert, + PRBool checkSig, + SECCertificateUsage requiredUsages, + void *wincx, + SECCertificateUsage *returnedUsages); + +/* +** Verify that a CA cert can certify some (unspecified) leaf cert for a given +** purpose. This is used by UI code to help identify where a chain may be +** broken and why. This takes identical parameters to CERT_VerifyCert +*/ +extern SECStatus CERT_VerifyCACertForUsage(CERTCertDBHandle *handle, + CERTCertificate *cert, + PRBool checkSig, + SECCertUsage certUsage, PRTime t, + void *wincx, CERTVerifyLog *log); + +/* +** OLD OBSOLETE FUNCTIONS with enum SECCertUsage - DO NOT USE FOR NEW CODE +** verify a certificate by checking validity times against a certain time, +** that we trust the issuer, and that the signature on the certificate is +** valid. +** "cert" the certificate to verify +** "checkSig" only check signatures if true +*/ +extern SECStatus CERT_VerifyCert(CERTCertDBHandle *handle, + CERTCertificate *cert, PRBool checkSig, + SECCertUsage certUsage, PRTime t, void *wincx, + CERTVerifyLog *log); + +/* same as above, but uses current time */ +extern SECStatus CERT_VerifyCertNow(CERTCertDBHandle *handle, + CERTCertificate *cert, PRBool checkSig, + SECCertUsage certUsage, void *wincx); + +SECStatus CERT_VerifyCertChain(CERTCertDBHandle *handle, CERTCertificate *cert, + PRBool checkSig, SECCertUsage certUsage, + PRTime t, void *wincx, CERTVerifyLog *log); + +/* +** Read a base64 ascii encoded DER certificate and convert it to our +** internal format. +** "certstr" is a null-terminated string containing the certificate +*/ +extern CERTCertificate *CERT_ConvertAndDecodeCertificate(char *certstr); + +/* +** Read a certificate in some foreign format, and convert it to our +** internal format. +** "certbuf" is the buffer containing the certificate +** "certlen" is the length of the buffer +** NOTE - currently supports netscape base64 ascii encoded raw certs +** and netscape binary DER typed files. +*/ +extern CERTCertificate *CERT_DecodeCertFromPackage(char *certbuf, int certlen); + +extern SECStatus CERT_ImportCAChain(SECItem *certs, int numcerts, + SECCertUsage certUsage); + +extern SECStatus CERT_ImportCAChainTrusted(SECItem *certs, int numcerts, + SECCertUsage certUsage); + +/* +** Read a certificate chain in some foreign format, and pass it to a +** callback function. +** "certbuf" is the buffer containing the certificate +** "certlen" is the length of the buffer +** "f" is the callback function +** "arg" is the callback argument +*/ +typedef SECStatus(PR_CALLBACK *CERTImportCertificateFunc)(void *arg, + SECItem **certs, + int numcerts); + +extern SECStatus CERT_DecodeCertPackage(char *certbuf, int certlen, + CERTImportCertificateFunc f, void *arg); + +/* +** Returns the value of an AVA. This was a formerly static +** function that has been exposed due to the need to decode +** and convert unicode strings to UTF8. +** +** XXX This function resides in certhtml.c, should it be +** moved elsewhere? +*/ +extern SECItem *CERT_DecodeAVAValue(const SECItem *derAVAValue); + +/* +** extract various element strings from a distinguished name. +** "name" the distinguished name +*/ + +extern char *CERT_GetCertificateEmailAddress(CERTCertificate *cert); + +extern char *CERT_GetCertEmailAddress(const CERTName *name); + +extern const char *CERT_GetFirstEmailAddress(CERTCertificate *cert); + +extern const char *CERT_GetNextEmailAddress(CERTCertificate *cert, + const char *prev); + +/* The return value must be freed with PORT_Free. */ +extern char *CERT_GetCommonName(const CERTName *name); + +extern char *CERT_GetCountryName(const CERTName *name); + +extern char *CERT_GetLocalityName(const CERTName *name); + +extern char *CERT_GetStateName(const CERTName *name); + +extern char *CERT_GetOrgName(const CERTName *name); + +extern char *CERT_GetOrgUnitName(const CERTName *name); + +extern char *CERT_GetDomainComponentName(const CERTName *name); + +extern char *CERT_GetCertUid(const CERTName *name); + +/* manipulate the trust parameters of a certificate */ + +extern SECStatus CERT_GetCertTrust(const CERTCertificate *cert, + CERTCertTrust *trust); + +extern SECStatus CERT_ChangeCertTrust(CERTCertDBHandle *handle, + CERTCertificate *cert, + CERTCertTrust *trust); + +extern SECStatus CERT_ChangeCertTrustByUsage(CERTCertDBHandle *certdb, + CERTCertificate *cert, + SECCertUsage usage); + +/************************************************************************* + * + * manipulate the extensions of a certificate + * + ************************************************************************/ + +/* +** Set up a cert for adding X509v3 extensions. Returns an opaque handle +** used by the next two routines. +** "cert" is the certificate we are adding extensions to +*/ +extern void *CERT_StartCertExtensions(CERTCertificate *cert); + +/* +** Add an extension to a certificate. +** "exthandle" is the handle returned by the previous function +** "idtag" is the integer tag for the OID that should ID this extension +** "value" is the value of the extension +** "critical" is the critical extension flag +** "copyData" is a flag indicating whether the value data should be +** copied. +*/ +extern SECStatus CERT_AddExtension(void *exthandle, int idtag, SECItem *value, + PRBool critical, PRBool copyData); + +extern SECStatus CERT_AddExtensionByOID(void *exthandle, SECItem *oid, + SECItem *value, PRBool critical, + PRBool copyData); + +extern SECStatus CERT_EncodeAndAddExtension(void *exthandle, int idtag, + void *value, PRBool critical, + const SEC_ASN1Template *atemplate); + +extern SECStatus CERT_EncodeAndAddBitStrExtension(void *exthandle, int idtag, + SECItem *value, + PRBool critical); + +extern SECStatus CERT_EncodeAltNameExtension(PLArenaPool *arena, + CERTGeneralName *value, + SECItem *encodedValue); + +/* +** Finish adding cert extensions. Does final processing on extension +** data, putting it in the right format, and freeing any temporary +** storage. +** "exthandle" is the handle used to add extensions to a certificate +*/ +extern SECStatus CERT_FinishExtensions(void *exthandle); + +/* +** Merge an external list of extensions into a cert's extension list, adding one +** only when its OID matches none of the cert's existing extensions. Call this +** immediately before calling CERT_FinishExtensions(). +*/ +SECStatus CERT_MergeExtensions(void *exthandle, CERTCertExtension **exts); + +/* If the extension is found, return its criticality and value. +** This allocate storage for the returning extension value. +*/ +extern SECStatus CERT_GetExtenCriticality(CERTCertExtension **extensions, + int tag, PRBool *isCritical); + +extern void CERT_DestroyOidSequence(CERTOidSequence *oidSeq); + +/**************************************************************************** + * + * DER encode and decode extension values + * + ****************************************************************************/ + +/* Encode the value of the basicConstraint extension. +** arena - where to allocate memory for the encoded value. +** value - extension value to encode +** encodedValue - output encoded value +*/ +extern SECStatus CERT_EncodeBasicConstraintValue(PLArenaPool *arena, + CERTBasicConstraints *value, + SECItem *encodedValue); + +/* +** Encode the value of the authorityKeyIdentifier extension. +*/ +extern SECStatus CERT_EncodeAuthKeyID(PLArenaPool *arena, CERTAuthKeyID *value, + SECItem *encodedValue); + +/* +** Encode the value of the crlDistributionPoints extension. +*/ +extern SECStatus CERT_EncodeCRLDistributionPoints( + PLArenaPool *arena, CERTCrlDistributionPoints *value, SECItem *derValue); + +/* +** Decodes a DER encoded basicConstaint extension value into a readable format +** value - decoded value +** encodedValue - value to decoded +*/ +extern SECStatus CERT_DecodeBasicConstraintValue(CERTBasicConstraints *value, + const SECItem *encodedValue); + +/* Decodes a DER encoded authorityKeyIdentifier extension value into a +** readable format. +** arena - where to allocate memory for the decoded value +** encodedValue - value to be decoded +** Returns a CERTAuthKeyID structure which contains the decoded value +*/ +extern CERTAuthKeyID *CERT_DecodeAuthKeyID(PLArenaPool *arena, + const SECItem *encodedValue); + +/* Decodes a DER encoded crlDistributionPoints extension value into a +** readable format. +** arena - where to allocate memory for the decoded value +** der - value to be decoded +** Returns a CERTCrlDistributionPoints structure which contains the +** decoded value +*/ +extern CERTCrlDistributionPoints *CERT_DecodeCRLDistributionPoints( + PLArenaPool *arena, SECItem *der); + +/* Extract certain name type from a generalName */ +extern void *CERT_GetGeneralNameByType(CERTGeneralName *genNames, + CERTGeneralNameType type, + PRBool derFormat); + +extern CERTOidSequence *CERT_DecodeOidSequence(const SECItem *seqItem); + +/**************************************************************************** + * + * Find extension values of a certificate + * + ***************************************************************************/ + +extern SECStatus CERT_FindCertExtension(const CERTCertificate *cert, int tag, + SECItem *value); + +extern SECStatus CERT_FindNSCertTypeExtension(CERTCertificate *cert, + SECItem *value); + +extern char *CERT_FindNSStringExtension(CERTCertificate *cert, int oidtag); + +extern SECStatus CERT_FindCertExtensionByOID(CERTCertificate *cert, + SECItem *oid, SECItem *value); + +/* Returns the decoded value of the authKeyID extension. +** Note that this uses passed in the arena to allocate storage for the result +*/ +extern CERTAuthKeyID *CERT_FindAuthKeyIDExten(PLArenaPool *arena, + CERTCertificate *cert); + +/* Returns the decoded value of the basicConstraint extension. + */ +extern SECStatus CERT_FindBasicConstraintExten(CERTCertificate *cert, + CERTBasicConstraints *value); + +/* Returns the decoded value of the crlDistributionPoints extension. +** Note that the arena in cert is used to allocate storage for the result +*/ +extern CERTCrlDistributionPoints *CERT_FindCRLDistributionPoints( + CERTCertificate *cert); + +/* Returns value of the keyUsage extension. This uses PR_Alloc to allocate +** buffer for the decoded value. The caller should free up the storage +** allocated in value->data. +*/ +extern SECStatus CERT_FindKeyUsageExtension(CERTCertificate *cert, + SECItem *value); + +/* Return the decoded value of the subjectKeyID extension. The caller should +** free up the storage allocated in retItem->data. +*/ +extern SECStatus CERT_FindSubjectKeyIDExtension(CERTCertificate *cert, + SECItem *retItem); + +/* +** If cert is a v3 certificate, and a critical keyUsage extension is included, +** then check the usage against the extension value. If a non-critical +** keyUsage extension is included, this will return SECSuccess without +** checking, since the extension is an advisory field, not a restriction. +** If cert is not a v3 certificate, this will return SECSuccess. +** cert - certificate +** usage - one of the x.509 v3 the Key Usage Extension flags +*/ +extern SECStatus CERT_CheckCertUsage(CERTCertificate *cert, + unsigned char usage); + +/**************************************************************************** + * + * CRL v2 Extensions supported routines + * + ****************************************************************************/ + +extern SECStatus CERT_FindCRLExtensionByOID(CERTCrl *crl, SECItem *oid, + SECItem *value); + +extern SECStatus CERT_FindCRLExtension(CERTCrl *crl, int tag, SECItem *value); + +extern SECStatus CERT_FindInvalidDateExten(CERTCrl *crl, PRTime *value); + +/* +** Set up a crl for adding X509v3 extensions. Returns an opaque handle +** used by routines that take an exthandle (void*) argument . +** "crl" is the CRL we are adding extensions to +*/ +extern void *CERT_StartCRLExtensions(CERTCrl *crl); + +/* +** Set up a crl entry for adding X509v3 extensions. Returns an opaque handle +** used by routines that take an exthandle (void*) argument . +** "crl" is the crl we are adding certs entries to +** "entry" is the crl entry we are adding extensions to +*/ +extern void *CERT_StartCRLEntryExtensions(CERTCrl *crl, CERTCrlEntry *entry); + +extern CERTCertNicknames *CERT_GetCertNicknames(CERTCertDBHandle *handle, + int what, void *wincx); + +/* +** Finds the crlNumber extension and decodes its value into 'value' +*/ +extern SECStatus CERT_FindCRLNumberExten(PLArenaPool *arena, CERTCrl *crl, + SECItem *value); + +extern SECStatus CERT_FindCRLEntryReasonExten(CERTCrlEntry *crlEntry, + CERTCRLEntryReasonCode *value); + +extern void CERT_FreeNicknames(CERTCertNicknames *nicknames); + +extern PRBool CERT_CompareCerts(const CERTCertificate *c1, + const CERTCertificate *c2); + +extern PRBool CERT_CompareCertsForRedirection(CERTCertificate *c1, + CERTCertificate *c2); + +/* +** Generate an array of the Distinguished Names that the given cert database +** "trusts" +*/ +extern CERTDistNames *CERT_GetSSLCACerts(CERTCertDBHandle *handle); + +extern void CERT_FreeDistNames(CERTDistNames *names); + +/* Duplicate distinguished name array */ +extern CERTDistNames *CERT_DupDistNames(CERTDistNames *orig); + +/* +** Generate an array of Distinguished names from an array of nicknames +*/ +extern CERTDistNames *CERT_DistNamesFromNicknames(CERTCertDBHandle *handle, + char **nicknames, int nnames); + +/* +** Generate an array of Distinguished names from a list of certs. +*/ +extern CERTDistNames *CERT_DistNamesFromCertList(CERTCertList *list); + +/* +** Generate a certificate chain from a certificate. +*/ +extern CERTCertificateList *CERT_CertChainFromCert(CERTCertificate *cert, + SECCertUsage usage, + PRBool includeRoot); + +extern CERTCertificateList *CERT_CertListFromCert(CERTCertificate *cert); + +extern CERTCertificateList *CERT_DupCertList( + const CERTCertificateList *oldList); + +extern void CERT_DestroyCertificateList(CERTCertificateList *list); + +/* +** is cert a user cert? i.e. does it have CERTDB_USER trust, +** i.e. a private key? +*/ +PRBool CERT_IsUserCert(CERTCertificate *cert); + +/* is cert a newer than cert b? */ +PRBool CERT_IsNewer(CERTCertificate *certa, CERTCertificate *certb); + +/* currently a stub for address book */ +PRBool CERT_IsCertRevoked(CERTCertificate *cert); + +void CERT_DestroyCertArray(CERTCertificate **certs, unsigned int ncerts); + +/* convert an email address to lower case */ +char *CERT_FixupEmailAddr(const char *emailAddr); + +/* decode string representation of trust flags into trust struct */ +SECStatus CERT_DecodeTrustString(CERTCertTrust *trust, const char *trusts); + +/* encode trust struct into string representation of trust flags */ +char *CERT_EncodeTrustString(CERTCertTrust *trust); + +/* find the next or prev cert in a subject list */ +CERTCertificate *CERT_PrevSubjectCert(CERTCertificate *cert); +CERTCertificate *CERT_NextSubjectCert(CERTCertificate *cert); + +/* + * import a collection of certs into the temporary or permanent cert + * database + */ +SECStatus CERT_ImportCerts(CERTCertDBHandle *certdb, SECCertUsage usage, + unsigned int ncerts, SECItem **derCerts, + CERTCertificate ***retCerts, PRBool keepCerts, + PRBool caOnly, char *nickname); + +char *CERT_MakeCANickname(CERTCertificate *cert); + +PRBool CERT_IsCACert(CERTCertificate *cert, unsigned int *rettype); + +PRBool CERT_IsCADERCert(SECItem *derCert, unsigned int *rettype); + +PRBool CERT_IsRootDERCert(SECItem *derCert); + +SECStatus CERT_SaveSMimeProfile(CERTCertificate *cert, SECItem *emailProfile, + SECItem *profileTime); + +/* + * find the smime symmetric capabilities profile for a given cert + */ +SECItem *CERT_FindSMimeProfile(CERTCertificate *cert); + +SECStatus CERT_AddNewCerts(CERTCertDBHandle *handle); + +CERTCertificatePolicies *CERT_DecodeCertificatePoliciesExtension( + const SECItem *extnValue); + +void CERT_DestroyCertificatePoliciesExtension( + CERTCertificatePolicies *policies); + +CERTCertificatePolicyMappings *CERT_DecodePolicyMappingsExtension( + SECItem *encodedCertPolicyMaps); + +SECStatus CERT_DestroyPolicyMappingsExtension( + CERTCertificatePolicyMappings *mappings); + +SECStatus CERT_DecodePolicyConstraintsExtension( + CERTCertificatePolicyConstraints *decodedValue, + const SECItem *encodedValue); + +SECStatus CERT_DecodeInhibitAnyExtension( + CERTCertificateInhibitAny *decodedValue, SECItem *extnValue); + +CERTUserNotice *CERT_DecodeUserNotice(SECItem *noticeItem); + +extern CERTGeneralName *CERT_DecodeAltNameExtension(PLArenaPool *reqArena, + SECItem *EncodedAltName); + +extern CERTNameConstraints *CERT_DecodeNameConstraintsExtension( + PLArenaPool *arena, const SECItem *encodedConstraints); + +/* returns addr of a NULL termainated array of pointers to CERTAuthInfoAccess */ +extern CERTAuthInfoAccess **CERT_DecodeAuthInfoAccessExtension( + PLArenaPool *reqArena, const SECItem *encodedExtension); + +extern CERTPrivKeyUsagePeriod *CERT_DecodePrivKeyUsagePeriodExtension( + PLArenaPool *arena, SECItem *extnValue); + +extern CERTGeneralName *CERT_GetNextGeneralName(CERTGeneralName *current); + +extern CERTGeneralName *CERT_GetPrevGeneralName(CERTGeneralName *current); + +/* + * Look up name constraints for some certs that do not include name constraints + * (Most importantly, root certificates) + * + * If a matching subject is found, |extensions| will be populated with a copy of + * the + * DER-encoded name constraints extension. The data in |extensions| will point + * to + * memory that the caller owns. + * + * There is no mechanism to configure imposed name constraints right now. All + * imposed name constraints are built into NSS. + */ +SECStatus CERT_GetImposedNameConstraints(const SECItem *derSubject, + SECItem *extensions); + +CERTNameConstraint *CERT_GetNextNameConstraint(CERTNameConstraint *current); + +CERTNameConstraint *CERT_GetPrevNameConstraint(CERTNameConstraint *current); + +void CERT_DestroyUserNotice(CERTUserNotice *userNotice); + +typedef char *(*CERTPolicyStringCallback)(char *org, unsigned long noticeNumber, + void *arg); +void CERT_SetCAPolicyStringCallback(CERTPolicyStringCallback cb, void *cbarg); + +char *CERT_GetCertCommentString(CERTCertificate *cert); + +PRBool CERT_GovtApprovedBitSet(CERTCertificate *cert); + +SECStatus CERT_AddPermNickname(CERTCertificate *cert, char *nickname); + +CERTCertList *CERT_MatchUserCert(CERTCertDBHandle *handle, SECCertUsage usage, + int nCANames, char **caNames, void *proto_win); + +CERTCertList *CERT_NewCertList(void); + +/* free the cert list and all the certs in the list */ +void CERT_DestroyCertList(CERTCertList *certs); + +/* remove the node and free the cert */ +void CERT_RemoveCertListNode(CERTCertListNode *node); + +/* equivalent to CERT_AddCertToListTailWithData(certs, cert, NULL) */ +SECStatus CERT_AddCertToListTail(CERTCertList *certs, CERTCertificate *cert); + +/* equivalent to CERT_AddCertToListHeadWithData(certs, cert, NULL) */ +SECStatus CERT_AddCertToListHead(CERTCertList *certs, CERTCertificate *cert); + +/* + * The new cert list node takes ownership of "cert". "cert" is freed + * when the list node is removed. + */ +SECStatus CERT_AddCertToListTailWithData(CERTCertList *certs, + CERTCertificate *cert, void *appData); + +/* + * The new cert list node takes ownership of "cert". "cert" is freed + * when the list node is removed. + */ +SECStatus CERT_AddCertToListHeadWithData(CERTCertList *certs, + CERTCertificate *cert, void *appData); + +typedef PRBool (*CERTSortCallback)(CERTCertificate *certa, + CERTCertificate *certb, void *arg); +SECStatus CERT_AddCertToListSorted(CERTCertList *certs, CERTCertificate *cert, + CERTSortCallback f, void *arg); + +/* callback for CERT_AddCertToListSorted that sorts based on validity + * period and a given time. + */ +PRBool CERT_SortCBValidity(CERTCertificate *certa, CERTCertificate *certb, + void *arg); + +SECStatus CERT_CheckForEvilCert(CERTCertificate *cert); + +CERTGeneralName *CERT_GetCertificateNames(CERTCertificate *cert, + PLArenaPool *arena); + +CERTGeneralName *CERT_GetConstrainedCertificateNames( + const CERTCertificate *cert, PLArenaPool *arena, + PRBool includeSubjectCommonName); + +/* + * Creates or adds to a list of all certs with a give subject name, sorted by + * validity time, newest first. Invalid certs are considered older than + * valid certs. If validOnly is set, do not include invalid certs on list. + */ +CERTCertList *CERT_CreateSubjectCertList(CERTCertList *certList, + CERTCertDBHandle *handle, + const SECItem *name, PRTime sorttime, + PRBool validOnly); + +/* + * remove certs from a list that don't have keyUsage and certType + * that match the given usage. + */ +SECStatus CERT_FilterCertListByUsage(CERTCertList *certList, SECCertUsage usage, + PRBool ca); + +/* + * check the key usage of a cert against a set of required values + */ +SECStatus CERT_CheckKeyUsage(CERTCertificate *cert, unsigned int requiredUsage); + +/* + * return required key usage and cert type based on cert usage + */ +SECStatus CERT_KeyUsageAndTypeForCertUsage(SECCertUsage usage, PRBool ca, + unsigned int *retKeyUsage, + unsigned int *retCertType); +/* + * return required trust flags for various cert usages for CAs + */ +SECStatus CERT_TrustFlagsForCACertUsage(SECCertUsage usage, + unsigned int *retFlags, + SECTrustType *retTrustType); + +/* + * Find all user certificates that match the given criteria. + * + * "handle" - database to search + * "usage" - certificate usage to match + * "oneCertPerName" - if set then only return the "best" cert per + * name + * "validOnly" - only return certs that are curently valid + * "proto_win" - window handle passed to pkcs11 + */ +CERTCertList *CERT_FindUserCertsByUsage(CERTCertDBHandle *handle, + SECCertUsage usage, + PRBool oneCertPerName, PRBool validOnly, + void *proto_win); + +/* + * Find a user certificate that matchs the given criteria. + * + * "handle" - database to search + * "nickname" - nickname to match + * "usage" - certificate usage to match + * "validOnly" - only return certs that are curently valid + * "proto_win" - window handle passed to pkcs11 + */ +CERTCertificate *CERT_FindUserCertByUsage(CERTCertDBHandle *handle, + const char *nickname, + SECCertUsage usage, PRBool validOnly, + void *proto_win); + +/* + * Filter a list of certificates, removing those certs that do not have + * one of the named CA certs somewhere in their cert chain. + * + * "certList" - the list of certificates to filter + * "nCANames" - number of CA names + * "caNames" - array of CA names in string(rfc 1485) form + * "usage" - what use the certs are for, this is used when + * selecting CA certs + */ +SECStatus CERT_FilterCertListByCANames(CERTCertList *certList, int nCANames, + char **caNames, SECCertUsage usage); + +/* + * Filter a list of certificates, removing those certs that aren't user certs + */ +SECStatus CERT_FilterCertListForUserCerts(CERTCertList *certList); + +/* + * Filter a list of certificates, removing those certs that don't match the + * nickname. + */ +SECStatus CERT_FilterCertListByNickname(CERTCertList *certList, char *nickname, + void *pwarg); + +/* return true if cert is in cert list */ +PRBool CERT_IsInList(const CERTCertificate *cert, const CERTCertList *certList); + +/* returned certList is the intersection of the certs on certList and the + * certs on filterList */ +SECStatus CERT_FilterCertListByCertList(CERTCertList *certList, + const CERTCertList *filterList); + +/* + * Collect the nicknames from all certs in a CertList. If the cert is not + * valid, append a string to that nickname. + * + * "certList" - the list of certificates + * "expiredString" - the string to append to the nickname of any expired cert + * "notYetGoodString" - the string to append to the nickname of any cert + * that is not yet valid + */ +CERTCertNicknames *CERT_NicknameStringsFromCertList(CERTCertList *certList, + char *expiredString, + char *notYetGoodString); + +/* + * Extract the nickname from a nickmake string that may have either + * expiredString or notYetGoodString appended. + * + * Args: + * "namestring" - the string containing the nickname, and possibly + * one of the validity label strings + * "expiredString" - the expired validity label string + * "notYetGoodString" - the not yet good validity label string + * + * Returns the raw nickname + */ +char *CERT_ExtractNicknameString(char *namestring, char *expiredString, + char *notYetGoodString); + +/* + * Given a certificate, return a string containing the nickname, and possibly + * one of the validity strings, based on the current validity state of the + * certificate. + * + * "arena" - arena to allocate returned string from. If NULL, then heap + * is used. + * "cert" - the cert to get nickname from + * "expiredString" - the string to append to the nickname if the cert is + * expired. + * "notYetGoodString" - the string to append to the nickname if the cert is + * not yet good. + */ +char *CERT_GetCertNicknameWithValidity(PLArenaPool *arena, + CERTCertificate *cert, + char *expiredString, + char *notYetGoodString); + +/* + * Return the string representation of a DER encoded distinguished name + * "dername" - The DER encoded name to convert + */ +char *CERT_DerNameToAscii(SECItem *dername); + +/* + * Supported usage values and types: + * certUsageSSLClient + * certUsageSSLServer + * certUsageSSLServerWithStepUp + * certUsageEmailSigner + * certUsageEmailRecipient + * certUsageObjectSigner + */ + +CERTCertificate *CERT_FindMatchingCert(CERTCertDBHandle *handle, + SECItem *derName, CERTCertOwner owner, + SECCertUsage usage, PRBool preferTrusted, + PRTime validTime, PRBool validOnly); + +/* + * Acquire the global lock on the cert database. + * This lock is currently used for the following operations: + * adding or deleting a cert to either the temp or perm databases + * converting a temp to perm or perm to temp + * changing(maybe just adding?) the trust of a cert + * adjusting the reference count of a cert + */ +void CERT_LockDB(CERTCertDBHandle *handle); + +/* + * Free the global cert database lock. + */ +void CERT_UnlockDB(CERTCertDBHandle *handle); + +/* + * Get the certificate status checking configuratino data for + * the certificate database + */ +CERTStatusConfig *CERT_GetStatusConfig(CERTCertDBHandle *handle); + +/* + * Set the certificate status checking information for the + * database. The input structure becomes part of the certificate + * database and will be freed by calling the 'Destroy' function in + * the configuration object. + */ +void CERT_SetStatusConfig(CERTCertDBHandle *handle, CERTStatusConfig *config); + +/* + * Acquire the cert reference count lock + * There is currently one global lock for all certs, but I'm putting a cert + * arg here so that it will be easy to make it per-cert in the future if + * that turns out to be necessary. + */ +void CERT_LockCertRefCount(CERTCertificate *cert); + +/* + * Release the cert reference count lock + */ +void CERT_UnlockCertRefCount(CERTCertificate *cert); + +/* + * Digest the cert's subject public key using the specified algorithm. + * NOTE: this digests the value of the BIT STRING subjectPublicKey (excluding + * the tag, length, and number of unused bits) rather than the whole + * subjectPublicKeyInfo field. + * + * The necessary storage for the digest data is allocated. If "fill" is + * non-null, the data is put there, otherwise a SECItem is allocated. + * Allocation from "arena" if it is non-null, heap otherwise. Any problem + * results in a NULL being returned (and an appropriate error set). + */ +extern SECItem *CERT_GetSubjectPublicKeyDigest(PLArenaPool *arena, + const CERTCertificate *cert, + SECOidTag digestAlg, + SECItem *fill); + +/* + * Digest the cert's subject name using the specified algorithm. + */ +extern SECItem *CERT_GetSubjectNameDigest(PLArenaPool *arena, + const CERTCertificate *cert, + SECOidTag digestAlg, SECItem *fill); + +SECStatus CERT_CheckCRL(CERTCertificate *cert, CERTCertificate *issuer, + const SECItem *dp, PRTime t, void *wincx); + +/* + * Add a CERTNameConstraint to the CERTNameConstraint list + */ +extern CERTNameConstraint *CERT_AddNameConstraint( + CERTNameConstraint *list, CERTNameConstraint *constraint); + +/* + * Allocate space and copy CERTNameConstraint from src to dest. + * Arena is used to allocate result(if dest eq NULL) and its members + * SECItem data. + */ +extern CERTNameConstraint *CERT_CopyNameConstraint(PLArenaPool *arena, + CERTNameConstraint *dest, + CERTNameConstraint *src); + +/* + * Verify name against all the constraints relevant to that type of + * the name. + */ +extern SECStatus CERT_CheckNameSpace(PLArenaPool *arena, + const CERTNameConstraints *constraints, + const CERTGeneralName *currentName); + +/* + * Extract and allocate the name constraints extension from the CA cert. + * If the certificate contains no name constraints extension, but + * CERT_GetImposedNameConstraints returns a name constraints extension + * for the subject of the certificate, then that extension will be returned. + */ +extern SECStatus CERT_FindNameConstraintsExten( + PLArenaPool *arena, CERTCertificate *cert, + CERTNameConstraints **constraints); + +/* + * Initialize a new GERTGeneralName fields (link) + */ +extern CERTGeneralName *CERT_NewGeneralName(PLArenaPool *arena, + CERTGeneralNameType type); + +/* + * Lookup a CERTGeneralNameType constant by its human readable string. + */ +extern CERTGeneralNameType CERT_GetGeneralNameTypeFromString( + const char *string); + +/* + * PKIX extension encoding routines + */ +extern SECStatus CERT_EncodePolicyConstraintsExtension( + PLArenaPool *arena, CERTCertificatePolicyConstraints *constr, + SECItem *dest); +extern SECStatus CERT_EncodeInhibitAnyExtension( + PLArenaPool *arena, CERTCertificateInhibitAny *inhibitAny, SECItem *dest); +extern SECStatus CERT_EncodePolicyMappingExtension( + PLArenaPool *arena, CERTCertificatePolicyMappings *maps, SECItem *dest); + +extern SECStatus CERT_EncodeInfoAccessExtension(PLArenaPool *arena, + CERTAuthInfoAccess **info, + SECItem *dest); +extern SECStatus CERT_EncodeUserNotice(PLArenaPool *arena, + CERTUserNotice *notice, SECItem *dest); + +extern SECStatus CERT_EncodeDisplayText(PLArenaPool *arena, SECItem *text, + SECItem *dest); + +extern SECStatus CERT_EncodeCertPoliciesExtension(PLArenaPool *arena, + CERTPolicyInfo **info, + SECItem *dest); +extern SECStatus CERT_EncodeNoticeReference(PLArenaPool *arena, + CERTNoticeReference *reference, + SECItem *dest); + +/* + * Returns a pointer to a static structure. + */ +extern const CERTRevocationFlags *CERT_GetPKIXVerifyNistRevocationPolicy(void); + +/* + * Returns a pointer to a static structure. + */ +extern const CERTRevocationFlags *CERT_GetClassicOCSPEnabledSoftFailurePolicy( + void); + +/* + * Returns a pointer to a static structure. + */ +extern const CERTRevocationFlags *CERT_GetClassicOCSPEnabledHardFailurePolicy( + void); + +/* + * Returns a pointer to a static structure. + */ +extern const CERTRevocationFlags *CERT_GetClassicOCSPDisabledPolicy(void); + +/* + * Verify a Cert with libpkix + * paramsIn control the verification options. If a value isn't specified + * in paramsIn, it reverts to the application default. + * paramsOut specifies the parameters the caller would like to get back. + * the caller may pass NULL, in which case no parameters are returned. + */ +extern SECStatus CERT_PKIXVerifyCert(CERTCertificate *cert, + SECCertificateUsage usages, + CERTValInParam *paramsIn, + CERTValOutParam *paramsOut, void *wincx); + +/* Makes old cert validation APIs(CERT_VerifyCert, CERT_VerifyCertificate) + * to use libpkix validation engine. The function should be called ones at + * application initialization time. + * Function is not thread safe.*/ +extern SECStatus CERT_SetUsePKIXForValidation(PRBool enable); + +/* The function return PR_TRUE if cert validation should use + * libpkix cert validation engine. */ +extern PRBool CERT_GetUsePKIXForValidation(void); + +/* + * Allocate a parameter container of type CERTRevocationFlags, + * and allocate the inner arrays of the given sizes. + * To cleanup call CERT_DestroyCERTRevocationFlags. + */ +extern CERTRevocationFlags *CERT_AllocCERTRevocationFlags( + PRUint32 number_leaf_methods, PRUint32 number_leaf_pref_methods, + PRUint32 number_chain_methods, PRUint32 number_chain_pref_methods); + +/* + * Destroy the arrays inside flags, + * and destroy the object pointed to by flags, too. + */ +extern void CERT_DestroyCERTRevocationFlags(CERTRevocationFlags *flags); + +/* + * Get istemp and isperm fields from a cert in a thread safe way. + */ +extern SECStatus CERT_GetCertIsTemp(const CERTCertificate *cert, PRBool *istemp); +extern SECStatus CERT_GetCertIsPerm(const CERTCertificate *cert, PRBool *isperm); + +SEC_END_PROTOS + +#endif /* _CERT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/certdb.h b/illumos-x86_64/usr/include/mps/certdb.h new file mode 100644 index 00000000..53d8a391 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/certdb.h @@ -0,0 +1,89 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _CERTDB_H_ +#define _CERTDB_H_ + +/* common flags for all types of certificates */ +#define CERTDB_TERMINAL_RECORD (1u << 0) +#define CERTDB_TRUSTED (1u << 1) +#define CERTDB_SEND_WARN (1u << 2) +#define CERTDB_VALID_CA (1u << 3) +#define CERTDB_TRUSTED_CA (1u << 4) /* trusted for issuing server certs */ +#define CERTDB_NS_TRUSTED_CA (1u << 5) +#define CERTDB_USER (1u << 6) +#define CERTDB_TRUSTED_CLIENT_CA (1u << 7) /* trusted for issuing client certs */ +#define CERTDB_INVISIBLE_CA (1u << 8) /* don't show in UI */ +#define CERTDB_GOVT_APPROVED_CA (1u << 9) /* can do strong crypto in export ver */ + +/* old usage, to keep old programs compiling */ +/* On Windows, Mac, and Linux (and other gcc platforms), we can give compile + * time deprecation warnings when applications use the old CERTDB_VALID_PEER + * define */ +#if __GNUC__ > 3 +#if (__GNUC__ == 4) && (__GNUC_MINOR__ < 5) +typedef unsigned int __CERTDB_VALID_PEER __attribute__((deprecated)); +#else +typedef unsigned int __CERTDB_VALID_PEER __attribute__(( + deprecated("CERTDB_VALID_PEER is now CERTDB_TERMINAL_RECORD"))); +#endif +#define CERTDB_VALID_PEER ((__CERTDB_VALID_PEER)CERTDB_TERMINAL_RECORD) +#else +#ifdef _WIN32 +#pragma deprecated(CERTDB_VALID_PEER) +#endif +#define CERTDB_VALID_PEER CERTDB_TERMINAL_RECORD +#endif + +SEC_BEGIN_PROTOS + +CERTSignedCrl *SEC_FindCrlByKey(CERTCertDBHandle *handle, SECItem *crlKey, + int type); + +CERTSignedCrl *SEC_FindCrlByName(CERTCertDBHandle *handle, SECItem *crlKey, + int type); + +CERTSignedCrl *SEC_FindCrlByDERCert(CERTCertDBHandle *handle, SECItem *derCrl, + int type); + +PRBool SEC_CertNicknameConflict(const char *nickname, const SECItem *derSubject, + CERTCertDBHandle *handle); +CERTSignedCrl *SEC_NewCrl(CERTCertDBHandle *handle, char *url, SECItem *derCrl, + int type); + +SECStatus SEC_DeletePermCRL(CERTSignedCrl *crl); + +SECStatus SEC_LookupCrls(CERTCertDBHandle *handle, CERTCrlHeadNode **nodes, + int type); + +SECStatus SEC_DestroyCrl(CERTSignedCrl *crl); + +CERTSignedCrl *SEC_DupCrl(CERTSignedCrl *acrl); + +SECStatus CERT_AddTempCertToPerm(CERTCertificate *cert, char *nickname, + CERTCertTrust *trust); + +SECStatus SEC_DeletePermCertificate(CERTCertificate *cert); + +PRBool SEC_CrlIsNewer(CERTCrl *inNew, CERTCrl *old); + +/* +** Extract the validity times from a CRL +** "crl" is the CRL +** "notBefore" is the start of the validity period (last update) +** "notAfter" is the end of the validity period (next update) +*/ +SECStatus SEC_GetCrlTimes(CERTCrl *crl, PRTime *notBefore, PRTime *notAfter); + +/* +** Check the validity times of a crl vs. time 't', allowing +** some slop for broken clocks and stuff. +** "crl" is the certificate to be checked +** "t" is the time to check against +*/ +SECCertTimeValidity SEC_CheckCrlTimes(CERTCrl *crl, PRTime t); + +SEC_END_PROTOS + +#endif /* _CERTDB_H_ */ diff --git a/illumos-x86_64/usr/include/mps/certt.h b/illumos-x86_64/usr/include/mps/certt.h new file mode 100644 index 00000000..b74de0e6 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/certt.h @@ -0,0 +1,1359 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* + * certt.h - public data structures for the certificate library + */ +#ifndef _CERTT_H_ +#define _CERTT_H_ + +#include "prclist.h" +#include "pkcs11t.h" +#include "seccomon.h" +#include "secmodt.h" +#include "secoidt.h" +#include "plarena.h" +#include "prcvar.h" +#include "nssilock.h" +#include "prio.h" +#include "prmon.h" + +/* Stan data types */ +struct NSSCertificateStr; +struct NSSTrustDomainStr; + +/* Non-opaque objects */ +typedef struct CERTAVAStr CERTAVA; +typedef struct CERTAttributeStr CERTAttribute; +typedef struct CERTAuthInfoAccessStr CERTAuthInfoAccess; +typedef struct CERTAuthKeyIDStr CERTAuthKeyID; +typedef struct CERTBasicConstraintsStr CERTBasicConstraints; +typedef struct NSSTrustDomainStr CERTCertDBHandle; +typedef struct CERTCertExtensionStr CERTCertExtension; +typedef struct CERTCertKeyStr CERTCertKey; +typedef struct CERTCertListStr CERTCertList; +typedef struct CERTCertListNodeStr CERTCertListNode; +typedef struct CERTCertNicknamesStr CERTCertNicknames; +typedef struct CERTCertTrustStr CERTCertTrust; +typedef struct CERTCertDistrustStr CERTCertDistrust; +typedef struct CERTCertificateStr CERTCertificate; +typedef struct CERTCertificateListStr CERTCertificateList; +typedef struct CERTCertificateRequestStr CERTCertificateRequest; +typedef struct CERTCrlStr CERTCrl; +typedef struct CERTCrlDistributionPointsStr CERTCrlDistributionPoints; +typedef struct CERTCrlEntryStr CERTCrlEntry; +typedef struct CERTCrlHeadNodeStr CERTCrlHeadNode; +typedef struct CERTCrlKeyStr CERTCrlKey; +typedef struct CERTCrlNodeStr CERTCrlNode; +typedef struct CERTDERCertsStr CERTDERCerts; +typedef struct CERTDistNamesStr CERTDistNames; +typedef struct CERTGeneralNameStr CERTGeneralName; +typedef struct CERTGeneralNameListStr CERTGeneralNameList; +typedef struct CERTIssuerAndSNStr CERTIssuerAndSN; +typedef struct CERTNameStr CERTName; +typedef struct CERTNameConstraintStr CERTNameConstraint; +typedef struct CERTNameConstraintsStr CERTNameConstraints; +typedef struct CERTOKDomainNameStr CERTOKDomainName; +typedef struct CERTPrivKeyUsagePeriodStr CERTPrivKeyUsagePeriod; +typedef struct CERTPublicKeyAndChallengeStr CERTPublicKeyAndChallenge; +typedef struct CERTRDNStr CERTRDN; +typedef struct CERTSignedCrlStr CERTSignedCrl; +typedef struct CERTSignedDataStr CERTSignedData; +typedef struct CERTStatusConfigStr CERTStatusConfig; +typedef struct CERTSubjectListStr CERTSubjectList; +typedef struct CERTSubjectNodeStr CERTSubjectNode; +typedef struct CERTSubjectPublicKeyInfoStr CERTSubjectPublicKeyInfo; +typedef struct CERTValidityStr CERTValidity; +typedef struct CERTVerifyLogStr CERTVerifyLog; +typedef struct CERTVerifyLogNodeStr CERTVerifyLogNode; +typedef struct CRLDistributionPointStr CRLDistributionPoint; + +/* CRL extensions type */ +typedef unsigned long CERTCrlNumber; + +/* +** An X.500 AVA object +*/ +struct CERTAVAStr { + SECItem type; + SECItem value; +}; + +/* +** An X.500 RDN object +*/ +struct CERTRDNStr { + CERTAVA **avas; +}; + +/* +** An X.500 name object +*/ +struct CERTNameStr { + PLArenaPool *arena; + CERTRDN **rdns; +}; + +/* +** An X.509 validity object +*/ +struct CERTValidityStr { + PLArenaPool *arena; + SECItem notBefore; + SECItem notAfter; +}; + +/* + * A serial number and issuer name, which is used as a database key + */ +struct CERTCertKeyStr { + SECItem serialNumber; + SECItem derIssuer; +}; + +/* +** A signed data object. Used to implement the "signed" macro used +** in the X.500 specs. +*/ +struct CERTSignedDataStr { + SECItem data; + SECAlgorithmID signatureAlgorithm; + SECItem signature; +}; + +/* +** An X.509 subject-public-key-info object +*/ +struct CERTSubjectPublicKeyInfoStr { + PLArenaPool *arena; + SECAlgorithmID algorithm; + SECItem subjectPublicKey; +}; + +struct CERTPublicKeyAndChallengeStr { + SECItem spki; + SECItem challenge; +}; + +struct CERTCertTrustStr { + unsigned int sslFlags; + unsigned int emailFlags; + unsigned int objectSigningFlags; +}; + +/* + * Distrust dates for specific certificate usages. + * These dates are hardcoded in nssckbi/builtins. They are DER encoded to be + * compatible with the format of certdata.txt, other date fields in certs and + * existing functions to read these dates. Clients should check the distrust + * date in certificates to avoid trusting a CA for service they have ceased to + * support */ +struct CERTCertDistrustStr { + SECItem serverDistrustAfter; + SECItem emailDistrustAfter; +}; + +/* + * defined the types of trust that exist + */ +typedef enum SECTrustTypeEnum { + trustSSL = 0, + trustEmail = 1, + trustObjectSigning = 2, + trustTypeNone = 3 +} SECTrustType; + +#define SEC_GET_TRUST_FLAGS(trust, type) \ + (((type) == trustSSL) \ + ? ((trust)->sslFlags) \ + : (((type) == trustEmail) ? ((trust)->emailFlags) \ + : (((type) == trustObjectSigning) \ + ? ((trust)->objectSigningFlags) \ + : 0))) + +/* +** An X.509.3 certificate extension +*/ +struct CERTCertExtensionStr { + SECItem id; + SECItem critical; + SECItem value; +}; + +struct CERTSubjectNodeStr { + struct CERTSubjectNodeStr *next; + struct CERTSubjectNodeStr *prev; + SECItem certKey; + SECItem keyID; +}; + +struct CERTSubjectListStr { + PLArenaPool *arena; + int ncerts; + char *emailAddr; + CERTSubjectNode *head; + CERTSubjectNode *tail; /* do we need tail? */ + void *entry; +}; + +/* +** An X.509 certificate object (the unsigned form) +*/ +struct CERTCertificateStr { + /* the arena is used to allocate any data structures that have the same + * lifetime as the cert. This is all stuff that hangs off of the cert + * structure, and is all freed at the same time. It is used when the + * cert is decoded, destroyed, and at some times when it changes + * state + */ + PLArenaPool *arena; + + /* The following fields are static after the cert has been decoded */ + char *subjectName; + char *issuerName; + CERTSignedData signatureWrap; /* XXX */ + SECItem derCert; /* original DER for the cert */ + SECItem derIssuer; /* DER for issuer name */ + SECItem derSubject; /* DER for subject name */ + SECItem derPublicKey; /* DER for the public key */ + SECItem certKey; /* database key for this cert */ + SECItem version; + SECItem serialNumber; + SECAlgorithmID signature; + CERTName issuer; + CERTValidity validity; + CERTName subject; + CERTSubjectPublicKeyInfo subjectPublicKeyInfo; + SECItem issuerID; + SECItem subjectID; + CERTCertExtension **extensions; + char *emailAddr; + CERTCertDBHandle *dbhandle; + SECItem subjectKeyID; /* x509v3 subject key identifier */ + PRBool keyIDGenerated; /* was the keyid generated? */ + unsigned int keyUsage; /* what uses are allowed for this cert */ + unsigned int rawKeyUsage; /* value of the key usage extension */ + PRBool keyUsagePresent; /* was the key usage extension present */ + PRUint32 nsCertType; /* value of the ns cert type extension */ + /* must be 32-bit for PR_ATOMIC_SET */ + + /* these values can be set by the application to bypass certain checks + * or to keep the cert in memory for an entire session. + * XXX - need an api to set these + */ + PRBool keepSession; /* keep this cert for entire session*/ + PRBool timeOK; /* is the bad validity time ok? */ + CERTOKDomainName *domainOK; /* these domain names are ok */ + + /* + * these values can change when the cert changes state. These state + * changes include transitions from temp to perm or vice-versa, and + * changes of trust flags + */ + PRBool isperm; + PRBool istemp; + char *nickname; + char *dbnickname; + struct NSSCertificateStr *nssCertificate; /* This is Stan stuff. */ + CERTCertTrust *trust; + + /* the reference count is modified whenever someone looks up, dups + * or destroys a certificate + */ + int referenceCount; + + /* The subject list is a list of all certs with the same subject name. + * It can be modified any time a cert is added or deleted from either + * the in-memory(temporary) or on-disk(permanent) database. + */ + CERTSubjectList *subjectList; + + /* these belong in the static section, but are here to maintain + * the structure's integrity + */ + CERTAuthKeyID *authKeyID; /* x509v3 authority key identifier */ + PRBool isRoot; /* cert is the end of a chain */ + + /* these fields are used by client GUI code to keep track of ssl sockets + * that are blocked waiting on GUI feedback related to this cert. + * XXX - these should be moved into some sort of application specific + * data structure. They are only used by the browser right now. + */ + union { + void *apointer; /* was struct SECSocketNode* authsocketlist */ + struct { + unsigned int hasUnsupportedCriticalExt : 1; + /* add any new option bits needed here */ + } bits; + } options; + int series; /* was int authsocketcount; record the series of the pkcs11ID */ + + /* This is PKCS #11 stuff. */ + PK11SlotInfo *slot; /*if this cert came of a token, which is it*/ + CK_OBJECT_HANDLE pkcs11ID; /*and which object on that token is it */ + PRBool ownSlot; /*true if the cert owns the slot reference */ + /* These fields are used in nssckbi/builtins CAs. */ + CERTCertDistrust *distrust; +}; +#define SEC_CERTIFICATE_VERSION_1 0 /* default created */ +#define SEC_CERTIFICATE_VERSION_2 1 /* v2 */ +#define SEC_CERTIFICATE_VERSION_3 2 /* v3 extensions */ + +#define SEC_CRL_VERSION_1 0 /* default */ +#define SEC_CRL_VERSION_2 1 /* v2 extensions */ + +/* + * used to identify class of cert in mime stream code + */ +#define SEC_CERT_CLASS_CA 1 +#define SEC_CERT_CLASS_SERVER 2 +#define SEC_CERT_CLASS_USER 3 +#define SEC_CERT_CLASS_EMAIL 4 + +struct CERTDERCertsStr { + PLArenaPool *arena; + int numcerts; + SECItem *rawCerts; +}; + +/* +** A PKCS ? Attribute +** XXX this is duplicated through out the code, it *should* be moved +** to a central location. Where would be appropriate? +*/ +struct CERTAttributeStr { + SECItem attrType; + SECItem **attrValue; +}; + +/* +** A PKCS#10 certificate-request object (the unsigned form) +*/ +struct CERTCertificateRequestStr { + PLArenaPool *arena; + SECItem version; + CERTName subject; + CERTSubjectPublicKeyInfo subjectPublicKeyInfo; + CERTAttribute **attributes; +}; +#define SEC_CERTIFICATE_REQUEST_VERSION 0 /* what we *create* */ + +/* +** A certificate list object. +*/ +struct CERTCertificateListStr { + SECItem *certs; + int len; /* number of certs */ + PLArenaPool *arena; +}; + +struct CERTCertListNodeStr { + PRCList links; + CERTCertificate *cert; + void *appData; +}; + +struct CERTCertListStr { + PRCList list; + PLArenaPool *arena; +}; + +#define CERT_LIST_HEAD(l) ((CERTCertListNode *)PR_LIST_HEAD(&l->list)) +#define CERT_LIST_TAIL(l) ((CERTCertListNode *)PR_LIST_TAIL(&l->list)) +#define CERT_LIST_NEXT(n) ((CERTCertListNode *)n->links.next) +#define CERT_LIST_END(n, l) (((void *)n) == ((void *)&l->list)) +#define CERT_LIST_EMPTY(l) CERT_LIST_END(CERT_LIST_HEAD(l), l) + +struct CERTCrlEntryStr { + SECItem serialNumber; + SECItem revocationDate; + CERTCertExtension **extensions; +}; + +struct CERTCrlStr { + PLArenaPool *arena; + SECItem version; + SECAlgorithmID signatureAlg; + SECItem derName; + CERTName name; + SECItem lastUpdate; + SECItem nextUpdate; /* optional for x.509 CRL */ + CERTCrlEntry **entries; + CERTCertExtension **extensions; + /* can't add anything there for binary backwards compatibility reasons */ +}; + +struct CERTCrlKeyStr { + SECItem derName; + SECItem dummy; /* The decoder can not skip a primitive, + this serves as a place holder for the + decoder to finish its task only + */ +}; + +struct CERTSignedCrlStr { + PLArenaPool *arena; + CERTCrl crl; + void *reserved1; + PRBool reserved2; + PRBool isperm; + PRBool istemp; + int referenceCount; + CERTCertDBHandle *dbhandle; + CERTSignedData signatureWrap; /* XXX */ + char *url; + SECItem *derCrl; + PK11SlotInfo *slot; + CK_OBJECT_HANDLE pkcs11ID; + void *opaque; /* do not touch */ +}; + +struct CERTCrlHeadNodeStr { + PLArenaPool *arena; + CERTCertDBHandle *dbhandle; + CERTCrlNode *first; + CERTCrlNode *last; +}; + +struct CERTCrlNodeStr { + CERTCrlNode *next; + int type; + CERTSignedCrl *crl; +}; + +/* + * Array of X.500 Distinguished Names + */ +struct CERTDistNamesStr { + PLArenaPool *arena; + int nnames; + SECItem *names; + void *head; /* private */ +}; + +/* + * NS_CERT_TYPE defines are used in two areas: + * 1) The old NSS Cert Type Extension, which is a certificate extension in the + * actual cert. It was created before the x509 Extended Key Usage Extension, + * which has now taken over it's function. This field is only 8 bits wide + * 2) The nsCertType entry in the CERTCertificate structure. This field is + * 32 bits wide. + * Any entries in this table greater than 0x80 will not be able to be encoded + * in an NSS Cert Type Extension, but can still be represented internally in + * the nsCertType field. + */ +#define NS_CERT_TYPE_IPSEC_CA (0x200) /* outside the NS Cert Type Extenstion */ +#define NS_CERT_TYPE_IPSEC (0x100) /* outside the NS Cert Type Extenstion */ +#define NS_CERT_TYPE_SSL_CLIENT (0x80) /* bit 0 */ +#define NS_CERT_TYPE_SSL_SERVER (0x40) /* bit 1 */ +#define NS_CERT_TYPE_EMAIL (0x20) /* bit 2 */ +#define NS_CERT_TYPE_OBJECT_SIGNING (0x10) /* bit 3 */ +#define NS_CERT_TYPE_RESERVED (0x08) /* bit 4 */ +#define NS_CERT_TYPE_SSL_CA (0x04) /* bit 5 */ +#define NS_CERT_TYPE_EMAIL_CA (0x02) /* bit 6 */ +#define NS_CERT_TYPE_OBJECT_SIGNING_CA (0x01) /* bit 7 */ + +#define EXT_KEY_USAGE_TIME_STAMP (0x8000) +#define EXT_KEY_USAGE_STATUS_RESPONDER (0x4000) + +#define NS_CERT_TYPE_APP \ + (NS_CERT_TYPE_SSL_CLIENT | NS_CERT_TYPE_SSL_SERVER | NS_CERT_TYPE_EMAIL | \ + NS_CERT_TYPE_IPSEC | NS_CERT_TYPE_OBJECT_SIGNING) + +#define NS_CERT_TYPE_CA \ + (NS_CERT_TYPE_SSL_CA | NS_CERT_TYPE_EMAIL_CA | \ + NS_CERT_TYPE_OBJECT_SIGNING_CA | EXT_KEY_USAGE_STATUS_RESPONDER | \ + NS_CERT_TYPE_IPSEC_CA) +typedef enum SECCertUsageEnum { + certUsageSSLClient = 0, + certUsageSSLServer = 1, + certUsageSSLServerWithStepUp = 2, + certUsageSSLCA = 3, + certUsageEmailSigner = 4, + certUsageEmailRecipient = 5, + certUsageObjectSigner = 6, + certUsageUserCertImport = 7, + certUsageVerifyCA = 8, + certUsageProtectedObjectSigner = 9, + certUsageStatusResponder = 10, + certUsageAnyCA = 11, + certUsageIPsec = 12 +} SECCertUsage; + +typedef PRInt64 SECCertificateUsage; + +#define certificateUsageCheckAllUsages (0x0000) +#define certificateUsageSSLClient (0x0001) +#define certificateUsageSSLServer (0x0002) +#define certificateUsageSSLServerWithStepUp (0x0004) +#define certificateUsageSSLCA (0x0008) +#define certificateUsageEmailSigner (0x0010) +#define certificateUsageEmailRecipient (0x0020) +#define certificateUsageObjectSigner (0x0040) +#define certificateUsageUserCertImport (0x0080) +#define certificateUsageVerifyCA (0x0100) +#define certificateUsageProtectedObjectSigner (0x0200) +#define certificateUsageStatusResponder (0x0400) +#define certificateUsageAnyCA (0x0800) +#define certificateUsageIPsec (0x1000) + +#define certificateUsageHighest certificateUsageIPsec + +/* + * Does the cert belong to the user, a peer, or a CA. + */ +typedef enum CERTCertOwnerEnum { + certOwnerUser = 0, + certOwnerPeer = 1, + certOwnerCA = 2 +} CERTCertOwner; + +/* + * This enum represents the state of validity times of a certificate + */ +typedef enum SECCertTimeValidityEnum { + secCertTimeValid = 0, + secCertTimeExpired = 1, + secCertTimeNotValidYet = 2, + secCertTimeUndetermined = 3 /* validity could not be decoded from the + cert, most likely because it was NULL */ +} SECCertTimeValidity; + +/* + * This is used as return status in functions that compare the validity + * periods of two certificates A and B, currently only + * CERT_CompareValidityTimes. + */ + +typedef enum CERTCompareValidityStatusEnum { + certValidityUndetermined = 0, /* the function is unable to select one cert + over another */ + certValidityChooseB = 1, /* cert B should be preferred */ + certValidityEqual = 2, /* both certs have the same validity period */ + certValidityChooseA = 3 /* cert A should be preferred */ +} CERTCompareValidityStatus; + +/* + * Interface for getting certificate nickname strings out of the database + */ + +/* these are values for the what argument below */ +#define SEC_CERT_NICKNAMES_ALL 1 +#define SEC_CERT_NICKNAMES_USER 2 +#define SEC_CERT_NICKNAMES_SERVER 3 +#define SEC_CERT_NICKNAMES_CA 4 + +struct CERTCertNicknamesStr { + PLArenaPool *arena; + void *head; + int numnicknames; + char **nicknames; + int what; + int totallen; +}; + +struct CERTIssuerAndSNStr { + SECItem derIssuer; + CERTName issuer; + SECItem serialNumber; +}; + +/* X.509 v3 Key Usage Extension flags */ +#define KU_DIGITAL_SIGNATURE (0x80) /* bit 0 */ +#define KU_NON_REPUDIATION (0x40) /* bit 1 */ +#define KU_KEY_ENCIPHERMENT (0x20) /* bit 2 */ +#define KU_DATA_ENCIPHERMENT (0x10) /* bit 3 */ +#define KU_KEY_AGREEMENT (0x08) /* bit 4 */ +#define KU_KEY_CERT_SIGN (0x04) /* bit 5 */ +#define KU_CRL_SIGN (0x02) /* bit 6 */ +#define KU_ENCIPHER_ONLY (0x01) /* bit 7 */ +#define KU_ALL \ + (KU_DIGITAL_SIGNATURE | KU_NON_REPUDIATION | KU_KEY_ENCIPHERMENT | \ + KU_DATA_ENCIPHERMENT | KU_KEY_AGREEMENT | KU_KEY_CERT_SIGN | \ + KU_CRL_SIGN | KU_ENCIPHER_ONLY) + +/* This value will not occur in certs. It is used internally for the case + * when either digital signature or non-repudiation is the correct value. + */ +#define KU_DIGITAL_SIGNATURE_OR_NON_REPUDIATION (0x2000) + +/* This value will not occur in certs. It is used internally for the case + * when the key type is not know ahead of time and either key agreement or + * key encipherment are the correct value based on key type + */ +#define KU_KEY_AGREEMENT_OR_ENCIPHERMENT (0x4000) + +/* internal bits that do not match bits in the x509v3 spec, but are used + * for similar purposes + */ +#define KU_NS_GOVT_APPROVED (0x8000) /*don't make part of KU_ALL!*/ +/* + * x.509 v3 Basic Constraints Extension + * If isCA is false, the pathLenConstraint is ignored. + * Otherwise, the following pathLenConstraint values will apply: + * < 0 - there is no limit to the certificate path + * 0 - CA can issues end-entity certificates only + * > 0 - the number of certificates in the certificate path is + * limited to this number + */ +#define CERT_UNLIMITED_PATH_CONSTRAINT -2 + +struct CERTBasicConstraintsStr { + PRBool isCA; /* on if is CA */ + int pathLenConstraint; /* maximum number of certificates that can be + in the cert path. Only applies to a CA + certificate; otherwise, it's ignored. + */ +}; + +/* Maximum length of a certificate chain */ +#define CERT_MAX_CERT_CHAIN 20 + +#define CERT_MAX_SERIAL_NUMBER_BYTES 20 /* from RFC 3280 */ +#define CERT_MAX_DN_BYTES 4096 /* arbitrary */ + +/* x.509 v3 Reason Flags, used in CRLDistributionPoint Extension */ +#define RF_UNUSED (0x80) /* bit 0 */ +#define RF_KEY_COMPROMISE (0x40) /* bit 1 */ +#define RF_CA_COMPROMISE (0x20) /* bit 2 */ +#define RF_AFFILIATION_CHANGED (0x10) /* bit 3 */ +#define RF_SUPERSEDED (0x08) /* bit 4 */ +#define RF_CESSATION_OF_OPERATION (0x04) /* bit 5 */ +#define RF_CERTIFICATE_HOLD (0x02) /* bit 6 */ + +/* enum for CRL Entry Reason Code */ +typedef enum CERTCRLEntryReasonCodeEnum { + crlEntryReasonUnspecified = 0, + crlEntryReasonKeyCompromise = 1, + crlEntryReasonCaCompromise = 2, + crlEntryReasonAffiliationChanged = 3, + crlEntryReasonSuperseded = 4, + crlEntryReasonCessationOfOperation = 5, + crlEntryReasoncertificatedHold = 6, + crlEntryReasonRemoveFromCRL = 8, + crlEntryReasonPrivilegeWithdrawn = 9, + crlEntryReasonAaCompromise = 10 +} CERTCRLEntryReasonCode; + +/* If we needed to extract the general name field, use this */ +/* General Name types */ +typedef enum CERTGeneralNameTypeEnum { + certOtherName = 1, + certRFC822Name = 2, + certDNSName = 3, + certX400Address = 4, + certDirectoryName = 5, + certEDIPartyName = 6, + certURI = 7, + certIPAddress = 8, + certRegisterID = 9 +} CERTGeneralNameType; + +typedef struct OtherNameStr { + SECItem name; + SECItem oid; +} OtherName; + +struct CERTGeneralNameStr { + CERTGeneralNameType type; /* name type */ + union { + CERTName directoryName; /* distinguish name */ + OtherName OthName; /* Other Name */ + SECItem other; /* the rest of the name forms */ + } name; + SECItem derDirectoryName; /* this is saved to simplify directory name + comparison */ + PRCList l; +}; + +struct CERTGeneralNameListStr { + PLArenaPool *arena; + CERTGeneralName *name; + int refCount; + int len; + PZLock *lock; +}; + +struct CERTNameConstraintStr { + CERTGeneralName name; + SECItem DERName; + SECItem min; + SECItem max; + PRCList l; +}; + +struct CERTNameConstraintsStr { + CERTNameConstraint *permited; + CERTNameConstraint *excluded; + SECItem **DERPermited; + SECItem **DERExcluded; +}; + +/* Private Key Usage Period extension struct. */ +struct CERTPrivKeyUsagePeriodStr { + SECItem notBefore; + SECItem notAfter; + PLArenaPool *arena; +}; + +/* X.509 v3 Authority Key Identifier extension. For the authority certificate + issuer field, we only support URI now. + */ +struct CERTAuthKeyIDStr { + SECItem keyID; /* unique key identifier */ + CERTGeneralName *authCertIssuer; /* CA's issuer name. End with a NULL */ + SECItem authCertSerialNumber; /* CA's certificate serial number */ + SECItem **DERAuthCertIssuer; /* This holds the DER encoded format of + the authCertIssuer field. It is used + by the encoding engine. It should be + used as a read only field by the caller. + */ +}; + +/* x.509 v3 CRL Distributeion Point */ + +/* + * defined the types of CRL Distribution points + */ +typedef enum DistributionPointTypesEnum { + generalName = 1, /* only support this for now */ + relativeDistinguishedName = 2 +} DistributionPointTypes; + +struct CRLDistributionPointStr { + DistributionPointTypes distPointType; + union { + CERTGeneralName *fullName; + CERTRDN relativeName; + } distPoint; + SECItem reasons; + CERTGeneralName *crlIssuer; + + /* Reserved for internal use only*/ + SECItem derDistPoint; + SECItem derRelativeName; + SECItem **derCrlIssuer; + SECItem **derFullName; + SECItem bitsmap; +}; + +struct CERTCrlDistributionPointsStr { + CRLDistributionPoint **distPoints; +}; + +/* + * This structure is used to keep a log of errors when verifying + * a cert chain. This allows multiple errors to be reported all at + * once. + */ +struct CERTVerifyLogNodeStr { + CERTCertificate *cert; /* what cert had the error */ + long error; /* what error was it? */ + unsigned int depth; /* how far up the chain are we */ + void *arg; /* error specific argument */ + struct CERTVerifyLogNodeStr *next; /* next in the list */ + struct CERTVerifyLogNodeStr *prev; /* next in the list */ +}; + +struct CERTVerifyLogStr { + PLArenaPool *arena; + unsigned int count; + struct CERTVerifyLogNodeStr *head; + struct CERTVerifyLogNodeStr *tail; +}; + +struct CERTOKDomainNameStr { + CERTOKDomainName *next; + char *name; +}; + +typedef SECStatus(PR_CALLBACK *CERTStatusChecker)(CERTCertDBHandle *handle, + CERTCertificate *cert, + PRTime time, void *pwArg); + +typedef SECStatus(PR_CALLBACK *CERTStatusDestroy)(CERTStatusConfig *handle); + +struct CERTStatusConfigStr { + CERTStatusChecker statusChecker; /* NULL means no checking enabled */ + CERTStatusDestroy statusDestroy; /* enabled or no, will clean up */ + void *statusContext; /* cx specific to checking protocol */ +}; + +struct CERTAuthInfoAccessStr { + SECItem method; + SECItem derLocation; + CERTGeneralName *location; /* decoded location */ +}; + +/* This is the typedef for the callback passed to CERT_OpenCertDB() */ +/* callback to return database name based on version number */ +typedef char *(*CERTDBNameFunc)(void *arg, int dbVersion); + +/* + * types of cert packages that we can decode + */ +typedef enum CERTPackageTypeEnum { + certPackageNone = 0, + certPackageCert = 1, + certPackagePKCS7 = 2, + certPackageNSCertSeq = 3, + certPackageNSCertWrap = 4 +} CERTPackageType; + +/* + * these types are for the PKIX Certificate Policies extension + */ +typedef struct { + SECOidTag oid; + SECItem qualifierID; + SECItem qualifierValue; +} CERTPolicyQualifier; + +typedef struct { + SECOidTag oid; + SECItem policyID; + CERTPolicyQualifier **policyQualifiers; +} CERTPolicyInfo; + +typedef struct { + PLArenaPool *arena; + CERTPolicyInfo **policyInfos; +} CERTCertificatePolicies; + +typedef struct { + SECItem organization; + SECItem **noticeNumbers; +} CERTNoticeReference; + +typedef struct { + PLArenaPool *arena; + CERTNoticeReference noticeReference; + SECItem derNoticeReference; + SECItem displayText; +} CERTUserNotice; + +typedef struct { + PLArenaPool *arena; + SECItem **oids; +} CERTOidSequence; + +/* + * these types are for the PKIX Policy Mappings extension + */ +typedef struct { + SECItem issuerDomainPolicy; + SECItem subjectDomainPolicy; +} CERTPolicyMap; + +typedef struct { + PLArenaPool *arena; + CERTPolicyMap **policyMaps; +} CERTCertificatePolicyMappings; + +/* + * these types are for the PKIX inhibitAnyPolicy extension + */ +typedef struct { + SECItem inhibitAnySkipCerts; +} CERTCertificateInhibitAny; + +/* + * these types are for the PKIX Policy Constraints extension + */ +typedef struct { + SECItem explicitPolicySkipCerts; + SECItem inhibitMappingSkipCerts; +} CERTCertificatePolicyConstraints; + +/* + * These types are for the validate chain callback param. + * + * CERTChainVerifyCallback is an application-supplied callback that can be used + * to augment libpkix's certificate chain validation with additional + * application-specific checks. It may be called multiple times if there are + * multiple potentially-valid paths for the certificate being validated. This + * callback is called before revocation checking is done on the certificates in + * the given chain. + * + * - isValidChainArg contains the application-provided opaque argument + * - currentChain is the currently validated chain. It is ordered with the leaf + * certificate at the head and the trust anchor at the tail. + * + * The callback should set *chainOK = PR_TRUE and return SECSuccess if the + * certificate chain is acceptable. It should set *chainOK = PR_FALSE and + * return SECSuccess if the chain is unacceptable, to indicate that the given + * chain is bad and path building should continue. It should return SECFailure + * to indicate an fatal error that will cause path validation to fail + * immediately. + */ +typedef SECStatus (*CERTChainVerifyCallbackFunc)( + void *isChainValidArg, const CERTCertList *currentChain, PRBool *chainOK); + +/* + * Note: If extending this structure, it will be necessary to change the + * associated CERTValParamInType + */ +typedef struct { + CERTChainVerifyCallbackFunc isChainValid; + void *isChainValidArg; +} CERTChainVerifyCallback; + +/* + * these types are for the CERT_PKIX* Verification functions + * These are all optional parameters. + */ + +typedef enum { + cert_pi_end = 0, /* SPECIAL: signifies end of array of + * CERTValParam* */ + cert_pi_nbioContext = 1, /* specify a non-blocking IO context used to + * resume a session. If this argument is + * specified, no other arguments should be. + * Specified in value.pointer.p. If the + * operation completes the context will be + * freed. */ + cert_pi_nbioAbort = 2, /* specify a non-blocking IO context for an + * existing operation which the caller wants + * to abort. If this argument is + * specified, no other arguments should be. + * Specified in value.pointer.p. If the + * operation succeeds the context will be + * freed. */ + cert_pi_certList = 3, /* specify the chain to validate against. If + * this value is given, then the path + * construction step in the validation is + * skipped. Specified in value.pointer.chain */ + cert_pi_policyOID = 4, /* validate certificate for policy OID. + * Specified in value.array.oids. Cert must + * be good for at least one OID in order + * to validate. Default is that the user is not + * concerned about certificate policy. */ + cert_pi_policyFlags = 5, /* flags for each policy specified in policyOID. + * Specified in value.scalar.ul. Policy flags + * apply to all specified oids. + * Use CERT_POLICY_FLAG_* macros below. If not + * specified policy flags default to 0 */ + cert_pi_keyusage = 6, /* specify what the keyusages the certificate + * will be evaluated against, specified in + * value.scalar.ui. The cert must validate for + * at least one of the specified key usages. + * Values match the KU_ bit flags defined + * in this file. Default is derived from + * the 'usages' function argument */ + cert_pi_extendedKeyusage = 7, /* specify what the required extended key + * usage of the certificate. Specified as + * an array of oidTags in value.array.oids. + * The cert must validate for at least one + * of the specified extended key usages. + * If not specified, no extended key usages + * will be checked. */ + cert_pi_date = 8, /* validate certificate is valid as of date + * specified in value.scalar.time. A special + * value '0' indicates 'now'. default is '0' */ + cert_pi_revocationFlags = 9, /* Specify what revocation checking to do. + * See CERT_REV_FLAG_* macros below + * Set in value.pointer.revocation */ + cert_pi_certStores = 10, /* Bitmask of Cert Store flags (see below) + * Set in value.scalar.ui */ + cert_pi_trustAnchors = + 11, /* Specify the list of trusted roots to + * validate against. + * The default set of trusted roots, these are + * root CA certs from libnssckbi.so or CA + * certs trusted by user, are used in any of + * the following cases: + * * when the parameter is not set. + * * when the list of trust anchors is + * empty. + * Note that this handling can be further + * altered by altering the + * cert_pi_useOnlyTrustAnchors flag + * Specified in value.pointer.chain */ + cert_pi_useAIACertFetch = 12, /* Enables cert fetching using AIA extension. + * In NSS 3.12.1 or later. Default is off. + * Value is in value.scalar.b */ + cert_pi_chainVerifyCallback = 13, + /* The callback container for doing extra + * validation on the currently calculated chain. + * Value is in value.pointer.chainVerifyCallback */ + cert_pi_useOnlyTrustAnchors = 14, + /* If true, disables trusting any + * certificates other than the ones passed in via cert_pi_trustAnchors. + * If false, then the certificates specified via cert_pi_trustAnchors + * will be combined with the pre-existing trusted roots, but only + * for the certificate validation being performed. + * If no value has been supplied via cert_pi_trustAnchors, this has + * no effect. + * The default value is true, meaning if this is not supplied, only + * trust anchors supplied via cert_pi_trustAnchors are trusted. + * Specified in value.scalar.b */ + cert_pi_max /* SPECIAL: signifies maximum allowed value, + * can increase in future releases */ +} CERTValParamInType; + +/* + * for all out parameters: + * out parameters are only returned if the caller asks for them in + * the CERTValOutParam array. Caller is responsible for the CERTValOutParam + * array itself. The pkix verify function will allocate and other arrays + * pointers, or objects. The Caller is responsible for freeing those results. + * If SECWouldBlock is returned, only cert_pi_nbioContext is returned. + */ +typedef enum { + cert_po_end = 0, /* SPECIAL: signifies end of array of + * CERTValParam* */ + cert_po_nbioContext = 1, /* Return a nonblocking context. If no + * non-blocking context is specified, then + * blocking IO will be used. + * Returned in value.pointer.p. The context is + * freed after an abort or a complete operation. + * This value is only returned on SECWouldBlock. + */ + cert_po_trustAnchor = 2, /* Return the trust anchor for the chain that + * was validated. Returned in + * value.pointer.cert, this value is only + * returned on SECSuccess. */ + cert_po_certList = 3, /* Return the entire chain that was validated. + * Returned in value.pointer.certList. If no + * chain could be constructed, this value + * would be NULL. */ + cert_po_policyOID = 4, /* Return the policies that were found to be + * valid. Returned in value.array.oids as an + * array. This is only returned on + * SECSuccess. */ + cert_po_errorLog = 5, /* Return a log of problems with the chain. + * Returned in value.pointer.log */ + cert_po_usages = 6, /* Return what usages the certificate is valid + for. Returned in value.scalar.usages */ + cert_po_keyUsage = 7, /* Return what key usages the certificate + * is valid for. + * Returned in value.scalar.usage */ + cert_po_extendedKeyusage = 8, /* Return what extended key usages the + * certificate is valid for. + * Returned in value.array.oids */ + cert_po_max /* SPECIAL: signifies maximum allowed value, + * can increase in future releases */ + +} CERTValParamOutType; + +typedef enum { + cert_revocation_method_crl = 0, + cert_revocation_method_ocsp, + cert_revocation_method_count +} CERTRevocationMethodIndex; + +/* + * The following flags are supposed to be used to control bits in + * each integer contained in the array pointed to be: + * CERTRevocationTests.cert_rev_flags_per_method + * All Flags are prefixed by CERT_REV_M_, where _M_ indicates + * this is a method dependent flag. + */ + +/* + * Whether or not to use a method for revocation testing. + * If set to "do not test", then all other flags are ignored. + */ +#define CERT_REV_M_DO_NOT_TEST_USING_THIS_METHOD 0UL +#define CERT_REV_M_TEST_USING_THIS_METHOD 1UL + +/* + * Whether or not NSS is allowed to attempt to fetch fresh information + * from the network. + * (Although fetching will never happen if fresh information for the + * method is already locally available.) + */ +#define CERT_REV_M_ALLOW_NETWORK_FETCHING 0UL +#define CERT_REV_M_FORBID_NETWORK_FETCHING 2UL + +/* + * Example for an implicit default source: + * The globally configured default OCSP responder. + * IGNORE means: + * ignore the implicit default source, whether it's configured or not. + * ALLOW means: + * if an implicit default source is configured, + * then it overrides any available or missing source in the cert. + * if no implicit default source is configured, + * then we continue to use what's available (or not available) + * in the certs. + */ +#define CERT_REV_M_ALLOW_IMPLICIT_DEFAULT_SOURCE 0UL +#define CERT_REV_M_IGNORE_IMPLICIT_DEFAULT_SOURCE 4UL + +/* + * Defines the behavior if no fresh information is available, + * fetching from the network is allowed, but the source of revocation + * information is unknown (even after considering implicit sources, + * if allowed by other flags). + * SKIPT_TEST means: + * We ignore that no fresh information is available and + * skip this test. + * REQUIRE_INFO means: + * We still require that fresh information is available. + * Other flags define what happens on missing fresh info. + */ +#define CERT_REV_M_SKIP_TEST_ON_MISSING_SOURCE 0UL +#define CERT_REV_M_REQUIRE_INFO_ON_MISSING_SOURCE 8UL + +/* + * Defines the behavior if we are unable to obtain fresh information. + * INGORE means: + * Return "cert status unknown" + * FAIL means: + * Return "cert revoked". + */ +#define CERT_REV_M_IGNORE_MISSING_FRESH_INFO 0UL +#define CERT_REV_M_FAIL_ON_MISSING_FRESH_INFO 16UL + +/* + * What should happen if we were able to find fresh information using + * this method, and the data indicated the cert is good? + * STOP_TESTING means: + * Our success is sufficient, do not continue testing + * other methods. + * CONTINUE_TESTING means: + * We will continue and test the next allowed + * specified method. + */ +#define CERT_REV_M_STOP_TESTING_ON_FRESH_INFO 0UL +#define CERT_REV_M_CONTINUE_TESTING_ON_FRESH_INFO 32UL + +/* When this flag is used, libpkix will never attempt to use the GET HTTP + * method for OCSP requests; it will always use POST. + */ +#define CERT_REV_M_FORCE_POST_METHOD_FOR_OCSP 64UL + +/* + * The following flags are supposed to be used to control bits in + * CERTRevocationTests.cert_rev_method_independent_flags + * All Flags are prefixed by CERT_REV_M_, where _M_ indicates + * this is a method independent flag. + */ + +/* + * This defines the order to checking. + * EACH_METHOD_SEPARATELY means: + * Do all tests related to a particular allowed method + * (both local information and network fetching) in a single step. + * Only after testing for a particular method is done, + * then switching to the next method will happen. + * ALL_LOCAL_INFORMATION_FIRST means: + * Start by testing the information for all allowed methods + * which are already locally available. Only after that is done + * consider to fetch from the network (as allowed by other flags). + */ +#define CERT_REV_MI_TEST_EACH_METHOD_SEPARATELY 0UL +#define CERT_REV_MI_TEST_ALL_LOCAL_INFORMATION_FIRST 1UL + +/* + * Use this flag to specify that it's necessary that fresh information + * is available for at least one of the allowed methods, but it's + * irrelevant which of the mechanisms succeeded. + * NO_OVERALL_INFO_REQUIREMENT means: + * We strictly follow the requirements for each individual method. + * REQUIRE_SOME_FRESH_INFO_AVAILABLE means: + * After the individual tests have been executed, we must have + * been able to find fresh information using at least one method. + * If we were unable to find fresh info, it's a failure. + * This setting overrides the CERT_REV_M_FAIL_ON_MISSING_FRESH_INFO + * flag on all methods. + */ +#define CERT_REV_MI_NO_OVERALL_INFO_REQUIREMENT 0UL +#define CERT_REV_MI_REQUIRE_SOME_FRESH_INFO_AVAILABLE 2UL + +typedef struct { + /* + * The size of the array that cert_rev_flags_per_method points to, + * meaning, the number of methods that are known and defined + * by the caller. + */ + PRUint32 number_of_defined_methods; + + /* + * A pointer to an array of integers. + * Each integer defines revocation checking for a single method, + * by having individual CERT_REV_M_* bits set or not set. + * The meaning of index numbers into this array are defined by + * enum CERTRevocationMethodIndex + * The size of the array must be specified by the caller in the separate + * variable number_of_defined_methods. + * The size of the array may be smaller than + * cert_revocation_method_count, it can happen if a caller + * is not yet aware of the latest revocation methods + * (or does not want to use them). + */ + PRUint64 *cert_rev_flags_per_method; + + /* + * How many preferred methods are specified? + * This is equivalent to the size of the array that + * preferred_methods points to. + * It's allowed to set this value to zero, + * then NSS will decide which methods to prefer. + */ + PRUint32 number_of_preferred_methods; + + /* Array that may specify an optional order of preferred methods. + * Each array entry shall contain a method identifier as defined + * by CERTRevocationMethodIndex. + * The entry at index [0] specifies the method with highest preference. + * These methods will be tested first for locally available information. + * Methods allowed for downloading will be attempted in the same order. + */ + CERTRevocationMethodIndex *preferred_methods; + + /* + * An integer which defines certain aspects of revocation checking + * (independent of individual methods) by having individual + * CERT_REV_MI_* bits set or not set. + */ + PRUint64 cert_rev_method_independent_flags; +} CERTRevocationTests; + +typedef struct { + CERTRevocationTests leafTests; + CERTRevocationTests chainTests; +} CERTRevocationFlags; + +typedef struct CERTValParamInValueStr { + union { + PRBool b; + PRInt32 i; + PRUint32 ui; + PRInt64 l; + PRUint64 ul; + PRTime time; + } scalar; + union { + const void *p; + const char *s; + const CERTCertificate *cert; + const CERTCertList *chain; + const CERTRevocationFlags *revocation; + const CERTChainVerifyCallback *chainVerifyCallback; + } pointer; + union { + const PRInt32 *pi; + const PRUint32 *pui; + const PRInt64 *pl; + const PRUint64 *pul; + const SECOidTag *oids; + } array; + int arraySize; +} CERTValParamInValue; + +typedef struct CERTValParamOutValueStr { + union { + PRBool b; + PRInt32 i; + PRUint32 ui; + PRInt64 l; + PRUint64 ul; + SECCertificateUsage usages; + } scalar; + union { + void *p; + char *s; + CERTVerifyLog *log; + CERTCertificate *cert; + CERTCertList *chain; + } pointer; + union { + void *p; + SECOidTag *oids; + } array; + int arraySize; +} CERTValParamOutValue; + +typedef struct { + CERTValParamInType type; + CERTValParamInValue value; +} CERTValInParam; + +typedef struct { + CERTValParamOutType type; + CERTValParamOutValue value; +} CERTValOutParam; + +/* + * Levels of standards conformance strictness for CERT_NameToAsciiInvertible + */ +typedef enum CertStrictnessLevels { + CERT_N2A_READABLE = 0, /* maximum human readability */ + CERT_N2A_STRICT = 10, /* strict RFC compliance */ + CERT_N2A_INVERTIBLE = 20 /* maximum invertibility, + all DirectoryStrings encoded in hex */ +} CertStrictnessLevel; + +/* + * policy flag defines + */ +#define CERT_POLICY_FLAG_NO_MAPPING 1 +#define CERT_POLICY_FLAG_EXPLICIT 2 +#define CERT_POLICY_FLAG_NO_ANY 4 + +/* + * CertStore flags + */ +#define CERT_ENABLE_LDAP_FETCH 1 +#define CERT_ENABLE_HTTP_FETCH 2 + +/* This functin pointer type may be used for any function that takes + * a CERTCertificate * and returns an allocated string, which must be + * freed by a call to PORT_Free. + */ +typedef char *(*CERT_StringFromCertFcn)(CERTCertificate *cert); + +/* XXX Lisa thinks the template declarations belong in cert.h, not here? */ + +#include "secasn1t.h" /* way down here because I expect template stuff to + * move out of here anyway */ + +SEC_BEGIN_PROTOS + +extern const SEC_ASN1Template CERT_CertificateRequestTemplate[]; +extern const SEC_ASN1Template CERT_CertificateTemplate[]; +extern const SEC_ASN1Template SEC_SignedCertificateTemplate[]; +extern const SEC_ASN1Template CERT_CertExtensionTemplate[]; +extern const SEC_ASN1Template CERT_SequenceOfCertExtensionTemplate[]; +extern const SEC_ASN1Template SECKEY_PublicKeyTemplate[]; +extern const SEC_ASN1Template CERT_SubjectPublicKeyInfoTemplate[]; +extern const SEC_ASN1Template CERT_TimeChoiceTemplate[]; +extern const SEC_ASN1Template CERT_ValidityTemplate[]; +extern const SEC_ASN1Template CERT_PublicKeyAndChallengeTemplate[]; +extern const SEC_ASN1Template SEC_CertSequenceTemplate[]; + +extern const SEC_ASN1Template CERT_IssuerAndSNTemplate[]; +extern const SEC_ASN1Template CERT_NameTemplate[]; +extern const SEC_ASN1Template CERT_SetOfSignedCrlTemplate[]; +extern const SEC_ASN1Template CERT_RDNTemplate[]; +extern const SEC_ASN1Template CERT_SignedDataTemplate[]; +extern const SEC_ASN1Template CERT_CrlTemplate[]; +extern const SEC_ASN1Template CERT_SignedCrlTemplate[]; + +/* +** XXX should the attribute stuff be centralized for all of ns/security? +*/ +extern const SEC_ASN1Template CERT_AttributeTemplate[]; +extern const SEC_ASN1Template CERT_SetOfAttributeTemplate[]; + +/* These functions simply return the address of the above-declared templates. +** This is necessary for Windows DLLs. Sigh. +*/ +SEC_ASN1_CHOOSER_DECLARE(CERT_CertificateRequestTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_CertificateTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_CrlTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_IssuerAndSNTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_NameTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_SequenceOfCertExtensionTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_SetOfSignedCrlTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_SignedDataTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_SubjectPublicKeyInfoTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_SignedCertificateTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_SignedCrlTemplate) +SEC_ASN1_CHOOSER_DECLARE(CERT_TimeChoiceTemplate) + +SEC_END_PROTOS + +#endif /* _CERTT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/ciferfam.h b/illumos-x86_64/usr/include/mps/ciferfam.h new file mode 100644 index 00000000..68caa4f8 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/ciferfam.h @@ -0,0 +1,62 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * ciferfam.h - cipher familie IDs used for configuring ciphers for export + * control + */ + +#ifndef _CIFERFAM_H_ +#define _CIFERFAM_H_ + +#include "utilrename.h" +/* Cipher Suite "Families" */ +#define CIPHER_FAMILY_PKCS12 "PKCS12" +#define CIPHER_FAMILY_SMIME "SMIME" +#define CIPHER_FAMILY_SSL2 "SSLv2" /* deprecated */ +#define CIPHER_FAMILY_SSL3 "SSLv3" +#define CIPHER_FAMILY_SSL "SSL" +#define CIPHER_FAMILY_ALL "" +#define CIPHER_FAMILY_UNKNOWN "UNKNOWN" + +#define CIPHER_FAMILYID_MASK 0xFFFF0000L +#define CIPHER_FAMILYID_SSL 0x00000000L +#define CIPHER_FAMILYID_SMIME 0x00010000L +#define CIPHER_FAMILYID_PKCS12 0x00020000L + +/* SMIME "Cipher Suites" */ +/* + * Note that it is assumed that the cipher number itself can be used + * as a bit position in a mask, and that mask is currently 32 bits wide. + * So, if you want to add a cipher that is greater than 0037, secmime.c + * needs to be made smarter at the same time. + */ +#define SMIME_RC2_CBC_40 (CIPHER_FAMILYID_SMIME | 0001) +#define SMIME_RC2_CBC_64 (CIPHER_FAMILYID_SMIME | 0002) +#define SMIME_RC2_CBC_128 (CIPHER_FAMILYID_SMIME | 0003) +#define SMIME_DES_CBC_56 (CIPHER_FAMILYID_SMIME | 0011) +#define SMIME_DES_EDE3_168 (CIPHER_FAMILYID_SMIME | 0012) +#define SMIME_AES_CBC_128 (CIPHER_FAMILYID_SMIME | 0013) +#define SMIME_AES_CBC_256 (CIPHER_FAMILYID_SMIME | 0014) +#define SMIME_RC5PAD_64_16_40 (CIPHER_FAMILYID_SMIME | 0021) +#define SMIME_RC5PAD_64_16_64 (CIPHER_FAMILYID_SMIME | 0022) +#define SMIME_RC5PAD_64_16_128 (CIPHER_FAMILYID_SMIME | 0023) +#define SMIME_FORTEZZA (CIPHER_FAMILYID_SMIME | 0031) + +/* PKCS12 "Cipher Suites" */ + +#define PKCS12_RC2_CBC_40 (CIPHER_FAMILYID_PKCS12 | 0001) +#define PKCS12_RC2_CBC_128 (CIPHER_FAMILYID_PKCS12 | 0002) +#define PKCS12_RC4_40 (CIPHER_FAMILYID_PKCS12 | 0011) +#define PKCS12_RC4_128 (CIPHER_FAMILYID_PKCS12 | 0012) +#define PKCS12_DES_56 (CIPHER_FAMILYID_PKCS12 | 0021) +#define PKCS12_DES_EDE3_168 (CIPHER_FAMILYID_PKCS12 | 0022) +#define PKCS12_AES_CBC_128 (CIPHER_FAMILYID_PKCS12 | 0031) +#define PKCS12_AES_CBC_192 (CIPHER_FAMILYID_PKCS12 | 0032) +#define PKCS12_AES_CBC_256 (CIPHER_FAMILYID_PKCS12 | 0033) + +/* SMIME version numbers are negative, to avoid colliding with SSL versions */ +#define SMIME_LIBRARY_VERSION_1_0 -0x0100 + +#endif /* _CIFERFAM_H_ */ diff --git a/illumos-x86_64/usr/include/mps/cmmf.h b/illumos-x86_64/usr/include/mps/cmmf.h new file mode 100644 index 00000000..1e39a8d2 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/cmmf.h @@ -0,0 +1,1082 @@ +/* -*- Mode: C; tab-width: 8 -*-*/ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _CMMF_H_ +#define _CMMF_H_ +/* + * These are the functions exported by the security library for + * implementing Certificate Management Message Formats (CMMF). + * + * This API is designed against July 1998 CMMF draft. Please read this + * draft before trying to use this API in an application that use CMMF. + */ +#include "seccomon.h" +#include "cmmft.h" +#include "crmf.h" + +SEC_BEGIN_PROTOS + +/******************* Creation Functions *************************/ + +/* + * FUNCTION: CMMF_CreateCertRepContent + * INPUTS: + * NONE + * NOTES: + * This function will create an empty CMMFCertRepContent Structure. + * The client of the library must set the CMMFCertResponses. + * Call CMMF_CertRepContentSetCertResponse to accomplish this task. + * If the client of the library also wants to include the chain of + * CA certs required to make the certificates in CMMFCertResponse valid, + * then the user must also set the caPubs field of CMMFCertRepContent. + * Call CMMF_CertRepContentSetCAPubs to accomplish this. After setting + * the desired fields, the user can then call CMMF_EncodeCertRepContent + * to DER-encode the CertRepContent. + * RETURN: + * A pointer to the CMMFCertRepContent. A NULL return value indicates + * an error in allocating memory or failure to initialize the structure. + */ +extern CMMFCertRepContent *CMMF_CreateCertRepContent(void); + +/* + * FUNCTION: CMMF_CreateCertRepContentFromDER + * INPUTS + * db + * The certificate database where the certificates will be placed. + * The certificates will be placed in the temporary database associated + * with the handle. + * buf + * A buffer to the DER-encoded CMMFCertRepContent + * len + * The length in bytes of the buffer 'buf' + * NOTES: + * This function passes the buffer to the ASN1 decoder and creates a + * CMMFCertRepContent structure. The user must call + * CMMF_DestroyCertRepContent after the return value is no longer needed. + * + * RETURN: + * A pointer to the CMMFCertRepContent structure. A NULL return + * value indicates the library was unable to parse the DER. + */ +extern CMMFCertRepContent * +CMMF_CreateCertRepContentFromDER(CERTCertDBHandle *db, + const char *buf, + long len); + +/* + * FUNCTION: CMMF_CreateCertResponse + * INPUTS: + * inCertReqId + * The Certificate Request Id this response is for. + * NOTES: + * This creates a CMMFCertResponse. This response should correspond + * to a request that was received via CRMF. From the CRMF message you + * can get the Request Id to pass in as inCertReqId, in essence binding + * a CMRFCertRequest message to the CMMFCertResponse created by this + * function. If no requuest id is associated with the response to create + * then the user should pass in -1 for 'inCertReqId'. + * + * RETURN: + * A pointer to the new CMMFCertResponse corresponding to the request id + * passed in. A NULL return value indicates an error while trying to + * create the CMMFCertResponse. + */ +extern CMMFCertResponse *CMMF_CreateCertResponse(long inCertReqId); + +/* + * FUNCTION: CMMF_CreateKeyRecRepContent + * INPUTS: + * NONE + * NOTES: + * This function creates a new empty CMMFKeyRecRepContent structure. + * At the very minimum, the user must call + * CMMF_KeyRecRepContentSetPKIStatusInfoStatus field to have an + * encodable structure. Depending on what the response is, the user may + * have to set other fields as well to properly build up the structure so + * that it can be encoded. Refer to the CMMF draft for how to properly + * set up a CMMFKeyRecRepContent. This is the structure that an RA returns + * to an end entity when doing key recovery. + + * The user must call CMMF_DestroyKeyRecRepContent when the return value + * is no longer needed. + * RETURN: + * A pointer to the empty CMMFKeyRecRepContent. A return value of NULL + * indicates an error in allocating memory or initializing the structure. + */ +extern CMMFKeyRecRepContent *CMMF_CreateKeyRecRepContent(void); + +/* + * FUNCTION: CMMF_CreateKeyRecRepContentFromDER + * INPUTS: + * db + * The handle for the certificate database where the decoded + * certificates will be placed. The decoded certificates will + * be placed in the temporary database associated with the + * handle. + * buf + * A buffer contatining the DER-encoded CMMFKeyRecRepContent + * len + * The length in bytes of the buffer 'buf' + * NOTES + * This function passes the buffer to the ASN1 decoder and creates a + * CMMFKeyRecRepContent structure. + * + * RETURN: + * A pointer to the CMMFKeyRecRepContent structure. A NULL return + * value indicates the library was unable to parse the DER. + */ +extern CMMFKeyRecRepContent * +CMMF_CreateKeyRecRepContentFromDER(CERTCertDBHandle *db, + const char *buf, + long len); + +/* + * FUNCTION: CMMF_CreatePOPODecKeyChallContent + * INPUTS: + * NONE + * NOTES: + * This function creates an empty CMMFPOPODecKeyChallContent. The user + * must add the challenges individually specifying the random number to + * be used and the public key to be used when creating each individual + * challenge. User can accomplish this by calling the function + * CMMF_POPODecKeyChallContentSetNextChallenge. + * RETURN: + * A pointer to a CMMFPOPODecKeyChallContent structure. Ther user can + * then call CMMF_EncodePOPODecKeyChallContent passing in the return + * value from this function after setting all of the challenges. A + * return value of NULL indicates an error while creating the + * CMMFPOPODecKeyChallContent structure. + */ +extern CMMFPOPODecKeyChallContent * +CMMF_CreatePOPODecKeyChallContent(void); + +/* + * FUNCTION: CMMF_CreatePOPODecKeyChallContentFromDER + * INPUTS + * buf + * A buffer containing the DER-encoded CMMFPOPODecKeyChallContent + * len + * The length in bytes of the buffer 'buf' + * NOTES: + * This function passes the buffer to the ASN1 decoder and creates a + * CMMFPOPODecKeyChallContent structure. + * + * RETURN: + * A pointer to the CMMFPOPODecKeyChallContent structure. A NULL return + * value indicates the library was unable to parse the DER. + */ +extern CMMFPOPODecKeyChallContent * +CMMF_CreatePOPODecKeyChallContentFromDER(const char *buf, long len); + +/* + * FUNCTION: CMMF_CreatePOPODecKeyRespContentFromDER + * INPUTS: + * buf + * A buffer contatining the DER-encoded CMMFPOPODecKeyRespContent + * len + * The length in bytes of the buffer 'buf' + * NOTES + * This function passes the buffer to the ASN1 decoder and creates a + * CMMFPOPODecKeyRespContent structure. + * + * RETURN: + * A pointer to the CMMFPOPODecKeyRespContent structure. A NULL return + * value indicates the library was unable to parse the DER. + */ +extern CMMFPOPODecKeyRespContent * +CMMF_CreatePOPODecKeyRespContentFromDER(const char *buf, long len); + +/************************** Set Functions *************************/ + +/* + * FUNCTION: CMMF_CertRepContentSetCertResponses + * INPUTS: + * inCertRepContent + * The CMMFCertRepContent to operate on. + * inCertResponses + * An array of pointers to CMMFCertResponse structures to + * add to the CMMFCertRepContent structure. + * inNumResponses + * The length of the array 'inCertResponses' + * NOTES: + * This function will add the CMMFCertResponse structure to the + * CMMFCertRepContent passed in. The CMMFCertResponse field of + * CMMFCertRepContent is required, so the client must call this function + * before calling CMMF_EncodeCertRepContent. If the user calls + * CMMF_EncodeCertRepContent before calling this function, + * CMMF_EncodeCertRepContent will fail. + * + * RETURN: + * SECSuccess if adding the CMMFCertResponses to the CMMFCertRepContent + * structure was successful. Any other return value indicates an error + * while trying to add the CMMFCertResponses. + */ +extern SECStatus +CMMF_CertRepContentSetCertResponses(CMMFCertRepContent *inCertRepContent, + CMMFCertResponse **inCertResponses, + int inNumResponses); + +/* + * FUNCTION: CMMF_CertRepContentSetCAPubs + * INPUTS: + * inCertRepContent + * The CMMFCertRepContent to operate on. + * inCAPubs + * The certificate list which makes up the chain of CA certificates + * required to make the issued cert valid. + * NOTES: + * This function will set the the certificates in the CA chain as part + * of the CMMFCertRepContent. This field is an optional member of the + * CMMFCertRepContent structure, so the client is not required to call + * this function before calling CMMF_EncodeCertRepContent. + * + * RETURN: + * SECSuccess if adding the 'inCAPubs' to the CERTRepContent was successful. + * Any other return value indicates an error while adding 'inCAPubs' to the + * CMMFCertRepContent structure. + * + */ +extern SECStatus +CMMF_CertRepContentSetCAPubs(CMMFCertRepContent *inCertRepContent, + CERTCertList *inCAPubs); + +/* + * FUNCTION: CMMF_CertResponseSetPKIStatusInfoStatus + * INPUTS: + * inCertResp + * The CMMFCertResponse to operate on. + * inPKIStatus + * The value to set for the PKIStatusInfo.status field. + * NOTES: + * This function will set the CertResponse.status.status field of + * the CMMFCertResponse structure. (View the definition of CertResponse + * in the CMMF draft to see exactly which value this talks about.) This + * field is a required member of the structure, so the user must call this + * function in order to have a CMMFCertResponse that can be encoded. + * + * RETURN: + * SECSuccess if setting the field with the passed in value was successful. + * Any other return value indicates an error while trying to set the field. + */ +extern SECStatus +CMMF_CertResponseSetPKIStatusInfoStatus(CMMFCertResponse *inCertResp, + CMMFPKIStatus inPKIStatus); + +/* + * FUNCTION: CMMF_CertResponseSetCertificate + * INPUTS: + * inCertResp + * The CMMFCertResponse to operate on. + * inCertificate + * The certificate to add to the + * CertResponse.CertifiedKeyPair.certOrEncCert.certificate field. + * NOTES: + * This function will take the certificate and make it a member of the + * CMMFCertResponse. The certificate should be the actual certificate + * being issued via the response. + * + * RETURN: + * SECSuccess if adding the certificate to the response was successful. + * Any other return value indicates an error in adding the certificate to + * the CertResponse. + */ +extern SECStatus +CMMF_CertResponseSetCertificate(CMMFCertResponse *inCertResp, + CERTCertificate *inCertificate); + +/* + * FUNCTION: CMMF_KeyRecRepContentSetPKIStatusInfoStatus + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent to operate on. + * inPKIStatus + * The value to set the PKIStatusInfo.status field to. + * NOTES: + * This function sets the only required field for the KeyRecRepContent. + * In most cases, the user will set this field and other fields of the + * structure to properly create the CMMFKeyRecRepContent structure. + * Refer to the CMMF draft to see which fields need to be set in order + * to create the desired CMMFKeyRecRepContent. + * + * RETURN: + * SECSuccess if setting the PKIStatusInfo.status field was successful. + * Any other return value indicates an error in setting the field. + */ +extern SECStatus +CMMF_KeyRecRepContentSetPKIStatusInfoStatus(CMMFKeyRecRepContent *inKeyRecRep, + CMMFPKIStatus inPKIStatus); + +/* + * FUNCTION: CMMF_KeyRecRepContentSetNewSignCert + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent to operate on. + * inNewSignCert + * The new signing cert to add to the CMMFKeyRecRepContent structure. + * NOTES: + * This function sets the new signeing cert in the CMMFKeyRecRepContent + * structure. + * + * RETURN: + * SECSuccess if setting the new signing cert was successful. Any other + * return value indicates an error occurred while trying to add the + * new signing certificate. + */ +extern SECStatus +CMMF_KeyRecRepContentSetNewSignCert(CMMFKeyRecRepContent *inKeyRecRep, + CERTCertificate *inNewSignCert); + +/* + * FUNCTION: CMMF_KeyRecRepContentSetCACerts + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent to operate on. + * inCACerts + * The list of CA certificates required to construct a valid + * certificate chain with the certificates that will be returned + * to the end user via this KeyRecRepContent. + * NOTES: + * This function sets the caCerts that are required to form a chain with the + * end entity certificates that are being re-issued in this + * CMMFKeyRecRepContent structure. + * + * RETURN: + * SECSuccess if adding the caCerts was successful. Any other return value + * indicates an error while tring to add the caCerts. + */ +extern SECStatus +CMMF_KeyRecRepContentSetCACerts(CMMFKeyRecRepContent *inKeyRecRep, + CERTCertList *inCACerts); + +/* + * FUNCTION: CMMF_KeyRecRepContentSetCertifiedKeyPair + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent to operate on. + * inCert + * The certificate to add to the CMMFKeyRecRepContent structure. + * inPrivKey + * The private key associated with the certificate above passed in. + * inPubKey + * The public key to use for wrapping the private key. + * NOTES: + * This function adds another certificate-key pair to the + * CMMFKeyRecRepcontent structure. There may be more than one + * certificate-key pair in the structure, so the user must call this + * function multiple times to add more than one cert-key pair. + * + * RETURN: + * SECSuccess if adding the certified key pair was successful. Any other + * return value indicates an error in adding certified key pair to + * CMMFKeyRecRepContent structure. + */ +extern SECStatus +CMMF_KeyRecRepContentSetCertifiedKeyPair(CMMFKeyRecRepContent *inKeyRecRep, + CERTCertificate *inCert, + SECKEYPrivateKey *inPrivKey, + SECKEYPublicKey *inPubKey); + +/* + * FUNCTION: CMMF_POPODecKeyChallContentSetNextChallenge + * INPUTS: + * inDecKeyChall + * The CMMFPOPODecKeyChallContent to operate on. + * inRandom + * The random number to use when generating the challenge, + * inSender + * The GeneralName representation of the sender of the challenge. + * inPubKey + * The public key to use when encrypting the challenge. + * passwdArg + * This value will be passed to the function used for getting a + * password. The password for getting a password should be registered + * by calling PK11_SetPasswordFunc before this function is called. + * If no password callback is registered and the library needs to + * authenticate to the slot for any reason, this function will fail. + * NOTES: + * This function adds a challenge to the end of the list of challenges + * contained by 'inDecKeyChall'. Refer to the CMMF draft on how the + * the random number passed in and the sender's GeneralName are used + * to generate the challenge and witness fields of the challenge. This + * library will use SHA1 as the one-way function for generating the + * witess field of the challenge. + * + * RETURN: + * SECSuccess if generating the challenge and adding to the end of list + * of challenges was successful. Any other return value indicates an error + * while trying to generate the challenge. + */ +extern SECStatus +CMMF_POPODecKeyChallContentSetNextChallenge(CMMFPOPODecKeyChallContent *inDecKeyChall, + long inRandom, + CERTGeneralName *inSender, + SECKEYPublicKey *inPubKey, + void *passwdArg); + +/************************** Encoding Functions *************************/ + +/* + * FUNCTION: CMMF_EncodeCertRepContent + * INPUTS: + * inCertRepContent + * The CMMFCertRepContent to DER-encode. + * inCallback + * A callback function that the ASN1 encoder will call whenever it + * wants to write out DER-encoded bytes. Look at the defintion of + * CRMFEncoderOutputCallback in crmft.h for a description of the + * parameters to the function. + * inArg + * An opaque pointer to a user-supplied argument that will be passed + * to the callback funtion whenever the function is called. + * NOTES: + * The CMMF library will use the same DER-encoding scheme as the CRMF + * library. In other words, when reading CRMF comments that pertain to + * encoding, those comments apply to the CMMF libray as well. + * The callback function will be called multiple times, each time supplying + * the next chunk of DER-encoded bytes. The user must concatenate the + * output of each successive call to the callback in order to get the + * entire DER-encoded CMMFCertRepContent structure. + * + * RETURN: + * SECSuccess if encoding the CMMFCertRepContent was successful. Any + * other return value indicates an error while decoding the structure. + */ +extern SECStatus +CMMF_EncodeCertRepContent(CMMFCertRepContent *inCertRepContent, + CRMFEncoderOutputCallback inCallback, + void *inArg); + +/* + * FUNCTION: CMMF_EncodeKeyRecRepContent + * INPUTS: + * inKeyRecRep + * The CMMFKeyRepContent to DER-encode. + * inCallback + * A callback function that the ASN1 encoder will call whenever it + * wants to write out DER-encoded bytes. Look at the defintion of + * CRMFEncoderOutputCallback in crmft.h for a description of the + * parameters to the function. + * inArg + * An opaque pointer to a user-supplied argument that will be passed + * to the callback funtion whenever the function is called. + * NOTES: + * The CMMF library will use the same DER-encoding scheme as the CRMF + * library. In other words, when reading CRMF comments that pertain to + * encoding, those comments apply to the CMMF libray as well. + * The callback function will be called multiple times, each time supplying + * the next chunk of DER-encoded bytes. The user must concatenate the + * output of each successive call to the callback in order to get the + * entire DER-encoded CMMFCertRepContent structure. + * + * RETURN: + * SECSuccess if encoding the CMMFKeyRecRepContent was successful. Any + * other return value indicates an error while decoding the structure. + */ +extern SECStatus +CMMF_EncodeKeyRecRepContent(CMMFKeyRecRepContent *inKeyRecRep, + CRMFEncoderOutputCallback inCallback, + void *inArg); + +/* + * FUNCTION: CMMF_EncodePOPODecKeyChallContent + * INPUTS: + * inDecKeyChall + * The CMMFDecKeyChallContent to operate on. + * inCallback + * A callback function that the ASN1 encoder will call whenever it + * wants to write out DER-encoded bytes. Look at the defintion of + * CRMFEncoderOutputCallback in crmft.h for a description of the + * parameters to the function. + * inArg + * An opaque pointer to a user-supplied argument that will be passed + * to the callback function whenever the function is called. + * NOTES: + * The CMMF library will use the same DER-encoding scheme as the CRMF + * library. In other words, when reading CRMF comments that pertain to + * encoding, those comments apply to the CMMF libray as well. + * The callback function will be called multiple times, each time supplying + * the next chunk of DER-encoded bytes. The user must concatenate the + * output of each successive call to the callback in order to get the + * entire DER-encoded CMMFCertRepContent structure. + * The DER will be an encoding of the type POPODecKeyChallContents, which + * is just a sequence of challenges. + * + * RETURN: + * SECSuccess if encoding was successful. Any other return value indicates + * an error in trying to encode the Challenges. + */ +extern SECStatus +CMMF_EncodePOPODecKeyChallContent(CMMFPOPODecKeyChallContent *inDecKeyChall, + CRMFEncoderOutputCallback inCallback, + void *inArg); + +/* + * FUNCTION: CMMF_EncodePOPODecKeyRespContent + * INPUTS: + * inDecodedRand + * An array of integers to encode as the responses to + * CMMFPOPODecKeyChallContent. The integers must be in the same order + * as the challenges extracted from CMMFPOPODecKeyChallContent. + * inNumRand + * The number of random integers contained in the array 'inDecodedRand' + * inCallback + * A callback function that the ASN1 encoder will call whenever it + * wants to write out DER-encoded bytes. Look at the defintion of + * CRMFEncoderOutputCallback in crmft.h for a description of the + * parameters to the function. + * inArg + * An opaque pointer to a user-supplied argument that will be passed + * to the callback funtion whenever the function is called. + * NOTES: + * The CMMF library will use the same DER-encoding scheme as the CRMF + * library. In other words, when reading CRMF comments that pertain to + * encoding, those comments apply to the CMMF libray as well. + * The callback function will be called multiple times, each time supplying + * the next chunk of DER-encoded bytes. The user must concatenate the + * output of each successive call to the callback in order to get the + * entire DER-encoded POPODecKeyRespContent. + * + * RETURN: + * SECSuccess if encoding was successful. Any other return value indicates + * an error in trying to encode the Challenges. + */ +extern SECStatus +CMMF_EncodePOPODecKeyRespContent(long *inDecodedRand, + int inNumRand, + CRMFEncoderOutputCallback inCallback, + void *inArg); + +/*************** Accessor function ***********************************/ + +/* + * FUNCTION: CMMF_CertRepContentGetCAPubs + * INPUTS: + * inCertRepContent + * The CMMFCertRepContent to extract the caPubs from. + * NOTES: + * This function will return a copy of the list of certificates that + * make up the chain of CA's required to make the cert issued valid. + * The user must call CERT_DestroyCertList on the return value when + * done using the return value. + * + * Only call this function on a CertRepContent that has been decoded. + * The client must call CERT_DestroyCertList when the certificate list + * is no longer needed. + * + * The certs in the list will not be in the temporary database. In order + * to make these certificates a part of the permanent CA internal database, + * the user must collect the der for all of these certs and call + * CERT_ImportCAChain. Afterwards the certs will be part of the permanent + * database. + * + * RETURN: + * A pointer to the CERTCertList representing the CA chain associated + * with the issued cert. A NULL return value indicates that no CA Pubs + * were available in the CMMFCertRepContent structure. + */ +extern CERTCertList * +CMMF_CertRepContentGetCAPubs(CMMFCertRepContent *inCertRepContent); + +/* + * FUNCTION: CMMF_CertRepContentGetNumResponses + * INPUTS: + * inCertRepContent + * The CMMFCertRepContent to operate on. + * NOTES: + * This function will return the number of CertResponses that are contained + * by the CMMFCertRepContent passed in. + * + * RETURN: + * The number of CMMFCertResponses contained in the structure passed in. + */ +extern int +CMMF_CertRepContentGetNumResponses(CMMFCertRepContent *inCertRepContent); + +/* + * FUNCTION: CMMF_CertRepContentGetResponseAtIndex + * INPUTS: + * inCertRepContent + * The CMMFCertRepContent to operate on. + * inIndex + * The index of the CMMFCertResponse the user wants a copy of. + * NOTES: + * This function creates a copy of the CMMFCertResponse at the index + * corresponding to the parameter 'inIndex'. Indexing is done like a + * traditional C array, ie the valid indexes are (0...numResponses-1). + * The user must call CMMF_DestroyCertResponse after the return value is + * no longer needed. + * + * RETURN: + * A pointer to the CMMFCertResponse at the index corresponding to + * 'inIndex'. A return value of NULL indicates an error in copying + * the CMMFCertResponse. + */ +extern CMMFCertResponse * +CMMF_CertRepContentGetResponseAtIndex(CMMFCertRepContent *inCertRepContent, + int inIndex); + +/* + * FUNCTION: CMMF_CertResponseGetCertReqId + * INPUTS: + * inCertResp + * The CMMFCertResponse to operate on. + * NOTES: + * This function returns the CertResponse.certReqId from the + * CMMFCertResponse structure passed in. If the return value is -1, that + * means there is no associated certificate request with the CertResponse. + * RETURN: + * A long representing the id of the certificate request this + * CMMFCertResponse corresponds to. A return value of -1 indicates an + * error in extracting the value of the integer. + */ +extern long CMMF_CertResponseGetCertReqId(CMMFCertResponse *inCertResp); + +/* + * FUNCTION: CMMF_CertResponseGetPKIStatusInfoStatus + * INPUTS: + * inCertResp + * The CMMFCertResponse to operate on. + * NOTES: + * This function returns the CertResponse.status.status field of the + * CMMFCertResponse structure. + * + * RETURN: + * The enumerated value corresponding to the PKIStatus defined in the CMMF + * draft. See the CMMF draft for the definition of PKIStatus. See crmft.h + * for the definition of CMMFPKIStatus. + */ +extern CMMFPKIStatus +CMMF_CertResponseGetPKIStatusInfoStatus(CMMFCertResponse *inCertResp); + +/* + * FUNCTION: CMMF_CertResponseGetCertificate + * INPUTS: + * inCertResp + * The Certificate Response to operate on. + * inCertdb + * This is the certificate database where the function will place the + * newly issued certificate. + * NOTES: + * This function retrieves the CertResponse.certifiedKeyPair.certificate + * from the CMMFCertResponse. The user will get a copy of that certificate + * so the user must call CERT_DestroyCertificate when the return value is + * no longer needed. The certificate returned will be in the temporary + * certificate database. + * + * RETURN: + * A pointer to a copy of the certificate contained within the + * CMMFCertResponse. A return value of NULL indicates an error while trying + * to make a copy of the certificate. + */ +extern CERTCertificate * +CMMF_CertResponseGetCertificate(CMMFCertResponse *inCertResp, + CERTCertDBHandle *inCertdb); + +/* + * FUNCTION: CMMF_KeyRecRepContentGetPKIStatusInfoStatus + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent structure to operate on. + * NOTES: + * This function retrieves the KeyRecRepContent.status.status field of + * the CMMFKeyRecRepContent structure. + * RETURN: + * The CMMFPKIStatus corresponding to the value held in the + * CMMFKeyRecRepContent structure. + */ +extern CMMFPKIStatus +CMMF_KeyRecRepContentGetPKIStatusInfoStatus(CMMFKeyRecRepContent *inKeyRecRep); + +/* + * FUNCTION: CMMF_KeyRecRepContentGetNewSignCert + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent to operate on. + * NOTES: + * This function retrieves the KeyRecRepContent.newSignCert field of the + * CMMFKeyRecRepContent structure. The user must call + * CERT_DestroyCertificate when the return value is no longer needed. The + * returned certificate will be in the temporary database. The user + * must then place the certificate permanently in whatever token the + * user determines is the proper destination. A return value of NULL + * indicates the newSigCert field was not present. + */ +extern CERTCertificate * +CMMF_KeyRecRepContentGetNewSignCert(CMMFKeyRecRepContent *inKeyRecRep); + +/* + * FUNCTION: CMMF_KeyRecRepContentGetCACerts + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent to operate on. + * NOTES: + * This function returns a CERTCertList which contains all of the + * certficates that are in the sequence KeyRecRepContent.caCerts + * User must call CERT_DestroyCertList when the return value is no longer + * needed. All of these certificates will be placed in the tempoaray + * database. + * + * RETURN: + * A pointer to the list of caCerts contained in the CMMFKeyRecRepContent + * structure. A return value of NULL indicates the library was not able to + * make a copy of the certifcates. This may be because there are no caCerts + * included in the CMMFKeyRecRepContent strucure or an internal error. Call + * CMMF_KeyRecRepContentHasCACerts to find out if there are any caCerts + * included in 'inKeyRecRep'. + */ +extern CERTCertList * +CMMF_KeyRecRepContentGetCACerts(CMMFKeyRecRepContent *inKeyRecRep); + +/* + * FUNCTION: CMMF_KeyRecRepContentGetNumKeyPairs + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent to operate on. + * RETURN: + * This function returns the number of CMMFCertifiedKeyPair structures that + * that are stored in the KeyRecRepContent structure. + */ +extern int +CMMF_KeyRecRepContentGetNumKeyPairs(CMMFKeyRecRepContent *inKeyRecRep); + +/* + * FUNCTION: CMMF_KeyRecRepContentGetCertKeyAtIndex + * INPUTS: + * inKeyRecRepContent + * The CMMFKeyRecRepContent to operate on. + * inIndex + * The index of the desired CMMFCertifiedKeyPair + * NOTES: + * This function retrieves the CMMFCertifiedKeyPair structure at the index + * 'inIndex'. Valid indexes are 0...(numKeyPairs-1) The user must call + * CMMF_DestroyCertifiedKeyPair when the return value is no longer needed. + * + * RETURN: + * A pointer to the Certified Key Pair at the desired index. A return value + * of NULL indicates an error in extracting the Certified Key Pair at the + * desired index. + */ +extern CMMFCertifiedKeyPair * +CMMF_KeyRecRepContentGetCertKeyAtIndex(CMMFKeyRecRepContent *inKeyRecRep, + int inIndex); + +/* + * FUNCTION: CMMF_CertifiedKeyPairGetCertificate + * INPUTS: + * inCertKeyPair + * The CMMFCertifiedKeyPair to operate on. + * inCertdb + * The database handle for the database you want this certificate + * to wind up in. + * NOTES: + * This function retrieves the certificate at + * CertifiedKeyPair.certOrEncCert.certificate + * The user must call CERT_DestroyCertificate when the return value is no + * longer needed. The user must import this certificate as a token object + * onto PKCS#11 slot in order to make it a permanent object. The returned + * certificate will be in the temporary database. + * + * RETURN: + * A pointer to the certificate contained within the certified key pair. + * A return value of NULL indicates an error in creating the copy of the + * certificate. + */ +extern CERTCertificate * +CMMF_CertifiedKeyPairGetCertificate(CMMFCertifiedKeyPair *inCertKeyPair, + CERTCertDBHandle *inCertdb); + +/* + * FUNCTION: CMMF_POPODecKeyChallContentGetNumChallenges + * INPUTS: + * inKeyChallCont + * The CMMFPOPODecKeyChallContent to operate on. + * RETURN: + * This function returns the number of CMMFChallenges are contained in + * the CMMFPOPODecKeyChallContent structure. + */ +extern int CMMF_POPODecKeyChallContentGetNumChallenges(CMMFPOPODecKeyChallContent *inKeyChallCont); + +/* + * FUNCTION: CMMF_POPODecKeyChallContentGetPublicValue + * --------------------------------------------------- + * INPUTS: + * inKeyChallCont + * The CMMFPOPODecKeyChallContent to operate on. + * inIndex + * The index of the Challenge within inKeyChallCont to operate on. + * Indexes start from 0, ie the Nth Challenge corresponds to index + * N-1. + * NOTES: + * This function retrieves the public value stored away in the Challenge at + * index inIndex of inKeyChallCont. + * RETURN: + * A pointer to a SECItem containing the public value. User must call + * SECITEM_FreeItem on the return value when the value is no longer necessary. + * A return value of NULL indicates an error while retrieving the public value. + */ +extern SECItem *CMMF_POPODecKeyChallContentGetPublicValue(CMMFPOPODecKeyChallContent *inKeyChallCont, + int inIndex); + +/* + * FUNCTION: CMMF_POPODecKeyChallContentGetRandomNumber + * INPUTS: + * inChallContent + * The CMMFPOPODecKeyChallContent to operate on. + * inIndex + * The index of the challenge to look at. Valid indexes are 0 through + * (CMMF_POPODecKeyChallContentGetNumChallenges(inChallContent) - 1). + * inDest + * A pointer to a user supplied buffer where the library + * can place a copy of the random integer contatained in the + * challenge. + * NOTES: + * This function returns the value held in the decrypted Rand structure + * corresponding to the random integer. The user must call + * CMMF_POPODecKeyChallContentDecryptChallenge before calling this function. Call + * CMMF_ChallengeIsDecrypted to find out if the challenge has been + * decrypted. + * + * RETURN: + * SECSuccess indicates the witness field has been previously decrypted + * and the value for the random integer was successfully placed at *inDest. + * Any other return value indicates an error and that the value at *inDest + * is not a valid value. + */ +extern SECStatus CMMF_POPODecKeyChallContentGetRandomNumber(CMMFPOPODecKeyChallContent *inKeyChallCont, + int inIndex, + long *inDest); + +/* + * FUNCTION: CMMF_POPODecKeyRespContentGetNumResponses + * INPUTS: + * inRespCont + * The POPODecKeyRespContent to operate on. + * RETURN: + * This function returns the number of responses contained in inRespContent. + */ +extern int +CMMF_POPODecKeyRespContentGetNumResponses(CMMFPOPODecKeyRespContent *inRespCont); + +/* + * FUNCTION: CMMF_POPODecKeyRespContentGetResponse + * INPUTS: + * inRespCont + * The POPODecKeyRespContent to operate on. + * inIndex + * The index of the response to retrieve. + * The Nth response is at index N-1, ie the 1st response is at index 0, + * the 2nd response is at index 1, and so on. + * inDest + * A pointer to a pre-allocated buffer where the library can put the + * value of the response located at inIndex. + * NOTES: + * The function returns the response contained at index inIndex. + * CMMFPOPODecKeyRespContent is a structure that the server will generally + * get in response to a CMMFPOPODecKeyChallContent. The server will expect + * to see the responses in the same order as it constructed them in + * the CMMFPOPODecKeyChallContent structure. + * RETURN: + * SECSuccess if getting the response at the desired index was successful. Any + * other return value indicates an errror. + */ +extern SECStatus +CMMF_POPODecKeyRespContentGetResponse(CMMFPOPODecKeyRespContent *inRespCont, + int inIndex, + long *inDest); + +/************************* Destructor Functions ******************************/ + +/* + * FUNCTION: CMMF_DestroyCertResponse + * INPUTS: + * inCertResp + * The CMMFCertResponse to destroy. + * NOTES: + * This function frees all the memory associated with the CMMFCertResponse + * passed in. + * RETURN: + * SECSuccess if freeing the memory was successful. Any other return value + * indicates an error while freeing the memory. + */ +extern SECStatus CMMF_DestroyCertResponse(CMMFCertResponse *inCertResp); + +/* + * FUNCTION: CMMF_DestroyCertRepContent + * INPUTS: + * inCertRepContent + * The CMMFCertRepContent to destroy + * NOTES: + * This function frees the memory associated with the CMMFCertRepContent + * passed in. + * RETURN: + * SECSuccess if freeing all the memory associated with the + * CMMFCertRepContent passed in is successful. Any other return value + * indicates an error while freeing the memory. + */ +extern SECStatus +CMMF_DestroyCertRepContent(CMMFCertRepContent *inCertRepContent); + +/* + * FUNCTION: CMMF_DestroyKeyRecRepContent + * INPUTS: + * inKeyRecRep + * The CMMFKeyRecRepContent to destroy. + * NOTES: + * This function destroys all the memory associated with the + * CMMFKeyRecRepContent passed in. + * + * RETURN: + * SECSuccess if freeing all the memory is successful. Any other return + * value indicates an error in freeing the memory. + */ +extern SECStatus +CMMF_DestroyKeyRecRepContent(CMMFKeyRecRepContent *inKeyRecRep); + +/* + * FUNCTION: CMMF_DestroyCertifiedKeyPair + * INPUTS: + * inCertKeyPair + * The CMMFCertifiedKeyPair to operate on. + * NOTES: + * This function frees up all the memory associated with 'inCertKeyPair' + * + * RETURN: + * SECSuccess if freeing all the memory associated with 'inCertKeyPair' + * is successful. Any other return value indicates an error while trying + * to free the memory. + */ +extern SECStatus +CMMF_DestroyCertifiedKeyPair(CMMFCertifiedKeyPair *inCertKeyPair); + +/* + * FUNCTION: CMMF_DestroyPOPODecKeyRespContent + * INPUTS: + * inDecKeyResp + * The CMMFPOPODecKeyRespContent structure to free. + * NOTES: + * This function frees up all the memory associate with the + * CMMFPOPODecKeyRespContent. + * + * RETURN: + * SECSuccess if freeing up all the memory associated with the + * CMMFPOPODecKeyRespContent structure is successful. Any other + * return value indicates an error while freeing the memory. + */ +extern SECStatus +CMMF_DestroyPOPODecKeyRespContent(CMMFPOPODecKeyRespContent *inDecKeyResp); + +/************************** Miscellaneous Functions *************************/ + +/* + * FUNCTION: CMMF_CertifiedKeyPairUnwrapPrivKey + * INPUTS: + * inCertKeyPair + * The CMMFCertifiedKeyPair to operate on. + * inPrivKey + * The private key to use to un-wrap the private key + * inNickName + * This is the nickname that will be associated with the private key + * to be unwrapped. + * inSlot + * The PKCS11 slot where the unwrapped private key should end up. + * inCertdb + * The Certificate database with which the new key will be associated. + * destPrivKey + * A pointer to memory where the library can place a pointer to the + * private key after importing the key onto the specified slot. + * wincx + * An opaque pointer that the library will use in a callback function + * to get the password if necessary. + * + * NOTES: + * This function uses the private key passed in to unwrap the private key + * contained within the CMMFCertifiedKeyPair structure. After this + * function successfully returns, the private key has been unwrapped and + * placed in the specified slot. + * + * RETURN: + * SECSuccess if unwrapping the private key was successful. Any other + * return value indicates an error while trying to un-wrap the private key. + */ +extern SECStatus +CMMF_CertifiedKeyPairUnwrapPrivKey(CMMFCertifiedKeyPair *inKeyPair, + SECKEYPrivateKey *inPrivKey, + SECItem *inNickName, + PK11SlotInfo *inSlot, + CERTCertDBHandle *inCertdb, + SECKEYPrivateKey **destPrivKey, + void *wincx); + +/* + * FUNCTION: CMMF_KeyRecRepContentHasCACerts + * INPUTS: + * inKeyRecRecp + * The CMMFKeyRecRepContent to operate on. + * RETURN: + * This function returns PR_TRUE if there are one or more certificates in + * the sequence KeyRecRepContent.caCerts within the CMMFKeyRecRepContent + * structure. The function will return PR_FALSE if there are 0 certificate + * in the above mentioned sequence. + */ +extern PRBool +CMMF_KeyRecRepContentHasCACerts(CMMFKeyRecRepContent *inKeyRecRep); + +/* + * FUNCTION: CMMF_POPODecKeyChallContDecryptChallenge + * INPUTS: + * inChalCont + * The CMMFPOPODecKeyChallContent to operate on. + * inIndex + * The index of the Challenge to operate on. The 1st Challenge is + * at index 0, the second at index 1 and so forth. + * inPrivKey + * The private key to use to decrypt the witness field. + * NOTES: + * This function uses the private key to decrypt the challenge field + * contained in the appropriate challenge. Make sure the private key matches + * the public key that was used to encrypt the witness. Use + * CMMF_POPODecKeyChallContentGetPublicValue to get the public value of + * the key used to encrypt the witness and then use that to determine the + * appropriate private key. This can be done by calling PK11_MakeIDFromPubKey + * and then passing that return value to PK11_FindKeyByKeyID. The creator of + * the challenge will most likely be an RA that has the public key + * from a Cert request. So the private key should be the private key + * associated with public key in that request. This function will also + * verify the witness field of the challenge. This function also verifies + * that the sender and witness hashes match within the challenge. + * + * RETURN: + * SECSuccess if decrypting the witness field was successful. This does + * not indicate that the decrypted data is valid, since the private key + * passed in may not be the actual key needed to properly decrypt the + * witness field. Meaning that there is a decrypted structure now, but + * may be garbage because the private key was incorrect. + * Any other return value indicates the function could not complete the + * decryption process. + */ +extern SECStatus +CMMF_POPODecKeyChallContDecryptChallenge(CMMFPOPODecKeyChallContent *inChalCont, + int inIndex, + SECKEYPrivateKey *inPrivKey); + +/* + * FUNCTION: CMMF_DestroyPOPODecKeyChallContent + * INPUTS: + * inDecKeyCont + * The CMMFPOPODecKeyChallContent to free + * NOTES: + * This function frees up all the memory associated with the + * CMMFPOPODecKeyChallContent + * RETURN: + * SECSuccess if freeing up all the memory associatd with the + * CMMFPOPODecKeyChallContent is successful. Any other return value + * indicates an error while freeing the memory. + * + */ +extern SECStatus +CMMF_DestroyPOPODecKeyChallContent(CMMFPOPODecKeyChallContent *inDecKeyCont); + +SEC_END_PROTOS +#endif /* _CMMF_H_ */ diff --git a/illumos-x86_64/usr/include/mps/cmmft.h b/illumos-x86_64/usr/include/mps/cmmft.h new file mode 100644 index 00000000..e39f19ed --- /dev/null +++ b/illumos-x86_64/usr/include/mps/cmmft.h @@ -0,0 +1,73 @@ +/* -*- Mode: C; tab-width: 8 -*-*/ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _CMMFT_H_ +#define _CMMFT_H_ + +#include "secasn1.h" + +/* + * These are the enumerations used to distinguish between the different + * choices available for the CMMFCertOrEncCert structure. + */ +typedef enum { + cmmfNoCertOrEncCert = 0, + cmmfCertificate = 1, + cmmfEncryptedCert = 2 +} CMMFCertOrEncCertChoice; + +/* + * This is the enumeration and the corresponding values used to + * represent the CMMF type PKIStatus + */ +typedef enum { + cmmfNoPKIStatus = -1, + cmmfGranted = 0, + cmmfGrantedWithMods = 1, + cmmfRejection = 2, + cmmfWaiting = 3, + cmmfRevocationWarning = 4, + cmmfRevocationNotification = 5, + cmmfKeyUpdateWarning = 6, + cmmfNumPKIStatus +} CMMFPKIStatus; + +/* + * These enumerations are used to represent the corresponding values + * in PKIFailureInfo defined in CMMF. + */ +typedef enum { + cmmfBadAlg = 0, + cmmfBadMessageCheck = 1, + cmmfBadRequest = 2, + cmmfBadTime = 3, + cmmfBadCertId = 4, + cmmfBadDataFormat = 5, + cmmfWrongAuthority = 6, + cmmfIncorrectData = 7, + cmmfMissingTimeStamp = 8, + cmmfNoFailureInfo = 9 +} CMMFPKIFailureInfo; + +typedef struct CMMFPKIStatusInfoStr CMMFPKIStatusInfo; +typedef struct CMMFCertOrEncCertStr CMMFCertOrEncCert; +typedef struct CMMFCertifiedKeyPairStr CMMFCertifiedKeyPair; +typedef struct CMMFCertResponseStr CMMFCertResponse; +typedef struct CMMFCertResponseSeqStr CMMFCertResponseSeq; +typedef struct CMMFPOPODecKeyChallContentStr CMMFPOPODecKeyChallContent; +typedef struct CMMFChallengeStr CMMFChallenge; +typedef struct CMMFRandStr CMMFRand; +typedef struct CMMFPOPODecKeyRespContentStr CMMFPOPODecKeyRespContent; +typedef struct CMMFKeyRecRepContentStr CMMFKeyRecRepContent; +typedef struct CMMFCertRepContentStr CMMFCertRepContent; + +/* Export this so people can call SEC_ASN1EncodeItem instead of having to + * write callbacks that are passed in to the high level encode function + * for CMMFCertRepContent. + */ +extern const SEC_ASN1Template CMMFCertRepContentTemplate[]; +extern const SEC_ASN1Template CMMFPOPODecKeyChallContentTemplate[]; + +#endif /*_CMMFT_H_*/ diff --git a/illumos-x86_64/usr/include/mps/cms.h b/illumos-x86_64/usr/include/mps/cms.h new file mode 100644 index 00000000..48a2f683 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/cms.h @@ -0,0 +1,1156 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Interfaces of the CMS implementation. + */ + +#ifndef _CMS_H_ +#define _CMS_H_ + +#include "seccomon.h" + +#include "secoidt.h" +#include "certt.h" +#include "keythi.h" +#include "hasht.h" +#include "cmst.h" + +/************************************************************************/ +SEC_BEGIN_PROTOS + +/************************************************************************ + * cmsdecode.c - CMS decoding + ************************************************************************/ + +/* + * NSS_CMSDecoder_Start - set up decoding of a DER-encoded CMS message + * + * "poolp" - pointer to arena for message, or NULL if new pool should be created + * "cb", "cb_arg" - callback function and argument for delivery of inner content + * inner content will be stored in the message if cb is NULL. + * "pwfn", pwfn_arg" - callback function for getting token password + * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData + */ +extern NSSCMSDecoderContext * +NSS_CMSDecoder_Start(PLArenaPool *poolp, + NSSCMSContentCallback cb, void *cb_arg, + PK11PasswordFunc pwfn, void *pwfn_arg, + NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg); + +/* + * NSS_CMSDecoder_Update - feed DER-encoded data to decoder + */ +extern SECStatus +NSS_CMSDecoder_Update(NSSCMSDecoderContext *p7dcx, const char *buf, unsigned long len); + +/* + * NSS_CMSDecoder_Cancel - cancel a decoding process + */ +extern void +NSS_CMSDecoder_Cancel(NSSCMSDecoderContext *p7dcx); + +/* + * NSS_CMSDecoder_Finish - mark the end of inner content and finish decoding + */ +extern NSSCMSMessage * +NSS_CMSDecoder_Finish(NSSCMSDecoderContext *p7dcx); + +/* + * NSS_CMSMessage_CreateFromDER - decode a CMS message from DER encoded data + */ +extern NSSCMSMessage * +NSS_CMSMessage_CreateFromDER(SECItem *DERmessage, + NSSCMSContentCallback cb, void *cb_arg, + PK11PasswordFunc pwfn, void *pwfn_arg, + NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg); + +/************************************************************************ + * cmsencode.c - CMS encoding + ************************************************************************/ + +/* + * NSS_CMSEncoder_Start - set up encoding of a CMS message + * + * "cmsg" - message to encode + * "outputfn", "outputarg" - callback function for delivery of DER-encoded output + * will not be called if NULL. + * "dest" - if non-NULL, pointer to SECItem that will hold the DER-encoded output + * "destpoolp" - pool to allocate DER-encoded output in + * "pwfn", pwfn_arg" - callback function for getting token password + * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData + * "detached_digestalgs", "detached_digests" - digests from detached content + */ +extern NSSCMSEncoderContext * +NSS_CMSEncoder_Start(NSSCMSMessage *cmsg, + NSSCMSContentCallback outputfn, void *outputarg, + SECItem *dest, PLArenaPool *destpoolp, + PK11PasswordFunc pwfn, void *pwfn_arg, + NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg, + SECAlgorithmID **detached_digestalgs, SECItem **detached_digests); + +/* + * NSS_CMSEncoder_Update - take content data delivery from the user + * + * "p7ecx" - encoder context + * "data" - content data + * "len" - length of content data + */ +extern SECStatus +NSS_CMSEncoder_Update(NSSCMSEncoderContext *p7ecx, const char *data, unsigned long len); + +/* + * NSS_CMSEncoder_Cancel - stop all encoding + */ +extern SECStatus +NSS_CMSEncoder_Cancel(NSSCMSEncoderContext *p7ecx); + +/* + * NSS_CMSEncoder_Finish - signal the end of data + * + * we need to walk down the chain of encoders and the finish them from the innermost out + */ +extern SECStatus +NSS_CMSEncoder_Finish(NSSCMSEncoderContext *p7ecx); + +/************************************************************************ + * cmsmessage.c - CMS message object + ************************************************************************/ + +/* + * NSS_CMSMessage_Create - create a CMS message object + * + * "poolp" - arena to allocate memory from, or NULL if new arena should be created + */ +extern NSSCMSMessage * +NSS_CMSMessage_Create(PLArenaPool *poolp); + +/* + * NSS_CMSMessage_SetEncodingParams - set up a CMS message object for encoding or decoding + * + * "cmsg" - message object + * "pwfn", pwfn_arg" - callback function for getting token password + * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData + * "detached_digestalgs", "detached_digests" - digests from detached content + * + * used internally. + */ +extern void +NSS_CMSMessage_SetEncodingParams(NSSCMSMessage *cmsg, + PK11PasswordFunc pwfn, void *pwfn_arg, + NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg, + SECAlgorithmID **detached_digestalgs, SECItem **detached_digests); + +/* + * NSS_CMSMessage_Destroy - destroy a CMS message and all of its sub-pieces. + */ +extern void +NSS_CMSMessage_Destroy(NSSCMSMessage *cmsg); + +/* + * NSS_CMSMessage_Copy - return a copy of the given message. + * + * The copy may be virtual or may be real -- either way, the result needs + * to be passed to NSS_CMSMessage_Destroy later (as does the original). + */ +extern NSSCMSMessage * +NSS_CMSMessage_Copy(NSSCMSMessage *cmsg); + +/* + * NSS_CMSMessage_GetArena - return a pointer to the message's arena pool + */ +extern PLArenaPool * +NSS_CMSMessage_GetArena(NSSCMSMessage *cmsg); + +/* + * NSS_CMSMessage_GetContentInfo - return a pointer to the top level contentInfo + */ +extern NSSCMSContentInfo * +NSS_CMSMessage_GetContentInfo(NSSCMSMessage *cmsg); + +/* + * Return a pointer to the actual content. + * In the case of those types which are encrypted, this returns the *plain* content. + * In case of nested contentInfos, this descends and retrieves the innermost content. + */ +extern SECItem * +NSS_CMSMessage_GetContent(NSSCMSMessage *cmsg); + +/* + * NSS_CMSMessage_ContentLevelCount - count number of levels of CMS content objects in this message + * + * CMS data content objects do not count. + */ +extern int +NSS_CMSMessage_ContentLevelCount(NSSCMSMessage *cmsg); + +/* + * NSS_CMSMessage_ContentLevel - find content level #n + * + * CMS data content objects do not count. + */ +extern NSSCMSContentInfo * +NSS_CMSMessage_ContentLevel(NSSCMSMessage *cmsg, int n); + +/* + * NSS_CMSMessage_ContainsCertsOrCrls - see if message contains certs along the way + */ +extern PRBool +NSS_CMSMessage_ContainsCertsOrCrls(NSSCMSMessage *cmsg); + +/* + * NSS_CMSMessage_IsEncrypted - see if message contains a encrypted submessage + */ +extern PRBool +NSS_CMSMessage_IsEncrypted(NSSCMSMessage *cmsg); + +/* + * NSS_CMSMessage_IsSigned - see if message contains a signed submessage + * + * If the CMS message has a SignedData with a signature (not just a SignedData) + * return true; false otherwise. This can/should be called before calling + * VerifySignature, which will always indicate failure if no signature is + * present, but that does not mean there even was a signature! + * Note that the content itself can be empty (detached content was sent + * another way); it is the presence of the signature that matters. + */ +extern PRBool +NSS_CMSMessage_IsSigned(NSSCMSMessage *cmsg); + +/* + * NSS_CMSMessage_IsContentEmpty - see if content is empty + * + * returns PR_TRUE is innermost content length is < minLen + * XXX need the encrypted content length (why?) + */ +extern PRBool +NSS_CMSMessage_IsContentEmpty(NSSCMSMessage *cmsg, unsigned int minLen); + +/************************************************************************ + * cmscinfo.c - CMS contentInfo methods + ************************************************************************/ + +/* + * NSS_CMSContentInfo_Destroy - destroy a CMS contentInfo and all of its sub-pieces. + */ +extern void +NSS_CMSContentInfo_Destroy(NSSCMSContentInfo *cinfo); + +/* + * NSS_CMSContentInfo_GetChildContentInfo - get content's contentInfo (if it exists) + */ +extern NSSCMSContentInfo * +NSS_CMSContentInfo_GetChildContentInfo(NSSCMSContentInfo *cinfo); + +/* + * NSS_CMSContentInfo_SetContent - set cinfo's content type & content to CMS object + */ +extern SECStatus +NSS_CMSContentInfo_SetContent(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, SECOidTag type, void *ptr); + +/* + * NSS_CMSContentInfo_SetContent_XXXX - typesafe wrappers for NSS_CMSContentInfo_SetType + * set cinfo's content type & content to CMS object + */ +extern SECStatus +NSS_CMSContentInfo_SetContent_Data(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, SECItem *data, PRBool detached); + +extern SECStatus +NSS_CMSContentInfo_SetContent_SignedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSSignedData *sigd); + +extern SECStatus +NSS_CMSContentInfo_SetContent_EnvelopedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSEnvelopedData *envd); + +extern SECStatus +NSS_CMSContentInfo_SetContent_DigestedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSDigestedData *digd); + +extern SECStatus +NSS_CMSContentInfo_SetContent_EncryptedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSEncryptedData *encd); + +/* + * turn off streaming for this content type. + * This could fail with SEC_ERROR_NO_MEMORY in memory constrained conditions. + */ +extern SECStatus +NSS_CMSContentInfo_SetDontStream(NSSCMSContentInfo *cinfo, PRBool dontStream); + +/* + * NSS_CMSContentInfo_GetContent - get pointer to inner content + * + * needs to be casted... + */ +extern void * +NSS_CMSContentInfo_GetContent(NSSCMSContentInfo *cinfo); + +/* + * NSS_CMSContentInfo_GetInnerContent - get pointer to innermost content + * + * this is typically only called by NSS_CMSMessage_GetContent() + */ +extern SECItem * +NSS_CMSContentInfo_GetInnerContent(NSSCMSContentInfo *cinfo); + +/* + * NSS_CMSContentInfo_GetContentType{Tag,OID} - find out (saving pointer to lookup result + * for future reference) and return the inner content type. + */ +extern SECOidTag +NSS_CMSContentInfo_GetContentTypeTag(NSSCMSContentInfo *cinfo); + +extern SECItem * +NSS_CMSContentInfo_GetContentTypeOID(NSSCMSContentInfo *cinfo); + +/* + * NSS_CMSContentInfo_GetContentEncAlgTag - find out (saving pointer to lookup result + * for future reference) and return the content encryption algorithm tag. + */ +extern SECOidTag +NSS_CMSContentInfo_GetContentEncAlgTag(NSSCMSContentInfo *cinfo); + +/* + * NSS_CMSContentInfo_GetContentEncAlg - find out and return the content encryption algorithm tag. + */ +extern SECAlgorithmID * +NSS_CMSContentInfo_GetContentEncAlg(NSSCMSContentInfo *cinfo); + +extern SECStatus +NSS_CMSContentInfo_SetContentEncAlg(PLArenaPool *poolp, NSSCMSContentInfo *cinfo, + SECOidTag bulkalgtag, SECItem *parameters, int keysize); + +extern SECStatus +NSS_CMSContentInfo_SetContentEncAlgID(PLArenaPool *poolp, NSSCMSContentInfo *cinfo, + SECAlgorithmID *algid, int keysize); + +extern void +NSS_CMSContentInfo_SetBulkKey(NSSCMSContentInfo *cinfo, PK11SymKey *bulkkey); + +extern PK11SymKey * +NSS_CMSContentInfo_GetBulkKey(NSSCMSContentInfo *cinfo); + +extern int +NSS_CMSContentInfo_GetBulkKeySize(NSSCMSContentInfo *cinfo); + +/************************************************************************ + * cmsutil.c - CMS misc utility functions + ************************************************************************/ + +/* + * NSS_CMSArray_SortByDER - sort array of objects by objects' DER encoding + * + * make sure that the order of the objects guarantees valid DER (which must be + * in lexigraphically ascending order for a SET OF); if reordering is necessary it + * will be done in place (in objs). + */ +extern SECStatus +NSS_CMSArray_SortByDER(void **objs, const SEC_ASN1Template *objtemplate, void **objs2); + +/* + * NSS_CMSUtil_DERCompare - for use with NSS_CMSArray_Sort to + * sort arrays of SECItems containing DER + */ +extern int +NSS_CMSUtil_DERCompare(void *a, void *b); + +/* + * NSS_CMSAlgArray_GetIndexByAlgID - find a specific algorithm in an array of + * algorithms. + * + * algorithmArray - array of algorithm IDs + * algid - algorithmid of algorithm to pick + * + * Returns: + * An integer containing the index of the algorithm in the array or -1 if + * algorithm was not found. + */ +extern int +NSS_CMSAlgArray_GetIndexByAlgID(SECAlgorithmID **algorithmArray, SECAlgorithmID *algid); + +/* + * NSS_CMSAlgArray_GetIndexByAlgID - find a specific algorithm in an array of + * algorithms. + * + * algorithmArray - array of algorithm IDs + * algiddata - id of algorithm to pick + * + * Returns: + * An integer containing the index of the algorithm in the array or -1 if + * algorithm was not found. + */ +extern int +NSS_CMSAlgArray_GetIndexByAlgTag(SECAlgorithmID **algorithmArray, SECOidTag algtag); + +extern const SECHashObject * +NSS_CMSUtil_GetHashObjByAlgID(SECAlgorithmID *algid); + +extern const SEC_ASN1Template * +NSS_CMSUtil_GetTemplateByTypeTag(SECOidTag type); + +extern size_t +NSS_CMSUtil_GetSizeByTypeTag(SECOidTag type); + +extern NSSCMSContentInfo * +NSS_CMSContent_GetContentInfo(void *msg, SECOidTag type); + +extern const char * +NSS_CMSUtil_VerificationStatusToString(NSSCMSVerificationStatus vs); + +/************************************************************************ + * cmssigdata.c - CMS signedData methods + ************************************************************************/ + +extern NSSCMSSignedData * +NSS_CMSSignedData_Create(NSSCMSMessage *cmsg); + +extern void +NSS_CMSSignedData_Destroy(NSSCMSSignedData *sigd); + +/* + * NSS_CMSSignedData_Encode_BeforeStart - do all the necessary things to a SignedData + * before start of encoding. + * + * In detail: + * - find out about the right value to put into sigd->version + * - come up with a list of digestAlgorithms (which should be the union of the algorithms + * in the signerinfos). + * If we happen to have a pre-set list of algorithms (and digest values!), we + * check if we have all the signerinfos' algorithms. If not, this is an error. + */ +extern SECStatus +NSS_CMSSignedData_Encode_BeforeStart(NSSCMSSignedData *sigd); + +extern SECStatus +NSS_CMSSignedData_Encode_BeforeData(NSSCMSSignedData *sigd); + +/* + * NSS_CMSSignedData_Encode_AfterData - do all the necessary things to a SignedData + * after all the encapsulated data was passed through the encoder. + * + * In detail: + * - create the signatures in all the SignerInfos + * + * Please note that nothing is done to the Certificates and CRLs in the message - this + * is entirely the responsibility of our callers. + */ +extern SECStatus +NSS_CMSSignedData_Encode_AfterData(NSSCMSSignedData *sigd); + +extern SECStatus +NSS_CMSSignedData_Decode_BeforeData(NSSCMSSignedData *sigd); + +/* + * NSS_CMSSignedData_Decode_AfterData - do all the necessary things to a SignedData + * after all the encapsulated data was passed through the decoder. + */ +extern SECStatus +NSS_CMSSignedData_Decode_AfterData(NSSCMSSignedData *sigd); + +/* + * NSS_CMSSignedData_Decode_AfterEnd - do all the necessary things to a SignedData + * after all decoding is finished. + */ +extern SECStatus +NSS_CMSSignedData_Decode_AfterEnd(NSSCMSSignedData *sigd); + +/* + * NSS_CMSSignedData_GetSignerInfos - retrieve the SignedData's signer list + */ +extern NSSCMSSignerInfo ** +NSS_CMSSignedData_GetSignerInfos(NSSCMSSignedData *sigd); + +extern int +NSS_CMSSignedData_SignerInfoCount(NSSCMSSignedData *sigd); + +extern NSSCMSSignerInfo * +NSS_CMSSignedData_GetSignerInfo(NSSCMSSignedData *sigd, int i); + +/* + * NSS_CMSSignedData_GetDigestAlgs - retrieve the SignedData's digest algorithm list + */ +extern SECAlgorithmID ** +NSS_CMSSignedData_GetDigestAlgs(NSSCMSSignedData *sigd); + +/* + * NSS_CMSSignedData_GetContentInfo - return pointer to this signedData's contentinfo + */ +extern NSSCMSContentInfo * +NSS_CMSSignedData_GetContentInfo(NSSCMSSignedData *sigd); + +/* + * NSS_CMSSignedData_GetCertificateList - retrieve the SignedData's certificate list + */ +extern SECItem ** +NSS_CMSSignedData_GetCertificateList(NSSCMSSignedData *sigd); + +extern SECStatus +NSS_CMSSignedData_ImportCerts(NSSCMSSignedData *sigd, CERTCertDBHandle *certdb, + SECCertUsage certusage, PRBool keepcerts); + +/* + * NSS_CMSSignedData_HasDigests - see if we have digests in place + */ +extern PRBool +NSS_CMSSignedData_HasDigests(NSSCMSSignedData *sigd); + +/* + * NSS_CMSSignedData_VerifySignerInfo - check a signature. + * + * The digests were either calculated during decoding (and are stored in the + * signedData itself) or set after decoding using NSS_CMSSignedData_SetDigests. + * + * The verification checks if the signing cert is valid and has a trusted chain + * for the purpose specified by "certusage". + */ +extern SECStatus +NSS_CMSSignedData_VerifySignerInfo(NSSCMSSignedData *sigd, int i, CERTCertDBHandle *certdb, + SECCertUsage certusage); + +/* + * NSS_CMSSignedData_VerifyCertsOnly - verify the certs in a certs-only message + */ +extern SECStatus +NSS_CMSSignedData_VerifyCertsOnly(NSSCMSSignedData *sigd, + CERTCertDBHandle *certdb, + SECCertUsage usage); + +extern SECStatus +NSS_CMSSignedData_AddCertList(NSSCMSSignedData *sigd, CERTCertificateList *certlist); + +/* + * NSS_CMSSignedData_AddCertChain - add cert and its entire chain to the set of certs + */ +extern SECStatus +NSS_CMSSignedData_AddCertChain(NSSCMSSignedData *sigd, CERTCertificate *cert); + +extern SECStatus +NSS_CMSSignedData_AddCertificate(NSSCMSSignedData *sigd, CERTCertificate *cert); + +extern PRBool +NSS_CMSSignedData_ContainsCertsOrCrls(NSSCMSSignedData *sigd); + +extern SECStatus +NSS_CMSSignedData_AddSignerInfo(NSSCMSSignedData *sigd, + NSSCMSSignerInfo *signerinfo); + +extern SECStatus +NSS_CMSSignedData_SetDigests(NSSCMSSignedData *sigd, + SECAlgorithmID **digestalgs, + SECItem **digests); + +extern SECStatus +NSS_CMSSignedData_SetDigestValue(NSSCMSSignedData *sigd, + SECOidTag digestalgtag, + SECItem *digestdata); + +extern SECStatus +NSS_CMSSignedData_AddDigest(PLArenaPool *poolp, + NSSCMSSignedData *sigd, + SECOidTag digestalgtag, + SECItem *digest); + +extern SECItem * +NSS_CMSSignedData_GetDigestValue(NSSCMSSignedData *sigd, SECOidTag digestalgtag); + +/* + * NSS_CMSSignedData_CreateCertsOnly - create a certs-only SignedData. + * + * cert - base certificates that will be included + * include_chain - if true, include the complete cert chain for cert + * + * More certs and chains can be added via AddCertificate and AddCertChain. + * + * An error results in a return value of NULL and an error set. + */ +extern NSSCMSSignedData * +NSS_CMSSignedData_CreateCertsOnly(NSSCMSMessage *cmsg, CERTCertificate *cert, PRBool include_chain); + +/************************************************************************ + * cmssiginfo.c - signerinfo methods + ************************************************************************/ + +extern NSSCMSSignerInfo * +NSS_CMSSignerInfo_Create(NSSCMSMessage *cmsg, CERTCertificate *cert, SECOidTag digestalgtag); +extern NSSCMSSignerInfo * +NSS_CMSSignerInfo_CreateWithSubjKeyID(NSSCMSMessage *cmsg, SECItem *subjKeyID, SECKEYPublicKey *pubKey, SECKEYPrivateKey *signingKey, SECOidTag digestalgtag); + +/* + * NSS_CMSSignerInfo_Destroy - destroy a SignerInfo data structure + */ +extern void +NSS_CMSSignerInfo_Destroy(NSSCMSSignerInfo *si); + +/* + * NSS_CMSSignerInfo_Sign - sign something + * + */ +extern SECStatus +NSS_CMSSignerInfo_Sign(NSSCMSSignerInfo *signerinfo, SECItem *digest, SECItem *contentType); + +extern SECStatus +NSS_CMSSignerInfo_VerifyCertificate(NSSCMSSignerInfo *signerinfo, CERTCertDBHandle *certdb, + SECCertUsage certusage); + +/* + * NSS_CMSSignerInfo_Verify - verify the signature of a single SignerInfo + * + * Just verifies the signature. The assumption is that verification of the certificate + * is done already. + */ +extern SECStatus +NSS_CMSSignerInfo_Verify(NSSCMSSignerInfo *signerinfo, SECItem *digest, SECItem *contentType); + +extern NSSCMSVerificationStatus +NSS_CMSSignerInfo_GetVerificationStatus(NSSCMSSignerInfo *signerinfo); + +extern SECOidData * +NSS_CMSSignerInfo_GetDigestAlg(NSSCMSSignerInfo *signerinfo); + +extern SECOidTag +NSS_CMSSignerInfo_GetDigestAlgTag(NSSCMSSignerInfo *signerinfo); + +extern int +NSS_CMSSignerInfo_GetVersion(NSSCMSSignerInfo *signerinfo); + +extern CERTCertificateList * +NSS_CMSSignerInfo_GetCertList(NSSCMSSignerInfo *signerinfo); + +/* + * NSS_CMSSignerInfo_GetSigningTime - return the signing time, + * in UTCTime format, of a CMS signerInfo. + * + * sinfo - signerInfo data for this signer + * + * Returns a pointer to XXXX (what?) + * A return value of NULL is an error. + */ +extern SECStatus +NSS_CMSSignerInfo_GetSigningTime(NSSCMSSignerInfo *sinfo, PRTime *stime); + +/* + * Return the signing cert of a CMS signerInfo. + * + * the certs in the enclosing SignedData must have been imported already + */ +extern CERTCertificate * +NSS_CMSSignerInfo_GetSigningCertificate(NSSCMSSignerInfo *signerinfo, CERTCertDBHandle *certdb); + +/* + * NSS_CMSSignerInfo_GetSignerCommonName - return the common name of the signer + * + * sinfo - signerInfo data for this signer + * + * Returns a pointer to allocated memory, which must be freed with PORT_Free. + * A return value of NULL is an error. + */ +extern char * +NSS_CMSSignerInfo_GetSignerCommonName(NSSCMSSignerInfo *sinfo); + +/* + * NSS_CMSSignerInfo_GetSignerEmailAddress - return the common name of the signer + * + * sinfo - signerInfo data for this signer + * + * Returns a pointer to allocated memory, which must be freed. + * A return value of NULL is an error. + */ +extern char * +NSS_CMSSignerInfo_GetSignerEmailAddress(NSSCMSSignerInfo *sinfo); + +/* + * NSS_CMSSignerInfo_AddAuthAttr - add an attribute to the + * authenticated (i.e. signed) attributes of "signerinfo". + */ +extern SECStatus +NSS_CMSSignerInfo_AddAuthAttr(NSSCMSSignerInfo *signerinfo, NSSCMSAttribute *attr); + +/* + * NSS_CMSSignerInfo_AddUnauthAttr - add an attribute to the + * unauthenticated attributes of "signerinfo". + */ +extern SECStatus +NSS_CMSSignerInfo_AddUnauthAttr(NSSCMSSignerInfo *signerinfo, NSSCMSAttribute *attr); + +/* + * NSS_CMSSignerInfo_AddSigningTime - add the signing time to the + * authenticated (i.e. signed) attributes of "signerinfo". + * + * This is expected to be included in outgoing signed + * messages for email (S/MIME) but is likely useful in other situations. + * + * This should only be added once; a second call will do nothing. + * + * XXX This will probably just shove the current time into "signerinfo" + * but it will not actually get signed until the entire item is + * processed for encoding. Is this (expected to be small) delay okay? + */ +extern SECStatus +NSS_CMSSignerInfo_AddSigningTime(NSSCMSSignerInfo *signerinfo, PRTime t); + +/* + * NSS_CMSSignerInfo_AddSMIMECaps - add a SMIMECapabilities attribute to the + * authenticated (i.e. signed) attributes of "signerinfo". + * + * This is expected to be included in outgoing signed + * messages for email (S/MIME). + */ +extern SECStatus +NSS_CMSSignerInfo_AddSMIMECaps(NSSCMSSignerInfo *signerinfo); + +/* + * NSS_CMSSignerInfo_AddSMIMEEncKeyPrefs - add a SMIMEEncryptionKeyPreferences attribute to the + * authenticated (i.e. signed) attributes of "signerinfo". + * + * This is expected to be included in outgoing signed messages for email (S/MIME). + */ +SECStatus +NSS_CMSSignerInfo_AddSMIMEEncKeyPrefs(NSSCMSSignerInfo *signerinfo, CERTCertificate *cert, CERTCertDBHandle *certdb); + +/* + * NSS_CMSSignerInfo_AddMSSMIMEEncKeyPrefs - add a SMIMEEncryptionKeyPreferences attribute to the + * authenticated (i.e. signed) attributes of "signerinfo", using the OID preferred by Microsoft. + * + * This is expected to be included in outgoing signed messages for email (S/MIME), + * if compatibility with Microsoft mail clients is wanted. + */ +SECStatus +NSS_CMSSignerInfo_AddMSSMIMEEncKeyPrefs(NSSCMSSignerInfo *signerinfo, CERTCertificate *cert, CERTCertDBHandle *certdb); + +/* + * NSS_CMSSignerInfo_AddCounterSignature - countersign a signerinfo + */ +extern SECStatus +NSS_CMSSignerInfo_AddCounterSignature(NSSCMSSignerInfo *signerinfo, + SECOidTag digestalg, CERTCertificate signingcert); + +/* + * XXXX the following needs to be done in the S/MIME layer code + * after signature of a signerinfo is verified + */ +extern SECStatus +NSS_SMIMESignerInfo_SaveSMIMEProfile(NSSCMSSignerInfo *signerinfo); + +/* + * NSS_CMSSignerInfo_IncludeCerts - set cert chain inclusion mode for this signer + */ +extern SECStatus +NSS_CMSSignerInfo_IncludeCerts(NSSCMSSignerInfo *signerinfo, NSSCMSCertChainMode cm, SECCertUsage usage); + +/************************************************************************ + * cmsenvdata.c - CMS envelopedData methods + ************************************************************************/ + +/* + * NSS_CMSEnvelopedData_Create - create an enveloped data message + */ +extern NSSCMSEnvelopedData * +NSS_CMSEnvelopedData_Create(NSSCMSMessage *cmsg, SECOidTag algorithm, int keysize); + +/* + * NSS_CMSEnvelopedData_Destroy - destroy an enveloped data message + */ +extern void +NSS_CMSEnvelopedData_Destroy(NSSCMSEnvelopedData *edp); + +/* + * NSS_CMSEnvelopedData_GetContentInfo - return pointer to this envelopedData's contentinfo + */ +extern NSSCMSContentInfo * +NSS_CMSEnvelopedData_GetContentInfo(NSSCMSEnvelopedData *envd); + +/* + * NSS_CMSEnvelopedData_AddRecipient - add a recipientinfo to the enveloped data msg + * + * rip must be created on the same pool as edp - this is not enforced, though. + */ +extern SECStatus +NSS_CMSEnvelopedData_AddRecipient(NSSCMSEnvelopedData *edp, NSSCMSRecipientInfo *rip); + +/* + * NSS_CMSEnvelopedData_Encode_BeforeStart - prepare this envelopedData for encoding + * + * at this point, we need + * - recipientinfos set up with recipient's certificates + * - a content encryption algorithm (if none, 3DES will be used) + * + * this function will generate a random content encryption key (aka bulk key), + * initialize the recipientinfos with certificate identification and wrap the bulk key + * using the proper algorithm for every certificiate. + * it will finally set the bulk algorithm and key so that the encode step can find it. + */ +extern SECStatus +NSS_CMSEnvelopedData_Encode_BeforeStart(NSSCMSEnvelopedData *envd); + +/* + * NSS_CMSEnvelopedData_Encode_BeforeData - set up encryption + */ +extern SECStatus +NSS_CMSEnvelopedData_Encode_BeforeData(NSSCMSEnvelopedData *envd); + +/* + * NSS_CMSEnvelopedData_Encode_AfterData - finalize this envelopedData for encoding + */ +extern SECStatus +NSS_CMSEnvelopedData_Encode_AfterData(NSSCMSEnvelopedData *envd); + +/* + * NSS_CMSEnvelopedData_Decode_BeforeData - find our recipientinfo, + * derive bulk key & set up our contentinfo + */ +extern SECStatus +NSS_CMSEnvelopedData_Decode_BeforeData(NSSCMSEnvelopedData *envd); + +/* + * NSS_CMSEnvelopedData_Decode_AfterData - finish decrypting this envelopedData's content + */ +extern SECStatus +NSS_CMSEnvelopedData_Decode_AfterData(NSSCMSEnvelopedData *envd); + +/* + * NSS_CMSEnvelopedData_Decode_AfterEnd - finish decoding this envelopedData + */ +extern SECStatus +NSS_CMSEnvelopedData_Decode_AfterEnd(NSSCMSEnvelopedData *envd); + +/************************************************************************ + * cmsrecinfo.c - CMS recipientInfo methods + ************************************************************************/ + +extern PRBool +NSS_CMSRecipient_IsSupported(CERTCertificate *cert); + +/* + * NSS_CMSRecipientInfo_Create - create a recipientinfo + * + * we currently do not create KeyAgreement recipientinfos with multiple recipientEncryptedKeys + * the certificate is supposed to have been verified by the caller + */ +extern NSSCMSRecipientInfo * +NSS_CMSRecipientInfo_Create(NSSCMSMessage *cmsg, CERTCertificate *cert); + +extern NSSCMSRecipientInfo * +NSS_CMSRecipientInfo_CreateWithSubjKeyID(NSSCMSMessage *cmsg, + SECItem *subjKeyID, + SECKEYPublicKey *pubKey); + +extern NSSCMSRecipientInfo * +NSS_CMSRecipientInfo_CreateWithSubjKeyIDFromCert(NSSCMSMessage *cmsg, + CERTCertificate *cert); + +/* + * NSS_CMSRecipientInfo_CreateNew - create a blank recipientinfo for + * applications which want to encode their own CMS structures and + * key exchange types. + */ +extern NSSCMSRecipientInfo * +NSS_CMSRecipientInfo_CreateNew(void *pwfn_arg); + +/* + * NSS_CMSRecipientInfo_CreateFromDER - create a recipientinfo from partially + * decoded DER data for applications which want to encode their own CMS + * structures and key exchange types. + */ +extern NSSCMSRecipientInfo * +NSS_CMSRecipientInfo_CreateFromDER(SECItem *input, void *pwfn_arg); + +extern void +NSS_CMSRecipientInfo_Destroy(NSSCMSRecipientInfo *ri); + +/* + * NSS_CMSRecipientInfo_GetCertAndKey - retrieve the cert and key from the + * recipientInfo struct. If retcert or retkey are NULL, the cert or + * key (respectively) would not be returned). This function is a no-op if both + * retcert and retkey are NULL. Caller inherits ownership of the cert and key + * he requested (and is responsible to free them). + */ +SECStatus NSS_CMSRecipientInfo_GetCertAndKey(NSSCMSRecipientInfo *ri, + CERTCertificate **retcert, + SECKEYPrivateKey **retkey); + +extern int +NSS_CMSRecipientInfo_GetVersion(NSSCMSRecipientInfo *ri); + +extern SECItem * +NSS_CMSRecipientInfo_GetEncryptedKey(NSSCMSRecipientInfo *ri, int subIndex); + +/* + * NSS_CMSRecipientInfo_Encode - encode an NSS_CMSRecipientInfo as ASN.1 + */ +SECStatus NSS_CMSRecipientInfo_Encode(PLArenaPool *poolp, + const NSSCMSRecipientInfo *src, + SECItem *returned); + +extern SECOidTag +NSS_CMSRecipientInfo_GetKeyEncryptionAlgorithmTag(NSSCMSRecipientInfo *ri); + +extern SECStatus +NSS_CMSRecipientInfo_WrapBulkKey(NSSCMSRecipientInfo *ri, PK11SymKey *bulkkey, + SECOidTag bulkalgtag); + +extern PK11SymKey * +NSS_CMSRecipientInfo_UnwrapBulkKey(NSSCMSRecipientInfo *ri, int subIndex, + CERTCertificate *cert, SECKEYPrivateKey *privkey, + SECOidTag bulkalgtag); + +/************************************************************************ + * cmsencdata.c - CMS encryptedData methods + ************************************************************************/ +/* + * NSS_CMSEncryptedData_Create - create an empty encryptedData object. + * + * "algorithm" specifies the bulk encryption algorithm to use. + * "keysize" is the key size. + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern NSSCMSEncryptedData * +NSS_CMSEncryptedData_Create(NSSCMSMessage *cmsg, SECOidTag algorithm, int keysize); + +/* + * NSS_CMSEncryptedData_Destroy - destroy an encryptedData object + */ +extern void +NSS_CMSEncryptedData_Destroy(NSSCMSEncryptedData *encd); + +/* + * NSS_CMSEncryptedData_GetContentInfo - return pointer to encryptedData object's contentInfo + */ +extern NSSCMSContentInfo * +NSS_CMSEncryptedData_GetContentInfo(NSSCMSEncryptedData *encd); + +/* + * NSS_CMSEncryptedData_Encode_BeforeStart - do all the necessary things to a EncryptedData + * before encoding begins. + * + * In particular: + * - set the correct version value. + * - get the encryption key + */ +extern SECStatus +NSS_CMSEncryptedData_Encode_BeforeStart(NSSCMSEncryptedData *encd); + +/* + * NSS_CMSEncryptedData_Encode_BeforeData - set up encryption + */ +extern SECStatus +NSS_CMSEncryptedData_Encode_BeforeData(NSSCMSEncryptedData *encd); + +/* + * NSS_CMSEncryptedData_Encode_AfterData - finalize this encryptedData for encoding + */ +extern SECStatus +NSS_CMSEncryptedData_Encode_AfterData(NSSCMSEncryptedData *encd); + +/* + * NSS_CMSEncryptedData_Decode_BeforeData - find bulk key & set up decryption + */ +extern SECStatus +NSS_CMSEncryptedData_Decode_BeforeData(NSSCMSEncryptedData *encd); + +/* + * NSS_CMSEncryptedData_Decode_AfterData - finish decrypting this encryptedData's content + */ +extern SECStatus +NSS_CMSEncryptedData_Decode_AfterData(NSSCMSEncryptedData *encd); + +/* + * NSS_CMSEncryptedData_Decode_AfterEnd - finish decoding this encryptedData + */ +extern SECStatus +NSS_CMSEncryptedData_Decode_AfterEnd(NSSCMSEncryptedData *encd); + +/************************************************************************ + * cmsdigdata.c - CMS encryptedData methods + ************************************************************************/ +/* + * NSS_CMSDigestedData_Create - create a digestedData object (presumably for encoding) + * + * version will be set by NSS_CMSDigestedData_Encode_BeforeStart + * digestAlg is passed as parameter + * contentInfo must be filled by the user + * digest will be calculated while encoding + */ +extern NSSCMSDigestedData * +NSS_CMSDigestedData_Create(NSSCMSMessage *cmsg, SECAlgorithmID *digestalg); + +/* + * NSS_CMSDigestedData_Destroy - destroy a digestedData object + */ +extern void +NSS_CMSDigestedData_Destroy(NSSCMSDigestedData *digd); + +/* + * NSS_CMSDigestedData_GetContentInfo - return pointer to digestedData object's contentInfo + */ +extern NSSCMSContentInfo * +NSS_CMSDigestedData_GetContentInfo(NSSCMSDigestedData *digd); + +/* + * NSS_CMSDigestedData_Encode_BeforeStart - do all the necessary things to a DigestedData + * before encoding begins. + * + * In particular: + * - set the right version number. The contentInfo's content type must be set up already. + */ +extern SECStatus +NSS_CMSDigestedData_Encode_BeforeStart(NSSCMSDigestedData *digd); + +/* + * NSS_CMSDigestedData_Encode_BeforeData - do all the necessary things to a DigestedData + * before the encapsulated data is passed through the encoder. + * + * In detail: + * - set up the digests if necessary + */ +extern SECStatus +NSS_CMSDigestedData_Encode_BeforeData(NSSCMSDigestedData *digd); + +/* + * NSS_CMSDigestedData_Encode_AfterData - do all the necessary things to a DigestedData + * after all the encapsulated data was passed through the encoder. + * + * In detail: + * - finish the digests + */ +extern SECStatus +NSS_CMSDigestedData_Encode_AfterData(NSSCMSDigestedData *digd); + +/* + * NSS_CMSDigestedData_Decode_BeforeData - do all the necessary things to a DigestedData + * before the encapsulated data is passed through the encoder. + * + * In detail: + * - set up the digests if necessary + */ +extern SECStatus +NSS_CMSDigestedData_Decode_BeforeData(NSSCMSDigestedData *digd); + +/* + * NSS_CMSDigestedData_Decode_AfterData - do all the necessary things to a DigestedData + * after all the encapsulated data was passed through the encoder. + * + * In detail: + * - finish the digests + */ +extern SECStatus +NSS_CMSDigestedData_Decode_AfterData(NSSCMSDigestedData *digd); + +/* + * NSS_CMSDigestedData_Decode_AfterEnd - finalize a digestedData. + * + * In detail: + * - check the digests for equality + */ +extern SECStatus +NSS_CMSDigestedData_Decode_AfterEnd(NSSCMSDigestedData *digd); + +/************************************************************************ + * cmsdigest.c - digestion routines + ************************************************************************/ + +/* + * NSS_CMSDigestContext_StartMultiple - start digest calculation using all the + * digest algorithms in "digestalgs" in parallel. + */ +extern NSSCMSDigestContext * +NSS_CMSDigestContext_StartMultiple(SECAlgorithmID **digestalgs); + +/* + * NSS_CMSDigestContext_StartSingle - same as NSS_CMSDigestContext_StartMultiple, but + * only one algorithm. + */ +extern NSSCMSDigestContext * +NSS_CMSDigestContext_StartSingle(SECAlgorithmID *digestalg); + +/* + * NSS_CMSDigestContext_Update - feed more data into the digest machine + */ +extern void +NSS_CMSDigestContext_Update(NSSCMSDigestContext *cmsdigcx, const unsigned char *data, int len); + +/* + * NSS_CMSDigestContext_Cancel - cancel digesting operation + */ +extern void +NSS_CMSDigestContext_Cancel(NSSCMSDigestContext *cmsdigcx); + +/* + * NSS_CMSDigestContext_FinishMultiple - finish the digests and put them + * into an array of SECItems (allocated on poolp) + */ +extern SECStatus +NSS_CMSDigestContext_FinishMultiple(NSSCMSDigestContext *cmsdigcx, PLArenaPool *poolp, + SECItem ***digestsp); + +/* + * NSS_CMSDigestContext_FinishSingle - same as NSS_CMSDigestContext_FinishMultiple, + * but for one digest. + */ +extern SECStatus +NSS_CMSDigestContext_FinishSingle(NSSCMSDigestContext *cmsdigcx, PLArenaPool *poolp, + SECItem *digest); + +/************************************************************************ + * + ************************************************************************/ + +/* shortcuts for basic use */ + +/* + * NSS_CMSDEREncode - DER Encode a CMS message, with input being + * the plaintext message and derOut being the output, + * stored in arena's pool. + */ +extern SECStatus +NSS_CMSDEREncode(NSSCMSMessage *cmsg, SECItem *input, SECItem *derOut, + PLArenaPool *arena); + +/************************************************************************ + * + ************************************************************************/ + +/* + * define new S/MIME content type entries + * + * S/MIME uses the builtin PKCS7 oid types for encoding and decoding the + * various S/MIME content. Some applications have their own content type + * which is different from the standard content type defined by S/MIME. + * + * This function allows you to register new content types. There are basically + * Two different types of content, Wrappping content, and Data. + * + * For data types, All the functions below can be zero or NULL excext + * type and is isData, which should be your oid tag and PR_FALSE respectively + * + * For wrapping types, everything must be provided, or you will get encoder + * failures. + * + * If NSS doesn't already define the OID that you need, you can register + * your own with SECOID_AddEntry. + * + * Once you have defined your new content type, you can pass your new content + * type to NSS_CMSContentInfo_SetContent(). + * + * If you are using a wrapping type you can pass your own data structure in + * the ptr field, but it must contain and embedded NSSCMSGenericWrappingData + * structure as the first element. The size you pass to + * NSS_CMSType_RegisterContentType is the total size of your self defined + * data structure. NSS_CMSContentInfo_GetContent will return that data + * structure from the content info. Your ASN1Template will be evaluated + * against that data structure. + */ +SECStatus NSS_CMSType_RegisterContentType(SECOidTag type, + SEC_ASN1Template *asn1Template, size_t size, + NSSCMSGenericWrapperDataDestroy destroy, + NSSCMSGenericWrapperDataCallback decode_before, + NSSCMSGenericWrapperDataCallback decode_after, + NSSCMSGenericWrapperDataCallback decode_end, + NSSCMSGenericWrapperDataCallback encode_start, + NSSCMSGenericWrapperDataCallback encode_before, + NSSCMSGenericWrapperDataCallback encode_after, + PRBool isData); + +/************************************************************************/ +SEC_END_PROTOS + +#endif /* _CMS_H_ */ diff --git a/illumos-x86_64/usr/include/mps/cmsreclist.h b/illumos-x86_64/usr/include/mps/cmsreclist.h new file mode 100644 index 00000000..f424aca6 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/cmsreclist.h @@ -0,0 +1,27 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _CMSRECLIST_H +#define _CMSRECLIST_H + +struct NSSCMSRecipientStr { + int riIndex; /* this recipient's index in recipientInfo array */ + int subIndex; /* index into recipientEncryptedKeys */ + /* (only in NSSCMSKeyAgreeRecipientInfoStr) */ + enum { RLIssuerSN = 0, + RLSubjKeyID = 1 } kind; /* for conversion recipientinfos -> recipientlist */ + union { + CERTIssuerAndSN* issuerAndSN; + SECItem* subjectKeyID; + } id; + + /* result data (filled out for each recipient that's us) */ + CERTCertificate* cert; + SECKEYPrivateKey* privkey; + PK11SlotInfo* slot; +}; + +typedef struct NSSCMSRecipientStr NSSCMSRecipient; + +#endif /* _CMSRECLIST_H */ diff --git a/illumos-x86_64/usr/include/mps/cmst.h b/illumos-x86_64/usr/include/mps/cmst.h new file mode 100644 index 00000000..66ee1ed6 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/cmst.h @@ -0,0 +1,498 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Header for CMS types. + */ + +#ifndef _CMST_H_ +#define _CMST_H_ + +#include "seccomon.h" +#include "secoidt.h" +#include "certt.h" +#include "secmodt.h" +#include "secmodt.h" + +#include "plarena.h" + +/* Non-opaque objects. NOTE, though: I want them to be treated as + * opaque as much as possible. If I could hide them completely, + * I would. (I tried, but ran into trouble that was taking me too + * much time to get out of.) I still intend to try to do so. + * In fact, the only type that "outsiders" should even *name* is + * NSSCMSMessage, and they should not reference its fields. + */ +/* rjr: PKCS #11 cert handling (pk11cert.c) does use NSSCMSRecipientInfo's. + * This is because when we search the recipient list for the cert and key we + * want, we need to invert the order of the loops we used to have. The old + * loops were: + * + * For each recipient { + * find_cert = PK11_Find_AllCert(recipient->issuerSN); + * [which unrolls to... ] + * For each slot { + * Log into slot; + * search slot for cert; + * } + * } + * + * the new loop searchs all the recipients at once on a slot. this allows + * PKCS #11 to order slots in such a way that logout slots don't get checked + * if we can find the cert on a logged in slot. This eliminates lots of + * spurious password prompts when smart cards are installed... so why this + * comment? If you make NSSCMSRecipientInfo completely opaque, you need + * to provide a non-opaque list of issuerSN's (the only field PKCS#11 needs + * and fix up pk11cert.c first. NOTE: Only S/MIME calls this special PKCS #11 + * function. + */ + +typedef struct NSSCMSMessageStr NSSCMSMessage; + +typedef union NSSCMSContentUnion NSSCMSContent; +typedef struct NSSCMSContentInfoStr NSSCMSContentInfo; + +typedef struct NSSCMSSignedDataStr NSSCMSSignedData; +typedef struct NSSCMSSignerInfoStr NSSCMSSignerInfo; +typedef struct NSSCMSSignerIdentifierStr NSSCMSSignerIdentifier; + +typedef struct NSSCMSEnvelopedDataStr NSSCMSEnvelopedData; +typedef struct NSSCMSOriginatorInfoStr NSSCMSOriginatorInfo; +typedef struct NSSCMSRecipientInfoStr NSSCMSRecipientInfo; + +typedef struct NSSCMSDigestedDataStr NSSCMSDigestedData; +typedef struct NSSCMSEncryptedDataStr NSSCMSEncryptedData; + +typedef struct NSSCMSGenericWrapperDataStr NSSCMSGenericWrapperData; + +typedef struct NSSCMSAttributeStr NSSCMSAttribute; + +typedef struct NSSCMSDecoderContextStr NSSCMSDecoderContext; +typedef struct NSSCMSEncoderContextStr NSSCMSEncoderContext; + +typedef struct NSSCMSCipherContextStr NSSCMSCipherContext; +typedef struct NSSCMSDigestContextStr NSSCMSDigestContext; + +typedef struct NSSCMSContentInfoPrivateStr NSSCMSContentInfoPrivate; + +typedef SECStatus (*NSSCMSGenericWrapperDataCallback)(NSSCMSGenericWrapperData *); +typedef void (*NSSCMSGenericWrapperDataDestroy)(NSSCMSGenericWrapperData *); + +extern const SEC_ASN1Template NSSCMSGenericWrapperDataTemplate[]; +extern const SEC_ASN1Template NSS_PointerToCMSGenericWrapperDataTemplate[]; + +SEC_ASN1_CHOOSER_DECLARE(NSS_PointerToCMSGenericWrapperDataTemplate) +SEC_ASN1_CHOOSER_DECLARE(NSSCMSGenericWrapperDataTemplate) + +/* + * Type of function passed to NSSCMSDecode or NSSCMSDecoderStart. + * If specified, this is where the content bytes (only) will be "sent" + * as they are recovered during the decoding. + * And: + * Type of function passed to NSSCMSEncode or NSSCMSEncoderStart. + * This is where the DER-encoded bytes will be "sent". + * + * XXX Should just combine this with NSSCMSEncoderContentCallback type + * and use a simpler, common name. + */ +typedef void (*NSSCMSContentCallback)(void *arg, const char *buf, unsigned long len); + +/* + * Type of function passed to NSSCMSDecode or NSSCMSDecoderStart + * to retrieve the decryption key. This function is intended to be + * used for EncryptedData content info's which do not have a key available + * in a certificate, etc. + */ +typedef PK11SymKey *(*NSSCMSGetDecryptKeyCallback)(void *arg, SECAlgorithmID *algid); + +/* ============================================================================= + * ENCAPSULATED CONTENTINFO & CONTENTINFO + */ + +union NSSCMSContentUnion { + /* either unstructured */ + SECItem *data; + /* or structured data */ + NSSCMSDigestedData *digestedData; + NSSCMSEncryptedData *encryptedData; + NSSCMSEnvelopedData *envelopedData; + NSSCMSSignedData *signedData; + NSSCMSGenericWrapperData *genericData; + /* or anonymous pointer to something */ + void *pointer; +}; + +struct NSSCMSContentInfoStr { + SECItem contentType; + NSSCMSContent content; + /* --------- local; not part of encoding --------- */ + SECOidData *contentTypeTag; + + /* additional info for encryptedData and envelopedData */ + /* we waste this space for signedData and digestedData. sue me. */ + + SECAlgorithmID contentEncAlg; + SECItem *rawContent; /* encrypted DER, optional */ + /* XXXX bytes not encrypted, but encoded? */ + /* --------- local; not part of encoding --------- */ + PK11SymKey *bulkkey; /* bulk encryption key */ + int keysize; /* size of bulk encryption key + * (only used by creation code) */ + SECOidTag contentEncAlgTag; /* oid tag of encryption algorithm + * (only used by creation code) */ + NSSCMSContentInfoPrivate *privateInfo; /* place for NSS private info */ + void *reserved; /* keep binary compatibility */ +}; + +/* ============================================================================= + * MESSAGE + */ + +struct NSSCMSMessageStr { + NSSCMSContentInfo contentInfo; /* "outer" cinfo */ + /* --------- local; not part of encoding --------- */ + PLArenaPool *poolp; + PRBool poolp_is_ours; + int refCount; + /* properties of the "inner" data */ + SECAlgorithmID **detached_digestalgs; + SECItem **detached_digests; + void *pwfn_arg; + NSSCMSGetDecryptKeyCallback decrypt_key_cb; + void *decrypt_key_cb_arg; +}; + +/* ============================================================================ + * GENERIC WRAPPER + * + * used for user defined types. + */ +struct NSSCMSGenericWrapperDataStr { + NSSCMSContentInfo contentInfo; + /* ---- local; not part of encoding ------ */ + NSSCMSMessage *cmsg; + /* wrapperspecific data starts here */ +}; + +/* ============================================================================= + * SIGNEDDATA + */ + +struct NSSCMSSignedDataStr { + SECItem version; + SECAlgorithmID **digestAlgorithms; + NSSCMSContentInfo contentInfo; + SECItem **rawCerts; + CERTSignedCrl **crls; + NSSCMSSignerInfo **signerInfos; + /* --------- local; not part of encoding --------- */ + NSSCMSMessage *cmsg; /* back pointer to message */ + SECItem **digests; + CERTCertificate **certs; + CERTCertificateList **certLists; + CERTCertificate **tempCerts; /* temporary certs, needed + * for example for signature + * verification */ +}; +#define NSS_CMS_SIGNED_DATA_VERSION_BASIC 1 /* what we *create* */ +#define NSS_CMS_SIGNED_DATA_VERSION_EXT 3 /* what we *create* */ + +typedef enum { + NSSCMSVS_Unverified = 0, + NSSCMSVS_GoodSignature = 1, + NSSCMSVS_BadSignature = 2, + NSSCMSVS_DigestMismatch = 3, + NSSCMSVS_SigningCertNotFound = 4, + NSSCMSVS_SigningCertNotTrusted = 5, + NSSCMSVS_SignatureAlgorithmUnknown = 6, + NSSCMSVS_SignatureAlgorithmUnsupported = 7, + NSSCMSVS_MalformedSignature = 8, + NSSCMSVS_ProcessingError = 9 +} NSSCMSVerificationStatus; + +typedef enum { + NSSCMSSignerID_IssuerSN = 0, + NSSCMSSignerID_SubjectKeyID = 1 +} NSSCMSSignerIDSelector; + +struct NSSCMSSignerIdentifierStr { + NSSCMSSignerIDSelector identifierType; + union { + CERTIssuerAndSN *issuerAndSN; + SECItem *subjectKeyID; + } id; +}; + +struct NSSCMSSignerInfoStr { + SECItem version; + NSSCMSSignerIdentifier signerIdentifier; + SECAlgorithmID digestAlg; + NSSCMSAttribute **authAttr; + SECAlgorithmID digestEncAlg; + SECItem encDigest; + NSSCMSAttribute **unAuthAttr; + /* --------- local; not part of encoding --------- */ + NSSCMSMessage *cmsg; /* back pointer to message */ + CERTCertificate *cert; + CERTCertificateList *certList; + PRTime signingTime; + NSSCMSVerificationStatus verificationStatus; + SECKEYPrivateKey *signingKey; /* Used if we're using subjKeyID*/ + SECKEYPublicKey *pubKey; +}; +#define NSS_CMS_SIGNER_INFO_VERSION_ISSUERSN 1 /* what we *create* */ +#define NSS_CMS_SIGNER_INFO_VERSION_SUBJKEY 3 /* what we *create* */ + +typedef enum { + NSSCMSCM_None = 0, + NSSCMSCM_CertOnly = 1, + NSSCMSCM_CertChain = 2, + NSSCMSCM_CertChainWithRoot = 3 +} NSSCMSCertChainMode; + +/* ============================================================================= + * ENVELOPED DATA + */ +struct NSSCMSEnvelopedDataStr { + SECItem version; + NSSCMSOriginatorInfo *originatorInfo; /* optional */ + NSSCMSRecipientInfo **recipientInfos; + NSSCMSContentInfo contentInfo; + NSSCMSAttribute **unprotectedAttr; + /* --------- local; not part of encoding --------- */ + NSSCMSMessage *cmsg; /* back pointer to message */ +}; +#define NSS_CMS_ENVELOPED_DATA_VERSION_REG 0 /* what we *create* */ +#define NSS_CMS_ENVELOPED_DATA_VERSION_ADV 2 /* what we *create* */ + +struct NSSCMSOriginatorInfoStr { + SECItem **rawCerts; + CERTSignedCrl **crls; + /* --------- local; not part of encoding --------- */ + CERTCertificate **certs; +}; + +/* ----------------------------------------------------------------------------- + * key transport recipient info + */ +typedef enum { + NSSCMSRecipientID_IssuerSN = 0, + NSSCMSRecipientID_SubjectKeyID = 1, + NSSCMSRecipientID_BrandNew = 2 +} NSSCMSRecipientIDSelector; + +struct NSSCMSRecipientIdentifierStr { + NSSCMSRecipientIDSelector identifierType; + union { + CERTIssuerAndSN *issuerAndSN; + SECItem *subjectKeyID; + } id; +}; +typedef struct NSSCMSRecipientIdentifierStr NSSCMSRecipientIdentifier; + +struct NSSCMSKeyTransRecipientInfoStr { + SECItem version; + NSSCMSRecipientIdentifier recipientIdentifier; + SECAlgorithmID keyEncAlg; + SECItem encKey; +}; +typedef struct NSSCMSKeyTransRecipientInfoStr NSSCMSKeyTransRecipientInfo; + +/* + * View comments before NSSCMSRecipientInfoStr for purpose of this + * structure. + */ +struct NSSCMSKeyTransRecipientInfoExStr { + NSSCMSKeyTransRecipientInfo recipientInfo; + int version; /* version of this structure (0) */ + SECKEYPublicKey *pubKey; +}; + +typedef struct NSSCMSKeyTransRecipientInfoExStr NSSCMSKeyTransRecipientInfoEx; + +#define NSS_CMS_KEYTRANS_RECIPIENT_INFO_VERSION_ISSUERSN 0 /* what we *create* */ +#define NSS_CMS_KEYTRANS_RECIPIENT_INFO_VERSION_SUBJKEY 2 /* what we *create* */ + +/* ----------------------------------------------------------------------------- + * key agreement recipient info + */ +struct NSSCMSOriginatorPublicKeyStr { + SECAlgorithmID algorithmIdentifier; + SECItem publicKey; /* bit string! */ +}; +typedef struct NSSCMSOriginatorPublicKeyStr NSSCMSOriginatorPublicKey; + +typedef enum { + NSSCMSOriginatorIDOrKey_IssuerSN = 0, + NSSCMSOriginatorIDOrKey_SubjectKeyID = 1, + NSSCMSOriginatorIDOrKey_OriginatorPublicKey = 2 +} NSSCMSOriginatorIDOrKeySelector; + +struct NSSCMSOriginatorIdentifierOrKeyStr { + NSSCMSOriginatorIDOrKeySelector identifierType; + union { + CERTIssuerAndSN *issuerAndSN; /* static-static */ + SECItem *subjectKeyID; /* static-static */ + NSSCMSOriginatorPublicKey originatorPublicKey; /* ephemeral-static */ + } id; +}; +typedef struct NSSCMSOriginatorIdentifierOrKeyStr NSSCMSOriginatorIdentifierOrKey; + +struct NSSCMSOtherKeyAttributeStr { + SECItem keyAttrId; + SECItem keyAttr; /* optional */ +}; + +typedef struct NSSCMSOtherKeyAttributeStr NSSCMSOtherKeyAttribute; + +struct NSSCMSRecipientKeyIdentifierStr { + SECItem *subjectKeyIdentifier; + SECItem *date; /* optional */ + NSSCMSOtherKeyAttribute *other; /* optional */ +}; +typedef struct NSSCMSRecipientKeyIdentifierStr NSSCMSRecipientKeyIdentifier; + +typedef enum { + NSSCMSKeyAgreeRecipientID_IssuerSN = 0, + NSSCMSKeyAgreeRecipientID_RKeyID = 1 +} NSSCMSKeyAgreeRecipientIDSelector; + +struct NSSCMSKeyAgreeRecipientIdentifierStr { + NSSCMSKeyAgreeRecipientIDSelector identifierType; + union { + CERTIssuerAndSN *issuerAndSN; + NSSCMSRecipientKeyIdentifier recipientKeyIdentifier; + } id; +}; +typedef struct NSSCMSKeyAgreeRecipientIdentifierStr NSSCMSKeyAgreeRecipientIdentifier; + +struct NSSCMSRecipientEncryptedKeyStr { + NSSCMSKeyAgreeRecipientIdentifier recipientIdentifier; + SECItem encKey; +}; +typedef struct NSSCMSRecipientEncryptedKeyStr NSSCMSRecipientEncryptedKey; + +struct NSSCMSKeyAgreeRecipientInfoStr { + SECItem version; + NSSCMSOriginatorIdentifierOrKey originatorIdentifierOrKey; + SECItem ukm; /* optional */ + SECAlgorithmID keyEncAlg; + NSSCMSRecipientEncryptedKey **recipientEncryptedKeys; +}; +typedef struct NSSCMSKeyAgreeRecipientInfoStr NSSCMSKeyAgreeRecipientInfo; + +#define NSS_CMS_KEYAGREE_RECIPIENT_INFO_VERSION 3 /* what we *create* */ + +/* ----------------------------------------------------------------------------- + * KEK recipient info + */ +struct NSSCMSKEKIdentifierStr { + SECItem keyIdentifier; + SECItem *date; /* optional */ + NSSCMSOtherKeyAttribute *other; /* optional */ +}; +typedef struct NSSCMSKEKIdentifierStr NSSCMSKEKIdentifier; + +struct NSSCMSKEKRecipientInfoStr { + SECItem version; + NSSCMSKEKIdentifier kekIdentifier; + SECAlgorithmID keyEncAlg; + SECItem encKey; +}; +typedef struct NSSCMSKEKRecipientInfoStr NSSCMSKEKRecipientInfo; + +#define NSS_CMS_KEK_RECIPIENT_INFO_VERSION 4 /* what we *create* */ + +/* ----------------------------------------------------------------------------- + * recipient info + */ + +typedef enum { + NSSCMSRecipientInfoID_KeyTrans = 0, + NSSCMSRecipientInfoID_KeyAgree = 1, + NSSCMSRecipientInfoID_KEK = 2 +} NSSCMSRecipientInfoIDSelector; + +/* + * In order to preserve backwards binary compatibility when implementing + * creation of Recipient Info's that uses subjectKeyID in the + * keyTransRecipientInfo we need to stash a public key pointer in this + * structure somewhere. We figured out that NSSCMSKeyTransRecipientInfo + * is the smallest member of the ri union. We're in luck since that's + * the very structure that would need to use the public key. So we created + * a new structure NSSCMSKeyTransRecipientInfoEx which has a member + * NSSCMSKeyTransRecipientInfo as the first member followed by a version + * and a public key pointer. This way we can keep backwards compatibility + * without changing the size of this structure. + * + * BTW, size of structure: + * NSSCMSKeyTransRecipientInfo: 9 ints, 4 pointers + * NSSCMSKeyAgreeRecipientInfo: 12 ints, 8 pointers + * NSSCMSKEKRecipientInfo: 10 ints, 7 pointers + * + * The new structure: + * NSSCMSKeyTransRecipientInfoEx: sizeof(NSSCMSKeyTransRecipientInfo) + + * 1 int, 1 pointer + */ + +struct NSSCMSRecipientInfoStr { + NSSCMSRecipientInfoIDSelector recipientInfoType; + union { + NSSCMSKeyTransRecipientInfo keyTransRecipientInfo; + NSSCMSKeyAgreeRecipientInfo keyAgreeRecipientInfo; + NSSCMSKEKRecipientInfo kekRecipientInfo; + NSSCMSKeyTransRecipientInfoEx keyTransRecipientInfoEx; + } ri; + /* --------- local; not part of encoding --------- */ + NSSCMSMessage *cmsg; /* back pointer to message */ + CERTCertificate *cert; /* recipient's certificate */ +}; + +/* ============================================================================= + * DIGESTED DATA + */ +struct NSSCMSDigestedDataStr { + SECItem version; + SECAlgorithmID digestAlg; + NSSCMSContentInfo contentInfo; + SECItem digest; + /* --------- local; not part of encoding --------- */ + NSSCMSMessage *cmsg; /* back pointer */ + SECItem cdigest; /* calculated digest */ +}; +#define NSS_CMS_DIGESTED_DATA_VERSION_DATA 0 /* what we *create* */ +#define NSS_CMS_DIGESTED_DATA_VERSION_ENCAP 2 /* what we *create* */ + +/* ============================================================================= + * ENCRYPTED DATA + */ +struct NSSCMSEncryptedDataStr { + SECItem version; + NSSCMSContentInfo contentInfo; + NSSCMSAttribute **unprotectedAttr; /* optional */ + /* --------- local; not part of encoding --------- */ + NSSCMSMessage *cmsg; /* back pointer */ +}; +#define NSS_CMS_ENCRYPTED_DATA_VERSION 0 /* what we *create* */ +#define NSS_CMS_ENCRYPTED_DATA_VERSION_UPATTR 2 /* what we *create* */ + +/* + * ***************************************************************************** + * ***************************************************************************** + * ***************************************************************************** + */ + +/* + * See comment above about this type not really belonging to CMS. + */ +struct NSSCMSAttributeStr { + /* The following fields make up an encoded Attribute: */ + SECItem type; + SECItem **values; /* data may or may not be encoded */ + /* The following fields are not part of an encoded Attribute: */ + SECOidData *typeTag; + PRBool encoded; /* when true, values are encoded */ +}; + +#endif /* _CMST_H_ */ diff --git a/illumos-x86_64/usr/include/mps/crmf.h b/illumos-x86_64/usr/include/mps/crmf.h new file mode 100644 index 00000000..c56e2891 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/crmf.h @@ -0,0 +1,1741 @@ +/* -*- Mode: C; tab-width: 8 -*-*/ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _CRMF_H_ +#define _CRMF_H_ + +#include "seccomon.h" +#include "cert.h" +#include "crmft.h" +#include "secoid.h" +#include "secpkcs7.h" + +SEC_BEGIN_PROTOS + +/* + * FUNCTION: CRMF_EncodeCertReqMsg + * INPUTS: + * inCertReqMsg + * The Certificate Request Message to be encoded. + * fn + * A Callback function that the ASN1 encoder calls whenever + * the encoder wants to write out some DER encoded bytes. + * arg + * An opaque pointer that gets passed to the function fn + * OUTPUT: + * The function fn will be called multiple times. Look at the + * comments in crmft.h where the CRMFEncoderOutputCallback type is + * defined for information on proper behavior of the function fn. + * RETURN: + * SECSuccess if encoding was successful. Any other return value + * indicates an error occurred during encoding. + */ +extern SECStatus +CRMF_EncodeCertReqMsg(CRMFCertReqMsg *inCertReqMsg, + CRMFEncoderOutputCallback fn, + void *arg); + +/* + * FUNCTION: CRMF_EncoderCertRequest + * INPUTS: + * inCertReq + * The Certificate Request to be encoded. + * fn + * A Callback function that the ASN1 encoder calls whenever + * the encoder wants to write out some DER encoded bytes. + * arg + * An opaque pointer that gets passed to the function fn. + * OUTPUT: + * The function fn will be called, probably multiple times whenever + * the ASN1 encoder wants to write out DER-encoded bytes. Look at the + * comments in crmft.h where the CRMFEncoderOutputCallback type is + * defined for information on proper behavior of the function fn. + * RETURN: + * SECSuccess if encoding was successful. Any other return value + * indicates an error occurred during encoding. + */ +extern SECStatus CRMF_EncodeCertRequest(CRMFCertRequest *inCertReq, + CRMFEncoderOutputCallback fn, + void *arg); +/* + * FUNCTION: CRMF_EncodeCertReqMessages + * INPUTS: + * inCertReqMsgs + * An array of pointers to the Certificate Request Messages + * to encode. The user must place a NULL pointer in the index + * after the last message to be encoded. When the library runs + * into the NULL pointer, the library assumes there are no more + * messages to encode. + * fn + * A Callback function that the ASN1 encoder calls whenever + * the encoder wants to write out some DER encoded byts. + * arg + * An opaque pointer that gets passed to the function fn. + * + * NOTES: + * The parameter inCertReqMsgs needs to be an array with a NULL pointer + * to signal the end of messages. An array in the form of + * {m1, m2, m3, NULL, m4, ...} will only encode the messages m1, m2, and + * m3. All messages from m4 on will not be looked at by the library. + * + * OUTPUT: + * The function fn will be called, probably multiple times. Look at the + * comments in crmft.h where the CRMFEncoderOutputCallback type is + * defined for information on proper behavior of the function fn. + * + * RETURN: + * SECSuccess if encoding the Certificate Request Messages was successful. + * Any other return value indicates an error occurred while encoding the + * certificate request messages. + */ +extern SECStatus +CRMF_EncodeCertReqMessages(CRMFCertReqMsg **inCertReqMsgs, + CRMFEncoderOutputCallback fn, + void *arg); + +/* + * FUNCTION: CRMF_CreateCertReqMsg + * INPUTS: + * NONE + * OUTPUT: + * An empty CRMF Certificate Request Message. + * Before encoding this message, the user must set + * the ProofOfPossession field and the certificate + * request which are necessary for the full message. + * After the user no longer needs this CertReqMsg, + * the user must call CRMF_DestroyCertReqMsg to free + * all memory associated with the Certificate Request + * Message. + * RETURN: + * A pointer to a Certificate Request Message. The user + * must pass the return value of this function to + * CRMF_DestroyCertReqMsg after the Certificate Request + * Message is no longer necessary. + */ +extern CRMFCertReqMsg *CRMF_CreateCertReqMsg(void); + +/* + * FUNCTION: CRMF_DestroyCertReqMsg + * INPUTS: + * inCertReqMsg + * The Certificate Request Message to destroy. + * NOTES: + * This function frees all the memory used for the Certificate + * Request Message and all the memory used in making copies of + * fields of elelments of the message, eg. the Proof Of Possession + * filed and the Cetificate Request. + * RETURN: + * SECSuccess if destruction was successful. Any other return value + * indicates an error while trying to free the memory associated + * with inCertReqMsg. + * + */ +extern SECStatus CRMF_DestroyCertReqMsg(CRMFCertReqMsg *inCertReqMsg); + +/* + * FUNCTION: CRMF_CertReqMsgSetCertRequest + * INPUTS: + * inCertReqMsg + * The Certificate Request Message that the function will set + * the certificate request for. + * inCertReq + * The Certificate Request that will be added to the Certificate + * Request Message. + * NOTES: + * This function will make a copy of the Certificate Request passed in + * and store it as part of the Certificate Request Message. Therefore, + * the user must not call this function until the Certificate Request + * has been fully built and is ready to be encoded. + * RETURN: + * SECSuccess + * If copying the Certificate as a member of the Certificate + * request message was successful. + * Any other return value indicates a failure to copy the Certificate + * Request and make it a part of the Certificate Request Message. + */ +extern SECStatus CRMF_CertReqMsgSetCertRequest(CRMFCertReqMsg *inCertReqMsg, + CRMFCertRequest *inCertReq); + +/* + * FUNCTION: CRMF_CreateCertRequest + * INPUTS: + * inRequestID + * The ID that will be associated with this certificate request. + * OUTPUTS: + * A certificate request which only has the requestID set. + * NOTES: + * The user must call the function CRMF_DestroyCertRequest when + * the returned value is no longer needed. This is usually the + * case after fully constructing the Certificate Request and then + * calling the function CRMF_CertReqMsgSetCertRequest. + * RETURN: + * A pointer to the new Certificate Request. A NULL return value + * indicates an error in creating the Certificate Request. + */ +extern CRMFCertRequest *CRMF_CreateCertRequest(PRUint32 inRequestID); + +/* + * FUNCTION: CRMF_DestroyCertRequest + * INPUTS: + * inCertReq + * The Certificate Request that will be destroyed. + * RETURN: + * SECSuccess + * If freeing the memory associated with the certificate request + * was successful. + * Any other return value indicates an error while trying to free the + * memory. + */ +extern SECStatus CRMF_DestroyCertRequest(CRMFCertRequest *inCertReq); + +/* + * FUNCTION: CRMF_CreateCertExtension + * INPUTS: + * id + * The SECOidTag to associate with this CertExtension. This must + * correspond to a valid Certificate Extension, if not the function + * will fail. + * isCritical + * A boolean value stating if the extension value is crtical. PR_TRUE + * means the value is crtical. PR_FALSE indicates the value is not + * critical. + * data + * This is the data associated with the extension. The user of the + * library is responsible for making sure the value passed in is a + * valid interpretation of the certificate extension. + * NOTES: + * Use this function to create CRMFCertExtension Structures which will + * then be passed to CRMF_AddFieldToCertTemplate as part of the + * CRMFCertCreationInfo.extensions The user must call + * CRMF_DestroyCertExtension after the extension has been added to a certifcate + * and the extension is no longer needed. + * + * RETURN: + * A pointer to a newly created CertExtension. A return value of NULL + * indicates the id passed in was an invalid certificate extension. + */ +extern CRMFCertExtension *CRMF_CreateCertExtension(SECOidTag id, + PRBool isCritical, + SECItem *data); + +/* + * FUNCTION: CMRF_DestroyCertExtension + * INPUTS: + * inExtension + * The Cert Extension to destroy + * NOTES: + * Destroy a structure allocated by CRMF_CreateCertExtension. + * + * RETURN: + * SECSuccess if freeing the memory associated with the certificate extension + * was successful. Any other error indicates an error while freeing the + * memory. + */ +extern SECStatus CRMF_DestroyCertExtension(CRMFCertExtension *inExtension); + +/* + * FUNCTION: CRMF_CertRequestSetTemplateField + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * inTemplateField + * An enumeration that indicates which field of the Certificate + * template to add. + * data + * A generic pointer that will be type cast according to the + * table under NOTES and used as the key for adding to the + * certificate template; + * NOTES: + * + * Below is a table that tells what type to pass in as data + * depending on the template field one wants to set. + * + * Look in crmft.h for the definition of CRMFCertTemplateField. + * + * In all cases, the library makes copies of the data passed in. + * + * CRMFCertTemplateField Type of data What data means + * --------------------- ------------ --------------- + * crmfVersion long * The version of + * the certificate + * to be created. + * + * crmfSerialNumber long * The serial number + * for the cert to be + * created. + * + * crmfSigningAlg SECAlgorithm * The ASN.1 object ID for + * the algorithm used in encoding + * the certificate. + * + * crmfIssuer CERTName * Certificate Library + * representation of the ASN1 type + * Name from X.509 + * + * crmfValidity CRMFValidityCreationInfo * At least one of the two + * fields in the structure must + * be present. A NULL pointer + * in the structure indicates + * that member should not be + * added. + * + * crmfSubject CERTName * Certificate Library + * representation of the ASN1 type + * Name from X.509 + * + * crmfPublicKey CERTSubjectPublicKeyInfo * The public key info for the + * certificate being requested. + * + * crmfIssuerUID SECItem * A bit string representation + * of the issuer UID. NOTE: The + * length is the number of bits + * and not the number of bytes. + * + * crmfSubjectUID SECItem* A bit string representation + * of the subject UID. NOTE: The + * length is the number of bits + * and not the number of bytes. + * + * crmfExtension CRMFCertExtCreationInfo * A pointer to the structure + * populated with an array of + * of certificate extensions + * and an integer that tells + * how many elements are in the + * array. Look in crmft.h for + * the definition of + * CRMFCertExtCreationInfo + * RETURN: + * SECSuccess if adding the desired field to the template was successful. + * Any other return value indicates failure when trying to add the field + * to the template. + * + */ +extern SECStatus +CRMF_CertRequestSetTemplateField(CRMFCertRequest *inCertReq, + CRMFCertTemplateField inTemplateField, + void *data); + +/* + * FUNCTION: CRMF_CertRequestIsFieldPresent + * INPUTS: + * inCertReq + * The certificate request to operate on. + * inTemplateField + * The enumeration for the template field the user wants to query + * about. + * NOTES: + * This function checks to see if the the field associated with inTemplateField + * enumeration is already present in the certificate request passed in. + * + * RETURN: + * The function returns PR_TRUE if the field associated with inTemplateField + * is already present in the certificate request. If the field is not present + * the function returns PR_FALSE. + */ +extern PRBool +CRMF_CertRequestIsFieldPresent(CRMFCertRequest *inCertReq, + CRMFCertTemplateField inTemplateField); + +/* + * FUNCTION: CRMF_CertRequestIsControlPresent + * INPUTS: + * inCertReq + * The certificate request to operate on. + * inControlType + * The type of control to look for. + * NOTES: + * This function looks at the control present in the certificate request + * and returns PR_TRUE iff a control of type inControlType already exists. + * The CRMF draft does not explicitly state that two controls of the same + * type can not exist within the same request. So the library will not + * cause an error if you try to add a control and one of the same type + * already exists. It is up to the application to ensure that multiple + * controls of the same type do not exist, if that is the desired behavior + * by the application. + * + * RETURN: + * The function returns PR_TRUE if a control of type inControlType already + * exists in the certificate request. If a control of type inControlType + * does not exist, the function will return PR_FALSE. + */ +extern PRBool +CRMF_CertRequestIsControlPresent(CRMFCertRequest *inCertReq, + CRMFControlType inControlType); + +/* + * FUNCTION: CRMF_CertRequestSetRegTokenControl + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * value + * The UTF8 value which will be the Registration Token Control + * for this Certificate Request. + * NOTES: + * The library does no verification that the value passed in is + * a valid UTF8 value. The caller must make sure of this in order + * to get an encoding that is valid. The library will ultimately + * encode this value as it was passed in. + * RETURN: + * SECSucces on successful addition of the Registration Token Control. + * Any other return value indicates an unsuccessful attempt to add the + * control. + * + */ +extern SECStatus CRMF_CertRequestSetRegTokenControl(CRMFCertRequest *inCertReq, + SECItem *value); + +/* + * FUNCTION: CRMF_CertRequestSetAuthenticatorControl + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * value + * The UTF8 value that will become the Authenticator Control + * for the passed in Certificate Request. + * NOTES: + * The library does no verification that the value passed in is + * a valid UTF8 value. The caller must make sure of this in order + * to get an encoding that is valid. The library will ultimately + * encode this value as it was passed in. + * RETURN: + * SECSucces on successful addition of the Authenticator Control. + * Any other return value indicates an unsuccessful attempt to add the + * control. + */ +extern SECStatus +CRMF_CertRequestSetAuthenticatorControl(CRMFCertRequest *inCertReq, + SECItem *value); + +/* + * FUNCTION: CRMF_CreateEncryptedKeyWithencryptedValue + * INPUTS: + * inPrivKey + * This is the private key associated with a certificate that is + * being requested. This structure will eventually wind up as + * a part of the PKIArchiveOptions Control. + * inCACert + * This is the certificate for the CA that will be receiving the + * certificate request for the private key passed in. + * OUTPUT: + * A CRMFEncryptedKey that can ultimately be used as part of the + * PKIArchiveOptions Control. + * + * RETURN: + * A pointer to a CRMFEncyptedKey. A NULL return value indicates an erro + * during the creation of the encrypted key. + */ +extern CRMFEncryptedKey * +CRMF_CreateEncryptedKeyWithEncryptedValue(SECKEYPrivateKey *inPrivKey, + CERTCertificate *inCACert); + +/* + * FUNCTION: CRMF_DestroyEncryptedKey + * INPUTS: + * inEncrKey + * The CRMFEncryptedKey to be destroyed. + * NOTES: + * Frees all memory associated with the CRMFEncryptedKey passed in. + * RETURN: + * SECSuccess if freeing the memory was successful. Any other return + * value indicates an error while freeig the memroy. + */ +extern SECStatus CRMF_DestroyEncryptedKey(CRMFEncryptedKey *inEncrKey); + +/* + * FUNCTION: CRMF_CreatePKIArchiveOptions + * INPUTS: + * inType + * An enumeration value indicating which option for + * PKIArchiveOptions to use. + * data + * A pointer that will be type-cast and de-referenced according + * to the table under NOTES. + * NOTES: + * A table listing what should be passed in as data + * ------------------------------------------------ + * + * inType data + * ------ ---- + * crmfEncryptedPrivateKey CRMFEncryptedKey* + * crmfKeyGenParameters SECItem*(This needs to be an octet string) + * crmfArchiveRemGenPrivKey PRBool* + * + * RETURN: + * A pointer the a CRMFPKIArchiveOptions that can be added to a Certificate + * Request. A NULL pointer indicates an error occurred while creating + * the CRMFPKIArchiveOptions Structure. + */ +extern CRMFPKIArchiveOptions * +CRMF_CreatePKIArchiveOptions(CRMFPKIArchiveOptionsType inType, + void *data); +/* + * FUNCTION: CRMF_DestroyPKIArchiveOptions + * INPUTS: + * inArchOpt + * A pointer to the CRMFPKIArchiveOptions structure to free. + * NOTES: + * Will free all memory associated with 'inArchOpt'. + * RETURN: + * SECSuccess if successful in freeing the memory used by 'inArchOpt' + * Any other return value indicates an error while freeing the memory. + */ +extern SECStatus +CRMF_DestroyPKIArchiveOptions(CRMFPKIArchiveOptions *inArchOpt); + +/* + * FUNCTION: CRMF_CertRequestSetPKIArchiveOptions + * INPUTS: + * inCertReq + * The Certificate Request to add the the options to. + * inOptions + * The Archive Options to add to the Certificate Request. + * NOTES: + * Adds the PKIArchiveOption to the Certificate Request. This is what + * enables Key Escrow to take place through CRMF. The library makes + * its own copy of the information. + * RETURN: + * SECSuccess if successful in adding the ArchiveOptions to the Certificate + * request. Any other return value indicates an error when trying to add + * the Archive Options to the Certificate Request. + */ +extern SECStatus +CRMF_CertRequestSetPKIArchiveOptions(CRMFCertRequest *inCertReq, + CRMFPKIArchiveOptions *inOptions); + +/* + * FUNCTION: CRMF_CertReqMsgGetPOPType + * INPUTS: + * inCertReqMsg + * The Certificate Request Message to operate on. + * NOTES: + * Returns an enumeration value indicating the method of Proof + * of Possession that was used for the passed in Certificate Request + * Message. + * RETURN: + * An enumeration indicating what method for Proof Of Possession is + * being used in this Certificate Request Message. Look in the file + * crmft.h for the definition of CRMFPOPChoice for the possible return + * values. + */ +extern CRMFPOPChoice CRMF_CertReqMsgGetPOPType(CRMFCertReqMsg *inCertReqMsg); + +/* + * FUNCTION: CRMF_CertReqMsgSetRAVerifiedPOP + * INPUT: + * InCertReqMsg + * The Certificate Request Message to operate on. + * NOTES: + * This function will set the method of Proof Of Possession to + * crmfRAVerified which means the RA has already verified the + * requester does possess the private key. + * RETURN: + * SECSuccess if adding RAVerified to the message is successful. + * Any other message indicates an error while trying to add RAVerified + * as the Proof of Possession. + */ +extern SECStatus CRMF_CertReqMsgSetRAVerifiedPOP(CRMFCertReqMsg *inCertReqMsg); + +/* + * FUNCTION: CRMF_CertReqMsgSetSignaturePOP + * INPUT: + * inCertReqMsg + * The Certificate Request Message to add the SignaturePOP to. + * inPrivKey + * The Private Key which corresponds to the the Certificate Request + * Message. + * inPubKey + * The Public Key which corresponds to the Private Key passed in. + * inCertForInput + * A Certificate that in the future may be used to create + * POPOSigningKeyInput. + * fn + * A callback for retrieving a password which may be used in the + * future to generate POPOSigningKeyInput. + * arg + * An opaque pointer that would be passed to fn whenever it is + * called. + * NOTES: + * Adds Proof Of Possession to the CertRequest using the signature field + * of the ProofOfPossession field. NOTE: In order to use this option, + * the certificate template must contain the publicKey at the very minimum. + * + * If you don't want the function to generate POPOSigningKeyInput, then + * make sure the cert template already contains the subject and public key + * values. Currently creating POPOSigningKeyInput is not supported, so + * a Message passed to this function must have the publicKey and the subject + * as part of the template + * + * This will take care of creating the entire POPOSigningKey structure + * that will become part of the message. + * + * inPrivKey is the key to be used in the signing operation when creating + * POPOSigningKey structure. This should be the key corresponding to + * the certificate being requested. + * + * inCertForInput will be used if POPOSigningKeyInput needs to be generated. + * It will be used in generating the authInfo.sender field. If the parameter + * is not passed in then authInfo.publicKeyMAC will be generated instead. + * If passed in, this certificate needs to be a valid certificate. + * + * The last 3 arguments are for future compatibility in case we ever want to + * support generating POPOSigningKeyInput. Pass in NULL for all 3 if you + * definitely don't want the function to even try to generate + * POPOSigningKeyInput. If you try to use POPOSigningKeyInput, the function + * will fail. + * + * RETURN: + * SECSuccess if adding the Signature Proof Of Possession worked. + * Any other return value indicates an error in trying to add + * the Signature Proof Of Possession. + */ +extern SECStatus +CRMF_CertReqMsgSetSignaturePOP(CRMFCertReqMsg *inCertReqMsg, + SECKEYPrivateKey *inPrivKey, + SECKEYPublicKey *inPubKey, + CERTCertificate *inCertForInput, + CRMFMACPasswordCallback fn, + void *arg); + +/* + * FUNCTION: CRMF_CertReqMsgSetKeyEnciphermentPOP + * INPUTS: + * inCertReqMsg + * The Certificate Request Message to operate on. + * inKeyChoice + * An enumeration indicating which POPOPrivKey Choice to use + * in constructing the KeyEnciphermentPOP. + * subseqMess + * This parameter must be provided iff inKeyChoice is + * crmfSubsequentMessage. This details how the RA is to respond + * in order to perform Proof Of Possession. Look in crmft.h under + * the definition of CRMFSubseqMessOptions for possible values. + * encPrivKey + * This parameter only needs to be provided if inKeyChoice is + * crmfThisMessage. The item should contain the encrypted private + * key. + * + * NOTES: + * Adds Proof Of Possession using the keyEncipherment field of + * ProofOfPossession. + * + * The function looks at the the inKeyChoice parameter and interprets it in + * in the following manner. + * + * If a parameter is not mentioned under interpretation, the function will not + * look at its value when implementing that case. + * + * inKeyChoice Interpretation + * ----------- -------------- + * crmfThisMessage This options requires that the encrypted private key + * be included in the thisMessage field of POPOPrivKey. + * We don't support this yet, so any clients who want + * to use this feature have to implement a wrapping + * function and agree with the server on how to properly + * wrap the key. That encrypted key must be passed in + * as the encPrivKey parameter. + * + * crmfSubequentMessage Must pass in a value for subseqMess. The value must + * be either CRMFEncrCert or CRMFChallengeResp. The + * parameter encPrivKey will not be looked at in this + * case. + * + * crmfDHMAC This is not a valid option for this function. Passing + * in this value will result in the function returning + * SECFailure. + * RETURN: + * SECSuccess if adding KeyEnciphermentPOP was successful. Any other return + * value indicates an error in adding KeyEnciphermentPOP. + */ +extern SECStatus +CRMF_CertReqMsgSetKeyEnciphermentPOP(CRMFCertReqMsg *inCertReqMsg, + CRMFPOPOPrivKeyChoice inKeyChoice, + CRMFSubseqMessOptions subseqMess, + SECItem *encPrivKey); + +/* + * FUNCTION: CRMF_CertReqMsgSetKeyAgreementPOP + * INPUTS: + * inCertReqMsg + * The Certificate Request Message to operate on. + * inKeyChoice + * An enumeration indicating which POPOPrivKey Choice to use + * in constructing the KeyAgreementPOP. + * subseqMess + * This parameter must be provided iff inKeyChoice is + * crmfSubsequentMessage. This details how the RA is to respond + * in order to perform Proof Of Possession. Look in crmft.h under + * the definition of CRMFSubseqMessOptions for possible values. + * encPrivKey + * This parameter only needs to be provided if inKeyChoice is + * crmfThisMessage. The item should contain the encrypted private + * key. + * Adds Proof Of Possession using the keyAgreement field of + * ProofOfPossession. + * + * The function looks at the the inKeyChoice parameter and interprets it in + * in the following manner. + * + * If a parameter is not mentioned under interpretation, the function will not + * look at its value when implementing that case. + * + * inKeyChoice Interpretation + * ----------- -------------- + * crmfThisMessage This options requires that the encrypted private key + * be included in the thisMessage field of POPOPrivKey. + * We don't support this yet, so any clients who want + * to use this feature have to implement a wrapping + * function and agree with the server on how to properly + * wrap the key. That encrypted key must be passed in + * as the encPrivKey parameter. + * + * crmfSubequentMessage Must pass in a value for subseqMess. The value must + * be either crmfEncrCert or crmfChallengeResp. The + * parameter encPrivKey will not be looked at in this + * case. + * + * crmfDHMAC This option is not supported. + */ +extern SECStatus +CRMF_CertReqMsgSetKeyAgreementPOP(CRMFCertReqMsg *inCertReqMsg, + CRMFPOPOPrivKeyChoice inKeyChoice, + CRMFSubseqMessOptions subseqMess, + SECItem *encPrivKey); + +/* + * FUNCTION: CRMF_CreateCertReqMsgFromDER + * INPUTS: + * buf + * A buffer to the DER-encoded Certificate Request Message. + * len + * The length in bytes of the buffer 'buf' + * NOTES: + * This function passes the buffer to the ASN1 decoder and creates a + * CRMFCertReqMsg structure. Do not try adding any fields to a message + * returned from this function. Specifically adding more Controls or + * Extensions may cause your program to crash. + * + * RETURN: + * A pointer to the Certificate Request Message structure. A NULL return + * value indicates the library was unable to parse the DER. + */ +extern CRMFCertReqMsg *CRMF_CreateCertReqMsgFromDER(const char *buf, long len); + +/* + * FUNCTION: CRMF_CreateCertReqMessagesFromDER + * INPUTS: + * buf + * A buffer to the DER-encoded Certificate Request Messages. + * len + * The length in bytes of buf + * NOTES: + * This function passes the buffer to the ASN1 decoder and creates a + * CRMFCertReqMessages structure. Do not try adding any fields to a message + * derived from this function. Specifically adding more Controls or + * Extensions may cause your program to crash. + * The user must call CRMF_DestroyCertReqMessages after the return value is + * no longer needed, ie when all individual messages have been extracted. + * + * RETURN: + * A pointer to the Certificate Request Messages structure. A NULL return + * value indicates the library was unable to parse the DER. + */ +extern CRMFCertReqMessages * +CRMF_CreateCertReqMessagesFromDER(const char *buf, long len); + +/* + * FUNCTION: CRMF_DestroyCertReqMessages + * INPUTS + * inCertReqMsgs + * The Messages to destroy. + * RETURN: + * SECSuccess if freeing the memory was done successfully. Any other + * return value indicates an error in freeing up memory. + */ +extern SECStatus +CRMF_DestroyCertReqMessages(CRMFCertReqMessages *inCertReqMsgs); + +/* + * FUNCTION: CRMF_CertReqMessagesGetNumMessages + * INPUTS: + * inCertReqMsgs + * The Request Messages to operate on. + * RETURN: + * The number of messages contained in the in the Request Messages + * strucure. + */ +extern int +CRMF_CertReqMessagesGetNumMessages(CRMFCertReqMessages *inCertReqMsgs); + +/* + * FUNCTION: CRMF_CertReqMessagesGetCertReqMsgAtIndex + * INPUTS: + * inReqMsgs + * The Certificate Request Messages to operate on. + * index + * The index of the single message the user wants a copy of. + * NOTES: + * This function returns a copy of the request messages stored at the + * index corresponding to the parameter 'index'. Indexing of the messages + * is done in the same manner as a C array. Meaning the valid index are + * 0...numMessages-1. User must call CRMF_DestroyCertReqMsg when done using + * the return value of this function. + * + * RETURN: + * SECSuccess if copying the message at the requested index was successful. + * Any other return value indicates an invalid index or error while copying + * the single request message. + */ +extern CRMFCertReqMsg * +CRMF_CertReqMessagesGetCertReqMsgAtIndex(CRMFCertReqMessages *inReqMsgs, + int index); + +/* + * FUNCTION: CRMF_CertReqMsgGetID + * INPUTS: + * inCertReqMsg + * The Certificate Request Message to get the ID from. + * destID + * A pointer to where the library can place the ID of the Message. + * RETURN: + * SECSuccess if the function was able to retrieve the ID and place it + * at *destID. Any other return value indicates an error meaning the value + * in *destId is un-reliable and should not be used by the caller of this + * function. + * + */ +extern SECStatus CRMF_CertReqMsgGetID(CRMFCertReqMsg *inCertReqMsg, + long *destID); + +/* + * FUNCTION: CRMF_DoesRequestHaveField + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * inField + * An enumeration indicating which filed of the certificate template + * to look for. + * NOTES: + * All the fields in a certificate template are optional. This function + * checks to see if the requested field is present. Look in crmft.h at the + * definition of CRMFCertTemplateField for possible values for possible + * querying. + * + * RETURN: + * PR_TRUE iff the field corresponding to 'inField' has been specified as part + * of 'inCertReq' + * PR_FALSE iff the field corresponding to 'inField' has not been speicified + * as part of 'inCertReq' + * + */ +extern PRBool CRMF_DoesRequestHaveField(CRMFCertRequest *inCertReq, + CRMFCertTemplateField inField); + +/* + * FUNCTION: CRMF_CertReqMsgGetCertRequest + * INPUTS: + * inCertReqMsg + * The Certificate Request Message to operate on. + * NOTES: + * This function returns a copy of the Certificate Request to the user. + * The user can keep adding to this request and then making it a part + * of another message. After the user no longer wants to use the + * returned request, the user must call CRMF_DestroyCertRequest and + * pass it the request returned by this function. + * RETURN: + * A pointer to a copy of the certificate request contained by the message. + * A NULL return value indicates an error occurred while copying the + * certificate request. + */ +extern CRMFCertRequest * +CRMF_CertReqMsgGetCertRequest(CRMFCertReqMsg *inCertReqMsg); + +/* + * FUNCTION: CRMF_CertRequestGetCertTemplateVersion + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * version + * A pointer to where the library can store the version contatined + * in the certificate template within the certifcate request. + * RETURN: + * SECSuccess if the Certificate template contains the version field. In + * this case, *version will hold the value of the certificate template + * version. + * SECFailure indicates that version field was not present as part of + * of the certificate template. + */ +extern SECStatus +CRMF_CertRequestGetCertTemplateVersion(CRMFCertRequest *inCertReq, + long *version); + +/* + * FUNCTION: CRMF_CertRequestGetCertTemplateSerialNumber + * INPUTS: + * inCertReq + * The certificate request to operate on. + * serialNumber + * A pointer where the library can put the serial number contained + * in the certificate request's certificate template. + * RETURN: + * If a serial number exists in the CertTemplate of the request, the function + * returns SECSuccess and the value at *serialNumber contains the serial + * number. + * If no serial number is present, then the function returns SECFailure and + * the value at *serialNumber is un-changed. + */ +extern SECStatus +CRMF_CertRequestGetCertTemplateSerialNumber(CRMFCertRequest *inCertReq, + long *serialNumber); + +/* + * FUNCTION: CRMF_CertRequestGetCertTemplateSigningAlg + * INPUT: + * inCertReq + * The Certificate Request to operate on. + * destAlg + * A Pointer to where the library can place a copy of the signing alg + * used in the cert request's cert template. + * RETURN: + * If the signingAlg is present in the CertRequest's CertTemplate, then + * the function returns SECSuccess and places a copy of sigingAlg in + * *destAlg. + * If no signingAlg is present, then the function returns SECFailure and + * the value at *destAlg is un-changed + */ +extern SECStatus +CRMF_CertRequestGetCertTemplateSigningAlg(CRMFCertRequest *inCertReq, + SECAlgorithmID *destAlg); +/* + * FUNCTION: CRMF_CertRequestGetCertTemplateIssuer + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * destIssuer + * A pointer to where the library can place a copy of the cert + * request's cert template issuer field. + * RETURN: + * If the issuer is present in the cert request cert template, the function + * returns SECSuccess and places a copy of the issuer in *destIssuer. + * If there is no issuer present, the function returns SECFailure and the + * value at *destIssuer is unchanged. + */ +extern SECStatus +CRMF_CertRequestGetCertTemplateIssuer(CRMFCertRequest *inCertReq, + CERTName *destIssuer); + +/* + * FUNCTION: CRMF_CertRequestGetCertTemplateValidity + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * destValdity + * A pointer to where the library can place a copy of the validity + * info in the cert request cert template. + * NOTES: + * Pass the pointer to + * RETURN: + * If there is an OptionalValidity field, the function will return SECSuccess + * and place the appropriate values in *destValidity->notBefore and + * *destValidity->notAfter. (Each field is optional, but at least one will + * be present if the function returns SECSuccess) + * + * If there is no OptionalValidity field, the function will return SECFailure + * and the values at *destValidity will be un-changed. + */ +extern SECStatus +CRMF_CertRequestGetCertTemplateValidity(CRMFCertRequest *inCertReq, + CRMFGetValidity *destValidity); +/* + * FUNCTION: CRMF_DestroyGetValidity + * INPUTS: + * inValidity + * A pointer to the memroy to be freed. + * NOTES: + * The function will free the memory allocated by the function + * CRMF_CertRequestGetCertTemplateValidity. That means only memory pointed + * to within the CRMFGetValidity structure. Since + * CRMF_CertRequestGetCertTemplateValidity does not allocate memory for the + * structure passed into it, it will not free it. Meaning this function will + * free the memory at inValidity->notBefore and inValidity->notAfter, but not + * the memory directly at inValdity. + * + * RETURN: + * SECSuccess if freeing the memory was successful. Any other return value + * indicates an error while freeing the memory. + */ +extern SECStatus +CRMF_DestroyGetValidity(CRMFGetValidity *inValidity); + +/* + * FUNCTION: CRMF_CertRequestGetCertTemplateSubject + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * destSubject + * A pointer to where the library can place a copy of the subject + * contained in the request's cert template. + * RETURN: + * If there is a subject in the CertTemplate, then the function returns + * SECSuccess and a copy of the subject is placed in *destSubject. + * + * If there is no subject, the function returns SECFailure and the values at + * *destSubject is unchanged. + */ +extern SECStatus +CRMF_CertRequestGetCertTemplateSubject(CRMFCertRequest *inCertReq, + CERTName *destSubject); + +/* + * FUNCTION: CRMF_CertRequestGetCertTemplatePublicKey + * INPUTS: + * inCertReq + * The Cert request to operate on. + * destPublicKey + * A pointer to where the library can place a copy of the request's + * cert template public key. + * RETURN: + * If there is a publicKey parameter in the CertRequest, the function returns + * SECSuccess, and places a copy of the publicKey in *destPublicKey. + * + * If there is no publicKey, the function returns SECFailure and the value + * at *destPublicKey is un-changed. + */ +extern SECStatus +CRMF_CertRequestGetCertTemplatePublicKey(CRMFCertRequest *inCertReq, + CERTSubjectPublicKeyInfo *destPublicKey); + +/* + * FUNCTION: CRMF_CertRequestGetCertTemplateIssuerUID + * INPUTS: + * inCertReq + * The Cert request to operate on. + * destIssuerUID + * A pointer to where the library can store a copy of the request's + * cert template destIssuerUID. + * + * NOTES: + * destIssuerUID is a bit string and will be returned in a SECItem as + * a bit string. Meaning the len field contains the number of valid bits as + * opposed to the number of bytes allocated. + * + * RETURN: + * If the CertTemplate has an issuerUID, the function returns SECSuccess and + * places a copy of the issuerUID in *destIssuerUID. + * + * If there is no issuerUID, the function returns SECFailure and the value + * *destIssuerUID is unchanged. + */ +extern SECStatus +CRMF_CertRequestGetCertTemplateIssuerUID(CRMFCertRequest *inCertReq, + SECItem *destIssuerUID); + +/* + * FUNCTION: CRMF_CertRequestGetCertTemplateSubjectUID + * inCertReq + * The Cert request to operate on. + * destSubjectUID + * A pointer to where the library can store a copy of the request's + * cert template destIssuerUID. + * + * NOTES: + * destSubjectUID is a bit string and will be returned in a SECItem as + * a bit string. Meaning the len field contains the number of valid bits as + * opposed to the number of bytes allocated. + * + * RETURN: + * If the CertTemplate has an issuerUID, the function returns SECSuccess and + * places a copy of the issuerUID in *destIssuerUID. + * + * If there is no issuerUID, the function returns SECSuccess and the value + * *destIssuerUID is unchanged. + */ +extern SECStatus CRMF_GetCertTemplateSubjectUID(CRMFCertRequest *inCertReq, + SECItem *destSubjectUID); + +/* + * FUNCTION: CRMF_CertRequestGetNumberOfExtensions + * INPUTS: + * inCertReq + * The cert request to operate on. + * RETURN: + * Returns the number of extensions contained by the Cert Request. + */ +extern int CRMF_CertRequestGetNumberOfExtensions(CRMFCertRequest *inCertReq); + +/* + * FUNCTION: CRMF_CertRequestGetExtensionAtIndex + * INPUTS: + * inCertReq + * The Certificate request to operate on. + * index + * The index of the extension array whihc the user wants to access. + * NOTES: + * This function retrieves the extension at the index corresponding to the + * parameter "index" indicates. Indexing is done like a C array. + * (0 ... numElements-1) + * + * Call CRMF_DestroyCertExtension when done using the return value. + * + * RETURN: + * A pointer to a copy of the extension at the desired index. A NULL + * return value indicates an invalid index or an error while copying + * the extension. + */ +extern CRMFCertExtension * +CRMF_CertRequestGetExtensionAtIndex(CRMFCertRequest *inCertReq, + int index); +/* + * FUNCTION: CRMF_CertExtensionGetOidTag + * INPUTS: + * inExtension + + * The extension to operate on. + * RETURN: + * Returns the SECOidTag associated with the cert extension passed in. + */ +extern SECOidTag CRMF_CertExtensionGetOidTag(CRMFCertExtension *inExtension); + +/* + * FUNCTION: CRMF_CertExtensionGetIsCritical + * INPUT: + * inExt + * The cert extension to operate on. + * + * RETURN: + * PR_TRUE if the extension is critical. + * PR_FALSE if the extension is not critical. + */ +extern PRBool CRMF_CertExtensionGetIsCritical(CRMFCertExtension *inExt); + +/* + * FUNCTION: CRMF_CertExtensionGetValue + * INPUT: + * inExtension + * The extension to operate on. + * NOTES: + * Caller is responsible for freeing the memory associated with the return + * value. Call SECITEM_FreeItem(retVal, PR_TRUE) when done using the return + * value. + * + * RETURN: + * A pointer to an item containig the value for the certificate extension. + * A NULL return value indicates an error in copying the information. + */ +extern SECItem *CRMF_CertExtensionGetValue(CRMFCertExtension *inExtension); + +/* + * FUNCTION: CRMF_CertReqMsgGetPOPOSigningKey + * INPUTS: + * inCertReqMsg + * The certificate request message to operate on. + * destKey + * A pointer to where the library can place a pointer to + * a copy of the Proof Of Possession Signing Key used + * by the message. + * + * RETURN: + * Get the POPOSigningKey associated with this CRMFCertReqMsg. + * If the CertReqMsg does not have a pop, the function returns + * SECFailure and the value at *destKey is un-changed.. + * + * If the CertReqMsg does have a pop, then the CertReqMsg's + * POPOSigningKey will be placed at *destKey. + */ +extern SECStatus +CRMF_CertReqMsgGetPOPOSigningKey(CRMFCertReqMsg *inCertReqMsg, + CRMFPOPOSigningKey **destKey); + +/* + * FUNCTION: CRMF_DestroyPOPOSigningKey + * INPUTS: + * inKey + * The signing key to free. + * + * RETURN: + * SECSuccess if freeing the memory was successful. Any other return value + * indicates an error while freeing memory. + */ +extern SECStatus CRMF_DestroyPOPOSigningKey(CRMFPOPOSigningKey *inKey); + +/* + * FUNCTION: CRMF_POPOSigningKeyGetAlgID + * INPUTS: + * inSignKey + * The Signing Key to operate on. + * RETURN: + * Return the algorithmID used by the CRMFPOPOSigningKey. User must + * call SECOID_DestroyAlgorithmID(destID, PR_TRUE) when done using the + * return value. + */ +extern SECAlgorithmID * +CRMF_POPOSigningKeyGetAlgID(CRMFPOPOSigningKey *inSignKey); + +/* + * FUNCTION: CRMF_POPOSigningKeyGetSignature + * INPUTS: + * inSignKey + * The Signing Key to operate on. + * + * RETURN: + * Get the actual signature stored away in the CRMFPOPOSigningKey. SECItem + * returned is a BIT STRING, so the len field is the number of bits as opposed + * to the total number of bytes allocatd. User must call + * SECITEM_FreeItem(retVal,PR_TRUE) when done using the return value. + */ +extern SECItem *CRMF_POPOSigningKeyGetSignature(CRMFPOPOSigningKey *inSignKey); + +/* + * FUNCTION: CRMF_POPOSigningKeyGetInput + * INPUTS: + * inSignKey + * The Signing Key to operate on. + * NOTES: + * This function will return the der encoded input that was read in while + * decoding. The API does not support this option when creating, so you + * cannot add this field. + * + * RETURN: + * Get the poposkInput that is part of the of the POPOSigningKey. If the + * optional field is not part of the POPOSigningKey, the function returns + * NULL. + * + * If the optional field is part of the POPOSingingKey, the function will + * return a copy of the der encoded poposkInput. + */ +extern SECItem *CRMF_POPOSigningKeyGetInput(CRMFPOPOSigningKey *inSignKey); + +/* + * FUNCTION: CRMF_CertReqMsgGetPOPKeyEncipherment + * INPUTS: + * inCertReqMsg + * The certificate request message to operate on. + * destKey + * A pointer to where the library can place a pointer to a + * copy of the POPOPrivKey representing Key Encipherment + * Proof of Possession. + *NOTES: + * This function gets the POPOPrivKey associated with this CRMFCertReqMsg + * for Key Encipherment. + * + * RETURN: + * If the CertReqMsg did not use Key Encipherment for Proof Of Possession, the + * function returns SECFailure and the value at *destKey is un-changed. + * + * If the CertReqMsg did use Key Encipherment for ProofOfPossession, the + * function returns SECSuccess and places the POPOPrivKey representing the + * Key Encipherment Proof Of Possessin at *destKey. + */ +extern SECStatus +CRMF_CertReqMsgGetPOPKeyEncipherment(CRMFCertReqMsg *inCertReqMsg, + CRMFPOPOPrivKey **destKey); + +/* + * FUNCTION: CRMF_CertReqMsgGetPOPKeyAgreement + * INPUTS: + * inCertReqMsg + * The certificate request message to operate on. + * destKey + * A pointer to where the library can place a pointer to a + * copy of the POPOPrivKey representing Key Agreement + * Proof of Possession. + * NOTES: + * This function gets the POPOPrivKey associated with this CRMFCertReqMsg for + * Key Agreement. + * + * RETURN: + * If the CertReqMsg used Key Agreement for Proof Of Possession, the + * function returns SECSuccess and the POPOPrivKey for Key Agreement + * is placed at *destKey. + * + * If the CertReqMsg did not use Key Agreement for Proof Of Possession, the + * function return SECFailure and the value at *destKey is unchanged. + */ +extern SECStatus +CRMF_CertReqMsgGetPOPKeyAgreement(CRMFCertReqMsg *inCertReqMsg, + CRMFPOPOPrivKey **destKey); + +/* + * FUNCTION: CRMF_DestroyPOPOPrivKey + * INPUTS: + * inPrivKey + * The POPOPrivKey to destroy. + * NOTES: + * Destroy a structure allocated by CRMF_GetPOPKeyEncipherment or + * CRMF_GetPOPKeyAgreement. + * + * RETURN: + * SECSuccess on successful destruction of the POPOPrivKey. + * Any other return value indicates an error in freeing the + * memory. + */ +extern SECStatus CRMF_DestroyPOPOPrivKey(CRMFPOPOPrivKey *inPrivKey); + +/* + * FUNCTION: CRMF_POPOPrivKeyGetChoice + * INPUT: + * inKey + * The POPOPrivKey to operate on. + * RETURN: + * Returns which choice was used in constructing the POPPOPrivKey. Look at + * the definition of CRMFPOPOPrivKeyChoice in crmft.h for the possible return + * values. + */ +extern CRMFPOPOPrivKeyChoice CRMF_POPOPrivKeyGetChoice(CRMFPOPOPrivKey *inKey); + +/* + * FUNCTION: CRMF_POPOPrivKeyGetThisMessage + * INPUTS: + * inKey + * The POPOPrivKey to operate on. + * destString + * A pointer to where the library can place a copy of the This Message + * field stored in the POPOPrivKey + * + * RETURN: + * Returns the field thisMessage from the POPOPrivKey. + * If the POPOPrivKey did not use the field thisMessage, the function + * returns SECFailure and the value at *destString is unchanged. + * + * If the POPOPrivKey did use the field thisMessage, the function returns + * SECSuccess and the BIT STRING representing thisMessage is placed + * at *destString. BIT STRING representation means the len field is the + * number of valid bits as opposed to the total number of bytes. + */ +extern SECStatus CRMF_POPOPrivKeyGetThisMessage(CRMFPOPOPrivKey *inKey, + SECItem *destString); + +/* + * FUNCTION: CRMF_POPOPrivKeyGetSubseqMess + * INPUTS: + * inKey + * The POPOPrivKey to operate on. + * destOpt + * A pointer to where the library can place the value of the + * Subsequent Message option used by POPOPrivKey. + * + * RETURN: + * Retrieves the field subsequentMessage from the POPOPrivKey. + * If the POPOPrivKey used the subsequentMessage option, the function + * returns SECSuccess and places the appropriate enumerated value at + * *destMessageOption. + * + * If the POPOPrivKey did not use the subsequenMessage option, the function + * returns SECFailure and the value at *destOpt is un-changed. + */ +extern SECStatus CRMF_POPOPrivKeyGetSubseqMess(CRMFPOPOPrivKey *inKey, + CRMFSubseqMessOptions *destOpt); + +/* + * FUNCTION: CRMF_POPOPrivKeyGetDHMAC + * INPUTS: + * inKey + * The POPOPrivKey to operate on. + * destMAC + * A pointer to where the library can place a copy of the dhMAC + * field of the POPOPrivKey. + * + * NOTES: + * Returns the field dhMAC from the POPOPrivKey. The populated SECItem + * is in BIT STRING format. + * + * RETURN: + * If the POPOPrivKey used the dhMAC option, the function returns SECSuccess + * and the BIT STRING for dhMAC will be placed at *destMAC. The len field in + * destMAC (ie destMAC->len) will be the valid number of bits as opposed to + * the number of allocated bytes. + * + * If the POPOPrivKey did not use the dhMAC option, the function returns + * SECFailure and the value at *destMAC is unchanged. + * + */ +extern SECStatus CRMF_POPOPrivKeyGetDHMAC(CRMFPOPOPrivKey *inKey, + SECItem *destMAC); + +/* + * FUNCTION: CRMF_CertRequestGetNumControls + * INPUTS: + * inCertReq + * The Certificate Request to operate on. + * RETURN: + * Returns the number of Controls registered with this CertRequest. + */ +extern int CRMF_CertRequestGetNumControls(CRMFCertRequest *inCertReq); + +/* + * FUNCTION: CRMF_CertRequestGetControlAtIndex + * INPUTS: + * inCertReq + * The certificate request to operate on. + * index + * The index of the control the user wants a copy of. + * NOTES: + * Function retrieves the Control at located at index. The Controls + * are numbered like a traditional C array (0 ... numElements-1) + * + * RETURN: + * Returns a copy of the control at the index specified. This is a copy + * so the user must call CRMF_DestroyControl after the return value is no + * longer needed. A return value of NULL indicates an error while copying + * the control or that the index was invalid. + */ +extern CRMFControl * +CRMF_CertRequestGetControlAtIndex(CRMFCertRequest *inCertReq, + int index); + +/* + * FUNCTION: CRMF_DestroyControl + * INPUTS: + * inControl + * The Control to destroy. + * NOTES: + * Destroy a CRMFControl allocated by CRMF_GetControlAtIndex. + * + * RETURN: + * SECSuccess if freeing the memory was successful. Any other return + * value indicates an error while freeing the memory. + */ +extern SECStatus CRMF_DestroyControl(CRMFControl *inControl); + +/* + * FUNCTION: CRMF_ControlGetControlType + * INPUTS: + * inControl + * The control to operate on. + * NOTES: + * The function returns an enumertion which indicates the type of control + * 'inControl'. + * + * RETURN: + * Look in crmft.h at the definition of the enumerated type CRMFControlType + * for the possible return values. + */ +extern CRMFControlType CRMF_ControlGetControlType(CRMFControl *inControl); + +/* + * FUNCTION: CRMF_ControlGetRegTokenControlValue + * INPUTS: + * inControl + * The Control to operate on. + * NOTES: + * The user must call SECITEM_FreeItem passing in the return value + * after the returnvalue is no longer needed. + + * RETURN: + * Return the value for a Registration Token Control. + * The SECItem returned should be in UTF8 format. A NULL + * return value indicates there was no Registration Control associated + * with the Control. + * (This library will not verify format. It assumes the client properly + * formatted the strings when adding it or the message decoded was properly + * formatted. The library will just give back the bytes it was given.) + */ +extern SECItem *CRMF_ControlGetRegTokenControlValue(CRMFControl *inControl); + +/* + * FUNCTION: CRMF_ControlGetAuthenticatorControlValue + * INPUTS: + * inControl + * The Control to operate on. + * NOTES: + * The user must call SECITEM_FreeItem passing in the return value + * after the returnvalue is no longer needed. + * + * RETURN: + * Return the value for the Authenticator Control. + * The SECItem returned should be in UTF8 format. A NULL + * return value indicates there was no Authenticator Control associated + * with the CRMFControl.. + * (This library will not verify format. It assumes the client properly + * formatted the strings when adding it or the message decoded was properly + * formatted. The library will just give back the bytes it was given.) + */ +extern SECItem *CRMF_ControlGetAuthicatorControlValue(CRMFControl *inControl); + +/* + * FUNCTION: CRMF_ControlGetPKIArchiveOptions + * INPUTS:inControl + * The Control tooperate on. + * NOTES: + * This function returns a copy of the PKIArchiveOptions. The user must call + * the function CRMF_DestroyPKIArchiveOptions when the return value is no + * longer needed. + * + * RETURN: + * Get the PKIArchiveOptions associated with the Control. A return + * value of NULL indicates the Control was not a PKIArchiveOptions + * Control. + */ +extern CRMFPKIArchiveOptions * +CRMF_ControlGetPKIArchiveOptions(CRMFControl *inControl); + +/* + * FUNCTION: CMRF_DestroyPKIArchiveOptions + * INPUTS: + * inOptions + * The ArchiveOptions to destroy. + * NOTE: + * Destroy the CRMFPKIArchiveOptions structure. + * + * RETURN: + * SECSuccess if successful in freeing all the memory associated with + * the PKIArchiveOptions. Any other return value indicates an error while + * freeing the PKIArchiveOptions. + */ +extern SECStatus +CRMF_DestroyPKIArchiveOptions(CRMFPKIArchiveOptions *inOptions); + +/* + * FUNCTION: CRMF_PKIArchiveOptionsGetOptionType + * INPUTS: + * inOptions + * The PKIArchiveOptions to operate on. + * RETURN: + * Returns the choice used for the PKIArchiveOptions. Look at the definition + * of CRMFPKIArchiveOptionsType in crmft.h for possible return values. + */ +extern CRMFPKIArchiveOptionsType +CRMF_PKIArchiveOptionsGetOptionType(CRMFPKIArchiveOptions *inOptions); + +/* + * FUNCTION: CRMF_PKIArchiveOptionsGetEncryptedPrivKey + * INPUTS: + * inOpts + * The PKIArchiveOptions to operate on. + * + * NOTES: + * The user must call CRMF_DestroyEncryptedKey when done using this return + * value. + * + * RETURN: + * Get the encryptedPrivKey field of the PKIArchiveOptions structure. + * A return value of NULL indicates that encryptedPrivKey was not used as + * the choice for this PKIArchiveOptions. + */ +extern CRMFEncryptedKey * +CRMF_PKIArchiveOptionsGetEncryptedPrivKey(CRMFPKIArchiveOptions *inOpts); + +/* + * FUNCTION: CRMF_EncryptedKeyGetChoice + * INPUTS: + * inEncrKey + * The EncryptedKey to operate on. + * + * NOTES: + * Get the choice used for representing the EncryptedKey. + * + * RETURN: + * Returns the Choice used in representing the EncryptedKey. Look in + * crmft.h at the definition of CRMFEncryptedKeyChoice for possible return + * values. + */ +extern CRMFEncryptedKeyChoice +CRMF_EncryptedKeyGetChoice(CRMFEncryptedKey *inEncrKey); + +/* + * FUNCTION: CRMF_EncryptedKeyGetEncryptedValue + * INPUTS: + * inKey + * The EncryptedKey to operate on. + * + * NOTES: + * The user must call CRMF_DestroyEncryptedValue passing in + * CRMF_GetEncryptedValue's return value. + * + * RETURN: + * A pointer to a copy of the EncryptedValue contained as a member of + * the EncryptedKey. + */ +extern CRMFEncryptedValue * +CRMF_EncryptedKeyGetEncryptedValue(CRMFEncryptedKey *inKey); + +/* + * FUNCTION: CRMF_DestroyEncryptedValue + * INPUTS: + * inEncrValue + * The EncryptedValue to destroy. + * + * NOTES: + * Free up all memory associated with 'inEncrValue'. + * + * RETURN: + * SECSuccess if freeing up the memory associated with the EncryptedValue + * is successful. Any other return value indicates an error while freeing the + * memory. + */ +extern SECStatus CRMF_DestroyEncryptedValue(CRMFEncryptedValue *inEncrValue); + +/* + * FUNCTION: CRMF_EncryptedValueGetEncValue + * INPUTS: + * inEncValue + * The EncryptedValue to operate on. + * NOTES: + * Function retrieves the encValue from an EncryptedValue structure. + * + * RETURN: + * A poiner to a SECItem containing the encValue of the EncryptedValue + * structure. The return value is in BIT STRING format, meaning the + * len field of the return structure represents the number of valid bits + * as opposed to the allocated number of bytes. + * ANULL return value indicates an error in copying the encValue field. + */ +extern SECItem *CRMF_EncryptedValueGetEncValue(CRMFEncryptedValue *inEncValue); + +/* + * FUNCTION: CRMF_EncryptedValueGetIntendedAlg + * INPUTS + * inEncValue + * The EncryptedValue to operate on. + * NOTES: + * Retrieve the IntendedAlg field from the EncryptedValue structure. + * Call SECOID_DestroyAlgorithmID (destAlgID, PR_TRUE) after done using + * the return value. When present, this alogorithm is the alogrithm for + * which the private key will be used. + * + * RETURN: + * A Copy of the intendedAlg field. A NULL return value indicates the + * optional field was not present in the structure. + */ +extern SECAlgorithmID * +CRMF_EncryptedValueGetIntendedAlg(CRMFEncryptedValue *inEncValue); + +/* + * FUNCTION: CRMF_EncryptedValueGetSymmAlg + * INPUTS + * inEncValue + * The EncryptedValue to operate on. + * NOTES: + * Retrieve the symmAlg field from the EncryptedValue structure. + * Call SECOID_DestroyAlgorithmID (destAlgID, PR_TRUE) after done using + * the return value. When present, this is algorithm used to + * encrypt the encValue of the EncryptedValue. + * + * RETURN: + * A Copy of the symmAlg field. A NULL return value indicates the + * optional field was not present in the structure. + */ +extern SECAlgorithmID * +CRMF_EncryptedValueGetSymmAlg(CRMFEncryptedValue *inEncValue); + +/* + * FUNCTION: CRMF_EncryptedValueGetKeyAlg + * INPUTS + * inEncValue + * The EncryptedValue to operate on. + * NOTES: + * Retrieve the keyAlg field from the EncryptedValue structure. + * Call SECOID_DestroyAlgorithmID (destAlgID, PR_TRUE) after done using + * the return value. When present, this is the algorithm used to encrypt + * the symmetric key in the encSymmKey field of the EncryptedValue structure. + * + * RETURN: + * A Copy of the keyAlg field. A NULL return value indicates the + * optional field was not present in the structure. + */ +extern SECAlgorithmID * +CRMF_EncryptedValueGetKeyAlg(CRMFEncryptedValue *inEncValue); + +/* + * FUNCTION: CRMF_EncryptedValueGetValueHint + * INPUTS: + * inEncValue + * The EncryptedValue to operate on. + * + * NOTES: + * Return a copy of the der-encoded value hint. + * User must call SECITEM_FreeItem(retVal, PR_TRUE) when done using the + * return value. When, present, this is a value that the client which + * originally issued a certificate request can use to reproduce any data + * it wants. The RA does not know how to interpret this data. + * + * RETURN: + * A copy of the valueHint field of the EncryptedValue. A NULL return + * value indicates the optional valueHint field is not present in the + * EncryptedValue. + */ +extern SECItem * +CRMF_EncryptedValueGetValueHint(CRMFEncryptedValue *inEncValue); + +/* + * FUNCTION: CRMF_EncrypteValueGetEncSymmKey + * INPUTS: + * inEncValue + * The EncryptedValue to operate on. + * + * NOTES: + * Return a copy of the encSymmKey field. This field is the encrypted + * symmetric key that the client uses in doing Public Key wrap of a private + * key. When present, this is the symmetric key that was used to wrap the + * private key. (The encrypted private key will be stored in encValue + * of the same EncryptedValue structure.) The user must call + * SECITEM_FreeItem(retVal, PR_TRUE) when the return value is no longer + * needed. + * + * RETURN: + * A copy of the optional encSymmKey field of the EncryptedValue structure. + * The return value will be in BIT STRING format, meaning the len field will + * be the number of valid bits as opposed to the number of bytes. A return + * value of NULL means the optional encSymmKey field was not present in + * the EncryptedValue structure. + */ +extern SECItem * +CRMF_EncryptedValueGetEncSymmKey(CRMFEncryptedValue *inEncValue); + +/* + * FUNCTION: CRMF_PKIArchiveOptionsGetKeyGenParameters + * INPUTS: + * inOptions + * The PKiArchiveOptions to operate on. + * + * NOTES: + * User must call SECITEM_FreeItem(retVal, PR_TRUE) after the return + * value is no longer needed. + * + * RETURN: + * Get the keyGenParameters field of the PKIArchiveOptions. + * A NULL return value indicates that keyGenParameters was not + * used as the choice for this PKIArchiveOptions. + * + * The SECItem returned is in BIT STRING format (ie, the len field indicates + * number of valid bits as opposed to allocated number of bytes.) + */ +extern SECItem * +CRMF_PKIArchiveOptionsGetKeyGenParameters(CRMFPKIArchiveOptions *inOptions); + +/* + * FUNCTION: CRMF_PKIArchiveOptionsGetArchiveRemGenPrivKey + * INPUTS: + * inOpt + * The PKIArchiveOptions to operate on. + * destVal + * A pointer to where the library can place the value for + * arciveRemGenPrivKey + * RETURN: + * If the PKIArchiveOptions used the archiveRemGenPrivKey field, the + * function returns SECSuccess and fills the value at *destValue with either + * PR_TRUE or PR_FALSE, depending on what the PKIArchiveOptions has as a + * value. + * + * If the PKIArchiveOptions does not use the archiveRemGenPrivKey field, the + * function returns SECFailure and the value at *destValue is unchanged. + */ +extern SECStatus +CRMF_PKIArchiveOptionsGetArchiveRemGenPrivKey(CRMFPKIArchiveOptions *inOpt, + PRBool *destVal); + +/* Helper functions that can be used by other libraries. */ +/* + * A quick helper function to get the best wrap mechanism. + */ +extern CK_MECHANISM_TYPE CRMF_GetBestWrapPadMechanism(PK11SlotInfo *slot); + +/* + * A helper function to get a randomly generated IV from a mechanism + * type. + */ +extern SECItem *CRMF_GetIVFromMechanism(CK_MECHANISM_TYPE mechType); + +SEC_END_PROTOS +#endif /*_CRMF_H_*/ diff --git a/illumos-x86_64/usr/include/mps/crmft.h b/illumos-x86_64/usr/include/mps/crmft.h new file mode 100644 index 00000000..8d83cf1e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/crmft.h @@ -0,0 +1,186 @@ +/* -*- Mode: C; tab-width: 8 -*-*/ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Header file with all of the structures and types that will be exported + * by the security library for implementation of CRMF. + */ + +#ifndef _CRMFT_H_ +#define _CRMFT_H_ + +/* Use these enumerated values for adding fields to the certificate request */ +typedef enum { + crmfVersion = 0, + crmfSerialNumber = 1, + crmfSigningAlg = 2, + crmfIssuer = 3, + crmfValidity = 4, + crmfSubject = 5, + crmfPublicKey = 6, + crmfIssuerUID = 7, + crmfSubjectUID = 8, + crmfExtension = 9 +} CRMFCertTemplateField; + +/* + * An enumeration for the different types of controls. + */ +typedef enum { + crmfNoControl = 0, + crmfRegTokenControl = 1, + crmfAuthenticatorControl = 2, + crmfPKIPublicationInfoControl = 3, + crmfPKIArchiveOptionsControl = 4, + crmfOldCertIDControl = 5, + crmfProtocolEncrKeyControl = 6 +} CRMFControlType; + +/* + * The possible values that are passed into CRMF_CreatePKIPublicationInfo + */ +typedef enum { + crmfDontPublish = 0, + crmfPleasePublish = 1 +} CRMFPublicationAction; + +/* + * An enumeration for the possible for pubMethod which is a part of + * the SinglePubInfo ASN1 type. + */ +typedef enum { + crmfDontCare = 0, + crmfX500 = 1, + crmfWeb = 2, + crmfLdap = 3 +} CRMFPublicationMethod; + +/* + * An enumeration for the different options for PKIArchiveOptions type. + */ +typedef enum { + crmfNoArchiveOptions = 0, + crmfEncryptedPrivateKey = 1, + crmfKeyGenParameters = 2, + crmfArchiveRemGenPrivKey = 3 +} CRMFPKIArchiveOptionsType; + +/* + * An enumeration for the different options for ProofOfPossession + */ +typedef enum { + crmfNoPOPChoice = 0, + crmfRAVerified = 1, + crmfSignature = 2, + crmfKeyEncipherment = 3, + crmfKeyAgreement = 4 +} CRMFPOPChoice; + +/* + * An enumertion type for options for the authInfo field of the + * CRMFPOPOSigningKeyInput structure. + */ +typedef enum { + crmfSender = 0, + crmfPublicKeyMAC = 1 +} CRMFPOPOSkiInputAuthChoice; + +/* + * An enumeration for the SubsequentMessage Options. + */ +typedef enum { + crmfNoSubseqMess = 0, + crmfEncrCert = 1, + crmfChallengeResp = 2 +} CRMFSubseqMessOptions; + +/* + * An enumeration for the choice used by POPOPrivKey. + */ +typedef enum { + crmfNoMessage = 0, + crmfThisMessage = 1, + crmfSubsequentMessage = 2, + crmfDHMAC = 3 +} CRMFPOPOPrivKeyChoice; + +/* + * An enumeration for the choices for the EncryptedKey type. + */ +typedef enum { + crmfNoEncryptedKeyChoice = 0, + crmfEncryptedValueChoice = 1, + crmfEnvelopedDataChoice = 2 +} CRMFEncryptedKeyChoice; + +/* + * TYPE: CRMFEncoderOutputCallback + * This function type defines a prototype for a function that the CRMF + * library expects when encoding is performed. + * + * ARGUMENTS: + * arg + * This will be a pointer the user passed into an encoding function. + * The user of the library is free to use this pointer in any way. + * The most common use is to keep around a buffer for writing out + * the DER encoded bytes. + * buf + * The DER encoded bytes that should be written out. + * len + * The number of DER encoded bytes to write out. + * + */ +typedef void (*CRMFEncoderOutputCallback)(void *arg, + const char *buf, + unsigned long len); + +/* + * Type for the function that gets a password. Just in case we ever + * need to support publicKeyMAC for POPOSigningKeyInput + */ +typedef SECItem *(*CRMFMACPasswordCallback)(void *arg); + +typedef struct CRMFOptionalValidityStr CRMFOptionalValidity; +typedef struct CRMFValidityCreationInfoStr CRMFGetValidity; +typedef struct CRMFCertTemplateStr CRMFCertTemplate; +typedef struct CRMFCertRequestStr CRMFCertRequest; +typedef struct CRMFCertReqMsgStr CRMFCertReqMsg; +typedef struct CRMFCertReqMessagesStr CRMFCertReqMessages; +typedef struct CRMFProofOfPossessionStr CRMFProofOfPossession; +typedef struct CRMFPOPOSigningKeyStr CRMFPOPOSigningKey; +typedef struct CRMFPOPOSigningKeyInputStr CRMFPOPOSigningKeyInput; +typedef struct CRMFPOPOPrivKeyStr CRMFPOPOPrivKey; +typedef struct CRMFPKIPublicationInfoStr CRMFPKIPublicationInfo; +typedef struct CRMFSinglePubInfoStr CRMFSinglePubInfo; +typedef struct CRMFPKIArchiveOptionsStr CRMFPKIArchiveOptions; +typedef struct CRMFEncryptedKeyStr CRMFEncryptedKey; +typedef struct CRMFEncryptedValueStr CRMFEncryptedValue; +typedef struct CRMFCertIDStr CRMFCertID; +typedef struct CRMFCertIDStr CRMFOldCertID; +typedef CERTSubjectPublicKeyInfo CRMFProtocolEncrKey; +typedef struct CRMFValidityCreationInfoStr CRMFValidityCreationInfo; +typedef struct CRMFCertExtCreationInfoStr CRMFCertExtCreationInfo; +typedef struct CRMFPKMACValueStr CRMFPKMACValue; +typedef struct CRMFAttributeStr CRMFAttribute; +typedef struct CRMFControlStr CRMFControl; +typedef CERTGeneralName CRMFGeneralName; +typedef struct CRMFCertExtensionStr CRMFCertExtension; + +struct CRMFValidityCreationInfoStr { + PRTime *notBefore; + PRTime *notAfter; +}; + +struct CRMFCertExtCreationInfoStr { + CRMFCertExtension **extensions; + int numExtensions; +}; + +/* + * Some ASN1 Templates that may be needed. + */ +extern const SEC_ASN1Template CRMFCertReqMessagesTemplate[]; +extern const SEC_ASN1Template CRMFCertRequestTemplate[]; + +#endif /*_CRMFT_H_*/ diff --git a/illumos-x86_64/usr/include/mps/cryptohi.h b/illumos-x86_64/usr/include/mps/cryptohi.h new file mode 100644 index 00000000..7b66f0b0 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/cryptohi.h @@ -0,0 +1,425 @@ +/* + * cryptohi.h - public prototypes for the crypto library + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _CRYPTOHI_H_ +#define _CRYPTOHI_H_ + +#include "blapit.h" + +#include "seccomon.h" +#include "secoidt.h" +#include "secdert.h" +#include "cryptoht.h" +#include "keythi.h" +#include "certt.h" + +SEC_BEGIN_PROTOS + +/****************************************/ +/* +** DER encode/decode (EC)DSA signatures +*/ + +/* ANSI X9.57 defines DSA signatures as DER encoded data. Our DSA1 code (and + * most of the rest of the world) just generates 40 bytes of raw data. These + * functions convert between formats. + */ +extern SECStatus DSAU_EncodeDerSig(SECItem *dest, SECItem *src); +extern SECItem *DSAU_DecodeDerSig(const SECItem *item); + +/* + * Unlike DSA1, raw DSA2 and ECDSA signatures do not have a fixed length. + * Rather they contain two integers r and s whose length depends + * on the size of q or the EC key used for signing. + * + * We can reuse the DSAU_EncodeDerSig interface to DER encode + * raw ECDSA signature keeping in mind that the length of r + * is the same as that of s and exactly half of src->len. + * + * For decoding, we need to pass the length of the desired + * raw signature (twice the key size) explicitly. + */ +extern SECStatus DSAU_EncodeDerSigWithLen(SECItem *dest, SECItem *src, + unsigned int len); +extern SECItem *DSAU_DecodeDerSigToLen(const SECItem *item, unsigned int len); + +/****************************************/ +/* +** Signature creation operations +*/ + +/* +** Create a new signature context used for signing a data stream. +** "alg" the signature algorithm to use (e.g. SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION) +** "privKey" the private key to use +*/ +extern SGNContext *SGN_NewContext(SECOidTag alg, SECKEYPrivateKey *privKey); + +/* +** Create a new signature context from an algorithmID. +** "alg" the signature algorithm to use +** "privKey" the private key to use +*/ +extern SGNContext *SGN_NewContextWithAlgorithmID(SECAlgorithmID *alg, + SECKEYPrivateKey *privKey); + +/* +** Destroy a signature-context object +** "cx" the object +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void SGN_DestroyContext(SGNContext *cx, PRBool freeit); + +/* +** Reset the signing context "cx" to its initial state, preparing it for +** another stream of data. +*/ +extern SECStatus SGN_Begin(SGNContext *cx); + +/* +** Update the signing context with more data to sign. +** "cx" the context +** "input" the input data to sign +** "inputLen" the length of the input data +*/ +extern SECStatus SGN_Update(SGNContext *cx, const unsigned char *input, + unsigned int inputLen); + +/* +** Finish the signature process. Use either k0 or k1 to sign the data +** stream that was input using SGN_Update. The resulting signature is +** formatted using PKCS#1 and then encrypted using RSA private or public +** encryption. +** "cx" the context +** "result" the final signature data (memory is allocated) +*/ +extern SECStatus SGN_End(SGNContext *cx, SECItem *result); + +/* +** Sign a single block of data using private key encryption and given +** signature/hash algorithm. +** "result" the final signature data (memory is allocated) +** "buf" the input data to sign +** "len" the amount of data to sign +** "pk" the private key to encrypt with +** "algid" the signature/hash algorithm to sign with +** (must be compatible with the key type). +*/ +extern SECStatus SEC_SignData(SECItem *result, + const unsigned char *buf, int len, + SECKEYPrivateKey *pk, SECOidTag algid); + +/* +** Sign a single block of data using private key encryption and given +** signature/hash algorithm with parameters from an algorithmID. +** "result" the final signature data (memory is allocated) +** "buf" the input data to sign +** "len" the amount of data to sign +** "pk" the private key to encrypt with +** "algid" the signature/hash algorithm to sign with +** (must be compatible with the key type). +*/ +extern SECStatus SEC_SignDataWithAlgorithmID(SECItem *result, + const unsigned char *buf, int len, + SECKEYPrivateKey *pk, + SECAlgorithmID *algid); + +/* +** Sign a pre-digested block of data using private key encryption, encoding +** The given signature/hash algorithm. +** "result" the final signature data (memory is allocated) +** "digest" the digest to sign +** "privKey" the private key to encrypt with +** "algtag" The algorithm tag to encode (need for RSA only) +*/ +extern SECStatus SGN_Digest(SECKEYPrivateKey *privKey, + SECOidTag algtag, SECItem *result, SECItem *digest); + +/* +** DER sign a single block of data using private key encryption and the +** MD5 hashing algorithm. This routine first computes a digital signature +** using SEC_SignData, then wraps it with an CERTSignedData and then der +** encodes the result. +** "arena" is the memory arena to use to allocate data from +** "result" the final der encoded data (memory is allocated) +** "buf" the input data to sign +** "len" the amount of data to sign +** "pk" the private key to encrypt with +*/ +extern SECStatus SEC_DerSignData(PLArenaPool *arena, SECItem *result, + const unsigned char *buf, int len, + SECKEYPrivateKey *pk, SECOidTag algid); + +/* +** DER sign a single block of data using private key encryption and +** the given signature/hash algorithm with parameters from an +** algorithmID. This routine first computes a digital signature using +** SEC_SignData, then wraps it with an CERTSignedData and then der +** encodes the result. +** "arena" is the memory arena to use to allocate data from +** "result" the final der encoded data (memory is allocated) +** "buf" the input data to sign +** "len" the amount of data to sign +** "pk" the private key to encrypt with +** "algid" the signature/hash algorithm to sign with +** (must be compatible with the key type). +*/ +extern SECStatus SEC_DerSignDataWithAlgorithmID(PLArenaPool *arena, + SECItem *result, + const unsigned char *buf, + int len, + SECKEYPrivateKey *pk, + SECAlgorithmID *algid); + +/* +** Destroy a signed-data object. +** "sd" the object +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void SEC_DestroySignedData(CERTSignedData *sd, PRBool freeit); + +/* +** Get the signature algorithm tag number for the given key type and hash +** algorithm tag. Returns SEC_OID_UNKNOWN if key type and hash algorithm +** do not match or are not supported. +*/ +extern SECOidTag SEC_GetSignatureAlgorithmOidTag(KeyType keyType, + SECOidTag hashAlgTag); + +/* +** Create algorithm parameters for signing. Return a new item +** allocated from arena, or NULL on failure. +** "arena" is the memory arena to use to allocate data from +** "result" the encoded parameters (memory is allocated) +** "signAlgTag" is the signing algorithm +** "hashAlgTag" is the preferred hash algorithm +** "params" is the default parameters +** "key" is the private key +*/ +extern SECItem *SEC_CreateSignatureAlgorithmParameters(PLArenaPool *arena, + SECItem *result, + SECOidTag signAlgTag, + SECOidTag hashAlgTag, + const SECItem *params, + const SECKEYPrivateKey *key); + +/****************************************/ +/* +** Signature verification operations +*/ + +/* +** Create a signature verification context. This version is deprecated, +** This function is deprecated. Use VFY_CreateContextDirect or +** VFY_CreateContextWithAlgorithmID instead. +** "key" the public key to verify with +** "sig" the encrypted signature data if sig is NULL then +** VFY_EndWithSignature must be called with the correct signature at +** the end of the processing. +** "sigAlg" specifies the signing algorithm to use (including the +** hash algorthim). This must match the key type. +** "wincx" void pointer to the window context +*/ +extern VFYContext *VFY_CreateContext(SECKEYPublicKey *key, SECItem *sig, + SECOidTag sigAlg, void *wincx); +/* +** Create a signature verification context. +** "key" the public key to verify with +** "sig" the encrypted signature data if sig is NULL then +** VFY_EndWithSignature must be called with the correct signature at +** the end of the processing. +** "pubkAlg" specifies the cryptographic signing algorithm to use (the +** raw algorithm without any hash specified. This must match the key +** type. +** "hashAlg" specifies the hashing algorithm used. If the key is an +** RSA key, and sig is not NULL, then hashAlg can be SEC_OID_UNKNOWN. +** the hash is selected from data in the sig. +** "hash" optional pointer to return the actual hash algorithm used. +** in practice this should always match the passed in hashAlg (the +** exception is the case where hashAlg is SEC_OID_UNKNOWN above). +** If this value is NULL no, hash oid is returned. +** "wincx" void pointer to the window context +*/ +extern VFYContext *VFY_CreateContextDirect(const SECKEYPublicKey *key, + const SECItem *sig, + SECOidTag pubkAlg, + SECOidTag hashAlg, + SECOidTag *hash, void *wincx); +/* +** Create a signature verification context from a algorithm ID. +** "key" the public key to verify with +** "sig" the encrypted signature data if sig is NULL then +** VFY_EndWithSignature must be called with the correct signature at +** the end of the processing. +** "algid" specifies the signing algorithm and parameters to use. +** This must match the key type. +** "hash" optional pointer to return the oid of the actual hash used in +** the signature. If this value is NULL no, hash oid is returned. +** "wincx" void pointer to the window context +*/ +extern VFYContext *VFY_CreateContextWithAlgorithmID(const SECKEYPublicKey *key, + const SECItem *sig, + const SECAlgorithmID *algid, + SECOidTag *hash, + void *wincx); + +/* +** Destroy a verification-context object. +** "cx" the context to destroy +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void VFY_DestroyContext(VFYContext *cx, PRBool freeit); + +extern SECStatus VFY_Begin(VFYContext *cx); + +/* +** Update a verification context with more input data. The input data +** is fed to a secure hash function (depending on what was in the +** encrypted signature data). +** "cx" the context +** "input" the input data +** "inputLen" the amount of input data +*/ +extern SECStatus VFY_Update(VFYContext *cx, const unsigned char *input, + unsigned int inputLen); + +/* +** Finish the verification process. The return value is a status which +** indicates success or failure. On success, the SECSuccess value is +** returned. Otherwise, SECFailure is returned and the error code found +** using PORT_GetError() indicates what failure occurred. +** "cx" the context +*/ +extern SECStatus VFY_End(VFYContext *cx); + +/* +** Finish the verification process. The return value is a status which +** indicates success or failure. On success, the SECSuccess value is +** returned. Otherwise, SECFailure is returned and the error code found +** using PORT_GetError() indicates what failure occurred. If signature is +** supplied the verification uses this signature to verify, otherwise the +** signature passed in VFY_CreateContext() is used. +** VFY_EndWithSignature(cx,NULL); is identical to VFY_End(cx);. +** "cx" the context +** "sig" the encrypted signature data +*/ +extern SECStatus VFY_EndWithSignature(VFYContext *cx, SECItem *sig); + +/* +** Verify the signature on a block of data for which we already have +** the digest. The signature data is an RSA private key encrypted +** block of data formatted according to PKCS#1. +** This function is deprecated. Use VFY_VerifyDigestDirect or +** VFY_VerifyDigestWithAlgorithmID instead. +** "dig" the digest +** "key" the public key to check the signature with +** "sig" the encrypted signature data +** "sigAlg" specifies the signing algorithm to use. This must match +** the key type. +** "wincx" void pointer to the window context +**/ +extern SECStatus VFY_VerifyDigest(SECItem *dig, SECKEYPublicKey *key, + SECItem *sig, SECOidTag sigAlg, void *wincx); +/* +** Verify the signature on a block of data for which we already have +** the digest. The signature data is an RSA private key encrypted +** block of data formatted according to PKCS#1. +** "dig" the digest +** "key" the public key to check the signature with +** "sig" the encrypted signature data +** "pubkAlg" specifies the cryptographic signing algorithm to use (the +** raw algorithm without any hash specified. This must match the key +** type. +** "hashAlg" specifies the hashing algorithm used. +** "wincx" void pointer to the window context +**/ +extern SECStatus VFY_VerifyDigestDirect(const SECItem *dig, + const SECKEYPublicKey *key, + const SECItem *sig, SECOidTag pubkAlg, + SECOidTag hashAlg, void *wincx); +/* +** Verify the signature on a block of data for which we already have +** the digest. The signature data is an RSA private key encrypted +** block of data formatted according to PKCS#1. +** "key" the public key to verify with +** "sig" the encrypted signature data if sig is NULL then +** VFY_EndWithSignature must be called with the correct signature at +** the end of the processing. +** "algid" specifies the signing algorithm and parameters to use. +** This must match the key type. +** "hash" oid of the actual hash used to create digest. If this value is +** not set to SEC_OID_UNKNOWN, it must match the hash of the signature. +** "wincx" void pointer to the window context +*/ +extern SECStatus VFY_VerifyDigestWithAlgorithmID(const SECItem *dig, + const SECKEYPublicKey *key, const SECItem *sig, + const SECAlgorithmID *algid, SECOidTag hash, + void *wincx); + +/* +** Verify the signature on a block of data. The signature data is an RSA +** private key encrypted block of data formatted according to PKCS#1. +** This function is deprecated. Use VFY_VerifyDataDirect or +** VFY_VerifyDataWithAlgorithmID instead. +** "buf" the input data +** "len" the length of the input data +** "key" the public key to check the signature with +** "sig" the encrypted signature data +** "sigAlg" specifies the signing algorithm to use. This must match +** the key type. +** "wincx" void pointer to the window context +*/ +extern SECStatus VFY_VerifyData(const unsigned char *buf, int len, + const SECKEYPublicKey *key, const SECItem *sig, + SECOidTag sigAlg, void *wincx); +/* +** Verify the signature on a block of data. The signature data is an RSA +** private key encrypted block of data formatted according to PKCS#1. +** "buf" the input data +** "len" the length of the input data +** "key" the public key to check the signature with +** "sig" the encrypted signature data +** "pubkAlg" specifies the cryptographic signing algorithm to use (the +** raw algorithm without any hash specified. This must match the key +** type. +** "hashAlg" specifies the hashing algorithm used. If the key is an +** RSA key, and sig is not NULL, then hashAlg can be SEC_OID_UNKNOWN. +** the hash is selected from data in the sig. +** "hash" optional pointer to return the actual hash algorithm used. +** in practice this should always match the passed in hashAlg (the +** exception is the case where hashAlg is SEC_OID_UNKNOWN above). +** If this value is NULL no, hash oid is returned. +** "wincx" void pointer to the window context +*/ +extern SECStatus VFY_VerifyDataDirect(const unsigned char *buf, int len, + const SECKEYPublicKey *key, + const SECItem *sig, + SECOidTag pubkAlg, SECOidTag hashAlg, + SECOidTag *hash, void *wincx); + +/* +** Verify the signature on a block of data. The signature data is an RSA +** private key encrypted block of data formatted according to PKCS#1. +** "buf" the input data +** "len" the length of the input data +** "key" the public key to check the signature with +** "sig" the encrypted signature data +** "algid" specifies the signing algorithm and parameters to use. +** This must match the key type. +** "hash" optional pointer to return the oid of the actual hash used in +** the signature. If this value is NULL no, hash oid is returned. +** "wincx" void pointer to the window context +*/ +extern SECStatus VFY_VerifyDataWithAlgorithmID(const unsigned char *buf, + int len, const SECKEYPublicKey *key, + const SECItem *sig, + const SECAlgorithmID *algid, SECOidTag *hash, + void *wincx); + +SEC_END_PROTOS + +#endif /* _CRYPTOHI_H_ */ diff --git a/illumos-x86_64/usr/include/mps/cryptoht.h b/illumos-x86_64/usr/include/mps/cryptoht.h new file mode 100644 index 00000000..5780bf47 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/cryptoht.h @@ -0,0 +1,14 @@ +/* + * cryptoht.h - public data structures for the crypto library + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _CRYPTOHT_H_ +#define _CRYPTOHT_H_ + +typedef struct SGNContextStr SGNContext; +typedef struct VFYContextStr VFYContext; + +#endif /* _CRYPTOHT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/eccutil.h b/illumos-x86_64/usr/include/mps/eccutil.h new file mode 100644 index 00000000..7b52295b --- /dev/null +++ b/illumos-x86_64/usr/include/mps/eccutil.h @@ -0,0 +1,17 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _FREEBL_H_ +#define _FREEBL_H_ + +#define X25519_PUBLIC_KEY_BYTES 32U + +/* deprecated */ +typedef enum { + ECPoint_Uncompressed, + ECPoint_XOnly, + ECPoint_Undefined +} ECPointEncoding; + +#endif /* _FREEBL_H_ */ diff --git a/illumos-x86_64/usr/include/mps/ecl-exp.h b/illumos-x86_64/usr/include/mps/ecl-exp.h new file mode 100644 index 00000000..14263c70 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/ecl-exp.h @@ -0,0 +1,168 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __ecl_exp_h_ +#define __ecl_exp_h_ + +/* Curve field type */ +typedef enum { + ECField_GFp, + ECField_GF2m +} ECField; + +/* Hexadecimal encoding of curve parameters */ +struct ECCurveParamsStr { + char *text; + ECField field; + unsigned int size; + char *irr; + char *curvea; + char *curveb; + char *genx; + char *geny; + char *order; + int cofactor; + int security; + int pointSize; + unsigned int usage; +}; +typedef struct ECCurveParamsStr ECCurveParams; + +/* Named curve parameters */ +typedef enum { + + ECCurve_noName = 0, + + /* NIST prime curves */ + ECCurve_NIST_P192, /* not supported */ + ECCurve_NIST_P224, /* not supported */ + ECCurve_NIST_P256, + ECCurve_NIST_P384, + ECCurve_NIST_P521, + + /* NIST binary curves */ + ECCurve_NIST_K163, /* not supported */ + ECCurve_NIST_B163, /* not supported */ + ECCurve_NIST_K233, /* not supported */ + ECCurve_NIST_B233, /* not supported */ + ECCurve_NIST_K283, /* not supported */ + ECCurve_NIST_B283, /* not supported */ + ECCurve_NIST_K409, /* not supported */ + ECCurve_NIST_B409, /* not supported */ + ECCurve_NIST_K571, /* not supported */ + ECCurve_NIST_B571, /* not supported */ + + /* ANSI X9.62 prime curves */ + /* ECCurve_X9_62_PRIME_192V1 == ECCurve_NIST_P192 */ + ECCurve_X9_62_PRIME_192V2, /* not supported */ + ECCurve_X9_62_PRIME_192V3, /* not supported */ + ECCurve_X9_62_PRIME_239V1, /* not supported */ + ECCurve_X9_62_PRIME_239V2, /* not supported */ + ECCurve_X9_62_PRIME_239V3, /* not supported */ + /* ECCurve_X9_62_PRIME_256V1 == ECCurve_NIST_P256 */ + + /* ANSI X9.62 binary curves */ + ECCurve_X9_62_CHAR2_PNB163V1, /* not supported */ + ECCurve_X9_62_CHAR2_PNB163V2, /* not supported */ + ECCurve_X9_62_CHAR2_PNB163V3, /* not supported */ + ECCurve_X9_62_CHAR2_PNB176V1, /* not supported */ + ECCurve_X9_62_CHAR2_TNB191V1, /* not supported */ + ECCurve_X9_62_CHAR2_TNB191V2, /* not supported */ + ECCurve_X9_62_CHAR2_TNB191V3, /* not supported */ + ECCurve_X9_62_CHAR2_PNB208W1, /* not supported */ + ECCurve_X9_62_CHAR2_TNB239V1, /* not supported */ + ECCurve_X9_62_CHAR2_TNB239V2, /* not supported */ + ECCurve_X9_62_CHAR2_TNB239V3, /* not supported */ + ECCurve_X9_62_CHAR2_PNB272W1, /* not supported */ + ECCurve_X9_62_CHAR2_PNB304W1, /* not supported */ + ECCurve_X9_62_CHAR2_TNB359V1, /* not supported */ + ECCurve_X9_62_CHAR2_PNB368W1, /* not supported */ + ECCurve_X9_62_CHAR2_TNB431R1, /* not supported */ + + /* SEC2 prime curves */ + ECCurve_SECG_PRIME_112R1, /* not supported */ + ECCurve_SECG_PRIME_112R2, /* not supported */ + ECCurve_SECG_PRIME_128R1, /* not supported */ + ECCurve_SECG_PRIME_128R2, /* not supported */ + ECCurve_SECG_PRIME_160K1, /* not supported */ + ECCurve_SECG_PRIME_160R1, /* not supported */ + ECCurve_SECG_PRIME_160R2, /* not supported */ + ECCurve_SECG_PRIME_192K1, /* not supported */ + /* ECCurve_SECG_PRIME_192R1 == ECCurve_NIST_P192 */ + ECCurve_SECG_PRIME_224K1, /* not supported */ + /* ECCurve_SECG_PRIME_224R1 == ECCurve_NIST_P224 */ + ECCurve_SECG_PRIME_256K1, /* not supported */ + /* ECCurve_SECG_PRIME_256R1 == ECCurve_NIST_P256 */ + /* ECCurve_SECG_PRIME_384R1 == ECCurve_NIST_P384 */ + /* ECCurve_SECG_PRIME_521R1 == ECCurve_NIST_P521 */ + + /* SEC2 binary curves */ + ECCurve_SECG_CHAR2_113R1, /* not supported */ + ECCurve_SECG_CHAR2_113R2, /* not supported */ + ECCurve_SECG_CHAR2_131R1, /* not supported */ + ECCurve_SECG_CHAR2_131R2, /* not supported */ + /* ECCurve_SECG_CHAR2_163K1 == ECCurve_NIST_K163 */ + ECCurve_SECG_CHAR2_163R1, /* not supported */ + /* ECCurve_SECG_CHAR2_163R2 == ECCurve_NIST_B163 */ + ECCurve_SECG_CHAR2_193R1, /* not supported */ + ECCurve_SECG_CHAR2_193R2, /* not supported */ + /* ECCurve_SECG_CHAR2_233K1 == ECCurve_NIST_K233 */ + /* ECCurve_SECG_CHAR2_233R1 == ECCurve_NIST_B233 */ + ECCurve_SECG_CHAR2_239K1, /* not supported */ + /* ECCurve_SECG_CHAR2_283K1 == ECCurve_NIST_K283 */ + /* ECCurve_SECG_CHAR2_283R1 == ECCurve_NIST_B283 */ + /* ECCurve_SECG_CHAR2_409K1 == ECCurve_NIST_K409 */ + /* ECCurve_SECG_CHAR2_409R1 == ECCurve_NIST_B409 */ + /* ECCurve_SECG_CHAR2_571K1 == ECCurve_NIST_K571 */ + /* ECCurve_SECG_CHAR2_571R1 == ECCurve_NIST_B571 */ + + /* WTLS curves */ + ECCurve_WTLS_1, /* not supported */ + /* there is no WTLS 2 curve */ + /* ECCurve_WTLS_3 == ECCurve_NIST_K163 */ + /* ECCurve_WTLS_4 == ECCurve_SECG_CHAR2_113R1 */ + /* ECCurve_WTLS_5 == ECCurve_X9_62_CHAR2_PNB163V1 */ + /* ECCurve_WTLS_6 == ECCurve_SECG_PRIME_112R1 */ + /* ECCurve_WTLS_7 == ECCurve_SECG_PRIME_160R1 */ + ECCurve_WTLS_8, /* not supported */ + ECCurve_WTLS_9, /* not supported */ + /* ECCurve_WTLS_10 == ECCurve_NIST_K233 */ + /* ECCurve_WTLS_11 == ECCurve_NIST_B233 */ + /* ECCurve_WTLS_12 == ECCurve_NIST_P224 */ + + ECCurve25519, + ECCurve_Ed25519, + + ECCurve_pastLastCurve +} ECCurveName; + +/* Aliased named curves */ + +#define ECCurve_X9_62_PRIME_192V1 ECCurve_NIST_P192 /* not supported */ +#define ECCurve_X9_62_PRIME_256V1 ECCurve_NIST_P256 +#define ECCurve_SECG_PRIME_192R1 ECCurve_NIST_P192 /* not supported */ +#define ECCurve_SECG_PRIME_224R1 ECCurve_NIST_P224 /* not supported */ +#define ECCurve_SECG_PRIME_256R1 ECCurve_NIST_P256 +#define ECCurve_SECG_PRIME_384R1 ECCurve_NIST_P384 +#define ECCurve_SECG_PRIME_521R1 ECCurve_NIST_P521 +#define ECCurve_SECG_CHAR2_163K1 ECCurve_NIST_K163 /* not supported */ +#define ECCurve_SECG_CHAR2_163R2 ECCurve_NIST_B163 /* not supported */ +#define ECCurve_SECG_CHAR2_233K1 ECCurve_NIST_K233 /* not supported */ +#define ECCurve_SECG_CHAR2_233R1 ECCurve_NIST_B233 /* not supported */ +#define ECCurve_SECG_CHAR2_283K1 ECCurve_NIST_K283 /* not supported */ +#define ECCurve_SECG_CHAR2_283R1 ECCurve_NIST_B283 /* not supported */ +#define ECCurve_SECG_CHAR2_409K1 ECCurve_NIST_K409 /* not supported */ +#define ECCurve_SECG_CHAR2_409R1 ECCurve_NIST_B409 /* not supported */ +#define ECCurve_SECG_CHAR2_571K1 ECCurve_NIST_K571 /* not supported */ +#define ECCurve_SECG_CHAR2_571R1 ECCurve_NIST_B571 /* not supported */ +#define ECCurve_WTLS_3 ECCurve_NIST_K163 /* not supported */ +#define ECCurve_WTLS_4 ECCurve_SECG_CHAR2_113R1 /* not supported */ +#define ECCurve_WTLS_5 ECCurve_X9_62_CHAR2_PNB163V1 /* not supported */ +#define ECCurve_WTLS_6 ECCurve_SECG_PRIME_112R1 /* not supported */ +#define ECCurve_WTLS_7 ECCurve_SECG_PRIME_160R1 /* not supported */ +#define ECCurve_WTLS_10 ECCurve_NIST_K233 /* not supported */ +#define ECCurve_WTLS_11 ECCurve_NIST_B233 /* not supported */ +#define ECCurve_WTLS_12 ECCurve_NIST_P224 /* not supported */ + +#endif /* __ecl_exp_h_ */ diff --git a/illumos-x86_64/usr/include/mps/hasht.h b/illumos-x86_64/usr/include/mps/hasht.h new file mode 100644 index 00000000..b70b94fb --- /dev/null +++ b/illumos-x86_64/usr/include/mps/hasht.h @@ -0,0 +1,71 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _HASHT_H_ +#define _HASHT_H_ + +#include "prtypes.h" + +/* Opaque objects */ +typedef struct SECHashObjectStr SECHashObject; +typedef struct HASHContextStr HASHContext; + +/* + * The hash functions the security library supports + * NOTE the order must match the definition of SECHashObjects[]! + */ +typedef enum { + HASH_AlgNULL = 0, + HASH_AlgMD2 = 1, + HASH_AlgMD5 = 2, + HASH_AlgSHA1 = 3, + HASH_AlgSHA256 = 4, + HASH_AlgSHA384 = 5, + HASH_AlgSHA512 = 6, + HASH_AlgSHA224 = 7, + HASH_AlgSHA3_224 = 8, + HASH_AlgSHA3_256 = 9, + HASH_AlgSHA3_384 = 10, + HASH_AlgSHA3_512 = 11, + HASH_AlgTOTAL +} HASH_HashType; + +/* + * Number of bytes each hash algorithm produces + */ +#define MD2_LENGTH 16 +#define MD5_LENGTH 16 +#define SHA1_LENGTH 20 +#define SHA224_LENGTH 28 +#define SHA256_LENGTH 32 +#define SHA384_LENGTH 48 +#define SHA512_LENGTH 64 +#define SHA3_224_LENGTH 28 +#define SHA3_256_LENGTH 32 +#define SHA3_384_LENGTH 48 +#define SHA3_512_LENGTH 64 +#define HASH_LENGTH_MAX SHA512_LENGTH + +/* + * Structure to hold hash computation info and routines + */ +struct SECHashObjectStr { + unsigned int length; /* hash output length (in bytes) */ + void *(*create)(void); + void *(*clone)(void *); + void (*destroy)(void *, PRBool); + void (*begin)(void *); + void (*update)(void *, const unsigned char *, unsigned int); + void (*end)(void *, unsigned char *, unsigned int *, unsigned int); + unsigned int blocklength; /* hash input block size (in bytes) */ + HASH_HashType type; + void (*end_raw)(void *, unsigned char *, unsigned int *, unsigned int); +}; + +struct HASHContextStr { + const struct SECHashObjectStr *hashobj; + void *hash_context; +}; + +#endif /* _HASHT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/jar-ds.h b/illumos-x86_64/usr/include/mps/jar-ds.h new file mode 100644 index 00000000..9818c66c --- /dev/null +++ b/illumos-x86_64/usr/include/mps/jar-ds.h @@ -0,0 +1,77 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __JAR_DS_h_ +#define __JAR_DS_h_ + +/* Typedefs */ +typedef struct ZZLinkStr ZZLink; +typedef struct ZZListStr ZZList; + +/* +** Circular linked list. Each link contains a pointer to the object that +** is actually in the list. +*/ +struct ZZLinkStr { + ZZLink *next; + ZZLink *prev; + JAR_Item *thing; +}; + +struct ZZListStr { + ZZLink link; +}; + +#define ZZ_InitList(lst) \ + { \ + (lst)->link.next = &(lst)->link; \ + (lst)->link.prev = &(lst)->link; \ + (lst)->link.thing = 0; \ + } + +#define ZZ_ListEmpty(lst) ((lst)->link.next == &(lst)->link) + +#define ZZ_ListHead(lst) ((lst)->link.next) + +#define ZZ_ListTail(lst) ((lst)->link.prev) + +#define ZZ_ListIterDone(lst, lnk) ((lnk) == &(lst)->link) + +#define ZZ_AppendLink(lst, lnk) \ + { \ + (lnk)->next = &(lst)->link; \ + (lnk)->prev = (lst)->link.prev; \ + (lst)->link.prev->next = (lnk); \ + (lst)->link.prev = (lnk); \ + } + +#define ZZ_InsertLink(lst, lnk) \ + { \ + (lnk)->next = (lst)->link.next; \ + (lnk)->prev = &(lst)->link; \ + (lst)->link.next->prev = (lnk); \ + (lst)->link.next = (lnk); \ + } + +#define ZZ_RemoveLink(lnk) \ + { \ + (lnk)->next->prev = (lnk)->prev; \ + (lnk)->prev->next = (lnk)->next; \ + (lnk)->next = 0; \ + (lnk)->prev = 0; \ + } + +extern ZZLink * +ZZ_NewLink(JAR_Item *thing); + +extern void +ZZ_DestroyLink(ZZLink *link); + +extern ZZList * +ZZ_NewList(void); + +extern void +ZZ_DestroyList(ZZList *list); + +#endif /* __JAR_DS_h_ */ diff --git a/illumos-x86_64/usr/include/mps/jar.h b/illumos-x86_64/usr/include/mps/jar.h new file mode 100644 index 00000000..8b0c26d9 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/jar.h @@ -0,0 +1,372 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __JAR_h_ +#define __JAR_h_ + +/* + * In general, any functions that return pointers + * have memory owned by the caller. + * + */ + +/* security includes */ +#include "cert.h" +#include "hasht.h" + +/* nspr 2.0 includes */ +#include "prio.h" + +#define ZHUGEP + +#include + +/* various types */ + +typedef enum { + jarTypeMF = 2, + jarTypeSF = 3, + jarTypeMeta = 6, + jarTypePhy = 7, + jarTypeSign = 10, + jarTypeSect = 11, + jarTypeOwner = 13 +} jarType; + +/* void data in ZZList's contain JAR_Item type */ +typedef struct JAR_Item_ { + char *pathname; /* relative. inside zip file */ + jarType type; /* various types */ + size_t size; /* size of data below */ + void *data; /* totally opaque */ +} JAR_Item; + +/* hashes */ +typedef enum { + jarHashNone = 0, + jarHashBad = 1, + jarHashPresent = 2 +} jarHash; + +typedef struct JAR_Digest_ { + jarHash md5_status; + unsigned char md5[MD5_LENGTH]; + jarHash sha1_status; + unsigned char sha1[SHA1_LENGTH]; +} JAR_Digest; + +/* physical archive formats */ +typedef enum { + jarArchGuess = 0, + jarArchNone = 1, + jarArchZip = 2, + jarArchTar = 3 +} jarArch; + +#include "jar-ds.h" + +struct JAR_; + +typedef int jar_settable_callback_fn(int status, struct JAR_ *jar, + const char *metafile, char *pathname, + char *errortext); + +/* jar object */ +typedef struct JAR_ { + jarArch format; /* physical archive format */ + + char *url; /* Where it came from */ + char *filename; /* Disk location */ + FILE *fp; /* For multiple extractions */ + /* JAR_FILE */ + + /* various linked lists */ + ZZList *manifest; /* Digests of MF sections */ + ZZList *hashes; /* Digests of actual signed files */ + ZZList *phy; /* Physical layout of JAR file */ + ZZList *metainfo; /* Global metainfo */ + + JAR_Digest *globalmeta; /* digest of .MF global portion */ + + /* Below will change to a linked list to support multiple sigs */ + int pkcs7; /* Enforced opaqueness */ + int valid; /* PKCS7 signature validated */ + + ZZList *signers; /* the above, per signer */ + + /* Window context, very necessary for PKCS11 now */ + void *mw; /* MWContext window context */ + + /* Signal callback function */ + jar_settable_callback_fn *signal; +} JAR; + +/* + * Iterator + * + * Context for iterative operations. Certain operations + * require iterating multiple linked lists because of + * multiple signers. "nextsign" is used for this purpose. + * + */ +typedef struct JAR_Context_ { + JAR *jar; /* Jar we are searching */ + char *pattern; /* Regular expression */ + jarType finding; /* Type of item to find */ + ZZLink *next; /* Next item in find */ + ZZLink *nextsign; /* Next signer, sometimes */ +} JAR_Context; + +typedef struct JAR_Signer_ { + int pkcs7; /* Enforced opaqueness */ + int valid; /* PKCS7 signature validated */ + char *owner; /* name of .RSA file */ + JAR_Digest *digest; /* of .SF file */ + ZZList *sf; /* Linked list of .SF file contents */ + ZZList *certs; /* Signing information */ +} JAR_Signer; + +/* Meta informaton, or "policy", from the manifest file. + Right now just one tuple per JAR_Item. */ +typedef struct JAR_Metainfo_ { + char *header; + char *info; +} JAR_Metainfo; + +/* This should not be global */ +typedef struct JAR_Physical_ { + unsigned char compression; + unsigned long offset; + unsigned long length; + unsigned long uncompressed_length; +#if defined(XP_UNIX) + PRUint16 mode; +#endif +} JAR_Physical; + +typedef struct JAR_Cert_ { + size_t length; + void *key; + CERTCertificate *cert; +} JAR_Cert; + +/* certificate stuff */ +typedef enum { + jarCertCompany = 1, + jarCertCA = 2, + jarCertSerial = 3, + jarCertExpires = 4, + jarCertNickname = 5, + jarCertFinger = 6, + jarCertJavaHack = 100 +} jarCert; + +/* callback types */ +#define JAR_CB_SIGNAL 1 + +/* + * This is the base for the JAR error codes. It will + * change when these are incorporated into allxpstr.c, + * but right now they won't let me put them there. + * + */ +#ifndef SEC_ERR_BASE +#define SEC_ERR_BASE (-0x2000) +#endif + +#define JAR_BASE SEC_ERR_BASE + 300 + +/* Jar specific error definitions */ + +#define JAR_ERR_GENERAL (JAR_BASE + 1) +#define JAR_ERR_FNF (JAR_BASE + 2) +#define JAR_ERR_CORRUPT (JAR_BASE + 3) +#define JAR_ERR_MEMORY (JAR_BASE + 4) +#define JAR_ERR_DISK (JAR_BASE + 5) +#define JAR_ERR_ORDER (JAR_BASE + 6) +#define JAR_ERR_SIG (JAR_BASE + 7) +#define JAR_ERR_METADATA (JAR_BASE + 8) +#define JAR_ERR_ENTRY (JAR_BASE + 9) +#define JAR_ERR_HASH (JAR_BASE + 10) +#define JAR_ERR_PK7 (JAR_BASE + 11) +#define JAR_ERR_PNF (JAR_BASE + 12) + +/* Function declarations */ + +extern JAR *JAR_new(void); + +extern void PR_CALLBACK JAR_destroy(JAR *jar); + +extern char *JAR_get_error(int status); + +extern int JAR_set_callback(int type, JAR *jar, jar_settable_callback_fn *fn); + +extern void +JAR_init_callbacks(char *(*string_cb)(int), + void *(*find_cx)(void), + void *(*init_cx)(void)); + +/* + * JAR_set_context + * + * PKCS11 may require a password to be entered by the user + * before any crypto routines may be called. This will require + * a window context if used from inside Mozilla. + * + * Call this routine with your context before calling + * verifying or signing. If you have no context, call with NULL + * and one will be chosen for you. + * + */ +int JAR_set_context(JAR *jar, void /*MWContext*/ *mw); + +/* + * Iterative operations + * + * JAR_find sets up for repeated calls with JAR_find_next. + * I never liked findfirst and findnext, this is nicer. + * + * Pattern contains a relative pathname to match inside the + * archive. It is currently assumed to be "*". + * + * To use: + * + * JAR_Item *item; + * JAR_find (jar, "*.class", jarTypeMF); + * while (JAR_find_next (jar, &item) >= 0) + * { do stuff } + * + */ + +/* Replacement functions with an external context */ + +extern JAR_Context *JAR_find(JAR *jar, char *pattern, jarType type); + +extern int JAR_find_next(JAR_Context *ctx, JAR_Item **it); + +extern void JAR_find_end(JAR_Context *ctx); + +/* + * Function to parse manifest file: + * + * Many signatures may be attached to a single filename located + * inside the zip file. We only support one. + * + * Several manifests may be included in the zip file. + * + * You must pass the MANIFEST.MF file before any .SF files. + * + * Right now this returns a big ole list, privately in the jar structure. + * If you need to traverse it, use JAR_find if possible. + * + * The path is needed to determine what type of binary signature is + * being passed, though it is technically not needed for manifest files. + * + * When parsing an ASCII file, null terminate the ASCII raw_manifest + * prior to sending it, and indicate a length of 0. For binary digital + * signatures only, indicate the true length of the signature. + * (This is legacy behavior.) + * + * You may free the manifest after parsing it. + * + */ + +extern int +JAR_parse_manifest(JAR *jar, char *raw_manifest, long length, const char *path, + const char *url); + +/* + * Verify data (nonstreaming). The signature is actually + * checked by JAR_parse_manifest or JAR_pass_archive. + * + */ + +extern JAR_Digest *PR_CALLBACK +JAR_calculate_digest(void *data, long length); + +extern int PR_CALLBACK +JAR_verify_digest(JAR *jar, const char *name, JAR_Digest *dig); + +extern int +JAR_digest_file(char *filename, JAR_Digest *dig); + +/* + * Meta information + * + * Currently, since this call does not support passing of an owner + * (certificate, or physical name of the .sf file), it is restricted to + * returning information located in the manifest.mf file. + * + * Meta information is a name/value pair inside the archive file. Here, + * the name is passed in *header and value returned in **info. + * + * Pass a NULL as the name to retrieve metainfo from the global section. + * + * Data is returned in **info, of size *length. The return value + * will indicate if no data was found. + * + */ + +extern int +JAR_get_metainfo(JAR *jar, char *name, char *header, void **info, + unsigned long *length); + +extern char *JAR_get_filename(JAR *jar); + +extern char *JAR_get_url(JAR *jar); + +/* save the certificate with this fingerprint in persistent + storage, somewhere, for retrieval in a future session when there + is no corresponding JAR structure. */ +extern int PR_CALLBACK +JAR_stash_cert(JAR *jar, long keylen, void *key); + +/* retrieve a certificate presumably stashed with the above + function, but may be any certificate. Type is &CERTCertificate */ +CERTCertificate * +JAR_fetch_cert(long length, void *key); + +/* + * New functions to handle archives alone + * (call JAR_new beforehand) + * + * JAR_pass_archive acts much like parse_manifest. Certificates + * are returned in the JAR structure but as opaque data. When calling + * JAR_verified_extract you still need to decide which of these + * certificates to honor. + * + * Code to examine a JAR structure is in jarbert.c. You can obtain both + * a list of filenames and certificates from traversing the linked list. + * + */ +extern int +JAR_pass_archive(JAR *jar, jarArch format, char *filename, const char *url); + +/* + * Same thing, but don't check signatures + */ +extern int +JAR_pass_archive_unverified(JAR *jar, jarArch format, char *filename, + const char *url); + +/* + * Extracts a relative pathname from the archive and places it + * in the filename specified. + * + * Call JAR_set_nailed if you want to keep the file descriptors + * open between multiple calls to JAR_verify_extract. + * + */ +extern int +JAR_verified_extract(JAR *jar, char *path, char *outpath); + +/* + * JAR_extract does no crypto checking. This can be used if you + * need to extract a manifest file or signature, etc. + * + */ +extern int +JAR_extract(JAR *jar, char *path, char *outpath); + +#endif /* __JAR_h_ */ diff --git a/illumos-x86_64/usr/include/mps/jarfile.h b/illumos-x86_64/usr/include/mps/jarfile.h new file mode 100644 index 00000000..52d4f1fc --- /dev/null +++ b/illumos-x86_64/usr/include/mps/jarfile.h @@ -0,0 +1,76 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * JARFILE.H + * + * Certain constants and structures for the archive format. + * + */ + +/* ZIP */ +struct ZipLocal { /* 30 bytes */ + char signature[4]; + char word[2]; + char bitflag[2]; + char method[2]; + char time[2]; + char date[2]; + char crc32[4]; + char size[4]; + char orglen[4]; + char filename_len[2]; + char extrafield_len[2]; +}; + +struct ZipCentral { /* 46 bytes */ + char signature[4]; + char version_made_by[2]; + char version[2]; + char bitflag[2]; + char method[2]; + char time[2]; + char date[2]; + char crc32[4]; + char size[4]; + char orglen[4]; + char filename_len[2]; + char extrafield_len[2]; + char commentfield_len[2]; + char diskstart_number[2]; + char internal_attributes[2]; + char external_attributes[4]; + char localhdr_offset[4]; +}; + +struct ZipEnd { /* 22 bytes */ + char signature[4]; + char disk_nr[2]; + char start_central_dir[2]; + char total_entries_disk[2]; + char total_entries_archive[2]; + char central_dir_size[4]; + char offset_central_dir[4]; + char commentfield_len[2]; +}; + +#define LSIG 0x04034B50l +#define CSIG 0x02014B50l +#define ESIG 0x06054B50l + +/* TAR */ +union TarEntry { /* 512 bytes */ + struct header { /* 257 bytes */ + char filename[100]; + char mode[8]; + char uid[8]; + char gid[8]; + char size[12]; + char time[12]; + char checksum[8]; + char linkflag; + char linkname[100]; + } val; + char buffer[512]; +}; diff --git a/illumos-x86_64/usr/include/mps/key.h b/illumos-x86_64/usr/include/mps/key.h new file mode 100644 index 00000000..8392031c --- /dev/null +++ b/illumos-x86_64/usr/include/mps/key.h @@ -0,0 +1,14 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _KEY_H_ +#define _KEY_H_ + +#if defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__) +#pragma message("key.h is deprecated. Please include keyhi.h instead.") +#endif + +#include "keyhi.h" + +#endif /* _KEY_H_ */ diff --git a/illumos-x86_64/usr/include/mps/keyhi.h b/illumos-x86_64/usr/include/mps/keyhi.h new file mode 100644 index 00000000..5bce35ce --- /dev/null +++ b/illumos-x86_64/usr/include/mps/keyhi.h @@ -0,0 +1,296 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _KEYHI_H_ +#define _KEYHI_H_ + +#include "plarena.h" + +#include "seccomon.h" +#include "secoidt.h" +#include "secdert.h" +#include "keythi.h" +#include "certt.h" +#include "secerr.h" + +SEC_BEGIN_PROTOS + +/* +** Destroy a subject-public-key-info object. +*/ +extern void SECKEY_DestroySubjectPublicKeyInfo(CERTSubjectPublicKeyInfo *spki); + +/* +** Copy subject-public-key-info "src" to "dst". "dst" is filled in +** appropriately (memory is allocated for each of the sub objects). +*/ +extern SECStatus SECKEY_CopySubjectPublicKeyInfo(PLArenaPool *arena, + CERTSubjectPublicKeyInfo *dst, + CERTSubjectPublicKeyInfo *src); + +/* +** Update the PQG parameters for a cert's public key. +** Only done for DSA certs +*/ +extern SECStatus +SECKEY_UpdateCertPQG(CERTCertificate *subjectCert); + +/* +** Return the number of bits in the provided big integer. This assumes that the +** SECItem contains a big-endian number and counts from the first non-zero bit. +*/ +extern unsigned SECKEY_BigIntegerBitLength(const SECItem *number); + +/* +** Return the strength of the public key in bytes +*/ +extern unsigned SECKEY_PublicKeyStrength(const SECKEYPublicKey *pubk); + +/* +** Return the strength of the public key in bits +*/ +extern unsigned SECKEY_PublicKeyStrengthInBits(const SECKEYPublicKey *pubk); + +/* +** Return the strength of the private key in bits +*/ +extern unsigned SECKEY_PrivateKeyStrengthInBits(const SECKEYPrivateKey *privk); + +/* +** Return the length of the signature in bytes +*/ +extern unsigned SECKEY_SignatureLen(const SECKEYPublicKey *pubk); + +/* +** Make a copy of the private key "privKey" +*/ +extern SECKEYPrivateKey *SECKEY_CopyPrivateKey(const SECKEYPrivateKey *privKey); + +/* +** Make a copy of the public key "pubKey" +*/ +extern SECKEYPublicKey *SECKEY_CopyPublicKey(const SECKEYPublicKey *pubKey); + +/* +** Convert a private key "privateKey" into a public key +*/ +extern SECKEYPublicKey *SECKEY_ConvertToPublicKey(SECKEYPrivateKey *privateKey); + +/* + * create a new RSA key pair. The private Key is returned... + */ +SECKEYPrivateKey *SECKEY_CreateRSAPrivateKey(int keySizeInBits, + SECKEYPublicKey **pubk, void *cx); + +/* + * create a new DH key pair. The private Key is returned... + */ +SECKEYPrivateKey *SECKEY_CreateDHPrivateKey(SECKEYDHParams *param, + SECKEYPublicKey **pubk, void *cx); + +/* + * create a new EC key pair. The private Key is returned... + */ +SECKEYPrivateKey *SECKEY_CreateECPrivateKey(SECKEYECParams *param, + SECKEYPublicKey **pubk, void *cx); + +/* +** Create a subject-public-key-info based on a public key. +*/ +extern CERTSubjectPublicKeyInfo * +SECKEY_CreateSubjectPublicKeyInfo(const SECKEYPublicKey *k); + +/* +** Convert a base64 ascii encoded DER public key and challenge to spki, +** and verify the signature and challenge data are correct +*/ +extern CERTSubjectPublicKeyInfo * +SECKEY_ConvertAndDecodePublicKeyAndChallenge(char *pkacstr, char *challenge, + void *cx); + +/* +** Encode a CERTSubjectPublicKeyInfo structure. into a +** DER encoded subject public key info. +*/ +SECItem * +SECKEY_EncodeDERSubjectPublicKeyInfo(const SECKEYPublicKey *pubk); + +/* +** Decode a DER encoded subject public key info into a +** CERTSubjectPublicKeyInfo structure. +*/ +extern CERTSubjectPublicKeyInfo * +SECKEY_DecodeDERSubjectPublicKeyInfo(const SECItem *spkider); + +/* +** Convert a base64 ascii encoded DER subject public key info to our +** internal format. +*/ +extern CERTSubjectPublicKeyInfo * +SECKEY_ConvertAndDecodeSubjectPublicKeyInfo(const char *spkistr); + +/* + * extract the public key from a subject Public Key info structure. + * (used by JSS). + */ +extern SECKEYPublicKey * +SECKEY_ExtractPublicKey(const CERTSubjectPublicKeyInfo *); + +/* +** Destroy a private key object. +** "key" the object +*/ +extern void SECKEY_DestroyPrivateKey(SECKEYPrivateKey *key); + +/* +** Destroy a public key object. +** "key" the object +*/ +extern void SECKEY_DestroyPublicKey(SECKEYPublicKey *key); + +/* Destroy and zero out a private key info structure. for now this + * function zero's out memory allocated in an arena for the key + * since PORT_FreeArena does not currently do this. + * + * NOTE -- If a private key info is allocated in an arena, one should + * not call this function with freeit = PR_FALSE. The function should + * destroy the arena. + */ +extern void +SECKEY_DestroyPrivateKeyInfo(SECKEYPrivateKeyInfo *pvk, PRBool freeit); + +/* Destroy and zero out an encrypted private key info. + * + * NOTE -- If a encrypted private key info is allocated in an arena, one should + * not call this function with freeit = PR_FALSE. The function should + * destroy the arena. + */ +extern void +SECKEY_DestroyEncryptedPrivateKeyInfo(SECKEYEncryptedPrivateKeyInfo *epki, + PRBool freeit); + +/* Copy private key info structure. + * poolp is the arena into which the contents of from is to be copied. + * NULL is a valid entry. + * to is the destination private key info + * from is the source private key info + * if either from or to is NULL or an error occurs, SECFailure is + * returned. otherwise, SECSuccess is returned. + */ +extern SECStatus +SECKEY_CopyPrivateKeyInfo(PLArenaPool *poolp, + SECKEYPrivateKeyInfo *to, + const SECKEYPrivateKeyInfo *from); + +extern SECStatus +SECKEY_CacheStaticFlags(SECKEYPrivateKey *key); + +/* Copy encrypted private key info structure. + * poolp is the arena into which the contents of from is to be copied. + * NULL is a valid entry. + * to is the destination encrypted private key info + * from is the source encrypted private key info + * if either from or to is NULL or an error occurs, SECFailure is + * returned. otherwise, SECSuccess is returned. + */ +extern SECStatus +SECKEY_CopyEncryptedPrivateKeyInfo(PLArenaPool *poolp, + SECKEYEncryptedPrivateKeyInfo *to, + const SECKEYEncryptedPrivateKeyInfo *from); +/* + * Accessor functions for key type of public and private keys. + */ +KeyType SECKEY_GetPrivateKeyType(const SECKEYPrivateKey *privKey); +KeyType SECKEY_GetPublicKeyType(const SECKEYPublicKey *pubKey); + +/* + * Creates a PublicKey from its DER encoding. + * Currently only supports RSA, DSA, and DH keys. + */ +SECKEYPublicKey * +SECKEY_ImportDERPublicKey(const SECItem *derKey, CK_KEY_TYPE type); + +SECKEYPrivateKeyList * +SECKEY_NewPrivateKeyList(void); + +void +SECKEY_DestroyPrivateKeyList(SECKEYPrivateKeyList *keys); + +void +SECKEY_RemovePrivateKeyListNode(SECKEYPrivateKeyListNode *node); + +SECStatus +SECKEY_AddPrivateKeyToListTail(SECKEYPrivateKeyList *list, + SECKEYPrivateKey *key); + +#define PRIVKEY_LIST_HEAD(l) ((SECKEYPrivateKeyListNode *)PR_LIST_HEAD(&l->list)) +#define PRIVKEY_LIST_NEXT(n) ((SECKEYPrivateKeyListNode *)n->links.next) +#define PRIVKEY_LIST_END(n, l) (((void *)n) == ((void *)&l->list)) + +SECKEYPublicKeyList * +SECKEY_NewPublicKeyList(void); + +void +SECKEY_DestroyPublicKeyList(SECKEYPublicKeyList *keys); + +void +SECKEY_RemovePublicKeyListNode(SECKEYPublicKeyListNode *node); + +SECStatus +SECKEY_AddPublicKeyToListTail(SECKEYPublicKeyList *list, + SECKEYPublicKey *key); + +#define PUBKEY_LIST_HEAD(l) ((SECKEYPublicKeyListNode *)PR_LIST_HEAD(&l->list)) +#define PUBKEY_LIST_NEXT(n) ((SECKEYPublicKeyListNode *)n->links.next) +#define PUBKEY_LIST_END(n, l) (((void *)n) == ((void *)&l->list)) + +/* + * Length in bits of the EC's field size. This is also the length of + * the x and y coordinates of EC points, such as EC public keys and + * base points. + * + * Return 0 on failure (unknown EC domain parameters). + */ +extern int SECKEY_ECParamsToKeySize(const SECItem *params); + +/* + * Length in bits of the EC base point order, usually denoted n. This + * is also the length of EC private keys and ECDSA signature components + * r and s. + * + * Return 0 on failure (unknown EC domain parameters). + */ +extern int SECKEY_ECParamsToBasePointOrderLen(const SECItem *params); + +/* + * Returns the object identifier of the curve, of the provided + * elliptic curve parameters structures. + * + * Return 0 on failure (unknown EC domain parameters). + */ +SECOidTag SECKEY_GetECCOid(const SECKEYECParams *params); + +/* make sure the key length matches the policy for keyType */ +SECStatus SECKEY_EnforceKeySize(KeyType keyType, unsigned keyLength, + SECErrorCodes error); + +/* Maps an ML-DSA OID tag to its corresponding PKCS#11's CKP_* parameter set */ +CK_ML_DSA_PARAMETER_SET_TYPE +SECKEY_GetMLDSAPkcs11ParamSetByOidTag(SECOidTag tag); + +/* Maps a PKCS#11's CKP_* parameter set to its corresponding ML-DSA OID tag */ +SECOidTag +SECKEY_GetMLDSAOidTagByPkcs11ParamSet(CK_ML_DSA_PARAMETER_SET_TYPE paramSet); + +typedef enum { + SECKEYPubKeyType = 1, + SECKEYPrivKeyType, + SECKEYSignatureType, +} SECKEYSizeType; + +unsigned int SECKEY_MLDSAOidParamsToLen(SECOidTag oid, SECKEYSizeType type); + +SEC_END_PROTOS + +#endif /* _KEYHI_H_ */ diff --git a/illumos-x86_64/usr/include/mps/keyt.h b/illumos-x86_64/usr/include/mps/keyt.h new file mode 100644 index 00000000..5a0d2c2e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/keyt.h @@ -0,0 +1,14 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _KEYT_H_ +#define _KEYT_H_ + +#if defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__) +#pragma message("keyt.h is deprecated. Please include keythi.h instead.") +#endif + +#include "keythi.h" + +#endif /* _KEYT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/keythi.h b/illumos-x86_64/usr/include/mps/keythi.h new file mode 100644 index 00000000..57e85aae --- /dev/null +++ b/illumos-x86_64/usr/include/mps/keythi.h @@ -0,0 +1,274 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _KEYTHI_H_ +#define _KEYTHI_H_ 1 + +#include "eccutil.h" +#include "kyber.h" +#include "ml_dsat.h" +#include "plarena.h" +#include "pkcs11t.h" +#include "secmodt.h" +#include "prclist.h" + +/* +** RFC 4055 Section 1.2 specifies three different RSA key types. +** +** rsaKey maps to keys with SEC_OID_PKCS1_RSA_ENCRYPTION and can be used for +** both encryption and signatures with old (PKCS #1 v1.5) and new (PKCS #1 +** v2.1) padding schemes. +** +** rsaPssKey maps to keys with SEC_OID_PKCS1_RSA_PSS_SIGNATURE and may only +** be used for signatures with PSS padding (PKCS #1 v2.1). +** +** rsaOaepKey maps to keys with SEC_OID_PKCS1_RSA_OAEP_ENCRYPTION and may only +** be used for encryption with OAEP padding (PKCS #1 v2.1). +*/ + +typedef enum { + nullKey = 0, + rsaKey = 1, + dsaKey = 2, + fortezzaKey = 3, /* deprecated */ + dhKey = 4, + keaKey = 5, /* deprecated */ + ecKey = 6, + rsaPssKey = 7, + rsaOaepKey = 8, + kyberKey = 9, + edKey = 10, + ecMontKey = 11, + mldsaKey = 12 +} KeyType; + +/* +** Template Definitions +**/ + +SEC_BEGIN_PROTOS +extern const SEC_ASN1Template SECKEY_RSAPublicKeyTemplate[]; +extern const SEC_ASN1Template SECKEY_RSAPSSParamsTemplate[]; +extern const SEC_ASN1Template SECKEY_DSAPublicKeyTemplate[]; +extern const SEC_ASN1Template SECKEY_DHPublicKeyTemplate[]; +extern const SEC_ASN1Template SECKEY_DHParamKeyTemplate[]; +extern const SEC_ASN1Template SECKEY_PQGParamsTemplate[]; +extern const SEC_ASN1Template SECKEY_DSAPrivateKeyExportTemplate[]; + +/* Windows DLL accessor functions */ +SEC_ASN1_CHOOSER_DECLARE(SECKEY_DSAPublicKeyTemplate) +SEC_ASN1_CHOOSER_DECLARE(SECKEY_RSAPublicKeyTemplate) +SEC_ASN1_CHOOSER_DECLARE(SECKEY_RSAPSSParamsTemplate) +SEC_END_PROTOS + +/* +** RSA Public Key structures +** member names from PKCS#1, section 7.1 +*/ + +struct SECKEYRSAPublicKeyStr { + PLArenaPool *arena; + SECItem modulus; + SECItem publicExponent; +}; +typedef struct SECKEYRSAPublicKeyStr SECKEYRSAPublicKey; + +/* +** RSA-PSS parameters +*/ +struct SECKEYRSAPSSParamsStr { + SECAlgorithmID *hashAlg; + SECAlgorithmID *maskAlg; + SECItem saltLength; + SECItem trailerField; +}; +typedef struct SECKEYRSAPSSParamsStr SECKEYRSAPSSParams; + +/* +** DSA Public Key and related structures +*/ + +struct SECKEYPQGParamsStr { + PLArenaPool *arena; + SECItem prime; /* p */ + SECItem subPrime; /* q */ + SECItem base; /* g */ + /* XXX chrisk: this needs to be expanded to hold j and validationParms (RFC2459 7.3.2) */ +}; +typedef struct SECKEYPQGParamsStr SECKEYPQGParams; + +struct SECKEYDSAPublicKeyStr { + SECKEYPQGParams params; + SECItem publicValue; +}; +typedef struct SECKEYDSAPublicKeyStr SECKEYDSAPublicKey; + +/* +** Diffie-Hellman Public Key structure +** Structure member names suggested by PKCS#3. +*/ +struct SECKEYDHParamsStr { + PLArenaPool *arena; + SECItem prime; /* p */ + SECItem base; /* g */ +}; +typedef struct SECKEYDHParamsStr SECKEYDHParams; + +struct SECKEYDHPublicKeyStr { + PLArenaPool *arena; + SECItem prime; + SECItem base; + SECItem publicValue; +}; +typedef struct SECKEYDHPublicKeyStr SECKEYDHPublicKey; + +/* +** Elliptic curve Public Key structure +** The PKCS#11 layer needs DER encoding of ANSI X9.62 +** parameters value +*/ +typedef SECItem SECKEYECParams; + +struct SECKEYECPublicKeyStr { + SECKEYECParams DEREncodedParams; + int size; /* size in bits */ + SECItem publicValue; /* encoded point */ + ECPointEncoding encoding; /* deprecated, ignored */ +}; +typedef struct SECKEYECPublicKeyStr SECKEYECPublicKey; + +/* +** FORTEZZA Public Key structures +*/ +struct SECKEYFortezzaPublicKeyStr { + int KEAversion; + int DSSversion; + unsigned char KMID[8]; + SECItem clearance; + SECItem KEApriviledge; + SECItem DSSpriviledge; + SECItem KEAKey; + SECItem DSSKey; + SECKEYPQGParams params; + SECKEYPQGParams keaParams; +}; +typedef struct SECKEYFortezzaPublicKeyStr SECKEYFortezzaPublicKey; +#define KEAprivilege KEApriviledge /* corrected spelling */ +#define DSSprivilege DSSpriviledge /* corrected spelling */ + +struct SECKEYDiffPQGParamsStr { + SECKEYPQGParams DiffKEAParams; + SECKEYPQGParams DiffDSAParams; +}; +typedef struct SECKEYDiffPQGParamsStr SECKEYDiffPQGParams; + +struct SECKEYPQGDualParamsStr { + SECKEYPQGParams CommParams; + SECKEYDiffPQGParams DiffParams; +}; +typedef struct SECKEYPQGDualParamsStr SECKEYPQGDualParams; + +struct SECKEYKEAParamsStr { + PLArenaPool *arena; + SECItem hash; +}; +typedef struct SECKEYKEAParamsStr SECKEYKEAParams; + +struct SECKEYKEAPublicKeyStr { + SECKEYKEAParams params; + SECItem publicValue; +}; +typedef struct SECKEYKEAPublicKeyStr SECKEYKEAPublicKey; + +/* +** Kyber Public Key structure +*/ + +struct SECKEYKyberPublicKeyStr { + KyberParams params; + SECItem publicValue; +}; +typedef struct SECKEYKyberPublicKeyStr SECKEYKyberPublicKey; + +/* +** ML-DSA Public Key structure +*/ +struct SECKEYMLDSAPublicKeyStr { + SECOidTag paramSet; + SECItem publicValue; +}; +typedef struct SECKEYMLDSAPublicKeyStr SECKEYMLDSAPublicKey; + +/* +** A Generic public key object. +*/ +struct SECKEYPublicKeyStr { + PLArenaPool *arena; + KeyType keyType; + PK11SlotInfo *pkcs11Slot; + CK_OBJECT_HANDLE pkcs11ID; + union { + SECKEYRSAPublicKey rsa; + SECKEYDSAPublicKey dsa; + SECKEYDHPublicKey dh; + SECKEYKEAPublicKey kea; + SECKEYFortezzaPublicKey fortezza; + SECKEYECPublicKey ec; + SECKEYKyberPublicKey kyber; + SECKEYMLDSAPublicKey mldsa; + } u; +}; +typedef struct SECKEYPublicKeyStr SECKEYPublicKey; + +/* bit flag definitions for staticflags */ +#define SECKEY_Attributes_Cached 0x1 /* bit 0 states \ + whether attributes are cached */ +#define SECKEY_CKA_PRIVATE (1U << 1) /* bit 1 is the value of CKA_PRIVATE */ +#define SECKEY_CKA_ALWAYS_AUTHENTICATE (1U << 2) + +#define SECKEY_ATTRIBUTES_CACHED(key) \ + (0 != (key->staticflags & SECKEY_Attributes_Cached)) + +#define SECKEY_ATTRIBUTE_VALUE(key, attribute) \ + (0 != (key->staticflags & SECKEY_##attribute)) + +#define SECKEY_HAS_ATTRIBUTE_SET(key, attribute) \ + (0 != (key->staticflags & SECKEY_Attributes_Cached)) ? (0 != (key->staticflags & SECKEY_##attribute)) : PK11_HasAttributeSet(key->pkcs11Slot, key->pkcs11ID, attribute, PR_FALSE) + +#define SECKEY_HAS_ATTRIBUTE_SET_LOCK(key, attribute, haslock) \ + (0 != (key->staticflags & SECKEY_Attributes_Cached)) ? (0 != (key->staticflags & SECKEY_##attribute)) : pk11_HasAttributeSet_Lock(key->pkcs11Slot, key->pkcs11ID, attribute, haslock) + +/* +** A generic key structure +*/ +struct SECKEYPrivateKeyStr { + PLArenaPool *arena; + KeyType keyType; + PK11SlotInfo *pkcs11Slot; /* pkcs11 slot this key lives in */ + CK_OBJECT_HANDLE pkcs11ID; /* ID of pkcs11 object */ + PRBool pkcs11IsTemp; /* temp pkcs11 object, delete it when done */ + void *wincx; /* context for errors and pw prompts */ + PRUint32 staticflags; /* bit flag of cached PKCS#11 attributes */ +}; +typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; + +typedef struct { + PRCList links; + SECKEYPrivateKey *key; +} SECKEYPrivateKeyListNode; + +typedef struct { + PRCList list; + PLArenaPool *arena; +} SECKEYPrivateKeyList; + +typedef struct { + PRCList links; + SECKEYPublicKey *key; +} SECKEYPublicKeyListNode; + +typedef struct { + PRCList list; + PLArenaPool *arena; +} SECKEYPublicKeyList; +#endif /* _KEYTHI_H_ */ diff --git a/illumos-x86_64/usr/include/mps/kyber.h b/illumos-x86_64/usr/include/mps/kyber.h new file mode 100644 index 00000000..71d98e95 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/kyber.h @@ -0,0 +1,48 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef KYBER_UTIL_H +#define KYBER_UTIL_H + +#define KYBER768_PUBLIC_KEY_BYTES 1184U +#define KYBER768_PRIVATE_KEY_BYTES 2400U +#define KYBER768_CIPHERTEXT_BYTES 1088U + +#define KYBER_SHARED_SECRET_BYTES 32U +#define KYBER_KEYPAIR_COIN_BYTES 64U +#define KYBER_ENC_COIN_BYTES 32U + +#define MAX_ML_KEM_CIPHER_LENGTH KYBER768_CIPHERTEXT_BYTES +#define MAX_ML_KEM_PRIVATE_KEY_LENGTH KYBER768_PRIVATE_KEY_BYTES +#define MAX_ML_KEM_PUBLIC_KEY_LENGTH KYBER768_PUBLIC_KEY_BYTES + +typedef enum { + params_kyber_invalid, + + /* + * The Kyber768 parameters specified in version 3.02 of the NIST submission + * https://pq-crystals.org/kyber/data/kyber-specification-round3-20210804.pdf + */ + params_kyber768_round3, + + /* + * Identical to params_kyber768_round3 except that this parameter set allows + * the use of a seed in `Kyber_Encapsulate` for testing. + */ + params_kyber768_round3_test_mode, + + /* + * The ML-KEM parameters specified in FIPS 203. + * https://csrc.nist.gov/pubs/fips/203/final + */ + params_ml_kem768, + + /* + * Identical to params_ml_kem768 except that this parameter set allows + * the use of a seed in `Kyber_Encapsulate` for testing. + */ + params_ml_kem768_test_mode, +} KyberParams; + +#endif /* KYBER_UTIL_H */ diff --git a/illumos-x86_64/usr/include/mps/lowkeyi.h b/illumos-x86_64/usr/include/mps/lowkeyi.h new file mode 100644 index 00000000..e599f01f --- /dev/null +++ b/illumos-x86_64/usr/include/mps/lowkeyi.h @@ -0,0 +1,70 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _LOWKEYI_H_ +#define _LOWKEYI_H_ + +#include "prtypes.h" +#include "seccomon.h" +#include "secoidt.h" +#include "lowkeyti.h" + +SEC_BEGIN_PROTOS + +/* + * See bugzilla bug 125359 + * Since NSS (via PKCS#11) wants to handle big integers as unsigned ints, + * all of the templates above that en/decode into integers must be converted + * from ASN.1's signed integer type. This is done by marking either the + * source or destination (encoding or decoding, respectively) type as + * siUnsignedInteger. + */ +extern void prepare_low_rsa_priv_key_for_asn1(NSSLOWKEYPrivateKey *key); +extern void prepare_low_pqg_params_for_asn1(PQGParams *params); +extern void prepare_low_dsa_priv_key_for_asn1(NSSLOWKEYPrivateKey *key); +extern void prepare_low_dsa_priv_key_export_for_asn1(NSSLOWKEYPrivateKey *key); +extern void prepare_low_dh_priv_key_for_asn1(NSSLOWKEYPrivateKey *key); +extern void prepare_low_ec_priv_key_for_asn1(NSSLOWKEYPrivateKey *key); +extern void prepare_low_ecparams_for_asn1(ECParams *params); +extern void prepare_low_rsa_pub_key_for_asn1(NSSLOWKEYPublicKey *key); + +/* +** Destroy a private key object. +** "key" the object +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void nsslowkey_DestroyPrivateKey(NSSLOWKEYPrivateKey *key); + +/* +** Destroy a public key object. +** "key" the object +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void nsslowkey_DestroyPublicKey(NSSLOWKEYPublicKey *key); + +/* +** Return the modulus length of "pubKey". +*/ +extern unsigned int nsslowkey_PublicModulusLen(NSSLOWKEYPublicKey *pubKey); + +/* +** Return the modulus length of "privKey". +*/ +extern unsigned int nsslowkey_PrivateModulusLen(NSSLOWKEYPrivateKey *privKey); + +/* +** Convert a low private key "privateKey" into a public low key +*/ +extern NSSLOWKEYPublicKey * +nsslowkey_ConvertToPublicKey(NSSLOWKEYPrivateKey *privateKey); + +/* Make a copy of a low private key in it's own arena. + * a return of NULL indicates an error. + */ +extern NSSLOWKEYPrivateKey * +nsslowkey_CopyPrivateKey(NSSLOWKEYPrivateKey *privKey); + +SEC_END_PROTOS + +#endif /* _LOWKEYI_H_ */ diff --git a/illumos-x86_64/usr/include/mps/lowkeyti.h b/illumos-x86_64/usr/include/mps/lowkeyti.h new file mode 100644 index 00000000..7e77592c --- /dev/null +++ b/illumos-x86_64/usr/include/mps/lowkeyti.h @@ -0,0 +1,100 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _LOWKEYTI_H_ +#define _LOWKEYTI_H_ 1 + +#include "blapit.h" +#include "prtypes.h" +#include "plarena.h" +#include "secitem.h" +#include "secasn1t.h" +#include "secoidt.h" + +/* +** Typedef for callback to get a password "key". +*/ +extern const SEC_ASN1Template nsslowkey_PQGParamsTemplate[]; +extern const SEC_ASN1Template nsslowkey_RSAPrivateKeyTemplate[]; +extern const SEC_ASN1Template nsslowkey_DSAPrivateKeyTemplate[]; +extern const SEC_ASN1Template nsslowkey_DSAPrivateKeyExportTemplate[]; +extern const SEC_ASN1Template nsslowkey_DHPrivateKeyTemplate[]; +extern const SEC_ASN1Template nsslowkey_DHPrivateKeyExportTemplate[]; +#define NSSLOWKEY_EC_PRIVATE_KEY_VERSION 1 /* as per SECG 1 C.4 */ +extern const SEC_ASN1Template nsslowkey_ECPrivateKeyTemplate[]; + +extern const SEC_ASN1Template nsslowkey_PrivateKeyInfoTemplate[]; +extern const SEC_ASN1Template nsslowkey_EncryptedPrivateKeyInfoTemplate[]; +extern const SEC_ASN1Template nsslowkey_SubjectPublicKeyInfoTemplate[]; +extern const SEC_ASN1Template nsslowkey_RSAPublicKeyTemplate[]; + +/* + * PKCS #8 attributes + */ +struct NSSLOWKEYAttributeStr { + SECItem attrType; + SECItem *attrValue; +}; +typedef struct NSSLOWKEYAttributeStr NSSLOWKEYAttribute; + +/* +** A PKCS#8 private key info object +*/ +struct NSSLOWKEYPrivateKeyInfoStr { + PLArenaPool *arena; + SECItem version; + SECAlgorithmID algorithm; + SECItem privateKey; + NSSLOWKEYAttribute **attributes; +}; +typedef struct NSSLOWKEYPrivateKeyInfoStr NSSLOWKEYPrivateKeyInfo; +#define NSSLOWKEY_PRIVATE_KEY_INFO_VERSION 0 /* what we *create* */ + +struct NSSLOWKEYSubjectPublicKeyInfoStr { + PLArenaPool *arena; + SECAlgorithmID algorithm; + SECItem subjectPublicKey; +}; +typedef struct NSSLOWKEYSubjectPublicKeyInfoStr NSSLOWKEYSubjectPublicKeyInfo; + +typedef enum { + NSSLOWKEYNullKey = 0, + NSSLOWKEYRSAKey = 1, + NSSLOWKEYDSAKey = 2, + NSSLOWKEYDHKey = 4, + NSSLOWKEYECKey = 5 +} NSSLOWKEYType; + +/* +** An RSA public key object. +*/ +struct NSSLOWKEYPublicKeyStr { + PLArenaPool *arena; + NSSLOWKEYType keyType; + union { + RSAPublicKey rsa; + DSAPublicKey dsa; + DHPublicKey dh; + ECPublicKey ec; + } u; +}; +typedef struct NSSLOWKEYPublicKeyStr NSSLOWKEYPublicKey; + +/* +** Low Level private key object +** This is only used by the raw Crypto engines (crypto), keydb (keydb), +** and PKCS #11. Everyone else uses the high level key structure. +*/ +struct NSSLOWKEYPrivateKeyStr { + PLArenaPool *arena; + NSSLOWKEYType keyType; + union { + RSAPrivateKey rsa; + DSAPrivateKey dsa; + DHPrivateKey dh; + ECPrivateKey ec; + } u; +}; +typedef struct NSSLOWKEYPrivateKeyStr NSSLOWKEYPrivateKey; + +#endif /* _LOWKEYTI_H_ */ diff --git a/illumos-x86_64/usr/include/mps/md/_aix32.cfg b/illumos-x86_64/usr/include/mps/md/_aix32.cfg new file mode 100644 index 00000000..23a3f512 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_aix32.cfg @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef AIX +#define AIX +#endif + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_AF_INET6 24 /* same as AF_INET6 */ + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +/* used by protypes.h only */ +#define _PR_AIX_HAVE_BSD_INT_TYPES + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_aix64.cfg b/illumos-x86_64/usr/include/mps/md/_aix64.cfg new file mode 100644 index 00000000..7efe896d --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_aix64.cfg @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef AIX +#define AIX +#endif + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 8 + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_AF_INET6 24 /* same as AF_INET6 */ + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +/* used by protypes.h only */ +#define _PR_AIX_HAVE_BSD_INT_TYPES + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_darwin.cfg b/illumos-x86_64/usr/include/mps/md/_darwin.cfg new file mode 100644 index 00000000..5e118933 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_darwin.cfg @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#define PR_AF_INET6 30 /* same as AF_INET6 */ + +#ifdef __LITTLE_ENDIAN__ +#undef IS_BIG_ENDIAN +#define IS_LITTLE_ENDIAN 1 +#else +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#endif + +#ifdef __LP64__ +#define IS_64 +#endif + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#undef HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS 1 + +#ifdef IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 + +#else /* IS_64 */ + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 +#define PR_BITS_PER_DWORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#endif /* IS_64 */ + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ + diff --git a/illumos-x86_64/usr/include/mps/md/_freebsd.cfg b/illumos-x86_64/usr/include/mps/md/_freebsd.cfg new file mode 100644 index 00000000..1d1039a5 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_freebsd.cfg @@ -0,0 +1,594 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef FREEBSD +#define FREEBSD +#endif + +#define PR_AF_INET6 28 /* same as AF_INET6 */ + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif + +#if defined(__i386__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#elif defined(__alpha__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#elif defined(__sparc__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#elif defined(__ia64__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#elif defined(__amd64__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#elif defined(__powerpc64__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__powerpc__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__aarch64__) + +#undef IS_BIG_ENDIAN +#define IS_LITTLE_ENDIAN 1 +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__arm__) + +#if defined(__ARMEB__) || defined(__ARM_BIG_ENDIAN__) +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#else +#undef IS_BIG_ENDIAN +#define IS_LITTLE_ENDIAN 1 +#endif + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__mips64__) + +#if defined(__MIPSEB__) || defined(_MIPSEB) +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#else +#undef IS_BIG_ENDIAN +#define IS_LITTLE_ENDIAN 1 +#endif + +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__mips__) + +#if defined(__MIPSEB__) || defined(_MIPSEB) +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#else +#undef IS_BIG_ENDIAN +#define IS_LITTLE_ENDIAN 1 +#endif + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else + +#error "Unknown CPU architecture" + +#endif + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_hpux32.cfg b/illumos-x86_64/usr/include/mps/md/_hpux32.cfg new file mode 100644 index 00000000..08950cbf --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_hpux32.cfg @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef HPUX +#define HPUX +#endif + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_AF_INET6 22 /* same as AF_INET6 */ + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_hpux64.cfg b/illumos-x86_64/usr/include/mps/md/_hpux64.cfg new file mode 100644 index 00000000..028a034f --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_hpux64.cfg @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef HPUX +#define HPUX +#endif + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define IS_64 + +#define PR_AF_INET6 22 /* same as AF_INET6 */ + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_linux.cfg b/illumos-x86_64/usr/include/mps/md/_linux.cfg new file mode 100644 index 00000000..009d5e56 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_linux.cfg @@ -0,0 +1,1369 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * This file is used by not only Linux but also other glibc systems + * such as GNU/Hurd and GNU/k*BSD. + */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#if !defined(LINUX) && defined(__linux__) +#define LINUX +#endif + +#ifdef __FreeBSD_kernel__ +#define PR_AF_INET6 28 /* same as AF_INET6 */ +#elif defined(__GNU__) +#define PR_AF_INET6 26 /* same as AF_INET6 */ +#else +#define PR_AF_INET6 10 /* same as AF_INET6 */ +#endif + +#ifdef __powerpc64__ + +#ifdef __LITTLE_ENDIAN__ +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#else +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#endif +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__powerpc__) + +#ifdef __LITTLE_ENDIAN__ +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#else +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#endif + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__alpha) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__ia64__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__x86_64__) + +#ifdef __ILP32__ + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#endif + +#elif defined(__mc68000__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 2 +#define PR_ALIGN_OF_LONG 2 +#define PR_ALIGN_OF_INT64 2 +#define PR_ALIGN_OF_FLOAT 2 +#define PR_ALIGN_OF_DOUBLE 2 +#define PR_ALIGN_OF_POINTER 2 +#define PR_ALIGN_OF_WORD 2 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__sparc__) && defined (__arch64__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__sparc__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__i386__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__mips__) + +/* For _ABI64 */ +#if defined(__GLIBC__) || defined(__UCLIBC__) +#include +#else +#include +#endif + +#ifdef __MIPSEB__ +#define IS_BIG_ENDIAN 1 +#undef IS_LITTLE_ENDIAN +#elif defined(__MIPSEL__) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#else +#error "Unknown MIPS endianness." +#endif + +#if _MIPS_SIM == _ABI64 + +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else /* _ABI64 */ + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#endif /* _ABI64 */ + +#elif defined(__arm__) + +#ifdef __ARMEB__ +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#elif defined(__ARMEL__) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#else +#error "Unknown ARM endianness." +#endif + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__aarch64__) + +#ifdef __AARCH64EB__ +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#elif defined(__AARCH64EL__) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#else +#error "Unknown Aarch64 endianness." +#endif +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__hppa__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__s390x__) + +#define IS_BIG_ENDIAN 1 +#undef IS_LITTLE_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__s390__) + +#define IS_BIG_ENDIAN 1 +#undef IS_LITTLE_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__sh__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__avr32__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__m32r__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__or1k__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__riscv) && (__riscv_xlen == 32) + +#undef IS_BIG_ENDIAN +#define IS_LITTLE_ENDIAN 1 +#undef IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__riscv) && (__riscv_xlen == 64) + +#undef IS_BIG_ENDIAN +#define IS_LITTLE_ENDIAN 1 +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__arc__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__nios2__) || defined(__microblaze__) || defined(__nds32__) || \ + defined(__xtensa__) + +#if defined(__microblaze__) && defined(__BIG_ENDIAN__) +#define IS_BIG_ENDIAN 1 +#undef IS_LITTLE_ENDIAN +#else +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#endif + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__e2k__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 4 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 32 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 5 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__loongarch64) + +#undef IS_BIG_ENDIAN +#define IS_LITTLE_ENDIAN 1 +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else + +#error "Unknown CPU architecture" + +#endif + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#if PR_ALIGN_OF_DOUBLE == 8 +#define HAVE_ALIGNED_DOUBLES +#endif +#if PR_ALIGN_OF_INT64 == 8 +#define HAVE_ALIGNED_LONGLONGS +#endif + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_netbsd.cfg b/illumos-x86_64/usr/include/mps/md/_netbsd.cfg new file mode 100644 index 00000000..1326556e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_netbsd.cfg @@ -0,0 +1,351 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef NETBSD +#define NETBSD +#endif + +#define PR_AF_INET6 24 /* same as AF_INET6 */ + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif + +#if defined(__i386__) || defined(__arm32__) || defined(__ARMEL__) || \ + defined(__MIPSEL__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#elif defined(__sparc_v9__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#elif defined(__sparc__) || defined(__MIPSEB__) || defined(__ARMEB__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 + +#elif defined(__alpha__) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__amd64__) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__powerpc__) || defined(__m68k__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else + +#error Must define constants for type sizes here. + +#endif + + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_nto.cfg b/illumos-x86_64/usr/include/mps/md/_nto.cfg new file mode 100644 index 00000000..b76a5605 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_nto.cfg @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef NTO +#define NTO +#endif + +#define PR_AF_INET6 24 /* same as AF_INET6 */ + +#ifdef __i386__ + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1L +#define PR_BYTES_PER_SHORT 2L +#define PR_BYTES_PER_INT 4L +#define PR_BYTES_PER_INT64 8L +#define PR_BYTES_PER_LONG 4L +#define PR_BYTES_PER_FLOAT 4L +#define PR_BYTES_PER_DOUBLE 8L +#define PR_BYTES_PER_WORD 4L +#define PR_BYTES_PER_DWORD 8L + +#define PR_BITS_PER_BYTE 8L +#define PR_BITS_PER_SHORT 16L +#define PR_BITS_PER_INT 32L +#define PR_BITS_PER_INT64 64L +#define PR_BITS_PER_LONG 32L +#define PR_BITS_PER_FLOAT 32L +#define PR_BITS_PER_DOUBLE 64L +#define PR_BITS_PER_WORD 32L + +#define PR_BITS_PER_BYTE_LOG2 3L +#define PR_BITS_PER_SHORT_LOG2 4L +#define PR_BITS_PER_INT_LOG2 5L +#define PR_BITS_PER_INT64_LOG2 6L +#define PR_BITS_PER_LONG_LOG2 5L +#define PR_BITS_PER_FLOAT_LOG2 5L +#define PR_BITS_PER_DOUBLE_LOG2 6L +#define PR_BITS_PER_WORD_LOG2 5L + +#define PR_ALIGN_OF_SHORT 2L +#define PR_ALIGN_OF_INT 4L +#define PR_ALIGN_OF_LONG 4L +#define PR_ALIGN_OF_INT64 4L +#define PR_ALIGN_OF_FLOAT 4L +#define PR_ALIGN_OF_DOUBLE 4L +#define PR_ALIGN_OF_POINTER 4L +#define PR_ALIGN_OF_WORD 4L + +#define PR_BYTES_PER_WORD_LOG2 2L +#define PR_BYTES_PER_DWORD_LOG2 3L +#define PR_WORDS_PER_DWORD_LOG2 1L + +#else + +#error Undefined CPU Architecture + +#endif + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_openbsd.cfg b/illumos-x86_64/usr/include/mps/md/_openbsd.cfg new file mode 100644 index 00000000..b68d6e9c --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_openbsd.cfg @@ -0,0 +1,353 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef OPENBSD +#define OPENBSD +#endif + +#define PR_AF_INET6 24 /* same as AF_INET6 */ + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif + +#if defined(__i386__) || defined(__arm__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#elif defined(__amd64__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS + +#elif defined(__sparc_v9__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__sparc__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 + +#elif defined(__alpha__) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__powerpc__) || defined(__m68k__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else + +#error Must define constants for type sizes here. + +#endif + + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_qnx.cfg b/illumos-x86_64/usr/include/mps/md/_qnx.cfg new file mode 100644 index 00000000..a459b8cb --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_qnx.cfg @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef QNX +#define QNX +#endif + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#undef HAVE_LONG_LONG +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 1 +#define PR_ALIGN_OF_INT 1 +#define PR_ALIGN_OF_LONG 1 +#define PR_ALIGN_OF_INT64 1 +#define PR_ALIGN_OF_FLOAT 1 +#define PR_ALIGN_OF_DOUBLE 1 +#define PR_ALIGN_OF_POINTER 1 +#define PR_ALIGN_OF_WORD 1 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 +#define PR_WORDS_PER_DWORD_LOG2 1 + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_riscos.cfg b/illumos-x86_64/usr/include/mps/md/_riscos.cfg new file mode 100644 index 00000000..c7adf2e1 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_riscos.cfg @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef RISCOS +#define RISCOS +#endif + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 +#define PR_WORDS_PER_DWORD_LOG2 1 + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_solaris.cfg b/illumos-x86_64/usr/include/mps/md/_solaris.cfg new file mode 100644 index 00000000..7473039b --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_solaris.cfg @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef SOLARIS +#define SOLARIS +#endif + +#define PR_AF_INET6 26 /* same as AF_INET6 */ + +#if defined(sparc) || defined(__sparc) +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_DOUBLE 8 +#if defined(__sparcv9) +#define IS_64 +#endif +#elif defined(__x86_64) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define IS_64 +#elif defined(i386) || defined(__i386) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_DOUBLE 4 +#elif defined(__aarch64__) || defined(__aarch64) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define IS_64 +#else +#error unknown processor +#endif + +#ifdef IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_POINTER 8 + +#else /* IS_64 */ + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_POINTER 4 + +#endif /* IS_64 */ + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* ifndef nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_win95.cfg b/illumos-x86_64/usr/include/mps/md/_win95.cfg new file mode 100644 index 00000000..7c379fce --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_win95.cfg @@ -0,0 +1,321 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_PC +#define XP_PC +#endif + +#ifndef WIN32 +#define WIN32 +#endif + +#ifndef WIN95 +#define WIN95 +#endif + +#define PR_AF_INET6 23 /* same as AF_INET6 */ + +#if defined(_M_IX86) || defined(_X86_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 32 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 5 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 4 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(_M_IA64) || defined(_IA64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(_M_ARM) || defined(_ARM_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 32 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 5 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 4 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(_M_ARM64) || defined(_ARM64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else /* defined(_M_IX86) || defined(_X86_) */ + +#error unknown processor architecture + +#endif /* defined(_M_IX86) || defined(_X86_) */ + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/md/_winnt.cfg b/illumos-x86_64/usr/include/mps/md/_winnt.cfg new file mode 100644 index 00000000..e2a277fd --- /dev/null +++ b/illumos-x86_64/usr/include/mps/md/_winnt.cfg @@ -0,0 +1,224 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_PC +#define XP_PC +#endif + +#ifndef WIN32 +#define WIN32 +#endif + +#ifndef WINNT +#define WINNT +#endif + +#define PR_AF_INET6 23 /* same as AF_INET6 */ + +#if defined(_M_IX86) || defined(_X86_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 32 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 5 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 4 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 2 + +#elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(_M_IA64) || defined(_IA64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else /* defined(_M_IX86) || defined(_X86_) */ + +#error unknown processor architecture + +#endif /* defined(_M_IX86) || defined(_X86_) */ + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/ml_dsat.h b/illumos-x86_64/usr/include/mps/ml_dsat.h new file mode 100644 index 00000000..32a7e37e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/ml_dsat.h @@ -0,0 +1,31 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef ML_DSAT_H +#define ML_DSAT_H + +// ML_DSA Key and signature sizes, independent of implementation + +// ml_dsa_44 +#define ML_DSA_44_PUBLICKEY_LEN 1312 +#define ML_DSA_44_PRIVATEKEY_LEN 2560 +#define ML_DSA_44_SIGNATURE_LEN 2420 + +// ml_dsa_65 +#define ML_DSA_65_PUBLICKEY_LEN 1952 +#define ML_DSA_65_PRIVATEKEY_LEN 4032 +#define ML_DSA_65_SIGNATURE_LEN 3309 + +// ml_dsa_87 +#define ML_DSA_87_PUBLICKEY_LEN 2592 +#define ML_DSA_87_PRIVATEKEY_LEN 4896 +#define ML_DSA_87_SIGNATURE_LEN 4627 + +// the max defines and common defines +#define MAX_ML_DSA_PRIVATE_KEY_LEN ML_DSA_87_PRIVATEKEY_LEN +#define MAX_ML_DSA_PUBLIC_KEY_LEN ML_DSA_87_PUBLICKEY_LEN +#define MAX_ML_DSA_SIGNATURE_LEN ML_DSA_87_SIGNATURE_LEN +#define ML_DSA_SEED_LEN 32 + +#endif /* ML_DSAT_H */ diff --git a/illumos-x86_64/usr/include/mps/nspr.h b/illumos-x86_64/usr/include/mps/nspr.h new file mode 100644 index 00000000..0cbc71c1 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nspr.h @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_h___ +#define nspr_h___ + +#include "pratom.h" +#include "prbit.h" +#include "prclist.h" +#include "prcmon.h" +#include "prcvar.h" +#include "prdtoa.h" +#include "prenv.h" +#include "prerror.h" +#include "prinet.h" +#include "prinit.h" +#include "prinrval.h" +#include "prio.h" +#include "pripcsem.h" +#include "prlink.h" +#include "prlock.h" +#include "prlog.h" +#include "prlong.h" +#include "prmem.h" +#include "prmon.h" +#include "prmwait.h" +#include "prnetdb.h" +#include "prprf.h" +#include "prproces.h" +#include "prrng.h" +#include "prrwlock.h" +#include "prshm.h" +#include "prshma.h" +#include "prsystem.h" +#include "prthread.h" +#include "prtime.h" +#include "prtpool.h" +#include "prtrace.h" +#include "prtypes.h" + +#endif /* nspr_h___ */ diff --git a/illumos-x86_64/usr/include/mps/nss.h b/illumos-x86_64/usr/include/mps/nss.h new file mode 100644 index 00000000..275a90b0 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nss.h @@ -0,0 +1,357 @@ +/* + * NSS utility functions + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __nss_h_ +#define __nss_h_ + +/* The private macro _NSS_CUSTOMIZED is for NSS internal use only. */ +#if defined(NSS_ALLOW_UNSUPPORTED_CRITICAL) +#define _NSS_CUSTOMIZED " (Customized build)" +#else +#define _NSS_CUSTOMIZED +#endif + +/* + * NSS's major version, minor version, patch level, build number, and whether + * this is a beta release. + * + * The format of the version string should be + * ".[.[.]][ ][ ]" + */ +#define NSS_VERSION "3.116" _NSS_CUSTOMIZED +#define NSS_VMAJOR 3 +#define NSS_VMINOR 116 +#define NSS_VPATCH 0 +#define NSS_VBUILD 0 +#define NSS_BETA PR_FALSE + +#ifndef RC_INVOKED + +#include "seccomon.h" + +typedef struct NSSInitParametersStr NSSInitParameters; + +/* + * parameters used to initialize softoken. Mostly strings used to + * internationalize softoken. Memory for the strings are owned by the caller, + * who is free to free them once NSS_ContextInit returns. If the string + * parameter is NULL (as opposed to empty, zero length), then the softoken + * default is used. These are equivalent to the parameters for + * PK11_ConfigurePKCS11(). + * + * field names match their equivalent parameter names for softoken strings + * documented at https://developer.mozilla.org/en/PKCS11_Module_Specs. + * + * minPWLen + * Minimum password length in bytes. + * manufacturerID + * Override the default manufactureID value for the module returned in + * the CK_INFO, CK_SLOT_INFO, and CK_TOKEN_INFO structures with an + * internationalize string (UTF8). This value will be truncated at 32 + * bytes (not including the trailing NULL, partial UTF8 characters will be + * dropped). + * libraryDescription + * Override the default libraryDescription value for the module returned in + * the CK_INFO structure with an internationalize string (UTF8). This value + * will be truncated at 32 bytes(not including the trailing NULL, partial + * UTF8 characters will be dropped). + * cryptoTokenDescription + * Override the default label value for the internal crypto token returned + * in the CK_TOKEN_INFO structure with an internationalize string (UTF8). + * This value will be truncated at 32 bytes (not including the trailing + * NULL, partial UTF8 characters will be dropped). + * dbTokenDescription + * Override the default label value for the internal DB token returned in + * the CK_TOKEN_INFO structure with an internationalize string (UTF8). This + * value will be truncated at 32 bytes (not including the trailing NULL, + * partial UTF8 characters will be dropped). + * FIPSTokenDescription + * Override the default label value for the internal FIPS token returned in + * the CK_TOKEN_INFO structure with an internationalize string (UTF8). This + * value will be truncated at 32 bytes (not including the trailing NULL, + * partial UTF8 characters will be dropped). + * cryptoSlotDescription + * Override the default slotDescription value for the internal crypto token + * returned in the CK_SLOT_INFO structure with an internationalize string + * (UTF8). This value will be truncated at 64 bytes (not including the + * trailing NULL, partial UTF8 characters will be dropped). + * dbSlotDescription + * Override the default slotDescription value for the internal DB token + * returned in the CK_SLOT_INFO structure with an internationalize string + * (UTF8). This value will be truncated at 64 bytes (not including the + * trailing NULL, partial UTF8 characters will be dropped). + * FIPSSlotDescription + * Override the default slotDecription value for the internal FIPS token + * returned in the CK_SLOT_INFO structure with an internationalize string + * (UTF8). This value will be truncated at 64 bytes (not including the + * trailing NULL, partial UTF8 characters will be dropped). + * + */ +struct NSSInitParametersStr { + unsigned int length; /* allow this structure to grow in the future, + * must be set */ + PRBool passwordRequired; + int minPWLen; + char *manufactureID; /* variable names for strings match the */ + char *libraryDescription; /* parameter name in softoken */ + char *cryptoTokenDescription; + char *dbTokenDescription; + char *FIPSTokenDescription; + char *cryptoSlotDescription; + char *dbSlotDescription; + char *FIPSSlotDescription; +}; + +SEC_BEGIN_PROTOS + +/* + * Return a boolean that indicates whether the underlying library + * will perform as the caller expects. + * + * The only argument is a string, which should be the version + * identifier of the NSS library. That string will be compared + * against a string that represents the actual build version of + * the NSS library. + */ +extern PRBool NSS_VersionCheck(const char *importedVersion); + +/* + * Returns a const string of the NSS library version. + */ +extern const char *NSS_GetVersion(void); + +/* + * Open the Cert, Key, and Security Module databases, read only. + * Initialize the Random Number Generator. + * Does not initialize the cipher policies or enables. + * Default policy settings disallow all ciphers. + */ +extern SECStatus NSS_Init(const char *configdir); + +/* + * Returns whether NSS has already been initialized or not. + */ +extern PRBool NSS_IsInitialized(void); + +/* + * Open the Cert, Key, and Security Module databases, read/write. + * Initialize the Random Number Generator. + * Does not initialize the cipher policies or enables. + * Default policy settings disallow all ciphers. + */ +extern SECStatus NSS_InitReadWrite(const char *configdir); + +/* + * Open the Cert, Key, and Security Module databases, read/write. + * Initialize the Random Number Generator. + * Does not initialize the cipher policies or enables. + * Default policy settings disallow all ciphers. + * + * This allows using application defined prefixes for the cert and key db's + * and an alternate name for the secmod database. NOTE: In future releases, + * the database prefixes my not necessarily map to database names. + * + * configdir - base directory where all the cert, key, and module datbases live. + * certPrefix - prefix added to the beginning of the cert database example: " + * "https-server1-" + * keyPrefix - prefix added to the beginning of the key database example: " + * "https-server1-" + * secmodName - name of the security module database (usually "secmod.db"). + * flags - change the open options of NSS_Initialize as follows: + * NSS_INIT_READONLY - Open the databases read only. + * NSS_INIT_NOCERTDB - Don't open the cert DB and key DB's, just + * initialize the volatile certdb. + * NSS_INIT_NOMODDB - Don't open the security module DB, just + * initialize the PKCS #11 module. + * NSS_INIT_FORCEOPEN - Continue to force initializations even if the + * databases cannot be opened. + * NSS_INIT_NOROOTINIT - Don't try to look for the root certs module + * automatically. + * NSS_INIT_OPTIMIZESPACE - Use smaller tables and caches. + * NSS_INIT_PK11THREADSAFE - only load PKCS#11 modules that are + * thread-safe, ie. that support locking - either OS + * locking or NSS-provided locks . If a PKCS#11 + * module isn't thread-safe, don't serialize its + * calls; just don't load it instead. This is necessary + * if another piece of code is using the same PKCS#11 + * modules that NSS is accessing without going through + * NSS, for example the Java SunPKCS11 provider. + * NSS_INIT_PK11RELOAD - ignore the CKR_CRYPTOKI_ALREADY_INITIALIZED + * error when loading PKCS#11 modules. This is necessary + * if another piece of code is using the same PKCS#11 + * modules that NSS is accessing without going through + * NSS, for example Java SunPKCS11 provider. + * NSS_INIT_NOPK11FINALIZE - never call C_Finalize on any + * PKCS#11 module. This may be necessary in order to + * ensure continuous operation and proper shutdown + * sequence if another piece of code is using the same + * PKCS#11 modules that NSS is accessing without going + * through NSS, for example Java SunPKCS11 provider. + * The following limitation applies when this is set : + * SECMOD_WaitForAnyTokenEvent will not use + * C_WaitForSlotEvent, in order to prevent the need for + * C_Finalize. This call will be emulated instead. + * NSS_INIT_RESERVED - Currently has no effect, but may be used in the + * future to trigger better cooperation between PKCS#11 + * modules used by both NSS and the Java SunPKCS11 + * provider. This should occur after a new flag is defined + * for C_Initialize by the PKCS#11 working group. + * NSS_INIT_COOPERATE - Sets 4 recommended options for applications that + * use both NSS and the Java SunPKCS11 provider. + * + * Also NOTE: This is not the recommended method for initializing NSS. + * The preferred method is NSS_init(). + */ +#define NSS_INIT_READONLY 0x1 +#define NSS_INIT_NOCERTDB 0x2 +#define NSS_INIT_NOMODDB 0x4 +#define NSS_INIT_FORCEOPEN 0x8 +#define NSS_INIT_NOROOTINIT 0x10 +#define NSS_INIT_OPTIMIZESPACE 0x20 +#define NSS_INIT_PK11THREADSAFE 0x40 +#define NSS_INIT_PK11RELOAD 0x80 +#define NSS_INIT_NOPK11FINALIZE 0x100 +#define NSS_INIT_RESERVED 0x200 + +#define NSS_INIT_COOPERATE NSS_INIT_PK11THREADSAFE | \ + NSS_INIT_PK11RELOAD | \ + NSS_INIT_NOPK11FINALIZE | \ + NSS_INIT_RESERVED + +#define SECMOD_DB "secmod.db" + +typedef struct NSSInitContextStr NSSInitContext; + +extern SECStatus NSS_Initialize(const char *configdir, + const char *certPrefix, const char *keyPrefix, + const char *secmodName, PRUint32 flags); + +extern NSSInitContext *NSS_InitContext(const char *configdir, + const char *certPrefix, const char *keyPrefix, + const char *secmodName, NSSInitParameters *initParams, PRUint32 flags); + +extern SECStatus NSS_ShutdownContext(NSSInitContext *); + +/* + * same as NSS_Init, but checks to see if we need to merge an + * old database in. + * updatedir is the directory where the old database lives. + * updCertPrefix is the certPrefix for the old database. + * updKeyPrefix is the keyPrefix for the old database. + * updateID is a unique identifier chosen by the application for + * the specific database. + * updatName is the name the user will be prompted for when + * asking to authenticate to the old database */ +extern SECStatus NSS_InitWithMerge(const char *configdir, + const char *certPrefix, const char *keyPrefix, const char *secmodName, + const char *updatedir, const char *updCertPrefix, + const char *updKeyPrefix, const char *updateID, + const char *updateName, PRUint32 flags); +/* + * initialize NSS without a creating cert db's, key db's, or secmod db's. + */ +SECStatus NSS_NoDB_Init(const char *configdir); + +/* + * Allow applications and libraries to register with NSS so that they are called + * when NSS shuts down. + * + * void *appData application specific data passed in by the application at + * NSS_RegisterShutdown() time. + * void *nssData is NULL in this release, but is reserved for future versions of + * NSS to pass some future status information * back to the shutdown function. + * + * If the shutdown function returns SECFailure, + * Shutdown will still complete, but NSS_Shutdown() will return SECFailure. + */ +typedef SECStatus (*NSS_ShutdownFunc)(void *appData, void *nssData); + +/* + * Register a shutdown function. + */ +SECStatus NSS_RegisterShutdown(NSS_ShutdownFunc sFunc, void *appData); + +/* + * Remove an existing shutdown function (you may do this if your library is + * complete and going away, but NSS is still running). + */ +SECStatus NSS_UnregisterShutdown(NSS_ShutdownFunc sFunc, void *appData); + +/* Available options for NSS_OptionSet() and NSS_OptionGet(). + */ +#define NSS_RSA_MIN_KEY_SIZE 0x001 +#define NSS_DH_MIN_KEY_SIZE 0x002 +#define NSS_DSA_MIN_KEY_SIZE 0x004 +#define NSS_TLS_VERSION_MIN_POLICY 0x008 +#define NSS_TLS_VERSION_MAX_POLICY 0x009 +#define NSS_DTLS_VERSION_MIN_POLICY 0x00a +#define NSS_DTLS_VERSION_MAX_POLICY 0x00b + +/* Until NSS 3.30, the PKCS#12 implementation used BMPString encoding + * for all passwords. This changed to use UTF-8 for non-PKCS#12 PBEs + * in NSS 3.31. + * + * For backward compatibility, this option reverts the behavior to the + * old NSS versions. This option might be removed in the future NSS + * releases; don't rely on it. */ +#define __NSS_PKCS12_DECODE_FORCE_UNICODE 0x00c +#define NSS_DEFAULT_LOCKS 0x00d /* lock default values */ +#define NSS_DEFAULT_SSL_LOCK 1 /* lock the ssl default values */ + +/* NSS_KEY_SIZE_POLICY controls what kinds of operations are subject to + * the NSS_XXX_MIN_KEY_SIZE values. + * NSS_KEY_SIZE_POLICY_FLAGS sets and clears all the flags to the input + * value + * On get it returns all the flags + * NSS_KEY_SIZE_POLICY_SET_FLAGS sets only the flags=1 in the input value + * and does not affect the other flags + * On get it returns all the flags + * NSS_KEY_SIZE_POLICY_CLEAR_FLAGS clears only the flags=1 in the input + * value and does not affect the other flags + * On get it returns all the compliment of all the flags + * (cleared flags == 1) */ +#define NSS_KEY_SIZE_POLICY_FLAGS 0x00e +#define NSS_KEY_SIZE_POLICY_SET_FLAGS 0x00f +#define NSS_KEY_SIZE_POLICY_CLEAR_FLAGS 0x010 +/* currently defined flags */ +#define NSS_KEY_SIZE_POLICY_SSL_FLAG 1 +#define NSS_KEY_SIZE_POLICY_VERIFY_FLAG 2 +#define NSS_KEY_SIZE_POLICY_SIGN_FLAG 4 +#define NSS_KEY_SIZE_POLICY_SMIME_FLAG 8 +#define NSS_KEY_SIZE_POLICY_ALL_FLAGS 0x0f + +#define NSS_ECC_MIN_KEY_SIZE 0x011 + +/* + * Set and get global options for the NSS library. + */ +SECStatus NSS_OptionSet(PRInt32 which, PRInt32 value); +SECStatus NSS_OptionGet(PRInt32 which, PRInt32 *value); + +/* + * Close the Cert, Key databases. + */ +extern SECStatus NSS_Shutdown(void); + +/* + * set the PKCS #11 strings for the internal token. + */ +void PK11_ConfigurePKCS11(const char *man, const char *libdesc, + const char *tokdesc, const char *ptokdesc, const char *slotdesc, + const char *pslotdesc, const char *fslotdesc, const char *fpslotdesc, + int minPwd, int pwRequired); + +/* + * Dump the contents of the certificate cache and the temporary cert store. + * Use to detect leaked references of certs at shutdown time. + */ +void nss_DumpCertificateCacheInfo(void); + +SEC_END_PROTOS + +#endif /* RC_INVOKED */ +#endif /* __nss_h_ */ diff --git a/illumos-x86_64/usr/include/mps/nssb64.h b/illumos-x86_64/usr/include/mps/nssb64.h new file mode 100644 index 00000000..7882c3b2 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssb64.h @@ -0,0 +1,94 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Public prototypes for base64 encoding/decoding. + */ +#ifndef _NSSB64_H_ +#define _NSSB64_H_ + +#include "utilrename.h" +#include "seccomon.h" +#include "nssb64t.h" + +SEC_BEGIN_PROTOS + +/* + * Functions to start a base64 decoding/encoding context. + */ + +extern NSSBase64Decoder * +NSSBase64Decoder_Create(PRInt32 (*output_fn)(void *, const unsigned char *, + PRInt32), + void *output_arg); + +extern NSSBase64Encoder * +NSSBase64Encoder_Create(PRInt32 (*output_fn)(void *, const char *, PRInt32), + void *output_arg); + +/* + * Push data through the decoder/encoder, causing the output_fn (provided + * to Create) to be called with the decoded/encoded data. + */ + +extern SECStatus +NSSBase64Decoder_Update(NSSBase64Decoder *data, const char *buffer, + PRUint32 size); + +extern SECStatus +NSSBase64Encoder_Update(NSSBase64Encoder *data, const unsigned char *buffer, + PRUint32 size); + +/* + * When you're done processing, call this to close the context. + * If "abort_p" is false, then calling this may cause the output_fn + * to be called one last time (as the last buffered data is flushed out). + */ + +extern SECStatus +NSSBase64Decoder_Destroy(NSSBase64Decoder *data, PRBool abort_p); + +extern SECStatus +NSSBase64Encoder_Destroy(NSSBase64Encoder *data, PRBool abort_p); + +/* + * Perform base64 decoding from an ascii string "inStr" to an Item. + * The length of the input must be provided as "inLen". The Item + * may be provided (as "outItemOpt"); you can also pass in a NULL + * and the Item will be allocated for you. + * + * In any case, the data within the Item will be allocated for you. + * All allocation will happen out of the passed-in "arenaOpt", if non-NULL. + * If "arenaOpt" is NULL, standard allocation (heap) will be used and + * you will want to free the result via SECITEM_FreeItem. + * + * Return value is NULL on error, the Item (allocated or provided) otherwise. + */ +extern SECItem * +NSSBase64_DecodeBuffer(PLArenaPool *arenaOpt, SECItem *outItemOpt, + const char *inStr, unsigned int inLen); + +/* + * Perform base64 encoding of binary data "inItem" to an ascii string. + * The output buffer may be provided (as "outStrOpt"); you can also pass + * in a NULL and the buffer will be allocated for you. The result will + * be null-terminated, and if the buffer is provided, "maxOutLen" must + * specify the maximum length of the buffer and will be checked to + * supply sufficient space space for the encoded result. (If "outStrOpt" + * is NULL, "maxOutLen" is ignored.) + * + * If "outStrOpt" is NULL, allocation will happen out of the passed-in + * "arenaOpt", if *it* is non-NULL, otherwise standard allocation (heap) + * will be used. + * + * Return value is NULL on error, the output buffer (allocated or provided) + * otherwise. + */ +extern char * +NSSBase64_EncodeItem(PLArenaPool *arenaOpt, char *outStrOpt, + unsigned int maxOutLen, SECItem *inItem); + +SEC_END_PROTOS + +#endif /* _NSSB64_H_ */ diff --git a/illumos-x86_64/usr/include/mps/nssb64t.h b/illumos-x86_64/usr/include/mps/nssb64t.h new file mode 100644 index 00000000..75e7877b --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssb64t.h @@ -0,0 +1,15 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Public data structures for base64 encoding/decoding. + */ +#ifndef _NSSB64T_H_ +#define _NSSB64T_H_ + +#include "utilrename.h" +typedef struct NSSBase64DecoderStr NSSBase64Decoder; +typedef struct NSSBase64EncoderStr NSSBase64Encoder; + +#endif /* _NSSB64T_H_ */ diff --git a/illumos-x86_64/usr/include/mps/nssbase.h b/illumos-x86_64/usr/include/mps/nssbase.h new file mode 100644 index 00000000..02e285fb --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssbase.h @@ -0,0 +1,233 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef NSSBASE_H +#define NSSBASE_H + +/* + * nssbase.h + * + * This header file contains the prototypes of the basic public + * NSS routines. + */ + +#ifndef NSSBASET_H +#include "nssbaset.h" +#endif /* NSSBASET_H */ + +PR_BEGIN_EXTERN_C + +/* + * NSSArena + * + * The public methods relating to this type are: + * + * NSSArena_Create -- constructor + * NSSArena_Destroy + * NSS_ZAlloc + * NSS_ZRealloc + * NSS_ZFreeIf + */ + +/* + * NSSArena_Create + * + * This routine creates a new memory arena. This routine may return + * NULL upon error, in which case it will have created an error stack. + * + * The top-level error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * + * Return value: + * NULL upon error + * A pointer to an NSSArena upon success + */ + +NSS_EXTERN NSSArena *NSSArena_Create(void); + +extern const NSSError NSS_ERROR_NO_MEMORY; + +/* + * NSSArena_Destroy + * + * This routine will destroy the specified arena, freeing all memory + * allocated from it. This routine returns a PRStatus value; if + * successful, it will return PR_SUCCESS. If unsuccessful, it will + * create an error stack and return PR_FAILURE. + * + * The top-level error may be one of the following values: + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_EXTERN PRStatus NSSArena_Destroy(NSSArena *arena); + +extern const NSSError NSS_ERROR_INVALID_ARENA; + +/* + * The error stack + * + * The public methods relating to the error stack are: + * + * NSS_GetError + * NSS_GetErrorStack + */ + +/* + * NSS_GetError + * + * This routine returns the highest-level (most general) error set + * by the most recent NSS library routine called by the same thread + * calling this routine. + * + * This routine cannot fail. It may return NSS_ERROR_NO_ERROR, which + * indicates that the previous NSS library call did not set an error. + * + * Return value: + * 0 if no error has been set + * A nonzero error number + */ + +NSS_EXTERN NSSError NSS_GetError(void); + +extern const NSSError NSS_ERROR_NO_ERROR; + +/* + * NSS_GetErrorStack + * + * This routine returns a pointer to an array of NSSError values, + * containingthe entire sequence or "stack" of errors set by the most + * recent NSS library routine called by the same thread calling this + * routine. NOTE: the caller DOES NOT OWN the memory pointed to by + * the return value. The pointer will remain valid until the calling + * thread calls another NSS routine. The lowest-level (most specific) + * error is first in the array, and the highest-level is last. The + * array is zero-terminated. This routine may return NULL upon error; + * this indicates a low-memory situation. + * + * Return value: + * NULL upon error, which is an implied NSS_ERROR_NO_MEMORY + * A NON-caller-owned pointer to an array of NSSError values + */ + +NSS_EXTERN NSSError *NSS_GetErrorStack(void); + +/* + * NSS_ZNEW + * + * This preprocessor macro will allocate memory for a new object + * of the specified type with nss_ZAlloc, and will cast the + * return value appropriately. If the optional arena argument is + * non-null, the memory will be obtained from that arena; otherwise, + * the memory will be obtained from the heap. This routine may + * return NULL upon error, in which case it will have set an error + * upon the error stack. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * NULL upon error + * A pointer to the new segment of zeroed memory + */ + +#define NSS_ZNEW(arenaOpt, type) ((type *)NSS_ZAlloc((arenaOpt), sizeof(type))) + +/* + * NSS_ZNEWARRAY + * + * This preprocessor macro will allocate memory for an array of + * new objects, and will cast the return value appropriately. + * If the optional arena argument is non-null, the memory will + * be obtained from that arena; otherwise, the memory will be + * obtained from the heap. This routine may return NULL upon + * error, in which case it will have set an error upon the error + * stack. The array size may be specified as zero. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * NULL upon error + * A pointer to the new segment of zeroed memory + */ + +#define NSS_ZNEWARRAY(arenaOpt, type, quantity) \ + ((type *)NSS_ZAlloc((arenaOpt), sizeof(type) * (quantity))) + +/* + * NSS_ZAlloc + * + * This routine allocates and zeroes a section of memory of the + * size, and returns to the caller a pointer to that memory. If + * the optional arena argument is non-null, the memory will be + * obtained from that arena; otherwise, the memory will be obtained + * from the heap. This routine may return NULL upon error, in + * which case it will have set an error upon the error stack. The + * value specified for size may be zero; in which case a valid + * zero-length block of memory will be allocated. This block may + * be expanded by calling NSS_ZRealloc. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD + * + * Return value: + * NULL upon error + * A pointer to the new segment of zeroed memory + */ + +NSS_EXTERN void *NSS_ZAlloc(NSSArena *arenaOpt, PRUint32 size); + +/* + * NSS_ZRealloc + * + * This routine reallocates a block of memory obtained by calling + * nss_ZAlloc or nss_ZRealloc. The portion of memory + * between the new and old sizes -- which is either being newly + * obtained or released -- is in either case zeroed. This routine + * may return NULL upon failure, in which case it will have placed + * an error on the error stack. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_POINTER + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD + * + * Return value: + * NULL upon error + * A pointer to the replacement segment of memory + */ + +NSS_EXTERN void *NSS_ZRealloc(void *pointer, PRUint32 newSize); + +/* + * NSS_ZFreeIf + * + * If the specified pointer is non-null, then the region of memory + * to which it points -- which must have been allocated with + * nss_ZAlloc -- will be zeroed and released. This routine + * returns a PRStatus value; if successful, it will return PR_SUCCESS. + * If unsuccessful, it will set an error on the error stack and return + * PR_FAILURE. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_POINTER + * + * Return value: + * PR_SUCCESS + * PR_FAILURE + */ + +NSS_EXTERN PRStatus NSS_ZFreeIf(void *pointer); + +PR_END_EXTERN_C + +#endif /* NSSBASE_H */ diff --git a/illumos-x86_64/usr/include/mps/nssbaset.h b/illumos-x86_64/usr/include/mps/nssbaset.h new file mode 100644 index 00000000..8bc556e6 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssbaset.h @@ -0,0 +1,118 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef NSSBASET_H +#define NSSBASET_H + +/* + * nssbaset.h + * + * This file contains the most low-level, fundamental public types. + */ + +#include "nspr.h" +#include "nssilock.h" + +/* + * NSS_EXTERN, NSS_IMPLEMENT, NSS_EXTERN_DATA, NSS_IMPLEMENT_DATA + * + * NSS has its own versions of these NSPR macros, in a form which + * does not confuse ctags and other related utilities. NSPR + * defines these macros to take the type as an argument, because + * of certain OS requirements on platforms not supported by NSS. + */ + +#define DUMMY /* dummy */ +#define NSS_EXTERN extern +#define NSS_EXTERN_DATA extern +#define NSS_IMPLEMENT +#define NSS_IMPLEMENT_DATA + +PR_BEGIN_EXTERN_C + +/* + * NSSError + * + * Calls to NSS routines may result in one or more errors being placed + * on the calling thread's "error stack." Every possible error that + * may be returned from a function is declared where the function is + * prototyped. All errors are of the following type. + */ + +typedef PRInt32 NSSError; + +/* + * NSSArena + * + * Arenas are logical sets of heap memory, from which memory may be + * allocated. When an arena is destroyed, all memory allocated within + * that arena is implicitly freed. These arenas are thread-safe: + * an arena pointer may be used by multiple threads simultaneously. + * However, as they are not backed by shared memory, they may only be + * used within one process. + */ + +struct NSSArenaStr; +typedef struct NSSArenaStr NSSArena; + +/* + * NSSItem + * + * This is the basic type used to refer to an unconstrained datum of + * arbitrary size. + */ + +struct NSSItemStr { + void *data; + PRUint32 size; +}; +typedef struct NSSItemStr NSSItem; + +/* + * NSSBER + * + * Data packed according to the Basic Encoding Rules of ASN.1. + */ + +typedef NSSItem NSSBER; + +/* + * NSSDER + * + * Data packed according to the Distinguished Encoding Rules of ASN.1; + * this form is also known as the Canonical Encoding Rules form (CER). + */ + +typedef NSSBER NSSDER; + +/* + * NSSBitString + * + * Some ASN.1 types use "bit strings," which are passed around as + * octet strings but whose length is counted in bits. We use this + * typedef of NSSItem to point out the occasions when the length + * is counted in bits, not octets. + */ + +typedef NSSItem NSSBitString; + +/* + * NSSUTF8 + * + * Character strings encoded in UTF-8, as defined by RFC 2279. + */ + +typedef char NSSUTF8; + +/* + * NSSASCII7 + * + * Character strings guaranteed to be 7-bit ASCII. + */ + +typedef char NSSASCII7; + +PR_END_EXTERN_C + +#endif /* NSSBASET_H */ diff --git a/illumos-x86_64/usr/include/mps/nssck.api b/illumos-x86_64/usr/include/mps/nssck.api new file mode 100644 index 00000000..55b43512 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssck.api @@ -0,0 +1,1854 @@ +/* THIS IS A GENERATED FILE */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * nssck.api + * + * This automatically-generated file is used to generate a set of + * Cryptoki entry points within the object space of a Module using + * the NSS Cryptoki Framework. + * + * The Module should have a .c file with the following: + * + * #define MODULE_NAME name + * #define INSTANCE_NAME instance + * #include "nssck.api" + * + * where "name" is some module-specific name that can be used to + * disambiguate various modules. This included file will then + * define the actual Cryptoki routines which pass through to the + * Framework calls. All routines, except C_GetFunctionList, will + * be prefixed with the name; C_GetFunctionList will be generated + * to return an entry-point vector with these routines. The + * instance specified should be the basic instance of NSSCKMDInstance. + * + * If, prior to including nssck.api, the .c file also specifies + * + * #define DECLARE_STRICT_CRYTPOKI_NAMES + * + * Then a set of "stub" routines not prefixed with the name will + * be included. This would allow the combined module and framework + * to be used in applications which are hard-coded to use the + * PKCS#11 names (instead of going through the EPV). Please note + * that such applications should be careful resolving symbols when + * more than one PKCS#11 module is loaded. + */ + +#ifndef MODULE_NAME +#error "Error: MODULE_NAME must be defined." +#endif /* MODULE_NAME */ + +#ifndef INSTANCE_NAME +#error "Error: INSTANCE_NAME must be defined." +#endif /* INSTANCE_NAME */ + +#ifndef NSSCKT_H +#include "nssckt.h" +#endif /* NSSCKT_H */ + +#ifndef NSSCKFWT_H +#include "nssckfwt.h" +#endif /* NSSCKFWT_H */ + +#ifndef NSSCKFWC_H +#include "nssckfwc.h" +#endif /* NSSCKFWC_H */ + +#ifndef NSSCKEPV_H +#include "nssckepv.h" +#endif /* NSSCKEPV_H */ + +#define ADJOIN(x,y) x##y + +#define __ADJOIN(x,y) ADJOIN(x,y) + +/* + * The anchor. This object is used to store an "anchor" pointer in + * the Module's object space, so the wrapper functions can relate + * back to this instance. + */ + +static NSSCKFWInstance *fwInstance = (NSSCKFWInstance *)0; + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Initialize) +( + CK_VOID_PTR pInitArgs +) +{ + return NSSCKFWC_Initialize(&fwInstance, INSTANCE_NAME, pInitArgs); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Initialize +( + CK_VOID_PTR pInitArgs +) +{ + return __ADJOIN(MODULE_NAME,C_Initialize)(pInitArgs); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Finalize) +( + CK_VOID_PTR pReserved +) +{ + return NSSCKFWC_Finalize(&fwInstance); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Finalize +( + CK_VOID_PTR pReserved +) +{ + return __ADJOIN(MODULE_NAME,C_Finalize)(pReserved); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetInfo) +( + CK_INFO_PTR pInfo +) +{ + return NSSCKFWC_GetInfo(fwInstance, pInfo); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetInfo +( + CK_INFO_PTR pInfo +) +{ + return __ADJOIN(MODULE_NAME,C_GetInfo)(pInfo); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +/* + * C_GetFunctionList is defined at the end. + */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetSlotList) +( + CK_BBOOL tokenPresent, + CK_SLOT_ID_PTR pSlotList, + CK_ULONG_PTR pulCount +) +{ + return NSSCKFWC_GetSlotList(fwInstance, tokenPresent, pSlotList, pulCount); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetSlotList +( + CK_BBOOL tokenPresent, + CK_SLOT_ID_PTR pSlotList, + CK_ULONG_PTR pulCount +) +{ + return __ADJOIN(MODULE_NAME,C_GetSlotList)(tokenPresent, pSlotList, pulCount); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetSlotInfo) +( + CK_SLOT_ID slotID, + CK_SLOT_INFO_PTR pInfo +) +{ + return NSSCKFWC_GetSlotInfo(fwInstance, slotID, pInfo); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetSlotInfo +( + CK_SLOT_ID slotID, + CK_SLOT_INFO_PTR pInfo +) +{ + return __ADJOIN(MODULE_NAME,C_GetSlotInfo)(slotID, pInfo); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetTokenInfo) +( + CK_SLOT_ID slotID, + CK_TOKEN_INFO_PTR pInfo +) +{ + return NSSCKFWC_GetTokenInfo(fwInstance, slotID, pInfo); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetTokenInfo +( + CK_SLOT_ID slotID, + CK_TOKEN_INFO_PTR pInfo +) +{ + return __ADJOIN(MODULE_NAME,C_GetTokenInfo)(slotID, pInfo); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetMechanismList) +( + CK_SLOT_ID slotID, + CK_MECHANISM_TYPE_PTR pMechanismList, + CK_ULONG_PTR pulCount +) +{ + return NSSCKFWC_GetMechanismList(fwInstance, slotID, pMechanismList, pulCount); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetMechanismList +( + CK_SLOT_ID slotID, + CK_MECHANISM_TYPE_PTR pMechanismList, + CK_ULONG_PTR pulCount +) +{ + return __ADJOIN(MODULE_NAME,C_GetMechanismList)(slotID, pMechanismList, pulCount); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetMechanismInfo) +( + CK_SLOT_ID slotID, + CK_MECHANISM_TYPE type, + CK_MECHANISM_INFO_PTR pInfo +) +{ + return NSSCKFWC_GetMechanismInfo(fwInstance, slotID, type, pInfo); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetMechanismInfo +( + CK_SLOT_ID slotID, + CK_MECHANISM_TYPE type, + CK_MECHANISM_INFO_PTR pInfo +) +{ + return __ADJOIN(MODULE_NAME,C_GetMechanismInfo)(slotID, type, pInfo); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_InitToken) +( + CK_SLOT_ID slotID, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen, + CK_CHAR_PTR pLabel +) +{ + return NSSCKFWC_InitToken(fwInstance, slotID, pPin, ulPinLen, pLabel); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_InitToken +( + CK_SLOT_ID slotID, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen, + CK_CHAR_PTR pLabel +) +{ + return __ADJOIN(MODULE_NAME,C_InitToken)(slotID, pPin, ulPinLen, pLabel); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_InitPIN) +( + CK_SESSION_HANDLE hSession, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen +) +{ + return NSSCKFWC_InitPIN(fwInstance, hSession, pPin, ulPinLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_InitPIN +( + CK_SESSION_HANDLE hSession, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen +) +{ + return __ADJOIN(MODULE_NAME,C_InitPIN)(hSession, pPin, ulPinLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SetPIN) +( + CK_SESSION_HANDLE hSession, + CK_CHAR_PTR pOldPin, + CK_ULONG ulOldLen, + CK_CHAR_PTR pNewPin, + CK_ULONG ulNewLen +) +{ + return NSSCKFWC_SetPIN(fwInstance, hSession, pOldPin, ulOldLen, pNewPin, ulNewLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SetPIN +( + CK_SESSION_HANDLE hSession, + CK_CHAR_PTR pOldPin, + CK_ULONG ulOldLen, + CK_CHAR_PTR pNewPin, + CK_ULONG ulNewLen +) +{ + return __ADJOIN(MODULE_NAME,C_SetPIN)(hSession, pOldPin, ulOldLen, pNewPin, ulNewLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_OpenSession) +( + CK_SLOT_ID slotID, + CK_FLAGS flags, + CK_VOID_PTR pApplication, + CK_NOTIFY Notify, + CK_SESSION_HANDLE_PTR phSession +) +{ + return NSSCKFWC_OpenSession(fwInstance, slotID, flags, pApplication, Notify, phSession); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_OpenSession +( + CK_SLOT_ID slotID, + CK_FLAGS flags, + CK_VOID_PTR pApplication, + CK_NOTIFY Notify, + CK_SESSION_HANDLE_PTR phSession +) +{ + return __ADJOIN(MODULE_NAME,C_OpenSession)(slotID, flags, pApplication, Notify, phSession); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_CloseSession) +( + CK_SESSION_HANDLE hSession +) +{ + return NSSCKFWC_CloseSession(fwInstance, hSession); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_CloseSession +( + CK_SESSION_HANDLE hSession +) +{ + return __ADJOIN(MODULE_NAME,C_CloseSession)(hSession); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_CloseAllSessions) +( + CK_SLOT_ID slotID +) +{ + return NSSCKFWC_CloseAllSessions(fwInstance, slotID); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_CloseAllSessions +( + CK_SLOT_ID slotID +) +{ + return __ADJOIN(MODULE_NAME,C_CloseAllSessions)(slotID); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetSessionInfo) +( + CK_SESSION_HANDLE hSession, + CK_SESSION_INFO_PTR pInfo +) +{ + return NSSCKFWC_GetSessionInfo(fwInstance, hSession, pInfo); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetSessionInfo +( + CK_SESSION_HANDLE hSession, + CK_SESSION_INFO_PTR pInfo +) +{ + return __ADJOIN(MODULE_NAME,C_GetSessionInfo)(hSession, pInfo); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetOperationState) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pOperationState, + CK_ULONG_PTR pulOperationStateLen +) +{ + return NSSCKFWC_GetOperationState(fwInstance, hSession, pOperationState, pulOperationStateLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetOperationState +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pOperationState, + CK_ULONG_PTR pulOperationStateLen +) +{ + return __ADJOIN(MODULE_NAME,C_GetOperationState)(hSession, pOperationState, pulOperationStateLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SetOperationState) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pOperationState, + CK_ULONG ulOperationStateLen, + CK_OBJECT_HANDLE hEncryptionKey, + CK_OBJECT_HANDLE hAuthenticationKey +) +{ + return NSSCKFWC_SetOperationState(fwInstance, hSession, pOperationState, ulOperationStateLen, hEncryptionKey, hAuthenticationKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SetOperationState +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pOperationState, + CK_ULONG ulOperationStateLen, + CK_OBJECT_HANDLE hEncryptionKey, + CK_OBJECT_HANDLE hAuthenticationKey +) +{ + return __ADJOIN(MODULE_NAME,C_SetOperationState)(hSession, pOperationState, ulOperationStateLen, hEncryptionKey, hAuthenticationKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Login) +( + CK_SESSION_HANDLE hSession, + CK_USER_TYPE userType, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen +) +{ + return NSSCKFWC_Login(fwInstance, hSession, userType, pPin, ulPinLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Login +( + CK_SESSION_HANDLE hSession, + CK_USER_TYPE userType, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen +) +{ + return __ADJOIN(MODULE_NAME,C_Login)(hSession, userType, pPin, ulPinLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Logout) +( + CK_SESSION_HANDLE hSession +) +{ + return NSSCKFWC_Logout(fwInstance, hSession); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Logout +( + CK_SESSION_HANDLE hSession +) +{ + return __ADJOIN(MODULE_NAME,C_Logout)(hSession); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_CreateObject) +( + CK_SESSION_HANDLE hSession, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phObject +) +{ + return NSSCKFWC_CreateObject(fwInstance, hSession, pTemplate, ulCount, phObject); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_CreateObject +( + CK_SESSION_HANDLE hSession, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phObject +) +{ + return __ADJOIN(MODULE_NAME,C_CreateObject)(hSession, pTemplate, ulCount, phObject); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_CopyObject) +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phNewObject +) +{ + return NSSCKFWC_CopyObject(fwInstance, hSession, hObject, pTemplate, ulCount, phNewObject); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_CopyObject +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phNewObject +) +{ + return __ADJOIN(MODULE_NAME,C_CopyObject)(hSession, hObject, pTemplate, ulCount, phNewObject); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DestroyObject) +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject +) +{ + return NSSCKFWC_DestroyObject(fwInstance, hSession, hObject); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DestroyObject +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject +) +{ + return __ADJOIN(MODULE_NAME,C_DestroyObject)(hSession, hObject); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetObjectSize) +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ULONG_PTR pulSize +) +{ + return NSSCKFWC_GetObjectSize(fwInstance, hSession, hObject, pulSize); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetObjectSize +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ULONG_PTR pulSize +) +{ + return __ADJOIN(MODULE_NAME,C_GetObjectSize)(hSession, hObject, pulSize); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetAttributeValue) +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount +) +{ + return NSSCKFWC_GetAttributeValue(fwInstance, hSession, hObject, pTemplate, ulCount); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetAttributeValue +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount +) +{ + return __ADJOIN(MODULE_NAME,C_GetAttributeValue)(hSession, hObject, pTemplate, ulCount); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SetAttributeValue) +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount +) +{ + return NSSCKFWC_SetAttributeValue(fwInstance, hSession, hObject, pTemplate, ulCount); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SetAttributeValue +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount +) +{ + return __ADJOIN(MODULE_NAME,C_SetAttributeValue)(hSession, hObject, pTemplate, ulCount); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_FindObjectsInit) +( + CK_SESSION_HANDLE hSession, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount +) +{ + return NSSCKFWC_FindObjectsInit(fwInstance, hSession, pTemplate, ulCount); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_FindObjectsInit +( + CK_SESSION_HANDLE hSession, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount +) +{ + return __ADJOIN(MODULE_NAME,C_FindObjectsInit)(hSession, pTemplate, ulCount); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_FindObjects) +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE_PTR phObject, + CK_ULONG ulMaxObjectCount, + CK_ULONG_PTR pulObjectCount +) +{ + return NSSCKFWC_FindObjects(fwInstance, hSession, phObject, ulMaxObjectCount, pulObjectCount); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_FindObjects +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE_PTR phObject, + CK_ULONG ulMaxObjectCount, + CK_ULONG_PTR pulObjectCount +) +{ + return __ADJOIN(MODULE_NAME,C_FindObjects)(hSession, phObject, ulMaxObjectCount, pulObjectCount); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_FindObjectsFinal) +( + CK_SESSION_HANDLE hSession +) +{ + return NSSCKFWC_FindObjectsFinal(fwInstance, hSession); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_FindObjectsFinal +( + CK_SESSION_HANDLE hSession +) +{ + return __ADJOIN(MODULE_NAME,C_FindObjectsFinal)(hSession); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_EncryptInit) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return NSSCKFWC_EncryptInit(fwInstance, hSession, pMechanism, hKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_EncryptInit +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return __ADJOIN(MODULE_NAME,C_EncryptInit)(hSession, pMechanism, hKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Encrypt) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pEncryptedData, + CK_ULONG_PTR pulEncryptedDataLen +) +{ + return NSSCKFWC_Encrypt(fwInstance, hSession, pData, ulDataLen, pEncryptedData, pulEncryptedDataLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Encrypt +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pEncryptedData, + CK_ULONG_PTR pulEncryptedDataLen +) +{ + return __ADJOIN(MODULE_NAME,C_Encrypt)(hSession, pData, ulDataLen, pEncryptedData, pulEncryptedDataLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_EncryptUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen +) +{ + return NSSCKFWC_EncryptUpdate(fwInstance, hSession, pPart, ulPartLen, pEncryptedPart, pulEncryptedPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_EncryptUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_EncryptUpdate)(hSession, pPart, ulPartLen, pEncryptedPart, pulEncryptedPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_EncryptFinal) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pLastEncryptedPart, + CK_ULONG_PTR pulLastEncryptedPartLen +) +{ + return NSSCKFWC_EncryptFinal(fwInstance, hSession, pLastEncryptedPart, pulLastEncryptedPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_EncryptFinal +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pLastEncryptedPart, + CK_ULONG_PTR pulLastEncryptedPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_EncryptFinal)(hSession, pLastEncryptedPart, pulLastEncryptedPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DecryptInit) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return NSSCKFWC_DecryptInit(fwInstance, hSession, pMechanism, hKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DecryptInit +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return __ADJOIN(MODULE_NAME,C_DecryptInit)(hSession, pMechanism, hKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Decrypt) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedData, + CK_ULONG ulEncryptedDataLen, + CK_BYTE_PTR pData, + CK_ULONG_PTR pulDataLen +) +{ + return NSSCKFWC_Decrypt(fwInstance, hSession, pEncryptedData, ulEncryptedDataLen, pData, pulDataLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Decrypt +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedData, + CK_ULONG ulEncryptedDataLen, + CK_BYTE_PTR pData, + CK_ULONG_PTR pulDataLen +) +{ + return __ADJOIN(MODULE_NAME,C_Decrypt)(hSession, pEncryptedData, ulEncryptedDataLen, pData, pulDataLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DecryptUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen +) +{ + return NSSCKFWC_DecryptUpdate(fwInstance, hSession, pEncryptedPart, ulEncryptedPartLen, pPart, pulPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DecryptUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_DecryptUpdate)(hSession, pEncryptedPart, ulEncryptedPartLen, pPart, pulPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DecryptFinal) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pLastPart, + CK_ULONG_PTR pulLastPartLen +) +{ + return NSSCKFWC_DecryptFinal(fwInstance, hSession, pLastPart, pulLastPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DecryptFinal +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pLastPart, + CK_ULONG_PTR pulLastPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_DecryptFinal)(hSession, pLastPart, pulLastPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DigestInit) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism +) +{ + return NSSCKFWC_DigestInit(fwInstance, hSession, pMechanism); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DigestInit +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism +) +{ + return __ADJOIN(MODULE_NAME,C_DigestInit)(hSession, pMechanism); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Digest) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pDigest, + CK_ULONG_PTR pulDigestLen +) +{ + return NSSCKFWC_Digest(fwInstance, hSession, pData, ulDataLen, pDigest, pulDigestLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Digest +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pDigest, + CK_ULONG_PTR pulDigestLen +) +{ + return __ADJOIN(MODULE_NAME,C_Digest)(hSession, pData, ulDataLen, pDigest, pulDigestLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DigestUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen +) +{ + return NSSCKFWC_DigestUpdate(fwInstance, hSession, pPart, ulPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DigestUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_DigestUpdate)(hSession, pPart, ulPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DigestKey) +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hKey +) +{ + return NSSCKFWC_DigestKey(fwInstance, hSession, hKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DigestKey +( + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hKey +) +{ + return __ADJOIN(MODULE_NAME,C_DigestKey)(hSession, hKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DigestFinal) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pDigest, + CK_ULONG_PTR pulDigestLen +) +{ + return NSSCKFWC_DigestFinal(fwInstance, hSession, pDigest, pulDigestLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DigestFinal +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pDigest, + CK_ULONG_PTR pulDigestLen +) +{ + return __ADJOIN(MODULE_NAME,C_DigestFinal)(hSession, pDigest, pulDigestLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SignInit) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return NSSCKFWC_SignInit(fwInstance, hSession, pMechanism, hKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SignInit +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return __ADJOIN(MODULE_NAME,C_SignInit)(hSession, pMechanism, hKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Sign) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen +) +{ + return NSSCKFWC_Sign(fwInstance, hSession, pData, ulDataLen, pSignature, pulSignatureLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Sign +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen +) +{ + return __ADJOIN(MODULE_NAME,C_Sign)(hSession, pData, ulDataLen, pSignature, pulSignatureLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SignUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen +) +{ + return NSSCKFWC_SignUpdate(fwInstance, hSession, pPart, ulPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SignUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_SignUpdate)(hSession, pPart, ulPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SignFinal) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen +) +{ + return NSSCKFWC_SignFinal(fwInstance, hSession, pSignature, pulSignatureLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SignFinal +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen +) +{ + return __ADJOIN(MODULE_NAME,C_SignFinal)(hSession, pSignature, pulSignatureLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SignRecoverInit) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return NSSCKFWC_SignRecoverInit(fwInstance, hSession, pMechanism, hKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SignRecoverInit +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return __ADJOIN(MODULE_NAME,C_SignRecoverInit)(hSession, pMechanism, hKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SignRecover) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen +) +{ + return NSSCKFWC_SignRecover(fwInstance, hSession, pData, ulDataLen, pSignature, pulSignatureLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SignRecover +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen +) +{ + return __ADJOIN(MODULE_NAME,C_SignRecover)(hSession, pData, ulDataLen, pSignature, pulSignatureLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_VerifyInit) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return NSSCKFWC_VerifyInit(fwInstance, hSession, pMechanism, hKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_VerifyInit +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return __ADJOIN(MODULE_NAME,C_VerifyInit)(hSession, pMechanism, hKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_Verify) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen +) +{ + return NSSCKFWC_Verify(fwInstance, hSession, pData, ulDataLen, pSignature, ulSignatureLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_Verify +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen +) +{ + return __ADJOIN(MODULE_NAME,C_Verify)(hSession, pData, ulDataLen, pSignature, ulSignatureLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_VerifyUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen +) +{ + return NSSCKFWC_VerifyUpdate(fwInstance, hSession, pPart, ulPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_VerifyUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_VerifyUpdate)(hSession, pPart, ulPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_VerifyFinal) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen +) +{ + return NSSCKFWC_VerifyFinal(fwInstance, hSession, pSignature, ulSignatureLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_VerifyFinal +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen +) +{ + return __ADJOIN(MODULE_NAME,C_VerifyFinal)(hSession, pSignature, ulSignatureLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_VerifyRecoverInit) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return NSSCKFWC_VerifyRecoverInit(fwInstance, hSession, pMechanism, hKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_VerifyRecoverInit +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey +) +{ + return __ADJOIN(MODULE_NAME,C_VerifyRecoverInit)(hSession, pMechanism, hKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_VerifyRecover) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen, + CK_BYTE_PTR pData, + CK_ULONG_PTR pulDataLen +) +{ + return NSSCKFWC_VerifyRecover(fwInstance, hSession, pSignature, ulSignatureLen, pData, pulDataLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_VerifyRecover +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen, + CK_BYTE_PTR pData, + CK_ULONG_PTR pulDataLen +) +{ + return __ADJOIN(MODULE_NAME,C_VerifyRecover)(hSession, pSignature, ulSignatureLen, pData, pulDataLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DigestEncryptUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen +) +{ + return NSSCKFWC_DigestEncryptUpdate(fwInstance, hSession, pPart, ulPartLen, pEncryptedPart, pulEncryptedPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DigestEncryptUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_DigestEncryptUpdate)(hSession, pPart, ulPartLen, pEncryptedPart, pulEncryptedPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DecryptDigestUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen +) +{ + return NSSCKFWC_DecryptDigestUpdate(fwInstance, hSession, pEncryptedPart, ulEncryptedPartLen, pPart, pulPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DecryptDigestUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_DecryptDigestUpdate)(hSession, pEncryptedPart, ulEncryptedPartLen, pPart, pulPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SignEncryptUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen +) +{ + return NSSCKFWC_SignEncryptUpdate(fwInstance, hSession, pPart, ulPartLen, pEncryptedPart, pulEncryptedPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SignEncryptUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_SignEncryptUpdate)(hSession, pPart, ulPartLen, pEncryptedPart, pulEncryptedPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DecryptVerifyUpdate) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen +) +{ + return NSSCKFWC_DecryptVerifyUpdate(fwInstance, hSession, pEncryptedPart, ulEncryptedPartLen, pPart, pulPartLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DecryptVerifyUpdate +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen +) +{ + return __ADJOIN(MODULE_NAME,C_DecryptVerifyUpdate)(hSession, pEncryptedPart, ulEncryptedPartLen, pPart, pulPartLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GenerateKey) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phKey +) +{ + return NSSCKFWC_GenerateKey(fwInstance, hSession, pMechanism, pTemplate, ulCount, phKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GenerateKey +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phKey +) +{ + return __ADJOIN(MODULE_NAME,C_GenerateKey)(hSession, pMechanism, pTemplate, ulCount, phKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GenerateKeyPair) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_ATTRIBUTE_PTR pPublicKeyTemplate, + CK_ULONG ulPublicKeyAttributeCount, + CK_ATTRIBUTE_PTR pPrivateKeyTemplate, + CK_ULONG ulPrivateKeyAttributeCount, + CK_OBJECT_HANDLE_PTR phPublicKey, + CK_OBJECT_HANDLE_PTR phPrivateKey +) +{ + return NSSCKFWC_GenerateKeyPair(fwInstance, hSession, pMechanism, pPublicKeyTemplate, ulPublicKeyAttributeCount, pPrivateKeyTemplate, ulPrivateKeyAttributeCount, phPublicKey, phPrivateKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GenerateKeyPair +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_ATTRIBUTE_PTR pPublicKeyTemplate, + CK_ULONG ulPublicKeyAttributeCount, + CK_ATTRIBUTE_PTR pPrivateKeyTemplate, + CK_ULONG ulPrivateKeyAttributeCount, + CK_OBJECT_HANDLE_PTR phPublicKey, + CK_OBJECT_HANDLE_PTR phPrivateKey +) +{ + return __ADJOIN(MODULE_NAME,C_GenerateKeyPair)(hSession, pMechanism, pPublicKeyTemplate, ulPublicKeyAttributeCount, pPrivateKeyTemplate, ulPrivateKeyAttributeCount, phPublicKey, phPrivateKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_WrapKey) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hWrappingKey, + CK_OBJECT_HANDLE hKey, + CK_BYTE_PTR pWrappedKey, + CK_ULONG_PTR pulWrappedKeyLen +) +{ + return NSSCKFWC_WrapKey(fwInstance, hSession, pMechanism, hWrappingKey, hKey, pWrappedKey, pulWrappedKeyLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_WrapKey +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hWrappingKey, + CK_OBJECT_HANDLE hKey, + CK_BYTE_PTR pWrappedKey, + CK_ULONG_PTR pulWrappedKeyLen +) +{ + return __ADJOIN(MODULE_NAME,C_WrapKey)(hSession, pMechanism, hWrappingKey, hKey, pWrappedKey, pulWrappedKeyLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_UnwrapKey) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hUnwrappingKey, + CK_BYTE_PTR pWrappedKey, + CK_ULONG ulWrappedKeyLen, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_OBJECT_HANDLE_PTR phKey +) +{ + return NSSCKFWC_UnwrapKey(fwInstance, hSession, pMechanism, hUnwrappingKey, pWrappedKey, ulWrappedKeyLen, pTemplate, ulAttributeCount, phKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_UnwrapKey +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hUnwrappingKey, + CK_BYTE_PTR pWrappedKey, + CK_ULONG ulWrappedKeyLen, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_OBJECT_HANDLE_PTR phKey +) +{ + return __ADJOIN(MODULE_NAME,C_UnwrapKey)(hSession, pMechanism, hUnwrappingKey, pWrappedKey, ulWrappedKeyLen, pTemplate, ulAttributeCount, phKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_DeriveKey) +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hBaseKey, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_OBJECT_HANDLE_PTR phKey +) +{ + return NSSCKFWC_DeriveKey(fwInstance, hSession, pMechanism, hBaseKey, pTemplate, ulAttributeCount, phKey); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_DeriveKey +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hBaseKey, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_OBJECT_HANDLE_PTR phKey +) +{ + return __ADJOIN(MODULE_NAME,C_DeriveKey)(hSession, pMechanism, hBaseKey, pTemplate, ulAttributeCount, phKey); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_SeedRandom) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSeed, + CK_ULONG ulSeedLen +) +{ + return NSSCKFWC_SeedRandom(fwInstance, hSession, pSeed, ulSeedLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_SeedRandom +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSeed, + CK_ULONG ulSeedLen +) +{ + return __ADJOIN(MODULE_NAME,C_SeedRandom)(hSession, pSeed, ulSeedLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GenerateRandom) +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR RandomData, + CK_ULONG ulRandomLen +) +{ + return NSSCKFWC_GenerateRandom(fwInstance, hSession, RandomData, ulRandomLen); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GenerateRandom +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR RandomData, + CK_ULONG ulRandomLen +) +{ + return __ADJOIN(MODULE_NAME,C_GenerateRandom)(hSession, RandomData, ulRandomLen); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetFunctionStatus) +( + CK_SESSION_HANDLE hSession +) +{ + return NSSCKFWC_GetFunctionStatus(fwInstance, hSession); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_GetFunctionStatus +( + CK_SESSION_HANDLE hSession +) +{ + return __ADJOIN(MODULE_NAME,C_GetFunctionStatus)(hSession); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_CancelFunction) +( + CK_SESSION_HANDLE hSession +) +{ + return NSSCKFWC_CancelFunction(fwInstance, hSession); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_CancelFunction +( + CK_SESSION_HANDLE hSession +) +{ + return __ADJOIN(MODULE_NAME,C_CancelFunction)(hSession); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_WaitForSlotEvent) +( + CK_FLAGS flags, + CK_SLOT_ID_PTR pSlot, + CK_VOID_PTR pRserved +) +{ + return NSSCKFWC_WaitForSlotEvent(fwInstance, flags, pSlot, pRserved); +} + +#ifdef DECLARE_STRICT_CRYPTOKI_NAMES +CK_RV CK_ENTRY +C_WaitForSlotEvent +( + CK_FLAGS flags, + CK_SLOT_ID_PTR pSlot, + CK_VOID_PTR pRserved +) +{ + return __ADJOIN(MODULE_NAME,C_WaitForSlotEvent)(flags, pSlot, pRserved); +} +#endif /* DECLARE_STRICT_CRYPTOKI_NAMES */ + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetFunctionList) +( + CK_FUNCTION_LIST_PTR_PTR ppFunctionList +); + +static CK_FUNCTION_LIST FunctionList = { + { 2, 1 }, +__ADJOIN(MODULE_NAME,C_Initialize), +__ADJOIN(MODULE_NAME,C_Finalize), +__ADJOIN(MODULE_NAME,C_GetInfo), +__ADJOIN(MODULE_NAME,C_GetFunctionList), +__ADJOIN(MODULE_NAME,C_GetSlotList), +__ADJOIN(MODULE_NAME,C_GetSlotInfo), +__ADJOIN(MODULE_NAME,C_GetTokenInfo), +__ADJOIN(MODULE_NAME,C_GetMechanismList), +__ADJOIN(MODULE_NAME,C_GetMechanismInfo), +__ADJOIN(MODULE_NAME,C_InitToken), +__ADJOIN(MODULE_NAME,C_InitPIN), +__ADJOIN(MODULE_NAME,C_SetPIN), +__ADJOIN(MODULE_NAME,C_OpenSession), +__ADJOIN(MODULE_NAME,C_CloseSession), +__ADJOIN(MODULE_NAME,C_CloseAllSessions), +__ADJOIN(MODULE_NAME,C_GetSessionInfo), +__ADJOIN(MODULE_NAME,C_GetOperationState), +__ADJOIN(MODULE_NAME,C_SetOperationState), +__ADJOIN(MODULE_NAME,C_Login), +__ADJOIN(MODULE_NAME,C_Logout), +__ADJOIN(MODULE_NAME,C_CreateObject), +__ADJOIN(MODULE_NAME,C_CopyObject), +__ADJOIN(MODULE_NAME,C_DestroyObject), +__ADJOIN(MODULE_NAME,C_GetObjectSize), +__ADJOIN(MODULE_NAME,C_GetAttributeValue), +__ADJOIN(MODULE_NAME,C_SetAttributeValue), +__ADJOIN(MODULE_NAME,C_FindObjectsInit), +__ADJOIN(MODULE_NAME,C_FindObjects), +__ADJOIN(MODULE_NAME,C_FindObjectsFinal), +__ADJOIN(MODULE_NAME,C_EncryptInit), +__ADJOIN(MODULE_NAME,C_Encrypt), +__ADJOIN(MODULE_NAME,C_EncryptUpdate), +__ADJOIN(MODULE_NAME,C_EncryptFinal), +__ADJOIN(MODULE_NAME,C_DecryptInit), +__ADJOIN(MODULE_NAME,C_Decrypt), +__ADJOIN(MODULE_NAME,C_DecryptUpdate), +__ADJOIN(MODULE_NAME,C_DecryptFinal), +__ADJOIN(MODULE_NAME,C_DigestInit), +__ADJOIN(MODULE_NAME,C_Digest), +__ADJOIN(MODULE_NAME,C_DigestUpdate), +__ADJOIN(MODULE_NAME,C_DigestKey), +__ADJOIN(MODULE_NAME,C_DigestFinal), +__ADJOIN(MODULE_NAME,C_SignInit), +__ADJOIN(MODULE_NAME,C_Sign), +__ADJOIN(MODULE_NAME,C_SignUpdate), +__ADJOIN(MODULE_NAME,C_SignFinal), +__ADJOIN(MODULE_NAME,C_SignRecoverInit), +__ADJOIN(MODULE_NAME,C_SignRecover), +__ADJOIN(MODULE_NAME,C_VerifyInit), +__ADJOIN(MODULE_NAME,C_Verify), +__ADJOIN(MODULE_NAME,C_VerifyUpdate), +__ADJOIN(MODULE_NAME,C_VerifyFinal), +__ADJOIN(MODULE_NAME,C_VerifyRecoverInit), +__ADJOIN(MODULE_NAME,C_VerifyRecover), +__ADJOIN(MODULE_NAME,C_DigestEncryptUpdate), +__ADJOIN(MODULE_NAME,C_DecryptDigestUpdate), +__ADJOIN(MODULE_NAME,C_SignEncryptUpdate), +__ADJOIN(MODULE_NAME,C_DecryptVerifyUpdate), +__ADJOIN(MODULE_NAME,C_GenerateKey), +__ADJOIN(MODULE_NAME,C_GenerateKeyPair), +__ADJOIN(MODULE_NAME,C_WrapKey), +__ADJOIN(MODULE_NAME,C_UnwrapKey), +__ADJOIN(MODULE_NAME,C_DeriveKey), +__ADJOIN(MODULE_NAME,C_SeedRandom), +__ADJOIN(MODULE_NAME,C_GenerateRandom), +__ADJOIN(MODULE_NAME,C_GetFunctionStatus), +__ADJOIN(MODULE_NAME,C_CancelFunction), +__ADJOIN(MODULE_NAME,C_WaitForSlotEvent) +}; + +static CK_RV CK_ENTRY +__ADJOIN(MODULE_NAME,C_GetFunctionList) +( + CK_FUNCTION_LIST_PTR_PTR ppFunctionList +) +{ + *ppFunctionList = &FunctionList; + return CKR_OK; +} + +/* This one is always present */ +CK_RV CK_ENTRY +C_GetFunctionList +( + CK_FUNCTION_LIST_PTR_PTR ppFunctionList +) +{ + return __ADJOIN(MODULE_NAME,C_GetFunctionList)(ppFunctionList); +} + +#undef __ADJOIN + diff --git a/illumos-x86_64/usr/include/mps/nssckbi.h b/illumos-x86_64/usr/include/mps/nssckbi.h new file mode 100644 index 00000000..2a137db8 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckbi.h @@ -0,0 +1,61 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef NSSCKBI_H +#define NSSCKBI_H + +/* + * NSS BUILTINS Version numbers. + * + * These are the version numbers for the builtins module packaged with + * this release on NSS. To determine the version numbers of the builtin + * module you are using, use the appropriate PKCS #11 calls. + * + * These version numbers detail changes to the PKCS #11 interface. They map + * to the PKCS #11 spec versions. + */ +#define NSS_BUILTINS_CRYPTOKI_VERSION_MAJOR 2 +#define NSS_BUILTINS_CRYPTOKI_VERSION_MINOR 20 + +/* These version numbers detail the changes + * to the list of trusted certificates. + * + * The NSS_BUILTINS_LIBRARY_VERSION_MINOR macro needs to be bumped + * whenever we change the list of trusted certificates. + * + * Please use the following rules when increasing the version number: + * + * - starting with version 2.14, NSS_BUILTINS_LIBRARY_VERSION_MINOR + * must always be an EVEN number (e.g. 16, 18, 20 etc.) + * + * - whenever possible, if older branches require a modification to the + * list, these changes should be made on the main line of development (trunk), + * and the older branches should update to the most recent list. + * + * - ODD minor version numbers are reserved to indicate a snapshot that has + * deviated from the main line of development, e.g. if it was necessary + * to modify the list on a stable branch. + * Once the version has been changed to an odd number (e.g. 2.13) on a branch, + * it should remain unchanged on that branch, even if further changes are + * made on that branch. + * + * NSS_BUILTINS_LIBRARY_VERSION_MINOR is a CK_BYTE. It's not clear + * whether we may use its full range (0-255) or only 0-99 because + * of the comment in the CK_VERSION type definition. + * It's recommend to switch back to 0 after having reached version 98/99. + */ +#define NSS_BUILTINS_LIBRARY_VERSION_MAJOR 2 +#define NSS_BUILTINS_LIBRARY_VERSION_MINOR 80 +#define NSS_BUILTINS_LIBRARY_VERSION "2.80" + +/* These version numbers detail the semantic changes to the ckfw engine. */ +#define NSS_BUILTINS_HARDWARE_VERSION_MAJOR 1 +#define NSS_BUILTINS_HARDWARE_VERSION_MINOR 0 + +/* These version numbers detail the semantic changes to ckbi itself + * (new PKCS #11 objects), etc. */ +#define NSS_BUILTINS_FIRMWARE_VERSION_MAJOR 1 +#define NSS_BUILTINS_FIRMWARE_VERSION_MINOR 0 + +#endif /* NSSCKBI_H */ diff --git a/illumos-x86_64/usr/include/mps/nssckepv.h b/illumos-x86_64/usr/include/mps/nssckepv.h new file mode 100644 index 00000000..042845d3 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckepv.h @@ -0,0 +1,10 @@ +/* THIS IS A GENERATED FILE */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef NSSCKEPV_H +#define NSSCKEPV_H + +#include "pkcs11.h" + +#endif /* NSSCKEPV_H */ diff --git a/illumos-x86_64/usr/include/mps/nssckft.h b/illumos-x86_64/usr/include/mps/nssckft.h new file mode 100644 index 00000000..80ee2924 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckft.h @@ -0,0 +1,11 @@ +/* THIS IS A GENERATED FILE */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _NSSCKFT_H_ +#define _NSSCKFT_H_ 1 + +#include "pkcs11t.h" + +#endif /* _NSSCKFT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/nssckfw.h b/illumos-x86_64/usr/include/mps/nssckfw.h new file mode 100644 index 00000000..0f93eaa0 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckfw.h @@ -0,0 +1,462 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef NSSCKFW_H +#define NSSCKFW_H + +/* + * nssckfw.h + * + * This file prototypes the publicly available calls of the + * NSS Cryptoki Framework. + */ + +#ifndef NSSBASET_H +#include "nssbaset.h" +#endif /* NSSBASET_H */ + +#ifndef NSSCKT_H +#include "nssckt.h" +#endif /* NSSCKT_H */ + +#ifndef NSSCKFWT_H +#include "nssckfwt.h" +#endif /* NSSCKFWT_H */ + +/* + * NSSCKFWInstance + * + * NSSCKFWInstance_GetMDInstance + * NSSCKFWInstance_GetArena + * NSSCKFWInstance_MayCreatePthreads + * NSSCKFWInstance_CreateMutex + * NSSCKFWInstance_GetConfigurationData + * NSSCKFWInstance_GetInitArgs + * NSSCKFWInstance_DestroySessionHandle + * NSSCKFWInstance_FindSessionHandle + */ + +/* + * NSSCKFWInstance_GetMDInstance + * + */ + +NSS_EXTERN NSSCKMDInstance * +NSSCKFWInstance_GetMDInstance( + NSSCKFWInstance *fwInstance); + +/* + * NSSCKFWInstance_GetArena + * + */ + +NSS_EXTERN NSSArena * +NSSCKFWInstance_GetArena( + NSSCKFWInstance *fwInstance, + CK_RV *pError); + +/* + * NSSCKFWInstance_MayCreatePthreads + * + */ + +NSS_EXTERN CK_BBOOL +NSSCKFWInstance_MayCreatePthreads( + NSSCKFWInstance *fwInstance); + +/* + * NSSCKFWInstance_CreateMutex + * + */ + +NSS_EXTERN NSSCKFWMutex * +NSSCKFWInstance_CreateMutex( + NSSCKFWInstance *fwInstance, + NSSArena *arena, + CK_RV *pError); + +/* + * NSSCKFWInstance_GetConfigurationData + * + */ + +NSS_EXTERN NSSUTF8 * +NSSCKFWInstance_GetConfigurationData( + NSSCKFWInstance *fwInstance); + +/* + * NSSCKFWInstance_GetInitArgs + * + */ + +NSS_EXTERN CK_C_INITIALIZE_ARGS_PTR +NSSCKFWInstance_GetInitArgs( + NSSCKFWInstance *fwInstance); + +/* + * nssCKFWInstance_DestroySessionHandle + * + */ +NSS_EXTERN void +NSSCKFWInstance_DestroySessionHandle( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession); + +/* + * nssCKFWInstance_FindSessionHandle + * + */ +NSS_EXTERN CK_SESSION_HANDLE +NSSCKFWInstance_FindSessionHandle( + NSSCKFWInstance *fwInstance, + NSSCKFWSession *fwSession); + +/* + * NSSCKFWSlot + * + * NSSCKFWSlot_GetMDSlot + * NSSCKFWSlot_GetFWInstance + * NSSCKFWSlot_GetMDInstance + * NSSCKFWSlot_GetSlotID + * + */ + +/* + * NSSCKFWSlot_GetMDSlot + * + */ + +NSS_EXTERN NSSCKMDSlot * +NSSCKFWSlot_GetMDSlot( + NSSCKFWSlot *fwSlot); + +/* + * NSSCKFWSlot_GetFWInstance + * + */ + +NSS_EXTERN NSSCKFWInstance * +NSSCKFWSlot_GetFWInstance( + NSSCKFWSlot *fwSlot); + +/* + * NSSCKFWSlot_GetMDInstance + * + */ + +NSS_EXTERN NSSCKMDInstance * +NSSCKFWSlot_GetMDInstance( + NSSCKFWSlot *fwSlot); + +/* + * NSSCKFWSlot_GetSlotID + * + */ + +NSS_EXTERN CK_SLOT_ID +NSSCKFWSlot_GetSlotID( + NSSCKFWSlot *fwSlot); + +/* + * NSSCKFWToken + * + * NSSCKFWToken_GetMDToken + * NSSCKFWToken_GetFWSlot + * NSSCKFWToken_GetMDSlot + * NSSCKFWToken_GetSessionState + * + */ + +/* + * NSSCKFWToken_GetMDToken + * + */ + +NSS_EXTERN NSSCKMDToken * +NSSCKFWToken_GetMDToken( + NSSCKFWToken *fwToken); + +/* + * NSSCKFWToken_GetArena + * + */ + +NSS_EXTERN NSSArena * +NSSCKFWToken_GetArena( + NSSCKFWToken *fwToken, + CK_RV *pError); + +/* + * NSSCKFWToken_GetFWSlot + * + */ + +NSS_EXTERN NSSCKFWSlot * +NSSCKFWToken_GetFWSlot( + NSSCKFWToken *fwToken); + +/* + * NSSCKFWToken_GetMDSlot + * + */ + +NSS_EXTERN NSSCKMDSlot * +NSSCKFWToken_GetMDSlot( + NSSCKFWToken *fwToken); + +/* + * NSSCKFWToken_GetSessionState + * + */ + +NSS_EXTERN CK_STATE +NSSCKFWToken_GetSessionState( + NSSCKFWToken *fwToken); + +/* + * NSSCKFWMechanism + * + * NSSKCFWMechanism_GetMDMechanism + * NSSCKFWMechanism_GetParameter + * + */ + +/* + * NSSKCFWMechanism_GetMDMechanism + * + */ + +NSS_EXTERN NSSCKMDMechanism * +NSSCKFWMechanism_GetMDMechanism( + NSSCKFWMechanism *fwMechanism); + +/* + * NSSCKFWMechanism_GetParameter + * + */ + +NSS_EXTERN NSSItem * +NSSCKFWMechanism_GetParameter( + NSSCKFWMechanism *fwMechanism); + +/* + * NSSCKFWSession + * + * NSSCKFWSession_GetMDSession + * NSSCKFWSession_GetArena + * NSSCKFWSession_CallNotification + * NSSCKFWSession_IsRWSession + * NSSCKFWSession_IsSO + * NSSCKFWSession_GetCurrentCryptoOperation + * NSSCKFWSession_GetFWSlot + * + */ + +/* + * NSSCKFWSession_GetMDSession + * + */ + +NSS_EXTERN NSSCKMDSession * +NSSCKFWSession_GetMDSession( + NSSCKFWSession *fwSession); + +/* + * NSSCKFWSession_GetArena + * + */ + +NSS_EXTERN NSSArena * +NSSCKFWSession_GetArena( + NSSCKFWSession *fwSession, + CK_RV *pError); + +/* + * NSSCKFWSession_CallNotification + * + */ + +NSS_EXTERN CK_RV +NSSCKFWSession_CallNotification( + NSSCKFWSession *fwSession, + CK_NOTIFICATION event); + +/* + * NSSCKFWSession_IsRWSession + * + */ + +NSS_EXTERN CK_BBOOL +NSSCKFWSession_IsRWSession( + NSSCKFWSession *fwSession); + +/* + * NSSCKFWSession_IsSO + * + */ + +NSS_EXTERN CK_BBOOL +NSSCKFWSession_IsSO( + NSSCKFWSession *fwSession); + +/* + * NSSCKFWSession_GetCurrentCryptoOperation + * + */ + +NSS_EXTERN NSSCKFWCryptoOperation * +NSSCKFWSession_GetCurrentCryptoOperation( + NSSCKFWSession *fwSession, + NSSCKFWCryptoOperationState state); + +/* + * NSSCKFWSession_GetFWSlot + * + */ + +NSS_EXTERN NSSCKFWSlot * +NSSCKFWSession_GetFWSlot( + NSSCKFWSession *fwSession); + +/* + * NSSCKFWObject + * + * NSSCKFWObject_GetMDObject + * NSSCKFWObject_GetArena + * NSSCKFWObject_IsTokenObject + * NSSCKFWObject_GetAttributeCount + * NSSCKFWObject_GetAttributeTypes + * NSSCKFWObject_GetAttributeSize + * NSSCKFWObject_GetAttribute + * NSSCKFWObject_GetObjectSize + */ + +/* + * NSSCKFWObject_GetMDObject + * + */ +NSS_EXTERN NSSCKMDObject * +NSSCKFWObject_GetMDObject( + NSSCKFWObject *fwObject); + +/* + * NSSCKFWObject_GetArena + * + */ +NSS_EXTERN NSSArena * +NSSCKFWObject_GetArena( + NSSCKFWObject *fwObject, + CK_RV *pError); + +/* + * NSSCKFWObject_IsTokenObject + * + */ +NSS_EXTERN CK_BBOOL +NSSCKFWObject_IsTokenObject( + NSSCKFWObject *fwObject); + +/* + * NSSCKFWObject_GetAttributeCount + * + */ +NSS_EXTERN CK_ULONG +NSSCKFWObject_GetAttributeCount( + NSSCKFWObject *fwObject, + CK_RV *pError); + +/* + * NSSCKFWObject_GetAttributeTypes + * + */ +NSS_EXTERN CK_RV +NSSCKFWObject_GetAttributeTypes( + NSSCKFWObject *fwObject, + CK_ATTRIBUTE_TYPE_PTR typeArray, + CK_ULONG ulCount); + +/* + * NSSCKFWObject_GetAttributeSize + * + */ +NSS_EXTERN CK_ULONG +NSSCKFWObject_GetAttributeSize( + NSSCKFWObject *fwObject, + CK_ATTRIBUTE_TYPE attribute, + CK_RV *pError); + +/* + * NSSCKFWObject_GetAttribute + * + */ +NSS_EXTERN NSSItem * +NSSCKFWObject_GetAttribute( + NSSCKFWObject *fwObject, + CK_ATTRIBUTE_TYPE attribute, + NSSItem *itemOpt, + NSSArena *arenaOpt, + CK_RV *pError); + +/* + * NSSCKFWObject_GetObjectSize + * + */ +NSS_EXTERN CK_ULONG +NSSCKFWObject_GetObjectSize( + NSSCKFWObject *fwObject, + CK_RV *pError); + +/* + * NSSCKFWFindObjects + * + * NSSCKFWFindObjects_GetMDFindObjects + * + */ + +/* + * NSSCKFWFindObjects_GetMDFindObjects + * + */ + +NSS_EXTERN NSSCKMDFindObjects * +NSSCKFWFindObjects_GetMDFindObjects( + NSSCKFWFindObjects *); + +/* + * NSSCKFWMutex + * + * NSSCKFWMutex_Destroy + * NSSCKFWMutex_Lock + * NSSCKFWMutex_Unlock + * + */ + +/* + * NSSCKFWMutex_Destroy + * + */ + +NSS_EXTERN CK_RV +NSSCKFWMutex_Destroy( + NSSCKFWMutex *mutex); + +/* + * NSSCKFWMutex_Lock + * + */ + +NSS_EXTERN CK_RV +NSSCKFWMutex_Lock( + NSSCKFWMutex *mutex); + +/* + * NSSCKFWMutex_Unlock + * + */ + +NSS_EXTERN CK_RV +NSSCKFWMutex_Unlock( + NSSCKFWMutex *mutex); + +#endif /* NSSCKFW_H */ diff --git a/illumos-x86_64/usr/include/mps/nssckfwc.h b/illumos-x86_64/usr/include/mps/nssckfwc.h new file mode 100644 index 00000000..734a67cf --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckfwc.h @@ -0,0 +1,879 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef NSSCKFWC_H +#define NSSCKFWC_H + +/* + * nssckfwc.h + * + * This file prototypes all of the NSS Cryptoki Framework "wrapper" + * which implement the PKCS#11 API. Technically, these are public + * routines (with capital "NSS" prefixes), since they are called + * from (generated) code within a Module using the Framework. + * However, they should not be called except from those generated + * calls. Hence, the prototypes have been split out into this file. + */ + +#ifndef NSSCKT_H +#include "nssckt.h" +#endif /* NSSCKT_H */ + +#ifndef NSSCKFWT_H +#include "nssckfwt.h" +#endif /* NSSCKFWT_H */ + +#ifndef NSSCKMDT_H +#include "nssckmdt.h" +#endif /* NSSCKMDT_H */ + +/* + * NSSCKFWC_Initialize + * NSSCKFWC_Finalize + * NSSCKFWC_GetInfo + * -- NSSCKFWC_GetFunctionList -- see the API insert file + * NSSCKFWC_GetSlotList + * NSSCKFWC_GetSlotInfo + * NSSCKFWC_GetTokenInfo + * NSSCKFWC_WaitForSlotEvent + * NSSCKFWC_GetMechanismList + * NSSCKFWC_GetMechanismInfo + * NSSCKFWC_InitToken + * NSSCKFWC_InitPIN + * NSSCKFWC_SetPIN + * NSSCKFWC_OpenSession + * NSSCKFWC_CloseSession + * NSSCKFWC_CloseAllSessions + * NSSCKFWC_GetSessionInfo + * NSSCKFWC_GetOperationState + * NSSCKFWC_SetOperationState + * NSSCKFWC_Login + * NSSCKFWC_Logout + * NSSCKFWC_CreateObject + * NSSCKFWC_CopyObject + * NSSCKFWC_DestroyObject + * NSSCKFWC_GetObjectSize + * NSSCKFWC_GetAttributeValue + * NSSCKFWC_SetAttributeValue + * NSSCKFWC_FindObjectsInit + * NSSCKFWC_FindObjects + * NSSCKFWC_FindObjectsFinal + * NSSCKFWC_EncryptInit + * NSSCKFWC_Encrypt + * NSSCKFWC_EncryptUpdate + * NSSCKFWC_EncryptFinal + * NSSCKFWC_DecryptInit + * NSSCKFWC_Decrypt + * NSSCKFWC_DecryptUpdate + * NSSCKFWC_DecryptFinal + * NSSCKFWC_DigestInit + * NSSCKFWC_Digest + * NSSCKFWC_DigestUpdate + * NSSCKFWC_DigestKey + * NSSCKFWC_DigestFinal + * NSSCKFWC_SignInit + * NSSCKFWC_Sign + * NSSCKFWC_SignUpdate + * NSSCKFWC_SignFinal + * NSSCKFWC_SignRecoverInit + * NSSCKFWC_SignRecover + * NSSCKFWC_VerifyInit + * NSSCKFWC_Verify + * NSSCKFWC_VerifyUpdate + * NSSCKFWC_VerifyFinal + * NSSCKFWC_VerifyRecoverInit + * NSSCKFWC_VerifyRecover + * NSSCKFWC_DigestEncryptUpdate + * NSSCKFWC_DecryptDigestUpdate + * NSSCKFWC_SignEncryptUpdate + * NSSCKFWC_DecryptVerifyUpdate + * NSSCKFWC_GenerateKey + * NSSCKFWC_GenerateKeyPair + * NSSCKFWC_WrapKey + * NSSCKFWC_UnwrapKey + * NSSCKFWC_DeriveKey + * NSSCKFWC_SeedRandom + * NSSCKFWC_GenerateRandom + * NSSCKFWC_GetFunctionStatus + * NSSCKFWC_CancelFunction + */ + +/* + * NSSCKFWC_Initialize + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Initialize( + NSSCKFWInstance **pFwInstance, + NSSCKMDInstance *mdInstance, + CK_VOID_PTR pInitArgs); + +/* + * NSSCKFWC_Finalize + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Finalize( + NSSCKFWInstance **pFwInstance); + +/* + * NSSCKFWC_GetInfo + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetInfo( + NSSCKFWInstance *fwInstance, + CK_INFO_PTR pInfo); + +/* + * C_GetFunctionList is implemented entirely in the Module's file which + * includes the Framework API insert file. It requires no "actual" + * NSSCKFW routine. + */ + +/* + * NSSCKFWC_GetSlotList + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetSlotList( + NSSCKFWInstance *fwInstance, + CK_BBOOL tokenPresent, + CK_SLOT_ID_PTR pSlotList, + CK_ULONG_PTR pulCount); + +/* + * NSSCKFWC_GetSlotInfo + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetSlotInfo( + NSSCKFWInstance *fwInstance, + CK_SLOT_ID slotID, + CK_SLOT_INFO_PTR pInfo); + +/* + * NSSCKFWC_GetTokenInfo + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetTokenInfo( + NSSCKFWInstance *fwInstance, + CK_SLOT_ID slotID, + CK_TOKEN_INFO_PTR pInfo); + +/* + * NSSCKFWC_WaitForSlotEvent + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_WaitForSlotEvent( + NSSCKFWInstance *fwInstance, + CK_FLAGS flags, + CK_SLOT_ID_PTR pSlot, + CK_VOID_PTR pReserved); + +/* + * NSSCKFWC_GetMechanismList + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetMechanismList( + NSSCKFWInstance *fwInstance, + CK_SLOT_ID slotID, + CK_MECHANISM_TYPE_PTR pMechanismList, + CK_ULONG_PTR pulCount); + +/* + * NSSCKFWC_GetMechanismInfo + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetMechanismInfo( + NSSCKFWInstance *fwInstance, + CK_SLOT_ID slotID, + CK_MECHANISM_TYPE type, + CK_MECHANISM_INFO_PTR pInfo); + +/* + * NSSCKFWC_InitToken + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_InitToken( + NSSCKFWInstance *fwInstance, + CK_SLOT_ID slotID, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen, + CK_CHAR_PTR pLabel); + +/* + * NSSCKFWC_InitPIN + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_InitPIN( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen); + +/* + * NSSCKFWC_SetPIN + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SetPIN( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_CHAR_PTR pOldPin, + CK_ULONG ulOldLen, + CK_CHAR_PTR pNewPin, + CK_ULONG ulNewLen); + +/* + * NSSCKFWC_OpenSession + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_OpenSession( + NSSCKFWInstance *fwInstance, + CK_SLOT_ID slotID, + CK_FLAGS flags, + CK_VOID_PTR pApplication, + CK_NOTIFY Notify, + CK_SESSION_HANDLE_PTR phSession); + +/* + * NSSCKFWC_CloseSession + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_CloseSession( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession); + +/* + * NSSCKFWC_CloseAllSessions + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_CloseAllSessions( + NSSCKFWInstance *fwInstance, + CK_SLOT_ID slotID); + +/* + * NSSCKFWC_GetSessionInfo + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetSessionInfo( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_SESSION_INFO_PTR pInfo); + +/* + * NSSCKFWC_GetOperationState + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetOperationState( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pOperationState, + CK_ULONG_PTR pulOperationStateLen); + +/* + * NSSCKFWC_SetOperationState + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SetOperationState( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pOperationState, + CK_ULONG ulOperationStateLen, + CK_OBJECT_HANDLE hEncryptionKey, + CK_OBJECT_HANDLE hAuthenticationKey); + +/* + * NSSCKFWC_Login + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Login( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_USER_TYPE userType, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen); + +/* + * NSSCKFWC_Logout + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Logout( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession); + +/* + * NSSCKFWC_CreateObject + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_CreateObject( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phObject); + +/* + * NSSCKFWC_CopyObject + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_CopyObject( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phNewObject); + +/* + * NSSCKFWC_DestroyObject + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DestroyObject( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject); + +/* + * NSSCKFWC_GetObjectSize + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetObjectSize( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ULONG_PTR pulSize); + +/* + * NSSCKFWC_GetAttributeValue + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetAttributeValue( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount); + +/* + * NSSCKFWC_SetAttributeValue + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SetAttributeValue( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount); + +/* + * NSSCKFWC_FindObjectsInit + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_FindObjectsInit( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount); + +/* + * NSSCKFWC_FindObjects + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_FindObjects( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE_PTR phObject, + CK_ULONG ulMaxObjectCount, + CK_ULONG_PTR pulObjectCount); + +/* + * NSSCKFWC_FindObjectsFinal + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_FindObjectsFinal( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession); + +/* + * NSSCKFWC_EncryptInit + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_EncryptInit( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); + +/* + * NSSCKFWC_Encrypt + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Encrypt( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pEncryptedData, + CK_ULONG_PTR pulEncryptedDataLen); + +/* + * NSSCKFWC_EncryptUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_EncryptUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen); + +/* + * NSSCKFWC_EncryptFinal + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_EncryptFinal( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pLastEncryptedPart, + CK_ULONG_PTR pulLastEncryptedPartLen); + +/* + * NSSCKFWC_DecryptInit + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DecryptInit( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); + +/* + * NSSCKFWC_Decrypt + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Decrypt( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedData, + CK_ULONG ulEncryptedDataLen, + CK_BYTE_PTR pData, + CK_ULONG_PTR pulDataLen); + +/* + * NSSCKFWC_DecryptUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DecryptUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen); + +/* + * NSSCKFWC_DecryptFinal + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DecryptFinal( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pLastPart, + CK_ULONG_PTR pulLastPartLen); + +/* + * NSSCKFWC_DigestInit + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DigestInit( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism); + +/* + * NSSCKFWC_Digest + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Digest( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pDigest, + CK_ULONG_PTR pulDigestLen); + +/* + * NSSCKFWC_DigestUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DigestUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen); + +/* + * NSSCKFWC_DigestKey + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DigestKey( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hKey); + +/* + * NSSCKFWC_DigestFinal + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DigestFinal( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pDigest, + CK_ULONG_PTR pulDigestLen); + +/* + * NSSCKFWC_SignInit + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SignInit( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); + +/* + * NSSCKFWC_Sign + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Sign( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen); + +/* + * NSSCKFWC_SignUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SignUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen); + +/* + * NSSCKFWC_SignFinal + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SignFinal( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen); + +/* + * NSSCKFWC_SignRecoverInit + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SignRecoverInit( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); + +/* + * NSSCKFWC_SignRecover + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SignRecover( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen); + +/* + * NSSCKFWC_VerifyInit + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_VerifyInit( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); + +/* + * NSSCKFWC_Verify + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_Verify( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen); + +/* + * NSSCKFWC_VerifyUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_VerifyUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen); + +/* + * NSSCKFWC_VerifyFinal + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_VerifyFinal( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen); + +/* + * NSSCKFWC_VerifyRecoverInit + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_VerifyRecoverInit( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); + +/* + * NSSCKFWC_VerifyRecover + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_VerifyRecover( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen, + CK_BYTE_PTR pData, + CK_ULONG_PTR pulDataLen); + +/* + * NSSCKFWC_DigestEncryptUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DigestEncryptUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen); + +/* + * NSSCKFWC_DecryptDigestUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DecryptDigestUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen); + +/* + * NSSCKFWC_SignEncryptUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SignEncryptUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG_PTR pulEncryptedPartLen); + +/* + * NSSCKFWC_DecryptVerifyUpdate + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DecryptVerifyUpdate( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pEncryptedPart, + CK_ULONG ulEncryptedPartLen, + CK_BYTE_PTR pPart, + CK_ULONG_PTR pulPartLen); + +/* + * NSSCKFWC_GenerateKey + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GenerateKey( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulCount, + CK_OBJECT_HANDLE_PTR phKey); + +/* + * NSSCKFWC_GenerateKeyPair + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GenerateKeyPair( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_ATTRIBUTE_PTR pPublicKeyTemplate, + CK_ULONG ulPublicKeyAttributeCount, + CK_ATTRIBUTE_PTR pPrivateKeyTemplate, + CK_ULONG ulPrivateKeyAttributeCount, + CK_OBJECT_HANDLE_PTR phPublicKey, + CK_OBJECT_HANDLE_PTR phPrivateKey); + +/* + * NSSCKFWC_WrapKey + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_WrapKey( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hWrappingKey, + CK_OBJECT_HANDLE hKey, + CK_BYTE_PTR pWrappedKey, + CK_ULONG_PTR pulWrappedKeyLen); + +/* + * NSSCKFWC_UnwrapKey + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_UnwrapKey( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hUnwrappingKey, + CK_BYTE_PTR pWrappedKey, + CK_ULONG ulWrappedKeyLen, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_OBJECT_HANDLE_PTR phKey); + +/* + * NSSCKFWC_DeriveKey + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_DeriveKey( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hBaseKey, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_OBJECT_HANDLE_PTR phKey); + +/* + * NSSCKFWC_SeedRandom + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_SeedRandom( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pSeed, + CK_ULONG ulSeedLen); + +/* + * NSSCKFWC_GenerateRandom + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GenerateRandom( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pRandomData, + CK_ULONG ulRandomLen); + +/* + * NSSCKFWC_GetFunctionStatus + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_GetFunctionStatus( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession); + +/* + * NSSCKFWC_CancelFunction + * + */ +NSS_EXTERN CK_RV +NSSCKFWC_CancelFunction( + NSSCKFWInstance *fwInstance, + CK_SESSION_HANDLE hSession); + +#endif /* NSSCKFWC_H */ diff --git a/illumos-x86_64/usr/include/mps/nssckfwt.h b/illumos-x86_64/usr/include/mps/nssckfwt.h new file mode 100644 index 00000000..cd015d51 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckfwt.h @@ -0,0 +1,109 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef NSSCKFWT_H +#define NSSCKFWT_H + +/* + * nssckfwt.h + * + * This file declares the public types used by the NSS Cryptoki Framework. + */ + +/* + * NSSCKFWInstance + * + */ + +struct NSSCKFWInstanceStr; +typedef struct NSSCKFWInstanceStr NSSCKFWInstance; + +/* + * NSSCKFWSlot + * + */ + +struct NSSCKFWSlotStr; +typedef struct NSSCKFWSlotStr NSSCKFWSlot; + +/* + * NSSCKFWToken + * + */ + +struct NSSCKFWTokenStr; +typedef struct NSSCKFWTokenStr NSSCKFWToken; + +/* + * NSSCKFWMechanism + * + */ + +struct NSSCKFWMechanismStr; +typedef struct NSSCKFWMechanismStr NSSCKFWMechanism; + +/* + * NSSCKFWCryptoOperation + * + */ + +struct NSSCKFWCryptoOperationStr; +typedef struct NSSCKFWCryptoOperationStr NSSCKFWCryptoOperation; + +/* + * NSSCKFWSession + * + */ + +struct NSSCKFWSessionStr; +typedef struct NSSCKFWSessionStr NSSCKFWSession; + +/* + * NSSCKFWObject + * + */ + +struct NSSCKFWObjectStr; +typedef struct NSSCKFWObjectStr NSSCKFWObject; + +/* + * NSSCKFWFindObjects + * + */ + +struct NSSCKFWFindObjectsStr; +typedef struct NSSCKFWFindObjectsStr NSSCKFWFindObjects; + +/* + * NSSCKFWMutex + * + */ + +struct NSSCKFWMutexStr; +typedef struct NSSCKFWMutexStr NSSCKFWMutex; + +typedef enum { + SingleThreaded, + MultiThreaded +} CryptokiLockingState; + +/* used as an index into an array, make sure it starts at '0' */ +typedef enum { + NSSCKFWCryptoOperationState_EncryptDecrypt = 0, + NSSCKFWCryptoOperationState_SignVerify, + NSSCKFWCryptoOperationState_Digest, + NSSCKFWCryptoOperationState_Max +} NSSCKFWCryptoOperationState; + +typedef enum { + NSSCKFWCryptoOperationType_Encrypt, + NSSCKFWCryptoOperationType_Decrypt, + NSSCKFWCryptoOperationType_Digest, + NSSCKFWCryptoOperationType_Sign, + NSSCKFWCryptoOperationType_Verify, + NSSCKFWCryptoOperationType_SignRecover, + NSSCKFWCryptoOperationType_VerifyRecover +} NSSCKFWCryptoOperationType; + +#endif /* NSSCKFWT_H */ diff --git a/illumos-x86_64/usr/include/mps/nssckg.h b/illumos-x86_64/usr/include/mps/nssckg.h new file mode 100644 index 00000000..bf0d43fb --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckg.h @@ -0,0 +1,10 @@ +/* THIS IS A GENERATED FILE */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef NSSCKG_H +#define NSSCKG_H + +#include "pkcs11.h" + +#endif /* NSSCKG_H */ diff --git a/illumos-x86_64/usr/include/mps/nssckmdt.h b/illumos-x86_64/usr/include/mps/nssckmdt.h new file mode 100644 index 00000000..890e8c32 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckmdt.h @@ -0,0 +1,1904 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef NSSCKMDT_H +#define NSSCKMDT_H + +/* + * nssckmdt.h + * + * This file specifies the basic types that must be implemented by + * any Module using the NSS Cryptoki Framework. + */ + +#ifndef NSSBASET_H +#include "nssbaset.h" +#endif /* NSSBASET_H */ + +#ifndef NSSCKT_H +#include "nssckt.h" +#endif /* NSSCKT_H */ + +#ifndef NSSCKFWT_H +#include "nssckfwt.h" +#endif /* NSSCKFWT_H */ + +typedef struct NSSCKMDInstanceStr NSSCKMDInstance; +typedef struct NSSCKMDSlotStr NSSCKMDSlot; +typedef struct NSSCKMDTokenStr NSSCKMDToken; +typedef struct NSSCKMDSessionStr NSSCKMDSession; +typedef struct NSSCKMDCryptoOperationStr NSSCKMDCryptoOperation; +typedef struct NSSCKMDFindObjectsStr NSSCKMDFindObjects; +typedef struct NSSCKMDMechanismStr NSSCKMDMechanism; +typedef struct NSSCKMDObjectStr NSSCKMDObject; + +/* + * NSSCKFWItem + * + * This is a structure used by modules to return object attributes. + * The needsFreeing bit indicates whether the object needs to be freed. + * If so, the framework will call the FreeAttribute function on the item + * after it is done using it. + * + */ + +typedef struct { + PRBool needsFreeing; + NSSItem *item; +} NSSCKFWItem; + +/* + * NSSCKMDInstance + * + * This is the basic handle for an instance of a PKCS#11 Module. + * It is returned by the Module's CreateInstance routine, and + * may be obtained from the corresponding NSSCKFWInstance object. + * It contains a pointer for use by the Module, to store any + * instance-related data, and it contains the EPV for a set of + * routines which the Module may implement for use by the Framework. + * Some of these routines are optional; others are mandatory. + */ + +struct NSSCKMDInstanceStr { + /* + * The Module may use this pointer for its own purposes. + */ + void *etc; + + /* + * This routine is called by the Framework to initialize + * the Module. This routine is optional; if unimplemented, + * it won't be called. If this routine returns an error, + * then the initialization will fail. + */ + CK_RV(PR_CALLBACK *Initialize) + ( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSUTF8 *configurationData); + + /* + * This routine is called when the Framework is finalizing + * the PKCS#11 Module. It is the last thing called before + * the NSSCKFWInstance's NSSArena is destroyed. This routine + * is optional; if unimplemented, it merely won't be called. + */ + void(PR_CALLBACK *Finalize)( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine gets the number of slots. This value must + * never change, once the instance is initialized. This + * routine must be implemented. It may return zero on error. + */ + CK_ULONG(PR_CALLBACK *GetNSlots) + ( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns the version of the Cryptoki standard + * to which this Module conforms. This routine is optional; + * if unimplemented, the Framework uses the version to which + * ~it~ was implemented. + */ + CK_VERSION(PR_CALLBACK *GetCryptokiVersion) + ( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns a pointer to a UTF8-encoded string + * containing the manufacturer ID for this Module. Only + * the characters completely encoded in the first thirty- + * two bytes are significant. This routine is optional. + * The string returned is never freed; if dynamically generated, + * the space for it should be allocated from the NSSArena + * that may be obtained from the NSSCKFWInstance. This + * routine may return NULL upon error; however if *pError + * is CKR_OK, the NULL will be considered the valid response. + */ + NSSUTF8 *(PR_CALLBACK *GetManufacturerID)( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns a pointer to a UTF8-encoded string + * containing a description of this Module library. Only + * the characters completely encoded in the first thirty- + * two bytes are significant. This routine is optional. + * The string returned is never freed; if dynamically generated, + * the space for it should be allocated from the NSSArena + * that may be obtained from the NSSCKFWInstance. This + * routine may return NULL upon error; however if *pError + * is CKR_OK, the NULL will be considered the valid response. + */ + NSSUTF8 *(PR_CALLBACK *GetLibraryDescription)( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns the version of this Module library. + * This routine is optional; if unimplemented, the Framework + * will assume a Module library version of 0.1. + */ + CK_VERSION(PR_CALLBACK *GetLibraryVersion) + ( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if the Module wishes to + * handle session objects. This routine is optional. + * If this routine is NULL, or if it exists but returns + * CK_FALSE, the Framework will assume responsibility + * for managing session objects. + */ + CK_BBOOL(PR_CALLBACK *ModuleHandlesSessionObjects) + ( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine stuffs pointers to NSSCKMDSlot objects into + * the specified array; one for each slot supported by this + * instance. The Framework will determine the size needed + * for the array by calling GetNSlots. This routine is + * required. + */ + CK_RV(PR_CALLBACK *GetSlots) + ( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDSlot *slots[]); + + /* + * This call returns a pointer to the slot in which an event + * has occurred. If the block argument is CK_TRUE, the call + * should block until a slot event occurs; if CK_FALSE, it + * should check to see if an event has occurred, occurred, + * but return NULL (and set *pError to CK_NO_EVENT) if one + * hasn't. This routine is optional; if unimplemented, the + * Framework will assume that no event has happened. This + * routine may return NULL upon error. + */ + NSSCKMDSlot *(PR_CALLBACK *WaitForSlotEvent)( + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_BBOOL block, + CK_RV *pError); + + /* + * This object may be extended in future versions of the + * NSS Cryptoki Framework. To allow for some flexibility + * in the area of binary compatibility, this field should + * be NULL. + */ + void *null; +}; + +/* + * NSSCKMDSlot + * + * This is the basic handle for a PKCS#11 Module Slot. It is + * created by the NSSCKMDInstance->GetSlots call, and may be + * obtained from the Framework's corresponding NSSCKFWSlot + * object. It contains a pointer for use by the Module, to + * store any slot-related data, and it contains the EPV for + * a set of routines which the Module may implement for use + * by the Framework. Some of these routines are optional. + */ + +struct NSSCKMDSlotStr { + /* + * The Module may use this pointer for its own purposes. + */ + void *etc; + + /* + * This routine is called during the Framework initialization + * step, after the Framework Instance has obtained the list + * of slots (by calling NSSCKMDInstance->GetSlots). Any slot- + * specific initialization can be done here. This routine is + * optional; if unimplemented, it won't be called. Note that + * if this routine returns an error, the entire Framework + * initialization for this Module will fail. + */ + CK_RV(PR_CALLBACK *Initialize) + ( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine is called when the Framework is finalizing + * the PKCS#11 Module. This call (for each of the slots) + * is the last thing called before NSSCKMDInstance->Finalize. + * This routine is optional; if unimplemented, it merely + * won't be called. Note: In the rare circumstance that + * the Framework initialization cannot complete (due to, + * for example, memory limitations), this can be called with + * a NULL value for fwSlot. + */ + void(PR_CALLBACK *Destroy)( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns a pointer to a UTF8-encoded string + * containing a description of this slot. Only the characters + * completely encoded in the first sixty-four bytes are + * significant. This routine is optional. The string + * returned is never freed; if dynamically generated, + * the space for it should be allocated from the NSSArena + * that may be obtained from the NSSCKFWInstance. This + * routine may return NULL upon error; however if *pError + * is CKR_OK, the NULL will be considered the valid response. + */ + NSSUTF8 *(PR_CALLBACK *GetSlotDescription)( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns a pointer to a UTF8-encoded string + * containing a description of the manufacturer of this slot. + * Only the characters completely encoded in the first thirty- + * two bytes are significant. This routine is optional. + * The string returned is never freed; if dynamically generated, + * the space for it should be allocated from the NSSArena + * that may be obtained from the NSSCKFWInstance. This + * routine may return NULL upon error; however if *pError + * is CKR_OK, the NULL will be considered the valid response. + */ + NSSUTF8 *(PR_CALLBACK *GetManufacturerID)( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns CK_TRUE if a token is present in this + * slot. This routine is optional; if unimplemented, CK_TRUE + * is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetTokenPresent) + ( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if the slot supports removable + * tokens. This routine is optional; if unimplemented, CK_FALSE + * is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetRemovableDevice) + ( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if this slot is a hardware + * device, or CK_FALSE if this slot is a software device. This + * routine is optional; if unimplemented, CK_FALSE is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetHardwareSlot) + ( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the version of this slot's hardware. + * This routine is optional; if unimplemented, the Framework + * will assume a hardware version of 0.1. + */ + CK_VERSION(PR_CALLBACK *GetHardwareVersion) + ( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the version of this slot's firmware. + * This routine is optional; if unimplemented, the Framework + * will assume a hardware version of 0.1. + */ + CK_VERSION(PR_CALLBACK *GetFirmwareVersion) + ( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine should return a pointer to an NSSCKMDToken + * object corresponding to the token in the specified slot. + * The NSSCKFWToken object passed in has an NSSArena + * available which is dedicated for this token. This routine + * must be implemented. This routine may return NULL upon + * error. + */ + NSSCKMDToken *(PR_CALLBACK *GetToken)( + NSSCKMDSlot *mdSlot, + NSSCKFWSlot *fwSlot, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This object may be extended in future versions of the + * NSS Cryptoki Framework. To allow for some flexibility + * in the area of binary compatibility, this field should + * be NULL. + */ + void *null; +}; + +/* + * NSSCKMDToken + * + * This is the basic handle for a PKCS#11 Token. It is created by + * the NSSCKMDSlot->GetToken call, and may be obtained from the + * Framework's corresponding NSSCKFWToken object. It contains a + * pointer for use by the Module, to store any token-related + * data, and it contains the EPV for a set of routines which the + * Module may implement for use by the Framework. Some of these + * routines are optional. + */ + +struct NSSCKMDTokenStr { + /* + * The Module may use this pointer for its own purposes. + */ + void *etc; + + /* + * This routine is used to prepare a Module token object for + * use. It is called after the NSSCKMDToken object is obtained + * from NSSCKMDSlot->GetToken. It is named "Setup" here because + * Cryptoki already defines "InitToken" to do the process of + * wiping out any existing state on a token and preparing it for + * a new use. This routine is optional; if unimplemented, it + * merely won't be called. + */ + CK_RV(PR_CALLBACK *Setup) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine is called by the Framework whenever it notices + * that the token object is invalid. (Typically this is when a + * routine indicates an error such as CKR_DEVICE_REMOVED). This + * call is the last thing called before the NSSArena in the + * corresponding NSSCKFWToken is destroyed. This routine is + * optional; if unimplemented, it merely won't be called. + */ + void(PR_CALLBACK *Invalidate)( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine initialises the token in the specified slot. + * This routine is optional; if unimplemented, the Framework + * will fail this operation with an error of CKR_DEVICE_ERROR. + */ + + CK_RV(PR_CALLBACK *InitToken) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSItem *pin, + NSSUTF8 *label); + + /* + * This routine returns a pointer to a UTF8-encoded string + * containing this token's label. Only the characters + * completely encoded in the first thirty-two bytes are + * significant. This routine is optional. The string + * returned is never freed; if dynamically generated, + * the space for it should be allocated from the NSSArena + * that may be obtained from the NSSCKFWInstance. This + * routine may return NULL upon error; however if *pError + * is CKR_OK, the NULL will be considered the valid response. + */ + NSSUTF8 *(PR_CALLBACK *GetLabel)( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns a pointer to a UTF8-encoded string + * containing this token's manufacturer ID. Only the characters + * completely encoded in the first thirty-two bytes are + * significant. This routine is optional. The string + * returned is never freed; if dynamically generated, + * the space for it should be allocated from the NSSArena + * that may be obtained from the NSSCKFWInstance. This + * routine may return NULL upon error; however if *pError + * is CKR_OK, the NULL will be considered the valid response. + */ + NSSUTF8 *(PR_CALLBACK *GetManufacturerID)( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns a pointer to a UTF8-encoded string + * containing this token's model name. Only the characters + * completely encoded in the first thirty-two bytes are + * significant. This routine is optional. The string + * returned is never freed; if dynamically generated, + * the space for it should be allocated from the NSSArena + * that may be obtained from the NSSCKFWInstance. This + * routine may return NULL upon error; however if *pError + * is CKR_OK, the NULL will be considered the valid response. + */ + NSSUTF8 *(PR_CALLBACK *GetModel)( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns a pointer to a UTF8-encoded string + * containing this token's serial number. Only the characters + * completely encoded in the first thirty-two bytes are + * significant. This routine is optional. The string + * returned is never freed; if dynamically generated, + * the space for it should be allocated from the NSSArena + * that may be obtained from the NSSCKFWInstance. This + * routine may return NULL upon error; however if *pError + * is CKR_OK, the NULL will be considered the valid response. + */ + NSSUTF8 *(PR_CALLBACK *GetSerialNumber)( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns CK_TRUE if the token has its own + * random number generator. This routine is optional; if + * unimplemented, CK_FALSE is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetHasRNG) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if this token is write-protected. + * This routine is optional; if unimplemented, CK_FALSE is + * assumed. + */ + CK_BBOOL(PR_CALLBACK *GetIsWriteProtected) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if this token requires a login. + * This routine is optional; if unimplemented, CK_FALSE is + * assumed. + */ + CK_BBOOL(PR_CALLBACK *GetLoginRequired) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if the normal user's PIN on this + * token has been initialised. This routine is optional; if + * unimplemented, CK_FALSE is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetUserPinInitialized) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if a successful save of a + * session's cryptographic operations state ~always~ contains + * all keys needed to restore the state of the session. This + * routine is optional; if unimplemented, CK_FALSE is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetRestoreKeyNotNeeded) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if the token has its own + * hardware clock. This routine is optional; if unimplemented, + * CK_FALSE is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetHasClockOnToken) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if the token has a protected + * authentication path. This routine is optional; if + * unimplemented, CK_FALSE is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetHasProtectedAuthenticationPath) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns CK_TRUE if the token supports dual + * cryptographic operations within a single session. This + * routine is optional; if unimplemented, CK_FALSE is assumed. + */ + CK_BBOOL(PR_CALLBACK *GetSupportsDualCryptoOperations) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * XXX fgmr-- should we have a call to return all the flags + * at once, for folks who already know about Cryptoki? + */ + + /* + * This routine returns the maximum number of sessions that + * may be opened on this token. This routine is optional; + * if unimplemented, the special value CK_UNAVAILABLE_INFORMATION + * is assumed. XXX fgmr-- or CK_EFFECTIVELY_INFINITE? + */ + CK_ULONG(PR_CALLBACK *GetMaxSessionCount) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the maximum number of read/write + * sesisons that may be opened on this token. This routine + * is optional; if unimplemented, the special value + * CK_UNAVAILABLE_INFORMATION is assumed. XXX fgmr-- or + * CK_EFFECTIVELY_INFINITE? + */ + CK_ULONG(PR_CALLBACK *GetMaxRwSessionCount) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the maximum PIN code length that is + * supported on this token. This routine is optional; + * if unimplemented, the special value CK_UNAVAILABLE_INFORMATION + * is assumed. + */ + CK_ULONG(PR_CALLBACK *GetMaxPinLen) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the minimum PIN code length that is + * supported on this token. This routine is optional; if + * unimplemented, the special value CK_UNAVAILABLE_INFORMATION + * is assumed. XXX fgmr-- or 0? + */ + CK_ULONG(PR_CALLBACK *GetMinPinLen) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the total amount of memory on the token + * in which public objects may be stored. This routine is + * optional; if unimplemented, the special value + * CK_UNAVAILABLE_INFORMATION is assumed. + */ + CK_ULONG(PR_CALLBACK *GetTotalPublicMemory) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the amount of unused memory on the + * token in which public objects may be stored. This routine + * is optional; if unimplemented, the special value + * CK_UNAVAILABLE_INFORMATION is assumed. + */ + CK_ULONG(PR_CALLBACK *GetFreePublicMemory) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the total amount of memory on the token + * in which private objects may be stored. This routine is + * optional; if unimplemented, the special value + * CK_UNAVAILABLE_INFORMATION is assumed. + */ + CK_ULONG(PR_CALLBACK *GetTotalPrivateMemory) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the amount of unused memory on the + * token in which private objects may be stored. This routine + * is optional; if unimplemented, the special value + * CK_UNAVAILABLE_INFORMATION is assumed. + */ + CK_ULONG(PR_CALLBACK *GetFreePrivateMemory) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the version number of this token's + * hardware. This routine is optional; if unimplemented, + * the value 0.1 is assumed. + */ + CK_VERSION(PR_CALLBACK *GetHardwareVersion) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the version number of this token's + * firmware. This routine is optional; if unimplemented, + * the value 0.1 is assumed. + */ + CK_VERSION(PR_CALLBACK *GetFirmwareVersion) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine stuffs the current UTC time, as obtained from + * the token, into the sixteen-byte buffer in the form + * YYYYMMDDhhmmss00. This routine need only be implemented + * by token which indicate that they have a real-time clock. + * XXX fgmr-- think about time formats. + */ + CK_RV(PR_CALLBACK *GetUTCTime) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_CHAR utcTime[16]); + + /* + * This routine creates a session on the token, and returns + * the corresponding NSSCKMDSession object. The value of + * rw will be CK_TRUE if the session is to be a read/write + * session, or CK_FALSE otherwise. An NSSArena dedicated to + * the new session is available from the specified NSSCKFWSession. + * This routine may return NULL upon error. + */ + NSSCKMDSession *(PR_CALLBACK *OpenSession)( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKFWSession *fwSession, + CK_BBOOL rw, + CK_RV *pError); + + /* + * This routine returns the number of PKCS#11 Mechanisms + * supported by this token. This routine is optional; if + * unimplemented, zero is assumed. + */ + CK_ULONG(PR_CALLBACK *GetMechanismCount) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine stuffs into the specified array the types + * of the mechanisms supported by this token. The Framework + * determines the size of the array by calling GetMechanismCount. + */ + CK_RV(PR_CALLBACK *GetMechanismTypes) + ( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_MECHANISM_TYPE types[]); + + /* + * This routine returns a pointer to a Module mechanism + * object corresponding to a specified type. This routine + * need only exist for tokens implementing at least one + * mechanism. + */ + NSSCKMDMechanism *(PR_CALLBACK *GetMechanism)( + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_MECHANISM_TYPE which, + CK_RV *pError); + + /* + * This object may be extended in future versions of the + * NSS Cryptoki Framework. To allow for some flexibility + * in the area of binary compatibility, this field should + * be NULL. + */ + void *null; +}; + +/* + * NSSCKMDSession + * + * This is the basic handle for a session on a PKCS#11 Token. It + * is created by NSSCKMDToken->OpenSession, and may be obtained + * from the Framework's corresponding NSSCKFWSession object. It + * contains a pointer for use by the Module, to store any session- + * realted data, and it contains the EPV for a set of routines + * which the Module may implement for use by the Framework. Some + * of these routines are optional. + */ + +struct NSSCKMDSessionStr { + /* + * The Module may use this pointer for its own purposes. + */ + void *etc; + + /* + * This routine is called by the Framework when a session is + * closed. This call is the last thing called before the + * NSSArena in the correspoinding NSSCKFWSession is destroyed. + * This routine is optional; if unimplemented, it merely won't + * be called. + */ + void(PR_CALLBACK *Close)( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine is used to get any device-specific error. + * This routine is optional. + */ + CK_ULONG(PR_CALLBACK *GetDeviceError) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine is used to log in a user to the token. This + * routine is optional, since the Framework's NSSCKFWSession + * object keeps track of the login state. + */ + CK_RV(PR_CALLBACK *Login) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_USER_TYPE userType, + NSSItem *pin, + CK_STATE oldState, + CK_STATE newState); + + /* + * This routine is used to log out a user from the token. This + * routine is optional, since the Framework's NSSCKFWSession + * object keeps track of the login state. + */ + CK_RV(PR_CALLBACK *Logout) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_STATE oldState, + CK_STATE newState); + + /* + * This routine is used to initialize the normal user's PIN or + * password. This will only be called in the "read/write + * security officer functions" state. If this token has a + * protected authentication path, then the pin argument will + * be NULL. This routine is optional; if unimplemented, the + * Framework will return the error CKR_TOKEN_WRITE_PROTECTED. + */ + CK_RV(PR_CALLBACK *InitPIN) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSItem *pin); + + /* + * This routine is used to modify a user's PIN or password. This + * routine will only be called in the "read/write security officer + * functions" or "read/write user functions" state. If this token + * has a protected authentication path, then the pin arguments + * will be NULL. This routine is optional; if unimplemented, the + * Framework will return the error CKR_TOKEN_WRITE_PROTECTED. + */ + CK_RV(PR_CALLBACK *SetPIN) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSItem *oldPin, + NSSItem *newPin); + + /* + * This routine is used to find out how much space would be required + * to save the current operational state. This routine is optional; + * if unimplemented, the Framework will reject any attempts to save + * the operational state with the error CKR_STATE_UNSAVEABLE. This + * routine may return zero on error. + */ + CK_ULONG(PR_CALLBACK *GetOperationStateLen) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine is used to store the current operational state. This + * routine is only required if GetOperationStateLen is implemented + * and can return a nonzero value. The buffer in the specified item + * will be pre-allocated, and the length will specify the amount of + * space available (which may be more than GetOperationStateLen + * asked for, but which will not be smaller). + */ + CK_RV(PR_CALLBACK *GetOperationState) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSItem *buffer); + + /* + * This routine is used to restore an operational state previously + * obtained with GetOperationState. The Framework will take pains + * to be sure that the state is (or was at one point) valid; if the + * Module notices that the state is invalid, it should return an + * error, but it is not required to be paranoid about the issue. + * [XXX fgmr-- should (can?) the framework verify the keys match up?] + * This routine is required only if GetOperationState is implemented. + */ + CK_RV(PR_CALLBACK *SetOperationState) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSItem *state, + NSSCKMDObject *mdEncryptionKey, + NSSCKFWObject *fwEncryptionKey, + NSSCKMDObject *mdAuthenticationKey, + NSSCKFWObject *fwAuthenticationKey); + + /* + * This routine is used to create an object. The specified template + * will only specify a session object if the Module has indicated + * that it wishes to handle its own session objects. This routine + * is optional; if unimplemented, the Framework will reject the + * operation with the error CKR_TOKEN_WRITE_PROTECTED. Space for + * token objects should come from the NSSArena available from the + * NSSCKFWToken object; space for session objects (if supported) + * should come from the NSSArena available from the NSSCKFWSession + * object. The appropriate NSSArena pointer will, as a convenience, + * be passed as the handyArenaPointer argument. This routine may + * return NULL upon error. + */ + NSSCKMDObject *(PR_CALLBACK *CreateObject)( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSArena *handyArenaPointer, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_RV *pError); + + /* + * This routine is used to make a copy of an object. It is entirely + * optional; if unimplemented, the Framework will try to use + * CreateObject instead. If the Module has indicated that it does + * not wish to handle session objects, then this routine will only + * be called to copy a token object to another token object. + * Otherwise, either the original object or the new may be of + * either the token or session variety. As with CreateObject, the + * handyArenaPointer will point to the appropriate arena for the + * new object. This routine may return NULL upon error. + */ + NSSCKMDObject *(PR_CALLBACK *CopyObject)( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdOldObject, + NSSCKFWObject *fwOldObject, + NSSArena *handyArenaPointer, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_RV *pError); + + /* + * This routine is used to begin an object search. This routine may + * be unimplemented only if the Module does not handle session + * objects, and if none of its tokens have token objects. The + * NSSCKFWFindObjects pointer has an NSSArena that may be used for + * storage for the life of this "find" operation. This routine may + * return NULL upon error. If the Module can determine immediately + * that the search will not find any matching objects, it may return + * NULL, and specify CKR_OK as the error. + */ + NSSCKMDFindObjects *(PR_CALLBACK *FindObjectsInit)( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_RV *pError); + + /* + * This routine seeds the random-number generator. It is + * optional, even if GetRandom is implemented. If unimplemented, + * the Framework will issue the error CKR_RANDOM_SEED_NOT_SUPPORTED. + */ + CK_RV(PR_CALLBACK *SeedRandom) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSItem *seed); + + /* + * This routine gets random data. It is optional. If unimplemented, + * the Framework will issue the error CKR_RANDOM_NO_RNG. + */ + CK_RV(PR_CALLBACK *GetRandom) + ( + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSItem *buffer); + + /* + * This object may be extended in future versions of the + * NSS Cryptoki Framework. To allow for some flexibility + * in the area of binary compatibility, this field should + * be NULL. + */ + void *null; +}; + +/* + * NSSCKMDFindObjects + * + * This is the basic handle for an object search. It is + * created by NSSCKMDSession->FindObjectsInit, and may be + * obtained from the Framework's corresponding object. + * It contains a pointer for use by the Module, to store + * any search-related data, and it contains the EPV for a + * set of routines which the Module may implement for use + * by the Framework. Some of these routines are optional. + */ + +struct NSSCKMDFindObjectsStr { + /* + * The Module may use this pointer for its own purposes. + */ + void *etc; + + /* + * This routine is called by the Framework to finish a + * search operation. Note that the Framework may finish + * a search before it has completed. This routine is + * optional; if unimplemented, it merely won't be called. + */ + void(PR_CALLBACK *Final)( + NSSCKMDFindObjects *mdFindObjects, + NSSCKFWFindObjects *fwFindObjects, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine is used to obtain another pointer to an + * object matching the search criteria. This routine is + * required. If no (more) objects match the search, it + * should return NULL and set the error to CKR_OK. + */ + NSSCKMDObject *(PR_CALLBACK *Next)( + NSSCKMDFindObjects *mdFindObjects, + NSSCKFWFindObjects *fwFindObjects, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSArena *arena, + CK_RV *pError); + + /* + * This object may be extended in future versions of the + * NSS Cryptoki Framework. To allow for some flexibility + * in the area of binary compatibility, this field should + * be NULL. + */ + void *null; +}; + +/* + * NSSCKMDCryptoOperaion + * + * This is the basic handle for an encryption, decryption, + * sign, verify, or hash opertion. + * created by NSSCKMDMechanism->XXXXInit, and may be + * obtained from the Framework's corresponding object. + * It contains a pointer for use by the Module, to store + * any intermediate data, and it contains the EPV for a + * set of routines which the Module may implement for use + * by the Framework. Some of these routines are optional. + */ + +struct NSSCKMDCryptoOperationStr { + /* + * The Module may use this pointer for its own purposes. + */ + void *etc; + + /* + * This routine is called by the Framework clean up the mdCryptoOperation + * structure. + * This routine is optional; if unimplemented, it will be ignored. + */ + void(PR_CALLBACK *Destroy)( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * how many bytes do we need to finish this buffer? + * must be implemented if Final is implemented. + */ + CK_ULONG(PR_CALLBACK *GetFinalLength) + ( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * how many bytes do we need to complete the next operation. + * used in both Update and UpdateFinal. + */ + CK_ULONG(PR_CALLBACK *GetOperationLength) + ( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + const NSSItem *inputBuffer, + CK_RV *pError); + + /* + * This routine is called by the Framework to finish a + * search operation. Note that the Framework may finish + * a search before it has completed. This routine is + * optional; if unimplemented, it merely won't be called. + * The respective final call with fail with CKR_FUNCTION_FAILED + * Final should not free the mdCryptoOperation. + */ + CK_RV(PR_CALLBACK *Final) + ( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSItem *outputBuffer); + + /* + * This routine is called by the Framework to complete the + * next step in an encryption/decryption operation. + * This routine is optional; if unimplemented, the respective + * update call with fail with CKR_FUNCTION_FAILED. + * Update should not be implemented for signing/verification/digest + * mechanisms. + */ + CK_RV(PR_CALLBACK *Update) + ( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + const NSSItem *inputBuffer, + NSSItem *outputBuffer); + + /* + * This routine is called by the Framework to complete the + * next step in a signing/verification/digest operation. + * This routine is optional; if unimplemented, the respective + * update call with fail with CKR_FUNCTION_FAILED + * Update should not be implemented for encryption/decryption + * mechanisms. + */ + CK_RV(PR_CALLBACK *DigestUpdate) + ( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + const NSSItem *inputBuffer); + + /* + * This routine is called by the Framework to complete a + * single step operation. This routine is optional; if unimplemented, + * the framework will use the Update and Final functions to complete + * the operation. + */ + CK_RV(PR_CALLBACK *UpdateFinal) + ( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + const NSSItem *inputBuffer, + NSSItem *outputBuffer); + + /* + * This routine is called by the Framework to complete next + * step in a combined operation. The Decrypt/Encrypt mechanism + * should define and drive the combo step. + * This routine is optional; if unimplemented, + * the framework will use the appropriate Update functions to complete + * the operation. + */ + CK_RV(PR_CALLBACK *UpdateCombo) + ( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDCryptoOperation *mdPeerCryptoOperation, + NSSCKFWCryptoOperation *fwPeerCryptoOperation, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + const NSSItem *inputBuffer, + NSSItem *outputBuffer); + + /* + * Hash a key directly into the digest + */ + CK_RV(PR_CALLBACK *DigestKey) + ( + NSSCKMDCryptoOperation *mdCryptoOperation, + NSSCKFWCryptoOperation *fwCryptoOperation, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdKey, + NSSCKFWObject *fwKey); + + /* + * This object may be extended in future versions of the + * NSS Cryptoki Framework. To allow for some flexibility + * in the area of binary compatibility, this field should + * be NULL. + */ + void *null; +}; + +/* + * NSSCKMDMechanism + * + */ + +struct NSSCKMDMechanismStr { + /* + * The Module may use this pointer for its own purposes. + */ + void *etc; + + /* + * This also frees the fwMechanism if appropriate. + * If it is not supplied, the Framework will assume that the Token + * Manages a static list of mechanisms and the function will not be called. + */ + void(PR_CALLBACK *Destroy)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the minimum key size allowed for + * this mechanism. This routine is optional; if unimplemented, + * zero will be assumed. This routine may return zero on + * error; if the error is CKR_OK, zero will be accepted as + * a valid response. + */ + CK_ULONG(PR_CALLBACK *GetMinKeySize) + ( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine returns the maximum key size allowed for + * this mechanism. This routine is optional; if unimplemented, + * zero will be assumed. This routine may return zero on + * error; if the error is CKR_OK, zero will be accepted as + * a valid response. + */ + CK_ULONG(PR_CALLBACK *GetMaxKeySize) + ( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine is called to determine if the mechanism is + * implemented in hardware or software. It returns CK_TRUE + * if it is done in hardware. + */ + CK_BBOOL(PR_CALLBACK *GetInHardware) + ( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * The crypto routines themselves. Most crypto operations may + * be performed in two ways, streaming and single-part. The + * streaming operations involve the use of (typically) three + * calls-- an Init method to set up the operation, an Update + * method to feed data to the operation, and a Final method to + * obtain the final result. Single-part operations involve + * one method, to perform the crypto operation all at once. + * + * The NSS Cryptoki Framework can implement the single-part + * operations in terms of the streaming operations on behalf + * of the Module. There are a few variances. + * + * Only the Init Functions are defined by the mechanism. Each + * init function will return a NSSCKFWCryptoOperation which + * can supply update, final, the single part updateFinal, and + * the combo updateCombo functions. + * + * For simplicity, the routines are listed in summary here: + * + * EncryptInit, + * DecryptInit, + * DigestInit, + * SignInit, + * SignRecoverInit; + * VerifyInit, + * VerifyRecoverInit; + * + * The key-management routines are + * + * GenerateKey + * GenerateKeyPair + * WrapKey + * UnwrapKey + * DeriveKey + * + * All of these routines based on the Cryptoki API; + * see PKCS#11 for further information. + */ + + /* + */ + NSSCKMDCryptoOperation *(PR_CALLBACK *EncryptInit)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdKey, + NSSCKFWObject *fwKey, + CK_RV *pError); + + /* + */ + NSSCKMDCryptoOperation *(PR_CALLBACK *DecryptInit)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdKey, + NSSCKFWObject *fwKey, + CK_RV *pError); + + /* + */ + NSSCKMDCryptoOperation *(PR_CALLBACK *DigestInit)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + */ + NSSCKMDCryptoOperation *(PR_CALLBACK *SignInit)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdKey, + NSSCKFWObject *fwKey, + CK_RV *pError); + + /* + */ + NSSCKMDCryptoOperation *(PR_CALLBACK *VerifyInit)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdKey, + NSSCKFWObject *fwKey, + CK_RV *pError); + + /* + */ + NSSCKMDCryptoOperation *(PR_CALLBACK *SignRecoverInit)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdKey, + NSSCKFWObject *fwKey, + CK_RV *pError); + + /* + */ + NSSCKMDCryptoOperation *(PR_CALLBACK *VerifyRecoverInit)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdKey, + NSSCKFWObject *fwKey, + CK_RV *pError); + + /* + * Key management operations. + */ + + /* + * This routine generates a key. This routine may return NULL + * upon error. + */ + NSSCKMDObject *(PR_CALLBACK *GenerateKey)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_RV *pError); + + /* + * This routine generates a key pair. + */ + CK_RV(PR_CALLBACK *GenerateKeyPair) + ( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_ATTRIBUTE_PTR pPublicKeyTemplate, + CK_ULONG ulPublicKeyAttributeCount, + CK_ATTRIBUTE_PTR pPrivateKeyTemplate, + CK_ULONG ulPrivateKeyAttributeCount, + NSSCKMDObject **pPublicKey, + NSSCKMDObject **pPrivateKey); + + /* + * This routine wraps a key. + */ + CK_ULONG(PR_CALLBACK *GetWrapKeyLength) + ( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdWrappingKey, + NSSCKFWObject *fwWrappingKey, + NSSCKMDObject *mdWrappedKey, + NSSCKFWObject *fwWrappedKey, + CK_RV *pError); + + /* + * This routine wraps a key. + */ + CK_RV(PR_CALLBACK *WrapKey) + ( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdWrappingKey, + NSSCKFWObject *fwWrappingKey, + NSSCKMDObject *mdKeyObject, + NSSCKFWObject *fwKeyObject, + NSSItem *wrappedKey); + + /* + * This routine unwraps a key. This routine may return NULL + * upon error. + */ + NSSCKMDObject *(PR_CALLBACK *UnwrapKey)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdWrappingKey, + NSSCKFWObject *fwWrappingKey, + NSSItem *wrappedKey, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_RV *pError); + + /* + * This routine derives a key. This routine may return NULL + * upon error. + */ + NSSCKMDObject *(PR_CALLBACK *DeriveKey)( + NSSCKMDMechanism *mdMechanism, + NSSCKFWMechanism *fwMechanism, + CK_MECHANISM_PTR pMechanism, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + NSSCKMDObject *mdBaseKey, + NSSCKFWObject *fwBaseKey, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_RV *pError); + + /* + * This object may be extended in future versions of the + * NSS Cryptoki Framework. To allow for some flexibility + * in the area of binary compatibility, this field should + * be NULL. + */ + void *null; +}; + +/* + * NSSCKMDObject + * + * This is the basic handle for any object used by a PKCS#11 Module. + * Modules must implement it if they support their own objects, and + * the Framework supports it for Modules that do not handle session + * objects. This type contains a pointer for use by the implementor, + * to store any object-specific data, and it contains an EPV for a + * set of routines used to access the object. + */ + +struct NSSCKMDObjectStr { + /* + * The implementation my use this pointer for its own purposes. + */ + void *etc; + + /* + * This routine is called by the Framework when it is letting + * go of an object handle. It can be used by the Module to + * free any resources tied up by an object "in use." It is + * optional. + */ + void(PR_CALLBACK *Finalize)( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine is used to completely destroy an object. + * It is optional. The parameter fwObject might be NULL + * if the framework runs out of memory at the wrong moment. + */ + CK_RV(PR_CALLBACK *Destroy) + ( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This helper routine is used by the Framework, and is especially + * useful when it is managing session objects on behalf of the + * Module. This routine is optional; if unimplemented, the + * Framework will actually look up the CKA_TOKEN attribute. In the + * event of an error, just make something up-- the Framework will + * find out soon enough anyway. + */ + CK_BBOOL(PR_CALLBACK *IsTokenObject) + ( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance); + + /* + * This routine returns the number of attributes of which this + * object consists. It is mandatory. It can return zero on + * error. + */ + CK_ULONG(PR_CALLBACK *GetAttributeCount) + ( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This routine stuffs the attribute types into the provided array. + * The array size (as obtained from GetAttributeCount) is passed in + * as a check; return CKR_BUFFER_TOO_SMALL if the count is wrong + * (either too big or too small). + */ + CK_RV(PR_CALLBACK *GetAttributeTypes) + ( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_ATTRIBUTE_TYPE_PTR typeArray, + CK_ULONG ulCount); + + /* + * This routine returns the size (in bytes) of the specified + * attribute. It can return zero on error. + */ + CK_ULONG(PR_CALLBACK *GetAttributeSize) + ( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_ATTRIBUTE_TYPE attribute, + CK_RV *pError); + + /* + * This routine returns an NSSCKFWItem structure. + * The item pointer points to an NSSItem containing the attribute value. + * The needsFreeing bit tells the framework whether to call the + * FreeAttribute function . Upon error, an NSSCKFWItem structure + * with a NULL NSSItem item pointer will be returned + */ + NSSCKFWItem(PR_CALLBACK *GetAttribute)( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_ATTRIBUTE_TYPE attribute, + CK_RV *pError); + + /* + * This routine returns CKR_OK if the attribute could be freed. + */ + CK_RV(PR_CALLBACK *FreeAttribute) + ( + NSSCKFWItem *item); + + /* + * This routine changes the specified attribute. If unimplemented, + * the object will be considered read-only. + */ + CK_RV(PR_CALLBACK *SetAttribute) + ( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_ATTRIBUTE_TYPE attribute, + NSSItem *value); + + /* + * This routine returns the storage requirements of this object, + * in bytes. Cryptoki doesn't strictly define the definition, + * but it should relate to the values returned by the "Get Memory" + * routines of the NSSCKMDToken. This routine is optional; if + * unimplemented, the Framework will consider this information + * sensitive. This routine may return zero on error. If the + * specified error is CKR_OK, zero will be accepted as a valid + * response. + */ + CK_ULONG(PR_CALLBACK *GetObjectSize) + ( + NSSCKMDObject *mdObject, + NSSCKFWObject *fwObject, + NSSCKMDSession *mdSession, + NSSCKFWSession *fwSession, + NSSCKMDToken *mdToken, + NSSCKFWToken *fwToken, + NSSCKMDInstance *mdInstance, + NSSCKFWInstance *fwInstance, + CK_RV *pError); + + /* + * This object may be extended in future versions of the + * NSS Cryptoki Framework. To allow for some flexibility + * in the area of binary compatibility, this field should + * be NULL. + */ + void *null; +}; + +#endif /* NSSCKMDT_H */ diff --git a/illumos-x86_64/usr/include/mps/nssckt.h b/illumos-x86_64/usr/include/mps/nssckt.h new file mode 100644 index 00000000..b50a88f7 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssckt.h @@ -0,0 +1,12 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _NSSCKT_H_ +#define _NSSCKT_H_ 1 + +#include "pkcs11t.h" + +typedef CK_ATTRIBUTE_TYPE CK_PTR CK_ATTRIBUTE_TYPE_PTR; +#define CK_ENTRY + +#endif /* _NSSCKT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/nsshash.h b/illumos-x86_64/usr/include/mps/nsshash.h new file mode 100644 index 00000000..393e1343 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nsshash.h @@ -0,0 +1,20 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _NSSHASH_H_ +#define _NSSHASH_H_ + +#include "hasht.h" +#include "utilrename.h" + +SEC_BEGIN_PROTOS + +extern HASH_HashType HASH_GetHashTypeByOidTag(SECOidTag hashOid); +extern SECOidTag HASH_GetHashOidTagByHashType(HASH_HashType type); +extern SECOidTag HASH_GetHashOidTagByHMACOidTag(SECOidTag hmacOid); +extern SECOidTag HASH_GetHMACOidTagByHashOidTag(SECOidTag hashOid); + +SEC_END_PROTOS + +#endif /* _NSSHASHT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/nssilckt.h b/illumos-x86_64/usr/include/mps/nssilckt.h new file mode 100644 index 00000000..417f96f6 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssilckt.h @@ -0,0 +1,191 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** nssilock.h - Instrumented locking functions for NSS +** +** Description: +** nssilock provides instrumentation for locks and monitors in +** the NSS libraries. The instrumentation, when enabled, causes +** each call to the instrumented function to record data about +** the call to an external file. The external file +** subsequently used to extract performance data and other +** statistical information about the operation of locks used in +** the nss library. +** +** To enable compilation with instrumentation, build NSS with +** the compile time switch NEED_NSS_ILOCK defined. +** +** say: "gmake OS_CFLAGS+=-DNEED_NSS_ILOCK" at make time. +** +** At runtime, to enable recording from nssilock, one or more +** environment variables must be set. For each nssILockType to +** be recorded, an environment variable of the form NSS_ILOCK_x +** must be set to 1. For example: +** +** set NSS_ILOCK_Cert=1 +** +** nssilock uses PRLOG is used to record to trace data. The +** PRLogModule name associated with nssilock data is: "nssilock". +** To enable recording of nssilock data you will need to set the +** environment variable NSPR_LOG_MODULES to enable +** recording for the nssilock log module. Similarly, you will +** need to set the environment variable NSPR_LOG_FILE to specify +** the filename to receive the recorded data. See prlog.h for usage. +** Example: +** +** export NSPR_LOG_MODULES=nssilock:6 +** export NSPR_LOG_FILE=xxxLogfile +** +** Operation: +** nssilock wraps calls to NSPR's PZLock and PZMonitor functions +** with similarly named functions: PZ_NewLock(), etc. When NSS is +** built with lock instrumentation enabled, the PZ* functions are +** compiled into NSS; when lock instrumentation is disabled, +** calls to PZ* functions are directly mapped to PR* functions +** and the instrumentation arguments to the PZ* functions are +** compiled away. +** +** +** File Format: +** The format of the external file is implementation +** dependent. Where NSPR's PR_LOG() function is used, the file +** contains data defined for PR_LOG() plus the data written by +** the wrapped function. On some platforms and under some +** circumstances, platform dependent logging or +** instrumentation probes may be used. In any case, the +** relevant data provided by the lock instrumentation is: +** +** lockType, func, address, duration, line, file [heldTime] +** +** where: +** +** lockType: a character representation of nssILockType for the +** call. e.g. ... "cert" +** +** func: the function doing the tracing. e.g. "NewLock" +** +** address: address of the instrumented lock or monitor +** +** duration: is how long was spent in the instrumented function, +** in PRIntervalTime "ticks". +** +** line: the line number within the calling function +** +** file: the file from which the call was made +** +** heldTime: how long the lock/monitor was held. field +** present only for PZ_Unlock() and PZ_ExitMonitor(). +** +** Design Notes: +** The design for lock instrumentation was influenced by the +** need to gather performance data on NSS 3.x. It is intended +** that the effort to modify NSS to use lock instrumentation +** be minimized. Existing calls to locking functions need only +** have their names changed to the instrumentation function +** names. +** +** Private NSS Interface: +** nssilock.h defines a private interface for use by NSS. +** nssilock.h is experimental in nature and is subject to +** change or revocation without notice. ... Don't mess with +** it. +** +*/ + +/* + * $Id: + */ + +#ifndef _NSSILCKT_H_ +#define _NSSILCKT_H_ + +#include "utilrename.h" +#include "prtypes.h" +#include "prmon.h" +#include "prlock.h" +#include "prcvar.h" + +typedef enum { + nssILockArena = 0, + nssILockSession = 1, + nssILockObject = 2, + nssILockRefLock = 3, + nssILockCert = 4, + nssILockCertDB = 5, + nssILockDBM = 6, + nssILockCache = 7, + nssILockSSL = 8, + nssILockList = 9, + nssILockSlot = 10, + nssILockFreelist = 11, + nssILockOID = 12, + nssILockAttribute = 13, + nssILockPK11cxt = 14, /* pk11context */ + nssILockRWLock = 15, + nssILockOther = 16, + nssILockSelfServ = 17, + nssILockKeyDB = 18, + nssILockLast /* don't use this one! */ +} nssILockType; + +/* +** conditionally compile in nssilock features +*/ +#if defined(NEED_NSS_ILOCK) + +/* +** Declare operation type enumerator +** enumerations identify the function being performed +*/ +typedef enum { + FlushTT = 0, + NewLock = 1, + Lock = 2, + Unlock = 3, + DestroyLock = 4, + NewCondVar = 5, + WaitCondVar = 6, + NotifyCondVar = 7, + NotifyAllCondVar = 8, + DestroyCondVar = 9, + NewMonitor = 10, + EnterMonitor = 11, + ExitMonitor = 12, + Notify = 13, + NotifyAll = 14, + Wait = 15, + DestroyMonitor = 16 +} nssILockOp; + +/* +** Declare the trace record +*/ +struct pzTrace_s { + PRUint32 threadID; /* PR_GetThreadID() */ + nssILockOp op; /* operation being performed */ + nssILockType ltype; /* lock type identifier */ + PRIntervalTime callTime; /* time spent in function */ + PRIntervalTime heldTime; /* lock held time, or -1 */ + void *lock; /* address of lock structure */ + PRIntn line; /* line number */ + char file[24]; /* filename */ +}; + +/* +** declare opaque types. See: nssilock.c +*/ +typedef struct pzlock_s PZLock; +typedef struct pzcondvar_s PZCondVar; +typedef struct pzmonitor_s PZMonitor; + +#else /* NEED_NSS_ILOCK */ + +#define PZLock PRLock +#define PZCondVar PRCondVar +#define PZMonitor PRMonitor + +#endif /* NEED_NSS_ILOCK */ + +#endif /* _NSSILCKT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/nssilock.h b/illumos-x86_64/usr/include/mps/nssilock.h new file mode 100644 index 00000000..01f666a7 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssilock.h @@ -0,0 +1,267 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** nssilock.h - Instrumented locking functions for NSS +** +** Description: +** nssilock provides instrumentation for locks and monitors in +** the NSS libraries. The instrumentation, when enabled, causes +** each call to the instrumented function to record data about +** the call to an external file. The external file +** subsequently used to extract performance data and other +** statistical information about the operation of locks used in +** the nss library. +** +** To enable compilation with instrumentation, build NSS with +** the compile time switch NEED_NSS_ILOCK defined. +** +** say: "gmake OS_CFLAGS+=-DNEED_NSS_ILOCK" at make time. +** +** At runtime, to enable recording from nssilock, one or more +** environment variables must be set. For each nssILockType to +** be recorded, an environment variable of the form NSS_ILOCK_x +** must be set to 1. For example: +** +** set NSS_ILOCK_Cert=1 +** +** nssilock uses PRLOG is used to record to trace data. The +** PRLogModule name associated with nssilock data is: "nssilock". +** To enable recording of nssilock data you will need to set the +** environment variable NSPR_LOG_MODULES to enable +** recording for the nssilock log module. Similarly, you will +** need to set the environment variable NSPR_LOG_FILE to specify +** the filename to receive the recorded data. See prlog.h for usage. +** Example: +** +** export NSPR_LOG_MODULES=nssilock:6 +** export NSPR_LOG_FILE=xxxLogfile +** +** Operation: +** nssilock wraps calls to NSPR's PZLock and PZMonitor functions +** with similarly named functions: PZ_NewLock(), etc. When NSS is +** built with lock instrumentation enabled, the PZ* functions are +** compiled into NSS; when lock instrumentation is disabled, +** calls to PZ* functions are directly mapped to PR* functions +** and the instrumentation arguments to the PZ* functions are +** compiled away. +** +** +** File Format: +** The format of the external file is implementation +** dependent. Where NSPR's PR_LOG() function is used, the file +** contains data defined for PR_LOG() plus the data written by +** the wrapped function. On some platforms and under some +** circumstances, platform dependent logging or +** instrumentation probes may be used. In any case, the +** relevant data provided by the lock instrumentation is: +** +** lockType, func, address, duration, line, file [heldTime] +** +** where: +** +** lockType: a character representation of nssILockType for the +** call. e.g. ... "cert" +** +** func: the function doing the tracing. e.g. "NewLock" +** +** address: address of the instrumented lock or monitor +** +** duration: is how long was spent in the instrumented function, +** in PRIntervalTime "ticks". +** +** line: the line number within the calling function +** +** file: the file from which the call was made +** +** heldTime: how long the lock/monitor was held. field +** present only for PZ_Unlock() and PZ_ExitMonitor(). +** +** Design Notes: +** The design for lock instrumentation was influenced by the +** need to gather performance data on NSS 3.x. It is intended +** that the effort to modify NSS to use lock instrumentation +** be minimized. Existing calls to locking functions need only +** have their names changed to the instrumentation function +** names. +** +** Private NSS Interface: +** nssilock.h defines a private interface for use by NSS. +** nssilock.h is experimental in nature and is subject to +** change or revocation without notice. ... Don't mess with +** it. +** +*/ + +/* + * $Id: + */ + +#ifndef _NSSILOCK_H_ +#define _NSSILOCK_H_ + +#include "utilrename.h" +#include "prtypes.h" +#include "prmon.h" +#include "prlock.h" +#include "prcvar.h" + +#include "nssilckt.h" + +PR_BEGIN_EXTERN_C + +#if defined(NEED_NSS_ILOCK) + +#define PZ_NewLock(t) pz_NewLock((t), __FILE__, __LINE__) +extern PZLock * +pz_NewLock( + nssILockType ltype, + char *file, + PRIntn line); + +#define PZ_Lock(k) pz_Lock((k), __FILE__, __LINE__) +extern void +pz_Lock( + PZLock *lock, + char *file, + PRIntn line); + +#define PZ_Unlock(k) pz_Unlock((k), __FILE__, __LINE__) +extern PRStatus +pz_Unlock( + PZLock *lock, + char *file, + PRIntn line); + +#define PZ_DestroyLock(k) pz_DestroyLock((k), __FILE__, __LINE__) +extern void +pz_DestroyLock( + PZLock *lock, + char *file, + PRIntn line); + +#define PZ_NewCondVar(l) pz_NewCondVar((l), __FILE__, __LINE__) +extern PZCondVar * +pz_NewCondVar( + PZLock *lock, + char *file, + PRIntn line); + +#define PZ_DestroyCondVar(v) pz_DestroyCondVar((v), __FILE__, __LINE__) +extern void +pz_DestroyCondVar( + PZCondVar *cvar, + char *file, + PRIntn line); + +#define PZ_WaitCondVar(v, t) pz_WaitCondVar((v), (t), __FILE__, __LINE__) +extern PRStatus +pz_WaitCondVar( + PZCondVar *cvar, + PRIntervalTime timeout, + char *file, + PRIntn line); + +#define PZ_NotifyCondVar(v) pz_NotifyCondVar((v), __FILE__, __LINE__) +extern PRStatus +pz_NotifyCondVar( + PZCondVar *cvar, + char *file, + PRIntn line); + +#define PZ_NotifyAllCondVar(v) pz_NotifyAllCondVar((v), __FILE__, __LINE__) +extern PRStatus +pz_NotifyAllCondVar( + PZCondVar *cvar, + char *file, + PRIntn line); + +#define PZ_NewMonitor(t) pz_NewMonitor((t), __FILE__, __LINE__) +extern PZMonitor * +pz_NewMonitor( + nssILockType ltype, + char *file, + PRIntn line); + +#define PZ_DestroyMonitor(m) pz_DestroyMonitor((m), __FILE__, __LINE__) +extern void +pz_DestroyMonitor( + PZMonitor *mon, + char *file, + PRIntn line); + +#define PZ_EnterMonitor(m) pz_EnterMonitor((m), __FILE__, __LINE__) +extern void +pz_EnterMonitor( + PZMonitor *mon, + char *file, + PRIntn line); + +#define PZ_ExitMonitor(m) pz_ExitMonitor((m), __FILE__, __LINE__) +extern PRStatus +pz_ExitMonitor( + PZMonitor *mon, + char *file, + PRIntn line); + +#define PZ_InMonitor(m) (PZ_GetMonitorEntryCount(m) > 0) +#define PZ_GetMonitorEntryCount(m) pz_GetMonitorEntryCount((m), __FILE__, __LINE__) +extern PRIntn +pz_GetMonitorEntryCount( + PZMonitor *mon, + char *file, + PRIntn line); + +#define PZ_Wait(m, i) pz_Wait((m), ((i)), __FILE__, __LINE__) +extern PRStatus +pz_Wait( + PZMonitor *mon, + PRIntervalTime ticks, + char *file, + PRIntn line); + +#define PZ_Notify(m) pz_Notify((m), __FILE__, __LINE__) +extern PRStatus +pz_Notify( + PZMonitor *mon, + char *file, + PRIntn line); + +#define PZ_NotifyAll(m) pz_NotifyAll((m), __FILE__, __LINE__) +extern PRStatus +pz_NotifyAll( + PZMonitor *mon, + char *file, + PRIntn line); + +#define PZ_TraceFlush() pz_TraceFlush() +extern void pz_TraceFlush(void); + +#else /* NEED_NSS_ILOCK */ + +#define PZ_NewLock(t) PR_NewLock() +#define PZ_DestroyLock(k) PR_DestroyLock((k)) +#define PZ_Lock(k) PR_Lock((k)) +#define PZ_Unlock(k) PR_Unlock((k)) + +#define PZ_NewCondVar(l) PR_NewCondVar((l)) +#define PZ_DestroyCondVar(v) PR_DestroyCondVar((v)) +#define PZ_WaitCondVar(v, t) PR_WaitCondVar((v), (t)) +#define PZ_NotifyCondVar(v) PR_NotifyCondVar((v)) +#define PZ_NotifyAllCondVar(v) PR_NotifyAllCondVar((v)) + +#define PZ_NewMonitor(t) PR_NewMonitor() +#define PZ_DestroyMonitor(m) PR_DestroyMonitor((m)) +#define PZ_EnterMonitor(m) PR_EnterMonitor((m)) +#define PZ_ExitMonitor(m) PR_ExitMonitor((m)) +#define PZ_InMonitor(m) PR_InMonitor((m)) +#define PZ_Wait(m, t) PR_Wait(((m)), ((t))) +#define PZ_Notify(m) PR_Notify((m)) +#define PZ_NotifyAll(m) PR_Notify((m)) +#define PZ_TraceFlush() /* nothing */ + +#endif /* NEED_NSS_ILOCK */ + +PR_END_EXTERN_C +#endif /* _NSSILOCK_H_ */ diff --git a/illumos-x86_64/usr/include/mps/nsslocks.h b/illumos-x86_64/usr/include/mps/nsslocks.h new file mode 100644 index 00000000..6098f56a --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nsslocks.h @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * nsslocks.h - threadsafe functions to initialize lock pointers. + * + * NOTE - The interfaces formerly in this header were private and are now all + * obsolete. + */ diff --git a/illumos-x86_64/usr/include/mps/nssrwlk.h b/illumos-x86_64/usr/include/mps/nssrwlk.h new file mode 100644 index 00000000..8e1fa6fb --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssrwlk.h @@ -0,0 +1,133 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: nsrwlock.h +** Description: API to basic reader-writer lock functions of NSS. +** These locks allow re-entry from writers but not readers. That is, +** If I hold the write lock, I can ask for it and get it again. +** If I hold the write lock, I can also ask for and get a read lock. +** I can then release the locks in any order (read or write). +** If I hold a read lock, I must not ask for another read lock or +** the write lock. +** I must release each lock type as many times as I acquired it. +** +** For deadlock detection, locks should be ranked, and no lock may be aquired +** while I hold a lock of higher rank number. +** If you don't want that feature, always use NSS_RWLOCK_RANK_NONE. +** Lock name is for debugging, and is optional (may be NULL) +**/ + +#ifndef nssrwlk_h___ +#define nssrwlk_h___ + +#include "utilrename.h" +#include "prtypes.h" +#include "nssrwlkt.h" + +#define NSS_RWLOCK_RANK_NONE 0 + +/* SEC_BEGIN_PROTOS */ +PR_BEGIN_EXTERN_C + +/*********************************************************************** +** FUNCTION: NSSRWLock_New +** DESCRIPTION: +** Returns a pointer to a newly created reader-writer lock object. +** INPUTS: Lock rank +** Lock name +** OUTPUTS: void +** RETURN: NSSRWLock* +** If the lock cannot be created because of resource constraints, NULL +** is returned. +** +***********************************************************************/ +extern NSSRWLock *NSSRWLock_New(PRUint32 lock_rank, const char *lock_name); + +/*********************************************************************** +** FUNCTION: NSSRWLock_AtomicCreate +** DESCRIPTION: +** Given the address of a NULL pointer to a NSSRWLock, +** atomically initializes that pointer to a newly created NSSRWLock. +** Returns the value placed into that pointer, or NULL. +** +** INPUTS: address of NSRWLock pointer +** Lock rank +** Lock name +** OUTPUTS: NSSRWLock* +** RETURN: NSSRWLock* +** If the lock cannot be created because of resource constraints, +** the pointer will be left NULL. +** +***********************************************************************/ +extern NSSRWLock * +nssRWLock_AtomicCreate(NSSRWLock **prwlock, + PRUint32 lock_rank, + const char *lock_name); + +/*********************************************************************** +** FUNCTION: NSSRWLock_Destroy +** DESCRIPTION: +** Destroys a given RW lock object. +** INPUTS: NSSRWLock *lock - Lock to be freed. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +extern void NSSRWLock_Destroy(NSSRWLock *lock); + +/*********************************************************************** +** FUNCTION: NSSRWLock_LockRead +** DESCRIPTION: +** Apply a read lock (non-exclusive) on a RWLock +** INPUTS: NSSRWLock *lock - Lock to be read-locked. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +extern void NSSRWLock_LockRead(NSSRWLock *lock); + +/*********************************************************************** +** FUNCTION: NSSRWLock_LockWrite +** DESCRIPTION: +** Apply a write lock (exclusive) on a RWLock +** INPUTS: NSSRWLock *lock - Lock to write-locked. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +extern void NSSRWLock_LockWrite(NSSRWLock *lock); + +/*********************************************************************** +** FUNCTION: NSSRWLock_UnlockRead +** DESCRIPTION: +** Release a Read lock. Unlocking an unlocked lock has undefined results. +** INPUTS: NSSRWLock *lock - Lock to unlocked. +** OUTPUTS: void +** RETURN: void +***********************************************************************/ +extern void NSSRWLock_UnlockRead(NSSRWLock *lock); + +/*********************************************************************** +** FUNCTION: NSSRWLock_UnlockWrite +** DESCRIPTION: +** Release a Write lock. Unlocking an unlocked lock has undefined results. +** INPUTS: NSSRWLock *lock - Lock to unlocked. +** OUTPUTS: void +** RETURN: void +***********************************************************************/ +extern void NSSRWLock_UnlockWrite(NSSRWLock *lock); + +/*********************************************************************** +** FUNCTION: NSSRWLock_HaveWriteLock +** DESCRIPTION: +** Tells caller whether the current thread holds the write lock, or not. +** INPUTS: NSSRWLock *lock - Lock to test. +** OUTPUTS: void +** RETURN: PRBool PR_TRUE IFF the current thread holds the write lock. +***********************************************************************/ + +extern PRBool NSSRWLock_HaveWriteLock(NSSRWLock *rwlock); + +/* SEC_END_PROTOS */ +PR_END_EXTERN_C + +#endif /* nsrwlock_h___ */ diff --git a/illumos-x86_64/usr/include/mps/nssrwlkt.h b/illumos-x86_64/usr/include/mps/nssrwlkt.h new file mode 100644 index 00000000..50a4112e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssrwlkt.h @@ -0,0 +1,19 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nssrwlkt_h___ +#define nssrwlkt_h___ + +#include "utilrename.h" +#include "nssilock.h" +/* + * NSSRWLock -- + * + * The reader writer lock, NSSRWLock, is an opaque object to the clients + * of NSS. All routines operate on a pointer to this opaque entity. + */ + +typedef struct nssRWLockStr NSSRWLock; + +#endif /* nsrwlock_h___ */ diff --git a/illumos-x86_64/usr/include/mps/nssutil.h b/illumos-x86_64/usr/include/mps/nssutil.h new file mode 100644 index 00000000..9643fe92 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/nssutil.h @@ -0,0 +1,41 @@ +/* + * NSS utility functions + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __nssutil_h_ +#define __nssutil_h_ + +#ifndef RC_INVOKED +#include "seccomon.h" +#endif + +/* + * NSS utilities's major version, minor version, patch level, build number, + * and whether this is a beta release. + * + * The format of the version string should be + * ".[.[.]][ ]" + */ +#define NSSUTIL_VERSION "3.116" +#define NSSUTIL_VMAJOR 3 +#define NSSUTIL_VMINOR 116 +#define NSSUTIL_VPATCH 0 +#define NSSUTIL_VBUILD 0 +#define NSSUTIL_BETA PR_FALSE + +SEC_BEGIN_PROTOS + +/* + * Returns a const string of the UTIL library version. + */ +extern const char *NSSUTIL_GetVersion(void); + +extern SECStatus +NSS_InitializePRErrorTable(void); + +SEC_END_PROTOS + +#endif /* __nssutil_h_ */ diff --git a/illumos-x86_64/usr/include/mps/obsolete/pralarm.h b/illumos-x86_64/usr/include/mps/obsolete/pralarm.h new file mode 100644 index 00000000..9ae3a4bc --- /dev/null +++ b/illumos-x86_64/usr/include/mps/obsolete/pralarm.h @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: pralarm.h +** Description: API to periodic alarms. +** +** +** Alarms are defined to invoke some client specified function at +** a time in the future. The notification may be a one time event +** or repeated at a fixed interval. The interval at which the next +** notification takes place may be modified by the client code only +** during the respective notification. +** +** The notification is delivered on a thread that is part of the +** alarm context (PRAlarm). The thread will inherit the priority +** of the Alarm creator. +** +** Any number of periodic alarms (PRAlarmID) may be created within +** the context of a single alarm (PRAlarm). The notifications will be +** scheduled as close to the desired time as possible. +** +** Repeating periodic notifies are expected to run at a fixed rate. +** That rate is expressed as some number of notifies per period where +** the period is much larger than a PRIntervalTime (see prinrval.h). +*/ + +#if !defined(pralarm_h) +#define pralarm_h + +#include "prtypes.h" +#include "prinrval.h" + + +PR_BEGIN_EXTERN_C + +/**********************************************************************/ +/************************* TYPES AND CONSTANTS ************************/ +/**********************************************************************/ + +typedef struct PRAlarm PRAlarm; +typedef struct PRAlarmID PRAlarmID; + +typedef PRBool (PR_CALLBACK *PRPeriodicAlarmFn)( + PRAlarmID *id, void *clientData, PRUint32 late); + +/**********************************************************************/ +/****************************** FUNCTIONS *****************************/ +/**********************************************************************/ + +/*********************************************************************** +** FUNCTION: PR_CreateAlarm +** DESCRIPTION: +** Create an alarm context. +** INPUTS: void +** OUTPUTS: None +** RETURN: PRAlarm* +** +** SIDE EFFECTS: +** This creates an alarm context, which is an object used for subsequent +** notification creations. It also creates a thread that will be used to +** deliver the notifications that are expected to be defined. The client +** is resposible for destroying the context when appropriate. +** RESTRICTIONS: +** None. +** MEMORY: The object (PRAlarm) and a thread to support notifications. +** ALGORITHM: N/A +***********************************************************************/ +NSPR_API(PRAlarm*) PR_CreateAlarm(void); + +/*********************************************************************** +** FUNCTION: PR_DestroyAlarm +** DESCRIPTION: +** Destroys the context created by PR_CreateAlarm(). +** INPUTS: PRAlarm* +** OUTPUTS: None +** RETURN: PRStatus +** +** SIDE EFFECTS: +** This destroys the context that was created by PR_CreateAlarm(). +** If there are any active alarms (PRAlarmID), they will be cancelled. +** Once that is done, the thread that was used to deliver the alarms +** will be joined. +** RESTRICTIONS: +** None. +** MEMORY: N/A +** ALGORITHM: N/A +***********************************************************************/ +NSPR_API(PRStatus) PR_DestroyAlarm(PRAlarm *alarm); + +/*********************************************************************** +** FUNCTION: PR_SetAlarm +** DESCRIPTION: +** Creates a periodic notifier that is to be delivered to a specified +** function at some fixed interval. +** INPUTS: PRAlarm *alarm Parent alarm context +** PRIntervalTime period Interval over which the notifies +** are delivered. +** PRUint32 rate The rate within the interval that +** the notifies will be delivered. +** PRPeriodicAlarmFn function Entry point where the notifies +** will be delivered. +** OUTPUTS: None +** RETURN: PRAlarmID* Handle to the notifier just created +** or NULL if the request failed. +** +** SIDE EFFECTS: +** A periodic notifier is created. The notifications will be delivered +** by the alarm's internal thread at a fixed interval whose rate is the +** number of interrupts per interval specified. The first notification +** will be delivered as soon as possible, and they will continue until +** the notifier routine indicates that they should cease of the alarm +** context is destroyed (PR_DestroyAlarm). +** RESTRICTIONS: +** None. +** MEMORY: Memory for the notifier object. +** ALGORITHM: The rate at which notifications are delivered are stated +** to be "'rate' notifies per 'interval'". The exact time of +** the notification is computed based on a epoch established +** when the notifier was set. Each notification is delivered +** not ealier than the epoch plus the fixed rate times the +** notification sequence number. Such notifications have the +** potential to be late by not more than 'interval'/'rate'. +** The amount of lateness of one notification is taken into +** account on the next in an attempt to avoid long term slew. +***********************************************************************/ +NSPR_API(PRAlarmID*) PR_SetAlarm( + PRAlarm *alarm, PRIntervalTime period, PRUint32 rate, + PRPeriodicAlarmFn function, void *clientData); + +/*********************************************************************** +** FUNCTION: PR_ResetAlarm +** DESCRIPTION: +** Resets an existing alarm. +** INPUTS: PRAlarmID *id Identify of the notifier. +** PRIntervalTime period Interval over which the notifies +** are delivered. +** PRUint32 rate The rate within the interval that +** the notifies will be delivered. +** OUTPUTS: None +** RETURN: PRStatus Indication of completion. +** +** SIDE EFFECTS: +** An existing alarm may have its period and rate redefined. The +** additional side effect is that the notifier's epoch is recomputed. +** The first notification delivered by the newly refreshed alarm is +** defined to be 'interval'/'rate' from the time of the reset. +** RESTRICTIONS: +** This function may only be called in the notifier for that alarm. +** MEMORY: N/A. +** ALGORITHM: See PR_SetAlarm(). +***********************************************************************/ +NSPR_API(PRStatus) PR_ResetAlarm( + PRAlarmID *id, PRIntervalTime period, PRUint32 rate); + +PR_END_EXTERN_C + +#endif /* !defined(pralarm_h) */ + +/* prinrval.h */ diff --git a/illumos-x86_64/usr/include/mps/obsolete/probslet.h b/illumos-x86_64/usr/include/mps/obsolete/probslet.h new file mode 100644 index 00000000..db743c5e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/obsolete/probslet.h @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** A collection of things thought to be obsolete +*/ + +#if defined(PROBSLET_H) +#else +#define PROBSLET_H + +#include "prio.h" +#include "private/pprio.h" /* for PROsfd */ + +PR_BEGIN_EXTERN_C + +/* +** Yield the current thread. The proper function to use in place of +** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT. +*/ +NSPR_API(PRStatus) PR_Yield(void); + +/************************************************************************/ +/************* The following definitions are for select *****************/ +/************************************************************************/ + +/* +** The following is obsolete and will be deleted in the next release! +** These are provided for compatibility, but are GUARANTEED to be slow. +** +** Override PR_MAX_SELECT_DESC if you need more space in the select set. +*/ +#ifndef PR_MAX_SELECT_DESC +#define PR_MAX_SELECT_DESC 1024 +#endif +typedef struct PR_fd_set { + PRUint32 hsize; + PRFileDesc *harray[PR_MAX_SELECT_DESC]; + PRUint32 nsize; + PROsfd narray[PR_MAX_SELECT_DESC]; +} PR_fd_set; + +/* +************************************************************************* +** FUNCTION: PR_Select +** DESCRIPTION: +** +** The call returns as soon as I/O is ready on one or more of the underlying +** file/socket descriptors or an exceptional condition is pending. A count of the +** number of ready descriptors is returned unless a timeout occurs in which case +** zero is returned. On return, PR_Select replaces the given descriptor sets with +** subsets consisting of those descriptors that are ready for the requested condition. +** The total number of ready descriptors in all the sets is the return value. +** +** INPUTS: +** PRInt32 num +** This argument is unused but is provided for select(unix) interface +** compatability. All input PR_fd_set arguments are self-describing +** with its own maximum number of elements in the set. +** +** PR_fd_set *readfds +** A set describing the io descriptors for which ready for reading +** condition is of interest. +** +** PR_fd_set *writefds +** A set describing the io descriptors for which ready for writing +** condition is of interest. +** +** PR_fd_set *exceptfds +** A set describing the io descriptors for which exception pending +** condition is of interest. +** +** Any of the above readfds, writefds or exceptfds may be given as NULL +** pointers if no descriptors are of interest for that particular condition. +** +** PRIntervalTime timeout +** Amount of time the call will block waiting for I/O to become ready. +** If this time expires without any I/O becoming ready, the result will +** be zero. +** +** OUTPUTS: +** PR_fd_set *readfds +** A set describing the io descriptors which are ready for reading. +** +** PR_fd_set *writefds +** A set describing the io descriptors which are ready for writing. +** +** PR_fd_set *exceptfds +** A set describing the io descriptors which have pending exception. +** +** RETURN:PRInt32 +** Number of io descriptors with asked for conditions or zero if the function +** timed out or -1 on failure. The reason for the failure is obtained by +** calling PR_GetError(). +** XXX can we implement this on windoze and mac? +************************************************************************** +*/ +NSPR_API(PRInt32) PR_Select( + PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds, + PR_fd_set *exceptfds, PRIntervalTime timeout); + +/* +** The following are not thread safe for two threads operating on them at the +** same time. +** +** The following routines are provided for manipulating io descriptor sets. +** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set. +** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset. +** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset. +** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of +** fdset, zero otherwise. +** +** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd +** in fdset. +** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset. +** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of +** fdset, zero otherwise. +*/ + +NSPR_API(void) PR_FD_ZERO(PR_fd_set *set); +NSPR_API(void) PR_FD_SET(PRFileDesc *fd, PR_fd_set *set); +NSPR_API(void) PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set); +NSPR_API(PRInt32) PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set); +NSPR_API(void) PR_FD_NSET(PROsfd osfd, PR_fd_set *set); +NSPR_API(void) PR_FD_NCLR(PROsfd osfd, PR_fd_set *set); +NSPR_API(PRInt32) PR_FD_NISSET(PROsfd osfd, PR_fd_set *set); + +/* +** The next two entry points should not be in the API, but they are +** declared here for historical reasons. +*/ + +NSPR_API(PRInt32) PR_GetSysfdTableMax(void); + +NSPR_API(PRInt32) PR_SetSysfdTableSize(PRIntn table_size); + +#ifndef NO_NSPR_10_SUPPORT +#include + +NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf); +#endif /* NO_NSPR_10_SUPPORT */ + +PR_END_EXTERN_C + +#endif /* defined(PROBSLET_H) */ + +/* probslet.h */ diff --git a/illumos-x86_64/usr/include/mps/obsolete/protypes.h b/illumos-x86_64/usr/include/mps/obsolete/protypes.h new file mode 100644 index 00000000..4ebf9b47 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/obsolete/protypes.h @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * This header typedefs the old 'native' types to the new PRs. + * These definitions are scheduled to be eliminated at the earliest + * possible time. The NSPR API is implemented and documented using + * the new definitions. + */ + +#if !defined(PROTYPES_H) +#define PROTYPES_H + +typedef PRUintn uintn; +#ifndef _XP_Core_ +typedef PRIntn intn; +#endif + +/* + * It is trickier to define uint, int8, uint8, int16, uint16, + * int32, uint32, int64, and uint64 because some of these int + * types are defined by standard header files on some platforms. + * Our strategy here is to include all such standard headers + * first, and then define these int types only if they are not + * defined by those standard headers. + */ + +/* + * SVR4 typedef of uint is commonly found on UNIX machines. + * + * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h) + * defines the types int8, int16, int32, and int64. + * + * On OS/2, sys/types.h defines uint. + */ +#if defined(XP_UNIX) +#include +#endif + +/* model.h on HP-UX defines int8, int16, and int32. */ +#ifdef HPUX +#include +#endif + +/* + * uint + */ + +#if !defined(XP_UNIX) || defined(NTO) +typedef PRUintn uint; +#endif + +/* + * uint64 + */ + +typedef PRUint64 uint64; + +/* + * uint32 + */ + +#if !defined(_WIN32) && !defined(NTO) +typedef PRUint32 uint32; +#else +typedef unsigned long uint32; +#endif + +/* + * uint16 + */ + +typedef PRUint16 uint16; + +/* + * uint8 + */ + +typedef PRUint8 uint8; + +/* + * int64 + */ + +#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) +typedef PRInt64 int64; +#endif + +/* + * int32 + */ + +#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) +#if !defined(_WIN32) && !defined(NTO) +typedef PRInt32 int32; +#else +typedef long int32; +#endif +#endif + +/* + * int16 + */ + +#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) +typedef PRInt16 int16; +#endif + +/* + * int8 + */ + +#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) +typedef PRInt8 int8; +#endif + +typedef PRFloat64 float64; +typedef PRUptrdiff uptrdiff_t; +typedef PRUword uprword_t; +typedef PRWord prword_t; + + +/* Re: prbit.h */ +#define TEST_BIT PR_TEST_BIT +#define SET_BIT PR_SET_BIT +#define CLEAR_BIT PR_CLEAR_BIT + +/* Re: prarena.h->plarena.h */ +#define PRArena PLArena +#define PRArenaPool PLArenaPool +#define PRArenaStats PLArenaStats +#define PR_ARENA_ALIGN PL_ARENA_ALIGN +#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL +#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE +#define PR_ARENA_GROW PL_ARENA_GROW +#define PR_ARENA_MARK PL_ARENA_MARK +#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED +#define PR_CLEAR_ARENA PL_CLEAR_ARENA +#define PR_ARENA_RELEASE PL_ARENA_RELEASE +#define PR_COUNT_ARENA PL_COUNT_ARENA +#define PR_ARENA_DESTROY PL_ARENA_DESTROY +#define PR_InitArenaPool PL_InitArenaPool +#define PR_FreeArenaPool PL_FreeArenaPool +#define PR_FinishArenaPool PL_FinishArenaPool +#define PR_CompactArenaPool PL_CompactArenaPool +#define PR_ArenaFinish PL_ArenaFinish +#define PR_ArenaAllocate PL_ArenaAllocate +#define PR_ArenaGrow PL_ArenaGrow +#define PR_ArenaRelease PL_ArenaRelease +#define PR_ArenaCountAllocation PL_ArenaCountAllocation +#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth +#define PR_ArenaCountGrowth PL_ArenaCountGrowth +#define PR_ArenaCountRelease PL_ArenaCountRelease +#define PR_ArenaCountRetract PL_ArenaCountRetract + +/* Re: prhash.h->plhash.h */ +#define PRHashEntry PLHashEntry +#define PRHashTable PLHashTable +#define PRHashNumber PLHashNumber +#define PRHashFunction PLHashFunction +#define PRHashComparator PLHashComparator +#define PRHashEnumerator PLHashEnumerator +#define PRHashAllocOps PLHashAllocOps +#define PR_NewHashTable PL_NewHashTable +#define PR_HashTableDestroy PL_HashTableDestroy +#define PR_HashTableRawLookup PL_HashTableRawLookup +#define PR_HashTableRawAdd PL_HashTableRawAdd +#define PR_HashTableRawRemove PL_HashTableRawRemove +#define PR_HashTableAdd PL_HashTableAdd +#define PR_HashTableRemove PL_HashTableRemove +#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries +#define PR_HashTableLookup PL_HashTableLookup +#define PR_HashTableDump PL_HashTableDump +#define PR_HashString PL_HashString +#define PR_CompareStrings PL_CompareStrings +#define PR_CompareValues PL_CompareValues + +#endif /* !defined(PROTYPES_H) */ diff --git a/illumos-x86_64/usr/include/mps/obsolete/prsem.h b/illumos-x86_64/usr/include/mps/obsolete/prsem.h new file mode 100644 index 00000000..d1981d2b --- /dev/null +++ b/illumos-x86_64/usr/include/mps/obsolete/prsem.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prsem_h___ +#define prsem_h___ + +/* +** API for counting semaphores. Semaphores are counting synchronizing +** variables based on a lock and a condition variable. They are lightweight +** contention control for a given count of resources. +*/ +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +typedef struct PRSemaphore PRSemaphore; + +/* +** Create a new semaphore object. +*/ +NSPR_API(PRSemaphore*) PR_NewSem(PRUintn value); + +/* +** Destroy the given semaphore object. +** +*/ +NSPR_API(void) PR_DestroySem(PRSemaphore *sem); + +/* +** Wait on a Semaphore. +** +** This routine allows a calling thread to wait or proceed depending upon the +** state of the semahore sem. The thread can proceed only if the counter value +** of the semaphore sem is currently greater than 0. If the value of semaphore +** sem is positive, it is decremented by one and the routine returns immediately +** allowing the calling thread to continue. If the value of semaphore sem is 0, +** the calling thread blocks awaiting the semaphore to be released by another +** thread. +** +** This routine can return PR_PENDING_INTERRUPT if the waiting thread +** has been interrupted. +*/ +NSPR_API(PRStatus) PR_WaitSem(PRSemaphore *sem); + +/* +** This routine increments the counter value of the semaphore. If other threads +** are blocked for the semaphore, then the scheduler will determine which ONE +** thread will be unblocked. +*/ +NSPR_API(void) PR_PostSem(PRSemaphore *sem); + +/* +** Returns the value of the semaphore referenced by sem without affecting +** the state of the semaphore. The value represents the semaphore vaule +F** at the time of the call, but may not be the actual value when the +** caller inspects it. +*/ +NSPR_API(PRUintn) PR_GetValueSem(PRSemaphore *sem); + +PR_END_EXTERN_C + +#endif /* prsem_h___ */ diff --git a/illumos-x86_64/usr/include/mps/ocsp.h b/illumos-x86_64/usr/include/mps/ocsp.h new file mode 100644 index 00000000..1b94aec2 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/ocsp.h @@ -0,0 +1,723 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Interface to the OCSP implementation. + */ + +#ifndef _OCSP_H_ +#define _OCSP_H_ + +#include "plarena.h" +#include "seccomon.h" +#include "secoidt.h" +#include "keythi.h" +#include "certt.h" +#include "ocspt.h" + +/************************************************************************/ +SEC_BEGIN_PROTOS + +/* + * This function registers the HttpClient with whose functions the + * HttpClientFcn structure has been populated as the default Http + * client. + * + * The function table must be a global object. + * The caller must ensure that NSS will be able to call + * the registered functions for the lifetime of the process. + */ +extern SECStatus +SEC_RegisterDefaultHttpClient(const SEC_HttpClientFcn *fcnTable); + +/* + * This function obtains the HttpClient which has been registered + * by an earlier call to SEC_RegisterDefaultHttpClient. + */ +extern const SEC_HttpClientFcn * +SEC_GetRegisteredHttpClient(void); + +/* + * Sets parameters that control NSS' internal OCSP cache. + * maxCacheEntries, special varlues are: + * -1 disable cache + * 0 unlimited cache entries + * minimumSecondsToNextFetchAttempt: + * whenever an OCSP request was attempted or completed over the network, + * wait at least this number of seconds before trying to fetch again. + * maximumSecondsToNextFetchAttempt: + * this is the maximum age of a cached response we allow, until we try + * to fetch an updated response, even if the OCSP responder expects + * that newer information update will not be available yet. + */ +extern SECStatus +CERT_OCSPCacheSettings(PRInt32 maxCacheEntries, + PRUint32 minimumSecondsToNextFetchAttempt, + PRUint32 maximumSecondsToNextFetchAttempt); + +/* + * Set the desired behaviour on OCSP failures. + * See definition of ocspFailureMode for allowed choices. + */ +extern SECStatus +CERT_SetOCSPFailureMode(SEC_OcspFailureMode ocspFailureMode); + +/* + * Configure the maximum time NSS will wait for an OCSP response. + */ +extern SECStatus +CERT_SetOCSPTimeout(PRUint32 seconds); + +/* + * Removes all items currently stored in the OCSP cache. + */ +extern SECStatus +CERT_ClearOCSPCache(void); + +/* + * FUNCTION: CERT_EnableOCSPChecking + * Turns on OCSP checking for the given certificate database. + * INPUTS: + * CERTCertDBHandle *handle + * Certificate database for which OCSP checking will be enabled. + * RETURN: + * Returns SECFailure if an error occurred (likely only problem + * allocating memory); SECSuccess otherwise. + */ +extern SECStatus +CERT_EnableOCSPChecking(CERTCertDBHandle *handle); + +/* + * FUNCTION: CERT_DisableOCSPChecking + * Turns off OCSP checking for the given certificate database. + * This routine disables OCSP checking. Though it will return + * SECFailure if OCSP checking is not enabled, it is "safe" to + * call it that way and just ignore the return value, if it is + * easier to just call it than to "remember" whether it is enabled. + * INPUTS: + * CERTCertDBHandle *handle + * Certificate database for which OCSP checking will be disabled. + * RETURN: + * Returns SECFailure if an error occurred (usually means that OCSP + * checking was not enabled or status contexts were not initialized -- + * error set will be SEC_ERROR_OCSP_NOT_ENABLED); SECSuccess otherwise. + */ +extern SECStatus +CERT_DisableOCSPChecking(CERTCertDBHandle *handle); + +/* + * FUNCTION: CERT_SetOCSPDefaultResponder + * Specify the location and cert of the default responder. + * If OCSP checking is already enabled *and* use of a default responder + * is also already enabled, all OCSP checking from now on will go directly + * to the specified responder. If OCSP checking is not enabled, or if + * it is but use of a default responder is not enabled, the information + * will be recorded and take effect whenever both are enabled. + * INPUTS: + * CERTCertDBHandle *handle + * Cert database on which OCSP checking should use the default responder. + * const char *url + * The location of the default responder (e.g. "http://foo.com:80/ocsp") + * Note that the location will not be tested until the first attempt + * to send a request there. + * const char *name + * The nickname of the cert to trust (expected) to sign the OCSP responses. + * If the corresponding cert cannot be found, SECFailure is returned. + * RETURN: + * Returns SECFailure if an error occurred; SECSuccess otherwise. + * The most likely error is that the cert for "name" could not be found + * (probably SEC_ERROR_UNKNOWN_CERT). Other errors are low-level (no memory, + * bad database, etc.). + */ +extern SECStatus +CERT_SetOCSPDefaultResponder(CERTCertDBHandle *handle, + const char *url, const char *name); + +/* + * FUNCTION: CERT_EnableOCSPDefaultResponder + * Turns on use of a default responder when OCSP checking. + * If OCSP checking is already enabled, this will make subsequent checks + * go directly to the default responder. (The location of the responder + * and the nickname of the responder cert must already be specified.) + * If OCSP checking is not enabled, this will be recorded and take effect + * whenever it is enabled. + * INPUTS: + * CERTCertDBHandle *handle + * Cert database on which OCSP checking should use the default responder. + * RETURN: + * Returns SECFailure if an error occurred; SECSuccess otherwise. + * No errors are especially likely unless the caller did not previously + * perform a successful call to SetOCSPDefaultResponder (in which case + * the error set will be SEC_ERROR_OCSP_NO_DEFAULT_RESPONDER). + */ +extern SECStatus +CERT_EnableOCSPDefaultResponder(CERTCertDBHandle *handle); + +/* + * FUNCTION: CERT_DisableOCSPDefaultResponder + * Turns off use of a default responder when OCSP checking. + * (Does nothing if use of a default responder is not enabled.) + * INPUTS: + * CERTCertDBHandle *handle + * Cert database on which OCSP checking should stop using a default + * responder. + * RETURN: + * Returns SECFailure if an error occurred; SECSuccess otherwise. + * Errors very unlikely (like random memory corruption...). + */ +extern SECStatus +CERT_DisableOCSPDefaultResponder(CERTCertDBHandle *handle); + +/* If forcePost is set, OCSP requests will only be sent using the HTTP POST + * method. When forcePost is not set, OCSP requests will be sent using the + * HTTP GET method, with a fallback to POST when we fail to receive a response + * and/or when we receive an uncacheable response like "Unknown." + * + * The default is to use GET and fallback to POST. + */ +extern SECStatus CERT_ForcePostMethodForOCSP(PRBool forcePost); + +/* + * ------------------------------------------------------- + * The Functions above are those expected to be used by a client + * providing OCSP status checking along with every cert verification. + * The functions below are for OCSP testing, debugging, or clients + * or servers performing more specialized OCSP tasks. + * ------------------------------------------------------- + */ + +/* + * FUNCTION: CERT_CreateOCSPRequest + * Creates a CERTOCSPRequest, requesting the status of the certs in + * the given list. + * INPUTS: + * CERTCertList *certList + * A list of certs for which status will be requested. + * Note that all of these certificates should have the same issuer, + * or it's expected the response will be signed by a trusted responder. + * If the certs need to be broken up into multiple requests, that + * must be handled by the caller (and thus by having multiple calls + * to this routine), who knows about where the request(s) are being + * sent and whether there are any trusted responders in place. + * PRTime time + * Indicates the time for which the certificate status is to be + * determined -- this may be used in the search for the cert's issuer + * but has no effect on the request itself. + * PRBool addServiceLocator + * If true, the Service Locator extension should be added to the + * single request(s) for each cert. + * CERTCertificate *signerCert + * If non-NULL, means sign the request using this cert. Otherwise, + * do not sign. + * XXX note that request signing is not yet supported; see comment in code + * RETURN: + * A pointer to a CERTOCSPRequest structure containing an OCSP request + * for the cert list. On error, null is returned, with an error set + * indicating the reason. This is likely SEC_ERROR_UNKNOWN_ISSUER. + * (The issuer is needed to create a request for the certificate.) + * Other errors are low-level problems (no memory, bad database, etc.). + */ +extern CERTOCSPRequest * +CERT_CreateOCSPRequest(CERTCertList *certList, PRTime time, + PRBool addServiceLocator, + CERTCertificate *signerCert); + +/* + * FUNCTION: CERT_AddOCSPAcceptableResponses + * Add the AcceptableResponses extension to an OCSP Request. + * INPUTS: + * CERTOCSPRequest *request + * The request to which the extension should be added. + * SECOidTag responseType0, ... + * A list (of one or more) of SECOidTag -- each of the response types + * to be added. The last OID *must* be SEC_OID_PKIX_OCSP_BASIC_RESPONSE. + * (This marks the end of the list, and it must be specified because a + * client conforming to the OCSP standard is required to handle the basic + * response type.) The OIDs are not checked in any way. + * RETURN: + * SECSuccess if the extension is added; SECFailure if anything goes wrong. + * All errors are internal or low-level problems (e.g. no memory). + */ +extern SECStatus +CERT_AddOCSPAcceptableResponses(CERTOCSPRequest *request, + SECOidTag responseType0, ...); + +/* + * FUNCTION: CERT_EncodeOCSPRequest + * DER encodes an OCSP Request, possibly adding a signature as well. + * XXX Signing is not yet supported, however; see comments in code. + * INPUTS: + * PLArenaPool *arena + * The return value is allocated from here. + * If a NULL is passed in, allocation is done from the heap instead. + * CERTOCSPRequest *request + * The request to be encoded. + * void *pwArg + * Pointer to argument for password prompting, if needed. (Definitely + * not needed if not signing.) + * RETURN: + * Returns a NULL on error and a pointer to the SECItem with the + * encoded value otherwise. Any error is likely to be low-level + * (e.g. no memory). + */ +extern SECItem * +CERT_EncodeOCSPRequest(PLArenaPool *arena, CERTOCSPRequest *request, + void *pwArg); + +/* + * FUNCTION: CERT_DecodeOCSPRequest + * Decode a DER encoded OCSP Request. + * INPUTS: + * SECItem *src + * Pointer to a SECItem holding DER encoded OCSP Request. + * RETURN: + * Returns a pointer to a CERTOCSPRequest containing the decoded request. + * On error, returns NULL. Most likely error is trouble decoding + * (SEC_ERROR_OCSP_MALFORMED_REQUEST), or low-level problem (no memory). + */ +extern CERTOCSPRequest * +CERT_DecodeOCSPRequest(const SECItem *src); + +/* + * FUNCTION: CERT_DestroyOCSPRequest + * Frees an OCSP Request structure. + * INPUTS: + * CERTOCSPRequest *request + * Pointer to CERTOCSPRequest to be freed. + * RETURN: + * No return value; no errors. + */ +extern void +CERT_DestroyOCSPRequest(CERTOCSPRequest *request); + +/* + * FUNCTION: CERT_DecodeOCSPResponse + * Decode a DER encoded OCSP Response. + * INPUTS: + * SECItem *src + * Pointer to a SECItem holding DER encoded OCSP Response. + * RETURN: + * Returns a pointer to a CERTOCSPResponse (the decoded OCSP Response); + * the caller is responsible for destroying it. Or NULL if error (either + * response could not be decoded (SEC_ERROR_OCSP_MALFORMED_RESPONSE), + * it was of an unexpected type (SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE), + * or a low-level or internal error occurred). + */ +extern CERTOCSPResponse * +CERT_DecodeOCSPResponse(const SECItem *src); + +/* + * FUNCTION: CERT_DestroyOCSPResponse + * Frees an OCSP Response structure. + * INPUTS: + * CERTOCSPResponse *request + * Pointer to CERTOCSPResponse to be freed. + * RETURN: + * No return value; no errors. + */ +extern void +CERT_DestroyOCSPResponse(CERTOCSPResponse *response); + +/* + * FUNCTION: CERT_GetEncodedOCSPResponse + * Creates and sends a request to an OCSP responder, then reads and + * returns the (encoded) response. + * INPUTS: + * PLArenaPool *arena + * Pointer to arena from which return value will be allocated. + * If NULL, result will be allocated from the heap (and thus should + * be freed via SECITEM_FreeItem). + * CERTCertList *certList + * A list of certs for which status will be requested. + * Note that all of these certificates should have the same issuer, + * or it's expected the response will be signed by a trusted responder. + * If the certs need to be broken up into multiple requests, that + * must be handled by the caller (and thus by having multiple calls + * to this routine), who knows about where the request(s) are being + * sent and whether there are any trusted responders in place. + * const char *location + * The location of the OCSP responder (a URL). + * PRTime time + * Indicates the time for which the certificate status is to be + * determined -- this may be used in the search for the cert's issuer + * but has no other bearing on the operation. + * PRBool addServiceLocator + * If true, the Service Locator extension should be added to the + * single request(s) for each cert. + * CERTCertificate *signerCert + * If non-NULL, means sign the request using this cert. Otherwise, + * do not sign. + * void *pwArg + * Pointer to argument for password prompting, if needed. (Definitely + * not needed if not signing.) + * OUTPUTS: + * CERTOCSPRequest **pRequest + * Pointer in which to store the OCSP request created for the given + * list of certificates. It is only filled in if the entire operation + * is successful and the pointer is not null -- and in that case the + * caller is then reponsible for destroying it. + * RETURN: + * Returns a pointer to the SECItem holding the response. + * On error, returns null with error set describing the reason: + * SEC_ERROR_UNKNOWN_ISSUER + * SEC_ERROR_CERT_BAD_ACCESS_LOCATION + * SEC_ERROR_OCSP_BAD_HTTP_RESPONSE + * Other errors are low-level problems (no memory, bad database, etc.). + */ +extern SECItem * +CERT_GetEncodedOCSPResponse(PLArenaPool *arena, CERTCertList *certList, + const char *location, PRTime time, + PRBool addServiceLocator, + CERTCertificate *signerCert, void *pwArg, + CERTOCSPRequest **pRequest); + +/* + * FUNCTION: CERT_VerifyOCSPResponseSignature + * Check the signature on an OCSP Response. Will also perform a + * verification of the signer's certificate. Note, however, that a + * successful verification does not make any statement about the + * signer's *authority* to provide status for the certificate(s), + * that must be checked individually for each certificate. + * INPUTS: + * CERTOCSPResponse *response + * Pointer to response structure with signature to be checked. + * CERTCertDBHandle *handle + * Pointer to CERTCertDBHandle for certificate DB to use for verification. + * void *pwArg + * Pointer to argument for password prompting, if needed. + * CERTCertificate *issuerCert + * Issuer of the certificate that generated the OCSP request. + * OUTPUTS: + * CERTCertificate **pSignerCert + * Pointer in which to store signer's certificate; only filled-in if + * non-null. + * RETURN: + * Returns SECSuccess when signature is valid, anything else means invalid. + * Possible errors set: + * SEC_ERROR_OCSP_MALFORMED_RESPONSE - unknown type of ResponderID + * SEC_ERROR_INVALID_TIME - bad format of "ProducedAt" time + * SEC_ERROR_UNKNOWN_SIGNER - signer's cert could not be found + * SEC_ERROR_BAD_SIGNATURE - the signature did not verify + * Other errors are any of the many possible failures in cert verification + * (e.g. SEC_ERROR_REVOKED_CERTIFICATE, SEC_ERROR_UNTRUSTED_ISSUER) when + * verifying the signer's cert, or low-level problems (no memory, etc.) + */ +extern SECStatus +CERT_VerifyOCSPResponseSignature(CERTOCSPResponse *response, + CERTCertDBHandle *handle, void *pwArg, + CERTCertificate **pSignerCert, + CERTCertificate *issuerCert); + +/* + * FUNCTION: CERT_GetOCSPAuthorityInfoAccessLocation + * Get the value of the URI of the OCSP responder for the given cert. + * This is found in the (optional) Authority Information Access extension + * in the cert. + * INPUTS: + * CERTCertificate *cert + * The certificate being examined. + * RETURN: + * char * + * A copy of the URI for the OCSP method, if found. If either the + * extension is not present or it does not contain an entry for OCSP, + * SEC_ERROR_EXTENSION_NOT_FOUND will be set and a NULL returned. + * Any other error will also result in a NULL being returned. + * + * This result should be freed (via PORT_Free) when no longer in use. + */ +extern char * +CERT_GetOCSPAuthorityInfoAccessLocation(const CERTCertificate *cert); + +/* + * FUNCTION: CERT_RegisterAlternateOCSPAIAInfoCallBack + * This function serves two purposes. + * 1) It registers the address of a callback function that will be + * called for certs that have no OCSP AIA extension, to see if the + * callback wishes to supply an alternative URL for such an OCSP inquiry. + * 2) It outputs the previously registered function's address to the + * address supplied by the caller, unless that is NULL. + * The registered callback function returns NULL, or an allocated string + * that may be subsequently freed by calling PORT_Free(). + * RETURN: + * SECSuccess or SECFailure (if the library is not yet intialized) + */ +extern SECStatus +CERT_RegisterAlternateOCSPAIAInfoCallBack( + CERT_StringFromCertFcn newCallback, + CERT_StringFromCertFcn *oldCallback); + +/* + * FUNCTION: CERT_ParseURL + * Parse a URI into hostname, port, and path. The scheme in the URI must + * be "http". + * INPUTS: + * const char *url + * The URI to be parsed + * OUTPUTS: + * char **pHostname + * Pointer to store the hostname obtained from the URI. + * This result should be freed (via PORT_Free) when no longer in use. + * PRUint16 *pPort + * Pointer to store the port number obtained from the URI. + * char **pPath + * Pointer to store the path obtained from the URI. + * This result should be freed (via PORT_Free) when no longer in use. + * RETURN: + * Returns SECSuccess when parsing was successful. Returns SECFailure when + * problems were encountered. + */ +extern SECStatus +CERT_ParseURL(const char *url, char **pHostname, PRUint16 *pPort, char **pPath); + +/* + * FUNCTION: CERT_CheckOCSPStatus + * Checks the status of a certificate via OCSP. Will only check status for + * a certificate that has an AIA (Authority Information Access) extension + * for OCSP *or* when a "default responder" is specified and enabled. + * (If no AIA extension for OCSP and no default responder in place, the + * cert is considered to have a good status and SECSuccess is returned.) + * INPUTS: + * CERTCertDBHandle *handle + * certificate DB of the cert that is being checked + * CERTCertificate *cert + * the certificate being checked + * XXX in the long term also need a boolean parameter that specifies + * whether to check the cert chain, as well; for now we check only + * the leaf (the specified certificate) + * PRTime time + * time for which status is to be determined + * void *pwArg + * argument for password prompting, if needed + * RETURN: + * Returns SECSuccess if an approved OCSP responder "knows" the cert + * *and* returns a non-revoked status for it; SECFailure otherwise, + * with an error set describing the reason: + * + * SEC_ERROR_OCSP_BAD_HTTP_RESPONSE + * SEC_ERROR_OCSP_FUTURE_RESPONSE + * SEC_ERROR_OCSP_MALFORMED_REQUEST + * SEC_ERROR_OCSP_MALFORMED_RESPONSE + * SEC_ERROR_OCSP_OLD_RESPONSE + * SEC_ERROR_OCSP_REQUEST_NEEDS_SIG + * SEC_ERROR_OCSP_SERVER_ERROR + * SEC_ERROR_OCSP_TRY_SERVER_LATER + * SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST + * SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE + * SEC_ERROR_OCSP_UNKNOWN_CERT + * SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS + * SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE + * + * SEC_ERROR_BAD_SIGNATURE + * SEC_ERROR_CERT_BAD_ACCESS_LOCATION + * SEC_ERROR_INVALID_TIME + * SEC_ERROR_REVOKED_CERTIFICATE + * SEC_ERROR_UNKNOWN_ISSUER + * SEC_ERROR_UNKNOWN_SIGNER + * + * Other errors are any of the many possible failures in cert verification + * (e.g. SEC_ERROR_REVOKED_CERTIFICATE, SEC_ERROR_UNTRUSTED_ISSUER) when + * verifying the signer's cert, or low-level problems (error allocating + * memory, error performing ASN.1 decoding, etc.). + */ +extern SECStatus +CERT_CheckOCSPStatus(CERTCertDBHandle *handle, CERTCertificate *cert, + PRTime time, void *pwArg); + +/* + * FUNCTION: CERT_CacheOCSPResponseFromSideChannel + * First, this function checks the OCSP cache to see if a good response + * for the given certificate already exists. If it does, then the function + * returns successfully. + * + * If not, then it validates that the given OCSP response is a valid, + * good response for the given certificate and inserts it into the + * cache. + * + * This function is intended for use when OCSP responses are provided via a + * side-channel, i.e. TLS OCSP stapling (a.k.a. the status_request extension). + * + * INPUTS: + * CERTCertDBHandle *handle + * certificate DB of the cert that is being checked + * CERTCertificate *cert + * the certificate being checked + * PRTime time + * time for which status is to be determined + * SECItem *encodedResponse + * the DER encoded bytes of the OCSP response + * void *pwArg + * argument for password prompting, if needed + * RETURN: + * SECSuccess if the cert was found in the cache, or if the OCSP response was + * found to be valid and inserted into the cache. SECFailure otherwise. + */ +extern SECStatus +CERT_CacheOCSPResponseFromSideChannel(CERTCertDBHandle *handle, + CERTCertificate *cert, + PRTime time, + const SECItem *encodedResponse, + void *pwArg); + +/* + * FUNCTION: CERT_GetOCSPStatusForCertID + * Returns the OCSP status contained in the passed in parameter response + * that corresponds to the certID passed in. + * INPUTS: + * CERTCertDBHandle *handle + * certificate DB of the cert that is being checked + * CERTOCSPResponse *response + * the OCSP response we want to retrieve status from. + * CERTOCSPCertID *certID + * the ID we want to look for from the response. + * CERTCertificate *signerCert + * the certificate that was used to sign the OCSP response. + * must be obtained via a call to CERT_VerifyOCSPResponseSignature. + * PRTime time + * The time at which we're checking the status for. + * RETURN: + * Return values are the same as those for CERT_CheckOCSPStatus + */ +extern SECStatus +CERT_GetOCSPStatusForCertID(CERTCertDBHandle *handle, + CERTOCSPResponse *response, + CERTOCSPCertID *certID, + CERTCertificate *signerCert, + PRTime time); + +/* + * FUNCTION CERT_GetOCSPResponseStatus + * Returns the response status for the response passed. + * INPUTS: + * CERTOCSPResponse *response + * The response to query for status + * RETURN: + * Returns SECSuccess if the response has a successful status value. + * Otherwise it returns SECFailure and sets one of the following error + * codes via PORT_SetError + * SEC_ERROR_OCSP_MALFORMED_REQUEST + * SEC_ERROR_OCSP_SERVER_ERROR + * SEC_ERROR_OCSP_TRY_SERVER_LATER + * SEC_ERROR_OCSP_REQUEST_NEEDS_SIG + * SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST + * SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS + */ +extern SECStatus +CERT_GetOCSPResponseStatus(CERTOCSPResponse *response); + +/* + * FUNCTION CERT_CreateOCSPCertID + * Returns the OCSP certID for the certificate passed in. + * INPUTS: + * CERTCertificate *cert + * The certificate for which to create the certID for. + * PRTime time + * The time at which the id is requested for. This is used + * to determine the appropriate issuer for the cert since + * the issuing CA may be an older expired certificate. + * RETURN: + * A new copy of a CERTOCSPCertID*. The memory for this certID + * should be freed by calling CERT_DestroyOCSPCertID when the + * certID is no longer necessary. + */ +extern CERTOCSPCertID * +CERT_CreateOCSPCertID(CERTCertificate *cert, PRTime time); + +/* + * FUNCTION: CERT_DestroyOCSPCertID + * Frees the memory associated with the certID passed in. + * INPUTS: + * CERTOCSPCertID* certID + * The certID that the caller no longer needs and wants to + * free the associated memory. + * RETURN: + * SECSuccess if freeing the memory was successful. Returns + * SECFailure if the memory passed in was not allocated with + * a call to CERT_CreateOCSPCertID. + */ +extern SECStatus +CERT_DestroyOCSPCertID(CERTOCSPCertID *certID); + +extern CERTOCSPSingleResponse * +CERT_CreateOCSPSingleResponseGood(PLArenaPool *arena, + CERTOCSPCertID *id, + PRTime thisUpdate, + const PRTime *nextUpdate); + +extern CERTOCSPSingleResponse * +CERT_CreateOCSPSingleResponseUnknown(PLArenaPool *arena, + CERTOCSPCertID *id, + PRTime thisUpdate, + const PRTime *nextUpdate); + +extern CERTOCSPSingleResponse * +CERT_CreateOCSPSingleResponseRevoked( + PLArenaPool *arena, + CERTOCSPCertID *id, + PRTime thisUpdate, + const PRTime *nextUpdate, + PRTime revocationTime, + const CERTCRLEntryReasonCode *revocationReason); + +extern SECItem * +CERT_CreateEncodedOCSPSuccessResponse( + PLArenaPool *arena, + CERTCertificate *responderCert, + CERTOCSPResponderIDType responderIDType, + PRTime producedAt, + CERTOCSPSingleResponse **responses, + void *wincx); + +/* + * FUNCTION: CERT_CreateEncodedOCSPErrorResponse + * Creates an encoded OCSP response with an error response status. + * INPUTS: + * PLArenaPool *arena + * The return value is allocated from here. + * If a NULL is passed in, allocation is done from the heap instead. + * int error + * An NSS error code indicating an error response status. The error + * code is mapped to an OCSP response status as follows: + * SEC_ERROR_OCSP_MALFORMED_REQUEST -> malformedRequest + * SEC_ERROR_OCSP_SERVER_ERROR -> internalError + * SEC_ERROR_OCSP_TRY_SERVER_LATER -> tryLater + * SEC_ERROR_OCSP_REQUEST_NEEDS_SIG -> sigRequired + * SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST -> unauthorized + * where the OCSP response status is an enumerated type defined in + * RFC 2560: + * OCSPResponseStatus ::= ENUMERATED { + * successful (0), --Response has valid confirmations + * malformedRequest (1), --Illegal confirmation request + * internalError (2), --Internal error in issuer + * tryLater (3), --Try again later + * --(4) is not used + * sigRequired (5), --Must sign the request + * unauthorized (6) --Request unauthorized + * } + * RETURN: + * Returns a pointer to the SECItem holding the response. + * On error, returns null with error set describing the reason: + * SEC_ERROR_INVALID_ARGS + * Other errors are low-level problems (no memory, bad database, etc.). + */ +extern SECItem * +CERT_CreateEncodedOCSPErrorResponse(PLArenaPool *arena, int error); + +/* Sends an OCSP request using the HTTP POST method to the location addressed + * by the URL in |location| parameter. The request body will be + * |encodedRequest|, which must be a valid encoded OCSP request. On success, + * the server's response is returned and the caller must free it using + * SECITEM_FreeItem. On failure, NULL is returned. No parsing or validation of + * the HTTP response is done. + * + * If a default HTTP client has been registered with + * SEC_RegisterDefaultHttpClient then that client is used. Otherwise, an + * internal HTTP client is used. + */ +SECItem *CERT_PostOCSPRequest(PLArenaPool *arena, const char *location, + const SECItem *encodedRequest); + +/************************************************************************/ +SEC_END_PROTOS + +#endif /* _OCSP_H_ */ diff --git a/illumos-x86_64/usr/include/mps/ocspt.h b/illumos-x86_64/usr/include/mps/ocspt.h new file mode 100644 index 00000000..db429ff0 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/ocspt.h @@ -0,0 +1,301 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Public header for exported OCSP types. + */ + +#ifndef _OCSPT_H_ +#define _OCSPT_H_ + +/* + * The following are all opaque types. If someone needs to get at + * a field within, then we need to fix the API. Try very hard not + * make the type available to them. + */ +typedef struct CERTOCSPRequestStr CERTOCSPRequest; +typedef struct CERTOCSPResponseStr CERTOCSPResponse; + +/* + * XXX I think only those first two above should need to be exported, + * but until I know for certain I am leaving the rest of these here, too. + */ +typedef struct CERTOCSPCertIDStr CERTOCSPCertID; +typedef struct CERTOCSPSingleResponseStr CERTOCSPSingleResponse; + +/* + * This interface is described in terms of an HttpClient which + * supports at least a specified set of functions. (An implementer may + * provide HttpClients with additional functionality accessible only to + * users with a particular implementation in mind.) The basic behavior + * is provided by defining a set of functions, listed in an + * SEC_HttpServerFcnStruct. If the implementor of a SpecificHttpClient + * registers his SpecificHttpClient as the default HttpClient, then his + * functions will be called by the user of an HttpClient, such as an + * OCSPChecker. + * + * The implementer of a specific HttpClient (e.g., the NSS-provided + * DefaultHttpClient), populates an SEC_HttpClientFcnStruct, uses it to + * register his client, and waits for his functions to be called. + * + * For future expandability, the SEC_HttpClientFcnStruct is defined as a + * union, with the version field acting as a selector. The proposed + * initial version of the structure is given following the definition + * of the union. The HttpClientState structure is implementation- + * dependent, and should be opaque to the user. + */ + +typedef void *SEC_HTTP_SERVER_SESSION; +typedef void *SEC_HTTP_REQUEST_SESSION; + +/* + * This function creates a SEC_HTTP_SERVER_SESSION object. The implementer of a + * specific HttpClient will allocate the necessary space, when this + * function is called, and will free it when the corresponding FreeFcn + * is called. The SEC_HTTP_SERVER_SESSION object is passed, as an opaque object, + * to subsequent calls. + * + * If the function returns SECSuccess, the returned SEC_HTTP_SERVER_SESSION + * must be cleaned up with a call to SEC_HttpServer_FreeSession, + * after processing is finished. + */ +typedef SECStatus (*SEC_HttpServer_CreateSessionFcn)( + const char *host, + PRUint16 portnum, + SEC_HTTP_SERVER_SESSION *pSession); + +/* + * This function is called to allow the implementation to attempt to keep + * the connection alive. Depending on the underlying platform, it might + * immediately return SECSuccess without having performed any operations. + * (If a connection has not been kept alive, a subsequent call to + * SEC_HttpRequest_TrySendAndReceiveFcn should reopen the connection + * automatically.) + * + * If the connection uses nonblocking I/O, this function may return + * SECWouldBlock and store a nonzero value at "pPollDesc". In that case + * the caller may wait on the poll descriptor, and should call this function + * again until SECSuccess (and a zero value at "pPollDesc") is obtained. + */ +typedef SECStatus (*SEC_HttpServer_KeepAliveSessionFcn)( + SEC_HTTP_SERVER_SESSION session, + PRPollDesc **pPollDesc); + +/* + * This function frees the client SEC_HTTP_SERVER_SESSION object, closes all + * SEC_HTTP_REQUEST_SESSIONs created for that server, discards all partial results, + * frees any memory that was allocated by the client, and invalidates any + * response pointers that might have been returned by prior server or request + * functions. + */ +typedef SECStatus (*SEC_HttpServer_FreeSessionFcn)( + SEC_HTTP_SERVER_SESSION session); + +/* + * This function creates a SEC_HTTP_REQUEST_SESSION object. The implementer of a + * specific HttpClient will allocate the necessary space, when this + * function is called, and will free it when the corresponding FreeFcn + * is called. The SEC_HTTP_REQUEST_SESSION object is passed, as an opaque object, + * to subsequent calls. + * + * An implementation that does not support the requested protocol variant + * (usually "http", but could eventually allow "https") or request method + * should return SECFailure. + * + * Timeout values may include the constants PR_INTERVAL_NO_TIMEOUT (wait + * forever) or PR_INTERVAL_NO_WAIT (nonblocking I/O). + * + * If the function returns SECSuccess, the returned SEC_HTTP_REQUEST_SESSION + * must be cleaned up with a call to SEC_HttpRequest_FreeSession, + * after processing is finished. + */ +typedef SECStatus (*SEC_HttpRequest_CreateFcn)( + SEC_HTTP_SERVER_SESSION session, + const char *http_protocol_variant, /* usually "http" */ + const char *path_and_query_string, + const char *http_request_method, + const PRIntervalTime timeout, + SEC_HTTP_REQUEST_SESSION *pRequest); + +/* + * This function sets data to be sent to the server for an HTTP request + * of http_request_method == POST. If a particular implementation + * supports it, the details for the POST request can be set by calling + * this function, prior to activating the request with TrySendAndReceiveFcn. + * + * An implementation that does not support the POST method should + * implement a SetPostDataFcn function that returns immediately. + * + * Setting http_content_type is optional, the parameter may + * by NULL or the empty string. + */ +typedef SECStatus (*SEC_HttpRequest_SetPostDataFcn)( + SEC_HTTP_REQUEST_SESSION request, + const char *http_data, + const PRUint32 http_data_len, + const char *http_content_type); + +/* + * This function sets an additional HTTP protocol request header. + * If a particular implementation supports it, one or multiple headers + * can be added to the request by calling this function once or multiple + * times, prior to activating the request with TryFcn. + * + * An implementation that does not support setting additional headers + * should implement an AddRequestHeaderFcn function that returns immediately. + */ +typedef SECStatus (*SEC_HttpRequest_AddHeaderFcn)( + SEC_HTTP_REQUEST_SESSION request, + const char *http_header_name, + const char *http_header_value); + +/* + * This function initiates or continues an HTTP request. After + * parameters have been set with the Create function and, optionally, + * modified or enhanced with the AddParams function, this call creates + * the socket connection and initiates the communication. + * + * If a timeout value of zero is specified, indicating non-blocking + * I/O, the client creates a non-blocking socket, and returns a status + * of SECWouldBlock and a non-NULL PRPollDesc if the operation is not + * complete. In that case all other return parameters are undefined. + * The caller is expected to repeat the call, possibly after using + * PRPoll to determine that a completion has occurred, until a return + * value of SECSuccess (and a NULL value for pPollDesc) or a return + * value of SECFailure (indicating failure on the network level) + * is obtained. + * + * http_response_data_len is both input and output parameter. + * If a pointer to a PRUint32 is supplied, the http client is + * expected to check the given integer value and always set an out + * value, even on failure. + * An input value of zero means, the caller will accept any response len. + * A different input value indicates the maximum response value acceptable + * to the caller. + * If data is successfully read and the size is acceptable to the caller, + * the function will return SECSuccess and set http_response_data_len to + * the size of the block returned in http_response_data. + * If the data read from the http server is larger than the acceptable + * size, the function will return SECFailure. + * http_response_data_len will be set to a value different from zero to + * indicate the reason of the failure. + * An out value of "0" means, the failure was unrelated to the + * acceptable size. + * An out value of "1" means, the result data is larger than the + * accpeptable size, but the real size is not yet known to the http client + * implementation and it stopped retrieving it, + * Any other out value combined with a return value of SECFailure + * will indicate the actual size of the server data. + * + * The caller is permitted to provide NULL values for any of the + * http_response arguments, indicating the caller is not interested in + * those values. If the caller does provide an address, the HttpClient + * stores at that address a pointer to the corresponding argument, at + * the completion of the operation. + * + * All returned pointers will be owned by the the HttpClient + * implementation and will remain valid until the call to + * SEC_HttpRequest_FreeFcn. + */ +typedef SECStatus (*SEC_HttpRequest_TrySendAndReceiveFcn)( + SEC_HTTP_REQUEST_SESSION request, + PRPollDesc **pPollDesc, + PRUint16 *http_response_code, + const char **http_response_content_type, + const char **http_response_headers, + const char **http_response_data, + PRUint32 *http_response_data_len); + +/* + * Calling CancelFcn asks for premature termination of the request. + * + * Future calls to SEC_HttpRequest_TrySendAndReceive should + * by avoided, but in this case the HttpClient implementation + * is expected to return immediately with SECFailure. + * + * After calling CancelFcn, a separate call to SEC_HttpRequest_FreeFcn + * is still necessary to free resources. + */ +typedef SECStatus (*SEC_HttpRequest_CancelFcn)( + SEC_HTTP_REQUEST_SESSION request); + +/* + * Before calling this function, it must be assured the request + * has been completed, i.e. either SEC_HttpRequest_TrySendAndReceiveFcn has + * returned SECSuccess, or the request has been canceled with + * a call to SEC_HttpRequest_CancelFcn. + * + * This function frees the client state object, closes all sockets, + * discards all partial results, frees any memory that was allocated + * by the client, and invalidates all response pointers that might + * have been returned by SEC_HttpRequest_TrySendAndReceiveFcn + */ +typedef SECStatus (*SEC_HttpRequest_FreeFcn)( + SEC_HTTP_REQUEST_SESSION request); + +typedef struct SEC_HttpClientFcnV1Struct { + SEC_HttpServer_CreateSessionFcn createSessionFcn; + SEC_HttpServer_KeepAliveSessionFcn keepAliveSessionFcn; + SEC_HttpServer_FreeSessionFcn freeSessionFcn; + SEC_HttpRequest_CreateFcn createFcn; + SEC_HttpRequest_SetPostDataFcn setPostDataFcn; + SEC_HttpRequest_AddHeaderFcn addHeaderFcn; + SEC_HttpRequest_TrySendAndReceiveFcn trySendAndReceiveFcn; + SEC_HttpRequest_CancelFcn cancelFcn; + SEC_HttpRequest_FreeFcn freeFcn; +} SEC_HttpClientFcnV1; + +typedef struct SEC_HttpClientFcnStruct { + PRInt16 version; + union { + SEC_HttpClientFcnV1 ftable1; + /* SEC_HttpClientFcnV2 ftable2; */ + /* ... */ + } fcnTable; +} SEC_HttpClientFcn; + +/* + * ocspMode_FailureIsVerificationFailure: + * This is the classic behaviour of NSS. + * Any OCSP failure is a verification failure (classic mode, default). + * Without a good response, OCSP networking will be retried each time + * it is required for verifying a cert. + * + * ocspMode_FailureIsNotAVerificationFailure: + * If we fail to obtain a valid OCSP response, consider the + * cert as good. + * Failed OCSP attempts might get cached and not retried until + * minimumSecondsToNextFetchAttempt. + * If we are able to obtain a valid response, the cert + * will be considered good, if either status is "good" + * or the cert was not yet revoked at verification time. + * + * Additional failure modes might be added in the future. + */ +typedef enum { + ocspMode_FailureIsVerificationFailure = 0, + ocspMode_FailureIsNotAVerificationFailure = 1 +} SEC_OcspFailureMode; + +/* + * A ResponderID identifies the responder -- or more correctly, the + * signer of the response. The ASN.1 definition of a ResponderID is: + * + * ResponderID ::= CHOICE { + * byName [1] EXPLICIT Name, + * byKey [2] EXPLICIT KeyHash } + * + * Because it is CHOICE, the type of identification used and the + * identification itself are actually encoded together. To represent + * this same information internally, we explicitly define a type and + * save it, along with the value, into a data structure. + */ + +typedef enum { + ocspResponderID_other = -1, /* unknown kind of responderID */ + ocspResponderID_byName = 1, + ocspResponderID_byKey = 2 +} CERTOCSPResponderIDType; + +#endif /* _OCSPT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/p12.h b/illumos-x86_64/usr/include/mps/p12.h new file mode 100644 index 00000000..495bbf6c --- /dev/null +++ b/illumos-x86_64/usr/include/mps/p12.h @@ -0,0 +1,236 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _P12_H_ +#define _P12_H_ + +#include "secoid.h" +#include "keyhi.h" +#include "secpkcs7.h" +#include "p12t.h" + +typedef int(PR_CALLBACK *PKCS12OpenFunction)(void *arg); +typedef int(PR_CALLBACK *PKCS12ReadFunction)(void *arg, + unsigned char *buffer, + unsigned int *lenRead, + unsigned int maxLen); +typedef int(PR_CALLBACK *PKCS12WriteFunction)(void *arg, + unsigned char *buffer, + unsigned int *bufLen, + unsigned int *lenWritten); +typedef int(PR_CALLBACK *PKCS12CloseFunction)(void *arg); +typedef SECStatus(PR_CALLBACK *PKCS12UnicodeConvertFunction)( + PLArenaPool *arena, + SECItem *dest, SECItem *src, + PRBool toUnicode, + PRBool swapBytes); +typedef void(PR_CALLBACK *SEC_PKCS12EncoderOutputCallback)( + void *arg, const char *buf, + unsigned long len); +typedef void(PR_CALLBACK *SEC_PKCS12DecoderOutputCallback)( + void *arg, const char *buf, + unsigned long len); +/* + * In NSS 3.12 or later, 'arg' actually points to a CERTCertificate, + * the 'leafCert' variable in sec_pkcs12_validate_cert in p12d.c. + * See r1.35 of p12d.c ("Patch 2" in bug 321584). + * + * This callback might be called by SEC_PKCS12DecoderValidateBags each time + * a nickname collission is detected. The callback must return a new + * nickname. The returned SECItem should be of type siAsciiString, + * it should be allocated using: + * SECITEM_AllocItem(NULL, NULL, LENGTH_OF_NEW_NICKNAME + 1) + * and data must contain the new nickname as a zero terminated string. + */ +typedef SECItem *(PR_CALLBACK *SEC_PKCS12NicknameCollisionCallback)( + SECItem *old_nickname, + PRBool *cancel, + void *arg); +/* + * This callback is called by SEC_PKCS12DecoderRenameCertNicknames for each + * certificate found in the p12 source data. + * + * cert: A decoded certificate. + * default_nickname: The nickname as found in the source data. + * Will be NULL if source data doesn't have nickname. + * new_nickname: Output parameter that may contain the renamed nickname. + * arg: The user data that was passed to SEC_PKCS12DecoderRenameCertNicknames. + * + * If the callback accept that NSS will use a nickname based on the + * default_nickname (potentially resolving conflicts), then the callback + * must set *new_nickname to NULL. + * + * If the callback wishes to override the nickname, it must set *new_nickname + * to a new SECItem which should be allocated using + * SECITEM_AllocItem(NULL, NULL, LENGTH_OF_NEW_NICKNAME + 1) + * new_nickname->type should be set to siAsciiString, and new_nickname->data + * must contain the new nickname as a zero terminated string. + * + * A return value of SECFailure indicates that the renaming operation failed, + * and callback should release new_nickname before returning if it's already + * being allocated. + * Otherwise, the callback function must return SECSuccess, including use + * default nickname as mentioned above. + */ +typedef SECStatus(PR_CALLBACK *SEC_PKCS12NicknameRenameCallback)( + const CERTCertificate *cert, + const SECItem *default_nickname, + SECItem **new_nickname, + void *arg); + +typedef SECStatus(PR_CALLBACK *digestOpenFn)(void *arg, PRBool readData); +typedef SECStatus(PR_CALLBACK *digestCloseFn)(void *arg, PRBool removeFile); +typedef int(PR_CALLBACK *digestIOFn)(void *arg, unsigned char *buf, + unsigned long len); + +typedef struct SEC_PKCS12ExportContextStr SEC_PKCS12ExportContext; +typedef struct SEC_PKCS12SafeInfoStr SEC_PKCS12SafeInfo; +typedef struct SEC_PKCS12DecoderContextStr SEC_PKCS12DecoderContext; +typedef struct SEC_PKCS12DecoderItemStr SEC_PKCS12DecoderItem; + +struct sec_PKCS12PasswordModeInfo { + SECItem *password; + SECOidTag algorithm; +}; + +struct sec_PKCS12PublicKeyModeInfo { + CERTCertificate *cert; + CERTCertDBHandle *certDb; + SECOidTag algorithm; + int keySize; +}; + +struct SEC_PKCS12DecoderItemStr { + SECItem *der; + SECOidTag type; + PRBool hasKey; + SECItem *friendlyName; /* UTF-8 string */ + SECAlgorithmID *shroudAlg; +}; + +SEC_BEGIN_PROTOS + +SEC_PKCS12SafeInfo * +SEC_PKCS12CreatePubKeyEncryptedSafe(SEC_PKCS12ExportContext *p12ctxt, + CERTCertDBHandle *certDb, + CERTCertificate *signer, + CERTCertificate **recipients, + SECOidTag algorithm, int keysize); + +extern SEC_PKCS12SafeInfo * +SEC_PKCS12CreatePasswordPrivSafe(SEC_PKCS12ExportContext *p12ctxt, + SECItem *pwitem, SECOidTag privAlg); + +extern SEC_PKCS12SafeInfo * +SEC_PKCS12CreateUnencryptedSafe(SEC_PKCS12ExportContext *p12ctxt); + +extern SECStatus +SEC_PKCS12AddPasswordIntegrity(SEC_PKCS12ExportContext *p12ctxt, + SECItem *pwitem, SECOidTag integAlg); +extern SECStatus +SEC_PKCS12AddPublicKeyIntegrity(SEC_PKCS12ExportContext *p12ctxt, + CERTCertificate *cert, CERTCertDBHandle *certDb, + SECOidTag algorithm, int keySize); + +extern SEC_PKCS12ExportContext * +SEC_PKCS12CreateExportContext(SECKEYGetPasswordKey pwfn, void *pwfnarg, + PK11SlotInfo *slot, void *wincx); + +extern SECStatus +SEC_PKCS12AddCert(SEC_PKCS12ExportContext *p12ctxt, + SEC_PKCS12SafeInfo *safe, void *nestedDest, + CERTCertificate *cert, CERTCertDBHandle *certDb, + SECItem *keyId, PRBool includeCertChain); + +extern SECStatus +SEC_PKCS12AddKeyForCert(SEC_PKCS12ExportContext *p12ctxt, + SEC_PKCS12SafeInfo *safe, + void *nestedDest, CERTCertificate *cert, + PRBool shroudKey, SECOidTag algorithm, SECItem *pwitem, + SECItem *keyId, SECItem *nickName); + +extern SECStatus +SEC_PKCS12AddCertOrChainAndKey(SEC_PKCS12ExportContext *p12ctxt, + void *certSafe, void *certNestedDest, + CERTCertificate *cert, CERTCertDBHandle *certDb, + void *keySafe, void *keyNestedDest, PRBool shroudKey, + SECItem *pwitem, SECOidTag algorithm, + PRBool includeCertChain); + +extern SECStatus +SEC_PKCS12AddCertAndKey(SEC_PKCS12ExportContext *p12ctxt, + void *certSafe, void *certNestedDest, + CERTCertificate *cert, CERTCertDBHandle *certDb, + void *keySafe, void *keyNestedDest, + PRBool shroudKey, SECItem *pwitem, SECOidTag algorithm); + +extern void * +SEC_PKCS12CreateNestedSafeContents(SEC_PKCS12ExportContext *p12ctxt, + void *baseSafe, void *nestedDest); + +extern SECStatus +SEC_PKCS12Encode(SEC_PKCS12ExportContext *p12exp, + SEC_PKCS12EncoderOutputCallback output, void *outputarg); + +extern void +SEC_PKCS12DestroyExportContext(SEC_PKCS12ExportContext *p12exp); + +extern SEC_PKCS12DecoderContext * +SEC_PKCS12DecoderStart(SECItem *pwitem, PK11SlotInfo *slot, void *wincx, + digestOpenFn dOpen, digestCloseFn dClose, + digestIOFn dRead, digestIOFn dWrite, void *dArg); + +extern SECStatus +SEC_PKCS12DecoderSetTargetTokenCAs(SEC_PKCS12DecoderContext *p12dcx, + SECPKCS12TargetTokenCAs tokenCAs); + +extern SECStatus +SEC_PKCS12DecoderUpdate(SEC_PKCS12DecoderContext *p12dcx, unsigned char *data, + unsigned long len); + +extern void +SEC_PKCS12DecoderFinish(SEC_PKCS12DecoderContext *p12dcx); + +extern SECStatus +SEC_PKCS12DecoderVerify(SEC_PKCS12DecoderContext *p12dcx); + +extern SECStatus +SEC_PKCS12DecoderValidateBags(SEC_PKCS12DecoderContext *p12dcx, + SEC_PKCS12NicknameCollisionCallback nicknameCb); + +/* + * SEC_PKCS12DecoderRenameCertNicknames() can be used to change + * certificate nicknames in SEC_PKCS12DecoderContext, prior to calling + * SEC_PKCS12DecoderImportBags. + * + * arg: User-defined data that will be passed to nicknameCb. + * + * If SEC_PKCS12DecoderRenameCertNicknames() is called after calling + * SEC_PKCS12DecoderValidateBags(), then only the certificate nickname + * will be changed. + * If SEC_PKCS12DecoderRenameCertNicknames() is called prior to calling + * SEC_PKCS12DecoderValidateBags(), then SEC_PKCS12DecoderValidateBags() + * will change the nickname of the corresponding private key, too. + */ +extern SECStatus +SEC_PKCS12DecoderRenameCertNicknames(SEC_PKCS12DecoderContext *p12dcx, + SEC_PKCS12NicknameRenameCallback nicknameCb, + void *arg); + +extern SECStatus +SEC_PKCS12DecoderImportBags(SEC_PKCS12DecoderContext *p12dcx); + +CERTCertList * +SEC_PKCS12DecoderGetCerts(SEC_PKCS12DecoderContext *p12dcx); + +SECStatus +SEC_PKCS12DecoderIterateInit(SEC_PKCS12DecoderContext *p12dcx); + +SECStatus +SEC_PKCS12DecoderIterateNext(SEC_PKCS12DecoderContext *p12dcx, + const SEC_PKCS12DecoderItem **ipp); + +SEC_END_PROTOS + +#endif diff --git a/illumos-x86_64/usr/include/mps/p12plcy.h b/illumos-x86_64/usr/include/mps/p12plcy.h new file mode 100644 index 00000000..b4f8a742 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/p12plcy.h @@ -0,0 +1,38 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _P12PLCY_H_ +#define _P12PLCY_H_ + +#include "secoid.h" +#include "ciferfam.h" + +SEC_BEGIN_PROTOS + +/* is this encryption algorithm allowed in PKCS #12 by policy? */ +/* pbeAlg is either a full PBE for pkcsv5v1 and pkcs12pbe; or + * a cipher alg for pkcs5v2, + * hmacAlg is an HMAC algorith. Must be included for pkcs5v2 + * and is ignored if pbeAlg is pkcs5v2 or pkcs12pbe */ +extern PRBool SEC_PKCS12CipherAllowed(SECOidTag pbeAlg, SECOidTag hmacAlg); + +/* for the algid specified, can we decrypt it ? + * both encryption and hash used in the hmac must be enabled. + * legacy/decrypt is sufficient */ +extern PRBool SEC_PKCS12DecryptionAllowed(SECAlgorithmID *algid); + +/* for integrity, we mark if we are signing or verifying in the call. Oid + * is the hash oid */ +extern PRBool SEC_PKCS12IntegrityHashAllowed(SECOidTag hashAlg, PRBool verify); + +/* is encryption allowed? */ +extern PRBool SEC_PKCS12IsEncryptionAllowed(void); + +/* enable a cipher for encryption/decryption */ +extern SECStatus SEC_PKCS12EnableCipher(long which, int on); + +/* return the preferred cipher for encryption */ +extern SECStatus SEC_PKCS12SetPreferredCipher(long which, int on); + +SEC_END_PROTOS +#endif diff --git a/illumos-x86_64/usr/include/mps/p12t.h b/illumos-x86_64/usr/include/mps/p12t.h new file mode 100644 index 00000000..d449afdd --- /dev/null +++ b/illumos-x86_64/usr/include/mps/p12t.h @@ -0,0 +1,156 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _P12T_H_ +#define _P12T_H_ + +#include "secoid.h" +#include "keythi.h" +#include "pkcs11.h" +#include "secpkcs7.h" +#include "secdig.h" /* for SGNDigestInfo */ +#include "pkcs12t.h" + +#define SEC_PKCS12_VERSION 3 + +/* structure declarations */ +typedef struct sec_PKCS12PFXItemStr sec_PKCS12PFXItem; +typedef struct sec_PKCS12MacDataStr sec_PKCS12MacData; +typedef struct sec_PKCS12AuthenticatedSafeStr sec_PKCS12AuthenticatedSafe; +typedef struct sec_PKCS12SafeContentsStr sec_PKCS12SafeContents; +typedef struct sec_PKCS12SafeBagStr sec_PKCS12SafeBag; +typedef struct sec_PKCS12PKCS8ShroudedKeyBagStr sec_PKCS12PKCS8ShroudedKeyBag; +typedef struct sec_PKCS12CertBagStr sec_PKCS12CertBag; +typedef struct sec_PKCS12CRLBagStr sec_PKCS12CRLBag; +typedef struct sec_PKCS12SecretBag sec_PKCS12SecretBag; +typedef struct sec_PKCS12AttributeStr sec_PKCS12Attribute; + +struct sec_PKCS12CertBagStr { + /* what type of cert is stored? */ + SECItem bagID; + + /* certificate information */ + union { + SECItem x509Cert; + SECItem SDSICert; + } value; +}; + +struct sec_PKCS12CRLBagStr { + /* what type of cert is stored? */ + SECItem bagID; + + /* certificate information */ + union { + SECItem x509CRL; + } value; +}; + +struct sec_PKCS12SecretBag { + /* what type of secret? */ + SECItem secretType; + + /* secret information. ssshhhh be vewy vewy quiet. */ + SECItem secretContent; +}; + +struct sec_PKCS12AttributeStr { + SECItem attrType; + SECItem **attrValue; +}; + +struct sec_PKCS12SafeBagStr { + + /* What type of bag are we using? */ + SECItem safeBagType; + + /* Dependent upon the type of bag being used. */ + union { + SECKEYPrivateKeyInfo *pkcs8KeyBag; + SECKEYEncryptedPrivateKeyInfo *pkcs8ShroudedKeyBag; + sec_PKCS12CertBag *certBag; + sec_PKCS12CRLBag *crlBag; + sec_PKCS12SecretBag *secretBag; + sec_PKCS12SafeContents *safeContents; + SECItem *unknownBag; + } safeBagContent; + + sec_PKCS12Attribute **attribs; + + /* used locally */ + SECOidData *bagTypeTag; + PLArenaPool *arena; + unsigned int nAttribs; + + /* used for validation/importing */ + PRBool problem, noInstall, validated, hasKey, unused, installed; + int error; + + PRBool swapUnicodeBytes; + PK11SlotInfo *slot; + SECItem *pwitem; + PRBool oldBagType; + SECPKCS12TargetTokenCAs tokenCAs; +}; + +struct sec_PKCS12SafeContentsStr { + sec_PKCS12SafeBag **safeBags; + SECItem **encodedSafeBags; + + /* used locally */ + PLArenaPool *arena; + unsigned int bagCount; +}; + +struct sec_PKCS12MacDataStr { + SGNDigestInfo safeMac; + SECItem macSalt; + SECItem iter; +}; + +struct sec_PKCS12PFXItemStr { + + SECItem version; + + /* Content type will either be Data (password integrity mode) + * or signedData (public-key integrity mode) + */ + SEC_PKCS7ContentInfo *authSafe; + SECItem encodedAuthSafe; + + /* Only present in password integrity mode */ + sec_PKCS12MacData macData; + SECItem encodedMacData; +}; + +struct sec_PKCS12AuthenticatedSafeStr { + /* Content type will either be encryptedData (password privacy mode) + * or envelopedData (public-key privacy mode) + */ + SEC_PKCS7ContentInfo **safes; + SECItem **encodedSafes; + + /* used locally */ + unsigned int safeCount; + SECItem dummySafe; +}; + +extern const SEC_ASN1Template sec_PKCS12PFXItemTemplate[]; +extern const SEC_ASN1Template sec_PKCS12MacDataTemplate[]; +extern const SEC_ASN1Template sec_PKCS12AuthenticatedSafeTemplate[]; +extern const SEC_ASN1Template sec_PKCS12SafeContentsTemplate[]; +extern const SEC_ASN1Template sec_PKCS12SafeContentsDecodeTemplate[]; +extern const SEC_ASN1Template sec_PKCS12NestedSafeContentsDecodeTemplate[]; +extern const SEC_ASN1Template sec_PKCS12CertBagTemplate[]; +extern const SEC_ASN1Template sec_PKCS12CRLBagTemplate[]; +extern const SEC_ASN1Template sec_PKCS12SecretBagTemplate[]; +extern const SEC_ASN1Template sec_PKCS12PointerToCertBagTemplate[]; +extern const SEC_ASN1Template sec_PKCS12PointerToCRLBagTemplate[]; +extern const SEC_ASN1Template sec_PKCS12PointerToSecretBagTemplate[]; +extern const SEC_ASN1Template sec_PKCS12PointerToSafeContentsTemplate[]; +extern const SEC_ASN1Template sec_PKCS12AttributeTemplate[]; +extern const SEC_ASN1Template sec_PKCS12PointerToContentInfoTemplate[]; +extern const SEC_ASN1Template sec_PKCS12SafeBagTemplate[]; + +#endif diff --git a/illumos-x86_64/usr/include/mps/pk11func.h b/illumos-x86_64/usr/include/mps/pk11func.h new file mode 100644 index 00000000..331c0eb8 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pk11func.h @@ -0,0 +1,15 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _PK11FUNC_H_ +#define _PK11FUNC_H_ + +/* + * The original pk11func.h had a mix of public and private functions. + * Continue to provide those for backward compatibility. New code should + * include pk11pub.h instead of pk11func.h. + */ +#include "pk11pub.h" +#include "pk11priv.h" + +#endif diff --git a/illumos-x86_64/usr/include/mps/pk11hpke.h b/illumos-x86_64/usr/include/mps/pk11hpke.h new file mode 100644 index 00000000..51132817 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pk11hpke.h @@ -0,0 +1,82 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _PK11_HPKE_H_ +#define _PK11_HPKE_H_ 1 + +#include "blapit.h" +#include "seccomon.h" + +#define CLEANUP \ + PORT_Assert(rv == SECSuccess); \ + cleanup + +/* Error code must already be set. */ +#define CHECK_RV(rv) \ + if ((rv) != SECSuccess) { \ + goto cleanup; \ + } + +/* Error code must already be set. */ +#define CHECK_FAIL(cond) \ + if ((cond)) { \ + rv = SECFailure; \ + goto cleanup; \ + } + +#define CHECK_FAIL_ERR(cond, err) \ + if ((cond)) { \ + PORT_SetError((err)); \ + rv = SECFailure; \ + goto cleanup; \ + } + +typedef enum { + HpkeModeBase = 0, + HpkeModePsk = 1, +} HpkeModeId; + +/* https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hpke-08#section-7.1 */ +typedef enum { + HpkeDhKemX25519Sha256 = 0x20, +} HpkeKemId; + +typedef enum { + HpkeKdfHkdfSha256 = 1, + HpkeKdfHkdfSha384 = 2, + HpkeKdfHkdfSha512 = 3, +} HpkeKdfId; + +typedef enum { + HpkeAeadAes128Gcm = 1, + HpkeAeadAes256Gcm = 2, + HpkeAeadChaCha20Poly1305 = 3, +} HpkeAeadId; + +typedef struct hpkeKemParamsStr { + HpkeKemId id; + unsigned int Nsk; + unsigned int Nsecret; + unsigned int Npk; + SECOidTag oidTag; + CK_MECHANISM_TYPE hashMech; +} hpkeKemParams; + +typedef struct hpkeKdfParamsStr { + HpkeKdfId id; + unsigned int Nh; + CK_MECHANISM_TYPE mech; +} hpkeKdfParams; + +typedef struct hpkeAeadParamsStr { + HpkeAeadId id; + unsigned int Nk; + unsigned int Nn; + unsigned int tagLen; + CK_MECHANISM_TYPE mech; +} hpkeAeadParams; + +typedef struct HpkeContextStr HpkeContext; + +#endif /* _PK11_HPKE_H_ */ diff --git a/illumos-x86_64/usr/include/mps/pk11pqg.h b/illumos-x86_64/usr/include/mps/pk11pqg.h new file mode 100644 index 00000000..36596dd4 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pk11pqg.h @@ -0,0 +1,135 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* Thse functions are stub functions which will get replaced with calls through + * PKCS #11. + */ + +#ifndef _PK11PQG_H_ +#define _PK11PQG_H_ 1 + +#include "blapit.h" + +SEC_BEGIN_PROTOS + +/* Generate PQGParams and PQGVerify structs. + * Length of seed and length of h both equal length of P. + * All lengths are specified by "j", according to the table above. + */ +extern SECStatus PK11_PQG_ParamGen(unsigned int j, PQGParams **pParams, + PQGVerify **pVfy); + +/* Generate PQGParams and PQGVerify structs. + * Length of P specified by j. Length of h will match length of P. + * Length of SEED in bytes specified in seedBytes. + * seedBbytes must be in the range [20..255] or an error will result. + */ +extern SECStatus PK11_PQG_ParamGenSeedLen(unsigned int j, + unsigned int seedBytes, PQGParams **pParams, PQGVerify **pVfy); + +/* Generate PQGParams and PQGVerify structs. + * Length of P specified by L. + * if L is greater than 1024 then the resulting verify parameters will be + * DSA2. + * Length of Q specified by N. If zero, The PKCS #11 module will + * pick an appropriately sized Q for L. If N is specified and L = 1024, then + * the resulting verify parameters will be DSA2, Otherwise DSA1 parameters + * will be returned. + * Length of SEED in bytes specified in seedBytes. + * + * The underlying PKCS #11 module will check the values for L, N, + * and seedBytes. The rules for softoken are: + * + * If L <= 1024, then L must be between 512 and 1024 in increments of 64 bits. + * If L <= 1024, then N must be 0 or 160. + * If L >= 1024, then L and N must match the following table: + * L=1024 N=0 or 160 + * L=2048 N=0 or 224 + * L=2048 N=256 + * L=3072 N=0 or 256 + * if L <= 1024 + * seedBbytes must be in the range [20..256]. + * if L >= 1024 + * seedBbytes must be in the range [20..L/16]. + */ +extern SECStatus +PK11_PQG_ParamGenV2(unsigned int L, unsigned int N, unsigned int seedBytes, + PQGParams **pParams, PQGVerify **pVfy); + +/* Test PQGParams for validity as DSS PQG values. + * If vfy is non-NULL, test PQGParams to make sure they were generated + * using the specified seed, counter, and h values. + * + * Return value indicates whether Verification operation ran successfully + * to completion, but does not indicate if PQGParams are valid or not. + * If return value is SECSuccess, then *pResult has these meanings: + * SECSuccess: PQGParams are valid. + * SECFailure: PQGParams are invalid. + * + * Verify the following 12 facts about PQG counter SEED g and h + * These tests are specified in FIPS 186-3 Appendix A.1.1.1, A.1.1.3, and A.2.2 + * PQG_VerifyParams in softoken/freebl will automatically choose the + * appropriate test. + */ +extern SECStatus PK11_PQG_VerifyParams(const PQGParams *params, + const PQGVerify *vfy, SECStatus *result); +extern void PK11_PQG_DestroyParams(PQGParams *params); +extern void PK11_PQG_DestroyVerify(PQGVerify *vfy); + +/************************************************************************** + * Return a pointer to a new PQGParams struct that is constructed from * + * copies of the arguments passed in. * + * Return NULL on failure. * + **************************************************************************/ +extern PQGParams *PK11_PQG_NewParams(const SECItem *prime, const SECItem *subPrime, const SECItem *base); + +/************************************************************************** + * Fills in caller's "prime" SECItem with the prime value in params. + * Contents can be freed by calling SECITEM_FreeItem(prime, PR_FALSE); + **************************************************************************/ +extern SECStatus PK11_PQG_GetPrimeFromParams(const PQGParams *params, + SECItem *prime); + +/************************************************************************** + * Fills in caller's "subPrime" SECItem with the prime value in params. + * Contents can be freed by calling SECITEM_FreeItem(subPrime, PR_FALSE); + **************************************************************************/ +extern SECStatus PK11_PQG_GetSubPrimeFromParams(const PQGParams *params, + SECItem *subPrime); + +/************************************************************************** + * Fills in caller's "base" SECItem with the base value in params. + * Contents can be freed by calling SECITEM_FreeItem(base, PR_FALSE); + **************************************************************************/ +extern SECStatus PK11_PQG_GetBaseFromParams(const PQGParams *params, + SECItem *base); + +/************************************************************************** + * Return a pointer to a new PQGVerify struct that is constructed from * + * copies of the arguments passed in. * + * Return NULL on failure. * + **************************************************************************/ +extern PQGVerify *PK11_PQG_NewVerify(unsigned int counter, + const SECItem *seed, const SECItem *h); + +/************************************************************************** + * Returns "counter" value from the PQGVerify. + **************************************************************************/ +extern unsigned int PK11_PQG_GetCounterFromVerify(const PQGVerify *verify); + +/************************************************************************** + * Fills in caller's "seed" SECItem with the seed value in verify. + * Contents can be freed by calling SECITEM_FreeItem(seed, PR_FALSE); + **************************************************************************/ +extern SECStatus PK11_PQG_GetSeedFromVerify(const PQGVerify *verify, + SECItem *seed); + +/************************************************************************** + * Fills in caller's "h" SECItem with the h value in verify. + * Contents can be freed by calling SECITEM_FreeItem(h, PR_FALSE); + **************************************************************************/ +extern SECStatus PK11_PQG_GetHFromVerify(const PQGVerify *verify, SECItem *h); + +SEC_END_PROTOS + +#endif diff --git a/illumos-x86_64/usr/include/mps/pk11priv.h b/illumos-x86_64/usr/include/mps/pk11priv.h new file mode 100644 index 00000000..bb7cf888 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pk11priv.h @@ -0,0 +1,207 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _PK11PRIV_H_ +#define _PK11PRIV_H_ + +#include + +#include "plarena.h" +#include "seccomon.h" +#include "secoidt.h" +#include "secdert.h" +#include "keythi.h" +#include "certt.h" +#include "pkcs11t.h" +#include "secmodt.h" +#include "seccomon.h" +#include "pkcs7t.h" +#include "cmsreclist.h" +#include "pkcs11uri.h" + +/* + * These are the private NSS functions. They are not exported by nss.def, and + * are not callable outside nss3.dll. + */ + +SEC_BEGIN_PROTOS + +/************************************************************ + * Generic Slot Lists Management + ************************************************************/ +PK11SlotList *PK11_NewSlotList(void); +PK11SlotList *PK11_GetPrivateKeyTokens(CK_MECHANISM_TYPE type, + PRBool needRW, void *wincx); +SECStatus PK11_AddSlotToList(PK11SlotList *list, PK11SlotInfo *slot, PRBool sorted); +SECStatus PK11_DeleteSlotFromList(PK11SlotList *list, PK11SlotListElement *le); +PK11SlotListElement *PK11_FindSlotElement(PK11SlotList *list, + PK11SlotInfo *slot); +PK11SlotInfo *PK11_FindSlotBySerial(char *serial); + +/************************************************************ + * Generic Slot Management + ************************************************************/ +CK_OBJECT_HANDLE PK11_CopyKey(PK11SlotInfo *slot, CK_OBJECT_HANDLE srcObject); +PRBool pk11_MatchUriTokenInfo(PK11SlotInfo *slot, PK11URI *uri); +SECStatus PK11_ReadAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id, + CK_ATTRIBUTE_TYPE type, PLArenaPool *arena, SECItem *result); +CK_ULONG PK11_ReadULongAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id, + CK_ATTRIBUTE_TYPE type); +char *PK11_MakeString(PLArenaPool *arena, char *space, char *staticSring, + int stringLen); +PRBool pk11_MatchString(const char *string, + const char *staticString, size_t staticStringLen); +int PK11_MapError(CK_RV error); +CK_SESSION_HANDLE PK11_GetRWSession(PK11SlotInfo *slot); +void PK11_RestoreROSession(PK11SlotInfo *slot, CK_SESSION_HANDLE rwsession); +PRBool PK11_RWSessionHasLock(PK11SlotInfo *slot, + CK_SESSION_HANDLE session_handle); +PK11SlotInfo *PK11_NewSlotInfo(SECMODModule *mod); +void PK11_EnterSlotMonitor(PK11SlotInfo *); +void PK11_ExitSlotMonitor(PK11SlotInfo *); +void PK11_CleanKeyList(PK11SlotInfo *slot); + +/************************************************************ + * Slot Password Management + ************************************************************/ +SECStatus PK11_DoPassword(PK11SlotInfo *slot, CK_SESSION_HANDLE session, + PRBool loadCerts, void *wincx, PRBool alreadyLocked, + PRBool contextSpecific); +SECStatus PK11_VerifyPW(PK11SlotInfo *slot, char *pw); +void PK11_HandlePasswordCheck(PK11SlotInfo *slot, void *wincx); +void PK11_SetVerifyPasswordFunc(PK11VerifyPasswordFunc func); +void PK11_SetIsLoggedInFunc(PK11IsLoggedInFunc func); + +/************************************************************ + * Manage the built-In Slot Lists + ************************************************************/ +SECStatus PK11_InitSlotLists(void); +void PK11_DestroySlotLists(void); +PK11SlotList *PK11_GetSlotList(CK_MECHANISM_TYPE type); +void PK11_LoadSlotList(PK11SlotInfo *slot, PK11PreSlotInfo *psi, int count); +void PK11_ClearSlotList(PK11SlotInfo *slot); + +/****************************************************************** + * Slot initialization + ******************************************************************/ +SECStatus PK11_InitToken(PK11SlotInfo *slot, PRBool loadCerts); +void PK11_InitSlot(SECMODModule *mod, CK_SLOT_ID slotID, PK11SlotInfo *slot); +PRBool PK11_NeedPWInitForSlot(PK11SlotInfo *slot); +SECStatus PK11_ReadSlotCerts(PK11SlotInfo *slot); +void pk11_SetInternalKeySlot(PK11SlotInfo *slot); +PK11SlotInfo *pk11_SwapInternalKeySlot(PK11SlotInfo *slot); +void pk11_SetInternalKeySlotIfFirst(PK11SlotInfo *slot); + +/********************************************************************* + * Mechanism Mapping functions + *********************************************************************/ +void PK11_AddMechanismEntry(CK_MECHANISM_TYPE type, CK_KEY_TYPE key, + CK_MECHANISM_TYPE keygen, CK_MECHANISM_TYPE pad, + int ivLen, int blocksize); +CK_MECHANISM_TYPE PK11_GetKeyMechanism(CK_KEY_TYPE type); +CK_MECHANISM_TYPE PK11_GetKeyGenWithSize(CK_MECHANISM_TYPE type, int size); +PRBool PK11_DoesMechanismFlag(PK11SlotInfo *, CK_MECHANISM_TYPE type, CK_FLAGS flags); + +/********************************************************************** + * Symetric, Public, and Private Keys + **********************************************************************/ +SECKEYPublicKey *PK11_ExtractPublicKey(PK11SlotInfo *slot, KeyType keyType, + CK_OBJECT_HANDLE id); +CK_OBJECT_HANDLE PK11_FindObjectForCert(CERTCertificate *cert, + void *wincx, PK11SlotInfo **pSlot); +PK11SymKey *pk11_CopyToSlot(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, + CK_ATTRIBUTE_TYPE operation, PK11SymKey *symKey); +unsigned int pk11_GetPredefinedKeyLength(CK_KEY_TYPE keyType); +CK_OBJECT_HANDLE PK11_DerivePubKeyFromPrivKey(SECKEYPrivateKey *privKey); + +/********************************************************************** + * Certs + **********************************************************************/ +SECStatus PK11_TraversePrivateKeysInSlot(PK11SlotInfo *slot, + SECStatus (*callback)(SECKEYPrivateKey *, void *), void *arg); +SECKEYPrivateKey *PK11_FindPrivateKeyFromNickname(char *nickname, void *wincx); +CK_OBJECT_HANDLE *PK11_FindObjectsFromNickname(char *nickname, + PK11SlotInfo **slotptr, CK_OBJECT_CLASS objclass, int *returnCount, + void *wincx); +CK_OBJECT_HANDLE PK11_MatchItem(PK11SlotInfo *slot, CK_OBJECT_HANDLE peer, + CK_OBJECT_CLASS o_class); +CK_BBOOL pk11_HasAttributeSet_Lock(PK11SlotInfo *slot, + CK_OBJECT_HANDLE id, + CK_ATTRIBUTE_TYPE type, + PRBool haslock); +CK_RV PK11_GetAttributes(PLArenaPool *arena, PK11SlotInfo *slot, + CK_OBJECT_HANDLE obj, CK_ATTRIBUTE *attr, int count); +int PK11_NumberCertsForCertSubject(CERTCertificate *cert); +SECStatus PK11_TraverseCertsForSubject(CERTCertificate *cert, + SECStatus (*callback)(CERTCertificate *, void *), void *arg); +SECStatus PK11_GetKEAMatchedCerts(PK11SlotInfo *slot1, + PK11SlotInfo *slot2, CERTCertificate **cert1, CERTCertificate **cert2); +SECStatus PK11_TraverseCertsInSlot(PK11SlotInfo *slot, + SECStatus (*callback)(CERTCertificate *, void *), void *arg); +SECStatus PK11_LookupCrls(CERTCrlHeadNode *nodes, int type, void *wincx); + +/********************************************************************** + * Crypto Contexts + **********************************************************************/ +PK11Context *PK11_CreateContextByRawKey(PK11SlotInfo *slot, + CK_MECHANISM_TYPE type, PK11Origin origin, CK_ATTRIBUTE_TYPE operation, + SECItem *key, SECItem *param, void *wincx); +PRBool PK11_HashOK(SECOidTag hashAlg); +/* + * Testing interfaces, not for general use. If your code isn't in + * gtests or cmd, stay away from these. This function forces + * an AEAD context into simulation mode even though the target token + * can already do PKCS #11 v3.0 Message (e.i. softoken). + */ +SECStatus _PK11_ContextSetAEADSimulation(PK11Context *context); +PRBool _PK11_ContextGetAEADSimulation(PK11Context *context); + +/********************************************************************** + * Functions which are deprecated.... + **********************************************************************/ + +SECItem * +PK11_FindCrlByName(PK11SlotInfo **slot, CK_OBJECT_HANDLE *handle, + SECItem *derName, int type, char **url); + +CK_OBJECT_HANDLE +PK11_PutCrl(PK11SlotInfo *slot, SECItem *crl, + SECItem *name, char *url, int type); + +SECItem * +PK11_FindSMimeProfile(PK11SlotInfo **slotp, char *emailAddr, SECItem *derSubj, + SECItem **profileTime); +SECStatus +PK11_SaveSMimeProfile(PK11SlotInfo *slot, char *emailAddr, SECItem *derSubj, + SECItem *emailProfile, SECItem *profileTime); + +PRBool PK11_IsPermObject(PK11SlotInfo *slot, CK_OBJECT_HANDLE handle); + +char *PK11_GetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id); +SECStatus PK11_SetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id, + const char *nickname); + +/* private */ +SECStatus pk11_TraverseAllSlots(SECStatus (*callback)(PK11SlotInfo *, void *), + void *cbArg, PRBool forceLogin, void *pwArg); + +/* fetch multiple CRLs for a specific issuer */ +SECStatus pk11_RetrieveCrls(CERTCrlHeadNode *nodes, SECItem *issuer, + void *wincx); + +/* set global options for NSS PKCS#11 module loader */ +SECStatus pk11_setGlobalOptions(PRBool noSingleThreadedModules, + PRBool allowAlreadyInitializedModules, + PRBool dontFinalizeModules); + +/* return whether NSS is allowed to call C_Finalize */ +PRBool pk11_getFinalizeModulesOption(void); + +/* fetch the FIPS state from the fips indicator, public versions of + * this function operate on the slot, the context, and the object */ +PRBool pk11slot_GetFIPSStatus(PK11SlotInfo *slot, CK_SESSION_HANDLE session, + CK_OBJECT_HANDLE object, CK_ULONG operationType); + +SEC_END_PROTOS + +#endif diff --git a/illumos-x86_64/usr/include/mps/pk11pub.h b/illumos-x86_64/usr/include/mps/pk11pub.h new file mode 100644 index 00000000..4e9164cc --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pk11pub.h @@ -0,0 +1,1136 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _PK11PUB_H_ +#define _PK11PUB_H_ +#include "plarena.h" +#include "seccomon.h" +#include "secoidt.h" +#include "secdert.h" +#include "keythi.h" +#include "certt.h" +#include "pk11hpke.h" +#include "pkcs11t.h" +#include "secmodt.h" +#include "seccomon.h" +#include "pkcs7t.h" +#include "cmsreclist.h" + +/* + * Exported PK11 wrap functions. + */ + +SEC_BEGIN_PROTOS + +/************************************************************ + * Generic Slot Lists Management + ************************************************************/ +void PK11_FreeSlotList(PK11SlotList *list); +SECStatus PK11_FreeSlotListElement(PK11SlotList *list, PK11SlotListElement *le); +PK11SlotListElement *PK11_GetFirstSafe(PK11SlotList *list); +PK11SlotListElement *PK11_GetNextSafe(PK11SlotList *list, + PK11SlotListElement *le, PRBool restart); + +/************************************************************ + * Generic Slot Management + ************************************************************/ +PK11SlotInfo *PK11_ReferenceSlot(PK11SlotInfo *slot); +void PK11_FreeSlot(PK11SlotInfo *slot); +SECStatus PK11_DestroyObject(PK11SlotInfo *slot, CK_OBJECT_HANDLE object); +SECStatus PK11_DestroyTokenObject(PK11SlotInfo *slot, CK_OBJECT_HANDLE object); +PK11SlotInfo *PK11_GetInternalKeySlot(void); +PK11SlotInfo *PK11_GetInternalSlot(void); +SECStatus PK11_Logout(PK11SlotInfo *slot); +void PK11_LogoutAll(void); + +/************************************************************ + * Slot Password Management + ************************************************************/ +void PK11_SetSlotPWValues(PK11SlotInfo *slot, int askpw, int timeout); +void PK11_GetSlotPWValues(PK11SlotInfo *slot, int *askpw, int *timeout); +SECStatus PK11_CheckSSOPassword(PK11SlotInfo *slot, char *ssopw); +SECStatus PK11_CheckUserPassword(PK11SlotInfo *slot, const char *pw); +PRBool PK11_IsLoggedIn(PK11SlotInfo *slot, void *wincx); +SECStatus PK11_InitPin(PK11SlotInfo *slot, const char *ssopw, + const char *pk11_userpwd); +SECStatus PK11_ChangePW(PK11SlotInfo *slot, const char *oldpw, + const char *newpw); +void PK11_SetPasswordFunc(PK11PasswordFunc func); +int PK11_GetMinimumPwdLength(PK11SlotInfo *slot); +SECStatus PK11_ResetToken(PK11SlotInfo *slot, char *sso_pwd); +SECStatus PK11_Authenticate(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); +SECStatus PK11_TokenRefresh(PK11SlotInfo *slot); + +/****************************************************************** + * Slot info functions + ******************************************************************/ +PK11SlotInfo *PK11_FindSlotByName(const char *name); +/****************************************************************** + * PK11_FindSlotsByNames searches for a PK11SlotInfo using one or + * more criteria : dllName, slotName and tokenName . In addition, if + * presentOnly is set , only slots with a token inserted will be + * returned. + ******************************************************************/ +PK11SlotList *PK11_FindSlotsByNames(const char *dllName, + const char *slotName, const char *tokenName, PRBool presentOnly); +PRBool PK11_IsReadOnly(PK11SlotInfo *slot); +PRBool PK11_IsInternal(PK11SlotInfo *slot); +PRBool PK11_IsInternalKeySlot(PK11SlotInfo *slot); +char *PK11_GetTokenName(PK11SlotInfo *slot); +char *PK11_GetTokenURI(PK11SlotInfo *slot); +char *PK11_GetSlotName(PK11SlotInfo *slot); +PRBool PK11_NeedLogin(PK11SlotInfo *slot); +PRBool PK11_IsFriendly(PK11SlotInfo *slot); +PRBool PK11_IsHW(PK11SlotInfo *slot); +PRBool PK11_IsRemovable(PK11SlotInfo *slot); +PRBool PK11_NeedUserInit(PK11SlotInfo *slot); +PRBool PK11_ProtectedAuthenticationPath(PK11SlotInfo *slot); +int PK11_GetSlotSeries(PK11SlotInfo *slot); +int PK11_GetCurrentWrapIndex(PK11SlotInfo *slot); +unsigned long PK11_GetDefaultFlags(PK11SlotInfo *slot); +CK_SLOT_ID PK11_GetSlotID(PK11SlotInfo *slot); +SECMODModuleID PK11_GetModuleID(PK11SlotInfo *slot); +SECStatus PK11_GetSlotInfo(PK11SlotInfo *slot, CK_SLOT_INFO *info); +SECStatus PK11_GetTokenInfo(PK11SlotInfo *slot, CK_TOKEN_INFO *info); +PRBool PK11_IsDisabled(PK11SlotInfo *slot); +PRBool PK11_HasRootCerts(PK11SlotInfo *slot); +PK11DisableReasons PK11_GetDisabledReason(PK11SlotInfo *slot); +/* like PORT_Memcmp, return -1 if the version is less then the + * passed in version, 0 if it's equal to and 1 if it's greater than + * the passed in version. PKCS #11 returns versions in 2 places, + * once in the function table and once in the module. the former + * is good to determine if it is safe to call a new function, + * the latter is good for module functionality */ +PRInt32 PK11_CheckPKCS11Version(PK11SlotInfo *slot, CK_BYTE major, + CK_BYTE minor, PRBool useFunctionTable); + +/* Prevents the slot from being used, and set disable reason to user-disable */ +/* NOTE: Mechanisms that were ON continue to stay ON */ +/* Therefore, when the slot is enabled, it will remember */ +/* what mechanisms needs to be turned on */ +PRBool PK11_UserDisableSlot(PK11SlotInfo *slot); +/* Allow all mechanisms that are ON before UserDisableSlot() */ +/* was called to be available again */ +PRBool PK11_UserEnableSlot(PK11SlotInfo *slot); +/* + * wait for a specific slot event. + * event is a specific event to wait for. Currently only + * PK11TokenChangeOrRemovalEvent and PK11TokenPresentEvents are defined. + * timeout can be an interval time to wait, PR_INTERVAL_NO_WAIT (meaning only + * poll once), or PR_INTERVAL_NO_TIMEOUT (meaning block until a change). + * pollInterval is a suggested pulling interval value. '0' means use the + * default. Future implementations that don't poll may ignore this value. + * series is the current series for the last slot. This should be the series + * value for the slot the last time you read persistant information from the + * slot. For instance, if you publish a cert from the slot, you should obtain + * the slot series at that time. Then PK11_WaitForTokenEvent can detect a + * a change in the slot between the time you publish and the time + * PK11_WaitForTokenEvent is called, elliminating potential race conditions. + * + * The current status that is returned is: + * PK11TokenNotRemovable - always returned for any non-removable token. + * PK11TokenPresent - returned when the token is present and we are waiting + * on a PK11TokenPresentEvent. Then next event to look for is a + * PK11TokenChangeOrRemovalEvent. + * PK11TokenChanged - returned when the old token has been removed and a new + * token ad been inserted, and we are waiting for a + * PK11TokenChangeOrRemovalEvent. The next event to look for is another + * PK11TokenChangeOrRemovalEvent. + * PK11TokenRemoved - returned when the token is not present and we are + * waiting for a PK11TokenChangeOrRemovalEvent. The next event to look for + * is a PK11TokenPresentEvent. + */ +PK11TokenStatus PK11_WaitForTokenEvent(PK11SlotInfo *slot, PK11TokenEvent event, + PRIntervalTime timeout, PRIntervalTime pollInterval, int series); + +PRBool PK11_NeedPWInit(void); +PRBool PK11_TokenExists(CK_MECHANISM_TYPE); +SECStatus PK11_GetModInfo(SECMODModule *mod, CK_INFO *info); +char *PK11_GetModuleURI(SECMODModule *mod); +PRBool PK11_IsFIPS(void); +SECMODModule *PK11_GetModule(PK11SlotInfo *slot); + +/********************************************************************* + * Slot mapping utility functions. + *********************************************************************/ +PRBool PK11_IsPresent(PK11SlotInfo *slot); +PRBool PK11_DoesMechanism(PK11SlotInfo *slot, CK_MECHANISM_TYPE type); +PK11SlotList *PK11_GetAllTokens(CK_MECHANISM_TYPE type, PRBool needRW, + PRBool loadCerts, void *wincx); +PK11SlotInfo *PK11_GetBestSlotMultipleWithAttributes(CK_MECHANISM_TYPE *type, + CK_FLAGS *mechFlag, unsigned int *keySize, + unsigned int count, void *wincx); +PK11SlotInfo *PK11_GetBestSlotMultiple(CK_MECHANISM_TYPE *type, + unsigned int count, void *wincx); +PK11SlotInfo *PK11_GetBestSlot(CK_MECHANISM_TYPE type, void *wincx); +PK11SlotInfo *PK11_GetBestSlotWithAttributes(CK_MECHANISM_TYPE type, + CK_FLAGS mechFlag, unsigned int keySize, void *wincx); +CK_MECHANISM_TYPE PK11_GetBestWrapMechanism(PK11SlotInfo *slot); +int PK11_GetBestKeyLength(PK11SlotInfo *slot, CK_MECHANISM_TYPE type); + +/* + * Open a new database using the softoken. The caller is responsible for making + * sure the module spec is correct and usable. The caller should ask for one + * new database per call if the caller wants to get meaningful information + * about the new database. + * + * moduleSpec is the same data that you would pass to softoken at + * initialization time under the 'tokens' options. For example, if you were + * to specify tokens=<0x4=[configdir='./mybackup' tokenDescription='Backup']> + * You would specify "configdir='./mybackup' tokenDescription='Backup'" as your + * module spec here. The slot ID will be calculated for you by + * SECMOD_OpenUserDB(). + * + * Typical parameters here are configdir, tokenDescription and flags. + * + * a Full list is below: + * + * + * configDir - The location of the databases for this token. If configDir is + * not specified, and noCertDB and noKeyDB is not specified, the load + * will fail. + * certPrefix - Cert prefix for this token. + * keyPrefix - Prefix for the key database for this token. (if not specified, + * certPrefix will be used). + * tokenDescription - The label value for this token returned in the + * CK_TOKEN_INFO structure with an internationalize string (UTF8). + * This value will be truncated at 32 bytes (no NULL, partial UTF8 + * characters dropped). You should specify a user friendly name here + * as this is the value the token will be referred to in most + * application UI's. You should make sure tokenDescription is unique. + * slotDescription - The slotDescription value for this token returned + * in the CK_SLOT_INFO structure with an internationalize string + * (UTF8). This value will be truncated at 64 bytes (no NULL, partial + * UTF8 characters dropped). This name will not change after the + * database is closed. It should have some number to make this unique. + * minPWLen - minimum password length for this token. + * flags - comma separated list of flag values, parsed case-insensitive. + * Valid flags are: + * readOnly - Databases should be opened read only. + * noCertDB - Don't try to open a certificate database. + * noKeyDB - Don't try to open a key database. + * forceOpen - Don't fail to initialize the token if the + * databases could not be opened. + * passwordRequired - zero length passwords are not acceptable + * (valid only if there is a keyDB). + * optimizeSpace - allocate smaller hash tables and lock tables. + * When this flag is not specified, Softoken will allocate + * large tables to prevent lock contention. + */ +PK11SlotInfo *SECMOD_OpenUserDB(const char *moduleSpec); +SECStatus SECMOD_CloseUserDB(PK11SlotInfo *slot); + +/* + * This is exactly the same as OpenUserDB except it can be called on any + * module that understands softoken style new slot entries. The resulting + * slot can be closed using SECMOD_CloseUserDB above. Value of moduleSpec + * is token specific. + */ +PK11SlotInfo *SECMOD_OpenNewSlot(SECMODModule *mod, const char *moduleSpec); + +/* + * merge the permanent objects from on token to another + */ +SECStatus PK11_MergeTokens(PK11SlotInfo *targetSlot, PK11SlotInfo *sourceSlot, + PK11MergeLog *log, void *targetPwArg, void *sourcePwArg); + +/* + * create and destroy merge logs needed by PK11_MergeTokens + */ +PK11MergeLog *PK11_CreateMergeLog(void); +void PK11_DestroyMergeLog(PK11MergeLog *log); + +/********************************************************************* + * Mechanism Mapping functions + *********************************************************************/ +CK_KEY_TYPE PK11_GetKeyType(CK_MECHANISM_TYPE type, unsigned long len); +CK_MECHANISM_TYPE PK11_GetKeyGen(CK_MECHANISM_TYPE type); +int PK11_GetBlockSize(CK_MECHANISM_TYPE type, SECItem *params); +int PK11_GetIVLength(CK_MECHANISM_TYPE type); +SECItem *PK11_ParamFromIV(CK_MECHANISM_TYPE type, SECItem *iv); +unsigned char *PK11_IVFromParam(CK_MECHANISM_TYPE type, SECItem *param, int *len); +SECItem *PK11_BlockData(SECItem *data, unsigned long size); +int PK11_GetMaxKeyLength(CK_MECHANISM_TYPE type); + +/* PKCS #11 to DER mapping functions */ +SECItem *PK11_ParamFromAlgid(SECAlgorithmID *algid); +SECItem *PK11_GenerateNewParam(CK_MECHANISM_TYPE, PK11SymKey *); +CK_MECHANISM_TYPE PK11_AlgtagToMechanism(SECOidTag algTag); +SECOidTag PK11_MechanismToAlgtag(CK_MECHANISM_TYPE type); +SECOidTag PK11_FortezzaMapSig(SECOidTag algTag); +SECStatus PK11_ParamToAlgid(SECOidTag algtag, SECItem *param, + PLArenaPool *arena, SECAlgorithmID *algid); +SECStatus PK11_SeedRandom(PK11SlotInfo *, unsigned char *data, int len); +SECStatus PK11_GenerateRandomOnSlot(PK11SlotInfo *, unsigned char *data, int len); +SECStatus PK11_RandomUpdate(void *data, size_t bytes); +SECStatus PK11_GenerateRandom(unsigned char *data, int len); + +/* warning: cannot work with pkcs 5 v2 + * use algorithm ID s instead of pkcs #11 mechanism pointers */ +CK_RV PK11_MapPBEMechanismToCryptoMechanism(CK_MECHANISM_PTR pPBEMechanism, + CK_MECHANISM_PTR pCryptoMechanism, + SECItem *pbe_pwd, PRBool bad3DES); +CK_MECHANISM_TYPE PK11_GetPadMechanism(CK_MECHANISM_TYPE); +CK_MECHANISM_TYPE PK11_MapSignKeyType(KeyType keyType); + +/********************************************************************** + * Symmetric, Public, and Private Keys + **********************************************************************/ +void PK11_FreeSymKey(PK11SymKey *key); +PK11SymKey *PK11_ReferenceSymKey(PK11SymKey *symKey); +PK11SymKey *PK11_ImportDataKey(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, PK11Origin origin, + CK_ATTRIBUTE_TYPE operation, SECItem *key, void *wincx); +PK11SymKey *PK11_ImportSymKey(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, + PK11Origin origin, CK_ATTRIBUTE_TYPE operation, SECItem *key, void *wincx); +PK11SymKey *PK11_ImportSymKeyWithFlags(PK11SlotInfo *slot, + CK_MECHANISM_TYPE type, PK11Origin origin, CK_ATTRIBUTE_TYPE operation, + SECItem *key, CK_FLAGS flags, PRBool isPerm, void *wincx); +PK11SymKey *PK11_SymKeyFromHandle(PK11SlotInfo *slot, PK11SymKey *parent, + PK11Origin origin, CK_MECHANISM_TYPE type, CK_OBJECT_HANDLE keyID, + PRBool owner, void *wincx); +/* PK11_GetWrapKey and PK11_SetWrapKey are not thread safe. */ +PK11SymKey *PK11_GetWrapKey(PK11SlotInfo *slot, int wrap, + CK_MECHANISM_TYPE type, int series, void *wincx); +void PK11_SetWrapKey(PK11SlotInfo *slot, int wrap, PK11SymKey *wrapKey); +CK_MECHANISM_TYPE PK11_GetMechanism(PK11SymKey *symKey); +/* + * import a public key into the desired slot + * + * This function takes a public key structure and creates a public key in a + * given slot. If isToken is set, then a persistant public key is created. + * + * Note: it is possible for this function to return a handle for a key which + * is persistant, even if isToken is not set. + */ +CK_OBJECT_HANDLE PK11_ImportPublicKey(PK11SlotInfo *slot, + SECKEYPublicKey *pubKey, PRBool isToken); +PK11SymKey *PK11_KeyGen(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, + SECItem *param, int keySize, void *wincx); +PK11SymKey *PK11_TokenKeyGen(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, + SECItem *param, int keySize, SECItem *keyid, + PRBool isToken, void *wincx); +PK11SymKey *PK11_TokenKeyGenWithFlags(PK11SlotInfo *slot, + CK_MECHANISM_TYPE type, SECItem *param, + int keySize, SECItem *keyid, CK_FLAGS opFlags, + PK11AttrFlags attrFlags, void *wincx); +/* Generates a key using the exact template supplied by the caller. The other + * PK11_[Token]KeyGen mechanisms should be used instead of this one whenever + * they work because they include/exclude the CKA_VALUE_LEN template value + * based on the mechanism type as required by many tokens. + * + * keyGenType should be PK11_GetKeyGenWithSize(type, ) or it should + * be equal to type if PK11_GetKeyGenWithSize cannot be used (e.g. because + * pk11wrap does not know about the mechanisms). + */ +PK11SymKey *PK11_KeyGenWithTemplate(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, + CK_MECHANISM_TYPE keyGenType, + SECItem *param, CK_ATTRIBUTE *attrs, + unsigned int attrsCount, void *wincx); +PK11SymKey *PK11_ListFixedKeysInSlot(PK11SlotInfo *slot, char *nickname, + void *wincx); +PK11SymKey *PK11_GetNextSymKey(PK11SymKey *symKey); +CK_KEY_TYPE PK11_GetSymKeyType(PK11SymKey *key); +CK_OBJECT_HANDLE PK11_GetSymKeyHandle(PK11SymKey *symKey); + +/* + * PK11_SetSymKeyUserData + * sets generic user data on keys (usually a pointer to a data structure) + * that can later be retrieved by PK11_GetSymKeyUserData(). + * symKey - key where data will be set. + * data - data to be set. + * freefunc - function used to free the data. + * Setting user data on symKeys with existing user data already set will cause + * the existing user data to be freed before the new user data is set. + * Freeing user data is done by calling the user specified freefunc. + * If freefunc is NULL, the user data is assumed to be global or static an + * not freed. Passing NULL for user data to PK11_SetSymKeyUserData has the + * effect of freeing any existing user data, and clearing the user data + * pointer. If user data exists when the symKey is finally freed, that + * data will be freed with freefunc. + * + * Applications should only use this function on keys which the application + * has created directly, as there is only one user data value per key. + */ +void PK11_SetSymKeyUserData(PK11SymKey *symKey, void *data, + PK11FreeDataFunc freefunc); +/* PK11_GetSymKeyUserData + * retrieves generic user data which was set on a key by + * PK11_SetSymKeyUserData. + * symKey - key with data to be fetched + * + * If no data exists, or the data has been cleared, PK11_GetSymKeyUserData + * will return NULL. Returned data is still owned and managed by the SymKey, + * the caller should not free the data. + * + */ +void *PK11_GetSymKeyUserData(PK11SymKey *symKey); + +SECStatus PK11_PubWrapSymKey(CK_MECHANISM_TYPE type, SECKEYPublicKey *pubKey, + PK11SymKey *symKey, SECItem *wrappedKey); +SECStatus PK11_PubWrapSymKeyWithMechanism(SECKEYPublicKey *pubKey, + CK_MECHANISM_TYPE mechType, + SECItem *param, + PK11SymKey *symKey, + SECItem *wrappedKey); +SECStatus PK11_WrapSymKey(CK_MECHANISM_TYPE type, SECItem *params, + PK11SymKey *wrappingKey, PK11SymKey *symKey, SECItem *wrappedKey); +/* move a key to 'slot' optionally set the key attributes according to either + * operation or the flags and making the key permanent at the same time. + * If the key is moved to the same slot, operation and flags values are + * currently ignored */ +PK11SymKey *PK11_MoveSymKey(PK11SlotInfo *slot, CK_ATTRIBUTE_TYPE operation, + CK_FLAGS flags, PRBool perm, PK11SymKey *symKey); +/* + * To do joint operations, we often need two keys in the same slot. + * Usually the PKCS #11 wrappers handle this correctly (like for PK11_WrapKey), + * but sometimes the wrappers don't know about mechanism specific keys in + * the Mechanism params. This function makes sure the two keys are in the + * same slot by copying one or both of the keys into a common slot. This + * functions makes sure the slot can handle the target mechanism. If the copy + * is warranted, this function will prefer to move the movingKey first, then + * the preferedKey. If the keys are moved, the new keys are returned in + * newMovingKey and/or newPreferedKey. The application is responsible + * for freeing those keys one the operation is complete. + */ +SECStatus PK11_SymKeysToSameSlot(CK_MECHANISM_TYPE mech, + CK_ATTRIBUTE_TYPE preferedOperation, + CK_ATTRIBUTE_TYPE movingOperation, + PK11SymKey *preferedKey, PK11SymKey *movingKey, + PK11SymKey **newPreferedKey, + PK11SymKey **newMovingKey); + +/* + * derive a new key from the base key. + * PK11_Derive returns a key which can do exactly one operation, and is + * ephemeral (session key). + * PK11_DeriveWithFlags is the same as PK11_Derive, except you can use + * CKF_ flags to enable more than one operation. + * PK11_DeriveWithFlagsPerm is the same as PK11_DeriveWithFlags except you can + * (optionally) make the key permanent (token key). + */ +PK11SymKey *PK11_Derive(PK11SymKey *baseKey, CK_MECHANISM_TYPE mechanism, + SECItem *param, CK_MECHANISM_TYPE target, + CK_ATTRIBUTE_TYPE operation, int keySize); +PK11SymKey *PK11_DeriveWithFlags(PK11SymKey *baseKey, + CK_MECHANISM_TYPE derive, SECItem *param, CK_MECHANISM_TYPE target, + CK_ATTRIBUTE_TYPE operation, int keySize, CK_FLAGS flags); +PK11SymKey *PK11_DeriveWithFlagsPerm(PK11SymKey *baseKey, + CK_MECHANISM_TYPE derive, + SECItem *param, CK_MECHANISM_TYPE target, CK_ATTRIBUTE_TYPE operation, + int keySize, CK_FLAGS flags, PRBool isPerm); +PK11SymKey * +PK11_DeriveWithTemplate(PK11SymKey *baseKey, CK_MECHANISM_TYPE derive, + SECItem *param, CK_MECHANISM_TYPE target, CK_ATTRIBUTE_TYPE operation, + int keySize, CK_ATTRIBUTE *userAttr, unsigned int numAttrs, + PRBool isPerm); + +PK11SymKey *PK11_PubDerive(SECKEYPrivateKey *privKey, + SECKEYPublicKey *pubKey, PRBool isSender, SECItem *randomA, SECItem *randomB, + CK_MECHANISM_TYPE derive, CK_MECHANISM_TYPE target, + CK_ATTRIBUTE_TYPE operation, int keySize, void *wincx); +PK11SymKey *PK11_PubDeriveWithKDF(SECKEYPrivateKey *privKey, + SECKEYPublicKey *pubKey, PRBool isSender, SECItem *randomA, SECItem *randomB, + CK_MECHANISM_TYPE derive, CK_MECHANISM_TYPE target, + CK_ATTRIBUTE_TYPE operation, int keySize, + CK_ULONG kdf, SECItem *sharedData, void *wincx); + +/* + * Concatenate a pair of symmetric keys. + */ +PK11SymKey *PK11_ConcatSymKeys(PK11SymKey *left, PK11SymKey *right, CK_MECHANISM_TYPE target, CK_ATTRIBUTE_TYPE operation); + +/* + * unwrap a new key with a symetric key. + * PK11_Unwrap returns a key which can do exactly one operation, and is + * ephemeral (session key). + * PK11_UnwrapWithFlags is the same as PK11_Unwrap, except you can use + * CKF_ flags to enable more than one operation. + * PK11_UnwrapWithFlagsPerm is the same as PK11_UnwrapWithFlags except you can + * (optionally) make the key permanent (token key). + */ +PK11SymKey *PK11_UnwrapSymKey(PK11SymKey *key, + CK_MECHANISM_TYPE wraptype, SECItem *param, SECItem *wrapppedKey, + CK_MECHANISM_TYPE target, CK_ATTRIBUTE_TYPE operation, int keySize); +PK11SymKey *PK11_UnwrapSymKeyWithFlags(PK11SymKey *wrappingKey, + CK_MECHANISM_TYPE wrapType, SECItem *param, SECItem *wrappedKey, + CK_MECHANISM_TYPE target, CK_ATTRIBUTE_TYPE operation, int keySize, + CK_FLAGS flags); +PK11SymKey *PK11_UnwrapSymKeyWithFlagsPerm(PK11SymKey *wrappingKey, + CK_MECHANISM_TYPE wrapType, + SECItem *param, SECItem *wrappedKey, + CK_MECHANISM_TYPE target, CK_ATTRIBUTE_TYPE operation, + int keySize, CK_FLAGS flags, PRBool isPerm); + +/* + * unwrap a new key with a private key. + * PK11_PubUnwrap returns a key which can do exactly one operation, and is + * ephemeral (session key). + * PK11_PubUnwrapWithFlagsPerm is the same as PK11_PubUnwrap except you can + * use * CKF_ flags to enable more than one operation, and optionally make + * the key permanent (token key). + */ +PK11SymKey *PK11_PubUnwrapSymKey(SECKEYPrivateKey *key, SECItem *wrapppedKey, + CK_MECHANISM_TYPE target, CK_ATTRIBUTE_TYPE operation, int keySize); +PK11SymKey *PK11_PubUnwrapSymKeyWithMechanism(SECKEYPrivateKey *key, + CK_MECHANISM_TYPE mechType, + SECItem *param, + SECItem *wrapppedKey, + CK_MECHANISM_TYPE target, + CK_ATTRIBUTE_TYPE operation, + int keySize); +PK11SymKey *PK11_PubUnwrapSymKeyWithFlagsPerm(SECKEYPrivateKey *wrappingKey, + SECItem *wrappedKey, CK_MECHANISM_TYPE target, + CK_ATTRIBUTE_TYPE operation, int keySize, + CK_FLAGS flags, PRBool isPerm); +PK11SymKey *PK11_FindFixedKey(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, + SECItem *keyID, void *wincx); +SECStatus PK11_DeleteTokenPrivateKey(SECKEYPrivateKey *privKey, PRBool force); +SECStatus PK11_DeleteTokenPublicKey(SECKEYPublicKey *pubKey); +SECStatus PK11_DeleteTokenSymKey(PK11SymKey *symKey); +SECStatus PK11_DeleteTokenCertAndKey(CERTCertificate *cert, void *wincx); +SECKEYPrivateKey *PK11_LoadPrivKey(PK11SlotInfo *slot, + SECKEYPrivateKey *privKey, SECKEYPublicKey *pubKey, + PRBool token, PRBool sensitive); +char *PK11_GetSymKeyNickname(PK11SymKey *symKey); +char *PK11_GetPrivateKeyNickname(SECKEYPrivateKey *privKey); +char *PK11_GetPublicKeyNickname(SECKEYPublicKey *pubKey); +SECStatus PK11_SetSymKeyNickname(PK11SymKey *symKey, const char *nickname); +SECStatus PK11_SetPrivateKeyNickname(SECKEYPrivateKey *privKey, + const char *nickname); +SECStatus PK11_SetPublicKeyNickname(SECKEYPublicKey *pubKey, + const char *nickname); + +/* + * Using __PK11_SetCertificateNickname is *DANGEROUS*. + * + * The API will update the NSS database, but it *will NOT* update the in-memory data. + * As a result, after calling this API, there will be INCONSISTENCY between + * in-memory data and the database. + * + * Use of the API should be limited to short-lived tools, which will exit immediately + * after using this API. + * + * If you ignore this warning, your process is TAINTED and will most likely misbehave. + */ +SECStatus __PK11_SetCertificateNickname(CERTCertificate *cert, + const char *nickname); + +/* size to hold key in bytes */ +unsigned int PK11_GetKeyLength(PK11SymKey *key); +/* size of actual secret parts of key in bits */ +/* algid is because RC4 strength is determined by the effective bits as well + * as the key bits */ +unsigned int PK11_GetKeyStrength(PK11SymKey *key, SECAlgorithmID *algid); +SECStatus PK11_ExtractKeyValue(PK11SymKey *symKey); +SECItem *PK11_GetKeyData(PK11SymKey *symKey); +PK11SlotInfo *PK11_GetSlotFromKey(PK11SymKey *symKey); +void *PK11_GetWindow(PK11SymKey *symKey); + +/* + * Explicitly set the key usage for the generated private key. + * + * This allows us to specify single use EC and RSA keys whose usage + * can be regulated by the underlying token. + * + * The underlying key usage is set using opFlags. opFlagsMask specifies + * which operations are specified by opFlags. For instance to turn encrypt + * on and signing off, opFlags would be CKF_ENCRYPT|CKF_DECRYPT and + * opFlagsMask would be CKF_ENCRYPT|CKF_DECRYPT|CKF_SIGN|CKF_VERIFY. You + * need to specify both the public and private key flags, + * PK11_GenerateKeyPairWithOpFlags will sort out the correct flag to the + * correct key type. Flags not specified in opFlagMask will be defaulted + * according to mechanism type and token capabilities. + */ +SECKEYPrivateKey *PK11_GenerateKeyPairWithOpFlags(PK11SlotInfo *slot, + CK_MECHANISM_TYPE type, void *param, SECKEYPublicKey **pubk, + PK11AttrFlags attrFlags, CK_FLAGS opFlags, CK_FLAGS opFlagsMask, + void *wincx); +/* + * The attrFlags is the logical OR of the PK11_ATTR_XXX bitflags. + * These flags apply to the private key. The PK11_ATTR_TOKEN, + * PK11_ATTR_SESSION, PK11_ATTR_MODIFIABLE, and PK11_ATTR_UNMODIFIABLE + * flags also apply to the public key. + */ +SECKEYPrivateKey *PK11_GenerateKeyPairWithFlags(PK11SlotInfo *slot, + CK_MECHANISM_TYPE type, void *param, SECKEYPublicKey **pubk, + PK11AttrFlags attrFlags, void *wincx); +SECKEYPrivateKey *PK11_GenerateKeyPair(PK11SlotInfo *slot, + CK_MECHANISM_TYPE type, void *param, SECKEYPublicKey **pubk, + PRBool isPerm, PRBool isSensitive, void *wincx); +SECKEYPrivateKey *PK11_FindPrivateKeyFromCert(PK11SlotInfo *slot, + CERTCertificate *cert, void *wincx); +SECKEYPrivateKey *PK11_FindKeyByAnyCert(CERTCertificate *cert, void *wincx); +SECKEYPrivateKey *PK11_FindKeyByKeyID(PK11SlotInfo *slot, SECItem *keyID, + void *wincx); +int PK11_GetPrivateModulusLen(SECKEYPrivateKey *key); + +SECStatus PK11_Decrypt(PK11SymKey *symkey, + CK_MECHANISM_TYPE mechanism, SECItem *param, + unsigned char *out, unsigned int *outLen, + unsigned int maxLen, + const unsigned char *enc, unsigned int encLen); +SECStatus PK11_Encrypt(PK11SymKey *symKey, + CK_MECHANISM_TYPE mechanism, SECItem *param, + unsigned char *out, unsigned int *outLen, + unsigned int maxLen, + const unsigned char *data, unsigned int dataLen); + +/* note: despite the name, this function takes a private key. */ +SECStatus PK11_PubDecryptRaw(SECKEYPrivateKey *key, + unsigned char *data, unsigned *outLen, + unsigned int maxLen, + const unsigned char *enc, unsigned encLen); +#define PK11_PrivDecryptRaw PK11_PubDecryptRaw +/* The encrypt function that complements the above decrypt function. */ +SECStatus PK11_PubEncryptRaw(SECKEYPublicKey *key, + unsigned char *enc, + const unsigned char *data, unsigned dataLen, + void *wincx); + +SECStatus PK11_PrivDecryptPKCS1(SECKEYPrivateKey *key, + unsigned char *data, unsigned *outLen, + unsigned int maxLen, + const unsigned char *enc, unsigned encLen); +/* The encrypt function that complements the above decrypt function. */ +SECStatus PK11_PubEncryptPKCS1(SECKEYPublicKey *key, + unsigned char *enc, + const unsigned char *data, unsigned dataLen, + void *wincx); + +SECStatus PK11_PrivDecrypt(SECKEYPrivateKey *key, + CK_MECHANISM_TYPE mechanism, SECItem *param, + unsigned char *out, unsigned int *outLen, + unsigned int maxLen, + const unsigned char *enc, unsigned int encLen); +SECStatus PK11_PubEncrypt(SECKEYPublicKey *key, + CK_MECHANISM_TYPE mechanism, SECItem *param, + unsigned char *out, unsigned int *outLen, + unsigned int maxLen, + const unsigned char *data, unsigned int dataLen, + void *wincx); + +SECStatus PK11_ImportPrivateKeyInfo(PK11SlotInfo *slot, + SECKEYPrivateKeyInfo *pki, SECItem *nickname, + SECItem *publicValue, PRBool isPerm, PRBool isPrivate, + unsigned int usage, void *wincx); +SECStatus PK11_ImportPrivateKeyInfoAndReturnKey(PK11SlotInfo *slot, + SECKEYPrivateKeyInfo *pki, SECItem *nickname, + SECItem *publicValue, PRBool isPerm, PRBool isPrivate, + unsigned int usage, SECKEYPrivateKey **privk, void *wincx); +SECStatus PK11_ImportDERPrivateKeyInfo(PK11SlotInfo *slot, + SECItem *derPKI, SECItem *nickname, + SECItem *publicValue, PRBool isPerm, PRBool isPrivate, + unsigned int usage, void *wincx); +SECStatus PK11_ImportDERPrivateKeyInfoAndReturnKey(PK11SlotInfo *slot, + SECItem *derPKI, SECItem *nickname, + SECItem *publicValue, PRBool isPerm, PRBool isPrivate, + unsigned int usage, SECKEYPrivateKey **privk, void *wincx); +SECStatus PK11_ImportEncryptedPrivateKeyInfo(PK11SlotInfo *slot, + SECKEYEncryptedPrivateKeyInfo *epki, SECItem *pwitem, + SECItem *nickname, SECItem *publicValue, PRBool isPerm, + PRBool isPrivate, KeyType type, + unsigned int usage, void *wincx); +SECStatus PK11_ImportEncryptedPrivateKeyInfoAndReturnKey(PK11SlotInfo *slot, + SECKEYEncryptedPrivateKeyInfo *epki, SECItem *pwitem, + SECItem *nickname, SECItem *publicValue, PRBool isPerm, + PRBool isPrivate, KeyType type, + unsigned int usage, SECKEYPrivateKey **privk, void *wincx); +SECItem *PK11_ExportDERPrivateKeyInfo(SECKEYPrivateKey *pk, void *wincx); +SECKEYPrivateKeyInfo *PK11_ExportPrivKeyInfo( + SECKEYPrivateKey *pk, void *wincx); +SECKEYPrivateKeyInfo *PK11_ExportPrivateKeyInfo( + CERTCertificate *cert, void *wincx); +SECKEYEncryptedPrivateKeyInfo *PK11_ExportEncryptedPrivKeyInfo( + PK11SlotInfo *slot, SECOidTag algTag, SECItem *pwitem, + SECKEYPrivateKey *pk, int iteration, void *pwArg); +SECKEYEncryptedPrivateKeyInfo *PK11_ExportEncryptedPrivateKeyInfo( + PK11SlotInfo *slot, SECOidTag algTag, SECItem *pwitem, + CERTCertificate *cert, int iteration, void *pwArg); +/* V2 refers to PKCS #5 V2 here. If a PKCS #5 v1 or PKCS #12 pbe is passed + * for pbeTag, then encTag and hashTag are ignored. If pbe is an encryption + * algorithm, then PKCS #5 V2 is used with prfTag for the prf. If prfTag isn't + * supplied prf will be SEC_OID_HMAC_SHA1 */ +SECKEYEncryptedPrivateKeyInfo *PK11_ExportEncryptedPrivKeyInfoV2( + PK11SlotInfo *slot, SECOidTag pbeTag, SECOidTag encTag, SECOidTag prfTag, + SECItem *pwitem, SECKEYPrivateKey *pk, int iteration, void *pwArg); +SECKEYEncryptedPrivateKeyInfo *PK11_ExportEncryptedPrivateKeyInfoV2( + PK11SlotInfo *slot, SECOidTag pbeTag, SECOidTag encTag, SECOidTag prfTag, + SECItem *pwitem, CERTCertificate *cert, int iteration, void *pwArg); +SECKEYPrivateKey *PK11_FindKeyByDERCert(PK11SlotInfo *slot, + CERTCertificate *cert, void *wincx); +SECKEYPublicKey *PK11_MakeKEAPubKey(unsigned char *data, int length); +SECStatus PK11_DigestKey(PK11Context *context, PK11SymKey *key); +PRBool PK11_VerifyKeyOK(PK11SymKey *key); +SECKEYPrivateKey *PK11_UnwrapPrivKey(PK11SlotInfo *slot, + PK11SymKey *wrappingKey, CK_MECHANISM_TYPE wrapType, + SECItem *param, SECItem *wrappedKey, SECItem *label, + SECItem *publicValue, PRBool token, PRBool sensitive, + CK_KEY_TYPE keyType, CK_ATTRIBUTE_TYPE *usage, int usageCount, + void *wincx); +SECStatus PK11_WrapPrivKey(PK11SlotInfo *slot, PK11SymKey *wrappingKey, + SECKEYPrivateKey *privKey, CK_MECHANISM_TYPE wrapType, + SECItem *param, SECItem *wrappedKey, void *wincx); +/* + * The caller of PK11_DEREncodePublicKey should free the returned SECItem with + * a SECITEM_FreeItem(..., PR_TRUE) call. + */ +SECItem *PK11_DEREncodePublicKey(const SECKEYPublicKey *pubk); +PK11SymKey *PK11_CopySymKeyForSigning(PK11SymKey *originalKey, + CK_MECHANISM_TYPE mech); +SECKEYPrivateKeyList *PK11_ListPrivKeysInSlot(PK11SlotInfo *slot, + char *nickname, void *wincx); +SECKEYPublicKeyList *PK11_ListPublicKeysInSlot(PK11SlotInfo *slot, + char *nickname); +SECKEYPQGParams *PK11_GetPQGParamsFromPrivateKey(SECKEYPrivateKey *privKey); +/* deprecated */ +SECKEYPrivateKeyList *PK11_ListPrivateKeysInSlot(PK11SlotInfo *slot); + +PK11SymKey *PK11_ConvertSessionSymKeyToTokenSymKey(PK11SymKey *symk, + void *wincx); +SECKEYPrivateKey *PK11_ConvertSessionPrivKeyToTokenPrivKey( + SECKEYPrivateKey *privk, void *wincx); +SECKEYPrivateKey *PK11_CopyTokenPrivKeyToSessionPrivKey(PK11SlotInfo *destSlot, + SECKEYPrivateKey *privKey); + +/********************************************************************** + * Certs + **********************************************************************/ +SECItem *PK11_MakeIDFromPubKey(SECItem *pubKeyData); +SECStatus PK11_TraverseSlotCerts( + SECStatus (*callback)(CERTCertificate *, SECItem *, void *), + void *arg, void *wincx); +CERTCertificate *PK11_FindCertFromNickname(const char *nickname, void *wincx); +CERTCertificate *PK11_FindCertFromURI(const char *uri, void *wincx); +CERTCertList *PK11_FindCertsFromURI(const char *uri, void *wincx); +CERTCertList *PK11_FindCertsFromEmailAddress(const char *email, void *wincx); +CERTCertList *PK11_FindCertsFromNickname(const char *nickname, void *wincx); +CERTCertificate *PK11_GetCertFromPrivateKey(SECKEYPrivateKey *privKey); +SECStatus PK11_ImportCert(PK11SlotInfo *slot, CERTCertificate *cert, + CK_OBJECT_HANDLE key, const char *nickname, + PRBool includeTrust); +SECStatus PK11_ImportDERCert(PK11SlotInfo *slot, SECItem *derCert, + CK_OBJECT_HANDLE key, char *nickname, PRBool includeTrust); +PK11SlotInfo *PK11_ImportCertForKey(CERTCertificate *cert, + const char *nickname, void *wincx); +PK11SlotInfo *PK11_ImportDERCertForKey(SECItem *derCert, char *nickname, + void *wincx); +PK11SlotInfo *PK11_KeyForCertExists(CERTCertificate *cert, + CK_OBJECT_HANDLE *keyPtr, void *wincx); +PK11SlotInfo *PK11_KeyForDERCertExists(SECItem *derCert, + CK_OBJECT_HANDLE *keyPtr, void *wincx); +CERTCertificate *PK11_FindCertByIssuerAndSN(PK11SlotInfo **slot, + CERTIssuerAndSN *sn, void *wincx); +CERTCertificate *PK11_FindCertAndKeyByRecipientList(PK11SlotInfo **slot, + SEC_PKCS7RecipientInfo **array, SEC_PKCS7RecipientInfo **rip, + SECKEYPrivateKey **privKey, void *wincx); +int PK11_FindCertAndKeyByRecipientListNew(NSSCMSRecipient **recipientlist, + void *wincx); +SECStatus PK11_TraverseCertsForSubjectInSlot(CERTCertificate *cert, + PK11SlotInfo *slot, SECStatus (*callback)(CERTCertificate *, void *), + void *arg); +CERTCertificate *PK11_FindCertFromDERCert(PK11SlotInfo *slot, + CERTCertificate *cert, void *wincx); +CERTCertificate *PK11_FindCertFromDERCertItem(PK11SlotInfo *slot, + const SECItem *derCert, void *wincx); +SECStatus PK11_ImportCertForKeyToSlot(PK11SlotInfo *slot, CERTCertificate *cert, + char *nickname, PRBool addUsage, + void *wincx); +CERTCertificate *PK11_FindBestKEAMatch(CERTCertificate *serverCert, void *wincx); +PRBool PK11_FortezzaHasKEA(CERTCertificate *cert); +CK_OBJECT_HANDLE PK11_FindEncodedCertInSlot(PK11SlotInfo *slot, SECItem *derCert, void *wincx); +CK_OBJECT_HANDLE PK11_FindCertInSlot(PK11SlotInfo *slot, CERTCertificate *cert, + void *wincx); +CK_OBJECT_HANDLE PK11_FindObjectForCert(CERTCertificate *cert, + void *wincx, PK11SlotInfo **pSlot); +SECStatus PK11_TraverseCertsForNicknameInSlot(SECItem *nickname, + PK11SlotInfo *slot, SECStatus (*callback)(CERTCertificate *, void *), + void *arg); +CERTCertList *PK11_ListCerts(PK11CertListType type, void *pwarg); +CERTCertList *PK11_ListCertsInSlot(PK11SlotInfo *slot); +CERTSignedCrl *PK11_ImportCRL(PK11SlotInfo *slot, SECItem *derCRL, char *url, + int type, void *wincx, PRInt32 importOptions, PLArenaPool *arena, PRInt32 decodeOptions); +CK_BBOOL PK11_HasAttributeSet(PK11SlotInfo *slot, + CK_OBJECT_HANDLE id, + CK_ATTRIBUTE_TYPE type, + PRBool haslock /* must be set to PR_FALSE */); + +/********************************************************************** + * Hybrid Public Key Encryption + **********************************************************************/ + +/* Some of the various HPKE arguments would ideally be const, but the + * underlying PK11 functions take them as non-const. To avoid lying to + * the application with a cast, this idiosyncrasy is exposed. */ +SECStatus PK11_HPKE_ValidateParameters(HpkeKemId kemId, HpkeKdfId kdfId, HpkeAeadId aeadId); +HpkeContext *PK11_HPKE_NewContext(HpkeKemId kemId, HpkeKdfId kdfId, HpkeAeadId aeadId, + PK11SymKey *psk, const SECItem *pskId); +SECStatus PK11_HPKE_Deserialize(const HpkeContext *cx, const PRUint8 *enc, + unsigned int encLen, SECKEYPublicKey **outPubKey); +void PK11_HPKE_DestroyContext(HpkeContext *cx, PRBool freeit); + +/* Serialize an initialized receiver context. This only retains the keys and + * associated information necessary to resume Export and Open operations after + * import. Serialization is currently supported for receiver contexts only. + * This is done for two reasons: 1) it avoids having to move the encryption + * sequence number outside of the token (or adding encryption context + * serialization support to softoken), and 2) we don't have to worry about IV + * reuse due to sequence number cloning. + * + * |wrapKey| is required when exporting in FIPS mode. If exported with a + * wrapping key, that same key must be provided to the import function, + * otherwise behavior is undefined. + * + * Even when exported with key wrap, HPKE expects the nonce to also be kept + * secret and that value is not protected by wrapKey. Applications are + * responsible for maintaining the confidentiality of the exported information. + */ +SECStatus PK11_HPKE_ExportContext(const HpkeContext *cx, PK11SymKey *wrapKey, SECItem **serialized); +SECStatus PK11_HPKE_ExportSecret(const HpkeContext *cx, const SECItem *info, unsigned int L, + PK11SymKey **outKey); + +/* + * Return a weak reference to SharedSecret stored in HPKE Context + */ +PK11SymKey *PK11_HPKE_GetSharedSecret(const HpkeContext *cx); +const SECItem *PK11_HPKE_GetEncapPubKey(const HpkeContext *cx); +HpkeContext *PK11_HPKE_ImportContext(const SECItem *serialized, PK11SymKey *wrapKey); +SECStatus PK11_HPKE_Open(HpkeContext *cx, const SECItem *aad, const SECItem *ct, SECItem **outPt); +SECStatus PK11_HPKE_Seal(HpkeContext *cx, const SECItem *aad, const SECItem *pt, SECItem **outCt); +SECStatus PK11_HPKE_Serialize(const SECKEYPublicKey *pk, PRUint8 *buf, unsigned int *len, unsigned int maxLen); +SECStatus PK11_HPKE_SetupS(HpkeContext *cx, const SECKEYPublicKey *pkE, SECKEYPrivateKey *skE, + SECKEYPublicKey *pkR, const SECItem *info); +SECStatus PK11_HPKE_SetupR(HpkeContext *cx, const SECKEYPublicKey *pkR, SECKEYPrivateKey *skR, + const SECItem *enc, const SECItem *info); + +/********************************************************************** + * Sign/Verify + **********************************************************************/ + +/* + * Return the length in bytes of a signature generated with the + * private key. + * + * Return 0 or -1 on failure. (XXX Should we fix it to always return + * -1 on failure?) + */ +int PK11_SignatureLen(SECKEYPrivateKey *key); +PK11SlotInfo *PK11_GetSlotFromPrivateKey(SECKEYPrivateKey *key); +SECStatus PK11_Sign(SECKEYPrivateKey *key, SECItem *sig, + const SECItem *hash); +SECStatus PK11_SignWithMechanism(SECKEYPrivateKey *key, + CK_MECHANISM_TYPE mechanism, + const SECItem *param, SECItem *sig, + const SECItem *hash); +SECStatus PK11_SignWithSymKey(PK11SymKey *symKey, CK_MECHANISM_TYPE mechanism, + SECItem *param, SECItem *sig, const SECItem *data); +SECStatus PK11_VerifyRecover(SECKEYPublicKey *key, const SECItem *sig, + SECItem *dsig, void *wincx); +SECStatus PK11_Verify(SECKEYPublicKey *key, const SECItem *sig, + const SECItem *hash, void *wincx); +SECStatus PK11_VerifyWithMechanism(SECKEYPublicKey *key, + CK_MECHANISM_TYPE mechanism, + const SECItem *param, const SECItem *sig, + const SECItem *hash, void *wincx); + +/********************************************************************** + * Key Encapsulation Mechanisms + **********************************************************************/ + +/* + * Using the given |pubKey|, generate a shared secret in |outKey| and an + * encapsulation of it in |ciphertext|. |outKey| will have usage attributes as + * specified in |attrFlags| and operation attributes as specified in |opFlags|. + * + * The function asserts that |pubKey|, |outKey|, and |ciphertext| are not NULL. + + * If an error occurs, no allocations are made to |outKey| and |ciphertext|; + * otherwise (if SECSuccess is returned) allocations are made to |outKey| and + * |ciphertext| and the caller is responsible for freeing the memory occupied + * by these structures. + */ +SECStatus PK11_Encapsulate(SECKEYPublicKey *pubKey, CK_MECHANISM_TYPE target, + PK11AttrFlags attrFlags, CK_FLAGS opFlags, + PK11SymKey **outKey, SECItem **outCiphertext); + +/* + * Using the given |privKey|, decapsulate |ciphertext| and put the resulting + * shared secret in |outKey|. |outKey| will have usage attributes as specified + * in |attrFlags| and operation attributes as specified in |opFlags|. + * + * The function asserts that |privKey|, |ciphertext|, and |outKey| are not NULL. + + * If an error occurs, |outKey| is not allocated; otherwise (if SECSuccess is + * returned) |outKey| is allocated and the caller is responsible for freeing + * the memory occupied by it. + */ +SECStatus +PK11_Decapsulate(SECKEYPrivateKey *privKey, const SECItem *ciphertext, + CK_MECHANISM_TYPE target, PK11AttrFlags attrFlags, + CK_FLAGS opFlags, PK11SymKey **outKey); + +/********************************************************************** + * Crypto Contexts + **********************************************************************/ +void PK11_DestroyContext(PK11Context *context, PRBool freeit); +PK11Context *PK11_CreateContextBySymKey(CK_MECHANISM_TYPE type, + CK_ATTRIBUTE_TYPE operation, + PK11SymKey *symKey, + const SECItem *param); +PK11Context *PK11_CreateSignatureContextByPubKey(CK_MECHANISM_TYPE type, + CK_ATTRIBUTE_TYPE operation, + SECKEYPublicKey *pubKey, + const SECItem *param, + const SECItem *sig, + void *pwArg); +PK11Context *PK11_CreateContextByPubKey(CK_MECHANISM_TYPE type, + CK_ATTRIBUTE_TYPE operation, + SECKEYPublicKey *pubKey, + const SECItem *param, void *pwArg); +PK11Context *PK11_CreateContextByPrivKey(CK_MECHANISM_TYPE type, + CK_ATTRIBUTE_TYPE operation, + SECKEYPrivateKey *privKey, + const SECItem *param); +PK11Context *PK11_CreateDigestContext(SECOidTag hashAlg); +PK11Context *PK11_CloneContext(PK11Context *old); +SECStatus PK11_DigestBegin(PK11Context *cx); +/* + * The output buffer 'out' must be big enough to hold the output of + * the hash algorithm 'hashAlg'. + */ +SECStatus PK11_HashBuf(SECOidTag hashAlg, unsigned char *out, + const unsigned char *in, PRInt32 len); +SECStatus PK11_DigestOp(PK11Context *context, const unsigned char *in, + unsigned len); +SECStatus PK11_CipherOp(PK11Context *context, unsigned char *out, int *outlen, + int maxout, const unsigned char *in, int inlen); +/* application builds the mechanism specific params */ +SECStatus PK11_AEADRawOp(PK11Context *context, void *params, int paramslen, + const unsigned char *aad, int aadlen, + unsigned char *out, int *outlen, + int maxout, const unsigned char *in, int inlen); +/* NSS builds the mechanism specific params */ +#if CRYPTOKI_VERSION_MAJOR >= 3 +SECStatus PK11_AEADOp(PK11Context *context, CK_ULONG ivGen, + int fixedbits, unsigned char *iv, int ivlen, + const unsigned char *aad, int aadlen, + unsigned char *out, int *outlen, + int maxout, unsigned char *tag, int taglen, + const unsigned char *in, int inlen); +#endif + +SECStatus PK11_Finalize(PK11Context *context); +SECStatus PK11_DigestFinal(PK11Context *context, unsigned char *data, + unsigned int *outLen, unsigned int length); +#define PK11_CipherFinal PK11_DigestFinal +SECStatus PK11_SaveContext(PK11Context *cx, unsigned char *save, + int *len, int saveLength); + +/* Save the context's state, with possible allocation. + * The caller may supply an already allocated buffer in preAllocBuf, + * with length pabLen. If the buffer is large enough for the context's + * state, it will receive the state. + * If the buffer is not large enough (or NULL), then a new buffer will + * be allocated with PORT_Alloc. + * In either case, the state will be returned as a buffer, and the length + * of the state will be given in *stateLen. + */ +unsigned char * +PK11_SaveContextAlloc(PK11Context *cx, + unsigned char *preAllocBuf, unsigned int pabLen, + unsigned int *stateLen); + +SECStatus PK11_RestoreContext(PK11Context *cx, unsigned char *save, int len); +SECStatus PK11_GenerateFortezzaIV(PK11SymKey *symKey, unsigned char *iv, int len); +void PK11_SetFortezzaHack(PK11SymKey *symKey); + +/********************************************************************** + * PBE functions + **********************************************************************/ + +/* This function creates PBE parameters from the given inputs. The result + * can be used to create a password integrity key for PKCS#12, by sending + * the return value to PK11_KeyGen along with the appropriate mechanism. + */ +SECItem * +PK11_CreatePBEParams(SECItem *salt, SECItem *pwd, unsigned int iterations); + +/* free params created above (can be called after keygen is done */ +void PK11_DestroyPBEParams(SECItem *params); + +SECAlgorithmID * +PK11_CreatePBEAlgorithmID(SECOidTag algorithm, int iteration, SECItem *salt); + +/* use to create PKCS5 V2 algorithms with finder control than that provided + * by PK11_CreatePBEAlgorithmID. */ +SECAlgorithmID * +PK11_CreatePBEV2AlgorithmID(SECOidTag pbeAlgTag, SECOidTag cipherAlgTag, + SECOidTag prfAlgTag, int keyLength, int iteration, + SECItem *salt); +PK11SymKey * +PK11_PBEKeyGen(PK11SlotInfo *slot, SECAlgorithmID *algid, SECItem *pwitem, + PRBool faulty3DES, void *wincx); + +/* warning: cannot work with PKCS 5 v2 use PK11_PBEKeyGen instead */ +PK11SymKey * +PK11_RawPBEKeyGen(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, SECItem *params, + SECItem *pwitem, PRBool faulty3DES, void *wincx); +SECItem * +PK11_GetPBEIV(SECAlgorithmID *algid, SECItem *pwitem); +/* + * Get the Mechanism and parameter of the base encryption or mac scheme from + * a PBE algorithm ID. + * Caller is responsible for freeing the return parameter (param). + */ +CK_MECHANISM_TYPE +PK11_GetPBECryptoMechanism(SECAlgorithmID *algid, + SECItem **param, SECItem *pwd); + +/********************************************************************** + * Functions to manage secmod flags + **********************************************************************/ +const PK11DefaultArrayEntry *PK11_GetDefaultArray(int *size); +SECStatus PK11_UpdateSlotAttribute(PK11SlotInfo *slot, + const PK11DefaultArrayEntry *entry, + PRBool add); + +/********************************************************************** + * Functions to look at PKCS #11 dependent data + **********************************************************************/ +PK11GenericObject *PK11_FindGenericObjects(PK11SlotInfo *slot, + CK_OBJECT_CLASS objClass); +PK11GenericObject *PK11_GetNextGenericObject(PK11GenericObject *object); +PK11GenericObject *PK11_GetPrevGenericObject(PK11GenericObject *object); +SECStatus PK11_UnlinkGenericObject(PK11GenericObject *object); +SECStatus PK11_LinkGenericObject(PK11GenericObject *list, + PK11GenericObject *object); +SECStatus PK11_DestroyGenericObjects(PK11GenericObject *object); +SECStatus PK11_DestroyGenericObject(PK11GenericObject *object); +PK11GenericObject *PK11_CreateManagedGenericObject(PK11SlotInfo *slot, + const CK_ATTRIBUTE *pTemplate, + int count, PRBool token); +/* deprecated */ +PK11GenericObject *PK11_CreateGenericObject(PK11SlotInfo *slot, + const CK_ATTRIBUTE *pTemplate, + int count, PRBool token); + +/* + * PK11_ReadRawAttribute and PK11_WriteRawAttribute are generic + * functions to read and modify the actual PKCS #11 attributes of + * the underlying pkcs #11 object. + * + * object is a pointer to an NSS object that represents the underlying + * PKCS #11 object. It's type must match the type of PK11ObjectType + * as follows: + * + * type object + * PK11_TypeGeneric PK11GenericObject * + * PK11_TypePrivKey SECKEYPrivateKey * + * PK11_TypePubKey SECKEYPublicKey * + * PK11_TypeSymKey PK11SymKey * + * + * All other types are considered invalid. If type does not match the object + * passed, unpredictable results will occur. + * + * PK11_ReadRawAttribute allocates the buffer for returning the attribute + * value. The caller of PK11_ReadRawAttribute should free the data buffer + * pointed to by item using a SECITEM_FreeItem(item, PR_FALSE) or + * PORT_Free(item->data) call. + */ +SECStatus PK11_ReadRawAttribute(PK11ObjectType type, void *object, + CK_ATTRIBUTE_TYPE attr, SECItem *item); +SECStatus PK11_ReadRawAttributes(PLArenaPool *arena, PK11ObjectType type, void *object, + CK_ATTRIBUTE *pTemplate, unsigned int count); +SECStatus PK11_WriteRawAttribute(PK11ObjectType type, void *object, + CK_ATTRIBUTE_TYPE attr, SECItem *item); +/* get the PKCS #11 handle and slot for a generic object */ +CK_OBJECT_HANDLE PK11_GetObjectHandle(PK11ObjectType objType, void *objSpec, + PK11SlotInfo **slotp); + +/* PK11_ReadDistrustAfterAttribute reads either the + * CKA_NSS_SERVER_DISTRUST_AFTER or the CKA_NSS_EMAIL_DISTRUST_AFTER attribute + * from the specified object. The "CK_ATTRIBUTE_TYPE type" input must be one of + * these. If this function returns SECSuccess, then an attribute of the + * requested type was found and it was either: + * (1) a single zero byte (indicating no distrust after date), or + * (2) a valid 13 byte UTCTime. + * In case (1), the value *distrusted is set to PR_FALSE and the value *time + * is undefined. In case (2), the value *distrusted is set to PR_TRUE and the + * value *time is set by DER_UTCTimeToTime(). Neither *distrusted nor *time + * is defined if this function returns SECFailure. + */ +SECStatus PK11_ReadDistrustAfterAttribute(PK11SlotInfo *slot, + CK_OBJECT_HANDLE object, + CK_ATTRIBUTE_TYPE type, + /* out */ PRBool *distrusted, + /* out */ PRTime *time); + +/* + * PK11_GetAllSlotsForCert returns all the slots that a given certificate + * exists on, since it's possible for a cert to exist on more than one + * PKCS#11 token. + */ +PK11SlotList * +PK11_GetAllSlotsForCert(CERTCertificate *cert, void *arg); + +/* + * Finds all certificates on the given slot with the given subject distinguished + * name and returns them as DER bytes. If no such certificates can be found, + * returns SECSuccess and sets *results to NULL. If a failure is encountered + * while fetching any of the matching certificates, SECFailure is returned and + * *results will be NULL. + */ +SECStatus +PK11_FindRawCertsWithSubject(PK11SlotInfo *slot, SECItem *derSubject, + CERTCertificateList **results); + +/* + * Finds and returns all certificates with a public key that matches the given + * private key. May return an empty list if no certificates match. Returns NULL + * if a failure is encountered. + */ +CERTCertList * +PK11_GetCertsMatchingPrivateKey(SECKEYPrivateKey *privKey); + +/********************************************************************** + * New functions which are already deprecated.... + **********************************************************************/ +SECItem * +PK11_GetLowLevelKeyIDForCert(PK11SlotInfo *slot, + CERTCertificate *cert, void *pwarg); +SECItem * +PK11_GetLowLevelKeyIDForPrivateKey(SECKEYPrivateKey *key); + +PRBool SECMOD_HasRootCerts(void); + +/********************************************************************** + * Other Utilities + **********************************************************************/ +/* + * Get the state of the system FIPS mode - + * NSS uses this to force FIPS mode if the system bit is on. This returns + * the system state independent of the database state and can be called + * before NSS initializes. + */ +int SECMOD_GetSystemFIPSEnabled(void); + +/* FIPS indicator functions. Some operations are physically allowed, but + * are against the NSS FIPS security policy. This is because sometimes NSS + * functions are used in non-security contexts. You can call these functions + * to determine if you are operating inside or outside the the current vendor's + * FIPS Security Policy for NSS. NOTE: if the current version of NSS is not + * actually FIPS certified, then these functions will always return PR_FALSE */ + +/* This function tells if if the last single shot operation on the slot + * was inside or outside the FIPS security policy */ +PRBool PK11_SlotGetLastFIPSStatus(PK11SlotInfo *slot); +/* This tells you if the current operation is within the FIPS security policy. If + * you have called finalize on the context, it tells you if the last operation + * was within the FIPS security policy */ +PRBool PK11_ContextGetFIPSStatus(PK11Context *context); +/* This tells you if the requested object was created in accordance to the + * NSS FIPS security policy. */ +PRBool PK11_ObjectGetFIPSStatus(PK11ObjectType objType, void *objSpec); + +SEC_END_PROTOS + +#endif diff --git a/illumos-x86_64/usr/include/mps/pk11sdr.h b/illumos-x86_64/usr/include/mps/pk11sdr.h new file mode 100644 index 00000000..571c576e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pk11sdr.h @@ -0,0 +1,39 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _PK11SDR_H_ +#define _PK11SDR_H_ + +#include "pkcs11t.h" +#include "seccomon.h" +#include "secmodt.h" + +SEC_BEGIN_PROTOS + +/* + * PK11SDR_Encrypt + * Deprecated version of PK11SDR_EncryptWithMechanism using DES3_CBC. + */ +SECStatus +PK11SDR_Encrypt(SECItem *keyid, SECItem *data, SECItem *result, void *cx); + +/* + * PK11SDR_EncryptWithMechanism + * Encrypt a block of data using the symmetric key identified and the + * encryption mechanism specified (only AES_CBC and DES3_CBC are supported). + * The result is an ASN.1 (DER) encoded block of keyid, params and data. + */ +SECStatus +PK11SDR_EncryptWithMechanism(PK11SlotInfo *slot, SECItem *keyid, CK_MECHANISM_TYPE type, SECItem *data, SECItem *result, void *cx); + +/* + * PK11SDR_Decrypt - decrypt data previously encrypted with PK11SDR_Encrypt + * result should be freed with SECItem_ZfreeItem + */ +SECStatus +PK11SDR_Decrypt(SECItem *data, SECItem *result, void *cx); + +SEC_END_PROTOS + +#endif diff --git a/illumos-x86_64/usr/include/mps/pkcs11.h b/illumos-x86_64/usr/include/mps/pkcs11.h new file mode 100644 index 00000000..a3814159 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs11.h @@ -0,0 +1,288 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* + * Copyright (C) 1994-1999 RSA Security Inc. Licence to copy this document + * is granted provided that it is identified as "RSA Security In.c Public-Key + * Cryptography Standards (PKCS)" in all material mentioning or referencing + * this document. + * + * The latest version of this header can be found at: + * http://www.rsalabs.com/pkcs/pkcs-11/index.html + */ +#ifndef _PKCS11_H_ +#define _PKCS11_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Before including this file (pkcs11.h) (or pkcs11t.h by + * itself), 6 platform-specific macros must be defined. These + * macros are described below, and typical definitions for them + * are also given. Be advised that these definitions can depend + * on both the platform and the compiler used (and possibly also + * on whether a PKCS #11 library is linked statically or + * dynamically). + * + * In addition to defining these 6 macros, the packing convention + * for PKCS #11 structures should be set. The PKCS #11 + * convention on packing is that structures should be 1-byte + * aligned. + * + * In a Win32 environment, this might be done by using the + * following preprocessor directive before including pkcs11.h + * or pkcs11t.h: + * + * #pragma pack(push, cryptoki, 1) + * + * and using the following preprocessor directive after including + * pkcs11.h or pkcs11t.h: + * + * #pragma pack(pop, cryptoki) + * + * In a UNIX environment, you're on your own here. You might + * not need to do anything. + * + * + * Now for the macros: + * + * + * 1. CK_PTR: The indirection string for making a pointer to an + * object. It can be used like this: + * + * typedef CK_BYTE CK_PTR CK_BYTE_PTR; + * + * In a Win32 environment, it might be defined by + * + * #define CK_PTR * + * + * In a UNIX environment, it might be defined by + * + * #define CK_PTR * + * + * + * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes + * an exportable PKCS #11 library function definition out of a + * return type and a function name. It should be used in the + * following fashion to define the exposed PKCS #11 functions in + * a PKCS #11 library: + * + * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)( + * CK_VOID_PTR pReserved + * ) + * { + * ... + * } + * + * For defining a function in a Win32 PKCS #11 .dll, it might be + * defined by + * + * #define CK_DEFINE_FUNCTION(returnType, name) \ + * returnType __declspec(dllexport) name + * + * In a UNIX environment, it might be defined by + * + * #define CK_DEFINE_FUNCTION(returnType, name) \ + * returnType name + * + * + * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes + * an importable PKCS #11 library function declaration out of a + * return type and a function name. It should be used in the + * following fashion: + * + * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)( + * CK_VOID_PTR pReserved + * ); + * + * For declaring a function in a Win32 PKCS #11 .dll, it might + * be defined by + * + * #define CK_DECLARE_FUNCTION(returnType, name) \ + * returnType __declspec(dllimport) name + * + * In a UNIX environment, it might be defined by + * + * #define CK_DECLARE_FUNCTION(returnType, name) \ + * returnType name + * + * + * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro + * which makes a PKCS #11 API function pointer declaration or + * function pointer type declaration out of a return type and a + * function name. It should be used in the following fashion: + * + * // Define funcPtr to be a pointer to a PKCS #11 API function + * // taking arguments args and returning CK_RV. + * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args); + * + * or + * + * // Define funcPtrType to be the type of a pointer to a + * // PKCS #11 API function taking arguments args and returning + * // CK_RV, and then define funcPtr to be a variable of type + * // funcPtrType. + * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args); + * funcPtrType funcPtr; + * + * For accessing functions in a Win32 PKCS #11 .dll, in might be + * defined by + * + * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ + * returnType __declspec(dllimport) (* name) + * + * In a UNIX environment, it might be defined by + * + * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ + * returnType (* name) + * + * + * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes + * a function pointer type for an application callback out of + * a return type for the callback and a name for the callback. + * It should be used in the following fashion: + * + * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args); + * + * to declare a function pointer, myCallback, to a callback + * which takes arguments args and returns a CK_RV. It can also + * be used like this: + * + * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args); + * myCallbackType myCallback; + * + * In a Win32 environment, it might be defined by + * + * #define CK_CALLBACK_FUNCTION(returnType, name) \ + * returnType (* name) + * + * In a UNIX environment, it might be defined by + * + * #define CK_CALLBACK_FUNCTION(returnType, name) \ + * returnType (* name) + * + * + * 6. NULL_PTR: This macro is the value of a NULL pointer. + * + * In any ANSI/ISO C environment (and in many others as well), + * this should be defined by + * + * #ifndef NULL_PTR + * #define NULL_PTR 0 + * #endif + */ + +/* All the various PKCS #11 types and #define'd values are in the + * file pkcs11t.h. */ +#include "pkcs11t.h" + +#define __PASTE(x, y) x##y + +/* some applications use pkcs11f.h to build their own tables of functions. + * we make them explicitly state what functions they want. Now we set up to + * get all of them */ +#ifndef CK_PKCS11_3_2 +/* remember that we set it so we can unset it at the end */ +#define __NSS_CK_PKCS11_3_2_IMPLICIT 1 +#define CK_PKCS11_3_2 1 +#endif + +/* ============================================================== + * Define the "extern" form of all the entry points. + * ============================================================== + */ + +#define CK_NEED_ARG_LIST 1 +#define CK_PKCS11_FUNCTION_INFO(name) \ + CK_DECLARE_FUNCTION(CK_RV, name) + +/* pkcs11f.h has all the information about the PKCS #11 + * function prototypes. */ +#include "pkcs11f.h" + +#undef CK_NEED_ARG_LIST +#undef CK_PKCS11_FUNCTION_INFO + +/* ============================================================== + * Define the typedef form of all the entry points. That is, for + * each PKCS #11 function C_XXX, define a type CK_C_XXX which is + * a pointer to that kind of function. + * ============================================================== + */ + +#define CK_NEED_ARG_LIST 1 +#define CK_PKCS11_FUNCTION_INFO(name) \ + typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_, name)) + +/* pkcs11f.h has all the information about the PKCS #11 + * function prototypes. */ +#include "pkcs11f.h" + +#undef CK_NEED_ARG_LIST +#undef CK_PKCS11_FUNCTION_INFO + +/* ============================================================== + * Define structed vector of entry points. A CK_FUNCTION_3_0_LIST + * contains a CK_VERSION indicating a library's PKCS #11 version + * and then a whole slew of function pointers to the routines in + * the library. This type was declared, but not defined, in + * pkcs11t.h. + * ============================================================== + */ + +#define CK_PKCS11_FUNCTION_INFO(name) \ + __PASTE(CK_, name) \ + name; + +#include "pkcs11p.h" +struct CK_FUNCTION_LIST_3_2 { + + CK_VERSION version; /* PKCS #11 version */ + +/* Pile all the function pointers into the CK_FUNCTION_LIST_3_0. */ +/* pkcs11f.h has all the information about the PKCS #11 + * function prototypes. */ +#include "pkcs11f.h" +}; + +#define CK_PKCS11_3_0_ONLY 1 +struct CK_FUNCTION_LIST_3_0 { + + CK_VERSION version; /* PKCS #11 version */ + +/* Pile all the function pointers into the CK_FUNCTION_LIST_3_0. */ +/* pkcs11f.h has all the information about the PKCS #11 + * function prototypes. */ +#include "pkcs11f.h" +}; +#undef CK_PKCS11_3_0_ONLY + +#define CK_PKCS11_2_0_ONLY 1 + +/* now define the 2.0 function list */ +struct CK_FUNCTION_LIST { + + CK_VERSION version; /* PKCS #11 version */ + +/* Pile all the function pointers into the CK_FUNCTION_LIST. */ +/* pkcs11f.h has all the information about the PKCS #11 + * function prototypes. */ +#include "pkcs11f.h" +}; +#include "pkcs11u.h" + +#undef CK_PKCS11_FUNCTION_INFO +#undef CK_PKCS11_2_0_ONLY + +#ifdef __NSS_CK_PKCS11_3_2_IMPLICIT +#undef CK_PKCS11_3_2 +#undef __NSS_CK_PKCS11_3_2_IMPLICIT +#endif +#undef __PASTE + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/mps/pkcs11f.h b/illumos-x86_64/usr/include/mps/pkcs11f.h new file mode 100644 index 00000000..147f8ac6 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs11f.h @@ -0,0 +1,1166 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* + * Copyright (C) 1994-1999 RSA Security Inc. Licence to copy this document + * is granted provided that it is identified as "RSA Security In.c Public-Key + * Cryptography Standards (PKCS)" in all material mentioning or referencing + * this document. + */ +/* This function contains pretty much everything about all the */ +/* PKCS #11 function prototypes. Because this information is */ +/* used for more than just declaring function prototypes, the */ +/* order of the functions appearing herein is important, and */ +/* should not be altered. */ + +/* General-purpose */ + +/* C_Initialize initializes the PKCS #11 library. */ +CK_PKCS11_FUNCTION_INFO(C_Initialize) +#ifdef CK_NEED_ARG_LIST +( + CK_VOID_PTR pInitArgs /* if this is not NULL_PTR, it gets + * cast to CK_C_INITIALIZE_ARGS_PTR + * and dereferenced */ +); +#endif + +/* C_Finalize indicates that an application is done with the + * PKCS #11 library. */ +CK_PKCS11_FUNCTION_INFO(C_Finalize) +#ifdef CK_NEED_ARG_LIST +( + CK_VOID_PTR pReserved /* reserved. Should be NULL_PTR */ +); +#endif + +/* C_GetInfo returns general information about PKCS #11. */ +CK_PKCS11_FUNCTION_INFO(C_GetInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_INFO_PTR pInfo /* location that receives information */ +); +#endif + +/* C_GetFunctionList returns the function list. */ +CK_PKCS11_FUNCTION_INFO(C_GetFunctionList) +#ifdef CK_NEED_ARG_LIST +( + CK_FUNCTION_LIST_PTR_PTR ppFunctionList /* receives pointer to + * function list */ +); +#endif + +/* Slot and token management */ + +/* C_GetSlotList obtains a list of slots in the system. */ +CK_PKCS11_FUNCTION_INFO(C_GetSlotList) +#ifdef CK_NEED_ARG_LIST +( + CK_BBOOL tokenPresent, /* only slots with tokens? */ + CK_SLOT_ID_PTR pSlotList, /* receives array of slot IDs */ + CK_ULONG_PTR pulCount /* receives number of slots */ +); +#endif + +/* C_GetSlotInfo obtains information about a particular slot in + * the system. */ +CK_PKCS11_FUNCTION_INFO(C_GetSlotInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* the ID of the slot */ + CK_SLOT_INFO_PTR pInfo /* receives the slot information */ +); +#endif + +/* C_GetTokenInfo obtains information about a particular token + * in the system. */ +CK_PKCS11_FUNCTION_INFO(C_GetTokenInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* ID of the token's slot */ + CK_TOKEN_INFO_PTR pInfo /* receives the token information */ +); +#endif + +/* C_GetMechanismList obtains a list of mechanism types + * supported by a token. */ +CK_PKCS11_FUNCTION_INFO(C_GetMechanismList) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* ID of token's slot */ + CK_MECHANISM_TYPE_PTR pMechanismList, /* gets mech. array */ + CK_ULONG_PTR pulCount /* gets # of mechs. */ +); +#endif + +/* C_GetMechanismInfo obtains information about a particular + * mechanism possibly supported by a token. */ +CK_PKCS11_FUNCTION_INFO(C_GetMechanismInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* ID of the token's slot */ + CK_MECHANISM_TYPE type, /* type of mechanism */ + CK_MECHANISM_INFO_PTR pInfo /* receives mechanism info */ +); +#endif + +/* C_InitToken initializes a token. */ +CK_PKCS11_FUNCTION_INFO(C_InitToken) +#ifdef CK_NEED_ARG_LIST +/* pLabel changed from CK_CHAR_PTR to CK_UTF8CHAR_PTR for v2.10 */ +( + CK_SLOT_ID slotID, /* ID of the token's slot */ + CK_UTF8CHAR_PTR pPin, /* the SO's initial PIN */ + CK_ULONG ulPinLen, /* length in bytes of the PIN */ + CK_UTF8CHAR_PTR pLabel /* 32-byte token label (blank padded) */ +); +#endif + +/* C_InitPIN initializes the normal user's PIN. */ +CK_PKCS11_FUNCTION_INFO(C_InitPIN) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_UTF8CHAR_PTR pPin, /* the normal user's PIN */ + CK_ULONG ulPinLen /* length in bytes of the PIN */ +); +#endif + +/* C_SetPIN modifies the PIN of the user who is logged in. */ +CK_PKCS11_FUNCTION_INFO(C_SetPIN) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_UTF8CHAR_PTR pOldPin, /* the old PIN */ + CK_ULONG ulOldLen, /* length of the old PIN */ + CK_UTF8CHAR_PTR pNewPin, /* the new PIN */ + CK_ULONG ulNewLen /* length of the new PIN */ +); +#endif + +/* Session management */ + +/* C_OpenSession opens a session between an application and a + * token. */ +CK_PKCS11_FUNCTION_INFO(C_OpenSession) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* the slot's ID */ + CK_FLAGS flags, /* from CK_SESSION_INFO */ + CK_VOID_PTR pApplication, /* passed to callback */ + CK_NOTIFY Notify, /* callback function */ + CK_SESSION_HANDLE_PTR phSession /* gets session handle */ +); +#endif + +/* C_CloseSession closes a session between an application and a + * token. */ +CK_PKCS11_FUNCTION_INFO(C_CloseSession) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + +/* C_CloseAllSessions closes all sessions with a token. */ +CK_PKCS11_FUNCTION_INFO(C_CloseAllSessions) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID /* the token's slot */ +); +#endif + +/* C_GetSessionInfo obtains information about the session. */ +CK_PKCS11_FUNCTION_INFO(C_GetSessionInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_SESSION_INFO_PTR pInfo /* receives session info */ +); +#endif + +/* C_GetOperationState obtains the state of the cryptographic operation + * in a session. */ +CK_PKCS11_FUNCTION_INFO(C_GetOperationState) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pOperationState, /* gets state */ + CK_ULONG_PTR pulOperationStateLen /* gets state length */ +); +#endif + +/* C_SetOperationState restores the state of the cryptographic + * operation in a session. */ +CK_PKCS11_FUNCTION_INFO(C_SetOperationState) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pOperationState, /* holds state */ + CK_ULONG ulOperationStateLen, /* holds state length */ + CK_OBJECT_HANDLE hEncryptionKey, /* en/decryption key */ + CK_OBJECT_HANDLE hAuthenticationKey /* sign/verify key */ +); +#endif + +/* C_Login logs a user into a token. */ +CK_PKCS11_FUNCTION_INFO(C_Login) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_USER_TYPE userType, /* the user type */ + CK_UTF8CHAR_PTR pPin, /* the user's PIN */ + CK_ULONG ulPinLen /* the length of the PIN */ +); +#endif + +/* C_Logout logs a user out from a token. */ +CK_PKCS11_FUNCTION_INFO(C_Logout) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + +/* Object management */ + +/* C_CreateObject creates a new object. */ +CK_PKCS11_FUNCTION_INFO(C_CreateObject) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* the object's template */ + CK_ULONG ulCount, /* attributes in template */ + CK_OBJECT_HANDLE_PTR phObject /* gets new object's handle. */ +); +#endif + +/* C_CopyObject copies an object, creating a new object for the + * copy. */ +CK_PKCS11_FUNCTION_INFO(C_CopyObject) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject, /* the object's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* template for new object */ + CK_ULONG ulCount, /* attributes in template */ + CK_OBJECT_HANDLE_PTR phNewObject /* receives handle of copy */ +); +#endif + +/* C_DestroyObject destroys an object. */ +CK_PKCS11_FUNCTION_INFO(C_DestroyObject) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject /* the object's handle */ +); +#endif + +/* C_GetObjectSize gets the size of an object in bytes. */ +CK_PKCS11_FUNCTION_INFO(C_GetObjectSize) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject, /* the object's handle */ + CK_ULONG_PTR pulSize /* receives size of object */ +); +#endif + +/* C_GetAttributeValue obtains the value of one or more object + * attributes. */ +CK_PKCS11_FUNCTION_INFO(C_GetAttributeValue) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject, /* the object's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs; gets vals */ + CK_ULONG ulCount /* attributes in template */ +); +#endif + +/* C_SetAttributeValue modifies the value of one or more object + * attributes */ +CK_PKCS11_FUNCTION_INFO(C_SetAttributeValue) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject, /* the object's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs and values */ + CK_ULONG ulCount /* attributes in template */ +); +#endif + +/* C_FindObjectsInit initializes a search for token and session + * objects that match a template. */ +CK_PKCS11_FUNCTION_INFO(C_FindObjectsInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* attribute values to match */ + CK_ULONG ulCount /* attrs in search template */ +); +#endif + +/* C_FindObjects continues a search for token and session + * objects that match a template, obtaining additional object + * handles. */ +CK_PKCS11_FUNCTION_INFO(C_FindObjects) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_OBJECT_HANDLE_PTR phObject, /* gets obj. handles */ + CK_ULONG ulMaxObjectCount, /* max handles to get */ + CK_ULONG_PTR pulObjectCount /* actual # returned */ +); +#endif + +/* C_FindObjectsFinal finishes a search for token and session + * objects. */ +CK_PKCS11_FUNCTION_INFO(C_FindObjectsFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + +/* Encryption and decryption */ + +/* C_EncryptInit initializes an encryption operation. */ +CK_PKCS11_FUNCTION_INFO(C_EncryptInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the encryption mechanism */ + CK_OBJECT_HANDLE hKey /* handle of encryption key */ +); +#endif + +/* C_Encrypt encrypts single-part data. */ +CK_PKCS11_FUNCTION_INFO(C_Encrypt) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pData, /* the plaintext data */ + CK_ULONG ulDataLen, /* bytes of plaintext */ + CK_BYTE_PTR pEncryptedData, /* gets ciphertext */ + CK_ULONG_PTR pulEncryptedDataLen /* gets c-text size */ +); +#endif + +/* C_EncryptUpdate continues a multiple-part encryption + * operation. */ +CK_PKCS11_FUNCTION_INFO(C_EncryptUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pPart, /* the plaintext data */ + CK_ULONG ulPartLen, /* plaintext data len */ + CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ + CK_ULONG_PTR pulEncryptedPartLen /* gets c-text size */ +); +#endif + +/* C_EncryptFinal finishes a multiple-part encryption + * operation. */ +CK_PKCS11_FUNCTION_INFO(C_EncryptFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session handle */ + CK_BYTE_PTR pLastEncryptedPart, /* last c-text */ + CK_ULONG_PTR pulLastEncryptedPartLen /* gets last size */ +); +#endif + +/* C_DecryptInit initializes a decryption operation. */ +CK_PKCS11_FUNCTION_INFO(C_DecryptInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the decryption mechanism */ + CK_OBJECT_HANDLE hKey /* handle of decryption key */ +); +#endif + +/* C_Decrypt decrypts encrypted data in a single part. */ +CK_PKCS11_FUNCTION_INFO(C_Decrypt) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pEncryptedData, /* ciphertext */ + CK_ULONG ulEncryptedDataLen, /* ciphertext length */ + CK_BYTE_PTR pData, /* gets plaintext */ + CK_ULONG_PTR pulDataLen /* gets p-text size */ +); +#endif + +/* C_DecryptUpdate continues a multiple-part decryption + * operation. */ +CK_PKCS11_FUNCTION_INFO(C_DecryptUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pEncryptedPart, /* encrypted data */ + CK_ULONG ulEncryptedPartLen, /* input length */ + CK_BYTE_PTR pPart, /* gets plaintext */ + CK_ULONG_PTR pulPartLen /* p-text size */ +); +#endif + +/* C_DecryptFinal finishes a multiple-part decryption + * operation. */ +CK_PKCS11_FUNCTION_INFO(C_DecryptFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pLastPart, /* gets plaintext */ + CK_ULONG_PTR pulLastPartLen /* p-text size */ +); +#endif + +/* Message digesting */ + +/* C_DigestInit initializes a message-digesting operation. */ +CK_PKCS11_FUNCTION_INFO(C_DigestInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism /* the digesting mechanism */ +); +#endif + +/* C_Digest digests data in a single part. */ +CK_PKCS11_FUNCTION_INFO(C_Digest) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pData, /* data to be digested */ + CK_ULONG ulDataLen, /* bytes of data to digest */ + CK_BYTE_PTR pDigest, /* gets the message digest */ + CK_ULONG_PTR pulDigestLen /* gets digest length */ +); +#endif + +/* C_DigestUpdate continues a multiple-part message-digesting + * operation. */ +CK_PKCS11_FUNCTION_INFO(C_DigestUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pPart, /* data to be digested */ + CK_ULONG ulPartLen /* bytes of data to be digested */ +); +#endif + +/* C_DigestKey continues a multi-part message-digesting + * operation, by digesting the value of a secret key as part of + * the data already digested. */ +CK_PKCS11_FUNCTION_INFO(C_DigestKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hKey /* secret key to digest */ +); +#endif + +/* C_DigestFinal finishes a multiple-part message-digesting + * operation. */ +CK_PKCS11_FUNCTION_INFO(C_DigestFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pDigest, /* gets the message digest */ + CK_ULONG_PTR pulDigestLen /* gets byte count of digest */ +); +#endif + +/* Signing and MACing */ + +/* C_SignInit initializes a signature (private key encryption) + * operation, where the signature is (will be) an appendix to + * the data, and plaintext cannot be recovered from the + *signature. */ +CK_PKCS11_FUNCTION_INFO(C_SignInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the signature mechanism */ + CK_OBJECT_HANDLE hKey /* handle of signature key */ +); +#endif + +/* C_Sign signs (encrypts with private key) data in a single + * part, where the signature is (will be) an appendix to the + * data, and plaintext cannot be recovered from the signature. */ +CK_PKCS11_FUNCTION_INFO(C_Sign) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pData, /* the data to sign */ + CK_ULONG ulDataLen, /* count of bytes to sign */ + CK_BYTE_PTR pSignature, /* gets the signature */ + CK_ULONG_PTR pulSignatureLen /* gets signature length */ +); +#endif + +/* C_SignUpdate continues a multiple-part signature operation, + * where the signature is (will be) an appendix to the data, + * and plaintext cannot be recovered from the signature. */ +CK_PKCS11_FUNCTION_INFO(C_SignUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pPart, /* the data to sign */ + CK_ULONG ulPartLen /* count of bytes to sign */ +); +#endif + +/* C_SignFinal finishes a multiple-part signature operation, + * returning the signature. */ +CK_PKCS11_FUNCTION_INFO(C_SignFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pSignature, /* gets the signature */ + CK_ULONG_PTR pulSignatureLen /* gets signature length */ +); +#endif + +/* C_SignRecoverInit initializes a signature operation, where + * the data can be recovered from the signature. */ +CK_PKCS11_FUNCTION_INFO(C_SignRecoverInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the signature mechanism */ + CK_OBJECT_HANDLE hKey /* handle of the signature key */ +); +#endif + +/* C_SignRecover signs data in a single operation, where the + * data can be recovered from the signature. */ +CK_PKCS11_FUNCTION_INFO(C_SignRecover) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pData, /* the data to sign */ + CK_ULONG ulDataLen, /* count of bytes to sign */ + CK_BYTE_PTR pSignature, /* gets the signature */ + CK_ULONG_PTR pulSignatureLen /* gets signature length */ +); +#endif + +/* Verifying signatures and MACs */ + +/* C_VerifyInit initializes a verification operation, where the + * signature is an appendix to the data, and plaintext cannot + * cannot be recovered from the signature (e.g. DSA). */ +CK_PKCS11_FUNCTION_INFO(C_VerifyInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the verification mechanism */ + CK_OBJECT_HANDLE hKey /* verification key */ +); +#endif + +/* C_Verify verifies a signature in a single-part operation, + * where the signature is an appendix to the data, and plaintext + * cannot be recovered from the signature. */ +CK_PKCS11_FUNCTION_INFO(C_Verify) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pData, /* signed data */ + CK_ULONG ulDataLen, /* length of signed data */ + CK_BYTE_PTR pSignature, /* signature */ + CK_ULONG ulSignatureLen /* signature length*/ +); +#endif + +/* C_VerifyUpdate continues a multiple-part verification + * operation, where the signature is an appendix to the data, + * and plaintext cannot be recovered from the signature. */ +CK_PKCS11_FUNCTION_INFO(C_VerifyUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pPart, /* signed data */ + CK_ULONG ulPartLen /* length of signed data */ +); +#endif + +/* C_VerifyFinal finishes a multiple-part verification + * operation, checking the signature. */ +CK_PKCS11_FUNCTION_INFO(C_VerifyFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pSignature, /* signature to verify */ + CK_ULONG ulSignatureLen /* signature length */ +); +#endif + +/* C_VerifyRecoverInit initializes a signature verification + * operation, where the data is recovered from the signature. */ +CK_PKCS11_FUNCTION_INFO(C_VerifyRecoverInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the verification mechanism */ + CK_OBJECT_HANDLE hKey /* verification key */ +); +#endif + +/* C_VerifyRecover verifies a signature in a single-part + * operation, where the data is recovered from the signature. */ +CK_PKCS11_FUNCTION_INFO(C_VerifyRecover) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pSignature, /* signature to verify */ + CK_ULONG ulSignatureLen, /* signature length */ + CK_BYTE_PTR pData, /* gets signed data */ + CK_ULONG_PTR pulDataLen /* gets signed data len */ +); +#endif + +/* Dual-function cryptographic operations */ + +/* C_DigestEncryptUpdate continues a multiple-part digesting + * and encryption operation. */ +CK_PKCS11_FUNCTION_INFO(C_DigestEncryptUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pPart, /* the plaintext data */ + CK_ULONG ulPartLen, /* plaintext length */ + CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ + CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */ +); +#endif + +/* C_DecryptDigestUpdate continues a multiple-part decryption and + * digesting operation. */ +CK_PKCS11_FUNCTION_INFO(C_DecryptDigestUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pEncryptedPart, /* ciphertext */ + CK_ULONG ulEncryptedPartLen, /* ciphertext length */ + CK_BYTE_PTR pPart, /* gets plaintext */ + CK_ULONG_PTR pulPartLen /* gets plaintext len */ +); +#endif + +/* C_SignEncryptUpdate continues a multiple-part signing and + * encryption operation. */ +CK_PKCS11_FUNCTION_INFO(C_SignEncryptUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pPart, /* the plaintext data */ + CK_ULONG ulPartLen, /* plaintext length */ + CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ + CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */ +); +#endif + +/* C_DecryptVerifyUpdate continues a multiple-part decryption and + * verify operation. */ +CK_PKCS11_FUNCTION_INFO(C_DecryptVerifyUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pEncryptedPart, /* ciphertext */ + CK_ULONG ulEncryptedPartLen, /* ciphertext length */ + CK_BYTE_PTR pPart, /* gets plaintext */ + CK_ULONG_PTR pulPartLen /* gets p-text length */ +); +#endif + +/* Key management */ + +/* C_GenerateKey generates a secret key, creating a new key + * object. */ +CK_PKCS11_FUNCTION_INFO(C_GenerateKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* key generation mech. */ + CK_ATTRIBUTE_PTR pTemplate, /* template for new key */ + CK_ULONG ulCount, /* # of attrs in template */ + CK_OBJECT_HANDLE_PTR phKey /* gets handle of new key */ +); +#endif + +/* C_GenerateKeyPair generates a public-key/private-key pair, + * creating new key objects. */ +CK_PKCS11_FUNCTION_INFO(C_GenerateKeyPair) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session handle */ + CK_MECHANISM_PTR pMechanism, /* key-gen mech. */ + CK_ATTRIBUTE_PTR pPublicKeyTemplate, /* template for pub. key */ + CK_ULONG ulPublicKeyAttributeCount, /* # pub. attrs. */ + CK_ATTRIBUTE_PTR pPrivateKeyTemplate, /* template for priv. key */ + CK_ULONG ulPrivateKeyAttributeCount, /* # priv. attrs. */ + CK_OBJECT_HANDLE_PTR phPublicKey, /* gets pub. key handle */ + CK_OBJECT_HANDLE_PTR phPrivateKey /* gets priv. key handle */ +); +#endif + +/* C_WrapKey wraps (i.e., encrypts) a key. */ +CK_PKCS11_FUNCTION_INFO(C_WrapKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the wrapping mechanism */ + CK_OBJECT_HANDLE hWrappingKey, /* wrapping key */ + CK_OBJECT_HANDLE hKey, /* key to be wrapped */ + CK_BYTE_PTR pWrappedKey, /* gets wrapped key */ + CK_ULONG_PTR pulWrappedKeyLen /* gets wrapped key size */ +); +#endif + +/* C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new + * key object. */ +CK_PKCS11_FUNCTION_INFO(C_UnwrapKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_MECHANISM_PTR pMechanism, /* unwrapping mech. */ + CK_OBJECT_HANDLE hUnwrappingKey, /* unwrapping key */ + CK_BYTE_PTR pWrappedKey, /* the wrapped key */ + CK_ULONG ulWrappedKeyLen, /* wrapped key len */ + CK_ATTRIBUTE_PTR pTemplate, /* new key template */ + CK_ULONG ulAttributeCount, /* template length */ + CK_OBJECT_HANDLE_PTR phKey /* gets new handle */ +); +#endif + +/* C_DeriveKey derives a key from a base key, creating a new key + * object. */ +CK_PKCS11_FUNCTION_INFO(C_DeriveKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_MECHANISM_PTR pMechanism, /* key deriv. mech. */ + CK_OBJECT_HANDLE hBaseKey, /* base key */ + CK_ATTRIBUTE_PTR pTemplate, /* new key template */ + CK_ULONG ulAttributeCount, /* template length */ + CK_OBJECT_HANDLE_PTR phKey /* gets new handle */ +); +#endif + +/* Random number generation */ + +/* C_SeedRandom mixes additional seed material into the token's + * random number generator. */ +CK_PKCS11_FUNCTION_INFO(C_SeedRandom) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pSeed, /* the seed material */ + CK_ULONG ulSeedLen /* length of seed material */ +); +#endif + +/* C_GenerateRandom generates random data. */ +CK_PKCS11_FUNCTION_INFO(C_GenerateRandom) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR RandomData, /* receives the random data */ + CK_ULONG ulRandomLen /* # of bytes to generate */ +); +#endif + +/* Parallel function management */ + +/* C_GetFunctionStatus is a legacy function; it obtains an + * updated status of a function running in parallel with an + * application. */ +CK_PKCS11_FUNCTION_INFO(C_GetFunctionStatus) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + +/* C_CancelFunction is a legacy function; it cancels a function + * running in parallel. */ +CK_PKCS11_FUNCTION_INFO(C_CancelFunction) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + +/* Functions added in for PKCS #11 Version 2.01 or later */ + +/* C_WaitForSlotEvent waits for a slot event (token insertion, + * removal, etc.) to occur. */ +CK_PKCS11_FUNCTION_INFO(C_WaitForSlotEvent) +#ifdef CK_NEED_ARG_LIST +( + CK_FLAGS flags, /* blocking/nonblocking flag */ + CK_SLOT_ID_PTR pSlot, /* location that receives the slot ID */ + CK_VOID_PTR pRserved /* reserved. Should be NULL_PTR */ +); +#endif + +#if (defined(CK_PKCS11_3_0) || defined(CK_PKCS11_3_2)) && !defined(CK_PKCS11_2_0_ONLY) +CK_PKCS11_FUNCTION_INFO(C_GetInterfaceList) +#ifdef CK_NEED_ARG_LIST +( + CK_INTERFACE_PTR interfaces, + CK_ULONG_PTR pulCount); +#endif + +CK_PKCS11_FUNCTION_INFO(C_GetInterface) +#ifdef CK_NEED_ARG_LIST +( + CK_UTF8CHAR_PTR pInterfaceName, + CK_VERSION_PTR pVersion, + CK_INTERFACE_PTR_PTR ppInterface, + CK_FLAGS flags); +#endif + +CK_PKCS11_FUNCTION_INFO(C_LoginUser) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_USER_TYPE userType, + CK_CHAR_PTR pPin, + CK_ULONG ulPinLen, + CK_UTF8CHAR_PTR pUsername, + CK_ULONG ulUsernameLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_SessionCancel) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_FLAGS flags); +#endif + +CK_PKCS11_FUNCTION_INFO(C_MessageEncryptInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); +#endif + +CK_PKCS11_FUNCTION_INFO(C_EncryptMessage) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pAssociatedData, + CK_ULONG ulAssociatedDataLen, + CK_BYTE_PTR pPlaintext, + CK_ULONG ulPlaintextLen, + CK_BYTE_PTR pCiphertext, + CK_ULONG_PTR pulCiphertextLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_EncryptMessageBegin) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pAssociatedData, + CK_ULONG ulAssociatedDataLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_EncryptMessageNext) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pPlaintextPart, + CK_ULONG ulPlaintextPartLen, + CK_BYTE_PTR pCiphertextPart, + CK_ULONG_PTR pulCiphertextPartLen, + CK_FLAGS flags); +#endif + +CK_PKCS11_FUNCTION_INFO(C_MessageEncryptFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession); +#endif + +CK_PKCS11_FUNCTION_INFO(C_MessageDecryptInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); +#endif + +CK_PKCS11_FUNCTION_INFO(C_DecryptMessage) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pAssociatedData, + CK_ULONG ulAssociatedDataLen, + CK_BYTE_PTR pCiphertext, + CK_ULONG ulCiphertextLen, + CK_BYTE_PTR pPlaintext, + CK_ULONG_PTR pulPlaintextLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_DecryptMessageBegin) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pAssociatedData, + CK_ULONG ulAssociatedDataLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_DecryptMessageNext) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pCiphertextPart, + CK_ULONG ulCiphertextPartLen, + CK_BYTE_PTR pPlaintextPart, + CK_ULONG_PTR pulPlaintextPartLen, + CK_FLAGS flags); +#endif + +CK_PKCS11_FUNCTION_INFO(C_MessageDecryptFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession); +#endif + +CK_PKCS11_FUNCTION_INFO(C_MessageSignInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); +#endif + +CK_PKCS11_FUNCTION_INFO(C_SignMessage) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_SignMessageBegin) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_SignMessageNext) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG_PTR pulSignatureLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_MessageSignFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession); +#endif + +CK_PKCS11_FUNCTION_INFO(C_MessageVerifyInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey); +#endif + +CK_PKCS11_FUNCTION_INFO(C_VerifyMessage) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_VerifyMessageBegin) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_VerifyMessageNext) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_VOID_PTR pParameter, + CK_ULONG ulParameterLen, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_MessageVerifyFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession); +#endif + +#if defined(CK_PKCS11_3_2) && !defined(CK_PKCS11_3_0_ONLY) +CK_PKCS11_FUNCTION_INFO(C_EncapsulateKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hPublicKey, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_BYTE_PTR pCiphertext, + CK_ULONG_PTR pulCiphertextLen, + CK_OBJECT_HANDLE_PTR phKey); +#endif + +CK_PKCS11_FUNCTION_INFO(C_DecapsulateKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hPrivateKey, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_BYTE_PTR pCiphertext, + CK_ULONG ulCiphertextLen, + CK_OBJECT_HANDLE_PTR phKey); +#endif + +CK_PKCS11_FUNCTION_INFO(C_VerifySignatureInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hKey, + CK_BYTE_PTR pSignature, + CK_ULONG ulSignatureLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_VerifySignature) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pData, + CK_ULONG ulDataLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_VerifySignatureUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_BYTE_PTR pPart, + CK_ULONG ulPartLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_VerifySignatureFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession); +#endif + +CK_PKCS11_FUNCTION_INFO(C_GetSessionValidationFlags) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_SESSION_VALIDATION_FLAGS_TYPE type, + CK_FLAGS_PTR pFlags); +#endif + +CK_PKCS11_FUNCTION_INFO(C_AsyncComplete) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_UTF8CHAR_PTR pFunctionName, + CK_ASYNC_DATA_PTR pResult); +#endif + +CK_PKCS11_FUNCTION_INFO(C_AsyncGetID) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_UTF8CHAR_PTR pFunctionName, + CK_ULONG_PTR pulID); +#endif + +CK_PKCS11_FUNCTION_INFO(C_AsyncJoin) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_UTF8CHAR_PTR pFunctionName, + CK_ULONG ulID, + CK_BYTE_PTR pData, + CK_ULONG ulData); +#endif + +CK_PKCS11_FUNCTION_INFO(C_WrapKeyAuthenticated) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hWrappingKey, + CK_OBJECT_HANDLE hKey, + CK_BYTE_PTR pAssociatedData, + CK_ULONG ulAssociatedDataLen, + CK_BYTE_PTR pWrappedKey, + CK_ULONG_PTR pulWrappedKeyLen); +#endif + +CK_PKCS11_FUNCTION_INFO(C_UnwrapKeyAuthenticated) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hUnwrappingKey, + CK_BYTE_PTR pWrappedKey, + CK_ULONG ulWrappedKeyLen, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_BYTE_PTR pAssociatedData, + CK_ULONG ulAssociatedDataLen, + CK_OBJECT_HANDLE_PTR phKey); +#endif + +#endif +#endif diff --git a/illumos-x86_64/usr/include/mps/pkcs11n.h b/illumos-x86_64/usr/include/mps/pkcs11n.h new file mode 100644 index 00000000..f354144a --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs11n.h @@ -0,0 +1,783 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _PKCS11N_H_ +#define _PKCS11N_H_ + +/* "friendly" macros to allow us to deprecate certain #defines */ +#if defined(__GNUC__) && (__GNUC__ > 3) && !defined(NSS_SKIP_DEPRECATION_WARNING) +/* make GCC warn when we use these #defines */ +/* + * This is really painful because GCC doesn't allow us to mark random + * #defines as deprecated. We can only mark the following: + * functions, variables, and types. + * const variables will create extra storage for everyone including this + * header file, so it's undesirable. + * functions could be inlined to prevent storage creation, but will fail + * when constant values are expected (like switch statements). + * enum types do not seem to pay attention to the deprecated attribute. + * + * That leaves typedefs. We declare new types that we then deprecate, then + * cast the resulting value to the deprecated type in the #define, thus + * producting the warning when the #define is used. + * + * To make this work with the C preprocessor, we first include a + * _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) declaration in our code + * with: + * 'type' being the base type that the #define is for (CK_TRUST, + * CK_MECHANISM_TTYPE, CK_KEY_TYPE etc.) + * 'name' being a unique name for the type (usually the name of the + * #define) + * 'message' is the string to print out when the compilier warns about + * the deprecated object. This only works in GCC >= 4.5 and + * is ignored on all other platforms. + * We then do a normal #define with _NSS_DEPRECATED_DEFINE_TYPE(name, value) + * as the value with: + * 'name' the same unique name used in _NSS_DEPRECATE_DEFINE_TYPE + * 'value' what you would normally place in the value. + * + * Just deprecating structs are easier, if the struct isn't already aliased + * to some other struct, make your own alias for it, then use + * + * _NSS_DEPRECATE_STRUCT(alias, name, message) + * with: + * 'alias' the alias structure. + * 'name' the name of the deprecated structure + * 'message' is the string to print out when the compilier warns about + * the deprecated object. This only works in GCC >= 4.5 and + * is ignored on all other platforms. + * + * + */ +#if (__GNUC__ == 4) && (__GNUC_MINOR__ < 5) +/* The mac doesn't like the friendlier deprecate messages. I'm assuming this + * is a gcc version issue rather than mac or ppc specific */ +#define _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) \ + typedef type __deprecate_##name __attribute__((deprecated)); +#define _NSS_DEPRECATE_DEFINE_VALUE(name, value) ((__deprecate_##name)(value)) + +#define _NSS_DEPRECATE_STRUCT(alias, name, message) \ + typedef alias name __attribute__((deprecated)); + +#else /*__GNUC__ >= 4.5 */ + +#define _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) \ + typedef type __deprecate_##name __attribute__((deprecated(message))); +#define _NSS_DEPRECATE_DEFINE_VALUE(name, value) ((__deprecate_##name)(value)) + +#define _NSS_DEPRECATE_STRUCT(alias, name, message) \ + typedef alias name __attribute__((deprecated(message))); + +#endif /* __GNUC__ < 4.5 */ +#else /* !__GNUC__ */ +#if defined(_WIN32) && !defined(NSS_SKIP_DEPRECATION_WARNING) +/* windows, we just use pragma deprecated(identifier) */ + +#define _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) +/* #pragma deprecated(name) */ +#define _NSS_DEPRECATE_DEFINE_VALUE(name, value) (value) + +#define _NSS_DEPRECATE_STRUCT(alias, name, message) \ + /* #pragma deprecated(name) */ typedef alias name; + +#else /* not WIN or GNUC, just define the structure */ + +/* fall back to just defining the thing we want without a deprecation warning */ +#define _NSS_DEPRECATE_DEFINE_TYPE(type, name, message) +#define _NSS_DEPRECATE_DEFINE_VALUE(name, value) (value) +#define _NSS_DEPRECATE_STRUCT(alias, name, message) \ + typedef alias name; + +#endif /* !_WIN32 */ +#endif /*!__GNUC__ */ + +/* + * pkcs11n.h + * + * This file contains the NSS-specific type definitions for Cryptoki + * (PKCS#11). + */ + +/* + * NSSCK_VENDOR_NSS + * + * Cryptoki reserves the high half of all the number spaces for + * vendor-defined use. I'd like to keep all of our NSS- + * specific values together, but not in the oh-so-obvious + * 0x80000001, 0x80000002, etc. area. So I've picked an offset, + * and constructed values for the beginnings of our spaces. + * + * Note that some "historical" Netscape values don't fall within + * this range. + */ +#define NSSCK_VENDOR_NSS 0x4E534350 /* NSCP */ + +/* + * NSS-defined object classes + * + */ +#define CKO_NSS (CKO_VENDOR_DEFINED | NSSCK_VENDOR_NSS) + +#define CKO_NSS_CRL (CKO_NSS + 1) +#define CKO_NSS_SMIME (CKO_NSS + 2) +#define CKO_NSS_TRUST (CKO_NSS + 3) +#define CKO_NSS_BUILTIN_ROOT_LIST (CKO_NSS + 4) +#define CKO_NSS_NEWSLOT (CKO_NSS + 5) +#define CKO_NSS_DELSLOT (CKO_NSS + 6) +#define CKO_NSS_VALIDATION (CKO_NSS + 7) + +#define CKV_NSS_FIPS_140 (CKO_NSS + 1) + +/* + * NSS-defined key types + * + */ +#define CKK_NSS (CKK_VENDOR_DEFINED | NSSCK_VENDOR_NSS) + +#define CKK_NSS_PKCS8 (CKK_NSS + 1) + +#define CKK_NSS_JPAKE_ROUND1 (CKK_NSS + 2) +#define CKK_NSS_JPAKE_ROUND2 (CKK_NSS + 3) + +#define CKK_NSS_CHACHA20 (CKK_NSS + 4) + +#define CKK_NSS_KYBER (CKK_NSS + 5) +#define CKK_NSS_ML_KEM (CKK_NSS + 6) + +/* + * NSS-defined certificate types + * + */ +#define CKC_NSS (CKC_VENDOR_DEFINED | NSSCK_VENDOR_NSS) + +/* FAKE PKCS #11 defines */ +/* These are used internally in the pk11wrap layer as operations and should not + * be passed to softoken or any other PKCS#11 module as actual attributes */ +#define CKA_DIGEST 0x81000000L +#define CKA_NSS_MESSAGE 0x82000000L +#define CKA_NSS_SIGNATURE 0x83000000L +#define CKA_NSS_MESSAGE_MASK 0xff000000L +#define CKA_FLAGS_ONLY 0 /* CKA_CLASS */ +#define CKA_NSS_VERIFY_SIGNATURE (CKA_NSS_SIGNATURE | CKA_VERIFY) + +/* + * NSS-defined object attributes + * + */ +#define CKA_NSS (CKA_VENDOR_DEFINED | NSSCK_VENDOR_NSS) + +#define CKA_NSS_URL (CKA_NSS + 1) +#define CKA_NSS_EMAIL (CKA_NSS + 2) +#define CKA_NSS_SMIME_INFO (CKA_NSS + 3) +#define CKA_NSS_SMIME_TIMESTAMP (CKA_NSS + 4) +#define CKA_NSS_PKCS8_SALT (CKA_NSS + 5) +#define CKA_NSS_PASSWORD_CHECK (CKA_NSS + 6) +#define CKA_NSS_EXPIRES (CKA_NSS + 7) +#define CKA_NSS_KRL (CKA_NSS + 8) + +#define CKA_NSS_PQG_COUNTER (CKA_NSS + 20) +#define CKA_NSS_PQG_SEED (CKA_NSS + 21) +#define CKA_NSS_PQG_H (CKA_NSS + 22) +#define CKA_NSS_PQG_SEED_BITS (CKA_NSS + 23) +#define CKA_NSS_MODULE_SPEC (CKA_NSS + 24) +#define CKA_NSS_OVERRIDE_EXTENSIONS (CKA_NSS + 25) + +#define CKA_NSS_JPAKE_SIGNERID (CKA_NSS + 26) +#define CKA_NSS_JPAKE_PEERID (CKA_NSS + 27) +#define CKA_NSS_JPAKE_GX1 (CKA_NSS + 28) +#define CKA_NSS_JPAKE_GX2 (CKA_NSS + 29) +#define CKA_NSS_JPAKE_GX3 (CKA_NSS + 30) +#define CKA_NSS_JPAKE_GX4 (CKA_NSS + 31) +#define CKA_NSS_JPAKE_X2 (CKA_NSS + 32) +#define CKA_NSS_JPAKE_X2S (CKA_NSS + 33) + +#define CKA_NSS_MOZILLA_CA_POLICY (CKA_NSS + 34) +#define CKA_NSS_SERVER_DISTRUST_AFTER (CKA_NSS + 35) +#define CKA_NSS_EMAIL_DISTRUST_AFTER (CKA_NSS + 36) + +#define CKA_NSS_VALIDATION_TYPE (CKA_NSS + 36) +#define CKA_NSS_VALIDATION_VERSION (CKA_NSS + 37) +#define CKA_NSS_VALIDATION_LEVEL (CKA_NSS + 38) +#define CKA_NSS_VALIDATION_MODULE_ID (CKA_NSS + 39) + +#define CKA_NSS_PARAMETER_SET (CKA_NSS + 40) + +/* + * Trust attributes: + * + * If trust attributes are now standard, but we didn't use + * NSS specific names, so the CKA_ names collide with the standard + * names. We'll update NSS to use specific names, and applications + * can use The #NSS_USE_STANDARD_TRUST define to select which values + * the CKA_TRUST_XXX names should map to. + * + * In our code we'll expect CKA_NSS_TRUST_xxx attributes in + * CKO_NSS_TRUST objects and CKA_PKCS_TRUST attributes in + * CKO_TRUST objects. + */ +#define CKA_NSS_TRUST_BASE (CKA_NSS + 0x2000) + +/* "Usage" key information */ +#define CKA_NSS_TRUST_DIGITAL_SIGNATURE (CKA_NSS_TRUST_BASE + 1) +#define CKA_NSS_TRUST_NON_REPUDIATION (CKA_NSS_TRUST_BASE + 2) +#define CKA_NSS_TRUST_KEY_ENCIPHERMENT (CKA_NSS_TRUST_BASE + 3) +#define CKA_NSS_TRUST_DATA_ENCIPHERMENT (CKA_NSS_TRUST_BASE + 4) +#define CKA_NSS_TRUST_KEY_AGREEMENT (CKA_NSS_TRUST_BASE + 5) +#define CKA_NSS_TRUST_KEY_CERT_SIGN (CKA_NSS_TRUST_BASE + 6) +#define CKA_NSS_TRUST_CRL_SIGN (CKA_NSS_TRUST_BASE + 7) + +/* "Purpose" trust information */ +#define CKA_NSS_TRUST_SERVER_AUTH (CKA_NSS_TRUST_BASE + 8) +#define CKA_NSS_TRUST_CLIENT_AUTH (CKA_NSS_TRUST_BASE + 9) +#define CKA_NSS_TRUST_CODE_SIGNING (CKA_NSS_TRUST_BASE + 10) +#define CKA_NSS_TRUST_EMAIL_PROTECTION (CKA_NSS_TRUST_BASE + 11) +#define CKA_NSS_TRUST_IPSEC_END_SYSTEM (CKA_NSS_TRUST_BASE + 12) +#define CKA_NSS_TRUST_IPSEC_TUNNEL (CKA_NSS_TRUST_BASE + 13) +#define CKA_NSS_TRUST_IPSEC_USER (CKA_NSS_TRUST_BASE + 14) +#define CKA_NSS_TRUST_TIME_STAMPING (CKA_NSS_TRUST_BASE + 15) +#define CKA_NSS_TRUST_STEP_UP_APPROVED (CKA_NSS_TRUST_BASE + 16) + +#define CKA_NSS_CERT_SHA1_HASH (CKA_NSS_TRUST_BASE + 100) +#define CKA_NSS_CERT_MD5_HASH (CKA_NSS_TRUST_BASE + 101) + +#ifdef NSS_USE_STANDARD_TRUST +/* Names take on the PKCS #11 standard values */ +#define CKA_TRUST_SERVER_AUTH CKA_PKCS_TRUST_SERVER_AUTH +#define CKA_TRUST_CLIENT_AUTH CKA_PKCS_TRUST_CLIENT_AUTH +#define CKA_TRUST_CODE_SIGNING CKA_PKCS_TRUST_CODE_SIGNING +#define CKA_TRUST_EMAIL_PROTECTION CKA_PKCS_TRUST_EMAIL_PROTECTION +#define CKA_TRUST_TIME_STAMPING CKA_PKCS_TRUST_TIME_STAMPING +#define CKA_TRUST_OCSP_SIGNING CKA_PKCS_TRUST_OCSP_SIGNING +#else +/* Names take on the legacy NSS values */ +/* NOTE these don't actually colide with the PKCS #11 standard values + * but we want to rename to with the NSS in them anyway. When + * you set NSS_USE_STANDARD_TRUST, the non _NSS_ names will + * go away */ +#define CKA_TRUST CKA_NSS_TRUST_BASE +#define CKA_TRUST_DIGITAL_SIGNATURE CKA_NSS_TRUST_DIGITAL_SIGNATURE +#define CKA_TRUST_NON_REPUDIATION CKA_NSS_TRUST_NON_REPUDIATION +#define CKA_TRUST_KEY_ENCIPHERMENT CKA_NSS_TRUST_KEY_ENCIPHERMENT +#define CKA_TRUST_DATA_ENCIPHERMENT CKA_NSS_TRUST_DATA_ENCIPHERMENT +#define CKA_TRUST_KEY_AGREEMENT CKA_NSS_TRUST_KEY_AGREEMENT +#define CKA_TRUST_KEY_CERT_SIGN CKA_NSS_TRUST_KEY_CERT_SIGN +#define CKA_TRUST_CRL_SIGN CKA_NSS_TRUST_CRL_SIGN +#define CKA_TRUST_EMAIL_PROTECTION CKA_NSS_TRUST_EMAIL_PROTECTION +#define CKA_TRUST_IPSEC_END_SYSTEM CKA_NSS_TRUST_IPSEC_END_SYSTEM +#define CKA_TRUST_IPSEC_TUNNEL CKA_NSS_TRUST_IPSEC_TUNNEL +#define CKA_TRUST_IPSEC_USER CKA_NSS_TRUST_IPSEC_USER +#define CKA_TRUST_STEP_UP_APPROVED CKA_NSS_TRUST_STEP_UP_APPROVED +#define CKA_CERT_SHA1_HASH CKA_NSS_CERT_SHA1_HASH +#define CKA_CERT_MD5_HASH CKA_NSS_CERT_MD5_HASH + +/* These names collide with pkcs #11 standard names */ +#define CKA_TRUST_SERVER_AUTH CKA_NSS_TRUST_SERVER_AUTH +#define CKA_TRUST_CLIENT_AUTH CKA_NSS_TRUST_CLIENT_AUTH +#define CKA_TRUST_CODE_SIGNING CKA_NSS_TRUST_CODE_SIGNING +#define CKA_TRUST_TIME_STAMPING CKA_NSS_TRUST_TIME_STAMPING +#endif + +/* NSS trust stuff */ + +/* HISTORICAL: define used to pass in the database key for DSA private keys */ +#define CKA_NSS_DB 0xD5A0DB00L +#define CKA_NSS_TRUST 0x80000001L + +/* FAKE PKCS #11 defines */ +#define CKM_FAKE_RANDOM 0x80000efeUL +#define CKM_INVALID_MECHANISM 0xffffffffUL +#define CKT_INVALID_TYPE 0xffffffffUL + +/* + * NSS-defined crypto mechanisms + * + */ +#define CKM_NSS (CKM_VENDOR_DEFINED | NSSCK_VENDOR_NSS) + +#define CKM_NSS_AES_KEY_WRAP (CKM_NSS + 1) +#define CKM_NSS_AES_KEY_WRAP_PAD (CKM_NSS + 2) + +/* HKDF key derivation mechanisms. See CK_NSS_HKDFParams for documentation. */ +#define CKM_NSS_HKDF_SHA1 (CKM_NSS + 3) +#define CKM_NSS_HKDF_SHA256 (CKM_NSS + 4) +#define CKM_NSS_HKDF_SHA384 (CKM_NSS + 5) +#define CKM_NSS_HKDF_SHA512 (CKM_NSS + 6) + +/* J-PAKE round 1 key generation mechanisms. + * + * Required template attributes: CKA_PRIME, CKA_SUBPRIME, CKA_BASE, + * CKA_NSS_JPAKE_SIGNERID + * Output key type: CKK_NSS_JPAKE_ROUND1 + * Output key class: CKO_PRIVATE_KEY + * Parameter type: CK_NSS_JPAKERound1Params + * + */ +#define CKM_NSS_JPAKE_ROUND1_SHA1 (CKM_NSS + 7) +#define CKM_NSS_JPAKE_ROUND1_SHA256 (CKM_NSS + 8) +#define CKM_NSS_JPAKE_ROUND1_SHA384 (CKM_NSS + 9) +#define CKM_NSS_JPAKE_ROUND1_SHA512 (CKM_NSS + 10) + +/* J-PAKE round 2 key derivation mechanisms. + * + * Required template attributes: CKA_NSS_JPAKE_PEERID + * Input key type: CKK_NSS_JPAKE_ROUND1 + * Output key type: CKK_NSS_JPAKE_ROUND2 + * Output key class: CKO_PRIVATE_KEY + * Parameter type: CK_NSS_JPAKERound2Params + */ +#define CKM_NSS_JPAKE_ROUND2_SHA1 (CKM_NSS + 11) +#define CKM_NSS_JPAKE_ROUND2_SHA256 (CKM_NSS + 12) +#define CKM_NSS_JPAKE_ROUND2_SHA384 (CKM_NSS + 13) +#define CKM_NSS_JPAKE_ROUND2_SHA512 (CKM_NSS + 14) + +/* J-PAKE final key material derivation mechanisms + * + * Input key type: CKK_NSS_JPAKE_ROUND2 + * Output key type: CKK_GENERIC_SECRET + * Output key class: CKO_SECRET_KEY + * Parameter type: CK_NSS_JPAKEFinalParams + * + * You must apply a KDF (e.g. CKM_NSS_HKDF_*) to resultant keying material + * to get a key with uniformly distributed bits. + */ +#define CKM_NSS_JPAKE_FINAL_SHA1 (CKM_NSS + 15) +#define CKM_NSS_JPAKE_FINAL_SHA256 (CKM_NSS + 16) +#define CKM_NSS_JPAKE_FINAL_SHA384 (CKM_NSS + 17) +#define CKM_NSS_JPAKE_FINAL_SHA512 (CKM_NSS + 18) + +/* Constant-time MAC mechanisms: + * + * These operations verify a padded, MAC-then-encrypt block of data in + * constant-time. Because of the order of operations, the padding bytes are not + * protected by the MAC. However, disclosing the value of the padding bytes + * gives an attacker the ability to decrypt ciphertexts. Such disclosure can be + * as subtle as taking slightly less time to perform the MAC when the padding + * is one byte longer. See https://www.isg.rhul.ac.uk/tls/ + * + * CKM_NSS_HMAC_CONSTANT_TIME: performs an HMAC authentication. + * CKM_NSS_SSL3_MAC_CONSTANT_TIME: performs an authentication with SSLv3 MAC. + * + * Parameter type: CK_NSS_MAC_CONSTANT_TIME_PARAMS + */ +#define CKM_NSS_HMAC_CONSTANT_TIME (CKM_NSS + 19) +#define CKM_NSS_SSL3_MAC_CONSTANT_TIME (CKM_NSS + 20) + +/* TLS 1.2 mechanisms */ +#define CKM_NSS_TLS_PRF_GENERAL_SHA256 (CKM_NSS + 21) +#define CKM_NSS_TLS_MASTER_KEY_DERIVE_SHA256 (CKM_NSS + 22) +#define CKM_NSS_TLS_KEY_AND_MAC_DERIVE_SHA256 (CKM_NSS + 23) +#define CKM_NSS_TLS_MASTER_KEY_DERIVE_DH_SHA256 (CKM_NSS + 24) + +/* TLS extended master secret derivation */ +#define CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE (CKM_NSS + 25) +#define CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_DH (CKM_NSS + 26) + +#define CKM_NSS_CHACHA20_KEY_GEN (CKM_NSS + 27) +#define CKM_NSS_CHACHA20_POLY1305 (CKM_NSS + 28) + +/* Additional PKCS #12 PBE algorithms defined in v1.1 */ +#define CKM_NSS_PKCS12_PBE_SHA224_HMAC_KEY_GEN (CKM_NSS + 29) +#define CKM_NSS_PKCS12_PBE_SHA256_HMAC_KEY_GEN (CKM_NSS + 30) +#define CKM_NSS_PKCS12_PBE_SHA384_HMAC_KEY_GEN (CKM_NSS + 31) +#define CKM_NSS_PKCS12_PBE_SHA512_HMAC_KEY_GEN (CKM_NSS + 32) + +#define CKM_NSS_CHACHA20_CTR (CKM_NSS + 33) + +/* IKE mechanisms now defined in PKCS #11, use those instead now */ +#define CKM_NSS_IKE_PRF_PLUS_DERIVE (CKM_NSS + 34) +#define CKM_NSS_IKE_PRF_DERIVE (CKM_NSS + 35) +#define CKM_NSS_IKE1_PRF_DERIVE (CKM_NSS + 36) +#define CKM_NSS_IKE1_APP_B_PRF_DERIVE (CKM_NSS + 37) + +#define CKM_NSS_PUB_FROM_PRIV (CKM_NSS + 40) + +/* SP800-108 NSS mechanism with support for data object derivation */ +#define CKM_NSS_SP800_108_COUNTER_KDF_DERIVE_DATA (CKM_NSS + 42) +#define CKM_NSS_SP800_108_FEEDBACK_KDF_DERIVE_DATA (CKM_NSS + 43) +#define CKM_NSS_SP800_108_DOUBLE_PIPELINE_KDF_DERIVE_DATA (CKM_NSS + 44) + +/* Kyber */ +#define CKM_NSS_KYBER_KEY_PAIR_GEN (CKM_NSS + 45) +#define CKM_NSS_KYBER (CKM_NSS + 46) + +/* TLS ECDHE key pair generation. This is used to indicate that a key pair is + * for use in a single TLS handshake, so NIST SP 800-56A pairwise consistency + * checks can be skipped. It is otherwise identical to CKM_EC_KEY_PAIR_GEN. + */ +#define CKM_NSS_ECDHE_NO_PAIRWISE_CHECK_KEY_PAIR_GEN (CKM_NSS + 47) + +/* ML-KEM */ +#define CKM_NSS_ML_KEM_KEY_PAIR_GEN (CKM_NSS + 48) +#define CKM_NSS_ML_KEM (CKM_NSS + 49) + +/* + * HISTORICAL: + * Do not attempt to use these. They are only used by NSS's internal + * PKCS #11 interface. Most of these are place holders for other mechanism + * and will change in the future. + */ +#define CKM_NSS_PBE_SHA1_DES_CBC 0x80000002UL +#define CKM_NSS_PBE_SHA1_TRIPLE_DES_CBC 0x80000003UL +#define CKM_NSS_PBE_SHA1_40_BIT_RC2_CBC 0x80000004UL +#define CKM_NSS_PBE_SHA1_128_BIT_RC2_CBC 0x80000005UL +#define CKM_NSS_PBE_SHA1_40_BIT_RC4 0x80000006UL +#define CKM_NSS_PBE_SHA1_128_BIT_RC4 0x80000007UL +#define CKM_NSS_PBE_SHA1_FAULTY_3DES_CBC 0x80000008UL +#define CKM_NSS_PBE_SHA1_HMAC_KEY_GEN 0x80000009UL +#define CKM_NSS_PBE_MD5_HMAC_KEY_GEN 0x8000000aUL +#define CKM_NSS_PBE_MD2_HMAC_KEY_GEN 0x8000000bUL + +#define CKM_TLS_PRF_GENERAL 0x80000373UL + +/* Parameter set identifiers */ +#define CKP_NSS (CKM_VENDOR_DEFINED | NSSCK_VENDOR_NSS) +#define CKP_NSS_KYBER_768_ROUND3 (CKP_NSS + 1) +#define CKP_NSS_ML_KEM_768 (CKP_NSS + 2) + +/* FIPS Indicator defines */ +#define CKS_NSS_UNINITIALIZED 0xffffffffUL +#define CKS_NSS_FIPS_NOT_OK 0UL +#define CKS_NSS_FIPS_OK 1UL + +#define CKT_NSS_SESSION_CHECK 1UL +#define CKT_NSS_OBJECT_CHECK 2UL +#define CKT_NSS_BOTH_CHECK 3UL +#define CKT_NSS_SESSION_LAST_CHECK 4UL + +typedef struct CK_NSS_JPAKEPublicValue { + CK_BYTE *pGX; + CK_ULONG ulGXLen; + CK_BYTE *pGV; + CK_ULONG ulGVLen; + CK_BYTE *pR; + CK_ULONG ulRLen; +} CK_NSS_JPAKEPublicValue; + +typedef struct CK_NSS_JPAKERound1Params { + CK_NSS_JPAKEPublicValue gx1; /* out */ + CK_NSS_JPAKEPublicValue gx2; /* out */ +} CK_NSS_JPAKERound1Params; + +typedef struct CK_NSS_JPAKERound2Params { + CK_BYTE *pSharedKey; /* in */ + CK_ULONG ulSharedKeyLen; /* in */ + CK_NSS_JPAKEPublicValue gx3; /* in */ + CK_NSS_JPAKEPublicValue gx4; /* in */ + CK_NSS_JPAKEPublicValue A; /* out */ +} CK_NSS_JPAKERound2Params; + +typedef struct CK_NSS_JPAKEFinalParams { + CK_NSS_JPAKEPublicValue B; /* in */ +} CK_NSS_JPAKEFinalParams; + +/* macAlg: the MAC algorithm to use. This determines the hash function used in + * the HMAC/SSLv3 MAC calculations. + * ulBodyTotalLen: the total length of the data, including padding bytes and + * padding length. + * pHeader: points to a block of data that contains additional data to + * authenticate. For TLS this includes the sequence number etc. For SSLv3, + * this also includes the initial padding bytes. + * + * NOTE: the softoken's implementation of CKM_NSS_HMAC_CONSTANT_TIME and + * CKM_NSS_SSL3_MAC_CONSTANT_TIME requires that the sum of ulBodyTotalLen + * and ulHeaderLen be much smaller than 2^32 / 8 bytes because it uses an + * unsigned int variable to represent the length in bits. This should not + * be a problem because the SSL/TLS protocol limits the size of an SSL + * record to something considerably less than 2^32 bytes. + */ +typedef struct CK_NSS_MAC_CONSTANT_TIME_PARAMS { + CK_MECHANISM_TYPE macAlg; /* in */ + CK_ULONG ulBodyTotalLen; /* in */ + CK_BYTE *pHeader; /* in */ + CK_ULONG ulHeaderLen; /* in */ +} CK_NSS_MAC_CONSTANT_TIME_PARAMS; + +typedef struct CK_NSS_AEAD_PARAMS { + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceLen; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulTagLen; +} CK_NSS_AEAD_PARAMS; + +/* + * NSS-defined return values + * + */ +#define CKR_NSS (CKM_VENDOR_DEFINED | NSSCK_VENDOR_NSS) + +#define CKR_NSS_CERTDB_FAILED (CKR_NSS + 1) +#define CKR_NSS_KEYDB_FAILED (CKR_NSS + 2) + +/* NSS specific types */ +typedef CK_ULONG CK_NSS_VALIDATION_TYPE; + +typedef CK_ULONG CK_NSS_KEM_PARAMETER_SET_TYPE; + +/* Mandatory parameter for the CKM_NSS_HKDF_* key deriviation mechanisms. + See RFC 5869. + + bExtract: If set, HKDF-Extract will be applied to the input key. If + the optional salt is given, it is used; otherwise, the salt is + set to a sequence of zeros equal in length to the HMAC output. + If bExpand is not set, then the key template given to + C_DeriveKey must indicate an output key size less than or equal + to the output size of the HMAC. + + bExpand: If set, HKDF-Expand will be applied to the input key (if + bExtract is not set) or to the result of HKDF-Extract (if + bExtract is set). Any info given in the optional pInfo field will + be included in the calculation. + + The size of the output key must be specified in the template passed to + C_DeriveKey. +*/ +typedef struct CK_NSS_HKDFParams { + CK_BBOOL bExtract; + CK_BYTE_PTR pSalt; + CK_ULONG ulSaltLen; + CK_BBOOL bExpand; + CK_BYTE_PTR pInfo; + CK_ULONG ulInfoLen; +} CK_NSS_HKDFParams; + +/* + * CK_NSS_IKE_PRF_PLUS_PARAMS is a structure that provides the parameters to + * the CKM_NSS_IKE_PRF_PLUS_DERIVE mechanism. + * It is now standardized, so The struct is just an alias for the standard + * struct in pkcs11t.h. + */ +typedef struct CK_IKE2_PRF_PLUS_DERIVE_PARAMS CK_NSS_IKE_PRF_PLUS_DERIVE_PARAMS; + +/* CK_NSS_IKE_PRF_DERIVE_PARAMS is a structure that provides the parameters to + * the CKM_NSS_IKE_PRF_DERIVE mechanism. + * It is now standardized, so The struct is just an alias for the standard + * struct in pkcs11t.h. + */ +typedef struct CK_IKE_PRF_DERIVE_PARAMS CK_NSS_IKE_PRF_DERIVE_PARAMS; + +/* CK_NSS_IKE1_PRF_DERIVE_PARAMS is a structure that provides the parameters + * to the CKM_NSS_IKE_PRF_DERIVE mechanism. + * It is now standardized, so The struct is just an alias for the standard + * struct in pkcs11t.h. + */ +typedef struct CK_IKE1_PRF_DERIVE_PARAMS CK_NSS_IKE1_PRF_DERIVE_PARAMS; + +/* CK_NSS_IKE1_APP_B_PRF_DERIVE_PARAMS is a structure that provides the + * parameters to the CKM_NSS_IKE_APP_B_PRF_DERIVE mechanism. + * It is now standardized, so The struct is just an alias for the standard + * struct in pkcs11t.h. + */ +typedef struct CK_IKE1_EXTENDED_DERIVE_PARAMS CK_NSS_IKE1_APP_B_PRF_DERIVE_PARAMS; + +/* + * Parameter for the TLS extended master secret key derivation mechanisms: + * + * * CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE + * * CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_DH + * + * For the TLS 1.2 PRF, the prfHashMechanism parameter determines the hash + * function used. For earlier versions of the PRF, set the prfHashMechanism + * value to CKM_TLS_PRF. + * It is now standardized, so The struct is just an alias for the standard + * struct in pkcs11t.h. */ +typedef struct CK_TLS12_EXTENDED_MASTER_KEY_DERIVE_PARAMS + CK_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_PARAMS; + +/* + * Trust info + * + * This now part of the Cryptoki standard , These are all the + * old vendor defined symbols. + */ + +/* The following trust types are defined: */ +#define CKT_VENDOR_DEFINED 0x80000000 + +#define CKT_NSS (CKT_VENDOR_DEFINED | NSSCK_VENDOR_NSS) + +/* If trust goes standard, these'll probably drop out of vendor space. */ +#define CKT_NSS_TRUSTED (CKT_NSS + 1) +#define CKT_NSS_TRUSTED_DELEGATOR (CKT_NSS + 2) +#define CKT_NSS_MUST_VERIFY_TRUST (CKT_NSS + 3) +#define CKT_NSS_NOT_TRUSTED (CKT_NSS + 10) +#define CKT_NSS_TRUST_UNKNOWN (CKT_NSS + 5) /* default */ + +/* + * These may well remain NSS-specific; I'm only using them + * to cache resolution data. + */ +#define CKT_NSS_VALID_DELEGATOR (CKT_NSS + 11) + +/* + * old definitions. They still exist, but the plain meaning of the + * labels have never been accurate to what was really implemented. + * The new labels correctly reflect what the values effectively mean. + */ +_NSS_DEPRECATE_DEFINE_TYPE(CK_TRUST, CKT_NSS_UNTRUSTED, + "CKT_NSS_UNTRUSTED really means CKT_NSS_MUST_VERIFY_TRUST") +#define CKT_NSS_UNTRUSTED \ + _NSS_DEPRECATE_DEFINE_VALUE(CKT_NSS_UNTRUSTED, CKT_NSS_MUST_VERIFY_TRUST) +_NSS_DEPRECATE_DEFINE_TYPE(CK_TRUST, CKT_NSS_VALID, + "CKT_NSS_VALID really means CKT_NSS_NOT_TRUSTED") +#define CKT_NSS_VALID \ + _NSS_DEPRECATE_DEFINE_VALUE(CKT_NSS_VALID, CKT_NSS_NOT_TRUSTED) +_NSS_DEPRECATE_DEFINE_TYPE(CK_TRUST, CKT_NSS_MUST_VERIFY, + "CKT_NSS_MUST_VERIFY really functions as CKT_NSS_TRUST_UNKNOWN") +#define CKT_NSS_MUST_VERIFY \ + _NSS_DEPRECATE_DEFINE_VALUE(CKT_NSS_MUST_VERIFY, CKT_NSS_TRUST_UNKNOWN) + +/* + * These are not really PKCS #11 values specifically. They are the 'loadable' + * module spec NSS uses. They are available for others to use as well, but not + * part of the formal PKCS #11 spec. + * + * The function 'FIND' returns an array of PKCS #11 initialization strings + * The function 'ADD' takes a PKCS #11 initialization string and stores it. + * The function 'DEL' takes a 'name= library=' value and deletes the associated + * string. + * The function 'RELEASE' frees the array returned by 'FIND' + */ +#define SECMOD_MODULE_DB_FUNCTION_FIND 0 +#define SECMOD_MODULE_DB_FUNCTION_ADD 1 +#define SECMOD_MODULE_DB_FUNCTION_DEL 2 +#define SECMOD_MODULE_DB_FUNCTION_RELEASE 3 +typedef char **(PR_CALLBACK *SECMODModuleDBFunc)(unsigned long function, + char *parameters, void *moduleSpec); + +/* softoken slot ID's */ +#define SFTK_MIN_USER_SLOT_ID 4 +#define SFTK_MAX_USER_SLOT_ID 100 +#define SFTK_MIN_FIPS_USER_SLOT_ID 101 +#define SFTK_MAX_FIPS_USER_SLOT_ID 127 + +/* Module Interface. This is the old NSS private module interface, now exported + * as a PKCS #11 v3 interface. It's interface name is + * "Vendor NSS Module Interface" */ +typedef char **(*CK_NSS_ModuleDBFunc)(unsigned long function, + char *parameters, void *args); +typedef struct CK_NSS_MODULE_FUNCTIONS { + CK_VERSION version; + CK_NSS_ModuleDBFunc NSC_ModuleDBFunc; +} CK_NSS_MODULE_FUNCTIONS; + +/* FIPS Indicator Interface. This may move to the normal PKCS #11 table + * in the future. For now it's called "Vendor NSS FIPS Interface" */ +typedef CK_RV (*CK_NSS_GetFIPSStatus)(CK_SESSION_HANDLE hSession, + CK_OBJECT_HANDLE hObject, + CK_ULONG ulOperationType, + CK_ULONG *pulFIPSStatus); + +typedef struct CK_NSS_FIPS_FUNCTIONS { + CK_VERSION version; + CK_NSS_GetFIPSStatus NSC_NSSGetFIPSStatus; +} CK_NSS_FIPS_FUNCTIONS; + +/* KEM interface. This may move to the normal PKCS #11 table in the future. For + * now it's called "Vendor NSS KEM Interface" */ +typedef CK_RV (*CK_NSS_Encapsulate)(CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hPublicKey, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_OBJECT_HANDLE_PTR phKey, + CK_BYTE_PTR pCiphertext, + CK_ULONG_PTR pulCiphertextLen); + +typedef CK_RV (*CK_NSS_Decapsulate)(CK_SESSION_HANDLE hSession, + CK_MECHANISM_PTR pMechanism, + CK_OBJECT_HANDLE hPrivateKey, + CK_BYTE_PTR pCiphertext, + CK_ULONG ulCiphertextLen, + CK_ATTRIBUTE_PTR pTemplate, + CK_ULONG ulAttributeCount, + CK_OBJECT_HANDLE_PTR phKey); + +typedef struct CK_NSS_KEM_FUNCTIONS { + CK_VERSION version; + CK_NSS_Encapsulate C_Encapsulate; + CK_NSS_Decapsulate C_Decapsulate; +} CK_NSS_KEM_FUNCTIONS; + +/* There was an inconsistency between the spec and the header file in defining + * the CK_GCM_PARAMS structure. The authoritative reference is the header file, + * but NSS used the spec when adding it to its own header. In V3 we've + * corrected it, but we need to handle the old case for devices that followed + * us in using the incorrect specification. */ +typedef struct CK_NSS_GCM_PARAMS { + CK_BYTE_PTR pIv; + CK_ULONG ulIvLen; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulTagBits; +} CK_NSS_GCM_PARAMS; + +typedef CK_NSS_GCM_PARAMS CK_PTR CK_NSS_GCM_PARAMS_PTR; + +/* deprecated #defines. Drop in future NSS releases */ +#ifdef NSS_PKCS11_2_0_COMPAT + +/* defines that were changed between NSS's PKCS #11 and the Oasis headers */ +#define CKF_EC_FP CKF_EC_F_P +#define CKO_KG_PARAMETERS CKO_DOMAIN_PARAMETERS +#define CK_INVALID_SESSION CK_INVALID_HANDLE +#define CKR_KEY_PARAMS_INVALID 0x0000006B + +/* use the old wrong CK_GCM_PARAMS if NSS_PCKS11_2_0_COMPAT is defined */ +typedef struct CK_NSS_GCM_PARAMS CK_GCM_PARAMS; +typedef CK_NSS_GCM_PARAMS CK_PTR CK_GCM_PARAMS_PTR; + +/* don't leave old programs in a lurch just yet, give them the old NETSCAPE + * synonym if NSS_PKCS11_2_0_COMPAT is defined*/ +#define CKO_NETSCAPE_CRL CKO_NSS_CRL +#define CKO_NETSCAPE_SMIME CKO_NSS_SMIME +#define CKO_NETSCAPE_TRUST CKO_NSS_TRUST +#define CKO_NETSCAPE_BUILTIN_ROOT_LIST CKO_NSS_BUILTIN_ROOT_LIST +#define CKO_NETSCAPE_NEWSLOT CKO_NSS_NEWSLOT +#define CKO_NETSCAPE_DELSLOT CKO_NSS_DELSLOT +#define CKK_NETSCAPE_PKCS8 CKK_NSS_PKCS8 +#define CKA_NETSCAPE_URL CKA_NSS_URL +#define CKA_NETSCAPE_EMAIL CKA_NSS_EMAIL +#define CKA_NETSCAPE_SMIME_INFO CKA_NSS_SMIME_INFO +#define CKA_NETSCAPE_SMIME_TIMESTAMP CKA_NSS_SMIME_TIMESTAMP +#define CKA_NETSCAPE_PKCS8_SALT CKA_NSS_PKCS8_SALT +#define CKA_NETSCAPE_PASSWORD_CHECK CKA_NSS_PASSWORD_CHECK +#define CKA_NETSCAPE_EXPIRES CKA_NSS_EXPIRES +#define CKA_NETSCAPE_KRL CKA_NSS_KRL +#define CKA_NETSCAPE_PQG_COUNTER CKA_NSS_PQG_COUNTER +#define CKA_NETSCAPE_PQG_SEED CKA_NSS_PQG_SEED +#define CKA_NETSCAPE_PQG_H CKA_NSS_PQG_H +#define CKA_NETSCAPE_PQG_SEED_BITS CKA_NSS_PQG_SEED_BITS +#define CKA_NETSCAPE_MODULE_SPEC CKA_NSS_MODULE_SPEC +#define CKA_NETSCAPE_DB CKA_NSS_DB +#define CKA_NETSCAPE_TRUST CKA_NSS_TRUST +#define CKM_NETSCAPE_AES_KEY_WRAP CKM_NSS_AES_KEY_WRAP +#define CKM_NETSCAPE_AES_KEY_WRAP_PAD CKM_NSS_AES_KEY_WRAP_PAD +#define CKM_NETSCAPE_PBE_SHA1_DES_CBC CKM_NSS_PBE_SHA1_DES_CBC +#define CKM_NETSCAPE_PBE_SHA1_TRIPLE_DES_CBC CKM_NSS_PBE_SHA1_TRIPLE_DES_CBC +#define CKM_NETSCAPE_PBE_SHA1_40_BIT_RC2_CBC CKM_NSS_PBE_SHA1_40_BIT_RC2_CBC +#define CKM_NETSCAPE_PBE_SHA1_128_BIT_RC2_CBC CKM_NSS_PBE_SHA1_128_BIT_RC2_CBC +#define CKM_NETSCAPE_PBE_SHA1_40_BIT_RC4 CKM_NSS_PBE_SHA1_40_BIT_RC4 +#define CKM_NETSCAPE_PBE_SHA1_128_BIT_RC4 CKM_NSS_PBE_SHA1_128_BIT_RC4 +#define CKM_NETSCAPE_PBE_SHA1_FAULTY_3DES_CBC CKM_NSS_PBE_SHA1_FAULTY_3DES_CBC +#define CKM_NETSCAPE_PBE_SHA1_HMAC_KEY_GEN CKM_NSS_PBE_SHA1_HMAC_KEY_GEN +#define CKM_NETSCAPE_PBE_MD5_HMAC_KEY_GEN CKM_NSS_PBE_MD5_HMAC_KEY_GEN +#define CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN CKM_NSS_PBE_MD2_HMAC_KEY_GEN +#define CKR_NETSCAPE_CERTDB_FAILED CKR_NSS_CERTDB_FAILED +#define CKR_NETSCAPE_KEYDB_FAILED CKR_NSS_KEYDB_FAILED + +#define CKT_NETSCAPE_TRUSTED CKT_NSS_TRUSTED +#define CKT_NETSCAPE_TRUSTED_DELEGATOR CKT_NSS_TRUSTED_DELEGATOR +#define CKT_NETSCAPE_UNTRUSTED CKT_NSS_UNTRUSTED +#define CKT_NETSCAPE_MUST_VERIFY CKT_NSS_MUST_VERIFY +#define CKT_NETSCAPE_TRUST_UNKNOWN CKT_NSS_TRUST_UNKNOWN +#define CKT_NETSCAPE_VALID CKT_NSS_VALID +#define CKT_NETSCAPE_VALID_DELEGATOR CKT_NSS_VALID_DELEGATOR +#else +/* use the new CK_GCM_PARAMS if NSS_PKCS11_2_0_COMPAT is not defined */ +typedef struct CK_GCM_PARAMS_V3 CK_GCM_PARAMS; +typedef CK_GCM_PARAMS_V3 CK_PTR CK_GCM_PARAMS_PTR; +#endif + +#endif /* _PKCS11N_H_ */ diff --git a/illumos-x86_64/usr/include/mps/pkcs11p.h b/illumos-x86_64/usr/include/mps/pkcs11p.h new file mode 100644 index 00000000..1c920135 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs11p.h @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* + * Copyright (C) 1994-1999 RSA Security Inc. Licence to copy this document + * is granted provided that it is identified as "RSA Security Inc. Public-Key + * Cryptography Standards (PKCS)" in all material mentioning or referencing + * this document. + */ +/* these data types are platform/implementation dependent. */ +/* + * Packing was removed from the shipped RSA header files, even + * though it's still needed. put in a central file to help merging.. + */ + +#if defined(_WIN32) || defined(_WINDOWS) +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpragma-pack" +#endif +#ifdef _MSC_VER +#pragma warning(disable : 4103) +#endif +#pragma pack(push, cryptoki, 1) +#endif diff --git a/illumos-x86_64/usr/include/mps/pkcs11t.h b/illumos-x86_64/usr/include/mps/pkcs11t.h new file mode 100644 index 00000000..6c068618 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs11t.h @@ -0,0 +1,3025 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* License to copy and use this software is granted provided that it is + * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface + * (Cryptoki)" in all material mentioning or referencing this software. + + * License is also granted to make and use derivative works provided that + * such works are identified as "derived from the RSA Security Inc. PKCS #11 + * Cryptographic Token Interface (Cryptoki)" in all material mentioning or + * referencing the derived work. + + * RSA Security Inc. makes no representations concerning either the + * merchantability of this software or the suitability of this software for + * any particular purpose. It is provided "as is" without express or implied + * warranty of any kind. + */ + +#ifndef _PKCS11T_H_ +#define _PKCS11T_H_ 1 + +#define CK_TRUE 1 +#define CK_FALSE 0 + +#include "prtypes.h" + +#define CK_PTR * +#define CK_NULL_PTR 0 +#define CK_CALLBACK_FUNCTION(rtype, func) rtype(PR_CALLBACK *func) +#define CK_DECLARE_FUNCTION(rtype, func) extern rtype func +#define CK_DECLARE_FUNCTION_POINTER(rtype, func) rtype(PR_CALLBACK *func) + +#ifdef NSS_PCKS11_2_0_COMPAT +#define prfHashMechanism prfMechanism +#endif + +#define CRYPTOKI_VERSION_MAJOR 3 +#define CRYPTOKI_VERSION_MINOR 2 +#define CRYPTOKI_VERSION_AMENDMENT 0 + +/* an unsigned 8-bit value */ +typedef unsigned char CK_BYTE; + +/* an unsigned 8-bit character */ +typedef CK_BYTE CK_CHAR; + +/* an 8-bit UTF-8 character */ +typedef CK_BYTE CK_UTF8CHAR; + +/* a BYTE-sized Boolean flag */ +typedef CK_BYTE CK_BBOOL; + +/* an unsigned value, at least 32 bits long */ +typedef unsigned long int CK_ULONG; + +/* a signed value, the same size as a CK_ULONG */ +/* CK_LONG is new for v2.0 */ +typedef long int CK_LONG; + +/* at least 32 bits; each bit is a Boolean flag */ +typedef CK_ULONG CK_FLAGS; + +/* some special values for certain CK_ULONG variables */ +#define CK_UNAVAILABLE_INFORMATION (~0UL) +#define CK_EFFECTIVELY_INFINITE 0 + +typedef CK_BYTE CK_PTR CK_BYTE_PTR; +typedef CK_CHAR CK_PTR CK_CHAR_PTR; +typedef CK_UTF8CHAR CK_PTR CK_UTF8CHAR_PTR; +typedef CK_ULONG CK_PTR CK_ULONG_PTR; +typedef void CK_PTR CK_VOID_PTR; +typedef CK_ULONG CK_PTR CK_FLAGS_PTR; + +/* Pointer to a CK_VOID_PTR-- i.e., pointer to pointer to void */ +typedef CK_VOID_PTR CK_PTR CK_VOID_PTR_PTR; + +/* The following value is always invalid if used as a session */ +/* handle or object handle */ +#define CK_INVALID_HANDLE 0 + +/* pack */ +#include "pkcs11p.h" + +typedef struct CK_VERSION { + CK_BYTE major; /* integer portion of version number */ + CK_BYTE minor; /* 1/100ths portion of version number */ +} CK_VERSION; + +typedef CK_VERSION CK_PTR CK_VERSION_PTR; + +typedef struct CK_INFO { + /* manufacturerID and libraryDecription have been changed from + * CK_CHAR to CK_UTF8CHAR for v2.10 */ + CK_VERSION cryptokiVersion; /* PKCS #11 interface ver */ + CK_UTF8CHAR manufacturerID[32]; /* blank padded */ + CK_FLAGS flags; /* must be zero */ + /* libraryDescription and libraryVersion are new for v2.0 */ + CK_UTF8CHAR libraryDescription[32]; /* blank padded */ + CK_VERSION libraryVersion; /* version of library */ +} CK_INFO; + +typedef CK_INFO CK_PTR CK_INFO_PTR; + +/* CK_NOTIFICATION enumerates the types of notifications that + * PKCS #11 provides to an application */ +/* CK_NOTIFICATION has been changed from an enum to a CK_ULONG + * for v2.0 */ +typedef CK_ULONG CK_NOTIFICATION; +#define CKN_SURRENDER 0 +#define CKN_OTP_CHANGED 1 + +typedef CK_ULONG CK_SLOT_ID; + +typedef CK_SLOT_ID CK_PTR CK_SLOT_ID_PTR; + +/* CK_SLOT_INFO provides information about a slot */ +typedef struct CK_SLOT_INFO { + /* slotDescription and manufacturerID have been changed from + * CK_CHAR to CK_UTF8CHAR for v2.10 */ + CK_UTF8CHAR slotDescription[64]; /* blank padded */ + CK_UTF8CHAR manufacturerID[32]; /* blank padded */ + CK_FLAGS flags; + + /* hardwareVersion and firmwareVersion are new for v2.0 */ + CK_VERSION hardwareVersion; /* version of hardware */ + CK_VERSION firmwareVersion; /* version of firmware */ +} CK_SLOT_INFO; + +/* flags: bit flags that provide capabilities of the slot + * Bit Flag Mask Meaning + */ +#define CKF_TOKEN_PRESENT 0x00000001UL /* a token is there */ +#define CKF_REMOVABLE_DEVICE 0x00000002UL /* removable devices*/ +#define CKF_HW_SLOT 0x00000004UL /* hardware slot */ + +typedef CK_SLOT_INFO CK_PTR CK_SLOT_INFO_PTR; + +/* CK_TOKEN_INFO provides information about a token */ +typedef struct CK_TOKEN_INFO { + /* label, manufacturerID, and model have been changed from + * CK_CHAR to CK_UTF8CHAR for v2.10 */ + CK_UTF8CHAR label[32]; /* blank padded */ + CK_UTF8CHAR manufacturerID[32]; /* blank padded */ + CK_UTF8CHAR model[16]; /* blank padded */ + CK_CHAR serialNumber[16]; /* blank padded */ + CK_FLAGS flags; /* see below */ + + /* ulMaxSessionCount, ulSessionCount, ulMaxRwSessionCount, + * ulRwSessionCount, ulMaxPinLen, and ulMinPinLen have all been + * changed from CK_USHORT to CK_ULONG for v2.0 */ + CK_ULONG ulMaxSessionCount; /* max open sessions */ + CK_ULONG ulSessionCount; /* sess. now open */ + CK_ULONG ulMaxRwSessionCount; /* max R/W sessions */ + CK_ULONG ulRwSessionCount; /* R/W sess. now open */ + CK_ULONG ulMaxPinLen; /* in bytes */ + CK_ULONG ulMinPinLen; /* in bytes */ + CK_ULONG ulTotalPublicMemory; /* in bytes */ + CK_ULONG ulFreePublicMemory; /* in bytes */ + CK_ULONG ulTotalPrivateMemory; /* in bytes */ + CK_ULONG ulFreePrivateMemory; /* in bytes */ + + /* hardwareVersion, firmwareVersion, and time are new for + * v2.0 */ + CK_VERSION hardwareVersion; /* version of hardware */ + CK_VERSION firmwareVersion; /* version of firmware */ + CK_CHAR utcTime[16]; /* time */ +} CK_TOKEN_INFO; + +/* The flags parameter is defined as follows: + * Bit Flag Mask Meaning + */ +#define CKF_RNG 0x00000001UL /* has random # \ + * generator */ +#define CKF_WRITE_PROTECTED 0x00000002UL /* token is \ + * write- \ + * protected */ +#define CKF_LOGIN_REQUIRED 0x00000004UL /* user must \ + * login */ +#define CKF_USER_PIN_INITIALIZED 0x00000008UL /* normal user's \ + * PIN is set */ + +/* CKF_RESTORE_KEY_NOT_NEEDED is new for v2.0. If it is set, + * that means that *every* time the state of cryptographic + * operations of a session is successfully saved, all keys + * needed to continue those operations are stored in the state */ +#define CKF_RESTORE_KEY_NOT_NEEDED 0x00000020UL + +/* CKF_CLOCK_ON_TOKEN is new for v2.0. If it is set, that means + * that the token has some sort of clock. The time on that + * clock is returned in the token info structure */ +#define CKF_CLOCK_ON_TOKEN 0x00000040UL + +/* CKF_PROTECTED_AUTHENTICATION_PATH is new for v2.0. If it is + * set, that means that there is some way for the user to login + * without sending a PIN through the PKCS #11 library itself */ +#define CKF_PROTECTED_AUTHENTICATION_PATH 0x00000100UL + +/* CKF_DUAL_CRYPTO_OPERATIONS is new for v2.0. If it is true, + * that means that a single session with the token can perform + * dual simultaneous cryptographic operations (digest and + * encrypt; decrypt and digest; sign and encrypt; and decrypt + * and sign) */ +#define CKF_DUAL_CRYPTO_OPERATIONS 0x00000200UL + +/* CKF_TOKEN_INITIALIZED if new for v2.10. If it is true, the + * token has been initialized using C_InitializeToken or an + * equivalent mechanism outside the scope of PKCS #11. + * Calling C_InitializeToken when this flag is set will cause + * the token to be reinitialized. */ +#define CKF_TOKEN_INITIALIZED 0x00000400UL + +/* CKF_SECONDARY_AUTHENTICATION if new for v2.10. If it is + * true, the token supports secondary authentication for + * private key objects. This flag is deprecated in v2.11 and + onwards. */ +#define CKF_SECONDARY_AUTHENTICATION 0x00000800UL + +/* CKF_USER_PIN_COUNT_LOW if new for v2.10. If it is true, an + * incorrect user login PIN has been entered at least once + * since the last successful authentication. */ +#define CKF_USER_PIN_COUNT_LOW 0x00010000UL + +/* CKF_USER_PIN_FINAL_TRY if new for v2.10. If it is true, + * supplying an incorrect user PIN will it to become locked. */ +#define CKF_USER_PIN_FINAL_TRY 0x00020000UL + +/* CKF_USER_PIN_LOCKED if new for v2.10. If it is true, the + * user PIN has been locked. User login to the token is not + * possible. */ +#define CKF_USER_PIN_LOCKED 0x00040000UL + +/* CKF_USER_PIN_TO_BE_CHANGED if new for v2.10. If it is true, + * the user PIN value is the default value set by token + * initialization or manufacturing, or the PIN has been + * expired by the card. */ +#define CKF_USER_PIN_TO_BE_CHANGED 0x00080000UL + +/* CKF_SO_PIN_COUNT_LOW if new for v2.10. If it is true, an + * incorrect SO login PIN has been entered at least once since + * the last successful authentication. */ +#define CKF_SO_PIN_COUNT_LOW 0x00100000UL + +/* CKF_SO_PIN_FINAL_TRY if new for v2.10. If it is true, + * supplying an incorrect SO PIN will it to become locked. */ +#define CKF_SO_PIN_FINAL_TRY 0x00200000UL + +/* CKF_SO_PIN_LOCKED if new for v2.10. If it is true, the SO + * PIN has been locked. SO login to the token is not possible. + */ +#define CKF_SO_PIN_LOCKED 0x00400000UL + +/* CKF_SO_PIN_TO_BE_CHANGED if new for v2.10. If it is true, + * the SO PIN value is the default value set by token + * initialization or manufacturing, or the PIN has been + * expired by the card. */ +#define CKF_SO_PIN_TO_BE_CHANGED 0x00800000UL + +#define CKF_ERROR_STATE 0x01000000UL + +/* CKF_SEED_RANDOM_REQUIRED new for v3.2. If this is true, the + * token's RNG must be seeded with C_SeedRandom */ +#define CKF_SEED_RANDOM_REQUIRED 0x02000000UL +/* CKF_ASYNC_SESSION_SUPPORTED new for v3.2. If this is true + * this token supports async operations */ +#define CKF_ASYNC_SESSION_SUPPORTED 0x04000000UL + +typedef CK_TOKEN_INFO CK_PTR CK_TOKEN_INFO_PTR; + +/* CK_SESSION_HANDLE is a PKCS #11-assigned value that + * identifies a session */ +typedef CK_ULONG CK_SESSION_HANDLE; + +typedef CK_SESSION_HANDLE CK_PTR CK_SESSION_HANDLE_PTR; + +/* CK_USER_TYPE enumerates the types of PKCS #11 users */ +/* CK_USER_TYPE has been changed from an enum to a CK_ULONG for + * v2.0 */ +typedef CK_ULONG CK_USER_TYPE; +/* Security Officer */ +#define CKU_SO 0 +/* Normal user */ +#define CKU_USER 1 +/* Context specific (added in v2.20) */ +#define CKU_CONTEXT_SPECIFIC 2 + +/* CK_STATE enumerates the session states */ +/* CK_STATE has been changed from an enum to a CK_ULONG for + * v2.0 */ +typedef CK_ULONG CK_STATE; +#define CKS_RO_PUBLIC_SESSION 0 +#define CKS_RO_USER_FUNCTIONS 1 +#define CKS_RW_PUBLIC_SESSION 2 +#define CKS_RW_USER_FUNCTIONS 3 +#define CKS_RW_SO_FUNCTIONS 4 + +/* CK_SESSION_INFO provides information about a session */ +typedef struct CK_SESSION_INFO { + CK_SLOT_ID slotID; + CK_STATE state; + CK_FLAGS flags; /* see below */ + + /* ulDeviceError was changed from CK_USHORT to CK_ULONG for + * v2.0 */ + CK_ULONG ulDeviceError; /* device-dependent error code */ +} CK_SESSION_INFO; + +/* The flags are defined in the following table: + * Bit Flag Mask Meaning + */ +#define CKF_RW_SESSION 0x00000002UL /* session is r/w */ +#define CKF_SERIAL_SESSION 0x00000004UL /* no parallel */ +/* new for v3.2 this session is async */ +#define CKF_ASYNC_SESSION 0x00000008UL + +typedef CK_SESSION_INFO CK_PTR CK_SESSION_INFO_PTR; + +/* CK_OBJECT_HANDLE is a token-specific identifier for an + * object */ +typedef CK_ULONG CK_OBJECT_HANDLE; + +typedef CK_OBJECT_HANDLE CK_PTR CK_OBJECT_HANDLE_PTR; + +/* CK_OBJECT_CLASS is a value that identifies the classes (or + * types) of objects that PKCS #11 recognizes. It is defined + * as follows: */ +/* CK_OBJECT_CLASS was changed from CK_USHORT to CK_ULONG for + * v2.0 */ +typedef CK_ULONG CK_OBJECT_CLASS; + +/* The following classes of objects are defined: */ +/* CKO_HW_FEATURE is new for v2.10 */ +/* CKO_DOMAIN_PARAMETERS is new for v2.11 */ +/* CKO_MECHANISM is new for v2.20 */ +/* CKO_PROFILE is new for v3.00 */ +#define CKO_DATA 0x00000000UL +#define CKO_CERTIFICATE 0x00000001UL +#define CKO_PUBLIC_KEY 0x00000002UL +#define CKO_PRIVATE_KEY 0x00000003UL +#define CKO_SECRET_KEY 0x00000004UL +#define CKO_HW_FEATURE 0x00000005UL +#define CKO_DOMAIN_PARAMETERS 0x00000006UL +#define CKO_MECHANISM 0x00000007UL +#define CKO_OTP_KEY 0x00000008UL +#define CKO_PROFILE 0x00000009UL +/* new for v3.2 */ +#define CKO_TRUST 0x0000000bUL +#define CKO_VALIDATION 0x0000000aUL + +#define CKO_VENDOR_DEFINED 0x80000000UL + +typedef CK_OBJECT_CLASS CK_PTR CK_OBJECT_CLASS_PTR; + +/* CK_PROFILE_ID is new for v3.00. CK_PROFILE_ID is a value that + * identifies the profile that the token supports. */ +typedef CK_ULONG CK_PROFILE_ID; +typedef CK_PROFILE_ID CK_PTR CK_PROFILE_ID_PTR; + +/* Profile ID's */ +#define CKP_INVALID_ID 0x00000000UL +#define CKP_BASELINE_PROVIDER 0x00000001UL +#define CKP_EXTENDED_PROVIDER 0x00000002UL +#define CKP_AUTHENTICATION_TOKEN 0x00000003UL +#define CKP_PUBLIC_CERTIFICATES_TOKEN 0x00000004UL +#define CKP_COMPLETE_PROVIDER 0x00000005UL +#define CKP_HKDF_TLS_TOKEN 0x00000006UL + +#define CKP_VENDOR_DEFINED 0x80000000UL + +/* CK_HW_FEATURE_TYPE is new for v2.10. CK_HW_FEATURE_TYPE is a + * value that identifies the hardware feature type of an object + * with CK_OBJECT_CLASS equal to CKO_HW_FEATURE. */ +typedef CK_ULONG CK_HW_FEATURE_TYPE; + +/* The following hardware feature types are defined */ +/* CKH_USER_INTERFACE is new for v2.20 */ +#define CKH_MONOTONIC_COUNTER 0x00000001UL +#define CKH_CLOCK 0x00000002UL +#define CKH_USER_INTERFACE 0x00000003UL +#define CKH_VENDOR_DEFINED 0x80000000UL + +/* CK_KEY_TYPE is a value that identifies a key type */ +/* CK_KEY_TYPE was changed from CK_USHORT to CK_ULONG for v2.0 */ +typedef CK_ULONG CK_KEY_TYPE; + +/* the following key types are defined: */ +#define CKK_RSA 0x00000000UL +#define CKK_DSA 0x00000001UL +#define CKK_DH 0x00000002UL + +/* CKK_ECDSA and CKK_KEA are new for v2.0 */ +/* CKK_ECDSA is deprecated in v2.11, CKK_EC is preferred. */ +#define CKK_ECDSA 0x00000003UL +#define CKK_EC 0x00000003UL +#define CKK_X9_42_DH 0x00000004UL +#define CKK_KEA 0x00000005UL + +#define CKK_GENERIC_SECRET 0x00000010UL +#define CKK_RC2 0x00000011UL +#define CKK_RC4 0x00000012UL +#define CKK_DES 0x00000013UL +#define CKK_DES2 0x00000014UL +#define CKK_DES3 0x00000015UL + +/* all these key types are new for v2.0 */ +#define CKK_CAST 0x00000016UL +#define CKK_CAST3 0x00000017UL +/* CKK_CAST5 is deprecated in v2.11, CKK_CAST128 is preferred. */ +#define CKK_CAST5 0x00000018UL +#define CKK_CAST128 0x00000018UL +#define CKK_RC5 0x00000019UL +#define CKK_IDEA 0x0000001AUL +#define CKK_SKIPJACK 0x0000001BUL +#define CKK_BATON 0x0000001CUL +#define CKK_JUNIPER 0x0000001DUL +#define CKK_CDMF 0x0000001EUL +#define CKK_AES 0x0000001FUL + +/* BlowFish and TwoFish are new for v2.20 */ +#define CKK_BLOWFISH 0x00000020UL +#define CKK_TWOFISH 0x00000021UL + +/* New for v3.1 */ +#define CKK_SECURID 0x00000022UL +#define CKK_ACTI 0x00000024UL +#define CKK_HOTP 0x00000023UL + +/* Camellia is proposed for v2.20 Amendment 3 */ +#define CKK_CAMELLIA 0x00000025UL + +#define CKK_SEED 0x0000002FUL /* was 2A */ + +/* added in v2.30 */ +#define CKK_ARIA 0x00000026UL + +/* added in 2.40 */ +#define CKK_MD5_HMAC 0x00000027UL +#define CKK_SHA_1_HMAC 0x00000028UL +#define CKK_RIPEMD128_HMAC 0x00000029UL +#define CKK_RIPEMD160_HMAC 0x0000002AUL +#define CKK_SHA256_HMAC 0x0000002BUL +#define CKK_SHA384_HMAC 0x0000002CUL +#define CKK_SHA512_HMAC 0x0000002DUL +#define CKK_SHA224_HMAC 0x0000002EUL +#define CKK_GOSTR3410 0x00000030UL +#define CKK_GOSTR3411 0x00000031UL +#define CKK_GOST28147 0x00000032UL +#define CKK_CHACHA20 0x00000033UL +#define CKK_POLY1305 0x00000034UL +#define CKK_AES_XTS 0x00000035UL +#define CKK_SHA3_224_HMAC 0x00000036UL +#define CKK_SHA3_256_HMAC 0x00000037UL +#define CKK_SHA3_384_HMAC 0x00000038UL +#define CKK_SHA3_512_HMAC 0x00000039UL + +/* added in 3.0 */ +#define CKK_BLAKE2B_160_HMAC 0x0000003aUL +#define CKK_BLAKE2B_256_HMAC 0x0000003bUL +#define CKK_BLAKE2B_384_HMAC 0x0000003cUL +#define CKK_BLAKE2B_512_HMAC 0x0000003dUL +#define CKK_SALSA20 0x0000003eUL +#define CKK_X2RATCHET 0x0000003fUL +#define CKK_EC_EDWARDS 0x00000040UL +#define CKK_EC_MONTGOMERY 0x00000041UL +#define CKK_HKDF 0x00000042UL +#define CKK_SHA512_224_HMAC 0x00000043UL +#define CKK_SHA512_256_HMAC 0x00000044UL +#define CKK_SHA512_T_HMAC 0x00000045UL + +/* New for v3.1 */ +#define CKK_HSS 0x00000046UL + +/* New for v3.2 */ +#define CKK_ML_DSA 0x0000004aUL +#define CKK_ML_KEM 0x00000049UL +#define CKK_SLH_DSA 0x0000004bUL +#define CKK_XMSS 0x00000047UL +#define CKK_XMSSMT 0x00000048UL + +#define CKK_VENDOR_DEFINED 0x80000000UL + +/* CK_CERTIFICATE_TYPE is a value that identifies a certificate + * type */ +/* CK_CERTIFICATE_TYPE was changed from CK_USHORT to CK_ULONG + * for v2.0 */ +typedef CK_ULONG CK_CERTIFICATE_TYPE; + +/* The following certificate types are defined: */ +/* CKC_X_509_ATTR_CERT is new for v2.10 */ +/* CKC_WTLS is new for v2.20 */ +#define CKC_X_509 0x00000000UL +#define CKC_X_509_ATTR_CERT 0x00000001UL +#define CKC_WTLS 0x00000002UL +#define CKC_VENDOR_DEFINED 0x80000000UL + +/* CK_ATTRIBUTE_TYPE is a value that identifies an attribute + * type */ +/* CK_ATTRIBUTE_TYPE was changed from CK_USHORT to CK_ULONG for + * v2.0 */ +typedef CK_ULONG CK_ATTRIBUTE_TYPE; + +/* values for CKA_CERTIFICATE_CATEGORY v2.20 */ +typedef CK_ULONG CK_CERTIFICATE_CATEGORY; +#define CK_CERTIFICATE_CATEGORY_UNSPECIFIED 0UL +#define CK_CERTIFICATE_CATEGORY_TOKEN_USER 1UL +#define CK_CERTIFICATE_CATEGORY_AUTHORITY 2UL +#define CK_CERTIFICATE_CATEGORY_OTHER_ENTITY 3UL + +/* values for CKA_JAVA_MIDP_SECURITY_DOMAIN v2.20 */ +typedef CK_ULONG CK_JAVA_MIDP_SECURITY_DOMAIN; +#define CK_SECURITY_DOMAIN_UNSPECIFIED 0UL +#define CK_SECURITY_DOMAIN_MANUFACTURER 1UL +#define CK_SECURITY_DOMAIN_OPERATOR 2UL +#define CK_SECURITY_DOMAIN_THIRD_PARTY 3UL + +/* values for CKA_OTP_FORMAT */ +#define CK_OTP_FORMAT_DECIMAL 0UL +#define CK_OTP_FORMAT_HEXADECIMAL 1UL +#define CK_OTP_FORMAT_ALPHANUMERIC 2UL +#define CK_OTP_FORMAT_BINARY 3UL + +/* values for CKA_OTP_CHALLENGE_REQUIREMENT, CKA_OTP_TIME_REQUIREMENT, + * CKA_OTP_COUNTER_REQUIREMENT, CKA_OTP_PIN_REQUIREMENT */ +#define CK_OTP_PARAM_IGNORED 0UL +#define CK_OTP_PARAM_OPTIONAL 1UL +#define CK_OTP_PARAM_MANDATORY 2UL + +/* The CKF_ARRAY_ATTRIBUTE flag identifies an attribute which + consists of an array of values. */ +#define CKF_ARRAY_ATTRIBUTE 0x40000000UL + +/* The following attribute types are defined: */ +#define CKA_CLASS 0x00000000UL +#define CKA_TOKEN 0x00000001UL +#define CKA_PRIVATE 0x00000002UL +#define CKA_LABEL 0x00000003UL +/* new for v3.1 */ +#define CKA_UNIQUE_ID 0x00000004UL + +#define CKA_APPLICATION 0x00000010UL +#define CKA_VALUE 0x00000011UL + +/* CKA_OBJECT_ID is new for v2.10 */ +#define CKA_OBJECT_ID 0x00000012UL + +#define CKA_CERTIFICATE_TYPE 0x00000080UL +#define CKA_ISSUER 0x00000081UL +#define CKA_SERIAL_NUMBER 0x00000082UL + +/* CKA_AC_ISSUER, CKA_OWNER, and CKA_ATTR_TYPES are new + * for v2.10 */ +#define CKA_AC_ISSUER 0x00000083UL +#define CKA_OWNER 0x00000084UL +#define CKA_ATTR_TYPES 0x00000085UL + +/* CKA_TRUSTED is new for v2.11 */ +#define CKA_TRUSTED 0x00000086UL + +/* CKA_CERTIFICATE_CATEGORY ... + * CKA_CHECK_VALUE are new for v2.20 */ +#define CKA_CERTIFICATE_CATEGORY 0x00000087UL +#define CKA_JAVA_MIDP_SECURITY_DOMAIN 0x00000088UL +#define CKA_URL 0x00000089UL +#define CKA_HASH_OF_SUBJECT_PUBLIC_KEY 0x0000008AUL +#define CKA_HASH_OF_ISSUER_PUBLIC_KEY 0x0000008BUL + +/* new for v3.1 */ +#define CKA_NAME_HASH_ALGORITHM 0x0000008cUL + +#define CKA_CHECK_VALUE 0x00000090UL + +#define CKA_KEY_TYPE 0x00000100UL +#define CKA_SUBJECT 0x00000101UL +#define CKA_ID 0x00000102UL +#define CKA_SENSITIVE 0x00000103UL +#define CKA_ENCRYPT 0x00000104UL +#define CKA_DECRYPT 0x00000105UL +#define CKA_WRAP 0x00000106UL +#define CKA_UNWRAP 0x00000107UL +#define CKA_SIGN 0x00000108UL +#define CKA_SIGN_RECOVER 0x00000109UL +#define CKA_VERIFY 0x0000010AUL +#define CKA_VERIFY_RECOVER 0x0000010BUL +#define CKA_DERIVE 0x0000010CUL +#define CKA_START_DATE 0x00000110UL +#define CKA_END_DATE 0x00000111UL +#define CKA_MODULUS 0x00000120UL +#define CKA_MODULUS_BITS 0x00000121UL +#define CKA_PUBLIC_EXPONENT 0x00000122UL +#define CKA_PRIVATE_EXPONENT 0x00000123UL +#define CKA_PRIME_1 0x00000124UL +#define CKA_PRIME_2 0x00000125UL +#define CKA_EXPONENT_1 0x00000126UL +#define CKA_EXPONENT_2 0x00000127UL +#define CKA_COEFFICIENT 0x00000128UL +/* CKA_PUBLIC_KEY_INFO is new for v2.40 */ +#define CKA_PUBLIC_KEY_INFO 0x00000129UL +#define CKA_PRIME 0x00000130UL +#define CKA_SUBPRIME 0x00000131UL +#define CKA_BASE 0x00000132UL + +/* CKA_PRIME_BITS and CKA_SUB_PRIME_BITS are new for v2.11 */ +#define CKA_PRIME_BITS 0x00000133UL +#define CKA_SUBPRIME_BITS 0x00000134UL +#define CKA_SUB_PRIME_BITS CKA_SUBPRIME_BITS +/* (To retain backwards-compatibility) */ + +#define CKA_VALUE_BITS 0x00000160UL +#define CKA_VALUE_LEN 0x00000161UL + +/* CKA_EXTRACTABLE, CKA_LOCAL, CKA_NEVER_EXTRACTABLE, + * CKA_ALWAYS_SENSITIVE, CKA_MODIFIABLE, CKA_ECDSA_PARAMS, + * and CKA_EC_POINT are new for v2.0 */ +#define CKA_EXTRACTABLE 0x00000162UL +#define CKA_LOCAL 0x00000163UL +#define CKA_NEVER_EXTRACTABLE 0x00000164UL +#define CKA_ALWAYS_SENSITIVE 0x00000165UL + +/* CKA_KEY_GEN_MECHANISM is new for v2.11 */ +#define CKA_KEY_GEN_MECHANISM 0x00000166UL + +#define CKA_MODIFIABLE 0x00000170UL + +/* New for 2.40 */ +#define CKA_COPYABLE 0x00000171UL +#define CKA_DESTROYABLE 0x00000172UL + +/* CKA_ECDSA_PARAMS is deprecated in v2.11, + * CKA_EC_PARAMS is preferred. */ +#define CKA_ECDSA_PARAMS 0x00000180UL +#define CKA_EC_PARAMS 0x00000180UL + +#define CKA_EC_POINT 0x00000181UL + +/* CKA_SECONDARY_AUTH, CKA_AUTH_PIN_FLAGS, + * are new for v2.10. Deprecated in v2.11 and onwards. */ +#define CKA_SECONDARY_AUTH 0x00000200UL +#define CKA_AUTH_PIN_FLAGS 0x00000201UL + +/* CKA_ALWAYS_AUTHENTICATE ... + * CKA_UNWRAP_TEMPLATE are new for v2.20 */ +#define CKA_ALWAYS_AUTHENTICATE 0x00000202UL + +#define CKA_WRAP_WITH_TRUSTED 0x00000210UL +#define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x00000211UL) +#define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x00000212UL) + +/* new for 2.40 */ +#define CKA_DERIVE_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x00000213UL) +#define CKA_OTP_FORMAT 0x00000220UL +#define CKA_OTP_LENGTH 0x00000221UL +#define CKA_OTP_TIME_INTERVAL 0x00000222UL +#define CKA_OTP_USER_FRIENDLY_MODE 0x00000223UL +#define CKA_OTP_CHALLENGE_REQUIREMENT 0x00000224UL +#define CKA_OTP_TIME_REQUIREMENT 0x00000225UL +#define CKA_OTP_COUNTER_REQUIREMENT 0x00000226UL +#define CKA_OTP_PIN_REQUIREMENT 0x00000227UL +#define CKA_OTP_COUNTER 0x0000022EUL +#define CKA_OTP_TIME 0x0000022FUL +#define CKA_OTP_USER_IDENTIFIER 0x0000022AUL +#define CKA_OTP_SERVICE_IDENTIFIER 0x0000022BUL +#define CKA_OTP_SERVICE_LOGO 0x0000022CUL +#define CKA_OTP_SERVICE_LOGO_TYPE 0x0000022DUL +#define CKA_GOSTR3410_PARAMS 0x00000250UL +#define CKA_GOSTR3411_PARAMS 0x00000251UL +#define CKA_GOST28147_PARAMS 0x00000252UL + +/* CKA_HW_FEATURE_TYPE, CKA_RESET_ON_INIT, and CKA_HAS_RESET + * are new for v2.10 */ +#define CKA_HW_FEATURE_TYPE 0x00000300UL +#define CKA_RESET_ON_INIT 0x00000301UL +#define CKA_HAS_RESET 0x00000302UL + +/* The following attributes are new for v2.20 */ +#define CKA_PIXEL_X 0x00000400UL +#define CKA_PIXEL_Y 0x00000401UL +#define CKA_RESOLUTION 0x00000402UL +#define CKA_CHAR_ROWS 0x00000403UL +#define CKA_CHAR_COLUMNS 0x00000404UL +#define CKA_COLOR 0x00000405UL +#define CKA_BITS_PER_PIXEL 0x00000406UL +#define CKA_CHAR_SETS 0x00000480UL +#define CKA_ENCODING_METHODS 0x00000481UL +#define CKA_MIME_TYPES 0x00000482UL +#define CKA_MECHANISM_TYPE 0x00000500UL +#define CKA_REQUIRED_CMS_ATTRIBUTES 0x00000501UL +#define CKA_DEFAULT_CMS_ATTRIBUTES 0x00000502UL +#define CKA_SUPPORTED_CMS_ATTRIBUTES 0x00000503UL +#define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE | 0x00000600UL) + +/* new for v3.0 */ +#define CKA_PROFILE_ID 0x00000601UL +#define CKA_X2RATCHET_BAG 0x00000602UL +#define CKA_X2RATCHET_BAGSIZE 0x00000603UL +#define CKA_X2RATCHET_BOBS1STMSG 0x00000604UL +#define CKA_X2RATCHET_CKR 0x00000605UL +#define CKA_X2RATCHET_CKS 0x00000606UL +#define CKA_X2RATCHET_DHP 0x00000607UL +#define CKA_X2RATCHET_DHR 0x00000608UL +#define CKA_X2RATCHET_DHS 0x00000609UL +#define CKA_X2RATCHET_HKR 0x0000060aUL +#define CKA_X2RATCHET_HKS 0x0000060bUL +#define CKA_X2RATCHET_ISALICE 0x0000060cUL +#define CKA_X2RATCHET_NHKR 0x0000060dUL +#define CKA_X2RATCHET_NHKS 0x0000060eUL +#define CKA_X2RATCHET_NR 0x0000060fUL +#define CKA_X2RATCHET_NS 0x00000610UL +#define CKA_X2RATCHET_PNS 0x00000611UL +#define CKA_X2RATCHET_RK 0x00000612UL + +/* new for v3.1 */ +#define CKA_HSS_LEVELS 0x00000617UL +#define CKA_HSS_LMS_TYPE 0x00000618UL +#define CKA_HSS_LMOTS_TYPE 0x00000619UL +#define CKA_HSS_LMS_TYPES 0x0000061aUL +#define CKA_HSS_LMOTS_TYPES 0x0000061bUL +#define CKA_HSS_KEYS_REMAINING 0x0000061cUL + +/* new for v3.2 */ +#define CKA_PARAMETER_SET 0x0000061dUL +#define CKA_OBJECT_VALIDATION_FLAGS 0x0000061eUL +#define CKA_VALIDATION_TYPE 0x0000061fUL +#define CKA_VALIDATION_VERSION 0x00000620UL +#define CKA_VALIDATION_LEVEL 0x00000621UL +#define CKA_VALIDATION_MODULE_ID 0x00000622UL +#define CKA_VALIDATION_FLAG 0x00000623UL +#define CKA_VALIDATION_AUTHORITY_TYPE 0x00000624UL +#define CKA_VALIDATION_COUNTRY 0x00000625UL +#define CKA_VALIDATION_CERTIFICATE_IDENTIFIER 0x00000626UL +#define CKA_VALIDATION_CERTIFICATE_URI 0x00000627UL +#define CKA_VALIDATION_PROFILE 0x00000629UL +#define CKA_VALIDATION_VENDOR_URI 0x00000628UL +#define CKA_ENCAPSULATE_TEMPLATE 0x0000062aUL +#define CKA_DECAPSULATE_TEMPLATE 0x0000062bUL +/* some trust atributes collide with the NSS vendor + * specific names. Separate those trust + * attributes into _NSS_ and _PKCS_ versions + * pkcs11n.h has a define, NSS_USE_STANDARD_TRUST + * to select which values CKA_TRUST_xxxx takes + * on. Old applications can use the headers + * normally, new applications can set + * NSS_USE_STANDARD_TRUST to get the standard + * values. */ +#define CKA_PKCS_TRUST_SERVER_AUTH 0x0000062cUL +#define CKA_PKCS_TRUST_CLIENT_AUTH 0x0000062dUL +#define CKA_PKCS_TRUST_CODE_SIGNING 0x0000062eUL +#define CKA_PKCS_TRUST_EMAIL_PROTECTION 0x0000062fUL +#define CKA_TRUST_IPSEC_IKE 0x00000630UL +#define CKA_PKCS_TRUST_TIME_STAMPING 0x00000631UL +#define CKA_PKCS_TRUST_OCSP_SIGNING 0x00000632UL +#define CKA_ENCAPSULATE 0x00000633UL +#define CKA_DECAPSULATE 0x00000634UL +#define CKA_HASH_OF_CERTIFICATE 0x00000635UL +#define CKA_PUBLIC_CRC64_VALUE 0x00000636UL +#define CKA_SEED 0x00000637UL + +#define CKA_VENDOR_DEFINED 0x80000000UL + +/* CK_ATTRIBUTE is a structure that includes the type, length + * and value of an attribute */ +typedef struct CK_ATTRIBUTE { + CK_ATTRIBUTE_TYPE type; + CK_VOID_PTR pValue; + /* ulValueLen went from CK_USHORT to CK_ULONG for v2.0 */ + CK_ULONG ulValueLen; /* in bytes */ +} CK_ATTRIBUTE; + +typedef CK_ATTRIBUTE CK_PTR CK_ATTRIBUTE_PTR; + +/* CK_DATE is a structure that defines a date */ +typedef struct CK_DATE { + CK_CHAR year[4]; /* the year ("1900" - "9999") */ + CK_CHAR month[2]; /* the month ("01" - "12") */ + CK_CHAR day[2]; /* the day ("01" - "31") */ +} CK_DATE; + +/* CK_MECHANISM_TYPE is a value that identifies a mechanism + * type */ +/* CK_MECHANISM_TYPE was changed from CK_USHORT to CK_ULONG for + * v2.0 */ +typedef CK_ULONG CK_MECHANISM_TYPE; + +/* the following mechanism types are defined: */ +#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000UL +#define CKM_RSA_PKCS 0x00000001UL +#define CKM_RSA_9796 0x00000002UL +#define CKM_RSA_X_509 0x00000003UL + +/* CKM_MD2_RSA_PKCS, CKM_MD5_RSA_PKCS, and CKM_SHA1_RSA_PKCS + * are new for v2.0. They are mechanisms which hash and sign */ +#define CKM_MD2_RSA_PKCS 0x00000004UL +#define CKM_MD5_RSA_PKCS 0x00000005UL +#define CKM_SHA1_RSA_PKCS 0x00000006UL + +/* CKM_RIPEMD128_RSA_PKCS, CKM_RIPEMD160_RSA_PKCS, and + * CKM_RSA_PKCS_OAEP are new for v2.10 */ +#define CKM_RIPEMD128_RSA_PKCS 0x00000007UL +#define CKM_RIPEMD160_RSA_PKCS 0x00000008UL +#define CKM_RSA_PKCS_OAEP 0x00000009UL + +/* CKM_RSA_X9_31_KEY_PAIR_GEN, CKM_RSA_X9_31, CKM_SHA1_RSA_X9_31, + * CKM_RSA_PKCS_PSS, and CKM_SHA1_RSA_PKCS_PSS are new for v2.11 */ +#define CKM_RSA_X9_31_KEY_PAIR_GEN 0x0000000AUL +#define CKM_RSA_X9_31 0x0000000BUL +#define CKM_SHA1_RSA_X9_31 0x0000000CUL +#define CKM_RSA_PKCS_PSS 0x0000000DUL +#define CKM_SHA1_RSA_PKCS_PSS 0x0000000EUL + +/* new for v3.2 */ +#define CKM_ML_KEM_KEY_PAIR_GEN 0x0000000fUL + +#define CKM_DSA_KEY_PAIR_GEN 0x00000010UL +#define CKM_DSA 0x00000011UL +#define CKM_DSA_SHA1 0x00000012UL + +/* new for v2.40 */ +#define CKM_DSA_SHA224 0x00000013UL +#define CKM_DSA_SHA256 0x00000014UL +#define CKM_DSA_SHA384 0x00000015UL +#define CKM_DSA_SHA512 0x00000016UL + +/* new for v3.2 */ +#define CKM_ML_KEM 0x00000017UL + +#define CKM_DSA_SHA3_224 0x00000018UL +#define CKM_DSA_SHA3_256 0x00000019UL +#define CKM_DSA_SHA3_384 0x0000001AUL +#define CKM_DSA_SHA3_512 0x0000001BUL + +/* new for v3.2 */ +#define CKM_ML_DSA_KEY_PAIR_GEN 0x0000001cUL +#define CKM_ML_DSA 0x0000001dUL +#define CKM_HASH_ML_DSA 0x0000001fUL + +#define CKM_DH_PKCS_KEY_PAIR_GEN 0x00000020UL +#define CKM_DH_PKCS_DERIVE 0x00000021UL + +/* new for v3.2 */ +#define CKM_HASH_ML_DSA_SHA224 0x00000023UL +#define CKM_HASH_ML_DSA_SHA256 0x00000024UL +#define CKM_HASH_ML_DSA_SHA384 0x00000025UL +#define CKM_HASH_ML_DSA_SHA3_224 0x00000027UL +#define CKM_HASH_ML_DSA_SHA3_256 0x00000028UL +#define CKM_HASH_ML_DSA_SHA3_384 0x00000029UL +#define CKM_HASH_ML_DSA_SHA3_512 0x0000002aUL +#define CKM_HASH_ML_DSA_SHA512 0x00000026UL +#define CKM_HASH_ML_DSA_SHAKE128 0x0000002bUL +#define CKM_HASH_ML_DSA_SHAKE256 0x0000002cUL +#define CKM_SLH_DSA_KEY_PAIR_GEN 0x0000002dUL +#define CKM_SLH_DSA 0x0000002eUL + +/* CKM_X9_42_DH_KEY_PAIR_GEN, CKM_X9_42_DH_DERIVE, + * CKM_X9_42_DH_HYBRID_DERIVE, and CKM_X9_42_MQV_DERIVE are new for + * v2.11 */ +#define CKM_X9_42_DH_KEY_PAIR_GEN 0x00000030UL +#define CKM_X9_42_DH_DERIVE 0x00000031UL +#define CKM_X9_42_DH_HYBRID_DERIVE 0x00000032UL +#define CKM_X9_42_MQV_DERIVE 0x00000033UL + +/* new for v3.2 */ +#define CKM_HASH_SLH_DSA 0x00000034UL +#define CKM_HASH_SLH_DSA_SHA224 0x00000036UL +#define CKM_HASH_SLH_DSA_SHA256 0x00000037UL +#define CKM_HASH_SLH_DSA_SHA384 0x00000038UL +#define CKM_HASH_SLH_DSA_SHA3_224 0x0000003aUL +#define CKM_HASH_SLH_DSA_SHA3_256 0x0000003bUL +#define CKM_HASH_SLH_DSA_SHA3_384 0x0000003cUL +#define CKM_HASH_SLH_DSA_SHA3_512 0x0000003dUL +#define CKM_HASH_SLH_DSA_SHA512 0x00000039UL +#define CKM_HASH_SLH_DSA_SHAKE128 0x0000003eUL +#define CKM_HASH_SLH_DSA_SHAKE256 0x0000003fUL + +/* CKM_SHA256/384/512 are new for v2.20 */ +#define CKM_SHA256_RSA_PKCS 0x00000040UL +#define CKM_SHA384_RSA_PKCS 0x00000041UL +#define CKM_SHA512_RSA_PKCS 0x00000042UL +#define CKM_SHA256_RSA_PKCS_PSS 0x00000043UL +#define CKM_SHA384_RSA_PKCS_PSS 0x00000044UL +#define CKM_SHA512_RSA_PKCS_PSS 0x00000045UL + +/* CKM_SHA224 new for v2.20 amendment 3 */ +#define CKM_SHA224_RSA_PKCS 0x00000046UL +#define CKM_SHA224_RSA_PKCS_PSS 0x00000047UL + +/* new for v2.40 */ +#define CKM_SHA512_224 0x00000048UL +#define CKM_SHA512_224_HMAC 0x00000049UL +#define CKM_SHA512_224_HMAC_GENERAL 0x0000004AUL +#define CKM_SHA512_224_KEY_DERIVATION 0x0000004BUL +#define CKM_SHA512_256 0x0000004CUL +#define CKM_SHA512_256_HMAC 0x0000004DUL +#define CKM_SHA512_256_HMAC_GENERAL 0x0000004EUL +#define CKM_SHA512_256_KEY_DERIVATION 0x0000004FUL +#define CKM_SHA512_T 0x00000050UL +#define CKM_SHA512_T_HMAC 0x00000051UL +#define CKM_SHA512_T_HMAC_GENERAL 0x00000052UL +#define CKM_SHA512_T_KEY_DERIVATION 0x00000053UL + +/* new for v3.2 */ +#define CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE 0x00000056UL +#define CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH 0x00000057UL + +#define CKM_SHA3_256_RSA_PKCS 0x00000060UL +#define CKM_SHA3_384_RSA_PKCS 0x00000061UL +#define CKM_SHA3_512_RSA_PKCS 0x00000062UL +#define CKM_SHA3_256_RSA_PKCS_PSS 0x00000063UL +#define CKM_SHA3_384_RSA_PKCS_PSS 0x00000064UL +#define CKM_SHA3_512_RSA_PKCS_PSS 0x00000065UL +#define CKM_SHA3_224_RSA_PKCS 0x00000066UL +#define CKM_SHA3_224_RSA_PKCS_PSS 0x00000067UL + +#define CKM_RC2_KEY_GEN 0x00000100UL +#define CKM_RC2_ECB 0x00000101UL +#define CKM_RC2_CBC 0x00000102UL +#define CKM_RC2_MAC 0x00000103UL + +/* CKM_RC2_MAC_GENERAL and CKM_RC2_CBC_PAD are new for v2.0 */ +#define CKM_RC2_MAC_GENERAL 0x00000104UL +#define CKM_RC2_CBC_PAD 0x00000105UL + +#define CKM_RC4_KEY_GEN 0x00000110UL +#define CKM_RC4 0x00000111UL +#define CKM_DES_KEY_GEN 0x00000120UL +#define CKM_DES_ECB 0x00000121UL +#define CKM_DES_CBC 0x00000122UL +#define CKM_DES_MAC 0x00000123UL + +/* CKM_DES_MAC_GENERAL and CKM_DES_CBC_PAD are new for v2.0 */ +#define CKM_DES_MAC_GENERAL 0x00000124UL +#define CKM_DES_CBC_PAD 0x00000125UL + +#define CKM_DES2_KEY_GEN 0x00000130UL +#define CKM_DES3_KEY_GEN 0x00000131UL +#define CKM_DES3_ECB 0x00000132UL +#define CKM_DES3_CBC 0x00000133UL +#define CKM_DES3_MAC 0x00000134UL + +/* CKM_DES3_MAC_GENERAL, CKM_DES3_CBC_PAD, CKM_CDMF_KEY_GEN, + * CKM_CDMF_ECB, CKM_CDMF_CBC, CKM_CDMF_MAC, + * CKM_CDMF_MAC_GENERAL, and CKM_CDMF_CBC_PAD are new for v2.0 */ +#define CKM_DES3_MAC_GENERAL 0x00000135UL +#define CKM_DES3_CBC_PAD 0x00000136UL +#define CKM_CDMF_KEY_GEN 0x00000140UL +#define CKM_CDMF_ECB 0x00000141UL +#define CKM_CDMF_CBC 0x00000142UL +#define CKM_CDMF_MAC 0x00000143UL +#define CKM_CDMF_MAC_GENERAL 0x00000144UL +#define CKM_CDMF_CBC_PAD 0x00000145UL + +/* the following four DES mechanisms are new for v2.20 */ +#define CKM_DES_OFB64 0x00000150UL +#define CKM_DES_OFB8 0x00000151UL +#define CKM_DES_CFB64 0x00000152UL +#define CKM_DES_CFB8 0x00000153UL + +#define CKM_MD2 0x00000200UL + +/* CKM_MD2_HMAC and CKM_MD2_HMAC_GENERAL are new for v2.0 */ +#define CKM_MD2_HMAC 0x00000201UL +#define CKM_MD2_HMAC_GENERAL 0x00000202UL + +#define CKM_MD5 0x00000210UL + +/* CKM_MD5_HMAC and CKM_MD5_HMAC_GENERAL are new for v2.0 */ +#define CKM_MD5_HMAC 0x00000211UL +#define CKM_MD5_HMAC_GENERAL 0x00000212UL + +#define CKM_SHA_1 0x00000220UL + +/* CKM_SHA_1_HMAC and CKM_SHA_1_HMAC_GENERAL are new for v2.0 */ +#define CKM_SHA_1_HMAC 0x00000221UL +#define CKM_SHA_1_HMAC_GENERAL 0x00000222UL + +/* CKM_RIPEMD128, CKM_RIPEMD128_HMAC, + * CKM_RIPEMD128_HMAC_GENERAL, CKM_RIPEMD160, CKM_RIPEMD160_HMAC, + * and CKM_RIPEMD160_HMAC_GENERAL are new for v2.10 */ +#define CKM_RIPEMD128 0x00000230UL +#define CKM_RIPEMD128_HMAC 0x00000231UL +#define CKM_RIPEMD128_HMAC_GENERAL 0x00000232UL +#define CKM_RIPEMD160 0x00000240UL +#define CKM_RIPEMD160_HMAC 0x00000241UL +#define CKM_RIPEMD160_HMAC_GENERAL 0x00000242UL + +/* CKM_SHA256/384/512 are new for v2.20 */ +#define CKM_SHA256 0x00000250UL +#define CKM_SHA256_HMAC 0x00000251UL +#define CKM_SHA256_HMAC_GENERAL 0x00000252UL +#define CKM_SHA384 0x00000260UL +#define CKM_SHA384_HMAC 0x00000261UL +#define CKM_SHA384_HMAC_GENERAL 0x00000262UL +#define CKM_SHA512 0x00000270UL +#define CKM_SHA512_HMAC 0x00000271UL +#define CKM_SHA512_HMAC_GENERAL 0x00000272UL + +/* CKM_SHA224 new for v2.20 amendment 3 */ +#define CKM_SHA224 0x00000255UL +#define CKM_SHA224_HMAC 0x00000256UL +#define CKM_SHA224_HMAC_GENERAL 0x00000257UL + +/* new for v2.40 */ +#define CKM_SECURID_KEY_GEN 0x00000280UL +#define CKM_SECURID 0x00000282UL +#define CKM_HOTP_KEY_GEN 0x00000290UL +#define CKM_HOTP 0x00000291UL +#define CKM_ACTI 0x000002A0UL +#define CKM_ACTI_KEY_GEN 0x000002A1UL +#define CKM_SHA3_256 0x000002B0UL +#define CKM_SHA3_256_HMAC 0x000002B1UL +#define CKM_SHA3_256_HMAC_GENERAL 0x000002B2UL +#define CKM_SHA3_256_KEY_GEN 0x000002B3UL +#define CKM_SHA3_224 0x000002B5UL +#define CKM_SHA3_224_HMAC 0x000002B6UL +#define CKM_SHA3_224_HMAC_GENERAL 0x000002B7UL +#define CKM_SHA3_224_KEY_GEN 0x000002B8UL +#define CKM_SHA3_384 0x000002C0UL +#define CKM_SHA3_384_HMAC 0x000002C1UL +#define CKM_SHA3_384_HMAC_GENERAL 0x000002C2UL +#define CKM_SHA3_384_KEY_GEN 0x000002C3UL +#define CKM_SHA3_512 0x000002D0UL +#define CKM_SHA3_512_HMAC 0x000002D1UL +#define CKM_SHA3_512_HMAC_GENERAL 0x000002D2UL +#define CKM_SHA3_512_KEY_GEN 0x000002D3UL + +/* All of the following mechanisms are new for v2.0 */ +/* Note that CAST128 and CAST5 are the same algorithm */ +#define CKM_CAST_KEY_GEN 0x00000300UL +#define CKM_CAST_ECB 0x00000301UL +#define CKM_CAST_CBC 0x00000302UL +#define CKM_CAST_MAC 0x00000303UL +#define CKM_CAST_MAC_GENERAL 0x00000304UL +#define CKM_CAST_CBC_PAD 0x00000305UL +#define CKM_CAST3_KEY_GEN 0x00000310UL +#define CKM_CAST3_ECB 0x00000311UL +#define CKM_CAST3_CBC 0x00000312UL +#define CKM_CAST3_MAC 0x00000313UL +#define CKM_CAST3_MAC_GENERAL 0x00000314UL +#define CKM_CAST3_CBC_PAD 0x00000315UL +#define CKM_CAST5_KEY_GEN 0x00000320UL +#define CKM_CAST128_KEY_GEN 0x00000320UL +#define CKM_CAST5_ECB 0x00000321UL +#define CKM_CAST128_ECB 0x00000321UL +#define CKM_CAST5_CBC 0x00000322UL +#define CKM_CAST128_CBC 0x00000322UL +#define CKM_CAST5_MAC 0x00000323UL +#define CKM_CAST128_MAC 0x00000323UL +#define CKM_CAST5_MAC_GENERAL 0x00000324UL +#define CKM_CAST128_MAC_GENERAL 0x00000324UL +#define CKM_CAST5_CBC_PAD 0x00000325UL +#define CKM_CAST128_CBC_PAD 0x00000325UL +#define CKM_RC5_KEY_GEN 0x00000330UL +#define CKM_RC5_ECB 0x00000331UL +#define CKM_RC5_CBC 0x00000332UL +#define CKM_RC5_MAC 0x00000333UL +#define CKM_RC5_MAC_GENERAL 0x00000334UL +#define CKM_RC5_CBC_PAD 0x00000335UL +#define CKM_IDEA_KEY_GEN 0x00000340UL +#define CKM_IDEA_ECB 0x00000341UL +#define CKM_IDEA_CBC 0x00000342UL +#define CKM_IDEA_MAC 0x00000343UL +#define CKM_IDEA_MAC_GENERAL 0x00000344UL +#define CKM_IDEA_CBC_PAD 0x00000345UL +#define CKM_GENERIC_SECRET_KEY_GEN 0x00000350UL +#define CKM_CONCATENATE_BASE_AND_KEY 0x00000360UL +#define CKM_CONCATENATE_BASE_AND_DATA 0x00000362UL +#define CKM_CONCATENATE_DATA_AND_BASE 0x00000363UL +#define CKM_XOR_BASE_AND_DATA 0x00000364UL +#define CKM_EXTRACT_KEY_FROM_KEY 0x00000365UL +#define CKM_SSL3_PRE_MASTER_KEY_GEN 0x00000370UL +#define CKM_SSL3_MASTER_KEY_DERIVE 0x00000371UL +#define CKM_SSL3_KEY_AND_MAC_DERIVE 0x00000372UL + +/* CKM_SSL3_MASTER_KEY_DERIVE_DH, CKM_TLS_PRE_MASTER_KEY_GEN, + * CKM_TLS_MASTER_KEY_DERIVE, CKM_TLS_KEY_AND_MAC_DERIVE, and + * CKM_TLS_MASTER_KEY_DERIVE_DH are new for v2.11 */ +#define CKM_SSL3_MASTER_KEY_DERIVE_DH 0x00000373UL +#define CKM_TLS_PRE_MASTER_KEY_GEN 0x00000374UL +#define CKM_TLS_MASTER_KEY_DERIVE 0x00000375UL +#define CKM_TLS_KEY_AND_MAC_DERIVE 0x00000376UL +#define CKM_TLS_MASTER_KEY_DERIVE_DH 0x00000377UL + +/* CKM_TLS_PRF is new for v2.20 */ +#define CKM_TLS_PRF 0x00000378UL + +#define CKM_SSL3_MD5_MAC 0x00000380UL +#define CKM_SSL3_SHA1_MAC 0x00000381UL +#define CKM_MD5_KEY_DERIVATION 0x00000390UL +#define CKM_MD2_KEY_DERIVATION 0x00000391UL +#define CKM_SHA1_KEY_DERIVATION 0x00000392UL + +/* CKM_SHA256/384/512 are new for v2.20 */ +#define CKM_SHA256_KEY_DERIVATION 0x00000393UL +#define CKM_SHA384_KEY_DERIVATION 0x00000394UL +#define CKM_SHA512_KEY_DERIVATION 0x00000395UL + +/* CKM_SHA224 new for v2.20 amendment 3 */ +#define CKM_SHA224_KEY_DERIVATION 0x00000396UL + +/* new for v2.40 */ +#define CKM_SHA3_256_KEY_DERIVATION 0x00000397UL +#define CKM_SHA3_224_KEY_DERIVATION 0x00000398UL +#define CKM_SHA3_384_KEY_DERIVATION 0x00000399UL +#define CKM_SHA3_512_KEY_DERIVATION 0x0000039AUL +#define CKM_SHAKE_128_KEY_DERIVATION 0x0000039BUL +#define CKM_SHAKE_256_KEY_DERIVATION 0x0000039CUL + +#define CKM_PBE_MD2_DES_CBC 0x000003A0UL +#define CKM_PBE_MD5_DES_CBC 0x000003A1UL +#define CKM_PBE_MD5_CAST_CBC 0x000003A2UL +#define CKM_PBE_MD5_CAST3_CBC 0x000003A3UL +#define CKM_PBE_MD5_CAST5_CBC 0x000003A4UL +#define CKM_PBE_MD5_CAST128_CBC 0x000003A4UL +#define CKM_PBE_SHA1_CAST5_CBC 0x000003A5UL +#define CKM_PBE_SHA1_CAST128_CBC 0x000003A5UL +#define CKM_PBE_SHA1_RC4_128 0x000003A6UL +#define CKM_PBE_SHA1_RC4_40 0x000003A7UL +#define CKM_PBE_SHA1_DES3_EDE_CBC 0x000003A8UL +#define CKM_PBE_SHA1_DES2_EDE_CBC 0x000003A9UL +#define CKM_PBE_SHA1_RC2_128_CBC 0x000003AAUL +#define CKM_PBE_SHA1_RC2_40_CBC 0x000003ABUL + +/* CKM_PKCS5_PBKD2 is new for v2.10 */ +#define CKM_PKCS5_PBKD2 0x000003B0UL + +#define CKM_PBA_SHA1_WITH_SHA1_HMAC 0x000003C0UL + +/* WTLS mechanisms are new for v2.20 */ +#define CKM_WTLS_PRE_MASTER_KEY_GEN 0x000003D0UL +#define CKM_WTLS_MASTER_KEY_DERIVE 0x000003D1UL +#define CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC 0x000003D2UL +#define CKM_WTLS_PRF 0x000003D3UL +#define CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE 0x000003D4UL +#define CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE 0x000003D5UL + +/* TLS 1.2 mechanisms are new for v2.40 */ +#define CKM_TLS12_MASTER_KEY_DERIVE 0x000003E0UL +#define CKM_TLS12_KEY_AND_MAC_DERIVE 0x000003E1UL +#define CKM_TLS12_MASTER_KEY_DERIVE_DH 0x000003E2UL +#define CKM_TLS12_KEY_SAFE_DERIVE 0x000003E3UL +#define CKM_TLS12_MAC 0x000003D8UL +#define CKM_TLS12_KDF 0x000003D9UL +#define CKM_TLS_MAC 0x000003E4UL +#define CKM_TLS_KDF 0x000003E5UL + +#define CKM_KEY_WRAP_LYNKS 0x00000400UL +#define CKM_KEY_WRAP_SET_OAEP 0x00000401UL + +/* CKM_CMS_SIG is new for v2.20 */ +#define CKM_CMS_SIG 0x00000500UL + +/* new for 2.40 */ +#define CKM_KIP_DERIVE 0x00000510UL +#define CKM_KIP_WRAP 0x00000511UL +#define CKM_KIP_MAC 0x00000512UL + +/* Fortezza mechanisms */ +#define CKM_SKIPJACK_KEY_GEN 0x00001000UL +#define CKM_SKIPJACK_ECB64 0x00001001UL +#define CKM_SKIPJACK_CBC64 0x00001002UL +#define CKM_SKIPJACK_OFB64 0x00001003UL +#define CKM_SKIPJACK_CFB64 0x00001004UL +#define CKM_SKIPJACK_CFB32 0x00001005UL +#define CKM_SKIPJACK_CFB16 0x00001006UL +#define CKM_SKIPJACK_CFB8 0x00001007UL +#define CKM_SKIPJACK_WRAP 0x00001008UL +#define CKM_SKIPJACK_PRIVATE_WRAP 0x00001009UL +#define CKM_SKIPJACK_RELAYX 0x0000100aUL +#define CKM_KEA_KEY_PAIR_GEN 0x00001010UL +#define CKM_KEA_KEY_DERIVE 0x00001011UL +#define CKM_FORTEZZA_TIMESTAMP 0x00001020UL +#define CKM_BATON_KEY_GEN 0x00001030UL +#define CKM_BATON_ECB128 0x00001031UL +#define CKM_BATON_ECB96 0x00001032UL +#define CKM_BATON_CBC128 0x00001033UL +#define CKM_BATON_COUNTER 0x00001034UL +#define CKM_BATON_SHUFFLE 0x00001035UL +#define CKM_BATON_WRAP 0x00001036UL + +/* CKM_ECDSA_KEY_PAIR_GEN is deprecated in v2.11, + * CKM_EC_KEY_PAIR_GEN is preferred */ +#define CKM_ECDSA_KEY_PAIR_GEN 0x00001040UL +#define CKM_EC_KEY_PAIR_GEN 0x00001040UL + +#define CKM_ECDSA 0x00001041UL +#define CKM_ECDSA_SHA1 0x00001042UL + +/* new for v2.40 */ +#define CKM_ECDSA_SHA224 0x00001043UL +#define CKM_ECDSA_SHA256 0x00001044UL +#define CKM_ECDSA_SHA384 0x00001045UL +#define CKM_ECDSA_SHA512 0x00001046UL +#define CKM_EC_KEY_PAIR_GEN_W_EXTRA_BITS 0x0000140BUL + +/* CKM_ECDH1_DERIVE, CKM_ECDH1_COFACTOR_DERIVE, and CKM_ECMQV_DERIVE + * are new for v2.11 */ +#define CKM_ECDH1_DERIVE 0x00001050UL +#define CKM_ECDH1_COFACTOR_DERIVE 0x00001051UL +#define CKM_ECMQV_DERIVE 0x00001052UL + +/* new for v2.40 */ +#define CKM_ECDH_AES_KEY_WRAP 0x00001053UL +#define CKM_RSA_AES_KEY_WRAP 0x00001054UL + +#define CKM_JUNIPER_KEY_GEN 0x00001060UL +#define CKM_JUNIPER_ECB128 0x00001061UL +#define CKM_JUNIPER_CBC128 0x00001062UL +#define CKM_JUNIPER_COUNTER 0x00001063UL +#define CKM_JUNIPER_SHUFFLE 0x00001064UL +#define CKM_JUNIPER_WRAP 0x00001065UL +#define CKM_FASTHASH 0x00001070UL + +/* CKM_AES_KEY_GEN, CKM_AES_ECB, CKM_AES_CBC, CKM_AES_MAC, + * CKM_AES_MAC_GENERAL, CKM_AES_CBC_PAD, CKM_DSA_PARAMETER_GEN, + * CKM_DH_PKCS_PARAMETER_GEN, and CKM_X9_42_DH_PARAMETER_GEN are + * new for v2.11 */ +#define CKM_AES_KEY_GEN 0x00001080UL +#define CKM_AES_ECB 0x00001081UL +#define CKM_AES_CBC 0x00001082UL +#define CKM_AES_MAC 0x00001083UL +#define CKM_AES_MAC_GENERAL 0x00001084UL +#define CKM_AES_CBC_PAD 0x00001085UL +/* new for v2.20 amendment 3 */ +#define CKM_AES_CTR 0x00001086UL +/* new for v2.30 */ +#define CKM_AES_GCM 0x00001087UL +#define CKM_AES_CCM 0x00001088UL +#define CKM_AES_CTS 0x00001089UL +/* AES-CMAC values copied from v2.40 errata 1 header file */ +#define CKM_AES_CMAC 0x0000108AUL +#define CKM_AES_CMAC_GENERAL 0x0000108BUL +#define CKM_AES_XCBC_MAC 0x0000108CUL +#define CKM_AES_XCBC_MAC_96 0x0000108DUL + +/* BlowFish and TwoFish are new for v2.20 */ +#define CKM_BLOWFISH_KEY_GEN 0x00001090UL +#define CKM_BLOWFISH_CBC 0x00001091UL +#define CKM_TWOFISH_KEY_GEN 0x00001092UL +#define CKM_TWOFISH_CBC 0x00001093UL + +/* new for v2.40 */ +#define CKM_BLOWFISH_CBC_PAD 0x00001094UL +#define CKM_TWOFISH_CBC_PAD 0x00001095UL + +/* Camellia is proposed for v2.20 Amendment 3 */ +#define CKM_CAMELLIA_KEY_GEN 0x00000550UL +#define CKM_CAMELLIA_ECB 0x00000551UL +#define CKM_CAMELLIA_CBC 0x00000552UL +#define CKM_CAMELLIA_MAC 0x00000553UL +#define CKM_CAMELLIA_MAC_GENERAL 0x00000554UL +#define CKM_CAMELLIA_CBC_PAD 0x00000555UL +#define CKM_CAMELLIA_ECB_ENCRYPT_DATA 0x00000556UL +#define CKM_CAMELLIA_CBC_ENCRYPT_DATA 0x00000557UL +#define CKM_CAMELLIA_CTR 0x00000558UL + +/* new for v2.40 */ +#define CKM_ARIA_KEY_GEN 0x00000560UL +#define CKM_ARIA_ECB 0x00000561UL +#define CKM_ARIA_CBC 0x00000562UL +#define CKM_ARIA_MAC 0x00000563UL +#define CKM_ARIA_MAC_GENERAL 0x00000564UL +#define CKM_ARIA_CBC_PAD 0x00000565UL +#define CKM_ARIA_ECB_ENCRYPT_DATA 0x00000566UL +#define CKM_ARIA_CBC_ENCRYPT_DATA 0x00000567UL + +#define CKM_SEED_KEY_GEN 0x00000650UL +#define CKM_SEED_ECB 0x00000651UL +#define CKM_SEED_CBC 0x00000652UL +#define CKM_SEED_MAC 0x00000653UL +#define CKM_SEED_MAC_GENERAL 0x00000654UL +#define CKM_SEED_CBC_PAD 0x00000655UL +#define CKM_SEED_ECB_ENCRYPT_DATA 0x00000656UL +#define CKM_SEED_CBC_ENCRYPT_DATA 0x00000657UL + +/* new for v3.1 */ +#define CKM_KEA_DERIVE 0x00001012UL + +/* new for v2.40 */ +#define CKM_ECDSA_SHA3_224 0x00001047UL +#define CKM_ECDSA_SHA3_256 0x00001048UL +#define CKM_ECDSA_SHA3_384 0x00001049UL +#define CKM_ECDSA_SHA3_512 0x0000104aUL +#define CKM_EC_EDWARDS_KEY_PAIR_GEN 0x00001055UL +#define CKM_EC_MONTGOMERY_KEY_PAIR_GEN 0x00001056UL +#define CKM_EDDSA 0x00001057UL + +/* new for v3.1 */ +#define CKM_AES_XTS 0x00001071UL +#define CKM_AES_XTS_KEY_GEN 0x00001072UL +#define CKM_AES_GMAC 0x0000108eUL + +/* CKM_xxx_ENCRYPT_DATA mechanisms are new for v2.20 */ +#define CKM_DES_ECB_ENCRYPT_DATA 0x00001100UL +#define CKM_DES_CBC_ENCRYPT_DATA 0x00001101UL +#define CKM_DES3_ECB_ENCRYPT_DATA 0x00001102UL +#define CKM_DES3_CBC_ENCRYPT_DATA 0x00001103UL +#define CKM_AES_ECB_ENCRYPT_DATA 0x00001104UL +#define CKM_AES_CBC_ENCRYPT_DATA 0x00001105UL + +#define CKM_GOSTR3410_KEY_PAIR_GEN 0x00001200UL +#define CKM_GOSTR3410 0x00001201UL +#define CKM_GOSTR3410_WITH_GOSTR3411 0x00001202UL +#define CKM_GOSTR3410_KEY_WRAP 0x00001203UL +#define CKM_GOSTR3410_DERIVE 0x00001204UL +#define CKM_GOSTR3411 0x00001210UL +#define CKM_GOSTR3411_HMAC 0x00001211UL +#define CKM_GOST28147_KEY_GEN 0x00001220UL +#define CKM_GOST28147_ECB 0x00001221UL +#define CKM_GOST28147 0x00001222UL +#define CKM_GOST28147_MAC 0x00001223UL +#define CKM_GOST28147_KEY_WRAP 0x00001224UL + +/* new for v2.40 */ +#define CKM_CHACHA20_KEY_GEN 0x00001225UL +#define CKM_CHACHA20 0x00001226UL +#define CKM_POLY1305_KEY_GEN 0x00001227UL +#define CKM_POLY1305 0x00001228UL + +/* new for v3.1 */ +#define CKM_DES3_CMAC 0x00000138UL +#define CKM_DES3_CMAC_GENERAL 0x00000137UL + +#define CKM_DSA_PARAMETER_GEN 0x00002000UL +#define CKM_DH_PKCS_PARAMETER_GEN 0x00002001UL +#define CKM_X9_42_DH_PARAMETER_GEN 0x00002002UL + +/* new for v2.40 */ +#define CKM_DSA_PROBABILISTIC_PARAMETER_GEN 0x00002003UL +#define CKM_DSA_PROBABLISTIC_PARAMETER_GEN 0x00002003UL +#define CKM_DSA_SHAWE_TAYLOR_PARAMETER_GEN 0x00002004UL +#define CKM_DSA_FIPS_G_GEN 0x00002005UL + +/* new for v3.1 */ +#define CKM_AES_OFB 0x00002104UL +#define CKM_AES_CFB64 0x00002105UL +#define CKM_AES_CFB8 0x00002106UL +#define CKM_AES_CFB128 0x00002107UL +#define CKM_AES_KEY_WRAP_PKCS7 0x0000210cUL + +/* new for v2.40 */ +#define CKM_AES_CFB1 0x00002108UL +#define CKM_AES_KEY_WRAP 0x00002109UL +#define CKM_AES_KEY_WRAP_PAD 0x0000210AUL +#define CKM_AES_KEY_WRAP_KWP 0x0000210BUL + +/* new for v3.1 */ +#define CKM_SHA3_256_KEY_DERIVE 0x00000397UL +#define CKM_SHA3_224_KEY_DERIVE 0x00000398UL +#define CKM_SHA3_384_KEY_DERIVE 0x00000399UL +#define CKM_SHA3_512_KEY_DERIVE 0x0000039aUL +#define CKM_SHAKE_128_KEY_DERIVE 0x0000039bUL +#define CKM_SHAKE_256_KEY_DERIVE 0x0000039cUL + +/* CKM_SP800_108_xxx_KDF are new for v3.0 */ +#define CKM_SP800_108_COUNTER_KDF 0x000003acUL +#define CKM_SP800_108_FEEDBACK_KDF 0x000003adUL +#define CKM_SP800_108_DOUBLE_PIPELINE_KDF 0x000003aeUL + +/* new for v3.1 */ +#define CKM_TLS10_MAC_SERVER 0x000003d6UL +#define CKM_TLS10_MAC_CLIENT 0x000003d7UL + +/* new for v2.4 */ +#define CKM_RSA_PKCS_TPM_1_1 0x00004001UL +#define CKM_RSA_PKCS_OAEP_TPM_1_1 0x00004002UL +#define CKM_SHA_1_KEY_GEN 0x00004003UL +#define CKM_SHA224_KEY_GEN 0x00004004UL +#define CKM_SHA256_KEY_GEN 0x00004005UL +#define CKM_SHA384_KEY_GEN 0x00004006UL +#define CKM_SHA512_KEY_GEN 0x00004007UL +#define CKM_SHA512_224_KEY_GEN 0x00004008UL +#define CKM_SHA512_256_KEY_GEN 0x00004009UL +#define CKM_SHA512_T_KEY_GEN 0x0000400aUL + +/* new for v3.0 */ +#define CKM_NULL 0x0000400bUL +#define CKM_BLAKE2B_160 0x0000400cUL +#define CKM_BLAKE2B_160_HMAC 0x0000400dUL +#define CKM_BLAKE2B_160_HMAC_GENERAL 0x0000400eUL +#define CKM_BLAKE2B_160_KEY_DERIVE 0x0000400fUL +#define CKM_BLAKE2B_160_KEY_GEN 0x00004010UL +#define CKM_BLAKE2B_256 0x00004011UL +#define CKM_BLAKE2B_256_HMAC 0x00004012UL +#define CKM_BLAKE2B_256_HMAC_GENERAL 0x00004013UL +#define CKM_BLAKE2B_256_KEY_DERIVE 0x00004014UL +#define CKM_BLAKE2B_256_KEY_GEN 0x00004015UL +#define CKM_BLAKE2B_384 0x00004016UL +#define CKM_BLAKE2B_384_HMAC 0x00004017UL +#define CKM_BLAKE2B_384_HMAC_GENERAL 0x00004018UL +#define CKM_BLAKE2B_384_KEY_DERIVE 0x00004019UL +#define CKM_BLAKE2B_384_KEY_GEN 0x0000401aUL +#define CKM_BLAKE2B_512 0x0000401bUL +#define CKM_BLAKE2B_512_HMAC 0x0000401cUL +#define CKM_BLAKE2B_512_HMAC_GENERAL 0x0000401dUL +#define CKM_BLAKE2B_512_KEY_DERIVE 0x0000401eUL +#define CKM_BLAKE2B_512_KEY_GEN 0x0000401fUL +#define CKM_SALSA20 0x00004020UL +#define CKM_CHACHA20_POLY1305 0x00004021UL +#define CKM_SALSA20_POLY1305 0x00004022UL +#define CKM_X3DH_INITIALIZE 0x00004023UL +#define CKM_X3DH_RESPOND 0x00004024UL +#define CKM_X2RATCHET_INITIALIZE 0x00004025UL +#define CKM_X2RATCHET_RESPOND 0x00004026UL +#define CKM_X2RATCHET_ENCRYPT 0x00004027UL +#define CKM_X2RATCHET_DECRYPT 0x00004028UL +#define CKM_XEDDSA 0x00004029UL +#define CKM_HKDF_DERIVE 0x0000402aUL +#define CKM_HKDF_DATA 0x0000402bUL +#define CKM_HKDF_KEY_GEN 0x0000402cUL +#define CKM_SALSA20_KEY_GEN 0x0000402dUL + +/* new for v3.1 */ +#define CKM_IKE2_PRF_PLUS_DERIVE 0x0000402eUL +#define CKM_IKE_PRF_DERIVE 0x0000402fUL +#define CKM_IKE1_PRF_DERIVE 0x00004030UL +#define CKM_IKE1_EXTENDED_DERIVE 0x00004031UL +#define CKM_HSS_KEY_PAIR_GEN 0x00004032UL +#define CKM_HSS 0x00004033UL + +/* new for v3.2 */ +#define CKM_XMSS_KEY_PAIR_GEN 0x00004034UL +#define CKM_XMSSMT_KEY_PAIR_GEN 0x00004035UL +#define CKM_XMSS 0x00004036UL +#define CKM_XMSSMT 0x00004037UL +#define CKM_ECDH_X_AES_KEY_WRAP 0x00004038UL +#define CKM_ECDH_COF_AES_KEY_WRAP 0x00004039UL +#define CKM_PUB_KEY_FROM_PRIV_KEY 0x0000403aUL + +#define CKM_VENDOR_DEFINED 0x80000000UL + +typedef CK_MECHANISM_TYPE CK_PTR CK_MECHANISM_TYPE_PTR; + +/* CK_MECHANISM is a structure that specifies a particular + * mechanism */ +typedef struct CK_MECHANISM { + CK_MECHANISM_TYPE mechanism; + CK_VOID_PTR pParameter; + + /* ulParameterLen was changed from CK_USHORT to CK_ULONG for + * v2.0 */ + CK_ULONG ulParameterLen; /* in bytes */ +} CK_MECHANISM; + +typedef CK_MECHANISM CK_PTR CK_MECHANISM_PTR; + +/* CK_MECHANISM_INFO provides information about a particular + * mechanism */ +typedef struct CK_MECHANISM_INFO { + CK_ULONG ulMinKeySize; + CK_ULONG ulMaxKeySize; + CK_FLAGS flags; +} CK_MECHANISM_INFO; + +/* The flags are defined as follows: + * Bit Flag Mask Meaning */ +#define CKF_HW 0x00000001UL /* performed by HW */ + +/* Message interface Flags, new for v3.0 */ +#define CKF_MESSAGE_ENCRYPT 0x00000002UL +#define CKF_MESSAGE_DECRYPT 0x00000004UL +#define CKF_MESSAGE_SIGN 0x00000008UL +#define CKF_MESSAGE_VERIFY 0x00000010UL +#define CKF_MULTI_MESSAGE 0x00000020UL + +/* FindObjects (not for CK_MECHANISM_INFO, but for C_CancelSession) v3.0 */ +#define CKF_FIND_OBJECTS 0x00000040UL + +/* The flags CKF_ENCRYPT, CKF_DECRYPT, CKF_DIGEST, CKF_SIGN, + * CKG_SIGN_RECOVER, CKF_VERIFY, CKF_VERIFY_RECOVER, + * CKF_GENERATE, CKF_GENERATE_KEY_PAIR, CKF_WRAP, CKF_UNWRAP, + * and CKF_DERIVE are new for v2.0. They specify whether or not + * a mechanism can be used for a particular task */ +#define CKF_ENCRYPT 0x00000100UL +#define CKF_DECRYPT 0x00000200UL +#define CKF_DIGEST 0x00000400UL +#define CKF_SIGN 0x00000800UL +#define CKF_SIGN_RECOVER 0x00001000UL +#define CKF_VERIFY 0x00002000 +#define CKF_VERIFY_RECOVER 0x00004000UL +#define CKF_GENERATE 0x00008000UL +#define CKF_GENERATE_KEY_PAIR 0x00010000UL +#define CKF_WRAP 0x00020000UL +#define CKF_UNWRAP 0x00040000UL +#define CKF_DERIVE 0x00080000UL + +/* CKF_EC_F_P, CKF_EC_F_2M, CKF_EC_ECPARAMETERS, CKF_EC_NAMEDCURVE, + * CKF_EC_UNCOMPRESS, and CKF_EC_COMPRESS are new for v2.11. They + * describe a token's EC capabilities not available in mechanism + * information. */ +#define CKF_EC_F_P 0x00100000UL +#define CKF_EC_F_2M 0x00200000UL +#define CKF_EC_ECPARAMETERS 0x00400000UL +#define CKF_EC_OID 0x00800000UL +#define CKF_EC_NAMEDCURVE CKF_EC_OID /* renamed in v3.0 */ +#define CKF_EC_UNCOMPRESS 0x01000000UL +#define CKF_EC_COMPRESS 0x02000000UL +#define CKF_EC_CURVENAME 0x04000000UL + +/* new for v3.2 */ +#define CKF_DECAPSULATE 0x20000000UL +#define CKF_ENCAPSULATE 0x10000000UL + +#define CKF_EXTENSION 0x80000000UL /* FALSE for this version */ + +typedef CK_MECHANISM_INFO CK_PTR CK_MECHANISM_INFO_PTR; + +/* CK_RV is a value that identifies the return value of a + * PKCS #11 function */ +/* CK_RV was changed from CK_USHORT to CK_ULONG for v2.0 */ +typedef CK_ULONG CK_RV; + +#define CKR_OK 0x00000000UL +#define CKR_CANCEL 0x00000001UL +#define CKR_HOST_MEMORY 0x00000002UL +#define CKR_SLOT_ID_INVALID 0x00000003UL + +/* CKR_FLAGS_INVALID was removed for v2.0 */ + +/* CKR_GENERAL_ERROR and CKR_FUNCTION_FAILED are new for v2.0 */ +#define CKR_GENERAL_ERROR 0x00000005UL +#define CKR_FUNCTION_FAILED 0x00000006UL + +/* CKR_ARGUMENTS_BAD, CKR_NO_EVENT, CKR_NEED_TO_CREATE_THREADS, + * and CKR_CANT_LOCK are new for v2.01 */ +#define CKR_ARGUMENTS_BAD 0x00000007UL +#define CKR_NO_EVENT 0x00000008UL +#define CKR_NEED_TO_CREATE_THREADS 0x00000009UL +#define CKR_CANT_LOCK 0x0000000AUL + +#define CKR_ATTRIBUTE_READ_ONLY 0x00000010UL +#define CKR_ATTRIBUTE_SENSITIVE 0x00000011UL +#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL +#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013UL + +/* new for v3.0 */ +#define CKR_ACTION_PROHIBITED 0x0000001BUL + +#define CKR_DATA_INVALID 0x00000020UL +#define CKR_DATA_LEN_RANGE 0x00000021UL +#define CKR_DEVICE_ERROR 0x00000030UL +#define CKR_DEVICE_MEMORY 0x00000031UL +#define CKR_DEVICE_REMOVED 0x00000032UL +#define CKR_ENCRYPTED_DATA_INVALID 0x00000040UL +#define CKR_ENCRYPTED_DATA_LEN_RANGE 0x00000041UL +#define CKR_AEAD_DECRYPT_FAILED 0x00000042UL +#define CKR_FUNCTION_CANCELED 0x00000050UL +#define CKR_FUNCTION_NOT_PARALLEL 0x00000051UL + +/* CKR_FUNCTION_NOT_SUPPORTED is new for v2.0 */ +#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL + +#define CKR_KEY_HANDLE_INVALID 0x00000060UL + +/* CKR_KEY_SENSITIVE was removed for v2.0 */ + +#define CKR_KEY_SIZE_RANGE 0x00000062UL +#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL + +/* CKR_KEY_NOT_NEEDED, CKR_KEY_CHANGED, CKR_KEY_NEEDED, + * CKR_KEY_INDIGESTIBLE, CKR_KEY_FUNCTION_NOT_PERMITTED, + * CKR_KEY_NOT_WRAPPABLE, and CKR_KEY_UNEXTRACTABLE are new for + * v2.0 */ +#define CKR_KEY_NOT_NEEDED 0x00000064UL +#define CKR_KEY_CHANGED 0x00000065UL +#define CKR_KEY_NEEDED 0x00000066UL +#define CKR_KEY_INDIGESTIBLE 0x00000067UL +#define CKR_KEY_FUNCTION_NOT_PERMITTED 0x00000068UL +#define CKR_KEY_NOT_WRAPPABLE 0x00000069UL +#define CKR_KEY_UNEXTRACTABLE 0x0000006AUL + +#define CKR_MECHANISM_INVALID 0x00000070UL +#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL + +/* CKR_OBJECT_CLASS_INCONSISTENT and CKR_OBJECT_CLASS_INVALID + * were removed for v2.0 */ +#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL +#define CKR_OPERATION_ACTIVE 0x00000090UL +#define CKR_OPERATION_NOT_INITIALIZED 0x00000091UL +#define CKR_PIN_INCORRECT 0x000000A0UL +#define CKR_PIN_INVALID 0x000000A1UL +#define CKR_PIN_LEN_RANGE 0x000000A2UL + +/* CKR_PIN_EXPIRED and CKR_PIN_LOCKED are new for v2.0 */ +#define CKR_PIN_EXPIRED 0x000000A3UL +#define CKR_PIN_LOCKED 0x000000A4UL + +#define CKR_SESSION_CLOSED 0x000000B0UL +#define CKR_SESSION_COUNT 0x000000B1UL +#define CKR_SESSION_HANDLE_INVALID 0x000000B3UL +#define CKR_SESSION_PARALLEL_NOT_SUPPORTED 0x000000B4UL +#define CKR_SESSION_READ_ONLY 0x000000B5UL +#define CKR_SESSION_EXISTS 0x000000B6UL + +/* CKR_SESSION_READ_ONLY_EXISTS and + * CKR_SESSION_READ_WRITE_SO_EXISTS are new for v2.0 */ +#define CKR_SESSION_READ_ONLY_EXISTS 0x000000B7UL +#define CKR_SESSION_READ_WRITE_SO_EXISTS 0x000000B8UL + +#define CKR_SIGNATURE_INVALID 0x000000C0UL +#define CKR_SIGNATURE_LEN_RANGE 0x000000C1UL +#define CKR_TEMPLATE_INCOMPLETE 0x000000D0UL +#define CKR_TEMPLATE_INCONSISTENT 0x000000D1UL +#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL +#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL +#define CKR_TOKEN_WRITE_PROTECTED 0x000000E2UL +#define CKR_UNWRAPPING_KEY_HANDLE_INVALID 0x000000F0UL +#define CKR_UNWRAPPING_KEY_SIZE_RANGE 0x000000F1UL +#define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT 0x000000F2UL +#define CKR_USER_ALREADY_LOGGED_IN 0x00000100UL +#define CKR_USER_NOT_LOGGED_IN 0x00000101UL +#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102UL +#define CKR_USER_TYPE_INVALID 0x00000103UL + +#define CKR_KEY_EXHAUSTED 0x00000203UL + +/* CKR_USER_ANOTHER_ALREADY_LOGGED_IN and CKR_USER_TOO_MANY_TYPES + * are new to v2.01 */ +#define CKR_USER_ANOTHER_ALREADY_LOGGED_IN 0x00000104UL +#define CKR_USER_TOO_MANY_TYPES 0x00000105UL + +#define CKR_WRAPPED_KEY_INVALID 0x00000110UL +#define CKR_WRAPPED_KEY_LEN_RANGE 0x00000112UL +#define CKR_WRAPPING_KEY_HANDLE_INVALID 0x00000113UL +#define CKR_WRAPPING_KEY_SIZE_RANGE 0x00000114UL +#define CKR_WRAPPING_KEY_TYPE_INCONSISTENT 0x00000115UL +#define CKR_RANDOM_SEED_NOT_SUPPORTED 0x00000120UL + +/* This is new to v2.0 */ +#define CKR_RANDOM_NO_RNG 0x00000121UL + +/* This is new to v2.11 */ +#define CKR_DOMAIN_PARAMS_INVALID 0x00000130UL + +/* This is new to v2.40 */ +#define CKR_CURVE_NOT_SUPPORTED 0x00000140UL + +/* These are new to v2.0 */ +#define CKR_BUFFER_TOO_SMALL 0x00000150UL +#define CKR_SAVED_STATE_INVALID 0x00000160UL +#define CKR_INFORMATION_SENSITIVE 0x00000170UL +#define CKR_STATE_UNSAVEABLE 0x00000180UL + +/* These are new to v2.01 */ +#define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190UL +#define CKR_CRYPTOKI_ALREADY_INITIALIZED 0x00000191UL +#define CKR_MUTEX_BAD 0x000001A0UL +#define CKR_MUTEX_NOT_LOCKED 0x000001A1UL + +/* These are new to v2.40 */ +#define CKR_NEW_PIN_MODE 0x000001B0UL +#define CKR_NEXT_OTP 0x000001B1UL +#define CKR_EXCEEDED_MAX_ITERATIONS 0x000001B5UL +#define CKR_FIPS_SELF_TEST_FAILED 0x000001B6UL +#define CKR_LIBRARY_LOAD_FAILED 0x000001B7UL +#define CKR_PIN_TOO_WEAK 0x000001B8UL +#define CKR_PUBLIC_KEY_INVALID 0x000001B9UL + +/* This is new to v2.20 */ +#define CKR_FUNCTION_REJECTED 0x00000200UL + +/* This is new to v3.0 */ +#define CKR_TOKEN_RESOURCE_EXCEEDED 0x00000201UL +#define CKR_OPERATION_CANCEL_FAILED 0x00000202UL + +/* new for v3.2 */ +#define CKR_PENDING 0x00000204UL +#define CKR_SESSION_ASYNC_NOT_SUPPORTED 0x00000205UL +#define CKR_SEED_RANDOM_REQUIRED 0x00000206UL +#define CKR_OPERATION_NOT_VALIDATED 0x00000207UL +#define CKR_TOKEN_NOT_INITIALIZED 0x00000208UL +#define CKR_PARAMETER_SET_NOT_SUPPORTED 0x00000209UL + +#define CKR_VENDOR_DEFINED 0x80000000UL + +/* CK_NOTIFY is an application callback that processes events */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_NOTIFY)( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_NOTIFICATION event, + CK_VOID_PTR pApplication /* passed to C_OpenSession */ +); + +/* CK_FUNCTION_LIST is a structure holding a PKCS #11 spec + * version and pointers of appropriate types to all the + * PKCS #11 functions */ +/* CK_FUNCTION_LIST is new for v2.0 */ +typedef struct CK_FUNCTION_LIST CK_FUNCTION_LIST; + +typedef CK_FUNCTION_LIST CK_PTR CK_FUNCTION_LIST_PTR; + +typedef CK_FUNCTION_LIST_PTR CK_PTR CK_FUNCTION_LIST_PTR_PTR; + +/* These are new for v3.0 */ +typedef struct CK_FUNCTION_LIST_3_0 CK_FUNCTION_LIST_3_0; +typedef CK_FUNCTION_LIST_3_0 CK_PTR CK_FUNCTION_LIST_3_0_PTR; +typedef CK_FUNCTION_LIST_3_0_PTR CK_PTR CK_FUNCTION_LIST_3_0_PTR_PTR; + +typedef struct CK_FUNCTION_LIST_3_2 CK_FUNCTION_LIST_3_2; +typedef CK_FUNCTION_LIST_3_2 CK_PTR CK_FUNCTION_LIST_3_2_PTR; +typedef CK_FUNCTION_LIST_3_2_PTR CK_PTR CK_FUNCTION_LIST_3_2_PTR_PTR; + +/* Interfaces are new in v3.0 */ +typedef struct CK_INTERFACE { + CK_CHAR *pInterfaceName; + CK_VOID_PTR pFunctionList; + CK_FLAGS flags; +} CK_INTERFACE; + +typedef CK_INTERFACE CK_PTR CK_INTERFACE_PTR; +typedef CK_INTERFACE_PTR CK_PTR CK_INTERFACE_PTR_PTR; + +#define CKF_END_OF_MESSAGE 0x00000001UL +#define CKF_INTERFACE_FORK_SAFE 0x00000001UL + +/* CK_CREATEMUTEX is an application callback for creating a + * mutex object */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_CREATEMUTEX)( + CK_VOID_PTR_PTR ppMutex /* location to receive ptr to mutex */ +); + +/* CK_DESTROYMUTEX is an application callback for destroying a + * mutex object */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_DESTROYMUTEX)( + CK_VOID_PTR pMutex /* pointer to mutex */ +); + +/* CK_LOCKMUTEX is an application callback for locking a mutex */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_LOCKMUTEX)( + CK_VOID_PTR pMutex /* pointer to mutex */ +); + +/* CK_UNLOCKMUTEX is an application callback for unlocking a + * mutex */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_UNLOCKMUTEX)( + CK_VOID_PTR pMutex /* pointer to mutex */ +); + +/* CK_C_INITIALIZE_ARGS provides the optional arguments to + * C_Initialize */ +typedef struct CK_C_INITIALIZE_ARGS { + CK_CREATEMUTEX CreateMutex; + CK_DESTROYMUTEX DestroyMutex; + CK_LOCKMUTEX LockMutex; + CK_UNLOCKMUTEX UnlockMutex; + CK_FLAGS flags; + /* The official PKCS #11 spec does not have a 'LibraryParameters' field, but + * a reserved field. NSS needs a way to pass instance-specific information + * to the library (like where to find its config files, etc). This + * information is usually provided by the installer and passed uninterpreted + * by NSS to the library, though NSS does know the specifics of the softoken + * version of this parameter. Most compliant PKCS#11 modules expect this + * parameter to be NULL, and will return CKR_ARGUMENTS_BAD from + * C_Initialize if Library parameters is supplied. */ + CK_CHAR_PTR *LibraryParameters; + /* This field is only present if the LibraryParameters is not NULL. It must + * be NULL in all cases */ + CK_VOID_PTR pReserved; +} CK_C_INITIALIZE_ARGS; + +/* flags: bit flags that provide capabilities of the slot + * Bit Flag Mask Meaning + */ +#define CKF_LIBRARY_CANT_CREATE_OS_THREADS 0x00000001UL +#define CKF_OS_LOCKING_OK 0x00000002UL + +typedef CK_C_INITIALIZE_ARGS CK_PTR CK_C_INITIALIZE_ARGS_PTR; + +/* additional flags for parameters to functions */ + +/* CKF_DONT_BLOCK is for the function C_WaitForSlotEvent */ +#define CKF_DONT_BLOCK 1 + +/* CK_RSA_PKCS_OAEP_MGF_TYPE is new for v2.10. + * CK_RSA_PKCS_OAEP_MGF_TYPE is used to indicate the Message + * Generation Function (MGF) applied to a message block when + * formatting a message block for the PKCS #1 OAEP encryption + * scheme. */ +typedef CK_ULONG CK_RSA_PKCS_MGF_TYPE; + +typedef CK_RSA_PKCS_MGF_TYPE CK_PTR CK_RSA_PKCS_MGF_TYPE_PTR; + +/* The following MGFs are defined */ +/* CKG_MGF1_SHA256, CKG_MGF1_SHA384, and CKG_MGF1_SHA512 + * are new for v2.20 */ +#define CKG_MGF1_SHA1 0x00000001UL +#define CKG_MGF1_SHA256 0x00000002UL +#define CKG_MGF1_SHA384 0x00000003UL +#define CKG_MGF1_SHA512 0x00000004UL + +/* v2.20 amendment 3 */ +#define CKG_MGF1_SHA224 0x00000005UL + +/* v2.40 */ +#define CKG_MGF1_SHA3_224 0x00000006UL +#define CKG_MGF1_SHA3_256 0x00000007UL +#define CKG_MGF1_SHA3_384 0x00000008UL +#define CKG_MGF1_SHA3_512 0x00000009UL + +/* CK_RSA_PKCS_OAEP_SOURCE_TYPE is new for v2.10. + * CK_RSA_PKCS_OAEP_SOURCE_TYPE is used to indicate the source + * of the encoding parameter when formatting a message block + * for the PKCS #1 OAEP encryption scheme. */ +typedef CK_ULONG CK_RSA_PKCS_OAEP_SOURCE_TYPE; + +typedef CK_RSA_PKCS_OAEP_SOURCE_TYPE CK_PTR CK_RSA_PKCS_OAEP_SOURCE_TYPE_PTR; + +/* The following encoding parameter sources are defined */ +#define CKZ_DATA_SPECIFIED 0x00000001UL + +/* CK_RSA_PKCS_OAEP_PARAMS is new for v2.10. + * CK_RSA_PKCS_OAEP_PARAMS provides the parameters to the + * CKM_RSA_PKCS_OAEP mechanism. */ +typedef struct CK_RSA_PKCS_OAEP_PARAMS { + CK_MECHANISM_TYPE hashAlg; + CK_RSA_PKCS_MGF_TYPE mgf; + CK_RSA_PKCS_OAEP_SOURCE_TYPE source; + CK_VOID_PTR pSourceData; + CK_ULONG ulSourceDataLen; +} CK_RSA_PKCS_OAEP_PARAMS; + +typedef CK_RSA_PKCS_OAEP_PARAMS CK_PTR CK_RSA_PKCS_OAEP_PARAMS_PTR; + +/* CK_RSA_PKCS_PSS_PARAMS is new for v2.11. + * CK_RSA_PKCS_PSS_PARAMS provides the parameters to the + * CKM_RSA_PKCS_PSS mechanism(s). */ +typedef struct CK_RSA_PKCS_PSS_PARAMS { + CK_MECHANISM_TYPE hashAlg; + CK_RSA_PKCS_MGF_TYPE mgf; + CK_ULONG sLen; +} CK_RSA_PKCS_PSS_PARAMS; + +typedef CK_RSA_PKCS_PSS_PARAMS CK_PTR CK_RSA_PKCS_PSS_PARAMS_PTR; + +/* CK_EC_KDF_TYPE is new for v2.11. */ +typedef CK_ULONG CK_EC_KDF_TYPE; +typedef CK_EC_KDF_TYPE CK_PTR CK_EC_KDF_TYPE_PTR; + +/* The following EC Key Derivation Functions are defined */ +#define CKD_NULL 0x00000001UL +#define CKD_SHA1_KDF 0x00000002UL +#define CKD_SHA224_KDF 0x00000005UL +#define CKD_SHA256_KDF 0x00000006UL +#define CKD_SHA384_KDF 0x00000007UL +#define CKD_SHA512_KDF 0x00000008UL + +/* new for v2.40 */ +#define CKD_CPDIVERSIFY_KDF 0x00000009UL +#define CKD_SHA3_224_KDF 0x0000000AUL +#define CKD_SHA3_256_KDF 0x0000000BUL +#define CKD_SHA3_384_KDF 0x0000000CUL +#define CKD_SHA3_512_KDF 0x0000000DUL + +/* new for v3.0 */ +#define CKD_SHA1_KDF_SP800 0x0000000EUL +#define CKD_SHA224_KDF_SP800 0x0000000FUL +#define CKD_SHA256_KDF_SP800 0x00000010UL +#define CKD_SHA384_KDF_SP800 0x00000011UL +#define CKD_SHA512_KDF_SP800 0x00000012UL +#define CKD_SHA3_224_KDF_SP800 0x00000013UL +#define CKD_SHA3_256_KDF_SP800 0x00000014UL +#define CKD_SHA3_384_KDF_SP800 0x00000015UL +#define CKD_SHA3_512_KDF_SP800 0x00000016UL +#define CKD_BLAKE2B_160_KDF 0x00000017UL +#define CKD_BLAKE2B_256_KDF 0x00000018UL +#define CKD_BLAKE2B_384_KDF 0x00000019UL +#define CKD_BLAKE2B_512_KDF 0x0000001aUL + +/* CK_ECDH1_DERIVE_PARAMS is new for v2.11. + * CK_ECDH1_DERIVE_PARAMS provides the parameters to the + * CKM_ECDH1_DERIVE and CKM_ECDH1_COFACTOR_DERIVE mechanisms, + * where each party contributes one key pair. + */ +typedef struct CK_ECDH1_DERIVE_PARAMS { + CK_EC_KDF_TYPE kdf; + CK_ULONG ulSharedDataLen; + CK_BYTE_PTR pSharedData; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; +} CK_ECDH1_DERIVE_PARAMS; + +typedef CK_ECDH1_DERIVE_PARAMS CK_PTR CK_ECDH1_DERIVE_PARAMS_PTR; + +/* CK_ECDH2_DERIVE_PARAMS is new for v2.11. + * CK_ECDH2_DERIVE_PARAMS provides the parameters to the + * CKM_ECMQV_DERIVE mechanism, where each party contributes two key pairs. */ +typedef struct CK_ECDH2_DERIVE_PARAMS { + CK_EC_KDF_TYPE kdf; + CK_ULONG ulSharedDataLen; + CK_BYTE_PTR pSharedData; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPrivateDataLen; + CK_OBJECT_HANDLE hPrivateData; + CK_ULONG ulPublicDataLen2; + CK_BYTE_PTR pPublicData2; +} CK_ECDH2_DERIVE_PARAMS; + +typedef CK_ECDH2_DERIVE_PARAMS CK_PTR CK_ECDH2_DERIVE_PARAMS_PTR; + +typedef struct CK_ECMQV_DERIVE_PARAMS { + CK_EC_KDF_TYPE kdf; + CK_ULONG ulSharedDataLen; + CK_BYTE_PTR pSharedData; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPrivateDataLen; + CK_OBJECT_HANDLE hPrivateData; + CK_ULONG ulPublicDataLen2; + CK_BYTE_PTR pPublicData2; + CK_OBJECT_HANDLE publicKey; +} CK_ECMQV_DERIVE_PARAMS; + +typedef CK_ECMQV_DERIVE_PARAMS CK_PTR CK_ECMQV_DERIVE_PARAMS_PTR; + +/* Typedefs and defines for the CKM_X9_42_DH_KEY_PAIR_GEN and the + * CKM_X9_42_DH_PARAMETER_GEN mechanisms (new for PKCS #11 v2.11) */ +typedef CK_ULONG CK_X9_42_DH_KDF_TYPE; +typedef CK_X9_42_DH_KDF_TYPE CK_PTR CK_X9_42_DH_KDF_TYPE_PTR; + +/* The following X9.42 DH key derivation functions are defined + (besides CKD_NULL already defined : */ +#define CKD_SHA1_KDF_ASN1 0x00000003UL +#define CKD_SHA1_KDF_CONCATENATE 0x00000004UL + +/* CK_X9_42_DH1_DERIVE_PARAMS is new for v2.11. + * CK_X9_42_DH1_DERIVE_PARAMS provides the parameters to the + * CKM_X9_42_DH_DERIVE key derivation mechanism, where each party + * contributes one key pair */ +typedef struct CK_X9_42_DH1_DERIVE_PARAMS { + CK_X9_42_DH_KDF_TYPE kdf; + CK_ULONG ulOtherInfoLen; + CK_BYTE_PTR pOtherInfo; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; +} CK_X9_42_DH1_DERIVE_PARAMS; + +typedef struct CK_X9_42_DH1_DERIVE_PARAMS CK_PTR CK_X9_42_DH1_DERIVE_PARAMS_PTR; + +/* CK_X9_42_DH2_DERIVE_PARAMS is new for v2.11. + * CK_X9_42_DH2_DERIVE_PARAMS provides the parameters to the + * CKM_X9_42_DH_HYBRID_DERIVE and CKM_X9_42_MQV_DERIVE key derivation + * mechanisms, where each party contributes two key pairs */ +typedef struct CK_X9_42_DH2_DERIVE_PARAMS { + CK_X9_42_DH_KDF_TYPE kdf; + CK_ULONG ulOtherInfoLen; + CK_BYTE_PTR pOtherInfo; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPrivateDataLen; + CK_OBJECT_HANDLE hPrivateData; + CK_ULONG ulPublicDataLen2; + CK_BYTE_PTR pPublicData2; +} CK_X9_42_DH2_DERIVE_PARAMS; + +typedef CK_X9_42_DH2_DERIVE_PARAMS CK_PTR CK_X9_42_DH2_DERIVE_PARAMS_PTR; + +typedef struct CK_X9_42_MQV_DERIVE_PARAMS { + CK_X9_42_DH_KDF_TYPE kdf; + CK_ULONG ulOtherInfoLen; + CK_BYTE_PTR pOtherInfo; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPrivateDataLen; + CK_OBJECT_HANDLE hPrivateData; + CK_ULONG ulPublicDataLen2; + CK_BYTE_PTR pPublicData2; + CK_OBJECT_HANDLE publicKey; +} CK_X9_42_MQV_DERIVE_PARAMS; + +typedef CK_X9_42_MQV_DERIVE_PARAMS CK_PTR CK_X9_42_MQV_DERIVE_PARAMS_PTR; + +/* CK_KEA_DERIVE_PARAMS provides the parameters to the + * CKM_KEA_DERIVE mechanism */ +/* CK_KEA_DERIVE_PARAMS is new for v2.0 */ +typedef struct CK_KEA_DERIVE_PARAMS { + CK_BBOOL isSender; + CK_ULONG ulRandomLen; + CK_BYTE_PTR pRandomA; + CK_BYTE_PTR pRandomB; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; +} CK_KEA_DERIVE_PARAMS; + +typedef CK_KEA_DERIVE_PARAMS CK_PTR CK_KEA_DERIVE_PARAMS_PTR; + +/* CK_RC2_PARAMS provides the parameters to the CKM_RC2_ECB and + * CKM_RC2_MAC mechanisms. An instance of CK_RC2_PARAMS just + * holds the effective keysize */ +typedef CK_ULONG CK_RC2_PARAMS; + +typedef CK_RC2_PARAMS CK_PTR CK_RC2_PARAMS_PTR; + +/* CK_RC2_CBC_PARAMS provides the parameters to the CKM_RC2_CBC + * mechanism */ +typedef struct CK_RC2_CBC_PARAMS { + /* ulEffectiveBits was changed from CK_USHORT to CK_ULONG for + * v2.0 */ + CK_ULONG ulEffectiveBits; /* effective bits (1-1024) */ + + CK_BYTE iv[8]; /* IV for CBC mode */ +} CK_RC2_CBC_PARAMS; + +typedef CK_RC2_CBC_PARAMS CK_PTR CK_RC2_CBC_PARAMS_PTR; + +/* CK_RC2_MAC_GENERAL_PARAMS provides the parameters for the + * CKM_RC2_MAC_GENERAL mechanism */ +/* CK_RC2_MAC_GENERAL_PARAMS is new for v2.0 */ +typedef struct CK_RC2_MAC_GENERAL_PARAMS { + CK_ULONG ulEffectiveBits; /* effective bits (1-1024) */ + CK_ULONG ulMacLength; /* Length of MAC in bytes */ +} CK_RC2_MAC_GENERAL_PARAMS; + +typedef CK_RC2_MAC_GENERAL_PARAMS CK_PTR + CK_RC2_MAC_GENERAL_PARAMS_PTR; + +/* CK_RC5_PARAMS provides the parameters to the CKM_RC5_ECB and + * CKM_RC5_MAC mechanisms */ +/* CK_RC5_PARAMS is new for v2.0 */ +typedef struct CK_RC5_PARAMS { + CK_ULONG ulWordsize; /* wordsize in bits */ + CK_ULONG ulRounds; /* number of rounds */ +} CK_RC5_PARAMS; + +typedef CK_RC5_PARAMS CK_PTR CK_RC5_PARAMS_PTR; + +/* CK_RC5_CBC_PARAMS provides the parameters to the CKM_RC5_CBC + * mechanism */ +/* CK_RC5_CBC_PARAMS is new for v2.0 */ +typedef struct CK_RC5_CBC_PARAMS { + CK_ULONG ulWordsize; /* wordsize in bits */ + CK_ULONG ulRounds; /* number of rounds */ + CK_BYTE_PTR pIv; /* pointer to IV */ + CK_ULONG ulIvLen; /* length of IV in bytes */ +} CK_RC5_CBC_PARAMS; + +typedef CK_RC5_CBC_PARAMS CK_PTR CK_RC5_CBC_PARAMS_PTR; + +/* CK_RC5_MAC_GENERAL_PARAMS provides the parameters for the + * CKM_RC5_MAC_GENERAL mechanism */ +/* CK_RC5_MAC_GENERAL_PARAMS is new for v2.0 */ +typedef struct CK_RC5_MAC_GENERAL_PARAMS { + CK_ULONG ulWordsize; /* wordsize in bits */ + CK_ULONG ulRounds; /* number of rounds */ + CK_ULONG ulMacLength; /* Length of MAC in bytes */ +} CK_RC5_MAC_GENERAL_PARAMS; + +typedef CK_RC5_MAC_GENERAL_PARAMS CK_PTR + CK_RC5_MAC_GENERAL_PARAMS_PTR; + +/* CK_MAC_GENERAL_PARAMS provides the parameters to most block + * ciphers' MAC_GENERAL mechanisms. Its value is the length of + * the MAC */ +/* CK_MAC_GENERAL_PARAMS is new for v2.0 */ +typedef CK_ULONG CK_MAC_GENERAL_PARAMS; + +typedef CK_MAC_GENERAL_PARAMS CK_PTR CK_MAC_GENERAL_PARAMS_PTR; + +/* CK_DES/AES_ECB/CBC_ENCRYPT_DATA_PARAMS are new for v2.20 */ +typedef struct CK_DES_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[8]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_DES_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_DES_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_DES_CBC_ENCRYPT_DATA_PARAMS_PTR; + +typedef struct CK_AES_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[16]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_AES_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_AES_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_AES_CBC_ENCRYPT_DATA_PARAMS_PTR; + +/* CK_AES_CTR_PARAMS is new for PKCS #11 v2.20 amendment 3 */ +typedef struct CK_AES_CTR_PARAMS { + CK_ULONG ulCounterBits; + CK_BYTE cb[16]; +} CK_AES_CTR_PARAMS; + +typedef CK_AES_CTR_PARAMS CK_PTR CK_AES_CTR_PARAMS_PTR; + +/* CK_GCM_PARAMS is new for version 2.30 */ +/* There was a discrepency between the doc and the headers + * in PKCS #11 v2.40, NSS had the doc version, but the header + * was normative. In V3.0 they were reconsiled as the header + * version. In NSS the header version is called CK_GCM_PARAMS_V3 + * and the v2.40 doc version is called CK_NSS_GCM_PARAMS. + * CK_GCM_PARMS is define as CK_NSS_GCM_PARAMS if + * NSS_PCKS11_2_0_COMPAT is defined and CK_GCM_PARAMS_V3 if it's not. + * Softoken accepts either version and internally uses CK_NSS_GCM_PARAMS */ +typedef struct CK_GCM_PARAMS_V3 { + CK_BYTE_PTR pIv; + CK_ULONG ulIvLen; + CK_ULONG ulIvBits; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulTagBits; +} CK_GCM_PARAMS_V3; + +typedef CK_GCM_PARAMS_V3 CK_PTR CK_GCM_PARAMS_V3_PTR; + +/* CK_CCM_PARAMS is new for version 2.30 */ +typedef struct CK_CCM_PARAMS { + CK_ULONG ulDataLen; + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceLen; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulMACLen; +} CK_CCM_PARAMS; + +typedef CK_CCM_PARAMS CK_PTR CK_CCM_PARAMS_PTR; + +/* SALSA20_POLY1305 and CHACHA20_POLY1305 is AEAD is new in v3.0 */ +typedef struct CK_SALSA20_CHACHA20_POLY1305_PARAMS { + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceLen; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; +} CK_SALSA20_CHACHA20_POLY1305_PARAMS; + +typedef CK_SALSA20_CHACHA20_POLY1305_PARAMS + CK_PTR CK_SALSA20_CHACHA20_POLY1305_PARAMS_PTR; + +/* MESSAGE params are new for v3.0 */ +typedef CK_ULONG CK_GENERATOR_FUNCTION; +#define CKG_NO_GENERATE 0x00000000UL +#define CKG_GENERATE 0x00000001UL +#define CKG_GENERATE_COUNTER 0x00000002UL +#define CKG_GENERATE_RANDOM 0x00000003UL +#define CKG_GENERATE_COUNTER_XOR 0x00000004UL + +typedef struct CK_GCM_MESSAGE_PARAMS { + CK_BYTE_PTR pIv; + CK_ULONG ulIvLen; + CK_ULONG ulIvFixedBits; + CK_GENERATOR_FUNCTION ivGenerator; + CK_BYTE_PTR pTag; + CK_ULONG ulTagBits; +} CK_GCM_MESSAGE_PARAMS; + +typedef CK_GCM_MESSAGE_PARAMS CK_PTR CK_GCM_MESSAGE_PARAMS_PTR; + +typedef struct CK_CCM_MESSAGE_PARAMS { + CK_ULONG ulDataLen; /*plaintext or ciphertext*/ + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceLen; + CK_ULONG ulNonceFixedBits; + CK_GENERATOR_FUNCTION nonceGenerator; + CK_BYTE_PTR pMAC; + CK_ULONG ulMACLen; +} CK_CCM_MESSAGE_PARAMS; + +typedef CK_CCM_MESSAGE_PARAMS CK_PTR CK_CCM_MESSAGE_PARAMS_PTR; + +/* new for v3.2 */ +typedef struct CK_GCM_WRAP_PARAMS { + CK_BYTE_PTR pIv; + CK_ULONG ulIvLen; + CK_ULONG ulIvFixedBits; + CK_GENERATOR_FUNCTION ivGenerator; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulTagBits; +} CK_GCM_WRAP_PARAMS; + +typedef CK_GCM_WRAP_PARAMS CK_PTR CK_GCM_WRAP_PARAMS_PTR; + +/* new for v3.2 */ +typedef struct CK_CCM_WRAP_PARAMS { + CK_ULONG ulDataLen; /*wrappedkey data*/ + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceLen; + CK_ULONG ulNonceFixedBits; + CK_GENERATOR_FUNCTION nonceGenerator; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulMACLen; +} CK_CCM_WRAP_PARAMS; + +typedef CK_CCM_WRAP_PARAMS CK_PTR CK_CCM_WRAP_PARAMS_PTR; + +/* SALSA20/CHACHA20 doe not define IV generators */ +typedef struct CK_SALSA20_CHACHA20_POLY1305_MSG_PARAMS { + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceLen; + CK_BYTE_PTR pTag; +} CK_SALSA20_CHACHA20_POLY1305_MSG_PARAMS; + +typedef CK_SALSA20_CHACHA20_POLY1305_MSG_PARAMS + CK_PTR CK_SALSA20_CHACHA20_POLY1305_MSG_PARAMS_PTR; + +/* CK_SKIPJACK_PRIVATE_WRAP_PARAMS provides the parameters to the + * CKM_SKIPJACK_PRIVATE_WRAP mechanism */ +/* CK_SKIPJACK_PRIVATE_WRAP_PARAMS is new for v2.0 */ +typedef struct CK_SKIPJACK_PRIVATE_WRAP_PARAMS { + CK_ULONG ulPasswordLen; + CK_BYTE_PTR pPassword; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPAndGLen; + CK_ULONG ulQLen; + CK_ULONG ulRandomLen; + CK_BYTE_PTR pRandomA; + CK_BYTE_PTR pPrimeP; + CK_BYTE_PTR pBaseG; + CK_BYTE_PTR pSubprimeQ; +} CK_SKIPJACK_PRIVATE_WRAP_PARAMS; + +typedef CK_SKIPJACK_PRIVATE_WRAP_PARAMS CK_PTR + CK_SKIPJACK_PRIVATE_WRAP_PARAMS_PTR; + +/* CK_SKIPJACK_RELAYX_PARAMS provides the parameters to the + * CKM_SKIPJACK_RELAYX mechanism */ +/* CK_SKIPJACK_RELAYX_PARAMS is new for v2.0 */ +typedef struct CK_SKIPJACK_RELAYX_PARAMS { + CK_ULONG ulOldWrappedXLen; + CK_BYTE_PTR pOldWrappedX; + CK_ULONG ulOldPasswordLen; + CK_BYTE_PTR pOldPassword; + CK_ULONG ulOldPublicDataLen; + CK_BYTE_PTR pOldPublicData; + CK_ULONG ulOldRandomLen; + CK_BYTE_PTR pOldRandomA; + CK_ULONG ulNewPasswordLen; + CK_BYTE_PTR pNewPassword; + CK_ULONG ulNewPublicDataLen; + CK_BYTE_PTR pNewPublicData; + CK_ULONG ulNewRandomLen; + CK_BYTE_PTR pNewRandomA; +} CK_SKIPJACK_RELAYX_PARAMS; + +typedef CK_SKIPJACK_RELAYX_PARAMS CK_PTR + CK_SKIPJACK_RELAYX_PARAMS_PTR; + +/* New for v2.40, CAMELLIA, ARIA, SEED */ +typedef struct CK_CAMELLIA_CTR_PARAMS { + CK_ULONG ulCounterBits; + CK_BYTE cb[16]; +} CK_CAMELLIA_CTR_PARAMS; + +typedef CK_CAMELLIA_CTR_PARAMS CK_PTR CK_CAMELLIA_CTR_PARAMS_PTR; + +typedef struct CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[16]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS CK_PTR + CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS_PTR; + +typedef struct CK_ARIA_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[16]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_ARIA_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_ARIA_CBC_ENCRYPT_DATA_PARAMS CK_PTR + CK_ARIA_CBC_ENCRYPT_DATA_PARAMS_PTR; + +typedef struct CK_SEED_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[16]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_SEED_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_SEED_CBC_ENCRYPT_DATA_PARAMS CK_PTR + CK_SEED_CBC_ENCRYPT_DATA_PARAMS_PTR; + +/* ChaCha20/Salsa20 Counter support is new in v3.0*/ +typedef struct CK_CHACHA20_PARAMS { + CK_BYTE_PTR pBlockCounter; + CK_ULONG blockCounterBits; + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceBits; +} CK_CHACHA20_PARAMS; + +typedef CK_CHACHA20_PARAMS CK_PTR CK_CHACHA20_PARAMS_PTR; + +typedef struct CK_SALSA20_PARAMS { + CK_BYTE_PTR pBlockCounter; + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceBits; +} CK_SALSA20_PARAMS; +typedef CK_SALSA20_PARAMS CK_PTR CK_SALSA20_PARAMS_PTR; + +typedef struct CK_PBE_PARAMS { + CK_BYTE_PTR pInitVector; + CK_UTF8CHAR_PTR pPassword; + CK_ULONG ulPasswordLen; + CK_BYTE_PTR pSalt; + CK_ULONG ulSaltLen; + CK_ULONG ulIteration; +} CK_PBE_PARAMS; + +typedef CK_PBE_PARAMS CK_PTR CK_PBE_PARAMS_PTR; + +/* CK_KEY_WRAP_SET_OAEP_PARAMS provides the parameters to the + * CKM_KEY_WRAP_SET_OAEP mechanism */ +/* CK_KEY_WRAP_SET_OAEP_PARAMS is new for v2.0 */ +typedef struct CK_KEY_WRAP_SET_OAEP_PARAMS { + CK_BYTE bBC; /* block contents byte */ + CK_BYTE_PTR pX; /* extra data */ + CK_ULONG ulXLen; /* length of extra data in bytes */ +} CK_KEY_WRAP_SET_OAEP_PARAMS; + +typedef CK_KEY_WRAP_SET_OAEP_PARAMS CK_PTR + CK_KEY_WRAP_SET_OAEP_PARAMS_PTR; + +typedef struct CK_SSL3_RANDOM_DATA { + CK_BYTE_PTR pClientRandom; + CK_ULONG ulClientRandomLen; + CK_BYTE_PTR pServerRandom; + CK_ULONG ulServerRandomLen; +} CK_SSL3_RANDOM_DATA; + +typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS { + CK_SSL3_RANDOM_DATA RandomInfo; + CK_VERSION_PTR pVersion; +} CK_SSL3_MASTER_KEY_DERIVE_PARAMS; + +typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS CK_PTR + CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR; + +typedef struct CK_SSL3_KEY_MAT_OUT { + CK_OBJECT_HANDLE hClientMacSecret; + CK_OBJECT_HANDLE hServerMacSecret; + CK_OBJECT_HANDLE hClientKey; + CK_OBJECT_HANDLE hServerKey; + CK_BYTE_PTR pIVClient; + CK_BYTE_PTR pIVServer; +} CK_SSL3_KEY_MAT_OUT; + +typedef CK_SSL3_KEY_MAT_OUT CK_PTR CK_SSL3_KEY_MAT_OUT_PTR; + +typedef struct CK_SSL3_KEY_MAT_PARAMS { + CK_ULONG ulMacSizeInBits; + CK_ULONG ulKeySizeInBits; + CK_ULONG ulIVSizeInBits; + CK_BBOOL bIsExport; /* Unused. Must be set to CK_FALSE. */ + CK_SSL3_RANDOM_DATA RandomInfo; + CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; +} CK_SSL3_KEY_MAT_PARAMS; + +typedef CK_SSL3_KEY_MAT_PARAMS CK_PTR CK_SSL3_KEY_MAT_PARAMS_PTR; + +/* CK_TLS_PRF_PARAMS is new for version 2.20 */ +typedef struct CK_TLS_PRF_PARAMS { + CK_BYTE_PTR pSeed; + CK_ULONG ulSeedLen; + CK_BYTE_PTR pLabel; + CK_ULONG ulLabelLen; + CK_BYTE_PTR pOutput; + CK_ULONG_PTR pulOutputLen; +} CK_TLS_PRF_PARAMS; + +typedef CK_TLS_PRF_PARAMS CK_PTR CK_TLS_PRF_PARAMS_PTR; + +/* TLS 1.2 is new for version 2.40 */ +typedef struct CK_TLS12_MASTER_KEY_DERIVE_PARAMS { + CK_SSL3_RANDOM_DATA RandomInfo; + CK_VERSION_PTR pVersion; + CK_MECHANISM_TYPE prfHashMechanism; +} CK_TLS12_MASTER_KEY_DERIVE_PARAMS; + +typedef CK_TLS12_MASTER_KEY_DERIVE_PARAMS CK_PTR + CK_TLS12_MASTER_KEY_DERIVE_PARAMS_PTR; + +typedef struct CK_TLS12_KEY_MAT_PARAMS { + CK_ULONG ulMacSizeInBits; + CK_ULONG ulKeySizeInBits; + CK_ULONG ulIVSizeInBits; + CK_BBOOL bIsExport; /* Unused. Must be set to CK_FALSE. */ + CK_SSL3_RANDOM_DATA RandomInfo; + CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; + CK_MECHANISM_TYPE prfHashMechanism; +} CK_TLS12_KEY_MAT_PARAMS; + +typedef CK_TLS12_KEY_MAT_PARAMS CK_PTR CK_TLS12_KEY_MAT_PARAMS_PTR; + +typedef struct CK_TLS_KDF_PARAMS { + CK_MECHANISM_TYPE prfMechanism; + CK_BYTE_PTR pLabel; + CK_ULONG ulLabelLength; + CK_SSL3_RANDOM_DATA RandomInfo; + CK_BYTE_PTR pContextData; + CK_ULONG ulContextDataLength; +} CK_TLS_KDF_PARAMS; + +typedef CK_TLS_KDF_PARAMS CK_PTR CK_TLS_KDF_PARAMS_PTR; + +typedef struct CK_TLS_MAC_PARAMS { + CK_MECHANISM_TYPE prfHashMechanism; + CK_ULONG ulMacLength; + CK_ULONG ulServerOrClient; +} CK_TLS_MAC_PARAMS; + +typedef CK_TLS_MAC_PARAMS CK_PTR CK_TLS_MAC_PARAMS_PTR; + +/* new for v3.2 */ +typedef struct CK_TLS12_EXTENDED_MASTER_KEY_DERIVE_PARAMS { + CK_MECHANISM_TYPE prfHashMechanism; + CK_BYTE_PTR pSessionHash; + CK_ULONG ulSessionHashLen; + CK_VERSION_PTR pVersion; +} CK_TLS12_EXTENDED_MASTER_KEY_DERIVE_PARAMS; + +typedef CK_TLS12_EXTENDED_MASTER_KEY_DERIVE_PARAMS CK_PTR + CK_TLS12_EXTENDED_MASTER_KEY_DERIVE_PARAMS_PTR; + +/* HKDF is new for v3.0 */ +typedef struct CK_HKDF_PARAMS { + CK_BBOOL bExtract; + CK_BBOOL bExpand; + CK_MECHANISM_TYPE prfHashMechanism; + CK_ULONG ulSaltType; + CK_BYTE_PTR pSalt; + CK_ULONG ulSaltLen; + CK_OBJECT_HANDLE hSaltKey; + CK_BYTE_PTR pInfo; + CK_ULONG ulInfoLen; +} CK_HKDF_PARAMS; +typedef CK_HKDF_PARAMS CK_PTR CK_HKDF_PARAMS_PTR; + +#define CKF_HKDF_SALT_NULL 0x00000001UL +#define CKF_HKDF_SALT_DATA 0x00000002UL +#define CKF_HKDF_SALT_KEY 0x00000004UL + +/* IKE is new for v3.1 */ +/* + * CK_IKE2_PRF_PLUS_PARAMS is a structure that provides the parameters to + * the CKM_IKE2_PRF_PLUS_DERIVE mechanism. + * The fields of the structure have the following meanings: + * prfMechanism underlying MAC mechanism used to generate the prf. + * bHasSeedKey hSeed key is present. + * hSeedKey optional seed from key + * pSeedData optional seed from data. + * ulSeedDataLen length of optional seed data. + * If no seed data is present this value is NULL. + */ +typedef struct CK_IKE2_PRF_PLUS_DERIVE_PARAMS { + CK_MECHANISM_TYPE prfMechanism; + CK_BBOOL bHasSeedKey; + CK_OBJECT_HANDLE hSeedKey; + CK_BYTE_PTR pSeedData; + CK_ULONG ulSeedDataLen; +} CK_IKE2_PRF_PLUS_DERIVE_PARAMS; + +typedef CK_IKE2_PRF_PLUS_DERIVE_PARAMS CK_PTR CK_IKE2_PRF_PLUS_DERIVE_PARAMS_PTR; + +/* CK_IKE_PRF_DERIVE_PARAMS is a structure that provides the parameters to + * the CKM_IKE_PRF_DERIVE mechanism. + * + * The fields of the structure have the following meanings: + * prfMechanism underlying MAC mechanism used to generate the prf. + * bRekey hNewKey is present. + * pNi Ni value + * ulNiLen length of Ni + * pNr Nr value + * ulNrLen length of Nr + * hNewKey New key value to drive the rekey. + */ +typedef struct CK_IKE_PRF_DERIVE_PARAMS { + CK_MECHANISM_TYPE prfMechanism; + CK_BBOOL bDataAsKey; + CK_BBOOL bRekey; + CK_BYTE_PTR pNi; + CK_ULONG ulNiLen; + CK_BYTE_PTR pNr; + CK_ULONG ulNrLen; + CK_OBJECT_HANDLE hNewKey; +} CK_IKE_PRF_DERIVE_PARAMS; + +typedef CK_IKE_PRF_DERIVE_PARAMS CK_PTR CK_IKE_PRF_DERIVE_PARAMS_PTR; + +/* CK_IKE1_PRF_DERIVE_PARAMS is a structure that provides the parameters + * to the CKM_IKE1_PRF_DERIVE mechanism. + * + * The fields of the structure have the following meanings: + * prfMechanism underlying MAC mechanism used to generate the prf. + * bHasPrevKey there is a previous key to use + * hKeygxy key to hash in the prf (usually a dhkey of sorts) + * hPrevKey the previous ike1 key + * pCKYi CKYi value + * ulCKYiLen length of CKYi + * pCKYr CKYr value + * ulCKYrLen length of CKYr + * hNewKey New key value to drive the rekey. + */ +typedef struct CK_IKE1_PRF_DERIVE_PARAMS { + CK_MECHANISM_TYPE prfMechanism; + CK_BBOOL bHasPrevKey; + CK_OBJECT_HANDLE hKeygxy; + CK_OBJECT_HANDLE hPrevKey; + CK_BYTE_PTR pCKYi; + CK_ULONG ulCKYiLen; + CK_BYTE_PTR pCKYr; + CK_ULONG ulCKYrLen; + CK_BYTE keyNumber; +} CK_IKE1_PRF_DERIVE_PARAMS; + +typedef CK_IKE1_PRF_DERIVE_PARAMS CK_PTR CK_IKE1_PRF_DERIVE_PARAMS_PTR; + +/* CK_IKE1_EXTENDED_DERIVE_PARAMS is a structure that provides the + * parameters to the CKM_IKE1_EXTENDED_DERIVE mechanism. + * + * The fields of the structure have the following meanings: + * prfMechanism underlying MAC mechanism used to generate the prf. + * bHasKeygxy hKeygxy exists + * hKeygxy optional key to hash in the prf + * pExtraData optional extra data to hash in the prf + * ulExtraData length of the optional extra data. + */ +typedef struct CK_IKE1_EXTENDED_DERIVE_PARAMS { + CK_MECHANISM_TYPE prfMechanism; + CK_BBOOL bHasKeygxy; + CK_OBJECT_HANDLE hKeygxy; + CK_BYTE_PTR pExtraData; + CK_ULONG ulExtraDataLen; +} CK_IKE1_EXTENDED_DERIVE_PARAMS; + +typedef CK_IKE1_EXTENDED_DERIVE_PARAMS CK_PTR CK_IKE1_EXTENDED_DERIVE_PARAMS_PTR; + +/* WTLS is new for version 2.20 */ +typedef struct CK_WTLS_RANDOM_DATA { + CK_BYTE_PTR pClientRandom; + CK_ULONG ulClientRandomLen; + CK_BYTE_PTR pServerRandom; + CK_ULONG ulServerRandomLen; +} CK_WTLS_RANDOM_DATA; + +typedef CK_WTLS_RANDOM_DATA CK_PTR CK_WTLS_RANDOM_DATA_PTR; + +typedef struct CK_WTLS_MASTER_KEY_DERIVE_PARAMS { + CK_MECHANISM_TYPE DigestMechanism; + CK_WTLS_RANDOM_DATA RandomInfo; + CK_BYTE_PTR pVersion; +} CK_WTLS_MASTER_KEY_DERIVE_PARAMS; + +typedef CK_WTLS_MASTER_KEY_DERIVE_PARAMS CK_PTR + CK_WTLS_MASTER_KEY_DERIVE_PARAMS_PTR; + +typedef struct CK_WTLS_PRF_PARAMS { + CK_MECHANISM_TYPE DigestMechanism; + CK_BYTE_PTR pSeed; + CK_ULONG ulSeedLen; + CK_BYTE_PTR pLabel; + CK_ULONG ulLabelLen; + CK_BYTE_PTR pOutput; + CK_ULONG_PTR pulOutputLen; +} CK_WTLS_PRF_PARAMS; + +typedef CK_WTLS_PRF_PARAMS CK_PTR CK_WTLS_PRF_PARAMS_PTR; + +typedef struct CK_WTLS_KEY_MAT_OUT { + CK_OBJECT_HANDLE hMacSecret; + CK_OBJECT_HANDLE hKey; + CK_BYTE_PTR pIV; +} CK_WTLS_KEY_MAT_OUT; + +typedef CK_WTLS_KEY_MAT_OUT CK_PTR CK_WTLS_KEY_MAT_OUT_PTR; + +typedef struct CK_WTLS_KEY_MAT_PARAMS { + CK_MECHANISM_TYPE DigestMechanism; + CK_ULONG ulMacSizeInBits; + CK_ULONG ulKeySizeInBits; + CK_ULONG ulIVSizeInBits; + CK_ULONG ulSequenceNumber; + CK_BBOOL bIsExport; /* Unused. Must be set to CK_FALSE. */ + CK_WTLS_RANDOM_DATA RandomInfo; + CK_WTLS_KEY_MAT_OUT_PTR pReturnedKeyMaterial; +} CK_WTLS_KEY_MAT_PARAMS; + +typedef CK_WTLS_KEY_MAT_PARAMS CK_PTR CK_WTLS_KEY_MAT_PARAMS_PTR; + +/* The following types for NIST 800-108 KBKDF are defined in PKCS#11 v3.0 */ +typedef CK_MECHANISM_TYPE CK_SP800_108_PRF_TYPE; +typedef CK_ULONG CK_PRF_DATA_TYPE; + +#define CK_SP800_108_ITERATION_VARIABLE 0x00000001UL +#define CK_SP800_108_OPTIONAL_COUNTER 0x00000002UL +#define CK_SP800_108_DKM_LENGTH 0x00000003UL +#define CK_SP800_108_BYTE_ARRAY 0x00000004UL +/* new for v3.2 */ +#define CK_SP800_108_KEY_HANDLE 0x00000005UL + +/* ERRATA: PKCS#11 v3.0 Cryptographic Token Interface Current Mechanisms + * specification specifies a CK_SP800_108_COUNTER, while the pkcs11t.h from + * PKCS#11 v3.0 Cryptographic Token Interface Base Specification specifies + * CK_SP800_108_OPTIONAL_COUNTER. */ +#define CK_SP800_108_COUNTER CK_SP800_108_OPTIONAL_COUNTER + +typedef struct CK_PRF_DATA_PARAM { + CK_PRF_DATA_TYPE type; + CK_VOID_PTR pValue; + CK_ULONG ulValueLen; +} CK_PRF_DATA_PARAM; + +typedef CK_PRF_DATA_PARAM CK_PTR CK_PRF_DATA_PARAM_PTR; + +typedef struct CK_SP800_108_COUNTER_FORMAT { + CK_BBOOL bLittleEndian; + CK_ULONG ulWidthInBits; +} CK_SP800_108_COUNTER_FORMAT; + +typedef CK_SP800_108_COUNTER_FORMAT CK_PTR CK_SP800_108_COUNTER_FORMAT_PTR; + +typedef CK_ULONG CK_SP800_108_DKM_LENGTH_METHOD; + +/* ERRATA: PKCS#11 v3.0 Cryptographic Token Interface Current Mechanisms + * defines that these constants exist, but doesn't specify values. pkcs11t.h + * from PKCS#11 v3.0 Cryptographic Token Interface Base Specification doesn't + * define these constants either. */ +#define CK_SP800_108_DKM_LENGTH_SUM_OF_KEYS 0x00000001UL +#define CK_SP800_108_DKM_LENGTH_SUM_OF_SEGMENTS 0x00000002UL + +typedef struct CK_SP800_108_DKM_LENGTH_FORMAT { + CK_SP800_108_DKM_LENGTH_METHOD dkmLengthMethod; + CK_BBOOL bLittleEndian; + CK_ULONG ulWidthInBits; +} CK_SP800_108_DKM_LENGTH_FORMAT; + +typedef CK_SP800_108_DKM_LENGTH_FORMAT CK_PTR CK_SP800_108_DKM_LENGTH_FORMAT_PTR; + +typedef struct CK_DERIVED_KEY { + CK_ATTRIBUTE_PTR pTemplate; + CK_ULONG ulAttributeCount; + CK_OBJECT_HANDLE_PTR phKey; +} CK_DERIVED_KEY; + +typedef CK_DERIVED_KEY CK_PTR CK_DERIVED_KEY_PTR; + +/* UNFIXED ERRATA: NIST SP800-108 specifies that implementer can decide the + * number of bits to take from each PRF invocation. However, all three forms + * of the PKCS#11 v3.0 implementation lack a bitwidth for the PRF and only + * allow the full-width mechanism varieties. Additionally, outside of the + * base key (used as the key to the PRF), there is no way to pass any + * additional, PRF-mechanism specific data. */ + +typedef struct CK_SP800_108_KDF_PARAMS { + CK_SP800_108_PRF_TYPE prfType; + CK_ULONG ulNumberOfDataParams; + CK_PRF_DATA_PARAM_PTR pDataParams; + CK_ULONG ulAdditionalDerivedKeys; + /* ERRATA: in PKCS#11 v3.0, pAdditionalDerivedKeys is typed as + * CK_DERVIED_KEY; it needs to be of type CK_DERIVED_KEY_PTR. */ + CK_DERIVED_KEY_PTR pAdditionalDerivedKeys; +} CK_SP800_108_KDF_PARAMS; + +typedef CK_SP800_108_KDF_PARAMS CK_PTR CK_SP800_108_KDF_PARAMS_PTR; + +typedef struct CK_SP800_108_FEEDBACK_KDF_PARAMS { + CK_SP800_108_PRF_TYPE prfType; + CK_ULONG ulNumberOfDataParams; + CK_PRF_DATA_PARAM_PTR pDataParams; + CK_ULONG ulIVLen; + CK_BYTE_PTR pIV; + CK_ULONG ulAdditionalDerivedKeys; + /* ERRATA: in PKCS#11 v3.0, pAdditionalDerivedKeys is typed as + * CK_DERVIED_KEY; it needs to be of type CK_DERIVED_KEY_PTR. */ + CK_DERIVED_KEY_PTR pAdditionalDerivedKeys; +} CK_SP800_108_FEEDBACK_KDF_PARAMS; + +typedef CK_SP800_108_FEEDBACK_KDF_PARAMS CK_PTR CK_SP800_108_FEEDBACK_KDF_PARAMS_PTR; + +/* CMS is new for version 2.20 */ +typedef struct CK_CMS_SIG_PARAMS { + CK_OBJECT_HANDLE certificateHandle; + CK_MECHANISM_PTR pSigningMechanism; + CK_MECHANISM_PTR pDigestMechanism; + CK_UTF8CHAR_PTR pContentType; + CK_BYTE_PTR pRequestedAttributes; + CK_ULONG ulRequestedAttributesLen; + CK_BYTE_PTR pRequiredAttributes; + CK_ULONG ulRequiredAttributesLen; +} CK_CMS_SIG_PARAMS; + +typedef CK_CMS_SIG_PARAMS CK_PTR CK_CMS_SIG_PARAMS_PTR; + +typedef struct CK_KEY_DERIVATION_STRING_DATA { + CK_BYTE_PTR pData; + CK_ULONG ulLen; +} CK_KEY_DERIVATION_STRING_DATA; + +typedef CK_KEY_DERIVATION_STRING_DATA CK_PTR + CK_KEY_DERIVATION_STRING_DATA_PTR; + +/* The CK_EXTRACT_PARAMS is used for the + * CKM_EXTRACT_KEY_FROM_KEY mechanism. It specifies which bit + * of the base key should be used as the first bit of the + * derived key */ +/* CK_EXTRACT_PARAMS is new for v2.0 */ +typedef CK_ULONG CK_EXTRACT_PARAMS; + +typedef CK_EXTRACT_PARAMS CK_PTR CK_EXTRACT_PARAMS_PTR; + +/* CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is new for v2.10. + * CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is used to + * indicate the Pseudo-Random Function (PRF) used to generate + * key bits using PKCS #5 PBKDF2. */ +typedef CK_ULONG CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE; + +typedef CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE CK_PTR CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE_PTR; + +/* The following PRFs are defined in PKCS #5 v2.1. */ +#define CKP_PKCS5_PBKD2_HMAC_SHA1 0x00000001UL +#define CKP_PKCS5_PBKD2_HMAC_GOSTR3411 0x00000002UL +#define CKP_PKCS5_PBKD2_HMAC_SHA224 0x00000003UL +#define CKP_PKCS5_PBKD2_HMAC_SHA256 0x00000004UL +#define CKP_PKCS5_PBKD2_HMAC_SHA384 0x00000005UL +#define CKP_PKCS5_PBKD2_HMAC_SHA512 0x00000006UL +#define CKP_PKCS5_PBKD2_HMAC_SHA512_224 0x00000007UL +#define CKP_PKCS5_PBKD2_HMAC_SHA512_256 0x00000008UL + +/* CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is new for v2.10. + * CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is used to indicate the + * source of the salt value when deriving a key using PKCS #5 + * PBKDF2. */ +typedef CK_ULONG CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE; + +typedef CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE CK_PTR CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE_PTR; + +/* The following salt value sources are defined in PKCS #5 v2.0. */ +#define CKZ_SALT_SPECIFIED 0x00000001UL + +/* CK_PKCS5_PBKD2_PARAMS is new for v2.10. + * CK_PKCS5_PBKD2_PARAMS is a structure that provides the + * parameters to the CKM_PKCS5_PBKD2 mechanism. */ +/* this structure is kept for compatibility. use _PARAMS2. */ +typedef struct CK_PKCS5_PBKD2_PARAMS { + CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE saltSource; + CK_VOID_PTR pSaltSourceData; + CK_ULONG ulSaltSourceDataLen; + CK_ULONG iterations; + CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf; + CK_VOID_PTR pPrfData; + CK_ULONG ulPrfDataLen; + CK_UTF8CHAR_PTR pPassword; + CK_ULONG_PTR ulPasswordLen; +} CK_PKCS5_PBKD2_PARAMS; + +typedef CK_PKCS5_PBKD2_PARAMS CK_PTR CK_PKCS5_PBKD2_PARAMS_PTR; + +typedef struct CK_PKCS5_PBKD2_PARAMS2 { + CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE saltSource; + CK_VOID_PTR pSaltSourceData; + CK_ULONG ulSaltSourceDataLen; + CK_ULONG iterations; + CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf; + CK_VOID_PTR pPrfData; + CK_ULONG ulPrfDataLen; + CK_UTF8CHAR_PTR pPassword; + CK_ULONG ulPasswordLen; +} CK_PKCS5_PBKD2_PARAMS2; + +typedef CK_PKCS5_PBKD2_PARAMS2 CK_PTR CK_PKCS5_PBKD2_PARAMS2_PTR; + +/* The following value is used to determines if a parameter is of type PARAMS or PARAMS2 + * based on the value of ulPasswordLen. If ulPasswordLen is greater that the value below, + * it is most likely a memory address i.e. a pointer (PARAMS). Otherwise, it is considered + * a length value (PARAMS2). This is ignored if NSS_USE_PKCS5_PBKD2_PARAMS2_ONLY is defined. + */ +#define CK_PKCS5_PBKD2_PARAMS_PTR_BOUNDARY 8192 + +/* OTP is new in v2.40 */ +typedef CK_ULONG CK_OTP_PARAM_TYPE; +#define CK_OTP_VALUE 0UL +#define CK_OTP_PIN 1UL +#define CK_OTP_CHALLENGE 2UL +#define CK_OTP_TIME 3UL +#define CK_OTP_COUNTER 4UL +#define CK_OTP_FLAGS 5UL +#define CK_OTP_OUTPUT_LENGTH 6UL +#define CK_OTP_OUTPUT_FORMAT 7UL + +typedef struct CK_OTP_PARAM { + CK_OTP_PARAM_TYPE type; + CK_VOID_PTR pValue; + CK_ULONG ulValueLen; +} CK_OTP_PARAM; + +typedef CK_OTP_PARAM CK_PTR CK_OTP_PARAM_PTR; + +typedef struct CK_OTP_PARAMS { + CK_OTP_PARAM_PTR pParams; + CK_ULONG ulCount; +} CK_OTP_PARAMS; + +typedef CK_OTP_PARAMS CK_PTR CK_OTP_PARAMS_PTR; + +typedef struct CK_OTP_SIGNATURE_INFO { + CK_OTP_PARAM_PTR pParams; + CK_ULONG ulCount; +} CK_OTP_SIGNATURE_INFO; + +typedef CK_OTP_SIGNATURE_INFO CK_PTR CK_OTP_SIGNATURE_INFO_PTR; + +#define CKF_NEXT_OTP 0x00000001UL +#define CKF_EXCLUDE_TIME 0x00000002UL +#define CKF_EXCLUDE_COUNTER 0x00000004UL +#define CKF_EXCLUDE_CHALLENGE 0x00000008UL +#define CKF_EXCLUDE_PIN 0x00000010UL +#define CKF_USER_FRIENDLY_OTP 0x00000020UL + +/* KIP is new in v2.40 */ +typedef struct CK_KIP_PARAMS { + CK_MECHANISM_PTR pMechanism; + CK_OBJECT_HANDLE hKey; + CK_BYTE_PTR pSeed; + CK_ULONG ulSeedLen; +} CK_KIP_PARAMS; + +typedef CK_KIP_PARAMS CK_PTR CK_KIP_PARAMS_PTR; + +/* DSA Param Gen is new for v2.40 */ +typedef struct CK_DSA_PARAMETER_GEN_PARAM { + CK_MECHANISM_TYPE hash; + CK_BYTE_PTR pSeed; + CK_ULONG ulSeedLen; + CK_ULONG ulIndex; +} CK_DSA_PARAMETER_GEN_PARAM; + +typedef CK_DSA_PARAMETER_GEN_PARAM CK_PTR CK_DSA_PARAMETER_GEN_PARAM_PTR; + +/* XXXX_AES_KEY_WRAP is new for v2.40 */ +typedef struct CK_ECDH_AES_KEY_WRAP_PARAMS { + CK_ULONG ulAESKeyBits; + CK_EC_KDF_TYPE kdf; + CK_ULONG ulSharedDataLen; + CK_BYTE_PTR pSharedData; +} CK_ECDH_AES_KEY_WRAP_PARAMS; + +typedef CK_ECDH_AES_KEY_WRAP_PARAMS CK_PTR CK_ECDH_AES_KEY_WRAP_PARAMS_PTR; + +typedef struct CK_RSA_AES_KEY_WRAP_PARAMS { + CK_ULONG ulAESKeyBits; + CK_RSA_PKCS_OAEP_PARAMS_PTR pOAEPParams; +} CK_RSA_AES_KEY_WRAP_PARAMS; + +typedef CK_RSA_AES_KEY_WRAP_PARAMS CK_PTR CK_RSA_AES_KEY_WRAP_PARAMS_PTR; + +/* GOSTR3410 is new for v2.40 */ +typedef struct CK_GOSTR3410_DERIVE_PARAMS { + CK_EC_KDF_TYPE kdf; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pUKM; + CK_ULONG ulUKMLen; +} CK_GOSTR3410_DERIVE_PARAMS; + +typedef CK_GOSTR3410_DERIVE_PARAMS CK_PTR CK_GOSTR3410_DERIVE_PARAMS_PTR; + +typedef struct CK_GOSTR3410_KEY_WRAP_PARAMS { + CK_BYTE_PTR pWrapOID; + CK_ULONG ulWrapOIDLen; + CK_BYTE_PTR pUKM; + CK_ULONG ulUKMLen; + CK_OBJECT_HANDLE hKey; +} CK_GOSTR3410_KEY_WRAP_PARAMS; + +typedef CK_GOSTR3410_KEY_WRAP_PARAMS CK_PTR CK_GOSTR3410_KEY_WRAP_PARAMS_PTR; + +/* EDDSA and XEDDSA are new for v3.0 */ +typedef struct CK_EDDSA_PARAMS { + CK_BBOOL phFlag; + CK_ULONG ulContextDataLen; + CK_BYTE_PTR pContextData; +} CK_EDDSA_PARAMS; +typedef CK_ULONG CK_XEDDSA_HASH_TYPE; +typedef CK_EDDSA_PARAMS CK_PTR CK_EDDSA_PARAMS_PTR; +typedef CK_XEDDSA_HASH_TYPE CK_PTR CK_XEDDSA_HASH_TYPE_PTR; + +typedef struct CK_XEDDSA_PARAMS { + CK_XEDDSA_HASH_TYPE hash; +} CK_XEDDSA_PARAMS; +typedef CK_XEDDSA_PARAMS CK_PTR CK_XEDDSA_PARAMS_PTR; + +/* X3DH and Ratchet are new in v3.0 */ +typedef CK_ULONG CK_X3DH_KDF_TYPE; +typedef CK_X3DH_KDF_TYPE CK_PTR CK_X3DH_KDF_TYPE_PTR; + +typedef struct CK_X3DH_INITIATE_PARAMS { + CK_X3DH_KDF_TYPE kdf; + CK_OBJECT_HANDLE pPeer_identity; + CK_OBJECT_HANDLE pPeer_prekey; + CK_BYTE_PTR pPrekey_signature; + CK_BYTE_PTR pOnetime_key; + CK_OBJECT_HANDLE pOwn_identity; + CK_OBJECT_HANDLE pOwn_ephemeral; +} CK_X3DH_INITIATE_PARAMS; + +typedef struct CK_X3DH_RESPOND_PARAMS { + CK_X3DH_KDF_TYPE kdf; + CK_BYTE_PTR pIdentity_id; + CK_BYTE_PTR pPrekey_id; + CK_BYTE_PTR pOnetime_id; + CK_OBJECT_HANDLE pInitiator_identity; + CK_BYTE_PTR pInitiator_ephemeral; +} CK_X3DH_RESPOND_PARAMS; + +typedef CK_ULONG CK_X2RATCHET_KDF_TYPE; +typedef CK_X2RATCHET_KDF_TYPE CK_PTR CK_X2RATCHET_KDF_TYPE_PTR; + +typedef struct CK_X2RATCHET_INITIALIZE_PARAMS { + CK_BYTE_PTR sk; + CK_OBJECT_HANDLE peer_public_prekey; + CK_OBJECT_HANDLE peer_public_identity; + CK_OBJECT_HANDLE own_public_identity; + CK_BBOOL bEncryptedHeader; + CK_ULONG eCurve; + CK_MECHANISM_TYPE aeadMechanism; + CK_X2RATCHET_KDF_TYPE kdfMechanism; +} CK_X2RATCHET_INITIALIZE_PARAMS; + +typedef CK_X2RATCHET_INITIALIZE_PARAMS + CK_PTR CK_X2RATCHET_INITIALIZE_PARAMS_PTR; + +typedef struct CK_X2RATCHET_RESPOND_PARAMS { + CK_BYTE_PTR sk; + CK_OBJECT_HANDLE own_prekey; + CK_OBJECT_HANDLE initiator_identity; + CK_OBJECT_HANDLE own_public_identity; + CK_BBOOL bEncryptedHeader; + CK_ULONG eCurve; + CK_MECHANISM_TYPE aeadMechanism; + CK_X2RATCHET_KDF_TYPE kdfMechanism; +} CK_X2RATCHET_RESPOND_PARAMS; +typedef CK_X2RATCHET_RESPOND_PARAMS + CK_PTR CK_X2RATCHET_RESPOND_PARAMS_PTR; + +/* async - new for v3.2 */ +typedef struct CK_ASYNC_DATA { + CK_ULONG ulVersion; + CK_BYTE_PTR pValue; + CK_ULONG ulValue; + CK_OBJECT_HANDLE hObject; + CK_OBJECT_HANDLE hAdditionalObject; +} CK_ASYNC_DATA; +typedef CK_ASYNC_DATA CK_PTR CK_ASYNC_DATA_PTR; + +/* validation - new for v3.2 */ +typedef CK_ULONG CK_SESSION_VALIDATION_FLAGS_TYPE; +#define CKS_LAST_VALIDATION_OK 0x00000001UL + +typedef CK_ULONG CK_VALIDATION_TYPE; +typedef CK_VALIDATION_TYPE CK_PTR CK_VALIDATION_TYPE_PTR; +#define CKV_TYPE_UNSPECIFIED 0x00000000UL +#define CKV_TYPE_SOFTWARE 0x00000001UL +#define CKV_TYPE_HARDWARE 0x00000002UL +#define CKV_TYPE_FIRMWARE 0x00000003UL +#define CKV_TYPE_HYBRID 0x00000004UL + +typedef CK_ULONG CK_VALIDATION_AUTHORITY_TYPE; +typedef CK_VALIDATION_AUTHORITY_TYPE CK_PTR CK_VALIDATION_AUTHORITY_TYPE_PTR; +#define CKV_AUTHORITY_TYPE_UNSPECIFIED 0x00000000UL +#define CKV_AUTHORITY_TYPE_NIST_CMVP 0x00000001UL +#define CKV_AUTHORITY_TYPE_COMMON_CRITERIA 0x00000002UL + +/* trust - new for v3.2 */ +typedef CK_ULONG CK_TRUST; +#define CKT_TRUST_UNKNOWN 0x00000000UL +#define CKT_TRUSTED 0x00000001UL +#define CKT_TRUST_ANCHOR 0x00000002UL +#define CKT_NOT_TRUSTED 0x00000003UL +#define CKT_TRUST_MUST_VERIFY_TRUST 0x00000004UL + +/* XMSS - new for v3.2*/ +typedef CK_ULONG CK_XMSSMT_PARAMETER_SET_TYPE; +typedef CK_ULONG CK_XMSS_PARAMETER_SET_TYPE; + +/* generic signing parameters - new for v3.2 */ +typedef CK_ULONG CK_HEDGE_TYPE; +#define CKH_HEDGE_PREFERRED 0x00000000UL +#define CKH_HEDGE_REQUIRED 0x00000001UL +#define CKH_DETERMINISTIC_REQUIRED 0x00000002UL + +typedef struct CK_SIGN_ADDITIONAL_CONTEXT { + CK_HEDGE_TYPE hedgeVariant; + CK_BYTE_PTR pContext; + CK_ULONG ulContextLen; +} CK_SIGN_ADDITIONAL_CONTEXT; + +typedef struct CK_HASH_SIGN_ADDITIONAL_CONTEXT { + CK_HEDGE_TYPE hedgeVariant; + CK_BYTE_PTR pContext; + CK_ULONG ulContextLen; + CK_MECHANISM_TYPE hash; +} CK_HASH_SIGN_ADDITIONAL_CONTEXT; + +/* CKA_PARAMETER_SETS for ML-DSA -- new for v3.2*/ +typedef CK_ULONG CK_ML_DSA_PARAMETER_SET_TYPE; +#define CKP_ML_DSA_44 0x00000001UL +#define CKP_ML_DSA_65 0x00000002UL +#define CKP_ML_DSA_87 0x00000003UL + +/* CKA_PARAMETER_SETS for SLH-DSA -- new for v3.2*/ +typedef CK_ULONG CK_SLH_DSA_PARAMETER_SET_TYPE; +#define CKP_SLH_DSA_SHA2_128S 0x00000001UL +#define CKP_SLH_DSA_SHAKE_128S 0x00000002UL +#define CKP_SLH_DSA_SHA2_128F 0x00000003UL +#define CKP_SLH_DSA_SHAKE_128F 0x00000004UL +#define CKP_SLH_DSA_SHA2_192S 0x00000005UL +#define CKP_SLH_DSA_SHAKE_192S 0x00000006UL +#define CKP_SLH_DSA_SHA2_192F 0x00000007UL +#define CKP_SLH_DSA_SHAKE_192F 0x00000008UL +#define CKP_SLH_DSA_SHA2_256S 0x00000009UL +#define CKP_SLH_DSA_SHAKE_256S 0x0000000aUL +#define CKP_SLH_DSA_SHA2_256F 0x0000000bUL +#define CKP_SLH_DSA_SHAKE_256F 0x0000000cUL + +/* CKA_PARAMETER_SETS for ML-KEM -- new for v3.2*/ +typedef CK_ULONG CK_ML_KEM_PARAMETER_SET_TYPE; +#define CKP_ML_KEM_512 0x00000001UL +#define CKP_ML_KEM_768 0x00000002UL +#define CKP_ML_KEM_1024 0x00000003UL + +/* NSS Specific defines */ +/* stuff that for historic reasons is in this header file but should have + * been in pkcs11n.h */ +#define CKK_INVALID_KEY_TYPE 0xffffffffUL + +#include "pkcs11n.h" + +/* undo packing */ +#include "pkcs11u.h" + +#endif diff --git a/illumos-x86_64/usr/include/mps/pkcs11u.h b/illumos-x86_64/usr/include/mps/pkcs11u.h new file mode 100644 index 00000000..64ec2fdb --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs11u.h @@ -0,0 +1,22 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* + * Copyright (C) 1994-1999 RSA Security Inc. Licence to copy this document + * is granted provided that it is identified as "RSA Security Inc. Public-Key + * Cryptography Standards (PKCS)" in all material mentioning or referencing + * this document. + */ +/* + * reset any packing set by pkcs11p.h + */ + +#if defined(_WIN32) || defined(_WINDOWS) +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpragma-pack" +#endif +#ifdef _MSC_VER +#pragma warning(disable : 4103) +#endif +#pragma pack(pop, cryptoki) +#endif diff --git a/illumos-x86_64/usr/include/mps/pkcs11uri.h b/illumos-x86_64/usr/include/mps/pkcs11uri.h new file mode 100644 index 00000000..84fb69f6 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs11uri.h @@ -0,0 +1,80 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _PKCS11URI_H_ +#define _PKCS11URI_H_ 1 + +#include "seccomon.h" + +/* Path attributes defined in RFC7512. */ +#define PK11URI_PATTR_TOKEN "token" +#define PK11URI_PATTR_MANUFACTURER "manufacturer" +#define PK11URI_PATTR_SERIAL "serial" +#define PK11URI_PATTR_MODEL "model" +#define PK11URI_PATTR_LIBRARY_MANUFACTURER "library-manufacturer" +#define PK11URI_PATTR_LIBRARY_DESCRIPTION "library-description" +#define PK11URI_PATTR_LIBRARY_VERSION "library-version" +#define PK11URI_PATTR_OBJECT "object" +#define PK11URI_PATTR_TYPE "type" +#define PK11URI_PATTR_ID "id" +#define PK11URI_PATTR_SLOT_MANUFACTURER "slot-manufacturer" +#define PK11URI_PATTR_SLOT_DESCRIPTION "slot-description" +#define PK11URI_PATTR_SLOT_ID "slot-id" + +/* Query attributes defined in RFC7512. */ +#define PK11URI_QATTR_PIN_SOURCE "pin-source" +#define PK11URI_QATTR_PIN_VALUE "pin-value" +#define PK11URI_QATTR_MODULE_NAME "module-name" +#define PK11URI_QATTR_MODULE_PATH "module-path" + +SEC_BEGIN_PROTOS + +/* A PK11URI object is an immutable structure that holds path and + * query attributes of a PKCS#11 URI. */ +struct PK11URIStr; +typedef struct PK11URIStr PK11URI; + +struct PK11URIAttributeStr { + const char *name; + const char *value; +}; +typedef struct PK11URIAttributeStr PK11URIAttribute; + +/* Create a new PK11URI object from a set of attributes. */ +extern PK11URI *PK11URI_CreateURI(const PK11URIAttribute *pattrs, + size_t num_pattrs, + const PK11URIAttribute *qattrs, + size_t num_qattrs); + +/* Parse PKCS#11 URI and return a new PK11URI object. */ +extern PK11URI *PK11URI_ParseURI(const char *string); + +/* Format a PK11URI object to a string. */ +extern char *PK11URI_FormatURI(PLArenaPool *arena, PK11URI *uri); + +/* Destroy a PK11URI object. */ +extern void PK11URI_DestroyURI(PK11URI *uri); + +/* Retrieve a path attribute with the given name. This function can be used only + * when we can assume that the attribute value is a string (such as "label" or + * "type"). If it can be a binary blob (such as "id"), use + * PK11URI_GetPathAttributeItem. + */ +extern const char *PK11URI_GetPathAttribute(PK11URI *uri, const char *name); + +/* Retrieve a query attribute with the given name. This function can be used + * only when we can assume that the attribute value is a string (such as + * "module-name"). If it can be a binary blob, use + * PK11URI_GetQueryAttributeItem.*/ +extern const char *PK11URI_GetQueryAttribute(PK11URI *uri, const char *name); + +/* Retrieve a path attribute with the given name as a SECItem. */ +extern const SECItem *PK11URI_GetPathAttributeItem(PK11URI *uri, const char *name); + +/* Retrieve a query attribute with the given name as a SECItem. */ +extern const SECItem *PK11URI_GetQueryAttributeItem(PK11URI *uri, const char *name); + +SEC_END_PROTOS + +#endif /* _PKCS11URI_H_ */ diff --git a/illumos-x86_64/usr/include/mps/pkcs12.h b/illumos-x86_64/usr/include/mps/pkcs12.h new file mode 100644 index 00000000..57b3263f --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs12.h @@ -0,0 +1,41 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _PKCS12_H_ +#define _PKCS12_H_ + +#include "pkcs12t.h" +#include "p12.h" + +SEC_BEGIN_PROTOS + +typedef SECItem *(*SEC_PKCS12GetPassword)(void *arg); + +/* Decode functions */ +/* Import a PFX item. + * der_pfx is the der-encoded pfx item to import. + * pbef, and pbefarg are used to retrieve passwords for the HMAC, + * and any passwords needed for passing to PKCS5 encryption + * routines. + * algorithm is the algorithm by which private keys are stored in + * the key database. this could be a specific algorithm or could + * be based on a global setting. + * slot is the slot to where the certificates will be placed. if NULL, + * the internal key slot is used. + * If the process is successful, a SECSuccess is returned, otherwise + * a failure occurred. + */ +SECStatus +SEC_PKCS12PutPFX(SECItem *der_pfx, SECItem *pwitem, + SEC_PKCS12NicknameCollisionCallback ncCall, + PK11SlotInfo *slot, void *wincx); + +/* check the first two bytes of a file to make sure that it matches + * the desired header for a PKCS 12 file + */ +PRBool SEC_PKCS12ValidData(char *buf, int bufLen, long int totalLength); + +SEC_END_PROTOS + +#endif diff --git a/illumos-x86_64/usr/include/mps/pkcs12t.h b/illumos-x86_64/usr/include/mps/pkcs12t.h new file mode 100644 index 00000000..db10d28a --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs12t.h @@ -0,0 +1,341 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _PKCS12T_H_ +#define _PKCS12T_H_ + +#include "seccomon.h" +#include "secoid.h" +#include "cert.h" +#include "keythi.h" +#include "plarena.h" +#include "secpkcs7.h" +#include "secdig.h" /* for SGNDigestInfo */ + +typedef enum { + SECPKCS12TargetTokenNoCAs, /* CA get loaded intothe fixed token, + * User certs go to target token */ + SECPKCS12TargetTokenIntermediateCAs, /* User certs and intermediates go to + * target token, root certs got to + * fixed token */ + SECPKCS12TargetTokenAllCAs /* All certs go to target token */ +} SECPKCS12TargetTokenCAs; + +/* PKCS12 Structures */ +typedef struct SEC_PKCS12PFXItemStr SEC_PKCS12PFXItem; +typedef struct SEC_PKCS12MacDataStr SEC_PKCS12MacData; +typedef struct SEC_PKCS12AuthenticatedSafeStr SEC_PKCS12AuthenticatedSafe; +typedef struct SEC_PKCS12BaggageItemStr SEC_PKCS12BaggageItem; +typedef struct SEC_PKCS12BaggageStr SEC_PKCS12Baggage; +typedef struct SEC_PKCS12Baggage_OLDStr SEC_PKCS12Baggage_OLD; +typedef struct SEC_PKCS12ESPVKItemStr SEC_PKCS12ESPVKItem; +typedef struct SEC_PKCS12PVKSupportingDataStr SEC_PKCS12PVKSupportingData; +typedef struct SEC_PKCS12PVKAdditionalDataStr SEC_PKCS12PVKAdditionalData; +typedef struct SEC_PKCS12SafeContentsStr SEC_PKCS12SafeContents; +typedef struct SEC_PKCS12SafeBagStr SEC_PKCS12SafeBag; +typedef struct SEC_PKCS12PrivateKeyStr SEC_PKCS12PrivateKey; +typedef struct SEC_PKCS12PrivateKeyBagStr SEC_PKCS12PrivateKeyBag; +typedef struct SEC_PKCS12CertAndCRLBagStr SEC_PKCS12CertAndCRLBag; +typedef struct SEC_PKCS12CertAndCRLStr SEC_PKCS12CertAndCRL; +typedef struct SEC_PKCS12X509CertCRLStr SEC_PKCS12X509CertCRL; +typedef struct SEC_PKCS12SDSICertStr SEC_PKCS12SDSICert; +typedef struct SEC_PKCS12SecretStr SEC_PKCS12Secret; +typedef struct SEC_PKCS12SecretAdditionalStr SEC_PKCS12SecretAdditional; +typedef struct SEC_PKCS12SecretItemStr SEC_PKCS12SecretItem; +typedef struct SEC_PKCS12SecretBagStr SEC_PKCS12SecretBag; + +typedef SECItem *(*SEC_PKCS12PasswordFunc)(SECItem *args); + +/* PKCS12 types */ + +/* stores shrouded keys */ +struct SEC_PKCS12BaggageStr { + PLArenaPool *poolp; + SEC_PKCS12BaggageItem **bags; + + int luggage_size; /* used locally */ +}; + +/* additional data to be associated with keys. currently there + * is nothing defined to be stored here. allows future expansion. + */ +struct SEC_PKCS12PVKAdditionalDataStr { + PLArenaPool *poolp; + SECOidData *pvkAdditionalTypeTag; /* used locally */ + SECItem pvkAdditionalType; + SECItem pvkAdditionalContent; +}; + +/* cert and other supporting data for private keys. used + * for both shrouded and non-shrouded keys. + */ +struct SEC_PKCS12PVKSupportingDataStr { + PLArenaPool *poolp; + SGNDigestInfo **assocCerts; + SECItem regenerable; + SECItem nickname; + SEC_PKCS12PVKAdditionalData pvkAdditional; + SECItem pvkAdditionalDER; + + SECItem uniNickName; + /* used locally */ + int nThumbs; +}; + +/* shrouded key structure. supports only pkcs8 shrouding + * currently. + */ +struct SEC_PKCS12ESPVKItemStr { + PLArenaPool *poolp; /* used locally */ + SECOidData *espvkTag; /* used locally */ + SECItem espvkOID; + SEC_PKCS12PVKSupportingData espvkData; + union { + SECKEYEncryptedPrivateKeyInfo *pkcs8KeyShroud; + } espvkCipherText; + + PRBool duplicate; /* used locally */ + PRBool problem_cert; /* used locally */ + PRBool single_cert; /* used locally */ + int nCerts; /* used locally */ + SECItem derCert; /* used locally */ +}; + +/* generic bag store for the safe. safeBagType identifies + * the type of bag stored. + */ +struct SEC_PKCS12SafeBagStr { + PLArenaPool *poolp; + SECOidData *safeBagTypeTag; /* used locally */ + SECItem safeBagType; + union { + SEC_PKCS12PrivateKeyBag *keyBag; + SEC_PKCS12CertAndCRLBag *certAndCRLBag; + SEC_PKCS12SecretBag *secretBag; + } safeContent; + + SECItem derSafeContent; + SECItem safeBagName; + + SECItem uniSafeBagName; +}; + +/* stores private keys and certificates in a list. each safebag + * has an ID identifying the type of content stored. + */ +struct SEC_PKCS12SafeContentsStr { + PLArenaPool *poolp; + SEC_PKCS12SafeBag **contents; + + /* used for tracking purposes */ + int safe_size; + PRBool old; + PRBool swapUnicode; + PRBool possibleSwapUnicode; +}; + +/* private key structure which holds encrypted private key and + * supporting data including nickname and certificate thumbprint. + */ +struct SEC_PKCS12PrivateKeyStr { + PLArenaPool *poolp; + SEC_PKCS12PVKSupportingData pvkData; + SECKEYPrivateKeyInfo pkcs8data; /* borrowed from PKCS 8 */ + + PRBool duplicate; /* used locally */ + PRBool problem_cert; /* used locally */ + PRBool single_cert; /* used locally */ + int nCerts; /* used locally */ + SECItem derCert; /* used locally */ +}; + +/* private key bag, holds a (null terminated) list of private key + * structures. + */ +struct SEC_PKCS12PrivateKeyBagStr { + PLArenaPool *poolp; + SEC_PKCS12PrivateKey **privateKeys; + + int bag_size; /* used locally */ +}; + +/* container to hold certificates. currently supports x509 + * and sdsi certificates + */ +struct SEC_PKCS12CertAndCRLStr { + PLArenaPool *poolp; + SECOidData *BagTypeTag; /* used locally */ + SECItem BagID; + union { + SEC_PKCS12X509CertCRL *x509; + SEC_PKCS12SDSICert *sdsi; + } value; + + SECItem derValue; + SECItem nickname; /* used locally */ + PRBool duplicate; /* used locally */ +}; + +/* x509 certificate structure. typically holds the der encoding + * of the x509 certificate. thumbprint contains a digest of the + * certificate + */ +struct SEC_PKCS12X509CertCRLStr { + PLArenaPool *poolp; + SEC_PKCS7ContentInfo certOrCRL; + SGNDigestInfo thumbprint; + + SECItem *derLeafCert; /* used locally */ +}; + +/* sdsi certificate structure. typically holds the der encoding + * of the sdsi certificate. thumbprint contains a digest of the + * certificate + */ +struct SEC_PKCS12SDSICertStr { + PLArenaPool *poolp; + SECItem value; + SGNDigestInfo thumbprint; +}; + +/* contains a null terminated list of certs and crls */ +struct SEC_PKCS12CertAndCRLBagStr { + PLArenaPool *poolp; + SEC_PKCS12CertAndCRL **certAndCRLs; + + int bag_size; /* used locally */ +}; + +/* additional secret information. currently no information + * stored in this structure. + */ +struct SEC_PKCS12SecretAdditionalStr { + PLArenaPool *poolp; + SECOidData *secretTypeTag; /* used locally */ + SECItem secretAdditionalType; + SECItem secretAdditionalContent; +}; + +/* secrets container. this will be used to contain currently + * unspecified secrets. (it's a secret) + */ +struct SEC_PKCS12SecretStr { + PLArenaPool *poolp; + SECItem secretName; + SECItem value; + SEC_PKCS12SecretAdditional secretAdditional; + + SECItem uniSecretName; +}; + +struct SEC_PKCS12SecretItemStr { + PLArenaPool *poolp; + SEC_PKCS12Secret secret; + SEC_PKCS12SafeBag subFolder; +}; + +/* a bag of secrets. holds a null terminated list of secrets. + */ +struct SEC_PKCS12SecretBagStr { + PLArenaPool *poolp; + SEC_PKCS12SecretItem **secrets; + + int bag_size; /* used locally */ +}; + +struct SEC_PKCS12MacDataStr { + SGNDigestInfo safeMac; + SECItem macSalt; +}; + +/* outer transfer unit */ +struct SEC_PKCS12PFXItemStr { + PLArenaPool *poolp; + SEC_PKCS12MacData macData; + SEC_PKCS7ContentInfo authSafe; + + /* for compatibility with beta */ + PRBool old; + SGNDigestInfo old_safeMac; + SECItem old_macSalt; + + /* compatibility between platforms for unicode swapping */ + PRBool swapUnicode; +}; + +struct SEC_PKCS12BaggageItemStr { + PLArenaPool *poolp; + SEC_PKCS12ESPVKItem **espvks; + SEC_PKCS12SafeBag **unencSecrets; + + int nEspvks; + int nSecrets; +}; + +/* stores shrouded keys */ +struct SEC_PKCS12Baggage_OLDStr { + PLArenaPool *poolp; + SEC_PKCS12ESPVKItem **espvks; + + int luggage_size; /* used locally */ +}; + +/* authenticated safe, stores certs, keys, and shrouded keys */ +struct SEC_PKCS12AuthenticatedSafeStr { + PLArenaPool *poolp; + SECItem version; + SECOidData *transportTypeTag; /* local not part of encoding*/ + SECItem transportMode; + SECItem privacySalt; + SEC_PKCS12Baggage baggage; + SEC_PKCS7ContentInfo *safe; + + /* used for beta compatibility */ + PRBool old; + PRBool emptySafe; + SEC_PKCS12Baggage_OLD old_baggage; + SEC_PKCS7ContentInfo old_safe; + PRBool swapUnicode; +}; +#define SEC_PKCS12_PFX_VERSION 1 /* what we create */ + +/* PKCS 12 Templates */ +extern const SEC_ASN1Template SEC_PKCS12PFXItemTemplate_OLD[]; +extern const SEC_ASN1Template SEC_PKCS12AuthenticatedSafeTemplate_OLD[]; +extern const SEC_ASN1Template SEC_PKCS12BaggageTemplate_OLD[]; +extern const SEC_ASN1Template SEC_PKCS12PFXItemTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12MacDataTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12AuthenticatedSafeTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12BaggageTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12ESPVKItemTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12PVKSupportingDataTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12PVKAdditionalTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12SafeContentsTemplate_OLD[]; +extern const SEC_ASN1Template SEC_PKCS12SafeContentsTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12SafeBagTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12PrivateKeyTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12PrivateKeyBagTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12CertAndCRLTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12CertAndCRLBagTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12X509CertCRLTemplate_OLD[]; +extern const SEC_ASN1Template SEC_PKCS12X509CertCRLTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12SDSICertTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12SecretBagTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12SecretTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12SecretItemTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12SecretAdditionalTemplate[]; +extern const SEC_ASN1Template SGN_DigestInfoTemplate[]; +extern const SEC_ASN1Template SEC_PointerToPKCS12KeyBagTemplate[]; +extern const SEC_ASN1Template SEC_PointerToPKCS12CertAndCRLBagTemplate[]; +extern const SEC_ASN1Template SEC_PointerToPKCS12CertAndCRLBagTemplate_OLD[]; +extern const SEC_ASN1Template SEC_PointerToPKCS12SecretBagTemplate[]; +extern const SEC_ASN1Template SEC_PointerToPKCS12X509CertCRLTemplate_OLD[]; +extern const SEC_ASN1Template SEC_PointerToPKCS12X509CertCRLTemplate[]; +extern const SEC_ASN1Template SEC_PointerToPKCS12SDSICertTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12CodedSafeBagTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12CodedCertBagTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12CodedCertAndCRLBagTemplate[]; +extern const SEC_ASN1Template SEC_PKCS12PVKSupportingDataTemplate_OLD[]; +extern const SEC_ASN1Template SEC_PKCS12ESPVKItemTemplate_OLD[]; +#endif diff --git a/illumos-x86_64/usr/include/mps/pkcs1sig.h b/illumos-x86_64/usr/include/mps/pkcs1sig.h new file mode 100644 index 00000000..7c52b157 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs1sig.h @@ -0,0 +1,30 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _PKCS1SIG_H_ +#define _PKCS1SIG_H_ + +#include "hasht.h" +#include "seccomon.h" +#include "secoidt.h" + +/* SGN_VerifyPKCS1DigestInfo verifies that the length of the digest is correct + * for the given algorithm, then verifies that the recovered data from the + * PKCS#1 signature is a properly-formatted DigestInfo that identifies the + * given digest algorithm, then verifies that the digest in the DigestInfo + * matches the given digest. + * + * dataRecoveredFromSignature must be the result of calling PK11_VerifyRecover + * or equivalent. + * + * If unsafeAllowMissingParameters is true (not recommended), then a DigestInfo + * without the mandatory ASN.1 NULL parameter will also be accepted. + */ +SECStatus _SGN_VerifyPKCS1DigestInfo(SECOidTag digestAlg, + const SECItem* digest, + const SECItem* dataRecoveredFromSignature, + PRBool unsafeAllowMissingParameters); + +#endif /* _PKCS1SIG_H_ */ diff --git a/illumos-x86_64/usr/include/mps/pkcs7t.h b/illumos-x86_64/usr/include/mps/pkcs7t.h new file mode 100644 index 00000000..4ef89027 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pkcs7t.h @@ -0,0 +1,233 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Header for pkcs7 types. + */ + +#ifndef _PKCS7T_H_ +#define _PKCS7T_H_ + +#include "plarena.h" + +#include "seccomon.h" +#include "secoidt.h" +#include "certt.h" +#include "secmodt.h" + +/* Opaque objects */ +typedef struct SEC_PKCS7DecoderContextStr SEC_PKCS7DecoderContext; +typedef struct SEC_PKCS7EncoderContextStr SEC_PKCS7EncoderContext; + +/* legacy defines that haven't been active for years */ +typedef void *(*SECKEYGetPasswordKey)(void *arg, void *handle); + +/* Non-opaque objects. NOTE, though: I want them to be treated as + * opaque as much as possible. If I could hide them completely, + * I would. (I tried, but ran into trouble that was taking me too + * much time to get out of.) I still intend to try to do so. + * In fact, the only type that "outsiders" should even *name* is + * SEC_PKCS7ContentInfo, and they should not reference its fields. + */ +/* rjr: PKCS #11 cert handling (pk11cert.c) does use SEC_PKCS7RecipientInfo's. + * This is because when we search the recipient list for the cert and key we + * want, we need to invert the order of the loops we used to have. The old + * loops were: + * + * For each recipient { + * find_cert = PK11_Find_AllCert(recipient->issuerSN); + * [which unrolls to... ] + * For each slot { + * Log into slot; + * search slot for cert; + * } + * } + * + * the new loop searchs all the recipients at once on a slot. this allows + * PKCS #11 to order slots in such a way that logout slots don't get checked + * if we can find the cert on a logged in slot. This eliminates lots of + * spurious password prompts when smart cards are installed... so why this + * comment? If you make SEC_PKCS7RecipientInfo completely opaque, you need + * to provide a non-opaque list of issuerSN's (the only field PKCS#11 needs + * and fix up pk11cert.c first. NOTE: Only S/MIME calls this special PKCS #11 + * function. + */ +typedef struct SEC_PKCS7ContentInfoStr SEC_PKCS7ContentInfo; +typedef struct SEC_PKCS7SignedDataStr SEC_PKCS7SignedData; +typedef struct SEC_PKCS7EncryptedContentInfoStr SEC_PKCS7EncryptedContentInfo; +typedef struct SEC_PKCS7EnvelopedDataStr SEC_PKCS7EnvelopedData; +typedef struct SEC_PKCS7SignedAndEnvelopedDataStr + SEC_PKCS7SignedAndEnvelopedData; +typedef struct SEC_PKCS7SignerInfoStr SEC_PKCS7SignerInfo; +typedef struct SEC_PKCS7RecipientInfoStr SEC_PKCS7RecipientInfo; +typedef struct SEC_PKCS7DigestedDataStr SEC_PKCS7DigestedData; +typedef struct SEC_PKCS7EncryptedDataStr SEC_PKCS7EncryptedData; +/* + * The following is not actually a PKCS7 type, but for now it is only + * used by PKCS7, so we have adopted it. If someone else *ever* needs + * it, its name should be changed and it should be moved out of here. + * Do not dare to use it without doing so! + */ +typedef struct SEC_PKCS7AttributeStr SEC_PKCS7Attribute; + +struct SEC_PKCS7ContentInfoStr { + PLArenaPool *poolp; /* local; not part of encoding */ + PRBool created; /* local; not part of encoding */ + int refCount; /* local; not part of encoding */ + SECOidData *contentTypeTag; /* local; not part of encoding */ + SECKEYGetPasswordKey pwfn; /* local; not part of encoding */ + void *pwfn_arg; /* local; not part of encoding */ + SECItem contentType; + union { + SECItem *data; + SEC_PKCS7DigestedData *digestedData; + SEC_PKCS7EncryptedData *encryptedData; + SEC_PKCS7EnvelopedData *envelopedData; + SEC_PKCS7SignedData *signedData; + SEC_PKCS7SignedAndEnvelopedData *signedAndEnvelopedData; + } content; +}; + +struct SEC_PKCS7SignedDataStr { + SECItem version; + SECAlgorithmID **digestAlgorithms; + SEC_PKCS7ContentInfo contentInfo; + SECItem **rawCerts; + CERTSignedCrl **crls; + SEC_PKCS7SignerInfo **signerInfos; + SECItem **digests; /* local; not part of encoding */ + CERTCertificate **certs; /* local; not part of encoding */ + CERTCertificateList **certLists; /* local; not part of encoding */ +}; +#define SEC_PKCS7_SIGNED_DATA_VERSION 1 /* what we *create* */ + +struct SEC_PKCS7EncryptedContentInfoStr { + SECOidData *contentTypeTag; /* local; not part of encoding */ + SECItem contentType; + SECAlgorithmID contentEncAlg; + SECItem encContent; + SECItem plainContent; /* local; not part of encoding */ + /* bytes not encrypted, but encoded */ + int keysize; /* local; not part of encoding */ + /* size of bulk encryption key + * (only used by creation code) */ + SECOidTag encalg; /* local; not part of encoding */ + /* oid tag of encryption algorithm + * (only used by creation code) */ +}; + +struct SEC_PKCS7EnvelopedDataStr { + SECItem version; + SEC_PKCS7RecipientInfo **recipientInfos; + SEC_PKCS7EncryptedContentInfo encContentInfo; +}; +#define SEC_PKCS7_ENVELOPED_DATA_VERSION 0 /* what we *create* */ + +struct SEC_PKCS7SignedAndEnvelopedDataStr { + SECItem version; + SEC_PKCS7RecipientInfo **recipientInfos; + SECAlgorithmID **digestAlgorithms; + SEC_PKCS7EncryptedContentInfo encContentInfo; + SECItem **rawCerts; + CERTSignedCrl **crls; + SEC_PKCS7SignerInfo **signerInfos; + SECItem **digests; /* local; not part of encoding */ + CERTCertificate **certs; /* local; not part of encoding */ + CERTCertificateList **certLists; /* local; not part of encoding */ + PK11SymKey *sigKey; /* local; not part of encoding */ +}; +#define SEC_PKCS7_SIGNED_AND_ENVELOPED_DATA_VERSION 1 /* what we *create* */ + +struct SEC_PKCS7SignerInfoStr { + SECItem version; + CERTIssuerAndSN *issuerAndSN; + SECAlgorithmID digestAlg; + SEC_PKCS7Attribute **authAttr; + SECAlgorithmID digestEncAlg; + SECItem encDigest; + SEC_PKCS7Attribute **unAuthAttr; + CERTCertificate *cert; /* local; not part of encoding */ + CERTCertificateList *certList; /* local; not part of encoding */ +}; +#define SEC_PKCS7_SIGNER_INFO_VERSION 1 /* what we *create* */ + +struct SEC_PKCS7RecipientInfoStr { + SECItem version; + CERTIssuerAndSN *issuerAndSN; + SECAlgorithmID keyEncAlg; + SECItem encKey; + CERTCertificate *cert; /* local; not part of encoding */ +}; +#define SEC_PKCS7_RECIPIENT_INFO_VERSION 0 /* what we *create* */ + +struct SEC_PKCS7DigestedDataStr { + SECItem version; + SECAlgorithmID digestAlg; + SEC_PKCS7ContentInfo contentInfo; + SECItem digest; +}; +#define SEC_PKCS7_DIGESTED_DATA_VERSION 0 /* what we *create* */ + +struct SEC_PKCS7EncryptedDataStr { + SECItem version; + SEC_PKCS7EncryptedContentInfo encContentInfo; +}; +#define SEC_PKCS7_ENCRYPTED_DATA_VERSION 0 /* what we *create* */ + +/* + * See comment above about this type not really belonging to PKCS7. + */ +struct SEC_PKCS7AttributeStr { + /* The following fields make up an encoded Attribute: */ + SECItem type; + SECItem **values; /* data may or may not be encoded */ + /* The following fields are not part of an encoded Attribute: */ + SECOidData *typeTag; + PRBool encoded; /* when true, values are encoded */ +}; + +/* + * Type of function passed to SEC_PKCS7Decode or SEC_PKCS7DecoderStart. + * If specified, this is where the content bytes (only) will be "sent" + * as they are recovered during the decoding. + * + * XXX Should just combine this with SEC_PKCS7EncoderContentCallback type + * and use a simpler, common name. + */ +typedef void (*SEC_PKCS7DecoderContentCallback)(void *arg, + const char *buf, + unsigned long len); + +/* + * Type of function passed to SEC_PKCS7Encode or SEC_PKCS7EncoderStart. + * This is where the encoded bytes will be "sent". + * + * XXX Should just combine this with SEC_PKCS7DecoderContentCallback type + * and use a simpler, common name. + */ +typedef void (*SEC_PKCS7EncoderOutputCallback)(void *arg, + const char *buf, + unsigned long len); + +/* + * Type of function passed to SEC_PKCS7Decode or SEC_PKCS7DecoderStart + * to retrieve the decryption key. This function is inteded to be + * used for EncryptedData content info's which do not have a key available + * in a certificate, etc. + */ +typedef PK11SymKey *(*SEC_PKCS7GetDecryptKeyCallback)(void *arg, + SECAlgorithmID *algid); + +/* + * Type of function passed to SEC_PKCS7Decode or SEC_PKCS7DecoderStart. + * This function in intended to be used to verify that decrypting a + * particular crypto algorithm is allowed. Content types which do not + * require decryption will not need the callback. If the callback + * is not specified for content types which require decryption, the + * decryption will be disallowed. + */ +typedef PRBool (*SEC_PKCS7DecryptionAllowedCallback)(SECAlgorithmID *algid, + PK11SymKey *bulkkey); + +#endif /* _PKCS7T_H_ */ diff --git a/illumos-x86_64/usr/include/mps/plarena.h b/illumos-x86_64/usr/include/mps/plarena.h new file mode 100644 index 00000000..0ca00c0a --- /dev/null +++ b/illumos-x86_64/usr/include/mps/plarena.h @@ -0,0 +1,338 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef plarena_h___ +#define plarena_h___ +/* + * Lifetime-based fast allocation, inspired by much prior art, including + * "Fast Allocation and Deallocation of Memory Based on Object Lifetimes" + * David R. Hanson, Software -- Practice and Experience, Vol. 20(1). + * + * Also supports LIFO allocation (PL_ARENA_MARK/PL_ARENA_RELEASE). + */ +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +typedef struct PLArena PLArena; + +struct PLArena { + PLArena *next; /* next arena for this lifetime */ + PRUword base; /* aligned base address, follows this header */ + PRUword limit; /* one beyond last byte in arena */ + PRUword avail; /* points to next available byte */ +}; + +#ifdef PL_ARENAMETER +typedef struct PLArenaStats PLArenaStats; + +struct PLArenaStats { + PLArenaStats *next; /* next in arenaStats list */ + char *name; /* name for debugging */ + PRUint32 narenas; /* number of arenas in pool */ + PRUint32 nallocs; /* number of PL_ARENA_ALLOCATE() calls */ + PRUint32 nreclaims; /* number of reclaims from freeArenas */ + PRUint32 nmallocs; /* number of malloc() calls */ + PRUint32 ndeallocs; /* number of lifetime deallocations */ + PRUint32 ngrows; /* number of PL_ARENA_GROW() calls */ + PRUint32 ninplace; /* number of in-place growths */ + PRUint32 nreleases; /* number of PL_ARENA_RELEASE() calls */ + PRUint32 nfastrels; /* number of "fast path" releases */ + PRUint32 nbytes; /* total bytes allocated */ + PRUint32 maxalloc; /* maximum allocation size in bytes */ + PRFloat64 variance; /* size variance accumulator */ +}; +#endif + +typedef struct PLArenaPool PLArenaPool; + +struct PLArenaPool { + PLArena first; /* first arena in pool list */ + PLArena *current; /* arena from which to allocate space */ + PRUint32 arenasize; /* net exact size of a new arena */ + PRUword mask; /* alignment mask (power-of-2 - 1) */ +#ifdef PL_ARENAMETER + PLArenaStats stats; +#endif +}; + +/* + * WARNING: The PL_MAKE_MEM_ macros are for internal use by NSPR. Do NOT use + * them in your code. + * + * NOTE: Valgrind support to be added. + * + * The PL_MAKE_MEM_ macros are modeled after the MOZ_MAKE_MEM_ macros in + * Mozilla's mfbt/MemoryChecking.h. Only AddressSanitizer is supported now. + * + * Provides a common interface to the ASan (AddressSanitizer) and Valgrind + * functions used to mark memory in certain ways. In detail, the following + * three macros are provided: + * + * PL_MAKE_MEM_NOACCESS - Mark memory as unsafe to access (e.g. freed) + * PL_MAKE_MEM_UNDEFINED - Mark memory as accessible, with content undefined + * PL_MAKE_MEM_DEFINED - Mark memory as accessible, with content defined + * + * With Valgrind in use, these directly map to the three respective Valgrind + * macros. With ASan in use, the NOACCESS macro maps to poisoning the memory, + * while the UNDEFINED/DEFINED macros unpoison memory. + * + * With no memory checker available, all macros expand to the empty statement. + */ + +/* WARNING: PL_SANITIZE_ADDRESS is for internal use by this header. Do NOT + * define or test this macro in your code. + */ +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define PL_SANITIZE_ADDRESS 1 +#endif +#elif defined(__SANITIZE_ADDRESS__) +#define PL_SANITIZE_ADDRESS 1 +#endif + +#if defined(PL_SANITIZE_ADDRESS) + +#if defined(_MSC_VER) +/* We can't use dllimport due to DLL linkage mismatch with + * sanitizer/asan_interface.h. + */ +#define PL_ASAN_VISIBILITY(type_) type_ +#else +#define PL_ASAN_VISIBILITY(type_) PR_IMPORT(type_) +#endif + +/* These definitions are usually provided through the + * sanitizer/asan_interface.h header installed by ASan. + * See https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning + */ + +PL_ASAN_VISIBILITY(void) __asan_poison_memory_region( + void const volatile *addr, size_t size); +PL_ASAN_VISIBILITY(void) __asan_unpoison_memory_region( + void const volatile *addr, size_t size); + +#define PL_MAKE_MEM_NOACCESS(addr, size) \ + __asan_poison_memory_region((addr), (size)) + +#define PL_MAKE_MEM_UNDEFINED(addr, size) \ + __asan_unpoison_memory_region((addr), (size)) + +#define PL_MAKE_MEM_DEFINED(addr, size) \ + __asan_unpoison_memory_region((addr), (size)) + +#else + +#define PL_MAKE_MEM_NOACCESS(addr, size) +#define PL_MAKE_MEM_UNDEFINED(addr, size) +#define PL_MAKE_MEM_DEFINED(addr, size) + +#endif + +/* + * If the including .c file uses only one power-of-2 alignment, it may define + * PL_ARENA_CONST_ALIGN_MASK to the alignment mask and save a few instructions + * per ALLOCATE and GROW. + */ +#ifdef PL_ARENA_CONST_ALIGN_MASK +#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + PL_ARENA_CONST_ALIGN_MASK) \ + & ~PL_ARENA_CONST_ALIGN_MASK) + +#define PL_INIT_ARENA_POOL(pool, name, size) \ + PL_InitArenaPool(pool, name, size, PL_ARENA_CONST_ALIGN_MASK + 1) +#else +#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + (pool)->mask) & ~(pool)->mask) +#endif + +#define PL_ARENA_ALLOCATE(p, pool, nb) \ + PR_BEGIN_MACRO \ + PLArena *_a = (pool)->current; \ + PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \ + PRUword _p = _a->avail; \ + if (_nb < (PRUint32)nb) { \ + _p = 0; \ + } else if (_nb > (_a->limit - _a->avail)) { \ + _p = (PRUword)PL_ArenaAllocate(pool, _nb); \ + } else { \ + _a->avail += _nb; \ + } \ + p = (void *)_p; \ + if (p) { \ + PL_MAKE_MEM_UNDEFINED(p, (PRUint32)nb); \ + PL_ArenaCountAllocation(pool, (PRUint32)nb); \ + } \ + PR_END_MACRO + +#define PL_ARENA_GROW(p, pool, size, incr) \ + PR_BEGIN_MACRO \ + PLArena *_a = (pool)->current; \ + PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \ + if (_incr < (PRUint32)incr) { \ + p = NULL; \ + } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \ + _incr <= (_a->limit - _a->avail)) { \ + PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, (PRUint32)incr); \ + _a->avail += _incr; \ + PL_ArenaCountInplaceGrowth(pool, size, (PRUint32)incr); \ + } else { \ + p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \ + } \ + if (p) {\ + PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \ + } \ + PR_END_MACRO + +#define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail) +#define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q)) + +#define PL_CLEAR_UNUSED_PATTERN(a, pattern) \ + PR_BEGIN_MACRO \ + PR_ASSERT((a)->avail <= (a)->limit); \ + PL_MAKE_MEM_UNDEFINED((void*)(a)->avail, (a)->limit - (a)->avail); \ + memset((void*)(a)->avail, (pattern), (a)->limit - (a)->avail); \ + PR_END_MACRO +#ifdef DEBUG +#define PL_FREE_PATTERN 0xDA +#define PL_CLEAR_UNUSED(a) PL_CLEAR_UNUSED_PATTERN((a), PL_FREE_PATTERN) +#define PL_CLEAR_ARENA(a) \ + PR_BEGIN_MACRO \ + PL_MAKE_MEM_UNDEFINED((void*)(a), (a)->limit - (PRUword)(a)); \ + memset((void*)(a), PL_FREE_PATTERN, (a)->limit - (PRUword)(a)); \ + PR_END_MACRO +#else +#define PL_CLEAR_UNUSED(a) +#define PL_CLEAR_ARENA(a) +#endif + +#define PL_ARENA_RELEASE(pool, mark) \ + PR_BEGIN_MACRO \ + char *_m = (char *)(mark); \ + PLArena *_a = (pool)->current; \ + if (PR_UPTRDIFF(_m, _a->base) <= PR_UPTRDIFF(_a->avail, _a->base)) { \ + _a->avail = (PRUword)PL_ARENA_ALIGN(pool, _m); \ + PL_CLEAR_UNUSED(_a); \ + PL_MAKE_MEM_NOACCESS((void*)_a->avail, _a->limit - _a->avail); \ + PL_ArenaCountRetract(pool, _m); \ + } else { \ + PL_ArenaRelease(pool, _m); \ + } \ + PL_ArenaCountRelease(pool, _m); \ + PR_END_MACRO + +#ifdef PL_ARENAMETER +#define PL_COUNT_ARENA(pool,op) ((pool)->stats.narenas op) +#else +#define PL_COUNT_ARENA(pool,op) +#endif + +#define PL_ARENA_DESTROY(pool, a, pnext) \ + PR_BEGIN_MACRO \ + PL_COUNT_ARENA(pool,--); \ + if ((pool)->current == (a)) (pool)->current = &(pool)->first; \ + *(pnext) = (a)->next; \ + PL_CLEAR_ARENA(a); \ + free(a); \ + (a) = 0; \ + PR_END_MACRO + +/* +** Initialize an arena pool with the given name for debugging and metering, +** with a minimum gross size per arena of size bytes. The net size per arena +** is smaller than the gross size by a header of four pointers plus any +** necessary padding for alignment. +** +** Note: choose a gross size that's a power of two to avoid the heap allocator +** rounding the size up. +**/ +PR_EXTERN(void) PL_InitArenaPool( + PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align); + +/* +** Finish using arenas, freeing all memory associated with them. +** NOTE: this function is now a no-op. If you want to free a single +** PLArenaPoolUse use PL_FreeArenaPool() or PL_FinishArenaPool(). +**/ +PR_EXTERN(void) PL_ArenaFinish(void); + +/* +** Free the arenas in pool. The user may continue to allocate from pool +** after calling this function. There is no need to call PL_InitArenaPool() +** again unless PL_FinishArenaPool(pool) has been called. +**/ +PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool); + +/* +** Free the arenas in pool and finish using it altogether. +**/ +PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool); + +/* +** Compact all of the arenas in a pool so that no space is wasted. +** NOT IMPLEMENTED. Do not use. +**/ +PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool); + +/* +** Friend functions used by the PL_ARENA_*() macros. +** +** WARNING: do not call these functions directly. Always use the +** PL_ARENA_*() macros. +**/ +PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb); + +PR_EXTERN(void *) PL_ArenaGrow( + PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr); + +PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark); + +/* +** memset contents of all arenas in pool to pattern +*/ +PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern); + +/* +** A function like malloc_size() or malloc_usable_size() that measures the +** size of a heap block. +*/ +typedef size_t (*PLMallocSizeFn)(const void *ptr); + +/* +** Measure all memory used by a PLArenaPool, excluding the PLArenaPool +** structure. +*/ +PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool( + const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf); + +#ifdef PL_ARENAMETER + +#include + +PR_EXTERN(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb); + +PR_EXTERN(void) PL_ArenaCountInplaceGrowth( + PLArenaPool *pool, PRUint32 size, PRUint32 incr); + +PR_EXTERN(void) PL_ArenaCountGrowth( + PLArenaPool *pool, PRUint32 size, PRUint32 incr); + +PR_EXTERN(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark); + +PR_EXTERN(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark); + +PR_EXTERN(void) PL_DumpArenaStats(FILE *fp); + +#else /* !PL_ARENAMETER */ + +#define PL_ArenaCountAllocation(ap, nb) /* nothing */ +#define PL_ArenaCountInplaceGrowth(ap, size, incr) /* nothing */ +#define PL_ArenaCountGrowth(ap, size, incr) /* nothing */ +#define PL_ArenaCountRelease(ap, mark) /* nothing */ +#define PL_ArenaCountRetract(ap, mark) /* nothing */ + +#endif /* !PL_ARENAMETER */ + +PR_END_EXTERN_C + +#endif /* plarena_h___ */ diff --git a/illumos-x86_64/usr/include/mps/plarenas.h b/illumos-x86_64/usr/include/mps/plarenas.h new file mode 100644 index 00000000..4a0f5a8d --- /dev/null +++ b/illumos-x86_64/usr/include/mps/plarenas.h @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** PLArena-related declarations used to be split between plarenas.h and +** plarena.h. That split wasn't useful, so now all the declarations are in +** plarena.h. However, this file still exists so that any old code that +** includes it will still work. +**/ +#include "plarena.h" diff --git a/illumos-x86_64/usr/include/mps/plbase64.h b/illumos-x86_64/usr/include/mps/plbase64.h new file mode 100644 index 00000000..8f2117cc --- /dev/null +++ b/illumos-x86_64/usr/include/mps/plbase64.h @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _plbase64_h +#define _plbase64_h + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* + * PL_Base64Encode + * + * This routine encodes the data pointed to by the "src" parameter using the + * base64 algorithm, and returns a pointer to the result. If the "srclen" + * parameter is not zero, it specifies the length of the source data. If it + * is zero, the source data is assumed to be null-terminated, and PL_strlen + * is used to determine the source length. If the "dest" parameter is not + * null, it is assumed to point to a buffer of sufficient size (which may be + * calculated: ((srclen + 2)/3)*4) into which the encoded data is placed + * (without any termination). If the "dest" parameter is null, a buffer is + * allocated from the heap to hold the encoded data, and the result *will* + * be terminated with an extra null character. It is the caller's + * responsibility to free the result when it is allocated. A null is returned + * if the allocation fails. + * + * NOTE: when calculating ((srclen + 2)/3)*4), first ensure that + * srclen <= (PR_UINT32_MAX/4) * 3 + * to avoid PRUint32 overflow. + */ + +PR_EXTERN(char *) +PL_Base64Encode +( + const char *src, + PRUint32 srclen, + char *dest +); + +/* + * PL_Base64Decode + * + * This routine decodes the data pointed to by the "src" parameter using + * the base64 algorithm, and returns a pointer to the result. The source + * may either include or exclude any trailing '=' characters. If the + * "srclen" parameter is not zero, it specifies the length of the source + * data. If it is zero, PL_strlen will be used to determine the source + * length. If the "dest" parameter is not null, it is assumed to point to + * a buffer of sufficient size (which may be calculated: (srclen * 3)/4 + * when srclen includes the '=' characters) into which the decoded data + * is placed (without any termination). If the "dest" parameter is null, + * a buffer is allocated from the heap to hold the decoded data, and the + * result *will* be terminated with an extra null character. It is the + * caller's responsibility to free the result when it is allocated. A null + * is retuned if the allocation fails, or if the source is not well-coded. + * + * NOTE: when calculating (srclen * 3)/4, first ensure that + * srclen <= PR_UINT32_MAX/3 + * to avoid PRUint32 overflow. Alternatively, calculate + * (srclen/4) * 3 + ((srclen%4) * 3)/4 + * which is equivalent but doesn't overflow for any value of srclen. + */ + +PR_EXTERN(char *) +PL_Base64Decode +( + const char *src, + PRUint32 srclen, + char *dest +); + +PR_END_EXTERN_C + +#endif /* _plbase64_h */ diff --git a/illumos-x86_64/usr/include/mps/plerror.h b/illumos-x86_64/usr/include/mps/plerror.h new file mode 100644 index 00000000..cd85dd3f --- /dev/null +++ b/illumos-x86_64/usr/include/mps/plerror.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: plerror.h +** Description: Simple routine to print translate the calling thread's +** error numbers and print them. +*/ + +#if defined(PLERROR_H) +#else +#define PLERROR_H + +#include "prio.h" +#include "prtypes.h" + +PR_BEGIN_EXTERN_C +/* +** Print the messages to "syserr" prepending 'msg' if not NULL. +*/ +PR_EXTERN(void) PL_PrintError(const char *msg); + +/* +** Print the messages to specified output file prepending 'msg' if not NULL. +*/ +PR_EXTERN(void) PL_FPrintError(PRFileDesc *output, const char *msg); + +PR_END_EXTERN_C + +#endif /* defined(PLERROR_H) */ + +/* plerror.h */ diff --git a/illumos-x86_64/usr/include/mps/plgetopt.h b/illumos-x86_64/usr/include/mps/plgetopt.h new file mode 100644 index 00000000..bd5181b1 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/plgetopt.h @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: plgetopt.h +** Description: utilities to parse argc/argv +*/ + +#if defined(PLGETOPT_H_) +#else +#define PLGETOPT_H_ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +typedef struct PLOptionInternal PLOptionInternal; + +typedef enum +{ + PL_OPT_OK, /* all's well with the option */ + PL_OPT_EOL, /* end of options list */ + PL_OPT_BAD /* invalid option (and value) */ +} PLOptStatus; + +typedef struct PLLongOpt +{ + const char * longOptName; /* long option name string */ + PRIntn longOption; /* value put in PLOptState for this option. */ + PRBool valueRequired; /* If option name not followed by '=', */ + /* value is the next argument from argv. */ +} PLLongOpt; + +typedef struct PLOptState +{ + char option; /* the name of the option */ + const char *value; /* the value of that option | NULL */ + + PLOptionInternal *internal; /* private processing state */ + + PRIntn longOption; /* value from PLLongOpt put here */ + PRIntn longOptIndex; /* index into caller's array of PLLongOpts */ +} PLOptState; + +/* + * PL_CreateOptState + * + * The argument "options" points to a string of single-character option + * names. Option names that may have an option argument value must be + * followed immediately by a ':' character. + */ +PR_EXTERN(PLOptState*) PL_CreateOptState( + PRIntn argc, char **argv, const char *options); + +/* + * PL_CreateLongOptState + * + * Alternative to PL_CreateOptState. + * Allows caller to specify BOTH a string of single-character option names, + * AND an array of structures describing "long" (keyword) option names. + * The array is terminated by a structure in which longOptName is NULL. + * Long option values (arguments) may always be given as "--name=value". + * If PLLongOpt.valueRequired is not PR_FALSE, and the option name was not + * followed by '=' then the next argument from argv is taken as the value. + */ +PR_EXTERN(PLOptState*) PL_CreateLongOptState( + PRIntn argc, char **argv, const char *options, + const PLLongOpt *longOpts); +/* + * PL_DestroyOptState + * + * Call this to destroy the PLOptState returned from PL_CreateOptState or + * PL_CreateLongOptState. + */ +PR_EXTERN(void) PL_DestroyOptState(PLOptState *opt); + +/* + * PL_GetNextOpt + * + * When this function returns PL_OPT_OK, + * - opt->option will hold the single-character option name that was parsed, + * or zero. + * When opt->option is zero, the token parsed was either a "long" (keyword) + * option or a positional parameter. + * For a positional parameter, + * - opt->longOptIndex will contain -1, and + * - opt->value will point to the positional parameter string. + * For a long option name, + * - opt->longOptIndex will contain the non-negative index of the + * PLLongOpt structure in the caller's array of PLLongOpt structures + * corresponding to the long option name, and + * For a single-character or long option, + * - opt->longOption will contain the value of the single-character option + * name, or the value of the longOption from the PLLongOpt structure + * for that long option. See notes below. + * - opt->value will point to the argument option string, or will + * be NULL if option does not require argument. If option requires + * argument but it is not provided, PL_OPT_BAD is returned. + * When opt->option is non-zero, + * - opt->longOptIndex will be -1 + * When this function returns PL_OPT_EOL, or PL_OPT_BAD, the contents of + * opt are undefined. + * + * Notes: It is possible to ignore opt->option, and always look at + * opt->longOption instead. opt->longOption will contain the same value + * as opt->option for single-character option names, and will contain the + * value of longOption from the PLLongOpt structure for long option names. + * This means that it is possible to equivalence long option names to + * single character names by giving the longOption in the PLLongOpt struct + * the same value as the single-character option name. + * For long options that are NOT intended to be equivalent to any single- + * character option, the longOption value should be chosen to not match + * any possible single character name. It might be advisable to choose + * longOption values greater than 0xff for such long options. + */ +PR_EXTERN(PLOptStatus) PL_GetNextOpt(PLOptState *opt); + +PR_END_EXTERN_C + +#endif /* defined(PLGETOPT_H_) */ + +/* plgetopt.h */ + diff --git a/illumos-x86_64/usr/include/mps/plhash.h b/illumos-x86_64/usr/include/mps/plhash.h new file mode 100644 index 00000000..2c221aed --- /dev/null +++ b/illumos-x86_64/usr/include/mps/plhash.h @@ -0,0 +1,126 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef plhash_h___ +#define plhash_h___ +/* + * API to portable hash table code. + */ +#include +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +typedef struct PLHashEntry PLHashEntry; +typedef struct PLHashTable PLHashTable; +typedef PRUint32 PLHashNumber; +#define PL_HASH_BITS 32 /* Number of bits in PLHashNumber */ +typedef PLHashNumber (PR_CALLBACK *PLHashFunction)(const void *key); +typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2); + +typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg); + +/* Flag bits in PLHashEnumerator's return value */ +#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */ +#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */ +#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */ +#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */ + +typedef struct PLHashAllocOps { + void * (PR_CALLBACK *allocTable)(void *pool, PRSize size); + void (PR_CALLBACK *freeTable)(void *pool, void *item); + PLHashEntry * (PR_CALLBACK *allocEntry)(void *pool, const void *key); + void (PR_CALLBACK *freeEntry)(void *pool, PLHashEntry *he, PRUintn flag); +} PLHashAllocOps; + +#define HT_FREE_VALUE 0 /* just free the entry's value */ +#define HT_FREE_ENTRY 1 /* free value and entire entry */ + +struct PLHashEntry { + PLHashEntry *next; /* hash chain linkage */ + PLHashNumber keyHash; /* key hash function result */ + const void *key; /* ptr to opaque key */ + void *value; /* ptr to opaque value */ +}; + +struct PLHashTable { + PLHashEntry **buckets; /* vector of hash buckets */ + PRUint32 nentries; /* number of entries in table */ + PRUint32 shift; /* multiplicative hash shift */ + PLHashFunction keyHash; /* key hash function */ + PLHashComparator keyCompare; /* key comparison function */ + PLHashComparator valueCompare; /* value comparison function */ + const PLHashAllocOps *allocOps; /* allocation operations */ + void *allocPriv; /* allocation private data */ +#ifdef HASHMETER + PRUint32 nlookups; /* total number of lookups */ + PRUint32 nsteps; /* number of hash chains traversed */ + PRUint32 ngrows; /* number of table expansions */ + PRUint32 nshrinks; /* number of table contractions */ +#endif +}; + +/* + * Create a new hash table. + * If allocOps is null, use default allocator ops built on top of malloc(). + */ +PR_EXTERN(PLHashTable *) +PL_NewHashTable(PRUint32 numBuckets, PLHashFunction keyHash, + PLHashComparator keyCompare, PLHashComparator valueCompare, + const PLHashAllocOps *allocOps, void *allocPriv); + +PR_EXTERN(void) +PL_HashTableDestroy(PLHashTable *ht); + +/* Higher level access methods */ +PR_EXTERN(PLHashEntry *) +PL_HashTableAdd(PLHashTable *ht, const void *key, void *value); + +PR_EXTERN(PRBool) +PL_HashTableRemove(PLHashTable *ht, const void *key); + +PR_EXTERN(void *) +PL_HashTableLookup(PLHashTable *ht, const void *key); + +PR_EXTERN(void *) +PL_HashTableLookupConst(PLHashTable *ht, const void *key); + +PR_EXTERN(PRIntn) +PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg); + +/* General-purpose C string hash function. */ +PR_EXTERN(PLHashNumber) +PL_HashString(const void *key); + +/* Compare strings using strcmp(), return true if equal. */ +PR_EXTERN(PRIntn) +PL_CompareStrings(const void *v1, const void *v2); + +/* Stub function just returns v1 == v2 */ +PR_EXTERN(PRIntn) +PL_CompareValues(const void *v1, const void *v2); + +/* Low level access methods */ +PR_EXTERN(PLHashEntry **) +PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key); + +PR_EXTERN(PLHashEntry **) +PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash, + const void *key); + +PR_EXTERN(PLHashEntry *) +PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash, + const void *key, void *value); + +PR_EXTERN(void) +PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he); + +/* This can be trivially implemented using PL_HashTableEnumerateEntries. */ +PR_EXTERN(PRIntn) +PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp); + +PR_END_EXTERN_C + +#endif /* plhash_h___ */ diff --git a/illumos-x86_64/usr/include/mps/plstr.h b/illumos-x86_64/usr/include/mps/plstr.h new file mode 100644 index 00000000..ea59832a --- /dev/null +++ b/illumos-x86_64/usr/include/mps/plstr.h @@ -0,0 +1,437 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _plstr_h +#define _plstr_h + +/* + * plstr.h + * + * This header file exports the API to the NSPR portable library or string- + * handling functions. + * + * This API was not designed as an "optimal" or "ideal" string library; it + * was based on the good ol' unix string.3 functions, and was written to + * + * 1) replace the libc functions, for cross-platform consistency, + * 2) complete the API on platforms lacking common functions (e.g., + * strcase*), and + * 3) to implement some obvious "closure" functions that I've seen + * people hacking around in our code. + * + * Point number three largely means that most functions have an "strn" + * limited-length version, and all comparison routines have a non-case- + * sensitive version available. + */ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C +/* + * PL_strlen + * + * Returns the length of the provided string, not including the trailing '\0'. + */ + +PR_EXTERN(PRUint32) +PL_strlen(const char *str); + +/* + * PL_strnlen + * + * Returns the length of the provided string, not including the trailing '\0', + * up to the indicated maximum. The string will not be examined beyond the + * maximum; if no terminating '\0' is found, the maximum will be returned. + */ + +PR_EXTERN(PRUint32) +PL_strnlen(const char *str, PRUint32 max); + +/* + * PL_strcpy + * + * Copies the source string, up to and including the trailing '\0', into the + * destination buffer. It does not (can not) verify that the destination + * buffer is large enough. It returns the "dest" argument. + */ + +PR_EXTERN(char *) +PL_strcpy(char *dest, const char *src); + +/* + * PL_strncpy + * + * Copies the source string into the destination buffer, up to and including + * the trailing '\0' or up to and including the max'th character, whichever + * comes first. It does not (can not) verify that the destination buffer is + * large enough. If the source string is longer than the maximum length, + * the result will *not* be null-terminated (JLRU). + */ + +PR_EXTERN(char *) +PL_strncpy(char *dest, const char *src, PRUint32 max); + +/* + * PL_strncpyz + * + * Copies the source string into the destination buffer, up to and including + * the trailing '\0' or up but not including the max'th character, whichever + * comes first. It does not (can not) verify that the destination buffer is + * large enough. The destination string is always terminated with a '\0', + * unlike the traditional libc implementation. It returns the "dest" argument. + * + * NOTE: If you call this with a source "abcdefg" and a max of 5, the + * destination will end up with "abcd\0" (i.e., its strlen length will be 4)! + * + * This means you can do this: + * + * char buffer[ SOME_SIZE ]; + * PL_strncpyz(buffer, src, sizeof(buffer)); + * + * and the result will be properly terminated. + */ + +PR_EXTERN(char *) +PL_strncpyz(char *dest, const char *src, PRUint32 max); + +/* + * PL_strdup + * + * Returns a pointer to a malloc'd extent of memory containing a duplicate + * of the argument string. The size of the allocated extent is one greater + * than the length of the argument string, because of the terminator. A + * null argument, like a zero-length argument, will result in a pointer to + * a one-byte extent containing the null value. This routine returns null + * upon malloc failure. + */ + +PR_EXTERN(char *) +PL_strdup(const char *s); + +/* + * PL_strfree + * + * Free memory allocated by PL_strdup + */ + +PR_EXTERN(void) +PL_strfree(char *s); + +/* + * PL_strndup + * + * Returns a pointer to a malloc'd extent of memory containing a duplicate + * of the argument string, up to the maximum specified. If the argument + * string has a length greater than the value of the specified maximum, the + * return value will be a pointer to an extent of memory of length one + * greater than the maximum specified. A null string, a zero-length string, + * or a zero maximum will all result in a pointer to a one-byte extent + * containing the null value. This routine returns null upon malloc failure. + */ + +PR_EXTERN(char *) +PL_strndup(const char *s, PRUint32 max); + +/* + * PL_strcat + * + * Appends a copy of the string pointed to by the second argument to the + * end of the string pointed to by the first. The destination buffer is + * not (can not be) checked for sufficient size. A null destination + * argument returns null; otherwise, the first argument is returned. + */ + +PR_EXTERN(char *) +PL_strcat(char *dst, const char *src); + +/* + * PL_strncat + * + * Appends a copy of the string pointed to by the second argument, up to + * the maximum size specified, to the end of the string pointed to by the + * first. The destination buffer is not (can not be) checked for sufficient + * size. A null destination argument returns null; otherwise, the first + * argument is returned. If the maximum size limits the copy, then the + * result will *not* be null-terminated (JLRU). A null destination + * returns null; otherwise, the destination argument is returned. + */ + +PR_EXTERN(char *) +PL_strncat(char *dst, const char *src, PRUint32 max); + +/* + * PL_strcatn + * + * Appends a copy of the string pointed to by the third argument, to the + * end of the string pointed to by the first. The second argument specifies + * the maximum size of the destination buffer, including the null termination. + * If the existing string in dst is longer than the max, no action is taken. + * The resulting string will be null-terminated. A null destination returns + * null; otherwise, the destination argument is returned. + */ + +PR_EXTERN(char *) +PL_strcatn(char *dst, PRUint32 max, const char *src); + +/* + * PL_strcmp + * + * Returns an integer, the sign of which -- positive, zero, or negative -- + * reflects the lexical sorting order of the two strings indicated. The + * result is positive if the first string comes after the second. The + * NSPR implementation is not i18n. + */ + +PR_EXTERN(PRIntn) +PL_strcmp(const char *a, const char *b); + +/* + * PL_strncmp + * + * Returns an integer, the sign of which -- positive, zero, or negative -- + * reflects the lexical sorting order of the two strings indicated, up to + * the maximum specified. The result is positive if the first string comes + * after the second. The NSPR implementation is not i18n. If the maximum + * is zero, only the existance or non-existance (pointer is null) of the + * strings is compared. + */ + +PR_EXTERN(PRIntn) +PL_strncmp(const char *a, const char *b, PRUint32 max); + +/* + * PL_strcasecmp + * + * Returns an integer, the sign of which -- positive, zero or negative -- + * reflects the case-insensitive lexical sorting order of the two strings + * indicated. The result is positive if the first string comes after the + * second. The NSPR implementation is not i18n. + */ + +PR_EXTERN(PRIntn) +PL_strcasecmp(const char *a, const char *b); + +/* + * PL_strncasecmp + * + * Returns an integer, the sign of which -- positive, zero or negative -- + * reflects the case-insensitive lexical sorting order of the first n characters + * of the two strings indicated. The result is positive if the first string comes + * after the second. The NSPR implementation is not i18n. + */ + +PR_EXTERN(PRIntn) +PL_strncasecmp(const char *a, const char *b, PRUint32 max); + +/* + * PL_strchr + * + * Returns a pointer to the first instance of the specified character in the + * provided string. It returns null if the character is not found, or if the + * provided string is null. The character may be the null character. + */ + +PR_EXTERN(char *) +PL_strchr(const char *s, char c); + +/* + * PL_strrchr + * + * Returns a pointer to the last instance of the specified character in the + * provided string. It returns null if the character is not found, or if the + * provided string is null. The character may be the null character. + */ + +PR_EXTERN(char *) +PL_strrchr(const char *s, char c); + +/* + * PL_strnchr + * + * Returns a pointer to the first instance of the specified character within the + * first n characters of the provided string. It returns null if the character + * is not found, or if the provided string is null. The character may be the + * null character. + */ + +PR_EXTERN(char *) +PL_strnchr(const char *s, char c, PRUint32 n); + +/* + * PL_strnrchr + * + * Returns a pointer to the last instance of the specified character within the + * first n characters of the provided string. It returns null if the character is + * not found, or if the provided string is null. The character may be the null + * character. + */ + +PR_EXTERN(char *) +PL_strnrchr(const char *s, char c, PRUint32 n); + +/* + * NOTE: Looking for strcasechr, strcaserchr, strncasechr, or strncaserchr? + * Use strpbrk, strprbrk, strnpbrk or strnprbrk. + */ + +/* + * PL_strpbrk + * + * Returns a pointer to the first instance in the first string of any character + * (not including the terminating null character) of the second string. It returns + * null if either string is null. + */ + +PR_EXTERN(char *) +PL_strpbrk(const char *s, const char *list); + +/* + * PL_strprbrk + * + * Returns a pointer to the last instance in the first string of any character + * (not including the terminating null character) of the second string. It returns + * null if either string is null. + */ + +PR_EXTERN(char *) +PL_strprbrk(const char *s, const char *list); + +/* + * PL_strnpbrk + * + * Returns a pointer to the first instance (within the first n characters) of any + * character (not including the terminating null character) of the second string. + * It returns null if either string is null. + */ + +PR_EXTERN(char *) +PL_strnpbrk(const char *s, const char *list, PRUint32 n); + +/* + * PL_strnprbrk + * + * Returns a pointer to the last instance (within the first n characters) of any + * character (not including the terminating null character) of the second string. + * It returns null if either string is null. + */ + +PR_EXTERN(char *) +PL_strnprbrk(const char *s, const char *list, PRUint32 n); + +/* + * PL_strstr + * + * Returns a pointer to the first instance of the little string within the + * big one. It returns null if either string is null. + */ + +PR_EXTERN(char *) +PL_strstr(const char *big, const char *little); + +/* + * PL_strrstr + * + * Returns a pointer to the last instance of the little string within the big one. + * It returns null if either string is null. + */ + +PR_EXTERN(char *) +PL_strrstr(const char *big, const char *little); + +/* + * PL_strnstr + * + * Returns a pointer to the first instance of the little string within the first + * n characters of the big one. It returns null if either string is null. It + * returns null if the length of the little string is greater than n. + */ + +PR_EXTERN(char *) +PL_strnstr(const char *big, const char *little, PRUint32 n); + +/* + * PL_strnrstr + * + * Returns a pointer to the last instance of the little string within the first + * n characters of the big one. It returns null if either string is null. It + * returns null if the length of the little string is greater than n. + */ + +PR_EXTERN(char *) +PL_strnrstr(const char *big, const char *little, PRUint32 max); + +/* + * PL_strcasestr + * + * Returns a pointer to the first instance of the little string within the big one, + * ignoring case. It returns null if either string is null. + */ + +PR_EXTERN(char *) +PL_strcasestr(const char *big, const char *little); + +/* + * PL_strcaserstr + * + * Returns a pointer to the last instance of the little string within the big one, + * ignoring case. It returns null if either string is null. + */ + +PR_EXTERN(char *) +PL_strcaserstr(const char *big, const char *little); + +/* + * PL_strncasestr + * + * Returns a pointer to the first instance of the little string within the first + * n characters of the big one, ignoring case. It returns null if either string is + * null. It returns null if the length of the little string is greater than n. + */ + +PR_EXTERN(char *) +PL_strncasestr(const char *big, const char *little, PRUint32 max); + +/* + * PL_strncaserstr + * + * Returns a pointer to the last instance of the little string within the first + * n characters of the big one, ignoring case. It returns null if either string is + * null. It returns null if the length of the little string is greater than n. + */ + +PR_EXTERN(char *) +PL_strncaserstr(const char *big, const char *little, PRUint32 max); + +/* + * PL_strtok_r + * + * Splits the string s1 into tokens, separated by one or more characters + * from the separator string s2. The argument lasts points to a + * user-supplied char * pointer in which PL_strtok_r stores information + * for it to continue scanning the same string. + * + * In the first call to PL_strtok_r, s1 points to a string and the value + * of *lasts is ignored. PL_strtok_r returns a pointer to the first + * token, writes '\0' into the character following the first token, and + * updates *lasts. + * + * In subsequent calls, s1 is null and lasts must stay unchanged from the + * previous call. The separator string s2 may be different from call to + * call. PL_strtok_r returns a pointer to the next token in s1. When no + * token remains in s1, PL_strtok_r returns null. + */ + +PR_EXTERN(char *) +PL_strtok_r(char *s1, const char *s2, char **lasts); + +/* + * Things not (yet?) included: strspn/strcspn, strsep. + * memchr, memcmp, memcpy, memccpy, index, rindex, bcmp, bcopy, bzero. + * Any and all i18n/l10n stuff. + */ + +PR_END_EXTERN_C + +#endif /* _plstr_h */ diff --git a/illumos-x86_64/usr/include/mps/portreg.h b/illumos-x86_64/usr/include/mps/portreg.h new file mode 100644 index 00000000..14bd9e76 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/portreg.h @@ -0,0 +1,81 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * shexp.h: Defines and prototypes for shell exp. match routines + * + * This routine will match a string with a shell expression. The expressions + * accepted are based loosely on the expressions accepted by zsh. + * + * o * matches anything + * o ? matches one character + * o \ will escape a special character + * o $ matches the end of the string + * Bracketed expressions: + * o [abc] matches one occurence of a, b, or c. + * o [^abc] matches any character except a, b, or c. + * To be matched between [ and ], these characters must be escaped: \ ] + * No other characters need be escaped between brackets. + * Unnecessary escaping is permitted. + * o [a-z] matches any character between a and z, inclusive. + * The two range-definition characters must be alphanumeric ASCII. + * If one is upper case and the other is lower case, then the ASCII + * non-alphanumeric characters between Z and a will also be in range. + * o [^a-z] matches any character except those between a and z, inclusive. + * These forms cannot be combined, e.g [a-gp-z] does not work. + * o Exclusions: + * As a top level, outter-most expression only, the expression + * foo~bar will match the expression foo, provided it does not also + * match the expression bar. Either expression or both may be a union. + * Except between brackets, any unescaped ~ is an exclusion. + * At most one exclusion is permitted. + * Exclusions cannot be nested (contain other exclusions). + * example: *~abc will match any string except abc + * o Unions: + * (foo|bar) will match either the expression foo, or the expression bar. + * At least one '|' separator is required. More are permitted. + * Expressions inside unions may not include unions or exclusions. + * Inside a union, to be matched and not treated as a special character, + * these characters must be escaped: \ ( | ) [ ~ except when they occur + * inside a bracketed expression, where only \ and ] require escaping. + * + * The public interface to these routines is documented below. + * + */ + +#ifndef SHEXP_H +#define SHEXP_H + +#include "utilrename.h" +/* + * Requires that the macro MALLOC be set to a "safe" malloc that will + * exit if no memory is available. + */ + +/* --------------------------- Public routines ---------------------------- */ + +/* + * shexp_valid takes a shell expression exp as input. It returns: + * + * NON_SXP if exp is a standard string + * INVALID_SXP if exp is a shell expression, but invalid + * VALID_SXP if exp is a valid shell expression + */ + +#define NON_SXP -1 +#define INVALID_SXP -2 +#define VALID_SXP 1 + +SEC_BEGIN_PROTOS + +extern int PORT_RegExpValid(const char *exp); + +extern int PORT_RegExpSearch(const char *str, const char *exp); + +/* same as above but uses case insensitive search */ +extern int PORT_RegExpCaseSearch(const char *str, const char *exp); + +SEC_END_PROTOS + +#endif diff --git a/illumos-x86_64/usr/include/mps/pratom.h b/illumos-x86_64/usr/include/mps/pratom.h new file mode 100644 index 00000000..5ced3c24 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pratom.h @@ -0,0 +1,200 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* GLOBAL FUNCTIONS: +** DESCRIPTION: +** PR Atomic operations +*/ + +#ifndef pratom_h___ +#define pratom_h___ + +#include "prtypes.h" +#include "prlock.h" + +PR_BEGIN_EXTERN_C + +/* +** FUNCTION: PR_AtomicIncrement +** DESCRIPTION: +** Atomically increment a 32 bit value. +** INPUTS: +** val: a pointer to the value to increment +** RETURN: +** the returned value is the result of the increment +*/ +NSPR_API(PRInt32) PR_AtomicIncrement(PRInt32 *val); + +/* +** FUNCTION: PR_AtomicDecrement +** DESCRIPTION: +** Atomically decrement a 32 bit value. +** INPUTS: +** val: a pointer to the value to decrement +** RETURN: +** the returned value is the result of the decrement +*/ +NSPR_API(PRInt32) PR_AtomicDecrement(PRInt32 *val); + +/* +** FUNCTION: PR_AtomicSet +** DESCRIPTION: +** Atomically set a 32 bit value. +** INPUTS: +** val: A pointer to a 32 bit value to be set +** newval: The newvalue to assign to val +** RETURN: +** Returns the prior value +*/ +NSPR_API(PRInt32) PR_AtomicSet(PRInt32 *val, PRInt32 newval); + +/* +** FUNCTION: PR_AtomicAdd +** DESCRIPTION: +** Atomically add a 32 bit value. +** INPUTS: +** ptr: a pointer to the value to increment +** val: value to be added +** RETURN: +** the returned value is the result of the addition +*/ +NSPR_API(PRInt32) PR_AtomicAdd(PRInt32 *ptr, PRInt32 val); + +/* +** MACRO: PR_ATOMIC_INCREMENT +** MACRO: PR_ATOMIC_DECREMENT +** MACRO: PR_ATOMIC_SET +** MACRO: PR_ATOMIC_ADD +** DESCRIPTION: +** Macro versions of the atomic operations. They may be implemented +** as compiler intrinsics. +** +** IMPORTANT NOTE TO NSPR MAINTAINERS: +** Implement these macros with compiler intrinsics only on platforms +** where the PR_AtomicXXX functions are truly atomic (i.e., where the +** configuration macro _PR_HAVE_ATOMIC_OPS is defined). Otherwise, +** the macros and functions won't be compatible and can't be used +** interchangeably. +*/ +#if defined(_WIN32) && !defined(_WIN32_WCE) && \ + (!defined(_MSC_VER) || (_MSC_VER >= 1310)) + +#include + +#ifdef _MSC_VER +#pragma intrinsic(_InterlockedIncrement) +#pragma intrinsic(_InterlockedDecrement) +#pragma intrinsic(_InterlockedExchange) +#pragma intrinsic(_InterlockedExchangeAdd) +#endif + +#define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement((long volatile *)(val)) +#define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement((long volatile *)(val)) +#define PR_ATOMIC_SET(val, newval) \ + _InterlockedExchange((long volatile *)(val), (long)(newval)) +#define PR_ATOMIC_ADD(ptr, val) \ + (_InterlockedExchangeAdd((long volatile *)(ptr), (long)(val)) + (val)) + +#elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && \ + ((defined(__APPLE__) && \ + (defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) || \ + (defined(__linux__) && \ + ((defined(__i386__) && \ + defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \ + defined(__ia64__) || defined(__x86_64__) || \ + defined(__powerpc__) || \ + (defined(__arm__) && \ + defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \ + defined(__aarch64__) || defined(__alpha) || \ + (defined(__riscv) && \ + defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \ + (defined(__mips__) && \ + defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))))) + +/* + * Because the GCC manual warns that some processors may support + * reduced functionality of __sync_lock_test_and_set, we test for the + * processors that we believe support a full atomic exchange operation. + */ + +#define PR_ATOMIC_INCREMENT(val) __sync_add_and_fetch(val, 1) +#define PR_ATOMIC_DECREMENT(val) __sync_sub_and_fetch(val, 1) +#define PR_ATOMIC_SET(val, newval) __sync_lock_test_and_set(val, newval) +#define PR_ATOMIC_ADD(ptr, val) __sync_add_and_fetch(ptr, val) + +#else + +#define PR_ATOMIC_INCREMENT(val) PR_AtomicIncrement(val) +#define PR_ATOMIC_DECREMENT(val) PR_AtomicDecrement(val) +#define PR_ATOMIC_SET(val, newval) PR_AtomicSet(val, newval) +#define PR_ATOMIC_ADD(ptr, val) PR_AtomicAdd(ptr, val) + +#endif + +/* +** LIFO linked-list (stack) +*/ +typedef struct PRStackElemStr PRStackElem; + +struct PRStackElemStr { + PRStackElem *prstk_elem_next; /* next pointer MUST be at offset 0; + assembly language code relies on this */ +}; + +typedef struct PRStackStr PRStack; + +/* +** FUNCTION: PR_CreateStack +** DESCRIPTION: +** Create a stack, a LIFO linked list +** INPUTS: +** stack_name: a pointer to string containing the name of the stack +** RETURN: +** A pointer to the created stack, if successful, else NULL. +*/ +NSPR_API(PRStack *) PR_CreateStack(const char *stack_name); + +/* +** FUNCTION: PR_StackPush +** DESCRIPTION: +** Push an element on the top of the stack +** INPUTS: +** stack: pointer to the stack +** stack_elem: pointer to the stack element +** RETURN: +** None +*/ +NSPR_API(void) PR_StackPush(PRStack *stack, PRStackElem *stack_elem); + +/* +** FUNCTION: PR_StackPop +** DESCRIPTION: +** Remove the element on the top of the stack +** INPUTS: +** stack: pointer to the stack +** RETURN: +** A pointer to the stack element removed from the top of the stack, +** if non-empty, +** else NULL +*/ +NSPR_API(PRStackElem *) PR_StackPop(PRStack *stack); + +/* +** FUNCTION: PR_DestroyStack +** DESCRIPTION: +** Destroy the stack +** INPUTS: +** stack: pointer to the stack +** RETURN: +** PR_SUCCESS - if successfully deleted +** PR_FAILURE - if the stack is not empty +** PR_GetError will return +** PR_INVALID_STATE_ERROR - stack is not empty +*/ +NSPR_API(PRStatus) PR_DestroyStack(PRStack *stack); + +PR_END_EXTERN_C + +#endif /* pratom_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prbit.h b/illumos-x86_64/usr/include/mps/prbit.h new file mode 100644 index 00000000..50c65923 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prbit.h @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prbit_h___ +#define prbit_h___ + +#include "prtypes.h" +PR_BEGIN_EXTERN_C + +/* +** Replace compare/jump/add/shift sequence with compiler built-in/intrinsic +** functions. +*/ +#if defined(_WIN32) && (_MSC_VER >= 1300) && \ + (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || \ + defined(_M_ARM64)) +# include +# pragma intrinsic(_BitScanForward,_BitScanReverse) +__forceinline static int __prBitScanForward32(unsigned int val) +{ + unsigned long idx; + _BitScanForward(&idx, (unsigned long)val); + return( (int)idx ); +} +__forceinline static int __prBitScanReverse32(unsigned int val) +{ + unsigned long idx; + _BitScanReverse(&idx, (unsigned long)val); + return( (int)(31-idx) ); +} +# define pr_bitscan_ctz32(val) __prBitScanForward32(val) +# define pr_bitscan_clz32(val) __prBitScanReverse32(val) +# define PR_HAVE_BUILTIN_BITSCAN32 +#elif ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \ + (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ + defined(__aarch64__)) +# define pr_bitscan_ctz32(val) __builtin_ctz(val) +# define pr_bitscan_clz32(val) __builtin_clz(val) +# define PR_HAVE_BUILTIN_BITSCAN32 +#endif /* MSVC || GCC */ + +/* +** A prbitmap_t is a long integer that can be used for bitmaps +*/ +typedef unsigned long prbitmap_t; + +#define PR_TEST_BIT(_map,_bit) \ + ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] & (1L << ((_bit) & (PR_BITS_PER_LONG-1)))) +#define PR_SET_BIT(_map,_bit) \ + ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] |= (1L << ((_bit) & (PR_BITS_PER_LONG-1)))) +#define PR_CLEAR_BIT(_map,_bit) \ + ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] &= ~(1L << ((_bit) & (PR_BITS_PER_LONG-1)))) + +/* +** Compute the log of the least power of 2 greater than or equal to n +*/ +NSPR_API(PRIntn) PR_CeilingLog2(PRUint32 i); + +/* +** Compute the log of the greatest power of 2 less than or equal to n +*/ +NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i); + +/* +** Macro version of PR_CeilingLog2: Compute the log of the least power of +** 2 greater than or equal to _n. The result is returned in _log2. +*/ +#ifdef PR_HAVE_BUILTIN_BITSCAN32 +#define PR_CEILING_LOG2(_log2,_n) \ + PR_BEGIN_MACRO \ + PRUint32 j_ = (PRUint32)(_n); \ + (_log2) = (j_ <= 1 ? 0 : 32 - pr_bitscan_clz32(j_ - 1)); \ + PR_END_MACRO +#else +#define PR_CEILING_LOG2(_log2,_n) \ + PR_BEGIN_MACRO \ + PRUint32 j_ = (PRUint32)(_n); \ + (_log2) = 0; \ + if ((j_) & ((j_)-1)) \ + (_log2) += 1; \ + if ((j_) >> 16) \ + (_log2) += 16, (j_) >>= 16; \ + if ((j_) >> 8) \ + (_log2) += 8, (j_) >>= 8; \ + if ((j_) >> 4) \ + (_log2) += 4, (j_) >>= 4; \ + if ((j_) >> 2) \ + (_log2) += 2, (j_) >>= 2; \ + if ((j_) >> 1) \ + (_log2) += 1; \ + PR_END_MACRO +#endif /* PR_HAVE_BUILTIN_BITSCAN32 */ + +/* +** Macro version of PR_FloorLog2: Compute the log of the greatest power of +** 2 less than or equal to _n. The result is returned in _log2. +** +** This is equivalent to finding the highest set bit in the word. +*/ +#ifdef PR_HAVE_BUILTIN_BITSCAN32 +#define PR_FLOOR_LOG2(_log2,_n) \ + PR_BEGIN_MACRO \ + PRUint32 j_ = (PRUint32)(_n); \ + (_log2) = 31 - pr_bitscan_clz32((j_) | 1); \ + PR_END_MACRO +#else +#define PR_FLOOR_LOG2(_log2,_n) \ + PR_BEGIN_MACRO \ + PRUint32 j_ = (PRUint32)(_n); \ + (_log2) = 0; \ + if ((j_) >> 16) \ + (_log2) += 16, (j_) >>= 16; \ + if ((j_) >> 8) \ + (_log2) += 8, (j_) >>= 8; \ + if ((j_) >> 4) \ + (_log2) += 4, (j_) >>= 4; \ + if ((j_) >> 2) \ + (_log2) += 2, (j_) >>= 2; \ + if ((j_) >> 1) \ + (_log2) += 1; \ + PR_END_MACRO +#endif /* PR_HAVE_BUILTIN_BITSCAN32 */ + +/* +** Macros for rotate left and right. The argument 'a' must be an unsigned +** 32-bit integer type such as PRUint32. +** +** There is no rotate operation in the C Language, so the construct +** (a << 4) | (a >> 28) is frequently used instead. Most compilers convert +** this to a rotate instruction, but MSVC doesn't without a little help. +** To get MSVC to generate a rotate instruction, we have to use the _rotl +** or _rotr intrinsic and use a pragma to make it inline. +** +** Note: MSVC in VS2005 will do an inline rotate instruction on the above +** construct. +*/ + +#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \ + defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64)) +#include +#pragma intrinsic(_rotl, _rotr) +#define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits) +#define PR_ROTATE_RIGHT32(a, bits) _rotr(a, bits) +#else +#define PR_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits)))) +#define PR_ROTATE_RIGHT32(a, bits) (((a) >> (bits)) | ((a) << (32 - (bits)))) +#endif + +PR_END_EXTERN_C +#endif /* prbit_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prclist.h b/illumos-x86_64/usr/include/mps/prclist.h new file mode 100644 index 00000000..a0691760 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prclist.h @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prclist_h___ +#define prclist_h___ + +#include "prtypes.h" + +typedef struct PRCListStr PRCList; + +/* +** Circular linked list +*/ +struct PRCListStr { + PRCList *next; + PRCList *prev; +}; + +/* +** Insert element "_e" into the list, before "_l". +*/ +#define PR_INSERT_BEFORE(_e,_l) \ + PR_BEGIN_MACRO \ + (_e)->next = (_l); \ + (_e)->prev = (_l)->prev; \ + (_l)->prev->next = (_e); \ + (_l)->prev = (_e); \ + PR_END_MACRO + +/* +** Insert element "_e" into the list, after "_l". +*/ +#define PR_INSERT_AFTER(_e,_l) \ + PR_BEGIN_MACRO \ + (_e)->next = (_l)->next; \ + (_e)->prev = (_l); \ + (_l)->next->prev = (_e); \ + (_l)->next = (_e); \ + PR_END_MACRO + +/* +** Return the element following element "_e" +*/ +#define PR_NEXT_LINK(_e) \ + ((_e)->next) +/* +** Return the element preceding element "_e" +*/ +#define PR_PREV_LINK(_e) \ + ((_e)->prev) + +/* +** Append an element "_e" to the end of the list "_l" +*/ +#define PR_APPEND_LINK(_e,_l) PR_INSERT_BEFORE(_e,_l) + +/* +** Insert an element "_e" at the head of the list "_l" +*/ +#define PR_INSERT_LINK(_e,_l) PR_INSERT_AFTER(_e,_l) + +/* Return the head/tail of the list */ +#define PR_LIST_HEAD(_l) (_l)->next +#define PR_LIST_TAIL(_l) (_l)->prev + +/* +** Remove the element "_e" from it's circular list. +*/ +#define PR_REMOVE_LINK(_e) \ + PR_BEGIN_MACRO \ + (_e)->prev->next = (_e)->next; \ + (_e)->next->prev = (_e)->prev; \ + PR_END_MACRO + +/* +** Remove the element "_e" from it's circular list. Also initializes the +** linkage. +*/ +#define PR_REMOVE_AND_INIT_LINK(_e) \ + PR_BEGIN_MACRO \ + (_e)->prev->next = (_e)->next; \ + (_e)->next->prev = (_e)->prev; \ + (_e)->next = (_e); \ + (_e)->prev = (_e); \ + PR_END_MACRO + +/* +** Return non-zero if the given circular list "_l" is empty, zero if the +** circular list is not empty +*/ +#define PR_CLIST_IS_EMPTY(_l) \ + ((_l)->next == (_l)) + +/* +** Initialize a circular list +*/ +#define PR_INIT_CLIST(_l) \ + PR_BEGIN_MACRO \ + (_l)->next = (_l); \ + (_l)->prev = (_l); \ + PR_END_MACRO + +#define PR_INIT_STATIC_CLIST(_l) \ + {(_l), (_l)} + +#endif /* prclist_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prcmon.h b/illumos-x86_64/usr/include/mps/prcmon.h new file mode 100644 index 00000000..69171138 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prcmon.h @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prcmon_h___ +#define prcmon_h___ + +/* +** Interface to cached monitors. Cached monitors use an address to find a +** given PR monitor. In this way a monitor can be associated with another +** object without preallocating a monitor for all objects. +** +** A hash table is used to quickly map addresses to individual monitors +** and the system automatically grows the hash table as needed. +** +** Cache monitors are about 5 times slower to use than uncached monitors. +*/ +#include "prmon.h" +#include "prinrval.h" + +PR_BEGIN_EXTERN_C + +/** +** Like PR_EnterMonitor except use the "address" to find a monitor in the +** monitor cache. If successful, returns the PRMonitor now associated +** with "address". Note that you must PR_CExitMonitor the address to +** release the monitor cache entry (otherwise the monitor cache will fill +** up). This call will return NULL if the monitor cache needs to be +** expanded and the system is out of memory. +*/ +NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address); + +/* +** Like PR_ExitMonitor except use the "address" to find a monitor in the +** monitor cache. +*/ +NSPR_API(PRStatus) PR_CExitMonitor(void *address); + +/* +** Like PR_Wait except use the "address" to find a monitor in the +** monitor cache. +*/ +NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout); + +/* +** Like PR_Notify except use the "address" to find a monitor in the +** monitor cache. +*/ +NSPR_API(PRStatus) PR_CNotify(void *address); + +/* +** Like PR_NotifyAll except use the "address" to find a monitor in the +** monitor cache. +*/ +NSPR_API(PRStatus) PR_CNotifyAll(void *address); + +/* +** Set a callback to be invoked each time a monitor is recycled from the cache +** freelist, with the monitor's cache-key passed in address. +*/ +NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address)); + +PR_END_EXTERN_C + +#endif /* prcmon_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prcountr.h b/illumos-x86_64/usr/include/mps/prcountr.h new file mode 100644 index 00000000..1503d06d --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prcountr.h @@ -0,0 +1,525 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prcountr_h___ +#define prcountr_h___ + +/*---------------------------------------------------------------------------- +** prcountr.h -- NSPR Instrumentation counters +** +** The NSPR Counter Feature provides a means to "count +** something." Counters can be dynamically defined, incremented, +** decremented, set, and deleted under application program +** control. +** +** The Counter Feature is intended to be used as instrumentation, +** not as operational data. If you need a counter for operational +** data, use native integral types. +** +** Counters are 32bit unsigned intergers. On overflow, a counter +** will wrap. No exception is recognized or reported. +** +** A counter can be dynamically created using a two level naming +** convention. A "handle" is returned when the counter is +** created. The counter can subsequently be addressed by its +** handle. An API is provided to get an existing counter's handle +** given the names with which it was originally created. +** Similarly, a counter's name can be retrieved given its handle. +** +** The counter naming convention is a two-level hierarchy. The +** QName is the higher level of the hierarchy; RName is the +** lower level. RNames can be thought of as existing within a +** QName. The same RName can exist within multiple QNames. QNames +** are unique. The NSPR Counter is not a near-zero overhead +** feature. Application designers should be aware of +** serialization issues when using the Counter API. Creating a +** counter locks a large asset, potentially causing a stall. This +** suggest that applications should create counters at component +** initialization, for example, and not create and destroy them +** willy-nilly. ... You have been warned. +** +** Incrementing and Adding to counters uses atomic operations. +** The performance of these operations will vary from platform +** to platform. On platforms where atomic operations are not +** supported the overhead may be substantial. +** +** When traversing the counter database with FindNext functions, +** the instantaneous values of any given counter is that at the +** moment of extraction. The state of the entire counter database +** may not be viewed as atomic. +** +** The counter interface may be disabled (No-Op'd) at compile +** time. When DEBUG is defined at compile time, the Counter +** Feature is compiled into NSPR and applications invoking it. +** When DEBUG is not defined, the counter macros compile to +** nothing. To force the Counter Feature to be compiled into an +** optimized build, define FORCE_NSPR_COUNTERS at compile time +** for both NSPR and the application intending to use it. +** +** Application designers should use the macro form of the Counter +** Feature methods to minimize performance impact in optimized +** builds. The macros normally compile to nothing on optimized +** builds. +** +** Application designers should be aware of the effects of +** debug and optimized build differences when using result of the +** Counter Feature macros in expressions. +** +** The Counter Feature is thread-safe and SMP safe. +** +** /lth. 09-Jun-1998. +*/ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* +** Opaque counter handle type. +** ... don't even think of looking in here. +** +*/ +typedef void * PRCounterHandle; + +#define PRCOUNTER_NAME_MAX 31 +#define PRCOUNTER_DESC_MAX 255 + + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_DEFINE_COUNTER() -- Define a PRCounterHandle +** +** DESCRIPTION: PR_DEFINE_COUNTER() is used to define a counter +** handle. +** +*/ +#define PR_DEFINE_COUNTER(name) PRCounterHandle name + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_INIT_COUNTER_HANDLE() -- Set the value of a PRCounterHandle +** +** DESCRIPTION: +** PR_INIT_COUNTER_HANDLE() sets the value of a PRCounterHandle +** to value. +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_INIT_COUNTER_HANDLE(handle,value)\ + (handle) = (PRCounterHandle)(value) +#else +#define PR_INIT_COUNTER_HANDLE(handle,value) +#endif + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_CreateCounter() -- Create a counter +** +** DESCRIPTION: PR_CreateCounter() creates a counter object and +** initializes it to zero. +** +** The macro form takes as its first argument the name of the +** PRCounterHandle to receive the handle returned from +** PR_CreateCounter(). +** +** INPUTS: +** qName: The QName for the counter object. The maximum length +** of qName is defined by PRCOUNTER_NAME_MAX +** +** rName: The RName for the counter object. The maximum length +** of qName is defined by PRCOUNTER_NAME_MAX +** +** descrioption: The description of the counter object. The +** maximum length of description is defined by +** PRCOUNTER_DESC_MAX. +** +** OUTPUTS: +** +** RETURNS: +** PRCounterHandle. +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_CREATE_COUNTER(handle,qName,rName,description)\ + (handle) = PR_CreateCounter((qName),(rName),(description)) +#else +#define PR_CREATE_COUNTER(handle,qName,rName,description) +#endif + +NSPR_API(PRCounterHandle) +PR_CreateCounter( + const char *qName, + const char *rName, + const char *description +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_DestroyCounter() -- Destroy a counter object. +** +** DESCRIPTION: PR_DestroyCounter() removes a counter and +** unregisters its handle from the counter database. +** +** INPUTS: +** handle: the PRCounterHandle of the counter to be destroyed. +** +** OUTPUTS: +** The counter is destroyed. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_DESTROY_COUNTER(handle) PR_DestroyCounter((handle)) +#else +#define PR_DESTROY_COUNTER(handle) +#endif + +NSPR_API(void) +PR_DestroyCounter( + PRCounterHandle handle +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_GetCounterHandleFromName() -- Retreive a +** counter's handle give its name. +** +** DESCRIPTION: PR_GetCounterHandleFromName() retreives a +** counter's handle from the counter database, given the name +** the counter was originally created with. +** +** INPUTS: +** qName: Counter's original QName. +** rName: Counter's original RName. +** +** OUTPUTS: +** +** RETURNS: +** PRCounterHandle or PRCounterError. +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)\ + (handle) = PR_GetCounterHandleFromName((qName),(rName)) +#else +#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName) +#endif + +NSPR_API(PRCounterHandle) +PR_GetCounterHandleFromName( + const char *qName, + const char *rName +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_GetCounterNameFromHandle() -- Retreive a +** counter's name, given its handle. +** +** DESCRIPTION: PR_GetCounterNameFromHandle() retreives a +** counter's name given its handle. +** +** INPUTS: +** qName: Where to store a pointer to qName. +** rName: Where to store a pointer to rName. +** description: Where to store a pointer to description. +** +** OUTPUTS: Pointers to the Counter Feature's copies of the names +** used when the counters were created. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description)\ + PR_GetCounterNameFromHandle((handle),(qName),(rName),(description)) +#else +#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description ) +#endif + +NSPR_API(void) +PR_GetCounterNameFromHandle( + PRCounterHandle handle, + const char **qName, + const char **rName, + const char **description +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_IncrementCounter() -- Add one to the referenced +** counter. +** +** DESCRIPTION: Add one to the referenced counter. +** +** INPUTS: +** handle: The PRCounterHandle of the counter to be incremented +** +** OUTPUTS: The counter is incrementd. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_INCREMENT_COUNTER(handle) PR_IncrementCounter(handle) +#else +#define PR_INCREMENT_COUNTER(handle) +#endif + +NSPR_API(void) +PR_IncrementCounter( + PRCounterHandle handle +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_DecrementCounter() -- Subtract one from the +** referenced counter +** +** DESCRIPTION: Subtract one from the referenced counter. +** +** INPUTS: +** handle: The PRCounterHandle of the coutner to be +** decremented. +** +** OUTPUTS: the counter is decremented. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_DECREMENT_COUNTER(handle) PR_DecrementCounter(handle) +#else +#define PR_DECREMENT_COUNTER(handle) +#endif + +NSPR_API(void) +PR_DecrementCounter( + PRCounterHandle handle +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_AddToCounter() -- Add a value to a counter. +** +** DESCRIPTION: Add value to the counter referenced by handle. +** +** INPUTS: +** handle: the PRCounterHandle of the counter to be added to. +** +** value: the value to be added to the counter. +** +** OUTPUTS: new value for counter. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_ADD_TO_COUNTER(handle,value)\ + PR_AddToCounter((handle),(value)) +#else +#define PR_ADD_TO_COUNTER(handle,value) +#endif + +NSPR_API(void) +PR_AddToCounter( + PRCounterHandle handle, + PRUint32 value +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_SubtractFromCounter() -- A value is subtracted +** from a counter. +** +** DESCRIPTION: +** Subtract a value from a counter. +** +** INPUTS: +** handle: the PRCounterHandle of the counter to be subtracted +** from. +** +** value: the value to be subtracted from the counter. +** +** OUTPUTS: new value for counter +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_SUBTRACT_FROM_COUNTER(handle,value)\ + PR_SubtractFromCounter((handle),(value)) +#else +#define PR_SUBTRACT_FROM_COUNTER(handle,value) +#endif + +NSPR_API(void) +PR_SubtractFromCounter( + PRCounterHandle handle, + PRUint32 value +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_GetCounter() -- Retreive the value of a counter +** +** DESCRIPTION: +** Retreive the value of a counter. +** +** INPUTS: +** handle: the PR_CounterHandle of the counter to be retreived +** +** OUTPUTS: +** +** RETURNS: The value of the referenced counter +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_GET_COUNTER(counter,handle)\ + (counter) = PR_GetCounter((handle)) +#else +#define PR_GET_COUNTER(counter,handle) 0 +#endif + +NSPR_API(PRUint32) +PR_GetCounter( + PRCounterHandle handle +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_SetCounter() -- Replace the content of counter +** with value. +** +** DESCRIPTION: The contents of the referenced counter are +** replaced by value. +** +** INPUTS: +** handle: the PRCounterHandle of the counter whose contents +** are to be replaced. +** +** value: the new value of the counter. +** +** OUTPUTS: +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_SET_COUNTER(handle,value) PR_SetCounter((handle),(value)) +#else +#define PR_SET_COUNTER(handle,value) +#endif + +NSPR_API(void) +PR_SetCounter( + PRCounterHandle handle, + PRUint32 value +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_FindNextCounterQname() -- Retreive the next QName counter +** handle iterator +** +** DESCRIPTION: +** PR_FindNextCounterQname() retreives the first or next Qname +** the counter data base, depending on the value of handle. When +** handle is NULL, the function attempts to retreive the first +** QName handle in the database. When handle is a handle previosly +** retreived QName handle, then the function attempts to retreive +** the next QName handle. +** +** INPUTS: +** handle: PRCounterHandle or NULL. +** +** OUTPUTS: returned +** +** RETURNS: PRCounterHandle or NULL when no more QName counter +** handles are present. +** +** RESTRICTIONS: +** A concurrent PR_CreateCounter() or PR_DestroyCounter() may +** cause unpredictable results. +** +** A PRCounterHandle returned from this function may only be used +** in another PR_FindNextCounterQname() function call; other +** operations may cause unpredictable results. +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_FIND_NEXT_COUNTER_QNAME(next,handle)\ + (next) = PR_FindNextCounterQname((handle)) +#else +#define PR_FIND_NEXT_COUNTER_QNAME(next,handle) NULL +#endif + +NSPR_API(PRCounterHandle) +PR_FindNextCounterQname( + PRCounterHandle handle +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_FindNextCounterRname() -- Retreive the next RName counter +** handle iterator +** +** DESCRIPTION: +** PR_FindNextCounterRname() retreives the first or next RNname +** handle from the counter data base, depending on the +** value of handle. When handle is NULL, the function attempts to +** retreive the first RName handle in the database. When handle is +** a handle previosly retreived RName handle, then the function +** attempts to retreive the next RName handle. +** +** INPUTS: +** handle: PRCounterHandle or NULL. +** qhandle: PRCounterHandle of a previously aquired via +** PR_FIND_NEXT_QNAME_HANDLE() +** +** OUTPUTS: returned +** +** RETURNS: PRCounterHandle or NULL when no more RName counter +** handles are present. +** +** RESTRICTIONS: +** A concurrent PR_CreateCounter() or PR_DestroyCounter() may +** cause unpredictable results. +** +** A PRCounterHandle returned from this function may only be used +** in another PR_FindNextCounterRname() function call; other +** operations may cause unpredictable results. +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) +#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)\ + (next) = PR_FindNextCounterRname((rhandle),(qhandle)) +#else +#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle) +#endif + +NSPR_API(PRCounterHandle) +PR_FindNextCounterRname( + PRCounterHandle rhandle, + PRCounterHandle qhandle +); + +PR_END_EXTERN_C + +#endif /* prcountr_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prcpucfg.h b/illumos-x86_64/usr/include/mps/prcpucfg.h new file mode 100644 index 00000000..7473039b --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prcpucfg.h @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef SOLARIS +#define SOLARIS +#endif + +#define PR_AF_INET6 26 /* same as AF_INET6 */ + +#if defined(sparc) || defined(__sparc) +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_DOUBLE 8 +#if defined(__sparcv9) +#define IS_64 +#endif +#elif defined(__x86_64) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define IS_64 +#elif defined(i386) || defined(__i386) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_DOUBLE 4 +#elif defined(__aarch64__) || defined(__aarch64) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define IS_64 +#else +#error unknown processor +#endif + +#ifdef IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_POINTER 8 + +#else /* IS_64 */ + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_POINTER 4 + +#endif /* IS_64 */ + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* ifndef nspr_cpucfg___ */ diff --git a/illumos-x86_64/usr/include/mps/prcvar.h b/illumos-x86_64/usr/include/mps/prcvar.h new file mode 100644 index 00000000..413a3646 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prcvar.h @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prcvar_h___ +#define prcvar_h___ + +#include "prlock.h" +#include "prinrval.h" + +PR_BEGIN_EXTERN_C + +typedef struct PRCondVar PRCondVar; + +/* +** Create a new condition variable. +** +** "lock" is the lock used to protect the condition variable. +** +** Condition variables are synchronization objects that threads can use +** to wait for some condition to occur. +** +** This may fail if memory is tight or if some operating system resource +** is low. In such cases, a NULL will be returned. +*/ +NSPR_API(PRCondVar*) PR_NewCondVar(PRLock *lock); + +/* +** Destroy a condition variable. There must be no thread +** waiting on the condvar. The caller is responsible for guaranteeing +** that the condvar is no longer in use. +** +*/ +NSPR_API(void) PR_DestroyCondVar(PRCondVar *cvar); + +/* +** The thread that waits on a condition is blocked in a "waiting on +** condition" state until another thread notifies the condition or a +** caller specified amount of time expires. The lock associated with +** the condition variable will be released, which must have be held +** prior to the call to wait. +** +** Logically a notified thread is moved from the "waiting on condition" +** state and made "ready." When scheduled, it will attempt to reacquire +** the lock that it held when wait was called. +** +** The timeout has two well known values, PR_INTERVAL_NO_TIMEOUT and +** PR_INTERVAL_NO_WAIT. The former value requires that a condition be +** notified (or the thread interrupted) before it will resume from the +** wait. If the timeout has a value of PR_INTERVAL_NO_WAIT, the effect +** is to release the lock, possibly causing a rescheduling within the +** runtime, then immediately attempting to reacquire the lock and resume. +** +** Any other value for timeout will cause the thread to be rescheduled +** either due to explicit notification or an expired interval. The latter +** must be determined by treating time as one part of the monitored data +** being protected by the lock and tested explicitly for an expired +** interval. +** +** Returns PR_FAILURE if the caller has not locked the lock associated +** with the condition variable or the thread was interrupted (PR_Interrupt()). +** The particular reason can be extracted with PR_GetError(). +*/ +NSPR_API(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout); + +/* +** Notify ONE thread that is currently waiting on 'cvar'. Which thread is +** dependent on the implementation of the runtime. Common sense would dictate +** that all threads waiting on a single condition have identical semantics, +** therefore which one gets notified is not significant. +** +** The calling thead must hold the lock that protects the condition, as +** well as the invariants that are tightly bound to the condition, when +** notify is called. +** +** Returns PR_FAILURE if the caller has not locked the lock associated +** with the condition variable. +*/ +NSPR_API(PRStatus) PR_NotifyCondVar(PRCondVar *cvar); + +/* +** Notify all of the threads waiting on the condition variable. The order +** that the threads are notified is indeterminant. The lock that protects +** the condition must be held. +** +** Returns PR_FAILURE if the caller has not locked the lock associated +** with the condition variable. +*/ +NSPR_API(PRStatus) PR_NotifyAllCondVar(PRCondVar *cvar); + +PR_END_EXTERN_C + +#endif /* prcvar_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prdtoa.h b/illumos-x86_64/usr/include/mps/prdtoa.h new file mode 100644 index 00000000..312a9d60 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prdtoa.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prdtoa_h___ +#define prdtoa_h___ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* +** PR_strtod() returns as a double-precision floating-point number +** the value represented by the character string pointed to by +** s00. The string is scanned up to the first unrecognized +** character. +**a +** If the value of se is not (char **)NULL, a pointer to +** the character terminating the scan is returned in the location pointed +** to by se. If no number can be formed, se is set to s00, and +** zero is returned. +*/ +NSPR_API(PRFloat64) +PR_strtod(const char *s00, char **se); + +/* +** PR_cnvtf() +** conversion routines for floating point +** prcsn - number of digits of precision to generate floating +** point value. +*/ +NSPR_API(void) PR_cnvtf(char *buf, PRIntn bufsz, PRIntn prcsn, PRFloat64 fval); + +/* +** PR_dtoa() converts double to a string. +** +** ARGUMENTS: +** If rve is not null, *rve is set to point to the end of the return value. +** If d is +-Infinity or NaN, then *decpt is set to 9999. +** +** mode: +** 0 ==> shortest string that yields d when read in +** and rounded to nearest. +*/ +NSPR_API(PRStatus) PR_dtoa(PRFloat64 d, PRIntn mode, PRIntn ndigits, + PRIntn *decpt, PRIntn *sign, char **rve, char *buf, PRSize bufsize); + +PR_END_EXTERN_C + +#endif /* prdtoa_h___ */ diff --git a/illumos-x86_64/usr/include/mps/preenc.h b/illumos-x86_64/usr/include/mps/preenc.h new file mode 100644 index 00000000..bebff89e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/preenc.h @@ -0,0 +1,113 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ + +/* + * Fortezza support is removed. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Fortezza support is removed. + * This file remains so that old programs will continue to compile, + * But this functionality is no longer supported or implemented. + */ + +#include "seccomon.h" +#include "prio.h" + +typedef struct PEHeaderStr PEHeader; + +#define PE_MIME_TYPE "application/pre-encrypted" + +typedef struct PEFortezzaHeaderStr PEFortezzaHeader; +typedef struct PEFortezzaGeneratedHeaderStr PEFortezzaGeneratedHeader; +typedef struct PEFixedKeyHeaderStr PEFixedKeyHeader; +typedef struct PERSAKeyHeaderStr PERSAKeyHeader; + +struct PEFortezzaHeaderStr { + unsigned char key[12]; + unsigned char iv[24]; + unsigned char hash[20]; + unsigned char serial[8]; +}; + +struct PEFortezzaGeneratedHeaderStr { + unsigned char key[12]; + unsigned char iv[24]; + unsigned char hash[20]; + unsigned char Ra[128]; + unsigned char Y[128]; +}; + +struct PEFixedKeyHeaderStr { + unsigned char pkcs11Mech[4]; + unsigned char labelLen[2]; + unsigned char keyIDLen[2]; + unsigned char ivLen[2]; + unsigned char keyLen[2]; + unsigned char data[1]; +}; + +struct PERSAKeyHeaderStr { + unsigned char pkcs11Mech[4]; + unsigned char issuerLen[2]; + unsigned char serialLen[2]; + unsigned char ivLen[2]; + unsigned char keyLen[2]; + unsigned char data[1]; +}; + +#define PEFIXED_Label(header) (header->data) +#define PEFIXED_KeyID(header) (&header->data[GetInt2(header->labelLen)]) +#define PEFIXED_IV(header) (&header->data[GetInt2(header->labelLen) + \ + GetInt2(header->keyIDLen)]) +#define PEFIXED_Key(header) (&header->data[GetInt2(header->labelLen) + \ + GetInt2(header->keyIDLen) + \ + GetInt2(header->keyLen)]) +#define PERSA_Issuer(header) (header->data) +#define PERSA_Serial(header) (&header->data[GetInt2(header->issuerLen)]) +#define PERSA_IV(header) (&header->data[GetInt2(header->issuerLen) + \ + GetInt2(header->serialLen)]) +#define PERSA_Key(header) (&header->data[GetInt2(header->issuerLen) + \ + GetInt2(header->serialLen) + \ + GetInt2(header->keyLen)]) +struct PEHeaderStr { + unsigned char magic[2]; + unsigned char len[2]; + unsigned char type[2]; + unsigned char version[2]; + union { + PEFortezzaHeader fortezza; + PEFortezzaGeneratedHeader g_fortezza; + PEFixedKeyHeader fixed; + PERSAKeyHeader rsa; + } u; +}; + +#define PE_CRYPT_INTRO_LEN 8 +#define PE_INTRO_LEN 4 +#define PE_BASE_HEADER_LEN 8 + +#define PRE_BLOCK_SIZE 8 + +#define GetInt2(c) ((c[0] << 8) | c[1]) +#define GetInt4(c) (((unsigned long)c[0] << 24) | ((unsigned long)c[1] << 16) | \ + ((unsigned long)c[2] << 8) | ((unsigned long)c[3])) +#define PutInt2(c, i) ((c[1] = (i)&0xff), (c[0] = ((i) >> 8) & 0xff)) +#define PutInt4(c, i) ((c[0] = ((i) >> 24) & 0xff), (c[1] = ((i) >> 16) & 0xff), \ + (c[2] = ((i) >> 8) & 0xff), (c[3] = (i)&0xff)) + +#define PRE_MAGIC 0xc0de +#define PRE_VERSION 0x1010 +#define PRE_FORTEZZA_FILE 0x00ff +#define PRE_FORTEZZA_STREAM 0x00f5 +#define PRE_FORTEZZA_GEN_STREAM 0x00f6 +#define PRE_FIXED_FILE 0x000f +#define PRE_RSA_FILE 0x001f +#define PRE_FIXED_STREAM 0x0005 + +PEHeader *SSL_PreencryptedStreamToFile(PRFileDesc *fd, PEHeader *, + int *headerSize); + +PEHeader *SSL_PreencryptedFileToStream(PRFileDesc *fd, PEHeader *, + int *headerSize); diff --git a/illumos-x86_64/usr/include/mps/prenv.h b/illumos-x86_64/usr/include/mps/prenv.h new file mode 100644 index 00000000..550f05c9 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prenv.h @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prenv_h___ +#define prenv_h___ + +#include "prtypes.h" + +/*******************************************************************************/ +/*******************************************************************************/ +/****************** THESE FUNCTIONS MAY NOT BE THREAD SAFE *********************/ +/*******************************************************************************/ +/*******************************************************************************/ + +PR_BEGIN_EXTERN_C + +/* +** PR_GetEnv() -- Retrieve value of environment variable +** +** Description: +** PR_GetEnv() is modeled on Unix getenv(). +** +** +** Inputs: +** var -- The name of the environment variable +** +** Returns: +** The value of the environment variable 'var' or NULL if +** the variable is undefined. +** +** Restrictions: +** You'd think that a POSIX getenv(), putenv() would be +** consistently implemented everywhere. Surprise! It is not. On +** some platforms, a putenv() where the argument is of +** the form "name" causes the named environment variable to +** be un-set; that is: a subsequent getenv() returns NULL. On +** other platforms, the putenv() fails, on others, it is a +** no-op. Similarly, a putenv() where the argument is of the +** form "name=" causes the named environment variable to be +** un-set; a subsequent call to getenv() returns NULL. On +** other platforms, a subsequent call to getenv() returns a +** pointer to a null-string (a byte of zero). +** +** PR_GetEnv(), PR_SetEnv() provide a consistent behavior +** across all supported platforms. There are, however, some +** restrictions and some practices you must use to achieve +** consistent results everywhere. +** +** When manipulating the environment there is no way to un-set +** an environment variable across all platforms. We suggest +** you interpret the return of a pointer to null-string to +** mean the same as a return of NULL from PR_GetEnv(). +** +** A call to PR_SetEnv() where the parameter is of the form +** "name" will return PR_FAILURE; the environment remains +** unchanged. A call to PR_SetEnv() where the parameter is +** of the form "name=" may un-set the envrionment variable on +** some platforms; on others it may set the value of the +** environment variable to the null-string. +** +** For example, to test for NULL return or return of the +** null-string from PR_GetEnv(), use the following code +** fragment: +** +** char *val = PR_GetEnv("foo"); +** if ((NULL == val) || ('\0' == *val)) { +** ... interpret this as un-set ... +** } +** +** The caller must ensure that the string passed +** to PR_SetEnv() is persistent. That is: The string should +** not be on the stack, where it can be overwritten +** on return from the function calling PR_SetEnv(). +** Similarly, the string passed to PR_SetEnv() must not be +** overwritten by other actions of the process. ... Some +** platforms use the string by reference rather than copying +** it into the environment space. ... You have been warned! +** +** Use of platform-native functions that manipulate the +** environment (getenv(), putenv(), +** SetEnvironmentVariable(), etc.) must not be used with +** NSPR's similar functions. The platform-native functions +** may not be thread safe and/or may operate on different +** conceptual environment space than that operated upon by +** NSPR's functions or other environment manipulating +** functions on the same platform. (!) +** +*/ +NSPR_API(char*) PR_GetEnv(const char *var); + +/* +** PR_GetEnvSecure() -- get a security-sensitive environment variable +** +** Description: +** +** PR_GetEnvSecure() is similar to PR_GetEnv(), but it returns NULL if +** the program was run with elevated privilege (e.g., setuid or setgid +** on Unix). This can be used for cases like log file paths which +** could otherwise be used for privilege escalation. Note that some +** platforms may have platform-specific privilege elevation mechanisms +** not recognized by this function; see the implementation for details. +*/ +NSPR_API(char*) PR_GetEnvSecure(const char *var); + +/* +** PR_SetEnv() -- set, unset or change an environment variable +** +** Description: +** PR_SetEnv() is modeled on the Unix putenv() function. +** +** Inputs: +** string -- pointer to a caller supplied +** constant, persistent string of the form name=value. Where +** name is the name of the environment variable to be set or +** changed; value is the value assigned to the variable. +** +** Returns: +** PRStatus. +** +** Restrictions: +** See the Restrictions documented in the description of +** PR_GetEnv() in this header file. +** +** +*/ +NSPR_API(PRStatus) PR_SetEnv(const char *string); + +/* +** PR_DuplicateEnvironment() -- Obtain a copy of the environment. +** +** Description: +** PR_DuplicateEnvironment() copies the environment so that it can be +** modified without changing the current process's environment, and +** then passed to interfaces such as POSIX execve(). In particular, +** this avoids needing to allocate memory or take locks in the child +** after a fork(); neither of these is allowed by POSIX after a +** multithreaded process calls fork(), and PR_SetEnv does both. +** +** Inputs: +** none +** +** Returns: +** A pointer to a null-terminated array of null-terminated strings, +** like the traditional global variable "environ". The array and +** the strings are allocated with PR_Malloc(), and it is the +** caller's responsibility to free them. +** +** In case of memory allocation failure, or if the operating system +** doesn't support reading the entire environment through the global +** variable "environ" or similar, returns NULL instead. +** +** Restrictions: +** Similarly to PR_GetEnv(), this function may not interoperate as +** expected with the operating system's native environment accessors. +*/ +NSPR_API(char **) PR_DuplicateEnvironment(void); + +PR_END_EXTERN_C + +#endif /* prenv_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prerr.h b/illumos-x86_64/usr/include/mps/prerr.h new file mode 100644 index 00000000..8512329e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prerr.h @@ -0,0 +1,249 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prerr_h___ +#define prerr_h___ + +/* + * + * prerr.h + * This file is automatically generated; please do not edit it. + */ + +/* Memory allocation attempt failed */ +#define PR_OUT_OF_MEMORY_ERROR (-6000L) + +/* Invalid file descriptor */ +#define PR_BAD_DESCRIPTOR_ERROR (-5999L) + +/* The operation would have blocked */ +#define PR_WOULD_BLOCK_ERROR (-5998L) + +/* Invalid memory address argument */ +#define PR_ACCESS_FAULT_ERROR (-5997L) + +/* Invalid function for file type */ +#define PR_INVALID_METHOD_ERROR (-5996L) + +/* Invalid memory address argument */ +#define PR_ILLEGAL_ACCESS_ERROR (-5995L) + +/* Some unknown error has occurred */ +#define PR_UNKNOWN_ERROR (-5994L) + +/* Operation interrupted by another thread */ +#define PR_PENDING_INTERRUPT_ERROR (-5993L) + +/* function not implemented */ +#define PR_NOT_IMPLEMENTED_ERROR (-5992L) + +/* I/O function error */ +#define PR_IO_ERROR (-5991L) + +/* I/O operation timed out */ +#define PR_IO_TIMEOUT_ERROR (-5990L) + +/* I/O operation on busy file descriptor */ +#define PR_IO_PENDING_ERROR (-5989L) + +/* The directory could not be opened */ +#define PR_DIRECTORY_OPEN_ERROR (-5988L) + +/* Invalid function argument */ +#define PR_INVALID_ARGUMENT_ERROR (-5987L) + +/* Network address not available (in use?) */ +#define PR_ADDRESS_NOT_AVAILABLE_ERROR (-5986L) + +/* Network address type not supported */ +#define PR_ADDRESS_NOT_SUPPORTED_ERROR (-5985L) + +/* Already connected */ +#define PR_IS_CONNECTED_ERROR (-5984L) + +/* Network address is invalid */ +#define PR_BAD_ADDRESS_ERROR (-5983L) + +/* Local Network address is in use */ +#define PR_ADDRESS_IN_USE_ERROR (-5982L) + +/* Connection refused by peer */ +#define PR_CONNECT_REFUSED_ERROR (-5981L) + +/* Network address is presently unreachable */ +#define PR_NETWORK_UNREACHABLE_ERROR (-5980L) + +/* Connection attempt timed out */ +#define PR_CONNECT_TIMEOUT_ERROR (-5979L) + +/* Network file descriptor is not connected */ +#define PR_NOT_CONNECTED_ERROR (-5978L) + +/* Failure to load dynamic library */ +#define PR_LOAD_LIBRARY_ERROR (-5977L) + +/* Failure to unload dynamic library */ +#define PR_UNLOAD_LIBRARY_ERROR (-5976L) + +/* Symbol not found in any of the loaded dynamic libraries */ +#define PR_FIND_SYMBOL_ERROR (-5975L) + +/* Insufficient system resources */ +#define PR_INSUFFICIENT_RESOURCES_ERROR (-5974L) + +/* A directory lookup on a network address has failed */ +#define PR_DIRECTORY_LOOKUP_ERROR (-5973L) + +/* Attempt to access a TPD key that is out of range */ +#define PR_TPD_RANGE_ERROR (-5972L) + +/* Process open FD table is full */ +#define PR_PROC_DESC_TABLE_FULL_ERROR (-5971L) + +/* System open FD table is full */ +#define PR_SYS_DESC_TABLE_FULL_ERROR (-5970L) + +/* Network operation attempted on non-network file descriptor */ +#define PR_NOT_SOCKET_ERROR (-5969L) + +/* TCP-specific function attempted on a non-TCP file descriptor */ +#define PR_NOT_TCP_SOCKET_ERROR (-5968L) + +/* TCP file descriptor is already bound */ +#define PR_SOCKET_ADDRESS_IS_BOUND_ERROR (-5967L) + +/* Access Denied */ +#define PR_NO_ACCESS_RIGHTS_ERROR (-5966L) + +/* The requested operation is not supported by the platform */ +#define PR_OPERATION_NOT_SUPPORTED_ERROR (-5965L) + +/* The host operating system does not support the protocol requested */ +#define PR_PROTOCOL_NOT_SUPPORTED_ERROR (-5964L) + +/* Access to the remote file has been severed */ +#define PR_REMOTE_FILE_ERROR (-5963L) + +/* The value requested is too large to be stored in the data buffer provided */ +#define PR_BUFFER_OVERFLOW_ERROR (-5962L) + +/* TCP connection reset by peer */ +#define PR_CONNECT_RESET_ERROR (-5961L) + +/* Unused */ +#define PR_RANGE_ERROR (-5960L) + +/* The operation would have deadlocked */ +#define PR_DEADLOCK_ERROR (-5959L) + +/* The file is already locked */ +#define PR_FILE_IS_LOCKED_ERROR (-5958L) + +/* Write would result in file larger than the system allows */ +#define PR_FILE_TOO_BIG_ERROR (-5957L) + +/* The device for storing the file is full */ +#define PR_NO_DEVICE_SPACE_ERROR (-5956L) + +/* Unused */ +#define PR_PIPE_ERROR (-5955L) + +/* Unused */ +#define PR_NO_SEEK_DEVICE_ERROR (-5954L) + +/* Cannot perform a normal file operation on a directory */ +#define PR_IS_DIRECTORY_ERROR (-5953L) + +/* Symbolic link loop */ +#define PR_LOOP_ERROR (-5952L) + +/* File name is too long */ +#define PR_NAME_TOO_LONG_ERROR (-5951L) + +/* File not found */ +#define PR_FILE_NOT_FOUND_ERROR (-5950L) + +/* Cannot perform directory operation on a normal file */ +#define PR_NOT_DIRECTORY_ERROR (-5949L) + +/* Cannot write to a read-only file system */ +#define PR_READ_ONLY_FILESYSTEM_ERROR (-5948L) + +/* Cannot delete a directory that is not empty */ +#define PR_DIRECTORY_NOT_EMPTY_ERROR (-5947L) + +/* Cannot delete or rename a file object while the file system is busy */ +#define PR_FILESYSTEM_MOUNTED_ERROR (-5946L) + +/* Cannot rename a file to a file system on another device */ +#define PR_NOT_SAME_DEVICE_ERROR (-5945L) + +/* The directory object in the file system is corrupted */ +#define PR_DIRECTORY_CORRUPTED_ERROR (-5944L) + +/* Cannot create or rename a filename that already exists */ +#define PR_FILE_EXISTS_ERROR (-5943L) + +/* Directory is full. No additional filenames may be added */ +#define PR_MAX_DIRECTORY_ENTRIES_ERROR (-5942L) + +/* The required device was in an invalid state */ +#define PR_INVALID_DEVICE_STATE_ERROR (-5941L) + +/* The device is locked */ +#define PR_DEVICE_IS_LOCKED_ERROR (-5940L) + +/* No more entries in the directory */ +#define PR_NO_MORE_FILES_ERROR (-5939L) + +/* Encountered end of file */ +#define PR_END_OF_FILE_ERROR (-5938L) + +/* Seek error */ +#define PR_FILE_SEEK_ERROR (-5937L) + +/* The file is busy */ +#define PR_FILE_IS_BUSY_ERROR (-5936L) + +/* The I/O operation was aborted */ +#define PR_OPERATION_ABORTED_ERROR (-5935L) + +/* Operation is still in progress (probably a non-blocking connect) */ +#define PR_IN_PROGRESS_ERROR (-5934L) + +/* Operation has already been initiated (probably a non-blocking connect) */ +#define PR_ALREADY_INITIATED_ERROR (-5933L) + +/* The wait group is empty */ +#define PR_GROUP_EMPTY_ERROR (-5932L) + +/* Object state improper for request */ +#define PR_INVALID_STATE_ERROR (-5931L) + +/* Network is down */ +#define PR_NETWORK_DOWN_ERROR (-5930L) + +/* Socket shutdown */ +#define PR_SOCKET_SHUTDOWN_ERROR (-5929L) + +/* Connection aborted */ +#define PR_CONNECT_ABORTED_ERROR (-5928L) + +/* Host is unreachable */ +#define PR_HOST_UNREACHABLE_ERROR (-5927L) + +/* The library is not loaded */ +#define PR_LIBRARY_NOT_LOADED_ERROR (-5926L) + +/* The one-time function was previously called and failed. Its error code is no longer available */ +#define PR_CALL_ONCE_ERROR (-5925L) + +/* Placeholder for the end of the list */ +#define PR_MAX_ERROR (-5924L) + +extern void nspr_InitializePRErrorTable(void); +#define ERROR_TABLE_BASE_nspr (-6000L) + +#endif /* prerr_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prerror.h b/illumos-x86_64/usr/include/mps/prerror.h new file mode 100644 index 00000000..f445aa90 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prerror.h @@ -0,0 +1,294 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prerror_h___ +#define prerror_h___ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +typedef PRInt32 PRErrorCode; + +#define PR_NSPR_ERROR_BASE -6000 + +#include "prerr.h" + +/* +** Set error will preserve an error condition within a thread context. +** The values stored are the NSPR (platform independent) translation of +** the error. Also, if available, the platform specific oserror is stored. +** If there is no appropriate OS error number, a zero my be supplied. +*/ +NSPR_API(void) PR_SetError(PRErrorCode errorCode, PRInt32 oserr); + +/* +** The text value specified may be NULL. If it is not NULL and the text length +** is zero, the string is assumed to be a null terminated C string. Otherwise +** the text is assumed to be the length specified and possibly include NULL +** characters (e.g., a multi-national string). +** +** The text will be copied into to thread structure and remain there +** until the next call to PR_SetError. +*/ +NSPR_API(void) PR_SetErrorText( + PRIntn textLength, const char *text); + +/* +** Return the current threads last set error code. +*/ +NSPR_API(PRErrorCode) PR_GetError(void); + +/* +** Return the current threads last set os error code. This is used for +** machine specific code that desires the underlying os error. +*/ +NSPR_API(PRInt32) PR_GetOSError(void); + +/* +** Get the length of the error text. If a zero is returned, then there +** is no text. Otherwise, the value returned is sufficient to contain +** the error text currently available. +*/ +NSPR_API(PRInt32) PR_GetErrorTextLength(void); + +/* +** Copy the current threads current error text. Then actual number of bytes +** copied is returned as the result. If the result is zero, the 'text' area +** is unaffected. +*/ +NSPR_API(PRInt32) PR_GetErrorText(char *text); + + +/* +Copyright (C) 1987, 1988 Student Information Processing Board of the +Massachusetts Institute of Technology. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided +that the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation, and that the names of M.I.T. and the M.I.T. S.I.P.B. not be +used in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. M.I.T. and the M.I.T. S.I.P.B. +make no representations about the suitability of this software for any +purpose. It is provided "as is" without express or implied warranty. +*/ + + +/* + * NOTE: + * The interfaces for error-code-translation described in the rest of + * this file are preliminary in the 3.1 release of nspr and are subject + * to change in future releases. + */ + +/* +** Description: Localizable error code to string function. +** +** +** NSPR provides a mechanism for converting an error code to a +** descriptive string, in a caller-specified language. +** +** Error codes themselves are 32 bit (signed) integers. Typically, +** the high order 24 bits are an identifier of which error table the +** error code is from, and the low order 8 bits are a sequential error +** number within the table. NSPR supports error tables whose first +** error code is not a multiple of 256, such error code assignments +** should be avoided when possible. +** +** Error table 0 is defined to match the UNIX system call error table +** (sys_errlist); this allows errno values to be used directly in the +** library. Other error table numbers are typically formed by +** compacting together the first four characters of the error table +** name. The mapping between characters in the name and numeric +** values in the error code are defined in a system-independent +** fashion, so that two systems that can pass integral values between +** them can reliably pass error codes without loss of meaning; this +** should work even if the character sets used are not the +** same. (However, if this is to be done, error table 0 should be +** avoided, since the local system call error tables may differ.) +** +** Libraries defining error codes need only provide a table mapping +** error code numbers to names and default English descriptions, +** calling a routine to install the table, making it ``known'' to NSPR +** library. Once installed, a table may not be removed. Any error +** code the library generates can be converted to the corresponding +** error message. There is also a default format for error codes +** accidentally returned before making the table known, which is of +** the form "unknown code foo 32", where "foo" would be the name of +** the table. +** +** Normally, the error code conversion routine only supports the +** languages "i-default" and "en", returning the error-table-provided +** English description for both languages. The application may +** provide a localization plugin, allowing support for additional +** languages. +** +**/ + +/**********************************************************************/ +/************************* TYPES AND CONSTANTS ************************/ +/**********************************************************************/ + +/* + * PRLanguageCode -- + * + * NSPR represents a language code as a non-negative integer. + * Languages 0 is always "i-default" the language you get without + * explicit negotiation. Language 1 is always "en", English + * which has been explicitly negotiated. Additional language + * codes are defined by an application-provided localization plugin. + */ +typedef PRUint32 PRLanguageCode; +#define PR_LANGUAGE_I_DEFAULT 0 /* i-default, the default language */ +#define PR_LANGUAGE_EN 1 /* English, explicitly negotiated */ + +/* + * struct PRErrorMessage -- + * + * An error message in an error table. + */ +struct PRErrorMessage { + const char * name; /* Macro name for error */ + const char * en_text; /* Default English text */ +}; + +/* + * struct PRErrorTable -- + * + * An error table, provided by a library. + */ +struct PRErrorTable { + const struct PRErrorMessage * msgs; /* Array of error information */ + const char *name; /* Name of error table source */ + PRErrorCode base; /* Error code for first error in table */ + int n_msgs; /* Number of codes in table */ +}; + +/* + * struct PRErrorCallbackPrivate -- + * + * A private structure for the localization plugin + */ +struct PRErrorCallbackPrivate; + +/* + * struct PRErrorCallbackTablePrivate -- + * + * A data structure under which the localization plugin may store information, + * associated with an error table, that is private to itself. + */ +struct PRErrorCallbackTablePrivate; + +/* + * PRErrorCallbackLookupFn -- + * + * A function of PRErrorCallbackLookupFn type is a localization + * plugin callback which converts an error code into a description + * in the requested language. The callback is provided the + * appropriate error table, private data for the plugin and the table. + * The callback returns the appropriate UTF-8 encoded description, or NULL + * if no description can be found. + */ +typedef const char * +PRErrorCallbackLookupFn(PRErrorCode code, PRLanguageCode language, + const struct PRErrorTable *table, + struct PRErrorCallbackPrivate *cb_private, + struct PRErrorCallbackTablePrivate *table_private); + +/* + * PRErrorCallbackNewTableFn -- + * + * A function PRErrorCallbackNewTableFn type is a localization plugin + * callback which is called once with each error table registered + * with NSPR. The callback is provided with the error table and + * the plugin's private structure. The callback returns any table private + * data it wishes to associate with the error table. Does not need to be thread + * safe. + */ +typedef struct PRErrorCallbackTablePrivate * +PRErrorCallbackNewTableFn(const struct PRErrorTable *table, + struct PRErrorCallbackPrivate *cb_private); + +/**********************************************************************/ +/****************************** FUNCTIONS *****************************/ +/**********************************************************************/ + +/*********************************************************************** +** FUNCTION: PR_ErrorToString +** DESCRIPTION: +** Returns the UTF-8 message for an error code in +** the requested language. May return the message +** in the default language if a translation in the requested +** language is not available. The returned string is +** valid for the duration of the process. Never returns NULL. +** +***********************************************************************/ +NSPR_API(const char *) PR_ErrorToString(PRErrorCode code, + PRLanguageCode language); + + +/*********************************************************************** +** FUNCTION: PR_ErrorToName +** DESCRIPTION: +** Returns the macro name for an error code, or NULL +** if the error code is not known. The returned string is +** valid for the duration of the process. +** +** Does not work for error table 0, the system error codes. +** +***********************************************************************/ +NSPR_API(const char *) PR_ErrorToName(PRErrorCode code); + + +/*********************************************************************** +** FUNCTION: PR_ErrorLanguages +** DESCRIPTION: +** Returns the RFC 1766 language tags for the language +** codes PR_ErrorToString() supports. The returned array is valid +** for the duration of the process. Never returns NULL. The first +** item in the returned array is the language tag for PRLanguageCode 0, +** the second is for PRLanguageCode 1, and so on. The array is terminated +** with a null pointer. +** +***********************************************************************/ +NSPR_API(const char * const *) PR_ErrorLanguages(void); + + +/*********************************************************************** +** FUNCTION: PR_ErrorInstallTable +** DESCRIPTION: +** Registers an error table with NSPR. Must be done exactly once per +** table. Memory pointed to by `table' must remain valid for the life +** of the process. +** +** NOT THREAD SAFE! +** +***********************************************************************/ +NSPR_API(PRErrorCode) PR_ErrorInstallTable(const struct PRErrorTable *table); + + +/*********************************************************************** +** FUNCTION: PR_ErrorInstallCallback +** DESCRIPTION: +** Registers an error localization plugin with NSPR. May be called +** at most one time. `languages' contains the language codes supported +** by this plugin. Languages 0 and 1 must be "i-default" and "en" +** respectively. `lookup' and `newtable' contain pointers to +** the plugin callback functions. `cb_private' contains any information +** private to the plugin functions. +** +** NOT THREAD SAFE! +** +***********************************************************************/ +NSPR_API(void) PR_ErrorInstallCallback(const char * const * languages, + PRErrorCallbackLookupFn *lookup, + PRErrorCallbackNewTableFn *newtable, + struct PRErrorCallbackPrivate *cb_private); + +PR_END_EXTERN_C + +#endif /* prerror_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prinet.h b/illumos-x86_64/usr/include/mps/prinet.h new file mode 100644 index 00000000..ffa4f916 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prinet.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * File: prinet.h + * Description: + * Header file used to find the system header files for socket support[1]. + * This file serves the following purposes: + * - A cross-platform, "get-everything" socket header file. On + * Unix, socket support is scattered in several header files, + * while Windows has a "get-everything" socket header file[2]. + * - NSPR needs the following macro definitions and function + * prototype declarations from these header files: + * AF_INET + * INADDR_ANY, INADDR_LOOPBACK, INADDR_BROADCAST + * ntohl(), ntohs(), htonl(), ntons(). + * NSPR does not define its own versions of these macros and + * functions. It simply uses the native versions, which have + * the same names on all supported platforms. + * This file is intended to be included by NSPR public header + * files, such as prio.h. One should not include this file directly. + * + * Notes: + * 1. This file should have been an internal header. Please do not + * depend on it to pull in the system header files you need. + * 2. WARNING: This file is no longer cross-platform as it is a no-op + * for WIN32! See the comment in the WIN32 section for details. + */ + +#ifndef prinet_h__ +#define prinet_h__ + +#if defined(XP_UNIX) +#include +#include /* AF_INET */ +#include /* INADDR_ANY, ..., ntohl(), ... */ +#ifdef XP_UNIX +#ifdef AIX +/* + * On AIX 4.3, the header refers to struct + * ether_addr and struct sockaddr_dl that are not declared. + * The following struct declarations eliminate the compiler + * warnings. + */ +struct ether_addr; +struct sockaddr_dl; +#endif /* AIX */ +#include +#endif /* XP_UNIX */ +#include + +#if defined(QNX) +#include /* the only place that defines INADDR_LOOPBACK */ +#endif + +/* + * OS/2 hack. For some reason INADDR_LOOPBACK is not defined in the + * socket headers. + */ +#if !defined(INADDR_LOOPBACK) +#define INADDR_LOOPBACK 0x7f000001 +#endif + +/* On Android, ntohl() etc. are declared in . */ +#ifdef __ANDROID__ +#include +#endif + +#elif defined(WIN32) + +/* + * Do not include any system header files. + * + * Originally we were including . It slowed down the + * compilation of files that included NSPR headers, so we removed + * the inclusion at customer's request, which created + * an unfortunate inconsistency with other platforms. + */ + +#else + +#error Unknown platform + +#endif + +#endif /* prinet_h__ */ diff --git a/illumos-x86_64/usr/include/mps/prinit.h b/illumos-x86_64/usr/include/mps/prinit.h new file mode 100644 index 00000000..2bc72a11 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prinit.h @@ -0,0 +1,214 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prinit_h___ +#define prinit_h___ + +#include "prthread.h" +#include "prtypes.h" +#include + +PR_BEGIN_EXTERN_C + +/************************************************************************/ +/**************************IDENTITY AND VERSIONING***********************/ +/************************************************************************/ + +/* +** NSPR's name, this should persist until at least the turn of the +** century. +*/ +#define PR_NAME "NSPR" + +/* +** NSPR's version is used to determine the likelihood that the version you +** used to build your component is anywhere close to being compatible with +** what is in the underlying library. +** +** The format of the version string is +** ".[.] []" +*/ +#define PR_VERSION "4.37" +#define PR_VMAJOR 4 +#define PR_VMINOR 37 +#define PR_VPATCH 0 +#define PR_BETA PR_FALSE + +/* +** PRVersionCheck +** +** The basic signature of the function that is called to provide version +** checking. The result will be a boolean that indicates the likelihood +** that the underling library will perform as the caller expects. +** +** The only argument is a string, which should be the verson identifier +** of the library in question. That string will be compared against an +** equivalent string that represents the actual build version of the +** exporting library. +** +** The result will be the logical union of the directly called library +** and all dependent libraries. +*/ + +typedef PRBool (*PRVersionCheck)(const char*); + +/* +** PR_VersionCheck +** +** NSPR's existance proof of the version check function. +** +** Note that NSPR has no cooperating dependencies. +*/ + +NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion); + +/* + * Returns a const string of the NSPR library version. + */ +NSPR_API(const char*) PR_GetVersion(void); + + +/************************************************************************/ +/*******************************INITIALIZATION***************************/ +/************************************************************************/ + +/* +** Initialize the runtime. Attach a thread object to the currently +** executing native thread of type "type". +** +** The specificaiton of 'maxPTDs' is ignored. +*/ +NSPR_API(void) PR_Init( + PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs); + +/* +** And alternate form of initialization, one that may become the default if +** not the only mechanism, provides a method to get the NSPR runtime init- +** ialized and place NSPR between the caller and the runtime library. This +** allows main() to be treated as any other thread root function, signalling +** its compeletion by returning and allowing the runtime to coordinate the +** completion of the other threads of the runtime. +** +** The priority of the main (or primordial) thread will be PR_PRIORITY_NORMAL. +** The thread may adjust its own priority by using PR_SetPriority(), though +** at this time the support for priorities is somewhat weak. +** +** The specificaiton of 'maxPTDs' is ignored. +** +** The value returned by PR_Initialize is the value returned from the root +** function, 'prmain'. +*/ + +typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv); + +NSPR_API(PRIntn) PR_Initialize( + PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs); + +/* +** Return PR_TRUE if PR_Init has already been called. +*/ +NSPR_API(PRBool) PR_Initialized(void); + +/* + * Perform a graceful shutdown of NSPR. PR_Cleanup() may be called by + * the primordial thread near the end of the main() function. + * + * PR_Cleanup() attempts to synchronize the natural termination of + * process. It does that by blocking the caller, if and only if it is + * the primordial thread, until the number of user threads has dropped + * to zero. When the primordial thread returns from main(), the process + * will immediately and silently exit. That is, it will (if necessary) + * forcibly terminate any existing threads and exit without significant + * blocking and there will be no error messages or core files. + * + * PR_Cleanup() returns PR_SUCCESS if NSPR is successfully shutdown, + * or PR_FAILURE if the calling thread of this function is not the + * primordial thread. + */ +NSPR_API(PRStatus) PR_Cleanup(void); + +/* +** Disable Interrupts +** Disables timer signals used for pre-emptive scheduling. +*/ +NSPR_API(void) PR_DisableClockInterrupts(void); + +/* +** Enables Interrupts +** Enables timer signals used for pre-emptive scheduling. +*/ +NSPR_API(void) PR_EnableClockInterrupts(void); + +/* +** Block Interrupts +** Blocks the timer signal used for pre-emptive scheduling +*/ +NSPR_API(void) PR_BlockClockInterrupts(void); + +/* +** Unblock Interrupts +** Unblocks the timer signal used for pre-emptive scheduling +*/ +NSPR_API(void) PR_UnblockClockInterrupts(void); + +/* +** Create extra virtual processor threads. Generally used with MP systems. +*/ +NSPR_API(void) PR_SetConcurrency(PRUintn numCPUs); + +/* +** Control the method and size of the file descriptor (PRFileDesc*) +** cache used by the runtime. Setting 'high' to zero is for performance, +** any other value probably for debugging (see memo on FD caching). +*/ +NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high); + +/* + * Cause an immediate, nongraceful, forced termination of the process. + * It takes a PRIntn argument, which is the exit status code of the + * process. + */ +NSPR_API(void) PR_ProcessExit(PRIntn status); + +/* +** Abort the process in a non-graceful manner. This will cause a core file, +** call to the debugger or other moral equivalent as well as causing the +** entire process to stop. +*/ +NSPR_API(void) PR_Abort(void); + +/* + **************************************************************** + * + * Module initialization: + * + **************************************************************** + */ + +typedef struct PRCallOnceType { + PRIntn initialized; + PRInt32 inProgress; + PRStatus status; +} PRCallOnceType; + +typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void); + +typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg); + +NSPR_API(PRStatus) PR_CallOnce( + PRCallOnceType *once, + PRCallOnceFN func +); + +NSPR_API(PRStatus) PR_CallOnceWithArg( + PRCallOnceType *once, + PRCallOnceWithArgFN func, + void *arg +); + + +PR_END_EXTERN_C + +#endif /* prinit_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prinrval.h b/illumos-x86_64/usr/include/mps/prinrval.h new file mode 100644 index 00000000..7797291d --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prinrval.h @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: prinrval.h +** Description: API to interval timing functions of NSPR. +** +** +** NSPR provides interval times that are independent of network time +** of day values. Interval times are (in theory) accurate regardless +** of host processing requirements and also very cheap to acquire. It +** is expected that getting an interval time while in a synchronized +** function (holding one's lock). +**/ + +#if !defined(prinrval_h) +#define prinrval_h + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/**********************************************************************/ +/************************* TYPES AND CONSTANTS ************************/ +/**********************************************************************/ + +typedef PRUint32 PRIntervalTime; + +/*********************************************************************** +** DEFINES: PR_INTERVAL_MIN +** PR_INTERVAL_MAX +** DESCRIPTION: +** These two constants define the range (in ticks / second) of the +** platform dependent type, PRIntervalTime. These constants bound both +** the period and the resolution of a PRIntervalTime. +***********************************************************************/ +#define PR_INTERVAL_MIN 1000UL +#define PR_INTERVAL_MAX 100000UL + +/*********************************************************************** +** DEFINES: PR_INTERVAL_NO_WAIT +** PR_INTERVAL_NO_TIMEOUT +** DESCRIPTION: +** Two reserved constants are defined in the PRIntervalTime namespace. +** They are used to indicate that the process should wait no time (return +** immediately) or wait forever (never time out), respectively. +** Note: PR_INTERVAL_NO_TIMEOUT passed as input to PR_Connect is +** interpreted as use the OS's connect timeout. +** +***********************************************************************/ +#define PR_INTERVAL_NO_WAIT 0UL +#define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL + +/**********************************************************************/ +/****************************** FUNCTIONS *****************************/ +/**********************************************************************/ + +/*********************************************************************** +** FUNCTION: PR_IntervalNow +** DESCRIPTION: +** Return the value of NSPR's free running interval timer. That timer +** can be used to establish epochs and determine intervals (be computing +** the difference between two times). +** INPUTS: void +** OUTPUTS: void +** RETURN: PRIntervalTime +** +** SIDE EFFECTS: +** None +** RESTRICTIONS: +** The units of PRIntervalTime are platform dependent. They are chosen +** such that they are appropriate for the host OS, yet provide sufficient +** resolution and period to be useful to clients. +** MEMORY: N/A +** ALGORITHM: Platform dependent +***********************************************************************/ +NSPR_API(PRIntervalTime) PR_IntervalNow(void); + +/*********************************************************************** +** FUNCTION: PR_TicksPerSecond +** DESCRIPTION: +** Return the number of ticks per second for PR_IntervalNow's clock. +** The value will be in the range [PR_INTERVAL_MIN..PR_INTERVAL_MAX]. +** INPUTS: void +** OUTPUTS: void +** RETURN: PRUint32 +** +** SIDE EFFECTS: +** None +** RESTRICTIONS: +** None +** MEMORY: N/A +** ALGORITHM: N/A +***********************************************************************/ +NSPR_API(PRUint32) PR_TicksPerSecond(void); + +/*********************************************************************** +** FUNCTION: PR_SecondsToInterval +** PR_MillisecondsToInterval +** PR_MicrosecondsToInterval +** DESCRIPTION: +** Convert standard clock units to platform dependent intervals. +** INPUTS: PRUint32 +** OUTPUTS: void +** RETURN: PRIntervalTime +** +** SIDE EFFECTS: +** None +** RESTRICTIONS: +** Conversion may cause overflow, which is not reported. +** MEMORY: N/A +** ALGORITHM: N/A +***********************************************************************/ +NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds); +NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli); +NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro); + +/*********************************************************************** +** FUNCTION: PR_IntervalToSeconds +** PR_IntervalToMilliseconds +** PR_IntervalToMicroseconds +** DESCRIPTION: +** Convert platform dependent intervals to standard clock units. +** INPUTS: PRIntervalTime +** OUTPUTS: void +** RETURN: PRUint32 +** +** SIDE EFFECTS: +** None +** RESTRICTIONS: +** Conversion may cause overflow, which is not reported. +** MEMORY: N/A +** ALGORITHM: N/A +***********************************************************************/ +NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks); +NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks); +NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks); + +PR_END_EXTERN_C + + +#endif /* !defined(prinrval_h) */ + +/* prinrval.h */ diff --git a/illumos-x86_64/usr/include/mps/prio.h b/illumos-x86_64/usr/include/mps/prio.h new file mode 100644 index 00000000..f726d476 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prio.h @@ -0,0 +1,2011 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * File: prio.h + * + * Description: PR i/o related stuff, such as file system access, file + * i/o, socket i/o, etc. + */ + +#ifndef prio_h___ +#define prio_h___ + +#include "prlong.h" +#include "prtime.h" +#include "prinrval.h" +#include "prinet.h" + +PR_BEGIN_EXTERN_C + +/* Typedefs */ +typedef struct PRDir PRDir; +typedef struct PRDirEntry PRDirEntry; +#ifdef MOZ_UNICODE +typedef struct PRDirUTF16 PRDirUTF16; +typedef struct PRDirEntryUTF16 PRDirEntryUTF16; +#endif /* MOZ_UNICODE */ +typedef struct PRFileDesc PRFileDesc; +typedef struct PRFileInfo PRFileInfo; +typedef struct PRFileInfo64 PRFileInfo64; +typedef union PRNetAddr PRNetAddr; +typedef struct PRIOMethods PRIOMethods; +typedef struct PRPollDesc PRPollDesc; +typedef struct PRFilePrivate PRFilePrivate; +typedef struct PRSendFileData PRSendFileData; + +/* +*************************************************************************** +** The file descriptor. +** This is the primary structure to represent any active open socket, +** whether it be a normal file or a network connection. Such objects +** are stackable (or layerable). Each layer may have its own set of +** method pointers and context private to that layer. All each layer +** knows about its neighbors is how to get to their method table. +*************************************************************************** +*/ + +typedef PRIntn PRDescIdentity; /* see: Layering file descriptors */ + +struct PRFileDesc { + const PRIOMethods *methods; /* the I/O methods table */ + PRFilePrivate *secret; /* layer dependent data */ + PRFileDesc *lower, *higher; /* pointers to adjacent layers */ + void (PR_CALLBACK *dtor)(PRFileDesc *fd); + /* A destructor function for layer */ + PRDescIdentity identity; /* Identity of this particular layer */ +}; + +/* +*************************************************************************** +** PRTransmitFileFlags +** +** Flags for PR_TransmitFile. Pass PR_TRANSMITFILE_CLOSE_SOCKET to +** PR_TransmitFile if the connection should be closed after the file +** is transmitted. +*************************************************************************** +*/ +typedef enum PRTransmitFileFlags { + PR_TRANSMITFILE_KEEP_OPEN = 0, /* socket is left open after file + * is transmitted. */ + PR_TRANSMITFILE_CLOSE_SOCKET = 1 /* socket is closed after file + * is transmitted. */ +} PRTransmitFileFlags; + +/* +************************************************************************** +** Macros for PRNetAddr +** +** Address families: PR_AF_INET, PR_AF_INET6, PR_AF_LOCAL +** IP addresses: PR_INADDR_ANY, PR_INADDR_LOOPBACK, PR_INADDR_BROADCAST +************************************************************************** +*/ + +#ifdef WIN32 + +#define PR_AF_INET 2 +#define PR_AF_LOCAL 1 +#define PR_INADDR_ANY (unsigned long)0x00000000 +#define PR_INADDR_LOOPBACK 0x7f000001 +#define PR_INADDR_BROADCAST (unsigned long)0xffffffff + +#else /* WIN32 */ + +#define PR_AF_INET AF_INET +#define PR_AF_LOCAL AF_UNIX +#define PR_INADDR_ANY INADDR_ANY +#define PR_INADDR_LOOPBACK INADDR_LOOPBACK +#define PR_INADDR_BROADCAST INADDR_BROADCAST + +#endif /* WIN32 */ + +/* +** Define PR_AF_INET6 in prcpucfg.h with the same +** value as AF_INET6 on platforms with IPv6 support. +** Otherwise define it here. +*/ +#ifndef PR_AF_INET6 +#define PR_AF_INET6 100 +#endif + +#define PR_AF_INET_SDP 101 +#define PR_AF_INET6_SDP 102 + +#ifndef PR_AF_UNSPEC +#define PR_AF_UNSPEC 0 +#endif + +/* +************************************************************************** +** A network address +** +** Only Internet Protocol (IPv4 and IPv6) addresses are supported. +** The address family must always represent IPv4 (AF_INET, probably == 2) +** or IPv6 (AF_INET6). +************************************************************************** +*************************************************************************/ + +struct PRIPv6Addr { + union { + PRUint8 _S6_u8[16]; + PRUint16 _S6_u16[8]; + PRUint32 _S6_u32[4]; + PRUint64 _S6_u64[2]; + } _S6_un; +}; +#define pr_s6_addr _S6_un._S6_u8 +#define pr_s6_addr16 _S6_un._S6_u16 +#define pr_s6_addr32 _S6_un._S6_u32 +#define pr_s6_addr64 _S6_un._S6_u64 + +typedef struct PRIPv6Addr PRIPv6Addr; + +union PRNetAddr { + struct { + PRUint16 family; /* address family (0x00ff maskable) */ + char data[14]; /* raw address data */ + } raw; + struct { + PRUint16 family; /* address family (AF_INET) */ + PRUint16 port; /* port number */ + PRUint32 ip; /* The actual 32 bits of address */ + char pad[8]; + } inet; + struct { + PRUint16 family; /* address family (AF_INET6) */ + PRUint16 port; /* port number */ + PRUint32 flowinfo; /* routing information */ + PRIPv6Addr ip; /* the actual 128 bits of address */ + PRUint32 scope_id; /* set of interfaces for a scope */ + } ipv6; +#if defined(XP_UNIX) || defined(XP_WIN) + struct { /* Unix domain socket address */ + PRUint16 family; /* address family (AF_UNIX) */ + char path[104]; /* null-terminated pathname */ + } local; +#endif +}; + +/* +*************************************************************************** +** PRSockOption +** +** The file descriptors can have predefined options set after they file +** descriptor is created to change their behavior. Only the options in +** the following enumeration are supported. +*************************************************************************** +*/ +typedef enum PRSockOption +{ + PR_SockOpt_Nonblocking, /* nonblocking io */ + PR_SockOpt_Linger, /* linger on close if data present */ + PR_SockOpt_Reuseaddr, /* allow local address reuse */ + PR_SockOpt_Keepalive, /* keep connections alive */ + PR_SockOpt_RecvBufferSize, /* receive buffer size */ + PR_SockOpt_SendBufferSize, /* send buffer size */ + + PR_SockOpt_IpTimeToLive, /* time to live */ + PR_SockOpt_IpTypeOfService, /* type of service and precedence */ + + PR_SockOpt_AddMember, /* add an IP group membership */ + PR_SockOpt_DropMember, /* drop an IP group membership */ + PR_SockOpt_McastInterface, /* multicast interface address */ + PR_SockOpt_McastTimeToLive, /* multicast timetolive */ + PR_SockOpt_McastLoopback, /* multicast loopback */ + + PR_SockOpt_NoDelay, /* don't delay send to coalesce packets */ + PR_SockOpt_MaxSegment, /* maximum segment size */ + PR_SockOpt_Broadcast, /* enable broadcast */ + PR_SockOpt_Reuseport, /* allow local address & port reuse on + * platforms that support it */ + PR_SockOpt_DontFrag, /* Do not fragment flag */ + PR_SockOpt_Last +} PRSockOption; + +typedef struct PRLinger { + PRBool polarity; /* Polarity of the option's setting */ + PRIntervalTime linger; /* Time to linger before closing */ +} PRLinger; + +typedef struct PRMcastRequest { + PRNetAddr mcaddr; /* IP multicast address of group */ + PRNetAddr ifaddr; /* local IP address of interface */ +} PRMcastRequest; + +typedef struct PRSocketOptionData +{ + PRSockOption option; + union + { + PRUintn ip_ttl; /* IP time to live */ + PRUintn mcast_ttl; /* IP multicast time to live */ + PRUintn tos; /* IP type of service and precedence */ + PRBool non_blocking; /* Non-blocking (network) I/O */ + PRBool reuse_addr; /* Allow local address reuse */ + PRBool reuse_port; /* Allow local address & port reuse on + * platforms that support it */ + PRBool dont_fragment; /* Do not fragment flag */ + PRBool keep_alive; /* Keep connections alive */ + PRBool mcast_loopback; /* IP multicast loopback */ + PRBool no_delay; /* Don't delay send to coalesce packets */ + PRBool broadcast; /* Enable broadcast */ + PRSize max_segment; /* Maximum segment size */ + PRSize recv_buffer_size; /* Receive buffer size */ + PRSize send_buffer_size; /* Send buffer size */ + PRLinger linger; /* Time to linger on close if data present */ + PRMcastRequest add_member; /* add an IP group membership */ + PRMcastRequest drop_member; /* Drop an IP group membership */ + PRNetAddr mcast_if; /* multicast interface address */ + } value; +} PRSocketOptionData; + +/* +*************************************************************************** +** PRIOVec +** +** The I/O vector is used by the write vector method to describe the areas +** that are affected by the ouput operation. +*************************************************************************** +*/ +typedef struct PRIOVec { + char *iov_base; + int iov_len; +} PRIOVec; + +/* +*************************************************************************** +** Discover what type of socket is being described by the file descriptor. +*************************************************************************** +*/ +typedef enum PRDescType +{ + PR_DESC_FILE = 1, + PR_DESC_SOCKET_TCP = 2, + PR_DESC_SOCKET_UDP = 3, + PR_DESC_LAYERED = 4, + PR_DESC_PIPE = 5 +} PRDescType; + +typedef enum PRSeekWhence { + PR_SEEK_SET = 0, + PR_SEEK_CUR = 1, + PR_SEEK_END = 2 +} PRSeekWhence; + +NSPR_API(PRDescType) PR_GetDescType(PRFileDesc *file); + +/* +*************************************************************************** +** PRIOMethods +** +** The I/O methods table provides procedural access to the functions of +** the file descriptor. It is the responsibility of a layer implementor +** to provide suitable functions at every entry point. If a layer provides +** no functionality, it should call the next lower(higher) function of the +** same name (e.g., return fd->lower->method->close(fd->lower)); +** +** Not all functions are implemented for all types of files. In cases where +** that is true, the function will return a error indication with an error +** code of PR_INVALID_METHOD_ERROR. +*************************************************************************** +*/ + +typedef PRStatus (PR_CALLBACK *PRCloseFN)(PRFileDesc *fd); +typedef PRInt32 (PR_CALLBACK *PRReadFN)(PRFileDesc *fd, void *buf, PRInt32 amount); +typedef PRInt32 (PR_CALLBACK *PRWriteFN)(PRFileDesc *fd, const void *buf, PRInt32 amount); +typedef PRInt32 (PR_CALLBACK *PRAvailableFN)(PRFileDesc *fd); +typedef PRInt64 (PR_CALLBACK *PRAvailable64FN)(PRFileDesc *fd); +typedef PRStatus (PR_CALLBACK *PRFsyncFN)(PRFileDesc *fd); +typedef PROffset32 (PR_CALLBACK *PRSeekFN)(PRFileDesc *fd, PROffset32 offset, PRSeekWhence how); +typedef PROffset64 (PR_CALLBACK *PRSeek64FN)(PRFileDesc *fd, PROffset64 offset, PRSeekWhence how); +typedef PRStatus (PR_CALLBACK *PRFileInfoFN)(PRFileDesc *fd, PRFileInfo *info); +typedef PRStatus (PR_CALLBACK *PRFileInfo64FN)(PRFileDesc *fd, PRFileInfo64 *info); +typedef PRInt32 (PR_CALLBACK *PRWritevFN)( + PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, + PRIntervalTime timeout); +typedef PRStatus (PR_CALLBACK *PRConnectFN)( + PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout); +typedef PRFileDesc* (PR_CALLBACK *PRAcceptFN) ( + PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout); +typedef PRStatus (PR_CALLBACK *PRBindFN)(PRFileDesc *fd, const PRNetAddr *addr); +typedef PRStatus (PR_CALLBACK *PRListenFN)(PRFileDesc *fd, PRIntn backlog); +typedef PRStatus (PR_CALLBACK *PRShutdownFN)(PRFileDesc *fd, PRIntn how); +typedef PRInt32 (PR_CALLBACK *PRRecvFN)( + PRFileDesc *fd, void *buf, PRInt32 amount, + PRIntn flags, PRIntervalTime timeout); +typedef PRInt32 (PR_CALLBACK *PRSendFN) ( + PRFileDesc *fd, const void *buf, PRInt32 amount, + PRIntn flags, PRIntervalTime timeout); +typedef PRInt32 (PR_CALLBACK *PRRecvfromFN)( + PRFileDesc *fd, void *buf, PRInt32 amount, + PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout); +typedef PRInt32 (PR_CALLBACK *PRSendtoFN)( + PRFileDesc *fd, const void *buf, PRInt32 amount, + PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout); +typedef PRInt16 (PR_CALLBACK *PRPollFN)( + PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags); +typedef PRInt32 (PR_CALLBACK *PRAcceptreadFN)( + PRFileDesc *sd, PRFileDesc **nd, PRNetAddr **raddr, + void *buf, PRInt32 amount, PRIntervalTime t); +typedef PRInt32 (PR_CALLBACK *PRTransmitfileFN)( + PRFileDesc *sd, PRFileDesc *fd, const void *headers, + PRInt32 hlen, PRTransmitFileFlags flags, PRIntervalTime t); +typedef PRStatus (PR_CALLBACK *PRGetsocknameFN)(PRFileDesc *fd, PRNetAddr *addr); +typedef PRStatus (PR_CALLBACK *PRGetpeernameFN)(PRFileDesc *fd, PRNetAddr *addr); +typedef PRStatus (PR_CALLBACK *PRGetsocketoptionFN)( + PRFileDesc *fd, PRSocketOptionData *data); +typedef PRStatus (PR_CALLBACK *PRSetsocketoptionFN)( + PRFileDesc *fd, const PRSocketOptionData *data); +typedef PRInt32 (PR_CALLBACK *PRSendfileFN)( + PRFileDesc *networkSocket, PRSendFileData *sendData, + PRTransmitFileFlags flags, PRIntervalTime timeout); +typedef PRStatus (PR_CALLBACK *PRConnectcontinueFN)( + PRFileDesc *fd, PRInt16 out_flags); +typedef PRIntn (PR_CALLBACK *PRReservedFN)(PRFileDesc *fd); + +struct PRIOMethods { + PRDescType file_type; /* Type of file represented (tos) */ + PRCloseFN close; /* close file and destroy descriptor */ + PRReadFN read; /* read up to specified bytes into buffer */ + PRWriteFN write; /* write specified bytes from buffer */ + PRAvailableFN available; /* determine number of bytes available */ + PRAvailable64FN available64; /* ditto, 64 bit */ + PRFsyncFN fsync; /* flush all buffers to permanent store */ + PRSeekFN seek; /* position the file to the desired place */ + PRSeek64FN seek64; /* ditto, 64 bit */ + PRFileInfoFN fileInfo; /* Get information about an open file */ + PRFileInfo64FN fileInfo64; /* ditto, 64 bit */ + PRWritevFN writev; /* Write segments as described by iovector */ + PRConnectFN connect; /* Connect to the specified (net) address */ + PRAcceptFN accept; /* Accept a connection for a (net) peer */ + PRBindFN bind; /* Associate a (net) address with the fd */ + PRListenFN listen; /* Prepare to listen for (net) connections */ + PRShutdownFN shutdown; /* Shutdown a (net) connection */ + PRRecvFN recv; /* Solicit up the the specified bytes */ + PRSendFN send; /* Send all the bytes specified */ + PRRecvfromFN recvfrom; /* Solicit (net) bytes and report source */ + PRSendtoFN sendto; /* Send bytes to (net) address specified */ + PRPollFN poll; /* Test the fd to see if it is ready */ + PRAcceptreadFN acceptread; /* Accept and read on a new (net) fd */ + PRTransmitfileFN transmitfile; /* Transmit at entire file */ + PRGetsocknameFN getsockname; /* Get (net) address associated with fd */ + PRGetpeernameFN getpeername; /* Get peer's (net) address */ + PRReservedFN reserved_fn_6; /* reserved for future use */ + PRReservedFN reserved_fn_5; /* reserved for future use */ + PRGetsocketoptionFN getsocketoption; + /* Get current setting of specified option */ + PRSetsocketoptionFN setsocketoption; + /* Set value of specified option */ + PRSendfileFN sendfile; /* Send a (partial) file with header/trailer*/ + PRConnectcontinueFN connectcontinue; + /* Continue a nonblocking connect */ + PRReservedFN reserved_fn_3; /* reserved for future use */ + PRReservedFN reserved_fn_2; /* reserved for future use */ + PRReservedFN reserved_fn_1; /* reserved for future use */ + PRReservedFN reserved_fn_0; /* reserved for future use */ +}; + +/* + ************************************************************************** + * FUNCTION: PR_GetSpecialFD + * DESCRIPTION: Get the file descriptor that represents the standard input, + * output, or error stream. + * INPUTS: + * PRSpecialFD id + * A value indicating the type of stream desired: + * PR_StandardInput: standard input + * PR_StandardOuput: standard output + * PR_StandardError: standard error + * OUTPUTS: none + * RETURNS: PRFileDesc * + * If the argument is valid, PR_GetSpecialFD returns a file descriptor + * that represents the corresponding standard I/O stream. Otherwise, + * PR_GetSpecialFD returns NULL and sets error PR_INVALID_ARGUMENT_ERROR. + ************************************************************************** + */ + +typedef enum PRSpecialFD +{ + PR_StandardInput, /* standard input */ + PR_StandardOutput, /* standard output */ + PR_StandardError /* standard error */ +} PRSpecialFD; + +NSPR_API(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD id); + +#define PR_STDIN PR_GetSpecialFD(PR_StandardInput) +#define PR_STDOUT PR_GetSpecialFD(PR_StandardOutput) +#define PR_STDERR PR_GetSpecialFD(PR_StandardError) + +/* + ************************************************************************** + * Layering file descriptors + * + * File descriptors may be layered. Each layer has it's own identity. + * Identities are allocated by the runtime and are to be associated + * (by the layer implementor) with all layers that are of that type. + * It is then possible to scan the chain of layers and find a layer + * that one recongizes and therefore predict that it will implement + * a desired protocol. + * + * There are three well-known identities: + * PR_INVALID_IO_LAYER => an invalid layer identity, for error return + * PR_TOP_IO_LAYER => the identity of the top of the stack + * PR_NSPR_IO_LAYER => the identity used by NSPR proper + * PR_TOP_IO_LAYER may be used as a shorthand for identifying the topmost + * layer of an existing stack. Ie., the following two constructs are + * equivalent. + * + * rv = PR_PushIOLayer(stack, PR_TOP_IO_LAYER, my_layer); + * rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), my_layer) + * + * A string may be associated with the creation of the identity. It + * will be copied by the runtime. If queried the runtime will return + * a reference to that copied string (not yet another copy). There + * is no facility for deleting an identity. + ************************************************************************** + */ + +#define PR_IO_LAYER_HEAD (PRDescIdentity)-3 +#define PR_INVALID_IO_LAYER (PRDescIdentity)-1 +#define PR_TOP_IO_LAYER (PRDescIdentity)-2 +#define PR_NSPR_IO_LAYER (PRDescIdentity)0 + +NSPR_API(PRDescIdentity) PR_GetUniqueIdentity(const char *layer_name); +NSPR_API(const char*) PR_GetNameForIdentity(PRDescIdentity ident); +NSPR_API(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd); +NSPR_API(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd_stack, PRDescIdentity id); + +/* + ************************************************************************** + * PR_GetDefaultIOMethods: Accessing the default methods table. + * You may get a pointer to the default methods table by calling this function. + * You may then select any elements from that table with which to build your + * layer's methods table. You may NOT modify the table directly. + ************************************************************************** + */ +NSPR_API(const PRIOMethods *) PR_GetDefaultIOMethods(void); + +/* + ************************************************************************** + * Creating a layer + * + * A new layer may be allocated by calling PR_CreateIOLayerStub(). The + * file descriptor returned will contain the pointer to the methods table + * provided. The runtime will not modify the table nor test its correctness. + ************************************************************************** + */ +NSPR_API(PRFileDesc*) PR_CreateIOLayerStub( + PRDescIdentity ident, const PRIOMethods *methods); + +/* + ************************************************************************** + * Creating a layer + * + * A new stack may be created by calling PR_CreateIOLayer(). The + * file descriptor returned will point to the top of the stack, which has + * the layer 'fd' as the topmost layer. + * + * NOTE: This function creates a new style stack, which has a fixed, dummy + * header. The old style stack, created by a call to PR_PushIOLayer, + * results in modifying contents of the top layer of the stack, when + * pushing and popping layers of the stack. + ************************************************************************** + */ +NSPR_API(PRFileDesc*) PR_CreateIOLayer(PRFileDesc* fd); + +/* + ************************************************************************** + * Pushing a layer + * + * A file descriptor (perhaps allocated using PR_CreateIOLayerStub()) may + * be pushed into an existing stack of file descriptors at any point the + * caller deems appropriate. The new layer will be inserted into the stack + * just above the layer with the indicated identity. + * + * Note: Even if the identity parameter indicates the top-most layer of + * the stack, the value of the file descriptor describing the original + * stack will not change. + ************************************************************************** + */ +NSPR_API(PRStatus) PR_PushIOLayer( + PRFileDesc *fd_stack, PRDescIdentity id, PRFileDesc *layer); + +/* + ************************************************************************** + * Popping a layer + * + * A layer may be popped from a stack by indicating the identity of the + * layer to be removed. If found, a pointer to the removed object will + * be returned to the caller. The object then becomes the responsibility + * of the caller. + * + * Note: Even if the identity indicates the top layer of the stack, the + * reference returned will not be the file descriptor for the stack and + * that file descriptor will remain valid. + ************************************************************************** + */ +NSPR_API(PRFileDesc*) PR_PopIOLayer(PRFileDesc *fd_stack, PRDescIdentity id); + +/* + ************************************************************************** + * FUNCTION: PR_Open + * DESCRIPTION: Open a file for reading, writing, or both. + * INPUTS: + * const char *name + * The path name of the file to be opened + * PRIntn flags + * The file status flags. + * It is a bitwise OR of the following bit flags (only one of + * the first three flags below may be used): + * PR_RDONLY Open for reading only. + * PR_WRONLY Open for writing only. + * PR_RDWR Open for reading and writing. + * PR_CREATE_FILE If the file does not exist, the file is created + * If the file exists, this flag has no effect. + * PR_SYNC If set, each write will wait for both the file data + * and file status to be physically updated. + * PR_APPEND The file pointer is set to the end of + * the file prior to each write. + * PR_TRUNCATE If the file exists, its length is truncated to 0. + * PR_EXCL With PR_CREATE_FILE, if the file does not exist, + * the file is created. If the file already + * exists, no action and NULL is returned + * + * PRIntn mode + * The access permission bits of the file mode, if the file is + * created when PR_CREATE_FILE is on. + * OUTPUTS: None + * RETURNS: PRFileDesc * + * If the file is successfully opened, + * returns a pointer to the PRFileDesc + * created for the newly opened file. + * Returns a NULL pointer if the open + * failed. + * SIDE EFFECTS: + * RESTRICTIONS: + * MEMORY: + * The return value, if not NULL, points to a dynamically allocated + * PRFileDesc object. + * ALGORITHM: + ************************************************************************** + */ + +/* Open flags */ +#define PR_RDONLY 0x01 +#define PR_WRONLY 0x02 +#define PR_RDWR 0x04 +#define PR_CREATE_FILE 0x08 +#define PR_APPEND 0x10 +#define PR_TRUNCATE 0x20 +#define PR_SYNC 0x40 +#define PR_EXCL 0x80 + +/* +** File modes .... +** +** CAVEAT: 'mode' is currently only applicable on UNIX platforms. +** The 'mode' argument may be ignored by PR_Open on other platforms. +** +** 00400 Read by owner. +** 00200 Write by owner. +** 00100 Execute (search if a directory) by owner. +** 00040 Read by group. +** 00020 Write by group. +** 00010 Execute by group. +** 00004 Read by others. +** 00002 Write by others +** 00001 Execute by others. +** +*/ + +NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode); + +/* + ************************************************************************** + * FUNCTION: PR_OpenFile + * DESCRIPTION: + * Open a file for reading, writing, or both. + * PR_OpenFile has the same prototype as PR_Open but implements + * the specified file mode where possible. + ************************************************************************** + */ + +/* File mode bits */ +#define PR_IRWXU 00700 /* read, write, execute/search by owner */ +#define PR_IRUSR 00400 /* read permission, owner */ +#define PR_IWUSR 00200 /* write permission, owner */ +#define PR_IXUSR 00100 /* execute/search permission, owner */ +#define PR_IRWXG 00070 /* read, write, execute/search by group */ +#define PR_IRGRP 00040 /* read permission, group */ +#define PR_IWGRP 00020 /* write permission, group */ +#define PR_IXGRP 00010 /* execute/search permission, group */ +#define PR_IRWXO 00007 /* read, write, execute/search by others */ +#define PR_IROTH 00004 /* read permission, others */ +#define PR_IWOTH 00002 /* write permission, others */ +#define PR_IXOTH 00001 /* execute/search permission, others */ + +NSPR_API(PRFileDesc*) PR_OpenFile( + const char *name, PRIntn flags, PRIntn mode); + +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRFileDesc*) PR_OpenFileUTF16( + const PRUnichar *name, PRIntn flags, PRIntn mode); +#endif /* MOZ_UNICODE */ + +/* + ************************************************************************** + * FUNCTION: PR_Close + * DESCRIPTION: + * Close a file or socket. + * INPUTS: + * PRFileDesc *fd + * a pointer to a PRFileDesc. + * OUTPUTS: + * None. + * RETURN: + * PRStatus + * SIDE EFFECTS: + * RESTRICTIONS: + * None. + * MEMORY: + * The dynamic memory pointed to by the argument fd is freed. + ************************************************************************** + */ + +NSPR_API(PRStatus) PR_Close(PRFileDesc *fd); + +/* + ************************************************************************** + * FUNCTION: PR_Read + * DESCRIPTION: + * Read bytes from a file or socket. + * The operation will block until either an end of stream indication is + * encountered, some positive number of bytes are transferred, or there + * is an error. No more than 'amount' bytes will be transferred. + * INPUTS: + * PRFileDesc *fd + * pointer to the PRFileDesc object for the file or socket + * void *buf + * pointer to a buffer to hold the data read in. + * PRInt32 amount + * the size of 'buf' (in bytes) + * OUTPUTS: + * RETURN: + * PRInt32 + * a positive number indicates the number of bytes actually read in. + * 0 means end of file is reached or the network connection is closed. + * -1 indicates a failure. The reason for the failure is obtained + * by calling PR_GetError(). + * SIDE EFFECTS: + * data is written into the buffer pointed to by 'buf'. + * RESTRICTIONS: + * None. + * MEMORY: + * N/A + * ALGORITHM: + * N/A + ************************************************************************** + */ + +NSPR_API(PRInt32) PR_Read(PRFileDesc *fd, void *buf, PRInt32 amount); + +/* + *************************************************************************** + * FUNCTION: PR_Write + * DESCRIPTION: + * Write a specified number of bytes to a file or socket. The thread + * invoking this function blocks until all the data is written. + * INPUTS: + * PRFileDesc *fd + * pointer to a PRFileDesc object that refers to a file or socket + * const void *buf + * pointer to the buffer holding the data + * PRInt32 amount + * amount of data in bytes to be written from the buffer + * OUTPUTS: + * None. + * RETURN: PRInt32 + * A positive number indicates the number of bytes successfully written. + * A -1 is an indication that the operation failed. The reason + * for the failure is obtained by calling PR_GetError(). + *************************************************************************** + */ + +NSPR_API(PRInt32) PR_Write(PRFileDesc *fd,const void *buf,PRInt32 amount); + +/* + *************************************************************************** + * FUNCTION: PR_Writev + * DESCRIPTION: + * Write data to a socket. The data is organized in a PRIOVec array. The + * operation will block until all the data is written or the operation + * fails. + * INPUTS: + * PRFileDesc *fd + * Pointer that points to a PRFileDesc object for a socket. + * const PRIOVec *iov + * An array of PRIOVec. PRIOVec is a struct with the following + * two fields: + * char *iov_base; + * int iov_len; + * PRInt32 iov_size + * Number of elements in the iov array. The value of this + * argument must not be greater than PR_MAX_IOVECTOR_SIZE. + * If it is, the method will fail (PR_BUFFER_OVERFLOW_ERROR). + * PRIntervalTime timeout + * Time limit for completion of the entire write operation. + * OUTPUTS: + * None + * RETURN: + * A positive number indicates the number of bytes successfully written. + * A -1 is an indication that the operation failed. The reason + * for the failure is obtained by calling PR_GetError(). + *************************************************************************** + */ + +#define PR_MAX_IOVECTOR_SIZE 16 /* 'iov_size' must be <= */ + +NSPR_API(PRInt32) PR_Writev( + PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, + PRIntervalTime timeout); + +/* + *************************************************************************** + * FUNCTION: PR_Delete + * DESCRIPTION: + * Delete a file from the filesystem. The operation may fail if the + * file is open. + * INPUTS: + * const char *name + * Path name of the file to be deleted. + * OUTPUTS: + * None. + * RETURN: PRStatus + * The function returns PR_SUCCESS if the file is successfully + * deleted, otherwise it returns PR_FAILURE. + *************************************************************************** + */ + +NSPR_API(PRStatus) PR_Delete(const char *name); + +/**************************************************************************/ + +typedef enum PRFileType +{ + PR_FILE_FILE = 1, + PR_FILE_DIRECTORY = 2, + PR_FILE_OTHER = 3 +} PRFileType; + +struct PRFileInfo { + PRFileType type; /* Type of file */ + PROffset32 size; /* Size, in bytes, of file's contents */ + PRTime creationTime; /* Creation time per definition of PRTime */ + PRTime modifyTime; /* Last modification time per definition of PRTime */ +}; + +struct PRFileInfo64 { + PRFileType type; /* Type of file */ + PROffset64 size; /* Size, in bytes, of file's contents */ + PRTime creationTime; /* Creation time per definition of PRTime */ + PRTime modifyTime; /* Last modification time per definition of PRTime */ +}; + +/**************************************************************************** + * FUNCTION: PR_GetFileInfo, PR_GetFileInfo64 + * DESCRIPTION: + * Get the information about the file with the given path name. This is + * applicable only to NSFileDesc describing 'file' types (see + * INPUTS: + * const char *fn + * path name of the file + * OUTPUTS: + * PRFileInfo *info + * Information about the given file is written into the file + * information object pointer to by 'info'. + * RETURN: PRStatus + * PR_GetFileInfo returns PR_SUCCESS if file information is successfully + * obtained, otherwise it returns PR_FAILURE. + *************************************************************************** + */ + +NSPR_API(PRStatus) PR_GetFileInfo(const char *fn, PRFileInfo *info); +NSPR_API(PRStatus) PR_GetFileInfo64(const char *fn, PRFileInfo64 *info); + +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRStatus) PR_GetFileInfo64UTF16(const PRUnichar *fn, PRFileInfo64 *info); +#endif /* MOZ_UNICODE */ + +/* + ************************************************************************** + * FUNCTION: PR_GetOpenFileInfo, PR_GetOpenFileInfo64 + * DESCRIPTION: + * Get information about an open file referred to by the + * given PRFileDesc object. + * INPUTS: + * const PRFileDesc *fd + * A reference to a valid, open file. + * OUTPUTS: + * Same as PR_GetFileInfo, PR_GetFileInfo64 + * RETURN: PRStatus + * PR_GetFileInfo returns PR_SUCCESS if file information is successfully + * obtained, otherwise it returns PR_FAILURE. + *************************************************************************** + */ + +NSPR_API(PRStatus) PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info); +NSPR_API(PRStatus) PR_GetOpenFileInfo64(PRFileDesc *fd, PRFileInfo64 *info); + +/* + ************************************************************************** + * FUNCTION: PR_Rename + * DESCRIPTION: + * Rename a file from the old name 'from' to the new name 'to'. + * INPUTS: + * const char *from + * The old name of the file to be renamed. + * const char *to + * The new name of the file. + * OUTPUTS: + * None. + * RETURN: PRStatus + ************************************************************************** + */ + +NSPR_API(PRStatus) PR_Rename(const char *from, const char *to); + +/* + ************************************************************************* + * FUNCTION: PR_Access + * DESCRIPTION: + * Determine accessibility of a file. + * INPUTS: + * const char *name + * path name of the file + * PRAccessHow how + * specifies which access permission to check for. + * It can be one of the following values: + * PR_ACCESS_READ_OK Test for read permission + * PR_ACCESS_WRITE_OK Test for write permission + * PR_ACCESS_EXISTS Check existence of file + * OUTPUTS: + * None. + * RETURN: PRStatus + * PR_SUCCESS is returned if the requested access is permitted. + * Otherwise, PR_FAILURE is returned. Additional information + * regarding the reason for the failure may be retrieved from + * PR_GetError(). + ************************************************************************* + */ + +typedef enum PRAccessHow { + PR_ACCESS_EXISTS = 1, + PR_ACCESS_WRITE_OK = 2, + PR_ACCESS_READ_OK = 3 +} PRAccessHow; + +NSPR_API(PRStatus) PR_Access(const char *name, PRAccessHow how); + +/* + ************************************************************************* + * FUNCTION: PR_Seek, PR_Seek64 + * DESCRIPTION: + * Moves read-write file offset + * INPUTS: + * PRFileDesc *fd + * Pointer to a PRFileDesc object. + * PROffset32, PROffset64 offset + * Specifies a value, in bytes, that is used in conjunction + * with the 'whence' parameter to set the file pointer. A + * negative value causes seeking in the reverse direction. + * PRSeekWhence whence + * Specifies how to interpret the 'offset' parameter in setting + * the file pointer associated with the 'fd' parameter. + * Values for the 'whence' parameter are: + * PR_SEEK_SET Sets the file pointer to the value of the + * 'offset' parameter + * PR_SEEK_CUR Sets the file pointer to its current location + * plus the value of the offset parameter. + * PR_SEEK_END Sets the file pointer to the size of the + * file plus the value of the offset parameter. + * OUTPUTS: + * None. + * RETURN: PROffset32, PROffset64 + * Upon successful completion, the resulting pointer location, + * measured in bytes from the beginning of the file, is returned. + * If the PR_Seek() function fails, the file offset remains + * unchanged, and the returned value is -1. The error code can + * then be retrieved via PR_GetError(). + ************************************************************************* + */ + +NSPR_API(PROffset32) PR_Seek(PRFileDesc *fd, PROffset32 offset, PRSeekWhence whence); +NSPR_API(PROffset64) PR_Seek64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence); + +/* + ************************************************************************ + * FUNCTION: PR_Available + * DESCRIPTION: + * Determine the amount of data in bytes available for reading + * in the given file or socket. + * INPUTS: + * PRFileDesc *fd + * Pointer to a PRFileDesc object that refers to a file or + * socket. + * OUTPUTS: + * None + * RETURN: PRInt32, PRInt64 + * Upon successful completion, PR_Available returns the number of + * bytes beyond the current read pointer that is available for + * reading. Otherwise, it returns a -1 and the reason for the + * failure can be retrieved via PR_GetError(). + ************************************************************************ + */ + +NSPR_API(PRInt32) PR_Available(PRFileDesc *fd); +NSPR_API(PRInt64) PR_Available64(PRFileDesc *fd); + +/* + ************************************************************************ + * FUNCTION: PR_Sync + * DESCRIPTION: + * Sync any buffered data for a fd to its backing device (disk). + * INPUTS: + * PRFileDesc *fd + * Pointer to a PRFileDesc object that refers to a file or + * socket + * OUTPUTS: + * None + * RETURN: PRStatus + * PR_SUCCESS is returned if the requested access is permitted. + * Otherwise, PR_FAILURE is returned. + ************************************************************************ + */ + +NSPR_API(PRStatus) PR_Sync(PRFileDesc *fd); + +/************************************************************************/ + +struct PRDirEntry { + const char *name; /* name of entry, relative to directory name */ +}; + +#ifdef MOZ_UNICODE +struct PRDirEntryUTF16 { + const PRUnichar *name; /* name of entry in UTF16, relative to + * directory name */ +}; +#endif /* MOZ_UNICODE */ + +#if !defined(NO_NSPR_10_SUPPORT) +#define PR_DirName(dirEntry) (dirEntry->name) +#endif + +/* + ************************************************************************* + * FUNCTION: PR_OpenDir + * DESCRIPTION: + * Open the directory by the given name + * INPUTS: + * const char *name + * path name of the directory to be opened + * OUTPUTS: + * None + * RETURN: PRDir * + * If the directory is sucessfully opened, a PRDir object is + * dynamically allocated and a pointer to it is returned. + * If the directory cannot be opened, a NULL pointer is returned. + * MEMORY: + * Upon successful completion, the return value points to + * dynamically allocated memory. + ************************************************************************* + */ + +NSPR_API(PRDir*) PR_OpenDir(const char *name); + +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRDirUTF16*) PR_OpenDirUTF16(const PRUnichar *name); +#endif /* MOZ_UNICODE */ + +/* + ************************************************************************* + * FUNCTION: PR_ReadDir + * DESCRIPTION: + * INPUTS: + * PRDir *dir + * pointer to a PRDir object that designates an open directory + * PRDirFlags flags + * PR_SKIP_NONE Do not skip any files + * PR_SKIP_DOT Skip the directory entry "." that + * represents the current directory + * PR_SKIP_DOT_DOT Skip the directory entry ".." that + * represents the parent directory. + * PR_SKIP_BOTH Skip both '.' and '..' + * PR_SKIP_HIDDEN Skip hidden files + * OUTPUTS: + * RETURN: PRDirEntry* + * Returns a pointer to the next entry in the directory. Returns + * a NULL pointer upon reaching the end of the directory or when an + * error occurs. The actual reason can be retrieved via PR_GetError(). + ************************************************************************* + */ + +typedef enum PRDirFlags { + PR_SKIP_NONE = 0x0, + PR_SKIP_DOT = 0x1, + PR_SKIP_DOT_DOT = 0x2, + PR_SKIP_BOTH = 0x3, + PR_SKIP_HIDDEN = 0x4 +} PRDirFlags; + +NSPR_API(PRDirEntry*) PR_ReadDir(PRDir *dir, PRDirFlags flags); + +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRDirEntryUTF16*) PR_ReadDirUTF16(PRDirUTF16 *dir, PRDirFlags flags); +#endif /* MOZ_UNICODE */ + +/* + ************************************************************************* + * FUNCTION: PR_CloseDir + * DESCRIPTION: + * Close the specified directory. + * INPUTS: + * PRDir *dir + * The directory to be closed. + * OUTPUTS: + * None + * RETURN: PRStatus + * If successful, will return a status of PR_SUCCESS. Otherwise + * a value of PR_FAILURE. The reason for the failure may be re- + * trieved using PR_GetError(). + ************************************************************************* + */ + +NSPR_API(PRStatus) PR_CloseDir(PRDir *dir); + +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRStatus) PR_CloseDirUTF16(PRDirUTF16 *dir); +#endif /* MOZ_UNICODE */ + +/* + ************************************************************************* + * FUNCTION: PR_MkDir + * DESCRIPTION: + * Create a new directory with the given name and access mode. + * INPUTS: + * const char *name + * The name of the directory to be created. All the path components + * up to but not including the leaf component must already exist. + * PRIntn mode + * See 'mode' definiton in PR_Open(). + * OUTPUTS: + * None + * RETURN: PRStatus + * If successful, will return a status of PR_SUCCESS. Otherwise + * a value of PR_FAILURE. The reason for the failure may be re- + * trieved using PR_GetError(). + ************************************************************************* + */ + +NSPR_API(PRStatus) PR_MkDir(const char *name, PRIntn mode); + +/* + ************************************************************************* + * FUNCTION: PR_MakeDir + * DESCRIPTION: + * Create a new directory with the given name and access mode. + * PR_MakeDir has the same prototype as PR_MkDir but implements + * the specified access mode where possible. + ************************************************************************* + */ + +NSPR_API(PRStatus) PR_MakeDir(const char *name, PRIntn mode); + +/* + ************************************************************************* + * FUNCTION: PR_RmDir + * DESCRIPTION: + * Remove a directory by the given name. + * INPUTS: + * const char *name + * The name of the directory to be removed. All the path components + * must already exist. Only the leaf component will be removed. + * OUTPUTS: + * None + * RETURN: PRStatus + * If successful, will return a status of PR_SUCCESS. Otherwise + * a value of PR_FAILURE. The reason for the failure may be re- + * trieved using PR_GetError(). + ************************************************************************** + */ + +NSPR_API(PRStatus) PR_RmDir(const char *name); + +/* + ************************************************************************* + * FUNCTION: PR_NewUDPSocket + * DESCRIPTION: + * Create a new UDP socket. + * INPUTS: + * None + * OUTPUTS: + * None + * RETURN: PRFileDesc* + * Upon successful completion, PR_NewUDPSocket returns a pointer + * to the PRFileDesc created for the newly opened UDP socket. + * Returns a NULL pointer if the creation of a new UDP socket failed. + * + ************************************************************************** + */ + +NSPR_API(PRFileDesc*) PR_NewUDPSocket(void); + +/* + ************************************************************************* + * FUNCTION: PR_NewTCPSocket + * DESCRIPTION: + * Create a new TCP socket. + * INPUTS: + * None + * OUTPUTS: + * None + * RETURN: PRFileDesc* + * Upon successful completion, PR_NewTCPSocket returns a pointer + * to the PRFileDesc created for the newly opened TCP socket. + * Returns a NULL pointer if the creation of a new TCP socket failed. + * + ************************************************************************** + */ + +NSPR_API(PRFileDesc*) PR_NewTCPSocket(void); + +/* + ************************************************************************* + * FUNCTION: PR_OpenUDPSocket + * DESCRIPTION: + * Create a new UDP socket of the specified address family. + * INPUTS: + * PRIntn af + * Address family + * OUTPUTS: + * None + * RETURN: PRFileDesc* + * Upon successful completion, PR_OpenUDPSocket returns a pointer + * to the PRFileDesc created for the newly opened UDP socket. + * Returns a NULL pointer if the creation of a new UDP socket failed. + * + ************************************************************************** + */ + +NSPR_API(PRFileDesc*) PR_OpenUDPSocket(PRIntn af); + +/* + ************************************************************************* + * FUNCTION: PR_OpenTCPSocket + * DESCRIPTION: + * Create a new TCP socket of the specified address family. + * INPUTS: + * PRIntn af + * Address family + * OUTPUTS: + * None + * RETURN: PRFileDesc* + * Upon successful completion, PR_NewTCPSocket returns a pointer + * to the PRFileDesc created for the newly opened TCP socket. + * Returns a NULL pointer if the creation of a new TCP socket failed. + * + ************************************************************************** + */ + +NSPR_API(PRFileDesc*) PR_OpenTCPSocket(PRIntn af); + +/* + ************************************************************************* + * FUNCTION: PR_Connect + * DESCRIPTION: + * Initiate a connection on a socket. + * INPUTS: + * PRFileDesc *fd + * Points to a PRFileDesc object representing a socket + * PRNetAddr *addr + * Specifies the address of the socket in its own communication + * space. + * PRIntervalTime timeout + * The function uses the lesser of the provided timeout and + * the OS's connect timeout. In particular, if you specify + * PR_INTERVAL_NO_TIMEOUT as the timeout, the OS's connection + * time limit will be used. + * + * OUTPUTS: + * None + * RETURN: PRStatus + * Upon successful completion of connection initiation, PR_Connect + * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further + * failure information can be obtained by calling PR_GetError(). + ************************************************************************** + */ + +NSPR_API(PRStatus) PR_Connect( + PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout); + +/* + ************************************************************************* + * FUNCTION: PR_ConnectContinue + * DESCRIPTION: + * Continue a nonblocking connect. After a nonblocking connect + * is initiated with PR_Connect() (which fails with + * PR_IN_PROGRESS_ERROR), one should call PR_Poll() on the socket, + * with the in_flags PR_POLL_WRITE | PR_POLL_EXCEPT. When + * PR_Poll() returns, one calls PR_ConnectContinue() on the + * socket to determine whether the nonblocking connect has + * completed or is still in progress. Repeat the PR_Poll(), + * PR_ConnectContinue() sequence until the nonblocking connect + * has completed. + * INPUTS: + * PRFileDesc *fd + * the file descriptor representing a socket + * PRInt16 out_flags + * the out_flags field of the poll descriptor returned by + * PR_Poll() + * RETURN: PRStatus + * If the nonblocking connect has successfully completed, + * PR_ConnectContinue returns PR_SUCCESS. If PR_ConnectContinue() + * returns PR_FAILURE, call PR_GetError(): + * - PR_IN_PROGRESS_ERROR: the nonblocking connect is still in + * progress and has not completed yet. The caller should poll + * on the file descriptor for the in_flags + * PR_POLL_WRITE|PR_POLL_EXCEPT and retry PR_ConnectContinue + * later when PR_Poll() returns. + * - Other errors: the nonblocking connect has failed with this + * error code. + */ + +NSPR_API(PRStatus) PR_ConnectContinue(PRFileDesc *fd, PRInt16 out_flags); + +/* + ************************************************************************* + * THIS FUNCTION IS DEPRECATED. USE PR_ConnectContinue INSTEAD. + * + * FUNCTION: PR_GetConnectStatus + * DESCRIPTION: + * Get the completion status of a nonblocking connect. After + * a nonblocking connect is initiated with PR_Connect() (which + * fails with PR_IN_PROGRESS_ERROR), one should call PR_Poll() + * on the socket, with the in_flags PR_POLL_WRITE | PR_POLL_EXCEPT. + * When PR_Poll() returns, one calls PR_GetConnectStatus on the + * PRPollDesc structure to determine whether the nonblocking + * connect has succeeded or failed. + * INPUTS: + * const PRPollDesc *pd + * Pointer to a PRPollDesc whose fd member is the socket, + * and in_flags must contain PR_POLL_WRITE and PR_POLL_EXCEPT. + * PR_Poll() should have been called and set the out_flags. + * RETURN: PRStatus + * If the nonblocking connect has successfully completed, + * PR_GetConnectStatus returns PR_SUCCESS. If PR_GetConnectStatus() + * returns PR_FAILURE, call PR_GetError(): + * - PR_IN_PROGRESS_ERROR: the nonblocking connect is still in + * progress and has not completed yet. + * - Other errors: the nonblocking connect has failed with this + * error code. + */ + +NSPR_API(PRStatus) PR_GetConnectStatus(const PRPollDesc *pd); + +/* + ************************************************************************* + * FUNCTION: PR_Accept + * DESCRIPTION: + * Accept a connection on a socket. + * INPUTS: + * PRFileDesc *fd + * Points to a PRFileDesc object representing the rendezvous socket + * on which the caller is willing to accept new connections. + * PRIntervalTime timeout + * Time limit for completion of the accept operation. + * OUTPUTS: + * PRNetAddr *addr + * Returns the address of the connecting entity in its own + * communication space. It may be NULL. + * RETURN: PRFileDesc* + * Upon successful acceptance of a connection, PR_Accept + * returns a valid file descriptor. Otherwise, it returns NULL. + * Further failure information can be obtained by calling PR_GetError(). + ************************************************************************** + */ + +NSPR_API(PRFileDesc*) PR_Accept( + PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout); + +/* + ************************************************************************* + * FUNCTION: PR_Bind + * DESCRIPTION: + * Bind an address to a socket. + * INPUTS: + * PRFileDesc *fd + * Points to a PRFileDesc object representing a socket. + * PRNetAddr *addr + * Specifies the address to which the socket will be bound. + * OUTPUTS: + * None + * RETURN: PRStatus + * Upon successful binding of an address to a socket, PR_Bind + * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further + * failure information can be obtained by calling PR_GetError(). + ************************************************************************** + */ + +NSPR_API(PRStatus) PR_Bind(PRFileDesc *fd, const PRNetAddr *addr); + +/* + ************************************************************************* + * FUNCTION: PR_Listen + * DESCRIPTION: + * Listen for connections on a socket. + * INPUTS: + * PRFileDesc *fd + * Points to a PRFileDesc object representing a socket that will be + * used to listen for new connections. + * PRIntn backlog + * Specifies the maximum length of the queue of pending connections. + * OUTPUTS: + * None + * RETURN: PRStatus + * Upon successful completion of listen request, PR_Listen + * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further + * failure information can be obtained by calling PR_GetError(). + ************************************************************************** + */ + +NSPR_API(PRStatus) PR_Listen(PRFileDesc *fd, PRIntn backlog); + +/* + ************************************************************************* + * FUNCTION: PR_Shutdown + * DESCRIPTION: + * Shut down part of a full-duplex connection on a socket. + * INPUTS: + * PRFileDesc *fd + * Points to a PRFileDesc object representing a connected socket. + * PRIntn how + * Specifies the kind of disallowed operations on the socket. + * PR_SHUTDOWN_RCV - Further receives will be disallowed + * PR_SHUTDOWN_SEND - Further sends will be disallowed + * PR_SHUTDOWN_BOTH - Further sends and receives will be disallowed + * OUTPUTS: + * None + * RETURN: PRStatus + * Upon successful completion of shutdown request, PR_Shutdown + * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further + * failure information can be obtained by calling PR_GetError(). + ************************************************************************** + */ + +typedef enum PRShutdownHow +{ + PR_SHUTDOWN_RCV = 0, /* disallow further receives */ + PR_SHUTDOWN_SEND = 1, /* disallow further sends */ + PR_SHUTDOWN_BOTH = 2 /* disallow further receives and sends */ +} PRShutdownHow; + +NSPR_API(PRStatus) PR_Shutdown(PRFileDesc *fd, PRShutdownHow how); + +/* + ************************************************************************* + * FUNCTION: PR_Recv + * DESCRIPTION: + * Receive a specified number of bytes from a connected socket. + * The operation will block until some positive number of bytes are + * transferred, a time out has occurred, or there is an error. + * No more than 'amount' bytes will be transferred. + * INPUTS: + * PRFileDesc *fd + * points to a PRFileDesc object representing a socket. + * void *buf + * pointer to a buffer to hold the data received. + * PRInt32 amount + * the size of 'buf' (in bytes) + * PRIntn flags + * must be zero or PR_MSG_PEEK. + * PRIntervalTime timeout + * Time limit for completion of the receive operation. + * OUTPUTS: + * None + * RETURN: PRInt32 + * a positive number indicates the number of bytes actually received. + * 0 means the network connection is closed. + * -1 indicates a failure. The reason for the failure is obtained + * by calling PR_GetError(). + ************************************************************************** + */ + +#define PR_MSG_PEEK 0x2 + +NSPR_API(PRInt32) PR_Recv(PRFileDesc *fd, void *buf, PRInt32 amount, + PRIntn flags, PRIntervalTime timeout); + +/* + ************************************************************************* + * FUNCTION: PR_Send + * DESCRIPTION: + * Send a specified number of bytes from a connected socket. + * The operation will block until all bytes are + * processed, a time out has occurred, or there is an error. + * INPUTS: + * PRFileDesc *fd + * points to a PRFileDesc object representing a socket. + * void *buf + * pointer to a buffer from where the data is sent. + * PRInt32 amount + * the size of 'buf' (in bytes) + * PRIntn flags + * (OBSOLETE - must always be zero) + * PRIntervalTime timeout + * Time limit for completion of the send operation. + * OUTPUTS: + * None + * RETURN: PRInt32 + * A positive number indicates the number of bytes successfully processed. + * This number must always equal 'amount'. A -1 is an indication that the + * operation failed. The reason for the failure is obtained by calling + * PR_GetError(). + ************************************************************************** + */ + +NSPR_API(PRInt32) PR_Send(PRFileDesc *fd, const void *buf, PRInt32 amount, + PRIntn flags, PRIntervalTime timeout); + +/* + ************************************************************************* + * FUNCTION: PR_RecvFrom + * DESCRIPTION: + * Receive up to a specified number of bytes from socket which may + * or may not be connected. + * The operation will block until one or more bytes are + * transferred, a time out has occurred, or there is an error. + * No more than 'amount' bytes will be transferred. + * INPUTS: + * PRFileDesc *fd + * points to a PRFileDesc object representing a socket. + * void *buf + * pointer to a buffer to hold the data received. + * PRInt32 amount + * the size of 'buf' (in bytes) + * PRIntn flags + * (OBSOLETE - must always be zero) + * PRNetAddr *addr + * Specifies the address of the sending peer. It may be NULL. + * PRIntervalTime timeout + * Time limit for completion of the receive operation. + * OUTPUTS: + * None + * RETURN: PRInt32 + * a positive number indicates the number of bytes actually received. + * 0 means the network connection is closed. + * -1 indicates a failure. The reason for the failure is obtained + * by calling PR_GetError(). + ************************************************************************** + */ + +NSPR_API(PRInt32) PR_RecvFrom( + PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, + PRNetAddr *addr, PRIntervalTime timeout); + +/* + ************************************************************************* + * FUNCTION: PR_SendTo + * DESCRIPTION: + * Send a specified number of bytes from an unconnected socket. + * The operation will block until all bytes are + * sent, a time out has occurred, or there is an error. + * INPUTS: + * PRFileDesc *fd + * points to a PRFileDesc object representing an unconnected socket. + * void *buf + * pointer to a buffer from where the data is sent. + * PRInt32 amount + * the size of 'buf' (in bytes) + * PRIntn flags + * (OBSOLETE - must always be zero) + * PRNetAddr *addr + * Specifies the address of the peer. +.* PRIntervalTime timeout + * Time limit for completion of the send operation. + * OUTPUTS: + * None + * RETURN: PRInt32 + * A positive number indicates the number of bytes successfully sent. + * -1 indicates a failure. The reason for the failure is obtained + * by calling PR_GetError(). + ************************************************************************** + */ + +NSPR_API(PRInt32) PR_SendTo( + PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, + const PRNetAddr *addr, PRIntervalTime timeout); + +/* +************************************************************************* +** FUNCTION: PR_TransmitFile +** DESCRIPTION: +** Transmitfile sends a complete file (sourceFile) across a socket +** (networkSocket). If headers is non-NULL, the headers will be sent across +** the socket prior to sending the file. +** +** Optionally, the PR_TRANSMITFILE_CLOSE_SOCKET flag may be passed to +** transmitfile. This flag specifies that transmitfile should close the +** socket after sending the data. +** +** INPUTS: +** PRFileDesc *networkSocket +** The socket to send data over +** PRFileDesc *sourceFile +** The file to send +** const void *headers +** A pointer to headers to be sent before sending data +** PRInt32 hlen +** length of header buffers in bytes. +** PRTransmitFileFlags flags +** If the flags indicate that the connection should be closed, +** it will be done immediately after transferring the file, unless +** the operation is unsuccessful. +.* PRIntervalTime timeout + * Time limit for completion of the transmit operation. +** +** RETURNS: +** Returns the number of bytes written or -1 if the operation failed. +** If an error occurs while sending the file, the PR_TRANSMITFILE_CLOSE_ +** SOCKET flag is ignored. The reason for the failure is obtained +** by calling PR_GetError(). +************************************************************************** +*/ + +NSPR_API(PRInt32) PR_TransmitFile( + PRFileDesc *networkSocket, PRFileDesc *sourceFile, + const void *headers, PRInt32 hlen, PRTransmitFileFlags flags, + PRIntervalTime timeout); + +/* +************************************************************************* +** FUNCTION: PR_SendFile +** DESCRIPTION: +** PR_SendFile sends data from a file (sendData->fd) across a socket +** (networkSocket). If specified, a header and/or trailer buffer are sent +** before and after the file, respectively. The file offset, number of bytes +** of file data to send, the header and trailer buffers are specified in the +** sendData argument. +** +** Optionally, if the PR_TRANSMITFILE_CLOSE_SOCKET flag is passed, the +** socket is closed after successfully sending the data. +** +** INPUTS: +** PRFileDesc *networkSocket +** The socket to send data over +** PRSendFileData *sendData +** Contains the FD, file offset and length, header and trailer +** buffer specifications. +** PRTransmitFileFlags flags +** If the flags indicate that the connection should be closed, +** it will be done immediately after transferring the file, unless +** the operation is unsuccessful. +.* PRIntervalTime timeout + * Time limit for completion of the send operation. +** +** RETURNS: +** Returns the number of bytes written or -1 if the operation failed. +** If an error occurs while sending the file, the PR_TRANSMITFILE_CLOSE_ +** SOCKET flag is ignored. The reason for the failure is obtained +** by calling PR_GetError(). +************************************************************************** +*/ + +struct PRSendFileData { + PRFileDesc *fd; /* file to send */ + PRUint32 file_offset; /* file offset */ + PRSize file_nbytes; /* number of bytes of file data to send */ + /* if 0, send data from file_offset to */ + /* end-of-file. */ + const void *header; /* header buffer */ + PRInt32 hlen; /* header len */ + const void *trailer; /* trailer buffer */ + PRInt32 tlen; /* trailer len */ +}; + + +NSPR_API(PRInt32) PR_SendFile( + PRFileDesc *networkSocket, PRSendFileData *sendData, + PRTransmitFileFlags flags, PRIntervalTime timeout); + +/* +************************************************************************* +** FUNCTION: PR_AcceptRead +** DESCRIPTION: +** AcceptRead accepts a new connection, returns the newly created +** socket's descriptor and also returns the connecting peer's address. +** AcceptRead, as its name suggests, also receives the first block of data +** sent by the peer. +** +** INPUTS: +** PRFileDesc *listenSock +** A socket descriptor that has been called with the PR_Listen() +** function, also known as the rendezvous socket. +** void *buf +** A pointer to a buffer to receive data sent by the client. This +** buffer must be large enough to receive bytes of data +** and two PRNetAddr structures, plus an extra 32 bytes. See: +** PR_ACCEPT_READ_BUF_OVERHEAD. +** PRInt32 amount +** The number of bytes of client data to receive. Does not include +** the size of the PRNetAddr structures. If 0, no data will be read +** from the client. +** PRIntervalTime timeout +** The timeout interval only applies to the read portion of the +** operation. PR_AcceptRead will block indefinitely until the +** connection is accepted; the read will timeout after the timeout +** interval elapses. +** OUTPUTS: +** PRFileDesc **acceptedSock +** The file descriptor for the newly connected socket. This parameter +** will only be valid if the function return does not indicate failure. +** PRNetAddr **peerAddr, +** The address of the remote socket. This parameter will only be +** valid if the function return does not indicate failure. The +** returned address is not guaranteed to be properly aligned. +** +** RETURNS: +** The number of bytes read from the client or -1 on failure. The reason +** for the failure is obtained by calling PR_GetError(). +************************************************************************** +**/ +/* define buffer overhead constant. Add this value to the user's +** data length when allocating a buffer to accept data. +** Example: +** #define USER_DATA_SIZE 10 +** char buf[USER_DATA_SIZE + PR_ACCEPT_READ_BUF_OVERHEAD]; +** bytesRead = PR_AcceptRead( s, fd, &a, &p, USER_DATA_SIZE, ...); +*/ +#define PR_ACCEPT_READ_BUF_OVERHEAD (32+(2*sizeof(PRNetAddr))) + +NSPR_API(PRInt32) PR_AcceptRead( + PRFileDesc *listenSock, PRFileDesc **acceptedSock, + PRNetAddr **peerAddr, void *buf, PRInt32 amount, PRIntervalTime timeout); + +/* +************************************************************************* +** FUNCTION: PR_NewTCPSocketPair +** DESCRIPTION: +** Create a new TCP socket pair. The returned descriptors can be used +** interchangeably; they are interconnected full-duplex descriptors: data +** written to one can be read from the other and vice-versa. +** +** INPUTS: +** None +** OUTPUTS: +** PRFileDesc *fds[2] +** The file descriptor pair for the newly created TCP sockets. +** RETURN: PRStatus +** Upon successful completion of TCP socket pair, PR_NewTCPSocketPair +** returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further +** failure information can be obtained by calling PR_GetError(). +** XXX can we implement this on windoze and mac? +************************************************************************** +**/ +NSPR_API(PRStatus) PR_NewTCPSocketPair(PRFileDesc *fds[2]); + +/* +************************************************************************* +** FUNCTION: PR_GetSockName +** DESCRIPTION: +** Get socket name. Return the network address for this socket. +** +** INPUTS: +** PRFileDesc *fd +** Points to a PRFileDesc object representing the socket. +** OUTPUTS: +** PRNetAddr *addr +** Returns the address of the socket in its own communication space. +** RETURN: PRStatus +** Upon successful completion, PR_GetSockName returns PR_SUCCESS. +** Otherwise, it returns PR_FAILURE. Further failure information can +** be obtained by calling PR_GetError(). +************************************************************************** +**/ +NSPR_API(PRStatus) PR_GetSockName(PRFileDesc *fd, PRNetAddr *addr); + +/* +************************************************************************* +** FUNCTION: PR_GetPeerName +** DESCRIPTION: +** Get name of the connected peer. Return the network address for the +** connected peer socket. +** +** INPUTS: +** PRFileDesc *fd +** Points to a PRFileDesc object representing the connected peer. +** OUTPUTS: +** PRNetAddr *addr +** Returns the address of the connected peer in its own communication +** space. +** RETURN: PRStatus +** Upon successful completion, PR_GetPeerName returns PR_SUCCESS. +** Otherwise, it returns PR_FAILURE. Further failure information can +** be obtained by calling PR_GetError(). +************************************************************************** +**/ +NSPR_API(PRStatus) PR_GetPeerName(PRFileDesc *fd, PRNetAddr *addr); + +NSPR_API(PRStatus) PR_GetSocketOption( + PRFileDesc *fd, PRSocketOptionData *data); + +NSPR_API(PRStatus) PR_SetSocketOption( + PRFileDesc *fd, const PRSocketOptionData *data); + +/* + ********************************************************************* + * + * File descriptor inheritance + * + ********************************************************************* + */ + +/* + ************************************************************************ + * FUNCTION: PR_SetFDInheritable + * DESCRIPTION: + * Set the inheritance attribute of a file descriptor. + * + * INPUTS: + * PRFileDesc *fd + * Points to a PRFileDesc object. + * PRBool inheritable + * If PR_TRUE, the file descriptor fd is set to be inheritable + * by a child process. If PR_FALSE, the file descriptor is set + * to be not inheritable by a child process. + * RETURN: PRStatus + * Upon successful completion, PR_SetFDInheritable returns PR_SUCCESS. + * Otherwise, it returns PR_FAILURE. Further failure information can + * be obtained by calling PR_GetError(). + ************************************************************************* + */ +NSPR_API(PRStatus) PR_SetFDInheritable( + PRFileDesc *fd, + PRBool inheritable); + +/* + ************************************************************************ + * FUNCTION: PR_GetInheritedFD + * DESCRIPTION: + * Get an inherited file descriptor with the specified name. + * + * INPUTS: + * const char *name + * The name of the inherited file descriptor. + * RETURN: PRFileDesc * + * Upon successful completion, PR_GetInheritedFD returns the + * inherited file descriptor with the specified name. Otherwise, + * it returns NULL. Further failure information can be obtained + * by calling PR_GetError(). + ************************************************************************* + */ +NSPR_API(PRFileDesc *) PR_GetInheritedFD(const char *name); + +/* + ********************************************************************* + * + * Memory-mapped files + * + ********************************************************************* + */ + +typedef struct PRFileMap PRFileMap; + +/* + * protection options for read and write accesses of a file mapping + */ +typedef enum PRFileMapProtect { + PR_PROT_READONLY, /* read only */ + PR_PROT_READWRITE, /* readable, and write is shared */ + PR_PROT_WRITECOPY /* readable, and write is private (copy-on-write) */ +} PRFileMapProtect; + +NSPR_API(PRFileMap *) PR_CreateFileMap( + PRFileDesc *fd, + PRInt64 size, + PRFileMapProtect prot); + +/* + * return the alignment (in bytes) of the offset argument to PR_MemMap + */ +NSPR_API(PRInt32) PR_GetMemMapAlignment(void); + +NSPR_API(void *) PR_MemMap( + PRFileMap *fmap, + PROffset64 offset, /* must be aligned and sized according to the + * return value of PR_GetMemMapAlignment() */ + PRUint32 len); + +NSPR_API(PRStatus) PR_MemUnmap(void *addr, PRUint32 len); + +NSPR_API(PRStatus) PR_CloseFileMap(PRFileMap *fmap); + +/* + * Synchronously flush the given memory-mapped address range of the given open + * file to disk. The function does not return until all modified data have + * been written to disk. + * + * On some platforms, the function will call PR_Sync(fd) internally if it is + * necessary for flushing modified data to disk synchronously. + */ +NSPR_API(PRStatus) PR_SyncMemMap( + PRFileDesc *fd, + void *addr, + PRUint32 len); + +/* + ****************************************************************** + * + * Interprocess communication + * + ****************************************************************** + */ + +/* + * Creates an anonymous pipe and returns file descriptors for the + * read and write ends of the pipe. + */ + +NSPR_API(PRStatus) PR_CreatePipe( + PRFileDesc **readPipe, + PRFileDesc **writePipe +); + +/************************************************************************/ +/************** The following definitions are for poll ******************/ +/************************************************************************/ + +struct PRPollDesc { + PRFileDesc* fd; + PRInt16 in_flags; + PRInt16 out_flags; +}; + +/* +** Bit values for PRPollDesc.in_flags or PRPollDesc.out_flags. Binary-or +** these together to produce the desired poll request. +*/ + +#if defined(_PR_POLL_BACKCOMPAT) + +#include +#define PR_POLL_READ POLLIN +#define PR_POLL_WRITE POLLOUT +#define PR_POLL_EXCEPT POLLPRI +#define PR_POLL_ERR POLLERR /* only in out_flags */ +#define PR_POLL_NVAL POLLNVAL /* only in out_flags when fd is bad */ +#define PR_POLL_HUP POLLHUP /* only in out_flags */ + +#else /* _PR_POLL_BACKCOMPAT */ + +#define PR_POLL_READ 0x1 +#define PR_POLL_WRITE 0x2 +#define PR_POLL_EXCEPT 0x4 +#define PR_POLL_ERR 0x8 /* only in out_flags */ +#define PR_POLL_NVAL 0x10 /* only in out_flags when fd is bad */ +#define PR_POLL_HUP 0x20 /* only in out_flags */ + +#endif /* _PR_POLL_BACKCOMPAT */ + +/* +************************************************************************* +** FUNCTION: PR_Poll +** DESCRIPTION: +** +** The call returns as soon as I/O is ready on one or more of the underlying +** socket objects. A count of the number of ready descriptors is +** returned unless a timeout occurs in which case zero is returned. +** +** PRPollDesc.fd should be set to a pointer to a PRFileDesc object +** representing a socket. This field can be set to NULL to indicate to +** PR_Poll that this PRFileDesc object should be ignored. +** PRPollDesc.in_flags should be set to the desired request +** (read/write/except or some combination). Upon successful return from +** this call PRPollDesc.out_flags will be set to indicate what kind of +** i/o can be performed on the respective descriptor. PR_Poll() uses the +** out_flags fields as scratch variables during the call. If PR_Poll() +** returns 0 or -1, the out_flags fields do not contain meaningful values +** and must not be used. +** +** INPUTS: +** PRPollDesc *pds A pointer to an array of PRPollDesc +** +** PRIntn npds The number of elements in the array +** If this argument is zero PR_Poll is +** equivalent to a PR_Sleep(timeout). +** +** PRIntervalTime timeout Amount of time the call will block waiting +** for I/O to become ready. If this time expires +** w/o any I/O becoming ready, the result will +** be zero. +** +** OUTPUTS: None +** RETURN: +** PRInt32 Number of PRPollDesc's with events or zero +** if the function timed out or -1 on failure. +** The reason for the failure is obtained by +** calling PR_GetError(). +************************************************************************** +*/ +NSPR_API(PRInt32) PR_Poll( + PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout); + +/* +************************************************************************** +** +** Pollable events +** +** A pollable event is a special kind of file descriptor. +** The only I/O operation you can perform on a pollable event +** is to poll it with the PR_POLL_READ flag. You can't +** read from or write to a pollable event. +** +** The purpose of a pollable event is to combine event waiting +** with I/O waiting in a single PR_Poll call. Pollable events +** are implemented using a pipe or a pair of TCP sockets +** connected via the loopback address, therefore setting and +** waiting for pollable events are expensive operating system +** calls. Do not use pollable events for general thread +** synchronization. Use condition variables instead. +** +** A pollable event has two states: set and unset. Events +** are not queued, so there is no notion of an event count. +** A pollable event is either set or unset. +** +** A new pollable event is created by a PR_NewPollableEvent +** call and is initially in the unset state. +** +** PR_WaitForPollableEvent blocks the calling thread until +** the pollable event is set, and then it atomically unsets +** the pollable event before it returns. +** +** To set a pollable event, call PR_SetPollableEvent. +** +** One can call PR_Poll with the PR_POLL_READ flag on a pollable +** event. When the pollable event is set, PR_Poll returns with +** the PR_POLL_READ flag set in the out_flags. +** +** To close a pollable event, call PR_DestroyPollableEvent +** (not PR_Close). +** +************************************************************************** +*/ + +NSPR_API(PRFileDesc *) PR_NewPollableEvent(void); + +NSPR_API(PRStatus) PR_DestroyPollableEvent(PRFileDesc *event); + +NSPR_API(PRStatus) PR_SetPollableEvent(PRFileDesc *event); + +NSPR_API(PRStatus) PR_WaitForPollableEvent(PRFileDesc *event); + +PR_END_EXTERN_C + +#endif /* prio_h___ */ diff --git a/illumos-x86_64/usr/include/mps/pripcsem.h b/illumos-x86_64/usr/include/mps/pripcsem.h new file mode 100644 index 00000000..f5a524da --- /dev/null +++ b/illumos-x86_64/usr/include/mps/pripcsem.h @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * File: pripcsem.h + * + * Description: named semaphores for interprocess + * synchronization + * + * Unrelated processes obtain access to a shared semaphore + * by specifying its name. + * + * Our goal is to support named semaphores on at least + * Unix and Win32 platforms. The implementation will use + * one of the three native semaphore APIs: POSIX, System V, + * and Win32. + * + * Because POSIX named semaphores have kernel persistence, + * we are forced to have a delete function in this API. + */ + +#ifndef pripcsem_h___ +#define pripcsem_h___ + +#include "prtypes.h" +#include "prio.h" + +PR_BEGIN_EXTERN_C + +/* + * PRSem is an opaque structure that represents a named + * semaphore. + */ +typedef struct PRSem PRSem; + +/* + * PR_OpenSemaphore -- + * + * Create or open a named semaphore with the specified name. + * A handle to the semaphore is returned. + * + * If the named semaphore doesn't exist and the PR_SEM_CREATE + * flag is specified, the named semaphore is created. The + * created semaphore needs to be removed from the system with + * a PR_DeleteSemaphore call. + * + * If PR_SEM_CREATE is specified, the third argument is the + * access permission bits of the new semaphore (same + * interpretation as the mode argument to PR_Open) and the + * fourth argument is the initial value of the new semaphore. + * If PR_SEM_CREATE is not specified, the third and fourth + * arguments are ignored. + */ + +#define PR_SEM_CREATE 0x1 /* create if not exist */ +#define PR_SEM_EXCL 0x2 /* fail if already exists */ + +NSPR_API(PRSem *) PR_OpenSemaphore( + const char *name, PRIntn flags, PRIntn mode, PRUintn value); + +/* + * PR_WaitSemaphore -- + * + * If the value of the semaphore is > 0, decrement the value and return. + * If the value is 0, sleep until the value becomes > 0, then decrement + * the value and return. + * + * The "test and decrement" operation is performed atomically. + */ + +NSPR_API(PRStatus) PR_WaitSemaphore(PRSem *sem); + +/* + * PR_PostSemaphore -- + * + * Increment the value of the named semaphore by 1. + */ + +NSPR_API(PRStatus) PR_PostSemaphore(PRSem *sem); + +/* + * PR_CloseSemaphore -- + * + * Close a named semaphore handle. + */ + +NSPR_API(PRStatus) PR_CloseSemaphore(PRSem *sem); + +/* + * PR_DeleteSemaphore -- + * + * Remove a named semaphore from the system. + */ + +NSPR_API(PRStatus) PR_DeleteSemaphore(const char *name); + +PR_END_EXTERN_C + +#endif /* pripcsem_h___ */ diff --git a/illumos-x86_64/usr/include/mps/private/pprio.h b/illumos-x86_64/usr/include/mps/private/pprio.h new file mode 100644 index 00000000..be8252b8 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/private/pprio.h @@ -0,0 +1,242 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: pprio.h +** +** Description: Private definitions for I/O related structures +*/ + +#ifndef pprio_h___ +#define pprio_h___ + +#include "prtypes.h" +#include "prio.h" + +PR_BEGIN_EXTERN_C + +/************************************************************************/ +/************************************************************************/ + +#ifdef _WIN64 +typedef __int64 PROsfd; +#else +typedef PRInt32 PROsfd; +#endif + +/* Return the method tables for files, tcp sockets and udp sockets */ +NSPR_API(const PRIOMethods*) PR_GetFileMethods(void); +NSPR_API(const PRIOMethods*) PR_GetTCPMethods(void); +NSPR_API(const PRIOMethods*) PR_GetUDPMethods(void); +NSPR_API(const PRIOMethods*) PR_GetPipeMethods(void); + +/* +** Convert a NSPR socket handle to a native socket handle. +** +** Using this function makes your code depend on the properties of the +** current NSPR implementation, which may change (although extremely +** unlikely because of NSPR's backward compatibility requirement). Avoid +** using it if you can. +** +** If you use this function, you need to understand what NSPR does to +** the native handle. For example, NSPR puts native socket handles in +** non-blocking mode or associates them with an I/O completion port (the +** WINNT build configuration only). Your use of the native handle should +** not interfere with NSPR's use of the native handle. If your code +** changes the configuration of the native handle, (e.g., changes it to +** blocking or closes it), NSPR will not work correctly. +*/ +NSPR_API(PROsfd) PR_FileDesc2NativeHandle(PRFileDesc *); +NSPR_API(void) PR_ChangeFileDescNativeHandle(PRFileDesc *, PROsfd); +NSPR_API(PRFileDesc*) PR_AllocFileDesc(PROsfd osfd, + const PRIOMethods *methods); +NSPR_API(void) PR_FreeFileDesc(PRFileDesc *fd); +/* +** Import an existing OS file to NSPR. +*/ +NSPR_API(PRFileDesc*) PR_ImportFile(PROsfd osfd); +NSPR_API(PRFileDesc*) PR_ImportPipe(PROsfd osfd); +NSPR_API(PRFileDesc*) PR_ImportTCPSocket(PROsfd osfd); +NSPR_API(PRFileDesc*) PR_ImportUDPSocket(PROsfd osfd); + + +/* + ************************************************************************* + * FUNCTION: PR_CreateSocketPollFd + * DESCRIPTION: + * Create a PRFileDesc wrapper for a native socket handle, for use with + * PR_Poll only + * INPUTS: + * None + * OUTPUTS: + * None + * RETURN: PRFileDesc* + * Upon successful completion, PR_CreateSocketPollFd returns a pointer + * to the PRFileDesc created for the native socket handle + * Returns a NULL pointer if the create of a new PRFileDesc failed + * + ************************************************************************** + */ + +NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PROsfd osfd); + +/* + ************************************************************************* + * FUNCTION: PR_DestroySocketPollFd + * DESCRIPTION: + * Destroy the PRFileDesc wrapper created by PR_CreateSocketPollFd + * INPUTS: + * None + * OUTPUTS: + * None + * RETURN: PRFileDesc* + * Upon successful completion, PR_DestroySocketPollFd returns + * PR_SUCCESS, else PR_FAILURE + * + ************************************************************************** + */ + +NSPR_API(PRStatus) PR_DestroySocketPollFd(PRFileDesc *fd); + + +/* +** Macros for PR_Socket +** +** Socket types: PR_SOCK_STREAM, PR_SOCK_DGRAM +*/ + +#ifdef WIN32 + +#define PR_SOCK_STREAM 1 +#define PR_SOCK_DGRAM 2 + +#else /* WIN32 */ + +#define PR_SOCK_STREAM SOCK_STREAM +#define PR_SOCK_DGRAM SOCK_DGRAM + +#endif /* WIN32 */ + +/* +** Create a new Socket; this function is obsolete. +*/ +NSPR_API(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto); + +/* FUNCTION: PR_LockFile +** DESCRIPTION: +** Lock a file for exclusive access. +** RETURNS: +** PR_SUCCESS when the lock is held +** PR_FAILURE otherwise +*/ +NSPR_API(PRStatus) PR_LockFile(PRFileDesc *fd); + +/* FUNCTION: PR_TLockFile +** DESCRIPTION: +** Test and Lock a file for exclusive access. Do not block if the +** file cannot be locked immediately. +** RETURNS: +** PR_SUCCESS when the lock is held +** PR_FAILURE otherwise +*/ +NSPR_API(PRStatus) PR_TLockFile(PRFileDesc *fd); + +/* FUNCTION: PR_UnlockFile +** DESCRIPTION: +** Unlock a file which has been previously locked successfully by this +** process. +** RETURNS: +** PR_SUCCESS when the lock is released +** PR_FAILURE otherwise +*/ +NSPR_API(PRStatus) PR_UnlockFile(PRFileDesc *fd); + +/* +** Emulate acceptread by accept and recv. +*/ +NSPR_API(PRInt32) PR_EmulateAcceptRead(PRFileDesc *sd, PRFileDesc **nd, + PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout); + +/* +** Emulate sendfile by reading from the file and writing to the socket. +** The file is memory-mapped if memory-mapped files are supported. +*/ +NSPR_API(PRInt32) PR_EmulateSendFile( + PRFileDesc *networkSocket, PRSendFileData *sendData, + PRTransmitFileFlags flags, PRIntervalTime timeout); + +#ifdef WIN32 +/* FUNCTION: PR_NTFast_AcceptRead +** DESCRIPTION: +** NT has the notion of an "accept context", which is only needed in +** order to make certain calls. By default, a socket connected via +** AcceptEx can only do a limited number of things without updating +** the acceptcontext. The generic version of PR_AcceptRead always +** updates the accept context. This version does not. +**/ +NSPR_API(PRInt32) PR_NTFast_AcceptRead(PRFileDesc *sd, PRFileDesc **nd, + PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime t); + +typedef void (*_PR_AcceptTimeoutCallback)(void *); + +/* FUNCTION: PR_NTFast_AcceptRead_WithTimeoutCallback +** DESCRIPTION: +** The AcceptEx call combines the accept with the read function. However, +** our daemon threads need to be able to wakeup and reliably flush their +** log buffers if the Accept times out. However, with the current blocking +** interface to AcceptRead, there is no way for us to timeout the Accept; +** this is because when we timeout the Read, we can close the newly +** socket and continue; but when we timeout the accept itself, there is no +** new socket to timeout. So instead, this version of the function is +** provided. After the initial timeout period elapses on the accept() +** portion of the function, it will call the callback routine and then +** continue the accept. If the timeout occurs on the read, it will +** close the connection and return error. +*/ +NSPR_API(PRInt32) PR_NTFast_AcceptRead_WithTimeoutCallback( + PRFileDesc *sd, + PRFileDesc **nd, + PRNetAddr **raddr, + void *buf, + PRInt32 amount, + PRIntervalTime t, + _PR_AcceptTimeoutCallback callback, + void *callback_arg); + +/* FUNCTION: PR_NTFast_Accept +** DESCRIPTION: +** NT has the notion of an "accept context", which is only needed in +** order to make certain calls. By default, a socket connected via +** AcceptEx can only do a limited number of things without updating +** the acceptcontext. The generic version of PR_Accept always +** updates the accept context. This version does not. +**/ +NSPR_API(PRFileDesc*) PR_NTFast_Accept(PRFileDesc *fd, PRNetAddr *addr, + PRIntervalTime timeout); + +/* FUNCTION: PR_NTFast_Update +** DESCRIPTION: +** For sockets accepted with PR_NTFast_Accept or PR_NTFastAcceptRead, +** this function will update the accept context for those sockets, +** so that the socket can make general purpose socket calls. +** Without calling this, the only operations supported on the socket +** Are PR_Read, PR_Write, PR_Transmitfile, and PR_Close. +*/ +NSPR_API(void) PR_NTFast_UpdateAcceptContext(PRFileDesc *acceptSock, + PRFileDesc *listenSock); + + +/* FUNCTION: PR_NT_CancelIo +** DESCRIPTION: +** Cancel IO operations on fd. +*/ +NSPR_API(PRStatus) PR_NT_CancelIo(PRFileDesc *fd); + + +#endif /* WIN32 */ + +PR_END_EXTERN_C + +#endif /* pprio_h___ */ diff --git a/illumos-x86_64/usr/include/mps/private/pprthred.h b/illumos-x86_64/usr/include/mps/private/pprthred.h new file mode 100644 index 00000000..e0cc7518 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/private/pprthred.h @@ -0,0 +1,295 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef pprthred_h___ +#define pprthred_h___ + +/* +** API for PR private functions. These calls are to be used by internal +** developers only. +*/ +#include "nspr.h" + +PR_BEGIN_EXTERN_C + +/*--------------------------------------------------------------------------- +** THREAD PRIVATE FUNCTIONS +---------------------------------------------------------------------------*/ + +/* +** Associate a thread object with an existing native thread. +** "type" is the type of thread object to attach +** "priority" is the priority to assign to the thread +** "stack" defines the shape of the threads stack +** +** This can return NULL if some kind of error occurs, or if memory is +** tight. This call invokes "start(obj,arg)" and returns when the +** function returns. The thread object is automatically destroyed. +** +** This call is not normally needed unless you create your own native +** thread. PR_Init does this automatically for the primordial thread. +*/ +NSPR_API(PRThread*) PR_AttachThread(PRThreadType type, + PRThreadPriority priority, + PRThreadStack *stack); + +/* +** Detach the nspr thread from the currently executing native thread. +** The thread object will be destroyed and all related data attached +** to it. The exit procs will be invoked. +** +** This call is not normally needed unless you create your own native +** thread. PR_Exit will automatially detach the nspr thread object +** created by PR_Init for the primordial thread. +** +** This call returns after the nspr thread object is destroyed. +*/ +NSPR_API(void) PR_DetachThread(void); + +/* +** Get the id of the named thread. Each thread is assigned a unique id +** when it is created or attached. +*/ +NSPR_API(PRUint32) PR_GetThreadID(PRThread *thread); + +/* +** Set the procedure that is called when a thread is dumped. The procedure +** will be applied to the argument, arg, when called. Setting the procedure +** to NULL effectively removes it. +*/ +typedef void (*PRThreadDumpProc)(PRFileDesc *fd, PRThread *t, void *arg); +NSPR_API(void) PR_SetThreadDumpProc( + PRThread* thread, PRThreadDumpProc dump, void *arg); + +/* +** Get this thread's affinity mask. The affinity mask is a 32 bit quantity +** marking a bit for each processor this process is allowed to run on. +** The processor mask is returned in the mask argument. +** The least-significant-bit represents processor 0. +** +** Returns 0 on success, -1 on failure. +*/ +NSPR_API(PRInt32) PR_GetThreadAffinityMask(PRThread *thread, PRUint32 *mask); + +/* +** Set this thread's affinity mask. +** +** Returns 0 on success, -1 on failure. +*/ +NSPR_API(PRInt32) PR_SetThreadAffinityMask(PRThread *thread, PRUint32 mask ); + +/* +** Set the default CPU Affinity mask. +** +*/ +NSPR_API(PRInt32) PR_SetCPUAffinityMask(PRUint32 mask); + +/* +** Show status of all threads to standard error output. +*/ +NSPR_API(void) PR_ShowStatus(void); + +/* +** Set thread recycle mode to on (1) or off (0) +*/ +NSPR_API(void) PR_SetThreadRecycleMode(PRUint32 flag); + + +/*--------------------------------------------------------------------------- +** THREAD PRIVATE FUNCTIONS FOR GARBAGE COLLECTIBLE THREADS +---------------------------------------------------------------------------*/ + +/* +** Only Garbage collectible threads participate in resume all, suspend all and +** enumeration operations. They are also different during creation when +** platform specific action may be needed (For example, all Solaris GC able +** threads are bound threads). +*/ + +/* +** Same as PR_CreateThread except that the thread is marked as garbage +** collectible. +*/ +NSPR_API(PRThread*) PR_CreateThreadGCAble(PRThreadType type, + void (*start)(void *arg), + void *arg, + PRThreadPriority priority, + PRThreadScope scope, + PRThreadState state, + PRUint32 stackSize); + +/* +** Same as PR_AttachThread except that the thread being attached is marked as +** garbage collectible. +*/ +NSPR_API(PRThread*) PR_AttachThreadGCAble(PRThreadType type, + PRThreadPriority priority, + PRThreadStack *stack); + +/* +** Mark the thread as garbage collectible. +*/ +NSPR_API(void) PR_SetThreadGCAble(void); + +/* +** Unmark the thread as garbage collectible. +*/ +NSPR_API(void) PR_ClearThreadGCAble(void); + +/* +** This routine prevents all other GC able threads from running. This call is needed by +** the garbage collector. +*/ +NSPR_API(void) PR_SuspendAll(void); + +/* +** This routine unblocks all other GC able threads that were suspended from running by +** PR_SuspendAll(). This call is needed by the garbage collector. +*/ +NSPR_API(void) PR_ResumeAll(void); + +/* +** Return the thread stack pointer of the given thread. +** Needed by the garbage collector. +*/ +NSPR_API(void *) PR_GetSP(PRThread *thread); + +/* +** Save the registers that the GC would find interesting into the thread +** "t". isCurrent will be non-zero if the thread state that is being +** saved is the currently executing thread. Return the address of the +** first register to be scanned as well as the number of registers to +** scan in "np". +** +** If "isCurrent" is non-zero then it is allowed for the thread context +** area to be used as scratch storage to hold just the registers +** necessary for scanning. +** +** This function simply calls the internal function _MD_HomeGCRegisters(). +*/ +NSPR_API(PRWord *) PR_GetGCRegisters(PRThread *t, int isCurrent, int *np); + +/* +** (Get|Set)ExecutionEnvironent +** +** Used by Java to associate it's execution environment so garbage collector +** can find it. If return is NULL, then it's probably not a collectable thread. +** +** There's no locking required around these calls. +*/ +NSPR_API(void*) GetExecutionEnvironment(PRThread *thread); +NSPR_API(void) SetExecutionEnvironment(PRThread* thread, void *environment); + +/* +** Enumeration function that applies "func(thread,i,arg)" to each active +** thread in the process. The enumerator returns PR_SUCCESS if the enumeration +** should continue, any other value is considered failure, and enumeration +** stops, returning the failure value from PR_EnumerateThreads. +** Needed by the garbage collector. +*/ +typedef PRStatus (PR_CALLBACK *PREnumerator)(PRThread *t, int i, void *arg); +NSPR_API(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg); + +/* +** Signature of a thread stack scanning function. It is applied to every +** contiguous group of potential pointers within a thread. Count denotes the +** number of pointers. +*/ +typedef PRStatus +(PR_CALLBACK *PRScanStackFun)(PRThread* t, + void** baseAddr, PRUword count, void* closure); + +/* +** Applies scanFun to all contiguous groups of potential pointers +** within a thread. This includes the stack, registers, and thread-local +** data. If scanFun returns a status value other than PR_SUCCESS the scan +** is aborted, and the status value is returned. +*/ +NSPR_API(PRStatus) +PR_ThreadScanStackPointers(PRThread* t, + PRScanStackFun scanFun, void* scanClosure); + +/* +** Calls PR_ThreadScanStackPointers for every thread. +*/ +NSPR_API(PRStatus) +PR_ScanStackPointers(PRScanStackFun scanFun, void* scanClosure); + +/* +** Returns a conservative estimate on the amount of stack space left +** on a thread in bytes, sufficient for making decisions about whether +** to continue recursing or not. +*/ +NSPR_API(PRUword) +PR_GetStackSpaceLeft(PRThread* t); + +/*--------------------------------------------------------------------------- +** THREAD CPU PRIVATE FUNCTIONS +---------------------------------------------------------------------------*/ + +/* +** Get a pointer to the primordial CPU. +*/ +NSPR_API(struct _PRCPU *) _PR_GetPrimordialCPU(void); + +/*--------------------------------------------------------------------------- +** THREAD SYNCHRONIZATION PRIVATE FUNCTIONS +---------------------------------------------------------------------------*/ + +/* +** Create a new named monitor (named for debugging purposes). +** Monitors are re-entrant locks with a built-in condition variable. +** +** This may fail if memory is tight or if some operating system resource +** is low. +*/ +NSPR_API(PRMonitor*) PR_NewNamedMonitor(const char* name); + +/* +** Test and then lock the lock if it's not already locked by some other +** thread. Return PR_FALSE if some other thread owned the lock at the +** time of the call. +*/ +NSPR_API(PRBool) PR_TestAndLock(PRLock *lock); + +/* +** Test and then enter the mutex associated with the monitor if it's not +** already entered by some other thread. Return PR_FALSE if some other +** thread owned the mutex at the time of the call. +*/ +NSPR_API(PRBool) PR_TestAndEnterMonitor(PRMonitor *mon); + +/* +** Return the number of times that the current thread has entered the +** mutex. Returns zero if the current thread has not entered the mutex. +*/ +NSPR_API(PRIntn) PR_GetMonitorEntryCount(PRMonitor *mon); + +/* +** Just like PR_CEnterMonitor except that if the monitor is owned by +** another thread NULL is returned. +*/ +NSPR_API(PRMonitor*) PR_CTestAndEnterMonitor(void *address); + +/*--------------------------------------------------------------------------- +** PLATFORM-SPECIFIC INITIALIZATION FUNCTIONS +---------------------------------------------------------------------------*/ + +/* I think PR_GetMonitorEntryCount is useless. All you really want is this... */ +#define PR_InMonitor(m) (PR_GetMonitorEntryCount(m) > 0) + +/*--------------------------------------------------------------------------- +** Special X-Lock hack for client +---------------------------------------------------------------------------*/ + +#ifdef XP_UNIX +extern void _PR_XLock(void); +extern void _PR_XUnlock(void); +extern PRBool _PR_XIsLocked(void); +#endif /* XP_UNIX */ + +PR_END_EXTERN_C + +#endif /* pprthred_h___ */ diff --git a/illumos-x86_64/usr/include/mps/private/prpriv.h b/illumos-x86_64/usr/include/mps/private/prpriv.h new file mode 100644 index 00000000..f45eee47 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/private/prpriv.h @@ -0,0 +1,16 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prpriv_h___ +#define prpriv_h___ + +/* + * NSPR 2.0 Private API + */ + +#include "private/pprio.h" +#include "private/pprthred.h" + +#endif /* prpriv_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prlink.h b/illumos-x86_64/usr/include/mps/prlink.h new file mode 100644 index 00000000..0e38effa --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prlink.h @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prlink_h___ +#define prlink_h___ + +/* +** API to static and dynamic linking. +*/ +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +typedef struct PRLibrary PRLibrary; + +typedef struct PRStaticLinkTable { + const char *name; + void (*fp)(void); +} PRStaticLinkTable; + +/* +** Change the default library path to the given string. The string is +** copied. This call will fail if it runs out of memory. +** +** The string provided as 'path' is copied. The caller can do whatever is +** convenient with the argument when the function is complete. +*/ +NSPR_API(PRStatus) PR_SetLibraryPath(const char *path); + +/* +** Return a character string which contains the path used to search for +** dynamically loadable libraries. +** +** The returned value is basically a copy of a PR_SetLibraryPath(). +** The storage is allocated by the runtime and becomes the responsibilty +** of the caller. +*/ +NSPR_API(char*) PR_GetLibraryPath(void); + +/* +** Given a directory name "dir" and a library name "lib" construct a full +** path name that will refer to the actual dynamically loaded +** library. This does not test for existance of said file, it just +** constructs the full filename. The name constructed is system dependent +** and prepared for PR_LoadLibrary. The result must be free'd when the +** caller is done with it. +** +** The storage for the result is allocated by the runtime and becomes the +** responsibility of the caller. +*/ +NSPR_API(char*) PR_GetLibraryName(const char *dir, const char *lib); + +/* +** +** Free the memory allocated, for the caller, by PR_GetLibraryName +*/ +NSPR_API(void) PR_FreeLibraryName(char *mem); + +/* +** Given a library "name" try to load the library. The argument "name" +** is a machine-dependent name for the library, such as the full pathname +** returned by PR_GetLibraryName. If the library is already loaded, +** this function will avoid loading the library twice. +** +** If the library is loaded successfully, then a pointer to the PRLibrary +** structure representing the library is returned. Otherwise, NULL is +** returned. +** +** This increments the reference count of the library. +*/ +NSPR_API(PRLibrary*) PR_LoadLibrary(const char *name); + +/* +** Each operating system has its preferred way of specifying +** a file in the file system. Most operating systems use +** a pathname. Mac OS Classic, on the other hand, uses the FSSpec +** structure to specify a file. PRLibSpec allows NSPR clients +** to use the type of file specification that is most efficient +** for a particular platform. +** +** On some operating systems such as Mac OS Classic, a shared library +** may contain code fragments that can be individually loaded. +** PRLibSpec also allows NSPR clients to identify a code fragment +** in a library, if code fragments are supported by the OS. +** A code fragment can be specified by name or by an integer index. +** +** Right now PRLibSpec supports four types of library specification: +** a pathname in the native character encoding, a Mac code fragment +** by name, a Mac code fragment by index, and a UTF-16 pathname. +*/ + +typedef enum PRLibSpecType { + PR_LibSpec_Pathname, + PR_LibSpec_MacNamedFragment, /* obsolete (for Mac OS Classic) */ + PR_LibSpec_MacIndexedFragment, /* obsolete (for Mac OS Classic) */ + PR_LibSpec_PathnameU /* supported only on Win32 */ +} PRLibSpecType; + +struct FSSpec; /* Mac OS Classic FSSpec */ + +typedef struct PRLibSpec { + PRLibSpecType type; + union { + /* if type is PR_LibSpec_Pathname */ + const char *pathname; + + /* if type is PR_LibSpec_MacNamedFragment */ + struct { + const struct FSSpec *fsspec; + const char *name; + } mac_named_fragment; /* obsolete (for Mac OS Classic) */ + + /* if type is PR_LibSpec_MacIndexedFragment */ + struct { + const struct FSSpec *fsspec; + PRUint32 index; + } mac_indexed_fragment; /* obsolete (for Mac OS Classic) */ + + /* if type is PR_LibSpec_PathnameU */ + const PRUnichar *pathname_u; /* supported only on Win32 */ + } value; +} PRLibSpec; + +/* +** The following bit flags may be or'd together and passed +** as the 'flags' argument to PR_LoadLibraryWithFlags. +** Flags not supported by the underlying OS are ignored. +*/ + +#define PR_LD_LAZY 0x1 /* equivalent to RTLD_LAZY on Unix */ +#define PR_LD_NOW 0x2 /* equivalent to RTLD_NOW on Unix */ +#define PR_LD_GLOBAL 0x4 /* equivalent to RTLD_GLOBAL on Unix */ +#define PR_LD_LOCAL 0x8 /* equivalent to RTLD_LOCAL on Unix */ +/* The following is equivalent to LOAD_WITH_ALTERED_SEARCH_PATH on Windows */ +#define PR_LD_ALT_SEARCH_PATH 0x10 +/* 0x8000 reserved for NSPR internal use */ + +/* +** Load the specified library, in the manner specified by 'flags'. +*/ + +NSPR_API(PRLibrary *) +PR_LoadLibraryWithFlags( + PRLibSpec libSpec, /* the shared library */ + PRIntn flags /* flags that affect the loading */ +); + +/* +** Unload a previously loaded library. If the library was a static +** library then the static link table will no longer be referenced. The +** associated PRLibrary object is freed. +** +** PR_FAILURE is returned if the library cannot be unloaded. +** +** This function decrements the reference count of the library. +*/ +NSPR_API(PRStatus) PR_UnloadLibrary(PRLibrary *lib); + +/* +** Given the name of a procedure, return the address of the function that +** implements the procedure, or NULL if no such function can be +** found. This does not find symbols in the main program (the ".exe"); +** use PR_LoadStaticLibrary to register symbols in the main program. +** +** This function does not modify the reference count of the library. +*/ +NSPR_API(void*) PR_FindSymbol(PRLibrary *lib, const char *name); + +/* +** Similar to PR_FindSymbol, except that the return value is a pointer to +** a function, and not a pointer to void. Casting between a data pointer +** and a function pointer is not portable according to the C standard. +** Any function pointer can be cast to any other function pointer. +** +** This function does not modify the reference count of the library. +*/ +typedef void (*PRFuncPtr)(void); +NSPR_API(PRFuncPtr) PR_FindFunctionSymbol(PRLibrary *lib, const char *name); + +/* +** Finds a symbol in one of the currently loaded libraries. Given the +** name of a procedure, return the address of the function that +** implements the procedure, and return the library that contains that +** symbol, or NULL if no such function can be found. This does not find +** symbols in the main program (the ".exe"); use PR_AddStaticLibrary to +** register symbols in the main program. +** +** This increments the reference count of the library. +*/ +NSPR_API(void*) PR_FindSymbolAndLibrary(const char *name, + PRLibrary* *lib); + +/* +** Similar to PR_FindSymbolAndLibrary, except that the return value is +** a pointer to a function, and not a pointer to void. Casting between a +** data pointer and a function pointer is not portable according to the C +** standard. Any function pointer can be cast to any other function pointer. +** +** This increments the reference count of the library. +*/ +NSPR_API(PRFuncPtr) PR_FindFunctionSymbolAndLibrary(const char *name, + PRLibrary* *lib); + +/* +** Register a static link table with the runtime under the name +** "name". The symbols present in the static link table will be made +** available to PR_FindSymbol. If "name" is null then the symbols will be +** made available to the library which represents the executable. The +** tables are not copied. +** +** Returns the library object if successful, null otherwise. +** +** This increments the reference count of the library. +*/ +NSPR_API(PRLibrary*) PR_LoadStaticLibrary( + const char *name, const PRStaticLinkTable *table); + +/* +** Return the pathname of the file that the library "name" was loaded +** from. "addr" is the address of a function defined in the library. +** +** The caller is responsible for freeing the result with PR_Free. +*/ +NSPR_API(char *) PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr); + +PR_END_EXTERN_C + +#endif /* prlink_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prlock.h b/illumos-x86_64/usr/include/mps/prlock.h new file mode 100644 index 00000000..9b7fdaa1 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prlock.h @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: prlock.h +** Description: API to basic locking functions of NSPR. +** +** +** NSPR provides basic locking mechanisms for thread synchronization. Locks +** are lightweight resource contention controls that prevent multiple threads +** from accessing something (code/data) simultaneously. +**/ + +#ifndef prlock_h___ +#define prlock_h___ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/**********************************************************************/ +/************************* TYPES AND CONSTANTS ************************/ +/**********************************************************************/ + +/* + * PRLock -- + * + * NSPR represents the lock as an opaque entity to the client of the + * API. All routines operate on a pointer to this opaque entity. + */ + +typedef struct PRLock PRLock; + +/**********************************************************************/ +/****************************** FUNCTIONS *****************************/ +/**********************************************************************/ + +/*********************************************************************** +** FUNCTION: PR_NewLock +** DESCRIPTION: +** Returns a pointer to a newly created opaque lock object. +** INPUTS: void +** OUTPUTS: void +** RETURN: PRLock* +** If the lock can not be created because of resource constraints, NULL +** is returned. +** +***********************************************************************/ +NSPR_API(PRLock*) PR_NewLock(void); + +/*********************************************************************** +** FUNCTION: PR_DestroyLock +** DESCRIPTION: +** Destroys a given opaque lock object. +** INPUTS: PRLock *lock +** Lock to be freed. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +NSPR_API(void) PR_DestroyLock(PRLock *lock); + +/*********************************************************************** +** FUNCTION: PR_Lock +** DESCRIPTION: +** Lock a lock. +** INPUTS: PRLock *lock +** Lock to locked. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +NSPR_API(void) PR_Lock(PRLock *lock); + +/*********************************************************************** +** FUNCTION: PR_Unlock +** DESCRIPTION: +** Unlock a lock. Unlocking an unlocked lock has undefined results. +** INPUTS: PRLock *lock +** Lock to unlocked. +** OUTPUTS: void +** RETURN: PR_STATUS +** Returns PR_FAILURE if the caller does not own the lock. +***********************************************************************/ +NSPR_API(PRStatus) PR_Unlock(PRLock *lock); + +/*********************************************************************** +** MACRO: PR_ASSERT_CURRENT_THREAD_OWNS_LOCK +** DESCRIPTION: +** If the current thread owns |lock|, this assertion is guaranteed to +** succeed. Otherwise, the behavior of this function is undefined. +** INPUTS: PRLock *lock +** Lock to assert ownership of. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +#if defined(DEBUG) || defined(FORCE_PR_ASSERT) +#define PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(/* PrLock* */ lock) \ + PR_AssertCurrentThreadOwnsLock(lock) +#else +#define PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(/* PrLock* */ lock) +#endif + +/* Don't call this function directly. */ +NSPR_API(void) PR_AssertCurrentThreadOwnsLock(PRLock *lock); + +PR_END_EXTERN_C + +#endif /* prlock_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prlog.h b/illumos-x86_64/usr/include/mps/prlog.h new file mode 100644 index 00000000..1922c255 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prlog.h @@ -0,0 +1,226 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prlog_h___ +#define prlog_h___ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* +** prlog.h -- Declare interfaces to NSPR's Logging service +** +** NSPR provides a logging service that is used by NSPR itself and is +** available to client programs. +** +** To use the service from a client program, you should create a +** PRLogModuleInfo structure by calling PR_NewLogModule(). After +** creating the LogModule, you can write to the log using the PR_LOG() +** macro. +** +** Initialization of the log service is handled by NSPR initialization. +** +** At execution time, you must enable the log service. To enable the +** log service, set the environment variable: NSPR_LOG_MODULES +** variable. +** +** NSPR_LOG_MODULES variable has the form: +** +** :[, :]* +** +** Where: +** is the name passed to PR_NewLogModule(). +** is a numeric constant, e.g. 5. This value is the maximum +** value of a log event, enumerated by PRLogModuleLevel, that you want +** written to the log. +** +** For example: to record all events of greater value than or equal to +** PR_LOG_ERROR for a LogModule names "gizmo", say: +** +** set NSPR_LOG_MODULES=gizmo:2 +** +** Note that you must specify the numeric value of PR_LOG_ERROR. +** +** Special LogModule names are provided for controlling NSPR's log +** service at execution time. These controls should be set in the +** NSPR_LOG_MODULES environment variable at execution time to affect +** NSPR's log service for your application. +** +** The special LogModule "all" enables all LogModules. To enable all +** LogModule calls to PR_LOG(), say: +** +** set NSPR_LOG_MODULES=all:5 +** +** The special LogModule name "sync" tells the NSPR log service to do +** unbuffered logging. +** +** The special LogModule name "bufsize:" tells NSPR to set the +** log buffer to . +** +** The environment variable NSPR_LOG_FILE specifies the log file to use +** unless the default of "stderr" is acceptable. For MS Windows +** systems, NSPR_LOG_FILE can be set to a special value: "WinDebug" +** (case sensitive). This value causes PR_LOG() output to be written +** using the Windows API OutputDebugString(). OutputDebugString() +** writes to the debugger window; some people find this helpful. +** +** +** To put log messages in your programs, use the PR_LOG macro: +** +** PR_LOG(, , (, *)); +** +** Where is the address of a PRLogModuleInfo structure, and +** is one of the levels defined by the enumeration: +** PRLogModuleLevel. is a printf() style of argument list. That +** is: (fmtstring, ...). +** +** Example: +** +** main() { +** PRIntn one = 1; +** PRLogModuleInfo * myLm = PR_NewLogModule("gizmo"); +** PR_LOG( myLm, PR_LOG_ALWAYS, ("Log this! %d\n", one)); +** return; +** } +** +** Note the use of printf() style arguments as the third agrument(s) to +** PR_LOG(). +** +** After compiling and linking you application, set the environment: +** +** set NSPR_LOG_MODULES=gizmo:5 +** set NSPR_LOG_FILE=logfile.txt +** +** When you execute your application, the string "Log this! 1" will be +** written to the file "logfile.txt". +** +** Note to NSPR engineers: a number of PRLogModuleInfo structures are +** defined and initialized in prinit.c. See this module for ideas on +** what to log where. +** +*/ + +typedef enum PRLogModuleLevel { + PR_LOG_NONE = 0, /* nothing */ + PR_LOG_ALWAYS = 1, /* always printed */ + PR_LOG_ERROR = 2, /* error messages */ + PR_LOG_WARNING = 3, /* warning messages */ + PR_LOG_DEBUG = 4, /* debug messages */ + + PR_LOG_NOTICE = PR_LOG_DEBUG, /* notice messages */ + PR_LOG_WARN = PR_LOG_WARNING, /* warning messages */ + PR_LOG_MIN = PR_LOG_DEBUG, /* minimal debugging messages */ + PR_LOG_MAX = PR_LOG_DEBUG /* maximal debugging messages */ +} PRLogModuleLevel; + +/* +** One of these structures is created for each module that uses logging. +** "name" is the name of the module +** "level" is the debugging level selected for that module +*/ +typedef struct PRLogModuleInfo { + const char *name; + PRLogModuleLevel level; + struct PRLogModuleInfo *next; +} PRLogModuleInfo; + +/* +** Create a new log module. +*/ +NSPR_API(PRLogModuleInfo*) PR_NewLogModule(const char *name); + +/* +** Set the file to use for logging. Returns PR_FALSE if the file cannot +** be created +*/ +NSPR_API(PRBool) PR_SetLogFile(const char *name); + +/* +** Set the size of the logging buffer. If "buffer_size" is zero then the +** logging becomes "synchronous" (or unbuffered). +*/ +NSPR_API(void) PR_SetLogBuffering(PRIntn buffer_size); + +/* +** Print a string to the log. "fmt" is a PR_snprintf format type. All +** messages printed to the log are preceeded by the name of the thread +** and a time stamp. Also, the routine provides a missing newline if one +** is not provided. +*/ +NSPR_API(void) PR_LogPrint(const char *fmt, ...); + +/* +** Flush the log to its file. +*/ +NSPR_API(void) PR_LogFlush(void); + +NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln) +PR_PRETEND_NORETURN; + +#if defined(DEBUG) || defined(FORCE_PR_LOG) +#define PR_LOGGING 1 + +#define PR_LOG_TEST(_module,_level) \ + ((_module)->level >= (_level)) + +/* +** Log something. +** "module" is the address of a PRLogModuleInfo structure +** "level" is the desired logging level +** "args" is a variable length list of arguments to print, in the following +** format: ("printf style format string", ...) +*/ +#define PR_LOG(_module,_level,_args) \ + PR_BEGIN_MACRO \ + if (PR_LOG_TEST(_module,_level)) { \ + PR_LogPrint _args; \ + } \ + PR_END_MACRO + +#else /* defined(DEBUG) || defined(FORCE_PR_LOG) */ + +#undef PR_LOGGING +#define PR_LOG_TEST(module,level) 0 +#define PR_LOG(module,level,args) + +#endif /* defined(DEBUG) || defined(FORCE_PR_LOG) */ + +#ifndef NO_NSPR_10_SUPPORT + +#ifdef PR_LOGGING +#define PR_LOG_BEGIN PR_LOG +#define PR_LOG_END PR_LOG +#define PR_LOG_DEFINE PR_NewLogModule +#else +#define PR_LOG_BEGIN(module,level,args) +#define PR_LOG_END(module,level,args) +#define PR_LOG_DEFINE(_name) NULL +#endif /* PR_LOGGING */ + +#endif /* NO_NSPR_10_SUPPORT */ + +#if defined(DEBUG) || defined(FORCE_PR_ASSERT) + +#define PR_ASSERT(_expr) \ + ((_expr)?((void)0):PR_Assert(# _expr,__FILE__,__LINE__)) + +#define PR_ASSERT_ARG(_expr) PR_ASSERT(_expr) + +#define PR_NOT_REACHED(_reasonStr) \ + PR_Assert(_reasonStr,__FILE__,__LINE__) + +#else + +#define PR_ASSERT(expr) ((void) 0) +/* PR_ASSERT_ARG avoids compiler warning: unused variable */ +#define PR_ASSERT_ARG(expr) ((void)(0 && (expr))) +#define PR_NOT_REACHED(reasonStr) + +#endif /* defined(DEBUG) || defined(FORCE_PR_ASSERT) */ + +PR_END_EXTERN_C + +#endif /* prlog_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prlong.h b/illumos-x86_64/usr/include/mps/prlong.h new file mode 100644 index 00000000..7cc1d567 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prlong.h @@ -0,0 +1,403 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: prlong.h +** Description: Portable access to 64 bit numerics +** +** Long-long (64-bit signed integer type) support. Some C compilers +** don't support 64 bit integers yet, so we use these macros to +** support both machines that do and don't. +**/ +#ifndef prlong_h___ +#define prlong_h___ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/*********************************************************************** +** DEFINES: LL_MaxInt +** LL_MinInt +** LL_Zero +** LL_MaxUint +** DESCRIPTION: +** Various interesting constants and static variable +** initializer +***********************************************************************/ +NSPR_API(PRInt64) LL_MaxInt(void); +NSPR_API(PRInt64) LL_MinInt(void); +NSPR_API(PRInt64) LL_Zero(void); +NSPR_API(PRUint64) LL_MaxUint(void); + +#if defined(HAVE_LONG_LONG) + +/* Keep this in sync with prtypes.h. */ +#if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF) +#define LL_MAXINT 9223372036854775807L +#define LL_MININT (-LL_MAXINT - 1L) +#define LL_ZERO 0L +#define LL_MAXUINT 18446744073709551615UL +#define LL_INIT(hi, lo) ((hi ## L << 32) + lo ## L) +#elif defined(WIN32) && !defined(__GNUC__) +#define LL_MAXINT 9223372036854775807i64 +#define LL_MININT (-LL_MAXINT - 1i64) +#define LL_ZERO 0i64 +#define LL_MAXUINT 18446744073709551615ui64 +#define LL_INIT(hi, lo) ((hi ## i64 << 32) + lo ## i64) +#else +#define LL_MAXINT 9223372036854775807LL +#define LL_MININT (-LL_MAXINT - 1LL) +#define LL_ZERO 0LL +#define LL_MAXUINT 18446744073709551615ULL +#define LL_INIT(hi, lo) ((hi ## LL << 32) + lo ## LL) +#endif + +/*********************************************************************** +** MACROS: LL_* +** DESCRIPTION: +** The following macros define portable access to the 64 bit +** math facilities. +** +***********************************************************************/ + +/*********************************************************************** +** MACROS: LL_ +** +** LL_IS_ZERO Test for zero +** LL_EQ Test for equality +** LL_NE Test for inequality +** LL_GE_ZERO Test for zero or positive +** LL_CMP Compare two values +***********************************************************************/ +#define LL_IS_ZERO(a) ((a) == 0) +#define LL_EQ(a, b) ((a) == (b)) +#define LL_NE(a, b) ((a) != (b)) +#define LL_GE_ZERO(a) ((a) >= 0) +#define LL_CMP(a, op, b) ((PRInt64)(a) op (PRInt64)(b)) +#define LL_UCMP(a, op, b) ((PRUint64)(a) op (PRUint64)(b)) + +/*********************************************************************** +** MACROS: LL_ +** +** LL_AND Logical and +** LL_OR Logical or +** LL_XOR Logical exclusion +** LL_OR2 A disgusting deviation +** LL_NOT Negation (one's complement) +***********************************************************************/ +#define LL_AND(r, a, b) ((r) = (a) & (b)) +#define LL_OR(r, a, b) ((r) = (a) | (b)) +#define LL_XOR(r, a, b) ((r) = (a) ^ (b)) +#define LL_OR2(r, a) ((r) = (r) | (a)) +#define LL_NOT(r, a) ((r) = ~(a)) + +/*********************************************************************** +** MACROS: LL_ +** +** LL_NEG Negation (two's complement) +** LL_ADD Summation (two's complement) +** LL_SUB Difference (two's complement) +***********************************************************************/ +#define LL_NEG(r, a) ((r) = -(a)) +#define LL_ADD(r, a, b) ((r) = (a) + (b)) +#define LL_SUB(r, a, b) ((r) = (a) - (b)) + +/*********************************************************************** +** MACROS: LL_ +** +** LL_MUL Product (two's complement) +** LL_DIV Quotient (two's complement) +** LL_MOD Modulus (two's complement) +***********************************************************************/ +#define LL_MUL(r, a, b) ((r) = (a) * (b)) +#define LL_DIV(r, a, b) ((r) = (a) / (b)) +#define LL_MOD(r, a, b) ((r) = (a) % (b)) + +/*********************************************************************** +** MACROS: LL_ +** +** LL_SHL Shift left [0..64] bits +** LL_SHR Shift right [0..64] bits with sign extension +** LL_USHR Unsigned shift right [0..64] bits +** LL_ISHL Signed shift left [0..64] bits +***********************************************************************/ +#define LL_SHL(r, a, b) ((r) = (PRInt64)(a) << (b)) +#define LL_SHR(r, a, b) ((r) = (PRInt64)(a) >> (b)) +#define LL_USHR(r, a, b) ((r) = (PRUint64)(a) >> (b)) +#define LL_ISHL(r, a, b) ((r) = (PRInt64)(a) << (b)) + +/*********************************************************************** +** MACROS: LL_ +** +** LL_L2I Convert to signed 32 bit +** LL_L2UI Convert to unsigned 32 bit +** LL_L2F Convert to floating point +** LL_L2D Convert to floating point +** LL_I2L Convert signed to 64 bit +** LL_UI2L Convert unsigned to 64 bit +** LL_F2L Convert float to 64 bit +** LL_D2L Convert float to 64 bit +***********************************************************************/ +#define LL_L2I(i, l) ((i) = (PRInt32)(l)) +#define LL_L2UI(ui, l) ((ui) = (PRUint32)(l)) +#define LL_L2F(f, l) ((f) = (PRFloat64)(l)) +#define LL_L2D(d, l) ((d) = (PRFloat64)(l)) + +#define LL_I2L(l, i) ((l) = (PRInt64)(i)) +#define LL_UI2L(l, ui) ((l) = (PRInt64)(ui)) +#define LL_F2L(l, f) ((l) = (PRInt64)(f)) +#define LL_D2L(l, d) ((l) = (PRInt64)(d)) + +/*********************************************************************** +** MACROS: LL_UDIVMOD +** DESCRIPTION: +** Produce both a quotient and a remainder given an unsigned +** INPUTS: PRUint64 a: The dividend of the operation +** PRUint64 b: The quotient of the operation +** OUTPUTS: PRUint64 *qp: pointer to quotient +** PRUint64 *rp: pointer to remainder +***********************************************************************/ +#define LL_UDIVMOD(qp, rp, a, b) \ + (*(qp) = ((PRUint64)(a) / (b)), \ + *(rp) = ((PRUint64)(a) % (b))) + +#else /* !HAVE_LONG_LONG */ + +#define LL_MAXINT LL_MaxInt() +#define LL_MININT LL_MinInt() +#define LL_ZERO LL_Zero() +#define LL_MAXUINT LL_MaxUint() + +#ifdef IS_LITTLE_ENDIAN +#define LL_INIT(hi, lo) {PR_UINT32(lo), PR_UINT32(hi)} +#else +#define LL_INIT(hi, lo) {PR_UINT32(hi), PR_UINT32(lo)} +#endif + +#define LL_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0)) +#define LL_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo)) +#define LL_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo)) +#define LL_GE_ZERO(a) (((a).hi >> 31) == 0) + +#define LL_CMP(a, op, b) (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \ + ((PRInt32)(a).hi op (PRInt32)(b).hi)) +#define LL_UCMP(a, op, b) (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \ + ((a).hi op (b).hi)) + +#define LL_AND(r, a, b) ((r).lo = (a).lo & (b).lo, \ + (r).hi = (a).hi & (b).hi) +#define LL_OR(r, a, b) ((r).lo = (a).lo | (b).lo, \ + (r).hi = (a).hi | (b).hi) +#define LL_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, \ + (r).hi = (a).hi ^ (b).hi) +#define LL_OR2(r, a) ((r).lo = (r).lo | (a).lo, \ + (r).hi = (r).hi | (a).hi) +#define LL_NOT(r, a) ((r).lo = ~(a).lo, \ + (r).hi = ~(a).hi) + +#define LL_NEG(r, a) ((r).lo = -(PRInt32)(a).lo, \ + (r).hi = -(PRInt32)(a).hi - ((r).lo != 0)) +#define LL_ADD(r, a, b) { \ + PRInt64 _a, _b; \ + _a = a; _b = b; \ + (r).lo = _a.lo + _b.lo; \ + (r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \ +} + +#define LL_SUB(r, a, b) { \ + PRInt64 _a, _b; \ + _a = a; _b = b; \ + (r).lo = _a.lo - _b.lo; \ + (r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \ +} + +#define LL_MUL(r, a, b) { \ + PRInt64 _a, _b; \ + _a = a; _b = b; \ + LL_MUL32(r, _a.lo, _b.lo); \ + (r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \ +} + +#define _lo16(a) ((a) & PR_BITMASK(16)) +#define _hi16(a) ((a) >> 16) + +#define LL_MUL32(r, a, b) { \ + PRUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \ + _a1 = _hi16(a), _a0 = _lo16(a); \ + _b1 = _hi16(b), _b0 = _lo16(b); \ + _y0 = _a0 * _b0; \ + _y1 = _a0 * _b1; \ + _y2 = _a1 * _b0; \ + _y3 = _a1 * _b1; \ + _y1 += _hi16(_y0); /* can't carry */ \ + _y1 += _y2; /* might carry */ \ + if (_y1 < _y2) \ + _y3 += (PRUint32)(PR_BIT(16)); /* propagate */ \ + (r).lo = (_lo16(_y1) << 16) + _lo16(_y0); \ + (r).hi = _y3 + _hi16(_y1); \ +} + +#define LL_UDIVMOD(qp, rp, a, b) ll_udivmod(qp, rp, a, b) + +NSPR_API(void) ll_udivmod(PRUint64 *qp, PRUint64 *rp, PRUint64 a, PRUint64 b); + +#define LL_DIV(r, a, b) { \ + PRInt64 _a, _b; \ + PRUint32 _negative = (PRInt32)(a).hi < 0; \ + if (_negative) { \ + LL_NEG(_a, a); \ + } else { \ + _a = a; \ + } \ + if ((PRInt32)(b).hi < 0) { \ + _negative ^= 1; \ + LL_NEG(_b, b); \ + } else { \ + _b = b; \ + } \ + LL_UDIVMOD(&(r), 0, _a, _b); \ + if (_negative) \ + LL_NEG(r, r); \ +} + +#define LL_MOD(r, a, b) { \ + PRInt64 _a, _b; \ + PRUint32 _negative = (PRInt32)(a).hi < 0; \ + if (_negative) { \ + LL_NEG(_a, a); \ + } else { \ + _a = a; \ + } \ + if ((PRInt32)(b).hi < 0) { \ + LL_NEG(_b, b); \ + } else { \ + _b = b; \ + } \ + LL_UDIVMOD(0, &(r), _a, _b); \ + if (_negative) \ + LL_NEG(r, r); \ +} + +#define LL_SHL(r, a, b) { \ + if (b) { \ + PRInt64 _a; \ + _a = a; \ + if ((b) < 32) { \ + (r).lo = _a.lo << ((b) & 31); \ + (r).hi = (_a.hi << ((b) & 31)) | (_a.lo >> (32 - (b))); \ + } else { \ + (r).lo = 0; \ + (r).hi = _a.lo << ((b) & 31); \ + } \ + } else { \ + (r) = (a); \ + } \ +} + +/* a is an PRInt32, b is PRInt32, r is PRInt64 */ +#define LL_ISHL(r, a, b) { \ + if (b) { \ + PRInt64 _a; \ + _a.lo = (a); \ + _a.hi = 0; \ + if ((b) < 32) { \ + (r).lo = (a) << ((b) & 31); \ + (r).hi = ((a) >> (32 - (b))); \ + } else { \ + (r).lo = 0; \ + (r).hi = (a) << ((b) & 31); \ + } \ + } else { \ + (r).lo = (a); \ + (r).hi = 0; \ + } \ +} + +#define LL_SHR(r, a, b) { \ + if (b) { \ + PRInt64 _a; \ + _a = a; \ + if ((b) < 32) { \ + (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \ + (r).hi = (PRInt32)_a.hi >> ((b) & 31); \ + } else { \ + (r).lo = (PRInt32)_a.hi >> ((b) & 31); \ + (r).hi = (PRInt32)_a.hi >> 31; \ + } \ + } else { \ + (r) = (a); \ + } \ +} + +#define LL_USHR(r, a, b) { \ + if (b) { \ + PRInt64 _a; \ + _a = a; \ + if ((b) < 32) { \ + (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \ + (r).hi = _a.hi >> ((b) & 31); \ + } else { \ + (r).lo = _a.hi >> ((b) & 31); \ + (r).hi = 0; \ + } \ + } else { \ + (r) = (a); \ + } \ +} + +#define LL_L2I(i, l) ((i) = (l).lo) +#define LL_L2UI(ui, l) ((ui) = (l).lo) +#define LL_L2F(f, l) { double _d; LL_L2D(_d, l); (f) = (PRFloat64)_d; } + +#define LL_L2D(d, l) { \ + int _negative; \ + PRInt64 _absval; \ + \ + _negative = (l).hi >> 31; \ + if (_negative) { \ + LL_NEG(_absval, l); \ + } else { \ + _absval = l; \ + } \ + (d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \ + if (_negative) \ + (d) = -(d); \ +} + +#define LL_I2L(l, i) { PRInt32 _i = ((PRInt32)(i)) >> 31; (l).lo = (i); (l).hi = _i; } +#define LL_UI2L(l, ui) ((l).lo = (ui), (l).hi = 0) +#define LL_F2L(l, f) { double _d = (double)f; LL_D2L(l, _d); } + +#define LL_D2L(l, d) { \ + int _negative; \ + double _absval, _d_hi; \ + PRInt64 _lo_d; \ + \ + _negative = ((d) < 0); \ + _absval = _negative ? -(d) : (d); \ + \ + (l).hi = _absval / 4.294967296e9; \ + (l).lo = 0; \ + LL_L2D(_d_hi, l); \ + _absval -= _d_hi; \ + _lo_d.hi = 0; \ + if (_absval < 0) { \ + _lo_d.lo = -_absval; \ + LL_SUB(l, l, _lo_d); \ + } else { \ + _lo_d.lo = _absval; \ + LL_ADD(l, l, _lo_d); \ + } \ + \ + if (_negative) \ + LL_NEG(l, l); \ +} + +#endif /* !HAVE_LONG_LONG */ + +PR_END_EXTERN_C + +#endif /* prlong_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prmem.h b/illumos-x86_64/usr/include/mps/prmem.h new file mode 100644 index 00000000..ed9a4289 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prmem.h @@ -0,0 +1,126 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: prmem.h +** Description: API to NSPR memory management functions +** +*/ +#ifndef prmem_h___ +#define prmem_h___ + +#include "prtypes.h" +#include + +PR_BEGIN_EXTERN_C + +/* +** Thread safe memory allocation. +** +** NOTE: pr wraps up malloc, free, calloc, realloc so they are already +** thread safe (and are not declared here - look in stdlib.h). +*/ + +/* +** PR_Malloc, PR_Calloc, PR_Realloc, and PR_Free have the same signatures +** as their libc equivalent malloc, calloc, realloc, and free, and have +** the same semantics. (Note that the argument type size_t is replaced +** by PRUint32.) Memory allocated by PR_Malloc, PR_Calloc, or PR_Realloc +** must be freed by PR_Free. +*/ + +NSPR_API(void *) PR_Malloc(PRUint32 size); + +NSPR_API(void *) PR_Calloc(PRUint32 nelem, PRUint32 elsize); + +NSPR_API(void *) PR_Realloc(void *ptr, PRUint32 size); + +NSPR_API(void) PR_Free(void *ptr); + +/* +** The following are some convenience macros defined in terms of +** PR_Malloc, PR_Calloc, PR_Realloc, and PR_Free. +*/ + +/*********************************************************************** +** FUNCTION: PR_MALLOC() +** DESCRIPTION: +** PR_NEW() allocates an untyped item of size _size from the heap. +** INPUTS: _size: size in bytes of item to be allocated +** OUTPUTS: untyped pointer to the node allocated +** RETURN: pointer to node or error returned from malloc(). +***********************************************************************/ +#define PR_MALLOC(_bytes) (PR_Malloc((_bytes))) + +/*********************************************************************** +** FUNCTION: PR_NEW() +** DESCRIPTION: +** PR_NEW() allocates an item of type _struct from the heap. +** INPUTS: _struct: a data type +** OUTPUTS: pointer to _struct +** RETURN: pointer to _struct or error returns from malloc(). +***********************************************************************/ +#define PR_NEW(_struct) ((_struct *) PR_MALLOC(sizeof(_struct))) + +/*********************************************************************** +** FUNCTION: PR_REALLOC() +** DESCRIPTION: +** PR_REALLOC() re-allocates _ptr bytes from the heap as a _size +** untyped item. +** INPUTS: _ptr: pointer to node to reallocate +** _size: size of node to allocate +** OUTPUTS: pointer to node allocated +** RETURN: pointer to node allocated +***********************************************************************/ +#define PR_REALLOC(_ptr, _size) (PR_Realloc((_ptr), (_size))) + +/*********************************************************************** +** FUNCTION: PR_CALLOC() +** DESCRIPTION: +** PR_CALLOC() allocates a _size bytes untyped item from the heap +** and sets the allocated memory to all 0x00. +** INPUTS: _size: size of node to allocate +** OUTPUTS: pointer to node allocated +** RETURN: pointer to node allocated +***********************************************************************/ +#define PR_CALLOC(_size) (PR_Calloc(1, (_size))) + +/*********************************************************************** +** FUNCTION: PR_NEWZAP() +** DESCRIPTION: +** PR_NEWZAP() allocates an item of type _struct from the heap +** and sets the allocated memory to all 0x00. +** INPUTS: _struct: a data type +** OUTPUTS: pointer to _struct +** RETURN: pointer to _struct +***********************************************************************/ +#define PR_NEWZAP(_struct) ((_struct*)PR_Calloc(1, sizeof(_struct))) + +/*********************************************************************** +** FUNCTION: PR_DELETE() +** DESCRIPTION: +** PR_DELETE() unallocates an object previosly allocated via PR_NEW() +** or PR_NEWZAP() to the heap. +** INPUTS: pointer to previously allocated object +** OUTPUTS: the referenced object is returned to the heap +** RETURN: void +***********************************************************************/ +#define PR_DELETE(_ptr) { PR_Free(_ptr); (_ptr) = NULL; } + +/*********************************************************************** +** FUNCTION: PR_FREEIF() +** DESCRIPTION: +** PR_FREEIF() conditionally unallocates an object previously allocated +** vial PR_NEW() or PR_NEWZAP(). If the pointer to the object is +** equal to zero (0), the object is not released. +** INPUTS: pointer to previously allocated object +** OUTPUTS: the referenced object is conditionally returned to the heap +** RETURN: void +***********************************************************************/ +#define PR_FREEIF(_ptr) if (_ptr) PR_DELETE(_ptr) + +PR_END_EXTERN_C + +#endif /* prmem_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prmon.h b/illumos-x86_64/usr/include/mps/prmon.h new file mode 100644 index 00000000..374e2982 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prmon.h @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prmon_h___ +#define prmon_h___ + +#include "prtypes.h" +#include "prinrval.h" + +PR_BEGIN_EXTERN_C + +typedef struct PRMonitor PRMonitor; + +/* +** Create a new monitor. Monitors are re-entrant locks with a single built-in +** condition variable. +** +** This may fail if memory is tight or if some operating system resource +** is low. +*/ +NSPR_API(PRMonitor*) PR_NewMonitor(void); + +/* +** Destroy a monitor. The caller is responsible for guaranteeing that the +** monitor is no longer in use. There must be no thread waiting on the monitor's +** condition variable and that the lock is not held. +** +*/ +NSPR_API(void) PR_DestroyMonitor(PRMonitor *mon); + +/* +** Enter the lock associated with the monitor. If the calling thread currently +** is in the monitor, the call to enter will silently succeed. In either case, +** it will increment the entry count by one. +*/ +NSPR_API(void) PR_EnterMonitor(PRMonitor *mon); + +/* +** Decrement the entry count associated with the monitor. If the decremented +** entry count is zero, the monitor is exited. Returns PR_FAILURE if the +** calling thread has not entered the monitor. +*/ +NSPR_API(PRStatus) PR_ExitMonitor(PRMonitor *mon); + +/* +** Wait for a notify on the monitor's condition variable. Sleep for "ticks" +** amount of time (if "ticks" is PR_INTERVAL_NO_TIMEOUT then the sleep is +** indefinite). +** +** While the thread is waiting it exits the monitor (as if it called +** PR_ExitMonitor as many times as it had called PR_EnterMonitor). When +** the wait has finished the thread regains control of the monitors lock +** with the same entry count as before the wait began. +** +** The thread waiting on the monitor will be resumed when the monitor is +** notified (assuming the thread is the next in line to receive the +** notify) or when the "ticks" timeout elapses. +** +** Returns PR_FAILURE if the caller has not entered the monitor. +*/ +NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks); + +/* +** Notify a thread waiting on the monitor's condition variable. If a thread +** is waiting on the condition variable (using PR_Wait) then it is awakened +** and attempts to reenter the monitor. +*/ +NSPR_API(PRStatus) PR_Notify(PRMonitor *mon); + +/* +** Notify all of the threads waiting on the monitor's condition variable. +** All of threads waiting on the condition are scheduled to reenter the +** monitor. +*/ +NSPR_API(PRStatus) PR_NotifyAll(PRMonitor *mon); + +/* +** PR_ASSERT_CURRENT_THREAD_IN_MONITOR +** If the current thread is in |mon|, this assertion is guaranteed to +** succeed. Otherwise, the behavior of this function is undefined. +*/ +#if defined(DEBUG) || defined(FORCE_PR_ASSERT) +#define PR_ASSERT_CURRENT_THREAD_IN_MONITOR(/* PRMonitor* */ mon) \ + PR_AssertCurrentThreadInMonitor(mon) +#else +#define PR_ASSERT_CURRENT_THREAD_IN_MONITOR(/* PRMonitor* */ mon) +#endif + +/* Don't call this function directly. */ +NSPR_API(void) PR_AssertCurrentThreadInMonitor(PRMonitor *mon); + +PR_END_EXTERN_C + +#endif /* prmon_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prmwait.h b/illumos-x86_64/usr/include/mps/prmwait.h new file mode 100644 index 00000000..16c07621 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prmwait.h @@ -0,0 +1,380 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#if defined(_PRMWAIT_H) +#else +#define _PRMWAIT_H + +#include "prio.h" +#include "prtypes.h" +#include "prclist.h" + +PR_BEGIN_EXTERN_C + +/********************************************************************************/ +/********************************************************************************/ +/********************************************************************************/ +/****************************** WARNING ****************************/ +/********************************************************************************/ +/**************************** This is work in progress. *************************/ +/************************** Do not make any assumptions *************************/ +/************************** about the stability of this *************************/ +/************************** API or the underlying imple- ************************/ +/************************** mentation. ************************/ +/********************************************************************************/ +/********************************************************************************/ + +/* +** STRUCTURE: PRWaitGroup +** DESCRIPTION: +** The client may define several wait groups in order to semantically +** tie a collection of file descriptors for a single purpose. This allows +** easier dispatching of threads that returned with active file descriptors +** from the wait function. +*/ +typedef struct PRWaitGroup PRWaitGroup; + +/* +** ENUMERATION: PRMWStatus +** DESCRIPTION: +** This enumeration is used to indicate the completion status of +** a receive wait object. Generally stated, a positive value indicates +** that the operation is not yet complete. A zero value indicates +** success (similar to PR_SUCCESS) and any negative value is an +** indication of failure. The reason for the failure can be retrieved +** by calling PR_GetError(). +** +** PR_MW_PENDING The operation is still pending. None of the other +** fields of the object are currently valid. +** PR_MW_SUCCESS The operation is complete and it was successful. +** PR_MW_FAILURE The operation failed. The reason for the failure +** can be retrieved by calling PR_GetError(). +** PR_MW_TIMEOUT The amount of time allowed for by the object's +** 'timeout' field has expired w/o the operation +** otherwise coming to closure. +** PR_MW_INTERRUPT The operation was cancelled, either by the client +** calling PR_CancelWaitFileDesc() or destroying the +** entire wait group (PR_DestroyWaitGroup()). +*/ +typedef enum PRMWStatus +{ + PR_MW_PENDING = 1, + PR_MW_SUCCESS = 0, + PR_MW_FAILURE = -1, + PR_MW_TIMEOUT = -2, + PR_MW_INTERRUPT = -3 +} PRMWStatus; + +/* +** STRUCTURE: PRMemoryDescriptor +** DESCRIPTION: +** THis is a descriptor for an interval of memory. It contains a +** pointer to the first byte of that memory and the length (in +** bytes) of the interval. +*/ +typedef struct PRMemoryDescriptor +{ + void *start; /* pointer to first byte of memory */ + PRSize length; /* length (in bytes) of memory interval */ +} PRMemoryDescriptor; + +/* +** STRUCTURE: PRMWaitClientData +** DESCRIPTION: +** An opague stucture for which a client MAY give provide a concrete +** definition and associate with a receive descriptor. The NSPR runtime +** does not manage this field. It is completely up to the client. +*/ +typedef struct PRMWaitClientData PRMWaitClientData; + +/* +** STRUCTURE: PRRecvWait +** DESCRIPTION: +** A receive wait object contains the file descriptor that is subject +** to the wait and the amount of time (beginning epoch established +** when the object is presented to the runtime) the the channel should +** block before abandoning the process. +** +** The success of the wait operation will be noted in the object's +** 'outcome' field. The fields are not valid when the NSPR runtime +** is in possession of the object. +** +** The memory descriptor describes an interval of writable memory +** in the caller's address space where data from an initial read +** can be placed. The description may indicate a null interval. +*/ +typedef struct PRRecvWait +{ + PRCList internal; /* internal runtime linkages */ + + PRFileDesc *fd; /* file descriptor associated w/ object */ + PRMWStatus outcome; /* outcome of the current/last operation */ + PRIntervalTime timeout; /* time allowed for entire operation */ + + PRInt32 bytesRecv; /* number of bytes transferred into buffer */ + PRMemoryDescriptor buffer; /* where to store first segment of input data */ + PRMWaitClientData *client; /* pointer to arbitrary client defined data */ +} PRRecvWait; + +/* +** STRUCTURE: PRMWaitEnumerator +** DESCRIPTION: +** An enumeration object is used to store the state of an existing +** enumeration over a wait group. The opaque object must be allocated +** by the client and the reference presented on each call to the +** pseudo-stateless enumerator. The enumeration objects are sharable +** only in serial fashion. +*/ +typedef struct PRMWaitEnumerator PRMWaitEnumerator; + + +/* +** FUNCTION: PR_AddWaitFileDesc +** DESCRIPTION: +** This function will effectively add a file descriptor to the +** list of those waiting for network receive. The new descriptor +** will be semantically tied to the wait group specified. +** +** The ownership for the storage pointed to by 'desc' is temporarily +** passed over the the NSPR runtime. It will be handed back by the +** function PR_WaitRecvReady(). +** +** INPUTS +** group A reference to a PRWaitGroup or NULL. Wait groups are +** created by calling PR_CreateWaitGroup() and are used +** to semantically group various file descriptors by the +** client's application. +** desc A reference to a valid PRRecvWait. The object of the +** reference must be preserved and not be modified +** until its ownership is returned to the client. +** RETURN +** PRStatus An indication of success. If equal to PR_FAILUE details +** of the failure are avaiable via PR_GetError(). +** +** ERRORS +** PR_INVALID_ARGUMENT_ERROR +** Invalid 'group' identifier or duplicate 'desc' object. +** PR_OUT_OF_MEMORY_ERROR +** Insuffient memory for internal data structures. +** PR_INVALID_STATE_ERROR +** The group is being destroyed. +*/ +NSPR_API(PRStatus) PR_AddWaitFileDesc(PRWaitGroup *group, PRRecvWait *desc); + +/* +** FUNCTION: PR_WaitRecvReady +** DESCRIPTION: +** PR_WaitRecvReady will block the calling thread until one of the +** file descriptors that have been added via PR_AddWaitFileDesc is +** available for input I/O. +** INPUT +** group A pointer to a valid PRWaitGroup or NULL (the null +** group. The function will block the caller until a +** channel from the wait group becomes ready for receive +** or there is some sort of error. +** RETURN +** PRReciveWait +** When the caller is resumed it is either returned a +** valid pointer to a previously added receive wait or +** a NULL. If the latter, the function has terminated +** for a reason that can be determined by calling +** PR_GetError(). +** If a valid pointer is returned, the reference is to the +** file descriptor contained in the receive wait object. +** The outcome of the wait operation may still fail, and +** if it has, that fact will be noted in the object's +** outcome field. Details can be retrieved from PR_GetError(). +** +** ERRORS +** PR_INVALID_ARGUMENT_ERROR +** The 'group' is not known by the runtime. +** PR_PENDING_INTERRUPT_ERROR + The thread was interrupted. +** PR_INVALID_STATE_ERROR +** The group is being destroyed. +*/ +NSPR_API(PRRecvWait*) PR_WaitRecvReady(PRWaitGroup *group); + +/* +** FUNCTION: PR_CancelWaitFileDesc +** DESCRIPTION: +** PR_CancelWaitFileDesc is provided as a means for cancelling operations +** on objects previously submitted by use of PR_AddWaitFileDesc(). If +** the runtime knows of the object, it will be marked as having failed +** because it was interrupted (similar to PR_Interrupt()). The first +** available thread waiting on the group will be made to return the +** PRRecvWait object with the outcome noted. +** +** INPUTS +** group The wait group under which the wait receive object was +** added. +** desc A pointer to the wait receive object that is to be +** cancelled. +** RETURN +** PRStatus If the wait receive object was located and associated +** with the specified wait group, the status returned will +** be PR_SUCCESS. There is still a race condition that would +** permit the offected object to complete normally, but it +** is assured that it will complete in the near future. +** If the receive object or wait group are invalid, the +** function will return with a status of PR_FAILURE. +** +** ERRORS +** PR_INVALID_ARGUMENT_ERROR +** The 'group' argument is not recognized as a valid group. +** PR_COLLECTION_EMPTY_ERROR +** There are no more receive wait objects in the group's +** collection. +** PR_INVALID_STATE_ERROR +** The group is being destroyed. +*/ +NSPR_API(PRStatus) PR_CancelWaitFileDesc(PRWaitGroup *group, PRRecvWait *desc); + +/* +** FUNCTION: PR_CancelWaitGroup +** DESCRIPTION: +** PR_CancelWaitGroup is provided as a means for cancelling operations +** on objects previously submitted by use of PR_AddWaitFileDesc(). Each +** successive call will return a pointer to a PRRecvWait object that +** was previously registered via PR_AddWaitFileDesc(). If no wait +** objects are associated with the wait group, a NULL will be returned. +** This function should be called in a loop until a NULL is returned +** to reclaim all the wait objects prior to calling PR_DestroyWaitGroup(). +** +** INPUTS +** group The wait group under which the wait receive object was +** added. +** RETURN +** PRRecvWait* If the wait group is valid and at least one receive wait +** object is present in the group, that object will be +** marked as PR_MW_INTERRUPT'd and removed from the group's +** queues. Otherwise a NULL will be returned and the reason +** for the NULL may be retrieved by calling PR_GetError(). +** +** ERRORS +** PR_INVALID_ARGUMENT_ERROR +** PR_GROUP_EMPTY_ERROR +*/ +NSPR_API(PRRecvWait*) PR_CancelWaitGroup(PRWaitGroup *group); + +/* +** FUNCTION: PR_CreateWaitGroup +** DESCRIPTION: +** A wait group is an opaque object that a client may create in order +** to semantically group various wait requests. Each wait group is +** unique, including the default wait group (NULL). A wait request +** that was added under a wait group will only be serviced by a caller +** that specified the same wait group. +** +** INPUT +** size The size of the hash table to be used to contain the +** receive wait objects. This is just the initial size. +** It will grow as it needs to, but to avoid that hassle +** one can suggest a suitable size initially. It should +** be ~30% larger than the maximum number of receive wait +** objects expected. +** RETURN +** PRWaitGroup If successful, the function will return a pointer to an +** object that was allocated by and owned by the runtime. +** The reference remains valid until it is explicitly destroyed +** by calling PR_DestroyWaitGroup(). +** +** ERRORS +** PR_OUT_OF_MEMORY_ERROR +*/ +NSPR_API(PRWaitGroup*) PR_CreateWaitGroup(PRInt32 size); + +/* +** FUNCTION: PR_DestroyWaitGroup +** DESCRIPTION: +** Undo the effects of PR_CreateWaitGroup(). Any receive wait operations +** on the group will be treated as if the each had been the target of a +** PR_CancelWaitFileDesc(). +** +** INPUT +** group Reference to a wait group previously allocated using +** PR_CreateWaitGroup(). +** RETURN +** PRStatus Will be PR_SUCCESS if the wait group was valid and there +** are no receive wait objects in that group. Otherwise +** will indicate PR_FAILURE. +** +** ERRORS +** PR_INVALID_ARGUMENT_ERROR +** The 'group' argument does not reference a known object. +** PR_INVALID_STATE_ERROR +** The group still contains receive wait objects. +*/ +NSPR_API(PRStatus) PR_DestroyWaitGroup(PRWaitGroup *group); + +/* +** FUNCTION: PR_CreateMWaitEnumerator +** DESCRIPTION: +** The PR_CreateMWaitEnumerator() function returns a reference to an +** opaque PRMWaitEnumerator object. The enumerator object is required +** as an argument for each successive call in the stateless enumeration +** of the indicated wait group. +** +** group The wait group that the enumeration is intended to +** process. It may be be the default wait group (NULL). +** RETURN +** PRMWaitEnumerator* group +** A reference to an object that will be used to store +** intermediate state of enumerations. +** ERRORS +** Errors are indicated by the function returning a NULL. +** PR_INVALID_ARGUMENT_ERROR +** The 'group' argument does not reference a known object. +** PR_OUT_OF_MEMORY_ERROR +*/ +NSPR_API(PRMWaitEnumerator*) PR_CreateMWaitEnumerator(PRWaitGroup *group); + +/* +** FUNCTION: PR_DestroyMWaitEnumerator +** DESCRIPTION: +** Destroys the object created by PR_CreateMWaitEnumerator(). The reference +** used as an argument becomes invalid. +** +** INPUT +** PRMWaitEnumerator* enumerator +** The PRMWaitEnumerator object to destroy. +** RETURN +** PRStatus +** PR_SUCCESS if successful, PR_FAILURE otherwise. +** ERRORS +** PR_INVALID_ARGUMENT_ERROR +** The enumerator is invalid. +*/ +NSPR_API(PRStatus) PR_DestroyMWaitEnumerator(PRMWaitEnumerator* enumerator); + +/* +** FUNCTION: PR_EnumerateWaitGroup +** DESCRIPTION: +** PR_EnumerateWaitGroup is a thread safe enumerator over a wait group. +** Each call to the enumerator must present a valid PRMWaitEnumerator +** rererence and a pointer to the "previous" element returned from the +** enumeration process or a NULL. +** +** An enumeration is started by passing a NULL as the "previous" value. +** Subsequent calls to the enumerator must pass in the result of the +** previous call. The enumeration end is signaled by the runtime returning +** a NULL as the result. +** +** Modifications to the content of the wait group are allowed during +** an enumeration. The effect is that the enumeration may have to be +** "reset" and that may result in duplicates being returned from the +** enumeration. +** +** An enumeration may be abandoned at any time. The runtime is not +** keeping any state, so there are no issues in that regard. +*/ +NSPR_API(PRRecvWait*) PR_EnumerateWaitGroup( + PRMWaitEnumerator *enumerator, const PRRecvWait *previous); + +PR_END_EXTERN_C + +#endif /* defined(_PRMWAIT_H) */ + +/* prmwait.h */ diff --git a/illumos-x86_64/usr/include/mps/prnetdb.h b/illumos-x86_64/usr/include/mps/prnetdb.h new file mode 100644 index 00000000..023a46e5 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prnetdb.h @@ -0,0 +1,475 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prnetdb_h___ +#define prnetdb_h___ + +#include "prtypes.h" +#include "prio.h" + +PR_BEGIN_EXTERN_C + + +/* + ********************************************************************* + * Translate an Internet address to/from a character string + ********************************************************************* + */ +NSPR_API(PRStatus) PR_StringToNetAddr( + const char *string, PRNetAddr *addr); + +NSPR_API(PRStatus) PR_NetAddrToString( + const PRNetAddr *addr, char *string, PRUint32 size); + +/* +** Structures returned by network data base library. All addresses are +** supplied in host order, and returned in network order (suitable for +** use in system calls). +*/ +/* +** Beware that WINSOCK.H defines h_addrtype and h_length as short. +** Client code does direct struct copies of hostent to PRHostEnt and +** hence the ifdef. +*/ +typedef struct PRHostEnt { + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ +#ifdef WIN32 + PRInt16 h_addrtype; /* host address type */ + PRInt16 h_length; /* length of address */ +#else + PRInt32 h_addrtype; /* host address type */ + PRInt32 h_length; /* length of address */ +#endif + char **h_addr_list; /* list of addresses from name server */ +} PRHostEnt; + +/* A safe size to use that will mostly work... */ +#if (defined(AIX) && defined(_THREAD_SAFE)) +#define PR_NETDB_BUF_SIZE sizeof(struct protoent_data) +#define PR_MIN_NETDB_BUF_SIZE PR_NETDB_BUF_SIZE +#else +/* PR_NETDB_BUF_SIZE is the recommended buffer size */ +#define PR_NETDB_BUF_SIZE 2048 +/* PR_MIN_NETDB_BUF_SIZE is the smallest buffer size that the API + * accepts (for backward compatibility). */ +#define PR_MIN_NETDB_BUF_SIZE 1024 +#endif + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_GetHostByName() +** Lookup a host by name. +** +** INPUTS: +** char *hostname Character string defining the host name of interest +** char *buf A scratch buffer for the runtime to return result. +** This buffer is allocated by the caller. +** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to +** use is PR_NETDB_BUF_SIZE. +** OUTPUTS: +** PRHostEnt *hostentry +** This structure is filled in by the runtime if +** the function returns PR_SUCCESS. This structure +** is allocated by the caller. +** RETURN: +** PRStatus PR_SUCCESS if the lookup succeeds. If it fails +** the result will be PR_FAILURE and the reason +** for the failure can be retrieved by PR_GetError(). +***********************************************************************/ +NSPR_API(PRStatus) PR_GetHostByName( + const char *hostname, char *buf, PRIntn bufsize, PRHostEnt *hostentry); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_GetIPNodeByName() +** Lookup a host by name. Equivalent to getipnodebyname(AI_DEFAULT) +** of RFC 2553. +** +** INPUTS: +** char *hostname Character string defining the host name of interest +** PRUint16 af Address family (either PR_AF_INET or PR_AF_INET6) +** PRIntn flags Specifies the types of addresses that are searched +** for and the types of addresses that are returned. +** The only supported flag is PR_AI_DEFAULT. +** char *buf A scratch buffer for the runtime to return result. +** This buffer is allocated by the caller. +** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to +** use is PR_NETDB_BUF_SIZE. +** OUTPUTS: +** PRHostEnt *hostentry +** This structure is filled in by the runtime if +** the function returns PR_SUCCESS. This structure +** is allocated by the caller. +** RETURN: +** PRStatus PR_SUCCESS if the lookup succeeds. If it fails +** the result will be PR_FAILURE and the reason +** for the failure can be retrieved by PR_GetError(). +***********************************************************************/ + + +#define PR_AI_ALL 0x08 +#define PR_AI_V4MAPPED 0x10 +#define PR_AI_ADDRCONFIG 0x20 +#define PR_AI_NOCANONNAME 0x8000 +#define PR_AI_DEFAULT (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG) + +NSPR_API(PRStatus) PR_GetIPNodeByName( + const char *hostname, + PRUint16 af, + PRIntn flags, + char *buf, + PRIntn bufsize, + PRHostEnt *hostentry); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_GetHostByAddr() +** Lookup a host entry by its network address. +** +** INPUTS: +** char *hostaddr IP address of host in question +** char *buf A scratch buffer for the runtime to return result. +** This buffer is allocated by the caller. +** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to +** use is PR_NETDB_BUF_SIZE. +** OUTPUTS: +** PRHostEnt *hostentry +** This structure is filled in by the runtime if +** the function returns PR_SUCCESS. This structure +** is allocated by the caller. +** RETURN: +** PRStatus PR_SUCCESS if the lookup succeeds. If it fails +** the result will be PR_FAILURE and the reason +** for the failure can be retrieved by PR_GetError(). +***********************************************************************/ +NSPR_API(PRStatus) PR_GetHostByAddr( + const PRNetAddr *hostaddr, char *buf, PRIntn bufsize, PRHostEnt *hostentry); + +/*********************************************************************** +** FUNCTION: PR_EnumerateHostEnt() +** DESCRIPTION: +** A stateless enumerator over a PRHostEnt structure acquired from +** PR_GetHostByName() PR_GetHostByAddr() to evaluate the possible +** network addresses. +** +** INPUTS: +** PRIntn enumIndex Index of the enumeration. The enumeration starts +** and ends with a value of zero. +** +** PRHostEnt *hostEnt A pointer to a host entry struct that was +** previously returned by PR_GetHostByName() or +** PR_GetHostByAddr(). +** +** PRUint16 port The port number to be assigned as part of the +** PRNetAddr. +** +** OUTPUTS: +** PRNetAddr *address A pointer to an address structure that will be +** filled in by the call to the enumeration if the +** result of the call is greater than zero. +** +** RETURN: +** PRIntn The value that should be used for the next call +** of the enumerator ('enumIndex'). The enumeration +** is ended if this value is returned zero. +** If a value of -1 is returned, the enumeration +** has failed. The reason for the failure can be +** retrieved by calling PR_GetError(). +***********************************************************************/ +NSPR_API(PRIntn) PR_EnumerateHostEnt( + PRIntn enumIndex, const PRHostEnt *hostEnt, PRUint16 port, PRNetAddr *address); + +/*********************************************************************** +** FUNCTION: PR_InitializeNetAddr(), +** DESCRIPTION: +** Initialize the fields of a PRNetAddr, assigning well known values as +** appropriate. +** +** INPUTS +** PRNetAddrValue val The value to be assigned to the IP Address portion +** of the network address. This can only specify the +** special well known values that are equivalent to +** INADDR_ANY and INADDR_LOOPBACK. +** +** PRUint16 port The port number to be assigned in the structure. +** +** OUTPUTS: +** PRNetAddr *addr The address to be manipulated. +** +** RETURN: +** PRStatus To indicate success or failure. If the latter, the +** reason for the failure can be retrieved by calling +** PR_GetError(); +***********************************************************************/ +typedef enum PRNetAddrValue +{ + PR_IpAddrNull, /* do NOT overwrite the IP address */ + PR_IpAddrAny, /* assign logical INADDR_ANY to IP address */ + PR_IpAddrLoopback, /* assign logical INADDR_LOOPBACK */ + PR_IpAddrV4Mapped /* IPv4 mapped address */ +} PRNetAddrValue; + +NSPR_API(PRStatus) PR_InitializeNetAddr( + PRNetAddrValue val, PRUint16 port, PRNetAddr *addr); + +/*********************************************************************** +** FUNCTION: PR_SetNetAddr(), +** DESCRIPTION: +** Set the fields of a PRNetAddr, assigning well known values as +** appropriate. This function is similar to PR_InitializeNetAddr +** but differs in that the address family is specified. +** +** INPUTS +** PRNetAddrValue val The value to be assigned to the IP Address portion +** of the network address. This can only specify the +** special well known values that are equivalent to +** INADDR_ANY and INADDR_LOOPBACK. +** +** PRUint16 af The address family (either PR_AF_INET or PR_AF_INET6) +** +** PRUint16 port The port number to be assigned in the structure. +** +** OUTPUTS: +** PRNetAddr *addr The address to be manipulated. +** +** RETURN: +** PRStatus To indicate success or failure. If the latter, the +** reason for the failure can be retrieved by calling +** PR_GetError(); +***********************************************************************/ +NSPR_API(PRStatus) PR_SetNetAddr( + PRNetAddrValue val, PRUint16 af, PRUint16 port, PRNetAddr *addr); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_IsNetAddrType() +** Determine if the network address is of the specified type. +** +** INPUTS: +** const PRNetAddr *addr A network address. +** PRNetAddrValue The type of network address +** +** RETURN: +** PRBool PR_TRUE if the network address is of the +** specified type, else PR_FALSE. +***********************************************************************/ +NSPR_API(PRBool) PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_ConvertIPv4AddrToIPv6() +** Convert an IPv4 addr to an (IPv4-mapped) IPv6 addr +** +** INPUTS: +** PRUint32 v4addr IPv4 address +** +** OUTPUTS: +** PRIPv6Addr *v6addr The converted IPv6 address +** +** RETURN: +** void +** +***********************************************************************/ +NSPR_API(void) PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr *v6addr); + +/*********************************************************************** +** MACRO: +** DESCRIPTION: PR_NetAddrFamily() +** Get the 'family' field of a PRNetAddr union. +** +** INPUTS: +** const PRNetAddr *addr A network address. +** +** RETURN: +** PRUint16 The 'family' field of 'addr'. +***********************************************************************/ +#define PR_NetAddrFamily(addr) ((addr)->raw.family) + +/*********************************************************************** +** MACRO: +** DESCRIPTION: PR_NetAddrInetPort() +** Get the 'port' field of a PRNetAddr union. +** +** INPUTS: +** const PRNetAddr *addr A network address. +** +** RETURN: +** PRUint16 The 'port' field of 'addr'. +***********************************************************************/ +#define PR_NetAddrInetPort(addr) \ + ((addr)->raw.family == PR_AF_INET6 ? (addr)->ipv6.port : (addr)->inet.port) + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_GetProtoByName() +** Lookup a protocol entry based on protocol's name +** +** INPUTS: +** char *protocolname Character string of the protocol's name. +** char *buf A scratch buffer for the runtime to return result. +** This buffer is allocated by the caller. +** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to +** use is PR_NETDB_BUF_SIZE. +** OUTPUTS: +** PRHostEnt *PRProtoEnt +** This structure is filled in by the runtime if +** the function returns PR_SUCCESS. This structure +** is allocated by the caller. +** RETURN: +** PRStatus PR_SUCCESS if the lookup succeeds. If it fails +** the result will be PR_FAILURE and the reason +** for the failure can be retrieved by PR_GetError(). +***********************************************************************/ + +typedef struct PRProtoEnt { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ +#ifdef WIN32 + PRInt16 p_num; /* protocol # */ +#else + PRInt32 p_num; /* protocol # */ +#endif +} PRProtoEnt; + +NSPR_API(PRStatus) PR_GetProtoByName( + const char* protocolname, char* buffer, PRInt32 bufsize, PRProtoEnt* result); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_GetProtoByNumber() +** Lookup a protocol entry based on protocol's number +** +** INPUTS: +** PRInt32 protocolnumber +** Number assigned to the protocol. +** char *buf A scratch buffer for the runtime to return result. +** This buffer is allocated by the caller. +** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to +** use is PR_NETDB_BUF_SIZE. +** OUTPUTS: +** PRHostEnt *PRProtoEnt +** This structure is filled in by the runtime if +** the function returns PR_SUCCESS. This structure +** is allocated by the caller. +** RETURN: +** PRStatus PR_SUCCESS if the lookup succeeds. If it fails +** the result will be PR_FAILURE and the reason +** for the failure can be retrieved by PR_GetError(). +***********************************************************************/ +NSPR_API(PRStatus) PR_GetProtoByNumber( + PRInt32 protocolnumber, char* buffer, PRInt32 bufsize, PRProtoEnt* result); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_GetAddrInfoByName() +** Look up a host by name. Equivalent to getaddrinfo(host, NULL, ...) of +** RFC 3493. +** +** INPUTS: +** char *hostname Character string defining the host name of interest +** PRUint16 af May be PR_AF_UNSPEC or PR_AF_INET. +** PRIntn flags May be either PR_AI_ADDRCONFIG or +** PR_AI_ADDRCONFIG | PR_AI_NOCANONNAME. Include +** PR_AI_NOCANONNAME to suppress the determination of +** the canonical name corresponding to hostname. +** RETURN: +** PRAddrInfo* Handle to a data structure containing the results +** of the host lookup. Use PR_EnumerateAddrInfo to +** inspect the PRNetAddr values stored in this object. +** When no longer needed, this handle must be destroyed +** with a call to PR_FreeAddrInfo. If a lookup error +** occurs, then NULL will be returned. +***********************************************************************/ +typedef struct PRAddrInfo PRAddrInfo; + +NSPR_API(PRAddrInfo*) PR_GetAddrInfoByName( + const char *hostname, PRUint16 af, PRIntn flags); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_FreeAddrInfo() +** Destroy the PRAddrInfo handle allocated by PR_GetAddrInfoByName(). +** +** INPUTS: +** PRAddrInfo *addrInfo +** The handle resulting from a successful call to +** PR_GetAddrInfoByName(). +** RETURN: +** void +***********************************************************************/ +NSPR_API(void) PR_FreeAddrInfo(PRAddrInfo *addrInfo); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_EnumerateAddrInfo() +** A stateless enumerator over a PRAddrInfo handle acquired from +** PR_GetAddrInfoByName() to inspect the possible network addresses. +** +** INPUTS: +** void *enumPtr Index pointer of the enumeration. The enumeration +** starts and ends with a value of NULL. +** const PRAddrInfo *addrInfo +** The PRAddrInfo handle returned by a successful +** call to PR_GetAddrInfoByName(). +** PRUint16 port The port number to be assigned as part of the +** PRNetAddr. +** OUTPUTS: +** PRNetAddr *result A pointer to an address structure that will be +** filled in by the call to the enumeration if the +** result of the call is not NULL. +** RETURN: +** void* The value that should be used for the next call +** of the enumerator ('enumPtr'). The enumeration +** is ended if this value is NULL. +***********************************************************************/ +NSPR_API(void *) PR_EnumerateAddrInfo( + void *enumPtr, const PRAddrInfo *addrInfo, PRUint16 port, PRNetAddr *result); + +NSPR_API(PRStatus) PR_GetPrefLoopbackAddrInfo(PRNetAddr *result, + PRUint16 port); + +/*********************************************************************** +** FUNCTION: +** DESCRIPTION: PR_GetCanonNameFromAddrInfo() +** Extracts the canonical name of the hostname passed to +** PR_GetAddrInfoByName(). +** +** INPUTS: +** const PRAddrInfo *addrInfo +** The PRAddrInfo handle returned by a successful +** call to PR_GetAddrInfoByName(). +** RETURN: +** const char * A const pointer to the canonical hostname stored +** in the given PRAddrInfo handle. This pointer is +** invalidated once the PRAddrInfo handle is destroyed +** by a call to PR_FreeAddrInfo(). +***********************************************************************/ +NSPR_API(const char *) PR_GetCanonNameFromAddrInfo( + const PRAddrInfo *addrInfo); + +/*********************************************************************** +** FUNCTIONS: PR_ntohs, PR_ntohl, PR_ntohll, PR_htons, PR_htonl, PR_htonll +** +** DESCRIPTION: API entries for the common byte ordering routines. +** +** PR_ntohs 16 bit conversion from network to host +** PR_ntohl 32 bit conversion from network to host +** PR_ntohll 64 bit conversion from network to host +** PR_htons 16 bit conversion from host to network +** PR_htonl 32 bit conversion from host to network +** PR_ntonll 64 bit conversion from host to network +** +***********************************************************************/ +NSPR_API(PRUint16) PR_ntohs(PRUint16); +NSPR_API(PRUint32) PR_ntohl(PRUint32); +NSPR_API(PRUint64) PR_ntohll(PRUint64); +NSPR_API(PRUint16) PR_htons(PRUint16); +NSPR_API(PRUint32) PR_htonl(PRUint32); +NSPR_API(PRUint64) PR_htonll(PRUint64); + +PR_END_EXTERN_C + +#endif /* prnetdb_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prolock.h b/illumos-x86_64/usr/include/mps/prolock.h new file mode 100644 index 00000000..7b57b3c7 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prolock.h @@ -0,0 +1,178 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prolock_h___ +#define prolock_h___ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* +** A locking mechanism, built on the existing PRLock definition, +** is provided that will permit applications to define a Lock +** Hierarchy (or Lock Ordering) schema. An application designed +** using the Ordered Lock functions will terminate with a +** diagnostic message when a lock inversion condition is +** detected. +** +** The lock ordering detection is compile-time enabled only. In +** optimized builds of NSPR, the Ordered Lock functions map +** directly to PRLock functions, providing no lock order +** detection. +** +** The Ordered Lock Facility is compiled in when DEBUG is defined at +** compile-time. Ordered Lock can be forced on in optimized builds by +** defining FORCE_NSPR_ORDERED_LOCK at compile-time. Both the +** application using Ordered Lock and NSPR must be compiled with the +** facility enabled to achieve the desired results. +** +** Application designers should use the macro interfaces to the Ordered +** Lock facility to ensure that it is compiled out in optimized builds. +** +** Application designers are responsible for defining their own +** lock hierarchy. +** +** Ordered Lock is thread-safe and SMP safe. +** +** See Also: prlock.h +** +** /lth. 10-Jun-1998. +** +*/ + +/* +** Opaque type for ordered lock. +** ... Don't even think of looking in here. +** +*/ + +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) +typedef void * PROrderedLock; +#else +/* +** Map PROrderedLock and methods onto PRLock when ordered locking +** is not compiled in. +** +*/ +#include "prlock.h" + +typedef PRLock PROrderedLock; +#endif + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_CreateOrderedLock() -- Create an Ordered Lock +** +** DESCRIPTION: PR_CreateOrderedLock() creates an ordered lock. +** +** INPUTS: +** order: user defined order of this lock. +** name: name of the lock. For debugging purposes. +** +** OUTPUTS: returned +** +** RETURNS: PR_OrderedLock pointer +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) +#define PR_CREATE_ORDERED_LOCK(order,name)\ + PR_CreateOrderedLock((order),(name)) +#else +#define PR_CREATE_ORDERED_LOCK(order) PR_NewLock() +#endif + +NSPR_API(PROrderedLock *) +PR_CreateOrderedLock( + PRInt32 order, + const char *name +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_DestroyOrderedLock() -- Destroy an Ordered Lock +** +** DESCRIPTION: PR_DestroyOrderedLock() destroys the ordered lock +** referenced by lock. +** +** INPUTS: lock: pointer to a PROrderedLock +** +** OUTPUTS: the lock is destroyed +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) +#define PR_DESTROY_ORDERED_LOCK(lock) PR_DestroyOrderedLock((lock)) +#else +#define PR_DESTROY_ORDERED_LOCK(lock) PR_DestroyLock((lock)) +#endif + +NSPR_API(void) +PR_DestroyOrderedLock( + PROrderedLock *lock +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_LockOrderedLock() -- Lock an ordered lock +** +** DESCRIPTION: PR_LockOrderedLock() locks the ordered lock +** referenced by lock. If the order of lock is less than or equal +** to the order of the highest lock held by the locking thread, +** the function asserts. +** +** INPUTS: lock: a pointer to a PROrderedLock +** +** OUTPUTS: The lock is held or the function asserts. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) +#define PR_LOCK_ORDERED_LOCK(lock) PR_LockOrderedLock((lock)) +#else +#define PR_LOCK_ORDERED_LOCK(lock) PR_Lock((lock)) +#endif + +NSPR_API(void) +PR_LockOrderedLock( + PROrderedLock *lock +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_UnlockOrderedLock() -- unlock and Ordered Lock +** +** DESCRIPTION: PR_UnlockOrderedLock() unlocks the lock referenced +** by lock. +** +** INPUTS: lock: a pointer to a PROrderedLock +** +** OUTPUTS: the lock is unlocked +** +** RETURNS: +** PR_SUCCESS +** PR_FAILURE +** +** RESTRICTIONS: +** +*/ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) +#define PR_UNLOCK_ORDERED_LOCK(lock) PR_UnlockOrderedLock((lock)) +#else +#define PR_UNLOCK_ORDERED_LOCK(lock) PR_Unlock((lock)) +#endif + +NSPR_API(PRStatus) +PR_UnlockOrderedLock( + PROrderedLock *lock +); + +PR_END_EXTERN_C + +#endif /* prolock_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prpdce.h b/illumos-x86_64/usr/include/mps/prpdce.h new file mode 100644 index 00000000..bf9ea9e2 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prpdce.h @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * File: prpdce.h + * Description: This file is the API defined to allow for DCE (aka POSIX) + * thread emulation in an NSPR environment. It is not the + * intent that this be a fully supported API. + */ + +#if !defined(PRPDCE_H) +#define PRPDCE_H + +#include "prlock.h" +#include "prcvar.h" +#include "prtypes.h" +#include "prinrval.h" + +PR_BEGIN_EXTERN_C + +#define _PR_NAKED_CV_LOCK (PRLock*)0xdce1dce1 + +/* +** Test and acquire a lock. +** +** If the lock is acquired by the calling thread, the +** return value will be PR_SUCCESS. If the lock is +** already held, by another thread or this thread, the +** result will be PR_FAILURE. +*/ +NSPR_API(PRStatus) PRP_TryLock(PRLock *lock); + +/* +** Create a naked condition variable +** +** A "naked" condition variable is one that is not created bound +** to a lock. The CV created with this function is the only type +** that may be used in the subsequent "naked" condition variable +** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast); +*/ +NSPR_API(PRCondVar*) PRP_NewNakedCondVar(void); + +/* +** Destroy a naked condition variable +** +** Destroy the condition variable created by PR_NewNakedCondVar. +*/ +NSPR_API(void) PRP_DestroyNakedCondVar(PRCondVar *cvar); + +/* +** Wait on a condition +** +** Wait on the condition variable 'cvar'. It is asserted that +** the lock protecting the condition 'lock' is held by the +** calling thread. If more time expires than that declared in +** 'timeout' the condition will be notified. Waits can be +** interrupted by another thread. +** +** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. +*/ +NSPR_API(PRStatus) PRP_NakedWait( + PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout); + +/* +** Notify a thread waiting on a condition +** +** Notify the condition specified 'cvar'. +** +** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. +*/ +NSPR_API(PRStatus) PRP_NakedNotify(PRCondVar *cvar); + +/* +** Notify all threads waiting on a condition +** +** Notify the condition specified 'cvar'. +** +** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. +*/ +NSPR_API(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar); + +PR_END_EXTERN_C + +#endif /* PRPDCE_H */ diff --git a/illumos-x86_64/usr/include/mps/prprf.h b/illumos-x86_64/usr/include/mps/prprf.h new file mode 100644 index 00000000..759ef405 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prprf.h @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prprf_h___ +#define prprf_h___ + +/* +** API for PR printf like routines. Supports the following formats +** %d - decimal +** %u - unsigned decimal +** %x - unsigned hex +** %X - unsigned uppercase hex +** %o - unsigned octal +** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above +** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above +** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above +** %s - string +** %c - character +** %p - pointer (deals with machine dependent pointer size) +** %f - float +** %g - float +*/ +#include "prtypes.h" +#include "prio.h" +#include +#include + +PR_BEGIN_EXTERN_C + +/* +** sprintf into a fixed size buffer. Guarantees that a NUL is at the end +** of the buffer. Returns the length of the written output, NOT including +** the NUL, or (PRUint32)-1 if an error occurs. +*/ +NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...); + +/* +** sprintf into a PR_MALLOC'd buffer. Return a pointer to the malloc'd +** buffer on success, NULL on failure. Call "PR_smprintf_free" to release +** the memory returned. +*/ +NSPR_API(char*) PR_smprintf(const char *fmt, ...); + +/* +** Free the memory allocated, for the caller, by PR_smprintf +*/ +NSPR_API(void) PR_smprintf_free(char *mem); + +/* +** "append" sprintf into a PR_MALLOC'd buffer. "last" is the last value of +** the PR_MALLOC'd buffer. sprintf will append data to the end of last, +** growing it as necessary using realloc. If last is NULL, PR_sprintf_append +** will allocate the initial string. The return value is the new value of +** last for subsequent calls, or NULL if there is a malloc failure. +*/ +NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...); + +/* +** sprintf into a function. The function "f" is called with a string to +** place into the output. "arg" is an opaque pointer used by the stuff +** function to hold any state needed to do the storage of the output +** data. The return value is a count of the number of characters fed to +** the stuff function, or (PRUint32)-1 if an error occurs. +*/ +typedef PRIntn (*PRStuffFunc)(void *arg, const char *s, PRUint32 slen); + +NSPR_API(PRUint32) PR_sxprintf(PRStuffFunc f, void *arg, const char *fmt, ...); + +/* +** fprintf to a PRFileDesc +*/ +NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...); + +/* +** va_list forms of the above. +*/ +NSPR_API(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen, const char *fmt, va_list ap); +NSPR_API(char*) PR_vsmprintf(const char *fmt, va_list ap); +NSPR_API(char*) PR_vsprintf_append(char *last, const char *fmt, va_list ap); +NSPR_API(PRUint32) PR_vsxprintf(PRStuffFunc f, void *arg, const char *fmt, va_list ap); +NSPR_API(PRUint32) PR_vfprintf(struct PRFileDesc* fd, const char *fmt, va_list ap); + +/* +*************************************************************************** +** FUNCTION: PR_sscanf +** DESCRIPTION: +** PR_sscanf() scans the input character string, performs data +** conversions, and stores the converted values in the data objects +** pointed to by its arguments according to the format control +** string. +** +** PR_sscanf() behaves the same way as the sscanf() function in the +** Standard C Library (stdio.h), with the following exceptions: +** - PR_sscanf() handles the NSPR integer and floating point types, +** such as PRInt16, PRInt32, PRInt64, and PRFloat64, whereas +** sscanf() handles the standard C types like short, int, long, +** and double. +** - PR_sscanf() has no multibyte character support, while sscanf() +** does. +** INPUTS: +** const char *buf +** a character string holding the input to scan +** const char *fmt +** the format control string for the conversions +** ... +** variable number of arguments, each of them is a pointer to +** a data object in which the converted value will be stored +** OUTPUTS: none +** RETURNS: PRInt32 +** The number of values converted and stored. +** RESTRICTIONS: +** Multibyte characters in 'buf' or 'fmt' are not allowed. +*************************************************************************** +*/ + +NSPR_API(PRInt32) PR_sscanf(const char *buf, const char *fmt, ...); + +PR_END_EXTERN_C + +#endif /* prprf_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prproces.h b/illumos-x86_64/usr/include/mps/prproces.h new file mode 100644 index 00000000..e23504ac --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prproces.h @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prproces_h___ +#define prproces_h___ + +#include "prtypes.h" +#include "prio.h" + +PR_BEGIN_EXTERN_C + +/************************************************************************/ +/*****************************PROCESS OPERATIONS*************************/ +/************************************************************************/ + +typedef struct PRProcess PRProcess; +typedef struct PRProcessAttr PRProcessAttr; + +NSPR_API(PRProcessAttr *) PR_NewProcessAttr(void); + +NSPR_API(void) PR_ResetProcessAttr(PRProcessAttr *attr); + +NSPR_API(void) PR_DestroyProcessAttr(PRProcessAttr *attr); + +NSPR_API(void) PR_ProcessAttrSetStdioRedirect( + PRProcessAttr *attr, + PRSpecialFD stdioFd, + PRFileDesc *redirectFd +); + +/* + * OBSOLETE -- use PR_ProcessAttrSetStdioRedirect instead. + */ +NSPR_API(void) PR_SetStdioRedirect( + PRProcessAttr *attr, + PRSpecialFD stdioFd, + PRFileDesc *redirectFd +); + +NSPR_API(PRStatus) PR_ProcessAttrSetCurrentDirectory( + PRProcessAttr *attr, + const char *dir +); + +NSPR_API(PRStatus) PR_ProcessAttrSetInheritableFD( + PRProcessAttr *attr, + PRFileDesc *fd, + const char *name +); + +/* +** Create a new process +** +** Create a new process executing the file specified as 'path' and with +** the supplied arguments and environment. +** +** This function may fail because of illegal access (permissions), +** invalid arguments or insufficient resources. +** +** A process may be created such that the creator can later synchronize its +** termination using PR_WaitProcess(). +*/ + +NSPR_API(PRProcess*) PR_CreateProcess( + const char *path, + char *const *argv, + char *const *envp, + const PRProcessAttr *attr); + +NSPR_API(PRStatus) PR_CreateProcessDetached( + const char *path, + char *const *argv, + char *const *envp, + const PRProcessAttr *attr); + +NSPR_API(PRStatus) PR_DetachProcess(PRProcess *process); + +NSPR_API(PRStatus) PR_WaitProcess(PRProcess *process, PRInt32 *exitCode); + +NSPR_API(PRStatus) PR_KillProcess(PRProcess *process); + +PR_END_EXTERN_C + +#endif /* prproces_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prrng.h b/illumos-x86_64/usr/include/mps/prrng.h new file mode 100644 index 00000000..db7dc68c --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prrng.h @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/* +** prrng.h -- NSPR Random Number Generator +** +** +** lth. 29-Oct-1999. +*/ + +#ifndef prrng_h___ +#define prrng_h___ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* +** PR_GetRandomNoise() -- Get random noise from the host platform +** +** Description: +** PR_GetRandomNoise() provides, depending on platform, a random value. +** The length of the random value is dependent on platform and the +** platform's ability to provide a random value at that moment. +** +** The intent of PR_GetRandomNoise() is to provide a "seed" value for a +** another random number generator that may be suitable for +** cryptographic operations. This implies that the random value +** provided may not be, by itself, cryptographically secure. The value +** generated by PR_GetRandomNoise() is at best, extremely difficult to +** predict and is as non-deterministic as the underlying platfrom can +** provide. +** +** Inputs: +** buf -- pointer to a caller supplied buffer to contain the +** generated random number. buf must be at least as large as +** is specified in the 'size' argument. +** +** size -- the requested size of the generated random number +** +** Outputs: +** a random number provided in 'buf'. +** +** Returns: +** PRSize value equal to the size of the random number actually +** generated, or zero. The generated size may be less than the size +** requested. A return value of zero means that PR_GetRandomNoise() is +** not implemented on this platform, or there is no available noise +** available to be returned at the time of the call. +** +** Restrictions: +** Calls to PR_GetRandomNoise() may use a lot of CPU on some platforms. +** Some platforms may block for up to a few seconds while they +** accumulate some noise. Busy machines generate lots of noise, but +** care is advised when using PR_GetRandomNoise() frequently in your +** application. +** +** History: +** Parts of the model dependent implementation for PR_GetRandomNoise() +** were taken in whole or part from code previously in Netscape's NSS +** component. +** +*/ +NSPR_API(PRSize) PR_GetRandomNoise( + void *buf, + PRSize size +); + +PR_END_EXTERN_C + +#endif /* prrng_h___ */ +/* end prrng.h */ diff --git a/illumos-x86_64/usr/include/mps/prrwlock.h b/illumos-x86_64/usr/include/mps/prrwlock.h new file mode 100644 index 00000000..ab47b53f --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prrwlock.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: prrwlock.h +** Description: API to basic reader-writer lock functions of NSPR. +** +**/ + +#ifndef prrwlock_h___ +#define prrwlock_h___ + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* + * PRRWLock -- + * + * The reader writer lock, PRRWLock, is an opaque object to the clients + * of NSPR. All routines operate on a pointer to this opaque entity. + */ + + +typedef struct PRRWLock PRRWLock; + +#define PR_RWLOCK_RANK_NONE 0 + + +/*********************************************************************** +** FUNCTION: PR_NewRWLock +** DESCRIPTION: +** Returns a pointer to a newly created reader-writer lock object. +** INPUTS: Lock rank +** Lock name +** OUTPUTS: void +** RETURN: PRRWLock* +** If the lock cannot be created because of resource constraints, NULL +** is returned. +** +***********************************************************************/ +NSPR_API(PRRWLock*) PR_NewRWLock(PRUint32 lock_rank, const char *lock_name); + +/*********************************************************************** +** FUNCTION: PR_DestroyRWLock +** DESCRIPTION: +** Destroys a given RW lock object. +** INPUTS: PRRWLock *lock - Lock to be freed. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +NSPR_API(void) PR_DestroyRWLock(PRRWLock *lock); + +/*********************************************************************** +** FUNCTION: PR_RWLock_Rlock +** DESCRIPTION: +** Apply a read lock (non-exclusive) on a RWLock +** INPUTS: PRRWLock *lock - Lock to be read-locked. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +NSPR_API(void) PR_RWLock_Rlock(PRRWLock *lock); + +/*********************************************************************** +** FUNCTION: PR_RWLock_Wlock +** DESCRIPTION: +** Apply a write lock (exclusive) on a RWLock +** INPUTS: PRRWLock *lock - Lock to write-locked. +** OUTPUTS: void +** RETURN: None +***********************************************************************/ +NSPR_API(void) PR_RWLock_Wlock(PRRWLock *lock); + +/*********************************************************************** +** FUNCTION: PR_RWLock_Unlock +** DESCRIPTION: +** Release a RW lock. Unlocking an unlocked lock has undefined results. +** INPUTS: PRRWLock *lock - Lock to unlocked. +** OUTPUTS: void +** RETURN: void +***********************************************************************/ +NSPR_API(void) PR_RWLock_Unlock(PRRWLock *lock); + +PR_END_EXTERN_C + +#endif /* prrwlock_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prshm.h b/illumos-x86_64/usr/include/mps/prshm.h new file mode 100644 index 00000000..3588aed4 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prshm.h @@ -0,0 +1,257 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** prshm.h -- NSPR Shared Memory +** +** NSPR Named Shared Memory API provides a cross-platform named +** shared-memory interface. NSPR Named Shared Memory is modeled on +** similar constructs in Unix and Windows operating systems. Shared +** memory allows multiple processes to access one or more common shared +** memory regions, using it as an inter-process communication channel. +** +** Notes on Platform Independence: +** NSPR Named Shared Memory is built on the native services offered +** by most platforms. The NSPR Named Shared Memory API tries to +** provide a least common denominator interface so that it works +** across all supported platforms. To ensure that it works everywhere, +** some platform considerations must be accomodated and the protocol +** for using NSPR Shared Memory API must be observed. +** +** Protocol: +** Multiple shared memories can be created using NSPR's Shared Memory +** feature. For each named shared memory, as defined by the name +** given in the PR_OpenSharedMemory() call, a protocol for using the +** shared memory API is required to ensure desired behavior. Failing +** to follow the protocol may yield unpredictable results. +** +** PR_OpenSharedMemory() will create the shared memory segment, if it +** does not already exist, or open a connection that the existing +** shared memory segment if it already exists. +** +** PR_AttachSharedMemory() should be called following +** PR_OpenSharedMemory() to map the memory segment to an address in +** the application's address space. +** +** PR_AttachSharedMemory() may be called to re-map a shared memory +** segment after detaching the same PRSharedMemory object. Be +** sure to detach it when done. +** +** PR_DetachSharedMemory() should be called to un-map the shared +** memory segment from the application's address space. +** +** PR_CloseSharedMemory() should be called when no further use of the +** PRSharedMemory object is required within a process. Following a +** call to PR_CloseSharedMemory() the PRSharedMemory object is +** invalid and cannot be reused. +** +** PR_DeleteSharedMemory() should be called before process +** termination. After calling PR_DeleteSharedMemory() any further use +** of the shared memory associated with the name may cause +** unpredictable results. +** +** Files: +** The name passed to PR_OpenSharedMemory() should be a valid filename +** for a unix platform. PR_OpenSharedMemory() creates file using the +** name passed in. Some platforms may mangle the name before creating +** the file and the shared memory. +** +** The unix implementation may use SysV IPC shared memory, Posix +** shared memory, or memory mapped files; the filename may used to +** define the namespace. On Windows, the name is significant, but +** there is no file associated with name. +** +** No assumptions about the persistence of data in the named file +** should be made. Depending on platform, the shared memory may be +** mapped onto system paging space and be discarded at process +** termination. +** +** All names provided to PR_OpenSharedMemory() should be valid +** filename syntax or name syntax for shared memory for the target +** platform. Referenced directories should have permissions +** appropriate for writing. +** +** Limits: +** Different platforms have limits on both the number and size of +** shared memory resources. The default system limits on some +** platforms may be smaller than your requirements. These limits may +** be adjusted on some platforms either via boot-time options or by +** setting the size of the system paging space to accomodate more +** and/or larger shared memory segment(s). +** +** Security: +** On unix platforms, depending on implementation, contents of the +** backing store for the shared memory can be exposed via the file +** system. Set permissions and or access controls at create and attach +** time to ensure you get the desired security. +** +** On windows platforms, no special security measures are provided. +** +** Example: +** The test case pr/tests/nameshm1.c provides an example of use as +** well as testing the operation of NSPR's Named Shared Memory. +** +** lth. 18-Aug-1999. +*/ + +#ifndef prshm_h___ +#define prshm_h___ + +#include "prtypes.h" +#include "prio.h" + +PR_BEGIN_EXTERN_C + +/* +** Declare opaque type PRSharedMemory. +*/ +typedef struct PRSharedMemory PRSharedMemory; + +/* +** FUNCTION: PR_OpenSharedMemory() +** +** DESCRIPTION: +** PR_OpenSharedMemory() creates a new shared-memory segment or +** associates a previously created memory segment with name. +** +** When parameter create is (PR_SHM_EXCL | PR_SHM_CREATE) and the +** shared memory already exists, the function returns NULL with the +** error set to PR_FILE_EXISTS_ERROR. +** +** When parameter create is PR_SHM_CREATE and the shared memory +** already exists, a handle to that memory segment is returned. If +** the segment does not exist, it is created and a pointer to the +** related PRSharedMemory structure is returned. +** +** When parameter create is 0, and the shared memory exists, a +** pointer to a PRSharedMemory is returned. If the shared memory does +** not exist, NULL is returned with the error set to +** PR_FILE_NOT_FOUND_ERROR. +** +** INPUTS: +** name -- the name the shared-memory segment is known as. +** size -- the size of the shared memory segment. +** flags -- Options for creating the shared memory +** mode -- Same as is passed to PR_Open() +** +** OUTPUTS: +** The shared memory is allocated. +** +** RETURNS: Pointer to opaque structure PRSharedMemory or NULL. +** NULL is returned on error. The reason for the error can be +** retrieved via PR_GetError() and PR_GetOSError(); +** +*/ +NSPR_API( PRSharedMemory * ) +PR_OpenSharedMemory( + const char *name, + PRSize size, + PRIntn flags, + PRIntn mode +); +/* Define values for PR_OpenShareMemory(...,create) */ +#define PR_SHM_CREATE 0x1 /* create if not exist */ +#define PR_SHM_EXCL 0x2 /* fail if already exists */ + +/* +** FUNCTION: PR_AttachSharedMemory() +** +** DESCRIPTION: +** PR_AttachSharedMemory() maps the shared-memory described by +** shm to the current process. +** +** INPUTS: +** shm -- The handle returned from PR_OpenSharedMemory(). +** flags -- options for mapping the shared memory. +** PR_SHM_READONLY causes the memory to be attached +** read-only. +** +** OUTPUTS: +** On success, the shared memory segment represented by shm is mapped +** into the process' address space. +** +** RETURNS: Address where shared memory is mapped, or NULL. +** NULL is returned on error. The reason for the error can be +** retrieved via PR_GetError() and PR_GetOSError(); +** +** +*/ +NSPR_API( void * ) +PR_AttachSharedMemory( + PRSharedMemory *shm, + PRIntn flags +); +/* Define values for PR_AttachSharedMemory(...,flags) */ +#define PR_SHM_READONLY 0x01 + +/* +** FUNCTION: PR_DetachSharedMemory() +** +** DESCRIPTION: +** PR_DetachSharedMemory() detaches the shared-memory described +** by shm. +** +** INPUTS: +** shm -- The handle returned from PR_OpenSharedMemory(). +** addr -- The address at which the memory was attached. +** +** OUTPUTS: +** The shared memory mapped to an address via a previous call to +** PR_AttachSharedMemory() is unmapped. +** +** RETURNS: PRStatus +** +*/ +NSPR_API( PRStatus ) +PR_DetachSharedMemory( + PRSharedMemory *shm, + void *addr +); + +/* +** FUNCTION: PR_CloseSharedMemory() +** +** DESCRIPTION: +** PR_CloseSharedMemory() closes the shared-memory described by +** shm. +** +** INPUTS: +** shm -- The handle returned from PR_OpenSharedMemory(). +** +** OUTPUTS: +** the shared memory represented by shm is closed +** +** RETURNS: PRStatus +** +*/ +NSPR_API( PRStatus ) +PR_CloseSharedMemory( + PRSharedMemory *shm +); + +/* +** FUNCTION: PR_DeleteSharedMemory() +** +** DESCRIPTION: +** The shared memory resource represented by name is released. +** +** INPUTS: +** name -- the name the shared-memory segment +** +** OUTPUTS: +** depending on platform, resources may be returned to the underlying +** operating system. +** +** RETURNS: PRStatus +** +*/ +NSPR_API( PRStatus ) +PR_DeleteSharedMemory( + const char *name +); + +PR_END_EXTERN_C + +#endif /* prshm_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prshma.h b/illumos-x86_64/usr/include/mps/prshma.h new file mode 100644 index 00000000..2a1990ad --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prshma.h @@ -0,0 +1,239 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** prshma.h -- NSPR Anonymous Shared Memory +** +** NSPR provides an anonymous shared memory based on NSPR's PRFileMap +** type. The anonymous file-mapped shared memory provides an inheritable +** shared memory, as in: the child process inherits the shared memory. +** Compare the file-mapped anonymous shared memory to to a named shared +** memory described in prshm.h. The intent is to provide a shared +** memory that is accessable only by parent and child processes. ... +** It's a security thing. +** +** Depending on the underlying platform, the file-mapped shared memory +** may be backed by a file. ... surprise! ... On some platforms, no +** real file backs the shared memory. On platforms where the shared +** memory is backed by a file, the file's name in the filesystem is +** visible to other processes for only the duration of the creation of +** the file, hopefully a very short time. This restricts processess +** that do not inherit the shared memory from opening the file and +** reading or writing its contents. Further, when all processes +** using an anonymous shared memory terminate, the backing file is +** deleted. ... If you are not paranoid, you're not paying attention. +** +** The file-mapped shared memory requires a protocol for the parent +** process and child process to share the memory. NSPR provides two +** protocols. Use one or the other; don't mix and match. +** +** In the first protocol, the job of passing the inheritable shared +** memory is done via helper-functions with PR_CreateProcess(). In the +** second protocol, the parent process is responsible for creating the +** child process; the parent and child are mutually responsible for +** passing a FileMap string. NSPR provides helper functions for +** extracting data from the PRFileMap object. ... See the examples +** below. +** +** Both sides should adhere strictly to the protocol for proper +** operation. The pseudo-code below shows the use of a file-mapped +** shared memory by a parent and child processes. In the examples, the +** server creates the file-mapped shared memory, the client attaches to +** it. +** +** First protocol. +** Server: +** +** fm = PR_OpenAnonFileMap(dirName, size, FilemapProt); +** addr = PR_MemMap(fm); +** attr = PR_NewProcessAttr(); +** PR_ProcessAttrSetInheritableFileMap( attr, fm, shmname ); +** PR_CreateProcess(Client); +** PR_DestroyProcessAttr(attr); +** ... yadda ... +** PR_MemUnmap( addr ); +** PR_CloseFileMap(fm); +** +** +** Client: +** ... started by server via PR_CreateProcess() +** fm = PR_GetInheritedFileMap( shmname ); +** addr = PR_MemMap(fm); +** ... yadda ... +** PR_MemUnmap(addr); +** PR_CloseFileMap(fm); +** +** +** Second Protocol: +** Server: +** +** fm = PR_OpenAnonFileMap(dirName, size, FilemapProt); +** fmstring = PR_ExportFileMapAsString( fm ); +** addr = PR_MemMap(fm); +** ... application specific technique to pass fmstring to child +** ... yadda ... Server uses his own magic to create child +** PR_MemUnmap( addr ); +** PR_CloseFileMap(fm); +** +** +** Client: +** ... started by server via his own magic +** ... application specific technique to find fmstring from parent +** fm = PR_ImportFileMapFromString( fmstring ) +** addr = PR_MemMap(fm); +** ... yadda ... +** PR_MemUnmap(addr); +** PR_CloseFileMap(fm); +** +** +** lth. 2-Jul-1999. +** +** Note: The second protocol was requested by NelsonB (7/1999); this is +** to accomodate servers which already create their own child processes +** using platform native methods. +** +*/ + +#ifndef prshma_h___ +#define prshma_h___ + +#include "prtypes.h" +#include "prio.h" +#include "prproces.h" + +PR_BEGIN_EXTERN_C + +/* +** PR_OpenAnonFileMap() -- Creates an anonymous file-mapped shared memory +** +** Description: +** PR_OpenAnonFileMap() creates an anonymous shared memory. If the +** shared memory already exists, a handle is returned to that shared +** memory object. +** +** On Unix platforms, PR_OpenAnonFileMap() uses 'dirName' as a +** directory name, without the trailing '/', to contain the anonymous +** file. A filename is generated for the name. +** +** On Windows platforms, dirName is ignored. +** +** Inputs: +** dirName -- A directory name to contain the anonymous file. +** size -- The size of the shared memory +** prot -- How the shared memory is mapped. See prio.h +** +** Outputs: +** PRFileMap * +** +** Returns: +** Pointer to PRFileMap or NULL on error. +** +*/ +NSPR_API( PRFileMap *) +PR_OpenAnonFileMap( + const char *dirName, + PRSize size, + PRFileMapProtect prot +); + +/* +** PR_ProcessAttrSetInheritableFileMap() -- Prepare FileMap for export +** to my children processes via PR_CreateProcess() +** +** Description: +** PR_ProcessAttrSetInheritableFileMap() connects the PRFileMap to +** PRProcessAttr with shmname. A subsequent call to PR_CreateProcess() +** makes the PRFileMap importable by the child process. +** +** Inputs: +** attr -- PRProcessAttr, used to pass data to PR_CreateProcess() +** fm -- PRFileMap structure to be passed to the child process +** shmname -- The name for the PRFileMap; used by child. +** +** Outputs: +** PRFileMap * +** +** Returns: +** PRStatus +** +*/ +NSPR_API(PRStatus) +PR_ProcessAttrSetInheritableFileMap( + PRProcessAttr *attr, + PRFileMap *fm, + const char *shmname +); + +/* +** PR_GetInheritedFileMap() -- Import a PRFileMap previously exported +** by my parent process via PR_CreateProcess() +** +** Description: +** PR_GetInheritedFileMap() retrieves a PRFileMap object exported from +** its parent process via PR_CreateProcess(). +** +** Inputs: +** shmname -- The name provided to PR_ProcessAttrSetInheritableFileMap() +** +** Outputs: +** PRFileMap * +** +** Returns: +** PRFileMap pointer or NULL. +** +*/ +NSPR_API( PRFileMap *) +PR_GetInheritedFileMap( + const char *shmname +); + +/* +** PR_ExportFileMapAsString() -- Creates a string identifying a PRFileMap +** +** Description: +** Creates an identifier, as a string, from a PRFileMap object +** previously created with PR_OpenAnonFileMap(). +** +** Inputs: +** fm -- PRFileMap pointer to be represented as a string. +** bufsize -- sizeof(buf) +** buf -- a buffer of length PR_FILEMAP_STRING_BUFSIZE +** +** Outputs: +** buf contains the stringized PRFileMap identifier +** +** Returns: +** PRStatus +** +*/ +NSPR_API( PRStatus ) +PR_ExportFileMapAsString( + PRFileMap *fm, + PRSize bufsize, + char *buf +); +#define PR_FILEMAP_STRING_BUFSIZE 128 + +/* +** PR_ImportFileMapFromString() -- Creates a PRFileMap from the identifying string +** +** Description: +** PR_ImportFileMapFromString() creates a PRFileMap object from a +** string previously created by PR_ExportFileMapAsString(). +** +** Inputs: +** fmstring -- string created by PR_ExportFileMapAsString() +** +** Returns: +** PRFileMap pointer or NULL. +** +*/ +NSPR_API( PRFileMap * ) +PR_ImportFileMapFromString( + const char *fmstring +); + +PR_END_EXTERN_C +#endif /* prshma_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prsystem.h b/illumos-x86_64/usr/include/mps/prsystem.h new file mode 100644 index 00000000..577e60e0 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prsystem.h @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prsystem_h___ +#define prsystem_h___ + +/* +** API to NSPR functions returning system info. +*/ +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* +** Get the host' directory separator. +** Pathnames are then assumed to be of the form: +** []*() +*/ + +NSPR_API(char) PR_GetDirectorySeparator(void); + +/* +** OBSOLETE -- the function name is misspelled. +** Use PR_GetDirectorySeparator instead. +*/ + +NSPR_API(char) PR_GetDirectorySepartor(void); + +/* +** Get the host' path separator. +** Paths are assumed to be of the form: +** []* +*/ + +NSPR_API(char) PR_GetPathSeparator(void); + +/* Types of information available via PR_GetSystemInfo(...) */ +typedef enum { + PR_SI_HOSTNAME, /* the hostname with the domain name (if any) + * removed */ + PR_SI_SYSNAME, + PR_SI_RELEASE, + PR_SI_ARCHITECTURE, + PR_SI_HOSTNAME_UNTRUNCATED, /* the hostname exactly as configured + * on the system */ + PR_SI_RELEASE_BUILD +} PRSysInfo; + + +/* +** If successful returns a null termintated string in 'buf' for +** the information indicated in 'cmd'. If unseccussful the reason for +** the failure can be retrieved from PR_GetError(). +** +** The buffer is allocated by the caller and should be at least +** SYS_INFO_BUFFER_LENGTH bytes in length. +*/ + +#define SYS_INFO_BUFFER_LENGTH 256 + +NSPR_API(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 buflen); + +/* +** Return the number of bytes in a page +*/ +NSPR_API(PRInt32) PR_GetPageSize(void); + +/* +** Return log2 of the size of a page +*/ +NSPR_API(PRInt32) PR_GetPageShift(void); + +/* +** PR_GetNumberOfProcessors() -- returns the number of CPUs +** +** Description: +** PR_GetNumberOfProcessors() extracts the number of processors +** (CPUs available in an SMP system) and returns the number. +** +** Parameters: +** none +** +** Returns: +** The number of available processors or -1 on error +** +*/ +NSPR_API(PRInt32) PR_GetNumberOfProcessors( void ); + +/* +** PR_GetPhysicalMemorySize() -- returns the amount of system RAM +** +** Description: +** PR_GetPhysicalMemorySize() determines the amount of physical RAM +** in the system and returns the size in bytes. +** +** Parameters: +** none +** +** Returns: +** The amount of system RAM, or 0 on failure. +** +*/ +NSPR_API(PRUint64) PR_GetPhysicalMemorySize(void); + +PR_END_EXTERN_C + +#endif /* prsystem_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prthread.h b/illumos-x86_64/usr/include/mps/prthread.h new file mode 100644 index 00000000..cacd3891 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prthread.h @@ -0,0 +1,272 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prthread_h___ +#define prthread_h___ + +/* +** API for NSPR threads. On some architectures (Mac OS Classic +** notably) pre-emptibility is not guaranteed. Hard priority scheduling +** is not guaranteed, so programming using priority based synchronization +** is a no-no. +** +** NSPR threads are scheduled based loosely on their client set priority. +** In general, a thread of a higher priority has a statistically better +** chance of running relative to threads of lower priority. However, +** NSPR uses multiple strategies to provide execution vehicles for thread +** abstraction of various host platforms. As it turns out, there is little +** NSPR can do to affect the scheduling attributes of "GLOBAL" threads. +** However, a semblance of GLOBAL threads is used to implement "LOCAL" +** threads. An arbitrary number of such LOCAL threads can be assigned to +** a single GLOBAL thread. +** +** For scheduling, NSPR will attempt to run the highest priority LOCAL +** thread associated with a given GLOBAL thread. It is further assumed +** that the host OS will apply some form of "fair" scheduling on the +** GLOBAL threads. +** +** Threads have a "system flag" which when set indicates the thread +** doesn't count for determining when the process should exit (the +** process exits when the last user thread exits). +** +** Threads also have a "scope flag" which controls whether the threads +** are scheduled in the local scope or scheduled by the OS globally. This +** indicates whether a thread is permanently bound to a native OS thread. +** An unbound thread competes for scheduling resources in the same process. +** +** Another flag is "state flag" which control whether the thread is joinable. +** It allows other threads to wait for the created thread to reach completion. +** +** Threads can have "per-thread-data" attached to them. Each thread has a +** per-thread error number and error string which are updated when NSPR +** operations fail. +*/ +#include "prtypes.h" +#include "prinrval.h" + +PR_BEGIN_EXTERN_C + +typedef struct PRThread PRThread; +typedef struct PRThreadStack PRThreadStack; + +typedef enum PRThreadType { + PR_USER_THREAD, + PR_SYSTEM_THREAD +} PRThreadType; + +typedef enum PRThreadScope { + PR_LOCAL_THREAD, + PR_GLOBAL_THREAD, + PR_GLOBAL_BOUND_THREAD +} PRThreadScope; + +typedef enum PRThreadState { + PR_JOINABLE_THREAD, + PR_UNJOINABLE_THREAD +} PRThreadState; + +typedef enum PRThreadPriority +{ + PR_PRIORITY_FIRST = 0, /* just a placeholder */ + PR_PRIORITY_LOW = 0, /* the lowest possible priority */ + PR_PRIORITY_NORMAL = 1, /* most common expected priority */ + PR_PRIORITY_HIGH = 2, /* slightly more aggressive scheduling */ + PR_PRIORITY_URGENT = 3, /* it does little good to have more than one */ + PR_PRIORITY_LAST = 3 /* this is just a placeholder */ +} PRThreadPriority; + +/* +** Create a new thread: +** "type" is the type of thread to create +** "start(arg)" will be invoked as the threads "main" +** "priority" will be created thread's priority +** "scope" will specify whether the thread is local or global +** "state" will specify whether the thread is joinable or not +** "stackSize" the size of the stack, in bytes. The value can be zero +** and then a machine specific stack size will be chosen. +** +** This can return NULL if some kind of error occurs, such as if memory is +** tight. +** +** If you want the thread to start up waiting for the creator to do +** something, enter a lock before creating the thread and then have the +** threads start routine enter and exit the same lock. When you are ready +** for the thread to run, exit the lock. +** +** If you want to detect the completion of the created thread, the thread +** should be created joinable. Then, use PR_JoinThread to synchrnoize the +** termination of another thread. +** +** When the start function returns the thread exits. If it is the last +** PR_USER_THREAD to exit then the process exits. +*/ +NSPR_API(PRThread*) PR_CreateThread(PRThreadType type, + void (PR_CALLBACK *start)(void *arg), + void *arg, + PRThreadPriority priority, + PRThreadScope scope, + PRThreadState state, + PRUint32 stackSize); + +/* +** Wait for thread termination: +** "thread" is the target thread +** +** This can return PR_FAILURE if no joinable thread could be found +** corresponding to the specified target thread. +** +** The calling thread is blocked until the target thread completes. +** Several threads cannot wait for the same thread to complete; one thread +** will operate successfully and others will terminate with an error PR_FAILURE. +** The calling thread will not be blocked if the target thread has already +** terminated. +*/ +NSPR_API(PRStatus) PR_JoinThread(PRThread *thread); + +/* +** Return the current thread object for the currently running code. +** Never returns NULL. +*/ +NSPR_API(PRThread*) PR_GetCurrentThread(void); +#ifndef NO_NSPR_10_SUPPORT +#define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */ +#endif /* NO_NSPR_10_SUPPORT */ + +/* +** Get the priority of "thread". +*/ +NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread); + +/* +** Change the priority of the "thread" to "priority". +** +** PR_SetThreadPriority works in a best-effort manner. On some platforms a +** special privilege, such as root access, is required to change thread +** priorities, especially to raise thread priorities. If the caller doesn't +** have enough privileges to change thread priorites, the function has no +** effect except causing a future PR_GetThreadPriority call to return +** |priority|. +*/ +NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority); + +/* +** Set the name of the current thread, which will be visible in a debugger +** and accessible via a call to PR_GetThreadName(). +*/ +NSPR_API(PRStatus) PR_SetCurrentThreadName(const char *name); + +/* +** Return the name of "thread", if set. Otherwise return NULL. +*/ +NSPR_API(const char *) PR_GetThreadName(const PRThread *thread); + +/* +** This routine returns a new index for per-thread-private data table. +** The index is visible to all threads within a process. This index can +** be used with the PR_SetThreadPrivate() and PR_GetThreadPrivate() routines +** to save and retrieve data associated with the index for a thread. +** +** Each index is associationed with a destructor function ('dtor'). The function +** may be specified as NULL when the index is created. If it is not NULL, the +** function will be called when: +** - the thread exits and the private data for the associated index +** is not NULL, +** - new thread private data is set and the current private data is +** not NULL. +** +** The index independently maintains specific values for each binding thread. +** A thread can only get access to its own thread-specific-data. +** +** Upon a new index return the value associated with the index for all threads +** is NULL, and upon thread creation the value associated with all indices for +** that thread is NULL. +** +** Returns PR_FAILURE if the total number of indices will exceed the maximun +** allowed. +*/ +typedef void (PR_CALLBACK *PRThreadPrivateDTOR)(void *priv); + +NSPR_API(PRStatus) PR_NewThreadPrivateIndex( + PRUintn *newIndex, PRThreadPrivateDTOR destructor); + +/* +** Define some per-thread-private data. +** "tpdIndex" is an index into the per-thread private data table +** "priv" is the per-thread-private data +** +** If the per-thread private data table has a previously registered +** destructor function and a non-NULL per-thread-private data value, +** the destructor function is invoked. +** +** This can return PR_FAILURE if the index is invalid. +*/ +NSPR_API(PRStatus) PR_SetThreadPrivate(PRUintn tpdIndex, void *priv); + +/* +** Recover the per-thread-private data for the current thread. "tpdIndex" is +** the index into the per-thread private data table. +** +** The returned value may be NULL which is indistinguishable from an error +** condition. +** +** A thread can only get access to its own thread-specific-data. +*/ +NSPR_API(void*) PR_GetThreadPrivate(PRUintn tpdIndex); + +/* +** This routine sets the interrupt request for a target thread. The interrupt +** request remains in the thread's state until it is delivered exactly once +** or explicitly canceled. +** +** A thread that has been interrupted will fail all NSPR blocking operations +** that return a PRStatus (I/O, waiting on a condition, etc). +** +** PR_Interrupt may itself fail if the target thread is invalid. +*/ +NSPR_API(PRStatus) PR_Interrupt(PRThread *thread); + +/* +** Clear the interrupt request for the calling thread. If no such request +** is pending, this operation is a noop. +*/ +NSPR_API(void) PR_ClearInterrupt(void); + +/* +** Block the interrupt for the calling thread. +*/ +NSPR_API(void) PR_BlockInterrupt(void); + +/* +** Unblock the interrupt for the calling thread. +*/ +NSPR_API(void) PR_UnblockInterrupt(void); + +/* +** Make the current thread sleep until "ticks" time amount of time +** has expired. If "ticks" is PR_INTERVAL_NO_WAIT then the call is +** equivalent to calling PR_Yield. Calling PR_Sleep with an argument +** equivalent to PR_INTERVAL_NO_TIMEOUT is an error and will result +** in a PR_FAILURE error return. +*/ +NSPR_API(PRStatus) PR_Sleep(PRIntervalTime ticks); + +/* +** Get the scoping of this thread. +*/ +NSPR_API(PRThreadScope) PR_GetThreadScope(const PRThread *thread); + +/* +** Get the type of this thread. +*/ +NSPR_API(PRThreadType) PR_GetThreadType(const PRThread *thread); + +/* +** Get the join state of this thread. +*/ +NSPR_API(PRThreadState) PR_GetThreadState(const PRThread *thread); + +PR_END_EXTERN_C + +#endif /* prthread_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prtime.h b/illumos-x86_64/usr/include/mps/prtime.h new file mode 100644 index 00000000..917a1615 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prtime.h @@ -0,0 +1,262 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + *---------------------------------------------------------------------- + * + * prtime.h -- + * + * NSPR date and time functions + * + *----------------------------------------------------------------------- + */ + +#ifndef prtime_h___ +#define prtime_h___ + +#include "prlong.h" + +PR_BEGIN_EXTERN_C + +/**********************************************************************/ +/************************* TYPES AND CONSTANTS ************************/ +/**********************************************************************/ + +#define PR_MSEC_PER_SEC 1000L +#define PR_USEC_PER_SEC 1000000L +#define PR_NSEC_PER_SEC 1000000000L +#define PR_USEC_PER_MSEC 1000L +#define PR_NSEC_PER_MSEC 1000000L + +/* + * PRTime -- + * + * NSPR represents basic time as 64-bit signed integers relative + * to midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT). + * (GMT is also known as Coordinated Universal Time, UTC.) + * The units of time are in microseconds. Negative times are allowed + * to represent times prior to the January 1970 epoch. Such values are + * intended to be exported to other systems or converted to human + * readable form. + * + * Notes on porting: PRTime corresponds to time_t in ANSI C. NSPR 1.0 + * simply uses PRInt64. + */ + +typedef PRInt64 PRTime; + +/* + * Time zone and daylight saving time corrections applied to GMT to + * obtain the local time of some geographic location + */ + +typedef struct PRTimeParameters { + PRInt32 tp_gmt_offset; /* the offset from GMT in seconds */ + PRInt32 tp_dst_offset; /* contribution of DST in seconds */ +} PRTimeParameters; + +/* + * PRExplodedTime -- + * + * Time broken down into human-readable components such as year, month, + * day, hour, minute, second, and microsecond. Time zone and daylight + * saving time corrections may be applied. If they are applied, the + * offsets from the GMT must be saved in the 'tm_params' field so that + * all the information is available to reconstruct GMT. + * + * Notes on porting: PRExplodedTime corrresponds to struct tm in + * ANSI C, with the following differences: + * - an additional field tm_usec; + * - replacing tm_isdst by tm_params; + * - the month field is spelled tm_month, not tm_mon; + * - we use absolute year, AD, not the year since 1900. + * The corresponding type in NSPR 1.0 is called PRTime. Below is + * a table of date/time type correspondence in the three APIs: + * API time since epoch time in components + * ANSI C time_t struct tm + * NSPR 1.0 PRInt64 PRTime + * NSPR 2.0 PRTime PRExplodedTime + */ + +typedef struct PRExplodedTime { + PRInt32 tm_usec; /* microseconds past tm_sec (0-99999) */ + PRInt32 tm_sec; /* seconds past tm_min (0-61, accomodating + up to two leap seconds) */ + PRInt32 tm_min; /* minutes past tm_hour (0-59) */ + PRInt32 tm_hour; /* hours past tm_day (0-23) */ + PRInt32 tm_mday; /* days past tm_mon (1-31, note that it + starts from 1) */ + PRInt32 tm_month; /* months past tm_year (0-11, Jan = 0) */ + PRInt16 tm_year; /* absolute year, AD (note that we do not + count from 1900) */ + + PRInt8 tm_wday; /* calculated day of the week + (0-6, Sun = 0) */ + PRInt16 tm_yday; /* calculated day of the year + (0-365, Jan 1 = 0) */ + + PRTimeParameters tm_params; /* time parameters used by conversion */ +} PRExplodedTime; + +/* + * PRTimeParamFn -- + * + * A function of PRTimeParamFn type returns the time zone and + * daylight saving time corrections for some geographic location, + * given the current time in GMT. The input argument gmt should + * point to a PRExplodedTime that is in GMT, i.e., whose + * tm_params contains all 0's. + * + * For any time zone other than GMT, the computation is intended to + * consist of two steps: + * - Figure out the time zone correction, tp_gmt_offset. This number + * usually depends on the geographic location only. But it may + * also depend on the current time. For example, all of China + * is one time zone right now. But this situation may change + * in the future. + * - Figure out the daylight saving time correction, tp_dst_offset. + * This number depends on both the geographic location and the + * current time. Most of the DST rules are expressed in local + * current time. If so, one should apply the time zone correction + * to GMT before applying the DST rules. + */ + +typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt); + +/**********************************************************************/ +/****************************** FUNCTIONS *****************************/ +/**********************************************************************/ + +/* + * The PR_Now routine returns the current time relative to the + * epoch, midnight, January 1, 1970 UTC. The units of the returned + * value are microseconds since the epoch. + * + * The values returned are not guaranteed to advance in a linear fashion + * due to the application of time correction protocols which synchronize + * computer clocks to some external time source. Consequently it should + * not be depended on for interval timing. + * + * The implementation is machine dependent. + * Cf. time_t time(time_t *tp) in ANSI C. + */ +NSPR_API(PRTime) +PR_Now(void); + +/* + * Expand time binding it to time parameters provided by PRTimeParamFn. + * The calculation is envisoned to proceed in the following steps: + * - From given PRTime, calculate PRExplodedTime in GMT + * - Apply the given PRTimeParamFn to the GMT that we just calculated + * to obtain PRTimeParameters. + * - Add the PRTimeParameters offsets to GMT to get the local time + * as PRExplodedTime. + */ + +NSPR_API(void) PR_ExplodeTime( + PRTime usecs, PRTimeParamFn params, PRExplodedTime *exploded); + +/* Reverse operation of PR_ExplodeTime */ +NSPR_API(PRTime) +PR_ImplodeTime(const PRExplodedTime *exploded); + +/* + * Adjust exploded time to normalize field overflows after manipulation. + * Note that the following fields of PRExplodedTime should not be + * manipulated: + * - tm_month and tm_year: because the number of days in a month and + * number of days in a year are not constant, it is ambiguous to + * manipulate the month and year fields, although one may be tempted + * to. For example, what does "a month from January 31st" mean? + * - tm_wday and tm_yday: these fields are calculated by NSPR. Users + * should treat them as "read-only". + */ + +NSPR_API(void) PR_NormalizeTime( + PRExplodedTime *exploded, PRTimeParamFn params); + +/**********************************************************************/ +/*********************** TIME PARAMETER FUNCTIONS *********************/ +/**********************************************************************/ + +/* Time parameters that suit current host machine */ +NSPR_API(PRTimeParameters) PR_LocalTimeParameters(const PRExplodedTime *gmt); + +/* Time parameters that represent Greenwich Mean Time */ +NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt); + +/* + * Time parameters that represent the US Pacific Time Zone, with the + * current daylight saving time rules (for testing only) + */ +NSPR_API(PRTimeParameters) PR_USPacificTimeParameters(const PRExplodedTime *gmt); + +/* + * This parses a time/date string into a PRExplodedTime + * struct. It populates all fields but it can't split + * the offset from UTC into tp_gmt_offset and tp_dst_offset in + * most cases (exceptions: PST/PDT, MST/MDT, CST/CDT, EST/EDT, GMT/BST). + * In those cases tp_gmt_offset will be the sum of these two and + * tp_dst_offset will be 0. + * It returns PR_SUCCESS on success, and PR_FAILURE + * if the time/date string can't be parsed. + * + * Many formats are handled, including: + * + * 14 Apr 89 03:20:12 + * 14 Apr 89 03:20 GMT + * Fri, 17 Mar 89 4:01:33 + * Fri, 17 Mar 89 4:01 GMT + * Mon Jan 16 16:12 PDT 1989 + * Mon Jan 16 16:12 +0130 1989 + * 6 May 1992 16:41-JST (Wednesday) + * 22-AUG-1993 10:59:12.82 + * 22-AUG-1993 10:59pm + * 22-AUG-1993 12:59am + * 22-AUG-1993 12:59 PM + * Friday, August 04, 1995 3:54 PM + * 06/21/95 04:24:34 PM + * 20/06/95 21:07 + * 95-06-08 19:32:48 EDT + * + * If the input string doesn't contain a description of the timezone, + * we consult the `default_to_gmt' to decide whether the string should + * be interpreted relative to the local time zone (PR_FALSE) or GMT (PR_TRUE). + * The correct value for this argument depends on what standard specified + * the time string which you are parsing. + */ + +NSPR_API(PRStatus) PR_ParseTimeStringToExplodedTime ( + const char *string, + PRBool default_to_gmt, + PRExplodedTime *result); + +/* + * This uses PR_ParseTimeStringToExplodedTime to parse + * a time/date string and PR_ImplodeTime to transform it into + * a PRTime (microseconds after "1-Jan-1970 00:00:00 GMT"). + * It returns PR_SUCCESS on success, and PR_FAILURE + * if the time/date string can't be parsed. + */ + +NSPR_API(PRStatus) PR_ParseTimeString ( + const char *string, + PRBool default_to_gmt, + PRTime *result); + +/* Format a time value into a buffer. Same semantics as strftime() */ +NSPR_API(PRUint32) PR_FormatTime(char *buf, int buflen, const char *fmt, + const PRExplodedTime *time); + +/* Format a time value into a buffer. Time is always in US English format, + * regardless of locale setting. + */ +NSPR_API(PRUint32) +PR_FormatTimeUSEnglish(char *buf, PRUint32 bufSize, + const char *format, const PRExplodedTime *time); + +PR_END_EXTERN_C + +#endif /* prtime_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prtpool.h b/illumos-x86_64/usr/include/mps/prtpool.h new file mode 100644 index 00000000..b4d18d41 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prtpool.h @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prtpool_h___ +#define prtpool_h___ + +#include "prtypes.h" +#include "prthread.h" +#include "prio.h" +#include "prerror.h" + +/* + * NOTE: + * THIS API IS A PRELIMINARY VERSION IN NSPR 4.0 AND IS SUBJECT TO + * CHANGE + */ + +PR_BEGIN_EXTERN_C + +typedef struct PRJobIoDesc { + PRFileDesc *socket; + PRErrorCode error; + PRIntervalTime timeout; +} PRJobIoDesc; + +typedef struct PRThreadPool PRThreadPool; +typedef struct PRJob PRJob; +typedef void (PR_CALLBACK *PRJobFn) (void *arg); + +/* Create thread pool */ +NSPR_API(PRThreadPool *) +PR_CreateThreadPool(PRInt32 initial_threads, PRInt32 max_threads, + PRUint32 stacksize); + +/* queue a job */ +NSPR_API(PRJob *) +PR_QueueJob(PRThreadPool *tpool, PRJobFn fn, void *arg, PRBool joinable); + +/* queue a job, when a socket is readable */ +NSPR_API(PRJob *) +PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod, + PRJobFn fn, void * arg, PRBool joinable); + +/* queue a job, when a socket is writeable */ +NSPR_API(PRJob *) +PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod, + PRJobFn fn, void * arg, PRBool joinable); + +/* queue a job, when a socket has a pending connection */ +NSPR_API(PRJob *) +PR_QueueJob_Accept(PRThreadPool *tpool, PRJobIoDesc *iod, + PRJobFn fn, void * arg, PRBool joinable); + +/* queue a job, when the socket connection to addr succeeds or fails */ +NSPR_API(PRJob *) +PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod, + const PRNetAddr *addr, PRJobFn fn, void * arg, PRBool joinable); + +/* queue a job, when a timer exipres */ +NSPR_API(PRJob *) +PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout, + PRJobFn fn, void * arg, PRBool joinable); +/* cancel a job */ +NSPR_API(PRStatus) +PR_CancelJob(PRJob *job); + +/* join a job */ +NSPR_API(PRStatus) +PR_JoinJob(PRJob *job); + +/* shutdown pool */ +NSPR_API(PRStatus) +PR_ShutdownThreadPool(PRThreadPool *tpool); + +/* join pool, wait for exit of all threads */ +NSPR_API(PRStatus) +PR_JoinThreadPool(PRThreadPool *tpool); + +PR_END_EXTERN_C + +#endif /* prtpool_h___ */ diff --git a/illumos-x86_64/usr/include/mps/prtrace.h b/illumos-x86_64/usr/include/mps/prtrace.h new file mode 100644 index 00000000..49bd3edb --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prtrace.h @@ -0,0 +1,646 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef prtrace_h___ +#define prtrace_h___ +/* +** prtrace.h -- NSPR's Trace Facility. +** +** The Trace Facility provides a means to trace application +** program events within a process. When implementing an +** application program an engineer may insert a "Trace" function +** call, passing arguments to be traced. The "Trace" function +** combines the user trace data with identifying data and +** writes this data in time ordered sequence into a circular +** in-memory buffer; when the buffer fills, it wraps. +** +** Functions are provided to set and/or re-configure the size of +** the trace buffer, control what events are recorded in the +** buffer, enable and disable tracing based on specific user +** supplied data and other control functions. Methods are provided +** to record the trace entries in the in-memory trace buffer to +** a file. +** +** Tracing may cause a performance degredation to the application +** depending on the number and placement of calls to the tracing +** facility. When tracing is compiled in and all tracing is +** disabled via the runtime controls, the overhead should be +** minimal. ... Famous last words, eh? +** +** When DEBUG is defined at compile time, the Trace Facility is +** compiled as part of NSPR and any application using NSPR's +** header files will have tracing compiled in. When DEBUG is not +** defined, the Trace Facility is not compiled into NSPR nor +** exported in its header files. If the Trace Facility is +** desired in a non-debug build, then FORCE_NSPR_TRACE may be +** defined at compile time for both the optimized build of NSPR +** and the application. NSPR and any application using NSPR's +** Trace Facility must be compiled with the same level of trace +** conditioning or unresolved references may be realized at link +** time. +** +** For any of the Trace Facility methods that requires a trace +** handle as an input argument, the caller must ensure that the +** trace handle argument is valid. An invalid trace handle +** argument may cause unpredictable results. +** +** Trace Facility methods are thread-safe and SMP safe. +** +** Users of the Trace Facility should use the defined macros to +** invoke trace methods, not the function calls directly. e.g. +** PR_TRACE( h1,0,1,2, ...); not PR_Trace(h1,0,1,2, ...); +** +** Application designers should be aware of the effects of +** debug and optimized build differences when using result of the +** Trace Facility macros in expressions. +** +** See Also: prcountr.h +** +** /lth. 08-Jun-1998. +*/ + +#include "prtypes.h" +#include "prthread.h" +#include "prtime.h" + +PR_BEGIN_EXTERN_C + +/* +** Opaque type for the trace handle +** ... Don't even think about looking in here. +** +*/ +typedef void * PRTraceHandle; + +/* +** PRTraceEntry -- A trace entry in the in-memory trace buffer +** looks like this. +** +*/ +typedef struct PRTraceEntry +{ + PRThread *thread; /* The thread creating the trace entry */ + PRTraceHandle handle; /* PRTraceHandle creating the trace entry */ + PRTime time; /* Value of PR_Now() at time of trace entry */ + PRUint32 userData[8]; /* user supplied trace data */ +} PRTraceEntry; + +/* +** PRTraceOption -- command operands to +** PR_[Set|Get]TraceOption(). See descriptive meanings there. +** +*/ +typedef enum PRTraceOption +{ + PRTraceBufSize, + PRTraceEnable, + PRTraceDisable, + PRTraceSuspend, + PRTraceResume, + PRTraceSuspendRecording, + PRTraceResumeRecording, + PRTraceLockHandles, + PRTraceUnLockHandles, + PRTraceStopRecording +} PRTraceOption; + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_DEFINE_TRACE() -- Define a PRTraceHandle +** +** DESCRIPTION: PR_DEFINE_TRACE() is used to define a trace +** handle. +** +*/ +#define PR_DEFINE_TRACE(name) PRTraceHandle name + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_INIT_TRACE_HANDLE() -- Set the value of a PRTraceHandle +** +** DESCRIPTION: +** PR_INIT_TRACE_HANDLE() sets the value of a PRTraceHandle +** to value. e.g. PR_INIT_TRACE_HANDLE( myHandle, NULL ); +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_INIT_TRACE_HANDLE(handle,value)\ + (handle) = (PRCounterHandle)(value) +#else +#define PR_INIT_TRACE_HANDLE(handle,value) +#endif + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_CreateTrace() -- Create a trace handle +** +** DESCRIPTION: +** PR_CreateTrace() creates a new trace handle. Tracing is +** enabled for this handle when it is created. The trace handle +** is intended for use in other Trace Facility calls. +** +** PR_CreateTrace() registers the QName, RName and description +** data so that this data can be retrieved later. +** +** INPUTS: +** qName: pointer to string. QName for this trace handle. +** +** rName: pointer to string. RName for this trace handle. +** +** description: pointer to string. Descriptive data about this +** trace handle. +** +** OUTPUTS: +** Creates the trace handle. +** Registers the QName and RName with the trace facility. +** +** RETURNS: +** PRTraceHandle +** +** RESTRICTIONS: +** qName is limited to 31 characters. +** rName is limited to 31 characters. +** description is limited to 255 characters. +** +*/ +#define PRTRACE_NAME_MAX 31 +#define PRTRACE_DESC_MAX 255 + +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_CREATE_TRACE(handle,qName,rName,description)\ + (handle) = PR_CreateTrace((qName),(rName),(description)) +#else +#define PR_CREATE_TRACE(handle,qName,rName,description) +#endif + +NSPR_API(PRTraceHandle) +PR_CreateTrace( + const char *qName, /* QName for this trace handle */ + const char *rName, /* RName for this trace handle */ + const char *description /* description for this trace handle */ +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_DestroyTrace() -- Destroy a trace handle +** +** DESCRIPTION: +** PR_DestroyTrace() removes the referenced trace handle and +** associated QName, RName and description data from the Trace +** Facility. +** +** INPUTS: handle. A PRTraceHandle +** +** OUTPUTS: +** The trace handle is unregistered. +** The QName, RName and description are removed. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_DESTROY_TRACE(handle)\ + PR_DestroyTrace((handle)) +#else +#define PR_DESTROY_TRACE(handle) +#endif + +NSPR_API(void) +PR_DestroyTrace( + PRTraceHandle handle /* Handle to be destroyed */ +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_Trace() -- Make a trace entry in the in-memory trace +** +** DESCRIPTION: +** PR_Trace() makes an entry in the in-memory trace buffer for +** the referenced trace handle. The next logically available +** PRTraceEntry is used; when the next trace entry would overflow +** the trace table, the table wraps. +** +** PR_Trace() for a specific trace handle may be disabled by +** calling PR_SetTraceOption() specifying PRTraceDisable for the +** trace handle to be disabled. +** +** INPUTS: +** handle: PRTraceHandle. The trace handle for this trace. +** +** userData[0..7]: unsigned 32bit integers. user supplied data +** that is copied into the PRTraceEntry +** +** OUTPUTS: +** A PRTraceEntry is (conditionally) formatted in the in-memory +** trace buffer. +** +** RETURNS: void. +** +** RESTRICTIONS: +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7)\ + PR_Trace((handle),(ud0),(ud1),(ud2),(ud3),(ud4),(ud5),(ud6),(ud7)) +#else +#define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7) +#endif + +NSPR_API(void) +PR_Trace( + PRTraceHandle handle, /* use this trace handle */ + PRUint32 userData0, /* User supplied data word 0 */ + PRUint32 userData1, /* User supplied data word 1 */ + PRUint32 userData2, /* User supplied data word 2 */ + PRUint32 userData3, /* User supplied data word 3 */ + PRUint32 userData4, /* User supplied data word 4 */ + PRUint32 userData5, /* User supplied data word 5 */ + PRUint32 userData6, /* User supplied data word 6 */ + PRUint32 userData7 /* User supplied data word 7 */ +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_SetTraceOption() -- Control the Trace Facility +** +** DESCRIPTION: +** PR_SetTraceOption() controls the Trace Facility. Depending on +** command and value, attributes of the Trace Facility may be +** changed. +** +** INPUTS: +** command: An enumerated value in the set of PRTraceOption. +** value: pointer to the data to be set. Type of the data is +** dependent on command; for each value of command, the type +** and meaning of dereferenced value is shown. +** +** PRTraceBufSize: unsigned long: the size of the trace buffer, +** in bytes. +** +** PRTraceEnable: PRTraceHandle. The trace handle to be +** enabled. +** +** PRTraceDisable: PRTraceHandle. The trace handle to be +** disabled. +** +** PRTraceSuspend: void. value must be NULL. All tracing is +** suspended. +** +** PRTraceResume: void. value must be NULL. Tracing for all +** previously enabled, prior to a PRTraceSuspend, is resumed. +** +** PRTraceStopRecording: void. value must be NULL. If recording +** (see: ** PR_RecordTraceEntries()) is being done, +** PRTraceStopRecording causes PR_RecordTraceEntries() to return +** to its caller. If recording is not being done, this function +** has no effect. +** +** PRTraceSuspendRecording: void. Must be NULL. If recording is +** being done, PRTraceSuspendRecording causes further writes to +** the trace file to be suspended. Data in the in-memory +** trace buffer that would ordinarily be written to the +** trace file will not be written. Trace entries will continue +** to be entered in the in-memory buffer. If the Trace Facility +** recording is already in a suspended state, the call has no +** effect. +** +** PRTraceResumeRecording: void. value must be NULL. If +** recording for the Trace Facility has been previously been +** suspended, this causes recording to resume. Recording resumes +** with the next in-memory buffer segment that would be written +** if trace recording had not been suspended. If recording is +** not currently suspended, the call has no effect. +** +** PRTraceLockHandles: void. value must be NULL. Locks the +** trace handle lock. While the trace handle lock is held, +** calls to PR_CreateTrace() will block until the lock is +** released. +** +** PRTraceUnlockHandles: void. value must be NULL. Unlocks the +** trace handle lock. +** +** OUTPUTS: +** The operation of the Trace Facility may be changed. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_SET_TRACE_OPTION(command,value)\ + PR_SetTraceOption((command),(value)) +#else +#define PR_SET_TRACE_OPTION(command,value) +#endif + +NSPR_API(void) +PR_SetTraceOption( + PRTraceOption command, /* One of the enumerated values */ + void *value /* command value or NULL */ +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_GetTraceOption() -- Retrieve settings from the Trace Facility +** +** DESCRIPTION: +** PR_GetTraceOption() retrieves the current setting of the +** Trace Facility control depending on command. +** +** +** PRTraceBufSize: unsigned long: the size of the trace buffer, +** in bytes. +** +** +** INPUTS: +** command: one of the enumerated values in PRTraceOptions +** valid for PR_GetTraceOption(). +** +** OUTPUTS: +** dependent on command. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_GET_TRACE_OPTION(command,value)\ + PR_GetTraceOption((command),(value)) +#else +#define PR_GET_TRACE_OPTION(command,value) +#endif + +NSPR_API(void) +PR_GetTraceOption( + PRTraceOption command, /* One of the enumerated values */ + void *value /* command value or NULL */ +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_GetTraceHandleFromName() -- Retrieve an existing +** handle by name. +** +** DESCRIPTION: +** PR_GetTraceHandleFromName() retreives an existing tracehandle +** using the name specified by qName and rName. +** +** INPUTS: +** qName: pointer to string. QName for this trace handle. +** +** rName: pointer to string. RName for this trace handle. +** +** +** OUTPUTS: returned. +** +** RETURNS: +** PRTraceHandle associated with qName and rName or NULL when +** there is no match. +** +** RESTRICTIONS: +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName)\ + (handle) = PR_GetTraceHandleFromName((qName),(rName)) +#else +#define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName) +#endif + +NSPR_API(PRTraceHandle) +PR_GetTraceHandleFromName( + const char *qName, /* QName search argument */ + const char *rName /* RName search argument */ +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_GetTraceNameFromHandle() -- Retreive trace name +** by bandle. +** +** DESCRIPTION: +** PR_GetTraceNameFromHandle() retreives the existing qName, +** rName, and description for the referenced trace handle. +** +** INPUTS: handle: PRTraceHandle. +** +** OUTPUTS: pointers to the Trace Facility's copy of qName, +** rName and description. ... Don't mess with these values. +** They're mine. +** +** RETURNS: void +** +** RESTRICTIONS: +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description)\ + PR_GetTraceNameFromHandle((handle),(qName),(rName),(description)) +#else +#define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description) +#endif + +NSPR_API(void) +PR_GetTraceNameFromHandle( + PRTraceHandle handle, /* handle as search argument */ + const char **qName, /* pointer to associated QName */ + const char **rName, /* pointer to associated RName */ + const char **description /* pointer to associated description */ +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_FindNextTraceQname() -- Retrieive a QName handle +** iterator. +** +** DESCRIPTION: +** PR_FindNextTraceQname() retreives the first or next trace +** QName handle, depending on the value of handle, from the trace +** database. The PRTraceHandle returned can be used as an +** iterator to traverse the QName handles in the Trace database. +** +** INPUTS: +** handle: When NULL, PR_FindNextQname() returns the first QName +** handle. When a handle is a valid PRTraceHandle previously +** retreived using PR_FindNextQname() the next QName handle is +** retreived. +** +** OUTPUTS: returned. +** +** RETURNS: +** PRTraceHandle or NULL when there are no trace handles. +** +** RESTRICTIONS: +** Iterating thru the trace handles via FindFirst/FindNext +** should be done under protection of the trace handle lock. +** See: PR_SetTraceOption( PRLockTraceHandles ). +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_FIND_NEXT_TRACE_QNAME(next,handle)\ + (next) = PR_FindNextTraceQname((handle)) +#else +#define PR_FIND_NEXT_TRACE_QNAME(next,handle) +#endif + +NSPR_API(PRTraceHandle) +PR_FindNextTraceQname( + PRTraceHandle handle +); + + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_FindNextTraceRname() -- Retrieive an RName handle +** iterator. +** +** DESCRIPTION: +** PR_FindNextTraceRname() retreives the first or next trace +** RName handle, depending on the value of handle, from the trace +** database. The PRTraceHandle returned can be used as an +** iterator to traverse the RName handles in the Trace database. +** +** INPUTS: +** rhandle: When NULL, PR_FindNextRname() returns the first +** RName handle. When a handle is a valid PRTraceHandle +** previously retreived using PR_FindNextRname() the next RName +** handle is retreived. +** qhandle: A valid PRTraceHandle retruned from a previous call +** to PR_FIND_NEXT_TRACE_QNAME(). +** +** OUTPUTS: returned. +** +** RETURNS: +** PRTraceHandle or NULL when there are no trace handles. +** +** RESTRICTIONS: +** Iterating thru the trace handles via FindNext should be done +** under protection of the trace handle lock. See: ( +** PR_SetTraceOption( PRLockTraceHandles ). +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle)\ + (next) = PR_FindNextTraceRname((rhandle),(qhandle)) +#else +#define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle) +#endif + +NSPR_API(PRTraceHandle) +PR_FindNextTraceRname( + PRTraceHandle rhandle, + PRTraceHandle qhandle +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_RecordTraceEntries() -- Write trace entries to external media +** +** DESCRIPTION: +** PR_RecordTraceEntries() causes entries in the in-memory trace +** buffer to be written to external media. +** +** When PR_RecordTraceEntries() is called from an application +** thread, the function appears to block until another thread +** calls PR_SetTraceOption() with the PRTraceStopRecording +** option. This suggests that PR_RecordTraceEntries() should be +** called from a user supplied thread whose only job is to +** record trace entries. +** +** The environment variable NSPR_TRACE_LOG controls the operation +** of this function. When NSPR_TRACE_LOG is not defined in the +** environment, no recording of trace entries occurs. When +** NSPR_TRACE_LOG is defined, the value of its definition must be +** the filename of the file to receive the trace entry buffer. +** +** PR_RecordTraceEntries() attempts to record the in-memory +** buffer to a file, subject to the setting of the environment +** variable NSPR_TRACE_LOG. It is possible because of system +** load, the thread priority of the recording thread, number of +** active trace records being written over time, and other +** variables that some trace records can be lost. ... In other +** words: don't bet the farm on getting everything. +** +** INPUTS: none +** +** OUTPUTS: none +** +** RETURNS: PR_STATUS +** PR_SUCCESS no errors were found. +** PR_FAILURE errors were found. +** +** RESTRICTIONS: +** Only one thread can call PR_RecordTraceEntries() within a +** process. +** +** On error, PR_RecordTraceEntries() may return prematurely. +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_RECORD_TRACE_ENTRIES()\ + PR_RecordTraceEntries() +#else +#define PR_RECORD_TRACE_ENTRIES() +#endif + +NSPR_API(void) +PR_RecordTraceEntries( + void +); + +/* ----------------------------------------------------------------------- +** FUNCTION: PR_GetTraceEntries() -- Retreive trace entries from +** the Trace Facility +** +** DESCRIPTION: +** PR_GetTraceEntries() retreives trace entries from the Trace +** Facility. Up to count trace entries are copied from the Trace +** Facility into buffer. Only those trace entries that have not +** been copied via a previous call to PR_GetTraceEntries() are +** copied. The actual number copied is placed in the PRInt32 +** variable pointed to by found. +** +** If more than count trace entries have entered the Trace +** Facility since the last call to PR_GetTraceEntries() +** a lost data condition is returned. In this case, the most +** recent count trace entries are copied into buffer and found is +** set to count. +** +** INPUTS: +** count. The number of trace entries to be copied into buffer. +** +** +** OUTPUTS: +** buffer. An array of PRTraceEntries. The buffer is supplied +** by the caller. +** +** found: 32bit signed integer. The number of PRTraceEntries +** actually copied. found is always less than or equal to count. +** +** RETURNS: +** zero when there is no lost data. +** non-zero when some PRTraceEntries have been lost. +** +** RESTRICTIONS: +** This is a real performance pig. The copy out operation is bad +** enough, but depending on then frequency of calls to the +** function, serious performance impact to the operating +** application may be realized. ... YMMV. +** +*/ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) +#define PR_GET_TRACE_ENTRIES(buffer,count,found)\ + PR_GetTraceEntries((buffer),(count),(found)) +#else +#define PR_GET_TRACE_ENTRIES(buffer,count,found) +#endif + +NSPR_API(PRIntn) +PR_GetTraceEntries( + PRTraceEntry *buffer, /* where to write output */ + PRInt32 count, /* number to get */ + PRInt32 *found /* number you got */ +); + +PR_END_EXTERN_C + +#endif /* prtrace_h___ */ + diff --git a/illumos-x86_64/usr/include/mps/prtypes.h b/illumos-x86_64/usr/include/mps/prtypes.h new file mode 100644 index 00000000..b81df408 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prtypes.h @@ -0,0 +1,559 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: prtypes.h +** Description: Definitions of NSPR's basic types +** +** Prototypes and macros used to make up for deficiencies that we have found +** in ANSI environments. +** +** Since we do not wrap and all the other standard headers, authors +** of portable code will not know in general that they need these definitions. +** Instead of requiring these authors to find the dependent uses in their code +** and take the following steps only in those C files, we take steps once here +** for all C files. +**/ + +#ifndef prtypes_h___ +#define prtypes_h___ + +#ifdef MDCPUCFG +#include MDCPUCFG +#else +#include "prcpucfg.h" +#endif + +#include + +/*********************************************************************** +** MACROS: PR_EXTERN +** PR_IMPLEMENT +** DESCRIPTION: +** These are only for externally visible routines and globals. For +** internal routines, just use "extern" for type checking and that +** will not export internal cross-file or forward-declared symbols. +** Define a macro for declaring procedures return types. We use this to +** deal with windoze specific type hackery for DLL definitions. Use +** PR_EXTERN when the prototype for the method is declared. Use +** PR_IMPLEMENT for the implementation of the method. +** +** Example: +** in dowhim.h +** PR_EXTERN( void ) DoWhatIMean( void ); +** in dowhim.c +** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; } +** +** +***********************************************************************/ +#if defined(WIN32) + +#define PR_EXPORT(__type) extern __declspec(dllexport) __type +#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPORT(__type) __declspec(dllimport) __type +#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type + +#define PR_EXTERN(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT(__type) __declspec(dllexport) __type +#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type + +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + +#elif defined(__declspec) + +#define PR_EXPORT(__type) extern __declspec(dllexport) __type +#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPORT(__type) extern __declspec(dllimport) __type +#define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type + +#define PR_EXTERN(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT(__type) __declspec(dllexport) __type +#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type + +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + +#else /* Unix */ + +/* GCC 3.3 and later support the visibility attribute. */ +#if (__GNUC__ >= 4) || \ + (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) +#define PR_VISIBILITY_DEFAULT __attribute__((visibility("default"))) +#else +#define PR_VISIBILITY_DEFAULT +#endif + +#define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type + +#define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type +#define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + +#endif + +#if defined(_NSPR_BUILD_) +#define NSPR_API(__type) PR_EXPORT(__type) +#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type) +#else +#define NSPR_API(__type) PR_IMPORT(__type) +#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type) +#endif + +/*********************************************************************** +** MACROS: PR_BEGIN_MACRO +** PR_END_MACRO +** DESCRIPTION: +** Macro body brackets so that macros with compound statement definitions +** behave syntactically more like functions when called. +***********************************************************************/ +#define PR_BEGIN_MACRO do { +#define PR_END_MACRO } while (0) + +/*********************************************************************** +** MACROS: PR_BEGIN_EXTERN_C +** PR_END_EXTERN_C +** DESCRIPTION: +** Macro shorthands for conditional C++ extern block delimiters. +***********************************************************************/ +#ifdef __cplusplus +#define PR_BEGIN_EXTERN_C extern "C" { +#define PR_END_EXTERN_C } +#else +#define PR_BEGIN_EXTERN_C +#define PR_END_EXTERN_C +#endif + +/*********************************************************************** +** MACROS: PR_BIT +** PR_BITMASK +** DESCRIPTION: +** Bit masking macros. XXX n must be <= 31 to be portable +***********************************************************************/ +#define PR_BIT(n) ((PRUint32)1 << (n)) +#define PR_BITMASK(n) (PR_BIT(n) - 1) + +/*********************************************************************** +** MACROS: PR_ROUNDUP +** PR_MIN +** PR_MAX +** PR_ABS +** DESCRIPTION: +** Commonly used macros for operations on compatible types. +***********************************************************************/ +#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y)) +#define PR_MIN(x,y) ((x)<(y)?(x):(y)) +#define PR_MAX(x,y) ((x)>(y)?(x):(y)) +#define PR_ABS(x) ((x)<0?-(x):(x)) + +/*********************************************************************** +** MACROS: PR_ARRAY_SIZE +** DESCRIPTION: +** The number of elements in an array. +***********************************************************************/ +#define PR_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) + +PR_BEGIN_EXTERN_C + +/* +** Starting in NSPR 4.9.5, NSPR's exact-width integer types should match +** the exact-width integer types defined in . This allows sloppy +** code to use PRInt{N} and int{N}_t interchangeably. +** +** The 8-bit and 16-bit integer types can only be defined using char and +** short. All platforms define the 32-bit integer types using int. So only +** the 64-bit integer types could be defined differently. +** +** NSPR's original strategy was to use the "shortest" 64-bit integer type: +** if long is 64-bit, then prefer it over long long. This strategy is also +** used by Linux/glibc, FreeBSD, and NetBSD. +** +** Other platforms use a different strategy: simply define the 64-bit +** integer types using long long. We define the PR_ALTERNATE_INT64_TYPEDEF +** macro on these platforms. Note that PR_ALTERNATE_INT64_TYPEDEF is for +** internal use by NSPR headers only. Do not define or test this macro in +** your code. +** +** NOTE: NSPR can't use because C99 requires C++ code to define +** __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS to make all the macros +** defined in available. This strange requirement is gone in +** C11. When most platforms ignore this C99 requirement, NSPR will be able +** to use . A patch to do that is in NSPR bug 634793. +*/ + +#if defined(__APPLE__) || defined(__OpenBSD__) +#define PR_ALTERNATE_INT64_TYPEDEF +#endif + +/************************************************************************ +** TYPES: PRUint8 +** PRInt8 +** DESCRIPTION: +** The int8 types are known to be 8 bits each. There is no type that +** is equivalent to a plain "char". +************************************************************************/ +#if PR_BYTES_PER_BYTE == 1 +typedef unsigned char PRUint8; +/* +** There are two scenarios that require us to define PRInt8 as type 'char'. +** (1) +** Some cfront-based C++ compilers do not like 'signed char' and +** issue the warning message: +** warning: "signed" not implemented (ignored) +** For these compilers, we have to define PRInt8 as plain 'char'. +** Make sure that plain 'char' is indeed signed under these compilers. +** (2) +** Mozilla C++ code expects the PRInt{N} and int{N}_t types to match (see bug +** 634793). If a platform defines int8_t as 'char', but NSPR defines it as +** 'signed char', it results in a type mismatch. +** On such platforms we define PRInt8 as 'char' to avoid the mismatch. +*/ +#if (defined(HPUX) && defined(__cplusplus) /* reason 1*/ \ + && !defined(__GNUC__) && __cplusplus < 199707L) \ + || (defined(__sun) && defined(__cplusplus)) /* reason 2 */ +typedef char PRInt8; +#else +typedef signed char PRInt8; +#endif +#else +#error No suitable type for PRInt8/PRUint8 +#endif + +/************************************************************************ + * MACROS: PR_INT8_MAX + * PR_INT8_MIN + * PR_UINT8_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt8 or PRUint8. +************************************************************************/ + +#define PR_INT8_MAX 127 +#define PR_INT8_MIN (-128) +#define PR_UINT8_MAX 255U + +/************************************************************************ +** TYPES: PRUint16 +** PRInt16 +** DESCRIPTION: +** The int16 types are known to be 16 bits each. +************************************************************************/ +#if PR_BYTES_PER_SHORT == 2 +typedef unsigned short PRUint16; +typedef short PRInt16; +#else +#error No suitable type for PRInt16/PRUint16 +#endif + +/************************************************************************ + * MACROS: PR_INT16_MAX + * PR_INT16_MIN + * PR_UINT16_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt16 or PRUint16. +************************************************************************/ + +#define PR_INT16_MAX 32767 +#define PR_INT16_MIN (-32768) +#define PR_UINT16_MAX 65535U + +/************************************************************************ +** TYPES: PRUint32 +** PRInt32 +** DESCRIPTION: +** The int32 types are known to be 32 bits each. +************************************************************************/ +#if PR_BYTES_PER_INT == 4 +typedef unsigned int PRUint32; +typedef int PRInt32; +#define PR_INT32(x) x +#define PR_UINT32(x) x ## U +#elif PR_BYTES_PER_LONG == 4 +typedef unsigned long PRUint32; +typedef long PRInt32; +#define PR_INT32(x) x ## L +#define PR_UINT32(x) x ## UL +#else +#error No suitable type for PRInt32/PRUint32 +#endif + +/************************************************************************ + * MACROS: PR_INT32_MAX + * PR_INT32_MIN + * PR_UINT32_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt32 or PRUint32. +************************************************************************/ + +#define PR_INT32_MAX PR_INT32(2147483647) +#define PR_INT32_MIN (-PR_INT32_MAX - 1) +#define PR_UINT32_MAX PR_UINT32(4294967295) + +/************************************************************************ +** TYPES: PRUint64 +** PRInt64 +** DESCRIPTION: +** The int64 types are known to be 64 bits each. Care must be used when +** declaring variables of type PRUint64 or PRInt64. Different hardware +** architectures and even different compilers have varying support for +** 64 bit values. The only guaranteed portability requires the use of +** the LL_ macros (see prlong.h). +** +** MACROS: PR_INT64 +** PR_UINT64 +** DESCRIPTION: +** The PR_INT64 and PR_UINT64 macros provide a portable way for +** specifying 64-bit integer constants. They can only be used if +** PRInt64 and PRUint64 are defined as compiler-supported 64-bit +** integer types (i.e., if HAVE_LONG_LONG is defined, which is true +** for all the supported compilers topday). If PRInt64 and PRUint64 +** are defined as structs, the LL_INIT macro defined in prlong.h has +** to be used. +** +** MACROS: PR_INT64_MAX +** PR_INT64_MIN +** PR_UINT64_MAX +** DESCRIPTION: +** The maximum and minimum values of a PRInt64 or PRUint64. +************************************************************************/ +#ifdef HAVE_LONG_LONG +/* Keep this in sync with prlong.h. */ +#if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF) +typedef long PRInt64; +typedef unsigned long PRUint64; +#define PR_INT64(x) x ## L +#define PR_UINT64(x) x ## UL +#elif defined(WIN32) && !defined(__GNUC__) +typedef __int64 PRInt64; +typedef unsigned __int64 PRUint64; +#define PR_INT64(x) x ## i64 +#define PR_UINT64(x) x ## ui64 +#else +typedef long long PRInt64; +typedef unsigned long long PRUint64; +#define PR_INT64(x) x ## LL +#define PR_UINT64(x) x ## ULL +#endif /* PR_BYTES_PER_LONG == 8 */ + +#define PR_INT64_MAX PR_INT64(0x7fffffffffffffff) +#define PR_INT64_MIN (-PR_INT64_MAX - 1) +#define PR_UINT64_MAX PR_UINT64(-1) +#else /* !HAVE_LONG_LONG */ +typedef struct { +#ifdef IS_LITTLE_ENDIAN + PRUint32 lo, hi; +#else + PRUint32 hi, lo; +#endif +} PRInt64; +typedef PRInt64 PRUint64; + +#define PR_INT64_MAX (PRInt64){0x7fffffff, 0xffffffff} +#define PR_INT64_MIN (PRInt64){0xffffffff, 0xffffffff} +#define PR_UINT64_MAX (PRUint64){0xffffffff, 0xffffffff} + +#endif /* !HAVE_LONG_LONG */ + +/************************************************************************ +** TYPES: PRUintn +** PRIntn +** DESCRIPTION: +** The PRIntn types are most appropriate for automatic variables. They are +** guaranteed to be at least 16 bits, though various architectures may +** define them to be wider (e.g., 32 or even 64 bits). These types are +** never valid for fields of a structure. +************************************************************************/ +#if PR_BYTES_PER_INT >= 2 +typedef int PRIntn; +typedef unsigned int PRUintn; +#else +#error 'sizeof(int)' not sufficient for platform use +#endif + +/************************************************************************ +** TYPES: PRFloat64 +** DESCRIPTION: +** NSPR's floating point type is always 64 bits. +************************************************************************/ +typedef double PRFloat64; + +/************************************************************************ +** TYPES: PRSize +** DESCRIPTION: +** A type for representing the size of objects. +************************************************************************/ +typedef size_t PRSize; + + +/************************************************************************ +** TYPES: PROffset32, PROffset64 +** DESCRIPTION: +** A type for representing byte offsets from some location. +************************************************************************/ +typedef PRInt32 PROffset32; +typedef PRInt64 PROffset64; + +/************************************************************************ +** TYPES: PRPtrDiff +** DESCRIPTION: +** A type for pointer difference. Variables of this type are suitable +** for storing a pointer or pointer subtraction. +************************************************************************/ +typedef ptrdiff_t PRPtrdiff; + +/************************************************************************ +** TYPES: PRUptrdiff +** DESCRIPTION: +** A type for pointer difference. Variables of this type are suitable +** for storing a pointer or pointer sutraction. +************************************************************************/ +#ifdef _WIN64 +typedef PRUint64 PRUptrdiff; +#else +typedef unsigned long PRUptrdiff; +#endif + +/************************************************************************ +** TYPES: PRBool +** DESCRIPTION: +** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE +** for clarity of target type in assignments and actual arguments. Use +** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans +** just as you would C int-valued conditions. +************************************************************************/ +typedef PRIntn PRBool; +#define PR_TRUE 1 +#define PR_FALSE 0 + +/************************************************************************ +** TYPES: PRPackedBool +** DESCRIPTION: +** Use PRPackedBool within structs where bitfields are not desirable +** but minimum and consistant overhead matters. +************************************************************************/ +typedef PRUint8 PRPackedBool; + +/* +** Status code used by some routines that have a single point of failure or +** special status return. +*/ +typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus; + +#ifndef __PRUNICHAR__ +#define __PRUNICHAR__ +#ifdef WIN32 +typedef wchar_t PRUnichar; +#else +typedef PRUint16 PRUnichar; +#endif +#endif + +/* +** WARNING: The undocumented data types PRWord and PRUword are +** only used in the garbage collection and arena code. Do not +** use PRWord and PRUword in new code. +** +** A PRWord is an integer that is the same size as a void*. +** It implements the notion of a "word" in the Java Virtual +** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine +** Specification, Addison-Wesley, September 1996. +** http://java.sun.com/docs/books/vmspec/index.html.) +*/ +#ifdef _WIN64 +typedef PRInt64 PRWord; +typedef PRUint64 PRUword; +#else +typedef long PRWord; +typedef unsigned long PRUword; +#endif + +/* + * PR_PRETEND_NORETURN, specified at the end of a function declaration, + * indicates that for the purposes of static analysis, this function does not + * return. (The function definition does not need to be annotated.) + * + * void PR_Assert(const char *s, const char *file, PRIntn ln) + * PR_PRETEND_NORETURN; + * + * Some static analyzers, like scan-build from clang, can use this information + * to eliminate false positives. From the upstream documentation of + * scan-build: + * This attribute is useful for annotating assertion handlers that actually + * can return, but for the purpose of using the analyzer we want to pretend + * that such functions do not return. + */ +#ifdef __clang_analyzer__ +#if __has_extension(attribute_analyzer_noreturn) +#define PR_PRETEND_NORETURN __attribute__((analyzer_noreturn)) +#endif +#endif + +#ifndef PR_PRETEND_NORETURN +#define PR_PRETEND_NORETURN /* no support */ +#endif + +#if defined(NO_NSPR_10_SUPPORT) +#else +/********* ???????????????? FIX ME ??????????????????????????? *****/ +/********************** Some old definitions until pr=>ds transition is done ***/ +/********************** Also, we are still using NSPR 1.0. GC ******************/ +/* +** Fundamental NSPR macros, used nearly everywhere. +*/ + +#define PR_PUBLIC_API PR_IMPLEMENT + +/* +** Macro body brackets so that macros with compound statement definitions +** behave syntactically more like functions when called. +*/ +#define NSPR_BEGIN_MACRO do { +#define NSPR_END_MACRO } while (0) + +/* +** Macro shorthands for conditional C++ extern block delimiters. +*/ +#ifdef NSPR_BEGIN_EXTERN_C +#undef NSPR_BEGIN_EXTERN_C +#endif +#ifdef NSPR_END_EXTERN_C +#undef NSPR_END_EXTERN_C +#endif + +#ifdef __cplusplus +#define NSPR_BEGIN_EXTERN_C extern "C" { +#define NSPR_END_EXTERN_C } +#else +#define NSPR_BEGIN_EXTERN_C +#define NSPR_END_EXTERN_C +#endif + +#include "obsolete/protypes.h" + +/********* ????????????? End Fix me ?????????????????????????????? *****/ +#endif /* NO_NSPR_10_SUPPORT */ + +/* +** Compile-time assert. "condition" must be a constant expression. +** The macro can be used only in places where an "extern" declaration is +** allowed. +*/ +#define PR_STATIC_ASSERT(condition) \ + extern void pr_static_assert(int arg[(condition) ? 1 : -1]) + +PR_END_EXTERN_C + +#endif /* prtypes_h___ */ + diff --git a/illumos-x86_64/usr/include/mps/prvrsion.h b/illumos-x86_64/usr/include/mps/prvrsion.h new file mode 100644 index 00000000..99ed1db6 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/prvrsion.h @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/* author: jstewart */ + +#if defined(_PRVERSION_H) +#else +#define _PRVERSION_H + +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + +/* All components participating in the PR version protocol must expose + * a structure and a function. The structure is defined below and named + * according to the naming conventions outlined further below. The function + * is called libVersionPoint and returns a pointer to this structure. + */ + +/* on NT, always pack the structure the same. */ +#ifdef _WIN32 +#pragma pack(push, 8) +#endif + +typedef struct { + /* + * The first field defines which version of this structure is in use. + * At this time, only version 2 is specified. If this value is not + * 2, you must read no further into the structure. + */ + PRInt32 version; + + /* for Version 2, this is the body format. */ + PRInt64 buildTime; /* 64 bits - usecs since midnight, 1/1/1970 */ + char * buildTimeString;/* a human readable version of the time */ + + PRUint8 vMajor; /* Major version of this component */ + PRUint8 vMinor; /* Minor version of this component */ + PRUint8 vPatch; /* Patch level of this component */ + + PRBool beta; /* true if this is a beta component */ + PRBool debug; /* true if this is a debug component */ + PRBool special; /* true if this component is a special build */ + + char * filename; /* The original filename */ + char * description; /* description of this component */ + char * security; /* level of security in this component */ + char * copyright; /* The copyright for this file */ + char * comment; /* free form field for misc usage */ + char * specialString; /* the special variant for this build */ +} PRVersionDescription; + +/* on NT, restore the previous packing */ +#ifdef _WIN32 +#pragma pack(pop) +#endif + +/* + * All components must define an entrypoint named libVersionPoint which + * is of type versionEntryPointType. + * + * For example, for a library named libfoo, we would have: + * + * PRVersionDescription prVersionDescription_libfoo = + * { + * ... + * }; + * + * PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void) + * { + * return &prVersionDescription_libfoo; + * } + */ +typedef const PRVersionDescription *(*versionEntryPointType)(void); + +/* + * Where you declare your libVersionPoint, do it like this: + * PR_IMPLEMENT(const PRVersionDescription *) libVersionPoint(void) { + * fill it in... + * } + */ + +/* + * NAMING CONVENTION FOR struct + * + * all components should also expose a static PRVersionDescription + * The name of the struct should be calculated as follows: + * Take the value of filename. (If filename is not specified, calculate + * a short, unique string.) Convert all non-alphanumeric characters + * to '_'. To this, prepend "PRVersionDescription_". Thus for libfoo.so, + * the symbol name is "PRVersionDescription_libfoo_so". + * so the file should have + * PRVersionDescription PRVersionDescription_libfoo_so { fill it in }; + * on NT, this file should be declspec export. + */ + +PR_END_EXTERN_C + +#endif /* defined(_PRVERSION_H) */ + +/* prvrsion.h */ + diff --git a/illumos-x86_64/usr/include/mps/secasn1.h b/illumos-x86_64/usr/include/mps/secasn1.h new file mode 100644 index 00000000..d02cdabe --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secasn1.h @@ -0,0 +1,303 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Support for encoding/decoding of ASN.1 using BER/DER (Basic/Distinguished + * Encoding Rules). The routines are found in and used extensively by the + * security library, but exported for other use. + */ + +#ifndef _SECASN1_H_ +#define _SECASN1_H_ + +#include "utilrename.h" +#include "plarena.h" + +#include "seccomon.h" +#include "secasn1t.h" + +/************************************************************************/ +SEC_BEGIN_PROTOS + +/* + * XXX These function prototypes need full, explanatory comments. + */ + +/* +** Decoding. +*/ + +extern SEC_ASN1DecoderContext *SEC_ASN1DecoderStart(PLArenaPool *pool, + void *dest, + const SEC_ASN1Template *t); + +/* XXX char or unsigned char? */ +extern SECStatus SEC_ASN1DecoderUpdate(SEC_ASN1DecoderContext *cx, + const char *buf, + unsigned long len); + +extern SECStatus SEC_ASN1DecoderFinish(SEC_ASN1DecoderContext *cx); + +/* Higher level code detected an error, abort the rest of the processing */ +extern void SEC_ASN1DecoderAbort(SEC_ASN1DecoderContext *cx, int error); + +extern void SEC_ASN1DecoderSetFilterProc(SEC_ASN1DecoderContext *cx, + SEC_ASN1WriteProc fn, + void *arg, PRBool no_store); + +extern void SEC_ASN1DecoderClearFilterProc(SEC_ASN1DecoderContext *cx); + +extern void SEC_ASN1DecoderSetNotifyProc(SEC_ASN1DecoderContext *cx, + SEC_ASN1NotifyProc fn, + void *arg); + +extern void SEC_ASN1DecoderClearNotifyProc(SEC_ASN1DecoderContext *cx); + +/* Sets the maximum size that should be allocated for a single ASN.1 + * element. Set to 0 to indicate there is no limit. + * + * Note: This does not set the maximum size overall that may be allocated + * while parsing, nor does it guarantee that the decoder won't allocate + * more than |max_size| while parsing an individual element; rather, it + * merely guarantees that any individual allocation for returned data + * should not exceed |max_size|. + */ +extern void SEC_ASN1DecoderSetMaximumElementSize(SEC_ASN1DecoderContext *cx, + unsigned long max_size); + +extern SECStatus SEC_ASN1Decode(PLArenaPool *pool, void *dest, + const SEC_ASN1Template *t, + const char *buf, long len); + +/* Both classic ASN.1 and QuickDER have a feature that removes leading zeroes + out of SEC_ASN1_INTEGER if the caller sets siUnsignedInteger in the type + field of the target SECItem prior to calling the decoder. Otherwise, the + type field is ignored and untouched. For SECItem that are dynamically + allocated (from POINTER, SET OF, SEQUENCE OF) the decoder sets the type + field to siBuffer. */ + +extern SECStatus SEC_ASN1DecodeItem(PLArenaPool *pool, void *dest, + const SEC_ASN1Template *t, + const SECItem *src); + +extern SECStatus SEC_QuickDERDecodeItem(PLArenaPool *arena, void *dest, + const SEC_ASN1Template *templateEntry, + const SECItem *src); + +/* +** Encoding. +*/ + +extern SEC_ASN1EncoderContext *SEC_ASN1EncoderStart(const void *src, + const SEC_ASN1Template *t, + SEC_ASN1WriteProc fn, + void *output_arg); + +/* XXX char or unsigned char? */ +extern SECStatus SEC_ASN1EncoderUpdate(SEC_ASN1EncoderContext *cx, + const char *buf, + unsigned long len); + +extern void SEC_ASN1EncoderFinish(SEC_ASN1EncoderContext *cx); + +/* Higher level code detected an error, abort the rest of the processing */ +extern void SEC_ASN1EncoderAbort(SEC_ASN1EncoderContext *cx, int error); + +extern void SEC_ASN1EncoderSetNotifyProc(SEC_ASN1EncoderContext *cx, + SEC_ASN1NotifyProc fn, + void *arg); + +extern void SEC_ASN1EncoderClearNotifyProc(SEC_ASN1EncoderContext *cx); + +extern void SEC_ASN1EncoderSetStreaming(SEC_ASN1EncoderContext *cx); + +extern void SEC_ASN1EncoderClearStreaming(SEC_ASN1EncoderContext *cx); + +extern void sec_ASN1EncoderSetDER(SEC_ASN1EncoderContext *cx); + +extern void sec_ASN1EncoderClearDER(SEC_ASN1EncoderContext *cx); + +extern void SEC_ASN1EncoderSetTakeFromBuf(SEC_ASN1EncoderContext *cx); + +extern void SEC_ASN1EncoderClearTakeFromBuf(SEC_ASN1EncoderContext *cx); + +extern SECStatus SEC_ASN1Encode(const void *src, const SEC_ASN1Template *t, + SEC_ASN1WriteProc output_proc, + void *output_arg); + +/* + * If both pool and dest are NULL, the caller should free the returned SECItem + * with a SECITEM_FreeItem(..., PR_TRUE) call. If pool is NULL but dest is + * not NULL, the caller should free the data buffer pointed to by dest with a + * SECITEM_FreeItem(dest, PR_FALSE) or PORT_Free(dest->data) call. + */ +extern SECItem *SEC_ASN1EncodeItem(PLArenaPool *pool, SECItem *dest, + const void *src, const SEC_ASN1Template *t); + +extern SECItem *SEC_ASN1EncodeInteger(PLArenaPool *pool, + SECItem *dest, long value); + +extern SECItem *SEC_ASN1EncodeUnsignedInteger(PLArenaPool *pool, + SECItem *dest, + unsigned long value); + +extern SECStatus SEC_ASN1DecodeInteger(SECItem *src, + unsigned long *value); + +/* +** Utilities. +*/ + +/* + * We have a length that needs to be encoded; how many bytes will the + * encoding take? + */ +extern int SEC_ASN1LengthLength(unsigned long len); + +/* encode the length and return the number of bytes we encoded. Buffer + * must be pre allocated */ +extern int SEC_ASN1EncodeLength(unsigned char *buf, int value); + +/* + * Find the appropriate subtemplate for the given template. + * This may involve calling a "chooser" function, or it may just + * be right there. In either case, it is expected to *have* a + * subtemplate; this is asserted in debug builds (in non-debug + * builds, NULL will be returned). + * + * "thing" is a pointer to the structure being encoded/decoded + * "encoding", when true, means that we are in the process of encoding + * (as opposed to in the process of decoding) + */ +extern const SEC_ASN1Template * +SEC_ASN1GetSubtemplate(const SEC_ASN1Template *inTemplate, void *thing, + PRBool encoding); + +/* whether the template is for a primitive type or a choice of + * primitive types + */ +extern PRBool SEC_ASN1IsTemplateSimple(const SEC_ASN1Template *theTemplate); + +/************************************************************************/ + +/* + * Generic Templates + * One for each of the simple types, plus a special one for ANY, plus: + * - a pointer to each one of those + * - a set of each one of those + * - a sequence of each one of those + * + * Note that these are alphabetical (case insensitive); please add new + * ones in the appropriate place. + */ + +extern const SEC_ASN1Template SEC_AnyTemplate[]; +extern const SEC_ASN1Template SEC_BitStringTemplate[]; +extern const SEC_ASN1Template SEC_BMPStringTemplate[]; +extern const SEC_ASN1Template SEC_BooleanTemplate[]; +extern const SEC_ASN1Template SEC_EnumeratedTemplate[]; +extern const SEC_ASN1Template SEC_GeneralizedTimeTemplate[]; +extern const SEC_ASN1Template SEC_IA5StringTemplate[]; +extern const SEC_ASN1Template SEC_IntegerTemplate[]; +extern const SEC_ASN1Template SEC_NullTemplate[]; +extern const SEC_ASN1Template SEC_ObjectIDTemplate[]; +extern const SEC_ASN1Template SEC_OctetStringTemplate[]; +extern const SEC_ASN1Template SEC_PrintableStringTemplate[]; +extern const SEC_ASN1Template SEC_T61StringTemplate[]; +extern const SEC_ASN1Template SEC_UniversalStringTemplate[]; +extern const SEC_ASN1Template SEC_UTCTimeTemplate[]; +extern const SEC_ASN1Template SEC_UTF8StringTemplate[]; +extern const SEC_ASN1Template SEC_VisibleStringTemplate[]; + +extern const SEC_ASN1Template SEC_PointerToAnyTemplate[]; +extern const SEC_ASN1Template SEC_PointerToBitStringTemplate[]; +extern const SEC_ASN1Template SEC_PointerToBMPStringTemplate[]; +extern const SEC_ASN1Template SEC_PointerToBooleanTemplate[]; +extern const SEC_ASN1Template SEC_PointerToEnumeratedTemplate[]; +extern const SEC_ASN1Template SEC_PointerToGeneralizedTimeTemplate[]; +extern const SEC_ASN1Template SEC_PointerToIA5StringTemplate[]; +extern const SEC_ASN1Template SEC_PointerToIntegerTemplate[]; +extern const SEC_ASN1Template SEC_PointerToNullTemplate[]; +extern const SEC_ASN1Template SEC_PointerToObjectIDTemplate[]; +extern const SEC_ASN1Template SEC_PointerToOctetStringTemplate[]; +extern const SEC_ASN1Template SEC_PointerToPrintableStringTemplate[]; +extern const SEC_ASN1Template SEC_PointerToT61StringTemplate[]; +extern const SEC_ASN1Template SEC_PointerToUniversalStringTemplate[]; +extern const SEC_ASN1Template SEC_PointerToUTCTimeTemplate[]; +extern const SEC_ASN1Template SEC_PointerToUTF8StringTemplate[]; +extern const SEC_ASN1Template SEC_PointerToVisibleStringTemplate[]; + +extern const SEC_ASN1Template SEC_SequenceOfAnyTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfBitStringTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfBMPStringTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfBooleanTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfEnumeratedTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfGeneralizedTimeTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfIA5StringTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfIntegerTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfNullTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfObjectIDTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfOctetStringTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfPrintableStringTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfT61StringTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfUniversalStringTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfUTCTimeTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfUTF8StringTemplate[]; +extern const SEC_ASN1Template SEC_SequenceOfVisibleStringTemplate[]; + +extern const SEC_ASN1Template SEC_SetOfAnyTemplate[]; +extern const SEC_ASN1Template SEC_SetOfBitStringTemplate[]; +extern const SEC_ASN1Template SEC_SetOfBMPStringTemplate[]; +extern const SEC_ASN1Template SEC_SetOfBooleanTemplate[]; +extern const SEC_ASN1Template SEC_SetOfEnumeratedTemplate[]; +extern const SEC_ASN1Template SEC_SetOfGeneralizedTimeTemplate[]; +extern const SEC_ASN1Template SEC_SetOfIA5StringTemplate[]; +extern const SEC_ASN1Template SEC_SetOfIntegerTemplate[]; +extern const SEC_ASN1Template SEC_SetOfNullTemplate[]; +extern const SEC_ASN1Template SEC_SetOfObjectIDTemplate[]; +extern const SEC_ASN1Template SEC_SetOfOctetStringTemplate[]; +extern const SEC_ASN1Template SEC_SetOfPrintableStringTemplate[]; +extern const SEC_ASN1Template SEC_SetOfT61StringTemplate[]; +extern const SEC_ASN1Template SEC_SetOfUniversalStringTemplate[]; +extern const SEC_ASN1Template SEC_SetOfUTCTimeTemplate[]; +extern const SEC_ASN1Template SEC_SetOfUTF8StringTemplate[]; +extern const SEC_ASN1Template SEC_SetOfVisibleStringTemplate[]; + +/* + * Template for skipping a subitem; this only makes sense when decoding. + */ +extern const SEC_ASN1Template SEC_SkipTemplate[]; + +/* These functions simply return the address of the above-declared templates. +** This is necessary for Windows DLLs. Sigh. +*/ +SEC_ASN1_CHOOSER_DECLARE(SEC_AnyTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_BMPStringTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_BooleanTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_BitStringTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_GeneralizedTimeTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_IA5StringTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_IntegerTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_NullTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_ObjectIDTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_OctetStringTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_UTCTimeTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_UTF8StringTemplate) + +SEC_ASN1_CHOOSER_DECLARE(SEC_PointerToAnyTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_PointerToOctetStringTemplate) + +SEC_ASN1_CHOOSER_DECLARE(SEC_SetOfAnyTemplate) + +SEC_ASN1_CHOOSER_DECLARE(SEC_EnumeratedTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_PointerToEnumeratedTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_SequenceOfAnyTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_SequenceOfObjectIDTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_SkipTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_UniversalStringTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_PrintableStringTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_T61StringTemplate) +SEC_ASN1_CHOOSER_DECLARE(SEC_PointerToGeneralizedTimeTemplate) +SEC_END_PROTOS +#endif /* _SECASN1_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secasn1t.h b/illumos-x86_64/usr/include/mps/secasn1t.h new file mode 100644 index 00000000..0d1a6aea --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secasn1t.h @@ -0,0 +1,267 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Types for encoding/decoding of ASN.1 using BER/DER (Basic/Distinguished + * Encoding Rules). + */ + +#ifndef _SECASN1T_H_ +#define _SECASN1T_H_ + +#include "utilrename.h" + +/* +** An array of these structures defines a BER/DER encoding for an object. +** +** The array usually starts with a dummy entry whose kind is SEC_ASN1_SEQUENCE; +** such an array is terminated with an entry where kind == 0. (An array +** which consists of a single component does not require a second dummy +** entry -- the array is only searched as long as previous component(s) +** instruct it.) +*/ +typedef struct sec_ASN1Template_struct { + /* + ** Kind of item being decoded/encoded, including tags and modifiers. + */ + unsigned long kind; + + /* + ** The value is the offset from the base of the structure to the + ** field that holds the value being decoded/encoded. + */ + unsigned long offset; + + /* + ** When kind suggests it (SEC_ASN1_POINTER, SEC_ASN1_GROUP, SEC_ASN1_INLINE, + ** or a component that is *not* a SEC_ASN1_UNIVERSAL), this points to + ** a sub-template for nested encoding/decoding, + ** OR, iff SEC_ASN1_DYNAMIC is set, then this is a pointer to a pointer + ** to a function which will return the appropriate template when called + ** at runtime. NOTE! that explicit level of indirection, which is + ** necessary because ANSI does not allow you to store a function + ** pointer directly as a "void *" so we must store it separately and + ** dereference it to get at the function pointer itself. + */ + const void *sub; + + /* + ** In the first element of a template array, the value is the size + ** of the structure to allocate when this template is being referenced + ** by another template via SEC_ASN1_POINTER or SEC_ASN1_GROUP. + ** In all other cases, the value is ignored. + */ + unsigned int size; +} SEC_ASN1Template; + +/* default size used for allocation of encoding/decoding stuff */ +/* XXX what is the best value here? */ +#define SEC_ASN1_DEFAULT_ARENA_SIZE (2048) + +/* +** BER/DER values for ASN.1 identifier octets. +*/ +#define SEC_ASN1_TAG_MASK 0xff + +/* + * BER/DER universal type tag numbers. + * The values are defined by the X.208 standard; do not change them! + * NOTE: if you add anything to this list, you must add code to secasn1d.c + * to accept the tag, and probably also to secasn1e.c to encode it. + * XXX It appears some have been added recently without being added to + * the code; so need to go through the list now and double-check them all. + * (Look especially at those added in revision 1.10.) + */ +#define SEC_ASN1_TAGNUM_MASK 0x1f +#define SEC_ASN1_BOOLEAN 0x01 +#define SEC_ASN1_INTEGER 0x02 +#define SEC_ASN1_BIT_STRING 0x03 +#define SEC_ASN1_OCTET_STRING 0x04 +#define SEC_ASN1_NULL 0x05 +#define SEC_ASN1_OBJECT_ID 0x06 +#define SEC_ASN1_OBJECT_DESCRIPTOR 0x07 +/* External type and instance-of type 0x08 */ +#define SEC_ASN1_REAL 0x09 +#define SEC_ASN1_ENUMERATED 0x0a +#define SEC_ASN1_EMBEDDED_PDV 0x0b +#define SEC_ASN1_UTF8_STRING 0x0c +/* 0x0d */ +/* 0x0e */ +/* 0x0f */ +#define SEC_ASN1_SEQUENCE 0x10 +#define SEC_ASN1_SET 0x11 +#define SEC_ASN1_NUMERIC_STRING 0x12 +#define SEC_ASN1_PRINTABLE_STRING 0x13 +#define SEC_ASN1_T61_STRING 0x14 +#define SEC_ASN1_VIDEOTEX_STRING 0x15 +#define SEC_ASN1_IA5_STRING 0x16 +#define SEC_ASN1_UTC_TIME 0x17 +#define SEC_ASN1_GENERALIZED_TIME 0x18 +#define SEC_ASN1_GRAPHIC_STRING 0x19 +#define SEC_ASN1_VISIBLE_STRING 0x1a +#define SEC_ASN1_GENERAL_STRING 0x1b +#define SEC_ASN1_UNIVERSAL_STRING 0x1c +/* 0x1d */ +#define SEC_ASN1_BMP_STRING 0x1e +#define SEC_ASN1_HIGH_TAG_NUMBER 0x1f +#define SEC_ASN1_TELETEX_STRING SEC_ASN1_T61_STRING + +/* +** Modifiers to type tags. These are also specified by a/the +** standard, and must not be changed. +*/ + +#define SEC_ASN1_METHOD_MASK 0x20 +#define SEC_ASN1_PRIMITIVE 0x00 +#define SEC_ASN1_CONSTRUCTED 0x20 + +#define SEC_ASN1_CLASS_MASK 0xc0 +#define SEC_ASN1_UNIVERSAL 0x00 +#define SEC_ASN1_APPLICATION 0x40 +#define SEC_ASN1_CONTEXT_SPECIFIC 0x80 +#define SEC_ASN1_PRIVATE 0xc0 + +/* +** Our additions, used for templates. +** These are not defined by any standard; the values are used internally only. +** Just be careful to keep them out of the low 8 bits. +** XXX finish comments +*/ +#define SEC_ASN1_OPTIONAL 0x00100 +#define SEC_ASN1_EXPLICIT 0x00200 +#define SEC_ASN1_ANY 0x00400 +#define SEC_ASN1_INLINE 0x00800 +#define SEC_ASN1_POINTER 0x01000 +#define SEC_ASN1_GROUP 0x02000 /* with SET or SEQUENCE means \ + * SET OF or SEQUENCE OF */ +#define SEC_ASN1_DYNAMIC 0x04000 /* subtemplate is found by calling \ + * a function at runtime */ +#define SEC_ASN1_SKIP 0x08000 /* skip a field; only for decoding */ +#define SEC_ASN1_INNER 0x10000 /* with ANY means capture the \ + * contents only (not the id, len, \ + * or eoc); only for decoding */ +#define SEC_ASN1_SAVE 0x20000 /* stash away the encoded bytes first; \ + * only for decoding */ +#define SEC_ASN1_MAY_STREAM 0x40000 /* field or one of its sub-fields may \ + * stream in and so should encode as \ + * indefinite-length when streaming \ + * has been indicated; only for \ + * encoding */ +#define SEC_ASN1_SKIP_REST 0x80000 /* skip all following fields; \ + only for decoding */ +#define SEC_ASN1_CHOICE 0x100000 /* pick one from a template */ +#define SEC_ASN1_NO_STREAM 0X200000 /* This entry will not stream \ + even if the sub-template says \ + streaming is possible. Helps \ + to solve ambiguities with potential \ + streaming entries that are \ + optional */ +#define SEC_ASN1_DEBUG_BREAK 0X400000 /* put this in your template and the \ + decoder will assert when it \ + processes it. Only for use with \ + SEC_QuickDERDecodeItem */ + +/* Shorthand/Aliases */ +#define SEC_ASN1_SEQUENCE_OF (SEC_ASN1_GROUP | SEC_ASN1_SEQUENCE) +#define SEC_ASN1_SET_OF (SEC_ASN1_GROUP | SEC_ASN1_SET) +#define SEC_ASN1_ANY_CONTENTS (SEC_ASN1_ANY | SEC_ASN1_INNER) + +/* Maximum depth of nested SEQUENCEs and SETs */ +#define SEC_ASN1D_MAX_DEPTH 32 + +/* +** Function used for SEC_ASN1_DYNAMIC. +** "arg" is a pointer to the structure being encoded/decoded +** "enc", when true, means that we are encoding (false means decoding) +*/ +typedef const SEC_ASN1Template *SEC_ASN1TemplateChooser(void *arg, PRBool enc); +typedef SEC_ASN1TemplateChooser *SEC_ASN1TemplateChooserPtr; + +#if defined(_WIN32) || defined(ANDROID) +#define SEC_ASN1_GET(x) NSS_Get_##x(NULL, PR_FALSE) +#define SEC_ASN1_SUB(x) &p_NSS_Get_##x +#define SEC_ASN1_XTRN SEC_ASN1_DYNAMIC +#define SEC_ASN1_MKSUB(x) \ + static const SEC_ASN1TemplateChooserPtr p_NSS_Get_##x = &NSS_Get_##x; +#else +#define SEC_ASN1_GET(x) x +#define SEC_ASN1_SUB(x) x +#define SEC_ASN1_XTRN 0 +#define SEC_ASN1_MKSUB(x) +#endif + +#define SEC_ASN1_CHOOSER_DECLARE(x) \ + extern const SEC_ASN1Template *NSS_Get_##x(void *arg, PRBool enc); + +#define SEC_ASN1_CHOOSER_IMPLEMENT(x) \ + const SEC_ASN1Template *NSS_Get_##x(void *arg, PRBool enc) \ + { \ + return x; \ + } + +/* +** Opaque object used by the decoder to store state. +*/ +typedef struct sec_DecoderContext_struct SEC_ASN1DecoderContext; + +/* +** Opaque object used by the encoder to store state. +*/ +typedef struct sec_EncoderContext_struct SEC_ASN1EncoderContext; + +/* + * This is used to describe to a filter function the bytes that are + * being passed to it. This is only useful when the filter is an "outer" + * one, meaning it expects to get *all* of the bytes not just the + * contents octets. + */ +typedef enum { + SEC_ASN1_Identifier = 0, + SEC_ASN1_Length = 1, + SEC_ASN1_Contents = 2, + SEC_ASN1_EndOfContents = 3 +} SEC_ASN1EncodingPart; + +/* + * Type of the function pointer used either for decoding or encoding, + * when doing anything "funny" (e.g. manipulating the data stream) + */ +typedef void (*SEC_ASN1NotifyProc)(void *arg, PRBool before, + void *dest, int real_depth); + +/* + * Type of the function pointer used for grabbing encoded bytes. + * This can be used during either encoding or decoding, as follows... + * + * When decoding, this can be used to filter the encoded bytes as they + * are parsed. This is what you would do if you wanted to process the data + * along the way (like to decrypt it, or to perform a hash on it in order + * to do a signature check later). See SEC_ASN1DecoderSetFilterProc(). + * When processing only part of the encoded bytes is desired, you "watch" + * for the field(s) you are interested in with a "notify proc" (see + * SEC_ASN1DecoderSetNotifyProc()) and for even finer granularity (e.g. to + * ignore all by the contents bytes) you pay attention to the "data_kind" + * parameter. + * + * When encoding, this is the specification for the output function which + * will receive the bytes as they are encoded. The output function can + * perform any postprocessing necessary (like hashing (some of) the data + * to create a digest that gets included at the end) as well as shoving + * the data off wherever it needs to go. (In order to "tune" any processing, + * you can set a "notify proc" as described above in the decoding case.) + * + * The parameters: + * - "arg" is an opaque pointer that you provided at the same time you + * specified a function of this type + * - "data" is a buffer of length "len", containing the encoded bytes + * - "depth" is how deep in a nested encoding we are (it is not usually + * valuable, but can be useful sometimes so I included it) + * - "data_kind" tells you if these bytes are part of the ASN.1 encoded + * octets for identifier, length, contents, or end-of-contents + */ +typedef void (*SEC_ASN1WriteProc)(void *arg, + const char *data, unsigned long len, + int depth, SEC_ASN1EncodingPart data_kind); + +#endif /* _SECASN1T_H_ */ diff --git a/illumos-x86_64/usr/include/mps/seccomon.h b/illumos-x86_64/usr/include/mps/seccomon.h new file mode 100644 index 00000000..2c6be350 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/seccomon.h @@ -0,0 +1,91 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * seccomon.h - common data structures for security libraries + * + * This file should have lowest-common-denominator datastructures + * for security libraries. It should not be dependent on any other + * headers, and should not require linking with any libraries. + */ + +#ifndef _SECCOMMON_H_ +#define _SECCOMMON_H_ + +#include "utilrename.h" +#include "prtypes.h" + +#ifdef __cplusplus +#define SEC_BEGIN_PROTOS extern "C" { +#define SEC_END_PROTOS } +#else +#define SEC_BEGIN_PROTOS +#define SEC_END_PROTOS +#endif + +#include "secport.h" + +typedef enum { + siBuffer = 0, + siClearDataBuffer = 1, + siCipherDataBuffer = 2, + siDERCertBuffer = 3, + siEncodedCertBuffer = 4, + siDERNameBuffer = 5, + siEncodedNameBuffer = 6, + siAsciiNameString = 7, + siAsciiString = 8, + siDEROID = 9, + siUnsignedInteger = 10, + siUTCTime = 11, + siGeneralizedTime = 12, + siVisibleString = 13, + siUTF8String = 14, + siBMPString = 15 +} SECItemType; + +typedef struct SECItemStr SECItem; + +struct SECItemStr { + SECItemType type; + unsigned char *data; + unsigned int len; +}; + +typedef struct SECItemArrayStr SECItemArray; + +struct SECItemArrayStr { + SECItem *items; + unsigned int len; +}; + +/* +** A status code. Statuses are used by procedures that return status +** values. Again the motivation is so that a compiler can generate +** warnings when return values are wrong. Correct testing of status codes: +** +** SECStatus rv; +** rv = some_function (some_argument); +** if (rv != SECSuccess) +** do_an_error_thing(); +** +*/ +typedef enum _SECStatus { + SECWouldBlock = -2, + SECFailure = -1, + SECSuccess = 0 +} SECStatus; + +/* +** A comparison code. Used for procedures that return comparison +** values. Again the motivation is so that a compiler can generate +** warnings when return values are wrong. +*/ +typedef enum _SECComparison { + SECLessThan = -1, + SECEqual = 0, + SECGreaterThan = 1 +} SECComparison; + +#endif /* _SECCOMMON_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secder.h b/illumos-x86_64/usr/include/mps/secder.h new file mode 100644 index 00000000..1b487d19 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secder.h @@ -0,0 +1,175 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _SECDER_H_ +#define _SECDER_H_ + +#include "utilrename.h" + +/* + * secder.h - public data structures and prototypes for the DER encoding and + * decoding utilities library + */ + +#include + +#include "plarena.h" +#include "prlong.h" + +#include "seccomon.h" +#include "secdert.h" +#include "prtime.h" + +SEC_BEGIN_PROTOS + +/* +** Encode a data structure into DER. +** "dest" will be filled in (and memory allocated) to hold the der +** encoded structure in "src" +** "t" is a template structure which defines the shape of the +** stored data +** "src" is a pointer to the structure that will be encoded +*/ +extern SECStatus DER_Encode(PLArenaPool *arena, SECItem *dest, DERTemplate *t, + void *src); + +/* +** This function is deprecated. +*/ +extern SECStatus DER_Lengths(SECItem *item, int *header_len_p, + PRUint32 *contents_len_p); + +/* +** Lower level der subroutine that stores the standard header into "to". +** The header is of variable length, based on encodingLen. +** The return value is the new value of "to" after skipping over the header. +** "to" is where the header will be stored +** "code" is the der code to write +** "encodingLen" is the number of bytes of data that will follow +** the header +*/ +extern unsigned char *DER_StoreHeader(unsigned char *to, unsigned int code, + PRUint32 encodingLen); + +/* +** Return the number of bytes it will take to hold a der encoded length. +*/ +extern int DER_LengthLength(PRUint32 len); + +/* +** Store a der encoded *signed* integer (whose value is "src") into "dst". +** XXX This should really be enhanced to take a long. +*/ +extern SECStatus DER_SetInteger(PLArenaPool *arena, SECItem *dst, PRInt32 src); + +/* +** Store a der encoded *unsigned* integer (whose value is "src") into "dst". +** XXX This should really be enhanced to take an unsigned long. +*/ +extern SECStatus DER_SetUInteger(PLArenaPool *arena, SECItem *dst, PRUint32 src); + +/* +** Decode a der encoded *signed* integer that is stored in "src". +** If "-1" is returned, then the caller should check the error in +** XP_GetError() to see if an overflow occurred (SEC_ERROR_BAD_DER). +*/ +extern long DER_GetInteger(const SECItem *src); + +/* +** Decode a der encoded *unsigned* integer that is stored in "src". +** If the ULONG_MAX is returned, then the caller should check the error +** in XP_GetError() to see if an overflow occurred (SEC_ERROR_BAD_DER). +*/ +extern unsigned long DER_GetUInteger(SECItem *src); + +/* +** Convert an NSPR time value to a der encoded time value. +** "result" is the der encoded time (memory is allocated) +** "time" is the NSPR time value (Since Jan 1st, 1970). +** time must be on or after January 1, 1950, and +** before January 1, 2050 +** The caller is responsible for freeing up the buffer which +** result->data points to upon a successful operation. +*/ +extern SECStatus DER_TimeToUTCTime(SECItem *result, PRTime time); +extern SECStatus DER_TimeToUTCTimeArena(PLArenaPool *arenaOpt, + SECItem *dst, PRTime gmttime); + +/* +** Convert an ascii encoded time value (according to DER rules) into +** an NSPR time value. +** "result" the resulting NSPR time +** "string" the der notation ascii value to decode +*/ +extern SECStatus DER_AsciiToTime(PRTime *result, const char *string); + +/* +** Same as DER_AsciiToTime except takes an SECItem instead of a string +*/ +extern SECStatus DER_UTCTimeToTime(PRTime *result, const SECItem *time); + +/* +** Convert a DER encoded UTC time to an ascii time representation +** "utctime" is the DER encoded UTC time to be converted. The +** caller is responsible for deallocating the returned buffer. +*/ +extern char *DER_UTCTimeToAscii(SECItem *utcTime); + +/* +** Convert a DER encoded UTC time to an ascii time representation, but only +** include the day, not the time. +** "utctime" is the DER encoded UTC time to be converted. +** The caller is responsible for deallocating the returned buffer. +*/ +extern char *DER_UTCDayToAscii(SECItem *utctime); +/* same thing for DER encoded GeneralizedTime */ +extern char *DER_GeneralizedDayToAscii(SECItem *gentime); +/* same thing for either DER UTCTime or GeneralizedTime */ +extern char *DER_TimeChoiceDayToAscii(SECItem *timechoice); + +/* +** Convert a PRTime to a DER encoded Generalized time +** gmttime must be on or after January 1, year 1 and +** before January 1, 10000. +*/ +extern SECStatus DER_TimeToGeneralizedTime(SECItem *dst, PRTime gmttime); +extern SECStatus DER_TimeToGeneralizedTimeArena(PLArenaPool *arenaOpt, + SECItem *dst, PRTime gmttime); + +/* +** Convert a DER encoded Generalized time value into an NSPR time value. +** "dst" the resulting NSPR time +** "string" the der notation ascii value to decode +*/ +extern SECStatus DER_GeneralizedTimeToTime(PRTime *dst, const SECItem *time); + +/* +** Convert from a PRTime UTC time value to a formatted ascii value. The +** caller is responsible for deallocating the returned buffer. +*/ +extern char *CERT_UTCTime2FormattedAscii(PRTime utcTime, char *format); +#define CERT_GeneralizedTime2FormattedAscii CERT_UTCTime2FormattedAscii + +/* +** Convert from a PRTime Generalized time value to a formatted ascii value. The +** caller is responsible for deallocating the returned buffer. +*/ +extern char *CERT_GenTime2FormattedAscii(PRTime genTime, char *format); + +/* +** decode a SECItem containing either a SEC_ASN1_GENERALIZED_TIME +** or a SEC_ASN1_UTC_TIME +*/ + +extern SECStatus DER_DecodeTimeChoice(PRTime *output, const SECItem *input); + +/* encode a PRTime to an ASN.1 DER SECItem containing either a + SEC_ASN1_GENERALIZED_TIME or a SEC_ASN1_UTC_TIME */ + +extern SECStatus DER_EncodeTimeChoice(PLArenaPool *arena, SECItem *output, + PRTime input); + +SEC_END_PROTOS + +#endif /* _SECDER_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secdert.h b/illumos-x86_64/usr/include/mps/secdert.h new file mode 100644 index 00000000..de67eafe --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secdert.h @@ -0,0 +1,129 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _SECDERT_H_ +#define _SECDERT_H_ +/* + * secdert.h - public data structures for the DER encoding and + * decoding utilities library + */ + +#include "utilrename.h" +#include "seccomon.h" + +typedef struct DERTemplateStr DERTemplate; + +/* +** An array of these structures defines an encoding for an object using DER. +** The array usually starts with a dummy entry whose kind is DER_SEQUENCE; +** such an array is terminated with an entry where kind == 0. (An array +** which consists of a single component does not require a second dummy +** entry -- the array is only searched as long as previous component(s) +** instruct it.) +*/ +struct DERTemplateStr { + /* + ** Kind of item being decoded/encoded, including tags and modifiers. + */ + unsigned long kind; + + /* + ** Offset from base of structure to field that holds the value + ** being decoded/encoded. + */ + unsigned int offset; + + /* + ** When kind suggests it (DER_POINTER, DER_INDEFINITE, DER_INLINE), + ** this points to a sub-template for nested encoding/decoding. + */ + DERTemplate *sub; + + /* + ** Argument value, dependent on "kind" and/or template placement + ** within an array of templates: + ** - In the first element of a template array, the value is the + ** size of the structure to allocate when this template is being + ** referenced by another template via DER_POINTER or DER_INDEFINITE. + ** - In a component of a DER_SET or DER_SEQUENCE which is *not* a + ** DER_UNIVERSAL type (that is, it has a class tag for either + ** DER_APPLICATION, DER_CONTEXT_SPECIFIC, or DER_PRIVATE), the + ** value is the underlying type of item being decoded/encoded. + */ + unsigned long arg; +}; + +/************************************************************************/ + +/* default chunksize for arenas used for DER stuff */ +#define DER_DEFAULT_CHUNKSIZE (2048) + +/* +** BER/DER values for ASN.1 identifier octets. +*/ +#define DER_TAG_MASK 0xff + +/* + * BER/DER universal type tag numbers. + * The values are defined by the X.208 standard; do not change them! + * NOTE: if you add anything to this list, you must add code to derdec.c + * to accept the tag, and probably also to derenc.c to encode it. + */ +#define DER_TAGNUM_MASK 0x1f +#define DER_BOOLEAN 0x01 +#define DER_INTEGER 0x02 +#define DER_BIT_STRING 0x03 +#define DER_OCTET_STRING 0x04 +#define DER_NULL 0x05 +#define DER_OBJECT_ID 0x06 +#define DER_SEQUENCE 0x10 +#define DER_SET 0x11 +#define DER_PRINTABLE_STRING 0x13 +#define DER_T61_STRING 0x14 +#define DER_IA5_STRING 0x16 +#define DER_UTC_TIME 0x17 +#define DER_VISIBLE_STRING 0x1a +#define DER_HIGH_TAG_NUMBER 0x1f + +/* +** Modifiers to type tags. These are also specified by a/the +** standard, and must not be changed. +*/ + +#define DER_METHOD_MASK 0x20 +#define DER_PRIMITIVE 0x00 +#define DER_CONSTRUCTED 0x20 + +#define DER_CLASS_MASK 0xc0 +#define DER_UNIVERSAL 0x00 +#define DER_APPLICATION 0x40 +#define DER_CONTEXT_SPECIFIC 0x80 +#define DER_PRIVATE 0xc0 + +/* +** Our additions, used for templates. +** These are not defined by any standard; the values are used internally only. +** Just be careful to keep them out of the low 8 bits. +*/ +#define DER_OPTIONAL 0x00100 +#define DER_EXPLICIT 0x00200 +#define DER_ANY 0x00400 +#define DER_INLINE 0x00800 +#define DER_POINTER 0x01000 +#define DER_INDEFINITE 0x02000 +#define DER_DERPTR 0x04000 +#define DER_SKIP 0x08000 +#define DER_FORCE 0x10000 +#define DER_OUTER 0x40000 /* for DER_DERPTR */ + +/* +** Macro to convert der decoded bit string into a decoded octet +** string. All it needs to do is fiddle with the length code. +*/ +#define DER_ConvertBitString(item) \ + { \ + (item)->len = ((item)->len + 7) >> 3; \ + } + +#endif /* _SECDERT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secdig.h b/illumos-x86_64/usr/include/mps/secdig.h new file mode 100644 index 00000000..1531bf10 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secdig.h @@ -0,0 +1,100 @@ +/* + * secdig.h - public prototypes for digest-info functions + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _SECDIG_H_ +#define _SECDIG_H_ + +#include "utilrename.h" +#include "secdigt.h" + +#include "seccomon.h" +#include "secasn1t.h" +#include "secdert.h" + +SEC_BEGIN_PROTOS + +extern const SEC_ASN1Template sgn_DigestInfoTemplate[]; + +SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate) + +/****************************************/ +/* +** Digest-info functions +*/ + +/* +** Create a new digest-info object +** "algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1 +** "sig" the raw signature data (from MD2 or MD5) +** "sigLen" the length of the signature data +** +** NOTE: this is a low level routine used to prepare some data for PKCS#1 +** digital signature formatting. +** +** XXX It might be nice to combine the create and encode functions. +** I think that is all anybody ever wants to do anyway. +*/ +extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm, + const unsigned char *sig, + unsigned int sigLen); + +/* +** Destroy a digest-info object +*/ +extern void SGN_DestroyDigestInfo(SGNDigestInfo *info); + +/* +** Encode a digest-info object +** "poolp" is where to allocate the result from; it can be NULL in +** which case generic heap allocation (XP_ALLOC) will be used +** "dest" is where to store the result; it can be NULL, in which case +** it will be allocated (from poolp or heap, as explained above) +** "diginfo" is the object to be encoded +** The return value is NULL if any error occurred, otherwise it is the +** resulting SECItem (either allocated or the same as the "dest" parameter). +** +** XXX It might be nice to combine the create and encode functions. +** I think that is all anybody ever wants to do anyway. +*/ +extern SECItem *SGN_EncodeDigestInfo(PLArenaPool *poolp, SECItem *dest, + SGNDigestInfo *diginfo); + +/* +** Decode a DER encoded digest info objct. +** didata is thr source of the encoded digest. +** The return value is NULL if an error occurs. Otherwise, a +** digest info object which is allocated within it's own +** pool is returned. The digest info should be deleted +** by later calling SGN_DestroyDigestInfo. +*/ +extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata); + +/* +** Copy digest info. +** poolp is the arena to which the digest will be copied. +** a is the destination digest, it must be non-NULL. +** b is the source digest +** This function is for copying digests. It allows digests +** to be copied into a specified pool. If the digest is in +** the same pool as other data, you do not want to delete +** the digest by calling SGN_DestroyDigestInfo. +** A return value of SECFailure indicates an error. A return +** of SECSuccess indicates no error occurred. +*/ +extern SECStatus SGN_CopyDigestInfo(PLArenaPool *poolp, + SGNDigestInfo *a, + SGNDigestInfo *b); + +/* +** Compare two digest-info objects, returning the difference between +** them. +*/ +extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b); + +SEC_END_PROTOS + +#endif /* _SECDIG_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secdigt.h b/illumos-x86_64/usr/include/mps/secdigt.h new file mode 100644 index 00000000..45534346 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secdigt.h @@ -0,0 +1,26 @@ +/* + * secdigt.h - public data structures for digest-info objects + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _SECDIGT_H_ +#define _SECDIGT_H_ + +#include "utilrename.h" +#include "plarena.h" +#include "secoidt.h" +#include "secitem.h" + +/* +** A PKCS#1 digest-info object +*/ +struct SGNDigestInfoStr { + PLArenaPool* arena; + SECAlgorithmID digestAlgorithm; + SECItem digest; +}; +typedef struct SGNDigestInfoStr SGNDigestInfo; + +#endif /* _SECDIGT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secerr.h b/illumos-x86_64/usr/include/mps/secerr.h new file mode 100644 index 00000000..5b7c9cc5 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secerr.h @@ -0,0 +1,226 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __SEC_ERR_H_ +#define __SEC_ERR_H_ + +#include "utilrename.h" + +#define SEC_ERROR_BASE (-0x2000) +#define SEC_ERROR_LIMIT (SEC_ERROR_BASE + 1000) + +#define IS_SEC_ERROR(code) \ + (((code) >= SEC_ERROR_BASE) && ((code) < SEC_ERROR_LIMIT)) + +#ifndef NO_SECURITY_ERROR_ENUM +typedef enum { + SEC_ERROR_IO = SEC_ERROR_BASE + 0, + SEC_ERROR_LIBRARY_FAILURE = SEC_ERROR_BASE + 1, + SEC_ERROR_BAD_DATA = SEC_ERROR_BASE + 2, + SEC_ERROR_OUTPUT_LEN = SEC_ERROR_BASE + 3, + SEC_ERROR_INPUT_LEN = SEC_ERROR_BASE + 4, + SEC_ERROR_INVALID_ARGS = SEC_ERROR_BASE + 5, + SEC_ERROR_INVALID_ALGORITHM = SEC_ERROR_BASE + 6, + SEC_ERROR_INVALID_AVA = SEC_ERROR_BASE + 7, + SEC_ERROR_INVALID_TIME = SEC_ERROR_BASE + 8, + SEC_ERROR_BAD_DER = SEC_ERROR_BASE + 9, + SEC_ERROR_BAD_SIGNATURE = SEC_ERROR_BASE + 10, + SEC_ERROR_EXPIRED_CERTIFICATE = SEC_ERROR_BASE + 11, + SEC_ERROR_REVOKED_CERTIFICATE = SEC_ERROR_BASE + 12, + SEC_ERROR_UNKNOWN_ISSUER = SEC_ERROR_BASE + 13, + SEC_ERROR_BAD_KEY = SEC_ERROR_BASE + 14, + SEC_ERROR_BAD_PASSWORD = SEC_ERROR_BASE + 15, + SEC_ERROR_RETRY_PASSWORD = SEC_ERROR_BASE + 16, + SEC_ERROR_NO_NODELOCK = SEC_ERROR_BASE + 17, + SEC_ERROR_BAD_DATABASE = SEC_ERROR_BASE + 18, + SEC_ERROR_NO_MEMORY = SEC_ERROR_BASE + 19, + SEC_ERROR_UNTRUSTED_ISSUER = SEC_ERROR_BASE + 20, + SEC_ERROR_UNTRUSTED_CERT = SEC_ERROR_BASE + 21, + SEC_ERROR_DUPLICATE_CERT = (SEC_ERROR_BASE + 22), + SEC_ERROR_DUPLICATE_CERT_NAME = (SEC_ERROR_BASE + 23), + SEC_ERROR_ADDING_CERT = (SEC_ERROR_BASE + 24), + SEC_ERROR_FILING_KEY = (SEC_ERROR_BASE + 25), + SEC_ERROR_NO_KEY = (SEC_ERROR_BASE + 26), + SEC_ERROR_CERT_VALID = (SEC_ERROR_BASE + 27), + SEC_ERROR_CERT_NOT_VALID = (SEC_ERROR_BASE + 28), + SEC_ERROR_CERT_NO_RESPONSE = (SEC_ERROR_BASE + 29), + SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE = (SEC_ERROR_BASE + 30), + SEC_ERROR_CRL_EXPIRED = (SEC_ERROR_BASE + 31), + SEC_ERROR_CRL_BAD_SIGNATURE = (SEC_ERROR_BASE + 32), + SEC_ERROR_CRL_INVALID = (SEC_ERROR_BASE + 33), + SEC_ERROR_EXTENSION_VALUE_INVALID = (SEC_ERROR_BASE + 34), + SEC_ERROR_EXTENSION_NOT_FOUND = (SEC_ERROR_BASE + 35), + SEC_ERROR_CA_CERT_INVALID = (SEC_ERROR_BASE + 36), + SEC_ERROR_PATH_LEN_CONSTRAINT_INVALID = (SEC_ERROR_BASE + 37), + SEC_ERROR_CERT_USAGES_INVALID = (SEC_ERROR_BASE + 38), + SEC_INTERNAL_ONLY = (SEC_ERROR_BASE + 39), + SEC_ERROR_INVALID_KEY = (SEC_ERROR_BASE + 40), + SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION = (SEC_ERROR_BASE + 41), + SEC_ERROR_OLD_CRL = (SEC_ERROR_BASE + 42), + SEC_ERROR_NO_EMAIL_CERT = (SEC_ERROR_BASE + 43), + SEC_ERROR_NO_RECIPIENT_CERTS_QUERY = (SEC_ERROR_BASE + 44), + SEC_ERROR_NOT_A_RECIPIENT = (SEC_ERROR_BASE + 45), + SEC_ERROR_PKCS7_KEYALG_MISMATCH = (SEC_ERROR_BASE + 46), + SEC_ERROR_PKCS7_BAD_SIGNATURE = (SEC_ERROR_BASE + 47), + SEC_ERROR_UNSUPPORTED_KEYALG = (SEC_ERROR_BASE + 48), + SEC_ERROR_DECRYPTION_DISALLOWED = (SEC_ERROR_BASE + 49), + /* Fortezza Alerts */ + XP_SEC_FORTEZZA_BAD_CARD = (SEC_ERROR_BASE + 50), + XP_SEC_FORTEZZA_NO_CARD = (SEC_ERROR_BASE + 51), + XP_SEC_FORTEZZA_NONE_SELECTED = (SEC_ERROR_BASE + 52), + XP_SEC_FORTEZZA_MORE_INFO = (SEC_ERROR_BASE + 53), + XP_SEC_FORTEZZA_PERSON_NOT_FOUND = (SEC_ERROR_BASE + 54), + XP_SEC_FORTEZZA_NO_MORE_INFO = (SEC_ERROR_BASE + 55), + XP_SEC_FORTEZZA_BAD_PIN = (SEC_ERROR_BASE + 56), + XP_SEC_FORTEZZA_PERSON_ERROR = (SEC_ERROR_BASE + 57), + SEC_ERROR_NO_KRL = (SEC_ERROR_BASE + 58), + SEC_ERROR_KRL_EXPIRED = (SEC_ERROR_BASE + 59), + SEC_ERROR_KRL_BAD_SIGNATURE = (SEC_ERROR_BASE + 60), + SEC_ERROR_REVOKED_KEY = (SEC_ERROR_BASE + 61), + SEC_ERROR_KRL_INVALID = (SEC_ERROR_BASE + 62), + SEC_ERROR_NEED_RANDOM = (SEC_ERROR_BASE + 63), + SEC_ERROR_NO_MODULE = (SEC_ERROR_BASE + 64), + SEC_ERROR_NO_TOKEN = (SEC_ERROR_BASE + 65), + SEC_ERROR_READ_ONLY = (SEC_ERROR_BASE + 66), + SEC_ERROR_NO_SLOT_SELECTED = (SEC_ERROR_BASE + 67), + SEC_ERROR_CERT_NICKNAME_COLLISION = (SEC_ERROR_BASE + 68), + SEC_ERROR_KEY_NICKNAME_COLLISION = (SEC_ERROR_BASE + 69), + SEC_ERROR_SAFE_NOT_CREATED = (SEC_ERROR_BASE + 70), + SEC_ERROR_BAGGAGE_NOT_CREATED = (SEC_ERROR_BASE + 71), + XP_JAVA_REMOVE_PRINCIPAL_ERROR = (SEC_ERROR_BASE + 72), + XP_JAVA_DELETE_PRIVILEGE_ERROR = (SEC_ERROR_BASE + 73), + XP_JAVA_CERT_NOT_EXISTS_ERROR = (SEC_ERROR_BASE + 74), + SEC_ERROR_BAD_EXPORT_ALGORITHM = (SEC_ERROR_BASE + 75), + SEC_ERROR_EXPORTING_CERTIFICATES = (SEC_ERROR_BASE + 76), + SEC_ERROR_IMPORTING_CERTIFICATES = (SEC_ERROR_BASE + 77), + SEC_ERROR_PKCS12_DECODING_PFX = (SEC_ERROR_BASE + 78), + SEC_ERROR_PKCS12_INVALID_MAC = (SEC_ERROR_BASE + 79), + SEC_ERROR_PKCS12_UNSUPPORTED_MAC_ALGORITHM = (SEC_ERROR_BASE + 80), + SEC_ERROR_PKCS12_UNSUPPORTED_TRANSPORT_MODE = (SEC_ERROR_BASE + 81), + SEC_ERROR_PKCS12_CORRUPT_PFX_STRUCTURE = (SEC_ERROR_BASE + 82), + SEC_ERROR_PKCS12_UNSUPPORTED_PBE_ALGORITHM = (SEC_ERROR_BASE + 83), + SEC_ERROR_PKCS12_UNSUPPORTED_VERSION = (SEC_ERROR_BASE + 84), + SEC_ERROR_PKCS12_PRIVACY_PASSWORD_INCORRECT = (SEC_ERROR_BASE + 85), + SEC_ERROR_PKCS12_CERT_COLLISION = (SEC_ERROR_BASE + 86), + SEC_ERROR_USER_CANCELLED = (SEC_ERROR_BASE + 87), + SEC_ERROR_PKCS12_DUPLICATE_DATA = (SEC_ERROR_BASE + 88), + SEC_ERROR_MESSAGE_SEND_ABORTED = (SEC_ERROR_BASE + 89), + SEC_ERROR_INADEQUATE_KEY_USAGE = (SEC_ERROR_BASE + 90), + SEC_ERROR_INADEQUATE_CERT_TYPE = (SEC_ERROR_BASE + 91), + SEC_ERROR_CERT_ADDR_MISMATCH = (SEC_ERROR_BASE + 92), + SEC_ERROR_PKCS12_UNABLE_TO_IMPORT_KEY = (SEC_ERROR_BASE + 93), + SEC_ERROR_PKCS12_IMPORTING_CERT_CHAIN = (SEC_ERROR_BASE + 94), + SEC_ERROR_PKCS12_UNABLE_TO_LOCATE_OBJECT_BY_NAME = (SEC_ERROR_BASE + 95), + SEC_ERROR_PKCS12_UNABLE_TO_EXPORT_KEY = (SEC_ERROR_BASE + 96), + SEC_ERROR_PKCS12_UNABLE_TO_WRITE = (SEC_ERROR_BASE + 97), + SEC_ERROR_PKCS12_UNABLE_TO_READ = (SEC_ERROR_BASE + 98), + SEC_ERROR_PKCS12_KEY_DATABASE_NOT_INITIALIZED = (SEC_ERROR_BASE + 99), + SEC_ERROR_KEYGEN_FAIL = (SEC_ERROR_BASE + 100), + SEC_ERROR_INVALID_PASSWORD = (SEC_ERROR_BASE + 101), + SEC_ERROR_RETRY_OLD_PASSWORD = (SEC_ERROR_BASE + 102), + SEC_ERROR_BAD_NICKNAME = (SEC_ERROR_BASE + 103), + SEC_ERROR_NOT_FORTEZZA_ISSUER = (SEC_ERROR_BASE + 104), + SEC_ERROR_CANNOT_MOVE_SENSITIVE_KEY = (SEC_ERROR_BASE + 105), + SEC_ERROR_JS_INVALID_MODULE_NAME = (SEC_ERROR_BASE + 106), + SEC_ERROR_JS_INVALID_DLL = (SEC_ERROR_BASE + 107), + SEC_ERROR_JS_ADD_MOD_FAILURE = (SEC_ERROR_BASE + 108), + SEC_ERROR_JS_DEL_MOD_FAILURE = (SEC_ERROR_BASE + 109), + SEC_ERROR_OLD_KRL = (SEC_ERROR_BASE + 110), + SEC_ERROR_CKL_CONFLICT = (SEC_ERROR_BASE + 111), + SEC_ERROR_CERT_NOT_IN_NAME_SPACE = (SEC_ERROR_BASE + 112), + SEC_ERROR_KRL_NOT_YET_VALID = (SEC_ERROR_BASE + 113), + SEC_ERROR_CRL_NOT_YET_VALID = (SEC_ERROR_BASE + 114), + SEC_ERROR_UNKNOWN_CERT = (SEC_ERROR_BASE + 115), + SEC_ERROR_UNKNOWN_SIGNER = (SEC_ERROR_BASE + 116), + SEC_ERROR_CERT_BAD_ACCESS_LOCATION = (SEC_ERROR_BASE + 117), + SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE = (SEC_ERROR_BASE + 118), + SEC_ERROR_OCSP_BAD_HTTP_RESPONSE = (SEC_ERROR_BASE + 119), + SEC_ERROR_OCSP_MALFORMED_REQUEST = (SEC_ERROR_BASE + 120), + SEC_ERROR_OCSP_SERVER_ERROR = (SEC_ERROR_BASE + 121), + SEC_ERROR_OCSP_TRY_SERVER_LATER = (SEC_ERROR_BASE + 122), + SEC_ERROR_OCSP_REQUEST_NEEDS_SIG = (SEC_ERROR_BASE + 123), + SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST = (SEC_ERROR_BASE + 124), + SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS = (SEC_ERROR_BASE + 125), + SEC_ERROR_OCSP_UNKNOWN_CERT = (SEC_ERROR_BASE + 126), + SEC_ERROR_OCSP_NOT_ENABLED = (SEC_ERROR_BASE + 127), + SEC_ERROR_OCSP_NO_DEFAULT_RESPONDER = (SEC_ERROR_BASE + 128), + SEC_ERROR_OCSP_MALFORMED_RESPONSE = (SEC_ERROR_BASE + 129), + SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE = (SEC_ERROR_BASE + 130), + SEC_ERROR_OCSP_FUTURE_RESPONSE = (SEC_ERROR_BASE + 131), + SEC_ERROR_OCSP_OLD_RESPONSE = (SEC_ERROR_BASE + 132), + /* smime stuff */ + SEC_ERROR_DIGEST_NOT_FOUND = (SEC_ERROR_BASE + 133), + SEC_ERROR_UNSUPPORTED_MESSAGE_TYPE = (SEC_ERROR_BASE + 134), + SEC_ERROR_MODULE_STUCK = (SEC_ERROR_BASE + 135), + SEC_ERROR_BAD_TEMPLATE = (SEC_ERROR_BASE + 136), + SEC_ERROR_CRL_NOT_FOUND = (SEC_ERROR_BASE + 137), + SEC_ERROR_REUSED_ISSUER_AND_SERIAL = (SEC_ERROR_BASE + 138), + SEC_ERROR_BUSY = (SEC_ERROR_BASE + 139), + SEC_ERROR_EXTRA_INPUT = (SEC_ERROR_BASE + 140), + /* error codes used by elliptic curve code */ + SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE = (SEC_ERROR_BASE + 141), + SEC_ERROR_UNSUPPORTED_EC_POINT_FORM = (SEC_ERROR_BASE + 142), + SEC_ERROR_UNRECOGNIZED_OID = (SEC_ERROR_BASE + 143), + SEC_ERROR_OCSP_INVALID_SIGNING_CERT = (SEC_ERROR_BASE + 144), + /* new revocation errors */ + SEC_ERROR_REVOKED_CERTIFICATE_CRL = (SEC_ERROR_BASE + 145), + SEC_ERROR_REVOKED_CERTIFICATE_OCSP = (SEC_ERROR_BASE + 146), + SEC_ERROR_CRL_INVALID_VERSION = (SEC_ERROR_BASE + 147), + SEC_ERROR_CRL_V1_CRITICAL_EXTENSION = (SEC_ERROR_BASE + 148), + SEC_ERROR_CRL_UNKNOWN_CRITICAL_EXTENSION = (SEC_ERROR_BASE + 149), + SEC_ERROR_UNKNOWN_OBJECT_TYPE = (SEC_ERROR_BASE + 150), + SEC_ERROR_INCOMPATIBLE_PKCS11 = (SEC_ERROR_BASE + 151), + SEC_ERROR_NO_EVENT = (SEC_ERROR_BASE + 152), + SEC_ERROR_CRL_ALREADY_EXISTS = (SEC_ERROR_BASE + 153), + SEC_ERROR_NOT_INITIALIZED = (SEC_ERROR_BASE + 154), + SEC_ERROR_TOKEN_NOT_LOGGED_IN = (SEC_ERROR_BASE + 155), + SEC_ERROR_OCSP_RESPONDER_CERT_INVALID = (SEC_ERROR_BASE + 156), + SEC_ERROR_OCSP_BAD_SIGNATURE = (SEC_ERROR_BASE + 157), + + SEC_ERROR_OUT_OF_SEARCH_LIMITS = (SEC_ERROR_BASE + 158), + SEC_ERROR_INVALID_POLICY_MAPPING = (SEC_ERROR_BASE + 159), + SEC_ERROR_POLICY_VALIDATION_FAILED = (SEC_ERROR_BASE + 160), + /* No longer used. Unknown AIA location types are now silently ignored. */ + SEC_ERROR_UNKNOWN_AIA_LOCATION_TYPE = (SEC_ERROR_BASE + 161), + SEC_ERROR_BAD_HTTP_RESPONSE = (SEC_ERROR_BASE + 162), + SEC_ERROR_BAD_LDAP_RESPONSE = (SEC_ERROR_BASE + 163), + SEC_ERROR_FAILED_TO_ENCODE_DATA = (SEC_ERROR_BASE + 164), + SEC_ERROR_BAD_INFO_ACCESS_LOCATION = (SEC_ERROR_BASE + 165), + + SEC_ERROR_LIBPKIX_INTERNAL = (SEC_ERROR_BASE + 166), + + SEC_ERROR_PKCS11_GENERAL_ERROR = (SEC_ERROR_BASE + 167), + SEC_ERROR_PKCS11_FUNCTION_FAILED = (SEC_ERROR_BASE + 168), + SEC_ERROR_PKCS11_DEVICE_ERROR = (SEC_ERROR_BASE + 169), + + SEC_ERROR_BAD_INFO_ACCESS_METHOD = (SEC_ERROR_BASE + 170), + SEC_ERROR_CRL_IMPORT_FAILED = (SEC_ERROR_BASE + 171), + + SEC_ERROR_EXPIRED_PASSWORD = (SEC_ERROR_BASE + 172), + SEC_ERROR_LOCKED_PASSWORD = (SEC_ERROR_BASE + 173), + + SEC_ERROR_UNKNOWN_PKCS11_ERROR = (SEC_ERROR_BASE + 174), + + SEC_ERROR_BAD_CRL_DP_URL = (SEC_ERROR_BASE + 175), + + SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED = (SEC_ERROR_BASE + 176), + + SEC_ERROR_LEGACY_DATABASE = (SEC_ERROR_BASE + 177), + + SEC_ERROR_APPLICATION_CALLBACK_ERROR = (SEC_ERROR_BASE + 178), + + SEC_ERROR_INVALID_STATE = (SEC_ERROR_BASE + 179), + + SEC_ERROR_POLICY_LOCKED = (SEC_ERROR_BASE + 180), + SEC_ERROR_SIGNATURE_ALGORITHM_DISABLED = (SEC_ERROR_BASE + 181), + SEC_ERROR_ALGORITHM_MISMATCH = (SEC_ERROR_BASE + 182), + + SEC_ERROR_CERTIFICATE_COMPRESSION_ALGORITHM_NOT_SUPPORTED = (SEC_ERROR_BASE + 183), + SEC_ERROR_UNEXPECTED_COMPRESSED_CERTIFICATE = (SEC_ERROR_BASE + 184), + /* Add new error codes above here. */ + SEC_ERROR_END_OF_LIST +} SECErrorCodes; +#endif /* NO_SECURITY_ERROR_ENUM */ + +#endif /* __SEC_ERR_H_ */ diff --git a/illumos-x86_64/usr/include/mps/sechash.h b/illumos-x86_64/usr/include/mps/sechash.h new file mode 100644 index 00000000..0e4568b8 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/sechash.h @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _HASH_H_ +#define _HASH_H_ + +#include "seccomon.h" +#include "hasht.h" +#include "secoidt.h" +#include "pkcs11t.h" +#include "nsshash.h" + +SEC_BEGIN_PROTOS + +/* +** Generic hash api. +*/ + +extern unsigned int HASH_ResultLen(HASH_HashType type); + +extern unsigned int HASH_ResultLenContext(HASHContext *context); + +extern unsigned int HASH_ResultLenByOidTag(SECOidTag hashOid); + +extern SECStatus HASH_HashBuf(HASH_HashType type, + unsigned char *dest, + const unsigned char *src, + PRUint32 src_len); + +extern HASHContext *HASH_Create(HASH_HashType type); + +extern HASHContext *HASH_Clone(HASHContext *context); + +extern void HASH_Destroy(HASHContext *context); + +extern void HASH_Begin(HASHContext *context); + +extern void HASH_Update(HASHContext *context, + const unsigned char *src, + unsigned int len); + +extern void HASH_End(HASHContext *context, + unsigned char *result, + unsigned int *result_len, + unsigned int max_result_len); + +extern HASH_HashType HASH_GetType(HASHContext *context); + +extern const SECHashObject *HASH_GetHashObject(HASH_HashType type); + +extern const SECHashObject *HASH_GetHashObjectByOidTag(SECOidTag hashOid); + +extern CK_RSA_PKCS_MGF_TYPE SEC_GetMgfTypeByOidTag(SECOidTag tag); + +SEC_END_PROTOS + +#endif /* _HASH_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secitem.h b/illumos-x86_64/usr/include/mps/secitem.h new file mode 100644 index 00000000..13fbb584 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secitem.h @@ -0,0 +1,126 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _SECITEM_H_ +#define _SECITEM_H_ + +#include "utilrename.h" + +/* + * secitem.h - public data structures and prototypes for handling + * SECItems + */ + +#include "plarena.h" +#include "plhash.h" +#include "seccomon.h" + +SEC_BEGIN_PROTOS + +/* +** Allocate an item. If "arena" is not NULL, then allocate from there, +** otherwise allocate from the heap. If "item" is not NULL, allocate +** only the data buffer for the item, not the item itself. If "len" is +** 0, do not allocate the data buffer for the item; simply set the data +** field to NULL and the len field to 0. The item structure is allocated +** zero-filled; the data buffer is not zeroed. The caller is responsible +** for initializing the type field of the item. +** +** The resulting item is returned; NULL if any error occurs. +** +** XXX This probably should take a SECItemType, but since that is mostly +** unused and our improved APIs (aka Stan) are looming, I left it out. +*/ +extern SECItem *SECITEM_AllocItem(PLArenaPool *arena, SECItem *item, + unsigned int len); + +/* Allocate and make an item with the requested contents. + * + * We seem to have mostly given up on SECItemType, so the result is + * always siBuffer. + */ +extern SECStatus SECITEM_MakeItem(PLArenaPool *arena, SECItem *dest, + const unsigned char *data, unsigned int len); + +/* +** This is a legacy function containing bugs. It doesn't update item->len, +** and it has other issues as described in bug 298649 and bug 298938. +** However, the function is kept unchanged for consumers that might depend +** on the broken behaviour. New code should call SECITEM_ReallocItemV2. +** +** Reallocate the data for the specified "item". If "arena" is not NULL, +** then reallocate from there, otherwise reallocate from the heap. +** In the case where oldlen is 0, the data is allocated (not reallocated). +** In any case, "item" is expected to be a valid SECItem pointer; +** SECFailure is returned if it is not. If the allocation succeeds, +** SECSuccess is returned. +*/ +extern SECStatus SECITEM_ReallocItem(/* deprecated function */ + PLArenaPool *arena, SECItem *item, + unsigned int oldlen, unsigned int newlen); + +/* +** Reallocate the data for the specified "item". If "arena" is not NULL, +** then reallocate from there, otherwise reallocate from the heap. +** If item->data is NULL, the data is allocated (not reallocated). +** In any case, "item" is expected to be a valid SECItem pointer; +** SECFailure is returned if it is not, and the item will remain unchanged. +** If the allocation succeeds, the item is updated and SECSuccess is returned. +*/ +extern SECStatus SECITEM_ReallocItemV2(PLArenaPool *arena, SECItem *item, + unsigned int newlen); + +/* +** Compare two items returning the difference between them. +*/ +extern SECComparison SECITEM_CompareItem(const SECItem *a, const SECItem *b); + +/* +** Compare two items -- if they are the same, return true; otherwise false. +*/ +extern PRBool SECITEM_ItemsAreEqual(const SECItem *a, const SECItem *b); + +/* +** Copy "from" to "to" +*/ +extern SECStatus SECITEM_CopyItem(PLArenaPool *arena, SECItem *to, + const SECItem *from); + +/* +** Allocate an item and copy "from" into it. +*/ +extern SECItem *SECITEM_DupItem(const SECItem *from); + +/* +** Allocate an item and copy "from" into it. The item itself and the +** data it points to are both allocated from the arena. If arena is +** NULL, this function is equivalent to SECITEM_DupItem. +*/ +extern SECItem *SECITEM_ArenaDupItem(PLArenaPool *arena, const SECItem *from); + +/* +** Free "zap". If freeit is PR_TRUE then "zap" itself is freed. +*/ +extern void SECITEM_FreeItem(SECItem *zap, PRBool freeit); + +/* +** Zero and then free "zap". If freeit is PR_TRUE then "zap" itself is freed. +*/ +extern void SECITEM_ZfreeItem(SECItem *zap, PRBool freeit); + +PLHashNumber PR_CALLBACK SECITEM_Hash(const void *key); + +PRIntn PR_CALLBACK SECITEM_HashCompare(const void *k1, const void *k2); + +extern SECItemArray *SECITEM_AllocArray(PLArenaPool *arena, + SECItemArray *array, + unsigned int len); +extern SECItemArray *SECITEM_DupArray(PLArenaPool *arena, + const SECItemArray *from); +extern void SECITEM_FreeArray(SECItemArray *array, PRBool freeit); +extern void SECITEM_ZfreeArray(SECItemArray *array, PRBool freeit); + +SEC_END_PROTOS + +#endif /* _SECITEM_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secmime.h b/illumos-x86_64/usr/include/mps/secmime.h new file mode 100644 index 00000000..683cd8db --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secmime.h @@ -0,0 +1,160 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Header file for routines specific to S/MIME. Keep things that are pure + * pkcs7 out of here; this is for S/MIME policy, S/MIME interoperability, etc. + */ + +#ifndef _SECMIME_H_ +#define _SECMIME_H_ 1 + +#include "secpkcs7.h" + +/************************************************************************/ +SEC_BEGIN_PROTOS + +/* + * Initialize the local recording of the user S/MIME cipher preferences. + * This function is called once for each cipher, the order being + * important (first call records greatest preference, and so on). + * When finished, it is called with a "which" of CIPHER_FAMILID_MASK. + * If the function is called again after that, it is assumed that + * the preferences are being reset, and the old preferences are + * discarded. + * + * XXX This is for a particular user, and right now the storage is + * XXX local, static. The preference should be stored elsewhere to allow + * XXX for multiple uses of one library? How does SSL handle this; + * XXX it has something similar? + * + * - The "which" values are defined in ciferfam.h (the SMIME_* values, + * for example SMIME_DES_CBC_56). + * - If "on" is non-zero then the named cipher is enabled, otherwise + * it is disabled. (It is not necessary to call the function for + * ciphers that are disabled, however, as that is the default.) + * + * If the cipher preference is successfully recorded, SECSuccess + * is returned. Otherwise SECFailure is returned. The only errors + * are due to failure allocating memory or bad parameters/calls: + * SEC_ERROR_XXX ("which" is not in the S/MIME cipher family) + * SEC_ERROR_XXX (function is being called more times than there + * are known/expected ciphers) + */ +extern SECStatus SECMIME_EnableCipher(long which, int on); + +/* + * Initialize the local recording of the S/MIME policy. + * This function is called to enable/disable a particular cipher. + * (S/MIME encryption or decryption using a particular cipher is only + * allowed if that cipher is currently enabled.) At startup, all S/MIME + * ciphers are disabled. From that point, this function can be called + * to enable a cipher -- it is not necessary to call this to disable + * a cipher unless that cipher was previously, explicitly enabled via + * this function. + * + * XXX This is for a the current module, I think, so local, static storage + * XXX is okay. Is that correct, or could multiple uses of the same + * XXX library expect to operate under different policies? + * + * - The "which" values are defined in ciferfam.h (the SMIME_* values, + * for example SMIME_DES_CBC_56). + * - If "on" is non-zero then the named cipher is enabled, otherwise + * it is disabled. + * + * If the cipher is successfully enabled/disabled, SECSuccess is + * returned. Otherwise SECFailure is returned. The only errors + * are due to bad parameters: + * SEC_ERROR_XXX ("which" is not in the S/MIME cipher family) + * SEC_ERROR_XXX ("which" exceeds expected maximum cipher; this is + * really an internal error) + */ +extern SECStatus SECMIME_SetPolicy(long which, int on); + +/* + * Does the current policy allow S/MIME decryption of this particular + * algorithm and keysize? + */ +extern PRBool SECMIME_DecryptionAllowed(SECAlgorithmID *algid, PK11SymKey *key); + +/* + * Does the current policy allow *any* S/MIME encryption (or decryption)? + * + * This tells whether or not *any* S/MIME encryption can be done, + * according to policy. Callers may use this to do nicer user interface + * (say, greying out a checkbox so a user does not even try to encrypt + * a message when they are not allowed to) or for any reason they want + * to check whether S/MIME encryption (or decryption, for that matter) + * may be done. + * + * It takes no arguments. The return value is a simple boolean: + * PR_TRUE means encryption (or decryption) is *possible* + * (but may still fail due to other reasons, like because we cannot + * find all the necessary certs, etc.; PR_TRUE is *not* a guarantee) + * PR_FALSE means encryption (or decryption) is not permitted + * + * There are no errors from this routine. + */ +extern PRBool SECMIME_EncryptionPossible(void); + +/* + * Start an S/MIME encrypting context. + * + * "scert" is the cert for the sender. It will be checked for validity. + * "rcerts" are the certs for the recipients. They will also be checked. + * + * "certdb" is the cert database to use for verifying the certs. + * It can be NULL if a default database is available (like in the client). + * + * This function already does all of the stuff specific to S/MIME protocol + * and local policy; the return value just needs to be passed to + * SEC_PKCS7Encode() or to SEC_PKCS7EncoderStart() to create the encoded data, + * and finally to SEC_PKCS7DestroyContentInfo(). + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern SEC_PKCS7ContentInfo *SECMIME_CreateEncrypted(CERTCertificate *scert, + CERTCertificate **rcerts, + CERTCertDBHandle *certdb, + SECKEYGetPasswordKey pwfn, + void *pwfn_arg); + +/* + * Start an S/MIME signing context. + * + * "scert" is the cert that will be used to sign the data. It will be + * checked for validity. + * + * "certdb" is the cert database to use for verifying the cert. + * It can be NULL if a default database is available (like in the client). + * + * "digestalg" names the digest algorithm. (It should be SEC_OID_SHA1; + * XXX There should be SECMIME functions for hashing, or the hashing should + * be built into this interface, which we would like because we would + * support more smartcards that way, and then this argument should go away.) + * + * "digest" is the actual digest of the data. It must be provided in + * the case of detached data or NULL if the content will be included. + * + * This function already does all of the stuff specific to S/MIME protocol + * and local policy; the return value just needs to be passed to + * SEC_PKCS7Encode() or to SEC_PKCS7EncoderStart() to create the encoded data, + * and finally to SEC_PKCS7DestroyContentInfo(). + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern SEC_PKCS7ContentInfo *SECMIME_CreateSigned(CERTCertificate *scert, + CERTCertificate *ecert, + CERTCertDBHandle *certdb, + SECOidTag digestalg, + SECItem *digest, + SECKEYGetPasswordKey pwfn, + void *pwfn_arg); + +/************************************************************************/ +SEC_END_PROTOS + +#endif /* _SECMIME_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secmod.h b/illumos-x86_64/usr/include/mps/secmod.h new file mode 100644 index 00000000..fee21d6b --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secmod.h @@ -0,0 +1,223 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _SECMOD_H_ +#define _SECMOD_H_ +#include "seccomon.h" +#include "secmodt.h" +#include "prinrval.h" +#include "pkcs11.h" + +/* These mechanisms flags are visible to all other libraries. */ +/* They must be converted to internal SECMOD_*_FLAG */ +/* if used inside the functions of the security library */ +#define PUBLIC_MECH_RSA_FLAG 0x00000001ul +#define PUBLIC_MECH_DSA_FLAG 0x00000002ul +#define PUBLIC_MECH_RC2_FLAG 0x00000004ul +#define PUBLIC_MECH_RC4_FLAG 0x00000008ul +#define PUBLIC_MECH_DES_FLAG 0x00000010ul +#define PUBLIC_MECH_DH_FLAG 0x00000020ul +#define PUBLIC_MECH_FORTEZZA_FLAG 0x00000040ul +#define PUBLIC_MECH_RC5_FLAG 0x00000080ul +#define PUBLIC_MECH_SHA1_FLAG 0x00000100ul +#define PUBLIC_MECH_MD5_FLAG 0x00000200ul +#define PUBLIC_MECH_MD2_FLAG 0x00000400ul +#define PUBLIC_MECH_SSL_FLAG 0x00000800ul +#define PUBLIC_MECH_TLS_FLAG 0x00001000ul +#define PUBLIC_MECH_AES_FLAG 0x00002000ul +#define PUBLIC_MECH_SHA256_FLAG 0x00004000ul +#define PUBLIC_MECH_SHA512_FLAG 0x00008000ul +#define PUBLIC_MECH_CAMELLIA_FLAG 0x00010000ul +#define PUBLIC_MECH_SEED_FLAG 0x00020000ul +#define PUBLIC_MECH_ECC_FLAG 0x00040000ul + +#define PUBLIC_MECH_RANDOM_FLAG 0x08000000ul +#define PUBLIC_MECH_FRIENDLY_FLAG 0x10000000ul +#define PUBLIC_OWN_PW_DEFAULTS 0X20000000ul +#define PUBLIC_DISABLE_FLAG 0x40000000ul + +/* warning: reserved means reserved */ +#define PUBLIC_MECH_RESERVED_FLAGS 0x87FF0000ul + +/* These cipher flags are visible to all other libraries, */ +/* But they must be converted before used in functions */ +/* withing the security module */ +#define PUBLIC_CIPHER_FORTEZZA_FLAG 0x00000001ul + +/* warning: reserved means reserved */ +#define PUBLIC_CIPHER_RESERVED_FLAGS 0xFFFFFFFEul + +SEC_BEGIN_PROTOS + +/* + * the following functions are going to be deprecated in NSS 4.0 in + * favor of the new stan functions. + */ + +/* Initialization */ +extern SECMODModule *SECMOD_LoadModule(char *moduleSpec, SECMODModule *parent, + PRBool recurse); + +extern SECMODModule *SECMOD_LoadUserModule(char *moduleSpec, SECMODModule *parent, + PRBool recurse); + +extern SECMODModule *SECMOD_LoadUserModuleWithFunction(const char *moduleName, + CK_C_GetFunctionList fentry); + +SECStatus SECMOD_UnloadUserModule(SECMODModule *mod); + +SECMODModule *SECMOD_CreateModule(const char *lib, const char *name, + const char *param, const char *nss); +SECMODModule *SECMOD_CreateModuleEx(const char *lib, const char *name, + const char *param, const char *nss, + const char *config); +/* + * After a fork(), PKCS #11 says we need to call C_Initialize again in + * the child before we can use the module. This function causes this + * reinitialization. + * NOTE: Any outstanding handles will become invalid, which means your + * keys and contexts will fail, but new ones can be created. + * + * Setting 'force' to true means to do the reinitialization even if the + * PKCS #11 module does not seem to need it. This allows software modules + * which ignore fork to preserve their keys across the fork(). + */ +SECStatus SECMOD_RestartModules(PRBool force); + +/* Module Management */ +char **SECMOD_GetModuleSpecList(SECMODModule *module); +SECStatus SECMOD_FreeModuleSpecList(SECMODModule *module, char **moduleSpecList); + +/* protoypes */ +/* Get a list of active PKCS #11 modules */ +extern SECMODModuleList *SECMOD_GetDefaultModuleList(void); +/* Get a list of defined but not loaded PKCS #11 modules */ +extern SECMODModuleList *SECMOD_GetDeadModuleList(void); +/* Get a list of Modules which define PKCS #11 modules to load */ +extern SECMODModuleList *SECMOD_GetDBModuleList(void); + +/* lock to protect all three module lists above */ +extern SECMODListLock *SECMOD_GetDefaultModuleListLock(void); + +extern SECStatus SECMOD_UpdateModule(SECMODModule *module); + +/* lock management */ +extern void SECMOD_GetReadLock(SECMODListLock *); +extern void SECMOD_ReleaseReadLock(SECMODListLock *); + +/* Operate on modules by name */ +extern SECMODModule *SECMOD_FindModule(const char *name); +extern SECStatus SECMOD_DeleteModule(const char *name, int *type); +extern SECStatus SECMOD_DeleteModuleEx(const char *name, + SECMODModule *mod, + int *type, + PRBool permdb); +extern SECStatus SECMOD_DeleteInternalModule(const char *name); +extern PRBool SECMOD_CanDeleteInternalModule(void); +extern SECStatus SECMOD_AddNewModule(const char *moduleName, + const char *dllPath, + unsigned long defaultMechanismFlags, + unsigned long cipherEnableFlags); +extern SECStatus SECMOD_AddNewModuleEx(const char *moduleName, + const char *dllPath, + unsigned long defaultMechanismFlags, + unsigned long cipherEnableFlags, + char *modparms, + char *nssparms); + +/* database/memory management */ +extern SECMODModule *SECMOD_GetInternalModule(void); +extern SECMODModule *SECMOD_ReferenceModule(SECMODModule *module); +extern void SECMOD_DestroyModule(SECMODModule *module); +extern PK11SlotInfo *SECMOD_LookupSlot(SECMODModuleID module, + unsigned long slotID); +extern PK11SlotInfo *SECMOD_FindSlot(SECMODModule *module, const char *name); + +/* Funtion reports true if at least one of the modules */ +/* of modType has been installed */ +PRBool SECMOD_IsModulePresent(unsigned long int pubCipherEnableFlags); + +/* accessors */ +PRBool SECMOD_GetSkipFirstFlag(SECMODModule *mod); +PRBool SECMOD_GetDefaultModDBFlag(SECMODModule *mod); + +/* Functions used to convert between internal & public representation + * of Mechanism Flags and Cipher Enable Flags */ +extern unsigned long SECMOD_PubMechFlagstoInternal(unsigned long publicFlags); +extern unsigned long SECMOD_InternaltoPubMechFlags(unsigned long internalFlags); +extern unsigned long SECMOD_PubCipherFlagstoInternal(unsigned long publicFlags); + +/* + * Check to see if the module has removable slots that we may need to + * watch for. + * + * NB: This function acquires the module list lock in order to access + * mod->slotCount and mod->slots. Deadlock can occur if the caller holds the + * module list lock. Callers that already hold the module list lock must use + * SECMOD_LockedModuleHasRemovableSlots instead. + */ +PRBool SECMOD_HasRemovableSlots(SECMODModule *mod); + +/* + * Like SECMOD_HasRemovableSlots but this function does not acquire the module + * list lock. + */ +PRBool SECMOD_LockedModuleHasRemovableSlots(SECMODModule *mod); + +/* + * this function waits for a token event on any slot of a given module + * This function should not be called from more than one thread of the + * same process (though other threads can make other library calls + * on this module while this call is blocked). + * + * Caller must not hold a module list read lock. + */ +PK11SlotInfo *SECMOD_WaitForAnyTokenEvent(SECMODModule *mod, + unsigned long flags, PRIntervalTime latency); +/* + * Warning: the SECMOD_CancelWait function is highly destructive, potentially + * finalizing the module 'mod' (causing inprogress operations to fail, + * and session key material to disappear). It should only be called when + * shutting down the module. + */ +SECStatus SECMOD_CancelWait(SECMODModule *mod); + +/* + * check to see if the module has added new slots. PKCS 11 v2.20 allows for + * modules to add new slots, but never remove them. Slots not be added between + * a call to C_GetSlotLlist(Flag, NULL, &count) and the corresponding + * C_GetSlotList(flag, &data, &count) so that the array doesn't accidently + * grow on the caller. It is permissible for the slots to increase between + * corresponding calls with NULL to get the size. + * + * Caller must not hold a module list read lock. + */ +SECStatus SECMOD_UpdateSlotList(SECMODModule *mod); + +/* + * Utilities to expose policy strings to applications: + * + * Policy strings are used by system configuration to specify what algorithms + * are included by policy. Each algorithm as a bitmask of operations allowed + * for that policy (Sign, SSL_KX, etc). Algorithm policies are tied to a oid, + * usually the primary oid used for that algorithm in X.509. + * In addition to policy oids, NSS has options, which are selected by a + * PRUint32. Options return an integer value, usually a limit (max key size, + * min key size, etc). + */ +/* Fetch the oid for a particular policy based on the string used to configure + * that policy. Policy are organized into logical list (ECC, HASH, MAC, + * CIPHER, SSL-KX, etc.). The search is restricted to a partular list unless + * ANY is specified). policy and list are case insensitive */ +SECOidTag SECMOD_PolicyStringToOid(const char *policy, const char *list); +/* fetch the Option integer based on the option string */ +PRUint32 SECMOD_PolicyStringToOpt(const char *optionString); +/* fetch a string descript of a particular bit value. The first match that has + * any of the requested bits is returns unless exact is specified, in which + * case the string must map to all existing bits. If no match is found, NULL + * is returned */ +const char *SECMOD_FlagsToPolicyString(PRUint32 val, PRBool exact); + +SEC_END_PROTOS + +#endif diff --git a/illumos-x86_64/usr/include/mps/secmodt.h b/illumos-x86_64/usr/include/mps/secmodt.h new file mode 100644 index 00000000..5f15e596 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secmodt.h @@ -0,0 +1,448 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _SECMODT_H_ +#define _SECMODT_H_ 1 + +#include "nssrwlkt.h" +#include "nssilckt.h" +#include "secoid.h" +#include "secasn1.h" +#include "pkcs11t.h" +#include "utilmodt.h" + +SEC_BEGIN_PROTOS + +/* find a better home for these... */ +extern const SEC_ASN1Template SECKEY_PointerToEncryptedPrivateKeyInfoTemplate[]; +SEC_ASN1_CHOOSER_DECLARE(SECKEY_PointerToEncryptedPrivateKeyInfoTemplate) +extern const SEC_ASN1Template SECKEY_EncryptedPrivateKeyInfoTemplate[]; +SEC_ASN1_CHOOSER_DECLARE(SECKEY_EncryptedPrivateKeyInfoTemplate) +extern const SEC_ASN1Template SECKEY_PrivateKeyInfoTemplate[]; +SEC_ASN1_CHOOSER_DECLARE(SECKEY_PrivateKeyInfoTemplate) +extern const SEC_ASN1Template SECKEY_PointerToPrivateKeyInfoTemplate[]; +SEC_ASN1_CHOOSER_DECLARE(SECKEY_PointerToPrivateKeyInfoTemplate) + +SEC_END_PROTOS + +/* PKCS11 needs to be included */ +typedef struct SECMODModuleStr SECMODModule; +typedef struct SECMODModuleListStr SECMODModuleList; +typedef NSSRWLock SECMODListLock; +typedef struct PK11SlotInfoStr PK11SlotInfo; /* defined in secmodti.h */ +typedef struct NSSUTILPreSlotInfoStr PK11PreSlotInfo; /* defined in secmodti.h */ +typedef struct PK11SymKeyStr PK11SymKey; /* defined in secmodti.h */ +typedef struct PK11ContextStr PK11Context; /* defined in secmodti.h */ +typedef struct PK11SlotListStr PK11SlotList; +typedef struct PK11SlotListElementStr PK11SlotListElement; +typedef struct PK11RSAGenParamsStr PK11RSAGenParams; +typedef unsigned long SECMODModuleID; +typedef struct PK11DefaultArrayEntryStr PK11DefaultArrayEntry; +typedef struct PK11GenericObjectStr PK11GenericObject; +typedef void (*PK11FreeDataFunc)(void *); + +struct SECMODModuleStr { + PLArenaPool *arena; + PRBool internal; /* true of internally linked modules, false + * for the loaded modules */ + PRBool loaded; /* Set to true if module has been loaded */ + PRBool isFIPS; /* Set to true if module is finst internal */ + char *dllName; /* name of the shared library which implements + * this module */ + char *commonName; /* name of the module to display to the user */ + void *library; /* pointer to the library. opaque. used only by + * pk11load.c */ + void *functionList; /* The PKCS #11 function table */ + PZLock *refLock; /* only used pk11db.c */ + int refCount; /* Module reference count */ + PK11SlotInfo **slots; /* array of slot points attached to this mod*/ + int slotCount; /* count of slot in above array */ + PK11PreSlotInfo *slotInfo; /* special info about slots default settings */ + int slotInfoCount; /* count */ + SECMODModuleID moduleID; /* ID so we can find this module again */ + PRBool isThreadSafe; + unsigned long ssl[2]; /* SSL cipher enable flags */ + char *libraryParams; /* Module specific parameters */ + void *moduleDBFunc; /* function to return module configuration data*/ + SECMODModule *parent; /* module that loaded us */ + PRBool isCritical; /* This module must load successfully */ + PRBool isModuleDB; /* this module has lists of PKCS #11 modules */ + PRBool moduleDBOnly; /* this module only has lists of PKCS #11 modules */ + int trustOrder; /* order for this module's certificate trust rollup */ + int cipherOrder; /* order for cipher operations */ + unsigned long evControlMask; /* control the running and shutdown of slot + * events (SECMOD_WaitForAnyTokenEvent) */ + CK_VERSION cryptokiVersion; /* version of this library */ + CK_FLAGS flags; /* pkcs11 v3 flags */ + /* Warning this could go way in future versions of NSS + * when FIPS indicators wind up in the functionList */ + CK_NSS_GetFIPSStatus fipsIndicator; +}; + +/* evControlMask flags */ +/* + * These bits tell the current state of a SECMOD_WaitForAnyTokenEvent. + * + * SECMOD_WAIT_PKCS11_EVENT - we're waiting in the PKCS #11 module in + * C_WaitForSlotEvent(). + * SECMOD_WAIT_SIMULATED_EVENT - we're waiting in the NSS simulation code + * which polls for token insertion and removal events. + * SECMOD_END_WAIT - SECMOD_CancelWait has been called while the module is + * waiting in SECMOD_WaitForAnyTokenEvent. SECMOD_WaitForAnyTokenEvent + * should return immediately to it's caller. + */ +#define SECMOD_END_WAIT 0x01 +#define SECMOD_WAIT_SIMULATED_EVENT 0x02 +#define SECMOD_WAIT_PKCS11_EVENT 0x04 + +struct SECMODModuleListStr { + SECMODModuleList *next; + SECMODModule *module; +}; + +struct PK11SlotListStr { + PK11SlotListElement *head; + PK11SlotListElement *tail; + PZLock *lock; +}; + +struct PK11SlotListElementStr { + PK11SlotListElement *next; + PK11SlotListElement *prev; + PK11SlotInfo *slot; + int refCount; +}; + +struct PK11RSAGenParamsStr { + int keySizeInBits; + unsigned long pe; +}; + +typedef enum { + PK11CertListUnique = 0, /* get one instance of all certs */ + PK11CertListUser = 1, /* get all instances of user certs */ + PK11CertListRootUnique = 2, /* get one instance of CA certs without a private key. + * deprecated. Use PK11CertListCAUnique + */ + PK11CertListCA = 3, /* get all instances of CA certs */ + PK11CertListCAUnique = 4, /* get one instance of CA certs */ + PK11CertListUserUnique = 5, /* get one instance of user certs */ + PK11CertListAll = 6 /* get all instances of all certs */ +} PK11CertListType; + +/* + * Entry into the array which lists all the legal bits for the default flags + * in the slot, their definition, and the PKCS #11 mechanism they represent. + * Always statically allocated. + */ +struct PK11DefaultArrayEntryStr { + const char *name; + unsigned long flag; + unsigned long mechanism; /* this is a long so we don't include the + * whole pkcs 11 world to use this header */ +}; + +/* + * PK11AttrFlags + * + * A 32-bit bitmask of PK11_ATTR_XXX flags + */ +typedef PRUint32 PK11AttrFlags; + +/* + * PK11_ATTR_XXX + * + * The following PK11_ATTR_XXX bitflags are used to specify + * PKCS #11 object attributes that have Boolean values. Some NSS + * functions have a "PK11AttrFlags attrFlags" parameter whose value + * is the logical OR of these bitflags. NSS use these bitflags on + * private keys or secret keys. Some of these bitflags also apply + * to the public keys associated with the private keys. + * + * For each PKCS #11 object attribute, we need two bitflags to + * specify not only "true" and "false" but also "default". For + * example, PK11_ATTR_PRIVATE and PK11_ATTR_PUBLIC control the + * CKA_PRIVATE attribute. If PK11_ATTR_PRIVATE is set, we add + * { CKA_PRIVATE, &cktrue, sizeof(CK_BBOOL) } + * to the template. If PK11_ATTR_PUBLIC is set, we add + * { CKA_PRIVATE, &ckfalse, sizeof(CK_BBOOL) } + * to the template. If neither flag is set, we don't add any + * CKA_PRIVATE entry to the template. + */ + +/* + * Attributes for PKCS #11 storage objects, which include not only + * keys but also certificates and domain parameters. + */ + +/* + * PK11_ATTR_TOKEN + * PK11_ATTR_SESSION + * + * These two flags determine whether the object is a token or + * session object. + * + * These two flags are related and cannot both be set. + * If the PK11_ATTR_TOKEN flag is set, the object is a token + * object. If the PK11_ATTR_SESSION flag is set, the object is + * a session object. If neither flag is set, the object is *by + * default* a session object. + * + * These two flags specify the value of the PKCS #11 CKA_TOKEN + * attribute. + */ +#define PK11_ATTR_TOKEN 0x00000001L +#define PK11_ATTR_SESSION 0x00000002L + +/* + * PK11_ATTR_PRIVATE + * PK11_ATTR_PUBLIC + * + * These two flags determine whether the object is a private or + * public object. A user may not access a private object until the + * user has authenticated to the token. + * + * These two flags are related and cannot both be set. + * If the PK11_ATTR_PRIVATE flag is set, the object is a private + * object. If the PK11_ATTR_PUBLIC flag is set, the object is a + * public object. If neither flag is set, it is token-specific + * whether the object is private or public. + * + * These two flags specify the value of the PKCS #11 CKA_PRIVATE + * attribute. NSS only uses this attribute on private and secret + * keys, so public keys created by NSS get the token-specific + * default value of the CKA_PRIVATE attribute. + */ +#define PK11_ATTR_PRIVATE 0x00000004L +#define PK11_ATTR_PUBLIC 0x00000008L + +/* + * PK11_ATTR_MODIFIABLE + * PK11_ATTR_UNMODIFIABLE + * + * These two flags determine whether the object is modifiable or + * read-only. + * + * These two flags are related and cannot both be set. + * If the PK11_ATTR_MODIFIABLE flag is set, the object can be + * modified. If the PK11_ATTR_UNMODIFIABLE flag is set, the object + * is read-only. If neither flag is set, the object is *by default* + * modifiable. + * + * These two flags specify the value of the PKCS #11 CKA_MODIFIABLE + * attribute. + */ +#define PK11_ATTR_MODIFIABLE 0x00000010L +#define PK11_ATTR_UNMODIFIABLE 0x00000020L + +/* Attributes for PKCS #11 key objects. */ + +/* + * PK11_ATTR_SENSITIVE + * PK11_ATTR_INSENSITIVE + * + * These two flags are related and cannot both be set. + * If the PK11_ATTR_SENSITIVE flag is set, the key is sensitive. + * If the PK11_ATTR_INSENSITIVE flag is set, the key is not + * sensitive. If neither flag is set, it is token-specific whether + * the key is sensitive or not. + * + * If a key is sensitive, certain attributes of the key cannot be + * revealed in plaintext outside the token. + * + * This flag specifies the value of the PKCS #11 CKA_SENSITIVE + * attribute. Although the default value of the CKA_SENSITIVE + * attribute for secret keys is CK_FALSE per PKCS #11, some FIPS + * tokens set the default value to CK_TRUE because only CK_TRUE + * is allowed. So in practice the default value of this attribute + * is token-specific, hence the need for two bitflags. + */ +#define PK11_ATTR_SENSITIVE 0x00000040L +#define PK11_ATTR_INSENSITIVE 0x00000080L + +/* + * PK11_ATTR_EXTRACTABLE + * PK11_ATTR_UNEXTRACTABLE + * + * These two flags are related and cannot both be set. + * If the PK11_ATTR_EXTRACTABLE flag is set, the key is extractable + * and can be wrapped. If the PK11_ATTR_UNEXTRACTABLE flag is set, + * the key is not extractable, and certain attributes of the key + * cannot be revealed in plaintext outside the token (just like a + * sensitive key). If neither flag is set, it is token-specific + * whether the key is extractable or not. + * + * These two flags specify the value of the PKCS #11 CKA_EXTRACTABLE + * attribute. + */ +#define PK11_ATTR_EXTRACTABLE 0x00000100L +#define PK11_ATTR_UNEXTRACTABLE 0x00000200L + +/* Cryptographic module types */ +#define SECMOD_EXTERNAL 0 /* external module */ +#define SECMOD_INTERNAL 1 /* internal default module */ +#define SECMOD_FIPS 2 /* internal fips module */ + +/* default module configuration strings */ +#define SECMOD_SLOT_FLAGS "slotFlags=[RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512]" + +#define SECMOD_MAKE_NSS_FLAGS(fips, slot) \ + "Flags=internal,critical" fips " slotparams=(" #slot "={" SECMOD_SLOT_FLAGS "})" + +#define SECMOD_INT_NAME "NSS Internal PKCS #11 Module" +#define SECMOD_INT_FLAGS SECMOD_MAKE_NSS_FLAGS("", 1) +#define SECMOD_FIPS_NAME "NSS Internal FIPS PKCS #11 Module" +#define SECMOD_FIPS_FLAGS SECMOD_MAKE_NSS_FLAGS(",fips", 3) + +/* + * What is the origin of a given Key. Normally this doesn't matter, but + * the fortezza code needs to know if it needs to invoke the SSL3 fortezza + * hack. + */ +typedef enum { + PK11_OriginNULL = 0, /* There is not key, it's a null SymKey */ + PK11_OriginDerive = 1, /* Key was derived from some other key */ + PK11_OriginGenerated = 2, /* Key was generated (also PBE keys) */ + PK11_OriginFortezzaHack = 3, /* Key was marked for fortezza hack */ + PK11_OriginUnwrap = 4 /* Key was unwrapped or decrypted */ +} PK11Origin; + +/* PKCS #11 disable reasons */ +typedef enum { + PK11_DIS_NONE = 0, + PK11_DIS_USER_SELECTED = 1, + PK11_DIS_COULD_NOT_INIT_TOKEN = 2, + PK11_DIS_TOKEN_VERIFY_FAILED = 3, + PK11_DIS_TOKEN_NOT_PRESENT = 4 +} PK11DisableReasons; + +/* types of PKCS #11 objects + * used to identify which NSS data structure is + * passed to the PK11_Raw* functions. Types map as follows: + * PK11_TypeGeneric PK11GenericObject * + * PK11_TypePrivKey SECKEYPrivateKey * + * PK11_TypePubKey SECKEYPublicKey * + * PK11_TypeSymKey PK11SymKey * + * PK11_TypeCert CERTCertificate * (currently not used). + */ +typedef enum { + PK11_TypeGeneric = 0, + PK11_TypePrivKey = 1, + PK11_TypePubKey = 2, + PK11_TypeCert = 3, + PK11_TypeSymKey = 4 +} PK11ObjectType; + +/* function pointer type for password callback function. + * This type is passed in to PK11_SetPasswordFunc() + */ +typedef char *(PR_CALLBACK *PK11PasswordFunc)(PK11SlotInfo *slot, PRBool retry, void *arg); +typedef PRBool(PR_CALLBACK *PK11VerifyPasswordFunc)(PK11SlotInfo *slot, void *arg); +typedef PRBool(PR_CALLBACK *PK11IsLoggedInFunc)(PK11SlotInfo *slot, void *arg); + +/* + * Special strings the password callback function can return only if + * the slot is an protected auth path slot. + */ +#define PK11_PW_RETRY "RETRY" /* an failed attempt to authenticate \ + * has already been made, just retry \ + * the operation */ +#define PK11_PW_AUTHENTICATED "AUTH" /* a successful attempt to authenticate \ + * has completed. Continue without \ + * another call to C_Login */ +/* All other non-null values mean that that NSS could call C_Login to force + * the authentication. The following define is to aid applications in + * documenting that is what it's trying to do */ +#define PK11_PW_TRY "TRY" /* Default: a prompt has been presented \ + * to the user, initiate a C_Login \ + * to authenticate the token */ + +/* + * PKCS #11 key structures + */ + +/* +** Attributes +*/ +struct SECKEYAttributeStr { + SECItem attrType; + SECItem **attrValue; +}; +typedef struct SECKEYAttributeStr SECKEYAttribute; + +/* +** A PKCS#8 private key info object +*/ +struct SECKEYPrivateKeyInfoStr { + PLArenaPool *arena; + SECItem version; + SECAlgorithmID algorithm; + SECItem privateKey; + SECKEYAttribute **attributes; +}; +typedef struct SECKEYPrivateKeyInfoStr SECKEYPrivateKeyInfo; + +/* +** A PKCS#8 private key info object +*/ +struct SECKEYEncryptedPrivateKeyInfoStr { + PLArenaPool *arena; + SECAlgorithmID algorithm; + SECItem encryptedData; +}; +typedef struct SECKEYEncryptedPrivateKeyInfoStr SECKEYEncryptedPrivateKeyInfo; + +/* + * token removal detection + */ +typedef enum { + PK11TokenNotRemovable = 0, + PK11TokenPresent = 1, + PK11TokenChanged = 2, + PK11TokenRemoved = 3 +} PK11TokenStatus; + +typedef enum { + PK11TokenRemovedOrChangedEvent = 0, + PK11TokenPresentEvent = 1 +} PK11TokenEvent; + +/* + * CRL Import Flags + */ +#define CRL_IMPORT_DEFAULT_OPTIONS 0x00000000 +#define CRL_IMPORT_BYPASS_CHECKS 0x00000001 + +/* + * Merge Error Log + */ +typedef struct PK11MergeLogStr PK11MergeLog; +typedef struct PK11MergeLogNodeStr PK11MergeLogNode; + +/* These need to be global, leave some open fields so we can 'expand' + * these without breaking binary compatibility */ +struct PK11MergeLogNodeStr { + PK11MergeLogNode *next; /* next entry in the list */ + PK11MergeLogNode *prev; /* last entry in the list */ + PK11GenericObject *object; /* object that failed */ + int error; /* what the error was */ + CK_RV reserved1; + unsigned long reserved2; /* future flags */ + unsigned long reserved3; /* future scalar */ + void *reserved4; /* future pointer */ + void *reserved5; /* future expansion pointer */ +}; + +struct PK11MergeLogStr { + PK11MergeLogNode *head; + PK11MergeLogNode *tail; + PLArenaPool *arena; + int version; + unsigned long reserved1; + unsigned long reserved2; + unsigned long reserved3; + void *reserverd4; + void *reserverd5; +}; + +#endif /*_SECMODT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secoid.h b/illumos-x86_64/usr/include/mps/secoid.h new file mode 100644 index 00000000..173ce1df --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secoid.h @@ -0,0 +1,169 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _SECOID_H_ +#define _SECOID_H_ + +#include "utilrename.h" + +/* + * secoid.h - public data structures and prototypes for ASN.1 OID functions + */ + +#include "plarena.h" + +#include "seccomon.h" +#include "secoidt.h" +#include "secasn1t.h" + +SEC_BEGIN_PROTOS + +extern const SEC_ASN1Template SECOID_AlgorithmIDTemplate[]; + +/* This functions simply returns the address of the above-declared template. */ +SEC_ASN1_CHOOSER_DECLARE(SECOID_AlgorithmIDTemplate) + +/* + * OID handling routines + */ +extern SECOidData *SECOID_FindOID(const SECItem *oid); +extern SECOidTag SECOID_FindOIDTag(const SECItem *oid); +extern SECOidData *SECOID_FindOIDByTag(SECOidTag tagnum); +extern SECOidData *SECOID_FindOIDByMechanism(unsigned long mechanism); + +/****************************************/ +/* +** Algorithm id handling operations +*/ + +/* +** Fill in an algorithm-ID object given a tag and some parameters. +** "aid" where the DER encoded algorithm info is stored (memory +** is allocated) +** "tag" the tag number defining the algorithm +** "params" if not NULL, the parameters to go with the algorithm +*/ +extern SECStatus SECOID_SetAlgorithmID(PLArenaPool *arena, SECAlgorithmID *aid, + SECOidTag tag, SECItem *params); + +/* +** Copy the "src" object to "dest". Memory is allocated in "dest" for +** each of the appropriate sub-objects. Memory in "dest" is not freed +** before memory is allocated (use SECOID_DestroyAlgorithmID(dest, PR_FALSE) +** to do that). +*/ +extern SECStatus SECOID_CopyAlgorithmID(PLArenaPool *arena, SECAlgorithmID *dest, + const SECAlgorithmID *src); + +/* +** Get the tag number for the given algorithm-id object. +*/ +extern SECOidTag SECOID_GetAlgorithmTag(const SECAlgorithmID *aid); + +/* +** Get the number of valid tags in the current system. This includes dynamic +** tags. This value can grow but never shrink. This is more reliable than using +** SEC_OID_TOTAL because 1) it includes dynamic tags, and 2) it includes any +** new tags the nss library has added since the last time the application +** was compilied. +*/ +extern SECOidTag SECOID_GetTotalTags(void); + +/* +** Destroy an algorithm-id object. +** "aid" the certificate-request to destroy +** "freeit" if PR_TRUE then free the object as well as its sub-objects +*/ +extern void SECOID_DestroyAlgorithmID(SECAlgorithmID *aid, PRBool freeit); + +/* +** Compare two algorithm-id objects, returning the difference between +** them. +*/ +extern SECComparison SECOID_CompareAlgorithmID(SECAlgorithmID *a, + SECAlgorithmID *b); + +extern PRBool SECOID_KnownCertExtenOID(SECItem *extenOid); + +/* Given a tag number, return a string describing it. + */ +extern const char *SECOID_FindOIDTagDescription(SECOidTag tagnum); + +/* Add a dynamic SECOidData to the dynamic OID table. +** Routine copies the src entry, and returns the new SECOidTag. +** Returns SEC_OID_INVALID if failed to add for some reason. +*/ +extern SECOidTag SECOID_AddEntry(const SECOidData *src); + +/* + * initialize the oid data structures. + */ +extern SECStatus SECOID_Init(void); + +/* + * free up the oid data structures. + */ +extern SECStatus SECOID_Shutdown(void); + +/* if to->data is not NULL, and to->len is large enough to hold the result, + * then the resultant OID will be copyed into to->data, and to->len will be + * changed to show the actual OID length. + * Otherwise, memory for the OID will be allocated (from the caller's + * PLArenaPool, if pool is non-NULL) and to->data will receive the address + * of the allocated data, and to->len will receive the OID length. + * The original value of to->data is not freed when a new buffer is allocated. + * + * The input string may begin with "OID." and this still be ignored. + * The length of the input string is given in len. If len == 0, then + * len will be computed as strlen(from), meaning it must be NUL terminated. + * It is an error if from == NULL, or if *from == '\0'. + */ +extern SECStatus SEC_StringToOID(PLArenaPool *pool, SECItem *to, + const char *from, PRUint32 len); + +extern void UTIL_SetForkState(PRBool forked); + +/* + * Accessor functions for new opaque extended SECOID table. + * Any of these functions may return SECSuccess or SECFailure with the error + * code set to SEC_ERROR_UNKNOWN_OBJECT_TYPE if the SECOidTag is out of range. + */ + +/* The Get function outputs the 32-bit value associated with the SECOidTag. + * Flags bits are the NSS_USE_ALG_ #defines in "secoidt.h". + * Default value for any algorithm is 0xffffffff (enabled for all purposes). + * No value is output if function returns SECFailure. + */ +extern SECStatus NSS_GetAlgorithmPolicy(SECOidTag tag, PRUint32 *pValue); + +/* The Set function modifies the stored value according to the following + * algorithm: + * policy[tag] = (policy[tag] & ~clearBits) | setBits; + */ +extern SECStatus +NSS_SetAlgorithmPolicy(SECOidTag tag, PRUint32 setBits, PRUint32 clearBits); + +/* Set all the tags to a particular policy (like to clear all S/MIME bits */ +extern SECStatus +NSS_SetAlgorithmPolicyAll(PRUint32 setBits, PRUint32 clearBits); + +/* Get all the tags with a particular policy. The policy must match the exact + * value after applying the mask. Caller is responsible for + * freeing the tag array with PORT_Free() */ +extern SECStatus +NSS_GetAlgorithmPolicyAll(PRUint32 maskBits, PRUint32 valueBits, + SECOidTag **outTags, int *outTagCount); + +/* Lock the policy so NSS_SetAlgorithmPolicy (and other policy functions) + * No longer function */ +void +NSS_LockPolicy(void); + +/* return true if policy changes are now locked out */ +PRBool +NSS_IsPolicyLocked(void); + +SEC_END_PROTOS + +#endif /* _SECOID_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secoidt.h b/illumos-x86_64/usr/include/mps/secoidt.h new file mode 100644 index 00000000..15499ece --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secoidt.h @@ -0,0 +1,639 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _SECOIDT_H_ +#define _SECOIDT_H_ + +#include "utilrename.h" + +/* + * secoidt.h - public data structures for ASN.1 OID functions + */ + +#include "secitem.h" + +typedef struct SECOidDataStr SECOidData; +typedef struct SECAlgorithmIDStr SECAlgorithmID; + +/* +** An X.500 algorithm identifier +*/ +struct SECAlgorithmIDStr { + SECItem algorithm; + SECItem parameters; +}; + +/* + * Misc object IDs - these numbers are for convenient handling. + * They are mapped into real object IDs + * + * NOTE: the order of these entries must mach the array "oids" of SECOidData + * in util/secoid.c. + */ +typedef enum { + SEC_OID_UNKNOWN = 0, + SEC_OID_MD2 = 1, + SEC_OID_MD4 = 2, + SEC_OID_MD5 = 3, + SEC_OID_SHA1 = 4, + SEC_OID_RC2_CBC = 5, + SEC_OID_RC4 = 6, + SEC_OID_DES_EDE3_CBC = 7, + SEC_OID_RC5_CBC_PAD = 8, + SEC_OID_DES_ECB = 9, + SEC_OID_DES_CBC = 10, + SEC_OID_DES_OFB = 11, + SEC_OID_DES_CFB = 12, + SEC_OID_DES_MAC = 13, + SEC_OID_DES_EDE = 14, + SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE = 15, + SEC_OID_PKCS1_RSA_ENCRYPTION = 16, + SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION = 17, + SEC_OID_PKCS1_MD4_WITH_RSA_ENCRYPTION = 18, + SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION = 19, + SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION = 20, + SEC_OID_PKCS5_PBE_WITH_MD2_AND_DES_CBC = 21, + SEC_OID_PKCS5_PBE_WITH_MD5_AND_DES_CBC = 22, + SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC = 23, + SEC_OID_PKCS7 = 24, + SEC_OID_PKCS7_DATA = 25, + SEC_OID_PKCS7_SIGNED_DATA = 26, + SEC_OID_PKCS7_ENVELOPED_DATA = 27, + SEC_OID_PKCS7_SIGNED_ENVELOPED_DATA = 28, + SEC_OID_PKCS7_DIGESTED_DATA = 29, + SEC_OID_PKCS7_ENCRYPTED_DATA = 30, + SEC_OID_PKCS9_EMAIL_ADDRESS = 31, + SEC_OID_PKCS9_UNSTRUCTURED_NAME = 32, + SEC_OID_PKCS9_CONTENT_TYPE = 33, + SEC_OID_PKCS9_MESSAGE_DIGEST = 34, + SEC_OID_PKCS9_SIGNING_TIME = 35, + SEC_OID_PKCS9_COUNTER_SIGNATURE = 36, + SEC_OID_PKCS9_CHALLENGE_PASSWORD = 37, + SEC_OID_PKCS9_UNSTRUCTURED_ADDRESS = 38, + SEC_OID_PKCS9_EXTENDED_CERTIFICATE_ATTRIBUTES = 39, + SEC_OID_PKCS9_SMIME_CAPABILITIES = 40, + SEC_OID_AVA_COMMON_NAME = 41, + SEC_OID_AVA_COUNTRY_NAME = 42, + SEC_OID_AVA_LOCALITY = 43, + SEC_OID_AVA_STATE_OR_PROVINCE = 44, + SEC_OID_AVA_ORGANIZATION_NAME = 45, + SEC_OID_AVA_ORGANIZATIONAL_UNIT_NAME = 46, + SEC_OID_AVA_DN_QUALIFIER = 47, + SEC_OID_AVA_DC = 48, + + SEC_OID_NS_TYPE_GIF = 49, + SEC_OID_NS_TYPE_JPEG = 50, + SEC_OID_NS_TYPE_URL = 51, + SEC_OID_NS_TYPE_HTML = 52, + SEC_OID_NS_TYPE_CERT_SEQUENCE = 53, + SEC_OID_MISSI_KEA_DSS_OLD = 54, + SEC_OID_MISSI_DSS_OLD = 55, + SEC_OID_MISSI_KEA_DSS = 56, + SEC_OID_MISSI_DSS = 57, + SEC_OID_MISSI_KEA = 58, + SEC_OID_MISSI_ALT_KEA = 59, + + /* Netscape private certificate extensions */ + SEC_OID_NS_CERT_EXT_NETSCAPE_OK = 60, + SEC_OID_NS_CERT_EXT_ISSUER_LOGO = 61, + SEC_OID_NS_CERT_EXT_SUBJECT_LOGO = 62, + SEC_OID_NS_CERT_EXT_CERT_TYPE = 63, + SEC_OID_NS_CERT_EXT_BASE_URL = 64, + SEC_OID_NS_CERT_EXT_REVOCATION_URL = 65, + SEC_OID_NS_CERT_EXT_CA_REVOCATION_URL = 66, + SEC_OID_NS_CERT_EXT_CA_CRL_URL = 67, + SEC_OID_NS_CERT_EXT_CA_CERT_URL = 68, + SEC_OID_NS_CERT_EXT_CERT_RENEWAL_URL = 69, + SEC_OID_NS_CERT_EXT_CA_POLICY_URL = 70, + SEC_OID_NS_CERT_EXT_HOMEPAGE_URL = 71, + SEC_OID_NS_CERT_EXT_ENTITY_LOGO = 72, + SEC_OID_NS_CERT_EXT_USER_PICTURE = 73, + SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME = 74, + SEC_OID_NS_CERT_EXT_COMMENT = 75, + SEC_OID_NS_CERT_EXT_LOST_PASSWORD_URL = 76, + SEC_OID_NS_CERT_EXT_CERT_RENEWAL_TIME = 77, + SEC_OID_NS_KEY_USAGE_GOVT_APPROVED = 78, + + /* x.509 v3 Extensions */ + SEC_OID_X509_SUBJECT_DIRECTORY_ATTR = 79, + SEC_OID_X509_SUBJECT_KEY_ID = 80, + SEC_OID_X509_KEY_USAGE = 81, + SEC_OID_X509_PRIVATE_KEY_USAGE_PERIOD = 82, + SEC_OID_X509_SUBJECT_ALT_NAME = 83, + SEC_OID_X509_ISSUER_ALT_NAME = 84, + SEC_OID_X509_BASIC_CONSTRAINTS = 85, + SEC_OID_X509_NAME_CONSTRAINTS = 86, + SEC_OID_X509_CRL_DIST_POINTS = 87, + SEC_OID_X509_CERTIFICATE_POLICIES = 88, + SEC_OID_X509_POLICY_MAPPINGS = 89, + SEC_OID_X509_POLICY_CONSTRAINTS = 90, + SEC_OID_X509_AUTH_KEY_ID = 91, + SEC_OID_X509_EXT_KEY_USAGE = 92, + SEC_OID_X509_AUTH_INFO_ACCESS = 93, + + SEC_OID_X509_CRL_NUMBER = 94, + SEC_OID_X509_REASON_CODE = 95, + SEC_OID_X509_INVALID_DATE = 96, + /* End of x.509 v3 Extensions */ + + SEC_OID_X500_RSA_ENCRYPTION = 97, + + /* alg 1485 additions */ + SEC_OID_RFC1274_UID = 98, + SEC_OID_RFC1274_MAIL = 99, + + /* PKCS 12 additions */ + SEC_OID_PKCS12 = 100, + SEC_OID_PKCS12_MODE_IDS = 101, + SEC_OID_PKCS12_ESPVK_IDS = 102, + SEC_OID_PKCS12_BAG_IDS = 103, + SEC_OID_PKCS12_CERT_BAG_IDS = 104, + SEC_OID_PKCS12_OIDS = 105, + SEC_OID_PKCS12_PBE_IDS = 106, + SEC_OID_PKCS12_SIGNATURE_IDS = 107, + SEC_OID_PKCS12_ENVELOPING_IDS = 108, + /* SEC_OID_PKCS12_OFFLINE_TRANSPORT_MODE, + SEC_OID_PKCS12_ONLINE_TRANSPORT_MODE, */ + SEC_OID_PKCS12_PKCS8_KEY_SHROUDING = 109, + SEC_OID_PKCS12_KEY_BAG_ID = 110, + SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID = 111, + SEC_OID_PKCS12_SECRET_BAG_ID = 112, + SEC_OID_PKCS12_X509_CERT_CRL_BAG = 113, + SEC_OID_PKCS12_SDSI_CERT_BAG = 114, + SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC4 = 115, + SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC4 = 116, + SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC = 117, + SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC = 118, + SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC = 119, + SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_128_BIT_RC4 = 120, + SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_40_BIT_RC4 = 121, + SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_TRIPLE_DES = 122, + SEC_OID_PKCS12_RSA_SIGNATURE_WITH_SHA1_DIGEST = 123, + /* end of PKCS 12 additions */ + + /* DSA signatures */ + SEC_OID_ANSIX9_DSA_SIGNATURE = 124, + SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST = 125, + SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST = 126, + + /* Verisign OIDs */ + SEC_OID_VERISIGN_USER_NOTICES = 127, + + /* PKIX OIDs */ + SEC_OID_PKIX_CPS_POINTER_QUALIFIER = 128, + SEC_OID_PKIX_USER_NOTICE_QUALIFIER = 129, + SEC_OID_PKIX_OCSP = 130, + SEC_OID_PKIX_OCSP_BASIC_RESPONSE = 131, + SEC_OID_PKIX_OCSP_NONCE = 132, + SEC_OID_PKIX_OCSP_CRL = 133, + SEC_OID_PKIX_OCSP_RESPONSE = 134, + SEC_OID_PKIX_OCSP_NO_CHECK = 135, + SEC_OID_PKIX_OCSP_ARCHIVE_CUTOFF = 136, + SEC_OID_PKIX_OCSP_SERVICE_LOCATOR = 137, + SEC_OID_PKIX_REGCTRL_REGTOKEN = 138, + SEC_OID_PKIX_REGCTRL_AUTHENTICATOR = 139, + SEC_OID_PKIX_REGCTRL_PKIPUBINFO = 140, + SEC_OID_PKIX_REGCTRL_PKI_ARCH_OPTIONS = 141, + SEC_OID_PKIX_REGCTRL_OLD_CERT_ID = 142, + SEC_OID_PKIX_REGCTRL_PROTOCOL_ENC_KEY = 143, + SEC_OID_PKIX_REGINFO_UTF8_PAIRS = 144, + SEC_OID_PKIX_REGINFO_CERT_REQUEST = 145, + SEC_OID_EXT_KEY_USAGE_SERVER_AUTH = 146, + SEC_OID_EXT_KEY_USAGE_CLIENT_AUTH = 147, + SEC_OID_EXT_KEY_USAGE_CODE_SIGN = 148, + SEC_OID_EXT_KEY_USAGE_EMAIL_PROTECT = 149, + SEC_OID_EXT_KEY_USAGE_TIME_STAMP = 150, + SEC_OID_OCSP_RESPONDER = 151, + + /* Netscape Algorithm OIDs */ + SEC_OID_NETSCAPE_SMIME_KEA = 152, + + /* Skipjack OID -- ### mwelch temporary */ + SEC_OID_FORTEZZA_SKIPJACK = 153, + + /* PKCS 12 V2 oids */ + SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC4 = 154, + SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC4 = 155, + SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_3KEY_TRIPLE_DES_CBC = 156, + SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_2KEY_TRIPLE_DES_CBC = 157, + SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC = 158, + SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC = 159, + SEC_OID_PKCS12_SAFE_CONTENTS_ID = 160, + SEC_OID_PKCS12_PKCS8_SHROUDED_KEY_BAG_ID = 161, + + SEC_OID_PKCS12_V1_KEY_BAG_ID = 162, + SEC_OID_PKCS12_V1_PKCS8_SHROUDED_KEY_BAG_ID = 163, + SEC_OID_PKCS12_V1_CERT_BAG_ID = 164, + SEC_OID_PKCS12_V1_CRL_BAG_ID = 165, + SEC_OID_PKCS12_V1_SECRET_BAG_ID = 166, + SEC_OID_PKCS12_V1_SAFE_CONTENTS_BAG_ID = 167, + SEC_OID_PKCS9_X509_CERT = 168, + SEC_OID_PKCS9_SDSI_CERT = 169, + SEC_OID_PKCS9_X509_CRL = 170, + SEC_OID_PKCS9_FRIENDLY_NAME = 171, + SEC_OID_PKCS9_LOCAL_KEY_ID = 172, + SEC_OID_BOGUS_KEY_USAGE = 173, + + /*Diffe Helman OIDS */ + SEC_OID_X942_DIFFIE_HELMAN_KEY = 174, + + /* Netscape other name types */ + /* SEC_OID_NETSCAPE_NICKNAME is an otherName field of type IA5String + * in the subjectAltName certificate extension. NSS dropped support + * for SEC_OID_NETSCAPE_NICKNAME in NSS 3.13. */ + SEC_OID_NETSCAPE_NICKNAME = 175, + + /* Cert Server OIDS */ + SEC_OID_NETSCAPE_RECOVERY_REQUEST = 176, + + /* New PSM certificate management OIDs */ + SEC_OID_CERT_RENEWAL_LOCATOR = 177, + SEC_OID_NS_CERT_EXT_SCOPE_OF_USE = 178, + + /* CMS (RFC2630) OIDs */ + SEC_OID_CMS_EPHEMERAL_STATIC_DIFFIE_HELLMAN = 179, + SEC_OID_CMS_3DES_KEY_WRAP = 180, + SEC_OID_CMS_RC2_KEY_WRAP = 181, + + /* SMIME attributes */ + SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE = 182, + + /* AES OIDs */ + SEC_OID_AES_128_ECB = 183, + SEC_OID_AES_128_CBC = 184, + SEC_OID_AES_192_ECB = 185, + SEC_OID_AES_192_CBC = 186, + SEC_OID_AES_256_ECB = 187, + SEC_OID_AES_256_CBC = 188, + + SEC_OID_SDN702_DSA_SIGNATURE = 189, + + SEC_OID_MS_SMIME_ENCRYPTION_KEY_PREFERENCE = 190, + + SEC_OID_SHA256 = 191, + SEC_OID_SHA384 = 192, + SEC_OID_SHA512 = 193, + + SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION = 194, + SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION = 195, + SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION = 196, + + SEC_OID_AES_128_KEY_WRAP = 197, + SEC_OID_AES_192_KEY_WRAP = 198, + SEC_OID_AES_256_KEY_WRAP = 199, + + /* Elliptic Curve Cryptography (ECC) OIDs */ + SEC_OID_ANSIX962_EC_PUBLIC_KEY = 200, + SEC_OID_ANSIX962_ECDSA_SHA1_SIGNATURE = 201, + +#define SEC_OID_ANSIX962_ECDSA_SIGNATURE_WITH_SHA1_DIGEST \ + SEC_OID_ANSIX962_ECDSA_SHA1_SIGNATURE + + /* ANSI X9.62 named elliptic curves (prime field) */ + SEC_OID_ANSIX962_EC_PRIME192V1 = 202, + SEC_OID_ANSIX962_EC_PRIME192V2 = 203, + SEC_OID_ANSIX962_EC_PRIME192V3 = 204, + SEC_OID_ANSIX962_EC_PRIME239V1 = 205, + SEC_OID_ANSIX962_EC_PRIME239V2 = 206, + SEC_OID_ANSIX962_EC_PRIME239V3 = 207, + SEC_OID_ANSIX962_EC_PRIME256V1 = 208, + + /* SECG named elliptic curves (prime field) */ + SEC_OID_SECG_EC_SECP112R1 = 209, + SEC_OID_SECG_EC_SECP112R2 = 210, + SEC_OID_SECG_EC_SECP128R1 = 211, + SEC_OID_SECG_EC_SECP128R2 = 212, + SEC_OID_SECG_EC_SECP160K1 = 213, + SEC_OID_SECG_EC_SECP160R1 = 214, + SEC_OID_SECG_EC_SECP160R2 = 215, + SEC_OID_SECG_EC_SECP192K1 = 216, + /* SEC_OID_SECG_EC_SECP192R1 is SEC_OID_ANSIX962_EC_PRIME192V1 */ + SEC_OID_SECG_EC_SECP224K1 = 217, + SEC_OID_SECG_EC_SECP224R1 = 218, + SEC_OID_SECG_EC_SECP256K1 = 219, + /* SEC_OID_SECG_EC_SECP256R1 is SEC_OID_ANSIX962_EC_PRIME256V1 */ + SEC_OID_SECG_EC_SECP384R1 = 220, + SEC_OID_SECG_EC_SECP521R1 = 221, + + /* ANSI X9.62 named elliptic curves (characteristic two field) */ + SEC_OID_ANSIX962_EC_C2PNB163V1 = 222, + SEC_OID_ANSIX962_EC_C2PNB163V2 = 223, + SEC_OID_ANSIX962_EC_C2PNB163V3 = 224, + SEC_OID_ANSIX962_EC_C2PNB176V1 = 225, + SEC_OID_ANSIX962_EC_C2TNB191V1 = 226, + SEC_OID_ANSIX962_EC_C2TNB191V2 = 227, + SEC_OID_ANSIX962_EC_C2TNB191V3 = 228, + SEC_OID_ANSIX962_EC_C2ONB191V4 = 229, + SEC_OID_ANSIX962_EC_C2ONB191V5 = 230, + SEC_OID_ANSIX962_EC_C2PNB208W1 = 231, + SEC_OID_ANSIX962_EC_C2TNB239V1 = 232, + SEC_OID_ANSIX962_EC_C2TNB239V2 = 233, + SEC_OID_ANSIX962_EC_C2TNB239V3 = 234, + SEC_OID_ANSIX962_EC_C2ONB239V4 = 235, + SEC_OID_ANSIX962_EC_C2ONB239V5 = 236, + SEC_OID_ANSIX962_EC_C2PNB272W1 = 237, + SEC_OID_ANSIX962_EC_C2PNB304W1 = 238, + SEC_OID_ANSIX962_EC_C2TNB359V1 = 239, + SEC_OID_ANSIX962_EC_C2PNB368W1 = 240, + SEC_OID_ANSIX962_EC_C2TNB431R1 = 241, + + /* SECG named elliptic curves (characteristic two field) */ + SEC_OID_SECG_EC_SECT113R1 = 242, + SEC_OID_SECG_EC_SECT113R2 = 243, + SEC_OID_SECG_EC_SECT131R1 = 244, + SEC_OID_SECG_EC_SECT131R2 = 245, + SEC_OID_SECG_EC_SECT163K1 = 246, + SEC_OID_SECG_EC_SECT163R1 = 247, + SEC_OID_SECG_EC_SECT163R2 = 248, + SEC_OID_SECG_EC_SECT193R1 = 249, + SEC_OID_SECG_EC_SECT193R2 = 250, + SEC_OID_SECG_EC_SECT233K1 = 251, + SEC_OID_SECG_EC_SECT233R1 = 252, + SEC_OID_SECG_EC_SECT239K1 = 253, + SEC_OID_SECG_EC_SECT283K1 = 254, + SEC_OID_SECG_EC_SECT283R1 = 255, + SEC_OID_SECG_EC_SECT409K1 = 256, + SEC_OID_SECG_EC_SECT409R1 = 257, + SEC_OID_SECG_EC_SECT571K1 = 258, + SEC_OID_SECG_EC_SECT571R1 = 259, + + SEC_OID_NETSCAPE_AOLSCREENNAME = 260, + + SEC_OID_AVA_SURNAME = 261, + SEC_OID_AVA_SERIAL_NUMBER = 262, + SEC_OID_AVA_STREET_ADDRESS = 263, + SEC_OID_AVA_TITLE = 264, + SEC_OID_AVA_POSTAL_ADDRESS = 265, + SEC_OID_AVA_POSTAL_CODE = 266, + SEC_OID_AVA_POST_OFFICE_BOX = 267, + SEC_OID_AVA_GIVEN_NAME = 268, + SEC_OID_AVA_INITIALS = 269, + SEC_OID_AVA_GENERATION_QUALIFIER = 270, + SEC_OID_AVA_HOUSE_IDENTIFIER = 271, + SEC_OID_AVA_PSEUDONYM = 272, + + /* More OIDs */ + SEC_OID_PKIX_CA_ISSUERS = 273, + SEC_OID_PKCS9_EXTENSION_REQUEST = 274, + + /* new EC Signature oids */ + SEC_OID_ANSIX962_ECDSA_SIGNATURE_RECOMMENDED_DIGEST = 275, + SEC_OID_ANSIX962_ECDSA_SIGNATURE_SPECIFIED_DIGEST = 276, + SEC_OID_ANSIX962_ECDSA_SHA224_SIGNATURE = 277, + SEC_OID_ANSIX962_ECDSA_SHA256_SIGNATURE = 278, + SEC_OID_ANSIX962_ECDSA_SHA384_SIGNATURE = 279, + SEC_OID_ANSIX962_ECDSA_SHA512_SIGNATURE = 280, + + /* More id-ce and id-pe OIDs from RFC 3280 */ + SEC_OID_X509_HOLD_INSTRUCTION_CODE = 281, + SEC_OID_X509_DELTA_CRL_INDICATOR = 282, + SEC_OID_X509_ISSUING_DISTRIBUTION_POINT = 283, + SEC_OID_X509_CERT_ISSUER = 284, + SEC_OID_X509_FRESHEST_CRL = 285, + SEC_OID_X509_INHIBIT_ANY_POLICY = 286, + SEC_OID_X509_SUBJECT_INFO_ACCESS = 287, + + /* Camellia OIDs (RFC3657)*/ + SEC_OID_CAMELLIA_128_CBC = 288, + SEC_OID_CAMELLIA_192_CBC = 289, + SEC_OID_CAMELLIA_256_CBC = 290, + + /* PKCS 5 V2 OIDS */ + SEC_OID_PKCS5_PBKDF2 = 291, + SEC_OID_PKCS5_PBES2 = 292, + SEC_OID_PKCS5_PBMAC1 = 293, + SEC_OID_HMAC_SHA1 = 294, + SEC_OID_HMAC_SHA224 = 295, + SEC_OID_HMAC_SHA256 = 296, + SEC_OID_HMAC_SHA384 = 297, + SEC_OID_HMAC_SHA512 = 298, + + SEC_OID_PKIX_TIMESTAMPING = 299, + SEC_OID_PKIX_CA_REPOSITORY = 300, + + SEC_OID_ISO_SHA1_WITH_RSA_SIGNATURE = 301, + + SEC_OID_SEED_CBC = 302, + + SEC_OID_X509_ANY_POLICY = 303, + + SEC_OID_PKCS1_RSA_OAEP_ENCRYPTION = 304, + SEC_OID_PKCS1_MGF1 = 305, + SEC_OID_PKCS1_PSPECIFIED = 306, + SEC_OID_PKCS1_RSA_PSS_SIGNATURE = 307, + SEC_OID_PKCS1_SHA224_WITH_RSA_ENCRYPTION = 308, + + SEC_OID_SHA224 = 309, + + SEC_OID_EV_INCORPORATION_LOCALITY = 310, + SEC_OID_EV_INCORPORATION_STATE = 311, + SEC_OID_EV_INCORPORATION_COUNTRY = 312, + SEC_OID_BUSINESS_CATEGORY = 313, + + SEC_OID_NIST_DSA_SIGNATURE_WITH_SHA224_DIGEST = 314, + SEC_OID_NIST_DSA_SIGNATURE_WITH_SHA256_DIGEST = 315, + + /* Microsoft Trust List Signing + * szOID_KP_CTL_USAGE_SIGNING + * where KP stands for Key Purpose + */ + SEC_OID_MS_EXT_KEY_USAGE_CTL_SIGNING = 316, + + /* The 'name' attribute type in X.520 */ + SEC_OID_AVA_NAME = 317, + + SEC_OID_AES_128_GCM = 318, + SEC_OID_AES_192_GCM = 319, + SEC_OID_AES_256_GCM = 320, + SEC_OID_IDEA_CBC = 321, + + /* pseudo - OIDs */ + + SEC_OID_RC2_40_CBC = 322, + SEC_OID_DES_40_CBC = 323, + SEC_OID_RC4_40 = 324, + SEC_OID_RC4_56 = 325, + SEC_OID_NULL_CIPHER = 326, + + SEC_OID_HMAC_MD5 = 327, + + SEC_OID_TLS_RSA = 328, + SEC_OID_TLS_DHE_RSA = 329, + SEC_OID_TLS_DHE_DSS = 330, + SEC_OID_TLS_DH_RSA = 331, + SEC_OID_TLS_DH_DSS = 332, + SEC_OID_TLS_DH_ANON = 333, + SEC_OID_TLS_ECDHE_ECDSA = 334, + SEC_OID_TLS_ECDHE_RSA = 335, + SEC_OID_TLS_ECDH_ECDSA = 336, + SEC_OID_TLS_ECDH_RSA = 337, + SEC_OID_TLS_ECDH_ANON = 338, + SEC_OID_TLS_RSA_EXPORT = 339, + + SEC_OID_TLS_DHE_RSA_EXPORT = 340, + SEC_OID_TLS_DHE_DSS_EXPORT = 341, + SEC_OID_TLS_DH_RSA_EXPORT = 342, + SEC_OID_TLS_DH_DSS_EXPORT = 343, + SEC_OID_TLS_DH_ANON_EXPORT = 344, + SEC_OID_APPLY_SSL_POLICY = 345, + + SEC_OID_CHACHA20_POLY1305 = 346, + + SEC_OID_TLS_ECDHE_PSK = 347, + SEC_OID_TLS_DHE_PSK = 348, + + SEC_OID_TLS_FFDHE_2048 = 349, + SEC_OID_TLS_FFDHE_3072 = 350, + SEC_OID_TLS_FFDHE_4096 = 351, + SEC_OID_TLS_FFDHE_6144 = 352, + SEC_OID_TLS_FFDHE_8192 = 353, + SEC_OID_TLS_DHE_CUSTOM = 354, + + SEC_OID_CURVE25519 = 355, + + SEC_OID_TLS13_KEA_ANY = 356, + + SEC_OID_X509_ANY_EXT_KEY_USAGE = 357, + SEC_OID_EXT_KEY_USAGE_IPSEC_IKE = 358, + SEC_OID_IPSEC_IKE_END = 359, + SEC_OID_IPSEC_IKE_INTERMEDIATE = 360, + SEC_OID_EXT_KEY_USAGE_IPSEC_END = 361, + SEC_OID_EXT_KEY_USAGE_IPSEC_TUNNEL = 362, + SEC_OID_EXT_KEY_USAGE_IPSEC_USER = 363, + + SEC_OID_SHA3_224 = 364, + SEC_OID_SHA3_256 = 365, + SEC_OID_SHA3_384 = 366, + SEC_OID_SHA3_512 = 367, + + SEC_OID_HMAC_SHA3_224 = 368, + SEC_OID_HMAC_SHA3_256 = 369, + SEC_OID_HMAC_SHA3_384 = 370, + SEC_OID_HMAC_SHA3_512 = 371, + + SEC_OID_XYBER768D00 = 372, + + SEC_OID_ED25519_SIGNATURE = 373, + SEC_OID_ED25519_PUBLIC_KEY = 374, + + SEC_OID_DHSINGLEPASS_STDDH_SHA1KDF_SCHEME = 375, + SEC_OID_DHSINGLEPASS_STDDH_SHA224KDF_SCHEME = 376, + SEC_OID_DHSINGLEPASS_STDDH_SHA256KDF_SCHEME = 377, + SEC_OID_DHSINGLEPASS_STDDH_SHA384KDF_SCHEME = 378, + SEC_OID_DHSINGLEPASS_STDDH_SHA512KDF_SCHEME = 379, + SEC_OID_DHSINGLEPASS_COFACTORDH_SHA1KDF_SCHEME = 380, + SEC_OID_DHSINGLEPASS_COFACTORDH_SHA224KDF_SCHEME = 381, + SEC_OID_DHSINGLEPASS_COFACTORDH_SHA256KDF_SCHEME = 382, + SEC_OID_DHSINGLEPASS_COFACTORDH_SHA384KDF_SCHEME = 383, + SEC_OID_DHSINGLEPASS_COFACTORDH_SHA512KDF_SCHEME = 384, + SEC_OID_RC2_64_CBC = 385, + SEC_OID_RC2_128_CBC = 386, + SEC_OID_ECDH_KEA = 387, + SEC_OID_X25519 = 388, + + SEC_OID_MLKEM768X25519 = 389, + + SEC_OID_TLS_REQUIRE_EMS = 390, + + SEC_OID_ML_DSA_44 = 391, + SEC_OID_ML_DSA_65 = 392, + SEC_OID_ML_DSA_87 = 393, + + SEC_OID_TOTAL +} SECOidTag; + +#define SEC_OID_SECG_EC_SECP192R1 SEC_OID_ANSIX962_EC_PRIME192V1 +#define SEC_OID_SECG_EC_SECP256R1 SEC_OID_ANSIX962_EC_PRIME256V1 +#define SEC_OID_PKCS12_KEY_USAGE SEC_OID_X509_KEY_USAGE + +/* fake OID for DSS sign/verify */ +#define SEC_OID_SHA SEC_OID_MISS_DSS + +/* ML-DSA Public keys and signatures use the same identifier */ +#define SEC_OID_ML_DSA_44_SIGNATURE SEC_OID_ML_DSA_44 +#define SEC_OID_ML_DSA_44_PUBLIC_KEY SEC_OID_ML_DSA_44 +#define SEC_OID_ML_DSA_65_SIGNATURE SEC_OID_ML_DSA_65 +#define SEC_OID_ML_DSA_65_PUBLIC_KEY SEC_OID_ML_DSA_65 +#define SEC_OID_ML_DSA_87_SIGNATURE SEC_OID_ML_DSA_87 +#define SEC_OID_ML_DSA_87_PUBLIC_KEY SEC_OID_ML_DSA_87 + +typedef enum { + INVALID_CERT_EXTENSION = 0, + UNSUPPORTED_CERT_EXTENSION = 1, + SUPPORTED_CERT_EXTENSION = 2 +} SECSupportExtenTag; + +struct SECOidDataStr { + SECItem oid; + SECOidTag offset; + const char* desc; + unsigned long mechanism; + SECSupportExtenTag supportedExtension; + /* only used for x.509 v3 extensions, so + that we can print the names of those + extensions that we don't even support */ +}; + +/* New Opaque extended OID table API. + * These are algorithm policy Flags, used with functions + * NSS_SetAlgorithmPolicy & NSS_GetAlgorithmPolicy. + */ +#define NSS_USE_ALG_IN_CERT_SIGNATURE 0x00000001 /* CRLs and OCSP, too */ +#define NSS_USE_ALG_IN_SMIME_SIGNATURE 0x00000002 /* used in S/MIME */ +#define NSS_USE_ALG_IN_SSL_KX 0x00000004 /* used in SSL key exchange */ +#define NSS_USE_ALG_IN_SSL 0x00000008 /* used in SSL record protocol */ +#define NSS_USE_POLICY_IN_SSL 0x00000010 /* enable policy in SSL protocol */ +#define NSS_USE_ALG_IN_ANY_SIGNATURE 0x00000020 /* used in any signature */ +#define NSS_USE_ALG_IN_PKCS12_DECRYPT 0x00000040 /* used to decrypt pkcs12 */ +#define NSS_USE_ALG_IN_PKCS12_ENCRYPT 0x00000080 /* used encrypt pkcs12 */ +#define NSS_USE_ALG_IN_SMIME_LEGACY 0x00000100 /* used to decrypt smime */ +#define NSS_USE_ALG_IN_SMIME_ENCRYPT 0x00000200 /* used to decrypt smime */ +#define NSS_USE_ALG_IN_SMIME_KX_LEGACY 0x00000400 /* used to decrypt smime */ +#define NSS_USE_ALG_IN_SMIME_KX_ENCRYPT 0x00000800 /* used to decrypt smime */ +/* these flags are used by the automatic policy scheme to set the default values + * for enabling and disabling ciphers. Applications should use the enable/disable + * calls directly. */ +#define NSS_USE_DEFAULT_NOT_VALID 0x80000000 /* clear to make the default flag valid */ +#define NSS_USE_DEFAULT_SSL_ENABLE 0x40000000 /* default cipher suite setting 1=enable */ +/* S/MIME Enable sets the list of algorithms we advertise and which algorithms + * we will encrypt/decrypt with. We will decrypt anything that's allowable */ +#define NSS_USE_DEFAULT_SMIME_ENABLE 0x20000000 /* default cipher suite setting 1=enable */ + +/* Combo policy bits */ +#define NSS_USE_ALG_RESERVED 0x1ffff000 /* may be used in future */ +/* both encrypt and decrypt PKCS 12 */ +#define NSS_USE_ALG_IN_PKCS12 (NSS_USE_ALG_IN_PKCS12_DECRYPT | \ + NSS_USE_ALG_IN_PKCS12_ENCRYPT) +/* both encrypt and decrypt SMIME */ +#define NSS_USE_ALG_IN_SMIME (NSS_USE_ALG_IN_SMIME_LEGACY | \ + NSS_USE_ALG_IN_SMIME_ENCRYPT) +/* both encrypt and decrypt key exchange */ +#define NSS_USE_ALG_IN_SMIME_KX (NSS_USE_ALG_IN_SMIME_KX_LEGACY | \ + NSS_USE_ALG_IN_SMIME_KX_ENCRYPT) +/* All the key exchange bits */ +#define NSS_USE_ALG_IN_KEY_EXCHANGE (NSS_USE_ALG_IN_SMIME_KX | \ + NSS_USE_ALG_IN_SSL_KX) +/* Alias of all the signature values. */ +#define NSS_USE_ALG_IN_SIGNATURE (NSS_USE_ALG_IN_CERT_SIGNATURE | \ + NSS_USE_ALG_IN_SMIME_SIGNATURE | \ + NSS_USE_ALG_IN_ANY_SIGNATURE) +/* all the bits needed for a certificate signature + * and only the bits needed for a certificate signature */ +#define NSS_USE_CERT_SIGNATURE_OK (NSS_USE_ALG_IN_CERT_SIGNATURE | \ + NSS_USE_ALG_IN_ANY_SIGNATURE) +/* all the bits needed for an SMIME signature + * and only the bits needed for an SMIME signature */ +#define NSS_USE_SMIME_SIGNATURE_OK (NSS_USE_ALG_IN_SMIME_SIGNATURE | \ + NSS_USE_ALG_IN_ANY_SIGNATURE) + +/* legacy names */ +#define NSS_USE_ALG_IN_CMS_SIGNATURE NSS_USE_ALG_IN_SMIME_SIGNATURE +#define NSS_USE_ALG_CMS_SIGNATURE_OK NSS_USE_ALG_SMIME_SIGNATURE_OK + +/* Code MUST NOT SET or CLEAR reserved bits, and must NOT depend on them + * being all zeros or having any other known value. The reserved bits + * must be ignored. + */ + +#endif /* _SECOIDT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secpkcs5.h b/illumos-x86_64/usr/include/mps/secpkcs5.h new file mode 100644 index 00000000..38178be1 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secpkcs5.h @@ -0,0 +1,71 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef _SECPKCS5_H_ +#define _SECPKCS5_H_ +#include "seccomon.h" +#include "secmodt.h" + +/* used for V2 PKCS 12 Draft Spec */ +typedef enum { + pbeBitGenIDNull = 0, + pbeBitGenCipherKey = 0x01, + pbeBitGenCipherIV = 0x02, + pbeBitGenIntegrityKey = 0x03 +} PBEBitGenID; + +typedef struct PBEBitGenContextStr PBEBitGenContext; + +SEC_BEGIN_PROTOS + +/* private */ +SECAlgorithmID * +sec_pkcs5CreateAlgorithmID(SECOidTag algorithm, SECOidTag cipherAlgorithm, + SECOidTag prfAlg, SECOidTag *pPbeAlgorithm, + int keyLengh, SECItem *salt, int iteration); + +/* Get the initialization vector. The password is passed in, hashing + * is performed, and the initialization vector is returned. + * algid is a pointer to a PBE algorithm ID + * pwitem is the password + * If an error occurs or the algorithm id is not a PBE algrithm, + * NULL is returned. Otherwise, the iv is returned in a secitem. + */ +SECItem * +SEC_PKCS5GetIV(SECAlgorithmID *algid, SECItem *pwitem, PRBool faulty3DES); + +SECOidTag SEC_PKCS5GetCryptoAlgorithm(SECAlgorithmID *algid); +SECOidTag SEC_PKCS5GetHashAlgorithm(SECAlgorithmID *algid); + +/* the next 2 maps a PKCS #12 PBE or PKCS #5v1 PBE oid to it's encryption algorithm + * and hash algorithms. + * All other values map to SEC_OID_UNKNOWN. In most cases you want + * to use SEC_PKCS5GetCryptoAlgorithm() with a full SECAlgorithmID which + * can handle PKCS #5v2 */ +SECOidTag SEC_PKCS5GetCryptoFromAlgTag(SECOidTag algTag); +SECOidTag SEC_PKCS5GetHashFromAlgTag(SECOidTag algTag); + +PRBool SEC_PKCS5IsAlgorithmPBEAlg(SECAlgorithmID *algid); +PRBool SEC_PKCS5IsAlgorithmPBEAlgTag(SECOidTag algTag); +SECOidTag SEC_PKCS5GetPBEAlgorithm(SECOidTag algTag, int keyLen); +int SEC_PKCS5GetKeyLength(SECAlgorithmID *algid); + +/********************************************************************** + * Deprecated PBE functions. Use the PBE functions in pk11func.h + * instead. + **********************************************************************/ + +PBEBitGenContext * +PBE_CreateContext(SECOidTag hashAlgorithm, PBEBitGenID bitGenPurpose, + SECItem *pwitem, SECItem *salt, unsigned int bitsNeeded, + unsigned int iterations); + +void +PBE_DestroyContext(PBEBitGenContext *context); + +SECItem * +PBE_GenerateBits(PBEBitGenContext *context); + +SEC_END_PROTOS + +#endif /* _SECPKS5_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secpkcs7.h b/illumos-x86_64/usr/include/mps/secpkcs7.h new file mode 100644 index 00000000..4a88df1d --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secpkcs7.h @@ -0,0 +1,626 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Interface to the PKCS7 implementation. + */ + +#ifndef _SECPKCS7_H_ +#define _SECPKCS7_H_ + +#include "seccomon.h" + +#include "secoidt.h" +#include "certt.h" +#include "keythi.h" +#include "hasht.h" +#include "pkcs7t.h" + +extern const SEC_ASN1Template sec_PKCS7ContentInfoTemplate[]; + +/************************************************************************/ +SEC_BEGIN_PROTOS + +/************************************************************************ + * Miscellaneous + ************************************************************************/ + +/* + * Returns the content type of the given contentInfo. + */ +extern SECOidTag SEC_PKCS7ContentType(SEC_PKCS7ContentInfo *cinfo); + +/* + * Destroy a PKCS7 contentInfo and all of its sub-pieces. + */ +extern void SEC_PKCS7DestroyContentInfo(SEC_PKCS7ContentInfo *contentInfo); + +/* + * Copy a PKCS7 contentInfo. A Destroy is needed on *each* copy. + */ +extern SEC_PKCS7ContentInfo * +SEC_PKCS7CopyContentInfo(SEC_PKCS7ContentInfo *contentInfo); + +/* + * Return a pointer to the actual content. In the case of those types + * which are encrypted, this returns the *plain* content. + */ +extern SECItem *SEC_PKCS7GetContent(SEC_PKCS7ContentInfo *cinfo); + +/************************************************************************ + * PKCS7 Decoding, Verification, etc.. + ************************************************************************/ + +extern SEC_PKCS7DecoderContext * +SEC_PKCS7DecoderStart(SEC_PKCS7DecoderContentCallback callback, + void *callback_arg, + SECKEYGetPasswordKey pwfn, void *pwfn_arg, + SEC_PKCS7GetDecryptKeyCallback decrypt_key_cb, + void *decrypt_key_cb_arg, + SEC_PKCS7DecryptionAllowedCallback decrypt_allowed_cb); + +extern SECStatus +SEC_PKCS7DecoderUpdate(SEC_PKCS7DecoderContext *p7dcx, + const char *buf, unsigned long len); + +extern SEC_PKCS7ContentInfo * +SEC_PKCS7DecoderFinish(SEC_PKCS7DecoderContext *p7dcx); + +/* Abort the underlying ASN.1 stream & set an error */ +void SEC_PKCS7DecoderAbort(SEC_PKCS7DecoderContext *p7dcx, int error); + +extern SEC_PKCS7ContentInfo * +SEC_PKCS7DecodeItem(SECItem *p7item, + SEC_PKCS7DecoderContentCallback cb, void *cb_arg, + SECKEYGetPasswordKey pwfn, void *pwfn_arg, + SEC_PKCS7GetDecryptKeyCallback decrypt_key_cb, + void *decrypt_key_cb_arg, + SEC_PKCS7DecryptionAllowedCallback decrypt_allowed_cb); + +extern PRBool SEC_PKCS7ContainsCertsOrCrls(SEC_PKCS7ContentInfo *cinfo); + +/* checks to see if the contents of the content info is + * empty. it so, PR_TRUE is returned. PR_FALSE, otherwise. + * + * minLen is used to specify a minimum size. if content size <= minLen, + * content is assumed empty. + */ +extern PRBool +SEC_PKCS7IsContentEmpty(SEC_PKCS7ContentInfo *cinfo, unsigned int minLen); + +extern PRBool SEC_PKCS7ContentIsEncrypted(SEC_PKCS7ContentInfo *cinfo); + +/* + * If the PKCS7 content has a signature (not just *could* have a signature) + * return true; false otherwise. This can/should be called before calling + * VerifySignature, which will always indicate failure if no signature is + * present, but that does not mean there even was a signature! + * Note that the content itself can be empty (detached content was sent + * another way); it is the presence of the signature that matters. + */ +extern PRBool SEC_PKCS7ContentIsSigned(SEC_PKCS7ContentInfo *cinfo); + +/* + * SEC_PKCS7VerifySignature + * Look at a PKCS7 contentInfo and check if the signature is good. + * The verification checks that the signing cert is valid and trusted + * for the purpose specified by "certusage". + * + * In addition, if "keepcerts" is true, add any new certificates found + * into our local database. + */ +extern PRBool SEC_PKCS7VerifySignature(SEC_PKCS7ContentInfo *cinfo, + SECCertUsage certusage, + PRBool keepcerts); + +/* + * SEC_PKCS7VerifyDetachedSignature + * Look at a PKCS7 contentInfo and check if the signature matches + * a passed-in digest (calculated, supposedly, from detached contents). + * The verification checks that the signing cert is valid and trusted + * for the purpose specified by "certusage". + * + * In addition, if "keepcerts" is true, add any new certificates found + * into our local database. + */ +extern PRBool SEC_PKCS7VerifyDetachedSignature(SEC_PKCS7ContentInfo *cinfo, + SECCertUsage certusage, + const SECItem *detached_digest, + HASH_HashType digest_type, + PRBool keepcerts); + +/* + * SEC_PKCS7VerifyDetachedSignatureAtTime + * Look at a PKCS7 contentInfo and check if the signature matches + * a passed-in digest (calculated, supposedly, from detached contents). + * The verification checks that the signing cert is valid and trusted + * for the purpose specified by "certusage" at time "atTime". + * + * In addition, if "keepcerts" is true, add any new certificates found + * into our local database. + */ +extern PRBool +SEC_PKCS7VerifyDetachedSignatureAtTime(SEC_PKCS7ContentInfo *cinfo, + SECCertUsage certusage, + const SECItem *detached_digest, + HASH_HashType digest_type, + PRBool keepcerts, + PRTime atTime); + +/* + * SEC_PKCS7GetSignerCommonName, SEC_PKCS7GetSignerEmailAddress + * The passed-in contentInfo is espected to be Signed, and these + * functions return the specified portion of the full signer name. + * + * Returns a pointer to allocated memory, which must be freed. + * A NULL return value is an error. + */ +extern char *SEC_PKCS7GetSignerCommonName(SEC_PKCS7ContentInfo *cinfo); +extern char *SEC_PKCS7GetSignerEmailAddress(SEC_PKCS7ContentInfo *cinfo); + +/* + * Return the the signing time, in UTCTime format, of a PKCS7 contentInfo. + */ +extern SECItem *SEC_PKCS7GetSigningTime(SEC_PKCS7ContentInfo *cinfo); + +/************************************************************************ + * PKCS7 Creation and Encoding. + ************************************************************************/ + +/* + * Start a PKCS7 signing context. + * + * "cert" is the cert that will be used to sign the data. It will be + * checked for validity. + * + * "certusage" describes the signing usage (e.g. certUsageEmailSigner) + * XXX Maybe SECCertUsage should be split so that our caller just says + * "email" and *we* add the "signing" part -- otherwise our caller + * could be lying about the usage; we do not want to allow encryption + * certs for signing or vice versa. + * + * "certdb" is the cert database to use for verifying the cert. + * It can be NULL if a default database is available (like in the client). + * + * "digestalg" names the digest algorithm (e.g. SEC_OID_SHA1). + * + * "digest" is the actual digest of the data. It must be provided in + * the case of detached data or NULL if the content will be included. + * + * The return value can be passed to functions which add things to + * it like attributes, then eventually to SEC_PKCS7Encode() or to + * SEC_PKCS7EncoderStart() to create the encoded data, and finally to + * SEC_PKCS7DestroyContentInfo(). + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern SEC_PKCS7ContentInfo * +SEC_PKCS7CreateSignedData(CERTCertificate *cert, + SECCertUsage certusage, + CERTCertDBHandle *certdb, + SECOidTag digestalg, + SECItem *digest, + SECKEYGetPasswordKey pwfn, void *pwfn_arg); + +/* + * Create a PKCS7 certs-only container. + * + * "cert" is the (first) cert that will be included. + * + * "include_chain" specifies whether the entire chain for "cert" should + * be included. + * + * "certdb" is the cert database to use for finding the chain. + * It can be NULL in when "include_chain" is false, or when meaning + * use the default database. + * + * More certs and chains can be added via AddCertficate and AddCertChain. + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern SEC_PKCS7ContentInfo * +SEC_PKCS7CreateCertsOnly(CERTCertificate *cert, + PRBool include_chain, + CERTCertDBHandle *certdb); + +/* + * Start a PKCS7 enveloping context. + * + * "cert" is the cert for the recipient. It will be checked for validity. + * + * "certusage" describes the encryption usage (e.g. certUsageEmailRecipient) + * XXX Maybe SECCertUsage should be split so that our caller just says + * "email" and *we* add the "recipient" part -- otherwise our caller + * could be lying about the usage; we do not want to allow encryption + * certs for signing or vice versa. + * + * "certdb" is the cert database to use for verifying the cert. + * It can be NULL if a default database is available (like in the client). + * + * "encalg" specifies the bulk encryption algorithm to use (e.g. SEC_OID_RC2). + * + * "keysize" specifies the bulk encryption key size, in bits. + * + * The return value can be passed to functions which add things to + * it like more recipients, then eventually to SEC_PKCS7Encode() or to + * SEC_PKCS7EncoderStart() to create the encoded data, and finally to + * SEC_PKCS7DestroyContentInfo(). + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern SEC_PKCS7ContentInfo * +SEC_PKCS7CreateEnvelopedData(CERTCertificate *cert, + SECCertUsage certusage, + CERTCertDBHandle *certdb, + SECOidTag encalg, + int keysize, + SECKEYGetPasswordKey pwfn, void *pwfn_arg); + +/* + * XXX There will be a similar routine for creating signedAndEnvelopedData. + * But its parameters will be different and I have no plans to implement + * it any time soon because we have no current need for it. + */ + +/* + * Create an empty PKCS7 data content info. + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern SEC_PKCS7ContentInfo *SEC_PKCS7CreateData(void); + +/* + * Create an empty PKCS7 encrypted content info. + * + * "algorithm" specifies the bulk encryption algorithm to use. + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern SEC_PKCS7ContentInfo * +SEC_PKCS7CreateEncryptedData(SECOidTag algorithm, int keysize, + SECKEYGetPasswordKey pwfn, void *pwfn_arg); + +/* + * Create an empty PKCS7 encrypted content info. + * + * Similar to SEC_PKCS7CreateEncryptedData(), but this is capable of + * creating encrypted content for PKCS #5 v2 algorithms. + * + * "pbe_algorithm" specifies the PBE algorithm to use. + * "cipher_algorithm" specifies the bulk encryption algorithm to use. + * "prf_algorithm" specifies the PRF algorithm which pbe_algorithm uses. + * + * An error results in a return value of NULL and an error set. + * (Retrieve specific errors via PORT_GetError()/XP_GetError().) + */ +extern SEC_PKCS7ContentInfo * +SEC_PKCS7CreateEncryptedDataWithPBEV2(SECOidTag pbe_algorithm, + SECOidTag cipher_algorithm, + SECOidTag prf_algorithm, + int keysize, + SECKEYGetPasswordKey pwfn, void *pwfn_arg); + +/* + * All of the following things return SECStatus to signal success or failure. + * Failure should have a more specific error status available via + * PORT_GetError()/XP_GetError(). + */ + +/* + * Add the specified attribute to the authenticated (i.e. signed) attributes + * of "cinfo" -- "oidtag" describes the attribute and "value" is the + * value to be associated with it. NOTE! "value" must already be encoded; + * no interpretation of "oidtag" is done. Also, it is assumed that this + * signedData has only one signer -- if we ever need to add attributes + * when there is more than one signature, we need a way to specify *which* + * signature should get the attribute. + * + * XXX Technically, a signed attribute can have multiple values; if/when + * we ever need to support an attribute which takes multiple values, we + * either need to change this interface or create an AddSignedAttributeValue + * which can be called subsequently, and would then append a value. + * + * "cinfo" should be of type signedData (the only kind of pkcs7 data + * that is allowed authenticated attributes); SECFailure will be returned + * if it is not. + */ +extern SECStatus SEC_PKCS7AddSignedAttribute(SEC_PKCS7ContentInfo *cinfo, + SECOidTag oidtag, + SECItem *value); + +/* + * Add "cert" and its entire chain to the set of certs included in "cinfo". + * + * "certdb" is the cert database to use for finding the chain. + * It can be NULL, meaning use the default database. + * + * "cinfo" should be of type signedData or signedAndEnvelopedData; + * SECFailure will be returned if it is not. + */ +extern SECStatus SEC_PKCS7AddCertChain(SEC_PKCS7ContentInfo *cinfo, + CERTCertificate *cert, + CERTCertDBHandle *certdb); + +/* + * Add "cert" to the set of certs included in "cinfo". + * + * "cinfo" should be of type signedData or signedAndEnvelopedData; + * SECFailure will be returned if it is not. + */ +extern SECStatus SEC_PKCS7AddCertificate(SEC_PKCS7ContentInfo *cinfo, + CERTCertificate *cert); + +/* + * Add another recipient to an encrypted message. + * + * "cinfo" should be of type envelopedData or signedAndEnvelopedData; + * SECFailure will be returned if it is not. + * + * "cert" is the cert for the recipient. It will be checked for validity. + * + * "certusage" describes the encryption usage (e.g. certUsageEmailRecipient) + * XXX Maybe SECCertUsage should be split so that our caller just says + * "email" and *we* add the "recipient" part -- otherwise our caller + * could be lying about the usage; we do not want to allow encryption + * certs for signing or vice versa. + * + * "certdb" is the cert database to use for verifying the cert. + * It can be NULL if a default database is available (like in the client). + */ +extern SECStatus SEC_PKCS7AddRecipient(SEC_PKCS7ContentInfo *cinfo, + CERTCertificate *cert, + SECCertUsage certusage, + CERTCertDBHandle *certdb); + +/* + * Add the signing time to the authenticated (i.e. signed) attributes + * of "cinfo". This is expected to be included in outgoing signed + * messages for email (S/MIME) but is likely useful in other situations. + * + * This should only be added once; a second call will either do + * nothing or replace an old signing time with a newer one. + * + * XXX This will probably just shove the current time into "cinfo" + * but it will not actually get signed until the entire item is + * processed for encoding. Is this (expected to be small) delay okay? + * + * "cinfo" should be of type signedData (the only kind of pkcs7 data + * that is allowed authenticated attributes); SECFailure will be returned + * if it is not. + */ +extern SECStatus SEC_PKCS7AddSigningTime(SEC_PKCS7ContentInfo *cinfo); + +/* + * Add the signer's symmetric capabilities to the authenticated + * (i.e. signed) attributes of "cinfo". This is expected to be + * included in outgoing signed messages for email (S/MIME). + * + * This can only be added once; a second call will return SECFailure. + * + * "cinfo" should be of type signedData or signedAndEnvelopedData; + * SECFailure will be returned if it is not. + */ +extern SECStatus SEC_PKCS7AddSymmetricCapabilities(SEC_PKCS7ContentInfo *cinfo); + +/* + * Mark that the signer's certificate and its issuing chain should + * be included in the encoded data. This is expected to be used + * in outgoing signed messages for email (S/MIME). + * + * "certdb" is the cert database to use for finding the chain. + * It can be NULL, meaning use the default database. + * + * "cinfo" should be of type signedData or signedAndEnvelopedData; + * SECFailure will be returned if it is not. + */ +extern SECStatus SEC_PKCS7IncludeCertChain(SEC_PKCS7ContentInfo *cinfo, + CERTCertDBHandle *certdb); + +/* + * Set the content; it will be included and also hashed and/or encrypted + * as appropriate. This is for in-memory content (expected to be "small") + * that will be included in the PKCS7 object. All others should stream the + * content through when encoding (see SEC_PKCS7Encoder{Start,Update,Finish}). + * + * "buf" points to data of length "len"; it will be copied. + */ +extern SECStatus SEC_PKCS7SetContent(SEC_PKCS7ContentInfo *cinfo, + const char *buf, unsigned long len); + +/* + * Encode a PKCS7 object, in one shot. All necessary components + * of the object must already be specified. Either the data has + * already been included (via SetContent), or the data is detached, + * or there is no data at all (certs-only). + * + * "cinfo" specifies the object to be encoded. + * + * "outputfn" is where the encoded bytes will be passed. + * + * "outputarg" is an opaque argument to the above callback. + * + * "bulkkey" specifies the bulk encryption key to use. This argument + * can be NULL if no encryption is being done, or if the bulk key should + * be generated internally (usually the case for EnvelopedData but never + * for EncryptedData, which *must* provide a bulk encryption key). + * + * "pwfn" is a callback for getting the password which protects the + * private key of the signer. This argument can be NULL if it is known + * that no signing is going to be done. + * + * "pwfnarg" is an opaque argument to the above callback. + */ +extern SECStatus SEC_PKCS7Encode(SEC_PKCS7ContentInfo *cinfo, + SEC_PKCS7EncoderOutputCallback outputfn, + void *outputarg, + PK11SymKey *bulkkey, + SECKEYGetPasswordKey pwfn, + void *pwfnarg); + +/* + * Encode a PKCS7 object, in one shot. All necessary components + * of the object must already be specified. Either the data has + * already been included (via SetContent), or the data is detached, + * or there is no data at all (certs-only). The output, rather than + * being passed to an output function as is done above, is all put + * into a SECItem. + * + * "pool" specifies a pool from which to allocate the result. + * It can be NULL, in which case memory is allocated generically. + * + * "dest" specifies a SECItem in which to put the result data. + * It can be NULL, in which case the entire item is allocated, too. + * + * "cinfo" specifies the object to be encoded. + * + * "bulkkey" specifies the bulk encryption key to use. This argument + * can be NULL if no encryption is being done, or if the bulk key should + * be generated internally (usually the case for EnvelopedData but never + * for EncryptedData, which *must* provide a bulk encryption key). + * + * "pwfn" is a callback for getting the password which protects the + * private key of the signer. This argument can be NULL if it is known + * that no signing is going to be done. + * + * "pwfnarg" is an opaque argument to the above callback. + */ +extern SECItem *SEC_PKCS7EncodeItem(PLArenaPool *pool, + SECItem *dest, + SEC_PKCS7ContentInfo *cinfo, + PK11SymKey *bulkkey, + SECKEYGetPasswordKey pwfn, + void *pwfnarg); + +/* + * For those who want to simply point to the pkcs7 contentInfo ASN.1 + * template, and *not* call the encoding functions directly, the + * following function can be used -- after it is called, the entire + * PKCS7 contentInfo is ready to be encoded. + */ +extern SECStatus SEC_PKCS7PrepareForEncode(SEC_PKCS7ContentInfo *cinfo, + PK11SymKey *bulkkey, + SECKEYGetPasswordKey pwfn, + void *pwfnarg); + +/* + * Start the process of encoding a PKCS7 object. The first part of + * the encoded object will be passed to the output function right away; + * after that it is expected that SEC_PKCS7EncoderUpdate will be called, + * streaming in the actual content that is getting included as well as + * signed or encrypted (or both). + * + * "cinfo" specifies the object to be encoded. + * + * "outputfn" is where the encoded bytes will be passed. + * + * "outputarg" is an opaque argument to the above callback. + * + * "bulkkey" specifies the bulk encryption key to use. This argument + * can be NULL if no encryption is being done, or if the bulk key should + * be generated internally (usually the case for EnvelopedData but never + * for EncryptedData, which *must* provide a bulk encryption key). + * + * Returns an object to be passed to EncoderUpdate and EncoderFinish. + */ +extern SEC_PKCS7EncoderContext * +SEC_PKCS7EncoderStart(SEC_PKCS7ContentInfo *cinfo, + SEC_PKCS7EncoderOutputCallback outputfn, + void *outputarg, + PK11SymKey *bulkkey); + +/* + * Encode more contents, hashing and/or encrypting along the way. + */ +extern SECStatus SEC_PKCS7EncoderUpdate(SEC_PKCS7EncoderContext *p7ecx, + const char *buf, + unsigned long len); + +/* + * No more contents; finish the signature creation, if appropriate, + * and then the encoding. + * + * "pwfn" is a callback for getting the password which protects the + * signer's private key. This argument can be NULL if it is known + * that no signing is going to be done. + * + * "pwfnarg" is an opaque argument to the above callback. + */ +extern SECStatus SEC_PKCS7EncoderFinish(SEC_PKCS7EncoderContext *p7ecx, + SECKEYGetPasswordKey pwfn, + void *pwfnarg); + +/* Abort the underlying ASN.1 stream & set an error */ +void SEC_PKCS7EncoderAbort(SEC_PKCS7EncoderContext *p7dcx, int error); + +/* retrieve the algorithm ID used to encrypt the content info + * for encrypted and enveloped data. The SECAlgorithmID pointer + * returned needs to be freed as it is a copy of the algorithm + * id in the content info. + */ +extern SECAlgorithmID * +SEC_PKCS7GetEncryptionAlgorithm(SEC_PKCS7ContentInfo *cinfo); + +/* the content of an encrypted data content info is encrypted. + * it is assumed that for encrypted data, that the data has already + * been set and is in the "plainContent" field of the content info. + * + * cinfo is the content info to encrypt + * + * key is the key with which to perform the encryption. if the + * algorithm is a password based encryption algorithm, the + * key is actually a password which will be processed per + * PKCS #5. + * + * in the event of an error, SECFailure is returned. SECSuccess + * indicates a success. + */ +extern SECStatus +SEC_PKCS7EncryptContents(PLArenaPool *poolp, + SEC_PKCS7ContentInfo *cinfo, + SECItem *key, + void *wincx); + +/* the content of an encrypted data content info is decrypted. + * it is assumed that for encrypted data, that the data has already + * been set and is in the "encContent" field of the content info. + * + * cinfo is the content info to decrypt + * + * key is the key with which to perform the decryption. if the + * algorithm is a password based encryption algorithm, the + * key is actually a password which will be processed per + * PKCS #5. + * + * in the event of an error, SECFailure is returned. SECSuccess + * indicates a success. + */ +extern SECStatus +SEC_PKCS7DecryptContents(PLArenaPool *poolp, + SEC_PKCS7ContentInfo *cinfo, + SECItem *key, + void *wincx); + +/* retrieve the certificate list from the content info. the list + * is a pointer to the list in the content info. this should not + * be deleted or freed in any way short of calling + * SEC_PKCS7DestroyContentInfo + */ +extern SECItem ** +SEC_PKCS7GetCertificateList(SEC_PKCS7ContentInfo *cinfo); + +/* Returns the key length (in bits) of the algorithm used to encrypt + this object. Returns 0 if it's not encrypted, or the key length is + irrelevant. */ +extern int +SEC_PKCS7GetKeyLength(SEC_PKCS7ContentInfo *cinfo); + +/************************************************************************/ +SEC_END_PROTOS + +#endif /* _SECPKCS7_H_ */ diff --git a/illumos-x86_64/usr/include/mps/secport.h b/illumos-x86_64/usr/include/mps/secport.h new file mode 100644 index 00000000..68834963 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/secport.h @@ -0,0 +1,378 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * secport.h - portability interfaces for security libraries + */ + +#ifndef _SECPORT_H_ +#define _SECPORT_H_ + +#include "utilrename.h" +#include "prlink.h" + +/* + * define XP_WIN, or XP_UNIX, in case they are not defined + * by anyone else + */ +#ifdef _WINDOWS +#ifndef XP_WIN +#define XP_WIN +#endif +#if defined(_WIN32) || defined(WIN32) +#ifndef XP_WIN32 +#define XP_WIN32 +#endif +#endif +#endif + +#ifdef unix +#ifndef XP_UNIX +#define XP_UNIX +#endif +#endif + +#include + +#include +/* ask for Annex K for memset_s. will set the appropriate #define + * if Annex K is supported */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include +#include "prtypes.h" +#include "prlog.h" /* for PR_ASSERT */ +#include "plarena.h" +#include "plstr.h" + +/* + * HACK for NSS 2.8 to allow Admin to compile without source changes. + */ +#ifndef SEC_BEGIN_PROTOS +#include "seccomon.h" +#endif + +/* + * The PORT_*Arena* function signatures mostly involve PLArenaPool* arguments. + * But this is misleading! It's not actually safe to use vanilla PLArenaPools + * with them. There are two "subclasses" of PLArenaPool that should be used + * instead. + * + * - PORTArenaPool (defined in secport.c): this "subclass" is always + * heap-allocated and uses a (heap-allocated) lock to protect all accesses. + * Use PORT_NewArena() and PORT_FreeArena() to create and destroy + * PORTArenaPools. + * + * - PORTCheapArenaPool (defined here): this "subclass" can be stack-allocated + * and does not use a lock to protect accesses. This makes it cheaper but + * less general. It is best used for arena pools that (a) are hot, (b) have + * lifetimes bounded within a single function, and (c) don't need locking. + * Use PORT_InitCheapArena() and PORT_DestroyCheapArena() to initialize and + * finalize PORTCheapArenaPools. + * + * All the other PORT_Arena* functions will operate safely with either + * subclass. + */ +typedef struct PORTCheapArenaPool_str { + PLArenaPool arena; + PRUint32 magic; /* This is used to distinguish the two subclasses. */ +} PORTCheapArenaPool; + +SEC_BEGIN_PROTOS + +extern void *PORT_Alloc(size_t len); +extern void *PORT_Realloc(void *old, size_t len); +extern void *PORT_ZAlloc(size_t len); +extern void *PORT_ZAllocAligned(size_t bytes, size_t alignment, void **mem); +extern void *PORT_ZAllocAlignedOffset(size_t bytes, size_t alignment, + size_t offset); +extern void PORT_Free(void *ptr); +extern void PORT_ZFree(void *ptr, size_t len); +extern char *PORT_Strdup(const char *s); +extern void PORT_SetError(int value); +extern int PORT_GetError(void); + +/* These functions are for use with PORTArenaPools. */ +extern PLArenaPool *PORT_NewArena(unsigned long chunksize); +extern void PORT_FreeArena(PLArenaPool *arena, PRBool zero); + +/* These functions are for use with PORTCheapArenaPools. */ +extern void PORT_InitCheapArena(PORTCheapArenaPool *arena, + unsigned long chunksize); +extern void PORT_DestroyCheapArena(PORTCheapArenaPool *arena); + +/* These functions work with both kinds of arena pool. */ +extern void *PORT_ArenaAlloc(PLArenaPool *arena, size_t size); +extern void *PORT_ArenaZAlloc(PLArenaPool *arena, size_t size); +extern void *PORT_ArenaGrow(PLArenaPool *arena, void *ptr, + size_t oldsize, size_t newsize); +extern void *PORT_ArenaMark(PLArenaPool *arena); +extern void PORT_ArenaRelease(PLArenaPool *arena, void *mark); +extern void PORT_ArenaZRelease(PLArenaPool *arena, void *mark); +extern void PORT_ArenaUnmark(PLArenaPool *arena, void *mark); +extern char *PORT_ArenaStrdup(PLArenaPool *arena, const char *str); + +SEC_END_PROTOS + +#define PORT_Assert PR_ASSERT +/* This is a variation of PORT_Assert where the arguments will be always + * used either in Debug or not. But, in optimized mode the result will be + * ignored. See more details in Bug 1588015. */ +#define PORT_AssertArg PR_ASSERT_ARG + +/* Assert the current location can't be reached, passing a reason-string. */ +#define PORT_AssertNotReached(reasonStr) PR_NOT_REACHED(reasonStr) + +/* macros to handle endian based byte conversion */ +#define PORT_GET_BYTE_BE(value, offset, len) \ + ((unsigned char)(((len) - (offset)-1) >= sizeof(value) ? 0 : (((value) >> (((len) - (offset)-1) * PR_BITS_PER_BYTE)) & 0xff))) +#define PORT_GET_BYTE_LE(value, offset, len) \ + ((unsigned char)((offset) > sizeof(value) ? 0 : (((value) >> ((offset)*PR_BITS_PER_BYTE)) & 0xff))) + +/* This runs a function that should return SECSuccess. + * Intended for NSS internal use only. + * The return value is asserted in a debug build, otherwise it is ignored. + * This is no substitute for proper error handling. It is OK only if you + * have ensured that the function cannot fail by other means such as checking + * prerequisites. In that case this can be used as a safeguard against + * unexpected changes in a function. + */ +#ifdef DEBUG +#define PORT_CheckSuccess(f) PR_ASSERT((f) == SECSuccess) +#else +#define PORT_CheckSuccess(f) (f) +#endif +#define PORT_ZNew(type) (type *)PORT_ZAlloc(sizeof(type)) +#define PORT_ZNewAligned(type, alignment, mem) \ + (type *)PORT_ZAllocAlignedOffset(sizeof(type), alignment, offsetof(type, mem)) +#define PORT_New(type) (type *)PORT_Alloc(sizeof(type)) +#define PORT_ArenaNew(poolp, type) \ + (type *)PORT_ArenaAlloc(poolp, sizeof(type)) +#define PORT_ArenaZNew(poolp, type) \ + (type *)PORT_ArenaZAlloc(poolp, sizeof(type)) +#define PORT_NewArray(type, num) \ + (type *)PORT_Alloc(sizeof(type) * (num)) +#define PORT_ZNewArray(type, num) \ + (type *)PORT_ZAlloc(sizeof(type) * (num)) +#define PORT_ArenaNewArray(poolp, type, num) \ + (type *)PORT_ArenaAlloc(poolp, sizeof(type) * (num)) +#define PORT_ArenaZNewArray(poolp, type, num) \ + (type *)PORT_ArenaZAlloc(poolp, sizeof(type) * (num)) + +/* Please, keep these defines sorted alphabetically. Thanks! */ + +#define PORT_Atoi(buff) (int)strtol(buff, NULL, 10) + +/* Returns a UTF-8 encoded constant error string for err. + * Returns NULL if initialization of the error tables fails + * due to insufficient memory. + * + * This string must not be modified by the application. + */ +#define PORT_ErrorToString(err) PR_ErrorToString((err), PR_LANGUAGE_I_DEFAULT) + +#define PORT_ErrorToName PR_ErrorToName + +#define PORT_Memcmp memcmp +#define PORT_Memcpy memcpy +#define PORT_Memmove memmove +#define PORT_Memset memset + +#define PORT_Strcasecmp PL_strcasecmp +#define PORT_Strcat strcat +#define PORT_Strchr strchr +#define PORT_Strrchr strrchr +#define PORT_Strcmp strcmp +#define PORT_Strcpy strcpy +#define PORT_Strlen(s) strlen(s) +#define PORT_Strncasecmp PL_strncasecmp +#define PORT_Strncat strncat +#define PORT_Strncmp strncmp +#define PORT_Strncpy strncpy +#define PORT_Strpbrk strpbrk +#define PORT_Strstr strstr +#define PORT_Strtok strtok + +#define PORT_Tolower tolower + +typedef PRBool(PR_CALLBACK *PORTCharConversionWSwapFunc)(PRBool toUnicode, + unsigned char *inBuf, unsigned int inBufLen, + unsigned char *outBuf, unsigned int maxOutBufLen, + unsigned int *outBufLen, PRBool swapBytes); + +typedef PRBool(PR_CALLBACK *PORTCharConversionFunc)(PRBool toUnicode, + unsigned char *inBuf, unsigned int inBufLen, + unsigned char *outBuf, unsigned int maxOutBufLen, + unsigned int *outBufLen); + +SEC_BEGIN_PROTOS + +void PORT_SetUCS4_UTF8ConversionFunction(PORTCharConversionFunc convFunc); +void PORT_SetUCS2_ASCIIConversionFunction(PORTCharConversionWSwapFunc convFunc); +PRBool PORT_UCS4_UTF8Conversion(PRBool toUnicode, unsigned char *inBuf, + unsigned int inBufLen, unsigned char *outBuf, + unsigned int maxOutBufLen, unsigned int *outBufLen); +PRBool PORT_UCS2_ASCIIConversion(PRBool toUnicode, unsigned char *inBuf, + unsigned int inBufLen, unsigned char *outBuf, + unsigned int maxOutBufLen, unsigned int *outBufLen, + PRBool swapBytes); +void PORT_SetUCS2_UTF8ConversionFunction(PORTCharConversionFunc convFunc); +PRBool PORT_UCS2_UTF8Conversion(PRBool toUnicode, unsigned char *inBuf, + unsigned int inBufLen, unsigned char *outBuf, + unsigned int maxOutBufLen, unsigned int *outBufLen); + +/* One-way conversion from ISO-8859-1 to UTF-8 */ +PRBool PORT_ISO88591_UTF8Conversion(const unsigned char *inBuf, + unsigned int inBufLen, unsigned char *outBuf, + unsigned int maxOutBufLen, unsigned int *outBufLen); + +extern PRBool +sec_port_ucs4_utf8_conversion_function( + PRBool toUnicode, + unsigned char *inBuf, + unsigned int inBufLen, + unsigned char *outBuf, + unsigned int maxOutBufLen, + unsigned int *outBufLen); + +extern PRBool +sec_port_ucs2_utf8_conversion_function( + PRBool toUnicode, + unsigned char *inBuf, + unsigned int inBufLen, + unsigned char *outBuf, + unsigned int maxOutBufLen, + unsigned int *outBufLen); + +/* One-way conversion from ISO-8859-1 to UTF-8 */ +extern PRBool +sec_port_iso88591_utf8_conversion_function( + const unsigned char *inBuf, + unsigned int inBufLen, + unsigned char *outBuf, + unsigned int maxOutBufLen, + unsigned int *outBufLen); + +extern int NSS_PutEnv(const char *envVarName, const char *envValue); + +extern void PORT_SafeZero(void *p, size_t n); +extern int NSS_SecureMemcmp(const void *a, const void *b, size_t n); +extern unsigned int NSS_SecureMemcmpZero(const void *mem, size_t n); +extern void NSS_SecureSelect(void *dest, const void *src0, const void *src1, size_t n, unsigned char b); +extern PRBool NSS_GetSystemFIPSEnabled(void); + +/* + * Load a shared library called "newShLibName" in the same directory as + * a shared library that is already loaded, called existingShLibName. + * A pointer to a static function in that shared library, + * staticShLibFunc, is required. + * + * existingShLibName: + * The file name of the shared library that shall be used as the + * "reference library". The loader will attempt to load the requested + * library from the same directory as the reference library. + * + * staticShLibFunc: + * Pointer to a static function in the "reference library". + * + * newShLibName: + * The simple file name of the new shared library to be loaded. + * + * We use PR_GetLibraryFilePathname to get the pathname of the loaded + * shared lib that contains this function, and then do a + * PR_LoadLibraryWithFlags with an absolute pathname for the shared + * library to be loaded. + * + * On Windows, the "alternate search path" strategy is employed, if available. + * On Unix, if existingShLibName is a symbolic link, and no link exists for the + * new library, the original link will be resolved, and the new library loaded + * from the resolved location. + * + * If the new shared library is not found in the same location as the reference + * library, it will then be loaded from the normal system library path. + */ +PRLibrary * +PORT_LoadLibraryFromOrigin(const char *existingShLibName, + PRFuncPtr staticShLibFunc, + const char *newShLibName); + +SEC_END_PROTOS + +/* + * Constant time macros + */ +/* These macros use the fact that arithmetic shift shifts-in the sign bit. + * However, this is not ensured by the C standard so you may need to replace + * them with something else for odd compilers. These macros work for object + * sizes up to 32 bits. The inequalities will produce incorrect results if + * abs(a-b) >= PR_UINT32_MAX/2. This can be a voided if unsigned values stay + * within the range 0-PRUINT32_MAX/2 and signed values stay within the range + * -PRINT32_MAX/2-PRINT32_MAX/2. If these are insufficient, we can fix + * this by either expanding the PORT_CT_DUPLICATE_MSB_TO_ALL to PRUint64 + * or by creating the following new macros for inequality: + * + * PORT_CT_OVERFLOW prevents the overflow condition by handling the case + * where the high bits in a and b are different specially. Basically if + * the high bit in a and b differs we can just + * copy the high bit of one of the parameters to determine the result as + * follows: + * GxU if a has the high bit on, a>b, so d=a + * LxU if b has the high bit on, ab so d=b + * LxS if a has the high bit on, it's negative a> (sizeof(PRInt32) * 8 - 1))) + +/* Constant-time helper macro that selects l or r depending on all-1 or all-0 + * mask m */ +#define PORT_CT_SEL(m, l, r) (((m) & (l)) | (~(m) & (r))) + +/* Constant-time helper macro that returns all-1s if x is not 0; and all-0s + * otherwise. */ +#define PORT_CT_NOT_ZERO(x) (PORT_CT_DUPLICATE_MSB_TO_ALL(((x) | (0 - (x))))) + +/* Constant-time helper macro that returns all-1s if x is 0; and all-0s + * otherwise. */ +#define PORT_CT_ZERO(x) (~PORT_CT_DUPLICATE_MSB_TO_ALL(((x) | (0 - (x))))) + +/* Constant-time helper macro for equalities and inequalities. + * returns all-1's for true and all-0's for false */ +#define PORT_CT_EQ(a, b) PORT_CT_ZERO(((a) - (b))) +#define PORT_CT_NE(a, b) PORT_CT_NOT_ZERO(((a) - (b))) +#define PORT_CT_GT(a, b) PORT_CT_DUPLICATE_MSB_TO_ALL((b) - (a)) +#define PORT_CT_LT(a, b) PORT_CT_DUPLICATE_MSB_TO_ALL((a) - (b)) +#define PORT_CT_GE(a, b) (~PORT_CT_LT(a, b)) +#define PORT_CT_LE(a, b) (~PORT_CT_GT(a, b)) +#define PORT_CT_TRUE (~0) +#define PORT_CT_FALSE 0 + +#ifdef CT_VERIF +#include +#define NSS_CLASSIFY(buf, length) VALGRIND_MAKE_MEM_UNDEFINED(buf, length); +#define NSS_DECLASSIFY(buf, length) VALGRIND_MAKE_MEM_DEFINED(buf, length); +#else +#define NSS_CLASSIFY(buf, length) +#define NSS_DECLASSIFY(buf, length) +#endif + +#endif /* _SECPORT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/shsign.h b/illumos-x86_64/usr/include/mps/shsign.h new file mode 100644 index 00000000..d1a595a3 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/shsign.h @@ -0,0 +1,26 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _SHSIGN_H_ +#define _SHSIGN_H_ + +#define SGN_SUFFIX ".chk" +#define NSS_SIGN_CHK_MAGIC1 0xf1 +#define NSS_SIGN_CHK_MAGIC2 0xc5 +/* new hmac based signatures */ +#define NSS_SIGN_CHK_MAJOR_VERSION 0x02 +#define NSS_SIGN_CHK_MINOR_VERSION 0x01 +#define NSS_SIGN_CHK_TYPE_FLAGS 0xff000000 +#define NSS_SIGN_CHK_FLAG_HMAC 0x80000000 + +typedef struct NSSSignChkHeaderStr NSSSignChkHeader; +struct NSSSignChkHeaderStr { + unsigned char magic1; + unsigned char magic2; + unsigned char majorVersion; + unsigned char minorVersion; + unsigned char offset[4]; + unsigned char type[4]; +}; +#endif /* _SHSIGN_H_ */ diff --git a/illumos-x86_64/usr/include/mps/smime.h b/illumos-x86_64/usr/include/mps/smime.h new file mode 100644 index 00000000..23b08708 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/smime.h @@ -0,0 +1,197 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Header file for routines specific to S/MIME. Keep things that are pure + * pkcs7 out of here; this is for S/MIME policy, S/MIME interoperability, etc. + */ + +#ifndef _SMIME_H_ +#define _SMIME_H_ 1 + +#include "cms.h" + +/************************************************************************/ +SEC_BEGIN_PROTOS + +/* + * Initialize the local recording of the user S/MIME cipher preferences. + * This function is called once for each cipher, the order being + * important (first call records greatest preference, and so on). + * When finished, it is called with a "which" of CIPHER_FAMILID_MASK. + * If the function is called again after that, it is assumed that + * the preferences are being reset, and the old preferences are + * discarded. + * + * This is for a particular user, and right now the storage is + * local, static. SSL uses the same technique, but keeps a copy in + * the ssl session, which can be changed to affect that particular + * ssl session. SSL also allows model sessions, which can be used + * to clone SSL configuration information to child sessions. A future + * version of this function could take a S/MIME content structure and + * affect only the given S/MIME operation. This function would still + * affect the default values. + * + * - The "which" still understands values which are defined in + * ciferfam.h (the SMIME_* values, for example SMIME_DES_CBC_56), + * but the preferred usage is to handle values based on algtags. + * - If "on" is non-zero then the named cipher is enabled, otherwise + * it is disabled. (It is not necessary to call the function for + * ciphers that are disabled, however, as that is the default.) + * + * If the cipher preference is successfully recorded, SECSuccess + * is returned. Otherwise SECFailure is returned. The only errors + * are due to failure allocating memory or bad parameters/calls: + * SEC_ERROR_XXX ("which" is not in the S/MIME cipher family) + * SEC_ERROR_XXX (function is being called more times than there + * are known/expected ciphers) + */ +extern SECStatus NSS_SMIMEUtil_EnableCipher(long which, int on); + +/* + * returns the current state of a particulare encryption algorithm + */ +PRBool NSS_SMIMEUtil_EncryptionEnabled(int which); + +/* + * Initialize the local recording of the S/MIME policy. + * This function is called to allow/disallow a particular cipher by + * policy. It uses the underlying NSS policy system. This can be used + * to allow new algorithms that can then be turned by + * NSS_SMIMEUtil_EnableCipher. + * + * - The "which" still understands values which are defined in + * ciferfam.h (the SMIME_* values, for example SMIME_DES_CBC_56), + * but the preferred usage is to handle values based on algtags. + * - If "on" is non-zero then the named cipher is enabled, otherwise + * it is disabled. + */ +extern SECStatus NSS_SMIMEUtils_AllowCipher(long which, int on); + +/* + * Does the current policy allow S/MIME decryption of this particular + * algorithm and keysize? + */ +extern PRBool NSS_SMIMEUtil_DecryptionAllowed(SECAlgorithmID *algid, PK11SymKey *key); + +/* + * Does the current policy allow S/MIME encryption of this particular + * algorithm and key size? + */ +extern PRBool NSS_SMIMEUtil_EncryptionAllowed(SECAlgorithmID *algid, PK11SymKey *key); + +/* + * Does the current policy allow *any* S/MIME encryption (or decryption)? + * + * This tells whether or not *any* S/MIME encryption can be done, + * according to policy. Callers may use this to do nicer user interface + * (say, greying out a checkbox so a user does not even try to encrypt + * a message when they are not allowed to) or for any reason they want + * to check whether S/MIME encryption (or decryption, for that matter) + * may be done. + * + * It takes no arguments. The return value is a simple boolean: + * PR_TRUE means encryption (or decryption) is *possible* + * (but may still fail due to other reasons, like because we cannot + * find all the necessary certs, etc.; PR_TRUE is *not* a guarantee) + * PR_FALSE means encryption (or decryption) is not permitted + * + * There are no errors from this routine. + */ +extern PRBool NSS_SMIMEUtil_EncryptionPossible(void); + +/* + * Does the current policy allow S/MIME signing with this particular + * algorithm? + */ +extern PRBool NSS_SMIMEUtil_SigningAllowed(SECAlgorithmID *algid); + +/* + * Does the current policy allow S/MIME Key exchange (encrypt) of this particular + * algorithm and keysize? + */ +extern PRBool NSS_SMIMEUtil_KeyEncodingAllowed(SECAlgorithmID *algtag, + CERTCertificate *cert, SECKEYPublicKey *key); + +/* + * Does the current policy allow S/MIME Key exchange (decrypt) of this particular + * algorithm and keysize? + */ +extern PRBool NSS_SMIMEUtil_KeyDecodingAllowed(SECAlgorithmID *algtag, + SECKEYPrivateKey *key); + +/* + * NSS_SMIME_EncryptionPossible - check if any encryption is allowed + * + * This tells whether or not *any* S/MIME encryption can be done, + * according to policy. Callers may use this to do nicer user interface + * (say, greying out a checkbox so a user does not even try to encrypt + * a message when they are not allowed to) or for any reason they want + * to check whether S/MIME encryption (or decryption, for that matter) + * may be done. + * + * It takes no arguments. The return value is a simple boolean: + * PR_TRUE means encryption (or decryption) is *possible* + * (but may still fail due to other reasons, like because we cannot + * find all the necessary certs, etc.; PR_TRUE is *not* a guarantee) + * PR_FALSE means encryption (or decryption) is not permitted + * + * There are no errors from this routine. + */ +extern PRBool NSS_SMIMEUtil_EncryptionPossible(void); + +/* + * NSS_SMIMEUtil_CreateSMIMECapabilities - get S/MIME capabilities attr value + * + * scans the list of allowed and enabled ciphers and construct a PKCS9-compliant + * S/MIME capabilities attribute value. + */ +extern SECStatus NSS_SMIMEUtil_CreateSMIMECapabilities(PLArenaPool *poolp, SECItem *dest); + +/* + * NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value + */ +extern SECStatus NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs(PLArenaPool *poolp, + SECItem *dest, CERTCertificate *cert); + +/* + * NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value using MS oid + */ +extern SECStatus NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs(PLArenaPool *poolp, + SECItem *dest, CERTCertificate *cert); + +/* + * NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference - find cert marked by EncryptionKeyPreference + * attribute + */ +extern CERTCertificate *NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference(CERTCertDBHandle *certdb, + SECItem *DERekp); + +/* + * NSS_SMIMEUtil_FindBulkAlgForRecipients - find bulk algorithm suitable for all recipients + */ +extern SECStatus +NSS_SMIMEUtil_FindBulkAlgForRecipients(CERTCertificate **rcerts, + SECOidTag *bulkalgtag, int *keysize); + +/* + * Return a boolean that indicates whether the underlying library + * will perform as the caller expects. + * + * The only argument is a string, which should be the version + * identifier of the NSS library. That string will be compared + * against a string that represents the actual build version of + * the S/MIME library. + */ +extern PRBool NSSSMIME_VersionCheck(const char *importedVersion); + +/* + * Returns a const string of the S/MIME library version. + */ +extern const char *NSSSMIME_GetVersion(void); + +/************************************************************************/ +SEC_END_PROTOS + +#endif /* _SECMIME_H_ */ diff --git a/illumos-x86_64/usr/include/mps/ssl.h b/illumos-x86_64/usr/include/mps/ssl.h new file mode 100644 index 00000000..2b7df26d --- /dev/null +++ b/illumos-x86_64/usr/include/mps/ssl.h @@ -0,0 +1,1614 @@ +/* + * This file contains prototypes for the public SSL functions. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __ssl_h_ +#define __ssl_h_ + +#include "prtypes.h" +#include "prerror.h" +#include "prio.h" +#include "seccomon.h" +#include "cert.h" +#include "keythi.h" + +#include "sslt.h" /* public ssl data types */ + +#if defined(_WIN32) && !defined(IN_LIBSSL) && !defined(NSS_USE_STATIC_LIBS) +#define SSL_IMPORT extern __declspec(dllimport) +#else +#define SSL_IMPORT extern +#endif + +SEC_BEGIN_PROTOS + +/* constant table enumerating all implemented cipher suites. */ +SSL_IMPORT const PRUint16 SSL_ImplementedCiphers[]; + +/* the same as the above, but is a function */ +SSL_IMPORT const PRUint16 *SSL_GetImplementedCiphers(void); + +/* number of entries in the above table. */ +SSL_IMPORT const PRUint16 SSL_NumImplementedCiphers; + +/* the same as the above, but is a function */ +SSL_IMPORT PRUint16 SSL_GetNumImplementedCiphers(void); + +/* Macro to tell which ciphers in table are SSL2 vs SSL3/TLS. */ +#define SSL_IS_SSL2_CIPHER(which) (((which)&0xfff0) == 0xff00) + +/* +** Imports fd into SSL, returning a new socket. Copies SSL configuration +** from model. +*/ +SSL_IMPORT PRFileDesc *SSL_ImportFD(PRFileDesc *model, PRFileDesc *fd); + +/* +** Imports fd into DTLS, returning a new socket. Copies DTLS configuration +** from model. +*/ +SSL_IMPORT PRFileDesc *DTLS_ImportFD(PRFileDesc *model, PRFileDesc *fd); + +/* +** Enable/disable an ssl mode +** +** SSL_SECURITY: +** enable/disable use of SSL security protocol before connect +** +** SSL_SOCKS: +** enable/disable use of socks before connect +** (No longer supported). +** +** SSL_REQUEST_CERTIFICATE: +** require a certificate during secure connect +*/ +/* options */ +#define SSL_SECURITY 1 /* (on by default) */ +#define SSL_SOCKS 2 /* (off by default) */ +#define SSL_REQUEST_CERTIFICATE 3 /* (off by default) */ +#define SSL_HANDSHAKE_AS_CLIENT 5 /* force accept to hs as client */ + /* (off by default) */ +#define SSL_HANDSHAKE_AS_SERVER 6 /* force connect to hs as server */ + /* (off by default) */ + +/* OBSOLETE: SSL v2 is obsolete and may be removed soon. */ +#define SSL_ENABLE_SSL2 7 /* enable ssl v2 (off by default) */ + +/* OBSOLETE: See "SSL Version Range API" below for the replacement and a +** description of the non-obvious semantics of using SSL_ENABLE_SSL3. +*/ +#define SSL_ENABLE_SSL3 8 /* enable ssl v3 (on by default) */ + +#define SSL_NO_CACHE 9 /* don't use the session cache */ + /* (off by default) */ +#define SSL_REQUIRE_CERTIFICATE 10 /* (SSL_REQUIRE_FIRST_HANDSHAKE */ + /* by default) */ +#define SSL_ENABLE_FDX 11 /* permit simultaneous read/write */ + /* (off by default) */ + +/* OBSOLETE: SSL v2 compatible hellos are not accepted by some TLS servers +** and cannot negotiate extensions. SSL v2 is obsolete. This option may be +** removed soon. +*/ +#define SSL_V2_COMPATIBLE_HELLO 12 /* send v3 client hello in v2 fmt */ + /* (off by default) */ + +/* OBSOLETE: See "SSL Version Range API" below for the replacement and a +** description of the non-obvious semantics of using SSL_ENABLE_TLS. +*/ +#define SSL_ENABLE_TLS 13 /* enable TLS (on by default) */ + +#define SSL_ROLLBACK_DETECTION 14 /* for compatibility, default: on */ +#define SSL_NO_STEP_DOWN 15 /* (unsupported, deprecated, off) */ +#define SSL_BYPASS_PKCS11 16 /* (unsupported, deprecated, off) */ +#define SSL_NO_LOCKS 17 /* Don't use locks for protection */ +#define SSL_ENABLE_SESSION_TICKETS 18 /* Enable TLS SessionTicket */ + /* extension (off by default) */ +#define SSL_ENABLE_DEFLATE 19 /* (unsupported, deprecated, off) */ +#define SSL_ENABLE_RENEGOTIATION 20 /* Values below (default: never) */ +#define SSL_REQUIRE_SAFE_NEGOTIATION 21 /* Peer must send Signaling */ + /* Cipher Suite Value (SCSV) or */ + /* Renegotiation Info (RI) */ + /* extension in ALL handshakes. */ + /* default: off */ +#define SSL_ENABLE_FALSE_START 22 /* Enable SSL false start (off by */ + /* default, applies only to */ + /* clients). False start is a */ +/* mode where an SSL client will start sending application data before + * verifying the server's Finished message. This means that we could end up + * sending data to an imposter. However, the data will be encrypted and + * only the true server can derive the session key. Thus, so long as the + * cipher isn't broken this is safe. The advantage of false start is that + * it saves a round trip for client-speaks-first protocols when performing a + * full handshake. + * + * In addition to enabling this option, the application must register a + * callback using the SSL_SetCanFalseStartCallback function. + */ + +/* For SSL 3.0 and TLS 1.0, by default we prevent chosen plaintext attacks + * on SSL CBC mode cipher suites (see RFC 4346 Section F.3) by splitting + * non-empty application_data records into two records; the first record has + * only the first byte of plaintext, and the second has the rest. + * + * This only prevents the attack in the sending direction; the connection may + * still be vulnerable to such attacks if the peer does not implement a similar + * countermeasure. + * + * This protection mechanism is on by default; the default can be overridden by + * setting NSS_SSL_CBC_RANDOM_IV=0 in the environment prior to execution, + * and/or by the application setting the option SSL_CBC_RANDOM_IV to PR_FALSE. + * + * The per-record IV in TLS 1.1 and later adds one block of overhead per + * record, whereas this hack will add at least two blocks of overhead per + * record, so TLS 1.1+ will always be more efficient. + * + * Other implementations (e.g. some versions of OpenSSL, in some + * configurations) prevent the same attack by prepending an empty + * application_data record to every application_data record they send; we do + * not do that because some implementations cannot handle empty + * application_data records. Also, we only split application_data records and + * not other types of records, because some implementations will not accept + * fragmented records of some other types (e.g. some versions of NSS do not + * accept fragmented alerts). + */ +#define SSL_CBC_RANDOM_IV 23 +#define SSL_ENABLE_OCSP_STAPLING 24 /* Request OCSP stapling (client) */ + +/* SSL_ENABLE_NPN is defunct and defaults to false. + * Using this option will not have any effect but won't produce an error. */ +#define SSL_ENABLE_NPN 25 + +/* SSL_ENABLE_ALPN controls whether the ALPN extension is enabled for the + * initial handshake when application layer protocol negotiation is used. + * SSL_SetNextProtoNego or SSL_SetNextProtoCallback can be used to control + * the application layer protocol negotiation; + * ALPN is not negotiated for renegotiation handshakes, even though the ALPN + * specification defines a way to use ALPN during renegotiations. + * SSL_ENABLE_ALPN is currently enabled by default, but this may change in + * future versions. + */ +#define SSL_ENABLE_ALPN 26 + +/* SSL_REUSE_SERVER_ECDHE_KEY controls whether the ECDHE server key is + * reused for multiple handshakes or generated each time. + * SSL_REUSE_SERVER_ECDHE_KEY is currently disabled by default. + * This socket option is for ECDHE, only. It is unrelated to DHE. + */ +#define SSL_REUSE_SERVER_ECDHE_KEY 27 + +#define SSL_ENABLE_FALLBACK_SCSV 28 /* Send fallback SCSV in \ + * handshakes. */ + +/* SSL_ENABLE_SERVER_DHE controls whether DHE is enabled for the server socket. + */ +#define SSL_ENABLE_SERVER_DHE 29 + +/* Use draft-ietf-tls-session-hash. Controls whether we offer the + * extended_master_secret extension which, when accepted, hashes + * the handshake transcript into the master secret. This option is + * enabled by default. + */ +#define SSL_ENABLE_EXTENDED_MASTER_SECRET 30 + +/* Request Signed Certificate Timestamps via TLS extension (client) */ +#define SSL_ENABLE_SIGNED_CERT_TIMESTAMPS 31 + +/* Ordinarily, when negotiating a TLS_DHE_* cipher suite the server picks the + * group. draft-ietf-tls-negotiated-ff-dhe changes this to use supported_groups + * (formerly supported_curves) to signal which pre-defined groups are OK. + * + * This option causes an NSS client to use this extension and demand that those + * groups be used. A client will signal any enabled DHE groups in the + * supported_groups extension and reject groups that don't match what it has + * enabled. A server will only negotiate TLS_DHE_* cipher suites if the + * client includes the extension. + * + * See SSL_NamedGroupConfig() for how to control which groups are enabled. + * + * This option cannot be enabled if NSS is not compiled with ECC support. + */ +#define SSL_REQUIRE_DH_NAMED_GROUPS 32 + +/* Allow 0-RTT data (for TLS 1.3). + * + * When this option is set, the server's session tickets will contain + * a flag indicating that it accepts 0-RTT. When resuming such a + * session, PR_Write() on the client will be allowed immediately after + * starting the handshake and PR_Read() on the server will be allowed + * on the server to read that data. Calls to + * SSL_GetPreliminaryChannelInfo() and SSL_GetNextProto() + * can be made used during this period to learn about the channel + * parameters. + * + * The transition between the 0-RTT and 1-RTT modes is marked by the + * handshake callback. However, it is possible to force the completion + * of the handshake (and cause the handshake callback to be called) + * prior to reading all 0-RTT data using SSL_ForceHandshake(). To + * ensure that all early data is read before the handshake callback, any + * time that SSL_ForceHandshake() returns a PR_WOULD_BLOCK_ERROR, use + * PR_Read() to read all available data. If PR_Read() is called + * multiple times, this will result in the handshake completing, but the + * handshake callback will occur after early data has all been read. + * + * WARNING: 0-RTT data has different anti-replay and PFS properties than + * the rest of the TLS data. See [draft-ietf-tls-tls13; Section 8] + * for more details. + * + * Note: when DTLS 1.3 is in use, any 0-RTT data received after EndOfEarlyData + * (e.g., because of reordering) is discarded. + */ +#define SSL_ENABLE_0RTT_DATA 33 + +/* Sets a limit to the size of encrypted records (see + * draft-ietf-tls-record-limit). This is the value that is advertised to peers, + * not a limit on the size of records that will be created. Setting this value + * reduces the size of records that will be received (not sent). + * + * This limit applies to the plaintext, but the records that appear on the wire + * will be bigger. This doesn't include record headers, IVs, block cipher + * padding, and authentication tags or MACs. + * + * NSS always advertises the record size limit extension. If this option is not + * set, the extension will contain the maximum allowed size for the selected TLS + * version (currently this is 16384 or 2^14 for TLS 1.2 and lower and 16385 for + * TLS 1.3). + * + * By default, NSS creates records that are the maximum size possible, using all + * the data that was written by the application. Writes larger than the maximum + * are split into maximum sized records, and any remainder (unless + * SSL_CBC_RANDOM_IV is enabled and active). If a peer advertises a record size + * limit then that value is used instead. + */ +#define SSL_RECORD_SIZE_LIMIT 34 + +/* Enables TLS 1.3 compatibility mode. In this mode, the client includes a fake + * session ID in the handshake and sends a ChangeCipherSpec. A server will + * always use the setting chosen by the client, so the value of this option has + * no effect for a server. This setting is ignored for DTLS. */ +#define SSL_ENABLE_TLS13_COMPAT_MODE 35 + +/* Enables the sending of DTLS records using the short (two octet) record + * header. Only do this if there are 2^10 or fewer packets in flight at a time; + * using this with a larger number of packets in flight could mean that packets + * are dropped if there is reordering. + * + * This applies to TLS 1.3 only. This is not a parameter that is negotiated + * during the TLS handshake. Unlike other socket options, this option can be + * changed after a handshake is complete. + */ +#define SSL_ENABLE_DTLS_SHORT_HEADER 36 + +/* + * Enables the processing of the downgrade sentinel that can be added to the + * ServerHello.random by a server that supports Section 4.1.3 of TLS 1.3 + * [RFC8446]. This sentinel will always be generated by a server that + * negotiates a version lower than its maximum, this only controls whether a + * client will treat receipt of a value that indicates a downgrade as an error. + */ +#define SSL_ENABLE_HELLO_DOWNGRADE_CHECK 37 + +/* Enables the SSLv2-compatible ClientHello for servers. NSS does not support + * SSLv2 and will never send an SSLv2-compatible ClientHello as a client. An + * NSS server with this option enabled will accept a ClientHello that is + * v2-compatible as defined in Appendix E.1 of RFC 6101. + * + * This is disabled by default and will be removed in a future version. */ +#define SSL_ENABLE_V2_COMPATIBLE_HELLO 38 + +/* Enables the post-handshake authentication in TLS 1.3. If it is set + * to PR_TRUE, the client will send the "post_handshake_auth" + * extension to indicate that it will process CertificateRequest + * messages after handshake. + * + * This option applies only to clients. For a server, the + * SSL_SendCertificateRequest can be used to request post-handshake + * authentication. + */ +#define SSL_ENABLE_POST_HANDSHAKE_AUTH 39 + +/* Enables the delegated credentials extension (draft-ietf-tls-subcerts). When + * enabled, a client that supports TLS 1.3 will indicate willingness to + * negotiate a delegated credential (DC). Note that client-delegated credentials + * are not currently supported. + * + * If support is indicated, the peer may use a DC to authenticate itself. The DC + * is sent as an extension to the peer's end-entity certificate; the end-entity + * certificate is used to verify the DC, which in turn is used to verify the + * handshake. DCs effectively extend the certificate chain by one, but only + * within the context of TLS. Once issued, DCs can't be revoked; in order to + * mitigate the damage in case the secret key is compromised, the DC is only + * valid for a short time (days, hours, or even minutes). + * + * This library implements draft-07 of the protocol spec. + */ +#define SSL_ENABLE_DELEGATED_CREDENTIALS 40 + +/* Causes TLS (>=1.3) to suppress the EndOfEarlyData message in stream mode. + * + * This is not advisable in general, but the message only exists to delineate + * early data in a streamed connection. DTLS does not use this message as a + * result. The integration of TLS with QUIC, which uses a record/packet + * protection layer that is unreliable, also does not use this message. + * + * On the server, this requires that SSL_RecordLayerData be used. + * EndOfEarlyData is otherwise needed to drive key changes. Additionally, + * servers that use this API must check that handshake messages (Certificate, + * CertificateVerify, and Finished in particular) are only received in epoch 2 + * (Handshake). SSL_RecordLayerData will accept these handshake messages if + * they are passed as epoch 1 (Early Data) in a single call. + * + * Using this option will cause connections to fail if early data is attempted + * and the peer expects this message. + */ +#define SSL_SUPPRESS_END_OF_EARLY_DATA 41 + +/* Enables TLS GREASE (specified in RFC8701, following Chrome 55 implementation + * decisions). + * + * If enabled and the client's ss->vrange.max >= SSL_LIBRARY_VERSION_TLS_1_3 or + * the server's ss->version >= SSL_LIBRARY_VERSION_TLS_1_3, this adds random + * GREASE values to: + * - ClientHello (Client): + * - A cipher_suite value to the cipher_suites field. + * - An empty and a 1B zeroed payload extension. + * - A named group value to the supported_groups extension and a + * KeyShareEntry value for the added named group. + * - A signature algorithm value to the signature_algorithms extension. + * - A version value to the supported_versions extension. + * - A PskKeyExchangeMode value to the psk_key_exchange_modes extension. + * - A alpn value to the application_layer_protocol_negotiation extension. + * + * - CertificateRequest (Server): + * - An empty extension. + * - A signature algorithm value to the signature_algorithms extension. + * + * - NewSessionTicket (Server): + * - An empty extension. + * + * GREASE values MUST nerver be negotiated but ignored. + */ +#define SSL_ENABLE_GREASE 42 + +/* Enables TLS ClientHello Extension Permutation. + * + * On a TLS ClientHello all extensions but the Psk extension + * (which MUST be last) will be sent in randomly shuffeld order. + */ +#define SSL_ENABLE_CH_EXTENSION_PERMUTATION 43 + +/* Import the peer certificate chain into the database before the + * authCertificate callback is invoked for certificate validation. + * This behavior is enabled by default. + */ +#define SSL_DB_LOAD_CERTIFICATE_CHAIN 44 + +#ifdef SSL_DEPRECATED_FUNCTION +/* Old deprecated function names */ +SSL_IMPORT SECStatus SSL_Enable(PRFileDesc *fd, int option, PRIntn on); +SSL_IMPORT SECStatus SSL_EnableDefault(int option, PRIntn on); +#endif + +/* Set (and get) options for sockets and defaults for newly created sockets. + * + * While the |val| parameter of these methods is PRIntn, options only support + * two values by default: PR_TRUE or PR_FALSE. The documentation of specific + * options will explain if other values are permitted. + */ +SSL_IMPORT SECStatus SSL_OptionSet(PRFileDesc *fd, PRInt32 option, PRIntn val); +SSL_IMPORT SECStatus SSL_OptionGet(PRFileDesc *fd, PRInt32 option, PRIntn *val); +SSL_IMPORT SECStatus SSL_OptionSetDefault(PRInt32 option, PRIntn val); +SSL_IMPORT SECStatus SSL_OptionGetDefault(PRInt32 option, PRIntn *val); +SSL_IMPORT SECStatus SSL_CertDBHandleSet(PRFileDesc *fd, CERTCertDBHandle *dbHandle); + +/* SSLNextProtoCallback is called during the handshake for the server, when an + * Application-Layer Protocol Negotiation (ALPN) extension has been received + * from the client. |protos| and |protosLen| define a buffer which contains the + * client's advertisement. + * |protoOut| is a buffer provided by the caller, of length 255 (the maximum + * allowed by the protocol). On successful return, the protocol to be announced + * to the server will be in |protoOut| and its length in |*protoOutLen|. + * + * The callback must return SECFailure or SECSuccess (not SECWouldBlock). + */ +typedef SECStatus(PR_CALLBACK *SSLNextProtoCallback)( + void *arg, + PRFileDesc *fd, + const unsigned char *protos, + unsigned int protosLen, + unsigned char *protoOut, + unsigned int *protoOutLen, + unsigned int protoMaxOut); + +/* SSL_SetNextProtoCallback sets a callback function to handle ALPN Negotiation. + * It causes a client to advertise ALPN. */ +SSL_IMPORT SECStatus SSL_SetNextProtoCallback(PRFileDesc *fd, + SSLNextProtoCallback callback, + void *arg); + +/* SSL_SetNextProtoNego can be used as an alternative to + * SSL_SetNextProtoCallback. + * + * Using this function allows client and server to transparently support ALPN. + * The same set of protocols will be advertised via ALPN and, if the server + * uses ALPN to select a protocol, SSL_GetNextProto will return + * SSL_NEXT_PROTO_SELECTED as the state. + * + * Because the predecessor to ALPN, NPN, used the first protocol as the fallback + * protocol, when sending an ALPN extension, the first protocol is moved to the + * end of the list. This indicates that the fallback protocol is the least + * preferred. The other protocols should be in preference order. + * + * The supported protocols are specified in |data| in wire-format (8-bit + * length-prefixed). For example: "\010http/1.1\006spdy/2". + * + * An empty value (i.e., where |length| is 0 and |data| is any value, + * including NULL) forcibly disables ALPN. In this mode, the server will + * reject any ClientHello that includes the ALPN extension. + * + * Calling this function overrides the callback previously set by + * SSL_SetNextProtoCallback. */ +SSL_IMPORT SECStatus SSL_SetNextProtoNego(PRFileDesc *fd, + const unsigned char *data, + unsigned int length); + +typedef enum SSLNextProtoState { + SSL_NEXT_PROTO_NO_SUPPORT = 0, /* No peer support */ + SSL_NEXT_PROTO_NEGOTIATED = 1, /* Mutual agreement */ + SSL_NEXT_PROTO_NO_OVERLAP = 2, /* No protocol overlap found */ + SSL_NEXT_PROTO_SELECTED = 3, /* Server selected proto (ALPN) */ + SSL_NEXT_PROTO_EARLY_VALUE = 4 /* We are in 0-RTT using this value. */ +} SSLNextProtoState; + +/* SSL_GetNextProto can be used in the HandshakeCallback or any time after + * a handshake to retrieve the result of the Next Protocol negotiation. + * + * The length of the negotiated protocol, if any, is written into *bufLen. + * If the negotiated protocol is longer than bufLenMax, then SECFailure is + * returned. Otherwise, the negotiated protocol, if any, is written into buf, + * and SECSuccess is returned. */ +SSL_IMPORT SECStatus SSL_GetNextProto(PRFileDesc *fd, + SSLNextProtoState *state, + unsigned char *buf, + unsigned int *bufLen, + unsigned int bufLenMax); + +/* +** Control ciphers that SSL uses. If on is non-zero then the named cipher +** is enabled, otherwise it is disabled. +** The "cipher" values are defined in sslproto.h (the SSL_EN_* values). +** EnableCipher records user preferences. +** SetPolicy sets the policy according to the policy module. +*/ +#ifdef SSL_DEPRECATED_FUNCTION +/* Old deprecated function names */ +SSL_IMPORT SECStatus SSL_EnableCipher(long which, PRBool enabled); +SSL_IMPORT SECStatus SSL_SetPolicy(long which, int policy); +#endif + +/* New function names */ +SSL_IMPORT SECStatus SSL_CipherPrefSet(PRFileDesc *fd, PRInt32 cipher, PRBool enabled); +SSL_IMPORT SECStatus SSL_CipherPrefGet(PRFileDesc *fd, PRInt32 cipher, PRBool *enabled); +SSL_IMPORT SECStatus SSL_CipherPrefSetDefault(PRInt32 cipher, PRBool enabled); +SSL_IMPORT SECStatus SSL_CipherPrefGetDefault(PRInt32 cipher, PRBool *enabled); +SSL_IMPORT SECStatus SSL_CipherPolicySet(PRInt32 cipher, PRInt32 policy); +SSL_IMPORT SECStatus SSL_CipherPolicyGet(PRInt32 cipher, PRInt32 *policy); + +/* +** Control for TLS signature schemes for TLS 1.2 and 1.3. +** +** This governs what signature schemes (or algorithms) are sent by a client in +** the signature_algorithms extension. A client will not accept a signature +** from a server unless it uses an enabled algorithm. +** +** This also governs what the server sends in the supported_signature_algorithms +** field of a CertificateRequest. +** +** This changes what the server uses to sign ServerKeyExchange and +** CertificateVerify messages. An endpoint uses the first entry from this list +** that is compatible with both its certificate and its peer's supported +** values. +** +** This configuration affects TLS 1.2, but the combination of EC group and hash +** algorithm is interpreted loosely to be compatible with other implementations. +** For TLS 1.2, NSS will ignore the curve group when generating or verifying +** ECDSA signatures. For example, a P-384 ECDSA certificate is used with +** SHA-256 if ssl_sig_ecdsa_secp256r1_sha256 is enabled. +** +** Omitting SHA-256 schemes from this list might be foolish. Support is +** mandatory in TLS 1.2 and 1.3 and there might be interoperability issues. +*/ +SSL_IMPORT SECStatus SSL_SignatureSchemePrefSet( + PRFileDesc *fd, const SSLSignatureScheme *schemes, unsigned int count); + +/* Deprecated, use SSL_SignatureSchemePrefSet() instead. */ +SSL_IMPORT SECStatus SSL_SignaturePrefSet( + PRFileDesc *fd, const SSLSignatureAndHashAlg *algorithms, + unsigned int count); + +/* +** Get the currently configured signature schemes. +** +** The schemes are written to |schemes| but not if there are more than +** |maxCount| values configured. The number of schemes that are in use are +** written to |count|. This fails if |maxCount| is insufficiently large. +*/ +SSL_IMPORT SECStatus SSL_SignatureSchemePrefGet( + PRFileDesc *fd, SSLSignatureScheme *algorithms, unsigned int *count, + unsigned int maxCount); + +/* Deprecated, use SSL_SignatureSchemePrefGet() instead. */ +SSL_IMPORT SECStatus SSL_SignaturePrefGet( + PRFileDesc *fd, SSLSignatureAndHashAlg *algorithms, unsigned int *count, + unsigned int maxCount); + +/* +** Returns the maximum number of signature algorithms that are supported and +** can be set or retrieved using SSL_SignatureSchemePrefSet or +** SSL_SignatureSchemePrefGet. +*/ +SSL_IMPORT unsigned int SSL_SignatureMaxCount(void); + +/* +** Define custom priorities for EC and FF groups used in DH key exchange and EC +** groups for ECDSA. This only changes the order of enabled lists (and thus +** their priorities) and enables all groups in |groups| while disabling all other +** groups. +*/ +SSL_IMPORT SECStatus SSL_NamedGroupConfig(PRFileDesc *fd, + const SSLNamedGroup *groups, + unsigned int num_groups); + +/* +** Configure the socket to configure additional key shares. Normally when a TLS +** 1.3 ClientHello is sent, just one key share is included using the first +** preference group (as set by SSL_NamedGroupConfig). If the server decides to +** pick a different group for key exchange, it is forced to send a +** HelloRetryRequest, which adds an entire round trip of latency. +** +** This function can be used to configure libssl to generate additional key +** shares when sending a TLS 1.3 ClientHello. If |count| is set to a non-zero +** value, then additional key shares are generated. Shares are added in the +** preference order set in SSL_NamedGroupConfig. |count| can be set to any +** value; NSS limits the number of shares to the number of supported groups. +*/ +SSL_IMPORT SECStatus SSL_SendAdditionalKeyShares(PRFileDesc *fd, + unsigned int count); + +/* Deprecated: use SSL_NamedGroupConfig() instead. +** SSL_DHEGroupPrefSet is used to configure the set of allowed/enabled DHE group +** parameters that can be used by NSS for the given server socket. +** The first item in the array is used as the default group, if no other +** selection criteria can be used by NSS. +** The set is provided as an array of identifiers as defined by SSLDHEGroupType. +** If more than one group identifier is provided, NSS will select the one to use. +** For example, a TLS extension sent by the client might indicate a preference. +*/ +SSL_IMPORT SECStatus SSL_DHEGroupPrefSet(PRFileDesc *fd, + const SSLDHEGroupType *groups, + PRUint16 num_groups); + +/* Enable the use of a DHE group that's smaller than the library default, +** for backwards compatibility reasons. The DH parameters will be created +** at the time this function is called, which might take a very long time. +** The function will block until generation is completed. +** The intention is to enforce that fresh and safe parameters are generated +** each time a process is started. +** At the time this API was initially implemented, the API will enable the +** use of 1024 bit DHE parameters. This value might get increased in future +** versions of NSS. +** +** It is allowed to call this API will a NULL value for parameter fd, +** which will prepare the global parameters that NSS will reuse for the remainder +** of the process lifetime. This can be used early after startup of a process, +** to avoid a delay when handling incoming client connections. +** This preparation with a NULL for parameter fd will NOT enable the weak group +** on sockets. The function needs to be called again for every socket that +** should use the weak group. +** +** It is allowed to use this API in combination with the SSL_NamedGroupConfig API. +** If both APIs have been called, the weakest group will be used, unless it is +** certain that the client supports larger group parameters. The weak group will +** be used as the default group for TLS <= 1.2, overriding the preference for +** the first group potentially set with a call to SSL_NamedGroupConfig. +*/ +SSL_IMPORT SECStatus SSL_EnableWeakDHEPrimeGroup(PRFileDesc *fd, PRBool enabled); + +/* SSL Version Range API +** +** This API should be used to control SSL 3.0 & TLS support instead of the +** older SSL_Option* API; however, the SSL_Option* API MUST still be used to +** control SSL 2.0 support. In this version of libssl, SSL 3.0 and TLS 1.0 are +** enabled by default. Future versions of libssl may change which versions of +** the protocol are enabled by default. +** +** The SSLProtocolVariant enum indicates whether the protocol is of type +** stream or datagram. This must be provided to the functions that do not +** take an fd. Functions which take an fd will get the variant from the fd, +** which is typed. +** +** Using the new version range API in conjunction with the older +** SSL_OptionSet-based API for controlling the enabled protocol versions may +** cause unexpected results. Going forward, we guarantee only the following: +** +** SSL_OptionGet(SSL_ENABLE_TLS) will return PR_TRUE if *ANY* versions of TLS +** are enabled. +** +** SSL_OptionSet(SSL_ENABLE_TLS, PR_FALSE) will disable *ALL* versions of TLS, +** including TLS 1.0 and later. +** +** The above two properties provide compatibility for applications that use +** SSL_OptionSet to implement the insecure fallback from TLS 1.x to SSL 3.0. +** +** SSL_OptionSet(SSL_ENABLE_TLS, PR_TRUE) will enable TLS 1.0, and may also +** enable some later versions of TLS, if it is necessary to do so in order to +** keep the set of enabled versions contiguous. For example, if TLS 1.2 is +** enabled, then after SSL_OptionSet(SSL_ENABLE_TLS, PR_TRUE), TLS 1.0, +** TLS 1.1, and TLS 1.2 will be enabled, and the call will have no effect on +** whether SSL 3.0 is enabled. If no later versions of TLS are enabled at the +** time SSL_OptionSet(SSL_ENABLE_TLS, PR_TRUE) is called, then no later +** versions of TLS will be enabled by the call. +** +** SSL_OptionSet(SSL_ENABLE_SSL3, PR_FALSE) will disable SSL 3.0, and will not +** change the set of TLS versions that are enabled. +** +** SSL_OptionSet(SSL_ENABLE_SSL3, PR_TRUE) will enable SSL 3.0, and may also +** enable some versions of TLS if TLS 1.1 or later is enabled at the time of +** the call, the same way SSL_OptionSet(SSL_ENABLE_TLS, PR_TRUE) works, in +** order to keep the set of enabled versions contiguous. +*/ + +/* Returns, in |*vrange|, the range of SSL3/TLS versions supported for the +** given protocol variant by the version of libssl linked-to at runtime. +*/ +SSL_IMPORT SECStatus SSL_VersionRangeGetSupported( + SSLProtocolVariant protocolVariant, SSLVersionRange *vrange); + +/* Returns, in |*vrange|, the range of SSL3/TLS versions enabled by default +** for the given protocol variant. +*/ +SSL_IMPORT SECStatus SSL_VersionRangeGetDefault( + SSLProtocolVariant protocolVariant, SSLVersionRange *vrange); + +/* Sets the range of enabled-by-default SSL3/TLS versions for the given +** protocol variant to |*vrange|. +*/ +SSL_IMPORT SECStatus SSL_VersionRangeSetDefault( + SSLProtocolVariant protocolVariant, const SSLVersionRange *vrange); + +/* Returns, in |*vrange|, the range of enabled SSL3/TLS versions for |fd|. */ +SSL_IMPORT SECStatus SSL_VersionRangeGet(PRFileDesc *fd, + SSLVersionRange *vrange); + +/* Sets the range of enabled SSL3/TLS versions for |fd| to |*vrange|. */ +SSL_IMPORT SECStatus SSL_VersionRangeSet(PRFileDesc *fd, + const SSLVersionRange *vrange); + +/* Sets the version to check the server random against for the + * fallback check defined in [draft-ietf-tls-tls13-11 Section 6.3.1.1]. + * This function is provided to allow for detection of forced downgrade + * attacks against client-side reconnect-and-fallback outside of TLS + * by setting |version| to be that of the original connection, rather + * than that of the new connection. + * + * The default, which can also be enabled by setting |version| to + * zero, is just to check against the max version in the + * version range (see SSL_VersionRangeSet). */ +SSL_IMPORT SECStatus SSL_SetDowngradeCheckVersion(PRFileDesc *fd, + PRUint16 version); + +/* Values for "policy" argument to SSL_CipherPolicySet */ +/* Values returned by SSL_CipherPolicyGet. */ +#define SSL_NOT_ALLOWED 0 /* or invalid or unimplemented */ +#define SSL_ALLOWED 1 +#define SSL_RESTRICTED 2 /* only with "Step-Up" certs. */ + +/* Values for "on" with SSL_REQUIRE_CERTIFICATE. */ +#define SSL_REQUIRE_NEVER ((PRBool)0) +#define SSL_REQUIRE_ALWAYS ((PRBool)1) +#define SSL_REQUIRE_FIRST_HANDSHAKE ((PRBool)2) +#define SSL_REQUIRE_NO_ERROR ((PRBool)3) + +/* Values for "on" with SSL_ENABLE_RENEGOTIATION */ +/* Never renegotiate at all. */ +#define SSL_RENEGOTIATE_NEVER ((PRBool)0) +/* Renegotiate without restriction, whether or not the peer's client hello */ +/* bears the renegotiation info extension. Vulnerable, as in the past. */ +#define SSL_RENEGOTIATE_UNRESTRICTED ((PRBool)1) +/* Only renegotiate if the peer's hello bears the TLS renegotiation_info */ +/* extension. This is safe renegotiation. */ +#define SSL_RENEGOTIATE_REQUIRES_XTN ((PRBool)2) +/* Disallow unsafe renegotiation in server sockets only, but allow clients */ +/* to continue to renegotiate with vulnerable servers. */ +/* This value should only be used during the transition period when few */ +/* servers have been upgraded. */ +#define SSL_RENEGOTIATE_TRANSITIONAL ((PRBool)3) + +/* +** Reset the handshake state for fd. This will make the complete SSL +** handshake protocol execute from the ground up on the next i/o +** operation. +*/ +SSL_IMPORT SECStatus SSL_ResetHandshake(PRFileDesc *fd, PRBool asServer); + +/* +** Force the handshake for fd to complete immediately. This blocks until +** the complete SSL handshake protocol is finished. +*/ +SSL_IMPORT SECStatus SSL_ForceHandshake(PRFileDesc *fd); + +/* +** Same as above, but with an I/O timeout. +*/ +SSL_IMPORT SECStatus SSL_ForceHandshakeWithTimeout(PRFileDesc *fd, + PRIntervalTime timeout); + +/* +** Query security status of socket. *on is set to one if security is +** enabled. *keySize will contain the stream key size used. *issuer will +** contain the RFC1485 verison of the name of the issuer of the +** certificate at the other end of the connection. For a client, this is +** the issuer of the server's certificate; for a server, this is the +** issuer of the client's certificate (if any). Subject is the subject of +** the other end's certificate. The pointers can be zero if the desired +** data is not needed. All strings returned by this function are owned +** by the caller, and need to be freed with PORT_Free. +*/ +SSL_IMPORT SECStatus SSL_SecurityStatus(PRFileDesc *fd, int *on, char **cipher, + int *keySize, int *secretKeySize, + char **issuer, char **subject); + +/* Values for "on" */ +#define SSL_SECURITY_STATUS_NOOPT -1 +#define SSL_SECURITY_STATUS_OFF 0 +#define SSL_SECURITY_STATUS_ON_HIGH 1 +#define SSL_SECURITY_STATUS_ON_LOW 2 +#define SSL_SECURITY_STATUS_FORTEZZA 3 /* NO LONGER SUPPORTED */ + +/* +** Return the certificate for our SSL peer. If the client calls this +** it will always return the server's certificate. If the server calls +** this, it may return NULL if client authentication is not enabled or +** if the client had no certificate when asked. +** "fd" the socket "file" descriptor +*/ +SSL_IMPORT CERTCertificate *SSL_PeerCertificate(PRFileDesc *fd); + +/* +** Return the certificates presented by the SSL peer. If the SSL peer +** did not present certificates, return NULL with the +** SSL_ERROR_NO_CERTIFICATE error. On failure, return NULL with an error +** code other than SSL_ERROR_NO_CERTIFICATE. +** "fd" the socket "file" descriptor +*/ +SSL_IMPORT CERTCertList *SSL_PeerCertificateChain(PRFileDesc *fd); + +/* SSL_PeerStapledOCSPResponses returns the OCSP responses that were provided + * by the TLS server. The return value is a pointer to an internal SECItemArray + * that contains the returned OCSP responses; it is only valid until the + * callback function that calls SSL_PeerStapledOCSPResponses returns. + * + * If no OCSP responses were given by the server then the result will be empty. + * If there was an error, then the result will be NULL. + * + * You must set the SSL_ENABLE_OCSP_STAPLING option to enable OCSP stapling. + * to be provided by a server. + * + * libssl does not do any validation of the OCSP response itself; the + * authenticate certificate hook is responsible for doing so. The default + * authenticate certificate hook, SSL_AuthCertificate, does not implement + * any OCSP stapling funtionality, but this may change in future versions. + */ +SSL_IMPORT const SECItemArray *SSL_PeerStapledOCSPResponses(PRFileDesc *fd); + +/* SSL_PeerSignedCertTimestamps returns the signed_certificate_timestamp + * extension data provided by the TLS server. The return value is a pointer + * to an internal SECItem that contains the returned response (as a serialized + * SignedCertificateTimestampList, see RFC 6962). The returned pointer is only + * valid until the callback function that calls SSL_PeerSignedCertTimestamps + * (e.g. the authenticate certificate hook, or the handshake callback) returns. + * + * If no Signed Certificate Timestamps were given by the server then the result + * will be empty. If there was an error, then the result will be NULL. + * + * You must set the SSL_ENABLE_SIGNED_CERT_TIMESTAMPS option to indicate support + * for Signed Certificate Timestamps to a server. + * + * libssl does not do any parsing or validation of the response itself. + */ +SSL_IMPORT const SECItem *SSL_PeerSignedCertTimestamps(PRFileDesc *fd); + +/* SSL_SetStapledOCSPResponses stores an array of one or multiple OCSP responses + * in the fd's data, which may be sent as part of a server side cert_status + * handshake message. Parameter |responses| is for the server certificate of + * the key exchange type |kea|. + * The function will duplicate the responses array. + * + * Deprecated: see SSL_ConfigSecureServer for details. + */ +SSL_IMPORT SECStatus +SSL_SetStapledOCSPResponses(PRFileDesc *fd, const SECItemArray *responses, + SSLKEAType kea); + +/* + * SSL_SetSignedCertTimestamps stores serialized signed_certificate_timestamp + * extension data in the fd. The signed_certificate_timestamp data is sent + * during the handshake (if requested by the client). Parameter |scts| + * is for the server certificate of the key exchange type |kea|. + * The function will duplicate the provided data item. To clear previously + * set data for a given key exchange type |kea|, pass NULL to |scts|. + * + * Deprecated: see SSL_ConfigSecureServer for details. + */ +SSL_IMPORT SECStatus +SSL_SetSignedCertTimestamps(PRFileDesc *fd, const SECItem *scts, + SSLKEAType kea); + +/* +** Authenticate certificate hook. Called when a certificate comes in +** (because of SSL_REQUIRE_CERTIFICATE in SSL_Enable) to authenticate the +** certificate. +** +** The authenticate certificate hook must return SECSuccess to indicate the +** certificate is valid, SECFailure to indicate the certificate is invalid, +** or SECWouldBlock if the application will authenticate the certificate +** asynchronously. SECWouldBlock is only supported for non-blocking sockets. +** +** If the authenticate certificate hook returns SECFailure, then the bad cert +** hook will be called. The bad cert handler is NEVER called if the +** authenticate certificate hook returns SECWouldBlock. If the application +** needs to handle and/or override a bad cert, it should do so before it +** calls SSL_AuthCertificateComplete (modifying the error it passes to +** SSL_AuthCertificateComplete as needed). +** +** See the documentation for SSL_AuthCertificateComplete for more information +** about the asynchronous behavior that occurs when the authenticate +** certificate hook returns SECWouldBlock. +** +** RFC 6066 says that clients should send the bad_certificate_status_response +** alert when they encounter an error processing the stapled OCSP response. +** libssl does not provide a way for the authenticate certificate hook to +** indicate that an OCSP error (SEC_ERROR_OCSP_*) that it returns is an error +** in the stapled OCSP response or an error in some other OCSP response. +** Further, NSS does not provide a convenient way to control or determine +** which OCSP response(s) were used to validate a certificate chain. +** Consequently, the current version of libssl does not ever send the +** bad_certificate_status_response alert. This may change in future releases. +*/ +typedef SECStatus(PR_CALLBACK *SSLAuthCertificate)(void *arg, PRFileDesc *fd, + PRBool checkSig, + PRBool isServer); + +SSL_IMPORT SECStatus SSL_AuthCertificateHook(PRFileDesc *fd, + SSLAuthCertificate f, + void *arg); + +/* An implementation of the certificate authentication hook */ +SSL_IMPORT SECStatus SSL_AuthCertificate(void *arg, PRFileDesc *fd, + PRBool checkSig, PRBool isServer); + +/* + * Prototype for SSL callback to get client auth data from the application. + * arg - application passed argument + * caNames - pointer to distinguished names of CAs that the server likes + * pRetCert - pointer to pointer to cert, for return of cert + * pRetKey - pointer to key pointer, for return of key + * Return value can be one of {SECSuccess, SECFailure, SECWouldBlock} + * + * If SECSuccess, pRetCert and pRetKey should be set to the selected + * client cert and private key respectively. If SECFailure or SECWouldBlock + * they should not be changed. + * + * Ownership of pRetCert and pRetKey passes to NSS. The application must not + * mutate or free the structures after passing them to NSS. + * + * Returning SECWouldBlock will block the handshake until SSL_ClientCertCallbackComplete + * is called. Note that references to *caNames should not be kept after SSLGetClientAuthData + * returns. Instead, take a copy of the data. + * + * See also the comments for SSL_ClientCertCallbackComplete. + */ +typedef SECStatus(PR_CALLBACK *SSLGetClientAuthData)(void *arg, + PRFileDesc *fd, + CERTDistNames *caNames, + CERTCertificate **pRetCert, /*return */ + SECKEYPrivateKey **pRetKey); /* return */ + +/* + * Set the client side callback for SSL to retrieve user's private key + * and certificate. + * fd - the file descriptor for the connection in question + * f - the application's callback that delivers the key and cert + * a - application specific data + */ +SSL_IMPORT SECStatus SSL_GetClientAuthDataHook(PRFileDesc *fd, + SSLGetClientAuthData f, void *a); + +/* +** SNI extension processing callback function. +** It is called when SSL socket receives SNI extension in ClientHello message. +** Upon this callback invocation, application is responsible to reconfigure the +** socket with the data for a particular server name. +** There are three potential outcomes of this function invocation: +** * application does not recognize the name or the type and wants the +** "unrecognized_name" alert be sent to the client. In this case the callback +** function must return SSL_SNI_SEND_ALERT status. +** * application does not recognize the name, but wants to continue with +** the handshake using the current socket configuration. In this case, +** no socket reconfiguration is needed and the function should return +** SSL_SNI_CURRENT_CONFIG_IS_USED. +** * application recognizes the name and reconfigures the socket with +** appropriate certs, key, etc. There are many ways to reconfigure. NSS +** provides SSL_ReconfigFD function that can be used to update the socket +** data from model socket. To continue with the rest of the handshake, the +** implementation function should return an index of a name it has chosen. +** LibSSL will ignore any SNI extension received in a ClientHello message +** if application does not register a SSLSNISocketConfig callback. +** Each type field of SECItem indicates the name type. +** NOTE: currently RFC3546 defines only one name type: sni_host_name. +** Client is allowed to send only one name per known type. LibSSL will +** send an "unrecognized_name" alert if SNI extension name list contains more +** then one name of a type. +*/ +typedef PRInt32(PR_CALLBACK *SSLSNISocketConfig)(PRFileDesc *fd, + const SECItem *srvNameArr, + PRUint32 srvNameArrSize, + void *arg); + +/* +** SSLSNISocketConfig should return an index within 0 and srvNameArrSize-1 +** when it has reconfigured the socket fd to use certs and keys, etc +** for a specific name. There are two other allowed return values. One +** tells libSSL to use the default cert and key. The other tells libSSL +** to send the "unrecognized_name" alert. These values are: +**/ +#define SSL_SNI_CURRENT_CONFIG_IS_USED -1 +#define SSL_SNI_SEND_ALERT -2 + +/* +** Set application implemented SNISocketConfig callback. +*/ +SSL_IMPORT SECStatus SSL_SNISocketConfigHook(PRFileDesc *fd, + SSLSNISocketConfig f, + void *arg); + +/* +** Reconfigure fd SSL socket with model socket parameters. Sets +** server certs and keys, list of trust anchor, socket options +** and all SSL socket call backs and parameters. +*/ +SSL_IMPORT PRFileDesc *SSL_ReconfigFD(PRFileDesc *model, PRFileDesc *fd); + +/* + * Set the client side argument for SSL to retrieve PKCS #11 pin. + * fd - the file descriptor for the connection in question + * a - pkcs11 application specific data + */ +SSL_IMPORT SECStatus SSL_SetPKCS11PinArg(PRFileDesc *fd, void *a); + +/* +** These are callbacks for dealing with SSL alerts. +*/ + +typedef PRUint8 SSLAlertLevel; +typedef PRUint8 SSLAlertDescription; + +typedef struct { + SSLAlertLevel level; + SSLAlertDescription description; +} SSLAlert; + +typedef void(PR_CALLBACK *SSLAlertCallback)(const PRFileDesc *fd, void *arg, + const SSLAlert *alert); + +SSL_IMPORT SECStatus SSL_AlertReceivedCallback(PRFileDesc *fd, SSLAlertCallback cb, + void *arg); +SSL_IMPORT SECStatus SSL_AlertSentCallback(PRFileDesc *fd, SSLAlertCallback cb, + void *arg); +/* +** This is a callback for dealing with server certs that are not authenticated +** by the client. The client app can decide that it actually likes the +** cert by some external means and restart the connection. +** +** The bad cert hook must return SECSuccess to override the result of the +** authenticate certificate hook, SECFailure if the certificate should still be +** considered invalid, or SECWouldBlock if the application will authenticate +** the certificate asynchronously. SECWouldBlock is only supported for +** non-blocking sockets. +** +** See the documentation for SSL_AuthCertificateComplete for more information +** about the asynchronous behavior that occurs when the bad cert hook returns +** SECWouldBlock. +*/ +typedef SECStatus(PR_CALLBACK *SSLBadCertHandler)(void *arg, PRFileDesc *fd); +SSL_IMPORT SECStatus SSL_BadCertHook(PRFileDesc *fd, SSLBadCertHandler f, + void *arg); + +/* +** Configure SSL socket for running a secure server. Needs the +** certificate for the server and the servers private key. The arguments +** are copied. +** +** This method should be used in preference to SSL_ConfigSecureServer, +** SSL_ConfigSecureServerWithCertChain, SSL_SetStapledOCSPResponses, and +** SSL_SetSignedCertTimestamps. +** +** The authentication method is determined from the certificate and private key +** based on how libssl authenticates peers. Primarily, this uses the value of +** the SSLAuthType enum and is derived from the type of public key in the +** certificate. For example, different RSA certificates might be saved for +** signing (ssl_auth_rsa_sign) and key encipherment +** (ssl_auth_rsa_decrypt). Unique to RSA, the same certificate can be used for +** both usages. Additional information about the authentication method is also +** used: EC keys with different curves are separately stored. +** +** Only one certificate is stored for each authentication method. +** +** The optional |data| argument contains additional information about the +** certificate: +** +** - |authType| (with a value other than ssl_auth_null) limits the +** authentication method; this is primarily useful in limiting the use of an +** RSA certificate to one particular key usage (either signing or key +** encipherment) when its key usages indicate support for both. +** +** - |certChain| provides an explicit certificate chain, rather than relying on +** NSS functions for finding a certificate chain. +** +** - |stapledOCSPResponses| provides a response for OCSP stapling. +** +** - |signedCertTimestamps| provides a value for the +** signed_certificate_timestamp extension used in certificate transparency. +** +** The |data_len| argument provides the length of the data. This should be set +** to |sizeof(data)|. +** +** This function allows an application to provide certificates with narrow key +** usages attached to them. For instance, RSA keys can be provided that are +** limited to signing or decryption only. Multiple EC certificates with keys on +** different named curves can be provided. +** +** Unlike SSL_ConfigSecureServer(WithCertChain), this function does not accept +** NULL for the |cert| and |key| arguments. It will replace certificates that +** have the same type, but it cannot be used to remove certificates that have +** already been configured. +*/ +SSL_IMPORT SECStatus SSL_ConfigServerCert( + PRFileDesc *fd, CERTCertificate *cert, SECKEYPrivateKey *key, + const SSLExtraServerCertData *data, unsigned int data_len); + +/* +** Deprecated variant of SSL_ConfigServerCert. +** +** This uses values from the SSLKEAType to identify the type of |key| that the +** |cert| contains. This is incorrect, since key exchange and authentication +** are separated in some cipher suites (in particular, ECDHE_RSA_* suites). +** +** Providing a |kea| parameter of ssl_kea_ecdh (or kt_ecdh) is interpreted as +** providing both ECDH and ECDSA certificates. +*/ +SSL_IMPORT SECStatus SSL_ConfigSecureServer( + PRFileDesc *fd, CERTCertificate *cert, + SECKEYPrivateKey *key, SSLKEAType kea); + +/* +** Deprecated variant of SSL_ConfigSecureServerCert. The |data| argument to +** SSL_ConfigSecureServerCert can be used to pass a certificate chain. +*/ +SSL_IMPORT SECStatus +SSL_ConfigSecureServerWithCertChain(PRFileDesc *fd, CERTCertificate *cert, + const CERTCertificateList *certChainOpt, + SECKEYPrivateKey *key, SSLKEAType kea); + +/* +** SSL_SetSessionTicketKeyPair configures an asymmetric key pair for use in +** wrapping session ticket keys, used by the server. This function currently +** only accepts an RSA public/private key pair. +** +** Prior to the existence of this function, NSS used an RSA private key +** associated with a configured certificate to perform session ticket +** encryption. If this function isn't used, the keys provided with a configured +** RSA certificate are used for wrapping session ticket keys. +** +** NOTE: This key is used for all self-encryption but is named for +** session tickets for historical reasons. +*/ +SSL_IMPORT SECStatus +SSL_SetSessionTicketKeyPair(SECKEYPublicKey *pubKey, SECKEYPrivateKey *privKey); + +/* +** Configure a secure server's session-id cache. Define the maximum number +** of entries in the cache, the longevity of the entires, and the directory +** where the cache files will be placed. These values can be zero, and +** if so, the implementation will choose defaults. +** This version of the function is for use in applications that have only one +** process that uses the cache (even if that process has multiple threads). +*/ +SSL_IMPORT SECStatus SSL_ConfigServerSessionIDCache(int maxCacheEntries, + PRUint32 timeout, + PRUint32 ssl3_timeout, + const char *directory); + +/* Configure a secure server's session-id cache. Depends on value of + * enableMPCache, configures malti-proc or single proc cache. */ +SSL_IMPORT SECStatus SSL_ConfigServerSessionIDCacheWithOpt( + PRUint32 timeout, + PRUint32 ssl3_timeout, + const char *directory, + int maxCacheEntries, + int maxCertCacheEntries, + int maxSrvNameCacheEntries, + PRBool enableMPCache); + +/* +** Like SSL_ConfigServerSessionIDCache, with one important difference. +** If the application will run multiple processes (as opposed to, or in +** addition to multiple threads), then it must call this function, instead +** of calling SSL_ConfigServerSessionIDCache(). +** This has nothing to do with the number of processORs, only processEs. +** This function sets up a Server Session ID (SID) cache that is safe for +** access by multiple processes on the same system. +*/ +SSL_IMPORT SECStatus SSL_ConfigMPServerSIDCache(int maxCacheEntries, + PRUint32 timeout, + PRUint32 ssl3_timeout, + const char *directory); + +/* Get and set the configured maximum number of mutexes used for the +** server's store of SSL sessions. This value is used by the server +** session ID cache initialization functions shown above. Note that on +** some platforms, these mutexes are actually implemented with POSIX +** semaphores, or with unnamed pipes. The default value varies by platform. +** An attempt to set a too-low maximum will return an error and the +** configured value will not be changed. +*/ +SSL_IMPORT PRUint32 SSL_GetMaxServerCacheLocks(void); +SSL_IMPORT SECStatus SSL_SetMaxServerCacheLocks(PRUint32 maxLocks); + +/* environment variable set by SSL_ConfigMPServerSIDCache, and queried by + * SSL_InheritMPServerSIDCache when envString is NULL. + */ +#define SSL_ENV_VAR_NAME "SSL_INHERITANCE" + +/* called in child to inherit SID Cache variables. + * If envString is NULL, this function will use the value of the environment + * variable "SSL_INHERITANCE", otherwise the string value passed in will be + * used. + */ +SSL_IMPORT SECStatus SSL_InheritMPServerSIDCache(const char *envString); + +/* +** Set the callback that gets called when a TLS handshake is complete. The +** handshake callback is called after verifying the peer's Finished message and +** before processing incoming application data. +** +** For the initial handshake: If the handshake false started (see +** SSL_ENABLE_FALSE_START), then application data may already have been sent +** before the handshake callback is called. If we did not false start then the +** callback will get called before any application data is sent. +*/ +typedef void(PR_CALLBACK *SSLHandshakeCallback)(PRFileDesc *fd, + void *client_data); +SSL_IMPORT SECStatus SSL_HandshakeCallback(PRFileDesc *fd, + SSLHandshakeCallback cb, void *client_data); + +/* Applications that wish to enable TLS false start must set this callback +** function. NSS will invoke the functon to determine if a particular +** connection should use false start or not. SECSuccess indicates that the +** callback completed successfully, and if so *canFalseStart indicates if false +** start can be used. If the callback does not return SECSuccess then the +** handshake will be canceled. NSS's recommended criteria can be evaluated by +** calling SSL_RecommendedCanFalseStart. +** +** If no false start callback is registered then false start will never be +** done, even if the SSL_ENABLE_FALSE_START option is enabled. +**/ +typedef SECStatus(PR_CALLBACK *SSLCanFalseStartCallback)( + PRFileDesc *fd, void *arg, PRBool *canFalseStart); + +SSL_IMPORT SECStatus SSL_SetCanFalseStartCallback( + PRFileDesc *fd, SSLCanFalseStartCallback callback, void *arg); + +/* This function sets *canFalseStart according to the recommended criteria for +** false start. These criteria may change from release to release and may depend +** on which handshake features have been negotiated and/or properties of the +** certifciates/keys used on the connection. +*/ +SSL_IMPORT SECStatus SSL_RecommendedCanFalseStart(PRFileDesc *fd, + PRBool *canFalseStart); + +/* +** For the server, request a new handshake. For the client, begin a new +** handshake. If flushCache is non-zero, the SSL3 cache entry will be +** flushed first, ensuring that a full SSL handshake will be done. +** If flushCache is zero, and an SSL connection is established, it will +** do the much faster session restart handshake. This will change the +** session keys without doing another private key operation. +*/ +SSL_IMPORT SECStatus SSL_ReHandshake(PRFileDesc *fd, PRBool flushCache); + +/* +** Same as above, but with an I/O timeout. +*/ +SSL_IMPORT SECStatus SSL_ReHandshakeWithTimeout(PRFileDesc *fd, + PRBool flushCache, + PRIntervalTime timeout); + +#ifdef SSL_DEPRECATED_FUNCTION +/* deprecated! +** For the server, request a new handshake. For the client, begin a new +** handshake. Flushes SSL3 session cache entry first, ensuring that a +** full handshake will be done. +** This call is equivalent to SSL_ReHandshake(fd, PR_TRUE) +*/ +SSL_IMPORT SECStatus SSL_RedoHandshake(PRFileDesc *fd); +#endif + +/* + * Allow the application to pass a URL or hostname into the SSL library. + */ +SSL_IMPORT SECStatus SSL_SetURL(PRFileDesc *fd, const char *url); + +/* + * Allow an application to define a set of trust anchors for peer + * cert validation. + */ +SSL_IMPORT SECStatus SSL_SetTrustAnchors(PRFileDesc *fd, CERTCertList *list); + +/* +** Return the number of bytes that SSL has waiting in internal buffers. +** Return 0 if security is not enabled. +*/ +SSL_IMPORT int SSL_DataPending(PRFileDesc *fd); + +/* +** Invalidate the SSL session associated with fd. +*/ +SSL_IMPORT SECStatus SSL_InvalidateSession(PRFileDesc *fd); + +/* +** Return a SECItem containing the SSL session ID associated with the fd. +*/ +SSL_IMPORT SECItem *SSL_GetSessionID(PRFileDesc *fd); + +/* +** Clear out the client's SSL session cache, not the server's session cache. +*/ +SSL_IMPORT void SSL_ClearSessionCache(void); + +/* +** Close the server's SSL session cache. +*/ +SSL_IMPORT SECStatus SSL_ShutdownServerSessionIDCache(void); + +/* +** Set peer information so we can correctly look up SSL session later. +** You only have to do this if you're tunneling through a proxy. +*/ +SSL_IMPORT SECStatus SSL_SetSockPeerID(PRFileDesc *fd, const char *peerID); + +/* +** Reveal the security information for the peer. +*/ +SSL_IMPORT CERTCertificate *SSL_RevealCert(PRFileDesc *socket); +SSL_IMPORT void *SSL_RevealPinArg(PRFileDesc *socket); +SSL_IMPORT char *SSL_RevealURL(PRFileDesc *socket); + +/* This callback may be passed to the SSL library via a call to + * SSL_GetClientAuthDataHook() for each SSL client socket. + * It will be invoked when SSL needs to know what certificate and private key + * (if any) to use to respond to a request for client authentication. + * If arg is non-NULL, it is a pointer to a NULL-terminated string containing + * the nickname of the cert/key pair to use. + * If arg is NULL, this function will search the cert and key databases for + * a suitable match and send it if one is found. + */ +SSL_IMPORT SECStatus +NSS_GetClientAuthData(void *arg, + PRFileDesc *socket, + struct CERTDistNamesStr *caNames, + struct CERTCertificateStr **pRetCert, + struct SECKEYPrivateKeyStr **pRetKey); + +/* This function can be called by the appliation's custom GetClientAuthHook + * to filter out any certs in the cert list that doesn't match the negotiated + * requirements of the current SSL connection. + */ +SSL_IMPORT SECStatus +SSL_FilterClientCertListBySocket(PRFileDesc *socket, CERTCertList *certlist); + +/* This function can be called by the application's custom GetClientAuthHook + * to determine if a single certificate matches the negotiated requirements of + * the current SSL connection. + */ +SSL_IMPORT PRBool +SSL_CertIsUsable(PRFileDesc *socket, CERTCertificate *cert); + +/* +** Configure DTLS-SRTP (RFC 5764) cipher suite preferences. +** Input is a list of ciphers in descending preference order and a length +** of the list. As a side effect, this causes the use_srtp extension to be +** negotiated. +** +** Invalid or unimplemented cipher suites in |ciphers| are ignored. If at +** least one cipher suite in |ciphers| is implemented, returns SECSuccess. +** Otherwise returns SECFailure. +*/ +SSL_IMPORT SECStatus SSL_SetSRTPCiphers(PRFileDesc *fd, + const PRUint16 *ciphers, + unsigned int numCiphers); + +/* +** Get the selected DTLS-SRTP cipher suite (if any). +** To be called after the handshake completes. +** Returns SECFailure if not negotiated. +*/ +SSL_IMPORT SECStatus SSL_GetSRTPCipher(PRFileDesc *fd, + PRUint16 *cipher); + +/* + * Look to see if any of the signers in the cert chain for "cert" are found + * in the list of caNames. + * Returns SECSuccess if so, SECFailure if not. + * Used by NSS_GetClientAuthData. May be used by other callback functions. + */ +SSL_IMPORT SECStatus NSS_CmpCertChainWCANames(CERTCertificate *cert, + CERTDistNames *caNames); + +/* Deprecated. This reports a misleading value for certificates that might + * be used for signing rather than key exchange. + * Returns key exchange type of the keys in an SSL server certificate. + */ +SSL_IMPORT SSLKEAType NSS_FindCertKEAType(CERTCertificate *cert); + +/* Set cipher policies to a predefined Domestic (U.S.A.) policy. + * This essentially allows all supported ciphers. + */ +SSL_IMPORT SECStatus NSS_SetDomesticPolicy(void); + +/* Set cipher policies to a predefined Policy that is exportable from the USA + * according to present U.S. policies as we understand them. + * It is the same as NSS_SetDomesticPolicy now. + */ +SSL_IMPORT SECStatus NSS_SetExportPolicy(void); + +/* Set cipher policies to a predefined Policy that is exportable from the USA + * according to present U.S. policies as we understand them, and that the + * nation of France will permit to be imported into their country. + * It is the same as NSS_SetDomesticPolicy now. + */ +SSL_IMPORT SECStatus NSS_SetFrancePolicy(void); + +SSL_IMPORT SSL3Statistics *SSL_GetStatistics(void); + +/* Report more information than SSL_SecurityStatus. + * Caller supplies the info struct. This function fills it in. Caller should + * pass sizeof(SSLChannelInfo) as the |len| argument. + * + * The information here will be zeroed prior to details being confirmed. The + * details are confirmed either when a Finished message is received, or - for a + * client - when the second flight of messages have been sent. This function + * therefore produces unreliable results prior to receiving the + * SSLHandshakeCallback or the SSLCanFalseStartCallback. + */ +SSL_IMPORT SECStatus SSL_GetChannelInfo(PRFileDesc *fd, SSLChannelInfo *info, + PRUintn len); +/* Get preliminary information about a channel. + * Caller supplies the info struct. This function fills it in. Caller should + * pass sizeof(SSLPreliminaryChannelInfo) as the |len| argument. + * + * This function can be called prior to handshake details being confirmed (see + * SSL_GetChannelInfo above for what that means). Thus, information provided by + * this function is available to SSLAuthCertificate, SSLGetClientAuthData, + * SSLSNISocketConfig, and other callbacks that might be called during the + * processing of the first flight of client of server handshake messages. + * Values are marked as being unavailable when renegotiation is initiated. + */ +SSL_IMPORT SECStatus +SSL_GetPreliminaryChannelInfo(PRFileDesc *fd, + SSLPreliminaryChannelInfo *info, + PRUintn len); +/* Get information about cipher suite with id of |cipherSuite|. + * Caller supplies the info struct. This function fills it in. Caller should + * pass sizeof(SSLCipherSuiteInfo) as the |len| argument. + */ +SSL_IMPORT SECStatus SSL_GetCipherSuiteInfo(PRUint16 cipherSuite, + SSLCipherSuiteInfo *info, PRUintn len); + +/* Returnes negotiated through SNI host info. */ +SSL_IMPORT SECItem *SSL_GetNegotiatedHostInfo(PRFileDesc *fd); + +/* Export keying material according to RFC 5705. +** fd must correspond to a TLS 1.0 or higher socket and out must +** already be allocated. If hasContext is false, it uses the no-context +** construction from the RFC and ignores the context and contextLen +** arguments. +*/ +SSL_IMPORT SECStatus SSL_ExportKeyingMaterial(PRFileDesc *fd, + const char *label, + unsigned int labelLen, + PRBool hasContext, + const unsigned char *context, + unsigned int contextLen, + unsigned char *out, + unsigned int outLen); + +/* Early exporters are used if 0-RTT is enabled. This is TLS 1.3 only. Note + * that in TLS 1.3, an empty context is equivalent to an absent context. */ +SSL_IMPORT SECStatus SSL_ExportEarlyKeyingMaterial(PRFileDesc *fd, + const char *label, + unsigned int labelLen, + const unsigned char *context, + unsigned int contextLen, + unsigned char *out, + unsigned int outLen); + +/* +** Return a new reference to the certificate that was most recently sent +** to the peer on this SSL/TLS connection, or NULL if none has been sent. +*/ +SSL_IMPORT CERTCertificate *SSL_LocalCertificate(PRFileDesc *fd); + +#define SSL_CBP_SSL3 0x0001 /* (deprecated) */ +#define SSL_CBP_TLS1_0 0x0002 /* (deprecated) */ + +/* DEPRECATED: The PKCS#11 bypass has been removed. +** This function will now always return false. */ +SSL_IMPORT SECStatus SSL_CanBypass(CERTCertificate *cert, + SECKEYPrivateKey *privKey, + PRUint32 protocolmask, + PRUint16 *ciphers, int nciphers, + PRBool *pcanbypass, void *pwArg); + +/* +** Did the handshake with the peer negotiate the given extension? +** Output parameter valid only if function returns SECSuccess +*/ +SSL_IMPORT SECStatus SSL_HandshakeNegotiatedExtension(PRFileDesc *socket, + SSLExtensionType extId, + PRBool *yes); + +/* +** How long should we wait before retransmitting the next flight of +** the DTLS handshake? Returns SECFailure if not DTLS or not in a +** handshake. +*/ +SSL_IMPORT SECStatus DTLS_GetHandshakeTimeout(PRFileDesc *socket, + PRIntervalTime *timeout); + +/* + * Return a boolean that indicates whether the underlying library + * will perform as the caller expects. + * + * The only argument is a string, which should be the version + * identifier of the NSS library. That string will be compared + * against a string that represents the actual build version of + * the SSL library. + */ +extern PRBool NSSSSL_VersionCheck(const char *importedVersion); + +/* + * Returns a const string of the SSL library version. + */ +extern const char *NSSSSL_GetVersion(void); + +/* Restart an SSL connection that was paused to do asynchronous certificate + * chain validation (when the auth certificate hook or bad cert handler + * returned SECWouldBlock). + * + * This function only works for non-blocking sockets; Do not use it for + * blocking sockets. Currently, this function works only for the client role of + * a connection; it does not work for the server role. + * + * The application must call SSL_AuthCertificateComplete with 0 as the value of + * the error parameter after it has successfully validated the peer's + * certificate, in order to continue the SSL handshake. + * + * The application may call SSL_AuthCertificateComplete with a non-zero value + * for error (e.g. SEC_ERROR_REVOKED_CERTIFICATE) when certificate validation + * fails, before it closes the connection. If the application does so, an + * alert corresponding to the error (e.g. certificate_revoked) will be sent to + * the peer. See the source code of the internal function + * ssl3_SendAlertForCertError for the current mapping of error to alert. This + * mapping may change in future versions of libssl. + * + * This function will not complete the entire handshake. The application must + * call SSL_ForceHandshake, PR_Recv, PR_Send, etc. after calling this function + * to force the handshake to complete. + * + * On the first handshake of a connection, libssl will wait for the peer's + * certificate to be authenticated before calling the handshake callback, + * sending a client certificate, sending any application data, or returning + * any application data to the application. On subsequent (renegotiation) + * handshakes, libssl will block the handshake unconditionally while the + * certificate is being validated. + * + * libssl may send and receive handshake messages while waiting for the + * application to call SSL_AuthCertificateComplete, and it may call other + * callbacks (e.g, the client auth data hook) before + * SSL_AuthCertificateComplete has been called. + * + * An application that uses this asynchronous mechanism will usually have lower + * handshake latency if it has to do public key operations on the certificate + * chain and/or CRL/OCSP/cert fetching during the authentication, especially if + * it does so in parallel on another thread. However, if the application can + * authenticate the peer's certificate quickly then it may be more efficient + * to use the synchronous mechanism (i.e. returning SECFailure/SECSuccess + * instead of SECWouldBlock from the authenticate certificate hook). + * + * Be careful about converting an application from synchronous cert validation + * to asynchronous certificate validation. A naive conversion is likely to + * result in deadlocks; e.g. the application will wait in PR_Poll for network + * I/O on the connection while all network I/O on the connection is blocked + * waiting for this function to be called. + * + * Returns SECFailure on failure, SECSuccess on success. Never returns + * SECWouldBlock. Note that SSL_AuthCertificateComplete will (usually) return + * SECSuccess; do not interpret the return value of SSL_AuthCertificateComplete + * as an indicator of whether it is OK to continue using the connection. For + * example, SSL_AuthCertificateComplete(fd, SEC_ERROR_REVOKED_CERTIFICATE) will + * return SECSuccess (normally), but that does not mean that the application + * should continue using the connection. If the application passes a non-zero + * value for second argument (error), or if SSL_AuthCertificateComplete returns + * anything other than SECSuccess, then the application should close the + * connection. + */ +SSL_IMPORT SECStatus SSL_AuthCertificateComplete(PRFileDesc *fd, + PRErrorCode error); + +/* Restart an SSL connection which was paused to do asynchronous client + * certificate selection (when the client certificate hook returned SECWouldBlock). + * + * This function only works for non-blocking sockets; Do not use it for + * blocking sockets. This function works only for the client role of + * a connection; it does not work for the server role. + * + * If a certificate has been sucessfully selected, the application must call + * SSL_ClientCertCallbackComplete with: + * - SECSuccess (0) as the value of outcome + * - a valid SECKEYPrivateKey located at *clientPrivateKey + * - a valid CERTCertificate located at *clientCertificate + * The ownership of these latter structures will pass to NSS and the application + * MUST not retain any references to them or invalidate them. + * + * If a certificate has not been selected, the application must call + * SSL_ClientCertCallbackComplete with: + * - SECFailure (-1) as the value of outcome + * - *clientPrivateKey set to NULL. + * - *clientCertificate set to NULL + * + * Once the application has returned SECWouldBlock to getClientAuthData + * the handshake will not proceed until this function is called. It is an + * error to call this function when the handshake is not waiting on client + * certificate selection, or to call this function more than once. + + * This function will not complete the entire handshake. The application must + * call SSL_ForceHandshake, PR_Recv, PR_Send, etc. after calling this function + * to force the handshake to complete. + * + * Be careful about converting an application from synchronous cert selection + * to asynchronous certificate selection. A naive conversion is likely to + * result in deadlocks; e.g. the application will wait in PR_Poll for network + * I/O on the connection while all network I/O on the connection is blocked + * waiting for this function to be called. + * + * Note that SSL_ClientCertCallbackComplete will (usually) return + * SECSuccess; SECFailure indicates that the function was invoked incorrectly or + * an error whilst processing the handshake. The return code does not indicate + * whether or not the provided private key and certificate were sucessfully loaded + * or accepted by the server. + */ +SSL_IMPORT SECStatus SSL_ClientCertCallbackComplete(PRFileDesc *fd, SECStatus outcome, SECKEYPrivateKey *clientPrivateKey, CERTCertificate *clientCertificate); + +/* + * This is used to access experimental APIs. Don't call this directly. This is + * used to enable the experimental APIs that are defined in "sslexp.h". + */ +SSL_IMPORT void *SSL_GetExperimentalAPI(const char *name); + +SEC_END_PROTOS + +#endif /* __ssl_h_ */ diff --git a/illumos-x86_64/usr/include/mps/sslerr.h b/illumos-x86_64/usr/include/mps/sslerr.h new file mode 100644 index 00000000..dbf36610 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/sslerr.h @@ -0,0 +1,300 @@ +/* + * Enumeration of all SSL-specific error codes. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef __SSL_ERR_H_ +#define __SSL_ERR_H_ + +/* clang-format off */ + +#define SSL_ERROR_BASE (-0x3000) +#define SSL_ERROR_LIMIT (SSL_ERROR_BASE + 1000) + +#define IS_SSL_ERROR(code) \ + (((code) >= SSL_ERROR_BASE) && ((code) < SSL_ERROR_LIMIT)) + +#ifndef NO_SECURITY_ERROR_ENUM +typedef enum { + SSL_ERROR_EXPORT_ONLY_SERVER = (SSL_ERROR_BASE + 0), + /* error 0 is obsolete */ + SSL_ERROR_US_ONLY_SERVER = (SSL_ERROR_BASE + 1), + /* error 1 is obsolete */ + SSL_ERROR_NO_CYPHER_OVERLAP = (SSL_ERROR_BASE + 2), + /* + * Received an alert reporting what we did wrong. (more alerts below) + */ + SSL_ERROR_NO_CERTIFICATE /*_ALERT */ = (SSL_ERROR_BASE + 3), + SSL_ERROR_BAD_CERTIFICATE = (SSL_ERROR_BASE + 4), + /* error 4 is obsolete */ + SSL_ERROR_UNUSED_5 = (SSL_ERROR_BASE + 5), + /* error 5 is obsolete */ + SSL_ERROR_BAD_CLIENT = (SSL_ERROR_BASE + 6), + SSL_ERROR_BAD_SERVER = (SSL_ERROR_BASE + 7), + SSL_ERROR_UNSUPPORTED_CERTIFICATE_TYPE = (SSL_ERROR_BASE + 8), + /* error 8 is obsolete */ + SSL_ERROR_UNSUPPORTED_VERSION = (SSL_ERROR_BASE + 9), + SSL_ERROR_UNUSED_10 = (SSL_ERROR_BASE + 10), + /* error 10 is obsolete */ + SSL_ERROR_WRONG_CERTIFICATE = (SSL_ERROR_BASE + 11), + /* error 11 is obsolete */ + SSL_ERROR_BAD_CERT_DOMAIN = (SSL_ERROR_BASE + 12), + SSL_ERROR_POST_WARNING = (SSL_ERROR_BASE + 13), + /* error 13 is obsolete */ + SSL_ERROR_SSL2_DISABLED = (SSL_ERROR_BASE + 14), + /* error 14 is obsolete */ + SSL_ERROR_BAD_MAC_READ = (SSL_ERROR_BASE + 15), + /* + * Received an alert reporting what we did wrong. + * (two more alerts above, and many more below) + */ + SSL_ERROR_BAD_MAC_ALERT = (SSL_ERROR_BASE + 16), + SSL_ERROR_BAD_CERT_ALERT = (SSL_ERROR_BASE + 17), + SSL_ERROR_REVOKED_CERT_ALERT = (SSL_ERROR_BASE + 18), + SSL_ERROR_EXPIRED_CERT_ALERT = (SSL_ERROR_BASE + 19), + + SSL_ERROR_SSL_DISABLED = (SSL_ERROR_BASE + 20), + SSL_ERROR_FORTEZZA_PQG = (SSL_ERROR_BASE + 21), + /* error 21 is obsolete */ + SSL_ERROR_UNKNOWN_CIPHER_SUITE = (SSL_ERROR_BASE + 22), + SSL_ERROR_NO_CIPHERS_SUPPORTED = (SSL_ERROR_BASE + 23), + SSL_ERROR_BAD_BLOCK_PADDING = (SSL_ERROR_BASE + 24), + SSL_ERROR_RX_RECORD_TOO_LONG = (SSL_ERROR_BASE + 25), + SSL_ERROR_TX_RECORD_TOO_LONG = (SSL_ERROR_BASE + 26), + /* + * Received a malformed (too long or short) SSL handshake. + */ + SSL_ERROR_RX_MALFORMED_HELLO_REQUEST = (SSL_ERROR_BASE + 27), + SSL_ERROR_RX_MALFORMED_CLIENT_HELLO = (SSL_ERROR_BASE + 28), + SSL_ERROR_RX_MALFORMED_SERVER_HELLO = (SSL_ERROR_BASE + 29), + SSL_ERROR_RX_MALFORMED_CERTIFICATE = (SSL_ERROR_BASE + 30), + SSL_ERROR_RX_MALFORMED_SERVER_KEY_EXCH = (SSL_ERROR_BASE + 31), + SSL_ERROR_RX_MALFORMED_CERT_REQUEST = (SSL_ERROR_BASE + 32), + SSL_ERROR_RX_MALFORMED_HELLO_DONE = (SSL_ERROR_BASE + 33), + SSL_ERROR_RX_MALFORMED_CERT_VERIFY = (SSL_ERROR_BASE + 34), + SSL_ERROR_RX_MALFORMED_CLIENT_KEY_EXCH = (SSL_ERROR_BASE + 35), + SSL_ERROR_RX_MALFORMED_FINISHED = (SSL_ERROR_BASE + 36), + /* + * Received a malformed (too long or short) SSL record. + */ + SSL_ERROR_RX_MALFORMED_CHANGE_CIPHER = (SSL_ERROR_BASE + 37), + SSL_ERROR_RX_MALFORMED_ALERT = (SSL_ERROR_BASE + 38), + SSL_ERROR_RX_MALFORMED_HANDSHAKE = (SSL_ERROR_BASE + 39), + SSL_ERROR_RX_MALFORMED_APPLICATION_DATA = (SSL_ERROR_BASE + 40), + /* + * Received an SSL handshake that was inappropriate for the state we're in. + * E.g. Server received message from server, or wrong state in state machine. + */ + SSL_ERROR_RX_UNEXPECTED_HELLO_REQUEST = (SSL_ERROR_BASE + 41), + SSL_ERROR_RX_UNEXPECTED_CLIENT_HELLO = (SSL_ERROR_BASE + 42), + SSL_ERROR_RX_UNEXPECTED_SERVER_HELLO = (SSL_ERROR_BASE + 43), + SSL_ERROR_RX_UNEXPECTED_CERTIFICATE = (SSL_ERROR_BASE + 44), + SSL_ERROR_RX_UNEXPECTED_SERVER_KEY_EXCH = (SSL_ERROR_BASE + 45), + SSL_ERROR_RX_UNEXPECTED_CERT_REQUEST = (SSL_ERROR_BASE + 46), + SSL_ERROR_RX_UNEXPECTED_HELLO_DONE = (SSL_ERROR_BASE + 47), + SSL_ERROR_RX_UNEXPECTED_CERT_VERIFY = (SSL_ERROR_BASE + 48), + SSL_ERROR_RX_UNEXPECTED_CLIENT_KEY_EXCH = (SSL_ERROR_BASE + 49), + SSL_ERROR_RX_UNEXPECTED_FINISHED = (SSL_ERROR_BASE + 50), + /* + * Received an SSL record that was inappropriate for the state we're in. + */ + SSL_ERROR_RX_UNEXPECTED_CHANGE_CIPHER = (SSL_ERROR_BASE + 51), + SSL_ERROR_RX_UNEXPECTED_ALERT = (SSL_ERROR_BASE + 52), + SSL_ERROR_RX_UNEXPECTED_HANDSHAKE = (SSL_ERROR_BASE + 53), + SSL_ERROR_RX_UNEXPECTED_APPLICATION_DATA = (SSL_ERROR_BASE + 54), + /* + * Received record/message with unknown discriminant. + */ + SSL_ERROR_RX_UNKNOWN_RECORD_TYPE = (SSL_ERROR_BASE + 55), + SSL_ERROR_RX_UNKNOWN_HANDSHAKE = (SSL_ERROR_BASE + 56), + SSL_ERROR_RX_UNKNOWN_ALERT = (SSL_ERROR_BASE + 57), + /* + * Received an alert reporting what we did wrong. (more alerts above) + */ + SSL_ERROR_CLOSE_NOTIFY_ALERT = (SSL_ERROR_BASE + 58), + SSL_ERROR_HANDSHAKE_UNEXPECTED_ALERT = (SSL_ERROR_BASE + 59), + SSL_ERROR_DECOMPRESSION_FAILURE_ALERT = (SSL_ERROR_BASE + 60), + SSL_ERROR_HANDSHAKE_FAILURE_ALERT = (SSL_ERROR_BASE + 61), + SSL_ERROR_ILLEGAL_PARAMETER_ALERT = (SSL_ERROR_BASE + 62), + SSL_ERROR_UNSUPPORTED_CERT_ALERT = (SSL_ERROR_BASE + 63), + SSL_ERROR_CERTIFICATE_UNKNOWN_ALERT = (SSL_ERROR_BASE + 64), + + SSL_ERROR_GENERATE_RANDOM_FAILURE = (SSL_ERROR_BASE + 65), + SSL_ERROR_SIGN_HASHES_FAILURE = (SSL_ERROR_BASE + 66), + SSL_ERROR_EXTRACT_PUBLIC_KEY_FAILURE = (SSL_ERROR_BASE + 67), + SSL_ERROR_SERVER_KEY_EXCHANGE_FAILURE = (SSL_ERROR_BASE + 68), + SSL_ERROR_CLIENT_KEY_EXCHANGE_FAILURE = (SSL_ERROR_BASE + 69), + + SSL_ERROR_ENCRYPTION_FAILURE = (SSL_ERROR_BASE + 70), + SSL_ERROR_DECRYPTION_FAILURE = (SSL_ERROR_BASE + 71), + /* error 71 is obsolete */ + SSL_ERROR_SOCKET_WRITE_FAILURE = (SSL_ERROR_BASE + 72), + + SSL_ERROR_MD5_DIGEST_FAILURE = (SSL_ERROR_BASE + 73), + SSL_ERROR_SHA_DIGEST_FAILURE = (SSL_ERROR_BASE + 74), + SSL_ERROR_MAC_COMPUTATION_FAILURE = (SSL_ERROR_BASE + 75), + SSL_ERROR_SYM_KEY_CONTEXT_FAILURE = (SSL_ERROR_BASE + 76), + SSL_ERROR_SYM_KEY_UNWRAP_FAILURE = (SSL_ERROR_BASE + 77), + SSL_ERROR_PUB_KEY_SIZE_LIMIT_EXCEEDED = (SSL_ERROR_BASE + 78), + /* error 78 is obsolete */ + SSL_ERROR_IV_PARAM_FAILURE = (SSL_ERROR_BASE + 79), + SSL_ERROR_INIT_CIPHER_SUITE_FAILURE = (SSL_ERROR_BASE + 80), + SSL_ERROR_SESSION_KEY_GEN_FAILURE = (SSL_ERROR_BASE + 81), + SSL_ERROR_NO_SERVER_KEY_FOR_ALG = (SSL_ERROR_BASE + 82), + SSL_ERROR_TOKEN_INSERTION_REMOVAL = (SSL_ERROR_BASE + 83), + SSL_ERROR_TOKEN_SLOT_NOT_FOUND = (SSL_ERROR_BASE + 84), + SSL_ERROR_NO_COMPRESSION_OVERLAP = (SSL_ERROR_BASE + 85), + SSL_ERROR_HANDSHAKE_NOT_COMPLETED = (SSL_ERROR_BASE + 86), + SSL_ERROR_BAD_HANDSHAKE_HASH_VALUE = (SSL_ERROR_BASE + 87), + SSL_ERROR_CERT_KEA_MISMATCH = (SSL_ERROR_BASE + 88), + SSL_ERROR_NO_TRUSTED_SSL_CLIENT_CA = (SSL_ERROR_BASE + 89), + /* error 89 is obsolete */ + SSL_ERROR_SESSION_NOT_FOUND = (SSL_ERROR_BASE + 90), + + SSL_ERROR_DECRYPTION_FAILED_ALERT = (SSL_ERROR_BASE + 91), + SSL_ERROR_RECORD_OVERFLOW_ALERT = (SSL_ERROR_BASE + 92), + SSL_ERROR_UNKNOWN_CA_ALERT = (SSL_ERROR_BASE + 93), + SSL_ERROR_ACCESS_DENIED_ALERT = (SSL_ERROR_BASE + 94), + SSL_ERROR_DECODE_ERROR_ALERT = (SSL_ERROR_BASE + 95), + SSL_ERROR_DECRYPT_ERROR_ALERT = (SSL_ERROR_BASE + 96), + SSL_ERROR_EXPORT_RESTRICTION_ALERT = (SSL_ERROR_BASE + 97), + SSL_ERROR_PROTOCOL_VERSION_ALERT = (SSL_ERROR_BASE + 98), + SSL_ERROR_INSUFFICIENT_SECURITY_ALERT = (SSL_ERROR_BASE + 99), + SSL_ERROR_INTERNAL_ERROR_ALERT = (SSL_ERROR_BASE + 100), + SSL_ERROR_USER_CANCELED_ALERT = (SSL_ERROR_BASE + 101), + SSL_ERROR_NO_RENEGOTIATION_ALERT = (SSL_ERROR_BASE + 102), + + SSL_ERROR_SERVER_CACHE_NOT_CONFIGURED = (SSL_ERROR_BASE + 103), + + SSL_ERROR_UNSUPPORTED_EXTENSION_ALERT = (SSL_ERROR_BASE + 104), + SSL_ERROR_CERTIFICATE_UNOBTAINABLE_ALERT = (SSL_ERROR_BASE + 105), + SSL_ERROR_UNRECOGNIZED_NAME_ALERT = (SSL_ERROR_BASE + 106), + SSL_ERROR_BAD_CERT_STATUS_RESPONSE_ALERT = (SSL_ERROR_BASE + 107), + SSL_ERROR_BAD_CERT_HASH_VALUE_ALERT = (SSL_ERROR_BASE + 108), + + SSL_ERROR_RX_UNEXPECTED_NEW_SESSION_TICKET = (SSL_ERROR_BASE + 109), + SSL_ERROR_RX_MALFORMED_NEW_SESSION_TICKET = (SSL_ERROR_BASE + 110), + + SSL_ERROR_DECOMPRESSION_FAILURE = (SSL_ERROR_BASE + 111), + SSL_ERROR_RENEGOTIATION_NOT_ALLOWED = (SSL_ERROR_BASE + 112), + SSL_ERROR_UNSAFE_NEGOTIATION = (SSL_ERROR_BASE + 113), + + SSL_ERROR_RX_UNEXPECTED_UNCOMPRESSED_RECORD = (SSL_ERROR_BASE + 114), + + SSL_ERROR_WEAK_SERVER_EPHEMERAL_DH_KEY = (SSL_ERROR_BASE + 115), + + SSL_ERROR_NEXT_PROTOCOL_DATA_INVALID = (SSL_ERROR_BASE + 116), + + SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SSL2 = (SSL_ERROR_BASE + 117), + /* error 117 is obsolete */ + SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SERVERS = (SSL_ERROR_BASE + 118), + SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_CLIENTS = (SSL_ERROR_BASE + 119), + + SSL_ERROR_INVALID_VERSION_RANGE = (SSL_ERROR_BASE + 120), + SSL_ERROR_CIPHER_DISALLOWED_FOR_VERSION = (SSL_ERROR_BASE + 121), + + SSL_ERROR_RX_MALFORMED_HELLO_VERIFY_REQUEST = (SSL_ERROR_BASE + 122), + SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST = (SSL_ERROR_BASE + 123), + + SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_VERSION = (SSL_ERROR_BASE + 124), + + SSL_ERROR_RX_UNEXPECTED_CERT_STATUS = (SSL_ERROR_BASE + 125), + + SSL_ERROR_UNSUPPORTED_HASH_ALGORITHM = (SSL_ERROR_BASE + 126), + SSL_ERROR_DIGEST_FAILURE = (SSL_ERROR_BASE + 127), + SSL_ERROR_INCORRECT_SIGNATURE_ALGORITHM = (SSL_ERROR_BASE + 128), + + SSL_ERROR_NEXT_PROTOCOL_NO_CALLBACK = (SSL_ERROR_BASE + 129), + SSL_ERROR_NEXT_PROTOCOL_NO_PROTOCOL = (SSL_ERROR_BASE + 130), + + SSL_ERROR_INAPPROPRIATE_FALLBACK_ALERT = (SSL_ERROR_BASE + 131), + + SSL_ERROR_WEAK_SERVER_CERT_KEY = (SSL_ERROR_BASE + 132), + + SSL_ERROR_RX_SHORT_DTLS_READ = (SSL_ERROR_BASE + 133), + + SSL_ERROR_NO_SUPPORTED_SIGNATURE_ALGORITHM = (SSL_ERROR_BASE + 134), + SSL_ERROR_UNSUPPORTED_SIGNATURE_ALGORITHM = (SSL_ERROR_BASE + 135), + + SSL_ERROR_MISSING_EXTENDED_MASTER_SECRET = (SSL_ERROR_BASE + 136), + SSL_ERROR_UNEXPECTED_EXTENDED_MASTER_SECRET = (SSL_ERROR_BASE + 137), + + SSL_ERROR_RX_MALFORMED_KEY_SHARE = (SSL_ERROR_BASE + 138), + SSL_ERROR_MISSING_KEY_SHARE = (SSL_ERROR_BASE + 139), + SSL_ERROR_RX_MALFORMED_ECDHE_KEY_SHARE = (SSL_ERROR_BASE + 140), + SSL_ERROR_RX_MALFORMED_DHE_KEY_SHARE = (SSL_ERROR_BASE + 141), + + SSL_ERROR_RX_UNEXPECTED_ENCRYPTED_EXTENSIONS = (SSL_ERROR_BASE + 142), + SSL_ERROR_MISSING_EXTENSION_ALERT = (SSL_ERROR_BASE + 143), + + SSL_ERROR_KEY_EXCHANGE_FAILURE = (SSL_ERROR_BASE + 144), + SSL_ERROR_EXTENSION_DISALLOWED_FOR_VERSION = (SSL_ERROR_BASE + 145), + SSL_ERROR_RX_MALFORMED_ENCRYPTED_EXTENSIONS = (SSL_ERROR_BASE + 146), + SSL_ERROR_MALFORMED_PRE_SHARED_KEY = (SSL_ERROR_BASE + 147), + SSL_ERROR_MALFORMED_EARLY_DATA = (SSL_ERROR_BASE + 148), + SSL_ERROR_END_OF_EARLY_DATA_ALERT = (SSL_ERROR_BASE + 149), + /* error 149 is obsolete */ + SSL_ERROR_MISSING_ALPN_EXTENSION = (SSL_ERROR_BASE + 150), + SSL_ERROR_RX_UNEXPECTED_EXTENSION = (SSL_ERROR_BASE + 151), + SSL_ERROR_MISSING_SUPPORTED_GROUPS_EXTENSION = (SSL_ERROR_BASE + 152), + SSL_ERROR_TOO_MANY_RECORDS = (SSL_ERROR_BASE + 153), + SSL_ERROR_RX_UNEXPECTED_HELLO_RETRY_REQUEST = (SSL_ERROR_BASE + 154), + SSL_ERROR_RX_MALFORMED_HELLO_RETRY_REQUEST = (SSL_ERROR_BASE + 155), + SSL_ERROR_BAD_2ND_CLIENT_HELLO = (SSL_ERROR_BASE + 156), + SSL_ERROR_MISSING_SIGNATURE_ALGORITHMS_EXTENSION = (SSL_ERROR_BASE + 157), + SSL_ERROR_MALFORMED_PSK_KEY_EXCHANGE_MODES = (SSL_ERROR_BASE + 158), + SSL_ERROR_MISSING_PSK_KEY_EXCHANGE_MODES = (SSL_ERROR_BASE + 159), + SSL_ERROR_DOWNGRADE_WITH_EARLY_DATA = (SSL_ERROR_BASE + 160), + SSL_ERROR_TOO_MUCH_EARLY_DATA = (SSL_ERROR_BASE + 161), + SSL_ERROR_RX_UNEXPECTED_END_OF_EARLY_DATA = (SSL_ERROR_BASE + 162), + SSL_ERROR_RX_MALFORMED_END_OF_EARLY_DATA = (SSL_ERROR_BASE + 163), + + SSL_ERROR_UNSUPPORTED_EXPERIMENTAL_API = (SSL_ERROR_BASE + 164), + + SSL_ERROR_APPLICATION_ABORT = (SSL_ERROR_BASE + 165), + SSL_ERROR_APP_CALLBACK_ERROR = (SSL_ERROR_BASE + 166), + SSL_ERROR_NO_TIMERS_FOUND = (SSL_ERROR_BASE + 167), + SSL_ERROR_MISSING_COOKIE_EXTENSION = (SSL_ERROR_BASE + 168), + + SSL_ERROR_RX_UNEXPECTED_KEY_UPDATE = (SSL_ERROR_BASE + 169), + SSL_ERROR_RX_MALFORMED_KEY_UPDATE = (SSL_ERROR_BASE + 170), + SSL_ERROR_TOO_MANY_KEY_UPDATES = (SSL_ERROR_BASE + 171), + SSL_ERROR_HANDSHAKE_FAILED = (SSL_ERROR_BASE + 172), + SSL_ERROR_BAD_RESUMPTION_TOKEN_ERROR = (SSL_ERROR_BASE + 173), + SSL_ERROR_RX_MALFORMED_DTLS_ACK = (SSL_ERROR_BASE + 174), + SSL_ERROR_DH_KEY_TOO_LONG = (SSL_ERROR_BASE + 175), + SSL_ERROR_RX_MALFORMED_ESNI_KEYS = (SSL_ERROR_BASE + 176), + SSL_ERROR_RX_MALFORMED_ESNI_EXTENSION = (SSL_ERROR_BASE + 177), + SSL_ERROR_MISSING_ESNI_EXTENSION = (SSL_ERROR_BASE + 178), + SSL_ERROR_RX_UNEXPECTED_RECORD_TYPE = (SSL_ERROR_BASE + 179), + SSL_ERROR_MISSING_POST_HANDSHAKE_AUTH_EXTENSION = (SSL_ERROR_BASE + 180), + SSL_ERROR_RX_CERTIFICATE_REQUIRED_ALERT = (SSL_ERROR_BASE + 181), + SSL_ERROR_DC_CERT_VERIFY_ALG_MISMATCH = (SSL_ERROR_BASE + 182), + SSL_ERROR_DC_BAD_SIGNATURE = (SSL_ERROR_BASE + 183), + SSL_ERROR_DC_INVALID_KEY_USAGE = (SSL_ERROR_BASE + 184), + SSL_ERROR_DC_EXPIRED = (SSL_ERROR_BASE + 185), + SSL_ERROR_DC_INAPPROPRIATE_VALIDITY_PERIOD = (SSL_ERROR_BASE + 186), + SSL_ERROR_FEATURE_DISABLED = (SSL_ERROR_BASE + 187), + /* ECH rejected, public name authentication succeeded, + * and at least one of the retry_configs is compatible. */ + SSL_ERROR_ECH_RETRY_WITH_ECH = (SSL_ERROR_BASE + 188), + /* ECH rejected, public name authentication succeeded, + * but none of the retry_configs are compatible. */ + SSL_ERROR_ECH_RETRY_WITHOUT_ECH = (SSL_ERROR_BASE + 189), + /* ECH rejected and public name authentication failed. */ + SSL_ERROR_ECH_FAILED = (SSL_ERROR_BASE + 190), + SSL_ERROR_ECH_REQUIRED_ALERT = (SSL_ERROR_BASE + 191), + + SSL_ERROR_RX_MALFORMED_HYBRID_KEY_SHARE = (SSL_ERROR_BASE + 192), + SSL_ERROR_END_OF_LIST /* let the c compiler determine the value of this. */ +} SSLErrorCodes; + +#define SSL_ERROR_RX_MALFORMED_ECH_CONFIG SSL_ERROR_RX_MALFORMED_ESNI_KEYS +#define SSL_ERROR_RX_MALFORMED_ECH_EXTENSION SSL_ERROR_RX_MALFORMED_ESNI_EXTENSION +#define SSL_ERROR_MISSING_ECH_EXTENSION SSL_ERROR_MISSING_ESNI_EXTENSION +#endif /* NO_SECURITY_ERROR_ENUM */ + +/* clang-format on */ + +#endif /* __SSL_ERR_H_ */ diff --git a/illumos-x86_64/usr/include/mps/sslexp.h b/illumos-x86_64/usr/include/mps/sslexp.h new file mode 100644 index 00000000..b205bc64 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/sslexp.h @@ -0,0 +1,1112 @@ +/* + * This file contains prototypes for experimental SSL functions. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __sslexp_h_ +#define __sslexp_h_ + +#include "ssl.h" +#include "sslerr.h" +#include "pk11hpke.h" + +SEC_BEGIN_PROTOS + +/* The functions in this header file are not guaranteed to remain available in + * future NSS versions. Code that uses these functions needs to safeguard + * against the function not being available. */ + +#define SSL_EXPERIMENTAL_API(name, arglist, args) \ + (SSL_GetExperimentalAPI(name) \ + ? ((SECStatus(*) arglist)SSL_GetExperimentalAPI(name))args \ + : SECFailure) +#define SSL_DEPRECATED_EXPERIMENTAL_API \ + (PR_SetError(SSL_ERROR_UNSUPPORTED_EXPERIMENTAL_API, 0), SECFailure) + +/* + * SSL_GetExtensionSupport() returns whether NSS supports a particular TLS + * extension. + * + * - ssl_ext_none indicates that NSS does not support the extension and + * extension hooks can be installed. + * + * - ssl_ext_native indicates that NSS supports the extension natively, but + * allows an application to override that support and install its own + * extension hooks. + * + * - ssl_ext_native_only indicates that NSS supports the extension natively + * and does not permit custom extension hooks to be installed. These + * extensions are critical to the functioning of NSS. + */ +typedef enum { + ssl_ext_none, + ssl_ext_native, + ssl_ext_native_only +} SSLExtensionSupport; + +#define SSL_GetExtensionSupport(extension, support) \ + SSL_EXPERIMENTAL_API("SSL_GetExtensionSupport", \ + (PRUint16 _extension, \ + SSLExtensionSupport * _support), \ + (extension, support)) + +/* + * Custom extension hooks. + * + * The SSL_InstallExtensionHooks() registers two callback functions for use + * with the identified extension type. + * + * Installing extension hooks disables the checks in TLS 1.3 that ensure that + * extensions are only added to the correct messages. The application is + * responsible for ensuring that extensions are only sent with the right message + * or messages. + * + * Installing an extension handler does not disable checks for whether an + * extension can be used in a message that is a response to an extension in + * another message. Extensions in ServerHello, EncryptedExtensions and the + * server Certificate messages are rejected unless the client sends an extension + * in the ClientHello. Similarly, a client Certificate message cannot contain + * extensions that don't appear in a CertificateRequest (in TLS 1.3). + * + * Setting both |writer| and |handler| to NULL removes any existing hooks for + * that extension. + * + * == SSLExtensionWriter + * + * An SSLExtensionWriter function is responsible for constructing the contents + * of an extension. This function is called during the construction of all + * handshake messages where an extension might be included. + * + * - The |fd| argument is the socket file descriptor. + * + * - The |message| argument is the TLS handshake message type. The writer will + * be called for every handshake message that NSS sends. Most extensions + * should only be sent in a subset of messages. NSS doesn’t check that + * extension writers don’t violate protocol rules regarding which message an + * extension can be sent in. + * + * - The |data| argument is a pointer to a buffer that should be written to with + * any data for the extension. + * + * - The |len| argument is an outparam indicating how many bytes were written to + * |data|. The value referenced by |len| is initialized to zero, so an + * extension that is empty does not need to write to this value. + * + * - The |maxLen| indicates the maximum number of bytes that can be written to + * |data|. + * + * - The |arg| argument is the value of the writerArg that was passed during + * installation. + * + * An SSLExtensionWriter function returns PR_TRUE if an extension should be + * written, and PR_FALSE otherwise. + * + * If there is an error, return PR_FALSE; if the error is truly fatal, the + * application can mark the connection as failed. However, recursively calling + * functions that alter the file descriptor in the callback - such as PR_Close() + * - should be avoided. + * + * Note: The ClientHello message can be sent twice in TLS 1.3. An + * SSLExtensionWriter will be called twice with the same arguments in that case; + * NSS does not distinguish between a first and second ClientHello. It is up to + * the application to track this if it needs to act differently each time. In + * most cases the correct behaviour is to provide an identical extension on each + * invocation. + * + * == SSLExtensionHandler + * + * An SSLExtensionHandler function consumes a handshake message. This function + * is called when an extension is present. + * + * - The |fd| argument is the socket file descriptor. + * + * - The |message| argument is the TLS handshake message type. This can be used + * to validate that the extension was included in the correct handshake + * message. + * + * - The |data| argument points to the contents of the extension. + * + * - The |len| argument contains the length of the extension. + * + * - The |alert| argument is an outparam that allows an application to choose + * which alert is sent in the case of a fatal error. + * + * - The |arg| argument is the value of the handlerArg that was passed during + * installation. + * + * An SSLExtensionHandler function returns SECSuccess when the extension is + * process successfully. It can return SECFailure to cause the handshake to + * fail. If the value of alert is written to, NSS will generate a fatal alert + * using the provided alert code. The value of |alert| is otherwise not used. + */ +typedef PRBool(PR_CALLBACK *SSLExtensionWriter)( + PRFileDesc *fd, SSLHandshakeType message, + PRUint8 *data, unsigned int *len, unsigned int maxLen, void *arg); + +typedef SECStatus(PR_CALLBACK *SSLExtensionHandler)( + PRFileDesc *fd, SSLHandshakeType message, + const PRUint8 *data, unsigned int len, + SSLAlertDescription *alert, void *arg); + +#define SSL_InstallExtensionHooks(fd, extension, writer, writerArg, \ + handler, handlerArg) \ + SSL_EXPERIMENTAL_API("SSL_InstallExtensionHooks", \ + (PRFileDesc * _fd, PRUint16 _extension, \ + SSLExtensionWriter _writer, void *_writerArg, \ + SSLExtensionHandler _handler, void *_handlerArg), \ + (fd, extension, writer, writerArg, \ + handler, handlerArg)) + +/* + * Create an anti-replay context for supporting 0-RTT in TLS 1.3 on servers. + * + * To use 0-RTT on a server, you must create an anti-replay context using + * SSL_CreateAntiReplayContext and set that on the socket with + * SSL_SetAntiReplayContext. Failing to set a context on the server will result + * in all 0-RTT being rejected. Connections will complete, but early data will + * be rejected. + * + * Anti-replay contexts are reference counted and are released with + * SSL_ReleaseAntiReplayContext. + * + * NSS uses a Bloom filter to track the ClientHello messages that it receives + * (specifically, it uses the PSK binder). This function initializes a pair of + * Bloom filters. The two filters are alternated over time, with new + * ClientHello messages recorded in the current filter and, if they are not + * already present, being checked against the previous filter. If the + * ClientHello is found, then early data is rejected, but the handshake is + * allowed to proceed. + * + * The false-positive probability of Bloom filters means that some valid + * handshakes will be marked as potential replays. Early data will be rejected + * for a false positive. To minimize this and to allow a trade-off of space + * against accuracy, the size of the Bloom filter can be set by this function. + * + * The first tuning parameter to consider is |window|, which determines the + * window over which ClientHello messages will be tracked. This also causes + * early data to be rejected if a ClientHello contains a ticket age parameter + * that is outside of this window (see Section 8.3 of RFC 8446 for details). + * Set |window| to account for any potential sources of clock error. |window| + * is the entire width of the window, which is symmetrical. Therefore to allow + * 5 seconds of clock error in both directions, set the value to 10 seconds + * (i.e., 10 * PR_USEC_PER_SEC). + * + * After calling this function, early data will be rejected until |window| + * elapses. This prevents replay across crashes and restarts. Only call this + * function once to avoid inadvertently disabling 0-RTT (use PR_CallOnce() to + * avoid this problem). + * + * The primary tuning parameter is |bits| which determines the amount of memory + * allocated to each Bloom filter. NSS will allocate two Bloom filters, each + * |2^(bits - 3)| octets in size. The value of |bits| is primarily driven by + * the number of connections that are expected in any time window. Note that + * this needs to account for there being two filters both of which have + * (presumably) independent false positive rates. The following formulae can be + * used to find a value of |bits| and |k| given a chosen false positive + * probability |p| and the number of requests expected in a given window |n|: + * + * bits = log2(n) + log2(-ln(1 - sqrt(1 - p))) + 1.0575327458897952 + * k = -log2(p) + * + * ... where log2 and ln are base 2 and e logarithms respectively. For a target + * false positive rate of 1% and 1000 handshake attempts, this produces bits=14 + * and k=7. This results in two Bloom filters that are 2kB each in size. Note + * that rounding |k| and |bits| up causes the false positive probability for + * these values to be a much lower 0.123%. + * + * IMPORTANT: This anti-replay scheme has several weaknesses. See the TLS 1.3 + * specification for the details of the generic problems with this technique. + * + * In addition to the generic anti-replay weaknesses, the state that the server + * maintains is in local memory only. Servers that operate in a cluster, even + * those that use shared memory for tickets, will not share anti-replay state. + * Early data can be replayed at least once with every server instance that will + * accept tickets that are encrypted with the same key. + */ +typedef struct SSLAntiReplayContextStr SSLAntiReplayContext; +#define SSL_CreateAntiReplayContext(now, window, k, bits, ctx) \ + SSL_EXPERIMENTAL_API("SSL_CreateAntiReplayContext", \ + (PRTime _now, PRTime _window, \ + unsigned int _k, unsigned int _bits, \ + SSLAntiReplayContext **_ctx), \ + (now, window, k, bits, ctx)) + +#define SSL_SetAntiReplayContext(fd, ctx) \ + SSL_EXPERIMENTAL_API("SSL_SetAntiReplayContext", \ + (PRFileDesc * _fd, SSLAntiReplayContext * _ctx), \ + (fd, ctx)) + +#define SSL_ReleaseAntiReplayContext(ctx) \ + SSL_EXPERIMENTAL_API("SSL_ReleaseAntiReplayContext", \ + (SSLAntiReplayContext * _ctx), \ + (ctx)) + +/* + * This function allows a server application to generate a session ticket that + * will embed the provided token. + * + * This function will cause a NewSessionTicket message to be sent by a server. + * This happens even if SSL_ENABLE_SESSION_TICKETS is disabled. This allows a + * server to suppress the usually automatic generation of a session ticket at + * the completion of the handshake - which do not include any token - and to + * control when session tickets are transmitted. + * + * This function will fail unless the socket has an active TLS 1.3 session. + * Earlier versions of TLS do not support the spontaneous sending of the + * NewSessionTicket message. It will also fail when external PSK + * authentication has been negotiated. + */ +#define SSL_SendSessionTicket(fd, appToken, appTokenLen) \ + SSL_EXPERIMENTAL_API("SSL_SendSessionTicket", \ + (PRFileDesc * _fd, const PRUint8 *_appToken, \ + unsigned int _appTokenLen), \ + (fd, appToken, appTokenLen)) + +/* + * A stateless retry handler gives an application some control over NSS handling + * of ClientHello messages. + * + * SSL_HelloRetryRequestCallback() installs a callback that allows an + * application to control how NSS sends HelloRetryRequest messages. This + * handler is only used on servers and will only be called if the server selects + * TLS 1.3. Support for older TLS versions could be added in other releases. + * + * The SSLHelloRetryRequestCallback is invoked during the processing of a + * TLS 1.3 ClientHello message. It takes the following arguments: + * + * - |firstHello| indicates if the NSS believes that this is an initial + * ClientHello. An initial ClientHello will never include a cookie extension, + * though it may contain a session ticket. + * + * - |clientToken| includes a token previously provided by the application. If + * |clientTokenLen| is 0, then |clientToken| may be NULL. + * + * - If |firstHello| is PR_FALSE, the value that was provided in the + * |retryToken| outparam of previous invocations of this callback will be + * present here. + * + * - If |firstHello| is PR_TRUE, and the handshake is resuming a session, then + * this will contain any value that was passed in the |token| parameter of + * SSL_SendNewSessionTicket() method (see below). If this is not resuming a + * session, then the token will be empty (and this value could be NULL). + * + * - |clientTokenLen| is the length of |clientToken|. + * + * - |retryToken| is an item that callback can write to. This provides NSS with + * a token. This token is encrypted and integrity protected and embedded in + * the cookie extension of a HelloRetryRequest. The value of this field is + * only used if the handler returns ssl_stateless_retry_check. NSS allocates + * space for this value. + * + * - |retryTokenLen| is an outparam for the length of the token. If this value + * is not set, or set to 0, an empty token will be sent. + * + * - |retryTokenMax| is the size of the space allocated for retryToken. An + * application cannot write more than this many bytes to retryToken. + * + * - |arg| is the same value that was passed to + * SSL_InstallStatelessRetryHandler(). + * + * The handler can validate any the value of |clientToken|, query the socket + * status (using SSL_GetPreliminaryChannelInfo() for example) and decide how to + * proceed: + * + * - Returning ssl_hello_retry_fail causes the handshake to fail. This might be + * used if the token is invalid or the application wishes to abort the + * handshake. + * + * - Returning ssl_hello_retry_accept causes the handshake to proceed. + * + * - Returning ssl_hello_retry_request causes NSS to send a HelloRetryRequest + * message and request a second ClientHello. NSS generates a cookie extension + * and embeds the value of |retryToken|. The value of |retryToken| value may + * be left empty if the application does not require any additional context to + * validate a second ClientHello attempt. This return code cannot be used to + * reject a second ClientHello (i.e., when firstHello is PR_FALSE); NSS will + * abort the handshake if this value is returned from a second call. + * + * - Returning ssl_hello_retry_reject_0rtt causes NSS to proceed normally, but + * to reject 0-RTT. Use this if there is something in the token that + * indicates that 0-RTT might be unsafe. + * + * An application that chooses to perform a stateless retry can discard the + * server socket. All necessary state to continue the TLS handshake will be + * included in the cookie extension. This makes it possible to use a new socket + * to handle the remainder of the handshake. The existing socket can be safely + * discarded. + * + * If the same socket is retained, the information in the cookie will be checked + * for consistency against the existing state of the socket. Any discrepancy + * will result in the connection being closed. + * + * Tokens should be kept as small as possible. NSS sets a limit on the size of + * tokens, which it passes in |retryTokenMax|. Depending on circumstances, + * observing a smaller limit might be desirable or even necessary. For + * instance, having HelloRetryRequest and ClientHello fit in a single packet has + * significant performance benefits. + */ +typedef enum { + ssl_hello_retry_fail, + ssl_hello_retry_accept, + ssl_hello_retry_request, + ssl_hello_retry_reject_0rtt +} SSLHelloRetryRequestAction; + +typedef SSLHelloRetryRequestAction(PR_CALLBACK *SSLHelloRetryRequestCallback)( + PRBool firstHello, const PRUint8 *clientToken, unsigned int clientTokenLen, + PRUint8 *retryToken, unsigned int *retryTokenLen, unsigned int retryTokMax, + void *arg); + +#define SSL_HelloRetryRequestCallback(fd, cb, arg) \ + SSL_EXPERIMENTAL_API("SSL_HelloRetryRequestCallback", \ + (PRFileDesc * _fd, \ + SSLHelloRetryRequestCallback _cb, void *_arg), \ + (fd, cb, arg)) + +/* Update traffic keys (TLS 1.3 only). + * + * The |requestUpdate| flag determines whether to request an update from the + * remote peer. + */ +#define SSL_KeyUpdate(fd, requestUpdate) \ + SSL_EXPERIMENTAL_API("SSL_KeyUpdate", \ + (PRFileDesc * _fd, PRBool _requestUpdate), \ + (fd, requestUpdate)) + +/* This function allows a server application to trigger + * re-authentication (TLS 1.3 only) after handshake. + * + * This function will cause a CertificateRequest message to be sent by + * a server. This can be called once at a time, and is not allowed + * until an answer is received. + * + * This function is not allowed for use with DTLS or when external + * PSK authentication has been negotiated. SECFailure is returned + * in both cases. + * + * The AuthCertificateCallback is called when the answer is received. + * If the answer is accepted by the server, the value returned by + * SSL_PeerCertificate() is replaced. If you need to remember all the + * certificates, you will need to call SSL_PeerCertificate() and save + * what you get before calling this. + * + * If the AuthCertificateCallback returns SECFailure, the connection + * is aborted. + */ +#define SSL_SendCertificateRequest(fd) \ + SSL_EXPERIMENTAL_API("SSL_SendCertificateRequest", \ + (PRFileDesc * _fd), \ + (fd)) + +/* + * Session cache API. + */ + +/* + * Information that can be retrieved about a resumption token. + * See SSL_GetResumptionTokenInfo for details about how to use this API. + * Note that peerCert points to a certificate in the NSS database and must be + * copied by the application if it should be used after NSS shutdown or after + * calling SSL_DestroyResumptionTokenInfo. + */ +typedef struct SSLResumptionTokenInfoStr { + PRUint16 length; + CERTCertificate *peerCert; + PRUint8 *alpnSelection; + PRUint32 alpnSelectionLen; + PRUint32 maxEarlyDataSize; + PRTime expirationTime; /* added in NSS 3.41 */ +} SSLResumptionTokenInfo; + +/* + * Allows applications to retrieve information about a resumption token. + * This does not require a TLS session. + * + * - The |tokenData| argument is a pointer to the resumption token as byte array + * of length |tokenLen|. + * - The |token| argument is a pointer to a SSLResumptionTokenInfo struct of + * of |len|. The struct gets filled by this function. + * See SSL_DestroyResumptionTokenInfo for information about how to manage the + * |token| memory. + */ +#define SSL_GetResumptionTokenInfo(tokenData, tokenLen, token, len) \ + SSL_EXPERIMENTAL_API("SSL_GetResumptionTokenInfo", \ + (const PRUint8 *_tokenData, unsigned int _tokenLen, \ + SSLResumptionTokenInfo *_token, PRUintn _len), \ + (tokenData, tokenLen, token, len)) + +/* + * SSL_GetResumptionTokenInfo allocates memory in order to populate |tokenInfo|. + * Any SSLResumptionTokenInfo struct filled with SSL_GetResumptionTokenInfo + * has to be freed with SSL_DestroyResumptionTokenInfo. + */ +#define SSL_DestroyResumptionTokenInfo(tokenInfo) \ + SSL_EXPERIMENTAL_API( \ + "SSL_DestroyResumptionTokenInfo", \ + (SSLResumptionTokenInfo * _tokenInfo), \ + (tokenInfo)) + +/* + * This is the function signature for function pointers used as resumption + * token callback. The caller has to copy the memory at |resumptionToken| with + * length |len| before returning. + * + * - The |fd| argument is the socket file descriptor. + * - The |resumptionToken| is a pointer to the resumption token as byte array + * of length |len|. + * - The |ctx| is a void pointer to the context set by the application in + * SSL_SetResumptionTokenCallback. + */ +typedef SECStatus(PR_CALLBACK *SSLResumptionTokenCallback)( + PRFileDesc *fd, const PRUint8 *resumptionToken, unsigned int len, + void *ctx); + +/* + * This allows setting a callback for external session caches to store + * resumption tokens. + * + * - The |fd| argument is the socket file descriptor. + * - The |cb| is a function pointer to an implementation of + * SSLResumptionTokenCallback. + * - The |ctx| is a pointer to some application specific context, which is + * returned when |cb| is called. + */ +#define SSL_SetResumptionTokenCallback(fd, cb, ctx) \ + SSL_EXPERIMENTAL_API( \ + "SSL_SetResumptionTokenCallback", \ + (PRFileDesc * _fd, SSLResumptionTokenCallback _cb, void *_ctx), \ + (fd, cb, ctx)) + +/* + * This allows setting a resumption token for a session. + * The function returns SECSuccess iff the resumption token can be used, + * SECFailure in any other case. The caller should remove the |token| from its + * cache when the function returns SECFailure. + * + * - The |fd| argument is the socket file descriptor. + * - The |token| is a pointer to the resumption token as byte array + * of length |len|. + */ +#define SSL_SetResumptionToken(fd, token, len) \ + SSL_EXPERIMENTAL_API( \ + "SSL_SetResumptionToken", \ + (PRFileDesc * _fd, const PRUint8 *_token, const unsigned int _len), \ + (fd, token, len)) + +/* TLS 1.3 allows a server to set a limit on the number of bytes of early data + * that can be received. This allows that limit to be set. This function has no + * effect on a client. */ +#define SSL_SetMaxEarlyDataSize(fd, size) \ + SSL_EXPERIMENTAL_API("SSL_SetMaxEarlyDataSize", \ + (PRFileDesc * _fd, PRUint32 _size), \ + (fd, size)) + +/* Client: + * If |enabled|, a GREASE ECH extension will be sent in every ClientHello, + * unless a valid and supported ECHConfig is configured to the socket + * (in which case real ECH takes precedence). If |!enabled|, it is not sent. + * + * Server: + * If |enabled|, a GREASE ECH extensions will be sent in every HelloRetryRequest, + * provided that the corresponding ClientHello contained an ECH extension. If ECH + * is enabled, the real ECH HRR extension takes precedence. + */ +#define SSL_EnableTls13GreaseEch(fd, enabled) \ + SSL_EXPERIMENTAL_API("SSL_EnableTls13GreaseEch", \ + (PRFileDesc * _fd, PRBool _enabled), (fd, enabled)) + +/* + * Client: + * When sending a GREASE ECH extension in a ClientHello, pad it as though the + * hypothetical ECHConfig had |maximum_name_length| equal to |size|. |size| may + * vary between 1 and 255 and defaults to 100. + * + * Server: + * Has no effect. + */ +#define SSL_SetTls13GreaseEchSize(fd, size) \ + SSL_EXPERIMENTAL_API("SSL_SetTls13GreaseEchSize", \ + (PRFileDesc * _fd, PRUint8 _size), (fd, size)) + +/* If |enabled|, a server receiving a Client Hello containing an encrypted_client_hello + * of type inner will respond with the ECH + * acceptance signal. This signals the client to continue with the inner + * transcript rather than outer. */ +#define SSL_EnableTls13BackendEch(fd, enabled) \ + SSL_EXPERIMENTAL_API("SSL_EnableTls13BackendEch", \ + (PRFileDesc * _fd, PRBool _enabled), (fd, enabled)) + +/* This allows an extension writer to supply different values for inner and + * outer ClientHello when using encrypted ClientHello. + * + * When enabled, each extension writer can be called more than once for the same + * message; it must provide the same response when called for the same message + * type. When calling the writer to construct the outer ClientHello, the + * function will be called with ssl_hs_ech_outer_client_hello as the message + * type (a value from outside the range of valid TLS handshake messages). + * + * When disabled, the extension writer is called once for the outer ClientHello + * and the value is copied to the inner ClientHello. + * + * Enabling this affects all extension writers. The order in which extension + * writers are added is also important. Any extension writer that writes + * different values for inner and outer ClientHello will prevent later + * extensions from being compressed. + */ +#define SSL_CallExtensionWriterOnEchInner(fd, enabled) \ + SSL_EXPERIMENTAL_API("SSL_CallExtensionWriterOnEchInner", \ + (PRFileDesc * _fd, PRBool _enabled), (fd, enabled)) + +/* Called by the client after an initial ECH connection fails with + * SSL_ERROR_ECH_RETRY_WITH_ECH. Returns compatible ECHConfigs, which + * are configured via SetClientEchConfigs for an ECH retry attempt. + * These configs MUST NOT be used for more than the single retry + * attempt. Subsequent connections MUST use advertised ECHConfigs. */ +#define SSL_GetEchRetryConfigs(fd, out) \ + SSL_EXPERIMENTAL_API("SSL_GetEchRetryConfigs", \ + (PRFileDesc * _fd, \ + SECItem * _out), \ + (fd, out)) + +/* Called to remove all ECHConfigs from a socket (fd). */ +#define SSL_RemoveEchConfigs(fd) \ + SSL_EXPERIMENTAL_API("SSL_RemoveEchConfigs", \ + (PRFileDesc * _fd), \ + (fd)) + +/* Set the ECHConfig and key pair on a socket (server side) + * + * fd -- the socket + * pubKey -- the server's SECKEYPublicKey for HPKE/ECH. + * privateKey -- the server's SECKEYPrivateKey for HPKE/ECH. + * record/recordLen -- the encoded DNS record (not base64) + */ +#define SSL_SetServerEchConfigs(fd, pubKey, \ + privKey, record, recordLen) \ + SSL_EXPERIMENTAL_API("SSL_SetServerEchConfigs", \ + (PRFileDesc * _fd, \ + const SECKEYPublicKey *_pubKey, \ + const SECKEYPrivateKey *_privKey, \ + const PRUint8 *_record, unsigned int _recordLen), \ + (fd, pubKey, privKey, \ + record, recordLen)) + +/* Set ECHConfig(s) on a client. The first supported ECHConfig will be used. + * + * fd -- the socket + * echConfigs/echConfigsLen -- the ECHConfigs structure (not base64) + */ +#define SSL_SetClientEchConfigs(fd, echConfigs, echConfigsLen) \ + SSL_EXPERIMENTAL_API("SSL_SetClientEchConfigs", \ + (PRFileDesc * _fd, \ + const PRUint8 *_echConfigs, \ + unsigned int _echConfigsLen), \ + (fd, echConfigs, echConfigsLen)) + +/* + * Generate an encoded ECHConfig structure (presumably server side). + * + * configId -- an identifier for the configuration. + * publicName -- the public_name value to be placed in SNI. + * maxNameLen -- the maximum length of protected names + * kemId -- the HKPE KEM ID value + * pubKey -- the public key for the key pair + * hpkeSuites -- the HPKE cipher suites that can be used + * hpkeSuitesCount -- the number of suites in hpkeSuites + * out/outlen/maxlen -- where to output the data + */ +typedef struct HpkeSymmetricSuiteStr { + HpkeKdfId kdfId; + HpkeAeadId aeadId; +} HpkeSymmetricSuite; +#define SSL_EncodeEchConfigId(configId, publicName, maxNameLen, \ + kemId, pubKey, hpkeSuites, hpkeSuiteCount, \ + out, outlen, maxlen) \ + SSL_EXPERIMENTAL_API("SSL_EncodeEchConfigId", \ + (PRUint8 _configId, const char *_publicName, \ + unsigned int _maxNameLen, HpkeKemId _kemId, \ + const SECKEYPublicKey *_pubKey, \ + const HpkeSymmetricSuite *_hpkeSuites, \ + unsigned int _hpkeSuiteCount, \ + PRUint8 *_out, unsigned int *_outlen, \ + unsigned int _maxlen), \ + (configId, publicName, maxNameLen, \ + kemId, pubKey, hpkeSuites, hpkeSuiteCount, \ + out, outlen, maxlen)) + +/* SSL_SetSecretCallback installs a callback that TLS calls when it installs new + * traffic secrets. + * + * SSLSecretCallback is called with the current epoch and the corresponding + * secret; this matches the epoch used in DTLS 1.3, even if the socket is + * operating in stream mode: + * + * - client_early_traffic_secret corresponds to epoch 1 + * - {client|server}_handshake_traffic_secret is epoch 2 + * - {client|server}_application_traffic_secret_{N} is epoch 3+N + * + * The callback is invoked separately for read secrets (client secrets on the + * server; server secrets on the client), and write secrets. + * + * This callback is only called if (D)TLS 1.3 is negotiated. + */ +typedef void(PR_CALLBACK *SSLSecretCallback)( + PRFileDesc *fd, PRUint16 epoch, SSLSecretDirection dir, PK11SymKey *secret, + void *arg); + +#define SSL_SecretCallback(fd, cb, arg) \ + SSL_EXPERIMENTAL_API("SSL_SecretCallback", \ + (PRFileDesc * _fd, SSLSecretCallback _cb, void *_arg), \ + (fd, cb, arg)) + +/* SSL_RecordLayerWriteCallback() is used to replace the TLS record layer. This + * function installs a callback that TLS calls when it would otherwise encrypt + * and write a record to the underlying NSPR IO layer. The application is + * responsible for ensuring that these records are encrypted and written. + * + * Calling this API also disables reads from the underlying NSPR layer. The + * application is expected to push data when it is available using + * SSL_RecordLayerData(). + * + * When data would be written, the provided SSLRecordWriteCallback with the + * epoch, TLS content type, and the data. The data provided to the callback is + * not split into record-sized writes. If the callback returns SECFailure, the + * write will be considered to have failed; in particular, PR_WOULD_BLOCK_ERROR + * is not handled specially. + * + * If TLS 1.3 is in use, the epoch indicates the expected level of protection + * that the record would receive, this matches that used in DTLS 1.3: + * + * - epoch 0 corresponds to no record protection + * - epoch 1 corresponds to 0-RTT + * - epoch 2 corresponds to TLS handshake + * - epoch 3 and higher are application data + * + * Prior versions of TLS use epoch 1 and higher for application data. + * + * This API is not supported for DTLS. + */ +typedef SECStatus(PR_CALLBACK *SSLRecordWriteCallback)( + PRFileDesc *fd, PRUint16 epoch, SSLContentType contentType, + const PRUint8 *data, unsigned int len, void *arg); + +#define SSL_RecordLayerWriteCallback(fd, writeCb, arg) \ + SSL_EXPERIMENTAL_API("SSL_RecordLayerWriteCallback", \ + (PRFileDesc * _fd, SSLRecordWriteCallback _wCb, \ + void *_arg), \ + (fd, writeCb, arg)) + +/* SSL_RecordLayerData() is used to provide new data to TLS. The application + * indicates the epoch (see the description of SSL_RecordLayerWriteCallback()), + * content type, and the data that was received. The application is responsible + * for removing any encryption or other protection before passing data to this + * function. + * + * This returns SECSuccess if the data was successfully processed. If this + * function is used to drive the handshake and the caller needs to know when the + * handshake is complete, a call to SSL_ForceHandshake will return SECSuccess + * when the handshake is complete. + * + * This API is not supported for DTLS sockets. + */ +#define SSL_RecordLayerData(fd, epoch, ct, data, len) \ + SSL_EXPERIMENTAL_API("SSL_RecordLayerData", \ + (PRFileDesc * _fd, PRUint16 _epoch, \ + SSLContentType _contentType, \ + const PRUint8 *_data, unsigned int _len), \ + (fd, epoch, ct, data, len)) + +/* + * SSL_GetCurrentEpoch() returns the read and write epochs that the socket is + * currently using. NULL values for readEpoch or writeEpoch are ignored. + * + * See SSL_RecordLayerWriteCallback() for details on epochs. + */ +#define SSL_GetCurrentEpoch(fd, readEpoch, writeEpoch) \ + SSL_EXPERIMENTAL_API("SSL_GetCurrentEpoch", \ + (PRFileDesc * _fd, PRUint16 * _readEpoch, \ + PRUint16 * _writeEpoch), \ + (fd, readEpoch, writeEpoch)) + +/* + * The following AEAD functions expose an AEAD primitive that uses a ciphersuite + * to set parameters. The ciphersuite determines the Hash function used by + * HKDF, the AEAD function, and the size of key and IV. This is only supported + * for TLS 1.3. + * + * The key and IV are generated using the TLS KDF with a custom label. That is + * HKDF-Expand-Label(secret, labelPrefix + " key" or " iv", "", L). + * + * The encrypt and decrypt functions use a nonce construction identical to that + * used in TLS. The lower bits of the IV are XORed with the 64-bit counter to + * produce the nonce. Otherwise, this is an AEAD interface similar to that + * described in RFC 5116. + * + * Note: SSL_MakeAead internally calls SSL_MakeVariantAead with a variant of + * "stream", behaving as noted above. If "datagram" variant is passed instead, + * the Label prefix used in HKDF-Expand is "dtls13" instead of "tls13 ". See + * 7.1 of RFC 8446 and draft-ietf-tls-dtls13-34. */ +typedef struct SSLAeadContextStr SSLAeadContext; + +#define SSL_MakeAead(version, cipherSuite, secret, \ + labelPrefix, labelPrefixLen, ctx) \ + SSL_EXPERIMENTAL_API("SSL_MakeAead", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + PK11SymKey * _secret, \ + const char *_labelPrefix, \ + unsigned int _labelPrefixLen, \ + SSLAeadContext **_ctx), \ + (version, cipherSuite, secret, \ + labelPrefix, labelPrefixLen, ctx)) + +#define SSL_MakeVariantAead(version, cipherSuite, variant, secret, \ + labelPrefix, labelPrefixLen, ctx) \ + SSL_EXPERIMENTAL_API("SSL_MakeVariantAead", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + SSLProtocolVariant _variant, \ + PK11SymKey * _secret, \ + const char *_labelPrefix, \ + unsigned int _labelPrefixLen, \ + SSLAeadContext **_ctx), \ + (version, cipherSuite, variant, secret, \ + labelPrefix, labelPrefixLen, ctx)) + +#define SSL_AeadEncrypt(ctx, counter, aad, aadLen, in, inLen, \ + output, outputLen, maxOutputLen) \ + SSL_EXPERIMENTAL_API("SSL_AeadEncrypt", \ + (const SSLAeadContext *_ctx, PRUint64 _counter, \ + const PRUint8 *_aad, unsigned int _aadLen, \ + const PRUint8 *_in, unsigned int _inLen, \ + PRUint8 *_out, unsigned int *_outLen, \ + unsigned int _maxOut), \ + (ctx, counter, aad, aadLen, in, inLen, \ + output, outputLen, maxOutputLen)) + +#define SSL_AeadDecrypt(ctx, counter, aad, aadLen, in, inLen, \ + output, outputLen, maxOutputLen) \ + SSL_EXPERIMENTAL_API("SSL_AeadDecrypt", \ + (const SSLAeadContext *_ctx, PRUint64 _counter, \ + const PRUint8 *_aad, unsigned int _aadLen, \ + const PRUint8 *_in, unsigned int _inLen, \ + PRUint8 *_output, unsigned int *_outLen, \ + unsigned int _maxOut), \ + (ctx, counter, aad, aadLen, in, inLen, \ + output, outputLen, maxOutputLen)) + +#define SSL_DestroyAead(ctx) \ + SSL_EXPERIMENTAL_API("SSL_DestroyAead", \ + (SSLAeadContext * _ctx), \ + (ctx)) + +/* SSL_HkdfExtract and SSL_HkdfExpandLabel implement the functions from TLS, + * using the version and ciphersuite to set parameters. This allows callers to + * use these TLS functions as a KDF. This is only supported for TLS 1.3. + * + * SSL_HkdfExtract produces a key with a mechanism that is suitable for input to + * SSL_HkdfExpandLabel (and SSL_HkdfExpandLabelWithMech). */ +#define SSL_HkdfExtract(version, cipherSuite, salt, ikm, keyp) \ + SSL_EXPERIMENTAL_API("SSL_HkdfExtract", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + PK11SymKey * _salt, PK11SymKey * _ikm, \ + PK11SymKey * *_keyp), \ + (version, cipherSuite, salt, ikm, keyp)) + +/* SSL_HkdfExpandLabel and SSL_HkdfVariantExpandLabel produce a key with a + * mechanism that is suitable for input to SSL_HkdfExpandLabel or SSL_MakeAead. + * + * Note: SSL_HkdfVariantExpandLabel internally calls SSL_HkdfExpandLabel with + * a default "stream" variant. If "datagram" variant is passed instead, the + * Label prefix used in HKDF-Expand is "dtls13" instead of "tls13 ". See 7.1 of + * RFC 8446 and draft-ietf-tls-dtls13-34. */ +#define SSL_HkdfExpandLabel(version, cipherSuite, prk, \ + hsHash, hsHashLen, label, labelLen, keyp) \ + SSL_EXPERIMENTAL_API("SSL_HkdfExpandLabel", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + PK11SymKey * _prk, \ + const PRUint8 *_hsHash, unsigned int _hsHashLen, \ + const char *_label, unsigned int _labelLen, \ + PK11SymKey **_keyp), \ + (version, cipherSuite, prk, \ + hsHash, hsHashLen, label, labelLen, keyp)) + +#define SSL_HkdfVariantExpandLabel(version, cipherSuite, prk, \ + hsHash, hsHashLen, label, labelLen, variant, \ + keyp) \ + SSL_EXPERIMENTAL_API("SSL_HkdfVariantExpandLabel", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + PK11SymKey * _prk, \ + const PRUint8 *_hsHash, unsigned int _hsHashLen, \ + const char *_label, unsigned int _labelLen, \ + SSLProtocolVariant _variant, \ + PK11SymKey **_keyp), \ + (version, cipherSuite, prk, \ + hsHash, hsHashLen, label, labelLen, variant, \ + keyp)) + +/* SSL_HkdfExpandLabelWithMech and SSL_HkdfVariantExpandLabelWithMech use the KDF + * from the selected TLS version and cipher suite, as with the other calls, but + * the provided mechanism and key size. This allows the key to be used more widely. + * + * Note: SSL_HkdfExpandLabelWithMech internally calls SSL_HkdfVariantExpandLabelWithMech + * with a default "stream" variant. If "datagram" variant is passed instead, the + * Label prefix used in HKDF-Expand is "dtls13" instead of "tls13 ". See 7.1 of + * RFC 8446 and draft-ietf-tls-dtls13-34. */ +#define SSL_HkdfExpandLabelWithMech(version, cipherSuite, prk, \ + hsHash, hsHashLen, label, labelLen, \ + mech, keySize, keyp) \ + SSL_EXPERIMENTAL_API("SSL_HkdfExpandLabelWithMech", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + PK11SymKey * _prk, \ + const PRUint8 *_hsHash, unsigned int _hsHashLen, \ + const char *_label, unsigned int _labelLen, \ + CK_MECHANISM_TYPE _mech, unsigned int _keySize, \ + PK11SymKey **_keyp), \ + (version, cipherSuite, prk, \ + hsHash, hsHashLen, label, labelLen, \ + mech, keySize, keyp)) + +#define SSL_HkdfVariantExpandLabelWithMech(version, cipherSuite, prk, \ + hsHash, hsHashLen, label, labelLen, \ + mech, keySize, variant, keyp) \ + SSL_EXPERIMENTAL_API("SSL_HkdfVariantExpandLabelWithMech", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + PK11SymKey * _prk, \ + const PRUint8 *_hsHash, unsigned int _hsHashLen, \ + const char *_label, unsigned int _labelLen, \ + CK_MECHANISM_TYPE _mech, unsigned int _keySize, \ + SSLProtocolVariant _variant, \ + PK11SymKey **_keyp), \ + (version, cipherSuite, prk, \ + hsHash, hsHashLen, label, labelLen, \ + mech, keySize, variant, keyp)) + +/* SSL_SetTimeFunc overrides the default time function (PR_Now()) and provides + * an alternative source of time for the socket. This is used in testing, and in + * applications that need better control over how the clock is accessed. Set the + * function to NULL to use PR_Now().*/ +typedef PRTime(PR_CALLBACK *SSLTimeFunc)(void *arg); + +#define SSL_SetTimeFunc(fd, f, arg) \ + SSL_EXPERIMENTAL_API("SSL_SetTimeFunc", \ + (PRFileDesc * _fd, SSLTimeFunc _f, void *_arg), \ + (fd, f, arg)) + +/* Create a delegated credential (DC) for the draft-ietf-tls-subcerts extension + * using the given certificate |cert| and its signing key |certPriv| and write + * the serialized DC to |out|. The + * parameters are: + * - the DC public key |dcPub|; + * - the DC signature scheme |dcCertVerifyAlg|, used to verify the handshake. + * - the DC time-to-live |dcValidFor|, the number of seconds from now for which + * the DC should be valid; and + * - the current time |now|. + * + * The signing algorithm used to verify the DC signature is deduced from + * |cert|. + * + * It's the caller's responsibility to ensure the input parameters are all + * valid. This procedure is meant primarily for testing; for this purpose it is + * useful to do no validation. + */ +#define SSL_DelegateCredential(cert, certPriv, dcPub, dcCertVerifyAlg, \ + dcValidFor, now, out) \ + SSL_EXPERIMENTAL_API("SSL_DelegateCredential", \ + (const CERTCertificate *_cert, \ + const SECKEYPrivateKey *_certPriv, \ + const SECKEYPublicKey *_dcPub, \ + SSLSignatureScheme _dcCertVerifyAlg, \ + PRUint32 _dcValidFor, \ + PRTime _now, \ + SECItem *_out), \ + (cert, certPriv, dcPub, dcCertVerifyAlg, dcValidFor, \ + now, out)) + +/* New functions created to permit get/set the CipherSuites Order for the + * handshake (Client Hello). + * + * The *Get function puts the current set of active (enabled and policy set as + * PR_TRUE) cipher suites in the cipherOrder outparam. Cipher suites that + * aren't active aren't included. The paramenters are: + * - PRFileDesc *fd = FileDescriptor to get information. + * - PRUint16 *cipherOrder = The memory allocated for cipherOrder needs to be + * SSL_GetNumImplementedCiphers() * sizeof(PRUint16) or more. + * - PRUint16 numCiphers = The number of active ciphersuites listed in + * *cipherOrder is written here. + * + * The *Set function permits reorder the CipherSuites list for the Handshake + * (Client Hello). The default ordering defined in ssl3con.c is enough in + * almost all cases. But, if the client needs some hardening or performance + * adjusts related to CipherSuites, this can be done with this function. + * The caller has to be aware about the risk of call this function while a + * handshake are being processed in this fd/socket. For example, if you disable + * a cipher after the handshake and this cipher was choosen for that + * connection, something bad will happen. + * The parameters are: + * - PRFileDesc *fd = FileDescriptor to change. + * - const PRUint16 *cipherOrder = Must receive all ciphers to be ordered, in + * the desired order. They will be set in the begin of the list. Only + * suites listed by SSL_ImplementedCiphers() can be included. + * - PRUint16 numCiphers = Must receive the number of items in *cipherOrder. + * */ +#define SSL_CipherSuiteOrderGet(fd, cipherOrder, numCiphers) \ + SSL_EXPERIMENTAL_API("SSL_CipherSuiteOrderGet", \ + (PRFileDesc * _fd, PRUint16 * _cipherOrder, \ + unsigned int *_numCiphers), \ + (fd, cipherOrder, numCiphers)) + +#define SSL_CipherSuiteOrderSet(fd, cipherOrder, numCiphers) \ + SSL_EXPERIMENTAL_API("SSL_CipherSuiteOrderSet", \ + (PRFileDesc * _fd, const PRUint16 *_cipherOrder, \ + PRUint16 _numCiphers), \ + (fd, cipherOrder, numCiphers)) + +/* + * The following functions expose a masking primitive that uses ciphersuite and + * version information to set paramaters for the masking key and mask generation + * logic. This is only supported for TLS 1.3. + * + * The key and IV are generated using the TLS KDF with a custom label. That is + * HKDF-Expand-Label(secret, label, "", L), where |label| is an input to + * SSL_CreateMaskingContext. + * + * The mask generation logic in SSL_CreateMask is determined by the underlying + * symmetric cipher: + * - For AES-ECB, mask = AES-ECB(mask_key, sample). |len| must be <= 16 as + * the output is limited to a single block. + * - For CHACHA20, mask = ChaCha20(mask_key, sample[0..3], sample[4..15], {0}.len) + * That is, the low 4 bytes of |sample| used as the counter, the remaining 12 bytes + * the nonce. We encrypt |len| bytes of zeros, returning the raw key stream. + * + * The caller must pre-allocate at least |len| bytes for output. If the underlying + * cipher cannot produce the requested amount of data, SECFailure is returned. + */ + +typedef struct SSLMaskingContextStr { + CK_MECHANISM_TYPE mech; + PRUint16 version; + PRUint16 cipherSuite; + PK11SymKey *secret; +} SSLMaskingContext; + +#define SSL_CreateMaskingContext(version, cipherSuite, secret, \ + label, labelLen, ctx) \ + SSL_EXPERIMENTAL_API("SSL_CreateMaskingContext", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + PK11SymKey * _secret, \ + const char *_label, \ + unsigned int _labelLen, \ + SSLMaskingContext **_ctx), \ + (version, cipherSuite, secret, label, labelLen, ctx)) + +#define SSL_CreateVariantMaskingContext(version, cipherSuite, variant, \ + secret, label, labelLen, ctx) \ + SSL_EXPERIMENTAL_API("SSL_CreateVariantMaskingContext", \ + (PRUint16 _version, PRUint16 _cipherSuite, \ + SSLProtocolVariant _variant, \ + PK11SymKey * _secret, \ + const char *_label, \ + unsigned int _labelLen, \ + SSLMaskingContext **_ctx), \ + (version, cipherSuite, variant, secret, \ + label, labelLen, ctx)) + +#define SSL_DestroyMaskingContext(ctx) \ + SSL_EXPERIMENTAL_API("SSL_DestroyMaskingContext", \ + (SSLMaskingContext * _ctx), \ + (ctx)) + +#define SSL_CreateMask(ctx, sample, sampleLen, mask, maskLen) \ + SSL_EXPERIMENTAL_API("SSL_CreateMask", \ + (SSLMaskingContext * _ctx, const PRUint8 *_sample, \ + unsigned int _sampleLen, PRUint8 *_mask, \ + unsigned int _maskLen), \ + (ctx, sample, sampleLen, mask, maskLen)) + +#define SSL_SetDtls13VersionWorkaround(fd, enabled) \ + SSL_EXPERIMENTAL_API("SSL_SetDtls13VersionWorkaround", \ + (PRFileDesc * _fd, PRBool _enabled), (fd, enabled)) + +/* SSL_AddExternalPsk() and SSL_AddExternalPsk0Rtt() can be used to + * set an external PSK on a socket. If successful, this PSK will + * be used in all subsequent connection attempts for this socket. + * This has no effect if the maximum TLS version is < 1.3. + * + * This API currently only accepts a single PSK, so multiple calls to + * either function will fail. An EPSK can be replaced by calling + * SSL_RemoveExternalPsk followed by SSL_AddExternalPsk. + * For both functions, the label is expected to be a unique identifier + * for the external PSK. Should en external PSK have the same label + * as a configured resumption PSK identity, the external PSK will + * take precedence. + * + * If you want to enable early data, you need to also provide a + * cipher suite for 0-RTT and a limit for the early data using + * SSL_AddExternalPsk0Rtt(). If you want to explicitly disallow + * certificate authentication, use SSL_AuthCertificateHook to set + * a callback that rejects all certificate chains. + */ +#define SSL_AddExternalPsk(fd, psk, identity, identityLen, hash) \ + SSL_EXPERIMENTAL_API("SSL_AddExternalPsk", \ + (PRFileDesc * _fd, PK11SymKey * _psk, \ + const PRUint8 *_identity, unsigned int _identityLen, \ + SSLHashType _hash), \ + (fd, psk, identity, identityLen, hash)) + +#define SSL_AddExternalPsk0Rtt(fd, psk, identity, identityLen, hash, \ + zeroRttSuite, maxEarlyData) \ + SSL_EXPERIMENTAL_API("SSL_AddExternalPsk0Rtt", \ + (PRFileDesc * _fd, PK11SymKey * _psk, \ + const PRUint8 *_identity, unsigned int _identityLen, \ + SSLHashType _hash, PRUint16 _zeroRttSuite, \ + PRUint32 _maxEarlyData), \ + (fd, psk, identity, identityLen, hash, \ + zeroRttSuite, maxEarlyData)) + +/* SSLExp_RemoveExternalPsk() removes an external PSK from socket + * configuration. Returns SECSuccess if the PSK was removed + * successfully, and SECFailure otherwise. */ +#define SSL_RemoveExternalPsk(fd, identity, identityLen) \ + SSL_EXPERIMENTAL_API("SSL_RemoveExternalPsk", \ + (PRFileDesc * _fd, const PRUint8 *_identity, \ + unsigned int _identityLen), \ + (fd, identity, identityLen)) + +/* The next function is used to provide support for TLS RFC 8879 + * (Certificate Compression). + * + * The function SSL_SetCertificateCompressionAlgorithm() adds a certificate + * compression mechanism to the socket fd. */ + +#define SSL_SetCertificateCompressionAlgorithm(fd, t) \ + SSL_EXPERIMENTAL_API("SSL_SetCertificateCompressionAlgorithm", \ + (PRFileDesc * _fd, \ + SSLCertificateCompressionAlgorithm t), \ + (fd, t)) + +/* + * SSL_PeerCertificateChainDER() returns the certificates that were presented + * by the peer as a SECItemArray of DER certificates. It is a replacement for + * SSL_PeerCertificateChain() which returns a CERTCertList. Returns SECFailure + * with error SSL_ERROR_NO_CERTIFICATE if the peer did not present + * certificates. The caller is responsible for freeing the output with + * SECItem_FreeArray(..., PR_TRUE) when this function returns SECSuccess. + */ +#define SSL_PeerCertificateChainDER(fd, out) \ + SSL_EXPERIMENTAL_API("SSL_PeerCertificateChainDER", \ + (PRFileDesc * _fd, SECItemArray * *_out), \ + (fd, out)) + +/* Deprecated experimental APIs */ +#define SSL_UseAltServerHelloType(fd, enable) SSL_DEPRECATED_EXPERIMENTAL_API +#define SSL_SetupAntiReplay(a, b, c) SSL_DEPRECATED_EXPERIMENTAL_API +#define SSL_InitAntiReplay(a, b, c) SSL_DEPRECATED_EXPERIMENTAL_API +#define SSL_EnableESNI(a, b, c, d) SSL_DEPRECATED_EXPERIMENTAL_API +#define SSL_EncodeESNIKeys(a, b, c, d, e, f, g, h, i, j) SSL_DEPRECATED_EXPERIMENTAL_API +#define SSL_SetESNIKeyPair(a, b, c, d) SSL_DEPRECATED_EXPERIMENTAL_API +#define SSL_EncodeEchConfig(a, b, c, d, e, f, g, h, i) SSL_DEPRECATED_EXPERIMENTAL_API + +SEC_END_PROTOS + +#endif /* __sslexp_h_ */ diff --git a/illumos-x86_64/usr/include/mps/sslproto.h b/illumos-x86_64/usr/include/mps/sslproto.h new file mode 100644 index 00000000..beaee517 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/sslproto.h @@ -0,0 +1,294 @@ +/* + * Various and sundry protocol constants. DON'T CHANGE THESE. These values + * are mostly defined by the SSL3 or TLS protocol specifications. + * Cipher kinds and ciphersuites are part of the public API. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __sslproto_h_ +#define __sslproto_h_ + +/* clang-format off */ + +/* All versions less than 3_0 are treated as SSL version 2 */ +#define SSL_LIBRARY_VERSION_2 0x0002 +#define SSL_LIBRARY_VERSION_3_0 0x0300 +#define SSL_LIBRARY_VERSION_TLS_1_0 0x0301 +#define SSL_LIBRARY_VERSION_TLS_1_1 0x0302 +#define SSL_LIBRARY_VERSION_TLS_1_2 0x0303 +#define SSL_LIBRARY_VERSION_TLS_1_3 0x0304 + +/* Note: this is the internal format, not the wire format */ +#define SSL_LIBRARY_VERSION_DTLS_1_0 SSL_LIBRARY_VERSION_TLS_1_1 +#define SSL_LIBRARY_VERSION_DTLS_1_2 SSL_LIBRARY_VERSION_TLS_1_2 +#define SSL_LIBRARY_VERSION_DTLS_1_3 SSL_LIBRARY_VERSION_TLS_1_3 + +/* deprecated old name */ +#define SSL_LIBRARY_VERSION_3_1_TLS SSL_LIBRARY_VERSION_TLS_1_0 + +/* The DTLS versions used in the spec */ +#define SSL_LIBRARY_VERSION_DTLS_1_0_WIRE ((~0x0100) & 0xffff) +#define SSL_LIBRARY_VERSION_DTLS_1_2_WIRE ((~0x0102) & 0xffff) +#define SSL_LIBRARY_VERSION_DTLS_1_3_WIRE ((~0x0103) & 0xffff) + +/* Certificate types */ +#define SSL_CT_X509_CERTIFICATE 0x01 +#if 0 /* XXX Not implemented yet */ +#define SSL_PKCS6_CERTIFICATE 0x02 +#endif +#define SSL_AT_MD5_WITH_RSA_ENCRYPTION 0x01 + +/* Error codes */ +#define SSL_PE_NO_CYPHERS 0x0001 +#define SSL_PE_NO_CERTIFICATE 0x0002 +#define SSL_PE_BAD_CERTIFICATE 0x0004 +#define SSL_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006 + +/* Deprecated SSL 3.0 & libssl names replaced by IANA-registered TLS names. */ +#ifndef SSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES +#define SSL_NULL_WITH_NULL_NULL TLS_NULL_WITH_NULL_NULL +#define SSL_RSA_WITH_NULL_MD5 TLS_RSA_WITH_NULL_MD5 +#define SSL_RSA_WITH_NULL_SHA TLS_RSA_WITH_NULL_SHA +#define SSL_RSA_WITH_RC4_128_MD5 TLS_RSA_WITH_RC4_128_MD5 +#define SSL_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_RC4_128_SHA +#define SSL_RSA_WITH_IDEA_CBC_SHA TLS_RSA_WITH_IDEA_CBC_SHA +#define SSL_RSA_WITH_DES_CBC_SHA TLS_RSA_WITH_DES_CBC_SHA +#define SSL_RSA_WITH_3DES_EDE_CBC_SHA TLS_RSA_WITH_3DES_EDE_CBC_SHA +#define SSL_DH_DSS_WITH_DES_CBC_SHA TLS_DH_DSS_WITH_DES_CBC_SHA +#define SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA +#define SSL_DH_RSA_WITH_DES_CBC_SHA TLS_DH_RSA_WITH_DES_CBC_SHA +#define SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA +#define SSL_DHE_DSS_WITH_DES_CBC_SHA TLS_DHE_DSS_WITH_DES_CBC_SHA +#define SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA +#define SSL_DHE_RSA_WITH_DES_CBC_SHA TLS_DHE_RSA_WITH_DES_CBC_SHA +#define SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA +#define SSL_DH_ANON_WITH_RC4_128_MD5 TLS_DH_anon_WITH_RC4_128_MD5 +#define SSL_DH_ANON_WITH_DES_CBC_SHA TLS_DH_anon_WITH_DES_CBC_SHA +#define SSL_DH_ANON_WITH_3DES_EDE_CBC_SHA TLS_DH_anon_WITH_3DES_EDE_CBC_SHA +#define TLS_DH_ANON_WITH_AES_128_CBC_SHA TLS_DH_anon_WITH_AES_128_CBC_SHA +#define TLS_DH_ANON_WITH_AES_256_CBC_SHA TLS_DH_anon_WITH_AES_256_CBC_SHA +#define TLS_DH_ANON_WITH_CAMELLIA_128_CBC_SHA TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA +#define TLS_DH_ANON_WITH_CAMELLIA_256_CBC_SHA TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA +#endif + +#define TLS_NULL_WITH_NULL_NULL 0x0000 + +#define TLS_RSA_WITH_NULL_MD5 0x0001 +#define TLS_RSA_WITH_NULL_SHA 0x0002 +#define TLS_RSA_WITH_RC4_128_MD5 0x0004 +#define TLS_RSA_WITH_RC4_128_SHA 0x0005 +#define TLS_RSA_WITH_IDEA_CBC_SHA 0x0007 +#define TLS_RSA_WITH_DES_CBC_SHA 0x0009 +#define TLS_RSA_WITH_3DES_EDE_CBC_SHA 0x000a + +#define TLS_DH_DSS_WITH_DES_CBC_SHA 0x000c +#define TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA 0x000d +#define TLS_DH_RSA_WITH_DES_CBC_SHA 0x000f +#define TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA 0x0010 + +#define TLS_DHE_DSS_WITH_DES_CBC_SHA 0x0012 +#define TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA 0x0013 +#define TLS_DHE_RSA_WITH_DES_CBC_SHA 0x0015 +#define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA 0x0016 + +#define TLS_DH_anon_WITH_RC4_128_MD5 0x0018 +#define TLS_DH_anon_WITH_DES_CBC_SHA 0x001a +#define TLS_DH_anon_WITH_3DES_EDE_CBC_SHA 0x001b + +#define TLS_RSA_WITH_AES_128_CBC_SHA 0x002F +#define TLS_DH_DSS_WITH_AES_128_CBC_SHA 0x0030 +#define TLS_DH_RSA_WITH_AES_128_CBC_SHA 0x0031 +#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA 0x0032 +#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA 0x0033 +#define TLS_DH_anon_WITH_AES_128_CBC_SHA 0x0034 + +#define TLS_RSA_WITH_AES_256_CBC_SHA 0x0035 +#define TLS_DH_DSS_WITH_AES_256_CBC_SHA 0x0036 +#define TLS_DH_RSA_WITH_AES_256_CBC_SHA 0x0037 +#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA 0x0038 +#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA 0x0039 +#define TLS_DH_anon_WITH_AES_256_CBC_SHA 0x003A +#define TLS_RSA_WITH_NULL_SHA256 0x003B +#define TLS_RSA_WITH_AES_128_CBC_SHA256 0x003C +#define TLS_RSA_WITH_AES_256_CBC_SHA256 0x003D + +#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 0x0040 +#define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA 0x0041 +#define TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x0042 +#define TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x0043 +#define TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x0044 +#define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x0045 +#define TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA 0x0046 + +#define TLS_DHE_DSS_WITH_RC4_128_SHA 0x0066 +#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 0x0067 +#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 0x006A +#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 0x006B + +#define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA 0x0084 +#define TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x0085 +#define TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x0086 +#define TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x0087 +#define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x0088 +#define TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA 0x0089 + +#define TLS_RSA_WITH_SEED_CBC_SHA 0x0096 + +#define TLS_RSA_WITH_AES_128_GCM_SHA256 0x009C +#define TLS_RSA_WITH_AES_256_GCM_SHA384 0x009D +#define TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 0x009E +#define TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 0x009F +#define TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 0x00A2 +#define TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 0x00A3 + +/* TLS "Signaling Cipher Suite Value" (SCSV). May be requested by client. + * Must NEVER be chosen by server. SSL 3.0 server acknowledges by sending + * back an empty Renegotiation Info (RI) server hello extension. + */ +#define TLS_EMPTY_RENEGOTIATION_INFO_SCSV 0x00FF + +/* TLS_FALLBACK_SCSV is a signaling cipher suite value that indicates that a + * handshake is the result of TLS version fallback. + */ +#define TLS_FALLBACK_SCSV 0x5600 + +/* Cipher Suite Values starting with 0xC000 are defined in informational + * RFCs. + */ +#define TLS_ECDH_ECDSA_WITH_NULL_SHA 0xC001 +#define TLS_ECDH_ECDSA_WITH_RC4_128_SHA 0xC002 +#define TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA 0xC003 +#define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0xC004 +#define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0xC005 + +#define TLS_ECDHE_ECDSA_WITH_NULL_SHA 0xC006 +#define TLS_ECDHE_ECDSA_WITH_RC4_128_SHA 0xC007 +#define TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA 0xC008 +#define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0xC009 +#define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0xC00A + +#define TLS_ECDH_RSA_WITH_NULL_SHA 0xC00B +#define TLS_ECDH_RSA_WITH_RC4_128_SHA 0xC00C +#define TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA 0xC00D +#define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA 0xC00E +#define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA 0xC00F + +#define TLS_ECDHE_RSA_WITH_NULL_SHA 0xC010 +#define TLS_ECDHE_RSA_WITH_RC4_128_SHA 0xC011 +#define TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA 0xC012 +#define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA 0xC013 +#define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA 0xC014 + +#define TLS_ECDH_anon_WITH_NULL_SHA 0xC015 +#define TLS_ECDH_anon_WITH_RC4_128_SHA 0xC016 +#define TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA 0xC017 +#define TLS_ECDH_anon_WITH_AES_128_CBC_SHA 0xC018 +#define TLS_ECDH_anon_WITH_AES_256_CBC_SHA 0xC019 + +#define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 0xC023 +#define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 0xC024 +#define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 0xC027 +#define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 0xC028 + +#define TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0xC02B +#define TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0xC02C +#define TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0xC02D +#define TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0xC02F +#define TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0xC030 +#define TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 0xC031 + +/* draft-ietf-tls-chacha20-poly1305-04 */ +#define TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 0xCCA8 +#define TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 0xCCA9 +#define TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 0xCCAA + +/* Special TLS 1.3 cipher suites that really just specify AEAD */ +#define TLS_AES_128_GCM_SHA256 0x1301 +#define TLS_AES_256_GCM_SHA384 0x1302 +#define TLS_CHACHA20_POLY1305_SHA256 0x1303 + +/* PSK cipher suites. NSS doesn't actually support these, but we + * exposed them when TLS 1.3 used them so we need to keep them + * in the API. */ +#define TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 0xCCAC +#define TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 0xCCAD +#define TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256 0xD001 +#define TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384 0xD002 +#define TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 0x00AA /* RFC 5487 */ +#define TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 0x00AB /* RFC 5487 */ + +/* DTLS-SRTP cipher suites from RFC 5764 */ +/* If you modify this, also modify MAX_DTLS_SRTP_CIPHER_SUITES in sslimpl.h */ +#define SRTP_AES128_CM_HMAC_SHA1_80 0x0001 +#define SRTP_AES128_CM_HMAC_SHA1_32 0x0002 +#define SRTP_NULL_HMAC_SHA1_80 0x0005 +#define SRTP_NULL_HMAC_SHA1_32 0x0006 + +/* DO NOT USE. (deprecated, will be removed) */ +#define SSL_HL_ERROR_HBYTES 3 +#define SSL_HL_CLIENT_HELLO_HBYTES 9 +#define SSL_HL_CLIENT_MASTER_KEY_HBYTES 10 +#define SSL_HL_CLIENT_FINISHED_HBYTES 1 +#define SSL_HL_SERVER_HELLO_HBYTES 11 +#define SSL_HL_SERVER_VERIFY_HBYTES 1 +#define SSL_HL_SERVER_FINISHED_HBYTES 1 +#define SSL_HL_REQUEST_CERTIFICATE_HBYTES 2 +#define SSL_HL_CLIENT_CERTIFICATE_HBYTES 6 +#define SSL_MT_ERROR 0 +#define SSL_MT_CLIENT_HELLO 1 +#define SSL_MT_CLIENT_MASTER_KEY 2 +#define SSL_MT_CLIENT_FINISHED 3 +#define SSL_MT_SERVER_HELLO 4 +#define SSL_MT_SERVER_VERIFY 5 +#define SSL_MT_SERVER_FINISHED 6 +#define SSL_MT_REQUEST_CERTIFICATE 7 +#define SSL_MT_CLIENT_CERTIFICATE 8 +#define SSL_CK_RC4_128_WITH_MD5 0x01 +#define SSL_CK_RC4_128_EXPORT40_WITH_MD5 0x02 +#define SSL_CK_RC2_128_CBC_WITH_MD5 0x03 +#define SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 0x04 +#define SSL_CK_IDEA_128_CBC_WITH_MD5 0x05 +#define SSL_CK_DES_64_CBC_WITH_MD5 0x06 +#define SSL_CK_DES_192_EDE3_CBC_WITH_MD5 0x07 +#define SSL_EN_RC4_128_WITH_MD5 0xFF01 +#define SSL_EN_RC4_128_EXPORT40_WITH_MD5 0xFF02 +#define SSL_EN_RC2_128_CBC_WITH_MD5 0xFF03 +#define SSL_EN_RC2_128_CBC_EXPORT40_WITH_MD5 0xFF04 +#define SSL_EN_IDEA_128_CBC_WITH_MD5 0xFF05 +#define SSL_EN_DES_64_CBC_WITH_MD5 0xFF06 +#define SSL_EN_DES_192_EDE3_CBC_WITH_MD5 0xFF07 +#define TLS_RSA_EXPORT_WITH_RC4_40_MD5 0x0003 +#define TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 0x0006 +#define TLS_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0008 +#define TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x0062 +#define TLS_RSA_EXPORT1024_WITH_RC4_56_SHA 0x0064 +#define TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0014 +#define TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA 0x000e +#define TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x0063 +#define TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x0065 +#define TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA 0x000b +#define TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA 0x0011 +#define TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 0x0017 +#define TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA 0x0019 +#define SSL_FORTEZZA_DMS_WITH_NULL_SHA 0x001c +#define SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA 0x001d +#define SSL_FORTEZZA_DMS_WITH_RC4_128_SHA 0x001e +#define SSL_RSA_OLDFIPS_WITH_3DES_EDE_CBC_SHA 0xffe0 +#define SSL_RSA_OLDFIPS_WITH_DES_CBC_SHA 0xffe1 +#define SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA 0xfeff +#define SSL_RSA_FIPS_WITH_DES_CBC_SHA 0xfefe +#define SSL_RSA_EXPORT_WITH_RC4_40_MD5 TLS_RSA_EXPORT_WITH_RC4_40_MD5 +#define SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 +#define SSL_RSA_EXPORT_WITH_DES40_CBC_SHA TLS_RSA_EXPORT_WITH_DES40_CBC_SHA +#define SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA +#define SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA +#define SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA +#define SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA +#define SSL_DH_ANON_EXPORT_WITH_DES40_CBC_SHA TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA +#define SSL_DH_ANON_EXPORT_WITH_RC4_40_MD5 TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 + +/* clang-format on */ + +#endif /* __sslproto_h_ */ diff --git a/illumos-x86_64/usr/include/mps/sslt.h b/illumos-x86_64/usr/include/mps/sslt.h new file mode 100644 index 00000000..b602f603 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/sslt.h @@ -0,0 +1,610 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file contains prototypes for the public SSL functions. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __sslt_h_ +#define __sslt_h_ + +#include "certt.h" +#include "keyhi.h" +#include "prtypes.h" +#include "secitem.h" + +typedef enum { + ssl_hs_hello_request = 0, + ssl_hs_client_hello = 1, + ssl_hs_server_hello = 2, + ssl_hs_hello_verify_request = 3, + ssl_hs_new_session_ticket = 4, + ssl_hs_end_of_early_data = 5, + ssl_hs_hello_retry_request = 6, + ssl_hs_encrypted_extensions = 8, + ssl_hs_certificate = 11, + ssl_hs_server_key_exchange = 12, + ssl_hs_certificate_request = 13, + ssl_hs_server_hello_done = 14, + ssl_hs_certificate_verify = 15, + ssl_hs_client_key_exchange = 16, + ssl_hs_finished = 20, + ssl_hs_certificate_status = 22, + ssl_hs_key_update = 24, + ssl_hs_compressed_certificate = 25, + ssl_hs_next_proto = 67, + ssl_hs_message_hash = 254, /* Not a real message. */ + ssl_hs_ech_outer_client_hello = 257, /* Not a real message. */ +} SSLHandshakeType; + +typedef enum { + ssl_ct_change_cipher_spec = 20, + ssl_ct_alert = 21, + ssl_ct_handshake = 22, + ssl_ct_application_data = 23, + ssl_ct_ack = 26 +} SSLContentType; + +typedef enum { + ssl_secret_read = 1, + ssl_secret_write = 2, +} SSLSecretDirection; + +typedef struct SSL3StatisticsStr { + /* statistics from ssl3_SendClientHello (sch) */ + long sch_sid_cache_hits; + long sch_sid_cache_misses; + long sch_sid_cache_not_ok; + + /* statistics from ssl3_HandleServerHello (hsh) */ + long hsh_sid_cache_hits; + long hsh_sid_cache_misses; + long hsh_sid_cache_not_ok; + + /* statistics from ssl3_HandleClientHello (hch) */ + long hch_sid_cache_hits; + long hch_sid_cache_misses; + long hch_sid_cache_not_ok; + + /* statistics related to stateless resume */ + long sch_sid_stateless_resumes; + long hsh_sid_stateless_resumes; + long hch_sid_stateless_resumes; + long hch_sid_ticket_parse_failures; +} SSL3Statistics; + +/* Key Exchange algorithm values */ +typedef enum { + ssl_kea_null = 0, + ssl_kea_rsa = 1, + ssl_kea_dh = 2, + ssl_kea_fortezza = 3, /* deprecated, now unused */ + ssl_kea_ecdh = 4, + ssl_kea_ecdh_psk = 5, + ssl_kea_dh_psk = 6, + ssl_kea_tls13_any = 7, + ssl_kea_ecdh_hybrid = 8, + ssl_kea_ecdh_hybrid_psk = 9, + ssl_kea_size /* number of ssl_kea_ algorithms */ +} SSLKEAType; + +/* The following defines are for backwards compatibility. +** They will be removed in a forthcoming release to reduce namespace pollution. +** programs that use the kt_ symbols should convert to the ssl_kt_ symbols +** soon. +*/ +#define kt_null ssl_kea_null +#define kt_rsa ssl_kea_rsa +#define kt_dh ssl_kea_dh +#define kt_fortezza ssl_kea_fortezza /* deprecated, now unused */ +#define kt_ecdh ssl_kea_ecdh +#define kt_kea_size ssl_kea_size + +/* Values of this enum match the SignatureAlgorithm enum from + * https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 */ +typedef enum { + ssl_sign_null = 0, /* "anonymous" in TLS */ + ssl_sign_rsa = 1, + ssl_sign_dsa = 2, + ssl_sign_ecdsa = 3 +} SSLSignType; + +/* Values of this enum match the HashAlgorithm enum from + * https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 */ +typedef enum { + /* ssl_hash_none is used internally to mean the pre-1.2 combination of MD5 + * and SHA1. The other values are only used in TLS 1.2. */ + ssl_hash_none = 0, + ssl_hash_md5 = 1, + ssl_hash_sha1 = 2, + ssl_hash_sha224 = 3, + ssl_hash_sha256 = 4, + ssl_hash_sha384 = 5, + ssl_hash_sha512 = 6 +} SSLHashType; + +/* Deprecated */ +typedef struct SSLSignatureAndHashAlgStr { + SSLHashType hashAlg; + SSLSignType sigAlg; +} SSLSignatureAndHashAlg; + +typedef enum { + ssl_sig_none = 0, + ssl_sig_rsa_pkcs1_sha1 = 0x0201, + ssl_sig_rsa_pkcs1_sha256 = 0x0401, + ssl_sig_rsa_pkcs1_sha384 = 0x0501, + ssl_sig_rsa_pkcs1_sha512 = 0x0601, + /* For ECDSA, the pairing of the hash with a specific curve is only enforced + * in TLS 1.3; in TLS 1.2 any curve can be used with each of these. */ + ssl_sig_ecdsa_secp256r1_sha256 = 0x0403, + ssl_sig_ecdsa_secp384r1_sha384 = 0x0503, + ssl_sig_ecdsa_secp521r1_sha512 = 0x0603, + ssl_sig_rsa_pss_rsae_sha256 = 0x0804, + ssl_sig_rsa_pss_rsae_sha384 = 0x0805, + ssl_sig_rsa_pss_rsae_sha512 = 0x0806, + ssl_sig_ed25519 = 0x0807, + ssl_sig_ed448 = 0x0808, + ssl_sig_rsa_pss_pss_sha256 = 0x0809, + ssl_sig_rsa_pss_pss_sha384 = 0x080a, + ssl_sig_rsa_pss_pss_sha512 = 0x080b, + + ssl_sig_dsa_sha1 = 0x0202, + ssl_sig_dsa_sha256 = 0x0402, + ssl_sig_dsa_sha384 = 0x0502, + ssl_sig_dsa_sha512 = 0x0602, + ssl_sig_ecdsa_sha1 = 0x0203, + + /* The following value (which can't be used in the protocol), represents + * the RSA signature using SHA-1 and MD5 that is used in TLS 1.0 and 1.1. + * This is reported as a signature scheme when TLS 1.0 or 1.1 is used. + * This should not be passed to SSL_SignatureSchemePrefSet(); this + * signature scheme is always used and cannot be disabled. */ + ssl_sig_rsa_pkcs1_sha1md5 = 0x10101, +} SSLSignatureScheme; + +/* Deprecated names maintained only for source compatibility. */ +#define ssl_sig_rsa_pss_sha256 ssl_sig_rsa_pss_rsae_sha256 +#define ssl_sig_rsa_pss_sha384 ssl_sig_rsa_pss_rsae_sha384 +#define ssl_sig_rsa_pss_sha512 ssl_sig_rsa_pss_rsae_sha512 + +/* +** SSLAuthType describes the type of key that is used to authenticate a +** connection. That is, the type of key in the end-entity certificate. +*/ +typedef enum { + ssl_auth_null = 0, + ssl_auth_rsa_decrypt = 1, /* RSA key exchange. */ + ssl_auth_dsa = 2, + ssl_auth_kea = 3, /* unused */ + ssl_auth_ecdsa = 4, + ssl_auth_ecdh_rsa = 5, /* ECDH cert with an RSA signature. */ + ssl_auth_ecdh_ecdsa = 6, /* ECDH cert with an ECDSA signature. */ + ssl_auth_rsa_sign = 7, /* RSA signing with an rsaEncryption key. */ + ssl_auth_rsa_pss = 8, /* RSA signing with a PSS key. */ + ssl_auth_psk = 9, + ssl_auth_tls13_any = 10, + ssl_auth_size /* number of authentication types */ +} SSLAuthType; + +typedef enum { + ssl_psk_none = 0, + ssl_psk_resume = 1, + ssl_psk_external = 2, +} SSLPskType; + +/* This is defined for backward compatibility reasons */ +#define ssl_auth_rsa ssl_auth_rsa_decrypt + +typedef enum { + ssl_calg_null = 0, + ssl_calg_rc4 = 1, + ssl_calg_rc2 = 2, + ssl_calg_des = 3, + ssl_calg_3des = 4, + ssl_calg_idea = 5, + ssl_calg_fortezza = 6, /* deprecated, now unused */ + ssl_calg_aes = 7, + ssl_calg_camellia = 8, + ssl_calg_seed = 9, + ssl_calg_aes_gcm = 10, + ssl_calg_chacha20 = 11 +} SSLCipherAlgorithm; + +typedef enum { + ssl_mac_null = 0, + ssl_mac_md5 = 1, + ssl_mac_sha = 2, + ssl_hmac_md5 = 3, /* TLS HMAC version of mac_md5 */ + ssl_hmac_sha = 4, /* TLS HMAC version of mac_sha */ + ssl_hmac_sha256 = 5, + ssl_mac_aead = 6, + ssl_hmac_sha384 = 7 +} SSLMACAlgorithm; + +typedef enum { + ssl_compression_null = 0, + ssl_compression_deflate = 1 /* RFC 3749 */ +} SSLCompressionMethod; + +typedef enum { + ssl_grp_ec_sect163k1 = 1, + ssl_grp_ec_sect163r1 = 2, + ssl_grp_ec_sect163r2 = 3, + ssl_grp_ec_sect193r1 = 4, + ssl_grp_ec_sect193r2 = 5, + ssl_grp_ec_sect233k1 = 6, + ssl_grp_ec_sect233r1 = 7, + ssl_grp_ec_sect239k1 = 8, + ssl_grp_ec_sect283k1 = 9, + ssl_grp_ec_sect283r1 = 10, + ssl_grp_ec_sect409k1 = 11, + ssl_grp_ec_sect409r1 = 12, + ssl_grp_ec_sect571k1 = 13, + ssl_grp_ec_sect571r1 = 14, + ssl_grp_ec_secp160k1 = 15, + ssl_grp_ec_secp160r1 = 16, + ssl_grp_ec_secp160r2 = 17, + ssl_grp_ec_secp192k1 = 18, + ssl_grp_ec_secp192r1 = 19, + ssl_grp_ec_secp224k1 = 20, + ssl_grp_ec_secp224r1 = 21, + ssl_grp_ec_secp256k1 = 22, + ssl_grp_ec_secp256r1 = 23, + ssl_grp_ec_secp384r1 = 24, + ssl_grp_ec_secp521r1 = 25, + ssl_grp_ec_curve25519 = 29, /* RFC4492 */ + ssl_grp_ffdhe_2048 = 256, /* RFC7919 */ + ssl_grp_ffdhe_3072 = 257, + ssl_grp_ffdhe_4096 = 258, + ssl_grp_ffdhe_6144 = 259, + ssl_grp_ffdhe_8192 = 260, + ssl_grp_kem_mlkem768x25519 = 4588, + ssl_grp_kem_xyber768d00 = 25497, /* draft-tls-westerbaan-xyber768d00-02 */ + ssl_grp_none = 65537, /* special value */ + ssl_grp_ffdhe_custom = 65538 /* special value */ +} SSLNamedGroup; + +typedef struct SSLExtraServerCertDataStr { + /* When this struct is passed to SSL_ConfigServerCert, and authType is set + * to a value other than ssl_auth_null, this limits the use of the key to + * the type defined; otherwise, the certificate is configured for all + * compatible types. */ + SSLAuthType authType; + /* The remainder of the certificate chain. */ + const CERTCertificateList* certChain; + /* A set of one or more stapled OCSP responses for the certificate. This is + * used to generate the OCSP stapling answer provided by the server. */ + const SECItemArray* stapledOCSPResponses; + /* A serialized sign_certificate_timestamp extension, used to answer + * requests from clients for this data. */ + const SECItem* signedCertTimestamps; + + /* Delegated credentials. + * + * A serialized delegated credential (DC) to use for authentication to peers + * who indicate support for this extension (ietf-drafts-tls-subcerts). DCs + * are used opportunistically if (1) the client indicates support, (2) TLS + * 1.3 or higher is negotiated, and (3) the selected certificate is + * configured with a DC. + * + * Note that it's the caller's responsibility to ensure that the DC is + * well-formed. + */ + const SECItem* delegCred; + + /* The secret key corresponding to the |delegCred|. + * + * Note that it's the caller's responsibility to ensure that this matches + * the DC public key. + */ + const SECKEYPrivateKey* delegCredPrivKey; +} SSLExtraServerCertData; + +typedef struct SSLChannelInfoStr { + /* On return, SSL_GetChannelInfo sets |length| to the smaller of + * the |len| argument and the length of the struct used by NSS. + * Callers must ensure the application uses a version of NSS that + * isn't older than the version used at compile time. */ + PRUint32 length; + PRUint16 protocolVersion; + PRUint16 cipherSuite; + + /* The strength of the key used to authenticate the peer. Before + * interpreting this value, check authType, signatureScheme, and + * peerDelegCred, to determine the type of the key and how it was used. + * + * Typically, this is the length of the key from the peer's end-entity + * certificate. If delegated credentials are used (i.e., peerDelegCred is + * PR_TRUE), then this is the strength of the delegated credential key. */ + PRUint32 authKeyBits; + + /* key exchange algorithm info */ + PRUint32 keaKeyBits; + + /* session info */ + PRUint32 creationTime; /* seconds since Jan 1, 1970 */ + PRUint32 lastAccessTime; /* seconds since Jan 1, 1970 */ + PRUint32 expirationTime; /* seconds since Jan 1, 1970 */ + PRUint32 sessionIDLength; /* up to 32 */ + PRUint8 sessionID[32]; + + /* The following fields are added in NSS 3.12.5. */ + + /* compression method info */ + const char* compressionMethodName; + SSLCompressionMethod compressionMethod; + + /* The following fields are added in NSS 3.21. + * This field only has meaning in TLS < 1.3 and will be set to + * PR_FALSE in TLS 1.3. + */ + PRBool extendedMasterSecretUsed; + + /* The following fields were added in NSS 3.25. + * This field only has meaning in TLS >= 1.3, and indicates on the + * client side that the server accepted early (0-RTT) data. + */ + PRBool earlyDataAccepted; + + /* The following fields were added in NSS 3.28. */ + /* These fields have the same meaning as in SSLCipherSuiteInfo. */ + SSLKEAType keaType; + SSLNamedGroup keaGroup; + SSLCipherAlgorithm symCipher; + SSLMACAlgorithm macAlgorithm; + SSLAuthType authType; + SSLSignatureScheme signatureScheme; + + /* The following fields were added in NSS 3.34. */ + /* When the session was resumed this holds the key exchange group of the + * original handshake. */ + SSLNamedGroup originalKeaGroup; + /* This field is PR_TRUE when the session is resumed and PR_FALSE + * otherwise. */ + PRBool resumed; + + /* Indicates whether the peer used a delegated credential (DC) for + * authentication. + */ + PRBool peerDelegCred; + + /* The following fields were added in NSS 3.54. */ + /* Indicates what type of PSK, if any, was used in a handshake. */ + SSLPskType pskType; + + /* The following fields were added in NSS 3.60 */ + /* This field is PR_TRUE when the connection is established + * with TLS 1.3 Encrypted Client Hello. */ + PRBool echAccepted; + + /* The following field was added in NSS 3.66 */ + /* This filed is PR_TRUE if the FIPS indicator is true for the + * current connection */ + PRBool isFIPS; + + /* When adding new fields to this structure, please document the + * NSS version in which they were added. */ +} SSLChannelInfo; + +/* Preliminary channel info */ +#define ssl_preinfo_version (1U << 0) +#define ssl_preinfo_cipher_suite (1U << 1) +#define ssl_preinfo_0rtt_cipher_suite (1U << 2) +/* ssl_preinfo_peer_auth covers peerDelegCred, authKeyBits, + * and scheme. Not included in ssl_preinfo_all as it is client-only. */ +#define ssl_preinfo_peer_auth (1U << 3) +#define ssl_preinfo_ech (1U << 4) +/* ssl_preinfo_all doesn't contain ssl_preinfo_0rtt_cipher_suite because that + * field is only set if 0-RTT is sent (client) or accepted (server). */ +#define ssl_preinfo_all (ssl_preinfo_version | ssl_preinfo_cipher_suite | ssl_preinfo_ech) + +typedef struct SSLPreliminaryChannelInfoStr { + /* On return, SSL_GetPreliminaryChannelInfo sets |length| to the smaller of + * the |len| argument and the length of the struct used by NSS. + * Callers must ensure the application uses a version of NSS that + * isn't older than the version used at compile time. */ + PRUint32 length; + /* A bitfield over SSLPreliminaryValueSet that describes which + * preliminary values are set (see ssl_preinfo_*). */ + PRUint32 valuesSet; + /* Protocol version: test (valuesSet & ssl_preinfo_version) */ + PRUint16 protocolVersion; + /* Cipher suite: test (valuesSet & ssl_preinfo_cipher_suite) */ + PRUint16 cipherSuite; + + /* The following fields were added in NSS 3.29. */ + /* |canSendEarlyData| is true when a 0-RTT is enabled. This can only be + * true after sending the ClientHello and before the handshake completes. + */ + PRBool canSendEarlyData; + + /* The following fields were added in NSS 3.31. */ + /* The number of early data octets that a client is permitted to send on + * this connection. The value will be zero if the connection was not + * resumed or early data is not permitted. For a client, this value only + * has meaning if |canSendEarlyData| is true. For a server, this indicates + * the value that was advertised in the session ticket that was used to + * resume this session. */ + PRUint32 maxEarlyDataSize; + + /* The following fields were added in NSS 3.43. */ + /* This reports the cipher suite used for 0-RTT if it sent or accepted. For + * a client, this is set earlier than |cipherSuite|, and will match that + * value if 0-RTT is accepted by the server. The server only sets this + * after accepting 0-RTT, so this will contain the same value. */ + PRUint16 zeroRttCipherSuite; + + /* The following fields were added in NSS 3.48. */ + /* These fields contain information about the key that will be used in + * the CertificateVerify message. If Delegated Credentials are being used, + * this is the DC-contained SPKI, else the EE-cert SPKI. These fields are + * valid only after the Certificate message is handled. This can be determined + * by checking the valuesSet field against |ssl_preinfo_peer_auth|. */ + PRBool peerDelegCred; + PRUint32 authKeyBits; + SSLSignatureScheme signatureScheme; + + /* The following fields were added in NSS 3.60. */ + PRBool echAccepted; + /* If the application configured ECH but |!echAccepted|, authCertificate + * should use the following hostname extracted from the ECHConfig. */ + const char* echPublicName; + + /* The following field was added in NSS 3.88. */ + PRBool ticketSupportsEarlyData; + + /* When adding new fields to this structure, please document the + * NSS version in which they were added. */ +} SSLPreliminaryChannelInfo; + +typedef struct SSLCipherSuiteInfoStr { + /* On return, SSL_GetCipherSuitelInfo sets |length| to the smaller of + * the |len| argument and the length of the struct used by NSS. + * Callers must ensure the application uses a version of NSS that + * isn't older than the version used at compile time. */ + PRUint16 length; + PRUint16 cipherSuite; + + /* Cipher Suite Name */ + const char* cipherSuiteName; + + /* server authentication info */ + const char* authAlgorithmName; + SSLAuthType authAlgorithm; /* deprecated, use |authType| */ + + /* key exchange algorithm info */ + const char* keaTypeName; + SSLKEAType keaType; + + /* symmetric encryption info */ + const char* symCipherName; + SSLCipherAlgorithm symCipher; + PRUint16 symKeyBits; + PRUint16 symKeySpace; + PRUint16 effectiveKeyBits; + + /* MAC info */ + /* AEAD ciphers don't have a MAC. For an AEAD cipher, macAlgorithmName + * is "AEAD", macAlgorithm is ssl_mac_aead, and macBits is the length in + * bits of the authentication tag. */ + const char* macAlgorithmName; + SSLMACAlgorithm macAlgorithm; + PRUint16 macBits; + + PRUintn isFIPS : 1; + PRUintn isExportable : 1; /* deprecated, don't use */ + PRUintn nonStandard : 1; + PRUintn reservedBits : 29; + + /* The following fields were added in NSS 3.24. */ + /* This reports the correct authentication type for the cipher suite, use + * this instead of |authAlgorithm|. */ + SSLAuthType authType; + + /* The following fields were added in NSS 3.43. */ + /* This reports the hash function used in the TLS KDF, or HKDF for TLS 1.3. + * For suites defined for versions of TLS earlier than TLS 1.2, this reports + * ssl_hash_none. */ + SSLHashType kdfHash; + + /* When adding new fields to this structure, please document the + * NSS version in which they were added. */ +} SSLCipherSuiteInfo; + +typedef enum { + ssl_variant_stream = 0, + ssl_variant_datagram = 1 +} SSLProtocolVariant; + +typedef struct SSLVersionRangeStr { + PRUint16 min; + PRUint16 max; +} SSLVersionRange; + +typedef enum { + SSL_sni_host_name = 0, + SSL_sni_type_total +} SSLSniNameType; + +/* Supported extensions. */ +/* Update SSL_MAX_EXTENSIONS whenever a new extension type is added. */ +typedef enum { + ssl_server_name_xtn = 0, + ssl_cert_status_xtn = 5, + ssl_supported_groups_xtn = 10, + ssl_ec_point_formats_xtn = 11, + ssl_signature_algorithms_xtn = 13, + ssl_use_srtp_xtn = 14, + ssl_app_layer_protocol_xtn = 16, + /* signed_certificate_timestamp extension, RFC 6962 */ + ssl_signed_cert_timestamp_xtn = 18, + ssl_padding_xtn = 21, + ssl_extended_master_secret_xtn = 23, + ssl_certificate_compression_xtn = 27, + ssl_record_size_limit_xtn = 28, + ssl_delegated_credentials_xtn = 34, + ssl_session_ticket_xtn = 35, + /* 40 was used in draft versions of TLS 1.3; it is now reserved. */ + ssl_tls13_pre_shared_key_xtn = 41, + ssl_tls13_early_data_xtn = 42, + ssl_tls13_supported_versions_xtn = 43, + ssl_tls13_cookie_xtn = 44, + ssl_tls13_psk_key_exchange_modes_xtn = 45, + ssl_tls13_ticket_early_data_info_xtn = 46, /* Deprecated. */ + ssl_tls13_certificate_authorities_xtn = 47, + ssl_tls13_post_handshake_auth_xtn = 49, + ssl_signature_algorithms_cert_xtn = 50, + ssl_tls13_key_share_xtn = 51, + /* TLS 1.3 GREASE extension dummy type for builders. */ + ssl_tls13_grease_xtn = 0x0a0a, + ssl_next_proto_nego_xtn = 13172, /* Deprecated. */ + ssl_renegotiation_info_xtn = 0xff01, + ssl_tls13_short_header_xtn = 0xff03, /* Deprecated. */ + ssl_tls13_outer_extensions_xtn = 0xfd00, + ssl_tls13_encrypted_client_hello_xtn = 0xfe0d, + ssl_tls13_encrypted_sni_xtn = 0xffce, /* Deprecated. */ +} SSLExtensionType; + +/* This is the old name for the supported_groups extensions. */ +#define ssl_elliptic_curves_xtn ssl_supported_groups_xtn + +/* SSL_MAX_EXTENSIONS includes the maximum number of extensions that are + * supported for any single message type. That is, a ClientHello; ServerHello + * and TLS 1.3 NewSessionTicket and HelloRetryRequest extensions have fewer. */ +#define SSL_MAX_EXTENSIONS 22 + +/* Deprecated */ +typedef enum { + ssl_dhe_group_none = 0, + ssl_ff_dhe_2048_group = 1, + ssl_ff_dhe_3072_group = 2, + ssl_ff_dhe_4096_group = 3, + ssl_ff_dhe_6144_group = 4, + ssl_ff_dhe_8192_group = 5, + ssl_dhe_group_max +} SSLDHEGroupType; + +/* RFC 8879: TLS Certificate Compression - 3. Negotiating Certificate Compression +** enum { +** zlib(1), +** brotli(2), +** zstd(3), +** (65535) +** } CertificateCompressionAlgorithm; +*/ +typedef PRUint16 SSLCertificateCompressionAlgorithmID; + +typedef struct SSLCertificateCompressionAlgorithmStr { + SSLCertificateCompressionAlgorithmID id; + const char* name; + SECStatus (*encode)(const SECItem* input, SECItem* output); + /* outputLen is the length of the output buffer passed by NSS to the decode function. + * Decode should return an error code if the decoding fails or the output buffer is not big enough. + * usedLen is an outparam which indicates the number of bytes the decoder consumed from output. + * Note: usedLen is always <= outputLen. */ + SECStatus (*decode)(const SECItem* input, unsigned char* output, size_t outputLen, size_t* usedLen); +} SSLCertificateCompressionAlgorithm; + +#endif /* __sslt_h_ */ diff --git a/illumos-x86_64/usr/include/mps/utilmodt.h b/illumos-x86_64/usr/include/mps/utilmodt.h new file mode 100644 index 00000000..0d1e4419 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/utilmodt.h @@ -0,0 +1,44 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _UTILMODT_H_ +#define _UTILMODT_H_ 1 + +/* + * these are SECMOD flags that would normally be in secmodt.h, but are needed + * for the parser in util. Fort this reason we preserve the SECMOD names. + */ +#define SECMOD_RSA_FLAG 0x00000001L +#define SECMOD_DSA_FLAG 0x00000002L +#define SECMOD_RC2_FLAG 0x00000004L +#define SECMOD_RC4_FLAG 0x00000008L +#define SECMOD_DES_FLAG 0x00000010L +#define SECMOD_DH_FLAG 0x00000020L +#define SECMOD_FORTEZZA_FLAG 0x00000040L +#define SECMOD_RC5_FLAG 0x00000080L +#define SECMOD_SHA1_FLAG 0x00000100L +#define SECMOD_MD5_FLAG 0x00000200L +#define SECMOD_MD2_FLAG 0x00000400L +#define SECMOD_SSL_FLAG 0x00000800L +#define SECMOD_TLS_FLAG 0x00001000L +#define SECMOD_AES_FLAG 0x00002000L +#define SECMOD_SHA256_FLAG 0x00004000L /* also for SHA224 */ +#define SECMOD_SHA512_FLAG 0x00008000L /* also for SHA384 */ +#define SECMOD_CAMELLIA_FLAG 0x00010000L /* = PUBLIC_MECH_CAMELLIA_FLAG */ +#define SECMOD_SEED_FLAG 0x00020000L +#define SECMOD_ECC_FLAG 0x00040000L +#define SECMOD_MLDSA_FLAG 0x00080000L +/* reserved bit for future, do not use */ +#define SECMOD_RESERVED_FLAG 0X08000000L +#define SECMOD_FRIENDLY_FLAG 0x10000000L +#define SECMOD_RANDOM_FLAG 0x80000000L + +#define PK11_OWN_PW_DEFAULTS 0x20000000L +#define PK11_DISABLE_FLAG 0x40000000L + +/* need to make SECMOD and PK11 prefixes consistent. */ +#define SECMOD_OWN_PW_DEFAULTS PK11_OWN_PW_DEFAULTS +#define SECMOD_DISABLE_FLAG PK11_DISABLE_FLAG + +#endif /* _UTILMODT_H_ */ diff --git a/illumos-x86_64/usr/include/mps/utilpars.h b/illumos-x86_64/usr/include/mps/utilpars.h new file mode 100644 index 00000000..289fdca9 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/utilpars.h @@ -0,0 +1,70 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _UTILPARS_H_ +#define _UTILPARS_H_ 1 + +#include "utilparst.h" +#include "plarena.h" + +/* handle a module db request */ +char **NSSUTIL_DoModuleDBFunction(unsigned long function, char *parameters, void *args); + +/* parsing functions */ +char *NSSUTIL_ArgFetchValue(const char *string, int *pcount); +const char *NSSUTIL_ArgStrip(const char *c); +char *NSSUTIL_ArgGetParamValue(const char *paramName, const char *parameters); +const char *NSSUTIL_ArgSkipParameter(const char *string); +char *NSSUTIL_ArgGetLabel(const char *inString, int *next); +long NSSUTIL_ArgDecodeNumber(const char *num); +PRBool NSSUTIL_ArgIsBlank(char c); +PRBool NSSUTIL_ArgHasFlag(const char *label, const char *flag, + const char *parameters); +long NSSUTIL_ArgReadLong(const char *label, const char *params, long defValue, + PRBool *isdefault); + +/* quoting functions */ +int NSSUTIL_EscapeSize(const char *string, char quote); +char *NSSUTIL_Escape(const char *string, char quote); +int NSSUTIL_QuoteSize(const char *string, char quote); +char *NSSUTIL_Quote(const char *string, char quote); +int NSSUTIL_DoubleEscapeSize(const char *string, char quote1, char quote2); +char *NSSUTIL_DoubleEscape(const char *string, char quote1, char quote2); + +unsigned long NSSUTIL_ArgParseSlotFlags(const char *label, const char *params); +struct NSSUTILPreSlotInfoStr *NSSUTIL_ArgParseSlotInfo(PLArenaPool *arena, + const char *slotParams, int *retCount); +char *NSSUTIL_MkSlotString(unsigned long slotID, unsigned long defaultFlags, + unsigned long timeout, unsigned char askpw_in, + PRBool hasRootCerts, PRBool hasRootTrust); +SECStatus NSSUTIL_ArgParseModuleSpec(const char *modulespec, char **lib, + char **mod, char **parameters, char **nss); +SECStatus NSSUTIL_ArgParseModuleSpecEx(const char *modulespec, char **lib, + char **mod, char **parameters, char **nss, char **config); +char *NSSUTIL_MkModuleSpec(char *dllName, char *commonName, + char *parameters, char *NSS); +char *NSSUTIL_MkModuleSpecEx(char *dllName, char *commonName, + char *parameters, char *NSS, char *config); +char *NSSUTIL_AddNSSFlagToModuleSpec(char *spec, char *addFlag); +void NSSUTIL_ArgParseCipherFlags(unsigned long *newCiphers, + const char *cipherList); +char *NSSUTIL_MkNSSString(char **slotStrings, int slotCount, PRBool internal, + PRBool isFIPS, PRBool isModuleDB, PRBool isModuleDBOnly, + PRBool isCritical, unsigned long trustOrder, + unsigned long cipherOrder, unsigned long ssl0, unsigned long ssl1); + +/* + * private functions for softoken. + */ +char *_NSSUTIL_GetSecmodName(const char *param, NSSDBType *dbType, + char **appName, char **filename, PRBool *rw); +const char *_NSSUTIL_EvaluateConfigDir(const char *configdir, NSSDBType *dbType, char **app); +#if defined(_WIN32) +wchar_t *_NSSUTIL_UTF8ToWide(const char *buf); +PRStatus _NSSUTIL_Access(const char *path, PRAccessHow how); +#else +#define _NSSUTIL_Access(path, how) PR_Access((path), (how)) +#endif + +#endif /* _UTILPARS_H_ */ diff --git a/illumos-x86_64/usr/include/mps/utilparst.h b/illumos-x86_64/usr/include/mps/utilparst.h new file mode 100644 index 00000000..5dda0902 --- /dev/null +++ b/illumos-x86_64/usr/include/mps/utilparst.h @@ -0,0 +1,78 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef UTILPARS_T_H +#define UTILPARS_T_H 1 +#include "pkcs11t.h" + +/* + * macros to handle parsing strings of blank sparated arguments. + * Several NSSUTIL_HANDLE_STRING() macros should be places one after another with no intervening + * code. The first ones have precedence over the later ones. The last Macro should be + * NSSUTIL_HANDLE_FINAL_ARG. + * + * param is the input parameters. On exit param will point to the next parameter to parse. If the + * last paramter has been returned, param points to a null byte (*param = '0'); + * target is the location to store any data aquired from the parameter. Caller is responsible to free this data. + * value is the string value of the parameter. + * command is any commands you need to run to help process the parameter's data. + */ +#define NSSUTIL_HANDLE_STRING_ARG(param, target, value, command) \ + if (PORT_Strncasecmp(param, value, sizeof(value) - 1) == 0) { \ + param += sizeof(value) - 1; \ + if (target) \ + PORT_Free(target); \ + target = NSSUTIL_ArgFetchValue(param, &next); \ + param += next; \ + command; \ + } else + +#define NSSUTIL_HANDLE_FINAL_ARG(param) \ + { \ + param = NSSUTIL_ArgSkipParameter(param); \ + } \ + param = NSSUTIL_ArgStrip(param); + +#define NSSUTIL_PATH_SEPARATOR "/" + +/* default module configuration strings */ +#define NSSUTIL_DEFAULT_INTERNAL_INIT1 \ + "library= name=\"NSS Internal PKCS #11 Module\" parameters=" +#define NSSUTIL_DEFAULT_INTERNAL_INIT2 \ + " NSS=\"Flags=internal,critical trustOrder=75 cipherOrder=100 slotParams=(1={" +#define NSSUTIL_DEFAULT_INTERNAL_INIT3 \ + " askpw=any timeout=30})\"" +#define NSSUTIL_DEFAULT_SFTKN_FLAGS \ + "slotFlags=[ECC,RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512]" + +#define NSSUTIL_DEFAULT_CIPHER_ORDER 0 +#define NSSUTIL_DEFAULT_TRUST_ORDER 50 +#define NSSUTIL_ARG_ESCAPE '\\' + +/* hold slot default flags until we initialize a slot. This structure is only + * useful between the time we define a module (either by hand or from the + * database) and the time the module is loaded. Not reference counted */ +struct NSSUTILPreSlotInfoStr { + CK_SLOT_ID slotID; /* slot these flags are for */ + unsigned long defaultFlags; /* bit mask of default implementation this slot + * provides */ + int askpw; /* slot specific password bits */ + long timeout; /* slot specific timeout value */ + char hasRootCerts; /* is this the root cert PKCS #11 module? */ + char hasRootTrust; /* is this the root cert PKCS #11 module? */ + int reserved0[2]; + void *reserved1[2]; +}; + +/* + * private functions for softoken. + */ +typedef enum { + NSS_DB_TYPE_NONE = 0, + NSS_DB_TYPE_SQL, + NSS_DB_TYPE_EXTERN, + NSS_DB_TYPE_LEGACY, + NSS_DB_TYPE_MULTIACCESS +} NSSDBType; + +#endif /* UTILPARS_T_H */ diff --git a/illumos-x86_64/usr/include/mps/utilrename.h b/illumos-x86_64/usr/include/mps/utilrename.h new file mode 100644 index 00000000..b4bb564e --- /dev/null +++ b/illumos-x86_64/usr/include/mps/utilrename.h @@ -0,0 +1,168 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * utilrename.h - rename symbols moved from libnss3 to libnssutil3 + * + */ + +#ifndef _LIBUTIL_H_ +#define _LIBUTIL_H_ _LIBUTIL_H__Util + +#ifdef USE_UTIL_DIRECTLY + +/* functions moved from libnss3 */ +#define ATOB_AsciiToData ATOB_AsciiToData_Util +#define ATOB_ConvertAsciiToItem ATOB_ConvertAsciiToItem_Util +#define BTOA_ConvertItemToAscii BTOA_ConvertItemToAscii_Util +#define BTOA_DataToAscii BTOA_DataToAscii_Util +#define CERT_GenTime2FormattedAscii CERT_GenTime2FormattedAscii_Util +#define DER_AsciiToTime DER_AsciiToTime_Util +#define DER_DecodeTimeChoice DER_DecodeTimeChoice_Util +#define DER_Encode DER_Encode_Util +#define DER_EncodeTimeChoice DER_EncodeTimeChoice_Util +#define DER_GeneralizedDayToAscii DER_GeneralizedDayToAscii_Util +#define DER_GeneralizedTimeToTime DER_GeneralizedTimeToTime_Util +#define DER_GetInteger DER_GetInteger_Util +#define DER_Lengths DER_Lengths_Util +#define DER_TimeChoiceDayToAscii DER_TimeChoiceDayToAscii_Util +#define DER_TimeToGeneralizedTime DER_TimeToGeneralizedTime_Util +#define DER_TimeToGeneralizedTimeArena DER_TimeToGeneralizedTimeArena_Util +#define DER_TimeToUTCTime DER_TimeToUTCTime_Util +#define DER_UTCDayToAscii DER_UTCDayToAscii_Util +#define DER_UTCTimeToAscii DER_UTCTimeToAscii_Util +#define DER_UTCTimeToTime DER_UTCTimeToTime_Util +#define NSS_PutEnv NSS_PutEnv_Util +#define NSSBase64_DecodeBuffer NSSBase64_DecodeBuffer_Util +#define NSSBase64_EncodeItem NSSBase64_EncodeItem_Util +#define NSSBase64Decoder_Create NSSBase64Decoder_Create_Util +#define NSSBase64Decoder_Destroy NSSBase64Decoder_Destroy_Util +#define NSSBase64Decoder_Update NSSBase64Decoder_Update_Util +#define NSSBase64Encoder_Create NSSBase64Encoder_Create_Util +#define NSSBase64Encoder_Destroy NSSBase64Encoder_Destroy_Util +#define NSSBase64Encoder_Update NSSBase64Encoder_Update_Util +#define NSSRWLock_Destroy NSSRWLock_Destroy_Util +#define NSSRWLock_HaveWriteLock NSSRWLock_HaveWriteLock_Util +#define NSSRWLock_LockRead NSSRWLock_LockRead_Util +#define NSSRWLock_LockWrite NSSRWLock_LockWrite_Util +#define NSSRWLock_New NSSRWLock_New_Util +#define NSSRWLock_UnlockRead NSSRWLock_UnlockRead_Util +#define NSSRWLock_UnlockWrite NSSRWLock_UnlockWrite_Util +#define PORT_Alloc PORT_Alloc_Util +#define PORT_ArenaAlloc PORT_ArenaAlloc_Util +#define PORT_ArenaGrow PORT_ArenaGrow_Util +#define PORT_ArenaMark PORT_ArenaMark_Util +#define PORT_ArenaRelease PORT_ArenaRelease_Util +#define PORT_ArenaStrdup PORT_ArenaStrdup_Util +#define PORT_ArenaUnmark PORT_ArenaUnmark_Util +#define PORT_ArenaZAlloc PORT_ArenaZAlloc_Util +#define PORT_Free PORT_Free_Util +#define PORT_FreeArena PORT_FreeArena_Util +#define PORT_GetError PORT_GetError_Util +#define PORT_NewArena PORT_NewArena_Util +#define PORT_Realloc PORT_Realloc_Util +#define PORT_SetError PORT_SetError_Util +#define PORT_SetUCS2_ASCIIConversionFunction PORT_SetUCS2_ASCIIConversionFunction_Util +#define PORT_SetUCS2_UTF8ConversionFunction PORT_SetUCS2_UTF8ConversionFunction_Util +#define PORT_SetUCS4_UTF8ConversionFunction PORT_SetUCS4_UTF8ConversionFunction_Util +#define PORT_Strdup PORT_Strdup_Util +#define PORT_UCS2_ASCIIConversion PORT_UCS2_ASCIIConversion_Util +#define PORT_UCS2_UTF8Conversion PORT_UCS2_UTF8Conversion_Util +#define PORT_ZAlloc PORT_ZAlloc_Util +#define PORT_ZAllocAligned PORT_ZAllocAligned_Util +#define PORT_ZAllocAlignedOffset PORT_ZAllocAlignedOffset_Util +#define PORT_ZFree PORT_ZFree_Util +#define SEC_ASN1Decode SEC_ASN1Decode_Util +#define SEC_ASN1DecodeInteger SEC_ASN1DecodeInteger_Util +#define SEC_ASN1DecodeItem SEC_ASN1DecodeItem_Util +#define SEC_ASN1DecoderAbort SEC_ASN1DecoderAbort_Util +#define SEC_ASN1DecoderClearFilterProc SEC_ASN1DecoderClearFilterProc_Util +#define SEC_ASN1DecoderClearNotifyProc SEC_ASN1DecoderClearNotifyProc_Util +#define SEC_ASN1DecoderFinish SEC_ASN1DecoderFinish_Util +#define SEC_ASN1DecoderSetFilterProc SEC_ASN1DecoderSetFilterProc_Util +#define SEC_ASN1DecoderSetNotifyProc SEC_ASN1DecoderSetNotifyProc_Util +#define SEC_ASN1DecoderStart SEC_ASN1DecoderStart_Util +#define SEC_ASN1DecoderUpdate SEC_ASN1DecoderUpdate_Util +#define SEC_ASN1Encode SEC_ASN1Encode_Util +#define SEC_ASN1EncodeInteger SEC_ASN1EncodeInteger_Util +#define SEC_ASN1EncodeItem SEC_ASN1EncodeItem_Util +#define SEC_ASN1EncoderAbort SEC_ASN1EncoderAbort_Util +#define SEC_ASN1EncoderClearNotifyProc SEC_ASN1EncoderClearNotifyProc_Util +#define SEC_ASN1EncoderClearStreaming SEC_ASN1EncoderClearStreaming_Util +#define SEC_ASN1EncoderClearTakeFromBuf SEC_ASN1EncoderClearTakeFromBuf_Util +#define SEC_ASN1EncoderFinish SEC_ASN1EncoderFinish_Util +#define SEC_ASN1EncoderSetNotifyProc SEC_ASN1EncoderSetNotifyProc_Util +#define SEC_ASN1EncoderSetStreaming SEC_ASN1EncoderSetStreaming_Util +#define SEC_ASN1EncoderSetTakeFromBuf SEC_ASN1EncoderSetTakeFromBuf_Util +#define SEC_ASN1EncoderStart SEC_ASN1EncoderStart_Util +#define SEC_ASN1EncoderUpdate SEC_ASN1EncoderUpdate_Util +#define SEC_ASN1EncodeUnsignedInteger SEC_ASN1EncodeUnsignedInteger_Util +#define SEC_ASN1LengthLength SEC_ASN1LengthLength_Util +#define SEC_QuickDERDecodeItem SEC_QuickDERDecodeItem_Util +#define SECITEM_AllocItem SECITEM_AllocItem_Util +#define SECITEM_ArenaDupItem SECITEM_ArenaDupItem_Util +#define SECITEM_CompareItem SECITEM_CompareItem_Util +#define SECITEM_CopyItem SECITEM_CopyItem_Util +#define SECITEM_DupItem SECITEM_DupItem_Util +#define SECITEM_FreeItem SECITEM_FreeItem_Util +#define SECITEM_ItemsAreEqual SECITEM_ItemsAreEqual_Util +#define SECITEM_ZfreeItem SECITEM_ZfreeItem_Util +#define SECOID_AddEntry SECOID_AddEntry_Util +#define SECOID_CompareAlgorithmID SECOID_CompareAlgorithmID_Util +#define SECOID_CopyAlgorithmID SECOID_CopyAlgorithmID_Util +#define SECOID_DestroyAlgorithmID SECOID_DestroyAlgorithmID_Util +#define SECOID_FindOID SECOID_FindOID_Util +#define SECOID_FindOIDByTag SECOID_FindOIDByTag_Util +#define SECOID_FindOIDTag SECOID_FindOIDTag_Util +#define SECOID_FindOIDTagDescription SECOID_FindOIDTagDescription_Util +#define SECOID_GetAlgorithmTag SECOID_GetAlgorithmTag_Util +#define SECOID_SetAlgorithmID SECOID_SetAlgorithmID_Util +#define SGN_CompareDigestInfo SGN_CompareDigestInfo_Util +#define SGN_CopyDigestInfo SGN_CopyDigestInfo_Util +#define SGN_CreateDigestInfo SGN_CreateDigestInfo_Util +#define SGN_DestroyDigestInfo SGN_DestroyDigestInfo_Util +#define HASH_GetHashTypeByOidTag HASH_GetHashTypeByOidTag_Util +#define HASH_GetHashOidTagByHashType HASH_GetHashOidTagByHashType_Util +#define HASH_GetHashOidTagByHMACOidTag HASH_GetHashOidTagByHMACOidTag_Util +#define HASH_GetHMACOidTagByHashOidTag HASH_GetHMACOidTagByHashOidTag_Util + +/* templates moved from libnss3 */ +#define NSS_Get_SEC_AnyTemplate NSS_Get_SEC_AnyTemplate_Util +#define NSS_Get_SEC_BitStringTemplate NSS_Get_SEC_BitStringTemplate_Util +#define NSS_Get_SEC_BMPStringTemplate NSS_Get_SEC_BMPStringTemplate_Util +#define NSS_Get_SEC_BooleanTemplate NSS_Get_SEC_BooleanTemplate_Util +#define NSS_Get_SEC_GeneralizedTimeTemplate NSS_Get_SEC_GeneralizedTimeTemplate_Util +#define NSS_Get_SEC_IA5StringTemplate NSS_Get_SEC_IA5StringTemplate_Util +#define NSS_Get_SEC_IntegerTemplate NSS_Get_SEC_IntegerTemplate_Util +#define NSS_Get_SEC_NullTemplate NSS_Get_SEC_NullTemplate_Util +#define NSS_Get_SEC_ObjectIDTemplate NSS_Get_SEC_ObjectIDTemplate_Util +#define NSS_Get_SEC_OctetStringTemplate NSS_Get_SEC_OctetStringTemplate_Util +#define NSS_Get_SEC_PointerToAnyTemplate NSS_Get_SEC_PointerToAnyTemplate_Util +#define NSS_Get_SEC_PointerToOctetStringTemplate NSS_Get_SEC_PointerToOctetStringTemplate_Util +#define NSS_Get_SEC_SetOfAnyTemplate NSS_Get_SEC_SetOfAnyTemplate_Util +#define NSS_Get_SEC_UTCTimeTemplate NSS_Get_SEC_UTCTimeTemplate_Util +#define NSS_Get_SEC_UTF8StringTemplate NSS_Get_SEC_UTF8StringTemplate_Util +#define NSS_Get_SECOID_AlgorithmIDTemplate NSS_Get_SECOID_AlgorithmIDTemplate_Util +#define NSS_Get_sgn_DigestInfoTemplate NSS_Get_sgn_DigestInfoTemplate_Util +#define SEC_AnyTemplate SEC_AnyTemplate_Util +#define SEC_BitStringTemplate SEC_BitStringTemplate_Util +#define SEC_BMPStringTemplate SEC_BMPStringTemplate_Util +#define SEC_BooleanTemplate SEC_BooleanTemplate_Util +#define SEC_GeneralizedTimeTemplate SEC_GeneralizedTimeTemplate_Util +#define SEC_IA5StringTemplate SEC_IA5StringTemplate_Util +#define SEC_IntegerTemplate SEC_IntegerTemplate_Util +#define SEC_NullTemplate SEC_NullTemplate_Util +#define SEC_ObjectIDTemplate SEC_ObjectIDTemplate_Util +#define SEC_OctetStringTemplate SEC_OctetStringTemplate_Util +#define SEC_PointerToAnyTemplate SEC_PointerToAnyTemplate_Util +#define SEC_PointerToOctetStringTemplate SEC_PointerToOctetStringTemplate_Util +#define SEC_SetOfAnyTemplate SEC_SetOfAnyTemplate_Util +#define SEC_UTCTimeTemplate SEC_UTCTimeTemplate_Util +#define SEC_UTF8StringTemplate SEC_UTF8StringTemplate_Util +#define SECOID_AlgorithmIDTemplate SECOID_AlgorithmIDTemplate_Util +#define sgn_DigestInfoTemplate sgn_DigestInfoTemplate_Util + +#endif /* USE_UTIL_DIRECTLY */ + +#endif /* _LIBUTIL_H_ */ diff --git a/illumos-x86_64/usr/include/mqueue.h b/illumos-x86_64/usr/include/mqueue.h new file mode 100644 index 00000000..caa5d453 --- /dev/null +++ b/illumos-x86_64/usr/include/mqueue.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _MQUEUE_H +#define _MQUEUE_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *mqd_t; /* opaque message queue descriptor */ + +struct mq_attr { + long mq_flags; /* message queue flags */ + long mq_maxmsg; /* maximum number of messages */ + long mq_msgsize; /* maximum message size */ + long mq_curmsgs; /* number of messages currently queued */ + int mq_pad[12]; +}; + +/* + * function prototypes + */ +#if (_POSIX_C_SOURCE - 0 > 0) && (_POSIX_C_SOURCE - 0 <= 2) +#error "POSIX Message Passing is not supported in POSIX.1-1990" +#endif +#include +mqd_t mq_open(const char *, int, ...); +int mq_close(mqd_t); +int mq_unlink(const char *); +int mq_send(mqd_t, const char *, size_t, unsigned int); +int mq_timedsend(mqd_t, const char *, size_t, unsigned int, + const struct timespec *); +int mq_reltimedsend_np(mqd_t, const char *, size_t, unsigned int, + const struct timespec *); +ssize_t mq_receive(mqd_t, char *, size_t, unsigned int *); +ssize_t mq_timedreceive(mqd_t, char *_RESTRICT_KYWD, size_t, + unsigned int *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +ssize_t mq_reltimedreceive_np(mqd_t, char *_RESTRICT_KYWD, size_t, + unsigned int *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +int mq_notify(mqd_t, const struct sigevent *); +int mq_getattr(mqd_t, struct mq_attr *); +int mq_setattr(mqd_t, const struct mq_attr *_RESTRICT_KYWD, + struct mq_attr *_RESTRICT_KYWD); + +#ifdef __cplusplus +} +#endif + +#endif /* _MQUEUE_H */ diff --git a/illumos-x86_64/usr/include/mtmalloc.h b/illumos-x86_64/usr/include/mtmalloc.h new file mode 100644 index 00000000..94c025bf --- /dev/null +++ b/illumos-x86_64/usr/include/mtmalloc.h @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _MTMALLOC_H +#define _MTMALLOC_H + +/* + * Public interface for multi-threadead malloc user land library + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* commands for mallocctl(int cmd, long value) */ + +#define MTDOUBLEFREE 1 /* core dumps on double free */ +#define MTDEBUGPATTERN 2 /* write misaligned data after free. */ +#define MTINITBUFFER 4 /* write misaligned data at allocation */ +#define MTCHUNKSIZE 32 /* How much to alloc when backfilling caches. */ + +void mallocctl(int, long); + +#ifdef __cplusplus +} +#endif + +#endif /* _MTMALLOC_H */ diff --git a/illumos-x86_64/usr/include/nan.h b/illumos-x86_64/usr/include/nan.h new file mode 100644 index 00000000..d4779c62 --- /dev/null +++ b/illumos-x86_64/usr/include/nan.h @@ -0,0 +1,136 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1996, by Sun Microsystems, Inc. + * All Rights Reserved + */ + +#ifndef _NAN_H +#define _NAN_H + +/* + * Handling of Not_a_Number's (only in IEEE floating-point standard) + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_IEEE_754) +/* + * Structure order is endian dependent. Only the common variants of + * big and little endian are supported. + */ + +#if defined(_BIG_ENDIAN) + +typedef union +{ + struct + { + unsigned sign : 1; + unsigned exponent :11; + unsigned bits :20; + unsigned fraction_low :32; + } inf_parts; + struct + { + unsigned sign : 1; + unsigned exponent :11; + unsigned qnan_bit : 1; + unsigned bits :19; + unsigned fraction_low :32; + } nan_parts; + double d; + +} dnan; + +#else /* Must be _LITTLE_ENDIAN */ + +typedef union +{ + struct { + unsigned fraction_low :32; + unsigned bits :20; + unsigned exponent :11; + unsigned sign : 1; + } inf_parts; + struct { + unsigned fraction_low :32; + unsigned bits :19; + unsigned qnan_bit : 1; + unsigned exponent :11; + unsigned sign : 1; + } nan_parts; + double d; +} dnan; + +#endif /* Endian based selection */ + +/* + * IsNANorINF checks that exponent of double == 2047 + * i.e. that number is a NaN or an infinity + */ +#define IsNANorINF(X) (((dnan *)&(X))->nan_parts.exponent == 0x7ff) + +/* + * IsINF must be used after IsNANorINF has checked the exponent + */ +#define IsINF(X) (((dnan *)&(X))->inf_parts.bits == 0 && \ + ((dnan *)&(X))->inf_parts.fraction_low == 0) + +/* + * IsPosNAN and IsNegNAN can be used to check the sign of infinities too + */ +#define IsPosNAN(X) (((dnan *)&(X))->nan_parts.sign == 0) + +#define IsNegNAN(X) (((dnan *)&(X))->nan_parts.sign == 1) + +/* + * GETNaNPC gets the leftmost 32 bits of the fraction part + */ +#define GETNaNPC(dval) (((dnan *)&(dval))->inf_parts.bits << 12 | \ + ((dnan *)&(dval))->nan_parts.fraction_low >> 20) + +#define KILLFPE() (void) _kill(_getpid(), 8) +#define NaN(X) (((dnan *)&(X))->nan_parts.exponent == 0x7ff) +#define KILLNaN(X) if (NaN(X)) KILLFPE() + +#else /* defined(_IEEE_754) */ +/* #error is strictly ansi-C, but works as well as anything for K&R systems. */ +#error ISA not supported +#endif /* defined(_IEEE_754) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NAN_H */ diff --git a/illumos-x86_64/usr/include/ncurses/curses.h b/illumos-x86_64/usr/include/ncurses/curses.h new file mode 100644 index 00000000..89e8a5ae --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/curses.h @@ -0,0 +1,2143 @@ +/**************************************************************************** + * Copyright 2018-2023,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* $Id: curses.h.in,v 1.282 2024/01/19 11:50:07 tom Exp $ */ + +#ifndef __NCURSES_H +#define __NCURSES_H + +/* + The symbols beginning NCURSES_ or USE_ are configuration choices. + A few of the former can be overridden by applications at compile-time. + Most of the others correspond to configure-script options (or checks + by the configure-script for features of the system on which it is built). + + These symbols can be overridden by applications at compile-time: + NCURSES_NOMACROS suppresses macro definitions in favor of functions + NCURSES_WATTR_MACROS suppresses wattr_* macro definitions + NCURSES_WIDECHAR is an alternative for declaring wide-character functions. + + These symbols are used only when building ncurses: + NCURSES_ATTR_T + NCURSES_FIELD_INTERNALS + NCURSES_INTERNALS + + These symbols are set by the configure script: + NCURSES_ENABLE_STDBOOL_H + NCURSES_EXPANDED + NCURSES_EXT_COLORS + NCURSES_EXT_FUNCS + NCURSES_EXT_PUTWIN + NCURSES_NO_PADDING + NCURSES_OSPEED_COMPAT + NCURSES_PATHSEP + NCURSES_REENTRANT + NCURSES_SIGWINCH + */ + +#define CURSES 1 +#define CURSES_H 1 + +/* These are defined only in curses.h, and are used for conditional compiles */ +#define NCURSES_VERSION_MAJOR 6 +#define NCURSES_VERSION_MINOR 5 +#define NCURSES_VERSION_PATCH 20240511 + +/* This is defined in more than one ncurses header, for identification */ +#undef NCURSES_VERSION +#define NCURSES_VERSION "6.5" + +/* + * Identify the mouse encoding version. + */ +#define NCURSES_MOUSE_VERSION 2 + +/* + * Definitions to facilitate DLL's. + */ +#include + +/* + * Extra headers. + */ +#if 1 +#include +#endif + +#ifdef __cplusplus +#else +#if 0 +#include +#undef GCC_NORETURN +#define GCC_NORETURN _Noreturn +#endif +#endif + +/* + * User-definable tweak to disable the include of . + */ +#ifndef NCURSES_ENABLE_STDBOOL_H +#define NCURSES_ENABLE_STDBOOL_H 1 +#endif + +/* + * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses + * configured using --disable-macros. + */ +#ifndef NCURSES_ATTR_T +#define NCURSES_ATTR_T int +#endif + +/* + * Expands to 'const' if ncurses is configured using --enable-const. Note that + * doing so makes it incompatible with other implementations of X/Open Curses. + */ +#undef NCURSES_CONST +#define NCURSES_CONST const + +#undef NCURSES_INLINE +#define NCURSES_INLINE inline + +/* + * The standard type used for color values, and for color-pairs. The latter + * allows the curses library to enumerate the combinations of foreground and + * background colors used by an application, and is normally the product of the + * total foreground and background colors. + * + * X/Open uses "short" for both of these types, ultimately because they are + * numbers from the SVr4 terminal database, which uses 16-bit signed values. + */ +#undef NCURSES_COLOR_T +#define NCURSES_COLOR_T short + +#undef NCURSES_PAIRS_T +#define NCURSES_PAIRS_T short + +/* + * Definitions used to make WINDOW and similar structs opaque. + */ +#ifndef NCURSES_INTERNALS +#define NCURSES_OPAQUE 1 +#define NCURSES_OPAQUE_FORM 1 +#define NCURSES_OPAQUE_MENU 1 +#define NCURSES_OPAQUE_PANEL 1 +#endif + +/* + * Definition used to optionally suppress wattr* macros to help with the + * transition from ncurses5 to ncurses6 by allowing the header files to + * be shared across development packages for ncursesw in both ABIs. + */ +#ifndef NCURSES_WATTR_MACROS +#define NCURSES_WATTR_MACROS 0 +#endif + +/* + * The reentrant code relies on the opaque setting, but adds features. + */ +#ifndef NCURSES_REENTRANT +#define NCURSES_REENTRANT 0 +#endif + +/* + * KEY_RESIZE is an extended feature that relies upon the SIGWINCH handler + * in ncurses. + */ +#if 1 +#ifndef NCURSES_SIGWINCH +#define NCURSES_SIGWINCH 1 +#endif +#else +#undef NCURSES_SIGWINCH +#define NCURSES_SIGWINCH 0 +#endif + +/* + * In certain environments, we must work around linker problems for data + */ +#undef NCURSES_BROKEN_LINKER +#if 0 +#define NCURSES_BROKEN_LINKER 1 +#endif + +/* + * Control whether bindings for interop support are added. + */ +#undef NCURSES_INTEROP_FUNCS +#define NCURSES_INTEROP_FUNCS 1 + +/* + * The internal type used for window dimensions. + */ +#undef NCURSES_SIZE_T +#define NCURSES_SIZE_T short + +/* + * Control whether tparm() supports varargs or fixed-parameter list. + */ +#undef NCURSES_TPARM_VARARGS +#define NCURSES_TPARM_VARARGS 1 + +/* + * Control type used for tparm's arguments. While X/Open equates long and + * char* values, this is not always workable for 64-bit platforms. + */ +#undef NCURSES_TPARM_ARG +#define NCURSES_TPARM_ARG intptr_t + +/* + * Control whether ncurses uses wcwidth() for checking width of line-drawing + * characters. + */ +#undef NCURSES_WCWIDTH_GRAPHICS +#define NCURSES_WCWIDTH_GRAPHICS 1 + +/* + * NCURSES_CH_T is used in building the library, but not used otherwise in + * this header file, since that would make the normal/wide-character versions + * of the header incompatible. + */ +#undef NCURSES_CH_T +#define NCURSES_CH_T cchar_t + +#if 1 && defined(_LP64) +typedef unsigned chtype; +typedef unsigned mmask_t; +#else +typedef uint32_t chtype; +typedef uint32_t mmask_t; +#endif + +/* + * We need FILE, etc. Include this before checking any feature symbols. + */ +#include + +/* + * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or + * conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is + * not already defined, e.g., if the platform relies upon nonstandard feature + * test macros, define it at this point if the standard feature test macros + * indicate that it should be defined. + */ +#ifndef NCURSES_WIDECHAR +#if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) +#define NCURSES_WIDECHAR 1 +#else +#define NCURSES_WIDECHAR 0 +#endif +#endif /* NCURSES_WIDECHAR */ + +#include /* we need va_list */ +#if NCURSES_WIDECHAR +#include /* we want wchar_t */ +#endif + +/* X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also + * implement it. If so, we must use the C++ compiler's type to avoid conflict + * with other interfaces. + * + * A further complication is that may declare 'bool' to be a + * different type, such as an enum which is not necessarily compatible with + * C++. If we have , make 'bool' a macro, so users may #undef it. + * Otherwise, let it remain a typedef to avoid conflicts with other #define's. + * In either case, make a typedef for NCURSES_BOOL which can be used if needed + * from either C or C++. + */ + +#undef TRUE +#define TRUE 1 + +#undef FALSE +#define FALSE 0 + +typedef unsigned char NCURSES_BOOL; + +#if defined(__cplusplus) /* __cplusplus, etc. */ + +/* use the C++ compiler's bool type */ +#define NCURSES_BOOL bool + +#else /* c89, c99, etc. */ + +#if NCURSES_ENABLE_STDBOOL_H +#include +/* use whatever the C compiler decides bool really is */ +#define NCURSES_BOOL bool +#else +/* there is no predefined bool - use our own */ +#undef bool +#define bool NCURSES_BOOL +#endif + +#endif /* !__cplusplus, etc. */ + +#ifdef __cplusplus +extern "C" { +#define NCURSES_CAST(type,value) static_cast(value) +#else +#define NCURSES_CAST(type,value) (type)(value) +#endif + +#define NCURSES_OK_ADDR(p) (0 != NCURSES_CAST(const void *, (p))) + +/* + * X/Open attributes. In the ncurses implementation, they are identical to the + * A_ attributes. + */ +#define WA_ATTRIBUTES A_ATTRIBUTES +#define WA_NORMAL A_NORMAL +#define WA_STANDOUT A_STANDOUT +#define WA_UNDERLINE A_UNDERLINE +#define WA_REVERSE A_REVERSE +#define WA_BLINK A_BLINK +#define WA_DIM A_DIM +#define WA_BOLD A_BOLD +#define WA_ALTCHARSET A_ALTCHARSET +#define WA_INVIS A_INVIS +#define WA_PROTECT A_PROTECT +#define WA_HORIZONTAL A_HORIZONTAL +#define WA_LEFT A_LEFT +#define WA_LOW A_LOW +#define WA_RIGHT A_RIGHT +#define WA_TOP A_TOP +#define WA_VERTICAL A_VERTICAL + +#if 1 +#define WA_ITALIC A_ITALIC /* ncurses extension */ +#endif + +/* colors */ +#define COLOR_BLACK 0 +#define COLOR_RED 1 +#define COLOR_GREEN 2 +#define COLOR_YELLOW 3 +#define COLOR_BLUE 4 +#define COLOR_MAGENTA 5 +#define COLOR_CYAN 6 +#define COLOR_WHITE 7 + +/* line graphics */ + +#if 0 || NCURSES_REENTRANT +NCURSES_WRAPPED_VAR(chtype*, acs_map); +#define acs_map NCURSES_PUBLIC_VAR(acs_map()) +#else +extern NCURSES_EXPORT_VAR(chtype) acs_map[]; +#endif + +#define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,(c))]) + +/* VT100 symbols begin here */ +#define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */ +#define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */ +#define ACS_URCORNER NCURSES_ACS('k') /* upper right corner */ +#define ACS_LRCORNER NCURSES_ACS('j') /* lower right corner */ +#define ACS_LTEE NCURSES_ACS('t') /* tee pointing right */ +#define ACS_RTEE NCURSES_ACS('u') /* tee pointing left */ +#define ACS_BTEE NCURSES_ACS('v') /* tee pointing up */ +#define ACS_TTEE NCURSES_ACS('w') /* tee pointing down */ +#define ACS_HLINE NCURSES_ACS('q') /* horizontal line */ +#define ACS_VLINE NCURSES_ACS('x') /* vertical line */ +#define ACS_PLUS NCURSES_ACS('n') /* large plus or crossover */ +#define ACS_S1 NCURSES_ACS('o') /* scan line 1 */ +#define ACS_S9 NCURSES_ACS('s') /* scan line 9 */ +#define ACS_DIAMOND NCURSES_ACS('`') /* diamond */ +#define ACS_CKBOARD NCURSES_ACS('a') /* checker board (stipple) */ +#define ACS_DEGREE NCURSES_ACS('f') /* degree symbol */ +#define ACS_PLMINUS NCURSES_ACS('g') /* plus/minus */ +#define ACS_BULLET NCURSES_ACS('~') /* bullet */ +/* Teletype 5410v1 symbols begin here */ +#define ACS_LARROW NCURSES_ACS(',') /* arrow pointing left */ +#define ACS_RARROW NCURSES_ACS('+') /* arrow pointing right */ +#define ACS_DARROW NCURSES_ACS('.') /* arrow pointing down */ +#define ACS_UARROW NCURSES_ACS('-') /* arrow pointing up */ +#define ACS_BOARD NCURSES_ACS('h') /* board of squares */ +#define ACS_LANTERN NCURSES_ACS('i') /* lantern symbol */ +#define ACS_BLOCK NCURSES_ACS('0') /* solid square block */ +/* + * These aren't documented, but a lot of System Vs have them anyway + * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings). + * The ACS_names may not match AT&T's, our source didn't know them. + */ +#define ACS_S3 NCURSES_ACS('p') /* scan line 3 */ +#define ACS_S7 NCURSES_ACS('r') /* scan line 7 */ +#define ACS_LEQUAL NCURSES_ACS('y') /* less/equal */ +#define ACS_GEQUAL NCURSES_ACS('z') /* greater/equal */ +#define ACS_PI NCURSES_ACS('{') /* Pi */ +#define ACS_NEQUAL NCURSES_ACS('|') /* not equal */ +#define ACS_STERLING NCURSES_ACS('}') /* UK pound sign */ + +/* + * Line drawing ACS names are of the form ACS_trbl, where t is the top, r + * is the right, b is the bottom, and l is the left. t, r, b, and l might + * be B (blank), S (single), D (double), or T (thick). The subset defined + * here only uses B and S. + */ +#define ACS_BSSB ACS_ULCORNER +#define ACS_SSBB ACS_LLCORNER +#define ACS_BBSS ACS_URCORNER +#define ACS_SBBS ACS_LRCORNER +#define ACS_SBSS ACS_RTEE +#define ACS_SSSB ACS_LTEE +#define ACS_SSBS ACS_BTEE +#define ACS_BSSS ACS_TTEE +#define ACS_BSBS ACS_HLINE +#define ACS_SBSB ACS_VLINE +#define ACS_SSSS ACS_PLUS + +#undef ERR +#define ERR (-1) + +#undef OK +#define OK (0) + +/* values for the _flags member */ +#define _SUBWIN 0x01 /* is this a sub-window? */ +#define _ENDLINE 0x02 /* is the window flush right? */ +#define _FULLWIN 0x04 /* is the window full-screen? */ +#define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */ +#define _ISPAD 0x10 /* is this window a pad? */ +#define _HASMOVED 0x20 /* has cursor moved since last refresh? */ +#define _WRAPPED 0x40 /* cursor was just wrappped */ + +/* + * this value is used in the firstchar and lastchar fields to mark + * unchanged lines + */ +#define _NOCHANGE -1 + +/* + * this value is used in the oldindex field to mark lines created by insertions + * and scrolls. + */ +#define _NEWINDEX -1 + +#ifdef NCURSES_INTERNALS +#undef SCREEN +#define SCREEN struct screen +SCREEN; +#else +typedef struct screen SCREEN; +#endif + +typedef struct _win_st WINDOW; + +typedef chtype attr_t; /* ...must be at least as wide as chtype */ + +#if NCURSES_WIDECHAR + +#if 0 +#ifdef mblen /* libutf8.h defines it w/o undefining first */ +#undef mblen +#endif +#include +#endif + +#if 1 +#include /* ...to get mbstate_t, etc. */ +#endif + +#if 0 +typedef unsigned short wchar_t1; +#endif + +#if 0 +typedef unsigned int wint_t1; +#endif + +/* + * cchar_t stores an array of CCHARW_MAX wide characters. The first is + * normally a spacing character. The others are non-spacing. If those + * (spacing and nonspacing) do not fill the array, a null L'\0' follows. + * Otherwise, a null is assumed to follow when extracting via getcchar(). + */ +#define CCHARW_MAX 5 +typedef struct +{ + attr_t attr; + wchar_t chars[CCHARW_MAX]; +#if 1 +#undef NCURSES_EXT_COLORS +#define NCURSES_EXT_COLORS 20240511 + int ext_color; /* color pair, must be more than 16-bits */ +#endif +} +cchar_t; + +#endif /* NCURSES_WIDECHAR */ + +#if !NCURSES_OPAQUE +struct ldat; + +struct _win_st +{ + NCURSES_SIZE_T _cury, _curx; /* current cursor position */ + + /* window location and size */ + NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */ + NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */ + + short _flags; /* window state flags */ + + /* attribute tracking */ + attr_t _attrs; /* current attribute for non-space character */ + chtype _bkgd; /* current background char/attribute pair */ + + /* option values set by user */ + bool _notimeout; /* no time out on function-key entry? */ + bool _clear; /* consider all data in the window invalid? */ + bool _leaveok; /* OK to not reset cursor on exit? */ + bool _scroll; /* OK to scroll this window? */ + bool _idlok; /* OK to use insert/delete line? */ + bool _idcok; /* OK to use insert/delete char? */ + bool _immed; /* window in immed mode? (not yet used) */ + bool _sync; /* window in sync mode? */ + bool _use_keypad; /* process function keys into KEY_ symbols? */ + int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */ + + struct ldat *_line; /* the actual line data */ + + /* global screen state */ + NCURSES_SIZE_T _regtop; /* top line of scrolling region */ + NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */ + + /* these are used only if this is a sub-window */ + int _parx; /* x coordinate of this window in parent */ + int _pary; /* y coordinate of this window in parent */ + WINDOW *_parent; /* pointer to parent if a sub-window */ + + /* these are used only if this is a pad */ + struct pdat + { + NCURSES_SIZE_T _pad_y, _pad_x; + NCURSES_SIZE_T _pad_top, _pad_left; + NCURSES_SIZE_T _pad_bottom, _pad_right; + } _pad; + + NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */ + +#if NCURSES_WIDECHAR + cchar_t _bkgrnd; /* current background char/attribute pair */ +#if 1 + int _color; /* current color-pair for non-space character */ +#endif +#endif +}; +#endif /* NCURSES_OPAQUE */ + +/* + * GCC (and some other compilers) define '__attribute__'; we're using this + * macro to alert the compiler to flag inconsistencies in printf/scanf-like + * function calls. Just in case '__attribute__' isn't defined, make a dummy. + * Old versions of G++ do not accept it anyway, at least not consistently with + * GCC. + */ +#if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__)) +#define __attribute__(p) /* nothing */ +#endif + +/* + * We cannot define these in ncurses_cfg.h, since they require parameters to be + * passed (that is non-portable). + */ +#ifndef GCC_PRINTFLIKE +#ifndef printf +#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) +#else +#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +#endif +#endif + +#ifndef GCC_SCANFLIKE +#ifndef scanf +#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) +#else +#define GCC_SCANFLIKE(fmt,var) /*nothing*/ +#endif +#endif + +#ifndef GCC_NORETURN +#define GCC_NORETURN /* nothing */ +#endif + +#ifndef GCC_UNUSED +#define GCC_UNUSED /* nothing */ +#endif + +#undef GCC_DEPRECATED +#if (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)) && !defined(NCURSES_INTERNALS) +#define GCC_DEPRECATED(msg) __attribute__((deprecated)) +#else +#define GCC_DEPRECATED(msg) /* nothing */ +#endif + +/* + * Curses uses a helper function. Define our type for this to simplify + * extending it for the sp-funcs feature. + */ +typedef int (*NCURSES_OUTC)(int); + +/* + * Function prototypes. This is the complete X/Open Curses list of required + * functions. Those marked `generated' will have sources generated from the + * macro definitions later in this file, in order to satisfy XPG4.2 + * requirements. + */ + +extern NCURSES_EXPORT(int) addch (const chtype); /* generated */ +extern NCURSES_EXPORT(int) addchnstr (const chtype *, int); /* generated */ +extern NCURSES_EXPORT(int) addchstr (const chtype *); /* generated */ +extern NCURSES_EXPORT(int) addnstr (const char *, int); /* generated */ +extern NCURSES_EXPORT(int) addstr (const char *); /* generated */ +extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T); /* generated */ +extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T); /* generated */ +extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T); /* generated */ +extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ +extern NCURSES_EXPORT(int) attr_off (attr_t, void *); /* generated */ +extern NCURSES_EXPORT(int) attr_on (attr_t, void *); /* generated */ +extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *); /* generated */ +extern NCURSES_EXPORT(int) baudrate (void); /* implemented */ +extern NCURSES_EXPORT(int) beep (void); /* implemented */ +extern NCURSES_EXPORT(int) bkgd (chtype); /* generated */ +extern NCURSES_EXPORT(void) bkgdset (chtype); /* generated */ +extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */ +extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */ +extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */ +extern NCURSES_EXPORT(int) cbreak (void); /* implemented */ +extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ +extern NCURSES_EXPORT(int) clear (void); /* generated */ +extern NCURSES_EXPORT(int) clearok (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) clrtobot (void); /* generated */ +extern NCURSES_EXPORT(int) clrtoeol (void); /* generated */ +extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ +extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*); /* generated */ +extern NCURSES_EXPORT(int) COLOR_PAIR (int); /* generated */ +extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) curs_set (int); /* implemented */ +extern NCURSES_EXPORT(int) def_prog_mode (void); /* implemented */ +extern NCURSES_EXPORT(int) def_shell_mode (void); /* implemented */ +extern NCURSES_EXPORT(int) delay_output (int); /* implemented */ +extern NCURSES_EXPORT(int) delch (void); /* generated */ +extern NCURSES_EXPORT(void) delscreen (SCREEN *); /* implemented */ +extern NCURSES_EXPORT(int) delwin (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) deleteln (void); /* generated */ +extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) doupdate (void); /* implemented */ +extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) echo (void); /* implemented */ +extern NCURSES_EXPORT(int) echochar (const chtype); /* generated */ +extern NCURSES_EXPORT(int) erase (void); /* generated */ +extern NCURSES_EXPORT(int) endwin (void); /* implemented */ +extern NCURSES_EXPORT(char) erasechar (void); /* implemented */ +extern NCURSES_EXPORT(void) filter (void); /* implemented */ +extern NCURSES_EXPORT(int) flash (void); /* implemented */ +extern NCURSES_EXPORT(int) flushinp (void); /* implemented */ +extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getch (void); /* generated */ +extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */ +extern NCURSES_EXPORT(int) getstr (char *); /* generated */ +extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */ +extern NCURSES_EXPORT(int) halfdelay (int); /* implemented */ +extern NCURSES_EXPORT(bool) has_colors (void); /* implemented */ +extern NCURSES_EXPORT(bool) has_ic (void); /* implemented */ +extern NCURSES_EXPORT(bool) has_il (void); /* implemented */ +extern NCURSES_EXPORT(int) hline (chtype, int); /* generated */ +extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */ +extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */ +extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */ +extern NCURSES_EXPORT(chtype) inch (void); /* generated */ +extern NCURSES_EXPORT(int) inchnstr (chtype *, int); /* generated */ +extern NCURSES_EXPORT(int) inchstr (chtype *); /* generated */ +extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */ +extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ +extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ +extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */ +extern NCURSES_EXPORT(int) insch (chtype); /* generated */ +extern NCURSES_EXPORT(int) insdelln (int); /* generated */ +extern NCURSES_EXPORT(int) insertln (void); /* generated */ +extern NCURSES_EXPORT(int) insnstr (const char *, int); /* generated */ +extern NCURSES_EXPORT(int) insstr (const char *); /* generated */ +extern NCURSES_EXPORT(int) instr (char *); /* generated */ +extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */ +extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int); /* implemented */ +extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int); /* implemented */ +extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(char) killchar (void); /* implemented */ +extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(char *) longname (void); /* implemented */ +extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) move (int, int); /* generated */ +extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype); /* generated */ +extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* generated */ +extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *); /* generated */ +extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int); /* generated */ +extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *); /* generated */ +extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ +extern NCURSES_EXPORT(int) mvcur (int,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) mvdelch (int, int); /* generated */ +extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int); /* implemented */ +extern NCURSES_EXPORT(int) mvgetch (int, int); /* generated */ +extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int); /* generated */ +extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */ +extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */ +extern NCURSES_EXPORT(chtype) mvinch (int, int); /* generated */ +extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int); /* generated */ +extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *); /* generated */ +extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int); /* generated */ +extern NCURSES_EXPORT(int) mvinsch (int, int, chtype); /* generated */ +extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int); /* generated */ +extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *); /* generated */ +extern NCURSES_EXPORT(int) mvinstr (int, int, char *); /* generated */ +extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */ + GCC_PRINTFLIKE(3,4); +extern NCURSES_EXPORT(int) mvscanw (int,int, const char *,...) /* implemented */ + GCC_SCANFLIKE(3,4); +extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */ +extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype); /* generated */ +extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */ +extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *); /* generated */ +extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int); /* generated */ +extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *); /* generated */ +extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */ +extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int); /* generated */ +extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int); /* generated */ +extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int); /* generated */ +extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */ +extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */ +extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int); /* implemented */ +extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int); /* generated */ +extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int); /* generated */ +extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *); /* generated */ +extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int); /* generated */ +extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype); /* generated */ +extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int); /* generated */ +extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *); /* generated */ +extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *); /* generated */ +extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */ + GCC_PRINTFLIKE(4,5); +extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, const char *,...) /* implemented */ + GCC_SCANFLIKE(4,5); +extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */ +extern NCURSES_EXPORT(int) napms (int); /* implemented */ +extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */ +extern NCURSES_EXPORT(SCREEN *) newterm (const char *,FILE *,FILE *); /* implemented */ +extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) nl (void); /* implemented */ +extern NCURSES_EXPORT(int) nocbreak (void); /* implemented */ +extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) noecho (void); /* implemented */ +extern NCURSES_EXPORT(int) nonl (void); /* implemented */ +extern NCURSES_EXPORT(void) noqiflush (void); /* implemented */ +extern NCURSES_EXPORT(int) noraw (void); /* implemented */ +extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ +extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */ +extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */ +extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */ +extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) printw (const char *,...) /* implemented */ + GCC_PRINTFLIKE(1,2); +extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */ +extern NCURSES_EXPORT(void) qiflush (void); /* implemented */ +extern NCURSES_EXPORT(int) raw (void); /* implemented */ +extern NCURSES_EXPORT(int) redrawwin (WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) refresh (void); /* generated */ +extern NCURSES_EXPORT(int) resetty (void); /* implemented */ +extern NCURSES_EXPORT(int) reset_prog_mode (void); /* implemented */ +extern NCURSES_EXPORT(int) reset_shell_mode (void); /* implemented */ +extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int)); /* implemented */ +extern NCURSES_EXPORT(int) savetty (void); /* implemented */ +extern NCURSES_EXPORT(int) scanw (const char *,...) /* implemented */ + GCC_SCANFLIKE(1,2); +extern NCURSES_EXPORT(int) scr_dump (const char *); /* implemented */ +extern NCURSES_EXPORT(int) scr_init (const char *); /* implemented */ +extern NCURSES_EXPORT(int) scrl (int); /* generated */ +extern NCURSES_EXPORT(int) scroll (WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) scr_restore (const char *); /* implemented */ +extern NCURSES_EXPORT(int) scr_set (const char *); /* implemented */ +extern NCURSES_EXPORT(int) setscrreg (int,int); /* generated */ +extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *); /* implemented */ +extern NCURSES_EXPORT(int) slk_attroff (const chtype); /* implemented */ +extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) slk_attron (const chtype); /* implemented */ +extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) slk_attrset (const chtype); /* implemented */ +extern NCURSES_EXPORT(attr_t) slk_attr (void); /* implemented */ +extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*); /* implemented */ +extern NCURSES_EXPORT(int) slk_clear (void); /* implemented */ +extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T); /* implemented */ +extern NCURSES_EXPORT(int) slk_init (int); /* implemented */ +extern NCURSES_EXPORT(char *) slk_label (int); /* implemented */ +extern NCURSES_EXPORT(int) slk_noutrefresh (void); /* implemented */ +extern NCURSES_EXPORT(int) slk_refresh (void); /* implemented */ +extern NCURSES_EXPORT(int) slk_restore (void); /* implemented */ +extern NCURSES_EXPORT(int) slk_set (int,const char *,int); /* implemented */ +extern NCURSES_EXPORT(int) slk_touch (void); /* implemented */ +extern NCURSES_EXPORT(int) standout (void); /* generated */ +extern NCURSES_EXPORT(int) standend (void); /* generated */ +extern NCURSES_EXPORT(int) start_color (void); /* implemented */ +extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int); /* implemented */ +extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int); /* implemented */ +extern NCURSES_EXPORT(int) syncok (WINDOW *, bool); /* implemented */ +extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */ +extern NCURSES_EXPORT(char *) termname (void); /* implemented */ +extern NCURSES_EXPORT(void) timeout (int); /* generated */ +extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int); /* generated */ +extern NCURSES_EXPORT(int) touchwin (WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) typeahead (int); /* implemented */ +extern NCURSES_EXPORT(int) ungetch (int); /* implemented */ +extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */ +extern NCURSES_EXPORT(void) use_env (bool); /* implemented */ +extern NCURSES_EXPORT(void) use_tioctl (bool); /* implemented */ +extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */ +extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */ +extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */ +extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *, va_list) GCC_DEPRECATED(use vw_printw) /* implemented */ + GCC_PRINTFLIKE(2,0); +extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *, va_list) /* implemented */ + GCC_PRINTFLIKE(2,0); +extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *, va_list) GCC_DEPRECATED(use vw_scanw) /* implemented */ + GCC_SCANFLIKE(2,0); +extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *, va_list) /* implemented */ + GCC_SCANFLIKE(2,0); +extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* implemented */ +extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int); /* implemented */ +extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *); /* generated */ +extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */ +extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */ +extern NCURSES_EXPORT(int) wattron (WINDOW *, int); /* generated */ +extern NCURSES_EXPORT(int) wattroff (WINDOW *, int); /* generated */ +extern NCURSES_EXPORT(int) wattrset (WINDOW *, int); /* generated */ +extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ +extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *); /* implemented */ +extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *); /* implemented */ +extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *); /* generated */ +extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */ +extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */ +extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */ +extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */ +extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*); /* implemented */ +extern NCURSES_EXPORT(void) wcursyncup (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wdelch (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wdeleteln (WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype); /* implemented */ +extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */ +extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */ +extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */ +extern NCURSES_EXPORT(chtype) winch (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int); /* implemented */ +extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *); /* generated */ +extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int); /* implemented */ +extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype); /* implemented */ +extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int); /* implemented */ +extern NCURSES_EXPORT(int) winsertln (WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int); /* implemented */ +extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *); /* generated */ +extern NCURSES_EXPORT(int) winstr (WINDOW *, char *); /* generated */ +extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */ +extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...) /* implemented */ + GCC_PRINTFLIKE(2,3); +extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int); /* implemented */ +extern NCURSES_EXPORT(int) wrefresh (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wscanw (WINDOW *, const char *,...) /* implemented */ + GCC_SCANFLIKE(2,3); +extern NCURSES_EXPORT(int) wscrl (WINDOW *,int); /* implemented */ +extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int); /* implemented */ +extern NCURSES_EXPORT(int) wstandout (WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) wstandend (WINDOW *); /* generated */ +extern NCURSES_EXPORT(void) wsyncdown (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(void) wsyncup (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int); /* implemented */ +extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */ + +/* + * These are also declared in : + */ +extern NCURSES_EXPORT(int) tigetflag (const char *); /* implemented */ +extern NCURSES_EXPORT(int) tigetnum (const char *); /* implemented */ +extern NCURSES_EXPORT(char *) tigetstr (const char *); /* implemented */ +extern NCURSES_EXPORT(int) putp (const char *); /* implemented */ + +#if NCURSES_TPARM_VARARGS +extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ +#else +extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG); /* special */ +#endif + +extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ +extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...); /* special */ +extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *); /* special */ + +/* + * These functions are not in X/Open, but we use them in macro definitions: + */ +extern NCURSES_EXPORT(int) getattrs (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getcurx (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getcury (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getbegx (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getbegy (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getmaxx (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getmaxy (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getparx (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) getpary (const WINDOW *); /* generated */ + +/* + * vid_attr() was implemented originally based on a draft of X/Open curses. + */ +#if !NCURSES_WIDECHAR +#define vid_attr(a,pair,opts) vidattr(a) +#endif + +/* + * These functions are extensions - not in X/Open Curses. + */ +#if 1 +#undef NCURSES_EXT_FUNCS +#define NCURSES_EXT_FUNCS 20240511 +typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *); +typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *); +extern NCURSES_EXPORT(int) alloc_pair (int, int); +extern NCURSES_EXPORT(int) assume_default_colors (int, int); +extern NCURSES_EXPORT(const char *) curses_version (void); +extern NCURSES_EXPORT(int) define_key (const char *, int); +extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *); +extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *); +extern NCURSES_EXPORT(int) extended_slk_color(int); +extern NCURSES_EXPORT(int) find_pair (int, int); +extern NCURSES_EXPORT(int) free_pair (int); +extern NCURSES_EXPORT(int) get_escdelay (void); +extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int); +extern NCURSES_EXPORT(int) init_extended_pair(int, int, int); +extern NCURSES_EXPORT(int) is_cbreak(void); +extern NCURSES_EXPORT(int) is_echo(void); +extern NCURSES_EXPORT(int) is_nl(void); +extern NCURSES_EXPORT(int) is_raw(void); +extern NCURSES_EXPORT(bool) is_term_resized (int, int); +extern NCURSES_EXPORT(int) key_defined (const char *); +extern NCURSES_EXPORT(char *) keybound (int, int); +extern NCURSES_EXPORT(int) keyok (int, bool); +extern NCURSES_EXPORT(void) nofilter(void); +extern NCURSES_EXPORT(void) reset_color_pairs (void); +extern NCURSES_EXPORT(int) resize_term (int, int); +extern NCURSES_EXPORT(int) resizeterm (int, int); +extern NCURSES_EXPORT(int) set_escdelay (int); +extern NCURSES_EXPORT(int) set_tabsize (int); +extern NCURSES_EXPORT(int) use_default_colors (void); +extern NCURSES_EXPORT(int) use_legacy_coding (int); +extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *); +extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *); +extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int); + +#if 1 +#undef NCURSES_XNAMES +#define NCURSES_XNAMES 1 +extern NCURSES_EXPORT(int) use_extended_names (bool); +#endif + +/* + * These extensions provide access to information stored in the WINDOW even + * when NCURSES_OPAQUE is set: + */ +extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_pad (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */ + +#else +#define curses_version() NCURSES_VERSION +#endif + +/* + * Extra extension-functions, which pass a SCREEN pointer rather than using + * a global variable SP. + */ +#if 1 +#undef NCURSES_SP_FUNCS +#define NCURSES_SP_FUNCS 20240511 +#define NCURSES_SP_NAME(name) name##_sp + +/* Define the sp-funcs helper function */ +#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) +typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); + +extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */ + +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, const char *, FILE *, FILE *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ +#if 1 +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_cbreak) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_echo) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_nl) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_raw) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */ /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +#endif +#else +#undef NCURSES_SP_FUNCS +#define NCURSES_SP_FUNCS 0 +#define NCURSES_SP_NAME(name) name +#define NCURSES_SP_OUTC NCURSES_OUTC +#endif + +/* attributes */ + +#define NCURSES_ATTR_SHIFT 8 +#define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT)) + +#define A_NORMAL (1U - 1U) +#define A_ATTRIBUTES NCURSES_BITS(~(1U - 1U),0) +#define A_CHARTEXT (NCURSES_BITS(1U,0) - 1U) +#define A_COLOR NCURSES_BITS(((1U) << 8) - 1U,0) +#define A_STANDOUT NCURSES_BITS(1U,8) +#define A_UNDERLINE NCURSES_BITS(1U,9) +#define A_REVERSE NCURSES_BITS(1U,10) +#define A_BLINK NCURSES_BITS(1U,11) +#define A_DIM NCURSES_BITS(1U,12) +#define A_BOLD NCURSES_BITS(1U,13) +#define A_ALTCHARSET NCURSES_BITS(1U,14) +#define A_INVIS NCURSES_BITS(1U,15) +#define A_PROTECT NCURSES_BITS(1U,16) +#define A_HORIZONTAL NCURSES_BITS(1U,17) +#define A_LEFT NCURSES_BITS(1U,18) +#define A_LOW NCURSES_BITS(1U,19) +#define A_RIGHT NCURSES_BITS(1U,20) +#define A_TOP NCURSES_BITS(1U,21) +#define A_VERTICAL NCURSES_BITS(1U,22) + +#if 1 +#define A_ITALIC NCURSES_BITS(1U,23) /* ncurses extension */ +#endif + +/* + * Most of the pseudo functions are macros that either provide compatibility + * with older versions of curses, or provide inline functionality to improve + * performance. + */ + +/* + * These pseudo functions are always implemented as macros: + */ + +#define getyx(win,y,x) (y = getcury(win), x = getcurx(win)) +#define getbegyx(win,y,x) (y = getbegy(win), x = getbegx(win)) +#define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win)) +#define getparyx(win,y,x) (y = getpary(win), x = getparx(win)) + +#define getsyx(y,x) do { if (newscr) { \ + if (is_leaveok(newscr)) \ + (y) = (x) = -1; \ + else \ + getyx(newscr,(y), (x)); \ + } \ + } while(0) + +#define setsyx(y,x) do { if (newscr) { \ + if ((y) == -1 && (x) == -1) \ + leaveok(newscr, TRUE); \ + else { \ + leaveok(newscr, FALSE); \ + wmove(newscr, (y), (x)); \ + } \ + } \ + } while(0) + +#ifndef NCURSES_NOMACROS + +/* + * These miscellaneous pseudo functions are provided for compatibility: + */ + +#define wgetstr(w, s) wgetnstr(w, s, -1) +#define getnstr(s, n) wgetnstr(stdscr, s, (n)) + +#define setterm(term) setupterm(term, 1, (int *)0) + +#define fixterm() reset_prog_mode() +#define resetterm() reset_shell_mode() +#define saveterm() def_prog_mode() +#define crmode() cbreak() +#define nocrmode() nocbreak() +#define gettmode() + +/* It seems older SYSV curses versions define these */ +#if !NCURSES_OPAQUE +#define getattrs(win) NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL) +#define getcurx(win) (NCURSES_OK_ADDR(win) ? (win)->_curx : ERR) +#define getcury(win) (NCURSES_OK_ADDR(win) ? (win)->_cury : ERR) +#define getbegx(win) (NCURSES_OK_ADDR(win) ? (win)->_begx : ERR) +#define getbegy(win) (NCURSES_OK_ADDR(win) ? (win)->_begy : ERR) +#define getmaxx(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR) +#define getmaxy(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR) +#define getparx(win) (NCURSES_OK_ADDR(win) ? (win)->_parx : ERR) +#define getpary(win) (NCURSES_OK_ADDR(win) ? (win)->_pary : ERR) +#endif /* NCURSES_OPAQUE */ + +#define wstandout(win) (wattrset(win,A_STANDOUT)) +#define wstandend(win) (wattrset(win,A_NORMAL)) + +#define wattron(win,at) wattr_on(win, NCURSES_CAST(attr_t, at), NULL) +#define wattroff(win,at) wattr_off(win, NCURSES_CAST(attr_t, at), NULL) + +#if !NCURSES_OPAQUE +#if NCURSES_WATTR_MACROS +#if NCURSES_WIDECHAR && 1 +#define wattrset(win,at) \ + (NCURSES_OK_ADDR(win) \ + ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \ + (win)->_attrs = NCURSES_CAST(attr_t, at), \ + OK) \ + : ERR) +#else +#define wattrset(win,at) \ + (NCURSES_OK_ADDR(win) \ + ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \ + OK) \ + : ERR) +#endif +#endif /* NCURSES_WATTR_MACROS */ +#endif /* NCURSES_OPAQUE */ + +#define scroll(win) wscrl(win,1) + +#define touchwin(win) wtouchln((win), 0, getmaxy(win), 1) +#define touchline(win, s, c) wtouchln((win), s, c, 1) +#define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0) + +#define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0) +#define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br) +#define hline(ch, n) whline(stdscr, ch, (n)) +#define vline(ch, n) wvline(stdscr, ch, (n)) + +#define winstr(w, s) winnstr(w, s, -1) +#define winchstr(w, s) winchnstr(w, s, -1) +#define winsstr(w, s) winsnstr(w, s, -1) + +#if !NCURSES_OPAQUE +#define redrawwin(win) wredrawln(win, 0, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -1)) +#endif /* NCURSES_OPAQUE */ + +#define waddstr(win,str) waddnstr(win,str,-1) +#define waddchstr(win,str) waddchnstr(win,str,-1) + +/* + * These apply to the first 256 color pairs. + */ +#define COLOR_PAIR(n) (NCURSES_BITS((n), 0) & A_COLOR) +#define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT))) + +/* + * pseudo functions for standard screen + */ + +#define addch(ch) waddch(stdscr,(ch)) +#define addchnstr(str,n) waddchnstr(stdscr,(str),(n)) +#define addchstr(str) waddchstr(stdscr,(str)) +#define addnstr(str,n) waddnstr(stdscr,(str),(n)) +#define addstr(str) waddnstr(stdscr,(str),-1) +#define attr_get(ap,cp,o) wattr_get(stdscr,(ap),(cp),(o)) +#define attr_off(a,o) wattr_off(stdscr,(a),(o)) +#define attr_on(a,o) wattr_on(stdscr,(a),(o)) +#define attr_set(a,c,o) wattr_set(stdscr,(a),(c),(o)) +#define attroff(at) wattroff(stdscr,(at)) +#define attron(at) wattron(stdscr,(at)) +#define attrset(at) wattrset(stdscr,(at)) +#define bkgd(ch) wbkgd(stdscr,(ch)) +#define bkgdset(ch) wbkgdset(stdscr,(ch)) +#define chgat(n,a,c,o) wchgat(stdscr,(n),(a),(c),(o)) +#define clear() wclear(stdscr) +#define clrtobot() wclrtobot(stdscr) +#define clrtoeol() wclrtoeol(stdscr) +#define color_set(c,o) wcolor_set(stdscr,(c),(o)) +#define delch() wdelch(stdscr) +#define deleteln() winsdelln(stdscr,-1) +#define echochar(c) wechochar(stdscr,(c)) +#define erase() werase(stdscr) +#define getch() wgetch(stdscr) +#define getstr(str) wgetstr(stdscr,(str)) +#define inch() winch(stdscr) +#define inchnstr(s,n) winchnstr(stdscr,(s),(n)) +#define inchstr(s) winchstr(stdscr,(s)) +#define innstr(s,n) winnstr(stdscr,(s),(n)) +#define insch(c) winsch(stdscr,(c)) +#define insdelln(n) winsdelln(stdscr,(n)) +#define insertln() winsdelln(stdscr,1) +#define insnstr(s,n) winsnstr(stdscr,(s),(n)) +#define insstr(s) winsstr(stdscr,(s)) +#define instr(s) winstr(stdscr,(s)) +#define move(y,x) wmove(stdscr,(y),(x)) +#define refresh() wrefresh(stdscr) +#define scrl(n) wscrl(stdscr,(n)) +#define setscrreg(t,b) wsetscrreg(stdscr,(t),(b)) +#define standend() wstandend(stdscr) +#define standout() wstandout(stdscr) +#define timeout(delay) wtimeout(stdscr,(delay)) +#define wdeleteln(win) winsdelln(win,-1) +#define winsertln(win) winsdelln(win,1) + +/* + * mv functions + */ + +#define mvwaddch(win,y,x,ch) (wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch))) +#define mvwaddchnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n))) +#define mvwaddchstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1)) +#define mvwaddnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n))) +#define mvwaddstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1)) +#define mvwchgat(win,y,x,n,a,c,o) (wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o))) +#define mvwdelch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wdelch(win)) +#define mvwgetch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wgetch(win)) +#define mvwgetnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n))) +#define mvwgetstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str))) +#define mvwhline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n))) +#define mvwinch(win,y,x) (wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win)) +#define mvwinchnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n))) +#define mvwinchstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s))) +#define mvwinnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n))) +#define mvwinsch(win,y,x,c) (wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c))) +#define mvwinsnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n))) +#define mvwinsstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s))) +#define mvwinstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s))) +#define mvwvline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n))) + +#define mvaddch(y,x,ch) mvwaddch(stdscr,(y),(x),(ch)) +#define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,(y),(x),(str),(n)) +#define mvaddchstr(y,x,str) mvwaddchstr(stdscr,(y),(x),(str)) +#define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,(y),(x),(str),(n)) +#define mvaddstr(y,x,str) mvwaddstr(stdscr,(y),(x),(str)) +#define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,(y),(x),(n),(a),(c),(o)) +#define mvdelch(y,x) mvwdelch(stdscr,(y),(x)) +#define mvgetch(y,x) mvwgetch(stdscr,(y),(x)) +#define mvgetnstr(y,x,str,n) mvwgetnstr(stdscr,(y),(x),(str),(n)) +#define mvgetstr(y,x,str) mvwgetstr(stdscr,(y),(x),(str)) +#define mvhline(y,x,c,n) mvwhline(stdscr,(y),(x),(c),(n)) +#define mvinch(y,x) mvwinch(stdscr,(y),(x)) +#define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,(y),(x),(s),(n)) +#define mvinchstr(y,x,s) mvwinchstr(stdscr,(y),(x),(s)) +#define mvinnstr(y,x,s,n) mvwinnstr(stdscr,(y),(x),(s),(n)) +#define mvinsch(y,x,c) mvwinsch(stdscr,(y),(x),(c)) +#define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,(y),(x),(s),(n)) +#define mvinsstr(y,x,s) mvwinsstr(stdscr,(y),(x),(s)) +#define mvinstr(y,x,s) mvwinstr(stdscr,(y),(x),(s)) +#define mvvline(y,x,c,n) mvwvline(stdscr,(y),(x),(c),(n)) + +/* + * Some wide-character functions can be implemented without the extensions. + */ +#if !NCURSES_OPAQUE +#define getbkgd(win) (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0) +#endif /* NCURSES_OPAQUE */ + +#define slk_attr_off(a,v) ((v) ? ERR : slk_attroff(a)) +#define slk_attr_on(a,v) ((v) ? ERR : slk_attron(a)) + +#if !NCURSES_OPAQUE +#if NCURSES_WATTR_MACROS +#if NCURSES_WIDECHAR && 1 +#define wattr_set(win,a,p,opts) \ + (NCURSES_OK_ADDR(win) \ + ? ((void)((win)->_attrs = ((a) & ~A_COLOR), \ + (win)->_color = (opts) ? *(int *)(opts) : (p)), \ + OK) \ + : ERR) +#define wattr_get(win,a,p,opts) \ + (NCURSES_OK_ADDR(win) \ + ? ((void)(NCURSES_OK_ADDR(a) \ + ? (*(a) = (win)->_attrs) \ + : OK), \ + (void)(NCURSES_OK_ADDR(p) \ + ? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \ + : OK), \ + (void)(NCURSES_OK_ADDR(opts) \ + ? (*(int *)(opts) = (win)->_color) \ + : OK), \ + OK) \ + : ERR) +#else /* !(NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ +#define wattr_set(win,a,p,opts) \ + (NCURSES_OK_ADDR(win) \ + ? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \ + (attr_t)COLOR_PAIR(p))), \ + OK) \ + : ERR) +#define wattr_get(win,a,p,opts) \ + (NCURSES_OK_ADDR(win) \ + ? ((void)(NCURSES_OK_ADDR(a) \ + ? (*(a) = (win)->_attrs) \ + : OK), \ + (void)(NCURSES_OK_ADDR(p) \ + ? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \ + : OK), \ + OK) \ + : ERR) +#endif /* (NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ +#endif /* NCURSES_WATTR_MACROS */ +#endif /* NCURSES_OPAQUE */ + +/* + * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use + * varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to + * use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already + * use stdarg.h, so... + */ +/* define vw_printw vwprintw */ +/* define vw_scanw vwscanw */ + +/* + * Export fallback function for use in C++ binding. + */ +#if !1 +#define vsscanf(a,b,c) _nc_vsscanf(a,b,c) +NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list); +#endif + +/* + * These macros are extensions - not in X/Open Curses. + */ +#if 1 +#if !NCURSES_OPAQUE +#define is_cleared(win) (NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE) +#define is_idcok(win) (NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE) +#define is_idlok(win) (NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE) +#define is_immedok(win) (NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE) +#define is_keypad(win) (NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE) +#define is_leaveok(win) (NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE) +#define is_nodelay(win) (NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE) +#define is_notimeout(win) (NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE) +#define is_pad(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) +#define is_scrollok(win) (NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE) +#define is_subwin(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE) +#define is_syncok(win) (NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE) +#define wgetdelay(win) (NCURSES_OK_ADDR(win) ? (win)->_delay : 0) +#define wgetparent(win) (NCURSES_OK_ADDR(win) ? (win)->_parent : 0) +#define wgetscrreg(win,t,b) (NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR) +#endif +#endif + +/* + * X/Open says this returns a bool; SVr4 also checked for out-of-range line. + * The macro provides compatibility: + */ +#define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l))) + +#endif /* NCURSES_NOMACROS */ + +/* + * Public variables. + * + * Notes: + * a. ESCDELAY was an undocumented feature under AIX curses. + * It gives the ESC expire time in milliseconds. + * b. ttytype is needed for backward compatibility + */ +#if NCURSES_REENTRANT + +NCURSES_WRAPPED_VAR(WINDOW *, curscr); +NCURSES_WRAPPED_VAR(WINDOW *, newscr); +NCURSES_WRAPPED_VAR(WINDOW *, stdscr); +NCURSES_WRAPPED_VAR(char *, ttytype); +NCURSES_WRAPPED_VAR(int, COLORS); +NCURSES_WRAPPED_VAR(int, COLOR_PAIRS); +NCURSES_WRAPPED_VAR(int, COLS); +NCURSES_WRAPPED_VAR(int, ESCDELAY); +NCURSES_WRAPPED_VAR(int, LINES); +NCURSES_WRAPPED_VAR(int, TABSIZE); + +#define curscr NCURSES_PUBLIC_VAR(curscr()) +#define newscr NCURSES_PUBLIC_VAR(newscr()) +#define stdscr NCURSES_PUBLIC_VAR(stdscr()) +#define ttytype NCURSES_PUBLIC_VAR(ttytype()) +#define COLORS NCURSES_PUBLIC_VAR(COLORS()) +#define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS()) +#define COLS NCURSES_PUBLIC_VAR(COLS()) +#define ESCDELAY NCURSES_PUBLIC_VAR(ESCDELAY()) +#define LINES NCURSES_PUBLIC_VAR(LINES()) +#define TABSIZE NCURSES_PUBLIC_VAR(TABSIZE()) + +#else + +extern NCURSES_EXPORT_VAR(WINDOW *) curscr; +extern NCURSES_EXPORT_VAR(WINDOW *) newscr; +extern NCURSES_EXPORT_VAR(WINDOW *) stdscr; +extern NCURSES_EXPORT_VAR(char) ttytype[]; +extern NCURSES_EXPORT_VAR(int) COLORS; +extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS; +extern NCURSES_EXPORT_VAR(int) COLS; +extern NCURSES_EXPORT_VAR(int) ESCDELAY; +extern NCURSES_EXPORT_VAR(int) LINES; +extern NCURSES_EXPORT_VAR(int) TABSIZE; + +#endif + +/* + * Pseudo-character tokens outside ASCII range. The curses wgetch() function + * will return any given one of these only if the corresponding k- capability + * is defined in your terminal's terminfo entry. + * + * Some keys (KEY_A1, etc) are arranged like this: + * a1 up a3 + * left b2 right + * c1 down c3 + * + * A few key codes do not depend upon the terminfo entry. + */ +#define KEY_CODE_YES 0400 /* A wchar_t contains a key code */ +#define KEY_MIN 0401 /* Minimum curses key */ +#define KEY_BREAK 0401 /* Break key (unreliable) */ +#define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */ +#define KEY_RESET 0531 /* Reset or hard reset (unreliable) */ +/* + * These definitions were generated by ./MKkey_defs.sh ./Caps ./Caps-ncurses + */ +#define KEY_DOWN 0402 /* down-arrow key */ +#define KEY_UP 0403 /* up-arrow key */ +#define KEY_LEFT 0404 /* left-arrow key */ +#define KEY_RIGHT 0405 /* right-arrow key */ +#define KEY_HOME 0406 /* home key */ +#define KEY_BACKSPACE 0407 /* backspace key */ +#define KEY_F0 0410 /* Function keys. Space for 64 */ +#define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */ +#define KEY_DL 0510 /* delete-line key */ +#define KEY_IL 0511 /* insert-line key */ +#define KEY_DC 0512 /* delete-character key */ +#define KEY_IC 0513 /* insert-character key */ +#define KEY_EIC 0514 /* sent by rmir or smir in insert mode */ +#define KEY_CLEAR 0515 /* clear-screen or erase key */ +#define KEY_EOS 0516 /* clear-to-end-of-screen key */ +#define KEY_EOL 0517 /* clear-to-end-of-line key */ +#define KEY_SF 0520 /* scroll-forward key */ +#define KEY_SR 0521 /* scroll-backward key */ +#define KEY_NPAGE 0522 /* next-page key */ +#define KEY_PPAGE 0523 /* previous-page key */ +#define KEY_STAB 0524 /* set-tab key */ +#define KEY_CTAB 0525 /* clear-tab key */ +#define KEY_CATAB 0526 /* clear-all-tabs key */ +#define KEY_ENTER 0527 /* enter/send key */ +#define KEY_PRINT 0532 /* print key */ +#define KEY_LL 0533 /* lower-left key (home down) */ +#define KEY_A1 0534 /* upper left of keypad */ +#define KEY_A3 0535 /* upper right of keypad */ +#define KEY_B2 0536 /* center of keypad */ +#define KEY_C1 0537 /* lower left of keypad */ +#define KEY_C3 0540 /* lower right of keypad */ +#define KEY_BTAB 0541 /* back-tab key */ +#define KEY_BEG 0542 /* begin key */ +#define KEY_CANCEL 0543 /* cancel key */ +#define KEY_CLOSE 0544 /* close key */ +#define KEY_COMMAND 0545 /* command key */ +#define KEY_COPY 0546 /* copy key */ +#define KEY_CREATE 0547 /* create key */ +#define KEY_END 0550 /* end key */ +#define KEY_EXIT 0551 /* exit key */ +#define KEY_FIND 0552 /* find key */ +#define KEY_HELP 0553 /* help key */ +#define KEY_MARK 0554 /* mark key */ +#define KEY_MESSAGE 0555 /* message key */ +#define KEY_MOVE 0556 /* move key */ +#define KEY_NEXT 0557 /* next key */ +#define KEY_OPEN 0560 /* open key */ +#define KEY_OPTIONS 0561 /* options key */ +#define KEY_PREVIOUS 0562 /* previous key */ +#define KEY_REDO 0563 /* redo key */ +#define KEY_REFERENCE 0564 /* reference key */ +#define KEY_REFRESH 0565 /* refresh key */ +#define KEY_REPLACE 0566 /* replace key */ +#define KEY_RESTART 0567 /* restart key */ +#define KEY_RESUME 0570 /* resume key */ +#define KEY_SAVE 0571 /* save key */ +#define KEY_SBEG 0572 /* shifted begin key */ +#define KEY_SCANCEL 0573 /* shifted cancel key */ +#define KEY_SCOMMAND 0574 /* shifted command key */ +#define KEY_SCOPY 0575 /* shifted copy key */ +#define KEY_SCREATE 0576 /* shifted create key */ +#define KEY_SDC 0577 /* shifted delete-character key */ +#define KEY_SDL 0600 /* shifted delete-line key */ +#define KEY_SELECT 0601 /* select key */ +#define KEY_SEND 0602 /* shifted end key */ +#define KEY_SEOL 0603 /* shifted clear-to-end-of-line key */ +#define KEY_SEXIT 0604 /* shifted exit key */ +#define KEY_SFIND 0605 /* shifted find key */ +#define KEY_SHELP 0606 /* shifted help key */ +#define KEY_SHOME 0607 /* shifted home key */ +#define KEY_SIC 0610 /* shifted insert-character key */ +#define KEY_SLEFT 0611 /* shifted left-arrow key */ +#define KEY_SMESSAGE 0612 /* shifted message key */ +#define KEY_SMOVE 0613 /* shifted move key */ +#define KEY_SNEXT 0614 /* shifted next key */ +#define KEY_SOPTIONS 0615 /* shifted options key */ +#define KEY_SPREVIOUS 0616 /* shifted previous key */ +#define KEY_SPRINT 0617 /* shifted print key */ +#define KEY_SREDO 0620 /* shifted redo key */ +#define KEY_SREPLACE 0621 /* shifted replace key */ +#define KEY_SRIGHT 0622 /* shifted right-arrow key */ +#define KEY_SRSUME 0623 /* shifted resume key */ +#define KEY_SSAVE 0624 /* shifted save key */ +#define KEY_SSUSPEND 0625 /* shifted suspend key */ +#define KEY_SUNDO 0626 /* shifted undo key */ +#define KEY_SUSPEND 0627 /* suspend key */ +#define KEY_UNDO 0630 /* undo key */ +#define KEY_MOUSE 0631 /* Mouse event has occurred */ + +#if NCURSES_SIGWINCH +#define KEY_RESIZE 0632 /* Terminal resize event */ +#endif + +#define KEY_MAX 0777 /* Maximum key value is 0632 */ +/* $Id: curses.wide,v 1.51 2021/05/22 20:28:29 tom Exp $ */ +/* + * vile:cmode: + * This file is part of ncurses, designed to be appended after curses.h.in + * (see that file for the relevant copyright). + */ +#define _XOPEN_CURSES 1 + +#if NCURSES_WIDECHAR + +extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs; + +#define NCURSES_WACS(c) (&_nc_wacs[NCURSES_CAST(unsigned char,(c))]) + +#define WACS_BSSB NCURSES_WACS('l') +#define WACS_SSBB NCURSES_WACS('m') +#define WACS_BBSS NCURSES_WACS('k') +#define WACS_SBBS NCURSES_WACS('j') +#define WACS_SBSS NCURSES_WACS('u') +#define WACS_SSSB NCURSES_WACS('t') +#define WACS_SSBS NCURSES_WACS('v') +#define WACS_BSSS NCURSES_WACS('w') +#define WACS_BSBS NCURSES_WACS('q') +#define WACS_SBSB NCURSES_WACS('x') +#define WACS_SSSS NCURSES_WACS('n') + +#define WACS_ULCORNER WACS_BSSB +#define WACS_LLCORNER WACS_SSBB +#define WACS_URCORNER WACS_BBSS +#define WACS_LRCORNER WACS_SBBS +#define WACS_RTEE WACS_SBSS +#define WACS_LTEE WACS_SSSB +#define WACS_BTEE WACS_SSBS +#define WACS_TTEE WACS_BSSS +#define WACS_HLINE WACS_BSBS +#define WACS_VLINE WACS_SBSB +#define WACS_PLUS WACS_SSSS + +#define WACS_S1 NCURSES_WACS('o') /* scan line 1 */ +#define WACS_S9 NCURSES_WACS('s') /* scan line 9 */ +#define WACS_DIAMOND NCURSES_WACS('`') /* diamond */ +#define WACS_CKBOARD NCURSES_WACS('a') /* checker board */ +#define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */ +#define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */ +#define WACS_BULLET NCURSES_WACS('~') /* bullet */ + + /* Teletype 5410v1 symbols */ +#define WACS_LARROW NCURSES_WACS(',') /* arrow left */ +#define WACS_RARROW NCURSES_WACS('+') /* arrow right */ +#define WACS_DARROW NCURSES_WACS('.') /* arrow down */ +#define WACS_UARROW NCURSES_WACS('-') /* arrow up */ +#define WACS_BOARD NCURSES_WACS('h') /* board of squares */ +#define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */ +#define WACS_BLOCK NCURSES_WACS('0') /* solid square block */ + + /* ncurses extensions */ +#define WACS_S3 NCURSES_WACS('p') /* scan line 3 */ +#define WACS_S7 NCURSES_WACS('r') /* scan line 7 */ +#define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */ +#define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */ +#define WACS_PI NCURSES_WACS('{') /* Pi */ +#define WACS_NEQUAL NCURSES_WACS('|') /* not equal */ +#define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */ + + /* double lines */ +#define WACS_BDDB NCURSES_WACS('C') +#define WACS_DDBB NCURSES_WACS('D') +#define WACS_BBDD NCURSES_WACS('B') +#define WACS_DBBD NCURSES_WACS('A') +#define WACS_DBDD NCURSES_WACS('G') +#define WACS_DDDB NCURSES_WACS('F') +#define WACS_DDBD NCURSES_WACS('H') +#define WACS_BDDD NCURSES_WACS('I') +#define WACS_BDBD NCURSES_WACS('R') +#define WACS_DBDB NCURSES_WACS('Y') +#define WACS_DDDD NCURSES_WACS('E') + +#define WACS_D_ULCORNER WACS_BDDB +#define WACS_D_LLCORNER WACS_DDBB +#define WACS_D_URCORNER WACS_BBDD +#define WACS_D_LRCORNER WACS_DBBD +#define WACS_D_RTEE WACS_DBDD +#define WACS_D_LTEE WACS_DDDB +#define WACS_D_BTEE WACS_DDBD +#define WACS_D_TTEE WACS_BDDD +#define WACS_D_HLINE WACS_BDBD +#define WACS_D_VLINE WACS_DBDB +#define WACS_D_PLUS WACS_DDDD + + /* thick lines */ +#define WACS_BTTB NCURSES_WACS('L') +#define WACS_TTBB NCURSES_WACS('M') +#define WACS_BBTT NCURSES_WACS('K') +#define WACS_TBBT NCURSES_WACS('J') +#define WACS_TBTT NCURSES_WACS('U') +#define WACS_TTTB NCURSES_WACS('T') +#define WACS_TTBT NCURSES_WACS('V') +#define WACS_BTTT NCURSES_WACS('W') +#define WACS_BTBT NCURSES_WACS('Q') +#define WACS_TBTB NCURSES_WACS('X') +#define WACS_TTTT NCURSES_WACS('N') + +#define WACS_T_ULCORNER WACS_BTTB +#define WACS_T_LLCORNER WACS_TTBB +#define WACS_T_URCORNER WACS_BBTT +#define WACS_T_LRCORNER WACS_TBBT +#define WACS_T_RTEE WACS_TBTT +#define WACS_T_LTEE WACS_TTTB +#define WACS_T_BTEE WACS_TTBT +#define WACS_T_TTEE WACS_BTTT +#define WACS_T_HLINE WACS_BTBT +#define WACS_T_VLINE WACS_TBTB +#define WACS_T_PLUS WACS_TTTT + +/* + * Function prototypes for wide-character operations. + * + * "generated" comments should include ":WIDEC" to make the corresponding + * functions ifdef'd in lib_gen.c + * + * "implemented" comments do not need this marker. + */ + +extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */ +extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, NCURSES_PAIRS_T*, void*); /* implemented */ +extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */ +extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, NCURSES_PAIRS_T, const void *); /* implemented */ +extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ +extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ +extern NCURSES_EXPORT(int) vid_attr (attr_t, NCURSES_PAIRS_T, void *); /* implemented */ +extern NCURSES_EXPORT(int) vid_puts (attr_t, NCURSES_PAIRS_T, void *, NCURSES_OUTC); /* implemented */ +extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ +extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */ +extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* implemented */ +extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */ +extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* implemented */ +extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */ + +#if NCURSES_SP_FUNCS +extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(erasewchar) (SCREEN*, wchar_t *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(killwchar) (SCREEN*, wchar_t *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented:SP_FUNC */ +#endif + +#ifndef NCURSES_NOMACROS + +/* + * XSI curses macros for XPG4 conformance. + */ +#define add_wch(c) wadd_wch(stdscr,(c)) +#define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n)) +#define add_wchstr(str) wadd_wchstr(stdscr,(str)) +#define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n)) +#define addwstr(wstr) waddwstr(stdscr,(wstr)) +#define bkgrnd(c) wbkgrnd(stdscr,(c)) +#define bkgrndset(c) wbkgrndset(stdscr,(c)) +#define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br) +#define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),0,0,0,0) +#define echo_wchar(c) wecho_wchar(stdscr,(c)) +#define get_wch(c) wget_wch(stdscr,(c)) +#define get_wstr(t) wget_wstr(stdscr,(t)) +#define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch)) +#define getn_wstr(t,n) wgetn_wstr(stdscr,(t),(n)) +#define hline_set(c,n) whline_set(stdscr,(c),(n)) +#define in_wch(c) win_wch(stdscr,(c)) +#define in_wchnstr(c,n) win_wchnstr(stdscr,(c),(n)) +#define in_wchstr(c) win_wchstr(stdscr,(c)) +#define innwstr(c,n) winnwstr(stdscr,(c),(n)) +#define ins_nwstr(t,n) wins_nwstr(stdscr,(t),(n)) +#define ins_wch(c) wins_wch(stdscr,(c)) +#define ins_wstr(t) wins_wstr(stdscr,(t)) +#define inwstr(c) winwstr(stdscr,(c)) +#define vline_set(c,n) wvline_set(stdscr,(c),(n)) +#define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1) +#define waddwstr(win,wstr) waddnwstr((win),(wstr),-1) +#define wget_wstr(w,t) wgetn_wstr((w),(t),-1) +#define win_wchstr(w,c) win_wchnstr((w),(c),-1) +#define wins_wstr(w,t) wins_nwstr((w),(t),-1) + +#if !NCURSES_OPAQUE +#define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR) +#endif + +#define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c)) +#define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n)) +#define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s)) +#define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n)) +#define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr)) +#define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c)) +#define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t)) +#define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,(y),(x),(t),(n)) +#define mvhline_set(y,x,c,n) mvwhline_set(stdscr,(y),(x),(c),(n)) +#define mvin_wch(y,x,c) mvwin_wch(stdscr,(y),(x),(c)) +#define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,(y),(x),(c),(n)) +#define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,(y),(x),(c)) +#define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,(y),(x),(c),(n)) +#define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,(y),(x),(t),(n)) +#define mvins_wch(y,x,c) mvwins_wch(stdscr,(y),(x),(c)) +#define mvins_wstr(y,x,t) mvwins_wstr(stdscr,(y),(x),(t)) +#define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c)) +#define mvvline_set(y,x,c,n) mvwvline_set(stdscr,(y),(x),(c),(n)) + +#define mvwadd_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wch((win),(c))) +#define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n))) +#define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s))) +#define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n))) +#define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr))) +#define mvwget_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wget_wch((win),(c))) +#define mvwget_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wget_wstr((win),(t))) +#define mvwgetn_wstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wgetn_wstr((win),(t),(n))) +#define mvwhline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : whline_set((win),(c),(n))) +#define mvwin_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wch((win),(c))) +#define mvwin_wchnstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : win_wchnstr((win),(c),(n))) +#define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c))) +#define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n))) +#define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n))) +#define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c))) +#define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t))) +#define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c))) +#define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n))) + +#endif /* NCURSES_NOMACROS */ + +#if defined(TRACE) || defined(NCURSES_TEST) +extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *); +extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *); +#endif + +#endif /* NCURSES_WIDECHAR */ +/* $Id: curses.tail,v 1.27 2023/08/05 19:43:46 tom Exp $ */ +/* + * vile:cmode: + * This file is part of ncurses, designed to be appended after curses.h.in + * (see that file for the relevant copyright). + */ + +/* mouse interface */ + +#if NCURSES_MOUSE_VERSION > 1 +#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5)) +#else +#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6)) +#endif + +#define NCURSES_BUTTON_RELEASED 001UL +#define NCURSES_BUTTON_PRESSED 002UL +#define NCURSES_BUTTON_CLICKED 004UL +#define NCURSES_DOUBLE_CLICKED 010UL +#define NCURSES_TRIPLE_CLICKED 020UL +#define NCURSES_RESERVED_EVENT 040UL + +/* event masks */ +#define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED) +#define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED) +#define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED) +#define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED) +#define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED) + +#define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED) +#define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) +#define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED) +#define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED) +#define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED) + +#define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED) +#define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED) +#define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED) +#define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED) +#define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED) + +#define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED) +#define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED) +#define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED) +#define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED) +#define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED) + +/* + * In 32 bits the version-1 scheme does not provide enough space for a 5th + * button, unless we choose to change the ABI by omitting the reserved-events. + */ +#if NCURSES_MOUSE_VERSION > 1 + +#define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED) +#define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED) +#define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED) +#define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED) +#define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED) + +#define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L) +#define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L) +#define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L) +#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L) + +#else + +#define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT) +#define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT) +#define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT) +#define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT) + +#define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L) +#define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L) +#define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L) +#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L) + +#endif + +#define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1) + +/* macros to extract single event-bits from masks */ +#define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001)) +#define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002)) +#define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004)) +#define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010)) +#define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020)) +#define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040)) + +typedef struct +{ + short id; /* ID to distinguish multiple devices */ + int x, y, z; /* event coordinates (character-cell) */ + mmask_t bstate; /* button state bits */ +} +MEVENT; + +extern NCURSES_EXPORT(bool) has_mouse(void); +extern NCURSES_EXPORT(int) getmouse (MEVENT *); +extern NCURSES_EXPORT(int) ungetmouse (MEVENT *); +extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *); +extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int); +extern NCURSES_EXPORT(int) mouseinterval (int); +extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool); +extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */ + +#if NCURSES_SP_FUNCS +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *); +extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mouseinterval) (SCREEN*, int); +#endif + +#ifndef NCURSES_NOMACROS +#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) +#endif + +/* other non-XSI functions */ + +extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */ +extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */ + +#if NCURSES_SP_FUNCS +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int); /* do we have given key? */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int); /* direct data to printer */ +#endif + +/* Debugging : use with libncurses_g.a */ + +extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2); +extern NCURSES_EXPORT(char *) _traceattr (attr_t); +extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype); +extern NCURSES_EXPORT(char *) _tracechar (int); +extern NCURSES_EXPORT(char *) _tracechtype (chtype); +extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype); +#if NCURSES_WIDECHAR +#define _tracech_t _tracecchar_t +extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *); +#define _tracech_t2 _tracecchar_t2 +extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *); +#else +#define _tracech_t _tracechtype +#define _tracech_t2 _tracechtype2 +#endif +extern NCURSES_EXPORT(void) trace (const unsigned) GCC_DEPRECATED("use curses_trace"); +extern NCURSES_EXPORT(unsigned) curses_trace (const unsigned); + +/* trace masks */ +#define TRACE_DISABLE 0x0000 /* turn off tracing */ +#define TRACE_TIMES 0x0001 /* trace user and system times of updates */ +#define TRACE_TPUTS 0x0002 /* trace tputs calls */ +#define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */ +#define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */ +#define TRACE_CHARPUT 0x0010 /* trace all character outputs */ +#define TRACE_ORDINARY 0x001F /* trace all update actions */ +#define TRACE_CALLS 0x0020 /* trace all curses calls */ +#define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */ +#define TRACE_IEVENT 0x0080 /* trace low-level input processing */ +#define TRACE_BITS 0x0100 /* trace state of TTY control bits */ +#define TRACE_ICALLS 0x0200 /* trace internal/nested calls */ +#define TRACE_CCALLS 0x0400 /* trace per-character calls */ +#define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */ +#define TRACE_ATTRS 0x1000 /* trace attribute updates */ + +#define TRACE_SHIFT 13 /* number of bits in the trace masks */ +#define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */ + +#if defined(TRACE) || defined(NCURSES_TEST) +extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */ +extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); +#define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */ +#define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */ +#define OPTIMIZE_SCROLL 0x04 /* scroll optimization */ +#define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */ +#endif + +extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int); + +#include + +#ifdef __cplusplus + +#ifndef NCURSES_NOMACROS + +/* these names conflict with STL */ +#undef box +#undef clear +#undef erase +#undef move +#undef refresh + +#endif /* NCURSES_NOMACROS */ + +} +#endif + +#endif /* __NCURSES_H */ diff --git a/illumos-x86_64/usr/include/ncurses/cursesapp.h b/illumos-x86_64/usr/include/ncurses/cursesapp.h new file mode 100644 index 00000000..c69c4908 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/cursesapp.h @@ -0,0 +1,191 @@ +// * This makes emacs happy -*-Mode: C++;-*- +/**************************************************************************** + * Copyright 2019-2020,2021 Thomas E. Dickey * + * Copyright 1998-2005,2011 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1997 * + ****************************************************************************/ + +// $Id: cursesapp.h,v 1.18 2021/06/17 21:26:02 tom Exp $ + +#ifndef NCURSES_CURSESAPP_H_incl +#define NCURSES_CURSESAPP_H_incl + +#include + +#if (defined(_WIN32) || defined(_WIN64)) +# define NCURSES_CXX_MAIN_NAME cursespp_main +# define NCURSES_CXX_MAIN \ + int main(int argc, char *argv[]) { \ + return NCURSES_CXX_MAIN_NAME(argc, argv); \ + } +#else +# define NCURSES_CXX_MAIN_NAME main +#endif +NCURSES_CXX_IMPEXP int NCURSES_CXX_MAIN_NAME(int argc, char *argv[]); + +class NCURSES_CXX_IMPEXP NCursesApplication { +public: + typedef struct _slk_link { // This structure is used to maintain + struct _slk_link* prev; // a stack of SLKs + Soft_Label_Key_Set* SLKs; + } SLK_Link; +private: + static int rinit(NCursesWindow& w); // Internal Init function for title + static NCursesApplication* theApp; // Global ref. to the application + + static SLK_Link* slk_stack; + +protected: + static NCursesWindow* titleWindow; // The Title Window (if any) + + bool b_Colors; // Is this a color application? + NCursesWindow* Root_Window; // This is the stdscr equiv. + + // Initialization of attributes; + // Rewrite this in your derived class if you prefer other settings + virtual void init(bool bColors); + + // The number of lines for the title window. Default is no title window + // You may rewrite this in your derived class + virtual int titlesize() const { + return 0; + } + + // This method is called to put something into the title window initially + // You may rewrite this in your derived class + virtual void title() { + } + + // The layout used for the Soft Label Keys. Default is to have no SLKs. + // You may rewrite this in your derived class + virtual Soft_Label_Key_Set::Label_Layout useSLKs() const { + return Soft_Label_Key_Set::None; + } + + // This method is called to initialize the SLKs. Default is nothing. + // You may rewrite this in your derived class + virtual void init_labels(Soft_Label_Key_Set& S) const { + (void) S; + } + + // Your derived class must implement this method. The return value must + // be the exit value of your application. + virtual int run() = 0; + + // The constructor is protected, so you may use it in your derived + // class constructor. The argument tells whether or not you want colors. + NCursesApplication(bool wantColors = FALSE); + + NCursesApplication& operator=(const NCursesApplication& rhs) + { + if (this != &rhs) { + *this = rhs; + } + return *this; + } + + NCursesApplication(const NCursesApplication& rhs) + : b_Colors(rhs.b_Colors), + Root_Window(rhs.Root_Window) + { + } + + static NCursesWindow *&getTitleWindow(); + +public: + virtual ~NCursesApplication() THROWS(NCursesException); + + // Get a pointer to the current application object + static NCursesApplication* getApplication(); + + // This method runs the application and returns its exit value + int operator()(void); + + // Process the commandline arguments. The default implementation simply + // ignores them. Your derived class may rewrite this. + virtual void handleArgs(int argc, char* argv[]) { + (void) argc; + (void) argv; + } + + // Does this application use colors? + inline bool useColors() const { + return b_Colors; + } + + // Push the Key Set S onto the SLK Stack. S then becomes the current set + // of Soft Labelled Keys. + void push(Soft_Label_Key_Set& S); + + // Throw away the current set of SLKs and make the previous one the + // new current set. + bool pop(); + + // Retrieve the current set of Soft Labelled Keys. + Soft_Label_Key_Set* top() const; + + // Attributes to use for menu and forms foregrounds + virtual chtype foregrounds() const { + return b_Colors ? static_cast(COLOR_PAIR(1)) : A_BOLD; + } + + // Attributes to use for menu and forms backgrounds + virtual chtype backgrounds() const { + return b_Colors ? static_cast(COLOR_PAIR(2)) : A_NORMAL; + } + + // Attributes to use for inactive (menu) elements + virtual chtype inactives() const { + return b_Colors ? static_cast(COLOR_PAIR(3)|A_DIM) : A_DIM; + } + + // Attributes to use for (form) labels and SLKs + virtual chtype labels() const { + return b_Colors ? static_cast(COLOR_PAIR(4)) : A_NORMAL; + } + + // Attributes to use for form backgrounds + virtual chtype dialog_backgrounds() const { + return b_Colors ? static_cast(COLOR_PAIR(4)) : A_NORMAL; + } + + // Attributes to use as default for (form) window backgrounds + virtual chtype window_backgrounds() const { + return b_Colors ? static_cast(COLOR_PAIR(5)) : A_NORMAL; + } + + // Attributes to use for the title window + virtual chtype screen_titles() const { + return b_Colors ? static_cast(COLOR_PAIR(6)) : A_BOLD; + } + +}; + +#endif /* NCURSES_CURSESAPP_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/cursesf.h b/illumos-x86_64/usr/include/ncurses/cursesf.h new file mode 100644 index 00000000..f4a733a4 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/cursesf.h @@ -0,0 +1,968 @@ +// * This makes emacs happy -*-Mode: C++;-*- +// vile:cppmode +/**************************************************************************** + * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 1998-2012,2014 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1997 * + ****************************************************************************/ + +// $Id: cursesf.h,v 1.39 2022/08/20 20:52:15 tom Exp $ + +#ifndef NCURSES_CURSESF_H_incl +#define NCURSES_CURSESF_H_incl 1 + +#include + +#ifndef __EXT_QNX +#include +#endif + +extern "C" { +# include +} +// +// ------------------------------------------------------------------------- +// The abstract base class for builtin and user defined Fieldtypes. +// ------------------------------------------------------------------------- +// +class NCURSES_CXX_IMPEXP NCursesFormField; // forward declaration + +// Class to represent builtin field types as well as C++ written new +// fieldtypes (see classes UserDefineFieldType... +class NCURSES_CXX_IMPEXP NCursesFieldType +{ + friend class NCursesFormField; + +protected: + FIELDTYPE* fieldtype; + + inline void OnError(int err) const THROW2(NCursesException const, NCursesFormException) { + if (err!=E_OK) + THROW(new NCursesFormException (err)); + } + + NCursesFieldType(FIELDTYPE *f) : fieldtype(f) { + } + + virtual ~NCursesFieldType() {} + + // Set the fields f fieldtype to this one. + virtual void set(NCursesFormField& f) = 0; + +public: + NCursesFieldType() + : fieldtype(STATIC_CAST(FIELDTYPE*)(0)) + { + } + + NCursesFieldType& operator=(const NCursesFieldType& rhs) + { + if (this != &rhs) { + *this = rhs; + } + return *this; + } + + NCursesFieldType(const NCursesFieldType& rhs) + : fieldtype(rhs.fieldtype) + { + } + +}; + +// +// ------------------------------------------------------------------------- +// The class representing a forms field, wrapping the lowlevel FIELD struct +// ------------------------------------------------------------------------- +// +class NCURSES_CXX_IMPEXP NCursesFormField +{ + friend class NCursesForm; + +protected: + FIELD *field; // lowlevel structure + NCursesFieldType* ftype; // Associated field type + + // Error handler + inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) { + if (err != E_OK) + THROW(new NCursesFormException (err)); + } + +public: + // Create a 'Null' field. Can be used to delimit a field list + NCursesFormField() + : field(STATIC_CAST(FIELD*)(0)), + ftype(STATIC_CAST(NCursesFieldType*)(0)) + { + } + + // Create a new field + NCursesFormField (int rows, + int ncols, + int first_row = 0, + int first_col = 0, + int offscreen_rows = 0, + int additional_buffers = 0) + : field(0), + ftype(STATIC_CAST(NCursesFieldType*)(0)) + { + field = ::new_field(rows, ncols, first_row, first_col, + offscreen_rows, additional_buffers); + if (!field) + OnError(errno); + } + + NCursesFormField& operator=(const NCursesFormField& rhs) + { + if (this != &rhs) { + *this = rhs; + } + return *this; + } + + NCursesFormField(const NCursesFormField& rhs) + : field(rhs.field), ftype(rhs.ftype) + { + } + + virtual ~NCursesFormField () THROWS(NCursesException); + + // Duplicate the field at a new position + inline NCursesFormField* dup(int first_row, int first_col) + { + NCursesFormField* f = new NCursesFormField(); + if (!f) + OnError(E_SYSTEM_ERROR); + else { + f->ftype = ftype; + f->field = ::dup_field(field,first_row,first_col); + if (!f->field) + OnError(errno); + } + return f; + } + + // Link the field to a new location + inline NCursesFormField* link(int first_row, int first_col) { + NCursesFormField* f = new NCursesFormField(); + if (!f) + OnError(E_SYSTEM_ERROR); + else { + f->ftype = ftype; + f->field = ::link_field(field,first_row,first_col); + if (!f->field) + OnError(errno); + } + return f; + } + + // Get the lowlevel field representation + inline FIELD* get_field() const { + return field; + } + + // Retrieve info about the field + inline void info(int& rows, int& ncols, + int& first_row, int& first_col, + int& offscreen_rows, int& additional_buffers) const { + OnError(::field_info(field, &rows, &ncols, + &first_row, &first_col, + &offscreen_rows, &additional_buffers)); + } + + // Retrieve info about the fields dynamic properties. + inline void dynamic_info(int& dynamic_rows, int& dynamic_cols, + int& max_growth) const { + OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols, + &max_growth)); + } + + // For a dynamic field you may set the maximum growth limit. + // A zero means unlimited growth. + inline void set_maximum_growth(int growth = 0) { + OnError(::set_max_field(field,growth)); + } + + // Move the field to a new position + inline void move(int row, int col) { + OnError(::move_field(field,row,col)); + } + + // Mark the field to start a new page + inline void new_page(bool pageFlag = FALSE) { + OnError(::set_new_page(field,pageFlag)); + } + + // Retrieve whether or not the field starts a new page. + inline bool is_new_page() const { + return ::new_page(field); + } + + // Set the justification for the field + inline void set_justification(int just) { + OnError(::set_field_just(field,just)); + } + + // Retrieve the fields justification + inline int justification() const { + return ::field_just(field); + } + // Set the foreground attribute for the field + inline void set_foreground(chtype foreground) { + OnError(::set_field_fore(field,foreground)); + } + + // Retrieve the fields foreground attribute + inline chtype fore() const { + return ::field_fore(field); + } + + // Set the background attribute for the field + inline void set_background(chtype background) { + OnError(::set_field_back(field,background)); + } + + // Retrieve the fields background attribute + inline chtype back() const { + return ::field_back(field); + } + + // Set the padding character for the field + inline void set_pad_character(int padding) { + OnError(::set_field_pad(field, padding)); + } + + // Retrieve the fields padding character + inline int pad() const { + return ::field_pad(field); + } + + // Switch on the fields options + inline void options_on (Field_Options opts) { + OnError (::field_opts_on (field, opts)); + } + + // Switch off the fields options + inline void options_off (Field_Options opts) { + OnError (::field_opts_off (field, opts)); + } + + // Retrieve the fields options + inline Field_Options options () const { + return ::field_opts (field); + } + + // Set the fields options + inline void set_options (Field_Options opts) { + OnError (::set_field_opts (field, opts)); + } + + // Mark the field as changed + inline void set_changed(bool changeFlag = TRUE) { + OnError(::set_field_status(field,changeFlag)); + } + + // Test whether or not the field is marked as changed + inline bool changed() const { + return ::field_status(field); + } + + // Return the index of the field in the field array of a form + // or -1 if the field is not associated to a form + inline int (index)() const { + return ::field_index(field); + } + + // Store a value in a fields buffer. The default buffer is nr. 0 + inline void set_value(const char *val, int buffer = 0) { + OnError(::set_field_buffer(field,buffer,val)); + } + + // Retrieve the value of a fields buffer. The default buffer is nr. 0 + inline char* value(int buffer = 0) const { + return ::field_buffer(field,buffer); + } + + // Set the validation type of the field. + inline void set_fieldtype(NCursesFieldType& f) { + ftype = &f; + f.set(*this); // A good friend may do that... + } + + // Retrieve the validation type of the field. + inline NCursesFieldType* fieldtype() const { + return ftype; + } + +}; + + // This are the built-in hook functions in this C++ binding. In C++ we use + // virtual member functions (see below On_..._Init and On_..._Termination) + // to provide this functionality in an object oriented manner. +extern "C" { + void _nc_xx_frm_init(FORM *); + void _nc_xx_frm_term(FORM *); + void _nc_xx_fld_init(FORM *); + void _nc_xx_fld_term(FORM *); +} + +// +// ------------------------------------------------------------------------- +// The class representing a form, wrapping the lowlevel FORM struct +// ------------------------------------------------------------------------- +// +class NCURSES_CXX_IMPEXP NCursesForm : public NCursesPanel +{ +protected: + FORM* form; // the lowlevel structure + +private: + NCursesWindow* sub; // the subwindow object + bool b_sub_owner; // is this our own subwindow? + bool b_framed; // has the form a border? + bool b_autoDelete; // Delete fields when deleting form? + + NCursesFormField** my_fields; // The array of fields for this form + + // This structure is used for the form's user data field to link the + // FORM* to the C++ object and to provide extra space for a user pointer. + typedef struct { + void* m_user; // the pointer for the user's data + const NCursesForm* m_back; // backward pointer to C++ object + const FORM* m_owner; + } UserHook; + + // Get the backward pointer to the C++ object from a FORM + static inline NCursesForm* getHook(const FORM *f) { + UserHook* hook = reinterpret_cast(::form_userptr(f)); + assert(hook != 0 && hook->m_owner==f); + return const_cast(hook->m_back); + } + + friend void _nc_xx_frm_init(FORM *); + friend void _nc_xx_frm_term(FORM *); + friend void _nc_xx_fld_init(FORM *); + friend void _nc_xx_fld_term(FORM *); + + // Calculate FIELD* array for the menu + FIELD** mapFields(NCursesFormField* nfields[]); + +protected: + // internal routines + inline void set_user(void *user) { + UserHook* uptr = reinterpret_cast(::form_userptr (form)); + assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); + uptr->m_user = user; + } + + inline void *get_user() { + UserHook* uptr = reinterpret_cast(::form_userptr (form)); + assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); + return uptr->m_user; + } + + void InitForm (NCursesFormField* Fields[], + bool with_frame, + bool autoDeleteFields); + + inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) { + if (err != E_OK) + THROW(new NCursesFormException (err)); + } + + // this wraps the form_driver call. + virtual int driver (int c) ; + + // 'Internal' constructor, builds an object without association to a + // field array. + NCursesForm( int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0) + : NCursesPanel(nlines, ncols, begin_y, begin_x), + form (STATIC_CAST(FORM*)(0)), + sub(0), + b_sub_owner(0), + b_framed(0), + b_autoDelete(0), + my_fields(0) + { + } + +public: + // Create form for the default panel. + NCursesForm (NCursesFormField* Fields[], + bool with_frame=FALSE, // reserve space for a frame? + bool autoDelete_Fields=FALSE) // do automatic cleanup? + : NCursesPanel(), + form(0), + sub(0), + b_sub_owner(0), + b_framed(0), + b_autoDelete(0), + my_fields(0) + { + InitForm(Fields, with_frame, autoDelete_Fields); + } + + // Create a form in a panel with the given position and size. + NCursesForm (NCursesFormField* Fields[], + int nlines, + int ncols, + int begin_y, + int begin_x, + bool with_frame=FALSE, // reserve space for a frame? + bool autoDelete_Fields=FALSE) // do automatic cleanup? + : NCursesPanel(nlines, ncols, begin_y, begin_x), + form(0), + sub(0), + b_sub_owner(0), + b_framed(0), + b_autoDelete(0), + my_fields(0) + { + InitForm(Fields, with_frame, autoDelete_Fields); + } + + NCursesForm& operator=(const NCursesForm& rhs) + { + if (this != &rhs) { + *this = rhs; + NCursesPanel::operator=(rhs); + } + return *this; + } + + NCursesForm(const NCursesForm& rhs) + : NCursesPanel(rhs), + form(rhs.form), + sub(rhs.sub), + b_sub_owner(rhs.b_sub_owner), + b_framed(rhs.b_framed), + b_autoDelete(rhs.b_autoDelete), + my_fields(rhs.my_fields) + { + } + + virtual ~NCursesForm() THROWS(NCursesException); + + // Set the default attributes for the form + virtual void setDefaultAttributes(); + + // Retrieve current field of the form. + inline NCursesFormField* current_field() const { + return my_fields[::field_index(::current_field(form))]; + } + + // Set the forms subwindow + void setSubWindow(NCursesWindow& sub); + + // Set these fields for the form + inline void setFields(NCursesFormField* Fields[]) { + OnError(::set_form_fields(form,mapFields(Fields))); + } + + // Remove the form from the screen + inline void unpost (void) { + OnError (::unpost_form (form)); + } + + // Post the form to the screen if flag is true, unpost it otherwise + inline void post(bool flag = TRUE) { + OnError (flag ? ::post_form(form) : ::unpost_form (form)); + } + + // Decorations + inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE { + if (b_framed) + NCursesPanel::frame(title,btitle); + else + OnError(E_SYSTEM_ERROR); + } + + inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE { + if (b_framed) + NCursesPanel::boldframe(title,btitle); + else + OnError(E_SYSTEM_ERROR); + } + + inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE { + if (b_framed) + NCursesPanel::label(topLabel,bottomLabel); + else + OnError(E_SYSTEM_ERROR); + } + + // ----- + // Hooks + // ----- + + // Called after the form gets repositioned in its window. + // This is especially true if the form is posted. + virtual void On_Form_Init(); + + // Called before the form gets repositioned in its window. + // This is especially true if the form is unposted. + virtual void On_Form_Termination(); + + // Called after the field became the current field + virtual void On_Field_Init(NCursesFormField& field); + + // Called before this field is left as current field. + virtual void On_Field_Termination(NCursesFormField& field); + + // Calculate required window size for the form. + void scale(int& rows, int& ncols) const { + OnError(::scale_form(form,&rows,&ncols)); + } + + // Retrieve number of fields in the form. + int count() const { + return ::field_count(form); + } + + // Make the page the current page of the form. + void set_page(int pageNum) { + OnError(::set_form_page(form, pageNum)); + } + + // Retrieve current page number + int page() const { + return ::form_page(form); + } + + // Switch on the forms options + inline void options_on (Form_Options opts) { + OnError (::form_opts_on (form, opts)); + } + + // Switch off the forms options + inline void options_off (Form_Options opts) { + OnError (::form_opts_off (form, opts)); + } + + // Retrieve the forms options + inline Form_Options options () const { + return ::form_opts (form); + } + + // Set the forms options + inline void set_options (Form_Options opts) { + OnError (::set_form_opts (form, opts)); + } + + // Are there more data in the current field after the data shown + inline bool data_ahead() const { + return ::data_ahead(form); + } + + // Are there more data in the current field before the data shown + inline bool data_behind() const { + return ::data_behind(form); + } + + // Position the cursor to the current field + inline void position_cursor () { + OnError (::pos_form_cursor (form)); + } + // Set the current field + inline void set_current(NCursesFormField& F) { + OnError (::set_current_field(form, F.field)); + } + + // Provide a default key virtualization. Translate the keyboard + // code c into a form request code. + // The default implementation provides a hopefully straightforward + // mapping for the most common keystrokes and form requests. + virtual int virtualize(int c); + + // Operators + inline NCursesFormField* operator[](int i) const { + if ( (i < 0) || (i >= ::field_count (form)) ) + OnError (E_BAD_ARGUMENT); + return my_fields[i]; + } + + // Perform the menu's operation + // Return the field where you left the form. + virtual NCursesFormField* operator()(void); + + // Exception handlers. The default is a Beep. + virtual void On_Request_Denied(int c) const; + virtual void On_Invalid_Field(int c) const; + virtual void On_Unknown_Command(int c) const; + +}; + +// +// ------------------------------------------------------------------------- +// This is the typical C++ typesafe way to allow to attach +// user data to a field of a form. Its assumed that the user +// data belongs to some class T. Use T as template argument +// to create a UserField. +// ------------------------------------------------------------------------- +template class NCURSES_CXX_IMPEXP NCursesUserField : public NCursesFormField +{ +public: + NCursesUserField (int rows, + int ncols, + int first_row = 0, + int first_col = 0, + const T* p_UserData = STATIC_CAST(T*)(0), + int offscreen_rows = 0, + int additional_buffers = 0) + : NCursesFormField (rows, ncols, + first_row, first_col, + offscreen_rows, additional_buffers) { + if (field) + OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData))); + } + + virtual ~NCursesUserField() THROWS(NCursesException) {}; + + inline const T* UserData (void) const { + return reinterpret_cast(::field_userptr (field)); + } + + inline virtual void setUserData(const T* p_UserData) { + if (field) + OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData))); + } +}; +// +// ------------------------------------------------------------------------- +// The same mechanism is used to attach user data to a form +// ------------------------------------------------------------------------- +// +template class NCURSES_CXX_IMPEXP NCursesUserForm : public NCursesForm +{ +protected: + // 'Internal' constructor, builds an object without association to a + // field array. + NCursesUserForm( int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0, + const T* p_UserData = STATIC_CAST(T*)(0)) + : NCursesForm(nlines,ncols,begin_y,begin_x) { + if (form) + set_user (const_cast(reinterpret_cast + (p_UserData))); + } + +public: + NCursesUserForm (NCursesFormField* Fields[], + const T* p_UserData = STATIC_CAST(T*)(0), + bool with_frame=FALSE, + bool autoDelete_Fields=FALSE) + : NCursesForm (Fields, with_frame, autoDelete_Fields) { + if (form) + set_user (const_cast(reinterpret_cast(p_UserData))); + }; + + NCursesUserForm (NCursesFormField* Fields[], + int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0, + const T* p_UserData = STATIC_CAST(T*)(0), + bool with_frame=FALSE, + bool autoDelete_Fields=FALSE) + : NCursesForm (Fields, nlines, ncols, begin_y, begin_x, + with_frame, autoDelete_Fields) { + if (form) + set_user (const_cast(reinterpret_cast + (p_UserData))); + }; + + virtual ~NCursesUserForm() THROWS(NCursesException) { + }; + + inline T* UserData (void) { + return reinterpret_cast(get_user ()); + }; + + inline virtual void setUserData (const T* p_UserData) { + if (form) + set_user (const_cast(reinterpret_cast(p_UserData))); + } + +}; +// +// ------------------------------------------------------------------------- +// Builtin Fieldtypes +// ------------------------------------------------------------------------- +// +class NCURSES_CXX_IMPEXP Alpha_Field : public NCursesFieldType +{ +private: + int min_field_width; + + void set(NCursesFormField& f) NCURSES_OVERRIDE { + OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); + } + +public: + explicit Alpha_Field(int width) + : NCursesFieldType(TYPE_ALPHA), + min_field_width(width) { + } +}; + +class NCURSES_CXX_IMPEXP Alphanumeric_Field : public NCursesFieldType +{ +private: + int min_field_width; + + void set(NCursesFormField& f) NCURSES_OVERRIDE { + OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); + } + +public: + explicit Alphanumeric_Field(int width) + : NCursesFieldType(TYPE_ALNUM), + min_field_width(width) { + } +}; + +class NCURSES_CXX_IMPEXP Integer_Field : public NCursesFieldType +{ +private: + int precision; + long lower_limit, upper_limit; + + void set(NCursesFormField& f) NCURSES_OVERRIDE { + OnError(::set_field_type(f.get_field(),fieldtype, + precision,lower_limit,upper_limit)); + } + +public: + Integer_Field(int prec, long low=0L, long high=0L) + : NCursesFieldType(TYPE_INTEGER), + precision(prec), lower_limit(low), upper_limit(high) { + } +}; + +class NCURSES_CXX_IMPEXP Numeric_Field : public NCursesFieldType +{ +private: + int precision; + double lower_limit, upper_limit; + + void set(NCursesFormField& f) NCURSES_OVERRIDE { + OnError(::set_field_type(f.get_field(),fieldtype, + precision,lower_limit,upper_limit)); + } + +public: + Numeric_Field(int prec, double low=0.0, double high=0.0) + : NCursesFieldType(TYPE_NUMERIC), + precision(prec), lower_limit(low), upper_limit(high) { + } +}; + +class NCURSES_CXX_IMPEXP Regular_Expression_Field : public NCursesFieldType +{ +private: + char* regex; + + void set(NCursesFormField& f) NCURSES_OVERRIDE { + OnError(::set_field_type(f.get_field(),fieldtype,regex)); + } + + void copy_regex(const char *source) + { + regex = new char[1 + ::strlen(source)]; + (::strcpy)(regex, source); + } + +public: + explicit Regular_Expression_Field(const char *expr) + : NCursesFieldType(TYPE_REGEXP), + regex(NULL) + { + copy_regex(expr); + } + + Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs) + { + if (this != &rhs) { + *this = rhs; + copy_regex(rhs.regex); + NCursesFieldType::operator=(rhs); + } + return *this; + } + + Regular_Expression_Field(const Regular_Expression_Field& rhs) + : NCursesFieldType(rhs), + regex(NULL) + { + copy_regex(rhs.regex); + } + + ~Regular_Expression_Field() { + delete[] regex; + } +}; + +class NCURSES_CXX_IMPEXP Enumeration_Field : public NCursesFieldType +{ +private: + const char** list; + int case_sensitive; + int non_unique_matches; + + void set(NCursesFormField& f) NCURSES_OVERRIDE { + OnError(::set_field_type(f.get_field(),fieldtype, + list,case_sensitive,non_unique_matches)); + } +public: + Enumeration_Field(const char* enums[], + bool case_sens=FALSE, + bool non_unique=FALSE) + : NCursesFieldType(TYPE_ENUM), + list(enums), + case_sensitive(case_sens ? -1 : 0), + non_unique_matches(non_unique ? -1 : 0) { + } + + Enumeration_Field& operator=(const Enumeration_Field& rhs) + { + if (this != &rhs) { + *this = rhs; + NCursesFieldType::operator=(rhs); + } + return *this; + } + + Enumeration_Field(const Enumeration_Field& rhs) + : NCursesFieldType(rhs), + list(rhs.list), + case_sensitive(rhs.case_sensitive), + non_unique_matches(rhs.non_unique_matches) + { + } +}; + +class NCURSES_CXX_IMPEXP IPV4_Address_Field : public NCursesFieldType +{ +private: + void set(NCursesFormField& f) NCURSES_OVERRIDE { + OnError(::set_field_type(f.get_field(),fieldtype)); + } + +public: + IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) { + } +}; + +extern "C" { + bool _nc_xx_fld_fcheck(FIELD *, const void*); + bool _nc_xx_fld_ccheck(int c, const void *); + void* _nc_xx_fld_makearg(va_list*); +} + +// +// ------------------------------------------------------------------------- +// Abstract base class for User-Defined Fieldtypes +// ------------------------------------------------------------------------- +// +class NCURSES_CXX_IMPEXP UserDefinedFieldType : public NCursesFieldType +{ + friend class UDF_Init; // Internal helper to set up statics +private: + // For all C++ defined fieldtypes we need only one generic lowlevel + // FIELDTYPE* element. + static FIELDTYPE* generic_fieldtype; + +protected: + // This are the functions required by the low level libforms functions + // to construct a fieldtype. + friend bool _nc_xx_fld_fcheck(FIELD *, const void*); + friend bool _nc_xx_fld_ccheck(int c, const void *); + friend void* _nc_xx_fld_makearg(va_list*); + + void set(NCursesFormField& f) NCURSES_OVERRIDE { + OnError(::set_field_type(f.get_field(),fieldtype,&f)); + } + +protected: + // Redefine this function to do a field validation. The argument + // is a reference to the field you should validate. + virtual bool field_check(NCursesFormField& f) = 0; + + // Redefine this function to do a character validation. The argument + // is the character to be validated. + virtual bool char_check (int c) = 0; + +public: + UserDefinedFieldType(); +}; + +extern "C" { + bool _nc_xx_next_choice(FIELD*, const void *); + bool _nc_xx_prev_choice(FIELD*, const void *); +} + +// +// ------------------------------------------------------------------------- +// Abstract base class for User-Defined Fieldtypes with Choice functions +// ------------------------------------------------------------------------- +// +class NCURSES_CXX_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType +{ + friend class UDF_Init; // Internal helper to set up statics +private: + // For all C++ defined fieldtypes with choice functions we need only one + // generic lowlevel FIELDTYPE* element. + static FIELDTYPE* generic_fieldtype_with_choice; + + // This are the functions required by the low level libforms functions + // to construct a fieldtype with choice functions. + friend bool _nc_xx_next_choice(FIELD*, const void *); + friend bool _nc_xx_prev_choice(FIELD*, const void *); + +protected: + // Redefine this function to do the retrieval of the next choice value. + // The argument is a reference to the field tobe examined. + virtual bool next (NCursesFormField& f) = 0; + + // Redefine this function to do the retrieval of the previous choice value. + // The argument is a reference to the field tobe examined. + virtual bool previous(NCursesFormField& f) = 0; + +public: + UserDefinedFieldType_With_Choice(); +}; + +#endif /* NCURSES_CURSESF_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/cursesm.h b/illumos-x86_64/usr/include/ncurses/cursesm.h new file mode 100644 index 00000000..7b545de9 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/cursesm.h @@ -0,0 +1,674 @@ +// * This makes emacs happy -*-Mode: C++;-*- +/**************************************************************************** + * Copyright 2019-2020,2022 Thomas E. Dickey * + * Copyright 1998-2012,2014 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1997 * + ****************************************************************************/ + +// $Id: cursesm.h,v 1.35 2022/08/20 20:52:15 tom Exp $ + +#ifndef NCURSES_CURSESM_H_incl +#define NCURSES_CURSESM_H_incl 1 + +#include + +extern "C" { +# include +} +// +// ------------------------------------------------------------------------- +// This wraps the ITEM type of +// ------------------------------------------------------------------------- +// +class NCURSES_CXX_IMPEXP NCursesMenuItem +{ + friend class NCursesMenu; + +protected: + ITEM *item; + + inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) { + if (err != E_OK) + THROW(new NCursesMenuException (err)); + } + +public: + NCursesMenuItem (const char* p_name = NULL, + const char* p_descript = NULL) + : item(0) + { + item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0); + if (p_name && !item) + OnError (E_SYSTEM_ERROR); + } + // Create an item. If you pass both parameters as NULL, a delimiting + // item is constructed which can be used to terminate a list of + // NCursesMenu objects. + + NCursesMenuItem& operator=(const NCursesMenuItem& rhs) + { + if (this != &rhs) { + *this = rhs; + } + return *this; + } + + NCursesMenuItem(const NCursesMenuItem& rhs) + : item(0) + { + (void) rhs; + } + + virtual ~NCursesMenuItem () THROWS(NCursesException); + // Release the items memory + + inline const char* name () const { + return ::item_name (item); + } + // Name of the item + + inline const char* description () const { + return ::item_description (item); + } + // Description of the item + + inline int (index) (void) const { + return ::item_index (item); + } + // Index of the item in an item array (or -1) + + inline void options_on (Item_Options opts) { + OnError (::item_opts_on (item, opts)); + } + // Switch on the items options + + inline void options_off (Item_Options opts) { + OnError (::item_opts_off (item, opts)); + } + // Switch off the item's option + + inline Item_Options options () const { + return ::item_opts (item); + } + // Retrieve the items options + + inline void set_options (Item_Options opts) { + OnError (::set_item_opts (item, opts)); + } + // Set the items options + + inline void set_value (bool f) { + OnError (::set_item_value (item,f)); + } + // Set/Reset the items selection state + + inline bool value () const { + return ::item_value (item); + } + // Retrieve the items selection state + + inline bool visible () const { + return ::item_visible (item); + } + // Retrieve visibility of the item + + virtual bool action(); + // Perform an action associated with this item; you may use this in an + // user supplied driver for a menu; you may derive from this class and + // overload action() to supply items with different actions. + // If an action returns true, the menu will be exited. The default action + // is to do nothing. +}; + +// Prototype for an items callback function. +typedef bool ITEMCALLBACK(NCursesMenuItem&); + +// If you don't like to create a child class for individual items to +// overload action(), you may use this class and provide a callback +// function pointer for items. +class NCURSES_CXX_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem +{ +private: + ITEMCALLBACK* p_fct; + +public: + NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL, + const char* p_name = NULL, + const char* p_descript = NULL ) + : NCursesMenuItem (p_name, p_descript), + p_fct (fct) { + } + + NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs) + { + if (this != &rhs) { + *this = rhs; + } + return *this; + } + + NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs) + : NCursesMenuItem(rhs), + p_fct(0) + { + } + + virtual ~NCursesMenuCallbackItem() THROWS(NCursesException); + + bool action() NCURSES_OVERRIDE; +}; + + // This are the built-in hook functions in this C++ binding. In C++ we use + // virtual member functions (see below On_..._Init and On_..._Termination) + // to provide this functionality in an object oriented manner. +extern "C" { + void _nc_xx_mnu_init(MENU *); + void _nc_xx_mnu_term(MENU *); + void _nc_xx_itm_init(MENU *); + void _nc_xx_itm_term(MENU *); +} + +// +// ------------------------------------------------------------------------- +// This wraps the MENU type of +// ------------------------------------------------------------------------- +// +class NCURSES_CXX_IMPEXP NCursesMenu : public NCursesPanel +{ +protected: + MENU *menu; + +private: + NCursesWindow* sub; // the subwindow object + bool b_sub_owner; // is this our own subwindow? + bool b_framed; // has the menu a border? + bool b_autoDelete; // Delete items when deleting menu? + + NCursesMenuItem** my_items; // The array of items for this menu + + // This structure is used for the menu's user data field to link the + // MENU* to the C++ object and to provide extra space for a user pointer. + typedef struct { + void* m_user; // the pointer for the user's data + const NCursesMenu* m_back; // backward pointer to C++ object + const MENU* m_owner; + } UserHook; + + // Get the backward pointer to the C++ object from a MENU + static inline NCursesMenu* getHook(const MENU *m) { + UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m)); + assert(hook != 0 && hook->m_owner==m); + return const_cast(hook->m_back); + } + + friend void _nc_xx_mnu_init(MENU *); + friend void _nc_xx_mnu_term(MENU *); + friend void _nc_xx_itm_init(MENU *); + friend void _nc_xx_itm_term(MENU *); + + // Calculate ITEM* array for the menu + ITEM** mapItems(NCursesMenuItem* nitems[]); + +protected: + // internal routines + inline void set_user(void *user) { + UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu)); + assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); + uptr->m_user = user; + } + + inline void *get_user() { + UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu)); + assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); + return uptr->m_user; + } + + void InitMenu (NCursesMenuItem* menu[], + bool with_frame, + bool autoDeleteItems); + + inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) { + if (err != E_OK) + THROW(new NCursesMenuException (this, err)); + } + + // this wraps the menu_driver call. + virtual int driver (int c) ; + + // 'Internal' constructor to create a menu without association to + // an array of items. + NCursesMenu( int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0) + : NCursesPanel(nlines,ncols,begin_y,begin_x), + menu (STATIC_CAST(MENU*)(0)), + sub(0), + b_sub_owner(0), + b_framed(0), + b_autoDelete(0), + my_items(0) + { + } + +public: + // Make a full window size menu + NCursesMenu (NCursesMenuItem* Items[], + bool with_frame=FALSE, // Reserve space for a frame? + bool autoDelete_Items=FALSE) // Autocleanup of Items? + : NCursesPanel(), + menu(0), + sub(0), + b_sub_owner(0), + b_framed(0), + b_autoDelete(0), + my_items(0) + { + InitMenu(Items, with_frame, autoDelete_Items); + } + + // Make a menu with a window of this size. + NCursesMenu (NCursesMenuItem* Items[], + int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0, + bool with_frame=FALSE, // Reserve space for a frame? + bool autoDelete_Items=FALSE) // Autocleanup of Items? + : NCursesPanel(nlines, ncols, begin_y, begin_x), + menu(0), + sub(0), + b_sub_owner(0), + b_framed(0), + b_autoDelete(0), + my_items(0) + { + InitMenu(Items, with_frame, autoDelete_Items); + } + + NCursesMenu& operator=(const NCursesMenu& rhs) + { + if (this != &rhs) { + *this = rhs; + NCursesPanel::operator=(rhs); + } + return *this; + } + + NCursesMenu(const NCursesMenu& rhs) + : NCursesPanel(rhs), + menu(rhs.menu), + sub(rhs.sub), + b_sub_owner(rhs.b_sub_owner), + b_framed(rhs.b_framed), + b_autoDelete(rhs.b_autoDelete), + my_items(rhs.my_items) + { + } + + virtual ~NCursesMenu () THROWS(NCursesException); + + // Retrieve the menus subwindow + inline NCursesWindow& subWindow() const { + assert(sub!=NULL); + return *sub; + } + + // Set the menus subwindow + void setSubWindow(NCursesWindow& sub); + + // Set these items for the menu + inline void setItems(NCursesMenuItem* Items[]) { + OnError(::set_menu_items(menu,mapItems(Items))); + } + + // Remove the menu from the screen + inline void unpost (void) { + OnError (::unpost_menu (menu)); + } + + // Post the menu to the screen if flag is true, unpost it otherwise + inline void post(bool flag = TRUE) { + flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu)); + } + + // Get the number of rows and columns for this menu + inline void scale (int& mrows, int& mcols) const { + OnError (::scale_menu (menu, &mrows, &mcols)); + } + + // Set the format of this menu + inline void set_format(int mrows, int mcols) { + OnError (::set_menu_format(menu, mrows, mcols)); + } + + // Get the format of this menu + inline void menu_format(int& rows,int& ncols) { + ::menu_format(menu,&rows,&ncols); + } + + // Items of the menu + inline NCursesMenuItem* items() const { + return *my_items; + } + + // Get the number of items in this menu + inline int count() const { + return ::item_count(menu); + } + + // Get the current item (i.e. the one the cursor is located) + inline NCursesMenuItem* current_item() const { + return my_items[::item_index(::current_item(menu))]; + } + + // Get the marker string + inline const char* mark() const { + return ::menu_mark(menu); + } + + // Set the marker string + inline void set_mark(const char *marker) { + OnError (::set_menu_mark (menu, marker)); + } + + // Get the name of the request code c + inline static const char* request_name(int c) { + return ::menu_request_name(c); + } + + // Get the current pattern + inline char* pattern() const { + return ::menu_pattern(menu); + } + + // true if there is a pattern match, false otherwise. + bool set_pattern (const char *pat); + + // set the default attributes for the menu + // i.e. set fore, back and grey attribute + virtual void setDefaultAttributes(); + + // Get the menus background attributes + inline chtype back() const { + return ::menu_back(menu); + } + + // Get the menus foreground attributes + inline chtype fore() const { + return ::menu_fore(menu); + } + + // Get the menus grey attributes (used for unselectable items) + inline chtype grey() const { + return ::menu_grey(menu); + } + + // Set the menus background attributes + inline chtype set_background(chtype a) { + return ::set_menu_back(menu,a); + } + + // Set the menus foreground attributes + inline chtype set_foreground(chtype a) { + return ::set_menu_fore(menu,a); + } + + // Set the menus grey attributes (used for unselectable items) + inline chtype set_grey(chtype a) { + return ::set_menu_grey(menu,a); + } + + inline void options_on (Menu_Options opts) { + OnError (::menu_opts_on (menu,opts)); + } + + inline void options_off(Menu_Options opts) { + OnError (::menu_opts_off(menu,opts)); + } + + inline Menu_Options options() const { + return ::menu_opts(menu); + } + + inline void set_options (Menu_Options opts) { + OnError (::set_menu_opts (menu,opts)); + } + + inline int pad() const { + return ::menu_pad(menu); + } + + inline void set_pad (int padch) { + OnError (::set_menu_pad (menu, padch)); + } + + // Position the cursor to the current item + inline void position_cursor () const { + OnError (::pos_menu_cursor (menu)); + } + + // Set the current item + inline void set_current(NCursesMenuItem& I) { + OnError (::set_current_item(menu, I.item)); + } + + // Get the current top row of the menu + inline int top_row (void) const { + return ::top_row (menu); + } + + // Set the current top row of the menu + inline void set_top_row (int row) { + OnError (::set_top_row (menu, row)); + } + + // spacing control + // Set the spacing for the menu + inline void setSpacing(int spc_description, + int spc_rows, + int spc_columns) { + OnError(::set_menu_spacing(menu, + spc_description, + spc_rows, + spc_columns)); + } + + // Get the spacing info for the menu + inline void Spacing(int& spc_description, + int& spc_rows, + int& spc_columns) const { + OnError(::menu_spacing(menu, + &spc_description, + &spc_rows, + &spc_columns)); + } + + // Decorations + inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE { + if (b_framed) + NCursesPanel::frame(title,btitle); + else + OnError(E_SYSTEM_ERROR); + } + + inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE { + if (b_framed) + NCursesPanel::boldframe(title,btitle); + else + OnError(E_SYSTEM_ERROR); + } + + inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE { + if (b_framed) + NCursesPanel::label(topLabel,bottomLabel); + else + OnError(E_SYSTEM_ERROR); + } + + // ----- + // Hooks + // ----- + + // Called after the menu gets repositioned in its window. + // This is especially true if the menu is posted. + virtual void On_Menu_Init(); + + // Called before the menu gets repositioned in its window. + // This is especially true if the menu is unposted. + virtual void On_Menu_Termination(); + + // Called after the item became the current item + virtual void On_Item_Init(NCursesMenuItem& item); + + // Called before this item is left as current item. + virtual void On_Item_Termination(NCursesMenuItem& item); + + // Provide a default key virtualization. Translate the keyboard + // code c into a menu request code. + // The default implementation provides a hopefully straightforward + // mapping for the most common keystrokes and menu requests. + virtual int virtualize(int c); + + + // Operators + inline NCursesMenuItem* operator[](int i) const { + if ( (i < 0) || (i >= ::item_count (menu)) ) + OnError (E_BAD_ARGUMENT); + return (my_items[i]); + } + + // Perform the menu's operation + // Return the item where you left the selection mark for a single + // selection menu, or NULL for a multivalued menu. + virtual NCursesMenuItem* operator()(void); + + // -------------------- + // Exception handlers + // Called by operator() + // -------------------- + + // Called if the request is denied + virtual void On_Request_Denied(int c) const; + + // Called if the item is not selectable + virtual void On_Not_Selectable(int c) const; + + // Called if pattern doesn't match + virtual void On_No_Match(int c) const; + + // Called if the command is unknown + virtual void On_Unknown_Command(int c) const; + +}; +// +// ------------------------------------------------------------------------- +// This is the typical C++ typesafe way to allow to attach +// user data to an item of a menu. Its assumed that the user +// data belongs to some class T. Use T as template argument +// to create a UserItem. +// ------------------------------------------------------------------------- +// +template class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuItem +{ +public: + NCursesUserItem (const char* p_name, + const char* p_descript = NULL, + const T* p_UserData = STATIC_CAST(T*)(0)) + : NCursesMenuItem (p_name, p_descript) { + if (item) + OnError (::set_item_userptr (item, const_cast(reinterpret_cast(p_UserData)))); + } + + virtual ~NCursesUserItem() THROWS(NCursesException) {} + + inline const T* UserData (void) const { + return reinterpret_cast(::item_userptr (item)); + }; + + inline virtual void setUserData(const T* p_UserData) { + if (item) + OnError (::set_item_userptr (item, const_cast(reinterpret_cast(p_UserData)))); + } +}; +// +// ------------------------------------------------------------------------- +// The same mechanism is used to attach user data to a menu +// ------------------------------------------------------------------------- +// +template class NCURSES_CXX_IMPEXP NCursesUserMenu : public NCursesMenu +{ +protected: + NCursesUserMenu( int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0, + const T* p_UserData = STATIC_CAST(T*)(0)) + : NCursesMenu(nlines,ncols,begin_y,begin_x) { + if (menu) + set_user (const_cast(reinterpret_cast(p_UserData))); + } + +public: + NCursesUserMenu (NCursesMenuItem* Items[], + const T* p_UserData = STATIC_CAST(T*)(0), + bool with_frame=FALSE, + bool autoDelete_Items=FALSE) + : NCursesMenu (Items, with_frame, autoDelete_Items) { + if (menu) + set_user (const_cast(reinterpret_cast(p_UserData))); + }; + + NCursesUserMenu (NCursesMenuItem* Items[], + int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0, + const T* p_UserData = STATIC_CAST(T*)(0), + bool with_frame=FALSE) + : NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) { + if (menu) + set_user (const_cast(reinterpret_cast(p_UserData))); + }; + + virtual ~NCursesUserMenu() THROWS(NCursesException) { + }; + + inline T* UserData (void) { + return reinterpret_cast(get_user ()); + }; + + inline virtual void setUserData (const T* p_UserData) { + if (menu) + set_user (const_cast(reinterpret_cast(p_UserData))); + } +}; + +#endif /* NCURSES_CURSESM_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/cursesp.h b/illumos-x86_64/usr/include/ncurses/cursesp.h new file mode 100644 index 00000000..712253b1 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/cursesp.h @@ -0,0 +1,271 @@ +// * This makes emacs happy -*-Mode: C++;-*- +// vile:cppmode +/**************************************************************************** + * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 1998-2012,2014 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1997 * + ****************************************************************************/ + +#ifndef NCURSES_CURSESP_H_incl +#define NCURSES_CURSESP_H_incl 1 + +// $Id: cursesp.h,v 1.36 2022/08/20 20:52:15 tom Exp $ + +#include + +extern "C" { +# include +} + +class NCURSES_CXX_IMPEXP NCursesPanel + : public NCursesWindow +{ +protected: + PANEL *p; + static NCursesPanel *dummy; + +private: + // This structure is used for the panel's user data field to link the + // PANEL* to the C++ object and to provide extra space for a user pointer. + typedef struct { + void* m_user; // the pointer for the user's data + const NCursesPanel* m_back; // backward pointer to C++ object + const PANEL* m_owner; // the panel itself + } UserHook; + + inline UserHook *UserPointer() + { + UserHook* uptr = reinterpret_cast( + const_cast(::panel_userptr (p))); + return uptr; + } + + void init(); // Initialize the panel object + +protected: + void set_user(void *user) + { + UserHook* uptr = UserPointer(); + if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) { + uptr->m_user = user; + } + } + // Set the user pointer of the panel. + + void *get_user() + { + UserHook* uptr = UserPointer(); + void *result = 0; + if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) + result = uptr->m_user; + return result; + } + + void OnError (int err) const THROW2(NCursesException const, NCursesPanelException) + { + if (err==ERR) + THROW(new NCursesPanelException (this, err)); + } + // If err is equal to the curses error indicator ERR, an error handler + // is called. + + // Get a keystroke. Default implementation calls getch() + virtual int getKey(void); + +public: + NCursesPanel(int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0) + : NCursesWindow(nlines,ncols,begin_y,begin_x), p(0) + { + init(); + } + // Create a panel with this size starting at the requested position. + + NCursesPanel() + : NCursesWindow(::stdscr), p(0) + { + init(); + } + // This constructor creates the default Panel associated with the + // ::stdscr window + + NCursesPanel& operator=(const NCursesPanel& rhs) + { + if (this != &rhs) { + *this = rhs; + NCursesWindow::operator=(rhs); + } + return *this; + } + + NCursesPanel(const NCursesPanel& rhs) + : NCursesWindow(rhs), + p(rhs.p) + { + } + + virtual ~NCursesPanel() THROWS(NCursesException); + + // basic manipulation + inline void hide() + { + OnError (::hide_panel(p)); + } + // Hide the panel. It stays in the stack but becomes invisible. + + inline void show() + { + OnError (::show_panel(p)); + } + // Show the panel, i.e. make it visible. + + inline void top() + { + OnError (::top_panel(p)); + } + // Make this panel the top panel in the stack. + + inline void bottom() + { + OnError (::bottom_panel(p)); + } + // Make this panel the bottom panel in the stack. + // N.B.: The panel associated with ::stdscr is always on the bottom. So + // actually bottom() makes the panel the first above ::stdscr. + + virtual int mvwin(int y, int x) NCURSES_OVERRIDE + { + OnError(::move_panel(p, y, x)); + return OK; + } + + inline bool hidden() const + { + return (::panel_hidden (p) ? TRUE : FALSE); + } + // Return TRUE if the panel is hidden, FALSE otherwise. + +/* The functions panel_above() and panel_below() are not reflected in + the NCursesPanel class. The reason for this is, that we cannot + assume that a panel retrieved by those operations is one wrapped + by a C++ class. Although this situation might be handled, we also + need a reverse mapping from PANEL to NCursesPanel which needs some + redesign of the low level stuff. At the moment, we define them in the + interface but they will always produce an error. */ + inline NCursesPanel& above() const + { + OnError(ERR); + return *dummy; + } + + inline NCursesPanel& below() const + { + OnError(ERR); + return *dummy; + } + + // Those two are rewrites of the corresponding virtual members of + // NCursesWindow + virtual int refresh() NCURSES_OVERRIDE; + // Propagate all panel changes to the virtual screen and update the + // physical screen. + + virtual int noutrefresh() NCURSES_OVERRIDE; + // Propagate all panel changes to the virtual screen. + + static void redraw(); + // Redraw all panels. + + // decorations + virtual void frame(const char* title=NULL, + const char* btitle=NULL); + // Put a frame around the panel and put the title centered in the top line + // and btitle in the bottom line. + + virtual void boldframe(const char* title=NULL, + const char* btitle=NULL); + // Same as frame(), but use highlighted attributes. + + virtual void label(const char* topLabel, + const char* bottomLabel); + // Put the title centered in the top line and btitle in the bottom line. + + virtual void centertext(int row,const char* label); + // Put the label text centered in the specified row. +}; + +/* We use templates to provide a typesafe mechanism to associate + * user data with a panel. A NCursesUserPanel is a panel + * associated with some user data of type T. + */ +template class NCursesUserPanel : public NCursesPanel +{ +public: + NCursesUserPanel (int nlines, + int ncols, + int begin_y = 0, + int begin_x = 0, + const T* p_UserData = STATIC_CAST(T*)(0)) + : NCursesPanel (nlines, ncols, begin_y, begin_x) + { + if (p) + set_user (const_cast(reinterpret_cast + (p_UserData))); + }; + // This creates an user panel of the requested size with associated + // user data pointed to by p_UserData. + + explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel() + { + if (p) + set_user(const_cast(reinterpret_cast(p_UserData))); + }; + // This creates an user panel associated with the ::stdscr and user data + // pointed to by p_UserData. + + virtual ~NCursesUserPanel() THROWS(NCursesException) {}; + + T* UserData (void) + { + return reinterpret_cast(get_user ()); + }; + // Retrieve the user data associated with the panel. + + virtual void setUserData (const T* p_UserData) + { + if (p) + set_user (const_cast(reinterpret_cast(p_UserData))); + } + // Associate the user panel with the user data pointed to by p_UserData. +}; + +#endif /* NCURSES_CURSESP_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/cursesw.h b/illumos-x86_64/usr/include/ncurses/cursesw.h new file mode 100644 index 00000000..7da0d4de --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/cursesw.h @@ -0,0 +1,1581 @@ +// * This makes emacs happy -*-Mode: C++;-*- +// vile:cppmode +/**************************************************************************** + * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +#ifndef NCURSES_CURSESW_H_incl +#define NCURSES_CURSESW_H_incl 1 + +// $Id: cursesw.h,v 1.59 2022/08/20 20:52:15 tom Exp $ + +extern "C" { +# include +} + +#if defined(BUILDING_NCURSES_CXX) +# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT +#else +# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT +#endif + +#define NCURSES_CXX_WRAPPED_VAR(type,name) extern NCURSES_CXX_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) + +#define NCURSES_CXX_EXPORT(type) NCURSES_CXX_IMPEXP type NCURSES_API +#define NCURSES_CXX_EXPORT_VAR(type) NCURSES_CXX_IMPEXP type + +#include + +/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro. + Undefine it here, because NCursesWindow uses lines as a method. */ +#undef lines + +/* "Convert" macros to inlines. We'll define it as another symbol to avoid + * conflict with library symbols. + */ +#undef UNDEF +#define UNDEF(name) CUR_ ##name + +#ifdef addch +inline int UNDEF(addch)(chtype ch) { return addch(ch); } +#undef addch +#define addch UNDEF(addch) +#endif + +#ifdef addchstr +inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); } +#undef addchstr +#define addchstr UNDEF(addchstr) +#endif + +#ifdef addnstr +inline int UNDEF(addnstr)(const char *str, int n) +{ return addnstr(str, n); } +#undef addnstr +#define addnstr UNDEF(addnstr) +#endif + +#ifdef addstr +inline int UNDEF(addstr)(const char * str) { return addstr(str); } +#undef addstr +#define addstr UNDEF(addstr) +#endif + +#ifdef attroff +inline int UNDEF(attroff)(chtype at) { return attroff(at); } +#undef attroff +#define attroff UNDEF(attroff) +#endif + +#ifdef attron +inline int UNDEF(attron)(chtype at) { return attron(at); } +#undef attron +#define attron UNDEF(attron) +#endif + +#ifdef attrset +inline chtype UNDEF(attrset)(chtype at) { return attrset(at); } +#undef attrset +#define attrset UNDEF(attrset) +#endif + +#ifdef bkgd +inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); } +#undef bkgd +#define bkgd UNDEF(bkgd) +#endif + +#ifdef bkgdset +inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); } +#undef bkgdset +#define bkgdset UNDEF(bkgdset) +#endif + +#ifdef border +inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) +{ return border(ls, rs, ts, bs, tl, tr, bl, br); } +#undef border +#define border UNDEF(border) +#endif + +#ifdef box +inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); } +#undef box +#define box UNDEF(box) +#endif + +#ifdef chgat +inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) { + return chgat(n, attr, color, opts); } +#undef chgat +#define chgat UNDEF(chgat) +#endif + +#ifdef clear +inline int UNDEF(clear)() { return clear(); } +#undef clear +#define clear UNDEF(clear) +#endif + +#ifdef clearok +inline int UNDEF(clearok)(WINDOW* win, bool bf) { return clearok(win, bf); } +#undef clearok +#define clearok UNDEF(clearok) +#else +extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool); +#endif + +#ifdef clrtobot +inline int UNDEF(clrtobot)() { return clrtobot(); } +#undef clrtobot +#define clrtobot UNDEF(clrtobot) +#endif + +#ifdef clrtoeol +inline int UNDEF(clrtoeol)() { return clrtoeol(); } +#undef clrtoeol +#define clrtoeol UNDEF(clrtoeol) +#endif + +#ifdef color_set +inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); } +#undef color_set +#define color_set UNDEF(color_set) +#endif + +#ifdef crmode +inline int UNDEF(crmode)(void) { return crmode(); } +#undef crmode +#define crmode UNDEF(crmode) +#endif + +#ifdef delch +inline int UNDEF(delch)() { return delch(); } +#undef delch +#define delch UNDEF(delch) +#endif + +#ifdef deleteln +inline int UNDEF(deleteln)() { return deleteln(); } +#undef deleteln +#define deleteln UNDEF(deleteln) +#endif + +#ifdef echochar +inline int UNDEF(echochar)(chtype ch) { return echochar(ch); } +#undef echochar +#define echochar UNDEF(echochar) +#endif + +#ifdef erase +inline int UNDEF(erase)() { return erase(); } +#undef erase +#define erase UNDEF(erase) +#endif + +#ifdef fixterm +inline int UNDEF(fixterm)(void) { return fixterm(); } +#undef fixterm +#define fixterm UNDEF(fixterm) +#endif + +#ifdef flushok +inline int UNDEF(flushok)(WINDOW* _win, bool _bf) { + return flushok(_win, _bf); } +#undef flushok +#define flushok UNDEF(flushok) +#else +#define _no_flushok +#endif + +#ifdef getattrs +inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); } +#undef getattrs +#define getattrs UNDEF(getattrs) +#endif + +#ifdef getbegyx +inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); } +#undef getbegyx +#define getbegyx UNDEF(getbegyx) +#endif + +#ifdef getbkgd +inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); } +#undef getbkgd +#define getbkgd UNDEF(getbkgd) +#endif + +#ifdef getch +inline int UNDEF(getch)() { return getch(); } +#undef getch +#define getch UNDEF(getch) +#endif + +#ifdef getmaxyx +inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); } +#undef getmaxyx +#define getmaxyx UNDEF(getmaxyx) +#endif + +#ifdef getnstr +inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str, n); } +#undef getnstr +#define getnstr UNDEF(getnstr) +#endif + +#ifdef getparyx +inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); } +#undef getparyx +#define getparyx UNDEF(getparyx) +#endif + +#ifdef getstr +inline int UNDEF(getstr)(char *_str) { return getstr(_str); } +#undef getstr +#define getstr UNDEF(getstr) +#endif + +#ifdef getyx +inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) { + getyx(win, y, x); } +#undef getyx +#define getyx UNDEF(getyx) +#endif + +#ifdef hline +inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); } +#undef hline +#define hline UNDEF(hline) +#endif + +#ifdef inch +inline chtype UNDEF(inch)() { return inch(); } +#undef inch +#define inch UNDEF(inch) +#endif + +#ifdef inchstr +inline int UNDEF(inchstr)(chtype *str) { return inchstr(str); } +#undef inchstr +#define inchstr UNDEF(inchstr) +#endif + +#ifdef innstr +inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str, n); } +#undef innstr +#define innstr UNDEF(innstr) +#endif + +#ifdef insch +inline int UNDEF(insch)(chtype c) { return insch(c); } +#undef insch +#define insch UNDEF(insch) +#endif + +#ifdef insdelln +inline int UNDEF(insdelln)(int n) { return insdelln(n); } +#undef insdelln +#define insdelln UNDEF(insdelln) +#endif + +#ifdef insertln +inline int UNDEF(insertln)() { return insertln(); } +#undef insertln +#define insertln UNDEF(insertln) +#endif + +#ifdef insnstr +inline int UNDEF(insnstr)(const char *_str, int n) { + return insnstr(_str, n); } +#undef insnstr +#define insnstr UNDEF(insnstr) +#endif + +#ifdef insstr +inline int UNDEF(insstr)(const char *_str) { + return insstr(_str); } +#undef insstr +#define insstr UNDEF(insstr) +#endif + +#ifdef instr +inline int UNDEF(instr)(char *_str) { return instr(_str); } +#undef instr +#define instr UNDEF(instr) +#endif + +#ifdef intrflush +inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); } +#undef intrflush +#define intrflush UNDEF(intrflush) +#endif + +#ifdef is_linetouched +inline int UNDEF(is_linetouched)(WINDOW *w, int l) { return is_linetouched(w,l); } +#undef is_linetouched +#define is_linetouched UNDEF(is_linetouched) +#endif + +#ifdef leaveok +inline int UNDEF(leaveok)(WINDOW* win, bool bf) { return leaveok(win, bf); } +#undef leaveok +#define leaveok UNDEF(leaveok) +#else +extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf); +#endif + +#ifdef move +inline int UNDEF(move)(int x, int y) { return move(x, y); } +#undef move +#define move UNDEF(move) +#endif + +#ifdef mvaddch +inline int UNDEF(mvaddch)(int y, int x, chtype ch) +{ return mvaddch(y, x, ch); } +#undef mvaddch +#define mvaddch UNDEF(mvaddch) +#endif + +#ifdef mvaddnstr +inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n) +{ return mvaddnstr(y, x, str, n); } +#undef mvaddnstr +#define mvaddnstr UNDEF(mvaddnstr) +#endif + +#ifdef mvaddstr +inline int UNDEF(mvaddstr)(int y, int x, const char * str) +{ return mvaddstr(y, x, str); } +#undef mvaddstr +#define mvaddstr UNDEF(mvaddstr) +#endif + +#ifdef mvchgat +inline int UNDEF(mvchgat)(int y, int x, int n, + attr_t attr, NCURSES_PAIRS_T color, const void *opts) { + return mvchgat(y, x, n, attr, color, opts); } +#undef mvchgat +#define mvchgat UNDEF(mvchgat) +#endif + +#ifdef mvdelch +inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);} +#undef mvdelch +#define mvdelch UNDEF(mvdelch) +#endif + +#ifdef mvgetch +inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);} +#undef mvgetch +#define mvgetch UNDEF(mvgetch) +#endif + +#ifdef mvgetnstr +inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) { + return mvgetnstr(y, x, str, n);} +#undef mvgetnstr +#define mvgetnstr UNDEF(mvgetnstr) +#endif + +#ifdef mvgetstr +inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);} +#undef mvgetstr +#define mvgetstr UNDEF(mvgetstr) +#endif + +#ifdef mvinch +inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);} +#undef mvinch +#define mvinch UNDEF(mvinch) +#endif + +#ifdef mvinnstr +inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) { + return mvinnstr(y, x, _str, n); } +#undef mvinnstr +#define mvinnstr UNDEF(mvinnstr) +#endif + +#ifdef mvinsch +inline int UNDEF(mvinsch)(int y, int x, chtype c) +{ return mvinsch(y, x, c); } +#undef mvinsch +#define mvinsch UNDEF(mvinsch) +#endif + +#ifdef mvinsnstr +inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) { + return mvinsnstr(y, x, _str, n); } +#undef mvinsnstr +#define mvinsnstr UNDEF(mvinsnstr) +#endif + +#ifdef mvinsstr +inline int UNDEF(mvinsstr)(int y, int x, const char *_str) { + return mvinsstr(y, x, _str); } +#undef mvinsstr +#define mvinsstr UNDEF(mvinsstr) +#endif + +#ifdef mvwaddch +inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch) +{ return mvwaddch(win, y, x, ch); } +#undef mvwaddch +#define mvwaddch UNDEF(mvwaddch) +#endif + +#ifdef mvwaddchnstr +inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n) +{ return mvwaddchnstr(win, y, x, str, n); } +#undef mvwaddchnstr +#define mvwaddchnstr UNDEF(mvwaddchnstr) +#endif + +#ifdef mvwaddchstr +inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str) +{ return mvwaddchstr(win, y, x, str); } +#undef mvwaddchstr +#define mvwaddchstr UNDEF(mvwaddchstr) +#endif + +#ifdef mvwaddnstr +inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n) +{ return mvwaddnstr(win, y, x, str, n); } +#undef mvwaddnstr +#define mvwaddnstr UNDEF(mvwaddnstr) +#endif + +#ifdef mvwaddstr +inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str) +{ return mvwaddstr(win, y, x, str); } +#undef mvwaddstr +#define mvwaddstr UNDEF(mvwaddstr) +#endif + +#ifdef mvwchgat +inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n, + attr_t attr, NCURSES_PAIRS_T color, const void *opts) { + return mvwchgat(win, y, x, n, attr, color, opts); } +#undef mvwchgat +#define mvwchgat UNDEF(mvwchgat) +#endif + +#ifdef mvwdelch +inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x) +{ return mvwdelch(win, y, x); } +#undef mvwdelch +#define mvwdelch UNDEF(mvwdelch) +#endif + +#ifdef mvwgetch +inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);} +#undef mvwgetch +#define mvwgetch UNDEF(mvwgetch) +#endif + +#ifdef mvwgetnstr +inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n) +{return mvwgetnstr(win, y, x, str, n);} +#undef mvwgetnstr +#define mvwgetnstr UNDEF(mvwgetnstr) +#endif + +#ifdef mvwgetstr +inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str) +{return mvwgetstr(win, y, x, str);} +#undef mvwgetstr +#define mvwgetstr UNDEF(mvwgetstr) +#endif + +#ifdef mvwhline +inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) { + return mvwhline(win, y, x, c, n); } +#undef mvwhline +#define mvwhline UNDEF(mvwhline) +#endif + +#ifdef mvwinch +inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) { + return mvwinch(win, y, x);} +#undef mvwinch +#define mvwinch UNDEF(mvwinch) +#endif + +#ifdef mvwinchnstr +inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n) { return mvwinchnstr(win, y, x, str, n); } +#undef mvwinchnstr +#define mvwinchnstr UNDEF(mvwinchnstr) +#endif + +#ifdef mvwinchstr +inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str) { return mvwinchstr(win, y, x, str); } +#undef mvwinchstr +#define mvwinchstr UNDEF(mvwinchstr) +#endif + +#ifdef mvwinnstr +inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) { + return mvwinnstr(win, y, x, _str, n); } +#undef mvwinnstr +#define mvwinnstr UNDEF(mvwinnstr) +#endif + +#ifdef mvwinsch +inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c) +{ return mvwinsch(win, y, x, c); } +#undef mvwinsch +#define mvwinsch UNDEF(mvwinsch) +#endif + +#ifdef mvwinsnstr +inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) { + return mvwinsnstr(w, y, x, _str, n); } +#undef mvwinsnstr +#define mvwinsnstr UNDEF(mvwinsnstr) +#endif + +#ifdef mvwinsstr +inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) { + return mvwinsstr(w, y, x, _str); } +#undef mvwinsstr +#define mvwinsstr UNDEF(mvwinsstr) +#endif + +#ifdef mvwvline +inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) { + return mvwvline(win, y, x, c, n); } +#undef mvwvline +#define mvwvline UNDEF(mvwvline) +#endif + +#ifdef napms +inline void UNDEF(napms)(unsigned long x) { napms(x); } +#undef napms +#define napms UNDEF(napms) +#endif + +#ifdef nocrmode +inline int UNDEF(nocrmode)(void) { return nocrmode(); } +#undef nocrmode +#define nocrmode UNDEF(nocrmode) +#endif + +#ifdef nodelay +inline void UNDEF(nodelay)() { nodelay(); } +#undef nodelay +#define nodelay UNDEF(nodelay) +#endif + +#ifdef redrawwin +inline int UNDEF(redrawwin)(WINDOW *win) { return redrawwin(win); } +#undef redrawwin +#define redrawwin UNDEF(redrawwin) +#endif + +#ifdef refresh +inline int UNDEF(refresh)() { return refresh(); } +#undef refresh +#define refresh UNDEF(refresh) +#endif + +#ifdef resetterm +inline int UNDEF(resetterm)(void) { return resetterm(); } +#undef resetterm +#define resetterm UNDEF(resetterm) +#endif + +#ifdef saveterm +inline int UNDEF(saveterm)(void) { return saveterm(); } +#undef saveterm +#define saveterm UNDEF(saveterm) +#endif + +#ifdef scrl +inline int UNDEF(scrl)(int l) { return scrl(l); } +#undef scrl +#define scrl UNDEF(scrl) +#endif + +#ifdef scroll +inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); } +#undef scroll +#define scroll UNDEF(scroll) +#endif + +#ifdef scrollok +inline int UNDEF(scrollok)(WINDOW* win, bool bf) { return scrollok(win, bf); } +#undef scrollok +#define scrollok UNDEF(scrollok) +#else +#if defined(__NCURSES_H) +extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool); +#else +extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char); +#endif +#endif + +#ifdef setscrreg +inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); } +#undef setscrreg +#define setscrreg UNDEF(setscrreg) +#endif + +#ifdef standend +inline int UNDEF(standend)() { return standend(); } +#undef standend +#define standend UNDEF(standend) +#endif + +#ifdef standout +inline int UNDEF(standout)() { return standout(); } +#undef standout +#define standout UNDEF(standout) +#endif + +#ifdef subpad +inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x) +{ return derwin(p, l, c, y, x); } +#undef subpad +#define subpad UNDEF(subpad) +#endif + +#ifdef timeout +inline void UNDEF(timeout)(int delay) { timeout(delay); } +#undef timeout +#define timeout UNDEF(timeout) +#endif + +#ifdef touchline +inline int UNDEF(touchline)(WINDOW *win, int s, int c) +{ return touchline(win, s, c); } +#undef touchline +#define touchline UNDEF(touchline) +#endif + +#ifdef touchwin +inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); } +#undef touchwin +#define touchwin UNDEF(touchwin) +#endif + +#ifdef untouchwin +inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); } +#undef untouchwin +#define untouchwin UNDEF(untouchwin) +#endif + +#ifdef vline +inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); } +#undef vline +#define vline UNDEF(vline) +#endif + +#ifdef waddchstr +inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); } +#undef waddchstr +#define waddchstr UNDEF(waddchstr) +#endif + +#ifdef waddstr +inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); } +#undef waddstr +#define waddstr UNDEF(waddstr) +#endif + +#ifdef wattroff +inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); } +#undef wattroff +#define wattroff UNDEF(wattroff) +#endif + +#ifdef wattrset +inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); } +#undef wattrset +#define wattrset UNDEF(wattrset) +#endif + +#ifdef winch +inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); } +#undef winch +#define winch UNDEF(winch) +#endif + +#ifdef winchnstr +inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n) { return winchnstr(win, str, n); } +#undef winchnstr +#define winchnstr UNDEF(winchnstr) +#endif + +#ifdef winchstr +inline int UNDEF(winchstr)(WINDOW *win, chtype *str) { return winchstr(win, str); } +#undef winchstr +#define winchstr UNDEF(winchstr) +#endif + +#ifdef winsstr +inline int UNDEF(winsstr)(WINDOW *w, const char *_str) { + return winsstr(w, _str); } +#undef winsstr +#define winsstr UNDEF(winsstr) +#endif + +#ifdef wstandend +inline int UNDEF(wstandend)(WINDOW *win) { return wstandend(win); } +#undef wstandend +#define wstandend UNDEF(wstandend) +#endif + +#ifdef wstandout +inline int UNDEF(wstandout)(WINDOW *win) { return wstandout(win); } +#undef wstandout +#define wstandout UNDEF(wstandout) +#endif + +/* + * + * C++ class for windows. + * + */ + +extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int)); +extern "C" int _nc_xx_ripoff_init(WINDOW *, int); +extern "C" int _nc_has_mouse(void); + +class NCURSES_CXX_IMPEXP NCursesWindow +{ + friend class NCursesMenu; + friend class NCursesForm; + +private: + static bool b_initialized; + static void initialize(); + void constructing(); + friend int _nc_xx_ripoff_init(WINDOW *, int); + + void set_keyboard(); + + NCURSES_COLOR_T getcolor(int getback) const; + NCURSES_PAIRS_T getPair() const; + + static int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair); + static int colorInitialized; + + // This private constructor is only used during the initialization + // of windows generated by ripoffline() calls. + NCursesWindow(WINDOW* win, int ncols); + +protected: + virtual void err_handler(const char *) const THROWS(NCursesException); + // Signal an error with the given message text. + + static long count; // count of all active windows: + // We rely on the c++ promise that + // all otherwise uninitialized + // static class vars are set to 0 + + WINDOW* w; // the curses WINDOW + + bool alloced; // TRUE if we own the WINDOW + + NCursesWindow* par; // parent, if subwindow + NCursesWindow* subwins; // head of subwindows list + NCursesWindow* sib; // next subwindow of parent + + void kill_subwindows(); // disable all subwindows + // Destroy all subwindows. + + /* Only for use by derived classes. They are then in charge to + fill the member variables correctly. */ + NCursesWindow(); + +public: + explicit NCursesWindow(WINDOW* window); // useful only for stdscr + + NCursesWindow(int nlines, // number of lines + int ncols, // number of columns + int begin_y, // line origin + int begin_x); // col origin + + NCursesWindow(NCursesWindow& par,// parent window + int nlines, // number of lines + int ncols, // number of columns + int begin_y, // absolute or relative + int begin_x, // origins: + char absrel = 'a');// if `a', begin_y & begin_x are + // absolute screen pos, else if `r', they are relative to par origin + + NCursesWindow(NCursesWindow& par,// parent window + bool do_box = TRUE); + // this is the very common case that we want to create the subwindow that + // is two lines and two columns smaller and begins at (1,1). + // We may automatically request the box around it. + + NCursesWindow& operator=(const NCursesWindow& rhs) + { + if (this != &rhs) + *this = rhs; + return *this; + } + + NCursesWindow(const NCursesWindow& rhs) + : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib) + { + } + + virtual ~NCursesWindow() THROWS(NCursesException); + + NCursesWindow Clone(); + // Make an exact copy of the window. + + // Initialization. + static void useColors(void); + // Call this routine very early if you want to have colors. + + static int ripoffline(int ripoff_lines, + int (*init)(NCursesWindow& win)); + // This function is used to generate a window of ripped-of lines. + // If the argument is positive, lines are removed from the top, if it + // is negative lines are removed from the bottom. This enhances the + // lowlevel ripoffline() function because it uses the internal + // implementation that allows to remove more than just a single line. + // This function must be called before any other ncurses function. The + // creation of the window is deferred until ncurses gets initialized. + // The initialization function is then called. + + // ------------------------------------------------------------------------- + // terminal status + // ------------------------------------------------------------------------- + int lines() const { initialize(); return LINES; } + // Number of lines on terminal, *not* window + + int cols() const { initialize(); return COLS; } + // Number of cols on terminal, *not* window + + int tabsize() const { initialize(); return TABSIZE; } + // Size of a tab on terminal, *not* window + + static int NumberOfColors(); + // Number of available colors + + int colors() const { return NumberOfColors(); } + // Number of available colors + + // ------------------------------------------------------------------------- + // window status + // ------------------------------------------------------------------------- + int height() const { return maxy() + 1; } + // Number of lines in this window + + int width() const { return maxx() + 1; } + // Number of columns in this window + + int begx() const { return getbegx(w); } + // Column of top left corner relative to stdscr + + int begy() const { return getbegy(w); } + // Line of top left corner relative to stdscr + + int curx() const { return getcurx(w); } + // Column of top left corner relative to stdscr + + int cury() const { return getcury(w); } + // Line of top left corner relative to stdscr + + int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; } + // Largest x coord in window + + int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; } + // Largest y coord in window + + NCURSES_PAIRS_T getcolor() const; + // Actual color pair + + NCURSES_COLOR_T foreground() const { return getcolor(0); } + // Actual foreground color + + NCURSES_COLOR_T background() const { return getcolor(1); } + // Actual background color + + int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back); + // Set color palette entry + + int setcolor(NCURSES_PAIRS_T pair); + // Set actually used palette entry + + // ------------------------------------------------------------------------- + // window positioning + // ------------------------------------------------------------------------- + virtual int mvwin(int begin_y, int begin_x) { + return ::mvwin(w, begin_y, begin_x); } + // Move window to new position with the new position as top left corner. + // This is virtual because it is redefined in NCursesPanel. + + // ------------------------------------------------------------------------- + // coordinate positioning + // ------------------------------------------------------------------------- + int move(int y, int x) { return ::wmove(w, y, x); } + // Move cursor the this position + + void getyx(int& y, int& x) const { ::getyx(w, y, x); } + // Get current position of the cursor + + void getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); } + // Get beginning of the window + + void getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); } + // Get size of the window + + void getparyx(int& y, int& x) const { ::getparyx(w, y, x); } + // Get parent's beginning of the window + + int mvcur(int oldrow, int oldcol, int newrow, int newcol) const { + return ::mvcur(oldrow, oldcol, newrow, newcol); } + // Perform lowlevel cursor motion that takes effect immediately. + + // ------------------------------------------------------------------------- + // input + // ------------------------------------------------------------------------- + int getch() { return ::wgetch(w); } + // Get a keystroke from the window. + + int getch(int y, int x) { return ::mvwgetch(w, y, x); } + // Move cursor to position and get a keystroke from the window + + int getstr(char* str, int n=-1) { + return ::wgetnstr(w, str, n); } + // Read a series of characters into str until a newline or carriage return + // is received. Read at most n characters. If n is negative, the limit is + // ignored. + + int getstr(int y, int x, char* str, int n=-1) { + return ::mvwgetnstr(w, y, x, str, n); } + // Move the cursor to the requested position and then perform the getstr() + // as described above. + + int instr(char *s, int n=-1) { return ::winnstr(w, s, n); } + // Get a string of characters from the window into the buffer s. Retrieve + // at most n characters, if n is negative retrieve all characters up to the + // end of the current line. Attributes are stripped from the characters. + + int instr(int y, int x, char *s, int n=-1) { + return ::mvwinnstr(w, y, x, s, n); } + // Move the cursor to the requested position and then perform the instr() + // as described above. + + int scanw(const char* fmt, ...) + // Perform a scanw function from the window. +#if __GNUG__ >= 2 + __attribute__ ((format (scanf, 2, 3))); +#else + ; +#endif + + int scanw(const char*, va_list); + // Perform a scanw function from the window. + + int scanw(int y, int x, const char* fmt, ...) + // Move the cursor to the requested position and then perform a scanw + // from the window. +#if __GNUG__ >= 2 + __attribute__ ((format (scanf, 4, 5))); +#else + ; +#endif + + int scanw(int y, int x, const char* fmt, va_list); + // Move the cursor to the requested position and then perform a scanw + // from the window. + + // ------------------------------------------------------------------------- + // output + // ------------------------------------------------------------------------- + int addch(const chtype ch) { return ::waddch(w, ch); } + // Put attributed character to the window. + + int addch(int y, int x, const chtype ch) { + return ::mvwaddch(w, y, x, ch); } + // Move cursor to the requested position and then put attributed character + // to the window. + + int echochar(const chtype ch) { return ::wechochar(w, ch); } + // Put attributed character to the window and refresh it immediately. + + int addstr(const char* str, int n=-1) { + return ::waddnstr(w, str, n); } + // Write the string str to the window, stop writing if the terminating + // NUL or the limit n is reached. If n is negative, it is ignored. + + int addstr(int y, int x, const char * str, int n=-1) { + return ::mvwaddnstr(w, y, x, str, n); } + // Move the cursor to the requested position and then perform the addchstr + // as described above. + + int addchstr(const chtype* str, int n=-1) { + return ::waddchnstr(w, str, n); } + // Write the string str to the window, stop writing if the terminating + // NUL or the limit n is reached. If n is negative, it is ignored. + + int addchstr(int y, int x, const chtype * str, int n=-1) { + return ::mvwaddchnstr(w, y, x, str, n); } + // Move the cursor to the requested position and then perform the addchstr + // as described above. + + int printw(const char* fmt, ...) + // Do a formatted print to the window. +#if (__GNUG__ >= 2) && !defined(printf) + __attribute__ ((format (printf, 2, 3))); +#else + ; +#endif + + int printw(int y, int x, const char * fmt, ...) + // Move the cursor and then do a formatted print to the window. +#if (__GNUG__ >= 2) && !defined(printf) + __attribute__ ((format (printf, 4, 5))); +#else + ; +#endif + + int printw(const char* fmt, va_list args); + // Do a formatted print to the window. + + int printw(int y, int x, const char * fmt, va_list args); + // Move the cursor and then do a formatted print to the window. + + chtype inch() const { return ::winch(w); } + // Retrieve attributed character under the current cursor position. + + chtype inch(int y, int x) { return ::mvwinch(w, y, x); } + // Move cursor to requested position and then retrieve attributed character + // at this position. + + int inchstr(chtype* str, int n=-1) { + return ::winchnstr(w, str, n); } + // Read the string str from the window, stop reading if the terminating + // NUL or the limit n is reached. If n is negative, it is ignored. + + int inchstr(int y, int x, chtype * str, int n=-1) { + return ::mvwinchnstr(w, y, x, str, n); } + // Move the cursor to the requested position and then perform the inchstr + // as described above. + + int insch(chtype ch) { return ::winsch(w, ch); } + // Insert attributed character into the window before current cursor + // position. + + int insch(int y, int x, chtype ch) { + return ::mvwinsch(w, y, x, ch); } + // Move cursor to requested position and then insert the attributed + // character before that position. + + int insertln() { return ::winsdelln(w, 1); } + // Insert an empty line above the current line. + + int insdelln(int n=1) { return ::winsdelln(w, n); } + // If n>0 insert that many lines above the current line. If n<0 delete + // that many lines beginning with the current line. + + int insstr(const char *s, int n=-1) { + return ::winsnstr(w, s, n); } + // Insert the string into the window before the current cursor position. + // Insert stops at end of string or when the limit n is reached. If n is + // negative, it is ignored. + + int insstr(int y, int x, const char *s, int n=-1) { + return ::mvwinsnstr(w, y, x, s, n); } + // Move the cursor to the requested position and then perform the insstr() + // as described above. + + int attron (chtype at) { return ::wattron (w, at); } + // Switch on the window attributes; + + int attroff(chtype at) { return ::wattroff(w, static_cast(at)); } + // Switch off the window attributes; + + int attrset(chtype at) { return ::wattrset(w, static_cast(at)); } + // Set the window attributes; + + chtype attrget() { return ::getattrs(w); } + // Get the window attributes; + + int color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) { + return ::wcolor_set(w, color_pair_number, opts); } + // Set the window color attribute; + + int chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) { + return ::wchgat(w, n, attr, color, opts); } + // Change the attributes of the next n characters in the current line. If + // n is negative or greater than the number of remaining characters in the + // line, the attributes will be changed up to the end of the line. + + int chgat(int y, int x, + int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) { + return ::mvwchgat(w, y, x, n, attr, color, opts); } + // Move the cursor to the requested position and then perform chgat() as + // described above. + + // ------------------------------------------------------------------------- + // background + // ------------------------------------------------------------------------- + chtype getbkgd() const { return ::getbkgd(w); } + // Get current background setting. + + int bkgd(const chtype ch) { return ::wbkgd(w, ch); } + // Set the background property and apply it to the window. + + void bkgdset(chtype ch) { ::wbkgdset(w, ch); } + // Set the background property. + + // ------------------------------------------------------------------------- + // borders + // ------------------------------------------------------------------------- + int box(chtype vert=0, chtype hor=0) { + return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); } + // Draw a box around the window with the given vertical and horizontal + // drawing characters. If you specify a zero as character, curses will try + // to find a "nice" character. + + int border(chtype left=0, chtype right=0, + chtype top =0, chtype bottom=0, + chtype top_left =0, chtype top_right=0, + chtype bottom_left =0, chtype bottom_right=0) { + return ::wborder(w, left, right, top, bottom, top_left, top_right, + bottom_left, bottom_right); } + // Draw a border around the window with the given characters for the + // various parts of the border. If you pass zero for a character, curses + // will try to find "nice" characters. + + // ------------------------------------------------------------------------- + // lines and boxes + // ------------------------------------------------------------------------- + int hline(int len, chtype ch=0) { return ::whline(w, ch, len); } + // Draw a horizontal line of len characters with the given character. If + // you pass zero for the character, curses will try to find a "nice" one. + + int hline(int y, int x, int len, chtype ch=0) { + return ::mvwhline(w, y, x, ch, len); } + // Move the cursor to the requested position and then draw a horizontal line. + + int vline(int len, chtype ch=0) { return ::wvline(w, ch, len); } + // Draw a vertical line of len characters with the given character. If + // you pass zero for the character, curses will try to find a "nice" one. + + int vline(int y, int x, int len, chtype ch=0) { + return ::mvwvline(w, y, x, ch, len); } + // Move the cursor to the requested position and then draw a vertical line. + + // ------------------------------------------------------------------------- + // erasure + // ------------------------------------------------------------------------- + int erase() { return ::werase(w); } + // Erase the window. + + int clear() { return ::wclear(w); } + // Clear the window. + + int clearok(bool bf) { return ::clearok(w, bf); } + // Set/Reset the clear flag. If set, the next refresh() will clear the + // screen. + + int clrtobot() { return ::wclrtobot(w); } + // Clear to the end of the window. + + int clrtoeol() { return ::wclrtoeol(w); } + // Clear to the end of the line. + + int delch() { return ::wdelch(w); } + // Delete character under the cursor. + + int delch(int y, int x) { return ::mvwdelch(w, y, x); } + // Move cursor to requested position and delete the character under the + // cursor. + + int deleteln() { return ::winsdelln(w, -1); } + // Delete the current line. + + // ------------------------------------------------------------------------- + // screen control + // ------------------------------------------------------------------------- + int scroll(int amount=1) { return ::wscrl(w, amount); } + // Scroll amount lines. If amount is positive, scroll up, otherwise + // scroll down. + + int scrollok(bool bf) { return ::scrollok(w, bf); } + // If bf is TRUE, window scrolls if cursor is moved off the bottom + // edge of the window or a scrolling region, otherwise the cursor is left + // at the bottom line. + + int setscrreg(int from, int to) { + return ::wsetscrreg(w, from, to); } + // Define a soft scrolling region. + + int idlok(bool bf) { return ::idlok(w, bf); } + // If bf is TRUE, use insert/delete line hardware support if possible. + // Otherwise do it in software. + + void idcok(bool bf) { ::idcok(w, bf); } + // If bf is TRUE, use insert/delete character hardware support if possible. + // Otherwise do it in software. + + int touchline(int s, int c) { return ::touchline(w, s, c); } + // Mark the given lines as modified. + + int touchwin() { return ::wtouchln(w, 0, height(), 1); } + // Mark the whole window as modified. + + int untouchwin() { return ::wtouchln(w, 0, height(), 0); } + // Mark the whole window as unmodified. + + int touchln(int s, int cnt, bool changed=TRUE) { + return ::wtouchln(w, s, cnt, static_cast(changed ? 1 : 0)); } + // Mark cnt lines beginning from line s as changed or unchanged, depending + // on the value of the changed flag. + + bool is_linetouched(int line) const { + return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); } + // Return TRUE if line is marked as changed, FALSE otherwise + + bool is_wintouched() const { + return (::is_wintouched(w) ? TRUE:FALSE); } + // Return TRUE if window is marked as changed, FALSE otherwise + + int leaveok(bool bf) { return ::leaveok(w, bf); } + // If bf is TRUE, curses will leave the cursor after an update wherever + // it is after the update. + + int redrawln(int from, int n) { return ::wredrawln(w, from, n); } + // Redraw n lines starting from the requested line + + int redrawwin() { return ::wredrawln(w, 0, height()); } + // Redraw the whole window + + int doupdate() { return ::doupdate(); } + // Do all outputs to make the physical screen looking like the virtual one + + void syncdown() { ::wsyncdown(w); } + // Propagate the changes down to all descendant windows + + void syncup() { ::wsyncup(w); } + // Propagate the changes up in the hierarchy + + void cursyncup() { ::wcursyncup(w); } + // Position the cursor in all ancestor windows corresponding to our setting + + int syncok(bool bf) { return ::syncok(w, bf); } + // If called with bf=TRUE, syncup() is called whenever the window is changed + +#ifndef _no_flushok + int flushok(bool bf) { return ::flushok(w, bf); } +#endif + + void immedok(bool bf) { ::immedok(w, bf); } + // If called with bf=TRUE, any change in the window will cause an + // automatic immediate refresh() + + int intrflush(bool bf) { return ::intrflush(w, bf); } + + int keypad(bool bf) { return ::keypad(w, bf); } + // If called with bf=TRUE, the application will interpret function keys. + + int nodelay(bool bf) { return ::nodelay(w, bf); } + + int meta(bool bf) { return ::meta(w, bf); } + // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise + // 7-Bit characters are generated. + + int standout() { return ::wstandout(w); } + // Enable "standout" attributes + + int standend() { return ::wstandend(w); } + // Disable "standout" attributes + + // ------------------------------------------------------------------------- + // The next two are virtual, because we redefine them in the + // NCursesPanel class. + // ------------------------------------------------------------------------- + virtual int refresh() { return ::wrefresh(w); } + // Propagate the changes in this window to the virtual screen and call + // doupdate(). This is redefined in NCursesPanel. + + virtual int noutrefresh() { return ::wnoutrefresh(w); } + // Propagate the changes in this window to the virtual screen. This is + // redefined in NCursesPanel. + + // ------------------------------------------------------------------------- + // multiple window control + // ------------------------------------------------------------------------- + int overlay(NCursesWindow& win) { + return ::overlay(w, win.w); } + // Overlay this window over win. + + int overwrite(NCursesWindow& win) { + return ::overwrite(w, win.w); } + // Overwrite win with this window. + + int copywin(NCursesWindow& win, + int sminrow, int smincol, + int dminrow, int dmincol, + int dmaxrow, int dmaxcol, bool overlaywin=TRUE) { + return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol, + dmaxrow, dmaxcol, static_cast(overlaywin ? 1 : 0)); } + // Overlay or overwrite the rectangle in win given by dminrow,dmincol, + // dmaxrow,dmaxcol with the rectangle in this window beginning at + // sminrow,smincol. + + // ------------------------------------------------------------------------- + // Extended functions + // ------------------------------------------------------------------------- +#if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0) + int wresize(int newLines, int newColumns) { + return ::wresize(w, newLines, newColumns); } +#endif + + // ------------------------------------------------------------------------- + // Mouse related + // ------------------------------------------------------------------------- + bool has_mouse() const; + // Return TRUE if terminal supports a mouse, FALSE otherwise + + // ------------------------------------------------------------------------- + // traversal support + // ------------------------------------------------------------------------- + NCursesWindow* child() { return subwins; } + // Get the first child window. + + NCursesWindow* sibling() { return sib; } + // Get the next child of my parent. + + NCursesWindow* parent() { return par; } + // Get my parent. + + bool isDescendant(NCursesWindow& win); + // Return TRUE if win is a descendant of this. +}; + +// ------------------------------------------------------------------------- +// We leave this here for compatibility reasons. +// ------------------------------------------------------------------------- +class NCURSES_CXX_IMPEXP NCursesColorWindow : public NCursesWindow +{ +public: + explicit NCursesColorWindow(WINDOW* &window) // useful only for stdscr + : NCursesWindow(window) { + useColors(); } + + NCursesColorWindow(int nlines, // number of lines + int ncols, // number of columns + int begin_y, // line origin + int begin_x) // col origin + : NCursesWindow(nlines, ncols, begin_y, begin_x) { + useColors(); } + + NCursesColorWindow(NCursesWindow& parentWin,// parent window + int nlines, // number of lines + int ncols, // number of columns + int begin_y, // absolute or relative + int begin_x, // origins: + char absrel = 'a') // if `a', by & bx are + : NCursesWindow(parentWin, + nlines, ncols, // absolute screen pos, + begin_y, begin_x, // else if `r', they are + absrel ) { // relative to par origin + useColors(); } +}; + +// These enum definitions really belong inside the NCursesPad class, but only +// recent compilers support that feature. + + typedef enum { + REQ_PAD_REFRESH = KEY_MAX + 1, + REQ_PAD_UP, + REQ_PAD_DOWN, + REQ_PAD_LEFT, + REQ_PAD_RIGHT, + REQ_PAD_EXIT + } Pad_Request; + + const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code + const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code + +// ------------------------------------------------------------------------- +// Pad Support. We allow an association of a pad with a "real" window +// through which the pad may be viewed. +// ------------------------------------------------------------------------- +class NCURSES_CXX_IMPEXP NCursesPad : public NCursesWindow +{ +private: + NCursesWindow* viewWin; // the "viewport" window + NCursesWindow* viewSub; // the "viewport" subwindow + + int h_gridsize, v_gridsize; + +protected: + int min_row, min_col; // top left row/col of the pads display area + + NCursesWindow* Win(void) const { + // Get the window into which the pad should be copied (if any) + return (viewSub?viewSub:(viewWin?viewWin:0)); + } + + NCursesWindow* getWindow(void) const { + return viewWin; + } + + NCursesWindow* getSubWindow(void) const { + return viewSub; + } + + virtual int driver (int key); // Virtualize keystroke key + // The driver translates the keystroke c into an Pad_Request + + virtual void OnUnknownOperation(int pad_req) { + (void) pad_req; + ::beep(); + } + // This is called if the driver returns an unknown op-code + + virtual void OnNavigationError(int pad_req) { + (void) pad_req; + ::beep(); + } + // This is called if a navigation request couldn't be satisfied + + virtual void OnOperation(int pad_req) { + (void) pad_req; + }; + // OnOperation is called if a Pad_Operation was executed and just before + // the refresh() operation is done. + +public: + NCursesPad(int nlines, int ncols); + // create a pad with the given size + + NCursesPad& operator=(const NCursesPad& rhs) + { + if (this != &rhs) { + *this = rhs; + NCursesWindow::operator=(rhs); + } + return *this; + } + + NCursesPad(const NCursesPad& rhs) + : NCursesWindow(rhs), + viewWin(rhs.viewWin), + viewSub(rhs.viewSub), + h_gridsize(rhs.h_gridsize), + v_gridsize(rhs.v_gridsize), + min_row(rhs.min_row), + min_col(rhs.min_col) + { + } + + virtual ~NCursesPad() THROWS(NCursesException) {} + + int echochar(const chtype ch) { return ::pechochar(w, ch); } + // Put the attributed character onto the pad and immediately do a + // prefresh(). + + int refresh() NCURSES_OVERRIDE; + // If a viewport is defined the pad is displayed in this window, otherwise + // this is a noop. + + int refresh(int pminrow, int pmincol, + int sminrow, int smincol, + int smaxrow, int smaxcol) { + return ::prefresh(w, pminrow, pmincol, + sminrow, smincol, smaxrow, smaxcol); + } + // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle + // on the screen. refresh copies a rectangle of this size beginning + // with top left corner pminrow,pmincol onto the screen and calls doupdate(). + + int noutrefresh() NCURSES_OVERRIDE; + // If a viewport is defined the pad is displayed in this window, otherwise + // this is a noop. + + int noutrefresh(int pminrow, int pmincol, + int sminrow, int smincol, + int smaxrow, int smaxcol) { + return ::pnoutrefresh(w, pminrow, pmincol, + sminrow, smincol, smaxrow, smaxcol); + } + // Does the same as refresh() but without calling doupdate(). + + virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1); + // Add the window "view" as viewing window to the pad. + + virtual void setSubWindow(NCursesWindow& sub); + // Use the subwindow "sub" of the viewport window for the actual viewing. + // The full viewport window is usually used to provide some decorations + // like frames, titles etc. + + virtual void operator() (void); + // Perform Pad's operation +}; + +// A FramedPad is constructed always with a viewport window. This viewport +// will be framed (by a box() command) and the interior of the box is the +// viewport subwindow. On the frame we display scrollbar sliders. +class NCURSES_CXX_IMPEXP NCursesFramedPad : public NCursesPad +{ +protected: + virtual void OnOperation(int pad_req) NCURSES_OVERRIDE; + +public: + NCursesFramedPad(NCursesWindow& win, int nlines, int ncols, + int v_grid = 1, int h_grid = 1) + : NCursesPad(nlines, ncols) { + NCursesPad::setWindow(win, v_grid, h_grid); + NCursesPad::setSubWindow(*(new NCursesWindow(win))); + } + // Construct the FramedPad with the given Window win as viewport. + + virtual ~NCursesFramedPad() THROWS(NCursesException) { + delete getSubWindow(); + } + + void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) NCURSES_OVERRIDE { + (void) view; + (void) v_grid; + (void) h_grid; + err_handler("Operation not allowed"); + } + // Disable this call; the viewport is already defined + + void setSubWindow(NCursesWindow& sub) NCURSES_OVERRIDE { + (void) sub; + err_handler("Operation not allowed"); + } + // Disable this call; the viewport subwindow is already defined + +}; + +#endif /* NCURSES_CURSESW_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/cursslk.h b/illumos-x86_64/usr/include/ncurses/cursslk.h new file mode 100644 index 00000000..f106c540 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/cursslk.h @@ -0,0 +1,240 @@ +// * this is for making emacs happy: -*-Mode: C++;-*- +// vile:cppmode +/**************************************************************************** + * Copyright 2019-2020,2021 Thomas E. Dickey * + * Copyright 1998-2003,2005 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1997 * + ****************************************************************************/ + +// $Id: cursslk.h,v 1.19 2021/04/17 18:11:08 tom Exp $ + +#ifndef NCURSES_CURSSLK_H_incl +#define NCURSES_CURSSLK_H_incl + +#include + +class NCURSES_CXX_IMPEXP Soft_Label_Key_Set { +public: + // This inner class represents the attributes of a Soft Label Key (SLK) + class NCURSES_CXX_IMPEXP Soft_Label_Key { + friend class Soft_Label_Key_Set; + public: + typedef enum { Left=0, Center=1, Right=2 } Justification; + + private: + char *label; // The Text of the Label + Justification format; // The Justification + int num; // The number of the Label + + Soft_Label_Key() : label(NULL), format(Left), num(-1) { + } + + virtual ~Soft_Label_Key() { + delete[] label; + }; + + public: + // Set the text of the Label + Soft_Label_Key& operator=(char *text); + + // Set the Justification of the Label + Soft_Label_Key& operator=(Justification just) { + format = just; + return *this; + } + + // Retrieve the text of the label + inline char* operator()(void) const { + return label; + } + + Soft_Label_Key& operator=(const Soft_Label_Key& rhs) + { + if (this != &rhs) { + *this = rhs; + } + return *this; + } + + Soft_Label_Key(const Soft_Label_Key& rhs) + : label(NULL), + format(rhs.format), + num(rhs.num) + { + *this = rhs.label; + } + }; + +public: + typedef enum { + None = -1, + Three_Two_Three = 0, + Four_Four = 1, + PC_Style = 2, + PC_Style_With_Index = 3 + } Label_Layout; + +private: + static long count; // Number of Key Sets + static Label_Layout format; // Layout of the Key Sets + static int num_labels; // Number Of Labels in Key Sets + bool b_attrInit; // Are attributes initialized + + Soft_Label_Key *slk_array; // The array of SLK's + + // Init the Key Set + void init(); + + // Activate or Deactivate Label# i, Label counting starts with 1! + void activate_label(int i, bool bf=TRUE); + + // Activate of Deactivate all Labels + void activate_labels(bool bf); + +protected: + inline void Error (const char* msg) const THROWS(NCursesException) { + THROW(new NCursesException (msg)); + } + + // Remove SLK's from screen + void clear() { + if (ERR==::slk_clear()) + Error("slk_clear"); + } + + // Restore them + void restore() { + if (ERR==::slk_restore()) + Error("slk_restore"); + } + +public: + + // Construct a Key Set, use the most comfortable layout as default. + // You must create a Soft_Label_Key_Set before you create any object of + // the NCursesWindow, NCursesPanel or derived classes. (Actually before + // ::initscr() is called). + explicit Soft_Label_Key_Set(Label_Layout fmt); + + // This constructor assumes, that you already constructed a Key Set + // with a layout by the constructor above. This layout will be reused. + Soft_Label_Key_Set(); + + Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs) + { + if (this != &rhs) { + *this = rhs; + init(); // allocate a new slk_array[] + } + return *this; + } + + Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs) + : b_attrInit(rhs.b_attrInit), + slk_array(NULL) + { + init(); // allocate a new slk_array[] + } + + virtual ~Soft_Label_Key_Set() THROWS(NCursesException); + + // Get Label# i. Label counting starts with 1! + Soft_Label_Key& operator[](int i); + + // Retrieve number of Labels + int labels() const; + + // Refresh the SLK portion of the screen + inline void refresh() { + if (ERR==::slk_refresh()) + Error("slk_refresh"); + } + + // Mark the SLK portion of the screen for refresh, defer actual refresh + // until next update call. + inline void noutrefresh() { + if (ERR==::slk_noutrefresh()) + Error("slk_noutrefresh"); + } + + // Mark the whole SLK portion of the screen as modified + inline void touch() { + if (ERR==::slk_touch()) + Error("slk_touch"); + } + + // Activate Label# i + inline void show(int i) { + activate_label(i,FALSE); + activate_label(i,TRUE); + } + + // Hide Label# i + inline void hide(int i) { + activate_label(i,FALSE); + } + + // Show all Labels + inline void show() { + activate_labels(FALSE); + activate_labels(TRUE); + } + + // Hide all Labels + inline void hide() { + activate_labels(FALSE); + } + + inline void attron(attr_t attrs) { + if (ERR==::slk_attron(attrs)) + Error("slk_attron"); + } + + inline void attroff(attr_t attrs) { + if (ERR==::slk_attroff(attrs)) + Error("slk_attroff"); + } + + inline void attrset(attr_t attrs) { + if (ERR==::slk_attrset(attrs)) + Error("slk_attrset"); + } + + inline void color(short color_pair_number) { + if (ERR==::slk_color(color_pair_number)) + Error("slk_color"); + } + + inline attr_t attr() const { + return ::slk_attr(); + } +}; + +#endif /* NCURSES_CURSSLK_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/eti.h b/illumos-x86_64/usr/include/ncurses/eti.h new file mode 100644 index 00000000..3c3302d0 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/eti.h @@ -0,0 +1,55 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2002,2003 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1995,1997 * + ****************************************************************************/ + +/* $Id: eti.h,v 1.9 2020/02/02 23:34:34 tom Exp $ */ + +#ifndef NCURSES_ETI_H_incl +#define NCURSES_ETI_H_incl 1 + +#define E_OK (0) +#define E_SYSTEM_ERROR (-1) +#define E_BAD_ARGUMENT (-2) +#define E_POSTED (-3) +#define E_CONNECTED (-4) +#define E_BAD_STATE (-5) +#define E_NO_ROOM (-6) +#define E_NOT_POSTED (-7) +#define E_UNKNOWN_COMMAND (-8) +#define E_NO_MATCH (-9) +#define E_NOT_SELECTABLE (-10) +#define E_NOT_CONNECTED (-11) +#define E_REQUEST_DENIED (-12) +#define E_INVALID_FIELD (-13) +#define E_CURRENT (-14) + +#endif diff --git a/illumos-x86_64/usr/include/ncurses/etip.h b/illumos-x86_64/usr/include/ncurses/etip.h new file mode 100644 index 00000000..21943d76 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/etip.h @@ -0,0 +1,406 @@ +// * This makes emacs happy -*-Mode: C++;-*- +/**************************************************************************** + * Copyright 2018-2021,2022 Thomas E. Dickey * + * Copyright 1998-2012,2017 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1997 * + ****************************************************************************/ + +// $Id: etip.h.in,v 1.50 2022/08/20 20:50:00 tom Exp $ + +#ifndef NCURSES_ETIP_H_incl +#define NCURSES_ETIP_H_incl 1 + +// These are substituted at configure/build time +#ifndef HAVE_BUILTIN_H +#define HAVE_BUILTIN_H 0 +#endif + +#ifndef HAVE_GXX_BUILTIN_H +#define HAVE_GXX_BUILTIN_H 0 +#endif + +#ifndef HAVE_GPP_BUILTIN_H +#define HAVE_GPP_BUILTIN_H 0 +#endif + +#ifndef HAVE_IOSTREAM +#define HAVE_IOSTREAM 1 +#endif + +#ifndef HAVE_TYPEINFO +#define HAVE_TYPEINFO 1 +#endif + +#ifndef HAVE_VALUES_H +#define HAVE_VALUES_H 0 +#endif + +#ifndef ETIP_NEEDS_MATH_H +#define ETIP_NEEDS_MATH_H 0 +#endif + +#ifndef ETIP_NEEDS_MATH_EXCEPTION +#define ETIP_NEEDS_MATH_EXCEPTION 0 +#endif + +#ifndef CPP_HAS_OVERRIDE +#define CPP_HAS_OVERRIDE 0 +#endif + +#ifndef CPP_HAS_PARAM_INIT +#define CPP_HAS_PARAM_INIT 0 +#endif + +#ifndef CPP_HAS_STATIC_CAST +#define CPP_HAS_STATIC_CAST 1 +#endif + +#ifndef IOSTREAM_NAMESPACE +#define IOSTREAM_NAMESPACE 1 +#endif + +#ifdef __GNUG__ +# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) +# if HAVE_TYPEINFO +# include +# endif +# endif +#endif + +#if defined(__GNUG__) +# if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H +# if ETIP_NEEDS_MATH_H +# if ETIP_NEEDS_MATH_EXCEPTION +# undef exception +# define exception math_exception +# endif +# include +# endif +# undef exception +# define exception builtin_exception +# if HAVE_GPP_BUILTIN_H +# include +# elif HAVE_GXX_BUILTIN_H +# include +# else +# include +# endif +# undef exception +# endif +#elif defined (__SUNPRO_CC) +# include +#endif + +#include + +extern "C" { +#if HAVE_VALUES_H +# include +#endif + +#include +#include +#include +} + +// Language features +#if CPP_HAS_OVERRIDE +#define NCURSES_OVERRIDE override +#else +#define NCURSES_OVERRIDE /*nothing*/ +#endif + +#if CPP_HAS_PARAM_INIT +#define NCURSES_PARAM_INIT(value) = value +#else +#define NCURSES_PARAM_INIT(value) /*nothing*/ +#endif + +#if CPP_HAS_STATIC_CAST +#define STATIC_CAST(s) static_cast +#else +#define STATIC_CAST(s) (s) +#endif + +#ifndef NCURSES_CXX_IMPEXP +#define NCURSES_CXX_IMPEXP /* nothing */ +#endif + +// Forward Declarations +class NCURSES_CXX_IMPEXP NCursesPanel; +class NCURSES_CXX_IMPEXP NCursesMenu; +class NCURSES_CXX_IMPEXP NCursesForm; + +class NCURSES_CXX_IMPEXP NCursesException +{ +public: + const char *message; + int errorno; + + NCursesException (const char* msg, int err) + : message(msg), errorno (err) + {}; + + explicit NCursesException (const char* msg) + : message(msg), errorno (E_SYSTEM_ERROR) + {}; + + NCursesException& operator=(const NCursesException& rhs) + { + message = rhs.message; + errorno = rhs.errorno; + return *this; + } + + NCursesException(const NCursesException& rhs) + : message(rhs.message), errorno(rhs.errorno) + { + } + + virtual const char *classname() const { + return "NCursesWindow"; + } + + virtual ~NCursesException() + { + } +}; + +class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException +{ +public: + const NCursesPanel* p; + + NCursesPanelException (const char *msg, int err) : + NCursesException (msg, err), + p (0) + {}; + + NCursesPanelException (const NCursesPanel* panel, + const char *msg, + int err) : + NCursesException (msg, err), + p (panel) + {}; + + explicit NCursesPanelException (int err) : + NCursesException ("panel library error", err), + p (0) + {}; + + NCursesPanelException (const NCursesPanel* panel, + int err) : + NCursesException ("panel library error", err), + p (panel) + {}; + + NCursesPanelException& operator=(const NCursesPanelException& rhs) + { + if (this != &rhs) { + NCursesException::operator=(rhs); + p = rhs.p; + } + return *this; + } + + NCursesPanelException(const NCursesPanelException& rhs) + : NCursesException(rhs), p(rhs.p) + { + } + + virtual const char *classname() const NCURSES_OVERRIDE { + return "NCursesPanel"; + } + + virtual ~NCursesPanelException() + { + } +}; + +class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException +{ +public: + const NCursesMenu* m; + + NCursesMenuException (const char *msg, int err) : + NCursesException (msg, err), + m (0) + {}; + + NCursesMenuException (const NCursesMenu* menu, + const char *msg, + int err) : + NCursesException (msg, err), + m (menu) + {}; + + explicit NCursesMenuException (int err) : + NCursesException ("menu library error", err), + m (0) + {}; + + NCursesMenuException (const NCursesMenu* menu, + int err) : + NCursesException ("menu library error", err), + m (menu) + {}; + + NCursesMenuException& operator=(const NCursesMenuException& rhs) + { + if (this != &rhs) { + NCursesException::operator=(rhs); + m = rhs.m; + } + return *this; + } + + NCursesMenuException(const NCursesMenuException& rhs) + : NCursesException(rhs), m(rhs.m) + { + } + + virtual const char *classname() const NCURSES_OVERRIDE { + return "NCursesMenu"; + } + + virtual ~NCursesMenuException() + { + } +}; + +class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException +{ +public: + const NCursesForm* f; + + NCursesFormException (const char *msg, int err) : + NCursesException (msg, err), + f (0) + {}; + + NCursesFormException (const NCursesForm* form, + const char *msg, + int err) : + NCursesException (msg, err), + f (form) + {}; + + explicit NCursesFormException (int err) : + NCursesException ("form library error", err), + f (0) + {}; + + NCursesFormException (const NCursesForm* form, + int err) : + NCursesException ("form library error", err), + f (form) + {}; + + NCursesFormException& operator=(const NCursesFormException& rhs) + { + if (this != &rhs) { + NCursesException::operator=(rhs); + f = rhs.f; + } + return *this; + } + + NCursesFormException(const NCursesFormException& rhs) + : NCursesException(rhs), f(rhs.f) + { + } + + virtual const char *classname() const NCURSES_OVERRIDE { + return "NCursesForm"; + } + + virtual ~NCursesFormException() + { + } +}; + +#if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC)) +# if HAVE_IOSTREAM +# include +# if IOSTREAM_NAMESPACE +using std::cerr; +using std::endl; +# endif +# else +# include +# endif +#endif + +inline void THROW(const NCursesException *e) { +#if defined(__GNUG__) && defined(__EXCEPTIONS) +# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) + (*lib_error_handler)(e ? e->classname() : "", e ? e->message : ""); +# elif (__GNUG__ >= 7) + // g++ 7.0 warns about deprecation, but lacks the predefined symbols + ::endwin(); + std::cerr << "Found a problem - goodbye" << std::endl; + exit(EXIT_FAILURE); +# else +# define CPP_HAS_TRY_CATCH 1 +# endif +#elif defined(__SUNPRO_CC) +# if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5) + genericerror(1, ((e != 0) ? (char *)(e->message) : "")); +# else +# define CPP_HAS_TRY_CATCH 1 +# endif +#else + if (e) + cerr << e->message << endl; + exit(0); +#endif + +#ifndef CPP_HAS_TRY_CATCH +#define CPP_HAS_TRY_CATCH 0 +#define NCURSES_CPP_TRY /* nothing */ +#define NCURSES_CPP_CATCH(e) if (false) +#define THROWS(s) /* nothing */ +#define THROW2(s,t) /* nothing */ +#elif CPP_HAS_TRY_CATCH + throw *e; +#define NCURSES_CPP_TRY try +#define NCURSES_CPP_CATCH(e) catch(e) +#if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510) +// C++17 deprecates the usage of throw(). +#define THROWS(s) /* nothing */ +#define THROW2(s,t) /* nothing */ +#else +#define THROWS(s) throw(s) +#define THROW2(s,t) throw(s,t) +#endif +#endif +} + +#endif /* NCURSES_ETIP_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/form.h b/illumos-x86_64/usr/include/ncurses/form.h new file mode 100644 index 00000000..18725e8b --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/form.h @@ -0,0 +1,460 @@ +/**************************************************************************** + * Copyright 2018-2019-2020,2021 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1995,1997 * + ****************************************************************************/ + +/* $Id: form.h,v 0.32 2021/06/17 21:26:02 tom Exp $ */ + +#ifndef FORM_H +#define FORM_H +/* *INDENT-OFF*/ + +#include +#include + +#ifdef __cplusplus + extern "C" { +#endif + +#if defined(BUILDING_FORM) +# define FORM_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT +#else +# define FORM_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT +#endif + +#define FORM_WRAPPED_VAR(type,name) extern FORM_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) + +#define FORM_EXPORT(type) FORM_IMPEXP type NCURSES_API +#define FORM_EXPORT_VAR(type) FORM_IMPEXP type + +#ifndef FORM_PRIV_H +typedef void *FIELD_CELL; +#endif + +#ifndef NCURSES_FIELD_INTERNALS +#define NCURSES_FIELD_INTERNALS /* nothing */ +#endif + +typedef int Form_Options; +typedef int Field_Options; + + /********** + * _PAGE * + **********/ + +typedef struct pagenode +#if !NCURSES_OPAQUE_FORM +{ + short pmin; /* index of first field on page */ + short pmax; /* index of last field on page */ + short smin; /* index of top leftmost field on page */ + short smax; /* index of bottom rightmost field on page */ +} +#endif /* !NCURSES_OPAQUE_FORM */ +_PAGE; + + /********** + * FIELD * + **********/ + +typedef struct fieldnode +#if 1 /* not yet: !NCURSES_OPAQUE_FORM */ +{ + unsigned short status; /* flags */ + short rows; /* size in rows */ + short cols; /* size in cols */ + short frow; /* first row */ + short fcol; /* first col */ + int drows; /* dynamic rows */ + int dcols; /* dynamic cols */ + int maxgrow; /* maximum field growth */ + int nrow; /* off-screen rows */ + short nbuf; /* additional buffers */ + short just; /* justification */ + short page; /* page on form */ + short index; /* into form -> field */ + int pad; /* pad character */ + chtype fore; /* foreground attribute */ + chtype back; /* background attribute */ + Field_Options opts; /* options */ + struct fieldnode * snext; /* sorted order pointer */ + struct fieldnode * sprev; /* sorted order pointer */ + struct fieldnode * link; /* linked field chain */ + struct formnode * form; /* containing form */ + struct typenode * type; /* field type */ + void * arg; /* argument for type */ + FIELD_CELL * buf; /* field buffers */ + void * usrptr; /* user pointer */ + /* + * The wide-character configuration requires extra information. Because + * there are existing applications that manipulate the members of FIELD + * directly, we cannot make the struct opaque, except by changing the ABI. + * Offsets of members up to this point are the same in the narrow- and + * wide-character configuration. But note that the type of buf depends on + * the configuration, and is made opaque for that reason. + */ + NCURSES_FIELD_INTERNALS +} +#endif /* NCURSES_OPAQUE_FORM */ +FIELD; + + + /********* + * FORM * + *********/ + +typedef struct formnode +#if 1 /* not yet: !NCURSES_OPAQUE_FORM */ +{ + unsigned short status; /* flags */ + short rows; /* size in rows */ + short cols; /* size in cols */ + int currow; /* current row in field window */ + int curcol; /* current col in field window */ + int toprow; /* in scrollable field window */ + int begincol; /* in horiz. scrollable field */ + short maxfield; /* number of fields */ + short maxpage; /* number of pages */ + short curpage; /* index into page */ + Form_Options opts; /* options */ + WINDOW * win; /* window */ + WINDOW * sub; /* subwindow */ + WINDOW * w; /* window for current field */ + FIELD ** field; /* field [maxfield] */ + FIELD * current; /* current field */ + _PAGE * page; /* page [maxpage] */ + void * usrptr; /* user pointer */ + + void (*forminit)(struct formnode *); + void (*formterm)(struct formnode *); + void (*fieldinit)(struct formnode *); + void (*fieldterm)(struct formnode *); + +} +#endif /* !NCURSES_OPAQUE_FORM */ +FORM; + + + /************** + * FIELDTYPE * + **************/ + +typedef struct typenode +#if !NCURSES_OPAQUE_FORM +{ + unsigned short status; /* flags */ + long ref; /* reference count */ + struct typenode * left; /* ptr to operand for | */ + struct typenode * right; /* ptr to operand for | */ + + void* (*makearg)(va_list *); /* make fieldtype arg */ + void* (*copyarg)(const void *); /* copy fieldtype arg */ + void (*freearg)(void *); /* free fieldtype arg */ + +#if NCURSES_INTEROP_FUNCS + union { + bool (*ofcheck)(FIELD *,const void *); /* field validation */ + bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */ + } fieldcheck; + union { + bool (*occheck)(int,const void *); /* character validation */ + bool (*gccheck)(int,FORM*, + FIELD*,const void*); /* generic char validation */ + } charcheck; + union { + bool (*onext)(FIELD *,const void *); /* enumerate next value */ + bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */ + } enum_next; + union { + bool (*oprev)(FIELD *,const void *); /* enumerate prev value */ + bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */ + } enum_prev; + void* (*genericarg)(void*); /* Alternate Arg method */ +#else + bool (*fcheck)(FIELD *,const void *); /* field validation */ + bool (*ccheck)(int,const void *); /* character validation */ + + bool (*next)(FIELD *,const void *); /* enumerate next value */ + bool (*prev)(FIELD *,const void *); /* enumerate prev value */ +#endif +} +#endif /* !NCURSES_OPAQUE_FORM */ +FIELDTYPE; + +typedef void (*Form_Hook)(FORM *); + + /*************************** + * miscellaneous #defines * + ***************************/ + +/* field justification */ +#define NO_JUSTIFICATION (0) +#define JUSTIFY_LEFT (1) +#define JUSTIFY_CENTER (2) +#define JUSTIFY_RIGHT (3) + +/* field options */ +#define O_VISIBLE (0x0001U) +#define O_ACTIVE (0x0002U) +#define O_PUBLIC (0x0004U) +#define O_EDIT (0x0008U) +#define O_WRAP (0x0010U) +#define O_BLANK (0x0020U) +#define O_AUTOSKIP (0x0040U) +#define O_NULLOK (0x0080U) +#define O_PASSOK (0x0100U) +#define O_STATIC (0x0200U) +#define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */ +#define O_NO_LEFT_STRIP (0x0800U) /* ncurses extension */ +#define O_EDGE_INSERT_STAY (0x1000U) /* ncurses extension */ +#define O_INPUT_LIMIT (0x2000U) /* ncurses extension */ + +/* form options */ +#define O_NL_OVERLOAD (0x0001U) +#define O_BS_OVERLOAD (0x0002U) + +/* form driver commands */ +#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */ +#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */ +#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */ +#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */ + +#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */ +#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */ +#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */ +#define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */ +#define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */ +#define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */ +#define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */ +#define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */ +#define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */ +#define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */ +#define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */ +#define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */ + +#define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */ +#define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */ +#define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */ +#define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */ +#define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */ +#define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */ +#define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */ +#define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */ +#define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */ +#define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */ +#define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */ +#define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */ +#define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */ +#define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */ + +#define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */ +#define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */ +#define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */ +#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */ +#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */ +#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */ +#define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */ +#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */ +#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */ +#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */ +#define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */ +#define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */ +#define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */ +#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */ +#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */ +#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */ +#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */ +#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */ +#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */ +#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */ +#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */ +#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */ +#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */ +#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */ + +#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */ +#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */ +#define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */ + +#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */ +#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */ + +#if defined(MAX_COMMAND) +# if (MAX_FORM_COMMAND > MAX_COMMAND) +# error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND +# elif (MAX_COMMAND != (KEY_MAX + 128)) +# error Something is wrong -- MAX_COMMAND is already inconsistently defined. +# endif +#else +# define MAX_COMMAND (KEY_MAX + 128) +#endif + + /************************* + * standard field types * + *************************/ +extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA; +extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM; +extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM; +extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER; +extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC; +extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP; + + /************************************ + * built-in additional field types * + * They are not defined in SVr4 * + ************************************/ +extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */ + + /*********************** + * FIELDTYPE routines * + ***********************/ +extern FORM_EXPORT(FIELDTYPE *) new_fieldtype ( + bool (* const field_check)(FIELD *,const void *), + bool (* const char_check)(int,const void *)); +extern FORM_EXPORT(FIELDTYPE *) link_fieldtype( + FIELDTYPE *, FIELDTYPE *); + +extern FORM_EXPORT(int) free_fieldtype (FIELDTYPE *); +extern FORM_EXPORT(int) set_fieldtype_arg (FIELDTYPE *, + void * (* const make_arg)(va_list *), + void * (* const copy_arg)(const void *), + void (* const free_arg)(void *)); +extern FORM_EXPORT(int) set_fieldtype_choice (FIELDTYPE *, + bool (* const next_choice)(FIELD *,const void *), + bool (* const prev_choice)(FIELD *,const void *)); + + /******************* + * FIELD routines * + *******************/ +extern FORM_EXPORT(FIELD *) new_field (int,int,int,int,int,int); +extern FORM_EXPORT(FIELD *) dup_field (FIELD *,int,int); +extern FORM_EXPORT(FIELD *) link_field (FIELD *,int,int); + +extern FORM_EXPORT(int) free_field (FIELD *); +extern FORM_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *); +extern FORM_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *); +extern FORM_EXPORT(int) set_max_field ( FIELD *,int); +extern FORM_EXPORT(int) move_field (FIELD *,int,int); +extern FORM_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...); +extern FORM_EXPORT(int) set_new_page (FIELD *,bool); +extern FORM_EXPORT(int) set_field_just (FIELD *,int); +extern FORM_EXPORT(int) field_just (const FIELD *); +extern FORM_EXPORT(int) set_field_fore (FIELD *,chtype); +extern FORM_EXPORT(int) set_field_back (FIELD *,chtype); +extern FORM_EXPORT(int) set_field_pad (FIELD *,int); +extern FORM_EXPORT(int) field_pad (const FIELD *); +extern FORM_EXPORT(int) set_field_buffer (FIELD *,int,const char *); +extern FORM_EXPORT(int) set_field_status (FIELD *,bool); +extern FORM_EXPORT(int) set_field_userptr (FIELD *, void *); +extern FORM_EXPORT(int) set_field_opts (FIELD *,Field_Options); +extern FORM_EXPORT(int) field_opts_on (FIELD *,Field_Options); +extern FORM_EXPORT(int) field_opts_off (FIELD *,Field_Options); + +extern FORM_EXPORT(chtype) field_fore (const FIELD *); +extern FORM_EXPORT(chtype) field_back (const FIELD *); + +extern FORM_EXPORT(bool) new_page (const FIELD *); +extern FORM_EXPORT(bool) field_status (const FIELD *); + +extern FORM_EXPORT(void *) field_arg (const FIELD *); + +extern FORM_EXPORT(void *) field_userptr (const FIELD *); + +extern FORM_EXPORT(FIELDTYPE *) field_type (const FIELD *); + +extern FORM_EXPORT(char *) field_buffer (const FIELD *,int); + +extern FORM_EXPORT(Field_Options) field_opts (const FIELD *); + + /****************** + * FORM routines * + ******************/ + +extern FORM_EXPORT(FORM *) new_form (FIELD **); + +extern FORM_EXPORT(FIELD **) form_fields (const FORM *); +extern FORM_EXPORT(FIELD *) current_field (const FORM *); + +extern FORM_EXPORT(WINDOW *) form_win (const FORM *); +extern FORM_EXPORT(WINDOW *) form_sub (const FORM *); + +extern FORM_EXPORT(Form_Hook) form_init (const FORM *); +extern FORM_EXPORT(Form_Hook) form_term (const FORM *); +extern FORM_EXPORT(Form_Hook) field_init (const FORM *); +extern FORM_EXPORT(Form_Hook) field_term (const FORM *); + +extern FORM_EXPORT(int) free_form (FORM *); +extern FORM_EXPORT(int) set_form_fields (FORM *,FIELD **); +extern FORM_EXPORT(int) field_count (const FORM *); +extern FORM_EXPORT(int) set_form_win (FORM *,WINDOW *); +extern FORM_EXPORT(int) set_form_sub (FORM *,WINDOW *); +extern FORM_EXPORT(int) set_current_field (FORM *,FIELD *); +extern FORM_EXPORT(int) unfocus_current_field (FORM *); +extern FORM_EXPORT(int) field_index (const FIELD *); +extern FORM_EXPORT(int) set_form_page (FORM *,int); +extern FORM_EXPORT(int) form_page (const FORM *); +extern FORM_EXPORT(int) scale_form (const FORM *,int *,int *); +extern FORM_EXPORT(int) set_form_init (FORM *,Form_Hook); +extern FORM_EXPORT(int) set_form_term (FORM *,Form_Hook); +extern FORM_EXPORT(int) set_field_init (FORM *,Form_Hook); +extern FORM_EXPORT(int) set_field_term (FORM *,Form_Hook); +extern FORM_EXPORT(int) post_form (FORM *); +extern FORM_EXPORT(int) unpost_form (FORM *); +extern FORM_EXPORT(int) pos_form_cursor (FORM *); +extern FORM_EXPORT(int) form_driver (FORM *,int); +# if NCURSES_WIDECHAR +extern FORM_EXPORT(int) form_driver_w (FORM *,int,wchar_t); +# endif +extern FORM_EXPORT(int) set_form_userptr (FORM *,void *); +extern FORM_EXPORT(int) set_form_opts (FORM *,Form_Options); +extern FORM_EXPORT(int) form_opts_on (FORM *,Form_Options); +extern FORM_EXPORT(int) form_opts_off (FORM *,Form_Options); +extern FORM_EXPORT(int) form_request_by_name (const char *); + +extern FORM_EXPORT(const char *) form_request_name (int); + +extern FORM_EXPORT(void *) form_userptr (const FORM *); + +extern FORM_EXPORT(Form_Options) form_opts (const FORM *); + +extern FORM_EXPORT(bool) data_ahead (const FORM *); +extern FORM_EXPORT(bool) data_behind (const FORM *); + +#if NCURSES_SP_FUNCS +extern FORM_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **); +#endif + +#ifdef __cplusplus + } +#endif +/* *INDENT-ON*/ + +#endif /* FORM_H */ diff --git a/illumos-x86_64/usr/include/ncurses/menu.h b/illumos-x86_64/usr/include/ncurses/menu.h new file mode 100644 index 00000000..285edff7 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/menu.h @@ -0,0 +1,281 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Juergen Pfeifer, 1995,1997 * + ****************************************************************************/ + +/* $Id: menu.h,v 1.26 2020/12/12 00:38:02 tom Exp $ */ + +#ifndef ETI_MENU +#define ETI_MENU + +#ifdef AMIGA +#define TEXT TEXT_ncurses +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if defined(BUILDING_MENU) +# define MENU_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT +#else +# define MENU_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT +#endif + +#define MENU_WRAPPED_VAR(type,name) extern MENU_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) + +#define MENU_EXPORT(type) MENU_IMPEXP type NCURSES_API +#define MENU_EXPORT_VAR(type) MENU_IMPEXP type + + typedef int Menu_Options; + typedef int Item_Options; + +/* Menu options: */ +#define O_ONEVALUE (0x01) +#define O_SHOWDESC (0x02) +#define O_ROWMAJOR (0x04) +#define O_IGNORECASE (0x08) +#define O_SHOWMATCH (0x10) +#define O_NONCYCLIC (0x20) +#define O_MOUSE_MENU (0x40) + +/* Item options: */ +#define O_SELECTABLE (0x01) + +#if !NCURSES_OPAQUE_MENU + typedef struct + { + const char *str; + unsigned short length; + } + TEXT; +#endif /* !NCURSES_OPAQUE_MENU */ + + struct tagMENU; + + typedef struct tagITEM +#if !NCURSES_OPAQUE_MENU + { + TEXT name; /* name of menu item */ + TEXT description; /* description of item, optional in display */ + struct tagMENU *imenu; /* Pointer to parent menu */ + void *userptr; /* Pointer to user defined per item data */ + Item_Options opt; /* Item options */ + short index; /* Item number if connected to a menu */ + short y; /* y and x location of item in menu */ + short x; + bool value; /* Selection value */ + + struct tagITEM *left; /* neighbor items */ + struct tagITEM *right; + struct tagITEM *up; + struct tagITEM *down; + + } +#endif /* !NCURSES_OPAQUE_MENU */ + ITEM; + + typedef void (*Menu_Hook) (struct tagMENU *); + + typedef struct tagMENU +#if 1 /* not yet: !NCURSES_OPAQUE_MENU */ + { + short height; /* Nr. of chars high */ + short width; /* Nr. of chars wide */ + short rows; /* Nr. of items high */ + short cols; /* Nr. of items wide */ + short frows; /* Nr. of formatted items high */ + short fcols; /* Nr. of formatted items wide */ + short arows; /* Nr. of items high (actual) */ + short namelen; /* Max. name length */ + short desclen; /* Max. description length */ + short marklen; /* Length of mark, if any */ + short itemlen; /* Length of one item */ + short spc_desc; /* Spacing for descriptor */ + short spc_cols; /* Spacing for columns */ + short spc_rows; /* Spacing for rows */ + char *pattern; /* Buffer to store match chars */ + short pindex; /* Index into pattern buffer */ + WINDOW *win; /* Window containing menu */ + WINDOW *sub; /* Subwindow for menu display */ + WINDOW *userwin; /* User's window */ + WINDOW *usersub; /* User's subwindow */ + ITEM **items; /* array of items */ + short nitems; /* Nr. of items in menu */ + ITEM *curitem; /* Current item */ + short toprow; /* Top row of menu */ + chtype fore; /* Selection attribute */ + chtype back; /* Nonselection attribute */ + chtype grey; /* Inactive attribute */ + unsigned char pad; /* Pad character */ + + Menu_Hook menuinit; /* User hooks */ + Menu_Hook menuterm; + Menu_Hook iteminit; + Menu_Hook itemterm; + + void *userptr; /* Pointer to menus user data */ + char *mark; /* Pointer to marker string */ + + Menu_Options opt; /* Menu options */ + unsigned short status; /* Internal state of menu */ + } +#endif /* !NCURSES_OPAQUE_MENU */ + MENU; + +/* Define keys */ + +#define REQ_LEFT_ITEM (KEY_MAX + 1) +#define REQ_RIGHT_ITEM (KEY_MAX + 2) +#define REQ_UP_ITEM (KEY_MAX + 3) +#define REQ_DOWN_ITEM (KEY_MAX + 4) +#define REQ_SCR_ULINE (KEY_MAX + 5) +#define REQ_SCR_DLINE (KEY_MAX + 6) +#define REQ_SCR_DPAGE (KEY_MAX + 7) +#define REQ_SCR_UPAGE (KEY_MAX + 8) +#define REQ_FIRST_ITEM (KEY_MAX + 9) +#define REQ_LAST_ITEM (KEY_MAX + 10) +#define REQ_NEXT_ITEM (KEY_MAX + 11) +#define REQ_PREV_ITEM (KEY_MAX + 12) +#define REQ_TOGGLE_ITEM (KEY_MAX + 13) +#define REQ_CLEAR_PATTERN (KEY_MAX + 14) +#define REQ_BACK_PATTERN (KEY_MAX + 15) +#define REQ_NEXT_MATCH (KEY_MAX + 16) +#define REQ_PREV_MATCH (KEY_MAX + 17) + +#define MIN_MENU_COMMAND (KEY_MAX + 1) +#define MAX_MENU_COMMAND (KEY_MAX + 17) + +/* + * Some AT&T code expects MAX_COMMAND to be out-of-band not + * just for menu commands but for forms ones as well. + */ +#if defined(MAX_COMMAND) +# if (MAX_MENU_COMMAND > MAX_COMMAND) +# error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND +# elif (MAX_COMMAND != (KEY_MAX + 128)) +# error Something is wrong -- MAX_COMMAND is already inconsistently defined. +# endif +#else +# define MAX_COMMAND (KEY_MAX + 128) +#endif + +/* --------- prototypes for libmenu functions ----------------------------- */ + + extern MENU_EXPORT(ITEM **) menu_items(const MENU *); + extern MENU_EXPORT(ITEM *) current_item(const MENU *); + extern MENU_EXPORT(ITEM *) new_item(const char *, const char *); + + extern MENU_EXPORT(MENU *) new_menu(ITEM **); + + extern MENU_EXPORT(Item_Options) item_opts(const ITEM *); + extern MENU_EXPORT(Menu_Options) menu_opts(const MENU *); + + extern MENU_EXPORT(Menu_Hook) item_init(const MENU *); + extern MENU_EXPORT(Menu_Hook) item_term(const MENU *); + extern MENU_EXPORT(Menu_Hook) menu_init(const MENU *); + extern MENU_EXPORT(Menu_Hook) menu_term(const MENU *); + + extern MENU_EXPORT(WINDOW *) menu_sub(const MENU *); + extern MENU_EXPORT(WINDOW *) menu_win(const MENU *); + + extern MENU_EXPORT(const char *) item_description(const ITEM *); + extern MENU_EXPORT(const char *) item_name(const ITEM *); + extern MENU_EXPORT(const char *) menu_mark(const MENU *); + extern MENU_EXPORT(const char *) menu_request_name(int); + + extern MENU_EXPORT(char *) menu_pattern(const MENU *); + + extern MENU_EXPORT(void *) menu_userptr(const MENU *); + extern MENU_EXPORT(void *) item_userptr(const ITEM *); + + extern MENU_EXPORT(chtype) menu_back(const MENU *); + extern MENU_EXPORT(chtype) menu_fore(const MENU *); + extern MENU_EXPORT(chtype) menu_grey(const MENU *); + + extern MENU_EXPORT(int) free_item(ITEM *); + extern MENU_EXPORT(int) free_menu(MENU *); + extern MENU_EXPORT(int) item_count(const MENU *); + extern MENU_EXPORT(int) item_index(const ITEM *); + extern MENU_EXPORT(int) item_opts_off(ITEM *, Item_Options); + extern MENU_EXPORT(int) item_opts_on(ITEM *, Item_Options); + extern MENU_EXPORT(int) menu_driver(MENU *, int); + extern MENU_EXPORT(int) menu_opts_off(MENU *, Menu_Options); + extern MENU_EXPORT(int) menu_opts_on(MENU *, Menu_Options); + extern MENU_EXPORT(int) menu_pad(const MENU *); + extern MENU_EXPORT(int) pos_menu_cursor(const MENU *); + extern MENU_EXPORT(int) post_menu(MENU *); + extern MENU_EXPORT(int) scale_menu(const MENU *, int *, int *); + extern MENU_EXPORT(int) set_current_item(MENU *menu, ITEM *item); + extern MENU_EXPORT(int) set_item_init(MENU *, Menu_Hook); + extern MENU_EXPORT(int) set_item_opts(ITEM *, Item_Options); + extern MENU_EXPORT(int) set_item_term(MENU *, Menu_Hook); + extern MENU_EXPORT(int) set_item_userptr(ITEM *, void *); + extern MENU_EXPORT(int) set_item_value(ITEM *, bool); + extern MENU_EXPORT(int) set_menu_back(MENU *, chtype); + extern MENU_EXPORT(int) set_menu_fore(MENU *, chtype); + extern MENU_EXPORT(int) set_menu_format(MENU *, int, int); + extern MENU_EXPORT(int) set_menu_grey(MENU *, chtype); + extern MENU_EXPORT(int) set_menu_init(MENU *, Menu_Hook); + extern MENU_EXPORT(int) set_menu_items(MENU *, ITEM **); + extern MENU_EXPORT(int) set_menu_mark(MENU *, const char *); + extern MENU_EXPORT(int) set_menu_opts(MENU *, Menu_Options); + extern MENU_EXPORT(int) set_menu_pad(MENU *, int); + extern MENU_EXPORT(int) set_menu_pattern(MENU *, const char *); + extern MENU_EXPORT(int) set_menu_sub(MENU *, WINDOW *); + extern MENU_EXPORT(int) set_menu_term(MENU *, Menu_Hook); + extern MENU_EXPORT(int) set_menu_userptr(MENU *, void *); + extern MENU_EXPORT(int) set_menu_win(MENU *, WINDOW *); + extern MENU_EXPORT(int) set_top_row(MENU *, int); + extern MENU_EXPORT(int) top_row(const MENU *); + extern MENU_EXPORT(int) unpost_menu(MENU *); + extern MENU_EXPORT(int) menu_request_by_name(const char *); + extern MENU_EXPORT(int) set_menu_spacing(MENU *, int, int, int); + extern MENU_EXPORT(int) menu_spacing(const MENU *, int *, int *, int *); + + extern MENU_EXPORT(bool) item_value(const ITEM *); + extern MENU_EXPORT(bool) item_visible(const ITEM *); + + extern MENU_EXPORT(void) menu_format(const MENU *, int *, int *); + +#if NCURSES_SP_FUNCS + extern MENU_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN *, ITEM **); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ETI_MENU */ diff --git a/illumos-x86_64/usr/include/ncurses/ncurses.h b/illumos-x86_64/usr/include/ncurses/ncurses.h new file mode 120000 index 00000000..149de6c1 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/ncurses.h @@ -0,0 +1 @@ +curses.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/ncurses/ncurses_dll.h b/illumos-x86_64/usr/include/ncurses/ncurses_dll.h new file mode 100644 index 00000000..2a6055f2 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/ncurses_dll.h @@ -0,0 +1,103 @@ +/**************************************************************************** + * Copyright 2018-2020,2023 Thomas E. Dickey * + * Copyright 2009,2014 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ +/* $Id: ncurses_dll.h.in,v 1.18 2023/05/06 20:12:43 tom Exp $ */ + +#ifndef NCURSES_DLL_H_incl +#define NCURSES_DLL_H_incl 1 + +/* + * MinGW gcc (unlike MSYS2 and Cygwin) should define _WIN32 and possibly _WIN64. + */ +#if defined(__MINGW64__) + +#ifndef _WIN64 +#define _WIN64 1 +#endif + +#elif defined(__MINGW32__) + +#ifndef _WIN32 +#define _WIN32 1 +#endif + +/* 2014-08-02 workaround for broken MinGW compiler. + * Oddly, only TRACE is mapped to trace - the other -D's are okay. + * suggest TDM as an alternative. + */ +#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) + +#ifdef trace +#undef trace +#define TRACE +#endif + +#endif /* broken compiler */ + +#endif /* MingW */ + +/* + * For reentrant code, we map the various global variables into SCREEN by + * using functions to access them. + */ +#define NCURSES_PUBLIC_VAR(name) _nc_##name + +#if defined(BUILDING_NCURSES) +# define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT +#else +# define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT +#endif + +#define NCURSES_WRAPPED_VAR(type,name) extern NCURSES_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) + +#define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API +#define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type + +/* + * These symbols hide dllimport/dllexport, for compilers which care about it. + */ +#if defined(__CYGWIN__) || (defined(_WIN32) || defined(_WIN64)) +# if defined(NCURSES_STATIC) /* "static" here only implies "not-a-DLL" */ +# define NCURSES_EXPORT_GENERAL_IMPORT +# define NCURSES_EXPORT_GENERAL_EXPORT +# else +# define NCURSES_EXPORT_GENERAL_IMPORT __declspec(dllimport) +# define NCURSES_EXPORT_GENERAL_EXPORT __declspec(dllexport) +# endif +# define NCURSES_API __cdecl +#else +# define NCURSES_EXPORT_GENERAL_IMPORT +# if (__GNUC__ >= 4) && !defined(__cplusplus) +# define NCURSES_EXPORT_GENERAL_EXPORT __attribute__((visibility ("default"))) +# else +# define NCURSES_EXPORT_GENERAL_EXPORT +# endif +# define NCURSES_API /* FIXME: __attribute__ ((cdecl)) is only available on x86 */ +#endif + +#endif /* NCURSES_DLL_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/panel.h b/illumos-x86_64/usr/include/ncurses/panel.h new file mode 100644 index 00000000..c60a063c --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/panel.h @@ -0,0 +1,100 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2009,2017 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Zeyd M. Ben-Halim 1995 * + * and: Eric S. Raymond * + * and: Juergen Pfeifer 1996-1999,2008 * + ****************************************************************************/ + +/* $Id: panel.h,v 1.14 2020/07/04 20:38:43 tom Exp $ */ + +/* panel.h -- interface file for panels library */ + +#ifndef NCURSES_PANEL_H_incl +#define NCURSES_PANEL_H_incl 1 + +#include + +typedef struct panel +#if !NCURSES_OPAQUE_PANEL +{ + WINDOW *win; + struct panel *below; + struct panel *above; + NCURSES_CONST void *user; +} +#endif /* !NCURSES_OPAQUE_PANEL */ +PANEL; + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(BUILDING_PANEL) +# define PANEL_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT +#else +# define PANEL_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT +#endif + +#define PANEL_WRAPPED_VAR(type,name) extern PANEL_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) + +#define PANEL_EXPORT(type) PANEL_IMPEXP type NCURSES_API +#define PANEL_EXPORT_VAR(type) PANEL_IMPEXP type + +extern PANEL_EXPORT(WINDOW*) panel_window (const PANEL *); +extern PANEL_EXPORT(void) update_panels (void); +extern PANEL_EXPORT(int) hide_panel (PANEL *); +extern PANEL_EXPORT(int) show_panel (PANEL *); +extern PANEL_EXPORT(int) del_panel (PANEL *); +extern PANEL_EXPORT(int) top_panel (PANEL *); +extern PANEL_EXPORT(int) bottom_panel (PANEL *); +extern PANEL_EXPORT(PANEL*) new_panel (WINDOW *); +extern PANEL_EXPORT(PANEL*) panel_above (const PANEL *); +extern PANEL_EXPORT(PANEL*) panel_below (const PANEL *); +extern PANEL_EXPORT(int) set_panel_userptr (PANEL *, NCURSES_CONST void *); +extern PANEL_EXPORT(NCURSES_CONST void*) panel_userptr (const PANEL *); +extern PANEL_EXPORT(int) move_panel (PANEL *, int, int); +extern PANEL_EXPORT(int) replace_panel (PANEL *,WINDOW *); +extern PANEL_EXPORT(int) panel_hidden (const PANEL *); + +#if NCURSES_SP_FUNCS +extern PANEL_EXPORT(PANEL *) ground_panel(SCREEN *); +extern PANEL_EXPORT(PANEL *) ceiling_panel(SCREEN *); + +extern PANEL_EXPORT(void) NCURSES_SP_NAME(update_panels) (SCREEN*); +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* NCURSES_PANEL_H_incl */ + +/* end of panel.h */ diff --git a/illumos-x86_64/usr/include/ncurses/term.h b/illumos-x86_64/usr/include/ncurses/term.h new file mode 100644 index 00000000..2a0e6720 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/term.h @@ -0,0 +1,890 @@ +/**************************************************************************** + * Copyright 2018-2021,2023 Thomas E. Dickey * + * Copyright 1998-2013,2017 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/****************************************************************************/ +/* Author: Zeyd M. Ben-Halim 1992,1995 */ +/* and: Eric S. Raymond */ +/* and: Thomas E. Dickey 1995-on */ +/****************************************************************************/ + +/* $Id: MKterm.h.awk.in,v 1.85 2023/04/23 19:15:36 tom Exp $ */ + +/* +** term.h -- Definition of struct term +*/ + +#ifndef NCURSES_TERM_H_incl +#define NCURSES_TERM_H_incl 1 + +#undef NCURSES_VERSION +#define NCURSES_VERSION "6.5" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H + * definition (based on the system for which this was configured). + */ + +#ifndef __NCURSES_H + +typedef struct screen SCREEN; + +#if 1 +#undef NCURSES_SP_FUNCS +#define NCURSES_SP_FUNCS 20240511 +#undef NCURSES_SP_NAME +#define NCURSES_SP_NAME(name) name##_sp + +/* Define the sp-funcs helper function */ +#undef NCURSES_SP_OUTC +#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) +typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); +#endif + +#endif /* __NCURSES_H */ + +#undef NCURSES_CONST +#define NCURSES_CONST const + +#undef NCURSES_SBOOL +#define NCURSES_SBOOL char + +#undef NCURSES_USE_DATABASE +#define NCURSES_USE_DATABASE 1 + +#undef NCURSES_USE_TERMCAP +#define NCURSES_USE_TERMCAP 0 + +#undef NCURSES_XNAMES +#define NCURSES_XNAMES 1 + +/* We will use these symbols to hide differences between + * termios/termio/sgttyb interfaces. + */ +#undef TTY +#undef SET_TTY +#undef GET_TTY + +/* Assume POSIX termio if we have the header and function */ +/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */ +#if 1 && 1 + +#undef TERMIOS +#define TERMIOS 1 + +#include +#define TTY struct termios + +#else /* !HAVE_TERMIOS_H */ + +/* #if HAVE_TERMIO_H */ +#if 1 + +#undef TERMIOS +#define TERMIOS 1 + +#include +#define TTY struct termio + +#else /* !HAVE_TERMIO_H */ + +#if (defined(_WIN32) || defined(_WIN64)) +#if 0 +#include +#define TTY struct winconmode +#else +#include +#define TTY struct termios +#endif +#else +#undef TERMIOS +#include +#include +#define TTY struct sgttyb +#endif /* MINGW32 */ +#endif /* HAVE_TERMIO_H */ + +#endif /* HAVE_TERMIOS_H */ + +#ifdef TERMIOS +#define GET_TTY(fd, buf) tcgetattr(fd, buf) +#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf) +#elif 0 && (defined(_WIN32) || defined(_WIN64)) +#define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf) +#define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf) +#else +#define GET_TTY(fd, buf) gtty(fd, buf) +#define SET_TTY(fd, buf) stty(fd, buf) +#endif + +#ifndef GCC_NORETURN +#define GCC_NORETURN /* nothing */ +#endif + +#define NAMESIZE 256 + +/* The cast works because TERMTYPE is the first data in TERMINAL */ +#define CUR ((TERMTYPE *)(cur_term))-> + +#define auto_left_margin CUR Booleans[0] +#define auto_right_margin CUR Booleans[1] +#define no_esc_ctlc CUR Booleans[2] +#define ceol_standout_glitch CUR Booleans[3] +#define eat_newline_glitch CUR Booleans[4] +#define erase_overstrike CUR Booleans[5] +#define generic_type CUR Booleans[6] +#define hard_copy CUR Booleans[7] +#define has_meta_key CUR Booleans[8] +#define has_status_line CUR Booleans[9] +#define insert_null_glitch CUR Booleans[10] +#define memory_above CUR Booleans[11] +#define memory_below CUR Booleans[12] +#define move_insert_mode CUR Booleans[13] +#define move_standout_mode CUR Booleans[14] +#define over_strike CUR Booleans[15] +#define status_line_esc_ok CUR Booleans[16] +#define dest_tabs_magic_smso CUR Booleans[17] +#define tilde_glitch CUR Booleans[18] +#define transparent_underline CUR Booleans[19] +#define xon_xoff CUR Booleans[20] +#define needs_xon_xoff CUR Booleans[21] +#define prtr_silent CUR Booleans[22] +#define hard_cursor CUR Booleans[23] +#define non_rev_rmcup CUR Booleans[24] +#define no_pad_char CUR Booleans[25] +#define non_dest_scroll_region CUR Booleans[26] +#define can_change CUR Booleans[27] +#define back_color_erase CUR Booleans[28] +#define hue_lightness_saturation CUR Booleans[29] +#define col_addr_glitch CUR Booleans[30] +#define cr_cancels_micro_mode CUR Booleans[31] +#define has_print_wheel CUR Booleans[32] +#define row_addr_glitch CUR Booleans[33] +#define semi_auto_right_margin CUR Booleans[34] +#define cpi_changes_res CUR Booleans[35] +#define lpi_changes_res CUR Booleans[36] +#define columns CUR Numbers[0] +#define init_tabs CUR Numbers[1] +#define lines CUR Numbers[2] +#define lines_of_memory CUR Numbers[3] +#define magic_cookie_glitch CUR Numbers[4] +#define padding_baud_rate CUR Numbers[5] +#define virtual_terminal CUR Numbers[6] +#define width_status_line CUR Numbers[7] +#define num_labels CUR Numbers[8] +#define label_height CUR Numbers[9] +#define label_width CUR Numbers[10] +#define max_attributes CUR Numbers[11] +#define maximum_windows CUR Numbers[12] +#define max_colors CUR Numbers[13] +#define max_pairs CUR Numbers[14] +#define no_color_video CUR Numbers[15] +#define buffer_capacity CUR Numbers[16] +#define dot_vert_spacing CUR Numbers[17] +#define dot_horz_spacing CUR Numbers[18] +#define max_micro_address CUR Numbers[19] +#define max_micro_jump CUR Numbers[20] +#define micro_col_size CUR Numbers[21] +#define micro_line_size CUR Numbers[22] +#define number_of_pins CUR Numbers[23] +#define output_res_char CUR Numbers[24] +#define output_res_line CUR Numbers[25] +#define output_res_horz_inch CUR Numbers[26] +#define output_res_vert_inch CUR Numbers[27] +#define print_rate CUR Numbers[28] +#define wide_char_size CUR Numbers[29] +#define buttons CUR Numbers[30] +#define bit_image_entwining CUR Numbers[31] +#define bit_image_type CUR Numbers[32] +#define back_tab CUR Strings[0] +#define bell CUR Strings[1] +#define carriage_return CUR Strings[2] +#define change_scroll_region CUR Strings[3] +#define clear_all_tabs CUR Strings[4] +#define clear_screen CUR Strings[5] +#define clr_eol CUR Strings[6] +#define clr_eos CUR Strings[7] +#define column_address CUR Strings[8] +#define command_character CUR Strings[9] +#define cursor_address CUR Strings[10] +#define cursor_down CUR Strings[11] +#define cursor_home CUR Strings[12] +#define cursor_invisible CUR Strings[13] +#define cursor_left CUR Strings[14] +#define cursor_mem_address CUR Strings[15] +#define cursor_normal CUR Strings[16] +#define cursor_right CUR Strings[17] +#define cursor_to_ll CUR Strings[18] +#define cursor_up CUR Strings[19] +#define cursor_visible CUR Strings[20] +#define delete_character CUR Strings[21] +#define delete_line CUR Strings[22] +#define dis_status_line CUR Strings[23] +#define down_half_line CUR Strings[24] +#define enter_alt_charset_mode CUR Strings[25] +#define enter_blink_mode CUR Strings[26] +#define enter_bold_mode CUR Strings[27] +#define enter_ca_mode CUR Strings[28] +#define enter_delete_mode CUR Strings[29] +#define enter_dim_mode CUR Strings[30] +#define enter_insert_mode CUR Strings[31] +#define enter_secure_mode CUR Strings[32] +#define enter_protected_mode CUR Strings[33] +#define enter_reverse_mode CUR Strings[34] +#define enter_standout_mode CUR Strings[35] +#define enter_underline_mode CUR Strings[36] +#define erase_chars CUR Strings[37] +#define exit_alt_charset_mode CUR Strings[38] +#define exit_attribute_mode CUR Strings[39] +#define exit_ca_mode CUR Strings[40] +#define exit_delete_mode CUR Strings[41] +#define exit_insert_mode CUR Strings[42] +#define exit_standout_mode CUR Strings[43] +#define exit_underline_mode CUR Strings[44] +#define flash_screen CUR Strings[45] +#define form_feed CUR Strings[46] +#define from_status_line CUR Strings[47] +#define init_1string CUR Strings[48] +#define init_2string CUR Strings[49] +#define init_3string CUR Strings[50] +#define init_file CUR Strings[51] +#define insert_character CUR Strings[52] +#define insert_line CUR Strings[53] +#define insert_padding CUR Strings[54] +#define key_backspace CUR Strings[55] +#define key_catab CUR Strings[56] +#define key_clear CUR Strings[57] +#define key_ctab CUR Strings[58] +#define key_dc CUR Strings[59] +#define key_dl CUR Strings[60] +#define key_down CUR Strings[61] +#define key_eic CUR Strings[62] +#define key_eol CUR Strings[63] +#define key_eos CUR Strings[64] +#define key_f0 CUR Strings[65] +#define key_f1 CUR Strings[66] +#define key_f10 CUR Strings[67] +#define key_f2 CUR Strings[68] +#define key_f3 CUR Strings[69] +#define key_f4 CUR Strings[70] +#define key_f5 CUR Strings[71] +#define key_f6 CUR Strings[72] +#define key_f7 CUR Strings[73] +#define key_f8 CUR Strings[74] +#define key_f9 CUR Strings[75] +#define key_home CUR Strings[76] +#define key_ic CUR Strings[77] +#define key_il CUR Strings[78] +#define key_left CUR Strings[79] +#define key_ll CUR Strings[80] +#define key_npage CUR Strings[81] +#define key_ppage CUR Strings[82] +#define key_right CUR Strings[83] +#define key_sf CUR Strings[84] +#define key_sr CUR Strings[85] +#define key_stab CUR Strings[86] +#define key_up CUR Strings[87] +#define keypad_local CUR Strings[88] +#define keypad_xmit CUR Strings[89] +#define lab_f0 CUR Strings[90] +#define lab_f1 CUR Strings[91] +#define lab_f10 CUR Strings[92] +#define lab_f2 CUR Strings[93] +#define lab_f3 CUR Strings[94] +#define lab_f4 CUR Strings[95] +#define lab_f5 CUR Strings[96] +#define lab_f6 CUR Strings[97] +#define lab_f7 CUR Strings[98] +#define lab_f8 CUR Strings[99] +#define lab_f9 CUR Strings[100] +#define meta_off CUR Strings[101] +#define meta_on CUR Strings[102] +#define newline CUR Strings[103] +#define pad_char CUR Strings[104] +#define parm_dch CUR Strings[105] +#define parm_delete_line CUR Strings[106] +#define parm_down_cursor CUR Strings[107] +#define parm_ich CUR Strings[108] +#define parm_index CUR Strings[109] +#define parm_insert_line CUR Strings[110] +#define parm_left_cursor CUR Strings[111] +#define parm_right_cursor CUR Strings[112] +#define parm_rindex CUR Strings[113] +#define parm_up_cursor CUR Strings[114] +#define pkey_key CUR Strings[115] +#define pkey_local CUR Strings[116] +#define pkey_xmit CUR Strings[117] +#define print_screen CUR Strings[118] +#define prtr_off CUR Strings[119] +#define prtr_on CUR Strings[120] +#define repeat_char CUR Strings[121] +#define reset_1string CUR Strings[122] +#define reset_2string CUR Strings[123] +#define reset_3string CUR Strings[124] +#define reset_file CUR Strings[125] +#define restore_cursor CUR Strings[126] +#define row_address CUR Strings[127] +#define save_cursor CUR Strings[128] +#define scroll_forward CUR Strings[129] +#define scroll_reverse CUR Strings[130] +#define set_attributes CUR Strings[131] +#define set_tab CUR Strings[132] +#define set_window CUR Strings[133] +#define tab CUR Strings[134] +#define to_status_line CUR Strings[135] +#define underline_char CUR Strings[136] +#define up_half_line CUR Strings[137] +#define init_prog CUR Strings[138] +#define key_a1 CUR Strings[139] +#define key_a3 CUR Strings[140] +#define key_b2 CUR Strings[141] +#define key_c1 CUR Strings[142] +#define key_c3 CUR Strings[143] +#define prtr_non CUR Strings[144] +#define char_padding CUR Strings[145] +#define acs_chars CUR Strings[146] +#define plab_norm CUR Strings[147] +#define key_btab CUR Strings[148] +#define enter_xon_mode CUR Strings[149] +#define exit_xon_mode CUR Strings[150] +#define enter_am_mode CUR Strings[151] +#define exit_am_mode CUR Strings[152] +#define xon_character CUR Strings[153] +#define xoff_character CUR Strings[154] +#define ena_acs CUR Strings[155] +#define label_on CUR Strings[156] +#define label_off CUR Strings[157] +#define key_beg CUR Strings[158] +#define key_cancel CUR Strings[159] +#define key_close CUR Strings[160] +#define key_command CUR Strings[161] +#define key_copy CUR Strings[162] +#define key_create CUR Strings[163] +#define key_end CUR Strings[164] +#define key_enter CUR Strings[165] +#define key_exit CUR Strings[166] +#define key_find CUR Strings[167] +#define key_help CUR Strings[168] +#define key_mark CUR Strings[169] +#define key_message CUR Strings[170] +#define key_move CUR Strings[171] +#define key_next CUR Strings[172] +#define key_open CUR Strings[173] +#define key_options CUR Strings[174] +#define key_previous CUR Strings[175] +#define key_print CUR Strings[176] +#define key_redo CUR Strings[177] +#define key_reference CUR Strings[178] +#define key_refresh CUR Strings[179] +#define key_replace CUR Strings[180] +#define key_restart CUR Strings[181] +#define key_resume CUR Strings[182] +#define key_save CUR Strings[183] +#define key_suspend CUR Strings[184] +#define key_undo CUR Strings[185] +#define key_sbeg CUR Strings[186] +#define key_scancel CUR Strings[187] +#define key_scommand CUR Strings[188] +#define key_scopy CUR Strings[189] +#define key_screate CUR Strings[190] +#define key_sdc CUR Strings[191] +#define key_sdl CUR Strings[192] +#define key_select CUR Strings[193] +#define key_send CUR Strings[194] +#define key_seol CUR Strings[195] +#define key_sexit CUR Strings[196] +#define key_sfind CUR Strings[197] +#define key_shelp CUR Strings[198] +#define key_shome CUR Strings[199] +#define key_sic CUR Strings[200] +#define key_sleft CUR Strings[201] +#define key_smessage CUR Strings[202] +#define key_smove CUR Strings[203] +#define key_snext CUR Strings[204] +#define key_soptions CUR Strings[205] +#define key_sprevious CUR Strings[206] +#define key_sprint CUR Strings[207] +#define key_sredo CUR Strings[208] +#define key_sreplace CUR Strings[209] +#define key_sright CUR Strings[210] +#define key_srsume CUR Strings[211] +#define key_ssave CUR Strings[212] +#define key_ssuspend CUR Strings[213] +#define key_sundo CUR Strings[214] +#define req_for_input CUR Strings[215] +#define key_f11 CUR Strings[216] +#define key_f12 CUR Strings[217] +#define key_f13 CUR Strings[218] +#define key_f14 CUR Strings[219] +#define key_f15 CUR Strings[220] +#define key_f16 CUR Strings[221] +#define key_f17 CUR Strings[222] +#define key_f18 CUR Strings[223] +#define key_f19 CUR Strings[224] +#define key_f20 CUR Strings[225] +#define key_f21 CUR Strings[226] +#define key_f22 CUR Strings[227] +#define key_f23 CUR Strings[228] +#define key_f24 CUR Strings[229] +#define key_f25 CUR Strings[230] +#define key_f26 CUR Strings[231] +#define key_f27 CUR Strings[232] +#define key_f28 CUR Strings[233] +#define key_f29 CUR Strings[234] +#define key_f30 CUR Strings[235] +#define key_f31 CUR Strings[236] +#define key_f32 CUR Strings[237] +#define key_f33 CUR Strings[238] +#define key_f34 CUR Strings[239] +#define key_f35 CUR Strings[240] +#define key_f36 CUR Strings[241] +#define key_f37 CUR Strings[242] +#define key_f38 CUR Strings[243] +#define key_f39 CUR Strings[244] +#define key_f40 CUR Strings[245] +#define key_f41 CUR Strings[246] +#define key_f42 CUR Strings[247] +#define key_f43 CUR Strings[248] +#define key_f44 CUR Strings[249] +#define key_f45 CUR Strings[250] +#define key_f46 CUR Strings[251] +#define key_f47 CUR Strings[252] +#define key_f48 CUR Strings[253] +#define key_f49 CUR Strings[254] +#define key_f50 CUR Strings[255] +#define key_f51 CUR Strings[256] +#define key_f52 CUR Strings[257] +#define key_f53 CUR Strings[258] +#define key_f54 CUR Strings[259] +#define key_f55 CUR Strings[260] +#define key_f56 CUR Strings[261] +#define key_f57 CUR Strings[262] +#define key_f58 CUR Strings[263] +#define key_f59 CUR Strings[264] +#define key_f60 CUR Strings[265] +#define key_f61 CUR Strings[266] +#define key_f62 CUR Strings[267] +#define key_f63 CUR Strings[268] +#define clr_bol CUR Strings[269] +#define clear_margins CUR Strings[270] +#define set_left_margin CUR Strings[271] +#define set_right_margin CUR Strings[272] +#define label_format CUR Strings[273] +#define set_clock CUR Strings[274] +#define display_clock CUR Strings[275] +#define remove_clock CUR Strings[276] +#define create_window CUR Strings[277] +#define goto_window CUR Strings[278] +#define hangup CUR Strings[279] +#define dial_phone CUR Strings[280] +#define quick_dial CUR Strings[281] +#define tone CUR Strings[282] +#define pulse CUR Strings[283] +#define flash_hook CUR Strings[284] +#define fixed_pause CUR Strings[285] +#define wait_tone CUR Strings[286] +#define user0 CUR Strings[287] +#define user1 CUR Strings[288] +#define user2 CUR Strings[289] +#define user3 CUR Strings[290] +#define user4 CUR Strings[291] +#define user5 CUR Strings[292] +#define user6 CUR Strings[293] +#define user7 CUR Strings[294] +#define user8 CUR Strings[295] +#define user9 CUR Strings[296] +#define orig_pair CUR Strings[297] +#define orig_colors CUR Strings[298] +#define initialize_color CUR Strings[299] +#define initialize_pair CUR Strings[300] +#define set_color_pair CUR Strings[301] +#define set_foreground CUR Strings[302] +#define set_background CUR Strings[303] +#define change_char_pitch CUR Strings[304] +#define change_line_pitch CUR Strings[305] +#define change_res_horz CUR Strings[306] +#define change_res_vert CUR Strings[307] +#define define_char CUR Strings[308] +#define enter_doublewide_mode CUR Strings[309] +#define enter_draft_quality CUR Strings[310] +#define enter_italics_mode CUR Strings[311] +#define enter_leftward_mode CUR Strings[312] +#define enter_micro_mode CUR Strings[313] +#define enter_near_letter_quality CUR Strings[314] +#define enter_normal_quality CUR Strings[315] +#define enter_shadow_mode CUR Strings[316] +#define enter_subscript_mode CUR Strings[317] +#define enter_superscript_mode CUR Strings[318] +#define enter_upward_mode CUR Strings[319] +#define exit_doublewide_mode CUR Strings[320] +#define exit_italics_mode CUR Strings[321] +#define exit_leftward_mode CUR Strings[322] +#define exit_micro_mode CUR Strings[323] +#define exit_shadow_mode CUR Strings[324] +#define exit_subscript_mode CUR Strings[325] +#define exit_superscript_mode CUR Strings[326] +#define exit_upward_mode CUR Strings[327] +#define micro_column_address CUR Strings[328] +#define micro_down CUR Strings[329] +#define micro_left CUR Strings[330] +#define micro_right CUR Strings[331] +#define micro_row_address CUR Strings[332] +#define micro_up CUR Strings[333] +#define order_of_pins CUR Strings[334] +#define parm_down_micro CUR Strings[335] +#define parm_left_micro CUR Strings[336] +#define parm_right_micro CUR Strings[337] +#define parm_up_micro CUR Strings[338] +#define select_char_set CUR Strings[339] +#define set_bottom_margin CUR Strings[340] +#define set_bottom_margin_parm CUR Strings[341] +#define set_left_margin_parm CUR Strings[342] +#define set_right_margin_parm CUR Strings[343] +#define set_top_margin CUR Strings[344] +#define set_top_margin_parm CUR Strings[345] +#define start_bit_image CUR Strings[346] +#define start_char_set_def CUR Strings[347] +#define stop_bit_image CUR Strings[348] +#define stop_char_set_def CUR Strings[349] +#define subscript_characters CUR Strings[350] +#define superscript_characters CUR Strings[351] +#define these_cause_cr CUR Strings[352] +#define zero_motion CUR Strings[353] +#define char_set_names CUR Strings[354] +#define key_mouse CUR Strings[355] +#define mouse_info CUR Strings[356] +#define req_mouse_pos CUR Strings[357] +#define get_mouse CUR Strings[358] +#define set_a_foreground CUR Strings[359] +#define set_a_background CUR Strings[360] +#define pkey_plab CUR Strings[361] +#define device_type CUR Strings[362] +#define code_set_init CUR Strings[363] +#define set0_des_seq CUR Strings[364] +#define set1_des_seq CUR Strings[365] +#define set2_des_seq CUR Strings[366] +#define set3_des_seq CUR Strings[367] +#define set_lr_margin CUR Strings[368] +#define set_tb_margin CUR Strings[369] +#define bit_image_repeat CUR Strings[370] +#define bit_image_newline CUR Strings[371] +#define bit_image_carriage_return CUR Strings[372] +#define color_names CUR Strings[373] +#define define_bit_image_region CUR Strings[374] +#define end_bit_image_region CUR Strings[375] +#define set_color_band CUR Strings[376] +#define set_page_length CUR Strings[377] +#define display_pc_char CUR Strings[378] +#define enter_pc_charset_mode CUR Strings[379] +#define exit_pc_charset_mode CUR Strings[380] +#define enter_scancode_mode CUR Strings[381] +#define exit_scancode_mode CUR Strings[382] +#define pc_term_options CUR Strings[383] +#define scancode_escape CUR Strings[384] +#define alt_scancode_esc CUR Strings[385] +#define enter_horizontal_hl_mode CUR Strings[386] +#define enter_left_hl_mode CUR Strings[387] +#define enter_low_hl_mode CUR Strings[388] +#define enter_right_hl_mode CUR Strings[389] +#define enter_top_hl_mode CUR Strings[390] +#define enter_vertical_hl_mode CUR Strings[391] +#define set_a_attributes CUR Strings[392] +#define set_pglen_inch CUR Strings[393] + +#define BOOLWRITE 37 +#define NUMWRITE 33 +#define STRWRITE 394 + +/* older synonyms for some capabilities */ +#define beehive_glitch no_esc_ctlc +#define teleray_glitch dest_tabs_magic_smso + +/* HPUX-11 uses this name rather than the standard one */ +#ifndef micro_char_size +#define micro_char_size micro_col_size +#endif + +#ifdef __INTERNAL_CAPS_VISIBLE +#define termcap_init2 CUR Strings[394] +#define termcap_reset CUR Strings[395] +#define magic_cookie_glitch_ul CUR Numbers[33] +#define backspaces_with_bs CUR Booleans[37] +#define crt_no_scrolling CUR Booleans[38] +#define no_correctly_working_cr CUR Booleans[39] +#define carriage_return_delay CUR Numbers[34] +#define new_line_delay CUR Numbers[35] +#define linefeed_if_not_lf CUR Strings[396] +#define backspace_if_not_bs CUR Strings[397] +#define gnu_has_meta_key CUR Booleans[40] +#define linefeed_is_newline CUR Booleans[41] +#define backspace_delay CUR Numbers[36] +#define horizontal_tab_delay CUR Numbers[37] +#define number_of_function_keys CUR Numbers[38] +#define other_non_function_keys CUR Strings[398] +#define arrow_key_map CUR Strings[399] +#define has_hardware_tabs CUR Booleans[42] +#define return_does_clr_eol CUR Booleans[43] +#define acs_ulcorner CUR Strings[400] +#define acs_llcorner CUR Strings[401] +#define acs_urcorner CUR Strings[402] +#define acs_lrcorner CUR Strings[403] +#define acs_ltee CUR Strings[404] +#define acs_rtee CUR Strings[405] +#define acs_btee CUR Strings[406] +#define acs_ttee CUR Strings[407] +#define acs_hline CUR Strings[408] +#define acs_vline CUR Strings[409] +#define acs_plus CUR Strings[410] +#define memory_lock CUR Strings[411] +#define memory_unlock CUR Strings[412] +#define box_chars_1 CUR Strings[413] +#endif /* __INTERNAL_CAPS_VISIBLE */ + + +/* + * Predefined terminfo array sizes + */ +#define BOOLCOUNT 44 +#define NUMCOUNT 39 +#define STRCOUNT 414 + +/* used by code for comparing entries */ +#define acs_chars_index 146 + +typedef struct termtype { /* in-core form of terminfo data */ + char *term_names; /* str_table offset of term names */ + char *str_table; /* pointer to string table */ + NCURSES_SBOOL *Booleans; /* array of boolean values */ + short *Numbers; /* array of integer values */ + char **Strings; /* array of string offsets */ + +#if NCURSES_XNAMES + char *ext_str_table; /* pointer to extended string table */ + char **ext_Names; /* corresponding names */ + + unsigned short num_Booleans;/* count total Booleans */ + unsigned short num_Numbers; /* count total Numbers */ + unsigned short num_Strings; /* count total Strings */ + + unsigned short ext_Booleans;/* count extensions to Booleans */ + unsigned short ext_Numbers; /* count extensions to Numbers */ + unsigned short ext_Strings; /* count extensions to Strings */ +#endif /* NCURSES_XNAMES */ + +} TERMTYPE; + +/* + * The only reason these structures are visible is for read-only use. + * Programs which modify the data are not, never were, portable across + * curses implementations. + * + * The first field in TERMINAL is used in macros. + * The remaining fields are private. + */ +#ifdef NCURSES_INTERNALS + +#undef TERMINAL +#define TERMINAL struct term +TERMINAL; + +typedef struct termtype2 { /* in-core form of terminfo data */ + char *term_names; /* str_table offset of term names */ + char *str_table; /* pointer to string table */ + NCURSES_SBOOL *Booleans; /* array of boolean values */ + int *Numbers; /* array of integer values */ + char **Strings; /* array of string offsets */ + +#if NCURSES_XNAMES + char *ext_str_table; /* pointer to extended string table */ + char **ext_Names; /* corresponding names */ + + unsigned short num_Booleans;/* count total Booleans */ + unsigned short num_Numbers; /* count total Numbers */ + unsigned short num_Strings; /* count total Strings */ + + unsigned short ext_Booleans;/* count extensions to Booleans */ + unsigned short ext_Numbers; /* count extensions to Numbers */ + unsigned short ext_Strings; /* count extensions to Strings */ +#endif /* NCURSES_XNAMES */ + +} TERMTYPE2; +#else + +typedef struct term { /* describe an actual terminal */ + TERMTYPE type; /* terminal type description */ +} TERMINAL; + +#endif /* NCURSES_INTERNALS */ + + +#if 0 && !0 +extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term; +#elif 0 +NCURSES_WRAPPED_VAR(TERMINAL *, cur_term); +#define cur_term NCURSES_PUBLIC_VAR(cur_term()) +#else +extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term; +#endif + +#if 0 || 0 +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames); +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes); +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames); +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames); +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes); +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames); +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames); +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes); +NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames); + +#define boolnames NCURSES_PUBLIC_VAR(boolnames()) +#define boolcodes NCURSES_PUBLIC_VAR(boolcodes()) +#define boolfnames NCURSES_PUBLIC_VAR(boolfnames()) +#define numnames NCURSES_PUBLIC_VAR(numnames()) +#define numcodes NCURSES_PUBLIC_VAR(numcodes()) +#define numfnames NCURSES_PUBLIC_VAR(numfnames()) +#define strnames NCURSES_PUBLIC_VAR(strnames()) +#define strcodes NCURSES_PUBLIC_VAR(strcodes()) +#define strfnames NCURSES_PUBLIC_VAR(strfnames()) + +#else + +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[]; +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[]; +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[]; +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[]; +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[]; +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[]; +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[]; +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[]; +extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[]; + +#endif + +/* + * These entrypoints are used only by the ncurses utilities such as tic. + */ +#ifdef NCURSES_INTERNALS + +extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf); +extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const); +extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *); +extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int); +extern NCURSES_EXPORT(char *) _nc_first_name (const char *const); +extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const); +extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...); +extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *); +extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const); + +#endif /* NCURSES_INTERNALS */ + +/* + * Normal entry points + */ +extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *); +extern NCURSES_EXPORT(int) del_curterm (TERMINAL *); + +/* miscellaneous entry points */ +extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *); +extern NCURSES_EXPORT(int) setupterm (const char *,int,int *); + +/* terminfo entry points, also declared in curses.h */ +#if !defined(__NCURSES_H) +extern NCURSES_EXPORT(char *) tigetstr (const char *); +extern NCURSES_EXPORT_VAR(char) ttytype[]; +extern NCURSES_EXPORT(int) putp (const char *); +extern NCURSES_EXPORT(int) tigetflag (const char *); +extern NCURSES_EXPORT(int) tigetnum (const char *); + +#if 1 /* NCURSES_TPARM_VARARGS */ +extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ +#else +extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long); /* special */ +#endif + +extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ +extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...); /* special */ +extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *); /* special */ + +#endif /* __NCURSES_H */ + +/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */ +#if !defined(NCURSES_TERMCAP_H_incl) +extern NCURSES_EXPORT(char *) tgetstr (const char *, char **); +extern NCURSES_EXPORT(char *) tgoto (const char *, int, int); +extern NCURSES_EXPORT(int) tgetent (char *, const char *); +extern NCURSES_EXPORT(int) tgetflag (const char *); +extern NCURSES_EXPORT(int) tgetnum (const char *); +extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int)); +#endif /* NCURSES_TERMCAP_H_incl */ + +/* + * Include curses.h before term.h to enable these extensions. + */ +#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0) + +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *); + +#if 1 /* NCURSES_TPARM_VARARGS */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...); /* special */ +#else +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long); /* special */ +#endif + +/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **); +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC); + +extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *); + +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *); +#endif /* NCURSES_SP_FUNCS */ + +/* + * Debugging features. + */ +extern GCC_NORETURN NCURSES_EXPORT(void) exit_terminfo(int); + +#ifdef __cplusplus +} +#endif + +#endif /* NCURSES_TERM_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/term_entry.h b/illumos-x86_64/usr/include/ncurses/term_entry.h new file mode 100644 index 00000000..2e098331 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/term_entry.h @@ -0,0 +1,220 @@ +/**************************************************************************** + * Copyright 2018-2022,2023 Thomas E. Dickey * + * Copyright 1998-2015,2017 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1998-on * + ****************************************************************************/ + +/* $Id: term_entry.h,v 1.64 2023/04/22 13:37:14 tom Exp $ */ + +/* + * term_entry.h -- interface to entry-manipulation code + */ + +#ifndef NCURSES_TERM_ENTRY_H_incl +#define NCURSES_TERM_ENTRY_H_incl 1 +/* *INDENT-OFF* */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * These macros may be used by programs that know about TERMTYPE: + */ +#if NCURSES_XNAMES +#define NUM_BOOLEANS(tp) (tp)->num_Booleans +#define NUM_NUMBERS(tp) (tp)->num_Numbers +#define NUM_STRINGS(tp) (tp)->num_Strings +#define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i] +#else +#define NUM_BOOLEANS(tp) BOOLCOUNT +#define NUM_NUMBERS(tp) NUMCOUNT +#define NUM_STRINGS(tp) STRCOUNT +#define EXT_NAMES(tp,i,limit,index,table) table[i] +#endif + +#define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings) + +#define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++) +#define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++) +#define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++) + +#if NCURSES_XNAMES +#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++) +#define for_each_ext_number(n,tp) for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp); n++) +#define for_each_ext_string(n,tp) for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp); n++) +#endif + +#define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names) +#define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names) +#define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names) + +/* + * The remaining type-definitions and macros are used only internally by the + * ncurses utilities. + */ +#ifdef NCURSES_INTERNALS + +/* + * see db_iterator.c - this enumeration lists the places searched for a + * terminal description and defines the order in which they are searched. + */ +typedef enum { + dbdTIC = 0, /* special, used by tic when writing entry */ +#if NCURSES_USE_DATABASE + dbdEnvOnce, /* the $TERMINFO environment variable */ + dbdHome, /* $HOME/.terminfo */ + dbdEnvList, /* the $TERMINFO_DIRS environment variable */ + dbdCfgList, /* the compiled-in TERMINFO_DIRS value */ + dbdCfgOnce, /* the compiled-in TERMINFO value */ +#endif +#if NCURSES_USE_TERMCAP + dbdEnvOnce2, /* the $TERMCAP environment variable */ + dbdEnvList2, /* the $TERMPATH environment variable */ + dbdCfgList2, /* the compiled-in TERMPATH */ +#endif + dbdLAST +} DBDIRS; + +#define MAX_USES 32 +#define MAX_CROSSLINKS 16 + +typedef struct entry ENTRY; + +typedef struct { + char *name; + ENTRY *link; + long line; +} ENTRY_USES; + +struct entry { + TERMTYPE2 tterm; + unsigned nuses; + ENTRY_USES uses[MAX_USES]; + int ncrosslinks; + ENTRY *crosslinks[MAX_CROSSLINKS]; + long cstart; + long cend; + long startline; + ENTRY *next; + ENTRY *last; +}; + +extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head; +extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail; +#define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next) +#define for_entry_list2(qp,q0) for (qp = q0; qp; qp = qp->next) + +#define MAX_LINE 132 + +#define NULLHOOK (bool(*)(ENTRY *))0 + +/* + * Note that WANTED and PRESENT are not simple inverses! If a capability + * has been explicitly cancelled, it is not considered WANTED. + */ +#define WANTED(s) ((s) == ABSENT_STRING) +#define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING)) + +#define ANDMISSING(p,q) \ + { \ + if (PRESENT(p) && !PRESENT(q)) \ + _nc_warning(#p " but no " #q); \ + } + +#define PAIRED(p,q) \ + { \ + if (PRESENT(q) && !PRESENT(p)) \ + _nc_warning(#q " but no " #p); \ + if (PRESENT(p) && !PRESENT(q)) \ + _nc_warning(#p " but no " #q); \ + } + +/* + * These entrypoints are used only by the ncurses utilities such as tic. + */ + +/* alloc_entry.c: elementary allocation code */ +extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp); +extern NCURSES_EXPORT(char *) _nc_save_str (const char *const); +extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const); +extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const); +extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool); + +/* alloc_ttype.c: elementary allocation code */ +extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *); + +/* free_ttype.c: elementary allocation code */ +extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *); +extern NCURSES_EXPORT(void) _nc_free_termtype1 (TERMTYPE *); +extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *); + +/* lib_termcap.c: trim sgr0 string for termcap users */ +extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *); + +/* parse_entry.c: entry-parsing code */ +#if NCURSES_XNAMES +extern NCURSES_EXPORT_VAR(bool) _nc_user_definable; +extern NCURSES_EXPORT_VAR(bool) _nc_disable_period; +#endif +extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool); +extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *); + +/* write_entry.c: writing an entry to the file system */ +extern NCURSES_EXPORT(void) _nc_set_writedir (const char *); +extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const); +extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned); + +/* comp_parse.c: entry list handling */ +extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*)); +extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *); +extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */ +extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool); +extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *); +extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */ +extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2)(TERMTYPE2 *, bool); + +/* trace_xnames.c */ +extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *); + +#endif /* NCURSES_INTERNALS */ + +#ifdef __cplusplus +} +#endif + +/* *INDENT-ON* */ + +#endif /* NCURSES_TERM_ENTRY_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/termcap.h b/illumos-x86_64/usr/include/ncurses/termcap.h new file mode 100644 index 00000000..024e08a7 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/termcap.h @@ -0,0 +1,73 @@ +/**************************************************************************** + * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 1998-2000,2001 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* $Id: termcap.h.in,v 1.20 2021/06/17 21:26:02 tom Exp $ */ + +#ifndef NCURSES_TERMCAP_H_incl +#define NCURSES_TERMCAP_H_incl 1 + +#undef NCURSES_VERSION +#define NCURSES_VERSION "6.5" + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include + +#undef NCURSES_OSPEED +#define NCURSES_OSPEED short + +extern NCURSES_EXPORT_VAR(char) PC; +extern NCURSES_EXPORT_VAR(char *) UP; +extern NCURSES_EXPORT_VAR(char *) BC; +extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed; + +#if !defined(NCURSES_TERM_H_incl) +extern NCURSES_EXPORT(char *) tgetstr (const char *, char **); +extern NCURSES_EXPORT(char *) tgoto (const char *, int, int); +extern NCURSES_EXPORT(int) tgetent (char *, const char *); +extern NCURSES_EXPORT(int) tgetflag (const char *); +extern NCURSES_EXPORT(int) tgetnum (const char *); +extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int)); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* NCURSES_TERMCAP_H_incl */ diff --git a/illumos-x86_64/usr/include/ncurses/unctrl.h b/illumos-x86_64/usr/include/ncurses/unctrl.h new file mode 100644 index 00000000..ba7e1bf4 --- /dev/null +++ b/illumos-x86_64/usr/include/ncurses/unctrl.h @@ -0,0 +1,68 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2001,2009 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* + * unctrl.h + * + * Display a printable version of a control character. + * Control characters are displayed in caret notation (^x), DELETE is displayed + * as ^?. Printable characters are displayed as is. + */ + +/* $Id: unctrl.h.in,v 1.12 2020/02/02 23:34:34 tom Exp $ */ + +#ifndef NCURSES_UNCTRL_H_incl +#define NCURSES_UNCTRL_H_incl 1 + +#undef NCURSES_VERSION +#define NCURSES_VERSION "6.5" + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#undef unctrl +NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype); + +#if 1 +NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* NCURSES_UNCTRL_H_incl */ diff --git a/illumos-x86_64/usr/include/ndbm.h b/illumos-x86_64/usr/include/ndbm.h new file mode 100644 index 00000000..68d175a3 --- /dev/null +++ b/illumos-x86_64/usr/include/ndbm.h @@ -0,0 +1,118 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1989 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +/* + * Hashed key data base library. + */ + +#ifndef _NDBM_H +#define _NDBM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * flags to dbm_store() + */ +#define DBM_INSERT 0 +#define DBM_REPLACE 1 + +#define _PBLKSIZ 1024 +#define _DBLKSIZ 4096 + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define PBLKSIZ _PBLKSIZ +#define DBLKSIZ _DBLKSIZ +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +typedef struct { + int dbm_dirf; /* open directory file */ + int dbm_pagf; /* open page file */ + int dbm_flags; /* flags, see below */ + long dbm_maxbno; /* last ``bit'' in dir file */ + long dbm_bitno; /* current bit number */ + long dbm_hmask; /* hash mask */ + long dbm_blkptr; /* current block for dbm_nextkey */ + int dbm_keyptr; /* current key for dbm_nextkey */ + long dbm_blkno; /* current page to read/write */ + long dbm_pagbno; /* current page in pagbuf */ + char dbm_pagbuf[_PBLKSIZ]; /* page file block buffer */ + long dbm_dirbno; /* current block in dirbuf */ + char dbm_dirbuf[_DBLKSIZ]; /* directory file block buffer */ +} DBM; + +#if defined(_XPG4_2) +typedef struct { + void *dptr; + size_t dsize; +} datum; +#else +typedef struct { + char *dptr; + long dsize; +} datum; +#endif + +DBM *dbm_open(const char *, int, mode_t); +void dbm_close(DBM *); +datum dbm_fetch(DBM *, datum); +datum dbm_firstkey(DBM *); +datum dbm_nextkey(DBM *); +int dbm_delete(DBM *, datum); +int dbm_store(DBM *, datum, datum, int); +int dbm_clearerr(DBM *); +int dbm_error(DBM *); + +#define _DBM_RDONLY 0x1 /* data base open read-only */ +#define _DBM_IOERR 0x2 /* data base I/O error */ + +#define dbm_rdonly(__db) ((__db)->dbm_flags & _DBM_RDONLY) +#define dbm_error(__db) ((__db)->dbm_flags & _DBM_IOERR) +/* use this one at your own risk! */ +#define dbm_clearerr(__db) ((__db)->dbm_flags &= ~_DBM_IOERR) +/* for fstat(2) */ +#define dbm_dirfno(__db) ((__db)->dbm_dirf) +#define dbm_pagfno(__db) ((__db)->dbm_pagf) + +#ifdef __cplusplus +} +#endif + +#endif /* _NDBM_H */ diff --git a/illumos-x86_64/usr/include/ndpd.h b/illumos-x86_64/usr/include/ndpd.h new file mode 100644 index 00000000..a8b16d9a --- /dev/null +++ b/illumos-x86_64/usr/include/ndpd.h @@ -0,0 +1,149 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NDPD_H +#define _NDPD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define NDPD_SNMP_SOCKET "/var/run/in.ndpd_mib" +#define NDPD_SNMP_INFO_REQ 1 +#define NDPD_SNMP_INFO_RESPONSE 2 +#define NDPD_PHYINT_INFO 3 +#define NDPD_PREFIX_INFO 4 +#define NDPD_ROUTER_INFO 5 + +#define NDPD_SNMP_INFO_VER 1 +#define NDPD_PHYINT_INFO_VER 1 +#define NDPD_PREFIX_INFO_VER 1 +#define NDPD_ROUTER_INFO_VER 1 + +/* + * Data structures used to handle configuration variables set in ndpd.conf. + * cf_notdefault is set for variables explicitly set in ndpd.conf. + */ +struct confvar { + uint_t cf_value; + boolean_t cf_notdefault; +}; + +extern struct confvar ifdefaults[]; + +/* + * Interfaces configuration variable indicies + */ +#define I_DupAddrDetectTransmits 0 /* From RFC 2462 */ +#define I_AdvSendAdvertisements 1 +#define I_MaxRtrAdvInterval 2 /* In seconds */ +#define I_MinRtrAdvInterval 3 /* In seconds */ +#define I_AdvManagedFlag 4 +#define I_AdvOtherConfigFlag 5 +#define I_AdvLinkMTU 6 +#define I_AdvReachableTime 7 /* In milliseconds */ +#define I_AdvRetransTimer 8 /* In milliseconds */ +#define I_AdvCurHopLimit 9 +#define I_AdvDefaultLifetime 10 /* In seconds */ +#define I_StatelessAddrConf 11 +#define I_TmpAddrsEnabled 12 /* From RFC 3041 */ +#define I_TmpValidLifetime 13 /* In seconds */ +#define I_TmpPreferredLifetime 14 /* In seconds */ +#define I_TmpRegenAdvance 15 /* In seconds */ +#define I_TmpMaxDesyncFactor 16 /* In seconds */ +#define I_StatefulAddrConf 17 +#define I_IFSIZE 18 /* # of variables */ + +typedef struct ndpd_info_s { + uint_t info_type; + uint_t info_version; + uint_t info_num_of_phyints; +} ndpd_info_t; + +typedef struct ndpd_prefix_info_s { + uint_t prefix_info_type; + uint_t prefix_info_version; + struct in6_addr prefix_prefix; /* Used to indentify prefix */ + uint_t prefix_len; /* Num bits valid */ + uint_t prefix_flags; /* IFF_ flags */ + uint_t prefix_phyint_index; + uint_t prefix_ValidLifetime; /* In ms w/ 2 hour rule */ + uint_t prefix_PreferredLifetime; /* In millseconds */ + uint_t prefix_OnLinkLifetime; /* ms valid w/o 2 hour rule */ + boolean_t prefix_OnLinkFlag; + boolean_t prefix_AutonomousFlag; +} ndpd_prefix_info_t; + +typedef struct ndpd_router_info_s { + uint_t router_info_type; + uint_t router_info_version; + struct in6_addr router_address; /* Used to identify router */ + uint_t router_lifetime; /* In milliseconds */ + uint_t router_phyint_index; +} ndpd_router_info_t; + + +typedef struct ndpd_phyint_info_s { + uint_t phyint_info_type; + uint_t phyint_info_version; + int phyint_index; + struct confvar phyint_config[I_IFSIZE]; +#define phyint_DupAddrDetectTransmits \ + phyint_config[I_DupAddrDetectTransmits].cf_value +#define phyint_AdvSendAdvertisements \ + phyint_config[I_AdvSendAdvertisements].cf_value +#define phyint_MaxRtrAdvInterval \ + phyint_config[I_MaxRtrAdvInterval].cf_value +#define phyint_MinRtrAdvInterval \ + phyint_config[I_MinRtrAdvInterval].cf_value +#define phyint_AdvManagedFlag phyint_config[I_AdvManagedFlag].cf_value +#define phyint_AdvOtherConfigFlag \ + phyint_config[I_AdvOtherConfigFlag].cf_value +#define phyint_AdvLinkMTU phyint_config[I_AdvLinkMTU].cf_value +#define phyint_AdvReachableTime phyint_config[I_AdvReachableTime].cf_value +#define phyint_AdvRetransTimer phyint_config[I_AdvRetransTimer].cf_value +#define phyint_AdvCurHopLimit phyint_config[I_AdvCurHopLimit].cf_value +#define phyint_AdvDefaultLifetime \ + phyint_config[I_AdvDefaultLifetime].cf_value +#define phyint_StatelessAddrConf \ + phyint_config[I_StatelessAddrConf].cf_value +#define phyint_TmpAddrsEnabled phyint_config[I_TmpAddrsEnabled].cf_value +#define phyint_TmpValidLifetime phyint_config[I_TmpValidLifetime].cf_value +#define phyint_TmpPreferredLifetime \ + phyint_config[I_TmpPreferredLifetime].cf_value +#define phyint_TmpRegenAdvance phyint_config[I_TmpRegenAdvance].cf_value +#define phyint_TmpMaxDesyncFactor \ + phyint_config[I_TmpMaxDesyncFactor].cf_value +#define phyint_StatefulAddrConf \ + phyint_config[I_StatefulAddrConf].cf_value + uint_t phyint_num_of_prefixes; + uint_t phyint_num_of_routers; +} ndpd_phyint_info_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _NDPD_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/agent_callbacks.h b/illumos-x86_64/usr/include/net-snmp/agent/agent_callbacks.h new file mode 100644 index 00000000..d600a665 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/agent_callbacks.h @@ -0,0 +1,22 @@ +#ifndef AGENT_CALLBACKS_H +#define AGENT_CALLBACKS_H + +#define SNMPD_CALLBACK_ACM_CHECK 0 +#define SNMPD_CALLBACK_REGISTER_OID 1 +#define SNMPD_CALLBACK_UNREGISTER_OID 2 +#define SNMPD_CALLBACK_REG_SYSOR 3 +#define SNMPD_CALLBACK_UNREG_SYSOR 4 +#define SNMPD_CALLBACK_ACM_CHECK_INITIAL 5 +#define SNMPD_CALLBACK_SEND_TRAP1 6 +#define SNMPD_CALLBACK_SEND_TRAP2 7 +#define SNMPD_CALLBACK_REGISTER_NOTIFICATIONS 8 +#define SNMPD_CALLBACK_PRE_UPDATE_CONFIG 9 +#define SNMPD_CALLBACK_INDEX_START 10 +#define SNMPD_CALLBACK_INDEX_STOP 11 +#define SNMPD_CALLBACK_ACM_CHECK_SUBTREE 12 +#define SNMPD_CALLBACK_REQ_REG_SYSOR 13 +#define SNMPD_CALLBACK_REQ_UNREG_SYSOR 14 +#define SNMPD_CALLBACK_REQ_UNREG_SYSOR_SESS 15 +#define SNMPD_CALLBACK_UNREGISTER_NOTIFICATIONS 16 + +#endif /* AGENT_CALLBACKS_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/agent_handler.h b/illumos-x86_64/usr/include/net-snmp/agent/agent_handler.h new file mode 100644 index 00000000..04ace26b --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/agent_handler.h @@ -0,0 +1,288 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#ifndef AGENT_HANDLER_H +#define AGENT_HANDLER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** @file agent_handler.h + * + * @addtogroup handler + * + * @{ + */ + +struct netsnmp_handler_registration_s; + +/* + * per mib handler flags. + * NOTE: Lower bits are reserved for the agent handler's use. + * The high 4 bits (31-28) are reserved for use by the handler. + */ +#define MIB_HANDLER_AUTO_NEXT 0x00000001 +#define MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE 0x00000002 +#define MIB_HANDLER_INSTANCE 0x00000004 + +#define MIB_HANDLER_CUSTOM4 0x10000000 +#define MIB_HANDLER_CUSTOM3 0x20000000 +#define MIB_HANDLER_CUSTOM2 0x40000000 +#define MIB_HANDLER_CUSTOM1 0x80000000 + + +/** @typedef struct netsnmp_mib_handler_s netsnmp_mib_handler + * Typedefs the netsnmp_mib_handler_s struct into netsnmp_mib_handler */ + +/** @struct netsnmp_mib_handler_s + * the mib handler structure to be registered + */ +typedef struct netsnmp_mib_handler_s { + char *handler_name; + /** for handler's internal use */ + void *myvoid; + /** for agent_handler's internal use */ + int flags; + + /** if you add more members, you probably also want to update */ + /** _clone_handler in agent_handler.c. */ + + int (*access_method) (struct netsnmp_mib_handler_s *, + struct + netsnmp_handler_registration_s *, + struct + netsnmp_agent_request_info_s *, + struct netsnmp_request_info_s *); + /** data clone hook for myvoid + * deep copy the myvoid member - default is to copy the pointer + * This method is only called if myvoid != NULL + * myvoid is the current myvoid pointer. + * returns NULL on failure + */ + void *(*data_clone)(void *myvoid); + /** data free hook for myvoid + * delete the myvoid member - default is to do nothing + * This method is only called if myvoid != NULL + */ + void (*data_free)(void *myvoid); /**< data free hook for myvoid */ + + struct netsnmp_mib_handler_s *next; + struct netsnmp_mib_handler_s *prev; +} netsnmp_mib_handler; + +/* + * per registration flags + */ +#define HANDLER_CAN_GETANDGETNEXT 0x01 /* must be able to do both */ +#define HANDLER_CAN_SET 0x02 /* implies create, too */ +#define HANDLER_CAN_GETBULK 0x04 +#define HANDLER_CAN_NOT_CREATE 0x08 /* auto set if ! CAN_SET */ +#define HANDLER_CAN_BABY_STEP 0x10 +#define HANDLER_CAN_STASH 0x20 + + +#define HANDLER_CAN_RONLY (HANDLER_CAN_GETANDGETNEXT) +#define HANDLER_CAN_RWRITE (HANDLER_CAN_GETANDGETNEXT | HANDLER_CAN_SET) +#define HANDLER_CAN_SET_ONLY (HANDLER_CAN_SET | HANDLER_CAN_NOT_CREATE) +#define HANDLER_CAN_DEFAULT (HANDLER_CAN_RONLY | HANDLER_CAN_NOT_CREATE) + +/** @typedef struct netsnmp_handler_registration_s netsnmp_handler_registration + * Typedefs the netsnmp_handler_registration_s struct into netsnmp_handler_registration */ + +/** @struct netsnmp_handler_registration_s + * Root registration info. + * The variables handlerName, contextName, and rootoid need to be allocated + * on the heap, when the registration structure is unregistered using + * unregister_mib_context() the code attempts to free them. + */ +typedef struct netsnmp_handler_registration_s { + + /** for mrTable listings, and other uses */ + char *handlerName; + /** NULL = default context */ + char *contextName; + + /** + * where are we registered at? + */ + oid *rootoid; + size_t rootoid_len; + + /** + * handler details + */ + netsnmp_mib_handler *handler; + int modes; + + /** + * more optional stuff + */ + int priority; + int range_subid; + oid range_ubound; + int timeout; + int global_cacheid; + + /** + * void ptr for registeree + */ + void * my_reg_void; + +} netsnmp_handler_registration; + +/* + * function handler definitions + */ + +/** + * @typedef Netsnmp_Node_Handler + * @param[in] handler pointer to MIB handler. + * @param[in] reginfo pointer to registration struct. + * @param[in] reqinfo pointer to current transaction. + * @param[in] requests SNMP requests to process. + */ +typedef int (Netsnmp_Node_Handler) (netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests); + + typedef struct netsnmp_handler_args_s { + netsnmp_mib_handler *handler; + netsnmp_handler_registration *reginfo; + netsnmp_agent_request_info *reqinfo; + netsnmp_request_info *requests; + } netsnmp_handler_args; + + typedef struct netsnmp_delegated_cache_s { + int transaction_id; + netsnmp_mib_handler *handler; + netsnmp_handler_registration *reginfo; + netsnmp_agent_request_info *reqinfo; + netsnmp_request_info *requests; + void *localinfo; + } netsnmp_delegated_cache; + + /* + * handler API functions + */ + void netsnmp_init_handler_conf(void); + int netsnmp_register_handler(netsnmp_handler_registration + *reginfo); + int netsnmp_unregister_handler(netsnmp_handler_registration + *reginfo); + int + netsnmp_register_handler_nocallback(netsnmp_handler_registration + *reginfo); + int netsnmp_inject_handler(netsnmp_handler_registration + *reginfo, + netsnmp_mib_handler *handler); + int + netsnmp_inject_handler_before(netsnmp_handler_registration *reginfo, + netsnmp_mib_handler *handler, + const char *before_what); + netsnmp_mib_handler + *netsnmp_find_handler_by_name(netsnmp_handler_registration + *reginfo, const char *name); + void + *netsnmp_find_handler_data_by_name(netsnmp_handler_registration + *reginfo, const char *name); + int netsnmp_call_handlers(netsnmp_handler_registration + *reginfo, + netsnmp_agent_request_info + *reqinfo, + netsnmp_request_info *requests); + int netsnmp_call_handler(netsnmp_mib_handler *next_handler, + netsnmp_handler_registration + *reginfo, + netsnmp_agent_request_info + *reqinfo, + netsnmp_request_info *requests); + int netsnmp_call_next_handler(netsnmp_mib_handler *current, + netsnmp_handler_registration + *reginfo, + netsnmp_agent_request_info + *reqinfo, + netsnmp_request_info + *requests); + int netsnmp_call_next_handler_one_request(netsnmp_mib_handler *current, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests); + + netsnmp_mib_handler *netsnmp_create_handler(const char *name, + Netsnmp_Node_Handler * + handler_access_method); + netsnmp_handler_registration * + netsnmp_handler_registration_create(const char *name, + netsnmp_mib_handler *handler, + const oid * reg_oid, size_t reg_oid_len, + int modes); + netsnmp_handler_registration * + netsnmp_create_handler_registration(const char *name, Netsnmp_Node_Handler* + handler_access_method, + const oid *reg_oid, size_t reg_oid_len, + int modes); + + netsnmp_delegated_cache + *netsnmp_create_delegated_cache(netsnmp_mib_handler *, + netsnmp_handler_registration *, + netsnmp_agent_request_info *, + netsnmp_request_info *, void *); + void netsnmp_free_delegated_cache(netsnmp_delegated_cache *dcache); + netsnmp_delegated_cache + *netsnmp_handler_check_cache(netsnmp_delegated_cache *dcache); + void netsnmp_register_handler_by_name(const char *, + netsnmp_mib_handler + *); + + void netsnmp_clear_handler_list(void); + + void + netsnmp_request_add_list_data(netsnmp_request_info *request, + netsnmp_data_list *node); + int netsnmp_request_remove_list_data(netsnmp_request_info *request, + const char *name); + + int + netsnmp_request_remove_list_data(netsnmp_request_info *request, + const char *name); + + void *netsnmp_request_get_list_data(netsnmp_request_info + *request, + const char *name); + + void + netsnmp_free_request_data_set(netsnmp_request_info *request); + + void + netsnmp_free_request_data_sets(netsnmp_request_info *request); + + void netsnmp_handler_free(netsnmp_mib_handler *); + netsnmp_mib_handler *netsnmp_handler_dup(netsnmp_mib_handler *); + netsnmp_handler_registration + *netsnmp_handler_registration_dup(netsnmp_handler_registration *); + void + netsnmp_handler_registration_free(netsnmp_handler_registration *); + +#define REQUEST_IS_DELEGATED 1 +#define REQUEST_IS_NOT_DELEGATED 0 + void + netsnmp_handler_mark_requests_as_delegated(netsnmp_request_info *, + int); + void *netsnmp_handler_get_parent_data(netsnmp_request_info *, + const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* AGENT_HANDLER_H */ +/** @} */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/agent_index.h b/illumos-x86_64/usr/include/net-snmp/agent/agent_index.h new file mode 100644 index 00000000..9846a61f --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/agent_index.h @@ -0,0 +1,48 @@ +#ifndef AGENT_INDEX_H +#define AGENT_INDEX_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define ALLOCATE_THIS_INDEX 0x0 +#define ALLOCATE_ANY_INDEX 0x1 +#define ALLOCATE_NEW_INDEX 0x3 + /* + * N.B: it's deliberate that NEW_INDEX & ANY_INDEX == ANY_INDEX + */ + +#define ANY_INTEGER_INDEX -1 +#define ANY_STRING_INDEX NULL +#define ANY_OID_INDEX NULL + +#define INDEX_ERR_GENERR -1 +#define INDEX_ERR_WRONG_TYPE -2 +#define INDEX_ERR_NOT_ALLOCATED -3 +#define INDEX_ERR_WRONG_SESSION -4 + +char *register_string_index(oid *, size_t, char *); +int register_int_index(oid *, size_t, int); +netsnmp_variable_list *register_oid_index(oid *, size_t, oid *, size_t); +netsnmp_variable_list *register_index(netsnmp_variable_list *, int, + netsnmp_session *); + +int unregister_string_index(oid *, size_t, char *); +int unregister_int_index(oid *, size_t, int); +int unregister_oid_index(oid *, size_t, oid *, size_t); + +int release_index(netsnmp_variable_list *); +int remove_index(netsnmp_variable_list *, netsnmp_session *); +void unregister_index_by_session(netsnmp_session *); +int unregister_index(netsnmp_variable_list *, int, + netsnmp_session *); + +unsigned long count_indexes(oid * name, size_t namelen, + int include_unallocated); + +void dump_idx_registry(void); + +#ifdef __cplusplus +} +#endif +#endif /* AGENT_INDEX_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/agent_module_config.h b/illumos-x86_64/usr/include/net-snmp/agent/agent_module_config.h new file mode 100644 index 00000000..23ad087e --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/agent_module_config.h @@ -0,0 +1,31 @@ +/* This file is automatically generated by configure. Do not modify by hand. */ +/* Define if compiling with the snmpv3/usmConf module files. */ +#define USING_SNMPV3_USMCONF_MODULE 1 + +/* Define if compiling with the agentx/master module files. */ +#define USING_AGENTX_MASTER_MODULE 1 + +/* Define if compiling with the agentx/subagent module files. */ +#define USING_AGENTX_SUBAGENT_MODULE 1 + +/* Define if compiling with the utilities/execute module files. */ +#define USING_UTILITIES_EXECUTE_MODULE 1 + +/* Define if compiling with the utilities/iquery module files. */ +#define USING_UTILITIES_IQUERY_MODULE 1 + +/* Define if compiling with the mibII/vacm_conf module files. */ +#define USING_MIBII_VACM_CONF_MODULE 1 + +/* Define if compiling with the agentx/protocol module files. */ +#define USING_AGENTX_PROTOCOL_MODULE 1 + +/* Define if compiling with the agentx/master_admin module files. */ +#define USING_AGENTX_MASTER_ADMIN_MODULE 1 + +/* Define if compiling with the agentx/agentx_config module files. */ +#define USING_AGENTX_AGENTX_CONFIG_MODULE 1 + +/* Define if compiling with the agentx/client module files. */ +#define USING_AGENTX_CLIENT_MODULE 1 + diff --git a/illumos-x86_64/usr/include/net-snmp/agent/agent_read_config.h b/illumos-x86_64/usr/include/net-snmp/agent/agent_read_config.h new file mode 100644 index 00000000..0dbf0256 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/agent_read_config.h @@ -0,0 +1,36 @@ +/* + * agent_read_config.h: reads configuration files for extensible sections. + * + */ +#ifndef _AGENT_READ_CONFIG_H +#define _AGENT_READ_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + + void init_agent_read_config(const char *); + void update_config(void); + void snmpd_register_config_handler(const char *token, + void (*parser) (const + char *, + char *), + void (*releaser) (void), + const char *help); + void snmpd_register_const_config_handler( + const char *, + void (*parser) (const char *, const char *), + void (*releaser) (void), + const char *); + void snmpd_unregister_config_handler(const char *); + void snmpd_store_config(const char *); + + void netsnmp_set_agent_user_id(int uid); + void netsnmp_set_agent_group_id(int gid); + void netsnmp_parse_agent_user(const char *token, char *cptr); + void netsnmp_parse_agent_group(const char *token, char *cptr); + +#ifdef __cplusplus +} +#endif +#endif /* _AGENT_READ_CONFIG_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/agent_registry.h b/illumos-x86_64/usr/include/net-snmp/agent/agent_registry.h new file mode 100644 index 00000000..78d0f866 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/agent_registry.h @@ -0,0 +1,192 @@ +#ifndef AGENT_REGISTRY_H +#define AGENT_REGISTRY_H + +/***********************************************************************/ +/* + * new version2 agent handler API structures + */ +/***********************************************************************/ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/***********************************************************************/ + /* + * requests api definitions + */ +/***********************************************************************/ + + /* + * the structure of parameters passed to registered ACM modules + */ +struct view_parameters { + netsnmp_pdu *pdu; + oid *name; + size_t namelen; + int test; + int errorcode; /* Do not change unless you're + specifying an error, as it starts + in a success state. */ + int check_subtree; +}; + +struct register_parameters { + oid *name; + size_t namelen; + int priority; + int range_subid; + oid range_ubound; + int timeout; + u_char flags; + const char *contextName; + netsnmp_session *session; + netsnmp_handler_registration *reginfo; +}; + +typedef struct subtree_context_cache_s { + const char *context_name; + struct netsnmp_subtree_s *first_subtree; + struct subtree_context_cache_s *next; +} subtree_context_cache; + + + +void setup_tree (void); +void shutdown_tree (void); +void dump_registry(void); + + +netsnmp_subtree *netsnmp_subtree_find (const oid *, size_t, + netsnmp_subtree *, + const char *context_name); + +netsnmp_subtree *netsnmp_subtree_find_next(const oid *, size_t, + netsnmp_subtree *, + const char *context_name); + +netsnmp_subtree *netsnmp_subtree_find_prev(const oid *, size_t, + netsnmp_subtree *, + const char *context_name); + +netsnmp_subtree *netsnmp_subtree_find_first(const char *context_name); + +netsnmp_session *get_session_for_oid (const oid *, size_t, + const char *context_name); + +subtree_context_cache *get_top_context_cache(void); + +void netsnmp_set_lookup_cache_size(int newsize); +int netsnmp_get_lookup_cache_size(void); + +#define MIB_REGISTERED_OK 0 +#define MIB_DUPLICATE_REGISTRATION -1 +#define MIB_REGISTRATION_FAILED -2 +#define MIB_UNREGISTERED_OK 0 +#define MIB_NO_SUCH_REGISTRATION -1 +#define MIB_UNREGISTRATION_FAILED -2 +#define DEFAULT_MIB_PRIORITY 127 + +int register_mib (const char *, + const struct variable *, + size_t, size_t, const oid *, + size_t); + +int register_mib_priority (const char *, + const struct variable *, + size_t, size_t, const oid *, size_t, + int); + +int register_mib_range (const char *, + const struct variable *, + size_t, size_t, const oid *, + size_t, int, int, oid, + netsnmp_session *); + +int register_mib_context (const char *, + const struct variable *, + size_t, size_t, const oid *, size_t, + int, int, oid, netsnmp_session *, + const char *, int, int); + +int netsnmp_register_mib_table_row (const char *, + const struct variable *, + size_t, size_t, oid *, + size_t, int, int, netsnmp_session *, + const char *, int, int); + +int unregister_mib (oid *, size_t); + +int unregister_mib_priority (oid *, size_t, int); +int unregister_mib_range (oid *, size_t, int, int, oid); +int unregister_mib_context (oid *, size_t, int, int, oid, + const char *); +void clear_context (void); +void unregister_mibs_by_session (netsnmp_session *); +int netsnmp_unregister_mib_table_row (oid *mibloc, size_t mibloclen, + int priority, int var_subid, + oid range_ubound, + const char *context); + +int compare_tree (const oid *, size_t, + const oid *, size_t); +int in_a_view (oid *, size_t *, + netsnmp_pdu *, int); +int check_access (netsnmp_pdu *pdu); +int netsnmp_acm_check_subtree (netsnmp_pdu *, oid *, size_t); +void register_mib_reattach (void); +void register_mib_detach (void); + +/* + * REGISTER_MIB(): This macro simply loads register_mib with less pain: + * + * descr: A short description of the mib group being loaded. + * var: The variable structure to load. + * vartype: The variable structure used to define it (variable[2, 4, ...]) + * theoid: An *initialized* *exact length* oid pointer. + * (sizeof(theoid) *must* return the number of elements!) + */ + +#define REGISTER_MIB(descr, var, vartype, theoid) \ + if (register_mib(descr, (const struct variable *) var, \ + sizeof(struct vartype), \ + sizeof(var)/sizeof(struct vartype), \ + theoid, sizeof(theoid)/sizeof(oid)) != \ + MIB_REGISTERED_OK) \ + DEBUGMSGTL(("register_mib", "%s registration failed\n", descr)); + + +#define NUM_EXTERNAL_SIGS 32 +#define SIG_REGISTERED_OK 0 +#define SIG_REGISTRATION_FAILED -2 +#define SIG_UNREGISTERED_OK 0 + +extern int external_signal_scheduled[NUM_EXTERNAL_SIGS]; +extern void (*external_signal_handler[NUM_EXTERNAL_SIGS])(int); + +int register_signal(int, void (*func)(int)); +int unregister_signal(int); + + + +/* + * internal API. Don't use this. Use netsnmp_register_handler instead + */ + +struct netsnmp_handler_registration_s; + +int netsnmp_register_mib(const char *, struct variable *, + size_t, size_t, oid *, size_t, + int, int, oid, netsnmp_session *, + const char *, int, int, + struct netsnmp_handler_registration_s *, + int); + +#ifdef __cplusplus +} +#endif + +#endif /* AGENT_REGISTRY_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/agent_sysORTable.h b/illumos-x86_64/usr/include/net-snmp/agent/agent_sysORTable.h new file mode 100644 index 00000000..5626e4ad --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/agent_sysORTable.h @@ -0,0 +1,28 @@ +#ifndef AGENT_SYSORTABLE_H +#define AGENT_SYSORTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct sysORTable; + +extern void init_agent_sysORTable(void); +extern void shutdown_agent_sysORTable(void); + +extern void netsnmp_sysORTable_foreach(void (*)(const struct sysORTable*, + void*), + void*); + +extern int register_sysORTable(oid *, size_t, const char *); +extern int unregister_sysORTable(oid *, size_t); +extern int register_sysORTable_sess(oid *, size_t, const char *, + netsnmp_session *); +extern int unregister_sysORTable_sess(oid *, size_t, netsnmp_session *); +extern void unregister_sysORTable_by_session(netsnmp_session *); + +#ifdef __cplusplus +} +#endif + +#endif /* AGENT_SYSORTABLE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/agent_trap.h b/illumos-x86_64/usr/include/net-snmp/agent/agent_trap.h new file mode 100644 index 00000000..c74fd9cf --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/agent_trap.h @@ -0,0 +1,95 @@ +#ifndef AGENT_TRAP_H +#define AGENT_TRAP_H + +/* + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#ifdef __cplusplus +extern "C" { +#endif + +struct agent_add_trap_args { + netsnmp_session *ss; + int confirm; + const char *nameData; /* notification target addr name */ + int nameLen; + const char *tagData; /* notification tag */ + int tagLen; + const char *profileData; /* filter profile */ + int profileLen; + int rc; +}; + +void init_traps(void); +void send_easy_trap(int, int); +void send_trap_pdu(netsnmp_pdu *); +void send_v2trap(netsnmp_variable_list *); +void send_v3trap(netsnmp_variable_list *vars, const char *context); +void send_trap_vars(int, int, netsnmp_variable_list *); +void send_trap_vars_with_context(int trap, int specific, + netsnmp_variable_list *vars, + const char *context); +void send_enterprise_trap_vars(int trap, int specific, + const oid * enterprise, + int enterprise_length, + netsnmp_variable_list * vars); +int netsnmp_send_traps(int trap, int specific, + const oid * enterprise, int enterprise_length, + netsnmp_variable_list * vars, + /* flags are currently unused */ + const char * context, int flags); +void snmpd_parse_config_authtrap(const char *, char *); +void snmpd_parse_config_trapsink(const char *, char *); +void snmpd_parse_config_trap2sink(const char *, char *); +void snmpd_parse_config_informsink(const char *, char *); +void snmpd_parse_config_trapsess(const char *, char *); +void snmpd_free_trapsinks(void); +void snmpd_parse_config_trapcommunity(const char *, char *); +void snmpd_free_trapcommunity(void); +void send_trap_to_sess(netsnmp_session * sess, + netsnmp_pdu *template_pdu); + +int create_trap_session(char *, u_short, char *, int, int); +int create_trap_session_with_src(const char *, const char *, + const char *, const char *, + int, int); +int add_trap_session(netsnmp_session *, int, int, int); +int remove_trap_session(netsnmp_session *); +netsnmp_session *netsnmp_create_v1v2_notification_session(const char *, + const char*, + const char *, + const char *, + int, int, + const char *, + const char *, + const char*); +netsnmp_session *netsnmp_create_v3user_notification_session(const char *dst, + const char *user, + int lvl, + const char *ctx, + int pdutype, + const u_char *eid, + size_t eidl, + const char *src, + const char *name, + const char *tag, + const char *prof); +int netsnmp_add_notification_session(netsnmp_session *, int, int, + int, const char*, const char*, + const char*); +void netsnmp_unregister_notification(const char *, u_char); + +int netsnmp_build_trap_oid(netsnmp_pdu *pdu, oid *, size_t *); + +void convert_v2_to_v1(netsnmp_variable_list *, netsnmp_pdu *); +netsnmp_variable_list *convert_v1_to_v2(netsnmp_pdu *); +netsnmp_pdu *convert_v2pdu_to_v1(netsnmp_pdu *); +netsnmp_pdu *convert_v1pdu_to_v2(netsnmp_pdu *); + +#ifdef __cplusplus +} +#endif +#endif /* AGENT_TRAP_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/all_helpers.h b/illumos-x86_64/usr/include/net-snmp/agent/all_helpers.h new file mode 100644 index 00000000..d0d5c22f --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/all_helpers.h @@ -0,0 +1,43 @@ +#ifndef ALL_HANDLERS_H +#define ALL_HANDLERS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/* + * #include + */ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +void netsnmp_init_helpers(void); + +#ifdef __cplusplus +} +#endif +#endif /* ALL_HANDLERS_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/auto_nlist.h b/illumos-x86_64/usr/include/net-snmp/agent/auto_nlist.h new file mode 100644 index 00000000..21b6b8c4 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/auto_nlist.h @@ -0,0 +1,28 @@ +/* + * auto_nlist.h + */ +#ifndef AUTO_NLIST_H +#define AUTO_NLIST_H +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(irix6) && defined(IRIX64) +#define nlist nlist64 +#endif + +#ifdef NETSNMP_CAN_USE_NLIST +int auto_nlist(const char *, char *, size_t); +long auto_nlist_value(const char *); +int KNLookup(struct nlist *, int, char *, size_t); +#else +int auto_nlist_noop(void); +# define auto_nlist(x,y,z) auto_nlist_noop() +# define auto_nlist_value(z) auto_nlist_noop() +# define KNLookup(w,x,y,z) auto_nlist_noop() +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/baby_steps.h b/illumos-x86_64/usr/include/net-snmp/agent/baby_steps.h new file mode 100644 index 00000000..d2565502 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/baby_steps.h @@ -0,0 +1,117 @@ +/* + * $Id$ + */ +#ifndef BABY_STEPS_H +#define BABY_STEPS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + /* + * Flags for baby step modes + */ +#define BABY_STEP_NONE 0 +#define BABY_STEP_PRE_REQUEST (0x1 << 1) +#define BABY_STEP_OBJECT_LOOKUP (0x1 << 2) +#ifndef NETSNMP_NO_WRITE_SUPPORT +#define BABY_STEP_CHECK_VALUE (0x1 << 3) +#define BABY_STEP_ROW_CREATE (0x1 << 4) +#define BABY_STEP_UNDO_SETUP (0x1 << 5) +#define BABY_STEP_SET_VALUE (0x1 << 6) +#define BABY_STEP_CHECK_CONSISTENCY (0x1 << 7) +#define BABY_STEP_UNDO_SET (0x1 << 8) +#define BABY_STEP_COMMIT (0x1 << 9) +#define BABY_STEP_UNDO_COMMIT (0x1 << 10) +#define BABY_STEP_IRREVERSIBLE_COMMIT (0x1 << 11) +#define BABY_STEP_UNDO_CLEANUP (0x1 << 12) +#endif /* NETSNMP_NO_WRITE_SUPPORT */ +#define BABY_STEP_POST_REQUEST (0x1 << 13) + +#define BABY_STEP_ALL (0xffffffff) + + +#ifndef NETSNMP_NO_WRITE_SUPPORT +#define BABY_STEP_CHECK_OBJECT BABY_STEP_CHECK_VALUE +#define BABY_STEP_SET_VALUES BABY_STEP_SET_VALUE +#define BABY_STEP_UNDO_SETS BABY_STEP_UNDO_SET +#endif /* NETSNMP_NO_WRITE_SUPPORT */ + +/** @name baby_steps + * + * This helper expands the original net-snmp set modes into the newer, finer + * grained modes. + * + * @{ */ + + typedef struct netsnmp_baby_steps_modes_s { + /** Number of handlers whose myvoid pointer points at this object. */ + int refcnt; + u_int registered; + u_int completed; + } netsnmp_baby_steps_modes; + +void netsnmp_baby_steps_init(void); + +netsnmp_mib_handler *netsnmp_baby_steps_handler_get(u_long modes); + +/** @} */ + + +/** @name access_multiplexer + * + * This helper calls individual access methods based on the mode. All + * access methods share the same handler, and the same myvoid pointer. + * If you need individual myvoid pointers, check out the multiplexer + * handler (though it currently only works for traditional modes). + * + * @{ */ + +/** @struct netsnmp_mib_handler_access_methods + * Defines the access methods to be called by the access_multiplexer helper + */ +typedef struct netsnmp_baby_steps_access_methods_s { + + /* + * baby step modes + */ + Netsnmp_Node_Handler *pre_request; + Netsnmp_Node_Handler *object_lookup; + Netsnmp_Node_Handler *get_values; +#ifndef NETSNMP_NO_WRITE_SUPPORT + Netsnmp_Node_Handler *object_syntax_checks; + Netsnmp_Node_Handler *row_creation; + Netsnmp_Node_Handler *undo_setup; + Netsnmp_Node_Handler *set_values; + Netsnmp_Node_Handler *consistency_checks; + Netsnmp_Node_Handler *commit; + Netsnmp_Node_Handler *undo_sets; + Netsnmp_Node_Handler *undo_cleanup; + Netsnmp_Node_Handler *undo_commit; + Netsnmp_Node_Handler *irreversible_commit; +#endif /* NETSNMP_NO_WRITE_SUPPORT */ + Netsnmp_Node_Handler *post_request; + + void *my_access_void; + +} netsnmp_baby_steps_access_methods; + + netsnmp_mib_handler * netsnmp_baby_steps_access_multiplexer_get( + netsnmp_baby_steps_access_methods *); + + int netsnmp_baby_step_mode2flag( u_int mode ); + +/** @} */ + + +/** backwards compatability. don't use in new code */ +#define netsnmp_get_baby_steps_handler netsnmp_baby_steps_handler_get +#define netsnmp_init_baby_steps_helper netsnmp_baby_steps_handler_init + + +#ifdef __cplusplus +} +#endif +#endif /* baby_steps */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/bulk_to_next.h b/illumos-x86_64/usr/include/net-snmp/agent/bulk_to_next.h new file mode 100644 index 00000000..b578da58 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/bulk_to_next.h @@ -0,0 +1,28 @@ +/* + * bulk_to_next.h + */ +#ifndef BULK_TO_NEXT_H +#define BULK_TO_NEXT_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * The helper merely intercepts GETBULK requests and converts them to + * * GETNEXT reequests. + */ + + +netsnmp_mib_handler *netsnmp_get_bulk_to_next_handler(void); +void netsnmp_init_bulk_to_next_helper(void); +void netsnmp_bulk_to_next_fix_requests(netsnmp_request_info + *requests); + +Netsnmp_Node_Handler netsnmp_bulk_to_next_helper; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/cache_handler.h b/illumos-x86_64/usr/include/net-snmp/agent/cache_handler.h new file mode 100644 index 00000000..1e4751c7 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/cache_handler.h @@ -0,0 +1,130 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright (C) 2007 Apple, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#ifndef NETSNMP_CACHE_HANDLER_H +#define NETSNMP_CACHE_HANDLER_H + +/* + * This caching helper provides a generalised (SNMP-manageable) caching + * mechanism. Individual SNMP table and scalar/scalar group MIB + * implementations can use data caching in a consistent manner, without + * needing to handle the generic caching details themselves. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CACHE_NAME "cache_info" + + typedef struct netsnmp_cache_s netsnmp_cache; + + typedef int (NetsnmpCacheLoad)(netsnmp_cache *, void*); + typedef void (NetsnmpCacheFree)(netsnmp_cache *, void*); + + struct netsnmp_cache_s { + /** Number of handlers whose myvoid member points at this structure. */ + int refcnt; + /* + * For operation of the data caches + */ + int flags; + int enabled; + int valid; + char expired; + int timeout; /* Length of time the cache is valid (in s) */ + marker_t timestampM; /* When the cache was last loaded */ + u_long timer_id; /* periodic timer id */ + + NetsnmpCacheLoad *load_cache; + NetsnmpCacheFree *free_cache; + + /* + * void pointer for the user that created the cache. + * You never know when it might not come in useful .... + */ + void *magic; + + /* + * hint from the cache helper. contains the standard + * handler arguments. + */ + netsnmp_handler_args *cache_hint; + + /* + * For SNMP-management of the data caches + */ + netsnmp_cache *next, *prev; + oid *rootoid; + int rootoid_len; + + }; + + + void netsnmp_cache_reqinfo_insert(netsnmp_cache* cache, + netsnmp_agent_request_info * reqinfo, + const char *name); + netsnmp_cache * + netsnmp_cache_reqinfo_extract(netsnmp_agent_request_info * reqinfo, + const char *name); + netsnmp_cache* netsnmp_extract_cache_info(netsnmp_agent_request_info *); + + int netsnmp_cache_check_and_reload(netsnmp_cache * cache); + int netsnmp_cache_check_expired(netsnmp_cache *cache); + int netsnmp_cache_is_valid( netsnmp_agent_request_info *, + const char *name); + /** for backwards compat */ + int netsnmp_is_cache_valid( netsnmp_agent_request_info *); + netsnmp_mib_handler *netsnmp_get_cache_handler(int, NetsnmpCacheLoad *, + NetsnmpCacheFree *, + const oid*, int); + int netsnmp_register_cache_handler(netsnmp_handler_registration *reginfo, + int, NetsnmpCacheLoad *, + NetsnmpCacheFree *); + + Netsnmp_Node_Handler netsnmp_cache_helper_handler; + + netsnmp_cache * + netsnmp_cache_create(int timeout, NetsnmpCacheLoad * load_hook, + NetsnmpCacheFree * free_hook, + const oid * rootoid, int rootoid_len); + int netsnmp_cache_remove(netsnmp_cache *cache); + int netsnmp_cache_free(netsnmp_cache *cache); + + netsnmp_mib_handler * + netsnmp_cache_handler_get(netsnmp_cache* cache); + void netsnmp_cache_handler_owns_cache(netsnmp_mib_handler *handler); + + netsnmp_cache * netsnmp_cache_find_by_oid(const oid * rootoid, + int rootoid_len); + + unsigned int netsnmp_cache_timer_start(netsnmp_cache *cache); + void netsnmp_cache_timer_stop(netsnmp_cache *cache); + +/* + * Flags affecting cache handler operation + */ +#define NETSNMP_CACHE_DONT_INVALIDATE_ON_SET 0x0001 +#define NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD 0x0002 +#define NETSNMP_CACHE_DONT_FREE_EXPIRED 0x0004 +#define NETSNMP_CACHE_DONT_AUTO_RELEASE 0x0008 +#define NETSNMP_CACHE_PRELOAD 0x0010 +#define NETSNMP_CACHE_AUTO_RELOAD 0x0020 +#define NETSNMP_CACHE_RESET_TIMER_ON_USE 0x0040 + +#define NETSNMP_CACHE_HINT_HANDLER_ARGS 0x1000 + + +#ifdef __cplusplus +} +#endif +#endif /* NETSNMP_CACHE_HANDLER_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/debug_handler.h b/illumos-x86_64/usr/include/net-snmp/agent/debug_handler.h new file mode 100644 index 00000000..0d612db9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/debug_handler.h @@ -0,0 +1,16 @@ +#ifndef DEBUG_HANDLER_H +#define DEBUG_HANDLER_H + +#ifdef __cplusplus +extern "C" { +#endif + +netsnmp_mib_handler *netsnmp_get_debug_handler(void); +void netsnmp_init_debug_helper(void); + +Netsnmp_Node_Handler netsnmp_debug_helper; + +#ifdef __cplusplus +} +#endif +#endif /* DEBUG_HANDLER_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/ds_agent.h b/illumos-x86_64/usr/include/net-snmp/agent/ds_agent.h new file mode 100644 index 00000000..105eeb44 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/ds_agent.h @@ -0,0 +1,80 @@ +#ifndef NETSNMP_DS_AGENT_H +#define NETSNMP_DS_AGENT_H +/* + * defines agent's default store registrations + */ +/* + * Note: + * If new ds_agent entries are added to this header file, + * then remember to run 'perl/agent/default_store/gen' to + * update the corresponding perl interface. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + */ + +/* + * booleans + */ +#define NETSNMP_DS_AGENT_VERBOSE 0 /* 1 if verbose output desired */ +#define NETSNMP_DS_AGENT_ROLE 1 /* 0 if master, 1 if client */ +#define NETSNMP_DS_AGENT_NO_ROOT_ACCESS 2 /* 1 if we can't get root access */ +#define NETSNMP_DS_AGENT_AGENTX_MASTER 3 /* 1 if AgentX desired */ +#define NETSNMP_DS_AGENT_QUIT_IMMEDIATELY 4 /* 1 to never start the agent */ +#define NETSNMP_DS_AGENT_DISABLE_PERL 5 /* 1 to never enable perl */ +#define NETSNMP_DS_AGENT_NO_CONNECTION_WARNINGS 6 /* 1 = !see !connect msgs */ +#define NETSNMP_DS_AGENT_LEAVE_PIDFILE 7 /* 1 = leave PID file on exit */ +#define NETSNMP_DS_AGENT_NO_CACHING 8 /* 1 = disable netsnmp_cache */ +#define NETSNMP_DS_AGENT_STRICT_DISMAN 9 /* 1 = "correct" object ordering */ +#define NETSNMP_DS_AGENT_DONT_RETAIN_NOTIFICATIONS 10 /* 1 = disable trap logging */ +#define NETSNMP_DS_AGENT_DONT_LOG_TCPWRAPPERS_CONNECTS 12 /* 1 = disable logging */ +#define NETSNMP_DS_APP_DONT_LOG NETSNMP_DS_AGENT_DONT_RETAIN_NOTIFICATIONS /* compat */ +#define NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES 13 /* 1 = don't store NFS entries in hrStorageTable */ +#define NETSNMP_DS_AGENT_REALSTORAGEUNITS 14 /* 1 = use real allocation units in hrStorageTable, 0 = recalculate it to fit 32bits */ + + /* Repeated from "apps/snmptrapd_ds.h" */ +#define NETSNMP_DS_APP_NUMERIC_IP 16 +#define NETSNMP_DS_APP_NO_AUTHORIZATION 17 + +#define NETSNMP_DS_AGENT_DISKIO_NO_FD 18 /* 1 = don't report /dev/fd* entries in diskIOTable */ +#define NETSNMP_DS_AGENT_DISKIO_NO_LOOP 19 /* 1 = don't report /dev/loop* entries in diskIOTable */ +#define NETSNMP_DS_AGENT_DISKIO_NO_RAM 20 /* 1 = don't report /dev/ram* entries in diskIOTable */ + +/* WARNING: The trap receiver also uses DS flags and must not conflict with these! + * If you define additional boolean entries, check in "apps/snmptrapd_ds.h" first */ + +/* + * strings + */ +#define NETSNMP_DS_AGENT_PROGNAME 0 /* argv[0] */ +#define NETSNMP_DS_AGENT_X_SOCKET 1 /* AF_UNIX or ip:port socket addr */ +#define NETSNMP_DS_AGENT_PORTS 2 /* localhost:9161,tcp:localhost:9161... */ +#define NETSNMP_DS_AGENT_INTERNAL_SECNAME 3 /* used by disman/mteTriggerTable. */ +#define NETSNMP_DS_AGENT_PERL_INIT_FILE 4 /* used by embedded perl */ +#define NETSNMP_DS_SMUX_SOCKET 5 /* ip:port socket addr */ +#define NETSNMP_DS_NOTIF_LOG_CTX 6 /* "" | "snmptrapd" */ +#define NETSNMP_DS_AGENT_TRAP_ADDR 7 /* used as v1 trap agent address */ + +/* + * integers + */ +#define NETSNMP_DS_AGENT_FLAGS 0 /* session.flags */ +#define NETSNMP_DS_AGENT_USERID 1 +#define NETSNMP_DS_AGENT_GROUPID 2 +#define NETSNMP_DS_AGENT_AGENTX_PING_INTERVAL 3 /* ping master every SECONDS */ +#define NETSNMP_DS_AGENT_AGENTX_TIMEOUT 4 +#define NETSNMP_DS_AGENT_AGENTX_RETRIES 5 +#define NETSNMP_DS_AGENT_X_SOCK_PERM 6 /* permissions for the */ +#define NETSNMP_DS_AGENT_X_DIR_PERM 7 /* AgentX socket */ +#define NETSNMP_DS_AGENT_X_SOCK_USER 8 /* ownership for the */ +#define NETSNMP_DS_AGENT_X_SOCK_GROUP 9 /* AgentX socket */ +#define NETSNMP_DS_AGENT_CACHE_TIMEOUT 10 /* default cache timeout */ +#define NETSNMP_DS_AGENT_INTERNAL_VERSION 11 /* used by internal queries */ +#define NETSNMP_DS_AGENT_INTERNAL_SECLEVEL 12 /* used by internal queries */ +#define NETSNMP_DS_AGENT_MAX_GETBULKREPEATS 13 /* max getbulk repeats */ +#define NETSNMP_DS_AGENT_MAX_GETBULKRESPONSES 14 /* max getbulk respones */ +#define NETSNMP_DS_AGENT_AVG_BULKVARBINDSIZE 15 /* avg varbind size estimate */ +#define NETSNMP_DS_AGENT_PDU_STATS_MAX 16 /* size of top N array*/ +#define NETSNMP_DS_AGENT_PDU_STATS_THRESHOLD 17 /* minimum threshold time */ +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/instance.h b/illumos-x86_64/usr/include/net-snmp/agent/instance.h new file mode 100644 index 00000000..82f2edd1 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/instance.h @@ -0,0 +1,145 @@ +/* + * instance.h + */ +#ifndef NETSNMP_INSTANCE_H +#define NETSNMP_INSTANCE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The instance helper is designed to simplify the task of adding simple + * * instances to the mib tree. + */ + +/* + * GETNEXTs are auto-converted to a GET. + * * non-valid GETs are dropped. + * * The client can assume that if you're called for a GET, it shouldn't + * * have to check the oid at all. Just answer. + */ + +int +netsnmp_register_instance(netsnmp_handler_registration * reginfo); + +int +netsnmp_register_read_only_instance(netsnmp_handler_registration *reginfo); + +#define INSTANCE_HANDLER_NAME "instance" + +netsnmp_mib_handler *netsnmp_get_instance_handler(void); + +int +netsnmp_register_read_only_ulong_instance(const char * name, + const oid * reg_oid, + size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler * subhandler); +int +netsnmp_register_ulong_instance(const char * name, + const oid * reg_oid, + size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler * subhandler); +int +netsnmp_register_read_only_counter32_instance(const char *name, + const oid * reg_oid, + size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler *subhandler); +int +netsnmp_register_read_only_long_instance(const char *name, + const oid * reg_oid, + size_t reg_oid_len, + long *it, + Netsnmp_Node_Handler * subhandler); +int +netsnmp_register_long_instance(const char *name, + const oid * reg_oid, + size_t reg_oid_len, + long *it, + Netsnmp_Node_Handler * subhandler); + +int +netsnmp_register_read_only_int_instance(const char *name, + const oid * reg_oid, + size_t reg_oid_len, int *it, + Netsnmp_Node_Handler * subhandler); + +int +netsnmp_register_int_instance(const char *name, + const oid * reg_oid, + size_t reg_oid_len, int *it, + Netsnmp_Node_Handler * subhandler); + +/* identical functions that register a in a particular context */ +int +netsnmp_register_read_only_ulong_instance_context(const char *name, + const oid * reg_oid, + size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler + * subhandler, + const char *contextName); +int +netsnmp_register_ulong_instance_context(const char *name, + const oid * reg_oid, + size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler * subhandler, + const char *contextName); +int +netsnmp_register_read_only_counter32_instance_context(const char *name, + const oid * reg_oid, + size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler + * subhandler, + const char *contextName); +int +netsnmp_register_read_only_long_instance_context(const char *name, + const oid * reg_oid, + size_t reg_oid_len, + long *it, + Netsnmp_Node_Handler + * subhandler, + const char *contextName); +int +netsnmp_register_long_instance_context(const char *name, + const oid * reg_oid, + size_t reg_oid_len, + long *it, + Netsnmp_Node_Handler * subhandler, + const char *contextName); + +int +netsnmp_register_read_only_int_instance_context(const char *name, + const oid * reg_oid, + size_t reg_oid_len, int *it, + Netsnmp_Node_Handler * + subhandler, + const char *contextName); + +int +netsnmp_register_int_instance_context(const char *name, + const oid * reg_oid, + size_t reg_oid_len, int *it, + Netsnmp_Node_Handler * subhandler, + const char *contextName); + +int +netsnmp_register_num_file_instance(const char *name, + const oid * reg_oid, size_t reg_oid_len, + const char *file_name, int asn_type, int mode, + Netsnmp_Node_Handler * subhandler, + const char *contextName); + +Netsnmp_Node_Handler netsnmp_instance_helper_handler; +Netsnmp_Node_Handler netsnmp_instance_num_file_handler; + +#ifdef __cplusplus +} +#endif + +#endif /** NETSNMP_INSTANCE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/mfd.h b/illumos-x86_64/usr/include/net-snmp/agent/mfd.h new file mode 100644 index 00000000..15d0d916 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/mfd.h @@ -0,0 +1,84 @@ +/* + * MIBs For Dummies header + * + * $Id$ + */ +#ifndef NETSNMP_MFD_H +#define NETSNMP_MFD_H + +/*********************************************************************** + * + * return codes + * + **********************************************************************/ + +/*---------------------------------------------------------------------- + * general success/failure + */ +#define MFD_SUCCESS SNMP_ERR_NOERROR +#define MFD_ERROR SNMP_ERR_GENERR + +/* + * object not currently available + */ +#define MFD_SKIP SNMP_NOSUCHINSTANCE + +/* + * no more data in table (get-next) + */ +#define MFD_END_OF_DATA SNMP_ENDOFMIBVIEW + +/*---------------------------------------------------------------------- + * set processing errors + */ +/* + * row creation errors + */ +#define MFD_CANNOT_CREATE_NOW SNMP_ERR_INCONSISTENTNAME +#define MFD_CANNOT_CREATE_EVER SNMP_ERR_NOCREATION + +/* + * not writable or resource unavailable + */ +#define MFD_NOT_WRITABLE SNMP_ERR_NOTWRITABLE +#define MFD_RESOURCE_UNAVAILABLE SNMP_ERR_RESOURCEUNAVAILABLE + +/* + * new value errors + */ +#define MFD_NOT_VALID_NOW SNMP_ERR_INCONSISTENTVALUE +#define MFD_NOT_VALID_EVER SNMP_ERR_WRONGVALUE + + +/*********************************************************************** + * + * rowreq flags + * + **********************************************************************/ + +/*---------------------------------------------------------------------- + * 8 flags resevered for the user + */ +#define MFD_ROW_FLAG_USER_1 0x00000001 /* user flag 1 */ +#define MFD_ROW_FLAG_USER_2 0x00000002 /* user flag 2 */ +#define MFD_ROW_FLAG_USER_3 0x00000004 /* user flag 3 */ +#define MFD_ROW_FLAG_USER_4 0x00000008 /* user flag 4 */ +#define MFD_ROW_FLAG_USER_5 0x00000010 /* user flag 5 */ +#define MFD_ROW_FLAG_USER_6 0x00000020 /* user flag 6 */ +#define MFD_ROW_FLAG_USER_7 0x00000040 /* user flag 7 */ +#define MFD_ROW_FLAG_USER_8 0x00000080 /* user flag 8 */ +#define MFD_ROW_FLAG_USER_MASK 0x000000ff /* user flag mask */ + +/*---------------------------------------------------------------------- + * MFD flags + * + * grow left to right, in case we want to add more user flags later + */ +#define MFD_ROW_MASK 0xffffff00 /* mask to clear user flags */ +#define MFD_ROW_CREATED 0x80000000 /* newly created row */ +#define MFD_ROW_DATA_FROM_USER 0x40000000 /* we didn't allocate data */ +#define MFD_ROW_DELETED 0x20000000 /* deleted row */ +#define MFD_ROW_DIRTY 0x10000000 /* changed row */ + + +#endif /* NETSNMP_MFD_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/mib_module_config.h b/illumos-x86_64/usr/include/net-snmp/agent/mib_module_config.h new file mode 100644 index 00000000..2cebbf25 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/mib_module_config.h @@ -0,0 +1,604 @@ +/* This file is automatically generated by configure. Do not modify by hand. */ +/* Define if compiling with the default_modules module files. */ +#define USING_DEFAULT_MODULES_MODULE 1 + +/* Define if compiling with the disman/event-mib module files. */ +#define USING_DISMAN_EVENT_MIB_MODULE 1 + +/* Define if compiling with the host module files. */ +#define USING_HOST_MODULE 1 + +/* Define if compiling with the if-mib module files. */ +#define USING_IF_MIB_MODULE 1 + +/* Define if compiling with the tcp-mib module files. */ +#define USING_TCP_MIB_MODULE 1 + +/* Define if compiling with the ucd-snmp/diskio module files. */ +#define USING_UCD_SNMP_DISKIO_MODULE 1 + +/* Define if compiling with the udp-mib module files. */ +#define USING_UDP_MIB_MODULE 1 + +/* Define if compiling with the snmpv3mibs module files. */ +#define USING_SNMPV3MIBS_MODULE 1 + +/* Define if compiling with the mibII module files. */ +#define USING_MIBII_MODULE 1 + +/* Define if compiling with the ucd_snmp module files. */ +#define USING_UCD_SNMP_MODULE 1 + +/* Define if compiling with the notification module files. */ +#define USING_NOTIFICATION_MODULE 1 + +/* Define if compiling with the notification-log-mib module files. */ +#define USING_NOTIFICATION_LOG_MIB_MODULE 1 + +/* Define if compiling with the target module files. */ +#define USING_TARGET_MODULE 1 + +/* Define if compiling with the agent_mibs module files. */ +#define USING_AGENT_MIBS_MODULE 1 + +/* Define if compiling with the agentx module files. */ +#define USING_AGENTX_MODULE 1 + +/* Define if compiling with the disman/event module files. */ +#define USING_DISMAN_EVENT_MODULE 1 + +/* Define if compiling with the disman/schedule module files. */ +#define USING_DISMAN_SCHEDULE_MODULE 1 + +/* Define if compiling with the utilities module files. */ +#define USING_UTILITIES_MODULE 1 + +/* Define if compiling with the host/hrh_storage module files. */ +#define USING_HOST_HRH_STORAGE_MODULE 1 + +/* Define if compiling with the host/hrh_filesys module files. */ +#define USING_HOST_HRH_FILESYS_MODULE 1 + +/* Define if compiling with the host/hrSWInstalledTable module files. */ +#define USING_HOST_HRSWINSTALLEDTABLE_MODULE 1 + +/* Define if compiling with the host/hrSWRunTable module files. */ +#define USING_HOST_HRSWRUNTABLE_MODULE 1 + +/* Define if compiling with the host/hr_system module files. */ +#define USING_HOST_HR_SYSTEM_MODULE 1 + +/* Define if compiling with the host/hr_device module files. */ +#define USING_HOST_HR_DEVICE_MODULE 1 + +/* Define if compiling with the host/hr_other module files. */ +#define USING_HOST_HR_OTHER_MODULE 1 + +/* Define if compiling with the host/hr_proc module files. */ +#define USING_HOST_HR_PROC_MODULE 1 + +/* Define if compiling with the host/hr_network module files. */ +#define USING_HOST_HR_NETWORK_MODULE 1 + +/* Define if compiling with the host/hr_print module files. */ +#define USING_HOST_HR_PRINT_MODULE 1 + +/* Define if compiling with the host/hr_disk module files. */ +#define USING_HOST_HR_DISK_MODULE 1 + +/* Define if compiling with the host/hr_partition module files. */ +#define USING_HOST_HR_PARTITION_MODULE 1 + +/* Define if compiling with the if-mib/ifTable module files. */ +#define USING_IF_MIB_IFTABLE_MODULE 1 + +/* Define if compiling with the if-mib/ifXTable module files. */ +#define USING_IF_MIB_IFXTABLE_MODULE 1 + +/* Define if compiling with the tcp-mib/tcpConnectionTable module files. */ +#define USING_TCP_MIB_TCPCONNECTIONTABLE_MODULE 1 + +/* Define if compiling with the tcp-mib/tcpListenerTable module files. */ +#define USING_TCP_MIB_TCPLISTENERTABLE_MODULE 1 + +/* Define if compiling with the util_funcs/header_simple_table module files. */ +#define USING_UTIL_FUNCS_HEADER_SIMPLE_TABLE_MODULE 1 + +/* Define if compiling with the udp-mib/udpEndpointTable module files. */ +#define USING_UDP_MIB_UDPENDPOINTTABLE_MODULE 1 + +/* Define if compiling with the snmpv3/snmpEngine module files. */ +#define USING_SNMPV3_SNMPENGINE_MODULE 1 + +/* Define if compiling with the snmpv3/snmpMPDStats module files. */ +#define USING_SNMPV3_SNMPMPDSTATS_MODULE 1 + +/* Define if compiling with the snmpv3/usmStats module files. */ +#define USING_SNMPV3_USMSTATS_MODULE 1 + +/* Define if compiling with the snmpv3/usmUser module files. */ +#define USING_SNMPV3_USMUSER_MODULE 1 + +/* Define if compiling with the mibII/system_mib module files. */ +#define USING_MIBII_SYSTEM_MIB_MODULE 1 + +/* Define if compiling with the mibII/sysORTable module files. */ +#define USING_MIBII_SYSORTABLE_MODULE 1 + +/* Define if compiling with the mibII/snmp_mib module files. */ +#define USING_MIBII_SNMP_MIB_MODULE 1 + +/* Define if compiling with the mibII/vacm_vars module files. */ +#define USING_MIBII_VACM_VARS_MODULE 1 + +/* Define if compiling with the mibII/setSerialNo module files. */ +#define USING_MIBII_SETSERIALNO_MODULE 1 + +/* Define if compiling with the mibII/at module files. */ +#define USING_MIBII_AT_MODULE 1 + +/* Define if compiling with the mibII/ifTable module files. */ +#define USING_MIBII_IFTABLE_MODULE 1 + +/* Define if compiling with the mibII/ip module files. */ +#define USING_MIBII_IP_MODULE 1 + +/* Define if compiling with the mibII/tcp module files. */ +#define USING_MIBII_TCP_MODULE 1 + +/* Define if compiling with the mibII/udp module files. */ +#define USING_MIBII_UDP_MODULE 1 + +/* Define if compiling with the mibII/icmp module files. */ +#define USING_MIBII_ICMP_MODULE 1 + +/* Define if compiling with the ip-forward-mib module files. */ +#define USING_IP_FORWARD_MIB_MODULE 1 + +/* Define if compiling with the ip-mib/ipAddressTable module files. */ +#define USING_IP_MIB_IPADDRESSTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipAddressPrefixTable module files. */ +#define USING_IP_MIB_IPADDRESSPREFIXTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipDefaultRouterTable module files. */ +#define USING_IP_MIB_IPDEFAULTROUTERTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipSystemStatsTable module files. */ +#define USING_IP_MIB_IPSYSTEMSTATSTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipIfStatsTable module files. */ +#define USING_IP_MIB_IPIFSTATSTABLE_MODULE 1 + +/* Define if compiling with the ucd-snmp/proc module files. */ +#define USING_UCD_SNMP_PROC_MODULE 1 + +/* Define if compiling with the ucd-snmp/versioninfo module files. */ +#define USING_UCD_SNMP_VERSIONINFO_MODULE 1 + +/* Define if compiling with the ucd-snmp/pass module files. */ +#define USING_UCD_SNMP_PASS_MODULE 1 + +/* Define if compiling with the ucd-snmp/pass_persist module files. */ +#define USING_UCD_SNMP_PASS_PERSIST_MODULE 1 + +/* Define if compiling with the ucd-snmp/disk_hw module files. */ +#define USING_UCD_SNMP_DISK_HW_MODULE 1 + +/* Define if compiling with the ucd-snmp/loadave module files. */ +#define USING_UCD_SNMP_LOADAVE_MODULE 1 + +/* Define if compiling with the agent/extend module files. */ +#define USING_AGENT_EXTEND_MODULE 1 + +/* Define if compiling with the ucd-snmp/errormib module files. */ +#define USING_UCD_SNMP_ERRORMIB_MODULE 1 + +/* Define if compiling with the ucd-snmp/file module files. */ +#define USING_UCD_SNMP_FILE_MODULE 1 + +/* Define if compiling with the ucd-snmp/dlmod module files. */ +#define USING_UCD_SNMP_DLMOD_MODULE 1 + +/* Define if compiling with the ucd-snmp/proxy module files. */ +#define USING_UCD_SNMP_PROXY_MODULE 1 + +/* Define if compiling with the ucd-snmp/logmatch module files. */ +#define USING_UCD_SNMP_LOGMATCH_MODULE 1 + +/* Define if compiling with the ucd-snmp/memory module files. */ +#define USING_UCD_SNMP_MEMORY_MODULE 1 + +/* Define if compiling with the ucd-snmp/vmstat module files. */ +#define USING_UCD_SNMP_VMSTAT_MODULE 1 + +/* Define if compiling with the notification/snmpNotifyTable module files. */ +#define USING_NOTIFICATION_SNMPNOTIFYTABLE_MODULE 1 + +/* Define if compiling with the snmp-notification-mib/snmpNotifyFilterTable module files. */ +#define USING_SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERTABLE_MODULE 1 + +/* Define if compiling with the notification/snmpNotifyFilterProfileTable module files. */ +#define USING_NOTIFICATION_SNMPNOTIFYFILTERPROFILETABLE_MODULE 1 + +/* Define if compiling with the notification-log-mib/notification_log module files. */ +#define USING_NOTIFICATION_LOG_MIB_NOTIFICATION_LOG_MODULE 1 + +/* Define if compiling with the target/snmpTargetAddrEntry module files. */ +#define USING_TARGET_SNMPTARGETADDRENTRY_MODULE 1 + +/* Define if compiling with the target/snmpTargetParamsEntry module files. */ +#define USING_TARGET_SNMPTARGETPARAMSENTRY_MODULE 1 + +/* Define if compiling with the target/target module files. */ +#define USING_TARGET_TARGET_MODULE 1 + +/* Define if compiling with the target/target_counters module files. */ +#define USING_TARGET_TARGET_COUNTERS_MODULE 1 + +/* Define if compiling with the agent/nsTransactionTable module files. */ +#define USING_AGENT_NSTRANSACTIONTABLE_MODULE 1 + +/* Define if compiling with the agent/nsModuleTable module files. */ +#define USING_AGENT_NSMODULETABLE_MODULE 1 + +/* Define if compiling with the agent/nsDebug module files. */ +#define USING_AGENT_NSDEBUG_MODULE 1 + +/* Define if compiling with the agent/nsCache module files. */ +#define USING_AGENT_NSCACHE_MODULE 1 + +/* Define if compiling with the agent/nsLogging module files. */ +#define USING_AGENT_NSLOGGING_MODULE 1 + +/* Define if compiling with the agent/nsVacmAccessTable module files. */ +#define USING_AGENT_NSVACMACCESSTABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteScalars module files. */ +#define USING_DISMAN_EVENT_MTESCALARS_MODULE 1 + +/* Define if compiling with the disman/event/mteTrigger module files. */ +#define USING_DISMAN_EVENT_MTETRIGGER_MODULE 1 + +/* Define if compiling with the disman/event/mteTriggerTable module files. */ +#define USING_DISMAN_EVENT_MTETRIGGERTABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteTriggerDeltaTable module files. */ +#define USING_DISMAN_EVENT_MTETRIGGERDELTATABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteTriggerExistenceTable module files. */ +#define USING_DISMAN_EVENT_MTETRIGGEREXISTENCETABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteTriggerBooleanTable module files. */ +#define USING_DISMAN_EVENT_MTETRIGGERBOOLEANTABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteTriggerThresholdTable module files. */ +#define USING_DISMAN_EVENT_MTETRIGGERTHRESHOLDTABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteTriggerConf module files. */ +#define USING_DISMAN_EVENT_MTETRIGGERCONF_MODULE 1 + +/* Define if compiling with the disman/event/mteEvent module files. */ +#define USING_DISMAN_EVENT_MTEEVENT_MODULE 1 + +/* Define if compiling with the disman/event/mteEventTable module files. */ +#define USING_DISMAN_EVENT_MTEEVENTTABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteEventSetTable module files. */ +#define USING_DISMAN_EVENT_MTEEVENTSETTABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteEventNotificationTable module files. */ +#define USING_DISMAN_EVENT_MTEEVENTNOTIFICATIONTABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteEventConf module files. */ +#define USING_DISMAN_EVENT_MTEEVENTCONF_MODULE 1 + +/* Define if compiling with the disman/event/mteObjects module files. */ +#define USING_DISMAN_EVENT_MTEOBJECTS_MODULE 1 + +/* Define if compiling with the disman/event/mteObjectsTable module files. */ +#define USING_DISMAN_EVENT_MTEOBJECTSTABLE_MODULE 1 + +/* Define if compiling with the disman/event/mteObjectsConf module files. */ +#define USING_DISMAN_EVENT_MTEOBJECTSCONF_MODULE 1 + +/* Define if compiling with the disman/schedule/schedCore module files. */ +#define USING_DISMAN_SCHEDULE_SCHEDCORE_MODULE 1 + +/* Define if compiling with the disman/schedule/schedConf module files. */ +#define USING_DISMAN_SCHEDULE_SCHEDCONF_MODULE 1 + +/* Define if compiling with the disman/schedule/schedTable module files. */ +#define USING_DISMAN_SCHEDULE_SCHEDTABLE_MODULE 1 + +/* Define if compiling with the utilities/override module files. */ +#define USING_UTILITIES_OVERRIDE_MODULE 1 + +/* Define if compiling with the hardware/memory module files. */ +#define USING_HARDWARE_MEMORY_MODULE 1 + +/* Define if compiling with the hardware/fsys module files. */ +#define USING_HARDWARE_FSYS_MODULE 1 + +/* Define if compiling with the host/data_access/swinst module files. */ +#define USING_HOST_DATA_ACCESS_SWINST_MODULE 1 + +/* Define if compiling with the host/data_access/swrun module files. */ +#define USING_HOST_DATA_ACCESS_SWRUN_MODULE 1 + +/* Define if compiling with the host/hrSWRunPerfTable module files. */ +#define USING_HOST_HRSWRUNPERFTABLE_MODULE 1 + +/* Define if compiling with the hardware/cpu module files. */ +#define USING_HARDWARE_CPU_MODULE 1 + +/* Define if compiling with the util_funcs module files. */ +#define USING_UTIL_FUNCS_MODULE 1 + +/* Define if compiling with the if-mib/ifTable/ifTable module files. */ +#define USING_IF_MIB_IFTABLE_IFTABLE_MODULE 1 + +/* Define if compiling with the if-mib/ifXTable/ifXTable module files. */ +#define USING_IF_MIB_IFXTABLE_IFXTABLE_MODULE 1 + +/* Define if compiling with the tcp-mib/data_access/tcpConn module files. */ +#define USING_TCP_MIB_DATA_ACCESS_TCPCONN_MODULE 1 + +/* Define if compiling with the tcp-mib/tcpConnectionTable/tcpConnectionTable module files. */ +#define USING_TCP_MIB_TCPCONNECTIONTABLE_TCPCONNECTIONTABLE_MODULE 1 + +/* Define if compiling with the tcp-mib/tcpListenerTable/tcpListenerTable module files. */ +#define USING_TCP_MIB_TCPLISTENERTABLE_TCPLISTENERTABLE_MODULE 1 + +/* Define if compiling with the udp-mib/udpEndpointTable/udpEndpointTable module files. */ +#define USING_UDP_MIB_UDPENDPOINTTABLE_UDPENDPOINTTABLE_MODULE 1 + +/* Define if compiling with the util_funcs/header_generic module files. */ +#define USING_UTIL_FUNCS_HEADER_GENERIC_MODULE 1 + +/* Define if compiling with the mibII/updates module files. */ +#define USING_MIBII_UPDATES_MODULE 1 + +/* Define if compiling with the mibII/vacm_context module files. */ +#define USING_MIBII_VACM_CONTEXT_MODULE 1 + +/* Define if compiling with the kernel_sunos5 module files. */ +#define USING_KERNEL_SUNOS5_MODULE 1 + +/* Define if compiling with the mibII/data_access/at_solaris module files. */ +#define USING_MIBII_DATA_ACCESS_AT_SOLARIS_MODULE 1 + +/* Define if compiling with the mibII/ipAddr module files. */ +#define USING_MIBII_IPADDR_MODULE 1 + +/* Define if compiling with the mibII/var_route module files. */ +#define USING_MIBII_VAR_ROUTE_MODULE 1 + +/* Define if compiling with the mibII/route_write module files. */ +#define USING_MIBII_ROUTE_WRITE_MODULE 1 + +/* Define if compiling with the mibII/tcpTable module files. */ +#define USING_MIBII_TCPTABLE_MODULE 1 + +/* Define if compiling with the mibII/udpTable module files. */ +#define USING_MIBII_UDPTABLE_MODULE 1 + +/* Define if compiling with the ip-forward-mib/ipCidrRouteTable module files. */ +#define USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_MODULE 1 + +/* Define if compiling with the ip-forward-mib/inetCidrRouteTable module files. */ +#define USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipAddressTable/ipAddressTable module files. */ +#define USING_IP_MIB_IPADDRESSTABLE_IPADDRESSTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipAddressPrefixTable/ipAddressPrefixTable module files. */ +#define USING_IP_MIB_IPADDRESSPREFIXTABLE_IPADDRESSPREFIXTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipDefaultRouterTable/ipDefaultRouterTable module files. */ +#define USING_IP_MIB_IPDEFAULTROUTERTABLE_IPDEFAULTROUTERTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/systemstats module files. */ +#define USING_IP_MIB_DATA_ACCESS_SYSTEMSTATS_MODULE 1 + +/* Define if compiling with the ip-mib/ipSystemStatsTable/ipSystemStatsTable module files. */ +#define USING_IP_MIB_IPSYSTEMSTATSTABLE_IPSYSTEMSTATSTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface module files. */ +#define USING_IP_MIB_IPSYSTEMSTATSTABLE_IPSYSTEMSTATSTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access module files. */ +#define USING_IP_MIB_IPSYSTEMSTATSTABLE_IPSYSTEMSTATSTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the ip-mib/ipIfStatsTable/ipIfStatsTable module files. */ +#define USING_IP_MIB_IPIFSTATSTABLE_IPIFSTATSTABLE_MODULE 1 + +/* Define if compiling with the ip-mib/ipIfStatsTable/ipIfStatsTable_interface module files. */ +#define USING_IP_MIB_IPIFSTATSTABLE_IPIFSTATSTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the ip-mib/ipIfStatsTable/ipIfStatsTable_data_access module files. */ +#define USING_IP_MIB_IPIFSTATSTABLE_IPIFSTATSTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the util_funcs/restart module files. */ +#define USING_UTIL_FUNCS_RESTART_MODULE 1 + +/* Define if compiling with the ucd-snmp/pass_common module files. */ +#define USING_UCD_SNMP_PASS_COMMON_MODULE 1 + +/* Define if compiling with the notification/snmpNotifyTable_data module files. */ +#define USING_NOTIFICATION_SNMPNOTIFYTABLE_DATA_MODULE 1 + +/* Define if compiling with the header_complex module files. */ +#define USING_HEADER_COMPLEX_MODULE 1 + +/* Define if compiling with the snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_data_storage module files. */ +#define USING_SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERTABLE_SNMPNOTIFYFILTERTABLE_DATA_STORAGE_MODULE 1 + +/* Define if compiling with the snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable module files. */ +#define USING_SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERTABLE_SNMPNOTIFYFILTERTABLE_MODULE 1 + +/* Define if compiling with the notification/snmpNotifyFilterProfileTable_data module files. */ +#define USING_NOTIFICATION_SNMPNOTIFYFILTERPROFILETABLE_DATA_MODULE 1 + +/* Define if compiling with the target/snmpTargetAddrEntry_data module files. */ +#define USING_TARGET_SNMPTARGETADDRENTRY_DATA_MODULE 1 + +/* Define if compiling with the target/snmpTargetParamsEntry_data module files. */ +#define USING_TARGET_SNMPTARGETPARAMSENTRY_DATA_MODULE 1 + +/* Define if compiling with the hardware/memory/hw_mem module files. */ +#define USING_HARDWARE_MEMORY_HW_MEM_MODULE 1 + +/* Define if compiling with the hardware/memory/memory_solaris module files. */ +#define USING_HARDWARE_MEMORY_MEMORY_SOLARIS_MODULE 1 + +/* Define if compiling with the hardware/fsys/hw_fsys module files. */ +#define USING_HARDWARE_FSYS_HW_FSYS_MODULE 1 + +/* Define if compiling with the hardware/fsys/fsys_mntent module files. */ +#define USING_HARDWARE_FSYS_FSYS_MNTENT_MODULE 1 + +/* Define if compiling with the host/data_access/swinst_pkginfo module files. */ +#define USING_HOST_DATA_ACCESS_SWINST_PKGINFO_MODULE 1 + +/* Define if compiling with the host/data_access/swrun_procfs_psinfo module files. */ +#define USING_HOST_DATA_ACCESS_SWRUN_PROCFS_PSINFO_MODULE 1 + +/* Define if compiling with the hardware/cpu/cpu module files. */ +#define USING_HARDWARE_CPU_CPU_MODULE 1 + +/* Define if compiling with the hardware/cpu/cpu_kstat module files. */ +#define USING_HARDWARE_CPU_CPU_KSTAT_MODULE 1 + +/* Define if compiling with the if-mib/data_access/interface module files. */ +#define USING_IF_MIB_DATA_ACCESS_INTERFACE_MODULE 1 + +/* Define if compiling with the if-mib/ifTable/ifTable_interface module files. */ +#define USING_IF_MIB_IFTABLE_IFTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the if-mib/ifTable/ifTable_data_access module files. */ +#define USING_IF_MIB_IFTABLE_IFTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the if-mib/ifXTable/ifXTable_interface module files. */ +#define USING_IF_MIB_IFXTABLE_IFXTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the if-mib/ifXTable/ifXTable_data_access module files. */ +#define USING_IF_MIB_IFXTABLE_IFXTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the tcp-mib/data_access/tcpConn_common module files. */ +#define USING_TCP_MIB_DATA_ACCESS_TCPCONN_COMMON_MODULE 1 + +/* Define if compiling with the tcp-mib/data_access/tcpConn_solaris2 module files. */ +#define USING_TCP_MIB_DATA_ACCESS_TCPCONN_SOLARIS2_MODULE 1 + +/* Define if compiling with the tcp-mib/tcpConnectionTable/tcpConnectionTable_interface module files. */ +#define USING_TCP_MIB_TCPCONNECTIONTABLE_TCPCONNECTIONTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access module files. */ +#define USING_TCP_MIB_TCPCONNECTIONTABLE_TCPCONNECTIONTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the tcp-mib/tcpListenerTable/tcpListenerTable_interface module files. */ +#define USING_TCP_MIB_TCPLISTENERTABLE_TCPLISTENERTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the tcp-mib/tcpListenerTable/tcpListenerTable_data_access module files. */ +#define USING_TCP_MIB_TCPLISTENERTABLE_TCPLISTENERTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the udp-mib/data_access/udp_endpoint module files. */ +#define USING_UDP_MIB_DATA_ACCESS_UDP_ENDPOINT_MODULE 1 + +/* Define if compiling with the udp-mib/udpEndpointTable/udpEndpointTable_interface module files. */ +#define USING_UDP_MIB_UDPENDPOINTTABLE_UDPENDPOINTTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the udp-mib/udpEndpointTable/udpEndpointTable_data_access module files. */ +#define USING_UDP_MIB_UDPENDPOINTTABLE_UDPENDPOINTTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable module files. */ +#define USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_MODULE 1 + +/* Define if compiling with the ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable module files. */ +#define USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/ipaddress module files. */ +#define USING_IP_MIB_DATA_ACCESS_IPADDRESS_MODULE 1 + +/* Define if compiling with the ip-mib/ipAddressTable/ipAddressTable_interface module files. */ +#define USING_IP_MIB_IPADDRESSTABLE_IPADDRESSTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the ip-mib/ipAddressTable/ipAddressTable_data_access module files. */ +#define USING_IP_MIB_IPADDRESSTABLE_IPADDRESSTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface module files. */ +#define USING_IP_MIB_IPADDRESSPREFIXTABLE_IPADDRESSPREFIXTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access module files. */ +#define USING_IP_MIB_IPADDRESSPREFIXTABLE_IPADDRESSPREFIXTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/defaultrouter module files. */ +#define USING_IP_MIB_DATA_ACCESS_DEFAULTROUTER_MODULE 1 + +/* Define if compiling with the ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface module files. */ +#define USING_IP_MIB_IPDEFAULTROUTERTABLE_IPDEFAULTROUTERTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access module files. */ +#define USING_IP_MIB_IPDEFAULTROUTERTABLE_IPDEFAULTROUTERTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get module files. */ +#define USING_IP_MIB_IPDEFAULTROUTERTABLE_IPDEFAULTROUTERTABLE_DATA_GET_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/systemstats_common module files. */ +#define USING_IP_MIB_DATA_ACCESS_SYSTEMSTATS_COMMON_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/systemstats_solaris2 module files. */ +#define USING_IP_MIB_DATA_ACCESS_SYSTEMSTATS_SOLARIS2_MODULE 1 + +/* Define if compiling with the ip-mib/ipIfStatsTable/ipIfStatsTable_data_get module files. */ +#define USING_IP_MIB_IPIFSTATSTABLE_IPIFSTATSTABLE_DATA_GET_MODULE 1 + +/* Define if compiling with the snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_interface module files. */ +#define USING_SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERTABLE_SNMPNOTIFYFILTERTABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_data_access module files. */ +#define USING_SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERTABLE_SNMPNOTIFYFILTERTABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the if-mib/data_access/interface_solaris2 module files. */ +#define USING_IF_MIB_DATA_ACCESS_INTERFACE_SOLARIS2_MODULE 1 + +/* Define if compiling with the udp-mib/data_access/udp_endpoint_common module files. */ +#define USING_UDP_MIB_DATA_ACCESS_UDP_ENDPOINT_COMMON_MODULE 1 + +/* Define if compiling with the udp-mib/data_access/udp_endpoint_solaris2 module files. */ +#define USING_UDP_MIB_DATA_ACCESS_UDP_ENDPOINT_SOLARIS2_MODULE 1 + +/* Define if compiling with the ip-forward-mib/data_access/route module files. */ +#define USING_IP_FORWARD_MIB_DATA_ACCESS_ROUTE_MODULE 1 + +/* Define if compiling with the ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface module files. */ +#define USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access module files. */ +#define USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface module files. */ +#define USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_INTERFACE_MODULE 1 + +/* Define if compiling with the ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access module files. */ +#define USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_DATA_ACCESS_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/ipaddress_common module files. */ +#define USING_IP_MIB_DATA_ACCESS_IPADDRESS_COMMON_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/ipaddress_solaris2 module files. */ +#define USING_IP_MIB_DATA_ACCESS_IPADDRESS_SOLARIS2_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/defaultrouter_common module files. */ +#define USING_IP_MIB_DATA_ACCESS_DEFAULTROUTER_COMMON_MODULE 1 + +/* Define if compiling with the ip-mib/data_access/defaultrouter_solaris2 module files. */ +#define USING_IP_MIB_DATA_ACCESS_DEFAULTROUTER_SOLARIS2_MODULE 1 + +/* Define if compiling with the ip-forward-mib/data_access/route_common module files. */ +#define USING_IP_FORWARD_MIB_DATA_ACCESS_ROUTE_COMMON_MODULE 1 + +/* Define if compiling with the ip-forward-mib/data_access/route_solaris module files. */ +#define USING_IP_FORWARD_MIB_DATA_ACCESS_ROUTE_SOLARIS_MODULE 1 + diff --git a/illumos-x86_64/usr/include/net-snmp/agent/mib_module_includes.h b/illumos-x86_64/usr/include/net-snmp/agent/mib_module_includes.h new file mode 100644 index 00000000..daa010c8 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/mib_module_includes.h @@ -0,0 +1,202 @@ +/* This file is automatically generated by configure. Do not modify by hand. */ +/*#include "mibgroup/default_modules.h"*/ +/*#include "mibgroup/disman/event-mib.h"*/ +/*#include "mibgroup/host.h"*/ +/*#include "mibgroup/if-mib.h"*/ +/*#include "mibgroup/tcp-mib.h"*/ +#include "mibgroup/ucd-snmp/diskio.h" +/*#include "mibgroup/udp-mib.h"*/ +/*#include "mibgroup/snmpv3mibs.h"*/ +/*#include "mibgroup/mibII.h"*/ +/*#include "mibgroup/ucd_snmp.h"*/ +/*#include "mibgroup/notification.h"*/ +/*#include "mibgroup/notification-log-mib.h"*/ +/*#include "mibgroup/target.h"*/ +/*#include "mibgroup/agent_mibs.h"*/ +/*#include "mibgroup/agentx.h"*/ +/*#include "mibgroup/disman/event.h"*/ +/*#include "mibgroup/disman/schedule.h"*/ +/*#include "mibgroup/utilities.h"*/ +#include "mibgroup/host/hrh_storage.h" +#include "mibgroup/host/hrh_filesys.h" +#include "mibgroup/host/hrSWInstalledTable.h" +#include "mibgroup/host/hrSWRunTable.h" +#include "mibgroup/host/hr_system.h" +#include "mibgroup/host/hr_device.h" +#include "mibgroup/host/hr_other.h" +#include "mibgroup/host/hr_proc.h" +#include "mibgroup/host/hr_network.h" +#include "mibgroup/host/hr_print.h" +#include "mibgroup/host/hr_disk.h" +#include "mibgroup/host/hr_partition.h" +/*#include "mibgroup/if-mib/ifTable.h"*/ +/*#include "mibgroup/if-mib/ifXTable.h"*/ +/*#include "mibgroup/tcp-mib/tcpConnectionTable.h"*/ +/*#include "mibgroup/tcp-mib/tcpListenerTable.h"*/ +/*#include "mibgroup/util_funcs/header_simple_table.h"*/ +/*#include "mibgroup/udp-mib/udpEndpointTable.h"*/ +#include "mibgroup/snmpv3/snmpEngine.h" +#include "mibgroup/snmpv3/snmpMPDStats.h" +#include "mibgroup/snmpv3/usmStats.h" +#include "mibgroup/snmpv3/usmUser.h" +#include "mibgroup/mibII/system_mib.h" +#include "mibgroup/mibII/sysORTable.h" +#include "mibgroup/mibII/snmp_mib.h" +#include "mibgroup/mibII/vacm_vars.h" +#include "mibgroup/mibII/setSerialNo.h" +#include "mibgroup/mibII/at.h" +/*#include "mibgroup/mibII/ifTable.h"*/ +#include "mibgroup/mibII/ip.h" +#include "mibgroup/mibII/tcp.h" +#include "mibgroup/mibII/udp.h" +#include "mibgroup/mibII/icmp.h" +/*#include "mibgroup/ip-forward-mib.h"*/ +/*#include "mibgroup/ip-mib/ipAddressTable.h"*/ +/*#include "mibgroup/ip-mib/ipAddressPrefixTable.h"*/ +/*#include "mibgroup/ip-mib/ipDefaultRouterTable.h"*/ +/*#include "mibgroup/ip-mib/ipSystemStatsTable.h"*/ +/*#include "mibgroup/ip-mib/ipIfStatsTable.h"*/ +#include "mibgroup/ucd-snmp/proc.h" +#include "mibgroup/ucd-snmp/versioninfo.h" +#include "mibgroup/ucd-snmp/pass.h" +#include "mibgroup/ucd-snmp/pass_persist.h" +#include "mibgroup/ucd-snmp/disk_hw.h" +#include "mibgroup/ucd-snmp/loadave.h" +#include "mibgroup/agent/extend.h" +#include "mibgroup/ucd-snmp/errormib.h" +#include "mibgroup/ucd-snmp/file.h" +#include "mibgroup/ucd-snmp/dlmod.h" +#include "mibgroup/ucd-snmp/proxy.h" +#include "mibgroup/ucd-snmp/logmatch.h" +#include "mibgroup/ucd-snmp/memory.h" +#include "mibgroup/ucd-snmp/vmstat.h" +#include "mibgroup/notification/snmpNotifyTable.h" +/*#include "mibgroup/snmp-notification-mib/snmpNotifyFilterTable.h"*/ +#include "mibgroup/notification/snmpNotifyFilterProfileTable.h" +#include "mibgroup/notification-log-mib/notification_log.h" +#include "mibgroup/target/snmpTargetAddrEntry.h" +#include "mibgroup/target/snmpTargetParamsEntry.h" +/*#include "mibgroup/target/target.h"*/ +#include "mibgroup/target/target_counters.h" +#include "mibgroup/agent/nsTransactionTable.h" +#include "mibgroup/agent/nsModuleTable.h" +#include "mibgroup/agent/nsDebug.h" +#include "mibgroup/agent/nsCache.h" +#include "mibgroup/agent/nsLogging.h" +#include "mibgroup/agent/nsVacmAccessTable.h" +#include "mibgroup/disman/event/mteScalars.h" +#include "mibgroup/disman/event/mteTrigger.h" +#include "mibgroup/disman/event/mteTriggerTable.h" +#include "mibgroup/disman/event/mteTriggerDeltaTable.h" +#include "mibgroup/disman/event/mteTriggerExistenceTable.h" +#include "mibgroup/disman/event/mteTriggerBooleanTable.h" +#include "mibgroup/disman/event/mteTriggerThresholdTable.h" +#include "mibgroup/disman/event/mteTriggerConf.h" +#include "mibgroup/disman/event/mteEvent.h" +#include "mibgroup/disman/event/mteEventTable.h" +#include "mibgroup/disman/event/mteEventSetTable.h" +#include "mibgroup/disman/event/mteEventNotificationTable.h" +#include "mibgroup/disman/event/mteEventConf.h" +#include "mibgroup/disman/event/mteObjects.h" +#include "mibgroup/disman/event/mteObjectsTable.h" +#include "mibgroup/disman/event/mteObjectsConf.h" +#include "mibgroup/disman/schedule/schedCore.h" +#include "mibgroup/disman/schedule/schedConf.h" +#include "mibgroup/disman/schedule/schedTable.h" +#include "mibgroup/utilities/override.h" +/*#include "mibgroup/hardware/memory.h"*/ +/*#include "mibgroup/hardware/fsys.h"*/ +#include "mibgroup/host/data_access/swinst.h" +#include "mibgroup/host/data_access/swrun.h" +#include "mibgroup/host/hrSWRunPerfTable.h" +/*#include "mibgroup/hardware/cpu.h"*/ +/*#include "mibgroup/util_funcs.h"*/ +#include "mibgroup/if-mib/ifTable/ifTable.h" +#include "mibgroup/if-mib/ifXTable/ifXTable.h" +/*#include "mibgroup/tcp-mib/data_access/tcpConn.h"*/ +#include "mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.h" +#include "mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.h" +#include "mibgroup/udp-mib/udpEndpointTable/udpEndpointTable.h" +/*#include "mibgroup/util_funcs/header_generic.h"*/ +/*#include "mibgroup/mibII/updates.h"*/ +#include "mibgroup/mibII/vacm_context.h" +#include "mibgroup/kernel_sunos5.h" +/*#include "mibgroup/mibII/data_access/at_solaris.h"*/ +/*#include "mibgroup/mibII/ipAddr.h"*/ +#include "mibgroup/mibII/var_route.h" +/*#include "mibgroup/mibII/route_write.h"*/ +#include "mibgroup/mibII/tcpTable.h" +#include "mibgroup/mibII/udpTable.h" +/*#include "mibgroup/ip-forward-mib/ipCidrRouteTable.h"*/ +/*#include "mibgroup/ip-forward-mib/inetCidrRouteTable.h"*/ +#include "mibgroup/ip-mib/ipAddressTable/ipAddressTable.h" +#include "mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable.h" +#include "mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.h" +/*#include "mibgroup/ip-mib/data_access/systemstats.h"*/ +#include "mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.h" +/*#include "mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.h"*/ +/*#include "mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access.h"*/ +#include "mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable.h" +/*#include "mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.h"*/ +/*#include "mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_access.h"*/ +/*#include "mibgroup/util_funcs/restart.h"*/ +/*#include "mibgroup/ucd-snmp/pass_common.h"*/ +#include "mibgroup/notification/snmpNotifyTable_data.h" +/*#include "mibgroup/header_complex.h"*/ +#include "mibgroup/snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_data_storage.h" +#include "mibgroup/snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable.h" +#include "mibgroup/notification/snmpNotifyFilterProfileTable_data.h" +#include "mibgroup/target/snmpTargetAddrEntry_data.h" +#include "mibgroup/target/snmpTargetParamsEntry_data.h" +#include "mibgroup/hardware/memory/hw_mem.h" +/*#include "mibgroup/hardware/memory/memory_solaris.h"*/ +#include "mibgroup/hardware/fsys/hw_fsys.h" +/*#include "mibgroup/hardware/fsys/fsys_mntent.h"*/ +/*#include "mibgroup/host/data_access/swinst_pkginfo.h"*/ +/*#include "mibgroup/host/data_access/swrun_procfs_psinfo.h"*/ +#include "mibgroup/hardware/cpu/cpu.h" +#include "mibgroup/hardware/cpu/cpu_kstat.h" +#include "mibgroup/if-mib/data_access/interface.h" +/*#include "mibgroup/if-mib/ifTable/ifTable_interface.h"*/ +/*#include "mibgroup/if-mib/ifTable/ifTable_data_access.h"*/ +/*#include "mibgroup/if-mib/ifXTable/ifXTable_interface.h"*/ +/*#include "mibgroup/if-mib/ifXTable/ifXTable_data_access.h"*/ +/*#include "mibgroup/tcp-mib/data_access/tcpConn_common.h"*/ +/*#include "mibgroup/tcp-mib/data_access/tcpConn_solaris2.h"*/ +/*#include "mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.h"*/ +/*#include "mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access.h"*/ +/*#include "mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.h"*/ +/*#include "mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.h"*/ +/*#include "mibgroup/udp-mib/data_access/udp_endpoint.h"*/ +/*#include "mibgroup/udp-mib/udpEndpointTable/udpEndpointTable_interface.h"*/ +/*#include "mibgroup/udp-mib/udpEndpointTable/udpEndpointTable_data_access.h"*/ +#include "mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable.h" +#include "mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable.h" +/*#include "mibgroup/ip-mib/data_access/ipaddress.h"*/ +/*#include "mibgroup/ip-mib/ipAddressTable/ipAddressTable_interface.h"*/ +/*#include "mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.h"*/ +/*#include "mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface.h"*/ +/*#include "mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access.h"*/ +/*#include "mibgroup/ip-mib/data_access/defaultrouter.h"*/ +/*#include "mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface.h"*/ +/*#include "mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access.h"*/ +/*#include "mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get.h"*/ +/*#include "mibgroup/ip-mib/data_access/systemstats_common.h"*/ +/*#include "mibgroup/ip-mib/data_access/systemstats_solaris2.h"*/ +/*#include "mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.h"*/ +/*#include "mibgroup/snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_interface.h"*/ +/*#include "mibgroup/snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_data_access.h"*/ +/*#include "mibgroup/if-mib/data_access/interface_solaris2.h"*/ +/*#include "mibgroup/udp-mib/data_access/udp_endpoint_common.h"*/ +/*#include "mibgroup/udp-mib/data_access/udp_endpoint_solaris2.h"*/ +/*#include "mibgroup/ip-forward-mib/data_access/route.h"*/ +/*#include "mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.h"*/ +/*#include "mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access.h"*/ +/*#include "mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.h"*/ +/*#include "mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access.h"*/ +/*#include "mibgroup/ip-mib/data_access/ipaddress_common.h"*/ +/*#include "mibgroup/ip-mib/data_access/ipaddress_solaris2.h"*/ +/*#include "mibgroup/ip-mib/data_access/defaultrouter_common.h"*/ +/*#include "mibgroup/ip-mib/data_access/defaultrouter_solaris2.h"*/ +/*#include "mibgroup/ip-forward-mib/data_access/route_common.h"*/ +/*#include "mibgroup/ip-forward-mib/data_access/route_solaris.h"*/ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/mib_modules.h b/illumos-x86_64/usr/include/net-snmp/agent/mib_modules.h new file mode 100644 index 00000000..7003a110 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/mib_modules.h @@ -0,0 +1,23 @@ +#ifndef MIB_MODULES_H +#define MIB_MODULES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define DO_INITIALIZE 1 +#define DONT_INITIALIZE 0 + +struct module_init_list { + char *module_name; + struct module_init_list *next; +}; + +void add_to_init_list(char *module_list); +int should_init(const char *module_name); +void init_mib_modules(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/mode_end_call.h b/illumos-x86_64/usr/include/net-snmp/agent/mode_end_call.h new file mode 100644 index 00000000..eb56d0a2 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/mode_end_call.h @@ -0,0 +1,39 @@ +/* + * mode_end_call.h + */ +#ifndef MODE_END_CALL_H +#define MODE_END_CALL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define NETSNMP_MODE_END_ALL_MODES -999 + +typedef struct netsnmp_mode_handler_list_s { + struct netsnmp_mode_handler_list_s *next; + int mode; + netsnmp_mib_handler *callback_handler; +} netsnmp_mode_handler_list; + +/* + * The helper calls another handler after each mode has been + * processed. + */ + +/* public functions */ +netsnmp_mib_handler * +netsnmp_get_mode_end_call_handler(netsnmp_mode_handler_list *endlist); + +netsnmp_mode_handler_list * +netsnmp_mode_end_call_add_mode_callback(netsnmp_mode_handler_list *endlist, + int mode, + netsnmp_mib_handler *callbackh); + +/* internal */ +Netsnmp_Node_Handler netsnmp_mode_end_call_helper; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/multiplexer.h b/illumos-x86_64/usr/include/net-snmp/agent/multiplexer.h new file mode 100644 index 00000000..2bbb7b1a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/multiplexer.h @@ -0,0 +1,39 @@ +#ifndef NETSNMP_MULTIPLEXER_H +#define NETSNMP_MULTIPLEXER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The multiplexer helper + */ + +/** @name multiplexer + * @{ */ + +/** @struct netsnmp_mib_handler_methods + * Defines the subhandlers to be called by the multiplexer helper + */ +typedef struct netsnmp_mib_handler_methods_s { + /** called when a GET request is received */ + netsnmp_mib_handler *get_handler; + /** called when a GETNEXT request is received */ + netsnmp_mib_handler *getnext_handler; + /** called when a GETBULK request is received */ + netsnmp_mib_handler *getbulk_handler; + /** called when a SET request is received */ + netsnmp_mib_handler *set_handler; +} netsnmp_mib_handler_methods; + +/** @} */ + +netsnmp_mib_handler + *netsnmp_get_multiplexer_handler(netsnmp_mib_handler_methods *); + +Netsnmp_Node_Handler netsnmp_multiplexer_helper_handler; + +#ifdef __cplusplus +} +#endif +#endif /* NETSNMP_MULTIPLEXER_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/net-snmp-agent-includes.h b/illumos-x86_64/usr/include/net-snmp/agent/net-snmp-agent-includes.h new file mode 100644 index 00000000..925349e6 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/net-snmp-agent-includes.h @@ -0,0 +1,22 @@ +/* + * A simple helpful wrapper to include lots of agent specific include + * * files for people wanting to embed and snmp agent into an external + * * application + */ +#ifndef NET_SNMP_AGENT_INCLUDES_H +#define NET_SNMP_AGENT_INCLUDES_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* NET_SNMP_AGENT_INCLUDES_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/netsnmp_close_fds.h b/illumos-x86_64/usr/include/net-snmp/agent/netsnmp_close_fds.h new file mode 100644 index 00000000..8c05f553 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/netsnmp_close_fds.h @@ -0,0 +1,6 @@ +#ifndef netsnmp_close_fds_h_INCLUDED +#define netsnmp_close_fds_h_INCLUDED + +extern void netsnmp_close_fds(int fd); + +#endif /* netsnmp_close_fds_h_INCLUDED */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/null.h b/illumos-x86_64/usr/include/net-snmp/agent/null.h new file mode 100644 index 00000000..f24a0b46 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/null.h @@ -0,0 +1,26 @@ +#ifndef AGENT_NULL_H +#define AGENT_NULL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * null.h + */ + +/* + * literally does nothing and is used as a final handler for + * "do-nothing" nodes that must exist solely for mib tree storage + * usage.. + */ + +int netsnmp_register_null(oid *, size_t); +int netsnmp_register_null_context(oid *, size_t, const char *contextName); + +Netsnmp_Node_Handler netsnmp_null_handler; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/old_api.h b/illumos-x86_64/usr/include/net-snmp/agent/old_api.h new file mode 100644 index 00000000..2bd3cd1e --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/old_api.h @@ -0,0 +1,49 @@ +#ifndef OLD_API_H +#define OLD_API_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define OLD_API_NAME "old_api" + +typedef struct netsnmp_old_api_info_s { + struct variable *var; + size_t varsize; + size_t numvars; + + /* + * old stuff + */ + netsnmp_session *ss; + int flags; +} netsnmp_old_api_info; + +typedef struct old_opi_cache_s { + u_char *data; + WriteMethod *write_method; +} netsnmp_old_api_cache; + +int netsnmp_register_old_api(const char *moduleName, + const struct variable *var, + size_t varsize, + size_t numvars, + const oid * mibloc, + size_t mibloclen, + int priority, + int range_subid, + oid range_ubound, + netsnmp_session * ss, + const char *context, + int timeout, int flags); +Netsnmp_Node_Handler netsnmp_old_api_helper; + +/* + * really shouldn't be used + */ +netsnmp_agent_session *netsnmp_get_current_agent_session(void); + +#ifdef __cplusplus +} +#endif +#endif /* OLD_API_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/read_only.h b/illumos-x86_64/usr/include/net-snmp/agent/read_only.h new file mode 100644 index 00000000..41635b0e --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/read_only.h @@ -0,0 +1,29 @@ +#ifndef READ_ONLY_H +#define READ_ONLY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * read_only.h + */ + +/* + * The helper merely intercepts SET requests and handles them early on + * making everything read-only (no SETs are actually permitted). + * Useful as a helper to handlers that are implementing MIBs with no + * SET support. + */ + + +netsnmp_mib_handler *netsnmp_get_read_only_handler(void); +void netsnmp_init_read_only_helper(void); + +Netsnmp_Node_Handler netsnmp_read_only_helper; + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/row_merge.h b/illumos-x86_64/usr/include/net-snmp/agent/row_merge.h new file mode 100644 index 00000000..3e989579 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/row_merge.h @@ -0,0 +1,38 @@ +#ifndef ROW_MERGE_H +#define ROW_MERGE_H + +/* + * This row_merge helper splits a whole bunch of requests into chunks + * based on the row index that they refer to, and passes all requests + * for a given row to the lower handlers. + */ + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct netsnmp_row_merge_status_x { + char count; /* number of requests */ + char rows; /* number of rows (unique indexes) */ + char current; /* current row number */ + char reserved; /* reserver for future use */ + + netsnmp_request_info **saved_requests; /* internal use */ + char *saved_status; /* internal use */ + } netsnmp_row_merge_status; + + netsnmp_mib_handler *netsnmp_get_row_merge_handler(int); + int netsnmp_register_row_merge(netsnmp_handler_registration *reginfo); + void netsnmp_init_row_merge(void); + + int netsnmp_row_merge_status_first(netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo); + int netsnmp_row_merge_status_last(netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo); + + Netsnmp_Node_Handler netsnmp_row_merge_helper_handler; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/scalar.h b/illumos-x86_64/usr/include/net-snmp/agent/scalar.h new file mode 100644 index 00000000..9af92cb1 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/scalar.h @@ -0,0 +1,36 @@ +/* + * scalar.h + */ +#ifndef NETSNMP_SCALAR_H +#define NETSNMP_SCALAR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The scalar helper is designed to simplify the task of adding simple + * scalar objects to the mib tree. + */ + +/* + * GETNEXTs are auto-converted to a GET. + * * non-valid GETs are dropped. + * * The client can assume that if you're called for a GET, it shouldn't + * * have to check the oid at all. Just answer. + */ + +int netsnmp_register_scalar(netsnmp_handler_registration *reginfo); +int netsnmp_register_read_only_scalar(netsnmp_handler_registration *reginfo); + +#define SCALAR_HANDLER_NAME "scalar" + +netsnmp_mib_handler *netsnmp_get_scalar_handler(void); + +Netsnmp_Node_Handler netsnmp_scalar_helper_handler; + +#ifdef __cplusplus +} +#endif + +#endif /** NETSNMP_SCALAR_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/scalar_group.h b/illumos-x86_64/usr/include/net-snmp/agent/scalar_group.h new file mode 100644 index 00000000..f4213371 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/scalar_group.h @@ -0,0 +1,36 @@ +/* + * scalar.h + */ +#ifndef NETSNMP_SCALAR_GROUP_H +#define NETSNMP_SCALAR_GROUP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The scalar group helper is designed to implement a group of + * scalar objects all in one go, making use of the scalar and + * instance helpers. + * + * GETNEXTs are auto-converted to a GET. Non-valid GETs are dropped. + * The client-provided handler just needs to check the OID name to + * see which object is being requested, but can otherwise assume that + * things are fine. + */ + +typedef struct netsnmp_scalar_group_s { + oid lbound; /* XXX - or do we need a more flexible arrangement? */ + oid ubound; +} netsnmp_scalar_group; + +int netsnmp_register_scalar_group(netsnmp_handler_registration *reginfo, + oid first, oid last); +netsnmp_mib_handler *netsnmp_get_scalar_group_handler(oid first, oid last); +Netsnmp_Node_Handler netsnmp_scalar_group_helper_handler; + +#ifdef __cplusplus +} +#endif + +#endif /** NETSNMP_SCALAR_GROUP_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/serialize.h b/illumos-x86_64/usr/include/net-snmp/agent/serialize.h new file mode 100644 index 00000000..08b38c13 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/serialize.h @@ -0,0 +1,24 @@ +#ifndef SERIALIZE_H +#define SERIALIZE_H + +/* + * The serialized helper merely calls its clients multiple times for a + * * given request set, so they don't have to loop through the requests + * * themselves. + */ + +#ifdef __cplusplus +extern "C" { +#endif + + netsnmp_mib_handler *netsnmp_get_serialize_handler(void); + int netsnmp_register_serialize(netsnmp_handler_registration + *reginfo); + void netsnmp_init_serialize(void); + + Netsnmp_Node_Handler netsnmp_serialize_helper_handler; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/set_helper.h b/illumos-x86_64/usr/include/net-snmp/agent/set_helper.h new file mode 100644 index 00000000..81d887ca --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/set_helper.h @@ -0,0 +1,25 @@ +#ifndef SET_HELPER_H +#define SET_HELPER_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct netsnmp_set_info_s { + int action; + void *stateRef; + + /* + * don't use yet: + */ + void **oldData; + int setCleanupFlags; /* XXX: client sets this to: */ +#define AUTO_FREE_STATEREF 0x01 /* calls free(stateRef) */ +#define AUTO_FREE_OLDDATA 0x02 /* calls free(*oldData) */ +#define AUTO_UNDO 0x04 /* ... */ +} netsnmp_set_info; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/snmp_agent.h b/illumos-x86_64/usr/include/net-snmp/agent/snmp_agent.h new file mode 100644 index 00000000..56ca3065 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/snmp_agent.h @@ -0,0 +1,354 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +/** + * @file snmp_agent.h + * + * @addtogroup agent + * @addtogroup table + * External definitions for functions and variables in snmp_agent.c. + * + * @{ + */ + +#ifndef SNMP_AGENT_H +#define SNMP_AGENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define SNMP_MAX_PDU_SIZE 64000 /* local constraint on PDU size sent by agent + * (see also SNMP_MAX_MSG_SIZE in snmp_api.h) */ + +#define SNMP_AGENT_FLAGS_NONE 0x0 +#define SNMP_AGENT_FLAGS_CANCEL_IN_PROGRESS 0x1 + + struct timeval; + + /* + * If non-zero, causes the addresses of peers to be logged when receptions + * occur. + */ + + extern int log_addresses; + + /* + * How many ticks since we last aged the address cache entries. + */ + + extern int lastAddrAge; + + /** @typedef struct netsnmp_request_info_s netsnmp_request_info + * Typedefs the netsnmp_request_info_s struct into + * netsnmp_request_info*/ + /** @struct netsnmp_request_info_s + * The netsnmp request info structure. + */ + typedef struct netsnmp_request_info_s { + /** + * variable bindings + */ + netsnmp_variable_list *requestvb; + + /** + * can be used to pass information on a per-request basis from a + * helper to the later handlers + */ + netsnmp_data_list *parent_data; + + /* + * pointer to the agent_request_info for this request + */ + struct netsnmp_agent_request_info_s *agent_req_info; + + /** don't free, reference to (struct tree)->end */ + oid *range_end; + size_t range_end_len; + + /* + * flags + */ + int delegated; + int processed; + int inclusive; + + int status; + /** index in original pdu */ + int index; + + /** get-bulk */ + int repeat; + int orig_repeat; + netsnmp_variable_list *requestvb_start; + + /* internal use */ + struct netsnmp_request_info_s *next; + struct netsnmp_request_info_s *prev; + struct netsnmp_subtree_s *subtree; + } netsnmp_request_info; + + typedef struct netsnmp_set_info_s { + int action; + void *stateRef; + + /* + * don't use yet: + */ + void **oldData; + int setCleanupFlags; +#define AUTO_FREE_STATEREF 0x01 /* calls free(stateRef) */ +#define AUTO_FREE_OLDDATA 0x02 /* calls free(*oldData) */ +#define AUTO_UNDO 0x03 /* ... */ + } netsnmp_set_info; + + typedef struct netsnmp_tree_cache_s { + struct netsnmp_subtree_s *subtree; + netsnmp_request_info *requests_begin; + netsnmp_request_info *requests_end; + } netsnmp_tree_cache; + +#define MODE_GET SNMP_MSG_GET +#define MODE_GETNEXT SNMP_MSG_GETNEXT +#define MODE_GETBULK SNMP_MSG_GETBULK +#define MODE_GET_STASH SNMP_MSG_INTERNAL_GET_STASH +#ifndef NETSNMP_NO_WRITE_SUPPORT +#define MODE_IS_GET(x) ((x >= 128) && (x != -1) && (x != SNMP_MSG_SET)) +#else /* NETSNMP_NO_WRITE_SUPPORT */ +#define MODE_IS_GET(x) ((x >= 128) && (x != -1)) +#endif /* NETSNMP_NO_WRITE_SUPPORT */ + + /* #define MODE_IS_GET(x) ((x == SNMP_MSG_GET) || (x == SNMP_MSG_GETNEXT) || (x == SNMP_MSG_GETBULK) || (x == SNMP_MSG_INTERNAL_GET_STASH)) */ + +#ifndef NETSNMP_NO_WRITE_SUPPORT +#define MODE_SET_BEGIN SNMP_MSG_INTERNAL_SET_BEGIN +#define MODE_SET_RESERVE1 SNMP_MSG_INTERNAL_SET_RESERVE1 +#define MODE_SET_RESERVE2 SNMP_MSG_INTERNAL_SET_RESERVE2 +#define MODE_SET_ACTION SNMP_MSG_INTERNAL_SET_ACTION +#define MODE_SET_COMMIT SNMP_MSG_INTERNAL_SET_COMMIT +#define MODE_SET_FREE SNMP_MSG_INTERNAL_SET_FREE +#define MODE_SET_UNDO SNMP_MSG_INTERNAL_SET_UNDO +#define MODE_IS_SET(x) ((x < 128) || (x == -1) || (x == SNMP_MSG_SET)) + /* #define MODE_IS_SET(x) (!MODE_IS_GET(x)) */ +#endif /* NETSNMP_NO_WRITE_SUPPORT */ + +#define MODE_BSTEP_PRE_REQUEST SNMP_MSG_INTERNAL_PRE_REQUEST +#define MODE_BSTEP_POST_REQUEST SNMP_MSG_INTERNAL_POST_REQUEST + +#define MODE_BSTEP_OBJECT_LOOKUP SNMP_MSG_INTERNAL_OBJECT_LOOKUP +#ifndef NETSNMP_NO_WRITE_SUPPORT +#define MODE_BSTEP_CHECK_VALUE SNMP_MSG_INTERNAL_CHECK_VALUE +#define MODE_BSTEP_ROW_CREATE SNMP_MSG_INTERNAL_ROW_CREATE +#define MODE_BSTEP_UNDO_SETUP SNMP_MSG_INTERNAL_UNDO_SETUP +#define MODE_BSTEP_SET_VALUE SNMP_MSG_INTERNAL_SET_VALUE +#define MODE_BSTEP_CHECK_CONSISTENCY SNMP_MSG_INTERNAL_CHECK_CONSISTENCY +#define MODE_BSTEP_UNDO_SET SNMP_MSG_INTERNAL_UNDO_SET +#define MODE_BSTEP_COMMIT SNMP_MSG_INTERNAL_COMMIT +#define MODE_BSTEP_UNDO_COMMIT SNMP_MSG_INTERNAL_UNDO_COMMIT +#define MODE_BSTEP_IRREVERSIBLE_COMMIT SNMP_MSG_INTERNAL_IRREVERSIBLE_COMMIT +#define MODE_BSTEP_UNDO_CLEANUP SNMP_MSG_INTERNAL_UNDO_CLEANUP +#endif /* NETSNMP_NO_WRITE_SUPPORT */ + +/** @typedef struct netsnmp_agent_request_info_s netsnmp_agent_request_info + * Typedefs the netsnmp_agent_request_info_s struct into + * netsnmp_agent_request_info + */ + +/** @struct netsnmp_agent_request_info_s + * The agent transaction request structure + */ + typedef struct netsnmp_agent_request_info_s { + int mode; + /** pdu contains authinfo, eg */ +/* netsnmp_pdu *pdu; */ + struct netsnmp_agent_session_s *asp; /* may not be needed */ + /* + * can be used to pass information on a per-pdu basis from a + * helper to the later handlers + */ + netsnmp_data_list *agent_data; + } netsnmp_agent_request_info; + + typedef struct netsnmp_cachemap_s { + int globalid; + int cacheid; + struct netsnmp_cachemap_s *next; + } netsnmp_cachemap; + + typedef struct netsnmp_agent_session_s { + int mode; + netsnmp_session *session; + netsnmp_pdu *pdu; + netsnmp_pdu *orig_pdu; + int rw; + int exact; + int status; + int index; + int oldmode; + + struct netsnmp_agent_session_s *next; + + /* + * new API pointers + */ + netsnmp_agent_request_info *reqinfo; + netsnmp_request_info *requests; + netsnmp_tree_cache *treecache; + netsnmp_variable_list **bulkcache; + int treecache_len; /* length of cache array */ + int treecache_num; /* number of current cache entries */ + netsnmp_cachemap *cache_store; + int vbcount; + int flags; + } netsnmp_agent_session; + + /* + * Address cache handling functions. + */ + + void netsnmp_addrcache_initialise(void); + void netsnmp_addrcache_destroy(void); + void netsnmp_addrcache_age(void); + + + /* + * config file parsing routines + */ + int handle_snmp_packet(int, netsnmp_session *, int, + netsnmp_pdu *, void *); + void snmp_agent_parse_config(char *, char *); + netsnmp_agent_session *init_agent_snmp_session(netsnmp_session *, + netsnmp_pdu *); + void free_agent_snmp_session(netsnmp_agent_session *); + void + netsnmp_remove_and_free_agent_snmp_session(netsnmp_agent_session + *asp); +#ifdef SNMP_NEED_REQUEST_LIST + void + netsnmp_free_agent_snmp_session_by_session(netsnmp_session * sess, + void (*free_request) + (netsnmp_request_list + *)); +#endif + int getNextSessID(void); + void dump_sess_list(void); + int init_master_agent(void); + void shutdown_master_agent(void); + int agent_check_and_process(int block); + void netsnmp_check_delegated_requests(void); + void netsnmp_check_outstanding_agent_requests(void); + + int netsnmp_request_set_error(netsnmp_request_info *request, + int error_value); + int netsnmp_check_requests_error(netsnmp_request_info *reqs); + int netsnmp_check_all_requests_error(netsnmp_agent_session *asp, + int look_for_specific); + int + netsnmp_set_all_requests_error(netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests, + int error_value); + int netsnmp_request_set_error_idx(netsnmp_request_info *requests, + int error_value, int idx); + int + netsnmp_request_set_error_all(netsnmp_request_info *requests, + int error_value); + + /** deprecated, use netsnmp_request_set_error instead */ + int netsnmp_set_request_error(netsnmp_agent_request_info + *reqinfo, + netsnmp_request_info + *request, int error_value); + /** deprecated, use netsnmp_request_set_error instead */ + int netsnmp_set_mode_request_error(int mode, + netsnmp_request_info + *request, + int error_value); + + u_long netsnmp_marker_uptime(marker_t pm); + u_long netsnmp_timeval_uptime(struct timeval *tv); + const_marker_t netsnmp_get_agent_starttime(void); + uint64_t netsnmp_get_agent_runtime(void); + void netsnmp_set_agent_starttime(marker_t s); + u_long netsnmp_get_agent_uptime(void); + void netsnmp_set_agent_uptime(u_long hsec); + int netsnmp_check_transaction_id(int transaction_id); + int netsnmp_agent_check_packet(netsnmp_session *, + struct netsnmp_transport_s + *, void *, int); + int netsnmp_agent_check_parse(netsnmp_session *, + netsnmp_pdu *, int); + int netsnmp_allocate_globalcacheid(void); + + int netsnmp_remove_delegated_requests_for_session(netsnmp_session *sess); + + /* + * Register and de-register agent NSAPs. + */ + + struct netsnmp_transport_s; + + int netsnmp_register_agent_nsap(struct netsnmp_transport_s + *t); + void netsnmp_deregister_agent_nsap(int handle); + + int netsnmp_agent_listen_on(const char *port); + + void + netsnmp_agent_add_list_data(netsnmp_agent_request_info *agent, + netsnmp_data_list *node); + + int + netsnmp_agent_remove_list_data(netsnmp_agent_request_info *ari, + const char * name); + + void * + netsnmp_agent_get_list_data(netsnmp_agent_request_info + *agent, const char *name); + + void + netsnmp_free_agent_data_set(netsnmp_agent_request_info *agent); + + void + netsnmp_free_agent_data_sets(netsnmp_agent_request_info *agent); + void + netsnmp_free_agent_request_info(netsnmp_agent_request_info *ari); + + +#ifndef NETSNMP_NO_PDU_STATS + /* + * pdu stats + */ + typedef struct netsnmp_pdu_stats_s { + u_long processing_time; /* ms */ + time_t timestamp; /* date/time */ + netsnmp_pdu *pdu; + } netsnmp_pdu_stats; + + netsnmp_container * netsnmp_get_pdu_stats(void); + +#endif /* NETSNMP_NO_PDU_STATS */ + + +#ifdef __cplusplus +} +#endif +#endif +/** @} */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/snmp_get_statistic.h b/illumos-x86_64/usr/include/net-snmp/agent/snmp_get_statistic.h new file mode 100644 index 00000000..cc5d4861 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/snmp_get_statistic.h @@ -0,0 +1,20 @@ +#ifndef SNMP_GET_STATISTIC_H +#define SNMP_GET_STATISTIC_H + +/** Registers a scalar group with statistics from @ref snmp_get_statistic. + * as reginfo.[start, start + end - begin]. + * @param reginfo registration to register the items under + * @param start offset to the begin item + * @param begin first snmp_get_statistic key to return + * @param end last snmp_get_statistic key to return + */ +int +netsnmp_register_statistic_handler(netsnmp_handler_registration *reginfo, + oid start, int begin, int end); + +#define NETSNMP_REGISTER_STATISTIC_HANDLER(reginfo, start, stat) \ + netsnmp_register_statistic_handler(reginfo, start, \ + STAT_ ## stat ## _STATS_START, \ + STAT_ ## stat ## _STATS_END) + +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/snmp_vars.h b/illumos-x86_64/usr/include/net-snmp/agent/snmp_vars.h new file mode 100644 index 00000000..77dbd704 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/snmp_vars.h @@ -0,0 +1,138 @@ +/* + * Definitions for SNMP (RFC 1067) agent variable finder. + * + */ + +#ifndef _SNMP_VARS_H_ +#define _SNMP_VARS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/*********************************************************** + Copyright 1988, 1989 by Carnegie Mellon University + Copyright 1989 TGV, Incorporated + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU and TGV not be used +in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + +CMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +******************************************************************/ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + + struct variable; + + /** + * Duplicates a variable. + * + * @return Pointer to the duplicate variable upon success; NULL upon + * failure. + * + * @see struct variable + * @see struct variable1 + * @see struct variable2 + * @see struct variable3 + * @see struct variable4 + * @see struct variable7 + * @see struct variable8 + * @see struct variable13 + */ + struct variable *netsnmp_duplicate_variable(const struct variable *var); + + /* + * Function pointer called by the master agent for writes. + */ + typedef int (WriteMethod) (int action, + u_char * var_val, + u_char var_val_type, + size_t var_val_len, + u_char * statP, + oid * name, size_t length); + + /* + * Function pointer called by the master agent for mib information retrieval + */ + typedef u_char *(FindVarMethod) (struct variable * vp, + oid * name, + size_t * length, + int exact, + size_t * var_len, + WriteMethod ** write_method); + + /* + * Function pointer called by the master agent for setting up subagent requests + */ + typedef int (AddVarMethod) (netsnmp_agent_session *asp, + netsnmp_variable_list * vbp); + + struct nlist; + + extern long long_return; + extern u_char return_buf[]; + + extern oid nullOid[]; + extern int nullOidLen; + +#define INST 0xFFFFFFFF /* used to fill out the instance field of the variables table */ + + struct variable { + u_char magic; /* passed to function as a hint */ + char type; /* type of variable */ + /* + * See important comment in snmp_vars.c relating to acl + */ + u_short acl; /* access control list for variable */ + FindVarMethod *findVar; /* function that finds variable */ + u_char namelen; /* length of above */ + oid name[MAX_OID_LEN]; /* object identifier of variable */ + }; + + int init_agent(const char *); + void shutdown_agent(void); + + int should_init(const char *module_name); + void add_to_init_list(char *module_list); + +#ifdef USING_AGENTX_SUBAGENT_MODULE + void netsnmp_enable_subagent(void); +#endif + +#ifndef _AGENT_REGISTRY_H +#include +#include +#include +#endif + + /* + * fail overloads non-negative integer value. it must be -1 ! + */ +#define MATCH_FAILED (-1) +#define MATCH_SUCCEEDED 0 + +#ifdef __cplusplus +} +#endif +#endif /* _SNMP_VARS_H_ */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/stash_cache.h b/illumos-x86_64/usr/include/net-snmp/agent/stash_cache.h new file mode 100644 index 00000000..3709a278 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/stash_cache.h @@ -0,0 +1,35 @@ +#ifndef STASH_CACHE_H +#define STASH_CACHE_H + +#include +#include + +#define STASH_CACHE_NAME "stash_cache" + +typedef struct netsnmp_stash_cache_info_s { + int cache_valid; + marker_t cache_time; + netsnmp_oid_stash_node *cache; + int cache_length; +} netsnmp_stash_cache_info; + +typedef struct netsnmp_stash_cache_data_s { + void *data; + size_t data_len; + u_char data_type; +} netsnmp_stash_cache_data; + +/* function prototypes */ +void netsnmp_init_stash_cache_helper(void); +netsnmp_mib_handler *netsnmp_get_bare_stash_cache_handler(void); +netsnmp_mib_handler *netsnmp_get_stash_cache_handler(void); +netsnmp_mib_handler *netsnmp_get_timed_bare_stash_cache_handler(int timeout, + oid *rootoid, size_t rootoid_len); +netsnmp_mib_handler *netsnmp_get_timed_stash_cache_handler(int timeout, + oid *rootoid, size_t rootoid_len); +Netsnmp_Node_Handler netsnmp_stash_cache_helper; +netsnmp_oid_stash_node **netsnmp_extract_stash_cache(netsnmp_agent_request_info *reqinfo); +int netsnmp_stash_cache_update(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests, netsnmp_stash_cache_info *cinfo); + + +#endif /* STASH_CACHE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/stash_to_next.h b/illumos-x86_64/usr/include/net-snmp/agent/stash_to_next.h new file mode 100644 index 00000000..200b5aae --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/stash_to_next.h @@ -0,0 +1,24 @@ +/* + * stash_to_next.h + */ +#ifndef STASH_TO_NEXT_H +#define STASH_TO_NEXT_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * The helper merely intercepts GETSTASH requests and converts them to + * GETNEXT reequests. + */ + + +netsnmp_mib_handler *netsnmp_get_stash_to_next_handler(void); +Netsnmp_Node_Handler netsnmp_stash_to_next_helper; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/struct.h b/illumos-x86_64/usr/include/net-snmp/agent/struct.h new file mode 100644 index 00000000..d6c69c04 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/struct.h @@ -0,0 +1,52 @@ +#ifndef UCD_SNMP_STRUCT +#define UCD_SNMP_STRUCT + +#define STRMAX 1024 +#define SHPROC 1 +#define EXECPROC 2 +#define PASSTHRU 3 +#define PASSTHRU_PERSIST 4 +#define MIBMAX 30 + +struct extensible { + char name[STRMAX]; + char *command; + char fixcmd[STRMAX]; + int type; + int result; + char output[STRMAX]; + struct extensible *next; + oid miboid[MIBMAX]; + size_t miblen; + int mibpriority; + netsnmp_pid_t pid; +#if defined(WIN32) + HANDLE tid; /* WIN32 thread */ +#endif +#ifdef USING_SINGLE_COMMON_PASSPERSIST_INSTANCE + struct extensible *passpersist_inst; +#endif /* USING_SINGLE_COMMON_PASSPERSIST_INSTANCE */ +}; + +struct myproc { + char name[STRMAX]; +#ifdef HAVE_PCRE_H + netsnmp_regex_ptr regexp; +#endif + char fixcmd[STRMAX]; + int min; + int max; + struct myproc *next; +}; + +/* + * struct mibinfo + * { + * int numid; + * unsigned long mibid[10]; + * char *name; + * void (*handle) (); + * }; + */ + +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/agent/sysORTable.h b/illumos-x86_64/usr/include/net-snmp/agent/sysORTable.h new file mode 100644 index 00000000..bfebad25 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/sysORTable.h @@ -0,0 +1,62 @@ +#ifndef NETSNMP_SYSORTABLE_H +#define NETSNMP_SYSORTABLE_H + +struct sysORTable { + char *OR_descr; + oid *OR_oid; + size_t OR_oidlen; + netsnmp_session *OR_sess; + u_long OR_uptime; +}; + +struct register_sysOR_parameters { + char *descr; + oid *name; + size_t namelen; +}; + +#define SYS_ORTABLE_REGISTERED_OK 0 +#define SYS_ORTABLE_REGISTRATION_FAILED -1 +#define SYS_ORTABLE_UNREGISTERED_OK 0 +#define SYS_ORTABLE_NO_SUCH_REGISTRATION -1 + +#include + +#define REGISTER_SYSOR_TABLE(theoid, len, descr) \ + do { \ + struct sysORTable t; \ + t.OR_descr = NETSNMP_REMOVE_CONST(char *, descr); \ + t.OR_oid = theoid; \ + t.OR_oidlen = len; \ + t.OR_sess = NULL; \ + t.OR_uptime = 0; \ + snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, \ + SNMPD_CALLBACK_REQ_REG_SYSOR, &t); \ + } while(0); + +#define REGISTER_SYSOR_ENTRY(theoid, descr) \ + REGISTER_SYSOR_TABLE(theoid, sizeof(theoid) / sizeof(oid), \ + descr) + +#define UNREGISTER_SYSOR_TABLE(theoid, len) \ + do { \ + struct sysORTable t; \ + t.OR_descr = NULL; \ + t.OR_oid = theoid; \ + t.OR_oidlen = len; \ + t.OR_sess = NULL; \ + t.OR_uptime = 0; \ + snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, \ + SNMPD_CALLBACK_REQ_UNREG_SYSOR, &t); \ + } while(0); + +#define UNREGISTER_SYSOR_ENTRY(theoid) \ + UNREGISTER_SYSOR_TABLE(theoid, sizeof(theoid) / sizeof(oid)) + +#define UNREGISTER_SYSOR_SESS(sess) \ + snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, \ + SNMPD_CALLBACK_REQ_UNREG_SYSOR_SESS, \ + sess); + + +#endif /* NETSNMP_SYSORTABLE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/table.h b/illumos-x86_64/usr/include/net-snmp/agent/table.h new file mode 100644 index 00000000..68440efb --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/table.h @@ -0,0 +1,200 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +/* + * Portions of this file are copyrighted by: + * Copyright (C) 2007 Apple, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +/** + * @file table.h + * + * @addtogroup table + * + * @{ + */ +#ifndef _TABLE_HANDLER_H_ +#define _TABLE_HANDLER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The table helper is designed to simplify the task of writing a + * table handler for the net-snmp agent. You should create a normal + * handler and register it using the netsnmp_register_table() function + * instead of the netsnmp_register_handler() function. + */ + +/** + * Notes: + * + * 1) illegal indexes automatically get handled for get/set cases. + * Simply check to make sure the value is type ASN_NULL before + * you answer a request. + */ + +/** + * used as an index to parent_data lookups + */ +#define TABLE_HANDLER_NAME "table" + +/** @typedef struct netsnmp_column_info_t netsnmp_column_info + * Typedefs the netsnmp_column_info_t struct into netsnmp_column_info */ + +/** + * @struct netsnmp_column_info_t + * column info struct. OVERLAPPING RANGES ARE NOT SUPPORTED. + */ + typedef struct netsnmp_column_info_t { + char isRange; + /** only useful if isRange == 0 */ + char list_count; + + union { + unsigned int range[2]; + unsigned int *list; + } details; + + struct netsnmp_column_info_t *next; + + } netsnmp_column_info; + +/** @typedef struct netsnmp_table_registration_info_s netsnmp_table_registration_info + * Typedefs the netsnmp_table_registration_info_s struct into + * netsnmp_table_registration_info */ + +/** + * @struct netsnmp_table_registration_info_s + * Table registration structure. + */ + typedef struct netsnmp_table_registration_info_s { + /** list of varbinds with only 'type' set */ + netsnmp_variable_list *indexes; + /** calculated automatically */ + unsigned int number_indexes; + + /** + * the minimum columns number. If there are columns + * in-between which are not valid, use valid_columns to get + * automatic column range checking. + */ + unsigned int min_column; + /** the maximum columns number */ + unsigned int max_column; + + /** more details on columns */ + netsnmp_column_info *valid_columns; + + } netsnmp_table_registration_info; + +/** @typedef struct netsnmp_table_request_info_s netsnmp_table_request_info + * Typedefs the netsnmp_table_request_info_s struct into + * netsnmp_table_request_info */ + +/** + * @struct netsnmp_table_request_info_s + * The table request info structure. + */ + typedef struct netsnmp_table_request_info_s { + /** 0 if OID not long enough */ + unsigned int colnum; + /** 0 if failure to parse any */ + unsigned int number_indexes; + /** contents freed by helper upon exit */ + netsnmp_variable_list *indexes; + + oid index_oid[MAX_OID_LEN]; + size_t index_oid_len; + netsnmp_table_registration_info *reg_info; + } netsnmp_table_request_info; + + netsnmp_mib_handler + *netsnmp_get_table_handler(netsnmp_table_registration_info + *tabreq); + void netsnmp_handler_owns_table_info(netsnmp_mib_handler *handler); + void netsnmp_registration_owns_table_info(netsnmp_handler_registration *reg); + int netsnmp_register_table( netsnmp_handler_registration *reginfo, + netsnmp_table_registration_info *tabreq); + int netsnmp_unregister_table(netsnmp_handler_registration *reginfo); + int netsnmp_table_build_oid( netsnmp_handler_registration *reginfo, + netsnmp_request_info *reqinfo, + netsnmp_table_request_info *table_info); + int + netsnmp_table_build_oid_from_index(netsnmp_handler_registration + *reginfo, + netsnmp_request_info *reqinfo, + netsnmp_table_request_info + *table_info); + int netsnmp_table_build_result(netsnmp_handler_registration + *reginfo, + netsnmp_request_info + *reqinfo, + netsnmp_table_request_info + *table_info, u_char type, + u_char * result, + size_t result_len); + int + netsnmp_update_variable_list_from_index(netsnmp_table_request_info + *); + int + netsnmp_update_indexes_from_variable_list + (netsnmp_table_request_info *tri); + netsnmp_table_registration_info + *netsnmp_find_table_registration_info(netsnmp_handler_registration + *reginfo); + netsnmp_table_registration_info * + netsnmp_table_registration_info_clone(netsnmp_table_registration_info *tri); + void netsnmp_table_registration_info_free(netsnmp_table_registration_info *); + + netsnmp_index * netsnmp_table_index_find_next_row(netsnmp_container *c, + netsnmp_table_request_info *tblreq); + + unsigned int netsnmp_closest_column(unsigned int current, + netsnmp_column_info + *valid_columns); + + Netsnmp_Node_Handler table_helper_handler; + +#define netsnmp_table_helper_add_index(tinfo, type) snmp_varlist_add_variable(&tinfo->indexes, NULL, 0, (u_char)type, NULL, 0); + + void + netsnmp_table_helper_add_indexes(netsnmp_table_registration_info + *tinfo, ...); + + int netsnmp_check_getnext_reply(netsnmp_request_info *request, + oid * prefix, size_t prefix_len, + netsnmp_variable_list * newvar, + netsnmp_variable_list ** outvar); + + netsnmp_table_request_info + *netsnmp_extract_table_info(netsnmp_request_info *); + netsnmp_oid_stash_node + **netsnmp_table_get_or_create_row_stash(netsnmp_agent_request_info + *reqinfo, + const u_char * + storage_name); + unsigned int + netsnmp_table_next_column(netsnmp_table_request_info *table_info); + + + int netsnmp_sparse_table_register(netsnmp_handler_registration *reginfo, + netsnmp_table_registration_info *tabreq); + + netsnmp_mib_handler *netsnmp_sparse_table_handler_get(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _TABLE_HANDLER_H_ */ +/** @} */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/table_array.h b/illumos-x86_64/usr/include/net-snmp/agent/table_array.h new file mode 100644 index 00000000..afe07171 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/table_array.h @@ -0,0 +1,158 @@ +/* + * table_array.h + * $Id$ + */ +#ifndef _TABLE_ARRAY_HANDLER_H_ +#define _TABLE_ARRAY_HANDLER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * The table array helper is designed to simplify the task of + * writing a table handler for the net-snmp agent when the data being + * accessed is in an oid sorted form and must be accessed externally. + * + * Functionally, it is a specialized version of the more + * generic table helper but easies the burden of GETNEXT processing by + * retrieving the appropriate row for ead index through + * function calls which should be supplied by the module that wishes + * help. The module the table_array helps should, afterwards, + * never be called for the case of "MODE_GETNEXT" and only for the GET + * and SET related modes instead. + */ + +#include +#include + +#define TABLE_ARRAY_NAME "table_array" + + /* + * group_item is to allow us to keep a list of requests without + * disrupting the actual netsnmp_request_info list. + */ + typedef struct netsnmp_request_group_item_s { + netsnmp_request_info *ri; + netsnmp_table_request_info *tri; + struct netsnmp_request_group_item_s *next; + } netsnmp_request_group_item; + + /* + * structure to keep a list of requests for each unique index + */ + typedef struct netsnmp_request_group_s { + /* + * index for this row. points to someone else's memory, so + * don't free it! + */ + netsnmp_index index; + + /* + * container in which rows belong + */ + netsnmp_container *table; + + /* + * actual old and new rows + */ + netsnmp_index *existing_row; + netsnmp_index *undo_info; + + /* + * flags + */ + char row_created; + char row_deleted; + char fill1; + char fill2; + + /* + * requests for this row + */ + netsnmp_request_group_item *list; + + int status; + + void *rg_void; + + } netsnmp_request_group; + + typedef int (Netsnmp_User_Row_Operation_c) (const void *lhs, + const void *rhs); + typedef int (Netsnmp_User_Row_Operation) (void *lhs, void *rhs); + typedef int (Netsnmp_User_Get_Processor) (netsnmp_request_info *, + netsnmp_index + *, + netsnmp_table_request_info + *); + typedef netsnmp_index + *(UserRowMethod) (netsnmp_index *); + typedef int (Netsnmp_User_Row_Action) (netsnmp_index *, + netsnmp_index *, + netsnmp_request_group *); + typedef void (Netsnmp_User_Group_Method) (netsnmp_request_group *); + + /* + * structure for array callbacks + */ + typedef struct netsnmp_table_array_callbacks_s { + + Netsnmp_User_Row_Operation *row_copy; + Netsnmp_User_Row_Operation_c *row_compare; + + Netsnmp_User_Get_Processor *get_value; + + + Netsnmp_User_Row_Action *can_activate; + Netsnmp_User_Row_Action *activated; + Netsnmp_User_Row_Action *can_deactivate; + Netsnmp_User_Row_Action *deactivated; + Netsnmp_User_Row_Action *can_delete; + + UserRowMethod *create_row; + UserRowMethod *duplicate_row; + UserRowMethod *delete_row; /* always returns NULL */ + + Netsnmp_User_Group_Method *set_reserve1; + Netsnmp_User_Group_Method *set_reserve2; + Netsnmp_User_Group_Method *set_action; + Netsnmp_User_Group_Method *set_commit; + Netsnmp_User_Group_Method *set_free; + Netsnmp_User_Group_Method *set_undo; + + /** not callbacks, but this is a useful place for them... */ + netsnmp_container* container; + char can_set; + + } netsnmp_table_array_callbacks; + + + int + netsnmp_table_container_register(netsnmp_handler_registration *reginfo, + netsnmp_table_registration_info + *tabreq, + netsnmp_table_array_callbacks *cb, + netsnmp_container *container, + int group_rows); + + int netsnmp_table_array_register(netsnmp_handler_registration *reginfo, + netsnmp_table_registration_info *tabreq, + netsnmp_table_array_callbacks *cb, + netsnmp_container *container, + int group_rows); + + netsnmp_container * netsnmp_extract_array_context(netsnmp_request_info *); + + Netsnmp_Node_Handler netsnmp_table_array_helper_handler; + + int + netsnmp_table_array_check_row_status(netsnmp_table_array_callbacks *cb, + netsnmp_request_group *ag, + long *rs_new, long *rs_old); + +#ifdef __cplusplus +} +#endif + +#endif /* _TABLE_ARRAY_HANDLER_H_ */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/table_container.h b/illumos-x86_64/usr/include/net-snmp/agent/table_container.h new file mode 100644 index 00000000..b3421109 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/table_container.h @@ -0,0 +1,108 @@ +/* + * table_container.h + * $Id$ + */ +#ifndef _TABLE_CONTAINER_HANDLER_H_ +#define _TABLE_CONTAINER_HANDLER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * The table container helper is designed to simplify the task of + * writing a table handler for the net-snmp agent when the data being + * accessed is accessible via a netsnmp_container. + * + * Functionally, it is a specialized version of the more + * generic table helper but easies the burden of GETNEXT processing by + * retrieving the appropriate row for each index through + * function calls which should be supplied by the module that wishes + * help. The module the table_container helps should, afterwards, + * never be called for the case of "MODE_GETNEXT" and only for the GET + * and SET related modes instead. + */ + +#include +#include + +#define TABLE_CONTAINER_ROW "table_container:row" +#define TABLE_CONTAINER_CONTAINER "table_container:container" + +#define TABLE_CONTAINER_KEY_NETSNMP_INDEX 1 /* default */ +#define TABLE_CONTAINER_KEY_VARBIND_INDEX 2 +#define TABLE_CONTAINER_KEY_VARBIND_RAW 3 + +/* ==================================== + * Container Table API: MIB maintenance + * ==================================== */ + + /* + * get an injectable container table handler + */ + netsnmp_mib_handler * + netsnmp_container_table_handler_get(netsnmp_table_registration_info *tabreq, + netsnmp_container *container, + char key_type); + /* + * register a container table + */ + int + netsnmp_container_table_register(netsnmp_handler_registration *reginfo, + netsnmp_table_registration_info *tabreq, + netsnmp_container *container, + char key_type); + int + netsnmp_container_table_unregister(netsnmp_handler_registration *reginfo); + + /** retrieve the container used by the table_container helper */ + netsnmp_container* + netsnmp_container_table_container_extract(netsnmp_request_info *request); + + /** find the context data used by the table_container helper */ +#ifdef NETSNMP_USE_INLINE + NETSNMP_STATIC_INLINE void * + netsnmp_container_table_row_extract(netsnmp_request_info *request) + { + /* + * NOTE: this function must match in table_container.c and table_container.h. + * if you change one, change them both! + */ + return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW); + } + + NETSNMP_STATIC_INLINE void * + netsnmp_container_table_extract_context(netsnmp_request_info *request) + { + /* + * NOTE: this function must match in table_container.c and table_container.h. + * if you change one, change them both! + */ + return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW); + } +#else + void * + netsnmp_container_table_row_extract(netsnmp_request_info *request); + void * + netsnmp_container_table_extract_context(netsnmp_request_info *request); +#endif /* inline */ + + void netsnmp_container_table_row_insert(netsnmp_request_info *request, + netsnmp_index *row); + void netsnmp_container_table_row_remove(netsnmp_request_info *request, + netsnmp_index *row); + +/* =================================== + * Container Table API: Row operations + * =================================== */ + + void * + netsnmp_container_table_find_next_row(netsnmp_request_info *request, + netsnmp_table_request_info *tblreq, + netsnmp_container *container, + char key_type ); +#ifdef __cplusplus +} +#endif + +#endif /* _TABLE_CONTAINER_HANDLER_H_ */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/table_data.h b/illumos-x86_64/usr/include/net-snmp/agent/table_data.h new file mode 100644 index 00000000..f64475e9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/table_data.h @@ -0,0 +1,124 @@ +/* + * table_iterator.h + */ +#ifndef _TABLE_DATA_HANDLER_H_ +#define _TABLE_DATA_HANDLER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * This helper is designed to completely automate the task of storing + * tables of data within the agent that are not tied to external data + * sources (like the kernel, hardware, or other processes, etc). IE, + * all rows within a table are expected to be added manually using + * functions found below. + */ + +#define TABLE_DATA_NAME "table_data" +#define TABLE_DATA_ROW "table_data" +#define TABLE_DATA_TABLE "table_data_table" + + typedef struct netsnmp_table_row_s { + netsnmp_variable_list *indexes; /* stored permanently if store_indexes = 1 */ + oid *index_oid; + size_t index_oid_len; + void *data; /* the data to store */ + + struct netsnmp_table_row_s *next, *prev; /* if used in a list */ + } netsnmp_table_row; + + typedef struct netsnmp_table_data_s { + netsnmp_variable_list *indexes_template; /* containing only types */ + char *name; /* if !NULL, it's registered globally */ + int flags; /* not currently used */ + int store_indexes; + netsnmp_table_row *first_row; + netsnmp_table_row *last_row; + } netsnmp_table_data; + +/* ================================= + * Table Data API: Table maintenance + * ================================= */ + + void netsnmp_table_data_generate_index_oid( netsnmp_table_row *row); + + netsnmp_table_data *netsnmp_create_table_data(const char *name); + netsnmp_table_row *netsnmp_create_table_data_row(void); + netsnmp_table_row *netsnmp_table_data_clone_row( netsnmp_table_row *row); + void *netsnmp_table_data_delete_row(netsnmp_table_row *row); + int netsnmp_table_data_add_row( netsnmp_table_data *table, + netsnmp_table_row *row); + void + netsnmp_table_data_replace_row(netsnmp_table_data *table, + netsnmp_table_row *origrow, + netsnmp_table_row *newrow); + netsnmp_table_row *netsnmp_table_data_remove_row(netsnmp_table_data *table, + netsnmp_table_row *row); + void *netsnmp_table_data_remove_and_delete_row(netsnmp_table_data *table, + netsnmp_table_row *row); + void netsnmp_table_data_delete_table( netsnmp_table_data *table ); + +/* ================================= + * Table Data API: MIB maintenance + * ================================= */ + + netsnmp_mib_handler * + netsnmp_get_table_data_handler(netsnmp_table_data *table); + + int netsnmp_register_table_data(netsnmp_handler_registration *reginfo, + netsnmp_table_data *table, + netsnmp_table_registration_info *table_info); + int netsnmp_register_read_only_table_data( + netsnmp_handler_registration *reginfo, + netsnmp_table_data *table, + netsnmp_table_registration_info *table_info); + Netsnmp_Node_Handler netsnmp_table_data_helper_handler; + + netsnmp_table_data *netsnmp_extract_table( netsnmp_request_info *); + netsnmp_table_row *netsnmp_extract_table_row(netsnmp_request_info *); + void *netsnmp_extract_table_row_data(netsnmp_request_info *); + void netsnmp_insert_table_row(netsnmp_request_info *, netsnmp_table_row *); + + int netsnmp_table_data_build_result(netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *request, + netsnmp_table_row *row, int column, + u_char type, u_char * result_data, + size_t result_data_len); + +/* ================================= + * Table Data API: Row operations + * ================================= */ + + netsnmp_table_row *netsnmp_table_data_get_first_row( + netsnmp_table_data *table); + netsnmp_table_row *netsnmp_table_data_get_next_row( + netsnmp_table_data *table, + netsnmp_table_row *row); + + netsnmp_table_row *netsnmp_table_data_get(netsnmp_table_data *table, + netsnmp_variable_list *indexes); + + netsnmp_table_row *netsnmp_table_data_get_from_oid( + netsnmp_table_data *table, + oid * searchfor, + size_t searchfor_len); + + int netsnmp_table_data_num_rows(netsnmp_table_data *table); + + +/* ================================= + * Table Data API: Index operations + * ================================= */ + +#define netsnmp_table_data_add_index(thetable, type) snmp_varlist_add_variable(&thetable->indexes_template, NULL, 0, type, NULL, 0) +#define netsnmp_table_row_add_index(row, type, value, value_len) snmp_varlist_add_variable(&row->indexes, NULL, 0, type, (const u_char *) value, value_len) + + +#ifdef __cplusplus +} +#endif + +#endif /* _TABLE_DATA_HANDLER_H_ */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/table_dataset.h b/illumos-x86_64/usr/include/net-snmp/agent/table_dataset.h new file mode 100644 index 00000000..66e3b3c0 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/table_dataset.h @@ -0,0 +1,196 @@ +/* + * table_iterator.h + */ +#ifndef _TABLE_DATA_SET_HANDLER_H_ +#define _TABLE_DATA_SET_HANDLER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * This helper is designed to completely automate the task of storing + * tables of data within the agent that are not tied to external data + * sources (like the kernel, hardware, or other processes, etc). IE, + * all rows within a table are expected to be added manually using + * functions found below. + */ + + void netsnmp_init_table_dataset(void); + +#define TABLE_DATA_SET_NAME "netsnmp_table_data_set" + + /* + * return SNMP_ERR_NOERROR or some SNMP specific protocol error id + */ + typedef int (Netsnmp_Value_Change_Ok) (char *old_value, + size_t old_value_len, + char *new_value, + size_t new_value_len, + void *mydata); + + /* + * stored within a given row + */ + typedef struct netsnmp_table_data_set_storage_s { + unsigned int column; + + /* + * info about it? + */ + char writable; + Netsnmp_Value_Change_Ok *change_ok_fn; + void *my_change_data; + + /* + * data actually stored + */ + u_char type; + union { /* value of variable */ + void *voidp; + long *integer; + u_char *string; + oid *objid; + u_char *bitstring; + struct counter64 *counter64; +#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + float *floatVal; + double *doubleVal; +#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */ + } data; + u_long data_len; + + struct netsnmp_table_data_set_storage_s *next; + } netsnmp_table_data_set_storage; + + typedef struct netsnmp_table_data_set_s { + netsnmp_table_data *table; + netsnmp_table_data_set_storage *default_row; + int allow_creation; /* set to 1 to allow creation of new rows */ + unsigned int rowstatus_column; + } netsnmp_table_data_set; + + +/* ============================ + * DataSet API: Table maintenance + * ============================ */ + + netsnmp_table_data_set *netsnmp_create_table_data_set(const char *); + netsnmp_table_row *netsnmp_table_data_set_clone_row( netsnmp_table_row *row); + void netsnmp_table_dataset_delete_all_data( + netsnmp_table_data_set_storage *data); + void netsnmp_table_dataset_delete_row(netsnmp_table_row *row); + + void netsnmp_table_dataset_add_row(netsnmp_table_data_set + *table, + netsnmp_table_row *row); + void + netsnmp_table_dataset_replace_row(netsnmp_table_data_set *table, + netsnmp_table_row *origrow, + netsnmp_table_row *newrow); + void netsnmp_table_dataset_remove_row(netsnmp_table_data_set + *table, + netsnmp_table_row *row); + void + netsnmp_table_dataset_remove_and_delete_row(netsnmp_table_data_set + *table, + netsnmp_table_row *row); + void netsnmp_delete_table_data_set(netsnmp_table_data_set *table_set); + +/* ============================ + * DataSet API: Default row operations + * ============================ */ + + /* + * to set, add column, type, (writable) ? 1 : 0 + */ + /* + * default value, if not NULL, is the default value used in row + * creation. It is copied into the storage template (free your + * calling argument). + */ + int netsnmp_table_set_add_default_row(netsnmp_table_data_set *, + unsigned int, int, int, + void *default_value, + size_t default_value_len); + void netsnmp_table_set_multi_add_default_row(netsnmp_table_data_set *, + ...); + + +/* ============================ + * DataSet API: MIB maintenance + * ============================ */ + + netsnmp_mib_handler + *netsnmp_get_table_data_set_handler(netsnmp_table_data_set *); + Netsnmp_Node_Handler netsnmp_table_data_set_helper_handler; + int netsnmp_register_table_data_set(netsnmp_handler_registration *, + netsnmp_table_data_set *, + netsnmp_table_registration_info *); + netsnmp_table_data_set + *netsnmp_extract_table_data_set(netsnmp_request_info *request); + netsnmp_table_data_set_storage + *netsnmp_extract_table_data_set_column(netsnmp_request_info *, + unsigned int); + netsnmp_oid_stash_node ** + netsnmp_table_dataset_get_or_create_stash(netsnmp_agent_request_info *ari, + netsnmp_table_data_set *tds, + netsnmp_table_request_info *tri); + netsnmp_table_row * + netsnmp_table_dataset_get_newrow(netsnmp_request_info *request, + netsnmp_agent_request_info *reqinfo, + int rootoid_len, + netsnmp_table_data_set *datatable, + netsnmp_table_request_info *table_info); + + +/* ============================ + * DataSet API: Config-based operations + * ============================ */ + + void netsnmp_register_auto_data_table(netsnmp_table_data_set *table_set, + char *registration_name); + void netsnmp_unregister_auto_data_table(netsnmp_table_data_set *table_set, + char *registration_name); + void netsnmp_config_parse_table_set(const char *token, char *line); + void netsnmp_config_parse_add_row( const char *token, char *line); + + +/* ============================ + * DataSet API: Row operations + * ============================ */ + + netsnmp_table_row *netsnmp_table_data_set_get_first_row(netsnmp_table_data_set *table); + netsnmp_table_row *netsnmp_table_data_set_get_next_row( netsnmp_table_data_set *table, + netsnmp_table_row *row); + int netsnmp_table_set_num_rows(netsnmp_table_data_set *table); + + +/* ============================ + * DataSet API: Column operations + * ============================ */ + + netsnmp_table_data_set_storage + *netsnmp_table_data_set_find_column(netsnmp_table_data_set_storage *, + unsigned int); + int netsnmp_mark_row_column_writable( netsnmp_table_row *row, + int column, int writable); + int netsnmp_set_row_column( netsnmp_table_row *, + unsigned int, int, const void *, + size_t); + +/* ============================ + * DataSet API: Index operations + * ============================ */ + + void netsnmp_table_dataset_add_index(netsnmp_table_data_set + *table, u_char type); + void netsnmp_table_set_add_indexes(netsnmp_table_data_set *tset, ...); + +#ifdef __cplusplus +} +#endif + +#define netsnmp_table_row_add_column(row, type, value, value_len) snmp_varlist_add_variable(&row->indexes, NULL, 0, type, (u_char *) value, value_len) + +#endif /* _TABLE_DATA_SET_HANDLER_H_ */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/table_iterator.h b/illumos-x86_64/usr/include/net-snmp/agent/table_iterator.h new file mode 100644 index 00000000..c71dd4e7 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/table_iterator.h @@ -0,0 +1,165 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +/** + * @file table_iterator.h + * @addtogroup table_iterator + * @{ + */ +#ifndef _TABLE_ITERATOR_HANDLER_H_ +#define _TABLE_ITERATOR_HANDLER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + struct netsnmp_iterator_info_s; + + typedef netsnmp_variable_list * + (Netsnmp_First_Data_Point) (void **loop_context, + void **data_context, + netsnmp_variable_list *, + struct netsnmp_iterator_info_s *); + typedef netsnmp_variable_list * + (Netsnmp_Next_Data_Point) (void **loop_context, + void **data_context, + netsnmp_variable_list *, + struct netsnmp_iterator_info_s *); + typedef void *(Netsnmp_Make_Data_Context) (void *loop_context, + struct netsnmp_iterator_info_s *); + typedef void (Netsnmp_Free_Loop_Context) (void *, + struct netsnmp_iterator_info_s *); + typedef void (Netsnmp_Free_Data_Context) (void *, + struct netsnmp_iterator_info_s *); + + /** @typedef struct netsnmp_iterator_info_s netsnmp_iterator_info + * Typedefs the netsnmp_iterator_info_s struct into netsnmp_iterator_info */ + + /** @struct netsnmp_iterator_info_s + + * Holds iterator information containing functions which should be + called by the iterator_handler to loop over your data set and + sort it in a SNMP specific manner. + + The netsnmp_iterator_info typedef can be used instead of directly calling this struct if you would prefer. + */ + typedef struct netsnmp_iterator_info_s { + /** Number of handlers that own this data structure. */ + int refcnt; + + /** Responsible for: returning the first set of "index" data, a + loop-context pointer, and optionally a data context + pointer */ + Netsnmp_First_Data_Point *get_first_data_point; + + /** Given the previous loop context, this should return the + next loop context, associated index set and optionally a + data context */ + Netsnmp_Next_Data_Point *get_next_data_point; + + /** If a data context wasn't supplied by the + get_first_data_point or get_next_data_point functions and + the make_data_context pointer is defined, it will be called + to convert a loop context into a data context. */ + Netsnmp_Make_Data_Context *make_data_context; + + /** A function which should free the loop context. This + function is called at *each* iteration step, which is + not-optimal for speed purposes. The use of + free_loop_context_at_end instead is strongly + encouraged. This can be set to NULL to avoid its usage. */ + Netsnmp_Free_Loop_Context *free_loop_context; + + /** Frees a data context. This will be called at any time a + data context needs to be freed. This may be at the same + time as a correspondng loop context is freed, or much much + later. Multiple data contexts may be kept in existence at + any time. */ + Netsnmp_Free_Data_Context *free_data_context; + + /** Frees a loop context at the end of the entire iteration + sequence. Generally, this would free the loop context + allocated by the get_first_data_point function (which would + then be updated by each call to the get_next_data_point + function). It is not called until the get_next_data_point + function returns a NULL */ + Netsnmp_Free_Loop_Context *free_loop_context_at_end; + + /** This can be used by client handlers to store any + information they need */ + void *myvoid; + int flags; +#define NETSNMP_ITERATOR_FLAG_SORTED 0x01 +#define NETSNMP_HANDLER_OWNS_IINFO 0x02 + + /** A pointer to the netsnmp_table_registration_info object + this iterator is registered along with. */ + netsnmp_table_registration_info *table_reginfo; + + /* Experimental extension - Use At Your Own Risk + (these two fields may change/disappear without warning) */ + Netsnmp_First_Data_Point *get_row_indexes; + netsnmp_variable_list *indexes; + } netsnmp_iterator_info; + +#define TABLE_ITERATOR_NAME "table_iterator" + +/* ============================ + * Iterator API: Table maintenance + * ============================ */ + /* N/A */ + +/* ============================ + * Iterator API: MIB maintenance + * ============================ */ + + void netsnmp_handler_owns_iterator_info(netsnmp_mib_handler *h); + netsnmp_mib_handler + *netsnmp_get_table_iterator_handler(netsnmp_iterator_info *iinfo); + int netsnmp_register_table_iterator(netsnmp_handler_registration *reginfo, + netsnmp_iterator_info *iinfo); + void netsnmp_iterator_delete_table(netsnmp_iterator_info *iinfo); + + void *netsnmp_extract_iterator_context(netsnmp_request_info *); + void netsnmp_insert_iterator_context(netsnmp_request_info *, void *); + + Netsnmp_Node_Handler netsnmp_table_iterator_helper_handler; + +#define netsnmp_register_table_iterator2(reginfo, iinfo) \ + (((iinfo)->flags |= NETSNMP_HANDLER_OWNS_IINFO), \ + netsnmp_register_table_iterator((reginfo), (iinfo))) + + +/* ============================ + * Iterator API: Row operations + * ============================ */ + +void *netsnmp_iterator_row_first( netsnmp_iterator_info *); +void *netsnmp_iterator_row_get( netsnmp_iterator_info *, void *); +void *netsnmp_iterator_row_next( netsnmp_iterator_info *, void *); +void *netsnmp_iterator_row_get_byidx( netsnmp_iterator_info *, + netsnmp_variable_list *); +void *netsnmp_iterator_row_next_byidx( netsnmp_iterator_info *, + netsnmp_variable_list *); +void *netsnmp_iterator_row_get_byoid( netsnmp_iterator_info *, oid *, size_t); +void *netsnmp_iterator_row_next_byoid( netsnmp_iterator_info *, oid *, size_t); +int netsnmp_iterator_row_count( netsnmp_iterator_info *); + + +/* ============================ + * Iterator API: Index operations + * ============================ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TABLE_ITERATOR_HANDLER_H_ */ +/** @} */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/table_tdata.h b/illumos-x86_64/usr/include/net-snmp/agent/table_tdata.h new file mode 100644 index 00000000..b0a16893 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/table_tdata.h @@ -0,0 +1,147 @@ +/* + * table_tdata.h + */ +#ifndef _TABLE_TDATA_HANDLER_H_ +#define _TABLE_TDATA_HANDLER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * This helper is designed to completely automate the task of storing + * tables of data within the agent that are not tied to external data + * sources (like the kernel, hardware, or other processes, etc). IE, + * all rows within a table are expected to be added manually using + * functions found below. + */ + +#define TABLE_TDATA_NAME "table_tdata" +#define TABLE_TDATA_ROW "table_tdata" +#define TABLE_TDATA_TABLE "table_tdata_table" + +#define TDATA_FLAG_NO_STORE_INDEXES 0x01 +#define TDATA_FLAG_NO_CONTAINER 0x02 /* user will provide container */ + + /* + * The (table-independent) per-row data structure + * This is a wrapper round the table-specific per-row data + * structure, which is referred to as a "table entry" + * + * It should be regarded as an opaque, private data structure, + * and shouldn't be accessed directly. + */ + typedef struct netsnmp_tdata_row_s { + netsnmp_index oid_index; /* table_container index format */ + netsnmp_variable_list *indexes; /* stored permanently if store_indexes = 1 */ + void *data; /* the data to store */ + } netsnmp_tdata_row; + + /* + * The data structure to hold a complete table. + * + * This should be regarded as an opaque, private data structure, + * and shouldn't be accessed directly. + */ + typedef struct netsnmp_tdata_s { + netsnmp_variable_list *indexes_template; /* containing only types */ + char *name; /* if !NULL, it's registered globally */ + int flags; /* This field may legitimately be accessed by external code */ + netsnmp_container *container; + } netsnmp_tdata; + +/* Backwards compatability with the previous (poorly named) data structures */ +typedef struct netsnmp_tdata_row_s netsnmp_table_data2row; +typedef struct netsnmp_tdata_s netsnmp_table_data2; + + +/* ============================ + * TData API: Table maintenance + * ============================ */ + + netsnmp_tdata *netsnmp_tdata_create_table(const char *name, long flags); + void netsnmp_tdata_delete_table(netsnmp_tdata *table); + netsnmp_tdata_row *netsnmp_tdata_create_row(void); + netsnmp_tdata_row *netsnmp_tdata_clone_row( netsnmp_tdata_row *row); + int netsnmp_tdata_copy_row( netsnmp_tdata_row *dst_row, + netsnmp_tdata_row *src_row); + void *netsnmp_tdata_delete_row( netsnmp_tdata_row *row); + + int netsnmp_tdata_add_row( netsnmp_tdata *table, + netsnmp_tdata_row *row); + void netsnmp_tdata_replace_row( netsnmp_tdata *table, + netsnmp_tdata_row *origrow, + netsnmp_tdata_row *newrow); + netsnmp_tdata_row *netsnmp_tdata_remove_row(netsnmp_tdata *table, + netsnmp_tdata_row *row); + void *netsnmp_tdata_remove_and_delete_row(netsnmp_tdata *table, + netsnmp_tdata_row *row); + + +/* ============================ + * TData API: MIB maintenance + * ============================ */ + + netsnmp_mib_handler *netsnmp_get_tdata_handler(netsnmp_tdata *table); + + int netsnmp_tdata_register( netsnmp_handler_registration *reginfo, + netsnmp_tdata *table, + netsnmp_table_registration_info *table_info); + int netsnmp_tdata_unregister(netsnmp_handler_registration *reginfo); + + netsnmp_tdata *netsnmp_tdata_extract_table( netsnmp_request_info *); + netsnmp_container *netsnmp_tdata_extract_container(netsnmp_request_info *); + netsnmp_tdata_row *netsnmp_tdata_extract_row( netsnmp_request_info *); + void *netsnmp_tdata_extract_entry( netsnmp_request_info *); + + void netsnmp_insert_tdata_row(netsnmp_request_info *, netsnmp_tdata_row *); + void netsnmp_remove_tdata_row(netsnmp_request_info *, netsnmp_tdata_row *); + + +/* ============================ + * TData API: Row operations + * ============================ */ + + void * netsnmp_tdata_row_entry( netsnmp_tdata_row *row ); + netsnmp_tdata_row *netsnmp_tdata_row_first(netsnmp_tdata *table); + netsnmp_tdata_row *netsnmp_tdata_row_get( netsnmp_tdata *table, + netsnmp_tdata_row *row); + netsnmp_tdata_row *netsnmp_tdata_row_next( netsnmp_tdata *table, + netsnmp_tdata_row *row); + + netsnmp_tdata_row *netsnmp_tdata_row_get_byidx(netsnmp_tdata *table, + netsnmp_variable_list *indexes); + netsnmp_tdata_row *netsnmp_tdata_row_get_byoid(netsnmp_tdata *table, + oid *searchfor, + size_t searchfor_len); + netsnmp_tdata_row *netsnmp_tdata_row_next_byidx(netsnmp_tdata *table, + netsnmp_variable_list *indexes); + netsnmp_tdata_row *netsnmp_tdata_row_next_byoid(netsnmp_tdata *table, + oid *searchfor, + size_t searchfor_len); + + int netsnmp_tdata_row_count(netsnmp_tdata *table); + + +/* ============================ + * TData API: Index operations + * ============================ */ + +#define netsnmp_tdata_add_index(thetable, type) snmp_varlist_add_variable(&thetable->indexes_template, NULL, 0, type, NULL, 0) +#define netsnmp_tdata_row_add_index(row, type, value, value_len) snmp_varlist_add_variable(&row->indexes, NULL, 0, type, (const u_char *) value, value_len) + + int netsnmp_tdata_compare_idx( netsnmp_tdata_row *row, + netsnmp_variable_list *indexes); + int netsnmp_tdata_compare_oid( netsnmp_tdata_row *row, + oid *compareto, size_t compareto_len); + int netsnmp_tdata_compare_subtree_idx(netsnmp_tdata_row *row, + netsnmp_variable_list *indexes); + int netsnmp_tdata_compare_subtree_oid(netsnmp_tdata_row *row, + oid *compareto, size_t compareto_len); + + +#ifdef __cplusplus +} +#endif + +#endif /* _TABLE_TDATA_HANDLER_H_ */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/util_funcs.h b/illumos-x86_64/usr/include/net-snmp/agent/util_funcs.h new file mode 100644 index 00000000..62eca557 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/util_funcs.h @@ -0,0 +1,108 @@ +/* + * util_funcs.h: utilitiy functions for extensible groups. + */ +#ifndef _MIBGROUP_UTIL_FUNCS_H +#define _MIBGROUP_UTIL_FUNCS_H + +config_require(util_funcs/header_generic); +config_require(util_funcs/header_simple_table); + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#include "util_funcs/header_generic.h" +#include "util_funcs/header_simple_table.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "struct.h" + +typedef struct prefix_info +{ + struct prefix_info *next_info; + unsigned long ipAddressPrefixOnLinkFlag; + unsigned long ipAddressPrefixAutonomousFlag; + char in6p[40]; +}prefix_cbx; +#ifndef WIN32 +typedef struct +{ + prefix_cbx **list_head; +}netsnmp_prefix_listen_info; +#endif +int shell_command(struct extensible *); +int exec_command(struct extensible *); +struct extensible *get_exten_instance(struct extensible *, size_t); +int get_exec_output(struct extensible *); +#if defined(WIN32) && !defined(cygwin) +int get_exec_pipes(const char *cmd, int *fdIn, int *fdOut, + HANDLE *pid); +#else +int get_exec_pipes(const char *cmd, int *fdIn, int *fdOut, + pid_t *pid); +#endif +WriteMethod clear_cache; +void print_mib_oid(oid *, size_t); +void sprint_mib_oid(char *, const oid *, size_t); +int checkmib(struct variable *, oid *, size_t *, int, size_t *, + WriteMethod ** write_method, int); +char *find_field(char *, int); +int parse_miboid(const char *, oid *); +void string_append_int(char *, int); +void wait_on_exec(struct extensible *); +const char *make_tempfile(void); + +prefix_cbx *net_snmp_create_prefix_info(unsigned long OnLinkFlag, + unsigned long AutonomousFlag, + char *in6ptr); +#ifndef WIN32 +int net_snmp_find_prefix_info(prefix_cbx **head, + char *address, + prefix_cbx *node_to_find); +int net_snmp_update_prefix_info(prefix_cbx **head, + prefix_cbx *node_to_update); +int net_snmp_search_update_prefix_info(prefix_cbx **head, + prefix_cbx *node_to_use, + int functionality); +int net_snmp_delete_prefix_info(prefix_cbx **head, + char *address); +#endif + +struct netsnmp_linux_link_settings { + uint32_t speed; + uint8_t duplex; +}; + +int netsnmp_get_link_settings(struct netsnmp_linux_link_settings *nlls, + int fd, const char *name); + +#define NIP6(addr) \ + ntohs((addr).s6_addr16[0]), \ + ntohs((addr).s6_addr16[1]), \ + ntohs((addr).s6_addr16[2]), \ + ntohs((addr).s6_addr16[3]), \ + ntohs((addr).s6_addr16[4]), \ + ntohs((addr).s6_addr16[5]), \ + ntohs((addr).s6_addr16[6]), \ + ntohs((addr).s6_addr16[7]) + +#define satosin(x) ((struct sockaddr_in *) &(x)) +#define SOCKADDR(x) (satosin(x)->sin_addr.s_addr) + +#include "util_funcs/MIB_STATS_CACHE_TIMEOUT.h" + +typedef void *mib_table_t; +typedef int (RELOAD) (mib_table_t); +typedef int (COMPARE) (const void *, const void *); +mib_table_t Initialise_Table(int, int, RELOAD*, COMPARE*); +int Search_Table(mib_table_t, void *, int); +int Add_Entry(mib_table_t, void *); +void *Retrieve_Table_Data(mib_table_t, int *); + +#ifdef __cplusplus +} +#endif + +#endif /* _MIBGROUP_UTIL_FUNCS_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/MIB_STATS_CACHE_TIMEOUT.h b/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/MIB_STATS_CACHE_TIMEOUT.h new file mode 100644 index 00000000..848bacd8 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/MIB_STATS_CACHE_TIMEOUT.h @@ -0,0 +1,12 @@ +/* + * util_funcs/MIB_STATS_CACHE_TIMEOUT.h: utilitiy functions for extensible + * groups. + */ +#ifndef _MIBGROUP_UTIL_FUNCS_MIB_STATS_CACHE_TIMEOUT_H +#define _MIBGROUP_UTIL_FUNCS_MIB_STATS_CACHE_TIMEOUT_H + +#ifndef MIB_STATS_CACHE_TIMEOUT +#define MIB_STATS_CACHE_TIMEOUT 5 +#endif + +#endif /* _MIBGROUP_UTIL_FUNCS_MIB_STATS_CACHE_TIMEOUT_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/header_generic.h b/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/header_generic.h new file mode 100644 index 00000000..9861040c --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/header_generic.h @@ -0,0 +1,18 @@ +/* + * util_funcs/header_generic.h: utilitiy functions for extensible groups. + */ +#ifndef _MIBGROUP_UTIL_FUNCS_HEADER_GENERIC_H +#define _MIBGROUP_UTIL_FUNCS_HEADER_GENERIC_H + +#ifdef __cplusplus +extern "C" { +#endif + +int header_generic(struct variable *, oid *, size_t *, int, size_t *, + WriteMethod **); + +#ifdef __cplusplus +} +#endif + +#endif /* _MIBGROUP_UTIL_FUNCS_HEADER_GENERIC_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/header_simple_table.h b/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/header_simple_table.h new file mode 100644 index 00000000..2a95d697 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/util_funcs/header_simple_table.h @@ -0,0 +1,19 @@ +/* + * util_funcs/header_simple_table.h: utilitiy functions for extensible + * groups. + */ +#ifndef _MIBGROUP_UTIL_FUNCS_HEADER_SIMPLE_TABLE_H +#define _MIBGROUP_UTIL_FUNCS_HEADER_SIMPLE_TABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +int header_simple_table(struct variable *, oid *, size_t *, int, size_t *, + WriteMethod **, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _MIBGROUP_UTIL_FUNCS_HEADER_SIMPLE_TABLE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/var_struct.h b/illumos-x86_64/usr/include/net-snmp/agent/var_struct.h new file mode 100644 index 00000000..15b5770c --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/var_struct.h @@ -0,0 +1,116 @@ +#ifndef VAR_STRUCT_H +#define VAR_STRUCT_H +/* + * The subtree structure contains a subtree prefix which applies to + * all variables in the associated variable list. + * + * By converting to a tree of subtree structures, entries can + * now be subtrees of another subtree in the structure. i.e: + * 1.2 + * 1.2.0 + */ + +#define UCD_REGISTRY_OID_MAX_LEN 128 + +/* + * subtree flags + */ +#define FULLY_QUALIFIED_INSTANCE 0x01 +#define SUBTREE_ATTACHED 0x02 + +typedef struct netsnmp_subtree_s { + oid *name_a; /* objid prefix of registered subtree */ + u_char namelen; /* number of subid's in name above */ + oid *start_a; /* objid of start of covered range */ + u_char start_len; /* number of subid's in start name */ + oid *end_a; /* objid of end of covered range */ + u_char end_len; /* number of subid's in end name */ + struct variable *variables; /* pointer to variables array */ + int variables_len; /* number of entries in above array */ + int variables_width; /* sizeof each variable entry */ + char *label_a; /* calling module's label */ + netsnmp_session *session; + u_char flags; + u_char priority; + int timeout; + struct netsnmp_subtree_s *next; /* List of 'sibling' subtrees */ + struct netsnmp_subtree_s *prev; /* (doubly-linked list) */ + struct netsnmp_subtree_s *children; /* List of 'child' subtrees */ + int range_subid; + oid range_ubound; + netsnmp_handler_registration *reginfo; /* new API */ + int cacheid; + int global_cacheid; + size_t oid_off; +} netsnmp_subtree; + +/* + * This is a new variable structure that doesn't have as much memory + * tied up in the object identifier. It's elements have also been re-arranged + * so that the name field can be variable length. Any number of these + * structures can be created with lengths tailor made to a particular + * application. The first 5 elements of the structure must remain constant. + */ +struct variable1 { + u_char magic; /* passed to function as a hint */ + u_char type; /* type of variable */ + u_short acl; /* access control list for variable */ + FindVarMethod *findVar; /* function that finds variable */ + u_char namelen; /* length of name below */ + oid name[1]; /* object identifier of variable */ +}; + +struct variable2 { + u_char magic; /* passed to function as a hint */ + u_char type; /* type of variable */ + u_short acl; /* access control list for variable */ + FindVarMethod *findVar; /* function that finds variable */ + u_char namelen; /* length of name below */ + oid name[2]; /* object identifier of variable */ +}; + +struct variable3 { + u_char magic; /* passed to function as a hint */ + u_char type; /* type of variable */ + u_short acl; /* access control list for variable */ + FindVarMethod *findVar; /* function that finds variable */ + u_char namelen; /* length of name below */ + oid name[3]; /* object identifier of variable */ +}; + +struct variable4 { + u_char magic; /* passed to function as a hint */ + u_char type; /* type of variable */ + u_short acl; /* access control list for variable */ + FindVarMethod *findVar; /* function that finds variable */ + u_char namelen; /* length of name below */ + oid name[4]; /* object identifier of variable */ +}; + +struct variable7 { + u_char magic; /* passed to function as a hint */ + u_char type; /* type of variable */ + u_short acl; /* access control list for variable */ + FindVarMethod *findVar; /* function that finds variable */ + u_char namelen; /* length of name below */ + oid name[7]; /* object identifier of variable */ +}; + +struct variable8 { + u_char magic; /* passed to function as a hint */ + u_char type; /* type of variable */ + u_short acl; /* access control list for variable */ + FindVarMethod *findVar; /* function that finds variable */ + u_char namelen; /* length of name below */ + oid name[8]; /* object identifier of variable */ +}; + +struct variable13 { + u_char magic; /* passed to function as a hint */ + u_char type; /* type of variable */ + u_short acl; /* access control list for variable */ + FindVarMethod *findVar; /* function that finds variable */ + u_char namelen; /* length of name below */ + oid name[13]; /* object identifier of variable */ +}; +#endif /* VAR_STRUCT_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/agent/watcher.h b/illumos-x86_64/usr/include/net-snmp/agent/watcher.h new file mode 100644 index 00000000..67104eee --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/agent/watcher.h @@ -0,0 +1,148 @@ +/* + * watcher.h + */ +#ifndef NETSNMP_WATCHER_H +#define NETSNMP_WATCHER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** @ingroup watcher + * @{ + */ + +/* + * if handler flag has this bit set, the timestamp will be + * treated as a pointer to the timestamp. If this bit is + * not set (the default), the timestamp is a struct timeval + * that must be compared to the agent starttime. + */ +#define NETSNMP_WATCHER_DIRECT MIB_HANDLER_CUSTOM1 + +/** The size of the watched object is constant. + * @hideinitializer + */ +#define WATCHER_FIXED_SIZE 0x01 +/** The maximum size of the watched object is stored in max_size. + * If WATCHER_SIZE_STRLEN is set then it is supposed that max_size + 1 + * bytes could be stored in the buffer. + * @hideinitializer + */ +#define WATCHER_MAX_SIZE 0x02 +/** If set then the variable data_size_p points to is supposed to hold the + * current size of the watched object and will be updated on writes. + * @hideinitializer + * @since Net-SNMP 5.5 + */ +#define WATCHER_SIZE_IS_PTR 0x04 +/** If set then data is suppposed to be a zero-terminated character array + * and both data_size and data_size_p are ignored. Additionally \\0 is a + * forbidden character in the data set. + * @hideinitializer + * @since Net-SNMP 5.5 + */ +#define WATCHER_SIZE_STRLEN 0x08 +/** If set then size is in units of object identifiers. + * This is useful if you have an OID and tracks the OID_LENGTH of it as + * opposed to it's size. + * @hideinitializer + * @since Net-SNMP 5.5.1 + */ +#define WATCHER_SIZE_UNIT_OIDS 0x10 + +typedef struct netsnmp_watcher_info_s { + void *data; + size_t data_size; + size_t max_size; + u_char type; + int flags; + size_t *data_size_p; +} netsnmp_watcher_info; + +/** @} */ + +int netsnmp_register_watched_instance( netsnmp_handler_registration *reginfo, + netsnmp_watcher_info *winfo); +int netsnmp_register_watched_instance2(netsnmp_handler_registration *reginfo, + netsnmp_watcher_info *winfo); +int netsnmp_register_watched_scalar( netsnmp_handler_registration *reginfo, + netsnmp_watcher_info *winfo); +int netsnmp_register_watched_scalar2( netsnmp_handler_registration *reginfo, + netsnmp_watcher_info *winfo); +int netsnmp_register_watched_timestamp(netsnmp_handler_registration *reginfo, + marker_t timestamp); +int netsnmp_watched_timestamp_register(netsnmp_mib_handler *whandler, + netsnmp_handler_registration *reginfo, + marker_t timestamp); +int netsnmp_register_watched_spinlock(netsnmp_handler_registration *reginfo, + int *spinlock); + +/* + * Convenience registration calls + */ + +int netsnmp_register_ulong_scalar(const char *name, + const oid * reg_oid, size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler * subhandler); +int netsnmp_register_read_only_ulong_scalar(const char *name, + const oid * reg_oid, size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler * subhandler); +int netsnmp_register_long_scalar(const char *name, + const oid * reg_oid, size_t reg_oid_len, + long * it, + Netsnmp_Node_Handler * subhandler); +int netsnmp_register_read_only_long_scalar(const char *name, + const oid * reg_oid, size_t reg_oid_len, + long * it, + Netsnmp_Node_Handler * subhandler); +int netsnmp_register_int_scalar(const char *name, + const oid * reg_oid, size_t reg_oid_len, + int * it, + Netsnmp_Node_Handler * subhandler); +int netsnmp_register_read_only_int_scalar(const char *name, + const oid * reg_oid, size_t reg_oid_len, + int * it, + Netsnmp_Node_Handler * subhandler); +int netsnmp_register_read_only_counter32_scalar(const char *name, + const oid * reg_oid, size_t reg_oid_len, + u_long * it, + Netsnmp_Node_Handler * subhandler); + +#define WATCHER_HANDLER_NAME "watcher" + +netsnmp_mib_handler *netsnmp_get_watcher_handler(void); + +netsnmp_watcher_info * +netsnmp_init_watcher_info(netsnmp_watcher_info *, void *, size_t, u_char, int); + +netsnmp_watcher_info * +netsnmp_init_watcher_info6(netsnmp_watcher_info *, + void *, size_t, u_char, int, size_t, size_t*); + +netsnmp_watcher_info * +netsnmp_create_watcher_info(void *, size_t, u_char, int); + +netsnmp_watcher_info * +netsnmp_create_watcher_info6(void *, size_t, u_char, int, size_t, size_t*); + +netsnmp_watcher_info * +netsnmp_clone_watcher_info(netsnmp_watcher_info *winfo); +void +netsnmp_owns_watcher_info(netsnmp_mib_handler *handler); + +Netsnmp_Node_Handler netsnmp_watcher_helper_handler; + +netsnmp_mib_handler *netsnmp_get_watched_timestamp_handler(void); +Netsnmp_Node_Handler netsnmp_watched_timestamp_handler; + +netsnmp_mib_handler *netsnmp_get_watched_spinlock_handler(void); +Netsnmp_Node_Handler netsnmp_watched_spinlock_handler; + +#ifdef __cplusplus +} +#endif + +#endif /** NETSNMP_WATCHER_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/config_api.h b/illumos-x86_64/usr/include/net-snmp/config_api.h new file mode 100644 index 00000000..048eed90 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/config_api.h @@ -0,0 +1,100 @@ +#ifndef NET_SNMP_CONFIG_API_H +#define NET_SNMP_CONFIG_API_H + + /** + * Library API routines concerned with configuration and control + * of the behaviour of the library, agent and other applications. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + /* Config Handlers */ + NETSNMP_IMPORT + struct config_line *register_config_handler(const char *filePrefix, + const char *token, + void (*parser) (const char *, char *), + void (*releaser) (void), + const char *usageLine); + NETSNMP_IMPORT + struct config_line *register_const_config_handler(const char *filePrefix, + const char *token, + void (*parser) (const char *, const char *), + void (*releaser) (void), + const char *usageLine); + NETSNMP_IMPORT + struct config_line *register_prenetsnmp_mib_handler(const char *filePrefix, + const char *token, + void (*parser) (const char *, char *), + void (*releaser) (void), + const char *usageLine); + NETSNMP_IMPORT + void unregister_config_handler(const char *filePrefix, const char *token); + + /* Defined in mib.c, rather than read_config.c */ + void register_mib_handlers(void); + void unregister_all_config_handlers(void); + + /* Application Handlers */ + NETSNMP_IMPORT + struct config_line *register_app_config_handler( + const char *token, + void (*parser) (const char *, char *), + void (*releaser) (void), + const char *usageLine); + + NETSNMP_IMPORT + struct config_line *register_app_prenetsnmp_mib_handler( + const char *token, + void (*parser) (const char *, char *), + void (*releaser) (void), + const char *usageLine); + NETSNMP_IMPORT + void unregister_app_config_handler( const char *token); + + /* Reading Config Files */ + NETSNMP_IMPORT + void read_configs(void); + NETSNMP_IMPORT + void read_premib_configs(void); + + /* Help Strings and Errors */ + NETSNMP_IMPORT + void read_config_print_usage(const char *lead); + NETSNMP_IMPORT + void config_perror(const char *); + NETSNMP_IMPORT + void config_pwarn(const char *); + +#ifdef __cplusplus +} +#endif + + /* + * Having extracted the main ("public API") calls relevant + * to this area of the Net-SNMP project, the next step is to + * identify the related "public internal API" routines. + * + * In due course, these should probably be gathered + * together into a companion 'library/config_api.h' header file. + * [Or some suitable name] + * + * But for the time being, the expectation is that the + * traditional headers that provided the above definitions + * will probably also cover the relevant internal API calls. + * Hence they are listed here: + */ +#include + +#include +#include + +#include /* for FILE definition */ +#include +#include +#include + +#endif /* NET_SNMP_CONFIG_API_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/definitions.h b/illumos-x86_64/usr/include/net-snmp/definitions.h new file mode 100644 index 00000000..27405c46 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/definitions.h @@ -0,0 +1,32 @@ +#ifndef NET_SNMP_DEFINITIONS_H +#define NET_SNMP_DEFINITIONS_H + + /** + * Defined constants, and other similar enumerations. + */ + +#define MAX_OID_LEN 128 /* max subid's in an oid */ + +#define ONE_SEC 1000000L + + /* + * For the initial release, this will just refer to the + * relevant UCD header files. + * In due course, the relevant definitions will be + * identified, and listed here directly. + * + * But for the time being, this header file is primarily a placeholder, + * to allow application writers to adopt the new header file names. + */ + +#include /* for oid */ +#include +#include +#include +#include +#include +/* + * #include + */ + +#endif /* NET_SNMP_DEFINITIONS_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/README b/illumos-x86_64/usr/include/net-snmp/library/README new file mode 100644 index 00000000..daac670a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/README @@ -0,0 +1,67 @@ +One of the goals of the Net-SNMP v5 development line, is to try and +clarify the distinction between the "public" library API, and routines +that are regarded as being more "internal" to the library. + + This doesn't mean that application writers are discouraged from +making use of such internal routines. There is a strong feeling +within the development team that as much as possible of the library +should be made externally visible, to support writing as wide a +range of applications as possible. To that end, most routines +will be declared within an installed header file, rather than +privately within the library code files themselves. + + The public/internal categorisation is rather concerned with issues +of documentation, stability, and ease of programming. The public +API routines have been selected as those covering the more common +requirements (e.g. creating SNMP requests, sending them to other SNMP +agents, and interpreting the results), together with certain supporting +activities (e.g. run-time configuration). + + The intention is that these routines should be properly documented, +and remain relatively stable. We will attempt to avoid changing the +profile of these interfaces, and would normally provide some mechanism +to retain backward compatability if need be. + + On the other hand, the internal API routines are regarded as just +that - "internal" - so may legitimately be changed without providing +any compatability mechanism. You are perfectly free to make use of +these routines, but be aware that you do so "at your own risk". + +[This statement is in no way intended to challenge or amend the status + of the disclaimers in the top-level 'COPYING' file, which remain + unchanged as the legal basis for using this code] + + + There are (currently) eight main "public API" header files, relating +to various areas of SNMP programming, plus a combined "all-in-one" +header file (net-snmp-includes.h). + Currently these simply include the relevant library header files +following the UCD-SNMP organisation. However, the intention is for +future releases to declare the public API calls directly within these +top-level header files, and use the 'library/*.h' files for the more +internal calls. (i.e. those that are more likely to change over time). + + Until this process can be started, the best approximation to the +"public API" list is probably those routines that are documented +in manual pages. Apologies for any confusion, but hopefully this +process will result in a clearer end result than at present. + +Applications writers are encouraged to start #including the new header +files as soon as possible - either individually, or using the combined +wrapper file. Hopefully, with only a handful of top-level files, it +will be reasonably clear which file(s) might be appropriate for any +particular programming requirement. + + + + One final disclaimer: The above description represents my own +personal aims and understanding of the likely development of the +library API. While I have every confidence in having the support of +the other developers (or being able to persuade them of the benefits +of this approach!), it may turn out that things actually take a different +route. Anyone wishing to influence the organisation of the eventual +library API is encouraged to subscribe to the net-snmp-coders mailing +list, and contribute to the discussions there. + +Dave Shield +February 2002 diff --git a/illumos-x86_64/usr/include/net-snmp/library/asn1.h b/illumos-x86_64/usr/include/net-snmp/library/asn1.h new file mode 100644 index 00000000..8de91624 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/asn1.h @@ -0,0 +1,485 @@ +#ifndef ASN1_H +#define ASN1_H + +#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define PARSE_PACKET 0 +#define DUMP_PACKET 1 + + /* + * Definitions for Abstract Syntax Notation One, ASN.1 + * As defined in ISO/IS 8824 and ISO/IS 8825 + * + * + */ +/*********************************************************** + Copyright 1988, 1989 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ +/* + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + */ + +#define MIN_OID_LEN 2 +#define MAX_OID_LEN 128 /* max subid's in an oid */ +#ifndef MAX_NAME_LEN /* conflicts with some libraries */ +#define MAX_NAME_LEN MAX_OID_LEN /* obsolete. use MAX_OID_LEN */ +#endif + +#define OID_LENGTH(x) (sizeof(x)/sizeof(oid)) + + +#define ASN_BOOLEAN 0x01U +#define ASN_INTEGER 0x02U +#define ASN_BIT_STR 0x03U +#define ASN_OCTET_STR 0x04U +#define ASN_NULL 0x05U +#define ASN_OBJECT_ID 0x06U +#define ASN_SEQUENCE 0x10U +#define ASN_SET 0x11U + +#define ASN_UNIVERSAL 0x00U +#define ASN_APPLICATION 0x40U +#define ASN_CONTEXT 0x80U +#define ASN_PRIVATE 0xC0U + +#define ASN_PRIMITIVE 0x00U +#define ASN_CONSTRUCTOR 0x20U + +#define ASN_LONG_LEN 0x80U +#define ASN_EXTENSION_ID 0x1FU +#define ASN_BIT8 0x80U + +#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR) +#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID) + + struct counter64 { + u_long high; + u_long low; + }; + +#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + typedef struct counter64 integer64; + typedef struct counter64 unsigned64; + + /* + * The BER inside an OPAQUE is an context specific with a value of 48 (0x30) + * plus the "normal" tag. For a Counter64, the tag is 0x46 (i.e., an + * applications specific tag with value 6). So the value for a 64 bit + * counter is 0x46 + 0x30, or 0x76 (118 base 10). However, values + * greater than 30 can not be encoded in one octet. So the first octet + * has the class, in this case context specific (ASN_CONTEXT), and + * the special value (i.e., 31) to indicate that the real value follows + * in one or more octets. The high order bit of each following octet + * indicates if the value is encoded in additional octets. A high order + * bit of zero, indicates the last. For this "hack", only one octet + * will be used for the value. + */ + + /* + * first octet of the tag + */ +#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID) + /* + * base value for the second octet of the tag - the + * second octet was the value for the tag + */ +#define ASN_OPAQUE_TAG2 0x30U + +#define ASN_OPAQUE_TAG2U 0x2fU /* second octet of tag for union */ + + /* + * All the ASN.1 types for SNMP "should have been" defined in this file, + * but they were not. (They are defined in snmp_impl.h) Thus, the tag for + * Opaque and Counter64 is defined, again, here with a different names. + */ +#define ASN_APP_OPAQUE (ASN_APPLICATION | 4) +#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6) +#define ASN_APP_FLOAT (ASN_APPLICATION | 8) +#define ASN_APP_DOUBLE (ASN_APPLICATION | 9) +#define ASN_APP_I64 (ASN_APPLICATION | 10) +#define ASN_APP_U64 (ASN_APPLICATION | 11) +#define ASN_APP_UNION (ASN_PRIVATE | 1) /* or ASN_PRIV_UNION ? */ + + /* + * value for Counter64 + */ +#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64) + /* + * max size of BER encoding of Counter64 + */ +#define ASN_OPAQUE_COUNTER64_MX_BER_LEN 12 + + /* + * value for Float + */ +#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT) + /* + * size of BER encoding of Float + */ +#define ASN_OPAQUE_FLOAT_BER_LEN 7 + + /* + * value for Double + */ +#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE) + /* + * size of BER encoding of Double + */ +#define ASN_OPAQUE_DOUBLE_BER_LEN 11 + + /* + * value for Integer64 + */ +#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64) + /* + * max size of BER encoding of Integer64 + */ +#define ASN_OPAQUE_I64_MX_BER_LEN 11 + + /* + * value for Unsigned64 + */ +#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64) + /* + * max size of BER encoding of Unsigned64 + */ +#define ASN_OPAQUE_U64_MX_BER_LEN 12 + +#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */ + + +#define ASN_PRIV_INCL_RANGE (ASN_PRIVATE | 2) +#define ASN_PRIV_EXCL_RANGE (ASN_PRIVATE | 3) +#define ASN_PRIV_DELEGATED (ASN_PRIVATE | 5) +#define ASN_PRIV_IMPLIED_OCTET_STR (ASN_PRIVATE | ASN_OCTET_STR) /* 4 */ +#define ASN_PRIV_IMPLIED_OBJECT_ID (ASN_PRIVATE | ASN_OBJECT_ID) /* 6 */ +#define ASN_PRIV_RETRY (ASN_PRIVATE | 7) /* 199 */ +#define ASN_PRIV_STOP (ASN_PRIVATE | 8) /* 200 */ +#define IS_DELEGATED(x) ((x) == ASN_PRIV_DELEGATED) + + + NETSNMP_IMPORT + int asn_check_packet(u_char *, size_t); + NETSNMP_IMPORT + u_char *asn_parse_int(u_char *, size_t *, u_char *, long *, + size_t); + NETSNMP_IMPORT + u_char *asn_build_int(u_char *, size_t *, u_char, const long *, + size_t); + NETSNMP_IMPORT + u_char *asn_parse_unsigned_int(u_char *, size_t *, u_char *, + u_long *, size_t); + NETSNMP_IMPORT + u_char *asn_build_unsigned_int(u_char *, size_t *, u_char, + const u_long *, size_t); + NETSNMP_IMPORT + u_char *asn_parse_string(u_char *, size_t *, u_char *, + u_char *, size_t *); + NETSNMP_IMPORT + u_char *asn_build_string(u_char *, size_t *, u_char, + const u_char *, size_t); + NETSNMP_IMPORT + u_char *asn_parse_header(u_char *, size_t *, u_char *); + NETSNMP_IMPORT + u_char *asn_parse_sequence(u_char *, size_t *, u_char *, u_char expected_type, /* must be this type */ + const char *estr); /* error message prefix */ + NETSNMP_IMPORT + u_char *asn_build_header(u_char *, size_t *, u_char, size_t); + NETSNMP_IMPORT + u_char *asn_build_sequence(u_char *, size_t *, u_char, size_t); + NETSNMP_IMPORT + u_char *asn_parse_length(u_char *, u_long *); + NETSNMP_IMPORT + u_char *asn_build_length(u_char *, size_t *, size_t); + NETSNMP_IMPORT + u_char *asn_parse_objid(u_char *, size_t *, u_char *, oid *, + size_t *); + NETSNMP_IMPORT + u_char *asn_build_objid(u_char *, size_t *, u_char, oid *, + size_t); + NETSNMP_IMPORT + u_char *asn_parse_null(u_char *, size_t *, u_char *); + NETSNMP_IMPORT + u_char *asn_build_null(u_char *, size_t *, u_char); + NETSNMP_IMPORT + u_char *asn_parse_bitstring(u_char *, size_t *, u_char *, + u_char *, size_t *); + NETSNMP_IMPORT + u_char *asn_build_bitstring(u_char *, size_t *, u_char, + const u_char *, size_t); + NETSNMP_IMPORT + u_char *asn_parse_unsigned_int64(u_char *, size_t *, u_char *, + struct counter64 *, size_t); + NETSNMP_IMPORT + u_char *asn_build_unsigned_int64(u_char *, size_t *, u_char, + const struct counter64 *, size_t); + NETSNMP_IMPORT + u_char *asn_parse_signed_int64(u_char *, size_t *, u_char *, + struct counter64 *, size_t); + NETSNMP_IMPORT + u_char *asn_build_signed_int64(u_char *, size_t *, u_char, + const struct counter64 *, size_t); + NETSNMP_IMPORT + u_char *asn_build_float(u_char *, size_t *, u_char, const float *, + size_t); + NETSNMP_IMPORT + u_char *asn_parse_float(u_char *, size_t *, u_char *, float *, + size_t); + NETSNMP_IMPORT + u_char *asn_build_double(u_char *, size_t *, u_char, const double *, + size_t); + NETSNMP_IMPORT + u_char *asn_parse_double(u_char *, size_t *, u_char *, + double *, size_t); + +#ifdef NETSNMP_USE_REVERSE_ASNENCODING + + /* + * Re-allocator function for below. + */ + + NETSNMP_IMPORT + int asn_realloc(u_char **, size_t *); + + /* + * Re-allocating reverse ASN.1 encoder functions. Synopsis: + * + * u_char *buf = (u_char*)malloc(100); + * u_char type = (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER); + * size_t buf_len = 100, offset = 0; + * long data = 12345; + * int allow_realloc = 1; + * + * if (asn_realloc_rbuild_int(&buf, &buf_len, &offset, allow_realloc, + * type, &data, sizeof(long)) == 0) { + * error; + * } + * + * NOTE WELL: after calling one of these functions with allow_realloc + * non-zero, buf might have moved, buf_len might have grown and + * offset will have increased by the size of the encoded data. + * You should **NEVER** do something like this: + * + * u_char *buf = (u_char *)malloc(100), *ptr; + * u_char type = (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER); + * size_t buf_len = 100, offset = 0; + * long data1 = 1234, data2 = 5678; + * int rc = 0, allow_realloc = 1; + * + * rc = asn_realloc_rbuild_int(&buf, &buf_len, &offset, allow_realloc, + * type, &data1, sizeof(long)); + * ptr = buf[buf_len - offset]; / * points at encoding of data1 * / + * if (rc == 0) { + * error; + * } + * rc = asn_realloc_rbuild_int(&buf, &buf_len, &offset, allow_realloc, + * type, &data2, sizeof(long)); + * make use of ptr here; + * + * + * ptr is **INVALID** at this point. In general, you should store the + * offset value and compute pointers when you need them: + * + * + * + * u_char *buf = (u_char *)malloc(100), *ptr; + * u_char type = (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER); + * size_t buf_len = 100, offset = 0, ptr_offset; + * long data1 = 1234, data2 = 5678; + * int rc = 0, allow_realloc = 1; + * + * rc = asn_realloc_rbuild_int(&buf, &buf_len, &offset, allow_realloc, + * type, &data1, sizeof(long)); + * ptr_offset = offset; + * if (rc == 0) { + * error; + * } + * rc = asn_realloc_rbuild_int(&buf, &buf_len, &offset, allow_realloc, + * type, &data2, sizeof(long)); + * ptr = buf + buf_len - ptr_offset + * make use of ptr here; + * + * + * + * Here, you can see that ptr will be a valid pointer even if the block of + * memory has been moved, as it may well have been. Plenty of examples of + * usage all over asn1.c, snmp_api.c, snmpusm.c. + * + * The other thing you should **NEVER** do is to pass a pointer to a buffer + * on the stack as the first argument when allow_realloc is non-zero, unless + * you really know what you are doing and your machine/compiler allows you to + * free non-heap memory. There are rumours that such things exist, but many + * consider them no more than the wild tales of a fool. + * + * Of course, you can pass allow_realloc as zero, to indicate that you do not + * wish the packet buffer to be reallocated for some reason; perhaps because + * it is on the stack. This may be useful to emulate the functionality of + * the old API: + * + * u_char my_static_buffer[100], *cp = NULL; + * size_t my_static_buffer_len = 100; + * float my_pi = (float)22/(float)7; + * + * cp = asn_rbuild_float(my_static_buffer, &my_static_buffer_len, + * ASN_OPAQUE_FLOAT, &my_pi, sizeof(float)); + * if (cp == NULL) { + * error; + * } + * + * + * IS EQUIVALENT TO: + * + * + * u_char my_static_buffer[100]; + * size_t my_static_buffer_len = 100, my_offset = 0; + * float my_pi = (float)22/(float)7; + * int rc = 0; + * + * rc = asn_realloc_rbuild_float(&my_static_buffer, &my_static_buffer_len, + * &my_offset, 0, + * ASN_OPAQUE_FLOAT, &my_pi, sizeof(float)); + * if (rc == 0) { + * error; + * } + * + * + */ + + + NETSNMP_IMPORT + int asn_realloc_rbuild_int(u_char ** pkt, size_t * pkt_len, + size_t * offset, + int allow_realloc, u_char type, + const long *data, size_t data_size); + + NETSNMP_IMPORT + int asn_realloc_rbuild_string(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, + const u_char * data, + size_t data_size); + + NETSNMP_IMPORT + int asn_realloc_rbuild_unsigned_int(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, + const u_long * data, + size_t data_size); + + NETSNMP_IMPORT + int asn_realloc_rbuild_header(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, + size_t data_size); + + NETSNMP_IMPORT + int asn_realloc_rbuild_sequence(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, + size_t data_size); + + NETSNMP_IMPORT + int asn_realloc_rbuild_length(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + size_t data_size); + + NETSNMP_IMPORT + int asn_realloc_rbuild_objid(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, const oid *, + size_t); + + NETSNMP_IMPORT + int asn_realloc_rbuild_null(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type); + + NETSNMP_IMPORT + int asn_realloc_rbuild_bitstring(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, + const u_char * data, + size_t data_size); + + NETSNMP_IMPORT + int asn_realloc_rbuild_unsigned_int64(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, + struct counter64 + const *data, size_t); + + NETSNMP_IMPORT + int asn_realloc_rbuild_signed_int64(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, + const struct counter64 *data, + size_t); + + NETSNMP_IMPORT + int asn_realloc_rbuild_float(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, const float *data, + size_t data_size); + + NETSNMP_IMPORT + int asn_realloc_rbuild_double(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + u_char type, const double *data, + size_t data_size); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* ASN1_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/callback.h b/illumos-x86_64/usr/include/net-snmp/library/callback.h new file mode 100644 index 00000000..555162dd --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/callback.h @@ -0,0 +1,85 @@ +/* + * callback.c: A generic callback mechanism + */ + +#ifndef CALLBACK_H +#define CALLBACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_CALLBACK_IDS 2 +#define MAX_CALLBACK_SUBIDS 17 + + /* + * Callback Major Types + */ +#define SNMP_CALLBACK_LIBRARY 0 +#define SNMP_CALLBACK_APPLICATION 1 + + /* + * SNMP_CALLBACK_LIBRARY minor types + */ +#define SNMP_CALLBACK_POST_READ_CONFIG 0 +#define SNMP_CALLBACK_STORE_DATA 1 +#define SNMP_CALLBACK_SHUTDOWN 2 +#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG 3 +#define SNMP_CALLBACK_LOGGING 4 +#define SNMP_CALLBACK_SESSION_INIT 5 +#define SNMP_CALLBACK_PRE_READ_CONFIG 7 +#define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG 8 + + + /* + * Callback priority (lower priority numbers called first( + */ +#define NETSNMP_CALLBACK_HIGHEST_PRIORITY -1024 +#define NETSNMP_CALLBACK_DEFAULT_PRIORITY 0 +#define NETSNMP_CALLBACK_LOWEST_PRIORITY 1024 + + typedef int (SNMPCallback) (int majorID, int minorID, + void *serverarg, void *clientarg); + + struct snmp_gen_callback { + SNMPCallback *sc_callback; + void *sc_client_arg; + int priority; + struct snmp_gen_callback *next; + }; + + /* + * function prototypes + */ + NETSNMP_IMPORT + void init_callbacks(void); + + NETSNMP_IMPORT + int netsnmp_register_callback(int major, int minor, + SNMPCallback * new_callback, + void *arg, int priority); + NETSNMP_IMPORT + int snmp_register_callback(int major, int minor, + SNMPCallback * new_callback, + void *arg); + NETSNMP_IMPORT + int snmp_call_callbacks(int major, int minor, + void *caller_arg); + NETSNMP_IMPORT + int snmp_callback_available(int major, int minor); /* is >1 available */ + NETSNMP_IMPORT + int snmp_count_callbacks(int major, int minor); /* ret the number registered */ + NETSNMP_IMPORT + int snmp_unregister_callback(int major, int minor, + SNMPCallback * new_callback, + void *arg, int matchargs); + NETSNMP_IMPORT + void clear_callback (void); + int netsnmp_callback_clear_client_arg(void *, int i, int j); + + struct snmp_gen_callback *snmp_callback_list(int major, int minor); + +#ifdef __cplusplus +} +#endif +#endif /* CALLBACK_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/cert_util.h b/illumos-x86_64/usr/include/net-snmp/library/cert_util.h new file mode 100644 index 00000000..80e2a19f --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/cert_util.h @@ -0,0 +1,230 @@ +#ifndef NETSNMP_CERT_UTIL_H + +#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) + +#ifndef HEADER_SSL_H +#error "must include before cert_util.h" +#endif +#ifndef HEADER_X509_H +#error "must include before cert_util.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /************************************************************************* + * + * netsnmp_cert structures, defines and function definitions + * + *************************************************************************/ + + void netsnmp_certs_init(void); + NETSNMP_IMPORT + void netsnmp_certs_agent_init(void); + void netsnmp_certs_shutdown(void); + void netsnmp_certs_load(void); + netsnmp_container *netsnmp_cert_get_trustlist(void); + + typedef struct netsnmp_cert_common_s { + char *dir; + char *filename; + + u_char type; + u_char allowed_uses; + u_char _pad[2]; /* for future use */ + } netsnmp_cert_common; + + typedef struct netsnmp_key_s { + netsnmp_cert_common info; + + EVP_PKEY *okey; + struct netsnmp_cert_s *cert; + } netsnmp_key; + + typedef struct netsnmp_cert_s { + netsnmp_cert_common info; + + X509 *ocert; + netsnmp_key *key; + struct netsnmp_cert_s *issuer_cert; + + char *issuer; + char *subject; + char *fingerprint; + char *common_name; + + u_char hash_type; + u_char _pad[3]; /* for future use */ + } netsnmp_cert; + +/** types */ + enum { NS_CERT_TYPE_UNKNOWN = 0, NS_CERT_TYPE_PEM, NS_CERT_TYPE_DER, + NS_CERT_TYPE_PKCS12, NS_CERT_TYPE_KEY }; + +/** uses */ +#define NS_CERT_IDENTITY 0x0001 +#define NS_CERT_REMOTE_PEER 0x0002 +#define NS_CERT_RESERVED1 0x0004 +#define NS_CERT_CA 0x0008 + +/** source */ +#define NS_CERTKEY_DEFAULT 0x000 /* get default from DS store */ +#define NS_CERTKEY_FILE 0x001 /* filename/full path */ +#define NS_CERTKEY_FINGERPRINT 0x002 /* public key fingerprint */ +#define NS_CERTKEY_CA 0x004 /* trusted CA */ +#define NS_CERTKEY_SAN_RFC822 0x008 /* subj alt name: rfc822 */ +#define NS_CERTKEY_SAN_DNS 0x010 /* subj alt name: DNS */ +#define NS_CERTKEY_SAN_IPADDR 0x020 /* subj alt name: IP address */ +#define NS_CERTKEY_COMMON_NAME 0x040 /* common name */ +#define NS_CERTKEY_TARGET_PARAM 0x080 /* tlstmParamsTable */ +#define NS_CERTKEY_TARGET_ADDR 0x100 /* tlstmAddrTable */ +#define NS_CERTKEY_MULTIPLE 0x200 /* try multiple sources */ + +/** RFC 5246 hash algorithms (Section 7.4.1.4.1) */ +#define NS_HASH_NONE 0 +#define NS_HASH_MD5 1 +#define NS_HASH_SHA1 2 +#define NS_HASH_SHA224 3 +#define NS_HASH_SHA256 4 +#define NS_HASH_SHA384 5 +#define NS_HASH_SHA512 6 +#define NS_HASH_MAX NS_HASH_SHA512 + +/** SNMP-TLS-TM-MIB */ +#define SNMPTLSFINGERPRINT_MAX_LEN 255 + + /************************************************************************* + * netsnmp_cert function definitions + *************************************************************************/ + + NETSNMP_IMPORT + netsnmp_cert *netsnmp_cert_find(int what, int where, void *hint); + + int netsnmp_cert_check_vb_fingerprint(const netsnmp_variable_list *var); + + void netsnmp_fp_lowercase_and_strip_colon(char *fp); + int netsnmp_cert_parse_hash_type(const char *str); + int netsnmp_tls_fingerprint_build(int hash_type, const char *hex_fp, + u_char **tls_fp, size_t *tls_fp_len, + int allow_realloc); + int netsnmp_tls_fingerprint_parse(const u_char *binary_fp, int fp_len, + char **fp_str_ptr, u_int *fp_str_len, + int allow_realloc, u_char *hash_type_ptr); + + + int netsnmp_cert_trust(SSL_CTX *ctx, netsnmp_cert *thiscert); + int netsnmp_cert_trust_ca(SSL_CTX *ctx, netsnmp_cert *thiscertsrootca); + + /************************************************************************* + * + * certificate to Transport Security Name mapping (netsnmp_cert_map) + * + *************************************************************************/ + +#define TSNM_tlstmCertSpecified 1 +#define TSNM_tlstmCertSANRFC822Name 2 +#define TSNM_tlstmCertSANDNSName 3 +#define TSNM_tlstmCertSANIpAddress 4 +#define TSNM_tlstmCertSANAny 5 +#define TSNM_tlstmCertCommonName 6 +#define TSNM_tlstmCert_MAX TSNM_tlstmCertCommonName + +#define NSCM_FROM_CONFIG 0x0001 +#define NSCM_FROM_MIB 0x0002 +#define NSCM_NONVOLATILE 0x0004 + + typedef struct netsnmp_cert_map_s { + int priority; + char *fingerprint; + int mapType; + char *data; + + char hashType; + char flags; + + X509 *ocert; + } netsnmp_cert_map; + + netsnmp_cert_map *netsnmp_cert_map_alloc(char *fp, X509 *ocert); + void netsnmp_cert_map_free(netsnmp_cert_map *cert_map); + int netsnmp_cert_map_add(netsnmp_cert_map *map); + int netsnmp_cert_map_remove(netsnmp_cert_map *map); + netsnmp_cert_map *netsnmp_cert_map_find(netsnmp_cert_map *map); + + void netsnmp_cert_map_container_free(netsnmp_container *c); + netsnmp_container *netsnmp_cert_map_container_create(int with_fp); + netsnmp_container *netsnmp_cert_map_container(void); + + netsnmp_cert_map *netsnmp_certToTSN_parse_common(char **line); + int netsnmp_cert_get_secname_maps(netsnmp_container *cm); + + /************************************************************************* + * + * snmpTlstmParamsTable data + * + *************************************************************************/ + typedef struct snmpTlstmParams_s { + char *name; + char *fingerprint; + char hashType; + u_char flags; + u_char fingerprint_len; + } snmpTlstmParams; + +#define TLSTM_PARAMS_FROM_CONFIG 0x01 +#define TLSTM_PARAMS_FROM_MIB 0x02 +#define TLSTM_PARAMS_NONVOLATILE 0x04 +/** ine TLSTM_PARAMS_XXX 0x08 */ + + snmpTlstmParams *netsnmp_tlstmParams_create(const char *tag, int hashType, + const char *fp, int fp_len); + void netsnmp_tlstmParams_free(snmpTlstmParams *stp); + snmpTlstmParams *netsnmp_tlstmParams_restore_common(char **line); + + netsnmp_container *netsnmp_tlstmParams_container(void); + int netsnmp_tlstmParams_add(snmpTlstmParams *stp); + int netsnmp_tlstmParams_remove(snmpTlstmParams *stp); + snmpTlstmParams *netsnmp_tlstmParams_find(snmpTlstmParams *stp); + + /************************************************************************* + * + * snmpTlstmAddrTable data + * + *************************************************************************/ + typedef struct snmpTlstmAddr_s { + char *name; + char *fingerprint; + char *identity; + + u_char hashType; + u_char flags; + + } snmpTlstmAddr; + +#define TLSTM_ADDR_FROM_CONFIG 0x01 +#define TLSTM_ADDR_FROM_MIB 0x02 +#define TLSTM_ADDR_NONVOLATILE 0x04 +/** ine TLSTM_ADDR_XXX 0x08 */ + + int netsnmp_tlstmAddr_restore_common(char **line, char *name, + size_t *name_len, char *id, + size_t *id_len, char *fp, + size_t *fp_len, u_char *ht); + netsnmp_container *netsnmp_tlstmAddr_container(void); + snmpTlstmAddr *netsnmp_tlstmAddr_find(snmpTlstmAddr *entry); + snmpTlstmAddr *netsnmp_tlstmAddr_create(char *targetAddrName); + void netsnmp_tlstmAddr_free(snmpTlstmAddr *entry); + int netsnmp_tlstmAddr_add(snmpTlstmAddr *entry); + int netsnmp_tlstmAddr_remove(snmpTlstmAddr *entry); + NETSNMP_IMPORT + char *netsnmp_tlstmAddr_get_serverId(const char *name); + +#ifdef __cplusplus +} +#endif + +#endif /* defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) */ + +#endif /* NETSNMP_CERT_UTIL_H */ + diff --git a/illumos-x86_64/usr/include/net-snmp/library/check_varbind.h b/illumos-x86_64/usr/include/net-snmp/library/check_varbind.h new file mode 100644 index 00000000..1e1615ab --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/check_varbind.h @@ -0,0 +1,53 @@ +#ifndef SNMP_CHECK_VARBIND_H +#define SNMP_CHECK_VARBIND_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Assorted convience routines to check the contents of a + * netsnmp_variable_list instance. + */ + + int netsnmp_check_vb_type(const netsnmp_variable_list *var, int type); + int netsnmp_check_vb_size(const netsnmp_variable_list *var, size_t size ); + int netsnmp_check_vb_max_size(const netsnmp_variable_list *var, size_t size ); + int netsnmp_check_vb_range(const netsnmp_variable_list *var, + size_t low, size_t high ); + int netsnmp_check_vb_size_range(const netsnmp_variable_list *var, + size_t low, size_t high ); + + NETSNMP_IMPORT + int netsnmp_check_vb_type_and_size(const netsnmp_variable_list *var, + int type, size_t size); + NETSNMP_IMPORT + int netsnmp_check_vb_type_and_max_size(const netsnmp_variable_list *var, + int type, size_t size); + + NETSNMP_IMPORT + int netsnmp_check_vb_oid(const netsnmp_variable_list *var); + NETSNMP_IMPORT + int netsnmp_check_vb_int(const netsnmp_variable_list *var); + NETSNMP_IMPORT + int netsnmp_check_vb_uint(const netsnmp_variable_list *var); + NETSNMP_IMPORT + int netsnmp_check_vb_int_range(const netsnmp_variable_list *var, int low, + int high); + + NETSNMP_IMPORT + int netsnmp_check_vb_truthvalue(const netsnmp_variable_list *var); + + NETSNMP_IMPORT + int netsnmp_check_vb_rowstatus_value(const netsnmp_variable_list *var); + NETSNMP_IMPORT + int netsnmp_check_vb_rowstatus(const netsnmp_variable_list *var, int old_val); + int netsnmp_check_vb_rowstatus_with_storagetype(const netsnmp_variable_list *var, int old_val, int old_storage); + + int netsnmp_check_vb_storagetype(const netsnmp_variable_list *var, int old_val); + + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_CHECK_VARBIND_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/container.h b/illumos-x86_64/usr/include/net-snmp/library/container.h new file mode 100644 index 00000000..af803607 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/container.h @@ -0,0 +1,553 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright (C) 2007 Apple, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#ifndef NETSNMP_CONTAINER_H +#define NETSNMP_CONTAINER_H + +/* + * $Id$ + * + * WARNING: This is a recently created file, and all of it's contents are + * subject to change at any time. + * + * A basic container template. A generic way for code to store and + * retrieve data. Allows for interchangable storage algorithms. + */ +#ifndef NET_SNMP_CONFIG_H +#error "Please include before this file" +#endif + +#include /* free() */ +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + /************************************************************************* + * + * function pointer definitions + * + *************************************************************************/ + struct netsnmp_container_s; /** forward declare */ + struct netsnmp_factory_s; /** forward declare */ + struct netsnmp_iterator_s; /** forward declare */ + + /* + * function for performing an operation on a container which + * returns (maybe the same) container. + */ + typedef struct netsnmp_container_s* (netsnmp_container_mod_op) + (struct netsnmp_container_s *, void *context, u_int flags); + + /* + * function for setting an option on a container + */ + typedef int (netsnmp_container_option)(struct netsnmp_container_s *, + int set, u_int flags); + + /* + * function returning an int for an operation on a container + */ + typedef int (netsnmp_container_rc)(struct netsnmp_container_s *); + + /* + * function returning an iterator for a container + */ + typedef struct netsnmp_iterator_s * (netsnmp_container_it) + (struct netsnmp_container_s *); + + /* + * function returning a size_t for an operation on a container + */ + typedef size_t (netsnmp_container_size)(struct netsnmp_container_s *); + + /* + * function returning an int for an operation on an object and + * a container + */ + typedef int (netsnmp_container_op)(struct netsnmp_container_s *, + const void *data); + + /* + * function returning an int for an operation on an object at a given + * position in a container (for containers supporting direct access) + */ + typedef int (netsnmp_container_da_op)(struct netsnmp_container_s *, + size_t pos, void *data); + + /* + * function returning an int and an object at a given position in a + * container (for containers supporting direct access) + */ + typedef int (netsnmp_container_da_op_rtn)(struct netsnmp_container_s *, + size_t pos, + void **data); + + /* + * function returning an oject for an operation on an object and a + * container + */ + typedef void * (netsnmp_container_rtn)(struct netsnmp_container_s *, + const void *data); + + /* + * function with no return which acts on an object + */ + typedef void (netsnmp_container_obj_func)(void *data, void *context); + + /* + * function with no return which calls a function on an object + */ + typedef void (netsnmp_container_func)(struct netsnmp_container_s *, + netsnmp_container_obj_func *, + void *context); + + /* + * function returning an array of objects for an operation on an + * ojbect and a container + */ + typedef netsnmp_void_array * (netsnmp_container_set) + (struct netsnmp_container_s *, void *data); + + /* + * function returning an int for a comparison between two objects + */ + typedef int (netsnmp_container_compare)(const void *lhs, + const void *rhs); + + /************************************************************************* + * + * Basic container + * + *************************************************************************/ + typedef struct netsnmp_container_s { + + /* + * pointer for container implementation + */ + void * container_data; + + /* + * returns the number of items in a container + */ + netsnmp_container_size *get_size; + + /* + * initialize a container + */ + netsnmp_container_rc *init; + + /* + * release memory used by a container. + * + * Note: if your data structures contained allocated + * memory, you are responsible for releasing that + * memory before calling this function! + */ + netsnmp_container_rc *cfree; + + /* + * add an entry to the container + */ + netsnmp_container_op *insert; + + /* + * add an entry to the container at a given position + */ + netsnmp_container_da_op *insert_before; + netsnmp_container_da_op *insert_after; + + /* + * remove an entry from the container + */ + netsnmp_container_op *remove; + + /* + * remove an entry from the container at a given position + */ + netsnmp_container_da_op_rtn *remove_at; + + /* + * release memory for an entry from the container + */ + netsnmp_container_op *release; /* NOTE: deprecated. Use free_item */ + netsnmp_container_obj_func *free_item; + + /* + * find the entry in the container with the same key + * + * Note: do not change the key! If you need to + * change a key, remove the entry, change the key, + * and the re-add the entry. + */ + netsnmp_container_rtn *find; + + /* + * find the entry in the container with the next highest key + * + * If the key is NULL, return the first item in the container. + */ + netsnmp_container_rtn *find_next; + + /* + * get entry at the given index (for containers supporting direct access + */ + netsnmp_container_da_op_rtn *get_at; + + /* + * find all entries in the container which match the partial key + * returns allocated memory (netsnmp_void_array). User is responsible + * for releasing this memory (free(array->array), free(array)). + * DO NOT FREE ELEMENTS OF THE ARRAY, because they are the same pointers + * stored in the container. + */ + netsnmp_container_set *get_subset; + + /* + * function to return an iterator for the container + */ + netsnmp_container_it *get_iterator; + + /* + * function to call another function for each object in the container + */ + netsnmp_container_func *for_each; + + /* + * specialized version of for_each used to optimize cleanup. + * clear the container, optionally calling a function for each item. + */ + netsnmp_container_func *clear; + + /* + * OPTIONAL function to filter inserts to the container + * (intended for a secondary container, which only wants + * a sub-set of the objects in the primary/parent container) + * Returns: + * 1 : filter matched (don't insert) + * 0 : no match (insert) + */ + netsnmp_container_op *insert_filter; + + /* + * OPTIONAL function to duplicate a container. Defaults to a shallow + * copy. Only the specified container is copied (i.e. sub-containers + * not included). + */ + netsnmp_container_mod_op *duplicate; + + + /* + * function to compare two object stored in the container. + * + * Returns: + * + * -1 LHS < RHS + * 0 LHS = RHS + * 1 LHS > RHS + */ + netsnmp_container_compare *compare; + + /* + * same as compare, but RHS will be a partial key + */ + netsnmp_container_compare *ncompare; + + /* + * function to set container options + */ + netsnmp_container_option *options; + + /* + * unique name for finding a particular container in a list + */ + char *container_name; + + /* + * sort count, for iterators to track (insert/delete + * bumps counter, invalidates iterator) + */ + u_long sync; + + /* + * flags + */ + u_int flags; + + /* + * containers can contain other containers (additional indexes) + */ + struct netsnmp_container_s *next, *prev; + + } netsnmp_container; + + /* + * initialize/free a container of container factories. used by + * netsnmp_container_find* functions. + */ + NETSNMP_IMPORT + void netsnmp_container_init_list(void); + NETSNMP_IMPORT + void netsnmp_container_free_list(void); + + /* + * register a new container factory + */ + int netsnmp_container_register_with_compare(const char* name, + struct netsnmp_factory_s *f, + netsnmp_container_compare *c); + int netsnmp_container_register(const char* name, struct netsnmp_factory_s *f); + + /* + * search for and create a container from a list of types or a + * specific type. + */ + NETSNMP_IMPORT + netsnmp_container * netsnmp_container_find(const char *type_list); + netsnmp_container * netsnmp_container_get(const char *type); + + /* + * utility routines + */ + NETSNMP_IMPORT + void netsnmp_container_add_index(netsnmp_container *primary, + netsnmp_container *new_index); + + + struct netsnmp_factory_s *netsnmp_container_get_factory(const char *type); + + /* + * common comparison routines + */ + /** first data element is a 'netsnmp_index' */ + NETSNMP_IMPORT + int netsnmp_compare_netsnmp_index(const void *lhs, const void *rhs); + NETSNMP_IMPORT + int netsnmp_ncompare_netsnmp_index(const void *lhs, const void *rhs); + + /** first data element is a 'char *' */ + int netsnmp_compare_cstring(const void * lhs, const void * rhs); + int netsnmp_ncompare_cstring(const void * lhs, const void * rhs); + + /** useful for octet strings */ + NETSNMP_IMPORT + int netsnmp_compare_mem(const char * lhs, size_t lhs_len, + const char * rhs, size_t rhs_len); + + /** no structure, just 'char *' pointers */ + int netsnmp_compare_direct_cstring(const void * lhs, const void * rhs); + + int netsnmp_compare_long(const void * lhs, const void * rhs); + int netsnmp_compare_ulong(const void * lhs, const void * rhs); + int netsnmp_compare_int32(const void * lhs, const void * rhs); + int netsnmp_compare_uint32(const void * lhs, const void * rhs); + + /** for_each callback to call free on data item */ + NETSNMP_IMPORT + void netsnmp_container_simple_free(void *data, void *context); + +/* + * container optionflags + */ +#define CONTAINER_KEY_ALLOW_DUPLICATES 0x00000001 +#define CONTAINER_KEY_UNSORTED 0x00000002 + /* ... */ +#define CONTAINER_FLAG_INTERNAL_1 0x80000000 + +#define CONTAINER_SET_OPTIONS(x,o,rc) do { \ + if (NULL==(x)->options) \ + rc = -1; \ + else { \ + rc = (x)->options(x, 1, o); \ + if (rc != -1 ) \ + (x)->flags |= o; \ + } \ + } while(0) + +#define CONTAINER_CHECK_OPTION(x,o,rc) do { \ + rc = x->flags & 0; \ + } while(0) + + + /* + * useful macros (x = container; k = key; c = user context) + */ +#define CONTAINER_FIRST(x) (x)->find_next(x,NULL) +#define CONTAINER_FIND(x,k) (x)->find(x,k) +#define CONTAINER_NEXT(x,k) (x)->find_next(x,k) +/* + * GET_SUBSET returns allocated memory (netsnmp_void_array). User is responsible + * for releasing this memory (free(array->array), free(array)). + * DO NOT FREE ELEMENTS OF THE ARRAY, because they are the same pointers + * stored in the container. + */ +#define CONTAINER_GET_SUBSET(x,k) (x)->get_subset(x,k) +#define CONTAINER_SIZE(x) (x)->get_size(x) +#define CONTAINER_ITERATOR(x) (x)->get_iterator(x) +#define CONTAINER_COMPARE(x,l,r) (x)->compare(l,r) +#define CONTAINER_FOR_EACH(x,f,c) (x)->for_each(x,f,c) + + /* + * insert k into all containers + */ + NETSNMP_IMPORT + int CONTAINER_INSERT(netsnmp_container *x, const void *k); + + /* + * insert item before given position + */ + NETSNMP_IMPORT + int CONTAINER_INSERT_BEFORE(netsnmp_container *x, size_t pos, void *k); + + /* + * remove k from all containers + */ + NETSNMP_IMPORT + int CONTAINER_REMOVE(netsnmp_container *x, const void *k); + + /* + * remove item at given position + */ + NETSNMP_IMPORT + int CONTAINER_REMOVE_AT(netsnmp_container *x, size_t pos, void **k); + + /* + * get item at given position + */ + NETSNMP_IMPORT + int CONTAINER_GET_AT(netsnmp_container *x, size_t pos, void **k); + + /* + * duplicate container + */ + NETSNMP_IMPORT + netsnmp_container *CONTAINER_DUP(netsnmp_container *x, void *ctx, + u_int flags); + + /* + * clear all containers. When clearing the *first* container, and + * *only* the first container, call the function f for each item. + * After calling this function, all containers should be empty. + */ + NETSNMP_IMPORT + void CONTAINER_CLEAR(netsnmp_container *x, netsnmp_container_obj_func *f, + void *c); + + /* + * clear all containers. When clearing the *first* container, and + * *only* the first container, call the free_item function for each item. + * After calling this function, all containers should be empty. + */ + NETSNMP_IMPORT + void CONTAINER_FREE_ALL(netsnmp_container *x, void *c); + + /* + * free all containers + */ + NETSNMP_IMPORT + int CONTAINER_FREE(netsnmp_container *x); + + NETSNMP_IMPORT + netsnmp_container *SUBCONTAINER_FIND(netsnmp_container *x, + const char* name); + + /* + * INTERNAL utility routines for container implementations + */ + void netsnmp_init_container(netsnmp_container *c, + netsnmp_container_rc *init, + netsnmp_container_rc *cfree, + netsnmp_container_size *size, + netsnmp_container_compare *cmp, + netsnmp_container_op *ins, + netsnmp_container_op *rem, + netsnmp_container_rtn *fnd); + /** Duplicate container meta-data. */ + int netsnmp_container_data_dup(netsnmp_container *dup, + netsnmp_container *c); + + + /************************************************************************* + * + * container iterator + * + *************************************************************************/ + /* + * function returning an int for an operation on an iterator + */ + typedef int (netsnmp_iterator_rc)(struct netsnmp_iterator_s *); + + /* + * function returning an oject for an operation on an iterator + */ + typedef void * (netsnmp_iterator_rtn)(struct netsnmp_iterator_s *); + + + /* + * iterator structure + */ + typedef struct netsnmp_iterator_s { + + netsnmp_container *container; + + /* + * sync from container when iterator created. used to invalidate + * the iterator when the container changes. + */ + u_long sync; + + /* + * reset iterator position to beginning of container. + */ + netsnmp_iterator_rc *reset; + + /* + * release iterator and memory it uses + */ + netsnmp_iterator_rc *release; + + /* + * first, last and current DO NOT advance the iterator + */ + netsnmp_iterator_rtn *first; + netsnmp_iterator_rtn *curr; + netsnmp_iterator_rtn *last; + + netsnmp_iterator_rtn *next; + + /* + * remove will remove the item at the current position, then back up + * the iterator to the previous item. That way next will move to the + * item (the one that replaced the removed item. + */ + netsnmp_iterator_rc *remove; + + } netsnmp_iterator; + + +#define ITERATOR_FIRST(x) x->first(x) +#define ITERATOR_NEXT(x) x->next(x) +#define ITERATOR_LAST(x) x->last(x) +#define ITERATOR_REMOVE(x) x->remove(x) +#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0) + +#ifdef __cplusplus +} +#endif + +#endif /** NETSNMP_CONTAINER_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/container_binary_array.h b/illumos-x86_64/usr/include/net-snmp/library/container_binary_array.h new file mode 100644 index 00000000..e47a8f07 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/container_binary_array.h @@ -0,0 +1,45 @@ +/* + * binary_array.h + * $Id$ + */ + +#ifndef BINARY_ARRAY_H +#define BINARY_ARRAY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + /* + * initialize binary array container. call at startup. + */ + void netsnmp_container_binary_array_init(void); + + /* + * get an container which uses an binary_array for storage + */ + netsnmp_container * netsnmp_container_get_binary_array(void); + + /* + * get a factory for producing binary_array objects + */ + struct netsnmp_factory_s *netsnmp_container_get_binary_array_factory(void); + + + int netsnmp_binary_array_remove(netsnmp_container *c, const void *key, + void **save); + + void netsnmp_binary_array_release(netsnmp_container *c); + + void netsnmp_container_binary_array_init(void); + + int netsnmp_binary_array_options_set(netsnmp_container *c, int set, u_int flags); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/library/container_iterator.h b/illumos-x86_64/usr/include/net-snmp/library/container_iterator.h new file mode 100644 index 00000000..6878292d --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/container_iterator.h @@ -0,0 +1,62 @@ +/** + * @file container_iterator.h + * @addtogroup container_iterator + * @{ + */ +#ifndef _CONTAINER_ITERATOR_HANDLER_H_ +#define _CONTAINER_ITERATOR_HANDLER_H_ + +#include "container.h" + +#ifdef __cplusplus +extern "C" { +#endif + + typedef int (Netsnmp_Iterator_Loop_Key) (void *iterator_ctx, + netsnmp_ref_void* loop_ctx, + netsnmp_ref_void* key); + typedef int (Netsnmp_Iterator_Loop_Data)(void *iterator_ctx, + netsnmp_ref_void* loop_ctx, + netsnmp_ref_void* data); + typedef int (Netsnmp_Iterator_Ctx) (void *iterator_ctx, + netsnmp_ref_void* loop_ctx); + typedef int (Netsnmp_Iterator_Ctx_Dup) (void *iterator_ctx, + netsnmp_ref_void* loop_ctx, + netsnmp_ref_void* dup_ctx, + int reuse); + typedef int (Netsnmp_Iterator_Op) (void *iterator_ctx); + typedef int (Netsnmp_Iterator_Data) (void *iterator_ctx, + const void *data); + + void netsnmp_container_iterator_init(void); + + netsnmp_container* netsnmp_container_iterator_get( + void *iterator_user_ctx, + netsnmp_container_compare * compare, + Netsnmp_Iterator_Loop_Key * get_first, + Netsnmp_Iterator_Loop_Key * get_next, + Netsnmp_Iterator_Loop_Data * get_data, + Netsnmp_Iterator_Ctx_Dup * save_pos, /* iff returning static data */ + Netsnmp_Iterator_Ctx * init_loop_ctx, + Netsnmp_Iterator_Ctx * cleanup_loop_ctx, + Netsnmp_Iterator_Data * free_user_ctx, + int sorted); + + /* + * set up optional callbacks/ + * NOTE: even though the first parameter is a generic netsnmp_container, + * this function should only be called for a container created + * by netsnmp_container_iterator_get. + */ + void + netsnmp_container_iterator_set_data_cb(netsnmp_container *c, + Netsnmp_Iterator_Data * insert_data, + Netsnmp_Iterator_Data * remove_data, + Netsnmp_Iterator_Op * get_size); + +#ifdef __cplusplus +} +#endif + +#endif /* _CONTAINER_ITERATOR_HANDLER_H_ */ +/** @} */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/container_list_ssll.h b/illumos-x86_64/usr/include/net-snmp/library/container_list_ssll.h new file mode 100644 index 00000000..494f2139 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/container_list_ssll.h @@ -0,0 +1,27 @@ +/* + * container_list_sl.h + * $Id$ + * + */ +#ifndef NETSNMP_CONTAINER_SSLL_H +#define NETSNMP_CONTAINER_SSLL_H + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + netsnmp_container *netsnmp_container_get_sorted_singly_linked_list(void); + netsnmp_container *netsnmp_container_get_singly_linked_list(int fifo); + + NETSNMP_IMPORT + void netsnmp_container_ssll_init(void); + + +#ifdef __cplusplus +} +#endif + +#endif /** NETSNMP_CONTAINER_SSLL_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/container_null.h b/illumos-x86_64/usr/include/net-snmp/library/container_null.h new file mode 100644 index 00000000..a55d3422 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/container_null.h @@ -0,0 +1,21 @@ +#ifndef NETSNMP_CONTAINER_NULL_H +#define NETSNMP_CONTAINER_NULL_H + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +netsnmp_container *netsnmp_container_get_null(void); + + NETSNMP_IMPORT + void netsnmp_container_null_init(void); + + +#ifdef __cplusplus +} +#endif + +#endif /** NETSNMP_CONTAINER_NULL_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/data_list.h b/illumos-x86_64/usr/include/net-snmp/library/data_list.h new file mode 100644 index 00000000..e31250e3 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/data_list.h @@ -0,0 +1,111 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +/** + * @file data_list.h + * + * @addtogroup agent + * @addtogroup library + * + * External definitions for functions and variables in netsnmp_data_list.c. + * + * @{ + */ + +#ifndef DATA_LIST_H +#define DATA_LIST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + typedef void (Netsnmp_Free_List_Data) (void *); + typedef int (Netsnmp_Save_List_Data) (char *buf, size_t buf_len, void *); + typedef void * (Netsnmp_Read_List_Data) (char *buf, size_t buf_len); + +/** @struct netsnmp_data_list_s + * used to iterate through lists of data + */ + typedef struct netsnmp_data_list_s { + struct netsnmp_data_list_s *next; + char *name; + /** The pointer to the data passed on. */ + void *data; + /** must know how to free netsnmp_data_list->data */ + Netsnmp_Free_List_Data *free_func; + } netsnmp_data_list; + + typedef struct netsnmp_data_list_saveinfo_s { + netsnmp_data_list **datalist; + const char *type; + const char *token; + Netsnmp_Save_List_Data *data_list_save_ptr; + Netsnmp_Read_List_Data *data_list_read_ptr; + Netsnmp_Free_List_Data *data_list_free_ptr; + } netsnmp_data_list_saveinfo; + + NETSNMP_IMPORT + netsnmp_data_list * + netsnmp_create_data_list(const char *, void *, Netsnmp_Free_List_Data* ); + void netsnmp_data_list_add_node(netsnmp_data_list **head, + netsnmp_data_list *node); + netsnmp_data_list * + netsnmp_data_list_add_data(netsnmp_data_list **head, + const char *name, void *data, + Netsnmp_Free_List_Data * beer); + NETSNMP_IMPORT + void *netsnmp_get_list_data(netsnmp_data_list *head, + const char *node); + NETSNMP_IMPORT + void netsnmp_free_list_data(netsnmp_data_list *head); /* single */ + NETSNMP_IMPORT + void netsnmp_free_all_list_data(netsnmp_data_list *head); /* multiple */ + NETSNMP_IMPORT + int netsnmp_remove_list_node(netsnmp_data_list **realhead, + const char *name); + NETSNMP_IMPORT + netsnmp_data_list * + netsnmp_get_list_node(netsnmp_data_list *head, + const char *name); + + /** depreciated: use netsnmp_data_list_add_node() */ + NETSNMP_IMPORT + void netsnmp_add_list_data(netsnmp_data_list **head, + netsnmp_data_list *node); + + + void + netsnmp_register_save_list(netsnmp_data_list **datalist, + const char *type, const char *token, + Netsnmp_Save_List_Data *data_list_save_ptr, + Netsnmp_Read_List_Data *data_list_read_ptr, + Netsnmp_Free_List_Data *data_list_free_ptr); + int + netsnmp_save_all_data(netsnmp_data_list *head, + const char *type, const char *token, + Netsnmp_Save_List_Data * data_list_save_ptr); + SNMPCallback netsnmp_save_all_data_callback; + void netsnmp_read_data_callback(const char *token, char *line); + + void shutdown_data_list(void); + +#ifdef __cplusplus +} +#endif +#endif +/** @} */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/default_store.h b/illumos-x86_64/usr/include/net-snmp/library/default_store.h new file mode 100644 index 00000000..1b1978e0 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/default_store.h @@ -0,0 +1,294 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +/* + * Note: + * If new default_store entries are added to this header file, + * then remember to run 'perl/default_store/gen' to update the + * corresponding perl interface. + */ +/** + * @file default_store.h: storage space for defaults + * + * @addtogroup default_store + * + * @{ + */ +#ifndef DEFAULT_STORE_H +#define DEFAULT_STORE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NETSNMP_DS_MAX_IDS 3 +#define NETSNMP_DS_MAX_SUBIDS 48 /* needs to be a multiple of 8 */ + + /* + * begin storage definitions + */ +/** + * @def NETSNMP_DS_LIBRARY_ID + * These definitions correspond with the "storid" argument to the API. + */ +#define NETSNMP_DS_LIBRARY_ID 0 +#define NETSNMP_DS_APPLICATION_ID 1 +#define NETSNMP_DS_TOKEN_ID 2 + + /* + * These definitions correspond with the "which" argument to the API, + * when the storeid argument is NETSNMP_DS_LIBRARY_ID + */ + /* + * library booleans + */ +#define NETSNMP_DS_LIB_MIB_ERRORS 0 +#define NETSNMP_DS_LIB_SAVE_MIB_DESCRS 1 +#define NETSNMP_DS_LIB_MIB_COMMENT_TERM 2 +#define NETSNMP_DS_LIB_MIB_PARSE_LABEL 3 +#define NETSNMP_DS_LIB_DUMP_PACKET 4 +#define NETSNMP_DS_LIB_LOG_TIMESTAMP 5 +#define NETSNMP_DS_LIB_DONT_READ_CONFIGS 6 /* don't read normal config files */ +#define NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD NETSNMP_DS_LIB_DONT_READ_CONFIGS +#define NETSNMP_DS_LIB_MIB_REPLACE 7 /* replace objects from latest module */ +#define NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM 8 /* print only numeric enum values */ +#define NETSNMP_DS_LIB_PRINT_NUMERIC_OIDS 9 /* print only numeric enum values */ +#define NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS 10 /* dont print oid indexes specially */ +#define NETSNMP_DS_LIB_ALARM_DONT_USE_SIG 11 /* don't use the alarm() signal */ +#define NETSNMP_DS_LIB_PRINT_FULL_OID 12 /* print fully qualified oids */ +#define NETSNMP_DS_LIB_QUICK_PRINT 13 /* print very brief output for parsing */ +#define NETSNMP_DS_LIB_RANDOM_ACCESS 14 /* random access to oid labels */ +#define NETSNMP_DS_LIB_REGEX_ACCESS 15 /* regex matching to oid labels */ +#define NETSNMP_DS_LIB_DONT_CHECK_RANGE 16 /* don't check values for ranges on send */ +#define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS 17 /* no warn about unknown config tokens */ +#define NETSNMP_DS_LIB_NUMERIC_TIMETICKS 18 /* print timeticks as a number */ +#define NETSNMP_DS_LIB_ESCAPE_QUOTES 19 /* shell escape quote marks in oids */ +#define NETSNMP_DS_LIB_REVERSE_ENCODE 20 /* encode packets from back to front */ +#define NETSNMP_DS_LIB_PRINT_BARE_VALUE 21 /* just print value (not OID = value) */ +#define NETSNMP_DS_LIB_EXTENDED_INDEX 22 /* print extended index format [x1][x2] */ +#define NETSNMP_DS_LIB_PRINT_HEX_TEXT 23 /* print ASCII text along with hex strings */ +#define NETSNMP_DS_LIB_PRINT_UCD_STYLE_OID 24 /* print OID's using the UCD-style prefix suppression */ +#define NETSNMP_DS_LIB_READ_UCD_STYLE_OID 25 /* require top-level OIDs to be prefixed with a dot */ +#define NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG 26 /* have the pre-mib parsing config tokens been processed */ +#define NETSNMP_DS_LIB_HAVE_READ_CONFIG 27 /* have the config tokens been processed */ +#define NETSNMP_DS_LIB_QUICKE_PRINT 28 +#define NETSNMP_DS_LIB_DONT_PRINT_UNITS 29 /* don't print UNITS suffix */ +#define NETSNMP_DS_LIB_NO_DISPLAY_HINT 30 /* don't apply DISPLAY-HINTs */ +#define NETSNMP_DS_LIB_16BIT_IDS 31 /* restrict requestIDs, etc to 16-bit values */ +#define NETSNMP_DS_LIB_DONT_PERSIST_STATE 32 /* don't load config and don't load/save persistent file */ +#define NETSNMP_DS_LIB_2DIGIT_HEX_OUTPUT 33 /* print a leading 0 on hex values <= 'f' */ +#define NETSNMP_DS_LIB_IGNORE_NO_COMMUNITY 34 /* don't complain if no community is specified in the command arguments */ +#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD 35 /* don't load persistent file */ +#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE 36 /* don't save persistent file */ +#define NETSNMP_DS_LIB_APPEND_LOGFILES 37 /* append, don't overwrite, log files */ +#define NETSNMP_DS_LIB_NO_DISCOVERY 38 /* don't support RFC5343 contextEngineID discovery */ +#define NETSNMP_DS_LIB_TSM_USE_PREFIX 39 /* TSM's simple security name mapping */ +#define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */ +#define NETSNMP_DS_LIB_DNSSEC_WARN_ONLY 41 /* tread DNSSEC errors as warnings */ +#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */ +#define NETSNMP_DS_LIB_DISABLE_V1 43 /* disable SNMPv1 */ +#define NETSNMP_DS_LIB_DISABLE_V2c 44 /* disable SNMPv2c */ +#define NETSNMP_DS_LIB_DISABLE_V3 45 /* disable SNMPv3 */ +#define NETSNMP_DS_LIB_FILTER_SOURCE 46 /* filter pkt by source IP */ +#define NETSNMP_DS_LIB_ADD_FORWARDER_INFO 47 /* add info about forwarder to SNMP packets */ +#define NETSNMP_DS_LIB_MAX_BOOL_ID 48 /* match NETSNMP_DS_MAX_SUBIDS */ + + /* + * library integers + */ +#define NETSNMP_DS_LIB_MIB_WARNINGS 0 +#define NETSNMP_DS_LIB_SECLEVEL 1 +#define NETSNMP_DS_LIB_SNMPVERSION 2 +#define NETSNMP_DS_LIB_DEFAULT_PORT 3 +#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT 4 +#define NETSNMP_DS_LIB_PRINT_SUFFIX_ONLY NETSNMP_DS_LIB_OID_OUTPUT_FORMAT +#define NETSNMP_DS_LIB_STRING_OUTPUT_FORMAT 5 +#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH 6 +#define NETSNMP_DS_LIB_SERVERSENDBUF 7 /* send buffer (server) */ +#define NETSNMP_DS_LIB_SERVERRECVBUF 8 /* receive buffer (server) */ +#define NETSNMP_DS_LIB_CLIENTSENDBUF 9 /* send buffer (client) */ +#define NETSNMP_DS_LIB_CLIENTRECVBUF 10 /* receive buffer (client) */ +#define NETSNMP_DS_SSHDOMAIN_SOCK_PERM 11 +#define NETSNMP_DS_SSHDOMAIN_DIR_PERM 12 +#define NETSNMP_DS_SSHDOMAIN_SOCK_USER 12 +#define NETSNMP_DS_SSHDOMAIN_SOCK_GROUP 13 +#define NETSNMP_DS_LIB_TIMEOUT 14 +#define NETSNMP_DS_LIB_RETRIES 15 +#define NETSNMP_DS_LIB_MSG_SEND_MAX 16 /* global max response size */ +#define NETSNMP_DS_LIB_FILTER_TYPE 17 /* 0=NONE, 1=acceptlist, -1=blocklist */ +#define NETSNMP_DS_LIB_MAX_INT_ID 48 /* match NETSNMP_DS_MAX_SUBIDS */ + + /* + * special meanings for the default SNMP version slot (NETSNMP_DS_LIB_SNMPVERSION) + */ +#ifndef NETSNMP_DISABLE_SNMPV1 +#define NETSNMP_DS_SNMP_VERSION_1 128 /* bogus */ +#endif +#ifndef NETSNMP_DISABLE_SNMPV2C +#define NETSNMP_DS_SNMP_VERSION_2c 1 /* real */ +#endif +#define NETSNMP_DS_SNMP_VERSION_3 3 /* real */ + + + /* + * library strings + */ +#define NETSNMP_DS_LIB_SECNAME 0 +#define NETSNMP_DS_LIB_CONTEXT 1 +#define NETSNMP_DS_LIB_PASSPHRASE 2 +#define NETSNMP_DS_LIB_AUTHPASSPHRASE 3 +#define NETSNMP_DS_LIB_PRIVPASSPHRASE 4 +#define NETSNMP_DS_LIB_OPTIONALCONFIG 5 +#define NETSNMP_DS_LIB_APPTYPE 6 +#define NETSNMP_DS_LIB_COMMUNITY 7 +#define NETSNMP_DS_LIB_PERSISTENT_DIR 8 +#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9 +#define NETSNMP_DS_LIB_SECMODEL 10 +#define NETSNMP_DS_LIB_MIBDIRS 11 +#define NETSNMP_DS_LIB_OIDSUFFIX 12 +#define NETSNMP_DS_LIB_OIDPREFIX 13 +#define NETSNMP_DS_LIB_CLIENT_ADDR 14 +#define NETSNMP_DS_LIB_TEMP_FILE_PATTERN 15 +#define NETSNMP_DS_LIB_AUTHMASTERKEY 16 +#define NETSNMP_DS_LIB_PRIVMASTERKEY 17 +#define NETSNMP_DS_LIB_AUTHLOCALIZEDKEY 18 +#define NETSNMP_DS_LIB_PRIVLOCALIZEDKEY 19 +#define NETSNMP_DS_LIB_APPTYPES 20 +#define NETSNMP_DS_LIB_KSM_KEYTAB 21 +#define NETSNMP_DS_LIB_KSM_SERVICE_NAME 22 +#define NETSNMP_DS_LIB_X509_CLIENT_PUB 23 +#define NETSNMP_DS_LIB_X509_SERVER_PUB 24 +#define NETSNMP_DS_LIB_SSHTOSNMP_SOCKET 25 +#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26 +#define NETSNMP_DS_LIB_HOSTNAME 27 +#define NETSNMP_DS_LIB_X509_CRL_FILE 28 +#define NETSNMP_DS_LIB_TLS_ALGORITMS 29 +#define NETSNMP_DS_LIB_TLS_LOCAL_CERT 30 +#define NETSNMP_DS_LIB_TLS_PEER_CERT 31 +#define NETSNMP_DS_LIB_SSH_USERNAME 32 +#define NETSNMP_DS_LIB_SSH_PUBKEY 33 +#define NETSNMP_DS_LIB_SSH_PRIVKEY 34 +#define NETSNMP_DS_LIB_OUTPUT_PRECISION 35 +#define NETSNMP_DS_LIB_MAX_STR_ID 48 /* match NETSNMP_DS_MAX_SUBIDS */ + + /* + * end storage definitions + */ + + /* + * macros for dynamic protocol switches + */ +#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION + +#if defined(NETSNMP_DISABLE_SNMPV1) +#define NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) \ + ((pc_ver) == 0/*SNMP_VERSION_1*/) +#else +#define NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) \ + ((pc_ver) == SNMP_VERSION_1 && \ + netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, \ + NETSNMP_DS_LIB_DISABLE_V1)) +#endif + +#if defined(NETSNMP_DISABLE_SNMPV2C) +#define NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) \ + ((pc_ver) == 1/*SNMP_VERSION_2c*/) +#else +#define NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) \ + ((pc_ver) == SNMP_VERSION_2c && \ + netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, \ + NETSNMP_DS_LIB_DISABLE_V2c)) +#endif + +#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target) do { \ + if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) || \ + NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver)) { \ + DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n")); \ + goto pc_target; \ + } \ + } while(0) + +#define NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver) \ + ((pc_ver == SNMP_VERSION_3) && \ + netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, \ + NETSNMP_DS_LIB_DISABLE_V3)) + +#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target) do { \ + if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) { \ + DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n")); \ + goto pc_target; \ + } \ + } while(0) + +#define NETSNMP_RUNTIME_PROTOCOL_CHECK(pc_ver, pc_target) do { \ + NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target); \ + NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target); \ + } while(0) + +#define NETSNMP_RUNTIME_PROTOCOL_SKIP(pc_ver) \ + (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) || \ + NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) || \ + NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) + +#else /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */ +#define NETSNMP_RUNTIME_PROTOCOL_SKIP(pc_ver) (0) +#define NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) (0) +#define NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) (0) +#define NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver) (0) +#define NETSNMP_RUNTIME_PROTOCOL_CHECK(ver, gt) do { ; } while(0) +#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(ver, gt) do { ; } while(0) +#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(ver, gt) do { ; } while(0) +#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */ + + + NETSNMP_IMPORT + int netsnmp_ds_set_boolean(int storeid, int which, int value); + NETSNMP_IMPORT + int netsnmp_ds_get_boolean(int storeid, int which); + NETSNMP_IMPORT + int netsnmp_ds_toggle_boolean(int storeid, int which); + NETSNMP_IMPORT + int netsnmp_ds_set_int(int storeid, int which, int value); + NETSNMP_IMPORT + int netsnmp_ds_get_int(int storeid, int which); + NETSNMP_IMPORT + int netsnmp_ds_set_string(int storeid, int which, + const char *value); + NETSNMP_IMPORT + char *netsnmp_ds_get_string(int storeid, int which); + NETSNMP_IMPORT + int netsnmp_ds_set_void(int storeid, int which, void *value); + NETSNMP_IMPORT + void *netsnmp_ds_get_void(int storeid, int which); + NETSNMP_IMPORT + int netsnmp_ds_register_config(u_char type, const char *ftype, + const char *token, int storeid, + int which); + NETSNMP_IMPORT + int netsnmp_ds_register_premib(u_char type, const char *ftype, + const char *token, int storeid, + int which); + NETSNMP_IMPORT + int netsnmp_ds_parse_boolean(char *line); + NETSNMP_IMPORT + void netsnmp_ds_shutdown(void); + +#ifdef __cplusplus +} +#endif +#endif /* DEFAULT_STORE_H */ +/** @} */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/dir_utils.h b/illumos-x86_64/usr/include/net-snmp/library/dir_utils.h new file mode 100644 index 00000000..471bb0b2 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/dir_utils.h @@ -0,0 +1,63 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright (C) 2007 Apple, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#ifndef NETSNMP_DIR_UTILS_H +#define NETSNMP_DIR_UTILS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * filter function; return 1 to include file, 0 to exclude + */ +#define NETSNMP_DIR_EXCLUDE 0 +#define NETSNMP_DIR_INCLUDE 1 + typedef int (netsnmp_directory_filter)(const void *text, void *ctx); + + + /*------------------------------------------------------------------ + * + * Prototypes + */ + netsnmp_container * + netsnmp_directory_container_read_some(netsnmp_container *user_container, + const char *dirname, + netsnmp_directory_filter *filter, + void *filter_ctx, u_int flags); + +#define netsnmp_directory_container_read(c,d,f) \ + netsnmp_directory_container_read_some(c,d,NULL,NULL,f); + + void netsnmp_directory_container_free(netsnmp_container *c); + + + + /*------------------------------------------------------------------ + * + * flags + */ +#define NETSNMP_DIR_RECURSE 0x0001 +#define NETSNMP_DIR_RELATIVE_PATH 0x0002 +#define NETSNMP_DIR_SORTED 0x0004 +/** don't return null if dir empty */ +#define NETSNMP_DIR_EMPTY_OK 0x0008 +/** store netsnmp_file instead of filenames */ +#define NETSNMP_DIR_NSFILE 0x0010 +/** load stats in netsnmp_file */ +#define NETSNMP_DIR_NSFILE_STATS 0x0020 + + + +#ifdef __cplusplus +} +#endif + +#endif /* NETSNMP_DIR_UTILS_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/fd_event_manager.h b/illumos-x86_64/usr/include/net-snmp/library/fd_event_manager.h new file mode 100644 index 00000000..ede67b4e --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/fd_event_manager.h @@ -0,0 +1,134 @@ +/************************************************************************** + * UNIT: File Descriptor (FD) Event Manager + * + * OVERVIEW: This unit contains functions to register a FD with the FD + * event manager for callbacks when activity is received on that + * FD. Notification of read, write, and exception activity can + * all be registered for individually. Once a registered FD is + * closed by the user, the FD must be unregistered. To use + * the FD Event manager you need to make calls to + * netsnmp_external_event_info() and + * netsnmp_dispatch_external_events() in your event loop to receive + * callbacks for registered events. See snmpd.c and snmptrapd.c + * for examples. + * + * LIMITATIONS: + **************************************************************************/ +#ifndef FD_EVENT_MANAGER_H +#define FD_EVENT_MANAGER_H + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define NUM_EXTERNAL_FDS 32 +#define FD_REGISTERED_OK 0 +#define FD_REGISTRATION_FAILED -2 +#define FD_UNREGISTERED_OK 0 +#define FD_NO_SUCH_REGISTRATION -1 + +/* Since the inception of netsnmp_external_event_info and + * netsnmp_dispatch_external_events, there is no longer a need for the data + * below to be globally visible. We will leave it global for now for + * compatibility purposes. */ +extern int external_readfd[NUM_EXTERNAL_FDS], external_readfdlen; +extern int external_writefd[NUM_EXTERNAL_FDS], external_writefdlen; +extern int external_exceptfd[NUM_EXTERNAL_FDS], external_exceptfdlen; + +extern void (*external_readfdfunc[NUM_EXTERNAL_FDS]) (int, void *); +extern void (*external_writefdfunc[NUM_EXTERNAL_FDS]) (int, void *); +extern void (*external_exceptfdfunc[NUM_EXTERNAL_FDS]) (int, void *); + +extern void *external_readfd_data[NUM_EXTERNAL_FDS]; +extern void *external_writefd_data[NUM_EXTERNAL_FDS]; +extern void *external_exceptfd_data[NUM_EXTERNAL_FDS]; + +/* Here are the key functions of this unit. Use register_xfd to register + * a callback to be called when there is x activity on the register fd. + * x can be read, write, or except (for exception). When registering, + * you can pass in a pointer to some data that you have allocated that + * you would like to have back when the callback is called. */ +int register_readfd(int, void (*func)(int, void *), void *); +int register_writefd(int, void (*func)(int, void *), void *); +int register_exceptfd(int, void (*func)(int, void *), void *); + +/* Unregisters a given fd for events */ +int unregister_readfd(int); +int unregister_writefd(int); +int unregister_exceptfd(int); + +/* + * External Event Info + * + * Description: + * Call this function to add an external event fds to your read, write, + * exception fds that your application already has. When this function + * returns, your fd_sets will be ready for select(). It returns the + * biggest fd in the fd_sets so far. + * + * Input Parameters: None + * + * Output Parameters: None + * + * In/Out Parameters: + * numfds - The biggest fd so far. On exit to this function, numfds + * could of changed since we pass out the new biggest fd. + * readfds - Set of read FDs that we are monitoring. This function + * can modify this set to have more FDs that we are monitoring. + * writefds - Set of write FDs that we are monitoring. This function + * can modify this set to have more FDs that we are monitoring. + * exceptfds - Set of exception FDs that we are monitoring. This function + * can modify this set to have more FDs that we are monitoring. + * + * Return Value: None + * + * Side Effects: None + */ +NETSNMP_IMPORT +void netsnmp_external_event_info(int *numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds); + +NETSNMP_IMPORT +void netsnmp_external_event_info2(int *numfds, + netsnmp_large_fd_set *readfds, + netsnmp_large_fd_set *writefds, + netsnmp_large_fd_set *exceptfds); + +/* + * Dispatch External Events + * + * Description: + * Call this function after select returns with pending events. If any of + * them were NETSNMP external events, the registered callback will be called. + * The corresponding fd_set will have the FD cleared after the event is + * dispatched. + * + * Input Parameters: None + * + * Output Parameters: None + * + * In/Out Parameters: + * count - Number of FDs that have activity. In this function, we decrement + * count as we dispatch an event. + * readfds - Set of read FDs that have activity + * writefds - Set of write FDs that have activity + * exceptfds - Set of exception FDs that have activity + * + * Return Value: None + * + * Side Effects: None + */ +NETSNMP_IMPORT +void netsnmp_dispatch_external_events(int *count, fd_set *readfds, fd_set *writefds, fd_set *exceptfds); +NETSNMP_IMPORT +void netsnmp_dispatch_external_events2(int *count, + netsnmp_large_fd_set *readfds, + netsnmp_large_fd_set *writefds, + netsnmp_large_fd_set *exceptfds); +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/library/file_utils.h b/illumos-x86_64/usr/include/net-snmp/library/file_utils.h new file mode 100644 index 00000000..9f5cdce9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/file_utils.h @@ -0,0 +1,88 @@ +#ifndef NETSNMP_FILE_UTILS_H +#define NETSNMP_FILE_UTILS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /*------------------------------------------------------------------ + * + * structures + * + */ + typedef struct netsnmp_file_s { + + /** file name */ + char *name; + + /** file descriptor for the file */ + int fd; + + /** filesystem flags */ + int fs_flags; + + /** open/create mode */ + mode_t mode; + + /** netsnmp flags */ + u_int ns_flags; + + /** file stats */ + struct stat *stats; + + /* + * future expansion + */ + netsnmp_data_list *extras; + + } netsnmp_file; + + + + /*------------------------------------------------------------------ + * + * Prototypes + * + */ + netsnmp_file *netsnmp_file_new(const char *name, int fs_flags, mode_t mode, + u_int ns_flags); + + netsnmp_file * netsnmp_file_create(void); + netsnmp_file * netsnmp_file_fill(netsnmp_file * filei, const char* name, + int fs_flags, mode_t mode, u_int ns_flags); + int netsnmp_file_release(netsnmp_file * filei); + + int netsnmp_file_open(netsnmp_file * filei); + int netsnmp_file_close(netsnmp_file * filei); + + /** support netsnmp_file containers */ + int netsnmp_file_compare_name(netsnmp_file *lhs, netsnmp_file *rhs); + void netsnmp_file_container_free(netsnmp_file *file, void *context); + + + + /*------------------------------------------------------------------ + * + * flags + * + */ +#define NETSNMP_FILE_NO_AUTOCLOSE 0x00000001 +#define NETSNMP_FILE_STATS 0x00000002 +#define NETSNMP_FILE_AUTO_OPEN 0x00000004 + + /*------------------------------------------------------------------ + * + * macros + * + */ +#define NS_FI_AUTOCLOSE(x) (0 == (x & NETSNMP_FILE_NO_AUTOCLOSE)) +#define NS_FI_(x) (0 == (x & NETSNMP_FILE_)) + + + +#ifdef __cplusplus +} +#endif + +#endif /* NETSNMP_FILE_UTILS_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/getopt.h b/illumos-x86_64/usr/include/net-snmp/library/getopt.h new file mode 100644 index 00000000..f70ffe46 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/getopt.h @@ -0,0 +1,24 @@ +#ifndef _GETOPT_H_ +#define _GETOPT_H_ 1 + +#ifndef NET_SNMP_CONFIG_H +#error must be included before . +#endif + +#if !defined(HAVE_GETOPT_H) + +#ifdef __cplusplus +extern "C" { +#endif + +NETSNMP_IMPORT int getopt(int, char *const *, const char *); +NETSNMP_IMPORT char *optarg; +NETSNMP_IMPORT int optind, opterr, optopt, optreset; + +#ifdef __cplusplus +} +#endif + +#endif /* HAVE_GETOPT_H */ + +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/library/int64.h b/illumos-x86_64/usr/include/net-snmp/library/int64.h new file mode 100644 index 00000000..69e5b5d9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/int64.h @@ -0,0 +1,55 @@ +#ifndef INT64_INCLUDED +#define INT64_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NETSNMP_REMOVE_U64 + /* + * Note: using the U64 typedef is deprecated because this typedef conflicts + * with a typedef with the same name defined in the Perl header files. + */ + typedef struct counter64 U64; +#endif + +#define I64CHARSZ 21 + + void divBy10(struct counter64, struct counter64 *, + unsigned int *); + void multBy10(struct counter64, struct counter64 *); + void incrByU16(struct counter64 *, unsigned int); + void incrByU32(struct counter64 *, unsigned int); + NETSNMP_IMPORT + void zeroU64(struct counter64 *); + int isZeroU64(const struct counter64 *); + NETSNMP_IMPORT + void printU64(char *, const struct counter64 *); + NETSNMP_IMPORT + void printI64(char *, const struct counter64 *); + int read64(struct counter64 *, const char *); + NETSNMP_IMPORT + void u64Subtract(const struct counter64 *pu64one, + const struct counter64 *pu64two, + struct counter64 *pu64out); + void u64Incr(struct counter64 *pu64out, + const struct counter64 *pu64one); + void u64UpdateCounter(struct counter64 *pu64out, + const struct counter64 *pu64one, + const struct counter64 *pu64two); + void u64Copy(struct counter64 *pu64one, + const struct counter64 *pu64two); + + int netsnmp_c64_check_for_32bit_wrap(const struct counter64 *old_val, + struct counter64 *new_val, + int adjust); + NETSNMP_IMPORT + int netsnmp_c64_check32_and_update(struct counter64 *prev_val, + struct counter64 *new_val, + const struct counter64 *old_prev_val, + int *need_wrap_check); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/library/keytools.h b/illumos-x86_64/usr/include/net-snmp/library/keytools.h new file mode 100644 index 00000000..7b3ddcd9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/keytools.h @@ -0,0 +1,70 @@ +/* + * keytools.h + */ + +#ifndef _KEYTOOLS_H +#define _KEYTOOLS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#define USM_LENGTH_EXPANDED_PASSPHRASE (1024 * 1024) /* 1Meg. */ + +#define USM_LENGTH_KU_HASHBLOCK 64 /* In bytes. */ + +#define USM_LENGTH_P_MIN 8 /* In characters. */ + /* + * Recommended practice given in , + * * Section 11.2 "Defining Users". Move into cmdline app argument + * * parsing, and out of the internal routine? XXX + */ + + /* + * Prototypes.h + */ + NETSNMP_IMPORT + int generate_Ku(const oid * hashtype, u_int hashtype_len, + const u_char * P, size_t pplen, + u_char * Ku, size_t * kulen); + + NETSNMP_IMPORT + int generate_kul(const oid * hashtype, u_int hashtype_len, + const u_char * engineID, size_t engineID_len, + const u_char * Ku, size_t ku_len, + u_char * Kul, size_t * kul_len); + + NETSNMP_IMPORT + int netsnmp_extend_kul(u_int needKeyLen, oid *hashoid, u_int hashoid_len, + int privType, u_char *engineID, u_int engineIDLen, + u_char **kulBuf, size_t *kulBufLen, + u_int kulBufSize); + + NETSNMP_IMPORT + int encode_keychange(const oid * hashtype, + u_int hashtype_len, u_char * oldkey, + size_t oldkey_len, u_char * newkey, + size_t newkey_len, u_char * kcstring, + size_t * kcstring_len); + + NETSNMP_IMPORT + int decode_keychange(const oid *hashtype, u_int hashtype_len, + const u_char *oldkey, size_t oldkey_len, + const u_char *kcstring, + size_t kcstring_len, u_char *newkey, + size_t *newkey_len); + + + /* + * All functions devolve to the following block if we can't do cryptography + */ +#define _KEYTOOLS_NOT_AVAILABLE \ +{ \ + return SNMPERR_KT_NOT_AVAILABLE; \ +} + +#ifdef __cplusplus +} +#endif +#endif /* _KEYTOOLS_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/large_fd_set.h b/illumos-x86_64/usr/include/net-snmp/library/large_fd_set.h new file mode 100644 index 00000000..f9f11950 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/large_fd_set.h @@ -0,0 +1,176 @@ +/** + * @file large_fd_set.h + * + * @brief Macro's and functions for manipulation of large file descriptor sets. + */ + + +#ifndef LARGE_FD_SET_H +#define LARGE_FD_SET_H + + +#include +#include + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#if defined(HAVE_WINSOCK_H) && !defined(_WINSOCKAPI_) && !defined(_WINSOCK_H) +#error or must have been included before this file. +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/** + * Add socket fd to the set *fdset if not yet present. + * Enlarges the set if necessary. + */ +#define NETSNMP_LARGE_FD_SET(fd, fdset) \ + netsnmp_large_fd_setfd(fd, fdset) + +/** + * Remove socket fd from the set *fdset. + * Do nothing if fd is not present in *fdset. + * Do nothing if fd >= fdset->lfs_setsize. + */ +#define NETSNMP_LARGE_FD_CLR(fd, fdset) \ + netsnmp_large_fd_clr(fd, fdset) + +/** + * Test whether set *fdset contains socket fd. + * Evaluates to zero (false) if fd >= fdset->lfs_setsize. + */ +#define NETSNMP_LARGE_FD_ISSET(fd, fdset) \ + netsnmp_large_fd_is_set(fd, fdset) + +#if !defined(cygwin) && defined(HAVE_WINSOCK_H) + +/** + * Number of bytes needed to store a number of file descriptors as a + * struct fd_set. + */ +#define NETSNMP_FD_SET_BYTES(setsize) \ + (sizeof(fd_set) + ((setsize) > FD_SETSIZE ? \ + ((setsize) - FD_SETSIZE) * sizeof(SOCKET) : 0)) + +/** Remove all sockets from the set *fdset. */ +#define NETSNMP_LARGE_FD_ZERO(fdset) \ + do { (fdset)->lfs_setptr->fd_count = 0; } while(0) + + +struct timeval; + + +NETSNMP_IMPORT +void netsnmp_large_fd_setfd( SOCKET fd, netsnmp_large_fd_set *fdset); +NETSNMP_IMPORT +void netsnmp_large_fd_clr( SOCKET fd, netsnmp_large_fd_set *fdset); +NETSNMP_IMPORT +int netsnmp_large_fd_is_set(SOCKET fd, netsnmp_large_fd_set *fdset); + +#else + +/** + * Size of a single element of the array with file descriptor bitmasks. + * + * According to SUSv2, this array must have the name fds_bits. See also + * The Single UNIX Specification, Version 2, <sys/time.h>. + */ +#define NETSNMP_FD_MASK_SIZE sizeof(((fd_set*)0)->fds_bits[0]) + +/** Number of bits in one element of the fd_set.fds_bits array. */ +#define NETSNMP_BITS_PER_FD_MASK (8 * NETSNMP_FD_MASK_SIZE) + +/** Number of elements needed for the fds_bits array. */ +#define NETSNMP_FD_SET_ELEM_COUNT(setsize) \ + (setsize + NETSNMP_BITS_PER_FD_MASK - 1) / NETSNMP_BITS_PER_FD_MASK + +/** + * Number of bytes needed to store a number of file descriptors as a + * struct fd_set. + */ +#define NETSNMP_FD_SET_BYTES(setsize) \ + (sizeof(fd_set) + ((setsize) > FD_SETSIZE ? \ + NETSNMP_FD_SET_ELEM_COUNT((setsize) - FD_SETSIZE) \ + * NETSNMP_FD_MASK_SIZE : 0)) + +/** Remove all file descriptors from the set *fdset. */ +#define NETSNMP_LARGE_FD_ZERO(fdset) \ + do { \ + memset((fdset)->lfs_setptr, 0, \ + NETSNMP_FD_SET_BYTES((fdset)->lfs_setsize)); \ + } while (0) + + +void netsnmp_large_fd_setfd( int fd, netsnmp_large_fd_set *fdset); +void netsnmp_large_fd_clr( int fd, netsnmp_large_fd_set *fdset); +int netsnmp_large_fd_is_set(int fd, netsnmp_large_fd_set *fdset); + +#endif + +/** + * Initialize a netsnmp_large_fd_set structure. + * + * Note: this function only initializes the lfs_setsize and lfs_setptr + * members of netsnmp_large_fd_set, not the file descriptor set itself. + * The file descriptor set must be initialized separately, e.g. via + * NETSNMP_LARGE_FD_CLR(). + */ +NETSNMP_IMPORT +void netsnmp_large_fd_set_init( netsnmp_large_fd_set *fdset, int setsize); + +/** + * Modify the size of a file descriptor set and preserve the first + * min(fdset->lfs_setsize, setsize) file descriptors. + * + * Returns 1 upon success or 0 if memory allocation failed. + */ +int netsnmp_large_fd_set_resize( netsnmp_large_fd_set *fdset, int setsize); + +/** + * Synchronous I/O multiplexing for large file descriptor sets. + * + * On POSIX systems, any file descriptor set with size below numfds will be + * resized before invoking select(). + * + * @see See also select(2) for more information. + */ +NETSNMP_IMPORT +int netsnmp_large_fd_set_select(int numfds, netsnmp_large_fd_set *readfds, + netsnmp_large_fd_set *writefds, + netsnmp_large_fd_set *exceptfds, + struct timeval *timeout); + +/** Deallocate the memory allocated by netsnmp_large_fd_set_init. */ +NETSNMP_IMPORT +void netsnmp_large_fd_set_cleanup(netsnmp_large_fd_set *fdset); + +/** + * Copy an fd_set to a netsnmp_large_fd_set structure. + * + * @note dst must have been initialized before this function is called. + */ +void netsnmp_copy_fd_set_to_large_fd_set(netsnmp_large_fd_set *dst, + const fd_set *src); + +/** + * Copy a netsnmp_large_fd_set structure into an fd_set. + * + * @return 0 upon success, -1 when copying fails because *src is too large to + * fit into *dst. + */ +int netsnmp_copy_large_fd_set_to_fd_set( fd_set *dst, + const netsnmp_large_fd_set *src); + +#ifdef __cplusplus +} +#endif + + +#endif /* LARGE_FD_SET_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/lcd_time.h b/illumos-x86_64/usr/include/net-snmp/library/lcd_time.h new file mode 100644 index 00000000..123dfd1a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/lcd_time.h @@ -0,0 +1,138 @@ +/* + * lcd_time.h + */ + +#ifndef _LCD_TIME_H +#define _LCD_TIME_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * undefine to enable time synchronization only on authenticated packets + */ +#define LCD_TIME_SYNC_OPT 1 + + /* + * Macros and definitions. + */ +#define ETIMELIST_SIZE 23 + + + + typedef struct enginetime_struct { + u_char *engineID; + u_int engineID_len; + + u_int engineTime; + u_int engineBoot; + /* + * Time & boots values received from last authenticated + * * message within the previous time window. + */ + + time_t lastReceivedEngineTime; + /* + * Timestamp made when engineTime/engineBoots was last + * * updated. Measured in seconds. + */ + +#ifdef LCD_TIME_SYNC_OPT + u_int authenticatedFlag; +#endif + struct enginetime_struct *next; + } enginetime , *Enginetime; + + + + + /* + * Macros for streamlined engineID existence checks -- + * + * e is char *engineID, + * e_l is u_int engineID_len. + * + * + * ISENGINEKNOWN(e, e_l) + * Returns: + * TRUE If engineID is recoreded in the EngineID List; + * FALSE Otherwise. + * + * ENSURE_ENGINE_RECORD(e, e_l) + * Adds the given engineID to the EngineID List if it does not exist + * already. engineID is added with a + * tuple of <0,0>. ALWAYS succeeds -- except in case of a + * fatal internal error. + * Returns: + * SNMPERR_SUCCESS On success; + * SNMPERR_GENERR Otherwise. + * + * MAKENEW_ENGINE_RECORD(e, e_l) + * Returns: + * SNMPERR_SUCCESS If engineID already exists in the EngineID List; + * SNMPERR_GENERR Otherwise -and- invokes ENSURE_ENGINE_RECORD() + * to add an entry to the EngineID List. + * + * XXX Requres the following declaration in modules calling ISENGINEKNOWN(): + * static u_int dummy_etime, dummy_eboot; + */ +#define ISENGINEKNOWN(e, e_l) \ + ( (get_enginetime(e, e_l, \ + &dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS) \ + ? TRUE \ + : FALSE ) + +#define ENSURE_ENGINE_RECORD(e, e_l) \ + ( (set_enginetime(e, e_l, 0, 0, FALSE) == SNMPERR_SUCCESS) \ + ? SNMPERR_SUCCESS \ + : SNMPERR_GENERR ) + +#define MAKENEW_ENGINE_RECORD(e, e_l) \ + ( (ISENGINEKNOWN(e, e_l) == TRUE) \ + ? SNMPERR_SUCCESS \ + : (ENSURE_ENGINE_RECORD(e, e_l), SNMPERR_GENERR) ) + + + + /* + * Prototypes. + */ + int get_enginetime(const u_char * engineID, u_int engineID_len, + u_int * engine_boot, + u_int * engine_time, + u_int authenticated); + + int get_enginetime_ex(u_char * engineID, + u_int engineID_len, + u_int * engine_boot, + u_int * engine_time, + u_int * last_engine_time, + u_int authenticated); + + NETSNMP_IMPORT + int set_enginetime(const u_char * engineID, u_int engineID_len, + u_int engine_boot, u_int engine_time, + u_int authenticated); + + + + + + + + Enginetime + search_enginetime_list(const u_char * engineID, u_int engineID_len); + + int hash_engineID(const u_char * engineID, u_int engineID_len); + + void dump_etimelist_entry(Enginetime e, int count); + void dump_etimelist(void); + void free_etimelist(void); + void free_enginetime(unsigned char *engineID, size_t engineID_len); + +#ifdef __cplusplus +} +#endif +#endif /* _LCD_TIME_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/md5.h b/illumos-x86_64/usr/include/net-snmp/library/md5.h new file mode 100644 index 00000000..12b192a0 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/md5.h @@ -0,0 +1,71 @@ +/* + * ** ************************************************************************** + * ** md5.h -- Header file for implementation of MD5 Message Digest Algorithm ** + * ** Updated: 2/13/90 by Ronald L. Rivest ** + * ** (C) 1990 RSA Data Security, Inc. ** + * ** ************************************************************************** + */ + +#ifndef MD5_H +#define MD5_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * MDstruct is the data structure for a message digest computation. + */ + typedef struct { + unsigned int buffer[4]; /* Holds 4-word result of MD computation */ + unsigned char count[8]; /* Number of bits processed so far */ + unsigned int done; /* Nonzero means MD computation finished */ + } MDstruct , *MDptr; + + /* + * MDbegin(MD) + * ** Input: MD -- an MDptr + * ** Initialize the MDstruct prepatory to doing a message digest computation. + */ + NETSNMP_IMPORT void MDbegin(MDptr); + + /* + * MDupdate(MD,X,count) + * ** Input: MD -- an MDptr + * ** X -- a pointer to an array of unsigned characters. + * ** count -- the number of bits of X to use (an unsigned int). + * ** Updates MD using the first ``count'' bits of X. + * ** The array pointed to by X is not modified. + * ** If count is not a multiple of 8, MDupdate uses high bits of last byte. + * ** This is the basic input routine for a user. + * ** The routine terminates the MD computation when count < 512, so + * ** every MD computation should end with one call to MDupdate with a + * ** count less than 512. Zero is OK for a count. + */ + NETSNMP_IMPORT int MDupdate(MDptr, const unsigned char *, unsigned int); + + /* + * MDprint(MD) + * ** Input: MD -- an MDptr + * ** Prints message digest buffer MD as 32 hexadecimal digits. + * ** Order is from low-order byte of buffer[0] to high-order byte of buffer[3]. + * ** Each byte is printed with high-order hexadecimal digit first. + */ + extern void MDprint(MDptr); + + int MDchecksum(const u_char * data, size_t len, u_char * mac, + size_t maclen); + int MDsign(const u_char * data, size_t len, u_char * mac, + size_t maclen, const u_char * secret, + size_t secretlen); + void MDget(MDstruct * MD, u_char * buf, size_t buflen); + + /* + * ** End of md5.h + * ****************************(cut)**************************************** + */ +#ifdef __cplusplus +} +#endif +#endif /* MD5_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/mib.h b/illumos-x86_64/usr/include/net-snmp/library/mib.h new file mode 100644 index 00000000..a90cb182 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/mib.h @@ -0,0 +1,519 @@ +#ifndef MIB_H +#define MIB_H + +#ifdef __cplusplus +extern "C" { +#endif + /* + * mib.h - Definitions for the variables as defined in the MIB + * + * Update: 1998-07-17 + * Added prototypes for print_oid_report* functions. + */ +/*********************************************************** + Copyright 1988, 1989 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ + +#include /* for FILE */ + +#include + +#define NETSNMP_MIB2_OID 1, 3, 6, 1, 2, 1 + +#ifndef NETSNMP_NO_LEGACY_DEFINITIONS +#define MIB NETSNMP_MIB2_OID +#endif + +#define MIB_IFTYPE_OTHER 1 +#define MIB_IFTYPE_REGULAR1822 2 +#define MIB_IFTYPE_HDH1822 3 +#define MIB_IFTYPE_DDNX25 4 +#define MIB_IFTYPE_RFC877X25 5 +#define MIB_IFTYPE_ETHERNETCSMACD 6 +#define MIB_IFTYPE_ISO88023CSMACD 7 +#define MIB_IFTYPE_ISO88024TOKENBUS 8 +#define MIB_IFTYPE_ISO88025TOKENRING 9 +#define MIB_IFTYPE_ISO88026MAN 10 +#define MIB_IFTYPE_STARLAN 11 +#define MIB_IFTYPE_PROTEON10MBIT 12 +#define MIB_IFTYPE_PROTEON80MBIT 13 +#define MIB_IFTYPE_HYPERCHANNEL 14 +#define MIB_IFTYPE_FDDI 15 +#define MIB_IFTYPE_LAPB 16 +#define MIB_IFTYPE_SDLC 17 +#define MIB_IFTYPE_T1CARRIER 18 +#define MIB_IFTYPE_CEPT 19 +#define MIB_IFTYPE_BASICISDN 20 +#define MIB_IFTYPE_PRIMARYISDN 21 +#define MIB_IFTYPE_PROPPOINTTOPOINTSERIAL 22 + +#define MIB_IFSTATUS_UP 1 +#define MIB_IFSTATUS_DOWN 2 +#define MIB_IFSTATUS_TESTING 3 + +#define MIB_FORWARD_GATEWAY 1 +#define MIB_FORWARD_HOST 2 + +#define MIB_IPROUTETYPE_OTHER 1 +#define MIB_IPROUTETYPE_INVALID 2 +#define MIB_IPROUTETYPE_DIRECT 3 +#define MIB_IPROUTETYPE_REMOTE 4 + +#define MIB_IPROUTEPROTO_OTHER 1 +#define MIB_IPROUTEPROTO_LOCAL 2 +#define MIB_IPROUTEPROTO_NETMGMT 3 +#define MIB_IPROUTEPROTO_ICMP 4 +#define MIB_IPROUTEPROTO_EGP 5 +#define MIB_IPROUTEPROTO_GGP 6 +#define MIB_IPROUTEPROTO_HELLO 7 +#define MIB_IPROUTEPROTO_RIP 8 +#define MIB_IPROUTEPROTO_ISIS 9 +#define MIB_IPROUTEPROTO_ESIS 10 +#define MIB_IPROUTEPROTO_CISCOIGRP 11 +#define MIB_IPROUTEPROTO_BBNSPFIGP 12 +#define MIB_IPROUTEPROTO_OIGP 13 + +#define MIB_TCPRTOALG_OTHER 1 +#define MIB_TCPRTOALG_CONSTANT 2 +#define MIB_TCPRTOALG_RSRE 3 +#define MIB_TCPRTOALG_VANJ 4 + +#define MIB_TCPCONNSTATE_CLOSED 1 +#define MIB_TCPCONNSTATE_LISTEN 2 +#define MIB_TCPCONNSTATE_SYNSENT 3 +#define MIB_TCPCONNSTATE_SYNRECEIVED 4 +#define MIB_TCPCONNSTATE_ESTABLISHED 5 +#define MIB_TCPCONNSTATE_FINWAIT1 6 +#define MIB_TCPCONNSTATE_FINWAIT2 7 +#define MIB_TCPCONNSTATE_CLOSEWAIT 8 +#define MIB_TCPCONNSTATE_LASTACK 9 +#define MIB_TCPCONNSTATE_CLOSING 10 +#define MIB_TCPCONNSTATE_TIMEWAIT 11 + +#define MIB_EGPNEIGHSTATE_IDLE 1 +#define MIB_EGPNEIGHSTATE_AQUISITION 2 +#define MIB_EGPNEIGHSTATE_DOWN 3 +#define MIB_EGPNEIGHSTATE_UP 4 +#define MIB_EGPNEIGHSTATE_CEASE 5 + + struct variable_list; + struct enum_list; + + NETSNMP_IMPORT + void print_ascii_dump(FILE *); + void register_mib_handlers(void); + void netsnmp_set_mib_directory(const char *dir); + NETSNMP_IMPORT + char *netsnmp_get_mib_directory(void); + void netsnmp_fixup_mib_directory(void); + int sprint_realloc_description(u_char ** buf, size_t * buf_len, + size_t * out_len, int allow_realloc, + oid * objid, size_t objidlen, int width); + NETSNMP_IMPORT + int get_wild_node(const char *, oid *, size_t *); + NETSNMP_IMPORT + int get_node(const char *, oid *, size_t *); + NETSNMP_IMPORT + struct tree *get_tree(const oid *, size_t, struct tree *); + NETSNMP_IMPORT + struct tree *get_tree_head(void); + void set_function(struct tree *); + + NETSNMP_IMPORT + int parse_one_oid_index(oid ** oidStart, size_t * oidLen, + netsnmp_variable_list * data, + int complete); + NETSNMP_IMPORT + int parse_oid_indexes(oid * oidIndex, size_t oidLen, + netsnmp_variable_list * data); + NETSNMP_IMPORT + int build_oid_noalloc(oid * in, size_t in_len, + size_t * out_len, const oid * prefix, + size_t prefix_len, + netsnmp_variable_list * indexes); + NETSNMP_IMPORT + int build_oid(oid ** out, size_t * out_len, oid * prefix, + size_t prefix_len, + netsnmp_variable_list * indexes); + int build_oid_segment(netsnmp_variable_list * var); + + NETSNMP_IMPORT + int sprint_realloc_variable(u_char ** buf, size_t * buf_len, + size_t * out_len, int allow_realloc, + const oid * objid, size_t objidlen, + const netsnmp_variable_list * variable); + + NETSNMP_IMPORT +#ifndef NETSNMP_DISABLE_MIB_LOADING + struct tree * +#else + void +#endif + netsnmp_sprint_realloc_objid_tree(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + int *buf_overflow, + const oid * objid, + size_t objidlen); + + NETSNMP_IMPORT + void + netsnmp_sprint_realloc_objid(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + int *buf_overflow, + const oid * objid, + size_t objidlen); + + NETSNMP_IMPORT + int sprint_realloc_value(u_char ** buf, size_t * buf_len, + size_t * out_len, int allow_realloc, + const oid * objid, size_t objidlen, + const netsnmp_variable_list * variable); + + NETSNMP_IMPORT + int sprint_realloc_objid(u_char ** buf, size_t * buf_len, + size_t * out_len, int allow_realloc, + const oid * objid, size_t objidlen); + + NETSNMP_IMPORT + int sprint_realloc_by_type(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list * var, + const struct enum_list *enums, + const char *hint, + const char *units); + + NETSNMP_IMPORT + int sprint_realloc_hexstring(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const u_char *, size_t); + + NETSNMP_IMPORT + int sprint_realloc_asciistring(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const u_char * cp, + size_t len); + + int sprint_realloc_octet_string(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, + const char *); + + int sprint_realloc_opaque(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int sprint_realloc_object_identifier(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list + *, const struct enum_list *, + const char *, + const char *); + + int sprint_realloc_timeticks(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int sprint_realloc_hinted_integer(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, long, + const char, const char *, + const char *); + + int sprint_realloc_integer(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int sprint_realloc_uinteger(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int sprint_realloc_gauge(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int sprint_realloc_counter(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int sprint_realloc_networkaddress(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, + const char *); + + int sprint_realloc_ipaddress(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int sprint_realloc_null(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int sprint_realloc_bitstring(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int sprint_realloc_nsapaddress(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int sprint_realloc_counter64(u_char ** buf, + size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int sprint_realloc_badtype(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + +#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + int sprint_realloc_float(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int sprint_realloc_double(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); +#endif + + + int snprint_by_type(char *buf, size_t buf_len, + netsnmp_variable_list * var, + const struct enum_list *enums, + const char *hint, const char *units); + + int snprint_hexstring(char *buf, size_t buf_len, + const u_char *, size_t); + + int snprint_asciistring(char *buf, size_t buf_len, + const u_char * cp, size_t len); + + int snprint_octet_string(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_opaque(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_object_identifier(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int snprint_timeticks(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_hinted_integer(char *buf, size_t buf_len, + long, const char *, + const char *); + + int snprint_integer(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_uinteger(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_gauge(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_counter(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_networkaddress(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, + const char *, const char *); + + int snprint_ipaddress(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_null(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + NETSNMP_IMPORT + int snprint_bitstring(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_nsapaddress(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_counter64(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_badtype(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + +#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + int snprint_float(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + + int snprint_double(char *buf, size_t buf_len, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); +#endif + + NETSNMP_IMPORT + void print_oid_report(FILE *); + NETSNMP_IMPORT + void print_oid_report_enable_labeledoid(void); + NETSNMP_IMPORT + void print_oid_report_enable_oid(void); + NETSNMP_IMPORT + void print_oid_report_enable_suffix(void); + NETSNMP_IMPORT + void print_oid_report_enable_symbolic(void); + NETSNMP_IMPORT + void print_oid_report_enable_mibchildoid(void); + + const char *parse_octet_hint(const char *hint, const char *value, + unsigned char **new_val, int *new_val_len); + + NETSNMP_IMPORT + void clear_tree_flags(struct tree *tp); + + NETSNMP_IMPORT + char *snmp_out_toggle_options(char *); + NETSNMP_IMPORT + char *snmp_out_options(char *, int, char * const *); + NETSNMP_IMPORT + void snmp_out_toggle_options_usage(const char *, FILE *); + NETSNMP_IMPORT + char *snmp_in_toggle_options(char *); + NETSNMP_IMPORT + char *snmp_in_options(char *, int, char * const *); + NETSNMP_IMPORT + void snmp_in_toggle_options_usage(const char *, FILE *); + NETSNMP_IMPORT + u_char mib_to_asn_type(int mib_type); + + + int netsnmp_str2oid(const char *S, oid * O, int L); + char *make_printf_format_string(const char *); + + +#define NETSNMP_STRING_OUTPUT_GUESS 1 +#define NETSNMP_STRING_OUTPUT_ASCII 2 +#define NETSNMP_STRING_OUTPUT_HEX 3 + +#define NETSNMP_OID_OUTPUT_SUFFIX 1 +#define NETSNMP_OID_OUTPUT_MODULE 2 +#define NETSNMP_OID_OUTPUT_FULL 3 +#define NETSNMP_OID_OUTPUT_NUMERIC 4 +#define NETSNMP_OID_OUTPUT_UCD 5 +#define NETSNMP_OID_OUTPUT_NONE 6 +#ifdef __cplusplus +} +#endif +#endif /* MIB_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/mt_support.h b/illumos-x86_64/usr/include/net-snmp/library/mt_support.h new file mode 100644 index 00000000..fd8e57c3 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/mt_support.h @@ -0,0 +1,89 @@ +/* + * mt_support.h - multi-thread resource locking support declarations + */ +/* + * Author: Markku Laukkanen + * Created: 6-Sep-1999 + * History: + * 8-Sep-1999 M. Slifcak method names changed; + * use array of resource locking structures. + */ + +#ifndef MT_SUPPORT_H +#define MT_SUPPORT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Lock group identifiers + */ + +#define MT_LIBRARY_ID 0 +#define MT_APPLICATION_ID 1 +#define MT_TOKEN_ID 2 + +#define MT_MAX_IDS 3 /* one greater than last from above */ +#define MT_MAX_SUBIDS 10 + + +/* + * Lock resource identifiers for library resources + */ + +#define MT_LIB_NONE 0 +#define MT_LIB_SESSION 1 +#define MT_LIB_REQUESTID 2 +#define MT_LIB_MESSAGEID 3 +#define MT_LIB_SESSIONID 4 +#define MT_LIB_TRANSID 5 + +#define MT_LIB_MAXIMUM 6 /* must be one greater than the last one */ + + +#if defined(NETSNMP_REENTRANT) || defined(WIN32) + +#ifdef HAVE_PTHREAD_H +#include +typedef pthread_mutex_t mutex_type; +#ifdef pthread_mutexattr_default +#define MT_MUTEX_INIT_DEFAULT pthread_mutexattr_default +#else +#define MT_MUTEX_INIT_DEFAULT 0 +#endif + +#elif defined(WIN32) || defined(cygwin) + +#include +typedef CRITICAL_SECTION mutex_type; + +#else /* HAVE_PTHREAD_H */ +error "There is no re-entrant support as defined." +#endif /* HAVE_PTHREAD_H */ + + +NETSNMP_IMPORT +int snmp_res_init(void); +NETSNMP_IMPORT +int snmp_res_lock(int groupID, int resourceID); +NETSNMP_IMPORT +int snmp_res_unlock(int groupID, int resourceID); +NETSNMP_IMPORT +int snmp_res_destroy_mutex(int groupID, int resourceID); + +#else /* NETSNMP_REENTRANT */ + +#ifndef WIN32 +#define snmp_res_init() do {} while (0) +#define snmp_res_lock(x,y) do {} while (0) +#define snmp_res_unlock(x,y) do {} while (0) +#define snmp_res_destroy_mutex(x,y) do {} while (0) +#endif /* WIN32 */ + +#endif /* NETSNMP_REENTRANT */ + +#ifdef __cplusplus +} +#endif +#endif /* MT_SUPPORT_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/netsnmp-attribute-format.h b/illumos-x86_64/usr/include/net-snmp/library/netsnmp-attribute-format.h new file mode 100644 index 00000000..8d357b3a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/netsnmp-attribute-format.h @@ -0,0 +1,11 @@ +#ifndef _NETSNMP_ATTRIBUTE_FORMAT_H_ +#define _NETSNMP_ATTRIBUTE_FORMAT_H_ + +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +#define NETSNMP_ATTRIBUTE_FORMAT(type, formatArg, firstArg) +#else +#define NETSNMP_ATTRIBUTE_FORMAT(type, formatArg, firstArg) \ + __attribute__((__format__( __ ## type ## __, formatArg, firstArg ))) +#endif + +#endif /* _NETSNMP_ATTRIBUTE_FORMAT_H_ */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/oid.h b/illumos-x86_64/usr/include/net-snmp/library/oid.h new file mode 100644 index 00000000..05965b99 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/oid.h @@ -0,0 +1,27 @@ +#ifndef NETSNMP_LIBRARY_OID_H +#define NETSNMP_LIBRARY_OID_H + +#if defined(__CYGWIN__) && defined(__LP64__) +/* + * The winExtDLL implementation assumes that the size of an OID component is + * 32 bits. Since on the 64-bit Cygwin environment unsigned long is 64 bits + * wide, use unsigned int instead for oids. See also the definition of + * SnmpVarBindList on MSDN + * (https://msdn.microsoft.com/en-us/library/windows/desktop/aa378929.aspx). + */ +typedef unsigned int oid; +#define MAX_SUBID 0xFFFFFFFFUL +#define NETSNMP_PRIo "" +#else +#ifndef EIGHTBIT_SUBIDS +typedef unsigned long oid; +#define MAX_SUBID 0xFFFFFFFFUL +#define NETSNMP_PRIo "l" +#else +typedef unsigned char oid; +#define MAX_SUBID 0xFF +#define NETSNMP_PRIo "" +#endif +#endif /* __CYGWIN64__ */ + +#endif /* NETSNMP_LIBRARY_OID_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/oid_stash.h b/illumos-x86_64/usr/include/net-snmp/library/oid_stash.h new file mode 100644 index 00000000..290bb405 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/oid_stash.h @@ -0,0 +1,82 @@ +#ifndef OID_STASH_H +#define OID_STASH_H + +/* + * designed to store/retrieve information associated with a given oid. + * Storage is done in an efficient tree manner for fast lookups. + */ + +#define OID_STASH_CHILDREN_SIZE 31 + +#ifdef __cplusplus +extern "C" { +#endif + + struct netsnmp_oid_stash_node_s; + + /* args: buffer, sizeof(buffer), yourdata, stashnode */ + typedef int (NetSNMPStashDump) (char *, size_t, + void *, + struct netsnmp_oid_stash_node_s *); + + typedef void (NetSNMPStashFreeNode) (void *); + + typedef struct netsnmp_oid_stash_node_s { + oid value; + struct netsnmp_oid_stash_node_s **children; /* array of children */ + size_t children_size; + struct netsnmp_oid_stash_node_s *next_sibling; /* cache too small links */ + struct netsnmp_oid_stash_node_s *prev_sibling; + struct netsnmp_oid_stash_node_s *parent; + + void *thedata; + } netsnmp_oid_stash_node; + + typedef struct netsnmp_oid_stash_save_info_s { + const char *token; + netsnmp_oid_stash_node **root; + NetSNMPStashDump *dumpfn; + } netsnmp_oid_stash_save_info; + + NETSNMP_IMPORT + int netsnmp_oid_stash_add_data(netsnmp_oid_stash_node **root, + const oid * lookup, + size_t lookup_len, + void *mydata); + SNMPCallback netsnmp_oid_stash_store_all; + + + netsnmp_oid_stash_node + *netsnmp_oid_stash_get_node(netsnmp_oid_stash_node *root, + const oid * lookup, size_t lookup_len); + NETSNMP_IMPORT + void *netsnmp_oid_stash_get_data(netsnmp_oid_stash_node *root, + const oid * lookup, + size_t lookup_len); + NETSNMP_IMPORT + netsnmp_oid_stash_node * + netsnmp_oid_stash_getnext_node(netsnmp_oid_stash_node *root, + oid * lookup, size_t lookup_len); + + netsnmp_oid_stash_node *netsnmp_oid_stash_create_sized_node(size_t + mysize); + netsnmp_oid_stash_node *netsnmp_oid_stash_create_node(void); /* returns a malloced node */ + + void netsnmp_oid_stash_store(netsnmp_oid_stash_node *root, + const char *tokenname, + NetSNMPStashDump *dumpfn, + oid *curoid, size_t curoid_len); + + /* frees all data in the stash and cleans it out. Sets root = NULL */ + NETSNMP_IMPORT + void netsnmp_oid_stash_free(netsnmp_oid_stash_node **root, + NetSNMPStashFreeNode *freefn); + + + /* a noop function that can be passed to netsnmp_oid_stash_node to + NOT free the data */ + NetSNMPStashFreeNode netsnmp_oid_stash_no_free; +#ifdef __cplusplus +} +#endif +#endif /* OID_STASH_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/parse.h b/illumos-x86_64/usr/include/net-snmp/library/parse.h new file mode 100644 index 00000000..7c33d3f4 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/parse.h @@ -0,0 +1,250 @@ +#ifndef PARSE_H +#define PARSE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + /* + * parse.h + */ +/*********************************************************** + Copyright 1989 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ + +#define NETSNMP_MAXLABEL 64 /* maximum characters in a label */ +#define MAXTOKEN 128 /* maximum characters in a token */ +#define MAXQUOTESTR 4096 /* maximum characters in a quoted string */ + +/* + * MAXLABEL appears to be unused in code, and conflicts with + * . Only define it if requested. This will + * cause problems if local DNSSEC validation is also enabled. + */ +#ifdef UCD_COMPATIBLE +#define MAXLABEL NETSNMP_MAXLABEL +#endif + + struct variable_list; + + /* + * A linked list of tag-value pairs for enumerated integers. + */ + struct enum_list { + struct enum_list *next; + int value; + char *label; + }; + + /* + * A linked list of ranges + */ + struct range_list { + struct range_list *next; + int low, high; + }; + + /* + * A linked list of indexes + */ + struct index_list { + struct index_list *next; + char *ilabel; + char isimplied; + }; + + /* + * A linked list of varbinds + */ + struct varbind_list { + struct varbind_list *next; + char *vblabel; + }; + + /* + * A tree in the format of the tree structure of the MIB. + */ + struct tree { + struct tree *child_list; /* list of children of this node */ + struct tree *next_peer; /* Next node in list of peers */ + struct tree *next; /* Next node in hashed list of names */ + struct tree *parent; + char *label; /* This node's textual name */ + u_long subid; /* This node's integer subidentifier */ + int modid; /* The module containing this node */ + int number_modules; + int *module_list; /* To handle multiple modules */ + int tc_index; /* index into tclist (-1 if NA) */ + int type; /* This node's object type */ + int access; /* This nodes access */ + int status; /* This nodes status */ + struct enum_list *enums; /* (optional) list of enumerated integers */ + struct range_list *ranges; + struct index_list *indexes; + char *augments; + struct varbind_list *varbinds; + char *hint; + char *units; + int (*printomat) (u_char **, size_t *, size_t *, int, + const netsnmp_variable_list *, + const struct enum_list *, const char *, + const char *); + void (*printer) (char *, const netsnmp_variable_list *, const struct enum_list *, const char *, const char *); /* Value printing function */ + char *description; /* description (a quoted string) */ + char *reference; /* references (a quoted string) */ + int reported; /* 1=report started in print_subtree... */ + char *defaultValue; + char *parseErrorString; /* Contains the error string if there are errors in parsing MIBs */ + }; + + /* + * Information held about each MIB module + */ + struct module_import { + char *label; /* The descriptor being imported */ + int modid; /* The module imported from */ + }; + + struct module { + char *name; /* This module's name */ + char *file; /* The file containing the module */ + struct module_import *imports; /* List of descriptors being imported */ + int no_imports; /* The number of such import descriptors */ + /* + * -1 implies the module hasn't been read in yet + */ + int modid; /* The index number of this module */ + struct module *next; /* Linked list pointer */ + }; + + struct module_compatability { + const char *old_module; + const char *new_module; + const char *tag; /* NULL implies unconditional replacement, + * otherwise node identifier or prefix */ + size_t tag_len; /* 0 implies exact match (or unconditional) */ + struct module_compatability *next; /* linked list */ + }; + + + /* + * non-aggregate types for tree end nodes + */ +#define TYPE_OTHER 0 +#define TYPE_OBJID 1 +#define TYPE_OCTETSTR 2 +#define TYPE_INTEGER 3 +#define TYPE_NETADDR 4 +#define TYPE_IPADDR 5 +#define TYPE_COUNTER 6 +#define TYPE_GAUGE 7 +#define TYPE_TIMETICKS 8 +#define TYPE_OPAQUE 9 +#define TYPE_NULL 10 +#define TYPE_COUNTER64 11 +#define TYPE_BITSTRING 12 +#define TYPE_NSAPADDRESS 13 +#define TYPE_UINTEGER 14 +#define TYPE_UNSIGNED32 15 +#define TYPE_INTEGER32 16 + +#define TYPE_SIMPLE_LAST 16 + +#define TYPE_TRAPTYPE 20 +#define TYPE_NOTIFTYPE 21 +#define TYPE_OBJGROUP 22 +#define TYPE_NOTIFGROUP 23 +#define TYPE_MODID 24 +#define TYPE_AGENTCAP 25 +#define TYPE_MODCOMP 26 +#define TYPE_OBJIDENTITY 27 + +#define MIB_ACCESS_READONLY 18 +#define MIB_ACCESS_READWRITE 19 +#define MIB_ACCESS_WRITEONLY 20 +#define MIB_ACCESS_NOACCESS 21 +#define MIB_ACCESS_NOTIFY 67 +#define MIB_ACCESS_CREATE 48 + +#define MIB_STATUS_MANDATORY 23 +#define MIB_STATUS_OPTIONAL 24 +#define MIB_STATUS_OBSOLETE 25 +#define MIB_STATUS_DEPRECATED 39 +#define MIB_STATUS_CURRENT 57 + +#define ANON "anonymous#" +#define ANON_LEN strlen(ANON) + + int netsnmp_unload_module(const char *name); +#ifndef NETSNMP_NO_LEGACY_DEFINITIONS + int unload_module(const char *name); +#endif + void netsnmp_init_mib_internals(void); + void unload_all_mibs(void); + int add_mibfile(const char*, const char*); + int which_module(const char *); + NETSNMP_IMPORT + char *module_name(int, char *); + NETSNMP_IMPORT + void print_subtree(FILE *, struct tree *, int); + NETSNMP_IMPORT + void print_ascii_dump_tree(FILE *, struct tree *, int); + NETSNMP_IMPORT + struct tree *find_tree_node(const char *, int); + NETSNMP_IMPORT + const char *get_tc_descriptor(int); + NETSNMP_IMPORT + const char *get_tc_description(int); + NETSNMP_IMPORT + struct tree *find_best_tree_node(const char *, struct tree *, + u_int *); + /* + * backwards compatability + */ + NETSNMP_IMPORT + struct tree *find_node(const char *, struct tree *); + struct tree *find_node2(const char *, const char *); + NETSNMP_IMPORT + struct module *find_module(int); + void adopt_orphans(void); + NETSNMP_IMPORT + char *snmp_mib_toggle_options(char *options); + NETSNMP_IMPORT + void snmp_mib_toggle_options_usage(const char *lead, + FILE * outf); + NETSNMP_IMPORT + void print_mib(FILE *); + NETSNMP_IMPORT + void print_mib_tree(FILE *, struct tree *, int); + int get_mib_parse_error_count(void); + NETSNMP_IMPORT + int snmp_get_token(FILE * fp, char *token, int maxtlen); + NETSNMP_IMPORT + struct tree *find_best_tree_node(const char *name, + struct tree *tree_top, + u_int * match); + +#ifdef __cplusplus +} +#endif +#endif /* PARSE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/read_config.h b/illumos-x86_64/usr/include/net-snmp/library/read_config.h new file mode 100644 index 00000000..f036c30a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/read_config.h @@ -0,0 +1,161 @@ +/* + * read_config.h: reads configuration files for extensible sections. + * + */ +#ifndef READ_CONFIG_H +#define READ_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define STRINGMAX 1024 + +#define NORMAL_CONFIG 0 +#define PREMIB_CONFIG 1 +#define EITHER_CONFIG 2 + +/* + * Value of 'type' parameter of various snmp_config calls, + * used by Net-SNMP client utilities. + */ +#define NETSNMP_APPLICATION_CONFIG_TYPE "snmpapp" + +#include +#include + + /* + * Defines a set of file types and the parse and free functions + * which process the syntax following a given token in a given file. + */ + struct config_files { + char *fileHeader; /* Label for entire file. */ + struct config_line *start; + struct config_files *next; + }; + + struct config_line { + char *config_token; /* Label for each line parser + * in the given file. */ + void (*parse_line) (const char *, char *); + void (*free_func) (void); + struct config_line *next; + char config_time; /* {NORMAL,PREMIB,EITHER}_CONFIG */ + char *help; + }; + + struct read_config_memory { + char *line; + struct read_config_memory *next; + }; + + + NETSNMP_IMPORT + int netsnmp_config(char *); /* parse a simple line: token=values */ + NETSNMP_IMPORT + void netsnmp_config_remember(char *); /* process later, during snmp_init() */ + void netsnmp_config_process_memories(void); /* run all memories through parser */ + int read_config(const char *, struct config_line *, int); + int read_config_files(int); + NETSNMP_IMPORT + void free_config(void); + NETSNMP_IMPORT + void netsnmp_config_error(const char *, ...) + NETSNMP_ATTRIBUTE_FORMAT(printf, 1, 2); + NETSNMP_IMPORT + void netsnmp_config_warn(const char *, ...) + NETSNMP_ATTRIBUTE_FORMAT(printf, 1, 2); + + NETSNMP_IMPORT + char *skip_white(char *); + NETSNMP_IMPORT + const char *skip_white_const(const char *); + NETSNMP_IMPORT + char *skip_not_white(char *); + NETSNMP_IMPORT + const char *skip_not_white_const(const char *); + NETSNMP_IMPORT + char *skip_token(char *); + NETSNMP_IMPORT + const char *skip_token_const(const char *); + NETSNMP_IMPORT + char *copy_nword(char *, char *, int); + NETSNMP_IMPORT + const char *copy_nword_const(const char *, char *, int); + NETSNMP_IMPORT + char *copy_word(char *, char *); /* do not use */ + NETSNMP_IMPORT + int read_config_with_type(const char *, const char *); + NETSNMP_IMPORT + char *read_config_save_octet_string(char *saveto, + const u_char * str, + size_t len); + NETSNMP_IMPORT + char *read_config_read_octet_string(const char *readfrom, + u_char ** str, + size_t * len); + NETSNMP_IMPORT + const char *read_config_read_octet_string_const(const char *readfrom, + u_char ** str, + size_t * len); + NETSNMP_IMPORT + char *read_config_read_objid(char *readfrom, oid ** objid, + size_t * len); + const char *read_config_read_objid_const(const char *readfrom, + oid ** objid, + size_t * len); + NETSNMP_IMPORT + char *read_config_save_objid(char *saveto, oid * objid, + size_t len); + NETSNMP_IMPORT + char *read_config_read_data(int type, char *readfrom, + void *dataptr, size_t * len); + NETSNMP_IMPORT + char *read_config_read_memory(int type, char *readfrom, + char *dataptr, size_t * len); + NETSNMP_IMPORT + char *read_config_store_data(int type, char *storeto, + void *dataptr, size_t * len); + char *read_config_store_data_prefix(char prefix, int type, + char *storeto, + void *dataptr, size_t len); + int read_config_files_of_type(int when, struct config_files *ctmp); + NETSNMP_IMPORT + void read_config_store(const char *type, const char *line); + NETSNMP_IMPORT + void read_app_config_store(const char *line); + NETSNMP_IMPORT + void snmp_save_persistent(const char *type); + NETSNMP_IMPORT + void snmp_clean_persistent(const char *type); + struct config_line *read_config_get_handlers(const char *type); + + /* + * external memory list handlers + */ + void snmp_config_remember_in_list(char *line, + struct read_config_memory + **mem); + void snmp_config_process_memory_list(struct + read_config_memory + **mem, int, int); + void snmp_config_remember_free_list(struct + read_config_memory + **mem); + + void set_configuration_directory(const char *dir); + NETSNMP_IMPORT + const char *get_configuration_directory(void); + void set_persistent_directory(const char *dir); + const char *get_persistent_directory(void); + void set_temp_file_pattern(const char *pattern); + NETSNMP_IMPORT + const char *get_temp_file_pattern(void); + NETSNMP_IMPORT + void handle_long_opt(const char *myoptarg); + + +#ifdef __cplusplus +} +#endif +#endif /* READ_CONFIG_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/scapi.h b/illumos-x86_64/usr/include/net-snmp/library/scapi.h new file mode 100644 index 00000000..6166560c --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/scapi.h @@ -0,0 +1,210 @@ +/* + * scapi.h + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef _SCAPI_H +#define _SCAPI_H + +#ifdef NETSNMP_USE_OPENSSL +#include /* EVP_MD */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Authentication/privacy transform bitlengths. + */ +#define SNMP_TRANS_AUTHLEN_HMACMD5 128 +#define SNMP_TRANS_AUTHLEN_HMACSHA1 160 +#define SNMP_TRANS_AUTHLEN_HMAC128SHA224 224 /* OPTIONAL */ +#define SNMP_TRANS_AUTHLEN_HMAC192SHA256 256 /* MUST */ +#define SNMP_TRANS_AUTHLEN_HMAC256SHA384 384 /* OPTIONAL */ +#define SNMP_TRANS_AUTHLEN_HMAC384SHA512 512 /* SHOULD */ + +#define SNMP_TRANS_AUTHLEN_HMAC96 96 + +#define SNMP_TRANS_PRIVLEN_1DES 64 +#define SNMP_TRANS_PRIVLEN_1DES_IV 64 + +#ifdef NETSNMP_DRAFT_REEDER_3DES +#define SNMP_TRANS_PRIVLEN_3DESEDE 256 +#define SNMP_TRANS_PRIVLEN_3DESEDE_IV 64 +#endif /* NETSNMP_DRAFT_REEDER_3DES */ + +#define SNMP_TRANS_PRIVLEN_AES 128 +#define SNMP_TRANS_PRIVLEN_AES_IV 128 + +#define SNMP_TRANS_PRIVLEN_AES128 SNMP_TRANS_PRIVLEN_AES +#define SNMP_TRANS_PRIVLEN_AES128_IV SNMP_TRANS_PRIVLEN_AES_IV + +#define SNMP_TRANS_PRIVLEN_AES192 192 +#define SNMP_TRANS_PRIVLEN_AES192_IV 128 /* 192 */ + +#define SNMP_TRANS_PRIVLEN_AES256 256 +#define SNMP_TRANS_PRIVLEN_AES256_IV 128 /* 256 */ + + +typedef struct netsnmp_auth_alg_info_s { + int type; + const char * name; + oid * alg_oid; + int oid_len; + int proper_length; + int mac_length; +} netsnmp_auth_alg_info; + +typedef struct netsnmp_priv_alg_info_s { + int type; + const char * name; + oid * alg_oid; + int oid_len; + int proper_length; + int iv_length; + int pad_size; +#ifdef NETSNMP_USE_OPENSSL + const EVP_CIPHER * cipher; +#endif +} netsnmp_priv_alg_info; + + /* + * Prototypes. + */ + NETSNMP_IMPORT + int sc_get_authtype(const oid * hashoid, u_int hashoid_len); + NETSNMP_IMPORT + int sc_get_proper_auth_length_bytype(int auth_type); + NETSNMP_IMPORT + int sc_get_auth_maclen(int auth_type); + NETSNMP_IMPORT + const char* sc_get_auth_name(int auth_type); + NETSNMP_IMPORT + oid * sc_get_auth_oid(int auth_type, size_t *oid_len); + NETSNMP_IMPORT + const netsnmp_auth_alg_info * + sc_find_auth_alg_byoid(const oid *oid, u_int len); + NETSNMP_IMPORT + const netsnmp_auth_alg_info * + sc_find_auth_alg_bytype(u_int type); + NETSNMP_IMPORT + const netsnmp_auth_alg_info * sc_get_auth_alg_byindex(u_int index); + + /** deprectated, use + * sc_get_authtype() + sc_get_proper_auth_length_bytype() */ + NETSNMP_IMPORT + int sc_get_properlength(const oid * hashtype, + u_int hashtype_len); + +#ifdef NETSNMP_USE_OPENSSL + NETSNMP_IMPORT + const EVP_MD *sc_get_openssl_hashfn(int auth_type); + NETSNMP_IMPORT + const EVP_CIPHER *sc_get_openssl_privfn(int priv_type); +#endif + + NETSNMP_IMPORT + int sc_get_privtype(const oid * privtype, u_int privtype_len); + NETSNMP_IMPORT + oid * sc_get_priv_oid(int type, size_t *oid_len); + NETSNMP_IMPORT + int sc_get_proper_priv_length(const oid * privtype, + u_int privtype_len); + NETSNMP_IMPORT + int sc_get_proper_priv_length_bytype(int privtype); + NETSNMP_IMPORT + const netsnmp_priv_alg_info * + sc_get_priv_alg_byoid(const oid *oid, u_int len); + NETSNMP_IMPORT + const netsnmp_priv_alg_info * sc_get_priv_alg_bytype(u_int type); + NETSNMP_IMPORT + const netsnmp_priv_alg_info * sc_get_priv_alg_byindex(u_int index); + + NETSNMP_IMPORT + int sc_init(void); + NETSNMP_IMPORT + int sc_shutdown(int majorID, int minorID, void *serverarg, + void *clientarg); + + NETSNMP_IMPORT + int sc_random(u_char * buf, size_t * buflen); + + NETSNMP_IMPORT + int sc_generate_keyed_hash(const oid * authtype, + size_t authtypelen, + const u_char * key, u_int keylen, + const u_char * message, u_int msglen, + u_char * MAC, size_t * maclen); + + NETSNMP_IMPORT + int sc_check_keyed_hash(const oid * authtype, + size_t authtypelen, const u_char * key, + u_int keylen, const u_char * message, + u_int msglen, const u_char * MAC, + u_int maclen); + + NETSNMP_IMPORT + int sc_encrypt(const oid * privtype, size_t privtypelen, + u_char * key, u_int keylen, + u_char * iv, u_int ivlen, + const u_char * plaintext, u_int ptlen, + u_char * ciphertext, size_t * ctlen); + + NETSNMP_IMPORT + int sc_decrypt(const oid * privtype, size_t privtypelen, + u_char * key, u_int keylen, + u_char * iv, u_int ivlen, + u_char * ciphertext, u_int ctlen, + u_char * plaintext, size_t * ptlen); + + NETSNMP_IMPORT + int sc_hash_type(int auth_type, const u_char * buf, + size_t buf_len, u_char * MAC, + size_t * MAC_len); + + NETSNMP_IMPORT + int sc_hash(const oid * hashtype, size_t hashtypelen, + const u_char * buf, size_t buf_len, + u_char * MAC, size_t * MAC_len); + + NETSNMP_IMPORT + int sc_get_transform_type(oid * hashtype, + u_int hashtype_len, + int (**hash_fn) (const int mode, + void **context, + const u_char * + data, + const int + data_len, + u_char ** + digest, + size_t * + digest_len)); + + + /* + * All functions devolve to the following block if we can't do cryptography + */ +#define _SCAPI_NOT_CONFIGURED \ +{ \ + snmp_log(LOG_ERR, "Encryption support not enabled.\n"); \ + DEBUGMSGTL(("scapi", "SCAPI not configured")); \ + return SNMPERR_SC_NOT_CONFIGURED; \ +} + + /* + * define a transform type if we're using the internal md5 support + */ +#ifdef NETSNMP_USE_INTERNAL_MD5 +#define INTERNAL_MD5 1 +#endif + +#ifdef __cplusplus +} +#endif +#endif /* _SCAPI_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp-tc.h b/illumos-x86_64/usr/include/net-snmp/library/snmp-tc.h new file mode 100644 index 00000000..a355dd07 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp-tc.h @@ -0,0 +1,66 @@ +#ifndef SNMP_TC_H +#define SNMP_TC_H + +#ifdef __cplusplus +extern "C" { +#endif + /* + * snmp-tc.h: Provide some standard #defines for Textual Convention + * related value information + */ + + int + netsnmp_dateandtime_set_buf_from_vars(u_char *buf, size_t *bufsize, + u_short y, u_char mon, u_char d, + u_char h, u_char min, u_char s, + u_char deci_seconds, + int utc_offset_direction, + u_char utc_offset_hours, + u_char utc_offset_minutes); + + NETSNMP_IMPORT + u_char *date_n_time(const time_t *, size_t *); + time_t ctime_to_timet(const char *); + + /* + * TrueValue + */ +#define TV_TRUE 1 +#define TV_FALSE 2 + + /* + * RowStatus + */ +#define RS_NONEXISTENT 0 +#define RS_ACTIVE 1 +#define RS_NOTINSERVICE 2 +#define RS_NOTREADY 3 +#define RS_CREATEANDGO 4 +#define RS_CREATEANDWAIT 5 +#define RS_DESTROY 6 + +#define RS_IS_GOING_ACTIVE( x ) ( x == RS_CREATEANDGO || x == RS_ACTIVE ) +#define RS_IS_ACTIVE( x ) ( x == RS_ACTIVE ) +#define RS_IS_NOT_ACTIVE( x ) ( ! RS_IS_GOING_ACTIVE(x) ) + + /* + * StorageType + */ +#define ST_NONE 0 +#define ST_OTHER 1 +#define ST_VOLATILE 2 +#define ST_NONVOLATILE 3 +#define ST_PERMANENT 4 +#define ST_READONLY 5 + + NETSNMP_IMPORT + char check_rowstatus_transition(int old_val, int new_val); + NETSNMP_IMPORT + char check_rowstatus_with_storagetype_transition(int old_val, int new_val, int old_storage); + NETSNMP_IMPORT + char check_storage_transition(int old_val, int new_val); + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_TC_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp.h b/illumos-x86_64/usr/include/net-snmp/library/snmp.h new file mode 100644 index 00000000..b2aa5fe4 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp.h @@ -0,0 +1,372 @@ +#ifndef SNMP_H +#define SNMP_H + +#ifdef __cplusplus +extern "C" { +#endif + /* + * Definitions for the Simple Network Management Protocol (RFC 1067). + * + * + */ +/*********************************************************** + Copyright 1988, 1989 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ + +/* + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + */ + + +#define SNMP_PORT 161 /* standard UDP port for SNMP agents + * to receive requests messages */ +#define SNMP_TRAP_PORT 162 /* standard UDP port for SNMP + * managers to receive notificaion + * (trap and inform) messages */ + +#define SNMP_MAX_LEN 1500 /* typical maximum message size */ +#define SNMP_MIN_MAX_LEN 484 /* minimum maximum message size */ +#define SNMP_MAX_PACKET_LEN (0x7fffffff) + + /* + * SNMP versions + */ + /* + * There currently exists the following SNMP versions. + * * (Note that only SNMPv1 is in widespread usage, and this code supports + * * only SNMPv1, SNMPv2c, and SNMPv3. + * * + * * SNMPv1 - (full) the original version, defined by RFC 1157 + * * SNMPsec - (historic) the first attempt to add strong security + * * to SNMPv1, defined by RFCs 1351, 1352, and 1353. + * * SNMPv2p - (historic) party-based SNMP, which was another + * * attempt to add strong security to SNMP, defined + * * by RFCs 1441, 1445, 1446, 1448, and 1449. + * * SNMPv2c - (experimental) community string-based SNMPv2, + * * which was an attempt to combine the protocol + * * operations of SNMPv2 with the security of + * * SNMPv1, defined by RFCs 1901, 1905, and 1906. + * * SNMPv2u - (experimental) user-based SNMPv2, which provided + * * security based on user names and protocol + * * operations of SNMPv2, defined by RFCs 1905, + * * 1909, and 1910. + * * SNMPv2* (or SNMPv2star) - (experimental) an attempt to add the + * * best features of SNMPv2p and SNMPv2u, defined + * * by unpublished documents found at WEB site + * * owned by SNMP Research (a leading SNMP vendor) + * * SNMPv3 - the current attempt by the IETF working group to merge + * * the SNMPv2u and SNMPv2* proposals into a more widly + * * accepted SNMPv3. It is defined by not yet published + * * documents of the IETF SNMPv3 WG. + * * + * * SNMPv1, SNMPv2c, SNMPv2u, and SNMPv3 messages have a common + * * form, which is an ASN.1 sequence containing a message version + * * field, followed by version dependent fields. + * * SNMPsec, SNMPv2p, and SNMPv2* messages have a common form, + * * which is a tagged ASN.1 context specific sequence containing + * * message dependent fields. + * * + * * In the #defines for the message versions below, the value + * * for SNMPv1, SNMPv2c, SNMPv2u, and SNMPv3 messages is the + * * value of the message version field. Since SNMPsec, SNMPv2p, + * * and SNMPv2* messages do not have a message version field, + * * the value in the defines for them is choosen to be a large + * * arbitrary number. + * * + * * Note that many of the version ID's are defined below purely for + * * documentational purposes. At this point the only protocol planned + * * for future implementations is SNMP3, as the other v2 protocols will + * * not be supported by the IETF (ie, v2u, v2sec, v2star) or used by + * * the snmp community at large (at the time of this writing). + */ + + /* + * versions based on version field + */ +#ifndef NETSNMP_DISABLE_SNMPV1 +#define SNMP_VERSION_1 0 +#endif +#ifndef NETSNMP_DISABLE_SNMPV2C +#define SNMP_VERSION_2c 1 +#endif +#define SNMP_VERSION_2u 2 /* not (will never be) supported by this code */ +#define SNMP_VERSION_3 3 + + /* + * versions not based on a version field + */ +#define SNMP_VERSION_sec 128 /* not (will never be) supported by this code */ +#define SNMP_VERSION_2p 129 /* no longer supported by this code (> 4.0) */ +#define SNMP_VERSION_2star 130 /* not (will never be) supported by this code */ + + /* + * PDU types in SNMPv1, SNMPsec, SNMPv2p, SNMPv2c, SNMPv2u, SNMPv2*, and SNMPv3 + */ +#define SNMP_MSG_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */ +#define SNMP_MSG_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */ +#define SNMP_MSG_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */ +#ifndef NETSNMP_NO_WRITE_SUPPORT +#define SNMP_MSG_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */ +#endif /* !NETSNMP_NO_WRITE_SUPPORT */ + + /* + * PDU types in SNMPv1 and SNMPsec + */ +#define SNMP_MSG_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */ + + /* + * PDU types in SNMPv2p, SNMPv2c, SNMPv2u, SNMPv2*, and SNMPv3 + */ +#define SNMP_MSG_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */ +#define SNMP_MSG_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */ +#define SNMP_MSG_TRAP2 (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */ + + /* + * PDU types in SNMPv2u, SNMPv2*, and SNMPv3 + */ +#define SNMP_MSG_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */ + +#ifndef NETSNMP_NO_WRITE_SUPPORT + /* + * internal modes that should never be used by the protocol for the + * pdu type. + * + * All modes < 128 are reserved for SET requests. + */ +#define SNMP_MSG_INTERNAL_SET_BEGIN -1 +#define SNMP_MSG_INTERNAL_SET_RESERVE1 0 /* these should match snmp.h */ +#define SNMP_MSG_INTERNAL_SET_RESERVE2 1 +#define SNMP_MSG_INTERNAL_SET_ACTION 2 +#define SNMP_MSG_INTERNAL_SET_COMMIT 3 +#define SNMP_MSG_INTERNAL_SET_FREE 4 +#define SNMP_MSG_INTERNAL_SET_UNDO 5 +#define SNMP_MSG_INTERNAL_SET_MAX 6 + +#define SNMP_MSG_INTERNAL_CHECK_VALUE 17 +#define SNMP_MSG_INTERNAL_ROW_CREATE 18 +#define SNMP_MSG_INTERNAL_UNDO_SETUP 19 +#define SNMP_MSG_INTERNAL_SET_VALUE 20 +#define SNMP_MSG_INTERNAL_CHECK_CONSISTENCY 21 +#define SNMP_MSG_INTERNAL_UNDO_SET 22 +#define SNMP_MSG_INTERNAL_COMMIT 23 +#define SNMP_MSG_INTERNAL_UNDO_COMMIT 24 +#define SNMP_MSG_INTERNAL_IRREVERSIBLE_COMMIT 25 +#define SNMP_MSG_INTERNAL_UNDO_CLEANUP 26 +#endif /* !NETSNMP_NO_WRITE_SUPPORT */ + + /* + * modes > 128 for non sets. + * Note that 160-168 overlap with SNMP ASN1 pdu types + */ +#define SNMP_MSG_INTERNAL_PRE_REQUEST 128 +#define SNMP_MSG_INTERNAL_OBJECT_LOOKUP 129 +#define SNMP_MSG_INTERNAL_POST_REQUEST 130 +#define SNMP_MSG_INTERNAL_GET_STASH 131 + + /* + * test for member of Confirmed Class i.e., reportable + */ +#ifdef NETSNMP_NO_WRITE_SUPPORT +#define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\ + c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET ) +#else /* !NETSNMP_NO_WRITE_SUPPORT */ +#define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\ + c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET || \ + c == SNMP_MSG_SET ) +#endif /* !NETSNMP_NO_WRITE_SUPPORT */ + + /* + * Exception values for SNMPv2p, SNMPv2c, SNMPv2u, SNMPv2*, and SNMPv3 + */ +#define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */ +#define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */ +#define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */ + + /* + * Error codes (the value of the field error-status in PDUs) + */ + + /* + * in SNMPv1, SNMPsec, SNMPv2p, SNMPv2c, SNMPv2u, SNMPv2*, and SNMPv3 PDUs + */ +#define SNMP_ERR_NOERROR (0) /* XXX Used only for PDUs? */ +#define SNMP_ERR_TOOBIG (1) +#define SNMP_ERR_NOSUCHNAME (2) +#define SNMP_ERR_BADVALUE (3) +#define SNMP_ERR_READONLY (4) +#define SNMP_ERR_GENERR (5) + + /* + * in SNMPv2p, SNMPv2c, SNMPv2u, SNMPv2*, and SNMPv3 PDUs + */ +#define SNMP_ERR_NOACCESS (6) +#define SNMP_ERR_WRONGTYPE (7) +#define SNMP_ERR_WRONGLENGTH (8) +#define SNMP_ERR_WRONGENCODING (9) +#define SNMP_ERR_WRONGVALUE (10) +#define SNMP_ERR_NOCREATION (11) +#define SNMP_ERR_INCONSISTENTVALUE (12) +#define SNMP_ERR_RESOURCEUNAVAILABLE (13) +#define SNMP_ERR_COMMITFAILED (14) +#define SNMP_ERR_UNDOFAILED (15) +#define SNMP_ERR_AUTHORIZATIONERROR (16) +#define SNMP_ERR_NOTWRITABLE (17) + + /* + * in SNMPv2c, SNMPv2u, SNMPv2*, and SNMPv3 PDUs + */ +#define SNMP_ERR_INCONSISTENTNAME (18) + +#define MAX_SNMP_ERR 18 + +#define SNMP_VALIDATE_ERR(x) ( (x > MAX_SNMP_ERR) ? \ + SNMP_ERR_GENERR : \ + (x < SNMP_ERR_NOERROR) ? \ + SNMP_ERR_GENERR : \ + x ) + + /* + * values of the generic-trap field in trap PDUs + */ +#define SNMP_TRAP_COLDSTART (0) +#define SNMP_TRAP_WARMSTART (1) +#define SNMP_TRAP_LINKDOWN (2) +#define SNMP_TRAP_LINKUP (3) +#define SNMP_TRAP_AUTHFAIL (4) +#define SNMP_TRAP_EGPNEIGHBORLOSS (5) +#define SNMP_TRAP_ENTERPRISESPECIFIC (6) + + /* + * row status values + */ +#define SNMP_ROW_NONEXISTENT 0 +#define SNMP_ROW_ACTIVE 1 +#define SNMP_ROW_NOTINSERVICE 2 +#define SNMP_ROW_NOTREADY 3 +#define SNMP_ROW_CREATEANDGO 4 +#define SNMP_ROW_CREATEANDWAIT 5 +#define SNMP_ROW_DESTROY 6 + + /* + * row storage values + */ +#define SNMP_STORAGE_NONE 0 +#define SNMP_STORAGE_OTHER 1 +#define SNMP_STORAGE_VOLATILE 2 +#define SNMP_STORAGE_NONVOLATILE 3 +#define SNMP_STORAGE_PERMANENT 4 +#define SNMP_STORAGE_READONLY 5 + + /* + * message processing models + */ +#define SNMP_MP_MODEL_SNMPv1 0 +#define SNMP_MP_MODEL_SNMPv2c 1 +#define SNMP_MP_MODEL_SNMPv2u 2 +#define SNMP_MP_MODEL_SNMPv3 3 +#define SNMP_MP_MODEL_SNMPv2p 256 + + /* + * security values + */ +#define SNMP_SEC_MODEL_ANY 0 +#define SNMP_SEC_MODEL_SNMPv1 1 +#define SNMP_SEC_MODEL_SNMPv2c 2 +#define SNMP_SEC_MODEL_USM 3 +#define SNMP_SEC_MODEL_TSM 4 +#define SNMP_SEC_MODEL_SNMPv2p 256 + +#define SNMP_SEC_LEVEL_NOAUTH 1 +#define SNMP_SEC_LEVEL_AUTHNOPRIV 2 +#define SNMP_SEC_LEVEL_AUTHPRIV 3 + +#define SNMP_MSG_FLAG_AUTH_BIT 0x01 +#define SNMP_MSG_FLAG_PRIV_BIT 0x02 +#define SNMP_MSG_FLAG_RPRT_BIT 0x04 + + /* + * control PDU handling characteristics + */ +/** NOTE low byte used for AGENTX_MSG_FLAG_* */ +#define UCD_MSG_FLAG_RESPONSE_PDU 0x100 +#define UCD_MSG_FLAG_EXPECT_RESPONSE 0x200 +#define UCD_MSG_FLAG_FORCE_PDU_COPY 0x400 +#define UCD_MSG_FLAG_ALWAYS_IN_VIEW 0x800 +#define UCD_MSG_FLAG_PDU_TIMEOUT 0x1000 +#define UCD_MSG_FLAG_ONE_PASS_ONLY 0x2000 +#define UCD_MSG_FLAG_TUNNELED 0x4000 +#ifdef NETSNMP_USE_REVERSE_ASNENCODING +#define UCD_MSG_FLAG_FORWARD_ENCODE 0x8000 +#endif +#define UCD_MSG_FLAG_BULK_TOOBIG 0x010000 + + /* + * view status + */ +#define SNMP_VIEW_INCLUDED 1 +#define SNMP_VIEW_EXCLUDED 2 + + /* + * basic oid values + */ +#define SNMP_OID_INTERNET 1, 3, 6, 1 +#define SNMP_OID_ENTERPRISES SNMP_OID_INTERNET, 4, 1 +#define SNMP_OID_MIB2 SNMP_OID_INTERNET, 2, 1 +#define SNMP_OID_SNMPV2 SNMP_OID_INTERNET, 6 +#define SNMP_OID_SNMPMODULES SNMP_OID_SNMPV2, 3 + + /* + * lengths as defined by TCs + */ +#define SNMPADMINLENGTH 255 + + + NETSNMP_IMPORT + char *uptime_string(u_long, char *); + char *uptime_string_n(u_long, char *, size_t); + NETSNMP_IMPORT + void xdump(const void *, size_t, const char *); + NETSNMP_IMPORT + u_char *snmp_parse_var_op(u_char *, oid *, size_t *, u_char *, + size_t *, u_char **, size_t *); + NETSNMP_IMPORT + u_char *snmp_build_var_op(u_char *, oid *, size_t *, u_char, + size_t, u_char *, size_t *); + + +#ifdef NETSNMP_USE_REVERSE_ASNENCODING + int snmp_realloc_rbuild_var_op(u_char ** pkt, + size_t * pkt_len, + size_t * offset, + int allow_realloc, + const oid * name, + size_t * name_len, + u_char value_type, + u_char * value, + size_t value_length); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpAliasDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpAliasDomain.h new file mode 100644 index 00000000..ccafcb5c --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpAliasDomain.h @@ -0,0 +1,32 @@ +#ifndef _SNMPALIASDOMAIN_H +#define _SNMPALIASDOMAIN_H + +#ifdef NETSNMP_TRANSPORT_ALIAS_DOMAIN + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Simple aliases for complex transport strings that can be specified + * via the snmp.conf file and the 'alias' token. + */ + +#define TRANSPORT_DOMAIN_ALIAS_IP 1,3,6,1,2,1,100,1,5 +NETSNMP_IMPORT oid netsnmp_snmpALIASDomain[]; + +/* + * "Constructor" for transport domain object. + */ + +void netsnmp_alias_ctor(void); + +#ifdef __cplusplus +} +#endif +#endif /*NETSNMP_TRANSPORT_ALIAS_DOMAIN */ + +#endif/*_SNMPALIASDOMAIN_H*/ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpCallbackDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpCallbackDomain.h new file mode 100644 index 00000000..e1be70b3 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpCallbackDomain.h @@ -0,0 +1,73 @@ +#ifndef _SNMPCALLBACKDOMAIN_H +#define _SNMPCALLBACKDOMAIN_H + +#ifndef NET_SNMP_CONFIG_H +#error "Please include before this file" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NETSNMP_TRANSPORT_CALLBACK_DOMAIN + +#include +#include + +typedef struct netsnmp_callback_pass_s { + int return_transport_num; + netsnmp_pdu *pdu; + struct netsnmp_callback_pass_s *next; +} netsnmp_callback_pass; + +typedef struct netsnmp_callback_info_s { + int linkedto; + void *parent_data; + netsnmp_callback_pass *data; + int callback_num; + int pipefds[2]; +} netsnmp_callback_info; + +netsnmp_transport *netsnmp_callback_transport(int); +int netsnmp_callback_hook_parse(netsnmp_session * sp, + netsnmp_pdu *pdu, + u_char * packetptr, + size_t len); +int netsnmp_callback_hook_build(netsnmp_session * sp, + netsnmp_pdu *pdu, + u_char * ptk, size_t * len); +int netsnmp_callback_check_packet(u_char * pkt, size_t len); +netsnmp_pdu *netsnmp_callback_create_pdu(netsnmp_transport *transport, + void *opaque, size_t olength); +NETSNMP_IMPORT +netsnmp_session *netsnmp_callback_open(int attach_to, + int (*return_func) (int op, + netsnmp_session + * session, + int reqid, + netsnmp_pdu + *pdu, + void *magic), + int (*fpre_parse) (netsnmp_session + *, + struct + netsnmp_transport_s + *, void *, int), + int (*fpost_parse) (netsnmp_session + *, + netsnmp_pdu *, + int)); +NETSNMP_IMPORT +void netsnmp_clear_callback_list(void); + +#else + +#define netsnmp_clear_callback_list() + + +#endif /*NETSNMP_TRANSPORT_CALLBACK_DOMAIN*/ + +#ifdef __cplusplus +} +#endif +#endif/*_SNMPCALLBACKDOMAIN_H*/ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpIPv4BaseDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpIPv4BaseDomain.h new file mode 100644 index 00000000..41eac0b4 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpIPv4BaseDomain.h @@ -0,0 +1,48 @@ +/* IPV4 base transport support functions + */ +#ifndef SNMPIPV4BASE_H +#define SNMPIPV4BASE_H + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#include + +config_require(IPBase); + +#ifdef __cplusplus +extern "C" { +#endif + + struct netsnmp_ep; + +/* + * Prototypes + */ + + char *netsnmp_ipv4_fmtaddr(const char *prefix, netsnmp_transport *t, + const void *data, int len); + void netsnmp_ipv4_get_taddr(struct netsnmp_transport_s *t, void **addr, + size_t *addr_len); + int netsnmp_ipv4_ostring_to_sockaddr(struct sockaddr_in *sin, + const void *o, size_t o_len); + +/* + * Convert a "traditional" peername into a sockaddr_in structure which is + * written to *addr_ Returns 1 if the conversion was successful, or 0 if it + * failed + */ + + int netsnmp_sockaddr_in(struct sockaddr_in *addr, const char *peername, + int remote_port); + int netsnmp_sockaddr_in2(struct sockaddr_in *addr, const char *inpeername, + const char *default_target); + int + netsnmp_sockaddr_in3(struct netsnmp_ep *ep, + const char *inpeername, const char *default_target); + +#ifdef __cplusplus +} +#endif +#endif /* SNMPIPV4BASE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpIPv6BaseDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpIPv6BaseDomain.h new file mode 100644 index 00000000..69eae1c5 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpIPv6BaseDomain.h @@ -0,0 +1,41 @@ +/* IPV6 base transport support functions + */ +#ifndef SNMPIPV6BASE_H +#define SNMPIPV6BASE_H + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +config_require(IPBase); + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Prototypes + */ + + char *netsnmp_ipv6_fmtaddr(const char *prefix, netsnmp_transport *t, + const void *data, int len); + void netsnmp_ipv6_get_taddr(struct netsnmp_transport_s *t, void **addr, + size_t *addr_len); + int netsnmp_ipv6_ostring_to_sockaddr(struct sockaddr_in6 *sin6, + const void *o, size_t o_len); + int netsnmp_sockaddr_in6_2(struct sockaddr_in6 *addr, + const char *inpeername, + const char *default_target); + int netsnmp_sockaddr_in6(struct sockaddr_in6 *addr, + const char *inpeername, int remote_port); + int + netsnmp_sockaddr_in6_3(struct netsnmp_ep *ep, + const char *inpeername, const char *default_target); + +#ifdef __cplusplus +} +#endif +#endif /* SNMPIPV6BASE_H */ + diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpSocketBaseDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpSocketBaseDomain.h new file mode 100644 index 00000000..06001727 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpSocketBaseDomain.h @@ -0,0 +1,25 @@ +#ifndef SNMPSOCKETBASEDOMAIN_H +#define SNMPSOCKETBASEDOMAIN_H + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Prototypes + */ + int netsnmp_socketbase_close(netsnmp_transport *t); + int netsnmp_sock_buffer_set(int s, int optname, int local, int size); + int netsnmp_set_non_blocking_mode(int sock, int non_blocking_mode); + +#ifdef __cplusplus +} +#endif + +#endif /* SNMPSOCKETBASEDOMAIN_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpTCPBaseDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpTCPBaseDomain.h new file mode 100644 index 00000000..e0e92472 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpTCPBaseDomain.h @@ -0,0 +1,22 @@ +#ifndef SNMPTCPBASEDOMAIN_H +#define SNMPTCPBASEDOMAIN_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Prototypes + */ + int netsnmp_tcpbase_recv(netsnmp_transport *t, void *buf, int size, + void **opaque, int *olength); + int netsnmp_tcpbase_send(netsnmp_transport *t, const void *buf, int size, + void **opaque, int *olength); + +#ifdef __cplusplus +} +#endif + +#endif /* SNMPTCPBASEDOMAIN_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpTCPDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpTCPDomain.h new file mode 100644 index 00000000..c662b48c --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpTCPDomain.h @@ -0,0 +1,42 @@ +#ifndef _SNMPTCPDOMAIN_H +#define _SNMPTCPDOMAIN_H + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +config_require(IPv4Base); +config_require(SocketBase); +config_require(TCPBase); + +#ifdef NETSNMP_TRANSPORT_TCP_DOMAIN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The SNMP over TCP over IPv4 transport domain is identified by + * transportDomainTcpIpv4 as defined in RFC 3419. + */ + +#define TRANSPORT_DOMAIN_TCP_IP 1,3,6,1,2,1,100,1,5 +NETSNMP_IMPORT oid netsnmp_snmpTCPDomain[]; + +netsnmp_transport * +netsnmp_tcp_transport(const struct netsnmp_ep *ep, int local); + +/* + * "Constructor" for transport domain object. + */ + +void netsnmp_tcp_ctor(void); + +#ifdef __cplusplus +} +#endif +#endif /*NETSNMP_TRANSPORT_TCP_DOMAIN */ + +#endif/*_SNMPTCPDOMAIN_H*/ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpTCPIPv6Domain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpTCPIPv6Domain.h new file mode 100644 index 00000000..bf8f4e8f --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpTCPIPv6Domain.h @@ -0,0 +1,38 @@ +#ifndef _SNMPTCPIPV6DOMAIN_H +#define _SNMPTCPIPV6DOMAIN_H + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +config_require(IPv6Base); +config_require(SocketBase); +config_require(TCPBase); + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The SNMP over TCP over IPv6 transport domain is identified by + * transportDomainTcpIpv4 as defined in RFC 3419. + */ + +#define TRANSPORT_DOMAIN_TCP_IPV6 1,3,6,1,2,1,100,1,6 +NETSNMP_IMPORT oid netsnmp_TCPIPv6Domain[]; + +netsnmp_transport * +netsnmp_tcp6_transport(const struct netsnmp_ep *ep, int local); + +/* + * "Constructor" for transport domain object. + */ + +void netsnmp_tcpipv6_ctor(void); + +#ifdef __cplusplus +} +#endif +#endif/*_SNMPTCPIPV6DOMAIN_H*/ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpUDPBaseDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpUDPBaseDomain.h new file mode 100644 index 00000000..93b8745d --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpUDPBaseDomain.h @@ -0,0 +1,41 @@ +#ifndef SNMPUDPBASEDOMAIN_H +#define SNMPUDPBASEDOMAIN_H + +config_require(SocketBase); + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * "Constructor" for transport domain object. + */ + + void netsnmp_udp_base_ctor(void); + +/* + * Prototypes + */ + void _netsnmp_udp_sockopt_set(int fd, int local); + int netsnmp_udpbase_recv(netsnmp_transport *t, void *buf, int size, + void **opaque, int *olength); + int netsnmp_udpbase_send(netsnmp_transport *t, const void *buf, int size, + void **opaque, int *olength); + +#if defined(HAVE_IP_PKTINFO) || defined(HAVE_IP_RECVDSTADDR) + int netsnmp_udpbase_recvfrom(int s, void *buf, int len, + struct sockaddr *from, socklen_t *fromlen, + struct sockaddr *dstip, socklen_t *dstlen, + int *if_index); + int netsnmp_udpbase_sendto(int fd, const struct in_addr *srcip, + int if_index, const struct sockaddr *remote, + const void *data, int len); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* SNMPUDPBASEDOMAIN_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpUDPDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpUDPDomain.h new file mode 100644 index 00000000..a518941a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpUDPDomain.h @@ -0,0 +1,96 @@ +#ifndef _SNMPUDPDOMAIN_H +#define _SNMPUDPDOMAIN_H + +/* + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif + +config_require(UDPIPv4Base); +#include + +netsnmp_transport * +netsnmp_udp_transport(const struct netsnmp_ep *ep, int local); + +netsnmp_transport *netsnmp_udp_create_tspec(netsnmp_tdomain_spec *tspec); + +netsnmp_transport * +netsnmp_udp_transport_with_source(const struct netsnmp_ep *ep, int local, + const struct netsnmp_ep *src_addr); + +#define C2SE_ERR_SUCCESS 0 +#define C2SE_ERR_MISSING_ARG -1 +#define C2SE_ERR_COMMUNITY_TOO_LONG -2 +#define C2SE_ERR_SECNAME_TOO_LONG -3 +#define C2SE_ERR_CONTEXT_TOO_LONG -4 +#define C2SE_ERR_MASK_MISMATCH -5 +#define C2SE_ERR_MEMORY -6 + +typedef struct com2SecEntry_s com2SecEntry; + +int netsnmp_udp_com2SecEntry_create(com2SecEntry **entryp, + const char *community, + const char *secName, + const char *contextName, + struct in_addr *network, + struct in_addr *mask, + int negate); +void netsnmp_udp_com2Sec_free(com2SecEntry *e); + +int netsnmp_udp_com2SecList_remove(com2SecEntry *e); + +/* + * Register any configuration tokens specific to the agent. + */ + +NETSNMP_IMPORT +void netsnmp_udp_agent_config_tokens_register(void); + +NETSNMP_IMPORT +void netsnmp_udp_parse_security(const char *token, char *param); + +NETSNMP_IMPORT +int netsnmp_udp_getSecName(void *opaque, int olength, + const char *community, + size_t community_len, + const char **secname, + const char **contextName); + +/* + * "Constructor" for transport domain object. + */ + +void netsnmp_udp_ctor(void); + +/* + * protected-ish functions used by other core-code + */ +char *netsnmp_udp_fmtaddr(netsnmp_transport *t, const void *data, int len); +#if defined(HAVE_IP_PKTINFO) || defined(HAVE_IP_RECVDSTADDR) +int netsnmp_udp_recvfrom(int s, void *buf, int len, struct sockaddr *from, + socklen_t *fromlen, struct sockaddr *dstip, + socklen_t *dstlen, int *if_index); +int netsnmp_udp_sendto(int fd, const struct in_addr *srcip, int if_index, + const struct sockaddr *remote, const void *data, + int len); +#endif + +#ifdef __cplusplus +} +#endif +#endif/*_SNMPUDPDOMAIN_H*/ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpUDPIPv4BaseDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpUDPIPv4BaseDomain.h new file mode 100644 index 00000000..cf9ea5ad --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpUDPIPv4BaseDomain.h @@ -0,0 +1,73 @@ +/* UDPIPV4 base transport support functions + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#ifndef SNMPUDPIPV4BASE_H +#define SNMPUDPIPV4BASE_H + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif + +config_require(UDPBase); +config_require(IPv4Base); + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Prototypes + */ + + netsnmp_transport * + netsnmp_udpipv4base_transport(const struct netsnmp_ep *ep, int local); + + netsnmp_transport * + netsnmp_udpipv4base_transport_with_source(const struct netsnmp_ep *ep, + int local, + const struct netsnmp_ep *src_addr); + + netsnmp_transport * + netsnmp_udpipv4base_tspec_transport(netsnmp_tdomain_spec *tspec); + + /** internal functions for derivatives of udpipv4base */ + netsnmp_transport * + netsnmp_udpipv4base_transport_init(const struct netsnmp_ep *ep, + int local); + + int + netsnmp_udpipv4base_transport_socket(int flags); + + int + netsnmp_udpipv4base_transport_bind(netsnmp_transport *t, + const struct netsnmp_ep *ep, + int flags); + + void + netsnmp_udpipv4base_transport_get_bound_addr(netsnmp_transport *t); + +#if defined(HAVE_IP_PKTINFO) || defined(HAVE_IP_RECVDSTADDR) + int netsnmp_udpipv4_recvfrom(int s, void *buf, int len, + struct sockaddr *from, socklen_t *fromlen, + struct sockaddr *dstip, socklen_t *dstlen, + int *if_index); + int netsnmp_udpipv4_sendto(int fd, const struct in_addr *srcip, + int if_index, const struct sockaddr *remote, + const void *data, int len); +#endif + + +#ifdef __cplusplus +} +#endif +#endif /* SNMPUDPIPV4BASE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpUDPIPv6Domain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpUDPIPv6Domain.h new file mode 100644 index 00000000..5c10ac92 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpUDPIPv6Domain.h @@ -0,0 +1,88 @@ +#ifndef _SNMPUDPIPV6DOMAIN_H +#define _SNMPUDPIPV6DOMAIN_H + +/* + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +config_require(IPv6Base); +config_require(UDPBase); + +#include + +/* + * The SNMP over UDP over IPv6 transport domain is identified by + * transportDomainUdpIpv6 as defined in RFC 3419. + */ + +#define TRANSPORT_DOMAIN_UDP_IPV6 1,3,6,1,2,1,100,1,2 +NETSNMP_IMPORT oid netsnmp_UDPIPv6Domain[]; + +netsnmp_transport *netsnmp_udp6_transport(const struct netsnmp_ep *ep, + int local); + +netsnmp_transport * +netsnmp_udp6_transport_with_source(const struct netsnmp_ep *ep, int local, + const struct netsnmp_ep *src_addr); + + /** internal functions for derivatives of udpipv6 */ + + netsnmp_transport * + netsnmp_udp6_transport_init(const struct netsnmp_ep *ep, int local); + + int + netsnmp_udp6_transport_socket(int flags); + + int + netsnmp_udp6_transport_bind(netsnmp_transport *t, + const struct netsnmp_ep *ep, + int flags); + + void + netsnmp_udp6_transport_get_bound_addr(netsnmp_transport *t); + + +/* + * Convert a "traditional" peername into a sockaddr_in6 structure which is + * written to *addr. Returns 1 if the conversion was successful, or 0 if it + * failed. + */ + +int netsnmp_sockaddr_in6(struct sockaddr_in6 *addr, + const char *peername, + int remote_port); + +NETSNMP_IMPORT +void netsnmp_udp6_agent_config_tokens_register(void); +NETSNMP_IMPORT +void netsnmp_udp6_parse_security(const char *token, + char *param); + +NETSNMP_IMPORT +int netsnmp_udp6_getSecName(void *opaque, int olength, + const char *community, + int community_len, + const char **secname, + const char **contextName); + +/* + * "Constructor" for transport domain object. + */ + +void netsnmp_udpipv6_ctor(void); + +#ifdef __cplusplus +} +#endif +#endif/*_SNMPUDPIPV6DOMAIN_H*/ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpUnixDomain.h b/illumos-x86_64/usr/include/net-snmp/library/snmpUnixDomain.h new file mode 100644 index 00000000..ac879c37 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpUnixDomain.h @@ -0,0 +1,65 @@ +#ifndef _SNMPUNIXDOMAIN_H +#define _SNMPUNIXDOMAIN_H + +#ifdef NETSNMP_TRANSPORT_UNIX_DOMAIN + +#if defined(cygwin) || defined(mingw32) || defined(mingw32msvc) + config_error(Unix domain protocol support unavailable for this platform); +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_UN_H +#include +#endif + +#include + +config_require(SocketBase); + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The SNMP over local socket transport domain is identified by + * transportDomainLocal as defined in RFC 3419. + */ + +#define TRANSPORT_DOMAIN_LOCAL 1,3,6,1,2,1,100,1,13 +NETSNMP_IMPORT oid netsnmp_UnixDomain[]; + +netsnmp_transport *netsnmp_unix_transport(const struct sockaddr_un *addr, + int local); +void netsnmp_unix_agent_config_tokens_register(void); +void netsnmp_unix_parse_security(const char *token, char *param); +int netsnmp_unix_getSecName(void *opaque, int olength, + const char *community, + size_t community_len, const char **secName, + const char **contextName); + + +/* + * "Constructor" for transport domain object. + */ + +void netsnmp_unix_ctor(void); + +/* + * Support functions + */ +void netsnmp_unix_create_path_with_mode(int mode); +void netsnmp_unix_dont_create_path(void); + +#ifdef __cplusplus +} +#endif +#else + +#define netsnmp_unix_create_path_with_mode(x) +#define netsnmp_unix_dont_create_path() + +#endif /*NETSNMP_TRANSPORT_UNIX_DOMAIN */ + +#endif/*_SNMPUNIXDOMAIN_H*/ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_alarm.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_alarm.h new file mode 100644 index 00000000..9e3b7d61 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_alarm.h @@ -0,0 +1,85 @@ +#ifndef SNMP_ALARM_H +#define SNMP_ALARM_H + +/* + * For 'timeval' + */ +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + typedef void (SNMPAlarmCallback) (unsigned int clientreg, + void *clientarg); + + /* + * alarm flags + */ +#define SA_REPEAT 0x01 /* keep repeating every X seconds */ +#define SA_FIRED 0x10 /* Being processed in run_alarms */ + + struct snmp_alarm { + /** Alarm interval. Zero if single-shot. */ + struct timeval t; + unsigned int flags; + unsigned int clientreg; + /** Last time the alarm fired [monotonic clock]. */ + struct timeval t_lastM; + /** Next time the alarm will fire [monotonic clock]. */ + struct timeval t_nextM; + void *clientarg; + SNMPAlarmCallback *thecallback; + struct snmp_alarm *next; + }; + + /* + * the ones you should need + */ + NETSNMP_IMPORT + void snmp_alarm_unregister(unsigned int clientreg); + void snmp_alarm_unregister_all(void); + NETSNMP_IMPORT + unsigned int snmp_alarm_register(unsigned int when, + unsigned int flags, + SNMPAlarmCallback * thecallback, + void *clientarg); + + unsigned int snmp_alarm_register_hr(struct timeval t, + unsigned int flags, + SNMPAlarmCallback * cb, + void *cd); + NETSNMP_IMPORT + int snmp_alarm_reset(unsigned int clientreg); + + + /* + * the ones you shouldn't + */ + NETSNMP_IMPORT void init_snmp_alarm(void); + int init_alarm_post_config(int majorid, int minorid, + void *serverarg, + void *clientarg); + void sa_update_entry(struct snmp_alarm *alrm); + struct snmp_alarm *sa_find_next(void); + NETSNMP_IMPORT void run_alarms(void); + RETSIGTYPE alarm_handler(int a); + void set_an_alarm(void); + int netsnmp_get_next_alarm_time(struct timeval *alarm_tm, + const struct timeval *now); + int get_next_alarm_delay_time(struct timeval *delta); + + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_ALARM_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_api.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_api.h new file mode 100644 index 00000000..ab614343 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_api.h @@ -0,0 +1,765 @@ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#ifndef SNMP_API_H +#define SNMP_API_H + +/* + * @file snmp_api.h - API for access to snmp. + * + * @addtogroup library + * + * Caution: when using this library in a multi-threaded application, + * the values of global variables "snmp_errno" and "snmp_detail" + * cannot be reliably determined. Suggest using snmp_error() + * to obtain the library error codes. + * + * @{ + */ + +#include +#include +#include +#include +#include + +#include + +#ifndef DONT_SHARE_ERROR_WITH_OTHER_THREADS +#define SET_SNMP_ERROR(x) snmp_errno=(x) +#else +#define SET_SNMP_ERROR(x) +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************** + Copyright 1989 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ + +struct timeval; +/* + * A list of all the outstanding requests for a particular session. + */ +#ifdef SNMP_NEED_REQUEST_LIST +typedef struct request_list { + struct request_list *next_request; + long request_id; /* request id */ + long message_id; /* message id */ + netsnmp_callback callback; /* user callback per request (NULL if unused) */ + void *cb_data; /* user callback data per request (NULL if unused) */ + int retries; /* Number of retries */ + u_long timeout; /* length to wait for timeout */ + struct timeval timeM; /* Time this request was made [monotonic clock] */ + struct timeval expireM; /* Time this request is due to expire [monotonic clock]. */ + struct snmp_session *session; + netsnmp_pdu *pdu; /* The pdu for this request + * (saved so it can be retransmitted */ +} netsnmp_request_list; +#endif /* SNMP_NEED_REQUEST_LIST */ + + /* + * Set fields in session and pdu to the following to get a default or unconfigured value. + */ +#define SNMP_DEFAULT_COMMUNITY_LEN 0 /* to get a default community name */ +#define SNMP_DEFAULT_RETRIES -1 +#define SNMP_DEFAULT_TIMEOUT -1 +#define SNMP_DEFAULT_REMPORT 0 +#define SNMP_DEFAULT_REQID -1 +#define SNMP_DEFAULT_MSGID -1 +#define SNMP_DEFAULT_ERRSTAT -1 +#define SNMP_DEFAULT_ERRINDEX -1 +#define SNMP_DEFAULT_ADDRESS 0 +#define SNMP_DEFAULT_PEERNAME NULL +#define SNMP_DEFAULT_ENTERPRISE_LENGTH 0 +#define SNMP_DEFAULT_TIME 0 +#define SNMP_DEFAULT_VERSION -1 +#define SNMP_DEFAULT_SECMODEL -1 +#define SNMP_DEFAULT_CONTEXT "" +#ifndef NETSNMP_DISABLE_MD5 +#define SNMP_DEFAULT_AUTH_PROTO usmHMACMD5AuthProtocol +#else +#define SNMP_DEFAULT_AUTH_PROTO usmHMACSHA1AuthProtocol +#endif +#define SNMP_DEFAULT_AUTH_PROTOLEN OID_LENGTH(SNMP_DEFAULT_AUTH_PROTO) +#ifndef NETSNMP_DISABLE_DES +#define SNMP_DEFAULT_PRIV_PROTO usmDESPrivProtocol +#else +#define SNMP_DEFAULT_PRIV_PROTO usmAESPrivProtocol +#endif +#define SNMP_DEFAULT_PRIV_PROTOLEN OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO) + + NETSNMP_IMPORT void snmp_set_detail(const char *); + +#define SNMP_MAX_RCV_MSG_SIZE 65536 +#define SNMP_MAX_MSG_SIZE 1472 /* ethernet MTU minus IP/UDP header */ +#define SNMP_MAX_MSG_V3_HDRS (4+3+4+7+7+3+7+16) /* fudge factor=16 */ +#define SNMP_MAX_ENG_SIZE 32 +#define SNMP_MAX_SEC_NAME_SIZE 256 +#define SNMP_MAX_CONTEXT_SIZE 256 +#define SNMP_SEC_PARAM_BUF_SIZE 256 + + /* + * set to one to ignore unauthenticated Reports + */ +#define SNMPV3_IGNORE_UNAUTH_REPORTS 0 + + /* + * authoritative engine definitions + */ +#define SNMP_SESS_NONAUTHORITATIVE 0 /* should be 0 to default to this */ +#define SNMP_SESS_AUTHORITATIVE 1 /* don't learn engineIDs */ +#define SNMP_SESS_UNKNOWNAUTH 2 /* sometimes (like NRs) */ + + /* + * to determine type of Report from varbind_list + */ +#define REPORT_STATS_LEN 9 /* Length of prefix for MPD/USM report statistic objects */ +#define REPORT_STATS_LEN2 8 /* Length of prefix for Target report statistic objects */ +/* From SNMP-MPD-MIB */ +#define REPORT_snmpUnknownSecurityModels_NUM 1 +#define REPORT_snmpInvalidMsgs_NUM 2 +#define REPORT_snmpUnknownPDUHandlers_NUM 3 +/* From SNMP-USER-BASED-SM-MIB */ +#define REPORT_usmStatsUnsupportedSecLevels_NUM 1 +#define REPORT_usmStatsNotInTimeWindows_NUM 2 +#define REPORT_usmStatsUnknownUserNames_NUM 3 +#define REPORT_usmStatsUnknownEngineIDs_NUM 4 +#define REPORT_usmStatsWrongDigests_NUM 5 +#define REPORT_usmStatsDecryptionErrors_NUM 6 +/* From SNMP-TARGET-MIB */ +#define REPORT_snmpUnavailableContexts_NUM 4 +#define REPORT_snmpUnknownContexts_NUM 5 + +#define SNMP_DETAIL_SIZE 512 + +#define SNMP_FLAGS_UDP_BROADCAST 0x800 +#define SNMP_FLAGS_RESP_CALLBACK 0x400 /* Additional callback on response */ +#define SNMP_FLAGS_USER_CREATED 0x200 /* USM user has been created */ +#define SNMP_FLAGS_DONT_PROBE 0x100 /* don't probe for an engineID */ +#define SNMP_FLAGS_STREAM_SOCKET 0x80 +#define SNMP_FLAGS_LISTENING 0x40 /* Server stream sockets only */ +#define SNMP_FLAGS_SUBSESSION 0x20 +#define SNMP_FLAGS_SHARED_SOCKET 0x10 /* subsession list=related sessions */ +#define SNMP_FLAGS_STRIKE2 0x02 +#define SNMP_FLAGS_STRIKE1 0x01 + +#define CLEAR_SNMP_STRIKE_FLAGS(x) \ + x &= ~(SNMP_FLAGS_STRIKE2|SNMP_FLAGS_STRIKE1) + + /* + * returns '1' if the session is to be regarded as dead, + * otherwise set the strike flags appropriately, and return 0 + */ +#define SET_SNMP_STRIKE_FLAGS(x) \ + (( x & SNMP_FLAGS_STRIKE2 ) ? 1 : \ + ((( x & SNMP_FLAGS_STRIKE1 ) ? ( x |= SNMP_FLAGS_STRIKE2 ) : \ + ( x |= SNMP_FLAGS_STRIKE1 )), \ + 0)) + + /* + * Error return values. + * + * SNMPERR_SUCCESS is the non-PDU "success" code. + * + * XXX These should be merged with SNMP_ERR_* defines and confined + * to values < 0. ??? + */ +#define SNMPERR_SUCCESS (0) /* XXX Non-PDU "success" code. */ +#define SNMPERR_GENERR (-1) +#define SNMPERR_BAD_LOCPORT (-2) +#define SNMPERR_BAD_ADDRESS (-3) +#define SNMPERR_BAD_SESSION (-4) +#define SNMPERR_TOO_LONG (-5) +#define SNMPERR_NO_SOCKET (-6) +#define SNMPERR_V2_IN_V1 (-7) +#define SNMPERR_V1_IN_V2 (-8) +#define SNMPERR_BAD_REPEATERS (-9) +#define SNMPERR_BAD_REPETITIONS (-10) +#define SNMPERR_BAD_ASN1_BUILD (-11) +#define SNMPERR_BAD_SENDTO (-12) +#define SNMPERR_BAD_PARSE (-13) +#define SNMPERR_BAD_VERSION (-14) +#define SNMPERR_BAD_SRC_PARTY (-15) +#define SNMPERR_BAD_DST_PARTY (-16) +#define SNMPERR_BAD_CONTEXT (-17) +#define SNMPERR_BAD_COMMUNITY (-18) +#define SNMPERR_NOAUTH_DESPRIV (-19) +#define SNMPERR_BAD_ACL (-20) +#define SNMPERR_BAD_PARTY (-21) +#define SNMPERR_ABORT (-22) +#define SNMPERR_UNKNOWN_PDU (-23) +#define SNMPERR_TIMEOUT (-24) +#define SNMPERR_BAD_RECVFROM (-25) +#define SNMPERR_BAD_ENG_ID (-26) +#define SNMPERR_BAD_SEC_NAME (-27) +#define SNMPERR_BAD_SEC_LEVEL (-28) +#define SNMPERR_ASN_PARSE_ERR (-29) +#define SNMPERR_UNKNOWN_SEC_MODEL (-30) +#define SNMPERR_INVALID_MSG (-31) +#define SNMPERR_UNKNOWN_ENG_ID (-32) +#define SNMPERR_UNKNOWN_USER_NAME (-33) +#define SNMPERR_UNSUPPORTED_SEC_LEVEL (-34) +#define SNMPERR_AUTHENTICATION_FAILURE (-35) +#define SNMPERR_NOT_IN_TIME_WINDOW (-36) +#define SNMPERR_DECRYPTION_ERR (-37) +#define SNMPERR_SC_GENERAL_FAILURE (-38) +#define SNMPERR_SC_NOT_CONFIGURED (-39) +#define SNMPERR_KT_NOT_AVAILABLE (-40) +#define SNMPERR_UNKNOWN_REPORT (-41) +#define SNMPERR_USM_GENERICERROR (-42) +#define SNMPERR_USM_UNKNOWNSECURITYNAME (-43) +#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL (-44) +#define SNMPERR_USM_ENCRYPTIONERROR (-45) +#define SNMPERR_USM_AUTHENTICATIONFAILURE (-46) +#define SNMPERR_USM_PARSEERROR (-47) +#define SNMPERR_USM_UNKNOWNENGINEID (-48) +#define SNMPERR_USM_NOTINTIMEWINDOW (-49) +#define SNMPERR_USM_DECRYPTIONERROR (-50) +#define SNMPERR_NOMIB (-51) +#define SNMPERR_RANGE (-52) +#define SNMPERR_MAX_SUBID (-53) +#define SNMPERR_BAD_SUBID (-54) +#define SNMPERR_LONG_OID (-55) +#define SNMPERR_BAD_NAME (-56) +#define SNMPERR_VALUE (-57) +#define SNMPERR_UNKNOWN_OBJID (-58) +#define SNMPERR_NULL_PDU (-59) +#define SNMPERR_NO_VARS (-60) +#define SNMPERR_VAR_TYPE (-61) +#define SNMPERR_MALLOC (-62) +#define SNMPERR_KRB5 (-63) +#define SNMPERR_PROTOCOL (-64) +#define SNMPERR_OID_NONINCREASING (-65) +#define SNMPERR_JUST_A_CONTEXT_PROBE (-66) +#define SNMPERR_TRANSPORT_NO_CONFIG (-67) +#define SNMPERR_TRANSPORT_CONFIG_ERROR (-68) +#define SNMPERR_TLS_NO_CERTIFICATE (-69) + +#define SNMPERR_MAX (-69) + + + /* + * General purpose memory allocation functions. Use these functions to + * allocate memory that may be reallocated or freed by the Net-SNMP + * library or to reallocate or free memory that has been allocated by the + * Net-SNMP library, and when working in a context where there is more than + * one heap. Examples are: + * - Perl XSUB's. + * - MSVC or MinGW with the Net-SNMP library compiled as a DLL instead of + * a static library. + */ + NETSNMP_IMPORT void *netsnmp_malloc(size_t size); + NETSNMP_IMPORT void *netsnmp_calloc(size_t nelem, size_t elsize); + NETSNMP_IMPORT void *netsnmp_realloc(void *ptr, size_t size); + NETSNMP_IMPORT void netsnmp_free(void *ptr); + NETSNMP_IMPORT char *netsnmp_strdup(const char *s1); + + NETSNMP_IMPORT long int netsnmp_random(void); + NETSNMP_IMPORT void netsnmp_srandom(unsigned int seed); + + /* + * void + * snmp_free_pdu(pdu) + * netsnmp_pdu *pdu; + * + * Frees the pdu and any malloc'd data associated with it. + */ + + NETSNMP_IMPORT void snmp_free_var_internals(netsnmp_variable_list *); /* frees contents only */ + + + /* + * This routine must be supplied by the application: + * + * u_char *authenticator(pdu, length, community, community_len) + * u_char *pdu; The rest of the PDU to be authenticated + * int *length; The length of the PDU (updated by the authenticator) + * u_char *community; The community name to authenticate under. + * int community_len The length of the community name. + * + * Returns the authenticated pdu, or NULL if authentication failed. + * If null authentication is used, the authenticator in snmp_session can be + * set to NULL(0). + */ + + + + /* + * This routine must be supplied by the application: + * + * int callback(operation, session, reqid, pdu, magic) + * int operation; + * netsnmp_session *session; The session authenticated under. + * int reqid; The request id of this pdu (0 for TRAP) + * netsnmp_pdu *pdu; The pdu information. + * void *magic A link to the data for this routine. + * + * Returns 1 if request was successful, 0 if it should be kept pending. + * Any data in the pdu must be copied because it will be freed elsewhere. + * Operations are defined below: + */ + +#define NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE 1 +#define NETSNMP_CALLBACK_OP_TIMED_OUT 2 +#define NETSNMP_CALLBACK_OP_SEND_FAILED 3 +#define NETSNMP_CALLBACK_OP_CONNECT 4 +#define NETSNMP_CALLBACK_OP_DISCONNECT 5 +#define NETSNMP_CALLBACK_OP_RESEND 6 +#define NETSNMP_CALLBACK_OP_SEC_ERROR 7 + + NETSNMP_IMPORT + long snmp_get_next_msgid(void); + NETSNMP_IMPORT + long snmp_get_next_reqid(void); + NETSNMP_IMPORT + long snmp_get_next_sessid(void); + NETSNMP_IMPORT + long snmp_get_next_transid(void); + + NETSNMP_IMPORT + int netsnmp_max_send_msg_size(void); + + NETSNMP_IMPORT + int snmp_oid_compare(const oid *, size_t, const oid *, + size_t); + NETSNMP_IMPORT + int snmp_oid_ncompare(const oid *, size_t, const oid *, + size_t, size_t); + NETSNMP_IMPORT + int snmp_oidtree_compare(const oid *, size_t, const oid *, + size_t); + NETSNMP_IMPORT + int snmp_oidsubtree_compare(const oid *, size_t, const oid *, + size_t); + NETSNMP_IMPORT + int netsnmp_oid_compare_ll(const oid * in_name1, + size_t len1, const oid * in_name2, + size_t len2, size_t *offpt); + NETSNMP_IMPORT + int netsnmp_oid_equals(const oid *, size_t, const oid *, + size_t); + NETSNMP_IMPORT + int netsnmp_oid_tree_equals(const oid *, size_t, const oid *, + size_t); + NETSNMP_IMPORT + int netsnmp_oid_is_subtree(const oid *, size_t, const oid *, + size_t); + NETSNMP_IMPORT + int netsnmp_oid_find_prefix(const oid * in_name1, size_t len1, + const oid * in_name2, size_t len2); + NETSNMP_IMPORT + void init_snmp(const char *); + + NETSNMP_IMPORT + int + snmp_build(u_char ** pkt, size_t * pkt_len, size_t * offset, + netsnmp_session * pss, netsnmp_pdu *pdu); + + NETSNMP_IMPORT + int + snmp_parse(struct session_list *sessp, netsnmp_session *pss, + netsnmp_pdu *pdu, u_char *data, size_t length); + + NETSNMP_IMPORT + u_char *snmp_pdu_build(netsnmp_pdu *, u_char *, size_t *); +#ifdef NETSNMP_USE_REVERSE_ASNENCODING + NETSNMP_IMPORT + u_char *snmp_pdu_rbuild(netsnmp_pdu *, u_char *, size_t *); +#endif + NETSNMP_IMPORT + int snmpv3_parse(netsnmp_pdu *, u_char *, size_t *, + u_char **, netsnmp_session *); + NETSNMP_IMPORT + int snmpv3_packet_build(netsnmp_session *, + netsnmp_pdu *pdu, u_char * packet, + size_t * out_length, + u_char * pdu_data, + size_t pdu_data_len); + NETSNMP_IMPORT + int snmpv3_packet_rbuild(netsnmp_session *, + netsnmp_pdu *pdu, u_char * packet, + size_t * out_length, + u_char * pdu_data, + size_t pdu_data_len); + NETSNMP_IMPORT + int snmpv3_make_report(netsnmp_pdu *pdu, int error); + NETSNMP_IMPORT + int snmpv3_get_report_type(netsnmp_pdu *pdu); + NETSNMP_IMPORT + int snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, + size_t * length); + NETSNMP_IMPORT + u_char *snmpv3_scopedPDU_parse(netsnmp_pdu *pdu, u_char * cp, + size_t * length); + NETSNMP_IMPORT + void snmp_store_needed(const char *type); + NETSNMP_IMPORT + void snmp_store_if_needed(void); + NETSNMP_IMPORT + void snmp_store(const char *type); + NETSNMP_IMPORT + void snmp_shutdown(const char *type); + NETSNMP_IMPORT + int snmp_add_var(netsnmp_pdu *, const oid *, size_t, char, + const char *); + NETSNMP_IMPORT + oid *snmp_duplicate_objid(const oid * objToCopy, size_t); + +#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS + NETSNMP_IMPORT + u_int snmp_increment_statistic(int which); + NETSNMP_IMPORT + u_int snmp_increment_statistic_by(int which, int count); + NETSNMP_IMPORT + u_int snmp_get_statistic(int which); + NETSNMP_IMPORT + void snmp_init_statistics(void); +#else /* NETSNMP_FEATURE_REMOVE_STATISTICS */ + +/* allow code to continue referencing API even if statistics are removed */ +#define snmp_increment_statistic(X) +#define snmp_increment_statistic_by(X,Y) +#define snmp_init_statistics() + +#endif + + NETSNMP_IMPORT + int create_user_from_session(netsnmp_session * session); + NETSNMP_IMPORT + int snmpv3_probe_contextEngineID_rfc5343(struct session_list *slp, + netsnmp_session *session); + + /* + * New re-allocating reverse encoding functions. + */ +#ifdef NETSNMP_USE_REVERSE_ASNENCODING + + NETSNMP_IMPORT + int snmpv3_packet_realloc_rbuild(u_char ** pkt, size_t * pkt_len, + size_t * offset, + netsnmp_session * session, + netsnmp_pdu *pdu, u_char * pdu_data, + size_t pdu_data_len); + + NETSNMP_IMPORT + int snmp_pdu_realloc_rbuild(u_char ** pkt, size_t * pkt_len, + size_t * offset, netsnmp_pdu *pdu); +#endif + + + +struct netsnmp_transport_s; + + /* + * Extended open; fpre_parse has changed. + */ + + NETSNMP_IMPORT + netsnmp_session *snmp_open_ex(netsnmp_session *, + int (*fpre_parse) (netsnmp_session *, + struct + netsnmp_transport_s *, + void *, int), + int (*fparse) (netsnmp_session *, + netsnmp_pdu *, u_char *, + size_t), + int (*fpost_parse) (netsnmp_session *, + netsnmp_pdu *, int), + int (*fbuild) (netsnmp_session *, + netsnmp_pdu *, u_char *, + size_t *), + int (*frbuild) (netsnmp_session *, + netsnmp_pdu *, u_char **, + size_t *, size_t *), + int (*fcheck) (u_char *, size_t)); + + /* + * provided for backwards compatability. Don't use these functions. + * See snmp_debug.h and snmp_debug.c instead. + */ + + NETSNMP_IMPORT + void snmp_set_do_debugging(int); + NETSNMP_IMPORT + int snmp_get_do_debugging(void); + + + NETSNMP_IMPORT + void netsnmp_sess_log_error(int priority, + const char *prog_string, + netsnmp_session * ss); + + NETSNMP_IMPORT + const char * snmp_pdu_type(int type); + + /* + * Return the netsnmp_transport structure associated with the given opaque + * pointer. + */ + + NETSNMP_IMPORT + struct netsnmp_transport_s *snmp_sess_transport(void *); + NETSNMP_IMPORT + void snmp_sess_transport_set(void *, + struct netsnmp_transport_s *); + + NETSNMP_IMPORT int + netsnmp_sess_config_transport(struct netsnmp_container_s *transport_configuration, + struct netsnmp_transport_s *transport); + + NETSNMP_IMPORT int + netsnmp_sess_config_and_open_transport(netsnmp_session *in_session, + struct netsnmp_transport_s *transport); + + /* + * EXTENDED SESSION API ------------------------------------------ + * + * snmp_sess_add_ex, snmp_sess_add, snmp_add + * + * Analogous to snmp_open family of functions, but taking an + * netsnmp_transport pointer as an extra argument. Unlike snmp_open et + * al. it doesn't attempt to interpret the in_session->peername as a + * transport endpoint specifier, but instead uses the supplied transport. + * JBPN + * + */ + + NETSNMP_IMPORT + void netsnmp_cleanup_session(netsnmp_session *s); + + NETSNMP_IMPORT + void *snmp_sess_add_ex(netsnmp_session *, + struct netsnmp_transport_s *, + int (*fpre_parse) (netsnmp_session *, + struct + netsnmp_transport_s + *, void *, int), + int (*fparse) (netsnmp_session *, + struct snmp_pdu *, + u_char *, size_t), + int (*fpost_parse) (netsnmp_session *, + struct snmp_pdu *, + int), + int (*fbuild) (netsnmp_session *, + struct snmp_pdu *, + u_char *, size_t *), + int (*frbuild) (netsnmp_session *, + struct snmp_pdu *, + u_char **, size_t *, + size_t *), + int (*fcheck) (u_char *, size_t), + netsnmp_pdu *(*fcreate_pdu) (struct + netsnmp_transport_s + *, + void *, + size_t)); + + NETSNMP_IMPORT + void *snmp_sess_add(netsnmp_session *, + struct netsnmp_transport_s *, + int (*fpre_parse) (netsnmp_session *, + struct + netsnmp_transport_s *, + void *, int), + int (*fpost_parse) (netsnmp_session *, + netsnmp_pdu *, int)); + + NETSNMP_IMPORT + netsnmp_session *snmp_add(netsnmp_session *, + struct netsnmp_transport_s *, + int (*fpre_parse) (netsnmp_session *, + struct netsnmp_transport_s + *, void *, int), + int (*fpost_parse) (netsnmp_session *, + netsnmp_pdu *, int)); + NETSNMP_IMPORT + netsnmp_session *snmp_add_full(netsnmp_session * in_session, + struct netsnmp_transport_s *transport, + int (*fpre_parse) (netsnmp_session *, + struct + netsnmp_transport_s + *, void *, int), + int (*fparse) (netsnmp_session *, + netsnmp_pdu *, u_char *, + size_t), + int (*fpost_parse) (netsnmp_session *, + netsnmp_pdu *, int), + int (*fbuild) (netsnmp_session *, + netsnmp_pdu *, u_char *, + size_t *), + int (*frbuild) (netsnmp_session *, + netsnmp_pdu *, + u_char **, size_t *, + size_t *), + int (*fcheck) (u_char *, size_t), + netsnmp_pdu *(*fcreate_pdu) (struct + netsnmp_transport_s + *, void *, + size_t) + ); + /* + * end single session API + */ + + /* + * generic statistic counters + */ + + /* + * snmpv3 statistics + */ + + /* + * mpd stats + */ +#define STAT_SNMPUNKNOWNSECURITYMODELS 0 +#define STAT_SNMPINVALIDMSGS 1 +#define STAT_SNMPUNKNOWNPDUHANDLERS 2 +#define STAT_MPD_STATS_START STAT_SNMPUNKNOWNSECURITYMODELS +#define STAT_MPD_STATS_END STAT_SNMPUNKNOWNPDUHANDLERS + + /* + * usm stats + */ +#define STAT_USMSTATSUNSUPPORTEDSECLEVELS 3 +#define STAT_USMSTATSNOTINTIMEWINDOWS 4 +#define STAT_USMSTATSUNKNOWNUSERNAMES 5 +#define STAT_USMSTATSUNKNOWNENGINEIDS 6 +#define STAT_USMSTATSWRONGDIGESTS 7 +#define STAT_USMSTATSDECRYPTIONERRORS 8 +#define STAT_USM_STATS_START STAT_USMSTATSUNSUPPORTEDSECLEVELS +#define STAT_USM_STATS_END STAT_USMSTATSDECRYPTIONERRORS + + /* + * snmp counters + */ +#define STAT_SNMPINPKTS 9 +#define STAT_SNMPOUTPKTS 10 +#define STAT_SNMPINBADVERSIONS 11 +#define STAT_SNMPINBADCOMMUNITYNAMES 12 +#define STAT_SNMPINBADCOMMUNITYUSES 13 +#define STAT_SNMPINASNPARSEERRS 14 + /* + * #define STAT_SNMPINBADTYPES 15 + */ +#define STAT_SNMPINTOOBIGS 16 +#define STAT_SNMPINNOSUCHNAMES 17 +#define STAT_SNMPINBADVALUES 18 +#define STAT_SNMPINREADONLYS 19 +#define STAT_SNMPINGENERRS 20 +#define STAT_SNMPINTOTALREQVARS 21 +#define STAT_SNMPINTOTALSETVARS 22 +#define STAT_SNMPINGETREQUESTS 23 +#define STAT_SNMPINGETNEXTS 24 +#define STAT_SNMPINSETREQUESTS 25 +#define STAT_SNMPINGETRESPONSES 26 +#define STAT_SNMPINTRAPS 27 +#define STAT_SNMPOUTTOOBIGS 28 +#define STAT_SNMPOUTNOSUCHNAMES 29 +#define STAT_SNMPOUTBADVALUES 30 + /* + * #define STAT_SNMPOUTREADONLYS 31 + */ +#define STAT_SNMPOUTGENERRS 32 +#define STAT_SNMPOUTGETREQUESTS 33 +#define STAT_SNMPOUTGETNEXTS 34 +#define STAT_SNMPOUTSETREQUESTS 35 +#define STAT_SNMPOUTGETRESPONSES 36 +#define STAT_SNMPOUTTRAPS 37 + /* + * AUTHTRAPENABLE 38 + */ +#define STAT_SNMPSILENTDROPS 39 +#define STAT_SNMPPROXYDROPS 40 +#define STAT_SNMP_STATS_START STAT_SNMPINPKTS +#define STAT_SNMP_STATS_END STAT_SNMPPROXYDROPS + + /* + * target mib counters + */ +#define STAT_SNMPUNAVAILABLECONTEXTS 41 +#define STAT_SNMPUNKNOWNCONTEXTS 42 +#define STAT_TARGET_STATS_START STAT_SNMPUNAVAILABLECONTEXTS +#define STAT_TARGET_STATS_END STAT_SNMPUNKNOWNCONTEXTS + + /* + * TSM counters + */ +#define STAT_TSM_SNMPTSMINVALIDCACHES 43 +#define STAT_TSM_SNMPTSMINADEQUATESECURITYLEVELS 44 +#define STAT_TSM_SNMPTSMUNKNOWNPREFIXES 45 +#define STAT_TSM_SNMPTSMINVALIDPREFIXES 46 +#define STAT_TSM_STATS_START STAT_TSM_SNMPTSMINVALIDCACHES +#define STAT_TSM_STATS_END STAT_TSM_SNMPTSMINVALIDPREFIXES + + /* + * TLSTM counters + */ +#define STAT_TLSTM_SNMPTLSTMSESSIONOPENS 47 +#define STAT_TLSTM_SNMPTLSTMSESSIONCLIENTCLOSES 48 +#define STAT_TLSTM_SNMPTLSTMSESSIONOPENERRORS 49 +#define STAT_TLSTM_SNMPTLSTMSESSIONACCEPTS 50 +#define STAT_TLSTM_SNMPTLSTMSESSIONSERVERCLOSES 51 +#define STAT_TLSTM_SNMPTLSTMSESSIONNOSESSIONS 52 +#define STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCLIENTCERTIFICATES 53 +#define STAT_TLSTM_SNMPTLSTMSESSIONUNKNOWNSERVERCERTIFICATE 54 +#define STAT_TLSTM_SNMPTLSTMSESSIONINVALIDSERVERCERTIFICATES 55 +#define STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES 56 + +#define STAT_TLSTM_STATS_START STAT_TLSTM_SNMPTLSTMSESSIONOPENS +#define STAT_TLSTM_STATS_END STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES + + /* this previously was end+1; don't know why the +1 is needed; + XXX: check the code */ +#define NETSNMP_STAT_MAX_STATS (STAT_TLSTM_STATS_END+1) +/** backwards compatability */ +#define MAX_STATS NETSNMP_STAT_MAX_STATS + + /* + * Internal: The list of active/open sessions. + */ + struct session_list { + struct session_list *next; + netsnmp_session *session; + netsnmp_transport *transport; + struct snmp_internal_session *internal; + }; + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_API_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_assert.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_assert.h new file mode 100644 index 00000000..8f52a69a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_assert.h @@ -0,0 +1,127 @@ +#ifndef SNMP_ASSERT_H +#define SNMP_ASSERT_H + +#ifdef NETSNMP_USE_ASSERT +# include +#else +# include +#endif + + +/* + * MACROs don't need extern "C" + */ + +/* + * define __STRING for systems (*cough* sun *cough*) that don't have it + */ +#ifndef __STRING +# if defined(__STDC__) || defined(_MSC_VER) +# define __STRING(x) #x +# else +# define __STRING(x) "x" +# endif /* __STDC__ */ +#endif /* __STRING */ + +/* + * always use assert if requested + */ +#ifdef NETSNMP_USE_ASSERT +/* void netsnmp_assert( int );*/ +# define netsnmp_assert(x) assert( x ) +# define netsnmp_assert_or_return(x, y) assert( x ) +# define netsnmp_assert_or_msgreturn(x, y, z) assert( x ) +#else +/* + * if asserts weren't requested, just log, unless NETSNMP_NO_DEBUGGING specified + */ +# ifndef NETSNMP_NO_DEBUGGING +# ifdef NETSNMP_FUNCTION +# define NETSNMP_FUNC_FMT " %s()\n" +# define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION +# else +# define NETSNMP_FUNC_FMT "%c" +# define NETSNMP_FUNC_PARAM '\n' +# endif +# +# define netsnmp_assert(x) do { \ + if ( x ) \ + ; \ + else \ + snmp_log(LOG_ERR, \ + "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \ + __STRING(x),__FILE__,__LINE__, \ + NETSNMP_FUNC_PARAM); \ + }while(0) +# define netsnmp_assert_or_return(x, y) do { \ + if ( x ) \ + ; \ + else { \ + snmp_log(LOG_ERR, \ + "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \ + __STRING(x),__FILE__,__LINE__, \ + NETSNMP_FUNC_PARAM); \ + return y; \ + } \ + }while(0) +# define netsnmp_assert_or_msgreturn(x, y, z) do { \ + if ( x ) \ + ; \ + else { \ + snmp_log(LOG_ERR, \ + "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \ + __STRING(x),__FILE__,__LINE__, \ + NETSNMP_FUNC_PARAM); \ + snmp_log(LOG_ERR, y); \ + return z; \ + } \ + }while(0) +# else /* NO DEBUGGING */ +# define netsnmp_assert(x) +# define netsnmp_assert_or_return(x, y) do { \ + if ( x ) \ + ; \ + else { \ + return y; \ + } \ + }while(0) +# define netsnmp_assert_or_msgreturn(x, y, z) do { \ + if ( x ) \ + ; \ + else { \ + return z; \ + } \ + }while(0) +# endif /* NO DEBUGGING */ +#endif /* not NETSNMP_USE_ASSERT */ + + +#define netsnmp_static_assert(x) \ + do { switch(0) { case (x): case 0: ; } } while(0) + + +/* + * EXPERIMENTAL macros. May be removed without warning in future + * releases. Use at your own risk + * + * The series of uppercase letters at or near the end of these macros give + * an indication of what they do. The letters used are: + * + * L : log a message + * RN : return NULL + * RE : return a specific hardcoded error appropriate for the condition + * RV : return user specified value + * + */ +#define netsnmp_malloc_check_LRN(ptr) \ + netsnmp_assert_or_return( (ptr) != NULL, NULL) +#define netsnmp_malloc_check_LRE(ptr) \ + netsnmp_assert_or_return( (ptr) != NULL, SNMPERR_MALLOC) +#define netsnmp_malloc_check_LRV(ptr, val) \ + netsnmp_assert_or_return( (ptr) != NULL, val) + +#define netsnmp_require_ptr_LRV( ptr, val ) \ + netsnmp_assert_or_return( (ptr) != NULL, val) + + +#endif /* SNMP_ASSERT_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_client.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_client.h new file mode 100644 index 00000000..ea54e7d0 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_client.h @@ -0,0 +1,167 @@ +/* + * snmp_client.h + */ +/*********************************************************** + Copyright 1988, 1989 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ + +#ifndef SNMP_CLIENT_H +#define SNMP_CLIENT_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + + struct snmp_pdu; + struct snmp_session; + struct variable_list; + + struct synch_state { + int waiting; + int status; + /* + * status codes + */ +#define STAT_SUCCESS 0 +#define STAT_ERROR 1 +#define STAT_TIMEOUT 2 + int reqid; + netsnmp_pdu *pdu; + }; + + NETSNMP_IMPORT + void snmp_replace_var_types(netsnmp_variable_list * vbl, + u_char old_type, + u_char new_type); + NETSNMP_IMPORT + void snmp_reset_var_buffers(netsnmp_variable_list * var); + void snmp_reset_var_types(netsnmp_variable_list * vbl, + u_char new_type); + NETSNMP_IMPORT + int count_varbinds(netsnmp_variable_list * var_ptr); + NETSNMP_IMPORT + int count_varbinds_of_type(netsnmp_variable_list * var_ptr, + u_char type); + netsnmp_variable_list *find_varbind_of_type(netsnmp_variable_list * + var_ptr, u_char type); + NETSNMP_IMPORT + netsnmp_variable_list *find_varbind_in_list(netsnmp_variable_list *vblist, + const oid *name, size_t len); + + netsnmp_pdu *snmp_split_pdu(netsnmp_pdu *, int skipCount, + int copyCount); + + unsigned long snmp_varbind_len(netsnmp_pdu *pdu); + NETSNMP_IMPORT + int snmp_clone_var(netsnmp_variable_list *, + netsnmp_variable_list *); + NETSNMP_IMPORT + int snmp_synch_response_cb(netsnmp_session *, + netsnmp_pdu *, netsnmp_pdu **, + snmp_callback); + NETSNMP_IMPORT + int snmp_clone_mem(void **, const void *, unsigned); + + +NETSNMP_IMPORT +void netsnmp_query_set_default_session(netsnmp_session *); +NETSNMP_IMPORT +netsnmp_session * netsnmp_query_get_default_session_unchecked( void ); +NETSNMP_IMPORT +netsnmp_session * netsnmp_query_get_default_session( void ); +NETSNMP_IMPORT +int netsnmp_query_get( netsnmp_variable_list *, netsnmp_session *); +NETSNMP_IMPORT +int netsnmp_query_getnext( netsnmp_variable_list *, netsnmp_session *); +NETSNMP_IMPORT +int netsnmp_query_walk( netsnmp_variable_list *, netsnmp_session *); +#ifndef NETSNMP_NO_WRITE_SUPPORT +NETSNMP_IMPORT +int netsnmp_query_set( netsnmp_variable_list *, netsnmp_session *); +#endif /* !NETSNMP_NO_WRITE_SUPPORT */ + +/** ************************************************************************** + * + * state machine + * + */ + /** forward declare */ + struct netsnmp_state_machine_step_s; + struct netsnmp_state_machine_input_s; + + /** state machine process */ + typedef int (netsnmp_state_machine_func)(struct netsnmp_state_machine_input_s *input, + struct netsnmp_state_machine_step_s *step); + + typedef struct netsnmp_state_machine_step_s { + + const char *name; /* primarily for logging/debugging */ + u_int sm_flags; + + netsnmp_state_machine_func *run; + int result; /* return code for this step */ + + + struct netsnmp_state_machine_step_s *on_success; + struct netsnmp_state_machine_step_s *on_error; + + /* + * user fields (not touched by state machine functions) + */ + u_int flags; + void *step_context; + + } netsnmp_state_machine_step; + + typedef struct netsnmp_state_machine_input_s { + const char *name; + int steps_so_far; + netsnmp_state_machine_step *steps; + netsnmp_state_machine_step *cleanup; + netsnmp_state_machine_step *last_run; + + /* + * user fields (not touched by state machine functions) + */ + void *input_context; + + } netsnmp_state_machine_input; + + + NETSNMP_IMPORT int + netsnmp_state_machine_run( netsnmp_state_machine_input *input ); + + NETSNMP_IMPORT int + netsnmp_row_create(netsnmp_session *sess, netsnmp_variable_list *vars, + int row_status_index); + + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_CLIENT_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_debug.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_debug.h new file mode 100644 index 00000000..7c2ed653 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_debug.h @@ -0,0 +1,251 @@ +/* + * Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef SNMP_DEBUG_H +#define SNMP_DEBUG_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * snmp_debug.h: + * + * - prototypes for snmp debugging routines. + * - easy to use macros to wrap around the functions. This also provides + * the ability to remove debugging code easily from the applications at + * compile time. + */ + + /* + * These functions should not be used, if at all possible. Instead, use + * the macros below. + */ + NETSNMP_IMPORT + void debugmsg(const char *token, const char *format, ...) + NETSNMP_ATTRIBUTE_FORMAT(printf, 2, 3); + NETSNMP_IMPORT + void debugmsgtoken(const char *token, const char *format, + ...) + NETSNMP_ATTRIBUTE_FORMAT(printf, 2, 3); + NETSNMP_IMPORT + void debug_combo_nc(const char *token, const char *format, + ...) + NETSNMP_ATTRIBUTE_FORMAT(printf, 2, 3); + NETSNMP_IMPORT + void debugmsg_oid(const char *token, const oid * theoid, + size_t len); + NETSNMP_IMPORT + void debugmsg_suboid(const char *token, const oid * theoid, + size_t len); + NETSNMP_IMPORT + void debugmsg_var(const char *token, + netsnmp_variable_list * var); + NETSNMP_IMPORT + void debugmsg_oidrange(const char *token, + const oid * theoid, size_t len, + size_t var_subid, oid range_ubound); + NETSNMP_IMPORT + void debugmsg_hex(const char *token, const u_char * thedata, + size_t len); + NETSNMP_IMPORT + void debugmsg_hextli(const char *token, const u_char * thedata, + size_t len); + NETSNMP_IMPORT + void debug_indent_add(int amount); + NETSNMP_IMPORT + void debug_indent_reset(void); + NETSNMP_IMPORT + int debug_indent_get(void); + NETSNMP_IMPORT + void debug_indent_reset(void); + /* + * What is said above is true for this function as well. Further this + * function is deprecated and only provided for backwards compatibility. + * Please use "%*s", debug_indent_get(), "" if you used this one before. + */ + NETSNMP_IMPORT + const char *debug_indent(void); + + /* + * Use these macros instead of the functions above to allow them to be + * re-defined at compile time to NOP for speed optimization. + * + * They need to be called enclosing all the arguments in a single set of ()s. + * Example: + * DEBUGMSGTL(("token", "debugging of something %s related\n", "snmp")); + * + * Usage: + * All of the functions take a "token" argument that helps determine when + * the output in question should be printed. See the snmpcmd.1 manual page + * on the -D flag to turn on/off output for a given token on the command line. + * + * DEBUGMSG((token, format, ...)): equivalent to printf(format, ...) + * (if "token" debugging output + * is requested by the user) + * + * DEBUGMSGT((token, format, ...)): equivalent to DEBUGMSG, but prints + * "token: " at the beginning of the + * line for you. + * + * DEBUGTRACE Insert this token anywhere you want + * tracing output displayed when the + * "trace" debugging token is selected. + * + * DEBUGMSGL((token, format, ...)): equivalent to DEBUGMSG, but includes + * DEBUGTRACE debugging line just before + * yours. + * + * DEBUGMSGTL((token, format, ...)): Same as DEBUGMSGL and DEBUGMSGT + * combined. + * + * Important: + * It is considered best if you use DEBUGMSGTL() everywhere possible, as it + * gives the nicest format output and provides tracing support just before + * every debugging statement output. + * + * To print multiple pieces to a single line in one call, use: + * + * DEBUGMSGTL(("token", "line part 1")); + * DEBUGMSG (("token", " and part 2\n")); + * + * to get: + * + * token: line part 1 and part 2 + * + * as debugging output. + * + * + * Each of these macros also have a version with a suffix of '_NC'. The + * NC suffix stands for 'No Check', which means that no check will be + * performed to see if debug is enabled or if the token has been turned + * on. These NC versions are intended for use within a DEBUG_IF {} block, + * where the debug/token check has already been performed. + */ + +#ifndef NETSNMP_NO_DEBUGGING /* make sure we're wanted */ + + /* + * define two macros : one macro with, one without, + * a test if debugging is enabled. + * + * Generally, use the macro with _DBG_IF_ + */ + +/******************* Start private macros ************************/ +#define _DBG_IF_ snmp_get_do_debugging() +#define DEBUGIF(x) if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS) + +#define __DBGMSGT(x) debugmsgtoken x, debugmsg x +#define __DBGMSG_NC(x) debugmsg x +#define __DBGMSGT_NC(x) debug_combo_nc x +#define __DBGMSGL_NC(x) __DBGTRACE; debugmsg x +#define __DBGMSGTL_NC(x) __DBGTRACE; debug_combo_nc x + +#ifdef NETSNMP_FUNCTION +#define __DBGTRACE __DBGMSGT(("trace","%s(): %s, %d:\n",\ + NETSNMP_FUNCTION,__FILE__,__LINE__)) +#define __DBGTRACETOK(x) __DBGMSGT((x,"%s(): %s, %d:\n", \ + NETSNMP_FUNCTION,__FILE__,__LINE__)) +#else +#define __DBGTRACE __DBGMSGT(("trace"," %s, %d:\n", __FILE__,__LINE__)) +#define __DBGTRACETOK(x) __DBGMSGT((x," %s, %d:\n", __FILE__,__LINE__)) +#endif + +#define __DBGMSGL(x) __DBGTRACE, debugmsg x +#define __DBGMSGTL(x) __DBGTRACE, debugmsgtoken x, debugmsg x +#define __DBGMSGOID(x) debugmsg_oid x +#define __DBGMSGSUBOID(x) debugmsg_suboid x +#define __DBGMSGVAR(x) debugmsg_var x +#define __DBGMSGOIDRANGE(x) debugmsg_oidrange x +#define __DBGMSGHEX(x) debugmsg_hex x +#define __DBGMSGHEXTLI(x) debugmsg_hextli x +#define __DBGINDENT() debug_indent_get() +#define __DBGINDENTADD(x) debug_indent_add(x) +#define __DBGINDENTMORE() debug_indent_add(2) +#define __DBGINDENTLESS() debug_indent_add(-2) +#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), "")) + +#define __DBGDUMPHEADER(token,x) \ + __DBGPRINTINDENT("dumph_" token); \ + debugmsg("dumph_" token,x); \ + if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS || \ + debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \ + (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS && \ + debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \ + debugmsg("dumph_" token,"\n"); \ + } else { \ + debugmsg("dumph_" token," "); \ + } \ + __DBGINDENTMORE() + +#define __DBGDUMPSECTION(token,x) \ + __DBGPRINTINDENT("dumph_" token); \ + debugmsg("dumph_" token,"%s\n",x);\ + __DBGINDENTMORE() + +#define __DBGDUMPSETUP(token,buf,len) \ + debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \ + __DBGMSGHEX(("dumpx_" token,buf,len)); \ + if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \ + debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \ + debugmsg("dumpx_" token,"\n"); \ + } else { \ + debugmsg("dumpx_" token," "); \ + } \ + debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), ""); + +/******************* End private macros ************************/ +/*****************************************************************/ +#endif /* NETSNMP_NO_DEBUGGING */ + +#ifdef __cplusplus +} +#endif + + /* Public macros moved to top-level API header file */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + void snmp_debug_init(void); + void snmp_debug_shutdown(void); + +#define MAX_DEBUG_TOKENS 256 +#define MAX_DEBUG_TOKEN_LEN 128 +#define DEBUG_TOKEN_DELIMITER "," +#define DEBUG_ALWAYS_TOKEN "all" + +#ifndef NETSNMP_NO_DEBUGGING + +/* + * internal: + * You probably shouldn't be using this information unless the word + * "expert" applies to you. I know it looks tempting. + */ +typedef struct netsnmp_token_descr_s { + char *token_name; + char enabled; +} netsnmp_token_descr; + +NETSNMP_IMPORT int debug_num_tokens; +NETSNMP_IMPORT netsnmp_token_descr dbg_tokens[MAX_DEBUG_TOKENS]; + +#endif /* NETSNMP_NO_DEBUGGING */ + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_DEBUG_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_enum.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_enum.h new file mode 100644 index 00000000..0dab3a5d --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_enum.h @@ -0,0 +1,127 @@ +#ifndef SNMP_ENUM_H +#define SNMP_ENUM_H + +/* + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifdef __cplusplus +extern "C" { +#endif + + struct snmp_enum_list { + struct snmp_enum_list *next; + int value; + char *label; + }; + +#define SE_MAX_IDS 5 +#define SE_MAX_SUBIDS 32 /* needs to be a multiple of 8 */ + + /* + * begin storage definitions + */ + /* + * These definitions correspond with the "storid" argument to the API + */ +#define SE_LIBRARY_ID 0 +#define SE_MIB_ID 1 +#define SE_APPLICATION_ID 2 +#define SE_ASSIGNED_ID 3 + + /* + * library specific enum locations + */ + + /* + * error codes + */ +#define SE_OK 0 +#define SE_NOMEM 1 +#define SE_ALREADY_THERE 2 +#define SE_DNE -2 + + int init_snmp_enum(const char *type); + struct snmp_enum_list *se_find_list(unsigned int major, + unsigned int minor); + struct snmp_enum_list *se_find_slist(const char *listname); + int se_store_in_list(struct snmp_enum_list *, + unsigned int major, unsigned int minor); + int se_find_value(unsigned int major, unsigned int minor, + const char *label); + int se_find_free_value(unsigned int major, unsigned int minor); + char *se_find_label(unsigned int major, unsigned int minor, + int value); + /** + * Add the pair (label, value) to the list (major, minor). Transfers + * ownership of the memory pointed to by label to the list: + * clear_snmp_enum() deallocates that memory. + */ + int se_add_pair(unsigned int major, unsigned int minor, + char *label, int value); + + /* + * finds a list of enums in a list of enum structs associated by a name. + */ + /* + * find a list, and then operate on that list + * ( direct methods further below if you already have the list pointer) + */ + NETSNMP_IMPORT + char *se_find_label_in_slist(const char *listname, + int value); + NETSNMP_IMPORT + int se_find_value_in_slist(const char *listname, + const char *label); + NETSNMP_IMPORT + int se_find_casevalue_in_slist(const char *listname, + const char *label); + int se_find_free_value_in_slist(const char *listname); + /** + * Add the pair (label, value) to the slist with name listname. Transfers + * ownership of the memory pointed to by label to the list: + * clear_snmp_enum() deallocates that memory. + */ + NETSNMP_IMPORT + int se_add_pair_to_slist(const char *listname, char *label, + int value); + + /* + * operates directly on a possibly external list + */ + char *se_find_label_in_list(struct snmp_enum_list *list, + int value); + int se_find_value_in_list(struct snmp_enum_list *list, + const char *label); + int se_find_casevalue_in_list(struct snmp_enum_list *list, + const char *label); + int se_find_free_value_in_list(struct snmp_enum_list *list); + int se_add_pair_to_list(struct snmp_enum_list **list, + char *label, int value); + + /* + * Persistent enumeration lists + */ + void se_store_enum_list(struct snmp_enum_list *new_list, + const char *token, const char *type); + void se_store_list(unsigned int major, unsigned int minor, + const char *type); + void se_clear_slist(const char *listname); + void se_store_slist(const char *listname, const char *type); + int se_store_slist_callback(int majorID, int minorID, + void *serverargs, void *clientargs); + void se_read_conf(const char *word, const char *cptr); + /** + * Deallocate the memory allocated by init_snmp_enum(): remove all key/value + * pairs stored by se_add_*() calls. + */ + NETSNMP_IMPORT + void clear_snmp_enum(void); + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_ENUM_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_impl.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_impl.h new file mode 100644 index 00000000..f79aebd9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_impl.h @@ -0,0 +1,146 @@ +#ifndef SNMP_IMPL_H +#define SNMP_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + /* + * * file: snmp_impl.h + */ + + /* + * Definitions for SNMP implementation. + * + * + */ +/*********************************************************** + Copyright 1988, 1989 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ + +#include +#include /* for 'u_char', etc */ + +#define COMMUNITY_MAX_LEN 256 + + /* + * Space for character representation of an object identifier + */ +#define SPRINT_MAX_LEN 2560 + + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#define READ 1 +#define WRITE 0 + +#define RESERVE1 0 +#define RESERVE2 1 +#define ACTION 2 +#define COMMIT 3 +#define FREE 4 +#define UNDO 5 +#define FINISHED_SUCCESS 9 +#define FINISHED_FAILURE 10 + + /* + * Access control statements for the agent + */ +#define NETSNMP_OLDAPI_RONLY 0x1 /* read access only */ +#define NETSNMP_OLDAPI_RWRITE 0x2 /* read and write access (must have 0x2 bit set) */ +#define NETSNMP_OLDAPI_NOACCESS 0x0000 /* no access for anybody */ + +#ifndef NETSNMP_NO_LEGACY_DEFINITIONS +#define RONLY NETSNMP_OLDAPI_RONLY +#define RWRITE NETSNMP_OLDAPI_RWRITE +#define NOACCESS NETSNMP_OLDAPI_NOACCESS +#endif + + /* + * defined types (from the SMI, RFC 1157) + */ +#define ASN_IPADDRESS (ASN_APPLICATION | 0) +#define ASN_COUNTER (ASN_APPLICATION | 1) +#define ASN_GAUGE (ASN_APPLICATION | 2) +#define ASN_UNSIGNED (ASN_APPLICATION | 2) /* RFC 1902 - same as GAUGE */ +#define ASN_TIMETICKS (ASN_APPLICATION | 3) +#define ASN_OPAQUE (ASN_APPLICATION | 4) /* changed so no conflict with other includes */ + + /* + * defined types (from the SMI, RFC 1442) + */ +#define ASN_NSAP (ASN_APPLICATION | 5) /* historic - don't use */ +#define ASN_COUNTER64 (ASN_APPLICATION | 6) +#define ASN_UINTEGER (ASN_APPLICATION | 7) /* historic - don't use */ + +#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + /* + * defined types from draft-perkins-opaque-01.txt + */ +#define ASN_FLOAT (ASN_APPLICATION | 8) +#define ASN_DOUBLE (ASN_APPLICATION | 9) +#define ASN_INTEGER64 (ASN_APPLICATION | 10) +#define ASN_UNSIGNED64 (ASN_APPLICATION | 11) +#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */ + + /* + * changed to ERROR_MSG to eliminate conflict with other includes + */ +#ifndef ERROR_MSG +#define ERROR_MSG(string) snmp_set_detail(string) +#endif + + /* + * from snmp.c + */ + extern u_char sid[]; /* size SID_MAX_LEN */ + NETSNMP_IMPORT int snmp_errno; + + + /* + * For calling secauth_build, FIRST_PASS is an indication that a new nonce + * and lastTimeStamp should be recorded. LAST_PASS is an indication that + * the packet should be checksummed and encrypted if applicable, in + * preparation for transmission. + * 0 means do neither, FIRST_PASS | LAST_PASS means do both. + * For secauth_parse, FIRST_PASS means decrypt the packet, otherwise leave it + * alone. LAST_PASS is ignored. + */ +#define FIRST_PASS 1 +#define LAST_PASS 2 + u_char *snmp_comstr_parse(u_char *, size_t *, u_char *, + size_t *, long *); + u_char *snmp_comstr_build(u_char *, size_t *, u_char *, + size_t *, long *, size_t); + + int has_access(u_char, int, int, int); +#ifdef __cplusplus +} +#endif +#endif /* SNMP_IMPL_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_logging.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_logging.h new file mode 100644 index 00000000..1278c119 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_logging.h @@ -0,0 +1,138 @@ +#ifndef SNMP_LOGGING_H +#define SNMP_LOGGING_H + +#include +#include + +#ifdef HAVE_SYSLOG_H +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef LOG_ERR +#define LOG_EMERG 0 /* system is unusable */ +#define LOG_ALERT 1 /* action must be taken immediately */ +#define LOG_CRIT 2 /* critical conditions */ +#define LOG_ERR 3 /* error conditions */ +#define LOG_WARNING 4 /* warning conditions */ +#define LOG_NOTICE 5 /* normal but significant condition */ +#define LOG_INFO 6 /* informational */ +#define LOG_DEBUG 7 /* debug-level messages */ +#endif + + struct snmp_log_message { + int priority; + const char *msg; + }; + +#ifndef DEFAULT_LOG_ID +#define DEFAULT_LOG_ID "net-snmp" +#endif + +#define NETSNMP_LOGONCE(x) do { \ + static char logged = 0; \ + if (!logged) { \ + logged = 1; \ + snmp_log x ; \ + } \ + } while(0) + + void init_snmp_logging(void); + NETSNMP_IMPORT + void snmp_disable_syslog(void); + void snmp_disable_filelog(void); + NETSNMP_IMPORT + void snmp_disable_stderrlog(void); + void snmp_disable_calllog(void); + NETSNMP_IMPORT + void snmp_enable_syslog(void); + NETSNMP_IMPORT + void snmp_enable_syslog_ident(const char *ident, + const int facility); + NETSNMP_IMPORT + void snmp_enable_filelog(const char *logfilename, + int dont_zero_log); + NETSNMP_IMPORT + void snmp_enable_stderrlog(void); + NETSNMP_IMPORT + void snmp_enable_calllog(void); + + NETSNMP_IMPORT + int snmp_stderrlog_status(void); + + +#define NETSNMP_LOGHANDLER_STDOUT 1 +#define NETSNMP_LOGHANDLER_STDERR 2 +#define NETSNMP_LOGHANDLER_FILE 3 +#define NETSNMP_LOGHANDLER_SYSLOG 4 +#define NETSNMP_LOGHANDLER_CALLBACK 5 +#define NETSNMP_LOGHANDLER_NONE 6 + + NETSNMP_IMPORT + void netsnmp_set_line_buffering(FILE *stream); + NETSNMP_IMPORT + int snmp_log_options(char *optarg, int argc, char *const *argv); + NETSNMP_IMPORT + void snmp_log_options_usage(const char *lead, FILE *outf); + NETSNMP_IMPORT + char *snmp_log_syslogname(const char *syslogname); + typedef struct netsnmp_log_handler_s netsnmp_log_handler; + typedef int (NetsnmpLogHandler)(netsnmp_log_handler*, int, const char *); +#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO + NetsnmpLogHandler log_handler_stdouterr; +#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */ + NetsnmpLogHandler log_handler_file; + NetsnmpLogHandler log_handler_syslog; + NetsnmpLogHandler log_handler_callback; + NetsnmpLogHandler log_handler_null; + + struct netsnmp_log_handler_s { + int enabled; + int priority; + int pri_max; + int type; + const char *token; /* Also used for filename */ + + NetsnmpLogHandler *handler; + + int imagic; /* E.g. file descriptor, syslog facility */ + void *magic; /* E.g. Callback function */ + + netsnmp_log_handler *next, *prev; + }; + +NETSNMP_IMPORT +netsnmp_log_handler *get_logh_head( void ); +NETSNMP_IMPORT +netsnmp_log_handler *netsnmp_register_loghandler( int type, int pri ); +netsnmp_log_handler *netsnmp_find_loghandler( const char *token ); +int netsnmp_add_loghandler( netsnmp_log_handler *logh ); +NETSNMP_IMPORT +int netsnmp_remove_loghandler( netsnmp_log_handler *logh ); +int netsnmp_enable_loghandler( const char *token ); +int netsnmp_disable_loghandler( const char *token ); +NETSNMP_IMPORT +void netsnmp_enable_this_loghandler( netsnmp_log_handler *logh ); +NETSNMP_IMPORT +void netsnmp_disable_this_loghandler( netsnmp_log_handler *logh ); +NETSNMP_IMPORT +void netsnmp_logging_restart(void); + +NETSNMP_IMPORT +netsnmp_log_handler * +netsnmp_create_stdio_loghandler(int is_stdout, int priority, int priority_max, + const char *tok); +NETSNMP_IMPORT +netsnmp_log_handler * +netsnmp_register_filelog_handler(const char* logfilename, int priority, + int priority_max, int dont_zero_log); + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_LOGGING_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_parse_args.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_parse_args.h new file mode 100644 index 00000000..6f6f9663 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_parse_args.h @@ -0,0 +1,91 @@ +#ifndef SNMP_PARSE_ARGS_H +#define SNMP_PARSE_ARGS_H + +/** + * @file snmp_parse_args.h + * + * Support for initializing variables of type netsnmp_session from command + * line arguments + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** Don't enable any logging even if there is no -L argument */ +#define NETSNMP_PARSE_ARGS_NOLOGGING 0x0001 +/** Don't zero out sensitive arguments as they are not on the command line + * anyway, typically used when the function is called from an internal + * config-line handler + */ +#define NETSNMP_PARSE_ARGS_NOZERO 0x0002 + +/** + * Parsing of command line arguments succeeded and application is expected + * to continue with normal operation. + */ +#define NETSNMP_PARSE_ARGS_SUCCESS 0 +/** + * Parsing of command line arguments succeeded, but the application is expected + * to exit with zero exit code. For example, '-V' parameter has been found. + */ +#define NETSNMP_PARSE_ARGS_SUCCESS_EXIT -2 +/** + * Parsing of command line arguments failed and application is expected to show + * usage (i.e. list of parameters) and exit with nozero exit code. + */ +#define NETSNMP_PARSE_ARGS_ERROR_USAGE -1 +/** + * Parsing of command line arguments failed and application is expected to exit + * with nozero exit code. netsnmp_parse_args() has already printed what went + * wrong. + */ +#define NETSNMP_PARSE_ARGS_ERROR -3 + +/** + * Parse an argument list and initialize netsnmp_session from it. + * @param argc Number of elements in argv + * @param argv string array of at least argc elements + * @param session + * @param localOpts Additional option characters to accept + * @param proc function pointer used to process any unhandled arguments + * @param flags flags directing how to handle the string + * + * @retval 0 (= #NETSNMP_PARSE_ARGS_SUCCESS) on success + * @retval #NETSNMP_PARSE_ARGS_SUCCESS_EXIT when the application is expected + * to exit with zero exit code (e.g. '-V' option was found) + * @retval #NETSNMP_PARSE_ARGS_ERROR_USAGE when the function failed to parse + * the command line and the application is expected to show it's usage + * @retval #NETSNMP_PARSE_ARGS_ERROR when the function failed to parse + * the command line and it has already printed enough information for the user + * and no other output is needed + * + * The proc function is called with argc, argv and the currently processed + * option as arguments + */ +NETSNMP_IMPORT int +netsnmp_parse_args(int argc, char **argv, netsnmp_session *session, + const char *localOpts, void (*proc)(int, char *const *, int), + int flags); + +/** + * Calls \link netsnmp_parse_args() + * netsnmp_parse_args(argc, argv, session, localOpts, proc, 0)\endlink + */ +NETSNMP_IMPORT +int +snmp_parse_args(int argc, char **argv, netsnmp_session *session, + const char *localOpts, void (*proc)(int, char *const *, int)); + +NETSNMP_IMPORT +void +snmp_parse_args_descriptions(FILE *); + +NETSNMP_IMPORT +void +snmp_parse_args_usage(FILE *); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_secmod.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_secmod.h new file mode 100644 index 00000000..937f2356 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_secmod.h @@ -0,0 +1,182 @@ +#ifndef SNMPSECMOD_H +#define SNMPSECMOD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Locally defined security models. + * (Net-SNMP enterprise number = 8072)*256 + local_num + */ +#define NETSNMP_SEC_MODEL_KSM 2066432 +#define NETSNMP_KSM_SECURITY_MODEL NETSNMP_SEC_MODEL_KSM +#define NETSNMP_TSM_SECURITY_MODEL SNMP_SEC_MODEL_TSM + +struct snmp_secmod_def; + +/* + * parameter information passed to security model routines + */ +struct snmp_secmod_outgoing_params { + int msgProcModel; + u_char *globalData; + size_t globalDataLen; + int maxMsgSize; + int secModel; + u_char *secEngineID; + size_t secEngineIDLen; + char *secName; + size_t secNameLen; + int secLevel; + u_char *scopedPdu; + size_t scopedPduLen; + void *secStateRef; + u_char *secParams; + size_t *secParamsLen; + u_char **wholeMsg; + size_t *wholeMsgLen; + size_t *wholeMsgOffset; + netsnmp_pdu *pdu; /* IN - the pdu getting encoded */ + netsnmp_session *session; /* IN - session sending the message */ +}; + +struct snmp_secmod_incoming_params { + int msgProcModel; /* IN */ + size_t maxMsgSize; /* IN - Used to calc maxSizeResponse. */ + + u_char *secParams; /* IN - BER encoded securityParameters. */ + int secModel; /* IN */ + int secLevel; /* IN - AuthNoPriv; authPriv etc. */ + + u_char *wholeMsg; /* IN - Original v3 message. */ + size_t wholeMsgLen; /* IN - Msg length. */ + + u_char *secEngineID; /* OUT - Pointer snmpEngineID. */ + size_t *secEngineIDLen; /* IN/OUT - Len available; len returned. */ + /* + * NOTE: Memory provided by caller. + */ + + char *secName; /* OUT - Pointer to securityName. */ + size_t *secNameLen; /* IN/OUT - Len available; len returned. */ + + u_char **scopedPdu; /* OUT - Pointer to plaintext scopedPdu. */ + size_t *scopedPduLen; /* IN/OUT - Len available; len returned. */ + + size_t *maxSizeResponse; /* OUT - Max size of Response PDU. */ + void **secStateRef; /* OUT - Ref to security state. */ + netsnmp_session *sess; /* IN - session which got the message */ + netsnmp_pdu *pdu; /* IN - the pdu getting parsed */ + u_char msg_flags; /* IN - v3 Message flags. */ +}; + + +/* + * function pointers: + */ + +/* + * free's a given security module's data; called at unregistration time + */ +typedef int (SecmodSessionCallback) (netsnmp_session *); +typedef int (SecmodPduCallback) (netsnmp_pdu *); +typedef int (Secmod2PduCallback) (netsnmp_pdu *, netsnmp_pdu *); +typedef int (SecmodOutMsg) (struct snmp_secmod_outgoing_params *); +typedef int (SecmodInMsg) (struct snmp_secmod_incoming_params *); +typedef void (SecmodFreeState) (void *); +typedef void (SecmodHandleReport) (struct session_list *slp, + netsnmp_transport *transport, + netsnmp_session *, + int result, + netsnmp_pdu *origpdu); +typedef int (SecmodDiscoveryMethod) (struct session_list *slp, + netsnmp_session *session); +typedef int (SecmodPostDiscovery) (struct session_list *slp, + netsnmp_session *session); + +typedef int (SecmodSessionSetup) (netsnmp_session *in_session, + netsnmp_session *out_session); +/* + * definition of a security module + */ + +/* + * all of these callback functions except the encoding and decoding + * routines are optional. The rest of them are available if need. + */ +struct snmp_secmod_def { + /* + * session maniplation functions + */ + SecmodSessionCallback *session_open; /* called in snmp_sess_open() */ + SecmodSessionCallback *session_close; /* called in snmp_sess_close() */ + SecmodSessionSetup *session_setup; + + /* + * pdu manipulation routines + */ + SecmodPduCallback *pdu_free; /* called in free_pdu() */ + Secmod2PduCallback *pdu_clone; /* called in snmp_clone_pdu() */ + SecmodPduCallback *pdu_timeout; /* called when request timesout */ + SecmodFreeState *pdu_free_state_ref; /* frees pdu->securityStateRef */ + + /* + * de/encoding routines: mandatory + */ + SecmodOutMsg *encode_reverse; /* encode packet back to front */ + SecmodOutMsg *encode_forward; /* encode packet forward */ + SecmodInMsg *decode; /* decode & validate incoming */ + + /* + * error and report handling + */ + SecmodHandleReport *handle_report; + + /* + * default engineID discovery mechanism + */ + SecmodDiscoveryMethod *probe_engineid; + SecmodPostDiscovery *post_probe_engineid; +}; + + +/* + * internal list + */ +struct snmp_secmod_list { + int securityModel; + struct snmp_secmod_def *secDef; + struct snmp_secmod_list *next; +}; + + +/* + * register a security service + */ +int register_sec_mod(int, const char *, + struct snmp_secmod_def *); +/* + * find a security service definition + */ +NETSNMP_IMPORT +struct snmp_secmod_def *find_sec_mod(int); +/* + * register a security service + */ +int unregister_sec_mod(int); /* register a security service */ +void init_secmod(void); +NETSNMP_IMPORT +void shutdown_secmod(void); + +/* + * clears the sec_mod list + */ +NETSNMP_IMPORT +void clear_sec_mod(void); + +#ifdef __cplusplus +} +#endif +#endif /* SNMPSECMOD_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_service.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_service.h new file mode 100644 index 00000000..711f6769 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_service.h @@ -0,0 +1,39 @@ +#ifndef _SNMP_SERVICE_H +#define _SNMP_SERVICE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Default port handling */ + +NETSNMP_IMPORT int +netsnmp_register_default_domain(const char* application, const char* domain); + +extern const char* +netsnmp_lookup_default_domain(const char* application); + +extern const char* const * +netsnmp_lookup_default_domains(const char* application); + +extern void +netsnmp_clear_default_domain(void); + +NETSNMP_IMPORT int +netsnmp_register_default_target(const char* application, const char* domain, + const char* target); + +extern const char* +netsnmp_lookup_default_target(const char* application, const char* domain); + +extern void +netsnmp_clear_default_target(void); + +NETSNMP_IMPORT void +netsnmp_register_service_handlers(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SNMP_SERVICE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmp_transport.h b/illumos-x86_64/usr/include/net-snmp/library/snmp_transport.h new file mode 100644 index 00000000..d005d452 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmp_transport.h @@ -0,0 +1,392 @@ +#ifndef _SNMP_TRANSPORT_H +#define _SNMP_TRANSPORT_H + +/* + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ +#include + +#ifdef HAVE_SYS_SOCKET_H +#ifdef solaris2 +#define _XPG4_2 +#endif + +#if defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7) +#define _LINUX_SOURCE_COMPAT +#endif + +#include + +#ifdef solaris2 +# ifndef CMSG_SPACE +# define CMSG_SPACE(l) \ + ((unsigned int)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l))) +# define CMSG_LEN(l) (_CMSG_HDR_ALIGN(sizeof(struct cmsghdr)) + (l)) +# endif +#endif +#endif /* HAVE_SYS_SOCKET_H */ + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Some transport-type constants. */ + +#ifndef NETSNMP_STREAM_QUEUE_LEN +#define NETSNMP_STREAM_QUEUE_LEN 5 +#endif + +/* Some transport-type flags. */ + +#define NETSNMP_TRANSPORT_FLAG_STREAM 0x01 +#define NETSNMP_TRANSPORT_FLAG_LISTEN 0x02 +#define NETSNMP_TRANSPORT_FLAG_TUNNELED 0x04 +#define NETSNMP_TRANSPORT_FLAG_TMSTATE 0x08 /* indicates opaque is a + TSM tmStateReference */ +#define NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10 +#define NETSNMP_TRANSPORT_FLAG_OPENED 0x20 /* f_open called */ +#define NETSNMP_TRANSPORT_FLAG_SHARED 0x40 +#define NETSNMP_TRANSPORT_FLAG_HOSTNAME 0x80 /* for fmtaddr hook */ + +/* The standard SNMP domains. */ + +NETSNMP_IMPORT oid netsnmpUDPDomain[]; /* = { 1, 3, 6, 1, 6, 1, 1 }; */ +NETSNMP_IMPORT oid netsnmpCLNSDomain[]; /* = { 1, 3, 6, 1, 6, 1, 2 }; */ +NETSNMP_IMPORT oid netsnmpCONSDomain[]; /* = { 1, 3, 6, 1, 6, 1, 3 }; */ +NETSNMP_IMPORT oid netsnmpDDPDomain[]; /* = { 1, 3, 6, 1, 6, 1, 4 }; */ +NETSNMP_IMPORT oid netsnmpIPXDomain[]; /* = { 1, 3, 6, 1, 6, 1, 5 }; */ +NETSNMP_IMPORT size_t netsnmpUDPDomain_len; +NETSNMP_IMPORT size_t netsnmpCLNSDomain_len; +NETSNMP_IMPORT size_t netsnmpCONSDomain_len; +NETSNMP_IMPORT size_t netsnmpDDPDomain_len; +NETSNMP_IMPORT size_t netsnmpIPXDomain_len; + +/* Structure which stores transport security model specific parameters */ +/* isms-secshell-11 section 4.1 */ + +/* contents documented in draft-ietf-isms-transport-security-model + Section 3.2 */ +/* note: VACM only allows <= 32 so this is overkill till another ACM comes */ +#define NETSNMP_TM_MAX_SECNAME 256 + +typedef union netsnmp_sockaddr_storage_u { + struct sockaddr sa; + struct sockaddr_in sin; +#ifdef NETSNMP_ENABLE_IPV6 + struct sockaddr_in6 sin6; +#endif +} netsnmp_sockaddr_storage; + +typedef struct netsnmp_addr_pair_s { + netsnmp_sockaddr_storage remote_addr; + netsnmp_sockaddr_storage local_addr; +} netsnmp_addr_pair; + +typedef struct netsnmp_indexed_addr_pair_s { + netsnmp_sockaddr_storage remote_addr; + netsnmp_sockaddr_storage local_addr; + int if_index; +} netsnmp_indexed_addr_pair; + +typedef struct netsnmp_tmStateReference_s { + oid transportDomain[MAX_OID_LEN]; + size_t transportDomainLen; + char securityName[NETSNMP_TM_MAX_SECNAME]; + size_t securityNameLen; + int requestedSecurityLevel; + int transportSecurityLevel; + char sameSecurity; + char sessionID[8]; + + char have_addresses; + netsnmp_indexed_addr_pair addresses; + + void *otherTransportOpaque; /* XXX: May have mem leak issues */ +} netsnmp_tmStateReference; + +#define NETSNMP_TSPEC_LOCAL 0x01 /* 1=server, 0=client */ +#define NETSNMP_TSPEC_PREBOUND 0x02 /* 1=bound by systemd, 0=needs bind in the library */ + +struct netsnmp_container_s; /* forward decl */ +typedef struct netsnmp_tdomain_spec_s { + const char *application; /* application name */ + const char *target; /* target as string */ + u_int flags; + const char *default_domain; /* default domain */ + const char *default_target; /* default target */ + const char *source; /* source as string iff remote */ + struct netsnmp_container_s *transport_config; /* extra config */ +} netsnmp_tdomain_spec; + +/* Structure which defines the transport-independent API. */ + +struct snmp_session; + +typedef struct netsnmp_transport_s { + /* The transport domain object identifier. */ + + const oid *domain; + int domain_length; /* In sub-IDs, not octets. */ + + /* Local transport address (in relevant SNMP-style encoding). */ + + void *local; + int local_length; /* In octets. */ + + /* Remote transport address (in relevant SNMP-style encoding). */ + + void *remote; + int remote_length; /* In octets. */ + + /* The actual socket. */ + + int sock; + + /* Flags (see #definitions above). */ + + unsigned int flags; + + /* Protocol-specific opaque data pointer. */ + + void *data; + int data_length; + + /* Maximum size of PDU that can be sent/received by this transport. */ + + size_t msgMaxSize; + +#ifdef FOR_STANDARDS_COMPLIANCE_OR_FUTURE_USE + /* TM state reference per ISMS WG solution */ + netsnmp_tmStateReference *tmStateRef; +#endif + + /* tunneled transports */ + struct netsnmp_transport_s * base_transport; + + /* Callbacks. Arguments are: + * + * "this" pointer, fd, buf, size, *opaque, *opaque_length + */ + + int (*f_recv) (struct netsnmp_transport_s *, void *, + int, void **, int *); + int (*f_send) (struct netsnmp_transport_s *, const void *, + int, void **, int *); + int (*f_close) (struct netsnmp_transport_s *); + + /* Optional: opening can occur during creation if more appropriate */ + struct netsnmp_transport_s * (*f_open) (struct netsnmp_transport_s *); + + /* This callback is only necessary for stream-oriented transports. */ + + int (*f_accept) (struct netsnmp_transport_s *); + + /* Optional callback to format a transport address. */ + + char *(*f_fmtaddr)(struct netsnmp_transport_s *, const void *, + int); + + /* Optional callback to support extra configuration token/value pairs */ + /* return non-zero on error */ + int (*f_config)(struct netsnmp_transport_s *, const char *, + const char *); + + /* Optional callback that is called after the first transport is + cloned to the second */ + int (*f_copy)(const struct netsnmp_transport_s *, + struct netsnmp_transport_s *); + + /* Setup initial session config if special things are needed */ + int (*f_setup_session)(struct netsnmp_transport_s *, + struct snmp_session *); + + /* allocated host name identifier; used by configuration system + to load localhost.conf for host-specific configuration */ + u_char *identifier; /* udp:localhost:161 -> "localhost" */ + + /* Duplicate the remote address in the format required by SNMP-TARGET-MIB */ + void (*f_get_taddr)(struct netsnmp_transport_s *t, + void **addr, size_t *addr_len); + +} netsnmp_transport; + +typedef struct netsnmp_transport_list_s { + netsnmp_transport *transport; + struct netsnmp_transport_list_s *next; +} netsnmp_transport_list; + +typedef struct netsnmp_tdomain_s { + const oid *name; + size_t name_length; + const char **prefix; + + /* + * The f_create_from_tstring and f_create_from_tstring_new fields are + * deprecated, please do not use them for new code and try to migrate + * old code away from using them. + */ + netsnmp_transport *(*f_create_from_tstring) (const char *, int); + + /* @o and @o_len define an address in the format used by SNMP-TARGET-MIB */ + netsnmp_transport *(*f_create_from_ostring) (const void *o, size_t o_len, + int local); + + struct netsnmp_tdomain_s *next; + + /** deprecated, please do not use it */ + netsnmp_transport *(*f_create_from_tstring_new) (const char *, int, + const char*); + netsnmp_transport *(*f_create_from_tspec) (netsnmp_tdomain_spec *); + +} netsnmp_tdomain; + +void init_snmp_transport(void); +void shutdown_snmp_transport(void); + +/* Some utility functions. */ + +NETSNMP_IMPORT +char *netsnmp_transport_peer_string(netsnmp_transport *t, const void *data, + int len); + +int netsnmp_transport_send(netsnmp_transport *t, const void *data, int len, + void **opaque, int *olength); +int netsnmp_transport_recv(netsnmp_transport *t, void *data, int len, + void **opaque, int *olength); + +int netsnmp_transport_add_to_list(netsnmp_transport_list **transport_list, + netsnmp_transport *transport); +int netsnmp_transport_remove_from_list(netsnmp_transport_list **transport_list, + netsnmp_transport *transport); +NETSNMP_IMPORT +int netsnmp_sockaddr_size(const struct sockaddr *sa); + + +/* + * Return an exact (deep) copy of t, or NULL if there is a memory allocation + * problem (for instance). + */ + +netsnmp_transport *netsnmp_transport_copy(const netsnmp_transport *t); + + +/* Free an netsnmp_transport. */ + +NETSNMP_IMPORT +void netsnmp_transport_free(netsnmp_transport *t); + +#ifndef FEATURE_REMOVE_TRANSPORT_CACHE + +/** transport cache support */ + +NETSNMP_IMPORT +netsnmp_transport *netsnmp_transport_cache_get(int af, int type, int local, + const netsnmp_sockaddr_storage *bind_addr); + +NETSNMP_IMPORT +int netsnmp_transport_cache_save(int af, int type, int local, + const netsnmp_sockaddr_storage *addr, + netsnmp_transport *t); + +NETSNMP_IMPORT +int netsnmp_transport_cache_remove(netsnmp_transport *t); + +#endif /* FEATURE_REMOVE_TRANSPORT_CACHE */ + +/* + * If the passed oid (in_oid, in_len) corresponds to a supported transport + * domain, return 1; if not return 0. If out_oid is not NULL and out_len is + * not NULL, then the "internal" oid which should be used to identify this + * domain (e.g. in pdu->tDomain etc.) is written to *out_oid and its length to + * *out_len. + */ + +NETSNMP_IMPORT +int netsnmp_tdomain_support(const oid *in_oid, size_t in_len, + const oid **out_oid, size_t *out_len); + +int netsnmp_tdomain_register(netsnmp_tdomain *domain); + +int netsnmp_tdomain_unregister(netsnmp_tdomain *domain); + +NETSNMP_IMPORT +void netsnmp_clear_tdomain_list(void); + +void netsnmp_tdomain_init(void); + +NETSNMP_IMPORT +netsnmp_transport *netsnmp_tdomain_transport(const char *str, + int local, + const char *default_domain); + +NETSNMP_IMPORT +netsnmp_transport *netsnmp_tdomain_transport_full(const char *application, + const char *str, + int local, + const char *default_domain, + const char *default_target); + +NETSNMP_IMPORT +netsnmp_transport *netsnmp_tdomain_transport_oid(const oid * dom, + size_t dom_len, + const u_char * o, + size_t o_len, + int local); + +NETSNMP_IMPORT +netsnmp_transport *netsnmp_tdomain_transport_tspec(netsnmp_tdomain_spec *tspec); + +NETSNMP_IMPORT +netsnmp_transport* +netsnmp_transport_open_client(const char* application, const char* str); + +NETSNMP_IMPORT +netsnmp_transport* +netsnmp_transport_open_server(const char* application, const char* str); + +netsnmp_transport* +netsnmp_transport_open(const char* application, const char* str, int local); + +typedef struct netsnmp_transport_config_s { + char *key; + char *value; +} netsnmp_transport_config; + +NETSNMP_IMPORT +int netsnmp_transport_config_compare(netsnmp_transport_config *left, + netsnmp_transport_config *right); +NETSNMP_IMPORT +netsnmp_transport_config *netsnmp_transport_create_config(const char *key, + const char *value); + +#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE +NETSNMP_IMPORT +void netsnmp_transport_parse_filterType(const char *word, char *cptr); + +NETSNMP_IMPORT +int netsnmp_transport_filter_add(const char *addrtxt); + +NETSNMP_IMPORT +int netsnmp_transport_filter_remove(const char *addrtxt); + +NETSNMP_IMPORT +int netsnmp_transport_filter_check(const char *addrtxt); + +NETSNMP_IMPORT +void netsnmp_transport_filter_cleanup(void); + +#endif /* NETSNMP_FEATURE_REMOVE_FILTER_SOURCE */ + +#ifdef __cplusplus +} +#endif +#endif/*_SNMP_TRANSPORT_H*/ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpusm.h b/illumos-x86_64/usr/include/net-snmp/library/snmpusm.h new file mode 100644 index 00000000..a97aeb22 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpusm.h @@ -0,0 +1,193 @@ +/* + * snmpusm.h + * + * Header file for USM support. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef SNMPUSM_H +#define SNMPUSM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define WILDCARDSTRING "*" + + /* + * General. + */ +#define USM_MAX_ID_LENGTH 1024 /* In bytes. */ +#define USM_MAX_SALT_LENGTH 128 /* In BITS. */ +#define USM_DES_SALT_LENGTH 64 /* In BITS. */ +#define USM_AES_SALT_LENGTH 128 /* In BITS. */ +#define USM_MAX_KEYEDHASH_LENGTH 128 /* In BITS. */ + +#define USM_TIME_WINDOW 150 +#define USM_MD5_AND_SHA_AUTH_LEN 12 /* bytes */ +#define USM_HMAC128SHA224_AUTH_LEN 16 /* OPTIONAL */ +#define USM_HMAC192SHA256_AUTH_LEN 24 /* MUST */ +#define USM_HMAC256SHA384_AUTH_LEN 32 /* OPTIONAL */ +#define USM_HMAC384SHA512_AUTH_LEN 48 /* SHOULD */ +#define USM_MAX_AUTHSIZE USM_HMAC384SHA512_AUTH_LEN + +#define USM_SEC_MODEL_NUMBER SNMP_SEC_MODEL_USM + + /* + * Structures. + */ + struct usmStateReference; + + /* + * struct usmUser: a structure to represent a given user in a list + */ + /* + * Note: Any changes made to this structure need to be reflected in + * the following functions: + */ + + struct usmUser; + struct usmUser { + u_int flags; + u_char *engineID; + size_t engineIDLen; + char *name; + char *secName; + oid *cloneFrom; + size_t cloneFromLen; + oid *authProtocol; + size_t authProtocolLen; + u_char *authKey; + size_t authKeyLen; + u_char *authKeyKu; + size_t authKeyKuLen; + oid *privProtocol; + size_t privProtocolLen; + u_char *privKeyKu; + size_t privKeyKuLen; + u_char *privKey; + size_t privKeyLen; + u_char *userPublicString; + size_t userPublicStringLen; + int userStatus; + int userStorageType; + /* these are actually DH * pointers but only if openssl is avail. */ + void *usmDHUserAuthKeyChange; + void *usmDHUserPrivKeyChange; + struct usmUser *next; + struct usmUser *prev; + }; + +#define USMUSER_FLAG_KEEP_MASTER_KEY 0x01 + + + /* + * Prototypes. + */ + NETSNMP_IMPORT + int usm_extend_user_kul(struct usmUser *user, + u_int privKeyBufSize); + NETSNMP_IMPORT + struct usmUser *usm_get_userList(void); + NETSNMP_IMPORT + struct usmUser *usm_get_user(const u_char *engineID, size_t engineIDLen, + const char *name); + NETSNMP_IMPORT + struct usmUser *usm_add_user(struct usmUser *user); + NETSNMP_IMPORT + struct usmUser *usm_free_user(struct usmUser *user); + NETSNMP_IMPORT + struct usmUser *usm_create_user(void); + NETSNMP_IMPORT + struct usmUser *usm_cloneFrom_user(struct usmUser *from, + struct usmUser *to); + NETSNMP_IMPORT + struct usmUser *usm_remove_user(struct usmUser *user); + NETSNMP_IMPORT + void usm_parse_config_usmUser(const char *token, + char *line); + NETSNMP_IMPORT + void usm_set_user_password(struct usmUser *user, + const char *token, char *line); + void init_usm(void); + NETSNMP_IMPORT + void init_usm_conf(const char *app); + NETSNMP_IMPORT + void shutdown_usm(void); + NETSNMP_IMPORT + int usm_lookup_auth_type(const char *str); + NETSNMP_IMPORT + const char *usm_lookup_auth_str(int value); + NETSNMP_IMPORT + oid *usm_get_auth_oid(int auth_type, size_t *oid_len); + NETSNMP_IMPORT + int usm_lookup_priv_type(const char *str); + NETSNMP_IMPORT + const char *usm_lookup_priv_str(int value); + NETSNMP_IMPORT + oid *usm_get_priv_oid(int priv_type, size_t *oid_len); + + +#define USM_CREATE_USER_AUTH_DFLT -1 +#define USM_CREATE_USER_AUTH_NONE NETSNMP_USMAUTH_NONE +#define USM_CREATE_USER_AUTH_MD5 NETSNMP_USMAUTH_HMACMD5 +#define USM_CREATE_USER_AUTH_SHA1 NETSNMP_USMAUTH_HMACSHA1 +#define USM_CREATE_USER_AUTH_SHA USM_CREATE_USER_AUTH_SHA1 +#define USM_CREATE_USER_AUTH_SHA512 NETSNMP_USMAUTH_HMAC384SHA512 +#define USM_CREATE_USER_AUTH_SHA384 NETSNMP_USMAUTH_HMAC256SHA384 +#define USM_CREATE_USER_AUTH_SHA256 NETSNMP_USMAUTH_HMAC192SHA256 +#define USM_CREATE_USER_AUTH_SHA224 NETSNMP_USMAUTH_HMAC128SHA224 + + /** flags for variants fo priv algorithsm */ +#define USM_DES_FLAG_3 0x000100 + +#define USM_AES_FLAG_192 0x000100 +#define USM_AES_FLAG_256 0x000200 + +#define USM_AES_REEDER_FLAG 0x030000 +#define USM_AES_FLAG_CISCO 0x100000 + +#define USM_PRIV_MASK_ALG 0x0000ff +#define USM_PRIV_MASK_VARIANT 0x00ff00 + +#define USM_CREATE_USER_PRIV_DFLT -1 +#define USM_CREATE_USER_PRIV_NONE 0 + +#define USM_CREATE_USER_PRIV_DES 0x01 +#define USM_CREATE_USER_PRIV_3DES \ + (USM_CREATE_USER_PRIV_DES | USM_DES_FLAG_3) + +#define USM_CREATE_USER_PRIV_AES 0x02 +#define USM_CREATE_USER_PRIV_AES192 \ + (USM_CREATE_USER_PRIV_AES | USM_AES_FLAG_192) +#define USM_CREATE_USER_PRIV_AES256 \ + (USM_CREATE_USER_PRIV_AES | USM_AES_FLAG_256) + +#define USM_CREATE_USER_PRIV_AES192_CISCO \ + (USM_CREATE_USER_PRIV_AES | USM_AES_FLAG_192 | USM_AES_FLAG_CISCO \ + | USM_AES_REEDER_FLAG) +#define USM_CREATE_USER_PRIV_AES256_CISCO \ + (USM_CREATE_USER_PRIV_AES | USM_AES_FLAG_256 | USM_AES_FLAG_CISCO \ + | USM_AES_REEDER_FLAG) + + + NETSNMP_IMPORT + int usm_create_user_from_session(netsnmp_session * session); + NETSNMP_IMPORT + void usm_parse_create_usmUser(const char *token, + char *line); + NETSNMP_IMPORT + const oid *get_default_authtype(size_t *); + NETSNMP_IMPORT + const oid *get_default_privtype(size_t *); + +#ifdef __cplusplus +} +#endif +#endif /* SNMPUSM_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpv3-security-includes.h b/illumos-x86_64/usr/include/net-snmp/library/snmpv3-security-includes.h new file mode 100644 index 00000000..5dd2a450 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpv3-security-includes.h @@ -0,0 +1,2 @@ +/* This file is automatically generated by configure. Do not modify by hand. */ +#include diff --git a/illumos-x86_64/usr/include/net-snmp/library/snmpv3.h b/illumos-x86_64/usr/include/net-snmp/library/snmpv3.h new file mode 100644 index 00000000..df8b8a4a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/snmpv3.h @@ -0,0 +1,78 @@ +/* + * snmpv3.h + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef SNMPV3_H +#define SNMPV3_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_ENGINEID_LENGTH 32 /* per SNMP-FRAMEWORK-MIB SnmpEngineID TC */ + +#define ENGINEID_TYPE_IPV4 1 +#define ENGINEID_TYPE_IPV6 2 +#define ENGINEID_TYPE_MACADDR 3 +#define ENGINEID_TYPE_TEXT 4 +#define ENGINEID_TYPE_EXACT 5 +#define ENGINEID_TYPE_NETSNMP_RND 128 + +#define DEFAULT_NIC "eth0" + + NETSNMP_IMPORT int + snmpv3_parse_args(char *optarg, netsnmp_session * session, char **Apsz, + char **Xpsz, int argc, char *const *argv, int flags); + NETSNMP_IMPORT + int setup_engineID(u_char ** eidp, const char *text); + NETSNMP_IMPORT + int set_exact_engineID(const u_char *id, size_t len); + void engineID_conf(const char *word, char *cptr); + void engineBoots_conf(const char *, char *); + void engineIDType_conf(const char *, char *); + void engineIDNic_conf(const char *, char *); + NETSNMP_IMPORT + void init_snmpv3(const char *); + int init_snmpv3_post_config(int majorid, int minorid, + void *serverarg, + void *clientarg); + int init_snmpv3_post_premib_config(int majorid, + int minorid, + void *serverarg, + void *clientarg); + void shutdown_snmpv3(const char *type); + int snmpv3_store(int majorID, int minorID, void *serverarg, + void *clientarg); + NETSNMP_IMPORT + u_long snmpv3_local_snmpEngineBoots(void); + int snmpv3_clone_engineID(u_char **, size_t *, u_char *, + size_t); + NETSNMP_IMPORT + size_t snmpv3_get_engineID(u_char * buf, size_t buflen); + NETSNMP_IMPORT + u_char *snmpv3_generate_engineID(size_t *); + NETSNMP_IMPORT + u_long snmpv3_local_snmpEngineTime(void); + int get_default_secLevel(void); + void snmpv3_set_engineBootsAndTime(int boots, int ttime); + int free_engineID(int majorid, int minorid, void *serverarg, + void *clientarg); + NETSNMP_IMPORT + int parse_secLevel_conf(const char* word, char *cptr); + NETSNMP_IMPORT int + snmpv3_parse_arg(int arg, char *optarg, netsnmp_session *session, + char **Apsz, char **Xpsz, int argc, char *const *argv, + int flags); + NETSNMP_IMPORT int + snmpv3_options(char *optarg, netsnmp_session * session, char **Apsz, + char **Xpsz, int argc, char *const *argv); + +#ifdef __cplusplus +} +#endif +#endif /* SNMPV3_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/system.h b/illumos-x86_64/usr/include/net-snmp/library/system.h new file mode 100644 index 00000000..52bafe35 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/system.h @@ -0,0 +1,219 @@ +#ifndef SNMP_SYSTEM_H +#define SNMP_SYSTEM_H + +#ifndef NET_SNMP_CONFIG_H +#error "Please include before this file" +#endif + +#include /* va_list */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Portions of this file are subject to the following copyrights. See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/*********************************************************** + Copyright 1993 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of CMU not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ +/* + * portions Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + + + struct timeval; + + + /* + * function to create a daemon. Will fork and call setsid(). + * + * Returns: -1 : fork failed + * 0 : No errors + */ + NETSNMP_IMPORT + int netsnmp_daemonize(int quit_immediately, int stderr_log); + + /* + * Definitions for the system dependent library file + * + * Do not define 'struct direct' when MSVC_PERL is defined because a + * structure with that name is also defined in the Perl header + * lib\CORE\dirent.h. Do not declare gettimeofday() either. + */ +#ifndef MSVC_PERL + +#ifndef HAVE_READDIR + /* + * structure of a directory entry + */ + typedef struct direct { + long d_ino; /* inode number (not used by MS-DOS) */ + int d_namlen; /* Name length */ + char d_name[257]; /* file name */ + } _DIRECT; + + /* + * structure for dir operations + */ + typedef struct _dir_struc { + char *start; /* Starting position */ + char *curr; /* Current position */ + long size; /* Size of string table */ + long nfiles; /* number if filenames in table */ + struct direct dirstr; /* Directory structure to return */ + } DIR; + + NETSNMP_IMPORT + DIR *opendir(const char *filename); + NETSNMP_IMPORT + struct direct *readdir(DIR * dirp); + NETSNMP_IMPORT + int closedir(DIR * dirp); +#endif /* HAVE_READDIR */ + +#ifndef HAVE_GETTIMEOFDAY + NETSNMP_IMPORT + int gettimeofday(struct timeval *, struct timezone *tz); +#endif + +#endif /* MSVC_PERL */ + +#if !defined(HAVE_STRNCASECMP) && !defined(strncasecmp) + NETSNMP_IMPORT + int strcasecmp(const char *s1, const char *s2); + NETSNMP_IMPORT + int strncasecmp(const char *s1, const char *s2, size_t n); +#endif + +#ifdef WIN32 + NETSNMP_IMPORT + char *winsock_startup(void); + NETSNMP_IMPORT + void winsock_cleanup(void); +#define SOCK_STARTUP winsock_startup() +#define SOCK_CLEANUP winsock_cleanup() +#else /* !WIN32 */ +#define SOCK_STARTUP +#define SOCK_CLEANUP +#endif /* WIN32 */ + +#include /* For definition of in_addr_t */ +#ifdef HAVE_NETINET_IN_H +#include +#endif + + /* Simply resolve a hostname and return first IPv4 address. + * Returns -1 on error */ + NETSNMP_IMPORT + int netsnmp_gethostbyname_v4(const char* name, + in_addr_t *addr_out); + + /** netsnmp versions of dns resoloution.. may include DNSSEC validation. */ + struct addrinfo; /* forward declare */ + NETSNMP_IMPORT + struct hostent *netsnmp_gethostbyname(const char *name); + + NETSNMP_IMPORT + struct hostent *netsnmp_gethostbyaddr(const void *addr, socklen_t len, + int type); + + NETSNMP_IMPORT + int netsnmp_getaddrinfo(const char *name, const char *service, + const struct addrinfo *hints, + struct addrinfo **res); + + NETSNMP_IMPORT + in_addr_t get_myaddr(void); + NETSNMP_IMPORT + long get_uptime(void); + +#ifndef HAVE_STRDUP + char *strdup(const char *); +#endif +#ifndef HAVE_SETENV + NETSNMP_IMPORT + int setenv(const char *, const char *, int); +#endif + + NETSNMP_IMPORT + int calculate_time_diff(const struct timeval *, + const struct timeval *); + NETSNMP_IMPORT + u_int calculate_sectime_diff(const struct timeval *now, + const struct timeval *then); + +#ifndef HAVE_STRCASESTR + char *strcasestr(const char *, const char *); +#endif +#ifndef HAVE_STRTOL + long strtol(const char *, char **, int); +#endif +#ifndef HAVE_STRTOUL + unsigned long strtoul(const char *, char **, int); +#endif +#ifndef HAVE_STRTOULL + NETSNMP_IMPORT uint64_t strtoull(const char *, char **, int); +#endif +#ifndef HAVE_STRTOK_R + NETSNMP_IMPORT + char *strtok_r(char *, const char *, char **); +#endif +#ifndef HAVE_SNPRINTF + int snprintf(char *, size_t, const char *, ...); +#endif +#ifndef HAVE_ASPRINTF + NETSNMP_IMPORT + int vasprintf(char **strp, const char *fmt, va_list ap); + NETSNMP_IMPORT + int asprintf(char **strp, const char *fmt, ...); +#endif + + NETSNMP_IMPORT + int mkdirhier(const char *pathname, mode_t mode, + int skiplast); + NETSNMP_IMPORT + const char *netsnmp_mktemp(void); +#ifndef HAVE_STRLCPY + NETSNMP_IMPORT + size_t strlcpy(char *, const char *, size_t); +#endif +#ifndef HAVE_STRLCAT + NETSNMP_IMPORT + size_t strlcat(char *, const char *, size_t); +#endif + + int netsnmp_os_prematch(const char *ospmname, + const char *ospmrelprefix); + int netsnmp_os_kernel_width(void); + + NETSNMP_IMPORT + int netsnmp_str_to_uid(const char *useroruid); + NETSNMP_IMPORT + int netsnmp_str_to_gid(const char *grouporgid); + +#ifdef __cplusplus +} +#endif +#endif /* SNMP_SYSTEM_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/text_utils.h b/illumos-x86_64/usr/include/net-snmp/library/text_utils.h new file mode 100644 index 00000000..864ca3f9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/text_utils.h @@ -0,0 +1,113 @@ +#ifndef NETSNMP_TEXT_UTILS_H +#define NETSNMP_TEXT_UTILS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /*------------------------------------------------------------------ + * + * text file processing + * + */ + netsnmp_container * + netsnmp_file_text_parse(netsnmp_file *f, netsnmp_container *cin, + int parse_mode, u_int flags, void *context); + +#define PM_SAVE_EVERYTHING 1 +#define PM_INDEX_STRING_STRING 2 +#define PM_USER_FUNCTION 3 + +#define PM_FLAG_NO_CONTAINER 0x00000001 +#define PM_FLAG_SKIP_WHITESPACE 0x00000002 + + + /* + * line processing user function + */ + struct netsnmp_line_process_info_s; /* fwd decl */ + + typedef struct netsnmp_line_info_s { + + size_t index; + + char *line; + size_t line_len; + size_t line_max; + + char *start; + size_t start_len; + + } netsnmp_line_info; + + typedef int (Netsnmp_Process_Text_Line) + (netsnmp_line_info *line_info, void *mem, + struct netsnmp_line_process_info_s* lpi); + + typedef struct netsnmp_line_process_info_s { + + size_t line_max; /* defaults to STRINGMAX if 0 */ + size_t mem_size; + + u_int flags; + + Netsnmp_Process_Text_Line *process; + + void *user_context; + + } netsnmp_line_process_info; + +/* + * user function return codes + */ +#define PMLP_RC_STOP_PROCESSING -1 +#define PMLP_RC_MEMORY_USED 0 +#define PMLP_RC_MEMORY_UNUSED 1 + + +/** ALLOC_LINE: wasteful, but fast */ +#define PMLP_FLAG_ALLOC_LINE 0x00000001 +/** STRDUP_LINE: slower if you don't keep memory in most cases */ +#define PMLP_FLAG_STRDUP_LINE 0x00000002 +/** don't strip trailing newlines */ +#define PMLP_FLAG_LEAVE_NEWLINE 0x00000004 +/** don't skip blank or comment lines */ +#define PMLP_FLAG_PROCESS_WHITESPACE 0x00000008 +/** just process line, don't save it */ +#define PMLP_FLAG_NO_CONTAINER 0x00000010 + + + /* + * a few useful pre-defined helpers + */ + + typedef struct netsnmp_token_value_index_s { + + char *token; + netsnmp_cvalue value; + size_t index; + + } netsnmp_token_value_index; + + netsnmp_container *netsnmp_text_token_container_from_file(const char *file, + u_int flags, + netsnmp_container *c, + void *context); +/* + * flags + */ +#define NSTTC_FLAG_TYPE_CONTEXT_DIRECT 0x00000001 + + +#define PMLP_TYPE_UNSIGNED 1 +#define PMLP_TYPE_INTEGER 2 +#define PMLP_TYPE_STRING 3 +#define PMLP_TYPE_BOOLEAN 4 + + +#ifdef __cplusplus +} +#endif + +#endif /* NETSNMP_TEXT_UTILS_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/tools.h b/illumos-x86_64/usr/include/net-snmp/library/tools.h new file mode 100644 index 00000000..09671392 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/tools.h @@ -0,0 +1,286 @@ +/** + * @file library/tools.h + * @defgroup util Memory Utility Routines + * @ingroup library + * @{ + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef _TOOLS_H +#define _TOOLS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + + /* + * General acros and constants. + */ +#ifdef WIN32 +# define SNMP_MAXPATH MAX_PATH +#else +# ifdef PATH_MAX +# define SNMP_MAXPATH PATH_MAX +# else +# ifdef MAXPATHLEN +# define SNMP_MAXPATH MAXPATHLEN +# else +# define SNMP_MAXPATH 1024 /* Should be safe enough */ +# endif +# endif +#endif + +#define SNMP_MAXBUF (1024 * 4) +#define SNMP_MAXBUF_MEDIUM 1024 +#define SNMP_MAXBUF_SMALL 512 + +#define SNMP_MAXBUF_MESSAGE 1500 + +#define SNMP_MAXOID 64 +#define SNMP_MAX_CMDLINE_OIDS 128 + +#define SNMP_FILEMODE_CLOSED 0600 +#define SNMP_FILEMODE_OPEN 0644 + +#define BYTESIZE(bitsize) ((bitsize + 7) >> 3) +#define ROUNDUP8(x) ( ( (x+7) >> 3 ) * 8 ) + +#define SNMP_STRORNULL(x) ( x ? x : "(null)") + +/** @def SNMP_FREE(s) + Frees a pointer only if it is !NULL and sets its value to NULL */ +#define SNMP_FREE(s) do { if (s) { free(s); s=NULL; } } while(0) + + /* + * XXX Not optimal everywhere. + */ +/** @def SNMP_MALLOC_STRUCT(s) + Mallocs memory of sizeof(struct s), zeros it and returns a pointer to it. */ +#define SNMP_MALLOC_STRUCT(s) (struct s *) calloc(1, sizeof(struct s)) + +/** @def SNMP_MALLOC_TYPEDEF(t) + Mallocs memory of sizeof(t), zeros it and returns a pointer to it. */ +#define SNMP_MALLOC_TYPEDEF(td) (td *) calloc(1, sizeof(td)) + +/** @def SNMP_ZERO(s,l) + Zeros l bytes of memory starting at s. */ +#define SNMP_ZERO(s,l) do { if (s) memset(s, 0, l); } while(0) + + +/** + * @def NETSNMP_REMOVE_CONST(t, e) + * + * Cast away constness without that gcc -Wcast-qual prints a compiler warning, + * similar to const_cast<> in C++. + * + * @param[in] t A pointer type. + * @param[in] e An expression of a type that can be assigned to the type (const t). + */ +#if defined(__GNUC__) +#define NETSNMP_REMOVE_CONST(t, e) \ + (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; })) +#else +#define NETSNMP_REMOVE_CONST(t, e) ((t)(size_t)(e)) +#endif + + +#define TOUPPER(c) (c >= 'a' && c <= 'z' ? c - ('a' - 'A') : c) +#define TOLOWER(c) (c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c) + +#define HEX2VAL(s) \ + ((isalpha(s) ? (TOLOWER(s)-'a'+10) : (TOLOWER(s)-'0')) & 0xf) +#define VAL2HEX(s) ( (s) + (((s) >= 10) ? ('a'-10) : '0') ) + + +/** @def SNMP_MAX(a, b) + Computers the maximum of a and b. */ +#define SNMP_MAX(a,b) ((a) > (b) ? (a) : (b)) + +/** @def SNMP_MIN(a, b) + Computers the minimum of a and b. */ +#define SNMP_MIN(a,b) ((a) > (b) ? (b) : (a)) + +/** @def SNMP_MACRO_VAL_TO_STR(s) + * Expands to string with value of the s. + * If s is macro, the resulting string is value of the macro. + * Example: + * \#define TEST 1234 + * SNMP_MACRO_VAL_TO_STR(TEST) expands to "1234" + * SNMP_MACRO_VAL_TO_STR(TEST+1) expands to "1234+1" + */ +#define SNMP_MACRO_VAL_TO_STR(s) SNMP_MACRO_VAL_TO_STR_PRIV(s) +#define SNMP_MACRO_VAL_TO_STR_PRIV(s) #s + +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + +#define NETSNMP_IGNORE_RESULT(e) do { if (e) { } } while (0) + + /* + * QUIT the FUNction: + * e Error code variable + * l Label to goto to cleanup and get out of the function. + * + * XXX It would be nice if the label could be constructed by the + * preprocessor in context. Limited to a single error return value. + * Temporary hack at best. + */ +#define QUITFUN(e, l) \ + if ( (e) != SNMPERR_SUCCESS) { \ + rval = SNMPERR_GENERR; \ + goto l ; \ + } + +/** + * Compute res = a + b. + * + * @pre a and b must be normalized 'struct timeval' values. + * + * @note res may be the same variable as one of the operands. In other + * words, &a == &res || &b == &res may hold. + */ +#define NETSNMP_TIMERADD(a, b, res) do { \ + (res)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (res)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ + if ((res)->tv_usec >= 1000000L) { \ + (res)->tv_usec -= 1000000L; \ + (res)->tv_sec++; \ + } \ +} while (0) + +/** + * Compute res = a - b. + * + * @pre a and b must be normalized 'struct timeval' values. + * + * @note res may be the same variable as one of the operands. In other + * words, &a == &res || &b == &res may hold. + */ +#define NETSNMP_TIMERSUB(a, b, res) do { \ + (res)->tv_sec = (a)->tv_sec - (b)->tv_sec - 1; \ + (res)->tv_usec = (a)->tv_usec - (b)->tv_usec + 1000000L; \ + if ((res)->tv_usec >= 1000000L) { \ + (res)->tv_usec -= 1000000L; \ + (res)->tv_sec++; \ + } \ +} while (0) + +#define ENGINETIME_MAX 2147483647 /* ((2^31)-1) */ +#define ENGINEBOOT_MAX 2147483647 /* ((2^31)-1) */ + + + struct timeval; + + + /* + * Prototypes. + */ + + NETSNMP_IMPORT + int snmp_realloc(u_char ** buf, size_t * buf_len); + + void free_zero(void *buf, size_t size); + + u_char *malloc_random(size_t * size); + u_char *malloc_zero(size_t size); + NETSNMP_IMPORT + void *netsnmp_memdup(const void * from, size_t size); + NETSNMP_IMPORT + void *netsnmp_memdup_nt(const void *from, size_t from_len, size_t *to_len); + + void netsnmp_check_definedness(const void *packet, + size_t length); + + NETSNMP_IMPORT + u_int netsnmp_binary_to_hex(u_char ** dest, size_t *dest_len, + int allow_realloc, + const u_char * input, size_t len); + + NETSNMP_IMPORT + u_int binary_to_hex(const u_char * input, size_t len, + char **output); + /* preferred */ + int netsnmp_hex_to_binary(u_char ** buf, size_t * buf_len, + size_t * offset, int allow_realloc, + const char *hex, const char *delim); + /* calls netsnmp_hex_to_binary w/delim of " " */ + NETSNMP_IMPORT + int snmp_hex_to_binary(u_char ** buf, size_t * buf_len, + size_t * offset, int allow_realloc, + const char *hex); + /* handles odd lengths */ + NETSNMP_IMPORT + int hex_to_binary2(const u_char * input, size_t len, + char **output); + + NETSNMP_IMPORT + int snmp_decimal_to_binary(u_char ** buf, size_t * buf_len, + size_t * out_len, + int allow_realloc, + const char *decimal); +#define snmp_cstrcat(b,l,o,a,s) snmp_strcat(b,l,o,a,(const u_char *)s) + NETSNMP_IMPORT + int snmp_strcat(u_char ** buf, size_t * buf_len, + size_t * out_len, int allow_realloc, + const u_char * s); + NETSNMP_IMPORT + char *netsnmp_strdup_and_null(const u_char * from, + size_t from_len); + + NETSNMP_IMPORT + void dump_chunk(const char *debugtoken, const char *title, + const u_char * buf, int size); + char *dump_snmpEngineID(const u_char * buf, size_t * buflen); + + /** A pointer to an opaque time marker value. */ + typedef void *marker_t; + typedef const void* const_marker_t; + + NETSNMP_IMPORT + marker_t atime_newMarker(void); + NETSNMP_IMPORT + void atime_setMarker(marker_t pm); + NETSNMP_IMPORT + void netsnmp_get_monotonic_clock(struct timeval* tv); + NETSNMP_IMPORT + void netsnmp_set_monotonic_marker(marker_t *pm); + NETSNMP_IMPORT + long atime_diff(const_marker_t first, const_marker_t second); + NETSNMP_IMPORT + u_long uatime_diff(const_marker_t first, const_marker_t second); /* 1/1000th sec */ + NETSNMP_IMPORT + u_long uatime_hdiff(const_marker_t first, const_marker_t second); /* 1/100th sec */ + NETSNMP_IMPORT + int atime_ready(const_marker_t pm, int delta_ms); + NETSNMP_IMPORT + int netsnmp_ready_monotonic(const_marker_t pm, int delta_ms); + int uatime_ready(const_marker_t pm, unsigned int delta_ms); + + int marker_tticks(const_marker_t pm); + int timeval_tticks(const struct timeval *tv); + NETSNMP_IMPORT + char *netsnmp_getenv(const char *name); + NETSNMP_IMPORT + int netsnmp_setenv(const char *envname, const char *envval, + int overwrite); + + int netsnmp_addrstr_hton(char *ptr, size_t len); + + NETSNMP_IMPORT + int netsnmp_string_time_to_secs(const char *time_string); + +#ifdef __cplusplus +} +#endif +#endif /* _TOOLS_H */ +/** @} */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/transform_oids.h b/illumos-x86_64/usr/include/net-snmp/library/transform_oids.h new file mode 100644 index 00000000..79dbca58 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/transform_oids.h @@ -0,0 +1,78 @@ +#ifndef _net_snmp_transform_oids_h +#define _net_snmp_transform_oids_h + +#ifdef __cplusplus +extern "C" { +#endif +/* + * transform_oids.h + * + * Numeric MIB names for auth and priv transforms. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +/** auth */ +#define NETSNMP_USMAUTH_BASE_OID 1,3,6,1,6,3,10,1,1 +#define NETSNMP_USMAUTH_NOAUTH 1 +#define NETSNMP_USMAUTH_HMACMD5 2 +#define NETSNMP_USMAUTH_HMACSHA1 3 +#define NETSNMP_USMAUTH_HMACSHA NETSNMP_USMAUTH_HMACSHA1 +#define NETSNMP_USMAUTH_HMAC128SHA224 4 /* RFC 7860; OPTIONAL */ +#define NETSNMP_USMAUTH_HMAC192SHA256 5 /* RFC 7860; MUST */ +#define NETSNMP_USMAUTH_HMAC256SHA384 6 /* RFC 7860; OPTIONAL */ +#define NETSNMP_USMAUTH_HMAC384SHA512 7 /* RFC 7860; SHOULD */ + +NETSNMP_IMPORT oid usmNoAuthProtocol[10]; + +#ifndef NETSNMP_DISABLE_MD5 +NETSNMP_IMPORT oid usmHMACMD5AuthProtocol[10]; +#endif + +NETSNMP_IMPORT oid usmHMACSHA1AuthProtocol[10]; + +NETSNMP_IMPORT oid usmHMAC128SHA224AuthProtocol[10]; +NETSNMP_IMPORT oid usmHMAC192SHA256AuthProtocol[10]; +NETSNMP_IMPORT oid usmHMAC256SHA384AuthProtocol[10]; +NETSNMP_IMPORT oid usmHMAC384SHA512AuthProtocol[10]; + +/** priv */ +NETSNMP_IMPORT oid usmNoPrivProtocol[10]; + +#ifndef NETSNMP_DISABLE_DES +NETSNMP_IMPORT oid usmDESPrivProtocol[10]; +#endif + +NETSNMP_IMPORT oid usmAESPrivProtocol[10]; +NETSNMP_IMPORT oid *usmAES128PrivProtocol; /* backwards compat */ + +/* + * backwards compatibility. should not be used in internal code. + */ +#define USM_AUTH_PROTO_NOAUTH_LEN 10 +#define USM_AUTH_PROTO_MD5_LEN 10 +#define USM_AUTH_PROTO_SHA_LEN 10 +#define USM_PRIV_PROTO_NOPRIV_LEN 10 +#define USM_PRIV_PROTO_DES_LEN 10 + +#define USM_PRIV_PROTO_AES_LEN 10 +#define USM_PRIV_PROTO_AES128_LEN 10 /* backwards compat */ + +#ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04 +NETSNMP_IMPORT oid usmAES192PrivProtocol[9]; +NETSNMP_IMPORT oid usmAES256PrivProtocol[9]; + +NETSNMP_IMPORT oid usmAES192CiscoPrivProtocol[11]; +NETSNMP_IMPORT oid usmAES256CiscoPrivProtocol[11]; + +NETSNMP_IMPORT oid usmAES192Cisco2PrivProtocol[11]; +NETSNMP_IMPORT oid usmAES256Cisco2PrivProtocol[11]; +#endif /* NETSNMP_DRAFT_BLUMENTHAL_AES_04 */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/library/types.h b/illumos-x86_64/usr/include/net-snmp/library/types.h new file mode 100644 index 00000000..01742914 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/types.h @@ -0,0 +1,70 @@ +#ifndef NET_SNMP_LIBRARY_TYPES_H +#define NET_SNMP_LIBRARY_TYPES_H + +#ifndef NET_SNMP_CONFIG_H +#error "Please include before this file" +#endif + + +#include + + +typedef struct netsnmp_index_s { + size_t len; + oid *oids; +} netsnmp_index; + +typedef struct netsnmp_void_array_s { + size_t size; + void **array; +} netsnmp_void_array; + +/* + * references to various types + */ +typedef struct netsnmp_ref_void { + void *val; +} netsnmp_ref_void; + +typedef union { + u_long ul; + u_int ui; + u_short us; + u_char uc; + long sl; + int si; + short ss; + char sc; + char *cp; + void *vp; +} netsnmp_cvalue; + +typedef struct netsnmp_ref_size_t_s { + size_t val; +} *netsnmp_ref_size_t; + +/* + * Structure for holding a set of file descriptors, similar to fd_set. + * + * This structure however can hold so-called large file descriptors + * (>= FD_SETSIZE or 1024) on Unix systems or more than FD_SETSIZE (64) + * sockets on Windows systems. + * + * It is safe to allocate this structure on the stack. + * + * This structure must be initialized by calling netsnmp_large_fd_set_init() + * and must be cleaned up via netsnmp_large_fd_set_cleanup(). If this last + * function is not called this may result in a memory leak. + * + * The members of this structure are: + * lfs_setsize: maximum set size. + * lsf_setptr: points to lfs_set if lfs_setsize <= FD_SETSIZE, and otherwise + * to dynamically allocated memory. + * lfs_set: file descriptor / socket set data if lfs_setsize <= FD_SETSIZE. + */ +typedef struct netsnmp_large_fd_set_s { + unsigned lfs_setsize; + fd_set *lfs_setptr; + fd_set lfs_set; +} netsnmp_large_fd_set; +#endif /* NET_SNMP_LIBRARY_TYPES_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/ucd_compat.h b/illumos-x86_64/usr/include/net-snmp/library/ucd_compat.h new file mode 100644 index 00000000..329d435b --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/ucd_compat.h @@ -0,0 +1,51 @@ +/* + * UCD compatability definitions & declarations + * + */ + +#ifndef NET_SNMP_UCD_COMPAT_H +#define NET_SNMP_UCD_COMPAT_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * from snmp_api.h + */ +NETSNMP_IMPORT +void snmp_set_dump_packet(int); +NETSNMP_IMPORT +int snmp_get_dump_packet(void); +NETSNMP_IMPORT +void snmp_set_quick_print(int); +NETSNMP_IMPORT +int snmp_get_quick_print(void); +NETSNMP_IMPORT +void snmp_set_suffix_only(int); +NETSNMP_IMPORT +int snmp_get_suffix_only(void); +NETSNMP_IMPORT +void snmp_set_full_objid(int); +int snmp_get_full_objid(void); +NETSNMP_IMPORT +void snmp_set_random_access(int); +NETSNMP_IMPORT +int snmp_get_random_access(void); + + /* + * from parse.h + */ +NETSNMP_IMPORT +void snmp_set_mib_warnings(int); +NETSNMP_IMPORT +void snmp_set_mib_errors(int); +NETSNMP_IMPORT +void snmp_set_save_descriptions(int); +void snmp_set_mib_comment_term(int); +void snmp_set_mib_parse_label(int); + +#ifdef __cplusplus +} +#endif +#endif /* NET_SNMP_UCD_COMPAT_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/vacm.h b/illumos-x86_64/usr/include/net-snmp/library/vacm.h new file mode 100644 index 00000000..e5bc5fd9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/vacm.h @@ -0,0 +1,284 @@ +/* + * vacm.h + * + * SNMPv3 View-based Access Control Model + * + * Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef VACM_H +#define VACM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define VACM_SUCCESS 0 +#define VACM_NOSECNAME 1 +#define VACM_NOGROUP 2 +#define VACM_NOACCESS 3 +#define VACM_NOVIEW 4 +#define VACM_NOTINVIEW 5 +#define VACM_NOSUCHCONTEXT 6 +#define VACM_SUBTREE_UNKNOWN 7 + +#define SECURITYMODEL 1 +#define SECURITYNAME 2 +#define SECURITYGROUP 3 +#define SECURITYSTORAGE 4 +#define SECURITYSTATUS 5 + +#define ACCESSPREFIX 1 +#define ACCESSMODEL 2 +#define ACCESSLEVEL 3 +#define ACCESSMATCH 4 +#define ACCESSREAD 5 +#define ACCESSWRITE 6 +#define ACCESSNOTIFY 7 +#define ACCESSSTORAGE 8 +#define ACCESSSTATUS 9 + +#define VACMVIEWSPINLOCK 1 +#define VIEWNAME 2 +#define VIEWSUBTREE 3 +#define VIEWMASK 4 +#define VIEWTYPE 5 +#define VIEWSTORAGE 6 +#define VACMVIEWSTATUS 7 + +#define VACM_MAX_STRING 32 +#define VACMSTRINGLEN 34 /* VACM_MAX_STRING + 2 */ + + struct vacm_groupEntry { + int securityModel; + char securityName[VACMSTRINGLEN]; + char groupName[VACMSTRINGLEN]; + int storageType; + int status; + + u_long bitMask; + struct vacm_groupEntry *reserved; + struct vacm_groupEntry *next; + }; + +#define CONTEXT_MATCH_EXACT 1 +#define CONTEXT_MATCH_PREFIX 2 + +/* VIEW ENUMS ---------------------------------------- */ + +/* SNMPD usage: get/set/send-notification views */ +#define VACM_VIEW_READ 0 +#define VACM_VIEW_WRITE 1 +#define VACM_VIEW_NOTIFY 2 + +/* SNMPTRAPD usage: log execute and net-access (forward) usage */ +#define VACM_VIEW_LOG 3 +#define VACM_VIEW_EXECUTE 4 +#define VACM_VIEW_NET 5 + +/* VIEW BIT MASK VALUES-------------------------------- */ + +/* SNMPD usage: get/set/send-notification views */ +#define VACM_VIEW_READ_BIT (1 << VACM_VIEW_READ) +#define VACM_VIEW_WRITE_BIT (1 << VACM_VIEW_WRITE) +#define VACM_VIEW_NOTIFY_BIT (1 << VACM_VIEW_NOTIFY) + +/* SNMPTRAPD usage: log execute and net-access (forward) usage */ +#define VACM_VIEW_LOG_BIT (1 << VACM_VIEW_LOG) +#define VACM_VIEW_EXECUTE_BIT (1 << VACM_VIEW_EXECUTE) +#define VACM_VIEW_NET_BIT (1 << VACM_VIEW_NET) + +#define VACM_VIEW_NO_BITS 0 + +/* Maximum number of views in the view array */ +#define VACM_MAX_VIEWS 8 + +#define VACM_VIEW_ENUM_NAME "vacmviews" + + void init_vacm(void); + + struct vacm_accessEntry { + char groupName[VACMSTRINGLEN]; + char contextPrefix[VACMSTRINGLEN]; + int securityModel; + int securityLevel; + int contextMatch; + char views[VACM_MAX_VIEWS][VACMSTRINGLEN]; + int storageType; + int status; + + u_long bitMask; + struct vacm_accessEntry *reserved; + struct vacm_accessEntry *next; + }; + + struct vacm_viewEntry { + char viewName[VACMSTRINGLEN]; + oid viewSubtree[MAX_OID_LEN+1]; /* keep len in [0] */ + size_t viewSubtreeLen; + u_char viewMask[VACMSTRINGLEN]; + size_t viewMaskLen; + int viewType; + int viewStorageType; + int viewStatus; + + u_long bitMask; + + struct vacm_viewEntry *reserved; + struct vacm_viewEntry *next; + }; + + NETSNMP_IMPORT + void vacm_destroyViewEntry(const char *, oid *, size_t); + NETSNMP_IMPORT + void vacm_destroyAllViewEntries(void); + +#define VACM_MODE_FIND 0 +#define VACM_MODE_IGNORE_MASK 1 +#define VACM_MODE_CHECK_SUBTREE 2 + NETSNMP_IMPORT + struct vacm_viewEntry *vacm_getViewEntry(const char *, oid *, size_t, + int); + /* + * Returns a pointer to the viewEntry with the + * same viewName and viewSubtree + * Returns NULL if that entry does not exist. + */ + + NETSNMP_IMPORT + int vacm_checkSubtree(const char *, oid *, size_t); + + /* + * Check to see if everything within a subtree is in view, not in view, + * or possibly both. + * + * Returns: + * VACM_SUCCESS The OID is included in the view. + * VACM_NOTINVIEW If no entry in the view list includes the + * provided OID, or the OID is explicitly excluded + * from the view. + * VACM_SUBTREE_UNKNOWN The entire subtree has both allowed and + * disallowed portions. + */ + + NETSNMP_IMPORT + void + vacm_scanViewInit(void); + /* + * Initialized the scan routines so that they will begin at the + * beginning of the list of viewEntries. + * + */ + + + NETSNMP_IMPORT + struct vacm_viewEntry *vacm_scanViewNext(void); + /* + * Returns a pointer to the next viewEntry. + * These entries are returned in no particular order, + * but if N entries exist, N calls to view_scanNext() will + * return all N entries once. + * Returns NULL if all entries have been returned. + * view_scanInit() starts the scan over. + */ + + NETSNMP_IMPORT + struct vacm_viewEntry *vacm_createViewEntry(const char *, oid *, + size_t); + /* + * Creates a viewEntry with the given index + * and returns a pointer to it. + * The status of this entry is created as invalid. + */ + + NETSNMP_IMPORT + void vacm_destroyGroupEntry(int, const char *); + NETSNMP_IMPORT + void vacm_destroyAllGroupEntries(void); + NETSNMP_IMPORT + struct vacm_groupEntry *vacm_createGroupEntry(int, const char *); + NETSNMP_IMPORT + struct vacm_groupEntry *vacm_getGroupEntry(int, const char *); + NETSNMP_IMPORT + void vacm_scanGroupInit(void); + NETSNMP_IMPORT + struct vacm_groupEntry *vacm_scanGroupNext(void); + + NETSNMP_IMPORT + void vacm_destroyAccessEntry(const char *, const char *, + int, int); + NETSNMP_IMPORT + void vacm_destroyAllAccessEntries(void); + NETSNMP_IMPORT + struct vacm_accessEntry *vacm_createAccessEntry(const char *, + const char *, int, + int); + NETSNMP_IMPORT + struct vacm_accessEntry *vacm_getAccessEntry(const char *, + const char *, int, int); + NETSNMP_IMPORT + void vacm_scanAccessInit(void); + NETSNMP_IMPORT + struct vacm_accessEntry *vacm_scanAccessNext(void); + + void vacm_destroySecurityEntry(const char *); + struct vacm_securityEntry *vacm_createSecurityEntry(const char *); + struct vacm_securityEntry *vacm_getSecurityEntry(const char *); + void vacm_scanSecurityInit(void); + struct vacm_securityEntry *vacm_scanSecurityEntry(void); + NETSNMP_IMPORT + int vacm_is_configured(void); + + void vacm_save(const char *token, const char *type); + void vacm_save_view(struct vacm_viewEntry *view, + const char *token, const char *type); + void vacm_save_access(struct vacm_accessEntry *access_entry, + const char *token, const char *type); + void vacm_save_auth_access(struct vacm_accessEntry *access_entry, + const char *token, const char *type, int authtype); + void vacm_save_group(struct vacm_groupEntry *group_entry, + const char *token, const char *type); + + NETSNMP_IMPORT + void vacm_parse_config_view(const char *token, const char *line); + NETSNMP_IMPORT + void vacm_parse_config_group(const char *token, + const char *line); + NETSNMP_IMPORT + void vacm_parse_config_access(const char *token, + const char *line); + NETSNMP_IMPORT + void vacm_parse_config_auth_access(const char *token, + const char *line); + + NETSNMP_IMPORT + int store_vacm(int majorID, int minorID, void *serverarg, + void *clientarg); + + NETSNMP_IMPORT + struct vacm_viewEntry *netsnmp_view_get(struct vacm_viewEntry *head, + const char *viewName, + oid * viewSubtree, + size_t viewSubtreeLen, int mode); + + NETSNMP_IMPORT + int netsnmp_vacm_simple_usm_add(const char *user, int rw, int authLevel, + const char *view, oid *oidView, + size_t oidViewLen, const char *context); + + NETSNMP_IMPORT + int netsnmp_vacm_simple_usm_del(const char *user, int authLevel, + const char *view, oid *oidView, + size_t oidViewLen, const char *context); + +#ifdef __cplusplus +} +#endif +#endif /* VACM_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/library/winpipe.h b/illumos-x86_64/usr/include/net-snmp/library/winpipe.h new file mode 100644 index 00000000..90fd7235 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/winpipe.h @@ -0,0 +1,44 @@ +/* + Copyright (c) Fabasoft R&D Software GmbH & Co KG, 2003 + oss@fabasoft.com + Author: Bernhard Penz + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * The name of Fabasoft R&D Software GmbH & Co KG or any of its subsidiaries, + brand or product names may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef WIN32 + +#ifndef WINPIPE_H +#define WINPIPE_H + +NETSNMP_IMPORT +int create_winpipe_transport(int *pipefds); + +#endif + +#endif + diff --git a/illumos-x86_64/usr/include/net-snmp/library/winservice.h b/illumos-x86_64/usr/include/net-snmp/library/winservice.h new file mode 100644 index 00000000..29d9f2a6 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/library/winservice.h @@ -0,0 +1,70 @@ +#ifndef WINSERVICE_H +#define WINSERVICE_H + +/* Windows Service related function declarations. */ + +#ifdef __cplusplus +extern "C" { +#elif 0 +} +#endif /* */ + +/* + * Define Constants for Register, De-register , Run As service or Console mode + */ +enum net_snmp_cmd_line_action { + REGISTER_SERVICE = 0, + UN_REGISTER_SERVICE = 1, + RUN_AS_SERVICE = 2, + RUN_AS_CONSOLE = 3, +}; + +/* + * Input parameter structure to thread + */ +typedef struct _InputParams { + DWORD Argc; + char **Argv; +} InputParams; + +/* + * Define Service Related functions + */ + +/* + * To register application as windows service with SCM + */ +int RegisterService(const char *lpszServiceName, + const char *lpszServiceDisplayName, + const char *lpszServiceDescription, + InputParams *StartUpArg, int quiet); + +/* + * To unregister service + */ +int UnregisterService(const char *lpszServiceName, int quiet); + +/* + * To parse command line for startup option + */ +enum net_snmp_cmd_line_action + ParseCmdLineForServiceOption(int argc, char *argv[], + int *quiet); + +/* + * To start Service + */ +BOOL RunAsService(int (*ServiceFunction)(int, char **)); + +/* + * Service STOP function registration with this framewrok + * * this function must be invoked before calling RunAsService + */ +void RegisterStopFunction(void (*StopFunc)(void)); + +#if 0 +{ +#elif defined(__cplusplus) +} +#endif /* */ +#endif /* WINSERVICE_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/machine/generic.h b/illumos-x86_64/usr/include/net-snmp/machine/generic.h new file mode 100644 index 00000000..ddfbe3a9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/machine/generic.h @@ -0,0 +1,3 @@ +/* + * chip specific definitions go here + */ diff --git a/illumos-x86_64/usr/include/net-snmp/mib_api.h b/illumos-x86_64/usr/include/net-snmp/mib_api.h new file mode 100644 index 00000000..3b54e837 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/mib_api.h @@ -0,0 +1,113 @@ +#ifndef NET_SNMP_MIB_API_H +#define NET_SNMP_MIB_API_H + + /** + * Library API routines concerned with MIB files and objects, and OIDs + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + /* Initialisation and Shutdown */ + NETSNMP_IMPORT + int add_mibdir(const char *); + + NETSNMP_IMPORT + void netsnmp_init_mib(void); +#ifndef NETSNMP_NO_LEGACY_DEFINITIONS + NETSNMP_IMPORT + void init_mib(void); + NETSNMP_IMPORT + void init_mib_internals(void); +#endif + NETSNMP_IMPORT + void shutdown_mib(void); + + /* Reading and Parsing MIBs */ + NETSNMP_IMPORT + struct tree *netsnmp_read_module(const char *); +#ifndef NETSNMP_NO_LEGACY_DEFINITIONS + NETSNMP_IMPORT + struct tree *read_module(const char *); +#endif + + NETSNMP_IMPORT + struct tree *read_mib(const char *); + NETSNMP_IMPORT + struct tree *read_all_mibs(void); + + NETSNMP_IMPORT + void add_module_replacement(const char *, const char *, + const char *, int); + + /* from ucd-compat.h */ + NETSNMP_IMPORT + void snmp_set_mib_warnings(int); + NETSNMP_IMPORT + void snmp_set_mib_errors(int); + NETSNMP_IMPORT + void snmp_set_save_descriptions(int); + + + /* Searching the MIB Tree */ + NETSNMP_IMPORT + int read_objid(const char *, oid *, size_t *); + NETSNMP_IMPORT + oid *snmp_parse_oid(const char *, oid *, size_t *); + NETSNMP_IMPORT + int get_module_node(const char *, const char *, oid *, size_t *); + + /* Output */ + NETSNMP_IMPORT + void print_mib(FILE * fp); + + NETSNMP_IMPORT + void print_objid(const oid * objid, size_t objidlen); + NETSNMP_IMPORT + void fprint_objid(FILE * fp, + const oid * objid, size_t objidlen); + NETSNMP_IMPORT + int snprint_objid(char *buf, size_t buf_len, + const oid * objid, size_t objidlen); + + NETSNMP_IMPORT + void print_description(oid * objid, size_t objidlen, int width); + NETSNMP_IMPORT + void fprint_description(FILE * fp, + oid * objid, size_t objidlen, int width); + NETSNMP_IMPORT + int snprint_description(char *buf, size_t buf_len, + oid * objid, size_t objidlen, int width); + +#ifdef __cplusplus +} +#endif + + /* + * Having extracted the main ("public API") calls relevant + * to this area of the Net-SNMP project, the next step is to + * identify the related "public internal API" routines. + * + * In due course, these should probably be gathered + * together into a companion 'library/mib_api.h' header file. + * [Or some suitable name] + * + * But for the time being, the expectation is that the + * traditional headers that provided the above definitions + * will probably also cover the relevant internal API calls. + * Hence they are listed here: + */ + +#include +#include +#ifndef NETSNMP_DISABLE_MIB_LOADING +#include +#endif +#include +#include +#include + +#endif /* NET_SNMP_MIB_API_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/net-snmp-config.h b/illumos-x86_64/usr/include/net-snmp/net-snmp-config.h new file mode 100644 index 00000000..aceaefc0 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/net-snmp-config.h @@ -0,0 +1,2773 @@ +/* include/net-snmp/net-snmp-config.h. Generated from net-snmp-config.h.in by configure. */ +/* include/net-snmp/net-snmp-config.h.in. Generated from configure.ac by autoheader. */ + +/* + * net-snmp configuration header file + * + * NOTE: DO NOT EDIT include/net-snmp/net-snmp-config.h.in as your changes + * will be overwritten. This content is in acconfig.h and merged + * into include/net-snmp/net-snmp-config.h.in by autoheader. + */ +/* Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + */ +/* + * Portions of this file are copyrighted by: + * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef NET_SNMP_CONFIG_H +#define NET_SNMP_CONFIG_H + + +/* ********* NETSNMP_MARK_BEGIN_AUTOCONF_DEFINITIONS ********* */ +/* + * put all autoconf-specific definitions below here + * + */ +#ifndef NETSNMP_NO_AUTOCONF_DEFINITIONS + +/* definitions added by configure on-the-fly */ + +#define config_parse_dot_conf(w,x,y,z) NETSNMP_REQUIRE_SEMICOLON + +#define config_error(x) NETSNMP_REQUIRE_SEMICOLON + +#define config_warning(x) NETSNMP_REQUIRE_SEMICOLON + +#define NETSNMP_REQUIRE_SEMICOLON extern void netsnmp_unused_function(void) + +#define config_belongs_in(x) NETSNMP_REQUIRE_SEMICOLON + +#define config_exclude(x) NETSNMP_REQUIRE_SEMICOLON + +#define config_arch_require(x,y) NETSNMP_REQUIRE_SEMICOLON + +#define config_version_require(x) NETSNMP_REQUIRE_SEMICOLON + +#define config_require(x) NETSNMP_REQUIRE_SEMICOLON + +#define config_add_mib(x) NETSNMP_REQUIRE_SEMICOLON + +/* Define to 1 if using 'alloca.c'. */ +/* #undef C_ALLOCA */ + +/* location of swap device */ +/* #undef DMEM_LOC */ + +/* Define if you want local DNSSEC validation support */ +/* #undef DNSSEC_LOCAL_VALIDATION */ + +/* Environment separator character surrounded by double quotes. */ +#define ENV_SEPARATOR ":" + +/* Environment separator character surrounded by single quotes. */ +#define ENV_SEPARATOR_CHAR ':' + +/* location of mount table list */ +#define ETC_MNTTAB "/etc/mnttab" + +/* Define to 1 if you have the `AES_cfb128_encrypt' function. */ +#define HAVE_AES_CFB128_ENCRYPT 1 + +/* Define to 1 if you have 'alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if works. */ +#define HAVE_ALLOCA_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ASM_PAGE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ASM_TYPES_H */ + +/* Define to 1 if you have the `ASN1_STRING_get0_data' function. */ +#define HAVE_ASN1_STRING_GET0_DATA 1 + +/* Define to 1 if you have the `asprintf' function. */ +#define HAVE_ASPRINTF 1 + +/* Define to 1 if you have the `cgetnext' function. */ +/* #undef HAVE_CGETNEXT */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define to 1 if you have the `clock_gettime' library */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define to 1 if you have the `closedir' function. */ +#define HAVE_CLOSEDIR 1 + +/* Define to 1 if you have the `closesocket' function. */ +/* #undef HAVE_CLOSESOCKET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_COM_ERR_H */ + +/* Define to 1 if the system has the type `Counter64'. */ +#define HAVE_COUNTER64 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRT_EXTERNS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_CURSES_H 1 + +/* Define to 1 if you have the declaration of `daylight', and to 0 if you + don't. */ +#define HAVE_DECL_DAYLIGHT 1 + +/* Define to 1 if you have the declaration of `sensors_get_all_subfeatures', + and to 0 if you don't. */ +/* #undef HAVE_DECL_SENSORS_GET_ALL_SUBFEATURES */ + +/* Define to 1 if you have the declaration of `timezone', and to 0 if you + don't. */ +#define HAVE_DECL_TIMEZONE 1 + +/* define to 1 if you have IRE_CACHE defined in header file. */ +#define HAVE_DEFINED_IRE_CACHE /**/ + +/* define if you have devstat_getdevs() */ +/* #undef HAVE_DEVSTAT_GETDEVS */ + +/* Define to 1 if you have the `DH_get0_key' function. */ +#define HAVE_DH_GET0_KEY 1 + +/* Define to 1 if you have the `DH_get0_pqg' function. */ +#define HAVE_DH_GET0_PQG 1 + +/* Define to 1 if you have the `DH_set0_pqg' function. */ +#define HAVE_DH_SET0_PQG 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Set if the dpkg-query command is available */ +/* #undef HAVE_DPKG_QUERY */ + +/* Define to 1 if you have the `DTLSv1_method' function. */ +#define HAVE_DTLSV1_METHOD 1 + +/* Define to 1 if you have the `DTLS_method' function. */ +#define HAVE_DTLS_METHOD 1 + +/* Define to 1 if you have the `endfsent' function. */ +/* #undef HAVE_ENDFSENT */ + +/* Define to 1 if you have the `ERR_get_error_all' function. */ +#define HAVE_ERR_GET_ERROR_ALL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERR_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ET_COM_ERR_H */ + +/* Define to 1 if you have the `eval_pv' function. */ +/* #undef HAVE_EVAL_PV */ + +/* Define to 1 if you have the `EVP_MD_CTX_create' function. */ +/* #undef HAVE_EVP_MD_CTX_CREATE */ + +/* Define to 1 if you have the `EVP_MD_CTX_destroy' function. */ +/* #undef HAVE_EVP_MD_CTX_DESTROY */ + +/* Define to 1 if you have the `EVP_MD_CTX_free' function. */ +#define HAVE_EVP_MD_CTX_FREE 1 + +/* Define to 1 if you have the `EVP_MD_CTX_new' function. */ +#define HAVE_EVP_MD_CTX_NEW 1 + +/* Define to 1 if you have the `EVP_sha224' function. */ +#define HAVE_EVP_SHA224 1 + +/* Define to 1 if you have the `EVP_sha384' function. */ +#define HAVE_EVP_SHA384 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `fgetc_unlocked' function. */ +/* #undef HAVE_FGETC_UNLOCKED */ + +/* Define to 1 if you have the `flockfile' function. */ +#define HAVE_FLOCKFILE 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkall' function. */ +#define HAVE_FORKALL 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FSTAB_H */ + +/* Define to 1 if you have the `fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `funlockfile' function. */ +#define HAVE_FUNLOCKFILE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +#define HAVE_GETADDRINFO 1 + +/* define if you have getdevs() */ +/* #undef HAVE_GETDEVS */ + +/* Define to 1 if you have the `getdtablesize' function. */ +#define HAVE_GETDTABLESIZE 1 + +/* Define to 1 if you have the `getfsent' function. */ +/* #undef HAVE_GETFSENT */ + +/* Define to 1 if you have the `getfsstat' function. */ +/* #undef HAVE_GETFSSTAT */ + +/* Define to 1 if you have the `getgrnam' function. */ +#define HAVE_GETGRNAM 1 + +/* Define to 1 if you have the `gethostbyaddr' function. */ +#define HAVE_GETHOSTBYADDR 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define to 1 if you have the `gethostbyname2' function. */ +/* #undef HAVE_GETHOSTBYNAME2 */ + +/* Define to 1 if you have the `gethostname' function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the `getipnodebyname' function. */ +#define HAVE_GETIPNODEBYNAME 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getmntent' function. */ +#define HAVE_GETMNTENT 1 + +/* Define to 1 if you have the `getmntinfo' function. */ +/* #undef HAVE_GETMNTINFO */ + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpwnam' function. */ +#define HAVE_GETPWNAM 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getvfsstat' function. */ +/* #undef HAVE_GETVFSSTAT */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `hasmntopt' function. */ +#define HAVE_HASMNTOPT 1 + +/* Define to 1 if you have the headerGet function. */ +/* #undef HAVE_HEADERGET */ + +/* Define to 1 if you have the `if_freenameindex' function. */ +#define HAVE_IF_FREENAMEINDEX 1 + +/* Define to 1 if you have the `if_indextoname' function. */ +#define HAVE_IF_INDEXTONAME 1 + +/* Define to 1 if you have the `if_nameindex' function. */ +#define HAVE_IF_NAMEINDEX 1 + +/* Define to 1 if you have the `if_nametoindex' function. */ +#define HAVE_IF_NAMETOINDEX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INET_COMMON_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INET_IP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INET_MIB2_H 1 + +/* Define to 1 if you have the `inet_ntop' function. */ +#define HAVE_INET_NTOP 1 + +/* Define to 1 if you have the `inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define to 1 if the system has the type `intmax_t'. */ +#define HAVE_INTMAX_T 1 + +/* Define to 1 if the system has the type `intptr_t'. */ +#define HAVE_INTPTR_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if the system has the type `in_addr_t'. */ +#define HAVE_IN_ADDR_T 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IOCTLS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IPHLPAPI_H */ + +/* Set if IP_PKTINFO is usable */ +/* #undef HAVE_IP_PKTINFO */ + +/* Set if IP_RECVDSTADDR is usable */ +/* #undef HAVE_IP_RECVDSTADDR */ + +/* Define to 1 if you have the `kinfo_get_cpus' function. */ +/* #undef HAVE_KINFO_GET_CPUS */ + +/* Define to 1 if you have the `knlist' function. */ +/* #undef HAVE_KNLIST */ + +/* Define to 1 if you have the `krb5_auth_con_getrecvsubkey' function. */ +/* #undef HAVE_KRB5_AUTH_CON_GETRECVSUBKEY */ + +/* Define to 1 if you have the `krb5_auth_con_getsendsubkey' function. */ +/* #undef HAVE_KRB5_AUTH_CON_GETSENDSUBKEY */ + +/* Define to 1 if `enctype' is a member of `krb5_keyblock'. */ +/* #undef HAVE_KRB5_KEYBLOCK_ENCTYPE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_KSTAT_H 1 + +/* Define to 1 if you have the `kvm_getfile2' function. */ +/* #undef HAVE_KVM_GETFILE2 */ + +/* Define to 1 if you have the `kvm_getfiles' function. */ +/* #undef HAVE_KVM_GETFILES */ + +/* Define to 1 if you have the `kvm_getproc2' function. */ +/* #undef HAVE_KVM_GETPROC2 */ + +/* Define to 1 if you have the `kvm_getprocs' function. */ +/* #undef HAVE_KVM_GETPROCS */ + +/* Define to 1 if you have the `kvm_getswapinfo' function. */ +/* #undef HAVE_KVM_GETSWAPINFO */ + +/* Define to 1 if you have the header file. */ +#define HAVE_KVM_H 1 + +/* Define to 1 if you have the `kvm_openfiles' function. */ +/* #undef HAVE_KVM_OPENFILES */ + +/* Define to 1 if you have the OpenSSL library (-lcrypto or -leay32). */ +#define HAVE_LIBCRYPTO 1 + +/* Define to 1 if you have the `elf' library (-lelf). */ +#define HAVE_LIBELF 1 + +/* Define to 1 if you have the `mld' library (-lmld). */ +/* #undef HAVE_LIBMLD */ + +/* Define to 1 if provides the libnl3 API */ +/* #undef HAVE_LIBNL3 */ + +/* define if you have libnm */ +/* #undef HAVE_LIBNM */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBPERFSTAT_H */ + +/* Define to 1 if you have the `pkcs11' library (-lpkcs11). */ +/* #undef HAVE_LIBPKCS11 */ + +/* define if you have BSD pkg-ng */ +/* #undef HAVE_LIBPKG */ + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +/* #undef HAVE_LIBPTHREAD */ + +/* Define to 1 if you have the `rpm' library (-lrpm). */ +/* #undef HAVE_LIBRPM */ + +/* Define to 1 if you have the `RSAglue' library (-lRSAglue). */ +/* #undef HAVE_LIBRSAGLUE */ + +/* Define to 1 if you have the `rsaref' library (-lrsaref). */ +/* #undef HAVE_LIBRSAREF */ + +/* Define to 1 if you have the `sres' library (-lsres). */ +/* #undef HAVE_LIBSRES */ + +/* Define to 1 if you have the `ssh2' library (-lssh2). */ +/* #undef HAVE_LIBSSH2 */ + +/* Define to 1 if you have the `ssl' library (-lssl). */ +/* #undef HAVE_LIBSSL */ + +/* Define to 1 if your `ssl' library supports DTLS (-lssl). */ +/* #undef HAVE_LIBSSL_DTLS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_ETHTOOL_H */ + +/* Define if __u8 .. __u64 must be declared explicitly before including + */ +#define HAVE_LINUX_ETHTOOL_NEEDS_U64 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_HDREG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_NETLINK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_RTNETLINK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TASKS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LM_H */ + +/* Define to 1 if you have the `load_defaults' function. */ +/* #undef HAVE_LOAD_DEFAULTS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `localtime_r' function. */ +#define HAVE_LOCALTIME_R 1 + +/* Define to 1 if the system has the type `long long int'. */ +#define HAVE_LONG_LONG_INT 1 + +/* Set if the lpstat command is available */ +/* #undef HAVE_LPSTAT */ + +/* Define to 1 if you have the `lrand48' function. */ +#define HAVE_LRAND48 1 + +/* Define to 1 if you have the `lseek64' function. */ +/* #undef HAVE_LSEEK64 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MACHINE_PARAM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MACHINE_PTE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MACHINE_TYPES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MACH_O_DYLD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if the system has the type `mib2_ipIfStatsEntry_t'. */ +#define HAVE_MIB2_IPIFSTATSENTRY_T 1 + +/* Define if MIB_IF_TABLE2 is available */ +/* #undef HAVE_MIB_IF_TABLE2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MINIX_CONFIG_H */ + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MNTENT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MTAB_H */ + +/* Define to 1 if you have the `mysql_init' function. */ +/* #undef HAVE_MYSQL_INIT */ + +/* Define to 1 if you have the `mysql_options' function. */ +/* #undef HAVE_MYSQL_OPTIONS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MY_GLOBAL_H */ + +/* Define if MY_INIT() is availabe in libmysqlclient */ +/* #undef HAVE_MY_INIT */ + +/* Define if having my_load_defaults() */ +/* #undef HAVE_MY_LOAD_DEFAULTS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MY_SYS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NBUTIL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NCURSES_CURSES_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET6_IN6_PCB_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET6_IN6_VAR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET6_IP6_VAR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET6_ND6_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET6_TCP6_FSM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET6_TCP6_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET6_TCP6_TIMER_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET6_TCP6_VAR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_ICMP6_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_ICMP_VAR_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IF_ETHER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET_IN_PCB_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_SYSTM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_VAR_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IP6_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IP_ICMP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IP_VAR_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCPIP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_FSM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_TIMER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_VAR_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_UDP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_UDP_VAR_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETIPX_IPX_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETLINK_NETLINK_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_ARP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_DL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NET_IF_MIB_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NET_IF_VAR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_ROUTE_H 1 + +/* Define to 1 if the system has the type `nfds_t'. */ +#define HAVE_NFDS_T 1 + +/* Define to 1 if you have the `nlist' function. */ +#define HAVE_NLIST 1 + +/* Define to 1 if you have the `nlist64' function. */ +/* #undef HAVE_NLIST64 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NLIST_H 1 + +/* Define to 1 if the system has the type `off64_t'. */ +#define HAVE_OFF64_T 1 + +/* Define to 1 if you have the `opendir' function. */ +#define HAVE_OPENDIR 1 + +/* Define to 1 if you have the `OpenSSL_add_all_algorithms' function. */ +/* #undef HAVE_OPENSSL_ADD_ALL_ALGORITHMS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_AES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_DES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_DH_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_EVP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_HMAC_H 1 + +/* Define to 1 if you have the `OPENSSL_sk_num' function. */ +#define HAVE_OPENSSL_SK_NUM 1 + +/* Define to 1 if you have the `OPENSSL_sk_value' function. */ +#define HAVE_OPENSSL_SK_VALUE 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OSRELDATE_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PCAP_PCAP_H 1 + +/* define if you have pci_lookup_name() */ +/* #undef HAVE_PCI_LOOKUP_NAME */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PCI_PCI_H */ + +/* Define to 1 if you have . */ +#define HAVE_PCRE_H 1 + +/* on aix, if you have perfstat */ +/* #undef HAVE_PERFSTAT */ + +/* Define to 1 if you have `the perl_eval_pv' function. */ +/* #undef HAVE_PERL_EVAL_PV_LC */ + +/* Define to 1 if you have the `Perl_eval_pv' function. */ +/* #undef HAVE_PERL_EVAL_PV_UC */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PICL_H */ + +/* define if you have pkginfo */ +#define HAVE_PKGINFO 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PKGINFO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PKGLOCS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PKG_H */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the `posix_spawn' function. */ +#define HAVE_POSIX_SPAWN 1 + +/* Define to 1 if you have the `pread64' function. */ +/* #undef HAVE_PREAD64 */ + +/* Set if /etc/printcap exists */ +/* #undef HAVE_PRINTCAP */ + +/* Define if prioritynames variable is declared in */ +/* #undef HAVE_PRIORITYNAMES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `rand' function. */ +#define HAVE_RAND 1 + +/* Define to 1 if you have the `random' function. */ +#define HAVE_RANDOM 1 + +/* Define to 1 if you have the `readdir' function. */ +#define HAVE_READDIR 1 + +/* Define to 1 if you have the `regcomp' function. */ +#define HAVE_REGCOMP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_REGEX_H 1 + +/* Define to 1 if you have the `rpmGetPath' function. */ +/* #undef HAVE_RPMGETPATH */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RPM_HEADER_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RPM_RPMFILEUTIL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RPM_RPMLIB_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RPM_RPMTS_H */ + +/* Define if timezone declared as a scalar in */ +#define HAVE_SCALAR_TIMEZONE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SEARCH_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SECURITY_CRYPTOKI_H 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SENSORS_SENSORS_H */ + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `setfsent' function. */ +/* #undef HAVE_SETFSENT */ + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define to 1 if you have the `setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setmntent' function. */ +/* #undef HAVE_SETMNTENT */ + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SGTTY_H 1 + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigalrm' function. */ +/* #undef HAVE_SIGALRM */ + +/* Define to 1 if you have the `sigblock' function. */ +/* #undef HAVE_SIGBLOCK */ + +/* Define if SIGHUP is defined in . */ +#define HAVE_SIGHUP 1 + +/* Define to 1 if you have the `signal' function. */ +#define HAVE_SIGNAL 1 + +/* Define to 1 if you have the `sigprocmask' function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define to 1 if you have the `sigset' function. */ +#define HAVE_SIGSET 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the `socket' function. */ +#define HAVE_SOCKET 1 + +/* Define to 1 if the system has the type `socklen_t'. */ +#define HAVE_SOCKLEN_T 1 + +/* Define to 1 if SO_BINDTODEVICE is available */ +/* #undef HAVE_SO_BINDTODEVICE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SPAWN_H 1 + +/* Define to 1 if you have the `srand' function. */ +#define HAVE_SRAND 1 + +/* Define to 1 if you have the `srand48' function. */ +#define HAVE_SRAND48 1 + +/* Define to 1 if you have the `srandom' function. */ +#define HAVE_SRANDOM 1 + +/* Define to 1 if the system has the type `ssize_t'. */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `SSL_get1_peer_certificate' function. */ +#define HAVE_SSL_GET1_PEER_CERTIFICATE 1 + +/* Define to 1 if you have the `SSL_library_init' function. */ +/* #undef HAVE_SSL_LIBRARY_INIT */ + +/* Define to 1 if you have the `SSL_load_error_strings' function. */ +/* #undef HAVE_SSL_LOAD_ERROR_STRINGS */ + +/* Define to 1 if you have the `statfs' function. */ +#define HAVE_STATFS 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stime' function. */ +#define HAVE_STIME 1 + +/* Define to 1 if you have the `strcasestr' function. */ +#define HAVE_STRCASESTR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcat' function. */ +#define HAVE_STRLCAT 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +#define HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the `strtok_r' function. */ +#define HAVE_STRTOK_R 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if `at_next' is a member of `struct arphd'. */ +/* #undef HAVE_STRUCT_ARPHD_AT_NEXT */ + +/* Define to 1 if `weak_key' is a member of `struct des_ks_struct'. */ +/* #undef HAVE_STRUCT_DES_KS_STRUCT_WEAK_KEY */ + +/* Define to 1 if `d_type' is a member of `struct dirent'. */ +/* #undef HAVE_STRUCT_DIRENT_D_TYPE */ + +/* Define to 1 if `speed_hi' is a member of `struct ethtool_cmd'. */ +/* #undef HAVE_STRUCT_ETHTOOL_CMD_SPEED_HI */ + +/* Define to 1 if `ifa_next' is a member of `struct ifaddr'. */ +#define HAVE_STRUCT_IFADDR_IFA_NEXT 1 + +/* Define to 1 if `if_addrhead.tqh_first' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_ADDRHEAD_TQH_FIRST */ + +/* Define to 1 if `if_addrlist' is a member of `struct ifnet'. */ +#define HAVE_STRUCT_IFNET_IF_ADDRLIST 1 + +/* Define to 1 if `if_baudrate' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_BAUDRATE */ + +/* Define to 1 if `if_baudrate.ifs_value' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_BAUDRATE_IFS_VALUE */ + +/* Define to 1 if `if_ibytes' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_IBYTES */ + +/* Define to 1 if `if_imcasts' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_IMCASTS */ + +/* Define to 1 if `if_iqdrops' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_IQDROPS */ + +/* Define to 1 if `if_lastchange.tv_nsec' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_LASTCHANGE_TV_NSEC */ + +/* Define to 1 if `if_lastchange.tv_sec' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_LASTCHANGE_TV_SEC */ + +/* Define to 1 if `if_mtu' is a member of `struct ifnet'. */ +#define HAVE_STRUCT_IFNET_IF_MTU 1 + +/* Define to 1 if `if_noproto' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_NOPROTO */ + +/* Define to 1 if `if_obytes' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_OBYTES */ + +/* Define to 1 if `if_omcasts' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_OMCASTS */ + +/* Define to 1 if `if_speed' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_SPEED */ + +/* Define to 1 if `if_type' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_TYPE */ + +/* Define to 1 if `if_xname' is a member of `struct ifnet'. */ +/* #undef HAVE_STRUCT_IFNET_IF_XNAME */ + +/* Define to 1 if `ia_subnetmask' is a member of `struct in_ifaddr'. */ +/* #undef HAVE_STRUCT_IN_IFADDR_IA_SUBNETMASK */ + +/* Define to 1 if `ipi_spec_dst' is a member of `struct in_pktinfo'. */ +#define HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST 1 + +/* Define to 1 if `ip6s_exthdrtoolong ' is a member of `struct ip6stat'. */ +/* #undef HAVE_STRUCT_IP6STAT_IP6S_EXTHDRTOOLONG_ */ + +/* Define to 1 if `ips_cantforward' is a member of `struct ipstat'. */ +#define HAVE_STRUCT_IPSTAT_IPS_CANTFORWARD 1 + +/* Define to 1 if `ips_cantfrag' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_CANTFRAG */ + +/* Define to 1 if `ips_delivered' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_DELIVERED */ + +/* Define to 1 if `ips_fragdropped' is a member of `struct ipstat'. */ +#define HAVE_STRUCT_IPSTAT_IPS_FRAGDROPPED 1 + +/* Define to 1 if `ips_fragmented' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_FRAGMENTED */ + +/* Define to 1 if `ips_fragtimeout' is a member of `struct ipstat'. */ +#define HAVE_STRUCT_IPSTAT_IPS_FRAGTIMEOUT 1 + +/* Define to 1 if `ips_localout' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_LOCALOUT */ + +/* Define to 1 if `ips_noproto' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_NOPROTO */ + +/* Define to 1 if `ips_noroute' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_NOROUTE */ + +/* Define to 1 if `ips_odropped' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_ODROPPED */ + +/* Define to 1 if `ips_ofragments' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_OFRAGMENTS */ + +/* Define to 1 if `ips_reassembled' is a member of `struct ipstat'. */ +/* #undef HAVE_STRUCT_IPSTAT_IPS_REASSEMBLED */ + +/* Define to 1 if `m_clfree' is a member of `struct mbstat'. */ +/* #undef HAVE_STRUCT_MBSTAT_M_CLFREE */ + +/* Define to 1 if `m_clusters' is a member of `struct mbstat'. */ +/* #undef HAVE_STRUCT_MBSTAT_M_CLUSTERS */ + +/* Define to 1 if `m_mbufs' is a member of `struct mbstat'. */ +/* #undef HAVE_STRUCT_MBSTAT_M_MBUFS */ + +/* Define to 1 if `n_value' is a member of `struct nlist64'. */ +/* #undef HAVE_STRUCT_NLIST64_N_VALUE */ + +/* Define to 1 if `n_value' is a member of `struct nlist'. */ +#define HAVE_STRUCT_NLIST_N_VALUE 1 + +/* Define to 1 if `rt_dst' is a member of `struct rtentry'. */ +#define HAVE_STRUCT_RTENTRY_RT_DST 1 + +/* Define to 1 if `rt_hash' is a member of `struct rtentry'. */ +#define HAVE_STRUCT_RTENTRY_RT_HASH 1 + +/* Define to 1 if `rt_next' is a member of `struct rtentry'. */ +/* #undef HAVE_STRUCT_RTENTRY_RT_NEXT */ + +/* Define to 1 if `rt_refcnt' is a member of `struct rtentry'. */ +#define HAVE_STRUCT_RTENTRY_RT_REFCNT 1 + +/* Define to 1 if `rt_unit' is a member of `struct rtentry'. */ +/* #undef HAVE_STRUCT_RTENTRY_RT_UNIT */ + +/* Define to 1 if `rt_use' is a member of `struct rtentry'. */ +#define HAVE_STRUCT_RTENTRY_RT_USE 1 + +/* Define to 1 if `sa_sigaction' is a member of `struct sigaction'. */ +#define HAVE_STRUCT_SIGACTION_SA_SIGACTION 1 + +/* Define to 1 if `sin6_scope_id' is a member of `struct sockaddr_in6'. */ +#define HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1 + +/* Define to 1 if `sa_len' is a member of `struct sockaddr'. */ +/* #undef HAVE_STRUCT_SOCKADDR_SA_LEN */ + +/* Define to 1 if `sa_union.sa_generic.sa_family2' is a member of `struct + sockaddr'. */ +/* #undef HAVE_STRUCT_SOCKADDR_SA_UNION_SA_GENERIC_SA_FAMILY2 */ + +/* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ +#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 + +/* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */ +/* #undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ + +/* Define to 1 if `f_favail' is a member of `struct statfs'. */ +/* #undef HAVE_STRUCT_STATFS_F_FAVAIL */ + +/* Define to 1 if `f_ffree' is a member of `struct statfs'. */ +#define HAVE_STRUCT_STATFS_F_FFREE 1 + +/* Define to 1 if `f_files' is a member of `struct statfs'. */ +#define HAVE_STRUCT_STATFS_F_FILES 1 + +/* Define to 1 if `f_flags' is a member of `struct statfs'. */ +/* #undef HAVE_STRUCT_STATFS_F_FLAGS */ + +/* Define to 1 if `f_frsize' is a member of `struct statfs'. */ +#define HAVE_STRUCT_STATFS_F_FRSIZE 1 + +/* Define to 1 if `f_files' is a member of `struct statvfs'. */ +#define HAVE_STRUCT_STATVFS_F_FILES 1 + +/* Define to 1 if `f_frsize' is a member of `struct statvfs'. */ +#define HAVE_STRUCT_STATVFS_F_FRSIZE 1 + +/* Define to 1 if `mnt_dir' is a member of `struct statvfs'. */ +/* #undef HAVE_STRUCT_STATVFS_MNT_DIR */ + +/* Define to 1 if `sw_nblksenabled' is a member of `struct swdevt'. */ +/* #undef HAVE_STRUCT_SWDEVT_SW_NBLKSENABLED */ + +/* Define to 1 if `tcp_rcvmemdrop' is a member of `struct tcpstat'. */ +/* #undef HAVE_STRUCT_TCPSTAT_TCP_RCVMEMDROP */ + +/* Define to 1 if `tz_dsttime' is a member of `struct timezone'. */ +#define HAVE_STRUCT_TIMEZONE_TZ_DSTTIME 1 + +/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */ +/* #undef HAVE_STRUCT_TM_TM_GMTOFF */ + +/* Define to 1 if `tm_isdst' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ISDST 1 + +/* Define to 1 if `udps_discard' is a member of `struct udpstat'. */ +/* #undef HAVE_STRUCT_UDPSTAT_UDPS_DISCARD */ + +/* Define to 1 if `udps_fullsock' is a member of `struct udpstat'. */ +#define HAVE_STRUCT_UDPSTAT_UDPS_FULLSOCK 1 + +/* Define to 1 if `udps_ipackets' is a member of `struct udpstat'. */ +/* #undef HAVE_STRUCT_UDPSTAT_UDPS_IPACKETS */ + +/* Define to 1 if `udps_noport' is a member of `struct udpstat'. */ +/* #undef HAVE_STRUCT_UDPSTAT_UDPS_NOPORT */ + +/* Define to 1 if `udps_noportbcast' is a member of `struct udpstat'. */ +/* #undef HAVE_STRUCT_UDPSTAT_UDPS_NOPORTBCAST */ + +/* Define to 1 if `udps_opackets' is a member of `struct udpstat'. */ +/* #undef HAVE_STRUCT_UDPSTAT_UDPS_OPACKETS */ + +/* Define to 1 if `pgswapin' is a member of `struct uvmexp'. */ +/* #undef HAVE_STRUCT_UVMEXP_PGSWAPIN */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the `system' function. */ +#define HAVE_SYSTEM 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_CDEFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_CONF_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DISKIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DISKLABEL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_DKIO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DKSTAT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DMAP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FIXPOINT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_HASHING_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_LOADAVG_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MBUF_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MNTENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MNTTAB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MOUNT_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PROC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PROTOSW_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PSTAT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_QUEUE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SEMA_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKETVAR_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STREAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SWAP_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYSCTL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYSGET_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSMACROS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYSMP_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYSTEMCFG_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSTEMINFO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TCPIPSTATS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMEB_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TIMEOUT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_USER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_VFS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_VMMAC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_VMMETER_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_VMPARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_VMSYSTM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_VM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_VNODE_H 1 + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetattr' function. */ +#define HAVE_TCGETATTR 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `TLSv1_method' function. */ +#define HAVE_TLSV1_METHOD 1 + +/* Define to 1 if you have the `TLS_method' function. */ +#define HAVE_TLS_METHOD 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UFS_FFS_FS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UFS_FS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UFS_UFS_DINODE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UFS_UFS_INODE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UFS_UFS_QUOTA_H */ + +/* Define to 1 if the system has the type `uintmax_t'. */ +#define HAVE_UINTMAX_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if the system has the type `unsigned long long int'. */ +#define HAVE_UNSIGNED_LONG_LONG_INT 1 + +/* Define to 1 if you have the `usleep' function. */ +#define HAVE_USLEEP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTMPX_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UTSNAME_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UVM_UVM_EXTERN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UVM_UVM_PARAM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VALGRIND_MEMCHECK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VALGRIND_VALGRIND_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VALIDATOR_VALIDATOR_CONFIG_H */ + +/* Define to 1 if you have the `vm_region' function. */ +/* #undef HAVE_VM_REGION */ + +/* Define to 1 if you have the `vm_region_64' function. */ +/* #undef HAVE_VM_REGION_64 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VM_SWAP_PAGER_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VM_VM_EXTERN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VM_VM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VM_VM_PARAM_H */ + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINDOWS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WS2TCPIP_H */ + +/* Define to 1 if you have the `X509_get_signature_nid' function. */ +#define HAVE_X509_GET_SIGNATURE_NID 1 + +/* Define to 1 if you have the `X509_NAME_ENTRY_get_data' function. */ +#define HAVE_X509_NAME_ENTRY_GET_DATA 1 + +/* Define to 1 if you have the `X509_NAME_ENTRY_get_object' function. */ +#define HAVE_X509_NAME_ENTRY_GET_OBJECT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_XTI_H 1 + +/* Define if _beginthreadex() is defined in */ +/* #undef HAVE__BEGINTHREADEX */ + +/* Define if _cputs() is defined in */ +/* #undef HAVE__CPUTS */ + +/* Define if _getch() is defined in */ +/* #undef HAVE__GETCH */ + +/* Define if _get_osfhandle() is defined in */ +/* #undef HAVE__GET_OSFHANDLE */ + +/* Define to 1 if you have the `_NSGetArgv' function. */ +/* #undef HAVE__NSGETARGV */ + +/* Define to 1 if you have the `_NSGetExecutablePath' function. */ +/* #undef HAVE__NSGETEXECUTABLEPATH */ + +/* Define if _open_osfhandle() is defined in */ +/* #undef HAVE__OPEN_OSFHANDLE */ + +/* location of UNIX kernel */ +#define KERNEL_LOC "/dev/ksyms" + +/* Path to the lpstat command */ +/* #undef LPSTAT_PATH */ + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* define if agentx transport is to use domain sockets only */ +#define NETSNMP_AGENTX_DOM_SOCK_ONLY 1 + +/* Unix domain socket for AgentX master-subagent communication */ +#define NETSNMP_AGENTX_SOCKET "/var/agentx/master" + +/* Used to make the compiler issue a warning about deprecated functions and + variables */ +#define NETSNMP_ATTRIBUTE_DEPRECATED __attribute__((deprecated)) + +/* Used to suppress compiler warnings about unused functions and variables */ +#define NETSNMP_ATTRIBUTE_UNUSED __attribute__((unused)) + +/* Define if static inline functions are unsupported */ +#define NETSNMP_BROKEN_INLINE 1 + +/* "Define if crytography support is possible" */ +#define NETSNMP_CAN_DO_CRYPTO 1 + +/* sysctl works to get boottime, etc... */ +/* #undef NETSNMP_CAN_USE_SYSCTL */ + +/* configure options specified */ +#define NETSNMP_CONFIGURE_OPTIONS " '--prefix=/usr' '--sysconfdir=/etc' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--libdir=/usr/lib/amd64' '--libexecdir=/usr/libexec/amd64' '--with-defaults' '--with-default-snmp-version=3' '--includedir=/usr/include' '--mandir=/usr/share/man' '--with-logfile=/var/log/snmpd.log' '--with-persistent-directory=/var/net-snmp' '--with-mibdirs=/etc/net-snmp/snmp/mibs' '--datadir=/etc/net-snmp' '--enable-agentx-dom-sock-only' '--enable-ucd-snmp-compatibility' '--enable-ipv6' '--enable-mfd-rewrites' '--enable-blumenthal-aes' '--disable-embedded-perl' '--without-perl-modules' '--disable-static' '--with-sys-contact=root@localhost' '--without-pkcs' '--with-openssl=/usr/ssl' '--disable-silent-rules' '--disable-maintainer-mode' '--with-transports=Unix UDP TCP UDPIPv6 TCPIPv6' '--with-mib-modules=host disman/event-mib ucd-snmp/diskio udp-mib tcp-mib if-mib' 'CC=/opt/gcc-14/bin/gcc' 'CFLAGS=-O2 -fno-omit-frame-pointer -fno-aggressive-loop-optimizations -fstack-protector-strong -gdwarf-4 -gstrict-dwarf -m64' 'LDFLAGS= -m64' 'CPPFLAGS= -D__int32_t=long ' 'PKG_CONFIG_PATH='" + +/* if defined daemons will use syslog when no log destination is defined */ +/* #undef NETSNMP_DAEMONS_DEFAULT_LOG_SYSLOG */ + +/* default location to look for mibs to load using the above tokens and/or + those in the MIBS envrionment variable */ +#define NETSNMP_DEFAULT_MIBDIRS "/etc/net-snmp/snmp/mibs" + +/* default mib files to load, specified by path. */ +/* #undef NETSNMP_DEFAULT_MIBFILES */ + +/* Define if no agent is built */ +/* #undef NETSNMP_DISABLE_AGENT */ + +/* Define if no apps are built */ +/* #undef NETSNMP_DISABLE_APPS */ + +/* Define if DES encryption should not be supported */ +/* #undef NETSNMP_DISABLE_DES */ + +/* Define if MD5 authentication should not be supported */ +/* #undef NETSNMP_DISABLE_MD5 */ + +/* Define if mib loading and parsing code should not be included */ +/* #undef NETSNMP_DISABLE_MIB_LOADING */ + +/* Define if SNMP SET support should be disabled */ +/* #undef NETSNMP_DISABLE_SET_SUPPORT */ + +/* Define if SNMPv1 code should not be included */ +/* #undef NETSNMP_DISABLE_SNMPV1 */ + +/* Define if SNMPv2c code should not be included */ +/* #undef NETSNMP_DISABLE_SNMPV2C */ + +/* Define if AES-192/AES-256 encryption should be supported */ +#define NETSNMP_DRAFT_BLUMENTHAL_AES_04 1 + +/* Define if you are embedding perl in the main agent. */ +/* #undef NETSNMP_EMBEDDED_PERL */ + +/* define if you want to enable IPv6 support */ +#define NETSNMP_ENABLE_IPV6 1 + +/* define if you want to restrict SMUX connections to localhost by default */ +/* #undef NETSNMP_ENABLE_LOCAL_SMUX */ + +/* Define if you want to build MFD module rewrites */ +#define NETSNMP_ENABLE_MFD_REWRITES 1 + +/* define if you want to compile support for both authentication and privacy + support. */ +#define NETSNMP_ENABLE_SCAPI_AUTHPRIV 1 + +/* testing code sections. */ +/* #undef NETSNMP_ENABLE_TESTING_CODE */ + +/* Type of fd_set::fds_bits */ +#define NETSNMP_FD_MASK_TYPE __int32_t + +/* if defined always use default auth/priv protocol when creating usmUsers */ +/* #undef NETSNMP_FORCE_SYSTEM_V3_AUTHPRIV */ + +/* Should evaluate to the name of the current function if defined */ +#define NETSNMP_FUNCTION __func__ + +/* ifnet needs to have _KERNEL defined */ +/* #undef NETSNMP_IFNET_NEEDS_KERNEL */ + +/* ifnet needs to have _KERNEL_STRUCTURES defined */ +/* #undef NETSNMP_IFNET_NEEDS_KERNEL_STRUCTURES */ + +/* Type of the third argument of ioctlsocket() */ +#define NETSNMP_IOCTLSOCKET_ARG unknown + +/* Define if you want to remove all non-essential code features. */ +/* #undef NETSNMP_MINIMAL_CODE */ + +/* Define if you want to only support sending notifications */ +/* #undef NETSNMP_NOTIFY_ONLY */ + +/* Define to suppress inclusion of deprecated functions */ +/* #undef NETSNMP_NO_DEPRECATED_FUNCTIONS */ + +/* If you don't want the agent to report on variables it doesn't have data for + */ +#define NETSNMP_NO_DUMMY_VALUES 1 + +/* If we don't want to use kmem. */ +/* #undef NETSNMP_NO_KMEM_USAGE */ + +/* Define if you want to remove all listening support from the code */ +/* #undef NETSNMP_NO_LISTEN_SUPPORT */ + +/* If you don't have root access don't exit upon kmem errors */ +/* #undef NETSNMP_NO_ROOT_ACCESS */ + +/* If you don't want to integrate with systemd. */ +#define NETSNMP_NO_SYSTEMD 1 + +/* Define if you want to remove all SET/write access from the code */ +/* #undef NETSNMP_NO_WRITE_SUPPORT */ + +/* umask permissions to set up persistent files with */ +#define NETSNMP_PERSISTENT_MASK 077 + +/* Size prefix to use to printf a size_t or ssize_t */ +#define NETSNMP_PRIz "z" + +/* Define to 1 if you want to build with reentrant/threaded code (incomplete). + */ +/* #undef NETSNMP_REENTRANT */ + +/* Type of the fifth argument of select() */ +#define NETSNMP_SELECT_TIMEVAL struct timeval + +/* define if you do not want snmptrapd to register as an AgentX subagent */ +/* #undef NETSNMP_SNMPTRAPD_DISABLE_AGENTX */ + +/* Pattern of temporary files */ +#define NETSNMP_TEMP_FILE_PATTERN "/tmp/snmpdXXXXXX" + +/* "Define if internal cryptography code should be used" */ +/* #undef NETSNMP_USE_INTERNAL_CRYPTO */ + +/* define if you are using the MD5 code ... */ +/* #undef NETSNMP_USE_INTERNAL_MD5 */ + +/* Define this if you're using Heimdal Kerberos */ +/* #undef NETSNMP_USE_KERBEROS_HEIMDAL */ + +/* Define this if we're using the new MIT crypto API */ +/* #undef NETSNMP_USE_KERBEROS_MIT */ + +/* define if you are using the mysql code for snmptrapd ... */ +/* #undef NETSNMP_USE_MYSQL */ + +/* Define if you are using the codeS11 library ... */ +/* #undef NETSNMP_USE_PKCS11 */ + +/* Define this if you have lm_sensors v3 or later */ +/* #undef NETSNMP_USE_SENSORS_V3 */ + +/* Should we compile to use special opaque types: float, double, counter64, + i64, ui64, union? */ +#define NETSNMP_WITH_OPAQUE_SPECIAL_TYPES 1 + +/* Define to the address where bug reports for this package should be sent. */ +#ifndef PACKAGE_BUGREPORT +#define PACKAGE_BUGREPORT "net-snmp-coders@lists.sourceforge.net" +#endif + +/* Define to the full name of this package. */ +#ifndef PACKAGE_NAME +#define PACKAGE_NAME "Net-SNMP" +#endif + +/* Define to the full name and version of this package. */ +#ifndef PACKAGE_STRING +#define PACKAGE_STRING "Net-SNMP 5.9.4.pre2" +#endif + +/* Define to the one symbol short name of this package. */ +#ifndef PACKAGE_TARNAME +#define PACKAGE_TARNAME "net-snmp" +#endif + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "5.9.4.pre2" +#endif + +/* Command to generate ps output, the final column must be the process name + withOUT arguments */ +#define PSCMD "/usr/bin/ps -e" + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* define rtentry to ortentry on SYSV machines (alphas) */ +#define RTENTRY struct rtentry + +/* Use BSD 4.4 routing table entries? */ +/* #undef RTENTRY_4_4 */ + +/* Qualifier for second argument of the appverify_cookie_cb() callback + function */ +#define SECOND_APPVERIFY_COOKIE_CB_ARG_QUALIFIER const + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `intmax_t', as computed by sizeof. */ +#define SIZEOF_INTMAX_T 8 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `sockaddr_un.sun_path', as computed by sizeof. */ +#define SIZEOF_SOCKADDR_UN_SUN_PATH 108 + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define if statfs takes 2 args and the second argument has type struct + fs_data. [Ultrix] */ +/* #undef STAT_STATFS_FS_DATA */ + +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#define STDC_HEADERS 1 + +/* define if SIOCGIFADDR exists in sys/ioctl.h */ +/* #undef SYS_IOCTL_H_HAS_SIOCGIFADDR */ + +/* Define if the TCP timer constants in depend on the + integer variable 'hz'. [FreeBSD] */ +/* #undef TCPTV_NEEDS_HZ */ + +/* Define to 1 if you can safely include both and . This + macro is obsolete. */ +#define TIME_WITH_SYS_TIME 1 + +/* Where is the uname command */ +#define UNAMEPROG "/usr/bin/uname" + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable general extensions on macOS. */ +#ifndef _DARWIN_C_SOURCE +# define _DARWIN_C_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# define _HPUX_ALT_XOPEN_SOCKET_API 1 +#endif +/* Identify the host operating system as Minix. + This macro does not affect the system headers' behavior. + A future release of Autoconf may stop defining this macro. */ +#ifndef _MINIX +/* # undef _MINIX */ +#endif +/* Enable general extensions on NetBSD. + Enable NetBSD compatibility extensions on Minix. */ +#ifndef _NETBSD_SOURCE +# define _NETBSD_SOURCE 1 +#endif +/* Enable OpenBSD compatibility extensions on NetBSD. + Oddly enough, this does nothing on OpenBSD. */ +#ifndef _OPENBSD_SOURCE +# define _OPENBSD_SOURCE 1 +#endif +/* Define to 1 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_SOURCE +/* # undef _POSIX_SOURCE */ +#endif +/* Define to 2 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_1_SOURCE +/* # undef _POSIX_1_SOURCE */ +#endif +/* Enable POSIX-compatible threading on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# define __STDC_WANT_IEC_60559_BFP_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# define __STDC_WANT_IEC_60559_DFP_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# define __STDC_WANT_LIB_EXT2__ 1 +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# define __STDC_WANT_MATH_SPEC_FUNCS__ 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable X/Open extensions. Define to 500 only if necessary + to make mbstate_t available. */ +#ifndef _XOPEN_SOURCE +/* # undef _XOPEN_SOURCE */ +#endif + + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT8_T */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* in_addr_t definition if not defined in . Must match the type + of sockaddr_in::sin_addr */ +/* #undef in_addr_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int16_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to the type of a signed integer type of width exactly 8 bits if such + a type exists and the standard includes do not define it. */ +/* #undef int8_t */ + +/* Define to the widest signed integer type if and do + not define. */ +/* #undef intmax_t */ + +/* Define to the type of a signed integer type wide enough to hold a pointer, + if such a type exists, and if the system does not define it. */ +/* #undef intptr_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define as a signed integer type capable of holding a process identifier. */ +/* #undef pid_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint16_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint8_t */ + +/* Define to the widest unsigned integer type if and + do not define. */ +/* #undef uintmax_t */ + +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +/* #undef uintptr_t */ + +/* end of definitions added by configure on-the-fly */ + +/* If you have openssl 0.9.7 or above, you likely have AES support. */ +#define NETSNMP_USE_OPENSSL 1 +#if (defined(NETSNMP_USE_OPENSSL) && defined(HAVE_OPENSSL_AES_H) && defined(HAVE_AES_CFB128_ENCRYPT)) || defined(NETSNMP_USE_INTERNAL_CRYPTO) +#define HAVE_AES 1 +#endif + +/* define signal if DNE */ + +#ifndef HAVE_SIGNAL +#ifdef HAVE_SIGSET +#define signal(a,b) sigset(a,b) +#endif +#endif + +#ifdef HAVE_DMALLOC_H +#define DMALLOC_FUNC_CHECK +#endif + +#endif /* NETSNMP_NO_AUTOCONF_DEFINITIONS */ + + +/* ********* NETSNMP_MARK_BEGIN_CLEAN_NAMESPACE ********* */ +/* + * put all new net-snmp-specific definitions here + * + * all definitions MUST have a NETSNMP_ prefix + * + */ + +/* Default (SNMP) version number for the tools to use */ +#define NETSNMP_DEFAULT_SNMP_VERSION 3 + +/* don't change these values! */ +#define NETSNMP_SNMPV1 0xAAAA /* readable by anyone */ +#define NETSNMP_SNMPV2ANY 0xA000 /* V2 Any type (includes NoAuth) */ +#define NETSNMP_SNMPV2AUTH 0x8000 /* V2 Authenticated requests only */ + +/* default list of mibs to load */ +#define NETSNMP_DEFAULT_MIBS ":SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:HOST-RESOURCES-TYPES:UCD-DISKIO-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IP-FORWARD-MIB:NET-SNMP-PASS-MIB:NET-SNMP-EXTEND-MIB:UCD-DLMOD-MIB:SNMP-NOTIFICATION-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB" + +/* debugging stuff */ +/* if defined, we optimize the code to exclude all debugging calls. */ +/* #undef NETSNMP_NO_DEBUGGING */ +/* ignore the -D flag and always print debugging information */ +#define NETSNMP_ALWAYS_DEBUG 0 + +/* reverse encoding BER packets is both faster and more efficient in space. */ +#define NETSNMP_USE_REVERSE_ASNENCODING 1 +#define NETSNMP_DEFAULT_ASNENCODING_DIRECTION 1 /* 1 = reverse, 0 = forwards */ + +/* PERSISTENT_DIRECTORY: If defined, the library is capabile of saving + persisant information to this directory in the form of configuration + lines: PERSISTENT_DIRECTORY/NAME.persistent.conf */ +#define NETSNMP_PERSISTENT_DIRECTORY "/var/net-snmp" + +/* AGENT_DIRECTORY_MODE: the mode the agents should use to create + directories with. Since the data stored here is probably sensitive, it + probably should be read-only by root/administrator. */ +#define NETSNMP_AGENT_DIRECTORY_MODE 0700 + +/* MAX_PERSISTENT_BACKUPS: + * The maximum number of persistent backups the library will try to + * read from the persistent cache directory. If an application fails to + * close down successfully more than this number of times, data will be lost. + */ +#define NETSNMP_MAX_PERSISTENT_BACKUPS 10 + +/* define the system type include file here */ +#define NETSNMP_SYSTEM_INCLUDE_FILE "net-snmp/system/solaris.h" + +/* define the machine (cpu) type include file here */ +#define NETSNMP_MACHINE_INCLUDE_FILE "net-snmp/machine/generic.h" + +/* define the UDP buffer defaults undefined means use the OS buffers + * by default */ +/* #undef NETSNMP_DEFAULT_SERVER_SEND_BUF */ +/* #undef NETSNMP_DEFAULT_SERVER_RECV_BUF */ +/* #undef NETSNMP_DEFAULT_CLIENT_SEND_BUF */ +/* #undef NETSNMP_DEFAULT_CLIENT_RECV_BUF */ + +/* net-snmp's major path names */ +#define SNMPLIBPATH "/usr/lib/amd64/snmp" +#define SNMPSHAREPATH "/etc/net-snmp/snmp" +#define SNMPCONFPATH "/etc/snmp" +#define SNMPDLMODPATH "/usr/lib/amd64/snmp/dlmod" + +/* NETSNMP_LOGFILE: If defined it closes stdout/err/in and opens this in + out/err's place. (stdin is closed so that sh scripts won't wait for it) */ +#define NETSNMP_LOGFILE "/var/log/snmpd.log" + +/* default system contact */ +#define NETSNMP_SYS_CONTACT "root@localhost" + +/* system location */ +#define NETSNMP_SYS_LOC "Unknown" + +/* Use libwrap to handle allow/deny hosts? */ +/* #undef NETSNMP_USE_LIBWRAP */ + +/* Mib-2 tree Info */ +/* These are the system information variables. */ + +#define NETSNMP_VERS_DESC "unknown" /* overridden at run time */ +#define NETSNMP_SYS_NAME "unknown" /* overridden at run time */ + +/* comment out the second define to turn off functionality for any of + these: (See README for details) */ + +/* proc PROCESSNAME [MAX] [MIN] */ +#define NETSNMP_PROCMIBNUM 2 + +/* exec/shell NAME COMMAND */ +#define NETSNMP_SHELLMIBNUM 8 + +/* swap MIN */ +#define NETSNMP_MEMMIBNUM 4 + +/* disk DISK MINSIZE */ +#define NETSNMP_DISKMIBNUM 9 + +/* load 1 5 15 */ +#define NETSNMP_LOADAVEMIBNUM 10 + +/* which version are you using? This mibloc will tell you */ +#define NETSNMP_VERSIONMIBNUM 100 + +/* Reports errors the agent runs into */ +/* (typically its "can't fork, no mem" problems) */ +#define NETSNMP_ERRORMIBNUM 101 + +/* The sub id of EXTENSIBLEMIB returned to queries of + .iso.org.dod.internet.mgmt.mib-2.system.sysObjectID.0 */ +#define NETSNMP_AGENTID 250 + +/* This ID is returned after the AGENTID above. IE, the resulting + value returned by a query to sysObjectID is + EXTENSIBLEMIB.AGENTID.???, where ??? is defined below by OSTYPE */ + +#define NETSNMP_HPUX9ID 1 +#define NETSNMP_SUNOS4ID 2 +#define NETSNMP_SOLARISID 3 +#define NETSNMP_OSFID 4 +#define NETSNMP_ULTRIXID 5 +#define NETSNMP_HPUX10ID 6 +#define NETSNMP_NETBSD1ID 7 +#define NETSNMP_FREEBSDID 8 +#define NETSNMP_IRIXID 9 +#define NETSNMP_LINUXID 10 +#define NETSNMP_BSDIID 11 +#define NETSNMP_OPENBSDID 12 +#define NETSNMP_WIN32ID 13 +#define NETSNMP_HPUX11ID 14 +#define NETSNMP_AIXID 15 +#define NETSNMP_MACOSXID 16 +#define NETSNMP_DRAGONFLYID 17 +#define NETSNMP_UNKNOWNID 255 + +#ifdef hpux9 +#define NETSNMP_OSTYPE NETSNMP_HPUX9ID +#endif +#ifdef hpux10 +#define NETSNMP_OSTYPE NETSNMP_HPUX10ID +#endif +#ifdef hpux11 +#define NETSNMP_OSTYPE NETSNMP_HPUX11ID +#endif +#ifdef sunos4 +#define NETSNMP_OSTYPE NETSNMP_SUNOS4ID +#endif +#ifdef solaris2 +#define NETSNMP_OSTYPE NETSNMP_SOLARISID +#endif +#if defined(osf3) || defined(osf4) || defined(osf5) +#define NETSNMP_OSTYPE NETSNMP_OSFID +#endif +#ifdef ultrix4 +#define NETSNMP_OSTYPE NETSNMP_ULTRIXID +#endif +#if defined(netbsd1) || defined(netbsd2) +#define NETSNMP_OSTYPE NETSNMP_NETBSD1ID +#endif +#if defined(__FreeBSD__) +#define NETSNMP_OSTYPE NETSNMP_FREEBSDID +#endif +#if defined(__DragonFly__) +#define NETSNMP_OSTYPE NETSNMP_DRAGONFLYID +#endif +#if defined(irix6) || defined(irix5) +#define NETSNMP_OSTYPE NETSNMP_IRIXID +#endif +#ifdef linux +#define NETSNMP_OSTYPE NETSNMP_LINUXID +#endif +#if defined(bsdi2) || defined(bsdi3) || defined(bsdi4) +#define NETSNMP_OSTYPE NETSNMP_BSDIID +#endif +#if defined(openbsd) +#define NETSNMP_OSTYPE NETSNMP_OPENBSDID +#endif +#ifdef WIN32 +#define NETSNMP_OSTYPE NETSNMP_WIN32ID +#endif +#if defined(aix3) || defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7) +#define NETSNMP_OSTYPE NETSNMP_AIXID +#endif +#if defined(darwin) && (darwin >= 8) +#define NETSNMP_OSTYPE NETSNMP_MACOSXID +#endif +/* unknown */ +#ifndef NETSNMP_OSTYPE +#define NETSNMP_OSTYPE NETSNMP_UNKNOWNID +#endif + +/* The enterprise number has been assigned by the IANA group. */ +/* Optionally, this may point to the location in the tree your */ +/* company/organization has been allocated. */ +/* The assigned enterprise number for the NET_SNMP MIB modules. */ +#define NETSNMP_ENTERPRISE_OID 8072 +#define NETSNMP_ENTERPRISE_MIB 1,3,6,1,4,1,8072 +#define NETSNMP_ENTERPRISE_DOT_MIB 1.3.6.1.4.1.8072 +#define NETSNMP_ENTERPRISE_DOT_MIB_LENGTH 7 + +/* The assigned enterprise number for sysObjectID. */ +#define NETSNMP_SYSTEM_MIB 1,3,6,1,4,1,8072,3,2,NETSNMP_OSTYPE +#define NETSNMP_SYSTEM_DOT_MIB 1.3.6.1.4.1.8072.3.2.NETSNMP_OSTYPE +#define NETSNMP_SYSTEM_DOT_MIB_LENGTH 10 + +/* The assigned enterprise number for notifications. */ +#define NETSNMP_NOTIFICATION_MIB 1,3,6,1,4,1,8072,4 +#define NETSNMP_NOTIFICATION_DOT_MIB 1.3.6.1.4.1.8072.4 +#define NETSNMP_NOTIFICATION_DOT_MIB_LENGTH 8 + +/* this is the location of the ucdavis mib tree. It shouldn't be + changed, as the places it is used are expected to be constant + values or are directly tied to the UCD-SNMP-MIB. */ +#define NETSNMP_UCDAVIS_OID 2021 +#define NETSNMP_UCDAVIS_MIB 1,3,6,1,4,1,2021 +#define NETSNMP_UCDAVIS_DOT_MIB 1.3.6.1.4.1.2021 +#define NETSNMP_UCDAVIS_DOT_MIB_LENGTH 7 + +/* how long to wait (seconds) for error querys before reseting the error trap.*/ +#define NETSNMP_ERRORTIMELENGTH 600 + +/* Exec command to fix PROC problems */ +/* %s will be replaced by the process name in error */ + +/* #define NETSNMP_PROCFIXCMD "/usr/bin/perl /local/scripts/fixproc %s" */ + +/* Exec command to fix EXEC problems */ +/* %s will be replaced by the exec/script name in error */ + +/* #define NETSNMP_EXECFIXCMD "/usr/bin/perl /local/scripts/fixproc %s" */ + +/* Should exec output Cashing be used (speeds up things greatly), and + if so, After how many seconds should the cache re-newed? Note: + Don't define CASHETIME to disable cashing completely */ + +#define NETSNMP_EXCACHETIME 30 +#define NETSNMP_CACHEFILE ".snmp-exec-cache" +#define NETSNMP_MAXCACHESIZE (1500*80) /* roughly 1500 lines max */ + +/* misc defaults */ + +/* default of 100 meg minimum if the minimum size is not specified in + the config file */ +#define NETSNMP_DEFDISKMINIMUMSPACE 100000 + +/* default maximum load average before error */ +#define NETSNMP_DEFMAXLOADAVE 12.0 + +/* max times to loop reading output from execs. */ +/* Because of sleep(1)s, this will also be time to wait (in seconds) for exec + to finish */ +#define NETSNMP_MAXREADCOUNT 100 + +/* Set if snmpgets should block and never timeout */ +/* The original CMU code had this hardcoded as = 1 */ +#define NETSNMP_SNMPBLOCK 1 + +/* How long to wait before restarting the agent after a snmpset to + EXTENSIBLEMIB.VERSIONMIBNUM.VERRESTARTAGENT. This is + necessary to finish the snmpset reply before restarting. */ +#define NETSNMP_RESTARTSLEEP 5 + +/* UNdefine to allow specifying zero-length community string */ +/* #define NETSNMP_NO_ZEROLENGTH_COMMUNITY 1 */ + +/* Number of community strings to store */ +#define NETSNMP_NUM_COMMUNITIES 5 + +/* internal define */ +#define NETSNMP_LASTFIELD -1 + +/* Pluggable transports. */ + +/* This is defined if support for the UDP/IP transport domain is + available. */ +#define NETSNMP_TRANSPORT_UDP_DOMAIN 1 + +/* This is defined if support for the shared UDP/IP transport domain is + available. */ +/* #undef NETSNMP_TRANSPORT_UDPSHARED_DOMAIN */ + +/* This is defined if support for the "callback" transport domain is + available. */ +#define NETSNMP_TRANSPORT_CALLBACK_DOMAIN 1 + +/* This is defined if support for the TCP/IP transport domain is + available. */ +#define NETSNMP_TRANSPORT_TCP_DOMAIN 1 + +/* This is defined if support for the Unix transport domain + (a.k.a. "local IPC") is available. */ +#define NETSNMP_TRANSPORT_UNIX_DOMAIN 1 + +/* This is defined if support for the AAL5 PVC transport domain is + available. */ +/* #undef NETSNMP_TRANSPORT_AAL5PVC_DOMAIN */ + +/* This is defined if support for the IPX transport domain is + available. */ +/* #undef NETSNMP_TRANSPORT_IPX_DOMAIN */ + +/* This is defined if support for the UDP/IPv6 transport domain is + available. */ +#define NETSNMP_TRANSPORT_UDPIPV6_DOMAIN 1 + +/* This is defined if support for the TCP/IPv6 transport domain is + available. */ +#define NETSNMP_TRANSPORT_TCPIPV6_DOMAIN 1 + +/* This is defined if support for the TLS transport domain is + available. */ +/* #undef NETSNMP_TRANSPORT_TLSBASE_DOMAIN */ + +/* This is defined if support for the Alias transport domain is + available. */ +#define NETSNMP_TRANSPORT_ALIAS_DOMAIN 1 + +/* This is defined if support for the SSH transport domain is + available. */ +/* #undef NETSNMP_TRANSPORT_SSH_DOMAIN */ + +/* This is defined if support for the DTLS/UDP transport domain is + available. */ +/* #undef NETSNMP_TRANSPORT_DTLSUDP_DOMAIN */ + +/* This is defined if support for the TLS/TCP transport domain is + available. */ +/* #undef NETSNMP_TRANSPORT_TLSTCP_DOMAIN */ + +/* This is defined if support for stdin/out transport domain is available. */ +/* #undef NETSNMP_TRANSPORT_STD_DOMAIN */ + +/* This is defined if support for the IPv4Base transport domain is available. */ +#define NETSNMP_TRANSPORT_IPV4BASE_DOMAIN 1 + +/* define this if the USM security module is available */ +#define NETSNMP_SECMOD_USM 1 + +/* define this if the KSM (kerberos based snmp) security module is available */ +/* #undef NETSNMP_SECMOD_KSM */ + +/* define this if the local security module is available */ +/* #undef NETSNMP_SECMOD_LOCALSM */ + +/* define if configured as a "mini-agent" */ +/* #undef NETSNMP_MINI_AGENT */ + +/* this is the location of the net-snmp mib tree. It shouldn't be + changed, as the places it is used are expected to be constant + values or are directly tied to the UCD-SNMP-MIB. */ +#define NETSNMP_OID 8072 +#define NETSNMP_MIB 1,3,6,1,4,1,8072 +#define NETSNMP_DOT_MIB 1.3.6.1.4.1.8072 +#define NETSNMP_DOT_MIB_LENGTH 7 + +/* pattern for temporary file names */ +#define NETSNMP_TEMP_FILE_PATTERN "/tmp/snmpdXXXXXX" + +/* + * this must be before the system/machine includes, to allow them to + * override and turn off inlining. To do so, they should do the + * following: + * + * #undef NETSNMP_ENABLE_INLINE + * #define NETSNMP_ENABLE_INLINE 0 + * + * A user having problems with their compiler can also turn off + * the use of inline by defining NETSNMP_NO_INLINE via their cflags: + * + * -DNETSNMP_NO_INLINE + * + * Header and source files should only test against NETSNMP_USE_INLINE: + * + * #ifdef NETSNMP_USE_INLINE + * NETSNMP_INLINE function(int parm) { return parm -1; } + * #endif + * + * Functions which should be static, regardless of whether or not inline + * is available or enabled should use the NETSNMP_STATIC_INLINE macro, + * like so: + * + * NETSNMP_STATIC_INLINE function(int parm) { return parm -1; } + * + * NOT like this: + * + * static NETSNMP_INLINE function(int parm) { return parm -1; } + * + */ +#ifdef NETSNMP_BROKEN_INLINE +# define NETSNMP_ENABLE_INLINE 0 +#else +# define NETSNMP_ENABLE_INLINE 1 +#endif + +#include NETSNMP_SYSTEM_INCLUDE_FILE +#include NETSNMP_MACHINE_INCLUDE_FILE + +#if NETSNMP_ENABLE_INLINE && !defined(NETSNMP_NO_INLINE) +# define NETSNMP_USE_INLINE 1 +# ifndef NETSNMP_INLINE +# define NETSNMP_INLINE __inline__ +# endif +# ifndef NETSNMP_STATIC_INLINE +# define NETSNMP_STATIC_INLINE static __inline__ +# endif +#else +# define NETSNMP_INLINE +# define NETSNMP_STATIC_INLINE static +#endif + +#ifndef NETSNMP_IMPORT +# define NETSNMP_IMPORT extern +#endif + +/* comment the next line if you are compiling with libsnmp.h + and are not using the UC-Davis SNMP library. */ +#define UCD_SNMP_LIBRARY 1 + +/* final conclusion on nlist usage */ +#if defined(HAVE_NLIST) && defined(HAVE_STRUCT_NLIST_N_VALUE) && !defined(NETSNMP_DONT_USE_NLIST) && !defined(NETSNMP_NO_KMEM_USAGE) +#define NETSNMP_CAN_USE_NLIST +#endif + +/* + * Note: GCC 4.6 added __BYTE_ORDER__, __ORDER_BIG_ENDIAN__, + * __ORDER_LITTLE_ENDIAN__ and __ORDER_PDP_ENDIAN__ in SVN r165881. For older + * gcc versions and also for other compilers, determine the endianness by + * calling a function that can be inlined. + */ +#if defined(__BYTE_ORDER__) +# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define NETSNMP_BIGENDIAN 1 +# elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define NETSNMP_BIGENDIAN 0 +# else +# error Unknown byte order +# endif +#else +NETSNMP_STATIC_INLINE int netsnmp_bigendian(void) +{ + union { unsigned long l; unsigned char c; } u; + + u.l = 1; + + return u.c == 0; +} +# define NETSNMP_BIGENDIAN netsnmp_bigendian() +#endif + + +/* ********* NETSNMP_MARK_BEGIN_LEGACY_DEFINITIONS *********/ +/* + * existing definitions prior to Net-SNMP 5.4 + * + * do not add anything new here + * + */ + +#ifndef NETSNMP_NO_LEGACY_DEFINITIONS + +#ifdef NETSNMP_DEFAULT_SNMP_VERSION +# define DEFAULT_SNMP_VERSION NETSNMP_DEFAULT_SNMP_VERSION +#endif + +#ifdef NETSNMP_SNMPV1 +# define SNMPV1 NETSNMP_SNMPV1 +#endif + +#ifdef NETSNMP_SNMPV2ANY +# define SNMPV2ANY NETSNMP_SNMPV2ANY +#endif + +#ifdef NETSNMP_SNMPV2AUTH +# define SNMPV2AUTH NETSNMP_SNMPV2AUTH +#endif + +#ifdef NETSNMP_DEFAULT_MIBS +# define DEFAULT_MIBS NETSNMP_DEFAULT_MIBS +#endif + +#ifdef NETSNMP_DEFAULT_MIBDIRS +# define DEFAULT_MIBDIRS NETSNMP_DEFAULT_MIBDIRS +#endif + +#ifdef NETSNMP_DEFAULT_MIBFILES +# define DEFAULT_MIBFILES NETSNMP_DEFAULT_MIBFILES +#endif + +#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES +# define OPAQUE_SPECIAL_TYPES NETSNMP_WITH_OPAQUE_SPECIAL_TYPES +#endif + +#ifdef NETSNMP_ENABLE_SCAPI_AUTHPRIV +# define SCAPI_AUTHPRIV NETSNMP_ENABLE_SCAPI_AUTHPRIV +#endif + +#ifdef NETSNMP_USE_INTERNAL_MD5 +# define USE_INTERNAL_MD5 NETSNMP_USE_INTERNAL_MD5 +#endif + +#ifdef NETSNMP_USE_PKCS11 +# define USE_PKCS NETSNMP_USE_PKCS11 +#endif + +#ifdef NETSNMP_USE_OPENSSL +# define USE_OPENSSL NETSNMP_USE_OPENSSL +#endif + +#ifdef NETSNMP_NO_DEBUGGING +# define SNMP_NO_DEBUGGING NETSNMP_NO_DEBUGGING +#endif + +#ifdef NETSNMP_ALWAYS_DEBUG +# define SNMP_ALWAYS_DEBUG NETSNMP_ALWAYS_DEBUG +#endif + +#ifdef NETSNMP_USE_REVERSE_ASNENCODING +# define USE_REVERSE_ASNENCODING NETSNMP_USE_REVERSE_ASNENCODING +#endif +#ifdef NETSNMP_DEFAULT_ASNENCODING_DIRECTION +# define DEFAULT_ASNENCODING_DIRECTION NETSNMP_DEFAULT_ASNENCODING_DIRECTION +#endif + +#define PERSISTENT_DIRECTORY NETSNMP_PERSISTENT_DIRECTORY +#define PERSISTENT_MASK NETSNMP_PERSISTENT_MASK +#define AGENT_DIRECTORY_MODE NETSNMP_AGENT_DIRECTORY_MODE +#define MAX_PERSISTENT_BACKUPS NETSNMP_MAX_PERSISTENT_BACKUPS +#define SYSTEM_INCLUDE_FILE NETSNMP_SYSTEM_INCLUDE_FILE +#define MACHINE_INCLUDE_FILE NETSNMP_MACHINE_INCLUDE_FILE + +#ifdef NETSNMP_DEFAULT_SERVER_SEND_BUF +# define DEFAULT_SERVER_SEND_BUF NETSNMP_DEFAULT_SERVER_SEND_BUF +#endif +#ifdef NETSNMP_DEFAULT_SERVER_RECV_BUF +# define DEFAULT_SERVER_RECV_BUF NETSNMP_DEFAULT_SERVER_RECV_BUF +#endif +#ifdef NETSNMP_DEFAULT_CLIENT_SEND_BUF +# define DEFAULT_CLIENT_SEND_BUF NETSNMP_DEFAULT_CLIENT_SEND_BUF +#endif +#ifdef NETSNMP_DEFAULT_CLIENT_RECV_BUF +# define DEFAULT_CLIENT_RECV_BUF NETSNMP_DEFAULT_CLIENT_RECV_BUF +#endif + +#ifdef NETSNMP_LOGFILE +# define LOGFILE NETSNMP_LOGFILE +#endif + +#ifdef NETSNMP_SYS_CONTACT +# define SYS_CONTACT NETSNMP_SYS_CONTACT +#endif + +#ifdef NETSNMP_SYS_LOC +# define SYS_LOC NETSNMP_SYS_LOC +#endif + +#ifdef NETSNMP_USE_LIBWRAP +# define USE_LIBWRAP NETSNMP_USE_LIBWRAP +#endif + +#ifdef NETSNMP_ENABLE_TESTING_CODE +# define SNMP_TESTING_CODE NETSNMP_ENABLE_TESTING_CODE +#endif + +#ifdef NETSNMP_NO_ROOT_ACCESS +# define NO_ROOT_ACCESS NETSNMP_NO_ROOT_ACCESS +#endif + +#ifdef NETSNMP_NO_KMEM_USAGE +# define NO_KMEM_USAGE NETSNMP_NO_KMEM_USAGE +#endif + +#ifdef NETSNMP_NO_DUMMY_VALUES +# define NO_DUMMY_VALUES NETSNMP_NO_DUMMY_VALUES +#endif + +#define VERS_DESC NETSNMP_VERS_DESC +#define SYS_NAME NETSNMP_SYS_NAME + +#define PROCMIBNUM NETSNMP_PROCMIBNUM +#define SHELLMIBNUM NETSNMP_SHELLMIBNUM +#define MEMMIBNUM NETSNMP_MEMMIBNUM +#define DISKMIBNUM NETSNMP_DISKMIBNUM + +#define LOADAVEMIBNUM NETSNMP_LOADAVEMIBNUM +#define VERSIONMIBNUM NETSNMP_VERSIONMIBNUM +#define ERRORMIBNUM NETSNMP_ERRORMIBNUM +#define AGENTID NETSNMP_AGENTID + +#define HPUX9ID NETSNMP_HPUX9ID +#define SUNOS4ID NETSNMP_SUNOS4ID +#define SOLARISID NETSNMP_SOLARISID +#define OSFID NETSNMP_OSFID +#define ULTRIXID NETSNMP_ULTRIXID +#define HPUX10ID NETSNMP_HPUX10ID +#define NETBSD1ID NETSNMP_NETBSD1ID +#define FREEBSDID NETSNMP_FREEBSDID +#define IRIXID NETSNMP_IRIXID +#define LINUXID NETSNMP_LINUXID +#define BSDIID NETSNMP_BSDIID +#define OPENBSDID NETSNMP_OPENBSDID +#define WIN32ID NETSNMP_WIN32ID +#define HPUX11ID NETSNMP_HPUX11ID +#define AIXID NETSNMP_AIXID +#define MACOSXID NETSNMP_MACOSXID +#define DRAGONFLYID NETSNMP_DRAGONFLYID +#define UNKNOWNID NETSNMP_UNKNOWNID + +#define ENTERPRISE_OID NETSNMP_ENTERPRISE_OID +#define ENTERPRISE_MIB NETSNMP_ENTERPRISE_MIB +#define ENTERPRISE_DOT_MIB NETSNMP_ENTERPRISE_DOT_MIB +#define ENTERPRISE_DOT_MIB_LENGTH NETSNMP_ENTERPRISE_DOT_MIB_LENGTH + +#define SYSTEM_MIB NETSNMP_SYSTEM_MIB +#define SYSTEM_DOT_MIB NETSNMP_SYSTEM_DOT_MIB +#define SYSTEM_DOT_MIB_LENGTH NETSNMP_SYSTEM_DOT_MIB_LENGTH + +#define NOTIFICATION_MIB NETSNMP_NOTIFICATION_MIB +#define NOTIFICATION_DOT_MIB NETSNMP_NOTIFICATION_DOT_MIB +#define NOTIFICATION_DOT_MIB_LENGTH NETSNMP_NOTIFICATION_DOT_MIB_LENGTH + +#define UCDAVIS_OID NETSNMP_UCDAVIS_OID +#define UCDAVIS_MIB NETSNMP_UCDAVIS_MIB +#define UCDAVIS_DOT_MIB NETSNMP_UCDAVIS_DOT_MIB +#define UCDAVIS_DOT_MIB_LENGTH NETSNMP_UCDAVIS_DOT_MIB_LENGTH + +#define ERRORTIMELENGTH NETSNMP_ERRORTIMELENGTH + +#ifdef NETSNMP_PROCFIXCMD +# define PROCFIXCMD NETSNMP_PROCFIXCMD +#endif + +#ifdef NETSNMP_EXECFIXCMD +# define EXECFIXCMD NETSNMP_EXECFIXCMD +#endif + +#define EXCACHETIME NETSNMP_EXCACHETIME +#define CACHEFILE NETSNMP_CACHEFILE +#define MAXCACHESIZE NETSNMP_MAXCACHESIZE + +#define DEFDISKMINIMUMSPACE NETSNMP_DEFDISKMINIMUMSPACE +#define DEFMAXLOADAVE NETSNMP_DEFMAXLOADAVE +#define MAXREADCOUNT NETSNMP_MAXREADCOUNT + +#define SNMPBLOCK NETSNMP_SNMPBLOCK +#define RESTARTSLEEP NETSNMP_RESTARTSLEEP + +#define NUM_COMMUNITIES NETSNMP_NUM_COMMUNITIES + +#ifdef NETSNMP_NO_ZEROLENGTH_COMMUNITY +# define NO_ZEROLENGTH_COMMUNITY NETSNMP_NO_ZEROLENGTH_COMMUNITY +#endif + +#define LASTFIELD NETSNMP_LASTFIELD + +#define CONFIGURE_OPTIONS NETSNMP_CONFIGURE_OPTIONS + +#ifdef NETSNMP_TRANSPORT_UDP_DOMAIN +# define SNMP_TRANSPORT_UDP_DOMAIN NETSNMP_TRANSPORT_UDP_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_CALLBACK_DOMAIN +# define SNMP_TRANSPORT_CALLBACK_DOMAIN NETSNMP_TRANSPORT_CALLBACK_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_TCP_DOMAIN +# define SNMP_TRANSPORT_TCP_DOMAIN NETSNMP_TRANSPORT_TCP_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_UNIX_DOMAIN +# define SNMP_TRANSPORT_UNIX_DOMAIN NETSNMP_TRANSPORT_UNIX_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_AAL5PVC_DOMAIN +# define SNMP_TRANSPORT_AAL5PVC_DOMAIN NETSNMP_TRANSPORT_AAL5PVC_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_IPX_DOMAIN +# define SNMP_TRANSPORT_IPX_DOMAIN NETSNMP_TRANSPORT_IPX_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN +# define SNMP_TRANSPORT_UDPIPV6_DOMAIN NETSNMP_TRANSPORT_UDPIPV6_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_TCPIPV6_DOMAIN +# define SNMP_TRANSPORT_TCPIPV6_DOMAIN NETSNMP_TRANSPORT_TCPIPV6_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_TLS_DOMAIN +# define SNMP_TRANSPORT_TLS_DOMAIN NETSNMP_TRANSPORT_TLS_DOMAIN +#endif + +#ifdef NETSNMP_TRANSPORT_STD_DOMAIN +# define SNMP_TRANSPORT_STD_DOMAIN NETSNMP_TRANSPORT_STD_DOMAIN +#endif + +#ifdef NETSNMP_SECMOD_USM +# define SNMP_SECMOD_USM NETSNMP_SECMOD_USM +#endif + +#ifdef NETSNMP_SECMOD_KSM +# define SNMP_SECMOD_KSM NETSNMP_SECMOD_KSM +#endif + +#ifdef NETSNMP_SECMOD_LOCALSM +# define SNMP_SECMOD_LOCALSM NETSNMP_SECMOD_LOCALSM +#endif + +#ifdef NETSNMP_REENTRANT +# define NS_REENTRANT NETSNMP_REENTRANT +#endif + +#ifdef NETSNMP_ENABLE_IPV6 +# define INET6 NETSNMP_ENABLE_IPV6 +#endif + +#ifdef NETSNMP_ENABLE_LOCAL_SMUX +# define LOCAL_SMUX NETSNMP_ENABLE_LOCAL_SMUX +#endif + +#ifdef NETSNMP_AGENTX_DOM_SOCK_ONLY +# define AGENTX_DOM_SOCK_ONLY NETSNMP_AGENTX_DOM_SOCK_ONLY +#endif + +#ifdef NETSNMP_SNMPTRAPD_DISABLE_AGENTX +# define SNMPTRAPD_DISABLE_AGENTX +#endif + +#ifdef NETSNMP_USE_KERBEROS_MIT +# define MIT_NEW_CRYPTO NETSNMP_USE_KERBEROS_MIT +#endif + +#ifdef NETSNMP_USE_KERBEROS_HEIMDAL +# define HEIMDAL NETSNMP_USE_KERBEROS_HEIMDAL +#endif + +#ifdef NETSNMP_AGENTX_SOCKET +# define AGENTX_SOCKET NETSNMP_AGENTX_SOCKET +#endif + +#ifdef NETSNMP_DISABLE_MIB_LOADING +# define DISABLE_MIB_LOADING NETSNMP_DISABLE_MIB_LOADING +#endif + +#ifdef NETSNMP_DISABLE_SNMPV1 +# define DISABLE_SNMPV1 NETSNMP_DISABLE_SNMPV1 +#endif + +#ifdef NETSNMP_DISABLE_SNMPV2C +# define DISABLE_SNMPV2C NETSNMP_DISABLE_SNMPV2C +#endif + +#ifdef NETSNMP_DISABLE_SET_SUPPORT +# define DISABLE_SET_SUPPORT NETSNMP_DISABLE_SET_SUPPORT +#endif + +#ifdef NETSNMP_DISABLE_DES +# define DISABLE_DES NETSNMP_DISABLE_DES +#endif + +#ifdef NETSNMP_DISABLE_MD5 +# define DISABLE_MD5 NETSNMP_DISABLE_MD5 +#endif + +#ifdef NETSNMP_DONT_USE_NLIST +# define DONT_USE_NLIST NETSNMP_DONT_USE_NLIST +#endif + +#ifdef NETSNMP_CAN_USE_NLIST +# define CAN_USE_NLIST NETSNMP_CAN_USE_NLIST +#endif + +#ifdef NETSNMP_CAN_USE_SYSCTL +# define CAN_USE_SYSCTL NETSNMP_CAN_USE_SYSCTL +#endif + +#endif /* NETSNMP_NO_LEGACY_DEFINITIONS */ + + +#endif /* NET_SNMP_CONFIG_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/net-snmp-features.h b/illumos-x86_64/usr/include/net-snmp/net-snmp-features.h new file mode 100644 index 00000000..0d53d5b4 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/net-snmp-features.h @@ -0,0 +1,32 @@ +#ifndef NETSNMP_FEATURES_H +#define NETSNMP_FEATURES_H + +/* include files that are only needed if --enable-minimalist is on */ +#ifdef NETSNMP_MINIMAL_CODE +#ifdef NETSNMP_FEATURE_CHECKING +#include +#else /* ! NETSNMP_FEATURE_CHECKING */ +#include +#ifndef NETSNMP_DISABLE_AGENT +#include +#include +#endif +#ifndef NETSNMP_DISABLE_APPS +#include +#include +#endif +#endif /* ! NETSNMP_FEATURE_CHECKING */ +#endif /* NETSNMP_MINIMAL_CODE */ + + +/* prototypes always needed */ +#ifndef NETSNMP_FEATURE_CHECKING +#define netsnmp_feature_provide(X) extern char netsnmp_feature_unused_ ## X +#define netsnmp_feature_require(X) extern char netsnmp_feature_unused_ ## X +#define netsnmp_feature_want(X) extern char netsnmp_feature_unused_ ## X +#define netsnmp_feature_child_of(X, Y) extern char netsnmp_feature_unused_ ## X +#endif + +#define netsnmp_feature_unused(X) extern char netsnmp_feature_unused_ ## X + +#endif /* NETSNMP_FEATURES_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/net-snmp-includes.h b/illumos-x86_64/usr/include/net-snmp/net-snmp-includes.h new file mode 100644 index 00000000..e0d47dcf --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/net-snmp-includes.h @@ -0,0 +1,37 @@ +#ifndef NET_SNMP_INCLUDES_H +#define NET_SNMP_INCLUDES_H + + /** + * Convenience header file to pull in the full + * Net-SNMP library API in one go, together with + * certain commonly-required system header files. + */ + + +#ifndef NET_SNMP_CONFIG_H +#error "Please include before this file" +#endif + +#ifdef HAVE_STRING_H +#include +#else +#include +#endif + + /* + * The full Net-SNMP API + */ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* NET_SNMP_INCLUDES_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/output_api.h b/illumos-x86_64/usr/include/net-snmp/output_api.h new file mode 100644 index 00000000..3b142850 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/output_api.h @@ -0,0 +1,187 @@ +#ifndef NET_SNMP_OUTPUT_API_H +#define NET_SNMP_OUTPUT_API_H + + /** + * Library API routines concerned with logging and message output + * (including error handling and debugging). + */ + +#include /* for va_list */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + /* Error reporting */ + NETSNMP_IMPORT + void snmp_error(netsnmp_session *sess, int *clib_errorno, + int *snmp_errorno, char **errstring); + NETSNMP_IMPORT + void snmp_sess_error( void *sess, int *clib_errorno, + int *snmp_errorno, char **errstring); + + NETSNMP_IMPORT + const char *snmp_api_errstring(int snmp_errorno); /* library errors */ + NETSNMP_IMPORT + const char *snmp_errstring(int snmp_errorno); /* protocol errors */ + + NETSNMP_IMPORT + void snmp_perror(const char *msg); /* for parsing errors only */ + + NETSNMP_IMPORT + void snmp_sess_perror(const char *msg, netsnmp_session *sess); + /* for all other SNMP library errors */ + NETSNMP_IMPORT + void snmp_log_perror(const char *msg); + /* for system library errors */ + + /* Logging messages */ + + NETSNMP_IMPORT + int snmp_log( int priority, const char *format, ...) + NETSNMP_ATTRIBUTE_FORMAT(printf, 2, 3); + NETSNMP_IMPORT + int snmp_vlog(int priority, const char *format, va_list ap); + NETSNMP_IMPORT + int snmp_get_do_logging( void); + NETSNMP_IMPORT + void netsnmp_logging_restart(void); + NETSNMP_IMPORT + void snmp_disable_log( void); + NETSNMP_IMPORT + void shutdown_snmp_logging( void); + +#undef _LOG_ATTR + + /* Debug messages */ +#ifndef NETSNMP_NO_DEBUGGING +#include /* for internal macros */ +#define DEBUGMSG(x) do {if (_DBG_IF_) {debugmsg x;} }while(0) +#define DEBUGMSGT(x) do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0) +#define DEBUGTRACE do {if (_DBG_IF_) {__DBGTRACE;} }while(0) +#define DEBUGTRACETOK(x) do {if (_DBG_IF_) {__DBGTRACETOK(x);} }while(0) +#define DEBUGMSGL(x) do {if (_DBG_IF_) {__DBGMSGL(x);} }while(0) +#define DEBUGMSGTL(x) do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0) +#define DEBUGMSGOID(x) do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0) +#define DEBUGMSGSUBOID(x) do {if (_DBG_IF_) {__DBGMSGSUBOID(x);} }while(0) +#define DEBUGMSGVAR(x) do {if (_DBG_IF_) {__DBGMSGVAR(x);} }while(0) +#define DEBUGMSGOIDRANGE(x) do {if (_DBG_IF_) {__DBGMSGOIDRANGE(x);} }while(0) +#define DEBUGMSGHEX(x) do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0) +#define DEBUGMSGHEXTLI(x) do {if (_DBG_IF_) {__DBGMSGHEXTLI(x);} }while(0) +#define DEBUGINDENTADD(x) do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0) +#define DEBUGINDENTMORE() do {if (_DBG_IF_) {__DBGINDENTMORE();} }while(0) +#define DEBUGINDENTLESS() do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0) +#define DEBUGPRINTINDENT(token) \ + do {if (_DBG_IF_) {__DBGPRINTINDENT(token);} }while(0) +#define DEBUGDUMPHEADER(token,x) \ + do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0) +#define DEBUGDUMPSECTION(token,x) \ + do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0) +#define DEBUGDUMPSETUP(token,buf,len) \ + do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0) +#define DEBUGMSG_NC(x) do { __DBGMSG_NC(x); }while(0) +#define DEBUGMSGT_NC(x) do { __DBGMSGT_NC(x); }while(0) + +#else /* NETSNMP_NO_DEBUGGING := enable streamlining of the code */ + +NETSNMP_STATIC_INLINE void +netsnmp_debug_no_msg(const char *token, const char *fmt, ...) +{ } + +NETSNMP_STATIC_INLINE void +netsnmp_debug_no_tracetok(const char *token) +{ } + +NETSNMP_STATIC_INLINE void +netsnmp_debug_no_oid(const char *token, const oid *oid, size_t oid_len) +{ } + +struct variable_list; + +NETSNMP_STATIC_INLINE void +netsnmp_debug_no_var(const char *token, const struct variable_list *var) +{ } + +NETSNMP_STATIC_INLINE void +netsnmp_debug_no_dumpsetup(const char *token, const void *buf, size_t len) +{ } + +#define DEBUGMSG(x) do { netsnmp_debug_no_msg x; } while (0) +#define DEBUGMSGT(x) do { netsnmp_debug_no_msg x; } while (0) +#define DEBUGTRACE do { } while (0) +#define DEBUGTRACETOK(x) \ + do { netsnmp_debug_no_tracetok(x); } while (0) +#define DEBUGMSGL(x) do { netsnmp_debug_no_msg x; } while (0) +#define DEBUGMSGTL(x) do { netsnmp_debug_no_msg x; } while (0) +#define DEBUGMSGOID(x) do { netsnmp_debug_no_oid x; } while (0) +#define DEBUGMSGSUBOID(x) do { netsnmp_debug_no_oid x; } while (0) +#define DEBUGMSGVAR(x) do { netsnmp_debug_no_var x; } while (0) +#define DEBUGMSGOIDRANGE(x) +#define DEBUGMSGHEX(x) +#define DEBUGIF(x) if(0) +#define DEBUGDUMP(t,b,l,p) +#define DEBUGINDENTMORE() +#define DEBUGINDENTLESS() +#define DEBUGINDENTADD(x) +#define DEBUGMSGHEXTLI(x) +#define DEBUGPRINTINDENT(token) +#define DEBUGDUMPHEADER(token,x) +#define DEBUGDUMPSECTION(token,x) +#define DEBUGDUMPSETUP(token, buf, len) \ + do { netsnmp_debug_no_dumpsetup(token, buf, len); } while (0) + +#define DEBUGMSG_NC(x) do { netsnmp_debug_no_msg x; } while (0) +#define DEBUGMSGT_NC(x) do { netsnmp_debug_no_msg x; } while (0) + +#endif /* NETSNMP_NO_DEBUGGING */ + + NETSNMP_IMPORT + void debug_register_tokens(const char *tokens); + NETSNMP_IMPORT + int debug_enable_token_logs (const char *token); + NETSNMP_IMPORT + int debug_disable_token_logs (const char *token); + NETSNMP_IMPORT + int debug_is_token_registered(const char *token); + NETSNMP_IMPORT + void snmp_set_do_debugging(int); + NETSNMP_IMPORT + int snmp_get_do_debugging(void); +#ifndef NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL + NETSNMP_IMPORT + void netsnmp_set_debug_log_level(int val); + NETSNMP_IMPORT + int netsnmp_get_debug_log_level(void); +#endif /* NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL */ + + /* + * Having extracted the main ("public API") calls relevant + * to this area of the Net-SNMP project, the next step is to + * identify the related "public internal API" routines. + * + * In due course, these should probably be gathered + * together into a companion 'library/output_api.h' header file. + * [Or some suitable name] + * + * But for the time being, the expectation is that the + * traditional headers that provided the above definitions + * will probably also cover the relevant internal API calls. + * Hence they are listed here: + */ + +#ifdef __cplusplus +} +#endif + +#include +#include +#include +#include + +#ifndef ERROR_MSG +#define ERROR_MSG(string) snmp_set_detail(string) +#endif + +#endif /* NET_SNMP_OUTPUT_API_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/pdu_api.h b/illumos-x86_64/usr/include/net-snmp/pdu_api.h new file mode 100644 index 00000000..125595d9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/pdu_api.h @@ -0,0 +1,46 @@ +#ifndef NET_SNMP_PDU_API_H +#define NET_SNMP_PDU_API_H + + /** + * Library API routines concerned with SNMP PDUs. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +NETSNMP_IMPORT +netsnmp_pdu *snmp_pdu_create(int type); +NETSNMP_IMPORT +netsnmp_pdu *snmp_clone_pdu(netsnmp_pdu *pdu); +NETSNMP_IMPORT +netsnmp_pdu *snmp_fix_pdu( netsnmp_pdu *pdu, int idx); +NETSNMP_IMPORT +void snmp_free_pdu( netsnmp_pdu *pdu); + +#ifdef __cplusplus +} +#endif + + /* + * Having extracted the main ("public API") calls relevant + * to this area of the Net-SNMP project, the next step is to + * identify the related "public internal API" routines. + * + * In due course, these should probably be gathered + * together into a companion 'library/pdu_api.h' header file. + * [Or some suitable name] + * + * But for the time being, the expectation is that the + * traditional headers that provided the above definitions + * will probably also cover the relevant internal API calls. + * Hence they are listed here: + */ + +#include +#include +#include + +#endif /* NET_SNMP_PDU_API_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/session_api.h b/illumos-x86_64/usr/include/net-snmp/session_api.h new file mode 100644 index 00000000..b785b7c6 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/session_api.h @@ -0,0 +1,331 @@ +/* + * Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef NET_SNMP_SESSION_API_H +#define NET_SNMP_SESSION_API_H + + /** + * Library API routines concerned with specifying and using SNMP "sessions" + * including sending and receiving requests. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + struct session_list; + struct timeval; + + + NETSNMP_IMPORT + void snmp_sess_init(netsnmp_session *); + + /* + * netsnmp_session *snmp_open(session) + * netsnmp_session *session; + * + * Sets up the session with the snmp_session information provided + * by the user. Then opens and binds the necessary UDP port. + * A handle to the created session is returned (this is different than + * the pointer passed to snmp_open()). On any error, NULL is returned + * and snmp_errno is set to the appropriate error code. + */ + NETSNMP_IMPORT + netsnmp_session *snmp_open(netsnmp_session *); + + /* + * int snmp_close(session) + * netsnmp_session *session; + * + * Close the input session. Frees all data allocated for the session, + * dequeues any pending requests, and closes any sockets allocated for + * the session. Returns 0 on error, 1 otherwise. + * + * snmp_close_sessions() does the same thing for all open sessions + */ + NETSNMP_IMPORT + int snmp_close(netsnmp_session *); + NETSNMP_IMPORT + int snmp_close_sessions(void); + + NETSNMP_IMPORT + int + _build_initial_pdu_packet(struct session_list *slp, netsnmp_pdu *pdu, + int bulk); + + /* + * int snmp_send(session, pdu) + * netsnmp_session *session; + * netsnmp_pdu *pdu; + * + * Sends the input pdu on the session after calling snmp_build to create + * a serialized packet. If necessary, set some of the pdu data from the + * session defaults. Add a request corresponding to this pdu to the list + * of outstanding requests on this session, then send the pdu. + * Returns the request id of the generated packet if applicable, otherwise 1. + * (There is a special case: if the request id is 0, 1 will be returned). + * On any error, 0 is returned. + * The pdu is freed by snmp_send() unless a failure occured. + */ + NETSNMP_IMPORT + int snmp_send(netsnmp_session *, netsnmp_pdu *); + + /* + * int snmp_async_send(session, pdu, callback, cb_data) + * netsnmp_session *session; + * netsnmp_pdu *pdu; + * netsnmp_callback callback; + * void *cb_data; + * + * Sends the input pdu on the session after calling snmp_build to create + * a serialized packet. If necessary, set some of the pdu data from the + * session defaults. Add a request corresponding to this pdu to the list + * of outstanding requests on this session and store callback and data, + * then send the pdu. + * Returns the request id of the generated packet if applicable, otherwise 1. + * On any error, 0 is returned. + * The pdu is freed by snmp_send() unless a failure occured. + */ + NETSNMP_IMPORT + int snmp_async_send(netsnmp_session *, netsnmp_pdu *, + netsnmp_callback, void *); + + + /* + * void snmp_read(fdset) + * fd_set *fdset; + * + * Checks to see if any of the fd's set in the fdset belong to + * snmp. Each socket with it's fd set has a packet read from it + * and snmp_parse is called on the packet received. The resulting pdu + * is passed to the callback routine for that session. If the callback + * routine returns successfully, the pdu and it's request are deleted. + */ + NETSNMP_IMPORT + void snmp_read(fd_set *); + + /* + * snmp_read2() is similar to snmp_read(), but accepts a pointer to a + * large file descriptor set instead of a pointer to a regular file + * descriptor set. + */ + NETSNMP_IMPORT + void snmp_read2(netsnmp_large_fd_set *); + + + NETSNMP_IMPORT + int snmp_synch_response(netsnmp_session *, netsnmp_pdu *, + netsnmp_pdu **); + + /* + * int snmp_select_info(numfds, fdset, timeout, block) + * int *numfds; + * fd_set *fdset; + * struct timeval *timeout; + * int *block; + * + * Returns info about what snmp requires from a select statement. + * numfds is the number of fds in the list that are significant. + * All file descriptors opened for SNMP are OR'd into the fdset. + * If activity occurs on any of these file descriptors, snmp_read + * should be called with that file descriptor set. + * + * The timeout is the latest time that SNMP can wait for a timeout. The + * select should be done with the minimum time between timeout and any other + * timeouts necessary. This should be checked upon each invocation of select. + * If a timeout is received, snmp_timeout should be called to check if the + * timeout was for SNMP. (snmp_timeout is idempotent) + * + * Block is 1 if the select is requested to block indefinitely, rather than + * time out. If block is input as 1, the timeout value will be treated as + * undefined, but it must be available for setting in snmp_select_info. On + * return, if block is true, the value of timeout will be undefined. + * + * snmp_select_info returns the number of open sockets. (i.e. The number + * of sessions open) + */ + NETSNMP_IMPORT + int snmp_select_info(int *, fd_set *, struct timeval *, + int *); + + /* + * snmp_select_info2() is similar to snmp_select_info(), but accepts a + * pointer to a large file descriptor set instead of a pointer to a + * regular file descriptor set. + */ + NETSNMP_IMPORT + int snmp_select_info2(int *, netsnmp_large_fd_set *, + struct timeval *, int *); + +#define NETSNMP_SELECT_NOFLAGS 0x00 +#define NETSNMP_SELECT_NOALARMS 0x01 + NETSNMP_IMPORT + int snmp_sess_select_info_flags(void *, int *, fd_set *, + struct timeval *, int *, int); + int snmp_sess_select_info2_flags(void *, int *, + netsnmp_large_fd_set *, + struct timeval *, int *, int); + + /* + * void snmp_timeout(); + * + * snmp_timeout should be called whenever the timeout from snmp_select_info + * expires, but it is idempotent, so snmp_timeout can be polled (probably a + * cpu expensive proposition). snmp_timeout checks to see if any of the + * sessions have an outstanding request that has timed out. If it finds one + * (or more), and that pdu has more retries available, a new packet is formed + * from the pdu and is resent. If there are no more retries available, the + * callback for the session is used to alert the user of the timeout. + */ + + NETSNMP_IMPORT + void snmp_timeout(void); + + /* + * single session API. + * + * These functions perform similar actions as snmp_XX functions, + * but operate on a single session only. + * + * Synopsis: + + void * sessp; + netsnmp_session session, *ss; + netsnmp_pdu *pdu, *response; + + snmp_sess_init(&session); + session.retries = ... + sessp = snmp_sess_open(&session); + ss = snmp_sess_session(sessp); + if (ss == NULL) + exit(1); + ... + if (ss->community) free(ss->community); + ss->community = strdup(gateway); + ss->community_len = strlen(gateway); + ... + snmp_sess_synch_response(sessp, pdu, &response); + ... + snmp_sess_close(sessp); + + * See also: + * snmp_sess_synch_response, in snmp_client.h. + + * Notes: + * 1. Invoke snmp_sess_session after snmp_sess_open. + * 2. snmp_sess_session return value is an opaque pointer. + * 3. Do NOT free memory returned by snmp_sess_session. + * 4. Replace snmp_send(ss,pdu) with snmp_sess_send(sessp,pdu) + */ + + NETSNMP_IMPORT + void *snmp_sess_open(netsnmp_session *); + NETSNMP_IMPORT + void *snmp_sess_pointer(netsnmp_session *); + NETSNMP_IMPORT + netsnmp_session *snmp_sess_session(void *); + NETSNMP_IMPORT + netsnmp_session *snmp_sess_session_lookup(void *); + NETSNMP_IMPORT + netsnmp_session *snmp_sess_lookup_by_name(const char *paramName); + + /* + * use return value from snmp_sess_open as void * parameter + */ + + NETSNMP_IMPORT + int snmp_sess_send(void *, netsnmp_pdu *); + NETSNMP_IMPORT + int snmp_sess_async_send(void *, netsnmp_pdu *, + netsnmp_callback, void *); + NETSNMP_IMPORT + int snmp_sess_select_info(void *, int *, fd_set *, + struct timeval *, int *); + NETSNMP_IMPORT + int snmp_sess_select_info2(void *, int *, + netsnmp_large_fd_set *, + struct timeval *, int *); + /* + * Returns 0 if success, -1 if fail. + */ + NETSNMP_IMPORT + int snmp_sess_read(void *, fd_set *); + /* + * Similar to snmp_sess_read(), but accepts a pointer to a large file + * descriptor set instead of a pointer to a file descriptor set. + */ + NETSNMP_IMPORT + int snmp_sess_read2(void *, + netsnmp_large_fd_set *); + NETSNMP_IMPORT + void snmp_sess_timeout(void *); + NETSNMP_IMPORT + int snmp_sess_close(void *); + + NETSNMP_IMPORT + int snmp_sess_synch_response(void *, netsnmp_pdu *, + netsnmp_pdu **); + +#ifdef __cplusplus +} +#endif + + + /* + * Having extracted the main ("public API") calls relevant + * to this area of the Net-SNMP project, the next step is to + * identify the related "public internal API" routines. + * + * In due course, these should probably be gathered + * together into a companion 'library/session_api.h' header file. + * [Or some suitable name] + * + * But for the time being, the expectation is that the + * traditional headers that provided the above definitions + * will probably also cover the relevant internal API calls. + * Hence they are listed here: + */ + +#include +#include +#include +#include + +#include +#include +#include +#ifdef NETSNMP_TRANSPORT_UNIX_DOMAIN +#include +#endif +#ifdef NETSNMP_TRANSPORT_UDP_DOMAIN +#include +#endif +#ifdef NETSNMP_TRANSPORT_TCP_DOMAIN +#include +#endif +#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN +#include +#endif +#ifdef NETSNMP_TRANSPORT_TCPIPV6_DOMAIN +#include +#endif +#ifdef NETSNMP_TRANSPORT_IPX_DOMAIN +#include +#endif +#ifdef NETSNMP_TRANSPORT_AAL5PVC_DOMAIN +#include +#endif + +#include + +#endif /* NET_SNMP_SESSION_API_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/snmpv3_api.h b/illumos-x86_64/usr/include/net-snmp/snmpv3_api.h new file mode 100644 index 00000000..3968f19d --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/snmpv3_api.h @@ -0,0 +1,38 @@ +#ifndef NET_SNMP_SNMPV3_H +#define NET_SNMP_SNMPV3_H + + /** + * Library API routines concerned with SNMPv3 handling. + * + * Most of these would typically not be used directly, + * but be invoked via version-independent API routines. + */ + +#include + + /* + * For the initial release, this will just refer to the + * relevant UCD header files. + * In due course, the routines relevant to this area of the + * API will be identified, and listed here directly. + * + * But for the time being, this header file is a placeholder, + * to allow application writers to adopt the new header file names. + */ + +#include + +#include +#include +#include +#include +#include +#include +#ifdef NETSNMP_USE_INTERNAL_MD5 +#include +#endif + +#include +#include + +#endif /* NET_SNMP_SNMPV3_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/system/aix.h b/illumos-x86_64/usr/include/net-snmp/system/aix.h new file mode 100644 index 00000000..aa75ddc9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/aix.h @@ -0,0 +1,33 @@ +#include +#include +#undef TOTAL_MEMORY_SYMBOL +#undef NPROC_SYMBOL +#undef RTHASHSIZE_SYMBOL +#undef RTHOST_SYMBOL +#undef RTNET_SYMBOL + +#undef RTTABLES_SYMBOL +#define RTTABLES_SYMBOL "rt_tables" + +#ifndef __GNUC__ +# undef NETSNMP_ENABLE_INLINE +# define NETSNMP_ENABLE_INLINE 0 +#endif + +/* define the extra mib modules that are supported */ +#define NETSNMP_INCLUDE_HOST_RESOURCES + +/* the legacy symbol NOACCESS clashes with the system headers. Remove it. */ +#define NETSNMP_NO_LEGACY_DEFINITIONS + +#ifdef _AIX43 +#define aix4 +#endif + +#ifdef _AIX51 +#define aix5 +#endif + +#ifdef _AIX61 +#define aix6 +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/system/bsd.h b/illumos-x86_64/usr/include/net-snmp/system/bsd.h new file mode 100644 index 00000000..ebb0ccd4 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/bsd.h @@ -0,0 +1,15 @@ +#include + +/* + * the bsd route symbol adds an 's' at the end to this symbol name + */ +#undef RTTABLES_SYMBOL +#define RTTABLES_SYMBOL "rt_tables" + +/* + * BSD systems use a different method of looking up sockaddr_in values + */ +#define NEED_KLGETSA 1 + +#define UTMP_HAS_NO_TYPE 1 +#define UTMP_HAS_NO_PID 1 diff --git a/illumos-x86_64/usr/include/net-snmp/system/bsdi.h b/illumos-x86_64/usr/include/net-snmp/system/bsdi.h new file mode 100644 index 00000000..b3387fc5 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/bsdi.h @@ -0,0 +1,3 @@ +#include "bsd.h" + +#define CHECK_RT_FLAGS 1 diff --git a/illumos-x86_64/usr/include/net-snmp/system/bsdi3.h b/illumos-x86_64/usr/include/net-snmp/system/bsdi3.h new file mode 100644 index 00000000..62c0e17e --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/bsdi3.h @@ -0,0 +1,2 @@ +#include "bsdi.h" +#define bsdi2 bsdi2 /* bsdi3 is a superset of bsdi2 */ diff --git a/illumos-x86_64/usr/include/net-snmp/system/bsdi4.h b/illumos-x86_64/usr/include/net-snmp/system/bsdi4.h new file mode 100644 index 00000000..63bec19b --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/bsdi4.h @@ -0,0 +1,11 @@ +#include "bsdi.h" +#define bsdi2 bsdi2 /* bsdi4 is a superset of bsdi2 */ +#undef NPROC_SYMBOL +#undef PROC_SYMBOL + +#define MNTTYPE_UFS "ufs" +#define BerkelyFS 1 +#define MNTTYPE_MSDOS "msdos" +#define MNTTYPE_ISO9660 "cd9660" +#define MNTTYPE_NFS "nfs" +#define MNTTYPE_MFS "mfs" diff --git a/illumos-x86_64/usr/include/net-snmp/system/cygwin.h b/illumos-x86_64/usr/include/net-snmp/system/cygwin.h new file mode 100644 index 00000000..64df9434 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/cygwin.h @@ -0,0 +1 @@ +/* Everything that is specific to Cygwin is detected by the configure script */ diff --git a/illumos-x86_64/usr/include/net-snmp/system/darwin.h b/illumos-x86_64/usr/include/net-snmp/system/darwin.h new file mode 100644 index 00000000..6e7a1c21 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/darwin.h @@ -0,0 +1,71 @@ +#include "freebsd4.h" +#define darwin darwin + +#define CHECK_RT_FLAGS 1 + +/* + * udp_inpcb list symbol, e.g. for mibII/udpTable.c + */ +#define INP_NEXT_SYMBOL inp_next + +/* + * Mac OS X should only use the modern API and definitions. + */ +#ifndef NETSNMP_NO_LEGACY_DEFINITIONS +#define NETSNMP_NO_LEGACY_DEFINITIONS 1 +#endif + +/* + * use new host resources files as well + */ +#define NETSNMP_INCLUDE_HOST_RESOURCES +#define NETSNMP_INCLUDE_HRSWINST_REWRITES +#define NETSNMP_INCLUDE_HRSWRUN_REWRITES +#undef NETSNMP_INCLUDE_HRSWRUN_WRITE_SUPPORT +#define NETSNMP_CAN_GET_DISK_LABEL 1 + +/* + * Enabling this restricts the compiler to mostly public APIs. + */ +#ifndef __APPLE_API_STRICT_CONFORMANCE +#define __APPLE_API_STRICT_CONFORMANCE 1 +#endif +#ifndef __APPLE_API_UNSTABLE +#define __APPLE_API_UNSTABLE 1 +#endif + +/* + * Although Darwin does have an fstab.h file, getfsfile etc. always return null + * At least, as of 5.3. + */ +#undef HAVE_FSTAB_H + +#define SWAPFILE_DIR "/private/var/vm" +#define SWAPFILE_PREFIX "swapfile" + +/* + * These apparently used to be in netinet/tcp_timers.h, but went away in + * 10.4.2. Define them here til we find out a way to get the real values. + */ +#define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ +#define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ + +/* + * Because Mac OS X is built on Mach, it does not provide a BSD-compatible + * VM statistics API. + */ +#define USE_MACH_HOST_STATISTICS 1 + +/* + * utility macro used in several darwin specific files + */ +#define SNMP_CFRelease(x) do { if (x) { CFRelease(x); x = NULL; } } while(0) + +/* + * Mac OS X runs on both PPC and Intel hardware, + * which handle udpTable index values differently + */ +#include +#ifdef TARGET_RT_LITTLE_ENDIAN +#define UDP_ADDRESSES_IN_HOST_ORDER 1 +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/system/dragonfly.h b/illumos-x86_64/usr/include/net-snmp/system/dragonfly.h new file mode 100644 index 00000000..5edb209d --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/dragonfly.h @@ -0,0 +1,26 @@ +#include "freebsd.h" + +/* + * dragonfly is a superset of freebsd4 + */ +#define freebsd2 freebsd2 +#define freebsd3 freebsd3 +#define freebsd4 freebsd4 +#define __FreeBSD_version 400000 +#define dragonfly dragonfly + +#undef IFADDR_SYMBOL +#define IFADDR_SYMBOL "in_ifaddrhead" + +#undef PROC_SYMBOL +#define PROC_SYMBOL "allproc" + +#undef NPROC_SYMBOL +#define NPROC_SYMBOL "nprocs" + +#undef TOTAL_MEMORY_SYMBOL + +#undef MBSTAT_SYMBOL + +#undef INP_NEXT_SYMBOL +#define INP_NEXT_SYMBOL inp_next diff --git a/illumos-x86_64/usr/include/net-snmp/system/dynix.h b/illumos-x86_64/usr/include/net-snmp/system/dynix.h new file mode 100644 index 00000000..db06dcc6 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/dynix.h @@ -0,0 +1,106 @@ +/* + * dynix.h + * + * Date Created: Sat Jan 12 10:50:50 BST 2002 + * Author: Patrick Hess + */ + +#include + +/* + * from s/sysv.h + */ +#define SYSV 1 + +/* + * to make these changes work... + */ +/* + * maybe I should have used _SEQUENT_ in all this code.. dunno + */ +#define dynix dynix + +#undef TOTAL_MEMORY_SYMBOL +#undef MBSTAT_SYMBOL + +/* + * Not enough alcohool in bloodstream [fmc] + */ +#ifdef NPROC_SYMBOL +#undef NPROC_SYMBOL +#endif +/* + * there might be a way to get NPROC... this might work.. might not + */ +/* + * #define NPROC_SYMBOL "procNPROC" + */ +#ifdef PROC_SYMBOL +#undef PROC_SYMBOL +#endif + +/* + * These definitions date from early BSD-based headers, + * and are included in modern NetBSD and OpenBSD distributions. + * As such, the relevant copyright probably resides with UCB. + */ +#ifndef TCPTV_MIN +#define TCPTV_MIN (1*PR_SLOWHZ) /* minimum allowable value */ +#endif +#ifndef TCPTV_REXMTMAX +#define TCPTV_REXMTMAX (64*PR_SLOWHZ) /* max allowable REXMT value */ +#endif + +/* + * some of the system headers wanna include asm code... let's not + */ +#define __NO_ASM_MACRO 1 + +/* + * Dynix doesn't seem to set this. Guess I'll set it here + */ +#ifndef L_SET +#define L_SET SEEK_SET +#endif + + +/* + * configure fails to detect these properly + */ +/* + * lives in libnsl.so + */ +#define HAVE_GETHOSTNAME 1 + +/* + * outta place... lives in /usr/include/sys + */ +#define HAVE_NET_IF_DL_H 1 + +/* + * got this library... dunno why configure didn't find it + */ +#define HAVE_LIBNSL 1 + +/* + * My Dynix box has nearly 400 filesystems and well over 50 disks + */ +/* + * #define MAXDISKS 500 + */ + +/* + * lives in libsocket.so + */ +#define HAVE_GETHOSTBYNAME 1 + +/* + * Might as well include this here, since a significant + * number of files seem to need it. DTS + */ +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +/* define the extra mib modules that are supported */ +#define NETSNMP_INCLUDE_HOST_RESOURCES diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd.h new file mode 100644 index 00000000..bf2eedef --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd.h @@ -0,0 +1,26 @@ +#include "bsd.h" + +#define CHECK_RT_FLAGS 1 + +/* + * udp_inpcb list symbol + */ +#undef INP_NEXT_SYMBOL +#define INP_NEXT_SYMBOL inp_list.le_next + +#undef INP_PREV_SYMBOL +#define INP_PREV_SYMBOL inp_list.le_prev + +#undef TCP_TTL_SYMBOL +#define TCP_TTL_SYMBOL "ip_defttl" + +#ifdef _PATH_UTMP +#define UTMP_FILE _PATH_UTMP +#else +#define UTMP_FILE "/var/run/utmp" +#endif + +#define UDP_ADDRESSES_IN_HOST_ORDER 1 + +/* define the extra mib modules that are supported */ +#define NETSNMP_INCLUDE_HOST_RESOURCES diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd10.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd10.h new file mode 100644 index 00000000..a7334b95 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd10.h @@ -0,0 +1,3 @@ +/* freebsd10 is a superset of freebsd9 */ +#include "freebsd9.h" +#define freebsd9 freebsd9 diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd11.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd11.h new file mode 100644 index 00000000..e81b4cfd --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd11.h @@ -0,0 +1,3 @@ +/* freebsd11 is a superset of freebsd10 */ +#include "freebsd10.h" +#define freebsd10 freebsd10 diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd12.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd12.h new file mode 100644 index 00000000..301432b9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd12.h @@ -0,0 +1,3 @@ +/* freebsd12 is a superset of freebsd11 */ +#include "freebsd11.h" +#define freebsd11 freebsd11 diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd13.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd13.h new file mode 100644 index 00000000..5add58ca --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd13.h @@ -0,0 +1,3 @@ +/* freebsd13 is a superset of freebsd12 */ +#include "freebsd12.h" +#define freebsd12 freebsd12 diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd14.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd14.h new file mode 100644 index 00000000..18df0644 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd14.h @@ -0,0 +1,3 @@ +/* freebsd14 is a superset of freebsd13 */ +#include "freebsd13.h" +#define freebsd13 freebsd13 diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd2.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd2.h new file mode 100644 index 00000000..a2673ac6 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd2.h @@ -0,0 +1,10 @@ +#include "freebsd.h" + +/* + * this is not good enough before freebsd3! + */ +#undef HAVE_NET_IF_MIB_H +#undef PROC_SYMBOL +#undef NPROC_SYMBOL +#undef LOADAVE_SYMBOL +#undef TOTAL_MEMORY_SYMBOL diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd3.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd3.h new file mode 100644 index 00000000..4d87b5ca --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd3.h @@ -0,0 +1,11 @@ +#include "freebsd.h" + +#define freebsd2 freebsd2 /* freebsd3 is a superset of freebsd2 */ + +#undef IFADDR_SYMBOL +#define IFADDR_SYMBOL "in_ifaddrhead" + +#undef PROC_SYMBOL +#undef NPROC_SYMBOL + +#undef TOTAL_MEMORY_SYMBOL diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd4.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd4.h new file mode 100644 index 00000000..2c41e82f --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd4.h @@ -0,0 +1,23 @@ +#include "freebsd.h" + +/* + * freebsd4 is a superset of all since freebsd2 + */ +#define freebsd2 freebsd2 +#define freebsd3 freebsd3 + +#undef IFADDR_SYMBOL +#define IFADDR_SYMBOL "in_ifaddrhead" + +#undef PROC_SYMBOL +#define PROC_SYMBOL "allproc" + +#undef NPROC_SYMBOL +#define NPROC_SYMBOL "nprocs" + +#undef TOTAL_MEMORY_SYMBOL + +#undef MBSTAT_SYMBOL + +#undef INP_NEXT_SYMBOL +#define INP_NEXT_SYMBOL inp_next diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd5.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd5.h new file mode 100644 index 00000000..369c1a47 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd5.h @@ -0,0 +1,8 @@ +/* freebsd5 is a superset of freebsd4 */ +#include "freebsd4.h" +#define freebsd4 freebsd4 + +/* don't define _KERNEL on FreeBSD 5.3 even if configure thinks we need it */ +#ifdef freebsd5 +#undef NETSNMP_IFNET_NEEDS_KERNEL +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd6.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd6.h new file mode 100644 index 00000000..b65fd2b7 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd6.h @@ -0,0 +1,3 @@ +/* freebsd6 is a superset of freebsd5 */ +#include "freebsd5.h" +#define freebsd5 freebsd5 diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd7.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd7.h new file mode 100644 index 00000000..e0a30f47 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd7.h @@ -0,0 +1,3 @@ +/* freebsd7 is a superset of freebsd6 */ +#include "freebsd6.h" +#define freebsd6 freebsd6 diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd8.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd8.h new file mode 100644 index 00000000..5f029842 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd8.h @@ -0,0 +1,11 @@ +/* freebsd8 is a superset of freebsd7 */ +#include "freebsd7.h" +#define freebsd7 freebsd7 + +/* + * Not completely sure when these fields got + * added to FreeBSD, but FreeBSD 8 is about the oldest + * one we care about, so add them here. + */ +#undef UTMP_HAS_NO_TYPE +#undef UTMP_HAS_NO_PID diff --git a/illumos-x86_64/usr/include/net-snmp/system/freebsd9.h b/illumos-x86_64/usr/include/net-snmp/system/freebsd9.h new file mode 100644 index 00000000..ce233225 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/freebsd9.h @@ -0,0 +1,3 @@ +/* freebsd9 is a superset of freebsd8 */ +#include "freebsd8.h" +#define freebsd8 freebsd8 diff --git a/illumos-x86_64/usr/include/net-snmp/system/generic.h b/illumos-x86_64/usr/include/net-snmp/system/generic.h new file mode 100644 index 00000000..545604ff --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/generic.h @@ -0,0 +1,72 @@ +#ifndef __NET_SNMP_SYSTEM_GENERIC_H__ +#define __NET_SNMP_SYSTEM_GENERIC_H__ + +#define bsdlike bsdlike + +/* + * nlist symbols in ip.c + */ +#define IPSTAT_SYMBOL "ipstat" +#define IP_FORWARDING_SYMBOL "ipforwarding" +#define TCP_TTL_SYMBOL "tcpDefaultTTL" + +/* + * nlist symbols in interfaces.c + */ +#define IFNET_SYMBOL "ifnet" +#define IFADDR_SYMBOL "in_ifaddr" + +/* + * load average lookup symbol + */ +#define LOADAVE_SYMBOL "avenrun" + +/* + * nlist symbols in hr_proc.c and memory.c + */ +#define PHYSMEM_SYMBOL "physmem" +#define TOTAL_MEMORY_SYMBOL "total" +#define MBSTAT_SYMBOL "mbstat" +#define SWDEVT_SYMBOL "swdevt" +#define FSWDEVT_SYMBOL "fswdevt" +#define NSWAPFS_SYMBOL "nswapfs" +#define NSWAPDEV_SYMBOL "nswapdev" + +/* + * process nlist symbols. + */ +#define NPROC_SYMBOL "nproc" +#define PROC_SYMBOL "proc" + +/* + * icmp.c nlist symbols + */ +#define ICMPSTAT_SYMBOL "icmpstat" + +/* + * tcp.c nlist symbols + */ +#define TCPSTAT_SYMBOL "tcpstat" +#define TCP_SYMBOL "tcb" + +/* + * upd.c nlist symbols + */ +#define UDPSTAT_SYMBOL "udpstat" +#define UDB_SYMBOL "udb" + +/* + * var_route.c nlist symbols + */ +#define RTTABLES_SYMBOL "rt_table" +#define RTHASHSIZE_SYMBOL "rthashsize" +#define RTHOST_SYMBOL "rthost" +#define RTNET_SYMBOL "rtnet" + +/* + * udp_inpcb list symbol + */ +#define INP_NEXT_SYMBOL inp_next +#define INP_PREV_SYMBOL inp_prev + +#endif /* !__NET_SNMP_SYSTEM_GENERIC_H__ */ diff --git a/illumos-x86_64/usr/include/net-snmp/system/hpux.h b/illumos-x86_64/usr/include/net-snmp/system/hpux.h new file mode 100644 index 00000000..1abf8f86 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/hpux.h @@ -0,0 +1,80 @@ +#include "sysv.h" + +#undef hpux +#define hpux hpux + +#ifdef hpux11 +#define NETSNMP_DONT_USE_NLIST 1 +#endif + +/* + * HP-UX needs _REENTRANT defined to pick up strtok_r. + * Otherwise, at least for 64-bit code, strtok_r will not work + * and will make net-snmp segfault. + */ +#define _REENTRANT 1 + +#undef TCP_TTL_SYMBOL +#ifndef hpux11 +#define TCP_TTL_SYMBOL "ipDefaultTTL" +#endif + +#ifndef hpux11 +/* + * hpux specific + */ +#define MIB_IPCOUNTER_SYMBOL "MIB_ipcounter" +#define MIB_TCPCOUNTER_SYMBOL "MIB_tcpcounter" +#define MIB_UDPCOUNTER_SYMBOL "MIB_udpcounter" +#endif + +#if defined(hpux10) || defined(hpux11) +#undef SWDEVT_SYMBOL +#undef FSWDEVT_SYMBOL +#undef NSWAPFS_SYMBOL +#undef NSWAPDEV_SYMBOL +#undef LOADAVE_SYMBOL +#undef PROC_SYMBOL +#undef NPROC_SYMBOL +#undef TOTAL_MEMORY_SYMBOL +#undef MBSTAT_SYMBOL +#endif + +#ifdef hpux11 +#undef IPSTAT_SYMBOL +#undef TCP_SYMBOL +#undef TCPSTAT_SYMBOL +#undef UDB_SYMBOL +#undef UDPSTAT_SYMBOL +#undef ICMPSTAT_SYMBOL +#undef IP_FORWARDING_SYMBOL +#undef RTTABLES_SYMBOL +#undef RTHASHSIZE_SYMBOL +#undef RTHOST_SYMBOL +#undef RTNET_SYMBOL + +#undef PHYSMEM_SYMBOL +#endif + +#define rt_pad1 rt_refcnt + +/* + * disable inline for non-gcc compiler + */ +#ifndef __GNUC__ +# undef NETSNMP_ENABLE_INLINE +# define NETSNMP_ENABLE_INLINE 0 +#endif + +/* + * prevent sigaction being redefined to cma_sigaction + * (causing build errors on HP-UX 10.20, at least) + */ +#ifdef hpux10 +#ifndef _CMA_NOWRAPPERS_ +# define _CMA_NOWRAPPERS_ 1 +#endif +#endif + +/* define the extra mib modules that are supported */ +#define NETSNMP_INCLUDE_HOST_RESOURCES diff --git a/illumos-x86_64/usr/include/net-snmp/system/irix.h b/illumos-x86_64/usr/include/net-snmp/system/irix.h new file mode 100644 index 00000000..e279174d --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/irix.h @@ -0,0 +1,31 @@ +/* + * irix.h + * + * Date Created: Mon Feb 16 22:19:39 1998 + * Initial Author: Simon Leinen + */ + +#include + +#undef TCP_TTL_SYMBOL +#define TCP_TTL_SYMBOL "tcp_ttl" + +#undef IPSTAT_SYMBOL +#define NO_DOUBLE_ICMPSTAT +#undef ICMPSTAT_SYMBOL +#undef TCPSTAT_SYMBOL +#undef UDPSTAT_SYMBOL + +#define _KMEMUSER 1 + +/* + * don't define _KERNEL before including sys/unistd.h + */ +#define NETSNMP_IFNET_NEEDS_KERNEL_LATE 1 + +#define STREAM_NEEDS_KERNEL_ISLANDS + +#ifndef __GNUC__ +# undef NETSNMP_ENABLE_INLINE +# define NETSNMP_ENABLE_INLINE 0 +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/system/kfreebsd.h b/illumos-x86_64/usr/include/net-snmp/system/kfreebsd.h new file mode 100644 index 00000000..3796fc89 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/kfreebsd.h @@ -0,0 +1,45 @@ +/* For __FreeBSD_kernel_version */ +#include +#define __FreeBSD_version __FreeBSD_kernel_version + +/* For */ +#include + +#define INP_NEXT_SYMBOL inp_next + +#if __FreeBSD_kernel_version >= 3 +#define freebsd3 +#endif +#if __FreeBSD_kernel_version >= 4 +#define freebsd4 +#endif +#if __FreeBSD_kernel_version >= 5 +#define freebsd5 +#endif +#if __FreeBSD_kernel_version >= 6 +#define freebsd6 +#endif +#if __FreeBSD_kernel_version >= 7 +#define freebsd7 +#endif +#if __FreeBSD_kernel_version >= 8 +#define freebsd8 +#endif +#if __FreeBSD_kernel_version >= 9 +#define freebsd9 +#endif +#if __FreeBSD_kernel_version >= 10 +#define freebsd10 +#endif +#if __FreeBSD_kernel_version >= 11 +#define freebsd11 +#endif +#if __FreeBSD_kernel_version >= 12 +#define freebsd12 +#endif +#if __FreeBSD_kernel_version >= 13 +#define freebsd13 +#endif +#if __FreeBSD_kernel_version >= 14 +#define freebsd14 +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/system/linux.h b/illumos-x86_64/usr/include/net-snmp/system/linux.h new file mode 100644 index 00000000..e7aeb681 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/linux.h @@ -0,0 +1,20 @@ +#include "sysv.h" + +#define NETSNMP_DONT_USE_NLIST 1 + +#undef NPROC_SYMBOL + +#undef bsdlike + +/* uncomment this to read process names from /proc/X/cmdline (like <= 5.0) */ +/* #define USE_PROC_CMDLINE */ + +/* + * red hat >= 5.0 doesn't have this + */ +#ifndef MNTTYPE_PROC +#define MNTTYPE_PROC "proc" +#endif + +/* define the extra mib modules that are supported */ +#define NETSNMP_INCLUDE_HOST_RESOURCES diff --git a/illumos-x86_64/usr/include/net-snmp/system/mingw32.h b/illumos-x86_64/usr/include/net-snmp/system/mingw32.h new file mode 100644 index 00000000..d3260620 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/mingw32.h @@ -0,0 +1,35 @@ +/* + * The Win32 API is maintained by the MinGW developers. + * The licensing for the Win32 API is defined in the + * MinGW file README.w32api, which states: + + "Unless otherwise stated in individual source files, + + THIS SOFTWARE IS NOT COPYRIGHTED + + This source code is offered for use in the public domain. You may use, + modify or distribute it freely. + + This source code is distributed in the hope that it will be useful but + WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + DISCLAIMED. This includes but is not limited to warranties of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + + */ + +/* + * Make sure that the Winsock header files get included before any + * header files to avoid that the build fails as follows: + * In file included from /usr/include/w32api/winsock2.h:56:0, + * from ../include/net-snmp/types.h:24, + * from snmp_client.c:87: + * /usr/include/w32api/psdk_inc/_fd_types.h:100:2: warning: *warning "fd_set and associated macros have been defined in sys/types. This can cause runtime problems with W32 sockets" [-Wcpp] + * #warning "fd_set and associated macros have been defined in sys/types. + */ +#include +#include + +#include +#undef bsdlike +#undef MBSTAT_SYMBOL +#undef TOTAL_MEMORY_SYMBOL diff --git a/illumos-x86_64/usr/include/net-snmp/system/mingw32msvc.h b/illumos-x86_64/usr/include/net-snmp/system/mingw32msvc.h new file mode 100644 index 00000000..66c0aed3 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/mingw32msvc.h @@ -0,0 +1,10 @@ +/* + * This header is here to accomodate cross compiling for + * Microsoft Windows on a linux host using MinGW. All changes + * should be made to mingw32.h - Andy + */ +#ifndef mingw32 +#define mingw32 mingw32 +#endif + +#include "mingw32.h" diff --git a/illumos-x86_64/usr/include/net-snmp/system/mips.h b/illumos-x86_64/usr/include/net-snmp/system/mips.h new file mode 100644 index 00000000..e73d8ab9 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/mips.h @@ -0,0 +1,4 @@ + +#define NETSNMP_DONT_USE_NLIST 1 + +#undef bsdlike diff --git a/illumos-x86_64/usr/include/net-snmp/system/netbsd.h b/illumos-x86_64/usr/include/net-snmp/system/netbsd.h new file mode 100644 index 00000000..b2c8c512 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/netbsd.h @@ -0,0 +1,98 @@ +#include "bsd.h" + +#include + +#define PCB_TABLE 1 +#undef TCP_SYMBOL +#define TCP_SYMBOL "tcbtable" +#undef TCP_TTL_SYMBOL +#define TCP_TTL_SYMBOL "ip_defttl" +#undef UDB_SYMBOL +#define UDB_SYMBOL "udbtable" +#undef NPROC_SYMBOL +#undef PROC_SYMBOL + +#define MBPOOL_SYMBOL "mbpool" +#define MCLPOOL_SYMBOL "mclpool" + +/* + * inp_next symbol + */ +#define HAVE_INPCBTABLE 1 +#undef INP_NEXT_SYMBOL +#undef INP_PREV_SYMBOL + +#if __NetBSD_Version__ >= 700000001 +#define INP_FIRST_SYMBOL inpt_queue.tqh_first +#define INP_NEXT_SYMBOL inp_queue.tqe_next +#define INP_PREV_SYMBOL inp_queue.tqe_prev +#else +#define INP_FIRST_SYMBOL inpt_queue.cqh_first +#define INP_NEXT_SYMBOL inp_queue.cqe_next +#define INP_PREV_SYMBOL inp_queue.cqe_prev +#endif + +#if __NetBSD_Version__ >= 106300000 /* NetBSD 1.6ZD */ +#undef IFADDR_SYMBOL +#define IFADDR_SYMBOL "in_ifaddrhead" +#undef TOTAL_MEMORY_SYMBOL +#endif + +#define UTMP_FILE _PATH_UTMP + +#define UDP_ADDRESSES_IN_HOST_ORDER 1 + +#ifdef netbsdelf7 +#define netbsd7 +#define netbsdelf6 +#endif +#ifdef netbsdelf6 +#define netbsd6 +#define netbsdelf5 +#endif +#ifdef netbsdelf5 +#define netbsd5 +#define netbsdelf4 +#endif +#ifdef netbsdelf4 +#define netbsd4 +#define netbsdelf3 +#endif +#ifdef netbsdelf3 +#define netbsd3 +#endif + +#if defined(netbsd10) && !defined(netbsd9) +#define netbsd9 netbsd9 +#endif +#if defined(netbsd9) && !defined(netbsd8) +#define netbsd8 netbsd8 +#endif +#if defined(netbsd8) && !defined(netbsd7) +#define netbsd7 netbsd7 +#endif +#if defined(netbsd7) && !defined(netbsd6) +#define netbsd6 netbsd6 +#endif +#if defined(netbsd6) && !defined(netbsd5) +#define netbsd5 netbsd5 +#endif +#if defined(netbsd5) && !defined(netbsd4) +#define netbsd4 netbsd4 +#endif +#if defined(netbsd4) && !defined(netbsd3) +#define netbsd3 netbsd3 +#endif +#if defined(netbsd3) && !defined(netbsd2) +#define netbsd2 netbsd2 +#endif +#ifndef netbsd1 +#define netbsd1 netbsd1 +#endif + +#if __NetBSD_Version__ >= 499005800 +#define NETBSD_STATS_VIA_SYSCTL +#endif /* __NetBSD_Version__ >= 499005800 */ + +/* define the extra mib modules that are supported */ +#define NETSNMP_INCLUDE_HOST_RESOURCES diff --git a/illumos-x86_64/usr/include/net-snmp/system/nto-qnx6.h b/illumos-x86_64/usr/include/net-snmp/system/nto-qnx6.h new file mode 100644 index 00000000..1965111c --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/nto-qnx6.h @@ -0,0 +1,35 @@ +#include "bsd.h" + +#include + +#define PCB_TABLE 1 +#undef TCP_SYMBOL +#define TCP_SYMBOL "tcbtable" +#undef TCP_TTL_SYMBOL +#define TCP_TTL_SYMBOL "ip_defttl" +#undef UDB_SYMBOL +#define UDB_SYMBOL "udbtable" +#undef NPROC_SYMBOL +#undef PROC_SYMBOL + +#define MBPOOL_SYMBOL "mbpool" +#define MCLPOOL_SYMBOL "mclpool" + +/* + * inp_next symbol + */ +#undef INP_NEXT_SYMBOL +#define INP_NEXT_SYMBOL inp_queue.cqe_next +#undef INP_PREV_SYMBOL +#define INP_PREV_SYMBOL inp_queue.cqe_prev +#define HAVE_INPCBTABLE 1 + +#undef IFADDR_SYMBOL +#define IFADDR_SYMBOL "in_ifaddrhead" + +#define UTMP_FILE _PATH_UTMP + +#define UDP_ADDRESSES_IN_HOST_ORDER 1 + +/* define the extra mib modules that are supported */ +/* #define NETSNMP_INCLUDE_HOST_RESOURCES */ diff --git a/illumos-x86_64/usr/include/net-snmp/system/openbsd.h b/illumos-x86_64/usr/include/net-snmp/system/openbsd.h new file mode 100644 index 00000000..6d36badc --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/openbsd.h @@ -0,0 +1,18 @@ +#define __NetBSD_Version__ 1 +#include "netbsd.h" + +#define netbsd1 netbsd1 /* we're really close to this */ +#define openbsd openbsd +#define UVM + +#undef MBPOOL_SYMBOL +#undef MCLPOOL_SYMBOL +#undef TOTAL_MEMORY_SYMBOL + +/* at least OpenBSD/SPARC 3.7 doesn't define this */ +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +/* define the extra mib modules that are supported */ +#define NETSNMP_INCLUDE_HOST_RESOURCES diff --git a/illumos-x86_64/usr/include/net-snmp/system/openbsd4.h b/illumos-x86_64/usr/include/net-snmp/system/openbsd4.h new file mode 100644 index 00000000..7077d061 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/openbsd4.h @@ -0,0 +1,3 @@ +/* openbsd4 is a superset of openbsd3 */ +#include "openbsd.h" +#define openbsd3 openbsd3 diff --git a/illumos-x86_64/usr/include/net-snmp/system/openbsd5.h b/illumos-x86_64/usr/include/net-snmp/system/openbsd5.h new file mode 100644 index 00000000..a3bedb0c --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/openbsd5.h @@ -0,0 +1,15 @@ +/* openbsd5 is a superset of all since openbsd3 */ +#include "openbsd4.h" +#define openbsd4 openbsd4 + +#undef HAVE_NET_IF_VAR_H + +#if OpenBSD >= 201605 +#undef INP_FIRST_SYMBOL +#define INP_FIRST_SYMBOL inpt_queue.tqh_first +#undef INP_NEXT_SYMBOL +#define INP_NEXT_SYMBOL inp_queue.tqe_next +#undef INP_PREV_SYMBOL +#define INP_PREV_SYMBOL inp_queue.tqe_prev +#endif + diff --git a/illumos-x86_64/usr/include/net-snmp/system/openbsd6.h b/illumos-x86_64/usr/include/net-snmp/system/openbsd6.h new file mode 100644 index 00000000..3889f166 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/openbsd6.h @@ -0,0 +1,3 @@ +/* openbsd6 is a superset of all since openbsd3 */ +#include "openbsd5.h" +#define openbsd5 openbsd5 diff --git a/illumos-x86_64/usr/include/net-snmp/system/osf5.h b/illumos-x86_64/usr/include/net-snmp/system/osf5.h new file mode 100644 index 00000000..9b0a2d1a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/osf5.h @@ -0,0 +1,26 @@ +#include + +#define osf4 osf4 + +/* Needed by to give us the correct sockaddr structures */ +#ifndef _SOCKADDR_LEN +#define _SOCKADDR_LEN +#endif + +#undef TCP_TTL_SYMBOL +#define TCP_TTL_SYMBOL "tcp_ttl" + +/* var_route.c nlist symbols */ +#undef RTTABLES_SYMBOL +#define RTTABLES_SYMBOL "rtable" +#undef RTHASHSIZE_SYMBOL +#define RTHASHSIZE_SYMBOL "rhash_size" + +#ifndef __GNUC__ +# undef NETSNMP_ENABLE_INLINE +# define NETSNMP_ENABLE_INLINE 0 +#endif + +#ifndef UINT32_MAX +# define UINT32_MAX UINT_MAX +#endif diff --git a/illumos-x86_64/usr/include/net-snmp/system/solaris.h b/illumos-x86_64/usr/include/net-snmp/system/solaris.h new file mode 100644 index 00000000..8650cbd0 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/solaris.h @@ -0,0 +1,38 @@ +#include "sysv.h" + +#undef bsdlike +#undef IP_FORWARDING_SYMBOL +#undef ICMPSTAT_SYMBOL +#undef TCPSTAT_SYMBOL +#undef TCP_SYMBOL +#undef UDPSTAT_SYMBOL +#undef UDB_SYMBOL +#undef RTTABLES_SYMBOL +#undef RTHASHSIZE_SYMBOL +#undef RTHOST_SYMBOL +#undef RTNET_SYMBOL +#undef IPSTAT_SYMBOL +#undef TCP_TTL_SYMBOL +#undef PROC_SYMBOL +#undef TOTAL_MEMORY_SYMBOL +#undef MBSTAT_SYMBOL + +#define UDP_ADDRESSES_IN_HOST_ORDER 1 +#define UDP_PORTS_IN_HOST_ORDER 1 +#define TCP_PORTS_IN_HOST_ORDER 1 + +/* define the extra mib modules that are supported */ +#define NETSNMP_INCLUDE_HOST_RESOURCES + +/* Solaris 2.6+ */ +#define _SLASH_PROC_METHOD_ 1 + +/* Solaris 7+ */ +#define NETSNMP_DONT_USE_NLIST 1 + +/* + * NEW_MIB_COMPLIANT is a define used in Solaris 10U4+ to enable additional + * MIB information (it affects the structs in ) + */ + +#define NEW_MIB_COMPLIANT diff --git a/illumos-x86_64/usr/include/net-snmp/system/solaris2.3.h b/illumos-x86_64/usr/include/net-snmp/system/solaris2.3.h new file mode 100644 index 00000000..7f4c5bf7 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/solaris2.3.h @@ -0,0 +1 @@ +#include "solaris2.5.h" diff --git a/illumos-x86_64/usr/include/net-snmp/system/solaris2.4.h b/illumos-x86_64/usr/include/net-snmp/system/solaris2.4.h new file mode 100644 index 00000000..7f4c5bf7 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/solaris2.4.h @@ -0,0 +1 @@ +#include "solaris2.5.h" diff --git a/illumos-x86_64/usr/include/net-snmp/system/solaris2.5.h b/illumos-x86_64/usr/include/net-snmp/system/solaris2.5.h new file mode 100644 index 00000000..341d21f5 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/solaris2.5.h @@ -0,0 +1,4 @@ +#include "solaris.h" +#undef _SLASH_PROC_METHOD_ +#undef NETSNMP_DONT_USE_NLIST + diff --git a/illumos-x86_64/usr/include/net-snmp/system/solaris2.6.h b/illumos-x86_64/usr/include/net-snmp/system/solaris2.6.h new file mode 100644 index 00000000..370ed336 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/solaris2.6.h @@ -0,0 +1,2 @@ +#include "solaris.h" +#undef NETSNMP_DONT_USE_NLIST diff --git a/illumos-x86_64/usr/include/net-snmp/system/sunos.h b/illumos-x86_64/usr/include/net-snmp/system/sunos.h new file mode 100644 index 00000000..48eef00d --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/sunos.h @@ -0,0 +1,12 @@ +#include + +typedef int ssize_t; + +#undef IP_FORWARDING_SYMBOL +#define IP_FORWARDING_SYMBOL "ip_forwarding" + +#undef TCP_TTL_SYMBOL +#define TCP_TTL_SYMBOL "tcp_ttl" + +#define UTMP_HAS_NO_TYPE 1 +#define UTMP_FILE "/etc/utmp" diff --git a/illumos-x86_64/usr/include/net-snmp/system/svr5.h b/illumos-x86_64/usr/include/net-snmp/system/svr5.h new file mode 100644 index 00000000..017c7c19 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/svr5.h @@ -0,0 +1,20 @@ +/* + * used to minimally build SCO UnixWare 7.1.0 using CCS 3.2 compiler - YMMV + */ + +#include + +/* + * using CCS "cc", "configure" does not find this item + */ +#define HAVE_GETHOSTBYNAME 1 + +/* + * lie about this next define to avoid sa_len and sa_family MACROS !! + */ +#define HAVE_STRUCT_SOCKADDR_SA_UNION_SA_GENERIC_SA_FAMILY2 1 + +/* + * this header requires queue_t, not easily done without kernel headers + */ +#undef HAVE_NETINET_IN_PCB_H diff --git a/illumos-x86_64/usr/include/net-snmp/system/sysv.h b/illumos-x86_64/usr/include/net-snmp/system/sysv.h new file mode 100644 index 00000000..45d6a39a --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/sysv.h @@ -0,0 +1,2 @@ +#include +#define SYSV 1 diff --git a/illumos-x86_64/usr/include/net-snmp/system/ultrix4.h b/illumos-x86_64/usr/include/net-snmp/system/ultrix4.h new file mode 100644 index 00000000..4efc3dba --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/system/ultrix4.h @@ -0,0 +1,9 @@ +#include +#include + +typedef int ssize_t; + +#undef TCP_TTL_SYMBOL +#define TCP_TTL_SYMBOL "tcp_ttl" + +#undef RTTABLES_SYMBOL diff --git a/illumos-x86_64/usr/include/net-snmp/types.h b/illumos-x86_64/usr/include/net-snmp/types.h new file mode 100644 index 00000000..d489f37b --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/types.h @@ -0,0 +1,431 @@ +/* + * Portions of this file are subject to the following copyright(s). See + * the Net-SNMP's COPYING file for more details and other copyrights + * that may apply: + * + * Portions of this file are copyrighted by: + * Copyright (c) 2016 VMware, Inc. All rights reserved. + * Use is subject to license terms specified in the COPYING file + * distributed with the Net-SNMP package. + */ + +#ifndef NET_SNMP_TYPES_H +#define NET_SNMP_TYPES_H + + /** + * Definitions of data structures, used within the library API. + */ + +#include + +#ifndef NET_SNMP_CONFIG_H +#error "Please include before this file" +#endif + +#include + +#if defined(WIN32) && !defined(cygwin) +typedef HANDLE netsnmp_pid_t; +#define NETSNMP_NO_SUCH_PROCESS INVALID_HANDLE_VALUE +#else +/* + * Note: on POSIX-compliant systems, pid_t is defined in . + * And if pid_t has not been defined in , AC_TYPE_PID_T ensures + * that a pid_t definition is present in net-snmp-config.h. + */ +typedef pid_t netsnmp_pid_t; +#define NETSNMP_NO_SUCH_PROCESS -1 +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef HAVE_SOCKLEN_T +#ifdef WIN32 +typedef int socklen_t; +#else +typedef u_int socklen_t; +#endif +#endif + +#ifndef HAVE_SSIZE_T +#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647 +typedef int ssize_t; +#else +typedef long ssize_t; +#endif +#endif + +#ifndef HAVE_NFDS_T +typedef unsigned long int nfds_t; +#endif + +#ifdef HAVE_PCRE_H +/* + * Abstract the pcre typedef such that not all *.c files have to include + * . + */ +typedef struct { + void *regex_ptr; +} netsnmp_regex_ptr; +#endif + + /* + * For the initial release, this will just refer to the + * relevant UCD header files. + * In due course, the types and structures relevant to the + * Net-SNMP API will be identified, and defined here directly. + * + * But for the time being, this header file is primarily a placeholder, + * to allow application writers to adopt the new header file names. + */ + +typedef union { + long *integer; + u_char *string; + oid *objid; + u_char *bitstring; + struct counter64 *counter64; +#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + float *floatVal; + double *doubleVal; + /* + * t_union *unionVal; + */ +#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */ +} netsnmp_vardata; + + +#define MAX_OID_LEN 128 /* max subid's in an oid */ + +/** @typedef struct variable_list netsnmp_variable_list + * Typedefs the variable_list struct into netsnmp_variable_list */ +/** @struct variable_list + * The netsnmp variable list binding structure, it's typedef'd to + * netsnmp_variable_list. + */ +typedef struct variable_list { + /** NULL for last variable */ + struct variable_list *next_variable; + /** Object identifier of variable */ + oid *name; + /** number of subid's in name */ + size_t name_length; + /** ASN type of variable */ + u_char type; + /** value of variable */ + netsnmp_vardata val; + /** the length of the value to be copied into buf */ + size_t val_len; + /** buffer to hold the OID */ + oid name_loc[MAX_OID_LEN]; + /** 90 percentile < 40. */ + u_char buf[40]; + /** (Opaque) hook for additional data */ + void *data; + /** callback to free above */ + void (*dataFreeHook)(void *); + int index; +} netsnmp_variable_list; + + +/** @typedef struct snmp_pdu to netsnmp_pdu + * Typedefs the snmp_pdu struct into netsnmp_pdu */ +/** @struct snmp_pdu + * The snmp protocol data unit. + */ +typedef struct snmp_pdu { + +#define non_repeaters errstat +#define max_repetitions errindex + + /* + * Protocol-version independent fields + */ + /** snmp version */ + long version; + /** Type of this PDU */ + int command; + /** Request id - note: incremented for each retry */ + long reqid; + /** Message id for V3 messages note: incremented for each retry */ + long msgid; + /** Unique ID for incoming transactions */ + long transid; + /** Session id for AgentX messages */ + long sessid; + /** Error status (non_repeaters in GetBulk) */ + long errstat; + /** Error index (max_repetitions in GetBulk) */ + long errindex; + /** Uptime */ + u_long time; + u_long flags; + + int securityModel; + /** noAuthNoPriv, authNoPriv, authPriv */ + int securityLevel; + int msgParseModel; + + /** smallest of max for transport, v3 msgMaxSize and local cfg. */ + long msgMaxSize; + + /** + * Transport-specific opaque data. This replaces the IP-centric address + * field. + */ + + void *transport_data; + int transport_data_length; + + /** + * The actual transport domain. This SHOULD NOT BE FREE()D. + */ + + const oid *tDomain; + size_t tDomainLen; + + netsnmp_variable_list *variables; + + + /* + * SNMPv1 & SNMPv2c fields + */ + /** community for outgoing requests. */ + u_char *community; + /** length of community name. */ + size_t community_len; + + /* + * Trap information + */ + /** System OID */ + oid *enterprise; + size_t enterprise_length; + /** trap type */ + long trap_type; + /** specific type */ + long specific_type; + /** This is ONLY used for v1 TRAPs */ + unsigned char agent_addr[4]; + + /* + * SNMPv3 fields + */ + /** context snmpEngineID */ + u_char *contextEngineID; + /** Length of contextEngineID */ + size_t contextEngineIDLen; + /** authoritative contextName */ + char *contextName; + /** Length of contextName */ + size_t contextNameLen; + /** authoritative snmpEngineID for security */ + u_char *securityEngineID; + /** Length of securityEngineID */ + size_t securityEngineIDLen; + /** on behalf of this principal */ + char *securityName; + /** Length of securityName. */ + size_t securityNameLen; + + /* + * AgentX fields + * (also uses SNMPv1 community field) + */ + int priority; + int range_subid; + + void *securityStateRef; +} netsnmp_pdu; + + +/** + * @typedef struct snmp_session netsnmp_session + * Typedefs the snmp_session struct into netsnmp_session. + */ +typedef struct snmp_session netsnmp_session; + +/** for openssl this should match up with EVP_MAX_MD_SIZE */ +#define USM_AUTH_KU_LEN 64 +#define USM_PRIV_KU_LEN 64 + +typedef int (*snmp_callback) (int, netsnmp_session *, int, + netsnmp_pdu *, void *); +typedef int (*netsnmp_callback) (int, netsnmp_session *, int, + netsnmp_pdu *, void *); + +struct netsnmp_container_s; + +#ifndef NETSNMP_NO_TRAP_STATS + /* + * trap/inform statistics. + * + * all times are sysuptime + */ +typedef struct netsnmp_trap_stats_s { + u_long sent_count; + u_long sent_last_sent; + + u_long sent_fail_count; + u_long sent_last_fail; + + u_long ack_count; + u_long ack_last_rcvd; + + u_long sec_err_count; + u_long sec_err_last; + + u_long timeouts; + u_long sent_last_timeout; +} netsnmp_trap_stats; +#endif /* NETSNMP_NO_TRAP_STATS */ + +/** @struct snmp_session + * The snmp session structure. + */ +struct snmp_session { + /* + * Protocol-version independent fields + */ + /** snmp version */ + long version; + /** Number of retries before timeout. */ + int retries; + /** Number of uS until first timeout, then exponential backoff */ + long timeout; + u_long flags; + struct snmp_session *subsession; + struct snmp_session *next; + + /** name or address of default peer (may include transport specifier and/or port number) */ + char *peername; + /** UDP port number of peer. (NO LONGER USED - USE peername INSTEAD) */ + u_short remote_port NETSNMP_ATTRIBUTE_DEPRECATED; + /** My Domain name or dotted IP address, 0 for default */ + char *localname; + /** My UDP port number, 0 for default, picked randomly */ + u_short local_port; + /** + * Authentication function or NULL if null authentication is used + */ + u_char *(*authenticator) (u_char *, size_t *, u_char *, size_t); + /** Function to interpret incoming data */ + netsnmp_callback callback; + /** + * Pointer to data that the callback function may consider important + */ + void *callback_magic; + /** copy of system errno */ + int s_errno; + /** copy of library errno */ + int s_snmp_errno; + /** Session id - AgentX only */ + long sessid; + + /* + * SNMPv1 & SNMPv2c fields + */ + /** community for outgoing requests. */ + u_char *community; + /** Length of community name. */ + size_t community_len; + /** Largest message to try to receive. */ + size_t rcvMsgMaxSize; + /** Largest message to try to send. */ + size_t sndMsgMaxSize; + + /* + * SNMPv3 fields + */ + /** are we the authoritative engine? */ + u_char isAuthoritative; + /** authoritative snmpEngineID */ + u_char *contextEngineID; + /** Length of contextEngineID */ + size_t contextEngineIDLen; + /** initial engineBoots for remote engine */ + u_int engineBoots; + /** initial engineTime for remote engine */ + u_int engineTime; + /** authoritative contextName */ + char *contextName; + /** Length of contextName */ + size_t contextNameLen; + /** authoritative snmpEngineID */ + u_char *securityEngineID; + /** Length of contextEngineID */ + size_t securityEngineIDLen; + /** on behalf of this principal */ + char *securityName; + /** Length of securityName. */ + size_t securityNameLen; + + /** auth protocol oid */ + oid *securityAuthProto; + /** Length of auth protocol oid */ + size_t securityAuthProtoLen; + /** Ku for auth protocol XXX */ + u_char securityAuthKey[USM_AUTH_KU_LEN]; + /** Length of Ku for auth protocol */ + size_t securityAuthKeyLen; + /** Kul for auth protocol */ + u_char *securityAuthLocalKey; + /** Length of Kul for auth protocol XXX */ + size_t securityAuthLocalKeyLen; + + /** priv protocol oid */ + oid *securityPrivProto; + /** Length of priv protocol oid */ + size_t securityPrivProtoLen; + /** Ku for privacy protocol XXX */ + u_char securityPrivKey[USM_PRIV_KU_LEN]; + /** Length of Ku for priv protocol */ + size_t securityPrivKeyLen; + /** Kul for priv protocol */ + u_char *securityPrivLocalKey; + /** Length of Kul for priv protocol XXX */ + size_t securityPrivLocalKeyLen; + + /** snmp security model, v1, v2c, usm */ + int securityModel; + /** noAuthNoPriv, authNoPriv, authPriv */ + int securityLevel; + /** target param name */ + char *paramName; +#ifndef NETSNMP_NO_TRAP_STATS + netsnmp_trap_stats *trap_stats; +#endif /* NETSNMP_NO_TRAP_STATS */ + + /** + * security module specific + */ + void *securityInfo; + + /** + * transport specific configuration + */ + struct netsnmp_container_s *transport_configuration; + + /** + * use as you want data + * + * used by 'SNMP_FLAGS_RESP_CALLBACK' handling in the agent + * XXX: or should we add a new field into this structure? + */ + void *myvoid; +}; + + +#include +#include +#include + +#ifdef __cplusplus +} +#endif + +#endif /* NET_SNMP_TYPES_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/utilities.h b/illumos-x86_64/usr/include/net-snmp/utilities.h new file mode 100644 index 00000000..85a7c712 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/utilities.h @@ -0,0 +1,60 @@ +#ifndef NET_SNMP_UTILITIES_H +#define NET_SNMP_UTILITIES_H + + /** + * Library API routines not specifically concerned with SNMP directly, + * but used more generally within the library, agent and other applications. + * + * This also includes "standard" system routines, which are missing on + * particular O/S distributiones. + */ + +#ifndef NET_SNMP_CONFIG_H +#error "Please include before this file" +#endif + +#include + + /* + * For the initial release, this will just refer to the + * relevant UCD header files. + * In due course, the routines relevant to this area of the + * API will be identified, and listed here directly. + * + * But for the time being, this header file is a placeholder, + * to allow application writers to adopt the new header file names. + */ + +#include +#include +#ifdef HAVE_GETOPT_H +#include +#else +#include +#endif + +#include +#include +#include /* for counter64 */ +#include + +#include +/* #include */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#endif /* NET_SNMP_UTILITIES_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/varbind_api.h b/illumos-x86_64/usr/include/net-snmp/varbind_api.h new file mode 100644 index 00000000..7f485031 --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/varbind_api.h @@ -0,0 +1,105 @@ +#ifndef NET_SNMP_VARBIND_API_H +#define NET_SNMP_VARBIND_API_H + + /** + * Library API routines concerned with variable bindings and values. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + /* Creation */ + NETSNMP_IMPORT + netsnmp_variable_list * + snmp_pdu_add_variable(netsnmp_pdu *pdu, + const oid * name, size_t name_length, + u_char type, + const void * value, size_t len); + NETSNMP_IMPORT + netsnmp_variable_list * + snmp_varlist_add_variable(netsnmp_variable_list ** varlist, + const oid * name, size_t name_length, + u_char type, + const void * value, size_t len); + NETSNMP_IMPORT + netsnmp_variable_list * + snmp_add_null_var(netsnmp_pdu *pdu, + const oid * name, size_t name_length); + NETSNMP_IMPORT + netsnmp_variable_list * + snmp_clone_varbind(netsnmp_variable_list * varlist); + + /* Setting Values */ + NETSNMP_IMPORT + int snmp_set_var_objid(netsnmp_variable_list * var, + const oid * name, size_t name_length); + NETSNMP_IMPORT + int snmp_set_var_value(netsnmp_variable_list * var, + const void * value, size_t len); + NETSNMP_IMPORT + int snmp_set_var_typed_value(netsnmp_variable_list * var, + u_char type, + const void * value, size_t len); + NETSNMP_IMPORT + int snmp_set_var_typed_integer(netsnmp_variable_list * var, + u_char type, long val); + + /* Output */ + NETSNMP_IMPORT + void print_variable(const oid * objid, size_t objidlen, + const netsnmp_variable_list * variable); + NETSNMP_IMPORT + void fprint_variable(FILE * fp, + const oid * objid, size_t objidlen, + const netsnmp_variable_list * variable); + NETSNMP_IMPORT + int snprint_variable(char *buf, size_t buf_len, + const oid * objid, size_t objidlen, + const netsnmp_variable_list * variable); + + NETSNMP_IMPORT + void print_value(const oid * objid, size_t objidlen, + const netsnmp_variable_list * variable); + NETSNMP_IMPORT + void fprint_value(FILE * fp, + const oid * objid, size_t objidlen, + const netsnmp_variable_list * variable); + NETSNMP_IMPORT + int snprint_value(char *buf, size_t buf_len, + const oid * objid, size_t objidlen, + const netsnmp_variable_list * variable); + + /* See mib_api.h for {,f,sn}print_objid */ + + /* Deletion */ + NETSNMP_IMPORT + void snmp_free_var( netsnmp_variable_list *var); /* frees just this one */ + NETSNMP_IMPORT + void snmp_free_varbind(netsnmp_variable_list *varlist); /* frees all in list */ + +#ifdef __cplusplus +} +#endif + + /* + * Having extracted the main ("public API") calls relevant + * to this area of the Net-SNMP project, the next step is to + * identify the related "public internal API" routines. + * + * In due course, these should probably be gathered + * together into a companion 'library/varbind_api.h' header file. + * [Or some suitable name] + * + * But for the time being, the expectation is that the + * traditional headers that provided the above definitions + * will probably also cover the relevant internal API calls. + * Hence they are listed here: + */ +#include +#include +#include + +#endif /* NET_SNMP_VARBIND_API_H */ diff --git a/illumos-x86_64/usr/include/net-snmp/version.h b/illumos-x86_64/usr/include/net-snmp/version.h new file mode 100644 index 00000000..1c36ffef --- /dev/null +++ b/illumos-x86_64/usr/include/net-snmp/version.h @@ -0,0 +1,18 @@ +#ifndef NET_SNMP_VERSION_H +#define NET_SNMP_VERSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef UCD_COMPATIBLE + extern const char *NetSnmpVersionInfo; +#endif + + NETSNMP_IMPORT + const char *netsnmp_get_version(void); + +#ifdef __cplusplus +} +#endif +#endif /* NET_SNMP_VERSION_H */ diff --git a/illumos-x86_64/usr/include/net/af.h b/illumos-x86_64/usr/include/net/af.h new file mode 100644 index 00000000..f26edc33 --- /dev/null +++ b/illumos-x86_64/usr/include/net/af.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1980, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NET_AF_H +#define _NET_AF_H + +/* af.h 1.10 88/08/19 SMI; from UCB 7.1 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Address family routines, + * used in handling generic sockaddr structures. + * + * Hash routine is called + * af_hash(addr, h); + * struct sockaddr *addr; struct afhash *h; + * producing an afhash structure for addr. + * + * Netmatch routine is called + * af_netmatch(addr1, addr2); + * where addr1 and addr2 are sockaddr *. Returns 1 if network + * values match, 0 otherwise. + */ +struct afswitch { + int (*af_hash)(); + int (*af_netmatch)(); +}; + +struct afhash { + uint_t afh_hosthash; + uint_t afh_nethash; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_AF_H */ diff --git a/illumos-x86_64/usr/include/net/bpf.h b/illumos-x86_64/usr/include/net/bpf.h new file mode 100644 index 00000000..4a15dcf1 --- /dev/null +++ b/illumos-x86_64/usr/include/net/bpf.h @@ -0,0 +1,298 @@ +/* $NetBSD: bpf.h,v 1.50 2009/01/13 19:10:52 christos Exp $ */ + +/* + * Copyright (c) 1990, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bpf.h 8.2 (Berkeley) 1/9/95 + * @(#) Header: bpf.h,v 1.36 97/06/12 14:29:53 leres Exp (LBL) + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NET_BPF_H_ +#define _NET_BPF_H_ + +#include +#include +#include + +/* BSD style release date */ +#define BPF_RELEASE 199606 + +typedef int bpf_int32; +typedef uint_t bpf_uint_t32; +typedef uint_t bpf_u_int32; + +/* + * Alignment macros. BPF_WORDALIGN rounds up to the next + * even multiple of BPF_ALIGNMENT. + */ +#define BPF_ALIGNMENT sizeof (uint32_t) +#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) + +#define BPF_MAXINSNS 512 +#define BPF_DFLTBUFSIZE (1024*1024) /* default static upper limit */ +#define BPF_MAXBUFSIZE (1024*1024*16) /* hard limit on sysctl'able value */ +#define BPF_MINBUFSIZE 32 + +/* + * Structure for BIOCSETF. + */ +struct bpf_program { + uint_t bf_len; + struct bpf_insn *bf_insns; +}; +struct bpf_program32 { + uint_t bf_len; + caddr32_t bf_insns; +}; + +/* + * Struct returned by BIOCGSTATS and net.bpf.stats sysctl. + */ +struct bpf_stat { + uint64_t bs_recv; /* number of packets received */ + uint64_t bs_drop; /* number of packets dropped */ + uint64_t bs_capt; /* number of packets captured */ + uint64_t bs_padding[13]; +}; + +/* + * Struct returned by BIOCGSTATSOLD. + */ +struct bpf_stat_old { + uint_t bs_recv; /* number of packets received */ + uint_t bs_drop; /* number of packets dropped */ +}; + +/* + * Struct return by BIOCVERSION. This represents the version number of + * the filter language described by the instruction encodings below. + * bpf understands a program iff kernel_major == filter_major && + * kernel_minor >= filter_minor, that is, if the value returned by the + * running kernel has the same major number and a minor number equal + * equal to or less than the filter being downloaded. Otherwise, the + * results are undefined, meaning an error may be returned or packets + * may be accepted haphazardly. + * It has nothing to do with the source code version. + */ +struct bpf_version { + ushort_t bv_major; + ushort_t bv_minor; +}; +/* Current version number of filter architecture. */ +#define BPF_MAJOR_VERSION 1 +#define BPF_MINOR_VERSION 1 + +/* + * BPF ioctls + * + * The first set is for compatibility with Sun's pcc style + * header files. If your using gcc, we assume that you + * have run fixincludes so the latter set should work. + */ +#define BIOCGBLEN _IOR('B', 102, uint_t) +#define BIOCSBLEN _IOWR('B', 102, uint_t) +#define BIOCSETF _IOW('B', 103, struct bpf_program) +#define BIOCFLUSH _IO('B', 104) +#define BIOCPROMISC _IO('B', 105) +#define BIOCGDLT _IOR('B', 106, uint_t) +#define BIOCGETIF _IOR('B', 107, struct ifreq) +#define BIOCGETLIF _IOR('B', 107, struct lifreq) +#define BIOCSETIF _IOW('B', 108, struct ifreq) +#define BIOCSETLIF _IOW('B', 108, struct lifreq) +#define BIOCGSTATS _IOR('B', 111, struct bpf_stat) +#define BIOCGSTATSOLD _IOR('B', 111, struct bpf_stat_old) +#define BIOCIMMEDIATE _IOW('B', 112, uint_t) +#define BIOCVERSION _IOR('B', 113, struct bpf_version) +#define BIOCSTCPF _IOW('B', 114, struct bpf_program) +#define BIOCSUDPF _IOW('B', 115, struct bpf_program) +#define BIOCGHDRCMPLT _IOR('B', 116, uint_t) +#define BIOCSHDRCMPLT _IOW('B', 117, uint_t) +#define BIOCSDLT _IOW('B', 118, uint_t) +#define BIOCGDLTLIST _IOWR('B', 119, struct bpf_dltlist) +#define BIOCGSEESENT _IOR('B', 120, uint_t) +#define BIOCSSEESENT _IOW('B', 121, uint_t) +#define BIOCSRTIMEOUT _IOW('B', 122, struct timeval) +#define BIOCGRTIMEOUT _IOR('B', 123, struct timeval) +/* + */ +#define BIOCSETF32 _IOW('B', 103, struct bpf_program32) +#define BIOCGDLTLIST32 _IOWR('B', 119, struct bpf_dltlist32) +#define BIOCSRTIMEOUT32 _IOW('B', 122, struct timeval32) +#define BIOCGRTIMEOUT32 _IOR('B', 123, struct timeval32) + +/* + * Structure prepended to each packet. This is "wire" format, so we + * cannot change it unfortunately to 64 bit times on 32 bit systems [yet]. + */ +struct bpf_timeval { + int32_t tv_sec; + int32_t tv_usec; +}; + +struct bpf_hdr { + struct bpf_timeval bh_tstamp; /* time stamp */ + uint32_t bh_caplen; /* length of captured portion */ + uint32_t bh_datalen; /* original length of packet */ + uint16_t bh_hdrlen; /* length of bpf header (this struct */ + /* plus alignment padding) */ +}; +/* + * Because the structure above is not a multiple of 4 bytes, some compilers + * will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work. + * Only the kernel needs to know about it; applications use bh_hdrlen. + * XXX To save a few bytes on 32-bit machines, we avoid end-of-struct + * XXX padding by using the size of the header data elements. This is + * XXX fail-safe: on new machines, we just use the 'safe' sizeof. + */ +#ifdef _KERNEL +#if defined(__arm32__) || defined(__i386__) || defined(__m68k__) || \ + defined(__mips__) || defined(__ns32k__) || defined(__vax__) || \ + defined(__sh__) || (defined(__sparc__) && !defined(__sparc64__)) +#define SIZEOF_BPF_HDR 18 +#else +#define SIZEOF_BPF_HDR sizeof (struct bpf_hdr) +#endif +#endif + +/* Pull in data-link level type codes. */ +#include + +/* + * The instruction encodings. + */ +/* instruction classes */ +#define BPF_CLASS(code) ((code) & 0x07) +#define BPF_LD 0x00 +#define BPF_LDX 0x01 +#define BPF_ST 0x02 +#define BPF_STX 0x03 +#define BPF_ALU 0x04 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_MISC 0x07 + +/* ld/ldx fields */ +#define BPF_SIZE(code) ((code) & 0x18) +#define BPF_W 0x00 +#define BPF_H 0x08 +#define BPF_B 0x10 +#define BPF_MODE(code) ((code) & 0xe0) +#define BPF_IMM 0x00 +#define BPF_ABS 0x20 +#define BPF_IND 0x40 +#define BPF_MEM 0x60 +#define BPF_LEN 0x80 +#define BPF_MSH 0xa0 + +/* alu/jmp fields */ +#define BPF_OP(code) ((code) & 0xf0) +#define BPF_ADD 0x00 +#define BPF_SUB 0x10 +#define BPF_MUL 0x20 +#define BPF_DIV 0x30 +#define BPF_OR 0x40 +#define BPF_AND 0x50 +#define BPF_LSH 0x60 +#define BPF_RSH 0x70 +#define BPF_NEG 0x80 +#define BPF_JA 0x00 +#define BPF_JEQ 0x10 +#define BPF_JGT 0x20 +#define BPF_JGE 0x30 +#define BPF_JSET 0x40 +#define BPF_SRC(code) ((code) & 0x08) +#define BPF_K 0x00 +#define BPF_X 0x08 + +/* ret - BPF_K and BPF_X also apply */ +#define BPF_RVAL(code) ((code) & 0x18) +#define BPF_A 0x10 + +/* misc */ +#define BPF_MISCOP(code) ((code) & 0xf8) +#define BPF_TAX 0x00 +#define BPF_TXA 0x80 + +/* + * The instruction data structure. + */ +struct bpf_insn { + uint16_t code; + uint8_t jt; + uint8_t jf; + uint32_t k; +}; + +/* + * Macros for insn array initializers. + */ +#define BPF_STMT(code, k) { (uint16_t)(code), 0, 0, k } +#define BPF_JUMP(code, k, jt, jf) { (uint16_t)(code), jt, jf, k } + +/* + * Structure to retrieve available DLTs for the interface. + */ +struct bpf_dltlist { + uint_t bfl_len; /* number of bfd_list array */ + uint_t *bfl_list; /* array of DLTs */ +}; +struct bpf_dltlist32 { + uint_t bfl_len; + caddr32_t bfl_list; +}; + +#ifdef _KERNEL +#include +#include + +typedef void (*bpf_itap_fn_t)(void *, mblk_t *, boolean_t, uint_t); + +extern void bpfattach(uintptr_t, int, zoneid_t, int); +extern void bpfdetach(uintptr_t); +extern uint_t bpf_filter(struct bpf_insn *, uchar_t *, uint_t, uint_t); +extern void bpf_itap(void *, mblk_t *, boolean_t, uint_t); +extern void bpf_mtap(void *, mac_resource_handle_t, mblk_t *, boolean_t); +extern int bpf_validate(struct bpf_insn *, int); + +#endif /* _KERNEL */ + +/* + * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). + */ +#define BPF_MEMWORDS 16 + +#endif /* !_NET_BPF_H_ */ diff --git a/illumos-x86_64/usr/include/net/bpfdesc.h b/illumos-x86_64/usr/include/net/bpfdesc.h new file mode 100644 index 00000000..e4ff331b --- /dev/null +++ b/illumos-x86_64/usr/include/net/bpfdesc.h @@ -0,0 +1,227 @@ +/* $NetBSD: bpfdesc.h,v 1.29 2009/03/14 14:46:10 dsl Exp $ */ + +/* + * Copyright (c) 1990, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93 + * + * @(#) Header: bpfdesc.h,v 1.14 96/06/16 22:28:07 leres Exp (LBL) + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NET_BPFDESC_H_ +#define _NET_BPFDESC_H_ + +#include /* for IFNAMSIZ */ +#include +#include +#include + +/* + * Access to "layer 2" networking is provided through each such provider + * delcaring a set of functions to use in the structure below. It has been + * modeled around what's required to use the mac layer. All of the functions + * below must be declared, even if only filled by a stub function. + */ +typedef struct bpf_provider_s { + int bpr_unit; + int (*bpr_open)(const char *, uintptr_t *, zoneid_t); + void (*bpr_close)(uintptr_t); + const char *(*bpr_name)(uintptr_t); + int (*bpr_type)(uintptr_t); + void (*bpr_sdu_get)(uintptr_t, uint_t *); + int (*bpr_tx)(uintptr_t, mblk_t *); + uintptr_t (*bpr_promisc_add)(uintptr_t, int, void *, uintptr_t *, + int); + void (*bpr_promisc_remove)(uintptr_t); + int (*bpr_getlinkid)(const char *, datalink_id_t *, + zoneid_t); + void (*bpr_client_close)(uintptr_t); + const char *(*bpr_client_name)(uintptr_t); + int (*bpr_client_open)(uintptr_t, uintptr_t *); + int (*bpr_getzone)(uintptr_t, zoneid_t *); + int (*bpr_getdlt)(uintptr_t, uint_t *); +} bpf_provider_t; + +typedef struct bpf_provider_list { + LIST_ENTRY(bpf_provider_list) bpl_next; + bpf_provider_t *bpl_what; +} bpf_provider_list_t; + +/* + * The bpr_field from bpf_provider_t expects an integer that comes from + * the list of defines below. + */ +#define BPR_MAC 1 +#define BPR_IPNET 2 + +#define MBPF_OPEN(_m, _n, _p, _z) (_m)->bpr_open(_n, (uintptr_t *)_p, _z) +#define MBPF_CLOSE(_m, _h) (_m)->bpr_close(_h) +#define MBPF_NAME(_m, _h) (_m)->bpr_name(_h) +#define MBPF_TYPE(_m, _h) (_m)->bpr_type(_h) +#define MBPF_SDU_GET(_m, _h, _p) (_m)->bpr_sdu_get(_h, _p) +#define MBPF_TX(_m, _h, _pkt) (_m)->bpr_tx(_h, _pkt) +#define MBPF_PROMISC_ADD(_m, _h, _o, _d, _p, _f) \ + (_m)->bpr_promisc_add(_h, _o, _d, _p, _f) +#define MBPF_PROMISC_REMOVE(_m, _h) (_m)->bpr_promisc_remove(_h) +#define MBPF_GET_LINKID(_m, _n, _ip, _z) \ + (_m)->bpr_getlinkid(_n, _ip, _z) +#define MBPF_CLIENT_CLOSE(_m, _h) (_m)->bpr_client_close(_h) +#define MBPF_CLIENT_NAME(_m, _h) (_m)->bpr_client_name(_h) +#define MBPF_CLIENT_OPEN(_m, _h, _p) (_m)->bpr_client_open((uintptr_t)_h, \ + (uintptr_t *)_p) +#define MBPF_GET_ZONE(_m, _h, _zp) (_m)->bpr_getzone(_h, _zp) +#define MBPF_GET_DLT(_m, _h, _dp) (_m)->bpr_getdlt(_h, _dp); +#define MBPF_GET_HDRLEN(_m, _h, _dp) (_m)->bpr_gethdrlen(_h, _dp); + + +/* + * Descriptor associated with each open bpf file. + */ +struct bpf_d { + LIST_ENTRY(bpf_d) bd_list; /* List of bpf_d */ + LIST_ENTRY(bpf_d) bd_next; /* List attaced to bif_if */ + /* + * Buffer slots: two mbuf clusters buffer the incoming packets. + * The model has three slots. Sbuf is always occupied. + * sbuf (store) - Receive interrupt puts packets here. + * hbuf (hold) - When sbuf is full, put cluster here and + * wakeup read (replace sbuf with fbuf). + * fbuf (free) - When read is done, put cluster here. + * On receiving, if sbuf is full and fbuf is 0, packet is dropped. + */ + void * bd_sbuf; /* store slot */ + void * bd_hbuf; /* hold slot */ + void * bd_fbuf; /* free slot */ + int bd_slen; /* current length of store buffer */ + int bd_hlen; /* current length of hold buffer */ + + int bd_bufsize; /* absolute length of buffers */ + + uintptr_t bd_bif; /* interface pointer */ + ulong_t bd_rtout; /* Read timeout in 'ticks' */ + struct bpf_insn *bd_filter; /* filter code */ + size_t bd_filter_size; + ulong_t bd_rcount; /* number of packets received */ + ulong_t bd_dcount; /* number of packets dropped */ + ulong_t bd_ccount; /* number of packets captured */ + + uchar_t bd_promisc; /* true if listening promiscuously */ + uchar_t bd_state; /* idle, waiting, or timed out */ + uchar_t bd_immediate; /* true to return on packet arrival */ + int bd_hdrcmplt; /* false to fill in src lladdr */ + int bd_seesent; /* true if bpf should see sent pkts */ + int bd_async; /* non-zero if packet reception .. */ + /* .. should generate signal */ + int bd_nonblock; /* non-zero for non-blocking read */ + pid_t bd_pgid; /* process or group id for signal */ + int bd_timedout; + timeout_id_t bd_callout; /* for BPF timeouts with select */ + pid_t bd_pid; /* corresponding PID */ + void *bd_sih; /* soft interrupt handle */ + /* + * Solaris specific bits after this. + */ + kmutex_t bd_lock; + kcondvar_t bd_wait; + uintptr_t bd_mh; /* where mac_handle gets put */ + uintptr_t bd_mcip; /* Where mac_client_handle_t gets put */ + uintptr_t bd_promisc_handle; + minor_t bd_dev; /* device number for this handle */ + int bd_fmode; /* flags from bpfopen */ + zoneid_t bd_zone; /* zoneid of the opening process */ + int bd_inuse; + int bd_waiting; + char bd_ifname[LIFNAMSIZ]; + int bd_dlt; + int bd_hdrlen; + bpf_provider_t bd_mac; + datalink_id_t bd_linkid; + /* + * bd_promisc_flags is used to store the promiscuous state of the + * the interface in BPF so that the correct mode of operation can + * be kept across changing DLT or network interface. + */ + int bd_promisc_flags; +}; + + +/* Values for bd_state */ +#define BPF_IDLE 0 /* no select in progress */ +#define BPF_WAITING 1 /* waiting for read timeout in select */ +#define BPF_TIMED_OUT 2 /* read timeout has expired in select */ + +/* + * Description associated with the external representation of each + * open bpf file. + */ +struct bpf_d_ext { + int32_t bde_bufsize; + uint8_t bde_promisc; + uint8_t bde_state; + uint8_t bde_immediate; + int32_t bde_hdrcmplt; + int32_t bde_seesent; + pid_t bde_pid; + uint64_t bde_rcount; /* number of packets received */ + uint64_t bde_dcount; /* number of packets dropped */ + uint64_t bde_ccount; /* number of packets captured */ + char bde_ifname[IFNAMSIZ]; +}; + +#ifdef _KERNEL +typedef struct bpf_kstats_s { + kstat_named_t kp_read_wait; + kstat_named_t kp_write_ok; + kstat_named_t kp_write_error; + kstat_named_t kp_receive; + kstat_named_t kp_capture; + kstat_named_t kp_dropped; +} bpf_kstats_t; + +int bpf_setf(struct bpf_d *, struct bpf_program *); +#endif + +typedef void (*bpf_attach_fn_t)(uintptr_t, int, zoneid_t, int); +typedef void (*bpf_detach_fn_t)(uintptr_t); +typedef int (*bpf_provider_reg_fn_t)(bpf_provider_t *); +typedef LIST_HEAD(, bpf_provider_list) bpf_provider_head_t; + +extern bpf_provider_t *bpf_find_provider_by_id(int); +extern int bpf_provider_tickle(char *, zoneid_t); +extern bpf_provider_head_t bpf_providers; + +#endif /* !_NET_BPFDESC_H_ */ diff --git a/illumos-x86_64/usr/include/net/bridge.h b/illumos-x86_64/usr/include/net/bridge.h new file mode 100644 index 00000000..c1df72eb --- /dev/null +++ b/illumos-x86_64/usr/include/net/bridge.h @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NET_BRIDGE_H +#define _NET_BRIDGE_H + +/* + * Private communication interface between bridging related daemons and kernel + * layer-two (Ethernet) bridging module. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Specified by IEEE 802.1d */ +#define BRIDGE_GROUP_ADDRESS { 0x01, 0x80, 0xC2, 0, 0, 0 } + +/* The constant below is "BRG" in hex. */ +#define _BRIOC(n) (0x42524700 + (n)) + +#define BRIOC_NEWBRIDGE _BRIOC(1) /* Create bridge; bridge_newbridge_t */ +#define BRIOC_ADDLINK _BRIOC(2) /* Add link to bridge; linkid+name */ +#define BRIOC_REMLINK _BRIOC(3) /* Remove link from bridge; linkid */ +#define BRIOC_SETSTATE _BRIOC(4) /* bridge_setstate_t */ +#define BRIOC_SETPVID _BRIOC(5) /* bridge_setpvid_t */ +#define BRIOC_VLANENAB _BRIOC(6) /* bridge_vlanenab_t */ +#define BRIOC_FLUSHFWD _BRIOC(7) /* bridge_flushfwd_t */ +#define BRIOC_LISTFWD _BRIOC(8) /* bridge_listfwd_t */ +#define BRIOC_TABLEMAX _BRIOC(8) /* uint32_t */ + +#define BRIDGE_CTL "bridgectl" +#define BRIDGE_CTLPATH "/dev/" BRIDGE_CTL + +typedef struct bridge_newbridge_s { + datalink_id_t bnb_linkid; /* bridge link ID */ + char bnb_name[MAXNAMELEN]; /* bridge name */ +} bridge_newbridge_t; + +typedef enum bridge_state_e { + BLS_BLOCKLISTEN, /* blocking or listening state */ + BLS_LEARNING, /* learning state */ + BLS_FORWARDING /* forwarding state */ +} bridge_state_t; + +typedef struct bridge_setstate_s { + datalink_id_t bss_linkid; + bridge_state_t bss_state; +} bridge_setstate_t; + +typedef struct bridge_setpvid_s { + datalink_id_t bsv_linkid; + uint_t bsv_vlan; +} bridge_setpvid_t; + +typedef struct bridge_vlanenab_s { + datalink_id_t bve_linkid; + uint_t bve_vlan; + boolean_t bve_onoff; +} bridge_vlanenab_t; + +typedef struct bridge_flushfwd_s { + datalink_id_t bff_linkid; + boolean_t bff_exclude; +} bridge_flushfwd_t; + +typedef struct bridge_listfwd_s { + char blf_name[MAXNAMELEN]; /* bridge name */ + ether_addr_t blf_dest; + uint16_t blf_trill_nick; + uint_t blf_ms_age; + boolean_t blf_is_local; + datalink_id_t blf_linkid; +} bridge_listfwd_t; + +/* Upward control messages */ +typedef struct bridge_ctl_s { + datalink_id_t bc_linkid; + boolean_t bc_failed; /* Max SDU mismatch */ +} bridge_ctl_t; + +/* GLDv3 control ioctls used by Bridging */ +#define BRIDGE_IOC_LISTFWD BRIDGEIOC(1) + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_BRIDGE_H */ diff --git a/illumos-x86_64/usr/include/net/dlt.h b/illumos-x86_64/usr/include/net/dlt.h new file mode 100644 index 00000000..a6aa18fa --- /dev/null +++ b/illumos-x86_64/usr/include/net/dlt.h @@ -0,0 +1,170 @@ +/* $NetBSD: dlt.h,v 1.11 2006/02/27 14:22:26 drochner Exp $ */ + +/* + * Copyright (c) 1990, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bpf.h 8.2 (Berkeley) 1/9/95 + * @(#) Header: bpf.h,v 1.36 97/06/12 14:29:53 leres Exp (LBL) + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NET_DLT_H_ +#define _NET_DLT_H_ + +/* + * Data-link level type codes. + */ +#define DLT_NULL 0 /* no link-layer encapsulation */ +#define DLT_EN10MB 1 /* Ethernet (10Mb) */ +#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */ +#define DLT_AX25 3 /* Amateur Radio AX.25 */ +#define DLT_PRONET 4 /* Proteon ProNET Token Ring */ +#define DLT_CHAOS 5 /* Chaos */ +#define DLT_IEEE802 6 /* IEEE 802 Networks */ +#define DLT_ARCNET 7 /* ARCNET */ +#define DLT_SLIP 8 /* Serial Line IP */ +#define DLT_PPP 9 /* Point-to-point Protocol */ +#define DLT_FDDI 10 /* FDDI */ +#define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */ +#define DLT_RAW 12 /* raw IP */ +#define DLT_SLIP_BSDOS 13 /* BSD/OS Serial Line IP */ +#define DLT_PPP_BSDOS 14 /* BSD/OS Point-to-point Protocol */ +#define DLT_HIPPI 15 /* HIPPI */ +#define DLT_HDLC 16 /* HDLC framing */ + +#define DLT_PFSYNC 18 /* Packet filter state syncing */ +#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */ +#define DLT_ENC 109 /* Encapsulated packets for IPsec */ +#define DLT_LINUX_SLL 113 /* Linux cooked sockets */ +#define DLT_LTALK 114 /* Apple LocalTalk hardware */ +#define DLT_PFLOG 117 /* Packet filter logging, by pcap people */ +#define DLT_CISCO_IOS 118 /* Registered for Cisco-internal use */ + +/* Axent Raptor / Symantec Enterprise Firewall */ +#define DLT_SYMANTEC_FIREWALL 99 + +#define DLT_C_HDLC 104 /* Cisco HDLC */ +#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */ +#define DLT_FRELAY 107 /* Frame Relay */ +#define DLT_LOOP 108 /* OpenBSD DLT_LOOP */ +#define DLT_ECONET 115 /* Acorn Econet */ +#define DLT_PRISM_HEADER 119 /* 802.11 header plus Prism II info. */ +#define DLT_AIRONET_HEADER 120 /* 802.11 header plus Aironet info. */ +#define DLT_HHDLC 121 /* Reserved for Siemens HiPath HDLC */ +#define DLT_IP_OVER_FC 122 /* RFC 2625 IP-over-Fibre Channel */ +#define DLT_SUNATM 123 /* Solaris+SunATM */ +#define DLT_RIO 124 /* RapidIO */ +#define DLT_PCI_EXP 125 /* PCI Express */ +#define DLT_AURORA 126 /* Xilinx Aurora link layer */ +#define DLT_IEEE802_11_RADIO 127 /* 802.11 header plus radio info. */ +#define DLT_TZSP 128 /* Tazmen Sniffer Protocol */ +#define DLT_ARCNET_LINUX 129 /* ARCNET */ +#define DLT_JUNIPER_MLPPP 130 /* Juniper-private data link types. */ +#define DLT_JUNIPER_MLFR 131 +#define DLT_JUNIPER_ES 132 +#define DLT_JUNIPER_GGSN 133 +#define DLT_JUNIPER_MFR 134 +#define DLT_JUNIPER_ATM2 135 +#define DLT_JUNIPER_SERVICES 136 +#define DLT_JUNIPER_ATM1 137 +#define DLT_APPLE_IP_OVER_IEEE1394 138 /* Apple IP-over-IEEE 1394 */ + +/* Various SS7 encapsulations */ +#define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, */ + /* followed by MTP2 */ +#define DLT_MTP2 140 /* MTP2, no pseudo-header */ +#define DLT_MTP3 141 /* MTP3, no pseudo-header or MTP2 */ +#define DLT_SCCP 142 /* SCCP, no pseudo-header or MTP2 */ + /* or MTP3 */ + +#define DLT_DOCSIS 143 /* Reserved for DOCSIS MAC frames. */ +#define DLT_LINUX_IRDA 144 /* Linux-IrDA packets */ + +/* Reserved for IBM SP switch and IBM Next Federation switch. */ +#define DLT_IBM_SP 145 +#define DLT_IBM_SN 146 + +#define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS header */ +#define DLT_JUNIPER_MONITOR 164 /* Juniper-private data link type */ +#define DLT_BACNET_MS_TP 165 +#define DLT_PPP_PPPD 166 /* Another PPP variant (Linux? */ + +#define DLT_JUNIPER_PPPOE 167 +#define DLT_JUNIPER_PPPOE_ATM 168 +#define DLT_JUNIPER_PIC_PEER 174 +#define DLT_JUNIPER_ETHER 178 +#define DLT_JUNIPER_PPP 179 +#define DLT_JUNIPER_FRELAY 180 +#define DLT_JUNIPER_CHDLC 181 + +#define DLT_GPRS_LLC 169 /* GPRS LLC */ +#define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */ +#define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */ + +#define DLT_GCOM_T1E1 172 +#define DLT_GCOM_SERIAL 173 + +/* "EndaceRecordFormat" */ +#define DLT_ERF_ETH 175 /* Ethernet */ +#define DLT_ERF_POS 176 /* Packet-over-SONET */ + +#define DLT_LINUX_LAPD 177 /* Raw LAPD for vISDN */ + +#define DLT_IPNET 226 /* MAC client view on Solaris */ +/* + * A number reserved for private user use is currently assigned, pending + * a real one from tcpdump.org. A description of the link layer frame + * is a requisite for this. + */ +#define DLT_IPOIB 162 /* Infiniband (IPoIB) on Solaris */ + +/* + * NetBSD-specific generic "raw" link type. The upper 16-bits indicate + * that this is the generic raw type, and the lower 16-bits are the + * address family we're dealing with. + */ +#define DLT_RAWAF_MASK 0x02240000 +#define DLT_RAWAF(af) (DLT_RAWAF_MASK | (af)) +#define DLT_RAWAF_AF(x) ((x) & 0x0000ffff) +#define DLT_IS_RAWAF(x) (((x) & 0xffff0000) == DLT_RAWAF_MASK) + +/* + * Solaris specific function to map DLPI DL_ data link types to BPF DLT_ + */ +extern int bpf_dl_to_dlt(int); +extern int bpf_dl_hdrsize(int); + +#endif /* !_NET_DLT_H_ */ diff --git a/illumos-x86_64/usr/include/net/if.h b/illumos-x86_64/usr/include/net/if.h new file mode 100644 index 00000000..924fd390 --- /dev/null +++ b/illumos-x86_64/usr/include/net/if.h @@ -0,0 +1,734 @@ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NET_IF_H +#define _NET_IF_H + +/* if.h 1.26 90/05/29 SMI; from UCB 7.1 6/4/86 */ + +#include + +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#include +#include +#if defined(_LP64) +#include +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structures defining a network interface, providing a packet + * transport mechanism (ala level 0 of the PUP protocols). + * + * Each interface accepts output datagrams of a specified maximum + * length, and provides higher level routines with input datagrams + * received from its medium. + * + * Output occurs when the routine if_output is called, with three parameters: + * (*ifp->if_output)(ifp, m, dst) + * Here m is the mbuf chain to be sent and dst is the destination address. + * The output routine encapsulates the supplied datagram if necessary, + * and then transmits it on its medium. + * + * On input, each interface unwraps the data received by it, and either + * places it on the input queue of a internetwork datagram routine + * and posts the associated software interrupt, or passes the datagram to a raw + * packet input routine. + * + * Routines exist for locating interfaces by their addresses + * or for locating a interface on a certain network, as well as more general + * routing and gateway routines maintaining information used to locate + * interfaces. These routines live in the files if.c and route.c + */ + +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) + +/* + * Structure defining a queue for a network interface. + * + * (Would like to call this struct ``if'', but C isn't PL/1.) + */ +struct ifnet { + char *if_name; /* name, e.g. ``en'' or ``lo'' */ + short if_unit; /* sub-unit for lower level driver */ + short if_mtu; /* maximum transmission unit */ + short if_flags; /* up/down, broadcast, etc. */ + short if_timer; /* time 'til if_watchdog called */ + ushort_t if_promisc; /* net # of requests for promisc mode */ + int if_metric; /* routing metric (external only) */ + struct ifaddr *if_addrlist; /* linked list of addresses per if */ + struct ifqueue { + struct mbuf *ifq_head; + struct mbuf *ifq_tail; + int ifq_len; + int ifq_maxlen; + int ifq_drops; + } if_snd; /* output queue */ +/* procedure handles */ + int (*if_init)(); /* init routine */ + int (*if_output)(); /* output routine */ + int (*if_ioctl)(); /* ioctl routine */ + int (*if_reset)(); /* bus reset routine */ + int (*if_watchdog)(); /* timer routine */ +/* generic interface statistics */ + int if_ipackets; /* packets received on interface */ + int if_ierrors; /* input errors on interface */ + int if_opackets; /* packets sent on interface */ + int if_oerrors; /* output errors on interface */ + int if_collisions; /* collisions on csma interfaces */ +/* end statistics */ + struct ifnet *if_next; + struct ifnet *if_upper; /* next layer up */ + struct ifnet *if_lower; /* next layer down */ + int (*if_input)(); /* input routine */ + int (*if_ctlin)(); /* control input routine */ + int (*if_ctlout)(); /* control output routine */ + struct map *if_memmap; /* rmap for interface specific memory */ +}; + +/* + * NOTE : These flags are not directly used within IP. + * ip_if.h has definitions derived from this which is used within IP. + * If you define a flag here, you need to define one in ip_if.h before + * using the new flag in IP. Don't use these flags directly in IP. + */ +#define IFF_UP 0x0000000001 /* address is up */ +#define IFF_BROADCAST 0x0000000002 /* broadcast address valid */ +#define IFF_DEBUG 0x0000000004 /* turn on debugging */ +#define IFF_LOOPBACK 0x0000000008 /* is a loopback net */ + +#define IFF_POINTOPOINT 0x0000000010 /* interface is point-to-point link */ +#define IFF_NOTRAILERS 0x0000000020 /* avoid use of trailers */ +#define IFF_RUNNING 0x0000000040 /* resources allocated */ +#define IFF_NOARP 0x0000000080 /* no address resolution protocol */ + +#define IFF_PROMISC 0x0000000100 /* receive all packets */ +#define IFF_ALLMULTI 0x0000000200 /* receive all multicast packets */ +#define IFF_INTELLIGENT 0x0000000400 /* protocol code on board */ +/* + * The IFF_MULTICAST flag indicates that the network can support the + * transmission and reception of higher-level (e.g., IP) multicast packets. + * It is independent of hardware support for multicasting; for example, + * point-to-point links or pure broadcast networks may well support + * higher-level multicasts. + */ +#define IFF_MULTICAST 0x0000000800 /* supports multicast */ + +#define IFF_MULTI_BCAST 0x0000001000 /* multicast using broadcast address */ +#define IFF_UNNUMBERED 0x0000002000 /* non-unique address */ +#define IFF_DHCPRUNNING 0x0000004000 /* DHCP controls this interface */ +#define IFF_PRIVATE 0x0000008000 /* do not advertise */ + +/* + * The following flags can't be grabbed or altered by SIOC[GS]IFFLAGS. + * Should use SIOC[GS]LIFFLAGS which has a larger flags field. + */ +#define IFF_NOXMIT 0x0000010000 /* Do not transmit packets */ +#define IFF_NOLOCAL 0x0000020000 /* No address - just on-link subnet */ +#define IFF_DEPRECATED 0x0000040000 /* Address is deprecated */ +#define IFF_ADDRCONF 0x0000080000 /* address from stateless addrconf */ + +#define IFF_ROUTER 0x0000100000 /* router on this interface */ +#define IFF_NONUD 0x0000200000 /* No NUD on this interface */ +#define IFF_ANYCAST 0x0000400000 /* Anycast address */ +#define IFF_NORTEXCH 0x0000800000 /* Do not exchange routing info */ + +#define IFF_IPV4 0x0001000000 /* IPv4 interface */ +#define IFF_IPV6 0x0002000000 /* IPv6 interface */ +#define IFF_NOACCEPT 0x0004000000 /* no-accept mode VRRP ill */ +#define IFF_NOFAILOVER 0x0008000000 /* in.mpathd(8) test address */ + +#define IFF_FAILED 0x0010000000 /* Interface has failed */ +#define IFF_STANDBY 0x0020000000 /* Interface is a hot-spare */ +#define IFF_INACTIVE 0x0040000000 /* Functioning but not used for data */ +#define IFF_OFFLINE 0x0080000000 /* Interface is offline */ + +/* + * The IFF_XRESOLV flag is an evolving interface and is subject + * to change without notice. + */ +#define IFF_XRESOLV 0x0100000000ll /* IPv6 external resolver */ +#define IFF_COS_ENABLED 0x0200000000ll /* If interface supports CoS marking */ +#define IFF_PREFERRED 0x0400000000ll /* Prefer as source address */ +#define IFF_TEMPORARY 0x0800000000ll /* RFC3041 */ + +#define IFF_FIXEDMTU 0x1000000000ll /* MTU manually set with SIOCSLIFMTU */ +#define IFF_VIRTUAL 0x2000000000ll /* Does not send or receive packets */ +#define IFF_DUPLICATE 0x4000000000ll /* Local address already in use */ +#define IFF_IPMP 0x8000000000ll /* IPMP IP interface */ +#define IFF_VRRP 0x10000000000ll /* Managed by VRRP */ + +#define IFF_NOLINKLOCAL 0x20000000000ll /* No default linklocal */ +#define IFF_L3PROTECT 0x40000000000ll /* Layer-3 protection enforced */ + +/* flags that cannot be changed by userland on any interface */ +#define IFF_CANTCHANGE \ + (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING | IFF_PROMISC | \ + IFF_MULTICAST | IFF_MULTI_BCAST | IFF_UNNUMBERED | IFF_IPV4 | \ + IFF_IPV6 | IFF_IPMP | IFF_FIXEDMTU | IFF_VIRTUAL | \ + IFF_LOOPBACK | IFF_ALLMULTI | IFF_DUPLICATE | IFF_COS_ENABLED | \ + IFF_VRRP | IFF_NOLINKLOCAL | IFF_L3PROTECT) + +/* flags that cannot be changed by userland on an IPMP interface */ +#define IFF_IPMP_CANTCHANGE IFF_FAILED + +/* flags that can never be set on an IPMP interface */ +#define IFF_IPMP_INVALID (IFF_STANDBY | IFF_INACTIVE | IFF_OFFLINE | \ + IFF_NOFAILOVER | IFF_NOARP | IFF_NONUD | IFF_XRESOLV | IFF_NOACCEPT) + +/* + * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) + * input routines have queues of messages stored on ifqueue structures + * (defined above). Entries are added to and deleted from these structures + * by these macros, which should be called with ipl raised to splimp(). + */ +#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) +#define IF_DROP(ifq) ((ifq)->ifq_drops++) +#define IF_ENQUEUE(ifq, m) { \ + (m)->m_act = 0; \ + if ((ifq)->ifq_tail == 0) \ + (ifq)->ifq_head = m; \ + else \ + (ifq)->ifq_tail->m_act = m; \ + (ifq)->ifq_tail = m; \ + (ifq)->ifq_len++; \ +} +#define IF_PREPEND(ifq, m) { \ + (m)->m_act = (ifq)->ifq_head; \ + if ((ifq)->ifq_tail == 0) \ + (ifq)->ifq_tail = (m); \ + (ifq)->ifq_head = (m); \ + (ifq)->ifq_len++; \ +} + +/* + * Packets destined for level-1 protocol input routines + * have a pointer to the receiving interface prepended to the data. + * IF_DEQUEUEIF extracts and returns this pointer when dequeuing the packet. + * IF_ADJ should be used otherwise to adjust for its presence. + */ +#define IF_ADJ(m) { \ + (m)->m_off += sizeof (struct ifnet *); \ + (m)->m_len -= sizeof (struct ifnet *); \ + if ((m)->m_len == 0) { \ + struct mbuf *n; \ + MFREE((m), n); \ + (m) = n; \ + } \ +} +#define IF_DEQUEUEIF(ifq, m, ifp) { \ + (m) = (ifq)->ifq_head; \ + if (m) { \ + if (((ifq)->ifq_head = (m)->m_act) == 0) \ + (ifq)->ifq_tail = 0; \ + (m)->m_act = 0; \ + (ifq)->ifq_len--; \ + (ifp) = *(mtod((m), struct ifnet **)); \ + IF_ADJ(m); \ + } \ +} +#define IF_DEQUEUE(ifq, m) { \ + (m) = (ifq)->ifq_head; \ + if (m) { \ + if (((ifq)->ifq_head = (m)->m_act) == 0) \ + (ifq)->ifq_tail = 0; \ + (m)->m_act = 0; \ + (ifq)->ifq_len--; \ + } \ +} + +#define IFQ_MAXLEN 50 +#define IFNET_SLOWHZ 1 /* granularity is 1 second */ + +/* + * The ifaddr structure contains information about one address + * of an interface. They are maintained by the different address families, + * are allocated and attached when an address is set, and are linked + * together so all addresses for an interface can be located. + */ +struct ifaddr { + struct sockaddr ifa_addr; /* address of interface */ + union { + struct sockaddr ifu_broadaddr; + struct sockaddr ifu_dstaddr; + } ifa_ifu; +#define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ +#define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */ + struct ifnet *ifa_ifp; /* back-pointer to interface */ + struct ifaddr *ifa_next; /* next address for interface */ +}; + +/* + * For SIOCLIF*ND ioctls. + * + * The lnr_state_* fields use the ND_* neighbor reachability states. + * The 3 different fields are for use with SIOCLIFSETND to cover the cases + * when + * A new entry is created + * The entry already exists and the link-layer address is the same + * The entry already exists and the link-layer address differs + * + * Use ND_UNCHANGED to not change any state. + */ +#define ND_MAX_HDW_LEN 64 +typedef struct lif_nd_req { + struct sockaddr_storage lnr_addr; + uint8_t lnr_state_create; /* When creating */ + uint8_t lnr_state_same_lla; /* Update same addr */ + uint8_t lnr_state_diff_lla; /* Update w/ diff. */ + int lnr_hdw_len; + int lnr_flags; /* See below */ + /* padding because ia32 "long long"s are only 4-byte aligned. */ + int lnr_pad0; + char lnr_hdw_addr[ND_MAX_HDW_LEN]; +} lif_nd_req_t; + +/* + * Neighbor reachability states + * Used with SIOCLIF*ND ioctls. + */ +#define ND_UNCHANGED 0 /* For ioctls that don't modify state */ +#define ND_INCOMPLETE 1 /* addr resolution in progress */ +#define ND_REACHABLE 2 /* have recently been reachable */ +#define ND_STALE 3 /* may be unreachable, don't do anything */ +#define ND_DELAY 4 /* wait for upper layer hint */ +#define ND_PROBE 5 /* send probes */ +#define ND_UNREACHABLE 6 /* delete this route */ +#define ND_INITIAL 7 /* ipv4: arp resolution has not been sent yet */ + +#define ND_STATE_VALID_MIN 0 +#define ND_STATE_VALID_MAX 7 + +/* + * lnr_flags value of lif_nd_req. + * Used with SIOCLIF*ND ioctls. + */ +#define NDF_ISROUTER_ON 0x1 +#define NDF_ISROUTER_OFF 0x2 +#define NDF_ANYCAST_ON 0x4 +#define NDF_ANYCAST_OFF 0x8 +#define NDF_PROXY_ON 0x10 +#define NDF_PROXY_OFF 0x20 +/* + * the NDF_STATIC entry ensures that an NCE will not be deleted, and is + * used by non-ON applications like IPv6 test suites. + */ +#define NDF_STATIC 0x40 + +/* For SIOC[GS]LIFLNKINFO */ +typedef struct lif_ifinfo_req { + uint8_t lir_maxhops; + uint32_t lir_reachtime; /* Reachable time in msec */ + uint32_t lir_reachretrans; /* Retransmission timer msec */ + uint32_t lir_maxmtu; +} lif_ifinfo_req_t; + +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +/* + * Maximum lengths of interface name and IPMP group name; these are the same + * for historical reasons. Note that the actual maximum length of a name is + * one byte less than these constants since the kernel always sets the final + * byte of lifr_name and lifr_groupname to NUL. + */ +#define _LIFNAMSIZ 32 + +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) + +#define LIFNAMSIZ _LIFNAMSIZ +#define LIFGRNAMSIZ LIFNAMSIZ + +/* + * Interface request structure used for socket + * ioctl's. All interface ioctl's must have parameter + * definitions which begin with ifr_name. The + * remainder may be interface specific. + * Note: This data structure uses 64bit type uint64_t which is not + * a valid type for strict ANSI/ISO C compilation for ILP32. + * Applications with ioctls using this structure that insist on + * building with strict ANSI/ISO C (-Xc) will need to be LP64. + */ +#if defined(_INT64_TYPE) +struct lifreq { + char lifr_name[LIFNAMSIZ]; /* if name, e.g. "en0" */ + union { + int lifru_addrlen; /* for subnet/token etc */ + uint_t lifru_ppa; /* SIOCSLIFNAME */ + } lifr_lifru1; +#define lifr_addrlen lifr_lifru1.lifru_addrlen +#define lifr_ppa lifr_lifru1.lifru_ppa /* Driver's ppa */ + uint_t lifr_type; /* IFT_ETHER, ... */ + union { + struct sockaddr_storage lifru_addr; + struct sockaddr_storage lifru_dstaddr; + struct sockaddr_storage lifru_broadaddr; + struct sockaddr_storage lifru_token; /* With lifr_addrlen */ + struct sockaddr_storage lifru_subnet; /* With lifr_addrlen */ + int lifru_index; /* interface index */ + uint64_t lifru_flags; /* Flags for SIOC?LIFFLAGS */ + int lifru_metric; + uint_t lifru_mtu; + int lif_muxid[2]; /* mux id's for arp and ip */ + struct lif_nd_req lifru_nd_req; /* SIOCLIF*ND */ + struct lif_ifinfo_req lifru_ifinfo_req; + char lifru_groupname[LIFGRNAMSIZ]; /* SIOC[GS]LIFGROUPNAME */ + char lifru_binding[LIFNAMSIZ]; /* SIOCGLIFBINDING */ + zoneid_t lifru_zoneid; /* SIOC[GS]LIFZONE */ + uint_t lifru_dadstate; /* SIOCGLIFDADSTATE */ + } lifr_lifru; + +#define lifr_addr lifr_lifru.lifru_addr /* address */ +#define lifr_dstaddr lifr_lifru.lifru_dstaddr /* other end of p-to-p link */ +#define lifr_broadaddr lifr_lifru.lifru_broadaddr /* broadcast address */ +#define lifr_token lifr_lifru.lifru_token /* address token */ +#define lifr_subnet lifr_lifru.lifru_subnet /* subnet prefix */ +#define lifr_index lifr_lifru.lifru_index /* interface index */ +#define lifr_flags lifr_lifru.lifru_flags /* flags */ +#define lifr_metric lifr_lifru.lifru_metric /* metric */ +#define lifr_mtu lifr_lifru.lifru_mtu /* mtu */ +#define lifr_ip_muxid lifr_lifru.lif_muxid[0] +#define lifr_arp_muxid lifr_lifru.lif_muxid[1] +#define lifr_nd lifr_lifru.lifru_nd_req /* SIOCLIF*ND */ +#define lifr_ifinfo lifr_lifru.lifru_ifinfo_req /* SIOC[GS]LIFLNKINFO */ +#define lifr_groupname lifr_lifru.lifru_groupname +#define lifr_binding lifr_lifru.lifru_binding +#define lifr_zoneid lifr_lifru.lifru_zoneid +#define lifr_dadstate lifr_lifru.lifru_dadstate +}; +#endif /* defined(_INT64_TYPE) */ + +/* + * Argument structure for SIOCT* address testing ioctls. + */ +struct sioc_addrreq { + struct sockaddr_storage sa_addr; /* Address to test */ + int sa_res; /* Result - 0/1 */ + int sa_pad; +}; + +/* + * Argument structure used by mrouted to get src-grp pkt counts using + * SIOCGETLSGCNT. See . + */ +struct sioc_lsg_req { + struct sockaddr_storage slr_src; + struct sockaddr_storage slr_grp; + uint_t slr_pktcnt; + uint_t slr_bytecnt; + uint_t slr_wrong_if; + uint_t slr_pad; +}; + +/* Argument structure for SIOCGLIFDADSTATE ioctl */ +typedef enum { + DAD_IN_PROGRESS = 0x1, + DAD_DONE = 0x2 +} glif_dad_state_t; + +/* + * OBSOLETE: Replaced by struct lifreq. Supported for compatibility. + * + * Interface request structure used for socket + * ioctl's. All interface ioctl's must have parameter + * definitions which begin with ifr_name. The + * remainder may be interface specific. + */ +struct ifreq { +#define IFNAMSIZ 16 + char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + char ifru_oname[IFNAMSIZ]; /* other if name */ + struct sockaddr ifru_broadaddr; + int ifru_index; /* interface index */ + uint_t ifru_mtu; + short ifru_flags; + int ifru_metric; + char ifru_data[1]; /* interface dependent data */ + char ifru_enaddr[6]; + int if_muxid[2]; /* mux id's for arp and ip */ + + /* Struct for flags/ppa */ + struct ifr_ppaflags { + short ifrup_flags; /* Space of ifru_flags. */ + short ifrup_filler; + uint_t ifrup_ppa; + } ifru_ppaflags; + + /* Struct for FDDI ioctl's */ + struct ifr_dnld_reqs { + uint32_t v_addr; + uint32_t m_addr; + uint32_t ex_addr; + uint32_t size; + } ifru_dnld_req; + + /* Struct for FDDI stats */ + struct ifr_fddi_stats { + uint32_t stat_size; + uint32_t fddi_stats; + } ifru_fddi_stat; + + struct ifr_netmapents { + uint32_t map_ent_size, /* size of netmap structure */ + entry_number; /* index into netmap list */ + uint32_t fddi_map_ent; /* pointer to user structure */ + } ifru_netmapent; + + /* Field for generic ioctl for fddi */ + + struct ifr_fddi_gen_struct { + uint32_t ifru_fddi_gioctl; /* field for gen ioctl */ + uint32_t ifru_fddi_gaddr; /* Generic ptr to a field */ + } ifru_fddi_gstruct; + + } ifr_ifru; + +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ +#define ifr_oname ifr_ifru.ifru_oname /* other if name */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_data ifr_ifru.ifru_data /* for use by interface */ +#define ifr_enaddr ifr_ifru.ifru_enaddr /* ethernet address */ +#define ifr_index ifr_ifru.ifru_index /* interface index */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +/* For setting ppa */ +#define ifr_ppa ifr_ifru.ifru_ppaflags.ifrup_ppa + +/* FDDI specific */ +#define ifr_dnld_req ifr_ifru.ifru_dnld_req +#define ifr_fddi_stat ifr_ifru.ifru_fddi_stat +#define ifr_fddi_netmap ifr_ifru.ifru_netmapent /* FDDI network map entries */ +#define ifr_fddi_gstruct ifr_ifru.ifru_fddi_gstruct + +#define ifr_ip_muxid ifr_ifru.if_muxid[0] +#define ifr_arp_muxid ifr_ifru.if_muxid[1] +}; + +/* Used by SIOCGLIFNUM. Uses same flags as in struct lifconf */ +struct lifnum { + sa_family_t lifn_family; + int lifn_flags; /* request specific interfaces */ + int lifn_count; /* Result */ +}; + +/* + * Structure used in SIOCGLIFCONF request. + * Used to retrieve interface configuration + * for machine (useful for programs which + * must know all networks accessible) for a given address family. + * Using AF_UNSPEC will retrieve all address families. + */ +struct lifconf { + sa_family_t lifc_family; + int lifc_flags; /* request specific interfaces */ + int lifc_len; /* size of associated buffer */ + union { + caddr_t lifcu_buf; + struct lifreq *lifcu_req; + } lifc_lifcu; +#define lifc_buf lifc_lifcu.lifcu_buf /* buffer address */ +#define lifc_req lifc_lifcu.lifcu_req /* array of structures returned */ +}; + +/* + * Structure used in SIOCGLIFSRCOF to get the interface + * configuration list for those interfaces that use an address + * hosted on the interface (set in lifs_ifindex), as the source + * address. + */ +struct lifsrcof { + uint_t lifs_ifindex; /* interface of interest */ + size_t lifs_maxlen; /* size of buffer: input */ + size_t lifs_len; /* size of buffer: output */ + union { + caddr_t lifsu_buf; + struct lifreq *lifsu_req; + } lifs_lifsu; +#define lifs_buf lifs_lifsu.lifsu_buf /* buffer address */ +#define lifs_req lifs_lifsu.lifsu_req /* array returned */ +}; + +/* Flags */ +#define LIFC_NOXMIT 0x01 /* Include IFF_NOXMIT interfaces */ +#define LIFC_EXTERNAL_SOURCE 0x02 /* Exclude the interfaces which can't */ + /* be used to communicate outside the */ + /* node (exclude interfaces which are */ + /* IFF_NOXMIT, IFF_NOLOCAL, */ + /* IFF_LOOPBACK, IFF_DEPRECATED, or */ + /* not IFF_UP). Has priority over */ + /* LIFC_NOXMIT. */ +#define LIFC_TEMPORARY 0x04 /* Include IFF_TEMPORARY interfaces */ +#define LIFC_ALLZONES 0x08 /* Include all zones */ + /* (must be issued from global zone) */ +#define LIFC_UNDER_IPMP 0x10 /* Include underlying IPMP interfaces */ +#define LIFC_ENABLED 0x20 /* Include only IFF_UP interfaces */ + +#if defined(_SYSCALL32) + +struct lifconf32 { + sa_family_t lifc_family; + int lifc_flags; /* request specific interfaces */ + int32_t lifc_len; /* size of associated buffer */ + union { + caddr32_t lifcu_buf; + caddr32_t lifcu_req; + } lifc_lifcu; +}; + +struct lifsrcof32 { + uint_t lifs_ifindex; /* interface of interest */ + size32_t lifs_maxlen; /* size of buffer: input */ + size32_t lifs_len; /* size of buffer: output */ + union { + caddr32_t lifsu_buf; + caddr32_t lifsu_req; + } lifs_lifsu; +}; + +#endif /* _SYSCALL32 */ + +/* + * IPMP group information, for use with SIOCGLIFGROUPINFO. + */ +typedef struct lifgroupinfo { + char gi_grname[LIFGRNAMSIZ]; /* group name (set by caller) */ + char gi_grifname[LIFNAMSIZ]; /* IPMP meta-interface name */ + char gi_m4ifname[LIFNAMSIZ]; /* v4 mcast interface name */ + char gi_m6ifname[LIFNAMSIZ]; /* v6 mcast interface name */ + char gi_bcifname[LIFNAMSIZ]; /* v4 bcast interface name */ + boolean_t gi_v4; /* group is plumbed for v4 */ + boolean_t gi_v6; /* group is plumbed for v6 */ + uint_t gi_nv4; /* # of underlying v4 if's */ + uint_t gi_nv6; /* # of underlying v6 if's */ + uint_t gi_mactype; /* DLPI mac type of group */ +} lifgroupinfo_t; + +/* + * OBSOLETE: Structure used in SIOCGIFCONF request. + * Used to retrieve interface configuration + * for machine (useful for programs which + * must know all networks accessible). + */ +struct ifconf { + int ifc_len; /* size of associated buffer */ + union { + caddr_t ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ +#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ +}; + +#if defined(_SYSCALL32) + +struct ifconf32 { + int32_t ifc_len; /* size of associated buffer */ + union { + caddr32_t ifcu_buf; + caddr32_t ifcu_req; + } ifc_ifcu; +}; + +#endif /* _SYSCALL32 */ + +typedef struct if_data { + /* generic interface information */ + uchar_t ifi_type; /* ethernet, tokenring, etc */ + uchar_t ifi_addrlen; /* media address length */ + uchar_t ifi_hdrlen; /* media header length */ + uint_t ifi_mtu; /* maximum transmission unit */ + uint_t ifi_metric; /* routing metric (external only) */ + uint_t ifi_baudrate; /* linespeed */ + /* volatile statistics */ + uint_t ifi_ipackets; /* packets received on interface */ + uint_t ifi_ierrors; /* input errors on interface */ + uint_t ifi_opackets; /* packets sent on interface */ + uint_t ifi_oerrors; /* output errors on interface */ + uint_t ifi_collisions; /* collisions on csma interfaces */ + uint_t ifi_ibytes; /* total number of octets received */ + uint_t ifi_obytes; /* total number of octets sent */ + uint_t ifi_imcasts; /* packets received via multicast */ + uint_t ifi_omcasts; /* packets sent via multicast */ + uint_t ifi_iqdrops; /* dropped on input, this interface */ + uint_t ifi_noproto; /* destined for unsupported protocol */ +#if defined(_LP64) + struct timeval32 ifi_lastchange; /* last updated */ +#else + struct timeval ifi_lastchange; /* last updated */ +#endif +} if_data_t; + +/* + * Message format for use in obtaining information about interfaces + * from the routing socket + */ +typedef struct if_msghdr { + ushort_t ifm_msglen; /* to skip over non-understood messages */ + uchar_t ifm_version; /* future binary compatibility */ + uchar_t ifm_type; /* message type */ + int ifm_addrs; /* like rtm_addrs */ + int ifm_flags; /* value of if_flags */ + ushort_t ifm_index; /* index for associated ifp */ + struct if_data ifm_data; /* statistics and other data about if */ +} if_msghdr_t; + +/* + * Message format for use in obtaining information about interface addresses + * from the routing socket + */ +typedef struct ifa_msghdr { + ushort_t ifam_msglen; /* to skip over non-understood messages */ + uchar_t ifam_version; /* future binary compatibility */ + uchar_t ifam_type; /* message type */ + int ifam_addrs; /* like rtm_addrs */ + int ifam_flags; /* route flags */ + ushort_t ifam_index; /* index for associated ifp */ + int ifam_metric; /* value of ipif_metric */ +} ifa_msghdr_t; + +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +/* + * The if_nameindex structure holds the interface index value about + * a single interface. An array of this structure is used to return + * all interfaces and indexes. + */ +struct if_nameindex { + unsigned if_index; /* positive interface index */ + char *if_name; /* if name, e.g. "en0" */ +}; + +/* Interface index identification API definitions */ +extern unsigned if_nametoindex(const char *); +extern char *if_indextoname(unsigned, char *); +extern struct if_nameindex *if_nameindex(void); +extern void if_freenameindex(struct if_nameindex *); + +#define IF_NAMESIZE _LIFNAMSIZ +/* + * If changing IF_MAX_INDEX to a value greater than UINT16_MAX, check if + * struct sockaddr_dl needs to be modified as the interface index is placed + * in this structure by the kernel. + */ +#define IF_INDEX_MAX UINT16_MAX + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_IF_H */ diff --git a/illumos-x86_64/usr/include/net/if_arp.h b/illumos-x86_64/usr/include/net/if_arp.h new file mode 100644 index 00000000..20cb83f4 --- /dev/null +++ b/illumos-x86_64/usr/include/net/if_arp.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright (c) 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NET_IF_ARP_H +#define _NET_IF_ARP_H + +/* if_arp.h 1.5 88/08/19 SMI; from UCB 7.1 1/24/86 */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Address Resolution Protocol. + * + * See RFC 826 for protocol description. ARP packets are variable + * in size; the arphdr structure defines the fixed-length portion. + * Protocol type values are the same as those for 10 Mb/s Ethernet. + * It is followed by the variable-sized fields ar_sha, arp_spa, + * arp_tha and arp_tpa in that order, according to the lengths + * specified. Field names used correspond to RFC 826. + */ +struct arphdr { + ushort_t ar_hrd; /* format of hardware address */ +#define ARPHRD_ETHER 1 /* ethernet hardware address */ +#define ARPHRD_EETHER 2 /* experimental ethernet */ +#define ARPHRD_AX25 3 /* amateur readio ax.25 */ +#define ARPHRD_CHAOS 5 /* Chaos net */ +#define ARPHRD_IEEE802 6 /* IEEE 802 hardware address */ +#define ARPHRD_ARCNET 7 /* ARCNET */ +#define ARPHRD_FRAME 15 /* Frame relay */ +#define ARPHRD_ATM 16 /* ATM */ +#define ARPHRD_HDLC 17 /* HDLC */ +#define ARPHRD_FC 18 /* Fibre Channel RFC 4338 */ +#define ARPHRD_IPATM 19 /* ATM RFC 2225 */ +#define ARPHRD_METRICOM 23 /* Metricom */ +#define ARPHRD_TUNNEL 31 /* IPsec Tunnel RFC 3456 */ +#define ARPHRD_IB 32 /* IPoIB hardware address */ + ushort_t ar_pro; /* format of protocol address */ + uchar_t ar_hln; /* length of hardware address */ + uchar_t ar_pln; /* length of protocol address */ + ushort_t ar_op; /* one of: */ +#define ARPOP_REQUEST 1 /* request to resolve address */ +#define ARPOP_REPLY 2 /* response to previous request */ +#define REVARP_REQUEST 3 /* Reverse ARP request */ +#define REVARP_REPLY 4 /* Reverse ARP reply */ + /* + * The remaining fields are variable in size, + * according to the sizes above, and are defined + * as appropriate for specific hardware/protocol + * combinations. (E.g., see .) + */ +#ifdef notdef + uchar_t ar_sha[]; /* sender hardware address */ + uchar_t ar_spa[]; /* sender protocol address */ + uchar_t ar_tha[]; /* target hardware address */ + uchar_t ar_tpa[]; /* target protocol address */ +#endif /* notdef */ +}; + +/* Maximum hardware and protocol address length */ +#define ARP_MAX_ADDR_LEN 255 + +/* + * Extended ARP ioctl request + */ +struct xarpreq { + struct sockaddr_storage xarp_pa; /* protocol address */ + struct sockaddr_dl xarp_ha; /* hardware address */ + int xarp_flags; /* flags */ +}; + +/* + * BSD ARP ioctl request + */ +struct arpreq { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ +}; +/* arp_flags field values */ +#define ATF_INUSE 0x01 /* entry in use */ +#define ATF_COM 0x02 /* completed entry (enaddr valid) */ +#define ATF_PERM 0x04 /* permanent entry */ +#define ATF_PUBL 0x08 /* publish entry (respond for other host) */ +#define ATF_USETRAILERS 0x10 /* has requested trailers */ +#define ATF_AUTHORITY 0x20 /* hardware address is authoritative */ + +/* + * This data structure is used by kernel protocol modules to register + * their interest in a particular packet type with the Ethernet drivers. + * For example, other kinds of ARP would use this, XNS, ApleTalk, etc. + */ +struct ether_family { + int ef_family; /* address family */ + ushort_t ef_ethertype; /* ethernet type field */ + struct ifqueue *(*ef_infunc)(); /* input function */ + int (*ef_outfunc)(); /* output function */ + int (*ef_netisr)(); /* soft interrupt function */ + struct ether_family *ef_next; /* link to next on list */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_IF_ARP_H */ diff --git a/illumos-x86_64/usr/include/net/if_dl.h b/illumos-x86_64/usr/include/net/if_dl.h new file mode 100644 index 00000000..675d19a2 --- /dev/null +++ b/illumos-x86_64/usr/include/net/if_dl.h @@ -0,0 +1,92 @@ +/* + * Copyright 1993-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _NET_IF_DL_H +#define _NET_IF_DL_H + +/* from UCB 8.1 (Berkeley) 6/10/93 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A Link-Level Sockaddr may specify the interface in one of two + * ways: either by means of a system-provided index number (computed + * anew and possibly differently on every reboot), or by a human-readable + * string such as "il0" (for managerial convenience). + * + * Census taking actions, such as something akin to SIOCGCONF would return + * both the index and the human name. + * + * High volume transactions (such as giving a link-level ``from'' address + * in a recvfrom or recvmsg call) may be likely only to provide the indexed + * form, (which requires fewer copy operations and less space). + * + * The form and interpretation of the link-level address is purely a matter + * of convention between the device driver and its consumers; however, it is + * expected that all drivers for an interface of a given if_type will agree. + */ + +/* + * Structure of a Link-Level sockaddr: + */ +struct sockaddr_dl { + ushort_t sdl_family; /* AF_LINK */ + ushort_t sdl_index; /* if != 0, system given index for interface */ + uchar_t sdl_type; /* interface type */ + uchar_t sdl_nlen; /* interface name length, no trailing 0 reqd. */ + uchar_t sdl_alen; /* link level address length */ + uchar_t sdl_slen; /* link layer selector length */ + char sdl_data[244]; /* contains both if name and ll address */ +}; + +#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen)) + +#ifdef __STDC__ +extern char *_link_ntoa(const unsigned char *, char *, int, int); +extern unsigned char *_link_aton(const char *, int *); +#else /* __STDC__ */ +extern char *_link_ntoa(); +extern unsigned char *_link_aton(); +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_IF_DL_H */ diff --git a/illumos-x86_64/usr/include/net/if_types.h b/illumos-x86_64/usr/include/net/if_types.h new file mode 100644 index 00000000..7e83b0ec --- /dev/null +++ b/illumos-x86_64/usr/include/net/if_types.h @@ -0,0 +1,116 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _NET_IF_TYPES_H +#define _NET_IF_TYPES_H + +/* from UCB 8.3 (Berkeley) 4/28/95 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Interface types for benefit of parsing media address headers. + * This list is derived from the SNMP list of ifTypes, currently + * documented in RFC1573. + */ + +#define IFT_OTHER 0x1 /* none of the following */ +#define IFT_1822 0x2 /* old-style arpanet imp */ +#define IFT_HDH1822 0x3 /* HDH arpanet imp */ +#define IFT_X25DDN 0x4 /* x25 to imp */ +#define IFT_X25 0x5 /* PDN X25 interface (RFC877) */ +#define IFT_ETHER 0x6 /* Ethernet CSMACD */ +#define IFT_ISO88023 0x7 /* CMSA CD */ +#define IFT_ISO88024 0x8 /* Token Bus */ +#define IFT_ISO88025 0x9 /* Token Ring */ +#define IFT_ISO88026 0xa /* MAN */ +#define IFT_STARLAN 0xb +#define IFT_P10 0xc /* Proteon 10MBit ring */ +#define IFT_P80 0xd /* Proteon 80MBit ring */ +#define IFT_HY 0xe /* Hyperchannel */ +#define IFT_FDDI 0xf +#define IFT_LAPB 0x10 +#define IFT_SDLC 0x11 +#define IFT_T1 0x12 +#define IFT_CEPT 0x13 /* E1 - european T1 */ +#define IFT_ISDNBASIC 0x14 +#define IFT_ISDNPRIMARY 0x15 +#define IFT_PTPSERIAL 0x16 /* Proprietary PTP serial */ +#define IFT_PPP 0x17 /* RFC 1331 */ +#define IFT_LOOP 0x18 /* loopback */ +#define IFT_EON 0x19 /* ISO over IP */ +#define IFT_XETHER 0x1a /* obsolete 3MB experimental ethernet */ +#define IFT_NSIP 0x1b /* XNS over IP */ +#define IFT_SLIP 0x1c /* IP over generic TTY */ +#define IFT_ULTRA 0x1d /* Ultra Technologies */ +#define IFT_DS3 0x1e /* Generic T3 */ +#define IFT_SIP 0x1f /* SMDS */ +#define IFT_FRELAY 0x20 /* Frame Relay DTE only */ +#define IFT_RS232 0x21 +#define IFT_PARA 0x22 /* parallel-port */ +#define IFT_ARCNET 0x23 +#define IFT_ARCNETPLUS 0x24 +#define IFT_ATM 0x25 /* ATM cells */ +#define IFT_MIOX25 0x26 +#define IFT_SONET 0x27 /* SONET or SDH */ +#define IFT_X25PLE 0x28 +#define IFT_ISO88022LLC 0x29 +#define IFT_LOCALTALK 0x2a +#define IFT_SMDSDXI 0x2b +#define IFT_FRELAYDCE 0x2c /* Frame Relay DCE */ +#define IFT_V35 0x2d +#define IFT_HSSI 0x2e +#define IFT_HIPPI 0x2f +#define IFT_MODEM 0x30 /* Generic Modem */ +#define IFT_AAL5 0x31 /* AAL5 over ATM */ +#define IFT_SONETPATH 0x32 +#define IFT_SONETVT 0x33 +#define IFT_SMDSICIP 0x34 /* SMDS InterCarrier Interface */ +#define IFT_PROPVIRTUAL 0x35 /* Proprietary Virtual/internal */ +#define IFT_PROPMUX 0x36 /* Proprietary Multiplexing */ +#define IFT_IB 0xc7 /* Infiniband */ +#define IFT_IPV4 0xc8 /* IPv4 tunnel */ +#define IFT_IPV6 0xc9 /* IPV6 tunnel */ +#define IFT_6TO4 0xca /* 6to4 tunnel */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_IF_TYPES_H */ diff --git a/illumos-x86_64/usr/include/net/pfkeyv2.h b/illumos-x86_64/usr/include/net/pfkeyv2.h new file mode 100644 index 00000000..477cde59 --- /dev/null +++ b/illumos-x86_64/usr/include/net/pfkeyv2.h @@ -0,0 +1,878 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _NET_PFKEYV2_H +#define _NET_PFKEYV2_H + +/* + * Definitions and structures for PF_KEY version 2. See RFC 2367 for + * more details. SA == Security Association, which is what PF_KEY provides + * an API for managing. + * + * Definitions of the form SADB_X_* are local extensions that are not present + * in the IPsec DOI. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define PF_KEY_V2 2 +#define PFKEYV2_REVISION 200109L + +/* + * Base PF_KEY message. + */ + +typedef struct sadb_msg { + uint8_t sadb_msg_version; /* Version, currently PF_KEY_V2 */ + uint8_t sadb_msg_type; /* ADD, UPDATE, etc. */ + uint8_t sadb_msg_errno; /* Error number from UNIX errno space */ + uint8_t sadb_msg_satype; /* ESP, AH, etc. */ + uint16_t sadb_msg_len; /* Length in 64-bit words. */ + uint16_t sadb_msg_reserved; /* must be zero */ +/* + * Use the reserved field for extended diagnostic information on errno + * responses. + */ +#define sadb_x_msg_diagnostic sadb_msg_reserved + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint32_t sadb_x_msg_useq; /* Set by originator */ + uint32_t sadb_x_msg_upid; /* Set by originator */ + } sadb_x_msg_actual; + uint64_t sadb_x_msg_alignment; + } sadb_x_msg_u; +#define sadb_msg_seq sadb_x_msg_u.sadb_x_msg_actual.sadb_x_msg_useq +#define sadb_msg_pid sadb_x_msg_u.sadb_x_msg_actual.sadb_x_msg_upid +} sadb_msg_t; + +/* + * Generic extension header. + */ + +typedef struct sadb_ext { + union { + /* Union is for guaranteeing 64-bit alignment. */ + struct { + uint16_t sadb_x_ext_ulen; /* In 64s, inclusive */ + uint16_t sadb_x_ext_utype; /* 0 is reserved */ + } sadb_x_ext_actual; + uint64_t sadb_x_ext_alignment; + } sadb_x_ext_u; +#define sadb_ext_len sadb_x_ext_u.sadb_x_ext_actual.sadb_x_ext_ulen +#define sadb_ext_type sadb_x_ext_u.sadb_x_ext_actual.sadb_x_ext_utype +} sadb_ext_t; + +/* + * Security Association information extension. + */ + +typedef struct sadb_sa { + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t sadb_x_sa_ulen; + uint16_t sadb_x_sa_uexttype; /* ASSOCIATION */ + uint32_t sadb_x_sa_uspi; /* Sec. Param. Index */ + } sadb_x_sa_uactual; + uint64_t sadb_x_sa_alignment; + } sadb_x_sa_u; +#define sadb_sa_len sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_ulen +#define sadb_sa_exttype sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_uexttype +#define sadb_sa_spi sadb_x_sa_u.sadb_x_sa_uactual.sadb_x_sa_uspi + uint8_t sadb_sa_replay; /* Replay counter */ + uint8_t sadb_sa_state; /* MATURE, DEAD, DYING, LARVAL */ + uint8_t sadb_sa_auth; /* Authentication algorithm */ + uint8_t sadb_sa_encrypt; /* Encryption algorithm */ + uint32_t sadb_sa_flags; /* SA flags. */ +} sadb_sa_t; + +/* + * SA Lifetime extension. Already 64-bit aligned thanks to uint64_t fields. + */ + +typedef struct sadb_lifetime { + uint16_t sadb_lifetime_len; + uint16_t sadb_lifetime_exttype; /* SOFT, HARD, CURRENT */ + uint32_t sadb_lifetime_allocations; + uint64_t sadb_lifetime_bytes; + uint64_t sadb_lifetime_addtime; /* These fields are assumed to hold */ + uint64_t sadb_lifetime_usetime; /* >= sizeof (time_t). */ +} sadb_lifetime_t; + +/* + * SA address information. + */ + +typedef struct sadb_address { + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t sadb_x_address_ulen; + uint16_t sadb_x_address_uexttype; /* SRC, DST, PROXY */ + uint8_t sadb_x_address_uproto; /* Proto for ports... */ + uint8_t sadb_x_address_uprefixlen; /* Prefix length. */ + uint16_t sadb_x_address_ureserved; /* Padding */ + } sadb_x_address_actual; + uint64_t sadb_x_address_alignment; + } sadb_x_address_u; +#define sadb_address_len \ + sadb_x_address_u.sadb_x_address_actual.sadb_x_address_ulen +#define sadb_address_exttype \ + sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uexttype +#define sadb_address_proto \ + sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uproto +#define sadb_address_prefixlen \ + sadb_x_address_u.sadb_x_address_actual.sadb_x_address_uprefixlen +#define sadb_address_reserved \ + sadb_x_address_u.sadb_x_address_actual.sadb_x_address_ureserved + /* Followed by a sockaddr structure which may contain ports. */ +} sadb_address_t; + +/* + * SA key information. + */ + +typedef struct sadb_key { + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t sadb_x_key_ulen; + uint16_t sadb_x_key_uexttype; /* AUTH, ENCRYPT */ + uint16_t sadb_x_key_ubits; /* Actual len (bits) */ + uint16_t sadb_x_key_ureserved; + } sadb_x_key_actual; + uint64_t sadb_x_key_alignment; + } sadb_x_key_u; +#define sadb_key_len sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ulen +#define sadb_key_exttype sadb_x_key_u.sadb_x_key_actual.sadb_x_key_uexttype +#define sadb_key_bits sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ubits +#define sadb_key_reserved sadb_x_key_u.sadb_x_key_actual.sadb_x_key_ureserved + /* Followed by actual key(s) in canonical (outbound proc.) order. */ +} sadb_key_t; + +/* + * SA Identity information. Already 64-bit aligned thanks to uint64_t fields. + */ + +typedef struct sadb_ident { + uint16_t sadb_ident_len; + uint16_t sadb_ident_exttype; /* SRC, DST, PROXY */ + uint16_t sadb_ident_type; /* FQDN, USER_FQDN, etc. */ + uint16_t sadb_ident_reserved; /* Padding */ + uint64_t sadb_ident_id; /* For userid, etc. */ + /* Followed by an identity null-terminate C string if present. */ +} sadb_ident_t; + +/* + * SA sensitivity information. This is mostly useful on MLS systems. + */ + +typedef struct sadb_sens { + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t sadb_x_sens_ulen; + uint16_t sadb_x_sens_uexttype; /* SENSITIVITY */ + uint32_t sadb_x_sens_udpd; /* Protection domain */ + } sadb_x_sens_actual; + uint64_t sadb_x_sens_alignment; + } sadb_x_sens_u; +#define sadb_sens_len sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_ulen +#define sadb_sens_exttype sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_uexttype +#define sadb_sens_dpd sadb_x_sens_u.sadb_x_sens_actual.sadb_x_sens_udpd + uint8_t sadb_sens_sens_level; + uint8_t sadb_sens_sens_len; /* 64-bit words */ + uint8_t sadb_sens_integ_level; + uint8_t sadb_sens_integ_len; /* 64-bit words */ + uint32_t sadb_x_sens_flags; + /* + * followed by two uint64_t arrays + * uint64_t sadb_sens_bitmap[sens_bitmap_len]; + * uint64_t sadb_integ_bitmap[integ_bitmap_len]; + */ +} sadb_sens_t; + +/* + * We recycled the formerly reserved word for flags. + */ + +#define sadb_sens_reserved sadb_x_sens_flags + +#define SADB_X_SENS_IMPLICIT 0x1 /* implicit labelling */ +#define SADB_X_SENS_UNLABELED 0x2 /* peer is unlabeled */ + +/* + * a proposal extension. This is found in an ACQUIRE message, and it + * proposes what sort of SA the kernel would like to ACQUIRE. + */ + +/* First, a base structure... */ + +typedef struct sadb_x_propbase { + uint16_t sadb_x_propb_len; + uint16_t sadb_x_propb_exttype; /* PROPOSAL, X_EPROP */ + union { + struct { + uint8_t sadb_x_propb_lenres_replay; + uint8_t sadb_x_propb_lenres_eres; + uint16_t sadb_x_propb_lenres_numecombs; + } sadb_x_propb_lenres; + struct { + uint8_t sadb_x_propb_oldres_replay; + uint8_t sadb_x_propb_oldres_reserved[3]; + } sadb_x_propb_oldres; + } sadb_x_propb_u; +#define sadb_x_propb_replay \ + sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_replay +#define sadb_x_propb_reserved \ + sadb_x_propb_u.sadb_x_propb_oldres.sadb_x_propb_oldres_reserved +#define sadb_x_propb_ereserved \ + sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_eres +#define sadb_x_propb_numecombs \ + sadb_x_propb_u.sadb_x_propb_lenres.sadb_x_propb_lenres_numecombs + /* Followed by sadb_comb[] array or sadb_ecomb[] array. */ +} sadb_x_propbase_t; + +/* Now, the actual sadb_prop structure, which will have alignment in it! */ + +typedef struct sadb_prop { + /* Union is for guaranteeing 64-bit alignment. */ + union { + sadb_x_propbase_t sadb_x_prop_actual; + uint64_t sadb_x_prop_alignment; + } sadb_x_prop_u; +#define sadb_prop_len sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_len +#define sadb_prop_exttype sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_exttype +#define sadb_prop_replay sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_replay +#define sadb_prop_reserved \ + sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_reserved +#define sadb_x_prop_ereserved \ + sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_ereserved +#define sadb_x_prop_numecombs \ + sadb_x_prop_u.sadb_x_prop_actual.sadb_x_propb_numecombs +} sadb_prop_t; + +/* + * This is a proposed combination. Many of these can follow a proposal + * extension. Already 64-bit aligned thanks to uint64_t fields. + */ + +typedef struct sadb_comb { + uint8_t sadb_comb_auth; /* Authentication algorithm */ + uint8_t sadb_comb_encrypt; /* Encryption algorithm */ + uint16_t sadb_comb_flags; /* Comb. flags (e.g. PFS) */ + uint16_t sadb_comb_auth_minbits; /* Bit strengths for auth */ + uint16_t sadb_comb_auth_maxbits; + uint16_t sadb_comb_encrypt_minbits; /* Bit strengths for encrypt */ + uint16_t sadb_comb_encrypt_maxbits; + uint8_t sadb_x_comb_encrypt_saltbits; + uint8_t sadb_x_comb_reserved; + uint16_t sadb_comb_reserved; + uint32_t sadb_comb_soft_allocations; /* Lifetime proposals for */ + uint32_t sadb_comb_hard_allocations; /* this combination. */ + uint64_t sadb_comb_soft_bytes; + uint64_t sadb_comb_hard_bytes; + uint64_t sadb_comb_soft_addtime; + uint64_t sadb_comb_hard_addtime; + uint64_t sadb_comb_soft_usetime; + uint64_t sadb_comb_hard_usetime; +} sadb_comb_t; + +/* + * An extended combination that can comprise of many SA types. + * A single combination has algorithms and SA types locked. + * These are represented by algorithm descriptors, the second structure + * in the list. For example, if the EACQUIRE requests AH(MD5) + ESP(DES/null) + * _or_ ESP(DES/MD5), it would have two combinations: + * + * COMB: algdes(AH, AUTH, MD5), algdes(ESP, CRYPT, DES) + * COMB: algdes(ESP, AUTH, MD5), algdes(ESP, CRYPT, DES) + * + * If an SA type supports an algorithm type, and there's no descriptor, + * assume it requires NONE, just like it were explicitly stated. + * (This includes ESP NULL encryption, BTW.) + * + * Already 64-bit aligned thanks to uint64_t fields. + */ + +typedef struct sadb_x_ecomb { + uint8_t sadb_x_ecomb_numalgs; + uint8_t sadb_x_ecomb_reserved; + uint16_t sadb_x_ecomb_flags; /* E.g. PFS? */ + uint32_t sadb_x_ecomb_reserved2; + uint32_t sadb_x_ecomb_soft_allocations; + uint32_t sadb_x_ecomb_hard_allocations; + uint64_t sadb_x_ecomb_soft_bytes; + uint64_t sadb_x_ecomb_hard_bytes; + uint64_t sadb_x_ecomb_soft_addtime; + uint64_t sadb_x_ecomb_hard_addtime; + uint64_t sadb_x_ecomb_soft_usetime; + uint64_t sadb_x_ecomb_hard_usetime; +} sadb_x_ecomb_t; + +typedef struct sadb_x_algdesc { + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint8_t sadb_x_algdesc_usatype; /* ESP, AH, etc. */ + uint8_t sadb_x_algdesc_ualgtype; /* AUTH, CRYPT, COMP */ + uint8_t sadb_x_algdesc_ualg; /* 3DES, MD5, etc. */ + uint8_t sadb_x_algdesc_usaltbits; + uint16_t sadb_x_algdesc_uminbits; /* Bit strengths. */ + uint16_t sadb_x_algdesc_umaxbits; + } sadb_x_algdesc_actual; + uint64_t sadb_x_algdesc_alignment; + } sadb_x_algdesc_u; +#define sadb_x_algdesc_satype \ + sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_usatype +#define sadb_x_algdesc_algtype \ + sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_ualgtype +#define sadb_x_algdesc_alg \ + sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_ualg +#define sadb_x_algdesc_saltbits \ + sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_usaltbits +#define sadb_x_algdesc_minbits \ + sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_uminbits +#define sadb_x_algdesc_maxbits \ + sadb_x_algdesc_u.sadb_x_algdesc_actual.sadb_x_algdesc_umaxbits +} sadb_x_algdesc_t; + +/* + * When key mgmt. registers with the kernel, the kernel will tell key mgmt. + * its supported algorithms. + */ + +typedef struct sadb_supported { + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t sadb_x_supported_ulen; + uint16_t sadb_x_supported_uexttype; + uint32_t sadb_x_supported_ureserved; + } sadb_x_supported_actual; + uint64_t sadb_x_supported_alignment; + } sadb_x_supported_u; +#define sadb_supported_len \ + sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_ulen +#define sadb_supported_exttype \ + sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_uexttype +#define sadb_supported_reserved \ + sadb_x_supported_u.sadb_x_supported_actual.sadb_x_supported_ureserved +} sadb_supported_t; + +/* First, a base structure... */ +typedef struct sadb_x_algb { + uint8_t sadb_x_algb_id; /* Algorithm type. */ + uint8_t sadb_x_algb_ivlen; /* IV len, in bits */ + uint16_t sadb_x_algb_minbits; /* Min. key len (in bits) */ + uint16_t sadb_x_algb_maxbits; /* Max. key length */ + union { + uint16_t sadb_x_algb_ureserved; + uint8_t sadb_x_algb_udefaults[2]; + } sadb_x_algb_union; + +#define sadb_x_algb_reserved sadb_x_algb_union.sadb_x_algb_ureserved +#define sadb_x_algb_increment sadb_x_algb_union.sadb_x_algb_udefaults[0] +#define sadb_x_algb_saltbits sadb_x_algb_union.sadb_x_algb_udefaults[1] +/* + * alg_increment: the number of bits from a key length to the next + */ +} sadb_x_algb_t; + +/* Now, the actual sadb_alg structure, which will have alignment in it. */ +typedef struct sadb_alg { + /* Union is for guaranteeing 64-bit alignment. */ + union { + sadb_x_algb_t sadb_x_alg_actual; + uint64_t sadb_x_alg_alignment; + } sadb_x_alg_u; +#define sadb_alg_id sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_id +#define sadb_alg_ivlen sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_ivlen +#define sadb_alg_minbits sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_minbits +#define sadb_alg_maxbits sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_maxbits +#define sadb_alg_reserved sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_reserved +#define sadb_x_alg_increment \ + sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_increment +#define sadb_x_alg_saltbits sadb_x_alg_u.sadb_x_alg_actual.sadb_x_algb_saltbits +} sadb_alg_t; + +/* + * If key mgmt. needs an SPI in a range (including 0 to 0xFFFFFFFF), it + * asks the kernel with this extension in the SADB_GETSPI message. + */ + +typedef struct sadb_spirange { + uint16_t sadb_spirange_len; + uint16_t sadb_spirange_exttype; /* SPI_RANGE */ + uint32_t sadb_spirange_min; + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint32_t sadb_x_spirange_umax; + uint32_t sadb_x_spirange_ureserved; + } sadb_x_spirange_actual; + uint64_t sadb_x_spirange_alignment; + } sadb_x_spirange_u; +#define sadb_spirange_max \ + sadb_x_spirange_u.sadb_x_spirange_actual.sadb_x_spirange_umax +#define sadb_spirange_reserved \ + sadb_x_spirange_u.sadb_x_spirange_actual.sadb_x_spirange_ureserved +} sadb_spirange_t; + +/* + * For the "extended REGISTER" which'll tell the kernel to send me + * "extended ACQUIREs". + */ + +typedef struct sadb_x_ereg { + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t sadb_x_ereg_ulen; + uint16_t sadb_x_ereg_uexttype; /* X_EREG */ + /* Array of SA types, 0-terminated. */ + uint8_t sadb_x_ereg_usatypes[4]; + } sadb_x_ereg_actual; + uint64_t sadb_x_ereg_alignment; + } sadb_x_ereg_u; +#define sadb_x_ereg_len \ + sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_ulen +#define sadb_x_ereg_exttype \ + sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_uexttype +#define sadb_x_ereg_satypes \ + sadb_x_ereg_u.sadb_x_ereg_actual.sadb_x_ereg_usatypes +} sadb_x_ereg_t; + +/* + * For conveying a Key Management Cookie with SADB_GETSPI, SADB_ADD, + * SADB_ACQUIRE, or SADB_X_INVERSE_ACQUIRE. + */ + +typedef struct sadb_x_kmc { + uint16_t sadb_x_kmc_len; + uint16_t sadb_x_kmc_exttype; /* X_KM_COOKIE */ + uint32_t sadb_x_kmc_proto; /* KM protocol */ + union { + struct { + uint32_t sadb_x_kmc_ucookie; /* KMP-specific */ + uint32_t sadb_x_kmc_ureserved; /* Must be zero */ + } sadb_x_kmc_actual; + uint64_t sadb_x_kmc_ucookie64; + } sadb_x_kmc_u; +#define sadb_x_kmc_cookie sadb_x_kmc_u.sadb_x_kmc_actual.sadb_x_kmc_ucookie +#define sadb_x_kmc_reserved sadb_x_kmc_u.sadb_x_kmc_actual.sadb_x_kmc_ureserved +#define sadb_x_kmc_cookie64 sadb_x_kmc_u.sadb_x_kmc_ucookie64 +} sadb_x_kmc_t; + +typedef struct sadb_x_pair { + union { + /* Union is for guaranteeing 64-bit alignment. */ + struct { + uint16_t sadb_x_pair_ulen; + uint16_t sadb_x_pair_uexttype; + uint32_t sadb_x_pair_uspi; /* SPI of paired SA */ + } sadb_x_pair_actual; + uint64_t sadb_x_ext_alignment; + } sadb_x_pair_u; +#define sadb_x_pair_len sadb_x_pair_u.sadb_x_pair_actual.sadb_x_pair_ulen +#define sadb_x_pair_exttype \ + sadb_x_pair_u.sadb_x_pair_actual.sadb_x_pair_uexttype +#define sadb_x_pair_spi sadb_x_pair_u.sadb_x_pair_actual.sadb_x_pair_uspi +} sadb_x_pair_t; + +/* + * For the Sequence numbers to be used with SADB_DUMP, SADB_GET, SADB_UPDATE. + */ + +typedef struct sadb_x_replay_ctr { + uint16_t sadb_x_rc_len; + uint16_t sadb_x_rc_exttype; + uint32_t sadb_x_rc_replay32; /* For 240x SAs. */ + uint64_t sadb_x_rc_replay64; /* For 430x SAs. */ +} sadb_x_replay_ctr_t; + +/* + * For extended DUMP request. Dumps the SAs which were idle for + * longer than the timeout specified. + */ + +typedef struct sadb_x_edump { + uint16_t sadb_x_edump_len; + uint16_t sadb_x_edump_exttype; + uint32_t sadb_x_edump_reserved; + uint64_t sadb_x_edump_timeout; +} sadb_x_edump_t; + +/* + * Base message types. + */ + +#define SADB_RESERVED 0 +#define SADB_GETSPI 1 +#define SADB_UPDATE 2 +#define SADB_ADD 3 +#define SADB_DELETE 4 +#define SADB_GET 5 +#define SADB_ACQUIRE 6 +#define SADB_REGISTER 7 +#define SADB_EXPIRE 8 +#define SADB_FLUSH 9 +#define SADB_DUMP 10 /* not used normally */ +#define SADB_X_PROMISC 11 +#define SADB_X_INVERSE_ACQUIRE 12 +#define SADB_X_UPDATEPAIR 13 +#define SADB_X_DELPAIR 14 +#define SADB_X_DELPAIR_STATE 15 +#define SADB_MAX 15 + +/* + * SA flags + */ + +#define SADB_SAFLAGS_PFS 0x1 /* Perfect forward secrecy? */ +#define SADB_SAFLAGS_NOREPLAY 0x2 /* Replay field NOT PRESENT. */ + +/* Below flags are used by this implementation. Grow from left-to-right. */ +#define SADB_X_SAFLAGS_USED 0x80000000 /* SA used/not used */ +#define SADB_X_SAFLAGS_UNIQUE 0x40000000 /* SA unique/reusable */ +#define SADB_X_SAFLAGS_AALG1 0x20000000 /* Auth-alg specific flag 1 */ +#define SADB_X_SAFLAGS_AALG2 0x10000000 /* Auth-alg specific flag 2 */ +#define SADB_X_SAFLAGS_EALG1 0x8000000 /* Encr-alg specific flag 1 */ +#define SADB_X_SAFLAGS_EALG2 0x4000000 /* Encr-alg specific flag 2 */ +#define SADB_X_SAFLAGS_KM1 0x2000000 /* Key mgmt. specific flag 1 */ +#define SADB_X_SAFLAGS_KM2 0x1000000 /* Key mgmt. specific flag 2 */ +#define SADB_X_SAFLAGS_KM3 0x800000 /* Key mgmt. specific flag 3 */ +#define SADB_X_SAFLAGS_KM4 0x400000 /* Key mgmt. specific flag 4 */ +#define SADB_X_SAFLAGS_KRES1 0x200000 /* Reserved by the kernel */ +#define SADB_X_SAFLAGS_NATT_LOC 0x100000 /* this has a natted src SA */ +#define SADB_X_SAFLAGS_NATT_REM 0x80000 /* this has a natted dst SA */ +#define SADB_X_SAFLAGS_KRES2 0x40000 /* Reserved by the kernel */ +#define SADB_X_SAFLAGS_TUNNEL 0x20000 /* tunnel mode */ +#define SADB_X_SAFLAGS_PAIRED 0x10000 /* inbound/outbound pair */ +#define SADB_X_SAFLAGS_OUTBOUND 0x8000 /* SA direction bit */ +#define SADB_X_SAFLAGS_INBOUND 0x4000 /* SA direction bit */ +#define SADB_X_SAFLAGS_TCPSIG 0x2000 /* SA is for a TCP signature */ +#define SADB_X_SAFLAGS_NATTED 0x1000 /* Local node is behind a NAT */ + +#define SADB_X_SAFLAGS_KRES \ + SADB_X_SAFLAGS_KRES1 | SADB_X_SAFLAGS_KRES2 + +/* + * SA state. + */ + +#define SADB_SASTATE_LARVAL 0 +#define SADB_SASTATE_MATURE 1 +#define SADB_SASTATE_DYING 2 +#define SADB_SASTATE_DEAD 3 +#define SADB_X_SASTATE_ACTIVE_ELSEWHERE 4 +#define SADB_X_SASTATE_IDLE 5 +#define SADB_X_SASTATE_ACTIVE 6 + +#define SADB_SASTATE_MAX 6 + +/* + * SA type. Gaps are present in the number space because (for the time being) + * these types correspond to the SA types in the IPsec DOI document. + */ + +#define SADB_SATYPE_UNSPEC 0 +#define SADB_SATYPE_AH 2 /* RFC-1826 */ +#define SADB_SATYPE_ESP 3 /* RFC-1827 */ +#define SADB_X_SATYPE_TCPSIG 4 /* RFC-2385 */ +#define SADB_SATYPE_RSVP 5 /* RSVP Authentication */ +#define SADB_SATYPE_OSPFV2 6 /* OSPFv2 Authentication */ +#define SADB_SATYPE_RIPV2 7 /* RIPv2 Authentication */ +#define SADB_SATYPE_MIP 8 /* Mobile IPv4 Authentication */ + +#define SADB_SATYPE_MAX 8 + +#define TCPSIG_MD5_KEY_LEN 80 + +/* + * Algorithm types. Gaps are present because (for the time being) these types + * correspond to the SA types in the IPsec DOI document. + * + * NOTE: These are numbered to play nice with the IPsec DOI. That's why + * there are gaps. + */ + +/* Authentication algorithms */ +#define SADB_AALG_NONE 0 +#define SADB_AALG_MD5 1 +#define SADB_AALG_MD5HMAC 2 +#define SADB_AALG_SHA1HMAC 3 +#define SADB_AALG_SHA256HMAC 5 +#define SADB_AALG_SHA384HMAC 6 +#define SADB_AALG_SHA512HMAC 7 + +#define SADB_AALG_MAX 7 + +/* Encryption algorithms */ +#define SADB_EALG_NONE 0 +#define SADB_EALG_DESCBC 2 +#define SADB_EALG_3DESCBC 3 +#define SADB_EALG_BLOWFISH 7 +#define SADB_EALG_NULL 11 +#define SADB_EALG_AES 12 +#define SADB_EALG_AES_CCM_8 14 +#define SADB_EALG_AES_CCM_12 15 +#define SADB_EALG_AES_CCM_16 16 +#define SADB_EALG_AES_GCM_8 18 +#define SADB_EALG_AES_GCM_12 19 +#define SADB_EALG_AES_GCM_16 20 +#define SADB_EALG_MAX 20 + +/* + * Extension header values. + */ + +#define SADB_EXT_RESERVED 0 + +#define SADB_EXT_SA 1 +#define SADB_EXT_LIFETIME_CURRENT 2 +#define SADB_EXT_LIFETIME_HARD 3 +#define SADB_EXT_LIFETIME_SOFT 4 +#define SADB_EXT_ADDRESS_SRC 5 +#define SADB_EXT_ADDRESS_DST 6 +/* These two are synonyms. */ +#define SADB_EXT_ADDRESS_PROXY 7 +#define SADB_X_EXT_ADDRESS_INNER_SRC SADB_EXT_ADDRESS_PROXY +#define SADB_EXT_KEY_AUTH 8 +#define SADB_EXT_KEY_ENCRYPT 9 +#define SADB_EXT_IDENTITY_SRC 10 +#define SADB_EXT_IDENTITY_DST 11 +#define SADB_EXT_SENSITIVITY 12 +#define SADB_EXT_PROPOSAL 13 +#define SADB_EXT_SUPPORTED_AUTH 14 +#define SADB_EXT_SUPPORTED_ENCRYPT 15 +#define SADB_EXT_SPIRANGE 16 +#define SADB_X_EXT_EREG 17 +#define SADB_X_EXT_EPROP 18 +#define SADB_X_EXT_KM_COOKIE 19 +#define SADB_X_EXT_ADDRESS_NATT_LOC 20 +#define SADB_X_EXT_ADDRESS_NATT_REM 21 +#define SADB_X_EXT_ADDRESS_INNER_DST 22 +#define SADB_X_EXT_PAIR 23 +#define SADB_X_EXT_REPLAY_VALUE 24 +#define SADB_X_EXT_EDUMP 25 +#define SADB_X_EXT_LIFETIME_IDLE 26 +#define SADB_X_EXT_OUTER_SENS 27 +#define SADB_X_EXT_STR_AUTH 28 + +#define SADB_EXT_MAX 28 + +/* + * Identity types. + */ + +#define SADB_IDENTTYPE_RESERVED 0 + +/* + * For PREFIX and ADDR_RANGE, use the AF of the PROXY if present, or the SRC + * if not present. + */ +#define SADB_IDENTTYPE_PREFIX 1 +#define SADB_IDENTTYPE_FQDN 2 /* Fully qualified domain name. */ +#define SADB_IDENTTYPE_USER_FQDN 3 /* e.g. root@domain.com */ +#define SADB_X_IDENTTYPE_DN 4 /* ASN.1 DER Distinguished Name. */ +#define SADB_X_IDENTTYPE_GN 5 /* ASN.1 DER Generic Name. */ +#define SADB_X_IDENTTYPE_KEY_ID 6 /* Generic KEY ID. */ +#define SADB_X_IDENTTYPE_ADDR_RANGE 7 + +#define SADB_IDENTTYPE_MAX 7 + +/* + * Protection DOI values for the SENSITIVITY extension. There are no values + * currently, so the MAX is the only non-zero value available. + */ + +#define SADB_DPD_NONE 0 + +#define SADB_DPD_MAX 1 + +/* + * Diagnostic codes. These supplement error messages. Be sure to + * update libipsecutil's keysock_diag() if you change any of these. + */ + +#define SADB_X_DIAGNOSTIC_PRESET -1 /* Internal value. */ + +#define SADB_X_DIAGNOSTIC_NONE 0 + +#define SADB_X_DIAGNOSTIC_UNKNOWN_MSG 1 +#define SADB_X_DIAGNOSTIC_UNKNOWN_EXT 2 +#define SADB_X_DIAGNOSTIC_BAD_EXTLEN 3 +#define SADB_X_DIAGNOSTIC_UNKNOWN_SATYPE 4 +#define SADB_X_DIAGNOSTIC_SATYPE_NEEDED 5 +#define SADB_X_DIAGNOSTIC_NO_SADBS 6 +#define SADB_X_DIAGNOSTIC_NO_EXT 7 +/* Bad address family value */ +#define SADB_X_DIAGNOSTIC_BAD_SRC_AF 8 +/* in sockaddr->sa_family. */ +#define SADB_X_DIAGNOSTIC_BAD_DST_AF 9 +/* These two are synonyms. */ +#define SADB_X_DIAGNOSTIC_BAD_PROXY_AF 10 +#define SADB_X_DIAGNOSTIC_BAD_INNER_SRC_AF 10 + +#define SADB_X_DIAGNOSTIC_AF_MISMATCH 11 + +#define SADB_X_DIAGNOSTIC_BAD_SRC 12 +#define SADB_X_DIAGNOSTIC_BAD_DST 13 + +#define SADB_X_DIAGNOSTIC_ALLOC_HSERR 14 +#define SADB_X_DIAGNOSTIC_BYTES_HSERR 15 +#define SADB_X_DIAGNOSTIC_ADDTIME_HSERR 16 +#define SADB_X_DIAGNOSTIC_USETIME_HSERR 17 + +#define SADB_X_DIAGNOSTIC_MISSING_SRC 18 +#define SADB_X_DIAGNOSTIC_MISSING_DST 19 +#define SADB_X_DIAGNOSTIC_MISSING_SA 20 +#define SADB_X_DIAGNOSTIC_MISSING_EKEY 21 +#define SADB_X_DIAGNOSTIC_MISSING_AKEY 22 +#define SADB_X_DIAGNOSTIC_MISSING_RANGE 23 + +#define SADB_X_DIAGNOSTIC_DUPLICATE_SRC 24 +#define SADB_X_DIAGNOSTIC_DUPLICATE_DST 25 +#define SADB_X_DIAGNOSTIC_DUPLICATE_SA 26 +#define SADB_X_DIAGNOSTIC_DUPLICATE_EKEY 27 +#define SADB_X_DIAGNOSTIC_DUPLICATE_AKEY 28 +#define SADB_X_DIAGNOSTIC_DUPLICATE_RANGE 29 + +#define SADB_X_DIAGNOSTIC_MALFORMED_SRC 30 +#define SADB_X_DIAGNOSTIC_MALFORMED_DST 31 +#define SADB_X_DIAGNOSTIC_MALFORMED_SA 32 +#define SADB_X_DIAGNOSTIC_MALFORMED_EKEY 33 +#define SADB_X_DIAGNOSTIC_MALFORMED_AKEY 34 +#define SADB_X_DIAGNOSTIC_MALFORMED_RANGE 35 + +#define SADB_X_DIAGNOSTIC_AKEY_PRESENT 36 +#define SADB_X_DIAGNOSTIC_EKEY_PRESENT 37 +#define SADB_X_DIAGNOSTIC_PROP_PRESENT 38 +#define SADB_X_DIAGNOSTIC_SUPP_PRESENT 39 + +#define SADB_X_DIAGNOSTIC_BAD_AALG 40 +#define SADB_X_DIAGNOSTIC_BAD_EALG 41 +#define SADB_X_DIAGNOSTIC_BAD_SAFLAGS 42 +#define SADB_X_DIAGNOSTIC_BAD_SASTATE 43 + +#define SADB_X_DIAGNOSTIC_BAD_AKEYBITS 44 +#define SADB_X_DIAGNOSTIC_BAD_EKEYBITS 45 + +#define SADB_X_DIAGNOSTIC_ENCR_NOTSUPP 46 + +#define SADB_X_DIAGNOSTIC_WEAK_EKEY 47 +#define SADB_X_DIAGNOSTIC_WEAK_AKEY 48 + +#define SADB_X_DIAGNOSTIC_DUPLICATE_KMP 49 +#define SADB_X_DIAGNOSTIC_DUPLICATE_KMC 50 + +#define SADB_X_DIAGNOSTIC_MISSING_NATT_LOC 51 +#define SADB_X_DIAGNOSTIC_MISSING_NATT_REM 52 +#define SADB_X_DIAGNOSTIC_DUPLICATE_NATT_LOC 53 +#define SADB_X_DIAGNOSTIC_DUPLICATE_NATT_REM 54 +#define SADB_X_DIAGNOSTIC_MALFORMED_NATT_LOC 55 +#define SADB_X_DIAGNOSTIC_MALFORMED_NATT_REM 56 +#define SADB_X_DIAGNOSTIC_DUPLICATE_NATT_PORTS 57 + +#define SADB_X_DIAGNOSTIC_MISSING_INNER_SRC 58 +#define SADB_X_DIAGNOSTIC_MISSING_INNER_DST 59 +#define SADB_X_DIAGNOSTIC_DUPLICATE_INNER_SRC 60 +#define SADB_X_DIAGNOSTIC_DUPLICATE_INNER_DST 61 +#define SADB_X_DIAGNOSTIC_MALFORMED_INNER_SRC 62 +#define SADB_X_DIAGNOSTIC_MALFORMED_INNER_DST 63 + +#define SADB_X_DIAGNOSTIC_PREFIX_INNER_SRC 64 +#define SADB_X_DIAGNOSTIC_PREFIX_INNER_DST 65 +#define SADB_X_DIAGNOSTIC_BAD_INNER_DST_AF 66 +#define SADB_X_DIAGNOSTIC_INNER_AF_MISMATCH 67 + +#define SADB_X_DIAGNOSTIC_BAD_NATT_REM_AF 68 +#define SADB_X_DIAGNOSTIC_BAD_NATT_LOC_AF 69 + +#define SADB_X_DIAGNOSTIC_PROTO_MISMATCH 70 +#define SADB_X_DIAGNOSTIC_INNER_PROTO_MISMATCH 71 + +#define SADB_X_DIAGNOSTIC_DUAL_PORT_SETS 72 + +#define SADB_X_DIAGNOSTIC_PAIR_INAPPROPRIATE 73 +#define SADB_X_DIAGNOSTIC_PAIR_ADD_MISMATCH 74 +#define SADB_X_DIAGNOSTIC_PAIR_ALREADY 75 +#define SADB_X_DIAGNOSTIC_PAIR_SA_NOTFOUND 76 +#define SADB_X_DIAGNOSTIC_BAD_SA_DIRECTION 77 + +#define SADB_X_DIAGNOSTIC_SA_NOTFOUND 78 +#define SADB_X_DIAGNOSTIC_SA_EXPIRED 79 +#define SADB_X_DIAGNOSTIC_BAD_CTX 80 +#define SADB_X_DIAGNOSTIC_INVALID_REPLAY 81 +#define SADB_X_DIAGNOSTIC_MISSING_LIFETIME 82 + +#define SADB_X_DIAGNOSTIC_BAD_LABEL 83 + +#define SADB_X_DIAGNOSTIC_MISSING_ASTR 84 +#define SADB_X_DIAGNOSTIC_DUPLICATE_ASTR 85 +#define SADB_X_DIAGNOSTIC_MALFORMED_ASTR 86 + +#define SADB_X_DIAGNOSTIC_MAX 86 + +/* Algorithm type for sadb_x_algdesc above... */ + +#define SADB_X_ALGTYPE_NONE 0 +#define SADB_X_ALGTYPE_AUTH 1 +#define SADB_X_ALGTYPE_CRYPT 2 +#define SADB_X_ALGTYPE_COMPRESS 3 + +#define SADB_X_ALGTYPE_MAX 3 + +/* Key management protocol for sadb_x_kmc above... */ + +#define SADB_X_KMP_MANUAL 0 /* Cookie is ignored. */ +#define SADB_X_KMP_IKE 1 +#define SADB_X_KMP_KINK 2 +#define SADB_X_KMP_IKEV2 3 + +#define SADB_X_KMP_MAX SADB_X_KMP_IKEV2 + +/* + * Handy conversion macros. Not part of the PF_KEY spec... + */ + +#define SADB_64TO8(x) ((x) << 3) +#define SADB_8TO64(x) ((x) >> 3) +#define SADB_8TO1(x) ((x) << 3) +#define SADB_1TO8(x) ((x) >> 3) + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_PFKEYV2_H */ diff --git a/illumos-x86_64/usr/include/net/pfpolicy.h b/illumos-x86_64/usr/include/net/pfpolicy.h new file mode 100644 index 00000000..7da8256a --- /dev/null +++ b/illumos-x86_64/usr/include/net/pfpolicy.h @@ -0,0 +1,540 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NET_PFPOLICY_H +#define _NET_PFPOLICY_H + +/* + * Definitions and structures for PF_POLICY version 1. + * + * This local protocol provides an interface allowing utilities to + * manage a system's IPsec System Policy Database; see RFC2401 for a + * conceptual overview of the SPD. + * The basic encoding is modelled on PF_KEY version 2; see pfkeyv2.h + * and RFC2367 for more information. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define PF_POLICY_V1 1 +#define PF_POLICY_REVISION 200304L + +/* + * Base PF_POLICY message header. Each request/response starts with + * one of these, followed by some number of extensions. Each + * extension type appears at most once in a message. spd_msg_len + * contains the total length of the message including header. + */ +typedef struct spd_msg +{ + uint8_t spd_msg_version; /* PF_POLICY_V1 */ + uint8_t spd_msg_type; /* ADD, DELETE, QUERY, ... */ + uint8_t spd_msg_errno; /* Unix errno space; mbz on request */ + uint8_t spd_msg_spdid; /* which policy db instance */ + uint16_t spd_msg_len; /* in 64-bit words */ + uint16_t spd_msg_diagnostic; /* additional error reason */ + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint32_t spd_msg_useq; /* set by sender */ + uint32_t spd_msg_upid; /* set by sender */ + } spd_msg_actual; + uint64_t spd_msg_alignment; + } spd_msg_u; +#define spd_msg_seq spd_msg_u.spd_msg_actual.spd_msg_useq +#define spd_msg_pid spd_msg_u.spd_msg_actual.spd_msg_upid +} spd_msg_t; + +/* + * Command numbers, found in spd_msg_type. + */ +#define SPD_RESERVED 0 +#define SPD_MIN 1 +#define SPD_FLUSH 1 +#define SPD_ADDRULE 2 +#define SPD_DELETERULE 3 +#define SPD_FLIP 4 +#define SPD_LOOKUP 5 +#define SPD_DUMP 6 +#define SPD_CLONE 7 +#define SPD_ALGLIST 8 +#define SPD_DUMPALGS 9 +#define SPD_UPDATEALGS 10 +#define SPD_MAX 10 + +/* + * Well-known policy db instances, found in spd_msg_spdid + */ +#define SPD_ACTIVE 0 /* The currently active instance */ +#define SPD_STANDBY 1 /* "on deck" standby SPD */ + +/* + * The spd_msg_t is followed by extensions, which start with the + * following header; each extension structure includes the length and + * type fields internally as an overlay to simplify parsing and + * construction. + */ +typedef struct spd_ext +{ + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t spd_ext_ulen; /* in 64-bit words */ + uint16_t spd_ext_utype; /* 0 is reserved */ + } spd_ext_actual; + uint64_t spd_ext_alignment; + } spd_ext_u; +#define spd_ext_len spd_ext_u.spd_ext_actual.spd_ext_ulen +#define spd_ext_type spd_ext_u.spd_ext_actual.spd_ext_utype +} spd_ext_t; + +/* + * Extension numbers, found in spd_ext_type. + */ + +#define SPD_EXT_LCLPORT 1 +#define SPD_EXT_REMPORT 2 +#define SPD_EXT_PROTO 3 +#define SPD_EXT_LCLADDR 4 +#define SPD_EXT_REMADDR 5 + +#define SPD_EXT_ACTION 6 +#define SPD_EXT_RULE 7 +#define SPD_EXT_RULESET 8 +#define SPD_EXT_ICMP_TYPECODE 9 + +#define SPD_EXT_TUN_NAME 10 + +#define SPD_EXT_MAX 10 + +/* + * base policy rule (attributes which every rule has) + * + * spd_rule_index MBZ on a SPD_ADD, and is assigned by the kernel. + * subsequent deletes can operate either by specifying selectors or by + * specifying a non-zero rule index. + */ +struct spd_rule +{ + uint16_t spd_rule_len; + uint16_t spd_rule_type; /* SPD_EXT_RULE */ + uint32_t spd_rule_priority; + uint32_t spd_rule_flags; /* INBOUND, OUTBOUND, ... */ + uint32_t spd_rule_unused; + uint64_t spd_rule_index; /* unique rule identifier. */ +}; + +/* + * Flags for spd_rule.spd_rule_flags + */ +#define SPD_RULE_FLAG_INBOUND 0x0001 +#define SPD_RULE_FLAG_OUTBOUND 0x0002 +/* Only applies to tunnel policy heads. */ +#define SPD_RULE_FLAG_TUNNEL 0x0004 + +/* + * Address selectors. Different from PF_KEY because we want a + * more precise format for wildcards on ports/protocol. + */ +typedef struct spd_address { + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t spd_address_ulen; + uint16_t spd_address_uexttype; /* SRC, DST */ + uint8_t spd_address_uaf; /* address family. */ + uint8_t spd_address_uprefixlen; /* Prefix len (bits). */ + uint16_t spd_address_ureserved2; /* Padding */ + } spd_address_actual; + uint64_t spd_address_alignment; + } spd_address_u; + /* + * .. followed by 4 bytes of IPv4 or 16 bytes of IPv6 address, + * padded up to next uint64_t + */ +#define spd_address_len \ + spd_address_u.spd_address_actual.spd_address_ulen +#define spd_address_exttype \ + spd_address_u.spd_address_actual.spd_address_uexttype +#define spd_address_af \ + spd_address_u.spd_address_actual.spd_address_uaf +#define spd_address_prefixlen \ + spd_address_u.spd_address_actual.spd_address_uprefixlen +#define spd_address_reserved2 \ + spd_address_u.spd_address_actual.spd_address_ureserved2 +} spd_address_t; + +/* + * Protocol selector + */ +struct spd_proto +{ + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t spd_proto_ulen; + uint16_t spd_proto_uexttype; /* PROTO */ + uint8_t spd_proto_unumber; /* IPPROTO_* */ + uint8_t spd_proto_ureserved1; /* pad */ + uint16_t spd_proto_ureserved2; /* pad */ + } spd_proto_actual; + uint64_t spd_proto_alignment; + } spd_proto_u; +#define spd_proto_len spd_proto_u.spd_proto_actual.spd_proto_ulen +#define spd_proto_exttype spd_proto_u.spd_proto_actual.spd_proto_uexttype +#define spd_proto_number spd_proto_u.spd_proto_actual.spd_proto_unumber +#define spd_proto_reserved1 spd_proto_u.spd_proto_actual.spd_proto_ureserved1 +#define spd_proto_reserved2 spd_proto_u.spd_proto_actual.spd_proto_ureserved2 +}; + +/* + * Port selector. We only support minport==maxport at present. + */ +struct spd_portrange +{ + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t spd_ports_ulen; + uint16_t spd_ports_uexttype; /* LCLPORT, REMPORT */ + uint16_t spd_ports_uminport; /* min port */ + uint16_t spd_ports_umaxport; /* max port */ + } spd_ports_actual; + uint64_t spd_ports_alignment; + } spd_ports_u; +#define spd_ports_len spd_ports_u.spd_ports_actual.spd_ports_ulen +#define spd_ports_exttype spd_ports_u.spd_ports_actual.spd_ports_uexttype +#define spd_ports_minport spd_ports_u.spd_ports_actual.spd_ports_uminport +#define spd_ports_maxport spd_ports_u.spd_ports_actual.spd_ports_umaxport +}; + +/* + * ICMP type selector. + */ +struct spd_typecode +{ + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t spd_typecode_ulen; + uint16_t spd_typecode_uexttype; /* ICMP_TYPECODE */ + uint8_t spd_typecode_utype; + uint8_t spd_typecode_utype_end; + uint8_t spd_typecode_ucode; + uint8_t spd_typecode_ucode_end; + } spd_typecode_actual; + uint64_t spd_typecode_alignment; + } spd_typecode_u; +#define spd_typecode_len \ + spd_typecode_u.spd_typecode_actual.spd_typecode_ulen +#define spd_typecode_exttype \ + spd_typecode_u.spd_typecode_actual.spd_typecode_uexttype +#define spd_typecode_type \ + spd_typecode_u.spd_typecode_actual.spd_typecode_utype +#define spd_typecode_type_end \ + spd_typecode_u.spd_typecode_actual.spd_typecode_utype_end +#define spd_typecode_code \ + spd_typecode_u.spd_typecode_actual.spd_typecode_ucode +#define spd_typecode_code_end \ + spd_typecode_u.spd_typecode_actual.spd_typecode_ucode_end +}; + + +/* + * Actions, specifying what happens to packets which match selectors. + * This extension is followed by some number of spd_attribute tag-value pairs + * which encode one or more alternative policies; see below for + * the encoding used. + */ +struct spd_ext_actions +{ + /* Union is for guaranteeing 64-bit alignment. */ + union { + struct { + uint16_t spd_actions_ulen; + uint16_t spd_actions_uexttype; /* ACTION */ + uint16_t spd_actions_ucount; /* # of alternatives */ + uint16_t spd_actions_ureserved; + } spd_actions_actual; + uint64_t spd_actions_alignment; + } spd_actions_u; +#define spd_actions_len \ + spd_actions_u.spd_actions_actual.spd_actions_ulen +#define spd_actions_exttype \ + spd_actions_u.spd_actions_actual.spd_actions_uexttype +#define spd_actions_count \ + spd_actions_u.spd_actions_actual.spd_actions_ucount +#define spd_actions_reserved \ + spd_actions_u.spd_actions_actual.spd_actions_ureserved +}; + +/* + * Extensible encoding for requested SA attributes. + * To allow additional attributes to be added, we use a simple-to-interpret + * (tag, value) encoding to fill in attributes in a list of alternatives. + * + * We fill in alternatives one at a time, starting with most-preferred, + * proceeding to least-preferred. + * + * Conceptually, we are filling in attributes of a "template", and + * then copying that template value into the list of alternatives when + * we see a SPD_ATTR_END or SPD_ATTR_NEXT. + * + * The template is not changed by SPD_ATTR_NEXT, so that attributes common to + * all alternatives need only be mentioned once. + * + * spd_actions_count is the maximum number of alternatives present; it + * should be one greater than the number of SPD_ATTR_NEXT opcodes + * present in the sequence. + */ + +struct spd_attribute +{ + union { + struct { + uint32_t spd_attr_utag; + uint32_t spd_attr_uvalue; + } spd_attribute_actual; + uint64_t spd_attribute_alignment; + } spd_attribute_u; +#define spd_attr_tag spd_attribute_u.spd_attribute_actual.spd_attr_utag +#define spd_attr_value spd_attribute_u.spd_attribute_actual.spd_attr_uvalue +}; + +/* + * These flags are used by the kernel algorithm structures and by ipsecalgs(8). + * ALG_FLAG_KERNELCHECKED is used by ipsecalgs(8) to tag ipsecalgent_t as + * kernel verified. ALG_FLAG_VALID is only meaningful if set by the kernel. + */ +#define ALG_FLAG_VALID 0x01 +#define ALG_FLAG_COUNTERMODE 0x02 +#define ALG_FLAG_COMBINED 0x04 +#define ALG_FLAG_CCM 0x08 +#define ALG_FLAG_GCM 0x10 +#define ALG_FLAG_KERNELCHECKED 0x80000000 + +#define SPD_ATTR_NOP 0x00000000 /* space filler */ +#define SPD_ATTR_END 0x00000001 /* end of description */ +#define SPD_ATTR_EMPTY 0x00000002 /* reset template to default */ +#define SPD_ATTR_NEXT 0x00000003 /* start filling next alternative */ + +#define SPD_ATTR_TYPE 0x00000100 +#define SPD_ATTR_FLAGS 0x00000101 +#define SPD_ATTR_AH_AUTH 0x00000102 +#define SPD_ATTR_ESP_ENCR 0x00000103 +#define SPD_ATTR_ESP_AUTH 0x00000104 +#define SPD_ATTR_ENCR_MINBITS 0x00000105 +#define SPD_ATTR_ENCR_MAXBITS 0x00000106 +#define SPD_ATTR_AH_MINBITS 0x00000107 +#define SPD_ATTR_AH_MAXBITS 0x00000108 +#define SPD_ATTR_LIFE_SOFT_TIME 0x00000109 +#define SPD_ATTR_LIFE_HARD_TIME 0x0000010a +#define SPD_ATTR_LIFE_SOFT_BYTES 0x0000010b +#define SPD_ATTR_LIFE_HARD_BYTES 0x0000010c +#define SPD_ATTR_KM_PROTO 0x0000010d +#define SPD_ATTR_KM_COOKIE 0x0000010e +#define SPD_ATTR_REPLAY_DEPTH 0x0000010f +#define SPD_ATTR_ESPA_MINBITS 0x00000110 +#define SPD_ATTR_ESPA_MAXBITS 0x00000111 +#define SPD_ATTR_ENCR_DEFBITS 0x00000112 +#define SPD_ATTR_ENCR_INCRBITS 0x00000113 +#define SPD_ATTR_AH_DEFBITS 0x00000114 +#define SPD_ATTR_AH_INCRBITS 0x00000115 +#define SPD_ATTR_ESPA_DEFBITS 0x00000116 +#define SPD_ATTR_ESPA_INCRBITS 0x00000117 +#define SPD_ATTR_ALG_ID 0x00000118 +#define SPD_ATTR_ALG_PROTO 0x00000119 +#define SPD_ATTR_ALG_INCRBITS 0x0000011a +#define SPD_ATTR_ALG_NKEYSIZES 0x0000011b +#define SPD_ATTR_ALG_KEYSIZE 0x0000011c +#define SPD_ATTR_ALG_NBLOCKSIZES 0x0000011d +#define SPD_ATTR_ALG_BLOCKSIZE 0x0000011e +#define SPD_ATTR_ALG_MECHNAME 0x0000011f +#define SPD_ATTR_PROTO_ID 0x00000120 +#define SPD_ATTR_PROTO_EXEC_MODE 0x00000121 +#define SPD_ATTR_ALG_NPARAMS 0x00000122 +#define SPD_ATTR_ALG_PARAMS 0x00000123 +#define SPD_ATTR_ALG_FLAGS 0x00000124 + +/* + * An interface extension identifies a network interface. + * It is used for configuring Tunnel Mode policies on a tunnelling + * interface for now. + */ +typedef struct spd_if_s { + union { + struct { + uint16_t spd_if_ulen; + uint16_t spd_if_uexttype; + union { + uint8_t spd_if_iuname[4]; + uint32_t spd_if_iuindex; + } spd_if_iu; + } spd_if_actual; + uint64_t spd_if_alignment; + } spd_if_u; +#define spd_if_len spd_if_u.spd_if_actual.spd_if_ulen +#define spd_if_exttype spd_if_u.spd_if_actual.spd_if_uexttype +#define spd_if_name spd_if_u.spd_if_actual.spd_if_iu.spd_if_iuname +#define spd_if_index spd_if_u.spd_if_actual.spd_if_iu.spd_if_iuindex +} spd_if_t; + +/* + * Minimum, maximum key lengths in bits. + */ +#define SPD_MIN_MINBITS 0x0000 +#define SPD_MAX_MAXBITS 0xffff + +/* + * IPsec action types (in SPD_ATTR_TYPE attribute) + */ +#define SPD_ACTTYPE_DROP 0x0001 +#define SPD_ACTTYPE_PASS 0x0002 +#define SPD_ACTTYPE_IPSEC 0x0003 + +/* + * Action flags (in SPD_ATTR_FLAGS attribute) + */ +#define SPD_APPLY_AH 0x0001 +#define SPD_APPLY_ESP 0x0002 +#define SPD_APPLY_SE 0x0004 /* self-encapsulation */ +#define SPD_APPLY_COMP 0x0008 /* compression; NYI */ +#define SPD_APPLY_UNIQUE 0x0010 /* unique per-flow SA */ +#define SPD_APPLY_BYPASS 0x0020 /* bypass policy */ +#define SPD_APPLY_ESPA 0x0040 /* ESP authentication */ + +/* + * SW crypto execution modes. + */ +#define SPD_ALG_EXEC_MODE_SYNC 1 /* synchronous */ +#define SPD_ALG_EXEC_MODE_ASYNC 2 /* asynchronous */ + +/* + * SPD_DUMP protocol: + * + * We do not want to force an stack to have to read-lock the entire + * SPD for the duration of the dump, but we want management apps to be + * able to get a consistent snapshot of the SPD. + * + * Therefore, we make optimistic locking assumptions. + * + * The response to a SPD_DUMP request consists of multiple spd_msg + * records, all with spd_msg_type == SPD_DUMP and spd_msg_{seq,pid} + * matching the request. + * + * There is one header, then a sequence of policy rule records (one + * rule per record), then a trailer. + * + * The header and trailer both contain a single SPD_EXT_RULESET + * containing a version number and rule count. The dump was "good" if + * header version == trailer version, and the number of rules read by + * the application matches the rule count in the trailer. The rule + * count in the header is unused and should be set to zero. + * + * In between, each rule record contains a set of extensions which, if + * used in an SPD_ADD request, would recreate an equivalent rule. + * + * If rules were added to the SPD during the dump, the dump may be + * truncated or otherwise incomplete; the management application + * should re-try the dump in this case. + */ + +/* + * Ruleset extension, used at the start and end of a SPD_DUMP. + */ +typedef struct spd_ruleset_ext +{ + uint16_t spd_ruleset_len; /* 2 x 64 bits */ + uint16_t spd_ruleset_type; /* SPD_EXT_RULESET */ + uint32_t spd_ruleset_count; /* only valid in trailer */ + uint64_t spd_ruleset_version; /* version number */ +} spd_ruleset_ext_t; + +/* + * Diagnostic codes. These supplement error messages. Be sure to + * update libipsecutil's spdsock_diag() if you change any of these. + */ +#define SPD_DIAGNOSTIC_NONE 0 +#define SPD_DIAGNOSTIC_UNKNOWN_EXT 1 +#define SPD_DIAGNOSTIC_BAD_EXTLEN 2 +#define SPD_DIAGNOSTIC_NO_RULE_EXT 3 +#define SPD_DIAGNOSTIC_BAD_ADDR_LEN 4 +#define SPD_DIAGNOSTIC_MIXED_AF 5 +#define SPD_DIAGNOSTIC_ADD_NO_MEM 6 +#define SPD_DIAGNOSTIC_ADD_WRONG_ACT_COUNT 7 +#define SPD_DIAGNOSTIC_ADD_BAD_TYPE 8 +#define SPD_DIAGNOSTIC_ADD_BAD_FLAGS 9 +#define SPD_DIAGNOSTIC_ADD_INCON_FLAGS 10 +#define SPD_DIAGNOSTIC_MALFORMED_LCLPORT 11 +#define SPD_DIAGNOSTIC_DUPLICATE_LCLPORT 12 +#define SPD_DIAGNOSTIC_MALFORMED_REMPORT 13 +#define SPD_DIAGNOSTIC_DUPLICATE_REMPORT 14 +#define SPD_DIAGNOSTIC_MALFORMED_PROTO 15 +#define SPD_DIAGNOSTIC_DUPLICATE_PROTO 16 +#define SPD_DIAGNOSTIC_MALFORMED_LCLADDR 17 +#define SPD_DIAGNOSTIC_DUPLICATE_LCLADDR 18 +#define SPD_DIAGNOSTIC_MALFORMED_REMADDR 19 +#define SPD_DIAGNOSTIC_DUPLICATE_REMADDR 20 +#define SPD_DIAGNOSTIC_MALFORMED_ACTION 21 +#define SPD_DIAGNOSTIC_DUPLICATE_ACTION 22 +#define SPD_DIAGNOSTIC_MALFORMED_RULE 23 +#define SPD_DIAGNOSTIC_DUPLICATE_RULE 24 +#define SPD_DIAGNOSTIC_MALFORMED_RULESET 25 +#define SPD_DIAGNOSTIC_DUPLICATE_RULESET 26 +#define SPD_DIAGNOSTIC_INVALID_RULE_INDEX 27 +#define SPD_DIAGNOSTIC_BAD_SPDID 28 +#define SPD_DIAGNOSTIC_BAD_MSG_TYPE 29 +#define SPD_DIAGNOSTIC_UNSUPP_AH_ALG 30 +#define SPD_DIAGNOSTIC_UNSUPP_ESP_ENCR_ALG 31 +#define SPD_DIAGNOSTIC_UNSUPP_ESP_AUTH_ALG 32 +#define SPD_DIAGNOSTIC_UNSUPP_AH_KEYSIZE 33 +#define SPD_DIAGNOSTIC_UNSUPP_ESP_ENCR_KEYSIZE 34 +#define SPD_DIAGNOSTIC_UNSUPP_ESP_AUTH_KEYSIZE 35 +#define SPD_DIAGNOSTIC_NO_ACTION_EXT 36 +#define SPD_DIAGNOSTIC_ALG_ID_RANGE 37 +#define SPD_DIAGNOSTIC_ALG_NUM_KEY_SIZES 38 +#define SPD_DIAGNOSTIC_ALG_NUM_BLOCK_SIZES 39 +#define SPD_DIAGNOSTIC_ALG_MECH_NAME_LEN 40 +#define SPD_DIAGNOSTIC_ALG_IPSEC_NOT_LOADED 41 +#define SPD_DIAGNOSTIC_MALFORMED_ICMP_TYPECODE 42 +#define SPD_DIAGNOSTIC_DUPLICATE_ICMP_TYPECODE 43 +#define SPD_DIAGNOSTIC_NOT_GLOBAL_OP 44 +#define SPD_DIAGNOSTIC_NO_TUNNEL_SELECTORS 45 + +/* + * Helper macros. + */ +#define SPD_64TO8(x) ((x) << 3) +#define SPD_8TO64(x) ((x) >> 3) +#define SPD_8TO1(x) ((x) << 3) +#define SPD_1TO8(x) ((x) >> 3) + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_PFPOLICY_H */ diff --git a/illumos-x86_64/usr/include/net/ppp-comp.h b/illumos-x86_64/usr/include/net/ppp-comp.h new file mode 100644 index 00000000..d7b13362 --- /dev/null +++ b/illumos-x86_64/usr/include/net/ppp-comp.h @@ -0,0 +1,203 @@ +/* + * ppp-comp.h - Definitions for doing PPP packet compression. + * + * Copyright 2000 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1994 The Australian National University. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, provided that the above copyright + * notice appears in all copies. This software is provided without any + * warranty, express or implied. The Australian National University + * makes no representations about the suitability of this software for + * any purpose. + * + * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY + * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, + * OR MODIFICATIONS. + * + * $Id: ppp-comp.h,v 1.11 1998/03/25 03:33:34 paulus Exp $ + */ + +#ifndef _NET_PPP_COMP_H +#define _NET_PPP_COMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following symbols control whether we include code for + * various compression methods. + */ +#ifndef DO_BSD_COMPRESS +#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */ +#endif +#ifndef DO_DEFLATE +#define DO_DEFLATE 1 /* by default, include Deflate */ +#endif +#define DO_PREDICTOR_1 0 +#define DO_PREDICTOR_2 0 + +/* + * Structure giving methods for compression/decompression. + */ +#ifdef PACKETPTR +struct compressor { + int compress_proto; /* CCP compression protocol number */ + + /* Allocate space for a compressor (transmit side) */ + void *(*comp_alloc) __P((uchar_t *options, int opt_len)); + /* Free space used by a compressor */ + void (*comp_free) __P((void *state)); + /* Initialize a compressor */ + int (*comp_init) __P((void *state, uchar_t *options, int opt_len, + int unit, int hdrlen, int debug)); + /* Reset a compressor */ + void (*comp_reset) __P((void *state)); + /* Compress a packet */ + int (*compress) __P((void *state, PACKETPTR *mret, + PACKETPTR mp, int orig_len, int max_len)); + /* Return compression statistics */ + void (*comp_stat) __P((void *state, struct compstat *stats)); + + /* Allocate space for a decompressor (receive side) */ + void *(*decomp_alloc) __P((uchar_t *options, int opt_len)); + /* Free space used by a decompressor */ + void (*decomp_free) __P((void *state)); + /* Initialize a decompressor */ + int (*decomp_init) __P((void *state, uchar_t *options, int opt_len, + int unit, int hdrlen, int mru, int debug)); + /* Reset a decompressor */ + void (*decomp_reset) __P((void *state)); + /* Decompress a packet. */ + int (*decompress) __P((void *state, PACKETPTR *mp)); + /* Update state for an incompressible packet received */ + int (*incomp) __P((void *state, PACKETPTR mp)); + /* Return decompression statistics */ + void (*decomp_stat) __P((void *state, struct compstat *stats)); + + /* Set or change compression effort level */ + int (*set_effort) __P((void *xstate, void *rstate, + int effortlevel)); +}; +#endif /* PACKETPTR */ + +/* + * Return values for decompress routine. + * We need to make these distinctions so that we can disable certain + * useful functionality, namely sending a CCP reset-request as a result + * of an error detected after decompression. This is to avoid infringing + * a patent held by Motorola. + * Don't you just lurve software patents. + */ +#define DECOMP_OK 0 /* everything went OK */ +#define DECOMP_ERROR 1 /* error detected before decomp. */ +#define DECOMP_FATALERROR 2 /* error detected after decomp. */ + +/* + * CCP codes. + */ +#define CCP_CONFREQ 1 +#define CCP_CONFACK 2 +#define CCP_TERMREQ 5 +#define CCP_TERMACK 6 +#define CCP_RESETREQ 14 +#define CCP_RESETACK 15 + +/* + * Max # bytes for a CCP option + */ +#define CCP_MAX_OPTION_LENGTH 32 + +/* + * Parts of a CCP packet. + */ +#define CCP_CODE(dp) ((dp)[0]) +#define CCP_ID(dp) ((dp)[1]) +#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3]) +#define CCP_HDRLEN 4 + +#define CCP_OPT_CODE(dp) ((dp)[0]) +#define CCP_OPT_LENGTH(dp) ((dp)[1]) +#define CCP_OPT_MINLEN 2 + +/* + * Definitions for BSD-Compress. + */ +#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */ +#define CILEN_BSD_COMPRESS 3 /* length of config. option */ + +/* Macros for handling the 3rd byte of the BSD-Compress config option. */ +#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */ +#define BSD_VERSION(x) ((x) >> 5) /* version of option format */ +#define BSD_CURRENT_VERSION 1 /* current version number */ +#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n)) + +#define BSD_MIN_BITS 9 /* smallest code size supported */ +#define BSD_MAX_BITS 15 /* largest code size supported */ + +/* + * Definitions for Deflate. + */ +#define CI_DEFLATE 26 /* config option for Deflate */ +#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */ +#define CILEN_DEFLATE 4 /* length of its config option */ + +#define DEFLATE_MIN_SIZE 8 +#define DEFLATE_MAX_SIZE 15 +#define DEFLATE_METHOD_VAL 8 +#define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE) +#define DEFLATE_METHOD(x) ((x) & 0x0F) +#define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \ + + DEFLATE_METHOD_VAL) +#define DEFLATE_CHK_SEQUENCE 0 + +/* + * Definitions for other, as yet unsupported, compression methods. + */ +#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */ +#define CILEN_PREDICTOR_1 2 /* length of its config option */ +#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */ +#define CILEN_PREDICTOR_2 2 /* length of its config option */ + +/* + * Note that some systems emit requests for STAC using a length of 6. + * The extra octet is 00 and should be ignored. + */ +#define CI_STAC 17 /* config option for STAC LZS */ +#define CILEN_STAC 5 /* length of its config option */ + +#define STAC_CHK_NONE 0 /* No checking */ +#define STAC_CHK_LCB 1 /* Longitudinal Check Bytes */ +#define STAC_CHK_CRC 2 /* Cyclic Redundancy Check */ +#define STAC_CHK_SEQ 3 /* Sequence Number */ +#define STAC_CHK_EXTENDED 4 /* Extended (Microsoft) */ + +#define CI_MPPC 18 /* config option for MS-PPC */ +#define CILEN_MPPC 6 /* length of its config option */ + +#define MPPC_COMP 0x00000001 /* Compression */ +#define MPPC_40LANM 0x00000010 /* MPPE, 40 bit LANManager */ +#define MPPC_40NT 0x00000020 /* MPPE, 40 bit NT key */ +#define MPPC_128NT 0x00000040 /* MPPE, 128 bit NT key */ +#define MPPC_56NT 0x00000080 /* MPPE, 56 bit NT key */ +#define MPPC_PBP 0x01000000 /* Packet-by-Packet mode */ +#define MPPC_MPPE 0x000000F0 + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_PPP_COMP_H */ diff --git a/illumos-x86_64/usr/include/net/ppp_defs.h b/illumos-x86_64/usr/include/net/ppp_defs.h new file mode 100644 index 00000000..dc64c2dd --- /dev/null +++ b/illumos-x86_64/usr/include/net/ppp_defs.h @@ -0,0 +1,292 @@ +/* $Id: ppp_defs.h,v 1.14 1999/08/13 01:55:40 paulus Exp $ */ + +/* + * ppp_defs.h - PPP definitions. + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1994 The Australian National University. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, provided that the above copyright + * notice appears in all copies. This software is provided without any + * warranty, express or implied. The Australian National University + * makes no representations about the suitability of this software for + * any purpose. + * + * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY + * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, + * OR MODIFICATIONS. + */ + +#ifndef _PPP_DEFS_H_ +#define _PPP_DEFS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The basic PPP frame. + */ +#define PPP_HDRLEN 4 /* octets for standard ppp header */ +#define PPP_FCSLEN 2 /* octets for FCS */ +#define PPP_FCS32LEN 4 /* octets for FCS-32 */ +#define PPP_MAX_MUX_LEN 127 /* maximum length of muxed frame */ +#define PFF 0x80 /* protocol field flag */ + +/* + * Packet sizes + */ +#define PPP_MTU 1500 /* Default MTU (size of Info field) */ +#define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN) +#define PPP_MINMTU 64 +#define PPP_MRU 1500 /* default MRU = max length of info field */ +#define PPP_MAXMRU 65000 /* Largest MRU we allow */ +#define PPP_MINMRU 128 + +#define PPP_ADDRESS(p) (((uchar_t *)(p))[0]) +#define PPP_CONTROL(p) (((uchar_t *)(p))[1]) +#define PPP_PROTOCOL(p) ((((uchar_t *)(p))[2] << 8) + ((uchar_t *)(p))[3]) + +/* + * Significant octet values. + */ +#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ +#define PPP_UI 0x03 /* Unnumbered Information */ +#define PPP_FLAG 0x7e /* Flag Sequence */ +#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ +#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ + +/* + * Protocol field values. + */ +#define PPP_IP 0x21 /* Internet Protocol */ +#define PPP_OSI 0x23 /* OSI Network Layer */ +#define PPP_AT 0x29 /* AppleTalk Protocol */ +#define PPP_IPX 0x2b /* IPX protocol */ +#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ +#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ +#define PPP_BRIDGE 0x31 /* Bridging */ +#define PPP_MP 0x3d /* Multilink protocol */ +#define PPP_ENCRYPT 0x53 /* Encryption */ +#define PPP_ENCRYPTFRAG 0x55 /* Individual Link Encryption */ +#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ +#define PPP_MUX 0x59 /* PPP Muxing */ +#define PPP_FULLHDR 0x61 /* IP Compression; full header */ +#define PPP_COMPTCP 0x63 /* IP Compression; compressed TCP */ +#define PPP_COMPNONTCP 0x65 /* IP Compression; non TCP */ +#define PPP_COMPUDP8 0x67 /* IP Compression; UDP, 8 bit CID */ +#define PPP_COMPRTP8 0x69 /* IP Compression; RTP, 8 bit CID */ +#define PPP_COMPFRAG 0xfb /* fragment compressed below bundle */ +#define PPP_COMP 0xfd /* compressed packet */ +#define PPP_802HELLO 0x201 /* 802.1d Hello (OBSOLETE) */ +#define PPP_MPLS 0x281 /* MPLS Unicast */ +#define PPP_MPLSMC 0x283 /* MPLS Multicast */ +#define PPP_COMPTCPND 0x2063 /* IP Compression; compressed TCP no delta */ +#define PPP_COMPSTATE 0x2065 /* IP Compression; state message */ +#define PPP_COMPUDP16 0x2067 /* IP Compression; UDP, 16 bit CID */ +#define PPP_COMPRTP16 0x2069 /* IP Compression; RTP, 16 bit CID */ +#define PPP_IPCP 0x8021 /* IP Control Protocol */ +#define PPP_OSINLCP 0x8023 /* OSI Network Layer Control Protocol */ +#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ +#define PPP_IPXCP 0x802b /* IPX Control Protocol */ +#define PPP_BCP 0x8031 /* Bridging Control Protocol */ +#define PPP_ECP 0x8053 /* Encryption Control Protocol */ +#define PPP_ECPFRAG 0x8055 /* ECP at link level (below MP bundle) */ +#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ +#define PPP_MUXCP 0x8059 /* PPP Muxing Control Protocol */ +#define PPP_CCPFRAG 0x80fb /* CCP at link level (below MP bundle) */ +#define PPP_CCP 0x80fd /* Compression Control Protocol */ +#define PPP_MPLSCP 0x8281 /* MPLS Control Protocol */ +#define PPP_LCP 0xc021 /* Link Control Protocol */ +#define PPP_PAP 0xc023 /* Password Authentication Protocol */ +#define PPP_LQR 0xc025 /* Link Quality Report protocol */ +#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */ +#define PPP_BAP 0xc02d /* Bandwidth Allocation Protocol */ +#define PPP_CBCP 0xc029 /* Callback Control Protocol */ +#define PPP_CHAP 0xc223 /* Challenge Handshake Auth. Protocol */ +#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */ + +/* + * Values for FCS calculations. + */ +#define PPP_INITFCS 0xffff /* Initial FCS value */ +#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ +#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) + +#define PPPINITFCS16 PPP_INITFCS +#define PPPGOODFCS16 PPP_GOODFCS +#define PPPFCS16(fcs, c) PPP_FCS((fcs), (c)) + +#define PPPINITFCS32 0xfffffffful +#define PPPGOODFCS32 0xdebb20e3ul +#define PPPFCS32(fcs, c) (((fcs) >> 8) ^ crc32_table[((fcs) ^ (c)) & 0xff]) + +/* Marker values shared between pppdump and pppd. */ +#define RECMARK_STARTSEND 1 +#define RECMARK_STARTRECV 2 +#define RECMARK_ENDSEND 3 +#define RECMARK_ENDRECV 4 +#define RECMARK_TIMEDELTA32 5 +#define RECMARK_TIMEDELTA8 6 +#define RECMARK_TIMESTART 7 + +/* + * A 32-bit unsigned integral type. + */ + +#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) && \ + !defined(__FreeBSD__) && (NS_TARGET < 40) +#ifdef UINT32_T +typedef UINT32_T u_int32_t; +#else +typedef unsigned int u_int32_t; +typedef unsigned short u_int16_t; +#endif +#endif + +#if defined(__sun) && !defined(_SYS_INT_TYPES_H) && !defined(_UINT32_T) +/* Backward compatibility */ +typedef uint_t uint32_t; +typedef ushort_t uint16_t; +typedef uchar_t uint8_t; +typedef unsigned long uintptr_t; +#define _UINT32_T +#endif + +/* + * Extended asyncmap - allows any character to be escaped. + */ +typedef u_int32_t ext_accm[8]; + +/* + * What to do with network protocol (NP) packets. + */ +enum NPmode { + NPMODE_PASS, /* pass the packet through */ + NPMODE_DROP, /* silently drop the packet */ + NPMODE_ERROR, /* return an error */ + NPMODE_QUEUE /* save it up for later. */ +}; + +/* + * Statistics. + */ +struct pppstat { + u_int32_t ppp_ibytes; /* bytes received */ + u_int32_t ppp_ipackets; /* packets received */ + u_int32_t ppp_ierrors; /* receive errors */ + u_int32_t ppp_obytes; /* bytes sent */ + u_int32_t ppp_opackets; /* packets sent */ + u_int32_t ppp_oerrors; /* transmit errors */ +}; + +struct vjstat { + u_int32_t vjs_packets; /* outbound packets */ + u_int32_t vjs_compressed; /* outbound compressed packets */ + u_int32_t vjs_searches; /* searches for connection state */ + u_int32_t vjs_misses; /* times couldn't find conn. state */ + u_int32_t vjs_uncompressedin; /* inbound uncompressed packets */ + u_int32_t vjs_compressedin; /* inbound compressed packets */ + u_int32_t vjs_errorin; /* inbound unknown type packets */ + u_int32_t vjs_tossed; /* inbound packets tossed because of error */ +}; + +struct ppp_stats { + struct pppstat p; /* basic PPP statistics */ + struct vjstat vj; /* VJ header compression statistics */ +}; + +#ifdef SOL2 +#define PPP_COUNTER_F "llu" +typedef uint64_t ppp_counter_t; + +struct pppstat64 { + ppp_counter_t ppp_ibytes; /* bytes received */ + ppp_counter_t ppp_ipackets; /* packets received */ + ppp_counter_t ppp_ierrors; /* receive errors */ + ppp_counter_t ppp_obytes; /* bytes sent */ + ppp_counter_t ppp_opackets; /* packets sent */ + ppp_counter_t ppp_oerrors; /* transmit errors */ +}; + +struct ppp_stats64 { + struct pppstat64 p; + struct vjstat vj; +}; +#else +#define PPP_COUNTER_F "u" +typedef u_int32_t ppp_counter_t; +#endif + +struct compstat { + u_int32_t unc_bytes; /* total uncompressed bytes */ + u_int32_t unc_packets; /* total uncompressed packets */ + u_int32_t comp_bytes; /* compressed bytes */ + u_int32_t comp_packets; /* compressed packets */ + u_int32_t inc_bytes; /* incompressible bytes */ + u_int32_t inc_packets; /* incompressible packets */ + u_int32_t ratio; /* recent compression ratio << 8 */ +}; + +struct ppp_comp_stats { + struct compstat c; /* packet compression statistics */ + struct compstat d; /* packet decompression statistics */ +}; + +/* + * The following structure records the time in seconds since + * the last NP packet was sent or received. + */ +struct ppp_idle { + /* + * Fix the length of these fields to be 32-bit, since + * otherwise, a time_t (long) is 64-bit in kernel while 32-bit + * in userland when running on a 64-bit CPU with a 64-bit OS. + */ + u_int32_t xmit_idle; /* time since last NP packet sent */ + u_int32_t recv_idle; /* time since last NP packet received */ +}; + +enum LSstat { + PPP_LINKSTAT_HANGUP = 0xabcd, /* link is hung up */ + PPP_LINKSTAT_NEEDUP, /* link is down and needs to be up */ + PPP_LINKSTAT_IPV4_UNBOUND, /* DL_UNBIND received on IPv4 stream */ + PPP_LINKSTAT_IPV6_UNBOUND, /* DL_UNBIND received on IPv6 stream */ + PPP_LINKSTAT_IPV4_BOUND, /* DL_BIND received on IPv4 stream */ + PPP_LINKSTAT_IPV6_BOUND, /* DL_BIND received on IPv6 stream */ + PPP_LINKSTAT_UP /* Integrated driver; hardware is up */ +}; + +#define PPPLSMAGIC 0x53505050 + +struct ppp_ls { + u_int32_t magic; /* magic number identifier (PPPLSMAGIC) */ + u_int32_t ppp_message; /* link status message */ +}; + +#ifndef __P +#ifdef __STDC__ +#define __P(x) x +#else +#define __P(x) () +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _PPP_DEFS_H_ */ diff --git a/illumos-x86_64/usr/include/net/pppio.h b/illumos-x86_64/usr/include/net/pppio.h new file mode 100644 index 00000000..622c7906 --- /dev/null +++ b/illumos-x86_64/usr/include/net/pppio.h @@ -0,0 +1,174 @@ +/* + * pppio.h - ioctl and other misc. definitions for STREAMS modules. + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1994 The Australian National University. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, provided that the above copyright + * notice appears in all copies. This software is provided without any + * warranty, express or implied. The Australian National University + * makes no representations about the suitability of this software for + * any purpose. + * + * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY + * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, + * OR MODIFICATIONS. + * + * $Id: pppio.h,v 1.8 1996/08/28 06:36:51 paulus Exp $ + */ + +#ifndef __PPPIO_H +#define __PPPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define _PPPIO(n) (('p' << 8) + (n)) + +#define PPPIO_NEWPPA _PPPIO(130) /* allocate a new PPP unit */ +#define PPPIO_GETSTAT _PPPIO(131) /* get PPP statistics */ +#define PPPIO_GETCSTAT _PPPIO(132) /* get PPP compression stats */ +#define PPPIO_MTU _PPPIO(133) /* set max transmission unit */ +#define PPPIO_MRU _PPPIO(134) /* set max receive unit */ +#define PPPIO_CFLAGS _PPPIO(135) /* set/clear/get compression flags */ +#define PPPIO_XCOMP _PPPIO(136) /* alloc transmit compressor */ +#define PPPIO_RCOMP _PPPIO(137) /* alloc receive decompressor */ +#define PPPIO_XACCM _PPPIO(138) /* set transmit asyncmap */ +#define PPPIO_RACCM _PPPIO(139) /* set receive asyncmap */ +#define PPPIO_VJINIT _PPPIO(140) /* initialize VJ comp/decomp */ +#define PPPIO_ATTACH _PPPIO(141) /* attach to a ppa (without putmsg) */ +#define PPPIO_LASTMOD _PPPIO(142) /* mark last ppp module */ +#define PPPIO_GCLEAN _PPPIO(143) /* get 8-bit-clean flags */ +#define PPPIO_DEBUG _PPPIO(144) /* request debug information */ +#define PPPIO_BIND _PPPIO(145) /* bind to SAP */ +#define PPPIO_NPMODE _PPPIO(146) /* set mode for handling data pkts */ +#define PPPIO_GIDLE _PPPIO(147) /* get time since last data pkt */ +#define PPPIO_PASSFILT _PPPIO(148) /* set filter for packets to pass */ +#define PPPIO_ACTIVEFILT _PPPIO(149) /* set filter for "link active" pkts */ +#define PPPIO_USETIMESTAMP _PPPIO(150) /* enable packet time-stamp */ +#define PPPIO_DETACH _PPPIO(151) /* detach from a ppa (w/o putmsg ) */ +#define PPPIO_XFCS _PPPIO(152) /* set transmit FCS type */ +#define PPPIO_RFCS _PPPIO(153) /* set receive FCS type */ +#define PPPIO_COMPLEV _PPPIO(154) /* set compression effort level */ +#define PPPIO_GTYPE _PPPIO(155) /* get existing driver type */ +#define PPPIO_MUX _PPPIO(156) /* multiplexed frame */ +#define PPPIO_GETSTAT64 _PPPIO(157) /* get PPP 64-bit statistics */ +#define PPPIO_BLOCKNP _PPPIO(158) /* block pkts with proto np in kernel */ +#define PPPIO_UNBLOCKNP _PPPIO(159) /* unblock pkts with proto np */ + +/* Values for PPPIO_MUX FLAGS */ +#define X_MUXMASK 0x10 /* transmit muxed frame option */ +#define R_MUXMASK 0x20 /* receive muxed frame option */ + +/* + * Values for PPPIO_CFLAGS. Data sent in is u_int32_t val[2], where + * result is newflags = val[0] | (oldflags & ~val[1]). Returned data + * is a single u_int32_t, containing the current flags. + */ +#define COMP_AC 0x1 /* compress address/control */ +#define DECOMP_AC 0x2 /* decompress address/control */ +#define COMP_PROT 0x4 /* compress PPP protocol */ +#define DECOMP_PROT 0x8 /* decompress PPP protocol */ + +#define COMP_VJC 0x10 /* compress TCP/IP headers */ +#define COMP_VJCCID 0x20 /* compress connection ID as well */ +#define DECOMP_VJC 0x40 /* decompress TCP/IP headers */ +#define DECOMP_VJCCID 0x80 /* accept compressed connection ID */ + +#define CCP_ISOPEN 0x100 /* look at CCP packets */ +#define CCP_ISUP 0x200 /* do packet comp/decomp */ +#define CCP_ERROR 0x400 /* (status) error in packet decomp */ +#define CCP_FATALERROR 0x800 /* (status) fatal error ditto */ +#define CCP_COMP_RUN 0x1000 /* (status) seen CCP ack sent */ +#define CCP_DECOMP_RUN 0x2000 /* (status) seen CCP ack rcvd */ + + +/* + * Values for PPPIO_XFCS/PPPIO_RFCS. (Note that we don't support + * simultaneous use of 16 bit and 32 bit CRCs.) + */ +#define PPPFCS_16 0 /* The default, usually; CRC-16 */ +#define PPPFCS_32 1 /* CRC-32 */ +#define PPPFCS_NONE 2 /* No CRC */ + +/* + * Values for 8-bit-clean flags. + */ +#define RCV_B7_0 1 /* have rcvd char with bit 7 = 0 */ +#define RCV_B7_1 2 /* have rcvd char with bit 7 = 1 */ +#define RCV_EVNP 4 /* have rcvd char with even parity */ +#define RCV_ODDP 8 /* have rcvd char with odd parity */ + +/* + * Values for the first byte of M_CTL messages passed between + * PPP modules. + */ +#define PPPCTL_OERROR 0xe0 /* output error [up] */ +#define PPPCTL_IERROR 0xe1 /* input error (e.g. FCS) [up] */ +#define PPPCTL_MTU 0xe2 /* set MTU [down] */ +#define PPPCTL_MRU 0xe3 /* set MRU [down] */ +#define PPPCTL_UNIT 0xe4 /* note PPP unit number [down] */ + +/* + * Values for the u_int32_t argument to PPPIO_DEBUG. + */ +#define PPPDBG_DUMP 0x10000 /* print out debug info now */ +#define PPPDBG_LOG 0x100 /* log various things */ +#define PPPDBG_DRIVER 0 /* identifies ppp driver as target */ +#define PPPDBG_IF 1 /* identifies ppp network i/f target */ +#define PPPDBG_COMP 2 /* identifies ppp compression target */ +#define PPPDBG_AHDLC 3 /* identifies ppp async hdlc target */ + +/* + * Values for the u_int32_t return from PPPIO_GTYPE. Only lastmod + * should respond. Current modules return PPPTYP_AHDLC (async + * module), PPPTYP_HC (compression module) and PPPTYP_MUX (PPP + * interface driver). + */ +#define PPPTYP_HDLC 0 /* raw HDLC I/O; no PPP handling */ +#define PPPTYP_AHDLC 1 /* async HDLC; has [XR]ACCM */ +#define PPPTYP_HC 2 /* HDLC with ACFC and PFC support */ +#define PPPTYP_AHC 3 /* async with ACFC and PFC */ +#define PPPTYP_MUX 4 /* multiplexor */ + +#ifdef SOL2 +/* Officially allocated module numbers */ +#define PPP_MOD_ID 2101 /* PPP multiplexor */ +#define COMP_MOD_ID 2102 /* Data and header compression */ +#define AHDLC_MOD_ID 2103 /* Asynchronous HDLC-like encapsulation */ +#define TUN_MOD_ID 2104 /* Tunneling protocols */ +#define MP_MOD_ID 2105 /* Multilink PPP */ +#define PPP_DRV_NAME "sppp" +#define AHDLC_MOD_NAME "spppasyn" +#define COMP_MOD_NAME "spppcomp" +#define TUN_MOD_NAME "sppptun" +#define MP_MOD_NAME "spppmp" +#else +#define PPP_MOD_ID 0xb1a6 +#define COMP_MOD_ID 0xbadf +#define AHDLC_MOD_ID 0x7d23 +#define PPP_DRV_NAME "ppp" +#define AHDLC_MOD_NAME "ppp_ahdl" +#define COMP_MOD_NAME "ppp_comp" +#endif +#define PPP_DEV_NAME "/dev/" PPP_DRV_NAME + +#ifdef __cplusplus +} +#endif + +#endif /* __PPPIO_H */ diff --git a/illumos-x86_64/usr/include/net/radix.h b/illumos-x86_64/usr/include/net/radix.h new file mode 100644 index 00000000..1967b9fe --- /dev/null +++ b/illumos-x86_64/usr/include/net/radix.h @@ -0,0 +1,232 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1988, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)radix.h 8.2 (Berkeley) 10/31/94 + * $FreeBSD: /repoman/r/ncvs/src/sys/net/radix.h,v 1.25.2.1 2005/01/31 23:26:23 + * imp Exp $ + */ + +#ifndef _RADIX_H_ +#define _RADIX_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +#include +#include +#endif +#include + +#ifdef MALLOC_DECLARE +MALLOC_DECLARE(M_RTABLE); +#endif + +/* + * Radix search tree node layout. + */ + +struct radix_node { + struct radix_mask *rn_mklist; /* list of masks contained in subtree */ + struct radix_node *rn_parent; /* parent */ + short rn_bit; /* bit offset; -1-index(netmask) */ + char rn_bmask; /* node: mask for bit test */ + uchar_t rn_flags; /* enumerated next */ +#define RNF_NORMAL 1 /* leaf contains normal route */ +#define RNF_ROOT 2 /* leaf is root leaf for tree */ +#define RNF_ACTIVE 4 /* This node is alive (for rtfree) */ + union { + struct { /* leaf only data: */ + caddr_t rn_Key; /* object of search */ + caddr_t rn_Mask; /* netmask, if present */ + struct radix_node *rn_Dupedkey; + } rn_leaf; + struct { /* node only data: */ + int rn_Off; /* where to start compare */ + struct radix_node *rn_L; /* progeny */ + struct radix_node *rn_R; /* progeny */ + } rn_node; + } rn_u; +}; + + +#define rn_dupedkey rn_u.rn_leaf.rn_Dupedkey +#define rn_key rn_u.rn_leaf.rn_Key +#define rn_mask rn_u.rn_leaf.rn_Mask +#define rn_offset rn_u.rn_node.rn_Off +#define rn_left rn_u.rn_node.rn_L +#define rn_right rn_u.rn_node.rn_R + +/* + * Annotations to tree concerning potential routes applying to subtrees. + */ + +struct radix_mask { + short rm_bit; /* bit offset; -1-index(netmask) */ + char rm_unused; /* cf. rn_bmask */ + uchar_t rm_flags; /* cf. rn_flags */ + struct radix_mask *rm_mklist; /* more masks to try */ + union { + caddr_t rmu_mask; /* the mask */ + struct radix_node *rmu_leaf; /* for normal routes */ + } rm_rmu; + int rm_refs; /* # of references to this struct */ +}; + +#define rm_mask rm_rmu.rmu_mask +#define rm_leaf rm_rmu.rmu_leaf /* extra field would make 32 bytes */ + +typedef int walktree_f_t(struct radix_node *, void *); +typedef boolean_t match_leaf_t(struct radix_node *, void *); +typedef void (*lockf_t)(struct radix_node *); + +struct radix_node_head { + struct radix_node *rnh_treetop; + int rnh_addrsize; /* permit, but not require fixed keys */ + int rnh_pktsize; /* permit, but not require fixed keys */ + struct radix_node *(*rnh_addaddr) /* add based on sockaddr */ + (void *v, void *mask, + struct radix_node_head *head, struct radix_node nodes[]); + struct radix_node *(*rnh_addpkt) /* add based on packet hdr */ + (void *v, void *mask, + struct radix_node_head *head, struct radix_node nodes[]); + struct radix_node *(*rnh_deladdr) /* remove based on sockaddr */ + (void *v, void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_delpkt) /* remove based on packet hdr */ + (void *v, void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_matchaddr) /* locate based on sockaddr */ + (void *v, struct radix_node_head *head); + /* rnh_matchaddr_args: locate based on sockaddr and match_leaf_t() */ + struct radix_node *(*rnh_matchaddr_args) + (void *v, struct radix_node_head *head, + match_leaf_t *f, void *w); + struct radix_node *(*rnh_lookup) /* locate based on sockaddr */ + (void *v, void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */ + (void *v, struct radix_node_head *head); + int (*rnh_walktree) /* traverse tree */ + (struct radix_node_head *head, walktree_f_t *f, void *w); + int (*rnh_walktree_mt) /* traverse tree */ + (struct radix_node_head *head, walktree_f_t *f, void *w, + lockf_t lockf, lockf_t unlockf); + /* rn_walktree_mt: MT safe version of rn_walktree */ + int (*rnh_walktree_from) /* traverse tree below a */ + (struct radix_node_head *head, void *a, void *m, + walktree_f_t *f, void *w); + void (*rnh_close) /* do something when the last ref drops */ + (struct radix_node *rn, struct radix_node_head *head); + struct radix_node rnh_nodes[3]; /* empty tree for common case */ +#ifdef _KERNEL + krwlock_t rnh_lock; /* locks entire radix tree */ +#endif +}; + +#ifdef _KERNEL +/* + * BSD's sockaddr_in and sockadr have a sin_len and an sa_len + * field respectively, as the first field in the structure, and + * everything in radix.c assumes that the first byte of the "varg" + * passed in tells the length of the key (the sockaddr). + * + * Since Solaris' sockaddr_in and sockadr, do not have these fields, we + * define a BSD4-like sockaddr_in structure with rt_sin_len field to + * make LEN macro wn radix.c to work correctly for Solaris + * See comments around LEN() macro in ip/radix.c + * The callers of functions of radix.c have to use this data structure + */ +struct rt_sockaddr { + uint8_t rt_sin_len; + uint8_t rt_sin_family; + uint16_t rt_sin_port; + struct in_addr rt_sin_addr; + char rt_sin_zero[8]; +}; + + +#define R_Malloc(p, c, n) p = kmem_cache_alloc((c), KM_NOSLEEP) +#define R_Zalloc(p, c, n) \ + if (p = kmem_cache_alloc((c), KM_NOSLEEP)) {\ + bzero(p, n); \ + } +#define R_ZallocSleep(p, t, n) p = (t) kmem_zalloc(n, KM_SLEEP) +#define Free(p, c) kmem_cache_free(c, p) +#define FreeHead(p, n) kmem_free(p, n) + +typedef struct radix_node rn_t; +typedef struct radix_mask rmsk_t; +typedef struct radix_node_head rnh_t; +typedef struct rt_sockaddr rt_sa_t; + +#define RADIX_NODE_HEAD_LOCK_INIT(rnh) \ + rw_init(&(rnh)->rnh_lock, NULL, RW_DEFAULT, NULL) +#define RADIX_NODE_HEAD_RLOCK(rnh) rw_enter(&(rnh)->rnh_lock, RW_READER) +#define RADIX_NODE_HEAD_WLOCK(rnh) rw_enter(&(rnh)->rnh_lock, RW_WRITER) +#define RADIX_NODE_HEAD_UNLOCK(rnh) rw_exit(&(rnh)->rnh_lock) +#define RADIX_NODE_HEAD_DESTROY(rnh) rw_destroy(&(rnh)->rnh_lock) +#define RADIX_NODE_HEAD_LOCK_ASSERT(rnh) RW_WRITE_HELD(&(rnh)->rnh_lock) + +#else /* _KERNEL */ + +#define R_Malloc(p, t, n) (p = malloc((unsigned int)(n))) +#define R_Zalloc(p, t, n) (p = calloc(1, (unsigned int)(n))) +#define R_ZallocSleep(p, t, n) R_Zalloc(p, t, n) +#define Free(p, c) free((char *)p); /* c is ignored */ +#ifndef RADIX_NODE_HEAD_RLOCK +#define RADIX_NODE_HEAD_RLOCK(x) /* */ +#endif +#ifndef RADIX_NODE_HEAD_WLOCK +#define RADIX_NODE_HEAD_WLOCK(x) /* */ +#endif +#ifndef RADIX_NODE_HEAD_UNLOCK +#define RADIX_NODE_HEAD_UNLOCK(x) /* */ +#endif + +#endif /* _KERNEL */ + +#ifndef min +#define min MIN +#endif +#ifndef max +#define max MAX +#endif + +void rn_init(void); +void rn_fini(void); +int rn_inithead(void **, int); +int rn_freenode(struct radix_node *, void *); +void rn_freehead(struct radix_node_head *); + +#ifdef __cplusplus +} +#endif + +#endif /* _RADIX_H_ */ diff --git a/illumos-x86_64/usr/include/net/route.h b/illumos-x86_64/usr/include/net/route.h new file mode 100644 index 00000000..af42382b --- /dev/null +++ b/illumos-x86_64/usr/include/net/route.h @@ -0,0 +1,275 @@ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Kernel resident routing tables. + * + * The routing tables are initialized when interface addresses + * are set by making entries for all directly connected interfaces. + */ + +#ifndef _NET_ROUTE_H +#define _NET_ROUTE_H + +/* from UCB 8.5 (Berkeley) 2/8/95 */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A route consists of a destination address and a reference + * to a routing entry. These are often held by protocols + * in their control blocks, e.g. inpcb. + */ +struct route { + struct rtentry *ro_rt; + struct sockaddr ro_dst; +}; + +/* + * These numbers are used by reliable protocols for determining + * retransmission behavior and are included in the routing structure. + * + * rmx_rtt and rmx_rttvar are stored as microseconds; + */ +typedef struct rt_metrics { + uint32_t rmx_locks; /* Kernel must leave these values */ + /* alone */ + uint32_t rmx_mtu; /* MTU for this path */ + uint32_t rmx_hopcount; /* max hops expected */ + uint32_t rmx_expire; /* lifetime for route, e.g. redirect */ + uint32_t rmx_recvpipe; /* inbound delay-bandwith product */ + uint32_t rmx_sendpipe; /* outbound delay-bandwith product */ + uint32_t rmx_ssthresh; /* outbound gateway buffer limit */ + uint32_t rmx_rtt; /* estimated round trip time */ + uint32_t rmx_rttvar; /* estimated rtt variance */ + uint32_t rmx_pksent; /* packets sent using this route */ +} rt_metrics_t; + +/* + * OLD rtentry structure not used in the kernel. Instead the kernel + * uses struct ire defined in . + * + * We distinguish between routes to hosts and routes to networks, + * preferring the former if available. For each route we infer + * the interface to use from the gateway address supplied when + * the route was entered. Routes that forward packets through + * gateways are marked so that the output routines know to address the + * gateway rather than the ultimate destination. + */ +struct rtentry { + uint_t rt_hash; /* to speed lookups */ + struct sockaddr rt_dst; /* key */ + struct sockaddr rt_gateway; /* value */ + short rt_flags; /* up/down?, host/net */ + short rt_refcnt; /* # held references */ + uint_t rt_use; /* raw # packets forwarded */ + +/* + * The kernel does not use this field, and without it the structure is + * datamodel independent. + */ +#if !defined(_KERNEL) + struct ifnet *rt_ifp; /* the answer: interface to use */ +#endif /* !defined(_KERNEL) */ +}; + +#define RTF_UP 0x1 /* route usable */ +#define RTF_GATEWAY 0x2 /* destination is a gateway */ +#define RTF_HOST 0x4 /* host entry (net otherwise) */ +#define RTF_REJECT 0x8 /* host or net unreachable */ +#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ +#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ +#define RTF_DONE 0x40 /* message confirmed */ +#define RTF_MASK 0x80 /* subnet mask present */ +#define RTF_CLONING 0x100 /* generate new routes on use */ +#define RTF_XRESOLVE 0x200 /* external daemon resolves name */ +#define RTF_LLINFO 0x400 /* generated by ARP or ESIS */ +#define RTF_STATIC 0x800 /* manually added */ +#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ +#define RTF_PRIVATE 0x2000 /* do not advertise this route */ +#define RTF_PROTO2 0x4000 /* protocol specific routing flag */ +#define RTF_PROTO1 0x8000 /* protocol specific routing flag */ +#define RTF_MULTIRT 0x10000 /* multiroute */ +#define RTF_SETSRC 0x20000 /* set default outgoing src address */ +#define RTF_INDIRECT 0x40000 /* gateway not directly reachable */ +#define RTF_KERNEL 0x80000 /* created by kernel; can't delete */ +#define RTF_ZONE 0x100000 /* (NGZ only) route from global zone */ + +/* + * OLD statistics not used by the kernel. The kernel uses . + * + * Routing statistics. + */ +struct rtstat { + short rts_badredirect; /* bogus redirect calls */ + short rts_dynamic; /* routes created by redirects */ + short rts_newgateway; /* routes modified by redirects */ + short rts_unreach; /* lookups which failed */ + short rts_wildcard; /* lookups satisfied by a wildcard */ +}; + +/* + * Structures for routing messages. + */ +typedef struct rt_msghdr { + ushort_t rtm_msglen; /* to skip over non-understood messages */ + uchar_t rtm_version; /* future binary compatibility */ + uchar_t rtm_type; /* message type */ + ushort_t rtm_index; /* index for associated ifp */ + int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ + int rtm_addrs; /* bitmask identifying sockaddrs in msg */ + pid_t rtm_pid; /* identify sender */ + int rtm_seq; /* for sender to identify action */ + int rtm_errno; /* why failed */ + int rtm_use; /* from rtentry */ + uint_t rtm_inits; /* which metrics we are initializing */ + struct rt_metrics rtm_rmx; /* metrics themselves */ +} rt_msghdr_t; + +#define RTM_VERSION 3 /* Up the ante and ignore older versions */ + +#define RTM_ADD 0x1 /* Add Route */ +#define RTM_DELETE 0x2 /* Delete Route */ +#define RTM_CHANGE 0x3 /* Change Metrics or flags */ +#define RTM_GET 0x4 /* Report Metrics */ +#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */ +#define RTM_REDIRECT 0x6 /* Told to use different route */ +#define RTM_MISS 0x7 /* Lookup failed on this address */ +#define RTM_LOCK 0x8 /* fix specified metrics */ +#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */ +#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */ +#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */ +#define RTM_NEWADDR 0xc /* address being added to iface */ +#define RTM_DELADDR 0xd /* address being removed from iface */ +#define RTM_IFINFO 0xe /* iface going up/down etc. */ +#define RTM_CHGADDR 0xf /* address added/changed (even while down) */ +#define RTM_FREEADDR 0x10 /* address removed (even while down) */ + +#define RTV_MTU 0x1 /* init or lock _mtu */ +#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ +#define RTV_EXPIRE 0x4 /* init or lock _expire */ +#define RTV_RPIPE 0x8 /* init or lock _recvpipe */ +#define RTV_SPIPE 0x10 /* init or lock _sendpipe */ +#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ +#define RTV_RTT 0x40 /* init or lock _rtt */ +#define RTV_RTTVAR 0x80 /* init or lock _rttvar */ + +/* + * Bitmask values for rtm_addr. + */ +#define RTA_DST 0x1 /* destination sockaddr present */ +#define RTA_GATEWAY 0x2 /* gateway sockaddr present */ +#define RTA_NETMASK 0x4 /* netmask sockaddr present */ +#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ +#define RTA_IFP 0x10 /* interface name sockaddr present */ +#define RTA_IFA 0x20 /* interface addr sockaddr present */ +#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ +#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */ +#define RTA_SRC 0x100 /* source sockaddr present */ + +#define RTA_NUMBITS 9 /* Number of bits used in RTA_* */ + +/* + * Index offsets for sockaddr_storage array for alternate internal encoding. + * There should be an RTAX_* associated with each RTA_*. + */ +#define RTAX_DST 0 +#define RTAX_GATEWAY 1 +#define RTAX_NETMASK 2 +#define RTAX_GENMASK 3 +#define RTAX_IFP 4 +#define RTAX_IFA 5 +#define RTAX_AUTHOR 6 +#define RTAX_BRD 7 +#define RTAX_SRC 8 +#define RTAX_MAX RTA_NUMBITS /* size of array to allocate */ + +/* + * Routing socket message extension after sockaddrs. + */ +typedef struct rtm_ext_s { + uint32_t rtmex_type; /* identifier for type of extension */ + uint32_t rtmex_len; /* length of this extension */ +} rtm_ext_t; + +#define RTMEX_GATEWAY_SECATTR 1 /* extension is tsol_rtsecattr */ +#define RTMEX_MAX RTMEX_GATEWAY_SECATTR + +/* + * Trusted Solaris route security attributes extension. + */ +typedef struct rtsa_s { + uint32_t rtsa_mask; /* see RTSA_* below */ + uint32_t rtsa_doi; /* domain of interpretation */ + brange_t rtsa_slrange; /* sensitivity label range */ +} rtsa_t; + +typedef struct tsol_rtsecattr_s { + uint32_t rtsa_cnt; /* number of attributes */ + rtsa_t rtsa_attr[1]; +} tsol_rtsecattr_t; + +#define TSOL_RTSECATTR_SIZE(n) \ + (sizeof (tsol_rtsecattr_t) + (((n) - 1) * sizeof (struct rtsa_s))) + +#define RTSA_MINSL 0x1 /* minimum sensitivity label is valid */ +#define RTSA_MAXSL 0x2 /* maximum sensitivity label is valid */ +#define RTSA_DOI 0x4 /* domain of interpretation is valid */ +#define RTSA_CIPSO 0x100 /* CIPSO protocol */ +#define RTSA_SLRANGE (RTSA_MINSL|RTSA_MAXSL) + +/* + * Routing socket options. + */ +#define RT_AWARE 0x0001 /* set awareness of hidden interfaces */ + +/* + * Supported RT_AWARE values. As a convenience, the bit-values here mirror + * the LIFC_* values. + */ +#define RTAW_DEFAULT 0x0000 /* unaware application */ +#define RTAW_UNDER_IPMP 0x0010 /* aware of underlying IPMP interfaces */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_ROUTE_H */ diff --git a/illumos-x86_64/usr/include/net/trill.h b/illumos-x86_64/usr/include/net/trill.h new file mode 100644 index 00000000..42005571 --- /dev/null +++ b/illumos-x86_64/usr/include/net/trill.h @@ -0,0 +1,174 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NET_TRILL_H +#define _NET_TRILL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Various well-known Ethernet addresses used by TRILL */ +#define ALL_RBRIDGES { 0x01, 0x80, 0xC2, 0x00, 0x02, 0x00 } +#define ALL_ISIS_RBRIDGES { 0x01, 0x80, 0xC2, 0x00, 0x02, 0x01 } +#define ALL_ESADI_RBRIDGES { 0x01, 0x80, 0xC2, 0x00, 0x02, 0x02 } + +#define TRILL_PROTOCOL_VERS 0 /* th_version */ +#define TRILL_DEFAULT_HOPS 21 /* th_hopcount */ + +/* Nickname range */ +#define RBRIDGE_NICKNAME_MIN 0x0000 +#define RBRIDGE_NICKNAME_MAX 0xFFFF + +/* Define well-known nicknames */ +#define RBRIDGE_NICKNAME_NONE RBRIDGE_NICKNAME_MIN +#define RBRIDGE_NICKNAME_MINRES 0xFFC0 +#define RBRIDGE_NICKNAME_MAXRES (RBRIDGE_NICKNAME_MAX - 1) +#define RBRIDGE_NICKNAME_UNUSED RBRIDGE_NICKNAME_MAX + +#define MIN_RBRIDGE_RANDOM_NICKNAME (RBRIDGE_NICKNAME_NONE + 1) +#define MAX_RBRIDGE_RANDOM_NICKNAME (RBRIDGE_NICKNAME_MINRES - 1) + +/* AF_TRILL IOCTL codes */ +#define TRILL_BASE (0x54524c00) /* base (TRL in hex) */ +#define TRILL_SETNICK (TRILL_BASE + 0) /* trill_node_t */ +#define TRILL_GETNICK (TRILL_BASE + 1) /* uint16_t */ +#define TRILL_ADDNICK (TRILL_BASE + 2) /* trill_node_t */ +#define TRILL_DELNICK (TRILL_BASE + 3) /* uint16_t */ +#define TRILL_DELALL (TRILL_BASE + 4) /* void */ +#define TRILL_HWADDR (TRILL_BASE + 5) /* uint8_t[ETHERADDRL] */ +#define TRILL_TREEROOT (TRILL_BASE + 6) /* uint16_t */ +#define TRILL_NEWBRIDGE (TRILL_BASE + 7) /* char[MAXLINKNAMELEN] */ +#define TRILL_VLANFWDER (TRILL_BASE + 8) /* uint8_t[TRILL_VLANS_ARRSIZE] */ +#define TRILL_DESIGVLAN (TRILL_BASE + 9) /* uint16_t */ +#define TRILL_LISTNICK (TRILL_BASE + 10) /* trill_listnick_t */ +#define TRILL_GETBRIDGE (TRILL_BASE + 11) /* char[MAXLINKNAMELEN] */ +#define TRILL_PORTFLUSH (TRILL_BASE + 12) /* uint16_t */ +#define TRILL_NICKFLUSH (TRILL_BASE + 13) /* uint16_t */ +#define TRILL_GETMTU (TRILL_BASE + 14) /* uint_t * */ + +typedef struct trill_header { +#ifdef _BIT_FIELDS_HTOL + uint8_t th_version : 2; + uint8_t th_reserved : 2; + uint8_t th_multidest : 1; + uint8_t th_optslen_hi : 3; +#else + uint8_t th_optslen_hi : 3; + uint8_t th_multidest : 1; + uint8_t th_reserved : 2; + uint8_t th_version : 2; +#endif + +#ifdef _BIT_FIELDS_HTOL + uint8_t th_optslen_lo : 2; + uint8_t th_hopcount : 6; +#else + uint8_t th_hopcount : 6; + uint8_t th_optslen_lo : 2; +#endif + uint16_t th_egressnick; + uint16_t th_ingressnick; +} trill_header_t; + +#define TRILL_HDR_ALIGN (sizeof (uint16_t)) + +#define SET_TRILL_OPTS_LEN(hdr_p, val) \ + do { \ + (hdr_p)->th_optslen_lo = (val)&0x03; \ + (hdr_p)->th_optslen_hi = (val)>>2; \ + _NOTE(CONSTANTCONDITION) \ + } while (0) + +#define GET_TRILL_OPTS_LEN(hdr_p) \ + ((hdr_p)->th_optslen_lo|((hdr_p)->th_optslen_hi<<2)) + +/* RBridge nick and tree information (*variable* size) */ +typedef struct trill_nickinfo_s { + /* Nickname of the RBridge */ + uint16_t tni_nick; + /* Next-hop SNPA address to reach this RBridge */ + ether_addr_t tni_adjsnpa; + /* Link on our system to use to reach next-hop */ + datalink_id_t tni_linkid; + /* Num of *our* adjacencies on a tree rooted at this RBridge */ + uint16_t tni_adjcount; + /* Num of distribution tree root nicks chosen by this RBridge */ + uint16_t tni_dtrootcount; + /* + * Variable size bytes to store adjacency nicks, distribution + * tree roots and VLAN filter lists. Adjacency nicks and + * distribution tree roots are 16-bit fields. + * + * Number of VLAN filter lists is equal to tni_adjcount as + * the VLAN filter list is one per adjacency in each DT. + * VLAN filter list is a 512 byte bitmap with the set of VLANs + * that are reachable downstream via the adjacency. + */ +} trill_nickinfo_t; + +typedef struct trill_listnick_s { + uint16_t tln_nick; + ether_addr_t tln_nexthop; + datalink_id_t tln_linkid; + boolean_t tln_ours; +} trill_listnick_t; + +/* Access the adjacency nick list at the end of trill_nickinfo_t */ +#define TNI_ADJNICKSPTR(v) ((uint16_t *)((trill_nickinfo_t *)(v)+1)) +#define TNI_ADJNICK(v, n) (TNI_ADJNICKSPTR(v)[(n)]) + +/* Access the DT root nick list in trill_nickinfo_t after adjacency nicks */ +#define TNI_DTROOTNICKSPTR(v) (TNI_ADJNICKSPTR(v)+(v)->tni_adjcount) +#define TNI_DTROOTNICK(v, n) (TNI_DTROOTNICKSPTR(v)[(n)]) + +/* Access the VLAN filter list in trill_nickinfo_t after DT Roots */ +#define TNI_VLANFILTERSPTR(v) (TNI_DTROOTNICKSPTR(v)+(v)->tni_dtrootcount) +#define TNI_VLANFILTERMAP(v, n) \ + (((uint8_t *)(TNI_VLANFILTERSPTR(v)))+((n)*((1<<12)/NBBY))) + +#define TNI_TOTALSIZE(v) (sizeof (trill_nickinfo_t) + \ + (sizeof (uint16_t) * (v)->tni_adjcount) + \ + (sizeof (uint16_t) * (v)->tni_dtrootcount) + \ + (((1<<12)/NBBY) * (v)->tni_adjcount)) + +/* + * This is a special value used in the sockaddr_dl "selector" field to denote + * that the packet represents a Bridging PDU. The core STP instance is not + * defined on a VLAN, so this overload is safe. All other selector values are + * used for TRILL IS-IS PDUs to indicate VLAN ID. + */ +#define TRILL_TCI_BPDU 0xFFFF + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_TRILL_H */ diff --git a/illumos-x86_64/usr/include/net/vjcompress.h b/illumos-x86_64/usr/include/net/vjcompress.h new file mode 100644 index 00000000..a99074b2 --- /dev/null +++ b/illumos-x86_64/usr/include/net/vjcompress.h @@ -0,0 +1,155 @@ +/* + * Definitions for tcp compression routines. + * + * $Id: vjcompress.h,v 1.3 1996/05/28 00:55:33 paulus Exp $ + * + * Copyright (c) 2000 by Sun Microsystems, Inc. + * All rights reserved. + * + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: + * - Initial distribution. + */ + +#ifndef _VJCOMPRESS_H_ +#define _VJCOMPRESS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_STATES 16 /* must be > 2 and < 256 */ +#define MAX_HDR 128 + +/* + * Compressed packet format: + * + * The first octet contains the packet type (top 3 bits), TCP + * 'push' bit, and flags that indicate which of the 4 TCP sequence + * numbers have changed (bottom 5 bits). The next octet is a + * conversation number that associates a saved IP/TCP header with + * the compressed packet. The next two octets are the TCP checksum + * from the original datagram. The next 0 to 15 octets are + * sequence number changes, one change per bit set in the header + * (there may be no changes and there are two special cases where + * the receiver implicitly knows what changed -- see below). + * + * There are 5 numbers which can change (they are always inserted + * in the following order): TCP urgent pointer, window, + * acknowlegement, sequence number and IP ID. (The urgent pointer + * is different from the others in that its value is sent, not the + * change in value.) Since typical use of SLIP links is biased + * toward small packets (see comments on MTU/MSS below), changes + * use a variable length coding with one octet for numbers in the + * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the + * range 256 - 65535 or 0. (If the change in sequence number or + * ack is more than 65535, an uncompressed packet is sent.) + */ + +/* + * Packet types (must not conflict with IP protocol version) + * + * The top nibble of the first octet is the packet type. There are + * three possible types: IP (not proto TCP or tcp with one of the + * control flags set); uncompressed TCP (a normal IP/TCP packet but + * with the 8-bit protocol field replaced by an 8-bit connection id -- + * this type of packet syncs the sender & receiver); and compressed + * TCP (described above). + * + * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and + * is logically part of the 4-bit "changes" field that follows. Top + * three bits are actual packet type. For backward compatibility + * and in the interest of conserving bits, numbers are chosen so the + * IP protocol version number (4) which normally appears in this nibble + * means "IP packet". + */ + +/* packet types */ +#define TYPE_IP 0x40 +#define TYPE_UNCOMPRESSED_TCP 0x70 +#define TYPE_COMPRESSED_TCP 0x80 +#define TYPE_ERROR 0x00 + +/* Bits in first octet of compressed packet */ +#define NEW_C 0x40 /* flag bits for what changed in a packet */ +#define NEW_I 0x20 +#define NEW_S 0x08 +#define NEW_A 0x04 +#define NEW_W 0x02 +#define NEW_U 0x01 + +/* reserved, special-case values of above */ +#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ +#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ +#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) + +#define TCP_PUSH_BIT 0x10 + + +/* + * "state" data for each active tcp conversation on the wire. This is + * basically a copy of the entire IP/TCP header from the last packet + * we saw from the conversation together with a small identifier + * the transmit & receive ends of the line use to locate saved header. + */ +struct cstate { + struct cstate *cs_next; /* next most recently used state (xmit only) */ + ushort_t cs_hlen; /* size of hdr (receive only) */ + uchar_t cs_id; /* connection # associated with this state */ + uchar_t cs_filler; + union { + char csu_hdr[MAX_HDR]; + struct ip csu_ip; /* ip/tcp hdr from most recent packet */ + } vjcs_u; +}; +#define cs_ip vjcs_u.csu_ip +#define cs_hdr vjcs_u.csu_hdr + +/* + * all the state data for one serial line (we need one of these per line). + */ +struct vjcompress { + struct cstate *last_cs; /* most recently used tstate */ + uchar_t last_recv; /* last rcvd conn. id */ + uchar_t last_xmit; /* last sent conn. id */ + ushort_t flags; +#ifndef VJ_NO_STATS + struct vjstat stats; +#endif + struct cstate tstate[MAX_STATES]; /* xmit connection states */ + struct cstate rstate[MAX_STATES]; /* receive connection states */ +}; + +/* flag values */ +#define VJF_TOSS 1 /* tossing rcvd frames because of input err */ + +extern void vj_compress_init __P((struct vjcompress *comp, int max_state)); +extern uint_t vj_compress_tcp __P((struct ip *ip, uint_t mlen, + struct vjcompress *comp, int compress_cid_flag, + uchar_t **vjhdrp)); +extern void vj_uncompress_err __P((struct vjcompress *comp)); +extern int vj_uncompress_uncomp __P((uchar_t *buf, int buflen, + struct vjcompress *comp)); +extern int vj_uncompress_tcp __P((uchar_t *buf, int buflen, int total_len, + struct vjcompress *comp, uchar_t **hdrp, + uint_t *hlenp)); + +#ifdef __cplusplus +} +#endif + +#endif /* _VJCOMPRESS_H_ */ diff --git a/illumos-x86_64/usr/include/netconfig.h b/illumos-x86_64/usr/include/netconfig.h new file mode 100644 index 00000000..6c089118 --- /dev/null +++ b/illumos-x86_64/usr/include/netconfig.h @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _NETCONFIG_H +#define _NETCONFIG_H + +#include + +#endif /* _NETCONFIG_H */ diff --git a/illumos-x86_64/usr/include/netdb.h b/illumos-x86_64/usr/include/netdb.h new file mode 100644 index 00000000..a7a06405 --- /dev/null +++ b/illumos-x86_64/usr/include/netdb.h @@ -0,0 +1,404 @@ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * BIND 4.9.3: + * + * Copyright (c) 1980, 1983, 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * --Copyright-- + * + * End BIND 4.9.3 + */ + +/* + * Structures returned by network data base library. + * All addresses are supplied in host order, and + * returned in network order (suitable for use in system calls). + */ + +#ifndef _NETDB_H +#define _NETDB_H + +#include +#include +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +#include +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define _PATH_HEQUIV "/etc/hosts.equiv" +#define _PATH_HOSTS "/etc/hosts" +#define _PATH_IPNODES "/etc/inet/ipnodes" +#define _PATH_IPSECALGS "/etc/inet/ipsecalgs" +#define _PATH_NETMASKS "/etc/netmasks" +#define _PATH_NETWORKS "/etc/networks" +#define _PATH_PROTOCOLS "/etc/protocols" +#define _PATH_SERVICES "/etc/services" + +struct hostent { + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ + int h_addrtype; /* host address type */ + int h_length; /* length of address */ + char **h_addr_list; /* list of addresses from name server */ +#define h_addr h_addr_list[0] /* address, for backward compatiblity */ +}; + + +/* + * addrinfo introduced with IPv6 for Protocol-Independent Hostname + * and Service Name Translation. + */ + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME, ... */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ +#ifdef __sparcv9 + int _ai_pad; /* for backwards compat with old size_t */ +#endif /* __sparcv9 */ + socklen_t ai_addrlen; + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; + +/* + * The flag 0x8000 is currently reserved for private use between libnsl and + * libsocket. See lib/libsocket/inet/getaddrinfo.c for more information. + */ +/* addrinfo flags */ +#define AI_PASSIVE 0x0008 /* intended for bind() + listen() */ +#define AI_CANONNAME 0x0010 /* return canonical version of host */ +#define AI_NUMERICHOST 0x0020 /* use numeric node address string */ +#define AI_NUMERICSERV 0x0040 /* servname is assumed numeric */ + +/* getipnodebyname() flags */ +#define AI_V4MAPPED 0x0001 /* IPv4 mapped addresses if no IPv6 */ +#define AI_ALL 0x0002 /* IPv6 and IPv4 mapped addresses */ +#define AI_ADDRCONFIG 0x0004 /* AAAA or A records only if IPv6/IPv4 cnfg'd */ + + +/* + * These were defined in RFC 2553 but not SUSv3 + * or RFC 3493 which obsoleted 2553. + */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG) + +/* addrinfo errors */ +#define EAI_ADDRFAMILY 1 /* address family not supported */ +#define EAI_NODATA 7 /* no address */ +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ +#define EAI_AGAIN 2 /* DNS temporary failure */ +#define EAI_BADFLAGS 3 /* invalid ai_flags */ +#define EAI_FAIL 4 /* DNS non-recoverable failure */ +#define EAI_FAMILY 5 /* ai_family not supported */ +#define EAI_MEMORY 6 /* memory allocation failure */ +#define EAI_NONAME 8 /* host/servname not known */ +#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ +#define EAI_SYSTEM 11 /* system error in errno */ +#define EAI_OVERFLOW 12 /* argument buffer overflow */ +#define EAI_PROTOCOL 13 +#define EAI_MAX 14 + +/* getnameinfo flags */ +#define NI_NOFQDN 0x0001 +#define NI_NUMERICHOST 0x0002 /* return numeric form of address */ +#define NI_NAMEREQD 0x0004 /* request DNS name */ +#define NI_NUMERICSERV 0x0008 +#define NI_DGRAM 0x0010 + +#if !defined(_XPG6) || defined(__EXTENSIONS__) +/* Not listed in any standards document */ +#define NI_WITHSCOPEID 0x0020 +#define NI_NUMERICSCOPE 0x0040 + +/* getnameinfo max sizes as defined in RFC 2553 obsoleted in RFC 3493 */ +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +/* + * Scope delimit character + */ +#define SCOPE_DELIMITER '%' + + +/* + * Algorithm entry for /etc/inet/ipsecalgs which defines IPsec protocols + * and algorithms. + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +typedef struct ipsecalgent { + char **a_names; /* algorithm names */ + int a_proto_num; /* protocol number */ + int a_alg_num; /* algorithm number */ + char *a_mech_name; /* encryption framework mechanism name */ + int *a_block_sizes; /* supported block sizes */ + int *a_key_sizes; /* supported key sizes */ + int a_key_increment; /* key size increment */ + int *a_mech_params; /* mechanism specific parameters */ + int a_alg_flags; /* algorithm flags */ +} ipsecalgent_t; + +/* well-known IPsec protocol numbers */ + +#define IPSEC_PROTO_AH 2 +#define IPSEC_PROTO_ESP 3 +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Assumption here is that a network number + * fits in 32 bits -- probably a poor one. + */ +struct netent { + char *n_name; /* official name of net */ + char **n_aliases; /* alias list */ + int n_addrtype; /* net address type */ + in_addr_t n_net; /* network # */ +}; + +struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol # */ +}; + +struct servent { + char *s_name; /* official service name */ + char **s_aliases; /* alias list */ + int s_port; /* port # */ + char *s_proto; /* protocol to use */ +}; + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +struct hostent *gethostbyname_r + (const char *, struct hostent *, char *, int, int *h_errnop); +struct hostent *gethostbyaddr_r + (const char *, int, int, struct hostent *, char *, int, int *h_errnop); +struct hostent *getipnodebyname(const char *, int, int, int *); +struct hostent *getipnodebyaddr(const void *, size_t, int, int *); +void freehostent(struct hostent *); +struct hostent *gethostent_r(struct hostent *, char *, int, int *h_errnop); + +struct servent *getservbyname_r + (const char *name, const char *, struct servent *, char *, int); +struct servent *getservbyport_r + (int port, const char *, struct servent *, char *, int); +struct servent *getservent_r(struct servent *, char *, int); + +struct netent *getnetbyname_r + (const char *, struct netent *, char *, int); +struct netent *getnetbyaddr_r(long, int, struct netent *, char *, int); +struct netent *getnetent_r(struct netent *, char *, int); + +struct protoent *getprotobyname_r + (const char *, struct protoent *, char *, int); +struct protoent *getprotobynumber_r + (int, struct protoent *, char *, int); +struct protoent *getprotoent_r(struct protoent *, char *, int); + +int getnetgrent_r(char **, char **, char **, char *, int); +int innetgr(const char *, const char *, const char *, const char *); +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* Old interfaces that return a pointer to a static area; MT-unsafe */ +struct hostent *gethostbyname(const char *); +struct hostent *gethostent(void); +struct netent *getnetbyaddr(in_addr_t, int); +struct netent *getnetbyname(const char *); +struct netent *getnetent(void); +struct protoent *getprotobyname(const char *); +struct protoent *getprotobynumber(int); +struct protoent *getprotoent(void); +struct servent *getservbyname(const char *, const char *); +struct servent *getservbyport(int, const char *); +struct servent *getservent(void); + +/* gethostbyaddr() second argument is a size_t only in unix95/unix98 */ +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +struct hostent *gethostbyaddr(const void *, socklen_t, int); +#else +struct hostent *gethostbyaddr(const void *, size_t, int); +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +int endhostent(void); +int endnetent(void); +int endprotoent(void); +int endservent(void); +int sethostent(int); +int setnetent(int); +int setprotoent(int); +int setservent(int); +#else +void endhostent(void); +void endnetent(void); +void endprotoent(void); +void endservent(void); +void sethostent(int); +void setnetent(int); +void setprotoent(int); +void setservent(int); +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) + +#ifdef _XPG6 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getaddrinfo __xnet_getaddrinfo +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define getaddrinfo __xnet_getaddrinfo +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* _XPG6 */ + +int getaddrinfo(const char *_RESTRICT_KYWD, + const char *_RESTRICT_KYWD, + const struct addrinfo *_RESTRICT_KYWD, + struct addrinfo **_RESTRICT_KYWD); +void freeaddrinfo(struct addrinfo *); +const char *gai_strerror(int); +int getnameinfo(const struct sockaddr *_RESTRICT_KYWD, + socklen_t, char *_RESTRICT_KYWD, socklen_t, + char *_RESTRICT_KYWD, socklen_t, int); +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +int getnetgrent(char **, char **, char **); +int setnetgrent(const char *); +int endnetgrent(void); +int rcmd(char **, unsigned short, + const char *, const char *, const char *, int *); +int rcmd_af(char **, unsigned short, + const char *, const char *, const char *, int *, int); +int rresvport_af(int *, int); +int rresvport_addr(int *, struct sockaddr_storage *); +int rexec(char **, unsigned short, + const char *, const char *, const char *, int *); +int rexec_af(char **, unsigned short, + const char *, const char *, const char *, int *, int); +int rresvport(int *); +int ruserok(const char *, int, const char *, const char *); +/* BIND */ +struct hostent *gethostbyname2(const char *, int); +void herror(const char *); +const char *hstrerror(int); +/* End BIND */ + +/* IPsec algorithm prototype definitions */ +struct ipsecalgent *getipsecalgbyname(const char *, int, int *); +struct ipsecalgent *getipsecalgbynum(int, int, int *); +int getipsecprotobyname(const char *doi_name); +char *getipsecprotobynum(int doi_domain); +void freeipsecalgent(struct ipsecalgent *ptr); +/* END IPsec algorithm prototype definitions */ + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Error return codes from gethostbyname() and gethostbyaddr() + * (when using the resolver) + */ + +extern int h_errno; + +#ifdef _REENTRANT +extern int *__h_errno(void); + +/* Only #define h_errno if there is no conflict with other use */ +#ifdef H_ERRNO_IS_FUNCTION +#define h_errno (*__h_errno()) +#endif /* NO_H_ERRNO_DEFINE */ +#endif /* _REENTRANT */ + +/* + * Error return codes from gethostbyname() and gethostbyaddr() + * (left in extern int h_errno). + */ +#define HOST_NOT_FOUND 1 /* Authoritive Answer Host not found */ +#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ +#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ +#define NO_DATA 4 /* Valid name, no data record of requested type */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define NO_ADDRESS NO_DATA /* no address, look for MX record */ + +/* BIND */ +#define NETDB_INTERNAL -1 /* see errno */ +#define NETDB_SUCCESS 0 /* no problem */ +/* End BIND */ + +#define MAXHOSTNAMELEN 256 + +#define MAXALIASES 35 +#define MAXADDRS 35 +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETDB_H */ diff --git a/illumos-x86_64/usr/include/netdir.h b/illumos-x86_64/usr/include/netdir.h new file mode 100644 index 00000000..123aeeea --- /dev/null +++ b/illumos-x86_64/usr/include/netdir.h @@ -0,0 +1,169 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 2016 by Delphix. All rights reserved. + */ +/* Copyright (c) 1992 Sun Microsystems, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * netdir.h + * + * This is the include file that defines various structures and + * constants used by the netdir routines. + */ + +#ifndef _NETDIR_H +#define _NETDIR_H + +/* + * This files uses struct netconfig, and netconfig.h must be included + * before this to avoid warnings. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct nd_addrlist { + int n_cnt; /* number of netbufs */ + struct netbuf *n_addrs; /* the netbufs */ +}; + +struct nd_hostservlist { + int h_cnt; /* number of nd_hostservs */ + struct nd_hostserv *h_hostservs; /* the entries */ +}; + +struct nd_hostserv { + char *h_host; /* the host name */ + char *h_serv; /* the service name */ +}; + +struct nd_mergearg { + char *s_uaddr; /* servers universal address */ + char *c_uaddr; /* clients universal address */ + char *m_uaddr; /* merged universal address */ +}; + +/* + * _nderror is a private variable to the netdir system. + */ +#ifdef _REENTRANT +extern int *__nderror(); +#define _nderror (*(__nderror())) +#else +extern int _nderror; +#endif /* _REENTRANT */ + + +int netdir_options(struct netconfig *, int option, int fd, char *par); +int netdir_getbyname(struct netconfig *, struct nd_hostserv *, + struct nd_addrlist **); +int netdir_getbyaddr(struct netconfig *, struct nd_hostservlist **, + struct netbuf *); +int __netdir_getbyaddr_nosrv(struct netconfig *, struct nd_hostservlist **, + struct netbuf *); +int netdir_mergeaddr(struct netconfig *, char **muaddr, char *uaddr, + char *ruaddr); +void netdir_free(void *, int); +struct netbuf *uaddr2taddr(struct netconfig *, char *); +char *taddr2uaddr(struct netconfig *, struct netbuf *); +void netdir_perror(char *); +char *netdir_sperror(); +struct nd_addrlist *_netdir_getbyname(struct netconfig *, struct nd_hostserv *); +struct nd_hostservlist *_netdir_getbyaddr(struct netconfig *, struct netbuf *); +struct netbuf *_uaddr2taddr(struct netconfig *, char *); +char *_taddr2uaddr(struct netconfig *, struct netbuf *); +char *_netdir_mergeaddr(struct netconfig *, char *uaddr, char *ruaddr); + +/* + * These are all objects that can be freed by netdir_free + */ +#define ND_HOSTSERV 0 +#define ND_HOSTSERVLIST 1 +#define ND_ADDR 2 +#define ND_ADDRLIST 3 + +/* + * These are the various errors that can be encountered while attempting + * to translate names to addresses. Note that none of them (except maybe + * no memory) are truely fatal unless the ntoa deamon is on its last attempt + * to translate the name. First four errors are to failitate return values + * from DNS, that are used by mail and others. + * + * Negative errors terminate the search resolution process, positive errors + * are treated as warnings. + */ + +#define ND_TRY_AGAIN -5 /* Non-Authoritive Host not found, or */ + /* SERVERFAIL */ +#define ND_NO_RECOVERY -4 /* Non recoverable errors, FORMERR, REFUSED, */ + /* NOTIMP */ +#define ND_NO_DATA -3 /* Valid name, no data record of requested */ + /* type */ +#define ND_NO_ADDRESS ND_NO_DATA /* no address, look for MX record */ +#define ND_BADARG -2 /* Bad arguments passed */ +#define ND_NOMEM -1 /* No virtual memory left */ +#define ND_OK 0 /* Translation successful */ +#define ND_NOHOST 1 /* Hostname was not resolvable */ +#define ND_NOSERV 2 /* Service was unknown */ +#define ND_NOSYM 3 /* Couldn't resolve symbol */ +#define ND_OPEN 4 /* File couldn't be opened */ +#define ND_ACCESS 5 /* File is not accessable */ +#define ND_UKNWN 6 /* Unknown object to be freed */ +#define ND_NOCTRL 7 /* Unknown option passed to netdir_options */ +#define ND_FAILCTRL 8 /* Option failed in netdir_options */ +#define ND_SYSTEM 9 /* Other System error */ + +/* + * The following netdir_options commands can be given to the fd. These is + * a way of providing for any transport specific action which the caller + * may want to initiate on its transport. It is up to the trasport provider + * to support the netdir_options it wants to support. + */ + +#define ND_SET_BROADCAST 1 /* Do t_optmgmt to support broadcast */ +#define ND_SET_RESERVEDPORT 2 /* bind it to reserve address */ +#define ND_CHECK_RESERVEDPORT 3 /* check if address is reserved */ +#define ND_MERGEADDR 4 /* Merge universal address */ + +/* + * The following special case host names are used to give the underlying + * transport provides a clue as to the intent of the request. + */ + +#define HOST_SELF "\\1" +#define HOST_ANY "\\2" +#define HOST_BROADCAST "\\3" +#define HOST_SELF_BIND HOST_SELF +#define HOST_SELF_CONNECT "\\4" + +#ifdef __cplusplus +} +#endif + +#endif /* _NETDIR_H */ diff --git a/illumos-x86_64/usr/include/netinet/arp.h b/illumos-x86_64/usr/include/netinet/arp.h new file mode 100644 index 00000000..e0790a81 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/arp.h @@ -0,0 +1,48 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_ARP_H +#define _NETINET_ARP_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + struct ether_addr arp_sha; /* sender hardware address */ + uchar_t arp_spa[4]; /* sender protocol address */ + struct ether_addr arp_tha; /* target hardware address */ + uchar_t arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_ARP_H */ diff --git a/illumos-x86_64/usr/include/netinet/dhcp.h b/illumos-x86_64/usr/include/netinet/dhcp.h new file mode 100644 index 00000000..73b233ad --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/dhcp.h @@ -0,0 +1,234 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2016, Chris Fraire . + */ + +/* + * dhcp.h - Generic DHCP definitions, as per RFC's 2131 and 2132. + */ + +#ifndef _DHCP_H +#define _DHCP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _REENTRANT +#include +#endif /* _REENTRANT */ + +/* + * DHCP option codes. + */ + +#define CD_PAD 0 +#define CD_END 255 +#define CD_SUBNETMASK 1 +#define CD_TIMEOFFSET 2 +#define CD_ROUTER 3 +#define CD_TIMESERV 4 +#define CD_IEN116_NAME_SERV 5 +#define CD_DNSSERV 6 +#define CD_LOG_SERV 7 +#define CD_COOKIE_SERV 8 +#define CD_LPR_SERV 9 +#define CD_IMPRESS_SERV 10 +#define CD_RESOURCE_SERV 11 +#define CD_HOSTNAME 12 +#define CD_BOOT_SIZE 13 +#define CD_DUMP_FILE 14 +#define CD_DNSDOMAIN 15 +#define CD_SWAP_SERV 16 +#define CD_ROOT_PATH 17 +#define CD_EXTEND_PATH 18 + +/* IP layer parameters */ +#define CD_IP_FORWARDING_ON 19 +#define CD_NON_LCL_ROUTE_ON 20 +#define CD_POLICY_FILTER 21 +#define CD_MAXIPSIZE 22 +#define CD_IPTTL 23 +#define CD_PATH_MTU_TIMEOUT 24 +#define CD_PATH_MTU_TABLE_SZ 25 + +/* IP layer parameters per interface */ +#define CD_MTU 26 +#define CD_ALL_SUBNETS_LCL_ON 27 +#define CD_BROADCASTADDR 28 +#define CD_MASK_DISCVRY_ON 29 +#define CD_MASK_SUPPLIER_ON 30 +#define CD_ROUTER_DISCVRY_ON 31 +#define CD_ROUTER_SOLICIT_SERV 32 +#define CD_STATIC_ROUTE 33 + +/* Link Layer Parameters per Interface */ +#define CD_TRAILER_ENCAPS_ON 34 +#define CD_ARP_TIMEOUT 35 +#define CD_ETHERNET_ENCAPS_ON 36 + +/* TCP Parameters */ +#define CD_TCP_TTL 37 +#define CD_TCP_KALIVE_INTVL 38 +#define CD_TCP_KALIVE_GRBG_ON 39 + +/* Application layer parameters */ +#define CD_NIS_DOMAIN 40 +#define CD_NIS_SERV 41 +#define CD_NTP_SERV 42 +#define CD_VENDOR_SPEC 43 + +/* NetBIOS parameters */ +#define CD_NETBIOS_NAME_SERV 44 +#define CD_NETBIOS_DIST_SERV 45 +#define CD_NETBIOS_NODE_TYPE 46 +#define CD_NETBIOS_SCOPE 47 + +/* X Window parameters */ +#define CD_XWIN_FONT_SERV 48 +#define CD_XWIN_DISP_SERV 49 + +/* DHCP protocol extension options */ +#define CD_REQUESTED_IP_ADDR 50 +#define CD_LEASE_TIME 51 +#define CD_OPTION_OVERLOAD 52 +#define CD_DHCP_TYPE 53 +#define CD_SERVER_ID 54 +#define CD_REQUEST_LIST 55 +#define CD_MESSAGE 56 +#define CD_MAX_DHCP_SIZE 57 +#define CD_T1_TIME 58 +#define CD_T2_TIME 59 +#define CD_CLASS_ID 60 +#define CD_CLIENT_ID 61 + +/* Netware options */ +#define CD_NW_IP_DOMAIN 62 +#define CD_NW_IP_OPTIONS 63 + +/* Nisplus options */ +#define CD_NISPLUS_DMAIN 64 +#define CD_NISPLUS_SERVS 65 + +/* Optional sname/bootfile options */ +#define CD_TFTP_SERV_NAME 66 +#define CD_OPT_BOOTFILE_NAME 67 + +/* Additional server options */ +#define CD_MOBILE_IP_AGENT 68 +#define CD_SMTP_SERVS 69 +#define CD_POP3_SERVS 70 +#define CD_NNTP_SERVS 71 +#define CD_WWW_SERVS 72 +#define CD_FINGER_SERVS 73 +#define CD_IRC_SERVS 74 + +/* Streettalk options */ +#define CD_STREETTALK_SERVS 75 +#define CD_STREETTALK_DA_SERVS 76 + +/* User class identifier */ +#define CD_USER_CLASS_ID 77 + +/* Newer options */ + +#define CD_SLPDA 78 +#define CD_SLPSS 79 +#define CD_CLIENTFQDN 81 +#define CD_AGENTOPT 82 + +/* + * Per RFC 3679, option 89 was "Never published as standard and [is] not in + * general use". See active CD_CLIENTFQDN and RFC 4702. + */ +#define CD_FQDN 89 + +#define CD_PXEARCHi 93 +#define CD_PXENIIi 94 +#define CD_PXECID 95 +#define CD_MULTICST 107 + +#define DHCP_FIRST_OPT CD_SUBNETMASK +#define DHCP_LAST_STD CD_MULTICST +#define DHCP_SITE_OPT 128 /* inclusive */ +#define DHCP_END_SITE 254 +#define DHCP_LAST_OPT DHCP_END_SITE /* last op code */ + +#define DHCP_MAX_OPT_SIZE 255 /* maximum option size in octets */ + +/* + * DHCP Packet. What will fit in a ethernet frame. We may use a smaller + * size, based on what our transport can handle. + */ +#define DHCP_DEF_MAX_SIZE 576 /* as spec'ed in RFC 2131 */ +#define PKT_BUFFER 1486 /* max possible size of pkt buffer */ +#define BASE_PKT_SIZE 240 /* everything but the options */ +typedef struct dhcp { + uint8_t op; /* message opcode */ + uint8_t htype; /* Hardware address type */ + uint8_t hlen; /* Hardware address length */ + uint8_t hops; /* Used by relay agents */ + uint32_t xid; /* transaction id */ + uint16_t secs; /* Secs elapsed since client boot */ + uint16_t flags; /* DHCP Flags field */ + struct in_addr ciaddr; /* client IP addr */ + struct in_addr yiaddr; /* 'Your' IP addr. (from server) */ + struct in_addr siaddr; /* Boot server IP addr */ + struct in_addr giaddr; /* Relay agent IP addr */ + uint8_t chaddr[16]; /* Client hardware addr */ + uint8_t sname[64]; /* Optl. boot server hostname */ + uint8_t file[128]; /* boot file name (ascii path) */ + uint8_t cookie[4]; /* Magic cookie */ + uint8_t options[60]; /* Options */ +} PKT; + +typedef uint32_t lease_t; /* DHCP lease time (32 bit quantity) */ + +/* + * DHCP packet types. As per protocol. + */ +#define DISCOVER ((uint8_t)1) +#define OFFER ((uint8_t)2) +#define REQUEST ((uint8_t)3) +#define DECLINE ((uint8_t)4) +#define ACK ((uint8_t)5) +#define NAK ((uint8_t)6) +#define RELEASE ((uint8_t)7) +#define INFORM ((uint8_t)8) + +/* + * Generic DHCP protocol defines + */ +#define DHCP_PERM ((lease_t)0xffffffff) /* "permanent" lease time */ +#define BOOTREQUEST (1) /* BOOTP REQUEST opcode */ +#define BOOTREPLY (2) /* BOOTP REPLY opcode */ +#define BOOTMAGIC { 99, 130, 83, 99 } /* rfc1048 magic cookie */ +#define BCAST_MASK 0x8000 /* BROADCAST flag */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DHCP_H */ diff --git a/illumos-x86_64/usr/include/netinet/dhcp6.h b/illumos-x86_64/usr/include/netinet/dhcp6.h new file mode 100644 index 00000000..64f583da --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/dhcp6.h @@ -0,0 +1,353 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DHCP6_H +#define _DHCP6_H + +/* + * This header file describes constants and on-the-wire data structures used + * with DHCPv6. + * + * Note that the data structures contained here must be used with caution. The + * DHCPv6 protocol generally does not maintain alignment. + * + * (Users may also need to include other header files to get ntohs/htons + * definitions, if the DHCPV6_{GET,SET} macros are used.) + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Message Types + */ +#define DHCPV6_MSG_SOLICIT 1 /* Client sends */ +#define DHCPV6_MSG_ADVERTISE 2 /* Server sends */ +#define DHCPV6_MSG_REQUEST 3 /* Client sends */ +#define DHCPV6_MSG_CONFIRM 4 /* Client sends */ +#define DHCPV6_MSG_RENEW 5 /* Client sends */ +#define DHCPV6_MSG_REBIND 6 /* Client sends */ +#define DHCPV6_MSG_REPLY 7 /* Server sends */ +#define DHCPV6_MSG_RELEASE 8 /* Client sends */ +#define DHCPV6_MSG_DECLINE 9 /* Client sends */ +#define DHCPV6_MSG_RECONFIGURE 10 /* Server sends */ +#define DHCPV6_MSG_INFO_REQ 11 /* Client sends */ +#define DHCPV6_MSG_RELAY_FORW 12 /* Relay agent sends to server */ +#define DHCPV6_MSG_RELAY_REPL 13 /* Server sends to relay agent */ + +/* + * Status Codes + */ +#define DHCPV6_STAT_SUCCESS 0 +#define DHCPV6_STAT_UNSPECFAIL 1 /* Unknown reason */ +#define DHCPV6_STAT_NOADDRS 2 /* Server has no addresses available */ +#define DHCPV6_STAT_NOBINDING 3 /* Client record unavailable */ +#define DHCPV6_STAT_NOTONLINK 4 /* Prefix inappropriate for link */ +#define DHCPV6_STAT_USEMCAST 5 /* Client must use multicast */ +#define DHCPV6_STAT_NOPREFIX 6 /* No prefix available; RFC3633 */ + +/* + * DHCP Unique Identifier (DUID) Types + */ +#define DHCPV6_DUID_LLT 1 /* Link layer address plus time */ +#define DHCPV6_DUID_EN 2 /* Vendor assigned */ +#define DHCPV6_DUID_LL 3 /* Link layer address */ + +/* + * DHCPv6 Option Codes + * Note: options 10 and 35 are not assigned. + */ +#define DHCPV6_OPT_CLIENTID 1 /* Client's DUID */ +#define DHCPV6_OPT_SERVERID 2 /* Server's DUID */ +#define DHCPV6_OPT_IA_NA 3 /* Non-temporary addrs; dhcpv6_ia_na */ +#define DHCPV6_OPT_IA_TA 4 /* Temporary addrs; dhcpv6_ia_ta */ +#define DHCPV6_OPT_IAADDR 5 /* IA Address; dhcpv6_iaaddr */ +#define DHCPV6_OPT_ORO 6 /* Option Request; uint16_t array */ +#define DHCPV6_OPT_PREFERENCE 7 /* Server preference; uint8_t */ +#define DHCPV6_OPT_ELAPSED_TIME 8 /* Client time; uint16_t; centisec */ +#define DHCPV6_OPT_RELAY_MSG 9 /* Relayed client DHCP message */ +#define DHCPV6_OPT_AUTH 11 /* Authentication; dhcpv6_auth */ +#define DHCPV6_OPT_UNICAST 12 /* Client may unicast; in6_addr_t */ +#define DHCPV6_OPT_STATUS_CODE 13 /* Status; uint16_t plus string */ +#define DHCPV6_OPT_RAPID_COMMIT 14 /* Server may do RC; boolean (len 0) */ +#define DHCPV6_OPT_USER_CLASS 15 /* Classes; {uint16_t,uint8_t...}... */ +#define DHCPV6_OPT_VENDOR_CLASS 16 /* Client vendor; uint32_t + list */ +#define DHCPV6_OPT_VENDOR_OPT 17 /* Vendor specific; uint32_t+opts */ +#define DHCPV6_OPT_INTERFACE_ID 18 /* Relay agent interface */ +#define DHCPV6_OPT_RECONF_MSG 19 /* Reconfigure; uint8_t */ +#define DHCPV6_OPT_RECONF_ACC 20 /* Reconfigure accept; boolean */ +#define DHCPV6_OPT_SIP_NAMES 21 /* SIP srv domain names (RFC3319) */ +#define DHCPV6_OPT_SIP_ADDR 22 /* SIP srv IPv6 address (RFC3319) */ +#define DHCPV6_OPT_DNS_ADDR 23 /* DNS Recur. Name Server (RFC3646) */ +#define DHCPV6_OPT_DNS_SEARCH 24 /* Domain Search List (RFC3646) */ +#define DHCPV6_OPT_IA_PD 25 /* Delegate dhcpv6_ia_na (RFC3633) */ +#define DHCPV6_OPT_IAPREFIX 26 /* Prefix dhcpv6_iaprefix (RFC3633) */ +#define DHCPV6_OPT_NIS_SERVERS 27 /* NIS in6_addr_t array (RFC3898) */ +#define DHCPV6_OPT_NIS_DOMAIN 29 /* NIS Domain string (RFC3898) */ +#define DHCPV6_OPT_SNTP_SERVERS 31 /* SNTP in6_addr_t array (RFC4075) */ +#define DHCPV6_OPT_INFO_REFTIME 32 /* Info refresh uint32_t (RFC4242) */ +#define DHCPV6_OPT_BCMCS_SRV_D 33 /* NUL-term string list (RFC4280) */ +#define DHCPV6_OPT_BCMCS_SRV_A 34 /* in6_addr_t array (RFC4280) */ +#define DHCPV6_OPT_GEOCONF_CVC 36 /* dhcpv6_civic_t plus TLVs */ +#define DHCPV6_OPT_REMOTE_ID 37 /* uint32_t plus opaque */ +#define DHCPV6_OPT_SUBSCRIBER 38 /* opaque; may be NVT ASCII */ +#define DHCPV6_OPT_CLIENT_FQDN 39 /* uint8_t plus domain */ + +/* + * Reconfiguration types; used with DHCPV6_OPT_RECONF_MSG option. + */ +#define DHCPV6_RECONF_RENEW 5 /* Renew now */ +#define DHCPV6_RECONF_INFO 11 /* Request information */ + +/* + * FQDN Flags; used with DHCPV6_OPT_CLIENT_FQDN option. + */ +#define DHCPV6_FQDNF_S 0x01 /* Server should perform AAAA RR updates */ +#define DHCPV6_FQDNF_O 0x02 /* Server override of 'S' bit */ +#define DHCPV6_FQDNF_N 0x04 /* Server should not perform any updates */ + +/* + * Miscellany + */ +#define DHCPV6_INFTIME 0xfffffffful /* Infinity; used for timers */ +#define DHCPV6_FOREVER 0xffff /* Used for elapsed time option */ +#define DHCPV6_SUN_ENT 42 /* Sun Microsystems enterprise ID */ + +/* + * Basic DHCPv6 message header used for server/client communications. The + * options follow this header. + */ +struct dhcpv6_message { + uint8_t d6m_msg_type; + uint8_t d6m_transid_ho; + uint16_t d6m_transid_lo; +}; + +#define DHCPV6_GET_TRANSID(msg) \ + (((msg)->d6m_transid_ho << 16) + ntohs((msg)->d6m_transid_lo)) +#define DHCPV6_SET_TRANSID(msg, id) \ + ((msg)->d6m_transid_ho = (id) >> 16, (msg)->d6m_transid_lo = htons(id)) + +/* + * DHCPv6 relay agent header used only for server/relay communications. The + * options follow this header, and the client message is encapsulated as an + * option. Note that the IPv6 addresses are not on natural word boundaries. + */ +struct dhcpv6_relay { + uint8_t d6r_msg_type; + uint8_t d6r_hop_count; + uint8_t d6r_linkaddr[16]; + uint8_t d6r_peeraddr[16]; +}; + +/* + * DHCPv6 generic option header. Note that options are not aligned on any + * convenient boundary. + */ +struct dhcpv6_option { + uint16_t d6o_code; + uint16_t d6o_len; +}; + +/* + * Option header for IA_NA (Non-temporary addresses) and IA_PD (Prefix + * delegation). Contains IA Address options for IA_NA, IA_PD Prefixes for + * IA_PD. + */ +struct dhcpv6_ia_na { + uint16_t d6in_code; + uint16_t d6in_len; + uint32_t d6in_iaid; /* Unique ID [interface] */ + uint32_t d6in_t1; /* Extend from same server */ + uint32_t d6in_t2; /* Extend from any server */ +}; + +/* + * Option header for IA_TA (Temporary addresses). Contains IA Address options. + */ +struct dhcpv6_ia_ta { + uint16_t d6it_code; + uint16_t d6it_len; + uint32_t d6it_iaid; /* Unique ID [interface] */ +}; + +/* + * Option header for IA Address. Must be used inside of an IA_NA or IA_TA + * option. May contain a Status Code option. + */ +struct dhcpv6_iaaddr { + uint16_t d6ia_code; + uint16_t d6ia_len; + in6_addr_t d6ia_addr; /* IPv6 address */ + uint32_t d6ia_preflife; /* Preferred lifetime */ + uint32_t d6ia_vallife; /* Valid lifetime */ +}; + +/* + * Option header for Authentication. Followed by variable-length + * authentication information field. Warning: padding may be present. Use + * defined size. + */ +struct dhcpv6_auth { + uint16_t d6a_code; + uint16_t d6a_len; + uint8_t d6a_proto; /* Protocol */ + uint8_t d6a_alg; /* Algorithm */ + uint8_t d6a_rdm; /* Replay Detection Method (RDM) */ + uint8_t d6a_replay[8]; /* Information for RDM */ +}; +#define DHCPV6_AUTH_SIZE 15 + +/* dhpv6_auth.d6a_proto values */ +#define DHCPV6_PROTO_DELAYED 2 /* Delayed Authentication mechanism */ +#define DHCPV6_PROTO_RECONFIG 3 /* Reconfigure Key mechanism */ + +/* dhpv6_auth.d6a_alg values */ +#define DHCPV6_ALG_HMAC_MD5 1 /* HMAC-MD5 signature */ + +/* dhpv6_auth.d6a_rdm values */ +#define DHCPV6_RDM_MONOCNT 0 /* Monotonic counter */ + +/* + * Option header for IA_PD Prefix. Must be used inside of an IA_PD option. + * May contain a Status Code option. Warning: padding may be present; use + * defined size. + */ +struct dhcpv6_iaprefix { + uint16_t d6ip_code; + uint16_t d6ip_len; + uint32_t d6ip_preflife; /* Preferred lifetime */ + uint32_t d6ip_vallife; /* Valid lifetime */ + uint8_t d6ip_preflen; /* Prefix length */ + uint8_t d6ip_addr[16]; /* IPv6 prefix */ +}; +#define DHCPV6_IAPREFIX_SIZE 29 + +/* + * Option header for Civic Address information. Followed by single octet TLV + * encoded address elements, using CIVICADDR_* values for type. Warning: + * padding may be present; use defined size. + */ +struct dhcpv6_civic { + uint16_t d6c_code; + uint16_t d6c_len; + uint8_t d6c_what; /* DHCPV6_CWHAT_* value */ + char d6c_cc[2]; /* Country code; ISO 3166 */ +}; +#define DHCPV6_CIVIC_SIZE 7 + +#define DHCPV6_CWHAT_SERVER 0 /* Location of server */ +#define DHCPV6_CWHAT_NETWORK 1 /* Location of network */ +#define DHCPV6_CWHAT_CLIENT 2 /* Location of client */ + +#define CIVICADDR_LANG 0 /* Language; RFC 2277 */ +#define CIVICADDR_A1 1 /* National division (state) */ +#define CIVICADDR_A2 2 /* County */ +#define CIVICADDR_A3 3 /* City */ +#define CIVICADDR_A4 4 /* City division */ +#define CIVICADDR_A5 5 /* Neighborhood */ +#define CIVICADDR_A6 6 /* Street group */ +#define CIVICADDR_PRD 16 /* Leading street direction */ +#define CIVICADDR_POD 17 /* Trailing street suffix */ +#define CIVICADDR_STS 18 /* Street suffix or type */ +#define CIVICADDR_HNO 19 /* House number */ +#define CIVICADDR_HNS 20 /* House number suffix */ +#define CIVICADDR_LMK 21 /* Landmark */ +#define CIVICADDR_LOC 22 /* Additional location information */ +#define CIVICADDR_NAM 23 /* Name/occupant */ +#define CIVICADDR_PC 24 /* Postal Code/ZIP */ +#define CIVICADDR_BLD 25 /* Building */ +#define CIVICADDR_UNIT 26 /* Unit/apt/suite */ +#define CIVICADDR_FLR 27 /* Floor */ +#define CIVICADDR_ROOM 28 /* Room number */ +#define CIVICADDR_TYPE 29 /* Place type */ +#define CIVICADDR_PCN 30 /* Postal community name */ +#define CIVICADDR_POBOX 31 /* Post office box */ +#define CIVICADDR_ADDL 32 /* Additional code */ +#define CIVICADDR_SEAT 33 /* Seat/desk */ +#define CIVICADDR_ROAD 34 /* Primary road or street */ +#define CIVICADDR_RSEC 35 /* Road section */ +#define CIVICADDR_RBRA 36 /* Road branch */ +#define CIVICADDR_RSBR 37 /* Road sub-branch */ +#define CIVICADDR_SPRE 38 /* Street name pre-modifier */ +#define CIVICADDR_SPOST 39 /* Street name post-modifier */ +#define CIVICADDR_SCRIPT 128 /* Script */ + +/* + * DHCP Unique Identifier structures. These represent the fixed portion of the + * unique identifier object, and are followed by the variable-length link layer + * address or identifier. + */ +struct duid_llt { + uint16_t dllt_dutype; + uint16_t dllt_hwtype; + uint32_t dllt_time; +}; + +/* DUID time stamps start on January 1st, 2000 UTC */ +#define DUID_TIME_BASE 946684800ul + +struct duid_en { + uint16_t den_dutype; + uint16_t den_entho; + uint16_t den_entlo; +}; + +#define DHCPV6_GET_ENTNUM(den) \ + ((ntohs((den)->den_entho) << 16) + ntohs((den)->den_entlo)) +#define DHCPV6_SET_ENTNUM(den, val) \ + ((den)->den_entho = htons((val) >> 16), (den)->den_entlo = htons(val)) + +struct duid_ll { + uint16_t dll_dutype; + uint16_t dll_hwtype; +}; + +/* + * Data types + */ +typedef struct dhcpv6_message dhcpv6_message_t; +typedef struct dhcpv6_relay dhcpv6_relay_t; +typedef struct dhcpv6_option dhcpv6_option_t; +typedef struct dhcpv6_ia_na dhcpv6_ia_na_t; +typedef struct dhcpv6_ia_ta dhcpv6_ia_ta_t; +typedef struct dhcpv6_iaaddr dhcpv6_iaaddr_t; +typedef struct dhcpv6_auth dhcpv6_auth_t; +typedef struct dhcpv6_iaprefix dhcpv6_iaprefix_t; +typedef struct dhcpv6_civic dhcpv6_civic_t; +typedef struct duid_llt duid_llt_t; +typedef struct duid_en duid_en_t; +typedef struct duid_ll duid_ll_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _DHCP6_H */ diff --git a/illumos-x86_64/usr/include/netinet/icmp6.h b/illumos-x86_64/usr/include/netinet/icmp6.h new file mode 100644 index 00000000..6aed5824 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/icmp6.h @@ -0,0 +1,507 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2024 Bill Sommerfeld + */ + +#ifndef _NETINET_ICMP6_H +#define _NETINET_ICMP6_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Type and code definitions for ICMPv6. + * Based on RFC2292. + */ + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +/* Minimum ICMPv6 header length. */ +#define ICMP6_MINLEN 8 + +typedef struct icmp6_hdr { + uint8_t icmp6_type; /* type field */ + uint8_t icmp6_code; /* code field */ + uint16_t icmp6_cksum; /* checksum field */ + union { + uint32_t icmp6_un_data32[1]; /* type-specific field */ + uint16_t icmp6_un_data16[2]; /* type-specific field */ + uint8_t icmp6_un_data8[4]; /* type-specific field */ + } icmp6_dataun; +} icmp6_t; + +#define icmp6_data32 icmp6_dataun.icmp6_un_data32 +#define icmp6_data16 icmp6_dataun.icmp6_un_data16 +#define icmp6_data8 icmp6_dataun.icmp6_un_data8 +#define icmp6_pptr icmp6_data32[0] /* parameter prob */ +#define icmp6_mtu icmp6_data32[0] /* packet too big */ +#define icmp6_id icmp6_data16[0] /* echo request/reply */ +#define icmp6_seq icmp6_data16[1] /* echo request/reply */ +#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ + +/* Multicast Listener Discovery messages (RFC 3542 (v1), RFC 3810 (v2)). */ + +#define MLD_MINLEN 24 +#define MLD_V2_QUERY_MINLEN 28 + +/* Query Header, common to v1 and v2 */ +typedef struct mld_hdr { + struct icmp6_hdr mld_icmp6_hdr; + struct in6_addr mld_addr; /* multicast address */ +} mld_hdr_t; + +#define mld_type mld_icmp6_hdr.icmp6_type +#define mld_code mld_icmp6_hdr.icmp6_code +#define mld_cksum mld_icmp6_hdr.icmp6_cksum +#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0] +#define mld_reserved mld_icmp6_hdr.icmp6_data16[1] + +/* MLDv2 query */ +typedef struct mld2q { + mld_hdr_t mld2q_hdr; + uint8_t mld2q_sqrv; /* S Flag, Q's Robustness Variable */ + uint8_t mld2q_qqic; /* Querier's Query Interval Code */ + uint16_t mld2q_numsrc; /* number of sources */ +} mld2q_t; + +#define mld2q_type mld2q_hdr.mld_icmp6_hdr.icmp6_type +#define mld2q_code mld2q_hdr.mld_icmp6_hdr.icmp6_code +#define mld2q_cksum mld2q_hdr.mld_icmp6_hdr.icmp6_cksum +#define mld2q_mxrc mld2q_hdr.mld_icmp6_hdr.icmp6_data16[0] +#define mld2q_addr mld2q_hdr.mld_addr + +#define MLD_V2_SFLAG_MASK 0x8 /* mask off s part of sqrv */ +#define MLD_V2_RV_MASK 0x7 /* mask off qrv part of sqrv */ + +/* definitions used to extract max response delay from mrc field */ +#define MLD_V2_MAXRT_FPMIN 0x8000 +#define MLD_V2_MAXRT_MANT_MASK 0x0fff +#define MLD_V2_MAXRT_EXP_MASK 0x7000 + +/* definitions used to extract querier's query interval from qqic field */ +#define MLD_V2_QQI_FPMIN 0x80 +#define MLD_V2_QQI_MANT_MASK 0x0f +#define MLD_V2_QQI_EXP_MASK 0x70 + +/* MLDv2 response */ +typedef icmp6_t mld2r_t; + +#define mld2r_type icmp6_type +#define mld2r_res icmp6_code +#define mld2r_cksum icmp6_cksum +#define mld2r_res1 icmp6_data16[0] +#define mld2r_nummar icmp6_data16[1] + +/* MLDv2 multicast address record */ +typedef struct mld2mar { + uint8_t mld2mar_type; /* type of record */ + uint8_t mld2mar_auxlen; /* auxiliary data length */ + uint16_t mld2mar_numsrc; /* number of sources */ + struct in6_addr mld2mar_group; /* group address being reported */ +} mld2mar_t; + + +/* For router renumbering. */ +struct icmp6_router_renum { /* router renumbering header */ + struct icmp6_hdr rr_hdr; + uint8_t rr_segnum; + uint8_t rr_flags; + uint16_t rr_maxdelay; + uint32_t rr_reserved; +}; + +#define rr_type rr_hdr.icmp6_type +#define rr_code rr_hdr.icmp6_code +#define rr_cksum rr_hdr.icmp6_cksum +#define rr_seqnum rr_hdr.icmp6_data32[0] + +/* Router renumbering flags */ +#define ICMP6_RR_FLAGS_TEST 0x80 +#define ICMP6_RR_FLAGS_REQRESULT 0x40 +#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 +#define ICMP6_RR_FLAGS_SPECSITE 0x10 +#define ICMP6_RR_FLAGS_PREVDONE 0x08 + +struct rr_pco_match { /* match prefix part */ + uint8_t rpm_code; + uint8_t rpm_len; + uint8_t rpm_ordinal; + uint8_t rpm_matchlen; + uint8_t rpm_minlen; + uint8_t rpm_maxlen; + uint16_t rpm_reserved; + struct in6_addr rpm_prefix; +}; + +/* PCO code values */ +#define RPM_PCO_ADD 1 +#define RPM_PCO_CHANGE 2 +#define RPM_PCO_SETGLOBAL 3 + +struct rr_pco_use { /* use prefix part */ + uint8_t rpu_uselen; + uint8_t rpu_keeplen; + uint8_t rpu_ramask; + uint8_t rpu_raflags; + uint32_t rpu_vltime; + uint32_t rpu_pltime; + uint32_t rpu_flags; + struct in6_addr rpu_prefix; +}; + +#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20 +#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10 + +#ifdef _BIG_ENDIAN +#define ICMP_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 +#define ICMP_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 +#else /* _BIG_ENDIAN */ +#define ICMP_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 +#define ICMP_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 +#endif /* _BIG_ENDIAN */ + +struct rr_result { /* router renumbering result message */ + uint16_t rrr_flags; + uint8_t rrr_ordinal; + uint8_t rrr_matchedlen; + uint32_t rrr_ifid; + struct in6_addr rrr_prefix; +}; + +#ifdef _BIG_ENDIAN +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 +#else /* _BIG_ENDIAN */ +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 +#endif /* _BIG_ENDIAN */ + +/* ICMPv6 error types */ +#define ICMP6_DST_UNREACH 1 +#define ICMP6_PACKET_TOO_BIG 2 +#define ICMP6_TIME_EXCEEDED 3 +#define ICMP6_PARAM_PROB 4 + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +/* ICMPv6 query types */ +#define ICMP6_ECHO_REQUEST 128 +#define ICMP6_ECHO_REPLY 129 + +/* + * ICMPv6 group membership types + * ICMP6_MEMBERSHIP* types are the older names for these constants and should + * not be used in new code. + */ +#define MLD_LISTENER_QUERY 130 +#define ICMP6_MEMBERSHIP_QUERY 130 +#define MLD_LISTENER_REPORT 131 +#define ICMP6_MEMBERSHIP_REPORT 131 +#define MLD_LISTENER_REDUCTION 132 +#define ICMP6_MEMBERSHIP_REDUCTION 132 +#define MLD_V2_LISTENER_REPORT 143 + +/* types for neighbor discovery */ +#define ND_ROUTER_SOLICIT 133 +#define ND_ROUTER_ADVERT 134 +#define ND_NEIGHBOR_SOLICIT 135 +#define ND_NEIGHBOR_ADVERT 136 +#define ND_REDIRECT 137 + +/* router renumbering */ +#define ICMP6_ROUTER_RENUMBERING 138 + +#define ICMP6_MAX_INFO_TYPE 138 + +#define ICMP6_IS_ERROR(x) ((x) < 128) + +/* codes for ICMP6_DST_UNREACH */ +#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ +#define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */ + /* administratively prohibited */ +#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor */ +#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source */ +#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ +#define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */ + +/* codes for ICMP6_TIME_EXCEEDED */ +#define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */ +#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */ + +/* codes for ICMP6_PARAM_PROB */ +#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ +#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */ +#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */ + +/* Default MLD max report delay value */ +#define ICMP6_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ + /* query (in seconds) */ + +typedef struct nd_router_solicit { /* router solicitation */ + icmp6_t nd_rs_hdr; + /* could be followed by options */ +} nd_router_solicit_t; + +#define nd_rs_type nd_rs_hdr.icmp6_type +#define nd_rs_code nd_rs_hdr.icmp6_code +#define nd_rs_cksum nd_rs_hdr.icmp6_cksum +#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] + +typedef struct nd_router_advert { /* router advertisement */ + icmp6_t nd_ra_hdr; + uint32_t nd_ra_reachable; /* reachable time */ + uint32_t nd_ra_retransmit; /* retransmit timer */ + /* could be followed by options */ +} nd_router_advert_t; + +#define nd_ra_type nd_ra_hdr.icmp6_type +#define nd_ra_code nd_ra_hdr.icmp6_code +#define nd_ra_cksum nd_ra_hdr.icmp6_cksum +#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] +#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] + +#define ND_RA_FLAG_OTHER 0x40 +#define ND_RA_FLAG_MANAGED 0x80 + +#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] + +typedef struct nd_neighbor_solicit { /* neighbor solicitation */ + icmp6_t nd_ns_hdr; + struct in6_addr nd_ns_target; /* target address */ + /* could be followed by options */ +} nd_neighbor_solicit_t; + +#define nd_ns_type nd_ns_hdr.icmp6_type +#define nd_ns_code nd_ns_hdr.icmp6_code +#define nd_ns_cksum nd_ns_hdr.icmp6_cksum +#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] + +typedef struct nd_neighbor_advert { /* neighbor advertisement */ + icmp6_t nd_na_hdr; + struct in6_addr nd_na_target; /* target address */ + /* could be followed by options */ +} nd_neighbor_advert_t; + +#define nd_na_type nd_na_hdr.icmp6_type +#define nd_na_code nd_na_hdr.icmp6_code +#define nd_na_cksum nd_na_hdr.icmp6_cksum + +#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] + +/* + * The first three bits of the flgs_reserved field of the ND structure are + * defined in this order: + * Router flag + * Solicited flag + * Override flag + */ + +/* Save valuable htonl() cycles on little-endian boxen. */ + +#ifdef _BIG_ENDIAN + +#define ND_NA_FLAG_ROUTER 0x80000000 +#define ND_NA_FLAG_SOLICITED 0x40000000 +#define ND_NA_FLAG_OVERRIDE 0x20000000 + +#else /* _BIG_ENDIAN */ + +#define ND_NA_FLAG_ROUTER 0x80 +#define ND_NA_FLAG_SOLICITED 0x40 +#define ND_NA_FLAG_OVERRIDE 0x20 + +#endif /* _BIG_ENDIAN */ + +typedef struct nd_redirect { /* redirect */ + icmp6_t nd_rd_hdr; + struct in6_addr nd_rd_target; /* target address */ + struct in6_addr nd_rd_dst; /* destination address */ + /* could be followed by options */ +} nd_redirect_t; + +#define nd_rd_type nd_rd_hdr.icmp6_type +#define nd_rd_code nd_rd_hdr.icmp6_code +#define nd_rd_cksum nd_rd_hdr.icmp6_cksum +#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] + +typedef struct nd_opt_hdr { /* Neighbor discovery option header */ + uint8_t nd_opt_type; + uint8_t nd_opt_len; /* in units of 8 octets */ + /* followed by option specific data */ +} nd_opt_hdr_t; + +/* Neighbor discovery option types */ +#define ND_OPT_SOURCE_LINKADDR 1 +#define ND_OPT_TARGET_LINKADDR 2 +#define ND_OPT_PREFIX_INFORMATION 3 +#define ND_OPT_REDIRECTED_HEADER 4 +#define ND_OPT_MTU 5 +#define ND_OPT_DNS_RESOLVER 25 +#define ND_OPT_DNS_SEARCHLIST 31 + +typedef struct nd_opt_prefix_info { /* prefix information */ + uint8_t nd_opt_pi_type; + uint8_t nd_opt_pi_len; + uint8_t nd_opt_pi_prefix_len; + uint8_t nd_opt_pi_flags_reserved; + uint32_t nd_opt_pi_valid_time; + uint32_t nd_opt_pi_preferred_time; + uint32_t nd_opt_pi_reserved2; + struct in6_addr nd_opt_pi_prefix; +} nd_opt_prefix_info_t; + +#define ND_OPT_PI_FLAG_AUTO 0x40 +#define ND_OPT_PI_FLAG_ONLINK 0x80 + +typedef struct nd_opt_rd_hdr { /* redirected header */ + uint8_t nd_opt_rh_type; + uint8_t nd_opt_rh_len; + uint16_t nd_opt_rh_reserved1; + uint32_t nd_opt_rh_reserved2; + /* followed by IP header and data */ +} nd_opt_rd_hdr_t; + +typedef struct nd_opt_mtu { /* MTU option */ + uint8_t nd_opt_mtu_type; + uint8_t nd_opt_mtu_len; + uint16_t nd_opt_mtu_reserved; + uint32_t nd_opt_mtu_mtu; +} nd_opt_mtu_t; + +/* Note: the option is variable length (at least 8 bytes long) */ +#ifndef ND_MAX_HDW_LEN +#define ND_MAX_HDW_LEN 64 +#endif +struct nd_opt_lla { + uint8_t nd_opt_lla_type; + uint8_t nd_opt_lla_len; /* in units of 8 octets */ + uint8_t nd_opt_lla_hdw_addr[ND_MAX_HDW_LEN]; +}; + +struct nd_opt_dns_resolver { + uint8_t nd_opt_dnsr_type; + uint8_t nd_opt_dnsr_len; /* in units of 8 octets */ + uint16_t nd_opt_dnsr_reserved; + uint32_t nd_opt_dnsr_lifetime; + struct in6_addr nd_opt_dnsr_addr[]; +}; + +struct nd_opt_dns_sl { + uint8_t nd_opt_dnss_type; + uint8_t nd_opt_dnss_len; /* in units of 8 octets */ + uint16_t nd_opt_dnss_reserved; + uint32_t nd_opt_dnss_lifetime; + uint8_t nd_opt_dnss_names[]; +}; + +/* Neighbor discovery protocol constants */ + +/* Router constants */ +#define ND_MAX_INITIAL_RTR_ADVERT_INTERVAL 16000 /* milliseconds */ +#define ND_MAX_INITIAL_RTR_ADVERTISEMENTS 3 /* transmissions */ +#define ND_MAX_FINAL_RTR_ADVERTISEMENTS 3 /* transmissions */ +#define ND_MIN_DELAY_BETWEEN_RAS 3000 /* milliseconds */ +#define ND_MAX_RA_DELAY_TIME 500 /* milliseconds */ + +/* Host constants */ +#define ND_MAX_RTR_SOLICITATION_DELAY 1000 /* milliseconds */ +#define ND_RTR_SOLICITATION_INTERVAL 4000 /* milliseconds */ +#define ND_MAX_RTR_SOLICITATIONS 3 /* transmissions */ + +/* Node constants */ +#define ND_MAX_MULTICAST_SOLICIT 3 /* transmissions */ +#define ND_MAX_UNICAST_SOLICIT 3 /* transmissions */ +#define ND_MAX_ANYCAST_DELAY_TIME 1000 /* milliseconds */ +#define ND_MAX_NEIGHBOR_ADVERTISEMENT 3 /* transmissions */ +#define ND_REACHABLE_TIME 30000 /* milliseconds */ +#define ND_RETRANS_TIMER 1000 /* milliseconds */ +#define ND_DELAY_FIRST_PROBE_TIME 5000 /* milliseconds */ +#define ND_MIN_RANDOM_FACTOR .5 +#define ND_MAX_RANDOM_FACTOR 1.5 + +#define ND_MAX_REACHTIME 3600000 /* milliseconds */ +#define ND_MAX_REACHRETRANSTIME 100000 /* milliseconds */ + +/* + * ICMPv6 type filtering for IPPROTO_ICMPV6 ICMP6_FILTER socket option + */ +#define ICMP6_FILTER 0x01 /* Set filter */ + +typedef struct icmp6_filter { + uint32_t __icmp6_filt[8]; +} icmp6_filter_t; + +/* Pass all ICMPv6 messages to the application */ +#define ICMP6_FILTER_SETPASSALL(filterp) ( \ + ((filterp)->__icmp6_filt[0] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[1] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[2] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[3] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[4] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[5] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[6] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[7] = 0xFFFFFFFFU)) + +/* ICMPv6 messages are blocked from being passed to the application */ +#define ICMP6_FILTER_SETBLOCKALL(filterp) ( \ + ((filterp)->__icmp6_filt[0] = 0x0), \ + ((filterp)->__icmp6_filt[1] = 0x0), \ + ((filterp)->__icmp6_filt[2] = 0x0), \ + ((filterp)->__icmp6_filt[3] = 0x0), \ + ((filterp)->__icmp6_filt[4] = 0x0), \ + ((filterp)->__icmp6_filt[5] = 0x0), \ + ((filterp)->__icmp6_filt[6] = 0x0), \ + ((filterp)->__icmp6_filt[7] = 0x0)) + +/* Pass messages of a given type to the application */ +#define ICMP6_FILTER_SETPASS(type, filterp) \ + ((((filterp)->__icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))) + +/* Block messages of a given type from being passed to the application */ +#define ICMP6_FILTER_SETBLOCK(type, filterp) \ + ((((filterp)->__icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))) + +/* Test if message of a given type will be passed to an application */ +#define ICMP6_FILTER_WILLPASS(type, filterp) \ + ((((filterp)->__icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) + +/* + * Test if message of a given type will blocked from + * being passed to an application + */ +#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ + ((((filterp)->__icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) + +#define ICMP_IOC_DEFAULT_Q (('I' << 8) + 51) + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_ICMP6_H */ diff --git a/illumos-x86_64/usr/include/netinet/icmp_var.h b/illumos-x86_64/usr/include/netinet/icmp_var.h new file mode 100644 index 00000000..b24be322 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/icmp_var.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Variables related to this implementation + * of the internet control message protocol. + */ + +#ifndef _NETINET_ICMP_VAR_H +#define _NETINET_ICMP_VAR_H + +/* icmp_var.h 1.10 88/08/19 SMI; from UCB 7.2 1/13/87 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct icmpstat { +/* statistics related to icmp packets generated */ + int icps_error; /* # of calls to icmp_error */ + int icps_oldshort; /* no error 'cuz old ip too short */ + int icps_oldicmp; /* no error 'cuz old was icmp */ + int icps_outhist[ICMP_MAXTYPE + 1]; +/* statistics related to input messages processed */ + int icps_badcode; /* icmp_code out of range */ + int icps_tooshort; /* packet < ICMP_MINLEN */ + int icps_checksum; /* bad checksum */ + int icps_badlen; /* calculated bound mismatch */ + int icps_reflect; /* number of responses */ + int icps_inhist[ICMP_MAXTYPE + 1]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_ICMP_VAR_H */ diff --git a/illumos-x86_64/usr/include/netinet/if_ether.h b/illumos-x86_64/usr/include/netinet/if_ether.h new file mode 100644 index 00000000..eded1c50 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/if_ether.h @@ -0,0 +1,120 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +#ifndef _NETINET_IF_ETHER_H +#define _NETINET_IF_ETHER_H + +/* if_ether.h 1.28 89/08/04 SMI; from UCB 7.2 12/7/87 */ + +#include + +/* + * The following include is for compatibility with SunOS 3.x and + * 4.3bsd. Newly written programs should include it separately. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + ether_addr_t arp_sha; /* sender hardware address */ + uchar_t arp_spa[4]; /* sender protocol address */ + ether_addr_t arp_tha; /* target hardware address */ + uchar_t arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +/* + * multicast address structure + * + * Keep a reference count for each multicast address so + * addresses loaded into chip are unique. + */ +struct mcaddr { + struct ether_addr mc_enaddr; /* multicast address */ + ushort_t mc_count; /* reference count */ +}; +#define MCADDRMAX 64 /* multicast addr table length */ +#define MCCOUNTMAX 4096 /* multicast addr max reference count */ + +/* + * Structure shared between the ethernet driver modules and + * the address resolution code. For example, each ec_softc or il_softc + * begins with this structure. + * + * The structure contains a pointer to an array of multicast addresses. + * This pointer is NULL until the first successful SIOCADDMULTI ioctl + * is issued for the interface. + */ +struct arpcom { + struct ifnet ac_if; /* network-visible interface */ + struct ether_addr ac_enaddr; /* ethernet hardware address */ + struct in_addr ac_ipaddr; /* copy of ip address- XXX */ + struct mcaddr *ac_mcaddr; /* table of multicast addrs */ + ushort_t ac_nmcaddr; /* count of M/C addrs in use */ + struct in_addr ac_lastip; /* cache of last ARP lookup */ + struct ether_addr ac_lastarp; /* result of the last ARP */ +}; + +/* + * Internet to ethernet address resolution table. + */ +struct arptab { + struct in_addr at_iaddr; /* internet address */ + union { + struct ether_addr atu_enaddr; /* ethernet address */ + long atu_tvsec; /* timestamp if incomplete */ + } at_union; + uchar_t at_timer; /* minutes since last reference */ + uchar_t at_flags; /* flags */ + struct mbuf *at_hold; /* last packet until resolved/timeout */ +}; + +#define at_enaddr at_union.atu_enaddr +#define at_tvsec at_union.atu_tvsec + +/* + * Copy IP addresses from a to b - assumes that the two given + * pointers can be referenced as shorts. On architectures + * where this is not the case, use bcopy instead. + */ +#if defined(__sparc) || defined(__i386) || defined(__amd64) +#define ip_copy(a, b) { ((short *)b)[0] = ((short *)a)[0]; \ + ((short *)b)[1] = ((short *)a)[1]; } +#else +#define ip_copy(a, b) (bcopy((caddr_t)a, (caddr_t)b, 4)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IF_ETHER_H */ diff --git a/illumos-x86_64/usr/include/netinet/igmp.h b/illumos-x86_64/usr/include/netinet/igmp.h new file mode 100644 index 00000000..332bd78b --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/igmp.h @@ -0,0 +1,197 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _NETINET_IGMP_H +#define _NETINET_IGMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Internet Group Management Protocol (IGMP) definitions. + * + * Written by Steve Deering, Stanford, May 1988. + * Modified by Rosen Sharma, Stanford, Aug 1994 + * Modified by Bill Fenner, Xerox PARC, April 1995 + * + * MULTICAST 3.5.1.1 + */ + +/* + * IGMP packet format. + */ +struct igmp { + uchar_t igmp_type; /* version & type of IGMP message */ + uchar_t igmp_code; /* code for routing sub-msgs */ + ushort_t igmp_cksum; /* IP-style checksum */ + struct in_addr igmp_group; /* group address being reported */ +}; /* (zero for queries) */ + +/* IGMPv3 Membership Report common header */ +struct igmp3r { + uchar_t igmp3r_type; /* version & type of IGMP message */ + uchar_t igmp3r_code; /* code for routing sub-msgs */ + ushort_t igmp3r_cksum; /* IP-style checksum */ + ushort_t igmp3r_res; /* Reserved */ + ushort_t igmp3r_numrec; /* Number of group records */ +}; + +/* IGMPv3 Group Record header */ +struct grphdr { + uchar_t grphdr_type; /* type of record */ + uchar_t grphdr_auxlen; /* auxiliary data length */ + ushort_t grphdr_numsrc; /* number of sources */ + struct in_addr grphdr_group; /* group address being reported */ +}; + +/* IGMPv3 Membership Query header */ +struct igmp3q { + uchar_t igmp3q_type; /* type of IGMP message */ + uchar_t igmp3q_mxrt; /* maximum response time */ + ushort_t igmp3q_cksum; /* IP-style checksum */ + struct in_addr igmp3q_group; /* group address being queried */ + ushort_t igmp3q_res; /* reserved */ + ushort_t igmp3q_numsrc; /* number of sources */ +}; + +#ifdef _KERNEL +typedef struct igmp_s { + uint8_t igmp_type; /* version & type of IGMP message */ + uint8_t igmp_code; /* code for routing sub-msgs */ + uint8_t igmp_cksum[2]; /* IP-style checksum */ + uint8_t igmp_group[4]; /* group address being reported */ +} igmp_t; /* (zero for queries) */ + +/* Aligned igmp header */ +typedef struct igmpa_s { + uint8_t igmpa_type; /* version & type of IGMP message */ + uint8_t igmpa_code; /* code for routing sub-msgs */ + uint16_t igmpa_cksum; /* IP-style checksum */ + ipaddr_t igmpa_group; /* group address being reported */ +} igmpa_t; /* (zero for queries) */ + +/* Aligned IGMPv3 Membership Report common header */ +typedef struct igmp3ra_s { + uint8_t igmp3ra_type; /* version & type of IGMP message */ + uint8_t igmp3ra_res; /* Reserved */ + uint16_t igmp3ra_cksum; /* IP-style checksum */ + uint16_t igmp3ra_res1; /* Reserved */ + uint16_t igmp3ra_numrec; /* Number of group records */ +} igmp3ra_t; + +/* Aligned IGMPv3 Group Record header */ +typedef struct grphdra_s { + uint8_t grphdra_type; /* type of record */ + uint8_t grphdra_auxlen; /* auxiliary data length */ + uint16_t grphdra_numsrc; /* number of sources */ + ipaddr_t grphdra_group; /* group addrss being reported */ +} grphdra_t; + +/* Aligned IGMpv3 Membership Query header */ +typedef struct igmp3qa_s { + uint8_t igmp3qa_type; /* type of IGMP message */ + uint8_t igmp3qa_mxrc; /* maximum response code */ + uint16_t igmp3qa_cksum; /* IP-style checksum */ + ipaddr_t igmp3qa_group; /* group address being queried */ + uint8_t igmp3qa_sqrv; /* S Flag, Q's Robustness Variable */ + uint8_t igmp3qa_qqic; /* Querier's Query Interval Code */ + uint16_t igmp3qa_numsrc; /* number of sources */ +} igmp3qa_t; + +#endif /* _KERNEL */ + + +#define IGMP_MINLEN 8 +#define IGMP_V3_QUERY_MINLEN 12 + + +/* + * Message types, including version number. + */ + +#define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */ +#define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Vers.1 membership report */ +#define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Vers.2 membership report */ +#define IGMP_V3_MEMBERSHIP_REPORT 0x22 /* Vers.3 membership report */ +#define IGMP_V2_LEAVE_GROUP 0x17 /* Leave-group message */ +#define IGMP_DVMRP 0x13 /* DVMRP routing message */ +#define IGMP_PIM 0x14 /* PIM routing message */ + +#define IGMP_MTRACE_RESP 0x1e /* traceroute resp to sender */ +#define IGMP_MTRACE 0x1f /* mcast traceroute messages */ + +#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ + /* query (in seconds) */ + /* according to RFC1112 */ + +#define IGMP_V3_MAXRT_FPMIN 0x80 /* max resp code fp format */ +#define IGMP_V3_MAXRT_MANT_MASK 0x0f +#define IGMP_V3_MAXRT_EXP_MASK 0x70 + +#define IGMP_V3_SFLAG_MASK 0x8 /* mask off s part of sqrv */ +#define IGMP_V3_RV_MASK 0x7 /* mask off qrv part of sqrv */ + +#define IGMP_V3_QQI_FPMIN 0x80 /* qqi code fp format */ +#define IGMP_V3_QQI_MANT_MASK 0x0f +#define IGMP_V3_QQI_EXP_MASK 0x70 + +/* + * IGMPv3/MLDv2-specific definitions + */ +/* + * Group Record Types. The values of these enums match the Record Type + * field values defined in RFCs 3376 and 3810 for IGMPv3 and MLDv2 reports. + */ +typedef enum { + MODE_IS_INCLUDE = 1, + MODE_IS_EXCLUDE, + CHANGE_TO_INCLUDE, + CHANGE_TO_EXCLUDE, + ALLOW_NEW_SOURCES, + BLOCK_OLD_SOURCES +} mcast_record_t; + +/* Router Alert Option */ +#define RTRALERT_LEN 4 +#define RTRALERT_LEN_IN_WORDS 1 + +/* + * The following four defininitions are for backwards compatibility. + * They should be removed as soon as all applications are updated to + * use the new constant names. + */ +#define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY +#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT +#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT +#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IGMP_H */ diff --git a/illumos-x86_64/usr/include/netinet/igmp_var.h b/illumos-x86_64/usr/include/netinet/igmp_var.h new file mode 100644 index 00000000..aa85c2c8 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/igmp_var.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NETINET_IGMP_VAR_H +#define _NETINET_IGMP_VAR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Internet Group Management Protocol (IGMP), + * implementation-specific definitions. + * + * Written by Steve Deering, Stanford, May 1988. + * Modified by Ajit Thyagarajan, PARC, August 1994. + * + * MULTICAST 3.5.1.1 + */ + +struct igmpstat { + uint_t igps_rcv_total; /* total IGMP messages received */ + uint_t igps_rcv_tooshort; /* received with too few bytes */ + uint_t igps_rcv_badsum; /* received with bad checksum */ + uint_t igps_rcv_queries; /* received membership queries */ + uint_t igps_rcv_badqueries; /* received invalid queries */ + uint_t igps_rcv_reports; /* received membership reports */ + uint_t igps_rcv_badreports; /* received invalid reports */ + uint_t igps_rcv_ourreports; /* received reports for our groups */ + uint_t igps_snd_reports; /* sent membership reports */ +}; + +#ifdef _KERNEL +/* + * slowtimo interval used for both IGMP and MLD + */ +#define MCAST_SLOWTIMO_INTERVAL 10000 /* milliseconds */ + + +/* + * Macro to compute a random timer value between 1 and maxticks. + * Include for random_get_pseudo_bytes() declaration. + */ +#include +#define MCAST_RANDOM_DELAY(timer, maxticks) \ + /* uint_t timer; int maxticks */ \ + (void) random_get_pseudo_bytes((uint8_t *)&(timer), sizeof (uint_t)); \ + (timer) = ((uint_t)(timer) % (maxticks)) + 1 + +/* + * States for IGMPv2's leave processing + */ +#define IGMP_OTHERMEMBER 0 +#define IGMP_IREPORTEDLAST 1 + +/* + * We must remember what version the subnet's querier is. + */ +#define IGMP_V1_ROUTER 0 +#define IGMP_V2_ROUTER 1 +#define IGMP_V3_ROUTER 2 + +/* + * Map MLD versions to corresponding IGMP versions + */ +#define MLD_V1_ROUTER IGMP_V2_ROUTER +#define MLD_V2_ROUTER IGMP_V3_ROUTER + +/* + * Default values for various IGMPv3/MLDv2 values + */ +#define MCAST_DEF_ROBUSTNESS 2 +#define MCAST_QUERY_RESP_INTERVAL 10 /* in seconds */ +#define MCAST_DEF_QUERY_INTERVAL 125 /* in seconds */ +#define MCAST_DEF_QUERY_RESP_INTERVAL 100 /* in tenths of secs */ +#define MCAST_DEF_UNSOL_RPT_INTERVAL 1 /* in seconds */ + +/* + * IGMP and MLD mandate a TTL/Hop Limit of 1 for protocol messages + */ +#define IGMP_TTL 1 +#define MLD_HOP_LIMIT 1 + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IGMP_VAR_H */ diff --git a/illumos-x86_64/usr/include/netinet/in.h b/illumos-x86_64/usr/include/netinet/in.h new file mode 100644 index 00000000..b4554c6b --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/in.h @@ -0,0 +1,1344 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright 2015, Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2024 Oxide Computer Company + */ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +/* + * Constants and structures defined by the internet system, + * according to following documents + * + * Internet ASSIGNED NUMBERS (RFC1700) and its successors: + * http://www.iana.org/assignments/protocol-numbers + * http://www.iana.org/assignments/port-numbers + * Basic Socket Interface Extensions for IPv6 (RFC2133 and its successors) + * + */ + +#ifndef _NETINET_IN_H +#define _NETINET_IN_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifndef _SOCKLEN_T +#define _SOCKLEN_T + +/* + * The socklen definitions are reproduced here from sys/socket.h so as to + * not introduce that namespace into existing users of netinet/in.h. + */ +#if defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) +typedef size_t socklen_t; +#else +typedef uint32_t socklen_t; +#endif /* defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) */ + +#if defined(_XPG4_2) || defined(_BOOT) +typedef socklen_t *Psocklen_t; +#else +typedef void *Psocklen_t; +#endif /* defined(_XPG4_2) || defined(_BOOT) */ + +#endif /* _SOCKLEN_T */ + +/* + * Symbols such as htonl() are required to be exposed through this file, + * per XNS Issue 5. This is achieved by inclusion of + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) || defined(_XPG5) +#include +#endif + +#ifndef _IN_PORT_T +#define _IN_PORT_T +typedef uint16_t in_port_t; +#endif + +/* + * Note: IPv4 address data structures usage conventions. + * The "in_addr_t" type below (required by Unix standards) + * is NOT a typedef of "struct in_addr" and violates the usual + * conventions where "struct " and _t are corresponding + * typedefs. + * To minimize confusion, kernel data structures/usage prefers use + * of "ipaddr_t" as atomic uint32_t type and avoid using "in_addr_t" + * The user level APIs continue to follow the historic popular + * practice of using "struct in_addr". + */ +#ifndef _IN_ADDR_T +#define _IN_ADDR_T +typedef uint32_t in_addr_t; +#endif + +#ifndef _IPADDR_T +#define _IPADDR_T +typedef uint32_t ipaddr_t; +#endif + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) + +struct in6_addr { + union { + /* + * Note: Static initalizers of "union" type assume + * the constant on the RHS is the type of the first member + * of union. + * To make static initializers (and efficient usage) work, + * the order of members exposed to user and kernel view of + * this data structure is different. + * User environment sees specified uint8_t type as first + * member whereas kernel sees most efficient type as + * first member. + */ +#ifdef _KERNEL + uint32_t _S6_u32[4]; /* IPv6 address */ + uint16_t _S6_u16[8]; /* IPv6 address */ + uint8_t _S6_u8[16]; /* IPv6 address */ +#else + uint8_t _S6_u8[16]; /* IPv6 address */ + uint16_t _S6_u16[8]; /* IPv6 address */ + uint32_t _S6_u32[4]; /* IPv6 address */ +#endif + uint32_t __S6_align; /* Align on 32 bit boundary */ + } _S6_un; +}; +#define s6_addr _S6_un._S6_u8 + +#ifdef _KERNEL +#define s6_addr8 _S6_un._S6_u8 +#define s6_addr16 _S6_un._S6_u16 +#define s6_addr32 _S6_un._S6_u32 +#endif + +typedef struct in6_addr in6_addr_t; + +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +#ifndef _SA_FAMILY_T +#define _SA_FAMILY_T +typedef uint16_t sa_family_t; +#endif + +/* + * Protocols + * + * Some of these constant names are copied for the DTrace IP provider in + * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept + * in sync. + */ +#define IPPROTO_IP 0 /* dummy for IP */ +#define IPPROTO_HOPOPTS 0 /* Hop by hop header for IPv6 */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#define IPPROTO_IGMP 2 /* group control protocol */ +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ +#define IPPROTO_ENCAP 4 /* IP in IP encapsulation */ +#define IPPROTO_TCP 6 /* tcp */ +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_UDP 17 /* user datagram protocol */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_IPV6 41 /* IPv6 encapsulated in IP */ +#define IPPROTO_ROUTING 43 /* Routing header for IPv6 */ +#define IPPROTO_FRAGMENT 44 /* Fragment header for IPv6 */ +#define IPPROTO_RSVP 46 /* rsvp */ +#define IPPROTO_ESP 50 /* IPsec Encap. Sec. Payload */ +#define IPPROTO_AH 51 /* IPsec Authentication Hdr. */ +#define IPPROTO_ICMPV6 58 /* ICMP for IPv6 */ +#define IPPROTO_NONE 59 /* No next header for IPv6 */ +#define IPPROTO_DSTOPTS 60 /* Destination options */ +#define IPPROTO_HELLO 63 /* "hello" routing protocol */ +#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ +#define IPPROTO_EON 80 /* ISO clnp */ +#define IPPROTO_OSPF 89 /* OSPF */ +#define IPPROTO_PIM 103 /* PIM routing protocol */ +#define IPPROTO_SCTP 132 /* Stream Control */ + /* Transmission Protocol */ +#define IPPROTO_MH 135 /* Mobility EH */ +#define IPPROTO_HIP 139 /* Host Identity Protocol */ +#define IPPROTO_SHIM6 140 /* Shim6 Protocol */ + +#define IPPROTO_RAW 255 /* raw IP packet */ +#define IPPROTO_MAX 256 + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define PROTO_SDP 257 /* Sockets Direct Protocol */ +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Port/socket numbers: network standard functions + * + * Entries should exist here for each port number compiled into an ON + * component, such as snoop. + */ +#define IPPORT_ECHO 7 +#define IPPORT_DISCARD 9 +#define IPPORT_SYSTAT 11 +#define IPPORT_DAYTIME 13 +#define IPPORT_NETSTAT 15 +#define IPPORT_CHARGEN 19 +#define IPPORT_FTP 21 +#define IPPORT_TELNET 23 +#define IPPORT_SMTP 25 +#define IPPORT_TIMESERVER 37 +#define IPPORT_NAMESERVER 42 +#define IPPORT_WHOIS 43 +#define IPPORT_DOMAIN 53 +#define IPPORT_MDNS 5353 +#define IPPORT_MTP 57 + +/* + * Port/socket numbers: host specific functions + */ +#define IPPORT_BOOTPS 67 +#define IPPORT_BOOTPC 68 +#define IPPORT_TFTP 69 +#define IPPORT_RJE 77 +#define IPPORT_FINGER 79 +#define IPPORT_HTTP 80 +#define IPPORT_HTTP_ALT 8080 +#define IPPORT_TTYLINK 87 +#define IPPORT_SUPDUP 95 +#define IPPORT_NTP 123 +#define IPPORT_NETBIOS_NS 137 +#define IPPORT_NETBIOS_DGM 138 +#define IPPORT_NETBIOS_SSN 139 +#define IPPORT_LDAP 389 +#define IPPORT_SLP 427 +#define IPPORT_MIP 434 +#define IPPORT_SMB 445 /* a.k.a. microsoft-ds */ +#define IPPORT_VXLAN 4789 + +/* + * Internet Key Exchange (IKE) ports + */ +#define IPPORT_IKE 500 +#define IPPORT_IKE_NATT 4500 + +/* + * UNIX TCP sockets + */ +#define IPPORT_EXECSERVER 512 +#define IPPORT_LOGINSERVER 513 +#define IPPORT_CMDSERVER 514 +#define IPPORT_PRINTER 515 +#define IPPORT_EFSSERVER 520 + +/* + * UNIX UDP sockets + */ +#define IPPORT_BIFFUDP 512 +#define IPPORT_WHOSERVER 513 +#define IPPORT_SYSLOG 514 +#define IPPORT_TALK 517 +#define IPPORT_ROUTESERVER 520 +#define IPPORT_RIPNG 521 + +/* + * DHCPv6 UDP ports + */ +#define IPPORT_DHCPV6C 546 +#define IPPORT_DHCPV6S 547 + +#define IPPORT_SOCKS 1080 + +/* + * Ports < IPPORT_RESERVED are reserved for + * privileged processes (e.g. root). + * Ports > IPPORT_USERRESERVED are reserved + * for servers, not necessarily privileged. + */ +#define IPPORT_RESERVED 1024 +#define IPPORT_USERRESERVED 5000 + +#ifdef _KERNEL +#define IPPORT_DYNAMIC_MIN 49152 +#define IPPORT_DYNAMIC_MAX 65535 +#endif + +/* + * Link numbers + */ +#define IMPLINK_IP 155 +#define IMPLINK_LOWEXPER 156 +#define IMPLINK_HIGHEXPER 158 + +/* + * IPv4 Internet address + * This definition contains obsolete fields for compatibility + * with SunOS 3.x and 4.2bsd. The presence of subnets renders + * divisions into fixed fields misleading at best. New code + * should use only the s_addr field. + */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define _S_un_b S_un_b +#define _S_un_w S_un_w +#define _S_addr S_addr +#define _S_un S_un +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +struct in_addr { + union { + struct { uint8_t s_b1, s_b2, s_b3, s_b4; } _S_un_b; + struct { uint16_t s_w1, s_w2; } _S_un_w; +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + uint32_t _S_addr; +#else + in_addr_t _S_addr; +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + } _S_un; +#define s_addr _S_un._S_addr /* should be used for all code */ +#define s_host _S_un._S_un_b.s_b2 /* OBSOLETE: host on imp */ +#define s_net _S_un._S_un_b.s_b1 /* OBSOLETE: network */ +#define s_imp _S_un._S_un_w.s_w2 /* OBSOLETE: imp */ +#define s_impno _S_un._S_un_b.s_b4 /* OBSOLETE: imp # */ +#define s_lh _S_un._S_un_b.s_b3 /* OBSOLETE: logical host */ +}; + +/* + * Definitions of bits in internet address integers. + * On subnets, the decomposition of addresses to host and net parts + * is done according to subnet mask, not the masks here. + * + * Note that with the introduction of CIDR, IN_CLASSA, IN_CLASSB, + * IN_CLASSC, IN_CLASSD and IN_CLASSE macros have become "de-facto + * obsolete". IN_MULTICAST macro should be used to test if a address + * is a multicast address. + */ +#define IN_CLASSA(i) (((i) & 0x80000000U) == 0) +#define IN_CLASSA_NET 0xff000000U +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffffU +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(i) (((i) & 0xc0000000U) == 0x80000000U) +#define IN_CLASSB_NET 0xffff0000U +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffffU +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(i) (((i) & 0xe0000000U) == 0xc0000000U) +#define IN_CLASSC_NET 0xffffff00U +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0x000000ffU + +#define IN_CLASSD(i) (((i) & 0xf0000000U) == 0xe0000000U) +#define IN_CLASSD_NET 0xf0000000U /* These aren't really */ +#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ +#define IN_CLASSD_HOST 0x0fffffffU /* routing needn't know */ + +#define IN_CLASSE(i) (((i) & 0xf0000000U) == 0xf0000000U) +#define IN_CLASSE_NET 0xffffffffU + +#define IN_MULTICAST(i) IN_CLASSD(i) + +/* + * We have removed CLASS E checks from the kernel + * But we preserve these defines for userland in order + * to avoid compile breakage of some 3rd party piece of software + */ +#ifndef _KERNEL +#define IN_EXPERIMENTAL(i) (((i) & 0xe0000000U) == 0xe0000000U) +#define IN_BADCLASS(i) (((i) & 0xf0000000U) == 0xf0000000U) +#endif + +#define INADDR_ANY 0x00000000U +#define INADDR_LOOPBACK 0x7F000001U +#define INADDR_BROADCAST 0xffffffffU /* must be masked */ +#define INADDR_NONE 0xffffffffU + +#define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */ +#define INADDR_ALLRPTS_GROUP 0xe0000016U /* 224.0.0.22, IGMPv3 */ +#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */ + +/* Scoped IPv4 prefixes (in host byte-order) */ +#define IN_AUTOCONF_NET 0xa9fe0000U /* 169.254/16 */ +#define IN_AUTOCONF_MASK 0xffff0000U +#define IN_PRIVATE8_NET 0x0a000000U /* 10/8 */ +#define IN_PRIVATE8_MASK 0xff000000U +#define IN_PRIVATE12_NET 0xac100000U /* 172.16/12 */ +#define IN_PRIVATE12_MASK 0xfff00000U +#define IN_PRIVATE16_NET 0xc0a80000U /* 192.168/16 */ +#define IN_PRIVATE16_MASK 0xffff0000U + +/* RFC 3927 IPv4 link local address (i in host byte-order) */ +#define IN_LINKLOCAL(i) (((i) & IN_AUTOCONF_MASK) == IN_AUTOCONF_NET) + +/* Well known 6to4 Relay Router Anycast address defined in RFC 3068 */ +#if !defined(_XPG4_2) || !defined(__EXTENSIONS__) +#define INADDR_6TO4RRANYCAST 0xc0586301U /* 192.88.99.1 */ +#endif /* !defined(_XPG4_2) || !defined(__EXTENSIONS__) */ + +#define IN_LOOPBACKNET 127 /* official! */ + +/* + * Define a macro to stuff the loopback address into an Internet address + */ +#if !defined(_XPG4_2) || !defined(__EXTENSIONS__) +#define IN_SET_LOOPBACK_ADDR(a) \ + { (a)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); \ + (a)->sin_family = AF_INET; } +#endif /* !defined(_XPG4_2) || !defined(__EXTENSIONS__) */ + +/* + * IPv4 Socket address. + */ +struct sockaddr_in { + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + char sin_zero[8]; +#else + unsigned char sin_zero[8]; +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ +}; + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +/* + * IPv6 socket address. + */ +struct sockaddr_in6 { + sa_family_t sin6_family; + in_port_t sin6_port; + uint32_t sin6_flowinfo; + struct in6_addr sin6_addr; + uint32_t sin6_scope_id; /* Depends on scope of sin6_addr */ + uint32_t __sin6_src_id; /* Impl. specific - UDP replies */ +}; + +/* + * Macros for accessing the traffic class and flow label fields from + * sin6_flowinfo. + * These are designed to be applied to a 32-bit value. + */ +#ifdef _BIG_ENDIAN + +/* masks */ +#define IPV6_FLOWINFO_FLOWLABEL 0x000fffffU +#define IPV6_FLOWINFO_TCLASS 0x0ff00000U + +#else /* _BIG_ENDIAN */ + +/* masks */ +#define IPV6_FLOWINFO_FLOWLABEL 0xffff0f00U +#define IPV6_FLOWINFO_TCLASS 0x0000f00fU + +#endif /* _BIG_ENDIAN */ + +/* + * Note: Macros IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT are for + * use as RHS of Static initializers of "struct in6_addr" (or in6_addr_t) + * only. They need to be different for User/Kernel versions because union + * component data structure is defined differently (it is identical at + * binary representation level). + * + * const struct in6_addr IN6ADDR_ANY_INIT; + * const struct in6_addr IN6ADDR_LOOPBACK_INIT; + */ + + +#ifdef _KERNEL +#define IN6ADDR_ANY_INIT { 0, 0, 0, 0 } + +#ifdef _BIG_ENDIAN +#define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0x00000001U } +#else /* _BIG_ENDIAN */ +#define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0x01000000U } +#endif /* _BIG_ENDIAN */ + +#else + +#define IN6ADDR_ANY_INIT { 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0 } + +#define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0x1U } +#endif /* _KERNEL */ + +/* + * RFC 2553 specifies the following macros. Their type is defined + * as "int" in the RFC but they only have boolean significance + * (zero or non-zero). For the purposes of our comment notation, + * we assume a hypothetical type "bool" defined as follows to + * write the prototypes assumed for macros in our comments better. + * + * typedef int bool; + */ + +/* + * IN6 macros used to test for special IPv6 addresses + * (Mostly from spec) + * + * bool IN6_IS_ADDR_UNSPECIFIED (const struct in6_addr *); + * bool IN6_IS_ADDR_LOOPBACK (const struct in6_addr *); + * bool IN6_IS_ADDR_MULTICAST (const struct in6_addr *); + * bool IN6_IS_ADDR_LINKLOCAL (const struct in6_addr *); + * bool IN6_IS_ADDR_SITELOCAL (const struct in6_addr *); + * bool IN6_IS_ADDR_V4MAPPED (const struct in6_addr *); + * bool IN6_IS_ADDR_V4MAPPED_ANY(const struct in6_addr *); -- Not from RFC2553 + * bool IN6_IS_ADDR_V4COMPAT (const struct in6_addr *); + * bool IN6_IS_ADDR_MC_RESERVED (const struct in6_addr *); -- Not from RFC2553 + * bool IN6_IS_ADDR_MC_NODELOCAL(const struct in6_addr *); + * bool IN6_IS_ADDR_MC_LINKLOCAL(const struct in6_addr *); + * bool IN6_IS_ADDR_MC_SITELOCAL(const struct in6_addr *); + * bool IN6_IS_ADDR_MC_ORGLOCAL (const struct in6_addr *); + * bool IN6_IS_ADDR_MC_GLOBAL (const struct in6_addr *); + * bool IN6_IS_ADDR_6TO4 (const struct in6_addr *); -- Not from RFC2553 + * bool IN6_ARE_6TO4_PREFIX_EQUAL(const struct in6_addr *, + * const struct in6_addr *); -- Not from RFC2553 + * bool IN6_IS_ADDR_LINKSCOPE (const struct in6addr *); -- Not from RFC2553 + */ + +#define IN6_IS_ADDR_UNSPECIFIED(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0) && \ + ((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_LOOPBACK(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0x00000001) && \ + ((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_LOOPBACK(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0x01000000) && \ + ((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MULTICAST(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff000000) == 0xff000000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MULTICAST(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x000000ff) == 0x000000ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_LINKLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xffc00000) == 0xfe800000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_LINKLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x0000c0ff) == 0x000080fe) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_SITELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xffc00000) == 0xfec00000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_SITELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x0000c0ff) == 0x0000c0fe) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_V4MAPPED(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_V4MAPPED(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#endif /* _BIG_ENDIAN */ + +/* + * IN6_IS_ADDR_V4MAPPED_ANY - A IPv4 mapped INADDR_ANY + * Note: This macro is currently NOT defined in RFC2553 specification + * and not a standard macro that portable applications should use. + */ +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_V4MAPPED_ANY(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0) && \ + ((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_V4MAPPED_ANY(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0) && \ + ((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#endif /* _BIG_ENDIAN */ + +/* Exclude loopback and unspecified address */ +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_V4COMPAT(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0) && \ + !((addr)->_S6_un._S6_u32[3] == 0) && \ + !((addr)->_S6_un._S6_u32[3] == 0x00000001)) + +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_V4COMPAT(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0) && \ + !((addr)->_S6_un._S6_u32[3] == 0) && \ + !((addr)->_S6_un._S6_u32[3] == 0x01000000)) +#endif /* _BIG_ENDIAN */ + +/* + * Note: + * IN6_IS_ADDR_MC_RESERVED macro is currently NOT defined in RFC2553 + * specification and not a standard macro that portable applications + * should use. + */ +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_RESERVED(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff000000) + +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_RESERVED(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000000ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_NODELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff010000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_NODELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000001ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_LINKLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff020000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_LINKLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000002ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_SITELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff050000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_SITELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000005ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_ORGLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff080000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_ORGLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000008ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_GLOBAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff0e0000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_GLOBAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x00000eff) +#endif /* _BIG_ENDIAN */ + +/* + * The IN6_IS_ADDR_MC_SOLICITEDNODE macro is not defined in any standard or + * RFC, and shouldn't be used by portable applications. It is used to see + * if an address is a solicited-node multicast address, which is prefixed + * with ff02:0:0:0:0:1:ff00::/104. + */ +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_SOLICITEDNODE(addr) \ + (((addr)->_S6_un._S6_u32[0] == 0xff020000) && \ + ((addr)->_S6_un._S6_u32[1] == 0x00000000) && \ + ((addr)->_S6_un._S6_u32[2] == 0x00000001) && \ + (((addr)->_S6_un._S6_u32[3] & 0xff000000) == 0xff000000)) +#else +#define IN6_IS_ADDR_MC_SOLICITEDNODE(addr) \ + (((addr)->_S6_un._S6_u32[0] == 0x000002ff) && \ + ((addr)->_S6_un._S6_u32[1] == 0x00000000) && \ + ((addr)->_S6_un._S6_u32[2] == 0x01000000) && \ + (((addr)->_S6_un._S6_u32[3] & 0x000000ff) == 0x000000ff)) +#endif + +/* + * Macros to a) test for 6to4 IPv6 address, and b) to test if two + * 6to4 addresses have the same /48 prefix, and, hence, are from the + * same 6to4 site. + */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_6TO4(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xffff0000) == 0x20020000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_6TO4(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x0000ffff) == 0x00000220) +#endif /* _BIG_ENDIAN */ + +#define IN6_ARE_6TO4_PREFIX_EQUAL(addr1, addr2) \ + (((addr1)->_S6_un._S6_u32[0] == (addr2)->_S6_un._S6_u32[0]) && \ + ((addr1)->_S6_un._S6_u8[4] == (addr2)->_S6_un._S6_u8[4]) && \ + ((addr1)->_S6_un._S6_u8[5] == (addr2)->_S6_un._S6_u8[5])) + +/* + * IN6_IS_ADDR_LINKSCOPE + * Identifies an address as being either link-local, link-local multicast or + * node-local multicast. All types of addresses are considered to be unique + * within the scope of a given link. + */ +#define IN6_IS_ADDR_LINKSCOPE(addr) \ + (IN6_IS_ADDR_LINKLOCAL(addr) || IN6_IS_ADDR_MC_LINKLOCAL(addr) || \ + IN6_IS_ADDR_MC_NODELOCAL(addr)) + +/* + * Useful utility macros for operations with IPv6 addresses + * Note: These macros are NOT defined in the RFC2553 or any other + * standard specification and are not standard macros that portable + * applications should use. + */ + +/* + * IN6_V4MAPPED_TO_INADDR + * IN6_V4MAPPED_TO_IPADDR + * Assign a IPv4-Mapped IPv6 address to an IPv4 address. + * Note: These macros are NOT defined in RFC2553 or any other standard + * specification and are not macros that portable applications should + * use. + * + * void IN6_V4MAPPED_TO_INADDR(const in6_addr_t *v6, struct in_addr *v4); + * void IN6_V4MAPPED_TO_IPADDR(const in6_addr_t *v6, ipaddr_t v4); + * + */ +#define IN6_V4MAPPED_TO_INADDR(v6, v4) \ + ((v4)->s_addr = (v6)->_S6_un._S6_u32[3]) +#define IN6_V4MAPPED_TO_IPADDR(v6, v4) \ + ((v4) = (v6)->_S6_un._S6_u32[3]) + +/* + * IN6_INADDR_TO_V4MAPPED + * IN6_IPADDR_TO_V4MAPPED + * Assign a IPv4 address address to an IPv6 address as a IPv4-mapped + * address. + * Note: These macros are NOT defined in RFC2553 or any other standard + * specification and are not macros that portable applications should + * use. + * + * void IN6_INADDR_TO_V4MAPPED(const struct in_addr *v4, in6_addr_t *v6); + * void IN6_IPADDR_TO_V4MAPPED(const ipaddr_t v4, in6_addr_t *v6); + * + */ +#ifdef _BIG_ENDIAN +#define IN6_INADDR_TO_V4MAPPED(v4, v6) \ + ((v6)->_S6_un._S6_u32[3] = (v4)->s_addr, \ + (v6)->_S6_un._S6_u32[2] = 0x0000ffff, \ + (v6)->_S6_un._S6_u32[1] = 0, \ + (v6)->_S6_un._S6_u32[0] = 0) +#define IN6_IPADDR_TO_V4MAPPED(v4, v6) \ + ((v6)->_S6_un._S6_u32[3] = (v4), \ + (v6)->_S6_un._S6_u32[2] = 0x0000ffff, \ + (v6)->_S6_un._S6_u32[1] = 0, \ + (v6)->_S6_un._S6_u32[0] = 0) +#else /* _BIG_ENDIAN */ +#define IN6_INADDR_TO_V4MAPPED(v4, v6) \ + ((v6)->_S6_un._S6_u32[3] = (v4)->s_addr, \ + (v6)->_S6_un._S6_u32[2] = 0xffff0000U, \ + (v6)->_S6_un._S6_u32[1] = 0, \ + (v6)->_S6_un._S6_u32[0] = 0) +#define IN6_IPADDR_TO_V4MAPPED(v4, v6) \ + ((v6)->_S6_un._S6_u32[3] = (v4), \ + (v6)->_S6_un._S6_u32[2] = 0xffff0000U, \ + (v6)->_S6_un._S6_u32[1] = 0, \ + (v6)->_S6_un._S6_u32[0] = 0) +#endif /* _BIG_ENDIAN */ + +/* + * IN6_6TO4_TO_V4ADDR + * Extract the embedded IPv4 address from the prefix to a 6to4 IPv6 + * address. + * Note: This macro is NOT defined in RFC2553 or any other standard + * specification and is not a macro that portable applications should + * use. + * Note: we don't use the IPADDR form of the macro because we need + * to do a bytewise copy; the V4ADDR in the 6to4 address is not + * 32-bit aligned. + * + * void IN6_6TO4_TO_V4ADDR(const in6_addr_t *v6, struct in_addr *v4); + * + */ +#define IN6_6TO4_TO_V4ADDR(v6, v4) \ + ((v4)->_S_un._S_un_b.s_b1 = (v6)->_S6_un._S6_u8[2], \ + (v4)->_S_un._S_un_b.s_b2 = (v6)->_S6_un._S6_u8[3], \ + (v4)->_S_un._S_un_b.s_b3 = (v6)->_S6_un._S6_u8[4], \ + (v4)->_S_un._S_un_b.s_b4 = (v6)->_S6_un._S6_u8[5]) + +/* + * IN6_V4ADDR_TO_6TO4 + * Given an IPv4 address and an IPv6 address for output, a 6to4 address + * will be created from the IPv4 Address. + * Note: This method for creating 6to4 addresses is not standardized + * outside of Solaris. The newly created 6to4 address will be of the form + * 2002::::, where SUBNETID will equal 0 and + * HOSTID will equal 1. + * + * void IN6_V4ADDR_TO_6TO4(const struct in_addr *v4, in6_addr_t *v6) + * + */ +#ifdef _BIG_ENDIAN +#define IN6_V4ADDR_TO_6TO4(v4, v6) \ + ((v6)->_S6_un._S6_u8[0] = 0x20, \ + (v6)->_S6_un._S6_u8[1] = 0x02, \ + (v6)->_S6_un._S6_u8[2] = (v4)->_S_un._S_un_b.s_b1, \ + (v6)->_S6_un._S6_u8[3] = (v4)->_S_un._S_un_b.s_b2, \ + (v6)->_S6_un._S6_u8[4] = (v4)->_S_un._S_un_b.s_b3, \ + (v6)->_S6_un._S6_u8[5] = (v4)->_S_un._S_un_b.s_b4, \ + (v6)->_S6_un._S6_u8[6] = 0, \ + (v6)->_S6_un._S6_u8[7] = 0, \ + (v6)->_S6_un._S6_u32[2] = 0, \ + (v6)->_S6_un._S6_u32[3] = 0x00000001U) +#else +#define IN6_V4ADDR_TO_6TO4(v4, v6) \ + ((v6)->_S6_un._S6_u8[0] = 0x20, \ + (v6)->_S6_un._S6_u8[1] = 0x02, \ + (v6)->_S6_un._S6_u8[2] = (v4)->_S_un._S_un_b.s_b1, \ + (v6)->_S6_un._S6_u8[3] = (v4)->_S_un._S_un_b.s_b2, \ + (v6)->_S6_un._S6_u8[4] = (v4)->_S_un._S_un_b.s_b3, \ + (v6)->_S6_un._S6_u8[5] = (v4)->_S_un._S_un_b.s_b4, \ + (v6)->_S6_un._S6_u8[6] = 0, \ + (v6)->_S6_un._S6_u8[7] = 0, \ + (v6)->_S6_un._S6_u32[2] = 0, \ + (v6)->_S6_un._S6_u32[3] = 0x01000000U) +#endif /* _BIG_ENDIAN */ + +/* + * IN6_ARE_ADDR_EQUAL (defined in RFC2292) + * Compares if IPv6 addresses are equal. + * Note: Compares in order of high likelyhood of a miss so we minimize + * compares. (Current heuristic order, compare in reverse order of + * uint32_t units) + * + * bool IN6_ARE_ADDR_EQUAL(const struct in6_addr *, + * const struct in6_addr *); + */ +#define IN6_ARE_ADDR_EQUAL(addr1, addr2) \ + (((addr1)->_S6_un._S6_u32[3] == (addr2)->_S6_un._S6_u32[3]) && \ + ((addr1)->_S6_un._S6_u32[2] == (addr2)->_S6_un._S6_u32[2]) && \ + ((addr1)->_S6_un._S6_u32[1] == (addr2)->_S6_un._S6_u32[1]) && \ + ((addr1)->_S6_un._S6_u32[0] == (addr2)->_S6_un._S6_u32[0])) + +/* + * IN6_ARE_PREFIXEDADDR_EQUAL (not defined in RFCs) + * Compares if prefixed parts of IPv6 addresses are equal. + * + * uint32_t IN6_MASK_FROM_PREFIX(int, int); + * bool IN6_ARE_PREFIXEDADDR_EQUAL(const struct in6_addr *, + * const struct in6_addr *, + * int); + */ +#define IN6_MASK_FROM_PREFIX(qoctet, prefix) \ + ((((qoctet) + 1) * 32 < (prefix)) ? 0xFFFFFFFFu : \ + ((((qoctet) * 32) >= (prefix)) ? 0x00000000u : \ + 0xFFFFFFFFu << (((qoctet) + 1) * 32 - (prefix)))) + +#define IN6_ARE_PREFIXEDADDR_EQUAL(addr1, addr2, prefix) \ + (((ntohl((addr1)->_S6_un._S6_u32[0]) & \ + IN6_MASK_FROM_PREFIX(0, prefix)) == \ + (ntohl((addr2)->_S6_un._S6_u32[0]) & \ + IN6_MASK_FROM_PREFIX(0, prefix))) && \ + ((ntohl((addr1)->_S6_un._S6_u32[1]) & \ + IN6_MASK_FROM_PREFIX(1, prefix)) == \ + (ntohl((addr2)->_S6_un._S6_u32[1]) & \ + IN6_MASK_FROM_PREFIX(1, prefix))) && \ + ((ntohl((addr1)->_S6_un._S6_u32[2]) & \ + IN6_MASK_FROM_PREFIX(2, prefix)) == \ + (ntohl((addr2)->_S6_un._S6_u32[2]) & \ + IN6_MASK_FROM_PREFIX(2, prefix))) && \ + ((ntohl((addr1)->_S6_un._S6_u32[3]) & \ + IN6_MASK_FROM_PREFIX(3, prefix)) == \ + (ntohl((addr2)->_S6_un._S6_u32[3]) & \ + IN6_MASK_FROM_PREFIX(3, prefix)))) + +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + + +/* + * Options for use with [gs]etsockopt at the IP level. + * + * Note: Some of the IP_ namespace has conflict with and + * and is exposed through . (It also requires exposing + * options not implemented). The options with potential + * for conflicts use #ifndef guards. + */ +#ifndef IP_OPTIONS +#define IP_OPTIONS 1 /* set/get IP per-packet options */ +#endif + +#define IP_HDRINCL 2 /* int; header is included with data (raw) */ + +#ifndef IP_TOS +#define IP_TOS 3 /* int; IP type of service and precedence */ +#endif + +#ifndef IP_TTL +#define IP_TTL 4 /* int; IP time to live */ +#endif + +#define IP_RECVOPTS 0x5 /* int; receive all IP options w/datagram */ +#define IP_RECVRETOPTS 0x6 /* int; receive IP options for response */ +#define IP_RECVDSTADDR 0x7 /* int; receive IP dst addr w/datagram */ +#define IP_RETOPTS 0x8 /* ip_opts; set/get IP per-packet options */ +#define IP_RECVIF 0x9 /* int; receive the inbound interface index */ +#define IP_RECVSLLA 0xa /* sockaddr_dl; get source link layer address */ +#define IP_RECVTTL 0xb /* uint8_t; get TTL for inbound packet */ +#define IP_RECVTOS 0xc /* uint8_t; get TOS for inbound packet */ + +#define IP_MULTICAST_IF 0x10 /* set/get IP multicast interface */ +#define IP_MULTICAST_TTL 0x11 /* set/get IP multicast timetolive */ +#define IP_MULTICAST_LOOP 0x12 /* set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 0x13 /* add an IP group membership */ +#define IP_DROP_MEMBERSHIP 0x14 /* drop an IP group membership */ +#define IP_BLOCK_SOURCE 0x15 /* block mcast pkts from source */ +#define IP_UNBLOCK_SOURCE 0x16 /* unblock mcast pkts from source */ +#define IP_ADD_SOURCE_MEMBERSHIP 0x17 /* add mcast group/source pair */ +#define IP_DROP_SOURCE_MEMBERSHIP 0x18 /* drop mcast group/source pair */ +#define IP_NEXTHOP 0x19 /* send directly to next hop */ +/* + * IP_PKTINFO and IP_RECVPKTINFO have same value. Size of argument passed in + * is used to differentiate b/w the two. + */ +#define IP_PKTINFO 0x1a /* specify src address and/or index */ +#define IP_RECVPKTINFO 0x1a /* recv dest/matched addr and index */ +#define IP_DONTFRAG 0x1b /* don't fragment packets */ +#define IP_MINTTL 0x1c /* minimum acceptable TTL */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * Different preferences that can be requested from IPSEC protocols. + */ +#define IP_SEC_OPT 0x22 /* Used to set IPSEC options */ +#define IPSEC_PREF_NEVER 0x01 +#define IPSEC_PREF_REQUIRED 0x02 +#define IPSEC_PREF_UNIQUE 0x04 +/* + * This can be used with the setsockopt() call to set per socket security + * options. When the application uses per-socket API, we will reflect + * the request on both outbound and inbound packets. + */ + +typedef struct ipsec_req { + uint_t ipsr_ah_req; /* AH request */ + uint_t ipsr_esp_req; /* ESP request */ + uint_t ipsr_self_encap_req; /* Self-Encap request */ + uint8_t ipsr_auth_alg; /* Auth algs for AH */ + uint8_t ipsr_esp_alg; /* Encr algs for ESP */ + uint8_t ipsr_esp_auth_alg; /* Auth algs for ESP */ +} ipsec_req_t; + +/* + * MCAST_* options are protocol-independent. The actual definitions + * are with the v6 options below; this comment is here to note the + * namespace usage. + * + * #define MCAST_JOIN_GROUP 0x29 + * #define MCAST_LEAVE_GROUP 0x2a + * #define MCAST_BLOCK_SOURCE 0x2b + * #define MCAST_UNBLOCK_SOURCE 0x2c + * #define MCAST_JOIN_SOURCE_GROUP 0x2d + * #define MCAST_LEAVE_SOURCE_GROUP 0x2e + */ +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * SunOS private (potentially not portable) IP_ option names + */ +#define IP_BOUND_IF 0x41 /* bind socket to an ifindex */ +#define IP_UNSPEC_SRC 0x42 /* use unspecified source address */ +#define IP_BROADCAST_TTL 0x43 /* use specific TTL for broadcast */ +/* can be reused 0x44 */ +#define IP_DHCPINIT_IF 0x45 /* accept all unicast DHCP traffic */ + +/* + * Option values and names (when !_XPG5) shared with + */ +#ifndef IP_REUSEADDR +#define IP_REUSEADDR 0x104 +#endif + +#ifndef IP_DONTROUTE +#define IP_DONTROUTE 0x105 +#endif + +#ifndef IP_BROADCAST +#define IP_BROADCAST 0x106 +#endif + +/* + * The following option values are reserved by + * + * T_IP_OPTIONS 0x107 - IP per-packet options + * T_IP_TOS 0x108 - IP per packet type of service + */ + +/* + * Default value constants for multicast attributes controlled by + * IP*_MULTICAST_LOOP and IP*_MULTICAST_{TTL,HOPS} options. + */ +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. + */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Argument structure for IP_BLOCK_SOURCE, IP_UNBLOCK_SOURCE, + * IP_ADD_SOURCE_MEMBERSHIP, and IP_DROP_SOURCE_MEMBERSHIP. + */ +struct ip_mreq_source { + struct in_addr imr_multiaddr; /* IP address of group */ + struct in_addr imr_sourceaddr; /* IP address of source */ + struct in_addr imr_interface; /* IP address of interface */ +}; + +/* + * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP on + * IPv6 addresses. + */ +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast addr */ + unsigned int ipv6mr_interface; /* interface index */ +}; + +/* + * Use #pragma pack() construct to force 32-bit alignment on amd64. + * This is needed to keep the structure size and offsets consistent + * between a 32-bit app and the 64-bit amd64 kernel in structures + * where 64-bit alignment would create gaps (in this case, structures + * which have a uint32_t followed by a struct sockaddr_storage). + */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* + * Argument structure for MCAST_JOIN_GROUP and MCAST_LEAVE_GROUP. + */ +struct group_req { + uint32_t gr_interface; /* interface index */ + struct sockaddr_storage gr_group; /* group address */ +}; + +/* + * Argument structure for MCAST_BLOCK_SOURCE, MCAST_UNBLOCK_SOURCE, + * MCAST_JOIN_SOURCE_GROUP, MCAST_LEAVE_SOURCE_GROUP. + */ +struct group_source_req { + uint32_t gsr_interface; /* interface index */ + struct sockaddr_storage gsr_group; /* group address */ + struct sockaddr_storage gsr_source; /* source address */ +}; + +/* + * Argument for SIOC[GS]MSFILTER ioctls + */ +struct group_filter { + uint32_t gf_interface; /* interface index */ + struct sockaddr_storage gf_group; /* multicast address */ + uint32_t gf_fmode; /* filter mode */ + uint32_t gf_numsrc; /* number of sources */ + struct sockaddr_storage gf_slist[1]; /* source address */ +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#define GROUP_FILTER_SIZE(numsrc) \ + (sizeof (struct group_filter) - sizeof (struct sockaddr_storage) \ + + (numsrc) * sizeof (struct sockaddr_storage)) + +/* + * Argument for SIOC[GS]IPMSFILTER ioctls (IPv4-specific) + */ +struct ip_msfilter { + struct in_addr imsf_multiaddr; /* IP multicast address of group */ + struct in_addr imsf_interface; /* local IP address of interface */ + uint32_t imsf_fmode; /* filter mode */ + uint32_t imsf_numsrc; /* number of sources in src_list */ + struct in_addr imsf_slist[1]; /* start of source list */ +}; + +#define IP_MSFILTER_SIZE(numsrc) \ + (sizeof (struct ip_msfilter) - sizeof (struct in_addr) \ + + (numsrc) * sizeof (struct in_addr)) + +/* + * Multicast source filter manipulation functions in libsocket; + * defined in RFC 3678. + */ +int setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, uint32_t, + uint_t, struct sockaddr_storage *); + +int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, uint32_t *, + uint_t *, struct sockaddr_storage *); + +int setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t, + uint32_t, struct in_addr *); + +int getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *, + uint32_t *, struct in_addr *); + +/* + * Definitions needed for [gs]etsourcefilter(), [gs]etipv4sourcefilter() + */ +#define MCAST_INCLUDE 1 +#define MCAST_EXCLUDE 2 + +/* + * Argument struct for IP_PKTINFO option + */ +typedef struct in_pktinfo { + unsigned int ipi_ifindex; /* send/recv interface index */ + struct in_addr ipi_spec_dst; /* matched source address */ + struct in_addr ipi_addr; /* src/dst address in IP hdr */ +} in_pktinfo_t; + +/* + * Argument struct for IPV6_PKTINFO option + */ +struct in6_pktinfo { + struct in6_addr ipi6_addr; /* src/dst IPv6 address */ + unsigned int ipi6_ifindex; /* send/recv interface index */ +}; + +/* + * Argument struct for IPV6_MTUINFO option + */ +struct ip6_mtuinfo { + struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */ + uint32_t ip6m_mtu; /* path MTU in host byte order */ +}; + +/* + * IPv6 routing header types + */ +#define IPV6_RTHDR_TYPE_0 0 + +extern socklen_t inet6_rth_space(int type, int segments); +extern void *inet6_rth_init(void *bp, socklen_t bp_len, int type, int segments); +extern int inet6_rth_add(void *bp, const struct in6_addr *addr); +extern int inet6_rth_reverse(const void *in, void *out); +extern int inet6_rth_segments(const void *bp); +extern struct in6_addr *inet6_rth_getaddr(const void *bp, int index); + +extern int inet6_opt_init(void *extbuf, socklen_t extlen); +extern int inet6_opt_append(void *extbuf, socklen_t extlen, int offset, + uint8_t type, socklen_t len, uint_t align, void **databufp); +extern int inet6_opt_finish(void *extbuf, socklen_t extlen, int offset); +extern int inet6_opt_set_val(void *databuf, int offset, void *val, + socklen_t vallen); +extern int inet6_opt_next(void *extbuf, socklen_t extlen, int offset, + uint8_t *typep, socklen_t *lenp, void **databufp); +extern int inet6_opt_find(void *extbufp, socklen_t extlen, int offset, + uint8_t type, socklen_t *lenp, void **databufp); +extern int inet6_opt_get_val(void *databuf, int offset, void *val, + socklen_t vallen); +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Argument structure for IP_ADD_PROXY_ADDR. + * Note that this is an unstable, experimental interface. It may change + * later. Don't use it unless you know what it is. + */ +typedef struct { + struct in_addr in_prefix_addr; + unsigned int in_prefix_len; +} in_prefix_t; + + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +/* + * IPv6 options + */ +#define IPV6_UNICAST_HOPS 0x5 /* hop limit value for unicast */ + /* packets. */ + /* argument type: uint_t */ +#define IPV6_MULTICAST_IF 0x6 /* outgoing interface for */ + /* multicast packets. */ + /* argument type: struct in6_addr */ +#define IPV6_MULTICAST_HOPS 0x7 /* hop limit value to use for */ + /* multicast packets. */ + /* argument type: uint_t */ +#define IPV6_MULTICAST_LOOP 0x8 /* enable/disable delivery of */ + /* multicast packets on same socket. */ + /* argument type: uint_t */ +#define IPV6_JOIN_GROUP 0x9 /* join an IPv6 multicast group. */ + /* argument type: struct ipv6_mreq */ +#define IPV6_LEAVE_GROUP 0xa /* leave an IPv6 multicast group */ + /* argument type: struct ipv6_mreq */ + +/* + * Other XPG6 constants. + */ +#define INET_ADDRSTRLEN 16 /* max len IPv4 addr in ascii dotted */ + /* decimal notation. */ +#define INET6_ADDRSTRLEN 46 /* max len of IPv6 addr in ascii */ + /* standard colon-hex notation. */ + +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + +/* + * IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP are being kept + * for backward compatibility. They have the same meaning as IPV6_JOIN_GROUP + * and IPV6_LEAVE_GROUP respectively. + */ +#define IPV6_ADD_MEMBERSHIP 0x9 /* join an IPv6 multicast group. */ + /* argument type: struct ipv6_mreq */ +#define IPV6_DROP_MEMBERSHIP 0xa /* leave an IPv6 multicast group */ + /* argument type: struct ipv6_mreq */ + +#define IPV6_PKTINFO 0xb /* addr plus interface index */ + /* arg type: "struct in6_pktingo" - */ +#define IPV6_HOPLIMIT 0xc /* hoplimit for datagram */ +#define IPV6_NEXTHOP 0xd /* next hop address */ +#define IPV6_HOPOPTS 0xe /* hop by hop options */ +#define IPV6_DSTOPTS 0xf /* destination options - after */ + /* the routing header */ +#define IPV6_RTHDR 0x10 /* routing header */ +#define IPV6_RTHDRDSTOPTS 0x11 /* destination options - before */ + /* the routing header */ +#define IPV6_RECVPKTINFO 0x12 /* enable/disable IPV6_PKTINFO */ +#define IPV6_RECVHOPLIMIT 0x13 /* enable/disable IPV6_HOPLIMIT */ +#define IPV6_RECVHOPOPTS 0x14 /* enable/disable IPV6_HOPOPTS */ + +/* + * This options exists for backwards compatability and should no longer be + * used. Use IPV6_RECVDSTOPTS instead. + */ +#define _OLD_IPV6_RECVDSTOPTS 0x15 + +#define IPV6_RECVRTHDR 0x16 /* enable/disable IPV6_RTHDR */ + +/* + * enable/disable IPV6_RTHDRDSTOPTS. Now obsolete. IPV6_RECVDSTOPTS enables + * the receipt of both headers. + */ +#define IPV6_RECVRTHDRDSTOPTS 0x17 + +#define IPV6_CHECKSUM 0x18 /* Control checksum on raw sockets */ +#define IPV6_RECVTCLASS 0x19 /* enable/disable IPV6_TCLASS */ +#define IPV6_USE_MIN_MTU 0x20 /* send packets with minimum MTU */ +#define IPV6_DONTFRAG 0x21 /* don't fragment packets */ +#define IPV6_SEC_OPT 0x22 /* Used to set IPSEC options */ +#define IPV6_SRC_PREFERENCES 0x23 /* Control socket's src addr select */ +#define IPV6_RECVPATHMTU 0x24 /* receive PMTU info */ +#define IPV6_PATHMTU 0x25 /* get the PMTU */ +#define IPV6_TCLASS 0x26 /* traffic class */ +#define IPV6_V6ONLY 0x27 /* v6 only socket option */ + +/* + * enable/disable receipt of both both IPV6_DSTOPTS headers. + */ +#define IPV6_RECVDSTOPTS 0x28 + +/* + * protocol-independent multicast membership options. + */ +#define MCAST_JOIN_GROUP 0x29 /* join group for all sources */ +#define MCAST_LEAVE_GROUP 0x2a /* leave group */ +#define MCAST_BLOCK_SOURCE 0x2b /* block specified source */ +#define MCAST_UNBLOCK_SOURCE 0x2c /* unblock specified source */ +#define MCAST_JOIN_SOURCE_GROUP 0x2d /* join group for specified source */ +#define MCAST_LEAVE_SOURCE_GROUP 0x2e /* leave source/group pair */ + +/* 32Bit field for IPV6_SRC_PREFERENCES */ +#define IPV6_PREFER_SRC_HOME 0x00000001 +#define IPV6_PREFER_SRC_COA 0x00000002 +#define IPV6_PREFER_SRC_PUBLIC 0x00000004 +#define IPV6_PREFER_SRC_TMP 0x00000008 +#define IPV6_PREFER_SRC_NONCGA 0x00000010 +#define IPV6_PREFER_SRC_CGA 0x00000020 + +#define IPV6_PREFER_SRC_MIPMASK (IPV6_PREFER_SRC_HOME | IPV6_PREFER_SRC_COA) +#define IPV6_PREFER_SRC_MIPDEFAULT IPV6_PREFER_SRC_HOME +#define IPV6_PREFER_SRC_TMPMASK (IPV6_PREFER_SRC_PUBLIC | IPV6_PREFER_SRC_TMP) +#define IPV6_PREFER_SRC_TMPDEFAULT IPV6_PREFER_SRC_PUBLIC +#define IPV6_PREFER_SRC_CGAMASK (IPV6_PREFER_SRC_NONCGA | IPV6_PREFER_SRC_CGA) +#define IPV6_PREFER_SRC_CGADEFAULT IPV6_PREFER_SRC_NONCGA + +#define IPV6_PREFER_SRC_MASK (IPV6_PREFER_SRC_MIPMASK |\ + IPV6_PREFER_SRC_TMPMASK | IPV6_PREFER_SRC_CGAMASK) + +#define IPV6_PREFER_SRC_DEFAULT (IPV6_PREFER_SRC_MIPDEFAULT |\ + IPV6_PREFER_SRC_TMPDEFAULT | IPV6_PREFER_SRC_CGADEFAULT) + +#define IPV6_MINHOPCOUNT 0x2f /* minimum acceptable hop limit */ + +/* + * SunOS private (potentially not portable) IPV6_ option names + */ +#define IPV6_BOUND_IF 0x41 /* bind to an ifindex */ +#define IPV6_UNSPEC_SRC 0x42 /* source of packets set to */ + /* unspecified (all zeros) */ + +/* + * Miscellaneous IPv6 constants. + */ +#define IPV6_PAD1_OPT 0 /* pad byte in IPv6 extension hdrs */ + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Extern declarations for pre-defined global const variables + */ +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +#ifndef _KERNEL +#ifdef __STDC__ +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; +#else +extern struct in6_addr in6addr_any; +extern struct in6_addr in6addr_loopback; +#endif +#endif +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IN_H */ diff --git a/illumos-x86_64/usr/include/netinet/in_pcb.h b/illumos-x86_64/usr/include/netinet/in_pcb.h new file mode 100644 index 00000000..b746d251 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/in_pcb.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Common structure pcb for internet protocol implementation. + * Here are stored pointers to local and foreign host table + * entries, local and foreign socket numbers, and pointers + * up (to a socket structure) and down (to a protocol-specific) + * control block. + */ + +#ifndef _NETINET_IN_PCB_H +#define _NETINET_IN_PCB_H + +/* in_pcb.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct inpcb { + struct inpcb *inp_next, *inp_prev; /* pointers to other pcb's */ + struct inpcb *inp_head; /* pointer back to chain of inpcb's */ + /* for this protocol */ + struct in_addr inp_faddr; /* foreign host table entry */ + ushort_t inp_fport; /* foreign port */ + struct in_addr inp_laddr; /* local host table entry */ + ushort_t inp_lport; /* local port */ + struct socket *inp_socket; /* back pointer to socket */ + caddr_t inp_ppcb; /* pointer to per-protocol pcb */ + struct route inp_route; /* placeholder for routing entry */ + struct mbuf *inp_options; /* IP options */ +}; + +#define INPLOOKUP_WILDCARD 1 +#define INPLOOKUP_SETLOCAL 2 + +#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IN_PCB_H */ diff --git a/illumos-x86_64/usr/include/netinet/in_systm.h b/illumos-x86_64/usr/include/netinet/in_systm.h new file mode 100644 index 00000000..4e197248 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/in_systm.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 1997-1998, 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_IN_SYSTM_H +#define _NETINET_IN_SYSTM_H + +/* in_systm.h 1.8 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Legacy "network types" -- these are provided for backwards compatibility + * only; new code should use uint16_t and uint32_t instead. + */ +typedef uint16_t n_short; /* short as received from the net */ +typedef uint32_t n_long; /* long as received from the net */ +typedef uint32_t n_time; /* ms since 00:00 GMT, byte rev */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IN_SYSTM_H */ diff --git a/illumos-x86_64/usr/include/netinet/in_var.h b/illumos-x86_64/usr/include/netinet/in_var.h new file mode 100644 index 00000000..cc66ffa4 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/in_var.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1985, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Interface address, Internet version. One of these structures + * is allocated for each interface with an Internet address. + * The ifaddr structure contains the protocol-independent part + * of the structure and is assumed to be first. + */ + +#ifndef _NETINET_IN_VAR_H +#define _NETINET_IN_VAR_H + +/* in_var.h 1.3 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct in_ifaddr { + struct ifaddr ia_ifa; /* protocol-independent info */ +#define ia_addr ia_ifa.ifa_addr +#define ia_broadaddr ia_ifa.ifa_broadaddr +#define ia_dstaddr ia_ifa.ifa_dstaddr +#define ia_ifp ia_ifa.ifa_ifp + ulong_t ia_net; /* network number of interface */ + ulong_t ia_netmask; /* mask of net part */ + ulong_t ia_subnet; /* subnet number, including net */ + ulong_t ia_subnetmask; /* mask of net + subnet */ + struct in_addr ia_netbroadcast; /* broadcast addr for (logical) net */ + int ia_flags; + struct in_ifaddr *ia_next; /* next in list of internet addresses */ +}; +/* + * Given a pointer to an in_ifaddr (ifaddr), + * return a pointer to the addr as a sockadd_in. + */ +#define IA_SIN(ia) ((struct sockaddr_in *)(&((struct in_ifaddr *)ia)->ia_addr)) +/* + * ia_flags + */ +#define IFA_ROUTE 0x01 /* routing entry installed */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IN_VAR_H */ diff --git a/illumos-x86_64/usr/include/netinet/ip.h b/illumos-x86_64/usr/include/netinet/ip.h new file mode 100644 index 00000000..9ba4e271 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/ip.h @@ -0,0 +1,183 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +/* + * Definitions for internet protocol version 4. + * Per RFC 791, September 1981. + */ + +#ifndef _NETINET_IP_H +#define _NETINET_IP_H + +/* ip.h 1.13 88/08/19 SMI; from UCB 7.6.1.1 3/15/88 */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define IPVERSION 4 + +/* + * Structure of an internet header, naked of options. + */ +struct ip { +#ifdef _BIT_FIELDS_LTOH + uchar_t ip_hl:4, /* header length */ + ip_v:4; /* version */ +#else + uchar_t ip_v:4, /* version */ + ip_hl:4; /* header length */ +#endif + uchar_t ip_tos; /* type of service */ + ushort_t ip_len; /* total length */ + ushort_t ip_id; /* identification */ + ushort_t ip_off; /* fragment offset field */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ + uchar_t ip_ttl; /* time to live */ + uchar_t ip_p; /* protocol */ + ushort_t ip_sum; /* checksum */ + struct in_addr ip_src, ip_dst; /* source and dest address */ +}; + +#define IP_MAXPACKET 65535 /* maximum packet size */ + +/* + * Definitions for IP type of service (ip_tos) + */ +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_ECT 0x02 /* ECN-Capable Transport flag */ +#define IPTOS_CE 0x01 /* ECN-Congestion Experienced flag */ + +/* + * Definitions for IP precedence (also in ip_tos) (hopefully unused) + */ +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* + * Definitions for options. + */ + +/* Bits in the option value */ +#define IPOPT_COPY 0x80 + +#define IPOPT_COPIED(o) ((o)&0x80) +#define IPOPT_CLASS(o) ((o)&0x60) +#define IPOPT_NUMBER(o) ((o)&0x1f) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0x00 /* end of option list */ +#define IPOPT_NOP 0x01 /* no operation */ + +#define IPOPT_RR 0x07 /* record packet route */ +#define IPOPT_RTRALERT 0x14 /* router alert */ +#define IPOPT_TS 0x44 /* timestamp */ +#define IPOPT_SECURITY 0x82 /* provide s,c,h,tcc */ +#define IPOPT_LSRR 0x83 /* loose source route */ +#define IPOPT_EXTSEC 0x85 +#define IPOPT_COMSEC 0x86 +#define IPOPT_SATID 0x88 /* satnet id */ +#define IPOPT_SSRR 0x89 /* strict source route */ +#define IPOPT_RA 0x94 +#define IPOPT_SDMDD 0x95 + +/* + * Offsets to fields in options other than EOL and NOP. + */ +#define IPOPT_OPTVAL 0 /* option ID */ +#define IPOPT_OLEN 1 /* option length */ +#define IPOPT_OFFSET 2 /* offset within option */ +#define IPOPT_POS_OV_FLG 3 +#define IPOPT_MINOFF 4 /* min value of IPOPT_OFFSET */ + + +/* Minimum for src and record route options */ +#define IPOPT_MINOFF_SR IPOPT_MINOFF + +/* + * Time stamp option structure. + */ +struct ip_timestamp { + uchar_t ipt_code; /* IPOPT_TS */ + uchar_t ipt_len; /* size of structure (variable) */ + uchar_t ipt_ptr; /* index of current entry */ +#ifdef _BIT_FIELDS_LTOH + uchar_t ipt_flg:4, /* flags, see below */ + ipt_oflw:4; /* overflow counter */ +#else + uchar_t ipt_oflw:4, /* overflow counter */ + ipt_flg:4; /* flags, see below */ +#endif + union ipt_timestamp { + uint32_t ipt_time[1]; + struct ipt_ta { + struct in_addr ipt_addr; + uint32_t ipt_time; + } ipt_ta[1]; + } ipt_timestamp; +}; + +/* flag bits for ipt_flg */ +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 2 /* specified modules only */ +#define IPOPT_TS_PRESPEC_RFC791 3 + +/* Minimum for timestamp option */ +#define IPOPT_MINOFF_IT 5 +#define IPOPT_MINLEN_IT 5 + +#define IPOPT_TS_TIMELEN 4 /* Timestamp size */ + +/* bits for security (not byte swapped) */ +#define IPOPT_SECUR_UNCLASS 0x0000 +#define IPOPT_SECUR_CONFID 0xf135 +#define IPOPT_SECUR_EFTO 0x789a +#define IPOPT_SECUR_MMMM 0xbc4d +#define IPOPT_SECUR_RESTR 0xaf13 +#define IPOPT_SECUR_SECRET 0xd788 +#define IPOPT_SECUR_TOPSECRET 0x6bc5 + +/* + * Internet implementation parameters. + */ +#define MAXTTL 255 /* maximum time to live (seconds) */ +#define IPFRAGTTL 60 /* time to live for frags, slowhz */ +#define IPTTLDEC 1 /* subtracted when forwarding */ + +#define IP_MSS 576 /* default maximum segment size */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP_H */ diff --git a/illumos-x86_64/usr/include/netinet/ip6.h b/illumos-x86_64/usr/include/netinet/ip6.h new file mode 100644 index 00000000..d0fd2845 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/ip6.h @@ -0,0 +1,266 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ip6.h - Common structures and definitions as defined by + * advanced BSD API. + */ + +#ifndef _NETINET_IP6_H +#define _NETINET_IP6_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +struct ip6_hdr { + union { + struct ip6_hdrctl { + uint32_t ip6_un1_flow; /* 4 bits version, */ + /* 8 bits tclass, and */ + /* 20 bits flow-ID */ + uint16_t ip6_un1_plen; /* payload length */ + uint8_t ip6_un1_nxt; /* next header */ + uint8_t ip6_un1_hlim; /* hop limit */ + } ip6_un1; + uint8_t ip6_un2_vfc; /* 4 bits version and */ + /* top 4 bits of tclass */ + } ip6_ctlun; + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ +}; +typedef struct ip6_hdr ip6_t; + +#define ip6_vfc ip6_ctlun.ip6_un2_vfc /* 4 bits version and */ + /* top 4 bits of tclass */ +#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow +#define ip6_vcf ip6_flow /* Version, tclass, flow-ID */ +#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt +#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim +#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim + +/* Hop-by-Hop options header */ +struct ip6_hbh { + uint8_t ip6h_nxt; /* next header */ + uint8_t ip6h_len; /* length in units of 8 octets */ + /* followed by options */ +}; +typedef struct ip6_hbh ip6_hbh_t; + +/* Destination options header */ +struct ip6_dest { + uint8_t ip6d_nxt; /* next header */ + uint8_t ip6d_len; /* length in units of 8 octets */ + /* followed by options */ +}; +typedef struct ip6_dest ip6_dest_t; + +/* Routing header */ +struct ip6_rthdr { + uint8_t ip6r_nxt; /* next header */ + uint8_t ip6r_len; /* length in units of 8 octets */ + uint8_t ip6r_type; /* routing type */ + uint8_t ip6r_segleft; /* segments left */ + /* followed by routing type specific data */ +}; +typedef struct ip6_rthdr ip6_rthdr_t; + +/* Type 0 Routing header */ +struct ip6_rthdr0 { + uint8_t ip6r0_nxt; /* next header */ + uint8_t ip6r0_len; /* length in units of 8 octets */ + uint8_t ip6r0_type; /* always zero */ + uint8_t ip6r0_segleft; /* segments left */ + uint32_t ip6r0_reserved; /* reserved field */ +}; +typedef struct ip6_rthdr0 ip6_rthdr0_t; + +/* Fragment header */ +struct ip6_frag { + uint8_t ip6f_nxt; /* next header */ + uint8_t ip6f_reserved; /* reserved field */ + uint16_t ip6f_offlg; /* offset, reserved, and flag */ + uint32_t ip6f_ident; /* identification */ +}; +typedef struct ip6_frag ip6_frag_t; + +/* ip6f_offlg field related constants (in network byte order) */ +#ifdef _BIG_ENDIAN +#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ +#else +#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */ +#endif + +/* IPv6 options */ +struct ip6_opt { + uint8_t ip6o_type; + uint8_t ip6o_len; +}; + +/* + * The high-order 3 bits of the option type define the behavior + * when processing an unknown option and whether or not the option + * content changes in flight. + */ +#define IP6OPT_TYPE(o) ((o) & 0xc0) +#define IP6OPT_TYPE_SKIP 0x00 +#define IP6OPT_TYPE_DISCARD 0x40 +#define IP6OPT_TYPE_FORCEICMP 0x80 +#define IP6OPT_TYPE_ICMP 0xc0 +#define IP6OPT_MUTABLE 0x20 + +#define IP6OPT_PAD1 0x00 /* 00 0 00000 */ +#define IP6OPT_PADN 0x01 /* 00 0 00001 */ +#define IP6OPT_JUMBO 0xc2 /* 11 0 00010 = 194 */ +#define IP6OPT_NSAP_ADDR 0xc3 /* 11 0 00011 */ +#define IP6OPT_TUNNEL_LIMIT 0x04 /* 00 0 00100 */ +#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ +#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */ +#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */ +#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */ +#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ +#define IP6OPT_EID 0x8a /* 10 0 01010 */ + +#define IP6OPT_LS 0x0a /* 00 0 01010 */ + +#define IP6_MAX_OPT_LENGTH 255 + +/* Jumbo Payload Option */ +struct ip6_opt_jumbo { + uint8_t ip6oj_type; + uint8_t ip6oj_len; + uint8_t ip6oj_jumbo_len[4]; +}; +#define IP6OPT_JUMBO_LEN 6 + +/* NSAP Address Option */ +struct ip6_opt_nsap { + uint8_t ip6on_type; + uint8_t ip6on_len; + uint8_t ip6on_src_nsap_len; + uint8_t ip6on_dst_nsap_len; + /* Followed by source NSAP */ + /* Followed by destination NSAP */ +}; + +/* Tunnel Limit Option */ +struct ip6_opt_tunnel { + uint8_t ip6ot_type; + uint8_t ip6ot_len; + uint8_t ip6ot_encap_limit; +}; + +/* Router Alert Option */ +struct ip6_opt_router { + uint8_t ip6or_type; + uint8_t ip6or_len; + uint8_t ip6or_value[2]; +}; + +/* Router alert values (in network byte order) */ +#ifdef _BIG_ENDIAN +#define IP6_ALERT_MLD 0x0000 +#define IP6_ALERT_RSVP 0x0001 +#define IP6_ALERT_AN 0x0002 +#else +#define IP6_ALERT_MLD 0x0000 +#define IP6_ALERT_RSVP 0x0100 +#define IP6_ALERT_AN 0x0200 +#endif + +/* Binding Update Option */ +struct ip6_opt_binding_update { + uint8_t ip6ou_type; + uint8_t ip6ou_len; + uint8_t ip6ou_flags; + uint8_t ip6ou_prefixlen; + uint8_t ip6ou_seqno[2]; + uint8_t ip6ou_lifetime[4]; + uint8_t ip6ou_coa[16]; /* Optional based on flags */ + /* Followed by sub-options */ +}; + +/* Binding Update Flags */ +#define IP6_BUF_ACK 0x80 /* Request a binding ack */ +#define IP6_BUF_HOME 0x40 /* Home Registration */ +#define IP6_BUF_COA 0x20 /* Care-of-address present in option */ +#define IP6_BUF_ROUTER 0x10 /* Sending mobile node is a router */ + +/* Binding Ack Option */ +struct ip6_opt_binding_ack { + uint8_t ip6oa_type; + uint8_t ip6oa_len; + uint8_t ip6oa_status; + uint8_t ip6oa_seqno[2]; + uint8_t ip6oa_lifetime[4]; + uint8_t ip6oa_refresh[4]; + /* Followed by sub-options */ +}; + +/* Binding Request Option */ +struct ip6_opt_binding_request { + uint8_t ip6or_type; + uint8_t ip6or_len; + /* Followed by sub-options */ +}; + +/* Home Address Option */ +struct ip6_opt_home_address { + uint8_t ip6oh_type; + uint8_t ip6oh_len; + uint8_t ip6oh_addr[16]; /* Home Address */ + /* Followed by sub-options */ +}; + +/* Labeled Security Option */ +struct ip6_opt_labeled_security { + uint8_t ip6ol_type; + uint8_t ip6ol_len; /* always even for defined values */ + uint8_t ip6ol_doi[4]; + /* Followed by sub-options */ +}; + +#define IP6LS_DOI_V4 0 /* IPv4 transition */ + +#define IP6LS_TT_LEVEL 1 /* level or classification; 2-octet value */ +#define IP6LS_TT_VECTOR 2 /* compartments; bit vector (even # octets) */ +#define IP6LS_TT_ENUM 3 /* set membership; list of 2-octet values */ +#define IP6LS_TT_RANGES 4 /* set membership; pairs of 2-octet values */ +#define IP6LS_TT_V4 5 /* IPv4 compatible option */ +#define IP6LS_TT_DEST 6 /* destination-only data; per DOI */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP6_H */ diff --git a/illumos-x86_64/usr/include/netinet/ip_icmp.h b/illumos-x86_64/usr/include/netinet/ip_icmp.h new file mode 100644 index 00000000..e25cf11e --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/ip_icmp.h @@ -0,0 +1,184 @@ +/* + * Copyright 1997-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Interface Control Message Protocol Definitions. + * Per RFC 792, September 1981. + */ + +#ifndef _NETINET_IP_ICMP_H +#define _NETINET_IP_ICMP_H + +#include + +/* ip_icmp.h 1.9 88/08/19 SMI; from UCB 7.3 12/7/87 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structure of an icmp header. + */ +struct icmp { + uchar_t icmp_type; /* type of message, see below */ + uchar_t icmp_code; /* type sub code */ + uint16_t icmp_cksum; /* ones complement cksum of struct */ + union { + uchar_t ih_pptr; /* ICMP_PARAMPROB */ + struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ + struct ih_idseq { + uint16_t icd_id; + uint16_t icd_seq; + } ih_idseq; + int ih_void; + + /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ + struct ih_pmtu { + uint16_t ipm_void; + uint16_t ipm_nextmtu; + } ih_pmtu; + + struct ih_rtradv { + uchar_t irt_num_addrs; + uchar_t irt_wpa; + uint16_t irt_lifetime; + } ih_rtradv; + } icmp_hun; +#define icmp_pptr icmp_hun.ih_pptr +#define icmp_gwaddr icmp_hun.ih_gwaddr +#define icmp_id icmp_hun.ih_idseq.icd_id +#define icmp_seq icmp_hun.ih_idseq.icd_seq +#define icmp_void icmp_hun.ih_void +#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void +#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu + union { + struct id_ts { + n_time its_otime; + n_time its_rtime; + n_time its_ttime; + } id_ts; + struct id_ip { + struct ip idi_ip; + /* options and then 64 bits of data */ + } id_ip; + uint32_t id_mask; + char id_data[1]; + } icmp_dun; +#define icmp_otime icmp_dun.id_ts.its_otime +#define icmp_rtime icmp_dun.id_ts.its_rtime +#define icmp_ttime icmp_dun.id_ts.its_ttime +#define icmp_ip icmp_dun.id_ip.idi_ip +#define icmp_mask icmp_dun.id_mask +#define icmp_data icmp_dun.id_data +}; + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enough to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ +#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ + +/* + * Definition of type and code field values. + */ +#define ICMP_ECHOREPLY 0 /* echo reply */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_UNREACH_FILTER_PROHIB 13 /* prohibited access */ +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* pred violationn */ +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_REDIRECT 5 /* shorter route, codes: */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ +#define ICMP_ECHO 8 /* echo service */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERADVERT_COMMON 0 /* common traffic */ +#define ICMP_ROUTERADVERT_NOCOMMON 16 /* no common traffic */ +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ +#define ICMP_PARAMPROB_BADLENGTH 2 /* Bad Length */ +#define ICMP_TSTAMP 13 /* timestamp request */ +#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ +#define ICMP_IREQ 15 /* information request */ +#define ICMP_IREQREPLY 16 /* information reply */ +#define ICMP_MASKREQ 17 /* address mask request */ +#define ICMP_MASKREPLY 18 /* address mask reply */ + +#define ICMP_MAXTYPE 18 + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP_ICMP_H */ diff --git a/illumos-x86_64/usr/include/netinet/ip_mroute.h b/illumos-x86_64/usr/include/netinet/ip_mroute.h new file mode 100644 index 00000000..b1dde41b --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/ip_mroute.h @@ -0,0 +1,299 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _NETINET_IP_MROUTE_H +#define _NETINET_IP_MROUTE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for the kernel part of DVMRP, + * a Distance-Vector Multicast Routing Protocol. + * (See RFC-1075.) + * + * Written by David Waitzman, BBN Labs, August 1988. + * Modified by Steve Deering, Stanford, February 1989. + * Modified by Ajit Thyagarajan, PARC, August 1993. + * Modified by Ajit Thyagarajan, PARC, August 1994. + * + * MROUTING 3.5 + */ + +/* + * DVMRP-specific setsockopt commands. + */ + +#define MRT_INIT 100 /* initialize forwarder */ +#define MRT_DONE 101 /* shut down forwarder */ +#define MRT_ADD_VIF 102 /* create virtual interface */ +#define MRT_DEL_VIF 103 /* delete virtual interface */ +#define MRT_ADD_MFC 104 /* insert forwarding cache entry */ +#define MRT_DEL_MFC 105 /* delete forwarding cache entry */ +#define MRT_VERSION 106 /* get kernel version number */ +#define MRT_ASSERT 107 /* enable PIM assert processing */ + +/* + * Types and macros for handling bitmaps with one bit per virtual interface. + */ +#define MAXVIFS 32 +typedef uint_t vifbitmap_t; +typedef ushort_t vifi_t; /* type of a vif index */ +#define ALL_VIFS (vifi_t)-1 + +#define VIFM_SET(n, m) ((m) |= (1 << (n))) +#define VIFM_CLR(n, m) ((m) &= ~(1 << (n))) +#define VIFM_ISSET(n, m) ((m) & (1 << (n))) +#define VIFM_CLRALL(m) ((m) = 0x00000000) +#define VIFM_COPY(mfrom, mto) ((mto) = (mfrom)) +#define VIFM_SAME(m1, m2) ((m1) == (m2)) + + +/* + * Argument structure for MRT_ADD_VIF. Also used for netstat. + * (MRT_DEL_VIF takes a single vifi_t argument.) + */ +struct vifctl { + vifi_t vifc_vifi; /* the index of the vif to be added */ + uchar_t vifc_flags; /* VIFF_ flags defined below */ + uchar_t vifc_threshold; /* min ttl required to forward on vif */ + uint_t vifc_rate_limit; /* max rate */ + struct in_addr vifc_lcl_addr; /* local interface address */ + struct in_addr vifc_rmt_addr; /* remote address(tunnels only) */ + /* + * vifc_pkt_in/out in Solaris, to report out of the kernel. + * Not nec. in BSD. + */ + uint_t vifc_pkt_in; /* # Pkts in on interface */ + uint_t vifc_pkt_out; /* # Pkts out on interface */ +}; + +#define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ +#define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */ +#define VIFF_REGISTER 0x4 /* for RPF check of PIM Register msg */ + +/* + * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC + * (mfcc_tos to be added at a future point) + */ +struct mfcctl { + struct in_addr mfcc_origin; /* ip origin of mcasts */ + struct in_addr mfcc_mcastgrp; /* multicast group associated */ + vifi_t mfcc_parent; /* incoming vif */ + uint_t mfcc_pkt_cnt; /* pkt count for src-grp */ + uchar_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ +}; + +/* + * The kernel's multicast routing statistics. + */ +struct mrtstat { + uint_t mrts_mfcfind_lookups; /* #forwarding cache table lookups */ + uint_t mrts_mfcfind_misses; /* # forwarding cache table misses */ + uint_t mrts_mfc_hits; /* forwarding pkt mfctable hits */ + uint_t mrts_mfc_misses; /* forwarding pkt mfctable misses */ + uint_t mrts_upcalls; /* # calls to mrouted */ + uint_t mrts_fwd_in; /* # packets potentially forwarded */ + uint_t mrts_fwd_out; /* # resulting outgoing packets */ + uint_t mrts_fwd_drop; /* # dropped for lack of resources */ + uint_t mrts_bad_tunnel; /* malformed tunnel options */ + uint_t mrts_cant_tunnel; /* no room for tunnel options */ + uint_t mrts_wrong_if; /* arrived on wrong interface */ + uint_t mrts_upq_ovflw; /* upcall Q overflow */ + uint_t mrts_cache_cleanups; /* # entries with no upcalls */ + uint_t mrts_drop_sel; /* pkts dropped selectively */ + uint_t mrts_q_overflow; /* pkts dropped - Q overflow */ + uint_t mrts_pkt2large; /* pkts dropped - size > BKT SIZE */ + uint_t mrts_vifctlSize; /* Size of vifctl */ + uint_t mrts_mfcctlSize; /* Size of mfcctl */ + uint_t mrts_pim_badversion; /* dtgrms dropped - bad version */ + uint_t mrts_pim_rcv_badcsum; /* dtgrms dropped - bad checksum */ + uint_t mrts_pim_badregisters; /* dtgrms dropped - bad register pkts */ + uint_t mrts_pim_regforwards; /* dtgrms to be forwd - register pkts */ + uint_t mrts_pim_regsend_drops; /* dtgrms dropped - register send */ + uint_t mrts_pim_malformed; /* dtgrms dropped - packet malformed */ + uint_t mrts_pim_nomemory; /* dtgrms dropped - no memory to fwd. */ +}; + +/* + * Argument structure used by mrouted to get src-grp pkt counts + */ +struct sioc_sg_req { + struct in_addr src; + struct in_addr grp; + uint_t pktcnt; + uint_t bytecnt; + uint_t wrong_if; +}; + +/* + * Argument structure used by mrouted to get vif pkt counts + */ +struct sioc_vif_req { + vifi_t vifi; /* vif number */ + uint_t icount; /* Input packet count on vif */ + uint_t ocount; /* Output packet count on vif */ + uint_t ibytes; /* Input byte count on vif */ + uint_t obytes; /* Output byte count on vif */ +}; + +#ifdef _KERNEL +/* + * The kernel's virtual-interface structure. + */ +struct vif { + uchar_t v_flags; /* VIFF_ flags defined above */ + uchar_t v_threshold; /* Min ttl required to forward on vif */ + uint_t v_rate_limit; /* Max rate, in kbits/sec */ + struct tbf *v_tbf; /* Token bkt structure at intf. */ + struct in_addr v_lcl_addr; /* Local interface address */ + struct in_addr v_rmt_addr; /* Remote address(tunnels only) */ + struct ipif_s *v_ipif; /* Pointer to logical interface */ + uint_t v_pkt_in; /* # Pkts in on interface */ + uint_t v_pkt_out; /* # Pkts out on interface */ + uint_t v_bytes_in; /* # Bytes in on interface */ + uint_t v_bytes_out; /* # Bytes out on interface */ + timeout_id_t v_timeout_id; /* Qtimeout return id */ + /* + * struct route v_route; Cached route if this is a tunnel + * Used in bsd for performance + */ + uint_t v_refcnt; + uchar_t v_marks; + kmutex_t v_lock; + ilm_t *v_ilm; /* allmulti join */ +}; + +/* + * vif is not being used. However if refcnt != 0 than its being initalized. + */ +#define VIF_MARK_NOTINUSE 0x0 /* see comment above */ + +#define VIF_MARK_CONDEMNED 0x1 /* delete when refcnt goes to zero. */ + +#define VIF_MARK_GOOD 0x2 /* vif is good */ + +#define VIF_MARK_INUSE VIF_MARK_CONDEMNED | VIF_MARK_GOOD + +/* + * The kernel's multicast forwarding cache entry structure + * (A field for the type of service (mfc_tos) is to be added + * at a future point) + */ +struct mfc { + struct in_addr mfc_origin; /* ip origin of mcasts */ + struct in_addr mfc_mcastgrp; /* multicast group associated */ + vifi_t mfc_parent; /* incoming vif */ + uchar_t mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ + uint_t mfc_pkt_cnt; /* pkt count for src-grp */ + uint_t mfc_byte_cnt; /* byte count for src-grp */ + uint_t mfc_wrong_if; /* wrong if for src-grp */ + struct timespec mfc_last_assert; /* last time I sent an assert */ + struct rtdetq *mfc_rte; /* pending upcall */ + timeout_id_t mfc_timeout_id; /* qtimeout return id */ + struct mfc *mfc_next; + uchar_t mfc_marks; + kmutex_t mfc_mutex; /* protects fields and rte list */ +}; + +/* + * mfc bucket structure. + */ +struct mfcb { + struct mfc *mfcb_mfc; /* first mfc in this bucket */ + kmutex_t mfcb_lock; + uint_t mfcb_refcnt; /* protected by mfcb_lock */ + uchar_t mfcb_marks; /* protected by mfcb_lock */ +}; + +#define MFCB_MARK_CONDEMNED 0x1 + +/* + * Argument structure used for pkt info. while upcall is made + */ +struct rtdetq { + mblk_t *mp; /* A copy of the packet */ + ill_t *ill; /* Interface pkt came in on */ + struct rtdetq *rte_next; +}; +#endif + +/* + * Struct used to communicate from kernel to multicast router + * note the convenient similarity to an IP packet + */ +struct igmpmsg { + uint_t unused1; + uint_t unused2; + uchar_t im_msgtype; /* what type of message */ +#define IGMPMSG_NOCACHE 1 +#define IGMPMSG_WRONGVIF 2 +#define IGMPMSG_WHOLEPKT 3 + uchar_t im_mbz; /* must be zero */ + uchar_t im_vif; /* vif rec'd on */ + uchar_t unused3; + struct in_addr im_src, im_dst; +}; + +#ifdef _KERNEL +#define MFCTBLSIZ 256 +#if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */ +#define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1)) +#else +#define MFCHASHMOD(h) ((h) % MFCTBLSIZ) +#endif + +#define MAX_UPQ 4 /* max. no of pkts in upcall Q */ + +/* + * Token Bucket filter code + */ +#define MAX_BKT_SIZE 10000 /* 10K bytes size */ +#define MAXQSIZE 10 /* max # of pkts in queue */ +#define TOKEN_SIZE 8 /* number of bits in token */ + +/* + * The token bucket filter at each vif + */ +struct tbf { + timespec_t tbf_last_pkt_t; /* arr. time of last pkt */ + uint_t tbf_n_tok; /* no of tokens in bucket */ + uint_t tbf_q_len; /* length of queue at this vif */ + uint_t tbf_max_q_len; /* max queue length */ + mblk_t *tbf_q; /* Packet queue */ + mblk_t *tbf_t; /* Tail-insertion pointer */ + kmutex_t tbf_lock; /* lock on the tbf */ +}; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP_MROUTE_H */ diff --git a/illumos-x86_64/usr/include/netinet/ip_var.h b/illumos-x86_64/usr/include/netinet/ip_var.h new file mode 100644 index 00000000..f4162785 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/ip_var.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 1997-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Overlay for ip header used by other protocols (tcp, udp). + */ + +#ifndef _NETINET_IP_VAR_H +#define _NETINET_IP_VAR_H + +/* ip_var.h 1.11 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ipovly { +#ifdef _LP64 + uint32_t ih_next, ih_prev; +#else + caddr_t ih_next, ih_prev; /* for protocol sequence q's */ +#endif + uchar_t ih_x1; /* (unused) */ + uchar_t ih_pr; /* protocol */ + short ih_len; /* protocol length */ + struct in_addr ih_src; /* source internet address */ + struct in_addr ih_dst; /* destination internet address */ +}; + +/* + * Ip reassembly queue structure. Each fragment + * being reassembled is attached to one of these structures. + * They are timed out after ipq_ttl drops to 0, and may also + * be reclaimed if memory becomes tight. + */ +struct ipq { + struct ipq *next, *prev; /* to other reass headers */ + uchar_t ipq_ttl; /* time for reass q to live */ + uchar_t ipq_p; /* protocol of this fragment */ + ushort_t ipq_id; /* sequence id for reassembly */ + struct ipasfrag *ipq_next, *ipq_prev; + /* to ip headers of fragments */ + struct in_addr ipq_src, ipq_dst; +}; + +/* + * Ip header, when holding a fragment. + * + * Note: ipf_next must be at same offset as ipq_next above + */ +struct ipasfrag { +#ifdef _BIT_FIELDS_LTOH + uchar_t ip_hl:4, + ip_v:4; +#else + uchar_t ip_v:4, + ip_hl:4; +#endif + uchar_t ipf_mff; /* copied from (ip_off&IP_MF) */ + short ip_len; + ushort_t ip_id; + short ip_off; + uchar_t ip_ttl; + uchar_t ip_p; + ushort_t ip_sum; + struct ipasfrag *ipf_next; /* next fragment */ + struct ipasfrag *ipf_prev; /* previous fragment */ +}; + +/* + * Structure stored in mbuf in inpcb.ip_options + * and passed to ip_output when ip options are in use. + * The actual length of the options (including ipopt_dst) + * is in m_len. + */ +#define MAX_IPOPTLEN 40 + +struct ipoption { + struct in_addr ipopt_dst; /* first-hop dst if source routed */ + char ipopt_list[MAX_IPOPTLEN]; /* options proper */ +}; + +struct ipstat { + long ips_total; /* total packets received */ + long ips_badsum; /* checksum bad */ + long ips_tooshort; /* packet too short */ + long ips_toosmall; /* not enough data */ + long ips_badhlen; /* ip header length < data size */ + long ips_badlen; /* ip length < ip header length */ + long ips_fragments; /* fragments received */ + long ips_fragdropped; /* frags dropped (dups, out of space) */ + long ips_fragtimeout; /* fragments timed out */ + long ips_forward; /* packets forwarded */ + long ips_cantforward; /* packets rcvd for unreachable dest */ + long ips_redirectsent; /* packets forwarded on same net */ +}; + +#ifdef _KERNEL +/* flags passed to ip_output as last parameter */ +#define IP_FORWARDING 0x1 /* most of ip header exists */ +#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ +#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP_VAR_H */ diff --git a/illumos-x86_64/usr/include/netinet/pim.h b/illumos-x86_64/usr/include/netinet/pim.h new file mode 100644 index 00000000..2ce02eb3 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/pim.h @@ -0,0 +1,131 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1996-1999 by the University of Southern California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation in source and binary forms for lawful + * purposes and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both + * the copyright notice and this permission notice appear in supporting + * documentation, and that any documentation, advertising materials, + * and other materials related to such distribution and use acknowledge + * that the software was developed by the University of Southern + * California and/or Information Sciences Institute. + * The name of the University of Southern California may not + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY REPRESENTATIONS + * ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS + * PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND + * NON-INFRINGEMENT. + * + * IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, + * TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, + * THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Other copyrights might apply to parts of this software and are so + * noted when applicable. + */ + +#ifndef _NETINET_PIM_H +#define _NETINET_PIM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Protocol Independent Multicast (PIM) definitions + * + * Written by Ahmed Helmy, USC/SGI, July 1996 + * Modified by George Edmond Eddy (Rusty), ISI, February 1998 + * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 + * + * $Id: pim.h,v 1.3 1999/08/31 03:03:08 pavlin Exp $ + */ + +/* + * PIM packet format. + */ +typedef struct pim { +#ifdef _BIT_FIELDS_LTOH + uint8_t pim_type:4, /* type of PIM message */ + pim_vers:4; /* PIM version */ +#else + uint8_t pim_vers:4, /* PIM version */ + pim_type:4; /* type of PIM message */ +#endif + uint8_t pim_reserved; /* Reserved */ + uint16_t pim_cksum; /* IP-style checksum */ +} pim_t; + +#define PIM_VERSION 2 +#define PIM_MINLEN 8 /* The header min. length is 8 */ + +/* Register message + inner IPheader */ +#define PIM_REG_MINLEN (PIM_MINLEN + IP_SIMPLE_HDR_LENGTH) + +/* + * From the PIM protocol spec (RFC 2362), the following PIM message types + * are defined. All of these, except PIM_REGISTER, are currently not defined + * in the USC/ISI distributed include file. So they are listed + * here commented out. + * + * #define PIM_HELLO 0x0 + * #define PIM_REGISTER 0x1 + * #define PIM_REGISTER_STOP 0x2 + * #define PIM_JOIN_PRUNE 0x3 + * #define PIM_BOOTSTRAP 0x4 + * #define PIM_ASSERT 0x5 + * #define PIM_GRAFT 0x6 + * #define PIM_GRAFT_ACK 0x7 + * #define PIM_CAND_RP_ADV 0x8 + * + */ +#define PIM_REGISTER 0x1 /* PIM Register type is 1 */ + +/* + * First bit in reg_head (right after PIM header) is the Border bit. + */ +#define PIM_BORDER_REGISTER 0x80000000 + +/* + * Second bit in reg_head (right after PIM header) is the Null-Register bit + */ +#define PIM_NULL_REGISTER 0x40000000 + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_PIM_H */ diff --git a/illumos-x86_64/usr/include/netinet/sctp.h b/illumos-x86_64/usr/include/netinet/sctp.h new file mode 100644 index 00000000..352466ca --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/sctp.h @@ -0,0 +1,802 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NETINET_SCTP_H +#define _NETINET_SCTP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * This file contains the structure defintions and function prototypes + * described in the IETF SCTP socket API document. + */ + +/* SCTP association ID type. */ +typedef int sctp_assoc_t; +typedef int32_t sctp_assoc32_t; + +/* + * SCTP socket options + */ +#define SCTP_RTOINFO 1 +#define SCTP_ASSOCINFO 2 +#define SCTP_INITMSG 3 +#define SCTP_NODELAY 4 +#define SCTP_AUTOCLOSE 5 +#define SCTP_SET_PEER_PRIMARY_ADDR 6 +#define SCTP_PRIMARY_ADDR 7 +#define SCTP_ADAPTATION_LAYER 8 +#define SCTP_DISABLE_FRAGMENTS 9 +#define SCTP_PEER_ADDR_PARAMS 10 +#define SCTP_DEFAULT_SEND_PARAM 11 +#define SCTP_EVENTS 12 +#define SCTP_I_WANT_MAPPED_V4_ADDR 13 +#define SCTP_MAXSEG 14 +#define SCTP_STATUS 15 +#define SCTP_GET_PEER_ADDR_INFO 16 + +/* + * Private socket options + */ +#define SCTP_GET_NLADDRS 17 +#define SCTP_GET_LADDRS 18 +#define SCTP_GET_NPADDRS 19 +#define SCTP_GET_PADDRS 20 +#define SCTP_ADD_ADDR 21 +#define SCTP_REM_ADDR 22 + +/* + * Additional SCTP socket options. This socket option is used to enable or + * disable PR-SCTP support prior to establishing an association. By default, + * PR-SCTP support is disabled. + */ +#define SCTP_PRSCTP 23 + +/* + * SCTP socket option used to read per endpoint association statistics. + */ +#define SCTP_GET_ASSOC_STATS 24 + +/* + * Ancillary data identifiers + */ +#define SCTP_SNDRCV 0x100 +#define SCTP_INIT 0x101 + +/* + * Notification types + */ +#define SCTP_ASSOC_CHANGE 1 +#define SCTP_PEER_ADDR_CHANGE 2 +#define SCTP_REMOTE_ERROR 3 +#define SCTP_SEND_FAILED 4 +#define SCTP_SHUTDOWN_EVENT 5 +#define SCTP_ADAPTATION_INDICATION 6 +#define SCTP_PARTIAL_DELIVERY_EVENT 7 + +/* + * SCTP Ancillary Data Definitions + */ + +/* + * sctp_initmsg structure provides information for initializing new SCTP + * associations with sendmsg(). The SCTP_INITMSG socket option uses + * this same data structure. + */ +struct sctp_initmsg { + uint16_t sinit_num_ostreams; + uint16_t sinit_max_instreams; + uint16_t sinit_max_attempts; + uint16_t sinit_max_init_timeo; +}; + +/* + * sctp_sndrcvinfo structure specifies SCTP options for sendmsg() and + * describes SCTP header information about a received message through + * recvmsg(). + */ +struct sctp_sndrcvinfo { + uint16_t sinfo_stream; + uint16_t sinfo_ssn; + uint16_t sinfo_flags; + uint32_t sinfo_ppid; + uint32_t sinfo_context; + uint32_t sinfo_timetolive; + uint32_t sinfo_tsn; + uint32_t sinfo_cumtsn; + sctp_assoc_t sinfo_assoc_id; +}; + +/* sinfo_flags */ +#define MSG_UNORDERED 0x01 /* Unordered data */ +#define MSG_ABORT 0x02 /* Abort the connection */ +#define MSG_EOF 0x04 /* Shutdown the connection */ + +/* + * Use destination addr passed as parameter, not the association primary one. + */ +#define MSG_ADDR_OVER 0x08 +/* + * This flag when set in sinfo_flags is used alongwith sinfo_timetolive to + * implement the "timed reliability" service discussed in RFC 3758. + */ +#define MSG_PR_SCTP 0x10 +/* + * SCTP notification definitions + */ + +/* + * To receive any ancillary data or notifications, the application can + * register it's interest by calling the SCTP_EVENTS setsockopt() with + * the sctp_event_subscribe structure. + */ +struct sctp_event_subscribe { + uint8_t sctp_data_io_event; + uint8_t sctp_association_event; + uint8_t sctp_address_event; + uint8_t sctp_send_failure_event; + uint8_t sctp_peer_error_event; + uint8_t sctp_shutdown_event; + uint8_t sctp_partial_delivery_event; + uint8_t sctp_adaptation_layer_event; +}; + +/* Association events used in sctp_assoc_change structure */ +#define SCTP_COMM_UP 0 +#define SCTP_COMM_LOST 1 +#define SCTP_RESTART 2 +#define SCTP_SHUTDOWN_COMP 3 +#define SCTP_CANT_STR_ASSOC 4 + +/* + * Association flags. This flags is filled in the sac_flags for a SCTP_COMM_UP + * event if the association supports PR-SCTP. + */ +#define SCTP_PRSCTP_CAPABLE 0x01 + +/* + * sctp_assoc_change notification informs the socket that an SCTP association + * has either begun or ended. The identifier for a new association is + * provided by this notification. + */ +struct sctp_assoc_change { + uint16_t sac_type; + uint16_t sac_flags; + uint32_t sac_length; + uint16_t sac_state; + uint16_t sac_error; + uint16_t sac_outbound_streams; + uint16_t sac_inbound_streams; + sctp_assoc_t sac_assoc_id; + /* + * The assoc ID can be followed by the ABORT chunk if available. + */ +}; + +/* + * A remote peer may send an Operational Error message to its peer. This + * message indicates a variety of error conditions on an association. + * The entire ERROR chunk as it appears on the wire is included in a + * SCTP_REMOTE_ERROR event. Refer to the SCTP specification RFC2960 + * and any extensions for a list of possible error formats. + */ +struct sctp_remote_error { + uint16_t sre_type; + uint16_t sre_flags; + uint32_t sre_length; + uint16_t sre_error; + sctp_assoc_t sre_assoc_id; + /* + * The assoc ID is followed by the actual error chunk. + */ +}; + +/* + * Note: + * + * In order to keep the offsets and size of the structure having a + * struct sockaddr_storage field the same between a 32-bit application + * and a 64-bit amd64 kernel, we use a #pragma pack(4) for those + * structures. + */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* Address change event state */ +#define SCTP_ADDR_AVAILABLE 0 +#define SCTP_ADDR_UNREACHABLE 1 +#define SCTP_ADDR_REMOVED 2 +#define SCTP_ADDR_ADDED 3 +#define SCTP_ADDR_MADE_PRIM 4 + +/* + * When a destination address on a multi-homed peer encounters a change, + * an interface details event, sctp_paddr_change, is sent to the socket. + */ +struct sctp_paddr_change { + uint16_t spc_type; + uint16_t spc_flags; + uint32_t spc_length; + struct sockaddr_storage spc_aaddr; + int spc_state; + int spc_error; + sctp_assoc_t spc_assoc_id; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* flags used in sctp_send_failed notification. */ +#define SCTP_DATA_UNSENT 1 +#define SCTP_DATA_SENT 2 + +/* + * If SCTP cannot deliver a message it may return the message as a + * notification using the following structure. + */ +struct sctp_send_failed { + uint16_t ssf_type; + uint16_t ssf_flags; + uint32_t ssf_length; + uint32_t ssf_error; + struct sctp_sndrcvinfo ssf_info; + sctp_assoc_t ssf_assoc_id; + /* + * The assoc ID is followed by the failed message. + */ +}; + +/* + * When a peer sends a SHUTDOWN, SCTP delivers the sctp_shutdown_event + * notification to inform the socket user that it should cease sending data. + */ +struct sctp_shutdown_event { + uint16_t sse_type; + uint16_t sse_flags; + uint16_t sse_length; + sctp_assoc_t sse_assoc_id; +}; + +/* + * When a peer sends an Adaptation Layer Indication parameter, SCTP + * delivers the sctp_adaptation_event notification to inform the socket + * user the peer's requested adaptation layer. + */ +struct sctp_adaptation_event { + uint16_t sai_type; + uint16_t sai_flags; + uint32_t sai_length; + uint32_t sai_adaptation_ind; + sctp_assoc_t sai_assoc_id; +}; + +/* Possible values in pdapi_indication for sctp_pdapi_event notification. */ +#define SCTP_PARTIAL_DELIVERY_ABORTED 1 + +/* + * When a receiver is engaged in a partial delivery of a message the + * sctp_pdapi_event notification is used to indicate various events. + */ +struct sctp_pdapi_event { + uint16_t pdapi_type; + uint16_t pdapi_flags; + uint32_t pdapi_length; + uint32_t pdapi_indication; + sctp_assoc_t pdapi_assoc_id; +}; + +/* + * The sctp_notification structure is defined as the union of all + * notification types defined above. + */ +union sctp_notification { + struct { + uint16_t sn_type; /* Notification type. */ + uint16_t sn_flags; + uint32_t sn_length; + } sn_header; + struct sctp_assoc_change sn_assoc_change; + struct sctp_paddr_change sn_paddr_change; + struct sctp_remote_error sn_remote_error; + struct sctp_send_failed sn_send_failed; + struct sctp_shutdown_event sn_shutdown_event; + struct sctp_adaptation_event sn_adaptation_event; + struct sctp_pdapi_event sn_pdapi_event; +}; + +/* + * sctp_opt_info() option definitions + */ + +/* + * The protocol parameters used to initialize and bound retransmission + * timeout (RTO) are tunable. See RFC2960 for more information on + * how these parameters are used in RTO calculation. + * + * The sctp_rtoinfo structure is used to access and modify these + * parameters. + */ +struct sctp_rtoinfo { + sctp_assoc_t srto_assoc_id; + uint32_t srto_initial; + uint32_t srto_max; + uint32_t srto_min; +}; + +/* + * The sctp_assocparams option is used to both examine and set various + * association and endpoint parameters. See RFC2960 for more information + * on how this parameter is used. The peer address parameter is ignored + * for one-to-one style socket. + */ +struct sctp_assocparams { + sctp_assoc_t sasoc_assoc_id; + uint16_t sasoc_asocmaxrxt; + uint16_t sasoc_number_peer_destinations; + uint32_t sasoc_peer_rwnd; + uint32_t sasoc_local_rwnd; + uint32_t sasoc_cookie_life; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* sctp_paddrinfo reachability state. */ +#define SCTP_INACTIVE 1 +#define SCTP_ACTIVE 2 + +/* + * Applications can retrieve information about a specific peer address + * of an association, including its reachability state, congestion + * window, and retransmission timer values. This information is + * read-only. The sctp_paddrinfo structure is used to access this + * information: + */ +struct sctp_paddrinfo { + sctp_assoc_t spinfo_assoc_id; + struct sockaddr_storage spinfo_address; + int32_t spinfo_state; + uint32_t spinfo_cwnd; + uint32_t spinfo_srtt; + uint32_t spinfo_rto; + uint32_t spinfo_mtu; +}; + +/* + * Applications can enable or disable heartbeats for any peer address of + * an association, modify an address's heartbeat interval, force a + * heartbeat to be sent immediately, and adjust the address's maximum + * number of retransmissions sent before an address is considered + * unreachable. The sctp_paddrparams structure is used to access and modify + * an address' parameters. + */ +struct sctp_paddrparams { + sctp_assoc_t spp_assoc_id; + struct sockaddr_storage spp_address; + uint32_t spp_hbinterval; + uint16_t spp_pathmaxrxt; +}; + +/* + * A socket user can request that the peer mark the enclosed address as the + * association's primary. The enclosed address must be one of the + * association's locally bound addresses. The sctp_setpeerprim structure is + * used to make such request. + */ +struct sctp_setpeerprim { + sctp_assoc_t sspp_assoc_id; + struct sockaddr_storage sspp_addr; +}; + +/* + * A socket user can request that the local SCTP stack use the enclosed peer + * address as the association primary. The enclosed address must be one of + * the association peer's addresses. The sctp_setprim structure is used to + * make such request. + */ +struct sctp_setprim { + sctp_assoc_t ssp_assoc_id; + struct sockaddr_storage ssp_addr; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* SCTP association states */ +#define SCTPS_IDLE -5 /* idle (opened, but not bound) */ +#define SCTPS_BOUND -4 /* bound, ready to connect or accept */ +#define SCTPS_LISTEN -3 /* listening for connection */ +#define SCTPS_COOKIE_WAIT -2 +#define SCTPS_COOKIE_ECHOED -1 +/* states < SCTPS_ESTABLISHED are those where connections not established */ +#define SCTPS_ESTABLISHED 0 /* established */ +#define SCTPS_SHUTDOWN_PENDING 1 +#define SCTPS_SHUTDOWN_SENT 2 +#define SCTPS_SHUTDOWN_RECEIVED 3 +#define SCTPS_SHUTDOWN_ACK_SENT 4 + +/* + * Applications can retrieve current status information about an + * association, including association state, peer receiver window size, + * number of unacked data chunks, and number of data chunks pending + * receipt. This information is read-only. The sctp_status structure is + * used to access this information: + */ +struct sctp_status { + sctp_assoc_t sstat_assoc_id; + int32_t sstat_state; + uint32_t sstat_rwnd; + uint16_t sstat_unackdata; + uint16_t sstat_penddata; + uint16_t sstat_instrms; + uint16_t sstat_outstrms; + uint32_t sstat_fragmentation_point; + struct sctp_paddrinfo sstat_primary; +}; + +/* Possible values for sstat_state */ +#define SCTP_CLOSED SCTPS_IDLE +#define SCTP_BOUND SCTPS_BOUND +#define SCTP_LISTEN SCTPS_LISTEN +#define SCTP_COOKIE_WAIT SCTPS_COOKIE_WAIT +#define SCTP_COOKIE_ECHOED SCTPS_COOKIE_ECHOED +#define SCTP_ESTABLISHED SCTPS_ESTABLISHED +#define SCTP_SHUTDOWN_PENDING SCTPS_SHUTDOWN_PENDING +#define SCTP_SHUTDOWN_SENT SCTPS_SHUTDOWN_SENT +#define SCTP_SHUTDOWN_RECEIVED SCTPS_SHUTDOWN_RECEIVED +#define SCTP_SHUTDOWN_ACK_SENT SCTPS_SHUTDOWN_ACK_SENT + +/* + * A socket user can request that the local endpoint set the specified + * Adaptation Layer Indication parameter for all future INIT and INIT-ACK + * exchanges. The sctp_setadaptation structure is used to make such request. + */ +struct sctp_setadaptation { + uint32_t ssb_adaptation_ind; +}; + +/* + * A socket user request reads local per endpoint association stats. + * All stats are counts except sas_maxrto, which is the max value + * since the last user request for stats on this endpoint. + */ +typedef struct sctp_assoc_stats { + uint64_t sas_rtxchunks; /* Retransmitted Chunks */ + uint64_t sas_gapcnt; /* Gap Acknowledgements Received */ + uint64_t sas_maxrto; /* Maximum Observed RTO this period */ + uint64_t sas_outseqtsns; /* TSN received > next expected */ + uint64_t sas_osacks; /* SACKs sent */ + uint64_t sas_isacks; /* SACKs received */ + uint64_t sas_octrlchunks; /* Control chunks sent - no dups */ + uint64_t sas_ictrlchunks; /* Control chunks received - no dups */ + uint64_t sas_oodchunks; /* Ordered data chunks sent */ + uint64_t sas_iodchunks; /* Ordered data chunks received */ + uint64_t sas_ouodchunks; /* Unordered data chunks sent */ + uint64_t sas_iuodchunks; /* Unordered data chunks received */ + uint64_t sas_idupchunks; /* Dups received (ordered+unordered) */ +} sctp_assoc_stats_t; + +/* + * Private ioctl option structure + */ +struct sctpopt { + sctp_assoc_t sopt_aid; + int sopt_name; + uint_t sopt_len; + caddr_t sopt_val; +}; + +#if defined(_SYSCALL32) +struct sctpopt32 { + sctp_assoc32_t sopt_aid; + int32_t sopt_name; + uint32_t sopt_len; + caddr32_t sopt_val; +}; +#endif /* _SYSCALL32 */ + +/* Forward Cumulative TSN chunk entry. */ +typedef struct ftsn_entry_s { + uint16_t ftsn_sid; + uint16_t ftsn_ssn; +} ftsn_entry_t; + +/* + * New socket functions for SCTP + */ + +/* sctp_bindx() operations. */ +#define SCTP_BINDX_ADD_ADDR 1 +#define SCTP_BINDX_REM_ADDR 2 + +#if !defined(_KERNEL) || defined(_BOOT) +#ifdef __STDC__ +extern int sctp_bindx(int, void *, int, int); +extern void sctp_freeladdrs(void *); +extern void sctp_freepaddrs(void *); +extern int sctp_getladdrs(int, sctp_assoc_t, void **); +extern int sctp_getpaddrs(int, sctp_assoc_t, void **); +extern int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *); +extern int sctp_peeloff(int, sctp_assoc_t); +extern ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *, + socklen_t *, struct sctp_sndrcvinfo *, int *msg_flags); +extern ssize_t sctp_send(int, const void *, size_t, + const struct sctp_sndrcvinfo *, int); +extern ssize_t sctp_sendmsg(int, const void *, size_t, const struct sockaddr *, + socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t); +#else /* __STDC__ */ +extern int sctp_bindx(); +extern void sctp_freeladdrs(); +extern void sctp_freepaddrs(); +extern int sctp_getladdrs(); +extern int sctp_getpaddrs(); +extern int sctp_opt_info(); +extern int sctp_peeloff(); +extern ssize_t sctp_recvmsg(); +extern ssize_t sctp_send(); +extern ssize_t sctp_sendmsg(); +#endif /* __STDC__ */ +#endif /* !defined(_KERNEL) || defined(_BOOT) */ + + +/* + * SCTP protocol related elements. + */ + +/* All SCTP chunks and parameters are 32-bit aligned */ +#define SCTP_ALIGN 4 + +/* + * SCTP association optional parameter handling. The top two bits + * of the parameter type define how this and further parameters in + * the received chunk should be handled. + */ +#define SCTP_UNREC_PARAM_MASK 0xc000 +/* Continue processing parameters after an unrecognized optional param? */ +#define SCTP_CONT_PROC_PARAMS 0x8000 +/* Report this unreconized optional parameter or silently ignore it? */ +#define SCTP_REPORT_THIS_PARAM 0x4000 + +/* + * Data chunk bit manipulations + */ +#define SCTP_DATA_EBIT 0x01 +#define SCTP_TBIT 0x01 +#define SCTP_DATA_BBIT 0x02 +#define SCTP_DATA_UBIT 0x04 + +#define SCTP_DATA_GET_BBIT(sdc) ((sdc)->sdh_flags & SCTP_DATA_BBIT) +#define SCTP_GET_TBIT(cp) ((cp)->sch_flags & SCTP_TBIT) +#define SCTP_DATA_GET_EBIT(sdc) ((sdc)->sdh_flags & SCTP_DATA_EBIT) +#define SCTP_DATA_GET_UBIT(sdc) ((sdc)->sdh_flags & SCTP_DATA_UBIT) + +#define SCTP_DATA_SET_BBIT(sdc) ((sdc)->sdh_flags |= SCTP_DATA_BBIT) +#define SCTP_SET_TBIT(cp) ((cp)->sch_flags |= SCTP_TBIT) +#define SCTP_DATA_SET_EBIT(sdc) ((sdc)->sdh_flags |= SCTP_DATA_EBIT) +#define SCTP_DATA_SET_UBIT(sdc) ((sdc)->sdh_flags |= SCTP_DATA_UBIT) + +/* SCTP common header */ +typedef struct sctp_hdr { + uint16_t sh_sport; + uint16_t sh_dport; + uint32_t sh_verf; + uint32_t sh_chksum; +} sctp_hdr_t; + +/* Chunk IDs */ +typedef enum { + CHUNK_DATA, + CHUNK_INIT, + CHUNK_INIT_ACK, + CHUNK_SACK, + CHUNK_HEARTBEAT, + CHUNK_HEARTBEAT_ACK, + CHUNK_ABORT, + CHUNK_SHUTDOWN, + CHUNK_SHUTDOWN_ACK, + CHUNK_ERROR, + CHUNK_COOKIE, + CHUNK_COOKIE_ACK, + CHUNK_ECNE, + CHUNK_CWR, + CHUNK_SHUTDOWN_COMPLETE, + CHUNK_ASCONF_ACK = 128, + CHUNK_FORWARD_TSN = 192, + CHUNK_ASCONF = 193 +} sctp_chunk_id_t; + +/* Common chunk header */ +typedef struct sctp_chunk_hdr { + uint8_t sch_id; + uint8_t sch_flags; + uint16_t sch_len; +} sctp_chunk_hdr_t; + +/* INIT chunk data definition */ +typedef struct sctp_init_chunk { + uint32_t sic_inittag; + uint32_t sic_a_rwnd; + uint16_t sic_outstr; + uint16_t sic_instr; + uint32_t sic_inittsn; +} sctp_init_chunk_t; + +/* SCTP DATA chunk */ +typedef struct sctp_data_chunk { + uint32_t sdc_tsn; + uint16_t sdc_sid; + uint16_t sdc_ssn; + uint32_t sdc_payload_id; +} sctp_data_chunk_t; + +/* sctp_data_hdr includes the SCTP chunk hdr and the DATA chunk */ +typedef struct sctp_data_hdr { + sctp_chunk_hdr_t sdh_chdr; + sctp_data_chunk_t sdh_data; +#define sdh_id sdh_chdr.sch_id +#define sdh_flags sdh_chdr.sch_flags +#define sdh_len sdh_chdr.sch_len +#define sdh_tsn sdh_data.sdc_tsn +#define sdh_sid sdh_data.sdc_sid +#define sdh_ssn sdh_data.sdc_ssn +#define sdh_payload_id sdh_data.sdc_payload_id +} sctp_data_hdr_t; + +typedef struct sctp_sack_chunk { + uint32_t ssc_cumtsn; + uint32_t ssc_a_rwnd; + uint16_t ssc_numfrags; + uint16_t ssc_numdups; +} sctp_sack_chunk_t; + +typedef struct sctp_sack_frag { + uint16_t ssf_start; + uint16_t ssf_end; +} sctp_sack_frag_t; + +/* Parameter types */ +#define PARM_UNKNOWN 0 +#define PARM_HBINFO 1 +#define PARM_ADDR4 5 +#define PARM_ADDR6 6 +#define PARM_COOKIE 7 +#define PARM_UNRECOGNIZED 8 +#define PARM_COOKIE_PRESERVE 9 +#define PARM_ADDR_HOST_NAME 11 +#define PARM_SUPP_ADDRS 12 +#define PARM_ECN 0x8000 +#define PARM_ECN_CAPABLE PARM_ECN +#define PARM_FORWARD_TSN 0xc000 +#define PARM_ADD_IP 0xc001 +#define PARM_DEL_IP 0xc002 +#define PARM_ERROR_IND 0xc003 +#define PARM_ASCONF_ERROR PARM_ERROR_IND +#define PARM_SET_PRIMARY 0xc004 +#define PARM_PRIMARY_ADDR PARM_SET_PRIMARY +#define PARM_SUCCESS 0xc005 +#define PARM_ASCONF_SUCCESS PARM_SUCCESS +#define PARM_ADAPT_LAYER_IND 0xc006 + + +/* Lengths from SCTP spec */ +#define PARM_ADDR4_LEN 8 +#define PARM_ADDR6_LEN 20 + +/* Parameter header */ +typedef struct sctp_parm_hdr { + uint16_t sph_type; + uint16_t sph_len; +} sctp_parm_hdr_t; + +/* + * The following extend sctp_parm_hdr_t + * with cause-specfic content used to fill + * CAUSE blocks in ABORT or ERROR chunks. + * The overall size of the CAUSE block will + * be sizeof (sctp_parm_hdr_t) plus the size + * of the extended cause structure, + */ + +/* + * Invalid stream-identifier extended cause. + * SCTP_ERR_BAD_SID + */ +typedef struct sctp_bsc { + uint16_t bsc_sid; + uint16_t bsc_pad; /* RESV = 0 */ +} sctp_bsc_t; + +/* + * Missing parameter extended cause, currently + * only one missing parameter is supported. + * SCTP_ERR_MISSING_PARM + */ +typedef struct sctp_mpc { + uint32_t mpc_num; + uint16_t mpc_param; + uint16_t mpc_pad; +} sctp_mpc_t; + +/* Error causes */ +#define SCTP_ERR_UNKNOWN 0 +#define SCTP_ERR_BAD_SID 1 +#define SCTP_ERR_MISSING_PARM 2 +#define SCTP_ERR_STALE_COOKIE 3 +#define SCTP_ERR_NO_RESOURCES 4 +#define SCTP_ERR_BAD_ADDR 5 +#define SCTP_ERR_UNREC_CHUNK 6 +#define SCTP_ERR_BAD_MANDPARM 7 +#define SCTP_ERR_UNREC_PARM 8 +#define SCTP_ERR_NO_USR_DATA 9 +#define SCTP_ERR_COOKIE_SHUT 10 +#define SCTP_ERR_RESTART_NEW_ADDRS 11 +#define SCTP_ERR_USER_ABORT 12 +#define SCTP_ERR_DELETE_LASTADDR 256 +#define SCTP_ERR_RESOURCE_SHORTAGE 257 +#define SCTP_ERR_DELETE_SRCADDR 258 +#define SCTP_ERR_AUTH_ERR 260 + +/* + * Extensions + */ + +/* Extended Chunk Types */ +#define CHUNK_ASCONF 0xc1 +#define CHUNK_ASCONF_ACK 0x80 + +/* Extension Error Causes */ +#define SCTP_ERR_DEL_LAST_ADDR 0x0100 +#define SCTP_ERR_RES_SHORTAGE 0x0101 +#define SCTP_ERR_DEL_SRC_ADDR 0x0102 +#define SCTP_ERR_ILLEGAL_ACK 0x0103 +#define SCTP_ERR_UNAUTHORIZED 0x0104 + +typedef struct sctp_addip4 { + sctp_parm_hdr_t sad4_addip_ph; + uint32_t asconf_req_cid; + sctp_parm_hdr_t sad4_addr4_ph; + ipaddr_t sad4_addr; +} sctp_addip4_t; + +typedef struct sctp_addip6 { + sctp_parm_hdr_t sad6_addip_ph; + uint32_t asconf_req_cid; + sctp_parm_hdr_t sad6_addr6_ph; + in6_addr_t sad6_addr; +} sctp_addip6_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_SCTP_H */ diff --git a/illumos-x86_64/usr/include/netinet/tcp.h b/illumos-x86_64/usr/include/netinet/tcp.h new file mode 100644 index 00000000..9287033e --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/tcp.h @@ -0,0 +1,142 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright 2024 Oxide Computer Company + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_TCP_H +#define _NETINET_TCP_H + +/* tcp.h 1.11 88/08/19 SMI; from UCB 7.2 10/28/86 */ + + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint32_t tcp_seq; +/* + * TCP header. + * Per RFC 793, September, 1981. + */ +struct tcphdr { + uint16_t th_sport; /* source port */ + uint16_t th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +#ifdef _BIT_FIELDS_LTOH + uint_t th_x2:4, /* (unused) */ + th_off:4; /* data offset */ +#else + uint_t th_off:4, /* data offset */ + th_x2:4; /* (unused) */ +#endif + uchar_t th_flags; +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 +#define TH_ECE 0x40 +#define TH_CWR 0x80 + uint16_t th_win; /* window */ + uint16_t th_sum; /* checksum */ + uint16_t th_urp; /* urgent pointer */ +}; + +#define TCPOPT_EOL 0 +#define TCPOPT_NOP 1 +#define TCPOPT_MAXSEG 2 +#define TCPOPT_WSCALE 3 +#define TCPOPT_SACK_PERMITTED 4 +#define TCPOPT_SACK 5 +#define TCPOPT_TSTAMP 8 +#define TCPOPT_MD5 19 /* RFC 2385 */ + +/* + * Default maximum segment size for TCP. + * With an IP MTU of 576, this is 536. + */ +#define TCP_MSS 536 + +/* + * Options for use with [gs]etsockopt at the TCP level. + * + * Note: Some of the TCP_ namespace has conflict with and + * and is exposed through . (It also requires exposing + * options not implemented). The options with potential + * for conflicts use #ifndef guards. + */ +#ifndef TCP_NODELAY +#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ +#endif + +#ifndef TCP_MAXSEG +#define TCP_MAXSEG 0x02 /* set maximum segment size */ +#endif + +#ifndef TCP_KEEPALIVE +#define TCP_KEEPALIVE 0x8 /* set keepalive timer */ +#endif + + +#define TCP_NOTIFY_THRESHOLD 0x10 +#define TCP_ABORT_THRESHOLD 0x11 +#define TCP_CONN_NOTIFY_THRESHOLD 0x12 +#define TCP_CONN_ABORT_THRESHOLD 0x13 +#define TCP_RECVDSTADDR 0x14 +#define TCP_INIT_CWND 0x15 +#define TCP_KEEPALIVE_THRESHOLD 0x16 +#define TCP_KEEPALIVE_ABORT_THRESHOLD 0x17 +#define TCP_CORK 0x18 +#define TCP_RTO_INITIAL 0x19 +#define TCP_RTO_MIN 0x1A +#define TCP_RTO_MAX 0x1B +#define TCP_LINGER2 0x1C + +/* gap for expansion of ``standard'' options */ +#define TCP_ANONPRIVBIND 0x20 /* for internal use only */ +#define TCP_EXCLBIND 0x21 /* for internal use only */ +#define TCP_KEEPIDLE 0x22 +#define TCP_KEEPCNT 0x23 +#define TCP_KEEPINTVL 0x24 +#define TCP_CONGESTION 0x25 +#define TCP_QUICKACK 0x26 /* enable/disable quick acks */ +#define TCP_MD5SIG 0x27 + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_H */ diff --git a/illumos-x86_64/usr/include/netinet/tcp_debug.h b/illumos-x86_64/usr/include/netinet/tcp_debug.h new file mode 100644 index 00000000..5439ada5 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/tcp_debug.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_TCP_DEBUG_H +#define _NETINET_TCP_DEBUG_H + +/* tcp_debug.h 1.8 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct tcp_debug { + n_time td_time; + short td_act; + short td_ostate; + caddr_t td_tcb; + struct tcpiphdr td_ti; + short td_req; + struct tcpcb td_cb; +}; + +#define TA_INPUT 0 +#define TA_OUTPUT 1 +#define TA_USER 2 +#define TA_RESPOND 3 +#define TA_DROP 4 + +#ifdef TANAMES +char *tanames[] = + { "input", "output", "user", "respond", "drop" }; +#endif + +#define TCP_NDEBUG 100 + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_DEBUG_H */ diff --git a/illumos-x86_64/usr/include/netinet/tcp_fsm.h b/illumos-x86_64/usr/include/netinet/tcp_fsm.h new file mode 100644 index 00000000..43073082 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/tcp_fsm.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * TCP FSM state definitions. + * Per RFC793, September, 1981. + */ + +#ifndef _NETINET_TCP_FSM_H +#define _NETINET_TCP_FSM_H + +/* tcp_fsm.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define TCP_NSTATES 11 + +#define TCPS_CLOSED 0 /* closed */ +#define TCPS_LISTEN 1 /* listening for connection */ +#define TCPS_SYN_SENT 2 /* active, have sent syn */ +#define TCPS_SYN_RECEIVED 3 /* have send and received syn */ +/* states < TCPS_ESTABLISHED are those where connections not established */ +#define TCPS_ESTABLISHED 4 /* established */ +#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ +/* states > TCPS_CLOSE_WAIT are those where user has closed */ +#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ +#define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ +#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ +/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ +#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ +#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ + +#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) +#define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT) + +#ifdef TCPOUTFLAGS +/* + * Flags used when sending segments in tcp_output. + * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally + * determined by state, with the proviso that TH_FIN is sent only + * if all data queued for output is included in the segment. + */ +uchar_t tcp_outflags[TCP_NSTATES] = { + TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK, + TH_ACK, TH_ACK, + TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK, +}; +#endif + +#ifdef KPROF +int tcp_acounts[TCP_NSTATES][PRU_NREQ]; +#endif + +#ifdef TCPSTATES +char *tcpstates[] = { + "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", + "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING", + "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT", +}; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_FSM_H */ diff --git a/illumos-x86_64/usr/include/netinet/tcp_seq.h b/illumos-x86_64/usr/include/netinet/tcp_seq.h new file mode 100644 index 00000000..c8cbce76 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/tcp_seq.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_TCP_SEQ_H +#define _NETINET_TCP_SEQ_H + +/* tcp_seq.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/85 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * TCP sequence numbers are 32 bit integers operated + * on with modular arithmetic. These macros can be + * used to compare such integers. + */ +#define SEQ_LT(a, b) ((int32_t)((a)-(b)) < 0) +#define SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) +#define SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) +#define SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) + +/* + * Macros to initialize tcp sequence numbers for + * send and receive from initial send and receive + * sequence numbers. + */ +#define tcp_rcvseqinit(tp) \ + (tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1 + +#define tcp_sendseqinit(tp) \ + (tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \ + (tp)->iss + +#define TCP_ISSINCR (125*1024) /* increment for tcp_iss each second */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_SEQ_H */ diff --git a/illumos-x86_64/usr/include/netinet/tcp_timer.h b/illumos-x86_64/usr/include/netinet/tcp_timer.h new file mode 100644 index 00000000..d120a6d1 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/tcp_timer.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * Copyright (c) 2016 by Delphix. All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + */ + +/* + * Definitions of the TCP timers. These timers are counted + * down PR_SLOWHZ times a second. + */ + +#ifndef _NETINET_TCP_TIMER_H +#define _NETINET_TCP_TIMER_H + +/* tcp_timer.h 1.13 89/06/16 SMI; from UCB 7.6 6/29/88 */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define TCPT_NTIMERS 4 + +#define TCPT_REXMT 0 /* retransmit */ +#define TCPT_PERSIST 1 /* retransmit persistance */ +#define TCPT_KEEP 2 /* keep alive */ +#define TCPT_2MSL 3 /* 2*msl quiet time timer */ + +/* + * The TCPT_REXMT timer is used to force retransmissions. + * The TCP has the TCPT_REXMT timer set whenever segments + * have been sent for which ACKs are expected but not yet + * received. If an ACK is received which advances tp->snd_una, + * then the retransmit timer is cleared (if there are no more + * outstanding segments) or reset to the base value (if there + * are more ACKs expected). Whenever the retransmit timer goes off, + * we retransmit one unacknowledged segment, and do a backoff + * on the retransmit timer. + * + * The TCPT_PERSIST timer is used to keep window size information + * flowing even if the window goes shut. If all previous transmissions + * have been acknowledged (so that there are no retransmissions in progress), + * and the window is too small to bother sending anything, then we start + * the TCPT_PERSIST timer. When it expires, if the window is nonzero, + * we go to transmit state. Otherwise, at intervals send a single byte + * into the peer's window to force it to update our window information. + * We do this at most as often as TCPT_PERSMIN time intervals, + * but no more frequently than the current estimate of round-trip + * packet time. The TCPT_PERSIST timer is cleared whenever we receive + * a window update from the peer. + * + * The TCPT_KEEP timer is used to keep connections alive. If a + * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time, + * but not yet established, then we drop the connection. Once the connection + * is established, if the connection is idle for TCPTV_KEEP_IDLE time + * (and keepalives have been enabled on the socket), we begin to probe + * the connection. We force the peer to send us a segment by sending: + * + * This segment is (deliberately) outside the window, and should elicit + * an ack segment in response from the peer. If, despite the TCPT_KEEP + * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE + * amount of time probing, then we drop the connection. + */ + +#define TCP_TTL 60 /* default time to live for TCP segs */ +/* + * Time constants. + */ +#define TCPTV_MSL (30*PR_SLOWHZ) /* max seg lifetime (hah!) */ +#define TCPTV_SRTTBASE 0 /* base roundtrip time; */ + /* if 0, no idea yet */ +#define TCPTV_SRTTDFLT (3*PR_SLOWHZ) /* assumed RTT if no info */ + +#define TCPTV_PERSMIN (5*PR_SLOWHZ) /* retransmit persistance */ +#define TCPTV_PERSMAX (60*PR_SLOWHZ) /* maximum persist interval */ + +#define TCPTV_KEEP_INIT (75*PR_SLOWHZ) /* initial connect keep alive */ +#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */ +#define TCPTV_KEEPINTVL (75*PR_SLOWHZ) /* default probe interval */ +#define TCPTV_KEEPCNT 8 /* max probes before drop */ + +#define TCPTV_MIN (1*PR_SLOWHZ) /* minimum allowable value */ +#define TCPTV_REXMTMAX (64*PR_SLOWHZ) /* max allowable REXMT value */ + +#define TCP_LINGERTIME 120 /* linger at most 2 minutes */ + +#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ + +#ifdef TCPTIMERS +char *tcptimers[] = + { "REXMT", "PERSIST", "KEEP", "2MSL" }; +#endif + +/* + * Force a time value to be in a certain range. + */ +#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ + (tv) = (value); \ + if ((tv) < (tvmin)) \ + (tv) = (tvmin); \ + else if ((tv) > (tvmax)) \ + (tv) = (tvmax); \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_TIMER_H */ diff --git a/illumos-x86_64/usr/include/netinet/tcp_var.h b/illumos-x86_64/usr/include/netinet/tcp_var.h new file mode 100644 index 00000000..083124d4 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/tcp_var.h @@ -0,0 +1,161 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Kernel variables for tcp. + */ + +#ifndef _NETINET_TCP_VAR_H +#define _NETINET_TCP_VAR_H + +/* tcp_var.h 1.11 88/08/19 SMI; from UCB 7.3 6/30/87 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Tcp control block, one per tcp; fields: + */ +struct tcpcb { + struct tcpiphdr *seg_next; /* sequencing queue */ + struct tcpiphdr *seg_prev; + short t_state; /* state of this connection */ + short t_timer[TCPT_NTIMERS]; /* tcp timers */ + short t_rxtshift; /* log(2) of rexmt exp. backoff */ + short t_rxtcur; /* current retransmit value */ + short t_dupacks; /* consecutive dup acks recd */ + ushort_t t_maxseg; /* maximum segment size */ + char t_force; /* 1 if forcing out a byte */ + uchar_t t_flags; +#define TF_ACKNOW 0x01 /* ack peer immediately */ +#define TF_DELACK 0x02 /* ack, but try to delay it */ +#define TF_NODELAY 0x04 /* don't delay packets to coalesce */ +#define TF_NOOPT 0x08 /* don't use tcp options */ +#define TF_SENTFIN 0x10 /* have sent FIN */ + struct tcpiphdr *t_template; /* skeletal packet for transmit */ + struct inpcb *t_inpcb; /* back pointer to internet pcb */ +/* + * The following fields are used as in the protocol specification. + * See RFC783, Dec. 1981, page 21. + */ +/* send sequence variables */ + tcp_seq snd_una; /* send unacknowledged */ + tcp_seq snd_nxt; /* send next */ + tcp_seq snd_up; /* send urgent pointer */ + tcp_seq snd_wl1; /* window update seg seq number */ + tcp_seq snd_wl2; /* window update seg ack number */ + tcp_seq iss; /* initial send sequence number */ + ushort_t snd_wnd; /* send window */ +/* receive sequence variables */ + ushort_t rcv_wnd; /* receive window */ + tcp_seq rcv_nxt; /* receive next */ + tcp_seq rcv_up; /* receive urgent pointer */ + tcp_seq irs; /* initial receive sequence number */ +/* + * Additional variables for this implementation. + */ +/* receive variables */ + tcp_seq rcv_adv; /* advertised window */ +/* retransmit variables */ + tcp_seq snd_max; /* highest sequence number sent */ + /* used to recognize retransmits */ + +/* congestion control (for slow start, source quench, retransmit after loss) */ + ushort_t snd_cwnd; /* congestion-controlled window */ + ushort_t snd_ssthresh; /* snd_cwnd size threshhold for */ + /* for slow start exponential to */ +/* + * transmit timing stuff. + * srtt and rttvar are stored as fixed point; for convenience in smoothing, + * srtt has 3 bits to the right of the binary point, rttvar has 2. + * "Variance" is actually smoothed difference. + */ + short t_idle; /* inactivity time */ + short t_rtt; /* round trip time */ + tcp_seq t_rtseq; /* sequence number being timed */ + short t_srtt; /* smoothed round-trip time */ + short t_rttvar; /* variance in round-trip time */ + ushort_t max_rcvd; /* most peer has sent into window */ + ushort_t max_sndwnd; /* largest window peer has offered */ +/* out-of-band data */ + char t_oobflags; /* have some */ + char t_iobc; /* input character */ +#define TCPOOB_HAVEDATA 0x01 +#define TCPOOB_HADDATA 0x02 +}; + +#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) +#define sototcpcb(so) (intotcpcb(sotoinpcb(so))) + +/* + * TCP statistics. + * Many of these should be kept per connection, + * but that's inconvenient at the moment. + */ +struct tcpstat { + uint_t tcps_connattempt; /* connections initiated */ + uint_t tcps_accepts; /* connections accepted */ + uint_t tcps_connects; /* connections established */ + uint_t tcps_drops; /* connections dropped */ + uint_t tcps_conndrops; /* embryonic connections dropped */ + uint_t tcps_closed; /* conn. closed (includes drops) */ + uint_t tcps_segstimed; /* segs where we tried to get rtt */ + uint_t tcps_rttupdated; /* times we succeeded */ + uint_t tcps_delack; /* delayed acks sent */ + uint_t tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ + uint_t tcps_rexmttimeo; /* retransmit timeouts */ + uint_t tcps_persisttimeo; /* persist timeouts */ + uint_t tcps_keeptimeo; /* keepalive timeouts */ + uint_t tcps_keepprobe; /* keepalive probes sent */ + uint_t tcps_keepdrops; /* connections dropped in keepalive */ + + uint_t tcps_sndtotal; /* total packets sent */ + uint_t tcps_sndpack; /* data packets sent */ + uint_t tcps_sndbyte; /* data bytes sent */ + uint_t tcps_sndrexmitpack; /* data packets retransmitted */ + uint_t tcps_sndrexmitbyte; /* data bytes retransmitted */ + uint_t tcps_sndacks; /* ack-only packets sent */ + uint_t tcps_sndprobe; /* window probes sent */ + uint_t tcps_sndurg; /* packets sent with URG only */ + uint_t tcps_sndwinup; /* window update-only packets sent */ + uint_t tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ + + uint_t tcps_rcvtotal; /* total packets received */ + uint_t tcps_rcvpack; /* packets received in sequence */ + uint_t tcps_rcvbyte; /* bytes received in sequence */ + uint_t tcps_rcvbadsum; /* packets received with ccksum errs */ + uint_t tcps_rcvbadoff; /* packets received with bad offset */ + uint_t tcps_rcvshort; /* packets received too short */ + uint_t tcps_rcvduppack; /* duplicate-only packets received */ + uint_t tcps_rcvdupbyte; /* duplicate-only bytes received */ + uint_t tcps_rcvpartduppack; /* packets with some duplicate data */ + uint_t tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ + uint_t tcps_rcvoopack; /* out-of-order packets received */ + uint_t tcps_rcvoobyte; /* out-of-order bytes received */ + uint_t tcps_rcvpackafterwin; /* packets with data after window */ + uint_t tcps_rcvbyteafterwin; /* bytes rcvd after window */ + uint_t tcps_rcvafterclose; /* packets rcvd after "close" */ + uint_t tcps_rcvwinprobe; /* rcvd window probe packets */ + uint_t tcps_rcvdupack; /* rcvd duplicate acks */ + uint_t tcps_rcvacktoomuch; /* rcvd acks for unsent data */ + uint_t tcps_rcvackpack; /* rcvd ack packets */ + uint_t tcps_rcvackbyte; /* bytes acked by rcvd acks */ + uint_t tcps_rcvwinupd; /* rcvd window update packets */ +}; + +#define TCP_COMPAT_42 + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_VAR_H */ diff --git a/illumos-x86_64/usr/include/netinet/tcpip.h b/illumos-x86_64/usr/include/netinet/tcpip.h new file mode 100644 index 00000000..cd4c67c7 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/tcpip.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Tcp+ip header, after ip options removed. + */ + +#ifndef _NETINET_TCPIP_H +#define _NETINET_TCPIP_H + +/* tcpip.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/85 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct tcpiphdr { + struct ipovly ti_i; /* overlaid ip structure */ + struct tcphdr ti_t; /* tcp header */ +}; +#define ti_next ti_i.ih_next +#define ti_prev ti_i.ih_prev +#define ti_x1 ti_i.ih_x1 +#define ti_pr ti_i.ih_pr +#define ti_len ti_i.ih_len +#define ti_src ti_i.ih_src +#define ti_dst ti_i.ih_dst +#define ti_sport ti_t.th_sport +#define ti_dport ti_t.th_dport +#define ti_seq ti_t.th_seq +#define ti_ack ti_t.th_ack +#define ti_x2 ti_t.th_x2 +#define ti_off ti_t.th_off +#define ti_flags ti_t.th_flags +#define ti_win ti_t.th_win +#define ti_sum ti_t.th_sum +#define ti_urp ti_t.th_urp + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCPIP_H */ diff --git a/illumos-x86_64/usr/include/netinet/udp.h b/illumos-x86_64/usr/include/netinet/udp.h new file mode 100644 index 00000000..74cff75d --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/udp.h @@ -0,0 +1,61 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Udp protocol header. + * Per RFC 768, September, 1981. + */ + +#ifndef _NETINET_UDP_H +#define _NETINET_UDP_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct udphdr { + in_port_t uh_sport; /* source port */ + in_port_t uh_dport; /* destination port */ + int16_t uh_ulen; /* udp length */ + uint16_t uh_sum; /* udp checksum */ +}; + +/* Option definitions. */ +#define UDP_ANONPRIVBIND 0x0100 /* for internal use only */ +#define UDP_EXCLBIND 0x0101 /* for internal use only */ +#define UDP_RCVHDR 0x0102 /* for internal use only */ +#define UDP_NAT_T_ENDPOINT 0x0103 /* for internal use only */ +#define UDP_SRCPORT_HASH 0x0104 /* for internal use only */ +#define UDP_SND_TO_CONNECTED 0x0105 /* for internal use only */ + +/* + * Hash definitions for UDP_SRCPORT_HASH that effectively tell UDP how to go + * handle UDP_SRCPORT_HASH. + */ +#define UDP_HASH_DISABLE 0x0000 /* for internal use only */ +#define UDP_HASH_VXLAN 0x0001 /* for internal use only */ + +/* + * Following option in UDP_ namespace required to be exposed through + * (It also requires exposing options not implemented). The options + * with potential for conflicts use #ifndef guards. + * + */ +#ifndef UDP_CHECKSUM +#define UDP_CHECKSUM 0x0600 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_UDP_H */ diff --git a/illumos-x86_64/usr/include/netinet/udp_var.h b/illumos-x86_64/usr/include/netinet/udp_var.h new file mode 100644 index 00000000..70cbdff0 --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/udp_var.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * UDP kernel structures and variables. + */ + +#ifndef _NETINET_UDP_VAR_H +#define _NETINET_UDP_VAR_H + +/* udp_var.h 1.8 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct udpiphdr { + struct ipovly ui_i; /* overlaid ip structure */ + struct udphdr ui_u; /* udp header */ +}; +#define ui_next ui_i.ih_next +#define ui_prev ui_i.ih_prev +#define ui_x1 ui_i.ih_x1 +#define ui_pr ui_i.ih_pr +#define ui_len ui_i.ih_len +#define ui_src ui_i.ih_src +#define ui_dst ui_i.ih_dst +#define ui_sport ui_u.uh_sport +#define ui_dport ui_u.uh_dport +#define ui_ulen ui_u.uh_ulen +#define ui_sum ui_u.uh_sum + +struct udpstat { + int udps_hdrops; + int udps_badsum; + int udps_badlen; + int udps_fullsock; +}; + +#define UDP_TTL 30 /* time to live for UDP packets */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_UDP_VAR_H */ diff --git a/illumos-x86_64/usr/include/netinet/vrrp.h b/illumos-x86_64/usr/include/netinet/vrrp.h new file mode 100644 index 00000000..30cb8eee --- /dev/null +++ b/illumos-x86_64/usr/include/netinet/vrrp.h @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _VRRP_H +#define _VRRP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct vrrp_pkt_s { + uint8_t vp_vers_type; + uint8_t vp_vrid; + uint8_t vp_prio; + uint8_t vp_ipnum; + uint16_t vp_rsvd_adver_int; + uint16_t vp_chksum; + /* then follows IPvX addresses */ + /* then follows NO authentification data */ +} vrrp_pkt_t; + +#define IPPROTO_VRRP 112 /* IP protocol number */ +#define VRRP_AUTH_LEN 0 /* XXX length of a chunk of Auth Data */ + +#define VRRP_IP_TTL 255 /* IPv4 TTL, IPv6 hop limit */ +#define VRRP_VERSION 3 /* current version */ +#define VRRP_PKT_ADVERT 1 /* packet type */ +#define VRRP_VER_MASK 0xf0 /* version mask */ +#define VRRP_TYPE_MASK 0x0f /* packet type mask */ + +#define VRRP_PRI_OWNER 255 /* priority of IP address owner */ +#define VRRP_PRI_MIN 1 /* minimum priority */ +#define VRRP_PRIO_ZERO 0 /* stop participating VRRP */ +#define VRRP_PRI_DEFAULT VRRP_PRI_OWNER /* default priority */ + +#define VRRP_VRID_NONE 0 +#define VRRP_VRID_MIN 1 +#define VRRP_VRID_MAX 255 + +#define CENTISEC2MSEC(centisec) ((centisec) * 10) +#define MSEC2CENTISEC(msec) ((msec) / 10) + +/* Max advertisement interval, in msec */ +#define VRRP_MAX_ADVER_INT_MIN CENTISEC2MSEC(1) +#define VRRP_MAX_ADVER_INT_MAX CENTISEC2MSEC(4095) /* (2^12 -1) */ +#define VRRP_MAX_ADVER_INT_DFLT CENTISEC2MSEC(100) /* 1 sec */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VRRP_H */ diff --git a/illumos-x86_64/usr/include/netpacket/packet.h b/illumos-x86_64/usr/include/netpacket/packet.h new file mode 100644 index 00000000..ba49076a --- /dev/null +++ b/illumos-x86_64/usr/include/netpacket/packet.h @@ -0,0 +1,218 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015 Joyent, Inc. All rights reserved. + */ + +#ifndef _PACKET_H +#define _PACKET_H + +#include +#include +#include + +/* + * With which we do the reverse of what it libpcap does.... + */ +#define PACKET_OUTGOING LINUX_SLL_OUTGOING +#define PACKET_HOST LINUX_SLL_HOST +#define PACKET_BROADCAST LINUX_SLL_BROADCAST +#define PACKET_MULTICAST LINUX_SLL_MULTICAST +#define PACKET_OTHERHOST LINUX_SLL_OTHERHOST + +#define PACKET_STATISTICS_SHORT 1 +#define PACKET_ADD_MEMBERSHIP 2 +#define PACKET_DROP_MEMBERSHIP 3 +#define PACKET_AUXDATA 4 +#define PACKET_STATISTICS 5 + + +struct packet_mreq { + uint32_t mr_ifindex; + uint16_t mr_type; + uint16_t mr_alen; + uint8_t mr_address[8]; +}; + +#define PACKET_MR_MULTICAST 1 +#define PACKET_MR_PROMISC 2 +#define PACKET_MR_ALLMULTI 3 + +typedef enum tpkt_status_e { + TP_STATUS_KERNEL, + TP_STATUS_USER, + TP_STATUS_COPY, + TP_STATUS_LOSING, + TP_STATUS_CSUMNOTREADY +} tpkt_status_t; + +struct tpacket_auxdata { /* tp_macoff/tp_netoff ?? */ + tpkt_status_t tp_status; + uint32_t tp_len; + uint32_t tp_snaplen; + uint16_t tp_macoff; + uint16_t tp_netoff; + uint16_t tp_vlan_vci; +}; + +struct tpacket_hdr { /* tp_macoff/tp_netoff ?? */ + uint64_t tp_status; + uint32_t tp_len; + uint32_t tp_snaplen; + uint16_t tp_macoff; + uint16_t tp_netoff; + uint32_t tp_sec; + uint32_t tp_usec; +}; + +struct tpacket2_hdr { /* tp_macoff/tp_netoff ?? */ + tpkt_status_t tp_status; + uint32_t tp_len; + uint32_t tp_snaplen; + uint16_t tp_macoff; + uint16_t tp_netoff; + uint32_t tp_sec; + uint32_t tp_nsec; + uint16_t tp_vlan_tci; +}; + +struct tpacket_stats { + uint32_t tp_packets; + uint32_t tp_drops; +}; + +struct tpacket_stats_short { + uint16_t tp_packets; + uint16_t tp_drops; +}; + +struct sock_filter { /* Fields named from bpf_insn */ + uint16_t code; + uint8_t jt; + uint8_t jf; + uint32_t k; +}; + +struct sock_fprog { + uint16_t len; + struct sock_filter *filter; +}; + +/* + * Linux ARPHRD_ symbols needed... + * + * The numbers above 50000 are because their real value is unknown from + * libpcap's source, so a number has been chosen that is unlikely to be + * confused with the real one on Linux. Those that are already found in + * Solaris inside may have a different value to that found + * in Linux but it should be used instead as the Solaris value originates + * from the IANA whereas the Linux values seem to ignore it. + */ +/* ARPHRD_AX25 see */ +/* ARPHRD_CHAOS see */ +#define ARPHRD_CSLIP 50005 +#define ARPHRD_CSLIP6 50006 +#define ARPHRD_DLCI 15 +/* ARPHRD_EETHER see */ +/* ARPHRD_ETHER see */ +#define ARPHRD_FCAL 785 +#define ARPHRD_FCFABRIC 787 +#define ARPHRD_FCPL 786 +#define ARPHRD_FCPP 784 +#define ARPHRD_FRAD 770 +#define ARPHRD_FDDI 774 +/* ARPHRD_IEEE802 see */ +#define ARPHRD_IEEE802_TR 800 +#define ARPHRD_IEEE80211 801 +#define ARPHRD_IEEE80211_PRISM 802 +#define ARPHRD_IEEE80211_RADIOTAP 803 +#define ARPHRD_IRDA 783 +#define ARPHRD_LAPD 8445 +#define ARPHRD_LOCALTLK 50010 +#define ARPHRD_LOOPBACK 50011 +/* ARPHRD_METRICOM see */ +#define ARPHRD_PRONET 50013 +#define ARPHRD_PPP 50014 +#define ARPHRD_RAWHDLC 518 +#define ARPHRD_SIT 776 +#define ARPHRD_SLIP6 50015 +#define ARPHRD_SLIP 50016 +/* ARPHRD_TUNNEL see */ + +#define ETH_P_ALL 0 +#define ETH_P_802_2 0xaa /* LSAP_SAP */ +#define ETH_P_803_3 0 +#define ETH_P_IP 0x800 +#define ETH_P_ARP 0x806 +#define ETH_P_IPV6 0x86dd + +#ifdef _KERNEL +/* + * PFP socket structure. + */ +typedef struct pfpsock { + struct bpf_program ps_bpf; + krwlock_t ps_bpflock; + sock_upper_handle_t ps_upper; + sock_upcalls_t *ps_upcalls; + mac_handle_t ps_mh; + mac_client_handle_t ps_mch; + mac_promisc_handle_t ps_phd; + int ps_type; + int ps_proto; + uint_t ps_max_sdu; + boolean_t ps_bound; + mac_client_promisc_type_t ps_promisc; + boolean_t ps_auxdata; + struct tpacket_stats ps_stats; + struct sockaddr_ll ps_sock; + datalink_id_t ps_linkid; + kmutex_t ps_lock; + boolean_t ps_flow_ctrld; + ulong_t ps_flow_ctrl_drops; + timespec_t ps_timestamp; + size_t ps_rcvbuf; +} pfpsock_t; + +typedef struct pfp_kstats_s { + kstat_named_t kp_recv_mac_hdr_fail; + kstat_named_t kp_recv_bad_proto; + kstat_named_t kp_recv_alloc_fail; + kstat_named_t kp_recv_ok; + kstat_named_t kp_recv_fail; + kstat_named_t kp_recv_filtered; + kstat_named_t kp_recv_flow_cntrld; + kstat_named_t kp_send_unbound; + kstat_named_t kp_send_failed; + kstat_named_t kp_send_too_big; + kstat_named_t kp_send_alloc_fail; + kstat_named_t kp_send_uiomove_fail; + kstat_named_t kp_send_no_memory; + kstat_named_t kp_send_open_fail; + kstat_named_t kp_send_wrong_family; + kstat_named_t kp_send_short_msg; + kstat_named_t kp_send_ok; +} pfp_kstats_t; +#endif /* _KERNEL */ + +#endif /* _PACKET_H */ diff --git a/illumos-x86_64/usr/include/nfs/auth.h b/illumos-x86_64/usr/include/nfs/auth.h new file mode 100644 index 00000000..c33ac714 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/auth.h @@ -0,0 +1,205 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _AUTH_H +#define _AUTH_H + +/* + * nfsauth_prot.x (The NFSAUTH Protocol) + * + * This protocol is used by the kernel to authorize NFS clients. This svc + * lives in the mount daemon and checks the client's access for an export + * with a given authentication flavor. + * + * The status result determines what kind of access the client is permitted. + * + * The result is cached in the kernel, so the authorization call will be + * made only the first time the client mounts the filesystem. + * + * const A_MAXPATH = 1024; + * + * struct auth_req { + * netobj req_client; # client's address + * string req_netid<>; # Netid of address + * string req_path; # export path + * int req_flavor; # auth flavor + * uid_t req_clnt_uid; # client's uid + * gid_t req_clnt_gid; # client's gid + * gid_t req_clnt_gids<>; # client's supplemental groups + * }; + * + * const NFSAUTH_DENIED = 0x01; # Access denied + * const NFSAUTH_RO = 0x02; # Read-only + * const NFSAUTH_RW = 0x04; # Read-write + * const NFSAUTH_ROOT = 0x08; # Root access + * const NFSAUTH_WRONGSEC = 0x10; # Advise NFS v4 clients to + * # try a different flavor + * const NFSAUTH_UIDMAP = 0x100; # uid mapped + * const NFSAUTH_GIDMAP = 0x200; # gid mapped + * const NFSAUTH_GROUPS = 0x400; # translated supplemental groups + * # + * # The following are not part of the protocol. + * # + * const NFSAUTH_DROP = 0x20; # Drop request + * const NFSAUTH_MAPNONE = 0x40; # Mapped flavor to AUTH_NONE + * const NFSAUTH_LIMITED = 0x80; # Access limited to visible nodes + * + * struct auth_res { + * int auth_perm; + * uid_t auth_srv_uid; # translated uid + * gid_t auth_srv_gid; # translated gid + * gid_t auth_srv_gids<>; # translated supplemental groups + * }; + * + * program NFSAUTH_PROG { + * version NFSAUTH_VERS { + * # + * # Authorization Request + * # + * auth_res + * NFSAUTH_ACCESS(auth_req) = 1; + * + * } = 1; + * } = 100231; + */ + +#ifndef _KERNEL +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* --8<-- Start: nfsauth_prot.x definitions --8<-- */ + +#define A_MAXPATH 1024 + +#define NFSAUTH_ACCESS 1 + +#define NFSAUTH_DENIED 0x01 +#define NFSAUTH_RO 0x02 +#define NFSAUTH_RW 0x04 +#define NFSAUTH_ROOT 0x08 +#define NFSAUTH_WRONGSEC 0x10 +#define NFSAUTH_DROP 0x20 +#define NFSAUTH_MAPNONE 0x40 +#define NFSAUTH_LIMITED 0x80 +#define NFSAUTH_UIDMAP 0x100 +#define NFSAUTH_GIDMAP 0x200 +#define NFSAUTH_GROUPS 0x400 + +struct auth_req { + netobj req_client; + char *req_netid; + char *req_path; + int req_flavor; + uid_t req_clnt_uid; + gid_t req_clnt_gid; + struct { + uint_t len; + gid_t *val; + } req_clnt_gids; +}; +typedef struct auth_req auth_req; + +struct auth_res { + int auth_perm; + uid_t auth_srv_uid; + gid_t auth_srv_gid; + struct { + uint_t len; + gid_t *val; + } auth_srv_gids; +}; +typedef struct auth_res auth_res; + +/* --8<-- End: nfsauth_prot.x definitions --8<-- */ + + +#define NFSAUTH_DR_OKAY 0x0 /* success */ +#define NFSAUTH_DR_BADCMD 0x100 /* NFSAUTH_ACCESS is only cmd allowed */ +#define NFSAUTH_DR_DECERR 0x200 /* mountd could not decode arguments */ +#define NFSAUTH_DR_EFAIL 0x400 /* mountd could not encode results */ +#define NFSAUTH_DR_TRYCNT 5 /* door handle acquisition retry cnt */ + +#if defined(DEBUG) && !defined(_KERNEL) +#define MOUNTD_DOOR "/var/run/mountd_door" +#endif + +/* + * Only cmd is added to the args. We need to know "what" we want + * the daemon to do for us. Also, 'stat' returns the status from + * the daemon down to the kernel in addition to perms. + */ +struct nfsauth_arg { + uint_t cmd; + auth_req areq; +}; +typedef struct nfsauth_arg nfsauth_arg_t; + +struct nfsauth_res { + uint_t stat; + auth_res ares; +}; +typedef struct nfsauth_res nfsauth_res_t; + +/* + * For future extensibility, we version the data structures so + * future incantations of mountd(8) will know how to XDR decode + * the arguments. + */ +enum vtypes { + V_ERROR = 0, + V_PROTO = 1 +}; +typedef enum vtypes vtypes; + +typedef struct varg { + uint_t vers; + union { + nfsauth_arg_t arg; + /* additional args versions go here */ + } arg_u; +} varg_t; + +extern bool_t xdr_varg(XDR *, varg_t *); +extern bool_t xdr_nfsauth_arg(XDR *, nfsauth_arg_t *); +extern bool_t xdr_nfsauth_res(XDR *, nfsauth_res_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _AUTH_H */ diff --git a/illumos-x86_64/usr/include/nfs/export.h b/illumos-x86_64/usr/include/nfs/export.h new file mode 100644 index 00000000..d06120ac --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/export.h @@ -0,0 +1,729 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Jason King. + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _NFS_EXPORT_H +#define _NFS_EXPORT_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include /* for PKP_HASH_SIZE */ +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * nfs pseudo flavor number is owned by IANA. Need to make sure the + * Solaris specific NFS_FLAVOR_NOMAP number will not overlap with any + * new IANA defined pseudo flavor numbers. The chance for the overlap + * is very small since the growth of new flavor numbers is expected + * to be limited. + */ +#define NFS_FLAVOR_NOMAP 999999 /* no nfs flavor mapping */ + +/* + * As duplicate flavors can be passed into exportfs in the arguments, we + * allocate a cleaned up array with non duplicate flavors on the stack. + * So we need to know how much to allocate. + */ +#define MAX_FLAVORS 6 /* none, sys, dh, krb5, krb5i krb5p */ + +/* + * Note: exported_lock is currently used to ensure the integrity of + * the secinfo fields. + */ +struct secinfo { + seconfig_t s_secinfo; /* /etc/nfssec.conf entry */ + unsigned int s_flags; /* flags (see below) */ + int32_t s_refcnt; /* reference count for tracking */ + /* how many children (self included) */ + /* use this flavor. */ + int s_window; /* window */ + uint_t s_rootid; /* UID to use for authorized roots */ + int s_rootcnt; /* count of root names */ + caddr_t *s_rootnames; /* array of root names */ + /* they are strings for AUTH_DES and */ + /* rpc_gss_principal_t for RPCSEC_GSS */ +}; + +#ifdef _SYSCALL32 +struct secinfo32 { + seconfig32_t s_secinfo; /* /etc/nfssec.conf entry */ + uint32_t s_flags; /* flags (see below) */ + int32_t s_refcnt; /* reference count for tracking */ + /* how many children (self included) */ + /* use this flavor. */ + int32_t s_window; /* window */ + uint32_t s_rootid; /* UID to use for authorized roots */ + int32_t s_rootcnt; /* count of root names */ + caddr32_t s_rootnames; /* array of root names */ + /* they are strings for AUTH_DES and */ + /* rpc_gss_principal_t for RPCSEC_GSS */ +}; +#endif /* _SYSCALL32 */ + +/* + * security negotiation related + */ + +#define SEC_QUERY 0x01 /* query sec modes */ + +struct sec_ol { + int sec_flags; /* security nego flags */ + uint_t sec_index; /* index into sec flavor array */ +}; + +/* + * Per-mode flags (secinfo.s_flags) + */ +#define M_RO 0x01 /* exported ro to all */ +#define M_ROL 0x02 /* exported ro to all listed */ +#define M_RW 0x04 /* exported rw to all */ +#define M_RWL 0x08 /* exported ro to all listed */ +#define M_ROOT 0x10 /* root list is defined */ +#define M_4SEC_EXPORTED 0x20 /* this is an explicitly shared flavor */ +#define M_NONE 0x40 /* none list is defined */ +#define M_MAP 0x80 /* uidmap and/or gidmap is defined */ + +/* invalid secinfo reference count */ +#define SEC_REF_INVALID(p) ((p)->s_refcnt < 1) + +/* last secinfo reference */ +#define SEC_REF_LAST(p) ((p)->s_refcnt == 1) + +/* sec flavor explicitly shared for the exported node */ +#define SEC_REF_EXPORTED(p) ((p)->s_flags & M_4SEC_EXPORTED) + +/* the only reference count left is for referring itself */ +#define SEC_REF_SELF(p) (SEC_REF_LAST(p) && SEC_REF_EXPORTED(p)) + +/* + * The export information passed to exportfs() (Version 2) + */ +#define EX_CURRENT_VERSION 2 /* current version of exportdata struct */ + +struct exportdata { + int ex_version; /* structure version */ + char *ex_path; /* exported path */ + size_t ex_pathlen; /* path length */ + int ex_flags; /* flags */ + unsigned int ex_anon; /* uid for unauthenticated requests */ + int ex_seccnt; /* count of security modes */ + struct secinfo *ex_secinfo; /* security mode info */ + char *ex_index; /* index file for public filesystem */ + char *ex_log_buffer; /* path to logging buffer file */ + size_t ex_log_bufferlen; /* buffer file path len */ + char *ex_tag; /* tag used to identify log config */ + size_t ex_taglen; /* tag length */ +}; + +#ifdef _SYSCALL32 +struct exportdata32 { + int32_t ex_version; /* structure version */ + caddr32_t ex_path; /* exported path */ + int32_t ex_pathlen; /* path length */ + int32_t ex_flags; /* flags */ + uint32_t ex_anon; /* uid for unauthenticated requests */ + int32_t ex_seccnt; /* count of security modes */ + caddr32_t ex_secinfo; /* security mode info */ + caddr32_t ex_index; /* index file for public filesystem */ + caddr32_t ex_log_buffer; /* path to logging buffer file */ + int32_t ex_log_bufferlen; /* buffer file path len */ + caddr32_t ex_tag; /* tag used to identify log config */ + int32_t ex_taglen; /* tag length */ +}; +#endif /* _SYSCALL32 */ + +/* + * exported vfs flags. + */ + +#define EX_NOSUID 0x01 /* exported with unsetable set[ug]ids */ +#define EX_ACLOK 0x02 /* exported with maximal access if acl exists */ +#define EX_PUBLIC 0x04 /* exported with public filehandle */ +#define EX_NOSUB 0x08 /* no nfs_getfh or MCL below export point */ +#define EX_INDEX 0x10 /* exported with index file specified */ +#define EX_LOG 0x20 /* logging enabled */ +#define EX_LOG_ALLOPS 0x40 /* logging of all RPC operations enabled */ + /* by default only operations which affect */ + /* transaction logging are enabled */ +#define EX_PSEUDO 0x80 /* pseudo filesystem export */ +#ifdef VOLATILE_FH_TEST +#define EX_VOLFH 0x100 /* XXX nfsv4 fh may expire anytime */ +#define EX_VOLRNM 0x200 /* XXX nfsv4 fh expire at rename */ +#define EX_VOLMIG 0x400 /* XXX nfsv4 fh expire at migration */ +#define EX_NOEXPOPEN 0x800 /* XXX nfsv4 fh no expire with open */ +#endif /* VOLATILE_FH_TEST */ + +#define EX_CHARMAP 0x1000 /* NFS may need a character set conversion */ +#define EX_NOACLFAB 0x2000 /* If set, NFSv2 and v3 servers won't */ + /* fabricate an aclent_t ACL on file systems */ + /* that don't support aclent_t ACLs */ +#define EX_NOHIDE 0x4000 /* traversable from exported parent */ + +#ifdef _KERNEL + +#ifdef VOLATILE_FH_TEST +struct ex_vol_rename { + nfs_fh4_fmt_t vrn_fh_fmt; + struct ex_vol_rename *vrn_next; +}; +#endif /* VOLATILE_FH_TEST */ + +/* + * An auth cache client entry. This is the umbrella structure and contains all + * related auth_cache entries in the authc_tree AVL tree. + */ +struct auth_cache_clnt { + avl_node_t authc_link; + struct netbuf authc_addr; /* address of the client */ + krwlock_t authc_lock; /* protects authc_tree */ + avl_tree_t authc_tree; /* auth_cache entries */ +}; + +/* + * An auth cache entry can exist in 6 states. + * + * A NEW entry was recently allocated and added to the cache. It does not + * contain the valid auth state yet. + * + * A WAITING entry is one which is actively engaging the user land mountd code + * to authenticate or re-authenticate it. The auth state might not be valid + * yet. The other threads should wait on auth_cv until the retrieving thread + * finishes the retrieval and changes the auth cache entry to FRESH, or NEW (in + * a case this entry had no valid auth state yet). + * + * A REFRESHING entry is one which is actively engaging the user land mountd + * code to re-authenticate the cache entry. There is currently no other thread + * waiting for the results of the refresh. + * + * A FRESH entry is one which is valid (it is either newly retrieved or has + * been refreshed at least once). + * + * A STALE entry is one which has been detected to be too old. The transition + * from FRESH to STALE prevents multiple threads from submitting refresh + * requests. + * + * An INVALID entry is one which was either STALE or REFRESHING and was deleted + * out of the encapsulating exi. Since we can't delete it yet, we mark it as + * INVALID, which lets the refresh thread know not to work on it and free it + * instead. + * + * Note that the auth state of the entry is valid, even if the entry is STALE. + * Just as you can eat stale bread, you can consume a stale cache entry. The + * only time the contents change could be during the transition from REFRESHING + * or WAITING to FRESH. + * + * Valid state transitions: + * + * alloc + * | + * v + * +-----+ + * +--->| NEW |------>free + * | +-----+ + * | | + * | v + * | +---------+ + * +<-| WAITING | + * ^ +---------+ + * | | + * | v + * | +<--------------------------+<---------------+ + * | | ^ | + * | v | | + * | +-------+ +-------+ +------------+ +---------+ + * +---| FRESH |--->| STALE |--->| REFRESHING |--->| WAITING | + * +-------+ +-------+ +------------+ +---------+ + * | | | + * | v | + * v +---------+ | + * free<-----| INVALID |<--------+ + * +---------+ + */ +typedef enum auth_state { + NFS_AUTH_FRESH, + NFS_AUTH_STALE, + NFS_AUTH_REFRESHING, + NFS_AUTH_INVALID, + NFS_AUTH_NEW, + NFS_AUTH_WAITING +} auth_state_t; + +/* + * An authorization cache entry + * + * Either the state in auth_state will protect the + * contents or auth_lock must be held. + */ +struct auth_cache { + avl_node_t auth_link; + struct auth_cache_clnt *auth_clnt; + int auth_flavor; + cred_t *auth_clnt_cred; + uid_t auth_srv_uid; + gid_t auth_srv_gid; + uint_t auth_srv_ngids; + gid_t *auth_srv_gids; + int auth_access; + time_t auth_time; + time_t auth_freshness; + auth_state_t auth_state; + kmutex_t auth_lock; + kcondvar_t auth_cv; +}; + +#define AUTH_TABLESIZE 32 + +/* + * Structure containing log file meta-data. + */ +struct log_file { + unsigned int lf_flags; /* flags (see below) */ + int lf_writers; /* outstanding writers */ + int lf_refcnt; /* references to this struct */ + caddr_t lf_path; /* buffer file location */ + vnode_t *lf_vp; /* vnode for the buffer file */ + kmutex_t lf_lock; + kcondvar_t lf_cv_waiters; +}; + +/* + * log_file and log_buffer flags. + */ +#define L_WAITING 0x01 /* flush of in-core data to stable */ + /* storage in progress */ +#define L_PRINTED 0x02 /* error message printed to console */ +#define L_ERROR 0x04 /* error condition detected */ + +/* + * The logging buffer information. + * This structure may be shared by multiple exportinfo structures, + * if they share the same buffer file. + * This structure contains the basic information about the buffer, such + * as it's location in the filesystem. + * + * 'lb_lock' protects all the fields in this structure except for 'lb_path', + * and 'lb_next'. + * 'lb_path' is a write-once/read-many field which needs no locking, it is + * set before the structure is linked to any exportinfo structure. + * 'lb_next' is protected by the log_buffer_list_lock. + */ +struct log_buffer { + unsigned int lb_flags; /* L_ONLIST set? */ + int lb_refcnt; /* references to this struct */ + unsigned int lb_rec_id; /* used to generate unique id */ + caddr_t lb_path; /* buffer file pathname */ + struct log_file *lb_logfile; /* points to log_file structure */ + kmutex_t lb_lock; + struct log_buffer *lb_next; + kcondvar_t lb_cv_waiters; + caddr_t lb_records; /* linked list of records to write */ + int lb_num_recs; /* # of records to write */ + ssize_t lb_size_queued; /* number of bytes queued for write */ +}; + +#define LOG_BUFFER_HOLD(lbp) { \ + mutex_enter(&(lbp)->lb_lock); \ + (lbp)->lb_refcnt++; \ + mutex_exit(&(lbp)->lb_lock); \ +} + +#define LOG_BUFFER_RELE(lbp) { \ + log_buffer_rele(lbp); \ +} + +/* + * Structure for character set conversion mapping based on client address. + */ +struct charset_cache { + struct charset_cache *next; + kiconv_t inbound; + kiconv_t outbound; + struct sockaddr client_addr; +}; + +/* Forward declarations */ +struct exportinfo; +struct exp_visible; +struct svc_req; + +/* + * Treenodes are used to build tree representing every node which is part + * of nfs server pseudo namespace. They are connected with both exportinfo + * and exp_visible struct. They were introduced to avoid lookup of ".." + * in the underlying file system during unshare, which was failing if the + * file system was forcibly unmounted or if the directory was removed. + * One exp_visible_t can be shared via several treenode_t, i.e. + * different tree_vis can point to the same exp_visible_t. + * This will happen if some directory is on two different shared paths: + * E.g. after share /tmp/a/b1 and share /tmp/a/b2 there will be two treenodes + * corresponding to /tmp/a and both will have same value in tree_vis. + * + * + * + * NEW DATA STRUCT ORIGINAL DATA STRUCT + * + * ns_root +---+ +----------+ + * | / | |PSEUDO EXP|-->+---+ +---+ +---+ + * +---+--------- ----+----------+ | a |-->| k |-->| b | + * /\ +---+ +---+ +---+ + * / \ . . . + * +---+...\......... ..................... . . + * *| a | \ +----------+ . . + * +---+-----\------- ----|REAL EXP a| . . + * / \ +----------+ . . + * / +===+... ............................. . + * / *| k | +----------+ . + * / +===+--- ----|REAL EXP k| . + * / +----------+ . + * +===+................ ..................................... + * *| b | +----------+ + * +===+---------------- ----|REAL EXP b|-->+---+ + * \ +----------+ | d | + * +===+............. ...................+---+ + * | d | +----------+ + * +===+------------- ----|PSEUDO EXP|-->+---+ +---+ + * / +----------+ | e |-->| g | + * +---+................. ...................+---+ +---+ + * | e | . + * +---+ . + * \ . + * +---+.............. ............................ + * *| g | +----------+ + * +---+-------------- ----|REAL EXP g| + * +----------+ + * + * + * + * +===+ +---+ +---+ + * | b |..mountpoint | e |..directory/file *| a |..node is shared + * +===+ (VROOT) +---+ +---+ + * + * + * Bi-directional interconnect: + * treenode_t::tree_exi --------- exportinfo_t::exi_tree + * One-way direction connection: + * treenode_t::tree_vis .........> exp_visible_t + */ +/* Access to treenode_t is under protection of exported_lock RW_LOCK */ +typedef struct treenode { + /* support for generic n-ary trees */ + struct treenode *tree_parent; + struct treenode *tree_child_first; + struct treenode *tree_sibling; /* next sibling */ + /* private, nfs specific part */ + struct exportinfo *tree_exi; + struct exp_visible *tree_vis; +} treenode_t; + +/* + * Now that we have links to chase, we can get the zone rootvp just from + * an export. No current-zone-context needed. + */ +#define EXI_TO_ZONEROOTVP(exi) ((exi)->exi_ne->exi_root->exi_vp) + +/* + * TREE_ROOT checks if the node corresponds to a filesystem root or + * the zone's root directory. + * TREE_EXPORTED checks if the node is explicitly shared + */ + +#define TREE_ROOT(t) \ + ((t)->tree_exi != NULL && \ + (((t)->tree_exi->exi_vp->v_flag & VROOT) || \ + VN_CMP(EXI_TO_ZONEROOTVP((t)->tree_exi), (t)->tree_exi->exi_vp))) + +#define TREE_EXPORTED(t) \ + ((t)->tree_exi && !PSEUDO((t)->tree_exi)) + +#define EXPTABLESIZE 256 + +struct exp_hash { + struct exportinfo *prev; /* ptr to the previous exportinfo */ + struct exportinfo *next; /* ptr to the next exportinfo */ + struct exportinfo **bckt; /* backpointer to the hash bucket */ +}; + +/* + * A node associated with an export entry on the + * list of exported filesystems. + * + * exi_count+exi_lock protects an individual exportinfo from being freed + * when in use. + * + * You must have the writer lock on exported_lock to add/delete an exportinfo + * structure to/from the list. + * + * exi_volatile_dev maps to VSW_VOLATILEDEV. It means that the + * underlying fs devno can change on each mount. When set, the server + * should not use va_fsid for a GETATTR(FATTR4_FSID) reply. It must + * use exi_fsid because it is guaranteed to be persistent. This isn't + * in any way related to NFS4 volatile filehandles. + * + * The exi_cache_lock protects the exi_cache AVL trees. + */ +struct exportinfo { + struct exportdata exi_export; + fsid_t exi_fsid; + struct fid exi_fid; + struct exp_hash fid_hash; + struct exp_hash path_hash; + struct treenode *exi_tree; + fhandle_t exi_fh; + krwlock_t exi_cache_lock; + kmutex_t exi_lock; + uint_t exi_count; + zoneid_t exi_zoneid; + vnode_t *exi_vp; + vnode_t *exi_dvp; + avl_tree_t *exi_cache[AUTH_TABLESIZE]; + struct log_buffer *exi_logbuffer; + struct exp_visible *exi_visible; + struct charset_cache *exi_charset; + unsigned exi_volatile_dev:1; + unsigned exi_moved:1; + int exi_id; + avl_node_t exi_id_link; + /* + * Soft-reference/backpointer to zone's nfs_export_t. + * This allows us access to the zone's rootvp (stored in + * exi_ne->exi_root->exi_vp) even if the current thread isn't in + * same-zone context. + */ + struct nfs_export *exi_ne; +#ifdef VOLATILE_FH_TEST + uint32_t exi_volatile_id; + struct ex_vol_rename *exi_vol_rename; + kmutex_t exi_vol_rename_lock; +#endif /* VOLATILE_FH_TEST -- keep last! */ +}; + +typedef struct exportinfo exportinfo_t; +typedef struct exportdata exportdata_t; +typedef struct secinfo secinfo_t; + +/* + * exp_visible is a visible list per filesystem. It is for filesystems + * that may need a limited view of its contents. A pseudo export and + * a real export at the mount point (VROOT) which has a subtree shared + * has a visible list. + * + * The exi_visible field is NULL for normal, non-pseudo filesystems + * which do not have any subtree exported. If the field is non-null, + * it points to a list of visible entries, identified by vis_fid and/or + * vis_ino. The presence of a "visible" list means that if this export + * can only have a limited view, it can only view the entries in the + * exp_visible list. The directories in the fid list comprise paths that + * lead to exported directories. + * + * The vis_count field records the number of paths in this filesystem + * that use this directory. The vis_exported field is non-zero if the + * entry is an exported directory (leaf node). + * + * exp_visible itself is not reference counted. Each exp_visible is + * referenced twice: + * 1) from treenode::tree_vis + * 2) linked from exportinfo::exi_visible + * The 'owner' of exp_visible is the exportinfo structure. exp_visible should + * be always freed only from exportinfo_t, never from treenode::tree_vis. + */ + +struct exp_visible { + vnode_t *vis_vp; + fid_t vis_fid; + u_longlong_t vis_ino; + int vis_count; + int vis_exported; + struct exp_visible *vis_next; + struct secinfo *vis_secinfo; + int vis_seccnt; + timespec_t vis_change; +}; +typedef struct exp_visible exp_visible_t; + +#define PSEUDO(exi) ((exi)->exi_export.ex_flags & EX_PSEUDO) +#define EXP_LINKED(exi) ((exi)->fid_hash.bckt != NULL) + +#define EQFSID(fsidp1, fsidp2) \ + (((fsidp1)->val[0] == (fsidp2)->val[0]) && \ + ((fsidp1)->val[1] == (fsidp2)->val[1])) + +#define EQFID(fidp1, fidp2) \ + ((fidp1)->fid_len == (fidp2)->fid_len && \ + bcmp((char *)(fidp1)->fid_data, (char *)(fidp2)->fid_data, \ + (uint_t)(fidp1)->fid_len) == 0) + +#define exportmatch(exi, fsid, fid) \ + (EQFSID(&(exi)->exi_fsid, (fsid)) && EQFID(&(exi)->exi_fid, (fid))) + +/* + * Returns true iff exported filesystem is read-only to the given host. + * + * Note: this macro should be as fast as possible since it's called + * on each NFS modification request. + */ +#define rdonly(ro, vp) ((ro) || vn_is_readonly(vp)) +#define rdonly4(req, cs) \ + (vn_is_readonly((cs)->vp) || \ + (nfsauth4_access((cs)->exi, (cs)->vp, (req), (cs)->basecr, NULL, \ + NULL, NULL, NULL) & (NFSAUTH_RO | NFSAUTH_LIMITED))) + +extern int nfsauth4_access(struct exportinfo *, vnode_t *, + struct svc_req *, cred_t *, uid_t *, gid_t *, uint_t *, gid_t **); +extern int nfsauth4_secinfo_access(struct exportinfo *, + struct svc_req *, int, int, cred_t *); +extern int nfsauth_cache_clnt_compar(const void *, const void *); +extern int nfs_fhbcmp(char *, char *, int); +extern void nfs_exportinit(void); +extern void nfs_exportfini(void); +extern void nfs_export_zone_init(nfs_globals_t *); +extern void nfs_export_zone_fini(nfs_globals_t *); +extern void nfs_export_zone_shutdown(nfs_globals_t *); +extern int nfs_export_get_rootfh(nfs_globals_t *); +extern int chk_clnt_sec(struct exportinfo *, struct svc_req *); +extern int makefh(fhandle_t *, struct vnode *, struct exportinfo *); +extern int makefh_ol(fhandle_t *, struct exportinfo *, uint_t); +extern int makefh3(nfs_fh3 *, struct vnode *, struct exportinfo *); +extern int makefh3_ol(nfs_fh3 *, struct exportinfo *, uint_t); +extern vnode_t *nfs_fhtovp(fhandle_t *, struct exportinfo *); +extern vnode_t *nfs3_fhtovp(nfs_fh3 *, struct exportinfo *); +extern struct exportinfo *checkexport(fsid_t *, struct fid *); +extern struct exportinfo *checkexport4(fsid_t *, struct fid *, vnode_t *); +extern void exi_hold(struct exportinfo *); +extern void exi_rele(struct exportinfo *); +extern struct exportinfo *nfs_vptoexi(vnode_t *, vnode_t *, cred_t *, int *, + int *, bool_t); +extern int nfs_check_vpexi(vnode_t *, vnode_t *, cred_t *, + struct exportinfo **); +extern vnode_t *untraverse(vnode_t *, vnode_t *); +extern int vn_is_nfs_reparse(vnode_t *, cred_t *); +extern int client_is_downrev(struct svc_req *); +extern char *build_symlink(vnode_t *, cred_t *, size_t *); + +extern fhandle_t nullfh2; /* for comparing V2 filehandles */ + +typedef struct nfs_export { + /* Root of nfs pseudo namespace */ + treenode_t *ns_root; + + nfs_globals_t *ne_globals; /* "up" pointer */ + + struct exportinfo *exptable_path_hash[PKP_HASH_SIZE]; + struct exportinfo *exptable[EXPTABLESIZE]; + + /* + * Read/Write lock that protects the exportinfo list. This lock + * must be held when searching or modifiying the exportinfo list. + */ + krwlock_t exported_lock; + + /* "public" and default (root) location for public filehandle */ + struct exportinfo *exi_public; + struct exportinfo *exi_root; + /* For checking default public file handle */ + fid_t exi_rootfid; + /* For comparing V2 filehandles */ + fhandle_t nullfh2; + + /* The change attribute value of the root of nfs pseudo namespace */ + timespec_t ns_root_change; +} nfs_export_t; + +/* + * Functions that handle the NFSv4 server namespace + */ +extern exportinfo_t *vis2exi(treenode_t *); +extern int treeclimb_export(struct exportinfo *); +extern void treeclimb_unexport(nfs_export_t *, struct exportinfo *); +extern int nfs_visible(struct exportinfo *, vnode_t *, int *); +extern int nfs_visible_inode(struct exportinfo *, ino64_t, + struct exp_visible **); +extern int has_visible(struct exportinfo *, vnode_t *); +extern void free_visible(struct exp_visible *); +extern int nfs_exported(struct exportinfo *, vnode_t *); +extern struct exportinfo *pseudo_exportfs(nfs_export_t *, vnode_t *, fid_t *, + struct exp_visible *, struct exportdata *); +extern int vop_fid_pseudo(vnode_t *, fid_t *); +extern int nfs4_vget_pseudo(struct exportinfo *, vnode_t **, fid_t *); +extern bool_t nfs_visible_change(struct exportinfo *, vnode_t *, + timespec_t *); +extern void tree_update_change(nfs_export_t *, treenode_t *, timespec_t *); +extern void rfs4_clean_state_exi(nfs_export_t *, struct exportinfo *); + +/* + * Functions that handle the NFSv4 server namespace security flavors + * information. + */ +extern void srv_secinfo_exp2pseu(struct exportdata *, struct exportdata *); +extern void srv_secinfo_list_free(struct secinfo *, int); + +extern nfs_export_t *nfs_get_export(); +extern void export_link(nfs_export_t *, struct exportinfo *); +extern void export_unlink(nfs_export_t *, struct exportinfo *); + +/* + * exi_id support + */ +extern kmutex_t nfs_exi_id_lock; +extern avl_tree_t exi_id_tree; +extern int exi_id_get_next(void); + +/* + * Two macros for identifying public filehandles. + * A v2 public filehandle is 32 zero bytes. + * A v3 public filehandle is zero length. + */ +#define PUBLIC_FH2(fh) \ + ((fh)->fh_fsid.val[1] == 0 && \ + bcmp((fh), &nullfh2, sizeof (fhandle_t)) == 0) + +#define PUBLIC_FH3(fh) \ + ((fh)->fh3_length == 0) + +extern int makefh4(nfs_fh4 *, struct vnode *, struct exportinfo *); +extern vnode_t *nfs4_fhtovp(nfs_fh4 *, struct exportinfo *, nfsstat4 *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_EXPORT_H */ diff --git a/illumos-x86_64/usr/include/nfs/lm.h b/illumos-x86_64/usr/include/nfs/lm.h new file mode 100644 index 00000000..0328a968 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/lm.h @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _NFS_LM_H +#define _NFS_LM_H + +/* + * Interface definitions for the NFSv2/v3 lock manager. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * Common interfaces. + */ + +struct exportinfo; + +/* + * The numeric sysid is used to identify a host and transport. + * + * The local locking code uses (pid, sysid) to uniquely identify a process. + * This means that the client-side code must doctor up the sysid before + * registering a lock, so that the local locking code doesn't confuse a + * remote process with a local process just because they have the same pid. + * We currently do this by ORing LM_SYSID_CLIENT into the sysid before + * registering a lock. + * + * If you change LM_SYSID and LM_SYSID_MAX, be sure to pick values so that + * LM_SYSID_MAX > LM_SYSID using signed arithmetic, and don't use zero. + * You may also need a different way to tag lock manager locks that are + * registered locally. + */ +#define LM_SYSID ((sysid_t)0x0001) +#define LM_SYSID_MAX ((sysid_t)0x3FFF) +#define LM_SYSID_CLIENT ((sysid_t)0x4000) +#define LM_NOSYSID ((sysid_t)-1) + +/* + * Struct used to represent a host. + */ +struct lm_sysid; +struct knetconfig; +struct netbuf; + +/* + * Given a knetconfig and network address, returns a reference to the + * associated lm_sysid. The 3rd argument is the hostname to assign to the + * lm_sysid. The 4th argument is an output parameter. It is set non-zero + * if the returned lm_sysid has a different protocol + * (knetconfig::knc_proto) than what was requested. + */ +extern struct lm_sysid *lm_get_sysid(struct knetconfig *, struct netbuf *, + char *, bool_t *); +extern void lm_rel_sysid(struct lm_sysid *); + +/* + * Return the integer sysid for the given lm_sysid. + */ +extern sysid_t lm_sysidt(struct lm_sysid *); + +extern void lm_free_config(struct knetconfig *); + +extern void lm_cprsuspend(void); +extern void lm_cprresume(void); + +/* + * Client-side interfaces. + */ + +extern int lm_frlock(struct vnode *vp, int cmd, + struct flock64 *flk, int flag, + u_offset_t offset, struct cred *cr, + netobj *fh, struct flk_callback *); +extern int lm_has_sleep(const struct vnode *); +extern void lm_register_lock_locally(vnode_t *, + struct lm_sysid *, struct flock64 *, int, + u_offset_t); +extern int lm_safelock(vnode_t *, const struct flock64 *, + cred_t *); +extern int lm_safemap(const vnode_t *); +extern int lm_shrlock(struct vnode *vp, int cmd, + struct shrlock *shr, int flag, netobj *fh); +extern int lm4_frlock(struct vnode *vp, int cmd, + struct flock64 *flk, int flag, + u_offset_t offset, struct cred *cr, + netobj *fh, struct flk_callback *); +extern int lm4_shrlock(struct vnode *vp, int cmd, + struct shrlock *shr, int flag, netobj *fh); + +/* + * Server-side interfaces. + */ + +extern void lm_unexport(struct exportinfo *); + +/* + * Clustering: functions to encode the nlmid of the node where this NLM + * server is running in the l_sysid of the flock struct or the s_sysid + * field of the shrlock struct (respectively). + */ +extern void lm_set_nlmid_flk(int *); +extern void lm_set_nlmid_shr(int32_t *); +/* Hook for deleting all mandatory NFSv4 file locks held by a remote client */ +extern void (*lm_remove_file_locks)(int); + +/* + * The following global variable is the node id of the node where this + * NLM server is running. + */ +extern int lm_global_nlmid; + +/* + * End of clustering hooks. + */ + +/* + * Return non-zero if the given local vnode is in use. + */ +extern int lm_vp_active(const struct vnode *); + +extern sysid_t lm_alloc_sysidt(void); +extern void lm_free_sysidt(sysid_t); + +#endif /* _KERNEL */ + +#ifdef __STDC__ +extern int lm_shutdown(void); +#else +extern int lm_shutdown(); +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_LM_H */ diff --git a/illumos-x86_64/usr/include/nfs/mapid.h b/illumos-x86_64/usr/include/nfs/mapid.h new file mode 100644 index 00000000..792542c2 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/mapid.h @@ -0,0 +1,222 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _MAPID_H +#define _MAPID_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DNAMEMAX (NS_MAXCDNAME + 1) + +typedef struct { + void *(*fcn)(void *); + int signal; +} cb_t; + +#ifdef __LIBMAPID_IMPL + +/* + * Error Messages + */ +#define EMSG_NETDB_INTERNAL "Internal Resolver Error: %s" + +#define EMSG_TRY_AGAIN "\"%s\" DNS nameserver(s) not responding" \ + "...\tRetrying" + +#define EMSG_NO_RECOVERY "Unrecoverable Resolver Error: %s" + +#define EMSG_HOST_NOT_FOUND "Authoritative nameserver unresponsive " \ + "to queries for domain \"%s\"" + +#define EMSG_NO_DATA "\"%s\" DNS TXT record not found: "\ + "Defaulting to \"%s\"" + +#define EMSG_DNS_THREAD_ERROR "Unable to create DNS query thread" + +#define EMSG_DNS_DISABLE "%s: Further DNS queries disabled !" + +#define EMSG_DNS_RR_INVAL "\"%s\" Invalid DNS TXT record: "\ + "Defaulting to \"%s\"" + +/* + * DNS related info + */ +#define NFSMAPID_DNS_RR "_nfsv4idmapdomain" +#define NFSMAPID_DNS_TOUT_SECS (30LL) +#define NFSMAPID_SLOG_RATE 20 /* ~10 mins */ + +#define NS_ERRS 6 /* netdb.h */ + +typedef union { + HEADER hdr; + uchar_t buf[PACKETSZ]; +} ans_t; + +/* + * NOTE: All s_ prefixed variables are only to be used by the DNS + * feature implementation (mapid.c). The exported globals + * (ie. seen by nfsmapid.c/nfsmapid_server.c) are the + * dns_ prefixed variables along with sysdns_domain. + */ +static ans_t s_ans; +static int s_anslen; +static char s_dname[DNAMEMAX] = {0}; +static char s_txt_rr[DNAMEMAX] = {0}; + +static rwlock_t s_dns_data_lock = DEFAULTRWLOCK; +static rwlock_t s_dns_impl_lock = DEFAULTRWLOCK; +static mutex_t s_res_lock = ERRORCHECKMUTEX; +static uint32_t s_dns_tout = 0; +static thread_t s_dns_qthread; +static bool_t s_dns_qthr_created = FALSE; +static bool_t s_dns_disabled = FALSE; +static struct __res_state s_res = {0}; +static thread_key_t s_thr_key; +int lib_init_done = 0; + +static int resolv_init(void); +static void resolv_decode(void); +static int resolv_error(void); +static void resolv_get_txt_data(void); +static void resolv_txt_reset(void); +static void resolve_process_txt(uchar_t *, int); +static int resolv_search(void); +static void resolv_destroy(void); +static uchar_t *resolv_skip_rr(uchar_t *, uchar_t *); +static void domain_sync(cb_t *, char *); +static int get_mtime(const char *, timestruc_t *); +static void get_nfs_domain(void); +static void get_dns_domain(void); +static void get_dns_txt_domain(cb_t *); +void _lib_init(void); + +#ifdef DEBUG +bool_t nfsmapid_debug = FALSE; +#endif /* DEBUG */ + +/* + * mapid_domain_lock: rwlock used to serialize access/changes + * to the library's mapid_domain global var. + * + * mapid_domain: Library variable used to store the current + * domain configured for use in decoding/encoding + * outbound and inbound attr strings, accordingly. + * + * nfs_domain: If nfsmapid_domain var in SMF + * has been set, nfs_domain will hold this + * value for the duration of the instance; + * If the value ever changes, the change is + * detected via the use of nfs_mtime and + * nfs_domain is updated accordingly. + * + * dns_domain: If the system's resolver (/etc/resolv.conf) + * has been configured, dns_domain will hold + * the configured DNS domain as reported by the + * res_ninit() resolver interface. If the system's + * /etc/resolv.conf file is updated, the change + * is detected via the use of dns_mtime and + * dns_domain is updated accordingly. + */ +rwlock_t mapid_domain_lock = DEFAULTRWLOCK; +uint32_t mapid_domain_len = 0; +char mapid_domain[DNAMEMAX] = {0}; + +timestruc_t nfs_mtime = {0}; +uint32_t nfs_domain_len = 0; +char nfs_domain[DNAMEMAX] = {0}; + +timestruc_t dns_mtime = {0}; +uint32_t dns_domain_len = 0; +char dns_domain[DNAMEMAX] = {0}; + +int dns_txt_cached = 0; +uint32_t dns_txt_domain_len = 0; +char dns_txt_domain[DNAMEMAX] = {0}; +char sysdns_domain[DNAMEMAX] = {0}; + +timestruc_t zapped_mtime = {0}; + +#define ZAP_DOMAIN(which) \ + { \ + bzero(which##_domain, DNAMEMAX);\ + which##_domain_len = 0; \ + which##_mtime = zapped_mtime; \ + } + +#define TIMESTRUC_EQ(a, b) \ + (((a).tv_sec == (b).tv_sec) && \ + ((a).tv_nsec == (b).tv_nsec)) + + + +#endif /* __LIBMAPID_IMPL */ + +/* + * PSARC 2005/487 Consolidation Private Interfaces + * mapid_reeval_domain(), mapid_get_domain() + * Changes must be reviewed by Solaris File Sharing + */ +extern void mapid_reeval_domain(cb_t *); +extern char *mapid_get_domain(void); + +/* + * PSARC 2005/487 Contracted Sun Private Interface + * mapid_derive_domain(), mapid_stdchk_domain() + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2005-487-01@sun.com + */ +extern int mapid_stdchk_domain(const char *); +extern char *mapid_derive_domain(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _MAPID_H */ diff --git a/illumos-x86_64/usr/include/nfs/mount.h b/illumos-x86_64/usr/include/nfs/mount.h new file mode 100644 index 00000000..c2785ce7 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/mount.h @@ -0,0 +1,166 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + */ + +#ifndef _NFS_MOUNT_H +#define _NFS_MOUNT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include /* static pathconf kludge */ + + +#define NFS_ARGS_EXTA 1 +#define NFS_ARGS_EXTB 2 + +/* + * extension data for nfs_args_ext == NFS_ARGS_EXTA. + */ +struct nfs_args_extA { + struct sec_data *secdata; /* security data */ +}; + +/* + * extension data for nfs_args_ext == NFS_ARGS_EXTB. + */ +struct nfs_args_extB { + struct sec_data *secdata; /* security data */ + struct nfs_args *next; /* link for failover */ +}; + +/* + * Union structure for future extension. + */ +union nfs_ext { + struct nfs_args_extA nfs_extA; /* nfs_args extension v1 */ + struct nfs_args_extB nfs_extB; /* nfs_args extension v2 */ +}; + +struct nfs_args { + struct netbuf *addr; /* file server address */ + struct netbuf *syncaddr; /* secure NFS time sync addr */ + struct knetconfig *knconf; /* transport netconfig struct */ + char *hostname; /* server's hostname */ + char *netname; /* server's netname */ + caddr_t fh; /* File handle to be mounted */ + int flags; /* flags */ + int wsize; /* write size in bytes */ + int rsize; /* read size in bytes */ + int timeo; /* initial timeout in .1 secs */ + int retrans; /* times to retry send */ + int acregmin; /* attr cache file min secs */ + int acregmax; /* attr cache file max secs */ + int acdirmin; /* attr cache dir min secs */ + int acdirmax; /* attr cache dir max secs */ + struct pathcnf *pathconf; /* static pathconf kludge */ + int nfs_args_ext; /* the nfs_args extension id */ + union nfs_ext nfs_ext_u; /* extension union structure */ +}; + +#ifdef _SYSCALL32 +struct nfs_args_extA32 { + caddr32_t secdata; /* security data */ +}; + +struct nfs_args_extB32 { + caddr32_t secdata; /* security data */ + caddr32_t next; /* link for failover */ +}; + +union nfs_ext32 { + struct nfs_args_extA32 nfs_extA; /* nfs_args extension v1 */ + struct nfs_args_extB32 nfs_extB; /* nfs_args extension v2 */ +}; + +struct nfs_args32 { + caddr32_t addr; /* file server address */ + caddr32_t syncaddr; /* secure NFS time sync addr */ + caddr32_t knconf; /* transport netconfig struct */ + caddr32_t hostname; /* server's hostname */ + caddr32_t netname; /* server's netname */ + caddr32_t fh; /* File handle to be mounted */ + int32_t flags; /* flags */ + int32_t wsize; /* write size in bytes */ + int32_t rsize; /* read size in bytes */ + int32_t timeo; /* initial timeout in .1 secs */ + int32_t retrans; /* times to retry send */ + int32_t acregmin; /* attr cache file min secs */ + int32_t acregmax; /* attr cache file max secs */ + int32_t acdirmin; /* attr cache dir min secs */ + int32_t acdirmax; /* attr cache dir max secs */ + caddr32_t pathconf; /* static pathconf kludge */ + int32_t nfs_args_ext; /* the nfs_args extension id */ + union nfs_ext32 nfs_ext_u; /* extension union structure */ +}; +#endif /* _SYSCALL32 */ + +/* + * NFS mount option flags + */ +#define NFSMNT_SOFT 0x001 /* soft mount (hard is default) */ +#define NFSMNT_WSIZE 0x002 /* set write size */ +#define NFSMNT_RSIZE 0x004 /* set read size */ +#define NFSMNT_TIMEO 0x008 /* set initial timeout */ +#define NFSMNT_RETRANS 0x010 /* set number of request retrys */ +#define NFSMNT_HOSTNAME 0x020 /* set hostname for error printf */ +#define NFSMNT_INT 0x040 /* allow interrupts on hard mount */ +#define NFSMNT_NOAC 0x080 /* don't cache attributes */ +#define NFSMNT_ACREGMIN 0x0100 /* set min secs for file attr cache */ +#define NFSMNT_ACREGMAX 0x0200 /* set max secs for file attr cache */ +#define NFSMNT_ACDIRMIN 0x0400 /* set min secs for dir attr cache */ +#define NFSMNT_ACDIRMAX 0x0800 /* set max secs for dir attr cache */ +#define NFSMNT_SECURE 0x1000 /* secure mount */ +#define NFSMNT_NOCTO 0x2000 /* no close-to-open consistency */ +#define NFSMNT_KNCONF 0x4000 /* transport's knetconfig structure */ +#define NFSMNT_GRPID 0x8000 /* System V-style gid inheritance */ +#define NFSMNT_RPCTIMESYNC 0x10000 /* use RPC to do secure NFS time sync */ +#define NFSMNT_KERBEROS 0x20000 /* use kerberos credentials */ +#define NFSMNT_POSIX 0x40000 /* static pathconf kludge info */ +#define NFSMNT_LLOCK 0x80000 /* Local locking (no lock manager) */ +#define NFSMNT_LOOPBACK 0x100000 /* Is a loopback mount */ +#define NFSMNT_SEMISOFT 0x200000 /* read soft, modify hard */ +#define NFSMNT_NOPRINT 0x400000 /* don't print messages */ +#define NFSMNT_NEWARGS 0x800000 /* using nfs_args extented structure */ +#define NFSMNT_DIRECTIO 0x1000000 /* do direct I/O */ +#define NFSMNT_PUBLIC 0x2000000 /* mount was done with url/public */ +#define NFSMNT_SECDEFAULT 0x4000000 /* mount using default sec flavor */ +#define NFSMNT_TRYRDMA 0x8000000 /* Try RDMA mount,no proto advised */ +#define NFSMNT_DORDMA 0x10000000 /* Do an RDMA mount, regardless */ +#define NFSMNT_MIRRORMOUNT 0x20000000 /* Is a mirrormount */ +#define NFSMNT_REFERRAL 0x40000000 /* Is a referral */ + +#define NFSMNT_EPHEMERAL (NFSMNT_MIRRORMOUNT | NFSMNT_REFERRAL) + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_MOUNT_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs.h b/illumos-x86_64/usr/include/nfs/nfs.h new file mode 100644 index 00000000..96d7aa70 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs.h @@ -0,0 +1,2428 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2019 Nexenta by DDN, Inc. All rights reserved. + */ + +#ifndef _NFS_NFS_H +#define _NFS_NFS_H + +#include +#include +#include +#include +#include +#ifdef _KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * remote file service numbers + */ +#define NFS_PROGRAM ((rpcprog_t)100003) +#define NFS_VERSMIN ((rpcvers_t)2) +#define NFS_VERSMAX ((rpcvers_t)4) +#define NFS_VERSION ((rpcvers_t)2) +#define NFS_PORT 2049 + +/* Protocol versions with internal representation */ +typedef enum nfs_prot_vers { + NFS_VERS_2 = 0x200, /* 2 */ + NFS_VERS_3 = 0x300, /* 3 */ + NFS_VERS_4 = 0x400, /* 4 */ + NFS_VERS_4_1 = 0x401, /* 4.1 */ + NFS_VERS_4_2 = 0x402, /* 4.2 */ +} nfs_prot_vers_t; + +#define NFS_PROT_VERSION(x) ((x) >> 8) +#define NFS_PROT_V4_MINORVERSION(x) ((x) & 0xFF) + +#define NFS_SRV_VERS_MIN NFS_VERS_2 +#define NFS_SRV_VERS_MAX NFS_VERS_4_2 + +/* + * Used to determine registration and service handling of versions + */ +#define NFS_VERSMIN_DEFAULT ((rpcvers_t)2) +#define NFS_VERSMAX_DEFAULT ((rpcvers_t)4) +#define NFS_SRV_VERSMIN_DEFAULT (NFS_VERS_2) +#define NFS_SRV_VERSMAX_DEFAULT (NFS_VERS_4) + +/* + * Used to track the state of the server so that initialization + * can be done properly. + */ +typedef enum { + NFS_SERVER_STOPPED, /* server state destroyed */ + NFS_SERVER_STOPPING, /* server state being destroyed */ + NFS_SERVER_RUNNING, + NFS_SERVER_QUIESCED, /* server state preserved */ + NFS_SERVER_OFFLINE /* server pool offline */ +} nfs_server_running_t; + +/* Forward declarations for nfs_globals */ +struct nfs_export; +struct nfs_srv; +struct nfs3_srv; +struct nfs4_srv; +struct nfsauth_globals; + +/* + * Zone globals variables of NFS server + */ +typedef struct nfs_globals { + list_node_t nfs_g_link; /* all globals list */ + + nfs_prot_vers_t nfs_versmin; /* NFS_VERS_... */ + nfs_prot_vers_t nfs_versmax; /* NFS_VERS_... */ + + /* NFS server locks and state */ + nfs_server_running_t nfs_server_upordown; + kmutex_t nfs_server_upordown_lock; + kcondvar_t nfs_server_upordown_cv; + + /* RDMA wait variables */ + kcondvar_t rdma_wait_cv; + kmutex_t rdma_wait_mutex; + + zoneid_t nfs_zoneid; + /* Per-zone data structures private to each module */ + struct nfs_export *nfs_export; /* nfs_export.c */ + struct nfs_srv *nfs_srv; /* nfs_srv.c */ + struct nfs3_srv *nfs3_srv; /* nfs3_srv.c */ + struct nfs4_srv *nfs4_srv; /* nfs4_srv.c */ + struct nfsauth_globals *nfs_auth; /* nfs_auth.c */ + + /* statistic: nfs_stat.c, etc. */ + kstat_named_t *svstat[NFS_VERSMAX + 1]; + kstat_named_t *rfsproccnt[NFS_VERSMAX + 1]; + kstat_named_t *aclproccnt[NFS_VERSMAX + 1]; +} nfs_globals_t; + +/* + * Default delegation setting for the server ==> "on" + */ +#define NFS_SERVER_DELEGATION_DEFAULT (TRUE) + +/* Maximum size of data portion of a remote request */ +#define NFS_MAXDATA 8192 +#define NFS_MAXNAMLEN 255 +#define NFS_MAXPATHLEN 1024 + +/* + * Rpc retransmission parameters + */ +#define NFS_TIMEO 11 /* initial timeout for clts in 10th of a sec */ +#define NFS_RETRIES 5 /* times to retry request */ +#define NFS_COTS_TIMEO 600 /* initial timeout for cots in 10th of a sec */ + +/* + * The value of UID_NOBODY/GID_NOBODY presented to the world via NFS. + * UID_NOBODY/GID_NOBODY is translated to NFS_UID_NOBODY/NFS_GID_NOBODY + * when being sent out over the network and NFS_UID_NOBODY/NFS_GID_NOBODY + * is translated to UID_NOBODY/GID_NOBODY when received. + */ +#define NFS_UID_NOBODY -2 +#define NFS_GID_NOBODY -2 + +/* + * maximum transfer size for different interfaces + */ +#define ECTSIZE 2048 +#define IETSIZE 8192 + +/* + * WebNFS error status + */ +enum wnfsstat { + WNFSERR_CLNT_FLAVOR = 20001 /* invalid client sec flavor */ +}; + +/* + * Error status + * Should include all possible net errors. + * For now we just cast errno into an enum nfsstat. + */ +enum nfsstat { + NFS_OK = 0, /* no error */ + NFSERR_PERM = 1, /* Not owner */ + NFSERR_NOENT = 2, /* No such file or directory */ + NFSERR_IO = 5, /* I/O error */ + NFSERR_NXIO = 6, /* No such device or address */ + NFSERR_ACCES = 13, /* Permission denied */ + NFSERR_EXIST = 17, /* File exists */ + NFSERR_XDEV = 18, /* Cross-device link */ + NFSERR_NODEV = 19, /* No such device */ + NFSERR_NOTDIR = 20, /* Not a directory */ + NFSERR_ISDIR = 21, /* Is a directory */ + NFSERR_INVAL = 22, /* Invalid argument */ + NFSERR_FBIG = 27, /* File too large */ + NFSERR_NOSPC = 28, /* No space left on device */ + NFSERR_ROFS = 30, /* Read-only file system */ + NFSERR_OPNOTSUPP = 45, /* Operation not supported */ + NFSERR_NAMETOOLONG = 63, /* File name too long */ + NFSERR_NOTEMPTY = 66, /* Directory not empty */ + NFSERR_DQUOT = 69, /* Disc quota exceeded */ + NFSERR_STALE = 70, /* Stale NFS file handle */ + NFSERR_REMOTE = 71, /* Object is remote */ + NFSERR_WFLUSH = 99 /* write cache flushed */ +}; + +typedef enum nfsstat nfsstat; + +/* + * File types + */ +enum nfsftype { + NFNON, + NFREG, /* regular file */ + NFDIR, /* directory */ + NFBLK, /* block special */ + NFCHR, /* character special */ + NFLNK, /* symbolic link */ + NFSOC /* socket */ +}; + +/* + * Macros for converting device numbers to and from the format + * SunOS 4.x used. SVR4 uses 14 bit majors and 18 bits minors, + * SunOS 4.x used 8 bit majors and 8 bit minors. It isn't sufficient + * to use the cmpdev() and expdev() macros because they only compress + * 7 bit (and smaller) majors. We must compress 8 bit majors too. + * If the major or minor exceeds 8 bits, then we send it out in + * full 32 bit format and hope that the peer can deal with it. + */ + +#define SO4_BITSMAJOR 8 /* # of SunOS 4.x major device bits */ +#define SO4_BITSMINOR 8 /* # of SunOS 4.x minor device bits */ +#define SO4_MAXMAJ 0xff /* SunOS 4.x max major value */ +#define SO4_MAXMIN 0xff /* SunOS 4.x max minor value */ + +/* + * Convert to over-the-wire device number format + */ +#define nfsv2_cmpdev(x) \ + ((uint32_t) \ + ((getmajor(x) > SO4_MAXMAJ || getminor(x) > SO4_MAXMIN) ? NODEV : \ + ((getmajor(x) << SO4_BITSMINOR) | (getminor(x) & SO4_MAXMIN)))) + +/* + * Convert from over-the-wire format to SVR4 device number format + */ +#define nfsv2_expdev(x) \ + makedevice((((x) >> SO4_BITSMINOR) & SO4_MAXMAJ), (x) & SO4_MAXMIN) + +/* + * Special kludge for fifos (named pipes) [to adhere to NFS Protocol Spec] + * + * VFIFO is not in the protocol spec (VNON will be replaced by VFIFO) + * so the over-the-wire representation is VCHR with a '-1' device number. + * + * NOTE: This kludge becomes unnecessary with the Protocol Revision, + * but it may be necessary to support it (backwards compatibility). + */ +#define NFS_FIFO_TYPE NFCHR +#define NFS_FIFO_MODE S_IFCHR +#define NFS_FIFO_DEV ((uint32_t)-1) + +/* identify fifo in nfs attributes */ +#define NA_ISFIFO(NA) (((NA)->na_type == NFS_FIFO_TYPE) && \ + ((NA)->na_rdev == NFS_FIFO_DEV)) + +/* set fifo in nfs attributes */ +#define NA_SETFIFO(NA) { \ + (NA)->na_type = NFS_FIFO_TYPE; \ + (NA)->na_rdev = NFS_FIFO_DEV; \ + (NA)->na_mode = ((NA)->na_mode & ~S_IFMT) | NFS_FIFO_MODE; \ + } + +/* + * Check for time overflow using a kernel tunable to determine whether + * we should accept or reject an unsigned 32-bit time value. Time value in NFS + * v2/3 protocol is unsigned 32 bit, but ILP32 kernel only allows 31 bits. + * In nfsv4, time value is a signed 64 bit, so needs to be checked for + * overflow as well (e.g. for setattr). So define the tunable as follows: + * nfs_allow_preepoch_time is TRUE if pre-epoch (negative) times are allowed + * and is FALSE (the default) otherwise. For nfsv2/3 this means that + * if negative times are allowed, the uint32_t time value is interpreted + * as a signed int, otherwise as a large positive number. For nfsv4, + * we use the value as is - except that if negative times are not allowed, + * we will not accept a negative value otw. + * + * So for nfsv2/3 (uint32_t): + * + * If nfs_allow_preepoch_time is + * FALSE, the maximum time value is INT32_MAX for 32-bit kernels and + * UINT32_MAX for 64-bit kernels (to allow times larger than 2038) + * and the minimum is zero. Note that in that case, a 32-bit application + * running on a 64-bit kernel will not be able to access files with + * the larger time values. + * If nfs_allow_preepoch_time is TRUE, the maximum time value is INT32_MAX + * for both kernel configurations and the minimum is INT32_MIN. + * + * And for nfsv4 (int64_t): + * + * nfsv4 allows for negative values in the protocol, and has a 64-bit + * time field, so nfs_allow_preepoch_time can be ignored. + */ +#ifdef _KERNEL + +extern bool_t nfs_allow_preepoch_time; + +#ifdef _LP64 + +/* + * If no negative otw values are allowed, may use the full 32-bits of the + * time to represent time later than 2038, by presenting the value as an + * unsigned (but this can only be used by 64-bit apps due to cstat32 + * restrictions). If negative values are allowed, cannot represent times + * after 2038. Either way, all 32 bits have a valid representation. + */ + +/* Check if nfstime4 seconds (int64_t) can be stored in the system time */ +#define NFS4_TIME_OK(tt) TRUE + + +#define NFS3_TIME_OVERFLOW(tt) (FALSE) +#define NFS2_TIME_OVERFLOW(tt) (FALSE) + +/* + * check if a time_t (int64_t) is ok when preepoch times are allowed - + * nfsv2/3: every 32-bit value is accepted, but can't overflow 64->32. + * nfsv4: every value is valid. + */ +#define NFS_PREEPOCH_TIME_T_OK(tt) \ + (((tt) >= (time_t)INT32_MIN) && ((tt) <= (time_t)INT32_MAX)) + +/* + * check if a time_t (int64_t) is ok when preepoch times are not allowed - + * nfsv2/3: every positive 32-bit value is accepted, but can't overflow 64->32. + * nfsv4: every value is valid. + */ +#define NFS_NO_PREEPOCH_TIME_T_OK(tt) \ + (((tt) >= 0) && ((tt) <= (time_t)(ulong_t)UINT32_MAX)) + +#else /* not _LP64 */ + +/* + * Cannot represent times after 2038 in a 32-bit kernel, but we may wish to + * restrict the use of negative values (which violate the protocol). + * So if negative times allowed, all uint32 time values are valid. Otherwise + * only those which are less than INT32_MAX (msb=0). + * + * NFSv4 uses int64_t for the time, so in a 32-bit kernel the nfsv4 value + * must fit in an int32_t. + */ + +/* Only allow signed 32-bit time values */ + +/* Check if an nfstime4 (int64_t) can be stored in the system time */ +#define NFS4_TIME_OK(tt) \ + (((tt) <= INT32_MAX) && ((tt) >= INT32_MIN)) + +#define NFS3_TIME_OVERFLOW(tt) ((tt) > INT32_MAX) +#define NFS2_TIME_OVERFLOW(tt) ((tt) > INT32_MAX) + +/* + * check if a time_t (int32_t) is ok when preepoch times are allowed - + * every 32-bit value is accepted + */ +#define NFS_PREEPOCH_TIME_T_OK(tt) TRUE + +/* + * check if a time_t (int32_t) is ok when preepoch times are not allowed - + * only positive values are accepted. + */ +#define NFS_NO_PREEPOCH_TIME_T_OK(tt) ((tt) >= 0) + +#endif /* _LP64 */ + +/* Check if an nfstime3 (uint32_t) can be stored in the system time */ +#define NFS3_TIME_OK(tt) \ + (nfs_allow_preepoch_time || (!NFS3_TIME_OVERFLOW(tt))) + +/* Check if an nfs2_timeval (uint32_t) can be stored in the system time. */ +#define NFS2_TIME_OK(tt) \ + (nfs_allow_preepoch_time || (!NFS2_TIME_OVERFLOW(tt))) + +/* + * Test if time_t (signed long) can be sent over the wire - for v2/3 only if: + * 1. The time value can fit in a uint32_t; and + * 2. Either the time value is positive or allow preepoch times. + * No restrictions for nfsv4. + */ +#define NFS_TIME_T_OK(tt) \ + (nfs_allow_preepoch_time ? \ + NFS_PREEPOCH_TIME_T_OK(tt) : NFS_NO_PREEPOCH_TIME_T_OK(tt)) + +#define NFS4_TIME_T_OK(tt) TRUE + +/* Test if all attr times are valid */ +#define NFS_VAP_TIME_OK(vap) \ + (nfs_allow_preepoch_time ? \ + (NFS_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) && \ + NFS_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) && \ + NFS_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec)) : \ + (NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) && \ + NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) && \ + NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec))) + +#define NFS4_VAP_TIME_OK(vap) TRUE + +/* + * To extend the sign or not extend the sign, that is the question. + * Note: The correct way is to code a macro: + * #define NFS_TIME_T_CONVERT(tt) \ + * (nfs_allow_preepoch_time ? (int32_t)(tt) : (uint32_t)(tt)) + * But the 64-bit compiler does not extend the sign in that case (why?) + * so we'll do it the ugly way... + */ +#define NFS_TIME_T_CONVERT(systt, tt) \ + if (nfs_allow_preepoch_time) { \ + systt = (int32_t)(tt); \ + } else { \ + systt = (uint32_t)(tt); \ + } + +/* macro to check for overflowed time attribute fields - version 3 */ +#define NFS3_FATTR_TIME_OK(attrs) \ + (NFS3_TIME_OK((attrs)->atime.seconds) && \ + NFS3_TIME_OK((attrs)->mtime.seconds) && \ + NFS3_TIME_OK((attrs)->ctime.seconds)) + +/* macro to check for overflowed time attribute fields - version 2 */ +#define NFS2_FATTR_TIME_OK(attrs) \ + (NFS2_TIME_OK((attrs)->na_atime.tv_sec) && \ + NFS2_TIME_OK((attrs)->na_mtime.tv_sec) && \ + NFS2_TIME_OK((attrs)->na_ctime.tv_sec)) + +/* Check that a size3 value is not overflowed */ +#define NFS3_SIZE_OK(size) ((size) <= MAXOFFSET_T) + +#endif /* _KERNEL */ + +/* + * Size of an fhandle in bytes + */ +#define NFS_FHSIZE 32 + +struct nfs_fid { + ushort_t nf_len; + ushort_t nf_pad; + char nf_data[NFS_FHSIZE]; +}; + +/* + * "Legacy" filehandles use NFS_FHMAXDATA (10) byte fids. Filesystems that + * return a larger fid than NFS_FHMAXDATA, such as ZFS's .zfs snapshot + * directory, can use up to (((64 - 8) / 2) - 2) bytes for their fid. + * This currently holds for both NFSv3 and NFSv4. + */ +#define NFS_FHMAXDATA 10 +#define NFS_FH3MAXDATA 26 +#define NFS_FH4MAXDATA 26 + +/* + * The original nfs file handle size for version 3 was 32 which was + * the same in version 2; now we're making it bigger to to deal with + * ZFS snapshot FIDs. + * + * If the size of fhandle3_t changes or if Version 3 uses some other + * filehandle format, this constant may need to change. + */ + +#define NFS3_OLDFHSIZE 32 +#define NFS3_MAXFHSIZE 64 + +/* + * This is the actual definition of a legacy filehandle. There is some + * dependence on this layout in NFS-related code, particularly in the + * user-level lock manager, so be careful about changing it. + * + * Currently only NFSv2 uses this structure. + */ + +typedef struct svcfh { + fsid_t fh_fsid; /* filesystem id */ + ushort_t fh_len; /* file number length */ + char fh_data[NFS_FHMAXDATA]; /* and data */ + ushort_t fh_xlen; /* export file number length */ + char fh_xdata[NFS_FHMAXDATA]; /* and data */ +} fhandle_t; + +/* + * This is the in-memory structure for an NFSv3 extended filehandle. + */ +typedef struct { + fsid_t _fh3_fsid; /* filesystem id */ + ushort_t _fh3_len; /* file number length */ + char _fh3_data[NFS_FH3MAXDATA]; /* and data */ + ushort_t _fh3_xlen; /* export file number length */ + char _fh3_xdata[NFS_FH3MAXDATA]; /* and data */ +} fhandle3_t; + +/* + * This is the in-memory structure for an NFSv4 extended filehandle. + */ +typedef struct { + fsid_t fhx_fsid; /* filesystem id */ + ushort_t fhx_len; /* file number length */ + char fhx_data[NFS_FH4MAXDATA]; /* and data */ + ushort_t fhx_xlen; /* export file number length */ + char fhx_xdata[NFS_FH4MAXDATA]; /* and data */ +} fhandle4_t; + +/* + * Arguments to remote write and writecache + */ +/* + * The `over the wire' representation of the first four arguments. + */ +struct otw_nfswriteargs { + fhandle_t otw_wa_fhandle; + uint32_t otw_wa_begoff; + uint32_t otw_wa_offset; + uint32_t otw_wa_totcount; +}; + +struct nfswriteargs { + struct otw_nfswriteargs *wa_args; /* ptr to the otw arguments */ + struct otw_nfswriteargs wa_args_buf; /* space for otw arguments */ + uint32_t wa_count; + char *wa_data; /* data to write (up to NFS_MAXDATA) */ + mblk_t *wa_mblk; /* pointer to mblks containing data */ +#ifdef _KERNEL + /* rdma related info */ + struct clist *wa_rlist; + CONN *wa_conn; +#endif /* _KERNEL */ +}; +#define wa_fhandle wa_args->otw_wa_fhandle +#define wa_begoff wa_args->otw_wa_begoff +#define wa_offset wa_args->otw_wa_offset +#define wa_totcount wa_args->otw_wa_totcount + +/* + * NFS timeval struct using unsigned int as specified in V2 protocol. + * tv_sec and tv_usec used to match existing code. + */ +struct nfs2_timeval { + uint32_t tv_sec; + uint32_t tv_usec; +}; +typedef struct nfs2_timeval nfs2_timeval; + +/* + * File attributes + */ +struct nfsfattr { + enum nfsftype na_type; /* file type */ + uint32_t na_mode; /* protection mode bits */ + uint32_t na_nlink; /* # hard links */ + uint32_t na_uid; /* owner user id */ + uint32_t na_gid; /* owner group id */ + uint32_t na_size; /* file size in bytes */ + uint32_t na_blocksize; /* preferred block size */ + uint32_t na_rdev; /* special device # */ + uint32_t na_blocks; /* Kb of disk used by file */ + uint32_t na_fsid; /* device # */ + uint32_t na_nodeid; /* inode # */ + struct nfs2_timeval na_atime; /* time of last access */ + struct nfs2_timeval na_mtime; /* time of last modification */ + struct nfs2_timeval na_ctime; /* time of last change */ +}; + +#define n2v_type(x) (NA_ISFIFO(x) ? VFIFO : nf_to_vt[(x)->na_type]) +#define n2v_rdev(x) (NA_ISFIFO(x) ? 0 : (x)->na_rdev) + +/* + * Arguments to remote read + */ +struct nfsreadargs { + fhandle_t ra_fhandle; /* handle for file */ + uint32_t ra_offset; /* byte offset in file */ + uint32_t ra_count; /* immediate read count */ + uint32_t ra_totcount; /* total read cnt (from this offset) */ +#ifdef _KERNEL + /* used in rdma transports */ + caddr_t ra_data; /* destination for read data */ + struct clist *ra_wlist; + CONN *ra_conn; +#endif +}; + +/* + * Status OK portion of remote read reply + */ +struct nfsrrok { + struct nfsfattr rrok_attr; /* attributes, need for pagin */ + uint32_t rrok_count; /* bytes of data */ + char *rrok_data; /* data (up to NFS_MAXDATA bytes) */ + uint_t rrok_bufsize; /* size of kmem_alloc'd buffer */ + mblk_t *rrok_mp; /* mblk_t contains data for reply */ +#ifdef _KERNEL + uint_t rrok_wlist_len; + struct clist *rrok_wlist; +#endif +}; + +/* + * Reply from remote read + */ +struct nfsrdresult { + nfsstat rr_status; /* status of read */ + union { + struct nfsrrok rr_ok_u; /* attributes, need for pagin */ + } rr_u; +}; +#define rr_ok rr_u.rr_ok_u +#define rr_attr rr_u.rr_ok_u.rrok_attr +#define rr_count rr_u.rr_ok_u.rrok_count +#define rr_bufsize rr_u.rr_ok_u.rrok_bufsize +#define rr_data rr_u.rr_ok_u.rrok_data +#define rr_mp rr_u.rr_ok_u.rrok_mp + +/* + * File attributes which can be set + */ +struct nfssattr { + uint32_t sa_mode; /* protection mode bits */ + uint32_t sa_uid; /* owner user id */ + uint32_t sa_gid; /* owner group id */ + uint32_t sa_size; /* file size in bytes */ + struct nfs2_timeval sa_atime; /* time of last access */ + struct nfs2_timeval sa_mtime; /* time of last modification */ +}; + + +/* + * Reply status with file attributes + */ +struct nfsattrstat { + nfsstat ns_status; /* reply status */ + union { + struct nfsfattr ns_attr_u; /* NFS_OK: file attributes */ + } ns_u; +}; +#define ns_attr ns_u.ns_attr_u + + +/* + * NFS_OK part of read sym link reply union + */ +struct nfssrok { + uint32_t srok_count; /* size of string */ + char *srok_data; /* string (up to NFS_MAXPATHLEN bytes) */ +}; + +/* + * Result of reading symbolic link + */ +struct nfsrdlnres { + nfsstat rl_status; /* status of symlink read */ + union { + struct nfssrok rl_srok_u; /* name of linked to */ + } rl_u; +}; +#define rl_srok rl_u.rl_srok_u +#define rl_count rl_u.rl_srok_u.srok_count +#define rl_data rl_u.rl_srok_u.srok_data + + +/* + * Arguments to readdir + */ +struct nfsrddirargs { + fhandle_t rda_fh; /* directory handle */ + uint32_t rda_offset; /* offset in directory (opaque) */ + uint32_t rda_count; /* number of directory bytes to read */ +}; + +/* + * NFS_OK part of readdir result + */ +struct nfsrdok { + uint32_t rdok_offset; /* next offset (opaque) */ + uint32_t rdok_size; /* size in bytes of entries */ + bool_t rdok_eof; /* true if last entry is in result */ + struct dirent64 *rdok_entries; /* variable number of entries */ +}; + +/* + * Readdir result + */ +struct nfsrddirres { + nfsstat rd_status; + uint_t rd_bufsize; /* client request size (not xdr'ed) */ + union { + struct nfsrdok rd_rdok_u; + } rd_u; +}; +#define rd_rdok rd_u.rd_rdok_u +#define rd_offset rd_u.rd_rdok_u.rdok_offset +#define rd_size rd_u.rd_rdok_u.rdok_size +#define rd_eof rd_u.rd_rdok_u.rdok_eof +#define rd_entries rd_u.rd_rdok_u.rdok_entries + + +/* + * Arguments for directory operations + */ +struct nfsdiropargs { + fhandle_t *da_fhandle; /* pointer to directory file handle */ + char *da_name; /* name (up to NFS_MAXNAMLEN bytes) */ + fhandle_t da_fhandle_buf; /* directory file handle */ + int da_flags; /* flags, see below */ +}; +#define DA_FREENAME 1 + +/* + * NFS_OK part of directory operation result + */ +struct nfsdrok { + fhandle_t drok_fhandle; /* result file handle */ + struct nfsfattr drok_attr; /* result file attributes */ +}; + +/* + * Results from directory operation + */ +struct nfsdiropres { + nfsstat dr_status; /* result status */ + union { + struct nfsdrok dr_drok_u; /* NFS_OK result */ + } dr_u; +}; +#define dr_drok dr_u.dr_drok_u +#define dr_fhandle dr_u.dr_drok_u.drok_fhandle +#define dr_attr dr_u.dr_drok_u.drok_attr + +/* + * arguments to setattr + */ +struct nfssaargs { + fhandle_t saa_fh; /* fhandle of file to be set */ + struct nfssattr saa_sa; /* new attributes */ +}; + +/* + * arguments to create and mkdir + */ +struct nfscreatargs { + struct nfsdiropargs ca_da; /* file name to create and parent dir */ + struct nfssattr *ca_sa; /* initial attributes */ + struct nfssattr ca_sa_buf; /* space to store attributes */ +}; + +/* + * arguments to link + */ +struct nfslinkargs { + fhandle_t *la_from; /* old file */ + fhandle_t la_from_buf; /* old file */ + struct nfsdiropargs la_to; /* new file and parent dir */ +}; + +/* + * arguments to rename + */ +struct nfsrnmargs { + struct nfsdiropargs rna_from; /* old file and parent dir */ + struct nfsdiropargs rna_to; /* new file and parent dir */ +}; + +/* + * arguments to symlink + */ +struct nfsslargs { + struct nfsdiropargs sla_from; /* old file and parent dir */ + char *sla_tnm; /* new name */ + int sla_tnm_flags; /* flags for name */ + struct nfssattr *sla_sa; /* attributes */ + struct nfssattr sla_sa_buf; /* attributes buffer */ +}; +#define SLA_FREETNM 1 + +/* + * NFS_OK part of statfs operation + */ +struct nfsstatfsok { + uint32_t fsok_tsize; /* preferred transfer size in bytes */ + uint32_t fsok_bsize; /* fundamental file system block size */ + uint32_t fsok_blocks; /* total blocks in file system */ + uint32_t fsok_bfree; /* free blocks in fs */ + uint32_t fsok_bavail; /* free blocks avail to non-superuser */ +}; + +/* + * Results of statfs operation + */ +struct nfsstatfs { + nfsstat fs_status; /* result status */ + union { + struct nfsstatfsok fs_fsok_u; /* NFS_OK result */ + } fs_u; +}; +#define fs_fsok fs_u.fs_fsok_u +#define fs_tsize fs_u.fs_fsok_u.fsok_tsize +#define fs_bsize fs_u.fs_fsok_u.fsok_bsize +#define fs_blocks fs_u.fs_fsok_u.fsok_blocks +#define fs_bfree fs_u.fs_fsok_u.fsok_bfree +#define fs_bavail fs_u.fs_fsok_u.fsok_bavail + +#ifdef _KERNEL +/* + * XDR routines for handling structures defined above + */ +extern bool_t xdr_attrstat(XDR *, struct nfsattrstat *); +extern bool_t xdr_fastattrstat(XDR *, struct nfsattrstat *); +extern bool_t xdr_creatargs(XDR *, struct nfscreatargs *); +extern bool_t xdr_diropargs(XDR *, struct nfsdiropargs *); +extern bool_t xdr_diropres(XDR *, struct nfsdiropres *); +extern bool_t xdr_fastdiropres(XDR *, struct nfsdiropres *); +extern bool_t xdr_drok(XDR *, struct nfsdrok *); +#ifdef _LITTLE_ENDIAN +extern bool_t xdr_fastdrok(XDR *, struct nfsdrok *); +extern bool_t xdr_fastfattr(XDR *, struct nfsfattr *); +#endif +extern bool_t xdr_fattr(XDR *, struct nfsfattr *); +extern bool_t xdr_fhandle(XDR *, fhandle_t *); +extern bool_t xdr_fastfhandle(XDR *, fhandle_t **); +extern bool_t xdr_linkargs(XDR *, struct nfslinkargs *); +extern bool_t xdr_rddirargs(XDR *, struct nfsrddirargs *); +extern bool_t xdr_putrddirres(XDR *, struct nfsrddirres *); +extern bool_t xdr_getrddirres(XDR *, struct nfsrddirres *); +extern bool_t xdr_rdlnres(XDR *, struct nfsrdlnres *); +extern bool_t xdr_rdresult(XDR *, struct nfsrdresult *); +extern bool_t xdr_readargs(XDR *, struct nfsreadargs *); +extern bool_t xdr_readlink(XDR *, fhandle_t *); +extern bool_t xdr_rnmargs(XDR *, struct nfsrnmargs *); +extern bool_t xdr_rrok(XDR *, struct nfsrrok *); +extern bool_t xdr_saargs(XDR *, struct nfssaargs *); +extern bool_t xdr_sattr(XDR *, struct nfssattr *); +extern bool_t xdr_slargs(XDR *, struct nfsslargs *); +extern bool_t xdr_srok(XDR *, struct nfssrok *); +extern bool_t xdr_nfs2_timeval(XDR *, struct nfs2_timeval *); +extern bool_t xdr_writeargs(XDR *, struct nfswriteargs *); +extern bool_t xdr_fsok(XDR *, struct nfsstatfsok *); +#ifdef _LITTLE_ENDIAN +extern bool_t xdr_fastfsok(XDR *, struct nfsstatfsok *); +extern bool_t xdr_fastenum(XDR *, enum_t *); +#endif +extern bool_t xdr_statfs(XDR *, struct nfsstatfs *); +extern bool_t xdr_faststatfs(XDR *, struct nfsstatfs *); +#endif + +/* + * Remote file service routines + */ +#define RFS_NULL 0 +#define RFS_GETATTR 1 +#define RFS_SETATTR 2 +#define RFS_ROOT 3 +#define RFS_LOOKUP 4 +#define RFS_READLINK 5 +#define RFS_READ 6 +#define RFS_WRITECACHE 7 +#define RFS_WRITE 8 +#define RFS_CREATE 9 +#define RFS_REMOVE 10 +#define RFS_RENAME 11 +#define RFS_LINK 12 +#define RFS_SYMLINK 13 +#define RFS_MKDIR 14 +#define RFS_RMDIR 15 +#define RFS_READDIR 16 +#define RFS_STATFS 17 +#define RFS_NPROC 18 + +#ifdef _KERNEL +/* + * The NFS Version 2 service procedures + */ +struct exportinfo; /* defined in nfs/export.h */ +struct servinfo; /* defined in nfs/nfs_clnt.h */ +struct mntinfo; /* defined in nfs/nfs_clnt.h */ + +extern void rfs_getattr(fhandle_t *, struct nfsattrstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_getattr_getfh(fhandle_t *); +extern void rfs_setattr(struct nfssaargs *, struct nfsattrstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_setattr_getfh(struct nfssaargs *); +extern void rfs_lookup(struct nfsdiropargs *, struct nfsdiropres *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_lookup_getfh(struct nfsdiropargs *); +extern void rfs_readlink(fhandle_t *, struct nfsrdlnres *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_readlink_getfh(fhandle_t *); +extern void rfs_rlfree(struct nfsrdlnres *); +extern void rfs_read(struct nfsreadargs *, struct nfsrdresult *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_read_getfh(struct nfsreadargs *); +extern void rfs_rdfree(struct nfsrdresult *); +extern void rfs_write_sync(struct nfswriteargs *, struct nfsattrstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void rfs_write(struct nfswriteargs *, struct nfsattrstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_write_getfh(struct nfswriteargs *); +extern void rfs_create(struct nfscreatargs *, struct nfsdiropres *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_create_getfh(struct nfscreatargs *); +extern void rfs_remove(struct nfsdiropargs *, enum nfsstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_remove_getfh(struct nfsdiropargs *); +extern void rfs_rename(struct nfsrnmargs *, enum nfsstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_rename_getfh(struct nfsrnmargs *); +extern void rfs_link(struct nfslinkargs *, enum nfsstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_link_getfh(struct nfslinkargs *); +extern void rfs_symlink(struct nfsslargs *, enum nfsstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_symlink_getfh(struct nfsslargs *); +extern void rfs_mkdir(struct nfscreatargs *, struct nfsdiropres *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_mkdir_getfh(struct nfscreatargs *); +extern void rfs_rmdir(struct nfsdiropargs *, enum nfsstat *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_rmdir_getfh(struct nfsdiropargs *); +extern void rfs_readdir(struct nfsrddirargs *, struct nfsrddirres *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs_readdir_getfh(struct nfsrddirargs *); +extern void rfs_rddirfree(struct nfsrddirres *); +extern void rfs_statfs(fhandle_t *, struct nfsstatfs *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs_statfs_getfh(fhandle_t *); +extern void rfs_srvrinit(void); +extern void rfs_srvrfini(void); +extern void rfs_srv_zone_init(nfs_globals_t *); +extern void rfs_srv_zone_fini(nfs_globals_t *); + +/* + * flags to define path types during Multi Component Lookups + * using the public filehandle + */ +#define URLPATH 0x01 /* Universal Resource Locator path */ +#define NATIVEPATH 0x02 /* Native path, i.e., via mount protocol */ +#define SECURITY_QUERY 0x04 /* Security query */ + +/* index for svstat_ptr */ +enum nfs_svccounts {NFS_CALLS, NFS_BADCALLS, NFS_REFERRALS, NFS_REFERLINKS}; + +#define NFS_V2 NFS_VERSION + +/* function defs for NFS kernel */ +extern int nfs_waitfor_purge_complete(vnode_t *); +extern int nfs_validate_caches(vnode_t *, cred_t *); +extern void nfs_purge_caches(vnode_t *, int, cred_t *); +extern void nfs_purge_rddir_cache(vnode_t *); +extern void nfs_attrcache(vnode_t *, struct nfsfattr *, hrtime_t); +extern int nfs_cache_fattr(vnode_t *, struct nfsfattr *, vattr_t *, + hrtime_t, cred_t *); +extern void nfs_attr_cache(vnode_t *, vattr_t *, hrtime_t, cred_t *); +extern void nfs_attrcache_va(vnode_t *, struct vattr *); +extern int nfs_getattr_otw(vnode_t *, struct vattr *, cred_t *); +extern int nfsgetattr(vnode_t *, struct vattr *, cred_t *); +extern int nattr_to_vattr(vnode_t *, struct nfsfattr *, struct vattr *); +extern void nfs_async_manager(struct vfs *); +extern void nfs_async_manager_stop(struct vfs *); +extern void nfs_async_stop(struct vfs *); +extern int nfs_async_stop_sig(struct vfs *); +extern int nfs_clntinit(void); +extern void nfs_clntfini(void); +extern int nfstsize(void); +extern void nfs_srvinit(void); +extern void nfs_srvfini(void); +extern int vattr_to_sattr(struct vattr *, struct nfssattr *); +extern void setdiropargs(struct nfsdiropargs *, char *, vnode_t *); +extern int setdirgid(vnode_t *, gid_t *, cred_t *); +extern int setdirmode(vnode_t *, mode_t *, cred_t *); +extern int newnum(void); +extern char *newname(void); +extern int nfs_subrinit(void); +extern void nfs_subrfini(void); +extern enum nfsstat puterrno(int); +extern int geterrno(enum nfsstat); +extern int nfsinit(int, char *); +extern void nfsfini(void); +extern int nfs_vfsinit(void); +extern void nfs_vfsfini(void); +extern int nfs_dump(vnode_t *, caddr_t, offset_t, offset_t, + caller_context_t *); +extern void nfs_perror(int, char *, ...); +extern void nfs_cmn_err(int, int, char *, ...); +extern int nfs_addcllock(vnode_t *, struct flock64 *); +extern void nfs_rmcllock(vnode_t *, struct flock64 *); +extern void nfs_lockrelease(vnode_t *, int, offset_t, cred_t *); +extern int vattr_to_nattr(struct vattr *, struct nfsfattr *); +extern int mount_root(char *, char *, int, struct nfs_args *, int *); +extern void nfs_lockcompletion(vnode_t *, int); +extern void nfs_add_locking_id(vnode_t *, pid_t, int, char *, int); +extern void nfs3copyfh(caddr_t, vnode_t *); +extern void nfscopyfh(caddr_t, vnode_t *); +extern int nfs3lookup(vnode_t *, char *, vnode_t **, struct pathname *, + int, vnode_t *, cred_t *, int); +extern int nfslookup(vnode_t *, char *, vnode_t **, struct pathname *, int, + vnode_t *, cred_t *, int); +extern void sv_free(struct servinfo *); +extern int nfsauth_access(struct exportinfo *, struct svc_req *, cred_t *, + uid_t *, gid_t *, uint_t *, gid_t **); +extern void nfsauth_init(void); +extern void nfsauth_fini(void); +extern void nfsauth_zone_init(nfs_globals_t *); +extern void nfsauth_zone_fini(nfs_globals_t *); +extern void nfsauth_zone_shutdown(nfs_globals_t *); +extern int nfs_setopts(vnode_t *, model_t, struct nfs_args *); +extern int nfs_mount_label_policy(vfs_t *, struct netbuf *, + struct knetconfig *, cred_t *); +extern boolean_t nfs_has_ctty(void); +extern nfs_globals_t *nfs_srv_getzg(void); +extern void nfs_srv_stop_all(void); +extern void nfs_srv_quiesce_all(void); +extern int rfs4_dss_setpaths(char *, size_t); +extern int nfs_setmod_check(page_t *); + +extern time_t rfs4_lease_time; +extern time_t rfs4_grace_period; +extern nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths; + +extern kstat_named_t *global_svstat_ptr[]; + +extern zone_key_t nfssrv_zone_key; +extern list_t nfssrv_globals_list; +extern krwlock_t nfssrv_globals_rwl; + +extern krwlock_t rroklock; +extern vtype_t nf_to_vt[]; +extern kmutex_t nfs_minor_lock; +extern int nfs_major; +extern int nfs_minor; +extern vfsops_t *nfs_vfsops; +extern struct vnodeops *nfs_vnodeops; +extern const struct fs_operation_def nfs_vnodeops_template[]; +extern int nfsfstyp; +extern void (*nfs_srv_quiesce_func)(void); +extern int (*nfs_srv_dss_func)(char *, size_t); + +/* + * Per-zone stats as consumed by nfsstat(8) + */ +struct nfs_version_stats { + kstat_named_t *aclreqcnt_ptr; /* nfs_acl:0:aclreqcnt_v? */ + kstat_named_t *rfsreqcnt_ptr; /* nfs:0:rfsreqcnt_v? */ +}; + +/* + * A bit of asymmetry: nfs:0:nfs_client isn't part of this structure. + */ +struct nfs_stats { + struct nfs_version_stats nfs_stats_v2; + struct nfs_version_stats nfs_stats_v3; + struct nfs_version_stats nfs_stats_v4; +}; + +/* + * Key used to retrieve counters. + */ +extern zone_key_t nfsstat_zone_key; + +/* + * Zone callback functions. + */ +extern void *nfsstat_zone_init(zoneid_t); +extern void nfsstat_zone_fini(zoneid_t, void *); + +extern void rfs_stat_zone_init(nfs_globals_t *); +extern void rfs_stat_zone_fini(nfs_globals_t *); + +#endif /* _KERNEL */ + +/* + * Version 3 declarations and definitions. + */ + +#define NFS3_FHSIZE 64 +#define NFS3_COOKIEVERFSIZE 8 +#define NFS3_CREATEVERFSIZE 8 +#define NFS3_WRITEVERFSIZE 8 + +typedef char *filename3; + +typedef char *nfspath3; + +#define nfs3nametoolong ((char *)-1) + +typedef uint64 fileid3; + +typedef uint64 cookie3; + +typedef uint32 uid3; + +typedef uint32 gid3; + +typedef uint64 size3; + +typedef uint64 offset3; + +typedef uint32 mode3; + +typedef uint32 count3; + +/* + * These three are really opaque arrays, but we treat them as + * uint64 for efficiency sake + */ +typedef uint64 cookieverf3; + +typedef uint64 createverf3; + +typedef uint64 writeverf3; + +typedef struct nfs_fh3 { + uint_t fh3_length; + union nfs_fh3_u { + struct nfs_fh3_i { + fhandle3_t fh3_i; + } nfs_fh3_i; + char data[NFS3_FHSIZE]; + } fh3_u; + uint_t fh3_flags; +} nfs_fh3; +#define fh3_fsid fh3_u.nfs_fh3_i.fh3_i._fh3_fsid +#define fh3_len fh3_u.nfs_fh3_i.fh3_i._fh3_len +#define fh3_data fh3_u.nfs_fh3_i.fh3_i._fh3_data +#define fh3_xlen fh3_u.nfs_fh3_i.fh3_i._fh3_xlen +#define fh3_xdata fh3_u.nfs_fh3_i.fh3_i._fh3_xdata +#define FH3TOFIDP(fh) ((fid_t *)&((fh)->fh3_len)) +#define FH3TOXFIDP(fh) ((fid_t *)&((fh)->fh3_xlen)) + +/* + * nfs_fh3.fh3_flags values + */ +#define FH_WEBNFS 0x1 /* fh is WebNFS overloaded - see makefh3_ol() */ + +/* + * Two elements were added to the + * diropargs3 structure for performance (xdr-inlining). + * They are not included as part of the args + * that are encoded or decoded: + * dirp - ptr to the nfs_fh3 + * flag indicating when to free the name that was + * allocated during decode. + */ +struct diropargs3 { + nfs_fh3 *dirp; + nfs_fh3 dir; + filename3 name; + int flags; +}; +typedef struct diropargs3 diropargs3; + +struct nfstime3 { + uint32 seconds; + uint32 nseconds; +}; +typedef struct nfstime3 nfstime3; + +struct specdata3 { + uint32 specdata1; + uint32 specdata2; +}; +typedef struct specdata3 specdata3; + +enum nfsstat3 { + NFS3_OK = 0, + NFS3ERR_PERM = 1, + NFS3ERR_NOENT = 2, + NFS3ERR_IO = 5, + NFS3ERR_NXIO = 6, + NFS3ERR_ACCES = 13, + NFS3ERR_EXIST = 17, + NFS3ERR_XDEV = 18, + NFS3ERR_NODEV = 19, + NFS3ERR_NOTDIR = 20, + NFS3ERR_ISDIR = 21, + NFS3ERR_INVAL = 22, + NFS3ERR_FBIG = 27, + NFS3ERR_NOSPC = 28, + NFS3ERR_ROFS = 30, + NFS3ERR_MLINK = 31, + NFS3ERR_NAMETOOLONG = 63, + NFS3ERR_NOTEMPTY = 66, + NFS3ERR_DQUOT = 69, + NFS3ERR_STALE = 70, + NFS3ERR_REMOTE = 71, + NFS3ERR_BADHANDLE = 10001, + NFS3ERR_NOT_SYNC = 10002, + NFS3ERR_BAD_COOKIE = 10003, + NFS3ERR_NOTSUPP = 10004, + NFS3ERR_TOOSMALL = 10005, + NFS3ERR_SERVERFAULT = 10006, + NFS3ERR_BADTYPE = 10007, + NFS3ERR_JUKEBOX = 10008 +}; +typedef enum nfsstat3 nfsstat3; + +enum ftype3 { + NF3REG = 1, + NF3DIR = 2, + NF3BLK = 3, + NF3CHR = 4, + NF3LNK = 5, + NF3SOCK = 6, + NF3FIFO = 7 +}; +typedef enum ftype3 ftype3; + +struct fattr3 { + ftype3 type; + mode3 mode; + uint32 nlink; + uid3 uid; + gid3 gid; + size3 size; + size3 used; + specdata3 rdev; + uint64 fsid; + fileid3 fileid; + nfstime3 atime; + nfstime3 mtime; + nfstime3 ctime; +}; +typedef struct fattr3 fattr3; + +#define NFS3_SIZEOF_FATTR3 (21) + +#ifdef _KERNEL +struct fattr3_res { + nfsstat3 status; + vattr_t *vap; + vnode_t *vp; +}; +typedef struct fattr3_res fattr3_res; +#endif /* _KERNEL */ + +struct post_op_attr { + bool_t attributes; + fattr3 attr; +}; +typedef struct post_op_attr post_op_attr; + +#ifdef _KERNEL +struct post_op_vattr { + bool_t attributes; + fattr3_res fres; +}; +typedef struct post_op_vattr post_op_vattr; +#endif /* _KERNEL */ + +struct wcc_attr { + size3 size; + nfstime3 mtime; + nfstime3 ctime; +}; +typedef struct wcc_attr wcc_attr; + +struct pre_op_attr { + bool_t attributes; + wcc_attr attr; +}; +typedef struct pre_op_attr pre_op_attr; + +struct wcc_data { + pre_op_attr before; + post_op_attr after; +}; +typedef struct wcc_data wcc_data; + +struct post_op_fh3 { + bool_t handle_follows; + nfs_fh3 handle; +}; +typedef struct post_op_fh3 post_op_fh3; + +enum time_how { + DONT_CHANGE = 0, + SET_TO_SERVER_TIME = 1, + SET_TO_CLIENT_TIME = 2 +}; +typedef enum time_how time_how; + +struct set_mode3 { + bool_t set_it; + mode3 mode; +}; +typedef struct set_mode3 set_mode3; + +struct set_uid3 { + bool_t set_it; + uid3 uid; +}; +typedef struct set_uid3 set_uid3; + +struct set_gid3 { + bool_t set_it; + gid3 gid; +}; +typedef struct set_gid3 set_gid3; + +struct set_size3 { + bool_t set_it; + size3 size; +}; +typedef struct set_size3 set_size3; + +struct set_atime { + time_how set_it; + nfstime3 atime; +}; +typedef struct set_atime set_atime; + +struct set_mtime { + time_how set_it; + nfstime3 mtime; +}; +typedef struct set_mtime set_mtime; + +struct sattr3 { + set_mode3 mode; + set_uid3 uid; + set_gid3 gid; + set_size3 size; + set_atime atime; + set_mtime mtime; +}; +typedef struct sattr3 sattr3; + +/* + * A couple of defines to make resok and resfail look like the + * correct things in a response type independent manner. + */ +#define resok res_u.ok +#define resfail res_u.fail + +struct GETATTR3args { + nfs_fh3 object; +}; +typedef struct GETATTR3args GETATTR3args; + +struct GETATTR3resok { + fattr3 obj_attributes; +}; +typedef struct GETATTR3resok GETATTR3resok; + +struct GETATTR3res { + nfsstat3 status; + union { + GETATTR3resok ok; + } res_u; +}; +typedef struct GETATTR3res GETATTR3res; + +#ifdef _KERNEL +struct GETATTR3vres { + nfsstat3 status; + fattr3_res fres; +}; +typedef struct GETATTR3vres GETATTR3vres; +#endif /* _KERNEL */ + +struct sattrguard3 { + bool_t check; + nfstime3 obj_ctime; +}; +typedef struct sattrguard3 sattrguard3; + +struct SETATTR3args { + nfs_fh3 object; + sattr3 new_attributes; + sattrguard3 guard; +}; +typedef struct SETATTR3args SETATTR3args; + +struct SETATTR3resok { + wcc_data obj_wcc; +}; +typedef struct SETATTR3resok SETATTR3resok; + +struct SETATTR3resfail { + wcc_data obj_wcc; +}; +typedef struct SETATTR3resfail SETATTR3resfail; + +struct SETATTR3res { + nfsstat3 status; + union { + SETATTR3resok ok; + SETATTR3resfail fail; + } res_u; +}; +typedef struct SETATTR3res SETATTR3res; + +struct LOOKUP3args { + diropargs3 what; +}; +typedef struct LOOKUP3args LOOKUP3args; + +struct LOOKUP3resok { + nfs_fh3 object; + post_op_attr obj_attributes; + post_op_attr dir_attributes; +}; +typedef struct LOOKUP3resok LOOKUP3resok; + +struct LOOKUP3resfail { + post_op_attr dir_attributes; +}; +typedef struct LOOKUP3resfail LOOKUP3resfail; + +struct LOOKUP3res { + nfsstat3 status; + union { + LOOKUP3resok ok; + LOOKUP3resfail fail; + } res_u; +}; +typedef struct LOOKUP3res LOOKUP3res; + +#ifdef _KERNEL +struct LOOKUP3vres { + nfsstat3 status; + nfs_fh3 object; + post_op_vattr dir_attributes; + post_op_vattr obj_attributes; +}; +typedef struct LOOKUP3vres LOOKUP3vres; +#endif /* _KERNEL */ + +struct ACCESS3args { + nfs_fh3 object; + uint32 access; +}; +typedef struct ACCESS3args ACCESS3args; +#define ACCESS3_READ 0x1 +#define ACCESS3_LOOKUP 0x2 +#define ACCESS3_MODIFY 0x4 +#define ACCESS3_EXTEND 0x8 +#define ACCESS3_DELETE 0x10 +#define ACCESS3_EXECUTE 0x20 + +struct ACCESS3resok { + post_op_attr obj_attributes; + uint32 access; +}; +typedef struct ACCESS3resok ACCESS3resok; + +struct ACCESS3resfail { + post_op_attr obj_attributes; +}; +typedef struct ACCESS3resfail ACCESS3resfail; + +struct ACCESS3res { + nfsstat3 status; + union { + ACCESS3resok ok; + ACCESS3resfail fail; + } res_u; +}; +typedef struct ACCESS3res ACCESS3res; + +struct READLINK3args { + nfs_fh3 symlink; +}; +typedef struct READLINK3args READLINK3args; + +struct READLINK3resok { + post_op_attr symlink_attributes; + nfspath3 data; +}; +typedef struct READLINK3resok READLINK3resok; + +struct READLINK3resfail { + post_op_attr symlink_attributes; +}; +typedef struct READLINK3resfail READLINK3resfail; + +struct READLINK3res { + nfsstat3 status; + union { + READLINK3resok ok; + READLINK3resfail fail; + } res_u; +}; +typedef struct READLINK3res READLINK3res; + +struct READ3args { + nfs_fh3 file; + offset3 offset; + count3 count; +#ifdef _KERNEL + /* for read using rdma */ + char *res_data_val_alt; + struct uio *res_uiop; + struct clist *wlist; + CONN *conn; +#endif +}; +typedef struct READ3args READ3args; + +struct READ3resok { + post_op_attr file_attributes; + count3 count; + bool_t eof; + struct { + uint_t data_len; + char *data_val; + mblk_t *mp; + } data; + uint_t size; +#ifdef _KERNEL + uint_t wlist_len; + struct clist *wlist; + frtn_t zcopy; +#endif +}; +typedef struct READ3resok READ3resok; + +struct READ3resfail { + post_op_attr file_attributes; +}; +typedef struct READ3resfail READ3resfail; + +struct READ3res { + nfsstat3 status; + union { + READ3resok ok; + READ3resfail fail; + } res_u; +}; +typedef struct READ3res READ3res; + +#ifdef _KERNEL +/* + * READ3 reply that directly decodes fattr3 directly into vattr + */ +struct READ3vres { + nfsstat3 status; + struct post_op_vattr pov; + count3 count; + bool_t eof; + struct { + uint_t data_len; + char *data_val; + } data; + uint_t size; + + uint_t wlist_len; + struct clist *wlist; +}; +typedef struct READ3vres READ3vres; +#endif /* _KERNEL */ + +/* + * READ3 reply that uiomoves data directly into a struct uio + * ignores any attributes returned + */ +struct READ3uiores { + nfsstat3 status; + count3 count; + bool_t eof; + struct uio *uiop; + uint_t size; /* maximum reply size */ +#ifdef _KERNEL + uint_t wlist_len; + struct clist *wlist; +#endif +}; +typedef struct READ3uiores READ3uiores; + +enum stable_how { + UNSTABLE = 0, + DATA_SYNC = 1, + FILE_SYNC = 2 +}; +typedef enum stable_how stable_how; + +struct WRITE3args { + nfs_fh3 file; + offset3 offset; + count3 count; + stable_how stable; + struct { + uint_t data_len; + char *data_val; + } data; + mblk_t *mblk; +#ifdef _KERNEL + struct clist *rlist; + CONN *conn; +#endif +}; +typedef struct WRITE3args WRITE3args; + +struct WRITE3resok { + wcc_data file_wcc; + count3 count; + stable_how committed; + writeverf3 verf; +}; +typedef struct WRITE3resok WRITE3resok; + +struct WRITE3resfail { + wcc_data file_wcc; +}; +typedef struct WRITE3resfail WRITE3resfail; + +struct WRITE3res { + nfsstat3 status; + union { + WRITE3resok ok; + WRITE3resfail fail; + } res_u; +}; +typedef struct WRITE3res WRITE3res; + +enum createmode3 { + UNCHECKED = 0, + GUARDED = 1, + EXCLUSIVE = 2 +}; +typedef enum createmode3 createmode3; + +struct createhow3 { + createmode3 mode; + union { + sattr3 obj_attributes; + createverf3 verf; + } createhow3_u; +}; +typedef struct createhow3 createhow3; + +struct CREATE3args { + diropargs3 where; + createhow3 how; +}; +typedef struct CREATE3args CREATE3args; + +struct CREATE3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; +typedef struct CREATE3resok CREATE3resok; + +struct CREATE3resfail { + wcc_data dir_wcc; +}; +typedef struct CREATE3resfail CREATE3resfail; + +struct CREATE3res { + nfsstat3 status; + union { + CREATE3resok ok; + CREATE3resfail fail; + } res_u; +}; +typedef struct CREATE3res CREATE3res; + +struct MKDIR3args { + diropargs3 where; + sattr3 attributes; +}; +typedef struct MKDIR3args MKDIR3args; + +struct MKDIR3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; +typedef struct MKDIR3resok MKDIR3resok; + +struct MKDIR3resfail { + wcc_data dir_wcc; +}; +typedef struct MKDIR3resfail MKDIR3resfail; + +struct MKDIR3res { + nfsstat3 status; + union { + MKDIR3resok ok; + MKDIR3resfail fail; + } res_u; +}; +typedef struct MKDIR3res MKDIR3res; + +struct symlinkdata3 { + sattr3 symlink_attributes; + nfspath3 symlink_data; +}; +typedef struct symlinkdata3 symlinkdata3; + +struct SYMLINK3args { + diropargs3 where; + symlinkdata3 symlink; +}; +typedef struct SYMLINK3args SYMLINK3args; + +struct SYMLINK3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; +typedef struct SYMLINK3resok SYMLINK3resok; + +struct SYMLINK3resfail { + wcc_data dir_wcc; +}; +typedef struct SYMLINK3resfail SYMLINK3resfail; + +struct SYMLINK3res { + nfsstat3 status; + union { + SYMLINK3resok ok; + SYMLINK3resfail fail; + } res_u; +}; +typedef struct SYMLINK3res SYMLINK3res; + +struct devicedata3 { + sattr3 dev_attributes; + specdata3 spec; +}; +typedef struct devicedata3 devicedata3; + +struct mknoddata3 { + ftype3 type; + union { + devicedata3 device; + sattr3 pipe_attributes; + } mknoddata3_u; +}; +typedef struct mknoddata3 mknoddata3; + +struct MKNOD3args { + diropargs3 where; + mknoddata3 what; +}; +typedef struct MKNOD3args MKNOD3args; + +struct MKNOD3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; +typedef struct MKNOD3resok MKNOD3resok; + +struct MKNOD3resfail { + wcc_data dir_wcc; +}; +typedef struct MKNOD3resfail MKNOD3resfail; + +struct MKNOD3res { + nfsstat3 status; + union { + MKNOD3resok ok; + MKNOD3resfail fail; + } res_u; +}; +typedef struct MKNOD3res MKNOD3res; + +struct REMOVE3args { + diropargs3 object; +}; +typedef struct REMOVE3args REMOVE3args; + +struct REMOVE3resok { + wcc_data dir_wcc; +}; +typedef struct REMOVE3resok REMOVE3resok; + +struct REMOVE3resfail { + wcc_data dir_wcc; +}; +typedef struct REMOVE3resfail REMOVE3resfail; + +struct REMOVE3res { + nfsstat3 status; + union { + REMOVE3resok ok; + REMOVE3resfail fail; + } res_u; +}; +typedef struct REMOVE3res REMOVE3res; + +struct RMDIR3args { + diropargs3 object; +}; +typedef struct RMDIR3args RMDIR3args; + +struct RMDIR3resok { + wcc_data dir_wcc; +}; +typedef struct RMDIR3resok RMDIR3resok; + +struct RMDIR3resfail { + wcc_data dir_wcc; +}; +typedef struct RMDIR3resfail RMDIR3resfail; + +struct RMDIR3res { + nfsstat3 status; + union { + RMDIR3resok ok; + RMDIR3resfail fail; + } res_u; +}; +typedef struct RMDIR3res RMDIR3res; + +struct RENAME3args { + diropargs3 from; + diropargs3 to; +}; +typedef struct RENAME3args RENAME3args; + +struct RENAME3resok { + wcc_data fromdir_wcc; + wcc_data todir_wcc; +}; +typedef struct RENAME3resok RENAME3resok; + +struct RENAME3resfail { + wcc_data fromdir_wcc; + wcc_data todir_wcc; +}; +typedef struct RENAME3resfail RENAME3resfail; + +struct RENAME3res { + nfsstat3 status; + union { + RENAME3resok ok; + RENAME3resfail fail; + } res_u; +}; +typedef struct RENAME3res RENAME3res; + +struct LINK3args { + nfs_fh3 file; + diropargs3 link; +}; +typedef struct LINK3args LINK3args; + +struct LINK3resok { + post_op_attr file_attributes; + wcc_data linkdir_wcc; +}; +typedef struct LINK3resok LINK3resok; + +struct LINK3resfail { + post_op_attr file_attributes; + wcc_data linkdir_wcc; +}; +typedef struct LINK3resfail LINK3resfail; + +struct LINK3res { + nfsstat3 status; + union { + LINK3resok ok; + LINK3resfail fail; + } res_u; +}; +typedef struct LINK3res LINK3res; + +struct READDIR3args { + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 count; +}; +typedef struct READDIR3args READDIR3args; + +struct entry3 { + fileid3 fileid; + filename3 name; + cookie3 cookie; + struct entry3 *nextentry; +}; +typedef struct entry3 entry3; + +struct dirlist3 { + entry3 *entries; + bool_t eof; +}; +typedef struct dirlist3 dirlist3; + +struct READDIR3resok { + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlist3 reply; + uint_t size; + uint_t count; + uint_t freecount; + cookie3 cookie; +}; +typedef struct READDIR3resok READDIR3resok; + +struct READDIR3resfail { + post_op_attr dir_attributes; +}; +typedef struct READDIR3resfail READDIR3resfail; + +struct READDIR3res { + nfsstat3 status; + union { + READDIR3resok ok; + READDIR3resfail fail; + } res_u; +}; +typedef struct READDIR3res READDIR3res; + +#ifdef _KERNEL +struct READDIR3vres { + nfsstat3 status; + post_op_vattr dir_attributes; + cookieverf3 cookieverf; + dirent64_t *entries; /* decoded dirent64s */ + uint_t size; /* actual size of entries */ + uint_t entries_size; /* max size of entries */ + off64_t loff; /* last offset/cookie */ + bool_t eof; /* End of directory */ +}; +typedef struct READDIR3vres READDIR3vres; +#endif /* _KERNEL */ + +struct READDIRPLUS3args { + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 dircount; + count3 maxcount; +}; +typedef struct READDIRPLUS3args READDIRPLUS3args; + +struct entryplus3 { + fileid3 fileid; + filename3 name; + cookie3 cookie; + post_op_attr name_attributes; + post_op_fh3 name_handle; + struct entryplus3 *nextentry; +}; +typedef struct entryplus3 entryplus3; + +struct dirlistplus3 { + entryplus3 *entries; + bool_t eof; +}; +typedef struct dirlistplus3 dirlistplus3; + +struct entryplus3_info { + post_op_attr attr; + post_op_fh3 fh; + uint_t namelen; +}; +typedef struct entryplus3_info entryplus3_info; + +struct READDIRPLUS3resok { + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlistplus3 reply; + uint_t size; + uint_t count; + uint_t maxcount; + entryplus3_info *infop; +}; +typedef struct READDIRPLUS3resok READDIRPLUS3resok; + +struct READDIRPLUS3resfail { + post_op_attr dir_attributes; +}; +typedef struct READDIRPLUS3resfail READDIRPLUS3resfail; + +struct READDIRPLUS3res { + nfsstat3 status; + union { + READDIRPLUS3resok ok; + READDIRPLUS3resfail fail; + } res_u; +}; +typedef struct READDIRPLUS3res READDIRPLUS3res; + +#ifdef _KERNEL +struct entryplus3_va_fh { + int va_valid; + int fh_valid; + vattr_t va; + nfs_fh3 fh; + char *d_name; /* back pointer into entries */ +}; + +struct READDIRPLUS3vres { + nfsstat3 status; + post_op_vattr dir_attributes; + cookieverf3 cookieverf; + dirent64_t *entries; /* decoded dirent64s */ + uint_t size; /* actual size of entries */ + uint_t entries_size; /* max size of entries */ + bool_t eof; /* End of directory */ + off64_t loff; /* last offset/cookie */ + cred_t *credentials; /* caller's credentials */ + hrtime_t time; /* time of READDIRPLUS call */ +}; +typedef struct READDIRPLUS3vres READDIRPLUS3vres; +#endif /* _KERNEL */ + +struct FSSTAT3args { + nfs_fh3 fsroot; +}; +typedef struct FSSTAT3args FSSTAT3args; + +struct FSSTAT3resok { + post_op_attr obj_attributes; + size3 tbytes; + size3 fbytes; + size3 abytes; + size3 tfiles; + size3 ffiles; + size3 afiles; + uint32 invarsec; +}; +typedef struct FSSTAT3resok FSSTAT3resok; + +struct FSSTAT3resfail { + post_op_attr obj_attributes; +}; +typedef struct FSSTAT3resfail FSSTAT3resfail; + +struct FSSTAT3res { + nfsstat3 status; + union { + FSSTAT3resok ok; + FSSTAT3resfail fail; + } res_u; +}; +typedef struct FSSTAT3res FSSTAT3res; + +struct FSINFO3args { + nfs_fh3 fsroot; +}; +typedef struct FSINFO3args FSINFO3args; + +struct FSINFO3resok { + post_op_attr obj_attributes; + uint32 rtmax; + uint32 rtpref; + uint32 rtmult; + uint32 wtmax; + uint32 wtpref; + uint32 wtmult; + uint32 dtpref; + size3 maxfilesize; + nfstime3 time_delta; + uint32 properties; +}; +typedef struct FSINFO3resok FSINFO3resok; + +struct FSINFO3resfail { + post_op_attr obj_attributes; +}; +typedef struct FSINFO3resfail FSINFO3resfail; +#define FSF3_LINK 0x1 +#define FSF3_SYMLINK 0x2 +#define FSF3_HOMOGENEOUS 0x8 +#define FSF3_CANSETTIME 0x10 + +struct FSINFO3res { + nfsstat3 status; + union { + FSINFO3resok ok; + FSINFO3resfail fail; + } res_u; +}; +typedef struct FSINFO3res FSINFO3res; + +struct PATHCONF3args { + nfs_fh3 object; +}; +typedef struct PATHCONF3args PATHCONF3args; + +struct nfs3_pathconf_info { + uint32 link_max; + uint32 name_max; + bool_t no_trunc; + bool_t chown_restricted; + bool_t case_insensitive; + bool_t case_preserving; +}; +typedef struct nfs3_pathconf_info nfs3_pathconf_info; + +struct PATHCONF3resok { + post_op_attr obj_attributes; + nfs3_pathconf_info info; +}; +typedef struct PATHCONF3resok PATHCONF3resok; + +struct PATHCONF3resfail { + post_op_attr obj_attributes; +}; +typedef struct PATHCONF3resfail PATHCONF3resfail; + +struct PATHCONF3res { + nfsstat3 status; + union { + PATHCONF3resok ok; + PATHCONF3resfail fail; + } res_u; +}; +typedef struct PATHCONF3res PATHCONF3res; + +struct COMMIT3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; +typedef struct COMMIT3args COMMIT3args; + +struct COMMIT3resok { + wcc_data file_wcc; + writeverf3 verf; +}; +typedef struct COMMIT3resok COMMIT3resok; + +struct COMMIT3resfail { + wcc_data file_wcc; +}; +typedef struct COMMIT3resfail COMMIT3resfail; + +struct COMMIT3res { + nfsstat3 status; + union { + COMMIT3resok ok; + COMMIT3resfail fail; + } res_u; +}; +typedef struct COMMIT3res COMMIT3res; + +#define NFS3_PROGRAM ((rpcprog_t)100003) +#define NFS_V3 ((rpcvers_t)3) +#define NFSPROC3_NULL ((rpcproc_t)0) +#define NFSPROC3_GETATTR ((rpcproc_t)1) +#define NFSPROC3_SETATTR ((rpcproc_t)2) +#define NFSPROC3_LOOKUP ((rpcproc_t)3) +#define NFSPROC3_ACCESS ((rpcproc_t)4) +#define NFSPROC3_READLINK ((rpcproc_t)5) +#define NFSPROC3_READ ((rpcproc_t)6) +#define NFSPROC3_WRITE ((rpcproc_t)7) +#define NFSPROC3_CREATE ((rpcproc_t)8) +#define NFSPROC3_MKDIR ((rpcproc_t)9) +#define NFSPROC3_SYMLINK ((rpcproc_t)10) +#define NFSPROC3_MKNOD ((rpcproc_t)11) +#define NFSPROC3_REMOVE ((rpcproc_t)12) +#define NFSPROC3_RMDIR ((rpcproc_t)13) +#define NFSPROC3_RENAME ((rpcproc_t)14) +#define NFSPROC3_LINK ((rpcproc_t)15) +#define NFSPROC3_READDIR ((rpcproc_t)16) +#define NFSPROC3_READDIRPLUS ((rpcproc_t)17) +#define NFSPROC3_FSSTAT ((rpcproc_t)18) +#define NFSPROC3_FSINFO ((rpcproc_t)19) +#define NFSPROC3_PATHCONF ((rpcproc_t)20) +#define NFSPROC3_COMMIT ((rpcproc_t)21) + +#ifndef _KERNEL +extern void *nfsproc3_null_3(); +extern GETATTR3res *nfsproc3_getattr_3(); +extern SETATTR3res *nfsproc3_setattr_3(); +extern LOOKUP3res *nfsproc3_lookup_3(); +extern ACCESS3res *nfsproc3_access_3(); +extern READLINK3res *nfsproc3_readlink_3(); +extern READ3res *nfsproc3_read_3(); +extern WRITE3res *nfsproc3_write_3(); +extern CREATE3res *nfsproc3_create_3(); +extern MKDIR3res *nfsproc3_mkdir_3(); +extern SYMLINK3res *nfsproc3_symlink_3(); +extern MKNOD3res *nfsproc3_mknod_3(); +extern REMOVE3res *nfsproc3_remove_3(); +extern RMDIR3res *nfsproc3_rmdir_3(); +extern RENAME3res *nfsproc3_rename_3(); +extern LINK3res *nfsproc3_link_3(); +extern READDIR3res *nfsproc3_readdir_3(); +extern READDIRPLUS3res *nfsproc3_readdirplus_3(); +extern FSSTAT3res *nfsproc3_fsstat_3(); +extern FSINFO3res *nfsproc3_fsinfo_3(); +extern PATHCONF3res *nfsproc3_pathconf_3(); +extern COMMIT3res *nfsproc3_commit_3(); +#endif /* !_KERNEL */ + +#ifdef _KERNEL +/* the NFS Version 3 XDR functions */ + +extern bool_t xdr_nfs_fh3(XDR *, nfs_fh3 *); +extern bool_t xdr_nfslog_nfs_fh3(XDR *, nfs_fh3 *); +extern bool_t xdr_nfs_fh3_server(XDR *, nfs_fh3 *); +extern bool_t xdr_diropargs3(XDR *, diropargs3 *); +extern bool_t xdr_post_op_attr(XDR *, post_op_attr *); +extern bool_t xdr_post_op_fh3(XDR *, post_op_fh3 *); +extern bool_t xdr_GETATTR3res(XDR *, GETATTR3res *); +extern bool_t xdr_GETATTR3vres(XDR *, GETATTR3vres *); +extern bool_t xdr_SETATTR3args(XDR *, SETATTR3args *); +extern bool_t xdr_SETATTR3res(XDR *, SETATTR3res *); +extern bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res *); +extern bool_t xdr_LOOKUP3vres(XDR *, LOOKUP3vres *); +extern bool_t xdr_ACCESS3args(XDR *, ACCESS3args *); +extern bool_t xdr_ACCESS3res(XDR *, ACCESS3res *); +extern bool_t xdr_READLINK3args(XDR *, READLINK3args *); +extern bool_t xdr_READLINK3res(XDR *, READLINK3res *); +extern bool_t xdr_READ3args(XDR *, READ3args *); +extern bool_t xdr_READ3res(XDR *, READ3res *); +extern bool_t xdr_READ3vres(XDR *, READ3vres *); +extern bool_t xdr_READ3uiores(XDR *, READ3uiores *); +extern bool_t xdr_WRITE3args(XDR *, WRITE3args *); +extern bool_t xdr_WRITE3res(XDR *, WRITE3res *); +extern bool_t xdr_CREATE3args(XDR *, CREATE3args *); +extern bool_t xdr_CREATE3res(XDR *, CREATE3res *); +extern bool_t xdr_MKDIR3args(XDR *, MKDIR3args *); +extern bool_t xdr_MKDIR3res(XDR *, MKDIR3res *); +extern bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args *); +extern bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res *); +extern bool_t xdr_MKNOD3args(XDR *, MKNOD3args *); +extern bool_t xdr_MKNOD3res(XDR *, MKNOD3res *); +extern bool_t xdr_REMOVE3res(XDR *, REMOVE3res *); +extern bool_t xdr_RMDIR3resfail(XDR *, RMDIR3resfail *); +extern bool_t xdr_RMDIR3res(XDR *, RMDIR3res *); +extern bool_t xdr_RENAME3args(XDR *, RENAME3args *); +extern bool_t xdr_RENAME3res(XDR *, RENAME3res *); +extern bool_t xdr_LINK3args(XDR *, LINK3args *); +extern bool_t xdr_LINK3res(XDR *, LINK3res *); +extern bool_t xdr_READDIR3args(XDR *, READDIR3args *); +extern bool_t xdr_READDIR3res(XDR *, READDIR3res *); +extern bool_t xdr_READDIR3vres(XDR *, READDIR3vres *); +extern bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args *); +extern bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res *); +extern bool_t xdr_READDIRPLUS3vres(XDR *, READDIRPLUS3vres *); +extern bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res *); +extern bool_t xdr_FSINFO3res(XDR *, FSINFO3res *); +extern bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res *); +extern bool_t xdr_COMMIT3args(XDR *, COMMIT3args *); +extern bool_t xdr_COMMIT3res(XDR *, COMMIT3res *); +extern bool_t xdr_fastnfs_fh3(XDR *, nfs_fh3 **); + +/* + * The NFS Version 3 service procedures. + */ +struct exportinfo; /* defined in nfs/export.h */ +struct servinfo; /* defined in nfs/nfs_clnt.h */ +struct mntinfo; /* defined in nfs/nfs_clnt.h */ +struct sec_ol; /* defined in nfs/export.h */ + +extern void rfs3_getattr(GETATTR3args *, GETATTR3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_getattr_getfh(GETATTR3args *); +extern void rfs3_setattr(SETATTR3args *, SETATTR3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_setattr_getfh(SETATTR3args *); +extern void rfs3_lookup(LOOKUP3args *, LOOKUP3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_lookup_getfh(LOOKUP3args *); +extern void rfs3_access(ACCESS3args *, ACCESS3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_access_getfh(ACCESS3args *); +extern void rfs3_readlink(READLINK3args *, READLINK3res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs3_readlink_getfh(READLINK3args *); +extern void rfs3_readlink_free(READLINK3res *); +extern void rfs3_read(READ3args *, READ3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_read_getfh(READ3args *); +extern void rfs3_read_free(READ3res *); +extern void rfs3_write(WRITE3args *, WRITE3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_write_getfh(WRITE3args *); +extern void rfs3_create(CREATE3args *, CREATE3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_create_getfh(CREATE3args *); +extern void rfs3_mkdir(MKDIR3args *, MKDIR3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_mkdir_getfh(MKDIR3args *); +extern void rfs3_symlink(SYMLINK3args *, SYMLINK3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_symlink_getfh(SYMLINK3args *); +extern void rfs3_mknod(MKNOD3args *, MKNOD3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_mknod_getfh(MKNOD3args *); +extern void rfs3_remove(REMOVE3args *, REMOVE3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_remove_getfh(REMOVE3args *); +extern void rfs3_rmdir(RMDIR3args *, RMDIR3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_rmdir_getfh(RMDIR3args *); +extern void rfs3_rename(RENAME3args *, RENAME3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_rename_getfh(RENAME3args *); +extern void rfs3_link(LINK3args *, LINK3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_link_getfh(LINK3args *); +extern void rfs3_readdir(READDIR3args *, READDIR3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_readdir_getfh(READDIR3args *); +extern void rfs3_readdir_free(READDIR3res *); +extern void rfs3_readdirplus(READDIRPLUS3args *, READDIRPLUS3res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs3_readdirplus_getfh(READDIRPLUS3args *); +extern void rfs3_readdirplus_free(READDIRPLUS3res *); +extern void rfs3_fsstat(FSSTAT3args *, FSSTAT3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_fsstat_getfh(FSSTAT3args *); +extern void rfs3_fsinfo(FSINFO3args *, FSINFO3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_fsinfo_getfh(FSINFO3args *); +extern void rfs3_pathconf(PATHCONF3args *, PATHCONF3res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *rfs3_pathconf_getfh(PATHCONF3args *); +extern void rfs3_commit(COMMIT3args *, COMMIT3res *, struct exportinfo *, + struct svc_req *, cred_t *, bool_t); +extern void *rfs3_commit_getfh(COMMIT3args *); +extern void rfs3_srvrinit(void); +extern void rfs3_srvrfini(void); +extern void rfs3_srv_zone_init(nfs_globals_t *); +extern void rfs3_srv_zone_fini(nfs_globals_t *); + +extern int nfs3_validate_caches(vnode_t *, cred_t *); +extern void nfs3_cache_post_op_attr(vnode_t *, post_op_attr *, hrtime_t, + cred_t *); +extern void nfs3_cache_post_op_vattr(vnode_t *, post_op_vattr *, hrtime_t, + cred_t *); +extern void nfs3_cache_wcc_data(vnode_t *, wcc_data *, hrtime_t, cred_t *); +extern void nfs3_attrcache(vnode_t *, fattr3 *, hrtime_t); +extern int nfs3_cache_fattr3(vnode_t *, fattr3 *, vattr_t *, hrtime_t, + cred_t *); +extern int nfs3_getattr_otw(vnode_t *, struct vattr *, cred_t *); +extern int nfs3getattr(vnode_t *, struct vattr *, cred_t *); +extern int fattr3_to_vattr(vnode_t *, fattr3 *, struct vattr *); +extern int nfs3tsize(void); +extern uint_t nfs3_tsize(struct knetconfig *); +extern uint_t rfs3_tsize(struct svc_req *); +extern int vattr_to_sattr3(struct vattr *, sattr3 *); +extern void setdiropargs3(diropargs3 *, char *, vnode_t *); +extern enum nfsstat3 puterrno3(int); +extern int geterrno3(enum nfsstat3); +extern int nfs3init(int, char *); +extern void nfs3fini(void); +extern int nfs3_vfsinit(void); +extern void nfs3_vfsfini(void); +extern void vattr_to_post_op_attr(struct vattr *, post_op_attr *); +extern void mblk_to_iov(mblk_t *, int, struct iovec *); +extern int rfs_publicfh_mclookup(char *, vnode_t *, cred_t *, vnode_t **, + struct exportinfo **, struct sec_ol *); +extern int rfs_pathname(char *, vnode_t **, vnode_t **, vnode_t *, + cred_t *, int); +extern int rfs_cross_mnt(vnode_t **, struct exportinfo **); +extern int rfs_climb_crossmnt(vnode_t **, struct exportinfo **, cred_t *); + +extern vtype_t nf3_to_vt[]; +extern vfsops_t *nfs3_vfsops; +extern struct vnodeops *nfs3_vnodeops; +extern const struct fs_operation_def nfs3_vnodeops_template[]; + +/* + * Some servers do not properly update the attributes of the + * directory when changes are made. To allow interoperability + * with these broken servers, the nfs_disable_rddir_cache + * parameter can be used to disable readdir response caching. + */ +extern int nfs_disable_rddir_cache; + +/* + * External functions called by the v2/v3 code into the v4 code + */ +extern void nfs4_clnt_init(void); +extern void nfs4_clnt_fini(void); + +/* + * Does NFS4 server have a vnode delegated? TRUE if so, FALSE if not. + */ +extern bool_t rfs4_check_delegated(int mode, vnode_t *, bool_t trunc); +/* + * VOP_GETATTR call. If a NFS4 delegation is present on the supplied vnode + * call back to the delegated client to get attributes for AT_MTIME and + * AT_SIZE. Invoke VOP_GETATTR to get all other attributes or all attributes + * if no delegation is present. + */ +extern int rfs4_delegated_getattr(vnode_t *, vattr_t *, int, cred_t *); + +extern int do_xattr_exists_check(vnode_t *, ulong_t *, cred_t *); + +extern int protect_zfs_mntpt(vnode_t *); + +extern ts_label_t *nfs_getflabel(vnode_t *, struct exportinfo *); +extern boolean_t do_rfs_label_check(bslabel_t *, vnode_t *, int, + struct exportinfo *); + +/* + * Copy Reduction support. + * xuio_t wrapper with additional private data. + */ + +typedef struct nfs_xuio { + xuio_t nu_uio; + vnode_t *nu_vp; + uint_t nu_ref; + frtn_t nu_frtn; +} nfs_xuio_t; + +extern xuio_t *rfs_setup_xuio(vnode_t *); +extern mblk_t *uio_to_mblk(uio_t *); +extern mblk_t *rfs_read_alloc(uint_t, struct iovec **, int *); +extern void rfs_rndup_mblks(mblk_t *, uint_t, int); +extern void rfs_free_xuio(void *); + +extern time_t nfs_sys_uptime(void); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_NFS_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs4.h b/illumos-x86_64/usr/include/nfs/nfs4.h new file mode 100644 index 00000000..021e5049 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs4.h @@ -0,0 +1,1575 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2018 Nexenta Systems, Inc. + * Copyright 2019 Nexenta by DDN, Inc. + * Copyright 2025 RackTop Systems, Inc. + */ + +#ifndef _NFS4_H +#define _NFS4_H + +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#include +#else +#include +#endif +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NFS4_MAX_SECOID4 65536 +#define NFS4_MAX_UTF8STRING 65536 +#define NFS4_MAX_LINKTEXT4 65536 +#define NFS4_MAX_PATHNAME4 65536 + +struct nfs_fsl_info { + uint_t netbuf_len; + uint_t netnm_len; + uint_t knconf_len; + char *netname; + struct netbuf *addr; + struct knetconfig *knconf; +}; + +#ifdef _KERNEL + +typedef struct nfs4_fhandle { + int fh_len; + char fh_buf[NFS4_FHSIZE]; +} nfs4_fhandle_t; + +typedef uint8_t nfs4_minor_t; + +#define NFS4_MINORVERSION 0 +#define CB4_MINORVERSION 0 + +#define FIRST_NFS4_OP OP_ACCESS +#define LAST_NFS40_OP OP_RELEASE_LOCKOWNER +#define LAST_NFS41_OP OP_RECLAIM_COMPLETE +#define LAST_NFS42_OP OP_CLONE +#define LAST_NFS4_OP LAST_NFS42_OP + +/* + * Set the fattr4_change variable using a time struct. Note that change + * is 64 bits, but timestruc_t is 128 bits in a 64-bit kernel. + */ +#define NFS4_SET_FATTR4_CHANGE(change, ts) \ +{ \ + change = (ts).tv_sec; \ + change <<= 32; \ + change |= (uint32_t)((ts).tv_nsec); \ +} + +/* + * Server lease period. Value is in seconds; Also used for grace period + */ +extern time_t rfs4_lease_time; + +/* + * This set of typedefs and interfaces represent the core or base set + * of functionality that backs the NFSv4 server's state related data + * structures. Since the NFSv4 server needs inter-RPC state to be + * available that is unrelated to the filesystem (in other words, + * soft-state), this functionality is needed to maintain that and is + * written to be somewhat flexible to adapt to the various types of + * data structures contained within the server. + * + * The basic structure at this level is that the server maintains a + * global "database" which consists of a set of tables. Each table + * contains a set of like data structures. Each table is indexed by + * at least one hash function and in most cases two hashes. Each + * table's characteristics is set when it is created at run-time via + * rfs4_table_create(). All table creation and related functions are + * located in nfs4_state.c. The generic database functionality is + * located in nfs4_db.c. + */ + +typedef struct rfs4_dbe rfs4_dbe_t; /* basic opaque db entry */ +typedef struct rfs4_table rfs4_table_t; /* basic table type */ +typedef struct rfs4_index rfs4_index_t; /* index */ +typedef struct rfs4_database rfs4_database_t; /* and database */ + +typedef struct { /* opaque entry type for later use */ + rfs4_dbe_t *dbe; +} *rfs4_entry_t; + +/* + * NFSv4 server state databases + * + * Initialized when the module is loaded and used by NFSv4 state tables. + * These kmem_cache free pools are used globally, the NFSv4 state tables + * which make use of these kmem_cache free pools are per zone. + */ +extern kmem_cache_t *rfs4_client_mem_cache; +extern kmem_cache_t *rfs4_clntIP_mem_cache; +extern kmem_cache_t *rfs4_openown_mem_cache; +extern kmem_cache_t *rfs4_openstID_mem_cache; +extern kmem_cache_t *rfs4_lockstID_mem_cache; +extern kmem_cache_t *rfs4_lockown_mem_cache; +extern kmem_cache_t *rfs4_file_mem_cache; +extern kmem_cache_t *rfs4_delegstID_mem_cache; +extern kmem_cache_t *rfs4_session_mem_cache; + +/* database, table, index creation entry points */ +extern rfs4_database_t *rfs4_database_create(uint32_t); +extern void rfs4_database_shutdown(rfs4_database_t *); +extern void rfs4_database_destroy(rfs4_database_t *); + +extern void rfs4_database_destroy(rfs4_database_t *); + +extern kmem_cache_t *nfs4_init_mem_cache(char *, uint32_t, uint32_t, + uint32_t); +extern rfs4_table_t *rfs4_table_create(rfs4_database_t *, char *, + time_t, uint32_t, + bool_t (*create)(rfs4_entry_t, void *), + void (*destroy)(rfs4_entry_t), + bool_t (*expiry)(rfs4_entry_t), + uint32_t, uint32_t, uint32_t, id_t); +extern void rfs4_table_destroy(rfs4_database_t *, rfs4_table_t *); +extern rfs4_index_t *rfs4_index_create(rfs4_table_t *, char *, + uint32_t (*hash)(void *), + bool_t (compare)(rfs4_entry_t, void *), + void *(*mkkey)(rfs4_entry_t), bool_t); +extern void rfs4_index_destroy(rfs4_index_t *); + +/* Type used to direct rfs4_dbsearch() in what types of records to inspect */ +typedef enum {RFS4_DBS_VALID, RFS4_DBS_INVALID} rfs4_dbsearch_type_t; +/* search and db entry manipulation entry points */ +extern rfs4_entry_t rfs4_dbsearch(rfs4_index_t *, void *, + bool_t *, void *, rfs4_dbsearch_type_t); +extern void rfs4_dbe_lock(rfs4_dbe_t *); +extern void rfs4_dbe_unlock(rfs4_dbe_t *); +extern clock_t rfs4_dbe_twait(rfs4_dbe_t *, clock_t); +extern void rfs4_dbe_cv_broadcast(rfs4_dbe_t *); +extern void rfs4_dbe_hold(rfs4_dbe_t *); +extern void rfs4_dbe_hold_nolock(rfs4_dbe_t *); +extern void rfs4_dbe_rele_nolock(rfs4_dbe_t *); +extern void rfs4_dbe_rele(rfs4_dbe_t *); +extern uint32_t rfs4_dbe_refcnt(rfs4_dbe_t *); +extern id_t rfs4_dbe_getid(rfs4_dbe_t *); +extern void rfs4_dbe_invalidate(rfs4_dbe_t *); +extern bool_t rfs4_dbe_is_invalid(rfs4_dbe_t *); +extern time_t rfs4_dbe_get_timerele(rfs4_dbe_t *); +extern void rfs4_dbe_hide(rfs4_dbe_t *); +extern void rfs4_dbe_unhide(rfs4_dbe_t *); +#ifdef DEBUG +extern bool_t rfs4_dbe_islocked(rfs4_dbe_t *); +#endif +extern void rfs4_dbe_walk(rfs4_table_t *, + void (*callout)(rfs4_entry_t, void *), void *); +extern void rfs4_dbsearch_cb(rfs4_index_t *idx, void *key, + int maxcount, void (*callout)(rfs4_entry_t)); + +/* + * Minimal server stable storage. + * + * Currently the NFSv4 server will only save the client + * ID (the long version) so that it will be able to + * grant possible reclaim requests during the infamous + * grace_period. + */ + +#define RFS4_SS_DIRSIZE 64 * 1024 +#define NFS4_SS_VERSION 1 + +/* handy pathname structure */ +typedef struct ss_pn { + char *leaf; + char pn[MAXPATHLEN]; +} rfs4_ss_pn_t; + +/* + * The server will build this link list on startup. It represents the + * clients that have had valid state on the server in a prior instance. + * + */ +typedef struct rfs4_oldstate { + struct rfs4_oldstate *next; + struct rfs4_oldstate *prev; + rfs4_ss_pn_t *ss_pn; + nfs_client_id4 cl_id4; +} rfs4_oldstate_t; + +/* + * This union is used to overlay the server's internal treatment of + * the protocols stateid4 datatype. Therefore, "bits" must not exceed + * the size of stateid4 and more importantly should match the size of + * stateid4. The chgseq field must the first entry since it overlays + * stateid4.seqid. + */ +typedef union { + stateid4 stateid; + struct { + uint32_t chgseq; /* State changes / protocol's seqid */ + uint32_t boottime; /* boot time */ + uint32_t type:2; /* stateid_type_t as define below */ + uint32_t clnodeid:8; /* cluster server nodeid */ + uint32_t ident:22; /* 2^22-1 openowner x fhs */ + pid_t pid; /* pid of corresponding lock owner */ + } bits; +} stateid_t; +/* + * Note that the way the type field above is defined, this enum must + * not have more than 4 members. + */ +typedef enum {OPENID, LOCKID, DELEGID} stateid_type_t; + +/* + * "wait" struct for use in the open open and lock owner state + * structures to provide serialization between server threads that are + * handling requests for the same open owner or lock stateid. This + * way only one thread will be updating things like sequence ids, + * replay cache and stateid at a time. + */ +typedef struct rfs4_state_wait { + uint32_t sw_active; + uint32_t sw_wait_count; + kmutex_t sw_cv_lock[1]; + kcondvar_t sw_cv[1]; +} rfs4_state_wait_t; + +extern void rfs4_sw_enter(rfs4_state_wait_t *); +extern void rfs4_sw_exit(rfs4_state_wait_t *); + +/* + * This enum and the following rfs4_cbinfo_t struct are used to + * maintain information about the callback path used from the server + * to client for operations like CB_GETATTR and CB_RECALL. The + * rfs4_cbinfo_t struct is meant to be encompassed in the client + * struct and managed within that structure's locking scheme. + * + * The various states of the callback path are used by the server to + * determine if delegations should initially be provided to a client + * and then later on if connectivity has been lost and delegations + * should be revoked. + */ + +/* + * CB_NOCHANGE - Special value used for interfaces within the delegation + * code to signify that "no change" has occurred to the + * callback path + * CB_UNINIT - No callback info provided by the client + * CB_NONE - Callback info provided but CB_NULL call + * has yet to be attempted + * CB_OK - Callback path tested with CB_NULL with success + * CB_INPROG - Callback path currently being tested with CB_NULL + * CB_FAILED - Callback path was == CB_OK but has failed + * with timeout/rpc error + * CB_BAD - Callback info provided but CB_NULL failed + */ +typedef enum { + CB_NOCHANGE = 0, + CB_UNINIT = 1, + CB_NONE = 2, + CB_OK = 3, + CB_INPROG = 4, + CB_FAILED = 5, + CB_BAD = 6 +} rfs4_cbstate_t; + +#define RFS4_CBCH_MAX 10 /* size callback client handle cache */ +/* + * Callback info for a client. + * Client only provides: cb_client4 and cb_ident + * The rest of the information is used to track callback path status + * and usage. + * + * cb_state - used as comments for the rfs4_cbstate_t enum indicate + * cb_notified_of_cb_path_down - if the callback path was once CB_OK and + * has hence CB_FAILED, the client needs to be notified via RENEW. + * cb_timefailed - current time when cb_state transitioned from + * CB_OK -> CB_FAILED. Meant for observability. When did that happen? + * cb_chc_free/cb_chc - cache of client handles for the callback path + * cb_ident - SETCLIENTID provided callback_ident value + * callback - SETCLIENTID provided cb_client4 value + * cb_refcnt - current number of users of this structure's content + * protected by cb_lock + * cb_badbehavior - how many times did a client do something we didn't like? + * cb_lock - lock for contents of cbinfo + * cb_cv - used to allow threads to wait on CB_NULL completion + * cb_nullcaller - is there a thread currently taking care of + * new callback information? + * cb_cv_nullcaller - used by the thread doing CB_NULL to wait on + * threads that may be using client handles of the current + * client handle cache. + * newer - new callback info provided by a client and awaiting + * CB_NULL testing and move to regular cbinfo. + */ +typedef struct { + rfs4_cbstate_t cb_state; + unsigned cb_notified_of_cb_path_down:1; + time_t cb_timefailed; + int cb_chc_free; + CLIENT *cb_chc[RFS4_CBCH_MAX]; + uint32_t cb_ident; + cb_client4 cb_callback; + uint32_t cb_refcnt; + uint32_t cb_badbehavior; + kmutex_t cb_lock[1]; + kcondvar_t cb_cv[1]; + bool_t cb_nullcaller; + kcondvar_t cb_cv_nullcaller[1]; + struct { + bool_t cb_new; + bool_t cb_confirmed; + uint32_t cb_ident; + cb_client4 cb_callback; + } cb_newer; +} rfs4_cbinfo_t; + +/* + * A server instance. We can associate sets of clients - via a pointer in + * rfs4_client_t - with a given server instance, allowing us to treat clients + * in the set differently to clients in other sets. + * + * Currently used only for Sun Cluster HA-NFS support, to group clients + * on NFS resource failover so each set of clients gets its own dedicated + * grace period and distributed stable storage data. + */ +typedef struct rfs4_servinst { + int dss_npaths; + krwlock_t rwlock; + krwlock_t oldstate_lock; + time_t start_time; + time_t grace_period; + uint_t nreclaim; /* number reclaim clients */ + rfs4_oldstate_t *oldstate; + struct rfs4_dss_path **dss_paths; + struct rfs4_servinst *next; + struct rfs4_servinst *prev; +} rfs4_servinst_t; + +/* + * DSS: distributed stable storage + */ + +typedef struct rfs4_dss_path { + struct rfs4_dss_path *next; /* for insque/remque */ + struct rfs4_dss_path *prev; /* for insque/remque */ + char *path; + struct rfs4_servinst *sip; + unsigned index; /* offset in servinst's array */ +} rfs4_dss_path_t; + +/* array of paths passed-in from nfsd command-line; stored in nvlist */ +extern char **rfs4_dss_newpaths; +extern uint_t rfs4_dss_numnewpaths; + +/* nvlists of all DSS paths: current, and before last warmstart */ +extern nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths; + +/* + * The server maintains a set of state on a per client basis that + * matches that of the protocol requirements. A client's state is + * rooted with the rfs4_client_t struct of which there is one per + * client and is created when SETCLIENTID/SETCLIENTID_CONFIRM are + * received. From there, the server then creates rfs4_openowner_t + * structs for each new open owner from that client and are initiated + * at OPEN/OPEN_CONFIRM (when the open owner is new to the server). + * At OPEN, at least two other structures are created, and potentially a + * third. rfs4_state_t is created to track the association between an + * open owner and a particular file. An rfs4_file_t struct may be + * created (if the file is not already open) at OPEN as well. The + * rfs4_file_t struct is the only one that is per server and not per + * client. The rfs4_deleg_state_t struct is created in the + * instance that the server is going to provide a delegation for the + * file being OPENed. Finally, the rfs4_lockowner_t is created at the + * first use of a lock owner at the server and is a result of the LOCK + * operation. The rfs4_lo_state_t struct is then created to represent + * the relation between the lock owner and the file. + * + */ +/* + * The following ascii art represents each of these data structs and + * their references to each other. Note: "<-(x)->" represents the + * doubly link lists (list_t). + * + * ____________________ + * | | + * | rfs4_client_t | + * ->| (1) |<- + * / |____________________| \ + * / ^ \ + * / | \ + * ____________________ ____________________ ____________________ + * | | | | | | + * | rfs4_lockowner_t | | rfs4_openowner_t | | rfs4_deleg_state_t | + * | | | (3) <-(1)-> | | <-(2)-> | + * |____________________| |____________________| |____________________| + * ^ ^ | + * | | V + * ____________________ ____________________ ____________________ + * | | | | | | + * | rfs4_lo_state_t |->| rfs4_state_t |->| rfs4_file_t | + * | <-(4)-> | | (4) <-(3)-> | | (2) | + * |____________________| |____________________| |____________________| + */ +/* + * Each of these data types are kept in a separate rfs4_table_t and is + * actually encapsulated within a rfs4_dbe_t struct. The various + * tables and their construction is done in nfs4_state.c but + * documented here to completeness. + * + * Table Data struct stored Indexed by + * ----- ------------------ ---------- + * rfs4_client_tab rfs4_client_t nfs_client_id4 + * clientid4 + * + * rfs4_openowner_tab rfs4_openowner_t open_owner4 + * + * rfs4_state_tab rfs4_state_t open_owner4 | file + * stateid + * + * rfs4_lo_state_tab rfs4_lo_state_t lockowner | stateid + * lock_stateid + * + * rfs4_lockowner_tab rfs4_lockowner_t lockowner + * pid + * + * rfs4_file_tab rfs4_file_t filehandle + * + * rfs4_deleg_state_tab rfs4_deleg_state_t clientid4 | file + * deleg_stateid + */ + +/* + * The client struct, it is the root of all state for a particular + * client. The client is identified by the nfs_client_id4 via + * SETCLIENTID and the server returns the clientid4 as short hand reference + */ +/* + * Client struct - as mentioned above it is the root of all state for + * a single client as identified by the client supplied nfs_client_id4 + * + * dbe - encapsulation struct + * clientid - server assigned short hand reference to client + * nfs_client - client supplied identifier for itself + * confirm_verf - the value provided to the client for SETCLIENTID_CONFIRM + * need_confirm - does this client need to be SETCLIENTID_CONFIRMed? + * + * unlksys_completed - has an F_UNLKSYS been done for this client which + * says that the use of cleanlocks() on individual files + * is not required? + * can_reclaim - indicates if client is allowed to reclaim after server + * start-up (client had previous state at server) + * ss_remove - indicates that the rfs4_client_destroy function should + * clean up stable storage file. + * forced_expire - set if the sysadmin has used clear_locks for this client. + * no_referrals - set if the client is Solaris and pre-dates referrals + * deleg_revoked - how many delegations have been revoked for this client? + * + * cp_confirmed - this refers to a confirmed client struct that has + * the same nfs_client_id4 as this client struct. When/if this client + * struct is confirmed via SETCLINETID_CONFIRM, the previously + * confirmed client struct will be "closed" and hence this reference. + * + * last_access - used to determine if the client has let its lease expire + * cbinfo - struct containing all callback related information + * cr_set - credentials used for the SETCLIENTID/SETCLIENTID_CONFIRM pair + * sysid - the lock manager sysid allocated for this client's file locks + * openownerlist - root of openowners list associated with this client + * ss_pn - Pathname to the stable storage file. + * cl_addr - Clients network address. + * server_instance - pointer to the currently associated server instance + */ +typedef struct rfs4_client { + rfs4_dbe_t *rc_dbe; + clientid4 rc_clientid; + nfs_client_id4 rc_nfs_client; + verifier4 rc_confirm_verf; + unsigned rc_need_confirm:1; + unsigned rc_unlksys_completed:1; + unsigned rc_can_reclaim:1; + unsigned rc_ss_remove:1; + unsigned rc_forced_expire:1; + unsigned rc_reclaim_completed:1; + uint_t rc_deleg_revoked; + struct rfs4_client *rc_cp_confirmed; + time_t rc_last_access; + rfs4_cbinfo_t rc_cbinfo; + cred_set_t rc_cr_set; + sysid_t rc_sysidt; + list_t rc_openownerlist; + rfs4_ss_pn_t *rc_ss_pn; + struct sockaddr_storage rc_addr; + rfs4_servinst_t *rc_server_instance; + + /* nfsv4.1 */ + rfs41_csr_t rc_contrived; + rfs41_sprot_t rc_state_prot; + list_t rc_sessions; + unsigned rc_destroying:1; /* flag: going to destroy */ +} rfs4_client_t; + +/* + * ClntIP struct - holds the diagnosis about whether the client + * cannot support referrals. Set to true for old Solaris clients. + */ + +typedef struct rfs4_clntip { + rfs4_dbe_t *ri_dbe; + struct sockaddr_storage ri_addr; + unsigned ri_no_referrals:1; +} rfs4_clntip_t; + +/* + * The openowner contains the client supplied open_owner4 as well as + * the matching sequence id and is used to track the client's usage of + * the open_owner4. Note that a reply is saved here as well for + * processing of retransmissions. + * + * dbe - encapsulation struct + * client - reference to rfs4_client_t for this openowner + * owner - actual client supplied open_owner4 + * need_confirm - does this openowner need to be OPEN_CONFIRMed + * postpone_confirm - set if error received on first use of open_owner + * state2confirm - what stateid4 should be used on the OPEN_CONFIRM + * open_seqid - what is the next open_seqid expected for this openowner + * oo_sw - used to serialize access to the open seqid/reply handling + * statelist - root of state struct list associated with this openowner + * node - node for client struct list of openowners + * reply_fh - open replay processing needs the filehandle so that it is + * able to reset the current filehandle for appropriate compound + * processing and reply. + * reply - last reply sent in relation to this openowner + */ +typedef struct rfs4_openowner { + rfs4_dbe_t *ro_dbe; + rfs4_client_t *ro_client; + open_owner4 ro_owner; + unsigned ro_need_confirm:1; + unsigned ro_postpone_confirm:1; + seqid4 ro_open_seqid; + rfs4_state_wait_t ro_sw; + list_t ro_statelist; + list_node_t ro_node; + nfs_fh4 ro_reply_fh; + nfs_resop4 ro_reply; +} rfs4_openowner_t; + +/* + * This state struct represents the association between an openowner + * and a file that has been OPENed by that openowner. + * + * dbe - encapsulation struct + * stateid - server provided stateid + * owner - reference back to the openowner for this state + * finfo - reference to the open file for this state + * open_access - how did the openowner OPEN the file (access) + * open_deny - how did the openowner OPEN the file (deny) + * share_access - what share reservation is on the file (access) + * share_deny - what share reservation is on the file (deny) + * closed - has this file been closed? + * lostatelist - root of list of lo_state associated with this state/file + * node - node for state struct list of states + */ +typedef struct rfs4_state { + rfs4_dbe_t *rs_dbe; + stateid_t rs_stateid; + rfs4_openowner_t *rs_owner; + struct rfs4_file *rs_finfo; + uint32_t rs_open_access; + uint32_t rs_open_deny; + uint32_t rs_share_access; + uint32_t rs_share_deny; + unsigned rs_closed:1; + list_t rs_lostatelist; + list_node_t rs_node; +} rfs4_state_t; + +/* + * Lockowner - track the lockowner and its related info + * + * dbe - encapsulation struct + * client - reference to the client + * owner - lockowner supplied by the client + * pid - local identifier used for file locking + */ +typedef struct rfs4_lockowner { + rfs4_dbe_t *rl_dbe; + rfs4_client_t *rl_client; + lock_owner4 rl_owner; + pid_t rl_pid; +} rfs4_lockowner_t; + +/* + * Lockowner_state associated with a state struct and lockowner + * + * dbe - encapsulation struct + * state - reference back to state struct for open file + * lockid - stateid for this lockowner/state + * locker - reference to lockowner + * seqid - sequence id for this lockowner/state + * skip_seqid_check - used on initialization of struct + * locks_cleaned - have all locks been released for this lockowner/file? + * lock_completed - successful LOCK with lockowner/file? + * ls_sw - used to serialize update seqid/reply/stateid handling + * node - node for state struct list of lo_states + * reply - last reply sent in relation to this lockowner/state + */ +typedef struct rfs4_lo_state { + rfs4_dbe_t *rls_dbe; + rfs4_state_t *rls_state; + stateid_t rls_lockid; + rfs4_lockowner_t *rls_locker; + seqid4 rls_seqid; + unsigned rls_skip_seqid_check:1; + unsigned rls_locks_cleaned:1; + unsigned rls_lock_completed:1; + rfs4_state_wait_t rls_sw; + list_node_t rls_node; + nfs_resop4 rls_reply; +} rfs4_lo_state_t; + +/* + * Delegation state - per client + * + * dbe - encapsulation struct + * dtype - type of delegation (NONE, READ, WRITE) + * delegid - stateid for this delegation + * time_granted - time this delegation was assigned to client + * time_recalled - time when the server started recall process + * time_revoked - if revoked, time that the revoke occurred + * finfo - reference to the file associated with this delegation + * client - reference to client for which this delegation is associated + * node - list of delegations for the file (WRITE == 1, READ == ) + */ +typedef struct rfs4_deleg_state { + rfs4_dbe_t *rds_dbe; + open_delegation_type4 rds_dtype; + stateid_t rds_delegid; + time_t rds_time_granted; + time_t rds_time_recalled; + time_t rds_time_revoked; + struct rfs4_file *rds_finfo; + rfs4_client_t *rds_client; + list_node_t rds_node; +} rfs4_deleg_state_t; + +/* + * Delegation info associated with the file + * + * dtype - type of delegation for file (NONE, READ, WRITE) + * time_returned - time that last delegation was returned for file + * time_recalled - time that recall sequence started + * time_lastgrant - time that last delegation was provided to a client + * time_lastwrite - time of last write to use the delegation stateid + * time_rm_delayed - time of last remove/rename which was DELAYed + * rdgrants - how many read delegations have been provided for this file + * wrgrants - how many write delegations provided (can only be one) + * recall_count - how many recall threads are outstanding + * recall_lock - lock to protect contents of this struct + * recall_cv - condition var for the "parent" thread to wait upon + * deleg_change_grant - value for change attribute at time of write grant + * deleg_change - most recent value of change obtained from client + * deleg_change_ts - time of last deleg_change update + * ever_recalled - has this particular delegation ever been recalled? + * dont_grant - file deletion is impending, don't grant a delegation + * conflicted_client - clientid of the client that caused a CB_RECALL + * to occur. This is used for delegation policy (should a delegation + * be granted shortly after it has been returned?) + */ +typedef struct rfs4_dinfo { + open_delegation_type4 rd_dtype; + time_t rd_time_returned; + time_t rd_time_recalled; + time_t rd_time_lastgrant; + time_t rd_time_lastwrite; + time_t rd_time_rm_delayed; + uint32_t rd_rdgrants; + uint32_t rd_wrgrants; + int32_t rd_recall_count; + kmutex_t rd_recall_lock[1]; + kcondvar_t rd_recall_cv[1]; + bool_t rd_ever_recalled; + uint32_t rd_hold_grant; + clientid4 rd_conflicted_client; +} rfs4_dinfo_t; + +/* + * File + * + * dbe - encapsulation struct + * vp - vnode for the file that is open or has a delegation + * filehandle - the filehandle generated by the server for this file + * delegstatelist - root of delegation list for this file + * dinfo - see struct definition above + * share_deny - union of all deny modes on file + * share_access - union of all access modes on file + * access_read - count of read access + * access_write - count of write access + * deny_read - count of deny reads + * deny_write - count of deny writes + * file_rwlock - lock for serializing the removal of a file while + * the state structures are active within the server + * + * The only requirement for locking file_rwlock is that the + * caller have a reference to the containing rfs4_file. The dbe + * lock may or may not be held for lock/unlock of file_rwlock. + * As mentioned above, the file_rwlock is used for serialization + * of file removal and more specifically reference to the held + * vnode (e.g. vp). + */ +typedef struct rfs4_file { + rfs4_dbe_t *rf_dbe; + vnode_t *rf_vp; + nfs_fh4 rf_filehandle; + list_t rf_delegstatelist; + rfs4_dinfo_t rf_dinfo; + uint32_t rf_share_deny; + uint32_t rf_share_access; + uint32_t rf_access_read; + uint32_t rf_access_write; + uint32_t rf_deny_read; + uint32_t rf_deny_write; + krwlock_t rf_file_rwlock; +} rfs4_file_t; + +/* + * nfs4_deleg_policy is used to signify the server's global delegation + * policy. The default is to NEVER delegate files and the + * administrator must configure the server to enable delegations. + * + * The disable/enable delegation functions are used to eliminate a + * race with exclusive creates. + */ +typedef enum { + SRV_NEVER_DELEGATE = 0, + SRV_NORMAL_DELEGATE = 1 +} srv_deleg_policy_t; + +extern void rfs4_disable_delegation(void), rfs4_enable_delegation(void); + +/* + * Request types for delegation. These correspond with + * open_delegation_type4 with the addition of a new value, DELEG_ANY, + * to reqequest any delegation. + */ +typedef enum { + DELEG_NONE = 0, /* Corresponds to OPEN_DELEG_NONE */ + DELEG_READ = 1, /* Corresponds to OPEN_DELEG_READ */ + DELEG_WRITE = 2, /* Corresponds to OPEN_DELEG_WRITE */ + DELEG_ANY = -1 /* New value to request any delegation type */ +} delegreq_t; + +#define NFS4_DELEG4TYPE2REQTYPE(x) (delegreq_t)(x) + +/* + * Zone global variables of NFSv4 server + */ +typedef struct nfs4_srv { + /* Unique write verifier */ + verifier4 write4verf; + /* Delegation lock */ + kmutex_t deleg_lock; + /* Used to serialize create/destroy of nfs4_server_state database */ + kmutex_t state_lock; + rfs4_database_t *nfs4_server_state; + /* Used to manage access to server instance linked list */ + kmutex_t servinst_lock; + rfs4_servinst_t *nfs4_cur_servinst; + /* Used to manage access to nfs4_deleg_policy */ + krwlock_t deleg_policy_lock; + srv_deleg_policy_t nfs4_deleg_policy; + /* Allowed minors, nfs4 minors start from 0, which is always allowed */ + nfs4_minor_t nfs4_minor_max; + /* Set first time we see one */ + int seen_first_compound; + /* + * Circular double-linked list of paths for currently-served RGs. + * No locking required -- only changed on server start. + * Managed with insque/remque. + */ + rfs4_dss_path_t *dss_pathlist; + /* Duplicate request cache */ + struct rfs4_drc *nfs4_drc; + /* nfsv4 server start time */ + time_t rfs4_start_time; + /* Used to serialize lookups of clientids */ + krwlock_t rfs4_findclient_lock; + + /* NFSv4 server state client tables */ + /* table expiry times */ + time_t rfs4_client_cache_time; + time_t rfs4_openowner_cache_time; + time_t rfs4_state_cache_time; + time_t rfs4_lo_state_cache_time; + time_t rfs4_lockowner_cache_time; + time_t rfs4_file_cache_time; + time_t rfs4_deleg_state_cache_time; + time_t rfs4_clntip_cache_time; + /* tables and indexes */ + /* client table */ + rfs4_table_t *rfs4_client_tab; + rfs4_index_t *rfs4_clientid_idx; + rfs4_index_t *rfs4_nfsclnt_idx; + /* client IP table */ + rfs4_table_t *rfs4_clntip_tab; + rfs4_index_t *rfs4_clntip_idx; + /* Open Owner table */ + rfs4_table_t *rfs4_openowner_tab; + rfs4_index_t *rfs4_openowner_idx; + /* Open State ID table */ + rfs4_table_t *rfs4_state_tab; + rfs4_index_t *rfs4_state_idx; + rfs4_index_t *rfs4_state_owner_file_idx; + rfs4_index_t *rfs4_state_file_idx; + /* Lock State ID table */ + rfs4_table_t *rfs4_lo_state_tab; + rfs4_index_t *rfs4_lo_state_idx; + rfs4_index_t *rfs4_lo_state_owner_idx; + /* Lock owner table */ + rfs4_table_t *rfs4_lockowner_tab; + rfs4_index_t *rfs4_lockowner_idx; + rfs4_index_t *rfs4_lockowner_pid_idx; + /* File table */ + rfs4_table_t *rfs4_file_tab; + rfs4_index_t *rfs4_file_idx; + /* Deleg State table */ + rfs4_table_t *rfs4_deleg_state_tab; + rfs4_index_t *rfs4_deleg_idx; + rfs4_index_t *rfs4_deleg_state_idx; + + /* nfs4.x */ + rfs4_table_t *rfs4_session_tab; + rfs4_index_t *rfs4_session_idx; + + /* client stable storage */ + int rfs4_ss_enabled; +} nfs4_srv_t; + +/* + * max length of the NFSv4 server database name + */ +#define RFS4_MAX_MEM_CACHE_NAME 48 + +/* + * global NFSv4 server kmem caches + * r_db_name - The name of the state database and the table that will use it + * These tables are defined in nfs4_srv_t + * r_db_mem_cache - The kmem cache associated with the state database name + */ +typedef struct rfs4_db_mem_cache { + char r_db_name[RFS4_MAX_MEM_CACHE_NAME]; + kmem_cache_t *r_db_mem_cache; +} rfs4_db_mem_cache_t; + +#define RFS4_DB_MEM_CACHE_NUM 9 + +extern rfs4_db_mem_cache_t rfs4_db_mem_cache_table[RFS4_DB_MEM_CACHE_NUM]; + +extern srv_deleg_policy_t nfs4_get_deleg_policy(); + +extern void rfs4_servinst_create(nfs4_srv_t *, int, int, char **); +extern void rfs4_servinst_destroy_all(nfs4_srv_t *); +extern void rfs4_servinst_assign(nfs4_srv_t *, rfs4_client_t *, + rfs4_servinst_t *); +extern rfs4_servinst_t *rfs4_servinst(rfs4_client_t *); +extern int rfs4_clnt_in_grace(rfs4_client_t *); +extern int rfs4_servinst_in_grace(rfs4_servinst_t *); +extern int rfs4_servinst_grace_new(rfs4_servinst_t *); +extern void rfs4_grace_start(rfs4_servinst_t *); +extern void rfs4_grace_start_new(nfs4_srv_t *); +extern void rfs4_grace_reset_all(nfs4_srv_t *); +extern void rfs4_dss_readstate(nfs4_srv_t *, int, char **); + +/* + * Various interfaces to manipulate the state structures introduced + * above + */ +extern void rfs4_free_reply(nfs_resop4 *); +extern void rfs4_copy_reply(nfs_resop4 *, nfs_resop4 *); + +/* rfs4_client_t handling */ +extern rfs4_client_t *rfs4_findclient(nfs_client_id4 *, + bool_t *, rfs4_client_t *); +extern rfs4_client_t *rfs4_findclient_by_id(clientid4, bool_t); +extern rfs4_client_t *rfs4_findclient_by_addr(struct sockaddr *); +extern void rfs4_client_rele(rfs4_client_t *); +extern void rfs4_client_close(rfs4_client_t *); +extern void rfs4_client_state_remove(rfs4_client_t *); +extern void rfs4_client_scv_next(rfs4_client_t *); +extern void rfs4_update_lease(rfs4_client_t *); +extern bool_t rfs4_lease_expired(rfs4_client_t *); +extern nfsstat4 rfs4_check_clientid(clientid4 *, int); + +/* rfs4_clntip_t handling */ +extern rfs4_clntip_t *rfs4_find_clntip(struct sockaddr *, bool_t *); +extern void rfs4_invalidate_clntip(struct sockaddr *); + +/* rfs4_openowner_t handling */ +extern rfs4_openowner_t *rfs4_findopenowner(open_owner4 *, bool_t *, seqid4); +extern void rfs4_update_open_sequence(rfs4_openowner_t *); +extern void rfs4_update_open_resp(rfs4_openowner_t *, + nfs_resop4 *, nfs_fh4 *); +extern void rfs4_openowner_rele(rfs4_openowner_t *); +extern void rfs4_free_opens(rfs4_openowner_t *, bool_t, bool_t); + +/* rfs4_lockowner_t handling */ +extern rfs4_lockowner_t *rfs4_findlockowner(lock_owner4 *, bool_t *); +extern rfs4_lockowner_t *rfs4_findlockowner_by_pid(pid_t); +extern void rfs4_lockowner_rele(rfs4_lockowner_t *); + +/* rfs4_state_t handling */ +extern rfs4_state_t *rfs4_findstate_by_owner_file(rfs4_openowner_t *, + rfs4_file_t *, bool_t *); +extern void rfs4_state_rele(rfs4_state_t *); +extern void rfs4_state_close(rfs4_state_t *, bool_t, + bool_t, cred_t *); +extern void rfs4_release_share_lock_state(rfs4_state_t *, + cred_t *, bool_t); +extern void rfs4_close_all_state(rfs4_file_t *); + +/* rfs4_lo_state_t handling */ +extern rfs4_lo_state_t *rfs4_findlo_state_by_owner(rfs4_lockowner_t *, + rfs4_state_t *, bool_t *); +extern void rfs4_lo_state_rele(rfs4_lo_state_t *, bool_t); +extern void rfs4_update_lock_sequence(rfs4_lo_state_t *); +extern void rfs4_update_lock_resp(rfs4_lo_state_t *, + nfs_resop4 *); + +/* rfs4_file_t handling */ +extern rfs4_file_t *rfs4_findfile(vnode_t *, nfs_fh4 *, bool_t *); +extern rfs4_file_t *rfs4_findfile_withlock(vnode_t *, nfs_fh4 *, + bool_t *); +extern void rfs4_file_rele(rfs4_file_t *); + +/* General collection of "get state" functions */ +extern nfsstat4 rfs4_get_state(stateid4 *, rfs4_state_t **, + rfs4_dbsearch_type_t); +extern nfsstat4 rfs4_get_state_nolock(stateid4 *, rfs4_state_t **, + rfs4_dbsearch_type_t); +extern void rfs4_state_rele_nounlock(rfs4_state_t *); + +extern nfsstat4 rfs4_get_deleg_state(stateid4 *, + rfs4_deleg_state_t **); +extern nfsstat4 rfs4_get_lo_state(stateid4 *, rfs4_lo_state_t **, + bool_t); +struct compound_state; +extern nfsstat4 rfs4_check_stateid(int, vnode_t *, stateid4 *, + bool_t, bool_t *, bool_t, + caller_context_t *, + struct compound_state *); +extern int rfs4_check_stateid_seqid(rfs4_state_t *, stateid4 *, + const struct compound_state *); +extern int rfs4_check_lo_stateid_seqid(rfs4_lo_state_t *, + stateid4 *, + const struct compound_state *); + +/* return values for rfs4_check_stateid_seqid() */ +#define NFS4_CHECK_STATEID_OKAY 1 +#define NFS4_CHECK_STATEID_OLD 2 +#define NFS4_CHECK_STATEID_BAD 3 +#define NFS4_CHECK_STATEID_EXPIRED 4 +#define NFS4_CHECK_STATEID_REPLAY 5 +#define NFS4_CHECK_STATEID_CLOSED 6 +#define NFS4_CHECK_STATEID_UNCONFIRMED 7 + +/* delay() time that server is willing to briefly wait for a delegreturn */ +#define NFS4_DELEGATION_CONFLICT_DELAY (hz/10) + +/* + * Interfaces for handling of callback's client handle cache and + * callback interfaces themselves. + */ +extern void rfs4_cbinfo_free(rfs4_cbinfo_t *); +extern void rfs4_client_setcb(rfs4_client_t *, cb_client4 *, + uint32_t); +extern void rfs4_deleg_cb_check(rfs4_client_t *); +extern nfsstat4 rfs4_vop_getattr(vnode_t *, vattr_t *, int, cred_t *); + +/* rfs4_deleg_state_t handling and other delegation interfaces */ +extern rfs4_deleg_state_t *rfs4_finddeleg(rfs4_state_t *, bool_t *); +extern rfs4_deleg_state_t *rfs4_finddelegstate(stateid_t *); +extern bool_t rfs4_check_recall(rfs4_state_t *, uint32_t); +extern void rfs4_recall_deleg(rfs4_file_t *, + bool_t, rfs4_client_t *); +extern int rfs4_get_deleg(rfs4_state_t *, open_delegation_type4, + open_delegation_type4 (*policy)(rfs4_state_t *, + open_delegation_type4 dtype)); +extern rfs4_deleg_state_t *rfs4_grant_delegation(delegreq_t, rfs4_state_t *, + int *); +extern void rfs4_set_deleg_response(rfs4_deleg_state_t *, + open_delegation4 *, nfsace4 *, int); +extern void rfs4_return_deleg(rfs4_deleg_state_t *, bool_t); +extern bool_t rfs4_is_deleg(rfs4_state_t *); +extern void rfs4_deleg_state_rele(rfs4_deleg_state_t *); +extern bool_t rfs4_check_delegated_byfp(int, rfs4_file_t *, + bool_t, bool_t, bool_t, clientid4 *); +extern void rfs4_clear_dont_grant(rfs4_file_t *); + +/* + * nfs4 monitored operations. + */ +extern int deleg_rd_open(femarg_t *, int, cred_t *, caller_context_t *); +extern int deleg_wr_open(femarg_t *, int, cred_t *, caller_context_t *); +extern int deleg_wr_read(femarg_t *, uio_t *, int, cred_t *, + caller_context_t *); +extern int deleg_rd_write(femarg_t *, uio_t *, int, cred_t *, + caller_context_t *); +extern int deleg_wr_write(femarg_t *, uio_t *, int, cred_t *, + caller_context_t *); +extern int deleg_rd_setattr(femarg_t *, vattr_t *, int, cred_t *, + caller_context_t *); +extern int deleg_wr_setattr(femarg_t *, vattr_t *, int, cred_t *, + caller_context_t *); +extern int deleg_rd_rwlock(femarg_t *, int, caller_context_t *); +extern int deleg_wr_rwlock(femarg_t *, int, caller_context_t *); +extern int deleg_rd_space(femarg_t *, int, flock64_t *, int, offset_t, cred_t *, + caller_context_t *); +extern int deleg_wr_space(femarg_t *, int, flock64_t *, int, offset_t, cred_t *, + caller_context_t *); +extern int deleg_rd_setsecattr(femarg_t *, vsecattr_t *, int, cred_t *, + caller_context_t *); +extern int deleg_wr_setsecattr(femarg_t *, vsecattr_t *, int, cred_t *, + caller_context_t *); +extern int deleg_rd_vnevent(femarg_t *, vnevent_t, vnode_t *, char *, + caller_context_t *); +extern int deleg_wr_vnevent(femarg_t *, vnevent_t, vnode_t *, char *, + caller_context_t *); + +extern void rfs4_mon_hold(void *); +extern void rfs4_mon_rele(void *); + +extern fem_t *deleg_rdops; +extern fem_t *deleg_wrops; + +extern int rfs4_share(rfs4_state_t *, uint32_t, uint32_t); +extern int rfs4_unshare(rfs4_state_t *); +extern void rfs4_set_deleg_policy(nfs4_srv_t *, srv_deleg_policy_t); +extern void rfs4_hold_deleg_policy(nfs4_srv_t *); +extern void rfs4_rele_deleg_policy(nfs4_srv_t *); + +#ifdef DEBUG +#define NFS4_DEBUG(var, args) if (var) cmn_err args + +extern int rfs4_debug; +extern int nfs4_client_attr_debug; +extern int nfs4_client_state_debug; +extern int nfs4_client_shadow_debug; +extern int nfs4_client_lock_debug; +extern int nfs4_client_lease_debug; +extern int nfs4_seqid_sync; +extern int nfs4_client_map_debug; +extern int nfs4_client_inactive_debug; +extern int nfs4_client_recov_debug; +extern int nfs4_client_failover_debug; +extern int nfs4_client_call_debug; +extern int nfs4_client_foo_debug; +extern int nfs4_client_zone_debug; +extern int nfs4_lost_rqst_debug; +extern int nfs4_open_stream_debug; +extern int nfs4_client_open_dg; +extern int nfs4_srvmnt_debug; +extern int nfs4_utf8_debug; + +void rfs4_dbe_debug(rfs4_dbe_t *e); + +#ifdef NFS4_DEBUG_MUTEX +void nfs4_debug_mutex_enter(kmutex_t *, char *, int); +void nfs4_debug_mutex_exit(kmutex_t *, char *, int); + +#define mutex_enter(m) nfs4_debug_mutex_enter((m), __FILE__, __LINE__) +#define mutex_exit(m) nfs4_debug_mutex_exit((m), __FILE__, __LINE__) +#endif /* NFS4_DEBUG_MUTEX */ + +#else /* ! DEBUG */ +#define NFS4_DEBUG(var, args) +#endif /* DEBUG */ + +/* + * XXX - temporary for testing of volatile fh + */ + +#ifdef VOLATILE_FH_TEST + +struct nfs_fh4_fmt { + fhandle4_t fh4_i; + uint32_t fh4_flag; + uint32_t fh4_volatile_id; +}; + +#else /* VOLATILE_FH_TEST */ + +struct nfs_fh4_fmt { + fhandle4_t fh4_i; + uint32_t fh4_flag; +}; + +#endif /* VOLATILE_FH_TEST */ + +#define FH4_NAMEDATTR 1 +#define FH4_ATTRDIR 2 + +#define fh4_fsid fh4_i.fhx_fsid +#define fh4_len fh4_i.fhx_len /* fid length */ +#define fh4_data fh4_i.fhx_data /* fid bytes */ +#define fh4_xlen fh4_i.fhx_xlen +#define fh4_xdata fh4_i.fhx_xdata +typedef struct nfs_fh4_fmt nfs_fh4_fmt_t; + +#define fh4_to_fmt4(fh4p) ((nfs_fh4_fmt_t *)(fh4p)->nfs_fh4_val) +#define get_fh4_flag(fh4p, flag) ((fh4_to_fmt4(fh4p)->fh4_flag) & (flag)) +#define set_fh4_flag(fh4p, flag) ((fh4_to_fmt4(fh4p)->fh4_flag) |= (flag)) +#define clr_fh4_flag(fh4p, flag) ((fh4_to_fmt4(fh4p)->fh4_flag) &= ~(flag)) + +#define NFS_FH4_LEN sizeof (nfs_fh4_fmt_t) + +/* + * Copy fields from external (fhandle_t) to in-memory (nfs_fh4_fmt_t) + * format to support export info checking. It does not copy over + * the complete filehandle, just the fsid, xlen and xdata. It may + * need to be changed to be used in other places. + * + * NOTE: The macro expects the space to be pre-allocated for + * the contents of nfs_fh4_fmt_t. + */ +#define FH_TO_FMT4(exifh, nfs_fmt) { \ + bzero((nfs_fmt), NFS_FH4_LEN); \ + (nfs_fmt)->fh4_fsid = (exifh)->fh_fsid; \ + (nfs_fmt)->fh4_xlen = (exifh)->fh_xlen; \ + bcopy((exifh)->fh_xdata, (nfs_fmt)->fh4_xdata, \ + (exifh)->fh_xlen); \ +} + +/* + * A few definitions of repeatedly used constructs for nfsv4 + */ +#define UTF8STRING_FREE(str) { \ + kmem_free((str).utf8string_val, (str).utf8string_len); \ + (str).utf8string_val = NULL; \ + (str).utf8string_len = 0; \ +} + +/* + * NFS4_VOLATILE_FH yields non-zero if the filesystem uses non-persistent + * filehandles. + */ +#define NFS4_VOLATILE_FH(mi) \ + ((mi)->mi_fh_expire_type & \ + (FH4_VOLATILE_ANY | FH4_VOL_MIGRATION | FH4_VOL_RENAME)) + +/* + * NFS_IS_DOTNAME checks if the name given represents a dot or dotdot entry + */ +#define NFS_IS_DOTNAME(name) \ + (((name)[0] == '.') && \ + (((name)[1] == '\0') || (((name)[1] == '.') && ((name)[2] == '\0')))) + +/* + * Define the number of bits in a bitmap word (uint32) + */ +#define NFS4_BITMAP4_BITSPERWORD (sizeof (uint32_t) * 8) + +/* + * Define the value for the access field of the compound_state structure + * based on the result of nfsauth access checking. + */ +#define CS_ACCESS_OK 0x1 +#define CS_ACCESS_DENIED 0x2 +#define CS_ACCESS_LIMITED 0x4 + +/* + * compound state in nfsv4 server + */ +struct compound_state { + struct exportinfo *exi; + struct exportinfo *saved_exi; /* export struct for saved_vp */ + cred_t *basecr; /* UNIX cred: only RPC request */ + caddr_t principal; + int nfsflavor; + cred_t *cr; /* UNIX cred: RPC request and */ + /* target export */ + bool_t cont; + uint_t access; /* access perm on vp per request */ + bool_t deleg; /* TRUE if current fh has */ + /* write delegated */ + vnode_t *vp; /* modified by PUTFH, and by ops that */ + /* input to GETFH */ + bool_t mandlock; /* Is mandatory locking in effect */ + /* for vp */ + vnode_t *saved_vp; /* modified by SAVEFH, copied to */ + /* vp by RESTOREFH */ + nfsstat4 *statusp; + nfs_fh4 fh; /* ditto. valid only if vp != NULL */ + nfs_fh4 saved_fh; /* ditto. valid only if */ + /* saved_vp != NULL */ + struct svc_req *req; + char fhbuf[NFS4_FHSIZE]; + + /* NFSv4.1 */ + uint8_t minorversion; /* NFS4 minor version */ + rfs4_session_t *sp; /* OP_SEQUENCE set it */ + slotid4 slotno; + rfs4_slot_t *slot; + rfs4_client_t *client; + uint16_t op_pos; + uint16_t op_len; /* number operations in compound req */ +#define RFS4_DISPATCH_DONE (1 << 0) +#define RFS4_CURRENT_STATEID (1 << 1) +#define RFS4_SAVED_STATEID (1 << 2) + uint8_t cs_flags; + bool_t cachethis; + COMPOUND4res *cmpresp; + stateid4 current_stateid; + stateid4 save_stateid; +}; + +typedef struct compound_state compound_state_t; + +static inline bool_t +rfs4_has_session(const compound_state_t *cs) +{ + return (cs->slot != NULL); +} + +extern stateid4 invalid_stateid; + +#define INVALID_STATEID(x) (!memcmp((x), &invalid_stateid, sizeof (stateid4)) + +/* + * Conversion commands for nfsv4 server attr checking + */ +enum nfs4_attr_cmd { + NFS4ATTR_SUPPORTED = 0, /* check which attrs supported */ + NFS4ATTR_GETIT = 1, /* getattr - sys to fattr4 (r) */ + NFS4ATTR_SETIT = 2, /* setattr - fattr4 to sys (w) */ + NFS4ATTR_VERIT = 3, /* verify - fattr4 to sys (r) */ + NFS4ATTR_FREEIT = 4 /* free any alloc'd space for attr */ +}; + +typedef enum nfs4_attr_cmd nfs4_attr_cmd_t; + +struct nfs4_svgetit_arg { + nfs4_attr_cmd_t op; /* getit or setit */ + struct compound_state *cs; + struct statvfs64 *sbp; + uint_t flag; /* VOP_GETATTR/VOP_SETATTR flag */ + uint_t xattr; /* object is xattr */ + bool_t rdattr_error_req; /* if readdir & client wants */ + /* rdattr_error */ + nfsstat4 rdattr_error; /* used for per-entry status */ + /* (if rdattr_err) */ + bool_t is_referral; /* because sometimes we tell lies */ + bool_t mntdfid_set; + + fattr4_mounted_on_fileid + mounted_on_fileid; + /* readdir op can always return */ + /* d_ino from server fs dirent */ + /* for mounted_on_fileid attr. */ + /* This field holds d_ino so */ + /* srv attr conv code can avoid */ + /* doing an untraverse. */ + vattr_t vap[1]; +}; + +struct nfs4_ntov_map { + bitmap4 fbit; /* FATTR4_XXX_MASKY */ + uint_t vbit; /* AT_XXX */ + bool_t vfsstat; + bool_t mandatory; /* attribute mandatory to implement? */ + uint_t nval; + int xdr_size; /* Size of XDR'd attr */ + xdrproc_t xfunc; + int (*sv_getit)(nfs4_attr_cmd_t, struct nfs4_svgetit_arg *, + union nfs4_attr_u *); /* subroutine for getting attr. */ + char *prtstr; /* string attr for printing */ +}; + +struct nfs4attr_to_vattr { + vnode_t *vp; + vattr_t *vap; + nfs_fh4 *fhp; + nfsstat4 rdattr_error; + uint32_t flag; + fattr4_change change; + fattr4_fsid srv_fsid; + fattr4_mounted_on_fileid mntd_fid; +}; + +typedef struct nfs4attr_to_vattr ntov4_t; + +/* + * nfs4attr_to_vattr flags + */ +#define NTOV_FHP_VALID 0x01 +#define NTOV_RDATTR_ERROR_VALID 0x02 +#define NTOV_CHANGE_VALID 0x04 +#define NTOV_SUPP_VALID 0x08 +#define NTOV_SRV_FSID_VALID 0x10 +#define NTOV_MOUNTED_ON_FILEID_VALID 0x20 + + +#define FATTR4_MANDATTR_MASK ( \ + FATTR4_SUPPORTED_ATTRS_MASK | \ + FATTR4_TYPE_MASK | \ + FATTR4_FH_EXPIRE_TYPE_MASK | \ + FATTR4_CHANGE_MASK | \ + FATTR4_SIZE_MASK | \ + FATTR4_LINK_SUPPORT_MASK | \ + FATTR4_SYMLINK_SUPPORT_MASK | \ + FATTR4_NAMED_ATTR_MASK | \ + FATTR4_FSID_MASK | \ + FATTR4_UNIQUE_HANDLES_MASK | \ + FATTR4_LEASE_TIME_MASK | \ + FATTR4_RDATTR_ERROR_MASK | \ + FATTR4_FILEHANDLE_MASK) + + +struct nfs4attr_to_osattr { + void *attrconv_arg; + uint_t mask; +}; + +struct mntinfo4; + +/* + * lkp4_attr_setup lists the different options for attributes when calling + * nfs4lookup_setup - either no attributes (just lookups - e.g., secinfo), + * one component only (normal component lookup), get attributes for the + * last component (e.g., mount), attributes for each component (e.g., + * failovers later), just the filehandle for the last component (e.g., + * volatile filehandle recovery), or stuff that needs OPENATTR (e.g. + * looking up a named attribute or it's hidden directory). + */ +enum lkp4_attr_setup { + LKP4_NO_ATTRIBUTES = 0, /* no attrs or filehandles */ + LKP4_ALL_ATTRIBUTES = 3, /* multi-comp: attrs for all comps */ + LKP4_LAST_NAMED_ATTR = 5, /* multi-comp: named attr & attrdir */ + LKP4_LAST_ATTRDIR = 6, /* multi-comp: just attrdir */ + LKP4_ALL_ATTR_SECINFO = 7 /* multi-comp: attrs for all comp and */ + /* secinfo for last comp */ +}; + +/* + * lookup4_param a set of parameters to nfs4lookup_setup - + * used to setup a path lookup compound request. + */ +typedef struct lookup4_param { + enum lkp4_attr_setup l4_getattrs; /* (in) get attrs in the lookup? */ + int header_len; /* (in) num ops before first lookup */ + int trailer_len; /* (in) num ops after last */ + /* Lookup/Getattr */ + bitmap4 ga_bits; /* (in) Which attributes for Getattr */ + COMPOUND4args_clnt *argsp; /* (in/out) args for compound struct */ + COMPOUND4res_clnt *resp; /* (in/out) res for compound struct */ + int arglen; /* (out) argop buffer alloc'd length */ + struct mntinfo4 *mi; +} lookup4_param_t; + + +#define NFS4_FATTR4_FINISH -1 /* fattr4 index indicating finish */ + +typedef int (*nfs4attr_to_os_t)(int, union nfs4_attr_u *, + struct nfs4attr_to_osattr *); + +/* + * The nfs4_error_t is the basic structure to return error values + * from rfs4call. It encapsulates the unix errno + * value, the nfsstat4 value and the rpc status value into a single + * structure. + * + * If error is set, then stat is ignored and rpc_status may be + * set if the error occurred as the result of a CLNT_CALL. If + * stat is set, then rpc request succeeded, error and + * rpc_status are set to 0 and stat contains the result of + * operation, NFS4_OK or one of the NFS4ERR_* values. + * + * Functions which want to generate errors independently from + * rfs4call should set error to the desired errno value and + * set stat and rpc_status to 0. nfs4_error_init() is a + * convenient function to do this. + */ +typedef struct { + int error; + nfsstat4 stat; + enum clnt_stat rpc_status; +} nfs4_error_t; + +/* + * Shared functions + */ +extern void rfs4_op_readdir(nfs_argop4 *, nfs_resop4 *, + struct svc_req *, struct compound_state *); +extern void nfs_fh4_copy(nfs_fh4 *, nfs_fh4 *); + +extern void nfs4_fattr4_free(fattr4 *); + +extern int nfs4lookup_setup(char *, lookup4_param_t *, int); +extern void nfs4_getattr_otw_norecovery(vnode_t *, + nfs4_ga_res_t *, nfs4_error_t *, cred_t *, int); +extern int nfs4_getattr_otw(vnode_t *, nfs4_ga_res_t *, cred_t *, int); +extern int nfs4cmpfh(const nfs_fh4 *, const nfs_fh4 *); +extern int nfs4cmpfhandle(nfs4_fhandle_t *, nfs4_fhandle_t *); +extern int nfs4getattr(vnode_t *, struct vattr *, cred_t *); +extern int nfs4_waitfor_purge_complete(vnode_t *); +extern int nfs4_validate_caches(vnode_t *, cred_t *); +extern int nfs4init(int, char *); +extern void nfs4fini(void); +extern int nfs4_vfsinit(void); +extern void nfs4_vfsfini(void); + +extern void nfs4_vnops_init(void); +extern void nfs4_vnops_fini(void); +extern void nfs_idmap_init(void); +extern void nfs_idmap_flush(int); +extern void nfs_idmap_fini(void); +extern int nfs4_rnode_init(void); +extern int nfs4_rnode_fini(void); +extern int nfs4_shadow_init(void); +extern int nfs4_shadow_fini(void); +extern int nfs4_acache_init(void); +extern int nfs4_acache_fini(void); +extern int nfs4_subr_init(void); +extern int nfs4_subr_fini(void); +extern void nfs4_acl_init(void); +extern void nfs4_acl_free_cache(vsecattr_t *); + +extern int geterrno4(nfsstat4); +extern nfsstat4 puterrno4(int); +extern int nfs4_need_to_bump_seqid(COMPOUND4res_clnt *); +extern int nfs4tsize(void); +extern int checkauth4(struct compound_state *, struct svc_req *); +extern nfsstat4 call_checkauth4(struct compound_state *, struct svc_req *); +extern int is_exported_sec(int, struct exportinfo *); +extern void nfs4_vmask_to_nmask(uint_t, bitmap4 *); +extern void nfs4_vmask_to_nmask_set(uint_t, bitmap4 *); +extern int nfs_idmap_str_uid(utf8string *u8s, uid_t *, bool_t); +extern int nfs_idmap_str_gid(utf8string *u8s, gid_t *, bool_t); +extern int nfs_idmap_uid_str(uid_t, utf8string *u8s, bool_t); +extern int nfs_idmap_gid_str(gid_t gid, utf8string *u8s, bool_t); +extern int nfs4_time_ntov(nfstime4 *, timestruc_t *); +extern int nfs4_time_vton(timestruc_t *, nfstime4 *); +extern char *utf8_to_str(utf8string *, uint_t *, char *); +extern char *utf8_to_fn(utf8string *, uint_t *, char *); +extern utf8string *str_to_utf8(char *, utf8string *); +extern utf8string *utf8_copy(utf8string *, utf8string *); +extern int utf8_compare(const utf8string *, const utf8string *); +extern nfsstat4 utf8_dir_verify(utf8string *); +extern char *utf8_strchr(utf8string *, const char); +extern int ln_ace4_cmp(nfsace4 *, nfsace4 *, int); +extern int vs_aent_to_ace4(vsecattr_t *, vsecattr_t *, int, int); +extern int vs_ace4_to_aent(vsecattr_t *, vsecattr_t *, uid_t, gid_t, + int, int); +extern int vs_ace4_to_acet(vsecattr_t *, vsecattr_t *, uid_t, gid_t, + int); +extern int vs_acet_to_ace4(vsecattr_t *, vsecattr_t *, int); +extern void vs_acet_destroy(vsecattr_t *); +extern void vs_ace4_destroy(vsecattr_t *); +extern void vs_aent_destroy(vsecattr_t *); + +extern int vn_find_nfs_record(vnode_t *, nvlist_t **, char **, char **); +extern int vn_is_nfs_reparse(vnode_t *, cred_t *); +extern fs_locations4 *fetch_referral(vnode_t *, cred_t *); +extern char *build_symlink(vnode_t *, cred_t *, size_t *); + +extern int stateid4_cmp(stateid4 *, stateid4 *); + +extern vtype_t nf4_to_vt[]; + +extern struct nfs4_ntov_map nfs4_ntov_map[]; +extern uint_t nfs4_ntov_map_size; + +extern struct vfsops *nfs4_vfsops; +extern struct vnodeops *nfs4_vnodeops; +extern const struct fs_operation_def nfs4_vnodeops_template[]; +extern vnodeops_t *nfs4_trigger_vnodeops; +extern const struct fs_operation_def nfs4_trigger_vnodeops_template[]; + +extern uint_t nfs4_tsize(struct knetconfig *); +extern uint_t rfs4_tsize(struct svc_req *); + +extern bool_t xdr_inline_decode_nfs_fh4(uint32_t *, nfs_fh4_fmt_t *, + uint32_t); +extern bool_t xdr_inline_encode_nfs_fh4(uint32_t **, uint32_t *, + nfs_fh4_fmt_t *); + +#ifdef DEBUG +extern int rfs4_do_pre_op_attr; +extern int rfs4_do_post_op_attr; +#endif + +extern stateid4 clnt_special0; +extern stateid4 clnt_special1; +#define CLNT_ISSPECIAL(id) (stateid4_cmp(id, &clnt_special0) || \ + stateid4_cmp(id, &clnt_special1)) + +/* State's functions */ +extern void rfs4_ss_clid(nfs4_srv_t *nsrv4, rfs4_client_t *); +extern void rfs4_ss_chkclid(nfs4_srv_t *nsrv4, rfs4_client_t *); + +/* Declarations for nfs4.x */ +nfsstat4 do_rfs4_op_secinfo(struct compound_state *, char *, SECINFO4res *); + +/* + * The NFS Version 4 service procedures. + */ + +extern void rfs4_do_server_start(int, int, nfs4_minor_t, int); +extern void rfs4_compound(COMPOUND4args *, COMPOUND4res *, + compound_state_t *, struct svc_req *, int *); +extern void rfs4_init_compound_state(struct compound_state *); +extern void rfs4_fini_compound_state(struct compound_state *); + +struct rpcdisp; +extern int rfs4_dispatch(struct rpcdisp *, struct svc_req *, SVCXPRT *, char *); +extern void rfs4_compound_free(COMPOUND4res *); +extern bool_t rfs4_idempotent_req(const COMPOUND4args *); + +extern void rfs4_srvrinit(void); +extern void rfs4_srvrfini(void); +extern void rfs4_srv_zone_init(nfs_globals_t *); +extern void rfs4_srv_zone_fini(nfs_globals_t *); +extern void rfs4_state_g_init(void); +extern void rfs4_state_zone_init(nfs4_srv_t *); +extern void rfs4_state_g_fini(void); +extern void rfs4_state_zone_fini(void); +extern nfs4_srv_t *nfs4_get_srv(void); + +void put_stateid4(struct compound_state *, stateid4 *); +void get_stateid4(struct compound_state *, stateid4 *); + +#endif +#ifdef __cplusplus +} +#endif + +#endif /* _NFS4_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs4_attr.h b/illumos-x86_64/usr/include/nfs/nfs4_attr.h new file mode 100644 index 00000000..95dd97d9 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs4_attr.h @@ -0,0 +1,461 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NFS4_ATTR_H +#define _NFS4_ATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define FATTR4_WORD0 32 +#define FATTR4_WORD1 0 + +/* + * Attributes + */ +#define FATTR4_SUPPORTED_ATTRS_MASK (1ULL << (FATTR4_WORD0 + 0)) +#define FATTR4_TYPE_MASK (1ULL << (FATTR4_WORD0 + 1)) +#define FATTR4_FH_EXPIRE_TYPE_MASK (1ULL << (FATTR4_WORD0 + 2)) +#define FATTR4_CHANGE_MASK (1ULL << (FATTR4_WORD0 + 3)) +#define FATTR4_SIZE_MASK (1ULL << (FATTR4_WORD0 + 4)) +#define FATTR4_LINK_SUPPORT_MASK (1ULL << (FATTR4_WORD0 + 5)) +#define FATTR4_SYMLINK_SUPPORT_MASK (1ULL << (FATTR4_WORD0 + 6)) +#define FATTR4_NAMED_ATTR_MASK (1ULL << (FATTR4_WORD0 + 7)) +#define FATTR4_FSID_MASK (1ULL << (FATTR4_WORD0 + 8)) +#define FATTR4_UNIQUE_HANDLES_MASK (1ULL << (FATTR4_WORD0 + 9)) +#define FATTR4_LEASE_TIME_MASK (1ULL << (FATTR4_WORD0 + 10)) +#define FATTR4_RDATTR_ERROR_MASK (1ULL << (FATTR4_WORD0 + 11)) +#define FATTR4_ACL_MASK (1ULL << (FATTR4_WORD0 + 12)) +#define FATTR4_ACLSUPPORT_MASK (1ULL << (FATTR4_WORD0 + 13)) +#define FATTR4_ARCHIVE_MASK (1ULL << (FATTR4_WORD0 + 14)) +#define FATTR4_CANSETTIME_MASK (1ULL << (FATTR4_WORD0 + 15)) +#define FATTR4_CASE_INSENSITIVE_MASK (1ULL << (FATTR4_WORD0 + 16)) +#define FATTR4_CASE_PRESERVING_MASK (1ULL << (FATTR4_WORD0 + 17)) +#define FATTR4_CHOWN_RESTRICTED_MASK (1ULL << (FATTR4_WORD0 + 18)) +#define FATTR4_FILEHANDLE_MASK (1ULL << (FATTR4_WORD0 + 19)) +#define FATTR4_FILEID_MASK (1ULL << (FATTR4_WORD0 + 20)) +#define FATTR4_FILES_AVAIL_MASK (1ULL << (FATTR4_WORD0 + 21)) +#define FATTR4_FILES_FREE_MASK (1ULL << (FATTR4_WORD0 + 22)) +#define FATTR4_FILES_TOTAL_MASK (1ULL << (FATTR4_WORD0 + 23)) +#define FATTR4_FS_LOCATIONS_MASK (1ULL << (FATTR4_WORD0 + 24)) +#define FATTR4_HIDDEN_MASK (1ULL << (FATTR4_WORD0 + 25)) +#define FATTR4_HOMOGENEOUS_MASK (1ULL << (FATTR4_WORD0 + 26)) +#define FATTR4_MAXFILESIZE_MASK (1ULL << (FATTR4_WORD0 + 27)) +#define FATTR4_MAXLINK_MASK (1ULL << (FATTR4_WORD0 + 28)) +#define FATTR4_MAXNAME_MASK (1ULL << (FATTR4_WORD0 + 29)) +#define FATTR4_MAXREAD_MASK (1ULL << (FATTR4_WORD0 + 30)) +#define FATTR4_MAXWRITE_MASK (1ULL << (FATTR4_WORD0 + 31)) + +#define FATTR4_MIMETYPE_MASK (1ULL << (FATTR4_WORD1 + 0)) +#define FATTR4_MODE_MASK (1ULL << (FATTR4_WORD1 + 1)) +#define FATTR4_NO_TRUNC_MASK (1ULL << (FATTR4_WORD1 + 2)) +#define FATTR4_NUMLINKS_MASK (1ULL << (FATTR4_WORD1 + 3)) +#define FATTR4_OWNER_MASK (1ULL << (FATTR4_WORD1 + 4)) +#define FATTR4_OWNER_GROUP_MASK (1ULL << (FATTR4_WORD1 + 5)) +#define FATTR4_QUOTA_AVAIL_HARD_MASK (1ULL << (FATTR4_WORD1 + 6)) +#define FATTR4_QUOTA_AVAIL_SOFT_MASK (1ULL << (FATTR4_WORD1 + 7)) +#define FATTR4_QUOTA_USED_MASK (1ULL << (FATTR4_WORD1 + 8)) +#define FATTR4_RAWDEV_MASK (1ULL << (FATTR4_WORD1 + 9)) +#define FATTR4_SPACE_AVAIL_MASK (1ULL << (FATTR4_WORD1 + 10)) +#define FATTR4_SPACE_FREE_MASK (1ULL << (FATTR4_WORD1 + 11)) +#define FATTR4_SPACE_TOTAL_MASK (1ULL << (FATTR4_WORD1 + 12)) +#define FATTR4_SPACE_USED_MASK (1ULL << (FATTR4_WORD1 + 13)) +#define FATTR4_SYSTEM_MASK (1ULL << (FATTR4_WORD1 + 14)) +#define FATTR4_TIME_ACCESS_MASK (1ULL << (FATTR4_WORD1 + 15)) +#define FATTR4_TIME_ACCESS_SET_MASK (1ULL << (FATTR4_WORD1 + 16)) +#define FATTR4_TIME_BACKUP_MASK (1ULL << (FATTR4_WORD1 + 17)) +#define FATTR4_TIME_CREATE_MASK (1ULL << (FATTR4_WORD1 + 18)) +#define FATTR4_TIME_DELTA_MASK (1ULL << (FATTR4_WORD1 + 19)) +#define FATTR4_TIME_METADATA_MASK (1ULL << (FATTR4_WORD1 + 20)) +#define FATTR4_TIME_MODIFY_MASK (1ULL << (FATTR4_WORD1 + 21)) +#define FATTR4_TIME_MODIFY_SET_MASK (1ULL << (FATTR4_WORD1 + 22)) +#define FATTR4_MOUNTED_ON_FILEID_MASK (1ULL << (FATTR4_WORD1 + 23)) + +/* nfsv4.1 */ + +/* Overload to fit to 64-bits bitmap4 */ +#define FATTR4_SUPPATTR_EXCLCREAT_MASK_LOCAL (1ULL << (FATTR4_WORD1 + 24)) +#define FATTR4_SEC_LABEL_MASK_LOCAL (1ULL << (FATTR4_WORD1 + 25)) + +/* + * Common bitmap4 of file attributes to be gathered + */ +#define NFS4_NTOV_ATTR_MASK ( \ + FATTR4_TYPE_MASK | \ + FATTR4_CHANGE_MASK | \ + FATTR4_SIZE_MASK | \ + FATTR4_FSID_MASK | \ + FATTR4_FILEID_MASK | \ + FATTR4_MODE_MASK | \ + FATTR4_OWNER_MASK | \ + FATTR4_OWNER_GROUP_MASK | \ + FATTR4_NUMLINKS_MASK | \ + FATTR4_TIME_ACCESS_MASK | \ + FATTR4_TIME_MODIFY_MASK | \ + FATTR4_TIME_METADATA_MASK | \ + FATTR4_RAWDEV_MASK | \ + FATTR4_SPACE_USED_MASK | \ + FATTR4_MOUNTED_ON_FILEID_MASK) + +#define NFS4_VATTR_MASK ( \ + FATTR4_TYPE_MASK | \ + FATTR4_CHANGE_MASK | \ + FATTR4_SIZE_MASK | \ + FATTR4_FSID_MASK | \ + FATTR4_FILEID_MASK | \ + FATTR4_MODE_MASK | \ + FATTR4_OWNER_MASK | \ + FATTR4_OWNER_GROUP_MASK | \ + FATTR4_NUMLINKS_MASK | \ + FATTR4_TIME_ACCESS_MASK | \ + FATTR4_TIME_MODIFY_MASK | \ + FATTR4_TIME_METADATA_MASK | \ + FATTR4_RAWDEV_MASK | \ + FATTR4_SPACE_USED_MASK | \ + FATTR4_MOUNTED_ON_FILEID_MASK) + +#define NFS4_PATHCONF_MASK ( \ + NFS4_VATTR_MASK | \ + FATTR4_NO_TRUNC_MASK | \ + FATTR4_CHOWN_RESTRICTED_MASK | \ + FATTR4_CASE_INSENSITIVE_MASK | \ + FATTR4_CASE_PRESERVING_MASK | \ + FATTR4_NAMED_ATTR_MASK | \ + FATTR4_LINK_SUPPORT_MASK | \ + FATTR4_SYMLINK_SUPPORT_MASK | \ + FATTR4_UNIQUE_HANDLES_MASK | \ + FATTR4_CANSETTIME_MASK | \ + FATTR4_HOMOGENEOUS_MASK | \ + FATTR4_MAXLINK_MASK | \ + FATTR4_MAXNAME_MASK | \ + FATTR4_MAXFILESIZE_MASK) + +/* + * The corresponding AT_MASK + */ +#define NFS4_NTOV_ATTR_AT_MASK ( \ + AT_TYPE | \ + AT_SIZE | \ + AT_FSID | \ + AT_NODEID | \ + AT_MODE | \ + AT_UID | \ + AT_GID | \ + AT_NLINK | \ + AT_ATIME | \ + AT_MTIME | \ + AT_CTIME | \ + AT_RDEV | \ + AT_NBLOCKS) + +/* + * Common bitmap4 of filesystem attributes to be gathered + */ +#define NFS4_FS_ATTR_MASK ( \ + FATTR4_FILES_AVAIL_MASK | \ + FATTR4_FILES_FREE_MASK | \ + FATTR4_FILES_TOTAL_MASK | \ + FATTR4_SPACE_AVAIL_MASK | \ + FATTR4_SPACE_FREE_MASK | \ + FATTR4_SPACE_TOTAL_MASK) + +#define NFS4_STATFS_ATTR_MASK ( \ + FATTR4_FILES_AVAIL_MASK | \ + FATTR4_FILES_FREE_MASK | \ + FATTR4_FILES_TOTAL_MASK | \ + FATTR4_SPACE_AVAIL_MASK | \ + FATTR4_SPACE_FREE_MASK | \ + FATTR4_SPACE_TOTAL_MASK | \ + FATTR4_MAXNAME_MASK) + +/* + * The corresponding AT_MASK + */ +#define NFS4_FS_ATTR_AT_MASK 0 + +/* + * Common bitmap4 to gather attr cache state + */ +#define NFS4_NTOV_ATTR_CACHE_MASK ( \ + FATTR4_TIME_METADATA_MASK | \ + FATTR4_TIME_MODIFY_MASK | \ + FATTR4_SIZE_MASK) + +/* + * The corresponding AT_MASK + */ +#define NFS4_NTOV_ATTR_CACHE_AT_MASK ( \ + AT_CTIME | \ + AT_MTIME | \ + AT_SIZE) + +#define NFS4_VTON_ATTR_MASK ( \ + AT_TYPE | \ + AT_MODE | \ + AT_UID | \ + AT_GID | \ + AT_NODEID | \ + AT_SIZE | \ + AT_NLINK | \ + AT_ATIME | \ + AT_MTIME | \ + AT_CTIME | \ + AT_RDEV | \ + AT_NBLOCKS | \ + AT_FSID) + +#define NFS4_VTON_ATTR_MASK_SET ( \ + AT_MODE | \ + AT_UID | \ + AT_GID | \ + AT_SIZE | \ + AT_ATIME | \ + AT_MTIME) + +/* solaris-supported, non-vattr_t per-vnode scoped attrs */ +#define NFS4_VP_ATTR_MASK ( \ + FATTR4_CHANGE_MASK | \ + FATTR4_CHOWN_RESTRICTED_MASK | \ + FATTR4_FILEHANDLE_MASK | \ + FATTR4_MAXFILESIZE_MASK | \ + FATTR4_MAXLINK_MASK | \ + FATTR4_MAXNAME_MASK | \ + FATTR4_MOUNTED_ON_FILEID_MASK) + +#define FATTR4_FSINFO_MASK ( \ + FATTR4_SUPPORTED_ATTRS_MASK | \ + FATTR4_TYPE_MASK | \ + FATTR4_FH_EXPIRE_TYPE_MASK | \ + FATTR4_LINK_SUPPORT_MASK | \ + FATTR4_SYMLINK_SUPPORT_MASK | \ + FATTR4_FSID_MASK | \ + FATTR4_MAXFILESIZE_MASK | \ + FATTR4_MAXREAD_MASK | \ + FATTR4_MAXWRITE_MASK) + +/* + * These are the support attributes for the NFSv4 server + */ +#define NFS4_SRV_RDDIR_SUPPORTED_ATTRS ( \ + FATTR4_SUPPORTED_ATTRS_MASK | \ + FATTR4_TYPE_MASK | \ + FATTR4_FH_EXPIRE_TYPE_MASK | \ + FATTR4_CHANGE_MASK | \ + FATTR4_SIZE_MASK | \ + FATTR4_LINK_SUPPORT_MASK | \ + FATTR4_SYMLINK_SUPPORT_MASK | \ + FATTR4_NAMED_ATTR_MASK | \ + FATTR4_FSID_MASK | \ + FATTR4_UNIQUE_HANDLES_MASK | \ + FATTR4_LEASE_TIME_MASK | \ + FATTR4_RDATTR_ERROR_MASK | \ + FATTR4_CANSETTIME_MASK | \ + FATTR4_CASE_INSENSITIVE_MASK | \ + FATTR4_CASE_PRESERVING_MASK | \ + FATTR4_CHOWN_RESTRICTED_MASK | \ + FATTR4_FILEHANDLE_MASK | \ + FATTR4_FILEID_MASK | \ + FATTR4_FILES_AVAIL_MASK | \ + FATTR4_FILES_FREE_MASK | \ + FATTR4_FILES_TOTAL_MASK | \ + FATTR4_FS_LOCATIONS_MASK | \ + FATTR4_HOMOGENEOUS_MASK | \ + FATTR4_MAXFILESIZE_MASK | \ + FATTR4_MAXLINK_MASK | \ + FATTR4_MAXNAME_MASK | \ + FATTR4_MAXREAD_MASK | \ + FATTR4_MAXWRITE_MASK | \ + FATTR4_MODE_MASK | \ + FATTR4_NO_TRUNC_MASK | \ + FATTR4_NUMLINKS_MASK | \ + FATTR4_OWNER_MASK | \ + FATTR4_OWNER_GROUP_MASK | \ + FATTR4_RAWDEV_MASK | \ + FATTR4_SPACE_AVAIL_MASK | \ + FATTR4_SPACE_FREE_MASK | \ + FATTR4_SPACE_TOTAL_MASK | \ + FATTR4_SPACE_USED_MASK | \ + FATTR4_TIME_ACCESS_MASK | \ + FATTR4_TIME_DELTA_MASK | \ + FATTR4_TIME_METADATA_MASK | \ + FATTR4_TIME_MODIFY_MASK | \ + FATTR4_MOUNTED_ON_FILEID_MASK \ +) + +/* nfsv4.1 */ +#define RFS4_SUPPATTR_EXCLCREAT ( \ + FATTR4_SIZE_MASK | \ + FATTR4_MODE_MASK | \ + FATTR4_ACL_MASK | \ + FATTR4_OWNER_MASK | \ + FATTR4_OWNER_GROUP_MASK | \ + FATTR4_TIME_ACCESS_SET_MASK) + +#define FATTR4_FSID_EQ(a, b) \ + ((a)->major == (b)->major && (a)->minor == (b)->minor) + +#define NFS4_MAXNUM_BITWORDS 2 +#define NFS4_MAXNUM_ATTRS 57 + +union nfs4_attr_u { + fattr4_supported_attrs supported_attrs; + fattr4_type type; + fattr4_fh_expire_type fh_expire_type; + fattr4_change change; + fattr4_size size; + fattr4_link_support link_support; + fattr4_symlink_support symlink_support; + fattr4_named_attr named_attr; + fattr4_fsid fsid; + fattr4_unique_handles unique_handles; + fattr4_lease_time lease_time; + fattr4_rdattr_error rdattr_error; + fattr4_acl acl; + fattr4_aclsupport aclsupport; + fattr4_archive archive; + fattr4_cansettime cansettime; + fattr4_case_insensitive case_insensitive; + fattr4_case_preserving case_preserving; + fattr4_chown_restricted chown_restricted; + fattr4_fileid fileid; + fattr4_files_avail files_avail; + fattr4_filehandle filehandle; + fattr4_files_free files_free; + fattr4_files_total files_total; + fattr4_fs_locations fs_locations; + fattr4_hidden hidden; + fattr4_homogeneous homogeneous; + fattr4_maxfilesize maxfilesize; + fattr4_maxlink maxlink; + fattr4_maxname maxname; + fattr4_maxread maxread; + fattr4_maxwrite maxwrite; + fattr4_mimetype mimetype; + fattr4_mode mode; + fattr4_no_trunc no_trunc; + fattr4_numlinks numlinks; + fattr4_owner owner; + fattr4_owner_group owner_group; + fattr4_quota_avail_hard quota_avail_hard; + fattr4_quota_avail_soft quota_avail_soft; + fattr4_quota_used quota_used; + fattr4_rawdev rawdev; + fattr4_space_avail space_avail; + fattr4_space_free space_free; + fattr4_space_total space_total; + fattr4_space_used space_used; + fattr4_system system; + fattr4_time_access time_access; + fattr4_time_access_set time_access_set; + fattr4_time_backup time_backup; + fattr4_time_create time_create; + fattr4_time_delta time_delta; + fattr4_time_metadata time_metadata; + fattr4_time_modify time_modify; + fattr4_time_modify_set time_modify_set; + fattr4_mounted_on_fileid mounted_on_fileid; + fattr4_suppattr_exclcreat supp_exclcreat; +}; + +/* + * Error details when processing the getattr response. + */ +#define NFS4_GETATTR_OP_OK 0 +#define NFS4_GETATTR_STATUS_ERR 1 +#define NFS4_GETATTR_MANDATTR_ERR 2 +#define NFS4_GETATTR_BITMAP_ERR 3 +#define NFS4_GETATTR_ATSIZE_ERR 4 +#define NFS4_GETATTR_ATUID_ERR 5 +#define NFS4_GETATTR_ATGID_ERR 6 +#define NFS4_GETATTR_ATATIME_ERR 7 +#define NFS4_GETATTR_ATMTIME_ERR 8 +#define NFS4_GETATTR_ATCTIME_ERR 9 +#define NFS4_GETATTR_RAWDEV_ERR 10 +#define NFS4_GETATTR_ATNBLOCK_ERR 11 +#define NFS4_GETATTR_MAXFILESIZE_ERR 12 +#define NFS4_GETATTR_FHANDLE_ERR 13 +#define NFS4_GETATTR_MAXREAD_ERR 14 +#define NFS4_GETATTR_MAXWRITE_ERR 15 +#define NFS4_GETATTR_NOCACHE_OK 16 + +typedef struct nfs4_pathconf_info { + unsigned pc4_cache_valid:1; /* When in rnode4, is data valid? */ + unsigned pc4_no_trunc:1; + unsigned pc4_chown_restricted:1; + unsigned pc4_case_insensitive:1; + unsigned pc4_case_preserving:1; + unsigned pc4_xattr_valid:1; + unsigned pc4_xattr_exists:1; + unsigned pc4_link_support:1; + unsigned pc4_symlink_support:1; + unsigned pc4_unique_handles:1; + unsigned pc4_cansettime:1; + unsigned pc4_homogeneous:1; + uint_t pc4_link_max; + uint_t pc4_name_max; + uint_t pc4_filesizebits; +} nfs4_pathconf_info_t; + +/* + * Used for client only to process incoming getattr results. + */ +typedef struct nfs4_ga_ext_res { + bitmap4 n4g_suppattrs; + nfsstat4 n4g_rdattr_error; + fattr4_fh_expire_type n4g_fet; + fattr4_lease_time n4g_leasetime; + uint64_t n4g_maxfilesize; + uint64_t n4g_maxread; + uint64_t n4g_maxwrite; + nfstime4 n4g_delta; + nfs4_pathconf_info_t n4g_pc4; + struct statvfs64 n4g_sb; + union { + nfs_fh4 n4g_fh; + struct { + uint_t len; + char *val; + char data[NFS4_FHSIZE]; + } nfs_fh4_alt; + } n4g_fh_u; + /* + * Bitmask with valid fields being: + * ACL4_SUPPORT_ALLOW_ACL + * ACL4_SUPPORT_DENY_ACL + * ACL4_SUPPORT_AUDIT_ACL + * ACL4_SUPPORT_ALARM_ACL + */ + fattr4_aclsupport n4g_aclsupport; + fattr4_fs_locations n4g_fslocations; +} nfs4_ga_ext_res_t; + +extern bitmap4 rfs4_supported_attrs; + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS4_ATTR_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs4_clnt.h b/illumos-x86_64/usr/include/nfs/nfs4_clnt.h new file mode 100644 index 00000000..68c810f7 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs4_clnt.h @@ -0,0 +1,2240 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _NFS4_CLNT_H +#define _NFS4_CLNT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NFS4_SIZE_OK(size) ((size) <= MAXOFFSET_T) + +/* Four states of nfs4_server's lease_valid */ +#define NFS4_LEASE_INVALID 0 +#define NFS4_LEASE_VALID 1 +#define NFS4_LEASE_UNINITIALIZED 2 +#define NFS4_LEASE_NOT_STARTED 3 + +/* flag to tell the renew thread it should exit */ +#define NFS4_THREAD_EXIT 1 + +/* Default number of seconds to wait on GRACE and DELAY errors */ +#define NFS4ERR_DELAY_TIME 10 + +/* Number of hash buckets for open owners for each nfs4_server */ +#define NFS4_NUM_OO_BUCKETS 53 + +/* Number of freed open owners (per mntinfo4_t) to keep around */ +#define NFS4_NUM_FREED_OPEN_OWNERS 8 + +/* Number of seconds to wait before retrying a SETCLIENTID(_CONFIRM) op */ +#define NFS4_RETRY_SCLID_DELAY 10 + +/* Number of times we should retry a SETCLIENTID(_CONFIRM) op */ +#define NFS4_NUM_SCLID_RETRIES 3 + +/* Number of times we should retry on open after getting NFS4ERR_BAD_SEQID */ +#define NFS4_NUM_RETRY_BAD_SEQID 3 + +/* + * Macro to wakeup sleeping async worker threads. + */ +#define NFS4_WAKE_ASYNC_WORKER(work_cv) { \ + if (CV_HAS_WAITERS(&work_cv[NFS4_ASYNC_QUEUE])) \ + cv_signal(&work_cv[NFS4_ASYNC_QUEUE]); \ + else if (CV_HAS_WAITERS(&work_cv[NFS4_ASYNC_PGOPS_QUEUE])) \ + cv_signal(&work_cv[NFS4_ASYNC_PGOPS_QUEUE]); \ +} + +#define NFS4_WAKEALL_ASYNC_WORKERS(work_cv) { \ + cv_broadcast(&work_cv[NFS4_ASYNC_QUEUE]); \ + cv_broadcast(&work_cv[NFS4_ASYNC_PGOPS_QUEUE]); \ +} + +/* + * Is the attribute cache valid? If client holds a delegation, then attrs + * are by definition valid. If not, then check to see if attrs have timed out. + */ +#define ATTRCACHE4_VALID(vp) (VTOR4(vp)->r_deleg_type != OPEN_DELEGATE_NONE || \ + gethrtime() < VTOR4(vp)->r_time_attr_inval) + +/* + * Flags to indicate whether to purge the DNLC for non-directory vnodes + * in a call to nfs_purge_caches. + */ +#define NFS4_NOPURGE_DNLC 0 +#define NFS4_PURGE_DNLC 1 + +/* + * Is cache valid? + * Swap is always valid, if no attributes (attrtime == 0) or + * if mtime matches cached mtime it is valid + * NOTE: mtime is now a timestruc_t. + * Caller should be holding the rnode r_statelock mutex. + */ +#define CACHE4_VALID(rp, mtime, fsize) \ + ((RTOV4(rp)->v_flag & VISSWAP) == VISSWAP || \ + (((mtime).tv_sec == (rp)->r_attr.va_mtime.tv_sec && \ + (mtime).tv_nsec == (rp)->r_attr.va_mtime.tv_nsec) && \ + ((fsize) == (rp)->r_attr.va_size))) + +/* + * Macro to detect forced unmount or a zone shutdown. + */ +#define FS_OR_ZONE_GONE4(vfsp) \ + (((vfsp)->vfs_flag & VFS_UNMOUNTED) || \ + zone_status_get(curproc->p_zone) >= ZONE_IS_SHUTTING_DOWN) + +/* + * Macro to help determine whether a request failed because the underlying + * filesystem has been forcibly unmounted or because of zone shutdown. + */ +#define NFS4_FRC_UNMT_ERR(err, vfsp) \ + ((err) == EIO && FS_OR_ZONE_GONE4((vfsp))) + +/* + * Due to the way the address space callbacks are used to execute a delmap, + * we must keep track of how many times the same thread has called + * VOP_DELMAP()->nfs4_delmap(). This is done by having a list of + * nfs4_delmapcall_t's associated with each rnode4_t. This list is protected + * by the rnode4_t's r_statelock. The individual elements do not need to be + * protected as they will only ever be created, modified and destroyed by + * one thread (the call_id). + * See nfs4_delmap() for further explanation. + */ +typedef struct nfs4_delmapcall { + kthread_t *call_id; + int error; /* error from delmap */ + list_node_t call_node; +} nfs4_delmapcall_t; + +/* + * delmap address space callback args + */ +typedef struct nfs4_delmap_args { + vnode_t *vp; + offset_t off; + caddr_t addr; + size_t len; + uint_t prot; + uint_t maxprot; + uint_t flags; + cred_t *cr; + nfs4_delmapcall_t *caller; /* to retrieve errors from the cb */ +} nfs4_delmap_args_t; + +/* + * client side statistics + */ +/* + * Per-zone counters + */ +struct clstat4 { + kstat_named_t calls; /* client requests */ + kstat_named_t badcalls; /* rpc failures */ + kstat_named_t referrals; /* referrals */ + kstat_named_t referlinks; /* referrals as symlinks */ + kstat_named_t clgets; /* client handle gets */ + kstat_named_t cltoomany; /* client handle cache misses */ +#ifdef DEBUG + kstat_named_t clalloc; /* number of client handles */ + kstat_named_t noresponse; /* server not responding cnt */ + kstat_named_t failover; /* server failover count */ + kstat_named_t remap; /* server remap count */ +#endif +}; + +#ifdef DEBUG +/* + * The following are statistics that describe the behavior of the system as a + * whole and don't correspond to any particular zone. + */ +struct clstat4_debug { + kstat_named_t nrnode; /* number of allocated rnodes */ + kstat_named_t access; /* size of access cache */ + kstat_named_t dirent; /* size of readdir cache */ + kstat_named_t dirents; /* size of readdir buf cache */ + kstat_named_t reclaim; /* number of reclaims */ + kstat_named_t clreclaim; /* number of cl reclaims */ + kstat_named_t f_reclaim; /* number of free reclaims */ + kstat_named_t a_reclaim; /* number of active reclaims */ + kstat_named_t r_reclaim; /* number of rnode reclaims */ + kstat_named_t rpath; /* bytes used to store rpaths */ +}; +extern struct clstat4_debug clstat4_debug; + +#endif + +/* + * The NFS specific async_reqs structure. iotype4 is grouped to support two + * types of async thread pools, please read comments section of mntinfo4_t + * definition for more information. Care should be taken while adding new + * members to this group. + */ + +enum iotype4 { + NFS4_PUTAPAGE, + NFS4_PAGEIO, + NFS4_COMMIT, + NFS4_READ_AHEAD, + NFS4_READDIR, + NFS4_INACTIVE, + NFS4_ASYNC_TYPES +}; +#define NFS4_ASYNC_PGOPS_TYPES (NFS4_COMMIT + 1) + +/* + * NFS async requests queue type. + */ +enum ioqtype4 { + NFS4_ASYNC_QUEUE, + NFS4_ASYNC_PGOPS_QUEUE, + NFS4_MAX_ASYNC_QUEUES +}; + +/* + * Number of NFS async threads operating exclusively on page op requests. + */ +#define NUM_ASYNC_PGOPS_THREADS 0x2 + +struct nfs4_async_read_req { + void (*readahead)(); /* pointer to readahead function */ + u_offset_t blkoff; /* offset in file */ + struct seg *seg; /* segment to do i/o to */ + caddr_t addr; /* address to do i/o to */ +}; + +struct nfs4_pageio_req { + int (*pageio)(); /* pointer to pageio function */ + page_t *pp; /* page list */ + u_offset_t io_off; /* offset in file */ + uint_t io_len; /* size of request */ + int flags; +}; + +struct nfs4_readdir_req { + int (*readdir)(); /* pointer to readdir function */ + struct rddir4_cache *rdc; /* pointer to cache entry to fill */ +}; + +struct nfs4_commit_req { + void (*commit)(); /* pointer to commit function */ + page_t *plist; /* page list */ + offset4 offset; /* starting offset */ + count4 count; /* size of range to be commited */ +}; + +struct nfs4_async_reqs { + struct nfs4_async_reqs *a_next; /* pointer to next arg struct */ +#ifdef DEBUG + kthread_t *a_queuer; /* thread id of queueing thread */ +#endif + struct vnode *a_vp; /* vnode pointer */ + struct cred *a_cred; /* cred pointer */ + enum iotype4 a_io; /* i/o type */ + union { + struct nfs4_async_read_req a_read_args; + struct nfs4_pageio_req a_pageio_args; + struct nfs4_readdir_req a_readdir_args; + struct nfs4_commit_req a_commit_args; + } a_args; +}; + +#define a_nfs4_readahead a_args.a_read_args.readahead +#define a_nfs4_blkoff a_args.a_read_args.blkoff +#define a_nfs4_seg a_args.a_read_args.seg +#define a_nfs4_addr a_args.a_read_args.addr + +#define a_nfs4_putapage a_args.a_pageio_args.pageio +#define a_nfs4_pageio a_args.a_pageio_args.pageio +#define a_nfs4_pp a_args.a_pageio_args.pp +#define a_nfs4_off a_args.a_pageio_args.io_off +#define a_nfs4_len a_args.a_pageio_args.io_len +#define a_nfs4_flags a_args.a_pageio_args.flags + +#define a_nfs4_readdir a_args.a_readdir_args.readdir +#define a_nfs4_rdc a_args.a_readdir_args.rdc + +#define a_nfs4_commit a_args.a_commit_args.commit +#define a_nfs4_plist a_args.a_commit_args.plist +#define a_nfs4_offset a_args.a_commit_args.offset +#define a_nfs4_count a_args.a_commit_args.count + +/* + * Security information + */ +typedef struct sv_secinfo { + uint_t count; /* how many sdata there are */ + uint_t index; /* which sdata[index] */ + struct sec_data *sdata; +} sv_secinfo_t; + +/* + * Hash bucket for the mi's open owner list (mi_oo_list). + */ +typedef struct nfs4_oo_hash_bucket { + list_t b_oo_hash_list; + kmutex_t b_lock; +} nfs4_oo_hash_bucket_t; + +/* + * Global array of ctags. + */ +extern ctag_t nfs4_ctags[]; + +typedef enum nfs4_tag_type { + TAG_NONE, + TAG_ACCESS, + TAG_CLOSE, + TAG_CLOSE_LOST, + TAG_CLOSE_UNDO, + TAG_COMMIT, + TAG_DELEGRETURN, + TAG_FSINFO, + TAG_GET_SYMLINK, + TAG_GETATTR, + TAG_GETATTR_FSLOCATION, + TAG_INACTIVE, + TAG_LINK, + TAG_LOCK, + TAG_LOCK_RECLAIM, + TAG_LOCK_RESEND, + TAG_LOCK_REINSTATE, + TAG_LOCK_UNKNOWN, + TAG_LOCKT, + TAG_LOCKU, + TAG_LOCKU_RESEND, + TAG_LOCKU_REINSTATE, + TAG_LOOKUP, + TAG_LOOKUP_PARENT, + TAG_LOOKUP_VALID, + TAG_LOOKUP_VPARENT, + TAG_MKDIR, + TAG_MKNOD, + TAG_MOUNT, + TAG_OPEN, + TAG_OPEN_CONFIRM, + TAG_OPEN_CONFIRM_LOST, + TAG_OPEN_DG, + TAG_OPEN_DG_LOST, + TAG_OPEN_LOST, + TAG_OPENATTR, + TAG_PATHCONF, + TAG_PUTROOTFH, + TAG_READ, + TAG_READAHEAD, + TAG_READDIR, + TAG_READLINK, + TAG_RELOCK, + TAG_REMAP_LOOKUP, + TAG_REMAP_LOOKUP_AD, + TAG_REMAP_LOOKUP_NA, + TAG_REMAP_MOUNT, + TAG_RMDIR, + TAG_REMOVE, + TAG_RENAME, + TAG_RENAME_VFH, + TAG_RENEW, + TAG_REOPEN, + TAG_REOPEN_LOST, + TAG_SECINFO, + TAG_SETATTR, + TAG_SETCLIENTID, + TAG_SETCLIENTID_CF, + TAG_SYMLINK, + TAG_WRITE +} nfs4_tag_type_t; + +#define NFS4_TAG_INITIALIZER { \ + {TAG_NONE, "", \ + {0x20202020, 0x20202020, 0x20202020}}, \ + {TAG_ACCESS, "access", \ + {0x61636365, 0x73732020, 0x20202020}}, \ + {TAG_CLOSE, "close", \ + {0x636c6f73, 0x65202020, 0x20202020}}, \ + {TAG_CLOSE_LOST, "lost close", \ + {0x6c6f7374, 0x20636c6f, 0x73652020}}, \ + {TAG_CLOSE_UNDO, "undo close", \ + {0x756e646f, 0x20636c6f, 0x73652020}}, \ + {TAG_COMMIT, "commit", \ + {0x636f6d6d, 0x69742020, 0x20202020}}, \ + {TAG_DELEGRETURN, "delegreturn", \ + {0x64656c65, 0x67726574, 0x75726e20}}, \ + {TAG_FSINFO, "fsinfo", \ + {0x6673696e, 0x666f2020, 0x20202020}}, \ + {TAG_GET_SYMLINK, "get symlink text", \ + {0x67657420, 0x736c6e6b, 0x20747874}}, \ + {TAG_GETATTR, "getattr", \ + {0x67657461, 0x74747220, 0x20202020}}, \ + {TAG_GETATTR_FSLOCATION, "getattr fslocation", \ + {0x67657461, 0x74747220, 0x66736c6f}}, \ + {TAG_INACTIVE, "inactive", \ + {0x696e6163, 0x74697665, 0x20202020}}, \ + {TAG_LINK, "link", \ + {0x6c696e6b, 0x20202020, 0x20202020}}, \ + {TAG_LOCK, "lock", \ + {0x6c6f636b, 0x20202020, 0x20202020}}, \ + {TAG_LOCK_RECLAIM, "reclaim lock", \ + {0x7265636c, 0x61696d20, 0x6c6f636b}}, \ + {TAG_LOCK_RESEND, "resend lock", \ + {0x72657365, 0x6e64206c, 0x6f636b20}}, \ + {TAG_LOCK_REINSTATE, "reinstate lock", \ + {0x7265696e, 0x7374206c, 0x6f636b20}}, \ + {TAG_LOCK_UNKNOWN, "unknown lock", \ + {0x756e6b6e, 0x6f776e20, 0x6c6f636b}}, \ + {TAG_LOCKT, "lock test", \ + {0x6c6f636b, 0x5f746573, 0x74202020}}, \ + {TAG_LOCKU, "unlock", \ + {0x756e6c6f, 0x636b2020, 0x20202020}}, \ + {TAG_LOCKU_RESEND, "resend locku", \ + {0x72657365, 0x6e64206c, 0x6f636b75}}, \ + {TAG_LOCKU_REINSTATE, "reinstate unlock", \ + {0x7265696e, 0x73742075, 0x6e6c636b}}, \ + {TAG_LOOKUP, "lookup", \ + {0x6c6f6f6b, 0x75702020, 0x20202020}}, \ + {TAG_LOOKUP_PARENT, "lookup parent", \ + {0x6c6f6f6b, 0x75702070, 0x6172656e}}, \ + {TAG_LOOKUP_VALID, "lookup valid", \ + {0x6c6f6f6b, 0x75702076, 0x616c6964}}, \ + {TAG_LOOKUP_VPARENT, "lookup valid parent", \ + {0x6c6f6f6b, 0x766c6420, 0x7061726e}}, \ + {TAG_MKDIR, "mkdir", \ + {0x6d6b6469, 0x72202020, 0x20202020}}, \ + {TAG_MKNOD, "mknod", \ + {0x6d6b6e6f, 0x64202020, 0x20202020}}, \ + {TAG_MOUNT, "mount", \ + {0x6d6f756e, 0x74202020, 0x20202020}}, \ + {TAG_OPEN, "open", \ + {0x6f70656e, 0x20202020, 0x20202020}}, \ + {TAG_OPEN_CONFIRM, "open confirm", \ + {0x6f70656e, 0x5f636f6e, 0x6669726d}}, \ + {TAG_OPEN_CONFIRM_LOST, "lost open confirm", \ + {0x6c6f7374, 0x206f7065, 0x6e5f636f}}, \ + {TAG_OPEN_DG, "open downgrade", \ + {0x6f70656e, 0x20646772, 0x61646520}}, \ + {TAG_OPEN_DG_LOST, "lost open downgrade", \ + {0x6c737420, 0x6f70656e, 0x20646772}}, \ + {TAG_OPEN_LOST, "lost open", \ + {0x6c6f7374, 0x206f7065, 0x6e202020}}, \ + {TAG_OPENATTR, "openattr", \ + {0x6f70656e, 0x61747472, 0x20202020}}, \ + {TAG_PATHCONF, "pathconf", \ + {0x70617468, 0x636f6e66, 0x20202020}}, \ + {TAG_PUTROOTFH, "putrootfh", \ + {0x70757472, 0x6f6f7466, 0x68202020}}, \ + {TAG_READ, "read", \ + {0x72656164, 0x20202020, 0x20202020}}, \ + {TAG_READAHEAD, "readahead", \ + {0x72656164, 0x61686561, 0x64202020}}, \ + {TAG_READDIR, "readdir", \ + {0x72656164, 0x64697220, 0x20202020}}, \ + {TAG_READLINK, "readlink", \ + {0x72656164, 0x6c696e6b, 0x20202020}}, \ + {TAG_RELOCK, "relock", \ + {0x72656c6f, 0x636b2020, 0x20202020}}, \ + {TAG_REMAP_LOOKUP, "remap lookup", \ + {0x72656d61, 0x70206c6f, 0x6f6b7570}}, \ + {TAG_REMAP_LOOKUP_AD, "remap lookup attr dir", \ + {0x72656d70, 0x206c6b75, 0x70206164}}, \ + {TAG_REMAP_LOOKUP_NA, "remap lookup named attrs", \ + {0x72656d70, 0x206c6b75, 0x70206e61}}, \ + {TAG_REMAP_MOUNT, "remap mount", \ + {0x72656d61, 0x70206d6f, 0x756e7420}}, \ + {TAG_RMDIR, "rmdir", \ + {0x726d6469, 0x72202020, 0x20202020}}, \ + {TAG_REMOVE, "remove", \ + {0x72656d6f, 0x76652020, 0x20202020}}, \ + {TAG_RENAME, "rename", \ + {0x72656e61, 0x6d652020, 0x20202020}}, \ + {TAG_RENAME_VFH, "rename volatile fh", \ + {0x72656e61, 0x6d652028, 0x76666829}}, \ + {TAG_RENEW, "renew", \ + {0x72656e65, 0x77202020, 0x20202020}}, \ + {TAG_REOPEN, "reopen", \ + {0x72656f70, 0x656e2020, 0x20202020}}, \ + {TAG_REOPEN_LOST, "lost reopen", \ + {0x6c6f7374, 0x2072656f, 0x70656e20}}, \ + {TAG_SECINFO, "secinfo", \ + {0x73656369, 0x6e666f20, 0x20202020}}, \ + {TAG_SETATTR, "setattr", \ + {0x73657461, 0x74747220, 0x20202020}}, \ + {TAG_SETCLIENTID, "setclientid", \ + {0x73657463, 0x6c69656e, 0x74696420}}, \ + {TAG_SETCLIENTID_CF, "setclientid_confirm", \ + {0x73636c6e, 0x7469645f, 0x636f6e66}}, \ + {TAG_SYMLINK, "symlink", \ + {0x73796d6c, 0x696e6b20, 0x20202020}}, \ + {TAG_WRITE, "write", \ + {0x77726974, 0x65202020, 0x20202020}} \ + } + +/* + * These flags are for differentiating the search criterian for + * find_open_owner(). The comparison is done with the open_owners's + * 'oo_just_created' flag. + */ +#define NFS4_PERM_CREATED 0x0 +#define NFS4_JUST_CREATED 0x1 + +/* + * Hashed by the cr_uid and cr_ruid of credential 'oo_cred'. 'oo_cred_otw' + * is stored upon a successful OPEN. This is needed when the user's effective + * and real uid's don't match. The 'oo_cred_otw' overrides the credential + * passed down by VFS for async read/write, commit, lock, and close operations. + * + * The oo_ref_count keeps track the number of active references on this + * data structure + number of nfs4_open_streams point to this structure. + * + * 'oo_valid' tells whether this stuct is about to be freed or not. + * + * 'oo_just_created' tells us whether this struct has just been created but + * not been fully finalized (that is created upon an OPEN request and + * finalized upon the OPEN success). + * + * The 'oo_seqid_inuse' is for the open seqid synchronization. If a thread + * is currently using the open owner and it's open_seqid, then it sets the + * oo_seqid_inuse to true if it currently is not set. If it is set then it + * does a cv_wait on the oo_cv_seqid_sync condition variable. When the thread + * is done it unsets the oo_seqid_inuse and does a cv_signal to wake a process + * waiting on the condition variable. + * + * 'oo_last_good_seqid' is the last valid seqid this open owner sent OTW, + * and 'oo_last_good_op' is the operation that issued the last valid seqid. + * + * Lock ordering: + * mntinfo4_t::mi_lock > oo_lock (for searching mi_oo_list) + * + * oo_seqid_inuse > mntinfo4_t::mi_lock + * oo_seqid_inuse > rnode4_t::r_statelock + * oo_seqid_inuse > rnode4_t::r_statev4_lock + * oo_seqid_inuse > nfs4_open_stream_t::os_sync_lock + * + * The 'oo_seqid_inuse'/'oo_cv_seqid_sync' protects: + * oo_last_good_op + * oo_last_good_seqid + * oo_name + * oo_seqid + * + * The 'oo_lock' protects: + * oo_cred + * oo_cred_otw + * oo_foo_node + * oo_hash_node + * oo_just_created + * oo_ref_count + * oo_valid + */ + +typedef struct nfs4_open_owner { + cred_t *oo_cred; + int oo_ref_count; + int oo_valid; + int oo_just_created; + seqid4 oo_seqid; + seqid4 oo_last_good_seqid; + nfs4_tag_type_t oo_last_good_op; + unsigned oo_seqid_inuse:1; + cred_t *oo_cred_otw; + kcondvar_t oo_cv_seqid_sync; + /* + * Fix this to always be 8 bytes + */ + uint64_t oo_name; + list_node_t oo_hash_node; + list_node_t oo_foo_node; + kmutex_t oo_lock; +} nfs4_open_owner_t; + +/* + * Static server information. + * These fields are read-only once they are initialized; sv_lock + * should be held as writer if they are changed during mount: + * sv_addr + * sv_dhsec + * sv_hostname + * sv_hostnamelen + * sv_knconf + * sv_next + * sv_origknconf + * + * These fields are protected by sv_lock: + * sv_currsec + * sv_fhandle + * sv_flags + * sv_fsid + * sv_path + * sv_pathlen + * sv_pfhandle + * sv_save_secinfo + * sv_savesec + * sv_secdata + * sv_secinfo + * sv_supp_attrs + * + * Lock ordering: + * nfs_rtable4_lock > sv_lock + * rnode4_t::r_statelock > sv_lock + */ +typedef struct servinfo4 { + struct knetconfig *sv_knconf; /* bound TLI fd */ + struct knetconfig *sv_origknconf; /* For RDMA save orig knconf */ + struct netbuf sv_addr; /* server's address */ + nfs4_fhandle_t sv_fhandle; /* this server's filehandle */ + nfs4_fhandle_t sv_pfhandle; /* parent dir filehandle */ + int sv_pathlen; /* Length of server path */ + char *sv_path; /* Path name on server */ + uint32_t sv_flags; /* flags for this server */ + sec_data_t *sv_secdata; /* client initiated security data */ + sv_secinfo_t *sv_secinfo; /* server security information */ + sec_data_t *sv_currsec; /* security data currently used; */ + /* points to one of the sec_data */ + /* entries in sv_secinfo */ + sv_secinfo_t *sv_save_secinfo; /* saved secinfo */ + sec_data_t *sv_savesec; /* saved security data */ + sec_data_t *sv_dhsec; /* AUTH_DH data from the user land */ + char *sv_hostname; /* server's hostname */ + int sv_hostnamelen; /* server's hostname length */ + fattr4_fsid sv_fsid; /* fsid of shared obj */ + fattr4_supported_attrs sv_supp_attrs; + struct servinfo4 *sv_next; /* next in list */ + nfs_rwlock_t sv_lock; +} servinfo4_t; + +/* sv_flags fields */ +#define SV4_TRYSECINFO 0x001 /* try secinfo data from the server */ +#define SV4_TRYSECDEFAULT 0x002 /* try a default flavor */ +#define SV4_NOTINUSE 0x004 /* servinfo4_t had fatal errors */ +#define SV4_ROOT_STALE 0x008 /* root vnode got ESTALE */ + +/* + * Lock call types. See nfs4frlock(). + */ +typedef enum nfs4_lock_call_type { + NFS4_LCK_CTYPE_NORM, + NFS4_LCK_CTYPE_RECLAIM, + NFS4_LCK_CTYPE_RESEND, + NFS4_LCK_CTYPE_REINSTATE +} nfs4_lock_call_type_t; + +/* + * This structure holds the information for a lost open/close/open downgrade/ + * lock/locku request. It is also used for requests that are queued up so + * that the recovery thread can release server state after a forced + * unmount. + * "lr_op" is 0 if the struct is uninitialized. Otherwise, it is set to + * the proper OP_* nfs_opnum4 number. The other fields contain information + * to reconstruct the call. + * + * lr_dvp is used for OPENs with CREATE, so that we can do a PUTFH of the + * parent directroy without relying on vtodv (since we may not have a vp + * for the file we wish to create). + * + * lr_putfirst means that the request should go to the front of the resend + * queue, rather than the end. + */ +typedef struct nfs4_lost_rqst { + list_node_t lr_node; + nfs_opnum4 lr_op; + vnode_t *lr_vp; + vnode_t *lr_dvp; + nfs4_open_owner_t *lr_oop; + struct nfs4_open_stream *lr_osp; + struct nfs4_lock_owner *lr_lop; + cred_t *lr_cr; + flock64_t *lr_flk; + bool_t lr_putfirst; + union { + struct { + nfs4_lock_call_type_t lru_ctype; + nfs_lock_type4 lru_locktype; + } lru_lockargs; /* LOCK, LOCKU */ + struct { + uint32_t lru_oaccess; + uint32_t lru_odeny; + enum open_claim_type4 lru_oclaim; + stateid4 lru_ostateid; /* reopen only */ + component4 lru_ofile; + } lru_open_args; + struct { + uint32_t lru_dg_access; + uint32_t lru_dg_deny; + } lru_open_dg_args; + } nfs4_lr_u; +} nfs4_lost_rqst_t; + +#define lr_oacc nfs4_lr_u.lru_open_args.lru_oaccess +#define lr_odeny nfs4_lr_u.lru_open_args.lru_odeny +#define lr_oclaim nfs4_lr_u.lru_open_args.lru_oclaim +#define lr_ostateid nfs4_lr_u.lru_open_args.lru_ostateid +#define lr_ofile nfs4_lr_u.lru_open_args.lru_ofile +#define lr_dg_acc nfs4_lr_u.lru_open_dg_args.lru_dg_access +#define lr_dg_deny nfs4_lr_u.lru_open_dg_args.lru_dg_deny +#define lr_ctype nfs4_lr_u.lru_lockargs.lru_ctype +#define lr_locktype nfs4_lr_u.lru_lockargs.lru_locktype + +/* + * Recovery actions. Some actions can imply further recovery using a + * different recovery action (e.g., recovering the clientid leads to + * recovering open files and locks). + */ + +typedef enum { + NR_UNUSED, + NR_CLIENTID, + NR_OPENFILES, + NR_FHEXPIRED, + NR_FAILOVER, + NR_WRONGSEC, + NR_EXPIRED, + NR_BAD_STATEID, + NR_BADHANDLE, + NR_BAD_SEQID, + NR_OLDSTATEID, + NR_GRACE, + NR_DELAY, + NR_LOST_LOCK, + NR_LOST_STATE_RQST, + NR_STALE, + NR_MOVED +} nfs4_recov_t; + +/* + * Administrative and debug message framework. + */ + +#define NFS4_MSG_MAX 100 +extern int nfs4_msg_max; + +#define NFS4_REFERRAL_LOOP_MAX 20 + +typedef enum { + RE_BAD_SEQID, + RE_BADHANDLE, + RE_CLIENTID, + RE_DEAD_FILE, + RE_END, + RE_FAIL_RELOCK, + RE_FAIL_REMAP_LEN, + RE_FAIL_REMAP_OP, + RE_FAILOVER, + RE_FILE_DIFF, + RE_LOST_STATE, + RE_OPENS_CHANGED, + RE_SIGLOST, + RE_SIGLOST_NO_DUMP, + RE_START, + RE_UNEXPECTED_ACTION, + RE_UNEXPECTED_ERRNO, + RE_UNEXPECTED_STATUS, + RE_WRONGSEC, + RE_LOST_STATE_BAD_OP, + RE_REFERRAL +} nfs4_event_type_t; + +typedef enum { + RFS_NO_INSPECT, + RFS_INSPECT +} nfs4_fact_status_t; + +typedef enum { + RF_BADOWNER, + RF_ERR, + RF_RENEW_EXPIRED, + RF_SRV_NOT_RESPOND, + RF_SRV_OK, + RF_SRVS_NOT_RESPOND, + RF_SRVS_OK, + RF_DELMAP_CB_ERR, + RF_SENDQ_FULL +} nfs4_fact_type_t; + +typedef enum { + NFS4_MS_DUMP, + NFS4_MS_NO_DUMP +} nfs4_msg_status_t; + +typedef struct nfs4_rfact { + nfs4_fact_type_t rf_type; + nfs4_fact_status_t rf_status; + bool_t rf_reboot; + nfs4_recov_t rf_action; + nfs_opnum4 rf_op; + nfsstat4 rf_stat4; + timespec_t rf_time; + int rf_error; + struct rnode4 *rf_rp1; + char *rf_char1; +} nfs4_rfact_t; + +typedef struct nfs4_revent { + nfs4_event_type_t re_type; + nfsstat4 re_stat4; + uint_t re_uint; + pid_t re_pid; + struct mntinfo4 *re_mi; + struct rnode4 *re_rp1; + struct rnode4 *re_rp2; + char *re_char1; + char *re_char2; + nfs4_tag_type_t re_tag1; + nfs4_tag_type_t re_tag2; + seqid4 re_seqid1; + seqid4 re_seqid2; +} nfs4_revent_t; + +typedef enum { + RM_EVENT, + RM_FACT +} nfs4_msg_type_t; + +typedef struct nfs4_debug_msg { + timespec_t msg_time; + nfs4_msg_type_t msg_type; + char *msg_srv; + char *msg_mntpt; + union { + nfs4_rfact_t msg_fact; + nfs4_revent_t msg_event; + } rmsg_u; + nfs4_msg_status_t msg_status; + list_node_t msg_node; +} nfs4_debug_msg_t; + +/* + * NFS private data per mounted file system + * The mi_lock mutex protects the following fields: + * mi_flags + * mi_in_recovery + * mi_recovflags + * mi_recovthread + * mi_error + * mi_printed + * mi_down + * mi_stsize + * mi_curread + * mi_curwrite + * mi_timers + * mi_curr_serv + * mi_klmconfig + * mi_oo_list + * mi_foo_list + * mi_foo_num + * mi_foo_max + * mi_lost_state + * mi_bseqid_list + * mi_ephemeral + * mi_ephemeral_tree + * + * Normally the netconfig information for the mount comes from + * mi_curr_serv and mi_klmconfig is NULL. If NLM calls need to use a + * different transport, mi_klmconfig contains the necessary netconfig + * information. + * + * The mi_async_lock mutex protects the following fields: + * mi_async_reqs + * mi_async_req_count + * mi_async_tail + * mi_async_curr[NFS4_MAX_ASYNC_QUEUES] + * mi_async_clusters + * mi_async_init_clusters + * mi_threads[NFS4_MAX_ASYNC_QUEUES] + * mi_inactive_thread + * mi_manager_thread + * + * The nfs4_server_t::s_lock protects the following fields: + * mi_clientid + * mi_clientid_next + * mi_clientid_prev + * mi_open_files + * + * The mntinfo4_t::mi_recovlock protects the following fields: + * mi_srvsettime + * mi_srvset_cnt + * mi_srv + * + * Changing mi_srv from one nfs4_server_t to a different one requires + * holding the mi_recovlock as RW_WRITER. + * Exception: setting mi_srv the first time in mount/mountroot is done + * holding the mi_recovlock as RW_READER. + * + * Locking order: + * mi4_globals::mig_lock > mi_async_lock + * mi_async_lock > nfs4_server_t::s_lock > mi_lock + * mi_recovlock > mi_rename_lock > nfs_rtable4_lock + * nfs4_server_t::s_recovlock > mi_recovlock + * rnode4_t::r_rwlock > mi_rename_lock + * nfs_rtable4_lock > mi_lock + * nfs4_server_t::s_lock > mi_msg_list_lock + * mi_recovlock > nfs4_server_t::s_lock + * mi_recovlock > nfs4_server_lst_lock + * + * The 'mi_oo_list' represents the hash buckets that contain the + * nfs4_open_owenrs for this particular mntinfo4. + * + * The 'mi_foo_list' represents the freed nfs4_open_owners for this mntinfo4. + * 'mi_foo_num' is the current number of freed open owners on the list, + * 'mi_foo_max' is the maximum number of freed open owners that are allowable + * on the list. + * + * mi_rootfh and mi_srvparentfh are read-only once created, but that just + * refers to the pointer. The contents must be updated to keep in sync + * with mi_curr_serv. + * + * The mi_msg_list_lock protects against adding/deleting entries to the + * mi_msg_list, and also the updating/retrieving of mi_lease_period; + * + * 'mi_zone' is initialized at structure creation time, and never + * changes; it may be read without a lock. + * + * mi_zone_node is linkage into the mi4_globals.mig_list, and is + * protected by mi4_globals.mig_list_lock. + * + * If MI4_EPHEMERAL is set in mi_flags, then mi_ephemeral points to an + * ephemeral structure for this ephemeral mount point. It can not be + * NULL. Also, mi_ephemeral_tree points to the root of the ephemeral + * tree. + * + * If MI4_EPHEMERAL is not set in mi_flags, then mi_ephemeral has + * to be NULL. If mi_ephemeral_tree is non-NULL, then this node + * is the enclosing mntinfo4 for the ephemeral tree. + */ +struct zone; +struct nfs4_ephemeral; +struct nfs4_ephemeral_tree; +struct nfs4_server; +typedef struct mntinfo4 { + kmutex_t mi_lock; /* protects mntinfo4 fields */ + struct servinfo4 *mi_servers; /* server list */ + struct servinfo4 *mi_curr_serv; /* current server */ + struct nfs4_sharedfh *mi_rootfh; /* root filehandle */ + struct nfs4_sharedfh *mi_srvparentfh; /* root's parent on server */ + kcondvar_t mi_failover_cv; /* failover synchronization */ + struct vfs *mi_vfsp; /* back pointer to vfs */ + enum vtype mi_type; /* file type of the root vnode */ + uint_t mi_flags; /* see below */ + uint_t mi_recovflags; /* if recovery active; see below */ + kthread_t *mi_recovthread; /* active recov thread or NULL */ + uint_t mi_error; /* only set/valid when MI4_RECOV_FAIL */ + /* is set in mi_flags */ + int mi_tsize; /* transfer size (bytes) */ + /* really read size */ + int mi_stsize; /* server's max transfer size (bytes) */ + /* really write size */ + int mi_timeo; /* inital timeout in 10th sec */ + int mi_retrans; /* times to retry request */ + hrtime_t mi_acregmin; /* min time to hold cached file attr */ + hrtime_t mi_acregmax; /* max time to hold cached file attr */ + hrtime_t mi_acdirmin; /* min time to hold cached dir attr */ + hrtime_t mi_acdirmax; /* max time to hold cached dir attr */ + len_t mi_maxfilesize; /* for pathconf _PC_FILESIZEBITS */ + int mi_curread; /* current read size */ + int mi_curwrite; /* current write size */ + uint_t mi_count; /* ref count */ + /* + * Async I/O management + * We have 2 pools of threads working on async I/O: + * (1) Threads which work on all async queues. Default number of + * threads in this queue is 8. Threads in this pool work on async + * queue pointed by mi_async_curr[NFS4_ASYNC_QUEUE]. Number of + * active threads in this pool is tracked by + * mi_threads[NFS4_ASYNC_QUEUE]. + * (ii)Threads which work only on page op async queues. + * Page ops queue comprises of NFS4_PUTAPAGE, NFS4_PAGEIO & + * NFS4_COMMIT. Default number of threads in this queue is 2 + * (NUM_ASYNC_PGOPS_THREADS). Threads in this pool work on async + * queue pointed by mi_async_curr[NFS4_ASYNC_PGOPS_QUEUE]. Number + * of active threads in this pool is tracked by + * mi_threads[NFS4_ASYNC_PGOPS_QUEUE]. + * + * In addition to above two pools, there is always one thread that + * handles over-the-wire requests for VOP_INACTIVE. + */ + struct nfs4_async_reqs *mi_async_reqs[NFS4_ASYNC_TYPES]; + struct nfs4_async_reqs *mi_async_tail[NFS4_ASYNC_TYPES]; + struct nfs4_async_reqs **mi_async_curr[NFS4_MAX_ASYNC_QUEUES]; + /* current async queue */ + uint_t mi_async_clusters[NFS4_ASYNC_TYPES]; + uint_t mi_async_init_clusters; + uint_t mi_async_req_count; /* # outstanding work requests */ + kcondvar_t mi_async_reqs_cv; /* signaled when there's work */ + ushort_t mi_threads[NFS4_MAX_ASYNC_QUEUES]; + /* number of active async threads */ + ushort_t mi_max_threads; /* max number of async threads */ + kthread_t *mi_manager_thread; /* async manager thread id */ + kthread_t *mi_inactive_thread; /* inactive thread id */ + kcondvar_t mi_inact_req_cv; /* notify VOP_INACTIVE thread */ + kcondvar_t mi_async_work_cv[NFS4_MAX_ASYNC_QUEUES]; + /* tell workers to work */ + kcondvar_t mi_async_cv; /* all pool threads exited */ + kmutex_t mi_async_lock; + /* + * Other stuff + */ + struct pathcnf *mi_pathconf; /* static pathconf kludge */ + rpcprog_t mi_prog; /* RPC program number */ + rpcvers_t mi_vers; /* RPC program version number */ + char **mi_rfsnames; /* mapping to proc names */ + kstat_named_t *mi_reqs; /* count of requests */ + clock_t mi_printftime; /* last error printf time */ + nfs_rwlock_t mi_recovlock; /* separate ops from recovery (v4) */ + time_t mi_grace_wait; /* non-zero represents time to wait */ + /* when we switched nfs4_server_t - only for observability purposes */ + time_t mi_srvsettime; + nfs_rwlock_t mi_rename_lock; /* atomic volfh rename */ + struct nfs4_fname *mi_fname; /* root fname */ + list_t mi_lost_state; /* resend list */ + list_t mi_bseqid_list; /* bad seqid list */ + /* + * Client Side Failover stats + */ + uint_t mi_noresponse; /* server not responding count */ + uint_t mi_failover; /* failover to new server count */ + uint_t mi_remap; /* remap to new server count */ + /* + * Kstat statistics + */ + struct kstat *mi_io_kstats; + struct kstat *mi_ro_kstats; + kstat_t *mi_recov_ksp; /* ptr to the recovery kstat */ + + /* + * Volatile fh flags (nfsv4) + */ + uint32_t mi_fh_expire_type; + /* + * Lease Management + */ + struct mntinfo4 *mi_clientid_next; + struct mntinfo4 *mi_clientid_prev; + clientid4 mi_clientid; /* redundant info found in nfs4_server */ + int mi_open_files; /* count of open files */ + int mi_in_recovery; /* count of recovery instances */ + kcondvar_t mi_cv_in_recov; /* cv for recovery threads */ + /* + * Open owner stuff. + */ + struct nfs4_oo_hash_bucket mi_oo_list[NFS4_NUM_OO_BUCKETS]; + list_t mi_foo_list; + int mi_foo_num; + int mi_foo_max; + /* + * Shared filehandle pool. + */ + nfs_rwlock_t mi_fh_lock; + avl_tree_t mi_filehandles; + + /* + * Debug message queue. + */ + list_t mi_msg_list; + int mi_msg_count; + time_t mi_lease_period; + /* + * not guaranteed to be accurate. + * only should be used by debug queue. + */ + kmutex_t mi_msg_list_lock; + /* + * Zones support. + */ + struct zone *mi_zone; /* Zone in which FS is mounted */ + zone_ref_t mi_zone_ref; /* Reference to aforementioned zone */ + list_node_t mi_zone_node; /* linkage into per-zone mi list */ + + /* + * Links for unmounting ephemeral mounts. + */ + struct nfs4_ephemeral *mi_ephemeral; + struct nfs4_ephemeral_tree *mi_ephemeral_tree; + + uint_t mi_srvset_cnt; /* increment when changing the nfs4_server_t */ + struct nfs4_server *mi_srv; /* backpointer to nfs4_server_t */ + /* + * Referral related info. + */ + int mi_vfs_referral_loop_cnt; + /* + * List of rnode4_t structures that belongs to this mntinfo4 + */ + kmutex_t mi_rnodes_lock; /* protects the mi_rnodes list */ + list_t mi_rnodes; /* the list */ +} mntinfo4_t; + +/* + * The values for mi_flags. + * + * MI4_HARD hard or soft mount + * MI4_PRINTED responding message printed + * MI4_INT allow INTR on hard mount + * MI4_DOWN server is down + * MI4_NOAC don't cache attributes + * MI4_NOCTO no close-to-open consistency + * MI4_LLOCK local locking only (no lockmgr) + * MI4_GRPID System V group id inheritance + * MI4_SHUTDOWN System is rebooting or shutting down + * MI4_LINK server supports link + * MI4_SYMLINK server supports symlink + * MI4_EPHEMERAL_RECURSED an ephemeral mount being unmounted + * due to a recursive call - no need + * for additional recursion + * MI4_ACL server supports NFSv4 ACLs + * MI4_MIRRORMOUNT is a mirrormount + * MI4_NOPRINT don't print messages + * MI4_DIRECTIO do direct I/O + * MI4_RECOV_ACTIV filesystem has recovery a thread + * MI4_REMOVE_ON_LAST_CLOSE remove from server's list + * MI4_RECOV_FAIL client recovery failed + * MI4_PUBLIC public/url option used + * MI4_MOUNTING mount in progress, don't failover + * MI4_POSIX_LOCK if server is using POSIX locking + * MI4_LOCK_DEBUG cmn_err'd posix lock err msg + * MI4_DEAD zone has released it + * MI4_INACTIVE_IDLE inactive thread idle + * MI4_BADOWNER_DEBUG badowner error msg per mount + * MI4_ASYNC_MGR_STOP tell async manager to die + * MI4_TIMEDOUT saw a timeout during zone shutdown + * MI4_EPHEMERAL is an ephemeral mount + */ +#define MI4_HARD 0x1 +#define MI4_PRINTED 0x2 +#define MI4_INT 0x4 +#define MI4_DOWN 0x8 +#define MI4_NOAC 0x10 +#define MI4_NOCTO 0x20 +#define MI4_LLOCK 0x80 +#define MI4_GRPID 0x100 +#define MI4_SHUTDOWN 0x200 +#define MI4_LINK 0x400 +#define MI4_SYMLINK 0x800 +#define MI4_EPHEMERAL_RECURSED 0x1000 +#define MI4_ACL 0x2000 +/* MI4_MIRRORMOUNT is also defined in nfsstat.c */ +#define MI4_MIRRORMOUNT 0x4000 +#define MI4_REFERRAL 0x8000 +/* 0x10000 is available */ +#define MI4_NOPRINT 0x20000 +#define MI4_DIRECTIO 0x40000 +/* 0x80000 is available */ +#define MI4_RECOV_ACTIV 0x100000 +#define MI4_REMOVE_ON_LAST_CLOSE 0x200000 +#define MI4_RECOV_FAIL 0x400000 +#define MI4_PUBLIC 0x800000 +#define MI4_MOUNTING 0x1000000 +#define MI4_POSIX_LOCK 0x2000000 +#define MI4_LOCK_DEBUG 0x4000000 +#define MI4_DEAD 0x8000000 +#define MI4_INACTIVE_IDLE 0x10000000 +#define MI4_BADOWNER_DEBUG 0x20000000 +#define MI4_ASYNC_MGR_STOP 0x40000000 +#define MI4_TIMEDOUT 0x80000000 + +#define MI4_EPHEMERAL (MI4_MIRRORMOUNT | MI4_REFERRAL) + +#define INTR4(vp) (VTOMI4(vp)->mi_flags & MI4_INT) + +#define FAILOVER_MOUNT4(mi) (mi->mi_servers->sv_next) + +/* + * Recovery flags. + * + * MI4R_NEED_CLIENTID is sort of redundant (it's the nfs4_server_t flag + * that's important), but some flag is needed to indicate that recovery is + * going on for the filesystem. + */ +#define MI4R_NEED_CLIENTID 0x1 +#define MI4R_REOPEN_FILES 0x2 +#define MI4R_NEED_SECINFO 0x4 +#define MI4R_NEED_NEW_SERVER 0x8 +#define MI4R_REMAP_FILES 0x10 +#define MI4R_SRV_REBOOT 0x20 /* server has rebooted */ +#define MI4R_LOST_STATE 0x40 +#define MI4R_BAD_SEQID 0x80 +#define MI4R_MOVED 0x100 + +#define MI4_HOLD(mi) { \ + mi_hold(mi); \ +} + +#define MI4_RELE(mi) { \ + mi_rele(mi); \ +} + +/* + * vfs pointer to mount info + */ +#define VFTOMI4(vfsp) ((mntinfo4_t *)((vfsp)->vfs_data)) + +/* + * vnode pointer to mount info + */ +#define VTOMI4(vp) ((mntinfo4_t *)(((vp)->v_vfsp)->vfs_data)) + +/* + * Lease Management + * + * lease_valid is initially set to NFS4_LEASE_NOT_STARTED. This is when the + * nfs4_server is first created. lease_valid is then set to + * NFS4_LEASE_UNITIALIZED when the renew thread is started. The extra state of + * NFS4_LEASE_NOT_STARTED is needed for client recovery (so we know if a thread + * already exists when we do SETCLIENTID). lease_valid is then set to + * NFS4_LEASE_VALID (if it is at NFS4_LEASE_UNITIALIZED) when a state creating + * operation (OPEN) is done. lease_valid stays at NFS4_LEASE_VALID as long as + * the lease is renewed. It is set to NFS4_LEASE_INVALID when the lease + * expires. Client recovery is needed to set the lease back to + * NFS4_LEASE_VALID from NFS4_LEASE_INVALID. + * + * The s_cred is the credential used to mount the first file system for this + * server. It used as the credential for the renew thread's calls to the + * server. + * + * The renew thread waits on the condition variable cv_thread_exit. If the cv + * is signalled, then the thread knows it must check s_thread_exit to see if + * it should exit. The cv is signaled when the last file system is unmounted + * from a particular server. s_thread_exit is set to 0 upon thread startup, + * and set to NFS4_THREAD_EXIT, when the last file system is unmounted thereby + * telling the thread to exit. s_thread_exit is needed to avoid spurious + * wakeups. + * + * state_ref_count is incremented every time a new file is opened and + * decremented every time a file is closed otw. This keeps track of whether + * the nfs4_server has state associated with it or not. + * + * s_refcnt is the reference count for storage management of the struct + * itself. + * + * mntinfo4_list points to the doubly linked list of mntinfo4s that share + * this nfs4_server (ie: pair) in the current zone. This is + * needed for a nfs4_server to get a mntinfo4 for use in rfs4call. + * + * s_recovlock is used to synchronize recovery operations. The thread + * that is recovering the client must acquire it as a writer. If the + * thread is using the clientid (including recovery operations on other + * state), acquire it as a reader. + * + * The 's_otw_call_count' keeps track of the number of outstanding over the + * wire requests for this structure. The struct will not go away as long + * as this is non-zero (or s_refcnt is non-zero). + * + * The 's_cv_otw_count' is used in conjuntion with the 's_otw_call_count' + * variable to let the renew thread when an outstanding otw request has + * finished. + * + * 'zoneid' and 'zone_globals' are set at creation of this structure + * and are read-only after that; no lock is required to read them. + * + * s_lock protects: everything except cv_thread_exit and s_recovlock. + * + * s_program is used as the index into the nfs4_callback_globals's + * nfs4prog2server table. When a callback request comes in, we can + * use that request's program number (minus NFS4_CALLBACK) as an index + * into the nfs4prog2server. That entry will hold the nfs4_server_t ptr. + * We can then access that nfs4_server_t and its 's_deleg_list' (its list of + * delegated rnode4_ts). + * + * Lock order: + * nfs4_server::s_lock > mntinfo4::mi_lock + * nfs_rtable4_lock > s_lock + * nfs4_server_lst_lock > s_lock + * s_recovlock > s_lock + */ +struct nfs4_callback_globals; + +typedef struct nfs4_server { + struct nfs4_server *forw; + struct nfs4_server *back; + struct netbuf saddr; + uint_t s_flags; /* see below */ + uint_t s_refcnt; + clientid4 clientid; /* what we get from server */ + nfs_client_id4 clidtosend; /* what we send to server */ + mntinfo4_t *mntinfo4_list; + int lease_valid; + time_t s_lease_time; + time_t last_renewal_time; + timespec_t propagation_delay; + cred_t *s_cred; + kcondvar_t cv_thread_exit; + int s_thread_exit; + int state_ref_count; + int s_otw_call_count; + kcondvar_t s_cv_otw_count; + kcondvar_t s_clientid_pend; + kmutex_t s_lock; + list_t s_deleg_list; + rpcprog_t s_program; + nfs_rwlock_t s_recovlock; + kcondvar_t wait_cb_null; /* used to wait for CB_NULL */ + zoneid_t zoneid; /* zone using this nfs4_server_t */ + struct nfs4_callback_globals *zone_globals; /* globals */ +} nfs4_server_t; + +/* nfs4_server flags */ +#define N4S_CLIENTID_SET 1 /* server has our clientid */ +#define N4S_CLIENTID_PEND 0x2 /* server doesn't have clientid */ +#define N4S_CB_PINGED 0x4 /* server has sent us a CB_NULL */ +#define N4S_CB_WAITER 0x8 /* is/has wait{ing/ed} for cb_null */ +#define N4S_INSERTED 0x10 /* list has reference for server */ +#define N4S_BADOWNER_DEBUG 0x20 /* bad owner err msg per client */ + +#define N4S_CB_PAUSE_TIME 10000 /* Amount of time to pause (10ms) */ + +struct lease_time_arg { + time_t lease_time; +}; + +enum nfs4_delegreturn_policy { + IMMEDIATE, + FIRSTCLOSE, + LASTCLOSE, + INACTIVE +}; + +/* + * Operation hints for the recovery framework (mostly). + * + * EXCEPTIONS: + * OH_ACCESS, OH_GETACL, OH_GETATTR, OH_LOOKUP, OH_READDIR + * These hints exist to allow user visit/readdir a R4SRVSTUB dir. + * (dir represents the root of a server fs that has not yet been + * mounted at client) + */ +typedef enum { + OH_OTHER, + OH_READ, + OH_WRITE, + OH_COMMIT, + OH_VFH_RENAME, + OH_MOUNT, + OH_CLOSE, + OH_LOCKU, + OH_DELEGRETURN, + OH_ACCESS, + OH_GETACL, + OH_GETATTR, + OH_LOOKUP, + OH_READDIR +} nfs4_op_hint_t; + +/* + * This data structure is used to track ephemeral mounts for both + * mirror mounts and referrals. + * + * Note that each nfs4_ephemeral can only have one other nfs4_ephemeral + * pointing at it. So we don't need two backpointers to walk + * back up the tree. + * + * An ephemeral tree is pointed to by an enclosing non-ephemeral + * mntinfo4. The root is also pointed to by its ephemeral + * mntinfo4. ne_child will get us back to it, while ne_prior + * will get us back to the non-ephemeral mntinfo4. This is an + * edge case we will need to be wary of when walking back up the + * tree. + * + * The way we handle this edge case is to have ne_prior be NULL + * for the root nfs4_ephemeral node. + */ +typedef struct nfs4_ephemeral { + mntinfo4_t *ne_mount; /* who encloses us */ + struct nfs4_ephemeral *ne_child; /* first child node */ + struct nfs4_ephemeral *ne_peer; /* next sibling */ + struct nfs4_ephemeral *ne_prior; /* who points at us */ + time_t ne_ref_time; /* time last referenced */ + uint_t ne_mount_to; /* timeout at */ + int ne_state; /* used to traverse */ +} nfs4_ephemeral_t; + +/* + * State for the node (set in ne_state): + */ +#define NFS4_EPHEMERAL_OK 0x0 +#define NFS4_EPHEMERAL_VISIT_CHILD 0x1 +#define NFS4_EPHEMERAL_VISIT_SIBLING 0x2 +#define NFS4_EPHEMERAL_PROCESS_ME 0x4 +#define NFS4_EPHEMERAL_CHILD_ERROR 0x8 +#define NFS4_EPHEMERAL_PEER_ERROR 0x10 + +/* + * These are the locks used in processing ephemeral data: + * + * mi->mi_lock + * + * net->net_tree_lock + * This lock is used to gate all tree operations. + * If it is held, then no other process may + * traverse the tree. This allows us to not + * throw a hold on each vfs_t in the tree. + * Can be held for a "long" time. + * + * net->net_cnt_lock + * Used to protect refcnt and status. + * Must be held for a really short time. + * + * nfs4_ephemeral_thread_lock + * Is only held to create the harvester for the zone. + * There is no ordering imposed on it. + * Held for a really short time. + * + * Some further detail on the interactions: + * + * net_tree_lock controls access to net_root. Access needs to first be + * attempted in a non-blocking check. + * + * net_cnt_lock controls access to net_refcnt and net_status. It must only be + * held for very short periods of time, unless the refcnt is 0 and the status + * is INVALID. + * + * Before a caller can grab net_tree_lock, it must first grab net_cnt_lock + * to bump the net_refcnt. It then releases it and does the action specific + * algorithm to get the net_tree_lock. Once it has that, then it is okay to + * grab the net_cnt_lock and change the status. The status can only be + * changed if the caller has the net_tree_lock held as well. + * + * Note that the initial grab of net_cnt_lock must occur whilst + * mi_lock is being held. This prevents stale data in that if the + * ephemeral tree is non-NULL, then the harvester can not remove + * the tree from the mntinfo node until it grabs that lock. I.e., + * we get the pointer to the tree and hold the lock atomically + * with respect to being in mi_lock. + * + * When a caller is done with net_tree_lock, it can decrement the net_refcnt + * either before it releases net_tree_lock or after. + * + * In either event, to decrement net_refcnt, it must hold net_cnt_lock. + * + * Note that the overall locking scheme for the nodes is to control access + * via the tree. The current scheme could easily be extended such that + * the enclosing root referenced a "forest" of trees. The underlying trees + * would be autonomous with respect to locks. + * + * Note that net_next is controlled by external locks + * particular to the data structure that the tree is being added to. + */ +typedef struct nfs4_ephemeral_tree { + mntinfo4_t *net_mount; + nfs4_ephemeral_t *net_root; + struct nfs4_ephemeral_tree *net_next; + kmutex_t net_tree_lock; + kmutex_t net_cnt_lock; + uint_t net_status; + uint_t net_refcnt; +} nfs4_ephemeral_tree_t; + +/* + * State for the tree (set in net_status): + */ +#define NFS4_EPHEMERAL_TREE_OK 0x0 +#define NFS4_EPHEMERAL_TREE_BUILDING 0x1 +#define NFS4_EPHEMERAL_TREE_DEROOTING 0x2 +#define NFS4_EPHEMERAL_TREE_INVALID 0x4 +#define NFS4_EPHEMERAL_TREE_MOUNTING 0x8 +#define NFS4_EPHEMERAL_TREE_UMOUNTING 0x10 +#define NFS4_EPHEMERAL_TREE_LOCKED 0x20 + +#define NFS4_EPHEMERAL_TREE_PROCESSING (NFS4_EPHEMERAL_TREE_DEROOTING | \ + NFS4_EPHEMERAL_TREE_INVALID | NFS4_EPHEMERAL_TREE_UMOUNTING | \ + NFS4_EPHEMERAL_TREE_LOCKED) + +/* + * This macro evaluates to non-zero if the given op releases state at the + * server. + */ +#define OH_IS_STATE_RELE(op) ((op) == OH_CLOSE || (op) == OH_LOCKU || \ + (op) == OH_DELEGRETURN) + +#ifdef _KERNEL + +extern void nfs4_async_manager(struct vfs *); +extern void nfs4_async_manager_stop(struct vfs *); +extern void nfs4_async_stop(struct vfs *); +extern int nfs4_async_stop_sig(struct vfs *); +extern int nfs4_async_readahead(vnode_t *, u_offset_t, caddr_t, + struct seg *, cred_t *, + void (*)(vnode_t *, u_offset_t, + caddr_t, struct seg *, cred_t *)); +extern int nfs4_async_putapage(vnode_t *, page_t *, u_offset_t, size_t, + int, cred_t *, int (*)(vnode_t *, page_t *, + u_offset_t, size_t, int, cred_t *)); +extern int nfs4_async_pageio(vnode_t *, page_t *, u_offset_t, size_t, + int, cred_t *, int (*)(vnode_t *, page_t *, + u_offset_t, size_t, int, cred_t *)); +extern void nfs4_async_commit(vnode_t *, page_t *, offset3, count3, + cred_t *, void (*)(vnode_t *, page_t *, + offset3, count3, cred_t *)); +extern void nfs4_async_inactive(vnode_t *, cred_t *); +extern void nfs4_inactive_thread(mntinfo4_t *mi); +extern void nfs4_inactive_otw(vnode_t *, cred_t *); +extern int nfs4_putpages(vnode_t *, u_offset_t, size_t, int, cred_t *); + +extern int nfs4_setopts(vnode_t *, model_t, struct nfs_args *); +extern void nfs4_mnt_kstat_init(struct vfs *); + +extern void rfs4call(struct mntinfo4 *, struct COMPOUND4args_clnt *, + struct COMPOUND4res_clnt *, cred_t *, int *, int, + nfs4_error_t *); +extern void nfs4_acl_fill_cache(struct rnode4 *, vsecattr_t *); +extern int nfs4_attr_otw(vnode_t *, nfs4_tag_type_t, + nfs4_ga_res_t *, bitmap4, cred_t *); + +extern void nfs4_attrcache_noinval(vnode_t *, nfs4_ga_res_t *, hrtime_t); +extern void nfs4_attr_cache(vnode_t *, nfs4_ga_res_t *, + hrtime_t, cred_t *, int, + change_info4 *); +extern void nfs4_purge_rddir_cache(vnode_t *); +extern void nfs4_invalidate_pages(vnode_t *, u_offset_t, cred_t *); +extern void nfs4_purge_caches(vnode_t *, int, cred_t *, int); +extern void nfs4_purge_stale_fh(int, vnode_t *, cred_t *); +extern void nfs4_flush_pages(vnode_t *vp, cred_t *cr); + +extern void nfs4rename_update(vnode_t *, vnode_t *, nfs_fh4 *, char *); +extern void nfs4_update_paths(vnode_t *, char *, vnode_t *, char *, + vnode_t *); + +extern void nfs4args_lookup_free(nfs_argop4 *, int); +extern void nfs4args_copen_free(OPEN4cargs *); + +extern void nfs4_printfhandle(nfs4_fhandle_t *); + +extern void nfs_free_mi4(mntinfo4_t *); +extern void sv4_free(servinfo4_t *); +extern void nfs4_mi_zonelist_add(mntinfo4_t *); +extern int nfs4_mi_zonelist_remove(mntinfo4_t *); +extern int nfs4_secinfo_recov(mntinfo4_t *, vnode_t *, vnode_t *); +extern void nfs4_secinfo_init(void); +extern void nfs4_secinfo_fini(void); +extern int nfs4_secinfo_path(mntinfo4_t *, cred_t *, int); +extern int nfs4_secinfo_vnode_otw(vnode_t *, char *, cred_t *); +extern void secinfo_free(sv_secinfo_t *); +extern void save_mnt_secinfo(servinfo4_t *); +extern void check_mnt_secinfo(servinfo4_t *, vnode_t *); +extern int vattr_to_fattr4(vattr_t *, vsecattr_t *, fattr4 *, int, + enum nfs_opnum4, bitmap4 supp_mask); +extern int nfs4_putapage(vnode_t *, page_t *, u_offset_t *, size_t *, + int, cred_t *); +extern void nfs4_write_error(vnode_t *, int, cred_t *); +extern void nfs4_lockcompletion(vnode_t *, int); +extern bool_t nfs4_map_lost_lock_conflict(vnode_t *); +extern int vtodv(vnode_t *, vnode_t **, cred_t *, bool_t); +extern int vtoname(vnode_t *, char *, ssize_t); +extern void nfs4open_confirm(vnode_t *, seqid4*, stateid4 *, cred_t *, + bool_t, bool_t *, nfs4_open_owner_t *, bool_t, + nfs4_error_t *, int *); +extern void nfs4_error_zinit(nfs4_error_t *); +extern void nfs4_error_init(nfs4_error_t *, int); +extern void nfs4_free_args(struct nfs_args *); + +extern void mi_hold(mntinfo4_t *); +extern void mi_rele(mntinfo4_t *); + +extern vnode_t *find_referral_stubvp(vnode_t *, char *, cred_t *); +extern int nfs4_setup_referral(vnode_t *, char *, vnode_t **, cred_t *); + +extern sec_data_t *copy_sec_data(sec_data_t *); +extern gss_clntdata_t *copy_sec_data_gss(gss_clntdata_t *); + +#ifdef DEBUG +extern int nfs4_consistent_type(vnode_t *); +#endif + +extern void nfs4_init_dot_entries(void); +extern void nfs4_destroy_dot_entries(void); +extern struct nfs4_callback_globals *nfs4_get_callback_globals(void); + +extern struct nfs4_server nfs4_server_lst; + +extern clock_t nfs_write_error_interval; + +#endif /* _KERNEL */ + +/* + * Flags for nfs4getfh_otw. + */ + +#define NFS4_GETFH_PUBLIC 0x01 +#define NFS4_GETFH_NEEDSOP 0x02 + +/* + * Found through rnodes. + * + * The os_open_ref_count keeps track the number of open file descriptor + * references on this data structure. It will be bumped for any successful + * OTW OPEN call and any OPEN call that determines the OTW call is not + * necessary and the open stream hasn't just been created (see + * nfs4_is_otw_open_necessary). + * + * os_mapcnt is a count of the number of mmapped pages for a particular + * open stream; this in conjunction w/ os_open_ref_count is used to + * determine when to do a close to the server. This is necessary because + * of the semantics of doing open, mmap, close; the OTW close must be wait + * until all open and mmap references have vanished. + * + * 'os_valid' tells us whether this structure is about to be freed or not, + * if it is then don't return it in find_open_stream(). + * + * 'os_final_close' is set when a CLOSE OTW was attempted. This is needed + * so we can properly count the os_open_ref_count in cases where we VOP_CLOSE + * without a VOP_OPEN, and have nfs4_inactive() drive the OTW CLOSE. It + * also helps differentiate the VOP_OPEN/VN_RELE case from the VOP_CLOSE + * that tried to close OTW but failed, and left the state cleanup to + * nfs4_inactive/CLOSE_FORCE. + * + * 'os_force_close' is used to let us know if an intervening thread came + * and reopened the open stream after we decided to issue a CLOSE_FORCE, + * but before we could actually process the CLOSE_FORCE. + * + * 'os_pending_close' is set when an over-the-wire CLOSE is deferred to the + * lost state queue. + * + * 'open_stateid' is set to the last open stateid returned by the server unless + * 'os_delegation' is 1, in which case 'open_stateid' refers to the + * delegation stateid returned by the server. This is used in cases where the + * client tries to OPEN a file but already has a suitable delegation, so we + * just stick the delegation stateid in the open stream. + * + * os_dc_openacc are open access bits which have been granted to the + * open stream by virtue of a delegation, but which have not been seen + * by the server. This applies even if the open stream does not have + * os_delegation set. These bits are used when setting file locks to + * determine whether an open with CLAIM_DELEGATE_CUR needs to be done + * before the lock request can be sent to the server. See + * nfs4frlock_check_deleg(). + * + * 'os_mmap_read/write' keep track of the read and write access our memory + * maps require. We need to keep track of this so we can provide the proper + * access bits in the open/mmap/close/reboot/reopen case. + * + * 'os_failed_reopen' tells us that we failed to successfully reopen this + * open stream; therefore, we should not use this open stateid as it is + * not valid anymore. This flag is also used to indicate an unsuccessful + * attempt to reopen a delegation open stream with CLAIM_DELEGATE_CUR. + * + * If 'os_orig_oo_name' is different than os_open_owner's oo_name + * then this tells us that this open stream's open owner used a + * bad seqid (that is, got NFS4ERR_BAD_SEQID). If different, this open + * stream will no longer be used for future OTW state releasing calls. + * + * Lock ordering: + * rnode4_t::r_os_lock > os_sync_lock + * os_sync_lock > rnode4_t::r_statelock + * os_sync_lock > rnode4_t::r_statev4_lock + * os_sync_lock > mntinfo4_t::mi_lock (via hold over rfs4call) + * + * The 'os_sync_lock' protects: + * open_stateid + * os_dc_openacc + * os_delegation + * os_failed_reopen + * os_final_close + * os_force_close + * os_mapcnt + * os_mmap_read + * os_mmap_write + * os_open_ref_count + * os_pending_close + * os_share_acc_read + * os_share_acc_write + * os_share_deny_none + * os_share_deny_read + * os_share_deny_write + * os_ref_count + * os_valid + * + * The rnode4_t::r_os_lock protects: + * os_node + * + * These fields are set at creation time and + * read only after that: + * os_open_owner + * os_orig_oo_name + */ +typedef struct nfs4_open_stream { + uint64_t os_share_acc_read; + uint64_t os_share_acc_write; + uint64_t os_mmap_read; + uint64_t os_mmap_write; + uint32_t os_share_deny_none; + uint32_t os_share_deny_read; + uint32_t os_share_deny_write; + stateid4 open_stateid; + int os_dc_openacc; + int os_ref_count; + unsigned os_valid:1; + unsigned os_delegation:1; + unsigned os_final_close:1; + unsigned os_pending_close:1; + unsigned os_failed_reopen:1; + unsigned os_force_close:1; + int os_open_ref_count; + long os_mapcnt; + list_node_t os_node; + struct nfs4_open_owner *os_open_owner; + uint64_t os_orig_oo_name; + kmutex_t os_sync_lock; +} nfs4_open_stream_t; + +/* + * This structure describes the format of the lock_owner_name + * field of the lock owner. + */ + +typedef struct nfs4_lo_name { + uint64_t ln_seq_num; + pid_t ln_pid; +} nfs4_lo_name_t; + +/* + * Flags for lo_flags. + */ +#define NFS4_LOCK_SEQID_INUSE 0x1 +#define NFS4_BAD_SEQID_LOCK 0x2 + +/* + * The lo_prev_rnode and lo_next_rnode are for a circular list that hangs + * off the rnode. If the links are NULL it means this object is not on the + * list. + * + * 'lo_pending_rqsts' is non-zero if we ever tried to send a request and + * didn't get a response back. This is used to figure out if we have + * possible remote v4 locks, so that we can clean up at process exit. In + * theory, the client should be able to figure out if the server received + * the request (based on what seqid works), so maybe we can get rid of this + * flag someday. + * + * 'lo_ref_count' tells us how many processes/threads are using this data + * structure. The rnode's list accounts for one reference. + * + * 'lo_just_created' is set to NFS4_JUST_CREATED when we first create the + * data structure. It is then set to NFS4_PERM_CREATED when a lock request + * is successful using this lock owner structure. We need to keep 'temporary' + * lock owners around so we can properly keep the lock seqid synchronization + * when multiple processes/threads are trying to create the lock owner for the + * first time (especially with the DENIED error case). Once + * 'lo_just_created' is set to NFS4_PERM_CREATED, it doesn't change. + * + * 'lo_valid' tells us whether this structure is about to be freed or not, + * if it is then don't return it from find_lock_owner(). + * + * Retrieving and setting of 'lock_seqid' is protected by the + * NFS4_LOCK_SEQID_INUSE flag. Waiters for NFS4_LOCK_SEQID_INUSE should + * use 'lo_cv_seqid_sync'. + * + * The setting of 'lock_stateid' is protected by the + * NFS4_LOCK_SEQID_INUSE flag and 'lo_lock'. The retrieving of the + * 'lock_stateid' is protected by 'lo_lock', with the additional + * requirement that the calling function can handle NFS4ERR_OLD_STATEID and + * NFS4ERR_BAD_STATEID as appropiate. + * + * The setting of NFS4_BAD_SEQID_LOCK to lo_flags tells us whether this lock + * owner used a bad seqid (that is, got NFS4ERR_BAD_SEQID). With this set, + * this lock owner will no longer be used for future OTW calls. Once set, + * it is never unset. + * + * Lock ordering: + * rnode4_t::r_statev4_lock > lo_lock + */ +typedef struct nfs4_lock_owner { + struct nfs4_lock_owner *lo_next_rnode; + struct nfs4_lock_owner *lo_prev_rnode; + int lo_pid; + stateid4 lock_stateid; + seqid4 lock_seqid; + /* + * Fix this to always be 12 bytes + */ + nfs4_lo_name_t lock_owner_name; + int lo_ref_count; + int lo_valid; + int lo_pending_rqsts; + int lo_just_created; + int lo_flags; + kcondvar_t lo_cv_seqid_sync; + kmutex_t lo_lock; + kthread_t *lo_seqid_holder; /* debugging aid */ +} nfs4_lock_owner_t; + +/* for nfs4_lock_owner_t lookups */ +typedef enum {LOWN_ANY, LOWN_VALID_STATEID} lown_which_t; + +/* Number of times to retry a call that fails with state independent error */ +#define NFS4_NUM_RECOV_RETRIES 3 + +typedef enum { + NO_SID, + DEL_SID, + LOCK_SID, + OPEN_SID, + SPEC_SID +} nfs4_stateid_type_t; + +typedef struct nfs4_stateid_types { + stateid4 d_sid; + stateid4 l_sid; + stateid4 o_sid; + nfs4_stateid_type_t cur_sid_type; +} nfs4_stateid_types_t; + +/* + * Per-zone data for dealing with callbacks. Included here solely for the + * benefit of MDB. + */ +struct nfs4_callback_stats { + kstat_named_t delegations; + kstat_named_t cb_getattr; + kstat_named_t cb_recall; + kstat_named_t cb_null; + kstat_named_t cb_dispatch; + kstat_named_t delegaccept_r; + kstat_named_t delegaccept_rw; + kstat_named_t delegreturn; + kstat_named_t callbacks; + kstat_named_t claim_cur; + kstat_named_t claim_cur_ok; + kstat_named_t recall_trunc; + kstat_named_t recall_failed; + kstat_named_t return_limit_write; + kstat_named_t return_limit_addmap; + kstat_named_t deleg_recover; + kstat_named_t cb_illegal; +}; + +struct nfs4_callback_globals { + kmutex_t nfs4_cb_lock; + kmutex_t nfs4_dlist_lock; + int nfs4_program_hint; + /* this table maps the program number to the nfs4_server structure */ + struct nfs4_server **nfs4prog2server; + list_t nfs4_dlist; + list_t nfs4_cb_ports; + struct nfs4_callback_stats nfs4_callback_stats; +#ifdef DEBUG + int nfs4_dlistadd_c; + int nfs4_dlistclean_c; +#endif +}; + +typedef enum { + CLOSE_NORM, + CLOSE_DELMAP, + CLOSE_FORCE, + CLOSE_RESEND, + CLOSE_AFTER_RESEND +} nfs4_close_type_t; + +/* + * Structure to hold the bad seqid information that is passed + * to the recovery framework. + */ +typedef struct nfs4_bseqid_entry { + nfs4_open_owner_t *bs_oop; + nfs4_lock_owner_t *bs_lop; + vnode_t *bs_vp; + pid_t bs_pid; + nfs4_tag_type_t bs_tag; + seqid4 bs_seqid; + list_node_t bs_node; +} nfs4_bseqid_entry_t; + +#ifdef _KERNEL + +extern void nfs4close_one(vnode_t *, nfs4_open_stream_t *, cred_t *, int, + nfs4_lost_rqst_t *, nfs4_error_t *, nfs4_close_type_t, + size_t, uint_t, uint_t); +extern void nfs4close_notw(vnode_t *, nfs4_open_stream_t *, int *); +extern void nfs4_set_lock_stateid(nfs4_lock_owner_t *, stateid4); +extern void open_owner_hold(nfs4_open_owner_t *); +extern void open_owner_rele(nfs4_open_owner_t *); +extern nfs4_open_stream_t *find_or_create_open_stream(nfs4_open_owner_t *, + struct rnode4 *, int *); +extern nfs4_open_stream_t *find_open_stream(nfs4_open_owner_t *, + struct rnode4 *); +extern nfs4_open_stream_t *create_open_stream(nfs4_open_owner_t *oop, + struct rnode4 *rp); +extern void open_stream_hold(nfs4_open_stream_t *); +extern void open_stream_rele(nfs4_open_stream_t *, struct rnode4 *); +extern int nfs4close_all(vnode_t *, cred_t *); +extern void lock_owner_hold(nfs4_lock_owner_t *); +extern void lock_owner_rele(nfs4_lock_owner_t *); +extern nfs4_lock_owner_t *create_lock_owner(struct rnode4 *, pid_t); +extern nfs4_lock_owner_t *find_lock_owner(struct rnode4 *, pid_t, lown_which_t); +extern void nfs4_rnode_remove_lock_owner(struct rnode4 *, + nfs4_lock_owner_t *); +extern void nfs4_flush_lock_owners(struct rnode4 *); +extern void nfs4_setlockowner_args(lock_owner4 *, struct rnode4 *, pid_t); +extern void nfs4_set_open_seqid(seqid4, nfs4_open_owner_t *, + nfs4_tag_type_t); +extern void nfs4_set_lock_seqid(seqid4, nfs4_lock_owner_t *); +extern void nfs4_get_and_set_next_open_seqid(nfs4_open_owner_t *, + nfs4_tag_type_t); +extern void nfs4_end_open_seqid_sync(nfs4_open_owner_t *); +extern int nfs4_start_open_seqid_sync(nfs4_open_owner_t *, mntinfo4_t *); +extern void nfs4_end_lock_seqid_sync(nfs4_lock_owner_t *); +extern int nfs4_start_lock_seqid_sync(nfs4_lock_owner_t *, mntinfo4_t *); +extern void nfs4_setup_lock_args(nfs4_lock_owner_t *, nfs4_open_owner_t *, + nfs4_open_stream_t *, clientid4, locker4 *); +extern void nfs4_destroy_open_owner(nfs4_open_owner_t *); + +extern void nfs4_renew_lease_thread(nfs4_server_t *); +extern nfs4_server_t *find_nfs4_server(mntinfo4_t *); +extern nfs4_server_t *find_nfs4_server_all(mntinfo4_t *, int all); +extern nfs4_server_t *new_nfs4_server(servinfo4_t *, cred_t *); +extern void nfs4_mark_srv_dead(nfs4_server_t *); +extern nfs4_server_t *servinfo4_to_nfs4_server(servinfo4_t *); +extern void nfs4_inc_state_ref_count(mntinfo4_t *); +extern void nfs4_inc_state_ref_count_nolock(nfs4_server_t *, + mntinfo4_t *); +extern void nfs4_dec_state_ref_count(mntinfo4_t *); +extern void nfs4_dec_state_ref_count_nolock(nfs4_server_t *, + mntinfo4_t *); +extern clientid4 mi2clientid(mntinfo4_t *); +extern int nfs4_server_in_recovery(nfs4_server_t *); +extern bool_t nfs4_server_vlock(nfs4_server_t *, int); +extern nfs4_open_owner_t *create_open_owner(cred_t *, mntinfo4_t *); +extern uint64_t nfs4_get_new_oo_name(void); +extern nfs4_open_owner_t *find_open_owner(cred_t *, int, mntinfo4_t *); +extern nfs4_open_owner_t *find_open_owner_nolock(cred_t *, int, mntinfo4_t *); +extern void nfs4frlock(nfs4_lock_call_type_t, vnode_t *, int, flock64_t *, + int, u_offset_t, cred_t *, nfs4_error_t *, + nfs4_lost_rqst_t *, int *); +extern void nfs4open_dg_save_lost_rqst(int, nfs4_lost_rqst_t *, + nfs4_open_owner_t *, nfs4_open_stream_t *, cred_t *, + vnode_t *, int, int); +extern void nfs4_open_downgrade(int, int, nfs4_open_owner_t *, + nfs4_open_stream_t *, vnode_t *, cred_t *, + nfs4_lost_rqst_t *, nfs4_error_t *, cred_t **, seqid4 *); +extern seqid4 nfs4_get_open_seqid(nfs4_open_owner_t *); +extern cred_t *nfs4_get_otw_cred(cred_t *, mntinfo4_t *, nfs4_open_owner_t *); +extern void nfs4_init_stateid_types(nfs4_stateid_types_t *); +extern void nfs4_save_stateid(stateid4 *, nfs4_stateid_types_t *); + +extern kmutex_t nfs4_server_lst_lock; + +extern void nfs4callback_destroy(nfs4_server_t *); +extern void nfs4_callback_init(void); +extern void nfs4_callback_fini(void); +extern void nfs4_cb_args(nfs4_server_t *, struct knetconfig *, + SETCLIENTID4args *); +extern void nfs4delegreturn_async(struct rnode4 *, int, bool_t); + +extern enum nfs4_delegreturn_policy nfs4_delegreturn_policy; + +extern void nfs4_add_mi_to_server(nfs4_server_t *, mntinfo4_t *); +extern void nfs4_remove_mi_from_server(mntinfo4_t *, nfs4_server_t *); +extern nfs4_server_t *nfs4_move_mi(mntinfo4_t *, servinfo4_t *, servinfo4_t *); +extern bool_t nfs4_fs_active(nfs4_server_t *); +extern void nfs4_server_rele(nfs4_server_t *); +extern bool_t inlease(nfs4_server_t *); +extern bool_t nfs4_has_pages(vnode_t *); +extern void nfs4_log_badowner(mntinfo4_t *, nfs_opnum4); + +#endif /* _KERNEL */ + +/* + * Client State Recovery + */ + +/* + * The following defines are used for rs_flags in + * a nfs4_recov_state_t structure. + * + * NFS4_RS_RENAME_HELD Indicates that the mi_rename_lock was held. + * NFS4_RS_GRACE_MSG Set once we have uprintf'ed a grace message. + * NFS4_RS_DELAY_MSG Set once we have uprintf'ed a delay message. + * NFS4_RS_RECALL_HELD1 r_deleg_recall_lock for vp1 was held. + * NFS4_RS_RECALL_HELD2 r_deleg_recall_lock for vp2 was held. + */ +#define NFS4_RS_RENAME_HELD 0x000000001 +#define NFS4_RS_GRACE_MSG 0x000000002 +#define NFS4_RS_DELAY_MSG 0x000000004 +#define NFS4_RS_RECALL_HELD1 0x000000008 +#define NFS4_RS_RECALL_HELD2 0x000000010 + +/* + * Information that is retrieved from nfs4_start_op() and that is + * passed into nfs4_end_op(). + * + * rs_sp is a reference to the nfs4_server that was found, or NULL. + * + * rs_num_retry_despite_err is the number times client retried an + * OTW op despite a recovery error. It is only incremented for hints + * exempt to normal R4RECOVERR processing + * (OH_CLOSE/OH_LOCKU/OH_DELEGRETURN). (XXX this special-case code + * needs review for possible removal.) + * It is initialized wherever nfs4_recov_state_t is declared -- usually + * very near initialization of rs_flags. + */ +typedef struct { + nfs4_server_t *rs_sp; + int rs_flags; + int rs_num_retry_despite_err; +} nfs4_recov_state_t; + +/* + * Flags for nfs4_check_remap, nfs4_remap_file and nfs4_remap_root. + */ + +#define NFS4_REMAP_CKATTRS 1 +#define NFS4_REMAP_NEEDSOP 2 + +#ifdef _KERNEL + +extern int nfs4_is_otw_open_necessary(nfs4_open_owner_t *, int, + vnode_t *, int, int *, int, nfs4_recov_state_t *); +extern void nfs4setclientid(struct mntinfo4 *, struct cred *, bool_t, + nfs4_error_t *); +extern void nfs4_reopen(vnode_t *, nfs4_open_stream_t *, nfs4_error_t *, + open_claim_type4, bool_t, bool_t); +extern void nfs4_remap_root(struct mntinfo4 *, nfs4_error_t *, int); +extern void nfs4_check_remap(mntinfo4_t *mi, vnode_t *vp, int, + nfs4_error_t *); +extern void nfs4_remap_file(mntinfo4_t *mi, vnode_t *vp, int, + nfs4_error_t *); +extern int nfs4_make_dotdot(struct nfs4_sharedfh *, hrtime_t, + vnode_t *, cred_t *, vnode_t **, int); +extern void nfs4_fail_recov(vnode_t *, char *, int, nfsstat4); + +extern int nfs4_needs_recovery(nfs4_error_t *, bool_t, vfs_t *); +extern int nfs4_recov_marks_dead(nfsstat4); +extern bool_t nfs4_start_recovery(nfs4_error_t *, struct mntinfo4 *, + vnode_t *, vnode_t *, stateid4 *, + nfs4_lost_rqst_t *, nfs_opnum4, nfs4_bseqid_entry_t *, + vnode_t *, char *); +extern int nfs4_start_op(struct mntinfo4 *, vnode_t *, vnode_t *, + nfs4_recov_state_t *); +extern void nfs4_end_op(struct mntinfo4 *, vnode_t *, vnode_t *, + nfs4_recov_state_t *, bool_t); +extern int nfs4_start_fop(struct mntinfo4 *, vnode_t *, vnode_t *, + nfs4_op_hint_t, nfs4_recov_state_t *, bool_t *); +extern void nfs4_end_fop(struct mntinfo4 *, vnode_t *, vnode_t *, + nfs4_op_hint_t, nfs4_recov_state_t *, bool_t); +extern char *nfs4_recov_action_to_str(nfs4_recov_t); + +/* + * In sequence, code desiring to unmount an ephemeral tree must + * call nfs4_ephemeral_umount, nfs4_ephemeral_umount_activate, + * and nfs4_ephemeral_umount_unlock. The _unlock must also be + * called on all error paths that occur before it would naturally + * be invoked. + * + * The caller must also provde a pointer to a boolean to keep track + * of whether or not the code in _unlock is to be ran. + */ +extern void nfs4_ephemeral_umount_activate(mntinfo4_t *, + bool_t *, nfs4_ephemeral_tree_t **); +extern int nfs4_ephemeral_umount(mntinfo4_t *, int, cred_t *, + bool_t *, nfs4_ephemeral_tree_t **); +extern void nfs4_ephemeral_umount_unlock(bool_t *, + nfs4_ephemeral_tree_t **); + +extern int nfs4_record_ephemeral_mount(mntinfo4_t *mi, vnode_t *mvp); + +extern int nfs4_callmapid(utf8string *, struct nfs_fsl_info *); +extern int nfs4_fetch_locations(mntinfo4_t *, struct nfs4_sharedfh *, + char *, cred_t *, nfs4_ga_res_t *, COMPOUND4res_clnt *, bool_t); + +extern int wait_for_recall(vnode_t *, vnode_t *, nfs4_op_hint_t, + nfs4_recov_state_t *); +extern void nfs4_end_op_recall(vnode_t *, vnode_t *, nfs4_recov_state_t *); +extern void nfs4_send_siglost(pid_t, mntinfo4_t *mi, vnode_t *vp, bool_t, + int, nfsstat4); +extern time_t nfs4err_delay_time; +extern void nfs4_set_grace_wait(mntinfo4_t *); +extern void nfs4_set_delay_wait(vnode_t *); +extern int nfs4_wait_for_grace(mntinfo4_t *, nfs4_recov_state_t *); +extern int nfs4_wait_for_delay(vnode_t *, nfs4_recov_state_t *); +extern nfs4_bseqid_entry_t *nfs4_create_bseqid_entry(nfs4_open_owner_t *, + nfs4_lock_owner_t *, vnode_t *, pid_t, nfs4_tag_type_t, + seqid4); + +extern void nfs4_resend_open_otw(vnode_t **, nfs4_lost_rqst_t *, + nfs4_error_t *); +extern void nfs4_resend_delegreturn(nfs4_lost_rqst_t *, nfs4_error_t *, + nfs4_server_t *); +extern int nfs4_rpc_retry_error(int); +extern int nfs4_try_failover(nfs4_error_t *); +extern void nfs4_free_msg(nfs4_debug_msg_t *); +extern void nfs4_mnt_recov_kstat_init(vfs_t *); +extern void nfs4_mi_kstat_inc_delay(mntinfo4_t *); +extern void nfs4_mi_kstat_inc_no_grace(mntinfo4_t *); +extern char *nfs4_stat_to_str(nfsstat4); +extern char *nfs4_op_to_str(nfs_opnum4); + +extern void nfs4_queue_event(nfs4_event_type_t, mntinfo4_t *, char *, + uint_t, vnode_t *, vnode_t *, nfsstat4, char *, pid_t, + nfs4_tag_type_t, nfs4_tag_type_t, seqid4, seqid4); +extern void nfs4_queue_fact(nfs4_fact_type_t, mntinfo4_t *, nfsstat4, + nfs4_recov_t, nfs_opnum4, bool_t, char *, int, vnode_t *); +#pragma rarely_called(nfs4_queue_event) +#pragma rarely_called(nfs4_queue_fact) + +/* Used for preformed "." and ".." dirents */ +extern char *nfs4_dot_entries; +extern char *nfs4_dot_dot_entry; + +#ifdef DEBUG +extern uint_t nfs4_tsd_key; +#endif + +#endif /* _KERNEL */ + +/* + * Filehandle management. + * + * Filehandles can change in v4, so rather than storing the filehandle + * directly in the rnode, etc., we manage the filehandle through one of + * these objects. + * Locking: sfh_fh and sfh_tree is protected by the filesystem's + * mi_fh_lock. The reference count and flags are protected by sfh_lock. + * sfh_mi is read-only. + * + * mntinfo4_t::mi_fh_lock > sfh_lock. + */ + +typedef struct nfs4_sharedfh { + nfs_fh4 sfh_fh; /* key and current filehandle */ + kmutex_t sfh_lock; + uint_t sfh_refcnt; /* reference count */ + uint_t sfh_flags; + mntinfo4_t *sfh_mi; /* backptr to filesystem */ + avl_node_t sfh_tree; /* used by avl package */ +} nfs4_sharedfh_t; + +#define SFH4_SAME(sfh1, sfh2) ((sfh1) == (sfh2)) + +/* + * Flags. + */ +#define SFH4_IN_TREE 0x1 /* currently in an AVL tree */ + +#ifdef _KERNEL + +extern void sfh4_createtab(avl_tree_t *); +extern nfs4_sharedfh_t *sfh4_get(const nfs_fh4 *, mntinfo4_t *); +extern nfs4_sharedfh_t *sfh4_put(const nfs_fh4 *, mntinfo4_t *, + nfs4_sharedfh_t *); +extern void sfh4_update(nfs4_sharedfh_t *, const nfs_fh4 *); +extern void sfh4_copyval(const nfs4_sharedfh_t *, nfs4_fhandle_t *); +extern void sfh4_hold(nfs4_sharedfh_t *); +extern void sfh4_rele(nfs4_sharedfh_t **); +extern void sfh4_printfhandle(const nfs4_sharedfh_t *); + +#endif + +/* + * Path and file name management. + * + * This type stores the name of an entry in the filesystem and keeps enough + * information that it can provide a complete path. All fields are + * protected by fn_lock, except for the reference count, which is managed + * using atomic add/subtract. + * + * Additionally shared filehandle for this fname is stored. + * Normally, fn_get() when it creates this fname stores the passed in + * shared fh in fn_sfh by doing sfh_hold. Similarly the path which + * destroys this fname releases the reference on this fh by doing sfh_rele. + * + * fn_get uses the fn_sfh to refine the comparision in cases + * where we have matched the name but have differing file handles, + * this normally happens due to + * + * 1. Server side rename of a file/directory. + * 2. Another client renaming a file/directory on the server. + * + * Differing names but same filehandle is possible as in the case of hardlinks, + * but differing filehandles with same name component will later confuse + * the client and can cause various panics. + * + * Lock order: child and then parent. + */ + +typedef struct nfs4_fname { + struct nfs4_fname *fn_parent; /* parent name; null if fs root */ + char *fn_name; /* the actual name */ + ssize_t fn_len; /* strlen(fn_name) */ + uint32_t fn_refcnt; /* reference count */ + kmutex_t fn_lock; + avl_node_t fn_tree; + avl_tree_t fn_children; /* children, if any */ + nfs4_sharedfh_t *fn_sfh; /* The fh for this fname */ +} nfs4_fname_t; + +#ifdef _KERNEL + +extern vnode_t nfs4_xattr_notsupp_vnode; +#define NFS4_XATTR_DIR_NOTSUPP &nfs4_xattr_notsupp_vnode + +extern nfs4_fname_t *fn_get(nfs4_fname_t *, char *, nfs4_sharedfh_t *); +extern void fn_hold(nfs4_fname_t *); +extern void fn_rele(nfs4_fname_t **); +extern char *fn_name(nfs4_fname_t *); +extern char *fn_path(nfs4_fname_t *); +extern void fn_move(nfs4_fname_t *, nfs4_fname_t *, char *); +extern nfs4_fname_t *fn_parent(nfs4_fname_t *); + +/* Referral Support */ +extern int nfs4_process_referral(mntinfo4_t *, nfs4_sharedfh_t *, char *, + cred_t *, nfs4_ga_res_t *, COMPOUND4res_clnt *, struct nfs_fsl_info *); + +#endif + +/* + * Per-zone data for managing client handles, included in this file for the + * benefit of MDB. + */ +struct nfs4_clnt { + struct chhead *nfscl_chtable4; + kmutex_t nfscl_chtable4_lock; + zoneid_t nfscl_zoneid; + list_node_t nfscl_node; + struct clstat4 nfscl_stat; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS4_CLNT_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs4_db_impl.h b/illumos-x86_64/usr/include/nfs/nfs4_db_impl.h new file mode 100644 index 00000000..291e4651 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs4_db_impl.h @@ -0,0 +1,177 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NFS4_DB_IMPL_H +#define _NFS4_DB_IMPL_H + +/* + * This is a private header file. Applications should not directly include + * this file. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SEARCH_DEBUG 0x0001 +#define CREATE_DEBUG 0x0002 +#define CACHED_DEBUG 0x0004 +#define DESTROY_DEBUG 0x0008 +#define REAP_DEBUG 0x0010 +#define OTHER_DEBUG 0x0020 +#define WALK_DEBUG 0x0040 + +/* + * A database is made up of a collection of tables. + * Tables are in turn made up of a collection of + * entries. Each table may haveone or more indices + * associtated with it. + */ + +/* Private implementation */ +typedef struct rfs4_link { + struct rfs4_link *next; + struct rfs4_link *prev; + rfs4_dbe_t *entry; +} rfs4_link_t; + +struct rfs4_dbe { + kmutex_t dbe_lock[1]; /* Exclusive lock for entry */ + uint32_t dbe_refcnt; /* # of references */ + unsigned dbe_skipsearch:1; /* skip search */ + unsigned dbe_invalid:1; /* invalid/"freed" entry */ + unsigned dbe_reserved:31; + time_t dbe_time_rele; /* Time of last rele */ + id_t dbe_id; /* unique identifier */ + kcondvar_t dbe_cv[1]; + rfs4_entry_t dbe_data; + rfs4_table_t *dbe_table; + rfs4_link_t dbe_indices[1]; /* Array of indices for entry */ +}; + +typedef struct rfs4_bucket { + krwlock_t dbk_lock[1]; /* lock hash chain */ + rfs4_link_t *dbk_head; +} rfs4_bucket_t; + +struct rfs4_index { + uint32_t dbi_tblidx; /* which indice in entry */ + bool_t dbi_createable; /* Can create entries */ + rfs4_table_t *dbi_table; /* Pointer to table */ + char *dbi_keyname; /* String rep of key */ + rfs4_bucket_t *dbi_buckets; /* Hash buckets */ + uint32_t (*dbi_hash)(void *); /* Given key find bucket */ + bool_t (*dbi_compare)(rfs4_entry_t, void *); /* Key match entry? */ + void *(*dbi_mkkey)(rfs4_entry_t); /* Given data generate a key */ + struct rfs4_index *dbi_inext; /* next index on table */ +}; + +struct rfs4_table { + rfs4_table_t *dbt_tnext; /* next table in db */ + struct rfs4_database *dbt_db; /* db that holds this table */ + krwlock_t dbt_t_lock[1]; /* lock table for resize */ + kmutex_t dbt_lock[1]; /* mutex for count and cached */ + char *dbt_name; /* Table name */ + id_space_t *dbt_id_space; /* space for unique entry ids */ + time_t dbt_min_cache_time; /* How long to cache entries */ + time_t dbt_max_cache_time; /* How long to cache entries */ + uint32_t dbt_usize; /* User entry size */ + uint32_t dbt_maxentries; /* max # of entries in table */ + uint32_t dbt_len; /* # of buckets in table */ + uint32_t dbt_count; /* # of entries in table */ + uint32_t dbt_idxcnt; /* # of indices in table */ + uint32_t dbt_maxcnt; /* max # of indices */ + uint32_t dbt_ccnt; /* # of creatable entries */ + uint32_t dbt_id_lwat; /* lo wtrmrk; 50% ids in use */ + uint32_t dbt_id_hwat; /* hi wtrmrk; 75% ids in use */ + time_t dbt_id_reap; /* table's reap interval */ + rfs4_index_t *dbt_indices; /* list of indices */ + /* Given entry and data construct entry */ + bool_t (*dbt_create)(rfs4_entry_t, void *data); + void (*dbt_destroy)(rfs4_entry_t); /* Destroy entry */ + bool_t (*dbt_expiry)(rfs4_entry_t); /* Has this entry expired */ + kmem_cache_t *dbt_mem_cache; /* Cache for table entries */ + uint32_t dbt_debug; /* Debug Flags */ + /* set of vars used for managing the reaper thread */ + unsigned dbt_reaper_shutdown:1; /* table shutting down? */ + kcondvar_t dbt_reaper_wait; /* reaper thread waits here */ + kmutex_t dbt_reaper_cv_lock; /* lock used for cpr wait */ + callb_cpr_t dbt_reaper_cpr_info; /* cpr the reaper thread */ +}; + +struct rfs4_database { + kmutex_t db_lock[1]; + uint32_t db_debug_flags; /* Table debug flags to set */ + uint32_t db_shutdown_count; /* count to manage shutdown */ + kcondvar_t db_shutdown_wait; /* where the shutdown waits */ + rfs4_table_t *db_tables; /* list of tables in db */ +}; + +#define RFS4_RECLAIM_PERCENT 10 +#define RFS4_REAP_INTERVAL 300 + +#define HASH(idx, key) (idx->dbi_hash(key) % idx->dbi_table->dbt_len) + +#define ENQUEUE(head, l) { \ + (l)->prev = NULL; \ + (l)->next = (head); \ + if ((l)->next) \ + (l)->next->prev = (l); \ + (head) = (l); \ +} + +#define DEQUEUE(head, l) { \ + if ((l)->prev) \ + (l)->prev->next = (l)->next; \ + else \ + (head) = (l)->next; \ + if ((l)->next) \ + (l)->next->prev = (l)->prev; \ +} + +#define INVALIDATE_ADDR(a) ((a) = (void *)((unsigned long)(a) | 1L)) +#define VALIDATE_ADDR(a) ((a) = (void *)((unsigned long)(a) & ~1L)) +#define INVALID_ADDR(a) (((unsigned long)(a) & 1L)) +#define INVALID_LINK(l) (INVALID_ADDR(l->entry)) + +#define ENQUEUE_IDX(bp, l) { \ + rw_enter((bp)->dbk_lock, RW_WRITER); \ + ENQUEUE((bp)->dbk_head, l); \ + VALIDATE_ADDR((l)->entry); \ + rw_exit((bp)->dbk_lock); \ +} + +#define DEQUEUE_IDX(bp, l) { \ + rw_enter((bp)->dbk_lock, RW_WRITER); \ + INVALIDATE_ADDR((l)->entry); \ + DEQUEUE((bp)->dbk_head, l); \ + rw_exit((bp)->dbk_lock); \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS4_DB_IMPL_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs4_idmap_impl.h b/illumos-x86_64/usr/include/nfs/nfs4_idmap_impl.h new file mode 100644 index 00000000..f0f16668 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs4_idmap_impl.h @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _NFS4_IDMAP_IMPL_H +#define _NFS4_IDMAP_IMPL_H + +#include +#include +#include + +/* + * This is a private header file. Applications should not directly include + * this file. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Cache Entry Definitions + */ +#define NFSID_CACHE_ANCHORS PKP_HASH_SIZE + +typedef struct nfsidmap { + struct nfsidmap *id_chain[2]; /* must be first */ + time_t id_time; /* time stamp */ + uid_t id_no; /* uid/gid */ + utf8string id_str; /* user@domain string */ +} nfsidmap_t; + +#define id_forw id_chain[0] +#define id_back id_chain[1] +#define id_len id_str.utf8string_len +#define id_val id_str.utf8string_val + +typedef struct nfsidhq { + union { + struct nfsidhq *hq_head[2]; /* for empty queue */ + struct nfsidmap *hq_chain[2]; /* for LRU list */ + } hq_link; + kmutex_t hq_lock; /* protects hash queue */ +} nfsidhq_t; + +#define hq_que_forw hq_link.hq_head[0] +#define hq_que_back hq_link.hq_head[1] +#define hq_lru_forw hq_link.hq_chain[0] +#define hq_lru_back hq_link.hq_chain[1] + +typedef struct { + const char *name; /* cache name */ + nfsidhq_t *table; /* hash table */ + /* + * Since we need to know the status of nfsmapid from random functions + * that deal with idmap caches, we keep a pointer to the relevant fields + * in the zone's globals so we don't have to keep passing them around. + */ + door_handle_t *nfsidmap_daemon_dh; +} idmap_cache_info_t; + +typedef enum hash_stat { HQ_HASH_HINT, HQ_HASH_FIND } hash_stat; + +/* + * Per-zone modular globals + */ +struct nfsidmap_globals { + list_node_t nig_link; /* linkage into global list */ + enum clnt_stat nig_last_stat; /* status of last RPC call */ + int nig_msg_done; /* have we printed a message? */ + idmap_cache_info_t u2s_ci; /* table mapping uid-to-string */ + idmap_cache_info_t s2u_ci; /* table mapping string-to-uid */ + idmap_cache_info_t g2s_ci; /* table mapping groupid-to-string */ + idmap_cache_info_t s2g_ci; /* table mapping string-to-groupid */ + pid_t nfsidmap_pid; + kmutex_t nfsidmap_daemon_lock; + /* + * nfsidmap_daemon_lock protects the following: + * nfsidmap_daemon_dh + */ + door_handle_t nfsidmap_daemon_dh; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS4_IDMAP_IMPL_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs4_kprot.h b/illumos-x86_64/usr/include/nfs/nfs4_kprot.h new file mode 100644 index 00000000..61eb37e8 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs4_kprot.h @@ -0,0 +1,4189 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2020-2025 RackTop Systems, Inc. + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NFS4_KPROT_H +#define _NFS4_KPROT_H + +/* + * Kernel specific version. + * NFS Version 4 protocol definitions. From nfs4_prot.x RFC 5662 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#ifdef _KERNEL +#include +#endif +#include + +#include +typedef struct authsys_parms authsys_parms; + +#define NFS4_FHSIZE 128 +#define NFS4_VERIFIER_SIZE 8 +#define NFS4_OTHER_SIZE 12 + +/* + * Reasonable upper bounds to catch badly behaving partners + */ +#define NFS4_OPAQUE_LIMIT 1024 +#define NFS4_COMPOUND_LIMIT 2048 +#define NFS4_FS_LOCATIONS_LIMIT 65536 +#define NFS4_ACL_LIMIT 65536 +#define NFS4_SECINFO_LIMIT 65536 +#define NFS4_FATTR4_LIMIT 1048576 +#define NFS4_DATA_LIMIT 134217728 + +#define NFS4_SESSIONID_SIZE 16 + +enum nfs_ftype4 { + NF4REG = 1, + NF4DIR = 2, + NF4BLK = 3, + NF4CHR = 4, + NF4LNK = 5, + NF4SOCK = 6, + NF4FIFO = 7, + NF4ATTRDIR = 8, + NF4NAMEDATTR = 9 +}; +typedef enum nfs_ftype4 nfs_ftype4; + +enum nfsstat4 { + NFS4_OK = 0, + NFS4ERR_PERM = 1, + NFS4ERR_NOENT = 2, + NFS4ERR_IO = 5, + NFS4ERR_NXIO = 6, + NFS4ERR_ACCESS = 13, + NFS4ERR_EXIST = 17, + NFS4ERR_XDEV = 18, + NFS4ERR_NOTDIR = 20, + NFS4ERR_ISDIR = 21, + NFS4ERR_INVAL = 22, + NFS4ERR_FBIG = 27, + NFS4ERR_NOSPC = 28, + NFS4ERR_ROFS = 30, + NFS4ERR_MLINK = 31, + NFS4ERR_NAMETOOLONG = 63, + NFS4ERR_NOTEMPTY = 66, + NFS4ERR_DQUOT = 69, + NFS4ERR_STALE = 70, + NFS4ERR_BADHANDLE = 10001, + NFS4ERR_BAD_COOKIE = 10003, + NFS4ERR_NOTSUPP = 10004, + NFS4ERR_TOOSMALL = 10005, + NFS4ERR_SERVERFAULT = 10006, + NFS4ERR_BADTYPE = 10007, + NFS4ERR_DELAY = 10008, + NFS4ERR_SAME = 10009, + NFS4ERR_DENIED = 10010, + NFS4ERR_EXPIRED = 10011, + NFS4ERR_LOCKED = 10012, + NFS4ERR_GRACE = 10013, + NFS4ERR_FHEXPIRED = 10014, + NFS4ERR_SHARE_DENIED = 10015, + NFS4ERR_WRONGSEC = 10016, + NFS4ERR_CLID_INUSE = 10017, + NFS4ERR_RESOURCE = 10018, + NFS4ERR_MOVED = 10019, + NFS4ERR_NOFILEHANDLE = 10020, + NFS4ERR_MINOR_VERS_MISMATCH = 10021, + NFS4ERR_STALE_CLIENTID = 10022, + NFS4ERR_STALE_STATEID = 10023, + NFS4ERR_OLD_STATEID = 10024, + NFS4ERR_BAD_STATEID = 10025, + NFS4ERR_BAD_SEQID = 10026, + NFS4ERR_NOT_SAME = 10027, + NFS4ERR_LOCK_RANGE = 10028, + NFS4ERR_SYMLINK = 10029, + NFS4ERR_RESTOREFH = 10030, + NFS4ERR_LEASE_MOVED = 10031, + NFS4ERR_ATTRNOTSUPP = 10032, + NFS4ERR_NO_GRACE = 10033, + NFS4ERR_RECLAIM_BAD = 10034, + NFS4ERR_RECLAIM_CONFLICT = 10035, + NFS4ERR_BADXDR = 10036, + NFS4ERR_LOCKS_HELD = 10037, + NFS4ERR_OPENMODE = 10038, + NFS4ERR_BADOWNER = 10039, + NFS4ERR_BADCHAR = 10040, + NFS4ERR_BADNAME = 10041, + NFS4ERR_BAD_RANGE = 10042, + NFS4ERR_LOCK_NOTSUPP = 10043, + NFS4ERR_OP_ILLEGAL = 10044, + NFS4ERR_DEADLOCK = 10045, + NFS4ERR_FILE_OPEN = 10046, + NFS4ERR_ADMIN_REVOKED = 10047, + NFS4ERR_CB_PATH_DOWN = 10048, + NFS4ERR_BADIOMODE = 10049, /* nfsv4.1 */ + NFS4ERR_BADLAYOUT = 10050, + NFS4ERR_BAD_SESSION_DIGEST = 10051, + NFS4ERR_BADSESSION = 10052, + NFS4ERR_BADSLOT = 10053, + NFS4ERR_COMPLETE_ALREADY = 10054, + NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055, + NFS4ERR_DELEG_ALREADY_WANTED = 10056, + NFS4ERR_BACK_CHAN_BUSY = 10057, + NFS4ERR_LAYOUTTRYLATER = 10058, + NFS4ERR_LAYOUTUNAVAILABLE = 10059, + NFS4ERR_NOMATCHING_LAYOUT = 10060, + NFS4ERR_RECALLCONFLICT = 10061, + NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062, + NFS4ERR_SEQ_MISORDERED = 10063, + NFS4ERR_SEQUENCE_POS = 10064, + NFS4ERR_REQ_TOO_BIG = 10065, + NFS4ERR_REP_TOO_BIG = 10066, + NFS4ERR_REP_TOO_BIG_TO_CACHE = 10067, + NFS4ERR_RETRY_UNCACHED_REP = 10068, + NFS4ERR_UNSAFE_COMPOUND = 10069, + NFS4ERR_TOO_MANY_OPS = 10070, + NFS4ERR_OP_NOT_IN_SESSION = 10071, + NFS4ERR_HASH_ALG_UNSUPP = 10072, + NFS4ERR_CLIENTID_BUSY = 10074, + NFS4ERR_PNFS_IO_HOLE = 10075, + NFS4ERR_SEQ_FALSE_RETRY = 10076, + NFS4ERR_BAD_HIGH_SLOT = 10077, + NFS4ERR_DEADSESSION = 10078, + NFS4ERR_ENCR_ALG_UNSUPP = 10079, + NFS4ERR_PNFS_NO_LAYOUT = 10080, + NFS4ERR_NOT_ONLY_OP = 10081, + NFS4ERR_WRONG_CRED = 10082, + NFS4ERR_WRONG_TYPE = 10083, + NFS4ERR_DIRDELEG_UNAVAIL = 10084, + NFS4ERR_REJECT_DELEG = 10085, + NFS4ERR_RETURNCONFLICT = 10086, + NFS4ERR_DELEG_REVOKED = 10087, + NFS4ERR_PARTNER_NOTSUPP = 10088, + NFS4ERR_PARTNER_NO_AUTH = 10089, + NFS4ERR_UNION_NOTSUPP = 10090, + NFS4ERR_OFFLOAD_DENIED = 10091, + NFS4ERR_WRONG_LFS = 10092, + NFS4ERR_BADLABEL = 10093, + NFS4ERR_OFFLOAD_NO_REQS = 10094, + + /* for internal use */ + NFS4ERR_REPLAY_CACHE = 30000 +}; +typedef enum nfsstat4 nfsstat4; + +/* + * A bitmap can only be 56 bits, treat it as a uint64_t for now + */ +typedef uint64_t bitmap4; + +typedef struct { + uint_t attrlist4_len; + char *attrlist4_val; +} attrlist4; + +typedef uint64_t offset4; + +typedef uint32_t count4; + +typedef uint64_t length4; + +typedef uint64_t clientid4; + +typedef uint32_t nfs_lease4; + +typedef uint32_t seqid4; + +typedef uint32_t sequenceid4; + +typedef char sessionid4[NFS4_SESSIONID_SIZE]; + +typedef uint32_t slotid4; + +typedef struct { + uint_t utf8string_len; + char *utf8string_val; +} utf8string; + +typedef utf8string component4; + +typedef utf8string utf8str_cis; + +typedef utf8string utf8str_cs; + +typedef utf8string utf8str_mixed; + +typedef struct { + uint_t pathname4_len; + component4 *pathname4_val; +} pathname4; + +typedef uint64_t nfs_cookie4; + +typedef struct { + uint_t linktext4_len; + char *linktext4_val; +} linktext4; + +typedef utf8string ascii_REQUIRED4; + +typedef struct { + uint_t sec_oid4_len; + char *sec_oid4_val; +} sec_oid4; + +typedef uint32_t qop4; + +typedef uint32_t mode4; + +typedef uint64_t changeid4; + +typedef uint64_t verifier4; + +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; +typedef struct nfstime4 nfstime4; + +enum time_how4 { + SET_TO_SERVER_TIME4 = 0, + SET_TO_CLIENT_TIME4 = 1 +}; +typedef enum time_how4 time_how4; + +struct settime4 { + time_how4 set_it; + nfstime4 time; +}; +typedef struct settime4 settime4; + +typedef struct { + uint_t nfs_fh4_len; + char *nfs_fh4_val; +} nfs_fh4; + +struct fsid4 { + uint64_t major; + uint64_t minor; +}; +typedef struct fsid4 fsid4; + +struct change_policy4 { + uint64_t cp_major; + uint64_t cp_minor; +}; +typedef struct change_policy4 change_policy4; + +struct fs_location4 { + uint_t server_len; + utf8string *server_val; + pathname4 rootpath; +}; +typedef struct fs_location4 fs_location4; + +struct fs_locations4 { + pathname4 fs_root; + uint_t locations_len; + fs_location4 *locations_val; +}; +typedef struct fs_locations4 fs_locations4; + +/* + * This structure is declared in nfs4.h + */ +struct nfs_fsl_info; + +/* + * ACL support + */ + +#define ACL4_SUPPORT_ALLOW_ACL 0x00000001 +#define ACL4_SUPPORT_DENY_ACL 0x00000002 +#define ACL4_SUPPORT_AUDIT_ACL 0x00000004 +#define ACL4_SUPPORT_ALARM_ACL 0x00000008 + +typedef uint32_t acetype4; +#define ACE4_ACCESS_ALLOWED_ACE_TYPE 0x00000000 +#define ACE4_ACCESS_DENIED_ACE_TYPE 0x00000001 +#define ACE4_SYSTEM_AUDIT_ACE_TYPE 0x00000002 +#define ACE4_SYSTEM_ALARM_ACE_TYPE 0x00000003 + +typedef uint32_t aceflag4; +#define ACE4_FILE_INHERIT_ACE 0x00000001 +#define ACE4_DIRECTORY_INHERIT_ACE 0x00000002 +#define ACE4_NO_PROPAGATE_INHERIT_ACE 0x00000004 +#define ACE4_INHERIT_ONLY_ACE 0x00000008 +#define ACE4_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010 +#define ACE4_FAILED_ACCESS_ACE_FLAG 0x00000020 +#define ACE4_IDENTIFIER_GROUP 0x00000040 +#define ACE4_INHERITED_ACE 0x00000080 + +/* + * This defines all valid flag bits, as defined by RFC 7530. If + * any additional flag bits are deemed part of the NFSv4 spec, + * you must also add them to the definition below. + */ +#define ACE4_VALID_FLAG_BITS (\ + ACE4_FILE_INHERIT_ACE | \ + ACE4_DIRECTORY_INHERIT_ACE | \ + ACE4_NO_PROPAGATE_INHERIT_ACE | \ + ACE4_INHERIT_ONLY_ACE | \ + ACE4_SUCCESSFUL_ACCESS_ACE_FLAG | \ + ACE4_FAILED_ACCESS_ACE_FLAG | \ + ACE4_IDENTIFIER_GROUP) + +typedef uint32_t acemask4; +#define ACE4_READ_DATA 0x00000001 +#define ACE4_LIST_DIRECTORY 0x00000001 +#define ACE4_WRITE_DATA 0x00000002 +#define ACE4_ADD_FILE 0x00000002 +#define ACE4_APPEND_DATA 0x00000004 +#define ACE4_ADD_SUBDIRECTORY 0x00000004 +#define ACE4_READ_NAMED_ATTRS 0x00000008 +#define ACE4_WRITE_NAMED_ATTRS 0x00000010 +#define ACE4_EXECUTE 0x00000020 +#define ACE4_DELETE_CHILD 0x00000040 +#define ACE4_READ_ATTRIBUTES 0x00000080 +#define ACE4_WRITE_ATTRIBUTES 0x00000100 +#define ACE4_WRITE_RETENTION 0x00000200 +#define ACE4_WRITE_RETENTION_HOLD 0x00000400 +#define ACE4_DELETE 0x00010000 +#define ACE4_READ_ACL 0x00020000 +#define ACE4_WRITE_ACL 0x00040000 +#define ACE4_WRITE_OWNER 0x00080000 +#define ACE4_SYNCHRONIZE 0x00100000 +#define ACE4_GENERIC_READ 0x00120081 +#define ACE4_GENERIC_WRITE 0x00160106 +#define ACE4_GENERIC_EXECUTE 0x001200A0 +/* + * This defines all valid access mask bits, as defined by RFC 7530. If + * any additional access mask bits are deemed part of the NFSv4 spec, + * you must also add them to the definition below. + */ +#define ACE4_VALID_MASK_BITS (\ + ACE4_READ_DATA | \ + ACE4_LIST_DIRECTORY | \ + ACE4_WRITE_DATA | \ + ACE4_ADD_FILE | \ + ACE4_APPEND_DATA | \ + ACE4_ADD_SUBDIRECTORY | \ + ACE4_READ_NAMED_ATTRS | \ + ACE4_WRITE_NAMED_ATTRS | \ + ACE4_EXECUTE | \ + ACE4_DELETE_CHILD | \ + ACE4_READ_ATTRIBUTES | \ + ACE4_WRITE_ATTRIBUTES | \ + ACE4_DELETE | \ + ACE4_READ_ACL | \ + ACE4_WRITE_ACL | \ + ACE4_WRITE_OWNER | \ + ACE4_SYNCHRONIZE) + +/* Used to signify an undefined value for an acemask4 */ +#define ACE4_MASK_UNDEFINED 0x80000000 + +#define ACE4_WHO_OWNER "OWNER@" +#define ACE4_WHO_GROUP "GROUP@" +#define ACE4_WHO_EVERYONE "EVERYONE@" + +struct nfsace4 { + acetype4 type; + aceflag4 flag; + acemask4 access_mask; + utf8string who; +}; +typedef struct nfsace4 nfsace4; + +typedef uint32_t aclflag4; /* 4.1 */ +#define ACL4_AUTO_INHERIT 0x00000001 +#define ACL4_PROTECTED 0x00000002 +#define ACL4_DEFAULTED 0x00000004 + +struct nfsacl41 { /* 4.1 */ + aclflag4 na41_flag; + struct { + uint_t na41_aces_len; + nfsace4 *na41_aces_val; + } na41_aces; +}; +typedef struct nfsacl41 nfsacl41; + +#define MODE4_SUID 0x800 +#define MODE4_SGID 0x400 +#define MODE4_SVTX 0x200 +#define MODE4_RUSR 0x100 +#define MODE4_WUSR 0x080 +#define MODE4_XUSR 0x040 +#define MODE4_RGRP 0x020 +#define MODE4_WGRP 0x010 +#define MODE4_XGRP 0x008 +#define MODE4_ROTH 0x004 +#define MODE4_WOTH 0x002 +#define MODE4_XOTH 0x001 + +struct mode_masked4 { /* 4.1 */ + mode4 mm_value_to_set; + mode4 mm_mask_bits; +}; +typedef struct mode_masked4 mode_masked4; + +/* + * ACL conversion helpers + */ + +typedef enum { + ace4_unused, + ace4_user_obj, + ace4_user, + ace4_group, /* includes GROUP and GROUP_OBJ */ + ace4_other_obj +} ace4_to_aent_state_t; + +typedef struct ace4vals { + utf8string *key; /* NB: not allocated here; points to existing utf8 */ + avl_node_t avl; + acemask4 mask; + acemask4 allowed; + acemask4 denied; + int aent_type; +} ace4vals_t; + +typedef struct ace4_list { + ace4vals_t user_obj; + avl_tree_t user; + int numusers; + ace4vals_t group_obj; + avl_tree_t group; + int numgroups; + ace4vals_t other_obj; + acemask4 acl_mask; + int hasmask; + int dfacl_flag; + ace4_to_aent_state_t state; + int seen; /* bitmask of all aclent_t a_type values seen */ +} ace4_list_t; + +struct specdata4 { + uint32_t specdata1; + uint32_t specdata2; +}; +typedef struct specdata4 specdata4; +#define FH4_PERSISTENT 0x00000000 +#define FH4_NOEXPIRE_WITH_OPEN 0x00000001 +#define FH4_VOLATILE_ANY 0x00000002 +#define FH4_VOL_MIGRATION 0x00000004 +#define FH4_VOL_RENAME 0x00000008 + +/* + * nfsv4.1 + */ +struct netaddr4 { + char *na_r_netid; + char *na_r_addr; +}; +typedef struct netaddr4 netaddr4; + +struct nfs_impl_id4 { + utf8str_cis nii_domain; + utf8str_cs nii_name; + nfstime4 nii_date; +}; +typedef struct nfs_impl_id4 nfs_impl_id4; + +struct stateid4 { + uint32_t seqid; + char other[NFS4_OTHER_SIZE]; +}; +typedef struct stateid4 stateid4; + +enum layouttype4 { + LAYOUT4_NFSV4_1_FILES = 0x1, + LAYOUT4_OSD2_OBJECTS = 0x2, + LAYOUT4_BLOCK_VOLUME = 0x3 +}; +typedef enum layouttype4 layouttype4; + +struct layout_content4 { + layouttype4 loc_type; + struct { + uint_t loc_body_len; + char *loc_body_val; + } loc_body; +}; +typedef struct layout_content4 layout_content4; + +/* + * LAYOUT4_OSD2_OBJECTS loc_body description + * is in a separate .x file + */ + +/* + * LAYOUT4_BLOCK_VOLUME loc_body description + * is in a separate .x file + */ + +struct layouthint4 { + layouttype4 loh_type; + struct { + uint_t loh_body_len; + char *loh_body_val; + } loh_body; +}; +typedef struct layouthint4 layouthint4; + +enum layoutiomode4 { + LAYOUTIOMODE4_READ = 1, + LAYOUTIOMODE4_RW = 2, + LAYOUTIOMODE4_ANY = 3 +}; +typedef enum layoutiomode4 layoutiomode4; + +struct layout4 { + offset4 lo_offset; + length4 lo_length; + layoutiomode4 lo_iomode; + layout_content4 lo_content; +}; +typedef struct layout4 layout4; +#define NFS4_DEVICEID4_SIZE 16 + +typedef char deviceid4[NFS4_DEVICEID4_SIZE]; + +struct device_addr4 { + layouttype4 da_layout_type; + struct { + uint_t da_addr_body_len; + char *da_addr_body_val; + } da_addr_body; +}; +typedef struct device_addr4 device_addr4; + +struct layoutupdate4 { + layouttype4 lou_type; + struct { + uint_t lou_body_len; + char *lou_body_val; + } lou_body; +}; +typedef struct layoutupdate4 layoutupdate4; + +#define LAYOUT4_RET_REC_FILE 1 +#define LAYOUT4_RET_REC_FSID 2 +#define LAYOUT4_RET_REC_ALL 3 + +enum layoutreturn_type4 { + LAYOUTRETURN4_FILE = LAYOUT4_RET_REC_FILE, + LAYOUTRETURN4_FSID = LAYOUT4_RET_REC_FSID, + LAYOUTRETURN4_ALL = LAYOUT4_RET_REC_ALL +}; +typedef enum layoutreturn_type4 layoutreturn_type4; + +/* layouttype4 specific data */ + +struct layoutreturn_file4 { + offset4 lrf_offset; + length4 lrf_length; + stateid4 lrf_stateid; + struct { + uint_t lrf_body_len; + char *lrf_body_val; + } lrf_body; +}; +typedef struct layoutreturn_file4 layoutreturn_file4; + +struct layoutreturn4 { + layoutreturn_type4 lr_returntype; + union { + layoutreturn_file4 lr_layout; + } layoutreturn4_u; +}; +typedef struct layoutreturn4 layoutreturn4; + +enum fs4_status_type { + STATUS4_FIXED = 1, + STATUS4_UPDATED = 2, + STATUS4_VERSIONED = 3, + STATUS4_WRITABLE = 4, + STATUS4_REFERRAL = 5 +}; +typedef enum fs4_status_type fs4_status_type; + +struct fs4_status { + bool_t fss_absent; + fs4_status_type fss_type; + utf8str_cs fss_source; + utf8str_cs fss_current; + int32_t fss_age; + nfstime4 fss_version; +}; +typedef struct fs4_status fs4_status; + +#define TH4_READ_SIZE 0 +#define TH4_WRITE_SIZE 1 +#define TH4_READ_IOSIZE 2 +#define TH4_WRITE_IOSIZE 3 + +typedef length4 threshold4_read_size; + +typedef length4 threshold4_write_size; + +typedef length4 threshold4_read_iosize; + +typedef length4 threshold4_write_iosize; + +struct threshold_item4 { + layouttype4 thi_layout_type; + bitmap4 thi_hintset; + struct { + uint_t thi_hintlist_len; + char *thi_hintlist_val; + } thi_hintlist; +}; +typedef struct threshold_item4 threshold_item4; + +struct mdsthreshold4 { + struct { + uint_t mth_hints_len; + threshold_item4 *mth_hints_val; + } mth_hints; +}; +typedef struct mdsthreshold4 mdsthreshold4; +#define RET4_DURATION_INFINITE 0xffffffffffffffff + +struct retention_get4 { + uint64_t rg_duration; + struct { + uint_t rg_begin_time_len; + nfstime4 *rg_begin_time_val; + } rg_begin_time; +}; +typedef struct retention_get4 retention_get4; + +struct retention_set4 { + bool_t rs_enable; + struct { + uint_t rs_duration_len; + uint64_t *rs_duration_val; + } rs_duration; +}; +typedef struct retention_set4 retention_set4; +#define FSCHARSET_CAP4_CONTAINS_NON_UTF8 0x1 +#define FSCHARSET_CAP4_ALLOWS_ONLY_UTF8 0x2 + +typedef uint32_t fs_charset_cap4; + +/* nfsv4.1 end, nfsv4.2 additions */ + +enum netloc_type4 { + NL4_NAME = 1, + NL4_URL = 2, + NL4_NETADDR = 3 +}; +typedef enum netloc_type4 netloc_type4; + +struct netloc4 { + netloc_type4 nl_type; + union { + utf8str_cis nl_name; + utf8str_cis nl_url; + netaddr4 nl_addr; + } netloc4_u; +}; +typedef struct netloc4 netloc4; + +enum change_attr_type4 { + NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR = 0, + NFS4_CHANGE_TYPE_IS_VERSION_COUNTER = 1, + NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS = 2, + NFS4_CHANGE_TYPE_IS_TIME_METADATA = 3, + NFS4_CHANGE_TYPE_IS_UNDEFINED = 4 +}; +typedef enum change_attr_type4 change_attr_type4; + +/* + * Note that rpcgen would have put here: + * typedef struct labelformat_spec4 {...} + * typedef struct sec_label4 {...} + * but this implementation is using a hand-coded replacment. + */ + +/* nfsv4.2 by-hand version */ +struct sec_label4 { + uint_t slai_len; + char *slai_val; +}; + +typedef struct sec_label4 sec_label4; + +/* + * Note that rpcgen would have put here: + * typedef struct copy_from_auth_priv {...} + * typedef struct copy_to_auth_priv {...} + * typedef struct copy_confirm_auth_priv {...} + * not currently used. + */ + +struct app_data_block4 { + offset4 adb_offset; + length4 adb_block_size; + length4 adb_block_count; + length4 adb_reloff_blocknum; + count4 adb_block_num; + length4 adb_reloff_pattern; + struct { + uint_t adb_pattern_len; + char *adb_pattern_val; + } adb_pattern; +}; +typedef struct app_data_block4 app_data_block4; + +struct data4 { + offset4 d_offset; + struct { + uint_t d_data_len; + char *d_data_val; + } d_data; +}; +typedef struct data4 data4; + +struct data_info4 { + offset4 di_offset; + length4 di_length; +}; +typedef struct data_info4 data_info4; + +enum data_content4 { + NFS4_CONTENT_DATA = 0, + NFS4_CONTENT_HOLE = 1 +}; +typedef enum data_content4 data_content4; + +enum stable_how4 { + UNSTABLE4 = 0, + DATA_SYNC4 = 1, + FILE_SYNC4 = 2 +}; +typedef enum stable_how4 stable_how4; + +struct write_response4 { + struct { + uint_t wr_callback_id_len; + stateid4 *wr_callback_id_val; + } wr_callback_id; + length4 wr_count; + stable_how4 wr_committed; + verifier4 wr_writeverf; +}; +typedef struct write_response4 write_response4; + +/* nfsv4.2 end */ + +typedef bitmap4 fattr4_supported_attrs; + +typedef nfs_ftype4 fattr4_type; + +typedef uint32_t fattr4_fh_expire_type; + +typedef changeid4 fattr4_change; + +typedef uint64_t fattr4_size; + +typedef bool_t fattr4_link_support; + +typedef bool_t fattr4_symlink_support; + +typedef bool_t fattr4_named_attr; + +typedef fsid4 fattr4_fsid; + +typedef bool_t fattr4_unique_handles; + +typedef nfs_lease4 fattr4_lease_time; + +typedef nfsstat4 fattr4_rdattr_error; + +typedef struct { + uint_t fattr4_acl_len; + nfsace4 *fattr4_acl_val; +} fattr4_acl; + +typedef uint32_t fattr4_aclsupport; + +typedef bool_t fattr4_archive; + +typedef bool_t fattr4_cansettime; + +typedef bool_t fattr4_case_insensitive; + +typedef bool_t fattr4_case_preserving; + +typedef bool_t fattr4_chown_restricted; + +typedef uint64_t fattr4_fileid; + +typedef uint64_t fattr4_files_avail; + +typedef nfs_fh4 fattr4_filehandle; + +typedef uint64_t fattr4_files_free; + +typedef uint64_t fattr4_files_total; + +typedef fs_locations4 fattr4_fs_locations; + +typedef bool_t fattr4_hidden; + +typedef bool_t fattr4_homogeneous; + +typedef uint64_t fattr4_maxfilesize; + +typedef uint32_t fattr4_maxlink; + +typedef uint32_t fattr4_maxname; + +typedef uint64_t fattr4_maxread; + +typedef uint64_t fattr4_maxwrite; + +typedef ascii_REQUIRED4 fattr4_mimetype; + +typedef mode4 fattr4_mode; + +typedef mode_masked4 fattr4_mode_set_masked; + +typedef uint64_t fattr4_mounted_on_fileid; + +typedef bool_t fattr4_no_trunc; + +typedef uint32_t fattr4_numlinks; + +typedef utf8string fattr4_owner; + +typedef utf8string fattr4_owner_group; + +typedef uint64_t fattr4_quota_avail_hard; + +typedef uint64_t fattr4_quota_avail_soft; + +typedef uint64_t fattr4_quota_used; + +typedef specdata4 fattr4_rawdev; + +typedef uint64_t fattr4_space_avail; + +typedef uint64_t fattr4_space_free; + +typedef uint64_t fattr4_space_total; + +typedef uint64_t fattr4_space_used; + +typedef bool_t fattr4_system; + +typedef nfstime4 fattr4_time_access; + +typedef settime4 fattr4_time_access_set; + +typedef nfstime4 fattr4_time_backup; + +typedef nfstime4 fattr4_time_create; + +typedef nfstime4 fattr4_time_delta; + +typedef nfstime4 fattr4_time_metadata; + +typedef nfstime4 fattr4_time_modify; + +typedef settime4 fattr4_time_modify_set; + +/* nfsv4.1 */ +typedef bitmap4 fattr4_suppattr_exclcreat; + +typedef nfstime4 fattr4_dir_notif_delay; + +typedef nfstime4 fattr4_dirent_notif_delay; + +typedef struct { + uint_t fattr4_fs_layout_types_len; + layouttype4 *fattr4_fs_layout_types_val; +} fattr4_fs_layout_types; + +typedef fs4_status fattr4_fs_status; + +typedef fs_charset_cap4 fattr4_fs_charset_cap; + +typedef uint32_t fattr4_layout_alignment; + +typedef uint32_t fattr4_layout_blksize; + +typedef layouthint4 fattr4_layout_hint; + +typedef struct { + uint_t fattr4_layout_types_len; + layouttype4 *fattr4_layout_types_val; +} fattr4_layout_types; + +typedef mdsthreshold4 fattr4_mdsthreshold; + +typedef retention_get4 fattr4_retention_get; + +typedef retention_set4 fattr4_retention_set; + +typedef retention_get4 fattr4_retentevt_get; + +typedef retention_set4 fattr4_retentevt_set; + +typedef uint64_t fattr4_retention_hold; + +typedef nfsacl41 fattr4_dacl; + +typedef nfsacl41 fattr4_sacl; + +typedef change_policy4 fattr4_change_policy; + +/* nfsv4.1 end, nfsv4.2 begin */ + +typedef uint64_t fattr4_space_freed; + +typedef change_attr_type4 fattr4_change_attr_type; + +typedef sec_label4 fattr4_sec_label; + +typedef uint32_t fattr4_clone_blksize; + +/* nfsv4.2 end */ + +/* + * REQUIRED Attributes + */ +#define FATTR4_SUPPORTED_ATTRS 0 +#define FATTR4_TYPE 1 +#define FATTR4_FH_EXPIRE_TYPE 2 +#define FATTR4_CHANGE 3 +#define FATTR4_SIZE 4 +#define FATTR4_LINK_SUPPORT 5 +#define FATTR4_SYMLINK_SUPPORT 6 +#define FATTR4_NAMED_ATTR 7 +#define FATTR4_FSID 8 +#define FATTR4_UNIQUE_HANDLES 9 +#define FATTR4_LEASE_TIME 10 +#define FATTR4_RDATTR_ERROR 11 +#define FATTR4_FILEHANDLE 19 +/* new to NFSV4.1 */ +#define FATTR4_SUPPATTR_EXCLCREAT 75 + +/* + * RECOMMENDED Attributes + */ +#define FATTR4_ACL 12 +#define FATTR4_ACLSUPPORT 13 +#define FATTR4_ARCHIVE 14 +#define FATTR4_CANSETTIME 15 +#define FATTR4_CASE_INSENSITIVE 16 +#define FATTR4_CASE_PRESERVING 17 +#define FATTR4_CHOWN_RESTRICTED 18 +#define FATTR4_FILEID 20 +#define FATTR4_FILES_AVAIL 21 +#define FATTR4_FILES_FREE 22 +#define FATTR4_FILES_TOTAL 23 +#define FATTR4_FS_LOCATIONS 24 +#define FATTR4_HIDDEN 25 +#define FATTR4_HOMOGENEOUS 26 +#define FATTR4_MAXFILESIZE 27 +#define FATTR4_MAXLINK 28 +#define FATTR4_MAXNAME 29 +#define FATTR4_MAXREAD 30 +#define FATTR4_MAXWRITE 31 +#define FATTR4_MIMETYPE 32 +#define FATTR4_MODE 33 +#define FATTR4_NO_TRUNC 34 +#define FATTR4_NUMLINKS 35 +#define FATTR4_OWNER 36 +#define FATTR4_OWNER_GROUP 37 +#define FATTR4_QUOTA_AVAIL_HARD 38 +#define FATTR4_QUOTA_AVAIL_SOFT 39 +#define FATTR4_QUOTA_USED 40 +#define FATTR4_RAWDEV 41 +#define FATTR4_SPACE_AVAIL 42 +#define FATTR4_SPACE_FREE 43 +#define FATTR4_SPACE_TOTAL 44 +#define FATTR4_SPACE_USED 45 +#define FATTR4_SYSTEM 46 +#define FATTR4_TIME_ACCESS 47 +#define FATTR4_TIME_ACCESS_SET 48 +#define FATTR4_TIME_BACKUP 49 +#define FATTR4_TIME_CREATE 50 +#define FATTR4_TIME_DELTA 51 +#define FATTR4_TIME_METADATA 52 +#define FATTR4_TIME_MODIFY 53 +#define FATTR4_TIME_MODIFY_SET 54 +#define FATTR4_MOUNTED_ON_FILEID 55 + +/* new to NFSV4.1 */ +#define FATTR4_DIR_NOTIF_DELAY 56 +#define FATTR4_DIRENT_NOTIF_DELAY 57 +#define FATTR4_DACL 58 +#define FATTR4_SACL 59 +#define FATTR4_CHANGE_POLICY 60 +#define FATTR4_FS_STATUS 61 +#define FATTR4_FS_LAYOUT_TYPES 62 +#define FATTR4_LAYOUT_HINT 63 +#define FATTR4_LAYOUT_TYPES 64 +#define FATTR4_LAYOUT_BLKSIZE 65 +#define FATTR4_LAYOUT_ALIGNMENT 66 +#define FATTR4_FS_LOCATIONS_INFO 67 +#define FATTR4_MDSTHRESHOLD 68 +#define FATTR4_RETENTION_GET 69 +#define FATTR4_RETENTION_SET 70 +#define FATTR4_RETENTEVT_GET 71 +#define FATTR4_RETENTEVT_SET 72 +#define FATTR4_RETENTION_HOLD 73 +#define FATTR4_MODE_SET_MASKED 74 +/* FATTR4_SUPPATTR_EXCLCREAT (75) is required. See above. */ +#define FATTR4_FS_CHARSET_CAP 76 + +/* new to NFSv4.2 */ +#define FATTR4_CLONE_BLKSIZE 77 +#define FATTR4_SPACE_FREED 78 +#define FATTR4_CHANGE_ATTR_TYPE 79 +#define FATTR4_SEC_LABEL 80 + +struct fattr4 { + bitmap4 attrmask; + char *attrlist4; + uint_t attrlist4_len; +}; +typedef struct fattr4 fattr4; + +struct change_info4 { + bool_t atomic; + changeid4 before; + changeid4 after; +}; +typedef struct change_info4 change_info4; + +struct clientaddr4 { + char *r_netid; + char *r_addr; +}; +typedef struct clientaddr4 clientaddr4; + +struct cb_client4 { + uint_t cb_program; + clientaddr4 cb_location; +}; +typedef struct cb_client4 cb_client4; + +struct nfs_client_id4 { + verifier4 verifier; + uint_t id_len; + char *id_val; + struct sockaddr *cl_addr; +}; +typedef struct nfs_client_id4 nfs_client_id4; + +struct client_owner4 { + verifier4 co_verifier; + struct { + uint_t co_ownerid_len; + char *co_ownerid_val; + } co_ownerid; +}; +typedef struct client_owner4 client_owner4; + +struct server_owner4 { + uint64_t so_minor_id; + struct { + uint_t so_major_id_len; + char *so_major_id_val; + } so_major_id; +}; +typedef struct server_owner4 server_owner4; + +struct state_owner4 { + clientid4 clientid; + struct { + uint_t owner_len; + char *owner_val; + } owner; +}; +typedef struct state_owner4 state_owner4; + +struct open_owner4 { + clientid4 clientid; + uint_t owner_len; + char *owner_val; +}; +typedef struct open_owner4 open_owner4; + +struct lock_owner4 { + clientid4 clientid; + uint_t owner_len; + char *owner_val; +}; +typedef struct lock_owner4 lock_owner4; + +enum nfs_lock_type4 { + READ_LT = 1, + WRITE_LT = 2, + READW_LT = 3, + WRITEW_LT = 4 +}; +typedef enum nfs_lock_type4 nfs_lock_type4; + +/* + * nfsv4.1 + */ + +/* Input for computing subkeys */ + +enum ssv_subkey4 { + SSV4_SUBKEY_MIC_I2T = 1, + SSV4_SUBKEY_MIC_T2I = 2, + SSV4_SUBKEY_SEAL_I2T = 3, + SSV4_SUBKEY_SEAL_T2I = 4 +}; +typedef enum ssv_subkey4 ssv_subkey4; + +/* Input for computing smt_hmac */ + +struct ssv_mic_plain_tkn4 { + uint32_t smpt_ssv_seq; + struct { + uint_t smpt_orig_plain_len; + char *smpt_orig_plain_val; + } smpt_orig_plain; +}; +typedef struct ssv_mic_plain_tkn4 ssv_mic_plain_tkn4; + +/* SSV GSS PerMsgToken token */ + +struct ssv_mic_tkn4 { + uint32_t smt_ssv_seq; + struct { + uint_t smt_hmac_len; + char *smt_hmac_val; + } smt_hmac; +}; +typedef struct ssv_mic_tkn4 ssv_mic_tkn4; + +/* Input for computing ssct_encr_data and ssct_hmac */ + +struct ssv_seal_plain_tkn4 { + struct { + uint_t sspt_confounder_len; + char *sspt_confounder_val; + } sspt_confounder; + uint32_t sspt_ssv_seq; + struct { + uint_t sspt_orig_plain_len; + char *sspt_orig_plain_val; + } sspt_orig_plain; + struct { + uint_t sspt_pad_len; + char *sspt_pad_val; + } sspt_pad; +}; +typedef struct ssv_seal_plain_tkn4 ssv_seal_plain_tkn4; + +/* SSV GSS SealedMessage token */ + +struct ssv_seal_cipher_tkn4 { + uint32_t ssct_ssv_seq; + struct { + uint_t ssct_iv_len; + char *ssct_iv_val; + } ssct_iv; + struct { + uint_t ssct_encr_data_len; + char *ssct_encr_data_val; + } ssct_encr_data; + struct { + uint_t ssct_hmac_len; + char *ssct_hmac_val; + } ssct_hmac; +}; +typedef struct ssv_seal_cipher_tkn4 ssv_seal_cipher_tkn4; + +struct fs_locations_server4 { + int32_t fls_currency; + struct { + uint_t fls_info_len; + char *fls_info_val; + } fls_info; + utf8str_cis fls_server; +}; +typedef struct fs_locations_server4 fs_locations_server4; +#define FSLI4BX_GFLAGS 0 +#define FSLI4BX_TFLAGS 1 +#define FSLI4BX_CLSIMUL 2 +#define FSLI4BX_CLHANDLE 3 +#define FSLI4BX_CLFILEID 4 +#define FSLI4BX_CLWRITEVER 5 +#define FSLI4BX_CLCHANGE 6 +#define FSLI4BX_CLREADDIR 7 +#define FSLI4BX_READRANK 8 +#define FSLI4BX_WRITERANK 9 +#define FSLI4BX_READORDER 10 +#define FSLI4BX_WRITEORDER 11 +#define FSLI4GF_WRITABLE 0x01 +#define FSLI4GF_CUR_REQ 0x02 +#define FSLI4GF_ABSENT 0x04 +#define FSLI4GF_GOING 0x08 +#define FSLI4GF_SPLIT 0x10 +#define FSLI4TF_RDMA 0x01 + +struct fs_locations_item4 { + struct { + uint_t fli_entries_len; + fs_locations_server4 *fli_entries_val; + } fli_entries; + pathname4 fli_rootpath; +}; +typedef struct fs_locations_item4 fs_locations_item4; + +struct fs_locations_info4 { + uint32_t fli_flags; + int32_t fli_valid_for; + pathname4 fli_fs_root; + struct { + uint_t fli_items_len; + fs_locations_item4 *fli_items_val; + } fli_items; +}; +typedef struct fs_locations_info4 fs_locations_info4; +#define FSLI4IF_VAR_SUB 0x00000001 + +typedef fs_locations_info4 fattr4_fs_locations_info; +#define NFL4_UFLG_MASK 0x0000003F +#define NFL4_UFLG_DENSE 0x00000001 +#define NFL4_UFLG_COMMIT_THRU_MDS 0x00000002 +#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0 + +typedef uint32_t nfl_util4; + +enum filelayout_hint_care4 { + NFLH4_CARE_DENSE = NFL4_UFLG_DENSE, + NFLH4_CARE_COMMIT_THRU_MDS = NFL4_UFLG_COMMIT_THRU_MDS, + NFLH4_CARE_STRIPE_UNIT_SIZE = 0x00000040, + NFLH4_CARE_STRIPE_COUNT = 0x00000080 +}; +typedef enum filelayout_hint_care4 filelayout_hint_care4; + +/* Encoded in the loh_body field of data type layouthint4: */ + +struct nfsv4_1_file_layouthint4 { + uint32_t nflh_care; + nfl_util4 nflh_util; + count4 nflh_stripe_count; +}; +typedef struct nfsv4_1_file_layouthint4 nfsv4_1_file_layouthint4; + +typedef struct { + uint_t multipath_list4_len; + netaddr4 *multipath_list4_val; +} multipath_list4; + +/* + * Encoded in the da_addr_body field of + * data type device_addr4: + */ + +struct nfsv4_1_file_layout_ds_addr4 { + struct { + uint_t nflda_stripe_indices_len; + uint32_t *nflda_stripe_indices_val; + } nflda_stripe_indices; + struct { + uint_t nflda_multipath_ds_list_len; + multipath_list4 *nflda_multipath_ds_list_val; + } nflda_multipath_ds_list; +}; +typedef struct nfsv4_1_file_layout_ds_addr4 nfsv4_1_file_layout_ds_addr4; + +/* + * Encoded in the loc_body field of + * data type layout_content4: + */ + +struct nfsv4_1_file_layout4 { + deviceid4 nfl_deviceid; + nfl_util4 nfl_util; + uint32_t nfl_first_stripe_index; + offset4 nfl_pattern_offset; + struct { + uint_t nfl_fh_list_len; + nfs_fh4 *nfl_fh_list_val; + } nfl_fh_list; +}; +typedef struct nfsv4_1_file_layout4 nfsv4_1_file_layout4; + +/* + * Encoded in the lou_body field of data type layoutupdate4: + * Nothing. lou_body is a zero length array of bytes. + */ + +/* + * Encoded in the lrf_body field of + * data type layoutreturn_file4: + * Nothing. lrf_body is a zero length array of bytes. + */ + +/* nfsv4.1 end */ + +enum nfs_opnum4 { + OP_ACCESS = 3, + OP_CLOSE = 4, + OP_COMMIT = 5, + OP_CREATE = 6, + OP_DELEGPURGE = 7, + OP_DELEGRETURN = 8, + OP_GETATTR = 9, + OP_GETFH = 10, + OP_LINK = 11, + OP_LOCK = 12, + OP_LOCKT = 13, + OP_LOCKU = 14, + OP_LOOKUP = 15, + OP_LOOKUPP = 16, + OP_NVERIFY = 17, + OP_OPEN = 18, + OP_OPENATTR = 19, + OP_OPEN_CONFIRM = 20, + OP_OPEN_DOWNGRADE = 21, + OP_PUTFH = 22, + OP_PUTPUBFH = 23, + OP_PUTROOTFH = 24, + OP_READ = 25, + OP_READDIR = 26, + OP_READLINK = 27, + OP_REMOVE = 28, + OP_RENAME = 29, + OP_RENEW = 30, + OP_RESTOREFH = 31, + OP_SAVEFH = 32, + OP_SECINFO = 33, + OP_SETATTR = 34, + OP_SETCLIENTID = 35, + OP_SETCLIENTID_CONFIRM = 36, + OP_VERIFY = 37, + OP_WRITE = 38, + OP_RELEASE_LOCKOWNER = 39, + + /* nfsv4.1 */ + OP_BACKCHANNEL_CTL = 40, + OP_BIND_CONN_TO_SESSION = 41, + OP_EXCHANGE_ID = 42, + OP_CREATE_SESSION = 43, + OP_DESTROY_SESSION = 44, + OP_FREE_STATEID = 45, + OP_GET_DIR_DELEGATION = 46, + OP_GETDEVICEINFO = 47, + OP_GETDEVICELIST = 48, + OP_LAYOUTCOMMIT = 49, + OP_LAYOUTGET = 50, + OP_LAYOUTRETURN = 51, + OP_SECINFO_NO_NAME = 52, + OP_SEQUENCE = 53, + OP_SET_SSV = 54, + OP_TEST_STATEID = 55, + OP_WANT_DELEGATION = 56, + OP_DESTROY_CLIENTID = 57, + OP_RECLAIM_COMPLETE = 58, + + /* NFSv4.2 */ + OP_ALLOCATE = 59, + OP_COPY = 60, + OP_COPY_NOTIFY = 61, + OP_DEALLOCATE = 62, + OP_IO_ADVISE = 63, + OP_LAYOUTERROR = 64, + OP_LAYOUTSTATS = 65, + OP_OFFLOAD_CANCEL = 66, + OP_OFFLOAD_STATUS = 67, + OP_READ_PLUS = 68, + OP_SEEK = 69, + OP_WRITE_SAME = 70, + OP_CLONE = 71, + + OP_ILLEGAL = 10044, +/* + * These are internal client pseudo ops that *MUST* never go over the wire + */ +#define SUNW_PRIVATE_OP 0x10000000 +#define REAL_OP4(op) ((op) & ~SUNW_PRIVATE_OP) + OP_CCREATE = OP_CREATE | SUNW_PRIVATE_OP, + OP_CLINK = OP_LINK | SUNW_PRIVATE_OP, + OP_CLOOKUP = OP_LOOKUP | SUNW_PRIVATE_OP, + OP_COPEN = OP_OPEN | SUNW_PRIVATE_OP, + OP_CPUTFH = OP_PUTFH | SUNW_PRIVATE_OP, + OP_CREMOVE = OP_REMOVE | SUNW_PRIVATE_OP, + OP_CRENAME = OP_RENAME | SUNW_PRIVATE_OP, + OP_CSECINFO = OP_SECINFO | SUNW_PRIVATE_OP +}; +typedef enum nfs_opnum4 nfs_opnum4; + +/* Args & res. structs */ + +#define ACCESS4_READ 0x00000001 +#define ACCESS4_LOOKUP 0x00000002 +#define ACCESS4_MODIFY 0x00000004 +#define ACCESS4_EXTEND 0x00000008 +#define ACCESS4_DELETE 0x00000010 +#define ACCESS4_EXECUTE 0x00000020 + +struct ACCESS4args { + uint32_t access; +}; +typedef struct ACCESS4args ACCESS4args; + +struct ACCESS4res { + nfsstat4 status; + uint32_t supported; + uint32_t access; +}; +typedef struct ACCESS4res ACCESS4res; + +struct CLOSE4args { + seqid4 seqid; + stateid4 open_stateid; +}; +typedef struct CLOSE4args CLOSE4args; + +struct CLOSE4res { + nfsstat4 status; + stateid4 open_stateid; +}; +typedef struct CLOSE4res CLOSE4res; + +struct COMMIT4args { + offset4 offset; + count4 count; +}; +typedef struct COMMIT4args COMMIT4args; + +struct COMMIT4res { + nfsstat4 status; + verifier4 writeverf; +}; +typedef struct COMMIT4res COMMIT4res; + +struct CREATE4args { + nfs_ftype4 type; + union { + linktext4 linkdata; + specdata4 devdata; + } ftype4_u; + component4 objname; + fattr4 createattrs; +}; +typedef struct CREATE4args CREATE4args; + +struct CREATE4cargs { + nfs_ftype4 type; + union { + char *clinkdata; + specdata4 devdata; + } ftype4_u; + char *cname; + fattr4 createattrs; +}; +typedef struct CREATE4cargs CREATE4cargs; + +struct CREATE4res { + nfsstat4 status; + change_info4 cinfo; + bitmap4 attrset; +}; +typedef struct CREATE4res CREATE4res; + +struct DELEGPURGE4args { + clientid4 clientid; +}; +typedef struct DELEGPURGE4args DELEGPURGE4args; + +struct DELEGPURGE4res { + nfsstat4 status; +}; +typedef struct DELEGPURGE4res DELEGPURGE4res; + +struct DELEGRETURN4args { + stateid4 deleg_stateid; +}; +typedef struct DELEGRETURN4args DELEGRETURN4args; + +struct DELEGRETURN4res { + nfsstat4 status; +}; +typedef struct DELEGRETURN4res DELEGRETURN4res; + +struct mntinfo4; + +struct GETATTR4args { + bitmap4 attr_request; + struct mntinfo4 *mi; +}; +typedef struct GETATTR4args GETATTR4args; + +struct nfs4_ga_ext_res; + +struct nfs4_ga_res { + vattr_t n4g_va; + unsigned n4g_change_valid:1; + unsigned n4g_mon_fid_valid:1; + unsigned n4g_fsid_valid:1; + uint_t n4g_attrerr; + uint_t n4g_attrwhy; + bitmap4 n4g_resbmap; + fattr4_change n4g_change; + fattr4_fsid n4g_fsid; + fattr4_mounted_on_fileid n4g_mon_fid; + struct nfs4_ga_ext_res *n4g_ext_res; + vsecattr_t n4g_vsa; +}; +typedef struct nfs4_ga_res nfs4_ga_res_t; + +struct GETATTR4res { + nfsstat4 status; + fattr4 obj_attributes; + nfsstat4 ga_status; + struct nfs4_ga_res ga_res; +}; +typedef struct GETATTR4res GETATTR4res; + +struct GETFH4res { + nfsstat4 status; + nfs_fh4 object; +}; +typedef struct GETFH4res GETFH4res; + +struct LINK4args { + component4 newname; +}; +typedef struct LINK4args LINK4args; + +struct LINK4cargs { + char *cnewname; +}; +typedef struct LINK4cargs LINK4cargs; + +struct LINK4res { + nfsstat4 status; + change_info4 cinfo; +}; +typedef struct LINK4res LINK4res; + +struct open_to_lock_owner4 { + seqid4 open_seqid; + stateid4 open_stateid; + seqid4 lock_seqid; + lock_owner4 lock_owner; +}; +typedef struct open_to_lock_owner4 open_to_lock_owner4; + +struct exist_lock_owner4 { + stateid4 lock_stateid; + seqid4 lock_seqid; +}; +typedef struct exist_lock_owner4 exist_lock_owner4; + +struct locker4 { + bool_t new_lock_owner; + union { + open_to_lock_owner4 open_owner; + exist_lock_owner4 lock_owner; + } locker4_u; +}; +typedef struct locker4 locker4; + +struct LOCK4args { + nfs_lock_type4 locktype; + bool_t reclaim; + offset4 offset; + length4 length; + locker4 locker; +}; +typedef struct LOCK4args LOCK4args; + +struct LOCK4denied { + offset4 offset; + length4 length; + nfs_lock_type4 locktype; + lock_owner4 owner; +}; +typedef struct LOCK4denied LOCK4denied; + +struct LOCK4res { + nfsstat4 status; + union { + stateid4 lock_stateid; + LOCK4denied denied; + } LOCK4res_u; +}; +typedef struct LOCK4res LOCK4res; + +struct LOCKT4args { + nfs_lock_type4 locktype; + offset4 offset; + length4 length; + lock_owner4 owner; +}; +typedef struct LOCKT4args LOCKT4args; + +struct LOCKT4res { + nfsstat4 status; + LOCK4denied denied; +}; +typedef struct LOCKT4res LOCKT4res; + +struct LOCKU4args { + nfs_lock_type4 locktype; + seqid4 seqid; + stateid4 lock_stateid; + offset4 offset; + length4 length; +}; +typedef struct LOCKU4args LOCKU4args; + +struct LOCKU4res { + nfsstat4 status; + stateid4 lock_stateid; +}; +typedef struct LOCKU4res LOCKU4res; + +struct LOOKUP4args { + component4 objname; +}; +typedef struct LOOKUP4args LOOKUP4args; + +struct LOOKUP4cargs { + char *cname; +}; +typedef struct LOOKUP4cargs LOOKUP4cargs; + +struct LOOKUP4res { + nfsstat4 status; +}; +typedef struct LOOKUP4res LOOKUP4res; + +struct LOOKUPP4res { + nfsstat4 status; +}; +typedef struct LOOKUPP4res LOOKUPP4res; + +struct NVERIFY4args { + fattr4 obj_attributes; +}; +typedef struct NVERIFY4args NVERIFY4args; + +struct NVERIFY4res { + nfsstat4 status; +}; +typedef struct NVERIFY4res NVERIFY4res; + +enum createmode4 { + UNCHECKED4 = 0, + GUARDED4 = 1, + EXCLUSIVE4 = 2, + EXCLUSIVE4_1 = 3 +}; +typedef enum createmode4 createmode4; + +struct creatverfattr { + verifier4 cva_verf; + fattr4 cva_attrs; +}; +typedef struct creatverfattr creatverfattr; + +struct createhow4 { + createmode4 mode; + union { + fattr4 createattrs; + verifier4 createverf; + creatverfattr ch_createboth; + } createhow4_u; +}; +typedef struct createhow4 createhow4; + +enum opentype4 { + OPEN4_NOCREATE = 0, + OPEN4_CREATE = 1 +}; +typedef enum opentype4 opentype4; + +struct openflag4 { + opentype4 opentype; + union { + createhow4 how; + } openflag4_u; +}; +typedef struct openflag4 openflag4; + +enum limit_by4 { + NFS_LIMIT_SIZE = 1, + NFS_LIMIT_BLOCKS = 2 +}; +typedef enum limit_by4 limit_by4; + +struct nfs_modified_limit4 { + uint32_t num_blocks; + uint32_t bytes_per_block; +}; +typedef struct nfs_modified_limit4 nfs_modified_limit4; + +struct nfs_space_limit4 { + limit_by4 limitby; + union { + uint64_t filesize; + nfs_modified_limit4 mod_blocks; + } nfs_space_limit4_u; +}; +typedef struct nfs_space_limit4 nfs_space_limit4; + +#define OPEN4_SHARE_ACCESS_MASK 0x00FF +#define OPEN4_SHARE_ACCESS_READ 0x00000001 +#define OPEN4_SHARE_ACCESS_WRITE 0x00000002 +#define OPEN4_SHARE_ACCESS_BOTH 0x00000003 +#define OPEN4_SHARE_DENY_NONE 0x00000000 +#define OPEN4_SHARE_DENY_READ 0x00000001 +#define OPEN4_SHARE_DENY_WRITE 0x00000002 +#define OPEN4_SHARE_DENY_BOTH 0x00000003 +/* nfsv4.1 */ +#define OPEN4_SHARE_WANT_MASK 0xFF00 +#define OPEN4_SHARE_WANT_NO_PREFERENCE 0x0000 +#define OPEN4_SHARE_WANT_READ_DELEG 0x0100 +#define OPEN4_SHARE_WANT_WRITE_DELEG 0x0200 +#define OPEN4_SHARE_WANT_ANY_DELEG 0x0300 +#define OPEN4_SHARE_WANT_NO_DELEG 0x0400 +#define OPEN4_SHARE_WANT_CANCEL 0x0500 + +#define OPEN4_SHARE_WHEN_MASK 0xF0000 +#define OPEN4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL 0x10000 +#define OPEN4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED 0x20000 + +enum open_delegation_type4 { + OPEN_DELEGATE_NONE = 0, + OPEN_DELEGATE_READ = 1, + OPEN_DELEGATE_WRITE = 2, + OPEN_DELEGATE_NONE_EXT = 3 +}; +typedef enum open_delegation_type4 open_delegation_type4; + +enum open_claim_type4 { + CLAIM_NULL = 0, + CLAIM_PREVIOUS = 1, + CLAIM_DELEGATE_CUR = 2, + CLAIM_DELEGATE_PREV = 3, + CLAIM_FH = 4, + CLAIM_DELEG_CUR_FH = 5, + CLAIM_DELEG_PREV_FH = 6 +}; +typedef enum open_claim_type4 open_claim_type4; + +struct open_claim_delegate_cur4 { + stateid4 delegate_stateid; + component4 file; +}; +typedef struct open_claim_delegate_cur4 open_claim_delegate_cur4; + +struct copen_claim_delegate_cur4 { + stateid4 delegate_stateid; + char *cfile; +}; +typedef struct copen_claim_delegate_cur4 copen_claim_delegate_cur4; + +struct open_claim4 { + open_claim_type4 claim; + union { + component4 file; + open_delegation_type4 delegate_type; + open_claim_delegate_cur4 delegate_cur_info; + component4 file_delegate_prev; + stateid4 oc_delegate_stateid; + } open_claim4_u; +}; +typedef struct open_claim4 open_claim4; + +struct OPEN4args { + seqid4 seqid; + uint32_t share_access; + uint32_t deleg_want; /* nfsv4.1 */ + uint32_t share_deny; + open_owner4 owner; + opentype4 opentype; + createmode4 mode; + union { + fattr4 createattrs; + verifier4 createverf; + creatverfattr ch_createboth; /* for nfsv4.1 */ + } createhow4_u; + open_claim4 claim; +}; +typedef struct OPEN4args OPEN4args; + +struct OPEN4cargs { + seqid4 seqid; + uint32_t share_access; + uint32_t share_deny; + open_owner4 owner; + opentype4 opentype; + createmode4 mode; + union { + fattr4 createattrs; + verifier4 createverf; + } createhow4_u; + open_claim_type4 claim; + union { + char *cfile; + open_delegation_type4 delegate_type; + copen_claim_delegate_cur4 delegate_cur_info; + char *cfile_delegate_prev; + } open_claim4_u; +}; +typedef struct OPEN4cargs OPEN4cargs; + +struct open_read_delegation4 { + stateid4 stateid; + bool_t recall; + nfsace4 permissions; +}; +typedef struct open_read_delegation4 open_read_delegation4; + +struct open_write_delegation4 { + stateid4 stateid; + bool_t recall; + nfs_space_limit4 space_limit; + nfsace4 permissions; +}; +typedef struct open_write_delegation4 open_write_delegation4; + +/* nfsv4.1 */ +enum why_no_delegation4 { + WND4_NOT_WANTED = 0, + WND4_CONTENTION = 1, + WND4_RESOURCE = 2, + WND4_NOT_SUPP_FTYPE = 3, + WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4, + WND4_NOT_SUPP_UPGRADE = 5, + WND4_NOT_SUPP_DOWNGRADE = 6, + WND4_CANCELLED = 7, + WND4_IS_DIR = 8 +}; +typedef enum why_no_delegation4 why_no_delegation4; + +struct open_none_delegation4 { + why_no_delegation4 ond_why; + union { + bool_t ond_server_will_push_deleg; + bool_t ond_server_will_signal_avail; + } open_none_delegation4_u; +}; +typedef struct open_none_delegation4 open_none_delegation4; + +/* nfsv4.1 end */ + +struct open_delegation4 { + open_delegation_type4 delegation_type; + union { + open_read_delegation4 read; + open_write_delegation4 write; + open_none_delegation4 od_whynone; /* nfsv4.1 */ + } open_delegation4_u; +}; +typedef struct open_delegation4 open_delegation4; +#define OPEN4_RESULT_CONFIRM 0x00000002 +#define OPEN4_RESULT_LOCKTYPE_POSIX 0x00000004 +#define OPEN4_RESULT_PRESERVE_UNLINKED 0x00000008 /* nfsv4.1 */ +#define OPEN4_RESULT_MAY_NOTIFY_LOCK 0x00000020 /* nfsv4.1 */ + +struct OPEN4res { + nfsstat4 status; + stateid4 stateid; + change_info4 cinfo; + uint32_t rflags; + bitmap4 attrset; + open_delegation4 delegation; +}; +typedef struct OPEN4res OPEN4res; + +struct OPENATTR4args { + bool_t createdir; +}; +typedef struct OPENATTR4args OPENATTR4args; + +struct OPENATTR4res { + nfsstat4 status; +}; +typedef struct OPENATTR4res OPENATTR4res; + +struct OPEN_CONFIRM4args { + stateid4 open_stateid; + seqid4 seqid; +}; +typedef struct OPEN_CONFIRM4args OPEN_CONFIRM4args; + +struct OPEN_CONFIRM4res { + nfsstat4 status; + stateid4 open_stateid; +}; +typedef struct OPEN_CONFIRM4res OPEN_CONFIRM4res; + +struct OPEN_DOWNGRADE4args { + stateid4 open_stateid; + seqid4 seqid; + uint32_t share_access; + uint32_t deleg_want; /* nfsv4.1 */ + uint32_t share_deny; +}; +typedef struct OPEN_DOWNGRADE4args OPEN_DOWNGRADE4args; + +struct OPEN_DOWNGRADE4res { + nfsstat4 status; + stateid4 open_stateid; +}; +typedef struct OPEN_DOWNGRADE4res OPEN_DOWNGRADE4res; + +struct PUTFH4args { + nfs_fh4 object; +}; +typedef struct PUTFH4args PUTFH4args; + +/* + * Client only side PUTFH arguments + * This is really a nfs4_sharedfh_t * but the forward declaration + * is problematic; + */ +struct PUTFH4cargs { + void *sfh; +}; +typedef struct PUTFH4cargs PUTFH4cargs; + +struct PUTFH4res { + nfsstat4 status; +}; +typedef struct PUTFH4res PUTFH4res; + +struct PUTPUBFH4res { + nfsstat4 status; +}; +typedef struct PUTPUBFH4res PUTPUBFH4res; + +struct PUTROOTFH4res { + nfsstat4 status; +}; +typedef struct PUTROOTFH4res PUTROOTFH4res; + +struct READ4args { + stateid4 stateid; + offset4 offset; + count4 count; + /* The following are used for the XDR decode path */ + char *res_data_val_alt; + mblk_t *res_mblk; + struct uio *res_uiop; + uint_t res_maxsize; +#ifdef _KERNEL + struct clist *wlist; + CONN *conn; +#endif +}; +typedef struct READ4args READ4args; + +struct READ4res { + nfsstat4 status; + bool_t eof; + uint_t data_len; + char *data_val; + mblk_t *mblk; +#ifdef _KERNEL + struct clist *wlist; + uint_t wlist_len; +#endif +}; +typedef struct READ4res READ4res; + +struct rddir4_cache; + +struct READDIR4args { + nfs_cookie4 cookie; + verifier4 cookieverf; + count4 dircount; + count4 maxcount; + bitmap4 attr_request; + vnode_t *dvp; + struct mntinfo4 *mi; + cred_t *cr; + struct rddir4_cache *rdc; + hrtime_t t; +}; +typedef struct READDIR4args READDIR4args; + +struct READDIR4res_clnt { + nfsstat4 status; + verifier4 cookieverf; + bool_t eof; + struct dirent64 *dotp, *dotdotp; + struct rddir4_cache *rdc; +}; +typedef struct READDIR4res_clnt READDIR4res_clnt; + +struct READDIR4res { + nfsstat4 status; + verifier4 cookieverf; + mblk_t *mblk; + uint_t data_len; +}; +typedef struct READDIR4res READDIR4res; + +struct READLINK4res { + nfsstat4 status; + linktext4 link; +}; +typedef struct READLINK4res READLINK4res; + +struct REMOVE4args { + component4 target; +}; +typedef struct REMOVE4args REMOVE4args; + +struct REMOVE4cargs { + char *ctarget; +}; +typedef struct REMOVE4cargs REMOVE4cargs; + +struct REMOVE4res { + nfsstat4 status; + change_info4 cinfo; +}; +typedef struct REMOVE4res REMOVE4res; + +struct RENAME4args { + component4 oldname; + component4 newname; +}; +typedef struct RENAME4args RENAME4args; + +struct RENAME4cargs { + char *coldname; + char *cnewname; +}; +typedef struct RENAME4cargs RENAME4cargs; + +struct RENAME4res { + nfsstat4 status; + change_info4 source_cinfo; + change_info4 target_cinfo; +}; +typedef struct RENAME4res RENAME4res; + +struct RENEW4args { + clientid4 clientid; +}; +typedef struct RENEW4args RENEW4args; + +struct RENEW4res { + nfsstat4 status; +}; +typedef struct RENEW4res RENEW4res; + +struct RESTOREFH4res { + nfsstat4 status; +}; +typedef struct RESTOREFH4res RESTOREFH4res; + +struct SAVEFH4res { + nfsstat4 status; +}; +typedef struct SAVEFH4res SAVEFH4res; + +struct SECINFO4args { + component4 name; +}; +typedef struct SECINFO4args SECINFO4args; + +struct SECINFO4cargs { + char *cname; +}; +typedef struct SECINFO4cargs SECINFO4cargs; + +enum rpc_gss_svc_t { + RPC_GSS_SVC_NONE = 1, + RPC_GSS_SVC_INTEGRITY = 2, + RPC_GSS_SVC_PRIVACY = 3 +}; +typedef enum rpc_gss_svc_t rpc_gss_svc_t; + +struct rpcsec_gss_info { + sec_oid4 oid; + qop4 qop; + rpc_gss_svc_t service; +}; +typedef struct rpcsec_gss_info rpcsec_gss_info; + +struct secinfo4 { + uint32_t flavor; + rpcsec_gss_info flavor_info; +}; +typedef struct secinfo4 secinfo4; + +struct SECINFO4res { + nfsstat4 status; + uint_t SECINFO4resok_len; + secinfo4 *SECINFO4resok_val; +}; +typedef struct SECINFO4res SECINFO4res; + +struct SETATTR4args { + stateid4 stateid; + fattr4 obj_attributes; +}; +typedef struct SETATTR4args SETATTR4args; + +struct SETATTR4res { + nfsstat4 status; + bitmap4 attrsset; +}; +typedef struct SETATTR4res SETATTR4res; + +struct SETCLIENTID4args { + nfs_client_id4 client; + cb_client4 callback; + uint32_t callback_ident; +}; +typedef struct SETCLIENTID4args SETCLIENTID4args; + +struct SETCLIENTID4resok { + clientid4 clientid; + verifier4 setclientid_confirm; +}; +typedef struct SETCLIENTID4resok SETCLIENTID4resok; + +struct SETCLIENTID4res { + nfsstat4 status; + union { + SETCLIENTID4resok resok4; + clientaddr4 client_using; + } SETCLIENTID4res_u; +}; +typedef struct SETCLIENTID4res SETCLIENTID4res; + +struct SETCLIENTID_CONFIRM4args { + clientid4 clientid; + verifier4 setclientid_confirm; +}; +typedef struct SETCLIENTID_CONFIRM4args SETCLIENTID_CONFIRM4args; + +struct SETCLIENTID_CONFIRM4res { + nfsstat4 status; +}; +typedef struct SETCLIENTID_CONFIRM4res SETCLIENTID_CONFIRM4res; + +struct VERIFY4args { + fattr4 obj_attributes; +}; +typedef struct VERIFY4args VERIFY4args; + +struct VERIFY4res { + nfsstat4 status; +}; +typedef struct VERIFY4res VERIFY4res; + +/* + * mblk doesn't go over the wire. If non-NULL, it points to an mblk chain + * for the write data. + */ + +struct WRITE4args { + stateid4 stateid; + offset4 offset; + stable_how4 stable; + uint_t data_len; + char *data_val; + mblk_t *mblk; +#ifdef _KERNEL + struct clist *rlist; + CONN *conn; +#endif +}; +typedef struct WRITE4args WRITE4args; + +struct WRITE4res { + nfsstat4 status; + count4 count; + stable_how4 committed; + verifier4 writeverf; +}; +typedef struct WRITE4res WRITE4res; + +struct RELEASE_LOCKOWNER4args { + lock_owner4 lock_owner; +}; +typedef struct RELEASE_LOCKOWNER4args RELEASE_LOCKOWNER4args; + +struct RELEASE_LOCKOWNER4res { + nfsstat4 status; +}; +typedef struct RELEASE_LOCKOWNER4res RELEASE_LOCKOWNER4res; + +struct ILLEGAL4res { + nfsstat4 status; +}; +typedef struct ILLEGAL4res ILLEGAL4res; + +/* + * New operations for nfsv4.1 + */ +typedef struct { + uint_t gsshandle4_t_len; + char *gsshandle4_t_val; +} gsshandle4_t; + +struct gss_cb_handles4 { + rpc_gss_svc_t gcbp_service; + gsshandle4_t gcbp_handle_from_server; + gsshandle4_t gcbp_handle_from_client; +}; +typedef struct gss_cb_handles4 gss_cb_handles4; + +struct callback_sec_parms4 { + uint32_t cb_secflavor; + union { + authsys_parms cbsp_sys_cred; + gss_cb_handles4 cbsp_gss_handles; + } callback_sec_parms4_u; +}; +typedef struct callback_sec_parms4 callback_sec_parms4; + +struct BACKCHANNEL_CTL4args { + uint32_t bca_cb_program; + struct { + uint_t bca_sec_parms_len; + callback_sec_parms4 *bca_sec_parms_val; + } bca_sec_parms; +}; +typedef struct BACKCHANNEL_CTL4args BACKCHANNEL_CTL4args; + +struct BACKCHANNEL_CTL4res { + nfsstat4 bcr_status; +}; +typedef struct BACKCHANNEL_CTL4res BACKCHANNEL_CTL4res; + +enum channel_dir_from_client4 { + CDFC4_FORE = 0x1, + CDFC4_BACK = 0x2, + CDFC4_FORE_OR_BOTH = 0x3, + CDFC4_BACK_OR_BOTH = 0x7 +}; +typedef enum channel_dir_from_client4 channel_dir_from_client4; + +struct BIND_CONN_TO_SESSION4args { + sessionid4 bctsa_sessid; + channel_dir_from_client4 bctsa_dir; + bool_t bctsa_use_conn_in_rdma_mode; +}; +typedef struct BIND_CONN_TO_SESSION4args BIND_CONN_TO_SESSION4args; + +enum channel_dir_from_server4 { + CDFS4_FORE = 0x1, + CDFS4_BACK = 0x2, + CDFS4_BOTH = 0x3 +}; +typedef enum channel_dir_from_server4 channel_dir_from_server4; + +struct BIND_CONN_TO_SESSION4resok { + sessionid4 bctsr_sessid; + channel_dir_from_server4 bctsr_dir; + bool_t bctsr_use_conn_in_rdma_mode; +}; +typedef struct BIND_CONN_TO_SESSION4resok BIND_CONN_TO_SESSION4resok; + +struct BIND_CONN_TO_SESSION4res { + nfsstat4 bctsr_status; + union { + BIND_CONN_TO_SESSION4resok bctsr_resok4; + } BIND_CONN_TO_SESSION4res_u; +}; +typedef struct BIND_CONN_TO_SESSION4res BIND_CONN_TO_SESSION4res; + +#define EXCHGID4_FLAG_SUPP_MOVED_REFER 0x00000001 +#define EXCHGID4_FLAG_SUPP_MOVED_MIGR 0x00000002 +#define EXCHGID4_FLAG_BIND_PRINC_STATEID 0x00000100 + +#define EXCHGID4_FLAG_USE_NON_PNFS 0x00010000 +#define EXCHGID4_FLAG_USE_PNFS_MDS 0x00020000 +#define EXCHGID4_FLAG_USE_PNFS_DS 0x00040000 +#define EXCHGID4_FLAG_MASK_PNFS 0x00070000 + +#define EXCHGID4_FLAG_UPD_CONFIRMED_REC_A 0x40000000 +#define EXCHGID4_FLAG_CONFIRMED_R 0x80000000 + +#define EXID4_FLAG_MASK 0x40070103 + +struct state_protect_ops4 { + bitmap4 spo_must_enforce; + bitmap4 spo_must_allow; +}; +typedef struct state_protect_ops4 state_protect_ops4; + +struct ssv_sp_parms4 { + state_protect_ops4 ssp_ops; + struct { + uint_t ssp_hash_algs_len; + sec_oid4 *ssp_hash_algs_val; + } ssp_hash_algs; + struct { + uint_t ssp_encr_algs_len; + sec_oid4 *ssp_encr_algs_val; + } ssp_encr_algs; + uint32_t ssp_window; + uint32_t ssp_num_gss_handles; +}; +typedef struct ssv_sp_parms4 ssv_sp_parms4; + +enum state_protect_how4 { + SP4_NONE = 0, + SP4_MACH_CRED = 1, + SP4_SSV = 2 +}; +typedef enum state_protect_how4 state_protect_how4; + +struct state_protect4_a { + state_protect_how4 spa_how; + union { + state_protect_ops4 spa_mach_ops; + ssv_sp_parms4 spa_ssv_parms; + } state_protect4_a_u; +}; +typedef struct state_protect4_a state_protect4_a; + +struct EXCHANGE_ID4args { + client_owner4 eia_clientowner; + uint32_t eia_flags; + state_protect4_a eia_state_protect; + struct { + uint_t eia_client_impl_id_len; + nfs_impl_id4 *eia_client_impl_id_val; + } eia_client_impl_id; +}; +typedef struct EXCHANGE_ID4args EXCHANGE_ID4args; + +struct ssv_prot_info4 { + state_protect_ops4 spi_ops; + uint32_t spi_hash_alg; + uint32_t spi_encr_alg; + uint32_t spi_ssv_len; + uint32_t spi_window; + struct { + uint_t spi_handles_len; + gsshandle4_t *spi_handles_val; + } spi_handles; +}; +typedef struct ssv_prot_info4 ssv_prot_info4; + +struct state_protect4_r { + state_protect_how4 spr_how; + union { + state_protect_ops4 spr_mach_ops; + ssv_prot_info4 spr_ssv_info; + } state_protect4_r_u; +}; +typedef struct state_protect4_r state_protect4_r; + +struct EXCHANGE_ID4resok { + clientid4 eir_clientid; + sequenceid4 eir_sequenceid; + uint32_t eir_flags; + state_protect4_r eir_state_protect; + server_owner4 eir_server_owner; + struct eir_server_scope { + uint_t eir_server_scope_len; + char *eir_server_scope_val; + } eir_server_scope; + struct { + uint_t eir_server_impl_id_len; + nfs_impl_id4 *eir_server_impl_id_val; + } eir_server_impl_id; +}; +typedef struct EXCHANGE_ID4resok EXCHANGE_ID4resok; + +struct EXCHANGE_ID4res { + nfsstat4 eir_status; + union { + EXCHANGE_ID4resok eir_resok4; + } EXCHANGE_ID4res_u; +}; +typedef struct EXCHANGE_ID4res EXCHANGE_ID4res; + +struct channel_attrs4 { + count4 ca_headerpadsize; + count4 ca_maxrequestsize; + count4 ca_maxresponsesize; + count4 ca_maxresponsesize_cached; + count4 ca_maxoperations; + count4 ca_maxrequests; + struct { + uint_t ca_rdma_ird_len; + uint32_t *ca_rdma_ird_val; + } ca_rdma_ird; +}; +typedef struct channel_attrs4 channel_attrs4; + +#define CREATE_SESSION4_FLAG_PERSIST 0x00000001 +#define CREATE_SESSION4_FLAG_CONN_BACK_CHAN 0x00000002 +#define CREATE_SESSION4_FLAG_CONN_RDMA 0x00000004 + +#define CREATE_SESSION4_FLAG_MASK 0x07 + +struct CREATE_SESSION4args { + clientid4 csa_clientid; + sequenceid4 csa_sequence; + uint32_t csa_flags; + channel_attrs4 csa_fore_chan_attrs; + channel_attrs4 csa_back_chan_attrs; + uint32_t csa_cb_program; + struct { + uint_t csa_sec_parms_len; + callback_sec_parms4 *csa_sec_parms_val; + } csa_sec_parms; +}; +typedef struct CREATE_SESSION4args CREATE_SESSION4args; + +struct CREATE_SESSION4resok { + sessionid4 csr_sessionid; + sequenceid4 csr_sequence; + uint32_t csr_flags; + channel_attrs4 csr_fore_chan_attrs; + channel_attrs4 csr_back_chan_attrs; +}; +typedef struct CREATE_SESSION4resok CREATE_SESSION4resok; + +struct CREATE_SESSION4res { + nfsstat4 csr_status; + union { + CREATE_SESSION4resok csr_resok4; + } CREATE_SESSION4res_u; +}; +typedef struct CREATE_SESSION4res CREATE_SESSION4res; + +struct DESTROY_SESSION4args { + sessionid4 dsa_sessionid; +}; +typedef struct DESTROY_SESSION4args DESTROY_SESSION4args; + +struct DESTROY_SESSION4res { + nfsstat4 dsr_status; +}; +typedef struct DESTROY_SESSION4res DESTROY_SESSION4res; + +struct FREE_STATEID4args { + stateid4 fsa_stateid; +}; +typedef struct FREE_STATEID4args FREE_STATEID4args; + +struct FREE_STATEID4res { + nfsstat4 fsr_status; +}; +typedef struct FREE_STATEID4res FREE_STATEID4res; + +typedef nfstime4 attr_notice4; + +struct GET_DIR_DELEGATION4args { + bool_t gdda_signal_deleg_avail; + bitmap4 gdda_notification_types; + attr_notice4 gdda_child_attr_delay; + attr_notice4 gdda_dir_attr_delay; + bitmap4 gdda_child_attributes; + bitmap4 gdda_dir_attributes; +}; +typedef struct GET_DIR_DELEGATION4args GET_DIR_DELEGATION4args; + +struct GET_DIR_DELEGATION4resok { + verifier4 gddr_cookieverf; + stateid4 gddr_stateid; + bitmap4 gddr_notification; + bitmap4 gddr_child_attributes; + bitmap4 gddr_dir_attributes; +}; +typedef struct GET_DIR_DELEGATION4resok GET_DIR_DELEGATION4resok; + +enum gddrnf4_status { + GDD4_OK = 0, + GDD4_UNAVAIL = 1 +}; +typedef enum gddrnf4_status gddrnf4_status; + +struct GET_DIR_DELEGATION4res_non_fatal { + gddrnf4_status gddrnf_status; + union { + GET_DIR_DELEGATION4resok gddrnf_resok4; + bool_t gddrnf_will_signal_deleg_avail; + } GET_DIR_DELEGATION4res_non_fatal_u; +}; +typedef struct GET_DIR_DELEGATION4res_non_fatal + GET_DIR_DELEGATION4res_non_fatal; + +struct GET_DIR_DELEGATION4res { + nfsstat4 gddr_status; + union { + GET_DIR_DELEGATION4res_non_fatal gddr_res_non_fatal4; + } GET_DIR_DELEGATION4res_u; +}; +typedef struct GET_DIR_DELEGATION4res GET_DIR_DELEGATION4res; + +struct GETDEVICEINFO4args { + deviceid4 gdia_device_id; + layouttype4 gdia_layout_type; + count4 gdia_maxcount; + bitmap4 gdia_notify_types; +}; +typedef struct GETDEVICEINFO4args GETDEVICEINFO4args; + +struct GETDEVICEINFO4resok { + device_addr4 gdir_device_addr; + bitmap4 gdir_notification; +}; +typedef struct GETDEVICEINFO4resok GETDEVICEINFO4resok; + +struct GETDEVICEINFO4res { + nfsstat4 gdir_status; + union { + GETDEVICEINFO4resok gdir_resok4; + count4 gdir_mincount; + } GETDEVICEINFO4res_u; +}; +typedef struct GETDEVICEINFO4res GETDEVICEINFO4res; + +struct GETDEVICELIST4args { + layouttype4 gdla_layout_type; + count4 gdla_maxdevices; + nfs_cookie4 gdla_cookie; + verifier4 gdla_cookieverf; +}; +typedef struct GETDEVICELIST4args GETDEVICELIST4args; + +struct GETDEVICELIST4resok { + nfs_cookie4 gdlr_cookie; + verifier4 gdlr_cookieverf; + struct { + uint_t gdlr_deviceid_list_len; + deviceid4 *gdlr_deviceid_list_val; + } gdlr_deviceid_list; + bool_t gdlr_eof; +}; +typedef struct GETDEVICELIST4resok GETDEVICELIST4resok; + +struct GETDEVICELIST4res { + nfsstat4 gdlr_status; + union { + GETDEVICELIST4resok gdlr_resok4; + } GETDEVICELIST4res_u; +}; +typedef struct GETDEVICELIST4res GETDEVICELIST4res; + +struct newtime4 { + bool_t nt_timechanged; + union { + nfstime4 nt_time; + } newtime4_u; +}; +typedef struct newtime4 newtime4; + +struct newoffset4 { + bool_t no_newoffset; + union { + offset4 no_offset; + } newoffset4_u; +}; +typedef struct newoffset4 newoffset4; + +struct LAYOUTCOMMIT4args { + offset4 loca_offset; + length4 loca_length; + bool_t loca_reclaim; + stateid4 loca_stateid; + newoffset4 loca_last_write_offset; + newtime4 loca_time_modify; + layoutupdate4 loca_layoutupdate; +}; +typedef struct LAYOUTCOMMIT4args LAYOUTCOMMIT4args; + +struct newsize4 { + bool_t ns_sizechanged; + union { + length4 ns_size; + } newsize4_u; +}; +typedef struct newsize4 newsize4; + +struct LAYOUTCOMMIT4resok { + newsize4 locr_newsize; +}; +typedef struct LAYOUTCOMMIT4resok LAYOUTCOMMIT4resok; + +struct LAYOUTCOMMIT4res { + nfsstat4 locr_status; + union { + LAYOUTCOMMIT4resok locr_resok4; + } LAYOUTCOMMIT4res_u; +}; +typedef struct LAYOUTCOMMIT4res LAYOUTCOMMIT4res; + +struct LAYOUTGET4args { + bool_t loga_signal_layout_avail; + layouttype4 loga_layout_type; + layoutiomode4 loga_iomode; + offset4 loga_offset; + length4 loga_length; + length4 loga_minlength; + stateid4 loga_stateid; + count4 loga_maxcount; +}; +typedef struct LAYOUTGET4args LAYOUTGET4args; + +struct LAYOUTGET4resok { + bool_t logr_return_on_close; + stateid4 logr_stateid; + struct { + uint_t logr_layout_len; + layout4 *logr_layout_val; + } logr_layout; +}; +typedef struct LAYOUTGET4resok LAYOUTGET4resok; + +struct LAYOUTGET4res { + nfsstat4 logr_status; + union { + LAYOUTGET4resok logr_resok4; + bool_t logr_will_signal_layout_avail; + } LAYOUTGET4res_u; +}; +typedef struct LAYOUTGET4res LAYOUTGET4res; + +struct LAYOUTRETURN4args { + bool_t lora_reclaim; + layouttype4 lora_layout_type; + layoutiomode4 lora_iomode; + layoutreturn4 lora_layoutreturn; +}; +typedef struct LAYOUTRETURN4args LAYOUTRETURN4args; + +struct layoutreturn_stateid { + bool_t lrs_present; + union { + stateid4 lrs_stateid; + } layoutreturn_stateid_u; +}; +typedef struct layoutreturn_stateid layoutreturn_stateid; + +struct LAYOUTRETURN4res { + nfsstat4 lorr_status; + union { + layoutreturn_stateid lorr_stateid; + } LAYOUTRETURN4res_u; +}; +typedef struct LAYOUTRETURN4res LAYOUTRETURN4res; + +enum secinfo_style4 { + SECINFO_STYLE4_CURRENT_FH = 0, + SECINFO_STYLE4_PARENT = 1 +}; +typedef enum secinfo_style4 secinfo_style4; + +typedef secinfo_style4 SECINFO_NO_NAME4args; + +typedef SECINFO4res SECINFO_NO_NAME4res; + +struct SEQUENCE4args { + sessionid4 sa_sessionid; + sequenceid4 sa_sequenceid; + slotid4 sa_slotid; + slotid4 sa_highest_slotid; + bool_t sa_cachethis; +}; +typedef struct SEQUENCE4args SEQUENCE4args; +#define SEQ4_STATUS_CB_PATH_DOWN 0x00000001 +#define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING 0x00000002 +#define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED 0x00000004 +#define SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED 0x00000008 +#define SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED 0x00000010 +#define SEQ4_STATUS_ADMIN_STATE_REVOKED 0x00000020 +#define SEQ4_STATUS_RECALLABLE_STATE_REVOKED 0x00000040 +#define SEQ4_STATUS_LEASE_MOVED 0x00000080 +#define SEQ4_STATUS_RESTART_RECLAIM_NEEDED 0x00000100 +#define SEQ4_STATUS_CB_PATH_DOWN_SESSION 0x00000200 +#define SEQ4_STATUS_BACKCHANNEL_FAULT 0x00000400 +#define SEQ4_STATUS_DEVID_CHANGED 0x00000800 +#define SEQ4_STATUS_DEVID_DELETED 0x00001000 +#define SEQ4_HIGH_BIT SEQ4_STATUS_DEVID_DELETED /* highest defined flag */ + +struct SEQUENCE4resok { + sessionid4 sr_sessionid; + sequenceid4 sr_sequenceid; + slotid4 sr_slotid; + slotid4 sr_highest_slotid; + slotid4 sr_target_highest_slotid; + uint32_t sr_status_flags; +}; +typedef struct SEQUENCE4resok SEQUENCE4resok; + +struct SEQUENCE4res { + nfsstat4 sr_status; + union { + SEQUENCE4resok sr_resok4; + } SEQUENCE4res_u; +}; +typedef struct SEQUENCE4res SEQUENCE4res; + +struct ssa_digest_input4 { + SEQUENCE4args sdi_seqargs; +}; +typedef struct ssa_digest_input4 ssa_digest_input4; + +struct SET_SSV4args { + struct { + uint_t ssa_ssv_len; + char *ssa_ssv_val; + } ssa_ssv; + struct { + uint_t ssa_digest_len; + char *ssa_digest_val; + } ssa_digest; +}; +typedef struct SET_SSV4args SET_SSV4args; + +struct ssr_digest_input4 { + SEQUENCE4res sdi_seqres; +}; +typedef struct ssr_digest_input4 ssr_digest_input4; + +struct SET_SSV4resok { + struct { + uint_t ssr_digest_len; + char *ssr_digest_val; + } ssr_digest; +}; +typedef struct SET_SSV4resok SET_SSV4resok; + +struct SET_SSV4res { + nfsstat4 ssr_status; + union { + SET_SSV4resok ssr_resok4; + } SET_SSV4res_u; +}; +typedef struct SET_SSV4res SET_SSV4res; + +struct TEST_STATEID4args { + struct { + uint_t ts_stateids_len; + stateid4 *ts_stateids_val; + } ts_stateids; +}; +typedef struct TEST_STATEID4args TEST_STATEID4args; + +struct TEST_STATEID4resok { + struct { + uint_t tsr_status_codes_len; + nfsstat4 *tsr_status_codes_val; + } tsr_status_codes; +}; +typedef struct TEST_STATEID4resok TEST_STATEID4resok; + +struct TEST_STATEID4res { + nfsstat4 tsr_status; + union { + TEST_STATEID4resok tsr_resok4; + } TEST_STATEID4res_u; +}; +typedef struct TEST_STATEID4res TEST_STATEID4res; + +struct deleg_claim4 { + open_claim_type4 dc_claim; + union { + open_delegation_type4 dc_delegate_type; + } deleg_claim4_u; +}; +typedef struct deleg_claim4 deleg_claim4; + +struct WANT_DELEGATION4args { + uint32_t wda_want; + deleg_claim4 wda_claim; +}; +typedef struct WANT_DELEGATION4args WANT_DELEGATION4args; + +struct WANT_DELEGATION4res { + nfsstat4 wdr_status; + union { + open_delegation4 wdr_resok4; + } WANT_DELEGATION4res_u; +}; +typedef struct WANT_DELEGATION4res WANT_DELEGATION4res; + +struct DESTROY_CLIENTID4args { + clientid4 dca_clientid; +}; +typedef struct DESTROY_CLIENTID4args DESTROY_CLIENTID4args; + +struct DESTROY_CLIENTID4res { + nfsstat4 dcr_status; +}; +typedef struct DESTROY_CLIENTID4res DESTROY_CLIENTID4res; + +struct RECLAIM_COMPLETE4args { + bool_t rca_one_fs; +}; +typedef struct RECLAIM_COMPLETE4args RECLAIM_COMPLETE4args; + +struct RECLAIM_COMPLETE4res { + nfsstat4 rcr_status; +}; +typedef struct RECLAIM_COMPLETE4res RECLAIM_COMPLETE4res; + +/* + * New operations for nfsv4.2 + */ + +struct CLONE4args { + stateid4 cl_src_stateid; + stateid4 cl_dst_stateid; + offset4 cl_src_offset; + offset4 cl_dst_offset; + length4 cl_count; +}; +typedef struct CLONE4args CLONE4args; + +struct CLONE4res { + nfsstat4 cl_status; +}; +typedef struct CLONE4res CLONE4res; + +struct COPY4args { + stateid4 ca_src_stateid; + stateid4 ca_dst_stateid; + offset4 ca_src_offset; + offset4 ca_dst_offset; + length4 ca_count; + bool_t ca_consecutive; + bool_t ca_synchronous; + struct { + uint_t ca_source_server_len; + netloc4 *ca_source_server_val; + } ca_source_server; +}; +typedef struct COPY4args COPY4args; + +struct copy_requirements4 { + bool_t cr_consecutive; + bool_t cr_synchronous; +}; +typedef struct copy_requirements4 copy_requirements4; + +struct COPY4resok { + write_response4 cr_response; + copy_requirements4 cr_requirements; +}; +typedef struct COPY4resok COPY4resok; + +struct COPY4res { + nfsstat4 cr_status; + union { + COPY4resok cr_resok4; + copy_requirements4 cr_requirements; + } COPY4res_u; +}; +typedef struct COPY4res COPY4res; + +struct COPY_NOTIFY4args { + stateid4 cna_src_stateid; + netloc4 cna_destination_server; +}; +typedef struct COPY_NOTIFY4args COPY_NOTIFY4args; + +struct COPY_NOTIFY4resok { + nfstime4 cnr_lease_time; + stateid4 cnr_stateid; + struct { + uint_t cnr_source_server_len; + netloc4 *cnr_source_server_val; + } cnr_source_server; +}; +typedef struct COPY_NOTIFY4resok COPY_NOTIFY4resok; + +struct COPY_NOTIFY4res { + nfsstat4 cnr_status; + union { + COPY_NOTIFY4resok resok4; + } COPY_NOTIFY4res_u; +}; +typedef struct COPY_NOTIFY4res COPY_NOTIFY4res; + +struct OFFLOAD_CANCEL4args { + stateid4 oca_stateid; +}; +typedef struct OFFLOAD_CANCEL4args OFFLOAD_CANCEL4args; + +struct OFFLOAD_CANCEL4res { + nfsstat4 ocr_status; +}; +typedef struct OFFLOAD_CANCEL4res OFFLOAD_CANCEL4res; + +struct OFFLOAD_STATUS4args { + stateid4 osa_stateid; +}; +typedef struct OFFLOAD_STATUS4args OFFLOAD_STATUS4args; + +struct OFFLOAD_STATUS4resok { + length4 osr_count; + struct { + uint_t osr_complete_len; + nfsstat4 *osr_complete_val; + } osr_complete; +}; +typedef struct OFFLOAD_STATUS4resok OFFLOAD_STATUS4resok; + +struct OFFLOAD_STATUS4res { + nfsstat4 osr_status; + union { + OFFLOAD_STATUS4resok osr_resok4; + } OFFLOAD_STATUS4res_u; +}; +typedef struct OFFLOAD_STATUS4res OFFLOAD_STATUS4res; + +struct ALLOCATE4args { + stateid4 aa_stateid; + offset4 aa_offset; + length4 aa_length; +}; +typedef struct ALLOCATE4args ALLOCATE4args; + +struct ALLOCATE4res { + nfsstat4 ar_status; +}; +typedef struct ALLOCATE4res ALLOCATE4res; + +struct DEALLOCATE4args { + stateid4 da_stateid; + offset4 da_offset; + length4 da_length; +}; +typedef struct DEALLOCATE4args DEALLOCATE4args; + +struct DEALLOCATE4res { + nfsstat4 dr_status; +}; +typedef struct DEALLOCATE4res DEALLOCATE4res; + +enum IO_ADVISE_type4 { + IO_ADVISE4_NORMAL = 0, + IO_ADVISE4_SEQUENTIAL = 1, + IO_ADVISE4_SEQUENTIAL_BACKWARDS = 2, + IO_ADVISE4_RANDOM = 3, + IO_ADVISE4_WILLNEED = 4, + IO_ADVISE4_WILLNEED_OPPORTUNISTIC = 5, + IO_ADVISE4_DONTNEED = 6, + IO_ADVISE4_NOREUSE = 7, + IO_ADVISE4_READ = 8, + IO_ADVISE4_WRITE = 9, + IO_ADVISE4_INIT_PROXIMITY = 10 +}; +typedef enum IO_ADVISE_type4 IO_ADVISE_type4; + +struct IO_ADVISE4args { + stateid4 iaa_stateid; + offset4 iaa_offset; + length4 iaa_count; + bitmap4 iaa_hints; +}; +typedef struct IO_ADVISE4args IO_ADVISE4args; + +struct IO_ADVISE4resok { + bitmap4 ior_hints; +}; +typedef struct IO_ADVISE4resok IO_ADVISE4resok; + +struct IO_ADVISE4res { + nfsstat4 ior_status; + union { + IO_ADVISE4resok resok4; + } IO_ADVISE4res_u; +}; +typedef struct IO_ADVISE4res IO_ADVISE4res; + +struct device_error4 { + deviceid4 de_deviceid; + nfsstat4 de_status; + nfs_opnum4 de_opnum; +}; +typedef struct device_error4 device_error4; + +struct LAYOUTERROR4args { + offset4 lea_offset; + length4 lea_length; + stateid4 lea_stateid; + struct { + uint_t lea_errors_len; + device_error4 *lea_errors_val; + } lea_errors; +}; +typedef struct LAYOUTERROR4args LAYOUTERROR4args; + +struct LAYOUTERROR4res { + nfsstat4 ler_status; +}; +typedef struct LAYOUTERROR4res LAYOUTERROR4res; + +struct io_info4 { + uint64_t ii_count; + uint64_t ii_bytes; +}; +typedef struct io_info4 io_info4; + +struct LAYOUTSTATS4args { + offset4 lsa_offset; + length4 lsa_length; + stateid4 lsa_stateid; + io_info4 lsa_read; + io_info4 lsa_write; + deviceid4 lsa_deviceid; + layoutupdate4 lsa_layoutupdate; +}; +typedef struct LAYOUTSTATS4args LAYOUTSTATS4args; + +struct LAYOUTSTATS4res { + nfsstat4 lsr_status; +}; +typedef struct LAYOUTSTATS4res LAYOUTSTATS4res; + +struct READ_PLUS4args { + stateid4 rpa_stateid; + offset4 rpa_offset; + count4 rpa_count; +}; +typedef struct READ_PLUS4args READ_PLUS4args; + +struct read_plus_content { + data_content4 rpc_content; + union { + data4 rpc_data; + data_info4 rpc_hole; + } read_plus_content_u; +}; +typedef struct read_plus_content read_plus_content; + +struct read_plus_res4 { + bool_t rpr_eof; + struct { + uint_t rpr_contents_len; + read_plus_content *rpr_contents_val; + } rpr_contents; +}; +typedef struct read_plus_res4 read_plus_res4; + +struct READ_PLUS4res { + nfsstat4 rp_status; + union { + read_plus_res4 rp_resok4; + } READ_PLUS4res_u; +}; +typedef struct READ_PLUS4res READ_PLUS4res; + +struct SEEK4args { + stateid4 sa_stateid; + offset4 sa_offset; + data_content4 sa_what; +}; +typedef struct SEEK4args SEEK4args; + +struct seek_res4 { + bool_t sr_eof; + offset4 sr_offset; +}; +typedef struct seek_res4 seek_res4; + +struct SEEK4res { + nfsstat4 sa_status; + union { + seek_res4 resok4; + } SEEK4res_u; +}; +typedef struct SEEK4res SEEK4res; + +struct WRITE_SAME4args { + stateid4 wsa_stateid; + stable_how4 wsa_stable; + app_data_block4 wsa_adb; +}; +typedef struct WRITE_SAME4args WRITE_SAME4args; + +struct WRITE_SAME4res { + nfsstat4 wsr_status; + union { + write_response4 resok4; + } WRITE_SAME4res_u; +}; +typedef struct WRITE_SAME4res WRITE_SAME4res; + +/* new operations for NFSv4.2 end */ + +struct nfs_argop4 { + nfs_opnum4 argop; + union { + ACCESS4args opaccess; + CLOSE4args opclose; + COMMIT4args opcommit; + CREATE4args opcreate; + CREATE4cargs opccreate; + DELEGPURGE4args opdelegpurge; + DELEGRETURN4args opdelegreturn; + GETATTR4args opgetattr; + LINK4args oplink; + LINK4cargs opclink; + LOCK4args oplock; + LOCKT4args oplockt; + LOCKU4args oplocku; + LOOKUP4args oplookup; + LOOKUP4cargs opclookup; + NVERIFY4args opnverify; + OPEN4args opopen; + OPEN4cargs opcopen; + OPENATTR4args opopenattr; + OPEN_CONFIRM4args opopen_confirm; + OPEN_DOWNGRADE4args opopen_downgrade; + PUTFH4args opputfh; + PUTFH4cargs opcputfh; + READ4args opread; + READDIR4args opreaddir; + REMOVE4args opremove; + REMOVE4cargs opcremove; + RENAME4args oprename; + RENAME4cargs opcrename; + RENEW4args oprenew; + SECINFO4args opsecinfo; + SECINFO4cargs opcsecinfo; + SETATTR4args opsetattr; + SETCLIENTID4args opsetclientid; + SETCLIENTID_CONFIRM4args opsetclientid_confirm; + VERIFY4args opverify; + WRITE4args opwrite; + RELEASE_LOCKOWNER4args oprelease_lockowner; + BACKCHANNEL_CTL4args opbackchannel_ctl; /* nfsv4.1 */ + BIND_CONN_TO_SESSION4args opbind_conn_to_session; + EXCHANGE_ID4args opexchange_id; + CREATE_SESSION4args opcreate_session; + DESTROY_SESSION4args opdestroy_session; + FREE_STATEID4args opfree_stateid; + GET_DIR_DELEGATION4args opget_dir_delegation; + GETDEVICEINFO4args opgetdeviceinfo; + GETDEVICELIST4args opgetdevicelist; + LAYOUTCOMMIT4args oplayoutcommit; + LAYOUTGET4args oplayoutget; + LAYOUTRETURN4args oplayoutreturn; + SECINFO_NO_NAME4args opsecinfo_no_name; + SEQUENCE4args opsequence; + SET_SSV4args opset_ssv; + TEST_STATEID4args optest_stateid; + WANT_DELEGATION4args opwant_delegation; + DESTROY_CLIENTID4args opdestroy_clientid; + RECLAIM_COMPLETE4args opreclaim_complete; + /* nfsv4.2 */ + ALLOCATE4args opallocate; + COPY4args opcopy; + COPY_NOTIFY4args opoffload_notify; + DEALLOCATE4args opdeallocate; + IO_ADVISE4args opio_advise; + LAYOUTERROR4args oplayouterror; + LAYOUTSTATS4args oplayoutstats; + OFFLOAD_CANCEL4args opoffload_cancel; + OFFLOAD_STATUS4args opoffload_status; + READ_PLUS4args opread_plus; + SEEK4args opseek; + WRITE_SAME4args opwrite_same; + CLONE4args opclone; + } nfs_argop4_u; +}; +typedef struct nfs_argop4 nfs_argop4; + +struct nfs_resop4 { + nfs_opnum4 resop; + union { + ACCESS4res opaccess; + CLOSE4res opclose; + COMMIT4res opcommit; + CREATE4res opcreate; + DELEGPURGE4res opdelegpurge; + DELEGRETURN4res opdelegreturn; + GETATTR4res opgetattr; + GETFH4res opgetfh; + LINK4res oplink; + LOCK4res oplock; + LOCKT4res oplockt; + LOCKU4res oplocku; + LOOKUP4res oplookup; + LOOKUPP4res oplookupp; + NVERIFY4res opnverify; + OPEN4res opopen; + OPENATTR4res opopenattr; + OPEN_CONFIRM4res opopen_confirm; + OPEN_DOWNGRADE4res opopen_downgrade; + PUTFH4res opputfh; + PUTPUBFH4res opputpubfh; + PUTROOTFH4res opputrootfh; + READ4res opread; + READDIR4res opreaddir; + READDIR4res_clnt opreaddirclnt; + READLINK4res opreadlink; + REMOVE4res opremove; + RENAME4res oprename; + RENEW4res oprenew; + RESTOREFH4res oprestorefh; + SAVEFH4res opsavefh; + SECINFO4res opsecinfo; + SETATTR4res opsetattr; + SETCLIENTID4res opsetclientid; + SETCLIENTID_CONFIRM4res opsetclientid_confirm; + VERIFY4res opverify; + WRITE4res opwrite; + RELEASE_LOCKOWNER4res oprelease_lockowner; + BACKCHANNEL_CTL4res opbackchannel_ctl; /* nfsv4.1 */ + BIND_CONN_TO_SESSION4res opbind_conn_to_session; + EXCHANGE_ID4res opexchange_id; + CREATE_SESSION4res opcreate_session; + DESTROY_SESSION4res opdestroy_session; + FREE_STATEID4res opfree_stateid; + GET_DIR_DELEGATION4res opget_dir_delegation; + GETDEVICEINFO4res opgetdeviceinfo; + GETDEVICELIST4res opgetdevicelist; + LAYOUTCOMMIT4res oplayoutcommit; + LAYOUTGET4res oplayoutget; + LAYOUTRETURN4res oplayoutreturn; + SECINFO_NO_NAME4res opsecinfo_no_name; + SEQUENCE4res opsequence; + SET_SSV4res opset_ssv; + TEST_STATEID4res optest_stateid; + WANT_DELEGATION4res opwant_delegation; + DESTROY_CLIENTID4res opdestroy_clientid; + RECLAIM_COMPLETE4res opreclaim_complete; + /* nfsv4.2 */ + ALLOCATE4res opallocate; + COPY4res opcopy; + COPY_NOTIFY4res opcopy_notify; + DEALLOCATE4res opdeallocate; + IO_ADVISE4res opio_advise; + LAYOUTERROR4res oplayouterror; + LAYOUTSTATS4res oplayoutstats; + OFFLOAD_CANCEL4res opoffload_cancel; + OFFLOAD_STATUS4res opoffload_status; + READ_PLUS4res opread_plus; + SEEK4res opseek; + WRITE_SAME4res opwrite_same; + CLONE4res opclone; + + ILLEGAL4res opillegal; + } nfs_resop4_u; +}; +typedef struct nfs_resop4 nfs_resop4; + +/* + * Fixed size tag string for easy client encoding + */ +struct _ctag { + int ct_type; + char *ct_str; + uint32_t ct_tag[3]; +}; +typedef struct _ctag ctag_t; + +/* + * Client-only encode-only version + */ +struct COMPOUND4args_clnt { + int ctag; + uint_t array_len; + nfs_argop4 *array; +}; +typedef struct COMPOUND4args_clnt COMPOUND4args_clnt; + +struct COMPOUND4args { + utf8string tag; + uint32_t minorversion; + uint_t array_len; + nfs_argop4 *array; +}; +typedef struct COMPOUND4args COMPOUND4args; + +struct COMPOUND4res_clnt { + nfsstat4 status; + uint_t array_len; + uint_t decode_len; + nfs_resop4 *array; + COMPOUND4args_clnt *argsp; +}; +typedef struct COMPOUND4res_clnt COMPOUND4res_clnt; + +struct COMPOUND4res { + nfsstat4 status; + utf8string tag; + uint_t array_len; + nfs_resop4 *array; +}; +typedef struct COMPOUND4res COMPOUND4res; + +struct CB_GETATTR4args { + nfs_fh4 fh; + bitmap4 attr_request; +}; +typedef struct CB_GETATTR4args CB_GETATTR4args; + +struct CB_GETATTR4res { + nfsstat4 status; + fattr4 obj_attributes; +}; +typedef struct CB_GETATTR4res CB_GETATTR4res; + +struct CB_RECALL4args { + stateid4 stateid; + bool_t truncate; + nfs_fh4 fh; +}; +typedef struct CB_RECALL4args CB_RECALL4args; + +struct CB_RECALL4res { + nfsstat4 status; +}; +typedef struct CB_RECALL4res CB_RECALL4res; + +struct CB_ILLEGAL4res { + nfsstat4 status; +}; +typedef struct CB_ILLEGAL4res CB_ILLEGAL4res; + +/* + * New to nfsv4.1 + */ +enum layoutrecall_type4 { + LAYOUTRECALL4_FILE = LAYOUT4_RET_REC_FILE, + LAYOUTRECALL4_FSID = LAYOUT4_RET_REC_FSID, + LAYOUTRECALL4_ALL = LAYOUT4_RET_REC_ALL +}; +typedef enum layoutrecall_type4 layoutrecall_type4; + +struct layoutrecall_file4 { + nfs_fh4 lor_fh; + offset4 lor_offset; + length4 lor_length; + stateid4 lor_stateid; +}; +typedef struct layoutrecall_file4 layoutrecall_file4; + +struct layoutrecall4 { + layoutrecall_type4 lor_recalltype; + union { + layoutrecall_file4 lor_layout; + fsid4 lor_fsid; + } layoutrecall4_u; +}; +typedef struct layoutrecall4 layoutrecall4; + +struct CB_LAYOUTRECALL4args { + layouttype4 clora_type; + layoutiomode4 clora_iomode; + bool_t clora_changed; + layoutrecall4 clora_recall; +}; +typedef struct CB_LAYOUTRECALL4args CB_LAYOUTRECALL4args; + +struct CB_LAYOUTRECALL4res { + nfsstat4 clorr_status; +}; +typedef struct CB_LAYOUTRECALL4res CB_LAYOUTRECALL4res; + +enum notify_type4 { + NOTIFY4_CHANGE_CHILD_ATTRS = 0, + NOTIFY4_CHANGE_DIR_ATTRS = 1, + NOTIFY4_REMOVE_ENTRY = 2, + NOTIFY4_ADD_ENTRY = 3, + NOTIFY4_RENAME_ENTRY = 4, + NOTIFY4_CHANGE_COOKIE_VERIFIER = 5 +}; +typedef enum notify_type4 notify_type4; + +struct notify_entry4 { + component4 ne_file; + fattr4 ne_attrs; +}; +typedef struct notify_entry4 notify_entry4; + +struct prev_entry4 { + notify_entry4 pe_prev_entry; + nfs_cookie4 pe_prev_entry_cookie; +}; +typedef struct prev_entry4 prev_entry4; + +struct notify_remove4 { + notify_entry4 nrm_old_entry; + nfs_cookie4 nrm_old_entry_cookie; +}; +typedef struct notify_remove4 notify_remove4; + +struct notify_add4 { + struct { + uint_t nad_old_entry_len; + notify_remove4 *nad_old_entry_val; + } nad_old_entry; + notify_entry4 nad_new_entry; + struct { + uint_t nad_new_entry_cookie_len; + nfs_cookie4 *nad_new_entry_cookie_val; +} nad_new_entry_cookie; + struct { + uint_t nad_prev_entry_len; + prev_entry4 *nad_prev_entry_val; + } nad_prev_entry; + bool_t nad_last_entry; +}; +typedef struct notify_add4 notify_add4; + +struct notify_attr4 { + notify_entry4 na_changed_entry; +}; +typedef struct notify_attr4 notify_attr4; + +struct notify_rename4 { + notify_remove4 nrn_old_entry; + notify_add4 nrn_new_entry; +}; +typedef struct notify_rename4 notify_rename4; + +struct notify_verifier4 { + verifier4 nv_old_cookieverf; + verifier4 nv_new_cookieverf; +}; +typedef struct notify_verifier4 notify_verifier4; + +typedef struct { + uint_t notifylist4_len; + char *notifylist4_val; +} notifylist4; + +struct notify4 { + bitmap4 notify_mask; + notifylist4 notify_vals; +}; +typedef struct notify4 notify4; + +struct CB_NOTIFY4args { + stateid4 cna_stateid; + nfs_fh4 cna_fh; + struct { + uint_t cna_changes_len; + notify4 *cna_changes_val; + } cna_changes; +}; +typedef struct CB_NOTIFY4args CB_NOTIFY4args; + +struct CB_NOTIFY4res { + nfsstat4 cnr_status; +}; +typedef struct CB_NOTIFY4res CB_NOTIFY4res; + +struct CB_PUSH_DELEG4args { + nfs_fh4 cpda_fh; + open_delegation4 cpda_delegation; +}; +typedef struct CB_PUSH_DELEG4args CB_PUSH_DELEG4args; + +struct CB_PUSH_DELEG4res { + nfsstat4 cpdr_status; +}; +typedef struct CB_PUSH_DELEG4res CB_PUSH_DELEG4res; +#define RCA4_TYPE_MASK_RDATA_DLG 0 +#define RCA4_TYPE_MASK_WDATA_DLG 1 +#define RCA4_TYPE_MASK_DIR_DLG 2 +#define RCA4_TYPE_MASK_FILE_LAYOUT 3 +#define RCA4_TYPE_MASK_BLK_LAYOUT 4 +#define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN 8 +#define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX 9 +#define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12 +#define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15 + +struct CB_RECALL_ANY4args { + uint32_t craa_objects_to_keep; + bitmap4 craa_type_mask; +}; +typedef struct CB_RECALL_ANY4args CB_RECALL_ANY4args; + +struct CB_RECALL_ANY4res { + nfsstat4 crar_status; +}; +typedef struct CB_RECALL_ANY4res CB_RECALL_ANY4res; + +typedef CB_RECALL_ANY4args CB_RECALLABLE_OBJ_AVAIL4args; + +struct CB_RECALLABLE_OBJ_AVAIL4res { + nfsstat4 croa_status; +}; +typedef struct CB_RECALLABLE_OBJ_AVAIL4res CB_RECALLABLE_OBJ_AVAIL4res; + +struct CB_RECALL_SLOT4args { + slotid4 rsa_target_highest_slotid; +}; +typedef struct CB_RECALL_SLOT4args CB_RECALL_SLOT4args; + +struct CB_RECALL_SLOT4res { + nfsstat4 rsr_status; +}; +typedef struct CB_RECALL_SLOT4res CB_RECALL_SLOT4res; + +struct referring_call4 { + sequenceid4 rc_sequenceid; + slotid4 rc_slotid; +}; +typedef struct referring_call4 referring_call4; + +struct referring_call_list4 { + sessionid4 rcl_sessionid; + struct { + uint_t rcl_referring_calls_len; + referring_call4 *rcl_referring_calls_val; + } rcl_referring_calls; +}; +typedef struct referring_call_list4 referring_call_list4; + +struct CB_SEQUENCE4args { + sessionid4 csa_sessionid; + sequenceid4 csa_sequenceid; + slotid4 csa_slotid; + slotid4 csa_highest_slotid; + bool_t csa_cachethis; + struct { + uint_t csa_referring_call_lists_len; + referring_call_list4 *csa_referring_call_lists_val; + } csa_referring_call_lists; +}; +typedef struct CB_SEQUENCE4args CB_SEQUENCE4args; + +struct CB_SEQUENCE4resok { + sessionid4 csr_sessionid; + sequenceid4 csr_sequenceid; + slotid4 csr_slotid; + slotid4 csr_highest_slotid; + slotid4 csr_target_highest_slotid; +}; +typedef struct CB_SEQUENCE4resok CB_SEQUENCE4resok; + +struct CB_SEQUENCE4res { + nfsstat4 csr_status; + union { + CB_SEQUENCE4resok csr_resok4; + } CB_SEQUENCE4res_u; +}; +typedef struct CB_SEQUENCE4res CB_SEQUENCE4res; + +struct CB_WANTS_CANCELLED4args { + bool_t cwca_contended_wants_cancelled; + bool_t cwca_resourced_wants_cancelled; +}; +typedef struct CB_WANTS_CANCELLED4args CB_WANTS_CANCELLED4args; + +struct CB_WANTS_CANCELLED4res { + nfsstat4 cwcr_status; +}; +typedef struct CB_WANTS_CANCELLED4res CB_WANTS_CANCELLED4res; + +struct CB_NOTIFY_LOCK4args { + nfs_fh4 cnla_fh; + lock_owner4 cnla_lock_owner; +}; +typedef struct CB_NOTIFY_LOCK4args CB_NOTIFY_LOCK4args; + +struct CB_NOTIFY_LOCK4res { + nfsstat4 cnlr_status; +}; +typedef struct CB_NOTIFY_LOCK4res CB_NOTIFY_LOCK4res; + +enum notify_deviceid_type4 { + NOTIFY_DEVICEID4_CHANGE = 1, + NOTIFY_DEVICEID4_DELETE = 2 +}; +typedef enum notify_deviceid_type4 notify_deviceid_type4; + +struct notify_deviceid_delete4 { + layouttype4 ndd_layouttype; + deviceid4 ndd_deviceid; +}; +typedef struct notify_deviceid_delete4 notify_deviceid_delete4; + +struct notify_deviceid_change4 { + layouttype4 ndc_layouttype; + deviceid4 ndc_deviceid; + bool_t ndc_immediate; +}; +typedef struct notify_deviceid_change4 notify_deviceid_change4; + +struct CB_NOTIFY_DEVICEID4args { + struct { + uint_t cnda_changes_len; + notify4 *cnda_changes_val; + } cnda_changes; +}; +typedef struct CB_NOTIFY_DEVICEID4args CB_NOTIFY_DEVICEID4args; + +struct CB_NOTIFY_DEVICEID4res { + nfsstat4 cndr_status; +}; +typedef struct CB_NOTIFY_DEVICEID4res CB_NOTIFY_DEVICEID4res; + +/* Callback operations new to NFSv4.1 */ + +enum nfs_cb_opnum4 { + OP_CB_GETATTR = 3, + OP_CB_RECALL = 4, + OP_CB_LAYOUTRECALL = 5, + OP_CB_NOTIFY = 6, + OP_CB_PUSH_DELEG = 7, + OP_CB_RECALL_ANY = 8, + OP_CB_RECALLABLE_OBJ_AVAIL = 9, + OP_CB_RECALL_SLOT = 10, + OP_CB_SEQUENCE = 11, + OP_CB_WANTS_CANCELLED = 12, + OP_CB_NOTIFY_LOCK = 13, + OP_CB_NOTIFY_DEVICEID = 14, + OP_CB_OFFLOAD = 15, /* nfsv4.2 */ + OP_CB_ILLEGAL = 10044 +}; +typedef enum nfs_cb_opnum4 nfs_cb_opnum4; + +struct nfs_cb_argop4 { + uint_t argop; + union { + CB_GETATTR4args opcbgetattr; + CB_RECALL4args opcbrecall; + CB_LAYOUTRECALL4args opcblayoutrecall; + CB_NOTIFY4args opcbnotify; + CB_PUSH_DELEG4args opcbpush_deleg; + CB_RECALL_ANY4args opcbrecall_any; + CB_RECALLABLE_OBJ_AVAIL4args opcbrecallable_obj_avail; + CB_RECALL_SLOT4args opcbrecall_slot; + CB_SEQUENCE4args opcbsequence; + CB_WANTS_CANCELLED4args opcbwants_cancelled; + CB_NOTIFY_LOCK4args opcbnotify_lock; + CB_NOTIFY_DEVICEID4args opcbnotify_deviceid; + } nfs_cb_argop4_u; +}; +typedef struct nfs_cb_argop4 nfs_cb_argop4; + +struct nfs_cb_resop4 { + uint_t resop; + union { + CB_GETATTR4res opcbgetattr; + CB_RECALL4res opcbrecall; + CB_LAYOUTRECALL4res opcblayoutrecall; + CB_NOTIFY4res opcbnotify; + CB_PUSH_DELEG4res opcbpush_deleg; + CB_RECALL_ANY4res opcbrecall_any; + CB_RECALLABLE_OBJ_AVAIL4res opcbrecallable_obj_avail; + CB_RECALL_SLOT4res opcbrecall_slot; + CB_SEQUENCE4res opcbsequence; + CB_WANTS_CANCELLED4res opcbwants_cancelled; + CB_NOTIFY_LOCK4res opcbnotify_lock; + CB_NOTIFY_DEVICEID4res opcbnotify_deviceid; + CB_ILLEGAL4res opcbillegal; + } nfs_cb_resop4_u; +}; +typedef struct nfs_cb_resop4 nfs_cb_resop4; + +struct CB_COMPOUND4args { + utf8string tag; + uint32_t minorversion; + uint32_t callback_ident; + uint_t array_len; + nfs_cb_argop4 *array; +}; +typedef struct CB_COMPOUND4args CB_COMPOUND4args; + +struct CB_COMPOUND4res { + nfsstat4 status; + utf8string tag; + uint_t array_len; + nfs_cb_resop4 *array; +}; +typedef struct CB_COMPOUND4res CB_COMPOUND4res; + +#define NFS4_PROGRAM 100003 +#define NFS_V4 4 +#define NFSPROC4_NULL 0 +#define NFSPROC4_COMPOUND 1 + +#define NFS4_CALLBACK 0x40000000 +#define NFS_CB 1 +#define CB_NULL 0 +#define CB_COMPOUND 1 + +extern bool_t xdr_bitmap4(XDR *, bitmap4 *); +extern bool_t xdr_utf8string(XDR *, utf8string *); +extern bool_t xdr_nfs_fh4(XDR *, nfs_fh4 *); +extern bool_t xdr_fattr4_fsid(XDR *, fattr4_fsid *); +extern bool_t xdr_fattr4_acl(XDR *, fattr4_acl *); +extern bool_t xdr_fattr4_fs_locations(XDR *, fattr4_fs_locations *); +extern bool_t xdr_fattr4_rawdev(XDR *, fattr4_rawdev *); +extern bool_t xdr_nfstime4(XDR *, nfstime4 *); +extern bool_t xdr_settime4(XDR *, settime4 *); +extern bool_t xdr_COMPOUND4args_clnt(XDR *, COMPOUND4args_clnt *); +extern bool_t xdr_COMPOUND4args_srv(XDR *, COMPOUND4args *); +extern bool_t xdr_COMPOUND4res_clnt(XDR *, COMPOUND4res_clnt *); +extern bool_t xdr_COMPOUND4res_srv(XDR *, COMPOUND4res *); +extern bool_t xdr_CB_COMPOUND4args_clnt(XDR *, CB_COMPOUND4args *); +extern bool_t xdr_CB_COMPOUND4args_srv(XDR *, CB_COMPOUND4args *); +extern bool_t xdr_CB_COMPOUND4res(XDR *, CB_COMPOUND4res *); + +/* New XDR to nfsv4.1 */ +extern bool_t xdr_nfs_ftype4(XDR *, nfs_ftype4*); +extern bool_t xdr_nfsstat4(XDR *, nfsstat4*); +extern bool_t xdr_attrlist4(XDR *, attrlist4*); +extern bool_t xdr_bitmap4(XDR *, bitmap4*); +extern bool_t xdr_changeid4(XDR *, changeid4*); +extern bool_t xdr_clientid4(XDR *, clientid4*); +extern bool_t xdr_count4(XDR *, count4*); +extern bool_t xdr_length4(XDR *, length4*); +extern bool_t xdr_mode4(XDR *, mode4*); +extern bool_t xdr_nfs_cookie4(XDR *, nfs_cookie4*); +extern bool_t xdr_nfs_fh4(XDR *, nfs_fh4*); +extern bool_t xdr_offset4(XDR *, offset4*); +extern bool_t xdr_qop4(XDR *, qop4*); +extern bool_t xdr_sec_oid4(XDR *, sec_oid4*); +extern bool_t xdr_sequenceid4(XDR *, sequenceid4*); +extern bool_t xdr_seqid4(XDR *, seqid4*); +extern bool_t xdr_sessionid4(XDR *, sessionid4); +extern bool_t xdr_slotid4(XDR *, slotid4*); +extern bool_t xdr_utf8string(XDR *, utf8string*); +extern bool_t xdr_utf8str_cis(XDR *, utf8str_cis*); +extern bool_t xdr_utf8str_cs(XDR *, utf8str_cs*); +extern bool_t xdr_utf8str_mixed(XDR *, utf8str_mixed*); +extern bool_t xdr_component4(XDR *, component4*); +extern bool_t xdr_linktext4(XDR *, linktext4*); +extern bool_t xdr_pathname4(XDR *, pathname4*); +extern bool_t xdr_verifier4(XDR *, verifier4*); +extern bool_t xdr_nfstime4(XDR *, nfstime4*); +extern bool_t xdr_time_how4(XDR *, time_how4*); +extern bool_t xdr_settime4(XDR *, settime4*); +extern bool_t xdr_nfs_lease4(XDR *, nfs_lease4*); +extern bool_t xdr_fsid4(XDR *, fsid4*); +extern bool_t xdr_change_policy4(XDR *, change_policy4*); +extern bool_t xdr_fs_locations4(XDR *, fs_locations4*); +extern bool_t xdr_acetype4(XDR *, acetype4*); +extern bool_t xdr_aceflag4(XDR *, aceflag4*); +extern bool_t xdr_acemask4(XDR *, acemask4*); +extern bool_t xdr_nfsace4(XDR *, nfsace4*); +extern bool_t xdr_aclflag4(XDR *, aclflag4*); +extern bool_t xdr_nfsacl41(XDR *, nfsacl41*); +extern bool_t xdr_mode_masked4(XDR *, mode_masked4*); +extern bool_t xdr_specdata4(XDR *, specdata4*); +extern bool_t xdr_netaddr4(XDR *, netaddr4*); +extern bool_t xdr_nfs_impl_id4(XDR *, nfs_impl_id4*); +extern bool_t xdr_stateid4(XDR *, stateid4*); +extern bool_t xdr_layouttype4(XDR *, layouttype4*); +extern bool_t xdr_layout_content4(XDR *, layout_content4*); +extern bool_t xdr_layouthint4(XDR *, layouthint4*); +extern bool_t xdr_layoutiomode4(XDR *, layoutiomode4*); +extern bool_t xdr_layout4(XDR *, layout4*); +extern bool_t xdr_deviceid4(XDR *, deviceid4); +extern bool_t xdr_device_addr4(XDR *, device_addr4*); +extern bool_t xdr_layoutupdate4(XDR *, layoutupdate4*); +extern bool_t xdr_layoutreturn_type4(XDR *, layoutreturn_type4*); +extern bool_t xdr_layoutreturn_file4(XDR *, layoutreturn_file4*); +extern bool_t xdr_layoutreturn4(XDR *, layoutreturn4*); +extern bool_t xdr_fs4_status_type(XDR *, fs4_status_type*); +extern bool_t xdr_fs4_status(XDR *, fs4_status*); +extern bool_t xdr_threshold4_read_size(XDR *, threshold4_read_size*); +extern bool_t xdr_threshold4_write_size(XDR *, threshold4_write_size*); +extern bool_t xdr_threshold4_read_iosize(XDR *, threshold4_read_iosize*); +extern bool_t xdr_threshold4_write_iosize(XDR *, threshold4_write_iosize*); +extern bool_t xdr_threshold_item4(XDR *, threshold_item4*); +extern bool_t xdr_mdsthreshold4(XDR *, mdsthreshold4*); +extern bool_t xdr_retention_get4(XDR *, retention_get4*); +extern bool_t xdr_retention_set4(XDR *, retention_set4*); +extern bool_t xdr_fs_charset_cap4(XDR *, fs_charset_cap4*); +extern bool_t xdr_netloc_type4(XDR *, netloc_type4*); +extern bool_t xdr_netloc4(XDR *, netloc4*); +extern bool_t xdr_change_attr_type4(XDR *, change_attr_type4*); +/* extern bool_t xdr_labelformat_spec4(XDR *, labelformat_spec4*); */ +extern bool_t xdr_sec_label4(XDR *, sec_label4*); +extern bool_t xdr_app_data_block4(XDR *, app_data_block4*); +extern bool_t xdr_data4(XDR *, data4*); +extern bool_t xdr_data_info4(XDR *, data_info4*); +extern bool_t xdr_data_content4(XDR *, data_content4*); +extern bool_t xdr_stable_how4(XDR *, stable_how4*); +extern bool_t xdr_write_response4(XDR *, write_response4*); +extern bool_t xdr_fattr4_supported_attrs(XDR *, fattr4_supported_attrs*); +extern bool_t xdr_fattr4_type(XDR *, fattr4_type*); +extern bool_t xdr_fattr4_fh_expire_type(XDR *, fattr4_fh_expire_type*); +extern bool_t xdr_fattr4_change(XDR *, fattr4_change*); +extern bool_t xdr_fattr4_size(XDR *, fattr4_size*); +extern bool_t xdr_fattr4_link_support(XDR *, fattr4_link_support*); +extern bool_t xdr_fattr4_symlink_support(XDR *, fattr4_symlink_support*); +extern bool_t xdr_fattr4_named_attr(XDR *, fattr4_named_attr*); +extern bool_t xdr_fattr4_fsid(XDR *, fattr4_fsid*); +extern bool_t xdr_fattr4_unique_handles(XDR *, fattr4_unique_handles*); +extern bool_t xdr_fattr4_lease_time(XDR *, fattr4_lease_time*); +extern bool_t xdr_fattr4_rdattr_error(XDR *, fattr4_rdattr_error*); +extern bool_t xdr_fattr4_acl(XDR *, fattr4_acl*); +extern bool_t xdr_fattr4_aclsupport(XDR *, fattr4_aclsupport*); +extern bool_t xdr_fattr4_archive(XDR *, fattr4_archive*); +extern bool_t xdr_fattr4_cansettime(XDR *, fattr4_cansettime*); +extern bool_t xdr_fattr4_case_insensitive(XDR *, fattr4_case_insensitive*); +extern bool_t xdr_fattr4_case_preserving(XDR *, fattr4_case_preserving*); +extern bool_t xdr_fattr4_chown_restricted(XDR *, fattr4_chown_restricted*); +extern bool_t xdr_fattr4_fileid(XDR *, fattr4_fileid*); +extern bool_t xdr_fattr4_files_avail(XDR *, fattr4_files_avail*); +extern bool_t xdr_fattr4_filehandle(XDR *, fattr4_filehandle*); +extern bool_t xdr_fattr4_files_free(XDR *, fattr4_files_free*); +extern bool_t xdr_fattr4_files_total(XDR *, fattr4_files_total*); +extern bool_t xdr_fattr4_fs_locations(XDR *, fattr4_fs_locations*); +extern bool_t xdr_fattr4_hidden(XDR *, fattr4_hidden*); +extern bool_t xdr_fattr4_homogeneous(XDR *, fattr4_homogeneous*); +extern bool_t xdr_fattr4_maxfilesize(XDR *, fattr4_maxfilesize*); +extern bool_t xdr_fattr4_maxlink(XDR *, fattr4_maxlink*); +extern bool_t xdr_fattr4_maxname(XDR *, fattr4_maxname*); +extern bool_t xdr_fattr4_maxread(XDR *, fattr4_maxread*); +extern bool_t xdr_fattr4_maxwrite(XDR *, fattr4_maxwrite*); +extern bool_t xdr_fattr4_mimetype(XDR *, fattr4_mimetype*); +extern bool_t xdr_fattr4_mode(XDR *, fattr4_mode*); +extern bool_t xdr_fattr4_mode_set_masked(XDR *, fattr4_mode_set_masked*); +extern bool_t xdr_fattr4_mounted_on_fileid(XDR *, fattr4_mounted_on_fileid*); +extern bool_t xdr_fattr4_no_trunc(XDR *, fattr4_no_trunc*); +extern bool_t xdr_fattr4_numlinks(XDR *, fattr4_numlinks*); +extern bool_t xdr_fattr4_owner(XDR *, fattr4_owner*); +extern bool_t xdr_fattr4_owner_group(XDR *, fattr4_owner_group*); +extern bool_t xdr_fattr4_quota_avail_hard(XDR *, fattr4_quota_avail_hard*); +extern bool_t xdr_fattr4_quota_avail_soft(XDR *, fattr4_quota_avail_soft*); +extern bool_t xdr_fattr4_quota_used(XDR *, fattr4_quota_used*); +extern bool_t xdr_fattr4_rawdev(XDR *, fattr4_rawdev*); +extern bool_t xdr_fattr4_space_avail(XDR *, fattr4_space_avail*); +extern bool_t xdr_fattr4_space_free(XDR *, fattr4_space_free*); +extern bool_t xdr_fattr4_space_total(XDR *, fattr4_space_total*); +extern bool_t xdr_fattr4_space_used(XDR *, fattr4_space_used*); +extern bool_t xdr_fattr4_system(XDR *, fattr4_system*); +extern bool_t xdr_fattr4_time_access(XDR *, fattr4_time_access*); +extern bool_t xdr_fattr4_time_access_set(XDR *, fattr4_time_access_set*); +extern bool_t xdr_fattr4_time_backup(XDR *, fattr4_time_backup*); +extern bool_t xdr_fattr4_time_create(XDR *, fattr4_time_create*); +extern bool_t xdr_fattr4_time_delta(XDR *, fattr4_time_delta*); +extern bool_t xdr_fattr4_time_metadata(XDR *, fattr4_time_metadata*); +extern bool_t xdr_fattr4_time_modify(XDR *, fattr4_time_modify*); +extern bool_t xdr_fattr4_time_modify_set(XDR *, fattr4_time_modify_set*); +extern bool_t xdr_fattr4_suppattr_exclcreat(XDR *, fattr4_suppattr_exclcreat*); +extern bool_t xdr_fattr4_dir_notif_delay(XDR *, fattr4_dir_notif_delay*); +extern bool_t xdr_fattr4_dirent_notif_delay(XDR *, fattr4_dirent_notif_delay*); +extern bool_t xdr_fattr4_fs_layout_types(XDR *, fattr4_fs_layout_types*); +extern bool_t xdr_fattr4_fs_status(XDR *, fattr4_fs_status*); +extern bool_t xdr_fattr4_fs_charset_cap(XDR *, fattr4_fs_charset_cap*); +extern bool_t xdr_fattr4_layout_alignment(XDR *, fattr4_layout_alignment*); +extern bool_t xdr_fattr4_layout_blksize(XDR *, fattr4_layout_blksize*); +extern bool_t xdr_fattr4_layout_hint(XDR *, fattr4_layout_hint*); +extern bool_t xdr_fattr4_layout_types(XDR *, fattr4_layout_types*); +extern bool_t xdr_fattr4_mdsthreshold(XDR *, fattr4_mdsthreshold*); +extern bool_t xdr_fattr4_retention_get(XDR *, fattr4_retention_get*); +extern bool_t xdr_fattr4_retention_set(XDR *, fattr4_retention_set*); +extern bool_t xdr_fattr4_retentevt_get(XDR *, fattr4_retentevt_get*); +extern bool_t xdr_fattr4_retentevt_set(XDR *, fattr4_retentevt_set*); +extern bool_t xdr_fattr4_retention_hold(XDR *, fattr4_retention_hold*); +extern bool_t xdr_fattr4_dacl(XDR *, fattr4_dacl*); +extern bool_t xdr_fattr4_sacl(XDR *, fattr4_sacl*); +extern bool_t xdr_fattr4_change_policy(XDR *, fattr4_change_policy*); +extern bool_t xdr_fattr4_space_freed(XDR *, fattr4_space_freed*); +extern bool_t xdr_fattr4_change_attr_type(XDR *, fattr4_change_attr_type*); +extern bool_t xdr_fattr4_sec_label(XDR *, fattr4_sec_label*); +extern bool_t xdr_fattr4_clone_blksize(XDR *, fattr4_clone_blksize*); +extern bool_t xdr_fattr4(XDR *, fattr4*); +extern bool_t xdr_change_info4(XDR *, change_info4*); +extern bool_t xdr_clientaddr4(XDR *, clientaddr4*); +extern bool_t xdr_cb_client4(XDR *, cb_client4*); +extern bool_t xdr_nfs_client_id4(XDR *, nfs_client_id4*); +extern bool_t xdr_client_owner4(XDR *, client_owner4*); +extern bool_t xdr_server_owner4(XDR *, server_owner4*); +extern bool_t xdr_state_owner4(XDR *, state_owner4*); +extern bool_t xdr_open_owner4(XDR *, open_owner4*); +extern bool_t xdr_lock_owner4(XDR *, lock_owner4*); +extern bool_t xdr_nfs_lock_type4(XDR *, nfs_lock_type4*); +extern bool_t xdr_ssv_subkey4(XDR *, ssv_subkey4*); +extern bool_t xdr_ssv_mic_plain_tkn4(XDR *, ssv_mic_plain_tkn4*); +extern bool_t xdr_ssv_mic_tkn4(XDR *, ssv_mic_tkn4*); +extern bool_t xdr_ssv_seal_plain_tkn4(XDR *, ssv_seal_plain_tkn4*); +extern bool_t xdr_ssv_seal_cipher_tkn4(XDR *, ssv_seal_cipher_tkn4*); +extern bool_t xdr_fs_locations_server4(XDR *, fs_locations_server4*); +extern bool_t xdr_fs_locations_item4(XDR *, fs_locations_item4*); +extern bool_t xdr_fs_locations_info4(XDR *, fs_locations_info4*); +extern bool_t xdr_fattr4_fs_locations_info(XDR *, fattr4_fs_locations_info*); +extern bool_t xdr_nfl_util4(XDR *, nfl_util4*); +extern bool_t xdr_filelayout_hint_care4(XDR *, filelayout_hint_care4*); +extern bool_t xdr_nfsv4_1_file_layouthint4(XDR *, nfsv4_1_file_layouthint4*); +extern bool_t xdr_multipath_list4(XDR *, multipath_list4*); +extern bool_t xdr_nfsv4_1_file_layout_ds_addr4(XDR *, + nfsv4_1_file_layout_ds_addr4*); +extern bool_t xdr_nfsv4_1_file_layout4(XDR *, nfsv4_1_file_layout4*); +extern bool_t xdr_ACCESS4args(XDR *, ACCESS4args*); +extern bool_t xdr_CLONE4args(XDR *, CLONE4args*); +extern bool_t xdr_CLONE4res(XDR *, CLONE4res*); +extern bool_t xdr_COMMIT4args(XDR *, COMMIT4args*); +extern bool_t xdr_COMMIT4res(XDR *, COMMIT4res*); +extern bool_t xdr_DELEGPURGE4args(XDR *, DELEGPURGE4args*); +extern bool_t xdr_DELEGPURGE4res(XDR *, DELEGPURGE4res*); +extern bool_t xdr_DELEGRETURN4args(XDR *, DELEGRETURN4args*); +extern bool_t xdr_DELEGRETURN4res(XDR *, DELEGRETURN4res*); +extern bool_t xdr_GETATTR4args(XDR *, GETATTR4args*); +extern bool_t xdr_GETATTR4res(XDR *, GETATTR4res*); +extern bool_t xdr_GETFH4res(XDR *, GETFH4res*); +extern bool_t xdr_open_to_lock_owner4(XDR *, open_to_lock_owner4*); +extern bool_t xdr_exist_lock_owner4(XDR *, exist_lock_owner4*); +extern bool_t xdr_locker4(XDR *, locker4*); +extern bool_t xdr_LOCK4denied(XDR *, LOCK4denied*); +extern bool_t xdr_LOOKUP4args(XDR *, LOOKUP4args*); +extern bool_t xdr_LOOKUP4res(XDR *, LOOKUP4res*); +extern bool_t xdr_LOOKUPP4res(XDR *, LOOKUPP4res*); +extern bool_t xdr_NVERIFY4args(XDR *, NVERIFY4args*); +extern bool_t xdr_NVERIFY4res(XDR *, NVERIFY4res*); +extern bool_t xdr_createmode4(XDR *, createmode4*); +extern bool_t xdr_creatverfattr(XDR *, creatverfattr*); +extern bool_t xdr_createhow4(XDR *, createhow4*); +extern bool_t xdr_opentype4(XDR *, opentype4*); +extern bool_t xdr_openflag4(XDR *, openflag4*); +extern bool_t xdr_limit_by4(XDR *, limit_by4*); +extern bool_t xdr_nfs_modified_limit4(XDR *, nfs_modified_limit4*); +extern bool_t xdr_nfs_space_limit4(XDR *, nfs_space_limit4*); +extern bool_t xdr_open_delegation_type4(XDR *, open_delegation_type4*); +extern bool_t xdr_open_claim_type4(XDR *, open_claim_type4*); +extern bool_t xdr_open_claim_delegate_cur4(XDR *, open_claim_delegate_cur4*); +extern bool_t xdr_open_claim4(XDR *, open_claim4*); +extern bool_t xdr_open_read_delegation4(XDR *, open_read_delegation4*); +extern bool_t xdr_open_write_delegation4(XDR *, open_write_delegation4*); +extern bool_t xdr_why_no_delegation4(XDR *, why_no_delegation4*); +extern bool_t xdr_open_none_delegation4(XDR *, open_none_delegation4*); +extern bool_t xdr_open_delegation4(XDR *, open_delegation4*); +extern bool_t xdr_PUTFH4args(XDR *, PUTFH4args*); +extern bool_t xdr_PUTFH4res(XDR *, PUTFH4res*); +extern bool_t xdr_PUTPUBFH4res(XDR *, PUTPUBFH4res*); +extern bool_t xdr_PUTROOTFH4res(XDR *, PUTROOTFH4res*); +extern bool_t xdr_RENEW4args(XDR *, RENEW4args*); +extern bool_t xdr_RENEW4res(XDR *, RENEW4res*); +extern bool_t xdr_RESTOREFH4res(XDR *, RESTOREFH4res*); +extern bool_t xdr_SAVEFH4res(XDR *, SAVEFH4res*); +extern bool_t xdr_SECINFO4args(XDR *, SECINFO4args*); +extern bool_t xdr_rpc_gss_svc_t(XDR *, rpc_gss_svc_t *); +extern bool_t xdr_rpcsec_gss_info(XDR *, rpcsec_gss_info*); +extern bool_t xdr_SECINFO4res(XDR *, SECINFO4res*); +extern bool_t xdr_SETATTR4args(XDR *, SETATTR4args*); +extern bool_t xdr_SETATTR4res(XDR *, SETATTR4res*); +extern bool_t xdr_SETCLIENTID_CONFIRM4args(XDR *, SETCLIENTID_CONFIRM4args*); +extern bool_t xdr_SETCLIENTID_CONFIRM4res(XDR *, SETCLIENTID_CONFIRM4res*); +extern bool_t xdr_VERIFY4args(XDR *, VERIFY4args*); +extern bool_t xdr_VERIFY4res(XDR *, VERIFY4res*); +extern bool_t xdr_RELEASE_LOCKOWNER4args(XDR *, RELEASE_LOCKOWNER4args*); +extern bool_t xdr_RELEASE_LOCKOWNER4res(XDR *, RELEASE_LOCKOWNER4res*); +extern bool_t xdr_ILLEGAL4res(XDR *, ILLEGAL4res*); +extern bool_t xdr_gsshandle4_t(XDR *, gsshandle4_t *); +extern bool_t xdr_gss_cb_handles4(XDR *, gss_cb_handles4*); +extern bool_t xdr_callback_sec_parms4(XDR *, callback_sec_parms4*); +extern bool_t xdr_BACKCHANNEL_CTL4args(XDR *, BACKCHANNEL_CTL4args*); +extern bool_t xdr_BACKCHANNEL_CTL4res(XDR *, BACKCHANNEL_CTL4res*); +extern bool_t xdr_channel_dir_from_client4(XDR *, channel_dir_from_client4*); +extern bool_t xdr_BIND_CONN_TO_SESSION4args(XDR *, BIND_CONN_TO_SESSION4args*); +extern bool_t xdr_channel_dir_from_server4(XDR *, channel_dir_from_server4*); +extern bool_t xdr_BIND_CONN_TO_SESSION4resok(XDR *, + BIND_CONN_TO_SESSION4resok*); +extern bool_t xdr_BIND_CONN_TO_SESSION4res(XDR *, BIND_CONN_TO_SESSION4res*); +extern bool_t xdr_state_protect_ops4(XDR *, state_protect_ops4*); +extern bool_t xdr_ssv_sp_parms4(XDR *, ssv_sp_parms4*); +extern bool_t xdr_state_protect_how4(XDR *, state_protect_how4*); +extern bool_t xdr_state_protect4_a(XDR *, state_protect4_a*); +extern bool_t xdr_EXCHANGE_ID4args(XDR *, EXCHANGE_ID4args*); +extern bool_t xdr_ssv_prot_info4(XDR *, ssv_prot_info4*); +extern bool_t xdr_state_protect4_r(XDR *, state_protect4_r*); +extern bool_t xdr_EXCHANGE_ID4resok(XDR *, EXCHANGE_ID4resok*); +extern bool_t xdr_EXCHANGE_ID4res(XDR *, EXCHANGE_ID4res*); +extern bool_t xdr_channel_attrs4(XDR *, channel_attrs4*); +extern bool_t xdr_CREATE_SESSION4args(XDR *, CREATE_SESSION4args*); +extern bool_t xdr_CREATE_SESSION4resok(XDR *, CREATE_SESSION4resok*); +extern bool_t xdr_CREATE_SESSION4res(XDR *, CREATE_SESSION4res*); +extern bool_t xdr_DESTROY_SESSION4args(XDR *, DESTROY_SESSION4args*); +extern bool_t xdr_DESTROY_SESSION4res(XDR *, DESTROY_SESSION4res*); +extern bool_t xdr_FREE_STATEID4args(XDR *, FREE_STATEID4args*); +extern bool_t xdr_FREE_STATEID4res(XDR *, FREE_STATEID4res*); +extern bool_t xdr_attr_notice4(XDR *, attr_notice4*); +extern bool_t xdr_GET_DIR_DELEGATION4args(XDR *, GET_DIR_DELEGATION4args*); +extern bool_t xdr_GET_DIR_DELEGATION4resok(XDR *, GET_DIR_DELEGATION4resok*); +extern bool_t xdr_gddrnf4_status(XDR *, gddrnf4_status*); +extern bool_t xdr_GET_DIR_DELEGATION4res_non_fatal(XDR *, + GET_DIR_DELEGATION4res_non_fatal*); +extern bool_t xdr_GET_DIR_DELEGATION4res(XDR *, GET_DIR_DELEGATION4res*); +extern bool_t xdr_GETDEVICEINFO4args(XDR *, GETDEVICEINFO4args*); +extern bool_t xdr_GETDEVICEINFO4resok(XDR *, GETDEVICEINFO4resok*); +extern bool_t xdr_GETDEVICEINFO4res(XDR *, GETDEVICEINFO4res*); +extern bool_t xdr_GETDEVICELIST4args(XDR *, GETDEVICELIST4args*); +extern bool_t xdr_GETDEVICELIST4resok(XDR *, GETDEVICELIST4resok*); +extern bool_t xdr_GETDEVICELIST4res(XDR *, GETDEVICELIST4res*); +extern bool_t xdr_newtime4(XDR *, newtime4*); +extern bool_t xdr_newoffset4(XDR *, newoffset4*); +extern bool_t xdr_LAYOUTCOMMIT4args(XDR *, LAYOUTCOMMIT4args*); +extern bool_t xdr_newsize4(XDR *, newsize4*); +extern bool_t xdr_LAYOUTCOMMIT4resok(XDR *, LAYOUTCOMMIT4resok*); +extern bool_t xdr_LAYOUTCOMMIT4res(XDR *, LAYOUTCOMMIT4res*); +extern bool_t xdr_LAYOUTGET4args(XDR *, LAYOUTGET4args*); +extern bool_t xdr_LAYOUTGET4resok(XDR *, LAYOUTGET4resok*); +extern bool_t xdr_LAYOUTGET4res(XDR *, LAYOUTGET4res*); +extern bool_t xdr_LAYOUTRETURN4args(XDR *, LAYOUTRETURN4args*); +extern bool_t xdr_layoutreturn_stateid(XDR *, layoutreturn_stateid*); +extern bool_t xdr_LAYOUTRETURN4res(XDR *, LAYOUTRETURN4res*); +extern bool_t xdr_secinfo_style4(XDR *, secinfo_style4*); +extern bool_t xdr_SECINFO_NO_NAME4args(XDR *, SECINFO_NO_NAME4args*); +extern bool_t xdr_SECINFO_NO_NAME4res(XDR *, SECINFO_NO_NAME4res*); +extern bool_t xdr_SEQUENCE4args(XDR *, SEQUENCE4args*); +extern bool_t xdr_SEQUENCE4resok(XDR *, SEQUENCE4resok*); +extern bool_t xdr_SEQUENCE4res(XDR *, SEQUENCE4res*); +extern bool_t xdr_ssa_digest_input4(XDR *, ssa_digest_input4*); +extern bool_t xdr_SET_SSV4args(XDR *, SET_SSV4args*); +extern bool_t xdr_ssr_digest_input4(XDR *, ssr_digest_input4*); +extern bool_t xdr_SET_SSV4resok(XDR *, SET_SSV4resok*); +extern bool_t xdr_SET_SSV4res(XDR *, SET_SSV4res*); +extern bool_t xdr_TEST_STATEID4args(XDR *, TEST_STATEID4args*); +extern bool_t xdr_TEST_STATEID4resok(XDR *, TEST_STATEID4resok*); +extern bool_t xdr_TEST_STATEID4res(XDR *, TEST_STATEID4res*); +extern bool_t xdr_deleg_claim4(XDR *, deleg_claim4*); +extern bool_t xdr_WANT_DELEGATION4args(XDR *, WANT_DELEGATION4args*); +extern bool_t xdr_WANT_DELEGATION4res(XDR *, WANT_DELEGATION4res*); +extern bool_t xdr_DESTROY_CLIENTID4args(XDR *, DESTROY_CLIENTID4args*); +extern bool_t xdr_DESTROY_CLIENTID4res(XDR *, DESTROY_CLIENTID4res*); +extern bool_t xdr_RECLAIM_COMPLETE4args(XDR *, RECLAIM_COMPLETE4args*); +extern bool_t xdr_RECLAIM_COMPLETE4res(XDR *, RECLAIM_COMPLETE4res*); +extern bool_t xdr_nfs_opnum4(XDR *, nfs_opnum4*); + +extern bool_t xdr_COPY4args(XDR *, COPY4args*); +extern bool_t xdr_copy_requirements4(XDR *, copy_requirements4*); +extern bool_t xdr_COPY4resok(XDR *, COPY4resok*); +extern bool_t xdr_COPY4res(XDR *, COPY4res*); +extern bool_t xdr_COPY_NOTIFY4args(XDR *, COPY_NOTIFY4args*); +extern bool_t xdr_COPY_NOTIFY4resok(XDR *, COPY_NOTIFY4resok*); +extern bool_t xdr_COPY_NOTIFY4res(XDR *, COPY_NOTIFY4res*); +extern bool_t xdr_OFFLOAD_CANCEL4args(XDR *, OFFLOAD_CANCEL4args*); +extern bool_t xdr_OFFLOAD_CANCEL4res(XDR *, OFFLOAD_CANCEL4res*); +extern bool_t xdr_OFFLOAD_STATUS4args(XDR *, OFFLOAD_STATUS4args*); +extern bool_t xdr_OFFLOAD_STATUS4resok(XDR *, OFFLOAD_STATUS4resok*); +extern bool_t xdr_OFFLOAD_STATUS4res(XDR *, OFFLOAD_STATUS4res*); +extern bool_t xdr_ALLOCATE4args(XDR *, ALLOCATE4args*); +extern bool_t xdr_ALLOCATE4res(XDR *, ALLOCATE4res*); +extern bool_t xdr_DEALLOCATE4args(XDR *, DEALLOCATE4args*); +extern bool_t xdr_DEALLOCATE4res(XDR *, DEALLOCATE4res*); +extern bool_t xdr_IO_ADVISE_type4(XDR *, IO_ADVISE_type4*); +extern bool_t xdr_IO_ADVISE4args(XDR *, IO_ADVISE4args*); +extern bool_t xdr_IO_ADVISE4resok(XDR *, IO_ADVISE4resok*); +extern bool_t xdr_IO_ADVISE4res(XDR *, IO_ADVISE4res*); +extern bool_t xdr_device_error4(XDR *, device_error4*); +extern bool_t xdr_LAYOUTERROR4args(XDR *, LAYOUTERROR4args*); +extern bool_t xdr_LAYOUTERROR4res(XDR *, LAYOUTERROR4res*); +extern bool_t xdr_io_info4(XDR *, io_info4*); +extern bool_t xdr_LAYOUTSTATS4args(XDR *, LAYOUTSTATS4args*); +extern bool_t xdr_LAYOUTSTATS4res(XDR *, LAYOUTSTATS4res*); +extern bool_t xdr_READ_PLUS4args(XDR *, READ_PLUS4args*); +extern bool_t xdr_read_plus_content(XDR *, read_plus_content*); +extern bool_t xdr_read_plus_res4(XDR *, read_plus_res4*); +extern bool_t xdr_READ_PLUS4res(XDR *, READ_PLUS4res*); +extern bool_t xdr_SEEK4args(XDR *, SEEK4args*); +extern bool_t xdr_seek_res4(XDR *, seek_res4*); +extern bool_t xdr_SEEK4res(XDR *, SEEK4res*); +extern bool_t xdr_WRITE_SAME4args(XDR *, WRITE_SAME4args*); +extern bool_t xdr_WRITE_SAME4res(XDR *, WRITE_SAME4res*); + +extern bool_t xdr_COMPOUND4args(XDR *, COMPOUND4args*); +extern bool_t xdr_COMPOUND4res(XDR *, COMPOUND4res*); +extern bool_t xdr_CB_GETATTR4args(XDR *, CB_GETATTR4args*); +extern bool_t xdr_CB_GETATTR4res(XDR *, CB_GETATTR4res*); +extern bool_t xdr_CB_RECALL4args(XDR *, CB_RECALL4args*); +extern bool_t xdr_CB_RECALL4res(XDR *, CB_RECALL4res*); +extern bool_t xdr_CB_ILLEGAL4res(XDR *, CB_ILLEGAL4res*); +extern bool_t xdr_layoutrecall_type4(XDR *, layoutrecall_type4*); +extern bool_t xdr_layoutrecall_file4(XDR *, layoutrecall_file4*); +extern bool_t xdr_layoutrecall4(XDR *, layoutrecall4*); +extern bool_t xdr_CB_LAYOUTRECALL4args(XDR *, CB_LAYOUTRECALL4args*); +extern bool_t xdr_CB_LAYOUTRECALL4res(XDR *, CB_LAYOUTRECALL4res*); +extern bool_t xdr_notify_type4(XDR *, notify_type4*); +extern bool_t xdr_notify_entry4(XDR *, notify_entry4*); +extern bool_t xdr_prev_entry4(XDR *, prev_entry4*); +extern bool_t xdr_notify_remove4(XDR *, notify_remove4*); +extern bool_t xdr_notify_add4(XDR *, notify_add4*); +extern bool_t xdr_notify_attr4(XDR *, notify_attr4*); +extern bool_t xdr_notify_rename4(XDR *, notify_rename4*); +extern bool_t xdr_notify_verifier4(XDR *, notify_verifier4*); +extern bool_t xdr_notifylist4(XDR *, notifylist4*); +extern bool_t xdr_notify4(XDR *, notify4*); +extern bool_t xdr_CB_NOTIFY4args(XDR *, CB_NOTIFY4args*); +extern bool_t xdr_CB_NOTIFY4res(XDR *, CB_NOTIFY4res*); +extern bool_t xdr_CB_PUSH_DELEG4args(XDR *, CB_PUSH_DELEG4args*); +extern bool_t xdr_CB_PUSH_DELEG4res(XDR *, CB_PUSH_DELEG4res*); +extern bool_t xdr_CB_RECALL_ANY4args(XDR *, CB_RECALL_ANY4args*); +extern bool_t xdr_CB_RECALL_ANY4res(XDR *, CB_RECALL_ANY4res*); +extern bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4args(XDR *, + CB_RECALLABLE_OBJ_AVAIL4args*); +extern bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4res(XDR *, + CB_RECALLABLE_OBJ_AVAIL4res*); +extern bool_t xdr_CB_RECALL_SLOT4args(XDR *, CB_RECALL_SLOT4args*); +extern bool_t xdr_CB_RECALL_SLOT4res(XDR *, CB_RECALL_SLOT4res*); +extern bool_t xdr_referring_call4(XDR *, referring_call4*); +extern bool_t xdr_referring_call_list4(XDR *, referring_call_list4*); +extern bool_t xdr_CB_SEQUENCE4args(XDR *, CB_SEQUENCE4args*); +extern bool_t xdr_CB_SEQUENCE4resok(XDR *, CB_SEQUENCE4resok*); +extern bool_t xdr_CB_SEQUENCE4res(XDR *, CB_SEQUENCE4res*); +extern bool_t xdr_CB_WANTS_CANCELLED4args(XDR *, CB_WANTS_CANCELLED4args*); +extern bool_t xdr_CB_WANTS_CANCELLED4res(XDR *, CB_WANTS_CANCELLED4res*); +extern bool_t xdr_CB_NOTIFY_LOCK4args(XDR *, CB_NOTIFY_LOCK4args*); +extern bool_t xdr_CB_NOTIFY_LOCK4res(XDR *, CB_NOTIFY_LOCK4res*); +extern bool_t xdr_notify_deviceid_type4(XDR *, notify_deviceid_type4*); +extern bool_t xdr_notify_deviceid_delete4(XDR *, notify_deviceid_delete4*); +extern bool_t xdr_notify_deviceid_change4(XDR *, notify_deviceid_change4*); +extern bool_t xdr_CB_NOTIFY_DEVICEID4args(XDR *, CB_NOTIFY_DEVICEID4args*); +extern bool_t xdr_CB_NOTIFY_DEVICEID4res(XDR *, CB_NOTIFY_DEVICEID4res*); +extern bool_t xdr_nfs_cb_opnum4(XDR *, nfs_cb_opnum4*); +extern bool_t xdr_nfs_cb_argop4(XDR *, nfs_cb_argop4*); +extern bool_t xdr_nfs_cb_resop4(XDR *, nfs_cb_resop4*); +extern bool_t xdr_CB_COMPOUND4args(XDR *, CB_COMPOUND4args*); +extern bool_t xdr_CB_COMPOUND4res(XDR *, CB_COMPOUND4res*); + +/* NFSv4.x xdr */ +extern bool_t xdr_nfs4x_argop4(XDR *xdrs, nfs_argop4 *objp); +extern bool_t xdr_nfs4x_resop4(XDR *xdrs, nfs_resop4 *objp); + +/* + * xdr for referrrals upcall + */ +extern bool_t xdr_knetconfig(XDR *, struct knetconfig *); +extern bool_t xdr_nfs_fsl_info(XDR *, struct nfs_fsl_info *); + + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS4_KPROT_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs4x.h b/illumos-x86_64/usr/include/nfs/nfs4x.h new file mode 100644 index 00000000..91a91a12 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs4x.h @@ -0,0 +1,210 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 RackTop Systems. + */ + +#ifndef _NFS4X_H +#define _NFS4X_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include +#include + +/* + * 24 bytes of rpc header + * 12 bytes for compound header + * 44 bytes for SEQUENCE response + */ +#define NFS4_MIN_HDR_SEQSZ (24 + 12 + 44) + +/* + * NFSv4.1: slot support (reply cache) + */ + +#define RFS4_SLOT_INUSE (1 << 0) +#define RFS4_SLOT_CACHED (1 << 1) + +/* Slot entry structure */ +typedef struct rfs4_slot { + uint32_t se_flags; + sequenceid4 se_seqid; + COMPOUND4res se_buf; /* Buf for slot and replays */ + kmutex_t se_lock; +} rfs4_slot_t; + +/* + * NFSv4.1 Sessions + */ + +typedef struct rfs41_csr { /* contrived create_session result */ + sequenceid4 xi_sid; /* seqid response to EXCHG_ID */ + nfsstat4 cs_status; + CREATE_SESSION4resok cs_res; /* cached results if NFS4_OK */ +} rfs41_csr_t; + +/* + * Sessions Callback Infrastructure + * + * Locking: + * + * . cn_lock protects all fields in sess_channel_t, but since + * fore/back and dir don't change often, we serialize only + * the occasional update. + * + * cn_lock: cn_lock + * bsd_rwlock: cn_lock -> bsd_rwlock + */ + +#define MAX_CH_CACHE 10 +typedef struct { /* Back Chan Specific Data */ + rfs4_slot_t *bsd_slots; /* opaque token for slot tab */ + nfsstat4 bsd_stat; + krwlock_t bsd_rwlock; /* protect slot tab info */ + uint64_t bsd_idx; /* Index of next spare CLNT */ + uint64_t bsd_cur; /* Most recent added CLNT */ + int bsd_ch_free; + CLIENT *bsd_clnt[MAX_CH_CACHE]; +} sess_bcsd_t; + +typedef struct { + channel_dir_from_server4 cn_dir; /* Chan Direction */ + channel_attrs4 cn_attrs; /* chan Attrs */ + channel_attrs4 cn_back_attrs; /* back channel Attrs */ + sess_bcsd_t *cn_csd; /* Chan Specific Data */ + krwlock_t cn_lock; +} sess_channel_t; + +/* + * Maximum number of concurrent COMPOUND requests per session + */ +#define MAXSLOTS 256 +#define MAXSLOTS_BACK 4 + +typedef struct { + state_protect_how4 sp_type; +} rfs41_sprot_t; + +/* + * NFSv4.1 Sessions (cont'd) + * + * rfs4_session_t rfs4_client_t + * +-------------+ +--------------------+ + * | sn_sessid | | clientid | + * | sn_clnt * -|---------->| : | + * | sn_fore | +--------------------+ + * | sn_back | + * | sn_slots * -|---------> +--------------------------------+ + * +-------------+ | (slot_ent_t) | + * | +----------------------------+| + * | | status, slot, seqid, resp *||------> + * | +----------------------------+| + * | | status, slot, seqid, resp *|| + * | +----------------------------+| + * | | status, slot, seqid, resp *|| + * | +----------------------------+| + * | . | + * | : | + * +--------------------------------+ + * stok_t + */ +struct rfs4_client; +struct rfs4_dbe; + +typedef struct { + nfsstat4 cs_error; + struct rfs4_client *cs_client; + struct svc_req *cs_req; + uint32_t cs_id; + CREATE_SESSION4args cs_aotw; +} session41_create_t; + +/* + * sn_seq4 - sequence result bit accounting info (session scope) + * CB_PATH_DOWN_SESSION, CB_GSS_CONTEXT_EXPIRING, + * CB_GSS_CONTEXT_EXPIRED, BACKCHANNEL_FAULT + */ +typedef struct rfs4_session { + struct rfs4_dbe *sn_dbe; + sessionid4 sn_sessid; /* session id */ + struct rfs4_client *sn_clnt; /* back ptr to client state */ + sess_channel_t *sn_fore; /* fore chan for this session */ + sess_channel_t *sn_back; /* back chan for this session */ + rfs4_slot_t *sn_slots; /* slot replay cache */ + time_t sn_laccess; /* struct was last accessed */ + int sn_csflags; /* create_session only flags */ + uint32_t sn_flags; /* SEQ4 status bits */ + list_node_t sn_node; /* link node to rfs4_client */ + struct { + uint32_t pngcnt; /* conn pings outstanding */ + uint32_t progno; /* cb_program number */ + uint32_t failed:1; /* TRUE if no cb path avail */ + uint32_t pnginprog:1; + } sn_bc; + uint32_t sn_rcached; /* cached replies, for stat */ +} rfs4_session_t; + +#define SN_CB_CHAN_EST(x) ((x)->sn_back != NULL) +#define SN_CB_CHAN_OK(x) ((x)->sn_bc.failed == 0) + +/* error code for internal use */ +#define nfserr_replay_cache NFS4ERR_REPLAY_CACHE + +/* Session end */ + +/* + * Set of RPC credentials used for a particular operation. + * Used for operations like SETCLIENTID_CONFIRM where the + * credentials needs to match those used at SETCLIENTID. + * For EXCHANGE_ID (NFSv4.1+) + */ + +typedef struct { + cred_t *cp_cr; + int cp_aflavor; + int cp_secmod; + caddr_t cp_princ; +} cred_set_t; + +/* NFSv4.1 Functions */ +extern int rfs4x_dispatch(struct svc_req *, SVCXPRT *, char *); + +void rfs4_free_cred_set(cred_set_t *); +void rfs4x_session_rele(rfs4_session_t *); +rfs4_session_t *rfs4x_createsession(session41_create_t *); +nfsstat4 rfs4x_destroysession(rfs4_session_t *, unsigned useref); +void rfs4x_client_session_remove(struct rfs4_client *); +rfs4_session_t *rfs4x_findsession_by_id(sessionid4); +void rfs4x_session_hold(rfs4_session_t *); +void rfs4x_session_rele(rfs4_session_t *); + +/* Some init/fini helpers */ +struct rfs4_srv; +struct compound_state; +void rfs4x_state_init_locked(struct nfs4_srv *); +void rfs4x_state_fini(struct nfs4_srv *); +int rfs4x_sequence_prep(COMPOUND4args *, COMPOUND4res *, + struct compound_state *, SVCXPRT *); +void rfs4x_sequence_done(COMPOUND4res *, struct compound_state *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS4X_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs_acl.h b/illumos-x86_64/usr/include/nfs/nfs_acl.h new file mode 100644 index 00000000..f3ab4764 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs_acl.h @@ -0,0 +1,398 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. + * All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _NFS_NFS_ACL_H +#define _NFS_NFS_ACL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define NFS_ACL_MAX_ENTRIES 1024 + +typedef ushort_t o_mode; + +struct aclent { + int type; + uid32_t id; + o_mode perm; +}; +typedef struct aclent aclent; + +#define NA_USER_OBJ 0x1 +#define NA_USER 0x2 +#define NA_GROUP_OBJ 0x4 +#define NA_GROUP 0x8 +#define NA_CLASS_OBJ 0x10 +#define NA_OTHER_OBJ 0x20 +#define NA_ACL_DEFAULT 0x1000 + +#define NA_READ 0x4 +#define NA_WRITE 0x2 +#define NA_EXEC 0x1 + +struct secattr { + uint32 mask; + int aclcnt; + struct { + uint_t aclent_len; + aclent *aclent_val; + } aclent; + int dfaclcnt; + struct { + uint_t dfaclent_len; + aclent *dfaclent_val; + } dfaclent; +}; +typedef struct secattr secattr; + +#define NA_ACL 0x1 +#define NA_ACLCNT 0x2 +#define NA_DFACL 0x4 +#define NA_DFACLCNT 0x8 + +struct GETACL2args { + fhandle_t fh; + uint32 mask; +}; +typedef struct GETACL2args GETACL2args; + +struct GETACL2resok { + struct nfsfattr attr; + vsecattr_t acl; +}; +typedef struct GETACL2resok GETACL2resok; + +struct GETACL2res { + enum nfsstat status; + union { + GETACL2resok ok; + } res_u; +}; +typedef struct GETACL2res GETACL2res; + +struct SETACL2args { + fhandle_t fh; + vsecattr_t acl; +}; +typedef struct SETACL2args SETACL2args; + +struct SETACL2resok { + struct nfsfattr attr; +}; +typedef struct SETACL2resok SETACL2resok; + +struct SETACL2res { + enum nfsstat status; + union { + SETACL2resok ok; + } res_u; +}; +typedef struct SETACL2res SETACL2res; + +struct GETATTR2args { + fhandle_t fh; +}; +typedef struct GETATTR2args GETATTR2args; + +struct GETATTR2resok { + struct nfsfattr attr; +}; +typedef struct GETATTR2resok GETATTR2resok; + +struct GETATTR2res { + enum nfsstat status; + union { + GETATTR2resok ok; + } res_u; +}; +typedef struct GETATTR2res GETATTR2res; + +struct ACCESS2args { + fhandle_t fh; + uint32 access; +}; +typedef struct ACCESS2args ACCESS2args; + +#define ACCESS2_READ 0x1 +#define ACCESS2_LOOKUP 0x2 +#define ACCESS2_MODIFY 0x4 +#define ACCESS2_EXTEND 0x8 +#define ACCESS2_DELETE 0x10 +#define ACCESS2_EXECUTE 0x20 + +struct ACCESS2resok { + struct nfsfattr attr; + uint32 access; +}; +typedef struct ACCESS2resok ACCESS2resok; + +struct ACCESS2res { + enum nfsstat status; + union { + ACCESS2resok ok; + } res_u; +}; +typedef struct ACCESS2res ACCESS2res; + +struct GETXATTRDIR2args { + fhandle_t fh; + bool_t create; +}; +typedef struct GETXATTRDIR2args GETXATTRDIR2args; + +struct GETXATTRDIR2resok { + fhandle_t fh; + struct nfsfattr attr; +}; +typedef struct GETXATTRDIR2resok GETXATTRDIR2resok; + +struct GETXATTRDIR2res { + enum nfsstat status; + union { + GETXATTRDIR2resok ok; + } res_u; +}; +typedef struct GETXATTRDIR2res GETXATTRDIR2res; + +struct GETACL3args { + nfs_fh3 fh; + uint32 mask; +}; +typedef struct GETACL3args GETACL3args; + +struct GETACL3resok { + post_op_attr attr; + vsecattr_t acl; +}; +typedef struct GETACL3resok GETACL3resok; + +struct GETACL3resfail { + post_op_attr attr; +}; +typedef struct GETACL3resfail GETACL3resfail; + +struct GETACL3res { + nfsstat3 status; + union { + GETACL3resok ok; + GETACL3resfail fail; + } res_u; +}; +typedef struct GETACL3res GETACL3res; + +struct SETACL3args { + nfs_fh3 fh; + vsecattr_t acl; +}; +typedef struct SETACL3args SETACL3args; + +struct SETACL3resok { + post_op_attr attr; +}; +typedef struct SETACL3resok SETACL3resok; + +struct SETACL3resfail { + post_op_attr attr; +}; +typedef struct SETACL3resfail SETACL3resfail; + +struct SETACL3res { + nfsstat3 status; + union { + SETACL3resok ok; + SETACL3resfail fail; + } res_u; +}; +typedef struct SETACL3res SETACL3res; + +struct GETXATTRDIR3args { + nfs_fh3 fh; + bool_t create; +}; +typedef struct GETXATTRDIR3args GETXATTRDIR3args; + +struct GETXATTRDIR3resok { + nfs_fh3 fh; + post_op_attr attr; +}; +typedef struct GETXATTRDIR3resok GETXATTRDIR3resok; + +struct GETXATTRDIR3res { + nfsstat3 status; + union { + GETXATTRDIR3resok ok; + } res_u; +}; +typedef struct GETXATTRDIR3res GETXATTRDIR3res; + +#define NFS_ACL_PROGRAM ((rpcprog_t)(100227)) +#define NFS_ACL_VERSMIN ((rpcvers_t)(2)) +#define NFS_ACL_VERSMAX ((rpcvers_t)(3)) + +#define NFS_ACL_V2 ((rpcvers_t)(2)) +#define ACLPROC2_NULL ((rpcproc_t)(0)) +#define ACLPROC2_GETACL ((rpcproc_t)(1)) +#define ACLPROC2_SETACL ((rpcproc_t)(2)) +#define ACLPROC2_GETATTR ((rpcproc_t)(3)) +#define ACLPROC2_ACCESS ((rpcproc_t)(4)) +#define ACLPROC2_GETXATTRDIR ((rpcproc_t)(5)) + +#define NFS_ACL_V3 ((rpcvers_t)(3)) +#define ACLPROC3_NULL ((rpcproc_t)(0)) +#define ACLPROC3_GETACL ((rpcproc_t)(1)) +#define ACLPROC3_SETACL ((rpcproc_t)(2)) +#define ACLPROC3_GETXATTRDIR ((rpcproc_t)(3)) + +#ifdef _KERNEL +/* the xdr functions */ +extern bool_t xdr_uid(XDR *, uid32_t *); +extern bool_t xdr_o_mode(XDR *, o_mode *); +extern bool_t xdr_aclent(XDR *, aclent_t *); +extern bool_t xdr_secattr(XDR *, vsecattr_t *); + +extern bool_t xdr_GETACL2args(XDR *, GETACL2args *); +extern bool_t xdr_fastGETACL2args(XDR *, GETACL2args **); +extern bool_t xdr_GETACL2resok(XDR *, GETACL2resok *); +extern bool_t xdr_GETACL2res(XDR *, GETACL2res *); +extern bool_t xdr_SETACL2args(XDR *, SETACL2args *); +extern bool_t xdr_SETACL2resok(XDR *, SETACL2resok *); +#ifdef _LITTLE_ENDIAN +extern bool_t xdr_fastSETACL2resok(XDR *, SETACL2resok *); +#endif +extern bool_t xdr_SETACL2res(XDR *, SETACL2res *); +#ifdef _LITTLE_ENDIAN +extern bool_t xdr_fastSETACL2res(XDR *, SETACL2res *); +#endif +extern bool_t xdr_GETATTR2args(XDR *, GETATTR2args *); +extern bool_t xdr_fastGETATTR2args(XDR *, GETATTR2args **); +extern bool_t xdr_GETATTR2resok(XDR *, GETATTR2resok *); +#ifdef _LITTLE_ENDIAN +extern bool_t xdr_fastGETATTR2resok(XDR *, GETATTR2resok *); +#endif +extern bool_t xdr_GETATTR2res(XDR *, GETATTR2res *); +#ifdef _LITTLE_ENDIAN +extern bool_t xdr_fastGETATTR2res(XDR *, GETATTR2res *); +#endif +extern bool_t xdr_ACCESS2args(XDR *, ACCESS2args *); +extern bool_t xdr_fastACCESS2args(XDR *, ACCESS2args **); +extern bool_t xdr_ACCESS2resok(XDR *, ACCESS2resok *); +#ifdef _LITTLE_ENDIAN +extern bool_t xdr_fastACCESS2resok(XDR *, ACCESS2resok *); +#endif +extern bool_t xdr_ACCESS2res(XDR *, ACCESS2res *); +#ifdef _LITTLE_ENDIAN +extern bool_t xdr_fastACCESS2res(XDR *, ACCESS2res *); +#endif +extern bool_t xdr_GETXATTRDIR2args(XDR *, GETXATTRDIR2args *); +extern bool_t xdr_GETXATTRDIR2res(XDR *, GETXATTRDIR2res *); + +extern bool_t xdr_GETACL3args(XDR *, GETACL3args *); +extern bool_t xdr_GETACL3resok(XDR *, GETACL3resok *); +extern bool_t xdr_GETACL3resfail(XDR *, GETACL3resfail *); +extern bool_t xdr_GETACL3res(XDR *, GETACL3res *); +extern bool_t xdr_SETACL3args(XDR *, SETACL3args *); +extern bool_t xdr_SETACL3resok(XDR *, SETACL3resok *); +extern bool_t xdr_SETACL3resfail(XDR *, SETACL3resfail *); +extern bool_t xdr_SETACL3res(XDR *, SETACL3res *); +extern bool_t xdr_GETXATTRDIR3args(XDR *, GETXATTRDIR3args *); +extern bool_t xdr_GETXATTRDIR3res(XDR *, GETXATTRDIR3res *); + +#endif + +#ifdef _KERNEL +/* the service procedures */ +extern void acl2_getacl(GETACL2args *, GETACL2res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *acl2_getacl_getfh(GETACL2args *); +extern void acl2_getacl_free(GETACL2res *); +extern void acl2_setacl(SETACL2args *, SETACL2res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *acl2_setacl_getfh(SETACL2args *); +extern void acl2_getattr(GETATTR2args *, GETATTR2res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *acl2_getattr_getfh(GETATTR2args *); +extern void acl2_access(ACCESS2args *, ACCESS2res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *acl2_access_getfh(ACCESS2args *); +extern void acl2_getxattrdir(GETXATTRDIR2args *, GETXATTRDIR2res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *acl2_getxattrdir_getfh(GETXATTRDIR2args *); + +extern void acl3_getacl(GETACL3args *, GETACL3res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *acl3_getacl_getfh(GETACL3args *); +extern void acl3_getacl_free(GETACL3res *); +extern void acl3_setacl(SETACL3args *, SETACL3res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *acl3_setacl_getfh(SETACL3args *); +extern void acl3_getxattrdir(GETXATTRDIR3args *, GETXATTRDIR3res *, + struct exportinfo *, struct svc_req *, cred_t *, bool_t); +extern void *acl3_getxattrdir_getfh(GETXATTRDIR3args *); + +#endif + +#ifdef _KERNEL +/* the client side procedures */ +extern int acl_getacl2(vnode_t *, vsecattr_t *, int, cred_t *); +extern int acl_setacl2(vnode_t *, vsecattr_t *, int, cred_t *); +extern int acl_getattr2_otw(vnode_t *, vattr_t *, cred_t *); +extern int acl_access2(vnode_t *, int, int, cred_t *); +extern int acl_getxattrdir2(vnode_t *, vnode_t **, bool_t, cred_t *, int); +extern int acl_getacl3(vnode_t *, vsecattr_t *, int, cred_t *); +extern int acl_setacl3(vnode_t *, vsecattr_t *, int, cred_t *); +extern int acl_getxattrdir3(vnode_t *, vnode_t **, bool_t, cred_t *, int); +extern int acl2call(mntinfo_t *, rpcproc_t, xdrproc_t, caddr_t, xdrproc_t, + caddr_t, cred_t *, int *, enum nfsstat *, int, + failinfo_t *); +extern int acl3call(mntinfo_t *, rpcproc_t, xdrproc_t, caddr_t, xdrproc_t, + caddr_t, cred_t *, int *, nfsstat3 *, int, + failinfo_t *); +extern void nfs_acl_free(vsecattr_t *); +#endif + +#ifdef _KERNEL +/* server and client data structures */ + +extern char *aclnames_v2[]; +extern uchar_t acl_call_type_v2[]; +extern uchar_t acl_ss_call_type_v2[]; +extern uchar_t acl_timer_type_v2[]; + +extern char *aclnames_v3[]; +extern uchar_t acl_call_type_v3[]; +extern uchar_t acl_ss_call_type_v3[]; +extern uchar_t acl_timer_type_v3[]; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_NFS_ACL_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs_clnt.h b/illumos-x86_64/usr/include/nfs/nfs_clnt.h new file mode 100644 index 00000000..391640c1 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs_clnt.h @@ -0,0 +1,672 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _NFS_NFS_CLNT_H +#define _NFS_NFS_CLNT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define HOSTNAMESZ 32 +#define ACREGMIN 3 /* min secs to hold cached file attr */ +#define ACREGMAX 60 /* max secs to hold cached file attr */ +#define ACDIRMIN 30 /* min secs to hold cached dir attr */ +#define ACDIRMAX 60 /* max secs to hold cached dir attr */ +#define ACMINMAX 3600 /* 1 hr is longest min timeout */ +#define ACMAXMAX 36000 /* 10 hr is longest max timeout */ + +#define NFS_CALLTYPES 3 /* Lookups, Reads, Writes */ + +/* + * rfscall() flags + */ +#define RFSCALL_SOFT 0x00000001 /* Do op as if fs was soft-mounted */ + +/* + * Fake errno passed back from rfscall to indicate transfer size adjustment + */ +#define ENFS_TRYAGAIN 999 + +/* + * The NFS specific async_reqs structure. iotype is grouped to support two + * types of async thread pools, please read comments section of mntinfo_t + * definition for more information. Care should be taken while adding new + * members to this group. + */ + +enum iotype { + NFS_PUTAPAGE, + NFS_PAGEIO, + NFS_COMMIT, + NFS_READ_AHEAD, + NFS_READDIR, + NFS_INACTIVE, + NFS_ASYNC_TYPES +}; +#define NFS_ASYNC_PGOPS_TYPES (NFS_COMMIT + 1) + +/* + * NFS async requests queue type. + */ + +enum ioqtype { + NFS_ASYNC_QUEUE, + NFS_ASYNC_PGOPS_QUEUE, + NFS_MAX_ASYNC_QUEUES +}; + +/* + * Number of NFS async threads operating exclusively on page op requests. + */ +#define NUM_ASYNC_PGOPS_THREADS 0x2 + +struct nfs_async_read_req { + void (*readahead)(); /* pointer to readahead function */ + u_offset_t blkoff; /* offset in file */ + struct seg *seg; /* segment to do i/o to */ + caddr_t addr; /* address to do i/o to */ +}; + +struct nfs_pageio_req { + int (*pageio)(); /* pointer to pageio function */ + page_t *pp; /* page list */ + u_offset_t io_off; /* offset in file */ + uint_t io_len; /* size of request */ + int flags; +}; + +struct nfs_readdir_req { + int (*readdir)(); /* pointer to readdir function */ + struct rddir_cache *rdc; /* pointer to cache entry to fill */ +}; + +struct nfs_commit_req { + void (*commit)(); /* pointer to commit function */ + page_t *plist; /* page list */ + offset3 offset; /* starting offset */ + count3 count; /* size of range to be commited */ +}; + +struct nfs_inactive_req { + void (*inactive)(); /* pointer to inactive function */ +}; + +struct nfs_async_reqs { + struct nfs_async_reqs *a_next; /* pointer to next arg struct */ +#ifdef DEBUG + kthread_t *a_queuer; /* thread id of queueing thread */ +#endif + struct vnode *a_vp; /* vnode pointer */ + struct cred *a_cred; /* cred pointer */ + enum iotype a_io; /* i/o type */ + union { + struct nfs_async_read_req a_read_args; + struct nfs_pageio_req a_pageio_args; + struct nfs_readdir_req a_readdir_args; + struct nfs_commit_req a_commit_args; + struct nfs_inactive_req a_inactive_args; + } a_args; +}; + +#define a_nfs_readahead a_args.a_read_args.readahead +#define a_nfs_blkoff a_args.a_read_args.blkoff +#define a_nfs_seg a_args.a_read_args.seg +#define a_nfs_addr a_args.a_read_args.addr + +#define a_nfs_putapage a_args.a_pageio_args.pageio +#define a_nfs_pageio a_args.a_pageio_args.pageio +#define a_nfs_pp a_args.a_pageio_args.pp +#define a_nfs_off a_args.a_pageio_args.io_off +#define a_nfs_len a_args.a_pageio_args.io_len +#define a_nfs_flags a_args.a_pageio_args.flags + +#define a_nfs_readdir a_args.a_readdir_args.readdir +#define a_nfs_rdc a_args.a_readdir_args.rdc + +#define a_nfs_commit a_args.a_commit_args.commit +#define a_nfs_plist a_args.a_commit_args.plist +#define a_nfs_offset a_args.a_commit_args.offset +#define a_nfs_count a_args.a_commit_args.count + +#define a_nfs_inactive a_args.a_inactive_args.inactive + +/* + * Due to the way the address space callbacks are used to execute a delmap, + * we must keep track of how many times the same thread has called + * VOP_DELMAP()->nfs_delmap()/nfs3_delmap(). This is done by having a list of + * nfs_delmapcall_t's associated with each rnode_t. This list is protected + * by the rnode_t's r_statelock. The individual elements do not need to be + * protected as they will only ever be created, modified and destroyed by + * one thread (the call_id). + * See nfs_delmap()/nfs3_delmap() for further explanation. + */ +typedef struct nfs_delmapcall { + kthread_t *call_id; + int error; /* error from delmap */ + list_node_t call_node; +} nfs_delmapcall_t; + +/* + * delmap address space callback args + */ +typedef struct nfs_delmap_args { + vnode_t *vp; + offset_t off; + caddr_t addr; + size_t len; + uint_t prot; + uint_t maxprot; + uint_t flags; + cred_t *cr; + nfs_delmapcall_t *caller; /* to retrieve errors from the cb */ +} nfs_delmap_args_t; + +#ifdef _KERNEL +extern nfs_delmapcall_t *nfs_init_delmapcall(void); +extern void nfs_free_delmapcall(nfs_delmapcall_t *); +extern int nfs_find_and_delete_delmapcall(rnode_t *, int *errp); +#endif /* _KERNEL */ + +/* + * The following structures, chhead and chtab, make up the client handle + * cache. chhead represents a quadruple(RPC program, RPC version, Protocol + * Family, and Transport). For example, a chhead entry could represent + * NFS/V3/IPv4/TCP requests. chhead nodes are linked together as a singly + * linked list and is referenced from chtable. + * + * chtab represents an allocated client handle bound to a particular + * quadruple. These nodes chain down from a chhead node. chtab + * entries which are on the chain are considered free, so a thread may simply + * unlink the first node without traversing the chain. When the thread is + * completed with its request, it puts the chtab node back on the chain. + */ +typedef struct chhead { + struct chhead *ch_next; /* next quadruple */ + struct chtab *ch_list; /* pointer to free client handle(s) */ + uint64_t ch_timesused; /* times this quadruple was requested */ + rpcprog_t ch_prog; /* RPC program number */ + rpcvers_t ch_vers; /* RPC version number */ + dev_t ch_dev; /* pseudo device number (i.e. /dev/udp) */ + char *ch_protofmly; /* protocol (i.e. NC_INET, NC_LOOPBACK) */ +} chhead_t; + +typedef struct chtab { + struct chtab *ch_list; /* next free client handle */ + struct chhead *ch_head; /* associated quadruple */ + time_t ch_freed; /* timestamp when freed */ + CLIENT *ch_client; /* pointer to client handle */ +} chtab_t; + +/* + * clinfo is a structure which encapsulates data that is needed to + * obtain a client handle from the cache + */ +typedef struct clinfo { + rpcprog_t cl_prog; /* RPC program number */ + rpcvers_t cl_vers; /* RPC version number */ + uint_t cl_readsize; /* transfer size */ + int cl_retrans; /* times to retry request */ + uint_t cl_flags; /* info flags */ +} clinfo_t; + +/* + * Failover information, passed opaquely through rfscall() + */ +typedef struct failinfo { + struct vnode *vp; + caddr_t fhp; + void (*copyproc)(caddr_t, vnode_t *); + int (*lookupproc)(vnode_t *, char *, vnode_t **, struct pathname *, + int, vnode_t *, struct cred *, int); + int (*xattrdirproc)(vnode_t *, vnode_t **, bool_t, cred_t *, int); +} failinfo_t; + +/* + * Static server information + * + * These fields are protected by sv_lock: + * sv_flags + */ +typedef struct servinfo { + struct knetconfig *sv_knconf; /* bound TLI fd */ + struct knetconfig *sv_origknconf; /* For RDMA save orig knconf */ + struct netbuf sv_addr; /* server's address */ + nfs_fhandle sv_fhandle; /* this server's filehandle */ + struct sec_data *sv_secdata; /* security data for rpcsec module */ + char *sv_hostname; /* server's hostname */ + int sv_hostnamelen; /* server's hostname length */ + uint_t sv_flags; /* see below */ + struct servinfo *sv_next; /* next in list */ + kmutex_t sv_lock; +} servinfo_t; + +/* + * The values for sv_flags. + */ +#define SV_ROOT_STALE 0x1 /* root vnode got ESTALE */ + +/* + * Switch from RDMA knconf to original mount knconf + */ + +#define ORIG_KNCONF(mi) (mi->mi_curr_serv->sv_origknconf ? \ + mi->mi_curr_serv->sv_origknconf : mi->mi_curr_serv->sv_knconf) + +#if defined(_KERNEL) +/* + * NFS private data per mounted file system + * The mi_lock mutex protects the following fields: + * mi_flags + * mi_printed + * mi_down + * mi_tsize + * mi_stsize + * mi_curread + * mi_curwrite + * mi_timers + * mi_curr_serv + * mi_readers + * mi_klmconfig + * + * The mi_async_lock mutex protects the following fields: + * mi_async_reqs + * mi_async_req_count + * mi_async_tail + * mi_async_curr[NFS_MAX_ASYNC_QUEUES] + * mi_async_clusters + * mi_async_init_clusters + * mi_threads[NFS_MAX_ASYNC_QUEUES] + * mi_manager_thread + * + * Normally the netconfig information for the mount comes from + * mi_curr_serv and mi_klmconfig is NULL. If NLM calls need to use a + * different transport, mi_klmconfig contains the necessary netconfig + * information. + * + * 'mi_zone' is initialized at structure creation time, and never + * changes; it may be read without a lock. + * + * mi_zone_node is linkage into the mi4_globals.mig_list, and is + * protected by mi4_globals.mig_list_lock. + * + * Locking order: + * mi_globals::mig_lock > mi_async_lock > mi_lock + */ +typedef struct mntinfo { + kmutex_t mi_lock; /* protects mntinfo fields */ + struct servinfo *mi_servers; /* server list */ + struct servinfo *mi_curr_serv; /* current server */ + kcondvar_t mi_failover_cv; /* failover synchronization */ + int mi_readers; /* failover - users of mi_curr_serv */ + struct vfs *mi_vfsp; /* back pointer to vfs */ + enum vtype mi_type; /* file type of the root vnode */ + uint_t mi_flags; /* see below */ + uint_t mi_tsize; /* max read transfer size (bytes) */ + uint_t mi_stsize; /* max write transfer size (bytes) */ + int mi_timeo; /* inital timeout in 10th sec */ + int mi_retrans; /* times to retry request */ + hrtime_t mi_acregmin; /* min time to hold cached file attr */ + hrtime_t mi_acregmax; /* max time to hold cached file attr */ + hrtime_t mi_acdirmin; /* min time to hold cached dir attr */ + hrtime_t mi_acdirmax; /* max time to hold cached dir attr */ + len_t mi_maxfilesize; /* for pathconf _PC_FILESIZEBITS */ + /* + * Extra fields for congestion control, one per NFS call type, + * plus one global one. + */ + struct rpc_timers mi_timers[NFS_CALLTYPES+1]; + int mi_curread; /* current read size */ + int mi_curwrite; /* current write size */ + /* + * Async I/O management + * We have 2 pools of threads working on async I/O: + * (i) Threads which work on all async queues. Default number of + * threads in this queue is 8. Threads in this pool work on async + * queue pointed by mi_async_curr[NFS_ASYNC_QUEUE]. Number of + * active threads in this pool is tracked by + * mi_threads[NFS_ASYNC_QUEUE]. + * (ii)Threads which work only on page op async queues. + * Page ops queue comprises of NFS_PUTAPAGE, NFS_PAGEIO & + * NFS_COMMIT. Default number of threads in this queue is 2 + * (NUM_ASYNC_PGOPS_THREADS). Threads in this pool work on async + * queue pointed by mi_async_curr[NFS_ASYNC_PGOPS_QUEUE]. Number + * of active threads in this pool is tracked by + * mi_threads[NFS_ASYNC_PGOPS_QUEUE]. + */ + struct nfs_async_reqs *mi_async_reqs[NFS_ASYNC_TYPES]; + struct nfs_async_reqs *mi_async_tail[NFS_ASYNC_TYPES]; + struct nfs_async_reqs **mi_async_curr[NFS_MAX_ASYNC_QUEUES]; + /* current async queue */ + uint_t mi_async_clusters[NFS_ASYNC_TYPES]; + uint_t mi_async_init_clusters; + uint_t mi_async_req_count; /* # outstanding work requests */ + kcondvar_t mi_async_reqs_cv; /* signaled when there's work */ + ushort_t mi_threads[NFS_MAX_ASYNC_QUEUES]; + /* number of active async threads */ + ushort_t mi_max_threads; /* max number of async worker threads */ + kthread_t *mi_manager_thread; /* async manager thread */ + kcondvar_t mi_async_cv; /* signaled when the last worker dies */ + kcondvar_t mi_async_work_cv[NFS_MAX_ASYNC_QUEUES]; + /* tell workers to work */ + kmutex_t mi_async_lock; /* lock to protect async list */ + /* + * Other stuff + */ + struct pathcnf *mi_pathconf; /* static pathconf kludge */ + rpcprog_t mi_prog; /* RPC program number */ + rpcvers_t mi_vers; /* RPC program version number */ + char **mi_rfsnames; /* mapping to proc names */ + kstat_named_t *mi_reqs; /* count of requests */ + uchar_t *mi_call_type; /* dynamic retrans call types */ + uchar_t *mi_ss_call_type; /* semisoft call type */ + uchar_t *mi_timer_type; /* dynamic retrans timer types */ + clock_t mi_printftime; /* last error printf time */ + /* + * ACL entries + */ + char **mi_aclnames; /* mapping to proc names */ + kstat_named_t *mi_aclreqs; /* count of acl requests */ + uchar_t *mi_acl_call_type; /* dynamic retrans call types */ + uchar_t *mi_acl_ss_call_type; /* semisoft call types */ + uchar_t *mi_acl_timer_type; /* dynamic retrans timer types */ + /* + * Client Side Failover stats + */ + uint_t mi_noresponse; /* server not responding count */ + uint_t mi_failover; /* failover to new server count */ + uint_t mi_remap; /* remap to new server count */ + /* + * Kstat statistics + */ + struct kstat *mi_io_kstats; + struct kstat *mi_ro_kstats; + struct knetconfig *mi_klmconfig; + /* + * Zones support. + */ + struct zone *mi_zone; /* Zone in which FS is mounted */ + zone_ref_t mi_zone_ref; /* Reference to aforementioned zone */ + list_node_t mi_zone_node; /* Linkage into per-zone mi list */ + /* + * Serializes threads in failover_remap. + * Need to acquire this lock first in failover_remap() function + * before acquiring any other rnode lock. + */ + kmutex_t mi_remap_lock; + /* + * List of rnode_t structures that belongs to this mntinfo + */ + kmutex_t mi_rnodes_lock; /* protects the mi_rnodes list */ + list_t mi_rnodes; /* the list */ +} mntinfo_t; +#endif /* _KERNEL */ + +/* + * vfs pointer to mount info + */ +#define VFTOMI(vfsp) ((mntinfo_t *)((vfsp)->vfs_data)) + +/* + * vnode pointer to mount info + */ +#define VTOMI(vp) ((mntinfo_t *)(((vp)->v_vfsp)->vfs_data)) + +/* + * The values for mi_flags. + */ +#define MI_HARD 0x1 /* hard or soft mount */ +#define MI_PRINTED 0x2 /* not responding message printed */ +#define MI_INT 0x4 /* interrupts allowed on hard mount */ +#define MI_DOWN 0x8 /* server is down */ +#define MI_NOAC 0x10 /* don't cache attributes */ +#define MI_NOCTO 0x20 /* no close-to-open consistency */ +#define MI_DYNAMIC 0x40 /* dynamic transfer size adjustment */ +#define MI_LLOCK 0x80 /* local locking only (no lockmgr) */ +#define MI_GRPID 0x100 /* System V group id inheritance */ +#define MI_RPCTIMESYNC 0x200 /* RPC time sync */ +#define MI_LINK 0x400 /* server supports link */ +#define MI_SYMLINK 0x800 /* server supports symlink */ +#define MI_READDIRONLY 0x1000 /* use readdir instead of readdirplus */ +#define MI_ACL 0x2000 /* server supports NFS_ACL */ +#define MI_BINDINPROG 0x4000 /* binding to server is changing */ +#define MI_LOOPBACK 0x8000 /* Set if this is a loopback mount */ +#define MI_SEMISOFT 0x10000 /* soft reads, hard modify */ +#define MI_NOPRINT 0x20000 /* don't print messages */ +#define MI_DIRECTIO 0x40000 /* do direct I/O */ +#define MI_EXTATTR 0x80000 /* server supports extended attrs */ +#define MI_ASYNC_MGR_STOP 0x100000 /* tell async mgr to die */ +#define MI_DEAD 0x200000 /* mount has been terminated */ + +/* + * Read-only mntinfo statistics + */ +struct mntinfo_kstat { + char mik_proto[KNC_STRSIZE]; + uint32_t mik_vers; + uint_t mik_flags; + uint_t mik_secmod; + uint32_t mik_curread; + uint32_t mik_curwrite; + int mik_timeo; + int mik_retrans; + uint_t mik_acregmin; + uint_t mik_acregmax; + uint_t mik_acdirmin; + uint_t mik_acdirmax; + struct { + uint32_t srtt; + uint32_t deviate; + uint32_t rtxcur; + } mik_timers[NFS_CALLTYPES+1]; + uint32_t mik_noresponse; + uint32_t mik_failover; + uint32_t mik_remap; + char mik_curserver[SYS_NMLN]; +}; + +/* + * Macro to wakeup sleeping async worker threads. + */ +#define NFS_WAKE_ASYNC_WORKER(work_cv) { \ + if (CV_HAS_WAITERS(&work_cv[NFS_ASYNC_QUEUE])) \ + cv_signal(&work_cv[NFS_ASYNC_QUEUE]); \ + else if (CV_HAS_WAITERS(&work_cv[NFS_ASYNC_PGOPS_QUEUE])) \ + cv_signal(&work_cv[NFS_ASYNC_PGOPS_QUEUE]); \ +} + +#define NFS_WAKEALL_ASYNC_WORKERS(work_cv) { \ + cv_broadcast(&work_cv[NFS_ASYNC_QUEUE]); \ + cv_broadcast(&work_cv[NFS_ASYNC_PGOPS_QUEUE]); \ +} + +/* + * Mark cached attributes as timed out + * + * The caller must not be holding the rnode r_statelock mutex. + */ +#define PURGE_ATTRCACHE(vp) { \ + rnode_t *rp = VTOR(vp); \ + mutex_enter(&rp->r_statelock); \ + PURGE_ATTRCACHE_LOCKED(rp); \ + mutex_exit(&rp->r_statelock); \ +} + +#define PURGE_ATTRCACHE_LOCKED(rp) { \ + ASSERT(MUTEX_HELD(&rp->r_statelock)); \ + rp->r_attrtime = gethrtime(); \ + rp->r_mtime = rp->r_attrtime; \ +} + +/* + * Is the attribute cache valid? + */ +#define ATTRCACHE_VALID(vp) (gethrtime() < VTOR(vp)->r_attrtime) + +/* + * Flags to indicate whether to purge the DNLC for non-directory vnodes + * in a call to nfs_purge_caches. + */ +#define NFS_NOPURGE_DNLC 0 +#define NFS_PURGE_DNLC 1 + +/* + * If returned error is ESTALE flush all caches. + */ +#define PURGE_STALE_FH(error, vp, cr) \ + if ((error) == ESTALE) { \ + struct rnode *rp = VTOR(vp); \ + if (vp->v_flag & VROOT) { \ + servinfo_t *svp = rp->r_server; \ + mutex_enter(&svp->sv_lock); \ + svp->sv_flags |= SV_ROOT_STALE; \ + mutex_exit(&svp->sv_lock); \ + } \ + mutex_enter(&rp->r_statelock); \ + rp->r_flags |= RSTALE; \ + if (!rp->r_error) \ + rp->r_error = (error); \ + mutex_exit(&rp->r_statelock); \ + if (vn_has_cached_data(vp)) \ + nfs_invalidate_pages((vp), (u_offset_t)0, (cr)); \ + nfs_purge_caches((vp), NFS_PURGE_DNLC, (cr)); \ + } + +/* + * Is cache valid? + * Swap is always valid, if no attributes (attrtime == 0) or + * if mtime matches cached mtime it is valid + * NOTE: mtime is now a timestruc_t. + * Caller should be holding the rnode r_statelock mutex. + */ +#define CACHE_VALID(rp, mtime, fsize) \ + ((RTOV(rp)->v_flag & VISSWAP) == VISSWAP || \ + (((mtime).tv_sec == (rp)->r_attr.va_mtime.tv_sec && \ + (mtime).tv_nsec == (rp)->r_attr.va_mtime.tv_nsec) && \ + ((fsize) == (rp)->r_attr.va_size))) + +/* + * Macro to detect forced unmount or a zone shutdown. + */ +#define FS_OR_ZONE_GONE(vfsp) \ + (((vfsp)->vfs_flag & VFS_UNMOUNTED) || \ + zone_status_get(curproc->p_zone) >= ZONE_IS_SHUTTING_DOWN) + +/* + * Convert NFS tunables to hrtime_t units, seconds to nanoseconds. + */ +#define SEC2HR(sec) ((sec) * (long long)NANOSEC) +#define HR2SEC(hr) ((hr) / (long long)NANOSEC) + +/* + * Structure to identify owner of a PC file share reservation. + */ +struct nfs_owner { + int magic; /* magic uniquifying number */ + char hname[16]; /* first 16 bytes of hostname */ + char lowner[8]; /* local owner from fcntl */ +}; + +/* + * Values for magic. + */ +#define NFS_OWNER_MAGIC 0x1D81E + +/* + * Support for extended attributes + */ +#define XATTR_DIR_NAME "/@/" /* used for DNLC entries */ +#define XATTR_RPATH "ExTaTtR" /* used for r_path for failover */ + +/* + * Short hand for checking to see whether the file system was mounted + * interruptible or not. + */ +#define INTR(vp) (VTOMI(vp)->mi_flags & MI_INT) + +/* + * Short hand for checking whether failover is enabled or not + */ +#define FAILOVER_MOUNT(mi) (mi->mi_servers->sv_next) + +/* + * How long will async threads wait for additional work. + */ +#define NFS_ASYNC_TIMEOUT (60 * 1 * hz) /* 1 minute */ + +#ifdef _KERNEL +extern int clget(clinfo_t *, servinfo_t *, cred_t *, CLIENT **, + struct chtab **); +extern void clfree(CLIENT *, struct chtab *); +extern void nfs_mi_zonelist_add(mntinfo_t *); +extern void nfs_free_mi(mntinfo_t *); +extern void nfs_mnt_kstat_init(struct vfs *); +#endif + +/* + * Per-zone data for managing client handles. Included here solely for the + * benefit of MDB. + */ +/* + * client side statistics + */ +struct clstat { + kstat_named_t calls; /* client requests */ + kstat_named_t badcalls; /* rpc failures */ + kstat_named_t clgets; /* client handle gets */ + kstat_named_t cltoomany; /* client handle cache misses */ +#ifdef DEBUG + kstat_named_t clalloc; /* number of client handles */ + kstat_named_t noresponse; /* server not responding cnt */ + kstat_named_t failover; /* server failover count */ + kstat_named_t remap; /* server remap count */ +#endif +}; + +struct nfs_clnt { + struct chhead *nfscl_chtable; + kmutex_t nfscl_chtable_lock; + zoneid_t nfscl_zoneid; + list_node_t nfscl_node; + struct clstat nfscl_stat; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_NFS_CLNT_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs_cmd.h b/illumos-x86_64/usr/include/nfs/nfs_cmd.h new file mode 100644 index 00000000..feb2e5a9 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs_cmd.h @@ -0,0 +1,105 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2018 Nexenta Systems, Inc. + */ + +#ifndef _NFS_CMD_H +#define _NFS_CMD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define KICONV_MAX_CODENAME_LEN 63 /* copied from sys/kiconv.h */ + +#define NFSCMD_VERS_1 1 +#define NFSCMD_VERSION NFSCMD_VERS_1 + +typedef enum { NFSCMD_CHARMAP_LOOKUP, NFSCMD_ERROR } nfscmd_t; +typedef enum { NFSCMD_ERR_SUCCESS, NFSCMD_ERR_BADCMD, NFSCMD_ERR_NOTFOUND, + NFSCMD_ERR_FAIL, NFSCMD_ERR_DROP, NFSCMD_ERR_NOMEM } nfscmd_err_t; +#define NFSCMD_ERR_RET 0x100000 + +typedef struct nfscmd_arg { + uint32_t version; + nfscmd_t cmd; + union { + struct { + char path[MAXPATHLEN]; + struct sockaddr addr; + } charmap; + } arg; +} nfscmd_arg_t; + +typedef struct nfscmd_res { + uint32_t version; + uint32_t cmd; + nfscmd_err_t error; + union { + struct { + char codeset[KICONV_MAX_CODENAME_LEN + 1]; + uint32_t apply; + } charmap; + } result; +} nfscmd_res_t; + +#ifdef _KERNEL + +#define NFSCMD_CONV_INBOUND 1 +#define NFSCMD_CONV_OUTBOUND 0 + +extern int nfscmd_send(nfscmd_arg_t *, nfscmd_res_t *); +extern struct charset_cache *nfscmd_findmap(struct exportinfo *, + struct sockaddr *); +extern char *nfscmd_convname(struct sockaddr *, struct exportinfo *, + char *, int, size_t); + +extern char *nfscmd_convdirent(struct sockaddr *, struct exportinfo *, char *, + size_t, enum nfsstat3 *); +extern size_t nfscmd_convdirplus(struct sockaddr *, struct exportinfo *, char *, + size_t, size_t, char **); +extern size_t nfscmd_countents(char *, size_t); +extern size_t nfscmd_dropped_entrysize(struct dirent64 *, size_t, size_t); + +extern void nfscmd_init(void); +extern void nfscmd_fini(void); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_CMD_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs_log.h b/illumos-x86_64/usr/include/nfs/nfs_log.h new file mode 100644 index 00000000..2bb90b37 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs_log.h @@ -0,0 +1,683 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2018 Nexenta Systems, Inc. + */ + +#ifndef _NFS_LOG_H +#define _NFS_LOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define LOG_MODE 0600 /* open log with these permissions */ +#define LOG_INPROG_STRING "_log_in_process" + +/* + * Definition of dummy program for logging special non-nfs reqs + */ +#define NFSLOG_PROGRAM ((rpcprog_t)42) +#define NFSLOG_VERSION ((rpcvers_t)1) + +#define NFSLOG_VERSMIN ((rpcvers_t)1) +#define NFSLOG_VERSMAX ((rpcvers_t)1) + +#define NFSLOG_NULL ((rpcproc_t)0) +#define NFSLOG_SHARE ((rpcproc_t)1) +#define NFSLOG_UNSHARE ((rpcproc_t)2) +#define NFSLOG_LOOKUP ((rpcproc_t)3) +#define NFSLOG_GETFH ((rpcproc_t)4) + +/* + * Version of the on disk log file + */ +#define NFSLOG_BUF_VERSION ((rpcvers_t)2) + +#define NFSLOG_BUF_VERSMIN ((rpcvers_t)1) +#define NFSLOG_BUF_VERSMAX ((rpcvers_t)2) +/* + * Contents of the on disk log file header + * + * Note: This is the structure for older version 1 buffers, and does not + * adequately support large buffer files, as the offset is 32 bit. Newer + * buffer files are written using version 2 buffer header (below) which + * has a 64 bit offset. However, because existing buffers continue to use + * the old header format, the daemon xdr code can read and write either format. + * This definition below is not explicitely used anywhere in the code, + * but is implicitely used by the daemon xdr code. For that reason, it + * is kept here for information purpose only. + */ +struct nfslog_buffer_header_1 { + uint32_t bh_length; /* Length of this header */ + uint32_t bh_version; /* Version of buffer contents */ + uint32_t bh_flags; /* Optional flags field */ + uint32_t bh_offset; /* offset within file to begin */ + timestruc32_t bh_timestamp; /* When the buffer was created */ +}; +typedef struct nfslog_buffer_header_1 nfslog_buffer_header_1; + +/* + * For the current version 2, which supports largefiles + */ +struct nfslog_buffer_header_2 { + uint32_t bh_length; /* Length of this header */ + rpcvers_t bh_version; /* Version of buffer contents */ + u_offset_t bh_offset; /* offset within file to begin */ + uint32_t bh_flags; /* Optional flags field */ + timestruc32_t bh_timestamp; /* When the buffer was created */ +}; +typedef struct nfslog_buffer_header_2 nfslog_buffer_header_2; + +typedef struct nfslog_buffer_header_2 nfslog_buffer_header; + +/* bh_flags values */ +#define NFSLOG_BH_OFFSET_OVERFLOW 1 /* version 1 bh_offset */ + +/* + * For each record written to the log file, this struct is used + * as the logical header; it will be XDR encoded to be written to the file. + * + * Note: if the buffer file becomes large enough, the rh_rec_id may + * wrap around. This situation is appropriately handled by the daemon however. + */ +struct nfslog_record_header { + uint32_t rh_reclen; /* Length of entire record */ + uint32_t rh_rec_id; /* unique id for this log */ + rpcprog_t rh_prognum; /* Program number */ + rpcproc_t rh_procnum; /* Procedure number */ + rpcvers_t rh_version; /* Version number */ + uint32_t rh_auth_flavor; /* Auth flavor of RPC request */ + timestruc32_t rh_timestamp; /* time stamp of the request */ + uid_t rh_uid; /* uid of requestor as per RPC */ + gid_t rh_gid; /* gid of requestor as per RPC */ +}; +typedef struct nfslog_record_header nfslog_record_header; + +/* + * For each record written to the log file, this is the logical + * structure of the record; it will be XDR encoded and written to + * the file. + */ +struct nfslog_request_record { + nfslog_record_header re_header; /* Header as defined above */ + char *re_principal_name; /* Principal name of caller */ + char *re_netid; /* Netid used for request */ + char *re_tag; /* Log buffer tag for file system */ + struct netbuf re_ipaddr; /* Requestors ip address */ + caddr_t re_rpc_arg; /* RPC arguments and response */ + caddr_t re_rpc_res; +}; +typedef struct nfslog_request_record nfslog_request_record; + +/* + * From this point forward, the definitions represent the arguments + * and results of each possible RPC that can be logged. These + * may have been trimmed in content from the real RPC arguments + * and results to save space. + */ +typedef fhandle_t fhandle; + +struct nfslog_sharefsargs { + int sh_flags; + uint32_t sh_anon; + char *sh_path; + fhandle sh_fh_buf; +}; +typedef struct nfslog_sharefsargs nfslog_sharefsargs; + +typedef nfsstat nfslog_sharefsres; + +struct nfslog_getfhargs { + fhandle gfh_fh_buf; + char *gfh_path; +}; +typedef struct nfslog_getfhargs nfslog_getfhargs; + +struct nfslog_diropargs { + fhandle da_fhandle; + char *da_name; +}; +typedef struct nfslog_diropargs nfslog_diropargs; + +struct nfslog_drok { + fhandle drok_fhandle; +}; +typedef struct nfslog_drok nfslog_drok; + +struct nfslog_diropres { + nfsstat dr_status; + union { + nfslog_drok dr_ok; + } nfslog_diropres_u; +}; +typedef struct nfslog_diropres nfslog_diropres; + +typedef struct nfsreadargs nfslog_nfsreadargs; + +struct nfslog_rrok { + uint32_t filesize; + uint32_t rrok_count; +}; +typedef struct nfslog_rrok nfslog_rrok; + +struct nfslog_rdresult { + nfsstat r_status; + union { + nfslog_rrok r_ok; + } nfslog_rdresult_u; +}; +typedef struct nfslog_rdresult nfslog_rdresult; + +struct nfslog_writeargs { + fhandle waargs_fhandle; + uint32_t waargs_begoff; + uint32_t waargs_offset; + uint32_t waargs_totcount; + uint32_t waargs_count; +}; +typedef struct nfslog_writeargs nfslog_writeargs; + +struct nfslog_writeresult { + nfsstat wr_status; + union { + uint32_t wr_size; + } nfslog_writeresult_u; +}; +typedef struct nfslog_writeresult nfslog_writeresult; + +struct nfslog_sattr { + uint32_t sa_mode; + uint32_t sa_uid; + uint32_t sa_gid; + uint32_t sa_size; + nfs2_timeval sa_atime; + nfs2_timeval sa_mtime; +}; +typedef struct nfslog_sattr nfslog_sattr; + +struct nfslog_createargs { + nfslog_sattr ca_sa; + nfslog_diropargs ca_da; +}; +typedef struct nfslog_createargs nfslog_createargs; + +struct nfslog_setattrargs { + fhandle saa_fh; + nfslog_sattr saa_sa; +}; +typedef struct nfslog_setattrargs nfslog_setattrargs; + +struct nfslog_rdlnres { + nfsstat rl_status; + union { + char *rl_ok; + } nfslog_rdlnres_u; +}; +typedef struct nfslog_rdlnres nfslog_rdlnres; + +struct nfslog_rnmargs { + nfslog_diropargs rna_from; + nfslog_diropargs rna_to; +}; +typedef struct nfslog_rnmargs nfslog_rnmargs; + +struct nfslog_linkargs { + fhandle la_from; + nfslog_diropargs la_to; +}; +typedef struct nfslog_linkargs nfslog_linkargs; + +struct nfslog_symlinkargs { + nfslog_diropargs sla_from; + char *sla_tnm; + nfslog_sattr sla_sa; +}; +typedef struct nfslog_symlinkargs nfslog_symlinkargs; + +struct nfslog_rddirargs { + fhandle rda_fh; + uint32_t rda_offset; + uint32_t rda_count; +}; +typedef struct nfslog_rddirargs nfslog_rddirargs; + +struct nfslog_rdok { + uint32_t rdok_offset; + uint32_t rdok_size; + bool_t rdok_eof; +}; +typedef struct nfslog_rdok nfslog_rdok; + +struct nfslog_rddirres { + nfsstat rd_status; + union { + nfslog_rdok rd_ok; + } nfslog_rddirres_u; +}; +typedef struct nfslog_rddirres nfslog_rddirres; + +struct nfslog_diropargs3 { + nfs_fh3 dir; + char *name; +}; +typedef struct nfslog_diropargs3 nfslog_diropargs3; + +struct nfslog_LOOKUP3res { + nfsstat3 status; + union { + nfs_fh3 object; + } nfslog_LOOKUP3res_u; +}; +typedef struct nfslog_LOOKUP3res nfslog_LOOKUP3res; + +struct nfslog_createhow3 { + createmode3 mode; + union { + set_size3 size; + } nfslog_createhow3_u; +}; +typedef struct nfslog_createhow3 nfslog_createhow3; + +struct nfslog_CREATE3args { + nfslog_diropargs3 where; + nfslog_createhow3 how; +}; +typedef struct nfslog_CREATE3args nfslog_CREATE3args; + +struct nfslog_CREATE3resok { + post_op_fh3 obj; +}; +typedef struct nfslog_CREATE3resok nfslog_CREATE3resok; + +struct nfslog_CREATE3res { + nfsstat3 status; + union { + nfslog_CREATE3resok ok; + } nfslog_CREATE3res_u; +}; +typedef struct nfslog_CREATE3res nfslog_CREATE3res; + +struct nfslog_SETATTR3args { + nfs_fh3 object; + set_size3 size; +}; +typedef struct nfslog_SETATTR3args nfslog_SETATTR3args; + +struct nfslog_READLINK3res { + nfsstat3 status; + union { + char *data; + } nfslog_READLINK3res_u; +}; +typedef struct nfslog_READLINK3res nfslog_READLINK3res; + +struct nfslog_READ3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; +typedef struct nfslog_READ3args nfslog_READ3args; + +struct nfslog_READ3resok { + size3 filesize; + count3 count; + bool_t eof; + uint32_t size; +}; +typedef struct nfslog_READ3resok nfslog_READ3resok; + +struct nfslog_READ3res { + nfsstat3 status; + union { + nfslog_READ3resok ok; + } nfslog_READ3res_u; +}; +typedef struct nfslog_READ3res nfslog_READ3res; + +struct nfslog_WRITE3args { + nfs_fh3 file; + offset3 offset; + count3 count; + stable_how stable; +}; +typedef struct nfslog_WRITE3args nfslog_WRITE3args; + +struct nfslog_WRITE3resok { + size3 filesize; + count3 count; + stable_how committed; +}; +typedef struct nfslog_WRITE3resok nfslog_WRITE3resok; + +struct nfslog_WRITE3res { + nfsstat3 status; + union { + nfslog_WRITE3resok ok; + } nfslog_WRITE3res_u; +}; +typedef struct nfslog_WRITE3res nfslog_WRITE3res; + +struct nfslog_MKDIR3args { + nfslog_diropargs3 where; +}; +typedef struct nfslog_MKDIR3args nfslog_MKDIR3args; + +struct nfslog_MKDIR3res { + nfsstat3 status; + union { + post_op_fh3 obj; + } nfslog_MKDIR3res_u; +}; +typedef struct nfslog_MKDIR3res nfslog_MKDIR3res; + +struct nfslog_SYMLINK3args { + nfslog_diropargs3 where; + char *symlink_data; +}; +typedef struct nfslog_SYMLINK3args nfslog_SYMLINK3args; + +struct nfslog_SYMLINK3res { + nfsstat3 status; + union { + post_op_fh3 obj; + } nfslog_SYMLINK3res_u; +}; +typedef struct nfslog_SYMLINK3res nfslog_SYMLINK3res; + +struct nfslog_MKNOD3args { + nfslog_diropargs3 where; + ftype3 type; +}; +typedef struct nfslog_MKNOD3args nfslog_MKNOD3args; + +struct nfslog_MKNOD3res { + nfsstat3 status; + union { + post_op_fh3 obj; + } nfslog_MKNOD3res_u; +}; +typedef struct nfslog_MKNOD3res nfslog_MKNOD3res; + +struct nfslog_REMOVE3args { + nfslog_diropargs3 object; +}; +typedef struct nfslog_REMOVE3args nfslog_REMOVE3args; + +struct nfslog_RMDIR3args { + nfslog_diropargs3 object; +}; +typedef struct nfslog_RMDIR3args nfslog_RMDIR3args; + +struct nfslog_RENAME3args { + nfslog_diropargs3 from; + nfslog_diropargs3 to; +}; +typedef struct nfslog_RENAME3args nfslog_RENAME3args; + +struct nfslog_LINK3args { + nfs_fh3 file; + nfslog_diropargs3 link; +}; +typedef struct nfslog_LINK3args nfslog_LINK3args; + +struct nfslog_READDIRPLUS3args { + nfs_fh3 dir; + count3 dircount; + count3 maxcount; +}; +typedef struct nfslog_READDIRPLUS3args nfslog_READDIRPLUS3args; + +struct nfslog_entryplus3 { + post_op_fh3 name_handle; + char *name; + struct nfslog_entryplus3 *nextentry; +}; +typedef struct nfslog_entryplus3 nfslog_entryplus3; + +struct nfslog_dirlistplus3 { + nfslog_entryplus3 *entries; + bool_t eof; +}; +typedef struct nfslog_dirlistplus3 nfslog_dirlistplus3; + +struct nfslog_READDIRPLUS3resok { + nfslog_dirlistplus3 reply; +}; +typedef struct nfslog_READDIRPLUS3resok nfslog_READDIRPLUS3resok; + +struct nfslog_READDIRPLUS3res { + nfsstat3 status; + union { + nfslog_READDIRPLUS3resok ok; + } nfslog_READDIRPLUS3res_u; +}; +typedef struct nfslog_READDIRPLUS3res nfslog_READDIRPLUS3res; + +struct nfslog_COMMIT3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; +typedef struct nfslog_COMMIT3args nfslog_COMMIT3args; + +/* the xdr functions */ +#ifndef _KERNEL + +extern bool_t xdr_nfsstat(XDR *, nfsstat *); +extern bool_t xdr_uint64(XDR *, uint64 *); +extern bool_t xdr_uint32(XDR *, uint32 *); +extern bool_t xdr_fhandle(XDR *, fhandle_t *); +extern bool_t xdr_nfs_fh3(XDR *, nfs_fh3 *); +extern bool_t xdr_nfsstat3(XDR *, nfsstat3 *); +extern bool_t xdr_nfslog_buffer_header(XDR *, nfslog_buffer_header *); +extern bool_t xdr_nfslog_request_record(XDR *, nfslog_request_record *); +extern bool_t xdr_nfslog_sharefsargs(XDR *, nfslog_sharefsargs *); +extern bool_t xdr_nfslog_sharefsres(XDR *, nfslog_sharefsres *); +extern bool_t xdr_nfslog_getfhargs(XDR *, nfslog_getfhargs *); +extern bool_t xdr_nfslog_diropargs(XDR *, nfslog_diropargs *); +extern bool_t xdr_nfslog_diropres(XDR *, nfslog_diropres *); +extern bool_t xdr_nfslog_nfsreadargs(XDR *, nfslog_nfsreadargs *); +extern bool_t xdr_nfslog_rdresult(XDR *, nfslog_rdresult *); +extern bool_t xdr_nfslog_writeargs(XDR *, nfslog_writeargs *); +extern bool_t xdr_nfslog_writeresult(XDR *, nfslog_writeresult *); +extern bool_t xdr_nfslog_createargs(XDR *, nfslog_createargs *); +extern bool_t xdr_nfslog_setattrargs(XDR *, nfslog_setattrargs *); +extern bool_t xdr_nfslog_rdlnres(XDR *, nfslog_rdlnres *); +extern bool_t xdr_nfslog_rnmargs(XDR *, nfslog_rnmargs *); +extern bool_t xdr_nfslog_linkargs(XDR *, nfslog_linkargs *); +extern bool_t xdr_nfslog_symlinkargs(XDR *, nfslog_symlinkargs *); +extern bool_t xdr_nfslog_rddirargs(XDR *, nfslog_rddirargs *); +extern bool_t xdr_nfslog_rddirres(XDR *, nfslog_rddirres *); +extern bool_t xdr_nfslog_diropargs3(XDR *, nfslog_diropargs3 *); +extern bool_t xdr_nfslog_LOOKUP3res(XDR *, nfslog_LOOKUP3res *); +extern bool_t xdr_nfslog_CREATE3args(XDR *, nfslog_CREATE3args *); +extern bool_t xdr_nfslog_CREATE3res(XDR *, nfslog_CREATE3res *); +extern bool_t xdr_nfslog_SETATTR3args(XDR *, nfslog_SETATTR3args *); +extern bool_t xdr_nfslog_READLINK3res(XDR *, nfslog_READLINK3res *); +extern bool_t xdr_nfslog_READ3args(XDR *, nfslog_READ3args *); +extern bool_t xdr_nfslog_READ3res(XDR *, nfslog_READ3res *); +extern bool_t xdr_nfslog_WRITE3args(XDR *, nfslog_WRITE3args *); +extern bool_t xdr_nfslog_WRITE3res(XDR *, nfslog_WRITE3res *); +extern bool_t xdr_nfslog_MKDIR3args(XDR *, nfslog_MKDIR3args *); +extern bool_t xdr_nfslog_MKDIR3res(XDR *, nfslog_MKDIR3res *); +extern bool_t xdr_nfslog_SYMLINK3args(XDR *, nfslog_SYMLINK3args *); +extern bool_t xdr_nfslog_SYMLINK3res(XDR *, nfslog_SYMLINK3res *); +extern bool_t xdr_nfslog_MKNOD3args(XDR *, nfslog_MKNOD3args *); +extern bool_t xdr_nfslog_MKNOD3res(XDR *, nfslog_MKNOD3res *); +extern bool_t xdr_nfslog_REMOVE3args(XDR *, nfslog_REMOVE3args *); +extern bool_t xdr_nfslog_RMDIR3args(XDR *, nfslog_RMDIR3args *); +extern bool_t xdr_nfslog_RENAME3args(XDR *, nfslog_RENAME3args *); +extern bool_t xdr_nfslog_LINK3args(XDR *, nfslog_LINK3args *); +extern bool_t xdr_nfslog_READDIRPLUS3args(XDR *, nfslog_READDIRPLUS3args *); +extern bool_t xdr_nfslog_READDIRPLUS3res(XDR *, nfslog_READDIRPLUS3res *); +extern bool_t xdr_nfslog_COMMIT3args(XDR *, nfslog_COMMIT3args *); + +#else /* !_KERNEL */ + +extern bool_t xdr_nfsstat(XDR *, nfsstat *); +extern bool_t xdr_nfslog_nfsreadargs(XDR *, nfslog_nfsreadargs *); +extern bool_t xdr_nfslog_sharefsres(XDR *, nfslog_sharefsres *); +extern bool_t xdr_nfslog_sharefsargs(XDR *, struct exportinfo *); +extern bool_t xdr_nfslog_getfhargs(XDR *, nfslog_getfhargs *); +extern bool_t xdr_nfslog_diropargs(XDR *, struct nfsdiropargs *); +extern bool_t xdr_nfslog_drok(XDR *, struct nfsdrok *); +extern bool_t xdr_nfslog_diropres(XDR *, struct nfsdiropres *); +extern bool_t xdr_nfslog_getattrres(XDR *, struct nfsattrstat *); +extern bool_t xdr_nfslog_rrok(XDR *, struct nfsrrok *); +extern bool_t xdr_nfslog_rdresult(XDR *, struct nfsrdresult *); +extern bool_t xdr_nfslog_writeargs(XDR *, struct nfswriteargs *); +extern bool_t xdr_nfslog_writeresult(XDR *, struct nfsattrstat *); +extern bool_t xdr_nfslog_createargs(XDR *, struct nfscreatargs *); +extern bool_t xdr_nfslog_sattr(XDR *, struct nfssattr *); +extern bool_t xdr_nfslog_setattrargs(XDR *, struct nfssaargs *); +extern bool_t xdr_nfslog_rdlnres(XDR *, struct nfsrdlnres *); +extern bool_t xdr_nfslog_rnmargs(XDR *, struct nfsrnmargs *); +extern bool_t xdr_nfslog_symlinkargs(XDR *, struct nfsslargs *); +extern bool_t xdr_nfslog_statfs(XDR *, struct nfsstatfs *); +extern bool_t xdr_nfslog_linkargs(XDR *, struct nfslinkargs *); +extern bool_t xdr_nfslog_rddirargs(XDR *, struct nfsrddirargs *); +extern bool_t xdr_nfslog_rdok(XDR *, struct nfsrdok *); +extern bool_t xdr_nfslog_rddirres(XDR *, struct nfsrddirres *); +extern bool_t xdr_nfslog_diropargs3(XDR *, diropargs3 *); +extern bool_t xdr_nfslog_LOOKUP3res(XDR *, LOOKUP3res *); +extern bool_t xdr_nfslog_createhow3(XDR *, createhow3 *); +extern bool_t xdr_nfslog_CREATE3args(XDR *, CREATE3args *); +extern bool_t xdr_nfslog_CREATE3resok(XDR *, CREATE3resok *); +extern bool_t xdr_nfslog_CREATE3res(XDR *, CREATE3res *); +extern bool_t xdr_nfslog_GETATTR3res(XDR *, GETATTR3res *); +extern bool_t xdr_nfslog_ACCESS3args(XDR *, ACCESS3args *); +extern bool_t xdr_nfslog_ACCESS3res(XDR *, ACCESS3res *); +extern bool_t xdr_nfslog_SETATTR3args(XDR *, SETATTR3args *); +extern bool_t xdr_nfslog_SETATTR3res(XDR *, SETATTR3res *); +extern bool_t xdr_nfslog_READLINK3res(XDR *, READLINK3res *); +extern bool_t xdr_nfslog_READ3args(XDR *, READ3args *); +extern bool_t xdr_nfslog_READ3resok(XDR *, READ3resok *); +extern bool_t xdr_nfslog_READ3res(XDR *, READ3res *); +extern bool_t xdr_nfslog_READ3resok(XDR *, READ3resok *); +extern bool_t xdr_nfslog_READ3res(XDR *, READ3res *); +extern bool_t xdr_nfslog_WRITE3args(XDR *, WRITE3args *); +extern bool_t xdr_nfslog_WRITE3resok(XDR *, WRITE3resok *); +extern bool_t xdr_nfslog_WRITE3res(XDR *, WRITE3res *); +extern bool_t xdr_nfslog_MKDIR3args(XDR *, MKDIR3args *); +extern bool_t xdr_nfslog_MKDIR3res(XDR *, MKDIR3res *); +extern bool_t xdr_nfslog_SYMLINK3args(XDR *, SYMLINK3args *); +extern bool_t xdr_nfslog_SYMLINK3res(XDR *, SYMLINK3res *); +extern bool_t xdr_nfslog_MKNOD3args(XDR *, MKNOD3args *); +extern bool_t xdr_nfslog_MKNOD3res(XDR *, MKNOD3res *); +extern bool_t xdr_nfslog_REMOVE3args(XDR *, REMOVE3args *); +extern bool_t xdr_nfslog_REMOVE3res(XDR *, REMOVE3res *); +extern bool_t xdr_nfslog_RMDIR3args(XDR *, RMDIR3args *); +extern bool_t xdr_nfslog_RMDIR3res(XDR *, RMDIR3res *); +extern bool_t xdr_nfslog_RENAME3args(XDR *, RENAME3args *); +extern bool_t xdr_nfslog_RENAME3res(XDR *, RENAME3res *); +extern bool_t xdr_nfslog_LINK3args(XDR *, LINK3args *); +extern bool_t xdr_nfslog_LINK3res(XDR *, LINK3res *); +extern bool_t xdr_nfslog_READDIR3args(XDR *, READDIR3args *); +extern bool_t xdr_nfslog_READDIR3res(XDR *, READDIR3res *); +extern bool_t xdr_nfslog_FSSTAT3args(XDR *, FSSTAT3args *); +extern bool_t xdr_nfslog_FSSTAT3res(XDR *, FSSTAT3res *); +extern bool_t xdr_nfslog_FSINFO3args(XDR *, FSINFO3args *); +extern bool_t xdr_nfslog_FSINFO3res(XDR *, FSINFO3res *); +extern bool_t xdr_nfslog_PATHCONF3args(XDR *, PATHCONF3args *); +extern bool_t xdr_nfslog_PATHCONF3res(XDR *, PATHCONF3res *); +extern bool_t xdr_nfslog_COMMIT3args(XDR *, COMMIT3args *); +extern bool_t xdr_nfslog_COMMIT3res(XDR *, COMMIT3res *); +extern bool_t xdr_nfslog_READDIRPLUS3args(XDR *, READDIRPLUS3args *); +extern bool_t xdr_nfslog_READDIRPLUS3res(XDR *, READDIRPLUS3res *); +extern bool_t xdr_nfslog_request_record(XDR *, struct exportinfo *, + struct svc_req *, cred_t *, struct netbuf *, + unsigned int, unsigned int); + + +#endif /* !_KERNEL */ + +#ifdef _KERNEL + +/* + * Used to direct nfslog_write_record() on its behavior of + * writing log entries + */ +#define NFSLOG_ALL_BUFFERS 1 +#define NFSLOG_ONE_BUFFER 2 + +/* Sizes of the various memory allocations for encoding records */ +#define NFSLOG_SMALL_RECORD_SIZE 512 +#define NFSLOG_SMALL_REC_NAME "nfslog_small_rec" +#define NFSLOG_MEDIUM_RECORD_SIZE 8192 +#define NFSLOG_MEDIUM_REC_NAME "nfslog_medium_rec" +#define NFSLOG_LARGE_RECORD_SIZE 32768 +#define NFSLOG_LARGE_REC_NAME "nfslog_large_rec" + +/* + * Functions used for interaction with nfs logging + */ +extern bool_t xdr_nfslog_buffer_header(XDR *, nfslog_buffer_header *); + +extern void nfslog_share_record(struct exportinfo *exi, cred_t *cr); +extern void nfslog_unshare_record(struct exportinfo *exi, cred_t *cr); +extern void nfslog_getfh(struct exportinfo *, fhandle *, char *, + enum uio_seg, cred_t *); + +extern void nfslog_init(); +extern int nfslog_setup(struct exportinfo *); +extern void nfslog_disable(struct exportinfo *); +/*PRINTFLIKE2*/ +extern void nfslog_dprint(const int, const char *fmt, ...) + __KPRINTFLIKE(2); +extern void *nfslog_record_alloc(struct exportinfo *, int, + void **, int); +extern void nfslog_record_free(void *, void *, size_t); +extern struct exportinfo *nfslog_get_exi(nfs_export_t *, struct exportinfo *, + struct svc_req *, caddr_t, unsigned int *); +extern void nfslog_write_record(struct exportinfo *, struct svc_req *, + caddr_t, caddr_t, cred_t *, struct netbuf *, unsigned int, + unsigned int); + +extern struct log_buffer *nfslog_buffer_list; + +/* + * Logging debug macro; expands to nothing for non-debug kernels. + */ +#ifndef DEBUG +#define LOGGING_DPRINT(x) +#else +#define LOGGING_DPRINT(x) nfslog_dprint x +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_LOG_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfs_sec.h b/illumos-x86_64/usr/include/nfs/nfs_sec.h new file mode 100644 index 00000000..99d528c3 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfs_sec.h @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * nfs_sec.h, NFS specific security service information. + */ + +#ifndef _NFS_SEC_H +#define _NFS_SEC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef _KERNEL +#define NFSSEC_CONF "/etc/nfssec.conf" +#define SC_FAILURE -1 +/* + * An error string produced by nfs_syslog_scerr can be no longer than + * MAXMSGLEN + */ +#define MAXMSGLEN 80 + +/* + * Errors for the nfssec_* + */ +#define SC_NOERROR 0 +#define SC_NOMEM 1 +#define SC_OPENFAIL 2 +#define SC_NOTFOUND 3 +#define SC_BADENTRIES 4 /* Bad entries in nfssec.conf file */ +#endif /* _KERNEL */ + +typedef struct seconfig { + char sc_name[MAX_NAME_LEN]; + int sc_nfsnum; + int sc_rpcnum; + char sc_gss_mech[MAX_NAME_LEN]; + struct rpc_gss_OID_s *sc_gss_mech_type; + uint_t sc_qop; + rpc_gss_service_t sc_service; + uid_t sc_uid; +} seconfig_t; + +#ifdef _SYSCALL32 +typedef struct seconfig32 { + char sc_name[MAX_NAME_LEN]; + int32_t sc_nfsnum; + int32_t sc_rpcnum; + char sc_gss_mech[MAX_NAME_LEN]; + caddr32_t sc_gss_mech_type; + uint32_t sc_qop; + int32_t sc_service; + uid_t sc_uid; +} seconfig32_t; +#endif /* _SYSCALL32 */ + +#ifndef _KERNEL +extern int nfs_getseconfig_default(seconfig_t *); +extern int nfs_getseconfig_byname(char *, seconfig_t *); +extern int nfs_getseconfig_bynumber(int, seconfig_t *); +extern int nfs_getseconfig_bydesc(char *, char *, rpc_gss_service_t, + seconfig_t *); +extern sec_data_t *nfs_clnt_secdata(seconfig_t *, char *, struct knetconfig *, + struct netbuf *, int); +extern void nfs_free_secdata(sec_data_t *); +extern int nfs_syslog_scerr(int, char[]); +extern bool_t nfs_get_root_principal(seconfig_t *, char *, caddr_t *); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_NFS_SEC_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfsid_map.h b/illumos-x86_64/usr/include/nfs/nfsid_map.h new file mode 100644 index 00000000..197970d4 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfsid_map.h @@ -0,0 +1,179 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NFSID_MAP_H +#define _NFSID_MAP_H + +#ifndef _KERNEL +#include +#endif +#include +#include + +/* + * NFSv4 id mapping daemon + * + * This daemon is used by the kernel to map strings in the form + * "user@dns_domain" from an integer form or vice-versa. The daemon + * uses the system configured name services for the mapping. + * + * The status results determines if a mapping was successful. + * + * The mapping is cached in the kernel, so that expensive upcalls are + * reduced to a minimum. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * mapid commands + */ +#define NFSMAPID_STR_UID 1 +#define NFSMAPID_UID_STR 2 +#define NFSMAPID_STR_GID 3 +#define NFSMAPID_GID_STR 4 +#define NFSMAPID_SRV_NETINFO 5 + +/* + * We are passing in arguments in a variable length struct + * similar to a dirent_t. We break apart a utf8string into + * its components and allocate a struct long enough to hold + * the string and a NUL terminator. The caller must ensure the + * terminator is set. + */ +struct mapid_arg { + uint_t cmd; + union { + uid_t uid; + gid_t gid; + int len; + } u_arg; + char str[1]; +}; +typedef struct mapid_arg mapid_arg_t; + +/* + * The actual required size of the args, rounded up to a 64 bit boundary + */ +#define MAPID_ARG_LEN(str_length) \ + ((offsetof(mapid_arg_t, str[0]) + 1 + (str_length) + 7) & ~ 7) + +/* + * Return status codes + */ +#define NFSMAPID_OK 0 + +/* + * numeric string is mapped to its literal number + */ +#define NFSMAPID_NUMSTR 1 + +/* + * Value cannot be mapped, badly formed string + */ +#define NFSMAPID_UNMAPPABLE 2 + +/* + * Caller provided invalid arguments + */ +#define NFSMAPID_INVALID 3 + +/* + * Internal error in daemon e.g. out of memory, can't return result + */ +#define NFSMAPID_INTERNAL 4 + +/* + * Incorrect domain used + */ +#define NFSMAPID_BADDOMAIN 5 + +/* + * Out of range uid/gid + */ +#define NFSMAPID_BADID 6 + +/* + * User or group cannot be found in nameservice + */ +#define NFSMAPID_NOTFOUND 7 + +/* + * Similar to the arguments, the result is variable length. + * The returner must ensure the string terminator is set. + */ +struct mapid_res { + uint_t status; + union { + uid_t uid; + gid_t gid; + int len; + } u_res; + char str[1]; +}; +typedef struct mapid_res mapid_res_t; + +/* + * The actual required size of the result, rounded up to a 64 bit boundary + */ +#define MAPID_RES_LEN(str_length) \ + ((offsetof(mapid_res_t, str[0]) + 1 + (str_length) + 7) & ~ 7) + +/* + * Support for referral name resolution by the NFS client + */ +typedef struct refd_door_args { + int cmd; /* NFS4_FS_LOCATIONS/NFS4_SRV_NETINFO */ + int xdr_len; /* Length of xdr Buffer */ + char xdr_arg[1]; /* Buffer holding xdr encoded data */ +} refd_door_args_t; + +typedef struct refd_door_res { + int res_status; + int xdr_len; + char xdr_res[1]; +} refd_door_res_t; + +#ifdef _SYSCALL32 +typedef struct refd_door_args32 { + int32_t cmd; + int32_t xdr_len; + char xdr_arg[1]; +} refd_door_args32_t; + +typedef struct refd_door_res32 { + int32_t res_status; + int32_t xdr_len; + char xdr_res[1]; +} refd_door_res32_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NFSID_MAP_H */ diff --git a/illumos-x86_64/usr/include/nfs/nfssys.h b/illumos-x86_64/usr/include/nfs/nfssys.h new file mode 100644 index 00000000..8cc2f05c --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/nfssys.h @@ -0,0 +1,342 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Joyent, Inc. + * Copyright 2023 MNX Cloud, Inc. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _NFS_NFSSYS_H +#define _NFS_NFSSYS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Private definitions for the nfssys system call. + * Note: and must be included before + * this file. + */ + +/* + * Flavors of nfssys call. Note that OLD_mumble commands are no longer + * implemented, but the entries are kept as placeholders for binary + * compatibility. + */ +enum nfssys_op { OLD_NFS_SVC, OLD_ASYNC_DAEMON, EXPORTFS, OLD_NFS_GETFH, + OLD_NFS_CNVT, NFS_REVAUTH, OLD_NFS_FH_TO_FID, OLD_LM_SVC, KILL_LOCKMGR, + LOG_FLUSH, SVCPOOL_CREATE, NFS_SVC, LM_SVC, SVCPOOL_WAIT, SVCPOOL_RUN, + NFS4_SVC, RDMA_SVC_INIT, NFS4_CLR_STATE, NFS_IDMAP, + NFS4_SVC_REQUEST_QUIESCE, NFS_GETFH, NFS4_DSS_SETPATHS, + NFS4_DSS_SETPATHS_SIZE, NFS4_EPHEMERAL_MOUNT_TO, MOUNTD_ARGS, + NFSCMD_ARGS }; + +/* + * The protocol version below represents protocol version number and + * for version 4 - minor version number. Use NFS_PROT_VERSION() and + * NFS_PROT_V4_MINORVERSION() to analyse them. + */ +struct nfs_svc_args { + int fd; /* Connection endpoint */ + char *netid; /* Identify transport */ + struct netbuf addrmask; /* Address mask for host */ + uint32_t nfs_versmin; /* Min protocol version. NFS_VERS_ */ + uint32_t nfs_versmax; /* Max protocol version. NFS_VERS_ */ + int delegation; /* NFSv4 delegation on/off? */ +}; + +#ifdef _SYSCALL32 +struct nfs_svc_args32 { + int32_t fd; /* Connection endpoint */ + caddr32_t netid; /* Identify transport */ + struct netbuf32 addrmask; /* Address mask for host */ + uint32_t nfs_versmin; /* Min protocol version. NFS_VERS_ */ + uint32_t nfs_versmax; /* Max protocol version. NFS_VERS_ */ + int32_t delegation; /* NFSv4 delegation on/off? */ +}; +#endif + +struct exportfs_args { + char *dname; + struct exportdata *uex; +}; + +#ifdef _SYSCALL32 +struct exportfs_args32 { + caddr32_t dname; + caddr32_t uex; +}; +#endif + +struct nfs_getfh_args { + char *fname; + int vers; + int *lenp; + char *fhp; +}; + +#ifdef _SYSCALL32 +struct nfs_getfh_args32 { + caddr32_t fname; + int32_t vers; + caddr32_t lenp; + caddr32_t fhp; +}; +#endif + +struct nfs_revauth_args { + int authtype; + uid_t uid; +}; + +#ifdef _SYSCALL32 +struct nfs_revauth_args32 { + int32_t authtype; + uid32_t uid; +}; +#endif + +/* + * Arguments for establishing lock manager service. If you change + * lm_svc_args, you should increment the version number. Try to keep + * supporting one or more old versions of the args, so that old lockd's + * will work with new kernels. + */ + +enum lm_fmly { LM_INET, LM_INET6, LM_LOOPBACK }; +enum lm_proto { LM_TCP, LM_UDP }; + +/* + * The 'n_v4_only' member was formerly called 'debug'. This member is not used + * in the kernel. To avoid a new version of this user/kernel interface + * structure, the member was renamed in a binary compatible way. It is now used + * by the user-level code to indicate that the zone is not running + * rpcbind/rpc.statd and that only NFSv4 locking is needed. + */ +struct lm_svc_args { + int version; /* keep this first */ + int fd; + enum lm_fmly n_fmly; /* protocol family */ + enum lm_proto n_proto; /* protocol */ + dev_t n_rdev; /* device ID */ + int n_v4_only; /* NFSv4 locking only */ + time_t timout; /* client handle life (asynch RPCs) */ + int grace; /* secs in grace period */ + time_t retransmittimeout; /* retransmission interval */ +}; + +#ifdef _SYSCALL32 +struct lm_svc_args32 { + int32_t version; /* keep this first */ + int32_t fd; + enum lm_fmly n_fmly; /* protocol family */ + enum lm_proto n_proto; /* protocol */ + dev32_t n_rdev; /* device ID */ + int32_t n_v4_only; /* NFSv4 locking only */ + time32_t timout; /* client handle life (asynch RPCs) */ + int32_t grace; /* secs in grace period */ + time32_t retransmittimeout; /* retransmission interval */ +}; +#endif + +#define LM_SVC_CUR_VERS 30 /* current lm_svc_args vers num */ + +/* + * Arguments for nfslog flush service. + */ +struct nfsl_flush_args { + int version; + int directive; + char *buff; /* buffer to flush/rename */ + int buff_len; /* includes terminating '\0' */ +}; + +#define NFSL_FLUSH_ARGS_VERS 1 /* current nfsl_flush_args vers num */ + +#ifdef _SYSCALL32 +struct nfsl_flush_args32 { + int32_t version; + int32_t directive; + caddr32_t buff; /* buffer to flush/rename */ + int32_t buff_len; /* includes terminating '\0' */ +}; +#endif + +/* + * Arguments for initialising RDMA service. + */ +struct rdma_svc_args { + uint32_t poolid; /* Thread Pool ID */ + char *netid; /* Network Identifier */ + uint32_t nfs_versmin; /* Min NFS version. NFS_VERS_... */ + uint32_t nfs_versmax; /* Max NFS version. NFS_VERS_... */ + int delegation; /* NFSv4 delegation on/off? */ +}; + +#ifdef _SYSCALL32 +struct rdma_svc_args32 { + uint32_t poolid; /* Thread Pool ID */ + caddr32_t netid; /* Network Identifier */ + uint32_t nfs_versmin; /* Min NFS version. NFS_VERS_... */ + uint32_t nfs_versmax; /* Max NFS version. NFS_VERS_... */ + int32_t delegation; /* NFSv4 delegation on/off? */ +}; +#endif + + +#define NFS4_CLRST_VERSION 1 +struct nfs4clrst_args { + int vers; + int addr_type; + void *ap; +}; + +#ifdef _SYSCALL32 +struct nfs4clrst_args32 { + int32_t vers; + int32_t addr_type; + caddr32_t ap; +}; +#endif + +struct nfsidmap_args { + uint_t state; /* Flushes caches, set state up 1 or down 0 */ + uint_t did; /* Door id to upcall */ +}; + +#define NFSL_ALL 0x01 /* Flush all buffers */ +#define NFSL_RENAME 0x02 /* Rename buffer(s) */ +#define NFSL_SYNC 0x04 /* Perform operation synchronously? */ + +#ifdef _KERNEL +union nfssysargs { + struct exportfs_args *exportfs_args_u; /* exportfs args */ + struct nfs_getfh_args *nfs_getfh_args_u; /* nfs_getfh args */ + struct nfs_svc_args *nfs_svc_args_u; /* nfs_svc args */ + struct rdma_svc_args *rdma_svc_args_u; /* rdma_svc args */ + struct nfs_revauth_args *nfs_revauth_args_u; /* nfs_revauth args */ + struct lm_svc_args *lm_svc_args_u; /* lm_svc args */ + /* kill_lockmgr args: none */ + struct nfsl_flush_args *nfsl_flush_args_u; /* nfsl_flush args */ + struct svcpool_args *svcpool_args_u; /* svcpool args */ + struct nfs4clrst_args *nfs4clrst_u; /* nfs4 clear state */ + struct nfsidmap_args *nfsidmap_u; /* nfsidmap */ +}; + +struct nfssysa { + enum nfssys_op opcode; /* operation discriminator */ + union nfssysargs arg; /* syscall-specific arg pointer */ +}; +#define nfssysarg_exportfs arg.exportfs_args_u +#define nfssysarg_getfh arg.nfs_getfh_args_u +#define nfssysarg_svc arg.nfs_svc_args_u +#define nfssysarg_rdmastart arg.rdma_svc_args_u +#define nfssysarg_revauth arg.nfs_revauth_args_u +#define nfssysarg_lmsvc arg.lm_svc_args_u +#define nfssysarg_nfslflush arg.nfsl_flush_args_u +#define nfssysarg_svcpool arg.svcpool_args_u +#define nfssysarg_nfs4clrst arg.nfs4clrst_u +#define nfssysarg_nfsidmap arg.nfsidmap_u + +#ifdef _SYSCALL32 +union nfssysargs32 { + caddr32_t exportfs_args_u; /* exportfs args */ + caddr32_t nfs_getfh_args_u; /* nfs_getfh args */ + caddr32_t nfs_svc_args_u; /* nfs_svc args */ + caddr32_t rdma_svc_args_u; /* rdma_start args */ + caddr32_t nfs_revauth_args_u; /* nfs_revauth args */ + caddr32_t lm_svc_args_u; /* lm_svc args */ + /* kill_lockmgr args: none */ + caddr32_t nfsl_flush_args_u; /* nfsl_flush args */ + caddr32_t svcpool_args_u; + caddr32_t nfs4clrst_u; +}; +struct nfssysa32 { + enum nfssys_op opcode; /* operation discriminator */ + union nfssysargs32 arg; /* syscall-specific arg pointer */ +}; +#endif /* _SYSCALL32 */ + +#endif /* _KERNEL */ + +struct nfs4_svc_args { + int fd; /* Connection endpoint */ + int cmd; + char *netid; /* Transport Identifier */ + char *addr; /* Universal Address */ + char *protofmly; /* Protocol Family */ + char *proto; /* Protocol, eg. "tcp" */ + struct netbuf addrmask; /* Address mask for host */ +}; + +#ifdef _SYSCALL32 +struct nfs4_svc_args32 { + int32_t fd; + int32_t cmd; + caddr32_t netid; + caddr32_t addr; + caddr32_t protofmly; + caddr32_t proto; + struct netbuf32 addrmask; +}; +#endif + +#define NFS4_KRPC_START 1 +#define NFS4_SETPORT 2 +#define NFS4_DQUERY 4 + +/* DSS: distributed stable storage */ +#define NFS4_DSS_STATE_LEAF "v4_state" +#define NFS4_DSS_OLDSTATE_LEAF "v4_oldstate" +#define NFS4_DSS_DIR_MODE 0755 +#define NFS4_DSS_NVPAIR_NAME "dss_pathname_array" +/* default storage dir */ +#define NFS4_DSS_VAR_DIR "/var/nfs" + +#ifdef _KERNEL + +#include /* for rval_t typedef */ + +extern int nfssys(enum nfssys_op opcode, void *arg); +extern int exportfs(struct exportfs_args *, model_t, cred_t *); +extern int nfs_getfh(struct nfs_getfh_args *, model_t, cred_t *); +extern int nfs_svc(struct nfs_svc_args *, model_t); +extern int lm_svc(struct lm_svc_args *uap); +extern int lm_shutdown(void); +extern int nfsl_flush(struct nfsl_flush_args *, model_t); +extern int nfs4_svc(struct nfs4_svc_args *, model_t); +extern int rdma_start(struct rdma_svc_args *); +extern int rfs4_clear_client_state(struct nfs4clrst_args *); +extern void nfs_idmap_args(struct nfsidmap_args *); +extern void nfs4_ephemeral_set_mount_to(uint_t); +extern void mountd_args(uint_t); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_NFSSYS_H */ diff --git a/illumos-x86_64/usr/include/nfs/rnode.h b/illumos-x86_64/usr/include/nfs/rnode.h new file mode 100644 index 00000000..a9433b94 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/rnode.h @@ -0,0 +1,416 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _NFS_RNODE_H +#define _NFS_RNODE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum nfs_access_type { + NFS_ACCESS_UNKNOWN, + NFS_ACCESS_ALLOWED, + NFS_ACCESS_DENIED +} nfs_access_type_t; + +typedef struct acache_hash { + struct acache *next; /* next and prev must be first */ + struct acache *prev; + krwlock_t lock; +} acache_hash_t; + +typedef struct acache { + struct acache *next; /* next and prev must be first */ + struct acache *prev; + uint32_t known; + uint32_t allowed; + struct rnode *rnode; + cred_t *cred; + struct acache *list; + struct acache_hash *hashq; +} acache_t; + +#define NFS_FHANDLE_LEN 72 + +typedef struct nfs_fhandle { + int fh_len; + char fh_buf[NFS_FHANDLE_LEN]; +} nfs_fhandle; + +typedef struct rddir_cache { + lloff_t _cookie; /* cookie used to find this cache entry */ + lloff_t _ncookie; /* cookie used to find the next cache entry */ + char *entries; /* buffer containing dirent entries */ + int eof; /* EOF reached after this request */ + int entlen; /* size of dirent entries in buf */ + int buflen; /* size of the buffer used to store entries */ + int flags; /* control flags, see below */ + kcondvar_t cv; /* cv for blocking */ + int error; /* error from RPC operation */ + kmutex_t lock; + uint_t count; /* reference count */ + avl_node_t tree; /* AVL tree links */ +} rddir_cache; + +#define nfs_cookie _cookie._p._l +#define nfs_ncookie _ncookie._p._l +#define nfs3_cookie _cookie._f +#define nfs3_ncookie _ncookie._f + +#define RDDIR 0x1 /* readdir operation in progress */ +#define RDDIRWAIT 0x2 /* waiting on readdir in progress */ +#define RDDIRREQ 0x4 /* a new readdir is required */ +#define RDDIRCACHED 0x8 /* entry is in the cache */ + +#define HAVE_RDDIR_CACHE(rp) (avl_numnodes(&(rp)->r_dir) > 0) + +typedef struct symlink_cache { + char *contents; /* contents of the symbolic link */ + int len; /* length of the contents */ + int size; /* size of the allocated buffer */ +} symlink_cache; + +typedef struct commit { + page_t *c_pages; /* list of pages to commit */ + offset3 c_commbase; /* base offset to do commit from */ + count3 c_commlen; /* len to commit */ + kcondvar_t c_cv; /* condvar for waiting for commit */ +} commit_t; + +/* + * The various values for the commit states. These are stored in + * the p_fsdata byte in the page struct. + * NFSv3,4 can use asynchronous writes - the NFS server can send a response + * before storing the data to the stable store (disk). The response contains + * information if the data are on a disk or not. NFS client marks pages + * which are already on the stable store as C_NOCOMMIT. The pages which were + * sent but are not yet on the stable store are only partially 'safe' and are + * marked as C_DELAYCOMMIT, which can be later changed to C_COMMIT if the + * commit operation is in progress. If the NFS server is e.g. rebooted, the + * client needs to resend all the uncommitted data. The client walks all the + * vp->v_pages and if C_DELAYCOMMIT or C_COMMIT is set, the page is marked as + * dirty and thus will be written to the server again. + */ +#define C_NOCOMMIT 0 /* no commit is required */ +#define C_COMMIT 1 /* a commit is required so do it now */ +#define C_DELAYCOMMIT 2 /* a commit is required, but can be delayed */ + +/* + * The lock manager holds state making it possible for the client + * and server to be out of sync. For example, if the response from + * the server granting a lock request is lost, the server will think + * the lock is granted and the client will think the lock is lost. + * To deal with this, a list of processes for which the client is + * not sure if the server holds a lock is attached to the rnode. + * When such a process closes the rnode, an unlock request is sent + * to the server to unlock the entire file. + * + * The list is kept as a singularly linked NULL terminated list. + * Because it is only added to under extreme error conditions, the + * list shouldn't get very big. DEBUG kernels print a console warning + * when the number of entries on a list go beyond nfs_lmpl_high_water + * an arbitrary number defined in nfs_add_locking_id() + */ +#define RLMPL_PID 1 +#define RLMPL_OWNER 2 +typedef struct lock_manager_pid_list { + int lmpl_type; + pid_t lmpl_pid; + union { + pid_t _pid; + struct { + int len; + char *owner; + } _own; + } un; + struct lock_manager_pid_list *lmpl_next; +} lmpl_t; + +#define lmpl_opid un._pid +#define lmpl_own_len un._own.len +#define lmpl_owner un._own.owner + +/* + * A homegrown reader/writer lock implementation. It addresses + * two requirements not addressed by the system primitives. They + * are that the `enter" operation is optionally interruptible and + * that they can be re`enter'ed by writers without deadlock. + */ +typedef struct nfs_rwlock { + int count; + int waiters; + kthread_t *owner; + kmutex_t lock; + kcondvar_t cv; + kcondvar_t cv_rd; +} nfs_rwlock_t; + +/* + * The format of the hash bucket used to lookup rnodes from a file handle. + */ +typedef struct rhashq { + struct rnode *r_hashf; + struct rnode *r_hashb; + krwlock_t r_lock; +} rhashq_t; + +/* + * Remote file information structure. + * + * The rnode is the "inode" for remote files. It contains all the + * information necessary to handle remote file on the client side. + * + * Note on file sizes: we keep two file sizes in the rnode: the size + * according to the client (r_size) and the size according to the server + * (r_attr.va_size). They can differ because we modify r_size during a + * write system call (nfs_rdwr), before the write request goes over the + * wire (before the file is actually modified on the server). If an OTW + * request occurs before the cached data is written to the server the file + * size returned from the server (r_attr.va_size) may not match r_size. + * r_size is the one we use, in general. r_attr.va_size is only used to + * determine whether or not our cached data is valid. + * + * Each rnode has 3 locks associated with it (not including the rnode + * hash table and free list locks): + * + * r_rwlock: Serializes nfs_write and nfs_setattr requests + * and allows nfs_read requests to proceed in parallel. + * Serializes reads/updates to directories. + * + * r_lkserlock: Serializes lock requests with map, write, and + * readahead operations. + * + * r_statelock: Protects all fields in the rnode except for + * those listed below. This lock is intented + * to be held for relatively short periods of + * time (not accross entire putpage operations, + * for example). + * + * The following members are protected by the mutex rpfreelist_lock: + * r_freef + * r_freeb + * + * The following members are protected by the hash bucket rwlock: + * r_hashf + * r_hashb + * + * Note: r_modaddr is only accessed when the r_statelock mutex is held. + * Its value is also controlled via r_rwlock. It is assumed that + * there will be only 1 writer active at a time, so it safe to + * set r_modaddr and release r_statelock as long as the r_rwlock + * writer lock is held. + * + * r_inmap informs nfsX_read()/write() that there is a call to nfsX_map() + * in progress. nfsX_read()/write() check r_inmap to decide whether + * to perform directio on the file or not. r_inmap is atomically + * incremented in nfsX_map() before the address space routines are + * called and atomically decremented just before nfsX_map() exits. + * r_inmap is not protected by any lock. + * + * r_mapcnt tells that the rnode has mapped pages. r_inmap can be 0 + * while the rnode has mapped pages. + * + * 64-bit offsets: the code formerly assumed that atomic reads of + * r_size were safe and reliable; on 32-bit architectures, this is + * not true since an intervening bus cycle from another processor + * could update half of the size field. The r_statelock must now + * be held whenever any kind of access of r_size is made. + * + * Lock ordering: + * r_rwlock > r_lkserlock > r_statelock + */ +struct exportinfo; /* defined in nfs/export.h */ +struct servinfo; /* defined in nfs/nfs_clnt.h */ +struct failinfo; /* defined in nfs/nfs_clnt.h */ +struct mntinfo; /* defined in nfs/nfs_clnt.h */ + +#ifdef _KERNEL + +typedef struct rnode { + /* the hash fields must be first to match the rhashq_t */ + struct rnode *r_hashf; /* hash queue forward pointer */ + struct rnode *r_hashb; /* hash queue back pointer */ + struct rnode *r_freef; /* free list forward pointer */ + struct rnode *r_freeb; /* free list back pointer */ + rhashq_t *r_hashq; /* pointer to the hash bucket */ + vnode_t *r_vnode; /* vnode for remote file */ + nfs_rwlock_t r_rwlock; /* serializes write/setattr requests */ + nfs_rwlock_t r_lkserlock; /* serialize lock with other ops */ + kmutex_t r_statelock; /* protects (most of) rnode contents */ + nfs_fhandle r_fh; /* file handle */ + struct servinfo *r_server; /* current server */ + char *r_path; /* path to this rnode */ + u_offset_t r_nextr; /* next byte read offset (read-ahead) */ + cred_t *r_cred; /* current credentials */ + cred_t *r_unlcred; /* unlinked credentials */ + char *r_unlname; /* unlinked file name */ + vnode_t *r_unldvp; /* parent dir of unlinked file */ + len_t r_size; /* client's view of file size */ + struct vattr r_attr; /* cached vnode attributes */ + hrtime_t r_attrtime; /* time attributes become invalid */ + hrtime_t r_mtime; /* client time file last modified */ + long r_mapcnt; /* count of mmapped pages */ + uint_t r_count; /* # of refs not reflect in v_count */ + uint_t r_awcount; /* # of outstanding async write */ + uint_t r_gcount; /* getattrs waiting to flush pages */ + ushort_t r_flags; /* flags, see below */ + short r_error; /* async write error */ + kcondvar_t r_cv; /* condvar for blocked threads */ + int (*r_putapage) /* address of putapage routine */ + (vnode_t *, page_t *, u_offset_t *, size_t *, int, cred_t *); + avl_tree_t r_dir; /* cache of readdir responses */ + rddir_cache *r_direof; /* pointer to the EOF entry */ + symlink_cache r_symlink; /* cached readlink response */ + writeverf3 r_verf; /* version 3 write verifier */ + u_offset_t r_modaddr; /* address for page in writerp */ + commit_t r_commit; /* commit information */ + u_offset_t r_truncaddr; /* base for truncate operation */ + vsecattr_t *r_secattr; /* cached security attributes (acls) */ + cookieverf3 r_cookieverf; /* version 3 readdir cookie verifier */ + lmpl_t *r_lmpl; /* pids that may be holding locks */ + nfs3_pathconf_info *r_pathconf; /* cached pathconf information */ + acache_t *r_acache; /* list of access cache entries */ + kthread_t *r_serial; /* id of purging thread */ + list_t r_indelmap; /* list of delmap callers */ + uint_t r_inmap; /* to serialize read/write and mmap */ + list_node_t r_mi_link; /* linkage into list of rnodes for */ + /* this mntinfo */ +} rnode_t; +#endif /* _KERNEL */ + +/* + * Flags + */ +#define RREADDIRPLUS 0x1 /* issue a READDIRPLUS instead of READDIR */ +#define RDIRTY 0x2 /* dirty pages from write operation */ +#define RSTALE 0x4 /* file handle is stale */ +#define RMODINPROGRESS 0x8 /* page modification happening */ +#define RTRUNCATE 0x10 /* truncating, don't commit */ +#define RHAVEVERF 0x20 /* have a write verifier to compare against */ +#define RCOMMIT 0x40 /* commit in progress */ +#define RCOMMITWAIT 0x80 /* someone is waiting to do a commit */ +#define RHASHED 0x100 /* rnode is in hash queues */ +#define ROUTOFSPACE 0x200 /* an out of space error has happened */ +#define RDIRECTIO 0x400 /* bypass the buffer cache */ +#define RLOOKUP 0x800 /* a lookup has been performed */ +#define RWRITEATTR 0x1000 /* attributes came from WRITE */ +#define RINDNLCPURGE 0x2000 /* in the process of purging DNLC references */ +#define RDELMAPLIST 0x4000 /* delmap callers tracking for as callback */ +#define RINCACHEPURGE 0x8000 /* purging caches due to file size change */ + +/* + * Convert between vnode and rnode + */ +#define RTOV(rp) ((rp)->r_vnode) +#define VTOR(vp) ((rnode_t *)((vp)->v_data)) + +#define VTOFH(vp) (RTOFH(VTOR(vp))) +#define RTOFH(rp) ((fhandle_t *)(&(rp)->r_fh.fh_buf)) +#define VTOFH3(vp) (RTOFH3(VTOR(vp))) +#define RTOFH3(rp) ((nfs_fh3 *)(&(rp)->r_fh)) + +#ifdef _KERNEL +extern int nfs_async_readahead(vnode_t *, u_offset_t, caddr_t, + struct seg *, cred_t *, + void (*)(vnode_t *, u_offset_t, + caddr_t, struct seg *, cred_t *)); +extern int nfs_async_putapage(vnode_t *, page_t *, u_offset_t, size_t, + int, cred_t *, int (*)(vnode_t *, page_t *, + u_offset_t, size_t, int, cred_t *)); +extern int nfs_async_pageio(vnode_t *, page_t *, u_offset_t, size_t, + int, cred_t *, int (*)(vnode_t *, page_t *, + u_offset_t, size_t, int, cred_t *)); +extern void nfs_async_readdir(vnode_t *, rddir_cache *, + cred_t *, int (*)(vnode_t *, + rddir_cache *, cred_t *)); +extern void nfs_async_commit(vnode_t *, page_t *, offset3, count3, + cred_t *, void (*)(vnode_t *, page_t *, + offset3, count3, cred_t *)); +extern void nfs_async_inactive(vnode_t *, cred_t *, void (*)(vnode_t *, + cred_t *, caller_context_t *)); +extern int writerp(rnode_t *, caddr_t, int, struct uio *, int); +extern int nfs_putpages(vnode_t *, u_offset_t, size_t, int, cred_t *); +extern void nfs_invalidate_pages(vnode_t *, u_offset_t, cred_t *); +extern int rfs2call(struct mntinfo *, rpcproc_t, xdrproc_t, caddr_t, + xdrproc_t, caddr_t, cred_t *, int *, enum nfsstat *, + int, struct failinfo *); +extern int rfs3call(struct mntinfo *, rpcproc_t, xdrproc_t, caddr_t, + xdrproc_t, caddr_t, cred_t *, int *, nfsstat3 *, + int, struct failinfo *); +extern void nfs_setswaplike(vnode_t *, vattr_t *); +extern vnode_t *makenfsnode(fhandle_t *, struct nfsfattr *, struct vfs *, + hrtime_t, cred_t *, char *, char *); +extern vnode_t *makenfs3node_va(nfs_fh3 *, vattr_t *, struct vfs *, hrtime_t, + cred_t *, char *, char *); +extern vnode_t *makenfs3node(nfs_fh3 *, fattr3 *, struct vfs *, hrtime_t, + cred_t *, char *, char *); +extern void rp_addfree(rnode_t *, cred_t *); +extern void rp_rmhash(rnode_t *); +extern int check_rtable(struct vfs *); +extern void destroy_rtable(struct vfs *, cred_t *); +extern void rflush(struct vfs *, cred_t *); +extern nfs_access_type_t nfs_access_check(rnode_t *, uint32_t, cred_t *); +extern void nfs_access_cache(rnode_t *rp, uint32_t, uint32_t, cred_t *); +extern int nfs_access_purge_rp(rnode_t *); +extern int nfs_putapage(vnode_t *, page_t *, u_offset_t *, size_t *, + int, cred_t *); +extern int nfs3_putapage(vnode_t *, page_t *, u_offset_t *, size_t *, + int, cred_t *); +extern void nfs_printfhandle(nfs_fhandle *); +extern void nfs_write_error(vnode_t *, int, cred_t *); +extern rddir_cache *rddir_cache_alloc(int); +extern void rddir_cache_hold(rddir_cache *); +extern void rddir_cache_rele(rddir_cache *); +#ifdef DEBUG +extern char *rddir_cache_buf_alloc(size_t, int); +extern void rddir_cache_buf_free(void *, size_t); +#endif +extern int nfs_rw_enter_sig(nfs_rwlock_t *, krw_t, int); +extern int nfs_rw_tryenter(nfs_rwlock_t *, krw_t); +extern void nfs_rw_exit(nfs_rwlock_t *); +extern int nfs_rw_lock_held(nfs_rwlock_t *, krw_t); +extern void nfs_rw_init(nfs_rwlock_t *, char *, krw_type_t, void *); +extern void nfs_rw_destroy(nfs_rwlock_t *); +extern int nfs_directio(vnode_t *, int, cred_t *); +extern int nfs3_rddir_compar(const void *, const void *); +extern int nfs_rddir_compar(const void *, const void *); +extern struct zone *nfs_zone(void); +extern zoneid_t nfs_zoneid(void); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_RNODE_H */ diff --git a/illumos-x86_64/usr/include/nfs/rnode4.h b/illumos-x86_64/usr/include/nfs/rnode4.h new file mode 100644 index 00000000..216ebd26 --- /dev/null +++ b/illumos-x86_64/usr/include/nfs/rnode4.h @@ -0,0 +1,518 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _NFS_RNODE4_H +#define _NFS_RNODE4_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include /* for symlink_cache, nfs_rwlock_t, etc. */ +#include +#include +#include +#include /* for offsetof */ + +typedef enum nfs4_stub_type { + NFS4_STUB_NONE, + NFS4_STUB_MIRRORMOUNT, + NFS4_STUB_REFERRAL +} nfs4_stub_type_t; + +typedef enum nfs4_access_type { + NFS4_ACCESS_UNKNOWN, + NFS4_ACCESS_ALLOWED, + NFS4_ACCESS_DENIED +} nfs4_access_type_t; + +/* + * Access cache + */ +typedef struct acache4_hash { + struct acache4 *next; + struct acache4 *prev; + krwlock_t lock; +} acache4_hash_t; + +typedef struct acache4 { + struct acache4 *next; /* next and prev must be first */ + struct acache4 *prev; + uint32_t known; + uint32_t allowed; + struct rnode4 *rnode; + cred_t *cred; + struct acache4 *list; + struct acache4_hash *hashq; +} acache4_t; + +/* + * Note on the different buffer sizes in rddir4_cache: + * There seems to be some discrepancy between the intended and actual + * use of entlen and buflen, which does not correspond to the comment below. + * entlen - nfsv2/3 used as both alloc'd size of entries buffer and + * as the actual size of the entries (XXX is this correct?). + * nfsv4 will use it only as the alloc'd size. + * buflen - used for calculations of readahead. + * actlen - added for nfsv4 to serve as the size of the useful + * portion of the entries buffer. That is because in + * nfsv4, the otw entries are converted to system entries, + * and may not be the same size - thus buffer may not be full. + */ +typedef struct rddir4_cache { + lloff_t _cookie; /* cookie used to find this cache entry */ + lloff_t _ncookie; /* cookie used to find the next cache entry */ + char *entries; /* buffer containing dirent entries */ + int eof; /* EOF reached after this request */ + int entlen; /* size of dirent entries in buf */ + int buflen; /* size of the buffer used to store entries */ + int actlen; /* size of the actual entries (nfsv4 only) */ + int flags; /* control flags, see below */ + kcondvar_t cv; /* cv for blocking */ + int error; /* error from RPC operation */ + void *data; /* private data */ +} rddir4_cache; + +#define nfs4_cookie _cookie._f +#define nfs4_ncookie _ncookie._f + +/* + * Shadow vnode, v4 only. + * + * A file's shadow vnode list is protected by its hash bucket lock, + * r_hashq->r_lock. + * + * sv_r_vnode is protected by the appropriate vnode locks. + * + * sv_dfh, sv_name, sv_dfileid, and sv_dfileid_valid are protected + * by rp->r_svlock. + */ + +typedef struct insq_link { + void *forw; + void *back; +} insq_link_t; + +typedef struct svnode { + insq_link_t sv_link; /* must be first for insque */ + vnode_t *sv_r_vnode; /* vnode for this shadow */ + nfs4_fname_t *sv_name; /* component name */ + nfs4_sharedfh_t *sv_dfh; /* directory file handle */ +} svnode_t; + +#define sv_forw sv_link.forw +#define sv_back sv_link.back +extern svnode_t *vtosv(vnode_t *); +#define VTOSV(vp) vtosv(vp) +#define SVTOV(svp) (((svp)->sv_r_vnode)) +#define IS_SHADOW(vp, rp) ((vp) != (rp)->r_vnode) + +/* + * The format of the hash bucket used to lookup rnodes from a file handle. + */ +typedef struct r4hashq { + struct rnode4 *r_hashf; + struct rnode4 *r_hashb; + krwlock_t r_lock; +} r4hashq_t; + +/* + * Remote file information structure. + * + * The rnode is the "inode" for remote files. It contains all the + * information necessary to handle remote file on the client side. + * + * Note on file sizes: we keep two file sizes in the rnode: the size + * according to the client (r_size) and the size according to the server + * (r_attr.va_size). They can differ because we modify r_size during a + * write system call (nfs_rdwr), before the write request goes over the + * wire (before the file is actually modified on the server). If an OTW + * request occurs before the cached data is written to the server the file + * size returned from the server (r_attr.va_size) may not match r_size. + * r_size is the one we use, in general. r_attr.va_size is only used to + * determine whether or not our cached data is valid. + * + * Each rnode has 5 locks associated with it (not including the rnode + * hash table and free list locks): + * + * r_rwlock: Serializes nfs_write and nfs_setattr requests + * and allows nfs_read requests to proceed in parallel. + * Serializes reads/updates to directories. + * + * r_lkserlock: Serializes lock requests with map, write, and + * readahead operations. + * + * r_statelock: Protects all fields in the rnode except for + * those listed below. This lock is intented + * to be held for relatively short periods of + * time (not accross entire putpage operations, + * for example). + * + * r_statev4_lock: Protects the created_v4 flag, the lock_owners list, + * and all the delegation fields except r_deleg_list. + * + * r_os_lock: Protects r_open_streams. + * + * + * The following members are protected by the mutex rp4freelist_lock: + * r_freef + * r_freeb + * + * The following members are protected by the hash bucket rwlock: + * r_hashf + * r_hashb + * + * r_fh is read-only except when an rnode is created (or recycled from the + * free list). + * + * The following members are protected by nfs4_server_t::s_lock: + * r_deleg_list + * + * Note: r_modaddr is only accessed when the r_statelock mutex is held. + * Its value is also controlled via r_rwlock. It is assumed that + * there will be only 1 writer active at a time, so it safe to + * set r_modaddr and release r_statelock as long as the r_rwlock + * writer lock is held. + * + * r_inmap informs nfs4_read()/write() that there is a call to nfs4_map() + * in progress. nfs4_read()/write() check r_inmap to decide whether + * to perform directio on the file or not. r_inmap is atomically + * incremented in nfs4_map() before the address space routines are + * called and atomically decremented just before nfs4_map() exits. + * r_inmap is not protected by any lock. + * + * r_mapcnt tells that the rnode has mapped pages. r_inmap can be 0 + * while the rnode has mapped pages. + * + * 64-bit offsets: the code formerly assumed that atomic reads of + * r_size were safe and reliable; on 32-bit architectures, this is + * not true since an intervening bus cycle from another processor + * could update half of the size field. The r_statelock must now + * be held whenever any kind of access of r_size is made. + * + * Lock ordering: + * r_rwlock > r_lkserlock > r_os_lock > r_statelock > r_statev4_lock + * vnode_t::v_lock > r_os_lock + */ +struct exportinfo; /* defined in nfs/export.h */ +struct servinfo4; /* defined in nfs/nfs4_clnt.h */ +struct failinfo; /* defined in nfs/nfs_clnt.h */ +struct mntinfo4; /* defined in nfs/nfs4_clnt.h */ + +typedef struct rnode4 { + /* the hash fields must be first to match the rhashq_t */ + struct rnode4 *r_hashf; /* hash queue forward pointer */ + struct rnode4 *r_hashb; /* hash queue back pointer */ + struct rnode4 *r_freef; /* free list forward pointer */ + struct rnode4 *r_freeb; /* free list back pointer */ + r4hashq_t *r_hashq; /* pointer to the hash bucket */ + + svnode_t r_svnode; /* "master" shadow vnode for file */ + kmutex_t r_svlock; /* serializes access to svnode list */ + nfs_rwlock_t r_rwlock; /* serializes write/setattr requests */ + nfs_rwlock_t r_lkserlock; /* serialize lock with other ops */ + kmutex_t r_statelock; /* protects (most of) rnode contents */ + nfs4_sharedfh_t *r_fh; /* file handle */ + struct servinfo4 + *r_server; /* current server */ + u_offset_t r_nextr; /* next byte read offset (read-ahead) */ + uint_t r_flags; /* flags, see below */ + short r_error; /* async write error */ + cred_t *r_unlcred; /* unlinked credentials */ + char *r_unlname; /* unlinked file name */ + vnode_t *r_unldvp; /* parent dir of unlinked file */ + vnode_t *r_xattr_dir; /* cached xattr dir vnode */ + len_t r_size; /* client's view of file size */ + vattr_t r_attr; /* cached vnode attributes */ + hrtime_t r_time_attr_saved; /* time attributes were cached */ + hrtime_t r_time_attr_inval; /* time attributes become invalid */ + hrtime_t r_time_cache_inval; /* time caches become invalid */ + time_t r_delay_wait; /* future time for DELAY handling */ + int r_delay_interval; /* Number of Secs of last DELAY */ + time_t r_last_recov; /* time of last recovery operation */ + nfs4_recov_t r_recov_act; /* action from last recovery op */ + long r_mapcnt; /* count of mmapped pages */ + uint_t r_count; /* # of refs not reflect in v_count */ + uint_t r_awcount; /* # of outstanding async write */ + uint_t r_gcount; /* getattrs waiting to flush pages */ + kcondvar_t r_cv; /* condvar for blocked threads */ + int (*r_putapage) /* address of putapage routine */ + (vnode_t *, page_t *, u_offset_t *, size_t *, int, cred_t *); + void *r_dir; /* cache of readdir responses */ + rddir4_cache *r_direof; /* pointer to the EOF entry */ + symlink_cache r_symlink; /* cached readlink response */ + verifier4 r_writeverf; /* file data write verifier */ + u_offset_t r_modaddr; /* address for page in writerp */ + commit_t r_commit; /* commit information */ + u_offset_t r_truncaddr; /* base for truncate operation */ + vsecattr_t *r_secattr; /* cached security attributes (acls) */ + verifier4 r_cookieverf4; /* version 4 readdir cookie verifier */ + nfs4_pathconf_info_t r_pathconf; /* cached pathconf info */ + acache4_t *r_acache; /* list of access cache entries */ + list_t r_open_streams; /* open streams list */ + kmutex_t r_os_lock; /* protects r_open_streams */ + nfs4_lock_owner_t + r_lo_head; /* lock owners list head */ + int created_v4; /* 1 if file has been created in v4 */ + kmutex_t r_statev4_lock; /* protects created_v4, state4ptr */ + + list_node_t r_deleg_link; /* linkage into list of */ + /* delegated rnodes for this server */ + open_delegation_type4 + r_deleg_type; /* type of delegation granted */ + stateid4 r_deleg_stateid; + /* delegation state id */ + nfs_space_limit4 + r_deleg_limit; /* file limits returned from */ + /* server on delegated open */ + nfsace4 r_deleg_perms; /* file permissions returned from */ + /* server on delegated open */ + fattr4_change r_deleg_change; /* current deleg change attr */ + fattr4_change r_deleg_change_grant; + /* change @ write deleg grant */ + cred_t *r_deleg_cred; /* credential in force when the */ + /* delegation was granted */ + open_delegation_type4 + r_deleg_needs_recovery; + /* delegation needs recovery */ + /* This contains the delegation type */ + /* for use with CLAIM_PREVIOUS. */ + /* OPEN_DELEGATE_NONE means recovery */ + /* is not needed. */ + unsigned r_deleg_needs_recall:1; + /* delegation has been recalled by */ + /* the server during open with */ + /* CLAIM_PREVIOUS */ + unsigned r_deleg_return_pending:1; + /* delegreturn is pending, don't use */ + /* the delegation stateid, set in */ + /* nfs4_dlistadd */ + unsigned r_deleg_return_inprog:1; + /* delegreturn is in progress, may */ + /* only be set by nfs4delegreturn. */ + nfs_rwlock_t r_deleg_recall_lock; + /* lock for synchronizing delegreturn */ + /* with in other operations, acquired */ + /* in read mode by nfs4_start_fop, */ + /* acquired in write mode in */ + /* nfs4delegreturn */ + fattr4_change r_change; /* GETATTR4 change attr; client */ + /* should always request change */ + /* when c/mtime requested to keep */ + /* change and c/mtime in sync */ + fattr4_fileid r_mntd_fid; /* mounted on fileid attr */ + kthread_t *r_serial; /* attrcache validation thread */ + kthread_t *r_pgflush; /* thread flushing page cache */ + list_t r_indelmap; /* list of delmap callers */ + fattr4_fsid r_srv_fsid; /* fsid of srv fs containing object */ + /* when rnode created; compare with */ + /* sv_fsid (servinfo4_t) to see why */ + /* stub type was set */ + nfs4_stub_type_t r_stub_type; + /* e.g. mirror-mount or referral */ + uint_t r_inmap; /* to serialize read/write and mmap */ + list_node_t r_mi_link; /* linkage into list of rnodes for */ + /* this mntinfo */ +} rnode4_t; + +#define r_vnode r_svnode.sv_r_vnode + +/* + * Flags + */ +#define R4READDIRWATTR 0x1 /* Use READDIR with attributes */ +#define R4DIRTY 0x2 /* dirty pages from write operation */ +#define R4STALE 0x4 /* stale, don't even attempt to write */ +#define R4MODINPROGRESS 0x8 /* page modification happening */ +#define R4TRUNCATE 0x10 /* truncating, don't commit */ +#define R4HAVEVERF 0x20 /* have a write verifier to compare against */ +#define R4COMMIT 0x40 /* commit in progress */ +#define R4COMMITWAIT 0x80 /* someone is waiting to do a commit */ +#define R4HASHED 0x100 /* rnode is in hash queues */ +#define R4OUTOFSPACE 0x200 /* an out of space error has happened */ +#define R4LODANGLERS 0x400 /* rnode has dangling lock_owners to cleanup */ +#define R4WRITEMODIFIED 0x800 /* file data has been modified by write */ +#define R4DIRECTIO 0x1000 /* bypass the buffer cache */ +#define R4RECOVERR 0x2000 /* couldn't recover */ +#define R4RECEXPFH 0x4000 /* recovering expired filehandle */ +#define R4RECOVERRP 0x8000 /* R4RECOVERR pending, but not set (yet) */ +#define R4ISXATTR 0x20000 /* rnode is a named attribute */ +#define R4DELMAPLIST 0x40000 /* delmap callers tracked for as callback */ +#define R4PGFLUSH 0x80000 /* page flush thread active */ +#define R4INCACHEPURGE 0x100000 /* purging caches due to file size change */ +#define R4LOOKUP 0x200000 /* a lookup has been done in the directory */ +/* + * Convert between vnode and rnode + */ +#define RTOV4(rp) ((rp)->r_vnode) +#define VTOR4(vp) ((rnode4_t *)((vp)->v_data)) + +#define RP_ISSTUB(rp) (((rp)->r_stub_type != NFS4_STUB_NONE)) +#define RP_ISSTUB_MIRRORMOUNT(rp) ((rp)->r_stub_type == NFS4_STUB_MIRRORMOUNT) +#define RP_ISSTUB_REFERRAL(rp) ((rp)->r_stub_type == NFS4_STUB_REFERRAL) + +/* + * Open file instances. + */ + +typedef struct nfs4_opinst { + struct nfs4_opinst *re_next; /* next in list */ + vnode_t *re_vp; /* held reference */ + uint32_t re_numosp; /* number of valid open streams */ + nfs4_open_stream_t **re_osp; /* held reference */ +} nfs4_opinst_t; + +#ifdef _KERNEL + +extern long nrnode; + +/* Used for r_delay_interval */ +#define NFS4_INITIAL_DELAY_INTERVAL 1 +#define NFS4_MAX_DELAY_INTERVAL 20 + +extern rnode4_t *r4find(r4hashq_t *, nfs4_sharedfh_t *, struct vfs *); +extern rnode4_t *r4find_unlocked(nfs4_sharedfh_t *, struct vfs *); +extern void r4flush(struct vfs *, cred_t *); +extern void destroy_rtable4(struct vfs *, cred_t *); +extern int check_rtable4(struct vfs *); +extern void rp4_addfree(rnode4_t *, cred_t *); +extern void rp4_addhash(rnode4_t *); +extern void rp4_rmhash(rnode4_t *); +extern void rp4_rmhash_locked(rnode4_t *); +extern int rtable4hash(nfs4_sharedfh_t *); + +extern vnode_t *makenfs4node(nfs4_sharedfh_t *, nfs4_ga_res_t *, struct vfs *, + hrtime_t, cred_t *, vnode_t *, nfs4_fname_t *); +extern vnode_t *makenfs4node_by_fh(nfs4_sharedfh_t *, nfs4_sharedfh_t *, + nfs4_fname_t **, nfs4_ga_res_t *, mntinfo4_t *, cred_t *, hrtime_t); + +extern nfs4_opinst_t *r4mkopenlist(struct mntinfo4 *); +extern void r4releopenlist(nfs4_opinst_t *); +extern int r4find_by_fsid(mntinfo4_t *, fattr4_fsid *); + +/* Access cache calls */ +extern nfs4_access_type_t nfs4_access_check(rnode4_t *, uint32_t, cred_t *); +extern void nfs4_access_cache(rnode4_t *rp, uint32_t, uint32_t, cred_t *); +extern int nfs4_access_purge_rp(rnode4_t *); + +extern int nfs4_free_data_reclaim(rnode4_t *); +extern void nfs4_rnode_invalidate(struct vfs *); + +extern time_t r2lease_time(rnode4_t *); +extern int nfs4_directio(vnode_t *, int, cred_t *); + +/* shadow vnode functions */ +extern void sv_activate(vnode_t **, vnode_t *, nfs4_fname_t **, int); +extern vnode_t *sv_find(vnode_t *, vnode_t *, nfs4_fname_t **); +extern void sv_update_path(vnode_t *, char *, char *); +extern void sv_inactive(vnode_t *); +extern void sv_exchange(vnode_t **); +extern void sv_uninit(svnode_t *); +extern void nfs4_clear_open_streams(rnode4_t *); + +/* + * Mark cached attributes as timed out + * + * The caller must not be holding the rnode r_statelock mutex. + */ +#define PURGE_ATTRCACHE4_LOCKED(rp) { \ + rp->r_time_attr_inval = gethrtime(); \ + rp->r_time_attr_saved = rp->r_time_attr_inval; \ + rp->r_pathconf.pc4_xattr_valid = 0; \ + rp->r_pathconf.pc4_cache_valid = 0; \ +} + +#define PURGE_ATTRCACHE4(vp) { \ + rnode4_t *rp = VTOR4(vp); \ + mutex_enter(&rp->r_statelock); \ + PURGE_ATTRCACHE4_LOCKED(rp); \ + mutex_exit(&rp->r_statelock); \ +} + + +extern void nfs4_async_readdir(vnode_t *, rddir4_cache *, + cred_t *, int (*)(vnode_t *, rddir4_cache *, cred_t *)); +extern char *rnode4info(rnode4_t *rp); + +extern int writerp4(rnode4_t *, caddr_t, int, struct uio *, int); +extern void nfs4_set_nonvattrs(rnode4_t *, struct nfs4attr_to_vattr *); +extern void nfs4delegabandon(rnode4_t *); +extern stateid4 nfs4_get_w_stateid(cred_t *, rnode4_t *, pid_t, mntinfo4_t *, + nfs_opnum4, nfs4_stateid_types_t *); +extern stateid4 nfs4_get_stateid(cred_t *, rnode4_t *, pid_t, mntinfo4_t *, + nfs_opnum4, nfs4_stateid_types_t *, bool_t); +extern nfsstat4 nfs4_find_or_create_lock_owner(pid_t, rnode4_t *, cred_t *, + nfs4_open_owner_t **, nfs4_open_stream_t **, + nfs4_lock_owner_t **); +extern cred_t *nfs4_get_otw_cred_by_osp(rnode4_t *, cred_t *, + nfs4_open_stream_t **, bool_t *, bool_t *); + + +/* + * Defines for the flag argument of nfs4delegreturn + */ +#define NFS4_DR_FORCE 0x1 /* discard even if start_op fails */ +#define NFS4_DR_PUSH 0x2 /* push modified data back to the server */ +#define NFS4_DR_DISCARD 0x4 /* discard the delegation w/o delegreturn */ +#define NFS4_DR_DID_OP 0x8 /* calling function did nfs4_start_op */ +#define NFS4_DR_RECALL 0x10 /* delegreturn done in response to CB_RECALL */ +#define NFS4_DR_REOPEN 0x20 /* perform file reopens, if applicable */ + +extern int nfs4delegreturn(rnode4_t *, int); +extern void nfs4_delegreturn_all(nfs4_server_t *); +extern void nfs4delegreturn_cleanup(rnode4_t *, nfs4_server_t *); +extern void nfs4_delegation_accept(rnode4_t *, open_claim_type4, OPEN4res *, + nfs4_ga_res_t *, cred_t *); + +extern void nfs4_dlistclean(void); +extern void nfs4_deleg_discard(mntinfo4_t *, nfs4_server_t *); + +extern void rddir4_cache_create(rnode4_t *); +extern void rddir4_cache_purge(rnode4_t *); +extern void rddir4_cache_destroy(rnode4_t *); +extern rddir4_cache *rddir4_cache_lookup(rnode4_t *, offset_t, int); +extern void rddir4_cache_rele(rnode4_t *, rddir4_cache *); + +extern void r4_stub_mirrormount(rnode4_t *); +extern void r4_stub_referral(rnode4_t *); +extern void r4_stub_none(rnode4_t *); + +#ifdef DEBUG +extern char *rddir4_cache_buf_alloc(size_t, int); +extern void rddir4_cache_buf_free(void *, size_t); +#endif + + + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NFS_RNODE4_H */ diff --git a/illumos-x86_64/usr/include/nghttp2/nghttp2.h b/illumos-x86_64/usr/include/nghttp2/nghttp2.h new file mode 100644 index 00000000..19c1874f --- /dev/null +++ b/illumos-x86_64/usr/include/nghttp2/nghttp2.h @@ -0,0 +1,6878 @@ +/* + * nghttp2 - HTTP/2 C Library + * + * Copyright (c) 2013, 2014 Tatsuhiro Tsujikawa + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef NGHTTP2_H +#define NGHTTP2_H + +/* Define WIN32 when build target is Win32 API (borrowed from + libcurl) */ +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif + +/* Compatibility for non-Clang compilers */ +#ifndef __has_declspec_attribute +# define __has_declspec_attribute(x) 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#if defined(_MSC_VER) && (_MSC_VER < 1800) +/* MSVC < 2013 does not have inttypes.h because it is not C99 + compliant. See compiler macros and version number in + https://sourceforge.net/p/predef/wiki/Compilers/ */ +# include +#else /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */ +# include +#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */ +#include +#include +#include + +#include + +#ifdef NGHTTP2_STATICLIB +# define NGHTTP2_EXTERN +#elif defined(WIN32) || \ + (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)) +# ifdef BUILDING_NGHTTP2 +# define NGHTTP2_EXTERN __declspec(dllexport) +# else /* !BUILDING_NGHTTP2 */ +# define NGHTTP2_EXTERN __declspec(dllimport) +# endif /* !BUILDING_NGHTTP2 */ +#else /* !defined(WIN32) */ +# ifdef BUILDING_NGHTTP2 +# define NGHTTP2_EXTERN __attribute__((visibility("default"))) +# else /* !BUILDING_NGHTTP2 */ +# define NGHTTP2_EXTERN +# endif /* !BUILDING_NGHTTP2 */ +#endif /* !defined(WIN32) */ + +#ifdef BUILDING_NGHTTP2 +# undef NGHTTP2_NO_SSIZE_T +#endif /* BUILDING_NGHTTP2 */ + +/** + * @typedef + * + * :type:`nghttp2_ssize` is a signed counterpart of size_t. + */ +typedef ptrdiff_t nghttp2_ssize; + +/** + * @macro + * + * The protocol version identification string of this library + * supports. This identifier is used if HTTP/2 is used over TLS. + */ +#define NGHTTP2_PROTO_VERSION_ID "h2" +/** + * @macro + * + * The length of :macro:`NGHTTP2_PROTO_VERSION_ID`. + */ +#define NGHTTP2_PROTO_VERSION_ID_LEN 2 + +/** + * @macro + * + * The serialized form of ALPN protocol identifier this library + * supports. Notice that first byte is the length of following + * protocol identifier. This is the same wire format of `TLS ALPN + * extension `_. This is useful + * to process incoming ALPN tokens in wire format. + */ +#define NGHTTP2_PROTO_ALPN "\x2h2" + +/** + * @macro + * + * The length of :macro:`NGHTTP2_PROTO_ALPN`. + */ +#define NGHTTP2_PROTO_ALPN_LEN (sizeof(NGHTTP2_PROTO_ALPN) - 1) + +/** + * @macro + * + * The protocol version identification string of this library + * supports. This identifier is used if HTTP/2 is used over cleartext + * TCP. + */ +#define NGHTTP2_CLEARTEXT_PROTO_VERSION_ID "h2c" + +/** + * @macro + * + * The length of :macro:`NGHTTP2_CLEARTEXT_PROTO_VERSION_ID`. + */ +#define NGHTTP2_CLEARTEXT_PROTO_VERSION_ID_LEN 3 + +struct nghttp2_session; +/** + * @struct + * + * The primary structure to hold the resources needed for a HTTP/2 + * session. The details of this structure are intentionally hidden + * from the public API. + */ +typedef struct nghttp2_session nghttp2_session; + +/** + * @macro + * + * The age of :type:`nghttp2_info` + */ +#define NGHTTP2_VERSION_AGE 1 + +/** + * @struct + * + * This struct is what `nghttp2_version()` returns. It holds + * information about the particular nghttp2 version. + */ +typedef struct { + /** + * Age of this struct. This instance of nghttp2 sets it to + * :macro:`NGHTTP2_VERSION_AGE` but a future version may bump it and + * add more struct fields at the bottom + */ + int age; + /** + * the :macro:`NGHTTP2_VERSION_NUM` number (since age ==1) + */ + int version_num; + /** + * points to the :macro:`NGHTTP2_VERSION` string (since age ==1) + */ + const char *version_str; + /** + * points to the :macro:`NGHTTP2_PROTO_VERSION_ID` string this + * instance implements (since age ==1) + */ + const char *proto_str; + /* -------- the above fields all exist when age == 1 */ +} nghttp2_info; + +/** + * @macro + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * The default weight of stream dependency. + */ +#define NGHTTP2_DEFAULT_WEIGHT 16 + +/** + * @macro + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * The maximum weight of stream dependency. + */ +#define NGHTTP2_MAX_WEIGHT 256 + +/** + * @macro + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * The minimum weight of stream dependency. + */ +#define NGHTTP2_MIN_WEIGHT 1 + +/** + * @macro + * + * The maximum window size + */ +#define NGHTTP2_MAX_WINDOW_SIZE ((int32_t)((1U << 31) - 1)) + +/** + * @macro + * + * The initial window size for stream level flow control. + */ +#define NGHTTP2_INITIAL_WINDOW_SIZE ((1 << 16) - 1) +/** + * @macro + * + * The initial window size for connection level flow control. + */ +#define NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE ((1 << 16) - 1) + +/** + * @macro + * + * The default header table size. + */ +#define NGHTTP2_DEFAULT_HEADER_TABLE_SIZE (1 << 12) + +/** + * @macro + * + * The client magic string, which is the first 24 bytes byte string of + * client connection preface. + */ +#define NGHTTP2_CLIENT_MAGIC "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" + +/** + * @macro + * + * The length of :macro:`NGHTTP2_CLIENT_MAGIC`. + */ +#define NGHTTP2_CLIENT_MAGIC_LEN 24 + +/** + * @macro + * + * The default max number of settings per SETTINGS frame + */ +#define NGHTTP2_DEFAULT_MAX_SETTINGS 32 + +/** + * @enum + * + * Error codes used in this library. The code range is [-999, -500], + * inclusive. The following values are defined: + */ +typedef enum { + /** + * Invalid argument passed. + */ + NGHTTP2_ERR_INVALID_ARGUMENT = -501, + /** + * Out of buffer space. + */ + NGHTTP2_ERR_BUFFER_ERROR = -502, + /** + * The specified protocol version is not supported. + */ + NGHTTP2_ERR_UNSUPPORTED_VERSION = -503, + /** + * Used as a return value from :type:`nghttp2_send_callback2`, + * :type:`nghttp2_recv_callback` and + * :type:`nghttp2_send_data_callback` to indicate that the operation + * would block. + */ + NGHTTP2_ERR_WOULDBLOCK = -504, + /** + * General protocol error + */ + NGHTTP2_ERR_PROTO = -505, + /** + * The frame is invalid. + */ + NGHTTP2_ERR_INVALID_FRAME = -506, + /** + * The peer performed a shutdown on the connection. + */ + NGHTTP2_ERR_EOF = -507, + /** + * Used as a return value from + * :func:`nghttp2_data_source_read_callback2` to indicate that data + * transfer is postponed. See + * :func:`nghttp2_data_source_read_callback2` for details. + */ + NGHTTP2_ERR_DEFERRED = -508, + /** + * Stream ID has reached the maximum value. Therefore no stream ID + * is available. + */ + NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE = -509, + /** + * The stream is already closed; or the stream ID is invalid. + */ + NGHTTP2_ERR_STREAM_CLOSED = -510, + /** + * RST_STREAM has been added to the outbound queue. The stream is + * in closing state. + */ + NGHTTP2_ERR_STREAM_CLOSING = -511, + /** + * The transmission is not allowed for this stream (e.g., a frame + * with END_STREAM flag set has already sent). + */ + NGHTTP2_ERR_STREAM_SHUT_WR = -512, + /** + * The stream ID is invalid. + */ + NGHTTP2_ERR_INVALID_STREAM_ID = -513, + /** + * The state of the stream is not valid (e.g., DATA cannot be sent + * to the stream if response HEADERS has not been sent). + */ + NGHTTP2_ERR_INVALID_STREAM_STATE = -514, + /** + * Another DATA frame has already been deferred. + */ + NGHTTP2_ERR_DEFERRED_DATA_EXIST = -515, + /** + * Starting new stream is not allowed (e.g., GOAWAY has been sent + * and/or received). + */ + NGHTTP2_ERR_START_STREAM_NOT_ALLOWED = -516, + /** + * GOAWAY has already been sent. + */ + NGHTTP2_ERR_GOAWAY_ALREADY_SENT = -517, + /** + * The received frame contains the invalid header block (e.g., There + * are duplicate header names; or the header names are not encoded + * in US-ASCII character set and not lower cased; or the header name + * is zero-length string; or the header value contains multiple + * in-sequence NUL bytes). + */ + NGHTTP2_ERR_INVALID_HEADER_BLOCK = -518, + /** + * Indicates that the context is not suitable to perform the + * requested operation. + */ + NGHTTP2_ERR_INVALID_STATE = -519, + /** + * The user callback function failed due to the temporal error. + */ + NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE = -521, + /** + * The length of the frame is invalid, either too large or too small. + */ + NGHTTP2_ERR_FRAME_SIZE_ERROR = -522, + /** + * Header block inflate/deflate error. + */ + NGHTTP2_ERR_HEADER_COMP = -523, + /** + * Flow control error + */ + NGHTTP2_ERR_FLOW_CONTROL = -524, + /** + * Insufficient buffer size given to function. + */ + NGHTTP2_ERR_INSUFF_BUFSIZE = -525, + /** + * Callback was paused by the application + */ + NGHTTP2_ERR_PAUSE = -526, + /** + * There are too many in-flight SETTING frame and no more + * transmission of SETTINGS is allowed. + */ + NGHTTP2_ERR_TOO_MANY_INFLIGHT_SETTINGS = -527, + /** + * The server push is disabled. + */ + NGHTTP2_ERR_PUSH_DISABLED = -528, + /** + * DATA or HEADERS frame for a given stream has been already + * submitted and has not been fully processed yet. Application + * should wait for the transmission of the previously submitted + * frame before submitting another. + */ + NGHTTP2_ERR_DATA_EXIST = -529, + /** + * The current session is closing due to a connection error or + * `nghttp2_session_terminate_session()` is called. + */ + NGHTTP2_ERR_SESSION_CLOSING = -530, + /** + * Invalid HTTP header field was received and stream is going to be + * closed. + */ + NGHTTP2_ERR_HTTP_HEADER = -531, + /** + * Violation in HTTP messaging rule. + */ + NGHTTP2_ERR_HTTP_MESSAGING = -532, + /** + * Stream was refused. + */ + NGHTTP2_ERR_REFUSED_STREAM = -533, + /** + * Unexpected internal error, but recovered. + */ + NGHTTP2_ERR_INTERNAL = -534, + /** + * Indicates that a processing was canceled. + */ + NGHTTP2_ERR_CANCEL = -535, + /** + * When a local endpoint expects to receive SETTINGS frame, it + * receives an other type of frame. + */ + NGHTTP2_ERR_SETTINGS_EXPECTED = -536, + /** + * When a local endpoint receives too many settings entries + * in a single SETTINGS frame. + */ + NGHTTP2_ERR_TOO_MANY_SETTINGS = -537, + /** + * The errors < :enum:`nghttp2_error.NGHTTP2_ERR_FATAL` mean that + * the library is under unexpected condition and processing was + * terminated (e.g., out of memory). If application receives this + * error code, it must stop using that :type:`nghttp2_session` + * object and only allowed operation for that object is deallocate + * it using `nghttp2_session_del()`. + */ + NGHTTP2_ERR_FATAL = -900, + /** + * Out of memory. This is a fatal error. + */ + NGHTTP2_ERR_NOMEM = -901, + /** + * The user callback function failed. This is a fatal error. + */ + NGHTTP2_ERR_CALLBACK_FAILURE = -902, + /** + * Invalid client magic (see :macro:`NGHTTP2_CLIENT_MAGIC`) was + * received and further processing is not possible. + */ + NGHTTP2_ERR_BAD_CLIENT_MAGIC = -903, + /** + * Possible flooding by peer was detected in this HTTP/2 session. + * Flooding is measured by how many PING and SETTINGS frames with + * ACK flag set are queued for transmission. These frames are + * response for the peer initiated frames, and peer can cause memory + * exhaustion on server side to send these frames forever and does + * not read network. + */ + NGHTTP2_ERR_FLOODED = -904, + /** + * When a local endpoint receives too many CONTINUATION frames + * following a HEADER frame. + */ + NGHTTP2_ERR_TOO_MANY_CONTINUATIONS = -905, +} nghttp2_error; + +/** + * @struct + * + * The object representing single contiguous buffer. + */ +typedef struct { + /** + * The pointer to the buffer. + */ + uint8_t *base; + /** + * The length of the buffer. + */ + size_t len; +} nghttp2_vec; + +struct nghttp2_rcbuf; + +/** + * @struct + * + * The object representing reference counted buffer. The details of + * this structure are intentionally hidden from the public API. + */ +typedef struct nghttp2_rcbuf nghttp2_rcbuf; + +/** + * @function + * + * Increments the reference count of |rcbuf| by 1. + */ +NGHTTP2_EXTERN void nghttp2_rcbuf_incref(nghttp2_rcbuf *rcbuf); + +/** + * @function + * + * Decrements the reference count of |rcbuf| by 1. If the reference + * count becomes zero, the object pointed by |rcbuf| will be freed. + * In this case, application must not use |rcbuf| again. + */ +NGHTTP2_EXTERN void nghttp2_rcbuf_decref(nghttp2_rcbuf *rcbuf); + +/** + * @function + * + * Returns the underlying buffer managed by |rcbuf|. + */ +NGHTTP2_EXTERN nghttp2_vec nghttp2_rcbuf_get_buf(nghttp2_rcbuf *rcbuf); + +/** + * @function + * + * Returns nonzero if the underlying buffer is statically allocated, + * and 0 otherwise. This can be useful for language bindings that wish + * to avoid creating duplicate strings for these buffers. + */ +NGHTTP2_EXTERN int nghttp2_rcbuf_is_static(const nghttp2_rcbuf *rcbuf); + +/** + * @enum + * + * The flags for header field name/value pair. + */ +typedef enum { + /** + * No flag set. + */ + NGHTTP2_NV_FLAG_NONE = 0, + /** + * Indicates that this name/value pair must not be indexed ("Literal + * Header Field never Indexed" representation must be used in HPACK + * encoding). Other implementation calls this bit as "sensitive". + */ + NGHTTP2_NV_FLAG_NO_INDEX = 0x01, + /** + * This flag is set solely by application. If this flag is set, the + * library does not make a copy of header field name. This could + * improve performance. + */ + NGHTTP2_NV_FLAG_NO_COPY_NAME = 0x02, + /** + * This flag is set solely by application. If this flag is set, the + * library does not make a copy of header field value. This could + * improve performance. + */ + NGHTTP2_NV_FLAG_NO_COPY_VALUE = 0x04 +} nghttp2_nv_flag; + +/** + * @struct + * + * The name/value pair, which mainly used to represent header fields. + */ +typedef struct { + /** + * The |name| byte string. If this struct is presented from library + * (e.g., :type:`nghttp2_on_frame_recv_callback`), |name| is + * guaranteed to be NULL-terminated. For some callbacks + * (:type:`nghttp2_before_frame_send_callback`, + * :type:`nghttp2_on_frame_send_callback`, and + * :type:`nghttp2_on_frame_not_send_callback`), it may not be + * NULL-terminated if header field is passed from application with + * the flag :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`). + * When application is constructing this struct, |name| is not + * required to be NULL-terminated. + */ + uint8_t *name; + /** + * The |value| byte string. If this struct is presented from + * library (e.g., :type:`nghttp2_on_frame_recv_callback`), |value| + * is guaranteed to be NULL-terminated. For some callbacks + * (:type:`nghttp2_before_frame_send_callback`, + * :type:`nghttp2_on_frame_send_callback`, and + * :type:`nghttp2_on_frame_not_send_callback`), it may not be + * NULL-terminated if header field is passed from application with + * the flag :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE`). + * When application is constructing this struct, |value| is not + * required to be NULL-terminated. + */ + uint8_t *value; + /** + * The length of the |name|, excluding terminating NULL. + */ + size_t namelen; + /** + * The length of the |value|, excluding terminating NULL. + */ + size_t valuelen; + /** + * Bitwise OR of one or more of :type:`nghttp2_nv_flag`. + */ + uint8_t flags; +} nghttp2_nv; + +/** + * @enum + * + * The frame types in HTTP/2 specification. + */ +typedef enum { + /** + * The DATA frame. + */ + NGHTTP2_DATA = 0, + /** + * The HEADERS frame. + */ + NGHTTP2_HEADERS = 0x01, + /** + * The PRIORITY frame. + */ + NGHTTP2_PRIORITY = 0x02, + /** + * The RST_STREAM frame. + */ + NGHTTP2_RST_STREAM = 0x03, + /** + * The SETTINGS frame. + */ + NGHTTP2_SETTINGS = 0x04, + /** + * The PUSH_PROMISE frame. + */ + NGHTTP2_PUSH_PROMISE = 0x05, + /** + * The PING frame. + */ + NGHTTP2_PING = 0x06, + /** + * The GOAWAY frame. + */ + NGHTTP2_GOAWAY = 0x07, + /** + * The WINDOW_UPDATE frame. + */ + NGHTTP2_WINDOW_UPDATE = 0x08, + /** + * The CONTINUATION frame. This frame type won't be passed to any + * callbacks because the library processes this frame type and its + * preceding HEADERS/PUSH_PROMISE as a single frame. + */ + NGHTTP2_CONTINUATION = 0x09, + /** + * The ALTSVC frame, which is defined in `RFC 7383 + * `_. + */ + NGHTTP2_ALTSVC = 0x0a, + /** + * The ORIGIN frame, which is defined by `RFC 8336 + * `_. + */ + NGHTTP2_ORIGIN = 0x0c, + /** + * The PRIORITY_UPDATE frame, which is defined by :rfc:`9218`. + */ + NGHTTP2_PRIORITY_UPDATE = 0x10 +} nghttp2_frame_type; + +/** + * @enum + * + * The flags for HTTP/2 frames. This enum defines all flags for all + * frames. + */ +typedef enum { + /** + * No flag set. + */ + NGHTTP2_FLAG_NONE = 0, + /** + * The END_STREAM flag. + */ + NGHTTP2_FLAG_END_STREAM = 0x01, + /** + * The END_HEADERS flag. + */ + NGHTTP2_FLAG_END_HEADERS = 0x04, + /** + * The ACK flag. + */ + NGHTTP2_FLAG_ACK = 0x01, + /** + * The PADDED flag. + */ + NGHTTP2_FLAG_PADDED = 0x08, + /** + * The PRIORITY flag. + */ + NGHTTP2_FLAG_PRIORITY = 0x20 +} nghttp2_flag; + +/** + * @enum + * The SETTINGS ID. + */ +typedef enum { + /** + * SETTINGS_HEADER_TABLE_SIZE + */ + NGHTTP2_SETTINGS_HEADER_TABLE_SIZE = 0x01, + /** + * SETTINGS_ENABLE_PUSH + */ + NGHTTP2_SETTINGS_ENABLE_PUSH = 0x02, + /** + * SETTINGS_MAX_CONCURRENT_STREAMS + */ + NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS = 0x03, + /** + * SETTINGS_INITIAL_WINDOW_SIZE + */ + NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE = 0x04, + /** + * SETTINGS_MAX_FRAME_SIZE + */ + NGHTTP2_SETTINGS_MAX_FRAME_SIZE = 0x05, + /** + * SETTINGS_MAX_HEADER_LIST_SIZE + */ + NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 0x06, + /** + * SETTINGS_ENABLE_CONNECT_PROTOCOL + * (`RFC 8441 `_) + */ + NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08, + /** + * SETTINGS_NO_RFC7540_PRIORITIES (:rfc:`9218`) + */ + NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES = 0x09 +} nghttp2_settings_id; +/* Note: If we add SETTINGS, update the capacity of + NGHTTP2_INBOUND_NUM_IV as well */ + +/** + * @macro + * + * .. warning:: + * + * Deprecated. The initial max concurrent streams is 0xffffffffu. + * + * Default maximum number of incoming concurrent streams. Use + * `nghttp2_submit_settings()` with + * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS` + * to change the maximum number of incoming concurrent streams. + * + * .. note:: + * + * The maximum number of outgoing concurrent streams is 100 by + * default. + */ +#define NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1) + +/** + * @enum + * The status codes for the RST_STREAM and GOAWAY frames. + */ +typedef enum { + /** + * No errors. + */ + NGHTTP2_NO_ERROR = 0x00, + /** + * PROTOCOL_ERROR + */ + NGHTTP2_PROTOCOL_ERROR = 0x01, + /** + * INTERNAL_ERROR + */ + NGHTTP2_INTERNAL_ERROR = 0x02, + /** + * FLOW_CONTROL_ERROR + */ + NGHTTP2_FLOW_CONTROL_ERROR = 0x03, + /** + * SETTINGS_TIMEOUT + */ + NGHTTP2_SETTINGS_TIMEOUT = 0x04, + /** + * STREAM_CLOSED + */ + NGHTTP2_STREAM_CLOSED = 0x05, + /** + * FRAME_SIZE_ERROR + */ + NGHTTP2_FRAME_SIZE_ERROR = 0x06, + /** + * REFUSED_STREAM + */ + NGHTTP2_REFUSED_STREAM = 0x07, + /** + * CANCEL + */ + NGHTTP2_CANCEL = 0x08, + /** + * COMPRESSION_ERROR + */ + NGHTTP2_COMPRESSION_ERROR = 0x09, + /** + * CONNECT_ERROR + */ + NGHTTP2_CONNECT_ERROR = 0x0a, + /** + * ENHANCE_YOUR_CALM + */ + NGHTTP2_ENHANCE_YOUR_CALM = 0x0b, + /** + * INADEQUATE_SECURITY + */ + NGHTTP2_INADEQUATE_SECURITY = 0x0c, + /** + * HTTP_1_1_REQUIRED + */ + NGHTTP2_HTTP_1_1_REQUIRED = 0x0d +} nghttp2_error_code; + +/** + * @struct + * The frame header. + */ +typedef struct { + /** + * The length field of this frame, excluding frame header. + */ + size_t length; + /** + * The stream identifier (aka, stream ID) + */ + int32_t stream_id; + /** + * The type of this frame. See `nghttp2_frame_type`. + */ + uint8_t type; + /** + * The flags. + */ + uint8_t flags; + /** + * Reserved bit in frame header. Currently, this is always set to 0 + * and application should not expect something useful in here. + */ + uint8_t reserved; +} nghttp2_frame_hd; + +/** + * @union + * + * This union represents the some kind of data source passed to + * :type:`nghttp2_data_source_read_callback2`. + */ +typedef union { + /** + * The integer field, suitable for a file descriptor. + */ + int fd; + /** + * The pointer to an arbitrary object. + */ + void *ptr; +} nghttp2_data_source; + +/** + * @enum + * + * The flags used to set in |data_flags| output parameter in + * :type:`nghttp2_data_source_read_callback2`. + */ +typedef enum { + /** + * No flag set. + */ + NGHTTP2_DATA_FLAG_NONE = 0, + /** + * Indicates EOF was sensed. + */ + NGHTTP2_DATA_FLAG_EOF = 0x01, + /** + * Indicates that END_STREAM flag must not be set even if + * NGHTTP2_DATA_FLAG_EOF is set. Usually this flag is used to send + * trailer fields with `nghttp2_submit_request2()` or + * `nghttp2_submit_response2()`. + */ + NGHTTP2_DATA_FLAG_NO_END_STREAM = 0x02, + /** + * Indicates that application will send complete DATA frame in + * :type:`nghttp2_send_data_callback`. + */ + NGHTTP2_DATA_FLAG_NO_COPY = 0x04 +} nghttp2_data_flag; + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @functypedef + * + * .. warning:: + * + * Deprecated. Use :type:`nghttp2_data_source_read_callback2` + * instead. + * + * Callback function invoked when the library wants to read data from + * the |source|. The read data is sent in the stream |stream_id|. + * The implementation of this function must read at most |length| + * bytes of data from |source| (or possibly other places) and store + * them in |buf| and return number of data stored in |buf|. If EOF is + * reached, set :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` flag + * in |*data_flags|. + * + * Sometime it is desirable to avoid copying data into |buf| and let + * application to send data directly. To achieve this, set + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY` to + * |*data_flags| (and possibly other flags, just like when we do + * copy), and return the number of bytes to send without copying data + * into |buf|. The library, seeing + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY`, will invoke + * :type:`nghttp2_send_data_callback`. The application must send + * complete DATA frame in that callback. + * + * If this callback is set by `nghttp2_submit_request()`, + * `nghttp2_submit_response()` or `nghttp2_submit_headers()` and + * `nghttp2_submit_data()` with flag parameter + * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` set, and + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` flag is set to + * |*data_flags|, DATA frame will have END_STREAM flag set. Usually, + * this is expected behaviour and all are fine. One exception is send + * trailer fields. You cannot send trailer fields after sending frame + * with END_STREAM set. To avoid this problem, one can set + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_END_STREAM` along + * with :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` to signal the + * library not to set END_STREAM in DATA frame. Then application can + * use `nghttp2_submit_trailer()` to send trailer fields. + * `nghttp2_submit_trailer()` can be called inside this callback. + * + * If the application wants to postpone DATA frames (e.g., + * asynchronous I/O, or reading data blocks for long time), it is + * achieved by returning :enum:`nghttp2_error.NGHTTP2_ERR_DEFERRED` + * without reading any data in this invocation. The library removes + * DATA frame from the outgoing queue temporarily. To move back + * deferred DATA frame to outgoing queue, call + * `nghttp2_session_resume_data()`. + * + * By default, |length| is limited to 16KiB at maximum. If peer + * allows larger frames, application can enlarge transmission buffer + * size. See :type:`nghttp2_data_source_read_length_callback` for + * more details. + * + * If the application just wants to return from + * `nghttp2_session_send()` or `nghttp2_session_mem_send()` without + * sending anything, return :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE`. + * + * In case of error, there are 2 choices. Returning + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will + * close the stream by issuing RST_STREAM with + * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. If a different + * error code is desirable, use `nghttp2_submit_rst_stream()` with a + * desired error code and then return + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. + * Returning :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will + * signal the entire session failure. + */ +typedef ssize_t (*nghttp2_data_source_read_callback)( + nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t length, + uint32_t *data_flags, nghttp2_data_source *source, void *user_data); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @functypedef + * + * Callback function invoked when the library wants to read data from + * the |source|. The read data is sent in the stream |stream_id|. + * The implementation of this function must read at most |length| + * bytes of data from |source| (or possibly other places) and store + * them in |buf| and return number of data stored in |buf|. If EOF is + * reached, set :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` flag + * in |*data_flags|. + * + * Sometime it is desirable to avoid copying data into |buf| and let + * application to send data directly. To achieve this, set + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY` to + * |*data_flags| (and possibly other flags, just like when we do + * copy), and return the number of bytes to send without copying data + * into |buf|. The library, seeing + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY`, will invoke + * :type:`nghttp2_send_data_callback`. The application must send + * complete DATA frame in that callback. + * + * If this callback is set by `nghttp2_submit_request2()`, + * `nghttp2_submit_response2()` or `nghttp2_submit_headers()` and + * `nghttp2_submit_data2()` with flag parameter + * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` set, and + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` flag is set to + * |*data_flags|, DATA frame will have END_STREAM flag set. Usually, + * this is expected behaviour and all are fine. One exception is send + * trailer fields. You cannot send trailer fields after sending frame + * with END_STREAM set. To avoid this problem, one can set + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_END_STREAM` along + * with :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` to signal the + * library not to set END_STREAM in DATA frame. Then application can + * use `nghttp2_submit_trailer()` to send trailer fields. + * `nghttp2_submit_trailer()` can be called inside this callback. + * + * If the application wants to postpone DATA frames (e.g., + * asynchronous I/O, or reading data blocks for long time), it is + * achieved by returning :enum:`nghttp2_error.NGHTTP2_ERR_DEFERRED` + * without reading any data in this invocation. The library removes + * DATA frame from the outgoing queue temporarily. To move back + * deferred DATA frame to outgoing queue, call + * `nghttp2_session_resume_data()`. + * + * By default, |length| is limited to 16KiB at maximum. If peer + * allows larger frames, application can enlarge transmission buffer + * size. See :type:`nghttp2_data_source_read_length_callback` for + * more details. + * + * If the application just wants to return from + * `nghttp2_session_send()` or `nghttp2_session_mem_send2()` without + * sending anything, return :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE`. + * + * In case of error, there are 2 choices. Returning + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will + * close the stream by issuing RST_STREAM with + * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. If a different + * error code is desirable, use `nghttp2_submit_rst_stream()` with a + * desired error code and then return + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. + * Returning :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will + * signal the entire session failure. + */ +typedef nghttp2_ssize (*nghttp2_data_source_read_callback2)( + nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t length, + uint32_t *data_flags, nghttp2_data_source *source, void *user_data); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @struct + * + * .. warning:: + * + * Deprecated. Use :type:`nghttp2_data_provider2` instead. + * + * This struct represents the data source and the way to read a chunk + * of data from it. + */ +typedef struct { + /** + * The data source. + */ + nghttp2_data_source source; + /** + * The callback function to read a chunk of data from the |source|. + */ + nghttp2_data_source_read_callback read_callback; +} nghttp2_data_provider; + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @struct + * + * This struct represents the data source and the way to read a chunk + * of data from it. + */ +typedef struct { + /** + * The data source. + */ + nghttp2_data_source source; + /** + * The callback function to read a chunk of data from the |source|. + */ + nghttp2_data_source_read_callback2 read_callback; +} nghttp2_data_provider2; + +/** + * @struct + * + * The DATA frame. The received data is delivered via + * :type:`nghttp2_on_data_chunk_recv_callback`. + */ +typedef struct { + nghttp2_frame_hd hd; + /** + * The length of the padding in this frame. This includes PAD_HIGH + * and PAD_LOW. + */ + size_t padlen; +} nghttp2_data; + +/** + * @enum + * + * The category of HEADERS, which indicates the role of the frame. In + * HTTP/2 spec, request, response, push response and other arbitrary + * headers (e.g., trailer fields) are all called just HEADERS. To + * give the application the role of incoming HEADERS frame, we define + * several categories. + */ +typedef enum { + /** + * The HEADERS frame is opening new stream, which is analogous to + * SYN_STREAM in SPDY. + */ + NGHTTP2_HCAT_REQUEST = 0, + /** + * The HEADERS frame is the first response headers, which is + * analogous to SYN_REPLY in SPDY. + */ + NGHTTP2_HCAT_RESPONSE = 1, + /** + * The HEADERS frame is the first headers sent against reserved + * stream. + */ + NGHTTP2_HCAT_PUSH_RESPONSE = 2, + /** + * The HEADERS frame which does not apply for the above categories, + * which is analogous to HEADERS in SPDY. If non-final response + * (e.g., status 1xx) is used, final response HEADERS frame will be + * categorized here. + */ + NGHTTP2_HCAT_HEADERS = 3 +} nghttp2_headers_category; + +/** + * @struct + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * The structure to specify stream dependency. + */ +typedef struct { + /** + * The stream ID of the stream to depend on. Specifying 0 makes + * stream not depend any other stream. + */ + int32_t stream_id; + /** + * The weight of this dependency. + */ + int32_t weight; + /** + * nonzero means exclusive dependency + */ + uint8_t exclusive; +} nghttp2_priority_spec; + +/** + * @struct + * + * The HEADERS frame. It has the following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The length of the padding in this frame. This includes PAD_HIGH + * and PAD_LOW. + */ + size_t padlen; + /** + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * The priority specification + */ + nghttp2_priority_spec pri_spec; + /** + * The name/value pairs. + */ + nghttp2_nv *nva; + /** + * The number of name/value pairs in |nva|. + */ + size_t nvlen; + /** + * The category of this HEADERS frame. + */ + nghttp2_headers_category cat; +} nghttp2_headers; + +/** + * @struct + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * The PRIORITY frame. It has the following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The priority specification. + */ + nghttp2_priority_spec pri_spec; +} nghttp2_priority; + +/** + * @struct + * + * The RST_STREAM frame. It has the following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The error code. See :type:`nghttp2_error_code`. + */ + uint32_t error_code; +} nghttp2_rst_stream; + +/** + * @struct + * + * The SETTINGS ID/Value pair. It has the following members: + */ +typedef struct { + /** + * The SETTINGS ID. See :type:`nghttp2_settings_id`. + */ + int32_t settings_id; + /** + * The value of this entry. + */ + uint32_t value; +} nghttp2_settings_entry; + +/** + * @struct + * + * The SETTINGS frame. It has the following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The number of SETTINGS ID/Value pairs in |iv|. + */ + size_t niv; + /** + * The pointer to the array of SETTINGS ID/Value pair. + */ + nghttp2_settings_entry *iv; +} nghttp2_settings; + +/** + * @struct + * + * The PUSH_PROMISE frame. It has the following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The length of the padding in this frame. This includes PAD_HIGH + * and PAD_LOW. + */ + size_t padlen; + /** + * The name/value pairs. + */ + nghttp2_nv *nva; + /** + * The number of name/value pairs in |nva|. + */ + size_t nvlen; + /** + * The promised stream ID + */ + int32_t promised_stream_id; + /** + * Reserved bit. Currently this is always set to 0 and application + * should not expect something useful in here. + */ + uint8_t reserved; +} nghttp2_push_promise; + +/** + * @struct + * + * The PING frame. It has the following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The opaque data + */ + uint8_t opaque_data[8]; +} nghttp2_ping; + +/** + * @struct + * + * The GOAWAY frame. It has the following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The last stream stream ID. + */ + int32_t last_stream_id; + /** + * The error code. See :type:`nghttp2_error_code`. + */ + uint32_t error_code; + /** + * The additional debug data + */ + uint8_t *opaque_data; + /** + * The length of |opaque_data| member. + */ + size_t opaque_data_len; + /** + * Reserved bit. Currently this is always set to 0 and application + * should not expect something useful in here. + */ + uint8_t reserved; +} nghttp2_goaway; + +/** + * @struct + * + * The WINDOW_UPDATE frame. It has the following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The window size increment. + */ + int32_t window_size_increment; + /** + * Reserved bit. Currently this is always set to 0 and application + * should not expect something useful in here. + */ + uint8_t reserved; +} nghttp2_window_update; + +/** + * @struct + * + * The extension frame. It has following members: + */ +typedef struct { + /** + * The frame header. + */ + nghttp2_frame_hd hd; + /** + * The pointer to extension payload. The exact pointer type is + * determined by hd.type. + * + * Currently, no extension is supported. This is a place holder for + * the future extensions. + */ + void *payload; +} nghttp2_extension; + +/** + * @union + * + * This union includes all frames to pass them to various function + * calls as nghttp2_frame type. The CONTINUATION frame is omitted + * from here because the library deals with it internally. + */ +typedef union { + /** + * The frame header, which is convenient to inspect frame header. + */ + nghttp2_frame_hd hd; + /** + * The DATA frame. + */ + nghttp2_data data; + /** + * The HEADERS frame. + */ + nghttp2_headers headers; + /** + * The PRIORITY frame. + */ + nghttp2_priority priority; + /** + * The RST_STREAM frame. + */ + nghttp2_rst_stream rst_stream; + /** + * The SETTINGS frame. + */ + nghttp2_settings settings; + /** + * The PUSH_PROMISE frame. + */ + nghttp2_push_promise push_promise; + /** + * The PING frame. + */ + nghttp2_ping ping; + /** + * The GOAWAY frame. + */ + nghttp2_goaway goaway; + /** + * The WINDOW_UPDATE frame. + */ + nghttp2_window_update window_update; + /** + * The extension frame. + */ + nghttp2_extension ext; +} nghttp2_frame; + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @functypedef + * + * .. warning:: + * + * Deprecated. Use :type:`nghttp2_send_callback2` instead. + * + * Callback function invoked when |session| wants to send data to the + * remote peer. The implementation of this function must send at most + * |length| bytes of data stored in |data|. The |flags| is currently + * not used and always 0. It must return the number of bytes sent if + * it succeeds. If it cannot send any single byte without blocking, + * it must return :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. For + * other errors, it must return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. The + * |user_data| pointer is the third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * + * This callback is required if the application uses + * `nghttp2_session_send()` to send data to the remote endpoint. If + * the application uses solely `nghttp2_session_mem_send()` instead, + * this callback function is unnecessary. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_send_callback()`. + * + * .. note:: + * + * The |length| may be very small. If that is the case, and + * application disables Nagle algorithm (``TCP_NODELAY``), then just + * writing |data| to the network stack leads to very small packet, + * and it is very inefficient. An application should be responsible + * to buffer up small chunks of data as necessary to avoid this + * situation. + */ +typedef ssize_t (*nghttp2_send_callback)(nghttp2_session *session, + const uint8_t *data, size_t length, + int flags, void *user_data); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @functypedef + * + * Callback function invoked when |session| wants to send data to the + * remote peer. The implementation of this function must send at most + * |length| bytes of data stored in |data|. The |flags| is currently + * not used and always 0. It must return the number of bytes sent if + * it succeeds. If it cannot send any single byte without blocking, + * it must return :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. For + * other errors, it must return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. The + * |user_data| pointer is the third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * + * This callback is required if the application uses + * `nghttp2_session_send()` to send data to the remote endpoint. If + * the application uses solely `nghttp2_session_mem_send2()` instead, + * this callback function is unnecessary. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_send_callback2()`. + * + * .. note:: + * + * The |length| may be very small. If that is the case, and + * application disables Nagle algorithm (``TCP_NODELAY``), then just + * writing |data| to the network stack leads to very small packet, + * and it is very inefficient. An application should be responsible + * to buffer up small chunks of data as necessary to avoid this + * situation. + */ +typedef nghttp2_ssize (*nghttp2_send_callback2)(nghttp2_session *session, + const uint8_t *data, + size_t length, int flags, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked when + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY` is used in + * :type:`nghttp2_data_source_read_callback` to send complete DATA + * frame. + * + * The |frame| is a DATA frame to send. The |framehd| is the + * serialized frame header (9 bytes). The |length| is the length of + * application data to send (this does not include padding). The + * |source| is the same pointer passed to + * :type:`nghttp2_data_source_read_callback`. + * + * The application first must send frame header |framehd| of length 9 + * bytes. If ``frame->data.padlen > 0``, send 1 byte of value + * ``frame->data.padlen - 1``. Then send exactly |length| bytes of + * application data. Finally, if ``frame->data.padlen > 1``, send + * ``frame->data.padlen - 1`` bytes of zero as padding. + * + * The application has to send complete DATA frame in this callback. + * If all data were written successfully, return 0. + * + * If it cannot send any data at all, just return + * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`; the library will call + * this callback with the same parameters later (It is recommended to + * send complete DATA frame at once in this function to deal with + * error; if partial frame data has already sent, it is impossible to + * send another data in that state, and all we can do is tear down + * connection). When data is fully processed, but application wants + * to make `nghttp2_session_mem_send2()` or `nghttp2_session_send()` + * return immediately without processing next frames, return + * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE`. If application decided to + * reset this stream, return + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`, then + * the library will send RST_STREAM with INTERNAL_ERROR as error code. + * The application can also return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`, which will + * result in connection closure. Returning any other value is treated + * as :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned. + */ +typedef int (*nghttp2_send_data_callback)(nghttp2_session *session, + nghttp2_frame *frame, + const uint8_t *framehd, size_t length, + nghttp2_data_source *source, + void *user_data); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @functypedef + * + * .. warning:: + * + * Deprecated. Use :type:`nghttp2_recv_callback2` instead. + * + * Callback function invoked when |session| wants to receive data from + * the remote peer. The implementation of this function must read at + * most |length| bytes of data and store it in |buf|. The |flags| is + * currently not used and always 0. It must return the number of + * bytes written in |buf| if it succeeds. If it cannot read any + * single byte without blocking, it must return + * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. If it gets EOF + * before it reads any single byte, it must return + * :enum:`nghttp2_error.NGHTTP2_ERR_EOF`. For other errors, it must + * return :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * Returning 0 is treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. The |user_data| + * pointer is the third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * + * This callback is required if the application uses + * `nghttp2_session_recv()` to receive data from the remote endpoint. + * If the application uses solely `nghttp2_session_mem_recv()` + * instead, this callback function is unnecessary. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_recv_callback()`. + */ +typedef ssize_t (*nghttp2_recv_callback)(nghttp2_session *session, uint8_t *buf, + size_t length, int flags, + void *user_data); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @functypedef + * + * Callback function invoked when |session| wants to receive data from + * the remote peer. The implementation of this function must read at + * most |length| bytes of data and store it in |buf|. The |flags| is + * currently not used and always 0. It must return the number of + * bytes written in |buf| if it succeeds. If it cannot read any + * single byte without blocking, it must return + * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. If it gets EOF + * before it reads any single byte, it must return + * :enum:`nghttp2_error.NGHTTP2_ERR_EOF`. For other errors, it must + * return :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * Returning 0 is treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. The |user_data| + * pointer is the third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * + * This callback is required if the application uses + * `nghttp2_session_recv()` to receive data from the remote endpoint. + * If the application uses solely `nghttp2_session_mem_recv2()` + * instead, this callback function is unnecessary. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_recv_callback2()`. + */ +typedef nghttp2_ssize (*nghttp2_recv_callback2)(nghttp2_session *session, + uint8_t *buf, size_t length, + int flags, void *user_data); + +/** + * @functypedef + * + * Callback function invoked by `nghttp2_session_recv()` and + * `nghttp2_session_mem_recv2()` when a frame is received. The + * |user_data| pointer is the third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * + * If frame is HEADERS or PUSH_PROMISE, the ``nva`` and ``nvlen`` + * member of their data structure are always ``NULL`` and 0 + * respectively. The header name/value pairs are emitted via + * :type:`nghttp2_on_header_callback`. + * + * Only HEADERS and DATA frame can signal the end of incoming data. + * If ``frame->hd.flags & NGHTTP2_FLAG_END_STREAM`` is nonzero, the + * |frame| is the last frame from the remote peer in this stream. + * + * This callback won't be called for CONTINUATION frames. + * HEADERS/PUSH_PROMISE + CONTINUATIONs are treated as single frame. + * + * The implementation of this function must return 0 if it succeeds. + * If nonzero value is returned, it is treated as fatal error and + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_frame_recv_callback()`. + */ +typedef int (*nghttp2_on_frame_recv_callback)(nghttp2_session *session, + const nghttp2_frame *frame, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked by `nghttp2_session_recv()` and + * `nghttp2_session_mem_recv2()` when an invalid non-DATA frame is + * received. The error is indicated by the |lib_error_code|, which is + * one of the values defined in :type:`nghttp2_error`. When this + * callback function is invoked, the library automatically submits + * either RST_STREAM or GOAWAY frame. The |user_data| pointer is the + * third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * + * If frame is HEADERS or PUSH_PROMISE, the ``nva`` and ``nvlen`` + * member of their data structure are always ``NULL`` and 0 + * respectively. + * + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error and + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_invalid_frame_recv_callback()`. + */ +typedef int (*nghttp2_on_invalid_frame_recv_callback)( + nghttp2_session *session, const nghttp2_frame *frame, int lib_error_code, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked when a chunk of data in DATA frame is + * received. The |stream_id| is the stream ID this DATA frame belongs + * to. The |flags| is the flags of DATA frame which this data chunk + * is contained. ``(flags & NGHTTP2_FLAG_END_STREAM) != 0`` does not + * necessarily mean this chunk of data is the last one in the stream. + * You should use :type:`nghttp2_on_frame_recv_callback` to know all + * data frames are received. The |user_data| pointer is the third + * argument passed in to the call to `nghttp2_session_client_new()` or + * `nghttp2_session_server_new()`. + * + * If the application uses `nghttp2_session_mem_recv2()`, it can + * return :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` to make + * `nghttp2_session_mem_recv2()` return without processing further + * input bytes. The memory by pointed by the |data| is retained until + * `nghttp2_session_mem_recv2()` or `nghttp2_session_recv()` is + * called. The application must retain the input bytes which was used + * to produce the |data| parameter, because it may refer to the memory + * region included in the input bytes. + * + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error, and + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_data_chunk_recv_callback()`. + */ +typedef int (*nghttp2_on_data_chunk_recv_callback)(nghttp2_session *session, + uint8_t flags, + int32_t stream_id, + const uint8_t *data, + size_t len, void *user_data); + +/** + * @functypedef + * + * Callback function invoked just before the non-DATA frame |frame| is + * sent. The |user_data| pointer is the third argument passed in to + * the call to `nghttp2_session_client_new()` or + * `nghttp2_session_server_new()`. + * + * The implementation of this function must return 0 if it succeeds. + * It can also return :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL` to + * cancel the transmission of the given frame. + * + * If there is a fatal error while executing this callback, the + * implementation should return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`, which makes + * `nghttp2_session_send()` and `nghttp2_session_mem_send2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * If the other value is returned, it is treated as if + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned. + * But the implementation should not rely on this since the library + * may define new return value to extend its capability. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_before_frame_send_callback()`. + */ +typedef int (*nghttp2_before_frame_send_callback)(nghttp2_session *session, + const nghttp2_frame *frame, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked after the frame |frame| is sent. The + * |user_data| pointer is the third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error and + * `nghttp2_session_send()` and `nghttp2_session_mem_send2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_frame_send_callback()`. + */ +typedef int (*nghttp2_on_frame_send_callback)(nghttp2_session *session, + const nghttp2_frame *frame, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked after the non-DATA frame |frame| is not + * sent because of the error. The error is indicated by the + * |lib_error_code|, which is one of the values defined in + * :type:`nghttp2_error`. The |user_data| pointer is the third + * argument passed in to the call to `nghttp2_session_client_new()` or + * `nghttp2_session_server_new()`. + * + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error and + * `nghttp2_session_send()` and `nghttp2_session_mem_send2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * `nghttp2_session_get_stream_user_data()` can be used to get + * associated data. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_frame_not_send_callback()`. + */ +typedef int (*nghttp2_on_frame_not_send_callback)(nghttp2_session *session, + const nghttp2_frame *frame, + int lib_error_code, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked when the stream |stream_id| is closed. + * The reason of closure is indicated by the |error_code|. The + * |error_code| is usually one of :enum:`nghttp2_error_code`, but that + * is not guaranteed. The stream_user_data, which was specified in + * `nghttp2_submit_request2()` or `nghttp2_submit_headers()`, is still + * available in this function. The |user_data| pointer is the third + * argument passed in to the call to `nghttp2_session_client_new()` or + * `nghttp2_session_server_new()`. + * + * This function is also called for a stream in reserved state. + * + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error and + * `nghttp2_session_recv()`, `nghttp2_session_mem_recv2()`, + * `nghttp2_session_send()`, and `nghttp2_session_mem_send2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_stream_close_callback()`. + */ +typedef int (*nghttp2_on_stream_close_callback)(nghttp2_session *session, + int32_t stream_id, + uint32_t error_code, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked when the reception of header block in + * HEADERS or PUSH_PROMISE is started. Each header name/value pair + * will be emitted by :type:`nghttp2_on_header_callback`. + * + * The ``frame->hd.flags`` may not have + * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_HEADERS` flag set, which + * indicates that one or more CONTINUATION frames are involved. But + * the application does not need to care about that because the header + * name/value pairs are emitted transparently regardless of + * CONTINUATION frames. + * + * The server applications probably create an object to store + * information about new stream if ``frame->hd.type == + * NGHTTP2_HEADERS`` and ``frame->headers.cat == + * NGHTTP2_HCAT_REQUEST``. If |session| is configured as server side, + * ``frame->headers.cat`` is either ``NGHTTP2_HCAT_REQUEST`` + * containing request headers or ``NGHTTP2_HCAT_HEADERS`` containing + * trailer fields and never get PUSH_PROMISE in this callback. + * + * For the client applications, ``frame->hd.type`` is either + * ``NGHTTP2_HEADERS`` or ``NGHTTP2_PUSH_PROMISE``. In case of + * ``NGHTTP2_HEADERS``, ``frame->headers.cat == + * NGHTTP2_HCAT_RESPONSE`` means that it is the first response + * headers, but it may be non-final response which is indicated by 1xx + * status code. In this case, there may be zero or more HEADERS frame + * with ``frame->headers.cat == NGHTTP2_HCAT_HEADERS`` which has + * non-final response code and finally client gets exactly one HEADERS + * frame with ``frame->headers.cat == NGHTTP2_HCAT_HEADERS`` + * containing final response headers (non-1xx status code). The + * trailer fields also has ``frame->headers.cat == + * NGHTTP2_HCAT_HEADERS`` which does not contain any status code. + * + * Returning + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will + * close the stream (promised stream if frame is PUSH_PROMISE) by + * issuing RST_STREAM with + * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. In this case, + * :type:`nghttp2_on_header_callback` and + * :type:`nghttp2_on_frame_recv_callback` will not be invoked. If a + * different error code is desirable, use + * `nghttp2_submit_rst_stream()` with a desired error code and then + * return :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. + * Again, use ``frame->push_promise.promised_stream_id`` as stream_id + * parameter in `nghttp2_submit_rst_stream()` if frame is + * PUSH_PROMISE. + * + * The implementation of this function must return 0 if it succeeds. + * It can return + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` to + * reset the stream (promised stream if frame is PUSH_PROMISE). For + * critical errors, it must return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other + * value is returned, it is treated as if + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned. If + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned, + * `nghttp2_session_mem_recv2()` function will immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_begin_headers_callback()`. + */ +typedef int (*nghttp2_on_begin_headers_callback)(nghttp2_session *session, + const nghttp2_frame *frame, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked when a header name/value pair is received + * for the |frame|. The |name| of length |namelen| is header name. + * The |value| of length |valuelen| is header value. The |flags| is + * bitwise OR of one or more of :type:`nghttp2_nv_flag`. + * + * If :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_INDEX` is set in + * |flags|, the receiver must not index this name/value pair when + * forwarding it to the next hop. More specifically, "Literal Header + * Field never Indexed" representation must be used in HPACK encoding. + * + * When this callback is invoked, ``frame->hd.type`` is either + * :enum:`nghttp2_frame_type.NGHTTP2_HEADERS` or + * :enum:`nghttp2_frame_type.NGHTTP2_PUSH_PROMISE`. After all header + * name/value pairs are processed with this callback, and no error has + * been detected, :type:`nghttp2_on_frame_recv_callback` will be + * invoked. If there is an error in decompression, + * :type:`nghttp2_on_frame_recv_callback` for the |frame| will not be + * invoked. + * + * Both |name| and |value| are guaranteed to be NULL-terminated. The + * |namelen| and |valuelen| do not include terminal NULL. If + * `nghttp2_option_set_no_http_messaging()` is used with nonzero + * value, NULL character may be included in |name| or |value| before + * terminating NULL. + * + * Please note that unless `nghttp2_option_set_no_http_messaging()` is + * used, nghttp2 library does perform validation against the |name| + * and the |value| using `nghttp2_check_header_name()` and + * `nghttp2_check_header_value()`. In addition to this, nghttp2 + * performs validation based on HTTP Messaging rule, which is briefly + * explained in :ref:`http-messaging` section. + * + * If the application uses `nghttp2_session_mem_recv2()`, it can + * return :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` to make + * `nghttp2_session_mem_recv2()` return without processing further + * input bytes. The memory pointed by |frame|, |name| and |value| + * parameters are retained until `nghttp2_session_mem_recv2()` or + * `nghttp2_session_recv()` is called. The application must retain + * the input bytes which was used to produce these parameters, because + * it may refer to the memory region included in the input bytes. + * + * Returning + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will + * close the stream (promised stream if frame is PUSH_PROMISE) by + * issuing RST_STREAM with + * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. In this case, + * :type:`nghttp2_on_header_callback` and + * :type:`nghttp2_on_frame_recv_callback` will not be invoked. If a + * different error code is desirable, use + * `nghttp2_submit_rst_stream()` with a desired error code and then + * return :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. + * Again, use ``frame->push_promise.promised_stream_id`` as stream_id + * parameter in `nghttp2_submit_rst_stream()` if frame is + * PUSH_PROMISE. + * + * The implementation of this function must return 0 if it succeeds. + * It may return :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` or + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. For + * other critical failures, it must return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other + * nonzero value is returned, it is treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned, + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_header_callback()`. + * + * .. warning:: + * + * Application should properly limit the total buffer size to store + * incoming header fields. Without it, peer may send large number + * of header fields or large header fields to cause out of memory in + * local endpoint. Due to how HPACK works, peer can do this + * effectively without using much memory on their own. + */ +typedef int (*nghttp2_on_header_callback)(nghttp2_session *session, + const nghttp2_frame *frame, + const uint8_t *name, size_t namelen, + const uint8_t *value, size_t valuelen, + uint8_t flags, void *user_data); + +/** + * @functypedef + * + * Callback function invoked when a header name/value pair is received + * for the |frame|. The |name| is header name. The |value| is header + * value. The |flags| is bitwise OR of one or more of + * :type:`nghttp2_nv_flag`. + * + * This callback behaves like :type:`nghttp2_on_header_callback`, + * except that |name| and |value| are stored in reference counted + * buffer. If application wishes to keep these references without + * copying them, use `nghttp2_rcbuf_incref()` to increment their + * reference count. It is the application's responsibility to call + * `nghttp2_rcbuf_decref()` if they called `nghttp2_rcbuf_incref()` so + * as not to leak memory. If the |session| is created by + * `nghttp2_session_server_new3()` or `nghttp2_session_client_new3()`, + * the function to free memory is the one belongs to the mem + * parameter. As long as this free function alives, |name| and + * |value| can live after |session| was destroyed. + */ +typedef int (*nghttp2_on_header_callback2)(nghttp2_session *session, + const nghttp2_frame *frame, + nghttp2_rcbuf *name, + nghttp2_rcbuf *value, uint8_t flags, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked when an invalid header name/value pair is + * received for the |frame|. + * + * The parameter and behaviour are similar to + * :type:`nghttp2_on_header_callback`. The difference is that this + * callback is only invoked when an invalid header name/value pair is + * received which is treated as stream error if this callback returns + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` and + * :type:`nghttp2_on_invalid_header_callback2` is not set. Only + * invalid regular header field are passed to this callback. In other + * words, invalid pseudo header field is not passed to this callback. + * Also header fields which includes upper cased latter are also + * treated as error without passing them to this callback. + * + * This callback is only considered if HTTP messaging validation is + * turned on (which is on by default, see + * `nghttp2_option_set_no_http_messaging()`). + * + * With this callback, application inspects the incoming invalid + * field, and it also can reset stream from this callback by returning + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By + * default, the error code is + * :enum:`nghttp2_error_code.NGHTTP2_PROTOCOL_ERROR`. To change the + * error code, call `nghttp2_submit_rst_stream()` with the error code + * of choice in addition to returning + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. + * + * If 0 is returned, the header field is ignored, and the stream is + * not reset. + */ +typedef int (*nghttp2_on_invalid_header_callback)( + nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, + size_t namelen, const uint8_t *value, size_t valuelen, uint8_t flags, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked when an invalid header name/value pair is + * received for the |frame|. + * + * The parameter and behaviour are similar to + * :type:`nghttp2_on_header_callback2`. The difference is that this + * callback is only invoked when an invalid header name/value pair is + * received which is silently ignored if neither this callback nor + * :type:`nghttp2_on_invalid_header_callback` is set. Only invalid + * regular header field are passed to this callback. In other words, + * invalid pseudo header field is not passed to this callback. Also + * header fields which includes upper cased latter are also treated as + * error without passing them to this callback. + * + * This callback is only considered if HTTP messaging validation is + * turned on (which is on by default, see + * `nghttp2_option_set_no_http_messaging()`). + * + * With this callback, application inspects the incoming invalid + * field, and it also can reset stream from this callback by returning + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By + * default, the error code is + * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. To change the + * error code, call `nghttp2_submit_rst_stream()` with the error code + * of choice in addition to returning + * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. + */ +typedef int (*nghttp2_on_invalid_header_callback2)( + nghttp2_session *session, const nghttp2_frame *frame, nghttp2_rcbuf *name, + nghttp2_rcbuf *value, uint8_t flags, void *user_data); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @functypedef + * + * .. warning:: + * + * Deprecated. Use :type:`nghttp2_select_padding_callback2` + * instead. + * + * Callback function invoked when the library asks application how + * many padding bytes are required for the transmission of the + * |frame|. The application must choose the total length of payload + * including padded bytes in range [frame->hd.length, max_payloadlen], + * inclusive. Choosing number not in this range will be treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. Returning + * ``frame->hd.length`` means no padding is added. Returning + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will make + * `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions + * immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_select_padding_callback()`. + */ +typedef ssize_t (*nghttp2_select_padding_callback)(nghttp2_session *session, + const nghttp2_frame *frame, + size_t max_payloadlen, + void *user_data); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @functypedef + * + * Callback function invoked when the library asks application how + * many padding bytes are required for the transmission of the + * |frame|. The application must choose the total length of payload + * including padded bytes in range [frame->hd.length, max_payloadlen], + * inclusive. Choosing number not in this range will be treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. Returning + * ``frame->hd.length`` means no padding is added. Returning + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will make + * `nghttp2_session_send()` and `nghttp2_session_mem_send2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_select_padding_callback2()`. + */ +typedef nghttp2_ssize (*nghttp2_select_padding_callback2)( + nghttp2_session *session, const nghttp2_frame *frame, size_t max_payloadlen, + void *user_data); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @functypedef + * + * .. warning:: + * + * Deprecated. Use + * :type:`nghttp2_data_source_read_length_callback2` instead. + * + * Callback function invoked when library wants to get max length of + * data to send data to the remote peer. The implementation of this + * function should return a value in the following range. [1, + * min(|session_remote_window_size|, |stream_remote_window_size|, + * |remote_max_frame_size|)]. If a value greater than this range is + * returned than the max allow value will be used. Returning a value + * smaller than this range is treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. The + * |frame_type| is provided for future extensibility and identifies + * the type of frame (see :type:`nghttp2_frame_type`) for which to get + * the length for. Currently supported frame types are: + * :enum:`nghttp2_frame_type.NGHTTP2_DATA`. + * + * This callback can be used to control the length in bytes for which + * :type:`nghttp2_data_source_read_callback` is allowed to send to the + * remote endpoint. This callback is optional. Returning + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will signal the + * entire session failure. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_data_source_read_length_callback()`. + */ +typedef ssize_t (*nghttp2_data_source_read_length_callback)( + nghttp2_session *session, uint8_t frame_type, int32_t stream_id, + int32_t session_remote_window_size, int32_t stream_remote_window_size, + uint32_t remote_max_frame_size, void *user_data); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @functypedef + * + * Callback function invoked when library wants to get max length of + * data to send data to the remote peer. The implementation of this + * function should return a value in the following range. [1, + * min(|session_remote_window_size|, |stream_remote_window_size|, + * |remote_max_frame_size|)]. If a value greater than this range is + * returned than the max allow value will be used. Returning a value + * smaller than this range is treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. The + * |frame_type| is provided for future extensibility and identifies + * the type of frame (see :type:`nghttp2_frame_type`) for which to get + * the length for. Currently supported frame types are: + * :enum:`nghttp2_frame_type.NGHTTP2_DATA`. + * + * This callback can be used to control the length in bytes for which + * :type:`nghttp2_data_source_read_callback` is allowed to send to the + * remote endpoint. This callback is optional. Returning + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will signal the + * entire session failure. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_data_source_read_length_callback2()`. + */ +typedef nghttp2_ssize (*nghttp2_data_source_read_length_callback2)( + nghttp2_session *session, uint8_t frame_type, int32_t stream_id, + int32_t session_remote_window_size, int32_t stream_remote_window_size, + uint32_t remote_max_frame_size, void *user_data); + +/** + * @functypedef + * + * Callback function invoked when a frame header is received. The + * |hd| points to received frame header. + * + * Unlike :type:`nghttp2_on_frame_recv_callback`, this callback will + * also be called when frame header of CONTINUATION frame is received. + * + * If both :type:`nghttp2_on_begin_frame_callback` and + * :type:`nghttp2_on_begin_headers_callback` are set and HEADERS or + * PUSH_PROMISE is received, :type:`nghttp2_on_begin_frame_callback` + * will be called first. + * + * The implementation of this function must return 0 if it succeeds. + * If nonzero value is returned, it is treated as fatal error and + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_begin_frame_callback()`. + */ +typedef int (*nghttp2_on_begin_frame_callback)(nghttp2_session *session, + const nghttp2_frame_hd *hd, + void *user_data); + +/** + * @functypedef + * + * Callback function invoked when chunk of extension frame payload is + * received. The |hd| points to frame header. The received + * chunk is |data| of length |len|. + * + * The implementation of this function must return 0 if it succeeds. + * + * To abort processing this extension frame, return + * :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL`. + * + * If fatal error occurred, application should return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other + * values are returned, currently they are treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + */ +typedef int (*nghttp2_on_extension_chunk_recv_callback)( + nghttp2_session *session, const nghttp2_frame_hd *hd, const uint8_t *data, + size_t len, void *user_data); + +/** + * @functypedef + * + * Callback function invoked when library asks the application to + * unpack extension payload from its wire format. The extension + * payload has been passed to the application using + * :type:`nghttp2_on_extension_chunk_recv_callback`. The frame header + * is already unpacked by the library and provided as |hd|. + * + * To receive extension frames, the application must tell desired + * extension frame type to the library using + * `nghttp2_option_set_user_recv_extension_type()`. + * + * The implementation of this function may store the pointer to the + * created object as a result of unpacking in |*payload|, and returns + * 0. The pointer stored in |*payload| is opaque to the library, and + * the library does not own its pointer. |*payload| is initialized as + * ``NULL``. The |*payload| is available as ``frame->ext.payload`` in + * :type:`nghttp2_on_frame_recv_callback`. Therefore if application + * can free that memory inside :type:`nghttp2_on_frame_recv_callback` + * callback. Of course, application has a liberty not to use + * |*payload|, and do its own mechanism to process extension frames. + * + * To abort processing this extension frame, return + * :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL`. + * + * If fatal error occurred, application should return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other + * values are returned, currently they are treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + */ +typedef int (*nghttp2_unpack_extension_callback)(nghttp2_session *session, + void **payload, + const nghttp2_frame_hd *hd, + void *user_data); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @functypedef + * + * .. warning:: + * + * Deprecated. Use :type:`nghttp2_pack_extension_callback2` + * instead. + * + * Callback function invoked when library asks the application to pack + * extension payload in its wire format. The frame header will be + * packed by library. Application must pack payload only. + * ``frame->ext.payload`` is the object passed to + * `nghttp2_submit_extension()` as payload parameter. Application + * must pack extension payload to the |buf| of its capacity |len| + * bytes. The |len| is at least 16KiB. + * + * The implementation of this function should return the number of + * bytes written into |buf| when it succeeds. + * + * To abort processing this extension frame, return + * :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL`, and + * :type:`nghttp2_on_frame_not_send_callback` will be invoked. + * + * If fatal error occurred, application should return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, + * `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions + * immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other + * values are returned, currently they are treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the return + * value is strictly larger than |len|, it is treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + */ +typedef ssize_t (*nghttp2_pack_extension_callback)(nghttp2_session *session, + uint8_t *buf, size_t len, + const nghttp2_frame *frame, + void *user_data); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @functypedef + * + * Callback function invoked when library asks the application to pack + * extension payload in its wire format. The frame header will be + * packed by library. Application must pack payload only. + * ``frame->ext.payload`` is the object passed to + * `nghttp2_submit_extension()` as payload parameter. Application + * must pack extension payload to the |buf| of its capacity |len| + * bytes. The |len| is at least 16KiB. + * + * The implementation of this function should return the number of + * bytes written into |buf| when it succeeds. + * + * To abort processing this extension frame, return + * :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL`, and + * :type:`nghttp2_on_frame_not_send_callback` will be invoked. + * + * If fatal error occurred, application should return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, + * `nghttp2_session_send()` and `nghttp2_session_mem_send2()` + * functions immediately return + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other + * values are returned, currently they are treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the return + * value is strictly larger than |len|, it is treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + */ +typedef nghttp2_ssize (*nghttp2_pack_extension_callback2)( + nghttp2_session *session, uint8_t *buf, size_t len, + const nghttp2_frame *frame, void *user_data); + +/** + * @functypedef + * + * .. warning:: + * + * Deprecated. Use :type:`nghttp2_error_callback2` instead. + * + * Callback function invoked when library provides the error message + * intended for human consumption. This callback is solely for + * debugging purpose. The |msg| is typically NULL-terminated string + * of length |len|. |len| does not include the sentinel NULL + * character. + * + * The format of error message may change between nghttp2 library + * versions. The application should not depend on the particular + * format. + * + * Normally, application should return 0 from this callback. If fatal + * error occurred while doing something in this callback, application + * should return :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * In this case, library will return immediately with return value + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if + * nonzero value is returned from this callback, they are treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`, but application + * should not rely on this details. + */ +typedef int (*nghttp2_error_callback)(nghttp2_session *session, const char *msg, + size_t len, void *user_data); + +/** + * @functypedef + * + * Callback function invoked when library provides the error code, and + * message. This callback is solely for debugging purpose. + * |lib_error_code| is one of error code defined in + * :enum:`nghttp2_error`. The |msg| is typically NULL-terminated + * string of length |len|, and intended for human consumption. |len| + * does not include the sentinel NULL character. + * + * The format of error message may change between nghttp2 library + * versions. The application should not depend on the particular + * format. + * + * Normally, application should return 0 from this callback. If fatal + * error occurred while doing something in this callback, application + * should return :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * In this case, library will return immediately with return value + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if + * nonzero value is returned from this callback, they are treated as + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`, but application + * should not rely on this details. + */ +typedef int (*nghttp2_error_callback2)(nghttp2_session *session, + int lib_error_code, const char *msg, + size_t len, void *user_data); + +/** + * @functypedef + * + * Callback function invoked when unpredictable data of |destlen| + * bytes are needed. The implementation must write unpredictable data + * of |destlen| bytes into the buffer pointed by |dest|. + */ +typedef void (*nghttp2_rand_callback)(uint8_t *dest, size_t destlen); + +struct nghttp2_session_callbacks; + +/** + * @struct + * + * Callback functions for :type:`nghttp2_session`. The details of + * this structure are intentionally hidden from the public API. + */ +typedef struct nghttp2_session_callbacks nghttp2_session_callbacks; + +/** + * @function + * + * Initializes |*callbacks_ptr| with NULL values. + * + * The initialized object can be used when initializing multiple + * :type:`nghttp2_session` objects. + * + * When the application finished using this object, it can use + * `nghttp2_session_callbacks_del()` to free its memory. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int +nghttp2_session_callbacks_new(nghttp2_session_callbacks **callbacks_ptr); + +/** + * @function + * + * Frees any resources allocated for |callbacks|. If |callbacks| is + * ``NULL``, this function does nothing. + */ +NGHTTP2_EXTERN void +nghttp2_session_callbacks_del(nghttp2_session_callbacks *callbacks); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_session_callbacks_set_send_callback2()` + * with :type:`nghttp2_send_callback2` instead. + * + * Sets callback function invoked when a session wants to send data to + * the remote peer. This callback is not necessary if the application + * uses solely `nghttp2_session_mem_send()` to serialize data to + * transmit. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_send_callback( + nghttp2_session_callbacks *cbs, nghttp2_send_callback send_callback); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Sets callback function invoked when a session wants to send data to + * the remote peer. This callback is not necessary if the application + * uses solely `nghttp2_session_mem_send2()` to serialize data to + * transmit. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_send_callback2( + nghttp2_session_callbacks *cbs, nghttp2_send_callback2 send_callback); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_session_callbacks_set_recv_callback2()` + * with :type:`nghttp2_recv_callback2` instead. + * + * Sets callback function invoked when the a session wants to receive + * data from the remote peer. This callback is not necessary if the + * application uses solely `nghttp2_session_mem_recv()` to process + * received data. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_recv_callback( + nghttp2_session_callbacks *cbs, nghttp2_recv_callback recv_callback); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Sets callback function invoked when the a session wants to receive + * data from the remote peer. This callback is not necessary if the + * application uses solely `nghttp2_session_mem_recv2()` to process + * received data. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_recv_callback2( + nghttp2_session_callbacks *cbs, nghttp2_recv_callback2 recv_callback); + +/** + * @function + * + * Sets callback function invoked by `nghttp2_session_recv()` and + * `nghttp2_session_mem_recv2()` when a frame is received. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_frame_recv_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_frame_recv_callback on_frame_recv_callback); + +/** + * @function + * + * Sets callback function invoked by `nghttp2_session_recv()` and + * `nghttp2_session_mem_recv2()` when an invalid non-DATA frame is + * received. + */ +NGHTTP2_EXTERN void +nghttp2_session_callbacks_set_on_invalid_frame_recv_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_invalid_frame_recv_callback on_invalid_frame_recv_callback); + +/** + * @function + * + * Sets callback function invoked when a chunk of data in DATA frame + * is received. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_data_chunk_recv_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_data_chunk_recv_callback on_data_chunk_recv_callback); + +/** + * @function + * + * Sets callback function invoked before a non-DATA frame is sent. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_before_frame_send_callback( + nghttp2_session_callbacks *cbs, + nghttp2_before_frame_send_callback before_frame_send_callback); + +/** + * @function + * + * Sets callback function invoked after a frame is sent. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_frame_send_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_frame_send_callback on_frame_send_callback); + +/** + * @function + * + * Sets callback function invoked when a non-DATA frame is not sent + * because of an error. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_frame_not_send_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_frame_not_send_callback on_frame_not_send_callback); + +/** + * @function + * + * Sets callback function invoked when the stream is closed. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_stream_close_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_stream_close_callback on_stream_close_callback); + +/** + * @function + * + * Sets callback function invoked when the reception of header block + * in HEADERS or PUSH_PROMISE is started. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_begin_headers_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_begin_headers_callback on_begin_headers_callback); + +/** + * @function + * + * Sets callback function invoked when a header name/value pair is + * received. If both + * `nghttp2_session_callbacks_set_on_header_callback()` and + * `nghttp2_session_callbacks_set_on_header_callback2()` are used to + * set callbacks, the latter has the precedence. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_header_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_header_callback on_header_callback); + +/** + * @function + * + * Sets callback function invoked when a header name/value pair is + * received. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_header_callback2( + nghttp2_session_callbacks *cbs, + nghttp2_on_header_callback2 on_header_callback2); + +/** + * @function + * + * Sets callback function invoked when an invalid header name/value + * pair is received. If both + * `nghttp2_session_callbacks_set_on_invalid_header_callback()` and + * `nghttp2_session_callbacks_set_on_invalid_header_callback2()` are + * used to set callbacks, the latter takes the precedence. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_invalid_header_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_invalid_header_callback on_invalid_header_callback); + +/** + * @function + * + * Sets callback function invoked when an invalid header name/value + * pair is received. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_invalid_header_callback2( + nghttp2_session_callbacks *cbs, + nghttp2_on_invalid_header_callback2 on_invalid_header_callback2); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use + * `nghttp2_session_callbacks_set_select_padding_callback2()` with + * :type:`nghttp2_select_padding_callback2` instead. + * + * Sets callback function invoked when the library asks application + * how many padding bytes are required for the transmission of the + * given frame. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_select_padding_callback( + nghttp2_session_callbacks *cbs, + nghttp2_select_padding_callback select_padding_callback); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Sets callback function invoked when the library asks application + * how many padding bytes are required for the transmission of the + * given frame. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_select_padding_callback2( + nghttp2_session_callbacks *cbs, + nghttp2_select_padding_callback2 select_padding_callback); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use + * `nghttp2_session_callbacks_set_data_source_read_length_callback2()` + * with :type:`nghttp2_data_source_read_length_callback2` instead. + * + * Sets callback function determine the length allowed in + * :type:`nghttp2_data_source_read_callback`. + */ +NGHTTP2_EXTERN void +nghttp2_session_callbacks_set_data_source_read_length_callback( + nghttp2_session_callbacks *cbs, + nghttp2_data_source_read_length_callback data_source_read_length_callback); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Sets callback function determine the length allowed in + * :type:`nghttp2_data_source_read_callback2`. + */ +NGHTTP2_EXTERN void +nghttp2_session_callbacks_set_data_source_read_length_callback2( + nghttp2_session_callbacks *cbs, + nghttp2_data_source_read_length_callback2 data_source_read_length_callback); + +/** + * @function + * + * Sets callback function invoked when a frame header is received. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_begin_frame_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_begin_frame_callback on_begin_frame_callback); + +/** + * @function + * + * Sets callback function invoked when + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY` is used in + * :type:`nghttp2_data_source_read_callback2` to avoid data copy. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_send_data_callback( + nghttp2_session_callbacks *cbs, + nghttp2_send_data_callback send_data_callback); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use + * `nghttp2_session_callbacks_set_pack_extension_callback2()` with + * :type:`nghttp2_pack_extension_callback2` instead. + * + * Sets callback function invoked when the library asks the + * application to pack extension frame payload in wire format. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_pack_extension_callback( + nghttp2_session_callbacks *cbs, + nghttp2_pack_extension_callback pack_extension_callback); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Sets callback function invoked when the library asks the + * application to pack extension frame payload in wire format. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_pack_extension_callback2( + nghttp2_session_callbacks *cbs, + nghttp2_pack_extension_callback2 pack_extension_callback); + +/** + * @function + * + * Sets callback function invoked when the library asks the + * application to unpack extension frame payload from wire format. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_unpack_extension_callback( + nghttp2_session_callbacks *cbs, + nghttp2_unpack_extension_callback unpack_extension_callback); + +/** + * @function + * + * Sets callback function invoked when chunk of extension frame + * payload is received. + */ +NGHTTP2_EXTERN void +nghttp2_session_callbacks_set_on_extension_chunk_recv_callback( + nghttp2_session_callbacks *cbs, + nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback); + +/** + * @function + * + * .. warning:: + * + * Deprecated. Use + * `nghttp2_session_callbacks_set_error_callback2()` with + * :type:`nghttp2_error_callback2` instead. + * + * Sets callback function invoked when library tells error message to + * the application. + * + * If both :type:`nghttp2_error_callback` and + * :type:`nghttp2_error_callback2` are set, the latter takes + * precedence. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_error_callback( + nghttp2_session_callbacks *cbs, nghttp2_error_callback error_callback); + +/** + * @function + * + * Sets callback function invoked when library tells error code, and + * message to the application. + * + * If both :type:`nghttp2_error_callback` and + * :type:`nghttp2_error_callback2` are set, the latter takes + * precedence. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_error_callback2( + nghttp2_session_callbacks *cbs, nghttp2_error_callback2 error_callback2); + +/** + * @function + * + * Sets callback function invoked when unpredictable data is needed. + * Although this callback is optional due to the backward + * compatibility, it is recommended to specify it to harden the + * runtime behavior against suspicious activities of a remote + * endpoint. + */ +NGHTTP2_EXTERN void nghttp2_session_callbacks_set_rand_callback( + nghttp2_session_callbacks *cbs, nghttp2_rand_callback rand_callback); + +/** + * @functypedef + * + * Custom memory allocator to replace malloc(). The |mem_user_data| + * is the mem_user_data member of :type:`nghttp2_mem` structure. + */ +typedef void *(*nghttp2_malloc)(size_t size, void *mem_user_data); + +/** + * @functypedef + * + * Custom memory allocator to replace free(). The |mem_user_data| is + * the mem_user_data member of :type:`nghttp2_mem` structure. + */ +typedef void (*nghttp2_free)(void *ptr, void *mem_user_data); + +/** + * @functypedef + * + * Custom memory allocator to replace calloc(). The |mem_user_data| + * is the mem_user_data member of :type:`nghttp2_mem` structure. + */ +typedef void *(*nghttp2_calloc)(size_t nmemb, size_t size, void *mem_user_data); + +/** + * @functypedef + * + * Custom memory allocator to replace realloc(). The |mem_user_data| + * is the mem_user_data member of :type:`nghttp2_mem` structure. + */ +typedef void *(*nghttp2_realloc)(void *ptr, size_t size, void *mem_user_data); + +/** + * @struct + * + * Custom memory allocator functions and user defined pointer. The + * |mem_user_data| member is passed to each allocator function. This + * can be used, for example, to achieve per-session memory pool. + * + * In the following example code, ``my_malloc``, ``my_free``, + * ``my_calloc`` and ``my_realloc`` are the replacement of the + * standard allocators ``malloc``, ``free``, ``calloc`` and + * ``realloc`` respectively:: + * + * void *my_malloc_cb(size_t size, void *mem_user_data) { + * return my_malloc(size); + * } + * + * void my_free_cb(void *ptr, void *mem_user_data) { my_free(ptr); } + * + * void *my_calloc_cb(size_t nmemb, size_t size, void *mem_user_data) { + * return my_calloc(nmemb, size); + * } + * + * void *my_realloc_cb(void *ptr, size_t size, void *mem_user_data) { + * return my_realloc(ptr, size); + * } + * + * void session_new() { + * nghttp2_session *session; + * nghttp2_session_callbacks *callbacks; + * nghttp2_mem mem = {NULL, my_malloc_cb, my_free_cb, my_calloc_cb, + * my_realloc_cb}; + * + * ... + * + * nghttp2_session_client_new3(&session, callbacks, NULL, NULL, &mem); + * + * ... + * } + */ +typedef struct { + /** + * An arbitrary user supplied data. This is passed to each + * allocator function. + */ + void *mem_user_data; + /** + * Custom allocator function to replace malloc(). + */ + nghttp2_malloc malloc; + /** + * Custom allocator function to replace free(). + */ + nghttp2_free free; + /** + * Custom allocator function to replace calloc(). + */ + nghttp2_calloc calloc; + /** + * Custom allocator function to replace realloc(). + */ + nghttp2_realloc realloc; +} nghttp2_mem; + +struct nghttp2_option; + +/** + * @struct + * + * Configuration options for :type:`nghttp2_session`. The details of + * this structure are intentionally hidden from the public API. + */ +typedef struct nghttp2_option nghttp2_option; + +/** + * @function + * + * Initializes |*option_ptr| with default values. + * + * When the application finished using this object, it can use + * `nghttp2_option_del()` to free its memory. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_option_new(nghttp2_option **option_ptr); + +/** + * @function + * + * Frees any resources allocated for |option|. If |option| is + * ``NULL``, this function does nothing. + */ +NGHTTP2_EXTERN void nghttp2_option_del(nghttp2_option *option); + +/** + * @function + * + * This option prevents the library from sending WINDOW_UPDATE for a + * connection automatically. If this option is set to nonzero, the + * library won't send WINDOW_UPDATE for DATA until application calls + * `nghttp2_session_consume()` to indicate the consumed amount of + * data. Don't use `nghttp2_submit_window_update()` for this purpose. + * By default, this option is set to zero. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_no_auto_window_update(nghttp2_option *option, int val); + +/** + * @function + * + * This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of + * remote endpoint as if it is received in SETTINGS frame. Without + * specifying this option, the maximum number of outgoing concurrent + * streams is initially limited to 100 to avoid issues when the local + * endpoint submits lots of requests before receiving initial SETTINGS + * frame from the remote endpoint, since sending them at once to the + * remote endpoint could lead to rejection of some of the requests. + * This value will be overwritten when the local endpoint receives + * initial SETTINGS frame from the remote endpoint, either to the + * value advertised in SETTINGS_MAX_CONCURRENT_STREAMS or to the + * default value (unlimited) if none was advertised. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_peer_max_concurrent_streams(nghttp2_option *option, + uint32_t val); + +/** + * @function + * + * By default, nghttp2 library, if configured as server, requires + * first 24 bytes of client magic byte string (MAGIC). In most cases, + * this will simplify the implementation of server. But sometimes + * server may want to detect the application protocol based on first + * few bytes on clear text communication. + * + * If this option is used with nonzero |val|, nghttp2 library does not + * handle MAGIC. It still checks following SETTINGS frame. This + * means that applications should deal with MAGIC by themselves. + * + * If this option is not used or used with zero value, if MAGIC does + * not match :macro:`NGHTTP2_CLIENT_MAGIC`, `nghttp2_session_recv()` + * and `nghttp2_session_mem_recv2()` will return error + * :enum:`nghttp2_error.NGHTTP2_ERR_BAD_CLIENT_MAGIC`, which is fatal + * error. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_no_recv_client_magic(nghttp2_option *option, int val); + +/** + * @function + * + * By default, nghttp2 library enforces subset of HTTP Messaging rules + * described in `HTTP/2 specification, section 8 + * `_. See + * :ref:`http-messaging` section for details. For those applications + * who use nghttp2 library as non-HTTP use, give nonzero to |val| to + * disable this enforcement. Please note that disabling this feature + * does not change the fundamental client and server model of HTTP. + * That is, even if the validation is disabled, only client can send + * requests. + */ +NGHTTP2_EXTERN void nghttp2_option_set_no_http_messaging(nghttp2_option *option, + int val); + +/** + * @function + * + * RFC 7540 does not enforce any limit on the number of incoming + * reserved streams (in RFC 7540 terms, streams in reserved (remote) + * state). This only affects client side, since only server can push + * streams. Malicious server can push arbitrary number of streams, + * and make client's memory exhausted. This option can set the + * maximum number of such incoming streams to avoid possible memory + * exhaustion. If this option is set, and pushed streams are + * automatically closed on reception, without calling user provided + * callback, if they exceed the given limit. The default value is + * 200. If session is configured as server side, this option has no + * effect. Server can control the number of streams to push. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_max_reserved_remote_streams(nghttp2_option *option, + uint32_t val); + +/** + * @function + * + * Sets extension frame type the application is willing to handle with + * user defined callbacks (see + * :type:`nghttp2_on_extension_chunk_recv_callback` and + * :type:`nghttp2_unpack_extension_callback`). The |type| is + * extension frame type, and must be strictly greater than 0x9. + * Otherwise, this function does nothing. The application can call + * this function multiple times to set more than one frame type to + * receive. The application does not have to call this function if it + * just sends extension frames. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_user_recv_extension_type(nghttp2_option *option, + uint8_t type); + +/** + * @function + * + * Sets extension frame type the application is willing to receive + * using builtin handler. The |type| is the extension frame type to + * receive, and must be strictly greater than 0x9. Otherwise, this + * function does nothing. The application can call this function + * multiple times to set more than one frame type to receive. The + * application does not have to call this function if it just sends + * extension frames. + * + * If same frame type is passed to both + * `nghttp2_option_set_builtin_recv_extension_type()` and + * `nghttp2_option_set_user_recv_extension_type()`, the latter takes + * precedence. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_builtin_recv_extension_type(nghttp2_option *option, + uint8_t type); + +/** + * @function + * + * This option prevents the library from sending PING frame with ACK + * flag set automatically when PING frame without ACK flag set is + * received. If this option is set to nonzero, the library won't send + * PING frame with ACK flag set in the response for incoming PING + * frame. The application can send PING frame with ACK flag set using + * `nghttp2_submit_ping()` with :enum:`nghttp2_flag.NGHTTP2_FLAG_ACK` + * as flags parameter. + */ +NGHTTP2_EXTERN void nghttp2_option_set_no_auto_ping_ack(nghttp2_option *option, + int val); + +/** + * @function + * + * This option sets the maximum length of header block (a set of + * header fields per one HEADERS frame) to send. The length of a + * given set of header fields is calculated using + * `nghttp2_hd_deflate_bound()`. The default value is 64KiB. If + * application attempts to send header fields larger than this limit, + * the transmission of the frame fails with error code + * :enum:`nghttp2_error.NGHTTP2_ERR_FRAME_SIZE_ERROR`. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_max_send_header_block_length(nghttp2_option *option, + size_t val); + +/** + * @function + * + * This option sets the maximum dynamic table size for deflating + * header fields. The default value is 4KiB. In HTTP/2, receiver of + * deflated header block can specify maximum dynamic table size. The + * actual maximum size is the minimum of the size receiver specified + * and this option value. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_max_deflate_dynamic_table_size(nghttp2_option *option, + size_t val); + +/** + * @function + * + * .. warning:: + * + * Deprecated. Closed streams are not retained anymore. + * + * This function works as before, but it does not take any effect + * against :type:`nghttp2_session`. + */ +NGHTTP2_EXTERN void nghttp2_option_set_no_closed_streams(nghttp2_option *option, + int val); + +/** + * @function + * + * This function sets the maximum number of outgoing SETTINGS ACK and + * PING ACK frames retained in :type:`nghttp2_session` object. If + * more than those frames are retained, the peer is considered to be + * misbehaving and session will be closed. The default value is 1000. + */ +NGHTTP2_EXTERN void nghttp2_option_set_max_outbound_ack(nghttp2_option *option, + size_t val); + +/** + * @function + * + * This function sets the maximum number of SETTINGS entries per + * SETTINGS frame that will be accepted. If more than those entries + * are received, the peer is considered to be misbehaving and session + * will be closed. The default value is 32. + */ +NGHTTP2_EXTERN void nghttp2_option_set_max_settings(nghttp2_option *option, + size_t val); + +/** + * @function + * + * .. warning:: + * Deprecated. :rfc:`7540` priorities have been removed. + * + * This function works as before, but it does not take any effect + * against :type:`nghttp2_session`. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_server_fallback_rfc7540_priorities(nghttp2_option *option, + int val); + +/** + * @function + * + * This option, if set to nonzero, turns off RFC 9113 leading and + * trailing white spaces validation against HTTP field value. Some + * important fields, such as HTTP/2 pseudo header fields, are + * validated more strictly and this option does not apply to them. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation( + nghttp2_option *option, int val); + +/** + * @function + * + * This function sets the rate limit for the incoming stream reset + * (RST_STREAM frame). It is server use only. It is a token-bucket + * based rate limiter. |burst| specifies the number of tokens that is + * initially available. The maximum number of tokens is capped to + * this value. |rate| specifies the number of tokens that are + * regenerated per second. An incoming RST_STREAM consumes one token. + * If there is no token available, GOAWAY is sent to tear down the + * connection. |burst| and |rate| default to 1000 and 33 + * respectively. + */ +NGHTTP2_EXTERN void +nghttp2_option_set_stream_reset_rate_limit(nghttp2_option *option, + uint64_t burst, uint64_t rate); + +/** + * @function + * + * This function sets the maximum number of CONTINUATION frames + * following an incoming HEADER frame. If more than those frames are + * received, the remote endpoint is considered to be misbehaving and + * session will be closed. The default value is 8. + */ +NGHTTP2_EXTERN void nghttp2_option_set_max_continuations(nghttp2_option *option, + size_t val); + +/** + * @function + * + * This function sets the rate limit for the "glitches", the + * suspicious activities from a remote endpoint. It is a token-bucket + * based rate limiter. |burst| specifies the number of tokens that is + * initially available. The maximum number of tokens is capped to + * this value. |rate| specifies the number of tokens that are + * regenerated per second. When a suspicious activity is detected, + * some amount of tokens are consumed. If there is no token + * available, GOAWAY is sent to tear down the connection. |burst| and + * |rate| default to 1000 and 33 respectively. + */ +NGHTTP2_EXTERN void nghttp2_option_set_glitch_rate_limit(nghttp2_option *option, + uint64_t burst, + uint64_t rate); + +/** + * @function + * + * Initializes |*session_ptr| for client use. The all members of + * |callbacks| are copied to |*session_ptr|. Therefore |*session_ptr| + * does not store |callbacks|. The |user_data| is an arbitrary user + * supplied data, which will be passed to the callback functions. + * + * The :type:`nghttp2_send_callback2` must be specified. If the + * application code uses `nghttp2_session_recv()`, the + * :type:`nghttp2_recv_callback` must be specified. The other members + * of |callbacks| can be ``NULL``. + * + * If this function fails, |*session_ptr| is left untouched. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int +nghttp2_session_client_new(nghttp2_session **session_ptr, + const nghttp2_session_callbacks *callbacks, + void *user_data); + +/** + * @function + * + * Initializes |*session_ptr| for server use. The all members of + * |callbacks| are copied to |*session_ptr|. Therefore |*session_ptr| + * does not store |callbacks|. The |user_data| is an arbitrary user + * supplied data, which will be passed to the callback functions. + * + * The :type:`nghttp2_send_callback2` must be specified. If the + * application code uses `nghttp2_session_recv()`, the + * :type:`nghttp2_recv_callback` must be specified. The other members + * of |callbacks| can be ``NULL``. + * + * If this function fails, |*session_ptr| is left untouched. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int +nghttp2_session_server_new(nghttp2_session **session_ptr, + const nghttp2_session_callbacks *callbacks, + void *user_data); + +/** + * @function + * + * Like `nghttp2_session_client_new()`, but with additional options + * specified in the |option|. + * + * The |option| can be ``NULL`` and the call is equivalent to + * `nghttp2_session_client_new()`. + * + * This function does not take ownership |option|. The application is + * responsible for freeing |option| if it finishes using the object. + * + * The library code does not refer to |option| after this function + * returns. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int +nghttp2_session_client_new2(nghttp2_session **session_ptr, + const nghttp2_session_callbacks *callbacks, + void *user_data, const nghttp2_option *option); + +/** + * @function + * + * Like `nghttp2_session_server_new()`, but with additional options + * specified in the |option|. + * + * The |option| can be ``NULL`` and the call is equivalent to + * `nghttp2_session_server_new()`. + * + * This function does not take ownership |option|. The application is + * responsible for freeing |option| if it finishes using the object. + * + * The library code does not refer to |option| after this function + * returns. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int +nghttp2_session_server_new2(nghttp2_session **session_ptr, + const nghttp2_session_callbacks *callbacks, + void *user_data, const nghttp2_option *option); + +/** + * @function + * + * Like `nghttp2_session_client_new2()`, but with additional custom + * memory allocator specified in the |mem|. + * + * The |mem| can be ``NULL`` and the call is equivalent to + * `nghttp2_session_client_new2()`. + * + * This function does not take ownership |mem|. The application is + * responsible for freeing |mem|. + * + * The library code does not refer to |mem| pointer after this + * function returns, so the application can safely free it. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_session_client_new3( + nghttp2_session **session_ptr, const nghttp2_session_callbacks *callbacks, + void *user_data, const nghttp2_option *option, nghttp2_mem *mem); + +/** + * @function + * + * Like `nghttp2_session_server_new2()`, but with additional custom + * memory allocator specified in the |mem|. + * + * The |mem| can be ``NULL`` and the call is equivalent to + * `nghttp2_session_server_new2()`. + * + * This function does not take ownership |mem|. The application is + * responsible for freeing |mem|. + * + * The library code does not refer to |mem| pointer after this + * function returns, so the application can safely free it. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_session_server_new3( + nghttp2_session **session_ptr, const nghttp2_session_callbacks *callbacks, + void *user_data, const nghttp2_option *option, nghttp2_mem *mem); + +/** + * @function + * + * Frees any resources allocated for |session|. If |session| is + * ``NULL``, this function does nothing. + */ +NGHTTP2_EXTERN void nghttp2_session_del(nghttp2_session *session); + +/** + * @function + * + * Sends pending frames to the remote peer. + * + * This function retrieves the highest prioritized frame from the + * outbound queue and sends it to the remote peer. It does this as + * many times as possible until the user callback + * :type:`nghttp2_send_callback2` returns + * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`, the outbound queue + * becomes empty or flow control is triggered (remote window size + * becomes depleted or maximum number of concurrent streams is + * reached). This function calls several callback functions which are + * passed when initializing the |session|. Here is the simple time + * chart which tells when each callback is invoked: + * + * 1. Get the next frame to send from outbound queue. + * + * 2. Prepare transmission of the frame. + * + * 3. If the control frame cannot be sent because some preconditions + * are not met (e.g., request HEADERS cannot be sent after GOAWAY), + * :type:`nghttp2_on_frame_not_send_callback` is invoked. Abort + * the following steps. + * + * 4. If the frame is HEADERS, PUSH_PROMISE or DATA, + * :type:`nghttp2_select_padding_callback` is invoked. + * + * 5. If the frame is request HEADERS, the stream is opened here. + * + * 6. :type:`nghttp2_before_frame_send_callback` is invoked. + * + * 7. If :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL` is returned from + * :type:`nghttp2_before_frame_send_callback`, the current frame + * transmission is canceled, and + * :type:`nghttp2_on_frame_not_send_callback` is invoked. Abort + * the following steps. + * + * 8. :type:`nghttp2_send_callback2` is invoked one or more times to + * send the frame. + * + * 9. :type:`nghttp2_on_frame_send_callback` is invoked. + * + * 10. If the transmission of the frame triggers closure of the + * stream, the stream is closed and + * :type:`nghttp2_on_stream_close_callback` is invoked. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` + * The callback function failed. + */ +NGHTTP2_EXTERN int nghttp2_session_send(nghttp2_session *session); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_session_mem_send2()` instead. + * + * Returns the serialized data to send. + * + * This function behaves like `nghttp2_session_send()` except that it + * does not use :type:`nghttp2_send_callback` to transmit data. + * Instead, it assigns the pointer to the serialized data to the + * |*data_ptr| and returns its length. The other callbacks are called + * in the same way as they are in `nghttp2_session_send()`. + * + * If no data is available to send, this function returns 0. + * + * This function may not return all serialized data in one invocation. + * To get all data, call this function repeatedly until it returns 0 + * or one of negative error codes. + * + * The assigned |*data_ptr| is valid until the next call of + * `nghttp2_session_mem_send()` or `nghttp2_session_send()`. + * + * The caller must send all data before sending the next chunk of + * data. + * + * This function returns the length of the data pointed by the + * |*data_ptr| if it succeeds, or one of the following negative error + * codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * + * .. note:: + * + * This function may produce very small byte string. If that is the + * case, and application disables Nagle algorithm (``TCP_NODELAY``), + * then writing this small chunk leads to very small packet, and it + * is very inefficient. An application should be responsible to + * buffer up small chunks of data as necessary to avoid this + * situation. + */ +NGHTTP2_EXTERN ssize_t nghttp2_session_mem_send(nghttp2_session *session, + const uint8_t **data_ptr); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Returns the serialized data to send. + * + * This function behaves like `nghttp2_session_send()` except that it + * does not use :type:`nghttp2_send_callback2` to transmit data. + * Instead, it assigns the pointer to the serialized data to the + * |*data_ptr| and returns its length. The other callbacks are called + * in the same way as they are in `nghttp2_session_send()`. + * + * If no data is available to send, this function returns 0. + * + * This function may not return all serialized data in one invocation. + * To get all data, call this function repeatedly until it returns 0 + * or one of negative error codes. + * + * The assigned |*data_ptr| is valid until the next call of + * `nghttp2_session_mem_send2()` or `nghttp2_session_send()`. + * + * The caller must send all data before sending the next chunk of + * data. + * + * This function returns the length of the data pointed by the + * |*data_ptr| if it succeeds, or one of the following negative error + * codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * + * .. note:: + * + * This function may produce very small byte string. If that is the + * case, and application disables Nagle algorithm (``TCP_NODELAY``), + * then writing this small chunk leads to very small packet, and it + * is very inefficient. An application should be responsible to + * buffer up small chunks of data as necessary to avoid this + * situation. + */ +NGHTTP2_EXTERN nghttp2_ssize +nghttp2_session_mem_send2(nghttp2_session *session, const uint8_t **data_ptr); + +/** + * @function + * + * Receives frames from the remote peer. + * + * This function receives as many frames as possible until the user + * callback :type:`nghttp2_recv_callback` returns + * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. This function calls + * several callback functions which are passed when initializing the + * |session|. Here is the simple time chart which tells when each + * callback is invoked: + * + * 1. :type:`nghttp2_recv_callback` is invoked one or more times to + * receive frame header. + * + * 2. When frame header is received, + * :type:`nghttp2_on_begin_frame_callback` is invoked. + * + * 3. If the frame is DATA frame: + * + * 1. :type:`nghttp2_recv_callback` is invoked to receive DATA + * payload. For each chunk of data, + * :type:`nghttp2_on_data_chunk_recv_callback` is invoked. + * + * 2. If one DATA frame is completely received, + * :type:`nghttp2_on_frame_recv_callback` is invoked. If the + * reception of the frame triggers the closure of the stream, + * :type:`nghttp2_on_stream_close_callback` is invoked. + * + * 4. If the frame is the control frame: + * + * 1. :type:`nghttp2_recv_callback` is invoked one or more times to + * receive whole frame. + * + * 2. If the received frame is valid, then following actions are + * taken. If the frame is either HEADERS or PUSH_PROMISE, + * :type:`nghttp2_on_begin_headers_callback` is invoked. Then + * :type:`nghttp2_on_header_callback` is invoked for each header + * name/value pair. For invalid header field, + * :type:`nghttp2_on_invalid_header_callback` is called. After + * all name/value pairs are emitted successfully, + * :type:`nghttp2_on_frame_recv_callback` is invoked. For other + * frames, :type:`nghttp2_on_frame_recv_callback` is invoked. + * If the reception of the frame triggers the closure of the + * stream, :type:`nghttp2_on_stream_close_callback` is invoked. + * + * 3. If the received frame is unpacked but is interpreted as + * invalid, :type:`nghttp2_on_invalid_frame_recv_callback` is + * invoked. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_EOF` + * The remote peer did shutdown on the connection. + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` + * The callback function failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_BAD_CLIENT_MAGIC` + * Invalid client magic was detected. This error only returns + * when |session| was configured as server and + * `nghttp2_option_set_no_recv_client_magic()` is not used with + * nonzero value. + * :enum:`nghttp2_error.NGHTTP2_ERR_FLOODED` + * Flooding was detected in this HTTP/2 session, and it must be + * closed. This is most likely caused by misbehaviour of peer. + */ +NGHTTP2_EXTERN int nghttp2_session_recv(nghttp2_session *session); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_session_mem_recv2()` instead. + * + * Processes data |in| as an input from the remote endpoint. The + * |inlen| indicates the number of bytes to receive in the |in|. + * + * This function behaves like `nghttp2_session_recv()` except that it + * does not use :type:`nghttp2_recv_callback` to receive data; the + * |in| is the only data for the invocation of this function. If all + * bytes are processed, this function returns. The other callbacks + * are called in the same way as they are in `nghttp2_session_recv()`. + * + * In the current implementation, this function always tries to + * processes |inlen| bytes of input data unless either an error occurs or + * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` is returned from + * :type:`nghttp2_on_header_callback` or + * :type:`nghttp2_on_data_chunk_recv_callback`. If + * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` is used, the return value + * includes the number of bytes which was used to produce the data or + * frame for the callback. + * + * This function returns the number of processed bytes, or one of the + * following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` + * The callback function failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_BAD_CLIENT_MAGIC` + * Invalid client magic was detected. This error only returns + * when |session| was configured as server and + * `nghttp2_option_set_no_recv_client_magic()` is not used with + * nonzero value. + * :enum:`nghttp2_error.NGHTTP2_ERR_FLOODED` + * Flooding was detected in this HTTP/2 session, and it must be + * closed. This is most likely caused by misbehaviour of peer. + */ +NGHTTP2_EXTERN ssize_t nghttp2_session_mem_recv(nghttp2_session *session, + const uint8_t *in, + size_t inlen); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Processes data |in| as an input from the remote endpoint. The + * |inlen| indicates the number of bytes to receive in the |in|. + * + * This function behaves like `nghttp2_session_recv()` except that it + * does not use :type:`nghttp2_recv_callback` to receive data; the + * |in| is the only data for the invocation of this function. If all + * bytes are processed, this function returns. The other callbacks + * are called in the same way as they are in `nghttp2_session_recv()`. + * + * In the current implementation, this function always tries to + * processes |inlen| bytes of input data unless either an error occurs or + * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` is returned from + * :type:`nghttp2_on_header_callback` or + * :type:`nghttp2_on_data_chunk_recv_callback`. If + * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` is used, the return value + * includes the number of bytes which was used to produce the data or + * frame for the callback. + * + * This function returns the number of processed bytes, or one of the + * following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` + * The callback function failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_BAD_CLIENT_MAGIC` + * Invalid client magic was detected. This error only returns + * when |session| was configured as server and + * `nghttp2_option_set_no_recv_client_magic()` is not used with + * nonzero value. + * :enum:`nghttp2_error.NGHTTP2_ERR_FLOODED` + * Flooding was detected in this HTTP/2 session, and it must be + * closed. This is most likely caused by misbehaviour of peer. + */ +NGHTTP2_EXTERN nghttp2_ssize nghttp2_session_mem_recv2(nghttp2_session *session, + const uint8_t *in, + size_t inlen); + +/** + * @function + * + * Puts back previously deferred DATA frame in the stream |stream_id| + * to the outbound queue. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The stream does not exist; or no deferred data exist. + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_session_resume_data(nghttp2_session *session, + int32_t stream_id); + +/** + * @function + * + * Returns nonzero value if |session| wants to receive data from the + * remote peer. + * + * If both `nghttp2_session_want_read()` and + * `nghttp2_session_want_write()` return 0, the application should + * drop the connection. + */ +NGHTTP2_EXTERN int nghttp2_session_want_read(nghttp2_session *session); + +/** + * @function + * + * Returns nonzero value if |session| wants to send data to the remote + * peer. + * + * If both `nghttp2_session_want_read()` and + * `nghttp2_session_want_write()` return 0, the application should + * drop the connection. + */ +NGHTTP2_EXTERN int nghttp2_session_want_write(nghttp2_session *session); + +/** + * @function + * + * Returns stream_user_data for the stream |stream_id|. The + * stream_user_data is provided by `nghttp2_submit_request2()`, + * `nghttp2_submit_headers()` or + * `nghttp2_session_set_stream_user_data()`. Unless it is set using + * `nghttp2_session_set_stream_user_data()`, if the stream is + * initiated by the remote endpoint, stream_user_data is always + * ``NULL``. If the stream does not exist, this function returns + * ``NULL``. + */ +NGHTTP2_EXTERN void * +nghttp2_session_get_stream_user_data(nghttp2_session *session, + int32_t stream_id); + +/** + * @function + * + * Sets the |stream_user_data| to the stream denoted by the + * |stream_id|. If a stream user data is already set to the stream, + * it is replaced with the |stream_user_data|. It is valid to specify + * ``NULL`` in the |stream_user_data|, which nullifies the associated + * data pointer. + * + * It is valid to set the |stream_user_data| to the stream reserved by + * PUSH_PROMISE frame. + * + * This function returns 0 if it succeeds, or one of following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The stream does not exist + */ +NGHTTP2_EXTERN int +nghttp2_session_set_stream_user_data(nghttp2_session *session, + int32_t stream_id, void *stream_user_data); + +/** + * @function + * + * Sets |user_data| to |session|, overwriting the existing user data + * specified in `nghttp2_session_client_new()`, or + * `nghttp2_session_server_new()`. + */ +NGHTTP2_EXTERN void nghttp2_session_set_user_data(nghttp2_session *session, + void *user_data); + +/** + * @function + * + * Returns the number of frames in the outbound queue. This does not + * include the deferred DATA frames. + */ +NGHTTP2_EXTERN size_t +nghttp2_session_get_outbound_queue_size(nghttp2_session *session); + +/** + * @function + * + * Returns the number of DATA payload in bytes received without + * WINDOW_UPDATE transmission for the stream |stream_id|. The local + * (receive) window size can be adjusted by + * `nghttp2_submit_window_update()`. This function takes into account + * that and returns effective data length. In particular, if the + * local window size is reduced by submitting negative + * window_size_increment with `nghttp2_submit_window_update()`, this + * function returns the number of bytes less than actually received. + * + * This function returns -1 if it fails. + */ +NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_recv_data_length( + nghttp2_session *session, int32_t stream_id); + +/** + * @function + * + * Returns the local (receive) window size for the stream |stream_id|. + * The local window size can be adjusted by + * `nghttp2_submit_window_update()`. This function takes into account + * that and returns effective window size. + * + * This function does not take into account the amount of received + * data from the remote endpoint. Use + * `nghttp2_session_get_stream_local_window_size()` to know the amount + * of data the remote endpoint can send without receiving stream level + * WINDOW_UPDATE frame. Note that each stream is still subject to the + * connection level flow control. + * + * This function returns -1 if it fails. + */ +NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_local_window_size( + nghttp2_session *session, int32_t stream_id); + +/** + * @function + * + * Returns the amount of flow-controlled payload (e.g., DATA) that the + * remote endpoint can send without receiving stream level + * WINDOW_UPDATE frame. It is also subject to the connection level + * flow control. So the actual amount of data to send is + * min(`nghttp2_session_get_stream_local_window_size()`, + * `nghttp2_session_get_local_window_size()`). + * + * This function returns -1 if it fails. + */ +NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_local_window_size( + nghttp2_session *session, int32_t stream_id); + +/** + * @function + * + * Returns the number of DATA payload in bytes received without + * WINDOW_UPDATE transmission for a connection. The local (receive) + * window size can be adjusted by `nghttp2_submit_window_update()`. + * This function takes into account that and returns effective data + * length. In particular, if the local window size is reduced by + * submitting negative window_size_increment with + * `nghttp2_submit_window_update()`, this function returns the number + * of bytes less than actually received. + * + * This function returns -1 if it fails. + */ +NGHTTP2_EXTERN int32_t +nghttp2_session_get_effective_recv_data_length(nghttp2_session *session); + +/** + * @function + * + * Returns the local (receive) window size for a connection. The + * local window size can be adjusted by + * `nghttp2_submit_window_update()`. This function takes into account + * that and returns effective window size. + * + * This function does not take into account the amount of received + * data from the remote endpoint. Use + * `nghttp2_session_get_local_window_size()` to know the amount of + * data the remote endpoint can send without receiving + * connection-level WINDOW_UPDATE frame. Note that each stream is + * still subject to the stream level flow control. + * + * This function returns -1 if it fails. + */ +NGHTTP2_EXTERN int32_t +nghttp2_session_get_effective_local_window_size(nghttp2_session *session); + +/** + * @function + * + * Returns the amount of flow-controlled payload (e.g., DATA) that the + * remote endpoint can send without receiving connection level + * WINDOW_UPDATE frame. Note that each stream is still subject to the + * stream level flow control (see + * `nghttp2_session_get_stream_local_window_size()`). + * + * This function returns -1 if it fails. + */ +NGHTTP2_EXTERN int32_t +nghttp2_session_get_local_window_size(nghttp2_session *session); + +/** + * @function + * + * Returns the remote window size for a given stream |stream_id|. + * + * This is the amount of flow-controlled payload (e.g., DATA) that the + * local endpoint can send without stream level WINDOW_UPDATE. There + * is also connection level flow control, so the effective size of + * payload that the local endpoint can actually send is + * min(`nghttp2_session_get_stream_remote_window_size()`, + * `nghttp2_session_get_remote_window_size()`). + * + * This function returns -1 if it fails. + */ +NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_remote_window_size( + nghttp2_session *session, int32_t stream_id); + +/** + * @function + * + * Returns the remote window size for a connection. + * + * This function always succeeds. + */ +NGHTTP2_EXTERN int32_t +nghttp2_session_get_remote_window_size(nghttp2_session *session); + +/** + * @function + * + * Returns 1 if local peer half closed the given stream |stream_id|. + * Returns 0 if it did not. Returns -1 if no such stream exists. + */ +NGHTTP2_EXTERN int +nghttp2_session_get_stream_local_close(nghttp2_session *session, + int32_t stream_id); + +/** + * @function + * + * Returns 1 if remote peer half closed the given stream |stream_id|. + * Returns 0 if it did not. Returns -1 if no such stream exists. + */ +NGHTTP2_EXTERN int +nghttp2_session_get_stream_remote_close(nghttp2_session *session, + int32_t stream_id); + +/** + * @function + * + * Returns the current dynamic table size of HPACK inflater, including + * the overhead 32 bytes per entry described in RFC 7541. + */ +NGHTTP2_EXTERN size_t +nghttp2_session_get_hd_inflate_dynamic_table_size(nghttp2_session *session); + +/** + * @function + * + * Returns the current dynamic table size of HPACK deflater including + * the overhead 32 bytes per entry described in RFC 7541. + */ +NGHTTP2_EXTERN size_t +nghttp2_session_get_hd_deflate_dynamic_table_size(nghttp2_session *session); + +/** + * @function + * + * Signals the session so that the connection should be terminated. + * + * The last stream ID is the minimum value between the stream ID of a + * stream for which :type:`nghttp2_on_frame_recv_callback` was called + * most recently and the last stream ID we have sent to the peer + * previously. + * + * The |error_code| is the error code of this GOAWAY frame. The + * pre-defined error code is one of :enum:`nghttp2_error_code`. + * + * After the transmission, both `nghttp2_session_want_read()` and + * `nghttp2_session_want_write()` return 0. + * + * This function should be called when the connection should be + * terminated after sending GOAWAY. If the remaining streams should + * be processed after GOAWAY, use `nghttp2_submit_goaway()` instead. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_session_terminate_session(nghttp2_session *session, + uint32_t error_code); + +/** + * @function + * + * Signals the session so that the connection should be terminated. + * + * This function behaves like `nghttp2_session_terminate_session()`, + * but the last stream ID can be specified by the application for fine + * grained control of stream. The HTTP/2 specification does not allow + * last_stream_id to be increased. So the actual value sent as + * last_stream_id is the minimum value between the given + * |last_stream_id| and the last_stream_id we have previously sent to + * the peer. + * + * The |last_stream_id| is peer's stream ID or 0. So if |session| is + * initialized as client, |last_stream_id| must be even or 0. If + * |session| is initialized as server, |last_stream_id| must be odd or + * 0. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |last_stream_id| is invalid. + */ +NGHTTP2_EXTERN int nghttp2_session_terminate_session2(nghttp2_session *session, + int32_t last_stream_id, + uint32_t error_code); + +/** + * @function + * + * Signals to the client that the server started graceful shutdown + * procedure. + * + * This function is only usable for server. If this function is + * called with client side session, this function returns + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. + * + * To gracefully shutdown HTTP/2 session, server should call this + * function to send GOAWAY with last_stream_id (1u << 31) - 1. And + * after some delay (e.g., 1 RTT), send another GOAWAY with the stream + * ID that the server has some processing using + * `nghttp2_submit_goaway()`. See also + * `nghttp2_session_get_last_proc_stream_id()`. + * + * Unlike `nghttp2_submit_goaway()`, this function just sends GOAWAY + * and does nothing more. This is a mere indication to the client + * that session shutdown is imminent. The application should call + * `nghttp2_submit_goaway()` with appropriate last_stream_id after + * this call. + * + * If one or more GOAWAY frame have been already sent by either + * `nghttp2_submit_goaway()` or `nghttp2_session_terminate_session()`, + * this function has no effect. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The |session| is initialized as client. + */ +NGHTTP2_EXTERN int nghttp2_submit_shutdown_notice(nghttp2_session *session); + +/** + * @function + * + * Returns the value of SETTINGS |id| notified by a remote endpoint. + * The |id| must be one of values defined in + * :enum:`nghttp2_settings_id`. + */ +NGHTTP2_EXTERN uint32_t nghttp2_session_get_remote_settings( + nghttp2_session *session, nghttp2_settings_id id); + +/** + * @function + * + * Returns the value of SETTINGS |id| of local endpoint acknowledged + * by the remote endpoint. The |id| must be one of the values defined + * in :enum:`nghttp2_settings_id`. + */ +NGHTTP2_EXTERN uint32_t nghttp2_session_get_local_settings( + nghttp2_session *session, nghttp2_settings_id id); + +/** + * @function + * + * Tells the |session| that next stream ID is |next_stream_id|. The + * |next_stream_id| must be equal or greater than the value returned + * by `nghttp2_session_get_next_stream_id()`. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |next_stream_id| is strictly less than the value + * `nghttp2_session_get_next_stream_id()` returns; or + * |next_stream_id| is invalid (e.g., even integer for client, or + * odd integer for server). + */ +NGHTTP2_EXTERN int nghttp2_session_set_next_stream_id(nghttp2_session *session, + int32_t next_stream_id); + +/** + * @function + * + * Returns the next outgoing stream ID. Notice that return type is + * uint32_t. If we run out of stream ID for this session, this + * function returns 1 << 31. + */ +NGHTTP2_EXTERN uint32_t +nghttp2_session_get_next_stream_id(nghttp2_session *session); + +/** + * @function + * + * Tells the |session| that |size| bytes for a stream denoted by + * |stream_id| were consumed by application and are ready to + * WINDOW_UPDATE. The consumed bytes are counted towards both + * connection and stream level WINDOW_UPDATE (see + * `nghttp2_session_consume_connection()` and + * `nghttp2_session_consume_stream()` to update consumption + * independently). This function is intended to be used without + * automatic window update (see + * `nghttp2_option_set_no_auto_window_update()`). + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * Automatic WINDOW_UPDATE is not disabled. + */ +NGHTTP2_EXTERN int nghttp2_session_consume(nghttp2_session *session, + int32_t stream_id, size_t size); + +/** + * @function + * + * Like `nghttp2_session_consume()`, but this only tells library that + * |size| bytes were consumed only for connection level. Note that + * HTTP/2 maintains connection and stream level flow control windows + * independently. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * Automatic WINDOW_UPDATE is not disabled. + */ +NGHTTP2_EXTERN int nghttp2_session_consume_connection(nghttp2_session *session, + size_t size); + +/** + * @function + * + * Like `nghttp2_session_consume()`, but this only tells library that + * |size| bytes were consumed only for stream denoted by |stream_id|. + * Note that HTTP/2 maintains connection and stream level flow control + * windows independently. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * Automatic WINDOW_UPDATE is not disabled. + */ +NGHTTP2_EXTERN int nghttp2_session_consume_stream(nghttp2_session *session, + int32_t stream_id, + size_t size); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function is noop. It always returns 0. + */ +NGHTTP2_EXTERN int +nghttp2_session_change_stream_priority(nghttp2_session *session, + int32_t stream_id, + const nghttp2_priority_spec *pri_spec); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function is noop. It always returns 0. + */ +NGHTTP2_EXTERN int +nghttp2_session_create_idle_stream(nghttp2_session *session, int32_t stream_id, + const nghttp2_priority_spec *pri_spec); + +/** + * @function + * + * .. warning:: + * + * This function is deprecated in favor of + * `nghttp2_session_upgrade2()`, because this function lacks the + * parameter to tell the library the request method used in the + * original HTTP request. This information is required for client + * to validate actual response body length against content-length + * header field (see `nghttp2_option_set_no_http_messaging()`). If + * HEAD is used in request, the length of response body must be 0 + * regardless of value included in content-length header field. + * + * Performs post-process of HTTP Upgrade request. This function can + * be called from both client and server, but the behavior is very + * different in each other. + * + * If called from client side, the |settings_payload| must be the + * value sent in ``HTTP2-Settings`` header field and must be decoded + * by base64url decoder. The |settings_payloadlen| is the length of + * |settings_payload|. The |settings_payload| is unpacked and its + * setting values will be submitted using `nghttp2_submit_settings()`. + * This means that the client application code does not need to submit + * SETTINGS by itself. The stream with stream ID=1 is opened and the + * |stream_user_data| is used for its stream_user_data. The opened + * stream becomes half-closed (local) state. + * + * If called from server side, the |settings_payload| must be the + * value received in ``HTTP2-Settings`` header field and must be + * decoded by base64url decoder. The |settings_payloadlen| is the + * length of |settings_payload|. It is treated as if the SETTINGS + * frame with that payload is received. Thus, callback functions for + * the reception of SETTINGS frame will be invoked. The stream with + * stream ID=1 is opened. The |stream_user_data| is ignored. The + * opened stream becomes half-closed (remote). + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |settings_payload| is badly formed. + * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The stream ID 1 is already used or closed; or is not available. + */ +NGHTTP2_EXTERN int nghttp2_session_upgrade(nghttp2_session *session, + const uint8_t *settings_payload, + size_t settings_payloadlen, + void *stream_user_data); + +/** + * @function + * + * Performs post-process of HTTP Upgrade request. This function can + * be called from both client and server, but the behavior is very + * different in each other. + * + * If called from client side, the |settings_payload| must be the + * value sent in ``HTTP2-Settings`` header field and must be decoded + * by base64url decoder. The |settings_payloadlen| is the length of + * |settings_payload|. The |settings_payload| is unpacked and its + * setting values will be submitted using `nghttp2_submit_settings()`. + * This means that the client application code does not need to submit + * SETTINGS by itself. The stream with stream ID=1 is opened and the + * |stream_user_data| is used for its stream_user_data. The opened + * stream becomes half-closed (local) state. + * + * If called from server side, the |settings_payload| must be the + * value received in ``HTTP2-Settings`` header field and must be + * decoded by base64url decoder. The |settings_payloadlen| is the + * length of |settings_payload|. It is treated as if the SETTINGS + * frame with that payload is received. Thus, callback functions for + * the reception of SETTINGS frame will be invoked. The stream with + * stream ID=1 is opened. The |stream_user_data| is ignored. The + * opened stream becomes half-closed (remote). + * + * If the request method is HEAD, pass nonzero value to + * |head_request|. Otherwise, pass 0. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |settings_payload| is badly formed. + * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The stream ID 1 is already used or closed; or is not available. + */ +NGHTTP2_EXTERN int nghttp2_session_upgrade2(nghttp2_session *session, + const uint8_t *settings_payload, + size_t settings_payloadlen, + int head_request, + void *stream_user_data); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_pack_settings_payload2()` instead. + * + * Serializes the SETTINGS values |iv| in the |buf|. The size of the + * |buf| is specified by |buflen|. The number of entries in the |iv| + * array is given by |niv|. The required space in |buf| for the |niv| + * entries is ``6*niv`` bytes and if the given buffer is too small, an + * error is returned. This function is used mainly for creating a + * SETTINGS payload to be sent with the ``HTTP2-Settings`` header + * field in an HTTP Upgrade request. The data written in |buf| is NOT + * base64url encoded and the application is responsible for encoding. + * + * This function returns the number of bytes written in |buf|, or one + * of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |iv| contains duplicate settings ID or invalid value. + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ +NGHTTP2_EXTERN ssize_t nghttp2_pack_settings_payload( + uint8_t *buf, size_t buflen, const nghttp2_settings_entry *iv, size_t niv); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Serializes the SETTINGS values |iv| in the |buf|. The size of the + * |buf| is specified by |buflen|. The number of entries in the |iv| + * array is given by |niv|. The required space in |buf| for the |niv| + * entries is ``6*niv`` bytes and if the given buffer is too small, an + * error is returned. This function is used mainly for creating a + * SETTINGS payload to be sent with the ``HTTP2-Settings`` header + * field in an HTTP Upgrade request. The data written in |buf| is NOT + * base64url encoded and the application is responsible for encoding. + * + * This function returns the number of bytes written in |buf|, or one + * of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |iv| contains duplicate settings ID or invalid value. + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ +NGHTTP2_EXTERN nghttp2_ssize nghttp2_pack_settings_payload2( + uint8_t *buf, size_t buflen, const nghttp2_settings_entry *iv, size_t niv); + +/** + * @function + * + * Returns string describing the |lib_error_code|. The + * |lib_error_code| must be one of the :enum:`nghttp2_error`. + */ +NGHTTP2_EXTERN const char *nghttp2_strerror(int lib_error_code); + +/** + * @function + * + * Returns string representation of HTTP/2 error code |error_code| + * (e.g., ``PROTOCOL_ERROR`` is returned if ``error_code == + * NGHTTP2_PROTOCOL_ERROR``). If string representation is unknown for + * given |error_code|, this function returns string ``unknown``. + */ +NGHTTP2_EXTERN const char *nghttp2_http2_strerror(uint32_t error_code); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * Initializes |pri_spec| with the |stream_id| of the stream to depend + * on with |weight| and its exclusive flag. If |exclusive| is + * nonzero, exclusive flag is set. + * + * The |weight| must be in [:macro:`NGHTTP2_MIN_WEIGHT`, + * :macro:`NGHTTP2_MAX_WEIGHT`], inclusive. + */ +NGHTTP2_EXTERN void nghttp2_priority_spec_init(nghttp2_priority_spec *pri_spec, + int32_t stream_id, + int32_t weight, int exclusive); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * Initializes |pri_spec| with the default values. The default values + * are: stream_id = 0, weight = :macro:`NGHTTP2_DEFAULT_WEIGHT` and + * exclusive = 0. + */ +NGHTTP2_EXTERN void +nghttp2_priority_spec_default_init(nghttp2_priority_spec *pri_spec); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * Returns nonzero if the |pri_spec| is filled with default values. + */ +NGHTTP2_EXTERN int +nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_submit_request2()` instead. + * + * Submits HEADERS frame and optionally one or more DATA frames. + * + * The |pri_spec| is ignored. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application is responsible to include + * required pseudo-header fields (header field whose name starts with + * ":") in |nva| and must place pseudo-headers before regular header + * fields. + * + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, + * header field name and value are not copied respectively. With + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application + * is responsible to pass header field name in lowercase. The + * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * + * HTTP/2 specification has requirement about header fields in the + * request HEADERS. See the specification for more details. + * + * If |data_prd| is not ``NULL``, it provides data which will be sent + * in subsequent DATA frames. In this case, a method that allows + * request message bodies + * (https://tools.ietf.org/html/rfc7231#section-4) must be specified + * with ``:method`` key in |nva| (e.g. ``POST``). This function does + * not take ownership of the |data_prd|. The function copies the + * members of the |data_prd|. If |data_prd| is ``NULL``, HEADERS have + * END_STREAM set. The |stream_user_data| is data associated to the + * stream opened by this request and can be an arbitrary pointer, + * which can be retrieved later by + * `nghttp2_session_get_stream_user_data()`. + * + * This function returns assigned stream ID if it succeeds, or one of + * the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` + * No stream ID is available because maximum stream ID was + * reached. + * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The |session| is server session. + * + * .. warning:: + * + * This function returns assigned stream ID if it succeeds. But + * that stream is not created yet. The application must not submit + * frame to that stream ID before + * :type:`nghttp2_before_frame_send_callback` is called for this + * frame. This means `nghttp2_session_get_stream_user_data()` does + * not work before the callback. But + * `nghttp2_session_set_stream_user_data()` handles this situation + * specially, and it can set data to a stream during this period. + * + */ +NGHTTP2_EXTERN int32_t nghttp2_submit_request( + nghttp2_session *session, const nghttp2_priority_spec *pri_spec, + const nghttp2_nv *nva, size_t nvlen, const nghttp2_data_provider *data_prd, + void *stream_user_data); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Submits HEADERS frame and optionally one or more DATA frames. + * + * The |pri_spec| is ignored. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application is responsible to include + * required pseudo-header fields (header field whose name starts with + * ":") in |nva| and must place pseudo-headers before regular header + * fields. + * + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, + * header field name and value are not copied respectively. With + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application + * is responsible to pass header field name in lowercase. The + * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * + * HTTP/2 specification has requirement about header fields in the + * request HEADERS. See the specification for more details. + * + * If |data_prd| is not ``NULL``, it provides data which will be sent + * in subsequent DATA frames. In this case, a method that allows + * request message bodies + * (https://tools.ietf.org/html/rfc7231#section-4) must be specified + * with ``:method`` key in |nva| (e.g. ``POST``). This function does + * not take ownership of the |data_prd|. The function copies the + * members of the |data_prd|. If |data_prd| is ``NULL``, HEADERS have + * END_STREAM set. The |stream_user_data| is data associated to the + * stream opened by this request and can be an arbitrary pointer, + * which can be retrieved later by + * `nghttp2_session_get_stream_user_data()`. + * + * This function returns assigned stream ID if it succeeds, or one of + * the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` + * No stream ID is available because maximum stream ID was + * reached. + * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The |session| is server session. + * + * .. warning:: + * + * This function returns assigned stream ID if it succeeds. But + * that stream is not created yet. The application must not submit + * frame to that stream ID before + * :type:`nghttp2_before_frame_send_callback` is called for this + * frame. This means `nghttp2_session_get_stream_user_data()` does + * not work before the callback. But + * `nghttp2_session_set_stream_user_data()` handles this situation + * specially, and it can set data to a stream during this period. + * + */ +NGHTTP2_EXTERN int32_t nghttp2_submit_request2( + nghttp2_session *session, const nghttp2_priority_spec *pri_spec, + const nghttp2_nv *nva, size_t nvlen, const nghttp2_data_provider2 *data_prd, + void *stream_user_data); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_submit_response2()` instead. + * + * Submits response HEADERS frame and optionally one or more DATA + * frames against the stream |stream_id|. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application is responsible to include + * required pseudo-header fields (header field whose name starts with + * ":") in |nva| and must place pseudo-headers before regular header + * fields. + * + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, + * header field name and value are not copied respectively. With + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application + * is responsible to pass header field name in lowercase. The + * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * + * HTTP/2 specification has requirement about header fields in the + * response HEADERS. See the specification for more details. + * + * If |data_prd| is not ``NULL``, it provides data which will be sent + * in subsequent DATA frames. This function does not take ownership + * of the |data_prd|. The function copies the members of the + * |data_prd|. If |data_prd| is ``NULL``, HEADERS will have + * END_STREAM flag set. + * + * This method can be used as normal HTTP response and push response. + * When pushing a resource using this function, the |session| must be + * configured using `nghttp2_session_server_new()` or its variants and + * the target stream denoted by the |stream_id| must be reserved using + * `nghttp2_submit_push_promise()`. + * + * To send non-final response headers (e.g., HTTP status 101), don't + * use this function because this function half-closes the outbound + * stream. Instead, use `nghttp2_submit_headers()` for this purpose. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` + * DATA or HEADERS has been already submitted and not fully + * processed yet. Normally, this does not happen, but when + * application wrongly calls `nghttp2_submit_response()` twice, + * this may happen. + * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The |session| is client session. + * + * .. warning:: + * + * Calling this function twice for the same stream ID may lead to + * program crash. It is generally considered to a programming error + * to commit response twice. + */ +NGHTTP2_EXTERN int +nghttp2_submit_response(nghttp2_session *session, int32_t stream_id, + const nghttp2_nv *nva, size_t nvlen, + const nghttp2_data_provider *data_prd); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Submits response HEADERS frame and optionally one or more DATA + * frames against the stream |stream_id|. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application is responsible to include + * required pseudo-header fields (header field whose name starts with + * ":") in |nva| and must place pseudo-headers before regular header + * fields. + * + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, + * header field name and value are not copied respectively. With + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application + * is responsible to pass header field name in lowercase. The + * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * + * HTTP/2 specification has requirement about header fields in the + * response HEADERS. See the specification for more details. + * + * If |data_prd| is not ``NULL``, it provides data which will be sent + * in subsequent DATA frames. This function does not take ownership + * of the |data_prd|. The function copies the members of the + * |data_prd|. If |data_prd| is ``NULL``, HEADERS will have + * END_STREAM flag set. + * + * This method can be used as normal HTTP response and push response. + * When pushing a resource using this function, the |session| must be + * configured using `nghttp2_session_server_new()` or its variants and + * the target stream denoted by the |stream_id| must be reserved using + * `nghttp2_submit_push_promise()`. + * + * To send non-final response headers (e.g., HTTP status 101), don't + * use this function because this function half-closes the outbound + * stream. Instead, use `nghttp2_submit_headers()` for this purpose. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` + * DATA or HEADERS has been already submitted and not fully + * processed yet. Normally, this does not happen, but when + * application wrongly calls `nghttp2_submit_response2()` twice, + * this may happen. + * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The |session| is client session. + * + * .. warning:: + * + * Calling this function twice for the same stream ID may lead to + * program crash. It is generally considered to a programming error + * to commit response twice. + */ +NGHTTP2_EXTERN int +nghttp2_submit_response2(nghttp2_session *session, int32_t stream_id, + const nghttp2_nv *nva, size_t nvlen, + const nghttp2_data_provider2 *data_prd); + +/** + * @function + * + * Submits trailer fields HEADERS against the stream |stream_id|. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application must not include pseudo-header + * fields (headers whose names starts with ":") in |nva|. + * + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, + * header field name and value are not copied respectively. With + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application + * is responsible to pass header field name in lowercase. The + * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * + * For server, trailer fields must follow response HEADERS or response + * DATA without END_STREAM flat set. The library does not enforce + * this requirement, and applications should do this for themselves. + * If `nghttp2_submit_trailer()` is called before any response HEADERS + * submission (usually by `nghttp2_submit_response2()`), the content + * of |nva| will be sent as response headers, which will result in + * error. + * + * This function has the same effect with `nghttp2_submit_headers()`, + * with flags = :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` and both + * pri_spec and stream_user_data to NULL. + * + * To submit trailer fields after `nghttp2_submit_response2()` is + * called, the application has to specify + * :type:`nghttp2_data_provider2` to `nghttp2_submit_response2()`. + * Inside of :type:`nghttp2_data_source_read_callback2`, when setting + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF`, also set + * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_END_STREAM`. After + * that, the application can send trailer fields using + * `nghttp2_submit_trailer()`. `nghttp2_submit_trailer()` can be used + * inside :type:`nghttp2_data_source_read_callback2`. + * + * This function returns 0 if it succeeds and |stream_id| is -1. + * Otherwise, this function returns 0 if it succeeds, or one of the + * following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + */ +NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session, + int32_t stream_id, + const nghttp2_nv *nva, size_t nvlen); + +/** + * @function + * + * Submits HEADERS frame. The |flags| is bitwise OR of the + * following values: + * + * * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` + * + * If |flags| includes :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM`, + * this frame has END_STREAM flag set. + * + * The library handles the CONTINUATION frame internally and it + * correctly sets END_HEADERS to the last sequence of the PUSH_PROMISE + * or CONTINUATION frame. + * + * If the |stream_id| is -1, this frame is assumed as request (i.e., + * request HEADERS frame which opens new stream). In this case, the + * assigned stream ID will be returned. Otherwise, specify stream ID + * in |stream_id|. + * + * The |pri_spec| is ignored. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application is responsible to include + * required pseudo-header fields (header field whose name starts with + * ":") in |nva| and must place pseudo-headers before regular header + * fields. + * + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, + * header field name and value are not copied respectively. With + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application + * is responsible to pass header field name in lowercase. The + * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * + * The |stream_user_data| is a pointer to an arbitrary data which is + * associated to the stream this frame will open. Therefore it is + * only used if this frame opens streams, in other words, it changes + * stream state from idle or reserved to open. + * + * This function is low-level in a sense that the application code can + * specify flags directly. For usual HTTP request, + * `nghttp2_submit_request2()` is useful. Likewise, for HTTP + * response, prefer `nghttp2_submit_response2()`. + * + * This function returns newly assigned stream ID if it succeeds and + * |stream_id| is -1. Otherwise, this function returns 0 if it + * succeeds, or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` + * No stream ID is available because maximum stream ID was + * reached. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` + * DATA or HEADERS has been already submitted and not fully + * processed yet. This happens if stream denoted by |stream_id| + * is in reserved state. + * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The |stream_id| is -1, and |session| is server session. + * + * .. warning:: + * + * This function returns assigned stream ID if it succeeds and + * |stream_id| is -1. But that stream is not opened yet. The + * application must not submit frame to that stream ID before + * :type:`nghttp2_before_frame_send_callback` is called for this + * frame. + * + */ +NGHTTP2_EXTERN int32_t nghttp2_submit_headers( + nghttp2_session *session, uint8_t flags, int32_t stream_id, + const nghttp2_priority_spec *pri_spec, const nghttp2_nv *nva, size_t nvlen, + void *stream_user_data); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_submit_data2()` instead. + * + * Submits one or more DATA frames to the stream |stream_id|. The + * data to be sent are provided by |data_prd|. If |flags| contains + * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM`, the last DATA frame + * has END_STREAM flag set. + * + * This function does not take ownership of the |data_prd|. The + * function copies the members of the |data_prd|. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` + * DATA or HEADERS has been already submitted and not fully + * processed yet. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_CLOSED` + * The stream was already closed; or the |stream_id| is invalid. + * + * .. note:: + * + * Currently, only one DATA or HEADERS is allowed for a stream at a + * time. Submitting these frames more than once before first DATA + * or HEADERS is finished results in + * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` error code. The + * earliest callback which tells that previous frame is done is + * :type:`nghttp2_on_frame_send_callback`. In side that callback, + * new data can be submitted using `nghttp2_submit_data()`. Of + * course, all data except for last one must not have + * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` flag set in |flags|. + * This sounds a bit complicated, and we recommend to use + * `nghttp2_submit_request()` and `nghttp2_submit_response()` to + * avoid this cascading issue. The experience shows that for HTTP + * use, these two functions are enough to implement both client and + * server. + */ +NGHTTP2_EXTERN int nghttp2_submit_data(nghttp2_session *session, uint8_t flags, + int32_t stream_id, + const nghttp2_data_provider *data_prd); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Submits one or more DATA frames to the stream |stream_id|. The + * data to be sent are provided by |data_prd|. If |flags| contains + * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM`, the last DATA frame + * has END_STREAM flag set. + * + * This function does not take ownership of the |data_prd|. The + * function copies the members of the |data_prd|. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` + * DATA or HEADERS has been already submitted and not fully + * processed yet. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_CLOSED` + * The stream was already closed; or the |stream_id| is invalid. + * + * .. note:: + * + * Currently, only one DATA or HEADERS is allowed for a stream at a + * time. Submitting these frames more than once before first DATA + * or HEADERS is finished results in + * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` error code. The + * earliest callback which tells that previous frame is done is + * :type:`nghttp2_on_frame_send_callback`. In side that callback, + * new data can be submitted using `nghttp2_submit_data2()`. Of + * course, all data except for last one must not have + * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` flag set in |flags|. + * This sounds a bit complicated, and we recommend to use + * `nghttp2_submit_request2()` and `nghttp2_submit_response2()` to + * avoid this cascading issue. The experience shows that for HTTP + * use, these two functions are enough to implement both client and + * server. + */ +NGHTTP2_EXTERN int nghttp2_submit_data2(nghttp2_session *session, uint8_t flags, + int32_t stream_id, + const nghttp2_data_provider2 *data_prd); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function is noop. It always returns 0. + */ +NGHTTP2_EXTERN int +nghttp2_submit_priority(nghttp2_session *session, uint8_t flags, + int32_t stream_id, + const nghttp2_priority_spec *pri_spec); + +/** + * @macro + * + * :macro:`NGHTTP2_EXTPRI_DEFAULT_URGENCY` is the default urgency + * level for :rfc:`9218` extensible priorities. + */ +#define NGHTTP2_EXTPRI_DEFAULT_URGENCY 3 + +/** + * @macro + * + * :macro:`NGHTTP2_EXTPRI_URGENCY_HIGH` is the highest urgency level + * for :rfc:`9218` extensible priorities. + */ +#define NGHTTP2_EXTPRI_URGENCY_HIGH 0 + +/** + * @macro + * + * :macro:`NGHTTP2_EXTPRI_URGENCY_LOW` is the lowest urgency level for + * :rfc:`9218` extensible priorities. + */ +#define NGHTTP2_EXTPRI_URGENCY_LOW 7 + +/** + * @macro + * + * :macro:`NGHTTP2_EXTPRI_URGENCY_LEVELS` is the number of urgency + * levels for :rfc:`9218` extensible priorities. + */ +#define NGHTTP2_EXTPRI_URGENCY_LEVELS (NGHTTP2_EXTPRI_URGENCY_LOW + 1) + +/** + * @struct + * + * :type:`nghttp2_extpri` is :rfc:`9218` extensible priorities + * specification for a stream. + */ +typedef struct nghttp2_extpri { + /** + * :member:`urgency` is the urgency of a stream, it must be in + * [:macro:`NGHTTP2_EXTPRI_URGENCY_HIGH`, + * :macro:`NGHTTP2_EXTPRI_URGENCY_LOW`], inclusive, and 0 is the + * highest urgency. + */ + uint32_t urgency; + /** + * :member:`inc` indicates that a content can be processed + * incrementally or not. If inc is 0, it cannot be processed + * incrementally. If inc is 1, it can be processed incrementally. + * Other value is not permitted. + */ + int inc; +} nghttp2_extpri; + +/** + * @function + * + * Submits RST_STREAM frame to cancel/reject the stream |stream_id| + * with the error code |error_code|. + * + * The pre-defined error code is one of :enum:`nghttp2_error_code`. + * + * The |flags| is currently ignored and should be + * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + */ +NGHTTP2_EXTERN int nghttp2_submit_rst_stream(nghttp2_session *session, + uint8_t flags, int32_t stream_id, + uint32_t error_code); + +/** + * @function + * + * Stores local settings and submits SETTINGS frame. The |iv| is the + * pointer to the array of :type:`nghttp2_settings_entry`. The |niv| + * indicates the number of :type:`nghttp2_settings_entry`. + * + * The |flags| is currently ignored and should be + * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * This function does not take ownership of the |iv|. This function + * copies all the elements in the |iv|. + * + * While updating individual stream's local window size, if the window + * size becomes strictly larger than NGHTTP2_MAX_WINDOW_SIZE, + * RST_STREAM is issued against such a stream. + * + * SETTINGS with :enum:`nghttp2_flag.NGHTTP2_FLAG_ACK` is + * automatically submitted by the library and application could not + * send it at its will. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |iv| contains invalid value (e.g., initial window size + * strictly greater than (1 << 31) - 1. + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_submit_settings(nghttp2_session *session, + uint8_t flags, + const nghttp2_settings_entry *iv, + size_t niv); + +/** + * @function + * + * Submits PUSH_PROMISE frame. + * + * The |flags| is currently ignored. The library handles the + * CONTINUATION frame internally and it correctly sets END_HEADERS to + * the last sequence of the PUSH_PROMISE or CONTINUATION frame. + * + * The |stream_id| must be client initiated stream ID. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application is responsible to include + * required pseudo-header fields (header field whose name starts with + * ":") in |nva| and must place pseudo-headers before regular header + * fields. + * + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, + * header field name and value are not copied respectively. With + * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application + * is responsible to pass header field name in lowercase. The + * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * + * The |promised_stream_user_data| is a pointer to an arbitrary data + * which is associated to the promised stream this frame will open and + * make it in reserved state. It is available using + * `nghttp2_session_get_stream_user_data()`. The application can + * access it in :type:`nghttp2_before_frame_send_callback` and + * :type:`nghttp2_on_frame_send_callback` of this frame. + * + * The client side is not allowed to use this function. + * + * To submit response headers and data, use + * `nghttp2_submit_response2()`. + * + * This function returns assigned promised stream ID if it succeeds, + * or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * This function was invoked when |session| is initialized as + * client. + * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` + * No stream ID is available because maximum stream ID was + * reached. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0; The |stream_id| does not designate stream + * that peer initiated. + * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_CLOSED` + * The stream was already closed; or the |stream_id| is invalid. + * + * .. warning:: + * + * This function returns assigned promised stream ID if it succeeds. + * As of 1.16.0, stream object for pushed resource is created when + * this function succeeds. In that case, the application can submit + * push response for the promised frame. + * + * In 1.15.0 or prior versions, pushed stream is not opened yet when + * this function succeeds. The application must not submit frame to + * that stream ID before :type:`nghttp2_before_frame_send_callback` + * is called for this frame. + * + */ +NGHTTP2_EXTERN int32_t nghttp2_submit_push_promise( + nghttp2_session *session, uint8_t flags, int32_t stream_id, + const nghttp2_nv *nva, size_t nvlen, void *promised_stream_user_data); + +/** + * @function + * + * Submits PING frame. You don't have to send PING back when you + * received PING frame. The library automatically submits PING frame + * in this case. + * + * The |flags| is bitwise OR of 0 or more of the following value. + * + * * :enum:`nghttp2_flag.NGHTTP2_FLAG_ACK` + * + * Unless `nghttp2_option_set_no_auto_ping_ack()` is used, the |flags| + * should be :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * If the |opaque_data| is non ``NULL``, then it should point to the 8 + * bytes array of memory to specify opaque data to send with PING + * frame. If the |opaque_data| is ``NULL``, zero-cleared 8 bytes will + * be sent as opaque data. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_submit_ping(nghttp2_session *session, uint8_t flags, + const uint8_t *opaque_data); + +/** + * @function + * + * Submits GOAWAY frame with the last stream ID |last_stream_id| and + * the error code |error_code|. + * + * The pre-defined error code is one of :enum:`nghttp2_error_code`. + * + * The |flags| is currently ignored and should be + * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |last_stream_id| is peer's stream ID or 0. So if |session| is + * initialized as client, |last_stream_id| must be even or 0. If + * |session| is initialized as server, |last_stream_id| must be odd or + * 0. + * + * The HTTP/2 specification says last_stream_id must not be increased + * from the value previously sent. So the actual value sent as + * last_stream_id is the minimum value between the given + * |last_stream_id| and the last_stream_id previously sent to the + * peer. + * + * If the |opaque_data| is not ``NULL`` and |opaque_data_len| is not + * zero, those data will be sent as additional debug data. The + * library makes a copy of the memory region pointed by |opaque_data| + * with the length |opaque_data_len|, so the caller does not need to + * keep this memory after the return of this function. If the + * |opaque_data_len| is 0, the |opaque_data| could be ``NULL``. + * + * After successful transmission of GOAWAY, following things happen. + * All incoming streams having strictly more than |last_stream_id| are + * closed. All incoming HEADERS which starts new stream are simply + * ignored. After all active streams are handled, both + * `nghttp2_session_want_read()` and `nghttp2_session_want_write()` + * return 0 and the application can close session. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |opaque_data_len| is too large; the |last_stream_id| is + * invalid. + */ +NGHTTP2_EXTERN int nghttp2_submit_goaway(nghttp2_session *session, + uint8_t flags, int32_t last_stream_id, + uint32_t error_code, + const uint8_t *opaque_data, + size_t opaque_data_len); + +/** + * @function + * + * Returns the last stream ID of a stream for which + * :type:`nghttp2_on_frame_recv_callback` was invoked most recently. + * The returned value can be used as last_stream_id parameter for + * `nghttp2_submit_goaway()` and + * `nghttp2_session_terminate_session2()`. + * + * This function always succeeds. + */ +NGHTTP2_EXTERN int32_t +nghttp2_session_get_last_proc_stream_id(nghttp2_session *session); + +/** + * @function + * + * Returns nonzero if new request can be sent from local endpoint. + * + * This function return 0 if request is not allowed for this session. + * There are several reasons why request is not allowed. Some of the + * reasons are: session is server; stream ID has been spent; GOAWAY + * has been sent or received. + * + * The application can call `nghttp2_submit_request2()` without + * consulting this function. In that case, + * `nghttp2_submit_request2()` may return error. Or, request is + * failed to sent, and :type:`nghttp2_on_stream_close_callback` is + * called. + */ +NGHTTP2_EXTERN int +nghttp2_session_check_request_allowed(nghttp2_session *session); + +/** + * @function + * + * Returns nonzero if |session| is initialized as server side session. + */ +NGHTTP2_EXTERN int +nghttp2_session_check_server_session(nghttp2_session *session); + +/** + * @function + * + * Submits WINDOW_UPDATE frame. + * + * The |flags| is currently ignored and should be + * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |stream_id| is the stream ID to send this WINDOW_UPDATE. To + * send connection level WINDOW_UPDATE, specify 0 to |stream_id|. + * + * If the |window_size_increment| is positive, the WINDOW_UPDATE with + * that value as window_size_increment is queued. If the + * |window_size_increment| is larger than the received bytes from the + * remote endpoint, the local window size is increased by that + * difference. If the sole purpose is to increase the local window + * size, consider to use `nghttp2_session_set_local_window_size()`. + * + * If the |window_size_increment| is negative, the local window size + * is decreased by -|window_size_increment|. If automatic + * WINDOW_UPDATE is enabled + * (`nghttp2_option_set_no_auto_window_update()`), and the library + * decided that the WINDOW_UPDATE should be submitted, then + * WINDOW_UPDATE is queued with the current received bytes count. If + * the sole purpose is to decrease the local window size, consider to + * use `nghttp2_session_set_local_window_size()`. + * + * If the |window_size_increment| is 0, the function does nothing and + * returns 0. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_FLOW_CONTROL` + * The local window size overflow or gets negative. + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_submit_window_update(nghttp2_session *session, + uint8_t flags, + int32_t stream_id, + int32_t window_size_increment); + +/** + * @function + * + * Set local window size (local endpoints's window size) to the given + * |window_size| for the given stream denoted by |stream_id|. To + * change connection level window size, specify 0 to |stream_id|. To + * increase window size, this function may submit WINDOW_UPDATE frame + * to transmission queue. + * + * The |flags| is currently ignored and should be + * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * This sounds similar to `nghttp2_submit_window_update()`, but there + * are 2 differences. The first difference is that this function + * takes the absolute value of window size to set, rather than the + * delta. To change the window size, this may be easier to use since + * the application just declares the intended window size, rather than + * calculating delta. The second difference is that + * `nghttp2_submit_window_update()` affects the received bytes count + * which has not acked yet. By the specification of + * `nghttp2_submit_window_update()`, to strictly increase the local + * window size, we have to submit delta including all received bytes + * count, which might not be desirable in some cases. On the other + * hand, this function does not affect the received bytes count. It + * just sets the local window size to the given value. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is negative. + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int +nghttp2_session_set_local_window_size(nghttp2_session *session, uint8_t flags, + int32_t stream_id, int32_t window_size); + +/** + * @function + * + * Submits extension frame. + * + * Application can pass arbitrary frame flags and stream ID in |flags| + * and |stream_id| respectively. The |payload| is opaque pointer, and + * it can be accessible though ``frame->ext.payload`` in + * :type:`nghttp2_pack_extension_callback2`. The library will not own + * passed |payload| pointer. + * + * The application must set :type:`nghttp2_pack_extension_callback2` + * using `nghttp2_session_callbacks_set_pack_extension_callback2()`. + * + * The application should retain the memory pointed by |payload| until + * the transmission of extension frame is done (which is indicated by + * :type:`nghttp2_on_frame_send_callback`), or transmission fails + * (which is indicated by :type:`nghttp2_on_frame_not_send_callback`). + * If application does not touch this memory region after packing it + * into a wire format, application can free it inside + * :type:`nghttp2_pack_extension_callback2`. + * + * The standard HTTP/2 frame cannot be sent with this function, so + * |type| must be strictly grater than 0x9. Otherwise, this function + * will fail with error code + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT`. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * If :type:`nghttp2_pack_extension_callback2` is not set. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * If |type| specifies standard HTTP/2 frame type. The frame + * types in the rage [0x0, 0x9], both inclusive, are standard + * HTTP/2 frame type, and cannot be sent using this function. + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory + */ +NGHTTP2_EXTERN int nghttp2_submit_extension(nghttp2_session *session, + uint8_t type, uint8_t flags, + int32_t stream_id, void *payload); + +/** + * @struct + * + * The payload of ALTSVC frame. ALTSVC frame is a non-critical + * extension to HTTP/2. If this frame is received, and + * `nghttp2_option_set_user_recv_extension_type()` is not set, and + * `nghttp2_option_set_builtin_recv_extension_type()` is set for + * :enum:`nghttp2_frame_type.NGHTTP2_ALTSVC`, + * ``nghttp2_extension.payload`` will point to this struct. + * + * It has the following members: + */ +typedef struct { + /** + * The pointer to origin which this alternative service is + * associated with. This is not necessarily NULL-terminated. + */ + uint8_t *origin; + /** + * The length of the |origin|. + */ + size_t origin_len; + /** + * The pointer to Alt-Svc field value contained in ALTSVC frame. + * This is not necessarily NULL-terminated. + */ + uint8_t *field_value; + /** + * The length of the |field_value|. + */ + size_t field_value_len; +} nghttp2_ext_altsvc; + +/** + * @function + * + * Submits ALTSVC frame. + * + * ALTSVC frame is a non-critical extension to HTTP/2, and defined in + * `RFC 7383 `_. + * + * The |flags| is currently ignored and should be + * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |origin| points to the origin this alternative service is + * associated with. The |origin_len| is the length of the origin. If + * |stream_id| is 0, the origin must be specified. If |stream_id| is + * not zero, the origin must be empty (in other words, |origin_len| + * must be 0). + * + * The ALTSVC frame is only usable from server side. If this function + * is invoked with client side session, this function returns + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The function is called from client side session + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The sum of |origin_len| and |field_value_len| is larger than + * 16382; or |origin_len| is 0 while |stream_id| is 0; or + * |origin_len| is not 0 while |stream_id| is not 0. + */ +NGHTTP2_EXTERN int nghttp2_submit_altsvc(nghttp2_session *session, + uint8_t flags, int32_t stream_id, + const uint8_t *origin, + size_t origin_len, + const uint8_t *field_value, + size_t field_value_len); + +/** + * @struct + * + * The single entry of an origin. + */ +typedef struct { + /** + * The pointer to origin. No validation is made against this field + * by the library. This is not necessarily NULL-terminated. + */ + uint8_t *origin; + /** + * The length of the |origin|. + */ + size_t origin_len; +} nghttp2_origin_entry; + +/** + * @struct + * + * The payload of ORIGIN frame. ORIGIN frame is a non-critical + * extension to HTTP/2 and defined by `RFC 8336 + * `_. + * + * If this frame is received, and + * `nghttp2_option_set_user_recv_extension_type()` is not set, and + * `nghttp2_option_set_builtin_recv_extension_type()` is set for + * :enum:`nghttp2_frame_type.NGHTTP2_ORIGIN`, + * ``nghttp2_extension.payload`` will point to this struct. + * + * It has the following members: + */ +typedef struct { + /** + * The number of origins contained in |ov|. + */ + size_t nov; + /** + * The pointer to the array of origins contained in ORIGIN frame. + */ + nghttp2_origin_entry *ov; +} nghttp2_ext_origin; + +/** + * @function + * + * Submits ORIGIN frame. + * + * ORIGIN frame is a non-critical extension to HTTP/2 and defined by + * `RFC 8336 `_. + * + * The |flags| is currently ignored and should be + * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |ov| points to the array of origins. The |nov| specifies the + * number of origins included in |ov|. This function creates copies + * of all elements in |ov|. + * + * The ORIGIN frame is only usable by a server. If this function is + * invoked with client side session, this function returns + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The function is called from client side session. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * There are too many origins, or an origin is too large to fit + * into a default frame payload. + */ +NGHTTP2_EXTERN int nghttp2_submit_origin(nghttp2_session *session, + uint8_t flags, + const nghttp2_origin_entry *ov, + size_t nov); + +/** + * @struct + * + * The payload of PRIORITY_UPDATE frame. PRIORITY_UPDATE frame is a + * non-critical extension to HTTP/2. If this frame is received, and + * `nghttp2_option_set_user_recv_extension_type()` is not set, and + * `nghttp2_option_set_builtin_recv_extension_type()` is set for + * :enum:`nghttp2_frame_type.NGHTTP2_PRIORITY_UPDATE`, + * ``nghttp2_extension.payload`` will point to this struct. + * + * It has the following members: + */ +typedef struct { + /** + * The stream ID of the stream whose priority is updated. + */ + int32_t stream_id; + /** + * The pointer to Priority field value. It is not necessarily + * NULL-terminated. + */ + uint8_t *field_value; + /** + * The length of the :member:`field_value`. + */ + size_t field_value_len; +} nghttp2_ext_priority_update; + +/** + * @function + * + * Submits PRIORITY_UPDATE frame. + * + * PRIORITY_UPDATE frame is a non-critical extension to HTTP/2, and + * defined in :rfc:`9218#section-7.1`. + * + * The |flags| is currently ignored and should be + * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |stream_id| is the ID of stream which is prioritized. The + * |field_value| points to the Priority field value. The + * |field_value_len| is the length of the Priority field value. + * + * If this function is called by server, + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` is returned. + * + * If + * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` + * of value of 0 is received by a remote endpoint (or it is omitted), + * this function does nothing and returns 0. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The function is called from server side session + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |field_value_len| is larger than 16380; or |stream_id| is + * 0. + */ +NGHTTP2_EXTERN int nghttp2_submit_priority_update(nghttp2_session *session, + uint8_t flags, + int32_t stream_id, + const uint8_t *field_value, + size_t field_value_len); + +/** + * @function + * + * Changes the priority of the existing stream denoted by |stream_id|. + * The new priority is |extpri|. This function is meant to be used by + * server for :rfc:`9218` extensible prioritization scheme. + * + * If |session| is initialized as client, this function returns + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. For client, use + * `nghttp2_submit_priority_update()` instead. + * + * If :member:`extpri->urgency ` is out of + * bound, it is set to :macro:`NGHTTP2_EXTPRI_URGENCY_LOW`. + * + * If |ignore_client_signal| is nonzero, server starts to ignore + * client priority signals for this stream. + * + * If + * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` + * of value of 1 is not submitted via `nghttp2_submit_settings()`, + * this function does nothing and returns 0. + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The |session| is initialized as client. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * |stream_id| is zero; or a stream denoted by |stream_id| is not + * found. + */ +NGHTTP2_EXTERN int nghttp2_session_change_extpri_stream_priority( + nghttp2_session *session, int32_t stream_id, const nghttp2_extpri *extpri, + int ignore_client_signal); + +/** + * @function + * + * Stores the stream priority of the existing stream denoted by + * |stream_id| in the object pointed by |extpri|. This function is + * meant to be used by server for :rfc:`9218` extensible + * prioritization scheme. + * + * If |session| is initialized as client, this function returns + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. + * + * If + * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` + * of value of 1 is not submitted via `nghttp2_submit_settings()`, + * this function does nothing and returns 0. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The |session| is initialized as client. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * |stream_id| is zero; or a stream denoted by |stream_id| is not + * found. + */ +NGHTTP2_EXTERN int nghttp2_session_get_extpri_stream_priority( + nghttp2_session *session, nghttp2_extpri *extpri, int32_t stream_id); + +/** + * @function + * + * Parses Priority header field value pointed by |value| of length + * |len|, and stores the result in the object pointed by |extpri|. + * Priority header field is defined in :rfc:`9218`. + * + * This function does not initialize the object pointed by |extpri| + * before storing the result. It only assigns the values that the + * parser correctly extracted to fields. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * Failed to parse the header field value. + */ +NGHTTP2_EXTERN int nghttp2_extpri_parse_priority(nghttp2_extpri *extpri, + const uint8_t *value, + size_t len); + +/** + * @function + * + * Compares ``lhs->name`` of length ``lhs->namelen`` bytes and + * ``rhs->name`` of length ``rhs->namelen`` bytes. Returns negative + * integer if ``lhs->name`` is found to be less than ``rhs->name``; or + * returns positive integer if ``lhs->name`` is found to be greater + * than ``rhs->name``; or returns 0 otherwise. + */ +NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs, + const nghttp2_nv *rhs); + +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_select_alpn` instead. + * + * A helper function for dealing with ALPN in server side. The |in| + * contains peer's protocol list in preferable order. The format of + * |in| is length-prefixed and not null-terminated. For example, + * ``h2`` and ``http/1.1`` stored in |in| like this:: + * + * in[0] = 2 + * in[1..2] = "h2" + * in[3] = 8 + * in[4..11] = "http/1.1" + * inlen = 12 + * + * The selection algorithm is as follows: + * + * 1. If peer's list contains HTTP/2 protocol the library supports, + * it is selected and returns 1. The following step is not taken. + * + * 2. If peer's list contains ``http/1.1``, this function selects + * ``http/1.1`` and returns 0. The following step is not taken. + * + * 3. This function selects nothing and returns -1 (So called + * non-overlap case). In this case, |out| and |outlen| are left + * untouched. + * + * Selecting ``h2`` means that ``h2`` is written into |*out| and its + * length (which is 2) is assigned to |*outlen|. + * + * For ALPN, refer to https://tools.ietf.org/html/rfc7301 + * + * To use this method you should do something like:: + * + * static int alpn_select_proto_cb(SSL* ssl, + * const unsigned char **out, + * unsigned char *outlen, + * const unsigned char *in, + * unsigned int inlen, + * void *arg) + * { + * int rv; + * rv = nghttp2_select_next_protocol((unsigned char**)out, outlen, + * in, inlen); + * if (rv == -1) { + * return SSL_TLSEXT_ERR_NOACK; + * } + * if (rv == 1) { + * ((MyType*)arg)->http2_selected = 1; + * } + * return SSL_TLSEXT_ERR_OK; + * } + * ... + * SSL_CTX_set_alpn_select_cb(ssl_ctx, alpn_select_proto_cb, my_obj); + * + */ +NGHTTP2_EXTERN int nghttp2_select_next_protocol(unsigned char **out, + unsigned char *outlen, + const unsigned char *in, + unsigned int inlen); + +/** + * @function + * + * A helper function for dealing with ALPN in server side. The |in| + * contains peer's protocol list in preferable order. The format of + * |in| is length-prefixed and not null-terminated. For example, + * ``h2`` and ``http/1.1`` stored in |in| like this:: + * + * in[0] = 2 + * in[1..2] = "h2" + * in[3] = 8 + * in[4..11] = "http/1.1" + * inlen = 12 + * + * The selection algorithm is as follows: + * + * 1. If peer's list contains HTTP/2 protocol the library supports, + * it is selected and returns 1. The following step is not taken. + * + * 2. If peer's list contains ``http/1.1``, this function selects + * ``http/1.1`` and returns 0. The following step is not taken. + * + * 3. This function selects nothing and returns -1 (So called + * non-overlap case). In this case, |out| and |outlen| are left + * untouched. + * + * Selecting ``h2`` means that ``h2`` is written into |*out| and its + * length (which is 2) is assigned to |*outlen|. + * + * For ALPN, refer to https://tools.ietf.org/html/rfc7301 + * + * To use this method you should do something like:: + * + * static int alpn_select_proto_cb(SSL* ssl, + * const unsigned char **out, + * unsigned char *outlen, + * const unsigned char *in, + * unsigned int inlen, + * void *arg) + * { + * int rv; + * rv = nghttp2_select_alpn(out, outlen, in, inlen); + * if (rv == -1) { + * return SSL_TLSEXT_ERR_NOACK; + * } + * if (rv == 1) { + * ((MyType*)arg)->http2_selected = 1; + * } + * return SSL_TLSEXT_ERR_OK; + * } + * ... + * SSL_CTX_set_alpn_select_cb(ssl_ctx, alpn_select_proto_cb, my_obj); + * + */ +NGHTTP2_EXTERN int nghttp2_select_alpn(const unsigned char **out, + unsigned char *outlen, + const unsigned char *in, + unsigned int inlen); + +/** + * @function + * + * Returns a pointer to a nghttp2_info struct with version information + * about the run-time library in use. The |least_version| argument + * can be set to a 24 bit numerical value for the least accepted + * version number and if the condition is not met, this function will + * return a ``NULL``. Pass in 0 to skip the version checking. + */ +NGHTTP2_EXTERN nghttp2_info *nghttp2_version(int least_version); + +/** + * @function + * + * Returns nonzero if the :type:`nghttp2_error` library error code + * |lib_error| is fatal. + */ +NGHTTP2_EXTERN int nghttp2_is_fatal(int lib_error_code); + +/** + * @function + * + * Returns nonzero if HTTP header field name |name| of length |len| is + * valid according to http://tools.ietf.org/html/rfc7230#section-3.2 + * + * Because this is a header field name in HTTP2, the upper cased alphabet + * is treated as error. + */ +NGHTTP2_EXTERN int nghttp2_check_header_name(const uint8_t *name, size_t len); + +/** + * @function + * + * Returns nonzero if HTTP header field value |value| of length |len| + * is valid according to + * http://tools.ietf.org/html/rfc7230#section-3.2 + * + * This function is considered obsolete, and application should + * consider to use `nghttp2_check_header_value_rfc9113()` instead. + */ +NGHTTP2_EXTERN int nghttp2_check_header_value(const uint8_t *value, size_t len); + +/** + * @function + * + * Returns nonzero if HTTP header field value |value| of length |len| + * is valid according to + * http://tools.ietf.org/html/rfc7230#section-3.2, plus + * https://datatracker.ietf.org/doc/html/rfc9113#section-8.2.1 + */ +NGHTTP2_EXTERN int nghttp2_check_header_value_rfc9113(const uint8_t *value, + size_t len); + +/** + * @function + * + * Returns nonzero if the |value| which is supposed to be the value of + * the :method header field is valid according to + * https://datatracker.ietf.org/doc/html/rfc7231#section-4 and + * https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6 + */ +NGHTTP2_EXTERN int nghttp2_check_method(const uint8_t *value, size_t len); + +/** + * @function + * + * Returns nonzero if the |value| which is supposed to be the value of + * the :path header field is valid according to + * https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.3 + * + * |value| is valid if it merely consists of the allowed characters. + * In particular, it does not check whether |value| follows the syntax + * of path. The allowed characters are all characters valid by + * `nghttp2_check_header_value` minus SPC and HT. + */ +NGHTTP2_EXTERN int nghttp2_check_path(const uint8_t *value, size_t len); + +/** + * @function + * + * Returns nonzero if the |value| which is supposed to be the value of the + * :authority or host header field is valid according to + * https://tools.ietf.org/html/rfc3986#section-3.2 + * + * Note that :authority and host field values are not authority. They + * do not include userinfo in RFC 3986, see + * https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2, that + * is, it does not include '@'. This function treats '@' as a valid + * character. + * + * |value| is valid if it merely consists of the allowed characters. + * In particular, it does not check whether |value| follows the syntax + * of authority. + */ +NGHTTP2_EXTERN int nghttp2_check_authority(const uint8_t *value, size_t len); + +/* HPACK API */ + +struct nghttp2_hd_deflater; + +/** + * @struct + * + * HPACK deflater object. + */ +typedef struct nghttp2_hd_deflater nghttp2_hd_deflater; + +/** + * @function + * + * Initializes |*deflater_ptr| for deflating name/values pairs. + * + * The |max_deflate_dynamic_table_size| is the upper bound of header + * table size the deflater will use. + * + * If this function fails, |*deflater_ptr| is left untouched. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int +nghttp2_hd_deflate_new(nghttp2_hd_deflater **deflater_ptr, + size_t max_deflate_dynamic_table_size); + +/** + * @function + * + * Like `nghttp2_hd_deflate_new()`, but with additional custom memory + * allocator specified in the |mem|. + * + * The |mem| can be ``NULL`` and the call is equivalent to + * `nghttp2_hd_deflate_new()`. + * + * This function does not take ownership |mem|. The application is + * responsible for freeing |mem|. + * + * The library code does not refer to |mem| pointer after this + * function returns, so the application can safely free it. + */ +NGHTTP2_EXTERN int +nghttp2_hd_deflate_new2(nghttp2_hd_deflater **deflater_ptr, + size_t max_deflate_dynamic_table_size, + nghttp2_mem *mem); + +/** + * @function + * + * Deallocates any resources allocated for |deflater|. + */ +NGHTTP2_EXTERN void nghttp2_hd_deflate_del(nghttp2_hd_deflater *deflater); + +/** + * @function + * + * Changes header table size of the |deflater| to + * |settings_max_dynamic_table_size| bytes. This may trigger eviction + * in the dynamic table. + * + * The |settings_max_dynamic_table_size| should be the value received + * in SETTINGS_HEADER_TABLE_SIZE. + * + * The deflater never uses more memory than + * ``max_deflate_dynamic_table_size`` bytes specified in + * `nghttp2_hd_deflate_new()`. Therefore, if + * |settings_max_dynamic_table_size| > + * ``max_deflate_dynamic_table_size``, resulting maximum table size + * becomes ``max_deflate_dynamic_table_size``. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int +nghttp2_hd_deflate_change_table_size(nghttp2_hd_deflater *deflater, + size_t settings_max_dynamic_table_size); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_hd_deflate_hd2()` instead. + * + * Deflates the |nva|, which has the |nvlen| name/value pairs, into + * the |buf| of length |buflen|. + * + * If |buf| is not large enough to store the deflated header block, + * this function fails with + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller + * should use `nghttp2_hd_deflate_bound()` to know the upper bound of + * buffer size required to deflate given header name/value pairs. + * + * Once this function fails, subsequent call of this function always + * returns :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP`. + * + * After this function returns, it is safe to delete the |nva|. + * + * This function returns the number of bytes written to |buf| if it + * succeeds, or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Deflation process has failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ +NGHTTP2_EXTERN ssize_t nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, + uint8_t *buf, size_t buflen, + const nghttp2_nv *nva, + size_t nvlen); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Deflates the |nva|, which has the |nvlen| name/value pairs, into + * the |buf| of length |buflen|. + * + * If |buf| is not large enough to store the deflated header block, + * this function fails with + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller + * should use `nghttp2_hd_deflate_bound()` to know the upper bound of + * buffer size required to deflate given header name/value pairs. + * + * Once this function fails, subsequent call of this function always + * returns :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP`. + * + * After this function returns, it is safe to delete the |nva|. + * + * This function returns the number of bytes written to |buf| if it + * succeeds, or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Deflation process has failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ +NGHTTP2_EXTERN nghttp2_ssize +nghttp2_hd_deflate_hd2(nghttp2_hd_deflater *deflater, uint8_t *buf, + size_t buflen, const nghttp2_nv *nva, size_t nvlen); + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_hd_deflate_hd_vec2()` instead. + * + * Deflates the |nva|, which has the |nvlen| name/value pairs, into + * the |veclen| size of buf vector |vec|. The each size of buffer + * must be set in len field of :type:`nghttp2_vec`. If and only if + * one chunk is filled up completely, next chunk will be used. If + * |vec| is not large enough to store the deflated header block, this + * function fails with + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller + * should use `nghttp2_hd_deflate_bound()` to know the upper bound of + * buffer size required to deflate given header name/value pairs. + * + * Once this function fails, subsequent call of this function always + * returns :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP`. + * + * After this function returns, it is safe to delete the |nva|. + * + * This function returns the number of bytes written to |vec| if it + * succeeds, or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Deflation process has failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ +NGHTTP2_EXTERN ssize_t nghttp2_hd_deflate_hd_vec(nghttp2_hd_deflater *deflater, + const nghttp2_vec *vec, + size_t veclen, + const nghttp2_nv *nva, + size_t nvlen); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Deflates the |nva|, which has the |nvlen| name/value pairs, into + * the |veclen| size of buf vector |vec|. The each size of buffer + * must be set in len field of :type:`nghttp2_vec`. If and only if + * one chunk is filled up completely, next chunk will be used. If + * |vec| is not large enough to store the deflated header block, this + * function fails with + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller + * should use `nghttp2_hd_deflate_bound()` to know the upper bound of + * buffer size required to deflate given header name/value pairs. + * + * Once this function fails, subsequent call of this function always + * returns :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP`. + * + * After this function returns, it is safe to delete the |nva|. + * + * This function returns the number of bytes written to |vec| if it + * succeeds, or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Deflation process has failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ +NGHTTP2_EXTERN nghttp2_ssize nghttp2_hd_deflate_hd_vec2( + nghttp2_hd_deflater *deflater, const nghttp2_vec *vec, size_t veclen, + const nghttp2_nv *nva, size_t nvlen); + +/** + * @function + * + * Returns an upper bound on the compressed size after deflation of + * |nva| of length |nvlen|. + */ +NGHTTP2_EXTERN size_t nghttp2_hd_deflate_bound(nghttp2_hd_deflater *deflater, + const nghttp2_nv *nva, + size_t nvlen); + +/** + * @function + * + * Returns the number of entries that header table of |deflater| + * contains. This is the sum of the number of static table and + * dynamic table, so the return value is at least 61. + */ +NGHTTP2_EXTERN +size_t nghttp2_hd_deflate_get_num_table_entries(nghttp2_hd_deflater *deflater); + +/** + * @function + * + * Returns the table entry denoted by |idx| from header table of + * |deflater|. The |idx| is 1-based, and idx=1 returns first entry of + * static table. idx=62 returns first entry of dynamic table if it + * exists. Specifying idx=0 is error, and this function returns NULL. + * If |idx| is strictly greater than the number of entries the tables + * contain, this function returns NULL. + */ +NGHTTP2_EXTERN +const nghttp2_nv * +nghttp2_hd_deflate_get_table_entry(nghttp2_hd_deflater *deflater, size_t idx); + +/** + * @function + * + * Returns the used dynamic table size, including the overhead 32 + * bytes per entry described in RFC 7541. + */ +NGHTTP2_EXTERN +size_t nghttp2_hd_deflate_get_dynamic_table_size(nghttp2_hd_deflater *deflater); + +/** + * @function + * + * Returns the maximum dynamic table size. + */ +NGHTTP2_EXTERN +size_t +nghttp2_hd_deflate_get_max_dynamic_table_size(nghttp2_hd_deflater *deflater); + +struct nghttp2_hd_inflater; + +/** + * @struct + * + * HPACK inflater object. + */ +typedef struct nghttp2_hd_inflater nghttp2_hd_inflater; + +/** + * @function + * + * Initializes |*inflater_ptr| for inflating name/values pairs. + * + * If this function fails, |*inflater_ptr| is left untouched. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ +NGHTTP2_EXTERN int nghttp2_hd_inflate_new(nghttp2_hd_inflater **inflater_ptr); + +/** + * @function + * + * Like `nghttp2_hd_inflate_new()`, but with additional custom memory + * allocator specified in the |mem|. + * + * The |mem| can be ``NULL`` and the call is equivalent to + * `nghttp2_hd_inflate_new()`. + * + * This function does not take ownership |mem|. The application is + * responsible for freeing |mem|. + * + * The library code does not refer to |mem| pointer after this + * function returns, so the application can safely free it. + */ +NGHTTP2_EXTERN int nghttp2_hd_inflate_new2(nghttp2_hd_inflater **inflater_ptr, + nghttp2_mem *mem); + +/** + * @function + * + * Deallocates any resources allocated for |inflater|. + */ +NGHTTP2_EXTERN void nghttp2_hd_inflate_del(nghttp2_hd_inflater *inflater); + +/** + * @function + * + * Changes header table size in the |inflater|. This may trigger + * eviction in the dynamic table. + * + * The |settings_max_dynamic_table_size| should be the value + * transmitted in SETTINGS_HEADER_TABLE_SIZE. + * + * This function must not be called while header block is being + * inflated. In other words, this function must be called after + * initialization of |inflater|, but before calling + * `nghttp2_hd_inflate_hd3()`, or after + * `nghttp2_hd_inflate_end_headers()`. Otherwise, + * `NGHTTP2_ERR_INVALID_STATE` was returned. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The function is called while header block is being inflated. + * Probably, application missed to call + * `nghttp2_hd_inflate_end_headers()`. + */ +NGHTTP2_EXTERN int +nghttp2_hd_inflate_change_table_size(nghttp2_hd_inflater *inflater, + size_t settings_max_dynamic_table_size); + +/** + * @enum + * + * The flags for header inflation. + */ +typedef enum { + /** + * No flag set. + */ + NGHTTP2_HD_INFLATE_NONE = 0, + /** + * Indicates all headers were inflated. + */ + NGHTTP2_HD_INFLATE_FINAL = 0x01, + /** + * Indicates a header was emitted. + */ + NGHTTP2_HD_INFLATE_EMIT = 0x02 +} nghttp2_hd_inflate_flag; + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_hd_inflate_hd2()` instead. + * + * Inflates name/value block stored in |in| with length |inlen|. This + * function performs decompression. For each successful emission of + * header name/value pair, + * :enum:`nghttp2_hd_inflate_flag.NGHTTP2_HD_INFLATE_EMIT` is set in + * |*inflate_flags| and name/value pair is assigned to the |nv_out| + * and the function returns. The caller must not free the members of + * |nv_out|. + * + * The |nv_out| may include pointers to the memory region in the |in|. + * The caller must retain the |in| while the |nv_out| is used. + * + * The application should call this function repeatedly until the + * ``(*inflate_flags) & NGHTTP2_HD_INFLATE_FINAL`` is nonzero and + * return value is non-negative. This means the all input values are + * processed successfully. Then the application must call + * `nghttp2_hd_inflate_end_headers()` to prepare for the next header + * block input. + * + * The caller can feed complete compressed header block. It also can + * feed it in several chunks. The caller must set |in_final| to + * nonzero if the given input is the last block of the compressed + * header. + * + * This function returns the number of bytes processed if it succeeds, + * or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Inflation process has failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_BUFFER_ERROR` + * The header field name or value is too large. + * + * Example follows:: + * + * int inflate_header_block(nghttp2_hd_inflater *hd_inflater, + * uint8_t *in, size_t inlen, int final) + * { + * ssize_t rv; + * + * for(;;) { + * nghttp2_nv nv; + * int inflate_flags = 0; + * + * rv = nghttp2_hd_inflate_hd(hd_inflater, &nv, &inflate_flags, + * in, inlen, final); + * + * if(rv < 0) { + * fprintf(stderr, "inflate failed with error code %zd", rv); + * return -1; + * } + * + * in += rv; + * inlen -= rv; + * + * if(inflate_flags & NGHTTP2_HD_INFLATE_EMIT) { + * fwrite(nv.name, nv.namelen, 1, stderr); + * fprintf(stderr, ": "); + * fwrite(nv.value, nv.valuelen, 1, stderr); + * fprintf(stderr, "\n"); + * } + * if(inflate_flags & NGHTTP2_HD_INFLATE_FINAL) { + * nghttp2_hd_inflate_end_headers(hd_inflater); + * break; + * } + * if((inflate_flags & NGHTTP2_HD_INFLATE_EMIT) == 0 && + * inlen == 0) { + * break; + * } + * } + * + * return 0; + * } + * + */ +NGHTTP2_EXTERN ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater, + nghttp2_nv *nv_out, + int *inflate_flags, uint8_t *in, + size_t inlen, int in_final); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +#ifndef NGHTTP2_NO_SSIZE_T +/** + * @function + * + * .. warning:: + * + * Deprecated. Use `nghttp2_hd_inflate_hd3()` instead. + * + * Inflates name/value block stored in |in| with length |inlen|. This + * function performs decompression. For each successful emission of + * header name/value pair, + * :enum:`nghttp2_hd_inflate_flag.NGHTTP2_HD_INFLATE_EMIT` is set in + * |*inflate_flags| and name/value pair is assigned to the |nv_out| + * and the function returns. The caller must not free the members of + * |nv_out|. + * + * The |nv_out| may include pointers to the memory region in the |in|. + * The caller must retain the |in| while the |nv_out| is used. + * + * The application should call this function repeatedly until the + * ``(*inflate_flags) & NGHTTP2_HD_INFLATE_FINAL`` is nonzero and + * return value is non-negative. If that happens, all given input + * data (|inlen| bytes) are processed successfully. Then the + * application must call `nghttp2_hd_inflate_end_headers()` to prepare + * for the next header block input. + * + * In other words, if |in_final| is nonzero, and this function returns + * |inlen|, you can assert that + * :enum:`nghttp2_hd_inflate_final.NGHTTP2_HD_INFLATE_FINAL` is set in + * |*inflate_flags|. + * + * The caller can feed complete compressed header block. It also can + * feed it in several chunks. The caller must set |in_final| to + * nonzero if the given input is the last block of the compressed + * header. + * + * This function returns the number of bytes processed if it succeeds, + * or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Inflation process has failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_BUFFER_ERROR` + * The header field name or value is too large. + * + * Example follows:: + * + * int inflate_header_block(nghttp2_hd_inflater *hd_inflater, + * uint8_t *in, size_t inlen, int final) + * { + * ssize_t rv; + * + * for(;;) { + * nghttp2_nv nv; + * int inflate_flags = 0; + * + * rv = nghttp2_hd_inflate_hd2(hd_inflater, &nv, &inflate_flags, + * in, inlen, final); + * + * if(rv < 0) { + * fprintf(stderr, "inflate failed with error code %zd", rv); + * return -1; + * } + * + * in += rv; + * inlen -= rv; + * + * if(inflate_flags & NGHTTP2_HD_INFLATE_EMIT) { + * fwrite(nv.name, nv.namelen, 1, stderr); + * fprintf(stderr, ": "); + * fwrite(nv.value, nv.valuelen, 1, stderr); + * fprintf(stderr, "\n"); + * } + * if(inflate_flags & NGHTTP2_HD_INFLATE_FINAL) { + * nghttp2_hd_inflate_end_headers(hd_inflater); + * break; + * } + * if((inflate_flags & NGHTTP2_HD_INFLATE_EMIT) == 0 && + * inlen == 0) { + * break; + * } + * } + * + * return 0; + * } + * + */ +NGHTTP2_EXTERN ssize_t nghttp2_hd_inflate_hd2(nghttp2_hd_inflater *inflater, + nghttp2_nv *nv_out, + int *inflate_flags, + const uint8_t *in, size_t inlen, + int in_final); + +#endif /* NGHTTP2_NO_SSIZE_T */ + +/** + * @function + * + * Inflates name/value block stored in |in| with length |inlen|. This + * function performs decompression. For each successful emission of + * header name/value pair, + * :enum:`nghttp2_hd_inflate_flag.NGHTTP2_HD_INFLATE_EMIT` is set in + * |*inflate_flags| and name/value pair is assigned to the |nv_out| + * and the function returns. The caller must not free the members of + * |nv_out|. + * + * The |nv_out| may include pointers to the memory region in the |in|. + * The caller must retain the |in| while the |nv_out| is used. + * + * The application should call this function repeatedly until the + * ``(*inflate_flags) & NGHTTP2_HD_INFLATE_FINAL`` is nonzero and + * return value is non-negative. If that happens, all given input + * data (|inlen| bytes) are processed successfully. Then the + * application must call `nghttp2_hd_inflate_end_headers()` to prepare + * for the next header block input. + * + * In other words, if |in_final| is nonzero, and this function returns + * |inlen|, you can assert that + * :enum:`nghttp2_hd_inflate_final.NGHTTP2_HD_INFLATE_FINAL` is set in + * |*inflate_flags|. + * + * The caller can feed complete compressed header block. It also can + * feed it in several chunks. The caller must set |in_final| to + * nonzero if the given input is the last block of the compressed + * header. + * + * This function returns the number of bytes processed if it succeeds, + * or one of the following negative error codes: + * + * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Inflation process has failed. + * :enum:`nghttp2_error.NGHTTP2_ERR_BUFFER_ERROR` + * The header field name or value is too large. + * + * Example follows:: + * + * int inflate_header_block(nghttp2_hd_inflater *hd_inflater, + * uint8_t *in, size_t inlen, int final) + * { + * nghttp2_ssize rv; + * + * for(;;) { + * nghttp2_nv nv; + * int inflate_flags = 0; + * + * rv = nghttp2_hd_inflate_hd3(hd_inflater, &nv, &inflate_flags, + * in, inlen, final); + * + * if(rv < 0) { + * fprintf(stderr, "inflate failed with error code %td", rv); + * return -1; + * } + * + * in += rv; + * inlen -= rv; + * + * if(inflate_flags & NGHTTP2_HD_INFLATE_EMIT) { + * fwrite(nv.name, nv.namelen, 1, stderr); + * fprintf(stderr, ": "); + * fwrite(nv.value, nv.valuelen, 1, stderr); + * fprintf(stderr, "\n"); + * } + * if(inflate_flags & NGHTTP2_HD_INFLATE_FINAL) { + * nghttp2_hd_inflate_end_headers(hd_inflater); + * break; + * } + * if((inflate_flags & NGHTTP2_HD_INFLATE_EMIT) == 0 && + * inlen == 0) { + * break; + * } + * } + * + * return 0; + * } + * + */ +NGHTTP2_EXTERN nghttp2_ssize nghttp2_hd_inflate_hd3( + nghttp2_hd_inflater *inflater, nghttp2_nv *nv_out, int *inflate_flags, + const uint8_t *in, size_t inlen, int in_final); + +/** + * @function + * + * Signals the end of decompression for one header block. + * + * This function returns 0 if it succeeds. Currently this function + * always succeeds. + */ +NGHTTP2_EXTERN int +nghttp2_hd_inflate_end_headers(nghttp2_hd_inflater *inflater); + +/** + * @function + * + * Returns the number of entries that header table of |inflater| + * contains. This is the sum of the number of static table and + * dynamic table, so the return value is at least 61. + */ +NGHTTP2_EXTERN +size_t nghttp2_hd_inflate_get_num_table_entries(nghttp2_hd_inflater *inflater); + +/** + * @function + * + * Returns the table entry denoted by |idx| from header table of + * |inflater|. The |idx| is 1-based, and idx=1 returns first entry of + * static table. idx=62 returns first entry of dynamic table if it + * exists. Specifying idx=0 is error, and this function returns NULL. + * If |idx| is strictly greater than the number of entries the tables + * contain, this function returns NULL. + */ +NGHTTP2_EXTERN +const nghttp2_nv * +nghttp2_hd_inflate_get_table_entry(nghttp2_hd_inflater *inflater, size_t idx); + +/** + * @function + * + * Returns the used dynamic table size, including the overhead 32 + * bytes per entry described in RFC 7541. + */ +NGHTTP2_EXTERN +size_t nghttp2_hd_inflate_get_dynamic_table_size(nghttp2_hd_inflater *inflater); + +/** + * @function + * + * Returns the maximum dynamic table size. + */ +NGHTTP2_EXTERN +size_t +nghttp2_hd_inflate_get_max_dynamic_table_size(nghttp2_hd_inflater *inflater); + +struct nghttp2_stream; + +/** + * @struct + * + * The structure to represent HTTP/2 stream. The details of this + * structure are intentionally hidden from the public API. + */ +typedef struct nghttp2_stream nghttp2_stream; + +/** + * @function + * + * Returns pointer to :type:`nghttp2_stream` object denoted by + * |stream_id|. If stream was not found, returns NULL. + * + * Returns imaginary root stream (see + * `nghttp2_session_get_root_stream()`) if 0 is given in |stream_id|. + * + * Unless |stream_id| == 0, the returned pointer is valid until next + * call of `nghttp2_session_send()`, `nghttp2_session_mem_send2()`, + * `nghttp2_session_recv()`, and `nghttp2_session_mem_recv2()`. + */ +NGHTTP2_EXTERN nghttp2_stream * +nghttp2_session_find_stream(nghttp2_session *session, int32_t stream_id); + +/** + * @enum + * + * State of stream as described in RFC 7540. + */ +typedef enum { + /** + * idle state. + */ + NGHTTP2_STREAM_STATE_IDLE = 1, + /** + * open state. + */ + NGHTTP2_STREAM_STATE_OPEN, + /** + * reserved (local) state. + */ + NGHTTP2_STREAM_STATE_RESERVED_LOCAL, + /** + * reserved (remote) state. + */ + NGHTTP2_STREAM_STATE_RESERVED_REMOTE, + /** + * half closed (local) state. + */ + NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL, + /** + * half closed (remote) state. + */ + NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE, + /** + * closed state. + */ + NGHTTP2_STREAM_STATE_CLOSED +} nghttp2_stream_proto_state; + +/** + * @function + * + * Returns state of |stream|. The root stream retrieved by + * `nghttp2_session_get_root_stream()` will have stream state + * :enum:`nghttp2_stream_proto_state.NGHTTP2_STREAM_STATE_IDLE`. + */ +NGHTTP2_EXTERN nghttp2_stream_proto_state +nghttp2_stream_get_state(nghttp2_stream *stream); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * Returns root of dependency tree, which is imaginary stream with + * stream ID 0. The returned pointer is valid until |session| is + * freed by `nghttp2_session_del()`. + */ +NGHTTP2_EXTERN nghttp2_stream * +nghttp2_session_get_root_stream(nghttp2_session *session); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function always returns NULL. + */ +NGHTTP2_EXTERN nghttp2_stream * +nghttp2_stream_get_parent(nghttp2_stream *stream); + +NGHTTP2_EXTERN int32_t nghttp2_stream_get_stream_id(nghttp2_stream *stream); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function always returns NULL. + */ +NGHTTP2_EXTERN nghttp2_stream * +nghttp2_stream_get_next_sibling(nghttp2_stream *stream); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function always returns NULL. + */ +NGHTTP2_EXTERN nghttp2_stream * +nghttp2_stream_get_previous_sibling(nghttp2_stream *stream); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function always returns NULL. + */ +NGHTTP2_EXTERN nghttp2_stream * +nghttp2_stream_get_first_child(nghttp2_stream *stream); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function always returns :macro:`NGHTTP2_DEFAULT_WEIGHT`. + */ +NGHTTP2_EXTERN int32_t nghttp2_stream_get_weight(nghttp2_stream *stream); + +/** + * @function + * + * .. warning:: + * + * Deprecated. :rfc:`7540` priorities are deprecated by + * :rfc:`9113`. Consider migrating to :rfc:`9218` extensible + * prioritization scheme. + * + * This function always returns 0. + */ +NGHTTP2_EXTERN int32_t +nghttp2_stream_get_sum_dependency_weight(nghttp2_stream *stream); + +/** + * @functypedef + * + * Callback function invoked when the library outputs debug logging. + * The function is called with arguments suitable for ``vfprintf(3)`` + * + * The debug output is only enabled if the library is built with + * ``DEBUGBUILD`` macro defined. + */ +typedef void (*nghttp2_debug_vprintf_callback)(const char *format, + va_list args); + +/** + * @function + * + * Sets a debug output callback called by the library when built with + * ``DEBUGBUILD`` macro defined. If this option is not used, debug + * log is written into standard error output. + * + * For builds without ``DEBUGBUILD`` macro defined, this function is + * noop. + * + * Note that building with ``DEBUGBUILD`` may cause significant + * performance penalty to libnghttp2 because of extra processing. It + * should be used for debugging purpose only. + * + * .. Warning:: + * + * Building with ``DEBUGBUILD`` may cause significant performance + * penalty to libnghttp2 because of extra processing. It should be + * used for debugging purpose only. We write this two times because + * this is important. + */ +NGHTTP2_EXTERN void nghttp2_set_debug_vprintf_callback( + nghttp2_debug_vprintf_callback debug_vprintf_callback); + +#ifdef __cplusplus +} +#endif + +#endif /* NGHTTP2_H */ diff --git a/illumos-x86_64/usr/include/nghttp2/nghttp2ver.h b/illumos-x86_64/usr/include/nghttp2/nghttp2ver.h new file mode 100644 index 00000000..bd5e6c28 --- /dev/null +++ b/illumos-x86_64/usr/include/nghttp2/nghttp2ver.h @@ -0,0 +1,42 @@ +/* + * nghttp2 - HTTP/2 C Library + * + * Copyright (c) 2012, 2013 Tatsuhiro Tsujikawa + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef NGHTTP2VER_H +#define NGHTTP2VER_H + +/** + * @macro + * Version number of the nghttp2 library release + */ +#define NGHTTP2_VERSION "1.67.1" + +/** + * @macro + * Numerical representation of the version number of the nghttp2 library + * release. This is a 24 bit number with 8 bits for major number, 8 bits + * for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203. + */ +#define NGHTTP2_VERSION_NUM 0x014301 + +#endif /* NGHTTP2VER_H */ diff --git a/illumos-x86_64/usr/include/nl_types.h b/illumos-x86_64/usr/include/nl_types.h new file mode 100644 index 00000000..1a4b1fc6 --- /dev/null +++ b/illumos-x86_64/usr/include/nl_types.h @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * nl_types.h + * + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1991,1997,2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _NL_TYPES_H +#define _NL_TYPES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NL_SETD 1 /* XPG3 Conformant Default set number. */ +#define NL_CAT_LOCALE (-1) /* XPG4 requirement */ + +#define _CAT_MAGIC 0xFF88FF89 +#define _CAT_HDR_SIZE sizeof (struct _cat_hdr) +#define _CAT_SET_HDR_SIZE sizeof (struct _cat_set_hdr) +#define _CAT_MSG_HDR_SIZE sizeof (struct _cat_msg_hdr) + +struct _cat_hdr +{ +#if !defined(_LP64) + long __hdr_magic; /* must contain CAT_MAGIC */ +#else + int __hdr_magic; /* must contain CAT_MAGIC */ +#endif + int __nsets; /* the number of sets in the catalogue */ + int __mem; /* the size of the catalogue; the size */ + /* does not include the size of the header */ +#if !defined(_LP64) + long __msg_hdr_offset; /* the byte offset of the first message */ + /* header */ + long __msg_text_offset; /* the byte offset of the message text area */ +#else + int __msg_hdr_offset; /* the byte offset of the first message */ + /* header */ + int __msg_text_offset; /* the byte offset of the message text area */ +#endif +}; + +struct _cat_set_hdr +{ + int __set_no; /* the set number; must be greater than 0; */ + /* should be less than or equal to NL_SETMAX */ + int __nmsgs; /* the number of msgs in the set */ + int __first_msg_hdr; /* the index of the first message header in */ + /* the set; the value is not a byte offset, */ + /* it is a 0-based index */ +}; + +struct _cat_msg_hdr +{ + int __msg_no; /* the message number; must be greater than 0; */ + /* should be less than or equal to NL_MSGMAX */ + int __msg_len; /* the length of the message; must be greater */ + /* than or equal to zero; should be less than */ + /* or equal to NL_TEXTMAX */ + int __msg_offset; /* the byte offset of the message in the message */ + /* area; the offset is relative to the start of */ + /* the message area, not to the start of the */ + /* catalogue. */ +}; + +struct _nl_catd_struct { + void *__content; /* mmaped catalogue contents */ + int __size; /* Size of catalogue file */ + int __trust; /* File is from a trusted location */ +}; + +typedef struct _nl_catd_struct *nl_catd; +typedef int nl_item; /* XPG3 Conformant for nl_langinfo(). */ + +/* The following is just for the compatibility between OSF and Solaris */ +/* Need to be removed later */ +typedef nl_item __nl_item; + +int catclose(nl_catd); +char *catgets(nl_catd, int, int, const char *); +nl_catd catopen(const char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _NL_TYPES_H */ diff --git a/illumos-x86_64/usr/include/nlist.h b/illumos-x86_64/usr/include/nlist.h new file mode 100644 index 00000000..b0c484ca --- /dev/null +++ b/illumos-x86_64/usr/include/nlist.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _NLIST_H +#define _NLIST_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct nlist { + char *n_name; /* symbol name */ + long n_value; /* value of symbol */ + short n_scnum; /* section number */ + unsigned short n_type; /* type and derived type */ + char n_sclass; /* storage class */ + char n_numaux; /* number of aux. entries */ +}; + +extern int nlist(const char *, struct nlist *); + +#ifdef __cplusplus +} +#endif + +#endif /* _NLIST_H */ diff --git a/illumos-x86_64/usr/include/note.h b/illumos-x86_64/usr/include/note.h new file mode 100644 index 00000000..b6b59473 --- /dev/null +++ b/illumos-x86_64/usr/include/note.h @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1994 by Sun Microsystems, Inc. + */ + +/* + * note.h: interface for annotating source with info for tools + * + * NOTE is the default interface, but if the identifier NOTE is in use for + * some other purpose, you may prepare a similar header file using your own + * identifier, mapping that identifier to _NOTE. Also, exported header + * files should *not* use NOTE, since the name may already be in use in + * a program's namespace. Rather, exported header files should include + * sys/note.h directly and use _NOTE. For consistency, all kernel source + * should use _NOTE. + */ + +#ifndef _NOTE_H +#define _NOTE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NOTE _NOTE + +#ifdef __cplusplus +} +#endif + +#endif /* _NOTE_H */ diff --git a/illumos-x86_64/usr/include/nss_common.h b/illumos-x86_64/usr/include/nss_common.h new file mode 100644 index 00000000..fb6f68ad --- /dev/null +++ b/illumos-x86_64/usr/include/nss_common.h @@ -0,0 +1,470 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * + * NOTE: The interfaces documented in this file may change in a minor + * release. It is intended that in the future a stronger committment + * will be made to these interface definitions which will guarantee + * them across minor releases. + */ + +#ifndef _NSS_COMMON_H +#define _NSS_COMMON_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The name-service switch + * ----------------------- + * + * From nsswitch.conf(5): + * + * The operating system uses a number of "databases" of information + * about hosts, users (passwd/shadow), groups and so forth. Data for + * these can come from a variety of "sources": host-names and + * -addresses, for example, may be found in /etc/hosts, NIS, NIS+ or + * DNS. One or more sources may be used for each database; the + * sources and their lookup order are specified in the + * /etc/nsswitch.conf file. + * + * The implementation of this consists of: + * + * - a "frontend" for each database, which provides a programming + * interface for that database [for example, the "passwd" frontend + * consists of getpwnam_r(), getpwuid_r(), getpwent_r(), setpwent(), + * endpwent(), and the old MT-unsafe routines getpwnam() and getpwuid()] + * and is implemented by calls to... + * + * - the common core of the switch (called the "switch" or "policy" engine); + * that determines what sources to use and when to invoke them. This + * component works in conjunction with the name service switch (nscd). + * Usually nscd is the policy engine for an application lookup. + * + * - Old style backend interfaces follow this pointer to function interface: + * + * A "backend" exists for useful pairs. Each backend + * consists of whatever private data it needs and a set of functions + * that the switch engine may invoke on behalf of the frontend + * [e.g. the "nis" backend for "passwd" provides routines to lookup + * by name and by uid, as well as set/get/end iterator routines]. + * The set of functions, and their expected arguments and results, + * constitutes a (database-specific) interface between a frontend and + * all its backends. The switch engine knows as little as possible + * about these interfaces. + * + * (The term "backend" is used ambiguously; it may also refer to a + * particular instantiation of a backend, or to the set of all backends + * for a particular source, e.g. "the nis backend"). + * + * This header file defines the interface between the switch engine and the + * frontends and backends. Interfaces between specific frontends and + * backends are defined elsewhere; many are in . + * Most of these definitions are in the form of pointer to function + * indicies used to call specific backend APIs. + * + * + * Switch-engine outline + * --------------------- + * + * Frontends may call the following routines in the switch engine: + * + * nss_search() does getXXXbyYYY, e.g. getpwnam_r(), getpwuid_r() + * nss_getent() does getXXXent, e.g. getpwent_r() + * nss_setent() does setXXXent, e.g. setpwent() + * nss_endent() does endXXXent, e.g. endpwent() + * nss_delete() releases resources, in the style of endpwent(). + * + * A getpwnam_r() call might proceed thus (with many details omitted): + * + * (1) getpwnam_r fills in (getpwnam-specific) argument/result struct, + * calls nss_search(), + * (2) nss_search queries the name service cache for an existing + * result via a call to _nsc_search(). if the cache + * (nscd) has a definitive answer skip to step 7 + * (3) nss_search looks up configuration info, gets "passwd: files nis", + * (4) nss_search decides to try first source ("files"), + * (a) nss_search locates code for <"passwd", "files"> backend, + * (b) nss_search creates instance of backend, + * (c) nss_search calls get-by-name routine in backend, + * through a function pointer interface, + * (d) backend searches /etc/passwd, doesn't find the name, + * returns "not found" status to nss_search, + * (5) nss_search examines status and config info, decides to try + * next source ("nis"), + * (a) nss_search locates code for <"passwd", "nis"> backend, + * (b) nss_search creates instance of backend, + * (c) nss_search calls get-by-name routine in backend, + * through a function pointer interface, + * (d) backend searches passwd.byname, finds the desired entry, + * fills in the result part of the getpwnam-specific + * struct, returns "success" status to nss_search, + * (6) nss_search examines status and config info, decides to return + * to caller, + * (7) getpwnam_r extracts result from getpwnam-specific struct, + * returns to caller. + * + * + * Data structures + * --------------- + * + * Both databases and sources are represented by case-sensitive strings + * (the same strings that appear in the configuration file). + * + * The switch engine maintains a per-frontend data structure so that the + * results of steps (2), (a) and (b) can be cached. The frontend holds a + * handle (nss_db_root_t) to this structure and passes it in to the + * nss_*() routines. + * + * The nss_setent(), nss_getent() and nss_endent() routines introduce another + * variety of state (the current position in the enumeration process). + * Within a single source, this information is maintained by private data + * in the backend instance -- but, in the presence of multiple sources, the + * switch engine must keep track of the current backend instance [e.g either + * <"passwd", "files"> or <"passwd", "nis"> instances]. The switch engine + * has a separate per-enumeration data structure for this; again, the + * frontend holds a handle (nss_getent_t) and passes it in, along with the + * nss_db_root_t handle, to nss_setent(), nss_getent() and nss_endent(). + * + * + * Multithreading + * -------------- + * + * The switch engine takes care of locking; frontends should be written to + * be reentrant, and a backend instance may assume that all calls to it are + * serialized. + * + * If multiple threads simultaneously want to use a particular backend, the + * switch engine creates multiple backend instances (up to some limit + * specified by the frontend). Backends must of course lock any state that + * is shared between instances, and must serialize calls to any MT-unsafe + * code. + * + * The switch engine has no notion of per-thread state. + * + * Frontends can use the nss_getent_t handle to define the scope of the + * enumeration (set/get/endXXXent) state: a static handle gives global state + * (which is what Posix has specified for the getXXXent_r routines), handles + * in Thread-Specific Data give per-thread state, and handles on the stack + * give per-invocation state. + */ + +/* + * Backend instances + * ----------------- + * + * As far as the switch engine is concerned, an instance of a backend is a + * struct whose first two members are: + * - A pointer to a vector of function pointers, one for each + * database-specific function, + * - The length of the vector (an int), used for bounds-checking. + * There are four well-known function slots in the vector: + * [0] is a destructor for the backend instance, + * [1] is the endXXXent routine, + * [2] is the setXXXent routine, + * [3] is the getXXXent routine. + * Any other slots are database-specific getXXXbyYYY routines; the frontend + * specifies a slot-number to nss_search(). + * + * The functions take two arguments: + * - a pointer to the backend instance (like a C++ "this" pointer) + * - a single (void *) pointer to the database-specific argument/result + * structure (the contents are opaque to the switch engine). + * The four well-known functions ignore the (void *) pointer. + * + * Backend routines return the following status codes to the switch engine: + * + * SUCCESS, UNAVAIL, NOTFOUND, TRYAGAIN (these are the same codes that may + * be specified in the config information; see nsswitch.conf(5)) + * + * The remaining conditions/errors are internally generated and if + * necessary are translated, as to one of the above external errors, + * usually NOTFOUND or UNAVAIL. + * + * NSS_NISSERVDNS_TRYAGAIN (should only be used by the NIS backend for + * NIS server in DNS forwarding mode to indicate DNS server non-response). + * + * The policy component may return NSS_TRYLOCAL which signifies that nscd + * is not going to process the request, and it should be performed locally. + * + * NSS_ERROR is a catchall for internal error conditions, errno will be set + * to a system error that can help track down the problem if + * it is persistent. This error is the result of some internal error + * condition and should not be seen during or exposed to aan application. + * The error may be from the application side switch component or from the + * nscd side switch component. + * + * NSS_ALTRETRY and NSS_ALTRESET are internal codes used by the application + * side policy component and nscd to direct the policy component to + * communicate to a per-user nscd if/when per-user authentication is enabled. + * + * NSS_NSCD_PRIV is a catchall for internal nscd errors or status + * conditions. This return code is not visible to applications. nscd + * may use this as a status flag and maintain additional error or status + * information elsewhere in other private nscd data. This status value + * is for nscd private/internal use only. + */ + +typedef enum { + NSS_SUCCESS = 0, + NSS_NOTFOUND = 1, + NSS_UNAVAIL = 2, + NSS_TRYAGAIN = 3, + NSS_NISSERVDNS_TRYAGAIN = 4, + NSS_TRYLOCAL = 5, + NSS_ERROR = 6, + NSS_ALTRETRY = 7, + NSS_ALTRESET = 8, + NSS_NSCD_PRIV = 9 +} nss_status_t; + +struct nss_backend; + +typedef nss_status_t (*nss_backend_op_t)(struct nss_backend *, void *args); + +struct nss_backend { + nss_backend_op_t *ops; + int n_ops; +}; +typedef struct nss_backend nss_backend_t; +typedef int nss_dbop_t; + +#define NSS_DBOP_DESTRUCTOR 0 +#define NSS_DBOP_ENDENT 1 +#define NSS_DBOP_SETENT 2 +#define NSS_DBOP_GETENT 3 +#define NSS_DBOP_next_iter (NSS_DBOP_GETENT + 1) +#define NSS_DBOP_next_noiter (NSS_DBOP_DESTRUCTOR + 1) +#define NSS_DBOP_next_ipv6_iter (NSS_DBOP_GETENT + 3) + +#define NSS_LOOKUP_DBOP(instp, n) \ + (((n) >= 0 && (n) < (instp)->n_ops) ? (instp)->ops[n] : 0) + +#define NSS_INVOKE_DBOP(instp, n, argp) (\ + ((n) >= 0 && (n) < (instp)->n_ops && (instp)->ops[n] != 0) \ + ? (*(instp)->ops[n])(instp, argp) \ + : NSS_UNAVAIL) + +/* + * Locating and instantiating backends + * ----------------------------------- + * + * To perform step (a), the switch consults a list of backend-finder routines, + * passing a pair. + * + * There is a standard backend-finder; frontends may augment or replace this + * in order to, say, indicate that some backends are "compiled in" with the + * frontend. + * + * Backend-finders return a pointer to a constructor function for the backend. + * (or NULL if they can't find the backend). The switch engine caches these + * function pointers; when it needs to perform step (b), it calls the + * constructor function, which returns a pointer to a new instance of the + * backend, properly initialized (or returns NULL). + */ + +typedef nss_backend_t *(*nss_backend_constr_t)(const char *db_name, + const char *src_name, +/* Hook for (unimplemented) args in nsswitch.conf */ const char *cfg_args); + +struct nss_backend_finder { + nss_backend_constr_t (*lookup) + (void *lkp_priv, const char *, const char *, void **del_privp); + void (*delete) + (void *del_priv, nss_backend_constr_t); + struct nss_backend_finder *next; + void *lookup_priv; +}; + +typedef struct nss_backend_finder nss_backend_finder_t; + +extern nss_backend_finder_t *nss_default_finders; + +/* + * Frontend parameters + * ------------------- + * + * The frontend must tell the switch engine: + * - the database name, + * - the compiled-in default configuration entry. + * It may also override default values for: + * - the database name to use when looking up the configuration + * information (e.g. "shadow" uses the config entry for "passwd"), + * - a limit on the number of instances of each backend that are + * simultaneously active, + * - a limit on the number of instances of each backend that are + * simultaneously dormant (waiting for new requests), + * - a flag that tells the switch engine to use the default configuration + * entry and ignore any other config entry for this database, + * - backend-finders (see above) + * - a cleanup routine that should be called when these parameters are + * about to be deleted. + * + * In order to do this, the frontend includes a pointer to an initialization + * function (nss_db_initf_t) in every nss_*() call. When necessary (normally + * just on the first invocation), the switch engine allocates a parameter + * structure (nss_db_params_t), fills in the default values, then calls + * the initialization function, which should update the parameter structure + * as necessary. + * + * (This might look more natural if we put nss_db_initf_t in nss_db_root_t, + * or abolished nss_db_initf_t and put nss_db_params_t in nss_db_root_t. + * It's done the way it is for shared-library efficiency, namely: + * - keep the unshared data (nss_db_root_t) to a minimum, + * - keep the symbol lookups and relocations to a minimum. + * In particular this means that non-null pointers, e.g. strings and + * function pointers, in global data are a bad thing). + */ + +enum nss_dbp_flags { + NSS_USE_DEFAULT_CONFIG = 0x1 +}; + +struct nss_db_params { + const char *name; /* Mandatory: database name */ + const char *config_name; /* config-file database name */ + const char *default_config; /* Mandatory: default config */ + unsigned max_active_per_src; + unsigned max_dormant_per_src; + enum nss_dbp_flags flags; + nss_backend_finder_t *finders; + void *private; /* Not used by switch */ + void (*cleanup)(struct nss_db_params *); +}; + +typedef struct nss_db_params nss_db_params_t; + +typedef void (*nss_db_initf_t)(nss_db_params_t *); + +/* + * DBD param offsets in NSS2 nscd header. + * Offsets are relative to beginning of dbd section. + * 32 bit offsets should be sufficient, forever. + * 0 offset == NULL + * flags == nss_dbp_flags + */ +typedef struct nss_dbd { + uint32_t o_name; + uint32_t o_config_name; + uint32_t o_default_config; + uint32_t flags; +} nss_dbd_t; + +/* + * These structures are defined inside the implementation of the switch + * engine; the interface just holds pointers to them. + */ +struct nss_db_state; +struct nss_getent_context; + +/* + * Finally, the two handles that frontends hold: + */ + +struct nss_db_root { + struct nss_db_state *s; + mutex_t lock; +}; +typedef struct nss_db_root nss_db_root_t; +#define NSS_DB_ROOT_INIT { 0, DEFAULTMUTEX } +#define DEFINE_NSS_DB_ROOT(name) nss_db_root_t name = NSS_DB_ROOT_INIT + + +typedef struct { + struct nss_getent_context *ctx; + mutex_t lock; +} nss_getent_t; + +#define NSS_GETENT_INIT { 0, DEFAULTMUTEX } +#define DEFINE_NSS_GETENT(name) nss_getent_t name = NSS_GETENT_INIT + +/* + * Policy Engine Configuration + * --------------------------- + * + * When nscd is running it can reconfigure it's internal policy engine + * as well as advise an application's front-end and policy engine on how + * respond optimally to results being returned from nscd. This is done + * through the policy engine configuration interface. + */ + +typedef enum { + NSS_CONFIG_GET, + NSS_CONFIG_PUT, + NSS_CONFIG_ADD, + NSS_CONFIG_DELETE, + NSS_CONFIG_LIST +} nss_config_op_t; + +struct nss_config { + char *name; + nss_config_op_t cop; + mutex_t *lock; + void *buffer; + size_t length; +}; +typedef struct nss_config nss_config_t; + + +extern nss_status_t nss_config(nss_config_t **, int); + +extern nss_status_t nss_search(nss_db_root_t *, nss_db_initf_t, + int search_fnum, void *search_args); +extern nss_status_t nss_getent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *, + void *getent_args); +extern void nss_setent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *); +extern void nss_endent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *); +extern void nss_delete(nss_db_root_t *); + +extern nss_status_t nss_pack(void *, size_t, nss_db_root_t *, + nss_db_initf_t, int, void *); +extern nss_status_t nss_pack_ent(void *, size_t, nss_db_root_t *, + nss_db_initf_t, nss_getent_t *); +extern nss_status_t nss_unpack(void *, size_t, nss_db_root_t *, + nss_db_initf_t, int, void *); +extern nss_status_t nss_unpack_ent(void *, size_t, nss_db_root_t *, + nss_db_initf_t, nss_getent_t *, void *); + +extern nss_status_t _nsc_search(nss_db_root_t *, nss_db_initf_t, + int search_fnum, void *search_args); +extern nss_status_t _nsc_getent_u(nss_db_root_t *, nss_db_initf_t, + nss_getent_t *, void *getent_args); +extern nss_status_t _nsc_setent_u(nss_db_root_t *, nss_db_initf_t, + nss_getent_t *); +extern nss_status_t _nsc_endent_u(nss_db_root_t *, nss_db_initf_t, + nss_getent_t *); + + +#ifdef __cplusplus +} +#endif + +#endif /* _NSS_COMMON_H */ diff --git a/illumos-x86_64/usr/include/nss_dbdefs.h b/illumos-x86_64/usr/include/nss_dbdefs.h new file mode 100644 index 00000000..ca5f9abf --- /dev/null +++ b/illumos-x86_64/usr/include/nss_dbdefs.h @@ -0,0 +1,834 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Database-specific definitions for the getXXXbyYYY routines + * (e.g getpwuid_r(), ether_ntohost()) that use the name-service switch. + * Database-independent definitions are in + * + * Ideally, this is the only switch header file one would add things + * to in order to support a new database. + * + * NOTE: The interfaces documented in this file may change in a minor + * release. It is intended that in the future a stronger committment + * will be made to these interface definitions which will guarantee + * them across minor releases. + */ + +#ifndef _NSS_DBDEFS_H +#define _NSS_DBDEFS_H + +#include +#include +#include +#include /* MAXALIASES, MAXADDRS */ +#include /* LOGNAME_MAX */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NSS_INCLUDE_UNSAFE +#define NSS_INCLUDE_UNSAFE 1 /* Build old, MT-unsafe interfaces, */ +#endif /* NSS_INCLUDE_UNSAFE */ /* e.g. getpwnam (c.f. getpwnam_r) */ + +/* + * Names of the well-known databases. + */ + +#define NSS_DBNAM_ALIASES "aliases" /* E-mail aliases, that is */ +#define NSS_DBNAM_AUTOMOUNT "automount" +#define NSS_DBNAM_BOOTPARAMS "bootparams" +#define NSS_DBNAM_ETHERS "ethers" +#define NSS_DBNAM_GROUP "group" +#define NSS_DBNAM_HOSTS "hosts" +#define NSS_DBNAM_IPNODES "ipnodes" +#define NSS_DBNAM_NETGROUP "netgroup" +#define NSS_DBNAM_NETMASKS "netmasks" +#define NSS_DBNAM_NETWORKS "networks" +#define NSS_DBNAM_PASSWD "passwd" +#define NSS_DBNAM_PRINTERS "printers" +#define NSS_DBNAM_PROJECT "project" +#define NSS_DBNAM_PROTOCOLS "protocols" +#define NSS_DBNAM_PUBLICKEY "publickey" +#define NSS_DBNAM_RPC "rpc" +#define NSS_DBNAM_SERVICES "services" +#define NSS_DBNAM_AUDITUSER "audit_user" +#define NSS_DBNAM_AUTHATTR "auth_attr" +#define NSS_DBNAM_EXECATTR "exec_attr" +#define NSS_DBNAM_PROFATTR "prof_attr" +#define NSS_DBNAM_USERATTR "user_attr" + +#define NSS_DBNAM_TSOL_TP "tnrhtp" +#define NSS_DBNAM_TSOL_RH "tnrhdb" +#define NSS_DBNAM_TSOL_ZC "tnzonecfg" + +/* getspnam() et al use the "passwd" config entry but the "shadow" backend */ +#define NSS_DBNAM_SHADOW "shadow" + +/* The "compat" backend gets config entries for these pseudo-databases */ +#define NSS_DBNAM_PASSWD_COMPAT "passwd_compat" +#define NSS_DBNAM_GROUP_COMPAT "group_compat" + +/* + * Default switch configuration, compiled into the front-ends. + * + * Absent good reasons to the contrary, this should be compatible with the + * default /etc/nsswitch.conf file. + */ +#define NSS_FILES_ONLY "files" +#define NSS_FILES_NS "files nis" +#define NSS_NS_FALLBACK "nis [NOTFOUND=return] files" +#define NSS_NS_ONLY "nis" +#define NSS_TSOL_FALLBACK "files ldap" + +#define NSS_DEFCONF_ALIASES NSS_FILES_NS +#define NSS_DEFCONF_AUTOMOUNT NSS_FILES_NS +#define NSS_DEFCONF_BOOTPARAMS NSS_NS_FALLBACK +#define NSS_DEFCONF_ETHERS NSS_NS_FALLBACK +#define NSS_DEFCONF_GROUP NSS_FILES_NS +#define NSS_DEFCONF_HOSTS NSS_NS_FALLBACK +#define NSS_DEFCONF_IPNODES NSS_NS_FALLBACK +#define NSS_DEFCONF_NETGROUP NSS_NS_ONLY +#define NSS_DEFCONF_NETMASKS NSS_NS_FALLBACK +#define NSS_DEFCONF_NETWORKS NSS_NS_FALLBACK +#define NSS_DEFCONF_PASSWD NSS_FILES_NS +#define NSS_DEFCONF_PRINTERS "user files nis" +#define NSS_DEFCONF_PROJECT NSS_FILES_NS +#define NSS_DEFCONF_PROTOCOLS NSS_NS_FALLBACK +#define NSS_DEFCONF_PUBLICKEY NSS_FILES_NS +#define NSS_DEFCONF_RPC NSS_NS_FALLBACK +#define NSS_DEFCONF_SERVICES NSS_FILES_NS /* speeds up byname() */ + +#define NSS_DEFCONF_GROUP_COMPAT NSS_NS_ONLY +#define NSS_DEFCONF_PASSWD_COMPAT NSS_NS_ONLY + +#define NSS_DEFCONF_ATTRDB NSS_FILES_NS + +#define NSS_DEFCONF_AUDITUSER NSS_DEFCONF_PASSWD +#define NSS_DEFCONF_USERATTR NSS_DEFCONF_PASSWD +#define NSS_DEFCONF_AUTHATTR NSS_DEFCONF_ATTRDB +#define NSS_DEFCONF_PROFATTR NSS_DEFCONF_ATTRDB +#define NSS_DEFCONF_EXECATTR NSS_DEFCONF_PROFATTR + +#define NSS_DEFCONF_TSOL_TP NSS_TSOL_FALLBACK +#define NSS_DEFCONF_TSOL_RH NSS_TSOL_FALLBACK +#define NSS_DEFCONF_TSOL_ZC NSS_TSOL_FALLBACK + +/* + * Line-lengths that the "files" and "compat" backends will try to support. + * It may be reasonable (even advisable) to use smaller values than these. + */ + +#define NSS_BUFSIZ 1024 + +#define NSS_LINELEN_GROUP ((NSS_BUFSIZ) * 8) +#define NSS_LINELEN_HOSTS ((NSS_BUFSIZ) * 8) +#define NSS_LINELEN_IPNODES ((NSS_BUFSIZ) * 8) +#define NSS_LINELEN_NETGROUP ((NSS_BUFSIZ) * 32) +#define NSS_LINELEN_NETMASKS NSS_BUFSIZ +#define NSS_LINELEN_NETWORKS NSS_BUFSIZ +#define NSS_LINELEN_PASSWD NSS_BUFSIZ +#define NSS_LINELEN_PRINTERS NSS_BUFSIZ +#define NSS_LINELEN_PROJECT ((NSS_BUFSIZ) * 4) +#define NSS_LINELEN_PROTOCOLS NSS_BUFSIZ +#define NSS_LINELEN_PUBLICKEY NSS_BUFSIZ +#define NSS_LINELEN_RPC NSS_BUFSIZ +#define NSS_LINELEN_SERVICES NSS_BUFSIZ +#define NSS_LINELEN_SHADOW NSS_BUFSIZ +#define NSS_LINELEN_ETHERS NSS_BUFSIZ +#define NSS_LINELEN_BOOTPARAMS NSS_BUFSIZ + +#define NSS_LINELEN_ATTRDB NSS_BUFSIZ + +#define NSS_LINELEN_AUDITUSER NSS_LINELEN_ATTRDB +#define NSS_LINELEN_AUTHATTR NSS_LINELEN_ATTRDB +#define NSS_LINELEN_EXECATTR NSS_LINELEN_ATTRDB +#define NSS_LINELEN_PROFATTR NSS_LINELEN_ATTRDB +#define NSS_LINELEN_USERATTR NSS_LINELEN_ATTRDB + +#define NSS_MMAPLEN_EXECATTR NSS_LINELEN_EXECATTR * 8 + +#define NSS_LINELEN_TSOL NSS_BUFSIZ + +#define NSS_LINELEN_TSOL_TP NSS_LINELEN_TSOL +#define NSS_LINELEN_TSOL_RH NSS_LINELEN_TSOL +#define NSS_LINELEN_TSOL_ZC NSS_LINELEN_TSOL + +/* + * Reasonable defaults for 'buflen' values passed to _r functions. The BSD + * and SunOS 4.x implementations of the getXXXbyYYY() functions used hard- + * coded array sizes; the values here are meant to handle anything that + * those implementations handled. + * === These might more reasonably go in , et al + */ + +#define NSS_BUFLEN_GROUP NSS_LINELEN_GROUP +#define NSS_BUFLEN_HOSTS \ + (NSS_LINELEN_HOSTS + (MAXALIASES + MAXADDRS + 2) * sizeof (char *)) +#define NSS_BUFLEN_IPNODES \ + (NSS_LINELEN_IPNODES + (MAXALIASES + MAXADDRS + 2) * sizeof (char *)) +#define NSS_BUFLEN_NETGROUP (MAXHOSTNAMELEN * 2 + LOGNAME_MAX + 3) +#define NSS_BUFLEN_NETWORKS NSS_LINELEN_NETWORKS /* === ? + 35 * 4 */ +#define NSS_BUFLEN_PASSWD NSS_LINELEN_PASSWD +#define NSS_BUFLEN_PROJECT (NSS_LINELEN_PROJECT + 800 * sizeof (char *)) +#define NSS_BUFLEN_PROTOCOLS NSS_LINELEN_PROTOCOLS /* === ? + 35 * 4 */ +#define NSS_BUFLEN_PUBLICKEY NSS_LINELEN_PUBLICKEY +#define NSS_BUFLEN_RPC NSS_LINELEN_RPC /* === ? + 35 * 4 */ +#define NSS_BUFLEN_SERVICES NSS_LINELEN_SERVICES /* === ? + 35 * 4 */ +#define NSS_BUFLEN_SHADOW NSS_LINELEN_SHADOW +#define NSS_BUFLEN_ETHERS NSS_LINELEN_ETHERS +#define NSS_BUFLEN_BOOTPARAMS NSS_LINELEN_BOOTPARAMS + +#define NSS_BUFLEN_ATTRDB NSS_LINELEN_ATTRDB + +#define NSS_BUFLEN_AUDITUSER NSS_BUFLEN_ATTRDB +#define NSS_BUFLEN_AUTHATTR NSS_BUFLEN_ATTRDB +#define NSS_BUFLEN_EXECATTR NSS_BUFLEN_ATTRDB +#define NSS_BUFLEN_PROFATTR NSS_BUFLEN_ATTRDB +#define NSS_BUFLEN_USERATTR ((NSS_BUFLEN_ATTRDB) * 8) + +#define NSS_BUFLEN_TSOL NSS_LINELEN_TSOL +#define NSS_BUFLEN_TSOL_TP NSS_BUFLEN_TSOL +#define NSS_BUFLEN_TSOL_RH NSS_BUFLEN_TSOL +#define NSS_BUFLEN_TSOL_ZC NSS_BUFLEN_TSOL + +/* + * Default cache door buffer size (2x largest buffer) + */ + +#define NSS_BUFLEN_DOOR ((NSS_BUFSIZ) * 16) + +/* + * Arguments and results, passed between the frontends and backends for + * the well-known databases. The getXbyY_r() and getXent_r() routines + * use a common format that is further described below; other routines + * use their own formats. + */ + +/* + * The nss_str2ent_t routine is the data marshaller for the nsswitch. + * it converts 'native files' format into 'entry' format as part of the + * return processing for a getXbyY interface. + * + * The nss_groupstr_t routine does the real work for any backend + * that can supply a netgroup entry as a string in /etc/group format + */ +typedef int (*nss_str2ent_t)(const char *in, int inlen, + void *ent, char *buf, int buflen); + +struct nss_groupsbymem; /* forward definition */ +typedef nss_status_t (*nss_groupstr_t)(const char *instr, int inlen, + struct nss_groupsbymem *); + +/* + * The initgroups() function [see initgroups(3c)] needs to find all the + * groups to which a given user belongs. To do this it calls + * _getgroupsbymember(), which is part of the frontend for the "group" + * database. + * We want the same effect as if we used getgrent_r() to enumerate the + * entire groups database (possibly from multiple sources), but getgrent_r() + * is too inefficient. Most backends can do better if they know they're + * meant to scan all groups; hence there's a separate backend operation, + * NSS_DBOP_GROUP_BYMEMBER, which uses the nss_groupsbymem struct. + * Note that the normal return-value from such a backend, even when it + * successfully finds matching group entries, is NSS_NOTFOUND, because + * this tells the switch engine to keep searching in any more sources. + * In fact, the backends only return NSS_SUCCESS if they find enough + * matching entries that the gid_array is completely filled, in which + * case the switch engine should stop searching. + * If the force_slow_way field is set, the backend should eschew any cached + * information (e.g. the YP netid.byname map or the NIS+ cred.org_dir table) + * and should instead grind its way through the group map/table/whatever. + */ + +struct nss_groupsbymem { /* For _getgroupsbymember() */ +/* in: */ + const char *username; + gid_t *gid_array; + int maxgids; + int force_slow_way; + nss_str2ent_t str2ent; + nss_groupstr_t process_cstr; + +/* in_out: */ + int numgids; +}; + +/* + * The netgroup routines are handled as follows: + * + * Policy decision: + * If netgroup A refers to netgroup B, both must occur in the same + * source (other choices give very confusing semantics). This + * assumption is deeply embedded in the frontend and backends. + * + * - setnetgrent(), despite its name, is really a getXXXbyYYY operation: + * it takes a name and finds a netgroup with that name (see the + * nss_setnetgrent_args struct below). The "result" that it returns + * to the frontend is an nss_backend_t for a pseudo-backend that allows + * one to enumerate the members of that netgroup. + * + * - getnetgrent() calls the 'getXXXent' function in the pseudo-backend; + * it doesn't go through the switch engine at all. It uses the + * nss_getnetgrent_args struct below. + * + * - innetgr() is implemented on top of __multi_innetgr(), which replaces + * each (char *) argument of innetgr() with a counted vector of (char *). + * The semantics are the same as an OR of the results of innetgr() + * operations on each possible 4-tuple picked from the arguments, but + * it's possible to implement some cases more efficiently. This is + * important for mountd, which used to read YP netgroup.byhost directly + * in order to determine efficiently whether a given host belonged to any + * one of a long list of netgroups. Wildcarded arguments are indicated + * by a count of zero. + * + * - __multi_innetgr() uses the nss_innetgr_args struct. A backend whose + * source contains at least one of the groups listed in the 'groups' + * vector will return NSS_SUCCESS and will set the 'status' field to + * indicate whether any 4-tuple was satisfied. A backend will only + * return NSS_NOTFOUND if the source contained none of the groups + * listed in the 'groups' vector. + */ + +enum nss_netgr_argn { /* We need (machine, user, domain) triples */ + NSS_NETGR_MACHINE = 0, + NSS_NETGR_USER = 1, + NSS_NETGR_DOMAIN = 2, + NSS_NETGR_N = 3 +}; + +enum nss_netgr_status { /* Status from setnetgrent, multi_innetgr */ + NSS_NETGR_FOUND = 0, + NSS_NETGR_NO = 1, + NSS_NETGR_NOMEM = 2 +}; + +struct nss_setnetgrent_args { +/* in: */ + const char *netgroup; +/* out: */ + nss_backend_t *iterator; /* <==== Explain */ +}; + +struct nss_getnetgrent_args { +/* in: */ + char *buffer; + int buflen; +/* out: */ + enum nss_netgr_status status; + char *retp[NSS_NETGR_N]; +}; + +typedef unsigned nss_innetgr_argc; /* 0 means wildcard */ +typedef char ** nss_innetgr_argv; /* === Do we really need these? */ + +struct nss_innetgr_1arg { + nss_innetgr_argc argc; + nss_innetgr_argv argv; +}; + +struct nss_innetgr_args { +/* in: */ + struct nss_innetgr_1arg arg[NSS_NETGR_N]; + struct nss_innetgr_1arg groups; +/* out: */ + enum nss_netgr_status status; +}; + +/* For NSS_DBOP_NETGROUP_BYNAME */ +struct nss_netgrent { + char *netgr_name; + char *netgr_members; +}; + +/* + * nss_XbyY_buf_t -- structure containing the generic arguments passwd to + * getXXXbyYYY_r() and getXXXent_r() routines. The (void *) value points to + * a struct of the appropriate type, e.g. struct passwd or struct hostent. + * + * The functions that allocate and free these structures do no locking at + * all, since the routines that use them are inherently MT-unsafe anyway. + */ + +typedef struct { + void *result; /* "result" parameter to getXbyY_r() */ + char *buffer; /* "buffer" " " */ + int buflen; /* "buflen" " " */ +} nss_XbyY_buf_t; + +extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int struct_size, int buffer_size); +extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *); + +#define NSS_XbyY_ALLOC(bufpp, str_size, buf_size) (\ + (*bufpp) == 0 \ + ? (*bufpp) = _nss_XbyY_buf_alloc(str_size, buf_size) \ + : (*bufpp)) + +#define NSS_XbyY_FREE(bufpp) (_nss_XbyY_buf_free(*bufpp), (*bufpp) = 0) + +/* + * The nss_XbyY_args_t struct contains all the information passed between + * frontends and backends for the getXbyY_r() and getXent() routines, + * including an nss_XbyY_buf_t and the lookup key (unused for getXXXent_r). + * + * The (*str2ent)() member converts a single XXXent from ASCII text to the + * appropriate struct, storing any pointer data (strings, in_addrs, arrays + * of these) in the buffer. The ASCII text is a counted string (*not* a + * zero-terminated string) whose length is specified by the instr_len + * parameter. The text is found at the address specified by instr and + * the string is treated as readonly. buffer and instr must be non- + * intersecting memory areas. + * + * With the exception of passwd, shadow and group, the text form for these + * databases allows trailing comments and arbitrary whitespace. The + * corresponding str2ent routine assumes that comments, leading whitespace + * and trailing whitespace have been stripped (and thus assumes that entries + * consisting only of these have been discarded). + * + * The text entries for "rpc" and for the databases described in + * follow a common format (a canonical name with a possibly empty list + * of aliases, and some other value), albeit with minor variations. + * The function _nss_netdb_aliases() does most of the generic work involved + * in parsing and marshalling these into the buffer. + */ + +typedef union nss_XbyY_key { /* No tag; backend should know what to expect */ + uid_t uid; + gid_t gid; + projid_t projid; + const char *name; + int number; + struct { + int net; + int type; + } netaddr; + struct { + const char *addr; + int len; + int type; + } hostaddr; + struct { + union { + const char *name; + int port; + } serv; + const char *proto; + } serv; + void *ether; + struct { + const char *name; + const char *keytype; + } pkey; + struct { + const char *name; + int af_family; + int flags; + } ipnode; + void *attrp; /* for the new attr databases */ +} nss_XbyY_key_t; + + +typedef int (*nss_key2str_t)(void *buffer, size_t buflen, + nss_XbyY_key_t *key, size_t *len); + + +typedef struct nss_XbyY_args { + +/* IN */ + nss_XbyY_buf_t buf; + int stayopen; + /* + * Support for setXXXent(stayopen) + * Used only in hosts, protocols, + * networks, rpc, and services. + */ + nss_str2ent_t str2ent; + union nss_XbyY_key key; + +/* OUT */ + void *returnval; + int erange; + int h_errno; /* For gethost*_r() */ + nss_status_t status; /* from the backend last called */ +/* NSS2 */ + nss_key2str_t key2str; /* IN */ + size_t returnlen; /* OUT */ + +/* NSCD/DOOR data */ + +/* ... buffer arena follows... */ +} nss_XbyY_args_t; + + + +/* + * nss/nscd v2 interface, packed buffer format + * + * A key component of the v2 name service switch is the redirection + * of all activity to nscd for actual processing. In the original + * switch most activity took place in each application, and the nscd + * cache component was an add-on optional interface. + * + * The nscd v1 format was a completely private interface that + * implemented specific bufferiing formats on a per getXbyY API basis. + * + * The nss/nscd v2 interface uses a common header and commonalizes + * the buffering format as consistently as possible. The general rule + * of thumb is that backends are required to assemble their results in + * "files based" format [IE the format used on a per result basis as + * returned by the files backend] and then call the standard str2ent + * interface. This is the original intended design as used in the files + * and nis backends. + * + * The benefit of this is that the application side library can assemble + * a request and provide a header and a variable length result buffer via + * a doors API, and then the nscd side switch can assemble a a getXbyY + * request providing the result buffer and a str2ent function that copies + * but does not unpack the result. + * + * This results is returned back via the door, and unpacked using the + * native library side str2ent interface. + * + * Additionally, the common header allows extensibility to add new + * getXbyYs, putXbyYs or other maintenance APIs to/from nscd without + * changing the existing "old style" backend interfaces. + * + * Finally new style getXbyY, putXbyY and backend interfaces can be + * by adding new operation requests to the header, while old style + * backwards compatability. + */ + +/* + * nss/nscd v2 callnumber definitions + */ + +/* + * callnumbers are separated by categories, such as: + * application to nscd requests, nscd to nscd requests, + * smf to nscd requests, etc. + */ + +#define NSCDV2CATMASK (0xFF000000) +#define NSCDV2CALLMASK (0x00FFFFFF) + +/* + * nss/nscd v2 categories + */ + +#define NSCD_CALLCAT_APP ('a'<<24) +#define NSCD_CALLCAT_N2N ('n'<<24) + +/* nscd v2 app-> nscd callnumbers */ + +#define NSCD_SEARCH (NSCD_CALLCAT_APP|0x01) +#define NSCD_SETENT (NSCD_CALLCAT_APP|0x02) +#define NSCD_GETENT (NSCD_CALLCAT_APP|0x03) +#define NSCD_ENDENT (NSCD_CALLCAT_APP|0x04) +#define NSCD_PUT (NSCD_CALLCAT_APP|0x05) +#define NSCD_GETHINTS (NSCD_CALLCAT_APP|0x06) + +/* nscd v2 SETENT cookie markers */ + +#define NSCD_NEW_COOKIE 0 +#define NSCD_LOCAL_COOKIE 1 + +/* nscd v2 header revision */ +/* treated as 0xMMMMmmmm MMMM - Major Rev, mmmm - Minor Rev */ + +#define NSCD_HEADER_REV 0x00020000 + +/* + * ptr/uint data type used to calculate shared nscd buffer struct sizes + * sizes/offsets are arbitrarily limited to 32 bits for 32/64 compatibility + * datatype is 64 bits for possible pointer storage and future use + */ + +typedef uint64_t nssuint_t; + +/* + * nscd v2 buffer layout overview + * + * The key interface to nscd moving forward is the doors interface + * between applications and nscd (NSCD_CALLCAT_APP), and nscd and + * it's children (NSCD_CALLCAT_N2N). + * + * Regardless of the interface used, the buffer layout is consistent. + * The General Layout is: + * [nss_pheader_t][IN key][OUT data results]{extend results} + * + * The header (nss_pheader_t) remains constant. + * Keys and key layouts vary between call numbers/requests + * NSCD_CALLCAT_APP use key layouts mimics/defines in nss_dbdefs.h + * NSCD_CALLCAT_NSN use layouts defined by nscd headers + * Data and data results vary between results + * NSCD_CALLCAT_APP return "file standard format" output buffers + * NSCD_CALLCAT_NSN return data defined by nscd headers + * extended results are optional and vary + * + */ + +/* + * nss_pheader_t -- buffer header structure that contains switch data + * "packed" by the client into a buffer suitable for transport over + * nscd's door, and that can be unpacked into a native form within + * nscd's switch. Capable of packing and unpacking data ans results. + * + * NSCD_HEADER_REV: 0x00020000 16 x uint64 = (128 byte header) + */ + +typedef struct { + uint32_t nsc_callnumber; /* packed buffer request */ + uint32_t nss_dbop; /* old nss dbop */ + uint32_t p_ruid; /* real uid */ + uint32_t p_euid; /* effective uid */ + uint32_t p_version; /* 0xMMMMmmmm Major/minor */ + uint32_t p_status; /* nss_status_t */ + uint32_t p_errno; /* errno */ + uint32_t p_herrno; /* h_errno */ + nssuint_t libpriv; /* reserved (for lib/client) */ + nssuint_t pbufsiz; /* buffer size */ + nssuint_t dbd_off; /* IN: db desc off */ + nssuint_t dbd_len; /* IN: db desc len */ + nssuint_t key_off; /* IN: key off */ + nssuint_t key_len; /* IN: key len */ + nssuint_t data_off; /* OUT: data off */ + nssuint_t data_len; /* OUT: data len */ + nssuint_t ext_off; /* OUT: extended results off */ + nssuint_t ext_len; /* OUT: extended results len */ + nssuint_t nscdpriv; /* reserved (for nscd) */ + nssuint_t reserved1; /* reserved (TBD) */ +} nss_pheader_t; + +/* + * nss_pnetgr_t -- packed offset structure for holding keys used + * by innetgr (__multi_innetgr) key + * Key format is: + * nss_pnetgr_t + * (nssuint_t)[machine_argc] offsets to strings + * (nssuint_t)[user_argc] offsets to strings + * (nssuint_t)[domain_argc] offsets to strings + * (nssuint_t)[groups_argc] offsets to strings + * machine,user,domain,groups strings + */ + +typedef struct { + uint32_t machine_argc; + uint32_t user_argc; + uint32_t domain_argc; + uint32_t groups_argc; + nssuint_t machine_offv; + nssuint_t user_offv; + nssuint_t domain_offv; + nssuint_t groups_offv; +} nss_pnetgr_t; + + +/* status returned by the str2ent parsing routines */ +#define NSS_STR_PARSE_SUCCESS 0 +#define NSS_STR_PARSE_PARSE 1 +#define NSS_STR_PARSE_ERANGE 2 + +#define NSS_XbyY_INIT(str, res, bufp, len, func) (\ + (str)->buf.result = (res), \ + (str)->buf.buffer = (bufp), \ + (str)->buf.buflen = (len), \ + (str)->stayopen = 0, \ + (str)->str2ent = (func), \ + (str)->key2str = NULL, \ + (str)->returnval = 0, \ + (str)->returnlen = 0, \ + (str)->h_errno = 0, \ + (str)->erange = 0) + +#define NSS_XbyY_INIT_EXT(str, res, bufp, len, func, kfunc) (\ + (str)->buf.result = (res), \ + (str)->buf.buffer = (bufp), \ + (str)->buf.buflen = (len), \ + (str)->stayopen = 0, \ + (str)->str2ent = (func), \ + (str)->key2str = (kfunc), \ + (str)->returnval = 0, \ + (str)->returnlen = 0, \ + (str)->h_errno = 0, \ + (str)->erange = 0) + +#define NSS_XbyY_FINI(str) _nss_XbyY_fini(str) + +#define NSS_PACKED_CRED_CHECK(buf, ruid, euid) (\ + ((nss_pheader_t *)(buf))->p_ruid == (ruid) && \ + ((nss_pheader_t *)(buf))->p_euid == (euid)) + +extern void *_nss_XbyY_fini(nss_XbyY_args_t *); +extern char **_nss_netdb_aliases(const char *, int, char *, int); +extern nss_status_t nss_default_key2str(void *, size_t, nss_XbyY_args_t *, + const char *, int, size_t *); +extern nss_status_t nss_packed_arg_init(void *, size_t, nss_db_root_t *, + nss_db_initf_t *, int *, + nss_XbyY_args_t *); +extern nss_status_t nss_packed_context_init(void *, size_t, nss_db_root_t *, + nss_db_initf_t *, nss_getent_t **, + nss_XbyY_args_t *); +extern void nss_packed_set_status(void *, size_t, nss_status_t, + nss_XbyY_args_t *); +extern nss_status_t nss_packed_getkey(void *, size_t, char **, int *, + nss_XbyY_args_t *); + +/* + * nss_dbop_t values for searches with various keys; values for + * destructor/endent/setent/getent are defined in + */ + +/* + * These are part of the "Over the wire" IE app->nscd getXbyY + * op for well known getXbyY's. Cannot use NSS_DBOP_X_Y directly + * because NSS_DBOP_next_iter is NOT an incrementing counter value + * it's a starting offset into an array value. + */ + +#define NSS_DBOP_X(x) ((x)<<16) +#define NSS_DBOP_XY(x, y) ((x)|(y)) + +#define NSS_DBOP_ALIASES NSS_DBOP_X(1) +#define NSS_DBOP_AUTOMOUNT NSS_DBOP_X(2) +#define NSS_DBOP_BOOTPARAMS NSS_DBOP_X(3) +#define NSS_DBOP_ETHERS NSS_DBOP_X(4) +#define NSS_DBOP_GROUP NSS_DBOP_X(5) +#define NSS_DBOP_HOSTS NSS_DBOP_X(6) +#define NSS_DBOP_IPNODES NSS_DBOP_X(7) +#define NSS_DBOP_NETGROUP NSS_DBOP_X(8) +#define NSS_DBOP_NETMASKS NSS_DBOP_X(9) +#define NSS_DBOP_NETWORKS NSS_DBOP_X(10) +#define NSS_DBOP_PASSWD NSS_DBOP_X(11) +#define NSS_DBOP_PRINTERS NSS_DBOP_X(12) +#define NSS_DBOP_PROJECT NSS_DBOP_X(13) +#define NSS_DBOP_PROTOCOLS NSS_DBOP_X(14) +#define NSS_DBOP_PUBLICKEY NSS_DBOP_X(15) +#define NSS_DBOP_RPC NSS_DBOP_X(16) +#define NSS_DBOP_SERVICES NSS_DBOP_X(17) +#define NSS_DBOP_AUDITUSER NSS_DBOP_X(18) +#define NSS_DBOP_AUTHATTR NSS_DBOP_X(19) +#define NSS_DBOP_EXECATTR NSS_DBOP_X(20) +#define NSS_DBOP_PROFATTR NSS_DBOP_X(21) +#define NSS_DBOP_USERATTR NSS_DBOP_X(22) + +#define NSS_DBOP_GROUP_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_GROUP_BYGID (NSS_DBOP_GROUP_BYNAME + 1) +#define NSS_DBOP_GROUP_BYMEMBER (NSS_DBOP_GROUP_BYGID + 1) + +#define NSS_DBOP_PASSWD_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_PASSWD_BYUID (NSS_DBOP_PASSWD_BYNAME + 1) + +/* The "compat" backend requires that PASSWD_BYNAME == SHADOW_BYNAME */ +/* (it also requires that both use key.name to pass the username). */ +#define NSS_DBOP_SHADOW_BYNAME (NSS_DBOP_PASSWD_BYNAME) + +#define NSS_DBOP_PROJECT_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_PROJECT_BYID (NSS_DBOP_PROJECT_BYNAME + 1) + +#define NSS_DBOP_HOSTS_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_HOSTS_BYADDR (NSS_DBOP_HOSTS_BYNAME + 1) + +#define NSS_DBOP_IPNODES_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_IPNODES_BYADDR (NSS_DBOP_IPNODES_BYNAME + 1) + +/* + * NSS_DBOP_NAME_2ADDR + * NSS_DBOP_ADDR_2NAME + * : are defines for ipv6 api's + */ + +#define NSS_DBOP_NAME_2ADDR (NSS_DBOP_next_ipv6_iter) +#define NSS_DBOP_ADDR_2NAME (NSS_DBOP_NAME_2ADDR + 1) + +#define NSS_DBOP_RPC_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_RPC_BYNUMBER (NSS_DBOP_RPC_BYNAME + 1) + +#define NSS_DBOP_NETWORKS_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_NETWORKS_BYADDR (NSS_DBOP_NETWORKS_BYNAME + 1) + +#define NSS_DBOP_SERVICES_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_SERVICES_BYPORT (NSS_DBOP_SERVICES_BYNAME + 1) + +#define NSS_DBOP_PROTOCOLS_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_PROTOCOLS_BYNUMBER (NSS_DBOP_PROTOCOLS_BYNAME + 1) + +#define NSS_DBOP_ETHERS_HOSTTON (NSS_DBOP_next_noiter) +#define NSS_DBOP_ETHERS_NTOHOST (NSS_DBOP_ETHERS_HOSTTON + 1) + +#define NSS_DBOP_BOOTPARAMS_BYNAME (NSS_DBOP_next_noiter) +#define NSS_DBOP_NETMASKS_BYNET (NSS_DBOP_next_noiter) + +#define NSS_DBOP_PRINTERS_BYNAME (NSS_DBOP_next_iter) + +/* + * The "real" backend for netgroup (__multi_innetgr, setnetgrent) + * Note: _BYNAME is implemented only in "files" (for now). + */ +#define NSS_DBOP_NETGROUP_IN (NSS_DBOP_next_iter) +#define NSS_DBOP_NETGROUP_SET (NSS_DBOP_NETGROUP_IN + 1) +#define NSS_DBOP_NETGROUP_BYNAME (NSS_DBOP_NETGROUP_SET + 1) + +/* + * The backend for getpublickey and getsecretkey (getkeys) + */ +#define NSS_DBOP_KEYS_BYNAME (NSS_DBOP_next_iter) + +/* + * The pseudo-backend for netgroup (returned by setnetgrent) doesn't have + * any getXXXbyYYY operations, just the usual destr/end/set/get ops, + * so needs no definitions here. + */ + +#define NSS_DBOP_ATTRDB_BYNAME (NSS_DBOP_next_iter) + +#define NSS_DBOP_AUDITUSER_BYNAME NSS_DBOP_ATTRDB_BYNAME +#define NSS_DBOP_AUTHATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME +#define NSS_DBOP_EXECATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME +#define NSS_DBOP_EXECATTR_BYID (NSS_DBOP_EXECATTR_BYNAME + 1) +#define NSS_DBOP_EXECATTR_BYNAMEID (NSS_DBOP_EXECATTR_BYID + 1) +#define NSS_DBOP_PROFATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME +#define NSS_DBOP_USERATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME + +#define NSS_DBOP_TSOL_TP_BYNAME (NSS_DBOP_next_iter) +#define NSS_DBOP_TSOL_RH_BYADDR (NSS_DBOP_next_iter) +#define NSS_DBOP_TSOL_ZC_BYNAME (NSS_DBOP_next_iter) + +/* + * Used all over in the switch code. The best home for it I can think of. + * Power-of-two alignments only. + */ +#define ROUND_DOWN(n, align) (((uintptr_t)n) & ~((align) - 1l)) +#define ROUND_UP(n, align) ROUND_DOWN(((uintptr_t)n) + (align) - 1l, \ + (align)) + +#ifdef __cplusplus +} +#endif + +#endif /* _NSS_DBDEFS_H */ diff --git a/illumos-x86_64/usr/include/nss_netdir.h b/illumos-x86_64/usr/include/nss_netdir.h new file mode 100644 index 00000000..9ab072fe --- /dev/null +++ b/illumos-x86_64/usr/include/nss_netdir.h @@ -0,0 +1,143 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * nss_netdir.h + * + * Defines structures that are shared between the OSNET-private + * _get_hostserv_inetnetdir_byYY() interfaces and the public + * interfaces gethostbyYY()/getservbyYY() and netdir_getbyYY(). + * Ideally, this header file should never be visible to developers + * outside of the OSNET build. + */ + +#ifndef _NSS_NETDIR_H +#define _NSS_NETDIR_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + NSS_HOST, + NSS_SERV, + NETDIR_BY, + NETDIR_BY_NOSRV, /* bypass service lookup */ + NETDIR_BY6, + NETDIR_BY_NOSRV6, /* bypass service lookup */ + NSS_HOST6 +} nss_netdir_op_t; + +struct nss_netdirbyname_in { + nss_netdir_op_t op_t; + union { + struct nd_hostserv *nd_hs; + union { + struct { + const char *name; + char *buf; + int buflen; + } host; + struct { + const char *name; + char *buf; + int buflen; + int af_family; /* for ipnode */ + int flags; /* for ipnode */ + } host6; + struct { + const char *name; + const char *proto; + char *buf; + int buflen; + } serv; + } nss; + } arg; +}; + +union nss_netdirbyname_out { + struct nd_addrlist **nd_alist; + union { + struct { + struct hostent *hent; + int *herrno_p; + } host; + struct servent *serv; + } nss; +}; + +struct nss_netdirbyaddr_in { + nss_netdir_op_t op_t; + union { + struct netbuf *nd_nbuf; + union { + struct { + const char *addr; + int len; + int type; + char *buf; + int buflen; + } host; + struct { + int port; + const char *proto; + char *buf; + int buflen; + } serv; + } nss; + } arg; +}; + +union nss_netdirbyaddr_out { + struct nd_hostservlist **nd_hslist; + union { + struct { + struct hostent *hent; + int *herrno_p; + } host; + struct servent *serv; + } nss; +}; + +int __classic_netdir_getbyname(struct netconfig *, + struct nd_hostserv *, struct nd_addrlist **); +int __classic_netdir_getbyaddr(struct netconfig *, + struct nd_hostservlist **, struct netbuf *); +int _get_hostserv_inetnetdir_byname(struct netconfig *, + struct nss_netdirbyname_in *, union nss_netdirbyname_out *); +int _get_hostserv_inetnetdir_byaddr(struct netconfig *, + struct nss_netdirbyaddr_in *, union nss_netdirbyaddr_out *); +int __inet_netdir_options(struct netconfig *, + int option, int fd, char *par); +struct netbuf *__inet_uaddr2taddr(struct netconfig *, char *); +char *__inet_taddr2uaddr(struct netconfig *, struct netbuf *); + +#ifdef __cplusplus +} +#endif + +#endif /* _NSS_NETDIR_H */ diff --git a/illumos-x86_64/usr/include/nsswitch.h b/illumos-x86_64/usr/include/nsswitch.h new file mode 100644 index 00000000..6044906a --- /dev/null +++ b/illumos-x86_64/usr/include/nsswitch.h @@ -0,0 +1,137 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * nsswitch.h + * + * Low-level interface to the name-service switch. The interface defined + * in should be used in preference to this. + * + * This is a Project Private interface. It may change in future releases. + */ + +#ifndef _NSSWITCH_H +#define _NSSWITCH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __NSW_CONFIG_FILE +#define __NSW_CONFIG_FILE "/etc/nsswitch.conf" +#endif +#define __NSW_DEFAULT_FILE "/etc/default/nss" + +#define __NSW_HOSTS_DB "hosts" +#define __NSW_PASSWD_DB "passwd" +#define __NSW_GROUP_DB "group" +#define __NSW_NETGROUP_DB "netgroup" +#define __NSW_NETWORKS_DB "networks" +#define __NSW_PROTOCOLS_DB "protocols" +#define __NSW_RPC_DB "rpc" +#define __NSW_SERVICES_DB "services" +#define __NSW_ETHERS_DB "ethers" +#define __NSW_BOOTPARAMS_DB "bootparams" +#define __NSW_NETMASKS_DB "netmasks" +#define __NSW_BROADCASTADDRS_DB "broadcastaddrs" +#define __NSW_MAIL_ALIASES_DB "aliases" +#define __NSW_AUDITUSER_DB "audit_user" +#define __NSW_AUTHATTR_DB "auth_attr" +#define __NSW_EXECATTR_DB "exec_attr" +#define __NSW_PROFATTR_DB "prof_attr" +#define __NSW_USERATTR_DB "user_attr" +#define __NSW_PROJECT_DB "project" + +#define __NSW_STD_ERRS 4 /* number of reserved errors that follow */ + +#define __NSW_SUCCESS 0 /* found the required data */ +#define __NSW_NOTFOUND 1 /* the naming service returned lookup failure */ +#define __NSW_UNAVAIL 2 /* could not call the naming service */ +#define __NSW_TRYAGAIN 3 /* bind error to suggest a retry */ + +typedef unsigned char action_t; +#define __NSW_CONTINUE 0 /* the action is to continue to next service */ +#define __NSW_RETURN 1 /* the action is to return to the user */ + +#define __NSW_STR_RETURN "return" +#define __NSW_STR_CONTINUE "continue" +#define __NSW_STR_SUCCESS "success" +#define __NSW_STR_NOTFOUND "notfound" +#define __NSW_STR_UNAVAIL "unavail" +#define __NSW_STR_TRYAGAIN "tryagain" + +/* prefix for all switch shared objects */ +#define __NSW_LIB "nsw" + +enum __nsw_parse_err { + __NSW_CONF_PARSE_SUCCESS = 0, /* parser found the required policy */ + __NSW_CONF_PARSE_NOFILE = 1, /* the policy files does not exist */ + __NSW_CONF_PARSE_NOPOLICY = 2, /* the required policy is not set */ + /* in the file */ + __NSW_CONF_PARSE_SYSERR = 3 /* system error in the parser */ +}; + + +struct __nsw_long_err { + int nsw_errno; + action_t action; + struct __nsw_long_err *next; +}; + +struct __nsw_lookup { + char *service_name; + action_t actions[__NSW_STD_ERRS]; + struct __nsw_long_err *long_errs; + struct __nsw_lookup *next; +}; + +struct __nsw_switchconfig { + int vers; + char *dbase; + int num_lookups; + struct __nsw_lookup *lookups; +}; + +#define __NSW_ACTION(lkp, err) \ + ((lkp)->next == NULL ? \ + __NSW_RETURN \ + : \ + ((err) >= 0 && (err) < __NSW_STD_ERRS ? \ + (lkp)->actions[err] \ + : \ + __nsw_extended_action(lkp, err))) + +struct __nsw_switchconfig *__nsw_getconfig + (const char *, enum __nsw_parse_err *); +int __nsw_freeconfig(struct __nsw_switchconfig *); +action_t __nsw_extended_action(struct __nsw_lookup *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _NSSWITCH_H */ diff --git a/illumos-x86_64/usr/include/openssl b/illumos-x86_64/usr/include/openssl new file mode 120000 index 00000000..4a91653b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl @@ -0,0 +1 @@ +openssl-3 \ No newline at end of file diff --git a/illumos-x86_64/usr/include/openssl-3/aes.h b/illumos-x86_64/usr/include/openssl-3/aes.h new file mode 100644 index 00000000..d0f9dfc6 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/aes.h @@ -0,0 +1,111 @@ +/* + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_AES_H +# define OPENSSL_AES_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_AES_H +# endif + +# include + +# include +# ifdef __cplusplus +extern "C" { +# endif + +# define AES_BLOCK_SIZE 16 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 + +# define AES_ENCRYPT 1 +# define AES_DECRYPT 0 + +# define AES_MAXNR 14 + + +/* This should be a hidden type, but EVP requires that the size be known */ +struct aes_key_st { +# ifdef AES_LONG + unsigned long rd_key[4 * (AES_MAXNR + 1)]; +# else + unsigned int rd_key[4 * (AES_MAXNR + 1)]; +# endif + int rounds; +}; +typedef struct aes_key_st AES_KEY; + +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 const char *AES_options(void); +OSSL_DEPRECATEDIN_3_0 +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +OSSL_DEPRECATEDIN_3_0 +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +OSSL_DEPRECATEDIN_3_0 +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +OSSL_DEPRECATEDIN_3_0 +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +OSSL_DEPRECATEDIN_3_0 +void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key, const int enc); +OSSL_DEPRECATEDIN_3_0 +void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, + unsigned char *ivec, const int enc); +OSSL_DEPRECATEDIN_3_0 +void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +OSSL_DEPRECATEDIN_3_0 +void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +OSSL_DEPRECATEDIN_3_0 +void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +OSSL_DEPRECATEDIN_3_0 +void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, + unsigned char *ivec, int *num); + +/* NB: the IV is _two_ blocks long */ +OSSL_DEPRECATEDIN_3_0 +void AES_ige_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, + unsigned char *ivec, const int enc); +/* NB: the IV is _four_ blocks long */ +OSSL_DEPRECATEDIN_3_0 +void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, const AES_KEY *key2, + const unsigned char *ivec, const int enc); +OSSL_DEPRECATEDIN_3_0 +int AES_wrap_key(AES_KEY *key, const unsigned char *iv, + unsigned char *out, const unsigned char *in, + unsigned int inlen); +OSSL_DEPRECATEDIN_3_0 +int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, + unsigned char *out, const unsigned char *in, + unsigned int inlen); +# endif + + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/asn1.h b/illumos-x86_64/usr/include/openssl-3/asn1.h new file mode 100644 index 00000000..15e9e446 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/asn1.h @@ -0,0 +1,1134 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/asn1.h.in + * + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_ASN1_H +# define OPENSSL_ASN1_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_ASN1_H +# endif + +# ifndef OPENSSL_NO_STDIO +# include +# endif +# include +# include +# include +# include +# include +# include +# include + +# include +# include + +# ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +# define V_ASN1_UNIVERSAL 0x00 +# define V_ASN1_APPLICATION 0x40 +# define V_ASN1_CONTEXT_SPECIFIC 0x80 +# define V_ASN1_PRIVATE 0xc0 + +# define V_ASN1_CONSTRUCTED 0x20 +# define V_ASN1_PRIMITIVE_TAG 0x1f +# define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG + +# define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ +# define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ +# define V_ASN1_ANY -4 /* used in ASN1 template code */ + +# define V_ASN1_UNDEF -1 +/* ASN.1 tag values */ +# define V_ASN1_EOC 0 +# define V_ASN1_BOOLEAN 1 +# define V_ASN1_INTEGER 2 +# define V_ASN1_BIT_STRING 3 +# define V_ASN1_OCTET_STRING 4 +# define V_ASN1_NULL 5 +# define V_ASN1_OBJECT 6 +# define V_ASN1_OBJECT_DESCRIPTOR 7 +# define V_ASN1_EXTERNAL 8 +# define V_ASN1_REAL 9 +# define V_ASN1_ENUMERATED 10 +# define V_ASN1_UTF8STRING 12 +# define V_ASN1_SEQUENCE 16 +# define V_ASN1_SET 17 +# define V_ASN1_NUMERICSTRING 18 +# define V_ASN1_PRINTABLESTRING 19 +# define V_ASN1_T61STRING 20 +# define V_ASN1_TELETEXSTRING 20 /* alias */ +# define V_ASN1_VIDEOTEXSTRING 21 +# define V_ASN1_IA5STRING 22 +# define V_ASN1_UTCTIME 23 +# define V_ASN1_GENERALIZEDTIME 24 +# define V_ASN1_GRAPHICSTRING 25 +# define V_ASN1_ISO64STRING 26 +# define V_ASN1_VISIBLESTRING 26 /* alias */ +# define V_ASN1_GENERALSTRING 27 +# define V_ASN1_UNIVERSALSTRING 28 +# define V_ASN1_BMPSTRING 30 + +/* + * NB the constants below are used internally by ASN1_INTEGER + * and ASN1_ENUMERATED to indicate the sign. They are *not* on + * the wire tag values. + */ + +# define V_ASN1_NEG 0x100 +# define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) +# define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) + +/* For use with d2i_ASN1_type_bytes() */ +# define B_ASN1_NUMERICSTRING 0x0001 +# define B_ASN1_PRINTABLESTRING 0x0002 +# define B_ASN1_T61STRING 0x0004 +# define B_ASN1_TELETEXSTRING 0x0004 +# define B_ASN1_VIDEOTEXSTRING 0x0008 +# define B_ASN1_IA5STRING 0x0010 +# define B_ASN1_GRAPHICSTRING 0x0020 +# define B_ASN1_ISO64STRING 0x0040 +# define B_ASN1_VISIBLESTRING 0x0040 +# define B_ASN1_GENERALSTRING 0x0080 +# define B_ASN1_UNIVERSALSTRING 0x0100 +# define B_ASN1_OCTET_STRING 0x0200 +# define B_ASN1_BIT_STRING 0x0400 +# define B_ASN1_BMPSTRING 0x0800 +# define B_ASN1_UNKNOWN 0x1000 +# define B_ASN1_UTF8STRING 0x2000 +# define B_ASN1_UTCTIME 0x4000 +# define B_ASN1_GENERALIZEDTIME 0x8000 +# define B_ASN1_SEQUENCE 0x10000 +/* For use with ASN1_mbstring_copy() */ +# define MBSTRING_FLAG 0x1000 +# define MBSTRING_UTF8 (MBSTRING_FLAG) +# define MBSTRING_ASC (MBSTRING_FLAG|1) +# define MBSTRING_BMP (MBSTRING_FLAG|2) +# define MBSTRING_UNIV (MBSTRING_FLAG|4) +# define SMIME_OLDMIME 0x400 +# define SMIME_CRLFEOL 0x800 +# define SMIME_STREAM 0x1000 + +/* Stacks for types not otherwise defined in this header */ +SKM_DEFINE_STACK_OF_INTERNAL(X509_ALGOR, X509_ALGOR, X509_ALGOR) +#define sk_X509_ALGOR_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_value(sk, idx) ((X509_ALGOR *)OPENSSL_sk_value(ossl_check_const_X509_ALGOR_sk_type(sk), (idx))) +#define sk_X509_ALGOR_new(cmp) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new(ossl_check_X509_ALGOR_compfunc_type(cmp))) +#define sk_X509_ALGOR_new_null() ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_null()) +#define sk_X509_ALGOR_new_reserve(cmp, n) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_reserve(ossl_check_X509_ALGOR_compfunc_type(cmp), (n))) +#define sk_X509_ALGOR_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_ALGOR_sk_type(sk), (n)) +#define sk_X509_ALGOR_free(sk) OPENSSL_sk_free(ossl_check_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_delete(sk, i) ((X509_ALGOR *)OPENSSL_sk_delete(ossl_check_X509_ALGOR_sk_type(sk), (i))) +#define sk_X509_ALGOR_delete_ptr(sk, ptr) ((X509_ALGOR *)OPENSSL_sk_delete_ptr(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr))) +#define sk_X509_ALGOR_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) +#define sk_X509_ALGOR_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) +#define sk_X509_ALGOR_pop(sk) ((X509_ALGOR *)OPENSSL_sk_pop(ossl_check_X509_ALGOR_sk_type(sk))) +#define sk_X509_ALGOR_shift(sk) ((X509_ALGOR *)OPENSSL_sk_shift(ossl_check_X509_ALGOR_sk_type(sk))) +#define sk_X509_ALGOR_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_ALGOR_sk_type(sk),ossl_check_X509_ALGOR_freefunc_type(freefunc)) +#define sk_X509_ALGOR_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr), (idx)) +#define sk_X509_ALGOR_set(sk, idx, ptr) ((X509_ALGOR *)OPENSSL_sk_set(ossl_check_X509_ALGOR_sk_type(sk), (idx), ossl_check_X509_ALGOR_type(ptr))) +#define sk_X509_ALGOR_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) +#define sk_X509_ALGOR_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) +#define sk_X509_ALGOR_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr), pnum) +#define sk_X509_ALGOR_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_dup(sk) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_dup(ossl_check_const_X509_ALGOR_sk_type(sk))) +#define sk_X509_ALGOR_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_copyfunc_type(copyfunc), ossl_check_X509_ALGOR_freefunc_type(freefunc))) +#define sk_X509_ALGOR_set_cmp_func(sk, cmp) ((sk_X509_ALGOR_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_compfunc_type(cmp))) + + + +# define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ +/* + * This indicates that the ASN1_STRING is not a real value but just a place + * holder for the location where indefinite length constructed data should be + * inserted in the memory buffer + */ +# define ASN1_STRING_FLAG_NDEF 0x010 + +/* + * This flag is used by the CMS code to indicate that a string is not + * complete and is a place holder for content when it had all been accessed. + * The flag will be reset when content has been written to it. + */ + +# define ASN1_STRING_FLAG_CONT 0x020 +/* + * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING + * type. + */ +# define ASN1_STRING_FLAG_MSTRING 0x040 +/* String is embedded and only content should be freed */ +# define ASN1_STRING_FLAG_EMBED 0x080 +/* String should be parsed in RFC 5280's time format */ +# define ASN1_STRING_FLAG_X509_TIME 0x100 +/* This is the base type that holds just about everything :-) */ +struct asn1_string_st { + int length; + int type; + unsigned char *data; + /* + * The value of the following field depends on the type being held. It + * is mostly being used for BIT_STRING so if the input data has a + * non-zero 'unused bits' value, it will be handled correctly + */ + long flags; +}; + +/* + * ASN1_ENCODING structure: this is used to save the received encoding of an + * ASN1 type. This is useful to get round problems with invalid encodings + * which can break signatures. + */ + +typedef struct ASN1_ENCODING_st { + unsigned char *enc; /* DER encoding */ + long len; /* Length of encoding */ + int modified; /* set to 1 if 'enc' is invalid */ +} ASN1_ENCODING; + +/* Used with ASN1 LONG type: if a long is set to this it is omitted */ +# define ASN1_LONG_UNDEF 0x7fffffffL + +# define STABLE_FLAGS_MALLOC 0x01 +/* + * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted + * as "don't change" and STABLE_FLAGS_MALLOC is always set. By setting + * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias + * STABLE_FLAGS_CLEAR to reflect this. + */ +# define STABLE_FLAGS_CLEAR STABLE_FLAGS_MALLOC +# define STABLE_NO_MASK 0x02 +# define DIRSTRING_TYPE \ + (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) +# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) + +struct asn1_string_table_st { + int nid; + long minsize; + long maxsize; + unsigned long mask; + unsigned long flags; +}; + +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_STRING_TABLE, ASN1_STRING_TABLE, ASN1_STRING_TABLE) +#define sk_ASN1_STRING_TABLE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_value(sk, idx) ((ASN1_STRING_TABLE *)OPENSSL_sk_value(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), (idx))) +#define sk_ASN1_STRING_TABLE_new(cmp) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new(ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp))) +#define sk_ASN1_STRING_TABLE_new_null() ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_null()) +#define sk_ASN1_STRING_TABLE_new_reserve(cmp, n) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp), (n))) +#define sk_ASN1_STRING_TABLE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (n)) +#define sk_ASN1_STRING_TABLE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_delete(sk, i) ((ASN1_STRING_TABLE *)OPENSSL_sk_delete(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (i))) +#define sk_ASN1_STRING_TABLE_delete_ptr(sk, ptr) ((ASN1_STRING_TABLE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr))) +#define sk_ASN1_STRING_TABLE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr)) +#define sk_ASN1_STRING_TABLE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr)) +#define sk_ASN1_STRING_TABLE_pop(sk) ((ASN1_STRING_TABLE *)OPENSSL_sk_pop(ossl_check_ASN1_STRING_TABLE_sk_type(sk))) +#define sk_ASN1_STRING_TABLE_shift(sk) ((ASN1_STRING_TABLE *)OPENSSL_sk_shift(ossl_check_ASN1_STRING_TABLE_sk_type(sk))) +#define sk_ASN1_STRING_TABLE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk),ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc)) +#define sk_ASN1_STRING_TABLE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr), (idx)) +#define sk_ASN1_STRING_TABLE_set(sk, idx, ptr) ((ASN1_STRING_TABLE *)OPENSSL_sk_set(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (idx), ossl_check_ASN1_STRING_TABLE_type(ptr))) +#define sk_ASN1_STRING_TABLE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr)) +#define sk_ASN1_STRING_TABLE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr)) +#define sk_ASN1_STRING_TABLE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr), pnum) +#define sk_ASN1_STRING_TABLE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_dup(sk) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk))) +#define sk_ASN1_STRING_TABLE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_copyfunc_type(copyfunc), ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc))) +#define sk_ASN1_STRING_TABLE_set_cmp_func(sk, cmp) ((sk_ASN1_STRING_TABLE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp))) + + +/* size limits: this stuff is taken straight from RFC2459 */ + +# define ub_name 32768 +# define ub_common_name 64 +# define ub_locality_name 128 +# define ub_state_name 128 +# define ub_organization_name 64 +# define ub_organization_unit_name 64 +# define ub_title 64 +# define ub_email_address 128 + +/* + * Declarations for template structures: for full definitions see asn1t.h + */ +typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; +typedef struct ASN1_TLC_st ASN1_TLC; +/* This is just an opaque pointer */ +typedef struct ASN1_VALUE_st ASN1_VALUE; + +/* Declare ASN1 functions: the implement macro is in asn1t.h */ + +/* + * The mysterious 'extern' that's passed to some macros is innocuous, + * and is there to quiet pre-C99 compilers that may complain about empty + * arguments in macro calls. + */ + +# define DECLARE_ASN1_FUNCTIONS_attr(attr, type) \ + DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, type) +# define DECLARE_ASN1_FUNCTIONS(type) \ + DECLARE_ASN1_FUNCTIONS_attr(extern, type) + +# define DECLARE_ASN1_ALLOC_FUNCTIONS_attr(attr, type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, type) +# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_attr(extern, type) + +# define DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) +# define DECLARE_ASN1_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_FUNCTIONS_name_attr(extern, type, name) + +# define DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, itname, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \ + DECLARE_ASN1_ITEM_attr(attr, itname) +# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_attr(extern, type, itname, name) + +# define DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, name, name) +# define DECLARE_ASN1_ENCODE_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(extern, type, name) + +# define DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \ + attr type *d2i_##name(type **a, const unsigned char **in, long len); \ + attr int i2d_##name(const type *a, unsigned char **out); +# define DECLARE_ASN1_ENCODE_FUNCTIONS_only(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(extern, type, name) + +# define DECLARE_ASN1_NDEF_FUNCTION_attr(attr, name) \ + attr int i2d_##name##_NDEF(const name *a, unsigned char **out); +# define DECLARE_ASN1_NDEF_FUNCTION(name) \ + DECLARE_ASN1_NDEF_FUNCTION_attr(extern, name) + +# define DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \ + attr type *name##_new(void); \ + attr void name##_free(type *a); +# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(extern, type, name) + +# define DECLARE_ASN1_DUP_FUNCTION_attr(attr, type) \ + DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, type) +# define DECLARE_ASN1_DUP_FUNCTION(type) \ + DECLARE_ASN1_DUP_FUNCTION_attr(extern, type) + +# define DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, name) \ + attr type *name##_dup(const type *a); +# define DECLARE_ASN1_DUP_FUNCTION_name(type, name) \ + DECLARE_ASN1_DUP_FUNCTION_name_attr(extern, type, name) + +# define DECLARE_ASN1_PRINT_FUNCTION_attr(attr, stname) \ + DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, stname) +# define DECLARE_ASN1_PRINT_FUNCTION(stname) \ + DECLARE_ASN1_PRINT_FUNCTION_attr(extern, stname) + +# define DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, fname) \ + attr int fname##_print_ctx(BIO *out, const stname *x, int indent, \ + const ASN1_PCTX *pctx); +# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ + DECLARE_ASN1_PRINT_FUNCTION_fname_attr(extern, stname, fname) + +# define D2I_OF(type) type *(*)(type **,const unsigned char **,long) +# define I2D_OF(type) int (*)(const type *,unsigned char **) + +# define CHECKED_D2I_OF(type, d2i) \ + ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0))) +# define CHECKED_I2D_OF(type, i2d) \ + ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0))) +# define CHECKED_NEW_OF(type, xnew) \ + ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0))) +# define CHECKED_PTR_OF(type, p) \ + ((void*) (1 ? p : (type*)0)) +# define CHECKED_PPTR_OF(type, p) \ + ((void**) (1 ? p : (type**)0)) + +# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) +# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(const type *,unsigned char **) +# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) + +typedef void *d2i_of_void(void **, const unsigned char **, long); +typedef int i2d_of_void(const void *, unsigned char **); +typedef int OSSL_i2d_of_void_ctx(const void *, unsigned char **, void *vctx); + +/*- + * The following macros and typedefs allow an ASN1_ITEM + * to be embedded in a structure and referenced. Since + * the ASN1_ITEM pointers need to be globally accessible + * (possibly from shared libraries) they may exist in + * different forms. On platforms that support it the + * ASN1_ITEM structure itself will be globally exported. + * Other platforms will export a function that returns + * an ASN1_ITEM pointer. + * + * To handle both cases transparently the macros below + * should be used instead of hard coding an ASN1_ITEM + * pointer in a structure. + * + * The structure will look like this: + * + * typedef struct SOMETHING_st { + * ... + * ASN1_ITEM_EXP *iptr; + * ... + * } SOMETHING; + * + * It would be initialised as e.g.: + * + * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; + * + * and the actual pointer extracted with: + * + * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); + * + * Finally an ASN1_ITEM pointer can be extracted from an + * appropriate reference with: ASN1_ITEM_rptr(X509). This + * would be used when a function takes an ASN1_ITEM * argument. + * + */ + + +/* + * Platforms that can't easily handle shared global variables are declared as + * functions returning ASN1_ITEM pointers. + */ + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM *ASN1_ITEM_EXP (void); + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +# define ASN1_ITEM_ptr(iptr) (iptr()) + +/* Macro to include ASN1_ITEM pointer from base type */ +# define ASN1_ITEM_ref(iptr) (iptr##_it) + +# define ASN1_ITEM_rptr(ref) (ref##_it()) + +# define DECLARE_ASN1_ITEM_attr(attr, name) \ + attr const ASN1_ITEM * name##_it(void); +# define DECLARE_ASN1_ITEM(name) \ + DECLARE_ASN1_ITEM_attr(extern, name) + +/* Parameters used by ASN1_STRING_print_ex() */ + +/* + * These determine which characters to escape: RFC2253 special characters, + * control characters and MSB set characters + */ + +# define ASN1_STRFLGS_ESC_2253 1 +# define ASN1_STRFLGS_ESC_CTRL 2 +# define ASN1_STRFLGS_ESC_MSB 4 + +/* Lower 8 bits are reserved as an output type specifier */ +# define ASN1_DTFLGS_TYPE_MASK 0x0FUL +# define ASN1_DTFLGS_RFC822 0x00UL +# define ASN1_DTFLGS_ISO8601 0x01UL + +/* + * This flag determines how we do escaping: normally RC2253 backslash only, + * set this to use backslash and quote. + */ + +# define ASN1_STRFLGS_ESC_QUOTE 8 + +/* These three flags are internal use only. */ + +/* Character is a valid PrintableString character */ +# define CHARTYPE_PRINTABLESTRING 0x10 +/* Character needs escaping if it is the first character */ +# define CHARTYPE_FIRST_ESC_2253 0x20 +/* Character needs escaping if it is the last character */ +# define CHARTYPE_LAST_ESC_2253 0x40 + +/* + * NB the internal flags are safely reused below by flags handled at the top + * level. + */ + +/* + * If this is set we convert all character strings to UTF8 first + */ + +# define ASN1_STRFLGS_UTF8_CONVERT 0x10 + +/* + * If this is set we don't attempt to interpret content: just assume all + * strings are 1 byte per character. This will produce some pretty odd + * looking output! + */ + +# define ASN1_STRFLGS_IGNORE_TYPE 0x20 + +/* If this is set we include the string type in the output */ +# define ASN1_STRFLGS_SHOW_TYPE 0x40 + +/* + * This determines which strings to display and which to 'dump' (hex dump of + * content octets or DER encoding). We can only dump non character strings or + * everything. If we don't dump 'unknown' they are interpreted as character + * strings with 1 octet per character and are subject to the usual escaping + * options. + */ + +# define ASN1_STRFLGS_DUMP_ALL 0x80 +# define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 + +/* + * These determine what 'dumping' does, we can dump the content octets or the + * DER encoding: both use the RFC2253 #XXXXX notation. + */ + +# define ASN1_STRFLGS_DUMP_DER 0x200 + +/* + * This flag specifies that RC2254 escaping shall be performed. + */ +#define ASN1_STRFLGS_ESC_2254 0x400 + +/* + * All the string flags consistent with RFC2253, escaping control characters + * isn't essential in RFC2253 but it is advisable anyway. + */ + +# define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ + ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + ASN1_STRFLGS_UTF8_CONVERT | \ + ASN1_STRFLGS_DUMP_UNKNOWN | \ + ASN1_STRFLGS_DUMP_DER) + + +struct asn1_type_st { + int type; + union { + char *ptr; + ASN1_BOOLEAN boolean; + ASN1_STRING *asn1_string; + ASN1_OBJECT *object; + ASN1_INTEGER *integer; + ASN1_ENUMERATED *enumerated; + ASN1_BIT_STRING *bit_string; + ASN1_OCTET_STRING *octet_string; + ASN1_PRINTABLESTRING *printablestring; + ASN1_T61STRING *t61string; + ASN1_IA5STRING *ia5string; + ASN1_GENERALSTRING *generalstring; + ASN1_BMPSTRING *bmpstring; + ASN1_UNIVERSALSTRING *universalstring; + ASN1_UTCTIME *utctime; + ASN1_GENERALIZEDTIME *generalizedtime; + ASN1_VISIBLESTRING *visiblestring; + ASN1_UTF8STRING *utf8string; + /* + * set and sequence are left complete and still contain the set or + * sequence bytes + */ + ASN1_STRING *set; + ASN1_STRING *sequence; + ASN1_VALUE *asn1_value; + } value; +}; + +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_TYPE, ASN1_TYPE, ASN1_TYPE) +#define sk_ASN1_TYPE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_TYPE_sk_type(sk)) +#define sk_ASN1_TYPE_value(sk, idx) ((ASN1_TYPE *)OPENSSL_sk_value(ossl_check_const_ASN1_TYPE_sk_type(sk), (idx))) +#define sk_ASN1_TYPE_new(cmp) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new(ossl_check_ASN1_TYPE_compfunc_type(cmp))) +#define sk_ASN1_TYPE_new_null() ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_null()) +#define sk_ASN1_TYPE_new_reserve(cmp, n) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_TYPE_compfunc_type(cmp), (n))) +#define sk_ASN1_TYPE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_TYPE_sk_type(sk), (n)) +#define sk_ASN1_TYPE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_TYPE_sk_type(sk)) +#define sk_ASN1_TYPE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_TYPE_sk_type(sk)) +#define sk_ASN1_TYPE_delete(sk, i) ((ASN1_TYPE *)OPENSSL_sk_delete(ossl_check_ASN1_TYPE_sk_type(sk), (i))) +#define sk_ASN1_TYPE_delete_ptr(sk, ptr) ((ASN1_TYPE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr))) +#define sk_ASN1_TYPE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) +#define sk_ASN1_TYPE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) +#define sk_ASN1_TYPE_pop(sk) ((ASN1_TYPE *)OPENSSL_sk_pop(ossl_check_ASN1_TYPE_sk_type(sk))) +#define sk_ASN1_TYPE_shift(sk) ((ASN1_TYPE *)OPENSSL_sk_shift(ossl_check_ASN1_TYPE_sk_type(sk))) +#define sk_ASN1_TYPE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_TYPE_sk_type(sk),ossl_check_ASN1_TYPE_freefunc_type(freefunc)) +#define sk_ASN1_TYPE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr), (idx)) +#define sk_ASN1_TYPE_set(sk, idx, ptr) ((ASN1_TYPE *)OPENSSL_sk_set(ossl_check_ASN1_TYPE_sk_type(sk), (idx), ossl_check_ASN1_TYPE_type(ptr))) +#define sk_ASN1_TYPE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) +#define sk_ASN1_TYPE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) +#define sk_ASN1_TYPE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr), pnum) +#define sk_ASN1_TYPE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_TYPE_sk_type(sk)) +#define sk_ASN1_TYPE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_TYPE_sk_type(sk)) +#define sk_ASN1_TYPE_dup(sk) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_TYPE_sk_type(sk))) +#define sk_ASN1_TYPE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_copyfunc_type(copyfunc), ossl_check_ASN1_TYPE_freefunc_type(freefunc))) +#define sk_ASN1_TYPE_set_cmp_func(sk, cmp) ((sk_ASN1_TYPE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_compfunc_type(cmp))) + + +typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; + +DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) +DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SET_ANY) + +/* This is used to contain a list of bit names */ +typedef struct BIT_STRING_BITNAME_st { + int bitnum; + const char *lname; + const char *sname; +} BIT_STRING_BITNAME; + +# define B_ASN1_TIME \ + B_ASN1_UTCTIME | \ + B_ASN1_GENERALIZEDTIME + +# define B_ASN1_PRINTABLE \ + B_ASN1_NUMERICSTRING| \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_T61STRING| \ + B_ASN1_IA5STRING| \ + B_ASN1_BIT_STRING| \ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING|\ + B_ASN1_SEQUENCE|\ + B_ASN1_UNKNOWN + +# define B_ASN1_DIRECTORYSTRING \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_TELETEXSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_UTF8STRING + +# define B_ASN1_DISPLAYTEXT \ + B_ASN1_IA5STRING| \ + B_ASN1_VISIBLESTRING| \ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING + +DECLARE_ASN1_ALLOC_FUNCTIONS_name(ASN1_TYPE, ASN1_TYPE) +DECLARE_ASN1_ENCODE_FUNCTIONS(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) + +int ASN1_TYPE_get(const ASN1_TYPE *a); +void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); +int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); +int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); + +ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t); +void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t); + +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_OBJECT, ASN1_OBJECT, ASN1_OBJECT) +#define sk_ASN1_OBJECT_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_value(sk, idx) ((ASN1_OBJECT *)OPENSSL_sk_value(ossl_check_const_ASN1_OBJECT_sk_type(sk), (idx))) +#define sk_ASN1_OBJECT_new(cmp) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new(ossl_check_ASN1_OBJECT_compfunc_type(cmp))) +#define sk_ASN1_OBJECT_new_null() ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_null()) +#define sk_ASN1_OBJECT_new_reserve(cmp, n) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_OBJECT_compfunc_type(cmp), (n))) +#define sk_ASN1_OBJECT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_OBJECT_sk_type(sk), (n)) +#define sk_ASN1_OBJECT_free(sk) OPENSSL_sk_free(ossl_check_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_delete(sk, i) ((ASN1_OBJECT *)OPENSSL_sk_delete(ossl_check_ASN1_OBJECT_sk_type(sk), (i))) +#define sk_ASN1_OBJECT_delete_ptr(sk, ptr) ((ASN1_OBJECT *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr))) +#define sk_ASN1_OBJECT_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) +#define sk_ASN1_OBJECT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) +#define sk_ASN1_OBJECT_pop(sk) ((ASN1_OBJECT *)OPENSSL_sk_pop(ossl_check_ASN1_OBJECT_sk_type(sk))) +#define sk_ASN1_OBJECT_shift(sk) ((ASN1_OBJECT *)OPENSSL_sk_shift(ossl_check_ASN1_OBJECT_sk_type(sk))) +#define sk_ASN1_OBJECT_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_OBJECT_sk_type(sk),ossl_check_ASN1_OBJECT_freefunc_type(freefunc)) +#define sk_ASN1_OBJECT_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr), (idx)) +#define sk_ASN1_OBJECT_set(sk, idx, ptr) ((ASN1_OBJECT *)OPENSSL_sk_set(ossl_check_ASN1_OBJECT_sk_type(sk), (idx), ossl_check_ASN1_OBJECT_type(ptr))) +#define sk_ASN1_OBJECT_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) +#define sk_ASN1_OBJECT_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) +#define sk_ASN1_OBJECT_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr), pnum) +#define sk_ASN1_OBJECT_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_dup(sk) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_dup(ossl_check_const_ASN1_OBJECT_sk_type(sk))) +#define sk_ASN1_OBJECT_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_copyfunc_type(copyfunc), ossl_check_ASN1_OBJECT_freefunc_type(freefunc))) +#define sk_ASN1_OBJECT_set_cmp_func(sk, cmp) ((sk_ASN1_OBJECT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_compfunc_type(cmp))) + + +DECLARE_ASN1_FUNCTIONS(ASN1_OBJECT) + +ASN1_STRING *ASN1_STRING_new(void); +void ASN1_STRING_free(ASN1_STRING *a); +void ASN1_STRING_clear_free(ASN1_STRING *a); +int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); +DECLARE_ASN1_DUP_FUNCTION(ASN1_STRING) +ASN1_STRING *ASN1_STRING_type_new(int type); +int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); + /* + * Since this is used to store all sorts of things, via macros, for now, + * make its data void * + */ +int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); +void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); +int ASN1_STRING_length(const ASN1_STRING *x); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 void ASN1_STRING_length_set(ASN1_STRING *x, int n); +# endif +int ASN1_STRING_type(const ASN1_STRING *x); +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 unsigned char *ASN1_STRING_data(ASN1_STRING *x); +# endif +const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x); + +DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) +int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length); +int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); +int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n); +int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, + const unsigned char *flags, int flags_len); + +int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, + BIT_STRING_BITNAME *tbl, int indent); +int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl); +int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value, + BIT_STRING_BITNAME *tbl); + +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_INTEGER, ASN1_INTEGER, ASN1_INTEGER) +#define sk_ASN1_INTEGER_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_value(sk, idx) ((ASN1_INTEGER *)OPENSSL_sk_value(ossl_check_const_ASN1_INTEGER_sk_type(sk), (idx))) +#define sk_ASN1_INTEGER_new(cmp) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new(ossl_check_ASN1_INTEGER_compfunc_type(cmp))) +#define sk_ASN1_INTEGER_new_null() ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_null()) +#define sk_ASN1_INTEGER_new_reserve(cmp, n) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_INTEGER_compfunc_type(cmp), (n))) +#define sk_ASN1_INTEGER_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_INTEGER_sk_type(sk), (n)) +#define sk_ASN1_INTEGER_free(sk) OPENSSL_sk_free(ossl_check_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_delete(sk, i) ((ASN1_INTEGER *)OPENSSL_sk_delete(ossl_check_ASN1_INTEGER_sk_type(sk), (i))) +#define sk_ASN1_INTEGER_delete_ptr(sk, ptr) ((ASN1_INTEGER *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr))) +#define sk_ASN1_INTEGER_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) +#define sk_ASN1_INTEGER_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) +#define sk_ASN1_INTEGER_pop(sk) ((ASN1_INTEGER *)OPENSSL_sk_pop(ossl_check_ASN1_INTEGER_sk_type(sk))) +#define sk_ASN1_INTEGER_shift(sk) ((ASN1_INTEGER *)OPENSSL_sk_shift(ossl_check_ASN1_INTEGER_sk_type(sk))) +#define sk_ASN1_INTEGER_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_INTEGER_sk_type(sk),ossl_check_ASN1_INTEGER_freefunc_type(freefunc)) +#define sk_ASN1_INTEGER_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr), (idx)) +#define sk_ASN1_INTEGER_set(sk, idx, ptr) ((ASN1_INTEGER *)OPENSSL_sk_set(ossl_check_ASN1_INTEGER_sk_type(sk), (idx), ossl_check_ASN1_INTEGER_type(ptr))) +#define sk_ASN1_INTEGER_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) +#define sk_ASN1_INTEGER_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) +#define sk_ASN1_INTEGER_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr), pnum) +#define sk_ASN1_INTEGER_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_dup(sk) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_dup(ossl_check_const_ASN1_INTEGER_sk_type(sk))) +#define sk_ASN1_INTEGER_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_copyfunc_type(copyfunc), ossl_check_ASN1_INTEGER_freefunc_type(freefunc))) +#define sk_ASN1_INTEGER_set_cmp_func(sk, cmp) ((sk_ASN1_INTEGER_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_compfunc_type(cmp))) + + + +DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) +ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, + long length); +DECLARE_ASN1_DUP_FUNCTION(ASN1_INTEGER) +int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); + +DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) + +int ASN1_UTCTIME_check(const ASN1_UTCTIME *a); +ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t); +ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, + int offset_day, long offset_sec); +int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); +int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); + +int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a); +ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, + time_t t); +ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, + time_t t, int offset_day, + long offset_sec); +int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); + +int ASN1_TIME_diff(int *pday, int *psec, + const ASN1_TIME *from, const ASN1_TIME *to); + +DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) +DECLARE_ASN1_DUP_FUNCTION(ASN1_OCTET_STRING) +int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, + const ASN1_OCTET_STRING *b); +int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, + int len); + +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_UTF8STRING, ASN1_UTF8STRING, ASN1_UTF8STRING) +#define sk_ASN1_UTF8STRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_value(sk, idx) ((ASN1_UTF8STRING *)OPENSSL_sk_value(ossl_check_const_ASN1_UTF8STRING_sk_type(sk), (idx))) +#define sk_ASN1_UTF8STRING_new(cmp) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp))) +#define sk_ASN1_UTF8STRING_new_null() ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_null()) +#define sk_ASN1_UTF8STRING_new_reserve(cmp, n) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp), (n))) +#define sk_ASN1_UTF8STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_UTF8STRING_sk_type(sk), (n)) +#define sk_ASN1_UTF8STRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_delete(sk, i) ((ASN1_UTF8STRING *)OPENSSL_sk_delete(ossl_check_ASN1_UTF8STRING_sk_type(sk), (i))) +#define sk_ASN1_UTF8STRING_delete_ptr(sk, ptr) ((ASN1_UTF8STRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr))) +#define sk_ASN1_UTF8STRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) +#define sk_ASN1_UTF8STRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) +#define sk_ASN1_UTF8STRING_pop(sk) ((ASN1_UTF8STRING *)OPENSSL_sk_pop(ossl_check_ASN1_UTF8STRING_sk_type(sk))) +#define sk_ASN1_UTF8STRING_shift(sk) ((ASN1_UTF8STRING *)OPENSSL_sk_shift(ossl_check_ASN1_UTF8STRING_sk_type(sk))) +#define sk_ASN1_UTF8STRING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_UTF8STRING_sk_type(sk),ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc)) +#define sk_ASN1_UTF8STRING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr), (idx)) +#define sk_ASN1_UTF8STRING_set(sk, idx, ptr) ((ASN1_UTF8STRING *)OPENSSL_sk_set(ossl_check_ASN1_UTF8STRING_sk_type(sk), (idx), ossl_check_ASN1_UTF8STRING_type(ptr))) +#define sk_ASN1_UTF8STRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) +#define sk_ASN1_UTF8STRING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) +#define sk_ASN1_UTF8STRING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr), pnum) +#define sk_ASN1_UTF8STRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_dup(sk) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_UTF8STRING_sk_type(sk))) +#define sk_ASN1_UTF8STRING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_copyfunc_type(copyfunc), ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc))) +#define sk_ASN1_UTF8STRING_set_cmp_func(sk, cmp) ((sk_ASN1_UTF8STRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_compfunc_type(cmp))) + + +DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_NULL) +DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) + +int UTF8_getc(const unsigned char *str, int len, unsigned long *val); +int UTF8_putc(unsigned char *str, int len, unsigned long value); + +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_GENERALSTRING, ASN1_GENERALSTRING, ASN1_GENERALSTRING) +#define sk_ASN1_GENERALSTRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_value(sk, idx) ((ASN1_GENERALSTRING *)OPENSSL_sk_value(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), (idx))) +#define sk_ASN1_GENERALSTRING_new(cmp) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new(ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp))) +#define sk_ASN1_GENERALSTRING_new_null() ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_null()) +#define sk_ASN1_GENERALSTRING_new_reserve(cmp, n) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp), (n))) +#define sk_ASN1_GENERALSTRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (n)) +#define sk_ASN1_GENERALSTRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_delete(sk, i) ((ASN1_GENERALSTRING *)OPENSSL_sk_delete(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (i))) +#define sk_ASN1_GENERALSTRING_delete_ptr(sk, ptr) ((ASN1_GENERALSTRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr))) +#define sk_ASN1_GENERALSTRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr)) +#define sk_ASN1_GENERALSTRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr)) +#define sk_ASN1_GENERALSTRING_pop(sk) ((ASN1_GENERALSTRING *)OPENSSL_sk_pop(ossl_check_ASN1_GENERALSTRING_sk_type(sk))) +#define sk_ASN1_GENERALSTRING_shift(sk) ((ASN1_GENERALSTRING *)OPENSSL_sk_shift(ossl_check_ASN1_GENERALSTRING_sk_type(sk))) +#define sk_ASN1_GENERALSTRING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk),ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc)) +#define sk_ASN1_GENERALSTRING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr), (idx)) +#define sk_ASN1_GENERALSTRING_set(sk, idx, ptr) ((ASN1_GENERALSTRING *)OPENSSL_sk_set(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (idx), ossl_check_ASN1_GENERALSTRING_type(ptr))) +#define sk_ASN1_GENERALSTRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr)) +#define sk_ASN1_GENERALSTRING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr)) +#define sk_ASN1_GENERALSTRING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr), pnum) +#define sk_ASN1_GENERALSTRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_dup(sk) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk))) +#define sk_ASN1_GENERALSTRING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_copyfunc_type(copyfunc), ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc))) +#define sk_ASN1_GENERALSTRING_set_cmp_func(sk, cmp) ((sk_ASN1_GENERALSTRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp))) + + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) +DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_TIME) + +DECLARE_ASN1_DUP_FUNCTION(ASN1_TIME) +DECLARE_ASN1_DUP_FUNCTION(ASN1_UTCTIME) +DECLARE_ASN1_DUP_FUNCTION(ASN1_GENERALIZEDTIME) + +DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) + +ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); +ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, + int offset_day, long offset_sec); +int ASN1_TIME_check(const ASN1_TIME *t); +ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, + ASN1_GENERALIZEDTIME **out); +int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); +int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str); +int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm); +int ASN1_TIME_normalize(ASN1_TIME *s); +int ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t); +int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b); + +int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a); +int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size); +int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a); +int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size); +int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a); +int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size); +int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type); +int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a); + +int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num); +ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, + const char *sn, const char *ln); + +int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a); +int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r); +int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a); +int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r); + +int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); +long ASN1_INTEGER_get(const ASN1_INTEGER *a); +ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); +BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn); + +int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a); +int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r); + + +int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); +long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a); +ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai); +BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn); + +/* General */ +/* given a string, return the correct type, max is the maximum length */ +int ASN1_PRINTABLE_type(const unsigned char *s, int max); + +unsigned long ASN1_tag2bit(int tag); + +/* SPECIALS */ +int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, + int *pclass, long omax); +int ASN1_check_infinite_end(unsigned char **p, long len); +int ASN1_const_check_infinite_end(const unsigned char **p, long len); +void ASN1_put_object(unsigned char **pp, int constructed, int length, + int tag, int xclass); +int ASN1_put_eoc(unsigned char **pp); +int ASN1_object_size(int constructed, int length, int tag); + +/* Used to implement other functions */ +void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x); + +# define ASN1_dup_of(type,i2d,d2i,x) \ + ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \ + CHECKED_D2I_OF(type, d2i), \ + CHECKED_PTR_OF(const type, x))) + +void *ASN1_item_dup(const ASN1_ITEM *it, const void *x); +int ASN1_item_sign_ex(const ASN1_ITEM *it, X509_ALGOR *algor1, + X509_ALGOR *algor2, ASN1_BIT_STRING *signature, + const void *data, const ASN1_OCTET_STRING *id, + EVP_PKEY *pkey, const EVP_MD *md, OSSL_LIB_CTX *libctx, + const char *propq); +int ASN1_item_verify_ex(const ASN1_ITEM *it, const X509_ALGOR *alg, + const ASN1_BIT_STRING *signature, const void *data, + const ASN1_OCTET_STRING *id, EVP_PKEY *pkey, + OSSL_LIB_CTX *libctx, const char *propq); + +/* ASN1 alloc/free macros for when a type is only used internally */ + +# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type)) +# define M_ASN1_free_of(x, type) \ + ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) + +# ifndef OPENSSL_NO_STDIO +void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x); + +# define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ + ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \ + CHECKED_D2I_OF(type, d2i), \ + in, \ + CHECKED_PPTR_OF(type, x))) + +void *ASN1_item_d2i_fp_ex(const ASN1_ITEM *it, FILE *in, void *x, + OSSL_LIB_CTX *libctx, const char *propq); +void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); +int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, const void *x); + +# define ASN1_i2d_fp_of(type,i2d,out,x) \ + (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \ + out, \ + CHECKED_PTR_OF(const type, x))) + +int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, const void *x); +int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags); +# endif + +int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in); + +void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x); + +# define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ + ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \ + CHECKED_D2I_OF(type, d2i), \ + in, \ + CHECKED_PPTR_OF(type, x))) + +void *ASN1_item_d2i_bio_ex(const ASN1_ITEM *it, BIO *in, void *pval, + OSSL_LIB_CTX *libctx, const char *propq); +void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *pval); +int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, const void *x); + +# define ASN1_i2d_bio_of(type,i2d,out,x) \ + (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \ + out, \ + CHECKED_PTR_OF(const type, x))) + +int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, const void *x); +BIO *ASN1_item_i2d_mem_bio(const ASN1_ITEM *it, const ASN1_VALUE *val); +int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a); +int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a); +int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm); +int ASN1_TIME_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags); +int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); +int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags); +int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off); +int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, + unsigned char *buf, int off); +int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); +int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, + int dump); +const char *ASN1_tag2str(int tag); + +/* Used to load and write Netscape format cert */ + +int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); + +int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); +int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len); +int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, + unsigned char *data, int len); +int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, + unsigned char *data, int max_len); + +void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it); +void *ASN1_item_unpack_ex(const ASN1_STRING *oct, const ASN1_ITEM *it, + OSSL_LIB_CTX *libctx, const char *propq); + +ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, + ASN1_OCTET_STRING **oct); + +void ASN1_STRING_set_default_mask(unsigned long mask); +int ASN1_STRING_set_default_mask_asc(const char *p); +unsigned long ASN1_STRING_get_default_mask(void); +int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask); +int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask, + long minsize, long maxsize); + +ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, + const unsigned char *in, int inlen, + int inform, int nid); +ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); +int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); +void ASN1_STRING_TABLE_cleanup(void); + +/* ASN1 template functions */ + +/* Old API compatible functions */ +ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); +ASN1_VALUE *ASN1_item_new_ex(const ASN1_ITEM *it, OSSL_LIB_CTX *libctx, + const char *propq); +void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); +ASN1_VALUE *ASN1_item_d2i_ex(ASN1_VALUE **val, const unsigned char **in, + long len, const ASN1_ITEM *it, + OSSL_LIB_CTX *libctx, const char *propq); +ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, + long len, const ASN1_ITEM *it); +int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); +int ASN1_item_ndef_i2d(const ASN1_VALUE *val, unsigned char **out, + const ASN1_ITEM *it); + +void ASN1_add_oid_module(void); +void ASN1_add_stable_module(void); + +ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf); +ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf); +int ASN1_str2mask(const char *str, unsigned long *pmask); + +/* ASN1 Print flags */ + +/* Indicate missing OPTIONAL fields */ +# define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001 +/* Mark start and end of SEQUENCE */ +# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002 +/* Mark start and end of SEQUENCE/SET OF */ +# define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004 +/* Show the ASN1 type of primitives */ +# define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008 +/* Don't show ASN1 type of ANY */ +# define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010 +/* Don't show ASN1 type of MSTRINGs */ +# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020 +/* Don't show field names in SEQUENCE */ +# define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040 +/* Show structure names of each SEQUENCE field */ +# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080 +/* Don't show structure name even at top level */ +# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100 + +int ASN1_item_print(BIO *out, const ASN1_VALUE *ifld, int indent, + const ASN1_ITEM *it, const ASN1_PCTX *pctx); +ASN1_PCTX *ASN1_PCTX_new(void); +void ASN1_PCTX_free(ASN1_PCTX *p); +unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p); +void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags); +unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p); +void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags); +unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p); +void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags); +unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p); +void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags); +unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p); +void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); + +ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx)); +void ASN1_SCTX_free(ASN1_SCTX *p); +const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p); +const ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p); +unsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p); +void ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data); +void *ASN1_SCTX_get_app_data(ASN1_SCTX *p); + +const BIO_METHOD *BIO_f_asn1(void); + +/* cannot constify val because of CMS_stream() */ +BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); + +int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, + const ASN1_ITEM *it); +int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, + const char *hdr, const ASN1_ITEM *it); +/* cannot constify val because of CMS_dataFinal() */ +int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, + int ctype_nid, int econt_nid, + STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it); +int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, + int ctype_nid, int econt_nid, + STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it, + OSSL_LIB_CTX *libctx, const char *propq); +ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); +ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, int flags, BIO **bcont, + const ASN1_ITEM *it, ASN1_VALUE **x, + OSSL_LIB_CTX *libctx, const char *propq); +int SMIME_crlf_copy(BIO *in, BIO *out, int flags); +int SMIME_text(BIO *in, BIO *out); + +const ASN1_ITEM *ASN1_ITEM_lookup(const char *name); +const ASN1_ITEM *ASN1_ITEM_get(size_t i); + +/* Legacy compatibility */ +# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) +# define DECLARE_ASN1_FUNCTIONS_const(type) DECLARE_ASN1_FUNCTIONS(type) +# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, name) +# define I2D_OF_const(type) I2D_OF(type) +# define ASN1_dup_of_const(type,i2d,d2i,x) ASN1_dup_of(type,i2d,d2i,x) +# define ASN1_i2d_fp_of_const(type,i2d,out,x) ASN1_i2d_fp_of(type,i2d,out,x) +# define ASN1_i2d_bio_of_const(type,i2d,out,x) ASN1_i2d_bio_of(type,i2d,out,x) + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/asn1err.h b/illumos-x86_64/usr/include/openssl-3/asn1err.h new file mode 100644 index 00000000..8fd85ed8 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/asn1err.h @@ -0,0 +1,142 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ASN1ERR_H +# define OPENSSL_ASN1ERR_H +# pragma once + +# include +# include +# include + + + +/* + * ASN1 reason codes. + */ +# define ASN1_R_ADDING_OBJECT 171 +# define ASN1_R_ASN1_PARSE_ERROR 203 +# define ASN1_R_ASN1_SIG_PARSE_ERROR 204 +# define ASN1_R_AUX_ERROR 100 +# define ASN1_R_BAD_OBJECT_HEADER 102 +# define ASN1_R_BAD_TEMPLATE 230 +# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214 +# define ASN1_R_BN_LIB 105 +# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 +# define ASN1_R_BUFFER_TOO_SMALL 107 +# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 +# define ASN1_R_CONTEXT_NOT_INITIALISED 217 +# define ASN1_R_DATA_IS_WRONG 109 +# define ASN1_R_DECODE_ERROR 110 +# define ASN1_R_DEPTH_EXCEEDED 174 +# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198 +# define ASN1_R_ENCODE_ERROR 112 +# define ASN1_R_ERROR_GETTING_TIME 173 +# define ASN1_R_ERROR_LOADING_SECTION 172 +# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 +# define ASN1_R_EXPECTING_AN_INTEGER 115 +# define ASN1_R_EXPECTING_AN_OBJECT 116 +# define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 +# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 +# define ASN1_R_FIELD_MISSING 121 +# define ASN1_R_FIRST_NUM_TOO_LARGE 122 +# define ASN1_R_GENERALIZEDTIME_IS_TOO_SHORT 232 +# define ASN1_R_HEADER_TOO_LONG 123 +# define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 +# define ASN1_R_ILLEGAL_BOOLEAN 176 +# define ASN1_R_ILLEGAL_CHARACTERS 124 +# define ASN1_R_ILLEGAL_FORMAT 177 +# define ASN1_R_ILLEGAL_HEX 178 +# define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 +# define ASN1_R_ILLEGAL_INTEGER 180 +# define ASN1_R_ILLEGAL_NEGATIVE_VALUE 226 +# define ASN1_R_ILLEGAL_NESTED_TAGGING 181 +# define ASN1_R_ILLEGAL_NULL 125 +# define ASN1_R_ILLEGAL_NULL_VALUE 182 +# define ASN1_R_ILLEGAL_OBJECT 183 +# define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 +# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 +# define ASN1_R_ILLEGAL_PADDING 221 +# define ASN1_R_ILLEGAL_TAGGED_ANY 127 +# define ASN1_R_ILLEGAL_TIME_VALUE 184 +# define ASN1_R_ILLEGAL_ZERO_CONTENT 222 +# define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 +# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 +# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220 +# define ASN1_R_INVALID_BMPSTRING_LENGTH 129 +# define ASN1_R_INVALID_DIGIT 130 +# define ASN1_R_INVALID_MIME_TYPE 205 +# define ASN1_R_INVALID_MODIFIER 186 +# define ASN1_R_INVALID_NUMBER 187 +# define ASN1_R_INVALID_OBJECT_ENCODING 216 +# define ASN1_R_INVALID_SCRYPT_PARAMETERS 227 +# define ASN1_R_INVALID_SEPARATOR 131 +# define ASN1_R_INVALID_STRING_TABLE_VALUE 218 +# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 +# define ASN1_R_INVALID_UTF8STRING 134 +# define ASN1_R_INVALID_VALUE 219 +# define ASN1_R_LENGTH_TOO_LONG 231 +# define ASN1_R_LIST_ERROR 188 +# define ASN1_R_MIME_NO_CONTENT_TYPE 206 +# define ASN1_R_MIME_PARSE_ERROR 207 +# define ASN1_R_MIME_SIG_PARSE_ERROR 208 +# define ASN1_R_MISSING_EOC 137 +# define ASN1_R_MISSING_SECOND_NUMBER 138 +# define ASN1_R_MISSING_VALUE 189 +# define ASN1_R_MSTRING_NOT_UNIVERSAL 139 +# define ASN1_R_MSTRING_WRONG_TAG 140 +# define ASN1_R_NESTED_ASN1_STRING 197 +# define ASN1_R_NESTED_TOO_DEEP 201 +# define ASN1_R_NON_HEX_CHARACTERS 141 +# define ASN1_R_NOT_ASCII_FORMAT 190 +# define ASN1_R_NOT_ENOUGH_DATA 142 +# define ASN1_R_NO_CONTENT_TYPE 209 +# define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 +# define ASN1_R_NO_MULTIPART_BODY_FAILURE 210 +# define ASN1_R_NO_MULTIPART_BOUNDARY 211 +# define ASN1_R_NO_SIG_CONTENT_TYPE 212 +# define ASN1_R_NULL_IS_WRONG_LENGTH 144 +# define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 +# define ASN1_R_ODD_NUMBER_OF_CHARS 145 +# define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 +# define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 +# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 +# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 +# define ASN1_R_SHORT_LINE 150 +# define ASN1_R_SIG_INVALID_MIME_TYPE 213 +# define ASN1_R_STREAMING_NOT_SUPPORTED 202 +# define ASN1_R_STRING_TOO_LONG 151 +# define ASN1_R_STRING_TOO_SHORT 152 +# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 +# define ASN1_R_TIME_NOT_ASCII_FORMAT 193 +# define ASN1_R_TOO_LARGE 223 +# define ASN1_R_TOO_LONG 155 +# define ASN1_R_TOO_SMALL 224 +# define ASN1_R_TYPE_NOT_CONSTRUCTED 156 +# define ASN1_R_TYPE_NOT_PRIMITIVE 195 +# define ASN1_R_UNEXPECTED_EOC 159 +# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215 +# define ASN1_R_UNKNOWN_DIGEST 229 +# define ASN1_R_UNKNOWN_FORMAT 160 +# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 +# define ASN1_R_UNKNOWN_OBJECT_TYPE 162 +# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 +# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199 +# define ASN1_R_UNKNOWN_TAG 194 +# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 +# define ASN1_R_UNSUPPORTED_CIPHER 228 +# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 +# define ASN1_R_UNSUPPORTED_TYPE 196 +# define ASN1_R_UTCTIME_IS_TOO_SHORT 233 +# define ASN1_R_WRONG_INTEGER_TYPE 225 +# define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200 +# define ASN1_R_WRONG_TAG 168 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/asn1t.h b/illumos-x86_64/usr/include/openssl-3/asn1t.h new file mode 100644 index 00000000..74ba47d0 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/asn1t.h @@ -0,0 +1,946 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/asn1t.h.in + * + * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_ASN1T_H +# define OPENSSL_ASN1T_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_ASN1T_H +# endif + +# include +# include +# include + +# ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +# endif + +/* ASN1 template defines, structures and functions */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*- + * These are the possible values for the itype field of the + * ASN1_ITEM structure and determine how it is interpreted. + * + * For PRIMITIVE types the underlying type + * determines the behaviour if items is NULL. + * + * Otherwise templates must contain a single + * template and the type is treated in the + * same way as the type specified in the template. + * + * For SEQUENCE types the templates field points + * to the members, the size field is the + * structure size. + * + * For CHOICE types the templates field points + * to each possible member (typically a union) + * and the 'size' field is the offset of the + * selector. + * + * The 'funcs' field is used for application-specific + * data and functions. + * + * The EXTERN type uses a new style d2i/i2d. + * The new style should be used where possible + * because it avoids things like the d2i IMPLICIT + * hack. + * + * MSTRING is a multiple string type, it is used + * for a CHOICE of character strings where the + * actual strings all occupy an ASN1_STRING + * structure. In this case the 'utype' field + * has a special meaning, it is used as a mask + * of acceptable types using the B_ASN1 constants. + * + * NDEF_SEQUENCE is the same as SEQUENCE except + * that it will use indefinite length constructed + * encoding if requested. + * + */ + +# define ASN1_ITYPE_PRIMITIVE 0x0 +# define ASN1_ITYPE_SEQUENCE 0x1 +# define ASN1_ITYPE_CHOICE 0x2 +/* unused value 0x3 */ +# define ASN1_ITYPE_EXTERN 0x4 +# define ASN1_ITYPE_MSTRING 0x5 +# define ASN1_ITYPE_NDEF_SEQUENCE 0x6 + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)())) + +/* Macros for start and end of ASN1_ITEM definition */ + +# define ASN1_ITEM_start(itname) \ + const ASN1_ITEM * itname##_it(void) \ + { \ + static const ASN1_ITEM local_it = { + +# define static_ASN1_ITEM_start(itname) \ + static ASN1_ITEM_start(itname) + +# define ASN1_ITEM_end(itname) \ + }; \ + return &local_it; \ + } + +/* Macros to aid ASN1 template writing */ + +# define ASN1_ITEM_TEMPLATE(tname) \ + static const ASN1_TEMPLATE tname##_item_tt + +# define ASN1_ITEM_TEMPLATE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_PRIMITIVE,\ + -1,\ + &tname##_item_tt,\ + 0,\ + NULL,\ + 0,\ + #tname \ + ASN1_ITEM_end(tname) +# define static_ASN1_ITEM_TEMPLATE_END(tname) \ + ;\ + static_ASN1_ITEM_start(tname) \ + ASN1_ITYPE_PRIMITIVE,\ + -1,\ + &tname##_item_tt,\ + 0,\ + NULL,\ + 0,\ + #tname \ + ASN1_ITEM_end(tname) + +/* This is a ASN1 type which just embeds a template */ + +/*- + * This pair helps declare a SEQUENCE. We can do: + * + * ASN1_SEQUENCE(stname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END(stname) + * + * This will produce an ASN1_ITEM called stname_it + * for a structure called stname. + * + * If you want the same structure but a different + * name then use: + * + * ASN1_SEQUENCE(itname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END_name(stname, itname) + * + * This will create an item called itname_it using + * a structure called stname. + */ + +# define ASN1_SEQUENCE(tname) \ + static const ASN1_TEMPLATE tname##_seq_tt[] + +# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) + +# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname) + +# define ASN1_SEQUENCE_END_name(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #tname \ + ASN1_ITEM_end(tname) + +# define static_ASN1_SEQUENCE_END_name(stname, tname) \ + ;\ + static_ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +# define ASN1_NDEF_SEQUENCE(tname) \ + ASN1_SEQUENCE(tname) + +# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \ + ASN1_SEQUENCE_cb(tname, cb) + +# define ASN1_SEQUENCE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \ + ASN1_SEQUENCE(tname) + +# define ASN1_SEQUENCE_const_cb(tname, const_cb) \ + static const ASN1_AUX tname##_aux = \ + {NULL, ASN1_AFLG_CONST_CB, 0, 0, NULL, 0, const_cb}; \ + ASN1_SEQUENCE(tname) + +# define ASN1_SEQUENCE_cb_const_cb(tname, cb, const_cb) \ + static const ASN1_AUX tname##_aux = \ + {NULL, ASN1_AFLG_CONST_CB, 0, 0, cb, 0, const_cb}; \ + ASN1_SEQUENCE(tname) + +# define ASN1_SEQUENCE_ref(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0, NULL}; \ + ASN1_SEQUENCE(tname) + +# define ASN1_SEQUENCE_enc(tname, enc, cb) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc), NULL}; \ + ASN1_SEQUENCE(tname) + +# define ASN1_NDEF_SEQUENCE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_NDEF_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(tname),\ + #tname \ + ASN1_ITEM_end(tname) +# define static_ASN1_NDEF_SEQUENCE_END(tname) \ + ;\ + static_ASN1_ITEM_start(tname) \ + ASN1_ITYPE_NDEF_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(tname),\ + #tname \ + ASN1_ITEM_end(tname) + + +# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) +# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname) + +# define ASN1_SEQUENCE_END_ref(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #tname \ + ASN1_ITEM_end(tname) +# define static_ASN1_SEQUENCE_END_ref(stname, tname) \ + ;\ + static_ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_NDEF_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +/*- + * This pair helps declare a CHOICE type. We can do: + * + * ASN1_CHOICE(chname) = { + * ... CHOICE options ... + * ASN1_CHOICE_END(chname) + * + * This will produce an ASN1_ITEM called chname_it + * for a structure called chname. The structure + * definition must look like this: + * typedef struct { + * int type; + * union { + * ASN1_SOMETHING *opt1; + * ASN1_SOMEOTHER *opt2; + * } value; + * } chname; + * + * the name of the selector must be 'type'. + * to use an alternative selector name use the + * ASN1_CHOICE_END_selector() version. + */ + +# define ASN1_CHOICE(tname) \ + static const ASN1_TEMPLATE tname##_ch_tt[] + +# define ASN1_CHOICE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \ + ASN1_CHOICE(tname) + +# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) + +# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname) + +# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) + +# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type) + +# define ASN1_CHOICE_END_selector(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \ + ;\ + static_ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +# define ASN1_CHOICE_END_cb(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +/* This helps with the template wrapper form of ASN1_ITEM */ + +# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ + (flags), (tag), 0,\ + #name, ASN1_ITEM_ref(type) } + +/* These help with SEQUENCE or CHOICE components */ + +/* used to declare other types */ + +# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ + (flags), (tag), offsetof(stname, field),\ + #field, ASN1_ITEM_ref(type) } + +/* implicit and explicit helper macros */ + +# define ASN1_IMP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type) + +# define ASN1_EXP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type) + +/* Any defined by macros: the field used is in the table itself */ + +# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } +# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } + +/* Plain simple type */ +# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) +/* Embedded simple type */ +# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type) + +/* OPTIONAL simple type */ +# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) +# define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED, 0, stname, field, type) + +/* IMPLICIT tagged simple type */ +# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) +# define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED) + +/* IMPLICIT tagged OPTIONAL simple type */ +# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) +# define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED) + +/* Same as above but EXPLICIT */ + +# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) +# define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED) +# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) +# define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED) + +/* SEQUENCE OF type */ +# define ASN1_SEQUENCE_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) + +/* OPTIONAL SEQUENCE OF */ +# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Same as above but for SET OF */ + +# define ASN1_SET_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) + +# define ASN1_SET_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ + +# define ASN1_IMP_SET_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +# define ASN1_EXP_SET_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +/* EXPLICIT using indefinite length constructed form */ +# define ASN1_NDEF_EXP(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) + +/* EXPLICIT OPTIONAL using indefinite length constructed form */ +# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) + +/* Macros for the ASN1_ADB structure */ + +# define ASN1_ADB(name) \ + static const ASN1_ADB_TABLE name##_adbtbl[] + +# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ + ;\ + static const ASN1_ITEM *name##_adb(void) \ + { \ + static const ASN1_ADB internal_adb = \ + {\ + flags,\ + offsetof(name, field),\ + adb_cb,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + }; \ + return (const ASN1_ITEM *) &internal_adb; \ + } \ + void dummy_function(void) + +# define ADB_ENTRY(val, template) {val, template} + +# define ASN1_ADB_TEMPLATE(name) \ + static const ASN1_TEMPLATE name##_tt + +/* + * This is the ASN1 template structure that defines a wrapper round the + * actual type. It determines the actual position of the field in the value + * structure, various flags such as OPTIONAL and the field name. + */ + +struct ASN1_TEMPLATE_st { + unsigned long flags; /* Various flags */ + long tag; /* tag, not used if no tagging */ + unsigned long offset; /* Offset of this field in structure */ + const char *field_name; /* Field name */ + ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ +}; + +/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ + +# define ASN1_TEMPLATE_item(t) (t->item_ptr) +# define ASN1_TEMPLATE_adb(t) (t->item_ptr) + +typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; +typedef struct ASN1_ADB_st ASN1_ADB; + +struct ASN1_ADB_st { + unsigned long flags; /* Various flags */ + unsigned long offset; /* Offset of selector field */ + int (*adb_cb)(long *psel); /* Application callback */ + const ASN1_ADB_TABLE *tbl; /* Table of possible types */ + long tblcount; /* Number of entries in tbl */ + const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ + const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ +}; + +struct ASN1_ADB_TABLE_st { + long value; /* NID for an object or value for an int */ + const ASN1_TEMPLATE tt; /* item for this value */ +}; + +/* template flags */ + +/* Field is optional */ +# define ASN1_TFLG_OPTIONAL (0x1) + +/* Field is a SET OF */ +# define ASN1_TFLG_SET_OF (0x1 << 1) + +/* Field is a SEQUENCE OF */ +# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) + +/* + * Special case: this refers to a SET OF that will be sorted into DER order + * when encoded *and* the corresponding STACK will be modified to match the + * new order. + */ +# define ASN1_TFLG_SET_ORDER (0x3 << 1) + +/* Mask for SET OF or SEQUENCE OF */ +# define ASN1_TFLG_SK_MASK (0x3 << 1) + +/* + * These flags mean the tag should be taken from the tag field. If EXPLICIT + * then the underlying type is used for the inner tag. + */ + +/* IMPLICIT tagging */ +# define ASN1_TFLG_IMPTAG (0x1 << 3) + +/* EXPLICIT tagging, inner tag from underlying type */ +# define ASN1_TFLG_EXPTAG (0x2 << 3) + +# define ASN1_TFLG_TAG_MASK (0x3 << 3) + +/* context specific IMPLICIT */ +# define ASN1_TFLG_IMPLICIT (ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT) + +/* context specific EXPLICIT */ +# define ASN1_TFLG_EXPLICIT (ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT) + +/* + * If tagging is in force these determine the type of tag to use. Otherwise + * the tag is determined by the underlying type. These values reflect the + * actual octet format. + */ + +/* Universal tag */ +# define ASN1_TFLG_UNIVERSAL (0x0<<6) +/* Application tag */ +# define ASN1_TFLG_APPLICATION (0x1<<6) +/* Context specific tag */ +# define ASN1_TFLG_CONTEXT (0x2<<6) +/* Private tag */ +# define ASN1_TFLG_PRIVATE (0x3<<6) + +# define ASN1_TFLG_TAG_CLASS (0x3<<6) + +/* + * These are for ANY DEFINED BY type. In this case the 'item' field points to + * an ASN1_ADB structure which contains a table of values to decode the + * relevant type + */ + +# define ASN1_TFLG_ADB_MASK (0x3<<8) + +# define ASN1_TFLG_ADB_OID (0x1<<8) + +# define ASN1_TFLG_ADB_INT (0x1<<9) + +/* + * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes + * indefinite length constructed encoding to be used if required. + */ + +# define ASN1_TFLG_NDEF (0x1<<11) + +/* Field is embedded and not a pointer */ +# define ASN1_TFLG_EMBED (0x1 << 12) + +/* This is the actual ASN1 item itself */ + +struct ASN1_ITEM_st { + char itype; /* The item type, primitive, SEQUENCE, CHOICE + * or extern */ + long utype; /* underlying type */ + const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains + * the contents */ + long tcount; /* Number of templates if SEQUENCE or CHOICE */ + const void *funcs; /* further data and type-specific functions */ + /* funcs can be ASN1_PRIMITIVE_FUNCS*, ASN1_EXTERN_FUNCS*, or ASN1_AUX* */ + long size; /* Structure size (usually) */ + const char *sname; /* Structure name */ +}; + +/* + * Cache for ASN1 tag and length, so we don't keep re-reading it for things + * like CHOICE + */ + +struct ASN1_TLC_st { + char valid; /* Values below are valid */ + int ret; /* return value */ + long plen; /* length */ + int ptag; /* class value */ + int pclass; /* class value */ + int hdrlen; /* header length */ +}; + +/* Typedefs for ASN1 function pointers */ +typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, + ASN1_TLC *ctx); + +typedef int ASN1_ex_d2i_ex(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, + ASN1_TLC *ctx, OSSL_LIB_CTX *libctx, + const char *propq); +typedef int ASN1_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, + const ASN1_ITEM *it, int tag, int aclass); +typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); +typedef int ASN1_ex_new_ex_func(ASN1_VALUE **pval, const ASN1_ITEM *it, + OSSL_LIB_CTX *libctx, const char *propq); +typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); + +typedef int ASN1_ex_print_func(BIO *out, const ASN1_VALUE **pval, + int indent, const char *fname, + const ASN1_PCTX *pctx); + +typedef int ASN1_primitive_i2c(const ASN1_VALUE **pval, unsigned char *cont, + int *putype, const ASN1_ITEM *it); +typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, + int len, int utype, char *free_cont, + const ASN1_ITEM *it); +typedef int ASN1_primitive_print(BIO *out, const ASN1_VALUE **pval, + const ASN1_ITEM *it, int indent, + const ASN1_PCTX *pctx); + +typedef struct ASN1_EXTERN_FUNCS_st { + void *app_data; + ASN1_ex_new_func *asn1_ex_new; + ASN1_ex_free_func *asn1_ex_free; + ASN1_ex_free_func *asn1_ex_clear; + ASN1_ex_d2i *asn1_ex_d2i; + ASN1_ex_i2d *asn1_ex_i2d; + ASN1_ex_print_func *asn1_ex_print; + ASN1_ex_new_ex_func *asn1_ex_new_ex; + ASN1_ex_d2i_ex *asn1_ex_d2i_ex; +} ASN1_EXTERN_FUNCS; + +typedef struct ASN1_PRIMITIVE_FUNCS_st { + void *app_data; + unsigned long flags; + ASN1_ex_new_func *prim_new; + ASN1_ex_free_func *prim_free; + ASN1_ex_free_func *prim_clear; + ASN1_primitive_c2i *prim_c2i; + ASN1_primitive_i2c *prim_i2c; + ASN1_primitive_print *prim_print; +} ASN1_PRIMITIVE_FUNCS; + +/* + * This is the ASN1_AUX structure: it handles various miscellaneous + * requirements. For example the use of reference counts and an informational + * callback. The "informational callback" is called at various points during + * the ASN1 encoding and decoding. It can be used to provide minor + * customisation of the structures used. This is most useful where the + * supplied routines *almost* do the right thing but need some extra help at + * a few points. If the callback returns zero then it is assumed a fatal + * error has occurred and the main operation should be abandoned. If major + * changes in the default behaviour are required then an external type is + * more appropriate. + * For the operations ASN1_OP_I2D_PRE, ASN1_OP_I2D_POST, ASN1_OP_PRINT_PRE, and + * ASN1_OP_PRINT_POST, meanwhile a variant of the callback with const parameter + * 'in' is provided to make clear statically that its input is not modified. If + * and only if this variant is in use the flag ASN1_AFLG_CONST_CB must be set. + */ + +typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, + void *exarg); +typedef int ASN1_aux_const_cb(int operation, const ASN1_VALUE **in, + const ASN1_ITEM *it, void *exarg); + +typedef struct ASN1_AUX_st { + void *app_data; + int flags; + int ref_offset; /* Offset of reference value */ + int ref_lock; /* Offset of lock value */ + ASN1_aux_cb *asn1_cb; + int enc_offset; /* Offset of ASN1_ENCODING structure */ + ASN1_aux_const_cb *asn1_const_cb; /* for ASN1_OP_I2D_ and ASN1_OP_PRINT_ */ +} ASN1_AUX; + +/* For print related callbacks exarg points to this structure */ +typedef struct ASN1_PRINT_ARG_st { + BIO *out; + int indent; + const ASN1_PCTX *pctx; +} ASN1_PRINT_ARG; + +/* For streaming related callbacks exarg points to this structure */ +typedef struct ASN1_STREAM_ARG_st { + /* BIO to stream through */ + BIO *out; + /* BIO with filters appended */ + BIO *ndef_bio; + /* Streaming I/O boundary */ + unsigned char **boundary; +} ASN1_STREAM_ARG; + +/* Flags in ASN1_AUX */ + +/* Use a reference count */ +# define ASN1_AFLG_REFCOUNT 1 +/* Save the encoding of structure (useful for signatures) */ +# define ASN1_AFLG_ENCODING 2 +/* The Sequence length is invalid */ +# define ASN1_AFLG_BROKEN 4 +/* Use the new asn1_const_cb */ +# define ASN1_AFLG_CONST_CB 8 + +/* operation values for asn1_cb */ + +# define ASN1_OP_NEW_PRE 0 +# define ASN1_OP_NEW_POST 1 +# define ASN1_OP_FREE_PRE 2 +# define ASN1_OP_FREE_POST 3 +# define ASN1_OP_D2I_PRE 4 +# define ASN1_OP_D2I_POST 5 +# define ASN1_OP_I2D_PRE 6 +# define ASN1_OP_I2D_POST 7 +# define ASN1_OP_PRINT_PRE 8 +# define ASN1_OP_PRINT_POST 9 +# define ASN1_OP_STREAM_PRE 10 +# define ASN1_OP_STREAM_POST 11 +# define ASN1_OP_DETACHED_PRE 12 +# define ASN1_OP_DETACHED_POST 13 +# define ASN1_OP_DUP_PRE 14 +# define ASN1_OP_DUP_POST 15 +# define ASN1_OP_GET0_LIBCTX 16 +# define ASN1_OP_GET0_PROPQ 17 + +/* Macro to implement a primitive type */ +# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) +# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement a multi string type */ +# define IMPLEMENT_ASN1_MSTRING(itname, mask) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ + ASN1_ITEM_end(itname) + +# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_EXTERN, \ + tag, \ + NULL, \ + 0, \ + &fptrs, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +/* Macro to implement standard functions in terms of ASN1_ITEM structures */ + +# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) + +# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) + +# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ + IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) + +# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) + +# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) + +# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ + pre stname *fname##_new(void) \ + { \ + return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ + } \ + pre void fname##_free(stname *a) \ + { \ + ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ + } + +# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ + stname *fname##_new(void) \ + { \ + return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ + } \ + void fname##_free(stname *a) \ + { \ + ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ + } + +# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ + int i2d_##stname##_NDEF(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_ndef_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ + } + +# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \ + static stname *d2i_##stname(stname **a, \ + const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \ + ASN1_ITEM_rptr(stname)); \ + } \ + static int i2d_##stname(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((const ASN1_VALUE *)a, out, \ + ASN1_ITEM_rptr(stname)); \ + } + +# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ + stname * stname##_dup(const stname *x) \ + { \ + return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ + } + +# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ + IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) + +# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ + int fname##_print_ctx(BIO *out, const stname *x, int indent, \ + const ASN1_PCTX *pctx) \ + { \ + return ASN1_item_print(out, (const ASN1_VALUE *)x, indent, \ + ASN1_ITEM_rptr(itname), pctx); \ + } + +/* external definitions for primitive types */ + +DECLARE_ASN1_ITEM(ASN1_BOOLEAN) +DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_SEQUENCE) +DECLARE_ASN1_ITEM(CBIGNUM) +DECLARE_ASN1_ITEM(BIGNUM) +DECLARE_ASN1_ITEM(INT32) +DECLARE_ASN1_ITEM(ZINT32) +DECLARE_ASN1_ITEM(UINT32) +DECLARE_ASN1_ITEM(ZUINT32) +DECLARE_ASN1_ITEM(INT64) +DECLARE_ASN1_ITEM(ZINT64) +DECLARE_ASN1_ITEM(UINT64) +DECLARE_ASN1_ITEM(ZUINT64) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* + * LONG and ZLONG are strongly discouraged for use as stored data, as the + * underlying C type (long) differs in size depending on the architecture. + * They are designed with 32-bit longs in mind. + */ +DECLARE_ASN1_ITEM(LONG) +DECLARE_ASN1_ITEM(ZLONG) +# endif + +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_VALUE, ASN1_VALUE, ASN1_VALUE) +#define sk_ASN1_VALUE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_value(sk, idx) ((ASN1_VALUE *)OPENSSL_sk_value(ossl_check_const_ASN1_VALUE_sk_type(sk), (idx))) +#define sk_ASN1_VALUE_new(cmp) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new(ossl_check_ASN1_VALUE_compfunc_type(cmp))) +#define sk_ASN1_VALUE_new_null() ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_null()) +#define sk_ASN1_VALUE_new_reserve(cmp, n) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_VALUE_compfunc_type(cmp), (n))) +#define sk_ASN1_VALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_VALUE_sk_type(sk), (n)) +#define sk_ASN1_VALUE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_delete(sk, i) ((ASN1_VALUE *)OPENSSL_sk_delete(ossl_check_ASN1_VALUE_sk_type(sk), (i))) +#define sk_ASN1_VALUE_delete_ptr(sk, ptr) ((ASN1_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))) +#define sk_ASN1_VALUE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)) +#define sk_ASN1_VALUE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)) +#define sk_ASN1_VALUE_pop(sk) ((ASN1_VALUE *)OPENSSL_sk_pop(ossl_check_ASN1_VALUE_sk_type(sk))) +#define sk_ASN1_VALUE_shift(sk) ((ASN1_VALUE *)OPENSSL_sk_shift(ossl_check_ASN1_VALUE_sk_type(sk))) +#define sk_ASN1_VALUE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_VALUE_sk_type(sk),ossl_check_ASN1_VALUE_freefunc_type(freefunc)) +#define sk_ASN1_VALUE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), (idx)) +#define sk_ASN1_VALUE_set(sk, idx, ptr) ((ASN1_VALUE *)OPENSSL_sk_set(ossl_check_ASN1_VALUE_sk_type(sk), (idx), ossl_check_ASN1_VALUE_type(ptr))) +#define sk_ASN1_VALUE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)) +#define sk_ASN1_VALUE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)) +#define sk_ASN1_VALUE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), pnum) +#define sk_ASN1_VALUE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_dup(sk) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_VALUE_sk_type(sk))) +#define sk_ASN1_VALUE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_copyfunc_type(copyfunc), ossl_check_ASN1_VALUE_freefunc_type(freefunc))) +#define sk_ASN1_VALUE_set_cmp_func(sk, cmp) ((sk_ASN1_VALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_compfunc_type(cmp))) + + + +/* Functions used internally by the ASN1 code */ + +int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); +void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); + +int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, + ASN1_TLC *ctx); + +int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, + const ASN1_ITEM *it, int tag, int aclass); + +/* Legacy compatibility */ +# define IMPLEMENT_ASN1_FUNCTIONS_const(name) IMPLEMENT_ASN1_FUNCTIONS(name) +# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/async.h b/illumos-x86_64/usr/include/openssl-3/async.h new file mode 100644 index 00000000..826ffb99 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/async.h @@ -0,0 +1,104 @@ +/* + * Copyright 2015-2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include + +#ifndef OPENSSL_ASYNC_H +# define OPENSSL_ASYNC_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_ASYNC_H +# endif + +#if defined(_WIN32) +# if defined(BASETYPES) || defined(_WINDEF_H) +/* application has to include to use this */ +#define OSSL_ASYNC_FD HANDLE +#define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE +# endif +#else +#define OSSL_ASYNC_FD int +#define OSSL_BAD_ASYNC_FD -1 +#endif +# include + + +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct async_job_st ASYNC_JOB; +typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; +typedef int (*ASYNC_callback_fn)(void *arg); + +#define ASYNC_ERR 0 +#define ASYNC_NO_JOBS 1 +#define ASYNC_PAUSE 2 +#define ASYNC_FINISH 3 + +#define ASYNC_STATUS_UNSUPPORTED 0 +#define ASYNC_STATUS_ERR 1 +#define ASYNC_STATUS_OK 2 +#define ASYNC_STATUS_EAGAIN 3 + +int ASYNC_init_thread(size_t max_size, size_t init_size); +void ASYNC_cleanup_thread(void); + +#ifdef OSSL_ASYNC_FD +ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void); +void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx); +int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, + OSSL_ASYNC_FD fd, + void *custom_data, + void (*cleanup)(ASYNC_WAIT_CTX *, const void *, + OSSL_ASYNC_FD, void *)); +int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, + OSSL_ASYNC_FD *fd, void **custom_data); +int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, + size_t *numfds); +int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx, + ASYNC_callback_fn *callback, + void **callback_arg); +int ASYNC_WAIT_CTX_set_callback(ASYNC_WAIT_CTX *ctx, + ASYNC_callback_fn callback, + void *callback_arg); +int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status); +int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx); +int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, + size_t *numaddfds, OSSL_ASYNC_FD *delfd, + size_t *numdelfds); +int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); +#endif + +int ASYNC_is_capable(void); + +typedef void *(*ASYNC_stack_alloc_fn)(size_t *num); +typedef void (*ASYNC_stack_free_fn)(void *addr); + +int ASYNC_set_mem_functions(ASYNC_stack_alloc_fn alloc_fn, + ASYNC_stack_free_fn free_fn); +void ASYNC_get_mem_functions(ASYNC_stack_alloc_fn *alloc_fn, + ASYNC_stack_free_fn *free_fn); + +int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, + int (*func)(void *), void *args, size_t size); +int ASYNC_pause_job(void); + +ASYNC_JOB *ASYNC_get_current_job(void); +ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); +void ASYNC_block_pause(void); +void ASYNC_unblock_pause(void); + + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/asyncerr.h b/illumos-x86_64/usr/include/openssl-3/asyncerr.h new file mode 100644 index 00000000..c093f7be --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/asyncerr.h @@ -0,0 +1,29 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ASYNCERR_H +# define OPENSSL_ASYNCERR_H +# pragma once + +# include +# include +# include + + + +/* + * ASYNC reason codes. + */ +# define ASYNC_R_FAILED_TO_SET_POOL 101 +# define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102 +# define ASYNC_R_INIT_FAILED 105 +# define ASYNC_R_INVALID_POOL_SIZE 103 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/bio.h b/illumos-x86_64/usr/include/openssl-3/bio.h new file mode 100644 index 00000000..e02f867b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/bio.h @@ -0,0 +1,1022 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/bio.h.in + * + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + +#ifndef OPENSSL_BIO_H +# define OPENSSL_BIO_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_BIO_H +# endif + +# include + +# ifndef OPENSSL_NO_STDIO +# include +# endif +# include + +# include +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/* There are the classes of BIOs */ +# define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ +# define BIO_TYPE_FILTER 0x0200 +# define BIO_TYPE_SOURCE_SINK 0x0400 + +/* These are the 'types' of BIOs */ +# define BIO_TYPE_NONE 0 +# define BIO_TYPE_MEM ( 1|BIO_TYPE_SOURCE_SINK) +# define BIO_TYPE_FILE ( 2|BIO_TYPE_SOURCE_SINK) + +# define BIO_TYPE_FD ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) +# define BIO_TYPE_SOCKET ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) +# define BIO_TYPE_NULL ( 6|BIO_TYPE_SOURCE_SINK) +# define BIO_TYPE_SSL ( 7|BIO_TYPE_FILTER) +# define BIO_TYPE_MD ( 8|BIO_TYPE_FILTER) +# define BIO_TYPE_BUFFER ( 9|BIO_TYPE_FILTER) +# define BIO_TYPE_CIPHER (10|BIO_TYPE_FILTER) +# define BIO_TYPE_BASE64 (11|BIO_TYPE_FILTER) +# define BIO_TYPE_CONNECT (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) +# define BIO_TYPE_ACCEPT (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) + +# define BIO_TYPE_NBIO_TEST (16|BIO_TYPE_FILTER)/* server proxy BIO */ +# define BIO_TYPE_NULL_FILTER (17|BIO_TYPE_FILTER) +# define BIO_TYPE_BIO (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */ +# define BIO_TYPE_LINEBUFFER (20|BIO_TYPE_FILTER) +# define BIO_TYPE_DGRAM (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) +# define BIO_TYPE_ASN1 (22|BIO_TYPE_FILTER) +# define BIO_TYPE_COMP (23|BIO_TYPE_FILTER) +# ifndef OPENSSL_NO_SCTP +# define BIO_TYPE_DGRAM_SCTP (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) +# endif +# define BIO_TYPE_CORE_TO_PROV (25|BIO_TYPE_SOURCE_SINK) +# define BIO_TYPE_DGRAM_PAIR (26|BIO_TYPE_SOURCE_SINK) +# define BIO_TYPE_DGRAM_MEM (27|BIO_TYPE_SOURCE_SINK) + +/* Custom type starting index returned by BIO_get_new_index() */ +#define BIO_TYPE_START 128 +/* Custom type maximum index that can be returned by BIO_get_new_index() */ +#define BIO_TYPE_MASK 0xFF + +/* + * BIO_FILENAME_READ|BIO_CLOSE to open or close on free. + * BIO_set_fp(in,stdin,BIO_NOCLOSE); + */ +# define BIO_NOCLOSE 0x00 +# define BIO_CLOSE 0x01 + +/* + * These are used in the following macros and are passed to BIO_ctrl() + */ +# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */ +# define BIO_CTRL_EOF 2/* opt - are we at the eof */ +# define BIO_CTRL_INFO 3/* opt - extra tit-bits */ +# define BIO_CTRL_SET 4/* man - set the 'IO' type */ +# define BIO_CTRL_GET 5/* man - get the 'IO' type */ +# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */ +# define BIO_CTRL_POP 7/* opt - internal, used to signify change */ +# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */ +# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */ +# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */ +# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */ +# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */ +# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */ +# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */ +# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */ + +# define BIO_CTRL_PEEK 29/* BIO_f_buffer special */ +# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */ + +/* dgram BIO stuff */ +# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */ +# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected + * socket to be passed in */ +# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */ +# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */ +# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */ +# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */ + +# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */ +# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation timed out */ + +/* #ifdef IP_MTU_DISCOVER */ +# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */ +/* #endif */ + +# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */ +# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 +# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */ +# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU. + * want to use this if asking + * the kernel fails */ + +# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was + * exceed in the previous write + * operation */ + +# define BIO_CTRL_DGRAM_GET_PEER 46 +# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */ + +# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout + * to adjust socket timeouts */ +# define BIO_CTRL_DGRAM_SET_DONT_FRAG 48 + +# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49 + +/* Deliberately outside of OPENSSL_NO_SCTP - used in bss_dgram.c */ +# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50 +# ifndef OPENSSL_NO_SCTP +/* SCTP stuff */ +# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51 +# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52 +# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53 +# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60 +# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61 +# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62 +# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63 +# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64 +# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65 +# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70 +# endif + +# define BIO_CTRL_DGRAM_SET_PEEK_MODE 71 + +/* + * internal BIO: + * # define BIO_CTRL_SET_KTLS_SEND 72 + * # define BIO_CTRL_SET_KTLS_SEND_CTRL_MSG 74 + * # define BIO_CTRL_CLEAR_KTLS_CTRL_MSG 75 + */ + +# define BIO_CTRL_GET_KTLS_SEND 73 +# define BIO_CTRL_GET_KTLS_RECV 76 + +# define BIO_CTRL_DGRAM_SCTP_WAIT_FOR_DRY 77 +# define BIO_CTRL_DGRAM_SCTP_MSG_WAITING 78 + +/* BIO_f_prefix controls */ +# define BIO_CTRL_SET_PREFIX 79 +# define BIO_CTRL_SET_INDENT 80 +# define BIO_CTRL_GET_INDENT 81 + +# define BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP 82 +# define BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE 83 +# define BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE 84 +# define BIO_CTRL_DGRAM_GET_EFFECTIVE_CAPS 85 +# define BIO_CTRL_DGRAM_GET_CAPS 86 +# define BIO_CTRL_DGRAM_SET_CAPS 87 +# define BIO_CTRL_DGRAM_GET_NO_TRUNC 88 +# define BIO_CTRL_DGRAM_SET_NO_TRUNC 89 + +/* + * internal BIO: + * # define BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE 90 + */ + +# define BIO_CTRL_GET_RPOLL_DESCRIPTOR 91 +# define BIO_CTRL_GET_WPOLL_DESCRIPTOR 92 +# define BIO_CTRL_DGRAM_DETECT_PEER_ADDR 93 +# define BIO_CTRL_DGRAM_SET0_LOCAL_ADDR 94 + +# define BIO_DGRAM_CAP_NONE 0U +# define BIO_DGRAM_CAP_HANDLES_SRC_ADDR (1U << 0) +# define BIO_DGRAM_CAP_HANDLES_DST_ADDR (1U << 1) +# define BIO_DGRAM_CAP_PROVIDES_SRC_ADDR (1U << 2) +# define BIO_DGRAM_CAP_PROVIDES_DST_ADDR (1U << 3) + +# ifndef OPENSSL_NO_KTLS +# define BIO_get_ktls_send(b) \ + (BIO_ctrl(b, BIO_CTRL_GET_KTLS_SEND, 0, NULL) > 0) +# define BIO_get_ktls_recv(b) \ + (BIO_ctrl(b, BIO_CTRL_GET_KTLS_RECV, 0, NULL) > 0) +# else +# define BIO_get_ktls_send(b) (0) +# define BIO_get_ktls_recv(b) (0) +# endif + +/* modifiers */ +# define BIO_FP_READ 0x02 +# define BIO_FP_WRITE 0x04 +# define BIO_FP_APPEND 0x08 +# define BIO_FP_TEXT 0x10 + +# define BIO_FLAGS_READ 0x01 +# define BIO_FLAGS_WRITE 0x02 +# define BIO_FLAGS_IO_SPECIAL 0x04 +# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) +# define BIO_FLAGS_SHOULD_RETRY 0x08 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* This #define was replaced by an internal constant and should not be used. */ +# define BIO_FLAGS_UPLINK 0 +# endif + +# define BIO_FLAGS_BASE64_NO_NL 0x100 + +/* + * This is used with memory BIOs: + * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way; + * BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset. + */ +# define BIO_FLAGS_MEM_RDONLY 0x200 +# define BIO_FLAGS_NONCLEAR_RST 0x400 +# define BIO_FLAGS_IN_EOF 0x800 + +/* the BIO FLAGS values 0x1000 to 0x8000 are reserved for internal KTLS flags */ + +typedef union bio_addr_st BIO_ADDR; +typedef struct bio_addrinfo_st BIO_ADDRINFO; + +int BIO_get_new_index(void); +void BIO_set_flags(BIO *b, int flags); +int BIO_test_flags(const BIO *b, int flags); +void BIO_clear_flags(BIO *b, int flags); + +# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) +# define BIO_set_retry_special(b) \ + BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) +# define BIO_set_retry_read(b) \ + BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) +# define BIO_set_retry_write(b) \ + BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) + +/* These are normally used internally in BIOs */ +# define BIO_clear_retry_flags(b) \ + BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) +# define BIO_get_retry_flags(b) \ + BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) + +/* These should be used by the application to tell why we should retry */ +# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) +# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) +# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) +# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) +# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) + +/* + * The next three are used in conjunction with the BIO_should_io_special() + * condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int + * *reason); will walk the BIO stack and return the 'reason' for the special + * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return + * the code. + */ +/* + * Returned from the SSL bio when the certificate retrieval code had an error + */ +# define BIO_RR_SSL_X509_LOOKUP 0x01 +/* Returned from the connect BIO when a connect would have blocked */ +# define BIO_RR_CONNECT 0x02 +/* Returned from the accept BIO when an accept would have blocked */ +# define BIO_RR_ACCEPT 0x03 + +/* These are passed by the BIO callback */ +# define BIO_CB_FREE 0x01 +# define BIO_CB_READ 0x02 +# define BIO_CB_WRITE 0x03 +# define BIO_CB_PUTS 0x04 +# define BIO_CB_GETS 0x05 +# define BIO_CB_CTRL 0x06 +# define BIO_CB_RECVMMSG 0x07 +# define BIO_CB_SENDMMSG 0x08 + +/* + * The callback is called before and after the underling operation, The + * BIO_CB_RETURN flag indicates if it is after the call + */ +# define BIO_CB_RETURN 0x80 +# define BIO_CB_return(a) ((a)|BIO_CB_RETURN) +# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) +# define BIO_cb_post(a) ((a)&BIO_CB_RETURN) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi, + long argl, long ret); +OSSL_DEPRECATEDIN_3_0 BIO_callback_fn BIO_get_callback(const BIO *b); +OSSL_DEPRECATEDIN_3_0 void BIO_set_callback(BIO *b, BIO_callback_fn callback); +OSSL_DEPRECATEDIN_3_0 long BIO_debug_callback(BIO *bio, int cmd, + const char *argp, int argi, + long argl, long ret); +# endif + +typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp, + size_t len, int argi, + long argl, int ret, size_t *processed); +BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b); +void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback); +long BIO_debug_callback_ex(BIO *bio, int oper, const char *argp, size_t len, + int argi, long argl, int ret, size_t *processed); + +char *BIO_get_callback_arg(const BIO *b); +void BIO_set_callback_arg(BIO *b, char *arg); + +typedef struct bio_method_st BIO_METHOD; + +const char *BIO_method_name(const BIO *b); +int BIO_method_type(const BIO *b); + +typedef int BIO_info_cb(BIO *, int, int); +typedef BIO_info_cb bio_info_cb; /* backward compatibility */ + +SKM_DEFINE_STACK_OF_INTERNAL(BIO, BIO, BIO) +#define sk_BIO_num(sk) OPENSSL_sk_num(ossl_check_const_BIO_sk_type(sk)) +#define sk_BIO_value(sk, idx) ((BIO *)OPENSSL_sk_value(ossl_check_const_BIO_sk_type(sk), (idx))) +#define sk_BIO_new(cmp) ((STACK_OF(BIO) *)OPENSSL_sk_new(ossl_check_BIO_compfunc_type(cmp))) +#define sk_BIO_new_null() ((STACK_OF(BIO) *)OPENSSL_sk_new_null()) +#define sk_BIO_new_reserve(cmp, n) ((STACK_OF(BIO) *)OPENSSL_sk_new_reserve(ossl_check_BIO_compfunc_type(cmp), (n))) +#define sk_BIO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_BIO_sk_type(sk), (n)) +#define sk_BIO_free(sk) OPENSSL_sk_free(ossl_check_BIO_sk_type(sk)) +#define sk_BIO_zero(sk) OPENSSL_sk_zero(ossl_check_BIO_sk_type(sk)) +#define sk_BIO_delete(sk, i) ((BIO *)OPENSSL_sk_delete(ossl_check_BIO_sk_type(sk), (i))) +#define sk_BIO_delete_ptr(sk, ptr) ((BIO *)OPENSSL_sk_delete_ptr(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))) +#define sk_BIO_push(sk, ptr) OPENSSL_sk_push(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) +#define sk_BIO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) +#define sk_BIO_pop(sk) ((BIO *)OPENSSL_sk_pop(ossl_check_BIO_sk_type(sk))) +#define sk_BIO_shift(sk) ((BIO *)OPENSSL_sk_shift(ossl_check_BIO_sk_type(sk))) +#define sk_BIO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_BIO_sk_type(sk),ossl_check_BIO_freefunc_type(freefunc)) +#define sk_BIO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), (idx)) +#define sk_BIO_set(sk, idx, ptr) ((BIO *)OPENSSL_sk_set(ossl_check_BIO_sk_type(sk), (idx), ossl_check_BIO_type(ptr))) +#define sk_BIO_find(sk, ptr) OPENSSL_sk_find(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) +#define sk_BIO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) +#define sk_BIO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), pnum) +#define sk_BIO_sort(sk) OPENSSL_sk_sort(ossl_check_BIO_sk_type(sk)) +#define sk_BIO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_BIO_sk_type(sk)) +#define sk_BIO_dup(sk) ((STACK_OF(BIO) *)OPENSSL_sk_dup(ossl_check_const_BIO_sk_type(sk))) +#define sk_BIO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(BIO) *)OPENSSL_sk_deep_copy(ossl_check_const_BIO_sk_type(sk), ossl_check_BIO_copyfunc_type(copyfunc), ossl_check_BIO_freefunc_type(freefunc))) +#define sk_BIO_set_cmp_func(sk, cmp) ((sk_BIO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_BIO_sk_type(sk), ossl_check_BIO_compfunc_type(cmp))) + + + +/* Prefix and suffix callback in ASN1 BIO */ +typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen, + void *parg); + +typedef void (*BIO_dgram_sctp_notification_handler_fn) (BIO *b, + void *context, + void *buf); +# ifndef OPENSSL_NO_SCTP +/* SCTP parameter structs */ +struct bio_dgram_sctp_sndinfo { + uint16_t snd_sid; + uint16_t snd_flags; + uint32_t snd_ppid; + uint32_t snd_context; +}; + +struct bio_dgram_sctp_rcvinfo { + uint16_t rcv_sid; + uint16_t rcv_ssn; + uint16_t rcv_flags; + uint32_t rcv_ppid; + uint32_t rcv_tsn; + uint32_t rcv_cumtsn; + uint32_t rcv_context; +}; + +struct bio_dgram_sctp_prinfo { + uint16_t pr_policy; + uint32_t pr_value; +}; +# endif + +/* BIO_sendmmsg/BIO_recvmmsg-related definitions */ +typedef struct bio_msg_st { + void *data; + size_t data_len; + BIO_ADDR *peer, *local; + uint64_t flags; +} BIO_MSG; + +typedef struct bio_mmsg_cb_args_st { + BIO_MSG *msg; + size_t stride, num_msg; + uint64_t flags; + size_t *msgs_processed; +} BIO_MMSG_CB_ARGS; + +#define BIO_POLL_DESCRIPTOR_TYPE_NONE 0 +#define BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD 1 +#define BIO_POLL_DESCRIPTOR_TYPE_SSL 2 +#define BIO_POLL_DESCRIPTOR_CUSTOM_START 8192 + +typedef struct bio_poll_descriptor_st { + uint32_t type; + union { + int fd; + void *custom; + uintptr_t custom_ui; + SSL *ssl; + } value; +} BIO_POLL_DESCRIPTOR; + +/* + * #define BIO_CONN_get_param_hostname BIO_ctrl + */ + +# define BIO_C_SET_CONNECT 100 +# define BIO_C_DO_STATE_MACHINE 101 +# define BIO_C_SET_NBIO 102 +/* # define BIO_C_SET_PROXY_PARAM 103 */ +# define BIO_C_SET_FD 104 +# define BIO_C_GET_FD 105 +# define BIO_C_SET_FILE_PTR 106 +# define BIO_C_GET_FILE_PTR 107 +# define BIO_C_SET_FILENAME 108 +# define BIO_C_SET_SSL 109 +# define BIO_C_GET_SSL 110 +# define BIO_C_SET_MD 111 +# define BIO_C_GET_MD 112 +# define BIO_C_GET_CIPHER_STATUS 113 +# define BIO_C_SET_BUF_MEM 114 +# define BIO_C_GET_BUF_MEM_PTR 115 +# define BIO_C_GET_BUFF_NUM_LINES 116 +# define BIO_C_SET_BUFF_SIZE 117 +# define BIO_C_SET_ACCEPT 118 +# define BIO_C_SSL_MODE 119 +# define BIO_C_GET_MD_CTX 120 +/* # define BIO_C_GET_PROXY_PARAM 121 */ +# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */ +# define BIO_C_GET_CONNECT 123 +# define BIO_C_GET_ACCEPT 124 +# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 +# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 +# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 +# define BIO_C_FILE_SEEK 128 +# define BIO_C_GET_CIPHER_CTX 129 +# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input + * value */ +# define BIO_C_SET_BIND_MODE 131 +# define BIO_C_GET_BIND_MODE 132 +# define BIO_C_FILE_TELL 133 +# define BIO_C_GET_SOCKS 134 +# define BIO_C_SET_SOCKS 135 + +# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ +# define BIO_C_GET_WRITE_BUF_SIZE 137 +# define BIO_C_MAKE_BIO_PAIR 138 +# define BIO_C_DESTROY_BIO_PAIR 139 +# define BIO_C_GET_WRITE_GUARANTEE 140 +# define BIO_C_GET_READ_REQUEST 141 +# define BIO_C_SHUTDOWN_WR 142 +# define BIO_C_NREAD0 143 +# define BIO_C_NREAD 144 +# define BIO_C_NWRITE0 145 +# define BIO_C_NWRITE 146 +# define BIO_C_RESET_READ_REQUEST 147 +# define BIO_C_SET_MD_CTX 148 + +# define BIO_C_SET_PREFIX 149 +# define BIO_C_GET_PREFIX 150 +# define BIO_C_SET_SUFFIX 151 +# define BIO_C_GET_SUFFIX 152 + +# define BIO_C_SET_EX_ARG 153 +# define BIO_C_GET_EX_ARG 154 + +# define BIO_C_SET_CONNECT_MODE 155 + +# define BIO_C_SET_TFO 156 /* like BIO_C_SET_NBIO */ + +# define BIO_C_SET_SOCK_TYPE 157 +# define BIO_C_GET_SOCK_TYPE 158 +# define BIO_C_GET_DGRAM_BIO 159 + +# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) +# define BIO_get_app_data(s) BIO_get_ex_data(s,0) + +# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) +# define BIO_set_tfo(b,n) BIO_ctrl(b,BIO_C_SET_TFO,(n),NULL) + +# ifndef OPENSSL_NO_SOCK +/* IP families we support, for BIO_s_connect() and BIO_s_accept() */ +/* Note: the underlying operating system may not support some of them */ +# define BIO_FAMILY_IPV4 4 +# define BIO_FAMILY_IPV6 6 +# define BIO_FAMILY_IPANY 256 + +/* BIO_s_connect() */ +# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0, \ + (char *)(name)) +# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1, \ + (char *)(port)) +# define BIO_set_conn_address(b,addr) BIO_ctrl(b,BIO_C_SET_CONNECT,2, \ + (char *)(addr)) +# define BIO_set_conn_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f) +# define BIO_get_conn_hostname(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)) +# define BIO_get_conn_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)) +# define BIO_get_conn_address(b) ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)) +# define BIO_get_conn_ip_family(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL) +# define BIO_get_conn_mode(b) BIO_ctrl(b,BIO_C_GET_CONNECT,4,NULL) +# define BIO_set_conn_mode(b,n) BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL) +# define BIO_set_sock_type(b,t) BIO_ctrl(b,BIO_C_SET_SOCK_TYPE,(t),NULL) +# define BIO_get_sock_type(b) BIO_ctrl(b,BIO_C_GET_SOCK_TYPE,0,NULL) +# define BIO_get0_dgram_bio(b, p) BIO_ctrl(b,BIO_C_GET_DGRAM_BIO,0,(void *)(BIO **)(p)) + +/* BIO_s_accept() */ +# define BIO_set_accept_name(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \ + (char *)(name)) +# define BIO_set_accept_port(b,port) BIO_ctrl(b,BIO_C_SET_ACCEPT,1, \ + (char *)(port)) +# define BIO_get_accept_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)) +# define BIO_get_accept_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1)) +# define BIO_get_peer_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2)) +# define BIO_get_peer_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3)) +/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ +# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)"a":NULL) +# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,3, \ + (char *)(bio)) +# define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f) +# define BIO_get_accept_ip_family(b) BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL) +# define BIO_set_tfo_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,5,(n)?(void *)"a":NULL) + +/* Aliases kept for backward compatibility */ +# define BIO_BIND_NORMAL 0 +# define BIO_BIND_REUSEADDR BIO_SOCK_REUSEADDR +# define BIO_BIND_REUSEADDR_IF_UNUSED BIO_SOCK_REUSEADDR +# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) +# define BIO_get_bind_mode(b) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) +# endif /* OPENSSL_NO_SOCK */ + +# define BIO_do_connect(b) BIO_do_handshake(b) +# define BIO_do_accept(b) BIO_do_handshake(b) + +# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) + +/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */ +# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) +# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)(c)) + +/* BIO_s_file() */ +# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp)) +# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)(fpp)) + +/* BIO_s_fd() and BIO_s_file() */ +# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) +# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) + +/* + * name is cast to lose const, but might be better to route through a + * function so we can do it safely + */ +# ifdef CONST_STRICT +/* + * If you are wondering why this isn't defined, its because CONST_STRICT is + * purely a compile-time kludge to allow const to be checked. + */ +int BIO_read_filename(BIO *b, const char *name); +# else +# define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ,(char *)(name)) +# endif +# define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_WRITE,name) +# define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_APPEND,name) +# define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) + +/* + * WARNING WARNING, this ups the reference count on the read bio of the SSL + * structure. This is because the ssl read BIO is now pointed to by the + * next_bio field in the bio. So when you free the BIO, make sure you are + * doing a BIO_free_all() to catch the underlying BIO. + */ +# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)(ssl)) +# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)(sslp)) +# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) +# define BIO_set_ssl_renegotiate_bytes(b,num) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL) +# define BIO_get_num_renegotiates(b) \ + BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL) +# define BIO_set_ssl_renegotiate_timeout(b,seconds) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL) + +/* defined in evp.h */ +/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */ + +# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)(pp)) +# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)(bm)) +# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0, \ + (char *)(pp)) +# define BIO_set_mem_eof_return(b,v) \ + BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) + +/* For the BIO_f_buffer() type */ +# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) +# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) +# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) +# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) +# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) + +/* Don't use the next one unless you know what you are doing :-) */ +# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) + +# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) +# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) +# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) +# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) +# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) +# define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) +/* ...pending macros have inappropriate return type */ +size_t BIO_ctrl_pending(BIO *b); +size_t BIO_ctrl_wpending(BIO *b); +# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) +# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ + cbp) +# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) + +/* For the BIO_f_buffer() type */ +# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) +# define BIO_buffer_peek(b,s,l) BIO_ctrl(b,BIO_CTRL_PEEK,(l),(s)) + +/* For BIO_s_bio() */ +# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) +# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) +# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) +# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) +# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) +/* macros with inappropriate type -- but ...pending macros use int too: */ +# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) +# define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) +size_t BIO_ctrl_get_write_guarantee(BIO *b); +size_t BIO_ctrl_get_read_request(BIO *b); +int BIO_ctrl_reset_read_request(BIO *b); + +/* ctrl macros for dgram */ +# define BIO_ctrl_dgram_connect(b,peer) \ + (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)(peer)) +# define BIO_ctrl_set_connected(b,peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer)) +# define BIO_dgram_recv_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) +# define BIO_dgram_send_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) +# define BIO_dgram_get_peer(b,peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer)) +# define BIO_dgram_set_peer(b,peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer)) +# define BIO_dgram_detect_peer_addr(b,peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_DETECT_PEER_ADDR, 0, (char *)(peer)) +# define BIO_dgram_get_mtu_overhead(b) \ + (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL) +# define BIO_dgram_get_local_addr_cap(b) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP, 0, NULL) +# define BIO_dgram_get_local_addr_enable(b, penable) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE, 0, (char *)(penable)) +# define BIO_dgram_set_local_addr_enable(b, enable) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE, (enable), NULL) +# define BIO_dgram_get_effective_caps(b) \ + (uint32_t)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_EFFECTIVE_CAPS, 0, NULL) +# define BIO_dgram_get_caps(b) \ + (uint32_t)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_CAPS, 0, NULL) +# define BIO_dgram_set_caps(b, caps) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_CAPS, (long)(caps), NULL) +# define BIO_dgram_get_no_trunc(b) \ + (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_NO_TRUNC, 0, NULL) +# define BIO_dgram_set_no_trunc(b, enable) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_NO_TRUNC, (enable), NULL) +# define BIO_dgram_get_mtu(b) \ + (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU, 0, NULL) +# define BIO_dgram_set_mtu(b, mtu) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_MTU, (mtu), NULL) +# define BIO_dgram_set0_local_addr(b, addr) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET0_LOCAL_ADDR, 0, (addr)) + +/* ctrl macros for BIO_f_prefix */ +# define BIO_set_prefix(b,p) BIO_ctrl((b), BIO_CTRL_SET_PREFIX, 0, (void *)(p)) +# define BIO_set_indent(b,i) BIO_ctrl((b), BIO_CTRL_SET_INDENT, (i), NULL) +# define BIO_get_indent(b) BIO_ctrl((b), BIO_CTRL_GET_INDENT, 0, NULL) + +#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef) +int BIO_set_ex_data(BIO *bio, int idx, void *data); +void *BIO_get_ex_data(const BIO *bio, int idx); +uint64_t BIO_number_read(BIO *bio); +uint64_t BIO_number_written(BIO *bio); + +/* For BIO_f_asn1() */ +int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, + asn1_ps_func *prefix_free); +int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, + asn1_ps_func **pprefix_free); +int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, + asn1_ps_func *suffix_free); +int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, + asn1_ps_func **psuffix_free); + +const BIO_METHOD *BIO_s_file(void); +BIO *BIO_new_file(const char *filename, const char *mode); +BIO *BIO_new_from_core_bio(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio); +# ifndef OPENSSL_NO_STDIO +BIO *BIO_new_fp(FILE *stream, int close_flag); +# endif +BIO *BIO_new_ex(OSSL_LIB_CTX *libctx, const BIO_METHOD *method); +BIO *BIO_new(const BIO_METHOD *type); +int BIO_free(BIO *a); +void BIO_set_data(BIO *a, void *ptr); +void *BIO_get_data(BIO *a); +void BIO_set_init(BIO *a, int init); +int BIO_get_init(BIO *a); +void BIO_set_shutdown(BIO *a, int shut); +int BIO_get_shutdown(BIO *a); +void BIO_vfree(BIO *a); +int BIO_up_ref(BIO *a); +int BIO_read(BIO *b, void *data, int dlen); +int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes); +__owur int BIO_recvmmsg(BIO *b, BIO_MSG *msg, + size_t stride, size_t num_msg, uint64_t flags, + size_t *msgs_processed); +int BIO_gets(BIO *bp, char *buf, int size); +int BIO_get_line(BIO *bio, char *buf, int size); +int BIO_write(BIO *b, const void *data, int dlen); +int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written); +__owur int BIO_sendmmsg(BIO *b, BIO_MSG *msg, + size_t stride, size_t num_msg, uint64_t flags, + size_t *msgs_processed); +__owur int BIO_get_rpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc); +__owur int BIO_get_wpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc); +int BIO_puts(BIO *bp, const char *buf); +int BIO_indent(BIO *b, int indent, int max); +long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); +long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp); +void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); +long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); +BIO *BIO_push(BIO *b, BIO *append); +BIO *BIO_pop(BIO *b); +void BIO_free_all(BIO *a); +BIO *BIO_find_type(BIO *b, int bio_type); +BIO *BIO_next(BIO *b); +void BIO_set_next(BIO *b, BIO *next); +BIO *BIO_get_retry_BIO(BIO *bio, int *reason); +int BIO_get_retry_reason(BIO *bio); +void BIO_set_retry_reason(BIO *bio, int reason); +BIO *BIO_dup_chain(BIO *in); + +int BIO_nread0(BIO *bio, char **buf); +int BIO_nread(BIO *bio, char **buf, int num); +int BIO_nwrite0(BIO *bio, char **buf); +int BIO_nwrite(BIO *bio, char **buf, int num); + +const BIO_METHOD *BIO_s_mem(void); +# ifndef OPENSSL_NO_DGRAM +const BIO_METHOD *BIO_s_dgram_mem(void); +# endif +const BIO_METHOD *BIO_s_secmem(void); +BIO *BIO_new_mem_buf(const void *buf, int len); +# ifndef OPENSSL_NO_SOCK +const BIO_METHOD *BIO_s_socket(void); +const BIO_METHOD *BIO_s_connect(void); +const BIO_METHOD *BIO_s_accept(void); +# endif +const BIO_METHOD *BIO_s_fd(void); +const BIO_METHOD *BIO_s_log(void); +const BIO_METHOD *BIO_s_bio(void); +const BIO_METHOD *BIO_s_null(void); +const BIO_METHOD *BIO_f_null(void); +const BIO_METHOD *BIO_f_buffer(void); +const BIO_METHOD *BIO_f_readbuffer(void); +const BIO_METHOD *BIO_f_linebuffer(void); +const BIO_METHOD *BIO_f_nbio_test(void); +const BIO_METHOD *BIO_f_prefix(void); +const BIO_METHOD *BIO_s_core(void); +# ifndef OPENSSL_NO_DGRAM +const BIO_METHOD *BIO_s_dgram_pair(void); +const BIO_METHOD *BIO_s_datagram(void); +int BIO_dgram_non_fatal_error(int error); +BIO *BIO_new_dgram(int fd, int close_flag); +# ifndef OPENSSL_NO_SCTP +const BIO_METHOD *BIO_s_datagram_sctp(void); +BIO *BIO_new_dgram_sctp(int fd, int close_flag); +int BIO_dgram_is_sctp(BIO *bio); +int BIO_dgram_sctp_notification_cb(BIO *b, + BIO_dgram_sctp_notification_handler_fn handle_notifications, + void *context); +int BIO_dgram_sctp_wait_for_dry(BIO *b); +int BIO_dgram_sctp_msg_waiting(BIO *b); +# endif +# endif + +# ifndef OPENSSL_NO_SOCK +int BIO_sock_should_retry(int i); +int BIO_sock_non_fatal_error(int error); +int BIO_err_is_non_fatal(unsigned int errcode); +int BIO_socket_wait(int fd, int for_read, time_t max_time); +# endif +int BIO_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds); +int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds); + +int BIO_fd_should_retry(int i); +int BIO_fd_non_fatal_error(int error); +int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u), + void *u, const void *s, int len); +int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), + void *u, const void *s, int len, int indent); +int BIO_dump(BIO *b, const void *bytes, int len); +int BIO_dump_indent(BIO *b, const void *bytes, int len, int indent); +# ifndef OPENSSL_NO_STDIO +int BIO_dump_fp(FILE *fp, const void *s, int len); +int BIO_dump_indent_fp(FILE *fp, const void *s, int len, int indent); +# endif +int BIO_hex_string(BIO *out, int indent, int width, const void *data, + int datalen); + +# ifndef OPENSSL_NO_SOCK +BIO_ADDR *BIO_ADDR_new(void); +int BIO_ADDR_copy(BIO_ADDR *dst, const BIO_ADDR *src); +BIO_ADDR *BIO_ADDR_dup(const BIO_ADDR *ap); +int BIO_ADDR_rawmake(BIO_ADDR *ap, int family, + const void *where, size_t wherelen, unsigned short port); +void BIO_ADDR_free(BIO_ADDR *); +void BIO_ADDR_clear(BIO_ADDR *ap); +int BIO_ADDR_family(const BIO_ADDR *ap); +int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l); +unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap); +char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric); +char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric); +char *BIO_ADDR_path_string(const BIO_ADDR *ap); + +const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai); +int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai); +int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai); +int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai); +const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai); +void BIO_ADDRINFO_free(BIO_ADDRINFO *bai); + +enum BIO_hostserv_priorities { + BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV +}; +int BIO_parse_hostserv(const char *hostserv, char **host, char **service, + enum BIO_hostserv_priorities hostserv_prio); +enum BIO_lookup_type { + BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER +}; +int BIO_lookup(const char *host, const char *service, + enum BIO_lookup_type lookup_type, + int family, int socktype, BIO_ADDRINFO **res); +int BIO_lookup_ex(const char *host, const char *service, + int lookup_type, int family, int socktype, int protocol, + BIO_ADDRINFO **res); +int BIO_sock_error(int sock); +int BIO_socket_ioctl(int fd, long type, void *arg); +int BIO_socket_nbio(int fd, int mode); +int BIO_sock_init(void); +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define BIO_sock_cleanup() while(0) continue +# endif +int BIO_set_tcp_ndelay(int sock, int turn_on); +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 struct hostent *BIO_gethostbyname(const char *name); +OSSL_DEPRECATEDIN_1_1_0 int BIO_get_port(const char *str, unsigned short *port_ptr); +OSSL_DEPRECATEDIN_1_1_0 int BIO_get_host_ip(const char *str, unsigned char *ip); +OSSL_DEPRECATEDIN_1_1_0 int BIO_get_accept_socket(char *host_port, int mode); +OSSL_DEPRECATEDIN_1_1_0 int BIO_accept(int sock, char **ip_port); +# endif + +union BIO_sock_info_u { + BIO_ADDR *addr; +}; +enum BIO_sock_info_type { + BIO_SOCK_INFO_ADDRESS +}; +int BIO_sock_info(int sock, + enum BIO_sock_info_type type, union BIO_sock_info_u *info); + +# define BIO_SOCK_REUSEADDR 0x01 +# define BIO_SOCK_V6_ONLY 0x02 +# define BIO_SOCK_KEEPALIVE 0x04 +# define BIO_SOCK_NONBLOCK 0x08 +# define BIO_SOCK_NODELAY 0x10 +# define BIO_SOCK_TFO 0x20 + +int BIO_socket(int domain, int socktype, int protocol, int options); +int BIO_connect(int sock, const BIO_ADDR *addr, int options); +int BIO_bind(int sock, const BIO_ADDR *addr, int options); +int BIO_listen(int sock, const BIO_ADDR *addr, int options); +int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options); +int BIO_closesocket(int sock); + +BIO *BIO_new_socket(int sock, int close_flag); +BIO *BIO_new_connect(const char *host_port); +BIO *BIO_new_accept(const char *host_port); +# endif /* OPENSSL_NO_SOCK*/ + +BIO *BIO_new_fd(int fd, int close_flag); + +int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, + BIO **bio2, size_t writebuf2); +# ifndef OPENSSL_NO_DGRAM +int BIO_new_bio_dgram_pair(BIO **bio1, size_t writebuf1, + BIO **bio2, size_t writebuf2); +# endif + +/* + * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. + * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default + * value. + */ + +void BIO_copy_next_retry(BIO *b); + +/* + * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); + */ + +# define ossl_bio__attr__(x) +# if defined(__GNUC__) && defined(__STDC_VERSION__) \ + && !defined(__MINGW32__) && !defined(__MINGW64__) \ + && !defined(__APPLE__) + /* + * Because we support the 'z' modifier, which made its appearance in C99, + * we can't use __attribute__ with pre C99 dialects. + */ +# if __STDC_VERSION__ >= 199901L +# undef ossl_bio__attr__ +# define ossl_bio__attr__ __attribute__ +# if __GNUC__*10 + __GNUC_MINOR__ >= 44 +# define ossl_bio__printf__ __gnu_printf__ +# else +# define ossl_bio__printf__ __printf__ +# endif +# endif +# endif +int BIO_printf(BIO *bio, const char *format, ...) +ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3))); +int BIO_vprintf(BIO *bio, const char *format, va_list args) +ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0))); +int BIO_snprintf(char *buf, size_t n, const char *format, ...) +ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4))); +int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) +ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0))); +# undef ossl_bio__attr__ +# undef ossl_bio__printf__ + + +BIO_METHOD *BIO_meth_new(int type, const char *name); +void BIO_meth_free(BIO_METHOD *biom); +int BIO_meth_set_write(BIO_METHOD *biom, + int (*write) (BIO *, const char *, int)); +int BIO_meth_set_write_ex(BIO_METHOD *biom, + int (*bwrite) (BIO *, const char *, size_t, size_t *)); +int BIO_meth_set_sendmmsg(BIO_METHOD *biom, + int (*f) (BIO *, BIO_MSG *, size_t, size_t, + uint64_t, size_t *)); +int BIO_meth_set_read(BIO_METHOD *biom, + int (*read) (BIO *, char *, int)); +int BIO_meth_set_read_ex(BIO_METHOD *biom, + int (*bread) (BIO *, char *, size_t, size_t *)); +int BIO_meth_set_recvmmsg(BIO_METHOD *biom, + int (*f) (BIO *, BIO_MSG *, size_t, size_t, + uint64_t, size_t *)); +int BIO_meth_set_puts(BIO_METHOD *biom, + int (*puts) (BIO *, const char *)); +int BIO_meth_set_gets(BIO_METHOD *biom, + int (*ossl_gets) (BIO *, char *, int)); +int BIO_meth_set_ctrl(BIO_METHOD *biom, + long (*ctrl) (BIO *, int, long, void *)); +int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *)); +int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *)); +int BIO_meth_set_callback_ctrl(BIO_METHOD *biom, + long (*callback_ctrl) (BIO *, int, + BIO_info_cb *)); +# ifndef OPENSSL_NO_DEPRECATED_3_5 +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, + int); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, + size_t, size_t *); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *, + size_t, size_t, + uint64_t, size_t *); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, + size_t, size_t *); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *, + size_t, size_t, + uint64_t, size_t *); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int); +OSSL_DEPRECATEDIN_3_5 long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, + long, void *); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *); +OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *); +OSSL_DEPRECATEDIN_3_5 long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom)) (BIO *, int, + BIO_info_cb *); +# endif +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/bioerr.h b/illumos-x86_64/usr/include/openssl-3/bioerr.h new file mode 100644 index 00000000..e4fdb649 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/bioerr.h @@ -0,0 +1,72 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_BIOERR_H +# define OPENSSL_BIOERR_H +# pragma once + +# include +# include +# include + + + +/* + * BIO reason codes. + */ +# define BIO_R_ACCEPT_ERROR 100 +# define BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET 141 +# define BIO_R_AMBIGUOUS_HOST_OR_SERVICE 129 +# define BIO_R_BAD_FOPEN_MODE 101 +# define BIO_R_BROKEN_PIPE 124 +# define BIO_R_CONNECT_ERROR 103 +# define BIO_R_CONNECT_TIMEOUT 147 +# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 +# define BIO_R_GETSOCKNAME_ERROR 132 +# define BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS 133 +# define BIO_R_GETTING_SOCKTYPE 134 +# define BIO_R_INVALID_ARGUMENT 125 +# define BIO_R_INVALID_SOCKET 135 +# define BIO_R_IN_USE 123 +# define BIO_R_LENGTH_TOO_LONG 102 +# define BIO_R_LISTEN_V6_ONLY 136 +# define BIO_R_LOCAL_ADDR_NOT_AVAILABLE 111 +# define BIO_R_LOOKUP_RETURNED_NOTHING 142 +# define BIO_R_MALFORMED_HOST_OR_SERVICE 130 +# define BIO_R_NBIO_CONNECT_ERROR 110 +# define BIO_R_NON_FATAL 112 +# define BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED 143 +# define BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED 144 +# define BIO_R_NO_PORT_DEFINED 113 +# define BIO_R_NO_SUCH_FILE 128 +# define BIO_R_NULL_PARAMETER 115 /* unused */ +# define BIO_R_TFO_DISABLED 106 +# define BIO_R_TFO_NO_KERNEL_SUPPORT 108 +# define BIO_R_TRANSFER_ERROR 104 +# define BIO_R_TRANSFER_TIMEOUT 105 +# define BIO_R_UNABLE_TO_BIND_SOCKET 117 +# define BIO_R_UNABLE_TO_CREATE_SOCKET 118 +# define BIO_R_UNABLE_TO_KEEPALIVE 137 +# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 +# define BIO_R_UNABLE_TO_NODELAY 138 +# define BIO_R_UNABLE_TO_REUSEADDR 139 +# define BIO_R_UNABLE_TO_TFO 109 +# define BIO_R_UNAVAILABLE_IP_FAMILY 145 +# define BIO_R_UNINITIALIZED 120 +# define BIO_R_UNKNOWN_INFO_TYPE 140 +# define BIO_R_UNSUPPORTED_IP_FAMILY 146 +# define BIO_R_UNSUPPORTED_METHOD 121 +# define BIO_R_UNSUPPORTED_PROTOCOL_FAMILY 131 +# define BIO_R_WRITE_TO_READ_ONLY_BIO 126 +# define BIO_R_WSASTARTUP 122 +# define BIO_R_PORT_MISMATCH 150 +# define BIO_R_PEER_ADDR_NOT_AVAILABLE 151 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/blowfish.h b/illumos-x86_64/usr/include/openssl-3/blowfish.h new file mode 100644 index 00000000..667d6423 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/blowfish.h @@ -0,0 +1,78 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_BLOWFISH_H +# define OPENSSL_BLOWFISH_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_BLOWFISH_H +# endif + +# include + +# ifndef OPENSSL_NO_BF +# include +# ifdef __cplusplus +extern "C" { +# endif + +# define BF_BLOCK 8 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 + +# define BF_ENCRYPT 1 +# define BF_DECRYPT 0 + +/*- + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! BF_LONG has to be at least 32 bits wide. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ +# define BF_LONG unsigned int + +# define BF_ROUNDS 16 + +typedef struct bf_key_st { + BF_LONG P[BF_ROUNDS + 2]; + BF_LONG S[4 * 256]; +} BF_KEY; + +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 void BF_set_key(BF_KEY *key, int len, + const unsigned char *data); +OSSL_DEPRECATEDIN_3_0 void BF_encrypt(BF_LONG *data, const BF_KEY *key); +OSSL_DEPRECATEDIN_3_0 void BF_decrypt(BF_LONG *data, const BF_KEY *key); +OSSL_DEPRECATEDIN_3_0 void BF_ecb_encrypt(const unsigned char *in, + unsigned char *out, const BF_KEY *key, + int enc); +OSSL_DEPRECATEDIN_3_0 void BF_cbc_encrypt(const unsigned char *in, + unsigned char *out, long length, + const BF_KEY *schedule, + unsigned char *ivec, int enc); +OSSL_DEPRECATEDIN_3_0 void BF_cfb64_encrypt(const unsigned char *in, + unsigned char *out, + long length, const BF_KEY *schedule, + unsigned char *ivec, int *num, + int enc); +OSSL_DEPRECATEDIN_3_0 void BF_ofb64_encrypt(const unsigned char *in, + unsigned char *out, + long length, const BF_KEY *schedule, + unsigned char *ivec, int *num); +OSSL_DEPRECATEDIN_3_0 const char *BF_options(void); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/bn.h b/illumos-x86_64/usr/include/openssl-3/bn.h new file mode 100644 index 00000000..ea706dca --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/bn.h @@ -0,0 +1,590 @@ +/* + * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_BN_H +# define OPENSSL_BN_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_BN_H +# endif + +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif +# include +# include +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * 64-bit processor with LP64 ABI + */ +# ifdef SIXTY_FOUR_BIT_LONG +# define BN_ULONG unsigned long +# define BN_BYTES 8 +# endif + +/* + * 64-bit processor other than LP64 ABI + */ +# ifdef SIXTY_FOUR_BIT +# define BN_ULONG unsigned long long +# define BN_BYTES 8 +# endif + +# ifdef THIRTY_TWO_BIT +# define BN_ULONG unsigned int +# define BN_BYTES 4 +# endif + +# define BN_BITS2 (BN_BYTES * 8) +# define BN_BITS (BN_BITS2 * 2) +# define BN_TBIT ((BN_ULONG)1 << (BN_BITS2 - 1)) + +# define BN_FLG_MALLOCED 0x01 +# define BN_FLG_STATIC_DATA 0x02 + +/* + * avoid leaking exponent information through timing, + * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime, + * BN_div() will call BN_div_no_branch, + * BN_mod_inverse() will call bn_mod_inverse_no_branch. + */ +# define BN_FLG_CONSTTIME 0x04 +# define BN_FLG_SECURE 0x08 + +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +/* deprecated name for the flag */ +# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME +# define BN_FLG_FREE 0x8000 /* used for debugging */ +# endif + +void BN_set_flags(BIGNUM *b, int n); +int BN_get_flags(const BIGNUM *b, int n); + +/* Values for |top| in BN_rand() */ +#define BN_RAND_TOP_ANY -1 +#define BN_RAND_TOP_ONE 0 +#define BN_RAND_TOP_TWO 1 + +/* Values for |bottom| in BN_rand() */ +#define BN_RAND_BOTTOM_ANY 0 +#define BN_RAND_BOTTOM_ODD 1 + +/* + * get a clone of a BIGNUM with changed flags, for *temporary* use only (the + * two BIGNUMs cannot be used in parallel!). Also only for *read only* use. The + * value |dest| should be a newly allocated BIGNUM obtained via BN_new() that + * has not been otherwise initialised or used. + */ +void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags); + +/* Wrapper function to make using BN_GENCB easier */ +int BN_GENCB_call(BN_GENCB *cb, int a, int b); + +BN_GENCB *BN_GENCB_new(void); +void BN_GENCB_free(BN_GENCB *cb); + +/* Populate a BN_GENCB structure with an "old"-style callback */ +void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *), + void *cb_arg); + +/* Populate a BN_GENCB structure with a "new"-style callback */ +void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *), + void *cb_arg); + +void *BN_GENCB_get_arg(BN_GENCB *cb); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define BN_prime_checks 0 /* default: select number of iterations based + * on the size of the number */ + +/* + * BN_prime_checks_for_size() returns the number of Miller-Rabin iterations + * that will be done for checking that a random number is probably prime. The + * error rate for accepting a composite number as prime depends on the size of + * the prime |b|. The error rates used are for calculating an RSA key with 2 primes, + * and so the level is what you would expect for a key of double the size of the + * prime. + * + * This table is generated using the algorithm of FIPS PUB 186-4 + * Digital Signature Standard (DSS), section F.1, page 117. + * (https://dx.doi.org/10.6028/NIST.FIPS.186-4) + * + * The following magma script was used to generate the output: + * securitybits:=125; + * k:=1024; + * for t:=1 to 65 do + * for M:=3 to Floor(2*Sqrt(k-1)-1) do + * S:=0; + * // Sum over m + * for m:=3 to M do + * s:=0; + * // Sum over j + * for j:=2 to m do + * s+:=(RealField(32)!2)^-(j+(k-1)/j); + * end for; + * S+:=2^(m-(m-1)*t)*s; + * end for; + * A:=2^(k-2-M*t); + * B:=8*(Pi(RealField(32))^2-6)/3*2^(k-2)*S; + * pkt:=2.00743*Log(2)*k*2^-k*(A+B); + * seclevel:=Floor(-Log(2,pkt)); + * if seclevel ge securitybits then + * printf "k: %5o, security: %o bits (t: %o, M: %o)\n",k,seclevel,t,M; + * break; + * end if; + * end for; + * if seclevel ge securitybits then break; end if; + * end for; + * + * It can be run online at: + * http://magma.maths.usyd.edu.au/calc + * + * And will output: + * k: 1024, security: 129 bits (t: 6, M: 23) + * + * k is the number of bits of the prime, securitybits is the level we want to + * reach. + * + * prime length | RSA key size | # MR tests | security level + * -------------+--------------|------------+--------------- + * (b) >= 6394 | >= 12788 | 3 | 256 bit + * (b) >= 3747 | >= 7494 | 3 | 192 bit + * (b) >= 1345 | >= 2690 | 4 | 128 bit + * (b) >= 1080 | >= 2160 | 5 | 128 bit + * (b) >= 852 | >= 1704 | 5 | 112 bit + * (b) >= 476 | >= 952 | 5 | 80 bit + * (b) >= 400 | >= 800 | 6 | 80 bit + * (b) >= 347 | >= 694 | 7 | 80 bit + * (b) >= 308 | >= 616 | 8 | 80 bit + * (b) >= 55 | >= 110 | 27 | 64 bit + * (b) >= 6 | >= 12 | 34 | 64 bit + */ + +# define BN_prime_checks_for_size(b) ((b) >= 3747 ? 3 : \ + (b) >= 1345 ? 4 : \ + (b) >= 476 ? 5 : \ + (b) >= 400 ? 6 : \ + (b) >= 347 ? 7 : \ + (b) >= 308 ? 8 : \ + (b) >= 55 ? 27 : \ + /* b >= 6 */ 34) +# endif + +# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) + +int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w); +int BN_is_zero(const BIGNUM *a); +int BN_is_one(const BIGNUM *a); +int BN_is_word(const BIGNUM *a, const BN_ULONG w); +int BN_is_odd(const BIGNUM *a); + +# define BN_one(a) (BN_set_word((a),1)) + +void BN_zero_ex(BIGNUM *a); + +# if OPENSSL_API_LEVEL > 908 +# define BN_zero(a) BN_zero_ex(a) +# else +# define BN_zero(a) (BN_set_word((a),0)) +# endif + +const BIGNUM *BN_value_one(void); +char *BN_options(void); +BN_CTX *BN_CTX_new_ex(OSSL_LIB_CTX *ctx); +BN_CTX *BN_CTX_new(void); +BN_CTX *BN_CTX_secure_new_ex(OSSL_LIB_CTX *ctx); +BN_CTX *BN_CTX_secure_new(void); +void BN_CTX_free(BN_CTX *c); +void BN_CTX_start(BN_CTX *ctx); +BIGNUM *BN_CTX_get(BN_CTX *ctx); +void BN_CTX_end(BN_CTX *ctx); +int BN_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, + unsigned int strength, BN_CTX *ctx); +int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); +int BN_priv_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, + unsigned int strength, BN_CTX *ctx); +int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom); +int BN_rand_range_ex(BIGNUM *r, const BIGNUM *range, unsigned int strength, + BN_CTX *ctx); +int BN_rand_range(BIGNUM *rnd, const BIGNUM *range); +int BN_priv_rand_range_ex(BIGNUM *r, const BIGNUM *range, + unsigned int strength, BN_CTX *ctx); +int BN_priv_rand_range(BIGNUM *rnd, const BIGNUM *range); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); +OSSL_DEPRECATEDIN_3_0 +int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range); +# endif +int BN_num_bits(const BIGNUM *a); +int BN_num_bits_word(BN_ULONG l); +int BN_security_bits(int L, int N); +BIGNUM *BN_new(void); +BIGNUM *BN_secure_new(void); +void BN_clear_free(BIGNUM *a); +BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); +void BN_swap(BIGNUM *a, BIGNUM *b); +BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); +BIGNUM *BN_signed_bin2bn(const unsigned char *s, int len, BIGNUM *ret); +int BN_bn2bin(const BIGNUM *a, unsigned char *to); +int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen); +int BN_signed_bn2bin(const BIGNUM *a, unsigned char *to, int tolen); +BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret); +BIGNUM *BN_signed_lebin2bn(const unsigned char *s, int len, BIGNUM *ret); +int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen); +int BN_signed_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen); +BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret); +BIGNUM *BN_signed_native2bn(const unsigned char *s, int len, BIGNUM *ret); +int BN_bn2nativepad(const BIGNUM *a, unsigned char *to, int tolen); +int BN_signed_bn2native(const BIGNUM *a, unsigned char *to, int tolen); +BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret); +int BN_bn2mpi(const BIGNUM *a, unsigned char *to); +int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); +/** BN_set_negative sets sign of a BIGNUM + * \param b pointer to the BIGNUM object + * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise + */ +void BN_set_negative(BIGNUM *b, int n); +/** BN_is_negative returns 1 if the BIGNUM is negative + * \param b pointer to the BIGNUM object + * \return 1 if a < 0 and 0 otherwise + */ +int BN_is_negative(const BIGNUM *b); + +int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, + BN_CTX *ctx); +# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) +int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); +int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m); +int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); +int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m); +int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); +int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); +int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, + BN_CTX *ctx); +int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); + +BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); +BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); +int BN_mul_word(BIGNUM *a, BN_ULONG w); +int BN_add_word(BIGNUM *a, BN_ULONG w); +int BN_sub_word(BIGNUM *a, BN_ULONG w); +int BN_set_word(BIGNUM *a, BN_ULONG w); +BN_ULONG BN_get_word(const BIGNUM *a); + +int BN_cmp(const BIGNUM *a, const BIGNUM *b); +void BN_free(BIGNUM *a); +int BN_is_bit_set(const BIGNUM *a, int n); +int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_lshift1(BIGNUM *r, const BIGNUM *a); +int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); + +int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont); +int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, + const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, + BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_mod_exp_mont_consttime_x2(BIGNUM *rr1, const BIGNUM *a1, const BIGNUM *p1, + const BIGNUM *m1, BN_MONT_CTX *in_mont1, + BIGNUM *rr2, const BIGNUM *a2, const BIGNUM *p2, + const BIGNUM *m2, BN_MONT_CTX *in_mont2, + BN_CTX *ctx); + +int BN_mask_bits(BIGNUM *a, int n); +# ifndef OPENSSL_NO_STDIO +int BN_print_fp(FILE *fp, const BIGNUM *a); +# endif +int BN_print(BIO *bio, const BIGNUM *a); +int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); +int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_rshift1(BIGNUM *r, const BIGNUM *a); +void BN_clear(BIGNUM *a); +BIGNUM *BN_dup(const BIGNUM *a); +int BN_ucmp(const BIGNUM *a, const BIGNUM *b); +int BN_set_bit(BIGNUM *a, int n); +int BN_clear_bit(BIGNUM *a, int n); +char *BN_bn2hex(const BIGNUM *a); +char *BN_bn2dec(const BIGNUM *a); +int BN_hex2bn(BIGNUM **a, const char *str); +int BN_dec2bn(BIGNUM **a, const char *str); +int BN_asc2bn(BIGNUM **a, const char *str); +int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns + * -2 for + * error */ +int BN_are_coprime(BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +BIGNUM *BN_mod_inverse(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); +BIGNUM *BN_mod_sqrt(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); + +void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); + +/* Deprecated versions */ +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +OSSL_DEPRECATEDIN_0_9_8 +BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, + const BIGNUM *add, const BIGNUM *rem, + void (*callback) (int, int, void *), + void *cb_arg); +OSSL_DEPRECATEDIN_0_9_8 +int BN_is_prime(const BIGNUM *p, int nchecks, + void (*callback) (int, int, void *), + BN_CTX *ctx, void *cb_arg); +OSSL_DEPRECATEDIN_0_9_8 +int BN_is_prime_fasttest(const BIGNUM *p, int nchecks, + void (*callback) (int, int, void *), + BN_CTX *ctx, void *cb_arg, + int do_trial_division); +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 +int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, + int do_trial_division, BN_GENCB *cb); +# endif +/* Newer versions */ +int BN_generate_prime_ex2(BIGNUM *ret, int bits, int safe, + const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb, + BN_CTX *ctx); +int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, + const BIGNUM *rem, BN_GENCB *cb); +int BN_check_prime(const BIGNUM *p, BN_CTX *ctx, BN_GENCB *cb); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx); + +OSSL_DEPRECATEDIN_3_0 +int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, + const BIGNUM *Xp, const BIGNUM *Xp1, + const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx, + BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 +int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1, + BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e, + BN_CTX *ctx, BN_GENCB *cb); +# endif + +BN_MONT_CTX *BN_MONT_CTX_new(void); +int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); +int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); +void BN_MONT_CTX_free(BN_MONT_CTX *mont); +int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx); +BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from); +BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock, + const BIGNUM *mod, BN_CTX *ctx); + +/* BN_BLINDING flags */ +# define BN_BLINDING_NO_UPDATE 0x00000001 +# define BN_BLINDING_NO_RECREATE 0x00000002 + +BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); +void BN_BLINDING_free(BN_BLINDING *b); +int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); +int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, + BN_CTX *); + +int BN_BLINDING_is_current_thread(BN_BLINDING *b); +void BN_BLINDING_set_current_thread(BN_BLINDING *b); +int BN_BLINDING_lock(BN_BLINDING *b); +int BN_BLINDING_unlock(BN_BLINDING *b); + +unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); +void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); +BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, + const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, + int (*bn_mod_exp) (BIGNUM *r, + const BIGNUM *a, + const BIGNUM *p, + const BIGNUM *m, + BN_CTX *ctx, + BN_MONT_CTX *m_ctx), + BN_MONT_CTX *m_ctx); +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +OSSL_DEPRECATEDIN_0_9_8 +void BN_set_params(int mul, int high, int low, int mont); +OSSL_DEPRECATEDIN_0_9_8 +int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ +# endif + +BN_RECP_CTX *BN_RECP_CTX_new(void); +void BN_RECP_CTX_free(BN_RECP_CTX *recp); +int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx); +int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, + BN_RECP_CTX *recp, BN_CTX *ctx); +int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, + BN_RECP_CTX *recp, BN_CTX *ctx); + +# ifndef OPENSSL_NO_EC2M + +/* + * Functions for arithmetic over binary polynomials represented by BIGNUMs. + * The BIGNUM::neg property of BIGNUMs representing binary polynomials is + * ignored. Note that input arguments are not const so that their bit arrays + * can be expanded to the appropriate size if needed. + */ + +/* + * r = a + b + */ +int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) +/* + * r=a mod p + */ +int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); +/* r = (a * b) mod p */ +int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); +/* r = (a * a) mod p */ +int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +/* r = (1 / b) mod p */ +int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx); +/* r = (a / b) mod p */ +int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); +/* r = (a ^ b) mod p */ +int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); +/* r = sqrt(a) mod p */ +int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); +/* r^2 + r = a mod p */ +int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); +# define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) +/*- + * Some functions allow for representation of the irreducible polynomials + * as an unsigned int[], say p. The irreducible f(t) is then of the form: + * t^p[0] + t^p[1] + ... + t^p[k] + * where m = p[0] > p[1] > ... > p[k] = 0. + */ +/* r = a mod p */ +int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]); +/* r = (a * b) mod p */ +int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const int p[], BN_CTX *ctx); +/* r = (a * a) mod p */ +int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], + BN_CTX *ctx); +/* r = (1 / b) mod p */ +int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[], + BN_CTX *ctx); +/* r = (a / b) mod p */ +int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const int p[], BN_CTX *ctx); +/* r = (a ^ b) mod p */ +int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const int p[], BN_CTX *ctx); +/* r = sqrt(a) mod p */ +int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, + const int p[], BN_CTX *ctx); +/* r^2 + r = a mod p */ +int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, + const int p[], BN_CTX *ctx); +int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max); +int BN_GF2m_arr2poly(const int p[], BIGNUM *a); + +# endif + +/* + * faster mod functions for the 'NIST primes' 0 <= a < p^2 + */ +int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); + +const BIGNUM *BN_get0_nist_prime_192(void); +const BIGNUM *BN_get0_nist_prime_224(void); +const BIGNUM *BN_get0_nist_prime_256(void); +const BIGNUM *BN_get0_nist_prime_384(void); +const BIGNUM *BN_get0_nist_prime_521(void); + +int (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a, + const BIGNUM *field, BN_CTX *ctx); + +int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, + const BIGNUM *priv, const unsigned char *message, + size_t message_len, BN_CTX *ctx); + +/* Primes from RFC 2409 */ +BIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn); +BIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn); + +/* Primes from RFC 3526 */ +BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define get_rfc2409_prime_768 BN_get_rfc2409_prime_768 +# define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024 +# define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536 +# define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048 +# define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072 +# define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096 +# define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144 +# define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192 +# endif + +int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom); + + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/bnerr.h b/illumos-x86_64/usr/include/openssl-3/bnerr.h new file mode 100644 index 00000000..7c3f6ef3 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/bnerr.h @@ -0,0 +1,47 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_BNERR_H +# define OPENSSL_BNERR_H +# pragma once + +# include +# include +# include + + + +/* + * BN reason codes. + */ +# define BN_R_ARG2_LT_ARG3 100 +# define BN_R_BAD_RECIPROCAL 101 +# define BN_R_BIGNUM_TOO_LONG 114 +# define BN_R_BITS_TOO_SMALL 118 +# define BN_R_CALLED_WITH_EVEN_MODULUS 102 +# define BN_R_DIV_BY_ZERO 103 +# define BN_R_ENCODING_ERROR 104 +# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 +# define BN_R_INPUT_NOT_REDUCED 110 +# define BN_R_INVALID_LENGTH 106 +# define BN_R_INVALID_RANGE 115 +# define BN_R_INVALID_SHIFT 119 +# define BN_R_NOT_A_SQUARE 111 +# define BN_R_NOT_INITIALIZED 107 +# define BN_R_NO_INVERSE 108 +# define BN_R_NO_PRIME_CANDIDATE 121 +# define BN_R_NO_SOLUTION 116 +# define BN_R_NO_SUITABLE_DIGEST 120 +# define BN_R_PRIVATE_KEY_TOO_LARGE 117 +# define BN_R_P_IS_NOT_PRIME 112 +# define BN_R_TOO_MANY_ITERATIONS 113 +# define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/buffer.h b/illumos-x86_64/usr/include/openssl-3/buffer.h new file mode 100644 index 00000000..5773b986 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/buffer.h @@ -0,0 +1,62 @@ +/* + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_BUFFER_H +# define OPENSSL_BUFFER_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_BUFFER_H +# endif + +# include +# ifndef OPENSSL_CRYPTO_H +# include +# endif +# include + + +#ifdef __cplusplus +extern "C" { +#endif + +# include +# include + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define BUF_strdup(s) OPENSSL_strdup(s) +# define BUF_strndup(s, size) OPENSSL_strndup(s, size) +# define BUF_memdup(data, size) OPENSSL_memdup(data, size) +# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) +# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) +# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) +# endif + +struct buf_mem_st { + size_t length; /* current number of bytes */ + char *data; + size_t max; /* size of buffer */ + unsigned long flags; +}; + +# define BUF_MEM_FLAG_SECURE 0x01 + +BUF_MEM *BUF_MEM_new(void); +BUF_MEM *BUF_MEM_new_ex(unsigned long flags); +void BUF_MEM_free(BUF_MEM *a); +size_t BUF_MEM_grow(BUF_MEM *str, size_t len); +size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len); +void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); + + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/buffererr.h b/illumos-x86_64/usr/include/openssl-3/buffererr.h new file mode 100644 index 00000000..d18b1f8f --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/buffererr.h @@ -0,0 +1,25 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_BUFFERERR_H +# define OPENSSL_BUFFERERR_H +# pragma once + +# include +# include +# include + + + +/* + * BUF reason codes. + */ + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/byteorder.h b/illumos-x86_64/usr/include/openssl-3/byteorder.h new file mode 100644 index 00000000..3c8f34b2 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/byteorder.h @@ -0,0 +1,339 @@ +/* + * Copyright 2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_BYTEORDER_H +# define OPENSSL_BYTEORDER_H +# pragma once + +# include +# include + +/* + * "Modern" compilers do a decent job of optimising these functions to just a + * couple of instruction ([swap +] store, or load [+ swap]) when either no + * swapping is required, or a suitable swap instruction is available. + */ + +# if defined(_MSC_VER) && _MSC_VER>=1300 +# include +# pragma intrinsic(_byteswap_ushort) +# pragma intrinsic(_byteswap_ulong) +# pragma intrinsic(_byteswap_uint64) +# define OSSL_HTOBE16(x) _byteswap_ushort(x) +# define OSSL_HTOBE32(x) _byteswap_ulong(x) +# define OSSL_HTOBE64(x) _byteswap_uint64(x) +# define OSSL_BE16TOH(x) _byteswap_ushort(x) +# define OSSL_BE32TOH(x) _byteswap_ulong(x) +# define OSSL_BE64TOH(x) _byteswap_uint64(x) +# define OSSL_HTOLE16(x) (x) +# define OSSL_HTOLE32(x) (x) +# define OSSL_HTOLE64(x) (x) +# define OSSL_LE16TOH(x) (x) +# define OSSL_LE32TOH(x) (x) +# define OSSL_LE64TOH(x) (x) + +# elif defined(__GLIBC__) && defined(__GLIBC_PREREQ) +# if (__GLIBC_PREREQ(2, 19)) && defined(_DEFAULT_SOURCE) +# include +# define OSSL_HTOBE16(x) htobe16(x) +# define OSSL_HTOBE32(x) htobe32(x) +# define OSSL_HTOBE64(x) htobe64(x) +# define OSSL_BE16TOH(x) be16toh(x) +# define OSSL_BE32TOH(x) be32toh(x) +# define OSSL_BE64TOH(x) be64toh(x) +# define OSSL_HTOLE16(x) htole16(x) +# define OSSL_HTOLE32(x) htole32(x) +# define OSSL_HTOLE64(x) htole64(x) +# define OSSL_LE16TOH(x) le16toh(x) +# define OSSL_LE32TOH(x) le32toh(x) +# define OSSL_LE64TOH(x) le64toh(x) +# endif + +# elif defined(__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__) +# if defined(__OpenBSD__) +# include +# else +# include +# endif +# define OSSL_HTOBE16(x) htobe16(x) +# define OSSL_HTOBE32(x) htobe32(x) +# define OSSL_HTOBE64(x) htobe64(x) +# define OSSL_BE16TOH(x) be16toh(x) +# define OSSL_BE32TOH(x) be32toh(x) +# define OSSL_BE64TOH(x) be64toh(x) +# define OSSL_HTOLE16(x) htole16(x) +# define OSSL_HTOLE32(x) htole32(x) +# define OSSL_HTOLE64(x) htole64(x) +# define OSSL_LE16TOH(x) le16toh(x) +# define OSSL_LE32TOH(x) le32toh(x) +# define OSSL_LE64TOH(x) le64toh(x) + +# elif defined(__APPLE__) +# include +# define OSSL_HTOBE16(x) OSSwapHostToBigInt16(x) +# define OSSL_HTOBE32(x) OSSwapHostToBigInt32(x) +# define OSSL_HTOBE64(x) OSSwapHostToBigInt64(x) +# define OSSL_BE16TOH(x) OSSwapBigToHostInt16(x) +# define OSSL_BE32TOH(x) OSSwapBigToHostInt32(x) +# define OSSL_BE64TOH(x) OSSwapBigToHostInt64(x) +# define OSSL_HTOLE16(x) OSSwapHostToLittleInt16(x) +# define OSSL_HTOLE32(x) OSSwapHostToLittleInt32(x) +# define OSSL_HTOLE64(x) OSSwapHostToLittleInt64(x) +# define OSSL_LE16TOH(x) OSSwapLittleToHostInt16(x) +# define OSSL_LE32TOH(x) OSSwapLittleToHostInt32(x) +# define OSSL_LE64TOH(x) OSSwapLittleToHostInt64(x) + +# endif + +static ossl_inline ossl_unused unsigned char * +OPENSSL_store_u16_le(unsigned char *out, uint16_t val) +{ +# ifdef OSSL_HTOLE16 + uint16_t t = OSSL_HTOLE16(val); + + memcpy(out, (unsigned char *)&t, 2); + return out + 2; +# else + *out++ = (val & 0xff); + *out++ = (val >> 8) & 0xff; + return out; +# endif +} + +static ossl_inline ossl_unused unsigned char * +OPENSSL_store_u16_be(unsigned char *out, uint16_t val) +{ +# ifdef OSSL_HTOBE16 + uint16_t t = OSSL_HTOBE16(val); + + memcpy(out, (unsigned char *)&t, 2); + return out + 2; +# else + *out++ = (val >> 8) & 0xff; + *out++ = (val & 0xff); + return out; +# endif +} + +static ossl_inline ossl_unused unsigned char * +OPENSSL_store_u32_le(unsigned char *out, uint32_t val) +{ +# ifdef OSSL_HTOLE32 + uint32_t t = OSSL_HTOLE32(val); + + memcpy(out, (unsigned char *)&t, 4); + return out + 4; +# else + *out++ = (val & 0xff); + *out++ = (val >> 8) & 0xff; + *out++ = (val >> 16) & 0xff; + *out++ = (val >> 24) & 0xff; + return out; +# endif +} + +static ossl_inline ossl_unused unsigned char * +OPENSSL_store_u32_be(unsigned char *out, uint32_t val) +{ +# ifdef OSSL_HTOBE32 + uint32_t t = OSSL_HTOBE32(val); + + memcpy(out, (unsigned char *)&t, 4); + return out + 4; +# else + *out++ = (val >> 24) & 0xff; + *out++ = (val >> 16) & 0xff; + *out++ = (val >> 8) & 0xff; + *out++ = (val & 0xff); + return out; +# endif +} + +static ossl_inline ossl_unused unsigned char * +OPENSSL_store_u64_le(unsigned char *out, uint64_t val) +{ +# ifdef OSSL_HTOLE64 + uint64_t t = OSSL_HTOLE64(val); + + memcpy(out, (unsigned char *)&t, 8); + return out + 8; +# else + *out++ = (val & 0xff); + *out++ = (val >> 8) & 0xff; + *out++ = (val >> 16) & 0xff; + *out++ = (val >> 24) & 0xff; + *out++ = (val >> 32) & 0xff; + *out++ = (val >> 40) & 0xff; + *out++ = (val >> 48) & 0xff; + *out++ = (val >> 56) & 0xff; + return out; +# endif +} + +static ossl_inline ossl_unused unsigned char * +OPENSSL_store_u64_be(unsigned char *out, uint64_t val) +{ +# ifdef OSSL_HTOLE64 + uint64_t t = OSSL_HTOBE64(val); + + memcpy(out, (unsigned char *)&t, 8); + return out + 8; +# else + *out++ = (val >> 56) & 0xff; + *out++ = (val >> 48) & 0xff; + *out++ = (val >> 40) & 0xff; + *out++ = (val >> 32) & 0xff; + *out++ = (val >> 24) & 0xff; + *out++ = (val >> 16) & 0xff; + *out++ = (val >> 8) & 0xff; + *out++ = (val & 0xff); + return out; +# endif +} + +static ossl_inline ossl_unused const unsigned char * +OPENSSL_load_u16_le(uint16_t *val, const unsigned char *in) +{ +# ifdef OSSL_LE16TOH + uint16_t t; + + memcpy((unsigned char *)&t, in, 2); + *val = OSSL_LE16TOH(t); + return in + 2; +# else + uint16_t b0 = *in++; + uint16_t b1 = *in++; + + *val = b0 | (b1 << 8); + return in; +#endif +} + +static ossl_inline ossl_unused const unsigned char * +OPENSSL_load_u16_be(uint16_t *val, const unsigned char *in) +{ +# ifdef OSSL_LE16TOH + uint16_t t; + + memcpy((unsigned char *)&t, in, 2); + *val = OSSL_BE16TOH(t); + return in + 2; +# else + uint16_t b1 = *in++; + uint16_t b0 = *in++; + + *val = b0 | (b1 << 8); + return in; +#endif +} + +static ossl_inline ossl_unused const unsigned char * +OPENSSL_load_u32_le(uint32_t *val, const unsigned char *in) +{ +# ifdef OSSL_LE32TOH + uint32_t t; + + memcpy((unsigned char *)&t, in, 4); + *val = OSSL_LE32TOH(t); + return in + 4; +# else + uint32_t b0 = *in++; + uint32_t b1 = *in++; + uint32_t b2 = *in++; + uint32_t b3 = *in++; + + *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); + return in; +#endif +} + +static ossl_inline ossl_unused const unsigned char * +OPENSSL_load_u32_be(uint32_t *val, const unsigned char *in) +{ +# ifdef OSSL_LE32TOH + uint32_t t; + + memcpy((unsigned char *)&t, in, 4); + *val = OSSL_BE32TOH(t); + return in + 4; +# else + uint32_t b3 = *in++; + uint32_t b2 = *in++; + uint32_t b1 = *in++; + uint32_t b0 = *in++; + + *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); + return in; +#endif +} + +static ossl_inline ossl_unused const unsigned char * +OPENSSL_load_u64_le(uint64_t *val, const unsigned char *in) +{ +# ifdef OSSL_LE64TOH + uint64_t t; + + memcpy((unsigned char *)&t, in, 8); + *val = OSSL_LE64TOH(t); + return in + 8; +# else + uint64_t b0 = *in++; + uint64_t b1 = *in++; + uint64_t b2 = *in++; + uint64_t b3 = *in++; + uint64_t b4 = *in++; + uint64_t b5 = *in++; + uint64_t b6 = *in++; + uint64_t b7 = *in++; + + *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) + | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56); + return in; +#endif +} + +static ossl_inline ossl_unused const unsigned char * +OPENSSL_load_u64_be(uint64_t *val, const unsigned char *in) +{ +# ifdef OSSL_LE64TOH + uint64_t t; + + memcpy((unsigned char *)&t, in, 8); + *val = OSSL_BE64TOH(t); + return in + 8; +# else + uint64_t b7 = *in++; + uint64_t b6 = *in++; + uint64_t b5 = *in++; + uint64_t b4 = *in++; + uint64_t b3 = *in++; + uint64_t b2 = *in++; + uint64_t b1 = *in++; + uint64_t b0 = *in++; + + *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) + | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56); + return in; +#endif +} + +# undef OSSL_HTOBE16 +# undef OSSL_HTOBE32 +# undef OSSL_HTOBE64 +# undef OSSL_BE16TOH +# undef OSSL_BE32TOH +# undef OSSL_BE64TOH +# undef OSSL_HTOLE16 +# undef OSSL_HTOLE32 +# undef OSSL_HTOLE64 +# undef OSSL_LE16TOH +# undef OSSL_LE32TOH +# undef OSSL_LE64TOH + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/camellia.h b/illumos-x86_64/usr/include/openssl-3/camellia.h new file mode 100644 index 00000000..88c2279e --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/camellia.h @@ -0,0 +1,117 @@ +/* + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CAMELLIA_H +# define OPENSSL_CAMELLIA_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_CAMELLIA_H +# endif + +# include + +# ifndef OPENSSL_NO_CAMELLIA +# include +#ifdef __cplusplus +extern "C" { +#endif + +# define CAMELLIA_BLOCK_SIZE 16 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 + +# define CAMELLIA_ENCRYPT 1 +# define CAMELLIA_DECRYPT 0 + +/* + * Because array size can't be a const in C, the following two are macros. + * Both sizes are in bytes. + */ + +/* This should be a hidden type, but EVP requires that the size be known */ + +# define CAMELLIA_TABLE_BYTE_LEN 272 +# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) + +typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match + * with WORD */ + +struct camellia_key_st { + union { + double d; /* ensures 64-bit align */ + KEY_TABLE_TYPE rd_key; + } u; + int grand_rounds; +}; +typedef struct camellia_key_st CAMELLIA_KEY; + +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int Camellia_set_key(const unsigned char *userKey, + const int bits, + CAMELLIA_KEY *key); +OSSL_DEPRECATEDIN_3_0 void Camellia_encrypt(const unsigned char *in, + unsigned char *out, + const CAMELLIA_KEY *key); +OSSL_DEPRECATEDIN_3_0 void Camellia_decrypt(const unsigned char *in, + unsigned char *out, + const CAMELLIA_KEY *key); +OSSL_DEPRECATEDIN_3_0 void Camellia_ecb_encrypt(const unsigned char *in, + unsigned char *out, + const CAMELLIA_KEY *key, + const int enc); +OSSL_DEPRECATEDIN_3_0 void Camellia_cbc_encrypt(const unsigned char *in, + unsigned char *out, + size_t length, + const CAMELLIA_KEY *key, + unsigned char *ivec, + const int enc); +OSSL_DEPRECATEDIN_3_0 void Camellia_cfb128_encrypt(const unsigned char *in, + unsigned char *out, + size_t length, + const CAMELLIA_KEY *key, + unsigned char *ivec, + int *num, + const int enc); +OSSL_DEPRECATEDIN_3_0 void Camellia_cfb1_encrypt(const unsigned char *in, + unsigned char *out, + size_t length, + const CAMELLIA_KEY *key, + unsigned char *ivec, + int *num, + const int enc); +OSSL_DEPRECATEDIN_3_0 void Camellia_cfb8_encrypt(const unsigned char *in, + unsigned char *out, + size_t length, + const CAMELLIA_KEY *key, + unsigned char *ivec, + int *num, + const int enc); +OSSL_DEPRECATEDIN_3_0 void Camellia_ofb128_encrypt(const unsigned char *in, + unsigned char *out, + size_t length, + const CAMELLIA_KEY *key, + unsigned char *ivec, + int *num); +OSSL_DEPRECATEDIN_3_0 +void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const CAMELLIA_KEY *key, + unsigned char ivec[CAMELLIA_BLOCK_SIZE], + unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], + unsigned int *num); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/cast.h b/illumos-x86_64/usr/include/openssl-3/cast.h new file mode 100644 index 00000000..0bf217be --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cast.h @@ -0,0 +1,71 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CAST_H +# define OPENSSL_CAST_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_CAST_H +# endif + +# include + +# ifndef OPENSSL_NO_CAST +# ifdef __cplusplus +extern "C" { +# endif + +# define CAST_BLOCK 8 +# define CAST_KEY_LENGTH 16 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 + +# define CAST_ENCRYPT 1 +# define CAST_DECRYPT 0 + +# define CAST_LONG unsigned int + +typedef struct cast_key_st { + CAST_LONG data[32]; + int short_key; /* Use reduced rounds for short key */ +} CAST_KEY; + +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); +OSSL_DEPRECATEDIN_3_0 +void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, + const CAST_KEY *key, int enc); +OSSL_DEPRECATEDIN_3_0 +void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key); +OSSL_DEPRECATEDIN_3_0 +void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key); +OSSL_DEPRECATEDIN_3_0 +void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, + long length, const CAST_KEY *ks, unsigned char *iv, + int enc); +OSSL_DEPRECATEDIN_3_0 +void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, const CAST_KEY *schedule, + unsigned char *ivec, int *num, int enc); +OSSL_DEPRECATEDIN_3_0 +void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, const CAST_KEY *schedule, + unsigned char *ivec, int *num); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/cmac.h b/illumos-x86_64/usr/include/openssl-3/cmac.h new file mode 100644 index 00000000..f5086183 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cmac.h @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CMAC_H +# define OPENSSL_CMAC_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_CMAC_H +# endif + +# ifndef OPENSSL_NO_CMAC + +# ifdef __cplusplus +extern "C" { +# endif + +# include + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* Opaque */ +typedef struct CMAC_CTX_st CMAC_CTX; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 CMAC_CTX *CMAC_CTX_new(void); +OSSL_DEPRECATEDIN_3_0 void CMAC_CTX_cleanup(CMAC_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 void CMAC_CTX_free(CMAC_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); +OSSL_DEPRECATEDIN_3_0 int CMAC_Init(CMAC_CTX *ctx, + const void *key, size_t keylen, + const EVP_CIPHER *cipher, ENGINE *impl); +OSSL_DEPRECATEDIN_3_0 int CMAC_Update(CMAC_CTX *ctx, + const void *data, size_t dlen); +OSSL_DEPRECATEDIN_3_0 int CMAC_Final(CMAC_CTX *ctx, + unsigned char *out, size_t *poutlen); +OSSL_DEPRECATEDIN_3_0 int CMAC_resume(CMAC_CTX *ctx); +# endif + +# ifdef __cplusplus +} +# endif + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/cmp.h b/illumos-x86_64/usr/include/openssl-3/cmp.h new file mode 100644 index 00000000..05aed302 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cmp.h @@ -0,0 +1,727 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/cmp.h.in + * + * Copyright 2007-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_CMP_H +# define OPENSSL_CMP_H + +# include +# ifndef OPENSSL_NO_CMP + +# include +# include +# include +# include + +/* explicit #includes not strictly needed since implied by the above: */ +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define OSSL_CMP_PVNO_2 2 +# define OSSL_CMP_PVNO_3 3 +# define OSSL_CMP_PVNO OSSL_CMP_PVNO_2 /* v2 is the default */ + +/*- + * PKIFailureInfo ::= BIT STRING { + * -- since we can fail in more than one way! + * -- More codes may be added in the future if/when required. + * badAlg (0), + * -- unrecognized or unsupported Algorithm Identifier + * badMessageCheck (1), + * -- integrity check failed (e.g., signature did not verify) + * badRequest (2), + * -- transaction not permitted or supported + * badTime (3), + * -- messageTime was not sufficiently close to the system time, + * -- as defined by local policy + * badCertId (4), + * -- no certificate could be found matching the provided criteria + * badDataFormat (5), + * -- the data submitted has the wrong format + * wrongAuthority (6), + * -- the authority indicated in the request is different from the + * -- one creating the response token + * incorrectData (7), + * -- the requester's data is incorrect (for notary services) + * missingTimeStamp (8), + * -- when the timestamp is missing but should be there + * -- (by policy) + * badPOP (9), + * -- the proof-of-possession failed + * certRevoked (10), + * -- the certificate has already been revoked + * certConfirmed (11), + * -- the certificate has already been confirmed + * wrongIntegrity (12), + * -- invalid integrity, password based instead of signature or + * -- vice versa + * badRecipientNonce (13), + * -- invalid recipient nonce, either missing or wrong value + * timeNotAvailable (14), + * -- the TSA's time source is not available + * unacceptedPolicy (15), + * -- the requested TSA policy is not supported by the TSA. + * unacceptedExtension (16), + * -- the requested extension is not supported by the TSA. + * addInfoNotAvailable (17), + * -- the additional information requested could not be + * -- understood or is not available + * badSenderNonce (18), + * -- invalid sender nonce, either missing or wrong size + * badCertTemplate (19), + * -- invalid cert. template or missing mandatory information + * signerNotTrusted (20), + * -- signer of the message unknown or not trusted + * transactionIdInUse (21), + * -- the transaction identifier is already in use + * unsupportedVersion (22), + * -- the version of the message is not supported + * notAuthorized (23), + * -- the sender was not authorized to make the preceding + * -- request or perform the preceding action + * systemUnavail (24), + * -- the request cannot be handled due to system unavailability + * systemFailure (25), + * -- the request cannot be handled due to system failure + * duplicateCertReq (26) + * -- certificate cannot be issued because a duplicate + * -- certificate already exists + * } + */ +# define OSSL_CMP_PKIFAILUREINFO_badAlg 0 +# define OSSL_CMP_PKIFAILUREINFO_badMessageCheck 1 +# define OSSL_CMP_PKIFAILUREINFO_badRequest 2 +# define OSSL_CMP_PKIFAILUREINFO_badTime 3 +# define OSSL_CMP_PKIFAILUREINFO_badCertId 4 +# define OSSL_CMP_PKIFAILUREINFO_badDataFormat 5 +# define OSSL_CMP_PKIFAILUREINFO_wrongAuthority 6 +# define OSSL_CMP_PKIFAILUREINFO_incorrectData 7 +# define OSSL_CMP_PKIFAILUREINFO_missingTimeStamp 8 +# define OSSL_CMP_PKIFAILUREINFO_badPOP 9 +# define OSSL_CMP_PKIFAILUREINFO_certRevoked 10 +# define OSSL_CMP_PKIFAILUREINFO_certConfirmed 11 +# define OSSL_CMP_PKIFAILUREINFO_wrongIntegrity 12 +# define OSSL_CMP_PKIFAILUREINFO_badRecipientNonce 13 +# define OSSL_CMP_PKIFAILUREINFO_timeNotAvailable 14 +# define OSSL_CMP_PKIFAILUREINFO_unacceptedPolicy 15 +# define OSSL_CMP_PKIFAILUREINFO_unacceptedExtension 16 +# define OSSL_CMP_PKIFAILUREINFO_addInfoNotAvailable 17 +# define OSSL_CMP_PKIFAILUREINFO_badSenderNonce 18 +# define OSSL_CMP_PKIFAILUREINFO_badCertTemplate 19 +# define OSSL_CMP_PKIFAILUREINFO_signerNotTrusted 20 +# define OSSL_CMP_PKIFAILUREINFO_transactionIdInUse 21 +# define OSSL_CMP_PKIFAILUREINFO_unsupportedVersion 22 +# define OSSL_CMP_PKIFAILUREINFO_notAuthorized 23 +# define OSSL_CMP_PKIFAILUREINFO_systemUnavail 24 +# define OSSL_CMP_PKIFAILUREINFO_systemFailure 25 +# define OSSL_CMP_PKIFAILUREINFO_duplicateCertReq 26 +# define OSSL_CMP_PKIFAILUREINFO_MAX 26 +# define OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN \ + ((1 << (OSSL_CMP_PKIFAILUREINFO_MAX + 1)) - 1) +# if OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN > INT_MAX +# error CMP_PKIFAILUREINFO_MAX bit pattern does not fit in type int +# endif +typedef ASN1_BIT_STRING OSSL_CMP_PKIFAILUREINFO; + +# define OSSL_CMP_CTX_FAILINFO_badAlg (1 << 0) +# define OSSL_CMP_CTX_FAILINFO_badMessageCheck (1 << 1) +# define OSSL_CMP_CTX_FAILINFO_badRequest (1 << 2) +# define OSSL_CMP_CTX_FAILINFO_badTime (1 << 3) +# define OSSL_CMP_CTX_FAILINFO_badCertId (1 << 4) +# define OSSL_CMP_CTX_FAILINFO_badDataFormat (1 << 5) +# define OSSL_CMP_CTX_FAILINFO_wrongAuthority (1 << 6) +# define OSSL_CMP_CTX_FAILINFO_incorrectData (1 << 7) +# define OSSL_CMP_CTX_FAILINFO_missingTimeStamp (1 << 8) +# define OSSL_CMP_CTX_FAILINFO_badPOP (1 << 9) +# define OSSL_CMP_CTX_FAILINFO_certRevoked (1 << 10) +# define OSSL_CMP_CTX_FAILINFO_certConfirmed (1 << 11) +# define OSSL_CMP_CTX_FAILINFO_wrongIntegrity (1 << 12) +# define OSSL_CMP_CTX_FAILINFO_badRecipientNonce (1 << 13) +# define OSSL_CMP_CTX_FAILINFO_timeNotAvailable (1 << 14) +# define OSSL_CMP_CTX_FAILINFO_unacceptedPolicy (1 << 15) +# define OSSL_CMP_CTX_FAILINFO_unacceptedExtension (1 << 16) +# define OSSL_CMP_CTX_FAILINFO_addInfoNotAvailable (1 << 17) +# define OSSL_CMP_CTX_FAILINFO_badSenderNonce (1 << 18) +# define OSSL_CMP_CTX_FAILINFO_badCertTemplate (1 << 19) +# define OSSL_CMP_CTX_FAILINFO_signerNotTrusted (1 << 20) +# define OSSL_CMP_CTX_FAILINFO_transactionIdInUse (1 << 21) +# define OSSL_CMP_CTX_FAILINFO_unsupportedVersion (1 << 22) +# define OSSL_CMP_CTX_FAILINFO_notAuthorized (1 << 23) +# define OSSL_CMP_CTX_FAILINFO_systemUnavail (1 << 24) +# define OSSL_CMP_CTX_FAILINFO_systemFailure (1 << 25) +# define OSSL_CMP_CTX_FAILINFO_duplicateCertReq (1 << 26) + +/*- + * PKIStatus ::= INTEGER { + * accepted (0), + * -- you got exactly what you asked for + * grantedWithMods (1), + * -- you got something like what you asked for; the + * -- requester is responsible for ascertaining the differences + * rejection (2), + * -- you don't get it, more information elsewhere in the message + * waiting (3), + * -- the request body part has not yet been processed; expect to + * -- hear more later (note: proper handling of this status + * -- response MAY use the polling req/rep PKIMessages specified + * -- in Section 5.3.22; alternatively, polling in the underlying + * -- transport layer MAY have some utility in this regard) + * revocationWarning (4), + * -- this message contains a warning that a revocation is + * -- imminent + * revocationNotification (5), + * -- notification that a revocation has occurred + * keyUpdateWarning (6) + * -- update already done for the oldCertId specified in + * -- CertReqMsg + * } + */ +# define OSSL_CMP_PKISTATUS_request -3 +# define OSSL_CMP_PKISTATUS_trans -2 +# define OSSL_CMP_PKISTATUS_unspecified -1 +# define OSSL_CMP_PKISTATUS_accepted 0 +# define OSSL_CMP_PKISTATUS_grantedWithMods 1 +# define OSSL_CMP_PKISTATUS_rejection 2 +# define OSSL_CMP_PKISTATUS_waiting 3 +# define OSSL_CMP_PKISTATUS_revocationWarning 4 +# define OSSL_CMP_PKISTATUS_revocationNotification 5 +# define OSSL_CMP_PKISTATUS_keyUpdateWarning 6 +typedef ASN1_INTEGER OSSL_CMP_PKISTATUS; + +DECLARE_ASN1_ITEM(OSSL_CMP_PKISTATUS) + +# define OSSL_CMP_CERTORENCCERT_CERTIFICATE 0 +# define OSSL_CMP_CERTORENCCERT_ENCRYPTEDCERT 1 + +/* data type declarations */ +typedef struct ossl_cmp_ctx_st OSSL_CMP_CTX; +typedef struct ossl_cmp_pkiheader_st OSSL_CMP_PKIHEADER; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER) +typedef struct ossl_cmp_msg_st OSSL_CMP_MSG; +DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG) +DECLARE_ASN1_ENCODE_FUNCTIONS(OSSL_CMP_MSG, OSSL_CMP_MSG, OSSL_CMP_MSG) +typedef struct ossl_cmp_certstatus_st OSSL_CMP_CERTSTATUS; +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTSTATUS, OSSL_CMP_CERTSTATUS, OSSL_CMP_CERTSTATUS) +#define sk_OSSL_CMP_CERTSTATUS_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CERTSTATUS_value(sk, idx) ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk), (idx))) +#define sk_OSSL_CMP_CERTSTATUS_new(cmp) ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new(ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp))) +#define sk_OSSL_CMP_CERTSTATUS_new_null() ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CMP_CERTSTATUS_new_reserve(cmp, n) ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp), (n))) +#define sk_OSSL_CMP_CERTSTATUS_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (n)) +#define sk_OSSL_CMP_CERTSTATUS_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CERTSTATUS_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CERTSTATUS_delete(sk, i) ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (i))) +#define sk_OSSL_CMP_CERTSTATUS_delete_ptr(sk, ptr) ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_type(ptr))) +#define sk_OSSL_CMP_CERTSTATUS_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) +#define sk_OSSL_CMP_CERTSTATUS_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) +#define sk_OSSL_CMP_CERTSTATUS_pop(sk) ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk))) +#define sk_OSSL_CMP_CERTSTATUS_shift(sk) ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk))) +#define sk_OSSL_CMP_CERTSTATUS_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk),ossl_check_OSSL_CMP_CERTSTATUS_freefunc_type(freefunc)) +#define sk_OSSL_CMP_CERTSTATUS_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_type(ptr), (idx)) +#define sk_OSSL_CMP_CERTSTATUS_set(sk, idx, ptr) ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_set(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (idx), ossl_check_OSSL_CMP_CERTSTATUS_type(ptr))) +#define sk_OSSL_CMP_CERTSTATUS_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) +#define sk_OSSL_CMP_CERTSTATUS_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) +#define sk_OSSL_CMP_CERTSTATUS_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_type(ptr), pnum) +#define sk_OSSL_CMP_CERTSTATUS_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CERTSTATUS_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CERTSTATUS_dup(sk) ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk))) +#define sk_OSSL_CMP_CERTSTATUS_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_copyfunc_type(copyfunc), ossl_check_OSSL_CMP_CERTSTATUS_freefunc_type(freefunc))) +#define sk_OSSL_CMP_CERTSTATUS_set_cmp_func(sk, cmp) ((sk_OSSL_CMP_CERTSTATUS_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp))) + +typedef struct ossl_cmp_itav_st OSSL_CMP_ITAV; +DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV) +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_ITAV, OSSL_CMP_ITAV, OSSL_CMP_ITAV) +#define sk_OSSL_CMP_ITAV_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk)) +#define sk_OSSL_CMP_ITAV_value(sk, idx) ((OSSL_CMP_ITAV *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk), (idx))) +#define sk_OSSL_CMP_ITAV_new(cmp) ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new(ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp))) +#define sk_OSSL_CMP_ITAV_new_null() ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CMP_ITAV_new_reserve(cmp, n) ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp), (n))) +#define sk_OSSL_CMP_ITAV_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CMP_ITAV_sk_type(sk), (n)) +#define sk_OSSL_CMP_ITAV_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) +#define sk_OSSL_CMP_ITAV_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) +#define sk_OSSL_CMP_ITAV_delete(sk, i) ((OSSL_CMP_ITAV *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_ITAV_sk_type(sk), (i))) +#define sk_OSSL_CMP_ITAV_delete_ptr(sk, ptr) ((OSSL_CMP_ITAV *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr))) +#define sk_OSSL_CMP_ITAV_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr)) +#define sk_OSSL_CMP_ITAV_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr)) +#define sk_OSSL_CMP_ITAV_pop(sk) ((OSSL_CMP_ITAV *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_ITAV_sk_type(sk))) +#define sk_OSSL_CMP_ITAV_shift(sk) ((OSSL_CMP_ITAV *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_ITAV_sk_type(sk))) +#define sk_OSSL_CMP_ITAV_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_ITAV_sk_type(sk),ossl_check_OSSL_CMP_ITAV_freefunc_type(freefunc)) +#define sk_OSSL_CMP_ITAV_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr), (idx)) +#define sk_OSSL_CMP_ITAV_set(sk, idx, ptr) ((OSSL_CMP_ITAV *)OPENSSL_sk_set(ossl_check_OSSL_CMP_ITAV_sk_type(sk), (idx), ossl_check_OSSL_CMP_ITAV_type(ptr))) +#define sk_OSSL_CMP_ITAV_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr)) +#define sk_OSSL_CMP_ITAV_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr)) +#define sk_OSSL_CMP_ITAV_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr), pnum) +#define sk_OSSL_CMP_ITAV_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) +#define sk_OSSL_CMP_ITAV_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk)) +#define sk_OSSL_CMP_ITAV_dup(sk) ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk))) +#define sk_OSSL_CMP_ITAV_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_copyfunc_type(copyfunc), ossl_check_OSSL_CMP_ITAV_freefunc_type(freefunc))) +#define sk_OSSL_CMP_ITAV_set_cmp_func(sk, cmp) ((sk_OSSL_CMP_ITAV_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp))) + + +typedef struct ossl_cmp_crlstatus_st OSSL_CMP_CRLSTATUS; +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CRLSTATUS, OSSL_CMP_CRLSTATUS, OSSL_CMP_CRLSTATUS) +#define sk_OSSL_CMP_CRLSTATUS_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CRLSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CRLSTATUS_value(sk, idx) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_CRLSTATUS_sk_type(sk), (idx))) +#define sk_OSSL_CMP_CRLSTATUS_new(cmp) ((STACK_OF(OSSL_CMP_CRLSTATUS) *)OPENSSL_sk_new(ossl_check_OSSL_CMP_CRLSTATUS_compfunc_type(cmp))) +#define sk_OSSL_CMP_CRLSTATUS_new_null() ((STACK_OF(OSSL_CMP_CRLSTATUS) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CMP_CRLSTATUS_new_reserve(cmp, n) ((STACK_OF(OSSL_CMP_CRLSTATUS) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CMP_CRLSTATUS_compfunc_type(cmp), (n))) +#define sk_OSSL_CMP_CRLSTATUS_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), (n)) +#define sk_OSSL_CMP_CRLSTATUS_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CRLSTATUS_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CRLSTATUS_delete(sk, i) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), (i))) +#define sk_OSSL_CMP_CRLSTATUS_delete_ptr(sk, ptr) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr))) +#define sk_OSSL_CMP_CRLSTATUS_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr)) +#define sk_OSSL_CMP_CRLSTATUS_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr)) +#define sk_OSSL_CMP_CRLSTATUS_pop(sk) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk))) +#define sk_OSSL_CMP_CRLSTATUS_shift(sk) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk))) +#define sk_OSSL_CMP_CRLSTATUS_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk),ossl_check_OSSL_CMP_CRLSTATUS_freefunc_type(freefunc)) +#define sk_OSSL_CMP_CRLSTATUS_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr), (idx)) +#define sk_OSSL_CMP_CRLSTATUS_set(sk, idx, ptr) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_set(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), (idx), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr))) +#define sk_OSSL_CMP_CRLSTATUS_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr)) +#define sk_OSSL_CMP_CRLSTATUS_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr)) +#define sk_OSSL_CMP_CRLSTATUS_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr), pnum) +#define sk_OSSL_CMP_CRLSTATUS_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CRLSTATUS_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CRLSTATUS_sk_type(sk)) +#define sk_OSSL_CMP_CRLSTATUS_dup(sk) ((STACK_OF(OSSL_CMP_CRLSTATUS) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CMP_CRLSTATUS_sk_type(sk))) +#define sk_OSSL_CMP_CRLSTATUS_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CMP_CRLSTATUS) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_copyfunc_type(copyfunc), ossl_check_OSSL_CMP_CRLSTATUS_freefunc_type(freefunc))) +#define sk_OSSL_CMP_CRLSTATUS_set_cmp_func(sk, cmp) ((sk_OSSL_CMP_CRLSTATUS_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_compfunc_type(cmp))) + + +typedef OSSL_CRMF_ATTRIBUTETYPEANDVALUE OSSL_CMP_ATAV; +# define OSSL_CMP_ATAV_free OSSL_CRMF_ATTRIBUTETYPEANDVALUE_free +typedef STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) OSSL_CMP_ATAVS; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ATAVS) +# define stack_st_OSSL_CMP_ATAV stack_st_OSSL_CRMF_ATTRIBUTETYPEANDVALUE +# define sk_OSSL_CMP_ATAV_num sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_num +# define sk_OSSL_CMP_ATAV_value sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_value +# define sk_OSSL_CMP_ATAV_push sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_push +# define sk_OSSL_CMP_ATAV_pop_free sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_pop_free + +typedef struct ossl_cmp_revrepcontent_st OSSL_CMP_REVREPCONTENT; +typedef struct ossl_cmp_pkisi_st OSSL_CMP_PKISI; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKISI) +DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI) +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_PKISI, OSSL_CMP_PKISI, OSSL_CMP_PKISI) +#define sk_OSSL_CMP_PKISI_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk)) +#define sk_OSSL_CMP_PKISI_value(sk, idx) ((OSSL_CMP_PKISI *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk), (idx))) +#define sk_OSSL_CMP_PKISI_new(cmp) ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new(ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp))) +#define sk_OSSL_CMP_PKISI_new_null() ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CMP_PKISI_new_reserve(cmp, n) ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp), (n))) +#define sk_OSSL_CMP_PKISI_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CMP_PKISI_sk_type(sk), (n)) +#define sk_OSSL_CMP_PKISI_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) +#define sk_OSSL_CMP_PKISI_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) +#define sk_OSSL_CMP_PKISI_delete(sk, i) ((OSSL_CMP_PKISI *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_PKISI_sk_type(sk), (i))) +#define sk_OSSL_CMP_PKISI_delete_ptr(sk, ptr) ((OSSL_CMP_PKISI *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr))) +#define sk_OSSL_CMP_PKISI_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr)) +#define sk_OSSL_CMP_PKISI_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr)) +#define sk_OSSL_CMP_PKISI_pop(sk) ((OSSL_CMP_PKISI *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_PKISI_sk_type(sk))) +#define sk_OSSL_CMP_PKISI_shift(sk) ((OSSL_CMP_PKISI *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_PKISI_sk_type(sk))) +#define sk_OSSL_CMP_PKISI_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_PKISI_sk_type(sk),ossl_check_OSSL_CMP_PKISI_freefunc_type(freefunc)) +#define sk_OSSL_CMP_PKISI_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr), (idx)) +#define sk_OSSL_CMP_PKISI_set(sk, idx, ptr) ((OSSL_CMP_PKISI *)OPENSSL_sk_set(ossl_check_OSSL_CMP_PKISI_sk_type(sk), (idx), ossl_check_OSSL_CMP_PKISI_type(ptr))) +#define sk_OSSL_CMP_PKISI_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr)) +#define sk_OSSL_CMP_PKISI_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr)) +#define sk_OSSL_CMP_PKISI_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr), pnum) +#define sk_OSSL_CMP_PKISI_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) +#define sk_OSSL_CMP_PKISI_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk)) +#define sk_OSSL_CMP_PKISI_dup(sk) ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk))) +#define sk_OSSL_CMP_PKISI_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_copyfunc_type(copyfunc), ossl_check_OSSL_CMP_PKISI_freefunc_type(freefunc))) +#define sk_OSSL_CMP_PKISI_set_cmp_func(sk, cmp) ((sk_OSSL_CMP_PKISI_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp))) + +typedef struct ossl_cmp_certrepmessage_st OSSL_CMP_CERTREPMESSAGE; +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTREPMESSAGE, OSSL_CMP_CERTREPMESSAGE, OSSL_CMP_CERTREPMESSAGE) +#define sk_OSSL_CMP_CERTREPMESSAGE_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +#define sk_OSSL_CMP_CERTREPMESSAGE_value(sk, idx) ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (idx))) +#define sk_OSSL_CMP_CERTREPMESSAGE_new(cmp) ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new(ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp))) +#define sk_OSSL_CMP_CERTREPMESSAGE_new_null() ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CMP_CERTREPMESSAGE_new_reserve(cmp, n) ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp), (n))) +#define sk_OSSL_CMP_CERTREPMESSAGE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (n)) +#define sk_OSSL_CMP_CERTREPMESSAGE_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +#define sk_OSSL_CMP_CERTREPMESSAGE_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +#define sk_OSSL_CMP_CERTREPMESSAGE_delete(sk, i) ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (i))) +#define sk_OSSL_CMP_CERTREPMESSAGE_delete_ptr(sk, ptr) ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr))) +#define sk_OSSL_CMP_CERTREPMESSAGE_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) +#define sk_OSSL_CMP_CERTREPMESSAGE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) +#define sk_OSSL_CMP_CERTREPMESSAGE_pop(sk) ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) +#define sk_OSSL_CMP_CERTREPMESSAGE_shift(sk) ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) +#define sk_OSSL_CMP_CERTREPMESSAGE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk),ossl_check_OSSL_CMP_CERTREPMESSAGE_freefunc_type(freefunc)) +#define sk_OSSL_CMP_CERTREPMESSAGE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr), (idx)) +#define sk_OSSL_CMP_CERTREPMESSAGE_set(sk, idx, ptr) ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_set(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (idx), ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr))) +#define sk_OSSL_CMP_CERTREPMESSAGE_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) +#define sk_OSSL_CMP_CERTREPMESSAGE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) +#define sk_OSSL_CMP_CERTREPMESSAGE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr), pnum) +#define sk_OSSL_CMP_CERTREPMESSAGE_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +#define sk_OSSL_CMP_CERTREPMESSAGE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +#define sk_OSSL_CMP_CERTREPMESSAGE_dup(sk) ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) +#define sk_OSSL_CMP_CERTREPMESSAGE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_copyfunc_type(copyfunc), ossl_check_OSSL_CMP_CERTREPMESSAGE_freefunc_type(freefunc))) +#define sk_OSSL_CMP_CERTREPMESSAGE_set_cmp_func(sk, cmp) ((sk_OSSL_CMP_CERTREPMESSAGE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp))) + +typedef struct ossl_cmp_pollrep_st OSSL_CMP_POLLREP; +typedef STACK_OF(OSSL_CMP_POLLREP) OSSL_CMP_POLLREPCONTENT; +typedef struct ossl_cmp_certresponse_st OSSL_CMP_CERTRESPONSE; +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTRESPONSE, OSSL_CMP_CERTRESPONSE, OSSL_CMP_CERTRESPONSE) +#define sk_OSSL_CMP_CERTRESPONSE_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +#define sk_OSSL_CMP_CERTRESPONSE_value(sk, idx) ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk), (idx))) +#define sk_OSSL_CMP_CERTRESPONSE_new(cmp) ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new(ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp))) +#define sk_OSSL_CMP_CERTRESPONSE_new_null() ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CMP_CERTRESPONSE_new_reserve(cmp, n) ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp), (n))) +#define sk_OSSL_CMP_CERTRESPONSE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), (n)) +#define sk_OSSL_CMP_CERTRESPONSE_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +#define sk_OSSL_CMP_CERTRESPONSE_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +#define sk_OSSL_CMP_CERTRESPONSE_delete(sk, i) ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), (i))) +#define sk_OSSL_CMP_CERTRESPONSE_delete_ptr(sk, ptr) ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr))) +#define sk_OSSL_CMP_CERTRESPONSE_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) +#define sk_OSSL_CMP_CERTRESPONSE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) +#define sk_OSSL_CMP_CERTRESPONSE_pop(sk) ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk))) +#define sk_OSSL_CMP_CERTRESPONSE_shift(sk) ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk))) +#define sk_OSSL_CMP_CERTRESPONSE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk),ossl_check_OSSL_CMP_CERTRESPONSE_freefunc_type(freefunc)) +#define sk_OSSL_CMP_CERTRESPONSE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr), (idx)) +#define sk_OSSL_CMP_CERTRESPONSE_set(sk, idx, ptr) ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_set(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), (idx), ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr))) +#define sk_OSSL_CMP_CERTRESPONSE_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) +#define sk_OSSL_CMP_CERTRESPONSE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) +#define sk_OSSL_CMP_CERTRESPONSE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr), pnum) +#define sk_OSSL_CMP_CERTRESPONSE_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +#define sk_OSSL_CMP_CERTRESPONSE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +#define sk_OSSL_CMP_CERTRESPONSE_dup(sk) ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk))) +#define sk_OSSL_CMP_CERTRESPONSE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_copyfunc_type(copyfunc), ossl_check_OSSL_CMP_CERTRESPONSE_freefunc_type(freefunc))) +#define sk_OSSL_CMP_CERTRESPONSE_set_cmp_func(sk, cmp) ((sk_OSSL_CMP_CERTRESPONSE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp))) + +typedef STACK_OF(ASN1_UTF8STRING) OSSL_CMP_PKIFREETEXT; + +/* + * function DECLARATIONS + */ + +/* from cmp_asn.c */ +OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value); +void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type, + ASN1_TYPE *value); +ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav); +ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav); +int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **sk_p, + OSSL_CMP_ITAV *itav); +void OSSL_CMP_ITAV_free(OSSL_CMP_ITAV *itav); + +OSSL_CMP_ITAV *OSSL_CMP_ITAV_new0_certProfile(STACK_OF(ASN1_UTF8STRING) + *certProfile); +int OSSL_CMP_ITAV_get0_certProfile(const OSSL_CMP_ITAV *itav, + STACK_OF(ASN1_UTF8STRING) **out); +OSSL_CMP_ITAV *OSSL_CMP_ITAV_new_caCerts(const STACK_OF(X509) *caCerts); +int OSSL_CMP_ITAV_get0_caCerts(const OSSL_CMP_ITAV *itav, STACK_OF(X509) **out); + +OSSL_CMP_ITAV *OSSL_CMP_ITAV_new_rootCaCert(const X509 *rootCaCert); +int OSSL_CMP_ITAV_get0_rootCaCert(const OSSL_CMP_ITAV *itav, X509 **out); +OSSL_CMP_ITAV *OSSL_CMP_ITAV_new_rootCaKeyUpdate(const X509 *newWithNew, + const X509 *newWithOld, + const X509 *oldWithNew); +int OSSL_CMP_ITAV_get0_rootCaKeyUpdate(const OSSL_CMP_ITAV *itav, + X509 **newWithNew, + X509 **newWithOld, + X509 **oldWithNew); + +OSSL_CMP_CRLSTATUS *OSSL_CMP_CRLSTATUS_create(const X509_CRL *crl, + const X509 *cert, int only_DN); +OSSL_CMP_CRLSTATUS *OSSL_CMP_CRLSTATUS_new1(const DIST_POINT_NAME *dpn, + const GENERAL_NAMES *issuer, + const ASN1_TIME *thisUpdate); +int OSSL_CMP_CRLSTATUS_get0(const OSSL_CMP_CRLSTATUS *crlstatus, + DIST_POINT_NAME **dpn, GENERAL_NAMES **issuer, + ASN1_TIME **thisUpdate); +void OSSL_CMP_CRLSTATUS_free(OSSL_CMP_CRLSTATUS *crlstatus); +OSSL_CMP_ITAV +*OSSL_CMP_ITAV_new0_crlStatusList(STACK_OF(OSSL_CMP_CRLSTATUS) *crlStatusList); +int OSSL_CMP_ITAV_get0_crlStatusList(const OSSL_CMP_ITAV *itav, + STACK_OF(OSSL_CMP_CRLSTATUS) **out); +OSSL_CMP_ITAV *OSSL_CMP_ITAV_new_crls(const X509_CRL *crls); +int OSSL_CMP_ITAV_get0_crls(const OSSL_CMP_ITAV *it, STACK_OF(X509_CRL) **out); +OSSL_CMP_ITAV +*OSSL_CMP_ITAV_new0_certReqTemplate(OSSL_CRMF_CERTTEMPLATE *certTemplate, + OSSL_CMP_ATAVS *keySpec); +int OSSL_CMP_ITAV_get1_certReqTemplate(const OSSL_CMP_ITAV *itav, + OSSL_CRMF_CERTTEMPLATE **certTemplate, + OSSL_CMP_ATAVS **keySpec); + +OSSL_CMP_ATAV *OSSL_CMP_ATAV_create(ASN1_OBJECT *type, ASN1_TYPE *value); +void OSSL_CMP_ATAV_set0(OSSL_CMP_ATAV *itav, ASN1_OBJECT *type, + ASN1_TYPE *value); +ASN1_OBJECT *OSSL_CMP_ATAV_get0_type(const OSSL_CMP_ATAV *itav); +ASN1_TYPE *OSSL_CMP_ATAV_get0_value(const OSSL_CMP_ATAV *itav); +OSSL_CMP_ATAV *OSSL_CMP_ATAV_new_algId(const X509_ALGOR *alg); +X509_ALGOR *OSSL_CMP_ATAV_get0_algId(const OSSL_CMP_ATAV *atav); +OSSL_CMP_ATAV *OSSL_CMP_ATAV_new_rsaKeyLen(int len); +int OSSL_CMP_ATAV_get_rsaKeyLen(const OSSL_CMP_ATAV *atav); +int OSSL_CMP_ATAV_push1(OSSL_CMP_ATAVS **sk_p, const OSSL_CMP_ATAV *atav); + +void OSSL_CMP_MSG_free(OSSL_CMP_MSG *msg); + +/* from cmp_ctx.c */ +OSSL_CMP_CTX *OSSL_CMP_CTX_new(OSSL_LIB_CTX *libctx, const char *propq); +void OSSL_CMP_CTX_free(OSSL_CMP_CTX *ctx); +int OSSL_CMP_CTX_reinit(OSSL_CMP_CTX *ctx); +OSSL_LIB_CTX *OSSL_CMP_CTX_get0_libctx(const OSSL_CMP_CTX *ctx); +const char *OSSL_CMP_CTX_get0_propq(const OSSL_CMP_CTX *ctx); +/* CMP general options: */ +# define OSSL_CMP_OPT_LOG_VERBOSITY 0 +/* CMP transfer options: */ +# define OSSL_CMP_OPT_KEEP_ALIVE 10 +# define OSSL_CMP_OPT_MSG_TIMEOUT 11 +# define OSSL_CMP_OPT_TOTAL_TIMEOUT 12 +# define OSSL_CMP_OPT_USE_TLS 13 +/* CMP request options: */ +# define OSSL_CMP_OPT_VALIDITY_DAYS 20 +# define OSSL_CMP_OPT_SUBJECTALTNAME_NODEFAULT 21 +# define OSSL_CMP_OPT_SUBJECTALTNAME_CRITICAL 22 +# define OSSL_CMP_OPT_POLICIES_CRITICAL 23 +# define OSSL_CMP_OPT_POPO_METHOD 24 +# define OSSL_CMP_OPT_IMPLICIT_CONFIRM 25 +# define OSSL_CMP_OPT_DISABLE_CONFIRM 26 +# define OSSL_CMP_OPT_REVOCATION_REASON 27 +/* CMP protection options: */ +# define OSSL_CMP_OPT_UNPROTECTED_SEND 30 +# define OSSL_CMP_OPT_UNPROTECTED_ERRORS 31 +# define OSSL_CMP_OPT_OWF_ALGNID 32 +# define OSSL_CMP_OPT_MAC_ALGNID 33 +# define OSSL_CMP_OPT_DIGEST_ALGNID 34 +# define OSSL_CMP_OPT_IGNORE_KEYUSAGE 35 +# define OSSL_CMP_OPT_PERMIT_TA_IN_EXTRACERTS_FOR_IR 36 +# define OSSL_CMP_OPT_NO_CACHE_EXTRACERTS 37 +int OSSL_CMP_CTX_set_option(OSSL_CMP_CTX *ctx, int opt, int val); +int OSSL_CMP_CTX_get_option(const OSSL_CMP_CTX *ctx, int opt); +/* CMP-specific callback for logging and outputting the error queue: */ +int OSSL_CMP_CTX_set_log_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_log_cb_t cb); +# define OSSL_CMP_CTX_set_log_verbosity(ctx, level) \ + OSSL_CMP_CTX_set_option(ctx, OSSL_CMP_OPT_LOG_VERBOSITY, level) +void OSSL_CMP_CTX_print_errors(const OSSL_CMP_CTX *ctx); +/* message transfer: */ +int OSSL_CMP_CTX_set1_serverPath(OSSL_CMP_CTX *ctx, const char *path); +int OSSL_CMP_CTX_set1_server(OSSL_CMP_CTX *ctx, const char *address); +int OSSL_CMP_CTX_set_serverPort(OSSL_CMP_CTX *ctx, int port); +int OSSL_CMP_CTX_set1_proxy(OSSL_CMP_CTX *ctx, const char *name); +int OSSL_CMP_CTX_set1_no_proxy(OSSL_CMP_CTX *ctx, const char *names); +# ifndef OPENSSL_NO_HTTP +int OSSL_CMP_CTX_set_http_cb(OSSL_CMP_CTX *ctx, OSSL_HTTP_bio_cb_t cb); +int OSSL_CMP_CTX_set_http_cb_arg(OSSL_CMP_CTX *ctx, void *arg); +void *OSSL_CMP_CTX_get_http_cb_arg(const OSSL_CMP_CTX *ctx); +# endif +typedef OSSL_CMP_MSG *(*OSSL_CMP_transfer_cb_t) (OSSL_CMP_CTX *ctx, + const OSSL_CMP_MSG *req); +int OSSL_CMP_CTX_set_transfer_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_transfer_cb_t cb); +int OSSL_CMP_CTX_set_transfer_cb_arg(OSSL_CMP_CTX *ctx, void *arg); +void *OSSL_CMP_CTX_get_transfer_cb_arg(const OSSL_CMP_CTX *ctx); +/* server authentication: */ +int OSSL_CMP_CTX_set1_srvCert(OSSL_CMP_CTX *ctx, X509 *cert); +int OSSL_CMP_CTX_set1_expected_sender(OSSL_CMP_CTX *ctx, const X509_NAME *name); +int OSSL_CMP_CTX_set0_trustedStore(OSSL_CMP_CTX *ctx, X509_STORE *store); +# define OSSL_CMP_CTX_set0_trusted OSSL_CMP_CTX_set0_trustedStore +X509_STORE *OSSL_CMP_CTX_get0_trustedStore(const OSSL_CMP_CTX *ctx); +# define OSSL_CMP_CTX_get0_trusted OSSL_CMP_CTX_get0_trustedStore +int OSSL_CMP_CTX_set1_untrusted(OSSL_CMP_CTX *ctx, STACK_OF(X509) *certs); +STACK_OF(X509) *OSSL_CMP_CTX_get0_untrusted(const OSSL_CMP_CTX *ctx); +/* client authentication: */ +int OSSL_CMP_CTX_set1_cert(OSSL_CMP_CTX *ctx, X509 *cert); +int OSSL_CMP_CTX_build_cert_chain(OSSL_CMP_CTX *ctx, X509_STORE *own_trusted, + STACK_OF(X509) *candidates); +int OSSL_CMP_CTX_set1_pkey(OSSL_CMP_CTX *ctx, EVP_PKEY *pkey); +int OSSL_CMP_CTX_set1_referenceValue(OSSL_CMP_CTX *ctx, + const unsigned char *ref, int len); +int OSSL_CMP_CTX_set1_secretValue(OSSL_CMP_CTX *ctx, + const unsigned char *sec, int len); +/* CMP message header and extra certificates: */ +int OSSL_CMP_CTX_set1_recipient(OSSL_CMP_CTX *ctx, const X509_NAME *name); +int OSSL_CMP_CTX_push0_geninfo_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav); +int OSSL_CMP_CTX_reset_geninfo_ITAVs(OSSL_CMP_CTX *ctx); +STACK_OF(OSSL_CMP_ITAV) + *OSSL_CMP_CTX_get0_geninfo_ITAVs(const OSSL_CMP_CTX *ctx); +int OSSL_CMP_CTX_set1_extraCertsOut(OSSL_CMP_CTX *ctx, + STACK_OF(X509) *extraCertsOut); +/* certificate template: */ +int OSSL_CMP_CTX_set0_newPkey(OSSL_CMP_CTX *ctx, int priv, EVP_PKEY *pkey); +EVP_PKEY *OSSL_CMP_CTX_get0_newPkey(const OSSL_CMP_CTX *ctx, int priv); +int OSSL_CMP_CTX_set1_issuer(OSSL_CMP_CTX *ctx, const X509_NAME *name); +int OSSL_CMP_CTX_set1_serialNumber(OSSL_CMP_CTX *ctx, const ASN1_INTEGER *sn); +int OSSL_CMP_CTX_set1_subjectName(OSSL_CMP_CTX *ctx, const X509_NAME *name); +int OSSL_CMP_CTX_push1_subjectAltName(OSSL_CMP_CTX *ctx, + const GENERAL_NAME *name); +int OSSL_CMP_CTX_set0_reqExtensions(OSSL_CMP_CTX *ctx, X509_EXTENSIONS *exts); +int OSSL_CMP_CTX_reqExtensions_have_SAN(OSSL_CMP_CTX *ctx); +int OSSL_CMP_CTX_push0_policy(OSSL_CMP_CTX *ctx, POLICYINFO *pinfo); +int OSSL_CMP_CTX_set1_oldCert(OSSL_CMP_CTX *ctx, X509 *cert); +int OSSL_CMP_CTX_set1_p10CSR(OSSL_CMP_CTX *ctx, const X509_REQ *csr); +/* misc body contents: */ +int OSSL_CMP_CTX_push0_genm_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav); +/* certificate confirmation: */ +typedef int (*OSSL_CMP_certConf_cb_t) (OSSL_CMP_CTX *ctx, X509 *cert, + int fail_info, const char **txt); +int OSSL_CMP_certConf_cb(OSSL_CMP_CTX *ctx, X509 *cert, int fail_info, + const char **text); +int OSSL_CMP_CTX_set_certConf_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_certConf_cb_t cb); +int OSSL_CMP_CTX_set_certConf_cb_arg(OSSL_CMP_CTX *ctx, void *arg); +void *OSSL_CMP_CTX_get_certConf_cb_arg(const OSSL_CMP_CTX *ctx); +/* result fetching: */ +int OSSL_CMP_CTX_get_status(const OSSL_CMP_CTX *ctx); +OSSL_CMP_PKIFREETEXT *OSSL_CMP_CTX_get0_statusString(const OSSL_CMP_CTX *ctx); +int OSSL_CMP_CTX_get_failInfoCode(const OSSL_CMP_CTX *ctx); +# define OSSL_CMP_PKISI_BUFLEN 1024 +X509 *OSSL_CMP_CTX_get0_validatedSrvCert(const OSSL_CMP_CTX *ctx); +X509 *OSSL_CMP_CTX_get0_newCert(const OSSL_CMP_CTX *ctx); +STACK_OF(X509) *OSSL_CMP_CTX_get1_newChain(const OSSL_CMP_CTX *ctx); +STACK_OF(X509) *OSSL_CMP_CTX_get1_caPubs(const OSSL_CMP_CTX *ctx); +STACK_OF(X509) *OSSL_CMP_CTX_get1_extraCertsIn(const OSSL_CMP_CTX *ctx); +int OSSL_CMP_CTX_set1_transactionID(OSSL_CMP_CTX *ctx, + const ASN1_OCTET_STRING *id); +int OSSL_CMP_CTX_set1_senderNonce(OSSL_CMP_CTX *ctx, + const ASN1_OCTET_STRING *nonce); + +/* from cmp_status.c */ +char *OSSL_CMP_CTX_snprint_PKIStatus(const OSSL_CMP_CTX *ctx, char *buf, + size_t bufsize); +char *OSSL_CMP_snprint_PKIStatusInfo(const OSSL_CMP_PKISI *statusInfo, + char *buf, size_t bufsize); +OSSL_CMP_PKISI * +OSSL_CMP_STATUSINFO_new(int status, int fail_info, const char *text); + +/* from cmp_hdr.c */ +ASN1_OCTET_STRING *OSSL_CMP_HDR_get0_transactionID(const + OSSL_CMP_PKIHEADER *hdr); +ASN1_OCTET_STRING *OSSL_CMP_HDR_get0_recipNonce(const OSSL_CMP_PKIHEADER *hdr); +STACK_OF(OSSL_CMP_ITAV) + *OSSL_CMP_HDR_get0_geninfo_ITAVs(const OSSL_CMP_PKIHEADER *hdr); + +/* from cmp_msg.c */ +OSSL_CMP_PKIHEADER *OSSL_CMP_MSG_get0_header(const OSSL_CMP_MSG *msg); +int OSSL_CMP_MSG_get_bodytype(const OSSL_CMP_MSG *msg); +X509_PUBKEY *OSSL_CMP_MSG_get0_certreq_publickey(const OSSL_CMP_MSG *msg); +int OSSL_CMP_MSG_update_transactionID(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg); +int OSSL_CMP_MSG_update_recipNonce(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg); +OSSL_CRMF_MSG *OSSL_CMP_CTX_setup_CRM(OSSL_CMP_CTX *ctx, int for_KUR, int rid); +OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx, + const char *propq); +int OSSL_CMP_MSG_write(const char *file, const OSSL_CMP_MSG *msg); +OSSL_CMP_MSG *d2i_OSSL_CMP_MSG_bio(BIO *bio, OSSL_CMP_MSG **msg); +int i2d_OSSL_CMP_MSG_bio(BIO *bio, const OSSL_CMP_MSG *msg); + +/* from cmp_vfy.c */ +int OSSL_CMP_validate_msg(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg); +int OSSL_CMP_validate_cert_path(const OSSL_CMP_CTX *ctx, + X509_STORE *trusted_store, X509 *cert); + +/* from cmp_http.c */ +# ifndef OPENSSL_NO_HTTP +OSSL_CMP_MSG *OSSL_CMP_MSG_http_perform(OSSL_CMP_CTX *ctx, + const OSSL_CMP_MSG *req); +# endif + +/* from cmp_server.c */ +typedef struct ossl_cmp_srv_ctx_st OSSL_CMP_SRV_CTX; +OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req); +OSSL_CMP_MSG * OSSL_CMP_CTX_server_perform(OSSL_CMP_CTX *client_ctx, + const OSSL_CMP_MSG *req); +OSSL_CMP_SRV_CTX *OSSL_CMP_SRV_CTX_new(OSSL_LIB_CTX *libctx, const char *propq); +void OSSL_CMP_SRV_CTX_free(OSSL_CMP_SRV_CTX *srv_ctx); +typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_cert_request_cb_t) + (OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, int certReqId, + const OSSL_CRMF_MSG *crm, const X509_REQ *p10cr, + X509 **certOut, STACK_OF(X509) **chainOut, STACK_OF(X509) **caPubs); +typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_rr_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, + const X509_NAME *issuer, + const ASN1_INTEGER *serial); +typedef int (*OSSL_CMP_SRV_genm_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, + const STACK_OF(OSSL_CMP_ITAV) *in, + STACK_OF(OSSL_CMP_ITAV) **out); +typedef void (*OSSL_CMP_SRV_error_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, + const OSSL_CMP_PKISI *statusInfo, + const ASN1_INTEGER *errorCode, + const OSSL_CMP_PKIFREETEXT *errDetails); +typedef int (*OSSL_CMP_SRV_certConf_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, + int certReqId, + const ASN1_OCTET_STRING *certHash, + const OSSL_CMP_PKISI *si); +typedef int (*OSSL_CMP_SRV_pollReq_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, int certReqId, + OSSL_CMP_MSG **certReq, + int64_t *check_after); +int OSSL_CMP_SRV_CTX_init(OSSL_CMP_SRV_CTX *srv_ctx, void *custom_ctx, + OSSL_CMP_SRV_cert_request_cb_t process_cert_request, + OSSL_CMP_SRV_rr_cb_t process_rr, + OSSL_CMP_SRV_genm_cb_t process_genm, + OSSL_CMP_SRV_error_cb_t process_error, + OSSL_CMP_SRV_certConf_cb_t process_certConf, + OSSL_CMP_SRV_pollReq_cb_t process_pollReq); +typedef int (*OSSL_CMP_SRV_delayed_delivery_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req); +typedef int (*OSSL_CMP_SRV_clean_transaction_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const ASN1_OCTET_STRING *id); +int OSSL_CMP_SRV_CTX_init_trans(OSSL_CMP_SRV_CTX *srv_ctx, + OSSL_CMP_SRV_delayed_delivery_cb_t delay, + OSSL_CMP_SRV_clean_transaction_cb_t clean); +OSSL_CMP_CTX *OSSL_CMP_SRV_CTX_get0_cmp_ctx(const OSSL_CMP_SRV_CTX *srv_ctx); +void *OSSL_CMP_SRV_CTX_get0_custom_ctx(const OSSL_CMP_SRV_CTX *srv_ctx); +int OSSL_CMP_SRV_CTX_set_send_unprotected_errors(OSSL_CMP_SRV_CTX *srv_ctx, + int val); +int OSSL_CMP_SRV_CTX_set_accept_unprotected(OSSL_CMP_SRV_CTX *srv_ctx, int val); +int OSSL_CMP_SRV_CTX_set_accept_raverified(OSSL_CMP_SRV_CTX *srv_ctx, int val); +int OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(OSSL_CMP_SRV_CTX *srv_ctx, + int val); + +/* from cmp_client.c */ +X509 *OSSL_CMP_exec_certreq(OSSL_CMP_CTX *ctx, int req_type, + const OSSL_CRMF_MSG *crm); +# define OSSL_CMP_IR 0 +# define OSSL_CMP_CR 2 +# define OSSL_CMP_P10CR 4 +# define OSSL_CMP_KUR 7 +# define OSSL_CMP_GENM 21 +# define OSSL_CMP_ERROR 23 +# define OSSL_CMP_exec_IR_ses(ctx) \ + OSSL_CMP_exec_certreq(ctx, OSSL_CMP_IR, NULL) +# define OSSL_CMP_exec_CR_ses(ctx) \ + OSSL_CMP_exec_certreq(ctx, OSSL_CMP_CR, NULL) +# define OSSL_CMP_exec_P10CR_ses(ctx) \ + OSSL_CMP_exec_certreq(ctx, OSSL_CMP_P10CR, NULL) +# define OSSL_CMP_exec_KUR_ses(ctx) \ + OSSL_CMP_exec_certreq(ctx, OSSL_CMP_KUR, NULL) +int OSSL_CMP_try_certreq(OSSL_CMP_CTX *ctx, int req_type, + const OSSL_CRMF_MSG *crm, int *checkAfter); +int OSSL_CMP_exec_RR_ses(OSSL_CMP_CTX *ctx); +STACK_OF(OSSL_CMP_ITAV) *OSSL_CMP_exec_GENM_ses(OSSL_CMP_CTX *ctx); + +/* from cmp_genm.c */ +int OSSL_CMP_get1_caCerts(OSSL_CMP_CTX *ctx, STACK_OF(X509) **out); +int OSSL_CMP_get1_rootCaKeyUpdate(OSSL_CMP_CTX *ctx, + const X509 *oldWithOld, X509 **newWithNew, + X509 **newWithOld, X509 **oldWithNew); +int OSSL_CMP_get1_crlUpdate(OSSL_CMP_CTX *ctx, const X509 *crlcert, + const X509_CRL *last_crl, + X509_CRL **crl); +int OSSL_CMP_get1_certReqTemplate(OSSL_CMP_CTX *ctx, + OSSL_CRMF_CERTTEMPLATE **certTemplate, + OSSL_CMP_ATAVS **keySpec); + +# ifdef __cplusplus +} +# endif +# endif /* !defined(OPENSSL_NO_CMP) */ +#endif /* !defined(OPENSSL_CMP_H) */ diff --git a/illumos-x86_64/usr/include/openssl-3/cmp_util.h b/illumos-x86_64/usr/include/openssl-3/cmp_util.h new file mode 100644 index 00000000..9a168922 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cmp_util.h @@ -0,0 +1,56 @@ +/* + * Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CMP_UTIL_H +# define OPENSSL_CMP_UTIL_H +# pragma once + +# include +# ifndef OPENSSL_NO_CMP + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +int OSSL_CMP_log_open(void); +void OSSL_CMP_log_close(void); +# define OSSL_CMP_LOG_PREFIX "CMP " + +/* + * generalized logging/error callback mirroring the severity levels of syslog.h + */ +typedef int OSSL_CMP_severity; +# define OSSL_CMP_LOG_EMERG 0 +# define OSSL_CMP_LOG_ALERT 1 +# define OSSL_CMP_LOG_CRIT 2 +# define OSSL_CMP_LOG_ERR 3 +# define OSSL_CMP_LOG_WARNING 4 +# define OSSL_CMP_LOG_NOTICE 5 +# define OSSL_CMP_LOG_INFO 6 +# define OSSL_CMP_LOG_DEBUG 7 +# define OSSL_CMP_LOG_TRACE 8 +# define OSSL_CMP_LOG_MAX OSSL_CMP_LOG_TRACE +typedef int (*OSSL_CMP_log_cb_t)(const char *func, const char *file, int line, + OSSL_CMP_severity level, const char *msg); + +int OSSL_CMP_print_to_bio(BIO *bio, const char *component, const char *file, + int line, OSSL_CMP_severity level, const char *msg); +/* use of the logging callback for outputting error queue */ +void OSSL_CMP_print_errors_cb(OSSL_CMP_log_cb_t log_fn); + +# ifdef __cplusplus +} +# endif +# endif /* !defined(OPENSSL_NO_CMP) */ +#endif /* !defined(OPENSSL_CMP_UTIL_H) */ diff --git a/illumos-x86_64/usr/include/openssl-3/cmperr.h b/illumos-x86_64/usr/include/openssl-3/cmperr.h new file mode 100644 index 00000000..62137aa8 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cmperr.h @@ -0,0 +1,134 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CMPERR_H +# define OPENSSL_CMPERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_CMP + + +/* + * CMP reason codes. + */ +# define CMP_R_ALGORITHM_NOT_SUPPORTED 139 +# define CMP_R_BAD_CHECKAFTER_IN_POLLREP 167 +# define CMP_R_BAD_REQUEST_ID 108 +# define CMP_R_CERTHASH_UNMATCHED 156 +# define CMP_R_CERTID_NOT_FOUND 109 +# define CMP_R_CERTIFICATE_NOT_ACCEPTED 169 +# define CMP_R_CERTIFICATE_NOT_FOUND 112 +# define CMP_R_CERTREQMSG_NOT_FOUND 157 +# define CMP_R_CERTRESPONSE_NOT_FOUND 113 +# define CMP_R_CERT_AND_KEY_DO_NOT_MATCH 114 +# define CMP_R_CHECKAFTER_OUT_OF_RANGE 181 +# define CMP_R_ENCOUNTERED_KEYUPDATEWARNING 176 +# define CMP_R_ENCOUNTERED_WAITING 162 +# define CMP_R_ERROR_CALCULATING_PROTECTION 115 +# define CMP_R_ERROR_CREATING_CERTCONF 116 +# define CMP_R_ERROR_CREATING_CERTREP 117 +# define CMP_R_ERROR_CREATING_CERTREQ 163 +# define CMP_R_ERROR_CREATING_ERROR 118 +# define CMP_R_ERROR_CREATING_GENM 119 +# define CMP_R_ERROR_CREATING_GENP 120 +# define CMP_R_ERROR_CREATING_PKICONF 122 +# define CMP_R_ERROR_CREATING_POLLREP 123 +# define CMP_R_ERROR_CREATING_POLLREQ 124 +# define CMP_R_ERROR_CREATING_RP 125 +# define CMP_R_ERROR_CREATING_RR 126 +# define CMP_R_ERROR_PARSING_PKISTATUS 107 +# define CMP_R_ERROR_PROCESSING_MESSAGE 158 +# define CMP_R_ERROR_PROTECTING_MESSAGE 127 +# define CMP_R_ERROR_SETTING_CERTHASH 128 +# define CMP_R_ERROR_UNEXPECTED_CERTCONF 160 +# define CMP_R_ERROR_VALIDATING_PROTECTION 140 +# define CMP_R_ERROR_VALIDATING_SIGNATURE 171 +# define CMP_R_EXPECTED_POLLREQ 104 +# define CMP_R_FAILED_BUILDING_OWN_CHAIN 164 +# define CMP_R_FAILED_EXTRACTING_CENTRAL_GEN_KEY 203 +# define CMP_R_FAILED_EXTRACTING_PUBKEY 141 +# define CMP_R_FAILURE_OBTAINING_RANDOM 110 +# define CMP_R_FAIL_INFO_OUT_OF_RANGE 129 +# define CMP_R_GENERATE_CERTREQTEMPLATE 197 +# define CMP_R_GENERATE_CRLSTATUS 198 +# define CMP_R_GETTING_GENP 192 +# define CMP_R_GET_ITAV 199 +# define CMP_R_INVALID_ARGS 100 +# define CMP_R_INVALID_GENP 193 +# define CMP_R_INVALID_KEYSPEC 202 +# define CMP_R_INVALID_OPTION 174 +# define CMP_R_INVALID_ROOTCAKEYUPDATE 195 +# define CMP_R_MISSING_CENTRAL_GEN_KEY 204 +# define CMP_R_MISSING_CERTID 165 +# define CMP_R_MISSING_KEY_INPUT_FOR_CREATING_PROTECTION 130 +# define CMP_R_MISSING_KEY_USAGE_DIGITALSIGNATURE 142 +# define CMP_R_MISSING_P10CSR 121 +# define CMP_R_MISSING_PBM_SECRET 166 +# define CMP_R_MISSING_PRIVATE_KEY 131 +# define CMP_R_MISSING_PRIVATE_KEY_FOR_POPO 190 +# define CMP_R_MISSING_PROTECTION 143 +# define CMP_R_MISSING_PUBLIC_KEY 183 +# define CMP_R_MISSING_REFERENCE_CERT 168 +# define CMP_R_MISSING_SECRET 178 +# define CMP_R_MISSING_SENDER_IDENTIFICATION 111 +# define CMP_R_MISSING_TRUST_ANCHOR 179 +# define CMP_R_MISSING_TRUST_STORE 144 +# define CMP_R_MULTIPLE_REQUESTS_NOT_SUPPORTED 161 +# define CMP_R_MULTIPLE_RESPONSES_NOT_SUPPORTED 170 +# define CMP_R_MULTIPLE_SAN_SOURCES 102 +# define CMP_R_NO_STDIO 194 +# define CMP_R_NO_SUITABLE_SENDER_CERT 145 +# define CMP_R_NULL_ARGUMENT 103 +# define CMP_R_PKIBODY_ERROR 146 +# define CMP_R_PKISTATUSINFO_NOT_FOUND 132 +# define CMP_R_POLLING_FAILED 172 +# define CMP_R_POTENTIALLY_INVALID_CERTIFICATE 147 +# define CMP_R_RECEIVED_ERROR 180 +# define CMP_R_RECIPNONCE_UNMATCHED 148 +# define CMP_R_REQUEST_NOT_ACCEPTED 149 +# define CMP_R_REQUEST_REJECTED_BY_SERVER 182 +# define CMP_R_SENDER_GENERALNAME_TYPE_NOT_SUPPORTED 150 +# define CMP_R_SRVCERT_DOES_NOT_VALIDATE_MSG 151 +# define CMP_R_TOTAL_TIMEOUT 184 +# define CMP_R_TRANSACTIONID_UNMATCHED 152 +# define CMP_R_TRANSFER_ERROR 159 +# define CMP_R_UNCLEAN_CTX 191 +# define CMP_R_UNEXPECTED_CENTRAL_GEN_KEY 205 +# define CMP_R_UNEXPECTED_CERTPROFILE 196 +# define CMP_R_UNEXPECTED_CRLSTATUSLIST 201 +# define CMP_R_UNEXPECTED_PKIBODY 133 +# define CMP_R_UNEXPECTED_PKISTATUS 185 +# define CMP_R_UNEXPECTED_POLLREQ 105 +# define CMP_R_UNEXPECTED_PVNO 153 +# define CMP_R_UNEXPECTED_SENDER 106 +# define CMP_R_UNKNOWN_ALGORITHM_ID 134 +# define CMP_R_UNKNOWN_CERT_TYPE 135 +# define CMP_R_UNKNOWN_CRL_ISSUER 200 +# define CMP_R_UNKNOWN_PKISTATUS 186 +# define CMP_R_UNSUPPORTED_ALGORITHM 136 +# define CMP_R_UNSUPPORTED_KEY_TYPE 137 +# define CMP_R_UNSUPPORTED_PKIBODY 101 +# define CMP_R_UNSUPPORTED_PROTECTION_ALG_DHBASEDMAC 154 +# define CMP_R_VALUE_TOO_LARGE 175 +# define CMP_R_VALUE_TOO_SMALL 177 +# define CMP_R_WRONG_ALGORITHM_OID 138 +# define CMP_R_WRONG_CERTID 189 +# define CMP_R_WRONG_CERTID_IN_RP 187 +# define CMP_R_WRONG_PBM_VALUE 155 +# define CMP_R_WRONG_RP_COMPONENT_COUNT 188 +# define CMP_R_WRONG_SERIAL_IN_RP 173 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/cms.h b/illumos-x86_64/usr/include/openssl-3/cms.h new file mode 100644 index 00000000..63afab56 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cms.h @@ -0,0 +1,511 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/cms.h.in + * + * Copyright 2008-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_CMS_H +# define OPENSSL_CMS_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_CMS_H +# endif + +# include + +# ifndef OPENSSL_NO_CMS +# include +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct CMS_EnvelopedData_st CMS_EnvelopedData; +typedef struct CMS_ContentInfo_st CMS_ContentInfo; +typedef struct CMS_SignerInfo_st CMS_SignerInfo; +typedef struct CMS_SignedData_st CMS_SignedData; +typedef struct CMS_CertificateChoices CMS_CertificateChoices; +typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice; +typedef struct CMS_RecipientInfo_st CMS_RecipientInfo; +typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest; +typedef struct CMS_Receipt_st CMS_Receipt; +typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey; +typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute; + +SKM_DEFINE_STACK_OF_INTERNAL(CMS_SignerInfo, CMS_SignerInfo, CMS_SignerInfo) +#define sk_CMS_SignerInfo_num(sk) OPENSSL_sk_num(ossl_check_const_CMS_SignerInfo_sk_type(sk)) +#define sk_CMS_SignerInfo_value(sk, idx) ((CMS_SignerInfo *)OPENSSL_sk_value(ossl_check_const_CMS_SignerInfo_sk_type(sk), (idx))) +#define sk_CMS_SignerInfo_new(cmp) ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new(ossl_check_CMS_SignerInfo_compfunc_type(cmp))) +#define sk_CMS_SignerInfo_new_null() ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new_null()) +#define sk_CMS_SignerInfo_new_reserve(cmp, n) ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new_reserve(ossl_check_CMS_SignerInfo_compfunc_type(cmp), (n))) +#define sk_CMS_SignerInfo_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CMS_SignerInfo_sk_type(sk), (n)) +#define sk_CMS_SignerInfo_free(sk) OPENSSL_sk_free(ossl_check_CMS_SignerInfo_sk_type(sk)) +#define sk_CMS_SignerInfo_zero(sk) OPENSSL_sk_zero(ossl_check_CMS_SignerInfo_sk_type(sk)) +#define sk_CMS_SignerInfo_delete(sk, i) ((CMS_SignerInfo *)OPENSSL_sk_delete(ossl_check_CMS_SignerInfo_sk_type(sk), (i))) +#define sk_CMS_SignerInfo_delete_ptr(sk, ptr) ((CMS_SignerInfo *)OPENSSL_sk_delete_ptr(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr))) +#define sk_CMS_SignerInfo_push(sk, ptr) OPENSSL_sk_push(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr)) +#define sk_CMS_SignerInfo_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr)) +#define sk_CMS_SignerInfo_pop(sk) ((CMS_SignerInfo *)OPENSSL_sk_pop(ossl_check_CMS_SignerInfo_sk_type(sk))) +#define sk_CMS_SignerInfo_shift(sk) ((CMS_SignerInfo *)OPENSSL_sk_shift(ossl_check_CMS_SignerInfo_sk_type(sk))) +#define sk_CMS_SignerInfo_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_CMS_SignerInfo_sk_type(sk),ossl_check_CMS_SignerInfo_freefunc_type(freefunc)) +#define sk_CMS_SignerInfo_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr), (idx)) +#define sk_CMS_SignerInfo_set(sk, idx, ptr) ((CMS_SignerInfo *)OPENSSL_sk_set(ossl_check_CMS_SignerInfo_sk_type(sk), (idx), ossl_check_CMS_SignerInfo_type(ptr))) +#define sk_CMS_SignerInfo_find(sk, ptr) OPENSSL_sk_find(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr)) +#define sk_CMS_SignerInfo_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr)) +#define sk_CMS_SignerInfo_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr), pnum) +#define sk_CMS_SignerInfo_sort(sk) OPENSSL_sk_sort(ossl_check_CMS_SignerInfo_sk_type(sk)) +#define sk_CMS_SignerInfo_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CMS_SignerInfo_sk_type(sk)) +#define sk_CMS_SignerInfo_dup(sk) ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_dup(ossl_check_const_CMS_SignerInfo_sk_type(sk))) +#define sk_CMS_SignerInfo_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_deep_copy(ossl_check_const_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_copyfunc_type(copyfunc), ossl_check_CMS_SignerInfo_freefunc_type(freefunc))) +#define sk_CMS_SignerInfo_set_cmp_func(sk, cmp) ((sk_CMS_SignerInfo_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(CMS_RecipientEncryptedKey, CMS_RecipientEncryptedKey, CMS_RecipientEncryptedKey) +#define sk_CMS_RecipientEncryptedKey_num(sk) OPENSSL_sk_num(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk)) +#define sk_CMS_RecipientEncryptedKey_value(sk, idx) ((CMS_RecipientEncryptedKey *)OPENSSL_sk_value(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk), (idx))) +#define sk_CMS_RecipientEncryptedKey_new(cmp) ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new(ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp))) +#define sk_CMS_RecipientEncryptedKey_new_null() ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new_null()) +#define sk_CMS_RecipientEncryptedKey_new_reserve(cmp, n) ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new_reserve(ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp), (n))) +#define sk_CMS_RecipientEncryptedKey_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (n)) +#define sk_CMS_RecipientEncryptedKey_free(sk) OPENSSL_sk_free(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) +#define sk_CMS_RecipientEncryptedKey_zero(sk) OPENSSL_sk_zero(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) +#define sk_CMS_RecipientEncryptedKey_delete(sk, i) ((CMS_RecipientEncryptedKey *)OPENSSL_sk_delete(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (i))) +#define sk_CMS_RecipientEncryptedKey_delete_ptr(sk, ptr) ((CMS_RecipientEncryptedKey *)OPENSSL_sk_delete_ptr(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_type(ptr))) +#define sk_CMS_RecipientEncryptedKey_push(sk, ptr) OPENSSL_sk_push(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_type(ptr)) +#define sk_CMS_RecipientEncryptedKey_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_type(ptr)) +#define sk_CMS_RecipientEncryptedKey_pop(sk) ((CMS_RecipientEncryptedKey *)OPENSSL_sk_pop(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk))) +#define sk_CMS_RecipientEncryptedKey_shift(sk) ((CMS_RecipientEncryptedKey *)OPENSSL_sk_shift(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk))) +#define sk_CMS_RecipientEncryptedKey_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk),ossl_check_CMS_RecipientEncryptedKey_freefunc_type(freefunc)) +#define sk_CMS_RecipientEncryptedKey_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_type(ptr), (idx)) +#define sk_CMS_RecipientEncryptedKey_set(sk, idx, ptr) ((CMS_RecipientEncryptedKey *)OPENSSL_sk_set(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (idx), ossl_check_CMS_RecipientEncryptedKey_type(ptr))) +#define sk_CMS_RecipientEncryptedKey_find(sk, ptr) OPENSSL_sk_find(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_type(ptr)) +#define sk_CMS_RecipientEncryptedKey_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_type(ptr)) +#define sk_CMS_RecipientEncryptedKey_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_type(ptr), pnum) +#define sk_CMS_RecipientEncryptedKey_sort(sk) OPENSSL_sk_sort(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) +#define sk_CMS_RecipientEncryptedKey_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk)) +#define sk_CMS_RecipientEncryptedKey_dup(sk) ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_dup(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk))) +#define sk_CMS_RecipientEncryptedKey_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_deep_copy(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_copyfunc_type(copyfunc), ossl_check_CMS_RecipientEncryptedKey_freefunc_type(freefunc))) +#define sk_CMS_RecipientEncryptedKey_set_cmp_func(sk, cmp) ((sk_CMS_RecipientEncryptedKey_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(CMS_RecipientInfo, CMS_RecipientInfo, CMS_RecipientInfo) +#define sk_CMS_RecipientInfo_num(sk) OPENSSL_sk_num(ossl_check_const_CMS_RecipientInfo_sk_type(sk)) +#define sk_CMS_RecipientInfo_value(sk, idx) ((CMS_RecipientInfo *)OPENSSL_sk_value(ossl_check_const_CMS_RecipientInfo_sk_type(sk), (idx))) +#define sk_CMS_RecipientInfo_new(cmp) ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new(ossl_check_CMS_RecipientInfo_compfunc_type(cmp))) +#define sk_CMS_RecipientInfo_new_null() ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new_null()) +#define sk_CMS_RecipientInfo_new_reserve(cmp, n) ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new_reserve(ossl_check_CMS_RecipientInfo_compfunc_type(cmp), (n))) +#define sk_CMS_RecipientInfo_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CMS_RecipientInfo_sk_type(sk), (n)) +#define sk_CMS_RecipientInfo_free(sk) OPENSSL_sk_free(ossl_check_CMS_RecipientInfo_sk_type(sk)) +#define sk_CMS_RecipientInfo_zero(sk) OPENSSL_sk_zero(ossl_check_CMS_RecipientInfo_sk_type(sk)) +#define sk_CMS_RecipientInfo_delete(sk, i) ((CMS_RecipientInfo *)OPENSSL_sk_delete(ossl_check_CMS_RecipientInfo_sk_type(sk), (i))) +#define sk_CMS_RecipientInfo_delete_ptr(sk, ptr) ((CMS_RecipientInfo *)OPENSSL_sk_delete_ptr(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr))) +#define sk_CMS_RecipientInfo_push(sk, ptr) OPENSSL_sk_push(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr)) +#define sk_CMS_RecipientInfo_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr)) +#define sk_CMS_RecipientInfo_pop(sk) ((CMS_RecipientInfo *)OPENSSL_sk_pop(ossl_check_CMS_RecipientInfo_sk_type(sk))) +#define sk_CMS_RecipientInfo_shift(sk) ((CMS_RecipientInfo *)OPENSSL_sk_shift(ossl_check_CMS_RecipientInfo_sk_type(sk))) +#define sk_CMS_RecipientInfo_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_CMS_RecipientInfo_sk_type(sk),ossl_check_CMS_RecipientInfo_freefunc_type(freefunc)) +#define sk_CMS_RecipientInfo_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr), (idx)) +#define sk_CMS_RecipientInfo_set(sk, idx, ptr) ((CMS_RecipientInfo *)OPENSSL_sk_set(ossl_check_CMS_RecipientInfo_sk_type(sk), (idx), ossl_check_CMS_RecipientInfo_type(ptr))) +#define sk_CMS_RecipientInfo_find(sk, ptr) OPENSSL_sk_find(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr)) +#define sk_CMS_RecipientInfo_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr)) +#define sk_CMS_RecipientInfo_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr), pnum) +#define sk_CMS_RecipientInfo_sort(sk) OPENSSL_sk_sort(ossl_check_CMS_RecipientInfo_sk_type(sk)) +#define sk_CMS_RecipientInfo_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CMS_RecipientInfo_sk_type(sk)) +#define sk_CMS_RecipientInfo_dup(sk) ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_dup(ossl_check_const_CMS_RecipientInfo_sk_type(sk))) +#define sk_CMS_RecipientInfo_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_deep_copy(ossl_check_const_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_copyfunc_type(copyfunc), ossl_check_CMS_RecipientInfo_freefunc_type(freefunc))) +#define sk_CMS_RecipientInfo_set_cmp_func(sk, cmp) ((sk_CMS_RecipientInfo_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(CMS_RevocationInfoChoice, CMS_RevocationInfoChoice, CMS_RevocationInfoChoice) +#define sk_CMS_RevocationInfoChoice_num(sk) OPENSSL_sk_num(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk)) +#define sk_CMS_RevocationInfoChoice_value(sk, idx) ((CMS_RevocationInfoChoice *)OPENSSL_sk_value(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk), (idx))) +#define sk_CMS_RevocationInfoChoice_new(cmp) ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new(ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp))) +#define sk_CMS_RevocationInfoChoice_new_null() ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new_null()) +#define sk_CMS_RevocationInfoChoice_new_reserve(cmp, n) ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new_reserve(ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp), (n))) +#define sk_CMS_RevocationInfoChoice_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (n)) +#define sk_CMS_RevocationInfoChoice_free(sk) OPENSSL_sk_free(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) +#define sk_CMS_RevocationInfoChoice_zero(sk) OPENSSL_sk_zero(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) +#define sk_CMS_RevocationInfoChoice_delete(sk, i) ((CMS_RevocationInfoChoice *)OPENSSL_sk_delete(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (i))) +#define sk_CMS_RevocationInfoChoice_delete_ptr(sk, ptr) ((CMS_RevocationInfoChoice *)OPENSSL_sk_delete_ptr(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_type(ptr))) +#define sk_CMS_RevocationInfoChoice_push(sk, ptr) OPENSSL_sk_push(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_type(ptr)) +#define sk_CMS_RevocationInfoChoice_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_type(ptr)) +#define sk_CMS_RevocationInfoChoice_pop(sk) ((CMS_RevocationInfoChoice *)OPENSSL_sk_pop(ossl_check_CMS_RevocationInfoChoice_sk_type(sk))) +#define sk_CMS_RevocationInfoChoice_shift(sk) ((CMS_RevocationInfoChoice *)OPENSSL_sk_shift(ossl_check_CMS_RevocationInfoChoice_sk_type(sk))) +#define sk_CMS_RevocationInfoChoice_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_CMS_RevocationInfoChoice_sk_type(sk),ossl_check_CMS_RevocationInfoChoice_freefunc_type(freefunc)) +#define sk_CMS_RevocationInfoChoice_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_type(ptr), (idx)) +#define sk_CMS_RevocationInfoChoice_set(sk, idx, ptr) ((CMS_RevocationInfoChoice *)OPENSSL_sk_set(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (idx), ossl_check_CMS_RevocationInfoChoice_type(ptr))) +#define sk_CMS_RevocationInfoChoice_find(sk, ptr) OPENSSL_sk_find(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_type(ptr)) +#define sk_CMS_RevocationInfoChoice_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_type(ptr)) +#define sk_CMS_RevocationInfoChoice_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_type(ptr), pnum) +#define sk_CMS_RevocationInfoChoice_sort(sk) OPENSSL_sk_sort(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) +#define sk_CMS_RevocationInfoChoice_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk)) +#define sk_CMS_RevocationInfoChoice_dup(sk) ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_dup(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk))) +#define sk_CMS_RevocationInfoChoice_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_deep_copy(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_copyfunc_type(copyfunc), ossl_check_CMS_RevocationInfoChoice_freefunc_type(freefunc))) +#define sk_CMS_RevocationInfoChoice_set_cmp_func(sk, cmp) ((sk_CMS_RevocationInfoChoice_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp))) + + +DECLARE_ASN1_ITEM(CMS_EnvelopedData) +DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_SignedData) +DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) +DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest) +DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo) + +DECLARE_ASN1_DUP_FUNCTION(CMS_EnvelopedData) + +CMS_ContentInfo *CMS_ContentInfo_new_ex(OSSL_LIB_CTX *libctx, const char *propq); + +# define CMS_SIGNERINFO_ISSUER_SERIAL 0 +# define CMS_SIGNERINFO_KEYIDENTIFIER 1 + +# define CMS_RECIPINFO_NONE -1 +# define CMS_RECIPINFO_TRANS 0 +# define CMS_RECIPINFO_AGREE 1 +# define CMS_RECIPINFO_KEK 2 +# define CMS_RECIPINFO_PASS 3 +# define CMS_RECIPINFO_OTHER 4 + +/* S/MIME related flags */ + +# define CMS_TEXT 0x1 +# define CMS_NOCERTS 0x2 +# define CMS_NO_CONTENT_VERIFY 0x4 +# define CMS_NO_ATTR_VERIFY 0x8 +# define CMS_NOSIGS \ + (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY) +# define CMS_NOINTERN 0x10 +# define CMS_NO_SIGNER_CERT_VERIFY 0x20 +# define CMS_NOVERIFY 0x20 +# define CMS_DETACHED 0x40 +# define CMS_BINARY 0x80 +# define CMS_NOATTR 0x100 +# define CMS_NOSMIMECAP 0x200 +# define CMS_NOOLDMIMETYPE 0x400 +# define CMS_CRLFEOL 0x800 +# define CMS_STREAM 0x1000 +# define CMS_NOCRL 0x2000 +# define CMS_PARTIAL 0x4000 +# define CMS_REUSE_DIGEST 0x8000 +# define CMS_USE_KEYID 0x10000 +# define CMS_DEBUG_DECRYPT 0x20000 +# define CMS_KEY_PARAM 0x40000 +# define CMS_ASCIICRLF 0x80000 +# define CMS_CADES 0x100000 +# define CMS_USE_ORIGINATOR_KEYID 0x200000 +# define CMS_NO_SIGNING_TIME 0x400000 + +const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms); + +BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont); +int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio); + +ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms); +int CMS_is_detached(CMS_ContentInfo *cms); +int CMS_set_detached(CMS_ContentInfo *cms, int detached); + +# ifdef OPENSSL_PEM_H +DECLARE_PEM_rw(CMS, CMS_ContentInfo) +# endif +int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms); +CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms); +int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms); + +BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms); +int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags); +int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, + int flags); +CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont); +CMS_ContentInfo *SMIME_read_CMS_ex(BIO *bio, int flags, BIO **bcont, CMS_ContentInfo **ci); +int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags); + +int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, + unsigned int flags); +int CMS_final_digest(CMS_ContentInfo *cms, + const unsigned char *md, unsigned int mdlen, BIO *dcont, + unsigned int flags); + +CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, + STACK_OF(X509) *certs, BIO *data, + unsigned int flags); +CMS_ContentInfo *CMS_sign_ex(X509 *signcert, EVP_PKEY *pkey, + STACK_OF(X509) *certs, BIO *data, + unsigned int flags, OSSL_LIB_CTX *libctx, + const char *propq); + +CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si, + X509 *signcert, EVP_PKEY *pkey, + STACK_OF(X509) *certs, unsigned int flags); + +int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags); +CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags); +CMS_ContentInfo *CMS_data_create_ex(BIO *in, unsigned int flags, + OSSL_LIB_CTX *libctx, const char *propq); + +int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out, + unsigned int flags); +CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md, + unsigned int flags); +CMS_ContentInfo *CMS_digest_create_ex(BIO *in, const EVP_MD *md, + unsigned int flags, OSSL_LIB_CTX *libctx, + const char *propq); + +int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, + const unsigned char *key, size_t keylen, + BIO *dcont, BIO *out, unsigned int flags); +CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, + const unsigned char *key, + size_t keylen, unsigned int flags); +CMS_ContentInfo *CMS_EncryptedData_encrypt_ex(BIO *in, const EVP_CIPHER *cipher, + const unsigned char *key, + size_t keylen, unsigned int flags, + OSSL_LIB_CTX *libctx, + const char *propq); + +int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph, + const unsigned char *key, size_t keylen); + +int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, + X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags); + +int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms, + STACK_OF(X509) *certs, + X509_STORE *store, unsigned int flags); + +STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms); + +CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in, + const EVP_CIPHER *cipher, unsigned int flags); +CMS_ContentInfo *CMS_encrypt_ex(STACK_OF(X509) *certs, BIO *in, + const EVP_CIPHER *cipher, unsigned int flags, + OSSL_LIB_CTX *libctx, const char *propq); + +int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert, + BIO *dcont, BIO *out, unsigned int flags); + +int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert); +int CMS_decrypt_set1_pkey_and_peer(CMS_ContentInfo *cms, EVP_PKEY *pk, + X509 *cert, X509 *peer); +int CMS_decrypt_set1_key(CMS_ContentInfo *cms, + unsigned char *key, size_t keylen, + const unsigned char *id, size_t idlen); +int CMS_decrypt_set1_password(CMS_ContentInfo *cms, + unsigned char *pass, ossl_ssize_t passlen); + +STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms); +int CMS_RecipientInfo_type(CMS_RecipientInfo *ri); +EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri); +CMS_ContentInfo *CMS_AuthEnvelopedData_create(const EVP_CIPHER *cipher); +CMS_ContentInfo * +CMS_AuthEnvelopedData_create_ex(const EVP_CIPHER *cipher, OSSL_LIB_CTX *libctx, + const char *propq); +CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher); +CMS_ContentInfo *CMS_EnvelopedData_create_ex(const EVP_CIPHER *cipher, + OSSL_LIB_CTX *libctx, + const char *propq); +BIO *CMS_EnvelopedData_decrypt(CMS_EnvelopedData *env, BIO *detached_data, + EVP_PKEY *pkey, X509 *cert, + ASN1_OCTET_STRING *secret, unsigned int flags, + OSSL_LIB_CTX *libctx, const char *propq); + +CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, + X509 *recip, unsigned int flags); +CMS_RecipientInfo *CMS_add1_recipient(CMS_ContentInfo *cms, X509 *recip, + EVP_PKEY *originatorPrivKey, X509 * originator, unsigned int flags); +int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey); +int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert); +int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri, + EVP_PKEY **pk, X509 **recip, + X509_ALGOR **palg); +int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri, + ASN1_OCTET_STRING **keyid, + X509_NAME **issuer, + ASN1_INTEGER **sno); + +CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, + unsigned char *key, size_t keylen, + unsigned char *id, size_t idlen, + ASN1_GENERALIZEDTIME *date, + ASN1_OBJECT *otherTypeId, + ASN1_TYPE *otherType); + +int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, + X509_ALGOR **palg, + ASN1_OCTET_STRING **pid, + ASN1_GENERALIZEDTIME **pdate, + ASN1_OBJECT **potherid, + ASN1_TYPE **pothertype); + +int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, + unsigned char *key, size_t keylen); + +int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, + const unsigned char *id, size_t idlen); + +int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, + unsigned char *pass, + ossl_ssize_t passlen); + +CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, + int iter, int wrap_nid, + int pbe_nid, + unsigned char *pass, + ossl_ssize_t passlen, + const EVP_CIPHER *kekciph); + +int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); +int CMS_RecipientInfo_encrypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri); + +int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, + unsigned int flags); +CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags); + +int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid); +const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms); + +CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms); +int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert); +int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert); +STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms); + +CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms); +int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl); +int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl); +STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms); + +int CMS_SignedData_init(CMS_ContentInfo *cms); +CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, + X509 *signer, EVP_PKEY *pk, const EVP_MD *md, + unsigned int flags); +EVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si); +EVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si); +STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms); + +void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer); +int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si, + ASN1_OCTET_STRING **keyid, + X509_NAME **issuer, ASN1_INTEGER **sno); +int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert); +int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs, + unsigned int flags); +void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk, + X509 **signer, X509_ALGOR **pdig, + X509_ALGOR **psig); +ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si); +int CMS_SignerInfo_sign(CMS_SignerInfo *si); +int CMS_SignerInfo_verify(CMS_SignerInfo *si); +int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain); +BIO *CMS_SignedData_verify(CMS_SignedData *sd, BIO *detached_data, + STACK_OF(X509) *scerts, X509_STORE *store, + STACK_OF(X509) *extra, STACK_OF(X509_CRL) *crls, + unsigned int flags, + OSSL_LIB_CTX *libctx, const char *propq); + +int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs); +int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs, + int algnid, int keysize); +int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap); + +int CMS_signed_get_attr_count(const CMS_SignerInfo *si); +int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, + int lastpos); +int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc); +X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc); +int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr); +int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si, + const ASN1_OBJECT *obj, int type, + const void *bytes, int len); +int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si, + int nid, int type, + const void *bytes, int len); +int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si, + const char *attrname, int type, + const void *bytes, int len); +void *CMS_signed_get0_data_by_OBJ(const CMS_SignerInfo *si, + const ASN1_OBJECT *oid, + int lastpos, int type); + +int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si); +int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid, + int lastpos); +int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, + const ASN1_OBJECT *obj, int lastpos); +X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc); +X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc); +int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr); +int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si, + const ASN1_OBJECT *obj, int type, + const void *bytes, int len); +int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si, + int nid, int type, + const void *bytes, int len); +int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, + const char *attrname, int type, + const void *bytes, int len); +void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, + int lastpos, int type); + +int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr); +CMS_ReceiptRequest *CMS_ReceiptRequest_create0( + unsigned char *id, int idlen, int allorfirst, + STACK_OF(GENERAL_NAMES) *receiptList, + STACK_OF(GENERAL_NAMES) *receiptsTo); +CMS_ReceiptRequest *CMS_ReceiptRequest_create0_ex( + unsigned char *id, int idlen, int allorfirst, + STACK_OF(GENERAL_NAMES) *receiptList, + STACK_OF(GENERAL_NAMES) *receiptsTo, + OSSL_LIB_CTX *libctx); + +int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr); +void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, + ASN1_STRING **pcid, + int *pallorfirst, + STACK_OF(GENERAL_NAMES) **plist, + STACK_OF(GENERAL_NAMES) **prto); +int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri, + X509_ALGOR **palg, + ASN1_OCTET_STRING **pukm); +STACK_OF(CMS_RecipientEncryptedKey) +*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri); + +int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri, + X509_ALGOR **pubalg, + ASN1_BIT_STRING **pubkey, + ASN1_OCTET_STRING **keyid, + X509_NAME **issuer, + ASN1_INTEGER **sno); + +int CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert); + +int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek, + ASN1_OCTET_STRING **keyid, + ASN1_GENERALIZEDTIME **tm, + CMS_OtherKeyAttribute **other, + X509_NAME **issuer, ASN1_INTEGER **sno); +int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek, + X509 *cert); +int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk); +int CMS_RecipientInfo_kari_set0_pkey_and_peer(CMS_RecipientInfo *ri, EVP_PKEY *pk, X509 *peer); +EVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri); +int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms, + CMS_RecipientInfo *ri, + CMS_RecipientEncryptedKey *rek); + +int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg, + ASN1_OCTET_STRING *ukm, int keylen); + +/* Backward compatibility for spelling errors. */ +# define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM +# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE \ + CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE + +# ifdef __cplusplus +} +# endif +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/cmserr.h b/illumos-x86_64/usr/include/openssl-3/cmserr.h new file mode 100644 index 00000000..5cfe07db --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cmserr.h @@ -0,0 +1,126 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CMSERR_H +# define OPENSSL_CMSERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_CMS + + +/* + * CMS reason codes. + */ +# define CMS_R_ADD_SIGNER_ERROR 99 +# define CMS_R_ATTRIBUTE_ERROR 161 +# define CMS_R_CERTIFICATE_ALREADY_PRESENT 175 +# define CMS_R_CERTIFICATE_HAS_NO_KEYID 160 +# define CMS_R_CERTIFICATE_VERIFY_ERROR 100 +# define CMS_R_CIPHER_AEAD_SET_TAG_ERROR 184 +# define CMS_R_CIPHER_GET_TAG 185 +# define CMS_R_CIPHER_INITIALISATION_ERROR 101 +# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR 102 +# define CMS_R_CMS_DATAFINAL_ERROR 103 +# define CMS_R_CMS_LIB 104 +# define CMS_R_CONTENTIDENTIFIER_MISMATCH 170 +# define CMS_R_CONTENT_NOT_FOUND 105 +# define CMS_R_CONTENT_TYPE_MISMATCH 171 +# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA 106 +# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA 107 +# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108 +# define CMS_R_CONTENT_VERIFY_ERROR 109 +# define CMS_R_CTRL_ERROR 110 +# define CMS_R_CTRL_FAILURE 111 +# define CMS_R_DECODE_ERROR 187 +# define CMS_R_DECRYPT_ERROR 112 +# define CMS_R_ERROR_GETTING_PUBLIC_KEY 113 +# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114 +# define CMS_R_ERROR_SETTING_KEY 115 +# define CMS_R_ERROR_SETTING_RECIPIENTINFO 116 +# define CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT 196 +# define CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR 183 +# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117 +# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176 +# define CMS_R_INVALID_KEY_LENGTH 118 +# define CMS_R_INVALID_LABEL 190 +# define CMS_R_INVALID_OAEP_PARAMETERS 191 +# define CMS_R_KDF_PARAMETER_ERROR 186 +# define CMS_R_MD_BIO_INIT_ERROR 119 +# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120 +# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121 +# define CMS_R_MSGSIGDIGEST_ERROR 172 +# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162 +# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163 +# define CMS_R_NEED_ONE_SIGNER 164 +# define CMS_R_NOT_A_SIGNED_RECEIPT 165 +# define CMS_R_NOT_ENCRYPTED_DATA 122 +# define CMS_R_NOT_KEK 123 +# define CMS_R_NOT_KEY_AGREEMENT 181 +# define CMS_R_NOT_KEY_TRANSPORT 124 +# define CMS_R_NOT_PWRI 177 +# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125 +# define CMS_R_NO_CIPHER 126 +# define CMS_R_NO_CONTENT 127 +# define CMS_R_NO_CONTENT_TYPE 173 +# define CMS_R_NO_DEFAULT_DIGEST 128 +# define CMS_R_NO_DIGEST_SET 129 +# define CMS_R_NO_KEY 130 +# define CMS_R_NO_KEY_OR_CERT 174 +# define CMS_R_NO_MATCHING_DIGEST 131 +# define CMS_R_NO_MATCHING_RECIPIENT 132 +# define CMS_R_NO_MATCHING_SIGNATURE 166 +# define CMS_R_NO_MSGSIGDIGEST 167 +# define CMS_R_NO_PASSWORD 178 +# define CMS_R_NO_PRIVATE_KEY 133 +# define CMS_R_NO_PUBLIC_KEY 134 +# define CMS_R_NO_RECEIPT_REQUEST 168 +# define CMS_R_NO_SIGNERS 135 +# define CMS_R_OPERATION_UNSUPPORTED 182 +# define CMS_R_PEER_KEY_ERROR 188 +# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 136 +# define CMS_R_RECEIPT_DECODE_ERROR 169 +# define CMS_R_RECIPIENT_ERROR 137 +# define CMS_R_SHARED_INFO_ERROR 189 +# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND 138 +# define CMS_R_SIGNFINAL_ERROR 139 +# define CMS_R_SMIME_TEXT_ERROR 140 +# define CMS_R_STORE_INIT_ERROR 141 +# define CMS_R_TYPE_NOT_COMPRESSED_DATA 142 +# define CMS_R_TYPE_NOT_DATA 143 +# define CMS_R_TYPE_NOT_DIGESTED_DATA 144 +# define CMS_R_TYPE_NOT_ENCRYPTED_DATA 145 +# define CMS_R_TYPE_NOT_ENVELOPED_DATA 146 +# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT 147 +# define CMS_R_UNKNOWN_CIPHER 148 +# define CMS_R_UNKNOWN_DIGEST_ALGORITHM 149 +# define CMS_R_UNKNOWN_ID 150 +# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM 151 +# define CMS_R_UNSUPPORTED_CONTENT_ENCRYPTION_ALGORITHM 194 +# define CMS_R_UNSUPPORTED_CONTENT_TYPE 152 +# define CMS_R_UNSUPPORTED_ENCRYPTION_TYPE 192 +# define CMS_R_UNSUPPORTED_KEK_ALGORITHM 153 +# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM 179 +# define CMS_R_UNSUPPORTED_LABEL_SOURCE 193 +# define CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE 155 +# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE 154 +# define CMS_R_UNSUPPORTED_SIGNATURE_ALGORITHM 195 +# define CMS_R_UNSUPPORTED_TYPE 156 +# define CMS_R_UNWRAP_ERROR 157 +# define CMS_R_UNWRAP_FAILURE 180 +# define CMS_R_VERIFICATION_FAILURE 158 +# define CMS_R_WRAP_ERROR 159 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/comp.h b/illumos-x86_64/usr/include/openssl-3/comp.h new file mode 100644 index 00000000..90e39511 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/comp.h @@ -0,0 +1,98 @@ +/* + * Copyright 2015-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_COMP_H +# define OPENSSL_COMP_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_COMP_H +# endif + +# include + +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + + + +# ifndef OPENSSL_NO_COMP + +COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); +const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx); +int COMP_CTX_get_type(const COMP_CTX* comp); +int COMP_get_type(const COMP_METHOD *meth); +const char *COMP_get_name(const COMP_METHOD *meth); +void COMP_CTX_free(COMP_CTX *ctx); + +int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); + +COMP_METHOD *COMP_zlib(void); +COMP_METHOD *COMP_zlib_oneshot(void); +COMP_METHOD *COMP_brotli(void); +COMP_METHOD *COMP_brotli_oneshot(void); +COMP_METHOD *COMP_zstd(void); +COMP_METHOD *COMP_zstd_oneshot(void); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define COMP_zlib_cleanup() while(0) continue +# endif + +# ifdef OPENSSL_BIO_H +const BIO_METHOD *BIO_f_zlib(void); +const BIO_METHOD *BIO_f_brotli(void); +const BIO_METHOD *BIO_f_zstd(void); +# endif + +# endif + +typedef struct ssl_comp_st SSL_COMP; + +SKM_DEFINE_STACK_OF_INTERNAL(SSL_COMP, SSL_COMP, SSL_COMP) +#define sk_SSL_COMP_num(sk) OPENSSL_sk_num(ossl_check_const_SSL_COMP_sk_type(sk)) +#define sk_SSL_COMP_value(sk, idx) ((SSL_COMP *)OPENSSL_sk_value(ossl_check_const_SSL_COMP_sk_type(sk), (idx))) +#define sk_SSL_COMP_new(cmp) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new(ossl_check_SSL_COMP_compfunc_type(cmp))) +#define sk_SSL_COMP_new_null() ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_null()) +#define sk_SSL_COMP_new_reserve(cmp, n) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_reserve(ossl_check_SSL_COMP_compfunc_type(cmp), (n))) +#define sk_SSL_COMP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SSL_COMP_sk_type(sk), (n)) +#define sk_SSL_COMP_free(sk) OPENSSL_sk_free(ossl_check_SSL_COMP_sk_type(sk)) +#define sk_SSL_COMP_zero(sk) OPENSSL_sk_zero(ossl_check_SSL_COMP_sk_type(sk)) +#define sk_SSL_COMP_delete(sk, i) ((SSL_COMP *)OPENSSL_sk_delete(ossl_check_SSL_COMP_sk_type(sk), (i))) +#define sk_SSL_COMP_delete_ptr(sk, ptr) ((SSL_COMP *)OPENSSL_sk_delete_ptr(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))) +#define sk_SSL_COMP_push(sk, ptr) OPENSSL_sk_push(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)) +#define sk_SSL_COMP_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)) +#define sk_SSL_COMP_pop(sk) ((SSL_COMP *)OPENSSL_sk_pop(ossl_check_SSL_COMP_sk_type(sk))) +#define sk_SSL_COMP_shift(sk) ((SSL_COMP *)OPENSSL_sk_shift(ossl_check_SSL_COMP_sk_type(sk))) +#define sk_SSL_COMP_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SSL_COMP_sk_type(sk),ossl_check_SSL_COMP_freefunc_type(freefunc)) +#define sk_SSL_COMP_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr), (idx)) +#define sk_SSL_COMP_set(sk, idx, ptr) ((SSL_COMP *)OPENSSL_sk_set(ossl_check_SSL_COMP_sk_type(sk), (idx), ossl_check_SSL_COMP_type(ptr))) +#define sk_SSL_COMP_find(sk, ptr) OPENSSL_sk_find(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)) +#define sk_SSL_COMP_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)) +#define sk_SSL_COMP_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr), pnum) +#define sk_SSL_COMP_sort(sk) OPENSSL_sk_sort(ossl_check_SSL_COMP_sk_type(sk)) +#define sk_SSL_COMP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SSL_COMP_sk_type(sk)) +#define sk_SSL_COMP_dup(sk) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_dup(ossl_check_const_SSL_COMP_sk_type(sk))) +#define sk_SSL_COMP_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_deep_copy(ossl_check_const_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_copyfunc_type(copyfunc), ossl_check_SSL_COMP_freefunc_type(freefunc))) +#define sk_SSL_COMP_set_cmp_func(sk, cmp) ((sk_SSL_COMP_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_compfunc_type(cmp))) + + + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/comperr.h b/illumos-x86_64/usr/include/openssl-3/comperr.h new file mode 100644 index 00000000..1948d37f --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/comperr.h @@ -0,0 +1,38 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_COMPERR_H +# define OPENSSL_COMPERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_COMP + + +/* + * COMP reason codes. + */ +# define COMP_R_BROTLI_DECODE_ERROR 102 +# define COMP_R_BROTLI_ENCODE_ERROR 103 +# define COMP_R_BROTLI_NOT_SUPPORTED 104 +# define COMP_R_ZLIB_DEFLATE_ERROR 99 +# define COMP_R_ZLIB_INFLATE_ERROR 100 +# define COMP_R_ZLIB_NOT_SUPPORTED 101 +# define COMP_R_ZSTD_COMPRESS_ERROR 105 +# define COMP_R_ZSTD_DECODE_ERROR 106 +# define COMP_R_ZSTD_DECOMPRESS_ERROR 107 +# define COMP_R_ZSTD_NOT_SUPPORTED 108 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/conf.h b/illumos-x86_64/usr/include/openssl-3/conf.h new file mode 100644 index 00000000..38576290 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/conf.h @@ -0,0 +1,214 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/conf.h.in + * + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_CONF_H +# define OPENSSL_CONF_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_CONF_H +# endif + +# include +# include +# include +# include +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + char *section; + char *name; + char *value; +} CONF_VALUE; + +SKM_DEFINE_STACK_OF_INTERNAL(CONF_VALUE, CONF_VALUE, CONF_VALUE) +#define sk_CONF_VALUE_num(sk) OPENSSL_sk_num(ossl_check_const_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_value(sk, idx) ((CONF_VALUE *)OPENSSL_sk_value(ossl_check_const_CONF_VALUE_sk_type(sk), (idx))) +#define sk_CONF_VALUE_new(cmp) ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_new(ossl_check_CONF_VALUE_compfunc_type(cmp))) +#define sk_CONF_VALUE_new_null() ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_new_null()) +#define sk_CONF_VALUE_new_reserve(cmp, n) ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_new_reserve(ossl_check_CONF_VALUE_compfunc_type(cmp), (n))) +#define sk_CONF_VALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CONF_VALUE_sk_type(sk), (n)) +#define sk_CONF_VALUE_free(sk) OPENSSL_sk_free(ossl_check_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_zero(sk) OPENSSL_sk_zero(ossl_check_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_delete(sk, i) ((CONF_VALUE *)OPENSSL_sk_delete(ossl_check_CONF_VALUE_sk_type(sk), (i))) +#define sk_CONF_VALUE_delete_ptr(sk, ptr) ((CONF_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr))) +#define sk_CONF_VALUE_push(sk, ptr) OPENSSL_sk_push(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr)) +#define sk_CONF_VALUE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr)) +#define sk_CONF_VALUE_pop(sk) ((CONF_VALUE *)OPENSSL_sk_pop(ossl_check_CONF_VALUE_sk_type(sk))) +#define sk_CONF_VALUE_shift(sk) ((CONF_VALUE *)OPENSSL_sk_shift(ossl_check_CONF_VALUE_sk_type(sk))) +#define sk_CONF_VALUE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_CONF_VALUE_sk_type(sk),ossl_check_CONF_VALUE_freefunc_type(freefunc)) +#define sk_CONF_VALUE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr), (idx)) +#define sk_CONF_VALUE_set(sk, idx, ptr) ((CONF_VALUE *)OPENSSL_sk_set(ossl_check_CONF_VALUE_sk_type(sk), (idx), ossl_check_CONF_VALUE_type(ptr))) +#define sk_CONF_VALUE_find(sk, ptr) OPENSSL_sk_find(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr)) +#define sk_CONF_VALUE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr)) +#define sk_CONF_VALUE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr), pnum) +#define sk_CONF_VALUE_sort(sk) OPENSSL_sk_sort(ossl_check_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_dup(sk) ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_dup(ossl_check_const_CONF_VALUE_sk_type(sk))) +#define sk_CONF_VALUE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_deep_copy(ossl_check_const_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_copyfunc_type(copyfunc), ossl_check_CONF_VALUE_freefunc_type(freefunc))) +#define sk_CONF_VALUE_set_cmp_func(sk, cmp) ((sk_CONF_VALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_compfunc_type(cmp))) +DEFINE_LHASH_OF_INTERNAL(CONF_VALUE); +#define lh_CONF_VALUE_new(hfn, cmp) ((LHASH_OF(CONF_VALUE) *)OPENSSL_LH_set_thunks(OPENSSL_LH_new(ossl_check_CONF_VALUE_lh_hashfunc_type(hfn), ossl_check_CONF_VALUE_lh_compfunc_type(cmp)), lh_CONF_VALUE_hash_thunk, lh_CONF_VALUE_comp_thunk, lh_CONF_VALUE_doall_thunk, lh_CONF_VALUE_doall_arg_thunk)) +#define lh_CONF_VALUE_free(lh) OPENSSL_LH_free(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_flush(lh) OPENSSL_LH_flush(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_insert(lh, ptr) ((CONF_VALUE *)OPENSSL_LH_insert(ossl_check_CONF_VALUE_lh_type(lh), ossl_check_CONF_VALUE_lh_plain_type(ptr))) +#define lh_CONF_VALUE_delete(lh, ptr) ((CONF_VALUE *)OPENSSL_LH_delete(ossl_check_CONF_VALUE_lh_type(lh), ossl_check_const_CONF_VALUE_lh_plain_type(ptr))) +#define lh_CONF_VALUE_retrieve(lh, ptr) ((CONF_VALUE *)OPENSSL_LH_retrieve(ossl_check_CONF_VALUE_lh_type(lh), ossl_check_const_CONF_VALUE_lh_plain_type(ptr))) +#define lh_CONF_VALUE_error(lh) OPENSSL_LH_error(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_num_items(lh) OPENSSL_LH_num_items(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_node_stats_bio(lh, out) OPENSSL_LH_node_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) +#define lh_CONF_VALUE_node_usage_stats_bio(lh, out) OPENSSL_LH_node_usage_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) +#define lh_CONF_VALUE_stats_bio(lh, out) OPENSSL_LH_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) +#define lh_CONF_VALUE_get_down_load(lh) OPENSSL_LH_get_down_load(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_set_down_load(lh, dl) OPENSSL_LH_set_down_load(ossl_check_CONF_VALUE_lh_type(lh), dl) +#define lh_CONF_VALUE_doall(lh, dfn) OPENSSL_LH_doall(ossl_check_CONF_VALUE_lh_type(lh), ossl_check_CONF_VALUE_lh_doallfunc_type(dfn)) + + +struct conf_st; +struct conf_method_st; +typedef struct conf_method_st CONF_METHOD; + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# include +# endif + +/* Module definitions */ +typedef struct conf_imodule_st CONF_IMODULE; +typedef struct conf_module_st CONF_MODULE; + +STACK_OF(CONF_MODULE); +STACK_OF(CONF_IMODULE); + +/* DSO module function typedefs */ +typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); +typedef void conf_finish_func (CONF_IMODULE *md); + +# define CONF_MFLAGS_IGNORE_ERRORS 0x1 +# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 +# define CONF_MFLAGS_SILENT 0x4 +# define CONF_MFLAGS_NO_DSO 0x8 +# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 +# define CONF_MFLAGS_DEFAULT_SECTION 0x20 + +int CONF_set_default_method(CONF_METHOD *meth); +void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); +LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, + long *eline); +# ifndef OPENSSL_NO_STDIO +LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, + long *eline); +# endif +LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, + long *eline); +STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, + const char *section); +char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, + const char *name); +long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, + const char *name); +void CONF_free(LHASH_OF(CONF_VALUE) *conf); +#ifndef OPENSSL_NO_STDIO +int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); +#endif +int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 void OPENSSL_config(const char *config_name); +#endif + +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define OPENSSL_no_config() \ + OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) +#endif + +/* + * New conf code. The semantics are different from the functions above. If + * that wasn't the case, the above functions would have been replaced + */ + +CONF *NCONF_new_ex(OSSL_LIB_CTX *libctx, CONF_METHOD *meth); +OSSL_LIB_CTX *NCONF_get0_libctx(const CONF *conf); +CONF *NCONF_new(CONF_METHOD *meth); +CONF_METHOD *NCONF_default(void); +#ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 CONF_METHOD *NCONF_WIN32(void); +#endif +void NCONF_free(CONF *conf); +void NCONF_free_data(CONF *conf); + +int NCONF_load(CONF *conf, const char *file, long *eline); +# ifndef OPENSSL_NO_STDIO +int NCONF_load_fp(CONF *conf, FILE *fp, long *eline); +# endif +int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); +STACK_OF(OPENSSL_CSTRING) *NCONF_get_section_names(const CONF *conf); +STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, + const char *section); +char *NCONF_get_string(const CONF *conf, const char *group, const char *name); +int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, + long *result); +#ifndef OPENSSL_NO_STDIO +int NCONF_dump_fp(const CONF *conf, FILE *out); +#endif +int NCONF_dump_bio(const CONF *conf, BIO *out); + +#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) + +/* Module functions */ + +int CONF_modules_load(const CONF *cnf, const char *appname, + unsigned long flags); +int CONF_modules_load_file_ex(OSSL_LIB_CTX *libctx, const char *filename, + const char *appname, unsigned long flags); +int CONF_modules_load_file(const char *filename, const char *appname, + unsigned long flags); +void CONF_modules_unload(int all); +void CONF_modules_finish(void); +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define CONF_modules_free() while(0) continue +#endif +int CONF_module_add(const char *name, conf_init_func *ifunc, + conf_finish_func *ffunc); + +const char *CONF_imodule_get_name(const CONF_IMODULE *md); +const char *CONF_imodule_get_value(const CONF_IMODULE *md); +void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); +void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); +CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); +unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); +void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); +void *CONF_module_get_usr_data(CONF_MODULE *pmod); +void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); + +char *CONF_get1_default_config_file(void); + +int CONF_parse_list(const char *list, int sep, int nospc, + int (*list_cb) (const char *elem, int len, void *usr), + void *arg); + +void OPENSSL_load_builtin_modules(void); + + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/conf_api.h b/illumos-x86_64/usr/include/openssl-3/conf_api.h new file mode 100644 index 00000000..ed67d577 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/conf_api.h @@ -0,0 +1,46 @@ +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CONF_API_H +# define OPENSSL_CONF_API_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_CONF_API_H +# endif + +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Up until OpenSSL 0.9.5a, this was new_section */ +CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was get_section */ +CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ +STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, + const char *section); + +int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); +char *_CONF_get_string(const CONF *conf, const char *section, + const char *name); +long _CONF_get_number(const CONF *conf, const char *section, + const char *name); + +int _CONF_new_data(CONF *conf); +void _CONF_free_data(CONF *conf); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/conferr.h b/illumos-x86_64/usr/include/openssl-3/conferr.h new file mode 100644 index 00000000..a8798e79 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/conferr.h @@ -0,0 +1,52 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CONFERR_H +# define OPENSSL_CONFERR_H +# pragma once + +# include +# include +# include + + + +/* + * CONF reason codes. + */ +# define CONF_R_ERROR_LOADING_DSO 110 +# define CONF_R_INVALID_PRAGMA 122 +# define CONF_R_LIST_CANNOT_BE_NULL 115 +# define CONF_R_MANDATORY_BRACES_IN_VARIABLE_EXPANSION 123 +# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 +# define CONF_R_MISSING_EQUAL_SIGN 101 +# define CONF_R_MISSING_INIT_FUNCTION 112 +# define CONF_R_MODULE_INITIALIZATION_ERROR 109 +# define CONF_R_NO_CLOSE_BRACE 102 +# define CONF_R_NO_CONF 105 +# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 +# define CONF_R_NO_SECTION 107 +# define CONF_R_NO_SUCH_FILE 114 +# define CONF_R_NO_VALUE 108 +# define CONF_R_NUMBER_TOO_LARGE 121 +# define CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION 124 +# define CONF_R_RECURSIVE_DIRECTORY_INCLUDE 111 +# define CONF_R_RECURSIVE_SECTION_REFERENCE 126 +# define CONF_R_RELATIVE_PATH 125 +# define CONF_R_SSL_COMMAND_SECTION_EMPTY 117 +# define CONF_R_SSL_COMMAND_SECTION_NOT_FOUND 118 +# define CONF_R_SSL_SECTION_EMPTY 119 +# define CONF_R_SSL_SECTION_NOT_FOUND 120 +# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 +# define CONF_R_UNKNOWN_MODULE_NAME 113 +# define CONF_R_VARIABLE_EXPANSION_TOO_LONG 116 +# define CONF_R_VARIABLE_HAS_NO_VALUE 104 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/configuration.h b/illumos-x86_64/usr/include/openssl-3/configuration.h new file mode 100644 index 00000000..3f18f870 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/configuration.h @@ -0,0 +1,199 @@ +/* + * WARNING: do not edit! + * Generated by configdata.pm from Configurations/common0.tmpl, Configurations/unix-Makefile.tmpl + * via Makefile.in + * + * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CONFIGURATION_H +# define OPENSSL_CONFIGURATION_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +# ifdef OPENSSL_ALGORITHM_DEFINES +# error OPENSSL_ALGORITHM_DEFINES no longer supported +# endif + +/* + * OpenSSL was configured with the following options: + */ + +# define OPENSSL_CONFIGURED_API 30500 +# ifndef OPENSSL_RAND_SEED_OS +# define OPENSSL_RAND_SEED_OS +# endif +# ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +# endif +# ifndef OPENSSL_NO_ACVP_TESTS +# define OPENSSL_NO_ACVP_TESTS +# endif +# ifndef OPENSSL_NO_AFALGENG +# define OPENSSL_NO_AFALGENG +# endif +# ifndef OPENSSL_NO_ASAN +# define OPENSSL_NO_ASAN +# endif +# ifndef OPENSSL_NO_BROTLI +# define OPENSSL_NO_BROTLI +# endif +# ifndef OPENSSL_NO_BROTLI_DYNAMIC +# define OPENSSL_NO_BROTLI_DYNAMIC +# endif +# ifndef OPENSSL_NO_CRYPTO_MDEBUG +# define OPENSSL_NO_CRYPTO_MDEBUG +# endif +# ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE +# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE +# endif +# ifndef OPENSSL_NO_DEMOS +# define OPENSSL_NO_DEMOS +# endif +# ifndef OPENSSL_NO_DEVCRYPTOENG +# define OPENSSL_NO_DEVCRYPTOENG +# endif +#ifndef __x86_64 +# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +# define OPENSSL_NO_EC_NISTP_64_GCC_128 +# endif +#endif /* __x86_64 */ +# ifndef OPENSSL_NO_EGD +# define OPENSSL_NO_EGD +# endif +# ifndef OPENSSL_NO_EXTERNAL_TESTS +# define OPENSSL_NO_EXTERNAL_TESTS +# endif +# ifndef OPENSSL_NO_FIPS_JITTER +# define OPENSSL_NO_FIPS_JITTER +# endif +# ifndef OPENSSL_NO_FIPS_POST +# define OPENSSL_NO_FIPS_POST +# endif +# ifndef OPENSSL_NO_FIPS_SECURITYCHECKS +# define OPENSSL_NO_FIPS_SECURITYCHECKS +# endif +# ifndef OPENSSL_NO_FUZZ_AFL +# define OPENSSL_NO_FUZZ_AFL +# endif +# ifndef OPENSSL_NO_FUZZ_LIBFUZZER +# define OPENSSL_NO_FUZZ_LIBFUZZER +# endif +# ifndef OPENSSL_NO_H3DEMO +# define OPENSSL_NO_H3DEMO +# endif +# ifndef OPENSSL_NO_HQINTEROP +# define OPENSSL_NO_HQINTEROP +# endif +# ifndef OPENSSL_NO_JITTER +# define OPENSSL_NO_JITTER +# endif +# ifndef OPENSSL_NO_KTLS +# define OPENSSL_NO_KTLS +# endif +# ifndef OPENSSL_NO_MD2 +# define OPENSSL_NO_MD2 +# endif +# ifndef OPENSSL_NO_MSAN +# define OPENSSL_NO_MSAN +# endif +# ifndef OPENSSL_NO_PIE +# define OPENSSL_NO_PIE +# endif +# ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +# endif +# ifndef OPENSSL_NO_SCTP +# define OPENSSL_NO_SCTP +# endif +# ifndef OPENSSL_NO_SSL3 +# define OPENSSL_NO_SSL3 +# endif +# ifndef OPENSSL_NO_SSL3_METHOD +# define OPENSSL_NO_SSL3_METHOD +# endif +# ifndef OPENSSL_NO_SSLKEYLOG +# define OPENSSL_NO_SSLKEYLOG +# endif +# ifndef OPENSSL_NO_TFO +# define OPENSSL_NO_TFO +# endif +# ifndef OPENSSL_NO_TRACE +# define OPENSSL_NO_TRACE +# endif +# ifndef OPENSSL_NO_UBSAN +# define OPENSSL_NO_UBSAN +# endif +# ifndef OPENSSL_NO_UNIT_TEST +# define OPENSSL_NO_UNIT_TEST +# endif +# ifndef OPENSSL_NO_UPLINK +# define OPENSSL_NO_UPLINK +# endif +# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +# endif +# ifndef OPENSSL_NO_WINSTORE +# define OPENSSL_NO_WINSTORE +# endif +# ifndef OPENSSL_NO_ZLIB_DYNAMIC +# define OPENSSL_NO_ZLIB_DYNAMIC +# endif +# ifndef OPENSSL_NO_ZSTD +# define OPENSSL_NO_ZSTD +# endif +# ifndef OPENSSL_NO_ZSTD_DYNAMIC +# define OPENSSL_NO_ZSTD_DYNAMIC +# endif +# ifndef OPENSSL_NO_STATIC_ENGINE +# define OPENSSL_NO_STATIC_ENGINE +# endif + + +/* Generate 80386 code? */ +# undef I386_ONLY + +/* + * The following are cipher-specific, but are part of the public API. + */ +# if !defined(OPENSSL_SYS_UEFI) +#ifndef __x86_64 +# define BN_LLONG +#else /* __x86_64 */ +# undef BN_LLONG +#endif /* __x86_64 */ +/* Only one for the following should be defined */ +#ifndef __x86_64 +# undef SIXTY_FOUR_BIT_LONG +#else /* __x86_64 */ +# define SIXTY_FOUR_BIT_LONG +#endif /* __x86_64 */ +# undef SIXTY_FOUR_BIT +#ifndef __x86_64 +# define THIRTY_TWO_BIT +#else /* __x86_64 */ +# undef THIRTY_TWO_BIT +#endif /* __x86_64 */ +# endif + +# define RC4_INT unsigned int + +# if defined(OPENSSL_NO_COMP) || (defined(OPENSSL_NO_BROTLI) && defined(OPENSSL_NO_ZSTD) && defined(OPENSSL_NO_ZLIB)) +# define OPENSSL_NO_COMP_ALG +# else +# undef OPENSSL_NO_COMP_ALG +# endif + +# ifdef __cplusplus +} +# endif + +#endif /* OPENSSL_CONFIGURATION_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/configuration.h.amd64 b/illumos-x86_64/usr/include/openssl-3/configuration.h.amd64 new file mode 100644 index 00000000..ca9a9e45 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/configuration.h.amd64 @@ -0,0 +1,182 @@ +/* + * WARNING: do not edit! + * Generated by configdata.pm from Configurations/common0.tmpl, Configurations/unix-Makefile.tmpl + * via Makefile.in + * + * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CONFIGURATION_H +# define OPENSSL_CONFIGURATION_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +# ifdef OPENSSL_ALGORITHM_DEFINES +# error OPENSSL_ALGORITHM_DEFINES no longer supported +# endif + +/* + * OpenSSL was configured with the following options: + */ + +# define OPENSSL_CONFIGURED_API 30500 +# ifndef OPENSSL_RAND_SEED_OS +# define OPENSSL_RAND_SEED_OS +# endif +# ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +# endif +# ifndef OPENSSL_NO_ACVP_TESTS +# define OPENSSL_NO_ACVP_TESTS +# endif +# ifndef OPENSSL_NO_AFALGENG +# define OPENSSL_NO_AFALGENG +# endif +# ifndef OPENSSL_NO_ASAN +# define OPENSSL_NO_ASAN +# endif +# ifndef OPENSSL_NO_BROTLI +# define OPENSSL_NO_BROTLI +# endif +# ifndef OPENSSL_NO_BROTLI_DYNAMIC +# define OPENSSL_NO_BROTLI_DYNAMIC +# endif +# ifndef OPENSSL_NO_CRYPTO_MDEBUG +# define OPENSSL_NO_CRYPTO_MDEBUG +# endif +# ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE +# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE +# endif +# ifndef OPENSSL_NO_DEMOS +# define OPENSSL_NO_DEMOS +# endif +# ifndef OPENSSL_NO_DEVCRYPTOENG +# define OPENSSL_NO_DEVCRYPTOENG +# endif +# ifndef OPENSSL_NO_EGD +# define OPENSSL_NO_EGD +# endif +# ifndef OPENSSL_NO_EXTERNAL_TESTS +# define OPENSSL_NO_EXTERNAL_TESTS +# endif +# ifndef OPENSSL_NO_FIPS_JITTER +# define OPENSSL_NO_FIPS_JITTER +# endif +# ifndef OPENSSL_NO_FIPS_POST +# define OPENSSL_NO_FIPS_POST +# endif +# ifndef OPENSSL_NO_FIPS_SECURITYCHECKS +# define OPENSSL_NO_FIPS_SECURITYCHECKS +# endif +# ifndef OPENSSL_NO_FUZZ_AFL +# define OPENSSL_NO_FUZZ_AFL +# endif +# ifndef OPENSSL_NO_FUZZ_LIBFUZZER +# define OPENSSL_NO_FUZZ_LIBFUZZER +# endif +# ifndef OPENSSL_NO_H3DEMO +# define OPENSSL_NO_H3DEMO +# endif +# ifndef OPENSSL_NO_HQINTEROP +# define OPENSSL_NO_HQINTEROP +# endif +# ifndef OPENSSL_NO_JITTER +# define OPENSSL_NO_JITTER +# endif +# ifndef OPENSSL_NO_KTLS +# define OPENSSL_NO_KTLS +# endif +# ifndef OPENSSL_NO_MD2 +# define OPENSSL_NO_MD2 +# endif +# ifndef OPENSSL_NO_MSAN +# define OPENSSL_NO_MSAN +# endif +# ifndef OPENSSL_NO_PIE +# define OPENSSL_NO_PIE +# endif +# ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +# endif +# ifndef OPENSSL_NO_SCTP +# define OPENSSL_NO_SCTP +# endif +# ifndef OPENSSL_NO_SSL3 +# define OPENSSL_NO_SSL3 +# endif +# ifndef OPENSSL_NO_SSL3_METHOD +# define OPENSSL_NO_SSL3_METHOD +# endif +# ifndef OPENSSL_NO_SSLKEYLOG +# define OPENSSL_NO_SSLKEYLOG +# endif +# ifndef OPENSSL_NO_TFO +# define OPENSSL_NO_TFO +# endif +# ifndef OPENSSL_NO_TRACE +# define OPENSSL_NO_TRACE +# endif +# ifndef OPENSSL_NO_UBSAN +# define OPENSSL_NO_UBSAN +# endif +# ifndef OPENSSL_NO_UNIT_TEST +# define OPENSSL_NO_UNIT_TEST +# endif +# ifndef OPENSSL_NO_UPLINK +# define OPENSSL_NO_UPLINK +# endif +# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +# endif +# ifndef OPENSSL_NO_WINSTORE +# define OPENSSL_NO_WINSTORE +# endif +# ifndef OPENSSL_NO_ZLIB_DYNAMIC +# define OPENSSL_NO_ZLIB_DYNAMIC +# endif +# ifndef OPENSSL_NO_ZSTD +# define OPENSSL_NO_ZSTD +# endif +# ifndef OPENSSL_NO_ZSTD_DYNAMIC +# define OPENSSL_NO_ZSTD_DYNAMIC +# endif +# ifndef OPENSSL_NO_STATIC_ENGINE +# define OPENSSL_NO_STATIC_ENGINE +# endif + + +/* Generate 80386 code? */ +# undef I386_ONLY + +/* + * The following are cipher-specific, but are part of the public API. + */ +# if !defined(OPENSSL_SYS_UEFI) +# undef BN_LLONG +/* Only one for the following should be defined */ +# define SIXTY_FOUR_BIT_LONG +# undef SIXTY_FOUR_BIT +# undef THIRTY_TWO_BIT +# endif + +# define RC4_INT unsigned int + +# if defined(OPENSSL_NO_COMP) || (defined(OPENSSL_NO_BROTLI) && defined(OPENSSL_NO_ZSTD) && defined(OPENSSL_NO_ZLIB)) +# define OPENSSL_NO_COMP_ALG +# else +# undef OPENSSL_NO_COMP_ALG +# endif + +# ifdef __cplusplus +} +# endif + +#endif /* OPENSSL_CONFIGURATION_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/configuration.h.i386 b/illumos-x86_64/usr/include/openssl-3/configuration.h.i386 new file mode 100644 index 00000000..4675cee0 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/configuration.h.i386 @@ -0,0 +1,185 @@ +/* + * WARNING: do not edit! + * Generated by configdata.pm from Configurations/common0.tmpl, Configurations/unix-Makefile.tmpl + * via Makefile.in + * + * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CONFIGURATION_H +# define OPENSSL_CONFIGURATION_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +# ifdef OPENSSL_ALGORITHM_DEFINES +# error OPENSSL_ALGORITHM_DEFINES no longer supported +# endif + +/* + * OpenSSL was configured with the following options: + */ + +# define OPENSSL_CONFIGURED_API 30500 +# ifndef OPENSSL_RAND_SEED_OS +# define OPENSSL_RAND_SEED_OS +# endif +# ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +# endif +# ifndef OPENSSL_NO_ACVP_TESTS +# define OPENSSL_NO_ACVP_TESTS +# endif +# ifndef OPENSSL_NO_AFALGENG +# define OPENSSL_NO_AFALGENG +# endif +# ifndef OPENSSL_NO_ASAN +# define OPENSSL_NO_ASAN +# endif +# ifndef OPENSSL_NO_BROTLI +# define OPENSSL_NO_BROTLI +# endif +# ifndef OPENSSL_NO_BROTLI_DYNAMIC +# define OPENSSL_NO_BROTLI_DYNAMIC +# endif +# ifndef OPENSSL_NO_CRYPTO_MDEBUG +# define OPENSSL_NO_CRYPTO_MDEBUG +# endif +# ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE +# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE +# endif +# ifndef OPENSSL_NO_DEMOS +# define OPENSSL_NO_DEMOS +# endif +# ifndef OPENSSL_NO_DEVCRYPTOENG +# define OPENSSL_NO_DEVCRYPTOENG +# endif +# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +# define OPENSSL_NO_EC_NISTP_64_GCC_128 +# endif +# ifndef OPENSSL_NO_EGD +# define OPENSSL_NO_EGD +# endif +# ifndef OPENSSL_NO_EXTERNAL_TESTS +# define OPENSSL_NO_EXTERNAL_TESTS +# endif +# ifndef OPENSSL_NO_FIPS_JITTER +# define OPENSSL_NO_FIPS_JITTER +# endif +# ifndef OPENSSL_NO_FIPS_POST +# define OPENSSL_NO_FIPS_POST +# endif +# ifndef OPENSSL_NO_FIPS_SECURITYCHECKS +# define OPENSSL_NO_FIPS_SECURITYCHECKS +# endif +# ifndef OPENSSL_NO_FUZZ_AFL +# define OPENSSL_NO_FUZZ_AFL +# endif +# ifndef OPENSSL_NO_FUZZ_LIBFUZZER +# define OPENSSL_NO_FUZZ_LIBFUZZER +# endif +# ifndef OPENSSL_NO_H3DEMO +# define OPENSSL_NO_H3DEMO +# endif +# ifndef OPENSSL_NO_HQINTEROP +# define OPENSSL_NO_HQINTEROP +# endif +# ifndef OPENSSL_NO_JITTER +# define OPENSSL_NO_JITTER +# endif +# ifndef OPENSSL_NO_KTLS +# define OPENSSL_NO_KTLS +# endif +# ifndef OPENSSL_NO_MD2 +# define OPENSSL_NO_MD2 +# endif +# ifndef OPENSSL_NO_MSAN +# define OPENSSL_NO_MSAN +# endif +# ifndef OPENSSL_NO_PIE +# define OPENSSL_NO_PIE +# endif +# ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +# endif +# ifndef OPENSSL_NO_SCTP +# define OPENSSL_NO_SCTP +# endif +# ifndef OPENSSL_NO_SSL3 +# define OPENSSL_NO_SSL3 +# endif +# ifndef OPENSSL_NO_SSL3_METHOD +# define OPENSSL_NO_SSL3_METHOD +# endif +# ifndef OPENSSL_NO_SSLKEYLOG +# define OPENSSL_NO_SSLKEYLOG +# endif +# ifndef OPENSSL_NO_TFO +# define OPENSSL_NO_TFO +# endif +# ifndef OPENSSL_NO_TRACE +# define OPENSSL_NO_TRACE +# endif +# ifndef OPENSSL_NO_UBSAN +# define OPENSSL_NO_UBSAN +# endif +# ifndef OPENSSL_NO_UNIT_TEST +# define OPENSSL_NO_UNIT_TEST +# endif +# ifndef OPENSSL_NO_UPLINK +# define OPENSSL_NO_UPLINK +# endif +# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +# endif +# ifndef OPENSSL_NO_WINSTORE +# define OPENSSL_NO_WINSTORE +# endif +# ifndef OPENSSL_NO_ZLIB_DYNAMIC +# define OPENSSL_NO_ZLIB_DYNAMIC +# endif +# ifndef OPENSSL_NO_ZSTD +# define OPENSSL_NO_ZSTD +# endif +# ifndef OPENSSL_NO_ZSTD_DYNAMIC +# define OPENSSL_NO_ZSTD_DYNAMIC +# endif +# ifndef OPENSSL_NO_STATIC_ENGINE +# define OPENSSL_NO_STATIC_ENGINE +# endif + + +/* Generate 80386 code? */ +# undef I386_ONLY + +/* + * The following are cipher-specific, but are part of the public API. + */ +# if !defined(OPENSSL_SYS_UEFI) +# define BN_LLONG +/* Only one for the following should be defined */ +# undef SIXTY_FOUR_BIT_LONG +# undef SIXTY_FOUR_BIT +# define THIRTY_TWO_BIT +# endif + +# define RC4_INT unsigned int + +# if defined(OPENSSL_NO_COMP) || (defined(OPENSSL_NO_BROTLI) && defined(OPENSSL_NO_ZSTD) && defined(OPENSSL_NO_ZLIB)) +# define OPENSSL_NO_COMP_ALG +# else +# undef OPENSSL_NO_COMP_ALG +# endif + +# ifdef __cplusplus +} +# endif + +#endif /* OPENSSL_CONFIGURATION_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/conftypes.h b/illumos-x86_64/usr/include/openssl-3/conftypes.h new file mode 100644 index 00000000..17cefaa4 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/conftypes.h @@ -0,0 +1,44 @@ +/* + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CONFTYPES_H +# define OPENSSL_CONFTYPES_H +# pragma once + +#ifndef OPENSSL_CONF_H +# include +#endif + +/* + * The contents of this file are deprecated and will be made opaque + */ +struct conf_method_st { + const char *name; + CONF *(*create) (CONF_METHOD *meth); + int (*init) (CONF *conf); + int (*destroy) (CONF *conf); + int (*destroy_data) (CONF *conf); + int (*load_bio) (CONF *conf, BIO *bp, long *eline); + int (*dump) (const CONF *conf, BIO *bp); + int (*is_number) (const CONF *conf, char c); + int (*to_int) (const CONF *conf, char c); + int (*load) (CONF *conf, const char *name, long *eline); +}; + +struct conf_st { + CONF_METHOD *meth; + void *meth_data; + LHASH_OF(CONF_VALUE) *data; + int flag_dollarid; + int flag_abspath; + char *includedir; + OSSL_LIB_CTX *libctx; +}; + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/core.h b/illumos-x86_64/usr/include/openssl-3/core.h new file mode 100644 index 00000000..18c19918 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/core.h @@ -0,0 +1,236 @@ +/* + * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CORE_H +# define OPENSSL_CORE_H +# pragma once + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/*- + * Base types + * ---------- + * + * These are the types that the OpenSSL core and providers have in common + * to communicate data between them. + */ + +/* Opaque handles to be used with core upcall functions from providers */ +typedef struct ossl_core_handle_st OSSL_CORE_HANDLE; +typedef struct openssl_core_ctx_st OPENSSL_CORE_CTX; +typedef struct ossl_core_bio_st OSSL_CORE_BIO; + +/* + * Dispatch table element. function_id numbers and the functions are defined + * in core_dispatch.h, see macros with 'OSSL_CORE_MAKE_FUNC' in their names. + * + * An array of these is always terminated by function_id == 0 + */ +struct ossl_dispatch_st { + int function_id; + void (*function)(void); +}; + +# define OSSL_DISPATCH_END \ + { 0, NULL } + +/* + * Other items, essentially an int<->pointer map element. + * + * We make this type distinct from OSSL_DISPATCH to ensure that dispatch + * tables remain tables with function pointers only. + * + * This is used whenever we need to pass things like a table of error reason + * codes <-> reason string maps, ... + * + * Usage determines which field works as key if any, rather than field order. + * + * An array of these is always terminated by id == 0 && ptr == NULL + */ +struct ossl_item_st { + unsigned int id; + void *ptr; +}; + +/* + * Type to tie together algorithm names, property definition string and + * the algorithm implementation in the form of a dispatch table. + * + * An array of these is always terminated by algorithm_names == NULL + */ +struct ossl_algorithm_st { + const char *algorithm_names; /* key */ + const char *property_definition; /* key */ + const OSSL_DISPATCH *implementation; + const char *algorithm_description; +}; + +/* + * Type to pass object data in a uniform way, without exposing the object + * structure. + * + * An array of these is always terminated by key == NULL + */ +struct ossl_param_st { + const char *key; /* the name of the parameter */ + unsigned int data_type; /* declare what kind of content is in buffer */ + void *data; /* value being passed in or out */ + size_t data_size; /* data size */ + size_t return_size; /* returned content size */ +}; + +/* Currently supported OSSL_PARAM data types */ +/* + * OSSL_PARAM_INTEGER and OSSL_PARAM_UNSIGNED_INTEGER + * are arbitrary length and therefore require an arbitrarily sized buffer, + * since they may be used to pass numbers larger than what is natively + * available. + * + * The number must be buffered in native form, i.e. MSB first on B_ENDIAN + * systems and LSB first on L_ENDIAN systems. This means that arbitrary + * native integers can be stored in the buffer, just make sure that the + * buffer size is correct and the buffer itself is properly aligned (for + * example by having the buffer field point at a C integer). + */ +# define OSSL_PARAM_INTEGER 1 +# define OSSL_PARAM_UNSIGNED_INTEGER 2 +/*- + * OSSL_PARAM_REAL + * is a C binary floating point values in native form and alignment. + */ +# define OSSL_PARAM_REAL 3 +/*- + * OSSL_PARAM_UTF8_STRING + * is a printable string. It is expected to be printed as it is. + */ +# define OSSL_PARAM_UTF8_STRING 4 +/*- + * OSSL_PARAM_OCTET_STRING + * is a string of bytes with no further specification. It is expected to be + * printed as a hexdump. + */ +# define OSSL_PARAM_OCTET_STRING 5 +/*- + * OSSL_PARAM_UTF8_PTR + * is a pointer to a printable string. It is expected to be printed as it is. + * + * The difference between this and OSSL_PARAM_UTF8_STRING is that only pointers + * are manipulated for this type. + * + * This is more relevant for parameter requests, where the responding + * function doesn't need to copy the data to the provided buffer, but + * sets the provided buffer to point at the actual data instead. + * + * WARNING! Using these is FRAGILE, as it assumes that the actual + * data and its location are constant. + * + * EXTRA WARNING! If you are not completely sure you most likely want + * to use the OSSL_PARAM_UTF8_STRING type. + */ +# define OSSL_PARAM_UTF8_PTR 6 +/*- + * OSSL_PARAM_OCTET_PTR + * is a pointer to a string of bytes with no further specification. It is + * expected to be printed as a hexdump. + * + * The difference between this and OSSL_PARAM_OCTET_STRING is that only pointers + * are manipulated for this type. + * + * This is more relevant for parameter requests, where the responding + * function doesn't need to copy the data to the provided buffer, but + * sets the provided buffer to point at the actual data instead. + * + * WARNING! Using these is FRAGILE, as it assumes that the actual + * data and its location are constant. + * + * EXTRA WARNING! If you are not completely sure you most likely want + * to use the OSSL_PARAM_OCTET_STRING type. + */ +# define OSSL_PARAM_OCTET_PTR 7 + +/* + * Typedef for the thread stop handling callback. Used both internally and by + * providers. + * + * Providers may register for notifications about threads stopping by + * registering a callback to hear about such events. Providers register the + * callback using the OSSL_FUNC_CORE_THREAD_START function in the |in| dispatch + * table passed to OSSL_provider_init(). The arg passed back to a provider will + * be the provider side context object. + */ +typedef void (*OSSL_thread_stop_handler_fn)(void *arg); + + +/*- + * Provider entry point + * -------------------- + * + * This function is expected to be present in any dynamically loadable + * provider module. By definition, if this function doesn't exist in a + * module, that module is not an OpenSSL provider module. + */ +/*- + * |handle| pointer to opaque type OSSL_CORE_HANDLE. This can be used + * together with some functions passed via |in| to query data. + * |in| is the array of functions that the Core passes to the provider. + * |out| will be the array of base functions that the provider passes + * back to the Core. + * |provctx| a provider side context object, optionally created if the + * provider needs it. This value is passed to other provider + * functions, notably other context constructors. + */ +typedef int (OSSL_provider_init_fn)(const OSSL_CORE_HANDLE *handle, + const OSSL_DISPATCH *in, + const OSSL_DISPATCH **out, + void **provctx); +# ifdef __VMS +# pragma names save +# pragma names uppercase,truncated +# endif +OPENSSL_EXPORT OSSL_provider_init_fn OSSL_provider_init; +# ifdef __VMS +# pragma names restore +# endif + +/* + * Generic callback function signature. + * + * The expectation is that any provider function that wants to offer + * a callback / hook can do so by taking an argument with this type, + * as well as a pointer to caller-specific data. When calling the + * callback, the provider function can populate an OSSL_PARAM array + * with data of its choice and pass that in the callback call, along + * with the caller data argument. + * + * libcrypto may use the OSSL_PARAM array to create arguments for an + * application callback it knows about. + */ +typedef int (OSSL_CALLBACK)(const OSSL_PARAM params[], void *arg); +typedef int (OSSL_INOUT_CALLBACK)(const OSSL_PARAM in_params[], + OSSL_PARAM out_params[], void *arg); +/* + * Passphrase callback function signature + * + * This is similar to the generic callback function above, but adds a + * result parameter. + */ +typedef int (OSSL_PASSPHRASE_CALLBACK)(char *pass, size_t pass_size, + size_t *pass_len, + const OSSL_PARAM params[], void *arg); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/core_dispatch.h b/illumos-x86_64/usr/include/openssl-3/core_dispatch.h new file mode 100644 index 00000000..13de04e2 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/core_dispatch.h @@ -0,0 +1,1145 @@ +/* + * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CORE_NUMBERS_H +# define OPENSSL_CORE_NUMBERS_H +# pragma once + +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * Generic function pointer for provider method arrays, or other contexts where + * functions of various signatures must occupy a common slot in an array of + * structures. + */ +typedef void (*OSSL_FUNC)(void); + +/*- + * Identities + * ---------- + * + * All series start with 1, to allow 0 to be an array terminator. + * For any FUNC identity, we also provide a function signature typedef + * and a static inline function to extract a function pointer from a + * OSSL_DISPATCH element in a type safe manner. + * + * Names: + * for any function base name 'foo' (uppercase form 'FOO'), we will have + * the following: + * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivatives + * thereof (to be specified further down) + * - a function signature typedef with the name OSSL_FUNC_'foo'_fn + * - a function pointer extractor function with the name OSSL_FUNC_'foo' + */ + +/* + * Helper macro to create the function signature typedef and the extractor + * |type| is the return-type of the function, |name| is the name of the + * function to fetch, and |args| is a parenthesized list of parameters + * for the function (that is, it is |name|'s function signature). + * Note: This is considered a "reserved" internal macro. Applications should + * not use this or assume its existence. + */ +#define OSSL_CORE_MAKE_FUNC(type,name,args) \ + typedef type (OSSL_FUNC_##name##_fn)args; \ + static ossl_unused ossl_inline \ + OSSL_FUNC_##name##_fn *OSSL_FUNC_##name(const OSSL_DISPATCH *opf) \ + { \ + return (OSSL_FUNC_##name##_fn *)opf->function; \ + } + +/* + * Core function identities, for the two OSSL_DISPATCH tables being passed + * in the OSSL_provider_init call. + * + * 0 serves as a marker for the end of the OSSL_DISPATCH array, and must + * therefore NEVER be used as a function identity. + */ +/* Functions provided by the Core to the provider, reserved numbers 1-1023 */ +# define OSSL_FUNC_CORE_GETTABLE_PARAMS 1 +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, + core_gettable_params,(const OSSL_CORE_HANDLE *prov)) +# define OSSL_FUNC_CORE_GET_PARAMS 2 +OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_CORE_HANDLE *prov, + OSSL_PARAM params[])) +# define OSSL_FUNC_CORE_THREAD_START 3 +OSSL_CORE_MAKE_FUNC(int,core_thread_start,(const OSSL_CORE_HANDLE *prov, + OSSL_thread_stop_handler_fn handfn, + void *arg)) +# define OSSL_FUNC_CORE_GET_LIBCTX 4 +OSSL_CORE_MAKE_FUNC(OPENSSL_CORE_CTX *,core_get_libctx, + (const OSSL_CORE_HANDLE *prov)) +# define OSSL_FUNC_CORE_NEW_ERROR 5 +OSSL_CORE_MAKE_FUNC(void,core_new_error,(const OSSL_CORE_HANDLE *prov)) +# define OSSL_FUNC_CORE_SET_ERROR_DEBUG 6 +OSSL_CORE_MAKE_FUNC(void,core_set_error_debug, + (const OSSL_CORE_HANDLE *prov, + const char *file, int line, const char *func)) +# define OSSL_FUNC_CORE_VSET_ERROR 7 +OSSL_CORE_MAKE_FUNC(void,core_vset_error, + (const OSSL_CORE_HANDLE *prov, + uint32_t reason, const char *fmt, va_list args)) +# define OSSL_FUNC_CORE_SET_ERROR_MARK 8 +OSSL_CORE_MAKE_FUNC(int, core_set_error_mark, (const OSSL_CORE_HANDLE *prov)) +# define OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK 9 +OSSL_CORE_MAKE_FUNC(int, core_clear_last_error_mark, + (const OSSL_CORE_HANDLE *prov)) +# define OSSL_FUNC_CORE_POP_ERROR_TO_MARK 10 +OSSL_CORE_MAKE_FUNC(int, core_pop_error_to_mark, (const OSSL_CORE_HANDLE *prov)) + + +/* Functions to access the OBJ database */ + +#define OSSL_FUNC_CORE_OBJ_ADD_SIGID 11 +#define OSSL_FUNC_CORE_OBJ_CREATE 12 + +OSSL_CORE_MAKE_FUNC(int, core_obj_add_sigid, + (const OSSL_CORE_HANDLE *prov, const char *sign_name, + const char *digest_name, const char *pkey_name)) +OSSL_CORE_MAKE_FUNC(int, core_obj_create, + (const OSSL_CORE_HANDLE *prov, const char *oid, + const char *sn, const char *ln)) + +/* Memory allocation, freeing, clearing. */ +#define OSSL_FUNC_CRYPTO_MALLOC 20 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_malloc, (size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_ZALLOC 21 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_zalloc, (size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_FREE 22 +OSSL_CORE_MAKE_FUNC(void, + CRYPTO_free, (void *ptr, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_CLEAR_FREE 23 +OSSL_CORE_MAKE_FUNC(void, + CRYPTO_clear_free, (void *ptr, size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_REALLOC 24 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_realloc, (void *addr, size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_CLEAR_REALLOC 25 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_clear_realloc, (void *addr, size_t old_num, size_t num, + const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_MALLOC 26 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_secure_malloc, (size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_ZALLOC 27 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_secure_zalloc, (size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_FREE 28 +OSSL_CORE_MAKE_FUNC(void, + CRYPTO_secure_free, (void *ptr, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE 29 +OSSL_CORE_MAKE_FUNC(void, + CRYPTO_secure_clear_free, (void *ptr, size_t num, const char *file, + int line)) +#define OSSL_FUNC_CRYPTO_SECURE_ALLOCATED 30 +OSSL_CORE_MAKE_FUNC(int, + CRYPTO_secure_allocated, (const void *ptr)) +#define OSSL_FUNC_OPENSSL_CLEANSE 31 +OSSL_CORE_MAKE_FUNC(void, + OPENSSL_cleanse, (void *ptr, size_t len)) + +/* Bio functions provided by the core */ +#define OSSL_FUNC_BIO_NEW_FILE 40 +#define OSSL_FUNC_BIO_NEW_MEMBUF 41 +#define OSSL_FUNC_BIO_READ_EX 42 +#define OSSL_FUNC_BIO_WRITE_EX 43 +#define OSSL_FUNC_BIO_UP_REF 44 +#define OSSL_FUNC_BIO_FREE 45 +#define OSSL_FUNC_BIO_VPRINTF 46 +#define OSSL_FUNC_BIO_VSNPRINTF 47 +#define OSSL_FUNC_BIO_PUTS 48 +#define OSSL_FUNC_BIO_GETS 49 +#define OSSL_FUNC_BIO_CTRL 50 + + +OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, (const char *filename, + const char *mode)) +OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_membuf, (const void *buf, int len)) +OSSL_CORE_MAKE_FUNC(int, BIO_read_ex, (OSSL_CORE_BIO *bio, void *data, + size_t data_len, size_t *bytes_read)) +OSSL_CORE_MAKE_FUNC(int, BIO_write_ex, (OSSL_CORE_BIO *bio, const void *data, + size_t data_len, size_t *written)) +OSSL_CORE_MAKE_FUNC(int, BIO_gets, (OSSL_CORE_BIO *bio, char *buf, int size)) +OSSL_CORE_MAKE_FUNC(int, BIO_puts, (OSSL_CORE_BIO *bio, const char *str)) +OSSL_CORE_MAKE_FUNC(int, BIO_up_ref, (OSSL_CORE_BIO *bio)) +OSSL_CORE_MAKE_FUNC(int, BIO_free, (OSSL_CORE_BIO *bio)) +OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, (OSSL_CORE_BIO *bio, const char *format, + va_list args)) +OSSL_CORE_MAKE_FUNC(int, BIO_vsnprintf, + (char *buf, size_t n, const char *fmt, va_list args)) +OSSL_CORE_MAKE_FUNC(int, BIO_ctrl, (OSSL_CORE_BIO *bio, + int cmd, long num, void *ptr)) + +/* New seeding functions prototypes with the 101-104 series */ +#define OSSL_FUNC_CLEANUP_USER_ENTROPY 96 +#define OSSL_FUNC_CLEANUP_USER_NONCE 97 +#define OSSL_FUNC_GET_USER_ENTROPY 98 +#define OSSL_FUNC_GET_USER_NONCE 99 + +#define OSSL_FUNC_INDICATOR_CB 95 +OSSL_CORE_MAKE_FUNC(void, indicator_cb, (OPENSSL_CORE_CTX *ctx, + OSSL_INDICATOR_CALLBACK **cb)) +#define OSSL_FUNC_SELF_TEST_CB 100 +OSSL_CORE_MAKE_FUNC(void, self_test_cb, (OPENSSL_CORE_CTX *ctx, OSSL_CALLBACK **cb, + void **cbarg)) + +/* Functions to get seed material from the operating system */ +#define OSSL_FUNC_GET_ENTROPY 101 +#define OSSL_FUNC_CLEANUP_ENTROPY 102 +#define OSSL_FUNC_GET_NONCE 103 +#define OSSL_FUNC_CLEANUP_NONCE 104 +OSSL_CORE_MAKE_FUNC(size_t, get_entropy, (const OSSL_CORE_HANDLE *handle, + unsigned char **pout, int entropy, + size_t min_len, size_t max_len)) +OSSL_CORE_MAKE_FUNC(size_t, get_user_entropy, (const OSSL_CORE_HANDLE *handle, + unsigned char **pout, int entropy, + size_t min_len, size_t max_len)) +OSSL_CORE_MAKE_FUNC(void, cleanup_entropy, (const OSSL_CORE_HANDLE *handle, + unsigned char *buf, size_t len)) +OSSL_CORE_MAKE_FUNC(void, cleanup_user_entropy, (const OSSL_CORE_HANDLE *handle, + unsigned char *buf, size_t len)) +OSSL_CORE_MAKE_FUNC(size_t, get_nonce, (const OSSL_CORE_HANDLE *handle, + unsigned char **pout, size_t min_len, + size_t max_len, const void *salt, + size_t salt_len)) +OSSL_CORE_MAKE_FUNC(size_t, get_user_nonce, (const OSSL_CORE_HANDLE *handle, + unsigned char **pout, size_t min_len, + size_t max_len, const void *salt, + size_t salt_len)) +OSSL_CORE_MAKE_FUNC(void, cleanup_nonce, (const OSSL_CORE_HANDLE *handle, + unsigned char *buf, size_t len)) +OSSL_CORE_MAKE_FUNC(void, cleanup_user_nonce, (const OSSL_CORE_HANDLE *handle, + unsigned char *buf, size_t len)) + +/* Functions to access the core's providers */ +#define OSSL_FUNC_PROVIDER_REGISTER_CHILD_CB 105 +#define OSSL_FUNC_PROVIDER_DEREGISTER_CHILD_CB 106 +#define OSSL_FUNC_PROVIDER_NAME 107 +#define OSSL_FUNC_PROVIDER_GET0_PROVIDER_CTX 108 +#define OSSL_FUNC_PROVIDER_GET0_DISPATCH 109 +#define OSSL_FUNC_PROVIDER_UP_REF 110 +#define OSSL_FUNC_PROVIDER_FREE 111 + +OSSL_CORE_MAKE_FUNC(int, provider_register_child_cb, + (const OSSL_CORE_HANDLE *handle, + int (*create_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata), + int (*remove_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata), + int (*global_props_cb)(const char *props, void *cbdata), + void *cbdata)) +OSSL_CORE_MAKE_FUNC(void, provider_deregister_child_cb, + (const OSSL_CORE_HANDLE *handle)) +OSSL_CORE_MAKE_FUNC(const char *, provider_name, + (const OSSL_CORE_HANDLE *prov)) +OSSL_CORE_MAKE_FUNC(void *, provider_get0_provider_ctx, + (const OSSL_CORE_HANDLE *prov)) +OSSL_CORE_MAKE_FUNC(const OSSL_DISPATCH *, provider_get0_dispatch, + (const OSSL_CORE_HANDLE *prov)) +OSSL_CORE_MAKE_FUNC(int, provider_up_ref, + (const OSSL_CORE_HANDLE *prov, int activate)) +OSSL_CORE_MAKE_FUNC(int, provider_free, + (const OSSL_CORE_HANDLE *prov, int deactivate)) + +/* Additional error functions provided by the core */ +# define OSSL_FUNC_CORE_COUNT_TO_MARK 120 +OSSL_CORE_MAKE_FUNC(int, core_count_to_mark, (const OSSL_CORE_HANDLE *prov)) + +/* Functions provided by the provider to the Core, reserved numbers 1024-1535 */ +# define OSSL_FUNC_PROVIDER_TEARDOWN 1024 +OSSL_CORE_MAKE_FUNC(void, provider_teardown, (void *provctx)) +# define OSSL_FUNC_PROVIDER_GETTABLE_PARAMS 1025 +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, + provider_gettable_params,(void *provctx)) +# define OSSL_FUNC_PROVIDER_GET_PARAMS 1026 +OSSL_CORE_MAKE_FUNC(int, provider_get_params, (void *provctx, + OSSL_PARAM params[])) +# define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027 +OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation, + (void *provctx, int operation_id, int *no_store)) +# define OSSL_FUNC_PROVIDER_UNQUERY_OPERATION 1028 +OSSL_CORE_MAKE_FUNC(void, provider_unquery_operation, + (void *provctx, int operation_id, const OSSL_ALGORITHM *)) +# define OSSL_FUNC_PROVIDER_GET_REASON_STRINGS 1029 +OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,provider_get_reason_strings, + (void *provctx)) +# define OSSL_FUNC_PROVIDER_GET_CAPABILITIES 1030 +OSSL_CORE_MAKE_FUNC(int, provider_get_capabilities, (void *provctx, + const char *capability, OSSL_CALLBACK *cb, void *arg)) +# define OSSL_FUNC_PROVIDER_SELF_TEST 1031 +OSSL_CORE_MAKE_FUNC(int, provider_self_test, (void *provctx)) +# define OSSL_FUNC_PROVIDER_RANDOM_BYTES 1032 +OSSL_CORE_MAKE_FUNC(int, provider_random_bytes, (void *provctx, int which, + void *buf, size_t n, + unsigned int strength)) + +/* Libssl related functions */ +#define OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_SEND 2001 +OSSL_CORE_MAKE_FUNC(int, SSL_QUIC_TLS_crypto_send, + (SSL *s, const unsigned char *buf, size_t buf_len, + size_t *consumed, void *arg)) +#define OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_RECV_RCD 2002 +OSSL_CORE_MAKE_FUNC(int, SSL_QUIC_TLS_crypto_recv_rcd, + (SSL *s, const unsigned char **buf, size_t *bytes_read, + void *arg)) +#define OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_RELEASE_RCD 2003 +OSSL_CORE_MAKE_FUNC(int, SSL_QUIC_TLS_crypto_release_rcd, + (SSL *s, size_t bytes_read, void *arg)) +#define OSSL_FUNC_SSL_QUIC_TLS_YIELD_SECRET 2004 +OSSL_CORE_MAKE_FUNC(int, SSL_QUIC_TLS_yield_secret, + (SSL *s, uint32_t prot_level, int direction, + const unsigned char *secret, size_t secret_len, void *arg)) +#define OSSL_FUNC_SSL_QUIC_TLS_GOT_TRANSPORT_PARAMS 2005 +OSSL_CORE_MAKE_FUNC(int, SSL_QUIC_TLS_got_transport_params, + (SSL *s, const unsigned char *params, size_t params_len, + void *arg)) +#define OSSL_FUNC_SSL_QUIC_TLS_ALERT 2006 +OSSL_CORE_MAKE_FUNC(int, SSL_QUIC_TLS_alert, + (SSL *s, unsigned char alert_code, void *arg)) + +/* Operations */ + +# define OSSL_OP_DIGEST 1 +# define OSSL_OP_CIPHER 2 /* Symmetric Ciphers */ +# define OSSL_OP_MAC 3 +# define OSSL_OP_KDF 4 +# define OSSL_OP_RAND 5 +# define OSSL_OP_KEYMGMT 10 +# define OSSL_OP_KEYEXCH 11 +# define OSSL_OP_SIGNATURE 12 +# define OSSL_OP_ASYM_CIPHER 13 +# define OSSL_OP_KEM 14 +# define OSSL_OP_SKEYMGMT 15 +/* New section for non-EVP operations */ +# define OSSL_OP_ENCODER 20 +# define OSSL_OP_DECODER 21 +# define OSSL_OP_STORE 22 +/* Highest known operation number */ +# define OSSL_OP__HIGHEST 22 + +/* Digests */ + +# define OSSL_FUNC_DIGEST_NEWCTX 1 +# define OSSL_FUNC_DIGEST_INIT 2 +# define OSSL_FUNC_DIGEST_UPDATE 3 +# define OSSL_FUNC_DIGEST_FINAL 4 +# define OSSL_FUNC_DIGEST_DIGEST 5 +# define OSSL_FUNC_DIGEST_FREECTX 6 +# define OSSL_FUNC_DIGEST_DUPCTX 7 +# define OSSL_FUNC_DIGEST_GET_PARAMS 8 +# define OSSL_FUNC_DIGEST_SET_CTX_PARAMS 9 +# define OSSL_FUNC_DIGEST_GET_CTX_PARAMS 10 +# define OSSL_FUNC_DIGEST_GETTABLE_PARAMS 11 +# define OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS 12 +# define OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS 13 +# define OSSL_FUNC_DIGEST_SQUEEZE 14 +# define OSSL_FUNC_DIGEST_COPYCTX 15 + +OSSL_CORE_MAKE_FUNC(void *, digest_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, digest_init, (void *dctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, digest_update, + (void *dctx, const unsigned char *in, size_t inl)) +OSSL_CORE_MAKE_FUNC(int, digest_final, + (void *dctx, + unsigned char *out, size_t *outl, size_t outsz)) +OSSL_CORE_MAKE_FUNC(int, digest_squeeze, + (void *dctx, + unsigned char *out, size_t *outl, size_t outsz)) +OSSL_CORE_MAKE_FUNC(int, digest_digest, + (void *provctx, const unsigned char *in, size_t inl, + unsigned char *out, size_t *outl, size_t outsz)) + +OSSL_CORE_MAKE_FUNC(void, digest_freectx, (void *dctx)) +OSSL_CORE_MAKE_FUNC(void *, digest_dupctx, (void *dctx)) +OSSL_CORE_MAKE_FUNC(void, digest_copyctx, (void *outctx, void *inctx)) + +OSSL_CORE_MAKE_FUNC(int, digest_get_params, (OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, digest_set_ctx_params, + (void *vctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, digest_get_ctx_params, + (void *vctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_params, + (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_settable_ctx_params, + (void *dctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_ctx_params, + (void *dctx, void *provctx)) + +/* Symmetric Ciphers */ + +# define OSSL_FUNC_CIPHER_NEWCTX 1 +# define OSSL_FUNC_CIPHER_ENCRYPT_INIT 2 +# define OSSL_FUNC_CIPHER_DECRYPT_INIT 3 +# define OSSL_FUNC_CIPHER_UPDATE 4 +# define OSSL_FUNC_CIPHER_FINAL 5 +# define OSSL_FUNC_CIPHER_CIPHER 6 +# define OSSL_FUNC_CIPHER_FREECTX 7 +# define OSSL_FUNC_CIPHER_DUPCTX 8 +# define OSSL_FUNC_CIPHER_GET_PARAMS 9 +# define OSSL_FUNC_CIPHER_GET_CTX_PARAMS 10 +# define OSSL_FUNC_CIPHER_SET_CTX_PARAMS 11 +# define OSSL_FUNC_CIPHER_GETTABLE_PARAMS 12 +# define OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS 13 +# define OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS 14 +# define OSSL_FUNC_CIPHER_PIPELINE_ENCRYPT_INIT 15 +# define OSSL_FUNC_CIPHER_PIPELINE_DECRYPT_INIT 16 +# define OSSL_FUNC_CIPHER_PIPELINE_UPDATE 17 +# define OSSL_FUNC_CIPHER_PIPELINE_FINAL 18 +# define OSSL_FUNC_CIPHER_ENCRYPT_SKEY_INIT 19 +# define OSSL_FUNC_CIPHER_DECRYPT_SKEY_INIT 20 + +OSSL_CORE_MAKE_FUNC(void *, cipher_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, cipher_encrypt_init, (void *cctx, + const unsigned char *key, + size_t keylen, + const unsigned char *iv, + size_t ivlen, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_decrypt_init, (void *cctx, + const unsigned char *key, + size_t keylen, + const unsigned char *iv, + size_t ivlen, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_update, + (void *cctx, + unsigned char *out, size_t *outl, size_t outsize, + const unsigned char *in, size_t inl)) +OSSL_CORE_MAKE_FUNC(int, cipher_final, + (void *cctx, + unsigned char *out, size_t *outl, size_t outsize)) +OSSL_CORE_MAKE_FUNC(int, cipher_cipher, + (void *cctx, + unsigned char *out, size_t *outl, size_t outsize, + const unsigned char *in, size_t inl)) +OSSL_CORE_MAKE_FUNC(int, cipher_pipeline_encrypt_init, + (void *cctx, + const unsigned char *key, size_t keylen, + size_t numpipes, const unsigned char **iv, size_t ivlen, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_pipeline_decrypt_init, + (void *cctx, + const unsigned char *key, size_t keylen, + size_t numpipes, const unsigned char **iv, size_t ivlen, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_pipeline_update, + (void *cctx, size_t numpipes, + unsigned char **out, size_t *outl, const size_t *outsize, + const unsigned char **in, const size_t *inl)) +OSSL_CORE_MAKE_FUNC(int, cipher_pipeline_final, + (void *cctx, size_t numpipes, + unsigned char **out, size_t *outl, const size_t *outsize)) +OSSL_CORE_MAKE_FUNC(void, cipher_freectx, (void *cctx)) +OSSL_CORE_MAKE_FUNC(void *, cipher_dupctx, (void *cctx)) +OSSL_CORE_MAKE_FUNC(int, cipher_get_params, (OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_get_ctx_params, (void *cctx, + OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_set_ctx_params, (void *cctx, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_params, + (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_settable_ctx_params, + (void *cctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_ctx_params, + (void *cctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, cipher_encrypt_skey_init, (void *cctx, + void *skeydata, + const unsigned char *iv, + size_t ivlen, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_decrypt_skey_init, (void *cctx, + void *skeydata, + const unsigned char *iv, + size_t ivlen, + const OSSL_PARAM params[])) + +/* MACs */ + +# define OSSL_FUNC_MAC_NEWCTX 1 +# define OSSL_FUNC_MAC_DUPCTX 2 +# define OSSL_FUNC_MAC_FREECTX 3 +# define OSSL_FUNC_MAC_INIT 4 +# define OSSL_FUNC_MAC_UPDATE 5 +# define OSSL_FUNC_MAC_FINAL 6 +# define OSSL_FUNC_MAC_GET_PARAMS 7 +# define OSSL_FUNC_MAC_GET_CTX_PARAMS 8 +# define OSSL_FUNC_MAC_SET_CTX_PARAMS 9 +# define OSSL_FUNC_MAC_GETTABLE_PARAMS 10 +# define OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS 11 +# define OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS 12 +# define OSSL_FUNC_MAC_INIT_SKEY 13 + +OSSL_CORE_MAKE_FUNC(void *, mac_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(void *, mac_dupctx, (void *src)) +OSSL_CORE_MAKE_FUNC(void, mac_freectx, (void *mctx)) +OSSL_CORE_MAKE_FUNC(int, mac_init, (void *mctx, const unsigned char *key, + size_t keylen, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, mac_update, + (void *mctx, const unsigned char *in, size_t inl)) +OSSL_CORE_MAKE_FUNC(int, mac_final, + (void *mctx, + unsigned char *out, size_t *outl, size_t outsize)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_ctx_params, + (void *mctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_settable_ctx_params, + (void *mctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, mac_get_params, (OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, mac_get_ctx_params, + (void *mctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, mac_set_ctx_params, + (void *mctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, mac_init_skey, (void *mctx, void *key, const OSSL_PARAM params[])) + +/* KDFs and PRFs */ + +# define OSSL_FUNC_KDF_NEWCTX 1 +# define OSSL_FUNC_KDF_DUPCTX 2 +# define OSSL_FUNC_KDF_FREECTX 3 +# define OSSL_FUNC_KDF_RESET 4 +# define OSSL_FUNC_KDF_DERIVE 5 +# define OSSL_FUNC_KDF_GETTABLE_PARAMS 6 +# define OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS 7 +# define OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS 8 +# define OSSL_FUNC_KDF_GET_PARAMS 9 +# define OSSL_FUNC_KDF_GET_CTX_PARAMS 10 +# define OSSL_FUNC_KDF_SET_CTX_PARAMS 11 + +OSSL_CORE_MAKE_FUNC(void *, kdf_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(void *, kdf_dupctx, (void *src)) +OSSL_CORE_MAKE_FUNC(void, kdf_freectx, (void *kctx)) +OSSL_CORE_MAKE_FUNC(void, kdf_reset, (void *kctx)) +OSSL_CORE_MAKE_FUNC(int, kdf_derive, (void *kctx, unsigned char *key, + size_t keylen, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_ctx_params, + (void *kctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_settable_ctx_params, + (void *kctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, kdf_get_params, (OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, kdf_get_ctx_params, + (void *kctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, kdf_set_ctx_params, + (void *kctx, const OSSL_PARAM params[])) + +/* RAND */ + +# define OSSL_FUNC_RAND_NEWCTX 1 +# define OSSL_FUNC_RAND_FREECTX 2 +# define OSSL_FUNC_RAND_INSTANTIATE 3 +# define OSSL_FUNC_RAND_UNINSTANTIATE 4 +# define OSSL_FUNC_RAND_GENERATE 5 +# define OSSL_FUNC_RAND_RESEED 6 +# define OSSL_FUNC_RAND_NONCE 7 +# define OSSL_FUNC_RAND_ENABLE_LOCKING 8 +# define OSSL_FUNC_RAND_LOCK 9 +# define OSSL_FUNC_RAND_UNLOCK 10 +# define OSSL_FUNC_RAND_GETTABLE_PARAMS 11 +# define OSSL_FUNC_RAND_GETTABLE_CTX_PARAMS 12 +# define OSSL_FUNC_RAND_SETTABLE_CTX_PARAMS 13 +# define OSSL_FUNC_RAND_GET_PARAMS 14 +# define OSSL_FUNC_RAND_GET_CTX_PARAMS 15 +# define OSSL_FUNC_RAND_SET_CTX_PARAMS 16 +# define OSSL_FUNC_RAND_VERIFY_ZEROIZATION 17 +# define OSSL_FUNC_RAND_GET_SEED 18 +# define OSSL_FUNC_RAND_CLEAR_SEED 19 + +OSSL_CORE_MAKE_FUNC(void *,rand_newctx, + (void *provctx, void *parent, + const OSSL_DISPATCH *parent_calls)) +OSSL_CORE_MAKE_FUNC(void,rand_freectx, (void *vctx)) +OSSL_CORE_MAKE_FUNC(int,rand_instantiate, + (void *vdrbg, unsigned int strength, + int prediction_resistance, + const unsigned char *pstr, size_t pstr_len, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int,rand_uninstantiate, (void *vdrbg)) +OSSL_CORE_MAKE_FUNC(int,rand_generate, + (void *vctx, unsigned char *out, size_t outlen, + unsigned int strength, int prediction_resistance, + const unsigned char *addin, size_t addin_len)) +OSSL_CORE_MAKE_FUNC(int,rand_reseed, + (void *vctx, int prediction_resistance, + const unsigned char *ent, size_t ent_len, + const unsigned char *addin, size_t addin_len)) +OSSL_CORE_MAKE_FUNC(size_t,rand_nonce, + (void *vctx, unsigned char *out, unsigned int strength, + size_t min_noncelen, size_t max_noncelen)) +OSSL_CORE_MAKE_FUNC(int,rand_enable_locking, (void *vctx)) +OSSL_CORE_MAKE_FUNC(int,rand_lock, (void *vctx)) +OSSL_CORE_MAKE_FUNC(void,rand_unlock, (void *vctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_gettable_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_gettable_ctx_params, + (void *vctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_settable_ctx_params, + (void *vctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int,rand_get_params, (OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int,rand_get_ctx_params, + (void *vctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int,rand_set_ctx_params, + (void *vctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(void,rand_set_callbacks, + (void *vctx, OSSL_INOUT_CALLBACK *get_entropy, + OSSL_CALLBACK *cleanup_entropy, + OSSL_INOUT_CALLBACK *get_nonce, + OSSL_CALLBACK *cleanup_nonce, void *arg)) +OSSL_CORE_MAKE_FUNC(int,rand_verify_zeroization, + (void *vctx)) +OSSL_CORE_MAKE_FUNC(size_t,rand_get_seed, + (void *vctx, unsigned char **buffer, + int entropy, size_t min_len, size_t max_len, + int prediction_resistance, + const unsigned char *adin, size_t adin_len)) +OSSL_CORE_MAKE_FUNC(void,rand_clear_seed, + (void *vctx, unsigned char *buffer, size_t b_len)) + +/*- + * Key management + * + * The Key Management takes care of provider side key objects, and includes + * all current functionality to create them, destroy them, set parameters + * and key material, etc, essentially everything that manipulates the keys + * themselves and their parameters. + * + * The key objects are commonly referred to as |keydata|, and it MUST be able + * to contain parameters if the key has any, the public key and the private + * key. All parts are optional, but their presence determines what can be + * done with the key object in terms of encryption, signature, and so on. + * The assumption from libcrypto is that the key object contains any of the + * following data combinations: + * + * - parameters only + * - public key only + * - public key + private key + * - parameters + public key + * - parameters + public key + private key + * + * What "parameters", "public key" and "private key" means in detail is left + * to the implementation. In the case of DH and DSA, they would typically + * include domain parameters, while for certain variants of RSA, they would + * typically include PSS or OAEP parameters. + * + * Key objects are created with OSSL_FUNC_keymgmt_new() and destroyed with + * OSSL_FUNC_keymgmt_free(). Key objects can have data filled in with + * OSSL_FUNC_keymgmt_import(). + * + * Three functions are made available to check what selection of data is + * present in a key object: OSSL_FUNC_keymgmt_has_parameters(), + * OSSL_FUNC_keymgmt_has_public_key(), and OSSL_FUNC_keymgmt_has_private_key(), + */ + +/* Key data subset selection - individual bits */ +# define OSSL_KEYMGMT_SELECT_PRIVATE_KEY 0x01 +# define OSSL_KEYMGMT_SELECT_PUBLIC_KEY 0x02 +# define OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS 0x04 +# define OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS 0x80 + +/* Key data subset selection - combinations */ +# define OSSL_KEYMGMT_SELECT_ALL_PARAMETERS \ + ( OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS \ + | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) +# define OSSL_KEYMGMT_SELECT_KEYPAIR \ + ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY | OSSL_KEYMGMT_SELECT_PUBLIC_KEY ) +# define OSSL_KEYMGMT_SELECT_ALL \ + ( OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS ) + +# define OSSL_KEYMGMT_VALIDATE_FULL_CHECK 0 +# define OSSL_KEYMGMT_VALIDATE_QUICK_CHECK 1 + +/* Basic key object creation */ +# define OSSL_FUNC_KEYMGMT_NEW 1 +OSSL_CORE_MAKE_FUNC(void *, keymgmt_new, (void *provctx)) + +/* Generation, a more complex constructor */ +# define OSSL_FUNC_KEYMGMT_GEN_INIT 2 +# define OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE 3 +# define OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS 4 +# define OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS 5 +# define OSSL_FUNC_KEYMGMT_GEN 6 +# define OSSL_FUNC_KEYMGMT_GEN_CLEANUP 7 +# define OSSL_FUNC_KEYMGMT_GEN_GET_PARAMS 15 +# define OSSL_FUNC_KEYMGMT_GEN_GETTABLE_PARAMS 16 + +OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen_init, + (void *provctx, int selection, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_template, + (void *genctx, void *templ)) +OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_params, + (void *genctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, + keymgmt_gen_settable_params, + (void *genctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_get_params, + (void *genctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gen_gettable_params, + (void *genctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen, + (void *genctx, OSSL_CALLBACK *cb, void *cbarg)) +OSSL_CORE_MAKE_FUNC(void, keymgmt_gen_cleanup, (void *genctx)) + +/* Key loading by object reference */ +# define OSSL_FUNC_KEYMGMT_LOAD 8 +OSSL_CORE_MAKE_FUNC(void *, keymgmt_load, + (const void *reference, size_t reference_sz)) + +/* Basic key object destruction */ +# define OSSL_FUNC_KEYMGMT_FREE 10 +OSSL_CORE_MAKE_FUNC(void, keymgmt_free, (void *keydata)) + +/* Key object information, with discovery */ +#define OSSL_FUNC_KEYMGMT_GET_PARAMS 11 +#define OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS 12 +OSSL_CORE_MAKE_FUNC(int, keymgmt_get_params, + (void *keydata, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gettable_params, + (void *provctx)) + +#define OSSL_FUNC_KEYMGMT_SET_PARAMS 13 +#define OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS 14 +OSSL_CORE_MAKE_FUNC(int, keymgmt_set_params, + (void *keydata, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_settable_params, + (void *provctx)) + +/* Key checks - discovery of supported operations */ +# define OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME 20 +OSSL_CORE_MAKE_FUNC(const char *, keymgmt_query_operation_name, + (int operation_id)) + +/* Key checks - key data content checks */ +# define OSSL_FUNC_KEYMGMT_HAS 21 +OSSL_CORE_MAKE_FUNC(int, keymgmt_has, (const void *keydata, int selection)) + +/* Key checks - validation */ +# define OSSL_FUNC_KEYMGMT_VALIDATE 22 +OSSL_CORE_MAKE_FUNC(int, keymgmt_validate, (const void *keydata, int selection, + int checktype)) + +/* Key checks - matching */ +# define OSSL_FUNC_KEYMGMT_MATCH 23 +OSSL_CORE_MAKE_FUNC(int, keymgmt_match, + (const void *keydata1, const void *keydata2, + int selection)) + +/* Import and export functions, with discovery */ +# define OSSL_FUNC_KEYMGMT_IMPORT 40 +# define OSSL_FUNC_KEYMGMT_IMPORT_TYPES 41 +# define OSSL_FUNC_KEYMGMT_EXPORT 42 +# define OSSL_FUNC_KEYMGMT_EXPORT_TYPES 43 +OSSL_CORE_MAKE_FUNC(int, keymgmt_import, + (void *keydata, int selection, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_import_types, + (int selection)) +OSSL_CORE_MAKE_FUNC(int, keymgmt_export, + (void *keydata, int selection, + OSSL_CALLBACK *param_cb, void *cbarg)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_export_types, + (int selection)) + +/* Dup function, constructor */ +# define OSSL_FUNC_KEYMGMT_DUP 44 +OSSL_CORE_MAKE_FUNC(void *, keymgmt_dup, + (const void *keydata_from, int selection)) + +/* Extended import and export functions */ +# define OSSL_FUNC_KEYMGMT_IMPORT_TYPES_EX 45 +# define OSSL_FUNC_KEYMGMT_EXPORT_TYPES_EX 46 +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_import_types_ex, + (void *provctx, int selection)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_export_types_ex, + (void *provctx, int selection)) + +/* Key Exchange */ + +# define OSSL_FUNC_KEYEXCH_NEWCTX 1 +# define OSSL_FUNC_KEYEXCH_INIT 2 +# define OSSL_FUNC_KEYEXCH_DERIVE 3 +# define OSSL_FUNC_KEYEXCH_SET_PEER 4 +# define OSSL_FUNC_KEYEXCH_FREECTX 5 +# define OSSL_FUNC_KEYEXCH_DUPCTX 6 +# define OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS 7 +# define OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS 8 +# define OSSL_FUNC_KEYEXCH_GET_CTX_PARAMS 9 +# define OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS 10 + +OSSL_CORE_MAKE_FUNC(void *, keyexch_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, keyexch_init, (void *ctx, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, keyexch_derive, (void *ctx, unsigned char *secret, + size_t *secretlen, size_t outlen)) +OSSL_CORE_MAKE_FUNC(int, keyexch_set_peer, (void *ctx, void *provkey)) +OSSL_CORE_MAKE_FUNC(void, keyexch_freectx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(void *, keyexch_dupctx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, keyexch_set_ctx_params, (void *ctx, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_settable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, keyexch_get_ctx_params, (void *ctx, + OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_gettable_ctx_params, + (void *ctx, void *provctx)) + +/* Signature */ + +# define OSSL_FUNC_SIGNATURE_NEWCTX 1 +# define OSSL_FUNC_SIGNATURE_SIGN_INIT 2 +# define OSSL_FUNC_SIGNATURE_SIGN 3 +# define OSSL_FUNC_SIGNATURE_VERIFY_INIT 4 +# define OSSL_FUNC_SIGNATURE_VERIFY 5 +# define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT 6 +# define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER 7 +# define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT 8 +# define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE 9 +# define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL 10 +# define OSSL_FUNC_SIGNATURE_DIGEST_SIGN 11 +# define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT 12 +# define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE 13 +# define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL 14 +# define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY 15 +# define OSSL_FUNC_SIGNATURE_FREECTX 16 +# define OSSL_FUNC_SIGNATURE_DUPCTX 17 +# define OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS 18 +# define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS 19 +# define OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS 20 +# define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS 21 +# define OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS 22 +# define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS 23 +# define OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS 24 +# define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS 25 +# define OSSL_FUNC_SIGNATURE_QUERY_KEY_TYPES 26 +# define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_INIT 27 +# define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_UPDATE 28 +# define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_FINAL 29 +# define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_INIT 30 +# define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_UPDATE 31 +# define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_FINAL 32 + +OSSL_CORE_MAKE_FUNC(void *, signature_newctx, (void *provctx, + const char *propq)) +OSSL_CORE_MAKE_FUNC(int, signature_sign_init, (void *ctx, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, signature_sign, (void *ctx, unsigned char *sig, + size_t *siglen, size_t sigsize, + const unsigned char *tbs, + size_t tbslen)) +OSSL_CORE_MAKE_FUNC(int, signature_sign_message_init, + (void *ctx, void *provkey, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, signature_sign_message_update, + (void *ctx, const unsigned char *in, size_t inlen)) +OSSL_CORE_MAKE_FUNC(int, signature_sign_message_final, + (void *ctx, unsigned char *sig, + size_t *siglen, size_t sigsize)) +OSSL_CORE_MAKE_FUNC(int, signature_verify_init, (void *ctx, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, signature_verify, (void *ctx, + const unsigned char *sig, + size_t siglen, + const unsigned char *tbs, + size_t tbslen)) +OSSL_CORE_MAKE_FUNC(int, signature_verify_message_init, + (void *ctx, void *provkey, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, signature_verify_message_update, + (void *ctx, const unsigned char *in, size_t inlen)) +/* + * signature_verify_final requires that the signature to be verified against + * is specified via an OSSL_PARAM. + */ +OSSL_CORE_MAKE_FUNC(int, signature_verify_message_final, (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, signature_verify_recover_init, + (void *ctx, void *provkey, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, signature_verify_recover, + (void *ctx, unsigned char *rout, size_t *routlen, + size_t routsize, const unsigned char *sig, size_t siglen)) +OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_init, + (void *ctx, const char *mdname, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_update, + (void *ctx, const unsigned char *data, size_t datalen)) +OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_final, + (void *ctx, unsigned char *sig, size_t *siglen, + size_t sigsize)) +OSSL_CORE_MAKE_FUNC(int, signature_digest_sign, + (void *ctx, unsigned char *sigret, size_t *siglen, + size_t sigsize, const unsigned char *tbs, size_t tbslen)) +OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_init, + (void *ctx, const char *mdname, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_update, + (void *ctx, const unsigned char *data, size_t datalen)) +OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_final, + (void *ctx, const unsigned char *sig, size_t siglen)) +OSSL_CORE_MAKE_FUNC(int, signature_digest_verify, + (void *ctx, const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen)) +OSSL_CORE_MAKE_FUNC(void, signature_freectx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(void *, signature_dupctx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_params, + (void *ctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_md_params, + (void *ctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_md_params, + (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_md_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_md_params, + (void *ctx)) +OSSL_CORE_MAKE_FUNC(const char **, signature_query_key_types, (void)) + +/*- + * Symmetric key management + * + * The Key Management takes care of provider side of symmetric key objects, and + * includes essentially everything that manipulates the keys themselves and + * their parameters. + * + * The key objects are commonly referred to as |keydata|, and it MUST be able + * to contain parameters if the key has any, and the secret key. + * + * Key objects are created with OSSL_FUNC_skeymgmt_import() (there is no + * dedicated memory allocation function), exported with + * OSSL_FUNC_skeymgmt_export() and destroyed with OSSL_FUNC_keymgmt_free(). + * + */ + +/* Key data subset selection - individual bits */ +# define OSSL_SKEYMGMT_SELECT_PARAMETERS 0x01 +# define OSSL_SKEYMGMT_SELECT_SECRET_KEY 0x02 + +/* Key data subset selection - combinations */ +# define OSSL_SKEYMGMT_SELECT_ALL \ + (OSSL_SKEYMGMT_SELECT_PARAMETERS | OSSL_SKEYMGMT_SELECT_SECRET_KEY) + +# define OSSL_FUNC_SKEYMGMT_FREE 1 +# define OSSL_FUNC_SKEYMGMT_IMPORT 2 +# define OSSL_FUNC_SKEYMGMT_EXPORT 3 +# define OSSL_FUNC_SKEYMGMT_GENERATE 4 +# define OSSL_FUNC_SKEYMGMT_GET_KEY_ID 5 +# define OSSL_FUNC_SKEYMGMT_IMP_SETTABLE_PARAMS 6 +# define OSSL_FUNC_SKEYMGMT_GEN_SETTABLE_PARAMS 7 + +OSSL_CORE_MAKE_FUNC(void, skeymgmt_free, (void *keydata)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, + skeymgmt_imp_settable_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(void *, skeymgmt_import, (void *provctx, int selection, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, skeymgmt_export, + (void *keydata, int selection, + OSSL_CALLBACK *param_cb, void *cbarg)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, + skeymgmt_gen_settable_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(void *, skeymgmt_generate, (void *provctx, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const char *, skeymgmt_get_key_id, (void *keydata)) + +/* Asymmetric Ciphers */ + +# define OSSL_FUNC_ASYM_CIPHER_NEWCTX 1 +# define OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT 2 +# define OSSL_FUNC_ASYM_CIPHER_ENCRYPT 3 +# define OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT 4 +# define OSSL_FUNC_ASYM_CIPHER_DECRYPT 5 +# define OSSL_FUNC_ASYM_CIPHER_FREECTX 6 +# define OSSL_FUNC_ASYM_CIPHER_DUPCTX 7 +# define OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS 8 +# define OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS 9 +# define OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS 10 +# define OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS 11 + +OSSL_CORE_MAKE_FUNC(void *, asym_cipher_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, asym_cipher_encrypt_init, (void *ctx, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, asym_cipher_encrypt, (void *ctx, unsigned char *out, + size_t *outlen, + size_t outsize, + const unsigned char *in, + size_t inlen)) +OSSL_CORE_MAKE_FUNC(int, asym_cipher_decrypt_init, (void *ctx, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, asym_cipher_decrypt, (void *ctx, unsigned char *out, + size_t *outlen, + size_t outsize, + const unsigned char *in, + size_t inlen)) +OSSL_CORE_MAKE_FUNC(void, asym_cipher_freectx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(void *, asym_cipher_dupctx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, asym_cipher_get_ctx_params, + (void *ctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_gettable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, asym_cipher_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_settable_ctx_params, + (void *ctx, void *provctx)) + +/* Asymmetric Key encapsulation */ +# define OSSL_FUNC_KEM_NEWCTX 1 +# define OSSL_FUNC_KEM_ENCAPSULATE_INIT 2 +# define OSSL_FUNC_KEM_ENCAPSULATE 3 +# define OSSL_FUNC_KEM_DECAPSULATE_INIT 4 +# define OSSL_FUNC_KEM_DECAPSULATE 5 +# define OSSL_FUNC_KEM_FREECTX 6 +# define OSSL_FUNC_KEM_DUPCTX 7 +# define OSSL_FUNC_KEM_GET_CTX_PARAMS 8 +# define OSSL_FUNC_KEM_GETTABLE_CTX_PARAMS 9 +# define OSSL_FUNC_KEM_SET_CTX_PARAMS 10 +# define OSSL_FUNC_KEM_SETTABLE_CTX_PARAMS 11 +# define OSSL_FUNC_KEM_AUTH_ENCAPSULATE_INIT 12 +# define OSSL_FUNC_KEM_AUTH_DECAPSULATE_INIT 13 + +OSSL_CORE_MAKE_FUNC(void *, kem_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, kem_encapsulate_init, (void *ctx, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, kem_auth_encapsulate_init, (void *ctx, void *provkey, + void *authprivkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, kem_encapsulate, (void *ctx, + unsigned char *out, size_t *outlen, + unsigned char *secret, + size_t *secretlen)) +OSSL_CORE_MAKE_FUNC(int, kem_decapsulate_init, (void *ctx, void *provkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, kem_auth_decapsulate_init, (void *ctx, void *provkey, + void *authpubkey, + const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, kem_decapsulate, (void *ctx, + unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)) +OSSL_CORE_MAKE_FUNC(void, kem_freectx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(void *, kem_dupctx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, kem_get_ctx_params, (void *ctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_gettable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, kem_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_settable_ctx_params, + (void *ctx, void *provctx)) + +/* Encoders and decoders */ +# define OSSL_FUNC_ENCODER_NEWCTX 1 +# define OSSL_FUNC_ENCODER_FREECTX 2 +# define OSSL_FUNC_ENCODER_GET_PARAMS 3 +# define OSSL_FUNC_ENCODER_GETTABLE_PARAMS 4 +# define OSSL_FUNC_ENCODER_SET_CTX_PARAMS 5 +# define OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS 6 +# define OSSL_FUNC_ENCODER_DOES_SELECTION 10 +# define OSSL_FUNC_ENCODER_ENCODE 11 +# define OSSL_FUNC_ENCODER_IMPORT_OBJECT 20 +# define OSSL_FUNC_ENCODER_FREE_OBJECT 21 +OSSL_CORE_MAKE_FUNC(void *, encoder_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(void, encoder_freectx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, encoder_get_params, (OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_gettable_params, + (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, encoder_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_settable_ctx_params, + (void *provctx)) + +OSSL_CORE_MAKE_FUNC(int, encoder_does_selection, + (void *provctx, int selection)) +OSSL_CORE_MAKE_FUNC(int, encoder_encode, + (void *ctx, OSSL_CORE_BIO *out, + const void *obj_raw, const OSSL_PARAM obj_abstract[], + int selection, + OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)) + +OSSL_CORE_MAKE_FUNC(void *, encoder_import_object, + (void *ctx, int selection, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(void, encoder_free_object, (void *obj)) + +# define OSSL_FUNC_DECODER_NEWCTX 1 +# define OSSL_FUNC_DECODER_FREECTX 2 +# define OSSL_FUNC_DECODER_GET_PARAMS 3 +# define OSSL_FUNC_DECODER_GETTABLE_PARAMS 4 +# define OSSL_FUNC_DECODER_SET_CTX_PARAMS 5 +# define OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS 6 +# define OSSL_FUNC_DECODER_DOES_SELECTION 10 +# define OSSL_FUNC_DECODER_DECODE 11 +# define OSSL_FUNC_DECODER_EXPORT_OBJECT 20 +OSSL_CORE_MAKE_FUNC(void *, decoder_newctx, (void *provctx)) +OSSL_CORE_MAKE_FUNC(void, decoder_freectx, (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, decoder_get_params, (OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_gettable_params, + (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, decoder_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_settable_ctx_params, + (void *provctx)) + +OSSL_CORE_MAKE_FUNC(int, decoder_does_selection, + (void *provctx, int selection)) +OSSL_CORE_MAKE_FUNC(int, decoder_decode, + (void *ctx, OSSL_CORE_BIO *in, int selection, + OSSL_CALLBACK *data_cb, void *data_cbarg, + OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) +OSSL_CORE_MAKE_FUNC(int, decoder_export_object, + (void *ctx, const void *objref, size_t objref_sz, + OSSL_CALLBACK *export_cb, void *export_cbarg)) + +/*- + * Store + * + * Objects are scanned by using the 'open', 'load', 'eof' and 'close' + * functions, which implement an OSSL_STORE loader. + * + * store_load() works in a way that's very similar to the decoders, in + * that they pass an abstract object through a callback, either as a DER + * octet string or as an object reference, which libcrypto will have to + * deal with. + */ + +#define OSSL_FUNC_STORE_OPEN 1 +#define OSSL_FUNC_STORE_ATTACH 2 +#define OSSL_FUNC_STORE_SETTABLE_CTX_PARAMS 3 +#define OSSL_FUNC_STORE_SET_CTX_PARAMS 4 +#define OSSL_FUNC_STORE_LOAD 5 +#define OSSL_FUNC_STORE_EOF 6 +#define OSSL_FUNC_STORE_CLOSE 7 +#define OSSL_FUNC_STORE_EXPORT_OBJECT 8 +#define OSSL_FUNC_STORE_DELETE 9 +#define OSSL_FUNC_STORE_OPEN_EX 10 +OSSL_CORE_MAKE_FUNC(void *, store_open, (void *provctx, const char *uri)) +OSSL_CORE_MAKE_FUNC(void *, store_attach, (void *provctx, OSSL_CORE_BIO *in)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, store_settable_ctx_params, + (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, store_set_ctx_params, + (void *loaderctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, store_load, + (void *loaderctx, + OSSL_CALLBACK *object_cb, void *object_cbarg, + OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) +OSSL_CORE_MAKE_FUNC(int, store_eof, (void *loaderctx)) +OSSL_CORE_MAKE_FUNC(int, store_close, (void *loaderctx)) +OSSL_CORE_MAKE_FUNC(int, store_export_object, + (void *loaderctx, const void *objref, size_t objref_sz, + OSSL_CALLBACK *export_cb, void *export_cbarg)) +OSSL_CORE_MAKE_FUNC(int, store_delete, + (void *provctx, const char *uri, const OSSL_PARAM params[], + OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) +OSSL_CORE_MAKE_FUNC(void *, store_open_ex, + (void *provctx, const char *uri, const OSSL_PARAM params[], + OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/core_names.h b/illumos-x86_64/usr/include/openssl-3/core_names.h new file mode 100644 index 00000000..e93e79a5 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/core_names.h @@ -0,0 +1,575 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/core_names.h.in + * + * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + +#ifndef OPENSSL_CORE_NAMES_H +# define OPENSSL_CORE_NAMES_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +/* OSSL_CIPHER_PARAM_CTS_MODE Values */ +# define OSSL_CIPHER_CTS_MODE_CS1 "CS1" +# define OSSL_CIPHER_CTS_MODE_CS2 "CS2" +# define OSSL_CIPHER_CTS_MODE_CS3 "CS3" + +/* Known CIPHER names (not a complete list) */ +# define OSSL_CIPHER_NAME_AES_128_GCM_SIV "AES-128-GCM-SIV" +# define OSSL_CIPHER_NAME_AES_192_GCM_SIV "AES-192-GCM-SIV" +# define OSSL_CIPHER_NAME_AES_256_GCM_SIV "AES-256-GCM-SIV" + +/* Known DIGEST names (not a complete list) */ +# define OSSL_DIGEST_NAME_MD5 "MD5" +# define OSSL_DIGEST_NAME_MD5_SHA1 "MD5-SHA1" +# define OSSL_DIGEST_NAME_SHA1 "SHA1" +# define OSSL_DIGEST_NAME_SHA2_224 "SHA2-224" +# define OSSL_DIGEST_NAME_SHA2_256 "SHA2-256" +# define OSSL_DIGEST_NAME_SHA2_256_192 "SHA2-256/192" +# define OSSL_DIGEST_NAME_SHA2_384 "SHA2-384" +# define OSSL_DIGEST_NAME_SHA2_512 "SHA2-512" +# define OSSL_DIGEST_NAME_SHA2_512_224 "SHA2-512/224" +# define OSSL_DIGEST_NAME_SHA2_512_256 "SHA2-512/256" +# define OSSL_DIGEST_NAME_MD2 "MD2" +# define OSSL_DIGEST_NAME_MD4 "MD4" +# define OSSL_DIGEST_NAME_MDC2 "MDC2" +# define OSSL_DIGEST_NAME_RIPEMD160 "RIPEMD160" +# define OSSL_DIGEST_NAME_SHA3_224 "SHA3-224" +# define OSSL_DIGEST_NAME_SHA3_256 "SHA3-256" +# define OSSL_DIGEST_NAME_SHA3_384 "SHA3-384" +# define OSSL_DIGEST_NAME_SHA3_512 "SHA3-512" +# define OSSL_DIGEST_NAME_KECCAK_KMAC128 "KECCAK-KMAC-128" +# define OSSL_DIGEST_NAME_KECCAK_KMAC256 "KECCAK-KMAC-256" +# define OSSL_DIGEST_NAME_SM3 "SM3" + +/* Known MAC names */ +# define OSSL_MAC_NAME_BLAKE2BMAC "BLAKE2BMAC" +# define OSSL_MAC_NAME_BLAKE2SMAC "BLAKE2SMAC" +# define OSSL_MAC_NAME_CMAC "CMAC" +# define OSSL_MAC_NAME_GMAC "GMAC" +# define OSSL_MAC_NAME_HMAC "HMAC" +# define OSSL_MAC_NAME_KMAC128 "KMAC128" +# define OSSL_MAC_NAME_KMAC256 "KMAC256" +# define OSSL_MAC_NAME_POLY1305 "POLY1305" +# define OSSL_MAC_NAME_SIPHASH "SIPHASH" + +/* Known KDF names */ +# define OSSL_KDF_NAME_HKDF "HKDF" +# define OSSL_KDF_NAME_TLS1_3_KDF "TLS13-KDF" +# define OSSL_KDF_NAME_PBKDF1 "PBKDF1" +# define OSSL_KDF_NAME_PBKDF2 "PBKDF2" +# define OSSL_KDF_NAME_SCRYPT "SCRYPT" +# define OSSL_KDF_NAME_SSHKDF "SSHKDF" +# define OSSL_KDF_NAME_SSKDF "SSKDF" +# define OSSL_KDF_NAME_TLS1_PRF "TLS1-PRF" +# define OSSL_KDF_NAME_X942KDF_ASN1 "X942KDF-ASN1" +# define OSSL_KDF_NAME_X942KDF_CONCAT "X942KDF-CONCAT" +# define OSSL_KDF_NAME_X963KDF "X963KDF" +# define OSSL_KDF_NAME_KBKDF "KBKDF" +# define OSSL_KDF_NAME_KRB5KDF "KRB5KDF" +# define OSSL_KDF_NAME_HMACDRBGKDF "HMAC-DRBG-KDF" + +/* RSA padding modes */ +# define OSSL_PKEY_RSA_PAD_MODE_NONE "none" +# define OSSL_PKEY_RSA_PAD_MODE_PKCSV15 "pkcs1" +# define OSSL_PKEY_RSA_PAD_MODE_OAEP "oaep" +# define OSSL_PKEY_RSA_PAD_MODE_X931 "x931" +# define OSSL_PKEY_RSA_PAD_MODE_PSS "pss" + +/* RSA pss padding salt length */ +# define OSSL_PKEY_RSA_PSS_SALT_LEN_DIGEST "digest" +# define OSSL_PKEY_RSA_PSS_SALT_LEN_MAX "max" +# define OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO "auto" +# define OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO_DIGEST_MAX "auto-digestmax" + +/* OSSL_PKEY_PARAM_EC_ENCODING values */ +# define OSSL_PKEY_EC_ENCODING_EXPLICIT "explicit" +# define OSSL_PKEY_EC_ENCODING_GROUP "named_curve" + +# define OSSL_PKEY_EC_POINT_CONVERSION_FORMAT_UNCOMPRESSED "uncompressed" +# define OSSL_PKEY_EC_POINT_CONVERSION_FORMAT_COMPRESSED "compressed" +# define OSSL_PKEY_EC_POINT_CONVERSION_FORMAT_HYBRID "hybrid" + +# define OSSL_PKEY_EC_GROUP_CHECK_DEFAULT "default" +# define OSSL_PKEY_EC_GROUP_CHECK_NAMED "named" +# define OSSL_PKEY_EC_GROUP_CHECK_NAMED_NIST "named-nist" + +/* PROV_SKEY well known key types */ +# define OSSL_SKEY_TYPE_GENERIC "GENERIC-SECRET" +# define OSSL_SKEY_TYPE_AES "AES" + +/* OSSL_KEM_PARAM_OPERATION values */ +#define OSSL_KEM_PARAM_OPERATION_RSASVE "RSASVE" +#define OSSL_KEM_PARAM_OPERATION_DHKEM "DHKEM" + +/* Provider configuration variables */ +#define OSSL_PKEY_RETAIN_SEED "pkey_retain_seed" + +/* Parameter name definitions - generated by util/perl/OpenSSL/paramnames.pm */ +# define OSSL_ALG_PARAM_ALGORITHM_ID "algorithm-id" +# define OSSL_ALG_PARAM_ALGORITHM_ID_PARAMS "algorithm-id-params" +# define OSSL_ALG_PARAM_CIPHER "cipher" +# define OSSL_ALG_PARAM_DIGEST "digest" +# define OSSL_ALG_PARAM_ENGINE "engine" +# define OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR "fips-indicator" +# define OSSL_ALG_PARAM_MAC "mac" +# define OSSL_ALG_PARAM_PROPERTIES "properties" +# define OSSL_ASYM_CIPHER_PARAM_DIGEST OSSL_PKEY_PARAM_DIGEST +# define OSSL_ASYM_CIPHER_PARAM_ENGINE OSSL_PKEY_PARAM_ENGINE +# define OSSL_ASYM_CIPHER_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_ASYM_CIPHER_PARAM_FIPS_KEY_CHECK OSSL_PKEY_PARAM_FIPS_KEY_CHECK +# define OSSL_ASYM_CIPHER_PARAM_FIPS_RSA_PKCS15_PAD_DISABLED OSSL_PROV_PARAM_RSA_PKCS15_PAD_DISABLED +# define OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION "implicit-rejection" +# define OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST OSSL_PKEY_PARAM_MGF1_DIGEST +# define OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS OSSL_PKEY_PARAM_MGF1_PROPERTIES +# define OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST OSSL_ALG_PARAM_DIGEST +# define OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS "digest-props" +# define OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL "oaep-label" +# define OSSL_ASYM_CIPHER_PARAM_PAD_MODE OSSL_PKEY_PARAM_PAD_MODE +# define OSSL_ASYM_CIPHER_PARAM_PROPERTIES OSSL_PKEY_PARAM_PROPERTIES +# define OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION "tls-client-version" +# define OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION "tls-negotiated-version" +# define OSSL_CAPABILITY_TLS_GROUP_ALG "tls-group-alg" +# define OSSL_CAPABILITY_TLS_GROUP_ID "tls-group-id" +# define OSSL_CAPABILITY_TLS_GROUP_IS_KEM "tls-group-is-kem" +# define OSSL_CAPABILITY_TLS_GROUP_MAX_DTLS "tls-max-dtls" +# define OSSL_CAPABILITY_TLS_GROUP_MAX_TLS "tls-max-tls" +# define OSSL_CAPABILITY_TLS_GROUP_MIN_DTLS "tls-min-dtls" +# define OSSL_CAPABILITY_TLS_GROUP_MIN_TLS "tls-min-tls" +# define OSSL_CAPABILITY_TLS_GROUP_NAME "tls-group-name" +# define OSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL "tls-group-name-internal" +# define OSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS "tls-group-sec-bits" +# define OSSL_CAPABILITY_TLS_SIGALG_CODE_POINT "tls-sigalg-code-point" +# define OSSL_CAPABILITY_TLS_SIGALG_HASH_NAME "tls-sigalg-hash-name" +# define OSSL_CAPABILITY_TLS_SIGALG_HASH_OID "tls-sigalg-hash-oid" +# define OSSL_CAPABILITY_TLS_SIGALG_IANA_NAME "tls-sigalg-iana-name" +# define OSSL_CAPABILITY_TLS_SIGALG_KEYTYPE "tls-sigalg-keytype" +# define OSSL_CAPABILITY_TLS_SIGALG_KEYTYPE_OID "tls-sigalg-keytype-oid" +# define OSSL_CAPABILITY_TLS_SIGALG_MAX_DTLS "tls-max-dtls" +# define OSSL_CAPABILITY_TLS_SIGALG_MAX_TLS "tls-max-tls" +# define OSSL_CAPABILITY_TLS_SIGALG_MIN_DTLS "tls-min-dtls" +# define OSSL_CAPABILITY_TLS_SIGALG_MIN_TLS "tls-min-tls" +# define OSSL_CAPABILITY_TLS_SIGALG_NAME "tls-sigalg-name" +# define OSSL_CAPABILITY_TLS_SIGALG_OID "tls-sigalg-oid" +# define OSSL_CAPABILITY_TLS_SIGALG_SECURITY_BITS "tls-sigalg-sec-bits" +# define OSSL_CAPABILITY_TLS_SIGALG_SIG_NAME "tls-sigalg-sig-name" +# define OSSL_CAPABILITY_TLS_SIGALG_SIG_OID "tls-sigalg-sig-oid" +# define OSSL_CIPHER_PARAM_AEAD "aead" +# define OSSL_CIPHER_PARAM_AEAD_IVLEN OSSL_CIPHER_PARAM_IVLEN +# define OSSL_CIPHER_PARAM_AEAD_IV_GENERATED "iv-generated" +# define OSSL_CIPHER_PARAM_AEAD_MAC_KEY "mackey" +# define OSSL_CIPHER_PARAM_AEAD_TAG "tag" +# define OSSL_CIPHER_PARAM_AEAD_TAGLEN "taglen" +# define OSSL_CIPHER_PARAM_AEAD_TLS1_AAD "tlsaad" +# define OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD "tlsaadpad" +# define OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN "tlsivgen" +# define OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED "tlsivfixed" +# define OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV "tlsivinv" +# define OSSL_CIPHER_PARAM_ALGORITHM_ID OSSL_ALG_PARAM_ALGORITHM_ID +# define OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS OSSL_ALG_PARAM_ALGORITHM_ID_PARAMS +# define OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS_OLD "alg_id_param" +# define OSSL_CIPHER_PARAM_BLOCK_SIZE "blocksize" +# define OSSL_CIPHER_PARAM_CTS "cts" +# define OSSL_CIPHER_PARAM_CTS_MODE "cts_mode" +# define OSSL_CIPHER_PARAM_CUSTOM_IV "custom-iv" +# define OSSL_CIPHER_PARAM_DECRYPT_ONLY "decrypt-only" +# define OSSL_CIPHER_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_CIPHER_PARAM_FIPS_ENCRYPT_CHECK "encrypt-check" +# define OSSL_CIPHER_PARAM_HAS_RAND_KEY "has-randkey" +# define OSSL_CIPHER_PARAM_IV "iv" +# define OSSL_CIPHER_PARAM_IVLEN "ivlen" +# define OSSL_CIPHER_PARAM_KEYLEN "keylen" +# define OSSL_CIPHER_PARAM_MODE "mode" +# define OSSL_CIPHER_PARAM_NUM "num" +# define OSSL_CIPHER_PARAM_PADDING "padding" +# define OSSL_CIPHER_PARAM_PIPELINE_AEAD_TAG "pipeline-tag" +# define OSSL_CIPHER_PARAM_RANDOM_KEY "randkey" +# define OSSL_CIPHER_PARAM_RC2_KEYBITS "keybits" +# define OSSL_CIPHER_PARAM_ROUNDS "rounds" +# define OSSL_CIPHER_PARAM_SPEED "speed" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK "tls-multi" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD "tls1multi_aad" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN "tls1multi_aadpacklen" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC "tls1multi_enc" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN "tls1multi_encin" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN "tls1multi_enclen" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE "tls1multi_interleave" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE "tls1multi_maxbufsz" +# define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT "tls1multi_maxsndfrag" +# define OSSL_CIPHER_PARAM_TLS_MAC "tls-mac" +# define OSSL_CIPHER_PARAM_TLS_MAC_SIZE "tls-mac-size" +# define OSSL_CIPHER_PARAM_TLS_VERSION "tls-version" +# define OSSL_CIPHER_PARAM_UPDATED_IV "updated-iv" +# define OSSL_CIPHER_PARAM_USE_BITS "use-bits" +# define OSSL_CIPHER_PARAM_XTS_STANDARD "xts_standard" +# define OSSL_DECODER_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES +# define OSSL_DIGEST_PARAM_ALGID_ABSENT "algid-absent" +# define OSSL_DIGEST_PARAM_BLOCK_SIZE "blocksize" +# define OSSL_DIGEST_PARAM_MICALG "micalg" +# define OSSL_DIGEST_PARAM_PAD_TYPE "pad-type" +# define OSSL_DIGEST_PARAM_SIZE "size" +# define OSSL_DIGEST_PARAM_SSL3_MS "ssl3-ms" +# define OSSL_DIGEST_PARAM_XOF "xof" +# define OSSL_DIGEST_PARAM_XOFLEN "xoflen" +# define OSSL_DRBG_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER +# define OSSL_DRBG_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST +# define OSSL_DRBG_PARAM_ENTROPY_REQUIRED "entropy_required" +# define OSSL_DRBG_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_DRBG_PARAM_FIPS_DIGEST_CHECK OSSL_PKEY_PARAM_FIPS_DIGEST_CHECK +# define OSSL_DRBG_PARAM_MAC OSSL_ALG_PARAM_MAC +# define OSSL_DRBG_PARAM_MAX_ADINLEN "max_adinlen" +# define OSSL_DRBG_PARAM_MAX_ENTROPYLEN "max_entropylen" +# define OSSL_DRBG_PARAM_MAX_LENGTH "maxium_length" +# define OSSL_DRBG_PARAM_MAX_NONCELEN "max_noncelen" +# define OSSL_DRBG_PARAM_MAX_PERSLEN "max_perslen" +# define OSSL_DRBG_PARAM_MIN_ENTROPYLEN "min_entropylen" +# define OSSL_DRBG_PARAM_MIN_LENGTH "minium_length" +# define OSSL_DRBG_PARAM_MIN_NONCELEN "min_noncelen" +# define OSSL_DRBG_PARAM_PREDICTION_RESISTANCE "prediction_resistance" +# define OSSL_DRBG_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES +# define OSSL_DRBG_PARAM_RANDOM_DATA "random_data" +# define OSSL_DRBG_PARAM_RESEED_COUNTER "reseed_counter" +# define OSSL_DRBG_PARAM_RESEED_REQUESTS "reseed_requests" +# define OSSL_DRBG_PARAM_RESEED_TIME "reseed_time" +# define OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL "reseed_time_interval" +# define OSSL_DRBG_PARAM_SIZE "size" +# define OSSL_DRBG_PARAM_USE_DF "use_derivation_function" +# define OSSL_ENCODER_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER +# define OSSL_ENCODER_PARAM_ENCRYPT_LEVEL "encrypt-level" +# define OSSL_ENCODER_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES +# define OSSL_ENCODER_PARAM_SAVE_PARAMETERS "save-parameters" +# define OSSL_EXCHANGE_PARAM_EC_ECDH_COFACTOR_MODE "ecdh-cofactor-mode" +# define OSSL_EXCHANGE_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_EXCHANGE_PARAM_FIPS_DIGEST_CHECK OSSL_PKEY_PARAM_FIPS_DIGEST_CHECK +# define OSSL_EXCHANGE_PARAM_FIPS_ECDH_COFACTOR_CHECK OSSL_PROV_PARAM_ECDH_COFACTOR_CHECK +# define OSSL_EXCHANGE_PARAM_FIPS_KEY_CHECK OSSL_PKEY_PARAM_FIPS_KEY_CHECK +# define OSSL_EXCHANGE_PARAM_KDF_DIGEST "kdf-digest" +# define OSSL_EXCHANGE_PARAM_KDF_DIGEST_PROPS "kdf-digest-props" +# define OSSL_EXCHANGE_PARAM_KDF_OUTLEN "kdf-outlen" +# define OSSL_EXCHANGE_PARAM_KDF_TYPE "kdf-type" +# define OSSL_EXCHANGE_PARAM_KDF_UKM "kdf-ukm" +# define OSSL_EXCHANGE_PARAM_PAD "pad" +# define OSSL_GEN_PARAM_ITERATION "iteration" +# define OSSL_GEN_PARAM_POTENTIAL "potential" +# define OSSL_KDF_PARAM_ARGON2_AD "ad" +# define OSSL_KDF_PARAM_ARGON2_LANES "lanes" +# define OSSL_KDF_PARAM_ARGON2_MEMCOST "memcost" +# define OSSL_KDF_PARAM_ARGON2_VERSION "version" +# define OSSL_KDF_PARAM_CEK_ALG "cekalg" +# define OSSL_KDF_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER +# define OSSL_KDF_PARAM_CONSTANT "constant" +# define OSSL_KDF_PARAM_DATA "data" +# define OSSL_KDF_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST +# define OSSL_KDF_PARAM_EARLY_CLEAN "early_clean" +# define OSSL_KDF_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_KDF_PARAM_FIPS_DIGEST_CHECK OSSL_PKEY_PARAM_FIPS_DIGEST_CHECK +# define OSSL_KDF_PARAM_FIPS_EMS_CHECK "ems_check" +# define OSSL_KDF_PARAM_FIPS_KEY_CHECK OSSL_PKEY_PARAM_FIPS_KEY_CHECK +# define OSSL_KDF_PARAM_HMACDRBG_ENTROPY "entropy" +# define OSSL_KDF_PARAM_HMACDRBG_NONCE "nonce" +# define OSSL_KDF_PARAM_INFO "info" +# define OSSL_KDF_PARAM_ITER "iter" +# define OSSL_KDF_PARAM_KBKDF_R "r" +# define OSSL_KDF_PARAM_KBKDF_USE_L "use-l" +# define OSSL_KDF_PARAM_KBKDF_USE_SEPARATOR "use-separator" +# define OSSL_KDF_PARAM_KEY "key" +# define OSSL_KDF_PARAM_LABEL "label" +# define OSSL_KDF_PARAM_MAC OSSL_ALG_PARAM_MAC +# define OSSL_KDF_PARAM_MAC_SIZE "maclen" +# define OSSL_KDF_PARAM_MODE "mode" +# define OSSL_KDF_PARAM_PASSWORD "pass" +# define OSSL_KDF_PARAM_PKCS12_ID "id" +# define OSSL_KDF_PARAM_PKCS5 "pkcs5" +# define OSSL_KDF_PARAM_PREFIX "prefix" +# define OSSL_KDF_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES +# define OSSL_KDF_PARAM_SALT "salt" +# define OSSL_KDF_PARAM_SCRYPT_MAXMEM "maxmem_bytes" +# define OSSL_KDF_PARAM_SCRYPT_N "n" +# define OSSL_KDF_PARAM_SCRYPT_P "p" +# define OSSL_KDF_PARAM_SCRYPT_R "r" +# define OSSL_KDF_PARAM_SECRET "secret" +# define OSSL_KDF_PARAM_SEED "seed" +# define OSSL_KDF_PARAM_SIZE "size" +# define OSSL_KDF_PARAM_SSHKDF_SESSION_ID "session_id" +# define OSSL_KDF_PARAM_SSHKDF_TYPE "type" +# define OSSL_KDF_PARAM_SSHKDF_XCGHASH "xcghash" +# define OSSL_KDF_PARAM_THREADS "threads" +# define OSSL_KDF_PARAM_UKM "ukm" +# define OSSL_KDF_PARAM_X942_ACVPINFO "acvp-info" +# define OSSL_KDF_PARAM_X942_PARTYUINFO "partyu-info" +# define OSSL_KDF_PARAM_X942_PARTYVINFO "partyv-info" +# define OSSL_KDF_PARAM_X942_SUPP_PRIVINFO "supp-privinfo" +# define OSSL_KDF_PARAM_X942_SUPP_PUBINFO "supp-pubinfo" +# define OSSL_KDF_PARAM_X942_USE_KEYBITS "use-keybits" +# define OSSL_KEM_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_KEM_PARAM_FIPS_KEY_CHECK OSSL_PKEY_PARAM_FIPS_KEY_CHECK +# define OSSL_KEM_PARAM_IKME "ikme" +# define OSSL_KEM_PARAM_OPERATION "operation" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_BLOCK_PADDING "block_padding" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_HS_PADDING "hs_padding" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_MAX_EARLY_DATA "max_early_data" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_MAX_FRAG_LEN "max_frag_len" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_MODE "mode" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_OPTIONS "options" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_READ_AHEAD "read_ahead" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_STREAM_MAC "stream_mac" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_TLSTREE "tlstree" +# define OSSL_LIBSSL_RECORD_LAYER_PARAM_USE_ETM "use_etm" +# define OSSL_LIBSSL_RECORD_LAYER_READ_BUFFER_LEN "read_buffer_len" +# define OSSL_MAC_PARAM_BLOCK_SIZE "block-size" +# define OSSL_MAC_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER +# define OSSL_MAC_PARAM_CUSTOM "custom" +# define OSSL_MAC_PARAM_C_ROUNDS "c-rounds" +# define OSSL_MAC_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST +# define OSSL_MAC_PARAM_DIGEST_NOINIT "digest-noinit" +# define OSSL_MAC_PARAM_DIGEST_ONESHOT "digest-oneshot" +# define OSSL_MAC_PARAM_D_ROUNDS "d-rounds" +# define OSSL_MAC_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_MAC_PARAM_FIPS_KEY_CHECK OSSL_PKEY_PARAM_FIPS_KEY_CHECK +# define OSSL_MAC_PARAM_FIPS_NO_SHORT_MAC OSSL_PROV_PARAM_NO_SHORT_MAC +# define OSSL_MAC_PARAM_IV "iv" +# define OSSL_MAC_PARAM_KEY "key" +# define OSSL_MAC_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES +# define OSSL_MAC_PARAM_SALT "salt" +# define OSSL_MAC_PARAM_SIZE "size" +# define OSSL_MAC_PARAM_TLS_DATA_SIZE "tls-data-size" +# define OSSL_MAC_PARAM_XOF "xof" +# define OSSL_OBJECT_PARAM_DATA "data" +# define OSSL_OBJECT_PARAM_DATA_STRUCTURE "data-structure" +# define OSSL_OBJECT_PARAM_DATA_TYPE "data-type" +# define OSSL_OBJECT_PARAM_DESC "desc" +# define OSSL_OBJECT_PARAM_INPUT_TYPE "input-type" +# define OSSL_OBJECT_PARAM_REFERENCE "reference" +# define OSSL_OBJECT_PARAM_TYPE "type" +# define OSSL_PASSPHRASE_PARAM_INFO "info" +# define OSSL_PKEY_PARAM_ALGORITHM_ID OSSL_ALG_PARAM_ALGORITHM_ID +# define OSSL_PKEY_PARAM_ALGORITHM_ID_PARAMS OSSL_ALG_PARAM_ALGORITHM_ID_PARAMS +# define OSSL_PKEY_PARAM_BITS "bits" +# define OSSL_PKEY_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER +# define OSSL_PKEY_PARAM_DEFAULT_DIGEST "default-digest" +# define OSSL_PKEY_PARAM_DHKEM_IKM "dhkem-ikm" +# define OSSL_PKEY_PARAM_DH_GENERATOR "safeprime-generator" +# define OSSL_PKEY_PARAM_DH_PRIV_LEN "priv_len" +# define OSSL_PKEY_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST +# define OSSL_PKEY_PARAM_DIGEST_SIZE "digest-size" +# define OSSL_PKEY_PARAM_DIST_ID "distid" +# define OSSL_PKEY_PARAM_EC_A "a" +# define OSSL_PKEY_PARAM_EC_B "b" +# define OSSL_PKEY_PARAM_EC_CHAR2_M "m" +# define OSSL_PKEY_PARAM_EC_CHAR2_PP_K1 "k1" +# define OSSL_PKEY_PARAM_EC_CHAR2_PP_K2 "k2" +# define OSSL_PKEY_PARAM_EC_CHAR2_PP_K3 "k3" +# define OSSL_PKEY_PARAM_EC_CHAR2_TP_BASIS "tp" +# define OSSL_PKEY_PARAM_EC_CHAR2_TYPE "basis-type" +# define OSSL_PKEY_PARAM_EC_COFACTOR "cofactor" +# define OSSL_PKEY_PARAM_EC_DECODED_FROM_EXPLICIT_PARAMS "decoded-from-explicit" +# define OSSL_PKEY_PARAM_EC_ENCODING "encoding" +# define OSSL_PKEY_PARAM_EC_FIELD_TYPE "field-type" +# define OSSL_PKEY_PARAM_EC_GENERATOR "generator" +# define OSSL_PKEY_PARAM_EC_GROUP_CHECK_TYPE "group-check" +# define OSSL_PKEY_PARAM_EC_INCLUDE_PUBLIC "include-public" +# define OSSL_PKEY_PARAM_EC_ORDER "order" +# define OSSL_PKEY_PARAM_EC_P "p" +# define OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT "point-format" +# define OSSL_PKEY_PARAM_EC_PUB_X "qx" +# define OSSL_PKEY_PARAM_EC_PUB_Y "qy" +# define OSSL_PKEY_PARAM_EC_SEED "seed" +# define OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY "encoded-pub-key" +# define OSSL_PKEY_PARAM_ENGINE OSSL_ALG_PARAM_ENGINE +# define OSSL_PKEY_PARAM_FFC_COFACTOR "j" +# define OSSL_PKEY_PARAM_FFC_DIGEST OSSL_PKEY_PARAM_DIGEST +# define OSSL_PKEY_PARAM_FFC_DIGEST_PROPS OSSL_PKEY_PARAM_PROPERTIES +# define OSSL_PKEY_PARAM_FFC_G "g" +# define OSSL_PKEY_PARAM_FFC_GINDEX "gindex" +# define OSSL_PKEY_PARAM_FFC_H "hindex" +# define OSSL_PKEY_PARAM_FFC_P "p" +# define OSSL_PKEY_PARAM_FFC_PBITS "pbits" +# define OSSL_PKEY_PARAM_FFC_PCOUNTER "pcounter" +# define OSSL_PKEY_PARAM_FFC_Q "q" +# define OSSL_PKEY_PARAM_FFC_QBITS "qbits" +# define OSSL_PKEY_PARAM_FFC_SEED "seed" +# define OSSL_PKEY_PARAM_FFC_TYPE "type" +# define OSSL_PKEY_PARAM_FFC_VALIDATE_G "validate-g" +# define OSSL_PKEY_PARAM_FFC_VALIDATE_LEGACY "validate-legacy" +# define OSSL_PKEY_PARAM_FFC_VALIDATE_PQ "validate-pq" +# define OSSL_PKEY_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_PKEY_PARAM_FIPS_DIGEST_CHECK "digest-check" +# define OSSL_PKEY_PARAM_FIPS_KEY_CHECK "key-check" +# define OSSL_PKEY_PARAM_FIPS_SIGN_CHECK "sign-check" +# define OSSL_PKEY_PARAM_GROUP_NAME "group" +# define OSSL_PKEY_PARAM_IMPLICIT_REJECTION "implicit-rejection" +# define OSSL_PKEY_PARAM_MANDATORY_DIGEST "mandatory-digest" +# define OSSL_PKEY_PARAM_MASKGENFUNC "mgf" +# define OSSL_PKEY_PARAM_MAX_SIZE "max-size" +# define OSSL_PKEY_PARAM_MGF1_DIGEST "mgf1-digest" +# define OSSL_PKEY_PARAM_MGF1_PROPERTIES "mgf1-properties" +# define OSSL_PKEY_PARAM_ML_DSA_INPUT_FORMATS "ml-dsa.input_formats" +# define OSSL_PKEY_PARAM_ML_DSA_OUTPUT_FORMATS "ml-dsa.output_formats" +# define OSSL_PKEY_PARAM_ML_DSA_PREFER_SEED "ml-dsa.prefer_seed" +# define OSSL_PKEY_PARAM_ML_DSA_RETAIN_SEED "ml-dsa.retain_seed" +# define OSSL_PKEY_PARAM_ML_DSA_SEED "seed" +# define OSSL_PKEY_PARAM_ML_KEM_IMPORT_PCT_TYPE "ml-kem.import_pct_type" +# define OSSL_PKEY_PARAM_ML_KEM_INPUT_FORMATS "ml-kem.input_formats" +# define OSSL_PKEY_PARAM_ML_KEM_OUTPUT_FORMATS "ml-kem.output_formats" +# define OSSL_PKEY_PARAM_ML_KEM_PREFER_SEED "ml-kem.prefer_seed" +# define OSSL_PKEY_PARAM_ML_KEM_RETAIN_SEED "ml-kem.retain_seed" +# define OSSL_PKEY_PARAM_ML_KEM_SEED "seed" +# define OSSL_PKEY_PARAM_PAD_MODE "pad-mode" +# define OSSL_PKEY_PARAM_PRIV_KEY "priv" +# define OSSL_PKEY_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES +# define OSSL_PKEY_PARAM_PUB_KEY "pub" +# define OSSL_PKEY_PARAM_RSA_BITS OSSL_PKEY_PARAM_BITS +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT "rsa-coefficient" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT1 "rsa-coefficient1" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT2 "rsa-coefficient2" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT3 "rsa-coefficient3" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT4 "rsa-coefficient4" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT5 "rsa-coefficient5" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT6 "rsa-coefficient6" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT7 "rsa-coefficient7" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT8 "rsa-coefficient8" +# define OSSL_PKEY_PARAM_RSA_COEFFICIENT9 "rsa-coefficient9" +# define OSSL_PKEY_PARAM_RSA_D "d" +# define OSSL_PKEY_PARAM_RSA_DERIVE_FROM_PQ "rsa-derive-from-pq" +# define OSSL_PKEY_PARAM_RSA_DIGEST OSSL_PKEY_PARAM_DIGEST +# define OSSL_PKEY_PARAM_RSA_DIGEST_PROPS OSSL_PKEY_PARAM_PROPERTIES +# define OSSL_PKEY_PARAM_RSA_E "e" +# define OSSL_PKEY_PARAM_RSA_EXPONENT "rsa-exponent" +# define OSSL_PKEY_PARAM_RSA_EXPONENT1 "rsa-exponent1" +# define OSSL_PKEY_PARAM_RSA_EXPONENT10 "rsa-exponent10" +# define OSSL_PKEY_PARAM_RSA_EXPONENT2 "rsa-exponent2" +# define OSSL_PKEY_PARAM_RSA_EXPONENT3 "rsa-exponent3" +# define OSSL_PKEY_PARAM_RSA_EXPONENT4 "rsa-exponent4" +# define OSSL_PKEY_PARAM_RSA_EXPONENT5 "rsa-exponent5" +# define OSSL_PKEY_PARAM_RSA_EXPONENT6 "rsa-exponent6" +# define OSSL_PKEY_PARAM_RSA_EXPONENT7 "rsa-exponent7" +# define OSSL_PKEY_PARAM_RSA_EXPONENT8 "rsa-exponent8" +# define OSSL_PKEY_PARAM_RSA_EXPONENT9 "rsa-exponent9" +# define OSSL_PKEY_PARAM_RSA_FACTOR "rsa-factor" +# define OSSL_PKEY_PARAM_RSA_FACTOR1 "rsa-factor1" +# define OSSL_PKEY_PARAM_RSA_FACTOR10 "rsa-factor10" +# define OSSL_PKEY_PARAM_RSA_FACTOR2 "rsa-factor2" +# define OSSL_PKEY_PARAM_RSA_FACTOR3 "rsa-factor3" +# define OSSL_PKEY_PARAM_RSA_FACTOR4 "rsa-factor4" +# define OSSL_PKEY_PARAM_RSA_FACTOR5 "rsa-factor5" +# define OSSL_PKEY_PARAM_RSA_FACTOR6 "rsa-factor6" +# define OSSL_PKEY_PARAM_RSA_FACTOR7 "rsa-factor7" +# define OSSL_PKEY_PARAM_RSA_FACTOR8 "rsa-factor8" +# define OSSL_PKEY_PARAM_RSA_FACTOR9 "rsa-factor9" +# define OSSL_PKEY_PARAM_RSA_MASKGENFUNC OSSL_PKEY_PARAM_MASKGENFUNC +# define OSSL_PKEY_PARAM_RSA_MGF1_DIGEST OSSL_PKEY_PARAM_MGF1_DIGEST +# define OSSL_PKEY_PARAM_RSA_N "n" +# define OSSL_PKEY_PARAM_RSA_PRIMES "primes" +# define OSSL_PKEY_PARAM_RSA_PSS_SALTLEN "saltlen" +# define OSSL_PKEY_PARAM_RSA_TEST_P1 "p1" +# define OSSL_PKEY_PARAM_RSA_TEST_P2 "p2" +# define OSSL_PKEY_PARAM_RSA_TEST_Q1 "q1" +# define OSSL_PKEY_PARAM_RSA_TEST_Q2 "q2" +# define OSSL_PKEY_PARAM_RSA_TEST_XP "xp" +# define OSSL_PKEY_PARAM_RSA_TEST_XP1 "xp1" +# define OSSL_PKEY_PARAM_RSA_TEST_XP2 "xp2" +# define OSSL_PKEY_PARAM_RSA_TEST_XQ "xq" +# define OSSL_PKEY_PARAM_RSA_TEST_XQ1 "xq1" +# define OSSL_PKEY_PARAM_RSA_TEST_XQ2 "xq2" +# define OSSL_PKEY_PARAM_SECURITY_BITS "security-bits" +# define OSSL_PKEY_PARAM_SLH_DSA_SEED "seed" +# define OSSL_PKEY_PARAM_USE_COFACTOR_ECDH OSSL_PKEY_PARAM_USE_COFACTOR_FLAG +# define OSSL_PKEY_PARAM_USE_COFACTOR_FLAG "use-cofactor-flag" +# define OSSL_PROV_PARAM_BUILDINFO "buildinfo" +# define OSSL_PROV_PARAM_CORE_MODULE_FILENAME "module-filename" +# define OSSL_PROV_PARAM_CORE_PROV_NAME "provider-name" +# define OSSL_PROV_PARAM_CORE_VERSION "openssl-version" +# define OSSL_PROV_PARAM_DRBG_TRUNC_DIGEST "drbg-no-trunc-md" +# define OSSL_PROV_PARAM_DSA_SIGN_DISABLED "dsa-sign-disabled" +# define OSSL_PROV_PARAM_ECDH_COFACTOR_CHECK "ecdh-cofactor-check" +# define OSSL_PROV_PARAM_HKDF_DIGEST_CHECK "hkdf-digest-check" +# define OSSL_PROV_PARAM_HKDF_KEY_CHECK "hkdf-key-check" +# define OSSL_PROV_PARAM_HMAC_KEY_CHECK "hmac-key-check" +# define OSSL_PROV_PARAM_KBKDF_KEY_CHECK "kbkdf-key-check" +# define OSSL_PROV_PARAM_KMAC_KEY_CHECK "kmac-key-check" +# define OSSL_PROV_PARAM_NAME "name" +# define OSSL_PROV_PARAM_NO_SHORT_MAC "no-short-mac" +# define OSSL_PROV_PARAM_PBKDF2_LOWER_BOUND_CHECK "pbkdf2-lower-bound-check" +# define OSSL_PROV_PARAM_RSA_PKCS15_PAD_DISABLED "rsa-pkcs15-pad-disabled" +# define OSSL_PROV_PARAM_RSA_PSS_SALTLEN_CHECK "rsa-pss-saltlen-check" +# define OSSL_PROV_PARAM_RSA_SIGN_X931_PAD_DISABLED "rsa-sign-x931-pad-disabled" +# define OSSL_PROV_PARAM_SECURITY_CHECKS "security-checks" +# define OSSL_PROV_PARAM_SELF_TEST_DESC "st-desc" +# define OSSL_PROV_PARAM_SELF_TEST_PHASE "st-phase" +# define OSSL_PROV_PARAM_SELF_TEST_TYPE "st-type" +# define OSSL_PROV_PARAM_SIGNATURE_DIGEST_CHECK "signature-digest-check" +# define OSSL_PROV_PARAM_SSHKDF_DIGEST_CHECK "sshkdf-digest-check" +# define OSSL_PROV_PARAM_SSHKDF_KEY_CHECK "sshkdf-key-check" +# define OSSL_PROV_PARAM_SSKDF_DIGEST_CHECK "sskdf-digest-check" +# define OSSL_PROV_PARAM_SSKDF_KEY_CHECK "sskdf-key-check" +# define OSSL_PROV_PARAM_STATUS "status" +# define OSSL_PROV_PARAM_TDES_ENCRYPT_DISABLED "tdes-encrypt-disabled" +# define OSSL_PROV_PARAM_TLS13_KDF_DIGEST_CHECK "tls13-kdf-digest-check" +# define OSSL_PROV_PARAM_TLS13_KDF_KEY_CHECK "tls13-kdf-key-check" +# define OSSL_PROV_PARAM_TLS1_PRF_DIGEST_CHECK "tls1-prf-digest-check" +# define OSSL_PROV_PARAM_TLS1_PRF_EMS_CHECK "tls1-prf-ems-check" +# define OSSL_PROV_PARAM_TLS1_PRF_KEY_CHECK "tls1-prf-key-check" +# define OSSL_PROV_PARAM_VERSION "version" +# define OSSL_PROV_PARAM_X942KDF_KEY_CHECK "x942kdf-key-check" +# define OSSL_PROV_PARAM_X963KDF_DIGEST_CHECK "x963kdf-digest-check" +# define OSSL_PROV_PARAM_X963KDF_KEY_CHECK "x963kdf-key-check" +# define OSSL_RAND_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_RAND_PARAM_GENERATE "generate" +# define OSSL_RAND_PARAM_MAX_REQUEST "max_request" +# define OSSL_RAND_PARAM_STATE "state" +# define OSSL_RAND_PARAM_STRENGTH "strength" +# define OSSL_RAND_PARAM_TEST_ENTROPY "test_entropy" +# define OSSL_RAND_PARAM_TEST_NONCE "test_nonce" +# define OSSL_SIGNATURE_PARAM_ADD_RANDOM "additional-random" +# define OSSL_SIGNATURE_PARAM_ALGORITHM_ID OSSL_PKEY_PARAM_ALGORITHM_ID +# define OSSL_SIGNATURE_PARAM_ALGORITHM_ID_PARAMS OSSL_PKEY_PARAM_ALGORITHM_ID_PARAMS +# define OSSL_SIGNATURE_PARAM_CONTEXT_STRING "context-string" +# define OSSL_SIGNATURE_PARAM_DETERMINISTIC "deterministic" +# define OSSL_SIGNATURE_PARAM_DIGEST OSSL_PKEY_PARAM_DIGEST +# define OSSL_SIGNATURE_PARAM_DIGEST_SIZE OSSL_PKEY_PARAM_DIGEST_SIZE +# define OSSL_SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR +# define OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK OSSL_PKEY_PARAM_FIPS_DIGEST_CHECK +# define OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK OSSL_PKEY_PARAM_FIPS_KEY_CHECK +# define OSSL_SIGNATURE_PARAM_FIPS_RSA_PSS_SALTLEN_CHECK "rsa-pss-saltlen-check" +# define OSSL_SIGNATURE_PARAM_FIPS_SIGN_CHECK OSSL_PKEY_PARAM_FIPS_SIGN_CHECK +# define OSSL_SIGNATURE_PARAM_FIPS_SIGN_X931_PAD_CHECK "sign-x931-pad-check" +# define OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE "verify-message" +# define OSSL_SIGNATURE_PARAM_INSTANCE "instance" +# define OSSL_SIGNATURE_PARAM_KAT "kat" +# define OSSL_SIGNATURE_PARAM_MESSAGE_ENCODING "message-encoding" +# define OSSL_SIGNATURE_PARAM_MGF1_DIGEST OSSL_PKEY_PARAM_MGF1_DIGEST +# define OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES OSSL_PKEY_PARAM_MGF1_PROPERTIES +# define OSSL_SIGNATURE_PARAM_MU "mu" +# define OSSL_SIGNATURE_PARAM_NONCE_TYPE "nonce-type" +# define OSSL_SIGNATURE_PARAM_PAD_MODE OSSL_PKEY_PARAM_PAD_MODE +# define OSSL_SIGNATURE_PARAM_PROPERTIES OSSL_PKEY_PARAM_PROPERTIES +# define OSSL_SIGNATURE_PARAM_PSS_SALTLEN "saltlen" +# define OSSL_SIGNATURE_PARAM_SIGNATURE "signature" +# define OSSL_SIGNATURE_PARAM_TEST_ENTROPY "test-entropy" +# define OSSL_SKEY_PARAM_KEY_LENGTH "key-length" +# define OSSL_SKEY_PARAM_RAW_BYTES "raw-bytes" +# define OSSL_STORE_PARAM_ALIAS "alias" +# define OSSL_STORE_PARAM_DIGEST "digest" +# define OSSL_STORE_PARAM_EXPECT "expect" +# define OSSL_STORE_PARAM_FINGERPRINT "fingerprint" +# define OSSL_STORE_PARAM_INPUT_TYPE "input-type" +# define OSSL_STORE_PARAM_ISSUER "name" +# define OSSL_STORE_PARAM_PROPERTIES "properties" +# define OSSL_STORE_PARAM_SERIAL "serial" +# define OSSL_STORE_PARAM_SUBJECT "subject" + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/core_object.h b/illumos-x86_64/usr/include/openssl-3/core_object.h new file mode 100644 index 00000000..62ccf39d --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/core_object.h @@ -0,0 +1,41 @@ +/* + * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CORE_OBJECT_H +# define OPENSSL_CORE_OBJECT_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +/*- + * Known object types + * + * These numbers are used as values for the OSSL_PARAM parameter + * OSSL_OBJECT_PARAM_TYPE. + * + * For most of these types, there's a corresponding libcrypto object type. + * The corresponding type is indicated with a comment after the number. + */ +# define OSSL_OBJECT_UNKNOWN 0 +# define OSSL_OBJECT_NAME 1 /* char * */ +# define OSSL_OBJECT_PKEY 2 /* EVP_PKEY * */ +# define OSSL_OBJECT_CERT 3 /* X509 * */ +# define OSSL_OBJECT_CRL 4 /* X509_CRL * */ + +/* + * The rest of the associated OSSL_PARAM elements is described in core_names.h + */ + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/crmf.h b/illumos-x86_64/usr/include/openssl-3/crmf.h new file mode 100644 index 00000000..4bf550fd --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/crmf.h @@ -0,0 +1,278 @@ +/*- + * WARNING: do not edit! + * Generated by Makefile from include/openssl/crmf.h.in + * + * Copyright 2007-2025 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + * + * CRMF (RFC 4211) implementation by M. Peylo, M. Viljanen, and D. von Oheimb. + */ + + + +#ifndef OPENSSL_CRMF_H +# define OPENSSL_CRMF_H + +# include + +# ifndef OPENSSL_NO_CRMF +# include +# include +# include +# include /* for GENERAL_NAME etc. */ +# include + +/* explicit #includes not strictly needed since implied by the above: */ +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define OSSL_CRMF_POPOPRIVKEY_THISMESSAGE 0 +# define OSSL_CRMF_POPOPRIVKEY_SUBSEQUENTMESSAGE 1 +# define OSSL_CRMF_POPOPRIVKEY_DHMAC 2 +# define OSSL_CRMF_POPOPRIVKEY_AGREEMAC 3 +# define OSSL_CRMF_POPOPRIVKEY_ENCRYPTEDKEY 4 + +# define OSSL_CRMF_SUBSEQUENTMESSAGE_ENCRCERT 0 +# define OSSL_CRMF_SUBSEQUENTMESSAGE_CHALLENGERESP 1 +typedef struct ossl_crmf_encryptedvalue_st OSSL_CRMF_ENCRYPTEDVALUE; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDVALUE) + +typedef struct ossl_crmf_encryptedkey_st OSSL_CRMF_ENCRYPTEDKEY; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDKEY) + +typedef struct ossl_crmf_msg_st OSSL_CRMF_MSG; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSG) +DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_MSG) +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CRMF_MSG, OSSL_CRMF_MSG, OSSL_CRMF_MSG) +#define sk_OSSL_CRMF_MSG_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk)) +#define sk_OSSL_CRMF_MSG_value(sk, idx) ((OSSL_CRMF_MSG *)OPENSSL_sk_value(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk), (idx))) +#define sk_OSSL_CRMF_MSG_new(cmp) ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new(ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp))) +#define sk_OSSL_CRMF_MSG_new_null() ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CRMF_MSG_new_reserve(cmp, n) ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp), (n))) +#define sk_OSSL_CRMF_MSG_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CRMF_MSG_sk_type(sk), (n)) +#define sk_OSSL_CRMF_MSG_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) +#define sk_OSSL_CRMF_MSG_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) +#define sk_OSSL_CRMF_MSG_delete(sk, i) ((OSSL_CRMF_MSG *)OPENSSL_sk_delete(ossl_check_OSSL_CRMF_MSG_sk_type(sk), (i))) +#define sk_OSSL_CRMF_MSG_delete_ptr(sk, ptr) ((OSSL_CRMF_MSG *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr))) +#define sk_OSSL_CRMF_MSG_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr)) +#define sk_OSSL_CRMF_MSG_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr)) +#define sk_OSSL_CRMF_MSG_pop(sk) ((OSSL_CRMF_MSG *)OPENSSL_sk_pop(ossl_check_OSSL_CRMF_MSG_sk_type(sk))) +#define sk_OSSL_CRMF_MSG_shift(sk) ((OSSL_CRMF_MSG *)OPENSSL_sk_shift(ossl_check_OSSL_CRMF_MSG_sk_type(sk))) +#define sk_OSSL_CRMF_MSG_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CRMF_MSG_sk_type(sk),ossl_check_OSSL_CRMF_MSG_freefunc_type(freefunc)) +#define sk_OSSL_CRMF_MSG_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr), (idx)) +#define sk_OSSL_CRMF_MSG_set(sk, idx, ptr) ((OSSL_CRMF_MSG *)OPENSSL_sk_set(ossl_check_OSSL_CRMF_MSG_sk_type(sk), (idx), ossl_check_OSSL_CRMF_MSG_type(ptr))) +#define sk_OSSL_CRMF_MSG_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr)) +#define sk_OSSL_CRMF_MSG_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr)) +#define sk_OSSL_CRMF_MSG_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr), pnum) +#define sk_OSSL_CRMF_MSG_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) +#define sk_OSSL_CRMF_MSG_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk)) +#define sk_OSSL_CRMF_MSG_dup(sk) ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk))) +#define sk_OSSL_CRMF_MSG_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_copyfunc_type(copyfunc), ossl_check_OSSL_CRMF_MSG_freefunc_type(freefunc))) +#define sk_OSSL_CRMF_MSG_set_cmp_func(sk, cmp) ((sk_OSSL_CRMF_MSG_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp))) + +typedef struct ossl_crmf_attributetypeandvalue_st OSSL_CRMF_ATTRIBUTETYPEANDVALUE; +void OSSL_CRMF_ATTRIBUTETYPEANDVALUE_free(OSSL_CRMF_ATTRIBUTETYPEANDVALUE *v); +DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, OSSL_CRMF_ATTRIBUTETYPEANDVALUE, OSSL_CRMF_ATTRIBUTETYPEANDVALUE) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_value(sk, idx) ((OSSL_CRMF_ATTRIBUTETYPEANDVALUE *)OPENSSL_sk_value(ossl_check_const_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), (idx))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_new(cmp) ((STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *)OPENSSL_sk_new(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_compfunc_type(cmp))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_new_null() ((STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_new_reserve(cmp, n) ((STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_compfunc_type(cmp), (n))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), (n)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_delete(sk, i) ((OSSL_CRMF_ATTRIBUTETYPEANDVALUE *)OPENSSL_sk_delete(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), (i))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_delete_ptr(sk, ptr) ((OSSL_CRMF_ATTRIBUTETYPEANDVALUE *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_type(ptr))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_type(ptr)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_type(ptr)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_pop(sk) ((OSSL_CRMF_ATTRIBUTETYPEANDVALUE *)OPENSSL_sk_pop(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_shift(sk) ((OSSL_CRMF_ATTRIBUTETYPEANDVALUE *)OPENSSL_sk_shift(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk),ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_freefunc_type(freefunc)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_type(ptr), (idx)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_set(sk, idx, ptr) ((OSSL_CRMF_ATTRIBUTETYPEANDVALUE *)OPENSSL_sk_set(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), (idx), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_type(ptr))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_type(ptr)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_type(ptr)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_type(ptr), pnum) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk)) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_dup(sk) ((STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_copyfunc_type(copyfunc), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_freefunc_type(freefunc))) +#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_set_cmp_func(sk, cmp) ((sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_compfunc_type(cmp))) + + +typedef struct ossl_crmf_pbmparameter_st OSSL_CRMF_PBMPARAMETER; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PBMPARAMETER) +typedef struct ossl_crmf_poposigningkey_st OSSL_CRMF_POPOSIGNINGKEY; +typedef struct ossl_crmf_certrequest_st OSSL_CRMF_CERTREQUEST; +typedef struct ossl_crmf_certid_st OSSL_CRMF_CERTID; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTID) +DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID) +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CRMF_CERTID, OSSL_CRMF_CERTID, OSSL_CRMF_CERTID) +#define sk_OSSL_CRMF_CERTID_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk)) +#define sk_OSSL_CRMF_CERTID_value(sk, idx) ((OSSL_CRMF_CERTID *)OPENSSL_sk_value(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk), (idx))) +#define sk_OSSL_CRMF_CERTID_new(cmp) ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new(ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp))) +#define sk_OSSL_CRMF_CERTID_new_null() ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new_null()) +#define sk_OSSL_CRMF_CERTID_new_reserve(cmp, n) ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp), (n))) +#define sk_OSSL_CRMF_CERTID_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (n)) +#define sk_OSSL_CRMF_CERTID_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) +#define sk_OSSL_CRMF_CERTID_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) +#define sk_OSSL_CRMF_CERTID_delete(sk, i) ((OSSL_CRMF_CERTID *)OPENSSL_sk_delete(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (i))) +#define sk_OSSL_CRMF_CERTID_delete_ptr(sk, ptr) ((OSSL_CRMF_CERTID *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_type(ptr))) +#define sk_OSSL_CRMF_CERTID_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_type(ptr)) +#define sk_OSSL_CRMF_CERTID_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_type(ptr)) +#define sk_OSSL_CRMF_CERTID_pop(sk) ((OSSL_CRMF_CERTID *)OPENSSL_sk_pop(ossl_check_OSSL_CRMF_CERTID_sk_type(sk))) +#define sk_OSSL_CRMF_CERTID_shift(sk) ((OSSL_CRMF_CERTID *)OPENSSL_sk_shift(ossl_check_OSSL_CRMF_CERTID_sk_type(sk))) +#define sk_OSSL_CRMF_CERTID_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_CRMF_CERTID_sk_type(sk),ossl_check_OSSL_CRMF_CERTID_freefunc_type(freefunc)) +#define sk_OSSL_CRMF_CERTID_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_type(ptr), (idx)) +#define sk_OSSL_CRMF_CERTID_set(sk, idx, ptr) ((OSSL_CRMF_CERTID *)OPENSSL_sk_set(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (idx), ossl_check_OSSL_CRMF_CERTID_type(ptr))) +#define sk_OSSL_CRMF_CERTID_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_type(ptr)) +#define sk_OSSL_CRMF_CERTID_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_type(ptr)) +#define sk_OSSL_CRMF_CERTID_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_type(ptr), pnum) +#define sk_OSSL_CRMF_CERTID_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) +#define sk_OSSL_CRMF_CERTID_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk)) +#define sk_OSSL_CRMF_CERTID_dup(sk) ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk))) +#define sk_OSSL_CRMF_CERTID_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_copyfunc_type(copyfunc), ossl_check_OSSL_CRMF_CERTID_freefunc_type(freefunc))) +#define sk_OSSL_CRMF_CERTID_set_cmp_func(sk, cmp) ((sk_OSSL_CRMF_CERTID_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp))) + + +typedef struct ossl_crmf_pkipublicationinfo_st OSSL_CRMF_PKIPUBLICATIONINFO; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKIPUBLICATIONINFO) +typedef struct ossl_crmf_singlepubinfo_st OSSL_CRMF_SINGLEPUBINFO; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_SINGLEPUBINFO) +typedef struct ossl_crmf_certtemplate_st OSSL_CRMF_CERTTEMPLATE; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTTEMPLATE) +DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTTEMPLATE) +typedef STACK_OF(OSSL_CRMF_MSG) OSSL_CRMF_MSGS; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSGS) + +typedef struct ossl_crmf_optionalvalidity_st OSSL_CRMF_OPTIONALVALIDITY; + +/* crmf_pbm.c */ +OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(OSSL_LIB_CTX *libctx, size_t slen, + int owfnid, size_t itercnt, + int macnid); +int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq, + const OSSL_CRMF_PBMPARAMETER *pbmp, + const unsigned char *msg, size_t msglen, + const unsigned char *sec, size_t seclen, + unsigned char **mac, size_t *maclen); + +/* crmf_lib.c */ +int OSSL_CRMF_MSG_set1_regCtrl_regToken(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *tok); +ASN1_UTF8STRING +*OSSL_CRMF_MSG_get0_regCtrl_regToken(const OSSL_CRMF_MSG *msg); +int OSSL_CRMF_MSG_set1_regCtrl_authenticator(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *auth); +ASN1_UTF8STRING +*OSSL_CRMF_MSG_get0_regCtrl_authenticator(const OSSL_CRMF_MSG *msg); +int +OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo(OSSL_CRMF_PKIPUBLICATIONINFO *pi, + OSSL_CRMF_SINGLEPUBINFO *spi); +# define OSSL_CRMF_PUB_METHOD_DONTCARE 0 +# define OSSL_CRMF_PUB_METHOD_X500 1 +# define OSSL_CRMF_PUB_METHOD_WEB 2 +# define OSSL_CRMF_PUB_METHOD_LDAP 3 +int OSSL_CRMF_MSG_set0_SinglePubInfo(OSSL_CRMF_SINGLEPUBINFO *spi, + int method, GENERAL_NAME *nm); +# define OSSL_CRMF_PUB_ACTION_DONTPUBLISH 0 +# define OSSL_CRMF_PUB_ACTION_PLEASEPUBLISH 1 +int OSSL_CRMF_MSG_set_PKIPublicationInfo_action(OSSL_CRMF_PKIPUBLICATIONINFO *pi, + int action); +int OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_PKIPUBLICATIONINFO *pi); +OSSL_CRMF_PKIPUBLICATIONINFO +*OSSL_CRMF_MSG_get0_regCtrl_pkiPublicationInfo(const OSSL_CRMF_MSG *msg); +int OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey(OSSL_CRMF_MSG *msg, + const X509_PUBKEY *pubkey); +X509_PUBKEY +*OSSL_CRMF_MSG_get0_regCtrl_protocolEncrKey(const OSSL_CRMF_MSG *msg); +int OSSL_CRMF_MSG_set1_regCtrl_oldCertID(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_CERTID *cid); +OSSL_CRMF_CERTID +*OSSL_CRMF_MSG_get0_regCtrl_oldCertID(const OSSL_CRMF_MSG *msg); +OSSL_CRMF_CERTID *OSSL_CRMF_CERTID_gen(const X509_NAME *issuer, + const ASN1_INTEGER *serial); + +int OSSL_CRMF_MSG_set1_regInfo_utf8Pairs(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *utf8pairs); +ASN1_UTF8STRING +*OSSL_CRMF_MSG_get0_regInfo_utf8Pairs(const OSSL_CRMF_MSG *msg); +int OSSL_CRMF_MSG_set1_regInfo_certReq(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_CERTREQUEST *cr); +OSSL_CRMF_CERTREQUEST +*OSSL_CRMF_MSG_get0_regInfo_certReq(const OSSL_CRMF_MSG *msg); + +int OSSL_CRMF_MSG_set0_validity(OSSL_CRMF_MSG *crm, + ASN1_TIME *notBefore, ASN1_TIME *notAfter); +int OSSL_CRMF_MSG_set_certReqId(OSSL_CRMF_MSG *crm, int rid); +int OSSL_CRMF_MSG_get_certReqId(const OSSL_CRMF_MSG *crm); +int OSSL_CRMF_MSG_set0_extensions(OSSL_CRMF_MSG *crm, X509_EXTENSIONS *exts); + +int OSSL_CRMF_MSG_push0_extension(OSSL_CRMF_MSG *crm, X509_EXTENSION *ext); +# define OSSL_CRMF_POPO_NONE -1 +# define OSSL_CRMF_POPO_RAVERIFIED 0 +# define OSSL_CRMF_POPO_SIGNATURE 1 +# define OSSL_CRMF_POPO_KEYENC 2 +# define OSSL_CRMF_POPO_KEYAGREE 3 +int OSSL_CRMF_MSG_create_popo(int meth, OSSL_CRMF_MSG *crm, + EVP_PKEY *pkey, const EVP_MD *digest, + OSSL_LIB_CTX *libctx, const char *propq); +int OSSL_CRMF_MSGS_verify_popo(const OSSL_CRMF_MSGS *reqs, + int rid, int acceptRAVerified, + OSSL_LIB_CTX *libctx, const char *propq); +OSSL_CRMF_CERTTEMPLATE *OSSL_CRMF_MSG_get0_tmpl(const OSSL_CRMF_MSG *crm); +X509_PUBKEY +*OSSL_CRMF_CERTTEMPLATE_get0_publicKey(const OSSL_CRMF_CERTTEMPLATE *tmpl); +const X509_NAME +*OSSL_CRMF_CERTTEMPLATE_get0_subject(const OSSL_CRMF_CERTTEMPLATE *tmpl); +const X509_NAME +*OSSL_CRMF_CERTTEMPLATE_get0_issuer(const OSSL_CRMF_CERTTEMPLATE *tmpl); +const ASN1_INTEGER +*OSSL_CRMF_CERTTEMPLATE_get0_serialNumber(const OSSL_CRMF_CERTTEMPLATE *tmpl); +X509_EXTENSIONS +*OSSL_CRMF_CERTTEMPLATE_get0_extensions(const OSSL_CRMF_CERTTEMPLATE *tmpl); +const X509_NAME +*OSSL_CRMF_CERTID_get0_issuer(const OSSL_CRMF_CERTID *cid); +const ASN1_INTEGER +*OSSL_CRMF_CERTID_get0_serialNumber(const OSSL_CRMF_CERTID *cid); +int OSSL_CRMF_CERTTEMPLATE_fill(OSSL_CRMF_CERTTEMPLATE *tmpl, + EVP_PKEY *pubkey, + const X509_NAME *subject, + const X509_NAME *issuer, + const ASN1_INTEGER *serial); +X509 *OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(const OSSL_CRMF_ENCRYPTEDVALUE *ecert, + OSSL_LIB_CTX *libctx, const char *propq, + EVP_PKEY *pkey); +X509 *OSSL_CRMF_ENCRYPTEDKEY_get1_encCert(const OSSL_CRMF_ENCRYPTEDKEY *ecert, + OSSL_LIB_CTX *libctx, const char *propq, + EVP_PKEY *pkey, unsigned int flags); +unsigned char +*OSSL_CRMF_ENCRYPTEDVALUE_decrypt(const OSSL_CRMF_ENCRYPTEDVALUE *enc, + OSSL_LIB_CTX *libctx, const char *propq, + EVP_PKEY *pkey, int *outlen); +EVP_PKEY *OSSL_CRMF_ENCRYPTEDKEY_get1_pkey(const OSSL_CRMF_ENCRYPTEDKEY *encryptedKey, + X509_STORE *ts, STACK_OF(X509) *extra, EVP_PKEY *pkey, + X509 *cert, ASN1_OCTET_STRING *secret, + OSSL_LIB_CTX *libctx, const char *propq); +int OSSL_CRMF_MSG_centralkeygen_requested(const OSSL_CRMF_MSG *crm, const X509_REQ *p10cr); +# ifndef OPENSSL_NO_CMS +OSSL_CRMF_ENCRYPTEDKEY *OSSL_CRMF_ENCRYPTEDKEY_init_envdata(CMS_EnvelopedData *envdata); +# endif + +# ifdef __cplusplus +} +# endif +# endif /* !defined(OPENSSL_NO_CRMF) */ +#endif /* !defined(OPENSSL_CRMF_H) */ diff --git a/illumos-x86_64/usr/include/openssl-3/crmferr.h b/illumos-x86_64/usr/include/openssl-3/crmferr.h new file mode 100644 index 00000000..a9b04e0e --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/crmferr.h @@ -0,0 +1,57 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CRMFERR_H +# define OPENSSL_CRMFERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_CRMF + + +/* + * CRMF reason codes. + */ +# define CRMF_R_BAD_PBM_ITERATIONCOUNT 100 +# define CRMF_R_CMS_NOT_SUPPORTED 122 +# define CRMF_R_CRMFERROR 102 +# define CRMF_R_ERROR 103 +# define CRMF_R_ERROR_DECODING_CERTIFICATE 104 +# define CRMF_R_ERROR_DECODING_ENCRYPTEDKEY 123 +# define CRMF_R_ERROR_DECRYPTING_CERTIFICATE 105 +# define CRMF_R_ERROR_DECRYPTING_ENCRYPTEDKEY 124 +# define CRMF_R_ERROR_DECRYPTING_ENCRYPTEDVALUE 125 +# define CRMF_R_ERROR_DECRYPTING_SYMMETRIC_KEY 106 +# define CRMF_R_ERROR_SETTING_PURPOSE 126 +# define CRMF_R_ERROR_VERIFYING_ENCRYPTEDKEY 127 +# define CRMF_R_FAILURE_OBTAINING_RANDOM 107 +# define CRMF_R_ITERATIONCOUNT_BELOW_100 108 +# define CRMF_R_MALFORMED_IV 101 +# define CRMF_R_NULL_ARGUMENT 109 +# define CRMF_R_POPOSKINPUT_NOT_SUPPORTED 113 +# define CRMF_R_POPO_INCONSISTENT_CENTRAL_KEYGEN 128 +# define CRMF_R_POPO_INCONSISTENT_PUBLIC_KEY 117 +# define CRMF_R_POPO_MISSING 121 +# define CRMF_R_POPO_MISSING_PUBLIC_KEY 118 +# define CRMF_R_POPO_MISSING_SUBJECT 119 +# define CRMF_R_POPO_RAVERIFIED_NOT_ACCEPTED 120 +# define CRMF_R_SETTING_MAC_ALGOR_FAILURE 110 +# define CRMF_R_SETTING_OWF_ALGOR_FAILURE 111 +# define CRMF_R_UNSUPPORTED_ALGORITHM 112 +# define CRMF_R_UNSUPPORTED_CIPHER 114 +# define CRMF_R_UNSUPPORTED_METHOD_FOR_CREATING_POPO 115 +# define CRMF_R_UNSUPPORTED_POPO_METHOD 116 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/crypto.h b/illumos-x86_64/usr/include/openssl-3/crypto.h new file mode 100644 index 00000000..87fefd4a --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/crypto.h @@ -0,0 +1,583 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/crypto.h.in + * + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_CRYPTO_H +# define OPENSSL_CRYPTO_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_CRYPTO_H +# endif + +# include +# include + +# include + +# ifndef OPENSSL_NO_STDIO +# include +# endif + +# include +# include +# include +# include +# include +# include + +# ifdef CHARSET_EBCDIC +# include +# endif + +/* + * Resolve problems on some operating systems with symbol names that clash + * one way or another + */ +# include + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define SSLeay OpenSSL_version_num +# define SSLeay_version OpenSSL_version +# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER +# define SSLEAY_VERSION OPENSSL_VERSION +# define SSLEAY_CFLAGS OPENSSL_CFLAGS +# define SSLEAY_BUILT_ON OPENSSL_BUILT_ON +# define SSLEAY_PLATFORM OPENSSL_PLATFORM +# define SSLEAY_DIR OPENSSL_DIR + +/* + * Old type for allocating dynamic locks. No longer used. Use the new thread + * API instead. + */ +typedef struct { + int dummy; +} CRYPTO_dynlock; + +# endif /* OPENSSL_NO_DEPRECATED_1_1_0 */ + +typedef void CRYPTO_RWLOCK; + +CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void); +__owur int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock); +__owur int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock); +int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock); +void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock); + +int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock); +int CRYPTO_atomic_add64(uint64_t *val, uint64_t op, uint64_t *ret, + CRYPTO_RWLOCK *lock); +int CRYPTO_atomic_and(uint64_t *val, uint64_t op, uint64_t *ret, + CRYPTO_RWLOCK *lock); +int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret, + CRYPTO_RWLOCK *lock); +int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock); +int CRYPTO_atomic_load_int(int *val, int *ret, CRYPTO_RWLOCK *lock); +int CRYPTO_atomic_store(uint64_t *dst, uint64_t val, CRYPTO_RWLOCK *lock); + +/* No longer needed, so this is a no-op */ +#define OPENSSL_malloc_init() while(0) continue + +# define OPENSSL_malloc(num) \ + CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_zalloc(num) \ + CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_aligned_alloc(num, alignment, freeptr) \ + CRYPTO_aligned_alloc(num, alignment, freeptr, \ + OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_realloc(addr, num) \ + CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_clear_realloc(addr, old_num, num) \ + CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_clear_free(addr, num) \ + CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_free(addr) \ + CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_memdup(str, s) \ + CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_strdup(str) \ + CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_strndup(str, n) \ + CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_secure_malloc(num) \ + CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_secure_zalloc(num) \ + CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_secure_free(addr) \ + CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_secure_clear_free(addr, num) \ + CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_secure_actual_size(ptr) \ + CRYPTO_secure_actual_size(ptr) + +size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz); +size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz); +size_t OPENSSL_strnlen(const char *str, size_t maxlen); +int OPENSSL_strtoul(const char *str, char **endptr, int base, unsigned long *num); +int OPENSSL_buf2hexstr_ex(char *str, size_t str_n, size_t *strlength, + const unsigned char *buf, size_t buflen, + const char sep); +char *OPENSSL_buf2hexstr(const unsigned char *buf, long buflen); +int OPENSSL_hexstr2buf_ex(unsigned char *buf, size_t buf_n, size_t *buflen, + const char *str, const char sep); +unsigned char *OPENSSL_hexstr2buf(const char *str, long *buflen); +int OPENSSL_hexchar2int(unsigned char c); +int OPENSSL_strcasecmp(const char *s1, const char *s2); +int OPENSSL_strncasecmp(const char *s1, const char *s2, size_t n); + +# define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type)) + +/* + * These functions return the values of OPENSSL_VERSION_MAJOR, + * OPENSSL_VERSION_MINOR, OPENSSL_VERSION_PATCH, OPENSSL_VERSION_PRE_RELEASE + * and OPENSSL_VERSION_BUILD_METADATA, respectively. + */ +unsigned int OPENSSL_version_major(void); +unsigned int OPENSSL_version_minor(void); +unsigned int OPENSSL_version_patch(void); +const char *OPENSSL_version_pre_release(void); +const char *OPENSSL_version_build_metadata(void); + +unsigned long OpenSSL_version_num(void); +const char *OpenSSL_version(int type); +# define OPENSSL_VERSION 0 +# define OPENSSL_CFLAGS 1 +# define OPENSSL_BUILT_ON 2 +# define OPENSSL_PLATFORM 3 +# define OPENSSL_DIR 4 +# define OPENSSL_ENGINES_DIR 5 +# define OPENSSL_VERSION_STRING 6 +# define OPENSSL_FULL_VERSION_STRING 7 +# define OPENSSL_MODULES_DIR 8 +# define OPENSSL_CPU_INFO 9 +# define OPENSSL_WINCTX 10 + +const char *OPENSSL_info(int type); +/* + * The series starts at 1001 to avoid confusion with the OpenSSL_version + * types. + */ +# define OPENSSL_INFO_CONFIG_DIR 1001 +# define OPENSSL_INFO_ENGINES_DIR 1002 +# define OPENSSL_INFO_MODULES_DIR 1003 +# define OPENSSL_INFO_DSO_EXTENSION 1004 +# define OPENSSL_INFO_DIR_FILENAME_SEPARATOR 1005 +# define OPENSSL_INFO_LIST_SEPARATOR 1006 +# define OPENSSL_INFO_SEED_SOURCE 1007 +# define OPENSSL_INFO_CPU_SETTINGS 1008 +# define OPENSSL_INFO_WINDOWS_CONTEXT 1009 + +int OPENSSL_issetugid(void); + +struct crypto_ex_data_st { + OSSL_LIB_CTX *ctx; + STACK_OF(void) *sk; +}; + +SKM_DEFINE_STACK_OF_INTERNAL(void, void, void) +#define sk_void_num(sk) OPENSSL_sk_num(ossl_check_const_void_sk_type(sk)) +#define sk_void_value(sk, idx) ((void *)OPENSSL_sk_value(ossl_check_const_void_sk_type(sk), (idx))) +#define sk_void_new(cmp) ((STACK_OF(void) *)OPENSSL_sk_new(ossl_check_void_compfunc_type(cmp))) +#define sk_void_new_null() ((STACK_OF(void) *)OPENSSL_sk_new_null()) +#define sk_void_new_reserve(cmp, n) ((STACK_OF(void) *)OPENSSL_sk_new_reserve(ossl_check_void_compfunc_type(cmp), (n))) +#define sk_void_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_void_sk_type(sk), (n)) +#define sk_void_free(sk) OPENSSL_sk_free(ossl_check_void_sk_type(sk)) +#define sk_void_zero(sk) OPENSSL_sk_zero(ossl_check_void_sk_type(sk)) +#define sk_void_delete(sk, i) ((void *)OPENSSL_sk_delete(ossl_check_void_sk_type(sk), (i))) +#define sk_void_delete_ptr(sk, ptr) ((void *)OPENSSL_sk_delete_ptr(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr))) +#define sk_void_push(sk, ptr) OPENSSL_sk_push(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) +#define sk_void_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) +#define sk_void_pop(sk) ((void *)OPENSSL_sk_pop(ossl_check_void_sk_type(sk))) +#define sk_void_shift(sk) ((void *)OPENSSL_sk_shift(ossl_check_void_sk_type(sk))) +#define sk_void_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_void_sk_type(sk),ossl_check_void_freefunc_type(freefunc)) +#define sk_void_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr), (idx)) +#define sk_void_set(sk, idx, ptr) ((void *)OPENSSL_sk_set(ossl_check_void_sk_type(sk), (idx), ossl_check_void_type(ptr))) +#define sk_void_find(sk, ptr) OPENSSL_sk_find(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) +#define sk_void_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) +#define sk_void_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr), pnum) +#define sk_void_sort(sk) OPENSSL_sk_sort(ossl_check_void_sk_type(sk)) +#define sk_void_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_void_sk_type(sk)) +#define sk_void_dup(sk) ((STACK_OF(void) *)OPENSSL_sk_dup(ossl_check_const_void_sk_type(sk))) +#define sk_void_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(void) *)OPENSSL_sk_deep_copy(ossl_check_const_void_sk_type(sk), ossl_check_void_copyfunc_type(copyfunc), ossl_check_void_freefunc_type(freefunc))) +#define sk_void_set_cmp_func(sk, cmp) ((sk_void_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_void_sk_type(sk), ossl_check_void_compfunc_type(cmp))) + + + +/* + * Per class, we have a STACK of function pointers. + */ +# define CRYPTO_EX_INDEX_SSL 0 +# define CRYPTO_EX_INDEX_SSL_CTX 1 +# define CRYPTO_EX_INDEX_SSL_SESSION 2 +# define CRYPTO_EX_INDEX_X509 3 +# define CRYPTO_EX_INDEX_X509_STORE 4 +# define CRYPTO_EX_INDEX_X509_STORE_CTX 5 +# define CRYPTO_EX_INDEX_DH 6 +# define CRYPTO_EX_INDEX_DSA 7 +# define CRYPTO_EX_INDEX_EC_KEY 8 +# define CRYPTO_EX_INDEX_RSA 9 +# define CRYPTO_EX_INDEX_ENGINE 10 +# define CRYPTO_EX_INDEX_UI 11 +# define CRYPTO_EX_INDEX_BIO 12 +# define CRYPTO_EX_INDEX_APP 13 +# define CRYPTO_EX_INDEX_UI_METHOD 14 +# define CRYPTO_EX_INDEX_RAND_DRBG 15 +# define CRYPTO_EX_INDEX_DRBG CRYPTO_EX_INDEX_RAND_DRBG +# define CRYPTO_EX_INDEX_OSSL_LIB_CTX 16 +# define CRYPTO_EX_INDEX_EVP_PKEY 17 +# define CRYPTO_EX_INDEX__COUNT 18 + +typedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, + void **from_d, int idx, long argl, void *argp); +__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, + CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, + CRYPTO_EX_free *free_func); +/* No longer use an index. */ +int CRYPTO_free_ex_index(int class_index, int idx); + +/* + * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a + * given class (invokes whatever per-class callbacks are applicable) + */ +int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, + const CRYPTO_EX_DATA *from); + +void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); + +/* Allocate a single item in the CRYPTO_EX_DATA variable */ +int CRYPTO_alloc_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad, + int idx); + +/* + * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular + * index (relative to the class type involved) + */ +int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); +void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +/* + * This function cleans up all "ex_data" state. It mustn't be called under + * potential race-conditions. + */ +# define CRYPTO_cleanup_all_ex_data() while(0) continue + +/* + * The old locking functions have been removed completely without compatibility + * macros. This is because the old functions either could not properly report + * errors, or the returned error values were not clearly documented. + * Replacing the locking functions with no-ops would cause race condition + * issues in the affected applications. It is far better for them to fail at + * compile time. + * On the other hand, the locking callbacks are no longer used. Consequently, + * the callback management functions can be safely replaced with no-op macros. + */ +# define CRYPTO_num_locks() (1) +# define CRYPTO_set_locking_callback(func) +# define CRYPTO_get_locking_callback() (NULL) +# define CRYPTO_set_add_lock_callback(func) +# define CRYPTO_get_add_lock_callback() (NULL) + +/* + * These defines where used in combination with the old locking callbacks, + * they are not called anymore, but old code that's not called might still + * use them. + */ +# define CRYPTO_LOCK 1 +# define CRYPTO_UNLOCK 2 +# define CRYPTO_READ 4 +# define CRYPTO_WRITE 8 + +/* This structure is no longer used */ +typedef struct crypto_threadid_st { + int dummy; +} CRYPTO_THREADID; +/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ +# define CRYPTO_THREADID_set_numeric(id, val) +# define CRYPTO_THREADID_set_pointer(id, ptr) +# define CRYPTO_THREADID_set_callback(threadid_func) (0) +# define CRYPTO_THREADID_get_callback() (NULL) +# define CRYPTO_THREADID_current(id) +# define CRYPTO_THREADID_cmp(a, b) (-1) +# define CRYPTO_THREADID_cpy(dest, src) +# define CRYPTO_THREADID_hash(id) (0UL) + +# ifndef OPENSSL_NO_DEPRECATED_1_0_0 +# define CRYPTO_set_id_callback(func) +# define CRYPTO_get_id_callback() (NULL) +# define CRYPTO_thread_id() (0UL) +# endif /* OPENSSL_NO_DEPRECATED_1_0_0 */ + +# define CRYPTO_set_dynlock_create_callback(dyn_create_function) +# define CRYPTO_set_dynlock_lock_callback(dyn_lock_function) +# define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function) +# define CRYPTO_get_dynlock_create_callback() (NULL) +# define CRYPTO_get_dynlock_lock_callback() (NULL) +# define CRYPTO_get_dynlock_destroy_callback() (NULL) +# endif /* OPENSSL_NO_DEPRECATED_1_1_0 */ + +typedef void *(*CRYPTO_malloc_fn)(size_t num, const char *file, int line); +typedef void *(*CRYPTO_realloc_fn)(void *addr, size_t num, const char *file, + int line); +typedef void (*CRYPTO_free_fn)(void *addr, const char *file, int line); +int CRYPTO_set_mem_functions(CRYPTO_malloc_fn malloc_fn, + CRYPTO_realloc_fn realloc_fn, + CRYPTO_free_fn free_fn); +void CRYPTO_get_mem_functions(CRYPTO_malloc_fn *malloc_fn, + CRYPTO_realloc_fn *realloc_fn, + CRYPTO_free_fn *free_fn); + +OSSL_CRYPTO_ALLOC void *CRYPTO_malloc(size_t num, const char *file, int line); +OSSL_CRYPTO_ALLOC void *CRYPTO_zalloc(size_t num, const char *file, int line); +OSSL_CRYPTO_ALLOC void *CRYPTO_aligned_alloc(size_t num, size_t align, + void **freeptr, const char *file, + int line); +void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line); +char *CRYPTO_strdup(const char *str, const char *file, int line); +char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line); +void CRYPTO_free(void *ptr, const char *file, int line); +void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line); +void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line); +void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num, + const char *file, int line); + +int CRYPTO_secure_malloc_init(size_t sz, size_t minsize); +int CRYPTO_secure_malloc_done(void); +OSSL_CRYPTO_ALLOC void *CRYPTO_secure_malloc(size_t num, const char *file, int line); +OSSL_CRYPTO_ALLOC void *CRYPTO_secure_zalloc(size_t num, const char *file, int line); +void CRYPTO_secure_free(void *ptr, const char *file, int line); +void CRYPTO_secure_clear_free(void *ptr, size_t num, + const char *file, int line); +int CRYPTO_secure_allocated(const void *ptr); +int CRYPTO_secure_malloc_initialized(void); +size_t CRYPTO_secure_actual_size(void *ptr); +size_t CRYPTO_secure_used(void); + +void OPENSSL_cleanse(void *ptr, size_t len); + +# ifndef OPENSSL_NO_CRYPTO_MDEBUG +/* + * The following can be used to detect memory leaks in the library. If + * used, it turns on malloc checking + */ +# define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */ +# define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */ +# define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */ +# define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */ + +/* max allowed length for value of OPENSSL_MALLOC_FAILURES env var. */ +# define CRYPTO_MEM_CHECK_MAX_FS 256 + +void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define OPENSSL_mem_debug_push(info) \ + CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_mem_debug_pop() \ + CRYPTO_mem_debug_pop() +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int CRYPTO_set_mem_debug(int flag); +OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_ctrl(int mode); +OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_debug_push(const char *info, + const char *file, int line); +OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_debug_pop(void); +OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_malloc(void *addr, size_t num, + int flag, + const char *file, int line); +OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, + size_t num, int flag, + const char *file, int line); +OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_free(void *addr, int flag, + const char *file, int line); +OSSL_DEPRECATEDIN_3_0 +int CRYPTO_mem_leaks_cb(int (*cb)(const char *str, size_t len, void *u), + void *u); +# endif +# ifndef OPENSSL_NO_STDIO +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_leaks_fp(FILE *); +# endif +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_leaks(BIO *bio); +# endif +# endif /* OPENSSL_NO_CRYPTO_MDEBUG */ + +/* die if we have to */ +ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line); +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l)) +# endif +# define OPENSSL_assert(e) \ + (void)((e) ? 0 : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, OPENSSL_LINE), 1)) + +int OPENSSL_isservice(void); + +void OPENSSL_init(void); +# ifdef OPENSSL_SYS_UNIX +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_prepare(void); +OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_parent(void); +OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_child(void); +# endif +# endif + +struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); +int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); +int OPENSSL_gmtime_diff(int *pday, int *psec, + const struct tm *from, const struct tm *to); + +/* + * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. + * It takes an amount of time dependent on |len|, but independent of the + * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements + * into a defined order as the return value when a != b is undefined, other + * than to be non-zero. + */ +int CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len); + +/* Standard initialisation options */ +# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L +# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L +# define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L +# define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L +# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0x00000010L +# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0x00000020L +# define OPENSSL_INIT_LOAD_CONFIG 0x00000040L +# define OPENSSL_INIT_NO_LOAD_CONFIG 0x00000080L +# define OPENSSL_INIT_ASYNC 0x00000100L +# define OPENSSL_INIT_ENGINE_RDRAND 0x00000200L +# define OPENSSL_INIT_ENGINE_DYNAMIC 0x00000400L +# define OPENSSL_INIT_ENGINE_OPENSSL 0x00000800L +# define OPENSSL_INIT_ENGINE_CRYPTODEV 0x00001000L +# define OPENSSL_INIT_ENGINE_CAPI 0x00002000L +# define OPENSSL_INIT_ENGINE_PADLOCK 0x00004000L +# define OPENSSL_INIT_ENGINE_AFALG 0x00008000L +/* FREE: 0x00010000L */ +# define OPENSSL_INIT_ATFORK 0x00020000L +/* OPENSSL_INIT_BASE_ONLY 0x00040000L */ +# define OPENSSL_INIT_NO_ATEXIT 0x00080000L +/* OPENSSL_INIT flag range 0x03f00000 reserved for OPENSSL_init_ssl() */ +/* FREE: 0x04000000L */ +/* FREE: 0x08000000L */ +/* FREE: 0x10000000L */ +/* FREE: 0x20000000L */ +/* FREE: 0x40000000L */ +/* FREE: 0x80000000L */ +/* Max OPENSSL_INIT flag value is 0x80000000 */ + +/* openssl and dasync not counted as builtin */ +# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \ + (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \ + | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \ + OPENSSL_INIT_ENGINE_PADLOCK) + +/* Library initialisation functions */ +void OPENSSL_cleanup(void); +int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); +int OPENSSL_atexit(void (*handler)(void)); +void OPENSSL_thread_stop(void); +void OPENSSL_thread_stop_ex(OSSL_LIB_CTX *ctx); + +/* Low-level control of initialization */ +OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void); +# ifndef OPENSSL_NO_STDIO +int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings, + const char *config_filename); +void OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings, + unsigned long flags); +int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings, + const char *config_appname); +# endif +void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings); + +# if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) +# if defined(_WIN32) +# if defined(BASETYPES) || defined(_WINDEF_H) +/* application has to include in order to use this */ +typedef DWORD CRYPTO_THREAD_LOCAL; +typedef DWORD CRYPTO_THREAD_ID; + +typedef LONG CRYPTO_ONCE; +# define CRYPTO_ONCE_STATIC_INIT 0 +# endif +# else +# if defined(__TANDEM) && defined(_SPT_MODEL_) +# define SPT_THREAD_SIGNAL 1 +# define SPT_THREAD_AWARE 1 +# include +# else +# include +# endif +typedef pthread_once_t CRYPTO_ONCE; +typedef pthread_key_t CRYPTO_THREAD_LOCAL; +typedef pthread_t CRYPTO_THREAD_ID; + +# define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT +# endif +# endif + +# if !defined(CRYPTO_ONCE_STATIC_INIT) +typedef unsigned int CRYPTO_ONCE; +typedef unsigned int CRYPTO_THREAD_LOCAL; +typedef unsigned int CRYPTO_THREAD_ID; +# define CRYPTO_ONCE_STATIC_INIT 0 +# endif + +int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void)); + +int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *)); +void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key); +int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val); +int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key); + +CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void); +int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b); + +OSSL_LIB_CTX *OSSL_LIB_CTX_new(void); +OSSL_LIB_CTX *OSSL_LIB_CTX_new_from_dispatch(const OSSL_CORE_HANDLE *handle, + const OSSL_DISPATCH *in); +OSSL_LIB_CTX *OSSL_LIB_CTX_new_child(const OSSL_CORE_HANDLE *handle, + const OSSL_DISPATCH *in); +int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file); +void OSSL_LIB_CTX_free(OSSL_LIB_CTX *); +OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void); +OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx); +int OSSL_LIB_CTX_get_conf_diagnostics(OSSL_LIB_CTX *ctx); +void OSSL_LIB_CTX_set_conf_diagnostics(OSSL_LIB_CTX *ctx, int value); + +void OSSL_sleep(uint64_t millis); + + +void *OSSL_LIB_CTX_get_data(OSSL_LIB_CTX *ctx, int index); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/cryptoerr.h b/illumos-x86_64/usr/include/openssl-3/cryptoerr.h new file mode 100644 index 00000000..7fa79cf3 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cryptoerr.h @@ -0,0 +1,56 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CRYPTOERR_H +# define OPENSSL_CRYPTOERR_H +# pragma once + +# include +# include +# include + + + +/* + * CRYPTO reason codes. + */ +# define CRYPTO_R_BAD_ALGORITHM_NAME 117 +# define CRYPTO_R_CONFLICTING_NAMES 118 +# define CRYPTO_R_HEX_STRING_TOO_SHORT 121 +# define CRYPTO_R_ILLEGAL_HEX_DIGIT 102 +# define CRYPTO_R_INSUFFICIENT_DATA_SPACE 106 +# define CRYPTO_R_INSUFFICIENT_PARAM_SIZE 107 +# define CRYPTO_R_INSUFFICIENT_SECURE_DATA_SPACE 108 +# define CRYPTO_R_INTEGER_OVERFLOW 127 +# define CRYPTO_R_INVALID_NEGATIVE_VALUE 122 +# define CRYPTO_R_INVALID_NULL_ARGUMENT 109 +# define CRYPTO_R_INVALID_OSSL_PARAM_TYPE 110 +# define CRYPTO_R_NO_PARAMS_TO_MERGE 131 +# define CRYPTO_R_NO_SPACE_FOR_TERMINATING_NULL 128 +# define CRYPTO_R_ODD_NUMBER_OF_DIGITS 103 +# define CRYPTO_R_PARAM_CANNOT_BE_REPRESENTED_EXACTLY 123 +# define CRYPTO_R_PARAM_NOT_INTEGER_TYPE 124 +# define CRYPTO_R_PARAM_OF_INCOMPATIBLE_TYPE 129 +# define CRYPTO_R_PARAM_UNSIGNED_INTEGER_NEGATIVE_VALUE_UNSUPPORTED 125 +# define CRYPTO_R_PARAM_UNSUPPORTED_FLOATING_POINT_FORMAT 130 +# define CRYPTO_R_PARAM_VALUE_TOO_LARGE_FOR_DESTINATION 126 +# define CRYPTO_R_PROVIDER_ALREADY_EXISTS 104 +# define CRYPTO_R_PROVIDER_SECTION_ERROR 105 +# define CRYPTO_R_RANDOM_SECTION_ERROR 119 +# define CRYPTO_R_SECURE_MALLOC_FAILURE 111 +# define CRYPTO_R_STRING_TOO_LONG 112 +# define CRYPTO_R_TOO_MANY_BYTES 113 +# define CRYPTO_R_TOO_MANY_NAMES 132 +# define CRYPTO_R_TOO_MANY_RECORDS 114 +# define CRYPTO_R_TOO_SMALL_BUFFER 116 +# define CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION 120 +# define CRYPTO_R_ZERO_LENGTH_NUMBER 115 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/cryptoerr_legacy.h b/illumos-x86_64/usr/include/openssl-3/cryptoerr_legacy.h new file mode 100644 index 00000000..ccab33a5 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cryptoerr_legacy.h @@ -0,0 +1,1466 @@ +/* + * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * This header file preserves symbols from pre-3.0 OpenSSL. + * It should never be included directly, as it's already included + * by the public {lib}err.h headers, and since it will go away some + * time in the future. + */ + +#ifndef OPENSSL_CRYPTOERR_LEGACY_H +# define OPENSSL_CRYPTOERR_LEGACY_H +# pragma once + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ERR_load_ASN1_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_ASYNC_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_BIO_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_BN_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_BUF_strings(void); +# ifndef OPENSSL_NO_CMS +OSSL_DEPRECATEDIN_3_0 int ERR_load_CMS_strings(void); +# endif +# ifndef OPENSSL_NO_COMP +OSSL_DEPRECATEDIN_3_0 int ERR_load_COMP_strings(void); +# endif +OSSL_DEPRECATEDIN_3_0 int ERR_load_CONF_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_CRYPTO_strings(void); +# ifndef OPENSSL_NO_CT +OSSL_DEPRECATEDIN_3_0 int ERR_load_CT_strings(void); +# endif +# ifndef OPENSSL_NO_DH +OSSL_DEPRECATEDIN_3_0 int ERR_load_DH_strings(void); +# endif +# ifndef OPENSSL_NO_DSA +OSSL_DEPRECATEDIN_3_0 int ERR_load_DSA_strings(void); +# endif +# ifndef OPENSSL_NO_EC +OSSL_DEPRECATEDIN_3_0 int ERR_load_EC_strings(void); +# endif +# ifndef OPENSSL_NO_ENGINE +OSSL_DEPRECATEDIN_3_0 int ERR_load_ENGINE_strings(void); +# endif +OSSL_DEPRECATEDIN_3_0 int ERR_load_ERR_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_EVP_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_KDF_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_OBJ_strings(void); +# ifndef OPENSSL_NO_OCSP +OSSL_DEPRECATEDIN_3_0 int ERR_load_OCSP_strings(void); +# endif +OSSL_DEPRECATEDIN_3_0 int ERR_load_PEM_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_PKCS12_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_PKCS7_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_RAND_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_RSA_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_OSSL_STORE_strings(void); +# ifndef OPENSSL_NO_TS +OSSL_DEPRECATEDIN_3_0 int ERR_load_TS_strings(void); +# endif +OSSL_DEPRECATEDIN_3_0 int ERR_load_UI_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_X509_strings(void); +OSSL_DEPRECATEDIN_3_0 int ERR_load_X509V3_strings(void); + +/* Collected _F_ macros from OpenSSL 1.1.1 */ + +/* + * ASN1 function codes. + */ +# define ASN1_F_A2D_ASN1_OBJECT 0 +# define ASN1_F_A2I_ASN1_INTEGER 0 +# define ASN1_F_A2I_ASN1_STRING 0 +# define ASN1_F_APPEND_EXP 0 +# define ASN1_F_ASN1_BIO_INIT 0 +# define ASN1_F_ASN1_BIT_STRING_SET_BIT 0 +# define ASN1_F_ASN1_CB 0 +# define ASN1_F_ASN1_CHECK_TLEN 0 +# define ASN1_F_ASN1_COLLECT 0 +# define ASN1_F_ASN1_D2I_EX_PRIMITIVE 0 +# define ASN1_F_ASN1_D2I_FP 0 +# define ASN1_F_ASN1_D2I_READ_BIO 0 +# define ASN1_F_ASN1_DIGEST 0 +# define ASN1_F_ASN1_DO_ADB 0 +# define ASN1_F_ASN1_DO_LOCK 0 +# define ASN1_F_ASN1_DUP 0 +# define ASN1_F_ASN1_ENC_SAVE 0 +# define ASN1_F_ASN1_EX_C2I 0 +# define ASN1_F_ASN1_FIND_END 0 +# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 0 +# define ASN1_F_ASN1_GENERATE_V3 0 +# define ASN1_F_ASN1_GET_INT64 0 +# define ASN1_F_ASN1_GET_OBJECT 0 +# define ASN1_F_ASN1_GET_UINT64 0 +# define ASN1_F_ASN1_I2D_BIO 0 +# define ASN1_F_ASN1_I2D_FP 0 +# define ASN1_F_ASN1_ITEM_D2I_FP 0 +# define ASN1_F_ASN1_ITEM_DUP 0 +# define ASN1_F_ASN1_ITEM_EMBED_D2I 0 +# define ASN1_F_ASN1_ITEM_EMBED_NEW 0 +# define ASN1_F_ASN1_ITEM_FLAGS_I2D 0 +# define ASN1_F_ASN1_ITEM_I2D_BIO 0 +# define ASN1_F_ASN1_ITEM_I2D_FP 0 +# define ASN1_F_ASN1_ITEM_PACK 0 +# define ASN1_F_ASN1_ITEM_SIGN 0 +# define ASN1_F_ASN1_ITEM_SIGN_CTX 0 +# define ASN1_F_ASN1_ITEM_UNPACK 0 +# define ASN1_F_ASN1_ITEM_VERIFY 0 +# define ASN1_F_ASN1_MBSTRING_NCOPY 0 +# define ASN1_F_ASN1_OBJECT_NEW 0 +# define ASN1_F_ASN1_OUTPUT_DATA 0 +# define ASN1_F_ASN1_PCTX_NEW 0 +# define ASN1_F_ASN1_PRIMITIVE_NEW 0 +# define ASN1_F_ASN1_SCTX_NEW 0 +# define ASN1_F_ASN1_SIGN 0 +# define ASN1_F_ASN1_STR2TYPE 0 +# define ASN1_F_ASN1_STRING_GET_INT64 0 +# define ASN1_F_ASN1_STRING_GET_UINT64 0 +# define ASN1_F_ASN1_STRING_SET 0 +# define ASN1_F_ASN1_STRING_TABLE_ADD 0 +# define ASN1_F_ASN1_STRING_TO_BN 0 +# define ASN1_F_ASN1_STRING_TYPE_NEW 0 +# define ASN1_F_ASN1_TEMPLATE_EX_D2I 0 +# define ASN1_F_ASN1_TEMPLATE_NEW 0 +# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 0 +# define ASN1_F_ASN1_TIME_ADJ 0 +# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 0 +# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 0 +# define ASN1_F_ASN1_UTCTIME_ADJ 0 +# define ASN1_F_ASN1_VERIFY 0 +# define ASN1_F_B64_READ_ASN1 0 +# define ASN1_F_B64_WRITE_ASN1 0 +# define ASN1_F_BIO_NEW_NDEF 0 +# define ASN1_F_BITSTR_CB 0 +# define ASN1_F_BN_TO_ASN1_STRING 0 +# define ASN1_F_C2I_ASN1_BIT_STRING 0 +# define ASN1_F_C2I_ASN1_INTEGER 0 +# define ASN1_F_C2I_ASN1_OBJECT 0 +# define ASN1_F_C2I_IBUF 0 +# define ASN1_F_C2I_UINT64_INT 0 +# define ASN1_F_COLLECT_DATA 0 +# define ASN1_F_D2I_ASN1_OBJECT 0 +# define ASN1_F_D2I_ASN1_UINTEGER 0 +# define ASN1_F_D2I_AUTOPRIVATEKEY 0 +# define ASN1_F_D2I_PRIVATEKEY 0 +# define ASN1_F_D2I_PUBLICKEY 0 +# define ASN1_F_DO_BUF 0 +# define ASN1_F_DO_CREATE 0 +# define ASN1_F_DO_DUMP 0 +# define ASN1_F_DO_TCREATE 0 +# define ASN1_F_I2A_ASN1_OBJECT 0 +# define ASN1_F_I2D_ASN1_BIO_STREAM 0 +# define ASN1_F_I2D_ASN1_OBJECT 0 +# define ASN1_F_I2D_DSA_PUBKEY 0 +# define ASN1_F_I2D_EC_PUBKEY 0 +# define ASN1_F_I2D_PRIVATEKEY 0 +# define ASN1_F_I2D_PUBLICKEY 0 +# define ASN1_F_I2D_RSA_PUBKEY 0 +# define ASN1_F_LONG_C2I 0 +# define ASN1_F_NDEF_PREFIX 0 +# define ASN1_F_NDEF_SUFFIX 0 +# define ASN1_F_OID_MODULE_INIT 0 +# define ASN1_F_PARSE_TAGGING 0 +# define ASN1_F_PKCS5_PBE2_SET_IV 0 +# define ASN1_F_PKCS5_PBE2_SET_SCRYPT 0 +# define ASN1_F_PKCS5_PBE_SET 0 +# define ASN1_F_PKCS5_PBE_SET0_ALGOR 0 +# define ASN1_F_PKCS5_PBKDF2_SET 0 +# define ASN1_F_PKCS5_SCRYPT_SET 0 +# define ASN1_F_SMIME_READ_ASN1 0 +# define ASN1_F_SMIME_TEXT 0 +# define ASN1_F_STABLE_GET 0 +# define ASN1_F_STBL_MODULE_INIT 0 +# define ASN1_F_UINT32_C2I 0 +# define ASN1_F_UINT32_NEW 0 +# define ASN1_F_UINT64_C2I 0 +# define ASN1_F_UINT64_NEW 0 +# define ASN1_F_X509_CRL_ADD0_REVOKED 0 +# define ASN1_F_X509_INFO_NEW 0 +# define ASN1_F_X509_NAME_ENCODE 0 +# define ASN1_F_X509_NAME_EX_D2I 0 +# define ASN1_F_X509_NAME_EX_NEW 0 +# define ASN1_F_X509_PKEY_NEW 0 + +/* + * ASYNC function codes. + */ +# define ASYNC_F_ASYNC_CTX_NEW 0 +# define ASYNC_F_ASYNC_INIT_THREAD 0 +# define ASYNC_F_ASYNC_JOB_NEW 0 +# define ASYNC_F_ASYNC_PAUSE_JOB 0 +# define ASYNC_F_ASYNC_START_FUNC 0 +# define ASYNC_F_ASYNC_START_JOB 0 +# define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD 0 + +/* + * BIO function codes. + */ +# define BIO_F_ACPT_STATE 0 +# define BIO_F_ADDRINFO_WRAP 0 +# define BIO_F_ADDR_STRINGS 0 +# define BIO_F_BIO_ACCEPT 0 +# define BIO_F_BIO_ACCEPT_EX 0 +# define BIO_F_BIO_ACCEPT_NEW 0 +# define BIO_F_BIO_ADDR_NEW 0 +# define BIO_F_BIO_BIND 0 +# define BIO_F_BIO_CALLBACK_CTRL 0 +# define BIO_F_BIO_CONNECT 0 +# define BIO_F_BIO_CONNECT_NEW 0 +# define BIO_F_BIO_CTRL 0 +# define BIO_F_BIO_GETS 0 +# define BIO_F_BIO_GET_HOST_IP 0 +# define BIO_F_BIO_GET_NEW_INDEX 0 +# define BIO_F_BIO_GET_PORT 0 +# define BIO_F_BIO_LISTEN 0 +# define BIO_F_BIO_LOOKUP 0 +# define BIO_F_BIO_LOOKUP_EX 0 +# define BIO_F_BIO_MAKE_PAIR 0 +# define BIO_F_BIO_METH_NEW 0 +# define BIO_F_BIO_NEW 0 +# define BIO_F_BIO_NEW_DGRAM_SCTP 0 +# define BIO_F_BIO_NEW_FILE 0 +# define BIO_F_BIO_NEW_MEM_BUF 0 +# define BIO_F_BIO_NREAD 0 +# define BIO_F_BIO_NREAD0 0 +# define BIO_F_BIO_NWRITE 0 +# define BIO_F_BIO_NWRITE0 0 +# define BIO_F_BIO_PARSE_HOSTSERV 0 +# define BIO_F_BIO_PUTS 0 +# define BIO_F_BIO_READ 0 +# define BIO_F_BIO_READ_EX 0 +# define BIO_F_BIO_READ_INTERN 0 +# define BIO_F_BIO_SOCKET 0 +# define BIO_F_BIO_SOCKET_NBIO 0 +# define BIO_F_BIO_SOCK_INFO 0 +# define BIO_F_BIO_SOCK_INIT 0 +# define BIO_F_BIO_WRITE 0 +# define BIO_F_BIO_WRITE_EX 0 +# define BIO_F_BIO_WRITE_INTERN 0 +# define BIO_F_BUFFER_CTRL 0 +# define BIO_F_CONN_CTRL 0 +# define BIO_F_CONN_STATE 0 +# define BIO_F_DGRAM_SCTP_NEW 0 +# define BIO_F_DGRAM_SCTP_READ 0 +# define BIO_F_DGRAM_SCTP_WRITE 0 +# define BIO_F_DOAPR_OUTCH 0 +# define BIO_F_FILE_CTRL 0 +# define BIO_F_FILE_READ 0 +# define BIO_F_LINEBUFFER_CTRL 0 +# define BIO_F_LINEBUFFER_NEW 0 +# define BIO_F_MEM_WRITE 0 +# define BIO_F_NBIOF_NEW 0 +# define BIO_F_SLG_WRITE 0 +# define BIO_F_SSL_NEW 0 + +/* + * BN function codes. + */ +# define BN_F_BNRAND 0 +# define BN_F_BNRAND_RANGE 0 +# define BN_F_BN_BLINDING_CONVERT_EX 0 +# define BN_F_BN_BLINDING_CREATE_PARAM 0 +# define BN_F_BN_BLINDING_INVERT_EX 0 +# define BN_F_BN_BLINDING_NEW 0 +# define BN_F_BN_BLINDING_UPDATE 0 +# define BN_F_BN_BN2DEC 0 +# define BN_F_BN_BN2HEX 0 +# define BN_F_BN_COMPUTE_WNAF 0 +# define BN_F_BN_CTX_GET 0 +# define BN_F_BN_CTX_NEW 0 +# define BN_F_BN_CTX_START 0 +# define BN_F_BN_DIV 0 +# define BN_F_BN_DIV_RECP 0 +# define BN_F_BN_EXP 0 +# define BN_F_BN_EXPAND_INTERNAL 0 +# define BN_F_BN_GENCB_NEW 0 +# define BN_F_BN_GENERATE_DSA_NONCE 0 +# define BN_F_BN_GENERATE_PRIME_EX 0 +# define BN_F_BN_GF2M_MOD 0 +# define BN_F_BN_GF2M_MOD_EXP 0 +# define BN_F_BN_GF2M_MOD_MUL 0 +# define BN_F_BN_GF2M_MOD_SOLVE_QUAD 0 +# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 0 +# define BN_F_BN_GF2M_MOD_SQR 0 +# define BN_F_BN_GF2M_MOD_SQRT 0 +# define BN_F_BN_LSHIFT 0 +# define BN_F_BN_MOD_EXP2_MONT 0 +# define BN_F_BN_MOD_EXP_MONT 0 +# define BN_F_BN_MOD_EXP_MONT_CONSTTIME 0 +# define BN_F_BN_MOD_EXP_MONT_WORD 0 +# define BN_F_BN_MOD_EXP_RECP 0 +# define BN_F_BN_MOD_EXP_SIMPLE 0 +# define BN_F_BN_MOD_INVERSE 0 +# define BN_F_BN_MOD_INVERSE_NO_BRANCH 0 +# define BN_F_BN_MOD_LSHIFT_QUICK 0 +# define BN_F_BN_MOD_SQRT 0 +# define BN_F_BN_MONT_CTX_NEW 0 +# define BN_F_BN_MPI2BN 0 +# define BN_F_BN_NEW 0 +# define BN_F_BN_POOL_GET 0 +# define BN_F_BN_RAND 0 +# define BN_F_BN_RAND_RANGE 0 +# define BN_F_BN_RECP_CTX_NEW 0 +# define BN_F_BN_RSHIFT 0 +# define BN_F_BN_SET_WORDS 0 +# define BN_F_BN_STACK_PUSH 0 +# define BN_F_BN_USUB 0 + +/* + * BUF function codes. + */ +# define BUF_F_BUF_MEM_GROW 0 +# define BUF_F_BUF_MEM_GROW_CLEAN 0 +# define BUF_F_BUF_MEM_NEW 0 + +# ifndef OPENSSL_NO_CMS +/* + * CMS function codes. + */ +# define CMS_F_CHECK_CONTENT 0 +# define CMS_F_CMS_ADD0_CERT 0 +# define CMS_F_CMS_ADD0_RECIPIENT_KEY 0 +# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD 0 +# define CMS_F_CMS_ADD1_RECEIPTREQUEST 0 +# define CMS_F_CMS_ADD1_RECIPIENT_CERT 0 +# define CMS_F_CMS_ADD1_SIGNER 0 +# define CMS_F_CMS_ADD1_SIGNINGTIME 0 +# define CMS_F_CMS_COMPRESS 0 +# define CMS_F_CMS_COMPRESSEDDATA_CREATE 0 +# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO 0 +# define CMS_F_CMS_COPY_CONTENT 0 +# define CMS_F_CMS_COPY_MESSAGEDIGEST 0 +# define CMS_F_CMS_DATA 0 +# define CMS_F_CMS_DATAFINAL 0 +# define CMS_F_CMS_DATAINIT 0 +# define CMS_F_CMS_DECRYPT 0 +# define CMS_F_CMS_DECRYPT_SET1_KEY 0 +# define CMS_F_CMS_DECRYPT_SET1_PASSWORD 0 +# define CMS_F_CMS_DECRYPT_SET1_PKEY 0 +# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX 0 +# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO 0 +# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL 0 +# define CMS_F_CMS_DIGEST_VERIFY 0 +# define CMS_F_CMS_ENCODE_RECEIPT 0 +# define CMS_F_CMS_ENCRYPT 0 +# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT 0 +# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO 0 +# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT 0 +# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT 0 +# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY 0 +# define CMS_F_CMS_ENVELOPEDDATA_CREATE 0 +# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO 0 +# define CMS_F_CMS_ENVELOPED_DATA_INIT 0 +# define CMS_F_CMS_ENV_ASN1_CTRL 0 +# define CMS_F_CMS_FINAL 0 +# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES 0 +# define CMS_F_CMS_GET0_CONTENT 0 +# define CMS_F_CMS_GET0_ECONTENT_TYPE 0 +# define CMS_F_CMS_GET0_ENVELOPED 0 +# define CMS_F_CMS_GET0_REVOCATION_CHOICES 0 +# define CMS_F_CMS_GET0_SIGNED 0 +# define CMS_F_CMS_MSGSIGDIGEST_ADD1 0 +# define CMS_F_CMS_RECEIPTREQUEST_CREATE0 0 +# define CMS_F_CMS_RECEIPT_VERIFY 0 +# define CMS_F_CMS_RECIPIENTINFO_DECRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP 0 +# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID 0 +# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID 0 +# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY 0 +# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD 0 +# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY 0 +# define CMS_F_CMS_SD_ASN1_CTRL 0 +# define CMS_F_CMS_SET1_IAS 0 +# define CMS_F_CMS_SET1_KEYID 0 +# define CMS_F_CMS_SET1_SIGNERIDENTIFIER 0 +# define CMS_F_CMS_SET_DETACHED 0 +# define CMS_F_CMS_SIGN 0 +# define CMS_F_CMS_SIGNED_DATA_INIT 0 +# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN 0 +# define CMS_F_CMS_SIGNERINFO_SIGN 0 +# define CMS_F_CMS_SIGNERINFO_VERIFY 0 +# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 0 +# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 0 +# define CMS_F_CMS_SIGN_RECEIPT 0 +# define CMS_F_CMS_SI_CHECK_ATTRIBUTES 0 +# define CMS_F_CMS_STREAM 0 +# define CMS_F_CMS_UNCOMPRESS 0 +# define CMS_F_CMS_VERIFY 0 +# define CMS_F_KEK_UNWRAP_KEY 0 +# endif + +# ifndef OPENSSL_NO_COMP +/* + * COMP function codes. + */ +# define COMP_F_BIO_ZLIB_FLUSH 0 +# define COMP_F_BIO_ZLIB_NEW 0 +# define COMP_F_BIO_ZLIB_READ 0 +# define COMP_F_BIO_ZLIB_WRITE 0 +# define COMP_F_COMP_CTX_NEW 0 +# endif + +/* + * CONF function codes. + */ +# define CONF_F_CONF_DUMP_FP 0 +# define CONF_F_CONF_LOAD 0 +# define CONF_F_CONF_LOAD_FP 0 +# define CONF_F_CONF_PARSE_LIST 0 +# define CONF_F_DEF_LOAD 0 +# define CONF_F_DEF_LOAD_BIO 0 +# define CONF_F_GET_NEXT_FILE 0 +# define CONF_F_MODULE_ADD 0 +# define CONF_F_MODULE_INIT 0 +# define CONF_F_MODULE_LOAD_DSO 0 +# define CONF_F_MODULE_RUN 0 +# define CONF_F_NCONF_DUMP_BIO 0 +# define CONF_F_NCONF_DUMP_FP 0 +# define CONF_F_NCONF_GET_NUMBER_E 0 +# define CONF_F_NCONF_GET_SECTION 0 +# define CONF_F_NCONF_GET_STRING 0 +# define CONF_F_NCONF_LOAD 0 +# define CONF_F_NCONF_LOAD_BIO 0 +# define CONF_F_NCONF_LOAD_FP 0 +# define CONF_F_NCONF_NEW 0 +# define CONF_F_PROCESS_INCLUDE 0 +# define CONF_F_SSL_MODULE_INIT 0 +# define CONF_F_STR_COPY 0 + +/* + * CRYPTO function codes. + */ +# define CRYPTO_F_CMAC_CTX_NEW 0 +# define CRYPTO_F_CRYPTO_DUP_EX_DATA 0 +# define CRYPTO_F_CRYPTO_FREE_EX_DATA 0 +# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 0 +# define CRYPTO_F_CRYPTO_MEMDUP 0 +# define CRYPTO_F_CRYPTO_NEW_EX_DATA 0 +# define CRYPTO_F_CRYPTO_OCB128_COPY_CTX 0 +# define CRYPTO_F_CRYPTO_OCB128_INIT 0 +# define CRYPTO_F_CRYPTO_SET_EX_DATA 0 +# define CRYPTO_F_GET_AND_LOCK 0 +# define CRYPTO_F_OPENSSL_ATEXIT 0 +# define CRYPTO_F_OPENSSL_BUF2HEXSTR 0 +# define CRYPTO_F_OPENSSL_FOPEN 0 +# define CRYPTO_F_OPENSSL_HEXSTR2BUF 0 +# define CRYPTO_F_OPENSSL_INIT_CRYPTO 0 +# define CRYPTO_F_OPENSSL_LH_NEW 0 +# define CRYPTO_F_OPENSSL_SK_DEEP_COPY 0 +# define CRYPTO_F_OPENSSL_SK_DUP 0 +# define CRYPTO_F_PKEY_HMAC_INIT 0 +# define CRYPTO_F_PKEY_POLY1305_INIT 0 +# define CRYPTO_F_PKEY_SIPHASH_INIT 0 +# define CRYPTO_F_SK_RESERVE 0 + +# ifndef OPENSSL_NO_CT +/* + * CT function codes. + */ +# define CT_F_CTLOG_NEW 0 +# define CT_F_CTLOG_NEW_FROM_BASE64 0 +# define CT_F_CTLOG_NEW_FROM_CONF 0 +# define CT_F_CTLOG_STORE_LOAD_CTX_NEW 0 +# define CT_F_CTLOG_STORE_LOAD_FILE 0 +# define CT_F_CTLOG_STORE_LOAD_LOG 0 +# define CT_F_CTLOG_STORE_NEW 0 +# define CT_F_CT_BASE64_DECODE 0 +# define CT_F_CT_POLICY_EVAL_CTX_NEW 0 +# define CT_F_CT_V1_LOG_ID_FROM_PKEY 0 +# define CT_F_I2O_SCT 0 +# define CT_F_I2O_SCT_LIST 0 +# define CT_F_I2O_SCT_SIGNATURE 0 +# define CT_F_O2I_SCT 0 +# define CT_F_O2I_SCT_LIST 0 +# define CT_F_O2I_SCT_SIGNATURE 0 +# define CT_F_SCT_CTX_NEW 0 +# define CT_F_SCT_CTX_VERIFY 0 +# define CT_F_SCT_NEW 0 +# define CT_F_SCT_NEW_FROM_BASE64 0 +# define CT_F_SCT_SET0_LOG_ID 0 +# define CT_F_SCT_SET1_EXTENSIONS 0 +# define CT_F_SCT_SET1_LOG_ID 0 +# define CT_F_SCT_SET1_SIGNATURE 0 +# define CT_F_SCT_SET_LOG_ENTRY_TYPE 0 +# define CT_F_SCT_SET_SIGNATURE_NID 0 +# define CT_F_SCT_SET_VERSION 0 +# endif + +# ifndef OPENSSL_NO_DH +/* + * DH function codes. + */ +# define DH_F_COMPUTE_KEY 0 +# define DH_F_DHPARAMS_PRINT_FP 0 +# define DH_F_DH_BUILTIN_GENPARAMS 0 +# define DH_F_DH_CHECK_EX 0 +# define DH_F_DH_CHECK_PARAMS_EX 0 +# define DH_F_DH_CHECK_PUB_KEY_EX 0 +# define DH_F_DH_CMS_DECRYPT 0 +# define DH_F_DH_CMS_SET_PEERKEY 0 +# define DH_F_DH_CMS_SET_SHARED_INFO 0 +# define DH_F_DH_METH_DUP 0 +# define DH_F_DH_METH_NEW 0 +# define DH_F_DH_METH_SET1_NAME 0 +# define DH_F_DH_NEW_BY_NID 0 +# define DH_F_DH_NEW_METHOD 0 +# define DH_F_DH_PARAM_DECODE 0 +# define DH_F_DH_PKEY_PUBLIC_CHECK 0 +# define DH_F_DH_PRIV_DECODE 0 +# define DH_F_DH_PRIV_ENCODE 0 +# define DH_F_DH_PUB_DECODE 0 +# define DH_F_DH_PUB_ENCODE 0 +# define DH_F_DO_DH_PRINT 0 +# define DH_F_GENERATE_KEY 0 +# define DH_F_PKEY_DH_CTRL_STR 0 +# define DH_F_PKEY_DH_DERIVE 0 +# define DH_F_PKEY_DH_INIT 0 +# define DH_F_PKEY_DH_KEYGEN 0 +# endif + +# ifndef OPENSSL_NO_DSA +/* + * DSA function codes. + */ +# define DSA_F_DSAPARAMS_PRINT 0 +# define DSA_F_DSAPARAMS_PRINT_FP 0 +# define DSA_F_DSA_BUILTIN_PARAMGEN 0 +# define DSA_F_DSA_BUILTIN_PARAMGEN2 0 +# define DSA_F_DSA_DO_SIGN 0 +# define DSA_F_DSA_DO_VERIFY 0 +# define DSA_F_DSA_METH_DUP 0 +# define DSA_F_DSA_METH_NEW 0 +# define DSA_F_DSA_METH_SET1_NAME 0 +# define DSA_F_DSA_NEW_METHOD 0 +# define DSA_F_DSA_PARAM_DECODE 0 +# define DSA_F_DSA_PRINT_FP 0 +# define DSA_F_DSA_PRIV_DECODE 0 +# define DSA_F_DSA_PRIV_ENCODE 0 +# define DSA_F_DSA_PUB_DECODE 0 +# define DSA_F_DSA_PUB_ENCODE 0 +# define DSA_F_DSA_SIGN 0 +# define DSA_F_DSA_SIGN_SETUP 0 +# define DSA_F_DSA_SIG_NEW 0 +# define DSA_F_OLD_DSA_PRIV_DECODE 0 +# define DSA_F_PKEY_DSA_CTRL 0 +# define DSA_F_PKEY_DSA_CTRL_STR 0 +# define DSA_F_PKEY_DSA_KEYGEN 0 +# endif + +# ifndef OPENSSL_NO_EC +/* + * EC function codes. + */ +# define EC_F_BN_TO_FELEM 0 +# define EC_F_D2I_ECPARAMETERS 0 +# define EC_F_D2I_ECPKPARAMETERS 0 +# define EC_F_D2I_ECPRIVATEKEY 0 +# define EC_F_DO_EC_KEY_PRINT 0 +# define EC_F_ECDH_CMS_DECRYPT 0 +# define EC_F_ECDH_CMS_SET_SHARED_INFO 0 +# define EC_F_ECDH_COMPUTE_KEY 0 +# define EC_F_ECDH_SIMPLE_COMPUTE_KEY 0 +# define EC_F_ECDSA_DO_SIGN_EX 0 +# define EC_F_ECDSA_DO_VERIFY 0 +# define EC_F_ECDSA_SIGN_EX 0 +# define EC_F_ECDSA_SIGN_SETUP 0 +# define EC_F_ECDSA_SIG_NEW 0 +# define EC_F_ECDSA_VERIFY 0 +# define EC_F_ECD_ITEM_VERIFY 0 +# define EC_F_ECKEY_PARAM2TYPE 0 +# define EC_F_ECKEY_PARAM_DECODE 0 +# define EC_F_ECKEY_PRIV_DECODE 0 +# define EC_F_ECKEY_PRIV_ENCODE 0 +# define EC_F_ECKEY_PUB_DECODE 0 +# define EC_F_ECKEY_PUB_ENCODE 0 +# define EC_F_ECKEY_TYPE2PARAM 0 +# define EC_F_ECPARAMETERS_PRINT 0 +# define EC_F_ECPARAMETERS_PRINT_FP 0 +# define EC_F_ECPKPARAMETERS_PRINT 0 +# define EC_F_ECPKPARAMETERS_PRINT_FP 0 +# define EC_F_ECP_NISTZ256_GET_AFFINE 0 +# define EC_F_ECP_NISTZ256_INV_MOD_ORD 0 +# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 0 +# define EC_F_ECP_NISTZ256_POINTS_MUL 0 +# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 0 +# define EC_F_ECP_NISTZ256_WINDOWED_MUL 0 +# define EC_F_ECX_KEY_OP 0 +# define EC_F_ECX_PRIV_ENCODE 0 +# define EC_F_ECX_PUB_ENCODE 0 +# define EC_F_EC_ASN1_GROUP2CURVE 0 +# define EC_F_EC_ASN1_GROUP2FIELDID 0 +# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 0 +# define EC_F_EC_GF2M_SIMPLE_FIELD_INV 0 +# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 0 +# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 0 +# define EC_F_EC_GF2M_SIMPLE_LADDER_POST 0 +# define EC_F_EC_GF2M_SIMPLE_LADDER_PRE 0 +# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 0 +# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 0 +# define EC_F_EC_GF2M_SIMPLE_POINTS_MUL 0 +# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 0 +# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 0 +# define EC_F_EC_GFP_MONT_FIELD_DECODE 0 +# define EC_F_EC_GFP_MONT_FIELD_ENCODE 0 +# define EC_F_EC_GFP_MONT_FIELD_INV 0 +# define EC_F_EC_GFP_MONT_FIELD_MUL 0 +# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 0 +# define EC_F_EC_GFP_MONT_FIELD_SQR 0 +# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_NISTP224_POINTS_MUL 0 +# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_NISTP256_POINTS_MUL 0 +# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_NISTP521_POINTS_MUL 0 +# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_NIST_FIELD_MUL 0 +# define EC_F_EC_GFP_NIST_FIELD_SQR 0 +# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES 0 +# define EC_F_EC_GFP_SIMPLE_FIELD_INV 0 +# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 0 +# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 0 +# define EC_F_EC_GFP_SIMPLE_OCT2POINT 0 +# define EC_F_EC_GFP_SIMPLE_POINT2OCT 0 +# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 0 +# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 0 +# define EC_F_EC_GROUP_CHECK 0 +# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 0 +# define EC_F_EC_GROUP_COPY 0 +# define EC_F_EC_GROUP_GET_CURVE 0 +# define EC_F_EC_GROUP_GET_CURVE_GF2M 0 +# define EC_F_EC_GROUP_GET_CURVE_GFP 0 +# define EC_F_EC_GROUP_GET_DEGREE 0 +# define EC_F_EC_GROUP_GET_ECPARAMETERS 0 +# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 0 +# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 0 +# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 0 +# define EC_F_EC_GROUP_NEW 0 +# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 0 +# define EC_F_EC_GROUP_NEW_FROM_DATA 0 +# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 0 +# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 0 +# define EC_F_EC_GROUP_SET_CURVE 0 +# define EC_F_EC_GROUP_SET_CURVE_GF2M 0 +# define EC_F_EC_GROUP_SET_CURVE_GFP 0 +# define EC_F_EC_GROUP_SET_GENERATOR 0 +# define EC_F_EC_GROUP_SET_SEED 0 +# define EC_F_EC_KEY_CHECK_KEY 0 +# define EC_F_EC_KEY_COPY 0 +# define EC_F_EC_KEY_GENERATE_KEY 0 +# define EC_F_EC_KEY_NEW 0 +# define EC_F_EC_KEY_NEW_METHOD 0 +# define EC_F_EC_KEY_OCT2PRIV 0 +# define EC_F_EC_KEY_PRINT 0 +# define EC_F_EC_KEY_PRINT_FP 0 +# define EC_F_EC_KEY_PRIV2BUF 0 +# define EC_F_EC_KEY_PRIV2OCT 0 +# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 0 +# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 0 +# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 0 +# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 0 +# define EC_F_EC_PKEY_CHECK 0 +# define EC_F_EC_PKEY_PARAM_CHECK 0 +# define EC_F_EC_POINTS_MAKE_AFFINE 0 +# define EC_F_EC_POINTS_MUL 0 +# define EC_F_EC_POINT_ADD 0 +# define EC_F_EC_POINT_BN2POINT 0 +# define EC_F_EC_POINT_CMP 0 +# define EC_F_EC_POINT_COPY 0 +# define EC_F_EC_POINT_DBL 0 +# define EC_F_EC_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 0 +# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 0 +# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 0 +# define EC_F_EC_POINT_INVERT 0 +# define EC_F_EC_POINT_IS_AT_INFINITY 0 +# define EC_F_EC_POINT_IS_ON_CURVE 0 +# define EC_F_EC_POINT_MAKE_AFFINE 0 +# define EC_F_EC_POINT_NEW 0 +# define EC_F_EC_POINT_OCT2POINT 0 +# define EC_F_EC_POINT_POINT2BUF 0 +# define EC_F_EC_POINT_POINT2OCT 0 +# define EC_F_EC_POINT_SET_AFFINE_COORDINATES 0 +# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 0 +# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 0 +# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES 0 +# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 0 +# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 0 +# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 0 +# define EC_F_EC_POINT_SET_TO_INFINITY 0 +# define EC_F_EC_PRE_COMP_NEW 0 +# define EC_F_EC_SCALAR_MUL_LADDER 0 +# define EC_F_EC_WNAF_MUL 0 +# define EC_F_EC_WNAF_PRECOMPUTE_MULT 0 +# define EC_F_I2D_ECPARAMETERS 0 +# define EC_F_I2D_ECPKPARAMETERS 0 +# define EC_F_I2D_ECPRIVATEKEY 0 +# define EC_F_I2O_ECPUBLICKEY 0 +# define EC_F_NISTP224_PRE_COMP_NEW 0 +# define EC_F_NISTP256_PRE_COMP_NEW 0 +# define EC_F_NISTP521_PRE_COMP_NEW 0 +# define EC_F_O2I_ECPUBLICKEY 0 +# define EC_F_OLD_EC_PRIV_DECODE 0 +# define EC_F_OSSL_ECDH_COMPUTE_KEY 0 +# define EC_F_OSSL_ECDSA_SIGN_SIG 0 +# define EC_F_OSSL_ECDSA_VERIFY_SIG 0 +# define EC_F_PKEY_ECD_CTRL 0 +# define EC_F_PKEY_ECD_DIGESTSIGN 0 +# define EC_F_PKEY_ECD_DIGESTSIGN25519 0 +# define EC_F_PKEY_ECD_DIGESTSIGN448 0 +# define EC_F_PKEY_ECX_DERIVE 0 +# define EC_F_PKEY_EC_CTRL 0 +# define EC_F_PKEY_EC_CTRL_STR 0 +# define EC_F_PKEY_EC_DERIVE 0 +# define EC_F_PKEY_EC_INIT 0 +# define EC_F_PKEY_EC_KDF_DERIVE 0 +# define EC_F_PKEY_EC_KEYGEN 0 +# define EC_F_PKEY_EC_PARAMGEN 0 +# define EC_F_PKEY_EC_SIGN 0 +# define EC_F_VALIDATE_ECX_DERIVE 0 +# endif + +# ifndef OPENSSL_NO_ENGINE +/* + * ENGINE function codes. + */ +# define ENGINE_F_DIGEST_UPDATE 0 +# define ENGINE_F_DYNAMIC_CTRL 0 +# define ENGINE_F_DYNAMIC_GET_DATA_CTX 0 +# define ENGINE_F_DYNAMIC_LOAD 0 +# define ENGINE_F_DYNAMIC_SET_DATA_CTX 0 +# define ENGINE_F_ENGINE_ADD 0 +# define ENGINE_F_ENGINE_BY_ID 0 +# define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 0 +# define ENGINE_F_ENGINE_CTRL 0 +# define ENGINE_F_ENGINE_CTRL_CMD 0 +# define ENGINE_F_ENGINE_CTRL_CMD_STRING 0 +# define ENGINE_F_ENGINE_FINISH 0 +# define ENGINE_F_ENGINE_GET_CIPHER 0 +# define ENGINE_F_ENGINE_GET_DIGEST 0 +# define ENGINE_F_ENGINE_GET_FIRST 0 +# define ENGINE_F_ENGINE_GET_LAST 0 +# define ENGINE_F_ENGINE_GET_NEXT 0 +# define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH 0 +# define ENGINE_F_ENGINE_GET_PKEY_METH 0 +# define ENGINE_F_ENGINE_GET_PREV 0 +# define ENGINE_F_ENGINE_INIT 0 +# define ENGINE_F_ENGINE_LIST_ADD 0 +# define ENGINE_F_ENGINE_LIST_REMOVE 0 +# define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 0 +# define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 0 +# define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 0 +# define ENGINE_F_ENGINE_NEW 0 +# define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR 0 +# define ENGINE_F_ENGINE_REMOVE 0 +# define ENGINE_F_ENGINE_SET_DEFAULT_STRING 0 +# define ENGINE_F_ENGINE_SET_ID 0 +# define ENGINE_F_ENGINE_SET_NAME 0 +# define ENGINE_F_ENGINE_TABLE_REGISTER 0 +# define ENGINE_F_ENGINE_UNLOCKED_FINISH 0 +# define ENGINE_F_ENGINE_UP_REF 0 +# define ENGINE_F_INT_CLEANUP_ITEM 0 +# define ENGINE_F_INT_CTRL_HELPER 0 +# define ENGINE_F_INT_ENGINE_CONFIGURE 0 +# define ENGINE_F_INT_ENGINE_MODULE_INIT 0 +# define ENGINE_F_OSSL_HMAC_INIT 0 +# endif + +/* + * EVP function codes. + */ +# define EVP_F_AESNI_INIT_KEY 0 +# define EVP_F_AESNI_XTS_INIT_KEY 0 +# define EVP_F_AES_GCM_CTRL 0 +# define EVP_F_AES_INIT_KEY 0 +# define EVP_F_AES_OCB_CIPHER 0 +# define EVP_F_AES_T4_INIT_KEY 0 +# define EVP_F_AES_T4_XTS_INIT_KEY 0 +# define EVP_F_AES_WRAP_CIPHER 0 +# define EVP_F_AES_XTS_INIT_KEY 0 +# define EVP_F_ALG_MODULE_INIT 0 +# define EVP_F_ARIA_CCM_INIT_KEY 0 +# define EVP_F_ARIA_GCM_CTRL 0 +# define EVP_F_ARIA_GCM_INIT_KEY 0 +# define EVP_F_ARIA_INIT_KEY 0 +# define EVP_F_B64_NEW 0 +# define EVP_F_CAMELLIA_INIT_KEY 0 +# define EVP_F_CHACHA20_POLY1305_CTRL 0 +# define EVP_F_CMLL_T4_INIT_KEY 0 +# define EVP_F_DES_EDE3_WRAP_CIPHER 0 +# define EVP_F_DO_SIGVER_INIT 0 +# define EVP_F_ENC_NEW 0 +# define EVP_F_EVP_CIPHERINIT_EX 0 +# define EVP_F_EVP_CIPHER_ASN1_TO_PARAM 0 +# define EVP_F_EVP_CIPHER_CTX_COPY 0 +# define EVP_F_EVP_CIPHER_CTX_CTRL 0 +# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 0 +# define EVP_F_EVP_CIPHER_PARAM_TO_ASN1 0 +# define EVP_F_EVP_DECRYPTFINAL_EX 0 +# define EVP_F_EVP_DECRYPTUPDATE 0 +# define EVP_F_EVP_DIGESTFINALXOF 0 +# define EVP_F_EVP_DIGESTINIT_EX 0 +# define EVP_F_EVP_ENCRYPTDECRYPTUPDATE 0 +# define EVP_F_EVP_ENCRYPTFINAL_EX 0 +# define EVP_F_EVP_ENCRYPTUPDATE 0 +# define EVP_F_EVP_MD_CTX_COPY_EX 0 +# define EVP_F_EVP_MD_SIZE 0 +# define EVP_F_EVP_OPENINIT 0 +# define EVP_F_EVP_PBE_ALG_ADD 0 +# define EVP_F_EVP_PBE_ALG_ADD_TYPE 0 +# define EVP_F_EVP_PBE_CIPHERINIT 0 +# define EVP_F_EVP_PBE_SCRYPT 0 +# define EVP_F_EVP_PKCS82PKEY 0 +# define EVP_F_EVP_PKEY2PKCS8 0 +# define EVP_F_EVP_PKEY_ASN1_ADD0 0 +# define EVP_F_EVP_PKEY_CHECK 0 +# define EVP_F_EVP_PKEY_COPY_PARAMETERS 0 +# define EVP_F_EVP_PKEY_CTX_CTRL 0 +# define EVP_F_EVP_PKEY_CTX_CTRL_STR 0 +# define EVP_F_EVP_PKEY_CTX_DUP 0 +# define EVP_F_EVP_PKEY_CTX_MD 0 +# define EVP_F_EVP_PKEY_DECRYPT 0 +# define EVP_F_EVP_PKEY_DECRYPT_INIT 0 +# define EVP_F_EVP_PKEY_DECRYPT_OLD 0 +# define EVP_F_EVP_PKEY_DERIVE 0 +# define EVP_F_EVP_PKEY_DERIVE_INIT 0 +# define EVP_F_EVP_PKEY_DERIVE_SET_PEER 0 +# define EVP_F_EVP_PKEY_ENCRYPT 0 +# define EVP_F_EVP_PKEY_ENCRYPT_INIT 0 +# define EVP_F_EVP_PKEY_ENCRYPT_OLD 0 +# define EVP_F_EVP_PKEY_GET0_DH 0 +# define EVP_F_EVP_PKEY_GET0_DSA 0 +# define EVP_F_EVP_PKEY_GET0_EC_KEY 0 +# define EVP_F_EVP_PKEY_GET0_HMAC 0 +# define EVP_F_EVP_PKEY_GET0_POLY1305 0 +# define EVP_F_EVP_PKEY_GET0_RSA 0 +# define EVP_F_EVP_PKEY_GET0_SIPHASH 0 +# define EVP_F_EVP_PKEY_GET_RAW_PRIVATE_KEY 0 +# define EVP_F_EVP_PKEY_GET_RAW_PUBLIC_KEY 0 +# define EVP_F_EVP_PKEY_KEYGEN 0 +# define EVP_F_EVP_PKEY_KEYGEN_INIT 0 +# define EVP_F_EVP_PKEY_METH_ADD0 0 +# define EVP_F_EVP_PKEY_METH_NEW 0 +# define EVP_F_EVP_PKEY_NEW 0 +# define EVP_F_EVP_PKEY_NEW_CMAC_KEY 0 +# define EVP_F_EVP_PKEY_NEW_RAW_PRIVATE_KEY 0 +# define EVP_F_EVP_PKEY_NEW_RAW_PUBLIC_KEY 0 +# define EVP_F_EVP_PKEY_PARAMGEN 0 +# define EVP_F_EVP_PKEY_PARAMGEN_INIT 0 +# define EVP_F_EVP_PKEY_PARAM_CHECK 0 +# define EVP_F_EVP_PKEY_PUBLIC_CHECK 0 +# define EVP_F_EVP_PKEY_SET1_ENGINE 0 +# define EVP_F_EVP_PKEY_SET_ALIAS_TYPE 0 +# define EVP_F_EVP_PKEY_SIGN 0 +# define EVP_F_EVP_PKEY_SIGN_INIT 0 +# define EVP_F_EVP_PKEY_VERIFY 0 +# define EVP_F_EVP_PKEY_VERIFY_INIT 0 +# define EVP_F_EVP_PKEY_VERIFY_RECOVER 0 +# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT 0 +# define EVP_F_EVP_SIGNFINAL 0 +# define EVP_F_EVP_VERIFYFINAL 0 +# define EVP_F_INT_CTX_NEW 0 +# define EVP_F_OK_NEW 0 +# define EVP_F_PKCS5_PBE_KEYIVGEN 0 +# define EVP_F_PKCS5_V2_PBE_KEYIVGEN 0 +# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN 0 +# define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN 0 +# define EVP_F_PKEY_SET_TYPE 0 +# define EVP_F_RC2_MAGIC_TO_METH 0 +# define EVP_F_RC5_CTRL 0 +# define EVP_F_R_32_12_16_INIT_KEY 0 +# define EVP_F_S390X_AES_GCM_CTRL 0 +# define EVP_F_UPDATE 0 + +/* + * KDF function codes. + */ +# define KDF_F_PKEY_HKDF_CTRL_STR 0 +# define KDF_F_PKEY_HKDF_DERIVE 0 +# define KDF_F_PKEY_HKDF_INIT 0 +# define KDF_F_PKEY_SCRYPT_CTRL_STR 0 +# define KDF_F_PKEY_SCRYPT_CTRL_UINT64 0 +# define KDF_F_PKEY_SCRYPT_DERIVE 0 +# define KDF_F_PKEY_SCRYPT_INIT 0 +# define KDF_F_PKEY_SCRYPT_SET_MEMBUF 0 +# define KDF_F_PKEY_TLS1_PRF_CTRL_STR 0 +# define KDF_F_PKEY_TLS1_PRF_DERIVE 0 +# define KDF_F_PKEY_TLS1_PRF_INIT 0 +# define KDF_F_TLS1_PRF_ALG 0 + +/* + * KDF reason codes. + */ +# define KDF_R_INVALID_DIGEST 0 +# define KDF_R_MISSING_ITERATION_COUNT 0 +# define KDF_R_MISSING_KEY 0 +# define KDF_R_MISSING_MESSAGE_DIGEST 0 +# define KDF_R_MISSING_PARAMETER 0 +# define KDF_R_MISSING_PASS 0 +# define KDF_R_MISSING_SALT 0 +# define KDF_R_MISSING_SECRET 0 +# define KDF_R_MISSING_SEED 0 +# define KDF_R_UNKNOWN_PARAMETER_TYPE 0 +# define KDF_R_VALUE_ERROR 0 +# define KDF_R_VALUE_MISSING 0 + +/* + * OBJ function codes. + */ +# define OBJ_F_OBJ_ADD_OBJECT 0 +# define OBJ_F_OBJ_ADD_SIGID 0 +# define OBJ_F_OBJ_CREATE 0 +# define OBJ_F_OBJ_DUP 0 +# define OBJ_F_OBJ_NAME_NEW_INDEX 0 +# define OBJ_F_OBJ_NID2LN 0 +# define OBJ_F_OBJ_NID2OBJ 0 +# define OBJ_F_OBJ_NID2SN 0 +# define OBJ_F_OBJ_TXT2OBJ 0 + +# ifndef OPENSSL_NO_OCSP +/* + * OCSP function codes. + */ +# define OCSP_F_D2I_OCSP_NONCE 0 +# define OCSP_F_OCSP_BASIC_ADD1_STATUS 0 +# define OCSP_F_OCSP_BASIC_SIGN 0 +# define OCSP_F_OCSP_BASIC_SIGN_CTX 0 +# define OCSP_F_OCSP_BASIC_VERIFY 0 +# define OCSP_F_OCSP_CERT_ID_NEW 0 +# define OCSP_F_OCSP_CHECK_DELEGATED 0 +# define OCSP_F_OCSP_CHECK_IDS 0 +# define OCSP_F_OCSP_CHECK_ISSUER 0 +# define OCSP_F_OCSP_CHECK_VALIDITY 0 +# define OCSP_F_OCSP_MATCH_ISSUERID 0 +# define OCSP_F_OCSP_PARSE_URL 0 +# define OCSP_F_OCSP_REQUEST_SIGN 0 +# define OCSP_F_OCSP_REQUEST_VERIFY 0 +# define OCSP_F_OCSP_RESPONSE_GET1_BASIC 0 +# define OCSP_F_PARSE_HTTP_LINE1 0 +# endif + +/* + * PEM function codes. + */ +# define PEM_F_B2I_DSS 0 +# define PEM_F_B2I_PVK_BIO 0 +# define PEM_F_B2I_RSA 0 +# define PEM_F_CHECK_BITLEN_DSA 0 +# define PEM_F_CHECK_BITLEN_RSA 0 +# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 0 +# define PEM_F_D2I_PKCS8PRIVATEKEY_FP 0 +# define PEM_F_DO_B2I 0 +# define PEM_F_DO_B2I_BIO 0 +# define PEM_F_DO_BLOB_HEADER 0 +# define PEM_F_DO_I2B 0 +# define PEM_F_DO_PK8PKEY 0 +# define PEM_F_DO_PK8PKEY_FP 0 +# define PEM_F_DO_PVK_BODY 0 +# define PEM_F_DO_PVK_HEADER 0 +# define PEM_F_GET_HEADER_AND_DATA 0 +# define PEM_F_GET_NAME 0 +# define PEM_F_I2B_PVK 0 +# define PEM_F_I2B_PVK_BIO 0 +# define PEM_F_LOAD_IV 0 +# define PEM_F_PEM_ASN1_READ 0 +# define PEM_F_PEM_ASN1_READ_BIO 0 +# define PEM_F_PEM_ASN1_WRITE 0 +# define PEM_F_PEM_ASN1_WRITE_BIO 0 +# define PEM_F_PEM_DEF_CALLBACK 0 +# define PEM_F_PEM_DO_HEADER 0 +# define PEM_F_PEM_GET_EVP_CIPHER_INFO 0 +# define PEM_F_PEM_READ 0 +# define PEM_F_PEM_READ_BIO 0 +# define PEM_F_PEM_READ_BIO_DHPARAMS 0 +# define PEM_F_PEM_READ_BIO_EX 0 +# define PEM_F_PEM_READ_BIO_PARAMETERS 0 +# define PEM_F_PEM_READ_BIO_PRIVATEKEY 0 +# define PEM_F_PEM_READ_DHPARAMS 0 +# define PEM_F_PEM_READ_PRIVATEKEY 0 +# define PEM_F_PEM_SIGNFINAL 0 +# define PEM_F_PEM_WRITE 0 +# define PEM_F_PEM_WRITE_BIO 0 +# define PEM_F_PEM_WRITE_BIO_PRIVATEKEY_TRADITIONAL 0 +# define PEM_F_PEM_WRITE_PRIVATEKEY 0 +# define PEM_F_PEM_X509_INFO_READ 0 +# define PEM_F_PEM_X509_INFO_READ_BIO 0 +# define PEM_F_PEM_X509_INFO_WRITE_BIO 0 + +/* + * PKCS12 function codes. + */ +# define PKCS12_F_OPENSSL_ASC2UNI 0 +# define PKCS12_F_OPENSSL_UNI2ASC 0 +# define PKCS12_F_OPENSSL_UNI2UTF8 0 +# define PKCS12_F_OPENSSL_UTF82UNI 0 +# define PKCS12_F_PKCS12_CREATE 0 +# define PKCS12_F_PKCS12_GEN_MAC 0 +# define PKCS12_F_PKCS12_INIT 0 +# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 0 +# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 0 +# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 0 +# define PKCS12_F_PKCS12_KEY_GEN_ASC 0 +# define PKCS12_F_PKCS12_KEY_GEN_UNI 0 +# define PKCS12_F_PKCS12_KEY_GEN_UTF8 0 +# define PKCS12_F_PKCS12_NEWPASS 0 +# define PKCS12_F_PKCS12_PACK_P7DATA 0 +# define PKCS12_F_PKCS12_PACK_P7ENCDATA 0 +# define PKCS12_F_PKCS12_PARSE 0 +# define PKCS12_F_PKCS12_PBE_CRYPT 0 +# define PKCS12_F_PKCS12_PBE_KEYIVGEN 0 +# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF 0 +# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8 0 +# define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT 0 +# define PKCS12_F_PKCS12_SETUP_MAC 0 +# define PKCS12_F_PKCS12_SET_MAC 0 +# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 0 +# define PKCS12_F_PKCS12_UNPACK_P7DATA 0 +# define PKCS12_F_PKCS12_VERIFY_MAC 0 +# define PKCS12_F_PKCS8_ENCRYPT 0 +# define PKCS12_F_PKCS8_SET0_PBE 0 + +/* + * PKCS7 function codes. + */ +# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB 0 +# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME 0 +# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 0 +# define PKCS7_F_PKCS7_ADD_CERTIFICATE 0 +# define PKCS7_F_PKCS7_ADD_CRL 0 +# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 0 +# define PKCS7_F_PKCS7_ADD_SIGNATURE 0 +# define PKCS7_F_PKCS7_ADD_SIGNER 0 +# define PKCS7_F_PKCS7_BIO_ADD_DIGEST 0 +# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST 0 +# define PKCS7_F_PKCS7_CTRL 0 +# define PKCS7_F_PKCS7_DATADECODE 0 +# define PKCS7_F_PKCS7_DATAFINAL 0 +# define PKCS7_F_PKCS7_DATAINIT 0 +# define PKCS7_F_PKCS7_DATAVERIFY 0 +# define PKCS7_F_PKCS7_DECRYPT 0 +# define PKCS7_F_PKCS7_DECRYPT_RINFO 0 +# define PKCS7_F_PKCS7_ENCODE_RINFO 0 +# define PKCS7_F_PKCS7_ENCRYPT 0 +# define PKCS7_F_PKCS7_FINAL 0 +# define PKCS7_F_PKCS7_FIND_DIGEST 0 +# define PKCS7_F_PKCS7_GET0_SIGNERS 0 +# define PKCS7_F_PKCS7_RECIP_INFO_SET 0 +# define PKCS7_F_PKCS7_SET_CIPHER 0 +# define PKCS7_F_PKCS7_SET_CONTENT 0 +# define PKCS7_F_PKCS7_SET_DIGEST 0 +# define PKCS7_F_PKCS7_SET_TYPE 0 +# define PKCS7_F_PKCS7_SIGN 0 +# define PKCS7_F_PKCS7_SIGNATUREVERIFY 0 +# define PKCS7_F_PKCS7_SIGNER_INFO_SET 0 +# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN 0 +# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER 0 +# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 0 +# define PKCS7_F_PKCS7_VERIFY 0 + +/* + * RAND function codes. + */ +# define RAND_F_DATA_COLLECT_METHOD 0 +# define RAND_F_DRBG_BYTES 0 +# define RAND_F_DRBG_GET_ENTROPY 0 +# define RAND_F_DRBG_SETUP 0 +# define RAND_F_GET_ENTROPY 0 +# define RAND_F_RAND_BYTES 0 +# define RAND_F_RAND_DRBG_ENABLE_LOCKING 0 +# define RAND_F_RAND_DRBG_GENERATE 0 +# define RAND_F_RAND_DRBG_GET_ENTROPY 0 +# define RAND_F_RAND_DRBG_GET_NONCE 0 +# define RAND_F_RAND_DRBG_INSTANTIATE 0 +# define RAND_F_RAND_DRBG_NEW 0 +# define RAND_F_RAND_DRBG_RESEED 0 +# define RAND_F_RAND_DRBG_RESTART 0 +# define RAND_F_RAND_DRBG_SET 0 +# define RAND_F_RAND_DRBG_SET_DEFAULTS 0 +# define RAND_F_RAND_DRBG_UNINSTANTIATE 0 +# define RAND_F_RAND_LOAD_FILE 0 +# define RAND_F_RAND_POOL_ACQUIRE_ENTROPY 0 +# define RAND_F_RAND_POOL_ADD 0 +# define RAND_F_RAND_POOL_ADD_BEGIN 0 +# define RAND_F_RAND_POOL_ADD_END 0 +# define RAND_F_RAND_POOL_ATTACH 0 +# define RAND_F_RAND_POOL_BYTES_NEEDED 0 +# define RAND_F_RAND_POOL_GROW 0 +# define RAND_F_RAND_POOL_NEW 0 +# define RAND_F_RAND_PSEUDO_BYTES 0 +# define RAND_F_RAND_WRITE_FILE 0 + +/* + * RSA function codes. + */ +# define RSA_F_CHECK_PADDING_MD 0 +# define RSA_F_ENCODE_PKCS1 0 +# define RSA_F_INT_RSA_VERIFY 0 +# define RSA_F_OLD_RSA_PRIV_DECODE 0 +# define RSA_F_PKEY_PSS_INIT 0 +# define RSA_F_PKEY_RSA_CTRL 0 +# define RSA_F_PKEY_RSA_CTRL_STR 0 +# define RSA_F_PKEY_RSA_SIGN 0 +# define RSA_F_PKEY_RSA_VERIFY 0 +# define RSA_F_PKEY_RSA_VERIFYRECOVER 0 +# define RSA_F_RSA_ALGOR_TO_MD 0 +# define RSA_F_RSA_BUILTIN_KEYGEN 0 +# define RSA_F_RSA_CHECK_KEY 0 +# define RSA_F_RSA_CHECK_KEY_EX 0 +# define RSA_F_RSA_CMS_DECRYPT 0 +# define RSA_F_RSA_CMS_VERIFY 0 +# define RSA_F_RSA_ITEM_VERIFY 0 +# define RSA_F_RSA_METH_DUP 0 +# define RSA_F_RSA_METH_NEW 0 +# define RSA_F_RSA_METH_SET1_NAME 0 +# define RSA_F_RSA_MGF1_TO_MD 0 +# define RSA_F_RSA_MULTIP_INFO_NEW 0 +# define RSA_F_RSA_NEW_METHOD 0 +# define RSA_F_RSA_NULL 0 +# define RSA_F_RSA_NULL_PRIVATE_DECRYPT 0 +# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 0 +# define RSA_F_RSA_NULL_PUBLIC_DECRYPT 0 +# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 0 +# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 0 +# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 0 +# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 0 +# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 0 +# define RSA_F_RSA_PADDING_ADD_NONE 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 0 +# define RSA_F_RSA_PADDING_ADD_SSLV23 0 +# define RSA_F_RSA_PADDING_ADD_X931 0 +# define RSA_F_RSA_PADDING_CHECK_NONE 0 +# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 0 +# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1 0 +# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 0 +# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 0 +# define RSA_F_RSA_PADDING_CHECK_SSLV23 0 +# define RSA_F_RSA_PADDING_CHECK_X931 0 +# define RSA_F_RSA_PARAM_DECODE 0 +# define RSA_F_RSA_PRINT 0 +# define RSA_F_RSA_PRINT_FP 0 +# define RSA_F_RSA_PRIV_DECODE 0 +# define RSA_F_RSA_PRIV_ENCODE 0 +# define RSA_F_RSA_PSS_GET_PARAM 0 +# define RSA_F_RSA_PSS_TO_CTX 0 +# define RSA_F_RSA_PUB_DECODE 0 +# define RSA_F_RSA_SETUP_BLINDING 0 +# define RSA_F_RSA_SIGN 0 +# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 0 +# define RSA_F_RSA_VERIFY 0 +# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 0 +# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1 0 +# define RSA_F_SETUP_TBUF 0 + +/* + * OSSL_STORE function codes. + */ +# define OSSL_STORE_F_FILE_CTRL 0 +# define OSSL_STORE_F_FILE_FIND 0 +# define OSSL_STORE_F_FILE_GET_PASS 0 +# define OSSL_STORE_F_FILE_LOAD 0 +# define OSSL_STORE_F_FILE_LOAD_TRY_DECODE 0 +# define OSSL_STORE_F_FILE_NAME_TO_URI 0 +# define OSSL_STORE_F_FILE_OPEN 0 +# define OSSL_STORE_F_OSSL_STORE_ATTACH_PEM_BIO 0 +# define OSSL_STORE_F_OSSL_STORE_EXPECT 0 +# define OSSL_STORE_F_OSSL_STORE_FILE_ATTACH_PEM_BIO_INT 0 +# define OSSL_STORE_F_OSSL_STORE_FIND 0 +# define OSSL_STORE_F_OSSL_STORE_GET0_LOADER_INT 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CERT 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CRL 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME_DESCRIPTION 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PARAMS 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PKEY 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CERT 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CRL 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_EMBEDDED 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_NAME 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PARAMS 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PKEY 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_SET0_NAME_DESCRIPTION 0 +# define OSSL_STORE_F_OSSL_STORE_INIT_ONCE 0 +# define OSSL_STORE_F_OSSL_STORE_LOADER_NEW 0 +# define OSSL_STORE_F_OSSL_STORE_OPEN 0 +# define OSSL_STORE_F_OSSL_STORE_OPEN_INT 0 +# define OSSL_STORE_F_OSSL_STORE_REGISTER_LOADER_INT 0 +# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ALIAS 0 +# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ISSUER_SERIAL 0 +# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT 0 +# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_NAME 0 +# define OSSL_STORE_F_OSSL_STORE_UNREGISTER_LOADER_INT 0 +# define OSSL_STORE_F_TRY_DECODE_PARAMS 0 +# define OSSL_STORE_F_TRY_DECODE_PKCS12 0 +# define OSSL_STORE_F_TRY_DECODE_PKCS8ENCRYPTED 0 + +# ifndef OPENSSL_NO_TS +/* + * TS function codes. + */ +# define TS_F_DEF_SERIAL_CB 0 +# define TS_F_DEF_TIME_CB 0 +# define TS_F_ESS_ADD_SIGNING_CERT 0 +# define TS_F_ESS_ADD_SIGNING_CERT_V2 0 +# define TS_F_ESS_CERT_ID_NEW_INIT 0 +# define TS_F_ESS_CERT_ID_V2_NEW_INIT 0 +# define TS_F_ESS_SIGNING_CERT_NEW_INIT 0 +# define TS_F_ESS_SIGNING_CERT_V2_NEW_INIT 0 +# define TS_F_INT_TS_RESP_VERIFY_TOKEN 0 +# define TS_F_PKCS7_TO_TS_TST_INFO 0 +# define TS_F_TS_ACCURACY_SET_MICROS 0 +# define TS_F_TS_ACCURACY_SET_MILLIS 0 +# define TS_F_TS_ACCURACY_SET_SECONDS 0 +# define TS_F_TS_CHECK_IMPRINTS 0 +# define TS_F_TS_CHECK_NONCES 0 +# define TS_F_TS_CHECK_POLICY 0 +# define TS_F_TS_CHECK_SIGNING_CERTS 0 +# define TS_F_TS_CHECK_STATUS_INFO 0 +# define TS_F_TS_COMPUTE_IMPRINT 0 +# define TS_F_TS_CONF_INVALID 0 +# define TS_F_TS_CONF_LOAD_CERT 0 +# define TS_F_TS_CONF_LOAD_CERTS 0 +# define TS_F_TS_CONF_LOAD_KEY 0 +# define TS_F_TS_CONF_LOOKUP_FAIL 0 +# define TS_F_TS_CONF_SET_DEFAULT_ENGINE 0 +# define TS_F_TS_GET_STATUS_TEXT 0 +# define TS_F_TS_MSG_IMPRINT_SET_ALGO 0 +# define TS_F_TS_REQ_SET_MSG_IMPRINT 0 +# define TS_F_TS_REQ_SET_NONCE 0 +# define TS_F_TS_REQ_SET_POLICY_ID 0 +# define TS_F_TS_RESP_CREATE_RESPONSE 0 +# define TS_F_TS_RESP_CREATE_TST_INFO 0 +# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO 0 +# define TS_F_TS_RESP_CTX_ADD_MD 0 +# define TS_F_TS_RESP_CTX_ADD_POLICY 0 +# define TS_F_TS_RESP_CTX_NEW 0 +# define TS_F_TS_RESP_CTX_SET_ACCURACY 0 +# define TS_F_TS_RESP_CTX_SET_CERTS 0 +# define TS_F_TS_RESP_CTX_SET_DEF_POLICY 0 +# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT 0 +# define TS_F_TS_RESP_CTX_SET_STATUS_INFO 0 +# define TS_F_TS_RESP_GET_POLICY 0 +# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION 0 +# define TS_F_TS_RESP_SET_STATUS_INFO 0 +# define TS_F_TS_RESP_SET_TST_INFO 0 +# define TS_F_TS_RESP_SIGN 0 +# define TS_F_TS_RESP_VERIFY_SIGNATURE 0 +# define TS_F_TS_TST_INFO_SET_ACCURACY 0 +# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT 0 +# define TS_F_TS_TST_INFO_SET_NONCE 0 +# define TS_F_TS_TST_INFO_SET_POLICY_ID 0 +# define TS_F_TS_TST_INFO_SET_SERIAL 0 +# define TS_F_TS_TST_INFO_SET_TIME 0 +# define TS_F_TS_TST_INFO_SET_TSA 0 +# define TS_F_TS_VERIFY 0 +# define TS_F_TS_VERIFY_CERT 0 +# define TS_F_TS_VERIFY_CTX_NEW 0 +# endif + +/* + * UI function codes. + */ +# define UI_F_CLOSE_CONSOLE 0 +# define UI_F_ECHO_CONSOLE 0 +# define UI_F_GENERAL_ALLOCATE_BOOLEAN 0 +# define UI_F_GENERAL_ALLOCATE_PROMPT 0 +# define UI_F_NOECHO_CONSOLE 0 +# define UI_F_OPEN_CONSOLE 0 +# define UI_F_UI_CONSTRUCT_PROMPT 0 +# define UI_F_UI_CREATE_METHOD 0 +# define UI_F_UI_CTRL 0 +# define UI_F_UI_DUP_ERROR_STRING 0 +# define UI_F_UI_DUP_INFO_STRING 0 +# define UI_F_UI_DUP_INPUT_BOOLEAN 0 +# define UI_F_UI_DUP_INPUT_STRING 0 +# define UI_F_UI_DUP_USER_DATA 0 +# define UI_F_UI_DUP_VERIFY_STRING 0 +# define UI_F_UI_GET0_RESULT 0 +# define UI_F_UI_GET_RESULT_LENGTH 0 +# define UI_F_UI_NEW_METHOD 0 +# define UI_F_UI_PROCESS 0 +# define UI_F_UI_SET_RESULT 0 +# define UI_F_UI_SET_RESULT_EX 0 + +/* + * X509 function codes. + */ +# define X509_F_ADD_CERT_DIR 0 +# define X509_F_BUILD_CHAIN 0 +# define X509_F_BY_FILE_CTRL 0 +# define X509_F_CHECK_NAME_CONSTRAINTS 0 +# define X509_F_CHECK_POLICY 0 +# define X509_F_DANE_I2D 0 +# define X509_F_DIR_CTRL 0 +# define X509_F_GET_CERT_BY_SUBJECT 0 +# define X509_F_I2D_X509_AUX 0 +# define X509_F_LOOKUP_CERTS_SK 0 +# define X509_F_NETSCAPE_SPKI_B64_DECODE 0 +# define X509_F_NETSCAPE_SPKI_B64_ENCODE 0 +# define X509_F_NEW_DIR 0 +# define X509_F_X509AT_ADD1_ATTR 0 +# define X509_F_X509V3_ADD_EXT 0 +# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 0 +# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 0 +# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 0 +# define X509_F_X509_ATTRIBUTE_GET0_DATA 0 +# define X509_F_X509_ATTRIBUTE_SET1_DATA 0 +# define X509_F_X509_CHECK_PRIVATE_KEY 0 +# define X509_F_X509_CRL_DIFF 0 +# define X509_F_X509_CRL_METHOD_NEW 0 +# define X509_F_X509_CRL_PRINT_FP 0 +# define X509_F_X509_EXTENSION_CREATE_BY_NID 0 +# define X509_F_X509_EXTENSION_CREATE_BY_OBJ 0 +# define X509_F_X509_GET_PUBKEY_PARAMETERS 0 +# define X509_F_X509_LOAD_CERT_CRL_FILE 0 +# define X509_F_X509_LOAD_CERT_FILE 0 +# define X509_F_X509_LOAD_CRL_FILE 0 +# define X509_F_X509_LOOKUP_METH_NEW 0 +# define X509_F_X509_LOOKUP_NEW 0 +# define X509_F_X509_NAME_ADD_ENTRY 0 +# define X509_F_X509_NAME_CANON 0 +# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 0 +# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 0 +# define X509_F_X509_NAME_ENTRY_SET_OBJECT 0 +# define X509_F_X509_NAME_ONELINE 0 +# define X509_F_X509_NAME_PRINT 0 +# define X509_F_X509_OBJECT_NEW 0 +# define X509_F_X509_PRINT_EX_FP 0 +# define X509_F_X509_PUBKEY_DECODE 0 +# define X509_F_X509_PUBKEY_GET 0 +# define X509_F_X509_PUBKEY_GET0 0 +# define X509_F_X509_PUBKEY_SET 0 +# define X509_F_X509_REQ_CHECK_PRIVATE_KEY 0 +# define X509_F_X509_REQ_PRINT_EX 0 +# define X509_F_X509_REQ_PRINT_FP 0 +# define X509_F_X509_REQ_TO_X509 0 +# define X509_F_X509_STORE_ADD_CERT 0 +# define X509_F_X509_STORE_ADD_CRL 0 +# define X509_F_X509_STORE_ADD_LOOKUP 0 +# define X509_F_X509_STORE_CTX_GET1_ISSUER 0 +# define X509_F_X509_STORE_CTX_INIT 0 +# define X509_F_X509_STORE_CTX_NEW 0 +# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 0 +# define X509_F_X509_STORE_NEW 0 +# define X509_F_X509_TO_X509_REQ 0 +# define X509_F_X509_TRUST_ADD 0 +# define X509_F_X509_TRUST_SET 0 +# define X509_F_X509_VERIFY_CERT 0 +# define X509_F_X509_VERIFY_PARAM_NEW 0 + +/* + * X509V3 function codes. + */ +# define X509V3_F_A2I_GENERAL_NAME 0 +# define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL 0 +# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 0 +# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 0 +# define X509V3_F_BIGNUM_TO_STRING 0 +# define X509V3_F_COPY_EMAIL 0 +# define X509V3_F_COPY_ISSUER 0 +# define X509V3_F_DO_DIRNAME 0 +# define X509V3_F_DO_EXT_I2D 0 +# define X509V3_F_DO_EXT_NCONF 0 +# define X509V3_F_GNAMES_FROM_SECTNAME 0 +# define X509V3_F_I2S_ASN1_ENUMERATED 0 +# define X509V3_F_I2S_ASN1_IA5STRING 0 +# define X509V3_F_I2S_ASN1_INTEGER 0 +# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 0 +# define X509V3_F_LEVEL_ADD_NODE 0 +# define X509V3_F_NOTICE_SECTION 0 +# define X509V3_F_NREF_NOS 0 +# define X509V3_F_POLICY_CACHE_CREATE 0 +# define X509V3_F_POLICY_CACHE_NEW 0 +# define X509V3_F_POLICY_DATA_NEW 0 +# define X509V3_F_POLICY_SECTION 0 +# define X509V3_F_PROCESS_PCI_VALUE 0 +# define X509V3_F_R2I_CERTPOL 0 +# define X509V3_F_R2I_PCI 0 +# define X509V3_F_S2I_ASN1_IA5STRING 0 +# define X509V3_F_S2I_ASN1_INTEGER 0 +# define X509V3_F_S2I_ASN1_OCTET_STRING 0 +# define X509V3_F_S2I_SKEY_ID 0 +# define X509V3_F_SET_DIST_POINT_NAME 0 +# define X509V3_F_SXNET_ADD_ID_ASC 0 +# define X509V3_F_SXNET_ADD_ID_INTEGER 0 +# define X509V3_F_SXNET_ADD_ID_ULONG 0 +# define X509V3_F_SXNET_GET_ID_ASC 0 +# define X509V3_F_SXNET_GET_ID_ULONG 0 +# define X509V3_F_TREE_INIT 0 +# define X509V3_F_V2I_ASIDENTIFIERS 0 +# define X509V3_F_V2I_ASN1_BIT_STRING 0 +# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 0 +# define X509V3_F_V2I_AUTHORITY_KEYID 0 +# define X509V3_F_V2I_BASIC_CONSTRAINTS 0 +# define X509V3_F_V2I_CRLD 0 +# define X509V3_F_V2I_EXTENDED_KEY_USAGE 0 +# define X509V3_F_V2I_GENERAL_NAMES 0 +# define X509V3_F_V2I_GENERAL_NAME_EX 0 +# define X509V3_F_V2I_IDP 0 +# define X509V3_F_V2I_IPADDRBLOCKS 0 +# define X509V3_F_V2I_ISSUER_ALT 0 +# define X509V3_F_V2I_NAME_CONSTRAINTS 0 +# define X509V3_F_V2I_POLICY_CONSTRAINTS 0 +# define X509V3_F_V2I_POLICY_MAPPINGS 0 +# define X509V3_F_V2I_SUBJECT_ALT 0 +# define X509V3_F_V2I_TLS_FEATURE 0 +# define X509V3_F_V3_GENERIC_EXTENSION 0 +# define X509V3_F_X509V3_ADD1_I2D 0 +# define X509V3_F_X509V3_ADD_VALUE 0 +# define X509V3_F_X509V3_EXT_ADD 0 +# define X509V3_F_X509V3_EXT_ADD_ALIAS 0 +# define X509V3_F_X509V3_EXT_I2D 0 +# define X509V3_F_X509V3_EXT_NCONF 0 +# define X509V3_F_X509V3_GET_SECTION 0 +# define X509V3_F_X509V3_GET_STRING 0 +# define X509V3_F_X509V3_GET_VALUE_BOOL 0 +# define X509V3_F_X509V3_PARSE_LIST 0 +# define X509V3_F_X509_PURPOSE_ADD 0 +# define X509V3_F_X509_PURPOSE_SET 0 + +/* + * Compatibility defines. + */ +# define EVP_R_OPERATON_NOT_INITIALIZED EVP_R_OPERATION_NOT_INITIALIZED + +# endif + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ct.h b/illumos-x86_64/usr/include/openssl-3/ct.h new file mode 100644 index 00000000..e6dd1192 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ct.h @@ -0,0 +1,573 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/ct.h.in + * + * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_CT_H +# define OPENSSL_CT_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_CT_H +# endif + +# include + +# ifndef OPENSSL_NO_CT +# include +# include +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + + +/* Minimum RSA key size, from RFC6962 */ +# define SCT_MIN_RSA_BITS 2048 + +/* All hashes are SHA256 in v1 of Certificate Transparency */ +# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH + +SKM_DEFINE_STACK_OF_INTERNAL(SCT, SCT, SCT) +#define sk_SCT_num(sk) OPENSSL_sk_num(ossl_check_const_SCT_sk_type(sk)) +#define sk_SCT_value(sk, idx) ((SCT *)OPENSSL_sk_value(ossl_check_const_SCT_sk_type(sk), (idx))) +#define sk_SCT_new(cmp) ((STACK_OF(SCT) *)OPENSSL_sk_new(ossl_check_SCT_compfunc_type(cmp))) +#define sk_SCT_new_null() ((STACK_OF(SCT) *)OPENSSL_sk_new_null()) +#define sk_SCT_new_reserve(cmp, n) ((STACK_OF(SCT) *)OPENSSL_sk_new_reserve(ossl_check_SCT_compfunc_type(cmp), (n))) +#define sk_SCT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SCT_sk_type(sk), (n)) +#define sk_SCT_free(sk) OPENSSL_sk_free(ossl_check_SCT_sk_type(sk)) +#define sk_SCT_zero(sk) OPENSSL_sk_zero(ossl_check_SCT_sk_type(sk)) +#define sk_SCT_delete(sk, i) ((SCT *)OPENSSL_sk_delete(ossl_check_SCT_sk_type(sk), (i))) +#define sk_SCT_delete_ptr(sk, ptr) ((SCT *)OPENSSL_sk_delete_ptr(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr))) +#define sk_SCT_push(sk, ptr) OPENSSL_sk_push(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) +#define sk_SCT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) +#define sk_SCT_pop(sk) ((SCT *)OPENSSL_sk_pop(ossl_check_SCT_sk_type(sk))) +#define sk_SCT_shift(sk) ((SCT *)OPENSSL_sk_shift(ossl_check_SCT_sk_type(sk))) +#define sk_SCT_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SCT_sk_type(sk),ossl_check_SCT_freefunc_type(freefunc)) +#define sk_SCT_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr), (idx)) +#define sk_SCT_set(sk, idx, ptr) ((SCT *)OPENSSL_sk_set(ossl_check_SCT_sk_type(sk), (idx), ossl_check_SCT_type(ptr))) +#define sk_SCT_find(sk, ptr) OPENSSL_sk_find(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) +#define sk_SCT_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) +#define sk_SCT_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr), pnum) +#define sk_SCT_sort(sk) OPENSSL_sk_sort(ossl_check_SCT_sk_type(sk)) +#define sk_SCT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SCT_sk_type(sk)) +#define sk_SCT_dup(sk) ((STACK_OF(SCT) *)OPENSSL_sk_dup(ossl_check_const_SCT_sk_type(sk))) +#define sk_SCT_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SCT) *)OPENSSL_sk_deep_copy(ossl_check_const_SCT_sk_type(sk), ossl_check_SCT_copyfunc_type(copyfunc), ossl_check_SCT_freefunc_type(freefunc))) +#define sk_SCT_set_cmp_func(sk, cmp) ((sk_SCT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SCT_sk_type(sk), ossl_check_SCT_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(CTLOG, CTLOG, CTLOG) +#define sk_CTLOG_num(sk) OPENSSL_sk_num(ossl_check_const_CTLOG_sk_type(sk)) +#define sk_CTLOG_value(sk, idx) ((CTLOG *)OPENSSL_sk_value(ossl_check_const_CTLOG_sk_type(sk), (idx))) +#define sk_CTLOG_new(cmp) ((STACK_OF(CTLOG) *)OPENSSL_sk_new(ossl_check_CTLOG_compfunc_type(cmp))) +#define sk_CTLOG_new_null() ((STACK_OF(CTLOG) *)OPENSSL_sk_new_null()) +#define sk_CTLOG_new_reserve(cmp, n) ((STACK_OF(CTLOG) *)OPENSSL_sk_new_reserve(ossl_check_CTLOG_compfunc_type(cmp), (n))) +#define sk_CTLOG_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CTLOG_sk_type(sk), (n)) +#define sk_CTLOG_free(sk) OPENSSL_sk_free(ossl_check_CTLOG_sk_type(sk)) +#define sk_CTLOG_zero(sk) OPENSSL_sk_zero(ossl_check_CTLOG_sk_type(sk)) +#define sk_CTLOG_delete(sk, i) ((CTLOG *)OPENSSL_sk_delete(ossl_check_CTLOG_sk_type(sk), (i))) +#define sk_CTLOG_delete_ptr(sk, ptr) ((CTLOG *)OPENSSL_sk_delete_ptr(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr))) +#define sk_CTLOG_push(sk, ptr) OPENSSL_sk_push(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) +#define sk_CTLOG_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) +#define sk_CTLOG_pop(sk) ((CTLOG *)OPENSSL_sk_pop(ossl_check_CTLOG_sk_type(sk))) +#define sk_CTLOG_shift(sk) ((CTLOG *)OPENSSL_sk_shift(ossl_check_CTLOG_sk_type(sk))) +#define sk_CTLOG_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_CTLOG_sk_type(sk),ossl_check_CTLOG_freefunc_type(freefunc)) +#define sk_CTLOG_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr), (idx)) +#define sk_CTLOG_set(sk, idx, ptr) ((CTLOG *)OPENSSL_sk_set(ossl_check_CTLOG_sk_type(sk), (idx), ossl_check_CTLOG_type(ptr))) +#define sk_CTLOG_find(sk, ptr) OPENSSL_sk_find(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) +#define sk_CTLOG_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) +#define sk_CTLOG_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr), pnum) +#define sk_CTLOG_sort(sk) OPENSSL_sk_sort(ossl_check_CTLOG_sk_type(sk)) +#define sk_CTLOG_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CTLOG_sk_type(sk)) +#define sk_CTLOG_dup(sk) ((STACK_OF(CTLOG) *)OPENSSL_sk_dup(ossl_check_const_CTLOG_sk_type(sk))) +#define sk_CTLOG_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(CTLOG) *)OPENSSL_sk_deep_copy(ossl_check_const_CTLOG_sk_type(sk), ossl_check_CTLOG_copyfunc_type(copyfunc), ossl_check_CTLOG_freefunc_type(freefunc))) +#define sk_CTLOG_set_cmp_func(sk, cmp) ((sk_CTLOG_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_compfunc_type(cmp))) + + + +typedef enum { + CT_LOG_ENTRY_TYPE_NOT_SET = -1, + CT_LOG_ENTRY_TYPE_X509 = 0, + CT_LOG_ENTRY_TYPE_PRECERT = 1 +} ct_log_entry_type_t; + +typedef enum { + SCT_VERSION_NOT_SET = -1, + SCT_VERSION_V1 = 0 +} sct_version_t; + +typedef enum { + SCT_SOURCE_UNKNOWN, + SCT_SOURCE_TLS_EXTENSION, + SCT_SOURCE_X509V3_EXTENSION, + SCT_SOURCE_OCSP_STAPLED_RESPONSE +} sct_source_t; + +typedef enum { + SCT_VALIDATION_STATUS_NOT_SET, + SCT_VALIDATION_STATUS_UNKNOWN_LOG, + SCT_VALIDATION_STATUS_VALID, + SCT_VALIDATION_STATUS_INVALID, + SCT_VALIDATION_STATUS_UNVERIFIED, + SCT_VALIDATION_STATUS_UNKNOWN_VERSION +} sct_validation_status_t; + +/****************************************** + * CT policy evaluation context functions * + ******************************************/ + +/* + * Creates a new, empty policy evaluation context associated with the given + * library context and property query string. + * The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished + * with the CT_POLICY_EVAL_CTX. + */ +CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new_ex(OSSL_LIB_CTX *libctx, + const char *propq); + +/* + * The same as CT_POLICY_EVAL_CTX_new_ex() but the default library + * context and property query string is used. + */ +CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void); + +/* Deletes a policy evaluation context and anything it owns. */ +void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx); + +/* Gets the peer certificate that the SCTs are for */ +X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx); + +/* + * Sets the certificate associated with the received SCTs. + * Increments the reference count of cert. + * Returns 1 on success, 0 otherwise. + */ +int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert); + +/* Gets the issuer of the aforementioned certificate */ +X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx); + +/* + * Sets the issuer of the certificate associated with the received SCTs. + * Increments the reference count of issuer. + * Returns 1 on success, 0 otherwise. + */ +int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer); + +/* Gets the CT logs that are trusted sources of SCTs */ +const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx); + +/* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */ +void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx, + CTLOG_STORE *log_store); + +/* + * Gets the time, in milliseconds since the Unix epoch, that will be used as the + * current time when checking whether an SCT was issued in the future. + * Such SCTs will fail validation, as required by RFC6962. + */ +uint64_t CT_POLICY_EVAL_CTX_get_time(const CT_POLICY_EVAL_CTX *ctx); + +/* + * Sets the time to evaluate SCTs against, in milliseconds since the Unix epoch. + * If an SCT's timestamp is after this time, it will be interpreted as having + * been issued in the future. RFC6962 states that "TLS clients MUST reject SCTs + * whose timestamp is in the future", so an SCT will not validate in this case. + */ +void CT_POLICY_EVAL_CTX_set_time(CT_POLICY_EVAL_CTX *ctx, uint64_t time_in_ms); + +/***************** + * SCT functions * + *****************/ + +/* + * Creates a new, blank SCT. + * The caller is responsible for calling SCT_free when finished with the SCT. + */ +SCT *SCT_new(void); + +/* + * Creates a new SCT from some base64-encoded strings. + * The caller is responsible for calling SCT_free when finished with the SCT. + */ +SCT *SCT_new_from_base64(unsigned char version, + const char *logid_base64, + ct_log_entry_type_t entry_type, + uint64_t timestamp, + const char *extensions_base64, + const char *signature_base64); + +/* + * Frees the SCT and the underlying data structures. + */ +void SCT_free(SCT *sct); + +/* + * Free a stack of SCTs, and the underlying SCTs themselves. + * Intended to be compatible with X509V3_EXT_FREE. + */ +void SCT_LIST_free(STACK_OF(SCT) *a); + +/* + * Returns the version of the SCT. + */ +sct_version_t SCT_get_version(const SCT *sct); + +/* + * Set the version of an SCT. + * Returns 1 on success, 0 if the version is unrecognized. + */ +__owur int SCT_set_version(SCT *sct, sct_version_t version); + +/* + * Returns the log entry type of the SCT. + */ +ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct); + +/* + * Set the log entry type of an SCT. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type); + +/* + * Gets the ID of the log that an SCT came from. + * Ownership of the log ID remains with the SCT. + * Returns the length of the log ID. + */ +size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id); + +/* + * Set the log ID of an SCT to point directly to the *log_id specified. + * The SCT takes ownership of the specified pointer. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len); + +/* + * Set the log ID of an SCT. + * This makes a copy of the log_id. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, + size_t log_id_len); + +/* + * Returns the timestamp for the SCT (epoch time in milliseconds). + */ +uint64_t SCT_get_timestamp(const SCT *sct); + +/* + * Set the timestamp of an SCT (epoch time in milliseconds). + */ +void SCT_set_timestamp(SCT *sct, uint64_t timestamp); + +/* + * Return the NID for the signature used by the SCT. + * For CT v1, this will be either NID_sha256WithRSAEncryption or + * NID_ecdsa_with_SHA256 (or NID_undef if incorrect/unset). + */ +int SCT_get_signature_nid(const SCT *sct); + +/* + * Set the signature type of an SCT + * For CT v1, this should be either NID_sha256WithRSAEncryption or + * NID_ecdsa_with_SHA256. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set_signature_nid(SCT *sct, int nid); + +/* + * Set *ext to point to the extension data for the SCT. ext must not be NULL. + * The SCT retains ownership of this pointer. + * Returns length of the data pointed to. + */ +size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext); + +/* + * Set the extensions of an SCT to point directly to the *ext specified. + * The SCT takes ownership of the specified pointer. + */ +void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len); + +/* + * Set the extensions of an SCT. + * This takes a copy of the ext. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext, + size_t ext_len); + +/* + * Set *sig to point to the signature for the SCT. sig must not be NULL. + * The SCT retains ownership of this pointer. + * Returns length of the data pointed to. + */ +size_t SCT_get0_signature(const SCT *sct, unsigned char **sig); + +/* + * Set the signature of an SCT to point directly to the *sig specified. + * The SCT takes ownership of the specified pointer. + */ +void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len); + +/* + * Set the signature of an SCT to be a copy of the *sig specified. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig, + size_t sig_len); + +/* + * The origin of this SCT, e.g. TLS extension, OCSP response, etc. + */ +sct_source_t SCT_get_source(const SCT *sct); + +/* + * Set the origin of this SCT, e.g. TLS extension, OCSP response, etc. + * Returns 1 on success, 0 otherwise. + */ +__owur int SCT_set_source(SCT *sct, sct_source_t source); + +/* + * Returns a text string describing the validation status of |sct|. + */ +const char *SCT_validation_status_string(const SCT *sct); + +/* + * Pretty-prints an |sct| to |out|. + * It will be indented by the number of spaces specified by |indent|. + * If |logs| is not NULL, it will be used to lookup the CT log that the SCT came + * from, so that the log name can be printed. + */ +void SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs); + +/* + * Pretty-prints an |sct_list| to |out|. + * It will be indented by the number of spaces specified by |indent|. + * SCTs will be delimited by |separator|. + * If |logs| is not NULL, it will be used to lookup the CT log that each SCT + * came from, so that the log names can be printed. + */ +void SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent, + const char *separator, const CTLOG_STORE *logs); + +/* + * Gets the last result of validating this SCT. + * If it has not been validated yet, returns SCT_VALIDATION_STATUS_NOT_SET. + */ +sct_validation_status_t SCT_get_validation_status(const SCT *sct); + +/* + * Validates the given SCT with the provided context. + * Sets the "validation_status" field of the SCT. + * Returns 1 if the SCT is valid and the signature verifies. + * Returns 0 if the SCT is invalid or could not be verified. + * Returns -1 if an error occurs. + */ +__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx); + +/* + * Validates the given list of SCTs with the provided context. + * Sets the "validation_status" field of each SCT. + * Returns 1 if there are no invalid SCTs and all signatures verify. + * Returns 0 if at least one SCT is invalid or could not be verified. + * Returns a negative integer if an error occurs. + */ +__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts, + CT_POLICY_EVAL_CTX *ctx); + + +/********************************* + * SCT parsing and serialization * + *********************************/ + +/* + * Serialize (to TLS format) a stack of SCTs and return the length. + * "a" must not be NULL. + * If "pp" is NULL, just return the length of what would have been serialized. + * If "pp" is not NULL and "*pp" is null, function will allocate a new pointer + * for data that caller is responsible for freeing (only if function returns + * successfully). + * If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring + * that "*pp" is large enough to accept all of the serialized data. + * Returns < 0 on error, >= 0 indicating bytes written (or would have been) + * on success. + */ +__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); + +/* + * Convert TLS format SCT list to a stack of SCTs. + * If "a" or "*a" is NULL, a new stack will be created that the caller is + * responsible for freeing (by calling SCT_LIST_free). + * "**pp" and "*pp" must not be NULL. + * Upon success, "*pp" will point to after the last bytes read, and a stack + * will be returned. + * Upon failure, a NULL pointer will be returned, and the position of "*pp" is + * not defined. + */ +STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, + size_t len); + +/* + * Serialize (to DER format) a stack of SCTs and return the length. + * "a" must not be NULL. + * If "pp" is NULL, just returns the length of what would have been serialized. + * If "pp" is not NULL and "*pp" is null, function will allocate a new pointer + * for data that caller is responsible for freeing (only if function returns + * successfully). + * If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring + * that "*pp" is large enough to accept all of the serialized data. + * Returns < 0 on error, >= 0 indicating bytes written (or would have been) + * on success. + */ +__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); + +/* + * Parses an SCT list in DER format and returns it. + * If "a" or "*a" is NULL, a new stack will be created that the caller is + * responsible for freeing (by calling SCT_LIST_free). + * "**pp" and "*pp" must not be NULL. + * Upon success, "*pp" will point to after the last bytes read, and a stack + * will be returned. + * Upon failure, a NULL pointer will be returned, and the position of "*pp" is + * not defined. + */ +STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, + long len); + +/* + * Serialize (to TLS format) an |sct| and write it to |out|. + * If |out| is null, no SCT will be output but the length will still be returned. + * If |out| points to a null pointer, a string will be allocated to hold the + * TLS-format SCT. It is the responsibility of the caller to free it. + * If |out| points to an allocated string, the TLS-format SCT will be written + * to it. + * The length of the SCT in TLS format will be returned. + */ +__owur int i2o_SCT(const SCT *sct, unsigned char **out); + +/* + * Parses an SCT in TLS format and returns it. + * If |psct| is not null, it will end up pointing to the parsed SCT. If it + * already points to a non-null pointer, the pointer will be free'd. + * |in| should be a pointer to a string containing the TLS-format SCT. + * |in| will be advanced to the end of the SCT if parsing succeeds. + * |len| should be the length of the SCT in |in|. + * Returns NULL if an error occurs. + * If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len' + * fields will be populated (with |in| and |len| respectively). + */ +SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len); + +/******************** + * CT log functions * + ********************/ + +/* + * Creates a new CT log instance with the given |public_key| and |name| and + * associates it with the give library context |libctx| and property query + * string |propq|. + * Takes ownership of |public_key| but copies |name|. + * Returns NULL if malloc fails or if |public_key| cannot be converted to DER. + * Should be deleted by the caller using CTLOG_free when no longer needed. + */ +CTLOG *CTLOG_new_ex(EVP_PKEY *public_key, const char *name, OSSL_LIB_CTX *libctx, + const char *propq); + +/* + * The same as CTLOG_new_ex except that the default library context and + * property query string are used. + */ +CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name); + +/* + * Creates a new CTLOG instance with the base64-encoded SubjectPublicKeyInfo DER + * in |pkey_base64| and associated with the given library context |libctx| and + * property query string |propq|. The |name| is a string to help users identify + * this log. + * Returns 1 on success, 0 on failure. + * Should be deleted by the caller using CTLOG_free when no longer needed. + */ +int CTLOG_new_from_base64_ex(CTLOG **ct_log, const char *pkey_base64, + const char *name, OSSL_LIB_CTX *libctx, + const char *propq); + +/* + * The same as CTLOG_new_from_base64_ex() except that the default + * library context and property query string are used. + * Returns 1 on success, 0 on failure. + */ +int CTLOG_new_from_base64(CTLOG ** ct_log, + const char *pkey_base64, const char *name); + +/* + * Deletes a CT log instance and its fields. + */ +void CTLOG_free(CTLOG *log); + +/* Gets the name of the CT log */ +const char *CTLOG_get0_name(const CTLOG *log); +/* Gets the ID of the CT log */ +void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id, + size_t *log_id_len); +/* Gets the public key of the CT log */ +EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log); + +/************************** + * CT log store functions * + **************************/ + +/* + * Creates a new CT log store and associates it with the given libctx and + * property query string. + * Should be deleted by the caller using CTLOG_STORE_free when no longer needed. + */ +CTLOG_STORE *CTLOG_STORE_new_ex(OSSL_LIB_CTX *libctx, const char *propq); + +/* + * Same as CTLOG_STORE_new_ex except that the default libctx and + * property query string are used. + * Should be deleted by the caller using CTLOG_STORE_free when no longer needed. + */ +CTLOG_STORE *CTLOG_STORE_new(void); + +/* + * Deletes a CT log store and all of the CT log instances held within. + */ +void CTLOG_STORE_free(CTLOG_STORE *store); + +/* + * Finds a CT log in the store based on its log ID. + * Returns the CT log, or NULL if no match is found. + */ +const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store, + const uint8_t *log_id, + size_t log_id_len); + +/* + * Loads a CT log list into a |store| from a |file|. + * Returns 1 if loading is successful, or 0 otherwise. + */ +__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file); + +/* + * Loads the default CT log list into a |store|. + * Returns 1 if loading is successful, or 0 otherwise. + */ +__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store); + +# ifdef __cplusplus +} +# endif +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/cterr.h b/illumos-x86_64/usr/include/openssl-3/cterr.h new file mode 100644 index 00000000..935d32d8 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/cterr.h @@ -0,0 +1,45 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_CTERR_H +# define OPENSSL_CTERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_CT + + +/* + * CT reason codes. + */ +# define CT_R_BASE64_DECODE_ERROR 108 +# define CT_R_INVALID_LOG_ID_LENGTH 100 +# define CT_R_LOG_CONF_INVALID 109 +# define CT_R_LOG_CONF_INVALID_KEY 110 +# define CT_R_LOG_CONF_MISSING_DESCRIPTION 111 +# define CT_R_LOG_CONF_MISSING_KEY 112 +# define CT_R_LOG_KEY_INVALID 113 +# define CT_R_SCT_FUTURE_TIMESTAMP 116 +# define CT_R_SCT_INVALID 104 +# define CT_R_SCT_INVALID_SIGNATURE 107 +# define CT_R_SCT_LIST_INVALID 105 +# define CT_R_SCT_LOG_ID_MISMATCH 114 +# define CT_R_SCT_NOT_SET 106 +# define CT_R_SCT_UNSUPPORTED_VERSION 115 +# define CT_R_UNRECOGNIZED_SIGNATURE_NID 101 +# define CT_R_UNSUPPORTED_ENTRY_TYPE 102 +# define CT_R_UNSUPPORTED_VERSION 103 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/decoder.h b/illumos-x86_64/usr/include/openssl-3/decoder.h new file mode 100644 index 00000000..d4ee2cf4 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/decoder.h @@ -0,0 +1,133 @@ +/* + * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_DECODER_H +# define OPENSSL_DECODER_H +# pragma once + +# include + +# ifndef OPENSSL_NO_STDIO +# include +# endif +# include +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *libctx, const char *name, + const char *properties); +int OSSL_DECODER_up_ref(OSSL_DECODER *encoder); +void OSSL_DECODER_free(OSSL_DECODER *encoder); + +const OSSL_PROVIDER *OSSL_DECODER_get0_provider(const OSSL_DECODER *encoder); +const char *OSSL_DECODER_get0_properties(const OSSL_DECODER *encoder); +const char *OSSL_DECODER_get0_name(const OSSL_DECODER *decoder); +const char *OSSL_DECODER_get0_description(const OSSL_DECODER *decoder); +int OSSL_DECODER_is_a(const OSSL_DECODER *encoder, const char *name); + +void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(OSSL_DECODER *encoder, void *arg), + void *arg); +int OSSL_DECODER_names_do_all(const OSSL_DECODER *encoder, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PARAM *OSSL_DECODER_gettable_params(OSSL_DECODER *decoder); +int OSSL_DECODER_get_params(OSSL_DECODER *decoder, OSSL_PARAM params[]); + +const OSSL_PARAM *OSSL_DECODER_settable_ctx_params(OSSL_DECODER *encoder); +OSSL_DECODER_CTX *OSSL_DECODER_CTX_new(void); +int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx, + const OSSL_PARAM params[]); +void OSSL_DECODER_CTX_free(OSSL_DECODER_CTX *ctx); + +/* Utilities that help set specific parameters */ +int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx, + const unsigned char *kstr, size_t klen); +int OSSL_DECODER_CTX_set_pem_password_cb(OSSL_DECODER_CTX *ctx, + pem_password_cb *cb, void *cbarg); +int OSSL_DECODER_CTX_set_passphrase_cb(OSSL_DECODER_CTX *ctx, + OSSL_PASSPHRASE_CALLBACK *cb, + void *cbarg); +int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx, + const UI_METHOD *ui_method, + void *ui_data); + +/* + * Utilities to read the object to decode, with the result sent to cb. + * These will discover all provided methods + */ + +int OSSL_DECODER_CTX_set_selection(OSSL_DECODER_CTX *ctx, int selection); +int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx, + const char *input_type); +int OSSL_DECODER_CTX_set_input_structure(OSSL_DECODER_CTX *ctx, + const char *input_structure); +int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder); +int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx, + OSSL_LIB_CTX *libctx, const char *propq); +int OSSL_DECODER_CTX_get_num_decoders(OSSL_DECODER_CTX *ctx); + +typedef struct ossl_decoder_instance_st OSSL_DECODER_INSTANCE; +OSSL_DECODER * +OSSL_DECODER_INSTANCE_get_decoder(OSSL_DECODER_INSTANCE *decoder_inst); +void * +OSSL_DECODER_INSTANCE_get_decoder_ctx(OSSL_DECODER_INSTANCE *decoder_inst); +const char * +OSSL_DECODER_INSTANCE_get_input_type(OSSL_DECODER_INSTANCE *decoder_inst); +const char * +OSSL_DECODER_INSTANCE_get_input_structure(OSSL_DECODER_INSTANCE *decoder_inst, + int *was_set); + +typedef int OSSL_DECODER_CONSTRUCT(OSSL_DECODER_INSTANCE *decoder_inst, + const OSSL_PARAM *params, + void *construct_data); +typedef void OSSL_DECODER_CLEANUP(void *construct_data); + +int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx, + OSSL_DECODER_CONSTRUCT *construct); +int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx, + void *construct_data); +int OSSL_DECODER_CTX_set_cleanup(OSSL_DECODER_CTX *ctx, + OSSL_DECODER_CLEANUP *cleanup); +OSSL_DECODER_CONSTRUCT *OSSL_DECODER_CTX_get_construct(OSSL_DECODER_CTX *ctx); +void *OSSL_DECODER_CTX_get_construct_data(OSSL_DECODER_CTX *ctx); +OSSL_DECODER_CLEANUP *OSSL_DECODER_CTX_get_cleanup(OSSL_DECODER_CTX *ctx); + +int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst, + void *reference, size_t reference_sz, + OSSL_CALLBACK *export_cb, void *export_cbarg); + +int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in); +#ifndef OPENSSL_NO_STDIO +int OSSL_DECODER_from_fp(OSSL_DECODER_CTX *ctx, FILE *in); +#endif +int OSSL_DECODER_from_data(OSSL_DECODER_CTX *ctx, const unsigned char **pdata, + size_t *pdata_len); + +/* + * Create the OSSL_DECODER_CTX with an associated type. This will perform + * an implicit OSSL_DECODER_fetch(), suitable for the object of that type. + */ +OSSL_DECODER_CTX * +OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey, + const char *input_type, + const char *input_struct, + const char *keytype, int selection, + OSSL_LIB_CTX *libctx, const char *propquery); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/decodererr.h b/illumos-x86_64/usr/include/openssl-3/decodererr.h new file mode 100644 index 00000000..4212a38b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/decodererr.h @@ -0,0 +1,28 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_DECODERERR_H +# define OPENSSL_DECODERERR_H +# pragma once + +# include +# include +# include + + + +/* + * OSSL_DECODER reason codes. + */ +# define OSSL_DECODER_R_COULD_NOT_DECODE_OBJECT 101 +# define OSSL_DECODER_R_DECODER_NOT_FOUND 102 +# define OSSL_DECODER_R_MISSING_GET_PARAMS 100 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/des.h b/illumos-x86_64/usr/include/openssl-3/des.h new file mode 100644 index 00000000..09798a61 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/des.h @@ -0,0 +1,211 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_DES_H +# define OPENSSL_DES_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_DES_H +# endif + +# include + +# ifndef OPENSSL_NO_DES +# ifdef __cplusplus +extern "C" { +# endif +# include + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef unsigned int DES_LONG; + +# ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +# endif + +typedef unsigned char DES_cblock[8]; +typedef /* const */ unsigned char const_DES_cblock[8]; +/* + * With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * and + * const_DES_cblock * are incompatible pointer types. + */ + +typedef struct DES_ks { + union { + DES_cblock cblock; + /* + * make sure things are correct size on machines with 8 byte longs + */ + DES_LONG deslong[2]; + } ks[16]; +} DES_key_schedule; + +# define DES_KEY_SZ (sizeof(DES_cblock)) +# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) + +# define DES_ENCRYPT 1 +# define DES_DECRYPT 0 + +# define DES_CBC_MODE 0 +# define DES_PCBC_MODE 1 + +# define DES_ecb2_encrypt(i,o,k1,k2,e) \ + DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +# define DES_fixup_key_parity DES_set_odd_parity +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 const char *DES_options(void); +OSSL_DEPRECATEDIN_3_0 +void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1, DES_key_schedule *ks2, + DES_key_schedule *ks3, int enc); +OSSL_DEPRECATEDIN_3_0 +DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, + long length, DES_key_schedule *schedule, + const_DES_cblock *ivec); +# endif +/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +void DES_cbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + const_DES_cblock *inw, const_DES_cblock *outw, int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks, int enc); +# endif + +/* + * This is the DES encryption function that gets called by just about every + * other DES routine in the library. You should not use this function except + * to implement 'modes' of DES. I say this because the functions that call + * this routine do the conversion from 'char *' to long, and this needs to be + * done to make sure 'non-aligned' memory access do not occur. The + * characters are loaded 'little endian'. Data is a pointer to 2 unsigned + * long's and ks is the DES_key_schedule to use. enc, is non zero specifies + * encryption, zero if decryption. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc); +# endif + +/* + * This functions is the same as DES_encrypt1() except that the DES initial + * permutation (IP) and final permutation (FP) have been left out. As for + * DES_encrypt1(), you should not use this function. It is used by the + * routines in the library that implement triple DES. IP() DES_encrypt2() + * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1() + * DES_encrypt1() DES_encrypt1() except faster :-). + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, DES_key_schedule *ks2, + DES_key_schedule *ks3); +OSSL_DEPRECATEDIN_3_0 +void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, DES_key_schedule *ks2, + DES_key_schedule *ks3); +OSSL_DEPRECATEDIN_3_0 +void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, + DES_cblock *ivec, int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, + DES_cblock *ivec, int *num, int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, + int numbits, long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, + DES_cblock *ivec, int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, + DES_cblock *ivec, int *num); +OSSL_DEPRECATEDIN_3_0 +char *DES_fcrypt(const char *buf, const char *salt, char *ret); +OSSL_DEPRECATEDIN_3_0 +char *DES_crypt(const char *buf, const char *salt); +OSSL_DEPRECATEDIN_3_0 +void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, + long length, DES_key_schedule *schedule, DES_cblock *ivec); +OSSL_DEPRECATEDIN_3_0 +void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, + DES_cblock *ivec, int enc); +OSSL_DEPRECATEDIN_3_0 +DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], + long length, int out_count, DES_cblock *seed); +OSSL_DEPRECATEDIN_3_0 int DES_random_key(DES_cblock *ret); +OSSL_DEPRECATEDIN_3_0 void DES_set_odd_parity(DES_cblock *key); +OSSL_DEPRECATEDIN_3_0 int DES_check_key_parity(const_DES_cblock *key); +OSSL_DEPRECATEDIN_3_0 int DES_is_weak_key(const_DES_cblock *key); +# endif +/* + * DES_set_key (= set_key = DES_key_sched = key_sched) calls + * DES_set_key_checked + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); +OSSL_DEPRECATEDIN_3_0 +int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule); +OSSL_DEPRECATEDIN_3_0 +int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule); +OSSL_DEPRECATEDIN_3_0 +void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule); +OSSL_DEPRECATEDIN_3_0 void DES_string_to_key(const char *str, DES_cblock *key); +OSSL_DEPRECATEDIN_3_0 +void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2); +OSSL_DEPRECATEDIN_3_0 +void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *schedule, + DES_cblock *ivec, int *num, int enc); +OSSL_DEPRECATEDIN_3_0 +void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *schedule, + DES_cblock *ivec, int *num); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/dh.h b/illumos-x86_64/usr/include/openssl-3/dh.h new file mode 100644 index 00000000..97024929 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/dh.h @@ -0,0 +1,339 @@ +/* + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_DH_H +# define OPENSSL_DH_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_DH_H +# endif + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +#include + +/* + * DH parameter generation types used by EVP_PKEY_CTX_set_dh_paramgen_type() + * Note that additions/changes to this set of values requires corresponding + * adjustments to range checks in dh_gen() + */ +# define DH_PARAMGEN_TYPE_GENERATOR 0 /* Use a safe prime generator */ +# define DH_PARAMGEN_TYPE_FIPS_186_2 1 /* Use FIPS186-2 standard */ +# define DH_PARAMGEN_TYPE_FIPS_186_4 2 /* Use FIPS186-4 standard */ +# define DH_PARAMGEN_TYPE_GROUP 3 /* Use a named safe prime group */ + +int EVP_PKEY_CTX_set_dh_paramgen_type(EVP_PKEY_CTX *ctx, int typ); +int EVP_PKEY_CTX_set_dh_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex); +int EVP_PKEY_CTX_set_dh_paramgen_seed(EVP_PKEY_CTX *ctx, + const unsigned char *seed, + size_t seedlen); +int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int pbits); +int EVP_PKEY_CTX_set_dh_paramgen_subprime_len(EVP_PKEY_CTX *ctx, int qlen); +int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen); +int EVP_PKEY_CTX_set_dh_nid(EVP_PKEY_CTX *ctx, int nid); +int EVP_PKEY_CTX_set_dh_rfc5114(EVP_PKEY_CTX *ctx, int gen); +int EVP_PKEY_CTX_set_dhx_rfc5114(EVP_PKEY_CTX *ctx, int gen); +int EVP_PKEY_CTX_set_dh_pad(EVP_PKEY_CTX *ctx, int pad); + +int EVP_PKEY_CTX_set_dh_kdf_type(EVP_PKEY_CTX *ctx, int kdf); +int EVP_PKEY_CTX_get_dh_kdf_type(EVP_PKEY_CTX *ctx); +int EVP_PKEY_CTX_set0_dh_kdf_oid(EVP_PKEY_CTX *ctx, ASN1_OBJECT *oid); +int EVP_PKEY_CTX_get0_dh_kdf_oid(EVP_PKEY_CTX *ctx, ASN1_OBJECT **oid); +int EVP_PKEY_CTX_set_dh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); +int EVP_PKEY_CTX_get_dh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); +int EVP_PKEY_CTX_set_dh_kdf_outlen(EVP_PKEY_CTX *ctx, int len); +int EVP_PKEY_CTX_get_dh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len); +int EVP_PKEY_CTX_set0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, int len); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); +#endif + +# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1) +# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2) +# define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3) +# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4) +# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5) +# define EVP_PKEY_CTRL_DH_KDF_TYPE (EVP_PKEY_ALG_CTRL + 6) +# define EVP_PKEY_CTRL_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 7) +# define EVP_PKEY_CTRL_GET_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 8) +# define EVP_PKEY_CTRL_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 9) +# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 10) +# define EVP_PKEY_CTRL_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 11) +# define EVP_PKEY_CTRL_GET_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 12) +# define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13) +# define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14) +# define EVP_PKEY_CTRL_DH_NID (EVP_PKEY_ALG_CTRL + 15) +# define EVP_PKEY_CTRL_DH_PAD (EVP_PKEY_ALG_CTRL + 16) + +/* KDF types */ +# define EVP_PKEY_DH_KDF_NONE 1 +# define EVP_PKEY_DH_KDF_X9_42 2 + +# ifndef OPENSSL_NO_STDIO +# include +# endif +# ifndef OPENSSL_NO_DH +# include +# include +# include +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif +# include + +# ifndef OPENSSL_DH_MAX_MODULUS_BITS +# define OPENSSL_DH_MAX_MODULUS_BITS 10000 +# endif + +# ifndef OPENSSL_DH_CHECK_MAX_MODULUS_BITS +# define OPENSSL_DH_CHECK_MAX_MODULUS_BITS 32768 +# endif + +# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024 + +# define DH_FLAG_CACHE_MONT_P 0x01 + +# define DH_FLAG_TYPE_MASK 0xF000 +# define DH_FLAG_TYPE_DH 0x0000 +# define DH_FLAG_TYPE_DHX 0x1000 + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +/* + * Does nothing. Previously this switched off constant time behaviour. + */ +# define DH_FLAG_NO_EXP_CONSTTIME 0x00 +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* + * If this flag is set the DH method is FIPS compliant and can be used in + * FIPS mode. This is set in the validated module method. If an application + * sets this flag in its own methods it is its responsibility to ensure the + * result is compliant. + */ + +# define DH_FLAG_FIPS_METHOD 0x0400 + +/* + * If this flag is set the operations normally disabled in FIPS mode are + * permitted it is then the applications responsibility to ensure that the + * usage is compliant. + */ + +# define DH_FLAG_NON_FIPS_ALLOW 0x0400 +# endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dh_st DH; */ +/* typedef struct dh_method DH_METHOD; */ + +DECLARE_ASN1_ITEM(DHparams) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DH_GENERATOR_2 2 +# define DH_GENERATOR_3 3 +# define DH_GENERATOR_5 5 + +/* DH_check error codes, some of them shared with DH_check_pub_key */ +/* + * NB: These values must align with the equivalently named macros in + * internal/ffc.h. + */ +# define DH_CHECK_P_NOT_PRIME 0x01 +# define DH_CHECK_P_NOT_SAFE_PRIME 0x02 +# define DH_UNABLE_TO_CHECK_GENERATOR 0x04 +# define DH_NOT_SUITABLE_GENERATOR 0x08 +# define DH_CHECK_Q_NOT_PRIME 0x10 +# define DH_CHECK_INVALID_Q_VALUE 0x20 /* +DH_check_pub_key */ +# define DH_CHECK_INVALID_J_VALUE 0x40 +# define DH_MODULUS_TOO_SMALL 0x80 +# define DH_MODULUS_TOO_LARGE 0x100 /* +DH_check_pub_key */ + +/* DH_check_pub_key error codes */ +# define DH_CHECK_PUBKEY_TOO_SMALL 0x01 +# define DH_CHECK_PUBKEY_TOO_LARGE 0x02 +# define DH_CHECK_PUBKEY_INVALID 0x04 + +/* + * primes p where (p-1)/2 is prime too are called "safe"; we define this for + * backward compatibility: + */ +# define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME + +# define d2i_DHparams_fp(fp, x) \ + (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ + (char *(*)())d2i_DHparams, \ + (fp), \ + (unsigned char **)(x)) +# define i2d_DHparams_fp(fp, x) \ + ASN1_i2d_fp(i2d_DHparams,(fp), (unsigned char *)(x)) +# define d2i_DHparams_bio(bp, x) \ + ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, bp, x) +# define i2d_DHparams_bio(bp, x) \ + ASN1_i2d_bio_of(DH, i2d_DHparams, bp, x) + +# define d2i_DHxparams_fp(fp,x) \ + (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ + (char *(*)())d2i_DHxparams, \ + (fp), \ + (unsigned char **)(x)) +# define i2d_DHxparams_fp(fp, x) \ + ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x)) +# define d2i_DHxparams_bio(bp, x) \ + ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x) +# define i2d_DHxparams_bio(bp, x) \ + ASN1_i2d_bio_of(DH, i2d_DHxparams, bp, x) + +DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, DH, DHparams) + +OSSL_DEPRECATEDIN_3_0 const DH_METHOD *DH_OpenSSL(void); + +OSSL_DEPRECATEDIN_3_0 void DH_set_default_method(const DH_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 const DH_METHOD *DH_get_default_method(void); +OSSL_DEPRECATEDIN_3_0 int DH_set_method(DH *dh, const DH_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 DH *DH_new_method(ENGINE *engine); + +OSSL_DEPRECATEDIN_3_0 DH *DH_new(void); +OSSL_DEPRECATEDIN_3_0 void DH_free(DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_up_ref(DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_bits(const DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_size(const DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_security_bits(const DH *dh); + +# define DH_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef) + +OSSL_DEPRECATEDIN_3_0 int DH_set_ex_data(DH *d, int idx, void *arg); +OSSL_DEPRECATEDIN_3_0 void *DH_get_ex_data(const DH *d, int idx); + +OSSL_DEPRECATEDIN_3_0 int DH_generate_parameters_ex(DH *dh, int prime_len, + int generator, + BN_GENCB *cb); + +OSSL_DEPRECATEDIN_3_0 int DH_check_params_ex(const DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_check_ex(const DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key); +OSSL_DEPRECATEDIN_3_0 int DH_check_params(const DH *dh, int *ret); +OSSL_DEPRECATEDIN_3_0 int DH_check(const DH *dh, int *codes); +OSSL_DEPRECATEDIN_3_0 int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, + int *codes); +OSSL_DEPRECATEDIN_3_0 int DH_generate_key(DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_compute_key(unsigned char *key, + const BIGNUM *pub_key, DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_compute_key_padded(unsigned char *key, + const BIGNUM *pub_key, DH *dh); + +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DH, DHparams) +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DH, DHxparams) + +# ifndef OPENSSL_NO_STDIO +OSSL_DEPRECATEDIN_3_0 int DHparams_print_fp(FILE *fp, const DH *x); +# endif +OSSL_DEPRECATEDIN_3_0 int DHparams_print(BIO *bp, const DH *x); + +/* RFC 5114 parameters */ +OSSL_DEPRECATEDIN_3_0 DH *DH_get_1024_160(void); +OSSL_DEPRECATEDIN_3_0 DH *DH_get_2048_224(void); +OSSL_DEPRECATEDIN_3_0 DH *DH_get_2048_256(void); + +/* Named parameters, currently RFC7919 and RFC3526 */ +OSSL_DEPRECATEDIN_3_0 DH *DH_new_by_nid(int nid); +OSSL_DEPRECATEDIN_3_0 int DH_get_nid(const DH *dh); + +/* RFC2631 KDF */ +OSSL_DEPRECATEDIN_3_0 int DH_KDF_X9_42(unsigned char *out, size_t outlen, + const unsigned char *Z, size_t Zlen, + ASN1_OBJECT *key_oid, + const unsigned char *ukm, + size_t ukmlen, const EVP_MD *md); + +OSSL_DEPRECATEDIN_3_0 void DH_get0_pqg(const DH *dh, const BIGNUM **p, + const BIGNUM **q, const BIGNUM **g); +OSSL_DEPRECATEDIN_3_0 int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); +OSSL_DEPRECATEDIN_3_0 void DH_get0_key(const DH *dh, const BIGNUM **pub_key, + const BIGNUM **priv_key); +OSSL_DEPRECATEDIN_3_0 int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DH_get0_p(const DH *dh); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DH_get0_q(const DH *dh); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DH_get0_g(const DH *dh); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DH_get0_priv_key(const DH *dh); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DH_get0_pub_key(const DH *dh); +OSSL_DEPRECATEDIN_3_0 void DH_clear_flags(DH *dh, int flags); +OSSL_DEPRECATEDIN_3_0 int DH_test_flags(const DH *dh, int flags); +OSSL_DEPRECATEDIN_3_0 void DH_set_flags(DH *dh, int flags); +OSSL_DEPRECATEDIN_3_0 ENGINE *DH_get0_engine(DH *d); +OSSL_DEPRECATEDIN_3_0 long DH_get_length(const DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_set_length(DH *dh, long length); + +OSSL_DEPRECATEDIN_3_0 DH_METHOD *DH_meth_new(const char *name, int flags); +OSSL_DEPRECATEDIN_3_0 void DH_meth_free(DH_METHOD *dhm); +OSSL_DEPRECATEDIN_3_0 DH_METHOD *DH_meth_dup(const DH_METHOD *dhm); +OSSL_DEPRECATEDIN_3_0 const char *DH_meth_get0_name(const DH_METHOD *dhm); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set1_name(DH_METHOD *dhm, const char *name); +OSSL_DEPRECATEDIN_3_0 int DH_meth_get_flags(const DH_METHOD *dhm); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_flags(DH_METHOD *dhm, int flags); +OSSL_DEPRECATEDIN_3_0 void *DH_meth_get0_app_data(const DH_METHOD *dhm); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_generate_key(const DH_METHOD *dhm)) (DH *); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_generate_key(DH_METHOD *dhm, + int (*generate_key) (DH *)); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_compute_key(const DH_METHOD *dhm)) + (unsigned char *key, + const BIGNUM *pub_key, + DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_compute_key(DH_METHOD *dhm, + int (*compute_key) + (unsigned char *key, + const BIGNUM *pub_key, + DH *dh)); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm)) + (const DH *, BIGNUM *, + const BIGNUM *, + const BIGNUM *, + const BIGNUM *, BN_CTX *, + BN_MONT_CTX *); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_bn_mod_exp(DH_METHOD *dhm, + int (*bn_mod_exp) + (const DH *, BIGNUM *, + const BIGNUM *, const BIGNUM *, + const BIGNUM *, BN_CTX *, + BN_MONT_CTX *)); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_init(const DH_METHOD *dhm))(DH *); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *)); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_finish(const DH_METHOD *dhm)) (DH *); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_finish(DH_METHOD *dhm, int (*finish) (DH *)); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_generate_params(const DH_METHOD *dhm)) + (DH *, int, int, + BN_GENCB *); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_generate_params(DH_METHOD *dhm, + int (*generate_params) + (DH *, int, int, + BN_GENCB *)); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +OSSL_DEPRECATEDIN_0_9_8 DH *DH_generate_parameters(int prime_len, int generator, + void (*callback) (int, int, + void *), + void *cb_arg); +# endif + +# endif +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/dherr.h b/illumos-x86_64/usr/include/openssl-3/dherr.h new file mode 100644 index 00000000..2997d7d4 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/dherr.h @@ -0,0 +1,59 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_DHERR_H +# define OPENSSL_DHERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_DH + + +/* + * DH reason codes. + */ +# define DH_R_BAD_FFC_PARAMETERS 127 +# define DH_R_BAD_GENERATOR 101 +# define DH_R_BN_DECODE_ERROR 109 +# define DH_R_BN_ERROR 106 +# define DH_R_CHECK_INVALID_J_VALUE 115 +# define DH_R_CHECK_INVALID_Q_VALUE 116 +# define DH_R_CHECK_PUBKEY_INVALID 122 +# define DH_R_CHECK_PUBKEY_TOO_LARGE 123 +# define DH_R_CHECK_PUBKEY_TOO_SMALL 124 +# define DH_R_CHECK_P_NOT_PRIME 117 +# define DH_R_CHECK_P_NOT_SAFE_PRIME 118 +# define DH_R_CHECK_Q_NOT_PRIME 119 +# define DH_R_DECODE_ERROR 104 +# define DH_R_INVALID_PARAMETER_NAME 110 +# define DH_R_INVALID_PARAMETER_NID 114 +# define DH_R_INVALID_PUBKEY 102 +# define DH_R_INVALID_SECRET 128 +# define DH_R_INVALID_SIZE 129 +# define DH_R_KDF_PARAMETER_ERROR 112 +# define DH_R_KEYS_NOT_SET 108 +# define DH_R_MISSING_PUBKEY 125 +# define DH_R_MODULUS_TOO_LARGE 103 +# define DH_R_MODULUS_TOO_SMALL 126 +# define DH_R_NOT_SUITABLE_GENERATOR 120 +# define DH_R_NO_PARAMETERS_SET 107 +# define DH_R_NO_PRIVATE_VALUE 100 +# define DH_R_PARAMETER_ENCODING_ERROR 105 +# define DH_R_PEER_KEY_ERROR 111 +# define DH_R_Q_TOO_LARGE 130 +# define DH_R_SHARED_INFO_ERROR 113 +# define DH_R_UNABLE_TO_CHECK_GENERATOR 121 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/dsa.h b/illumos-x86_64/usr/include/openssl-3/dsa.h new file mode 100644 index 00000000..109878e6 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/dsa.h @@ -0,0 +1,280 @@ +/* + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_DSA_H +# define OPENSSL_DSA_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_DSA_H +# endif + +# include +# include + +# include + +# ifndef OPENSSL_NO_DSA +# include +# include +# include +# include +# include +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif +# endif + +# ifdef __cplusplus +extern "C" { +# endif + +int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits); +int EVP_PKEY_CTX_set_dsa_paramgen_q_bits(EVP_PKEY_CTX *ctx, int qbits); +int EVP_PKEY_CTX_set_dsa_paramgen_md_props(EVP_PKEY_CTX *ctx, + const char *md_name, + const char *md_properties); +int EVP_PKEY_CTX_set_dsa_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex); +int EVP_PKEY_CTX_set_dsa_paramgen_type(EVP_PKEY_CTX *ctx, const char *name); +int EVP_PKEY_CTX_set_dsa_paramgen_seed(EVP_PKEY_CTX *ctx, + const unsigned char *seed, + size_t seedlen); +int EVP_PKEY_CTX_set_dsa_paramgen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); + +# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1) +# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2) +# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3) + +# ifndef OPENSSL_NO_DSA +# ifndef OPENSSL_DSA_MAX_MODULUS_BITS +# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 +# endif + +# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024 + +typedef struct DSA_SIG_st DSA_SIG; +DSA_SIG *DSA_SIG_new(void); +void DSA_SIG_free(DSA_SIG *a); +DECLARE_ASN1_ENCODE_FUNCTIONS_only(DSA_SIG, DSA_SIG) +void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); +int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); + + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +/* + * Does nothing. Previously this switched off constant time behaviour. + */ +# define DSA_FLAG_NO_EXP_CONSTTIME 0x00 +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DSA_FLAG_CACHE_MONT_P 0x01 + +/* + * If this flag is set the DSA method is FIPS compliant and can be used in + * FIPS mode. This is set in the validated module method. If an application + * sets this flag in its own methods it is its responsibility to ensure the + * result is compliant. + */ + +# define DSA_FLAG_FIPS_METHOD 0x0400 + +/* + * If this flag is set the operations normally disabled in FIPS mode are + * permitted it is then the applications responsibility to ensure that the + * usage is compliant. + */ + +# define DSA_FLAG_NON_FIPS_ALLOW 0x0400 +# define DSA_FLAG_FIPS_CHECKED 0x0800 + +/* Already defined in ossl_typ.h */ +/* typedef struct dsa_st DSA; */ +/* typedef struct dsa_method DSA_METHOD; */ + +# define d2i_DSAparams_fp(fp, x) \ + (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ + (char *(*)())d2i_DSAparams, (fp), \ + (unsigned char **)(x)) +# define i2d_DSAparams_fp(fp, x) \ + ASN1_i2d_fp(i2d_DSAparams, (fp), (unsigned char *)(x)) +# define d2i_DSAparams_bio(bp, x) \ + ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAparams, bp, x) +# define i2d_DSAparams_bio(bp, x) \ + ASN1_i2d_bio_of(DSA, i2d_DSAparams, bp, x) + +DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSAparams) +OSSL_DEPRECATEDIN_3_0 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, + DSA *dsa); +OSSL_DEPRECATEDIN_3_0 int DSA_do_verify(const unsigned char *dgst, int dgst_len, + DSA_SIG *sig, DSA *dsa); + +OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_OpenSSL(void); + +OSSL_DEPRECATEDIN_3_0 void DSA_set_default_method(const DSA_METHOD *); +OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_get_default_method(void); +OSSL_DEPRECATEDIN_3_0 int DSA_set_method(DSA *dsa, const DSA_METHOD *); +OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_get_method(DSA *d); + +OSSL_DEPRECATEDIN_3_0 DSA *DSA_new(void); +OSSL_DEPRECATEDIN_3_0 DSA *DSA_new_method(ENGINE *engine); +OSSL_DEPRECATEDIN_3_0 void DSA_free(DSA *r); +/* "up" the DSA object's reference count */ +OSSL_DEPRECATEDIN_3_0 int DSA_up_ref(DSA *r); +OSSL_DEPRECATEDIN_3_0 int DSA_size(const DSA *); +OSSL_DEPRECATEDIN_3_0 int DSA_bits(const DSA *d); +OSSL_DEPRECATEDIN_3_0 int DSA_security_bits(const DSA *d); + /* next 4 return -1 on error */ +OSSL_DEPRECATEDIN_3_0 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, + BIGNUM **kinvp, BIGNUM **rp); +OSSL_DEPRECATEDIN_3_0 int DSA_sign(int type, const unsigned char *dgst, + int dlen, unsigned char *sig, + unsigned int *siglen, DSA *dsa); +OSSL_DEPRECATEDIN_3_0 int DSA_verify(int type, const unsigned char *dgst, + int dgst_len, const unsigned char *sigbuf, + int siglen, DSA *dsa); + +# define DSA_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef) +OSSL_DEPRECATEDIN_3_0 int DSA_set_ex_data(DSA *d, int idx, void *arg); +OSSL_DEPRECATEDIN_3_0 void *DSA_get_ex_data(const DSA *d, int idx); + +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, + DSA, DSAPublicKey) +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, + DSA, DSAPrivateKey) +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, + DSA, DSAparams) +# endif + +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +/* Deprecated version */ +OSSL_DEPRECATEDIN_0_9_8 +DSA *DSA_generate_parameters(int bits, unsigned char *seed, int seed_len, + int *counter_ret, unsigned long *h_ret, + void (*callback) (int, int, void *), + void *cb_arg); +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* New version */ +OSSL_DEPRECATEDIN_3_0 int DSA_generate_parameters_ex(DSA *dsa, int bits, + const unsigned char *seed, + int seed_len, + int *counter_ret, + unsigned long *h_ret, + BN_GENCB *cb); + +OSSL_DEPRECATEDIN_3_0 int DSA_generate_key(DSA *a); + +OSSL_DEPRECATEDIN_3_0 int DSAparams_print(BIO *bp, const DSA *x); +OSSL_DEPRECATEDIN_3_0 int DSA_print(BIO *bp, const DSA *x, int off); +# ifndef OPENSSL_NO_STDIO +OSSL_DEPRECATEDIN_3_0 int DSAparams_print_fp(FILE *fp, const DSA *x); +OSSL_DEPRECATEDIN_3_0 int DSA_print_fp(FILE *bp, const DSA *x, int off); +# endif + +# define DSS_prime_checks 64 +/* + * Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only + * have one value here we set the number of checks to 64 which is the 128 bit + * security level that is the highest level and valid for creating a 3072 bit + * DSA key. + */ +# define DSA_is_prime(n, callback, cb_arg) \ + BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) + +# ifndef OPENSSL_NO_DH +/* + * Convert DSA structure (key or just parameters) into DH structure (be + * careful to avoid small subgroup attacks when using this!) + */ +OSSL_DEPRECATEDIN_3_0 DH *DSA_dup_DH(const DSA *r); +# endif + +OSSL_DEPRECATEDIN_3_0 void DSA_get0_pqg(const DSA *d, const BIGNUM **p, + const BIGNUM **q, const BIGNUM **g); +OSSL_DEPRECATEDIN_3_0 int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); +OSSL_DEPRECATEDIN_3_0 void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, + const BIGNUM **priv_key); +OSSL_DEPRECATEDIN_3_0 int DSA_set0_key(DSA *d, BIGNUM *pub_key, + BIGNUM *priv_key); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_p(const DSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_q(const DSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_g(const DSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_pub_key(const DSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_priv_key(const DSA *d); +OSSL_DEPRECATEDIN_3_0 void DSA_clear_flags(DSA *d, int flags); +OSSL_DEPRECATEDIN_3_0 int DSA_test_flags(const DSA *d, int flags); +OSSL_DEPRECATEDIN_3_0 void DSA_set_flags(DSA *d, int flags); +OSSL_DEPRECATEDIN_3_0 ENGINE *DSA_get0_engine(DSA *d); + +OSSL_DEPRECATEDIN_3_0 DSA_METHOD *DSA_meth_new(const char *name, int flags); +OSSL_DEPRECATEDIN_3_0 void DSA_meth_free(DSA_METHOD *dsam); +OSSL_DEPRECATEDIN_3_0 DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam); +OSSL_DEPRECATEDIN_3_0 const char *DSA_meth_get0_name(const DSA_METHOD *dsam); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set1_name(DSA_METHOD *dsam, + const char *name); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_get_flags(const DSA_METHOD *dsam); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_flags(DSA_METHOD *dsam, int flags); +OSSL_DEPRECATEDIN_3_0 void *DSA_meth_get0_app_data(const DSA_METHOD *dsam); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set0_app_data(DSA_METHOD *dsam, + void *app_data); +OSSL_DEPRECATEDIN_3_0 DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam)) + (const unsigned char *, int, DSA *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_sign(DSA_METHOD *dsam, + DSA_SIG *(*sign) (const unsigned char *, int, DSA *)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam)) + (DSA *, BN_CTX *, BIGNUM **, BIGNUM **); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_sign_setup(DSA_METHOD *dsam, + int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_verify(const DSA_METHOD *dsam)) + (const unsigned char *, int, DSA_SIG *, DSA *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_verify(DSA_METHOD *dsam, + int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam)) + (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_mod_exp(DSA_METHOD *dsam, + int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *, + BN_MONT_CTX *)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam)) + (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, + BN_CTX *, BN_MONT_CTX *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam, + int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_init(DSA_METHOD *dsam, + int (*init)(DSA *)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_finish(const DSA_METHOD *dsam))(DSA *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_finish(DSA_METHOD *dsam, + int (*finish)(DSA *)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam)) + (DSA *, int, const unsigned char *, int, int *, unsigned long *, + BN_GENCB *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_paramgen(DSA_METHOD *dsam, + int (*paramgen) (DSA *, int, const unsigned char *, int, int *, + unsigned long *, BN_GENCB *)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_keygen(const DSA_METHOD *dsam))(DSA *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_keygen(DSA_METHOD *dsam, + int (*keygen) (DSA *)); + +# endif +# endif +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/dsaerr.h b/illumos-x86_64/usr/include/openssl-3/dsaerr.h new file mode 100644 index 00000000..26ada57d --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/dsaerr.h @@ -0,0 +1,44 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_DSAERR_H +# define OPENSSL_DSAERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_DSA + + +/* + * DSA reason codes. + */ +# define DSA_R_BAD_FFC_PARAMETERS 114 +# define DSA_R_BAD_Q_VALUE 102 +# define DSA_R_BN_DECODE_ERROR 108 +# define DSA_R_BN_ERROR 109 +# define DSA_R_DECODE_ERROR 104 +# define DSA_R_INVALID_DIGEST_TYPE 106 +# define DSA_R_INVALID_PARAMETERS 112 +# define DSA_R_MISSING_PARAMETERS 101 +# define DSA_R_MISSING_PRIVATE_KEY 111 +# define DSA_R_MODULUS_TOO_LARGE 103 +# define DSA_R_NO_PARAMETERS_SET 107 +# define DSA_R_PARAMETER_ENCODING_ERROR 105 +# define DSA_R_P_NOT_PRIME 115 +# define DSA_R_Q_NOT_PRIME 113 +# define DSA_R_SEED_LEN_SMALL 110 +# define DSA_R_TOO_MANY_RETRIES 116 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/dtls1.h b/illumos-x86_64/usr/include/openssl-3/dtls1.h new file mode 100644 index 00000000..5dc6b541 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/dtls1.h @@ -0,0 +1,57 @@ +/* + * Copyright 2005-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_DTLS1_H +# define OPENSSL_DTLS1_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_DTLS1_H +# endif + +# include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* DTLS*_VERSION constants are defined in prov_ssl.h */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DTLS_MIN_VERSION DTLS1_VERSION +# define DTLS_MAX_VERSION DTLS1_2_VERSION +# endif +# define DTLS1_VERSION_MAJOR 0xFE + +/* Special value for method supporting multiple versions */ +# define DTLS_ANY_VERSION 0x1FFFF + +/* lengths of messages */ + +# define DTLS1_COOKIE_LENGTH 255 + +# define DTLS1_RT_HEADER_LENGTH 13 + +# define DTLS1_HM_HEADER_LENGTH 12 + +# define DTLS1_HM_BAD_FRAGMENT -2 +# define DTLS1_HM_FRAGMENT_RETRY -3 + +# define DTLS1_CCS_HEADER_LENGTH 1 + +# define DTLS1_AL_HEADER_LENGTH 2 + +# define DTLS1_TMO_ALERT_COUNT 12 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/e_os2.h b/illumos-x86_64/usr/include/openssl-3/e_os2.h new file mode 100644 index 00000000..b8c61079 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/e_os2.h @@ -0,0 +1,310 @@ +/* + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_E_OS2_H +# define OPENSSL_E_OS2_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_E_OS2_H +# endif + +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** + * Detect operating systems. This probably needs completing. + * The result is that at least one OPENSSL_SYS_os macro should be defined. + * However, if none is defined, Unix is assumed. + **/ + +# define OPENSSL_SYS_UNIX + +/* --------------------- Microsoft operating systems ---------------------- */ + +/* + * Note that MSDOS actually denotes 32-bit environments running on top of + * MS-DOS, such as DJGPP one. + */ +# if defined(OPENSSL_SYS_MSDOS) +# undef OPENSSL_SYS_UNIX +# endif + +/* + * For 32 bit environment, there seems to be the CygWin environment and then + * all the others that try to do the same thing Microsoft does... + */ +/* + * UEFI lives here because it might be built with a Microsoft toolchain and + * we need to avoid the false positive match on Windows. + */ +# if defined(OPENSSL_SYS_UEFI) +# undef OPENSSL_SYS_UNIX +# elif defined(OPENSSL_SYS_UWIN) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_UWIN +# else +# if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN) +# define OPENSSL_SYS_WIN32_CYGWIN +# else +# if defined(_WIN32) || defined(OPENSSL_SYS_WIN32) +# undef OPENSSL_SYS_UNIX +# if !defined(OPENSSL_SYS_WIN32) +# define OPENSSL_SYS_WIN32 +# endif +# endif +# if defined(_WIN64) || defined(OPENSSL_SYS_WIN64) +# undef OPENSSL_SYS_UNIX +# if !defined(OPENSSL_SYS_WIN64) +# define OPENSSL_SYS_WIN64 +# endif +# endif +# if defined(OPENSSL_SYS_WINNT) +# undef OPENSSL_SYS_UNIX +# endif +# if defined(OPENSSL_SYS_WINCE) +# undef OPENSSL_SYS_UNIX +# endif +# endif +# endif + +/* Anything that tries to look like Microsoft is "Windows" */ +# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_SYS_MSDOS +# define OPENSSL_SYS_MSDOS +# endif +# endif + +/* + * DLL settings. This part is a bit tough, because it's up to the + * application implementer how he or she will link the application, so it + * requires some macro to be used. + */ +# ifdef OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_OPT_WINDLL +# if defined(_WINDLL) /* This is used when building OpenSSL to + * indicate that DLL linkage should be used */ +# define OPENSSL_OPT_WINDLL +# endif +# endif +# endif + +/* ------------------------------- OpenVMS -------------------------------- */ +# if defined(__VMS) || defined(VMS) +# if !defined(OPENSSL_SYS_VMS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_VMS +# endif +# if defined(__DECC) +# define OPENSSL_SYS_VMS_DECC +# elif defined(__DECCXX) +# define OPENSSL_SYS_VMS_DECC +# define OPENSSL_SYS_VMS_DECCXX +# else +# define OPENSSL_SYS_VMS_NODECC +# endif +# endif + +/* -------------------------------- Unix ---------------------------------- */ +# ifdef OPENSSL_SYS_UNIX +# if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX) +# define OPENSSL_SYS_LINUX +# endif +# if defined(_AIX) && !defined(OPENSSL_SYS_AIX) +# define OPENSSL_SYS_AIX +# endif +# endif + +/* -------------------------------- VOS ----------------------------------- */ +# if defined(__VOS__) && !defined(OPENSSL_SYS_VOS) +# define OPENSSL_SYS_VOS +# ifdef __HPPA__ +# define OPENSSL_SYS_VOS_HPPA +# endif +# ifdef __IA32__ +# define OPENSSL_SYS_VOS_IA32 +# endif +# endif + +/* ---------------------------- HP NonStop -------------------------------- */ +# ifdef __TANDEM +# ifdef _STRING +# include +# endif +# define OPENSSL_USE_BUILD_DATE +# if defined(OPENSSL_THREADS) && defined(_SPT_MODEL_) +# define SPT_THREAD_SIGNAL 1 +# define SPT_THREAD_AWARE 1 +# include +# elif defined(OPENSSL_THREADS) && defined(_PUT_MODEL_) +# include +# endif +# endif + +/** + * That's it for OS-specific stuff + *****************************************************************************/ + +/*- + * OPENSSL_EXTERN is normally used to declare a symbol with possible extra + * attributes to handle its presence in a shared library. + * OPENSSL_EXPORT is used to define a symbol with extra possible attributes + * to make it visible in a shared library. + * Care needs to be taken when a header file is used both to declare and + * define symbols. Basically, for any library that exports some global + * variables, the following code must be present in the header file that + * declares them, before OPENSSL_EXTERN is used: + * + * #ifdef SOME_BUILD_FLAG_MACRO + * # undef OPENSSL_EXTERN + * # define OPENSSL_EXTERN OPENSSL_EXPORT + * #endif + * + * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN + * have some generally sensible values. + */ + +# if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) +# define OPENSSL_EXPORT extern __declspec(dllexport) +# define OPENSSL_EXTERN extern __declspec(dllimport) +# else +# define OPENSSL_EXPORT extern +# define OPENSSL_EXTERN extern +# endif + +# ifdef _WIN32 +# ifdef _WIN64 +# define ossl_ssize_t __int64 +# define OSSL_SSIZE_MAX _I64_MAX +# else +# define ossl_ssize_t int +# define OSSL_SSIZE_MAX INT_MAX +# endif +# endif + +# if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t) +# define ossl_ssize_t INTN +# define OSSL_SSIZE_MAX MAX_INTN +# endif + +# ifndef ossl_ssize_t +# include +# define ossl_ssize_t ssize_t +# if defined(SSIZE_MAX) +# define OSSL_SSIZE_MAX SSIZE_MAX +# elif defined(_POSIX_SSIZE_MAX) +# define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX +# else +# define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1)) +# endif +# endif + +# if defined(UNUSEDRESULT_DEBUG) +# define __owur __attribute__((__warn_unused_result__)) +# else +# define __owur +# endif + +/* Standard integer types */ +# define OPENSSL_NO_INTTYPES_H +# define OPENSSL_NO_STDINT_H +# if defined(OPENSSL_SYS_UEFI) +typedef INT8 int8_t; +typedef UINT8 uint8_t; +typedef INT16 int16_t; +typedef UINT16 uint16_t; +typedef INT32 int32_t; +typedef UINT32 uint32_t; +typedef INT64 int64_t; +typedef UINT64 uint64_t; +typedef UINTN uintptr_t; +# elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + defined(__osf__) || defined(__sgi) || defined(__hpux) || \ + defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__) +# include +# undef OPENSSL_NO_INTTYPES_H +/* Because the specs say that inttypes.h includes stdint.h if present */ +# undef OPENSSL_NO_STDINT_H +# elif defined(_MSC_VER) && _MSC_VER<1600 +/* + * minimally required typdefs for systems not supporting inttypes.h or + * stdint.h: currently just older VC++ + */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +# elif defined(OPENSSL_SYS_TANDEM) +# include +# include +# else +# include +# undef OPENSSL_NO_STDINT_H +# endif +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ + defined(INTMAX_MAX) && defined(UINTMAX_MAX) +typedef intmax_t ossl_intmax_t; +typedef uintmax_t ossl_uintmax_t; +# else +/* Fall back to the largest we know we require and can handle */ +typedef int64_t ossl_intmax_t; +typedef uint64_t ossl_uintmax_t; +# endif + +/* ossl_inline: portable inline definition usable in public headers */ +# if !defined(inline) && !defined(__cplusplus) +# if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L + /* just use inline */ +# define ossl_inline inline +# elif defined(__GNUC__) && __GNUC__>=2 +# define ossl_inline __inline__ +# elif defined(_MSC_VER) + /* + * Visual Studio: inline is available in C++ only, however + * __inline is available for C, see + * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx + */ +# define ossl_inline __inline +# else +# define ossl_inline +# endif +# else +# define ossl_inline inline +# endif + +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \ + !defined(__cplusplus) +# define ossl_noreturn _Noreturn +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define ossl_noreturn __attribute__((noreturn)) +# else +# define ossl_noreturn +# endif + +/* ossl_unused: portable unused attribute for use in public headers */ +# if defined(__GNUC__) +# define ossl_unused __attribute__((unused)) +# else +# define ossl_unused +# endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/e_ostime.h b/illumos-x86_64/usr/include/openssl-3/e_ostime.h new file mode 100644 index 00000000..0e174875 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/e_ostime.h @@ -0,0 +1,38 @@ +/* + * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_E_OSTIME_H +# define OPENSSL_E_OSTIME_H +# pragma once + +# include +# include +# include + +/* + * This header guarantees that 'struct timeval' will be available. It includes + * the minimum headers needed to facilitate this. This may still be a + * substantial set of headers on some platforms (e.g. on Win32). + */ + +# if defined(OPENSSL_SYS_WINDOWS) +# if !defined(_WINSOCKAPI_) + /* + * winsock2.h defines _WINSOCK2API_ and both winsock2.h and winsock.h define + * _WINSOCKAPI_. Both of these provide struct timeval. Don't include + * winsock2.h if either header has been included to avoid breakage with + * applications that prefer to use over . + */ +# include +# endif +# else +# include +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ebcdic.h b/illumos-x86_64/usr/include/openssl-3/ebcdic.h new file mode 100644 index 00000000..e0ae1aa8 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ebcdic.h @@ -0,0 +1,39 @@ +/* + * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_EBCDIC_H +# define OPENSSL_EBCDIC_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_EBCDIC_H +# endif + +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Avoid name clashes with other applications */ +# define os_toascii _openssl_os_toascii +# define os_toebcdic _openssl_os_toebcdic +# define ebcdic2ascii _openssl_ebcdic2ascii +# define ascii2ebcdic _openssl_ascii2ebcdic + +extern const unsigned char os_toascii[256]; +extern const unsigned char os_toebcdic[256]; +void *ebcdic2ascii(void *dest, const void *srce, size_t count); +void *ascii2ebcdic(void *dest, const void *srce, size_t count); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ec.h b/illumos-x86_64/usr/include/openssl-3/ec.h new file mode 100644 index 00000000..e1cbe982 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ec.h @@ -0,0 +1,1588 @@ +/* + * Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_EC_H +# define OPENSSL_EC_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_EC_H +# endif + +# include +# include + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* Values for EVP_PKEY_CTX_set_ec_param_enc() */ +# define OPENSSL_EC_EXPLICIT_CURVE 0x000 +# define OPENSSL_EC_NAMED_CURVE 0x001 + +int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); +int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc); +int EVP_PKEY_CTX_set_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx, int cofactor_mode); +int EVP_PKEY_CTX_get_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx); + +int EVP_PKEY_CTX_set_ecdh_kdf_type(EVP_PKEY_CTX *ctx, int kdf); +int EVP_PKEY_CTX_get_ecdh_kdf_type(EVP_PKEY_CTX *ctx); + +int EVP_PKEY_CTX_set_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); +int EVP_PKEY_CTX_get_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); + +int EVP_PKEY_CTX_set_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int len); +int EVP_PKEY_CTX_get_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len); + +int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, + int len); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); +# endif + +# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) +# define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2) +# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3) +# define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4) +# define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5) +# define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6) +# define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7) +# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8) +# define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9) +# define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10) + +/* KDF types */ +# define EVP_PKEY_ECDH_KDF_NONE 1 +# define EVP_PKEY_ECDH_KDF_X9_63 2 +/* + * The old name for EVP_PKEY_ECDH_KDF_X9_63 + * The ECDH KDF specification has been mistakenly attributed to ANSI X9.62, + * it is actually specified in ANSI X9.63. + * This identifier is retained for backwards compatibility + */ +# define EVP_PKEY_ECDH_KDF_X9_62 EVP_PKEY_ECDH_KDF_X9_63 + +/** Enum for the point conversion form as defined in X9.62 (ECDSA) + * for the encoding of a elliptic curve point (x,y) */ +typedef enum { + /** the point is encoded as z||x, where the octet z specifies + * which solution of the quadratic equation y is */ + POINT_CONVERSION_COMPRESSED = 2, + /** the point is encoded as z||x||y, where z is the octet 0x04 */ + POINT_CONVERSION_UNCOMPRESSED = 4, + /** the point is encoded as z||x||y, where the octet z specifies + * which solution of the quadratic equation y is */ + POINT_CONVERSION_HYBRID = 6 +} point_conversion_form_t; + +const char *OSSL_EC_curve_nid2name(int nid); + +# ifndef OPENSSL_NO_STDIO +# include +# endif +# ifndef OPENSSL_NO_EC +# include +# include +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif +# include + +# ifndef OPENSSL_ECC_MAX_FIELD_BITS +# define OPENSSL_ECC_MAX_FIELD_BITS 661 +# endif + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef struct ec_method_st EC_METHOD; +# endif +typedef struct ec_group_st EC_GROUP; +typedef struct ec_point_st EC_POINT; +typedef struct ecpk_parameters_st ECPKPARAMETERS; +typedef struct ec_parameters_st ECPARAMETERS; + +/********************************************************************/ +/* EC_METHODs for curves over GF(p) */ +/********************************************************************/ + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/** Returns the basic GFp ec methods which provides the basis for the + * optimized methods. + * \return EC_METHOD object + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_simple_method(void); + +/** Returns GFp methods using montgomery multiplication. + * \return EC_METHOD object + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_mont_method(void); + +/** Returns GFp methods using optimized methods for NIST recommended curves + * \return EC_METHOD object + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nist_method(void); + +# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +/** Returns 64-bit optimized methods for nistp224 + * \return EC_METHOD object + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp224_method(void); + +/** Returns 64-bit optimized methods for nistp256 + * \return EC_METHOD object + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp256_method(void); + +/** Returns 64-bit optimized methods for nistp521 + * \return EC_METHOD object + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp521_method(void); +# endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */ + +# ifndef OPENSSL_NO_EC2M +/********************************************************************/ +/* EC_METHOD for curves over GF(2^m) */ +/********************************************************************/ + +/** Returns the basic GF2m ec method + * \return EC_METHOD object + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GF2m_simple_method(void); + +# endif + +/********************************************************************/ +/* EC_GROUP functions */ +/********************************************************************/ + +/** + * Creates a new EC_GROUP object + * \param meth EC_METHOD to use + * \return newly created EC_GROUP object or NULL in case of an error. + */ +OSSL_DEPRECATEDIN_3_0 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); + +/** Clears and frees a EC_GROUP object + * \param group EC_GROUP object to be cleared and freed. + */ +OSSL_DEPRECATEDIN_3_0 void EC_GROUP_clear_free(EC_GROUP *group); + +/** Returns the EC_METHOD of the EC_GROUP object. + * \param group EC_GROUP object + * \return EC_METHOD used in this EC_GROUP object. + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); + +/** Returns the field type of the EC_METHOD. + * \param meth EC_METHOD object + * \return NID of the underlying field type OID. + */ +OSSL_DEPRECATEDIN_3_0 int EC_METHOD_get_field_type(const EC_METHOD *meth); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/** Frees a EC_GROUP object + * \param group EC_GROUP object to be freed. + */ +void EC_GROUP_free(EC_GROUP *group); + +/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. + * \param dst destination EC_GROUP object + * \param src source EC_GROUP object + * \return 1 on success and 0 if an error occurred. + */ +int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); + +/** Creates a new EC_GROUP object and copies the content + * form src to the newly created EC_KEY object + * \param src source EC_GROUP object + * \return newly created EC_GROUP object or NULL in case of an error. + */ +EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); + +/** Sets the generator and its order/cofactor of a EC_GROUP object. + * \param group EC_GROUP object + * \param generator EC_POINT object with the generator. + * \param order the order of the group generated by the generator. + * \param cofactor the index of the sub-group generated by the generator + * in the group of all points on the elliptic curve. + * \return 1 on success and 0 if an error occurred + */ +int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, + const BIGNUM *order, const BIGNUM *cofactor); + +/** Returns the generator of a EC_GROUP object. + * \param group EC_GROUP object + * \return the currently used generator (possibly NULL). + */ +const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); + +/** Returns the montgomery data for order(Generator) + * \param group EC_GROUP object + * \return the currently used montgomery data (possibly NULL). +*/ +BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group); + +/** Gets the order of a EC_GROUP + * \param group EC_GROUP object + * \param order BIGNUM to which the order is copied + * \param ctx unused + * \return 1 on success and 0 if an error occurred + */ +int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); + +/** Gets the order of an EC_GROUP + * \param group EC_GROUP object + * \return the group order + */ +const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group); + +/** Gets the number of bits of the order of an EC_GROUP + * \param group EC_GROUP object + * \return number of bits of group order. + */ +int EC_GROUP_order_bits(const EC_GROUP *group); + +/** Gets the cofactor of a EC_GROUP + * \param group EC_GROUP object + * \param cofactor BIGNUM to which the cofactor is copied + * \param ctx unused + * \return 1 on success and 0 if an error occurred + */ +int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, + BN_CTX *ctx); + +/** Gets the cofactor of an EC_GROUP + * \param group EC_GROUP object + * \return the group cofactor + */ +const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group); + +/** Sets the name of a EC_GROUP object + * \param group EC_GROUP object + * \param nid NID of the curve name OID + */ +void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); + +/** Returns the curve name of a EC_GROUP object + * \param group EC_GROUP object + * \return NID of the curve name OID or 0 if not set. + */ +int EC_GROUP_get_curve_name(const EC_GROUP *group); + +/** Gets the field of an EC_GROUP + * \param group EC_GROUP object + * \return the group field + */ +const BIGNUM *EC_GROUP_get0_field(const EC_GROUP *group); + +/** Returns the field type of the EC_GROUP. + * \param group EC_GROUP object + * \return NID of the underlying field type OID. + */ +int EC_GROUP_get_field_type(const EC_GROUP *group); + +void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); +int EC_GROUP_get_asn1_flag(const EC_GROUP *group); + +void EC_GROUP_set_point_conversion_form(EC_GROUP *group, + point_conversion_form_t form); +point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); + +unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); +size_t EC_GROUP_get_seed_len(const EC_GROUP *); +size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); + +/** Sets the parameters of an ec curve defined by y^2 = x^3 + a*x + b (for GFp) + * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) + * \param group EC_GROUP object + * \param p BIGNUM with the prime number (GFp) or the polynomial + * defining the underlying field (GF2m) + * \param a BIGNUM with parameter a of the equation + * \param b BIGNUM with parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx); + +/** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp) + * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) + * \param group EC_GROUP object + * \param p BIGNUM with the prime number (GFp) or the polynomial + * defining the underlying field (GF2m) + * \param a BIGNUM for parameter a of the equation + * \param b BIGNUM for parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, + BN_CTX *ctx); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve + * \param group EC_GROUP object + * \param p BIGNUM with the prime number (GFp) or the polynomial + * defining the underlying field (GF2m) + * \param a BIGNUM with parameter a of the equation + * \param b BIGNUM with parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GFp(EC_GROUP *group, + const BIGNUM *p, + const BIGNUM *a, + const BIGNUM *b, + BN_CTX *ctx); + +/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve + * \param group EC_GROUP object + * \param p BIGNUM with the prime number (GFp) or the polynomial + * defining the underlying field (GF2m) + * \param a BIGNUM for parameter a of the equation + * \param b BIGNUM for parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, + BIGNUM *p, + BIGNUM *a, BIGNUM *b, + BN_CTX *ctx); + +# ifndef OPENSSL_NO_EC2M +/** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve + * \param group EC_GROUP object + * \param p BIGNUM with the prime number (GFp) or the polynomial + * defining the underlying field (GF2m) + * \param a BIGNUM with parameter a of the equation + * \param b BIGNUM with parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, + const BIGNUM *p, + const BIGNUM *a, + const BIGNUM *b, + BN_CTX *ctx); + +/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve + * \param group EC_GROUP object + * \param p BIGNUM with the prime number (GFp) or the polynomial + * defining the underlying field (GF2m) + * \param a BIGNUM for parameter a of the equation + * \param b BIGNUM for parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, + BIGNUM *p, + BIGNUM *a, BIGNUM *b, + BN_CTX *ctx); +# endif /* OPENSSL_NO_EC2M */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/** Returns the number of bits needed to represent a field element + * \param group EC_GROUP object + * \return number of bits needed to represent a field element + */ +int EC_GROUP_get_degree(const EC_GROUP *group); + +/** Checks whether the parameter in the EC_GROUP define a valid ec group + * \param group EC_GROUP object + * \param ctx BN_CTX object (optional) + * \return 1 if group is a valid ec group and 0 otherwise + */ +int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); + +/** Checks whether the discriminant of the elliptic curve is zero or not + * \param group EC_GROUP object + * \param ctx BN_CTX object (optional) + * \return 1 if the discriminant is not zero and 0 otherwise + */ +int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); + +/** Compares two EC_GROUP objects + * \param a first EC_GROUP object + * \param b second EC_GROUP object + * \param ctx BN_CTX object (optional) + * \return 0 if the groups are equal, 1 if not, or -1 on error + */ +int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); + +/* + * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after + * choosing an appropriate EC_METHOD + */ + +/** Creates a new EC_GROUP object with the specified parameters defined + * over GFp (defined by the equation y^2 = x^3 + a*x + b) + * \param p BIGNUM with the prime number + * \param a BIGNUM with the parameter a of the equation + * \param b BIGNUM with the parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return newly created EC_GROUP object with the specified parameters + */ +EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx); +# ifndef OPENSSL_NO_EC2M +/** Creates a new EC_GROUP object with the specified parameters defined + * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) + * \param p BIGNUM with the polynomial defining the underlying field + * \param a BIGNUM with the parameter a of the equation + * \param b BIGNUM with the parameter b of the equation + * \param ctx BN_CTX object (optional) + * \return newly created EC_GROUP object with the specified parameters + */ +EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx); +# endif + +/** + * Creates a EC_GROUP object with a curve specified by parameters. + * The parameters may be explicit or a named curve, + * \param params A list of parameters describing the group. + * \param libctx The associated library context or NULL for the default + * context + * \param propq A property query string + * \return newly created EC_GROUP object with specified parameters or NULL + * if an error occurred + */ +EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[], + OSSL_LIB_CTX *libctx, const char *propq); + +/** + * Creates an OSSL_PARAM array with the parameters describing the given + * EC_GROUP. + * The resulting parameters may contain an explicit or a named curve depending + * on the EC_GROUP. + * \param group pointer to the EC_GROUP object + * \param libctx The associated library context or NULL for the default + * context + * \param propq A property query string + * \param bnctx BN_CTX object (optional) + * \return newly created OSSL_PARAM array with the parameters + * describing the given EC_GROUP or NULL if an error occurred + */ +OSSL_PARAM *EC_GROUP_to_params(const EC_GROUP *group, OSSL_LIB_CTX *libctx, + const char *propq, BN_CTX *bnctx); + +/** + * Creates a EC_GROUP object with a curve specified by a NID + * \param libctx The associated library context or NULL for the default + * context + * \param propq A property query string + * \param nid NID of the OID of the curve name + * \return newly created EC_GROUP object with specified curve or NULL + * if an error occurred + */ +EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq, + int nid); + +/** + * Creates a EC_GROUP object with a curve specified by a NID. Same as + * EC_GROUP_new_by_curve_name_ex but the libctx and propq are always + * NULL. + * \param nid NID of the OID of the curve name + * \return newly created EC_GROUP object with specified curve or NULL + * if an error occurred + */ +EC_GROUP *EC_GROUP_new_by_curve_name(int nid); + +/** Creates a new EC_GROUP object from an ECPARAMETERS object + * \param params pointer to the ECPARAMETERS object + * \return newly created EC_GROUP object with specified curve or NULL + * if an error occurred + */ +EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params); + +/** Creates an ECPARAMETERS object for the given EC_GROUP object. + * \param group pointer to the EC_GROUP object + * \param params pointer to an existing ECPARAMETERS object or NULL + * \return pointer to the new ECPARAMETERS object or NULL + * if an error occurred. + */ +ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, + ECPARAMETERS *params); + +/** Creates a new EC_GROUP object from an ECPKPARAMETERS object + * \param params pointer to an existing ECPKPARAMETERS object, or NULL + * \return newly created EC_GROUP object with specified curve, or NULL + * if an error occurred + */ +EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params); + +/** Creates an ECPKPARAMETERS object for the given EC_GROUP object. + * \param group pointer to the EC_GROUP object + * \param params pointer to an existing ECPKPARAMETERS object or NULL + * \return pointer to the new ECPKPARAMETERS object or NULL + * if an error occurred. + */ +ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, + ECPKPARAMETERS *params); + +/********************************************************************/ +/* handling of internal curves */ +/********************************************************************/ + +typedef struct { + int nid; + const char *comment; +} EC_builtin_curve; + +/* + * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all + * available curves or zero if a error occurred. In case r is not zero, + * nitems EC_builtin_curve structures are filled with the data of the first + * nitems internal groups + */ +size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); + +const char *EC_curve_nid2nist(int nid); +int EC_curve_nist2nid(const char *name); +int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only, + BN_CTX *ctx); + +/********************************************************************/ +/* EC_POINT functions */ +/********************************************************************/ + +/** Creates a new EC_POINT object for the specified EC_GROUP + * \param group EC_GROUP the underlying EC_GROUP object + * \return newly created EC_POINT object or NULL if an error occurred + */ +EC_POINT *EC_POINT_new(const EC_GROUP *group); + +/** Frees a EC_POINT object + * \param point EC_POINT object to be freed + */ +void EC_POINT_free(EC_POINT *point); + +/** Clears and frees a EC_POINT object + * \param point EC_POINT object to be cleared and freed + */ +void EC_POINT_clear_free(EC_POINT *point); + +/** Copies EC_POINT object + * \param dst destination EC_POINT object + * \param src source EC_POINT object + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); + +/** Creates a new EC_POINT object and copies the content of the supplied + * EC_POINT + * \param src source EC_POINT object + * \param group underlying the EC_GROUP object + * \return newly created EC_POINT object or NULL if an error occurred + */ +EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); + +/** Sets a point to infinity (neutral element) + * \param group underlying EC_GROUP object + * \param point EC_POINT to set to infinity + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/** Returns the EC_METHOD used in EC_POINT object + * \param point EC_POINT object + * \return the EC_METHOD used + */ +OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); + +/** Sets the jacobian projective coordinates of a EC_POINT over GFp + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with the x-coordinate + * \param y BIGNUM with the y-coordinate + * \param z BIGNUM with the z-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_Jprojective_coordinates_GFp + (const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, + BN_CTX *ctx); + +/** Gets the jacobian projective coordinates of a EC_POINT over GFp + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM for the x-coordinate + * \param y BIGNUM for the y-coordinate + * \param z BIGNUM for the z-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_Jprojective_coordinates_GFp + (const EC_GROUP *group, const EC_POINT *p, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/** Sets the affine coordinates of an EC_POINT + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with the x-coordinate + * \param y BIGNUM with the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, + BN_CTX *ctx); + +/** Gets the affine coordinates of an EC_POINT. + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM for the x-coordinate + * \param y BIGNUM for the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/** Sets the affine coordinates of an EC_POINT. A synonym of + * EC_POINT_set_affine_coordinates + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with the x-coordinate + * \param y BIGNUM with the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GFp + (const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); + +/** Gets the affine coordinates of an EC_POINT. A synonym of + * EC_POINT_get_affine_coordinates + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM for the x-coordinate + * \param y BIGNUM for the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GFp + (const EC_GROUP *group, const EC_POINT *p, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/** Sets the x9.62 compressed coordinates of a EC_POINT + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with x-coordinate + * \param y_bit integer with the y-Bit (either 0 or 1) + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, int y_bit, + BN_CTX *ctx); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of + * EC_POINT_set_compressed_coordinates + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with x-coordinate + * \param y_bit integer with the y-Bit (either 0 or 1) + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GFp + (const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, int y_bit, BN_CTX *ctx); +# ifndef OPENSSL_NO_EC2M +/** Sets the affine coordinates of an EC_POINT. A synonym of + * EC_POINT_set_affine_coordinates + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with the x-coordinate + * \param y BIGNUM with the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GF2m + (const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); + +/** Gets the affine coordinates of an EC_POINT. A synonym of + * EC_POINT_get_affine_coordinates + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM for the x-coordinate + * \param y BIGNUM for the y-coordinate + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GF2m + (const EC_GROUP *group, const EC_POINT *p, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx); + +/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of + * EC_POINT_set_compressed_coordinates + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param x BIGNUM with x-coordinate + * \param y_bit integer with the y-Bit (either 0 or 1) + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GF2m + (const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, int y_bit, BN_CTX *ctx); +# endif +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/** Encodes a EC_POINT object to a octet string + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param form point conversion form + * \param buf memory buffer for the result. If NULL the function returns + * required buffer size. + * \param len length of the memory buffer + * \param ctx BN_CTX object (optional) + * \return the length of the encoded octet string or 0 if an error occurred + */ +size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, + point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *ctx); + +/** Decodes a EC_POINT from a octet string + * \param group underlying EC_GROUP object + * \param p EC_POINT object + * \param buf memory buffer with the encoded ec point + * \param len length of the encoded ec point + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, + const unsigned char *buf, size_t len, BN_CTX *ctx); + +/** Encodes an EC_POINT object to an allocated octet string + * \param group underlying EC_GROUP object + * \param point EC_POINT object + * \param form point conversion form + * \param pbuf returns pointer to allocated buffer + * \param ctx BN_CTX object (optional) + * \return the length of the encoded octet string or 0 if an error occurred + */ +size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point, + point_conversion_form_t form, + unsigned char **pbuf, BN_CTX *ctx); + +/* other interfaces to point2oct/oct2point: */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, + const EC_POINT *, + point_conversion_form_t form, + BIGNUM *, BN_CTX *); +OSSL_DEPRECATEDIN_3_0 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, + const BIGNUM *, + EC_POINT *, BN_CTX *); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BN_CTX *); +EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, + EC_POINT *, BN_CTX *); + +/********************************************************************/ +/* functions for doing EC_POINT arithmetic */ +/********************************************************************/ + +/** Computes the sum of two EC_POINT + * \param group underlying EC_GROUP object + * \param r EC_POINT object for the result (r = a + b) + * \param a EC_POINT object with the first summand + * \param b EC_POINT object with the second summand + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, + const EC_POINT *b, BN_CTX *ctx); + +/** Computes the double of a EC_POINT + * \param group underlying EC_GROUP object + * \param r EC_POINT object for the result (r = 2 * a) + * \param a EC_POINT object + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, + BN_CTX *ctx); + +/** Computes the inverse of a EC_POINT + * \param group underlying EC_GROUP object + * \param a EC_POINT object to be inverted (it's used for the result as well) + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); + +/** Checks whether the point is the neutral element of the group + * \param group the underlying EC_GROUP object + * \param p EC_POINT object + * \return 1 if the point is the neutral element and 0 otherwise + */ +int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); + +/** Checks whether the point is on the curve + * \param group underlying EC_GROUP object + * \param point EC_POINT object to check + * \param ctx BN_CTX object (optional) + * \return 1 if the point is on the curve, 0 if not, or -1 on error + */ +int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, + BN_CTX *ctx); + +/** Compares two EC_POINTs + * \param group underlying EC_GROUP object + * \param a first EC_POINT object + * \param b second EC_POINT object + * \param ctx BN_CTX object (optional) + * \return 1 if the points are not equal, 0 if they are, or -1 on error + */ +int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, + BN_CTX *ctx); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int EC_POINT_make_affine(const EC_GROUP *group, + EC_POINT *point, BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, + EC_POINT *points[], BN_CTX *ctx); + +/** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i] + * \param group underlying EC_GROUP object + * \param r EC_POINT object for the result + * \param n BIGNUM with the multiplier for the group generator (optional) + * \param num number further summands + * \param p array of size num of EC_POINT objects + * \param m array of size num of BIGNUM objects + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *n, size_t num, + const EC_POINT *p[], const BIGNUM *m[], + BN_CTX *ctx); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/** Computes r = generator * n + q * m + * \param group underlying EC_GROUP object + * \param r EC_POINT object for the result + * \param n BIGNUM with the multiplier for the group generator (optional) + * \param q EC_POINT object with the first factor of the second summand + * \param m BIGNUM with the second factor of the second summand + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, + const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/** Stores multiples of generator for faster point multiplication + * \param group EC_GROUP object + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); + +/** Reports whether a precomputation has been done + * \param group EC_GROUP object + * \return 1 if a pre-computation has been done and 0 otherwise + */ +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_have_precompute_mult(const EC_GROUP *group); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/********************************************************************/ +/* ASN1 stuff */ +/********************************************************************/ + +DECLARE_ASN1_ITEM(ECPKPARAMETERS) +DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS) +DECLARE_ASN1_ITEM(ECPARAMETERS) +DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) + +/* + * EC_GROUP_get_basis_type() returns the NID of the basis type used to + * represent the field elements + */ +int EC_GROUP_get_basis_type(const EC_GROUP *); +# ifndef OPENSSL_NO_EC2M +int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); +int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, + unsigned int *k2, unsigned int *k3); +# endif + +EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); +int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); + +# define d2i_ECPKParameters_bio(bp,x) \ + ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x) +# define i2d_ECPKParameters_bio(bp,x) \ + ASN1_i2d_bio_of(EC_GROUP, i2d_ECPKParameters, bp, x) +# define d2i_ECPKParameters_fp(fp,x) \ + (EC_GROUP *)ASN1_d2i_fp(NULL, (d2i_of_void *)d2i_ECPKParameters, (fp), \ + (void **)(x)) +# define i2d_ECPKParameters_fp(fp,x) \ + ASN1_i2d_fp((i2d_of_void *)i2d_ECPKParameters, (fp), (void *)(x)) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, + int off); +# ifndef OPENSSL_NO_STDIO +OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, + int off); +# endif +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/********************************************************************/ +/* EC_KEY functions */ +/********************************************************************/ + +/* some values for the encoding_flag */ +# define EC_PKEY_NO_PARAMETERS 0x001 +# define EC_PKEY_NO_PUBKEY 0x002 + +/* some values for the flags field */ +# define EC_FLAG_SM2_RANGE 0x0004 +# define EC_FLAG_COFACTOR_ECDH 0x1000 +# define EC_FLAG_CHECK_NAMED_GROUP 0x2000 +# define EC_FLAG_CHECK_NAMED_GROUP_NIST 0x4000 +# define EC_FLAG_CHECK_NAMED_GROUP_MASK \ + (EC_FLAG_CHECK_NAMED_GROUP | EC_FLAG_CHECK_NAMED_GROUP_NIST) + +/* Deprecated flags - it was using 0x01..0x02 */ +# define EC_FLAG_NON_FIPS_ALLOW 0x0000 +# define EC_FLAG_FIPS_CHECKED 0x0000 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/** + * Creates a new EC_KEY object. + * \param ctx The library context for to use for this EC_KEY. May be NULL in + * which case the default library context is used. + * \return EC_KEY object or NULL if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_ex(OSSL_LIB_CTX *ctx, const char *propq); + +/** + * Creates a new EC_KEY object. Same as calling EC_KEY_new_ex with a + * NULL library context + * \return EC_KEY object or NULL if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new(void); + +OSSL_DEPRECATEDIN_3_0 int EC_KEY_get_flags(const EC_KEY *key); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_flags(EC_KEY *key, int flags); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_clear_flags(EC_KEY *key, int flags); + +OSSL_DEPRECATEDIN_3_0 int EC_KEY_decoded_from_explicit_params(const EC_KEY *key); + +/** + * Creates a new EC_KEY object using a named curve as underlying + * EC_GROUP object. + * \param ctx The library context for to use for this EC_KEY. May be NULL in + * which case the default library context is used. + * \param propq Any property query string + * \param nid NID of the named curve. + * \return EC_KEY object or NULL if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name_ex(OSSL_LIB_CTX *ctx, + const char *propq, + int nid); + +/** + * Creates a new EC_KEY object using a named curve as underlying + * EC_GROUP object. Same as calling EC_KEY_new_by_curve_name_ex with a NULL + * library context and property query string. + * \param nid NID of the named curve. + * \return EC_KEY object or NULL if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name(int nid); + +/** Frees a EC_KEY object. + * \param key EC_KEY object to be freed. + */ +OSSL_DEPRECATEDIN_3_0 void EC_KEY_free(EC_KEY *key); + +/** Copies a EC_KEY object. + * \param dst destination EC_KEY object + * \param src src EC_KEY object + * \return dst or NULL if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); + +/** Creates a new EC_KEY object and copies the content from src to it. + * \param src the source EC_KEY object + * \return newly created EC_KEY object or NULL if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_dup(const EC_KEY *src); + +/** Increases the internal reference count of a EC_KEY object. + * \param key EC_KEY object + * \return 1 on success and 0 if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_up_ref(EC_KEY *key); + +/** Returns the ENGINE object of a EC_KEY object + * \param eckey EC_KEY object + * \return the ENGINE object (possibly NULL). + */ +OSSL_DEPRECATEDIN_3_0 ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey); + +/** Returns the EC_GROUP object of a EC_KEY object + * \param key EC_KEY object + * \return the EC_GROUP object (possibly NULL). + */ +OSSL_DEPRECATEDIN_3_0 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); + +/** Sets the EC_GROUP of a EC_KEY object. + * \param key EC_KEY object + * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY + * object will use an own copy of the EC_GROUP). + * \return 1 on success and 0 if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); + +/** Returns the private key of a EC_KEY object. + * \param key EC_KEY object + * \return a BIGNUM with the private key (possibly NULL). + */ +OSSL_DEPRECATEDIN_3_0 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); + +/** Sets the private key of a EC_KEY object. + * \param key EC_KEY object + * \param prv BIGNUM with the private key (note: the EC_KEY object + * will use an own copy of the BIGNUM). + * \return 1 on success and 0 if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); + +/** Returns the public key of a EC_KEY object. + * \param key the EC_KEY object + * \return a EC_POINT object with the public key (possibly NULL) + */ +OSSL_DEPRECATEDIN_3_0 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); + +/** Sets the public key of a EC_KEY object. + * \param key EC_KEY object + * \param pub EC_POINT object with the public key (note: the EC_KEY object + * will use an own copy of the EC_POINT object). + * \return 1 on success and 0 if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); + +OSSL_DEPRECATEDIN_3_0 unsigned EC_KEY_get_enc_flags(const EC_KEY *key); +OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); +OSSL_DEPRECATEDIN_3_0 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); +OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_conv_form(EC_KEY *eckey, + point_conversion_form_t cform); +# endif /*OPENSSL_NO_DEPRECATED_3_0 */ + +# define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg); +OSSL_DEPRECATEDIN_3_0 void *EC_KEY_get_ex_data(const EC_KEY *key, int idx); + +/* wrapper functions for the underlying EC_GROUP object */ +OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); + +/** Creates a table of pre-computed multiples of the generator to + * accelerate further EC_KEY operations. + * \param key EC_KEY object + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); + +/** Creates a new ec private (and optional a new public) key. + * \param key EC_KEY object + * \return 1 on success and 0 if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_generate_key(EC_KEY *key); + +/** Verifies that a private and/or public key is valid. + * \param key the EC_KEY object + * \return 1 on success and 0 otherwise. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_check_key(const EC_KEY *key); + +/** Indicates if an EC_KEY can be used for signing. + * \param eckey the EC_KEY object + * \return 1 if can sign and 0 otherwise. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_can_sign(const EC_KEY *eckey); + +/** Sets a public key from affine coordinates performing + * necessary NIST PKV tests. + * \param key the EC_KEY object + * \param x public key x coordinate + * \param y public key y coordinate + * \return 1 on success and 0 otherwise. + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, + BIGNUM *x, + BIGNUM *y); + +/** Encodes an EC_KEY public key to an allocated octet string + * \param key key to encode + * \param form point conversion form + * \param pbuf returns pointer to allocated buffer + * \param ctx BN_CTX object (optional) + * \return the length of the encoded octet string or 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_key2buf(const EC_KEY *key, + point_conversion_form_t form, + unsigned char **pbuf, BN_CTX *ctx); + +/** Decodes a EC_KEY public key from a octet string + * \param key key to decode + * \param buf memory buffer with the encoded ec point + * \param len length of the encoded ec point + * \param ctx BN_CTX object (optional) + * \return 1 on success and 0 if an error occurred + */ + +OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, + size_t len, BN_CTX *ctx); + +/** Decodes an EC_KEY private key from an octet string + * \param key key to decode + * \param buf memory buffer with the encoded private key + * \param len length of the encoded key + * \return 1 on success and 0 if an error occurred + */ + +OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, + size_t len); + +/** Encodes a EC_KEY private key to an octet string + * \param key key to encode + * \param buf memory buffer for the result. If NULL the function returns + * required buffer size. + * \param len length of the memory buffer + * \return the length of the encoded octet string or 0 if an error occurred + */ + +OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2oct(const EC_KEY *key, + unsigned char *buf, size_t len); + +/** Encodes an EC_KEY private key to an allocated octet string + * \param eckey key to encode + * \param pbuf returns pointer to allocated buffer + * \return the length of the encoded octet string or 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2buf(const EC_KEY *eckey, + unsigned char **pbuf); + +/********************************************************************/ +/* de- and encoding functions for SEC1 ECPrivateKey */ +/********************************************************************/ + +/** Decodes a private key from a memory buffer. + * \param key a pointer to a EC_KEY object which should be used (or NULL) + * \param in pointer to memory with the DER encoded private key + * \param len length of the DER encoded private key + * \return the decoded private key or NULL if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, + const unsigned char **in, + long len); + +/** Encodes a private key object and stores the result in a buffer. + * \param key the EC_KEY object to encode + * \param out the buffer for the result (if NULL the function returns number + * of bytes needed). + * \return 1 on success and 0 if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey(const EC_KEY *key, + unsigned char **out); + +/********************************************************************/ +/* de- and encoding functions for EC parameters */ +/********************************************************************/ + +/** Decodes ec parameter from a memory buffer. + * \param key a pointer to a EC_KEY object which should be used (or NULL) + * \param in pointer to memory with the DER encoded ec parameters + * \param len length of the DER encoded ec parameters + * \return a EC_KEY object with the decoded parameters or NULL if an error + * occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECParameters(EC_KEY **key, + const unsigned char **in, + long len); + +/** Encodes ec parameter and stores the result in a buffer. + * \param key the EC_KEY object with ec parameters to encode + * \param out the buffer for the result (if NULL the function returns number + * of bytes needed). + * \return 1 on success and 0 if an error occurred. + */ +OSSL_DEPRECATEDIN_3_0 int i2d_ECParameters(const EC_KEY *key, + unsigned char **out); + +/********************************************************************/ +/* de- and encoding functions for EC public key */ +/* (octet string, not DER -- hence 'o2i' and 'i2o') */ +/********************************************************************/ + +/** Decodes an ec public key from a octet string. + * \param key a pointer to a EC_KEY object which should be used + * \param in memory buffer with the encoded public key + * \param len length of the encoded public key + * \return EC_KEY object with decoded public key or NULL if an error + * occurred. + */ +OSSL_DEPRECATEDIN_3_0 EC_KEY *o2i_ECPublicKey(EC_KEY **key, + const unsigned char **in, long len); + +/** Encodes an ec public key in an octet string. + * \param key the EC_KEY object with the public key + * \param out the buffer for the result (if NULL the function returns number + * of bytes needed). + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out); + +/** Prints out the ec parameters on human readable form. + * \param bp BIO object to which the information is printed + * \param key EC_KEY object + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int ECParameters_print(BIO *bp, const EC_KEY *key); + +/** Prints out the contents of a EC_KEY object + * \param bp BIO object to which the information is printed + * \param key EC_KEY object + * \param off line offset + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); + +# ifndef OPENSSL_NO_STDIO +/** Prints out the ec parameters on human readable form. + * \param fp file descriptor to which the information is printed + * \param key EC_KEY object + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int ECParameters_print_fp(FILE *fp, const EC_KEY *key); + +/** Prints out the contents of a EC_KEY object + * \param fp file descriptor to which the information is printed + * \param key EC_KEY object + * \param off line offset + * \return 1 on success and 0 if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); +# endif /* OPENSSL_NO_STDIO */ + +OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_OpenSSL(void); +OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_get_default_method(void); +OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_default_method(const EC_KEY_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key); +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_method(ENGINE *engine); + +/** The old name for ecdh_KDF_X9_63 + * The ECDH KDF specification has been mistakenly attributed to ANSI X9.62, + * it is actually specified in ANSI X9.63. + * This identifier is retained for backwards compatibility + */ +OSSL_DEPRECATEDIN_3_0 int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, + const unsigned char *Z, size_t Zlen, + const unsigned char *sinfo, + size_t sinfolen, const EVP_MD *md); + +OSSL_DEPRECATEDIN_3_0 int ECDH_compute_key(void *out, size_t outlen, + const EC_POINT *pub_key, + const EC_KEY *ecdh, + void *(*KDF)(const void *in, + size_t inlen, void *out, + size_t *outlen)); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +typedef struct ECDSA_SIG_st ECDSA_SIG; + +/** Allocates and initialize a ECDSA_SIG structure + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +ECDSA_SIG *ECDSA_SIG_new(void); + +/** frees a ECDSA_SIG structure + * \param sig pointer to the ECDSA_SIG structure + */ +void ECDSA_SIG_free(ECDSA_SIG *sig); + +/** i2d_ECDSA_SIG encodes content of ECDSA_SIG (note: this function modifies *pp + * (*pp += length of the DER encoded signature)). + * \param sig pointer to the ECDSA_SIG object + * \param pp pointer to a unsigned char pointer for the output or NULL + * \return the length of the DER encoded ECDSA_SIG object or a negative value + * on error + */ +DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG, ECDSA_SIG) + +/** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies *pp + * (*pp += len)). + * \param sig pointer to ECDSA_SIG pointer (may be NULL) + * \param pp memory buffer with the DER encoded signature + * \param len length of the buffer + * \return pointer to the decoded ECDSA_SIG structure (or NULL) + */ + +/** Accessor for r and s fields of ECDSA_SIG + * \param sig pointer to ECDSA_SIG structure + * \param pr pointer to BIGNUM pointer for r (may be NULL) + * \param ps pointer to BIGNUM pointer for s (may be NULL) + */ +void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); + +/** Accessor for r field of ECDSA_SIG + * \param sig pointer to ECDSA_SIG structure + */ +const BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig); + +/** Accessor for s field of ECDSA_SIG + * \param sig pointer to ECDSA_SIG structure + */ +const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig); + +/** Setter for r and s fields of ECDSA_SIG + * \param sig pointer to ECDSA_SIG structure + * \param r pointer to BIGNUM for r + * \param s pointer to BIGNUM for s + */ +int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/** Computes the ECDSA signature of the given hash value using + * the supplied private key and returns the created signature. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param eckey EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, + int dgst_len, EC_KEY *eckey); + +/** Computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param kinv BIGNUM with a pre-computed inverse k (optional) + * \param rp BIGNUM with a pre-computed rp value (optional), + * see ECDSA_sign_setup + * \param eckey EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, + int dgstlen, const BIGNUM *kinv, + const BIGNUM *rp, EC_KEY *eckey); + +/** Verifies that the supplied signature is a valid ECDSA + * signature of the supplied hash value using the supplied public key. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param sig ECDSA_SIG structure + * \param eckey EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid + * and -1 on error + */ +OSSL_DEPRECATEDIN_3_0 int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey); + +/** Precompute parts of the signing operation + * \param eckey EC_KEY object containing a private EC key + * \param ctx BN_CTX object (optional) + * \param kinv BIGNUM pointer for the inverse of k + * \param rp BIGNUM pointer for x coordinate of k * generator + * \return 1 on success and 0 otherwise + */ +OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, + BIGNUM **kinv, BIGNUM **rp); + +/** Computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig memory for the DER encoded created signature + * \param siglen pointer to the length of the returned signature + * \param eckey EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +OSSL_DEPRECATEDIN_3_0 int ECDSA_sign(int type, const unsigned char *dgst, + int dgstlen, unsigned char *sig, + unsigned int *siglen, EC_KEY *eckey); + +/** Computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param kinv BIGNUM with a pre-computed inverse k (optional) + * \param rp BIGNUM with a pre-computed rp value (optional), + * see ECDSA_sign_setup + * \param eckey EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_ex(int type, const unsigned char *dgst, + int dgstlen, unsigned char *sig, + unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *rp, EC_KEY *eckey); + +/** Verifies that the given signature is valid ECDSA signature + * of the supplied hash value using the specified public key. + * \param type this parameter is ignored + * \param dgst pointer to the hash value + * \param dgstlen length of the hash value + * \param sig pointer to the DER encoded signature + * \param siglen length of the DER encoded signature + * \param eckey EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid + * and -1 on error + */ +OSSL_DEPRECATEDIN_3_0 int ECDSA_verify(int type, const unsigned char *dgst, + int dgstlen, const unsigned char *sig, + int siglen, EC_KEY *eckey); + +/** Returns the maximum length of the DER encoded signature + * \param eckey EC_KEY object + * \return numbers of bytes required for the DER encoded signature + */ +OSSL_DEPRECATEDIN_3_0 int ECDSA_size(const EC_KEY *eckey); + +/********************************************************************/ +/* EC_KEY_METHOD constructors, destructors, writers and accessors */ +/********************************************************************/ + +OSSL_DEPRECATEDIN_3_0 EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_free(EC_KEY_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_init + (EC_KEY_METHOD *meth, + int (*init)(EC_KEY *key), + void (*finish)(EC_KEY *key), + int (*copy)(EC_KEY *dest, const EC_KEY *src), + int (*set_group)(EC_KEY *key, const EC_GROUP *grp), + int (*set_private)(EC_KEY *key, const BIGNUM *priv_key), + int (*set_public)(EC_KEY *key, const EC_POINT *pub_key)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth, + int (*keygen)(EC_KEY *key)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_compute_key + (EC_KEY_METHOD *meth, + int (*ckey)(unsigned char **psec, size_t *pseclen, + const EC_POINT *pub_key, const EC_KEY *ecdh)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_sign + (EC_KEY_METHOD *meth, + int (*sign)(int type, const unsigned char *dgst, + int dlen, unsigned char *sig, + unsigned int *siglen, + const BIGNUM *kinv, const BIGNUM *r, + EC_KEY *eckey), + int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, + BIGNUM **kinvp, BIGNUM **rp), + ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, + int dgst_len, + const BIGNUM *in_kinv, + const BIGNUM *in_r, + EC_KEY *eckey)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_verify + (EC_KEY_METHOD *meth, + int (*verify)(int type, const unsigned + char *dgst, int dgst_len, + const unsigned char *sigbuf, + int sig_len, EC_KEY *eckey), + int (*verify_sig)(const unsigned char *dgst, + int dgst_len, const ECDSA_SIG *sig, + EC_KEY *eckey)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_init + (const EC_KEY_METHOD *meth, + int (**pinit)(EC_KEY *key), + void (**pfinish)(EC_KEY *key), + int (**pcopy)(EC_KEY *dest, const EC_KEY *src), + int (**pset_group)(EC_KEY *key, const EC_GROUP *grp), + int (**pset_private)(EC_KEY *key, const BIGNUM *priv_key), + int (**pset_public)(EC_KEY *key, const EC_POINT *pub_key)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_keygen + (const EC_KEY_METHOD *meth, int (**pkeygen)(EC_KEY *key)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_compute_key + (const EC_KEY_METHOD *meth, + int (**pck)(unsigned char **psec, + size_t *pseclen, + const EC_POINT *pub_key, + const EC_KEY *ecdh)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_sign + (const EC_KEY_METHOD *meth, + int (**psign)(int type, const unsigned char *dgst, + int dlen, unsigned char *sig, + unsigned int *siglen, + const BIGNUM *kinv, const BIGNUM *r, + EC_KEY *eckey), + int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, + BIGNUM **kinvp, BIGNUM **rp), + ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, + int dgst_len, + const BIGNUM *in_kinv, + const BIGNUM *in_r, + EC_KEY *eckey)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_verify + (const EC_KEY_METHOD *meth, + int (**pverify)(int type, const unsigned + char *dgst, int dgst_len, + const unsigned char *sigbuf, + int sig_len, EC_KEY *eckey), + int (**pverify_sig)(const unsigned char *dgst, + int dgst_len, + const ECDSA_SIG *sig, + EC_KEY *eckey)); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +# define EVP_EC_gen(curve) \ + EVP_PKEY_Q_keygen(NULL, NULL, "EC", (char *)(strstr(curve, ""))) + /* strstr is used to enable type checking for the variadic string arg */ +# define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, \ + d2i_ECParameters, x) + +# ifndef __cplusplus +# if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +# endif +# endif + +# endif +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ecdh.h b/illumos-x86_64/usr/include/openssl-3/ecdh.h new file mode 100644 index 00000000..56bd4cc2 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ecdh.h @@ -0,0 +1,10 @@ +/* + * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include diff --git a/illumos-x86_64/usr/include/openssl-3/ecdsa.h b/illumos-x86_64/usr/include/openssl-3/ecdsa.h new file mode 100644 index 00000000..56bd4cc2 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ecdsa.h @@ -0,0 +1,10 @@ +/* + * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include diff --git a/illumos-x86_64/usr/include/openssl-3/ecerr.h b/illumos-x86_64/usr/include/openssl-3/ecerr.h new file mode 100644 index 00000000..f15f91f6 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ecerr.h @@ -0,0 +1,104 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ECERR_H +# define OPENSSL_ECERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_EC + + +/* + * EC reason codes. + */ +# define EC_R_ASN1_ERROR 115 +# define EC_R_BAD_SIGNATURE 156 +# define EC_R_BIGNUM_OUT_OF_RANGE 144 +# define EC_R_BUFFER_TOO_SMALL 100 +# define EC_R_CANNOT_INVERT 165 +# define EC_R_COORDINATES_OUT_OF_RANGE 146 +# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160 +# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDSA 170 +# define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159 +# define EC_R_DECODE_ERROR 142 +# define EC_R_DISCRIMINANT_IS_ZERO 118 +# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 +# define EC_R_EXPLICIT_PARAMS_NOT_SUPPORTED 127 +# define EC_R_FAILED_MAKING_PUBLIC_KEY 166 +# define EC_R_FIELD_TOO_LARGE 143 +# define EC_R_GF2M_NOT_SUPPORTED 147 +# define EC_R_GROUP2PKPARAMETERS_FAILURE 120 +# define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 +# define EC_R_INCOMPATIBLE_OBJECTS 101 +# define EC_R_INVALID_A 168 +# define EC_R_INVALID_ARGUMENT 112 +# define EC_R_INVALID_B 169 +# define EC_R_INVALID_COFACTOR 171 +# define EC_R_INVALID_COMPRESSED_POINT 110 +# define EC_R_INVALID_COMPRESSION_BIT 109 +# define EC_R_INVALID_CURVE 141 +# define EC_R_INVALID_DIGEST 151 +# define EC_R_INVALID_DIGEST_TYPE 138 +# define EC_R_INVALID_ENCODING 102 +# define EC_R_INVALID_FIELD 103 +# define EC_R_INVALID_FORM 104 +# define EC_R_INVALID_GENERATOR 173 +# define EC_R_INVALID_GROUP_ORDER 122 +# define EC_R_INVALID_KEY 116 +# define EC_R_INVALID_LENGTH 117 +# define EC_R_INVALID_NAMED_GROUP_CONVERSION 174 +# define EC_R_INVALID_OUTPUT_LENGTH 161 +# define EC_R_INVALID_P 172 +# define EC_R_INVALID_PEER_KEY 133 +# define EC_R_INVALID_PENTANOMIAL_BASIS 132 +# define EC_R_INVALID_PRIVATE_KEY 123 +# define EC_R_INVALID_SEED 175 +# define EC_R_INVALID_TRINOMIAL_BASIS 137 +# define EC_R_KDF_PARAMETER_ERROR 148 +# define EC_R_KEYS_NOT_SET 140 +# define EC_R_LADDER_POST_FAILURE 136 +# define EC_R_LADDER_PRE_FAILURE 153 +# define EC_R_LADDER_STEP_FAILURE 162 +# define EC_R_MISSING_OID 167 +# define EC_R_MISSING_PARAMETERS 124 +# define EC_R_MISSING_PRIVATE_KEY 125 +# define EC_R_NEED_NEW_SETUP_VALUES 157 +# define EC_R_NOT_A_NIST_PRIME 135 +# define EC_R_NOT_IMPLEMENTED 126 +# define EC_R_NOT_INITIALIZED 111 +# define EC_R_NO_PARAMETERS_SET 139 +# define EC_R_NO_PRIVATE_VALUE 154 +# define EC_R_OPERATION_NOT_SUPPORTED 152 +# define EC_R_PASSED_NULL_PARAMETER 134 +# define EC_R_PEER_KEY_ERROR 149 +# define EC_R_POINT_ARITHMETIC_FAILURE 155 +# define EC_R_POINT_AT_INFINITY 106 +# define EC_R_POINT_COORDINATES_BLIND_FAILURE 163 +# define EC_R_POINT_IS_NOT_ON_CURVE 107 +# define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158 +# define EC_R_SHARED_INFO_ERROR 150 +# define EC_R_SLOT_FULL 108 +# define EC_R_TOO_MANY_RETRIES 176 +# define EC_R_UNDEFINED_GENERATOR 113 +# define EC_R_UNDEFINED_ORDER 128 +# define EC_R_UNKNOWN_COFACTOR 164 +# define EC_R_UNKNOWN_GROUP 129 +# define EC_R_UNKNOWN_ORDER 114 +# define EC_R_UNSUPPORTED_FIELD 131 +# define EC_R_WRONG_CURVE_PARAMETERS 145 +# define EC_R_WRONG_ORDER 130 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/encoder.h b/illumos-x86_64/usr/include/openssl-3/encoder.h new file mode 100644 index 00000000..c37a6f16 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/encoder.h @@ -0,0 +1,124 @@ +/* + * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ENCODER_H +# define OPENSSL_ENCODER_H +# pragma once + +# include + +# ifndef OPENSSL_NO_STDIO +# include +# endif +# include +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +OSSL_ENCODER *OSSL_ENCODER_fetch(OSSL_LIB_CTX *libctx, const char *name, + const char *properties); +int OSSL_ENCODER_up_ref(OSSL_ENCODER *encoder); +void OSSL_ENCODER_free(OSSL_ENCODER *encoder); + +const OSSL_PROVIDER *OSSL_ENCODER_get0_provider(const OSSL_ENCODER *encoder); +const char *OSSL_ENCODER_get0_properties(const OSSL_ENCODER *encoder); +const char *OSSL_ENCODER_get0_name(const OSSL_ENCODER *kdf); +const char *OSSL_ENCODER_get0_description(const OSSL_ENCODER *kdf); +int OSSL_ENCODER_is_a(const OSSL_ENCODER *encoder, const char *name); + +void OSSL_ENCODER_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(OSSL_ENCODER *encoder, void *arg), + void *arg); +int OSSL_ENCODER_names_do_all(const OSSL_ENCODER *encoder, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PARAM *OSSL_ENCODER_gettable_params(OSSL_ENCODER *encoder); +int OSSL_ENCODER_get_params(OSSL_ENCODER *encoder, OSSL_PARAM params[]); + +const OSSL_PARAM *OSSL_ENCODER_settable_ctx_params(OSSL_ENCODER *encoder); +OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new(void); +int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx, + const OSSL_PARAM params[]); +void OSSL_ENCODER_CTX_free(OSSL_ENCODER_CTX *ctx); + +/* Utilities that help set specific parameters */ +int OSSL_ENCODER_CTX_set_passphrase(OSSL_ENCODER_CTX *ctx, + const unsigned char *kstr, size_t klen); +int OSSL_ENCODER_CTX_set_pem_password_cb(OSSL_ENCODER_CTX *ctx, + pem_password_cb *cb, void *cbarg); +int OSSL_ENCODER_CTX_set_passphrase_cb(OSSL_ENCODER_CTX *ctx, + OSSL_PASSPHRASE_CALLBACK *cb, + void *cbarg); +int OSSL_ENCODER_CTX_set_passphrase_ui(OSSL_ENCODER_CTX *ctx, + const UI_METHOD *ui_method, + void *ui_data); +int OSSL_ENCODER_CTX_set_cipher(OSSL_ENCODER_CTX *ctx, + const char *cipher_name, + const char *propquery); +int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection); +int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx, + const char *output_type); +int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx, + const char *output_structure); + +/* Utilities to add encoders */ +int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder); +int OSSL_ENCODER_CTX_add_extra(OSSL_ENCODER_CTX *ctx, + OSSL_LIB_CTX *libctx, const char *propq); +int OSSL_ENCODER_CTX_get_num_encoders(OSSL_ENCODER_CTX *ctx); + +typedef struct ossl_encoder_instance_st OSSL_ENCODER_INSTANCE; +OSSL_ENCODER * +OSSL_ENCODER_INSTANCE_get_encoder(OSSL_ENCODER_INSTANCE *encoder_inst); +void * +OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE *encoder_inst); +const char * +OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE *encoder_inst); +const char * +OSSL_ENCODER_INSTANCE_get_output_structure(OSSL_ENCODER_INSTANCE *encoder_inst); + +typedef const void *OSSL_ENCODER_CONSTRUCT(OSSL_ENCODER_INSTANCE *encoder_inst, + void *construct_data); +typedef void OSSL_ENCODER_CLEANUP(void *construct_data); + +int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx, + OSSL_ENCODER_CONSTRUCT *construct); +int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx, + void *construct_data); +int OSSL_ENCODER_CTX_set_cleanup(OSSL_ENCODER_CTX *ctx, + OSSL_ENCODER_CLEANUP *cleanup); + +/* Utilities to output the object to encode */ +int OSSL_ENCODER_to_bio(OSSL_ENCODER_CTX *ctx, BIO *out); +#ifndef OPENSSL_NO_STDIO +int OSSL_ENCODER_to_fp(OSSL_ENCODER_CTX *ctx, FILE *fp); +#endif +int OSSL_ENCODER_to_data(OSSL_ENCODER_CTX *ctx, unsigned char **pdata, + size_t *pdata_len); + +/* + * Create the OSSL_ENCODER_CTX with an associated type. This will perform + * an implicit OSSL_ENCODER_fetch(), suitable for the object of that type. + * This is more useful than calling OSSL_ENCODER_CTX_new(). + */ +OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new_for_pkey(const EVP_PKEY *pkey, + int selection, + const char *output_type, + const char *output_struct, + const char *propquery); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/encodererr.h b/illumos-x86_64/usr/include/openssl-3/encodererr.h new file mode 100644 index 00000000..5e318b14 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/encodererr.h @@ -0,0 +1,28 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ENCODERERR_H +# define OPENSSL_ENCODERERR_H +# pragma once + +# include +# include +# include + + + +/* + * OSSL_ENCODER reason codes. + */ +# define OSSL_ENCODER_R_ENCODER_NOT_FOUND 101 +# define OSSL_ENCODER_R_INCORRECT_PROPERTY_QUERY 100 +# define OSSL_ENCODER_R_MISSING_GET_PARAMS 102 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/engine.h b/illumos-x86_64/usr/include/openssl-3/engine.h new file mode 100644 index 00000000..5b4b504b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/engine.h @@ -0,0 +1,833 @@ +/* + * Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ENGINE_H +# define OPENSSL_ENGINE_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_ENGINE_H +# endif + +# include + +# ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# include +# include +# include +# include +# include +# include +# include +# endif +# include +# include +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + +/* + * These flags are used to control combinations of algorithm (methods) by + * bitwise "OR"ing. + */ +# define ENGINE_METHOD_RSA (unsigned int)0x0001 +# define ENGINE_METHOD_DSA (unsigned int)0x0002 +# define ENGINE_METHOD_DH (unsigned int)0x0004 +# define ENGINE_METHOD_RAND (unsigned int)0x0008 +# define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 +# define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 +# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 +# define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 +# define ENGINE_METHOD_EC (unsigned int)0x0800 +/* Obvious all-or-nothing cases. */ +# define ENGINE_METHOD_ALL (unsigned int)0xFFFF +# define ENGINE_METHOD_NONE (unsigned int)0x0000 + +/* + * This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used + * internally to control registration of ENGINE implementations, and can be + * set by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to + * initialise registered ENGINEs if they are not already initialised. + */ +# define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 + +/* ENGINE flags that can be set by ENGINE_set_flags(). */ +/* Not used */ +/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ + +/* + * This flag is for ENGINEs that wish to handle the various 'CMD'-related + * control commands on their own. Without this flag, ENGINE_ctrl() handles + * these control commands on behalf of the ENGINE using their "cmd_defns" + * data. + */ +# define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 + +/* + * This flag is for ENGINEs who return new duplicate structures when found + * via "ENGINE_by_id()". When an ENGINE must store state (eg. if + * ENGINE_ctrl() commands are called in sequence as part of some stateful + * process like key-generation setup and execution), it can set this flag - + * then each attempt to obtain the ENGINE will result in it being copied into + * a new structure. Normally, ENGINEs don't declare this flag so + * ENGINE_by_id() just increments the existing ENGINE's structural reference + * count. + */ +# define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 + +/* + * This flag is for an ENGINE that does not want its methods registered as + * part of ENGINE_register_all_complete() for example if the methods are not + * usable as default methods. + */ + +# define ENGINE_FLAGS_NO_REGISTER_ALL (int)0x0008 + +/* + * ENGINEs can support their own command types, and these flags are used in + * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input + * each command expects. Currently only numeric and string input is + * supported. If a control command supports none of the _NUMERIC, _STRING, or + * _NO_INPUT options, then it is regarded as an "internal" control command - + * and not for use in config setting situations. As such, they're not + * available to the ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() + * access. Changes to this list of 'command types' should be reflected + * carefully in ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). + */ + +/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ +# define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 +/* + * accepts string input (cast from 'void*' to 'const char *', 4th parameter + * to ENGINE_ctrl) + */ +# define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 +/* + * Indicates that the control command takes *no* input. Ie. the control + * command is unparameterised. + */ +# define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 +/* + * Indicates that the control command is internal. This control command won't + * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() + * function. + */ +# define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 + +/* + * NB: These 3 control commands are deprecated and should not be used. + * ENGINEs relying on these commands should compile conditional support for + * compatibility (eg. if these symbols are defined) but should also migrate + * the same functionality to their own ENGINE-specific control functions that + * can be "discovered" by calling applications. The fact these control + * commands wouldn't be "executable" (ie. usable by text-based config) + * doesn't change the fact that application code can find and use them + * without requiring per-ENGINE hacking. + */ + +/* + * These flags are used to tell the ctrl function what should be done. All + * command numbers are shared between all engines, even if some don't make + * sense to some engines. In such a case, they do nothing but return the + * error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. + */ +# define ENGINE_CTRL_SET_LOGSTREAM 1 +# define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 +# define ENGINE_CTRL_HUP 3/* Close and reinitialise + * any handles/connections + * etc. */ +# define ENGINE_CTRL_SET_USER_INTERFACE 4/* Alternative to callback */ +# define ENGINE_CTRL_SET_CALLBACK_DATA 5/* User-specific data, used + * when calling the password + * callback and the user + * interface */ +# define ENGINE_CTRL_LOAD_CONFIGURATION 6/* Load a configuration, + * given a string that + * represents a file name + * or so */ +# define ENGINE_CTRL_LOAD_SECTION 7/* Load data from a given + * section in the already + * loaded configuration */ + +/* + * These control commands allow an application to deal with an arbitrary + * engine in a dynamic way. Warn: Negative return values indicate errors FOR + * THESE COMMANDS because zero is used to indicate 'end-of-list'. Other + * commands, including ENGINE-specific command types, return zero for an + * error. An ENGINE can choose to implement these ctrl functions, and can + * internally manage things however it chooses - it does so by setting the + * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise + * the ENGINE_ctrl() code handles this on the ENGINE's behalf using the + * cmd_defns data (set using ENGINE_set_cmd_defns()). This means an ENGINE's + * ctrl() handler need only implement its own commands - the above "meta" + * commands will be taken care of. + */ + +/* + * Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", + * then all the remaining control commands will return failure, so it is + * worth checking this first if the caller is trying to "discover" the + * engine's capabilities and doesn't want errors generated unnecessarily. + */ +# define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 +/* + * Returns a positive command number for the first command supported by the + * engine. Returns zero if no ctrl commands are supported. + */ +# define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 +/* + * The 'long' argument specifies a command implemented by the engine, and the + * return value is the next command supported, or zero if there are no more. + */ +# define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 +/* + * The 'void*' argument is a command name (cast from 'const char *'), and the + * return value is the command that corresponds to it. + */ +# define ENGINE_CTRL_GET_CMD_FROM_NAME 13 +/* + * The next two allow a command to be converted into its corresponding string + * form. In each case, the 'long' argument supplies the command. In the + * NAME_LEN case, the return value is the length of the command name (not + * counting a trailing EOL). In the NAME case, the 'void*' argument must be a + * string buffer large enough, and it will be populated with the name of the + * command (WITH a trailing EOL). + */ +# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 +# define ENGINE_CTRL_GET_NAME_FROM_CMD 15 +/* The next two are similar but give a "short description" of a command. */ +# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 +# define ENGINE_CTRL_GET_DESC_FROM_CMD 17 +/* + * With this command, the return value is the OR'd combination of + * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given + * engine-specific ctrl command expects. + */ +# define ENGINE_CTRL_GET_CMD_FLAGS 18 + +/* + * ENGINE implementations should start the numbering of their own control + * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). + */ +# define ENGINE_CMD_BASE 200 + +/* + * NB: These 2 nCipher "chil" control commands are deprecated, and their + * functionality is now available through ENGINE-specific control commands + * (exposed through the above-mentioned 'CMD'-handling). Code using these 2 + * commands should be migrated to the more general command handling before + * these are removed. + */ + +/* Flags specific to the nCipher "chil" engine */ +# define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 + /* + * Depending on the value of the (long)i argument, this sets or + * unsets the SimpleForkCheck flag in the CHIL API to enable or + * disable checking and workarounds for applications that fork(). + */ +# define ENGINE_CTRL_CHIL_NO_LOCKING 101 + /* + * This prevents the initialisation function from providing mutex + * callbacks to the nCipher library. + */ + +/* + * If an ENGINE supports its own specific control commands and wishes the + * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on + * its behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN + * entries to ENGINE_set_cmd_defns(). It should also implement a ctrl() + * handler that supports the stated commands (ie. the "cmd_num" entries as + * described by the array). NB: The array must be ordered in increasing order + * of cmd_num. "null-terminated" means that the last ENGINE_CMD_DEFN element + * has cmd_num set to zero and/or cmd_name set to NULL. + */ +typedef struct ENGINE_CMD_DEFN_st { + unsigned int cmd_num; /* The command number */ + const char *cmd_name; /* The command name itself */ + const char *cmd_desc; /* A short description of the command */ + unsigned int cmd_flags; /* The input the command expects */ +} ENGINE_CMD_DEFN; + +/* Generic function pointer */ +typedef int (*ENGINE_GEN_FUNC_PTR) (void); +/* Generic function pointer taking no arguments */ +typedef int (*ENGINE_GEN_INT_FUNC_PTR) (ENGINE *); +/* Specific control function pointer */ +typedef int (*ENGINE_CTRL_FUNC_PTR) (ENGINE *, int, long, void *, + void (*f) (void)); +/* Generic load_key function pointer */ +typedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, + UI_METHOD *ui_method, + void *callback_data); +typedef int (*ENGINE_SSL_CLIENT_CERT_PTR) (ENGINE *, SSL *ssl, + STACK_OF(X509_NAME) *ca_dn, + X509 **pcert, EVP_PKEY **pkey, + STACK_OF(X509) **pother, + UI_METHOD *ui_method, + void *callback_data); +/*- + * These callback types are for an ENGINE's handler for cipher and digest logic. + * These handlers have these prototypes; + * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); + * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); + * Looking at how to implement these handlers in the case of cipher support, if + * the framework wants the EVP_CIPHER for 'nid', it will call; + * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure) + * If the framework wants a list of supported 'nid's, it will call; + * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error) + */ +/* + * Returns to a pointer to the array of supported cipher 'nid's. If the + * second parameter is non-NULL it is set to the size of the returned array. + */ +typedef int (*ENGINE_CIPHERS_PTR) (ENGINE *, const EVP_CIPHER **, + const int **, int); +typedef int (*ENGINE_DIGESTS_PTR) (ENGINE *, const EVP_MD **, const int **, + int); +typedef int (*ENGINE_PKEY_METHS_PTR) (ENGINE *, EVP_PKEY_METHOD **, + const int **, int); +typedef int (*ENGINE_PKEY_ASN1_METHS_PTR) (ENGINE *, EVP_PKEY_ASN1_METHOD **, + const int **, int); +/* + * STRUCTURE functions ... all of these functions deal with pointers to + * ENGINE structures where the pointers have a "structural reference". This + * means that their reference is to allowed access to the structure but it + * does not imply that the structure is functional. To simply increment or + * decrement the structural reference count, use ENGINE_by_id and + * ENGINE_free. NB: This is not required when iterating using ENGINE_get_next + * as it will automatically decrement the structural reference count of the + * "current" ENGINE and increment the structural reference count of the + * ENGINE it returns (unless it is NULL). + */ + +/* Get the first/last "ENGINE" type available. */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_first(void); +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_last(void); +# endif +/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_next(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_prev(ENGINE *e); +# endif +/* Add another "ENGINE" type into the array. */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_add(ENGINE *e); +# endif +/* Remove an existing "ENGINE" type from the array. */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_remove(ENGINE *e); +# endif +/* Retrieve an engine from the list by its unique "id" value. */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_by_id(const char *id); +# endif + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define ENGINE_load_openssl() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL) +# define ENGINE_load_dynamic() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL) +# ifndef OPENSSL_NO_STATIC_ENGINE +# define ENGINE_load_padlock() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL) +# define ENGINE_load_capi() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL) +# define ENGINE_load_afalg() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL) +# endif +# define ENGINE_load_cryptodev() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL) +# define ENGINE_load_rdrand() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL) +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 void ENGINE_load_builtin_engines(void); +# endif + +/* + * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation + * "registry" handling. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 unsigned int ENGINE_get_table_flags(void); +OSSL_DEPRECATEDIN_3_0 void ENGINE_set_table_flags(unsigned int flags); +# endif + +/*- Manage registration of ENGINEs per "table". For each type, there are 3 + * functions; + * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) + * ENGINE_unregister_***(e) - unregister the implementation from 'e' + * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list + * Cleanup is automatically registered from each table when required. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_RSA(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_RSA(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_RSA(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_DSA(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_DSA(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_DSA(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_EC(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_EC(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_EC(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_DH(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_DH(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_DH(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_RAND(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_RAND(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_RAND(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_ciphers(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_ciphers(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_ciphers(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_digests(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_digests(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_digests(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_pkey_meths(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_pkey_meths(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_pkey_meths(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_pkey_asn1_meths(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_pkey_asn1_meths(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_pkey_asn1_meths(void); +# endif + +/* + * These functions register all support from the above categories. Note, use + * of these functions can result in static linkage of code your application + * may not need. If you only need a subset of functionality, consider using + * more selective initialisation. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_complete(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_register_all_complete(void); +# endif + +/* + * Send parameterised control commands to the engine. The possibilities to + * send down an integer, a pointer to data or a function pointer are + * provided. Any of the parameters may or may not be NULL, depending on the + * command number. In actuality, this function only requires a structural + * (rather than functional) reference to an engine, but many control commands + * may require the engine be functional. The caller should be aware of trying + * commands that require an operational ENGINE, and only use functional + * references in such situations. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, + void (*f) (void)); +# endif + +/* + * This function tests if an ENGINE-specific command is usable as a + * "setting". Eg. in an application's config file that gets processed through + * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to + * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_cmd_is_executable(ENGINE *e, int cmd); +# endif + +/* + * This function works like ENGINE_ctrl() with the exception of taking a + * command name instead of a command number, and can handle optional + * commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation + * on how to use the cmd_name and cmd_optional. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, + long i, void *p, void (*f) (void), + int cmd_optional); +# endif + +/* + * This function passes a command-name and argument to an ENGINE. The + * cmd_name is converted to a command number and the control command is + * called using 'arg' as an argument (unless the ENGINE doesn't support such + * a command, in which case no control command is called). The command is + * checked for input flags, and if necessary the argument will be converted + * to a numeric value. If cmd_optional is non-zero, then if the ENGINE + * doesn't support the given cmd_name the return value will be success + * anyway. This function is intended for applications to use so that users + * (or config files) can supply engine-specific config data to the ENGINE at + * run-time to control behaviour of specific engines. As such, it shouldn't + * be used for calling ENGINE_ctrl() functions that return data, deal with + * binary data, or that are otherwise supposed to be used directly through + * ENGINE_ctrl() in application code. Any "return" data from an ENGINE_ctrl() + * operation in this function will be lost - the return value is interpreted + * as failure if the return value is zero, success otherwise, and this + * function returns a boolean value as a result. In other words, vendors of + * 'ENGINE'-enabled devices should write ENGINE implementations with + * parameterisations that work in this scheme, so that compliant ENGINE-based + * applications can work consistently with the same configuration for the + * same ENGINE-enabled devices, across applications. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, + int cmd_optional); +# endif + +/* + * These functions are useful for manufacturing new ENGINE structures. They + * don't address reference counting at all - one uses them to populate an + * ENGINE structure with personalised implementations of things prior to + * using it directly or adding it to the builtin ENGINE list in OpenSSL. + * These are also here so that the ENGINE structure doesn't have to be + * exposed and break binary compatibility! + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_new(void); +OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_up_ref(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_id(ENGINE *e, const char *id); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_name(ENGINE *e, const char *name); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_destroy_function(ENGINE *e,ENGINE_GEN_INT_FUNC_PTR destroy_f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, + ENGINE_SSL_CLIENT_CERT_PTR loadssl_f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_flags(ENGINE *e, int flags); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_cmd_defns(ENGINE *e, + const ENGINE_CMD_DEFN *defns); +# endif +/* These functions allow control over any per-structure ENGINE data. */ +# define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef) +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); +OSSL_DEPRECATEDIN_3_0 void *ENGINE_get_ex_data(const ENGINE *e, int idx); +# endif + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +/* + * This function previously cleaned up anything that needs it. Auto-deinit will + * now take care of it so it is no longer required to call this function. + */ +# define ENGINE_cleanup() while(0) continue +# endif + +/* + * These return values from within the ENGINE structure. These can be useful + * with functional references as well as structural references - it depends + * which you obtained. Using the result for functional purposes if you only + * obtained a structural reference may be problematic! + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 const char *ENGINE_get_id(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 const char *ENGINE_get_name(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 const DH_METHOD *ENGINE_get_DH(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); +OSSL_DEPRECATEDIN_3_0 +const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); +OSSL_DEPRECATEDIN_3_0 +const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); +OSSL_DEPRECATEDIN_3_0 +const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); +OSSL_DEPRECATEDIN_3_0 +const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, + const char *str, + int len); +OSSL_DEPRECATEDIN_3_0 +const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, + const char *str, int len); +OSSL_DEPRECATEDIN_3_0 +const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_get_flags(const ENGINE *e); +# endif + +/* + * FUNCTIONAL functions. These functions deal with ENGINE structures that + * have (or will) be initialised for use. Broadly speaking, the structural + * functions are useful for iterating the list of available engine types, + * creating new engine types, and other "list" operations. These functions + * actually deal with ENGINEs that are to be used. As such these functions + * can fail (if applicable) when particular engines are unavailable - eg. if + * a hardware accelerator is not attached or not functioning correctly. Each + * ENGINE has 2 reference counts; structural and functional. Every time a + * functional reference is obtained or released, a corresponding structural + * reference is automatically obtained or released too. + */ + +/* + * Initialise an engine type for use (or up its reference count if it's + * already in use). This will fail if the engine is not currently operational + * and cannot initialise. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_init(ENGINE *e); +# endif +/* + * Free a functional reference to an engine type. This does not require a + * corresponding call to ENGINE_free as it also releases a structural + * reference. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_finish(ENGINE *e); +# endif + +/* + * The following functions handle keys that are stored in some secondary + * location, handled by the engine. The storage may be on a card or + * whatever. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); +OSSL_DEPRECATEDIN_3_0 +EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); +OSSL_DEPRECATEDIN_3_0 +int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, STACK_OF(X509_NAME) *ca_dn, + X509 **pcert, EVP_PKEY **ppkey, + STACK_OF(X509) **pother, + UI_METHOD *ui_method, void *callback_data); +# endif + +/* + * This returns a pointer for the current ENGINE structure that is (by + * default) performing any RSA operations. The value returned is an + * incremented reference, so it should be free'd (ENGINE_finish) before it is + * discarded. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_RSA(void); +# endif +/* Same for the other "methods" */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_DSA(void); +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_EC(void); +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_DH(void); +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_RAND(void); +# endif +/* + * These functions can be used to get a functional reference to perform + * ciphering or digesting corresponding to "nid". + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_cipher_engine(int nid); +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_digest_engine(int nid); +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_pkey_meth_engine(int nid); +OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid); +# endif + +/* + * This sets a new default ENGINE structure for performing RSA operations. If + * the result is non-zero (success) then the ENGINE structure will have had + * its reference count up'd so the caller should still free their own + * reference 'e'. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_RSA(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_string(ENGINE *e, + const char *def_list); +# endif +/* Same for the other "methods" */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_DSA(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_EC(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_DH(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_RAND(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_ciphers(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_digests(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_pkey_meths(ENGINE *e); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_pkey_asn1_meths(ENGINE *e); +# endif + +/* + * The combination "set" - the flags are bitwise "OR"d from the + * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" + * function, this function can result in unnecessary static linkage. If your + * application requires only specific functionality, consider using more + * selective functions. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default(ENGINE *e, unsigned int flags); +OSSL_DEPRECATEDIN_3_0 void ENGINE_add_conf_module(void); +# endif + +/* Deprecated functions ... */ +/* int ENGINE_clear_defaults(void); */ + +/**************************/ +/* DYNAMIC ENGINE SUPPORT */ +/**************************/ + +/* Binary/behaviour compatibility levels */ +# define OSSL_DYNAMIC_VERSION (unsigned long)0x00030000 +/* + * Binary versions older than this are too old for us (whether we're a loader + * or a loadee) + */ +# define OSSL_DYNAMIC_OLDEST (unsigned long)0x00030000 + +/* + * When compiling an ENGINE entirely as an external shared library, loadable + * by the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' + * structure type provides the calling application's (or library's) error + * functionality and memory management function pointers to the loaded + * library. These should be used/set in the loaded library code so that the + * loading application's 'state' will be used/changed in all operations. The + * 'static_state' pointer allows the loaded library to know if it shares the + * same static data as the calling application (or library), and thus whether + * these callbacks need to be set or not. + */ +typedef void *(*dyn_MEM_malloc_fn) (size_t, const char *, int); +typedef void *(*dyn_MEM_realloc_fn) (void *, size_t, const char *, int); +typedef void (*dyn_MEM_free_fn) (void *, const char *, int); +typedef struct st_dynamic_MEM_fns { + dyn_MEM_malloc_fn malloc_fn; + dyn_MEM_realloc_fn realloc_fn; + dyn_MEM_free_fn free_fn; +} dynamic_MEM_fns; +/* + * FIXME: Perhaps the memory and locking code (crypto.h) should declare and + * use these types so we (and any other dependent code) can simplify a bit?? + */ +/* The top-level structure */ +typedef struct st_dynamic_fns { + void *static_state; + dynamic_MEM_fns mem_fns; +} dynamic_fns; + +/* + * The version checking function should be of this prototype. NB: The + * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading + * code. If this function returns zero, it indicates a (potential) version + * incompatibility and the loaded library doesn't believe it can proceed. + * Otherwise, the returned value is the (latest) version supported by the + * loading library. The loader may still decide that the loaded code's + * version is unsatisfactory and could veto the load. The function is + * expected to be implemented with the symbol name "v_check", and a default + * implementation can be fully instantiated with + * IMPLEMENT_DYNAMIC_CHECK_FN(). + */ +typedef unsigned long (*dynamic_v_check_fn) (unsigned long ossl_version); +# define IMPLEMENT_DYNAMIC_CHECK_FN() \ + OPENSSL_EXPORT unsigned long v_check(unsigned long v); \ + OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ + if (v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ + return 0; } + +/* + * This function is passed the ENGINE structure to initialise with its own + * function and command settings. It should not adjust the structural or + * functional reference counts. If this function returns zero, (a) the load + * will be aborted, (b) the previous ENGINE state will be memcpy'd back onto + * the structure, and (c) the shared library will be unloaded. So + * implementations should do their own internal cleanup in failure + * circumstances otherwise they could leak. The 'id' parameter, if non-NULL, + * represents the ENGINE id that the loader is looking for. If this is NULL, + * the shared library can choose to return failure or to initialise a + * 'default' ENGINE. If non-NULL, the shared library must initialise only an + * ENGINE matching the passed 'id'. The function is expected to be + * implemented with the symbol name "bind_engine". A standard implementation + * can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where the parameter + * 'fn' is a callback function that populates the ENGINE structure and + * returns an int value (zero for failure). 'fn' should have prototype; + * [static] int fn(ENGINE *e, const char *id); + */ +typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id, + const dynamic_fns *fns); +# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ + OPENSSL_EXPORT \ + int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ + OPENSSL_EXPORT \ + int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ + if (ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ + CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \ + fns->mem_fns.realloc_fn, \ + fns->mem_fns.free_fn); \ + OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \ + skip_cbs: \ + if (!fn(e, id)) return 0; \ + return 1; } + +/* + * If the loading application (or library) and the loaded ENGINE library + * share the same static data (eg. they're both dynamically linked to the + * same libcrypto.so) we need a way to avoid trying to set system callbacks - + * this would fail, and for the same reason that it's unnecessary to try. If + * the loaded ENGINE has (or gets from through the loader) its own copy of + * the libcrypto static data, we will need to set the callbacks. The easiest + * way to detect this is to have a function that returns a pointer to some + * static data and let the loading application and loaded ENGINE compare + * their respective values. + */ +void *ENGINE_get_static_state(void); + +# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 void ENGINE_setup_bsd_cryptodev(void); +# endif +# endif + + +# ifdef __cplusplus +} +# endif +# endif /* OPENSSL_NO_ENGINE */ +#endif /* OPENSSL_ENGINE_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/engineerr.h b/illumos-x86_64/usr/include/openssl-3/engineerr.h new file mode 100644 index 00000000..d439b682 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/engineerr.h @@ -0,0 +1,63 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ENGINEERR_H +# define OPENSSL_ENGINEERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_ENGINE + + +/* + * ENGINE reason codes. + */ +# define ENGINE_R_ALREADY_LOADED 100 +# define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 +# define ENGINE_R_CMD_NOT_EXECUTABLE 134 +# define ENGINE_R_COMMAND_TAKES_INPUT 135 +# define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 +# define ENGINE_R_CONFLICTING_ENGINE_ID 103 +# define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 +# define ENGINE_R_DSO_FAILURE 104 +# define ENGINE_R_DSO_NOT_FOUND 132 +# define ENGINE_R_ENGINES_SECTION_ERROR 148 +# define ENGINE_R_ENGINE_CONFIGURATION_ERROR 102 +# define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 +# define ENGINE_R_ENGINE_SECTION_ERROR 149 +# define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 +# define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 +# define ENGINE_R_FINISH_FAILED 106 +# define ENGINE_R_ID_OR_NAME_MISSING 108 +# define ENGINE_R_INIT_FAILED 109 +# define ENGINE_R_INTERNAL_LIST_ERROR 110 +# define ENGINE_R_INVALID_ARGUMENT 143 +# define ENGINE_R_INVALID_CMD_NAME 137 +# define ENGINE_R_INVALID_CMD_NUMBER 138 +# define ENGINE_R_INVALID_INIT_VALUE 151 +# define ENGINE_R_INVALID_STRING 150 +# define ENGINE_R_NOT_INITIALISED 117 +# define ENGINE_R_NOT_LOADED 112 +# define ENGINE_R_NO_CONTROL_FUNCTION 120 +# define ENGINE_R_NO_INDEX 144 +# define ENGINE_R_NO_LOAD_FUNCTION 125 +# define ENGINE_R_NO_REFERENCE 130 +# define ENGINE_R_NO_SUCH_ENGINE 116 +# define ENGINE_R_UNIMPLEMENTED_CIPHER 146 +# define ENGINE_R_UNIMPLEMENTED_DIGEST 147 +# define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD 101 +# define ENGINE_R_VERSION_INCOMPATIBILITY 145 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/err.h b/illumos-x86_64/usr/include/openssl-3/err.h new file mode 100644 index 00000000..daca18e7 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/err.h @@ -0,0 +1,512 @@ +/* + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_ERR_H +# define OPENSSL_ERR_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_ERR_H +# endif + +# include + +# ifndef OPENSSL_NO_STDIO +# include +# include +# endif + +# include +# include +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_FILENAMES +# define ERR_PUT_error(l,f,r,fn,ln) ERR_put_error(l,f,r,fn,ln) +# else +# define ERR_PUT_error(l,f,r,fn,ln) ERR_put_error(l,f,r,NULL,0) +# endif +# endif + +# include +# include + +# define ERR_TXT_MALLOCED 0x01 +# define ERR_TXT_STRING 0x02 + +# if !defined(OPENSSL_NO_DEPRECATED_3_0) || defined(OSSL_FORCE_ERR_STATE) +# define ERR_FLAG_MARK 0x01 +# define ERR_FLAG_CLEAR 0x02 + +# define ERR_NUM_ERRORS 16 +struct err_state_st { + int err_flags[ERR_NUM_ERRORS]; + int err_marks[ERR_NUM_ERRORS]; + unsigned long err_buffer[ERR_NUM_ERRORS]; + char *err_data[ERR_NUM_ERRORS]; + size_t err_data_size[ERR_NUM_ERRORS]; + int err_data_flags[ERR_NUM_ERRORS]; + char *err_file[ERR_NUM_ERRORS]; + int err_line[ERR_NUM_ERRORS]; + char *err_func[ERR_NUM_ERRORS]; + int top, bottom; +}; +# endif + +/* library */ +# define ERR_LIB_NONE 1 +# define ERR_LIB_SYS 2 +# define ERR_LIB_BN 3 +# define ERR_LIB_RSA 4 +# define ERR_LIB_DH 5 +# define ERR_LIB_EVP 6 +# define ERR_LIB_BUF 7 +# define ERR_LIB_OBJ 8 +# define ERR_LIB_PEM 9 +# define ERR_LIB_DSA 10 +# define ERR_LIB_X509 11 +/* #define ERR_LIB_METH 12 */ +# define ERR_LIB_ASN1 13 +# define ERR_LIB_CONF 14 +# define ERR_LIB_CRYPTO 15 +# define ERR_LIB_EC 16 +# define ERR_LIB_SSL 20 +/* #define ERR_LIB_SSL23 21 */ +/* #define ERR_LIB_SSL2 22 */ +/* #define ERR_LIB_SSL3 23 */ +/* #define ERR_LIB_RSAREF 30 */ +/* #define ERR_LIB_PROXY 31 */ +# define ERR_LIB_BIO 32 +# define ERR_LIB_PKCS7 33 +# define ERR_LIB_X509V3 34 +# define ERR_LIB_PKCS12 35 +# define ERR_LIB_RAND 36 +# define ERR_LIB_DSO 37 +# define ERR_LIB_ENGINE 38 +# define ERR_LIB_OCSP 39 +# define ERR_LIB_UI 40 +# define ERR_LIB_COMP 41 +# define ERR_LIB_ECDSA 42 +# define ERR_LIB_ECDH 43 +# define ERR_LIB_OSSL_STORE 44 +# define ERR_LIB_FIPS 45 +# define ERR_LIB_CMS 46 +# define ERR_LIB_TS 47 +# define ERR_LIB_HMAC 48 +/* # define ERR_LIB_JPAKE 49 */ +# define ERR_LIB_CT 50 +# define ERR_LIB_ASYNC 51 +# define ERR_LIB_KDF 52 +# define ERR_LIB_SM2 53 +# define ERR_LIB_ESS 54 +# define ERR_LIB_PROP 55 +# define ERR_LIB_CRMF 56 +# define ERR_LIB_PROV 57 +# define ERR_LIB_CMP 58 +# define ERR_LIB_OSSL_ENCODER 59 +# define ERR_LIB_OSSL_DECODER 60 +# define ERR_LIB_HTTP 61 + +# define ERR_LIB_USER 128 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define ASN1err(f, r) ERR_raise_data(ERR_LIB_ASN1, (r), NULL) +# define ASYNCerr(f, r) ERR_raise_data(ERR_LIB_ASYNC, (r), NULL) +# define BIOerr(f, r) ERR_raise_data(ERR_LIB_BIO, (r), NULL) +# define BNerr(f, r) ERR_raise_data(ERR_LIB_BN, (r), NULL) +# define BUFerr(f, r) ERR_raise_data(ERR_LIB_BUF, (r), NULL) +# define CMPerr(f, r) ERR_raise_data(ERR_LIB_CMP, (r), NULL) +# define CMSerr(f, r) ERR_raise_data(ERR_LIB_CMS, (r), NULL) +# define COMPerr(f, r) ERR_raise_data(ERR_LIB_COMP, (r), NULL) +# define CONFerr(f, r) ERR_raise_data(ERR_LIB_CONF, (r), NULL) +# define CRMFerr(f, r) ERR_raise_data(ERR_LIB_CRMF, (r), NULL) +# define CRYPTOerr(f, r) ERR_raise_data(ERR_LIB_CRYPTO, (r), NULL) +# define CTerr(f, r) ERR_raise_data(ERR_LIB_CT, (r), NULL) +# define DHerr(f, r) ERR_raise_data(ERR_LIB_DH, (r), NULL) +# define DSAerr(f, r) ERR_raise_data(ERR_LIB_DSA, (r), NULL) +# define DSOerr(f, r) ERR_raise_data(ERR_LIB_DSO, (r), NULL) +# define ECDHerr(f, r) ERR_raise_data(ERR_LIB_ECDH, (r), NULL) +# define ECDSAerr(f, r) ERR_raise_data(ERR_LIB_ECDSA, (r), NULL) +# define ECerr(f, r) ERR_raise_data(ERR_LIB_EC, (r), NULL) +# define ENGINEerr(f, r) ERR_raise_data(ERR_LIB_ENGINE, (r), NULL) +# define ESSerr(f, r) ERR_raise_data(ERR_LIB_ESS, (r), NULL) +# define EVPerr(f, r) ERR_raise_data(ERR_LIB_EVP, (r), NULL) +# define FIPSerr(f, r) ERR_raise_data(ERR_LIB_FIPS, (r), NULL) +# define HMACerr(f, r) ERR_raise_data(ERR_LIB_HMAC, (r), NULL) +# define HTTPerr(f, r) ERR_raise_data(ERR_LIB_HTTP, (r), NULL) +# define KDFerr(f, r) ERR_raise_data(ERR_LIB_KDF, (r), NULL) +# define OBJerr(f, r) ERR_raise_data(ERR_LIB_OBJ, (r), NULL) +# define OCSPerr(f, r) ERR_raise_data(ERR_LIB_OCSP, (r), NULL) +# define OSSL_STOREerr(f, r) ERR_raise_data(ERR_LIB_OSSL_STORE, (r), NULL) +# define PEMerr(f, r) ERR_raise_data(ERR_LIB_PEM, (r), NULL) +# define PKCS12err(f, r) ERR_raise_data(ERR_LIB_PKCS12, (r), NULL) +# define PKCS7err(f, r) ERR_raise_data(ERR_LIB_PKCS7, (r), NULL) +# define PROPerr(f, r) ERR_raise_data(ERR_LIB_PROP, (r), NULL) +# define PROVerr(f, r) ERR_raise_data(ERR_LIB_PROV, (r), NULL) +# define RANDerr(f, r) ERR_raise_data(ERR_LIB_RAND, (r), NULL) +# define RSAerr(f, r) ERR_raise_data(ERR_LIB_RSA, (r), NULL) +# define KDFerr(f, r) ERR_raise_data(ERR_LIB_KDF, (r), NULL) +# define SM2err(f, r) ERR_raise_data(ERR_LIB_SM2, (r), NULL) +# define SSLerr(f, r) ERR_raise_data(ERR_LIB_SSL, (r), NULL) +# define SYSerr(f, r) ERR_raise_data(ERR_LIB_SYS, (r), NULL) +# define TSerr(f, r) ERR_raise_data(ERR_LIB_TS, (r), NULL) +# define UIerr(f, r) ERR_raise_data(ERR_LIB_UI, (r), NULL) +# define X509V3err(f, r) ERR_raise_data(ERR_LIB_X509V3, (r), NULL) +# define X509err(f, r) ERR_raise_data(ERR_LIB_X509, (r), NULL) +# endif + +/*- + * The error code packs differently depending on if it records a system + * error or an OpenSSL error. + * + * A system error packs like this (we follow POSIX and only allow positive + * numbers that fit in an |int|): + * + * +-+-------------------------------------------------------------+ + * |1| system error number | + * +-+-------------------------------------------------------------+ + * + * An OpenSSL error packs like this: + * + * <---------------------------- 32 bits --------------------------> + * <--- 8 bits ---><------------------ 23 bits -----------------> + * +-+---------------+---------------------------------------------+ + * |0| library | reason | + * +-+---------------+---------------------------------------------+ + * + * A few of the reason bits are reserved as flags with special meaning: + * + * <5 bits-<>--------- 19 bits -----------------> + * +-------+-+-----------------------------------+ + * | rflags| | reason | + * +-------+-+-----------------------------------+ + * ^ + * | + * ERR_RFLAG_FATAL = ERR_R_FATAL + * + * The reason flags are part of the overall reason code for practical + * reasons, as they provide an easy way to place different types of + * reason codes in different numeric ranges. + * + * The currently known reason flags are: + * + * ERR_RFLAG_FATAL Flags that the reason code is considered fatal. + * For backward compatibility reasons, this flag + * is also the code for ERR_R_FATAL (that reason + * code served the dual purpose of flag and reason + * code in one in pre-3.0 OpenSSL). + * ERR_RFLAG_COMMON Flags that the reason code is common to all + * libraries. All ERR_R_ macros must use this flag, + * and no other _R_ macro is allowed to use it. + */ + +/* Macros to help decode recorded system errors */ +# define ERR_SYSTEM_FLAG ((unsigned int)INT_MAX + 1) +# define ERR_SYSTEM_MASK ((unsigned int)INT_MAX) + +/* + * Macros to help decode recorded OpenSSL errors + * As expressed above, RFLAGS and REASON overlap by one bit to allow + * ERR_R_FATAL to use ERR_RFLAG_FATAL as its reason code. + */ +# define ERR_LIB_OFFSET 23L +# define ERR_LIB_MASK 0xFF +# define ERR_RFLAGS_OFFSET 18L +# define ERR_RFLAGS_MASK 0x1F +# define ERR_REASON_MASK 0X7FFFFF + +/* + * Reason flags are defined pre-shifted to easily combine with the reason + * number. + */ +# define ERR_RFLAG_FATAL (0x1 << ERR_RFLAGS_OFFSET) +# define ERR_RFLAG_COMMON (0x2 << ERR_RFLAGS_OFFSET) + +# define ERR_SYSTEM_ERROR(errcode) (((errcode) & ERR_SYSTEM_FLAG) != 0) + +static ossl_unused ossl_inline int ERR_GET_LIB(unsigned long errcode) +{ + if (ERR_SYSTEM_ERROR(errcode)) + return ERR_LIB_SYS; + return (errcode >> ERR_LIB_OFFSET) & ERR_LIB_MASK; +} + +static ossl_unused ossl_inline int ERR_GET_RFLAGS(unsigned long errcode) +{ + if (ERR_SYSTEM_ERROR(errcode)) + return 0; + return errcode & (ERR_RFLAGS_MASK << ERR_RFLAGS_OFFSET); +} + +static ossl_unused ossl_inline int ERR_GET_REASON(unsigned long errcode) +{ + if (ERR_SYSTEM_ERROR(errcode)) + return errcode & ERR_SYSTEM_MASK; + return errcode & ERR_REASON_MASK; +} + +static ossl_unused ossl_inline int ERR_FATAL_ERROR(unsigned long errcode) +{ + return (ERR_GET_RFLAGS(errcode) & ERR_RFLAG_FATAL) != 0; +} + +static ossl_unused ossl_inline int ERR_COMMON_ERROR(unsigned long errcode) +{ + return (ERR_GET_RFLAGS(errcode) & ERR_RFLAG_COMMON) != 0; +} + +/* + * ERR_PACK is a helper macro to properly pack OpenSSL error codes and may + * only be used for that purpose. System errors are packed internally. + * ERR_PACK takes reason flags and reason code combined in |reason|. + * ERR_PACK ignores |func|, that parameter is just legacy from pre-3.0 OpenSSL. + */ +# define ERR_PACK(lib,func,reason) \ + ( (((unsigned long)(lib) & ERR_LIB_MASK ) << ERR_LIB_OFFSET) | \ + (((unsigned long)(reason) & ERR_REASON_MASK)) ) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SYS_F_FOPEN 0 +# define SYS_F_CONNECT 0 +# define SYS_F_GETSERVBYNAME 0 +# define SYS_F_SOCKET 0 +# define SYS_F_IOCTLSOCKET 0 +# define SYS_F_BIND 0 +# define SYS_F_LISTEN 0 +# define SYS_F_ACCEPT 0 +# define SYS_F_WSASTARTUP 0 +# define SYS_F_OPENDIR 0 +# define SYS_F_FREAD 0 +# define SYS_F_GETADDRINFO 0 +# define SYS_F_GETNAMEINFO 0 +# define SYS_F_SETSOCKOPT 0 +# define SYS_F_GETSOCKOPT 0 +# define SYS_F_GETSOCKNAME 0 +# define SYS_F_GETHOSTBYNAME 0 +# define SYS_F_FFLUSH 0 +# define SYS_F_OPEN 0 +# define SYS_F_CLOSE 0 +# define SYS_F_IOCTL 0 +# define SYS_F_STAT 0 +# define SYS_F_FCNTL 0 +# define SYS_F_FSTAT 0 +# define SYS_F_SENDFILE 0 +# endif + +/* + * All ERR_R_ codes must be combined with ERR_RFLAG_COMMON. + */ + +/* "we came from here" global reason codes, range 1..255 */ +# define ERR_R_SYS_LIB (ERR_LIB_SYS/* 2 */ | ERR_RFLAG_COMMON) +# define ERR_R_BN_LIB (ERR_LIB_BN/* 3 */ | ERR_RFLAG_COMMON) +# define ERR_R_RSA_LIB (ERR_LIB_RSA/* 4 */ | ERR_RFLAG_COMMON) +# define ERR_R_DH_LIB (ERR_LIB_DH/* 5 */ | ERR_RFLAG_COMMON) +# define ERR_R_EVP_LIB (ERR_LIB_EVP/* 6 */ | ERR_RFLAG_COMMON) +# define ERR_R_BUF_LIB (ERR_LIB_BUF/* 7 */ | ERR_RFLAG_COMMON) +# define ERR_R_OBJ_LIB (ERR_LIB_OBJ/* 8 */ | ERR_RFLAG_COMMON) +# define ERR_R_PEM_LIB (ERR_LIB_PEM/* 9 */ | ERR_RFLAG_COMMON) +# define ERR_R_DSA_LIB (ERR_LIB_DSA/* 10 */ | ERR_RFLAG_COMMON) +# define ERR_R_X509_LIB (ERR_LIB_X509/* 11 */ | ERR_RFLAG_COMMON) +# define ERR_R_ASN1_LIB (ERR_LIB_ASN1/* 13 */ | ERR_RFLAG_COMMON) +# define ERR_R_CONF_LIB (ERR_LIB_CONF/* 14 */ | ERR_RFLAG_COMMON) +# define ERR_R_CRYPTO_LIB (ERR_LIB_CRYPTO/* 15 */ | ERR_RFLAG_COMMON) +# define ERR_R_EC_LIB (ERR_LIB_EC/* 16 */ | ERR_RFLAG_COMMON) +# define ERR_R_SSL_LIB (ERR_LIB_SSL/* 20 */ | ERR_RFLAG_COMMON) +# define ERR_R_BIO_LIB (ERR_LIB_BIO/* 32 */ | ERR_RFLAG_COMMON) +# define ERR_R_PKCS7_LIB (ERR_LIB_PKCS7/* 33 */ | ERR_RFLAG_COMMON) +# define ERR_R_X509V3_LIB (ERR_LIB_X509V3/* 34 */ | ERR_RFLAG_COMMON) +# define ERR_R_PKCS12_LIB (ERR_LIB_PKCS12/* 35 */ | ERR_RFLAG_COMMON) +# define ERR_R_RAND_LIB (ERR_LIB_RAND/* 36 */ | ERR_RFLAG_COMMON) +# define ERR_R_DSO_LIB (ERR_LIB_DSO/* 37 */ | ERR_RFLAG_COMMON) +# define ERR_R_ENGINE_LIB (ERR_LIB_ENGINE/* 38 */ | ERR_RFLAG_COMMON) +# define ERR_R_UI_LIB (ERR_LIB_UI/* 40 */ | ERR_RFLAG_COMMON) +# define ERR_R_ECDSA_LIB (ERR_LIB_ECDSA/* 42 */ | ERR_RFLAG_COMMON) +# define ERR_R_OSSL_STORE_LIB (ERR_LIB_OSSL_STORE/* 44 */ | ERR_RFLAG_COMMON) +# define ERR_R_CMS_LIB (ERR_LIB_CMS/* 46 */ | ERR_RFLAG_COMMON) +# define ERR_R_TS_LIB (ERR_LIB_TS/* 47 */ | ERR_RFLAG_COMMON) +# define ERR_R_CT_LIB (ERR_LIB_CT/* 50 */ | ERR_RFLAG_COMMON) +# define ERR_R_PROV_LIB (ERR_LIB_PROV/* 57 */ | ERR_RFLAG_COMMON) +# define ERR_R_ESS_LIB (ERR_LIB_ESS/* 54 */ | ERR_RFLAG_COMMON) +# define ERR_R_CMP_LIB (ERR_LIB_CMP/* 58 */ | ERR_RFLAG_COMMON) +# define ERR_R_OSSL_ENCODER_LIB (ERR_LIB_OSSL_ENCODER/* 59 */ | ERR_RFLAG_COMMON) +# define ERR_R_OSSL_DECODER_LIB (ERR_LIB_OSSL_DECODER/* 60 */ | ERR_RFLAG_COMMON) + +/* Other common error codes, range 256..2^ERR_RFLAGS_OFFSET-1 */ +# define ERR_R_FATAL (ERR_RFLAG_FATAL|ERR_RFLAG_COMMON) +# define ERR_R_MALLOC_FAILURE (256|ERR_R_FATAL) +# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (257|ERR_R_FATAL) +# define ERR_R_PASSED_NULL_PARAMETER (258|ERR_R_FATAL) +# define ERR_R_INTERNAL_ERROR (259|ERR_R_FATAL) +# define ERR_R_DISABLED (260|ERR_R_FATAL) +# define ERR_R_INIT_FAIL (261|ERR_R_FATAL) +# define ERR_R_PASSED_INVALID_ARGUMENT (262|ERR_RFLAG_COMMON) +# define ERR_R_OPERATION_FAIL (263|ERR_R_FATAL) +# define ERR_R_INVALID_PROVIDER_FUNCTIONS (264|ERR_R_FATAL) +# define ERR_R_INTERRUPTED_OR_CANCELLED (265|ERR_RFLAG_COMMON) +# define ERR_R_NESTED_ASN1_ERROR (266|ERR_RFLAG_COMMON) +# define ERR_R_MISSING_ASN1_EOS (267|ERR_RFLAG_COMMON) +# define ERR_R_UNSUPPORTED (268|ERR_RFLAG_COMMON) +# define ERR_R_FETCH_FAILED (269|ERR_RFLAG_COMMON) +# define ERR_R_INVALID_PROPERTY_DEFINITION (270|ERR_RFLAG_COMMON) +# define ERR_R_UNABLE_TO_GET_READ_LOCK (271|ERR_R_FATAL) +# define ERR_R_UNABLE_TO_GET_WRITE_LOCK (272|ERR_R_FATAL) + +typedef struct ERR_string_data_st { + unsigned long error; + const char *string; +} ERR_STRING_DATA; + +DEFINE_LHASH_OF_INTERNAL(ERR_STRING_DATA); +#define lh_ERR_STRING_DATA_new(hfn, cmp) ((LHASH_OF(ERR_STRING_DATA) *)OPENSSL_LH_set_thunks(OPENSSL_LH_new(ossl_check_ERR_STRING_DATA_lh_hashfunc_type(hfn), ossl_check_ERR_STRING_DATA_lh_compfunc_type(cmp)), lh_ERR_STRING_DATA_hash_thunk, lh_ERR_STRING_DATA_comp_thunk, lh_ERR_STRING_DATA_doall_thunk, lh_ERR_STRING_DATA_doall_arg_thunk)) +#define lh_ERR_STRING_DATA_free(lh) OPENSSL_LH_free(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_flush(lh) OPENSSL_LH_flush(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_insert(lh, ptr) ((ERR_STRING_DATA *)OPENSSL_LH_insert(ossl_check_ERR_STRING_DATA_lh_type(lh), ossl_check_ERR_STRING_DATA_lh_plain_type(ptr))) +#define lh_ERR_STRING_DATA_delete(lh, ptr) ((ERR_STRING_DATA *)OPENSSL_LH_delete(ossl_check_ERR_STRING_DATA_lh_type(lh), ossl_check_const_ERR_STRING_DATA_lh_plain_type(ptr))) +#define lh_ERR_STRING_DATA_retrieve(lh, ptr) ((ERR_STRING_DATA *)OPENSSL_LH_retrieve(ossl_check_ERR_STRING_DATA_lh_type(lh), ossl_check_const_ERR_STRING_DATA_lh_plain_type(ptr))) +#define lh_ERR_STRING_DATA_error(lh) OPENSSL_LH_error(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_num_items(lh) OPENSSL_LH_num_items(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_node_stats_bio(lh, out) OPENSSL_LH_node_stats_bio(ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) +#define lh_ERR_STRING_DATA_node_usage_stats_bio(lh, out) OPENSSL_LH_node_usage_stats_bio(ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) +#define lh_ERR_STRING_DATA_stats_bio(lh, out) OPENSSL_LH_stats_bio(ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) +#define lh_ERR_STRING_DATA_get_down_load(lh) OPENSSL_LH_get_down_load(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_set_down_load(lh, dl) OPENSSL_LH_set_down_load(ossl_check_ERR_STRING_DATA_lh_type(lh), dl) +#define lh_ERR_STRING_DATA_doall(lh, dfn) OPENSSL_LH_doall(ossl_check_ERR_STRING_DATA_lh_type(lh), ossl_check_ERR_STRING_DATA_lh_doallfunc_type(dfn)) + + +/* 12 lines and some on an 80 column terminal */ +#define ERR_MAX_DATA_SIZE 1024 + +/* Building blocks */ +void ERR_new(void); +void ERR_set_debug(const char *file, int line, const char *func); +void ERR_set_error(int lib, int reason, const char *fmt, ...); +void ERR_vset_error(int lib, int reason, const char *fmt, va_list args); + +/* Main error raising functions */ +# define ERR_raise(lib, reason) ERR_raise_data((lib),(reason),NULL) +# define ERR_raise_data \ + (ERR_new(), \ + ERR_set_debug(OPENSSL_FILE,OPENSSL_LINE,OPENSSL_FUNC), \ + ERR_set_error) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* Backward compatibility */ +# define ERR_put_error(lib, func, reason, file, line) \ + (ERR_new(), \ + ERR_set_debug((file), (line), OPENSSL_FUNC), \ + ERR_set_error((lib), (reason), NULL)) +# endif + +void ERR_set_error_data(char *data, int flags); + +unsigned long ERR_get_error(void); +unsigned long ERR_get_error_all(const char **file, int *line, + const char **func, + const char **data, int *flags); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +unsigned long ERR_get_error_line(const char **file, int *line); +OSSL_DEPRECATEDIN_3_0 +unsigned long ERR_get_error_line_data(const char **file, int *line, + const char **data, int *flags); +#endif +unsigned long ERR_peek_error(void); +unsigned long ERR_peek_error_line(const char **file, int *line); +unsigned long ERR_peek_error_func(const char **func); +unsigned long ERR_peek_error_data(const char **data, int *flags); +unsigned long ERR_peek_error_all(const char **file, int *line, + const char **func, + const char **data, int *flags); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +unsigned long ERR_peek_error_line_data(const char **file, int *line, + const char **data, int *flags); +# endif +unsigned long ERR_peek_last_error(void); +unsigned long ERR_peek_last_error_line(const char **file, int *line); +unsigned long ERR_peek_last_error_func(const char **func); +unsigned long ERR_peek_last_error_data(const char **data, int *flags); +unsigned long ERR_peek_last_error_all(const char **file, int *line, + const char **func, + const char **data, int *flags); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +unsigned long ERR_peek_last_error_line_data(const char **file, int *line, + const char **data, int *flags); +# endif + +void ERR_clear_error(void); + +char *ERR_error_string(unsigned long e, char *buf); +void ERR_error_string_n(unsigned long e, char *buf, size_t len); +const char *ERR_lib_error_string(unsigned long e); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 const char *ERR_func_error_string(unsigned long e); +# endif +const char *ERR_reason_error_string(unsigned long e); + +void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u), + void *u); +# ifndef OPENSSL_NO_STDIO +void ERR_print_errors_fp(FILE *fp); +# endif +void ERR_print_errors(BIO *bp); + +void ERR_add_error_data(int num, ...); +void ERR_add_error_vdata(int num, va_list args); +void ERR_add_error_txt(const char *sepr, const char *txt); +void ERR_add_error_mem_bio(const char *sep, BIO *bio); + +int ERR_load_strings(int lib, ERR_STRING_DATA *str); +int ERR_load_strings_const(const ERR_STRING_DATA *str); +int ERR_unload_strings(int lib, ERR_STRING_DATA *str); + +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define ERR_load_crypto_strings() \ + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) +# define ERR_free_strings() while(0) continue +#endif +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 void ERR_remove_thread_state(void *); +#endif +#ifndef OPENSSL_NO_DEPRECATED_1_0_0 +OSSL_DEPRECATEDIN_1_0_0 void ERR_remove_state(unsigned long pid); +#endif +#ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 ERR_STATE *ERR_get_state(void); +#endif + +int ERR_get_next_error_library(void); + +int ERR_set_mark(void); +int ERR_pop_to_mark(void); +int ERR_clear_last_mark(void); +int ERR_count_to_mark(void); +int ERR_pop(void); + +ERR_STATE *OSSL_ERR_STATE_new(void); +void OSSL_ERR_STATE_save(ERR_STATE *es); +void OSSL_ERR_STATE_save_to_mark(ERR_STATE *es); +void OSSL_ERR_STATE_restore(const ERR_STATE *es); +void OSSL_ERR_STATE_free(ERR_STATE *es); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ess.h b/illumos-x86_64/usr/include/openssl-3/ess.h new file mode 100644 index 00000000..4055bebb --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ess.h @@ -0,0 +1,128 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/ess.h.in + * + * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_ESS_H +# define OPENSSL_ESS_H +# pragma once + +# include + +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + + +typedef struct ESS_issuer_serial ESS_ISSUER_SERIAL; +typedef struct ESS_cert_id ESS_CERT_ID; +typedef struct ESS_signing_cert ESS_SIGNING_CERT; + +SKM_DEFINE_STACK_OF_INTERNAL(ESS_CERT_ID, ESS_CERT_ID, ESS_CERT_ID) +#define sk_ESS_CERT_ID_num(sk) OPENSSL_sk_num(ossl_check_const_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_value(sk, idx) ((ESS_CERT_ID *)OPENSSL_sk_value(ossl_check_const_ESS_CERT_ID_sk_type(sk), (idx))) +#define sk_ESS_CERT_ID_new(cmp) ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new(ossl_check_ESS_CERT_ID_compfunc_type(cmp))) +#define sk_ESS_CERT_ID_new_null() ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new_null()) +#define sk_ESS_CERT_ID_new_reserve(cmp, n) ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new_reserve(ossl_check_ESS_CERT_ID_compfunc_type(cmp), (n))) +#define sk_ESS_CERT_ID_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ESS_CERT_ID_sk_type(sk), (n)) +#define sk_ESS_CERT_ID_free(sk) OPENSSL_sk_free(ossl_check_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_zero(sk) OPENSSL_sk_zero(ossl_check_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_delete(sk, i) ((ESS_CERT_ID *)OPENSSL_sk_delete(ossl_check_ESS_CERT_ID_sk_type(sk), (i))) +#define sk_ESS_CERT_ID_delete_ptr(sk, ptr) ((ESS_CERT_ID *)OPENSSL_sk_delete_ptr(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr))) +#define sk_ESS_CERT_ID_push(sk, ptr) OPENSSL_sk_push(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr)) +#define sk_ESS_CERT_ID_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr)) +#define sk_ESS_CERT_ID_pop(sk) ((ESS_CERT_ID *)OPENSSL_sk_pop(ossl_check_ESS_CERT_ID_sk_type(sk))) +#define sk_ESS_CERT_ID_shift(sk) ((ESS_CERT_ID *)OPENSSL_sk_shift(ossl_check_ESS_CERT_ID_sk_type(sk))) +#define sk_ESS_CERT_ID_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ESS_CERT_ID_sk_type(sk),ossl_check_ESS_CERT_ID_freefunc_type(freefunc)) +#define sk_ESS_CERT_ID_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr), (idx)) +#define sk_ESS_CERT_ID_set(sk, idx, ptr) ((ESS_CERT_ID *)OPENSSL_sk_set(ossl_check_ESS_CERT_ID_sk_type(sk), (idx), ossl_check_ESS_CERT_ID_type(ptr))) +#define sk_ESS_CERT_ID_find(sk, ptr) OPENSSL_sk_find(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr)) +#define sk_ESS_CERT_ID_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr)) +#define sk_ESS_CERT_ID_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr), pnum) +#define sk_ESS_CERT_ID_sort(sk) OPENSSL_sk_sort(ossl_check_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_dup(sk) ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_dup(ossl_check_const_ESS_CERT_ID_sk_type(sk))) +#define sk_ESS_CERT_ID_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_deep_copy(ossl_check_const_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_copyfunc_type(copyfunc), ossl_check_ESS_CERT_ID_freefunc_type(freefunc))) +#define sk_ESS_CERT_ID_set_cmp_func(sk, cmp) ((sk_ESS_CERT_ID_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_compfunc_type(cmp))) + + + +typedef struct ESS_signing_cert_v2_st ESS_SIGNING_CERT_V2; +typedef struct ESS_cert_id_v2_st ESS_CERT_ID_V2; + +SKM_DEFINE_STACK_OF_INTERNAL(ESS_CERT_ID_V2, ESS_CERT_ID_V2, ESS_CERT_ID_V2) +#define sk_ESS_CERT_ID_V2_num(sk) OPENSSL_sk_num(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_value(sk, idx) ((ESS_CERT_ID_V2 *)OPENSSL_sk_value(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk), (idx))) +#define sk_ESS_CERT_ID_V2_new(cmp) ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new(ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp))) +#define sk_ESS_CERT_ID_V2_new_null() ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new_null()) +#define sk_ESS_CERT_ID_V2_new_reserve(cmp, n) ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new_reserve(ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp), (n))) +#define sk_ESS_CERT_ID_V2_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ESS_CERT_ID_V2_sk_type(sk), (n)) +#define sk_ESS_CERT_ID_V2_free(sk) OPENSSL_sk_free(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_zero(sk) OPENSSL_sk_zero(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_delete(sk, i) ((ESS_CERT_ID_V2 *)OPENSSL_sk_delete(ossl_check_ESS_CERT_ID_V2_sk_type(sk), (i))) +#define sk_ESS_CERT_ID_V2_delete_ptr(sk, ptr) ((ESS_CERT_ID_V2 *)OPENSSL_sk_delete_ptr(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr))) +#define sk_ESS_CERT_ID_V2_push(sk, ptr) OPENSSL_sk_push(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr)) +#define sk_ESS_CERT_ID_V2_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr)) +#define sk_ESS_CERT_ID_V2_pop(sk) ((ESS_CERT_ID_V2 *)OPENSSL_sk_pop(ossl_check_ESS_CERT_ID_V2_sk_type(sk))) +#define sk_ESS_CERT_ID_V2_shift(sk) ((ESS_CERT_ID_V2 *)OPENSSL_sk_shift(ossl_check_ESS_CERT_ID_V2_sk_type(sk))) +#define sk_ESS_CERT_ID_V2_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ESS_CERT_ID_V2_sk_type(sk),ossl_check_ESS_CERT_ID_V2_freefunc_type(freefunc)) +#define sk_ESS_CERT_ID_V2_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr), (idx)) +#define sk_ESS_CERT_ID_V2_set(sk, idx, ptr) ((ESS_CERT_ID_V2 *)OPENSSL_sk_set(ossl_check_ESS_CERT_ID_V2_sk_type(sk), (idx), ossl_check_ESS_CERT_ID_V2_type(ptr))) +#define sk_ESS_CERT_ID_V2_find(sk, ptr) OPENSSL_sk_find(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr)) +#define sk_ESS_CERT_ID_V2_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr)) +#define sk_ESS_CERT_ID_V2_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr), pnum) +#define sk_ESS_CERT_ID_V2_sort(sk) OPENSSL_sk_sort(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_dup(sk) ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_dup(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk))) +#define sk_ESS_CERT_ID_V2_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_deep_copy(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_copyfunc_type(copyfunc), ossl_check_ESS_CERT_ID_V2_freefunc_type(freefunc))) +#define sk_ESS_CERT_ID_V2_set_cmp_func(sk, cmp) ((sk_ESS_CERT_ID_V2_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp))) + + +DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_ISSUER_SERIAL) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(ESS_ISSUER_SERIAL, ESS_ISSUER_SERIAL) +DECLARE_ASN1_DUP_FUNCTION(ESS_ISSUER_SERIAL) + +DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_CERT_ID) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(ESS_CERT_ID, ESS_CERT_ID) +DECLARE_ASN1_DUP_FUNCTION(ESS_CERT_ID) + +DECLARE_ASN1_FUNCTIONS(ESS_SIGNING_CERT) +DECLARE_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT) + +DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_CERT_ID_V2) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(ESS_CERT_ID_V2, ESS_CERT_ID_V2) +DECLARE_ASN1_DUP_FUNCTION(ESS_CERT_ID_V2) + +DECLARE_ASN1_FUNCTIONS(ESS_SIGNING_CERT_V2) +DECLARE_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT_V2) + +ESS_SIGNING_CERT *OSSL_ESS_signing_cert_new_init(const X509 *signcert, + const STACK_OF(X509) *certs, + int set_issuer_serial); +ESS_SIGNING_CERT_V2 *OSSL_ESS_signing_cert_v2_new_init(const EVP_MD *hash_alg, + const X509 *signcert, + const + STACK_OF(X509) *certs, + int set_issuer_serial); +int OSSL_ESS_check_signing_certs(const ESS_SIGNING_CERT *ss, + const ESS_SIGNING_CERT_V2 *ssv2, + const STACK_OF(X509) *chain, + int require_signing_cert); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/esserr.h b/illumos-x86_64/usr/include/openssl-3/esserr.h new file mode 100644 index 00000000..165ce7c4 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/esserr.h @@ -0,0 +1,32 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ESSERR_H +# define OPENSSL_ESSERR_H +# pragma once + +# include +# include +# include + +/* + * ESS reason codes. + */ +# define ESS_R_EMPTY_ESS_CERT_ID_LIST 107 +# define ESS_R_ESS_CERT_DIGEST_ERROR 103 +# define ESS_R_ESS_CERT_ID_NOT_FOUND 104 +# define ESS_R_ESS_CERT_ID_WRONG_ORDER 105 +# define ESS_R_ESS_DIGEST_ALG_UNKNOWN 106 +# define ESS_R_ESS_SIGNING_CERTIFICATE_ERROR 102 +# define ESS_R_ESS_SIGNING_CERT_ADD_ERROR 100 +# define ESS_R_ESS_SIGNING_CERT_V2_ADD_ERROR 101 +# define ESS_R_MISSING_SIGNING_CERTIFICATE_ATTRIBUTE 108 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/evp.h b/illumos-x86_64/usr/include/openssl-3/evp.h new file mode 100644 index 00000000..e5da1e64 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/evp.h @@ -0,0 +1,2310 @@ +/* + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_EVP_H +# define OPENSSL_EVP_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_ENVELOPE_H +# endif + +# include + +# ifndef OPENSSL_NO_STDIO +# include +# endif + +# include +# include +# include +# include +# include +# include +# include +# include + +# define EVP_MAX_MD_SIZE 64/* longest known is SHA512 */ +# define EVP_MAX_KEY_LENGTH 64 +# define EVP_MAX_IV_LENGTH 16 +# define EVP_MAX_BLOCK_LENGTH 32 +# define EVP_MAX_AEAD_TAG_LENGTH 16 + +/* Maximum pipes in cipher pipelining */ +# define EVP_MAX_PIPES 32 + +# define PKCS5_SALT_LEN 8 +/* Default PKCS#5 iteration count */ +# define PKCS5_DEFAULT_ITER 2048 + +# include + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define EVP_PK_RSA 0x0001 +# define EVP_PK_DSA 0x0002 +# define EVP_PK_DH 0x0004 +# define EVP_PK_EC 0x0008 +# define EVP_PKT_SIGN 0x0010 +# define EVP_PKT_ENC 0x0020 +# define EVP_PKT_EXCH 0x0040 +# define EVP_PKS_RSA 0x0100 +# define EVP_PKS_DSA 0x0200 +# define EVP_PKS_EC 0x0400 +# endif + +# define EVP_PKEY_NONE NID_undef +# define EVP_PKEY_RSA NID_rsaEncryption +# define EVP_PKEY_RSA2 NID_rsa +# define EVP_PKEY_RSA_PSS NID_rsassaPss +# define EVP_PKEY_DSA NID_dsa +# define EVP_PKEY_DSA1 NID_dsa_2 +# define EVP_PKEY_DSA2 NID_dsaWithSHA +# define EVP_PKEY_DSA3 NID_dsaWithSHA1 +# define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 +# define EVP_PKEY_DH NID_dhKeyAgreement +# define EVP_PKEY_DHX NID_dhpublicnumber +# define EVP_PKEY_EC NID_X9_62_id_ecPublicKey +# define EVP_PKEY_SM2 NID_sm2 +# define EVP_PKEY_HMAC NID_hmac +# define EVP_PKEY_CMAC NID_cmac +# define EVP_PKEY_SCRYPT NID_id_scrypt +# define EVP_PKEY_TLS1_PRF NID_tls1_prf +# define EVP_PKEY_HKDF NID_hkdf +# define EVP_PKEY_POLY1305 NID_poly1305 +# define EVP_PKEY_SIPHASH NID_siphash +# define EVP_PKEY_X25519 NID_X25519 +# define EVP_PKEY_ED25519 NID_ED25519 +# define EVP_PKEY_X448 NID_X448 +# define EVP_PKEY_ED448 NID_ED448 +# define EVP_PKEY_ML_DSA_44 NID_ML_DSA_44 +# define EVP_PKEY_ML_DSA_65 NID_ML_DSA_65 +# define EVP_PKEY_ML_DSA_87 NID_ML_DSA_87 +# define EVP_PKEY_SLH_DSA_SHA2_128S NID_SLH_DSA_SHA2_128s +# define EVP_PKEY_SLH_DSA_SHA2_128F NID_SLH_DSA_SHA2_128f +# define EVP_PKEY_SLH_DSA_SHA2_192S NID_SLH_DSA_SHA2_192s +# define EVP_PKEY_SLH_DSA_SHA2_192F NID_SLH_DSA_SHA2_192f +# define EVP_PKEY_SLH_DSA_SHA2_256S NID_SLH_DSA_SHA2_256s +# define EVP_PKEY_SLH_DSA_SHA2_256F NID_SLH_DSA_SHA2_256f +# define EVP_PKEY_SLH_DSA_SHAKE_128S NID_SLH_DSA_SHAKE_128s +# define EVP_PKEY_SLH_DSA_SHAKE_128F NID_SLH_DSA_SHAKE_128f +# define EVP_PKEY_SLH_DSA_SHAKE_192S NID_SLH_DSA_SHAKE_192s +# define EVP_PKEY_SLH_DSA_SHAKE_192F NID_SLH_DSA_SHAKE_192f +# define EVP_PKEY_SLH_DSA_SHAKE_256S NID_SLH_DSA_SHAKE_256s +# define EVP_PKEY_SLH_DSA_SHAKE_256F NID_SLH_DSA_SHAKE_256f + +/* Special indicator that the object is uniquely provider side */ +# define EVP_PKEY_KEYMGMT -1 + +/* Easy to use macros for EVP_PKEY related selections */ +# define EVP_PKEY_KEY_PARAMETERS \ + ( OSSL_KEYMGMT_SELECT_ALL_PARAMETERS ) +# define EVP_PKEY_PRIVATE_KEY \ + ( EVP_PKEY_KEY_PARAMETERS | OSSL_KEYMGMT_SELECT_PRIVATE_KEY ) +# define EVP_PKEY_PUBLIC_KEY \ + ( EVP_PKEY_KEY_PARAMETERS | OSSL_KEYMGMT_SELECT_PUBLIC_KEY ) +# define EVP_PKEY_KEYPAIR \ + ( EVP_PKEY_PUBLIC_KEY | OSSL_KEYMGMT_SELECT_PRIVATE_KEY ) + +#ifdef __cplusplus +extern "C" { +#endif + +int EVP_set_default_properties(OSSL_LIB_CTX *libctx, const char *propq); +char *EVP_get1_default_properties(OSSL_LIB_CTX *libctx); +int EVP_default_properties_is_fips_enabled(OSSL_LIB_CTX *libctx); +int EVP_default_properties_enable_fips(OSSL_LIB_CTX *libctx, int enable); + +# define EVP_PKEY_MO_SIGN 0x0001 +# define EVP_PKEY_MO_VERIFY 0x0002 +# define EVP_PKEY_MO_ENCRYPT 0x0004 +# define EVP_PKEY_MO_DECRYPT 0x0008 + +# ifndef EVP_MD +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type); +OSSL_DEPRECATEDIN_3_0 EVP_MD *EVP_MD_meth_dup(const EVP_MD *md); +OSSL_DEPRECATEDIN_3_0 void EVP_MD_meth_free(EVP_MD *md); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx, + const void *data, + size_t count)); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx, + unsigned char *md)); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to, + const EVP_MD_CTX *from)); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 +int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd, + int p1, void *p2)); +OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_input_blocksize(const EVP_MD *md); +OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_result_size(const EVP_MD *md); +OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_app_datasize(const EVP_MD *md); +OSSL_DEPRECATEDIN_3_0 unsigned long EVP_MD_meth_get_flags(const EVP_MD *md); +OSSL_DEPRECATEDIN_3_0 +int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 +int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx, + const void *data, size_t count); +OSSL_DEPRECATEDIN_3_0 +int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx, + unsigned char *md); +OSSL_DEPRECATEDIN_3_0 +int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to, + const EVP_MD_CTX *from); +OSSL_DEPRECATEDIN_3_0 +int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 +int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, + int p1, void *p2); +# endif +/* digest can only handle a single block */ +# define EVP_MD_FLAG_ONESHOT 0x0001 + +/* digest is extensible-output function, XOF */ +# define EVP_MD_FLAG_XOF 0x0002 + +/* DigestAlgorithmIdentifier flags... */ + +# define EVP_MD_FLAG_DIGALGID_MASK 0x0018 + +/* NULL or absent parameter accepted. Use NULL */ + +# define EVP_MD_FLAG_DIGALGID_NULL 0x0000 + +/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */ + +# define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008 + +/* Custom handling via ctrl */ + +# define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018 + +/* Note if suitable for use in FIPS mode */ +# define EVP_MD_FLAG_FIPS 0x0400 + +/* Digest ctrls */ + +# define EVP_MD_CTRL_DIGALGID 0x1 +# define EVP_MD_CTRL_MICALG 0x2 +# define EVP_MD_CTRL_XOF_LEN 0x3 +# define EVP_MD_CTRL_TLSTREE 0x4 + +/* Minimum Algorithm specific ctrl value */ + +# define EVP_MD_CTRL_ALG_CTRL 0x1000 + +# endif /* !EVP_MD */ + +/* values for EVP_MD_CTX flags */ + +# define EVP_MD_CTX_FLAG_ONESHOT 0x0001/* digest update will be + * called once only */ +# define EVP_MD_CTX_FLAG_CLEANED 0x0002/* context has already been + * cleaned */ +# define EVP_MD_CTX_FLAG_REUSE 0x0004/* Don't free up ctx->md_data + * in EVP_MD_CTX_reset */ +/* + * FIPS and pad options are ignored in 1.0.0, definitions are here so we + * don't accidentally reuse the values for other purposes. + */ + +/* This flag has no effect from openssl-3.0 onwards */ +# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008 + +/* + * The following PAD options are also currently ignored in 1.0.0, digest + * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*() + * instead. + */ +# define EVP_MD_CTX_FLAG_PAD_MASK 0xF0/* RSA mode to use */ +# define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00/* PKCS#1 v1.5 mode */ +# define EVP_MD_CTX_FLAG_PAD_X931 0x10/* X9.31 mode */ +# define EVP_MD_CTX_FLAG_PAD_PSS 0x20/* PSS mode */ + +# define EVP_MD_CTX_FLAG_NO_INIT 0x0100/* Don't initialize md_data */ +/* + * Some functions such as EVP_DigestSign only finalise copies of internal + * contexts so additional data can be included after the finalisation call. + * This is inefficient if this functionality is not required: it is disabled + * if the following flag is set. + */ +# define EVP_MD_CTX_FLAG_FINALISE 0x0200 +/* NOTE: 0x0400 and 0x0800 are reserved for internal usage */ + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len); +OSSL_DEPRECATEDIN_3_0 +EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher); +OSSL_DEPRECATEDIN_3_0 +void EVP_CIPHER_meth_free(EVP_CIPHER *cipher); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher, + int (*init) (EVP_CIPHER_CTX *ctx, + const unsigned char *key, + const unsigned char *iv, + int enc)); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher, + int (*do_cipher) (EVP_CIPHER_CTX *ctx, + unsigned char *out, + const unsigned char *in, + size_t inl)); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher, + int (*cleanup) (EVP_CIPHER_CTX *)); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher, + int (*set_asn1_parameters) (EVP_CIPHER_CTX *, + ASN1_TYPE *)); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher, + int (*get_asn1_parameters) (EVP_CIPHER_CTX *, + ASN1_TYPE *)); +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher, + int (*ctrl) (EVP_CIPHER_CTX *, int type, + int arg, void *ptr)); +OSSL_DEPRECATEDIN_3_0 int +(*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx, + const unsigned char *key, + const unsigned char *iv, + int enc); +OSSL_DEPRECATEDIN_3_0 int +(*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx, + unsigned char *out, + const unsigned char *in, + size_t inl); +OSSL_DEPRECATEDIN_3_0 int +(*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *); +OSSL_DEPRECATEDIN_3_0 int +(*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, + ASN1_TYPE *); +OSSL_DEPRECATEDIN_3_0 int +(*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, + ASN1_TYPE *); +OSSL_DEPRECATEDIN_3_0 int +(*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, int type, + int arg, void *ptr); +# endif + +/* Values for cipher flags */ + +/* Modes for ciphers */ + +# define EVP_CIPH_STREAM_CIPHER 0x0 +# define EVP_CIPH_ECB_MODE 0x1 +# define EVP_CIPH_CBC_MODE 0x2 +# define EVP_CIPH_CFB_MODE 0x3 +# define EVP_CIPH_OFB_MODE 0x4 +# define EVP_CIPH_CTR_MODE 0x5 +# define EVP_CIPH_GCM_MODE 0x6 +# define EVP_CIPH_CCM_MODE 0x7 +# define EVP_CIPH_XTS_MODE 0x10001 +# define EVP_CIPH_WRAP_MODE 0x10002 +# define EVP_CIPH_OCB_MODE 0x10003 +# define EVP_CIPH_SIV_MODE 0x10004 +# define EVP_CIPH_GCM_SIV_MODE 0x10005 +# define EVP_CIPH_MODE 0xF0007 +/* Set if variable length cipher */ +# define EVP_CIPH_VARIABLE_LENGTH 0x8 +/* Set if the iv handling should be done by the cipher itself */ +# define EVP_CIPH_CUSTOM_IV 0x10 +/* Set if the cipher's init() function should be called if key is NULL */ +# define EVP_CIPH_ALWAYS_CALL_INIT 0x20 +/* Call ctrl() to init cipher parameters */ +# define EVP_CIPH_CTRL_INIT 0x40 +/* Don't use standard key length function */ +# define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 +/* Don't use standard block padding */ +# define EVP_CIPH_NO_PADDING 0x100 +/* cipher handles random key generation */ +# define EVP_CIPH_RAND_KEY 0x200 +/* cipher has its own additional copying logic */ +# define EVP_CIPH_CUSTOM_COPY 0x400 +/* Don't use standard iv length function */ +# define EVP_CIPH_CUSTOM_IV_LENGTH 0x800 +/* Legacy and no longer relevant: Allow use default ASN1 get/set iv */ +# define EVP_CIPH_FLAG_DEFAULT_ASN1 0 +/* Free: 0x1000 */ +/* Buffer length in bits not bytes: CFB1 mode only */ +# define EVP_CIPH_FLAG_LENGTH_BITS 0x2000 +/* Deprecated FIPS flag: was 0x4000 */ +# define EVP_CIPH_FLAG_FIPS 0 +/* Deprecated FIPS flag: was 0x8000 */ +# define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0 + +/* + * Cipher handles any and all padding logic as well as finalisation. + */ +# define EVP_CIPH_FLAG_CTS 0x4000 +# define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000 +# define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 +# define EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000 +/* Cipher can handle pipeline operations */ +# define EVP_CIPH_FLAG_PIPELINE 0X800000 +/* For provider implementations that handle ASN1 get/set param themselves */ +# define EVP_CIPH_FLAG_CUSTOM_ASN1 0x1000000 +/* For ciphers generating unprotected CMS attributes */ +# define EVP_CIPH_FLAG_CIPHER_WITH_MAC 0x2000000 +/* For supplementary wrap cipher support */ +# define EVP_CIPH_FLAG_GET_WRAP_CIPHER 0x4000000 +# define EVP_CIPH_FLAG_INVERSE_CIPHER 0x8000000 + +/* + * Cipher context flag to indicate we can handle wrap mode: if allowed in + * older applications it could overflow buffers. + */ + +# define EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 0x1 + +/* ctrl() values */ + +# define EVP_CTRL_INIT 0x0 +# define EVP_CTRL_SET_KEY_LENGTH 0x1 +# define EVP_CTRL_GET_RC2_KEY_BITS 0x2 +# define EVP_CTRL_SET_RC2_KEY_BITS 0x3 +# define EVP_CTRL_GET_RC5_ROUNDS 0x4 +# define EVP_CTRL_SET_RC5_ROUNDS 0x5 +# define EVP_CTRL_RAND_KEY 0x6 +# define EVP_CTRL_PBE_PRF_NID 0x7 +# define EVP_CTRL_COPY 0x8 +# define EVP_CTRL_AEAD_SET_IVLEN 0x9 +# define EVP_CTRL_AEAD_GET_TAG 0x10 +# define EVP_CTRL_AEAD_SET_TAG 0x11 +# define EVP_CTRL_AEAD_SET_IV_FIXED 0x12 +# define EVP_CTRL_GCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN +# define EVP_CTRL_GCM_GET_TAG EVP_CTRL_AEAD_GET_TAG +# define EVP_CTRL_GCM_SET_TAG EVP_CTRL_AEAD_SET_TAG +# define EVP_CTRL_GCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED +# define EVP_CTRL_GCM_IV_GEN 0x13 +# define EVP_CTRL_CCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN +# define EVP_CTRL_CCM_GET_TAG EVP_CTRL_AEAD_GET_TAG +# define EVP_CTRL_CCM_SET_TAG EVP_CTRL_AEAD_SET_TAG +# define EVP_CTRL_CCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED +# define EVP_CTRL_CCM_SET_L 0x14 +# define EVP_CTRL_CCM_SET_MSGLEN 0x15 +/* + * AEAD cipher deduces payload length and returns number of bytes required to + * store MAC and eventual padding. Subsequent call to EVP_Cipher even + * appends/verifies MAC. + */ +# define EVP_CTRL_AEAD_TLS1_AAD 0x16 +/* Used by composite AEAD ciphers, no-op in GCM, CCM... */ +# define EVP_CTRL_AEAD_SET_MAC_KEY 0x17 +/* Set the GCM invocation field, decrypt only */ +# define EVP_CTRL_GCM_SET_IV_INV 0x18 + +# define EVP_CTRL_TLS1_1_MULTIBLOCK_AAD 0x19 +# define EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT 0x1a +# define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b +# define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c + +# define EVP_CTRL_SSL3_MASTER_SECRET 0x1d + +/* EVP_CTRL_SET_SBOX takes the char * specifying S-boxes */ +# define EVP_CTRL_SET_SBOX 0x1e +/* + * EVP_CTRL_SBOX_USED takes a 'size_t' and 'char *', pointing at a + * pre-allocated buffer with specified size + */ +# define EVP_CTRL_SBOX_USED 0x1f +/* EVP_CTRL_KEY_MESH takes 'size_t' number of bytes to mesh the key after, + * 0 switches meshing off + */ +# define EVP_CTRL_KEY_MESH 0x20 +/* EVP_CTRL_BLOCK_PADDING_MODE takes the padding mode */ +# define EVP_CTRL_BLOCK_PADDING_MODE 0x21 + +/* Set the output buffers to use for a pipelined operation */ +# define EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS 0x22 +/* Set the input buffers to use for a pipelined operation */ +# define EVP_CTRL_SET_PIPELINE_INPUT_BUFS 0x23 +/* Set the input buffer lengths to use for a pipelined operation */ +# define EVP_CTRL_SET_PIPELINE_INPUT_LENS 0x24 +/* Get the IV length used by the cipher */ +# define EVP_CTRL_GET_IVLEN 0x25 +/* 0x26 is unused */ +/* Tell the cipher it's doing a speed test (SIV disallows multiple ops) */ +# define EVP_CTRL_SET_SPEED 0x27 +/* Get the unprotectedAttrs from cipher ctx */ +# define EVP_CTRL_PROCESS_UNPROTECTED 0x28 +/* Get the supplementary wrap cipher */ +#define EVP_CTRL_GET_WRAP_CIPHER 0x29 +/* TLSTREE key diversification */ +#define EVP_CTRL_TLSTREE 0x2A + +/* Padding modes */ +#define EVP_PADDING_PKCS7 1 +#define EVP_PADDING_ISO7816_4 2 +#define EVP_PADDING_ANSI923 3 +#define EVP_PADDING_ISO10126 4 +#define EVP_PADDING_ZERO 5 + +/* RFC 5246 defines additional data to be 13 bytes in length */ +# define EVP_AEAD_TLS1_AAD_LEN 13 + +typedef struct { + unsigned char *out; + const unsigned char *inp; + size_t len; + unsigned int interleave; +} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM; + +/* GCM TLS constants */ +/* Length of fixed part of IV derived from PRF */ +# define EVP_GCM_TLS_FIXED_IV_LEN 4 +/* Length of explicit part of IV part of TLS records */ +# define EVP_GCM_TLS_EXPLICIT_IV_LEN 8 +/* Length of tag for TLS */ +# define EVP_GCM_TLS_TAG_LEN 16 + +/* CCM TLS constants */ +/* Length of fixed part of IV derived from PRF */ +# define EVP_CCM_TLS_FIXED_IV_LEN 4 +/* Length of explicit part of IV part of TLS records */ +# define EVP_CCM_TLS_EXPLICIT_IV_LEN 8 +/* Total length of CCM IV length for TLS */ +# define EVP_CCM_TLS_IV_LEN 12 +/* Length of tag for TLS */ +# define EVP_CCM_TLS_TAG_LEN 16 +/* Length of CCM8 tag for TLS */ +# define EVP_CCM8_TLS_TAG_LEN 8 + +/* Length of tag for TLS */ +# define EVP_CHACHAPOLY_TLS_TAG_LEN 16 + +typedef struct evp_cipher_info_st { + const EVP_CIPHER *cipher; + unsigned char iv[EVP_MAX_IV_LENGTH]; +} EVP_CIPHER_INFO; + + +/* Password based encryption function */ +typedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass, + int passlen, ASN1_TYPE *param, + const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); + +typedef int (EVP_PBE_KEYGEN_EX) (EVP_CIPHER_CTX *ctx, const char *pass, + int passlen, ASN1_TYPE *param, + const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de, OSSL_LIB_CTX *libctx, const char *propq); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ + (rsa)) +# endif + +# ifndef OPENSSL_NO_DSA +# define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ + (dsa)) +# endif + +# if !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_DEPRECATED_3_0) +# define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,(dh)) +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_EC +# define EVP_PKEY_assign_EC_KEY(pkey,eckey) \ + EVP_PKEY_assign((pkey), EVP_PKEY_EC, (eckey)) +# endif +# endif +# ifndef OPENSSL_NO_SIPHASH +# define EVP_PKEY_assign_SIPHASH(pkey,shkey) EVP_PKEY_assign((pkey),\ + EVP_PKEY_SIPHASH,(shkey)) +# endif + +# ifndef OPENSSL_NO_POLY1305 +# define EVP_PKEY_assign_POLY1305(pkey,polykey) EVP_PKEY_assign((pkey),\ + EVP_PKEY_POLY1305,(polykey)) +# endif + +/* Add some extra combinations */ +# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) +# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) +# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) +# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) + +int EVP_MD_get_type(const EVP_MD *md); +# define EVP_MD_type EVP_MD_get_type +# define EVP_MD_nid EVP_MD_get_type +const char *EVP_MD_get0_name(const EVP_MD *md); +# define EVP_MD_name EVP_MD_get0_name +const char *EVP_MD_get0_description(const EVP_MD *md); +int EVP_MD_is_a(const EVP_MD *md, const char *name); +int EVP_MD_names_do_all(const EVP_MD *md, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PROVIDER *EVP_MD_get0_provider(const EVP_MD *md); +int EVP_MD_get_pkey_type(const EVP_MD *md); +# define EVP_MD_pkey_type EVP_MD_get_pkey_type +int EVP_MD_get_size(const EVP_MD *md); +# define EVP_MD_size EVP_MD_get_size +int EVP_MD_get_block_size(const EVP_MD *md); +# define EVP_MD_block_size EVP_MD_get_block_size +unsigned long EVP_MD_get_flags(const EVP_MD *md); +# define EVP_MD_flags EVP_MD_get_flags +int EVP_MD_xof(const EVP_MD *md); + +const EVP_MD *EVP_MD_CTX_get0_md(const EVP_MD_CTX *ctx); +EVP_MD *EVP_MD_CTX_get1_md(EVP_MD_CTX *ctx); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 +int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx, + const void *data, size_t count); +OSSL_DEPRECATEDIN_3_0 +void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx, + int (*update) (EVP_MD_CTX *ctx, + const void *data, size_t count)); +# endif +int EVP_MD_CTX_get_size_ex(const EVP_MD_CTX *ctx); + +# define EVP_MD_CTX_get0_name(e) EVP_MD_get0_name(EVP_MD_CTX_get0_md(e)) +# define EVP_MD_CTX_get_size(e) EVP_MD_CTX_get_size_ex(e) +# define EVP_MD_CTX_size EVP_MD_CTX_get_size_ex +# define EVP_MD_CTX_get_block_size(e) EVP_MD_get_block_size(EVP_MD_CTX_get0_md(e)) +# define EVP_MD_CTX_block_size EVP_MD_CTX_get_block_size +# define EVP_MD_CTX_get_type(e) EVP_MD_get_type(EVP_MD_CTX_get0_md(e)) +# define EVP_MD_CTX_type EVP_MD_CTX_get_type +EVP_PKEY_CTX *EVP_MD_CTX_get_pkey_ctx(const EVP_MD_CTX *ctx); +# define EVP_MD_CTX_pkey_ctx EVP_MD_CTX_get_pkey_ctx +void EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx); +void *EVP_MD_CTX_get0_md_data(const EVP_MD_CTX *ctx); +# define EVP_MD_CTX_md_data EVP_MD_CTX_get0_md_data + +int EVP_CIPHER_get_nid(const EVP_CIPHER *cipher); +# define EVP_CIPHER_nid EVP_CIPHER_get_nid +const char *EVP_CIPHER_get0_name(const EVP_CIPHER *cipher); +# define EVP_CIPHER_name EVP_CIPHER_get0_name +const char *EVP_CIPHER_get0_description(const EVP_CIPHER *cipher); +int EVP_CIPHER_is_a(const EVP_CIPHER *cipher, const char *name); +int EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PROVIDER *EVP_CIPHER_get0_provider(const EVP_CIPHER *cipher); +int EVP_CIPHER_get_block_size(const EVP_CIPHER *cipher); +# define EVP_CIPHER_block_size EVP_CIPHER_get_block_size +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher); +# endif +int EVP_CIPHER_get_key_length(const EVP_CIPHER *cipher); +# define EVP_CIPHER_key_length EVP_CIPHER_get_key_length +int EVP_CIPHER_get_iv_length(const EVP_CIPHER *cipher); +# define EVP_CIPHER_iv_length EVP_CIPHER_get_iv_length +unsigned long EVP_CIPHER_get_flags(const EVP_CIPHER *cipher); +# define EVP_CIPHER_flags EVP_CIPHER_get_flags +int EVP_CIPHER_get_mode(const EVP_CIPHER *cipher); +# define EVP_CIPHER_mode EVP_CIPHER_get_mode +int EVP_CIPHER_get_type(const EVP_CIPHER *cipher); +# define EVP_CIPHER_type EVP_CIPHER_get_type +EVP_CIPHER *EVP_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); +int EVP_CIPHER_can_pipeline(const EVP_CIPHER *cipher, int enc); +int EVP_CIPHER_up_ref(EVP_CIPHER *cipher); +void EVP_CIPHER_free(EVP_CIPHER *cipher); + +const EVP_CIPHER *EVP_CIPHER_CTX_get0_cipher(const EVP_CIPHER_CTX *ctx); +EVP_CIPHER *EVP_CIPHER_CTX_get1_cipher(EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_is_encrypting(const EVP_CIPHER_CTX *ctx); +# define EVP_CIPHER_CTX_encrypting EVP_CIPHER_CTX_is_encrypting +int EVP_CIPHER_CTX_get_nid(const EVP_CIPHER_CTX *ctx); +# define EVP_CIPHER_CTX_nid EVP_CIPHER_CTX_get_nid +int EVP_CIPHER_CTX_get_block_size(const EVP_CIPHER_CTX *ctx); +# define EVP_CIPHER_CTX_block_size EVP_CIPHER_CTX_get_block_size +int EVP_CIPHER_CTX_get_key_length(const EVP_CIPHER_CTX *ctx); +# define EVP_CIPHER_CTX_key_length EVP_CIPHER_CTX_get_key_length +int EVP_CIPHER_CTX_get_iv_length(const EVP_CIPHER_CTX *ctx); +# define EVP_CIPHER_CTX_iv_length EVP_CIPHER_CTX_get_iv_length +int EVP_CIPHER_CTX_get_tag_length(const EVP_CIPHER_CTX *ctx); +# define EVP_CIPHER_CTX_tag_length EVP_CIPHER_CTX_get_tag_length +# ifndef OPENSSL_NO_DEPRECATED_3_0 +const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx); +# endif +int EVP_CIPHER_CTX_get_updated_iv(EVP_CIPHER_CTX *ctx, void *buf, size_t len); +int EVP_CIPHER_CTX_get_original_iv(EVP_CIPHER_CTX *ctx, void *buf, size_t len); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx); +# endif +int EVP_CIPHER_CTX_get_num(const EVP_CIPHER_CTX *ctx); +# define EVP_CIPHER_CTX_num EVP_CIPHER_CTX_get_num +int EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num); +EVP_CIPHER_CTX *EVP_CIPHER_CTX_dup(const EVP_CIPHER_CTX *in); +int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in); +void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); +void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); +void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx); +void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data); +# define EVP_CIPHER_CTX_get0_name(c) EVP_CIPHER_get0_name(EVP_CIPHER_CTX_get0_cipher(c)) +# define EVP_CIPHER_CTX_get_type(c) EVP_CIPHER_get_type(EVP_CIPHER_CTX_get0_cipher(c)) +# define EVP_CIPHER_CTX_type EVP_CIPHER_CTX_get_type +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(c)) +# endif +# define EVP_CIPHER_CTX_get_mode(c) EVP_CIPHER_get_mode(EVP_CIPHER_CTX_get0_cipher(c)) +# define EVP_CIPHER_CTX_mode EVP_CIPHER_CTX_get_mode + +# define EVP_ENCODE_LENGTH(l) ((((l)+2)/3*4)+((l)/48+1)*2+80) +# define EVP_DECODE_LENGTH(l) (((l)+3)/4*3+80) + +# define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +# define EVP_SignInit(a,b) EVP_DigestInit(a,b) +# define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +# define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +# define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) +# define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +# define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) +# define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) + +# ifdef CONST_STRICT +void BIO_set_md(BIO *, const EVP_MD *md); +# else +# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(void *)(md)) +# endif +# define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(mdp)) +# define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(mdcp)) +# define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(mdcp)) +# define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) +# define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(c_pp)) + +__owur int EVP_Cipher(EVP_CIPHER_CTX *c, + unsigned char *out, + const unsigned char *in, unsigned int inl); + +# define EVP_add_cipher_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) +# define EVP_add_digest_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) +# define EVP_delete_cipher_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); +# define EVP_delete_digest_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); + +int EVP_MD_get_params(const EVP_MD *digest, OSSL_PARAM params[]); +int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]); +int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]); +const OSSL_PARAM *EVP_MD_gettable_params(const EVP_MD *digest); +const OSSL_PARAM *EVP_MD_settable_ctx_params(const EVP_MD *md); +const OSSL_PARAM *EVP_MD_gettable_ctx_params(const EVP_MD *md); +const OSSL_PARAM *EVP_MD_CTX_settable_params(EVP_MD_CTX *ctx); +const OSSL_PARAM *EVP_MD_CTX_gettable_params(EVP_MD_CTX *ctx); +int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); +EVP_MD_CTX *EVP_MD_CTX_new(void); +int EVP_MD_CTX_reset(EVP_MD_CTX *ctx); +void EVP_MD_CTX_free(EVP_MD_CTX *ctx); +# define EVP_MD_CTX_create() EVP_MD_CTX_new() +# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx)) +# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx)) +__owur EVP_MD_CTX *EVP_MD_CTX_dup(const EVP_MD_CTX *in); +__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in); +void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); +void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); +int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags); +__owur int EVP_DigestInit_ex2(EVP_MD_CTX *ctx, const EVP_MD *type, + const OSSL_PARAM params[]); +__owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, + ENGINE *impl); +__owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, + size_t cnt); +__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, + unsigned int *s); +__owur int EVP_Digest(const void *data, size_t count, + unsigned char *md, unsigned int *size, + const EVP_MD *type, ENGINE *impl); +__owur int EVP_Q_digest(OSSL_LIB_CTX *libctx, const char *name, + const char *propq, const void *data, size_t datalen, + unsigned char *md, size_t *mdlen); + +__owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in); +__owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); +__owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, + unsigned int *s); +__owur int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *out, + size_t outlen); +__owur int EVP_DigestSqueeze(EVP_MD_CTX *ctx, unsigned char *out, + size_t outlen); + +__owur EVP_MD *EVP_MD_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); + +int EVP_MD_up_ref(EVP_MD *md); +void EVP_MD_free(EVP_MD *md); + +int EVP_read_pw_string(char *buf, int length, const char *prompt, int verify); +int EVP_read_pw_string_min(char *buf, int minlen, int maxlen, + const char *prompt, int verify); +void EVP_set_pw_prompt(const char *prompt); +char *EVP_get_pw_prompt(void); + +__owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, + const unsigned char *salt, + const unsigned char *data, int datal, int count, + unsigned char *key, unsigned char *iv); + +void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags); +void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags); +int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags); + +__owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +__owur int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, + const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, + const unsigned char *iv); +__owur int EVP_EncryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, + const unsigned char *iv, + const OSSL_PARAM params[]); +__owur int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +__owur int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl); +__owur int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl); + +__owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +__owur int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, + const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, + const unsigned char *iv); +__owur int EVP_DecryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, + const unsigned char *iv, + const OSSL_PARAM params[]); +__owur int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +__owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, + int *outl); +__owur int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, + int *outl); + +__owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv, + int enc); +__owur int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, + const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, + const unsigned char *iv, int enc); +__owur int EVP_CipherInit_SKEY(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + EVP_SKEY *skey, const unsigned char *iv, size_t iv_len, + int enc, const OSSL_PARAM params[]); +__owur int EVP_CipherInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv, + int enc, const OSSL_PARAM params[]); +__owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +__owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, + int *outl); +__owur int EVP_CipherPipelineEncryptInit(EVP_CIPHER_CTX *ctx, + const EVP_CIPHER *cipher, + const unsigned char *key, size_t keylen, + size_t numpipes, + const unsigned char **iv, size_t ivlen); +__owur int EVP_CipherPipelineDecryptInit(EVP_CIPHER_CTX *ctx, + const EVP_CIPHER *cipher, + const unsigned char *key, size_t keylen, + size_t numpipes, + const unsigned char **iv, size_t ivlen); +__owur int EVP_CipherPipelineUpdate(EVP_CIPHER_CTX *ctx, + unsigned char **out, size_t *outl, + const size_t *outsize, + const unsigned char **in, const size_t *inl); +__owur int EVP_CipherPipelineFinal(EVP_CIPHER_CTX *ctx, + unsigned char **outm, size_t *outl, + const size_t *outsize); +__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, + int *outl); + +__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s, + EVP_PKEY *pkey); +__owur int EVP_SignFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s, + EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, + const char *propq); + +__owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, + size_t *siglen, const unsigned char *tbs, + size_t tbslen); + +__owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, + unsigned int siglen, EVP_PKEY *pkey); +__owur int EVP_VerifyFinal_ex(EVP_MD_CTX *ctx, const unsigned char *sigbuf, + unsigned int siglen, EVP_PKEY *pkey, + OSSL_LIB_CTX *libctx, const char *propq); + +__owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, + size_t siglen, const unsigned char *tbs, + size_t tbslen); + +__owur int EVP_DigestSignInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, + const char *mdname, OSSL_LIB_CTX *libctx, + const char *props, EVP_PKEY *pkey, + const OSSL_PARAM params[]); +__owur int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, + const EVP_MD *type, ENGINE *e, + EVP_PKEY *pkey); +__owur int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize); +__owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + size_t *siglen); + +__owur int EVP_DigestVerifyInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, + const char *mdname, OSSL_LIB_CTX *libctx, + const char *props, EVP_PKEY *pkey, + const OSSL_PARAM params[]); +__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, + const EVP_MD *type, ENGINE *e, + EVP_PKEY *pkey); +int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize); +__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen); + +__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + const unsigned char *ek, int ekl, + const unsigned char *iv, EVP_PKEY *priv); +__owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + unsigned char **ek, int *ekl, unsigned char *iv, + EVP_PKEY **pubk, int npubk); +__owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void); +void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx); +int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, const EVP_ENCODE_CTX *sctx); +int EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx); +void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); +int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, + const unsigned char *in, int inl); +void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl); +int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); +int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, + const unsigned char *in, int inl); +int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned + char *out, int *outl); +int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c) +# define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c) +# endif +EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); +int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c); +void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c); +int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); +int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); +int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); +int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); +int EVP_CIPHER_get_params(EVP_CIPHER *cipher, OSSL_PARAM params[]); +int EVP_CIPHER_CTX_set_params(EVP_CIPHER_CTX *ctx, const OSSL_PARAM params[]); +int EVP_CIPHER_CTX_get_params(EVP_CIPHER_CTX *ctx, OSSL_PARAM params[]); +const OSSL_PARAM *EVP_CIPHER_gettable_params(const EVP_CIPHER *cipher); +const OSSL_PARAM *EVP_CIPHER_settable_ctx_params(const EVP_CIPHER *cipher); +const OSSL_PARAM *EVP_CIPHER_gettable_ctx_params(const EVP_CIPHER *cipher); +const OSSL_PARAM *EVP_CIPHER_CTX_settable_params(EVP_CIPHER_CTX *ctx); +const OSSL_PARAM *EVP_CIPHER_CTX_gettable_params(EVP_CIPHER_CTX *ctx); + +int EVP_CIPHER_CTX_set_algor_params(EVP_CIPHER_CTX *ctx, const X509_ALGOR *alg); +int EVP_CIPHER_CTX_get_algor_params(EVP_CIPHER_CTX *ctx, X509_ALGOR *alg); +int EVP_CIPHER_CTX_get_algor(EVP_CIPHER_CTX *ctx, X509_ALGOR **alg); + +const BIO_METHOD *BIO_f_md(void); +const BIO_METHOD *BIO_f_base64(void); +const BIO_METHOD *BIO_f_cipher(void); +const BIO_METHOD *BIO_f_reliable(void); +__owur int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, + const unsigned char *i, int enc); + +const EVP_MD *EVP_md_null(void); +# ifndef OPENSSL_NO_MD2 +const EVP_MD *EVP_md2(void); +# endif +# ifndef OPENSSL_NO_MD4 +const EVP_MD *EVP_md4(void); +# endif +# ifndef OPENSSL_NO_MD5 +const EVP_MD *EVP_md5(void); +const EVP_MD *EVP_md5_sha1(void); +# endif +# ifndef OPENSSL_NO_BLAKE2 +const EVP_MD *EVP_blake2b512(void); +const EVP_MD *EVP_blake2s256(void); +# endif +const EVP_MD *EVP_sha1(void); +const EVP_MD *EVP_sha224(void); +const EVP_MD *EVP_sha256(void); +const EVP_MD *EVP_sha384(void); +const EVP_MD *EVP_sha512(void); +const EVP_MD *EVP_sha512_224(void); +const EVP_MD *EVP_sha512_256(void); +const EVP_MD *EVP_sha3_224(void); +const EVP_MD *EVP_sha3_256(void); +const EVP_MD *EVP_sha3_384(void); +const EVP_MD *EVP_sha3_512(void); +const EVP_MD *EVP_shake128(void); +const EVP_MD *EVP_shake256(void); + +# ifndef OPENSSL_NO_MDC2 +const EVP_MD *EVP_mdc2(void); +# endif +# ifndef OPENSSL_NO_RMD160 +const EVP_MD *EVP_ripemd160(void); +# endif +# ifndef OPENSSL_NO_WHIRLPOOL +const EVP_MD *EVP_whirlpool(void); +# endif +# ifndef OPENSSL_NO_SM3 +const EVP_MD *EVP_sm3(void); +# endif +const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ +# ifndef OPENSSL_NO_DES +const EVP_CIPHER *EVP_des_ecb(void); +const EVP_CIPHER *EVP_des_ede(void); +const EVP_CIPHER *EVP_des_ede3(void); +const EVP_CIPHER *EVP_des_ede_ecb(void); +const EVP_CIPHER *EVP_des_ede3_ecb(void); +const EVP_CIPHER *EVP_des_cfb64(void); +# define EVP_des_cfb EVP_des_cfb64 +const EVP_CIPHER *EVP_des_cfb1(void); +const EVP_CIPHER *EVP_des_cfb8(void); +const EVP_CIPHER *EVP_des_ede_cfb64(void); +# define EVP_des_ede_cfb EVP_des_ede_cfb64 +const EVP_CIPHER *EVP_des_ede3_cfb64(void); +# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 +const EVP_CIPHER *EVP_des_ede3_cfb1(void); +const EVP_CIPHER *EVP_des_ede3_cfb8(void); +const EVP_CIPHER *EVP_des_ofb(void); +const EVP_CIPHER *EVP_des_ede_ofb(void); +const EVP_CIPHER *EVP_des_ede3_ofb(void); +const EVP_CIPHER *EVP_des_cbc(void); +const EVP_CIPHER *EVP_des_ede_cbc(void); +const EVP_CIPHER *EVP_des_ede3_cbc(void); +const EVP_CIPHER *EVP_desx_cbc(void); +const EVP_CIPHER *EVP_des_ede3_wrap(void); +/* + * This should now be supported through the dev_crypto ENGINE. But also, why + * are rc4 and md5 declarations made here inside a "NO_DES" precompiler + * branch? + */ +# endif +# ifndef OPENSSL_NO_RC4 +const EVP_CIPHER *EVP_rc4(void); +const EVP_CIPHER *EVP_rc4_40(void); +# ifndef OPENSSL_NO_MD5 +const EVP_CIPHER *EVP_rc4_hmac_md5(void); +# endif +# endif +# ifndef OPENSSL_NO_IDEA +const EVP_CIPHER *EVP_idea_ecb(void); +const EVP_CIPHER *EVP_idea_cfb64(void); +# define EVP_idea_cfb EVP_idea_cfb64 +const EVP_CIPHER *EVP_idea_ofb(void); +const EVP_CIPHER *EVP_idea_cbc(void); +# endif +# ifndef OPENSSL_NO_RC2 +const EVP_CIPHER *EVP_rc2_ecb(void); +const EVP_CIPHER *EVP_rc2_cbc(void); +const EVP_CIPHER *EVP_rc2_40_cbc(void); +const EVP_CIPHER *EVP_rc2_64_cbc(void); +const EVP_CIPHER *EVP_rc2_cfb64(void); +# define EVP_rc2_cfb EVP_rc2_cfb64 +const EVP_CIPHER *EVP_rc2_ofb(void); +# endif +# ifndef OPENSSL_NO_BF +const EVP_CIPHER *EVP_bf_ecb(void); +const EVP_CIPHER *EVP_bf_cbc(void); +const EVP_CIPHER *EVP_bf_cfb64(void); +# define EVP_bf_cfb EVP_bf_cfb64 +const EVP_CIPHER *EVP_bf_ofb(void); +# endif +# ifndef OPENSSL_NO_CAST +const EVP_CIPHER *EVP_cast5_ecb(void); +const EVP_CIPHER *EVP_cast5_cbc(void); +const EVP_CIPHER *EVP_cast5_cfb64(void); +# define EVP_cast5_cfb EVP_cast5_cfb64 +const EVP_CIPHER *EVP_cast5_ofb(void); +# endif +# ifndef OPENSSL_NO_RC5 +const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); +const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); +const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); +# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 +const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); +# endif +const EVP_CIPHER *EVP_aes_128_ecb(void); +const EVP_CIPHER *EVP_aes_128_cbc(void); +const EVP_CIPHER *EVP_aes_128_cfb1(void); +const EVP_CIPHER *EVP_aes_128_cfb8(void); +const EVP_CIPHER *EVP_aes_128_cfb128(void); +# define EVP_aes_128_cfb EVP_aes_128_cfb128 +const EVP_CIPHER *EVP_aes_128_ofb(void); +const EVP_CIPHER *EVP_aes_128_ctr(void); +const EVP_CIPHER *EVP_aes_128_ccm(void); +const EVP_CIPHER *EVP_aes_128_gcm(void); +const EVP_CIPHER *EVP_aes_128_xts(void); +const EVP_CIPHER *EVP_aes_128_wrap(void); +const EVP_CIPHER *EVP_aes_128_wrap_pad(void); +# ifndef OPENSSL_NO_OCB +const EVP_CIPHER *EVP_aes_128_ocb(void); +# endif +const EVP_CIPHER *EVP_aes_192_ecb(void); +const EVP_CIPHER *EVP_aes_192_cbc(void); +const EVP_CIPHER *EVP_aes_192_cfb1(void); +const EVP_CIPHER *EVP_aes_192_cfb8(void); +const EVP_CIPHER *EVP_aes_192_cfb128(void); +# define EVP_aes_192_cfb EVP_aes_192_cfb128 +const EVP_CIPHER *EVP_aes_192_ofb(void); +const EVP_CIPHER *EVP_aes_192_ctr(void); +const EVP_CIPHER *EVP_aes_192_ccm(void); +const EVP_CIPHER *EVP_aes_192_gcm(void); +const EVP_CIPHER *EVP_aes_192_wrap(void); +const EVP_CIPHER *EVP_aes_192_wrap_pad(void); +# ifndef OPENSSL_NO_OCB +const EVP_CIPHER *EVP_aes_192_ocb(void); +# endif +const EVP_CIPHER *EVP_aes_256_ecb(void); +const EVP_CIPHER *EVP_aes_256_cbc(void); +const EVP_CIPHER *EVP_aes_256_cfb1(void); +const EVP_CIPHER *EVP_aes_256_cfb8(void); +const EVP_CIPHER *EVP_aes_256_cfb128(void); +# define EVP_aes_256_cfb EVP_aes_256_cfb128 +const EVP_CIPHER *EVP_aes_256_ofb(void); +const EVP_CIPHER *EVP_aes_256_ctr(void); +const EVP_CIPHER *EVP_aes_256_ccm(void); +const EVP_CIPHER *EVP_aes_256_gcm(void); +const EVP_CIPHER *EVP_aes_256_xts(void); +const EVP_CIPHER *EVP_aes_256_wrap(void); +const EVP_CIPHER *EVP_aes_256_wrap_pad(void); +# ifndef OPENSSL_NO_OCB +const EVP_CIPHER *EVP_aes_256_ocb(void); +# endif +const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); +const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void); +const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void); +const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void); +# ifndef OPENSSL_NO_ARIA +const EVP_CIPHER *EVP_aria_128_ecb(void); +const EVP_CIPHER *EVP_aria_128_cbc(void); +const EVP_CIPHER *EVP_aria_128_cfb1(void); +const EVP_CIPHER *EVP_aria_128_cfb8(void); +const EVP_CIPHER *EVP_aria_128_cfb128(void); +# define EVP_aria_128_cfb EVP_aria_128_cfb128 +const EVP_CIPHER *EVP_aria_128_ctr(void); +const EVP_CIPHER *EVP_aria_128_ofb(void); +const EVP_CIPHER *EVP_aria_128_gcm(void); +const EVP_CIPHER *EVP_aria_128_ccm(void); +const EVP_CIPHER *EVP_aria_192_ecb(void); +const EVP_CIPHER *EVP_aria_192_cbc(void); +const EVP_CIPHER *EVP_aria_192_cfb1(void); +const EVP_CIPHER *EVP_aria_192_cfb8(void); +const EVP_CIPHER *EVP_aria_192_cfb128(void); +# define EVP_aria_192_cfb EVP_aria_192_cfb128 +const EVP_CIPHER *EVP_aria_192_ctr(void); +const EVP_CIPHER *EVP_aria_192_ofb(void); +const EVP_CIPHER *EVP_aria_192_gcm(void); +const EVP_CIPHER *EVP_aria_192_ccm(void); +const EVP_CIPHER *EVP_aria_256_ecb(void); +const EVP_CIPHER *EVP_aria_256_cbc(void); +const EVP_CIPHER *EVP_aria_256_cfb1(void); +const EVP_CIPHER *EVP_aria_256_cfb8(void); +const EVP_CIPHER *EVP_aria_256_cfb128(void); +# define EVP_aria_256_cfb EVP_aria_256_cfb128 +const EVP_CIPHER *EVP_aria_256_ctr(void); +const EVP_CIPHER *EVP_aria_256_ofb(void); +const EVP_CIPHER *EVP_aria_256_gcm(void); +const EVP_CIPHER *EVP_aria_256_ccm(void); +# endif +# ifndef OPENSSL_NO_CAMELLIA +const EVP_CIPHER *EVP_camellia_128_ecb(void); +const EVP_CIPHER *EVP_camellia_128_cbc(void); +const EVP_CIPHER *EVP_camellia_128_cfb1(void); +const EVP_CIPHER *EVP_camellia_128_cfb8(void); +const EVP_CIPHER *EVP_camellia_128_cfb128(void); +# define EVP_camellia_128_cfb EVP_camellia_128_cfb128 +const EVP_CIPHER *EVP_camellia_128_ofb(void); +const EVP_CIPHER *EVP_camellia_128_ctr(void); +const EVP_CIPHER *EVP_camellia_192_ecb(void); +const EVP_CIPHER *EVP_camellia_192_cbc(void); +const EVP_CIPHER *EVP_camellia_192_cfb1(void); +const EVP_CIPHER *EVP_camellia_192_cfb8(void); +const EVP_CIPHER *EVP_camellia_192_cfb128(void); +# define EVP_camellia_192_cfb EVP_camellia_192_cfb128 +const EVP_CIPHER *EVP_camellia_192_ofb(void); +const EVP_CIPHER *EVP_camellia_192_ctr(void); +const EVP_CIPHER *EVP_camellia_256_ecb(void); +const EVP_CIPHER *EVP_camellia_256_cbc(void); +const EVP_CIPHER *EVP_camellia_256_cfb1(void); +const EVP_CIPHER *EVP_camellia_256_cfb8(void); +const EVP_CIPHER *EVP_camellia_256_cfb128(void); +# define EVP_camellia_256_cfb EVP_camellia_256_cfb128 +const EVP_CIPHER *EVP_camellia_256_ofb(void); +const EVP_CIPHER *EVP_camellia_256_ctr(void); +# endif +# ifndef OPENSSL_NO_CHACHA +const EVP_CIPHER *EVP_chacha20(void); +# ifndef OPENSSL_NO_POLY1305 +const EVP_CIPHER *EVP_chacha20_poly1305(void); +# endif +# endif + +# ifndef OPENSSL_NO_SEED +const EVP_CIPHER *EVP_seed_ecb(void); +const EVP_CIPHER *EVP_seed_cbc(void); +const EVP_CIPHER *EVP_seed_cfb128(void); +# define EVP_seed_cfb EVP_seed_cfb128 +const EVP_CIPHER *EVP_seed_ofb(void); +# endif + +# ifndef OPENSSL_NO_SM4 +const EVP_CIPHER *EVP_sm4_ecb(void); +const EVP_CIPHER *EVP_sm4_cbc(void); +const EVP_CIPHER *EVP_sm4_cfb128(void); +# define EVP_sm4_cfb EVP_sm4_cfb128 +const EVP_CIPHER *EVP_sm4_ofb(void); +const EVP_CIPHER *EVP_sm4_ctr(void); +# endif + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define OPENSSL_add_all_algorithms_conf() \ + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ + | OPENSSL_INIT_ADD_ALL_DIGESTS \ + | OPENSSL_INIT_LOAD_CONFIG, NULL) +# define OPENSSL_add_all_algorithms_noconf() \ + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ + | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) + +# ifdef OPENSSL_LOAD_CONF +# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf() +# else +# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf() +# endif + +# define OpenSSL_add_all_ciphers() \ + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL) +# define OpenSSL_add_all_digests() \ + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) + +# define EVP_cleanup() while(0) continue +# endif + +int EVP_add_cipher(const EVP_CIPHER *cipher); +int EVP_add_digest(const EVP_MD *digest); + +const EVP_CIPHER *EVP_get_cipherbyname(const char *name); +const EVP_MD *EVP_get_digestbyname(const char *name); + +void EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph, + const char *from, const char *to, void *x), + void *arg); +void EVP_CIPHER_do_all_sorted(void (*fn) + (const EVP_CIPHER *ciph, const char *from, + const char *to, void *x), void *arg); +void EVP_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_CIPHER *cipher, void *arg), + void *arg); + +void EVP_MD_do_all(void (*fn) (const EVP_MD *ciph, + const char *from, const char *to, void *x), + void *arg); +void EVP_MD_do_all_sorted(void (*fn) + (const EVP_MD *ciph, const char *from, + const char *to, void *x), void *arg); +void EVP_MD_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_MD *md, void *arg), + void *arg); + +/* MAC stuff */ + +EVP_MAC *EVP_MAC_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, + const char *properties); +int EVP_MAC_up_ref(EVP_MAC *mac); +void EVP_MAC_free(EVP_MAC *mac); +const char *EVP_MAC_get0_name(const EVP_MAC *mac); +const char *EVP_MAC_get0_description(const EVP_MAC *mac); +int EVP_MAC_is_a(const EVP_MAC *mac, const char *name); +const OSSL_PROVIDER *EVP_MAC_get0_provider(const EVP_MAC *mac); +int EVP_MAC_get_params(EVP_MAC *mac, OSSL_PARAM params[]); + +EVP_MAC_CTX *EVP_MAC_CTX_new(EVP_MAC *mac); +void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx); +EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src); +EVP_MAC *EVP_MAC_CTX_get0_mac(EVP_MAC_CTX *ctx); +int EVP_MAC_CTX_get_params(EVP_MAC_CTX *ctx, OSSL_PARAM params[]); +int EVP_MAC_CTX_set_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[]); + +size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx); +size_t EVP_MAC_CTX_get_block_size(EVP_MAC_CTX *ctx); +unsigned char *EVP_Q_mac(OSSL_LIB_CTX *libctx, const char *name, const char *propq, + const char *subalg, const OSSL_PARAM *params, + const void *key, size_t keylen, + const unsigned char *data, size_t datalen, + unsigned char *out, size_t outsize, size_t *outlen); +int EVP_MAC_init(EVP_MAC_CTX *ctx, const unsigned char *key, size_t keylen, + const OSSL_PARAM params[]); +int EVP_MAC_init_SKEY(EVP_MAC_CTX *ctx, EVP_SKEY *skey, const OSSL_PARAM params[]); +int EVP_MAC_update(EVP_MAC_CTX *ctx, const unsigned char *data, size_t datalen); +int EVP_MAC_final(EVP_MAC_CTX *ctx, + unsigned char *out, size_t *outl, size_t outsize); +int EVP_MAC_finalXOF(EVP_MAC_CTX *ctx, unsigned char *out, size_t outsize); +const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac); +const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac); +const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac); +const OSSL_PARAM *EVP_MAC_CTX_gettable_params(EVP_MAC_CTX *ctx); +const OSSL_PARAM *EVP_MAC_CTX_settable_params(EVP_MAC_CTX *ctx); + +void EVP_MAC_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_MAC *mac, void *arg), + void *arg); +int EVP_MAC_names_do_all(const EVP_MAC *mac, + void (*fn)(const char *name, void *data), + void *data); + +/* RAND stuff */ +EVP_RAND *EVP_RAND_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, + const char *properties); +int EVP_RAND_up_ref(EVP_RAND *rand); +void EVP_RAND_free(EVP_RAND *rand); +const char *EVP_RAND_get0_name(const EVP_RAND *rand); +const char *EVP_RAND_get0_description(const EVP_RAND *md); +int EVP_RAND_is_a(const EVP_RAND *rand, const char *name); +const OSSL_PROVIDER *EVP_RAND_get0_provider(const EVP_RAND *rand); +int EVP_RAND_get_params(EVP_RAND *rand, OSSL_PARAM params[]); + +EVP_RAND_CTX *EVP_RAND_CTX_new(EVP_RAND *rand, EVP_RAND_CTX *parent); +int EVP_RAND_CTX_up_ref(EVP_RAND_CTX *ctx); +void EVP_RAND_CTX_free(EVP_RAND_CTX *ctx); +EVP_RAND *EVP_RAND_CTX_get0_rand(EVP_RAND_CTX *ctx); +int EVP_RAND_CTX_get_params(EVP_RAND_CTX *ctx, OSSL_PARAM params[]); +int EVP_RAND_CTX_set_params(EVP_RAND_CTX *ctx, const OSSL_PARAM params[]); +const OSSL_PARAM *EVP_RAND_gettable_params(const EVP_RAND *rand); +const OSSL_PARAM *EVP_RAND_gettable_ctx_params(const EVP_RAND *rand); +const OSSL_PARAM *EVP_RAND_settable_ctx_params(const EVP_RAND *rand); +const OSSL_PARAM *EVP_RAND_CTX_gettable_params(EVP_RAND_CTX *ctx); +const OSSL_PARAM *EVP_RAND_CTX_settable_params(EVP_RAND_CTX *ctx); + +void EVP_RAND_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_RAND *rand, void *arg), + void *arg); +int EVP_RAND_names_do_all(const EVP_RAND *rand, + void (*fn)(const char *name, void *data), + void *data); + +__owur int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength, + int prediction_resistance, + const unsigned char *pstr, size_t pstr_len, + const OSSL_PARAM params[]); +int EVP_RAND_uninstantiate(EVP_RAND_CTX *ctx); +__owur int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out, + size_t outlen, unsigned int strength, + int prediction_resistance, + const unsigned char *addin, size_t addin_len); +int EVP_RAND_reseed(EVP_RAND_CTX *ctx, int prediction_resistance, + const unsigned char *ent, size_t ent_len, + const unsigned char *addin, size_t addin_len); +__owur int EVP_RAND_nonce(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen); +__owur int EVP_RAND_enable_locking(EVP_RAND_CTX *ctx); + +int EVP_RAND_verify_zeroization(EVP_RAND_CTX *ctx); +unsigned int EVP_RAND_get_strength(EVP_RAND_CTX *ctx); +int EVP_RAND_get_state(EVP_RAND_CTX *ctx); + +# define EVP_RAND_STATE_UNINITIALISED 0 +# define EVP_RAND_STATE_READY 1 +# define EVP_RAND_STATE_ERROR 2 + +/* PKEY stuff */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_decrypt_old(unsigned char *dec_key, + const unsigned char *enc_key, + int enc_key_len, + EVP_PKEY *private_key); +OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_encrypt_old(unsigned char *enc_key, + const unsigned char *key, + int key_len, EVP_PKEY *pub_key); +# endif +int EVP_PKEY_is_a(const EVP_PKEY *pkey, const char *name); +int EVP_PKEY_type_names_do_all(const EVP_PKEY *pkey, + void (*fn)(const char *name, void *data), + void *data); +int EVP_PKEY_type(int type); +int EVP_PKEY_get_id(const EVP_PKEY *pkey); +# define EVP_PKEY_id EVP_PKEY_get_id +int EVP_PKEY_get_base_id(const EVP_PKEY *pkey); +# define EVP_PKEY_base_id EVP_PKEY_get_base_id +int EVP_PKEY_get_bits(const EVP_PKEY *pkey); +# define EVP_PKEY_bits EVP_PKEY_get_bits +int EVP_PKEY_get_security_bits(const EVP_PKEY *pkey); +# define EVP_PKEY_security_bits EVP_PKEY_get_security_bits +int EVP_PKEY_get_size(const EVP_PKEY *pkey); +# define EVP_PKEY_size EVP_PKEY_get_size +int EVP_PKEY_can_sign(const EVP_PKEY *pkey); +int EVP_PKEY_set_type(EVP_PKEY *pkey, int type); +int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len); +int EVP_PKEY_set_type_by_keymgmt(EVP_PKEY *pkey, EVP_KEYMGMT *keymgmt); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_ENGINE +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e); +OSSL_DEPRECATEDIN_3_0 +ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey); +# endif +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); +OSSL_DEPRECATEDIN_3_0 +void *EVP_PKEY_get0(const EVP_PKEY *pkey); +OSSL_DEPRECATEDIN_3_0 +const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len); +# ifndef OPENSSL_NO_POLY1305 +OSSL_DEPRECATEDIN_3_0 +const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len); +# endif +# ifndef OPENSSL_NO_SIPHASH +OSSL_DEPRECATEDIN_3_0 +const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len); +# endif + +struct rsa_st; +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key); +OSSL_DEPRECATEDIN_3_0 +const struct rsa_st *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey); +OSSL_DEPRECATEDIN_3_0 +struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); + +# ifndef OPENSSL_NO_DSA +struct dsa_st; +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key); +OSSL_DEPRECATEDIN_3_0 +const struct dsa_st *EVP_PKEY_get0_DSA(const EVP_PKEY *pkey); +OSSL_DEPRECATEDIN_3_0 +struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); +# endif + +# ifndef OPENSSL_NO_DH +struct dh_st; +OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key); +OSSL_DEPRECATEDIN_3_0 const struct dh_st *EVP_PKEY_get0_DH(const EVP_PKEY *pkey); +OSSL_DEPRECATEDIN_3_0 struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); +# endif + +# ifndef OPENSSL_NO_EC +struct ec_key_st; +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key); +OSSL_DEPRECATEDIN_3_0 +const struct ec_key_st *EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey); +OSSL_DEPRECATEDIN_3_0 +struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); +# endif +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +EVP_PKEY *EVP_PKEY_new(void); +int EVP_PKEY_up_ref(EVP_PKEY *pkey); +EVP_PKEY *EVP_PKEY_dup(EVP_PKEY *pkey); +void EVP_PKEY_free(EVP_PKEY *pkey); +const char *EVP_PKEY_get0_description(const EVP_PKEY *pkey); +const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key); + +EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PublicKey(const EVP_PKEY *a, unsigned char **pp); + + +EVP_PKEY *d2i_PrivateKey_ex(int type, EVP_PKEY **a, const unsigned char **pp, + long length, OSSL_LIB_CTX *libctx, + const char *propq); +EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, + long length); +EVP_PKEY *d2i_AutoPrivateKey_ex(EVP_PKEY **a, const unsigned char **pp, + long length, OSSL_LIB_CTX *libctx, + const char *propq); +EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PrivateKey(const EVP_PKEY *a, unsigned char **pp); + +int i2d_KeyParams(const EVP_PKEY *a, unsigned char **pp); +EVP_PKEY *d2i_KeyParams(int type, EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_KeyParams_bio(BIO *bp, const EVP_PKEY *pkey); +EVP_PKEY *d2i_KeyParams_bio(int type, EVP_PKEY **a, BIO *in); + +int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); +int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); +int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode); +int EVP_PKEY_parameters_eq(const EVP_PKEY *a, const EVP_PKEY *b); +int EVP_PKEY_eq(const EVP_PKEY *a, const EVP_PKEY *b); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); +# endif + +int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, + int indent, ASN1_PCTX *pctx); +int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, + int indent, ASN1_PCTX *pctx); +int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, + int indent, ASN1_PCTX *pctx); +# ifndef OPENSSL_NO_STDIO +int EVP_PKEY_print_public_fp(FILE *fp, const EVP_PKEY *pkey, + int indent, ASN1_PCTX *pctx); +int EVP_PKEY_print_private_fp(FILE *fp, const EVP_PKEY *pkey, + int indent, ASN1_PCTX *pctx); +int EVP_PKEY_print_params_fp(FILE *fp, const EVP_PKEY *pkey, + int indent, ASN1_PCTX *pctx); +# endif + +int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid); +int EVP_PKEY_get_default_digest_name(EVP_PKEY *pkey, + char *mdname, size_t mdname_sz); +int EVP_PKEY_digestsign_supports_digest(EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, + const char *name, const char *propq); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* + * For backwards compatibility. Use EVP_PKEY_set1_encoded_public_key in + * preference + */ +# define EVP_PKEY_set1_tls_encodedpoint(pkey, pt, ptlen) \ + EVP_PKEY_set1_encoded_public_key((pkey), (pt), (ptlen)) +# endif + +int EVP_PKEY_set1_encoded_public_key(EVP_PKEY *pkey, + const unsigned char *pub, size_t publen); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* + * For backwards compatibility. Use EVP_PKEY_get1_encoded_public_key in + * preference + */ +# define EVP_PKEY_get1_tls_encodedpoint(pkey, ppt) \ + EVP_PKEY_get1_encoded_public_key((pkey), (ppt)) +# endif + +size_t EVP_PKEY_get1_encoded_public_key(EVP_PKEY *pkey, unsigned char **ppub); + +/* calls methods */ +int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); +int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); + +/* These are used by EVP_CIPHER methods */ +int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); +int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); + +/* PKCS5 password based encryption */ +int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); +int PKCS5_PBE_keyivgen_ex(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de, OSSL_LIB_CTX *libctx, + const char *propq); +int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, + const unsigned char *salt, int saltlen, int iter, + int keylen, unsigned char *out); +int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, + const unsigned char *salt, int saltlen, int iter, + const EVP_MD *digest, int keylen, unsigned char *out); +int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); +int PKCS5_v2_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de, + OSSL_LIB_CTX *libctx, const char *propq); + +#ifndef OPENSSL_NO_SCRYPT +int EVP_PBE_scrypt(const char *pass, size_t passlen, + const unsigned char *salt, size_t saltlen, + uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem, + unsigned char *key, size_t keylen); +int EVP_PBE_scrypt_ex(const char *pass, size_t passlen, + const unsigned char *salt, size_t saltlen, + uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem, + unsigned char *key, size_t keylen, + OSSL_LIB_CTX *ctx, const char *propq); + +int PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, + int passlen, ASN1_TYPE *param, + const EVP_CIPHER *c, const EVP_MD *md, int en_de); +int PKCS5_v2_scrypt_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, + int passlen, ASN1_TYPE *param, + const EVP_CIPHER *c, const EVP_MD *md, int en_de, + OSSL_LIB_CTX *libctx, const char *propq); +#endif + +void PKCS5_PBE_add(void); + +int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, + ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); + +int EVP_PBE_CipherInit_ex(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, + ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de, + OSSL_LIB_CTX *libctx, const char *propq); + +/* PBE type */ + +/* Can appear as the outermost AlgorithmIdentifier */ +# define EVP_PBE_TYPE_OUTER 0x0 +/* Is an PRF type OID */ +# define EVP_PBE_TYPE_PRF 0x1 +/* Is a PKCS#5 v2.0 KDF */ +# define EVP_PBE_TYPE_KDF 0x2 + +int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, + int md_nid, EVP_PBE_KEYGEN *keygen); +int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, + EVP_PBE_KEYGEN *keygen); +int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid, + EVP_PBE_KEYGEN **pkeygen); +int EVP_PBE_find_ex(int type, int pbe_nid, int *pcnid, int *pmnid, + EVP_PBE_KEYGEN **pkeygen, EVP_PBE_KEYGEN_EX **pkeygen_ex); +void EVP_PBE_cleanup(void); +int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num); + +# define ASN1_PKEY_ALIAS 0x1 +# define ASN1_PKEY_DYNAMIC 0x2 +# define ASN1_PKEY_SIGPARAM_NULL 0x4 + +# define ASN1_PKEY_CTRL_PKCS7_SIGN 0x1 +# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT 0x2 +# define ASN1_PKEY_CTRL_DEFAULT_MD_NID 0x3 +# define ASN1_PKEY_CTRL_CMS_SIGN 0x5 +# define ASN1_PKEY_CTRL_CMS_ENVELOPE 0x7 +# define ASN1_PKEY_CTRL_CMS_RI_TYPE 0x8 + +# define ASN1_PKEY_CTRL_SET1_TLS_ENCPT 0x9 +# define ASN1_PKEY_CTRL_GET1_TLS_ENCPT 0xa +# define ASN1_PKEY_CTRL_CMS_IS_RI_TYPE_SUPPORTED 0xb + +int EVP_PKEY_asn1_get_count(void); +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx); +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type); +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, + const char *str, int len); +int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth); +int EVP_PKEY_asn1_add_alias(int to, int from); +int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, + int *ppkey_flags, const char **pinfo, + const char **ppem_str, + const EVP_PKEY_ASN1_METHOD *ameth); + +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey); +EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, + const char *pem_str, + const char *info); +void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, + const EVP_PKEY_ASN1_METHOD *src); +void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth); +void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, + int (*pub_decode) (EVP_PKEY *pk, + const X509_PUBKEY *pub), + int (*pub_encode) (X509_PUBKEY *pub, + const EVP_PKEY *pk), + int (*pub_cmp) (const EVP_PKEY *a, + const EVP_PKEY *b), + int (*pub_print) (BIO *out, + const EVP_PKEY *pkey, + int indent, ASN1_PCTX *pctx), + int (*pkey_size) (const EVP_PKEY *pk), + int (*pkey_bits) (const EVP_PKEY *pk)); +void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, + int (*priv_decode) (EVP_PKEY *pk, + const PKCS8_PRIV_KEY_INFO + *p8inf), + int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, + const EVP_PKEY *pk), + int (*priv_print) (BIO *out, + const EVP_PKEY *pkey, + int indent, + ASN1_PCTX *pctx)); +void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth, + int (*param_decode) (EVP_PKEY *pkey, + const unsigned char **pder, + int derlen), + int (*param_encode) (const EVP_PKEY *pkey, + unsigned char **pder), + int (*param_missing) (const EVP_PKEY *pk), + int (*param_copy) (EVP_PKEY *to, + const EVP_PKEY *from), + int (*param_cmp) (const EVP_PKEY *a, + const EVP_PKEY *b), + int (*param_print) (BIO *out, + const EVP_PKEY *pkey, + int indent, + ASN1_PCTX *pctx)); + +void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, + void (*pkey_free) (EVP_PKEY *pkey)); +void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, + int (*pkey_ctrl) (EVP_PKEY *pkey, int op, + long arg1, void *arg2)); +void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth, + int (*item_verify) (EVP_MD_CTX *ctx, + const ASN1_ITEM *it, + const void *data, + const X509_ALGOR *a, + const ASN1_BIT_STRING *sig, + EVP_PKEY *pkey), + int (*item_sign) (EVP_MD_CTX *ctx, + const ASN1_ITEM *it, + const void *data, + X509_ALGOR *alg1, + X509_ALGOR *alg2, + ASN1_BIT_STRING *sig)); + +void EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth, + int (*siginf_set) (X509_SIG_INFO *siginf, + const X509_ALGOR *alg, + const ASN1_STRING *sig)); + +void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth, + int (*pkey_check) (const EVP_PKEY *pk)); + +void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth, + int (*pkey_pub_check) (const EVP_PKEY *pk)); + +void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth, + int (*pkey_param_check) (const EVP_PKEY *pk)); + +void EVP_PKEY_asn1_set_set_priv_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*set_priv_key) (EVP_PKEY *pk, + const unsigned char + *priv, + size_t len)); +void EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*set_pub_key) (EVP_PKEY *pk, + const unsigned char *pub, + size_t len)); +void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*get_priv_key) (const EVP_PKEY *pk, + unsigned char *priv, + size_t *len)); +void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*get_pub_key) (const EVP_PKEY *pk, + unsigned char *pub, + size_t *len)); + +void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, + int (*pkey_security_bits) (const EVP_PKEY + *pk)); + +int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); +int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); + +int EVP_PKEY_CTX_set1_id(EVP_PKEY_CTX *ctx, const void *id, int len); +int EVP_PKEY_CTX_get1_id(EVP_PKEY_CTX *ctx, void *id); +int EVP_PKEY_CTX_get1_id_len(EVP_PKEY_CTX *ctx, size_t *id_len); + +int EVP_PKEY_CTX_set_kem_op(EVP_PKEY_CTX *ctx, const char *op); + +const char *EVP_PKEY_get0_type_name(const EVP_PKEY *key); + +# define EVP_PKEY_OP_UNDEFINED 0 +# define EVP_PKEY_OP_PARAMGEN (1 << 1) +# define EVP_PKEY_OP_KEYGEN (1 << 2) +# define EVP_PKEY_OP_FROMDATA (1 << 3) +# define EVP_PKEY_OP_SIGN (1 << 4) +# define EVP_PKEY_OP_VERIFY (1 << 5) +# define EVP_PKEY_OP_VERIFYRECOVER (1 << 6) +# define EVP_PKEY_OP_SIGNCTX (1 << 7) +# define EVP_PKEY_OP_VERIFYCTX (1 << 8) +# define EVP_PKEY_OP_ENCRYPT (1 << 9) +# define EVP_PKEY_OP_DECRYPT (1 << 10) +# define EVP_PKEY_OP_DERIVE (1 << 11) +# define EVP_PKEY_OP_ENCAPSULATE (1 << 12) +# define EVP_PKEY_OP_DECAPSULATE (1 << 13) +# define EVP_PKEY_OP_SIGNMSG (1 << 14) +# define EVP_PKEY_OP_VERIFYMSG (1 << 15) +/* Update the following when adding new EVP_PKEY_OPs */ +# define EVP_PKEY_OP_ALL ((1 << 16) - 1) + +# define EVP_PKEY_OP_TYPE_SIG \ + (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_SIGNMSG \ + | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYMSG \ + | EVP_PKEY_OP_VERIFYRECOVER \ + | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX) + +# define EVP_PKEY_OP_TYPE_CRYPT \ + (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT) + +# define EVP_PKEY_OP_TYPE_DERIVE \ + (EVP_PKEY_OP_DERIVE) + +# define EVP_PKEY_OP_TYPE_DATA \ + (EVP_PKEY_OP_FROMDATA) + +# define EVP_PKEY_OP_TYPE_KEM \ + (EVP_PKEY_OP_ENCAPSULATE | EVP_PKEY_OP_DECAPSULATE) + +# define EVP_PKEY_OP_TYPE_GEN \ + (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN) + +# define EVP_PKEY_OP_TYPE_NOGEN \ + (EVP_PKEY_OP_ALL & ~EVP_PKEY_OP_TYPE_GEN) + +int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key, + int keylen); + +# define EVP_PKEY_CTRL_MD 1 +# define EVP_PKEY_CTRL_PEER_KEY 2 +# define EVP_PKEY_CTRL_SET_MAC_KEY 6 +# define EVP_PKEY_CTRL_DIGESTINIT 7 +/* Used by GOST key encryption in TLS */ +# define EVP_PKEY_CTRL_SET_IV 8 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3 +# define EVP_PKEY_CTRL_PKCS7_DECRYPT 4 +# define EVP_PKEY_CTRL_PKCS7_SIGN 5 +# define EVP_PKEY_CTRL_CMS_ENCRYPT 9 +# define EVP_PKEY_CTRL_CMS_DECRYPT 10 +# define EVP_PKEY_CTRL_CMS_SIGN 11 +# endif +# define EVP_PKEY_CTRL_CIPHER 12 +# define EVP_PKEY_CTRL_GET_MD 13 +# define EVP_PKEY_CTRL_SET_DIGEST_SIZE 14 +# define EVP_PKEY_CTRL_SET1_ID 15 +# define EVP_PKEY_CTRL_GET1_ID 16 +# define EVP_PKEY_CTRL_GET1_ID_LEN 17 + +# define EVP_PKEY_ALG_CTRL 0x1000 + +# define EVP_PKEY_FLAG_AUTOARGLEN 2 +/* + * Method handles all operations: don't assume any digest related defaults. + */ +# define EVP_PKEY_FLAG_SIGCTX_CUSTOM 4 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type); +OSSL_DEPRECATEDIN_3_0 EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags, + const EVP_PKEY_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, + const EVP_PKEY_METHOD *src); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth); +OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth); +OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth); +OSSL_DEPRECATEDIN_3_0 size_t EVP_PKEY_meth_get_count(void); +OSSL_DEPRECATEDIN_3_0 const EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx); +# endif + +EVP_KEYMGMT *EVP_KEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); +int EVP_KEYMGMT_up_ref(EVP_KEYMGMT *keymgmt); +void EVP_KEYMGMT_free(EVP_KEYMGMT *keymgmt); +const OSSL_PROVIDER *EVP_KEYMGMT_get0_provider(const EVP_KEYMGMT *keymgmt); +const char *EVP_KEYMGMT_get0_name(const EVP_KEYMGMT *keymgmt); +const char *EVP_KEYMGMT_get0_description(const EVP_KEYMGMT *keymgmt); +int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name); +void EVP_KEYMGMT_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_KEYMGMT *keymgmt, void *arg), + void *arg); +int EVP_KEYMGMT_names_do_all(const EVP_KEYMGMT *keymgmt, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PARAM *EVP_KEYMGMT_gettable_params(const EVP_KEYMGMT *keymgmt); +const OSSL_PARAM *EVP_KEYMGMT_settable_params(const EVP_KEYMGMT *keymgmt); +const OSSL_PARAM *EVP_KEYMGMT_gen_settable_params(const EVP_KEYMGMT *keymgmt); +const OSSL_PARAM *EVP_KEYMGMT_gen_gettable_params(const EVP_KEYMGMT *keymgmt); + +EVP_SKEYMGMT *EVP_SKEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); +int EVP_SKEYMGMT_up_ref(EVP_SKEYMGMT *keymgmt); +void EVP_SKEYMGMT_free(EVP_SKEYMGMT *keymgmt); +const OSSL_PROVIDER *EVP_SKEYMGMT_get0_provider(const EVP_SKEYMGMT *keymgmt); +const char *EVP_SKEYMGMT_get0_name(const EVP_SKEYMGMT *keymgmt); +const char *EVP_SKEYMGMT_get0_description(const EVP_SKEYMGMT *keymgmt); +int EVP_SKEYMGMT_is_a(const EVP_SKEYMGMT *keymgmt, const char *name); +void EVP_SKEYMGMT_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_SKEYMGMT *keymgmt, void *arg), + void *arg); +int EVP_SKEYMGMT_names_do_all(const EVP_SKEYMGMT *keymgmt, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PARAM *EVP_SKEYMGMT_get0_gen_settable_params(const EVP_SKEYMGMT *skeymgmt); +const OSSL_PARAM *EVP_SKEYMGMT_get0_imp_settable_params(const EVP_SKEYMGMT *skeymgmt); + +EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); +EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); +EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx, + const char *name, + const char *propquery); +EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx, + EVP_PKEY *pkey, const char *propquery); +EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx); +void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx); +int EVP_PKEY_CTX_is_a(EVP_PKEY_CTX *ctx, const char *keytype); + +int EVP_PKEY_CTX_get_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params); +const OSSL_PARAM *EVP_PKEY_CTX_gettable_params(const EVP_PKEY_CTX *ctx); +int EVP_PKEY_CTX_set_params(EVP_PKEY_CTX *ctx, const OSSL_PARAM *params); +const OSSL_PARAM *EVP_PKEY_CTX_settable_params(const EVP_PKEY_CTX *ctx); + +int EVP_PKEY_CTX_set_algor_params(EVP_PKEY_CTX *ctx, const X509_ALGOR *alg); +int EVP_PKEY_CTX_get_algor_params(EVP_PKEY_CTX *ctx, X509_ALGOR *alg); +int EVP_PKEY_CTX_get_algor(EVP_PKEY_CTX *ctx, X509_ALGOR **alg); + +int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, + int cmd, int p1, void *p2); +int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, + const char *value); +int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype, + int cmd, uint64_t value); + +int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str); +int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex); + +int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md); + +int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx); +void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen); + +EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, + const unsigned char *key, int keylen); +EVP_PKEY *EVP_PKEY_new_raw_private_key_ex(OSSL_LIB_CTX *libctx, + const char *keytype, + const char *propq, + const unsigned char *priv, size_t len); +EVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *e, + const unsigned char *priv, + size_t len); +EVP_PKEY *EVP_PKEY_new_raw_public_key_ex(OSSL_LIB_CTX *libctx, + const char *keytype, const char *propq, + const unsigned char *pub, size_t len); +EVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *e, + const unsigned char *pub, + size_t len); +int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, unsigned char *priv, + size_t *len); +int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub, + size_t *len); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv, + size_t len, const EVP_CIPHER *cipher); +# endif + +void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data); +void *EVP_PKEY_CTX_get_data(const EVP_PKEY_CTX *ctx); +EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx); + +EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx); + +void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data); +void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx); + +int EVP_PKEY_CTX_set_signature(EVP_PKEY_CTX *pctx, + const unsigned char *sig, size_t siglen); + +void EVP_SIGNATURE_free(EVP_SIGNATURE *signature); +int EVP_SIGNATURE_up_ref(EVP_SIGNATURE *signature); +OSSL_PROVIDER *EVP_SIGNATURE_get0_provider(const EVP_SIGNATURE *signature); +EVP_SIGNATURE *EVP_SIGNATURE_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); +int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name); +const char *EVP_SIGNATURE_get0_name(const EVP_SIGNATURE *signature); +const char *EVP_SIGNATURE_get0_description(const EVP_SIGNATURE *signature); +void EVP_SIGNATURE_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_SIGNATURE *signature, + void *data), + void *data); +int EVP_SIGNATURE_names_do_all(const EVP_SIGNATURE *signature, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PARAM *EVP_SIGNATURE_gettable_ctx_params(const EVP_SIGNATURE *sig); +const OSSL_PARAM *EVP_SIGNATURE_settable_ctx_params(const EVP_SIGNATURE *sig); + +void EVP_ASYM_CIPHER_free(EVP_ASYM_CIPHER *cipher); +int EVP_ASYM_CIPHER_up_ref(EVP_ASYM_CIPHER *cipher); +OSSL_PROVIDER *EVP_ASYM_CIPHER_get0_provider(const EVP_ASYM_CIPHER *cipher); +EVP_ASYM_CIPHER *EVP_ASYM_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); +int EVP_ASYM_CIPHER_is_a(const EVP_ASYM_CIPHER *cipher, const char *name); +const char *EVP_ASYM_CIPHER_get0_name(const EVP_ASYM_CIPHER *cipher); +const char *EVP_ASYM_CIPHER_get0_description(const EVP_ASYM_CIPHER *cipher); +void EVP_ASYM_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_ASYM_CIPHER *cipher, + void *arg), + void *arg); +int EVP_ASYM_CIPHER_names_do_all(const EVP_ASYM_CIPHER *cipher, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PARAM *EVP_ASYM_CIPHER_gettable_ctx_params(const EVP_ASYM_CIPHER *ciph); +const OSSL_PARAM *EVP_ASYM_CIPHER_settable_ctx_params(const EVP_ASYM_CIPHER *ciph); + +void EVP_KEM_free(EVP_KEM *wrap); +int EVP_KEM_up_ref(EVP_KEM *wrap); +OSSL_PROVIDER *EVP_KEM_get0_provider(const EVP_KEM *wrap); +EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); +int EVP_KEM_is_a(const EVP_KEM *wrap, const char *name); +const char *EVP_KEM_get0_name(const EVP_KEM *wrap); +const char *EVP_KEM_get0_description(const EVP_KEM *wrap); +void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_KEM *wrap, void *arg), void *arg); +int EVP_KEM_names_do_all(const EVP_KEM *wrap, + void (*fn)(const char *name, void *data), void *data); +const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem); +const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem); + +int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_sign_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); +int EVP_PKEY_sign_init_ex2(EVP_PKEY_CTX *ctx, + EVP_SIGNATURE *algo, const OSSL_PARAM params[]); +int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, + unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen); +int EVP_PKEY_sign_message_init(EVP_PKEY_CTX *ctx, + EVP_SIGNATURE *algo, const OSSL_PARAM params[]); +int EVP_PKEY_sign_message_update(EVP_PKEY_CTX *ctx, + const unsigned char *in, size_t inlen); +int EVP_PKEY_sign_message_final(EVP_PKEY_CTX *ctx, + unsigned char *sig, size_t *siglen); +int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_verify_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); +int EVP_PKEY_verify_init_ex2(EVP_PKEY_CTX *ctx, + EVP_SIGNATURE *algo, const OSSL_PARAM params[]); +int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, + const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen); +int EVP_PKEY_verify_message_init(EVP_PKEY_CTX *ctx, + EVP_SIGNATURE *algo, const OSSL_PARAM params[]); +int EVP_PKEY_verify_message_update(EVP_PKEY_CTX *ctx, + const unsigned char *in, size_t inlen); +int EVP_PKEY_verify_message_final(EVP_PKEY_CTX *ctx); +int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_verify_recover_init_ex(EVP_PKEY_CTX *ctx, + const OSSL_PARAM params[]); +int EVP_PKEY_verify_recover_init_ex2(EVP_PKEY_CTX *ctx, + EVP_SIGNATURE *algo, + const OSSL_PARAM params[]); +int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, + unsigned char *rout, size_t *routlen, + const unsigned char *sig, size_t siglen); +int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_encrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); +int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, + unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); +int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_decrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); +int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, + unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); + +int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_derive_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); +int EVP_PKEY_derive_set_peer_ex(EVP_PKEY_CTX *ctx, EVP_PKEY *peer, + int validate_peer); +int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer); +int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); + +int EVP_PKEY_encapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); +int EVP_PKEY_auth_encapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpriv, + const OSSL_PARAM params[]); +int EVP_PKEY_encapsulate(EVP_PKEY_CTX *ctx, + unsigned char *wrappedkey, size_t *wrappedkeylen, + unsigned char *genkey, size_t *genkeylen); +int EVP_PKEY_decapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); +int EVP_PKEY_auth_decapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpub, + const OSSL_PARAM params[]); +int EVP_PKEY_decapsulate(EVP_PKEY_CTX *ctx, + unsigned char *unwrapped, size_t *unwrappedlen, + const unsigned char *wrapped, size_t wrappedlen); +typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx); + +int EVP_PKEY_fromdata_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_fromdata(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey, int selection, + OSSL_PARAM param[]); +const OSSL_PARAM *EVP_PKEY_fromdata_settable(EVP_PKEY_CTX *ctx, int selection); + +int EVP_PKEY_todata(const EVP_PKEY *pkey, int selection, OSSL_PARAM **params); +int EVP_PKEY_export(const EVP_PKEY *pkey, int selection, + OSSL_CALLBACK *export_cb, void *export_cbarg); + +const OSSL_PARAM *EVP_PKEY_gettable_params(const EVP_PKEY *pkey); +int EVP_PKEY_get_params(const EVP_PKEY *pkey, OSSL_PARAM params[]); +int EVP_PKEY_get_int_param(const EVP_PKEY *pkey, const char *key_name, + int *out); +int EVP_PKEY_get_size_t_param(const EVP_PKEY *pkey, const char *key_name, + size_t *out); +int EVP_PKEY_get_bn_param(const EVP_PKEY *pkey, const char *key_name, + BIGNUM **bn); +int EVP_PKEY_get_utf8_string_param(const EVP_PKEY *pkey, const char *key_name, + char *str, size_t max_buf_sz, size_t *out_sz); +int EVP_PKEY_get_octet_string_param(const EVP_PKEY *pkey, const char *key_name, + unsigned char *buf, size_t max_buf_sz, + size_t *out_sz); + +const OSSL_PARAM *EVP_PKEY_settable_params(const EVP_PKEY *pkey); +int EVP_PKEY_set_params(EVP_PKEY *pkey, OSSL_PARAM params[]); +int EVP_PKEY_set_int_param(EVP_PKEY *pkey, const char *key_name, int in); +int EVP_PKEY_set_size_t_param(EVP_PKEY *pkey, const char *key_name, size_t in); +int EVP_PKEY_set_bn_param(EVP_PKEY *pkey, const char *key_name, + const BIGNUM *bn); +int EVP_PKEY_set_utf8_string_param(EVP_PKEY *pkey, const char *key_name, + const char *str); +int EVP_PKEY_set_octet_string_param(EVP_PKEY *pkey, const char *key_name, + const unsigned char *buf, size_t bsize); + +int EVP_PKEY_get_ec_point_conv_form(const EVP_PKEY *pkey); +int EVP_PKEY_get_field_type(const EVP_PKEY *pkey); + +EVP_PKEY *EVP_PKEY_Q_keygen(OSSL_LIB_CTX *libctx, const char *propq, + const char *type, ...); +int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); +int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx); +int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); +int EVP_PKEY_generate(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); +int EVP_PKEY_check(EVP_PKEY_CTX *ctx); +int EVP_PKEY_public_check(EVP_PKEY_CTX *ctx); +int EVP_PKEY_public_check_quick(EVP_PKEY_CTX *ctx); +int EVP_PKEY_param_check(EVP_PKEY_CTX *ctx); +int EVP_PKEY_param_check_quick(EVP_PKEY_CTX *ctx); +int EVP_PKEY_private_check(EVP_PKEY_CTX *ctx); +int EVP_PKEY_pairwise_check(EVP_PKEY_CTX *ctx); + +# define EVP_PKEY_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EVP_PKEY, l, p, newf, dupf, freef) +int EVP_PKEY_set_ex_data(EVP_PKEY *key, int idx, void *arg); +void *EVP_PKEY_get_ex_data(const EVP_PKEY *key, int idx); + +void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb); +EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx); + +int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth, + int (*init) (EVP_PKEY_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_copy + (EVP_PKEY_METHOD *pmeth, int (*copy) (EVP_PKEY_CTX *dst, + const EVP_PKEY_CTX *src)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_cleanup + (EVP_PKEY_METHOD *pmeth, void (*cleanup) (EVP_PKEY_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_paramgen + (EVP_PKEY_METHOD *pmeth, int (*paramgen_init) (EVP_PKEY_CTX *ctx), + int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_keygen + (EVP_PKEY_METHOD *pmeth, int (*keygen_init) (EVP_PKEY_CTX *ctx), + int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_sign + (EVP_PKEY_METHOD *pmeth, int (*sign_init) (EVP_PKEY_CTX *ctx), + int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verify + (EVP_PKEY_METHOD *pmeth, int (*verify_init) (EVP_PKEY_CTX *ctx), + int (*verify) (EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verify_recover + (EVP_PKEY_METHOD *pmeth, int (*verify_recover_init) (EVP_PKEY_CTX *ctx), + int (*verify_recover) (EVP_PKEY_CTX *ctx, unsigned char *sig, + size_t *siglen, const unsigned char *tbs, + size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_signctx + (EVP_PKEY_METHOD *pmeth, int (*signctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + EVP_MD_CTX *mctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verifyctx + (EVP_PKEY_METHOD *pmeth, int (*verifyctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, + EVP_MD_CTX *mctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_encrypt + (EVP_PKEY_METHOD *pmeth, int (*encrypt_init) (EVP_PKEY_CTX *ctx), + int (*encryptfn) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_decrypt + (EVP_PKEY_METHOD *pmeth, int (*decrypt_init) (EVP_PKEY_CTX *ctx), + int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_derive + (EVP_PKEY_METHOD *pmeth, int (*derive_init) (EVP_PKEY_CTX *ctx), + int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_ctrl + (EVP_PKEY_METHOD *pmeth, int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, + void *p2), + int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digestsign + (EVP_PKEY_METHOD *pmeth, + int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digestverify + (EVP_PKEY_METHOD *pmeth, + int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, + size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_check + (EVP_PKEY_METHOD *pmeth, int (*check) (EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_public_check + (EVP_PKEY_METHOD *pmeth, int (*check) (EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_param_check + (EVP_PKEY_METHOD *pmeth, int (*check) (EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digest_custom + (EVP_PKEY_METHOD *pmeth, int (*digest_custom) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_init + (const EVP_PKEY_METHOD *pmeth, int (**pinit) (EVP_PKEY_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_copy + (const EVP_PKEY_METHOD *pmeth, int (**pcopy) (EVP_PKEY_CTX *dst, + const EVP_PKEY_CTX *src)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_cleanup + (const EVP_PKEY_METHOD *pmeth, void (**pcleanup) (EVP_PKEY_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_paramgen + (const EVP_PKEY_METHOD *pmeth, int (**pparamgen_init) (EVP_PKEY_CTX *ctx), + int (**pparamgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_keygen + (const EVP_PKEY_METHOD *pmeth, int (**pkeygen_init) (EVP_PKEY_CTX *ctx), + int (**pkeygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_sign + (const EVP_PKEY_METHOD *pmeth, int (**psign_init) (EVP_PKEY_CTX *ctx), + int (**psign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verify + (const EVP_PKEY_METHOD *pmeth, int (**pverify_init) (EVP_PKEY_CTX *ctx), + int (**pverify) (EVP_PKEY_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verify_recover + (const EVP_PKEY_METHOD *pmeth, + int (**pverify_recover_init) (EVP_PKEY_CTX *ctx), + int (**pverify_recover) (EVP_PKEY_CTX *ctx, unsigned char *sig, + size_t *siglen, const unsigned char *tbs, + size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_signctx + (const EVP_PKEY_METHOD *pmeth, + int (**psignctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), + int (**psignctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + EVP_MD_CTX *mctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verifyctx + (const EVP_PKEY_METHOD *pmeth, + int (**pverifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), + int (**pverifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, + int siglen, EVP_MD_CTX *mctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_encrypt + (const EVP_PKEY_METHOD *pmeth, int (**pencrypt_init) (EVP_PKEY_CTX *ctx), + int (**pencryptfn) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_decrypt + (const EVP_PKEY_METHOD *pmeth, int (**pdecrypt_init) (EVP_PKEY_CTX *ctx), + int (**pdecrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_derive + (const EVP_PKEY_METHOD *pmeth, int (**pderive_init) (EVP_PKEY_CTX *ctx), + int (**pderive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_ctrl + (const EVP_PKEY_METHOD *pmeth, + int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2), + int (**pctrl_str) (EVP_PKEY_CTX *ctx, const char *type, + const char *value)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digestsign + (const EVP_PKEY_METHOD *pmeth, + int (**digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digestverify + (const EVP_PKEY_METHOD *pmeth, + int (**digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, + size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_check + (const EVP_PKEY_METHOD *pmeth, int (**pcheck) (EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_public_check + (const EVP_PKEY_METHOD *pmeth, int (**pcheck) (EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_param_check + (const EVP_PKEY_METHOD *pmeth, int (**pcheck) (EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digest_custom + (const EVP_PKEY_METHOD *pmeth, + int (**pdigest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)); +# endif + +void EVP_KEYEXCH_free(EVP_KEYEXCH *exchange); +int EVP_KEYEXCH_up_ref(EVP_KEYEXCH *exchange); +EVP_KEYEXCH *EVP_KEYEXCH_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); +OSSL_PROVIDER *EVP_KEYEXCH_get0_provider(const EVP_KEYEXCH *exchange); +int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *keyexch, const char *name); +const char *EVP_KEYEXCH_get0_name(const EVP_KEYEXCH *keyexch); +const char *EVP_KEYEXCH_get0_description(const EVP_KEYEXCH *keyexch); +void EVP_KEYEXCH_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_KEYEXCH *keyexch, void *data), + void *data); +int EVP_KEYEXCH_names_do_all(const EVP_KEYEXCH *keyexch, + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PARAM *EVP_KEYEXCH_gettable_ctx_params(const EVP_KEYEXCH *keyexch); +const OSSL_PARAM *EVP_KEYEXCH_settable_ctx_params(const EVP_KEYEXCH *keyexch); + +void EVP_add_alg_module(void); + +int EVP_PKEY_CTX_set_group_name(EVP_PKEY_CTX *ctx, const char *name); +int EVP_PKEY_CTX_get_group_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen); +int EVP_PKEY_get_group_name(const EVP_PKEY *pkey, char *name, size_t name_sz, + size_t *gname_len); + +OSSL_LIB_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx); +const char *EVP_PKEY_CTX_get0_propq(const EVP_PKEY_CTX *ctx); +const OSSL_PROVIDER *EVP_PKEY_CTX_get0_provider(const EVP_PKEY_CTX *ctx); + +int EVP_SKEY_is_a(const EVP_SKEY *skey, const char *name); +EVP_SKEY *EVP_SKEY_import(OSSL_LIB_CTX *libctx, const char *skeymgmtname, const char *propquery, + int selection, const OSSL_PARAM *params); +EVP_SKEY *EVP_SKEY_generate(OSSL_LIB_CTX *libctx, const char *skeymgmtname, + const char *propquery, const OSSL_PARAM *params); +EVP_SKEY *EVP_SKEY_import_raw_key(OSSL_LIB_CTX *libctx, const char *skeymgmtname, + unsigned char *key, size_t keylen, + const char *propquery); +int EVP_SKEY_get0_raw_key(const EVP_SKEY *skey, const unsigned char **key, + size_t *len); +const char *EVP_SKEY_get0_key_id(const EVP_SKEY *skey); +int EVP_SKEY_export(const EVP_SKEY *skey, int selection, + OSSL_CALLBACK *export_cb, void *export_cbarg); +int EVP_SKEY_up_ref(EVP_SKEY *skey); +void EVP_SKEY_free(EVP_SKEY *skey); +const char *EVP_SKEY_get0_skeymgmt_name(const EVP_SKEY *skey); +const char *EVP_SKEY_get0_provider_name(const EVP_SKEY *skey); +EVP_SKEY *EVP_SKEY_to_provider(EVP_SKEY *skey, OSSL_LIB_CTX *libctx, + OSSL_PROVIDER *prov, const char *propquery); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/evperr.h b/illumos-x86_64/usr/include/openssl-3/evperr.h new file mode 100644 index 00000000..6dc846a2 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/evperr.h @@ -0,0 +1,148 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_EVPERR_H +# define OPENSSL_EVPERR_H +# pragma once + +# include +# include +# include + + + +/* + * EVP reason codes. + */ +# define EVP_R_AES_KEY_SETUP_FAILED 143 +# define EVP_R_ARIA_KEY_SETUP_FAILED 176 +# define EVP_R_BAD_ALGORITHM_NAME 200 +# define EVP_R_BAD_DECRYPT 100 +# define EVP_R_BAD_KEY_LENGTH 195 +# define EVP_R_BUFFER_TOO_SMALL 155 +# define EVP_R_CACHE_CONSTANTS_FAILED 225 +# define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157 +# define EVP_R_CANNOT_GET_PARAMETERS 197 +# define EVP_R_CANNOT_SET_PARAMETERS 198 +# define EVP_R_CIPHER_NOT_GCM_MODE 184 +# define EVP_R_CIPHER_PARAMETER_ERROR 122 +# define EVP_R_COMMAND_NOT_SUPPORTED 147 +# define EVP_R_CONFLICTING_ALGORITHM_NAME 201 +# define EVP_R_COPY_ERROR 173 +# define EVP_R_CTRL_NOT_IMPLEMENTED 132 +# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 +# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 +# define EVP_R_DECODE_ERROR 114 +# define EVP_R_DEFAULT_QUERY_PARSE_ERROR 210 +# define EVP_R_DIFFERENT_KEY_TYPES 101 +# define EVP_R_DIFFERENT_PARAMETERS 153 +# define EVP_R_ERROR_LOADING_SECTION 165 +# define EVP_R_EXPECTING_AN_HMAC_KEY 174 +# define EVP_R_EXPECTING_AN_RSA_KEY 127 +# define EVP_R_EXPECTING_A_DH_KEY 128 +# define EVP_R_EXPECTING_A_DSA_KEY 129 +# define EVP_R_EXPECTING_A_ECX_KEY 219 +# define EVP_R_EXPECTING_A_EC_KEY 142 +# define EVP_R_EXPECTING_A_POLY1305_KEY 164 +# define EVP_R_EXPECTING_A_SIPHASH_KEY 175 +# define EVP_R_FINAL_ERROR 188 +# define EVP_R_GENERATE_ERROR 214 +# define EVP_R_GETTING_ALGORITHMIDENTIFIER_NOT_SUPPORTED 229 +# define EVP_R_GET_RAW_KEY_FAILED 182 +# define EVP_R_ILLEGAL_SCRYPT_PARAMETERS 171 +# define EVP_R_INACCESSIBLE_DOMAIN_PARAMETERS 204 +# define EVP_R_INACCESSIBLE_KEY 203 +# define EVP_R_INITIALIZATION_ERROR 134 +# define EVP_R_INPUT_NOT_INITIALIZED 111 +# define EVP_R_INVALID_CUSTOM_LENGTH 185 +# define EVP_R_INVALID_DIGEST 152 +# define EVP_R_INVALID_IV_LENGTH 194 +# define EVP_R_INVALID_KEY 163 +# define EVP_R_INVALID_KEY_LENGTH 130 +# define EVP_R_INVALID_LENGTH 221 +# define EVP_R_INVALID_NULL_ALGORITHM 218 +# define EVP_R_INVALID_OPERATION 148 +# define EVP_R_INVALID_PROVIDER_FUNCTIONS 193 +# define EVP_R_INVALID_SALT_LENGTH 186 +# define EVP_R_INVALID_SECRET_LENGTH 223 +# define EVP_R_INVALID_SEED_LENGTH 220 +# define EVP_R_INVALID_VALUE 222 +# define EVP_R_KEYMGMT_EXPORT_FAILURE 205 +# define EVP_R_KEY_SETUP_FAILED 180 +# define EVP_R_LOCKING_NOT_SUPPORTED 213 +# define EVP_R_MEMORY_LIMIT_EXCEEDED 172 +# define EVP_R_MESSAGE_DIGEST_IS_NULL 159 +# define EVP_R_METHOD_NOT_SUPPORTED 144 +# define EVP_R_MISSING_PARAMETERS 103 +# define EVP_R_NOT_ABLE_TO_COPY_CTX 190 +# define EVP_R_NOT_XOF_OR_INVALID_LENGTH 178 +# define EVP_R_NO_CIPHER_SET 131 +# define EVP_R_NO_DEFAULT_DIGEST 158 +# define EVP_R_NO_DIGEST_SET 139 +# define EVP_R_NO_IMPORT_FUNCTION 206 +# define EVP_R_NO_KEYMGMT_AVAILABLE 199 +# define EVP_R_NO_KEYMGMT_PRESENT 196 +# define EVP_R_NO_KEY_SET 154 +# define EVP_R_NO_OPERATION_SET 149 +# define EVP_R_NULL_MAC_PKEY_CTX 208 +# define EVP_R_ONLY_ONESHOT_SUPPORTED 177 +# define EVP_R_OPERATION_NOT_INITIALIZED 151 +# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150 +# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_SIGNATURE_TYPE 226 +# define EVP_R_OUTPUT_WOULD_OVERFLOW 202 +# define EVP_R_PARAMETER_TOO_LARGE 187 +# define EVP_R_PARTIALLY_OVERLAPPING 162 +# define EVP_R_PBKDF2_ERROR 181 +# define EVP_R_PIPELINE_NOT_SUPPORTED 230 +# define EVP_R_PKEY_APPLICATION_ASN1_METHOD_ALREADY_REGISTERED 179 +# define EVP_R_PRIVATE_KEY_DECODE_ERROR 145 +# define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146 +# define EVP_R_PROVIDER_ASYM_CIPHER_FAILURE 232 +# define EVP_R_PROVIDER_ASYM_CIPHER_NOT_SUPPORTED 235 +# define EVP_R_PROVIDER_KEYMGMT_FAILURE 233 +# define EVP_R_PROVIDER_KEYMGMT_NOT_SUPPORTED 236 +# define EVP_R_PROVIDER_SIGNATURE_FAILURE 234 +# define EVP_R_PROVIDER_SIGNATURE_NOT_SUPPORTED 237 +# define EVP_R_PUBLIC_KEY_NOT_RSA 106 +# define EVP_R_SETTING_XOF_FAILED 227 +# define EVP_R_SET_DEFAULT_PROPERTY_FAILURE 209 +# define EVP_R_SIGNATURE_TYPE_AND_KEY_TYPE_INCOMPATIBLE 228 +# define EVP_R_TOO_MANY_PIPES 231 +# define EVP_R_TOO_MANY_RECORDS 183 +# define EVP_R_UNABLE_TO_ENABLE_LOCKING 212 +# define EVP_R_UNABLE_TO_GET_MAXIMUM_REQUEST_SIZE 215 +# define EVP_R_UNABLE_TO_GET_RANDOM_STRENGTH 216 +# define EVP_R_UNABLE_TO_LOCK_CONTEXT 211 +# define EVP_R_UNABLE_TO_SET_CALLBACKS 217 +# define EVP_R_UNKNOWN_BITS 166 +# define EVP_R_UNKNOWN_CIPHER 160 +# define EVP_R_UNKNOWN_DIGEST 161 +# define EVP_R_UNKNOWN_KEY_TYPE 207 +# define EVP_R_UNKNOWN_MAX_SIZE 167 +# define EVP_R_UNKNOWN_OPTION 169 +# define EVP_R_UNKNOWN_PBE_ALGORITHM 121 +# define EVP_R_UNKNOWN_SECURITY_BITS 168 +# define EVP_R_UNSUPPORTED_ALGORITHM 156 +# define EVP_R_UNSUPPORTED_CIPHER 107 +# define EVP_R_UNSUPPORTED_KEYLENGTH 123 +# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 +# define EVP_R_UNSUPPORTED_KEY_SIZE 108 +# define EVP_R_UNSUPPORTED_KEY_TYPE 224 +# define EVP_R_UNSUPPORTED_NUMBER_OF_ROUNDS 135 +# define EVP_R_UNSUPPORTED_PRF 125 +# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 +# define EVP_R_UNSUPPORTED_SALT_TYPE 126 +# define EVP_R_UPDATE_ERROR 189 +# define EVP_R_WRAP_MODE_NOT_ALLOWED 170 +# define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 +# define EVP_R_XTS_DATA_UNIT_IS_TOO_LARGE 191 +# define EVP_R_XTS_DUPLICATED_KEYS 192 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/fips_names.h b/illumos-x86_64/usr/include/openssl-3/fips_names.h new file mode 100644 index 00000000..fa481fc6 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/fips_names.h @@ -0,0 +1,50 @@ +/* + * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_FIPS_NAMES_H +# define OPENSSL_FIPS_NAMES_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * Parameter names that the FIPS Provider defines + * All parameters are of type: OSSL_PARAM_UTF8_STRING + */ + +/* The following 4 Parameters are used for FIPS Self Testing */ + +/* The calculated MAC of the module file */ +# define OSSL_PROV_FIPS_PARAM_MODULE_MAC "module-mac" +/* The Version number for the fips install process */ +# define OSSL_PROV_FIPS_PARAM_INSTALL_VERSION "install-version" +/* The calculated MAC of the install status indicator */ +# define OSSL_PROV_FIPS_PARAM_INSTALL_MAC "install-mac" +/* The install status indicator */ +# define OSSL_PROV_FIPS_PARAM_INSTALL_STATUS "install-status" + +/* + * A boolean that determines if the FIPS conditional test errors result in + * the module entering an error state. + * Type: OSSL_PARAM_UTF8_STRING + */ +# define OSSL_PROV_FIPS_PARAM_CONDITIONAL_ERRORS "conditional-errors" + +/* The following are provided for backwards compatibility */ +# define OSSL_PROV_FIPS_PARAM_SECURITY_CHECKS OSSL_PROV_PARAM_SECURITY_CHECKS +# define OSSL_PROV_FIPS_PARAM_TLS1_PRF_EMS_CHECK OSSL_PROV_PARAM_TLS1_PRF_EMS_CHECK +# define OSSL_PROV_FIPS_PARAM_DRBG_TRUNC_DIGEST OSSL_PROV_PARAM_DRBG_TRUNC_DIGEST + +# ifdef __cplusplus +} +# endif + +#endif /* OPENSSL_FIPS_NAMES_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/fipskey.h b/illumos-x86_64/usr/include/openssl-3/fipskey.h new file mode 100644 index 00000000..620812bf --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/fipskey.h @@ -0,0 +1,41 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/fipskey.h.in + * + * Copyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_FIPSKEY_H +# define OPENSSL_FIPSKEY_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * The FIPS validation HMAC key, usable as an array initializer. + */ +#define FIPS_KEY_ELEMENTS \ + 0xf4, 0x55, 0x66, 0x50, 0xac, 0x31, 0xd3, 0x54, 0x61, 0x61, 0x0b, 0xac, 0x4e, 0xd8, 0x1b, 0x1a, 0x18, 0x1b, 0x2d, 0x8a, 0x43, 0xea, 0x28, 0x54, 0xcb, 0xae, 0x22, 0xca, 0x74, 0x56, 0x08, 0x13 + +/* + * The FIPS validation key, as a string. + */ +#define FIPS_KEY_STRING "f4556650ac31d35461610bac4ed81b1a181b2d8a43ea2854cbae22ca74560813" + +/* + * The FIPS provider vendor name, as a string. + */ +#define FIPS_VENDOR "OpenSSL non-compliant FIPS Provider" + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/hmac.h b/illumos-x86_64/usr/include/openssl-3/hmac.h new file mode 100644 index 00000000..f9e1bff3 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/hmac.h @@ -0,0 +1,62 @@ +/* + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_HMAC_H +# define OPENSSL_HMAC_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_HMAC_H +# endif + +# include + +# include + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HMAC_MAX_MD_CBLOCK 200 /* Deprecated */ +# endif + +# ifdef __cplusplus +extern "C" { +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 size_t HMAC_size(const HMAC_CTX *e); +OSSL_DEPRECATEDIN_3_0 HMAC_CTX *HMAC_CTX_new(void); +OSSL_DEPRECATEDIN_3_0 int HMAC_CTX_reset(HMAC_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_free(HMAC_CTX *ctx); +# endif +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur int HMAC_Init(HMAC_CTX *ctx, + const void *key, int len, + const EVP_MD *md); +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md, ENGINE *impl); +OSSL_DEPRECATEDIN_3_0 int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, + size_t len); +OSSL_DEPRECATEDIN_3_0 int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, + unsigned int *len); +OSSL_DEPRECATEDIN_3_0 __owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); +OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); +OSSL_DEPRECATEDIN_3_0 const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); +# endif + +unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, + const unsigned char *data, size_t data_len, + unsigned char *md, unsigned int *md_len); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/hpke.h b/illumos-x86_64/usr/include/openssl-3/hpke.h new file mode 100644 index 00000000..482acd22 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/hpke.h @@ -0,0 +1,169 @@ +/* + * Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* APIs and data structures for HPKE (RFC9180) */ +#ifndef OSSL_HPKE_H +# define OSSL_HPKE_H +# pragma once + +# include + +/* HPKE modes */ +# define OSSL_HPKE_MODE_BASE 0 /* Base mode */ +# define OSSL_HPKE_MODE_PSK 1 /* Pre-shared key mode */ +# define OSSL_HPKE_MODE_AUTH 2 /* Authenticated mode */ +# define OSSL_HPKE_MODE_PSKAUTH 3 /* PSK+authenticated mode */ + +/* + * Max for ikm, psk, pskid, info and exporter contexts. + * RFC9180, section 7.2.1 RECOMMENDS 64 octets but we have test vectors from + * Appendix A.6.1 with a 66 octet IKM so we'll allow that. + */ +# define OSSL_HPKE_MAX_PARMLEN 66 +# define OSSL_HPKE_MIN_PSKLEN 32 +# define OSSL_HPKE_MAX_INFOLEN 1024 + +/* + * The (16bit) HPKE algorithm ID IANA codepoints + * If/when new IANA codepoints are added there are tables in + * crypto/hpke/hpke_util.c that must also be updated. + */ +# define OSSL_HPKE_KEM_ID_RESERVED 0x0000 /* not used */ +# define OSSL_HPKE_KEM_ID_P256 0x0010 /* NIST P-256 */ +# define OSSL_HPKE_KEM_ID_P384 0x0011 /* NIST P-384 */ +# define OSSL_HPKE_KEM_ID_P521 0x0012 /* NIST P-521 */ +# define OSSL_HPKE_KEM_ID_X25519 0x0020 /* Curve25519 */ +# define OSSL_HPKE_KEM_ID_X448 0x0021 /* Curve448 */ + +# define OSSL_HPKE_KDF_ID_RESERVED 0x0000 /* not used */ +# define OSSL_HPKE_KDF_ID_HKDF_SHA256 0x0001 /* HKDF-SHA256 */ +# define OSSL_HPKE_KDF_ID_HKDF_SHA384 0x0002 /* HKDF-SHA384 */ +# define OSSL_HPKE_KDF_ID_HKDF_SHA512 0x0003 /* HKDF-SHA512 */ + +# define OSSL_HPKE_AEAD_ID_RESERVED 0x0000 /* not used */ +# define OSSL_HPKE_AEAD_ID_AES_GCM_128 0x0001 /* AES-GCM-128 */ +# define OSSL_HPKE_AEAD_ID_AES_GCM_256 0x0002 /* AES-GCM-256 */ +# define OSSL_HPKE_AEAD_ID_CHACHA_POLY1305 0x0003 /* Chacha20-Poly1305 */ +# define OSSL_HPKE_AEAD_ID_EXPORTONLY 0xFFFF /* export-only fake ID */ + +/* strings for suite components */ +# define OSSL_HPKE_KEMSTR_P256 "P-256" /* KEM id 0x10 */ +# define OSSL_HPKE_KEMSTR_P384 "P-384" /* KEM id 0x11 */ +# define OSSL_HPKE_KEMSTR_P521 "P-521" /* KEM id 0x12 */ +# define OSSL_HPKE_KEMSTR_X25519 "X25519" /* KEM id 0x20 */ +# define OSSL_HPKE_KEMSTR_X448 "X448" /* KEM id 0x21 */ +# define OSSL_HPKE_KDFSTR_256 "hkdf-sha256" /* KDF id 1 */ +# define OSSL_HPKE_KDFSTR_384 "hkdf-sha384" /* KDF id 2 */ +# define OSSL_HPKE_KDFSTR_512 "hkdf-sha512" /* KDF id 3 */ +# define OSSL_HPKE_AEADSTR_AES128GCM "aes-128-gcm" /* AEAD id 1 */ +# define OSSL_HPKE_AEADSTR_AES256GCM "aes-256-gcm" /* AEAD id 2 */ +# define OSSL_HPKE_AEADSTR_CP "chacha20-poly1305" /* AEAD id 3 */ +# define OSSL_HPKE_AEADSTR_EXP "exporter" /* AEAD id 0xff */ + +/* + * Roles for use in creating an OSSL_HPKE_CTX, most + * important use of this is to control nonce reuse. + */ +# define OSSL_HPKE_ROLE_SENDER 0 +# define OSSL_HPKE_ROLE_RECEIVER 1 + +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct { + uint16_t kem_id; /* Key Encapsulation Method id */ + uint16_t kdf_id; /* Key Derivation Function id */ + uint16_t aead_id; /* AEAD alg id */ +} OSSL_HPKE_SUITE; + +/** + * Suite constants, use this like: + * OSSL_HPKE_SUITE myvar = OSSL_HPKE_SUITE_DEFAULT; + */ +# ifndef OPENSSL_NO_ECX +# define OSSL_HPKE_SUITE_DEFAULT \ + {\ + OSSL_HPKE_KEM_ID_X25519, \ + OSSL_HPKE_KDF_ID_HKDF_SHA256, \ + OSSL_HPKE_AEAD_ID_AES_GCM_128 \ + } +# else +# define OSSL_HPKE_SUITE_DEFAULT \ + {\ + OSSL_HPKE_KEM_ID_P256, \ + OSSL_HPKE_KDF_ID_HKDF_SHA256, \ + OSSL_HPKE_AEAD_ID_AES_GCM_128 \ + } +#endif + +typedef struct ossl_hpke_ctx_st OSSL_HPKE_CTX; + +OSSL_HPKE_CTX *OSSL_HPKE_CTX_new(int mode, OSSL_HPKE_SUITE suite, int role, + OSSL_LIB_CTX *libctx, const char *propq); +void OSSL_HPKE_CTX_free(OSSL_HPKE_CTX *ctx); + +int OSSL_HPKE_encap(OSSL_HPKE_CTX *ctx, + unsigned char *enc, size_t *enclen, + const unsigned char *pub, size_t publen, + const unsigned char *info, size_t infolen); +int OSSL_HPKE_seal(OSSL_HPKE_CTX *ctx, + unsigned char *ct, size_t *ctlen, + const unsigned char *aad, size_t aadlen, + const unsigned char *pt, size_t ptlen); + +int OSSL_HPKE_keygen(OSSL_HPKE_SUITE suite, + unsigned char *pub, size_t *publen, EVP_PKEY **priv, + const unsigned char *ikm, size_t ikmlen, + OSSL_LIB_CTX *libctx, const char *propq); +int OSSL_HPKE_decap(OSSL_HPKE_CTX *ctx, + const unsigned char *enc, size_t enclen, + EVP_PKEY *recippriv, + const unsigned char *info, size_t infolen); +int OSSL_HPKE_open(OSSL_HPKE_CTX *ctx, + unsigned char *pt, size_t *ptlen, + const unsigned char *aad, size_t aadlen, + const unsigned char *ct, size_t ctlen); + +int OSSL_HPKE_export(OSSL_HPKE_CTX *ctx, + unsigned char *secret, + size_t secretlen, + const unsigned char *label, + size_t labellen); + +int OSSL_HPKE_CTX_set1_authpriv(OSSL_HPKE_CTX *ctx, EVP_PKEY *priv); +int OSSL_HPKE_CTX_set1_authpub(OSSL_HPKE_CTX *ctx, + const unsigned char *pub, + size_t publen); +int OSSL_HPKE_CTX_set1_psk(OSSL_HPKE_CTX *ctx, + const char *pskid, + const unsigned char *psk, size_t psklen); + +int OSSL_HPKE_CTX_set1_ikme(OSSL_HPKE_CTX *ctx, + const unsigned char *ikme, size_t ikmelen); + +int OSSL_HPKE_CTX_set_seq(OSSL_HPKE_CTX *ctx, uint64_t seq); +int OSSL_HPKE_CTX_get_seq(OSSL_HPKE_CTX *ctx, uint64_t *seq); + +int OSSL_HPKE_suite_check(OSSL_HPKE_SUITE suite); +int OSSL_HPKE_get_grease_value(const OSSL_HPKE_SUITE *suite_in, + OSSL_HPKE_SUITE *suite, + unsigned char *enc, size_t *enclen, + unsigned char *ct, size_t ctlen, + OSSL_LIB_CTX *libctx, const char *propq); +int OSSL_HPKE_str2suite(const char *str, OSSL_HPKE_SUITE *suite); +size_t OSSL_HPKE_get_ciphertext_size(OSSL_HPKE_SUITE suite, size_t clearlen); +size_t OSSL_HPKE_get_public_encap_size(OSSL_HPKE_SUITE suite); +size_t OSSL_HPKE_get_recommended_ikmelen(OSSL_HPKE_SUITE suite); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/http.h b/illumos-x86_64/usr/include/openssl-3/http.h new file mode 100644 index 00000000..d7aa5707 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/http.h @@ -0,0 +1,119 @@ +/* + * Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Siemens AG 2018-2020 + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_HTTP_H +# define OPENSSL_HTTP_H +# pragma once + +# include + +# include +# include +# include + + +# ifdef __cplusplus +extern "C" { +# endif + +# define OSSL_HTTP_NAME "http" +# define OSSL_HTTPS_NAME "https" +# define OSSL_HTTP_PREFIX OSSL_HTTP_NAME"://" +# define OSSL_HTTPS_PREFIX OSSL_HTTPS_NAME"://" +# define OSSL_HTTP_PORT "80" +# define OSSL_HTTPS_PORT "443" +# define OPENSSL_NO_PROXY "NO_PROXY" +# define OPENSSL_HTTP_PROXY "HTTP_PROXY" +# define OPENSSL_HTTPS_PROXY "HTTPS_PROXY" + +/* We want to have this even in case of OPENSSL_NO_HTTP */ +int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost, + char **pport, int *pport_num, + char **ppath, char **pquery, char **pfrag); + +# ifndef OPENSSL_NO_HTTP + +# define OSSL_HTTP_DEFAULT_MAX_LINE_LEN (4 * 1024) +# define OSSL_HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024) +# define OSSL_HTTP_DEFAULT_MAX_CRL_LEN (32 * 1024 * 1024) +# define OSSL_HTTP_DEFAULT_MAX_RESP_HDR_LINES 256 + + +/* Low-level HTTP API */ +OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, int buf_size); +void OSSL_HTTP_REQ_CTX_free(OSSL_HTTP_REQ_CTX *rctx); +int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX *rctx, int method_POST, + const char *server, const char *port, + const char *path); +int OSSL_HTTP_REQ_CTX_add1_header(OSSL_HTTP_REQ_CTX *rctx, + const char *name, const char *value); +int OSSL_HTTP_REQ_CTX_set_expected(OSSL_HTTP_REQ_CTX *rctx, + const char *content_type, int asn1, + int timeout, int keep_alive); +int OSSL_HTTP_REQ_CTX_set1_req(OSSL_HTTP_REQ_CTX *rctx, const char *content_type, + const ASN1_ITEM *it, const ASN1_VALUE *req); +int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx); +int OSSL_HTTP_REQ_CTX_nbio_d2i(OSSL_HTTP_REQ_CTX *rctx, + ASN1_VALUE **pval, const ASN1_ITEM *it); +BIO *OSSL_HTTP_REQ_CTX_exchange(OSSL_HTTP_REQ_CTX *rctx); +BIO *OSSL_HTTP_REQ_CTX_get0_mem_bio(const OSSL_HTTP_REQ_CTX *rctx); +size_t OSSL_HTTP_REQ_CTX_get_resp_len(const OSSL_HTTP_REQ_CTX *rctx); +void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX *rctx, + unsigned long len); +void OSSL_HTTP_REQ_CTX_set_max_response_hdr_lines(OSSL_HTTP_REQ_CTX *rctx, + size_t count); +int OSSL_HTTP_is_alive(const OSSL_HTTP_REQ_CTX *rctx); + +/* High-level HTTP API */ +typedef BIO *(*OSSL_HTTP_bio_cb_t)(BIO *bio, void *arg, int connect, int detail); +OSSL_HTTP_REQ_CTX *OSSL_HTTP_open(const char *server, const char *port, + const char *proxy, const char *no_proxy, + int use_ssl, BIO *bio, BIO *rbio, + OSSL_HTTP_bio_cb_t bio_update_fn, void *arg, + int buf_size, int overall_timeout); +int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port, + const char *proxyuser, const char *proxypass, + int timeout, BIO *bio_err, const char *prog); +int OSSL_HTTP_set1_request(OSSL_HTTP_REQ_CTX *rctx, const char *path, + const STACK_OF(CONF_VALUE) *headers, + const char *content_type, BIO *req, + const char *expected_content_type, int expect_asn1, + size_t max_resp_len, int timeout, int keep_alive); +BIO *OSSL_HTTP_exchange(OSSL_HTTP_REQ_CTX *rctx, char **redirection_url); +BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy, + BIO *bio, BIO *rbio, + OSSL_HTTP_bio_cb_t bio_update_fn, void *arg, + int buf_size, const STACK_OF(CONF_VALUE) *headers, + const char *expected_content_type, int expect_asn1, + size_t max_resp_len, int timeout); +BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx, + const char *server, const char *port, + const char *path, int use_ssl, + const char *proxy, const char *no_proxy, + BIO *bio, BIO *rbio, + OSSL_HTTP_bio_cb_t bio_update_fn, void *arg, + int buf_size, const STACK_OF(CONF_VALUE) *headers, + const char *content_type, BIO *req, + const char *expected_content_type, int expect_asn1, + size_t max_resp_len, int timeout, int keep_alive); +int OSSL_HTTP_close(OSSL_HTTP_REQ_CTX *rctx, int ok); + +/* Auxiliary functions */ +int OSSL_HTTP_parse_url(const char *url, int *pssl, char **puser, char **phost, + char **pport, int *pport_num, + char **ppath, char **pquery, char **pfrag); +const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy, + const char *server, int use_ssl); + +# endif /* !defined(OPENSSL_NO_HTTP) */ +# ifdef __cplusplus +} +# endif +#endif /* !defined(OPENSSL_HTTP_H) */ diff --git a/illumos-x86_64/usr/include/openssl-3/httperr.h b/illumos-x86_64/usr/include/openssl-3/httperr.h new file mode 100644 index 00000000..ae7f00ca --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/httperr.h @@ -0,0 +1,56 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_HTTPERR_H +# define OPENSSL_HTTPERR_H +# pragma once + +# include +# include +# include + + + +/* + * HTTP reason codes. + */ +# define HTTP_R_ASN1_LEN_EXCEEDS_MAX_RESP_LEN 108 +# define HTTP_R_CONNECT_FAILURE 100 +# define HTTP_R_ERROR_PARSING_ASN1_LENGTH 109 +# define HTTP_R_ERROR_PARSING_CONTENT_LENGTH 119 +# define HTTP_R_ERROR_PARSING_URL 101 +# define HTTP_R_ERROR_RECEIVING 103 +# define HTTP_R_ERROR_SENDING 102 +# define HTTP_R_FAILED_READING_DATA 128 +# define HTTP_R_HEADER_PARSE_ERROR 126 +# define HTTP_R_INCONSISTENT_CONTENT_LENGTH 120 +# define HTTP_R_INVALID_PORT_NUMBER 123 +# define HTTP_R_INVALID_URL_PATH 125 +# define HTTP_R_INVALID_URL_SCHEME 124 +# define HTTP_R_MAX_RESP_LEN_EXCEEDED 117 +# define HTTP_R_MISSING_ASN1_ENCODING 110 +# define HTTP_R_MISSING_CONTENT_TYPE 121 +# define HTTP_R_MISSING_REDIRECT_LOCATION 111 +# define HTTP_R_RECEIVED_ERROR 105 +# define HTTP_R_RECEIVED_WRONG_HTTP_VERSION 106 +# define HTTP_R_REDIRECTION_FROM_HTTPS_TO_HTTP 112 +# define HTTP_R_REDIRECTION_NOT_ENABLED 116 +# define HTTP_R_RESPONSE_LINE_TOO_LONG 113 +# define HTTP_R_RESPONSE_PARSE_ERROR 104 +# define HTTP_R_RESPONSE_TOO_MANY_HDRLINES 130 +# define HTTP_R_RETRY_TIMEOUT 129 +# define HTTP_R_SERVER_CANCELED_CONNECTION 127 +# define HTTP_R_SOCK_NOT_SUPPORTED 122 +# define HTTP_R_STATUS_CODE_UNSUPPORTED 114 +# define HTTP_R_TLS_NOT_ENABLED 107 +# define HTTP_R_TOO_MANY_REDIRECTIONS 115 +# define HTTP_R_UNEXPECTED_CONTENT_TYPE 118 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/idea.h b/illumos-x86_64/usr/include/openssl-3/idea.h new file mode 100644 index 00000000..1f9bb3b3 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/idea.h @@ -0,0 +1,82 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_IDEA_H +# define OPENSSL_IDEA_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_IDEA_H +# endif + +# include + +# ifndef OPENSSL_NO_IDEA +# ifdef __cplusplus +extern "C" { +# endif + +# define IDEA_BLOCK 8 +# define IDEA_KEY_LENGTH 16 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 + +typedef unsigned int IDEA_INT; + +# define IDEA_ENCRYPT 1 +# define IDEA_DECRYPT 0 + +typedef struct idea_key_st { + IDEA_INT data[9][6]; +} IDEA_KEY_SCHEDULE; +#endif +#ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 const char *IDEA_options(void); +OSSL_DEPRECATEDIN_3_0 void IDEA_ecb_encrypt(const unsigned char *in, + unsigned char *out, + IDEA_KEY_SCHEDULE *ks); +OSSL_DEPRECATEDIN_3_0 void IDEA_set_encrypt_key(const unsigned char *key, + IDEA_KEY_SCHEDULE *ks); +OSSL_DEPRECATEDIN_3_0 void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, + IDEA_KEY_SCHEDULE *dk); +OSSL_DEPRECATEDIN_3_0 void IDEA_cbc_encrypt(const unsigned char *in, + unsigned char *out, long length, + IDEA_KEY_SCHEDULE *ks, + unsigned char *iv, int enc); +OSSL_DEPRECATEDIN_3_0 void IDEA_cfb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + IDEA_KEY_SCHEDULE *ks, + unsigned char *iv, int *num, + int enc); +OSSL_DEPRECATEDIN_3_0 void IDEA_ofb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + IDEA_KEY_SCHEDULE *ks, + unsigned char *iv, int *num); +OSSL_DEPRECATEDIN_3_0 void IDEA_encrypt(unsigned long *in, + IDEA_KEY_SCHEDULE *ks); +#endif + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define idea_options IDEA_options +# define idea_ecb_encrypt IDEA_ecb_encrypt +# define idea_set_encrypt_key IDEA_set_encrypt_key +# define idea_set_decrypt_key IDEA_set_decrypt_key +# define idea_cbc_encrypt IDEA_cbc_encrypt +# define idea_cfb64_encrypt IDEA_cfb64_encrypt +# define idea_ofb64_encrypt IDEA_ofb64_encrypt +# define idea_encrypt IDEA_encrypt +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/indicator.h b/illumos-x86_64/usr/include/openssl-3/indicator.h new file mode 100644 index 00000000..3ea01221 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/indicator.h @@ -0,0 +1,31 @@ +/* + * Copyright 2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_INDICATOR_H +# define OPENSSL_INDICATOR_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +#include + +typedef int (OSSL_INDICATOR_CALLBACK)(const char *type, const char *desc, + const OSSL_PARAM params[]); + +void OSSL_INDICATOR_set_callback(OSSL_LIB_CTX *libctx, + OSSL_INDICATOR_CALLBACK *cb); +void OSSL_INDICATOR_get_callback(OSSL_LIB_CTX *libctx, + OSSL_INDICATOR_CALLBACK **cb); + +# ifdef __cplusplus +} +# endif +#endif /* OPENSSL_INDICATOR_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/kdf.h b/illumos-x86_64/usr/include/openssl-3/kdf.h new file mode 100644 index 00000000..0983230a --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/kdf.h @@ -0,0 +1,138 @@ +/* + * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_KDF_H +# define OPENSSL_KDF_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_KDF_H +# endif + +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +int EVP_KDF_up_ref(EVP_KDF *kdf); +void EVP_KDF_free(EVP_KDF *kdf); +EVP_KDF *EVP_KDF_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, + const char *properties); + +EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf); +void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx); +EVP_KDF_CTX *EVP_KDF_CTX_dup(const EVP_KDF_CTX *src); +const char *EVP_KDF_get0_description(const EVP_KDF *kdf); +int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name); +const char *EVP_KDF_get0_name(const EVP_KDF *kdf); +const OSSL_PROVIDER *EVP_KDF_get0_provider(const EVP_KDF *kdf); +const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx); + +void EVP_KDF_CTX_reset(EVP_KDF_CTX *ctx); +size_t EVP_KDF_CTX_get_kdf_size(EVP_KDF_CTX *ctx); +int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen, + const OSSL_PARAM params[]); +int EVP_KDF_get_params(EVP_KDF *kdf, OSSL_PARAM params[]); +int EVP_KDF_CTX_get_params(EVP_KDF_CTX *ctx, OSSL_PARAM params[]); +int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]); +const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf); +const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf); +const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf); +const OSSL_PARAM *EVP_KDF_CTX_gettable_params(EVP_KDF_CTX *ctx); +const OSSL_PARAM *EVP_KDF_CTX_settable_params(EVP_KDF_CTX *ctx); + +void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_KDF *kdf, void *arg), + void *arg); +int EVP_KDF_names_do_all(const EVP_KDF *kdf, + void (*fn)(const char *name, void *data), + void *data); + +# define EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND 0 +# define EVP_KDF_HKDF_MODE_EXTRACT_ONLY 1 +# define EVP_KDF_HKDF_MODE_EXPAND_ONLY 2 + +#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV 65 +#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI 66 +#define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV 67 +#define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI 68 +#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV 69 +#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI 70 + +/**** The legacy PKEY-based KDF API follows. ****/ + +# define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL) +# define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1) +# define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2) +# define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3) +# define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4) +# define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5) +# define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6) +# define EVP_PKEY_CTRL_HKDF_MODE (EVP_PKEY_ALG_CTRL + 7) +# define EVP_PKEY_CTRL_PASS (EVP_PKEY_ALG_CTRL + 8) +# define EVP_PKEY_CTRL_SCRYPT_SALT (EVP_PKEY_ALG_CTRL + 9) +# define EVP_PKEY_CTRL_SCRYPT_N (EVP_PKEY_ALG_CTRL + 10) +# define EVP_PKEY_CTRL_SCRYPT_R (EVP_PKEY_ALG_CTRL + 11) +# define EVP_PKEY_CTRL_SCRYPT_P (EVP_PKEY_ALG_CTRL + 12) +# define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES (EVP_PKEY_ALG_CTRL + 13) + +# define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND \ + EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND +# define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY \ + EVP_KDF_HKDF_MODE_EXTRACT_ONLY +# define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY \ + EVP_KDF_HKDF_MODE_EXPAND_ONLY + +int EVP_PKEY_CTX_set_tls1_prf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); + +int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx, + const unsigned char *sec, int seclen); + +int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx, + const unsigned char *seed, int seedlen); + +int EVP_PKEY_CTX_set_hkdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); + +int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *ctx, + const unsigned char *salt, int saltlen); + +int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx, + const unsigned char *key, int keylen); + +int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx, + const unsigned char *info, int infolen); + +int EVP_PKEY_CTX_set_hkdf_mode(EVP_PKEY_CTX *ctx, int mode); +# define EVP_PKEY_CTX_hkdf_mode EVP_PKEY_CTX_set_hkdf_mode + +int EVP_PKEY_CTX_set1_pbe_pass(EVP_PKEY_CTX *ctx, const char *pass, + int passlen); + +int EVP_PKEY_CTX_set1_scrypt_salt(EVP_PKEY_CTX *ctx, + const unsigned char *salt, int saltlen); + +int EVP_PKEY_CTX_set_scrypt_N(EVP_PKEY_CTX *ctx, uint64_t n); + +int EVP_PKEY_CTX_set_scrypt_r(EVP_PKEY_CTX *ctx, uint64_t r); + +int EVP_PKEY_CTX_set_scrypt_p(EVP_PKEY_CTX *ctx, uint64_t p); + +int EVP_PKEY_CTX_set_scrypt_maxmem_bytes(EVP_PKEY_CTX *ctx, + uint64_t maxmem_bytes); + + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/kdferr.h b/illumos-x86_64/usr/include/openssl-3/kdferr.h new file mode 100644 index 00000000..963d766d --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/kdferr.h @@ -0,0 +1,16 @@ +/* + * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_KDFERR_H +# define OPENSSL_KDFERR_H +# pragma once + +#include + +#endif /* !defined(OPENSSL_KDFERR_H) */ diff --git a/illumos-x86_64/usr/include/openssl-3/lhash.h b/illumos-x86_64/usr/include/openssl-3/lhash.h new file mode 100644 index 00000000..62c55b20 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/lhash.h @@ -0,0 +1,398 @@ +/* + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +/* + * Header for dynamic hash table routines Author - Eric Young + */ + +#ifndef OPENSSL_LHASH_H +# define OPENSSL_LHASH_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_LHASH_H +# endif + +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct lhash_node_st OPENSSL_LH_NODE; +typedef int (*OPENSSL_LH_COMPFUNC) (const void *, const void *); +typedef int (*OPENSSL_LH_COMPFUNCTHUNK) (const void *, const void *, OPENSSL_LH_COMPFUNC cfn); +typedef unsigned long (*OPENSSL_LH_HASHFUNC) (const void *); +typedef unsigned long (*OPENSSL_LH_HASHFUNCTHUNK) (const void *, OPENSSL_LH_HASHFUNC hfn); +typedef void (*OPENSSL_LH_DOALL_FUNC) (void *); +typedef void (*OPENSSL_LH_DOALL_FUNC_THUNK) (void *, OPENSSL_LH_DOALL_FUNC doall); +typedef void (*OPENSSL_LH_DOALL_FUNCARG) (void *, void *); +typedef void (*OPENSSL_LH_DOALL_FUNCARG_THUNK) (void *, void *, OPENSSL_LH_DOALL_FUNCARG doall); +typedef struct lhash_st OPENSSL_LHASH; + +/* + * Macros for declaring and implementing type-safe wrappers for LHASH + * callbacks. This way, callbacks can be provided to LHASH structures without + * function pointer casting and the macro-defined callbacks provide + * per-variable casting before deferring to the underlying type-specific + * callbacks. NB: It is possible to place a "static" in front of both the + * DECLARE and IMPLEMENT macros if the functions are strictly internal. + */ + +/* First: "hash" functions */ +# define DECLARE_LHASH_HASH_FN(name, o_type) \ + unsigned long name##_LHASH_HASH(const void *); +# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \ + unsigned long name##_LHASH_HASH(const void *arg) { \ + const o_type *a = arg; \ + return name##_hash(a); } +# define LHASH_HASH_FN(name) name##_LHASH_HASH + +/* Second: "compare" functions */ +# define DECLARE_LHASH_COMP_FN(name, o_type) \ + int name##_LHASH_COMP(const void *, const void *); +# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \ + int name##_LHASH_COMP(const void *arg1, const void *arg2) { \ + const o_type *a = arg1; \ + const o_type *b = arg2; \ + return name##_cmp(a,b); } +# define LHASH_COMP_FN(name) name##_LHASH_COMP + +/* Fourth: "doall_arg" functions */ +# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ + void name##_LHASH_DOALL_ARG(void *, void *); +# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ + void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ + o_type *a = arg1; \ + a_type *b = arg2; \ + name##_doall_arg(a, b); } +# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG + + +# define LH_LOAD_MULT 256 + +int OPENSSL_LH_error(OPENSSL_LHASH *lh); +OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c); +OPENSSL_LHASH *OPENSSL_LH_set_thunks(OPENSSL_LHASH *lh, + OPENSSL_LH_HASHFUNCTHUNK hw, + OPENSSL_LH_COMPFUNCTHUNK cw, + OPENSSL_LH_DOALL_FUNC_THUNK daw, + OPENSSL_LH_DOALL_FUNCARG_THUNK daaw); +void OPENSSL_LH_free(OPENSSL_LHASH *lh); +void OPENSSL_LH_flush(OPENSSL_LHASH *lh); +void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data); +void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data); +void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data); +void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func); +void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, + OPENSSL_LH_DOALL_FUNCARG func, void *arg); +void OPENSSL_LH_doall_arg_thunk(OPENSSL_LHASH *lh, + OPENSSL_LH_DOALL_FUNCARG_THUNK daaw, + OPENSSL_LH_DOALL_FUNCARG fn, void *arg); + +unsigned long OPENSSL_LH_strhash(const char *c); +unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh); +unsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh); +void OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load); + +# ifndef OPENSSL_NO_STDIO +# ifndef OPENSSL_NO_DEPRECATED_3_1 +OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp); +OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp); +OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp); +# endif +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_1 +OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out); +OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out); +OSSL_DEPRECATEDIN_3_1 void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out); +# endif + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define _LHASH OPENSSL_LHASH +# define LHASH_NODE OPENSSL_LH_NODE +# define lh_error OPENSSL_LH_error +# define lh_new OPENSSL_LH_new +# define lh_free OPENSSL_LH_free +# define lh_insert OPENSSL_LH_insert +# define lh_delete OPENSSL_LH_delete +# define lh_retrieve OPENSSL_LH_retrieve +# define lh_doall OPENSSL_LH_doall +# define lh_doall_arg OPENSSL_LH_doall_arg +# define lh_strhash OPENSSL_LH_strhash +# define lh_num_items OPENSSL_LH_num_items +# ifndef OPENSSL_NO_STDIO +# define lh_stats OPENSSL_LH_stats +# define lh_node_stats OPENSSL_LH_node_stats +# define lh_node_usage_stats OPENSSL_LH_node_usage_stats +# endif +# define lh_stats_bio OPENSSL_LH_stats_bio +# define lh_node_stats_bio OPENSSL_LH_node_stats_bio +# define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio +# endif + +/* Type checking... */ + +# define LHASH_OF(type) struct lhash_st_##type + +/* Helper macro for internal use */ +# define DEFINE_LHASH_OF_INTERNAL(type) \ + LHASH_OF(type) { \ + union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; \ + }; \ + typedef int (*lh_##type##_compfunc)(const type *a, const type *b); \ + typedef unsigned long (*lh_##type##_hashfunc)(const type *a); \ + typedef void (*lh_##type##_doallfunc)(type *a); \ + static ossl_inline unsigned long lh_##type##_hash_thunk(const void *data, OPENSSL_LH_HASHFUNC hfn) \ + { \ + unsigned long (*hfn_conv)(const type *) = (unsigned long (*)(const type *))hfn; \ + return hfn_conv((const type *)data); \ + } \ + static ossl_inline int lh_##type##_comp_thunk(const void *da, const void *db, OPENSSL_LH_COMPFUNC cfn) \ + { \ + int (*cfn_conv)(const type *, const type *) = (int (*)(const type *, const type *))cfn; \ + return cfn_conv((const type *)da, (const type *)db); \ + } \ + static ossl_inline void lh_##type##_doall_thunk(void *node, OPENSSL_LH_DOALL_FUNC doall) \ + { \ + void (*doall_conv)(type *) = (void (*)(type *))doall; \ + doall_conv((type *)node); \ + } \ + static ossl_inline void lh_##type##_doall_arg_thunk(void *node, void *arg, OPENSSL_LH_DOALL_FUNCARG doall) \ + { \ + void (*doall_conv)(type *, void *) = (void (*)(type *, void *))doall; \ + doall_conv((type *)node, arg); \ + } \ + static ossl_unused ossl_inline type *\ + ossl_check_##type##_lh_plain_type(type *ptr) \ + { \ + return ptr; \ + } \ + static ossl_unused ossl_inline const type * \ + ossl_check_const_##type##_lh_plain_type(const type *ptr) \ + { \ + return ptr; \ + } \ + static ossl_unused ossl_inline const OPENSSL_LHASH * \ + ossl_check_const_##type##_lh_type(const LHASH_OF(type) *lh) \ + { \ + return (const OPENSSL_LHASH *)lh; \ + } \ + static ossl_unused ossl_inline OPENSSL_LHASH * \ + ossl_check_##type##_lh_type(LHASH_OF(type) *lh) \ + { \ + return (OPENSSL_LHASH *)lh; \ + } \ + static ossl_unused ossl_inline OPENSSL_LH_COMPFUNC \ + ossl_check_##type##_lh_compfunc_type(lh_##type##_compfunc cmp) \ + { \ + return (OPENSSL_LH_COMPFUNC)cmp; \ + } \ + static ossl_unused ossl_inline OPENSSL_LH_HASHFUNC \ + ossl_check_##type##_lh_hashfunc_type(lh_##type##_hashfunc hfn) \ + { \ + return (OPENSSL_LH_HASHFUNC)hfn; \ + } \ + static ossl_unused ossl_inline OPENSSL_LH_DOALL_FUNC \ + ossl_check_##type##_lh_doallfunc_type(lh_##type##_doallfunc dfn) \ + { \ + return (OPENSSL_LH_DOALL_FUNC)dfn; \ + } \ + LHASH_OF(type) + +# ifndef OPENSSL_NO_DEPRECATED_3_1 +# define DEFINE_LHASH_OF_DEPRECATED(type) \ + static ossl_unused ossl_inline void \ + lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ + { \ + OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ + { \ + OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ + { \ + OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \ + } +# else +# define DEFINE_LHASH_OF_DEPRECATED(type) +# endif + +# define DEFINE_LHASH_OF_EX(type) \ + LHASH_OF(type) { \ + union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; \ + }; \ + static unsigned long \ + lh_##type##_hfn_thunk(const void *data, OPENSSL_LH_HASHFUNC hfn) \ + { \ + unsigned long (*hfn_conv)(const type *) = (unsigned long (*)(const type *))hfn; \ + return hfn_conv((const type *)data); \ + } \ + static int lh_##type##_cfn_thunk(const void *da, const void *db, OPENSSL_LH_COMPFUNC cfn) \ + { \ + int (*cfn_conv)(const type *, const type *) = (int (*)(const type *, const type *))cfn; \ + return cfn_conv((const type *)da, (const type *)db); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_free(LHASH_OF(type) *lh) \ + { \ + OPENSSL_LH_free((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_flush(LHASH_OF(type) *lh) \ + { \ + OPENSSL_LH_flush((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline type * \ + lh_##type##_insert(LHASH_OF(type) *lh, type *d) \ + { \ + return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \ + } \ + static ossl_unused ossl_inline type * \ + lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \ + { \ + return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \ + } \ + static ossl_unused ossl_inline type * \ + lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \ + { \ + return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \ + } \ + static ossl_unused ossl_inline int \ + lh_##type##_error(LHASH_OF(type) *lh) \ + { \ + return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline unsigned long \ + lh_##type##_num_items(LHASH_OF(type) *lh) \ + { \ + return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline unsigned long \ + lh_##type##_get_down_load(LHASH_OF(type) *lh) \ + { \ + return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \ + { \ + OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_doall_thunk(void *node, OPENSSL_LH_DOALL_FUNC doall) \ + { \ + void (*doall_conv)(type *) = (void (*)(type *))doall; \ + doall_conv((type *)node); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_doall_arg_thunk(void *node, void *arg, OPENSSL_LH_DOALL_FUNCARG doall) \ + { \ + void (*doall_conv)(type *, void *) = (void (*)(type *, void *))doall; \ + doall_conv((type *)node, arg); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_doall(LHASH_OF(type) *lh, void (*doall)(type *)) \ + { \ + OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \ + } \ + static ossl_unused ossl_inline LHASH_OF(type) * \ + lh_##type##_new(unsigned long (*hfn)(const type *), \ + int (*cfn)(const type *, const type *)) \ + { \ + return (LHASH_OF(type) *)OPENSSL_LH_set_thunks(OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn), \ + lh_##type##_hfn_thunk, lh_##type##_cfn_thunk, \ + lh_##type##_doall_thunk, \ + lh_##type##_doall_arg_thunk); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_doall_arg(LHASH_OF(type) *lh, \ + void (*doallarg)(type *, void *), void *arg) \ + { \ + OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, \ + (OPENSSL_LH_DOALL_FUNCARG)doallarg, arg); \ + } \ + LHASH_OF(type) + +# define DEFINE_LHASH_OF(type) \ + DEFINE_LHASH_OF_EX(type); \ + DEFINE_LHASH_OF_DEPRECATED(type) \ + LHASH_OF(type) + +#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \ + int_implement_lhash_doall(type, argtype, const type) + +#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \ + int_implement_lhash_doall(type, argtype, type) + +#define int_implement_lhash_doall(type, argtype, cbargtype) \ + static ossl_unused ossl_inline void \ + lh_##type##_doall_##argtype##_thunk(void *node, void *arg, OPENSSL_LH_DOALL_FUNCARG fn) \ + { \ + void (*fn_conv)(cbargtype *, argtype *) = (void (*)(cbargtype *, argtype *))fn; \ + fn_conv((cbargtype *)node, (argtype *)arg); \ + } \ + static ossl_unused ossl_inline void \ + lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \ + void (*fn)(cbargtype *, argtype *), \ + argtype *arg) \ + { \ + OPENSSL_LH_doall_arg_thunk((OPENSSL_LHASH *)lh, \ + lh_##type##_doall_##argtype##_thunk, \ + (OPENSSL_LH_DOALL_FUNCARG)fn, \ + (void *)arg); \ + } \ + LHASH_OF(type) + +DEFINE_LHASH_OF_INTERNAL(OPENSSL_STRING); +#define lh_OPENSSL_STRING_new(hfn, cmp) ((LHASH_OF(OPENSSL_STRING) *)OPENSSL_LH_set_thunks(OPENSSL_LH_new(ossl_check_OPENSSL_STRING_lh_hashfunc_type(hfn), ossl_check_OPENSSL_STRING_lh_compfunc_type(cmp)), lh_OPENSSL_STRING_hash_thunk, lh_OPENSSL_STRING_comp_thunk, lh_OPENSSL_STRING_doall_thunk, lh_OPENSSL_STRING_doall_arg_thunk)) +#define lh_OPENSSL_STRING_free(lh) OPENSSL_LH_free(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_flush(lh) OPENSSL_LH_flush(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_insert(lh, ptr) ((OPENSSL_STRING *)OPENSSL_LH_insert(ossl_check_OPENSSL_STRING_lh_type(lh), ossl_check_OPENSSL_STRING_lh_plain_type(ptr))) +#define lh_OPENSSL_STRING_delete(lh, ptr) ((OPENSSL_STRING *)OPENSSL_LH_delete(ossl_check_OPENSSL_STRING_lh_type(lh), ossl_check_const_OPENSSL_STRING_lh_plain_type(ptr))) +#define lh_OPENSSL_STRING_retrieve(lh, ptr) ((OPENSSL_STRING *)OPENSSL_LH_retrieve(ossl_check_OPENSSL_STRING_lh_type(lh), ossl_check_const_OPENSSL_STRING_lh_plain_type(ptr))) +#define lh_OPENSSL_STRING_error(lh) OPENSSL_LH_error(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_num_items(lh) OPENSSL_LH_num_items(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_node_stats_bio(lh, out) OPENSSL_LH_node_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out) +#define lh_OPENSSL_STRING_node_usage_stats_bio(lh, out) OPENSSL_LH_node_usage_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out) +#define lh_OPENSSL_STRING_stats_bio(lh, out) OPENSSL_LH_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out) +#define lh_OPENSSL_STRING_get_down_load(lh) OPENSSL_LH_get_down_load(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_set_down_load(lh, dl) OPENSSL_LH_set_down_load(ossl_check_OPENSSL_STRING_lh_type(lh), dl) +#define lh_OPENSSL_STRING_doall(lh, dfn) OPENSSL_LH_doall(ossl_check_OPENSSL_STRING_lh_type(lh), ossl_check_OPENSSL_STRING_lh_doallfunc_type(dfn)) +DEFINE_LHASH_OF_INTERNAL(OPENSSL_CSTRING); +#define lh_OPENSSL_CSTRING_new(hfn, cmp) ((LHASH_OF(OPENSSL_CSTRING) *)OPENSSL_LH_set_thunks(OPENSSL_LH_new(ossl_check_OPENSSL_CSTRING_lh_hashfunc_type(hfn), ossl_check_OPENSSL_CSTRING_lh_compfunc_type(cmp)), lh_OPENSSL_CSTRING_hash_thunk, lh_OPENSSL_CSTRING_comp_thunk, lh_OPENSSL_CSTRING_doall_thunk, lh_OPENSSL_CSTRING_doall_arg_thunk)) +#define lh_OPENSSL_CSTRING_free(lh) OPENSSL_LH_free(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_flush(lh) OPENSSL_LH_flush(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_insert(lh, ptr) ((OPENSSL_CSTRING *)OPENSSL_LH_insert(ossl_check_OPENSSL_CSTRING_lh_type(lh), ossl_check_OPENSSL_CSTRING_lh_plain_type(ptr))) +#define lh_OPENSSL_CSTRING_delete(lh, ptr) ((OPENSSL_CSTRING *)OPENSSL_LH_delete(ossl_check_OPENSSL_CSTRING_lh_type(lh), ossl_check_const_OPENSSL_CSTRING_lh_plain_type(ptr))) +#define lh_OPENSSL_CSTRING_retrieve(lh, ptr) ((OPENSSL_CSTRING *)OPENSSL_LH_retrieve(ossl_check_OPENSSL_CSTRING_lh_type(lh), ossl_check_const_OPENSSL_CSTRING_lh_plain_type(ptr))) +#define lh_OPENSSL_CSTRING_error(lh) OPENSSL_LH_error(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_num_items(lh) OPENSSL_LH_num_items(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_node_stats_bio(lh, out) OPENSSL_LH_node_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) +#define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh, out) OPENSSL_LH_node_usage_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) +#define lh_OPENSSL_CSTRING_stats_bio(lh, out) OPENSSL_LH_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) +#define lh_OPENSSL_CSTRING_get_down_load(lh) OPENSSL_LH_get_down_load(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_set_down_load(lh, dl) OPENSSL_LH_set_down_load(ossl_check_OPENSSL_CSTRING_lh_type(lh), dl) +#define lh_OPENSSL_CSTRING_doall(lh, dfn) OPENSSL_LH_doall(ossl_check_OPENSSL_CSTRING_lh_type(lh), ossl_check_OPENSSL_CSTRING_lh_doallfunc_type(dfn)) + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/macros.h b/illumos-x86_64/usr/include/openssl-3/macros.h new file mode 100644 index 00000000..296723ec --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/macros.h @@ -0,0 +1,349 @@ +/* + * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_MACROS_H +# define OPENSSL_MACROS_H +# pragma once + +#include +#include + + +/* Helper macros for CPP string composition */ +# define OPENSSL_MSTR_HELPER(x) #x +# define OPENSSL_MSTR(x) OPENSSL_MSTR_HELPER(x) + +/* + * Sometimes OPENSSL_NO_xxx ends up with an empty file and some compilers + * don't like that. This will hopefully silence them. + */ +# define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy; + +/* + * Generic deprecation macro + * + * If OPENSSL_SUPPRESS_DEPRECATED is defined, then OSSL_DEPRECATED and + * OSSL_DEPRECATED_FOR become no-ops + */ +# ifndef OSSL_DEPRECATED +# undef OSSL_DEPRECATED_FOR +# ifndef OPENSSL_SUPPRESS_DEPRECATED +# if defined(_MSC_VER) + /* + * MSVC supports __declspec(deprecated) since MSVC 2003 (13.10), + * and __declspec(deprecated(message)) since MSVC 2005 (14.00) + */ +# if _MSC_VER >= 1400 +# define OSSL_DEPRECATED(since) \ + __declspec(deprecated("Since OpenSSL " # since)) +# define OSSL_DEPRECATED_FOR(since, message) \ + __declspec(deprecated("Since OpenSSL " # since ";" message)) +# elif _MSC_VER >= 1310 +# define OSSL_DEPRECATED(since) __declspec(deprecated) +# define OSSL_DEPRECATED_FOR(since, message) __declspec(deprecated) +# endif +# elif defined(__GNUC__) + /* + * According to GCC documentation, deprecations with message appeared in + * GCC 4.5.0 + */ +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +# define OSSL_DEPRECATED(since) \ + __attribute__((deprecated("Since OpenSSL " # since))) +# define OSSL_DEPRECATED_FOR(since, message) \ + __attribute__((deprecated("Since OpenSSL " # since ";" message))) +# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) +# define OSSL_DEPRECATED(since) __attribute__((deprecated)) +# define OSSL_DEPRECATED_FOR(since, message) __attribute__((deprecated)) +# endif +# elif defined(__SUNPRO_C) +# if (__SUNPRO_C >= 0x5130) +# define OSSL_DEPRECATED(since) __attribute__ ((deprecated)) +# define OSSL_DEPRECATED_FOR(since, message) __attribute__ ((deprecated)) +# endif +# endif +# endif +# endif + +/* + * Still not defined? Then define no-op macros. This means these macros + * are unsuitable for use in a typedef. + */ +# ifndef OSSL_DEPRECATED +# define OSSL_DEPRECATED(since) extern +# define OSSL_DEPRECATED_FOR(since, message) extern +# endif + +/* + * Applications should use -DOPENSSL_API_COMPAT= to suppress the + * declarations of functions deprecated in or before . If this is + * undefined, the value of the macro OPENSSL_CONFIGURED_API (defined in + * ) is the default. + * + * For any version number up until version 1.1.x, is expected to be + * the calculated version number 0xMNNFFPPSL. + * For version numbers 3.0 and on, is expected to be a computation + * of the major and minor numbers in decimal using this formula: + * + * MAJOR * 10000 + MINOR * 100 + * + * So version 3.0 becomes 30000, version 3.2 becomes 30200, etc. + */ + +/* + * We use the OPENSSL_API_COMPAT value to define API level macros. These + * macros are used to enable or disable features at that API version boundary. + */ + +# ifdef OPENSSL_API_LEVEL +# error "OPENSSL_API_LEVEL must not be defined by application" +# endif + +/* + * We figure out what API level was intended by simple numeric comparison. + * The lowest old style number we recognise is 0x00908000L, so we take some + * safety margin and assume that anything below 0x00900000L is a new style + * number. This allows new versions up to and including v943.71.83. + */ +# ifdef OPENSSL_API_COMPAT +# if OPENSSL_API_COMPAT < 0x900000L +# define OPENSSL_API_LEVEL (OPENSSL_API_COMPAT) +# else +# define OPENSSL_API_LEVEL \ + (((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \ + + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \ + + ((OPENSSL_API_COMPAT >> 12) & 0xFF)) +# endif +# endif + +/* + * If OPENSSL_API_COMPAT wasn't given, we use default numbers to set + * the API compatibility level. + */ +# ifndef OPENSSL_API_LEVEL +# if OPENSSL_CONFIGURED_API > 0 +# define OPENSSL_API_LEVEL (OPENSSL_CONFIGURED_API) +# else +# define OPENSSL_API_LEVEL \ + (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100) +# endif +# endif + +# if OPENSSL_API_LEVEL > OPENSSL_CONFIGURED_API +# error "The requested API level higher than the configured API compatibility level" +# endif + +/* + * Check of sane values. + */ +/* Can't go higher than the current version. */ +# if OPENSSL_API_LEVEL > (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100) +# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" +# endif +/* OpenSSL will have no version 2.y.z */ +# if OPENSSL_API_LEVEL < 30000 && OPENSSL_API_LEVEL >= 20000 +# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" +# endif +/* Below 0.9.8 is unacceptably low */ +# if OPENSSL_API_LEVEL < 908 +# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" +# endif + +/* + * Define macros for deprecation and simulated removal purposes. + * + * The macros OSSL_DEPRECATEDIN_{major}_{minor} are always defined for + * all OpenSSL versions we care for. They can be used as attributes + * in function declarations where appropriate. + * + * The macros OPENSSL_NO_DEPRECATED_{major}_{minor} are defined for + * all OpenSSL versions up to or equal to the version given with + * OPENSSL_API_COMPAT. They are used as guards around anything that's + * deprecated up to that version, as an effect of the developer option + * 'no-deprecated'. + */ + +# undef OPENSSL_NO_DEPRECATED_3_4 +# undef OPENSSL_NO_DEPRECATED_3_1 +# undef OPENSSL_NO_DEPRECATED_3_0 +# undef OPENSSL_NO_DEPRECATED_1_1_1 +# undef OPENSSL_NO_DEPRECATED_1_1_0 +# undef OPENSSL_NO_DEPRECATED_1_0_2 +# undef OPENSSL_NO_DEPRECATED_1_0_1 +# undef OPENSSL_NO_DEPRECATED_1_0_0 +# undef OPENSSL_NO_DEPRECATED_0_9_8 + +# if OPENSSL_API_LEVEL >= 30500 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_3_5 OSSL_DEPRECATED(3.5) +# define OSSL_DEPRECATEDIN_3_5_FOR(msg) OSSL_DEPRECATED_FOR(3.5, msg) +# else +# define OPENSSL_NO_DEPRECATED_3_5 +# endif +# else +# define OSSL_DEPRECATEDIN_3_5 +# define OSSL_DEPRECATEDIN_3_5_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 30400 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_3_4 OSSL_DEPRECATED(3.4) +# define OSSL_DEPRECATEDIN_3_4_FOR(msg) OSSL_DEPRECATED_FOR(3.4, msg) +# else +# define OPENSSL_NO_DEPRECATED_3_4 +# endif +# else +# define OSSL_DEPRECATEDIN_3_4 +# define OSSL_DEPRECATEDIN_3_4_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 30100 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_3_1 OSSL_DEPRECATED(3.1) +# define OSSL_DEPRECATEDIN_3_1_FOR(msg) OSSL_DEPRECATED_FOR(3.1, msg) +# else +# define OPENSSL_NO_DEPRECATED_3_1 +# endif +# else +# define OSSL_DEPRECATEDIN_3_1 +# define OSSL_DEPRECATEDIN_3_1_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 30000 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_3_0 OSSL_DEPRECATED(3.0) +# define OSSL_DEPRECATEDIN_3_0_FOR(msg) OSSL_DEPRECATED_FOR(3.0, msg) +# else +# define OPENSSL_NO_DEPRECATED_3_0 +# endif +# else +# define OSSL_DEPRECATEDIN_3_0 +# define OSSL_DEPRECATEDIN_3_0_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 10101 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_1_1 OSSL_DEPRECATED(1.1.1) +# define OSSL_DEPRECATEDIN_1_1_1_FOR(msg) OSSL_DEPRECATED_FOR(1.1.1, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_1_1 +# endif +# else +# define OSSL_DEPRECATEDIN_1_1_1 +# define OSSL_DEPRECATEDIN_1_1_1_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 10100 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_1_0 OSSL_DEPRECATED(1.1.0) +# define OSSL_DEPRECATEDIN_1_1_0_FOR(msg) OSSL_DEPRECATED_FOR(1.1.0, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_1_0 +# endif +# else +# define OSSL_DEPRECATEDIN_1_1_0 +# define OSSL_DEPRECATEDIN_1_1_0_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 10002 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_0_2 OSSL_DEPRECATED(1.0.2) +# define OSSL_DEPRECATEDIN_1_0_2_FOR(msg) OSSL_DEPRECATED_FOR(1.0.2, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_0_2 +# endif +# else +# define OSSL_DEPRECATEDIN_1_0_2 +# define OSSL_DEPRECATEDIN_1_0_2_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 10001 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_0_1 OSSL_DEPRECATED(1.0.1) +# define OSSL_DEPRECATEDIN_1_0_1_FOR(msg) OSSL_DEPRECATED_FOR(1.0.1, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_0_1 +# endif +# else +# define OSSL_DEPRECATEDIN_1_0_1 +# define OSSL_DEPRECATEDIN_1_0_1_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 10000 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_0_0 OSSL_DEPRECATED(1.0.0) +# define OSSL_DEPRECATEDIN_1_0_0_FOR(msg) OSSL_DEPRECATED_FOR(1.0.0, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_0_0 +# endif +# else +# define OSSL_DEPRECATEDIN_1_0_0 +# define OSSL_DEPRECATEDIN_1_0_0_FOR(msg) +# endif +# if OPENSSL_API_LEVEL >= 908 +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_0_9_8 OSSL_DEPRECATED(0.9.8) +# define OSSL_DEPRECATEDIN_0_9_8_FOR(msg) OSSL_DEPRECATED_FOR(0.9.8, msg) +# else +# define OPENSSL_NO_DEPRECATED_0_9_8 +# endif +# else +# define OSSL_DEPRECATEDIN_0_9_8 +# define OSSL_DEPRECATEDIN_0_9_8_FOR(msg) +# endif + +/* + * Make our own variants of __FILE__ and __LINE__, depending on configuration + */ + +# ifndef OPENSSL_FILE +# ifdef OPENSSL_NO_FILENAMES +# define OPENSSL_FILE "" +# define OPENSSL_LINE 0 +# else +# define OPENSSL_FILE __FILE__ +# define OPENSSL_LINE __LINE__ +# endif +# endif + +/* + * __func__ was standardized in C99, so for any compiler that claims + * to implement that language level or newer, we assume we can safely + * use that symbol. + * + * GNU C also provides __FUNCTION__ since version 2, which predates + * C99. We can, however, only use this if __STDC_VERSION__ exists, + * as it's otherwise not allowed according to ISO C standards (C90). + * (compiling with GNU C's -pedantic tells us so) + * + * If none of the above applies, we check if the compiler is MSVC, + * and use __FUNCTION__ if that's the case. + */ +# ifndef OPENSSL_FUNC +# if defined(__STDC_VERSION__) +# if __STDC_VERSION__ >= 199901L +# define OPENSSL_FUNC __func__ +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define OPENSSL_FUNC __FUNCTION__ +# endif +# elif defined(_MSC_VER) +# define OPENSSL_FUNC __FUNCTION__ +# endif +/* + * If all these possibilities are exhausted, we give up and use a + * static string. + */ +# ifndef OPENSSL_FUNC +# define OPENSSL_FUNC "(unknown function)" +# endif +# endif + +# ifndef OSSL_CRYPTO_ALLOC +# if defined(__GNUC__) +# define OSSL_CRYPTO_ALLOC __attribute__((__malloc__)) +# elif defined(_MSC_VER) +# define OSSL_CRYPTO_ALLOC __declspec(restrict) +# else +# define OSSL_CRYPTO_ALLOC +# endif +# endif + +#endif /* OPENSSL_MACROS_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/md2.h b/illumos-x86_64/usr/include/openssl-3/md2.h new file mode 100644 index 00000000..5d4cb77e --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/md2.h @@ -0,0 +1,56 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_MD2_H +# define OPENSSL_MD2_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_MD2_H +# endif + +# include + +# ifndef OPENSSL_NO_MD2 +# include +# ifdef __cplusplus +extern "C" { +# endif + +# define MD2_DIGEST_LENGTH 16 + +# if !defined(OPENSSL_NO_DEPRECATED_3_0) + +typedef unsigned char MD2_INT; + +# define MD2_BLOCK 16 + +typedef struct MD2state_st { + unsigned int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; +} MD2_CTX; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 const char *MD2_options(void); +OSSL_DEPRECATEDIN_3_0 int MD2_Init(MD2_CTX *c); +OSSL_DEPRECATEDIN_3_0 int MD2_Update(MD2_CTX *c, const unsigned char *data, + size_t len); +OSSL_DEPRECATEDIN_3_0 int MD2_Final(unsigned char *md, MD2_CTX *c); +OSSL_DEPRECATEDIN_3_0 unsigned char *MD2(const unsigned char *d, size_t n, + unsigned char *md); +# endif + +# ifdef __cplusplus +} +# endif +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/md4.h b/illumos-x86_64/usr/include/openssl-3/md4.h new file mode 100644 index 00000000..6c150a6c --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/md4.h @@ -0,0 +1,63 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_MD4_H +# define OPENSSL_MD4_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_MD4_H +# endif + +# include + +# ifndef OPENSSL_NO_MD4 +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + +# define MD4_DIGEST_LENGTH 16 + +# if !defined(OPENSSL_NO_DEPRECATED_3_0) + +/*- + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD4_LONG has to be at least 32 bits wide. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ +# define MD4_LONG unsigned int + +# define MD4_CBLOCK 64 +# define MD4_LBLOCK (MD4_CBLOCK/4) + +typedef struct MD4state_st { + MD4_LONG A, B, C, D; + MD4_LONG Nl, Nh; + MD4_LONG data[MD4_LBLOCK]; + unsigned int num; +} MD4_CTX; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int MD4_Init(MD4_CTX *c); +OSSL_DEPRECATEDIN_3_0 int MD4_Update(MD4_CTX *c, const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int MD4_Final(unsigned char *md, MD4_CTX *c); +OSSL_DEPRECATEDIN_3_0 unsigned char *MD4(const unsigned char *d, size_t n, + unsigned char *md); +OSSL_DEPRECATEDIN_3_0 void MD4_Transform(MD4_CTX *c, const unsigned char *b); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/md5.h b/illumos-x86_64/usr/include/openssl-3/md5.h new file mode 100644 index 00000000..77a57734 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/md5.h @@ -0,0 +1,62 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_MD5_H +# define OPENSSL_MD5_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_MD5_H +# endif + +# include + +# ifndef OPENSSL_NO_MD5 +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + +# define MD5_DIGEST_LENGTH 16 + +# if !defined(OPENSSL_NO_DEPRECATED_3_0) +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD5_LONG has to be at least 32 bits wide. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ +# define MD5_LONG unsigned int + +# define MD5_CBLOCK 64 +# define MD5_LBLOCK (MD5_CBLOCK/4) + +typedef struct MD5state_st { + MD5_LONG A, B, C, D; + MD5_LONG Nl, Nh; + MD5_LONG data[MD5_LBLOCK]; + unsigned int num; +} MD5_CTX; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c); +OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c); +OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n, + unsigned char *md); +OSSL_DEPRECATEDIN_3_0 void MD5_Transform(MD5_CTX *c, const unsigned char *b); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/mdc2.h b/illumos-x86_64/usr/include/openssl-3/mdc2.h new file mode 100644 index 00000000..5a7ee289 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/mdc2.h @@ -0,0 +1,55 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_MDC2_H +# define OPENSSL_MDC2_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_MDC2_H +# endif + +# include + +# ifndef OPENSSL_NO_MDC2 +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + +# define MDC2_DIGEST_LENGTH 16 + +# if !defined(OPENSSL_NO_DEPRECATED_3_0) + +# define MDC2_BLOCK 8 + +typedef struct mdc2_ctx_st { + unsigned int num; + unsigned char data[MDC2_BLOCK]; + DES_cblock h, hh; + unsigned int pad_type; /* either 1 or 2, default 1 */ +} MDC2_CTX; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int MDC2_Init(MDC2_CTX *c); +OSSL_DEPRECATEDIN_3_0 int MDC2_Update(MDC2_CTX *c, const unsigned char *data, + size_t len); +OSSL_DEPRECATEDIN_3_0 int MDC2_Final(unsigned char *md, MDC2_CTX *c); +OSSL_DEPRECATEDIN_3_0 unsigned char *MDC2(const unsigned char *d, size_t n, + unsigned char *md); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ml_kem.h b/illumos-x86_64/usr/include/openssl-3/ml_kem.h new file mode 100644 index 00000000..1c901634 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ml_kem.h @@ -0,0 +1,31 @@ +/* + * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_ML_KEM_H +# define OPENSSL_ML_KEM_H +# pragma once + +# define OSSL_ML_KEM_SHARED_SECRET_BYTES 32 + +# define OSSL_ML_KEM_512_BITS 512 +# define OSSL_ML_KEM_512_SECURITY_BITS 128 +# define OSSL_ML_KEM_512_CIPHERTEXT_BYTES 768 +# define OSSL_ML_KEM_512_PUBLIC_KEY_BYTES 800 + +# define OSSL_ML_KEM_768_BITS 768 +# define OSSL_ML_KEM_768_SECURITY_BITS 192 +# define OSSL_ML_KEM_768_CIPHERTEXT_BYTES 1088 +# define OSSL_ML_KEM_768_PUBLIC_KEY_BYTES 1184 + +# define OSSL_ML_KEM_1024_BITS 1024 +# define OSSL_ML_KEM_1024_SECURITY_BITS 256 +# define OSSL_ML_KEM_1024_CIPHERTEXT_BYTES 1568 +# define OSSL_ML_KEM_1024_PUBLIC_KEY_BYTES 1568 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/modes.h b/illumos-x86_64/usr/include/openssl-3/modes.h new file mode 100644 index 00000000..e1907991 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/modes.h @@ -0,0 +1,219 @@ +/* + * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_MODES_H +# define OPENSSL_MODES_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_MODES_H +# endif + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif +typedef void (*block128_f) (const unsigned char in[16], + unsigned char out[16], const void *key); + +typedef void (*cbc128_f) (const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], int enc); + +typedef void (*ecb128_f) (const unsigned char *in, unsigned char *out, + size_t len, const void *key, + int enc); + +typedef void (*ctr128_f) (const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, + const unsigned char ivec[16]); + +typedef void (*ccm128_f) (const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, + const unsigned char ivec[16], + unsigned char cmac[16]); + +void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], block128_f block); +void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], block128_f block); + +void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], + unsigned char ecount_buf[16], unsigned int *num, + block128_f block); + +void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], + unsigned char ecount_buf[16], + unsigned int *num, ctr128_f ctr); + +void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], int *num, + block128_f block); + +void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], int *num, + int enc, block128_f block); +void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const void *key, + unsigned char ivec[16], int *num, + int enc, block128_f block); +void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out, + size_t bits, const void *key, + unsigned char ivec[16], int *num, + int enc, block128_f block); + +size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, + unsigned char *out, size_t len, + const void *key, unsigned char ivec[16], + block128_f block); +size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], cbc128_f cbc); +size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, + unsigned char *out, size_t len, + const void *key, unsigned char ivec[16], + block128_f block); +size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], cbc128_f cbc); + +size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, + unsigned char *out, size_t len, + const void *key, + unsigned char ivec[16], + block128_f block); +size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], cbc128_f cbc); +size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, + unsigned char *out, size_t len, + const void *key, + unsigned char ivec[16], + block128_f block); +size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], cbc128_f cbc); + +typedef struct gcm128_context GCM128_CONTEXT; + +GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block); +void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block); +void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, + size_t len); +int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad, + size_t len); +int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, + const unsigned char *in, unsigned char *out, + size_t len); +int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, + const unsigned char *in, unsigned char *out, + size_t len); +int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, + const unsigned char *in, unsigned char *out, + size_t len, ctr128_f stream); +int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, + const unsigned char *in, unsigned char *out, + size_t len, ctr128_f stream); +int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag, + size_t len); +void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len); +void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx); + +typedef struct ccm128_context CCM128_CONTEXT; + +void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, + unsigned int M, unsigned int L, void *key, + block128_f block); +int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce, + size_t nlen, size_t mlen); +void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad, + size_t alen); +int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, + unsigned char *out, size_t len); +int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, + unsigned char *out, size_t len); +int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, + unsigned char *out, size_t len, + ccm128_f stream); +int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, + unsigned char *out, size_t len, + ccm128_f stream); +size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len); + +typedef struct xts128_context XTS128_CONTEXT; + +int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, + const unsigned char iv[16], + const unsigned char *inp, unsigned char *out, + size_t len, int enc); + +size_t CRYPTO_128_wrap(void *key, const unsigned char *iv, + unsigned char *out, + const unsigned char *in, size_t inlen, + block128_f block); + +size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv, + unsigned char *out, + const unsigned char *in, size_t inlen, + block128_f block); +size_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv, + unsigned char *out, const unsigned char *in, + size_t inlen, block128_f block); +size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv, + unsigned char *out, const unsigned char *in, + size_t inlen, block128_f block); + +# ifndef OPENSSL_NO_OCB +typedef struct ocb128_context OCB128_CONTEXT; + +typedef void (*ocb128_f) (const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, + size_t start_block_num, + unsigned char offset_i[16], + const unsigned char L_[][16], + unsigned char checksum[16]); + +OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec, + block128_f encrypt, block128_f decrypt, + ocb128_f stream); +int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec, + block128_f encrypt, block128_f decrypt, + ocb128_f stream); +int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src, + void *keyenc, void *keydec); +int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv, + size_t len, size_t taglen); +int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad, + size_t len); +int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len); +int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len); +int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag, + size_t len); +int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len); +void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx); +# endif /* OPENSSL_NO_OCB */ + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/obj_mac.h b/illumos-x86_64/usr/include/openssl-3/obj_mac.h new file mode 100644 index 00000000..ee71e264 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/obj_mac.h @@ -0,0 +1,6636 @@ +/* + * WARNING: do not edit! + * Generated by crypto/objects/objects.pl + * + * Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved. + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_OBJ_MAC_H +# define OPENSSL_OBJ_MAC_H +# pragma once + +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_itu_t "ITU-T" +#define LN_itu_t "itu-t" +#define NID_itu_t 645 +#define OBJ_itu_t 0L + +#define NID_ccitt 404 +#define OBJ_ccitt OBJ_itu_t + +#define SN_iso "ISO" +#define LN_iso "iso" +#define NID_iso 181 +#define OBJ_iso 1L + +#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" +#define LN_joint_iso_itu_t "joint-iso-itu-t" +#define NID_joint_iso_itu_t 646 +#define OBJ_joint_iso_itu_t 2L + +#define NID_joint_iso_ccitt 393 +#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t + +#define SN_member_body "member-body" +#define LN_member_body "ISO Member Body" +#define NID_member_body 182 +#define OBJ_member_body OBJ_iso,2L + +#define SN_identified_organization "identified-organization" +#define NID_identified_organization 676 +#define OBJ_identified_organization OBJ_iso,3L + +#define SN_gmac "GMAC" +#define LN_gmac "gmac" +#define NID_gmac 1195 +#define OBJ_gmac OBJ_iso,0L,9797L,3L,4L + +#define SN_hmac_md5 "HMAC-MD5" +#define LN_hmac_md5 "hmac-md5" +#define NID_hmac_md5 780 +#define OBJ_hmac_md5 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L + +#define SN_hmac_sha1 "HMAC-SHA1" +#define LN_hmac_sha1 "hmac-sha1" +#define NID_hmac_sha1 781 +#define OBJ_hmac_sha1 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L + +#define SN_x509ExtAdmission "x509ExtAdmission" +#define LN_x509ExtAdmission "Professional Information or basis for Admission" +#define NID_x509ExtAdmission 1093 +#define OBJ_x509ExtAdmission OBJ_identified_organization,36L,8L,3L,3L + +#define SN_certicom_arc "certicom-arc" +#define NID_certicom_arc 677 +#define OBJ_certicom_arc OBJ_identified_organization,132L + +#define SN_ieee "ieee" +#define NID_ieee 1170 +#define OBJ_ieee OBJ_identified_organization,111L + +#define SN_ieee_siswg "ieee-siswg" +#define LN_ieee_siswg "IEEE Security in Storage Working Group" +#define NID_ieee_siswg 1171 +#define OBJ_ieee_siswg OBJ_ieee,2L,1619L + +#define SN_international_organizations "international-organizations" +#define LN_international_organizations "International Organizations" +#define NID_international_organizations 647 +#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L + +#define SN_wap "wap" +#define NID_wap 678 +#define OBJ_wap OBJ_international_organizations,43L + +#define SN_wap_wsg "wap-wsg" +#define NID_wap_wsg 679 +#define OBJ_wap_wsg OBJ_wap,1L + +#define SN_selected_attribute_types "selected-attribute-types" +#define LN_selected_attribute_types "Selected Attribute Types" +#define NID_selected_attribute_types 394 +#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L + +#define SN_clearance "clearance" +#define NID_clearance 395 +#define OBJ_clearance OBJ_selected_attribute_types,55L + +#define SN_ISO_US "ISO-US" +#define LN_ISO_US "ISO US Member Body" +#define NID_ISO_US 183 +#define OBJ_ISO_US OBJ_member_body,840L + +#define SN_X9_57 "X9-57" +#define LN_X9_57 "X9.57" +#define NID_X9_57 184 +#define OBJ_X9_57 OBJ_ISO_US,10040L + +#define SN_X9cm "X9cm" +#define LN_X9cm "X9.57 CM ?" +#define NID_X9cm 185 +#define OBJ_X9cm OBJ_X9_57,4L + +#define SN_ISO_CN "ISO-CN" +#define LN_ISO_CN "ISO CN Member Body" +#define NID_ISO_CN 1140 +#define OBJ_ISO_CN OBJ_member_body,156L + +#define SN_oscca "oscca" +#define NID_oscca 1141 +#define OBJ_oscca OBJ_ISO_CN,10197L + +#define SN_sm_scheme "sm-scheme" +#define NID_sm_scheme 1142 +#define OBJ_sm_scheme OBJ_oscca,1L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa OBJ_X9cm,1L + +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 OBJ_X9cm,3L + +#define SN_ansi_X9_62 "ansi-X9-62" +#define LN_ansi_X9_62 "ANSI X9.62" +#define NID_ansi_X9_62 405 +#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L + +#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L + +#define SN_X9_62_prime_field "prime-field" +#define NID_X9_62_prime_field 406 +#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L + +#define SN_X9_62_characteristic_two_field "characteristic-two-field" +#define NID_X9_62_characteristic_two_field 407 +#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L + +#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" +#define NID_X9_62_id_characteristic_two_basis 680 +#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L + +#define SN_X9_62_onBasis "onBasis" +#define NID_X9_62_onBasis 681 +#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L + +#define SN_X9_62_tpBasis "tpBasis" +#define NID_X9_62_tpBasis 682 +#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L + +#define SN_X9_62_ppBasis "ppBasis" +#define NID_X9_62_ppBasis 683 +#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L + +#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L + +#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" +#define NID_X9_62_id_ecPublicKey 408 +#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L + +#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L + +#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L + +#define SN_X9_62_c2pnb163v1 "c2pnb163v1" +#define NID_X9_62_c2pnb163v1 684 +#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L + +#define SN_X9_62_c2pnb163v2 "c2pnb163v2" +#define NID_X9_62_c2pnb163v2 685 +#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L + +#define SN_X9_62_c2pnb163v3 "c2pnb163v3" +#define NID_X9_62_c2pnb163v3 686 +#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L + +#define SN_X9_62_c2pnb176v1 "c2pnb176v1" +#define NID_X9_62_c2pnb176v1 687 +#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L + +#define SN_X9_62_c2tnb191v1 "c2tnb191v1" +#define NID_X9_62_c2tnb191v1 688 +#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L + +#define SN_X9_62_c2tnb191v2 "c2tnb191v2" +#define NID_X9_62_c2tnb191v2 689 +#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L + +#define SN_X9_62_c2tnb191v3 "c2tnb191v3" +#define NID_X9_62_c2tnb191v3 690 +#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L + +#define SN_X9_62_c2onb191v4 "c2onb191v4" +#define NID_X9_62_c2onb191v4 691 +#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L + +#define SN_X9_62_c2onb191v5 "c2onb191v5" +#define NID_X9_62_c2onb191v5 692 +#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L + +#define SN_X9_62_c2pnb208w1 "c2pnb208w1" +#define NID_X9_62_c2pnb208w1 693 +#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L + +#define SN_X9_62_c2tnb239v1 "c2tnb239v1" +#define NID_X9_62_c2tnb239v1 694 +#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L + +#define SN_X9_62_c2tnb239v2 "c2tnb239v2" +#define NID_X9_62_c2tnb239v2 695 +#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L + +#define SN_X9_62_c2tnb239v3 "c2tnb239v3" +#define NID_X9_62_c2tnb239v3 696 +#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L + +#define SN_X9_62_c2onb239v4 "c2onb239v4" +#define NID_X9_62_c2onb239v4 697 +#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L + +#define SN_X9_62_c2onb239v5 "c2onb239v5" +#define NID_X9_62_c2onb239v5 698 +#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L + +#define SN_X9_62_c2pnb272w1 "c2pnb272w1" +#define NID_X9_62_c2pnb272w1 699 +#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L + +#define SN_X9_62_c2pnb304w1 "c2pnb304w1" +#define NID_X9_62_c2pnb304w1 700 +#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L + +#define SN_X9_62_c2tnb359v1 "c2tnb359v1" +#define NID_X9_62_c2tnb359v1 701 +#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L + +#define SN_X9_62_c2pnb368w1 "c2pnb368w1" +#define NID_X9_62_c2pnb368w1 702 +#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L + +#define SN_X9_62_c2tnb431r1 "c2tnb431r1" +#define NID_X9_62_c2tnb431r1 703 +#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L + +#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L + +#define SN_X9_62_prime192v1 "prime192v1" +#define NID_X9_62_prime192v1 409 +#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L + +#define SN_X9_62_prime192v2 "prime192v2" +#define NID_X9_62_prime192v2 410 +#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L + +#define SN_X9_62_prime192v3 "prime192v3" +#define NID_X9_62_prime192v3 411 +#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L + +#define SN_X9_62_prime239v1 "prime239v1" +#define NID_X9_62_prime239v1 412 +#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L + +#define SN_X9_62_prime239v2 "prime239v2" +#define NID_X9_62_prime239v2 413 +#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L + +#define SN_X9_62_prime239v3 "prime239v3" +#define NID_X9_62_prime239v3 414 +#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L + +#define SN_X9_62_prime256v1 "prime256v1" +#define NID_X9_62_prime256v1 415 +#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L + +#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L + +#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" +#define NID_ecdsa_with_SHA1 416 +#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L + +#define SN_ecdsa_with_Recommended "ecdsa-with-Recommended" +#define NID_ecdsa_with_Recommended 791 +#define OBJ_ecdsa_with_Recommended OBJ_X9_62_id_ecSigType,2L + +#define SN_ecdsa_with_Specified "ecdsa-with-Specified" +#define NID_ecdsa_with_Specified 792 +#define OBJ_ecdsa_with_Specified OBJ_X9_62_id_ecSigType,3L + +#define SN_ecdsa_with_SHA224 "ecdsa-with-SHA224" +#define NID_ecdsa_with_SHA224 793 +#define OBJ_ecdsa_with_SHA224 OBJ_ecdsa_with_Specified,1L + +#define SN_ecdsa_with_SHA256 "ecdsa-with-SHA256" +#define NID_ecdsa_with_SHA256 794 +#define OBJ_ecdsa_with_SHA256 OBJ_ecdsa_with_Specified,2L + +#define SN_ecdsa_with_SHA384 "ecdsa-with-SHA384" +#define NID_ecdsa_with_SHA384 795 +#define OBJ_ecdsa_with_SHA384 OBJ_ecdsa_with_Specified,3L + +#define SN_ecdsa_with_SHA512 "ecdsa-with-SHA512" +#define NID_ecdsa_with_SHA512 796 +#define OBJ_ecdsa_with_SHA512 OBJ_ecdsa_with_Specified,4L + +#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L + +#define SN_secp112r1 "secp112r1" +#define NID_secp112r1 704 +#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L + +#define SN_secp112r2 "secp112r2" +#define NID_secp112r2 705 +#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L + +#define SN_secp128r1 "secp128r1" +#define NID_secp128r1 706 +#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L + +#define SN_secp128r2 "secp128r2" +#define NID_secp128r2 707 +#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L + +#define SN_secp160k1 "secp160k1" +#define NID_secp160k1 708 +#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L + +#define SN_secp160r1 "secp160r1" +#define NID_secp160r1 709 +#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L + +#define SN_secp160r2 "secp160r2" +#define NID_secp160r2 710 +#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L + +#define SN_secp192k1 "secp192k1" +#define NID_secp192k1 711 +#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L + +#define SN_secp224k1 "secp224k1" +#define NID_secp224k1 712 +#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L + +#define SN_secp224r1 "secp224r1" +#define NID_secp224r1 713 +#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L + +#define SN_secp256k1 "secp256k1" +#define NID_secp256k1 714 +#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L + +#define SN_secp384r1 "secp384r1" +#define NID_secp384r1 715 +#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L + +#define SN_secp521r1 "secp521r1" +#define NID_secp521r1 716 +#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L + +#define SN_sect113r1 "sect113r1" +#define NID_sect113r1 717 +#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L + +#define SN_sect113r2 "sect113r2" +#define NID_sect113r2 718 +#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L + +#define SN_sect131r1 "sect131r1" +#define NID_sect131r1 719 +#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L + +#define SN_sect131r2 "sect131r2" +#define NID_sect131r2 720 +#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L + +#define SN_sect163k1 "sect163k1" +#define NID_sect163k1 721 +#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L + +#define SN_sect163r1 "sect163r1" +#define NID_sect163r1 722 +#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L + +#define SN_sect163r2 "sect163r2" +#define NID_sect163r2 723 +#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L + +#define SN_sect193r1 "sect193r1" +#define NID_sect193r1 724 +#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L + +#define SN_sect193r2 "sect193r2" +#define NID_sect193r2 725 +#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L + +#define SN_sect233k1 "sect233k1" +#define NID_sect233k1 726 +#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L + +#define SN_sect233r1 "sect233r1" +#define NID_sect233r1 727 +#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L + +#define SN_sect239k1 "sect239k1" +#define NID_sect239k1 728 +#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L + +#define SN_sect283k1 "sect283k1" +#define NID_sect283k1 729 +#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L + +#define SN_sect283r1 "sect283r1" +#define NID_sect283r1 730 +#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L + +#define SN_sect409k1 "sect409k1" +#define NID_sect409k1 731 +#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L + +#define SN_sect409r1 "sect409r1" +#define NID_sect409r1 732 +#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L + +#define SN_sect571k1 "sect571k1" +#define NID_sect571k1 733 +#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L + +#define SN_sect571r1 "sect571r1" +#define NID_sect571r1 734 +#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L + +#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L + +#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" +#define NID_wap_wsg_idm_ecid_wtls1 735 +#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L + +#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" +#define NID_wap_wsg_idm_ecid_wtls3 736 +#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L + +#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" +#define NID_wap_wsg_idm_ecid_wtls4 737 +#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L + +#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" +#define NID_wap_wsg_idm_ecid_wtls5 738 +#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L + +#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" +#define NID_wap_wsg_idm_ecid_wtls6 739 +#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L + +#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" +#define NID_wap_wsg_idm_ecid_wtls7 740 +#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L + +#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" +#define NID_wap_wsg_idm_ecid_wtls8 741 +#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L + +#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" +#define NID_wap_wsg_idm_ecid_wtls9 742 +#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L + +#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" +#define NID_wap_wsg_idm_ecid_wtls10 743 +#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L + +#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" +#define NID_wap_wsg_idm_ecid_wtls11 744 +#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L + +#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" +#define NID_wap_wsg_idm_ecid_wtls12 745 +#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L + +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L + +#define SN_id_PasswordBasedMAC "id-PasswordBasedMAC" +#define LN_id_PasswordBasedMAC "password based MAC" +#define NID_id_PasswordBasedMAC 782 +#define OBJ_id_PasswordBasedMAC OBJ_ISO_US,113533L,7L,66L,13L + +#define SN_id_DHBasedMac "id-DHBasedMac" +#define LN_id_DHBasedMac "Diffie-Hellman based MAC" +#define NID_id_DHBasedMac 783 +#define OBJ_id_DHBasedMac OBJ_ISO_US,113533L,7L,66L,30L + +#define SN_rsadsi "rsadsi" +#define LN_rsadsi "RSA Data Security, Inc." +#define NID_rsadsi 1 +#define OBJ_rsadsi OBJ_ISO_US,113549L + +#define SN_pkcs "pkcs" +#define LN_pkcs "RSA Data Security, Inc. PKCS" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_pkcs1 "pkcs1" +#define NID_pkcs1 186 +#define OBJ_pkcs1 OBJ_pkcs,1L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs1,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L + +#define SN_md4WithRSAEncryption "RSA-MD4" +#define LN_md4WithRSAEncryption "md4WithRSAEncryption" +#define NID_md4WithRSAEncryption 396 +#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L + +#define SN_rsaesOaep "RSAES-OAEP" +#define LN_rsaesOaep "rsaesOaep" +#define NID_rsaesOaep 919 +#define OBJ_rsaesOaep OBJ_pkcs1,7L + +#define SN_mgf1 "MGF1" +#define LN_mgf1 "mgf1" +#define NID_mgf1 911 +#define OBJ_mgf1 OBJ_pkcs1,8L + +#define SN_pSpecified "PSPECIFIED" +#define LN_pSpecified "pSpecified" +#define NID_pSpecified 935 +#define OBJ_pSpecified OBJ_pkcs1,9L + +#define SN_rsassaPss "RSASSA-PSS" +#define LN_rsassaPss "rsassaPss" +#define NID_rsassaPss 912 +#define OBJ_rsassaPss OBJ_pkcs1,10L + +#define SN_sha256WithRSAEncryption "RSA-SHA256" +#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" +#define NID_sha256WithRSAEncryption 668 +#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L + +#define SN_sha384WithRSAEncryption "RSA-SHA384" +#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" +#define NID_sha384WithRSAEncryption 669 +#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L + +#define SN_sha512WithRSAEncryption "RSA-SHA512" +#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" +#define NID_sha512WithRSAEncryption 670 +#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L + +#define SN_sha224WithRSAEncryption "RSA-SHA224" +#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" +#define NID_sha224WithRSAEncryption 671 +#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L + +#define SN_sha512_224WithRSAEncryption "RSA-SHA512/224" +#define LN_sha512_224WithRSAEncryption "sha512-224WithRSAEncryption" +#define NID_sha512_224WithRSAEncryption 1145 +#define OBJ_sha512_224WithRSAEncryption OBJ_pkcs1,15L + +#define SN_sha512_256WithRSAEncryption "RSA-SHA512/256" +#define LN_sha512_256WithRSAEncryption "sha512-256WithRSAEncryption" +#define NID_sha512_256WithRSAEncryption 1146 +#define OBJ_sha512_256WithRSAEncryption OBJ_pkcs1,16L + +#define SN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_pkcs5 "pkcs5" +#define NID_pkcs5 187 +#define OBJ_pkcs5 OBJ_pkcs,5L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L + +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L + +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs5,12L + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs5,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs5,14L + +#define SN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define SN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_ext_req "extReq" +#define LN_ext_req "Extension Request" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_SMIME "SMIME" +#define LN_SMIME "S/MIME" +#define NID_SMIME 188 +#define OBJ_SMIME OBJ_pkcs9,16L + +#define SN_id_smime_mod "id-smime-mod" +#define NID_id_smime_mod 189 +#define OBJ_id_smime_mod OBJ_SMIME,0L + +#define SN_id_smime_ct "id-smime-ct" +#define NID_id_smime_ct 190 +#define OBJ_id_smime_ct OBJ_SMIME,1L + +#define SN_id_smime_aa "id-smime-aa" +#define NID_id_smime_aa 191 +#define OBJ_id_smime_aa OBJ_SMIME,2L + +#define SN_id_smime_alg "id-smime-alg" +#define NID_id_smime_alg 192 +#define OBJ_id_smime_alg OBJ_SMIME,3L + +#define SN_id_smime_cd "id-smime-cd" +#define NID_id_smime_cd 193 +#define OBJ_id_smime_cd OBJ_SMIME,4L + +#define SN_id_smime_spq "id-smime-spq" +#define NID_id_smime_spq 194 +#define OBJ_id_smime_spq OBJ_SMIME,5L + +#define SN_id_smime_cti "id-smime-cti" +#define NID_id_smime_cti 195 +#define OBJ_id_smime_cti OBJ_SMIME,6L + +#define SN_id_smime_mod_cms "id-smime-mod-cms" +#define NID_id_smime_mod_cms 196 +#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L + +#define SN_id_smime_mod_ess "id-smime-mod-ess" +#define NID_id_smime_mod_ess 197 +#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L + +#define SN_id_smime_mod_oid "id-smime-mod-oid" +#define NID_id_smime_mod_oid 198 +#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L + +#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" +#define NID_id_smime_mod_msg_v3 199 +#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L + +#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" +#define NID_id_smime_mod_ets_eSignature_88 200 +#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L + +#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" +#define NID_id_smime_mod_ets_eSignature_97 201 +#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L + +#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" +#define NID_id_smime_mod_ets_eSigPolicy_88 202 +#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L + +#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" +#define NID_id_smime_mod_ets_eSigPolicy_97 203 +#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L + +#define SN_id_smime_ct_receipt "id-smime-ct-receipt" +#define NID_id_smime_ct_receipt 204 +#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L + +#define SN_id_smime_ct_authData "id-smime-ct-authData" +#define NID_id_smime_ct_authData 205 +#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L + +#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" +#define NID_id_smime_ct_publishCert 206 +#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L + +#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" +#define NID_id_smime_ct_TSTInfo 207 +#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L + +#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" +#define NID_id_smime_ct_TDTInfo 208 +#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L + +#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" +#define NID_id_smime_ct_contentInfo 209 +#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L + +#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" +#define NID_id_smime_ct_DVCSRequestData 210 +#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L + +#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" +#define NID_id_smime_ct_DVCSResponseData 211 +#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L + +#define SN_id_smime_ct_compressedData "id-smime-ct-compressedData" +#define NID_id_smime_ct_compressedData 786 +#define OBJ_id_smime_ct_compressedData OBJ_id_smime_ct,9L + +#define SN_id_smime_ct_contentCollection "id-smime-ct-contentCollection" +#define NID_id_smime_ct_contentCollection 1058 +#define OBJ_id_smime_ct_contentCollection OBJ_id_smime_ct,19L + +#define SN_id_smime_ct_authEnvelopedData "id-smime-ct-authEnvelopedData" +#define NID_id_smime_ct_authEnvelopedData 1059 +#define OBJ_id_smime_ct_authEnvelopedData OBJ_id_smime_ct,23L + +#define SN_id_ct_routeOriginAuthz "id-ct-routeOriginAuthz" +#define NID_id_ct_routeOriginAuthz 1234 +#define OBJ_id_ct_routeOriginAuthz OBJ_id_smime_ct,24L + +#define SN_id_ct_rpkiManifest "id-ct-rpkiManifest" +#define NID_id_ct_rpkiManifest 1235 +#define OBJ_id_ct_rpkiManifest OBJ_id_smime_ct,26L + +#define SN_id_ct_asciiTextWithCRLF "id-ct-asciiTextWithCRLF" +#define NID_id_ct_asciiTextWithCRLF 787 +#define OBJ_id_ct_asciiTextWithCRLF OBJ_id_smime_ct,27L + +#define SN_id_ct_xml "id-ct-xml" +#define NID_id_ct_xml 1060 +#define OBJ_id_ct_xml OBJ_id_smime_ct,28L + +#define SN_id_ct_rpkiGhostbusters "id-ct-rpkiGhostbusters" +#define NID_id_ct_rpkiGhostbusters 1236 +#define OBJ_id_ct_rpkiGhostbusters OBJ_id_smime_ct,35L + +#define SN_id_ct_resourceTaggedAttest "id-ct-resourceTaggedAttest" +#define NID_id_ct_resourceTaggedAttest 1237 +#define OBJ_id_ct_resourceTaggedAttest OBJ_id_smime_ct,36L + +#define SN_id_ct_geofeedCSVwithCRLF "id-ct-geofeedCSVwithCRLF" +#define NID_id_ct_geofeedCSVwithCRLF 1246 +#define OBJ_id_ct_geofeedCSVwithCRLF OBJ_id_smime_ct,47L + +#define SN_id_ct_signedChecklist "id-ct-signedChecklist" +#define NID_id_ct_signedChecklist 1247 +#define OBJ_id_ct_signedChecklist OBJ_id_smime_ct,48L + +#define SN_id_ct_ASPA "id-ct-ASPA" +#define NID_id_ct_ASPA 1250 +#define OBJ_id_ct_ASPA OBJ_id_smime_ct,49L + +#define SN_id_ct_signedTAL "id-ct-signedTAL" +#define NID_id_ct_signedTAL 1284 +#define OBJ_id_ct_signedTAL OBJ_id_smime_ct,50L + +#define SN_id_ct_rpkiSignedPrefixList "id-ct-rpkiSignedPrefixList" +#define NID_id_ct_rpkiSignedPrefixList 1320 +#define OBJ_id_ct_rpkiSignedPrefixList OBJ_id_smime_ct,51L + +#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" +#define NID_id_smime_aa_receiptRequest 212 +#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L + +#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" +#define NID_id_smime_aa_securityLabel 213 +#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L + +#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" +#define NID_id_smime_aa_mlExpandHistory 214 +#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L + +#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" +#define NID_id_smime_aa_contentHint 215 +#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L + +#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" +#define NID_id_smime_aa_msgSigDigest 216 +#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L + +#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" +#define NID_id_smime_aa_encapContentType 217 +#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L + +#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" +#define NID_id_smime_aa_contentIdentifier 218 +#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L + +#define SN_id_smime_aa_macValue "id-smime-aa-macValue" +#define NID_id_smime_aa_macValue 219 +#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L + +#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" +#define NID_id_smime_aa_equivalentLabels 220 +#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L + +#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" +#define NID_id_smime_aa_contentReference 221 +#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L + +#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" +#define NID_id_smime_aa_encrypKeyPref 222 +#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L + +#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" +#define NID_id_smime_aa_signingCertificate 223 +#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L + +#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" +#define NID_id_smime_aa_smimeEncryptCerts 224 +#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L + +#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" +#define NID_id_smime_aa_timeStampToken 225 +#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L + +#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" +#define NID_id_smime_aa_ets_sigPolicyId 226 +#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L + +#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" +#define NID_id_smime_aa_ets_commitmentType 227 +#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L + +#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" +#define NID_id_smime_aa_ets_signerLocation 228 +#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L + +#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" +#define NID_id_smime_aa_ets_signerAttr 229 +#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L + +#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" +#define NID_id_smime_aa_ets_otherSigCert 230 +#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L + +#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" +#define NID_id_smime_aa_ets_contentTimestamp 231 +#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L + +#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" +#define NID_id_smime_aa_ets_CertificateRefs 232 +#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L + +#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" +#define NID_id_smime_aa_ets_RevocationRefs 233 +#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L + +#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" +#define NID_id_smime_aa_ets_certValues 234 +#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L + +#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" +#define NID_id_smime_aa_ets_revocationValues 235 +#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L + +#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" +#define NID_id_smime_aa_ets_escTimeStamp 236 +#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L + +#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" +#define NID_id_smime_aa_ets_certCRLTimestamp 237 +#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L + +#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" +#define NID_id_smime_aa_ets_archiveTimeStamp 238 +#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L + +#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" +#define NID_id_smime_aa_signatureType 239 +#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L + +#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" +#define NID_id_smime_aa_dvcs_dvc 240 +#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L + +#define SN_id_aa_ets_attrCertificateRefs "id-aa-ets-attrCertificateRefs" +#define NID_id_aa_ets_attrCertificateRefs 1261 +#define OBJ_id_aa_ets_attrCertificateRefs OBJ_id_smime_aa,44L + +#define SN_id_aa_ets_attrRevocationRefs "id-aa-ets-attrRevocationRefs" +#define NID_id_aa_ets_attrRevocationRefs 1262 +#define OBJ_id_aa_ets_attrRevocationRefs OBJ_id_smime_aa,45L + +#define SN_id_smime_aa_signingCertificateV2 "id-smime-aa-signingCertificateV2" +#define NID_id_smime_aa_signingCertificateV2 1086 +#define OBJ_id_smime_aa_signingCertificateV2 OBJ_id_smime_aa,47L + +#define SN_id_aa_ets_archiveTimestampV2 "id-aa-ets-archiveTimestampV2" +#define NID_id_aa_ets_archiveTimestampV2 1280 +#define OBJ_id_aa_ets_archiveTimestampV2 OBJ_id_smime_aa,48L + +#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" +#define NID_id_smime_alg_ESDHwith3DES 241 +#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L + +#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" +#define NID_id_smime_alg_ESDHwithRC2 242 +#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L + +#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" +#define NID_id_smime_alg_3DESwrap 243 +#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L + +#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" +#define NID_id_smime_alg_RC2wrap 244 +#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L + +#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" +#define NID_id_smime_alg_ESDH 245 +#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L + +#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" +#define NID_id_smime_alg_CMS3DESwrap 246 +#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L + +#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" +#define NID_id_smime_alg_CMSRC2wrap 247 +#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L + +#define SN_id_alg_PWRI_KEK "id-alg-PWRI-KEK" +#define NID_id_alg_PWRI_KEK 893 +#define OBJ_id_alg_PWRI_KEK OBJ_id_smime_alg,9L + +#define SN_id_smime_cd_ldap "id-smime-cd-ldap" +#define NID_id_smime_cd_ldap 248 +#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L + +#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" +#define NID_id_smime_spq_ets_sqt_uri 249 +#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L + +#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" +#define NID_id_smime_spq_ets_sqt_unotice 250 +#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L + +#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" +#define NID_id_smime_cti_ets_proofOfOrigin 251 +#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L + +#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" +#define NID_id_smime_cti_ets_proofOfReceipt 252 +#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L + +#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" +#define NID_id_smime_cti_ets_proofOfDelivery 253 +#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L + +#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" +#define NID_id_smime_cti_ets_proofOfSender 254 +#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L + +#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" +#define NID_id_smime_cti_ets_proofOfApproval 255 +#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L + +#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" +#define NID_id_smime_cti_ets_proofOfCreation 256 +#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9,20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9,21L + +#define OBJ_ms_corp 1L,3L,6L,1L,4L,1L,311L + +#define SN_ms_csp_name "CSPName" +#define LN_ms_csp_name "Microsoft CSP Name" +#define NID_ms_csp_name 417 +#define OBJ_ms_csp_name OBJ_ms_corp,17L,1L + +#define SN_LocalKeySet "LocalKeySet" +#define LN_LocalKeySet "Microsoft Local Key set" +#define NID_LocalKeySet 856 +#define OBJ_LocalKeySet OBJ_ms_corp,17L,2L + +#define OBJ_certTypes OBJ_pkcs9,22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes,1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes,2L + +#define OBJ_crlTypes OBJ_pkcs9,23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes,1L + +#define SN_id_aa_CMSAlgorithmProtection "id-aa-CMSAlgorithmProtection" +#define NID_id_aa_CMSAlgorithmProtection 1263 +#define OBJ_id_aa_CMSAlgorithmProtection OBJ_pkcs9,52L + +#define OBJ_pkcs12 OBJ_pkcs,12L + +#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds,1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds,3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds,4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds,5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md4 "MD4" +#define LN_md4 "md4" +#define NID_md4 257 +#define OBJ_md4 OBJ_rsadsi,2L,4L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" +#define NID_md5_sha1 114 + +#define LN_hmacWithMD5 "hmacWithMD5" +#define NID_hmacWithMD5 797 +#define OBJ_hmacWithMD5 OBJ_rsadsi,2L,6L + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +#define SN_sm2 "SM2" +#define LN_sm2 "sm2" +#define NID_sm2 1172 +#define OBJ_sm2 OBJ_sm_scheme,301L + +#define SN_sm3 "SM3" +#define LN_sm3 "sm3" +#define NID_sm3 1143 +#define OBJ_sm3 OBJ_sm_scheme,401L + +#define SN_sm3WithRSAEncryption "RSA-SM3" +#define LN_sm3WithRSAEncryption "sm3WithRSAEncryption" +#define NID_sm3WithRSAEncryption 1144 +#define OBJ_sm3WithRSAEncryption OBJ_sm_scheme,504L + +#define SN_SM2_with_SM3 "SM2-SM3" +#define LN_SM2_with_SM3 "SM2-with-SM3" +#define NID_SM2_with_SM3 1204 +#define OBJ_SM2_with_SM3 OBJ_sm_scheme,501L + +#define LN_hmacWithSM3 "hmacWithSM3" +#define NID_hmacWithSM3 1281 +#define OBJ_hmacWithSM3 OBJ_sm3,3L,1L + +#define LN_hmacWithSHA224 "hmacWithSHA224" +#define NID_hmacWithSHA224 798 +#define OBJ_hmacWithSHA224 OBJ_rsadsi,2L,8L + +#define LN_hmacWithSHA256 "hmacWithSHA256" +#define NID_hmacWithSHA256 799 +#define OBJ_hmacWithSHA256 OBJ_rsadsi,2L,9L + +#define LN_hmacWithSHA384 "hmacWithSHA384" +#define NID_hmacWithSHA384 800 +#define OBJ_hmacWithSHA384 OBJ_rsadsi,2L,10L + +#define LN_hmacWithSHA512 "hmacWithSHA512" +#define NID_hmacWithSHA512 801 +#define OBJ_hmacWithSHA512 OBJ_rsadsi,2L,11L + +#define LN_hmacWithSHA512_224 "hmacWithSHA512-224" +#define NID_hmacWithSHA512_224 1193 +#define OBJ_hmacWithSHA512_224 OBJ_rsadsi,2L,12L + +#define LN_hmacWithSHA512_256 "hmacWithSHA512-256" +#define NID_hmacWithSHA512_256 1194 +#define OBJ_hmacWithSHA512_256 OBJ_rsadsi,2L,13L + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_ms_ext_req "msExtReq" +#define LN_ms_ext_req "Microsoft Extension Request" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req OBJ_ms_corp,2L,1L,14L + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind OBJ_ms_corp,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com OBJ_ms_corp,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign OBJ_ms_corp,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc OBJ_ms_corp,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs OBJ_ms_corp,10L,3L,4L + +#define SN_ms_smartcard_login "msSmartcardLogin" +#define LN_ms_smartcard_login "Microsoft Smartcard Login" +#define NID_ms_smartcard_login 648 +#define OBJ_ms_smartcard_login OBJ_ms_corp,20L,2L,2L + +#define SN_ms_upn "msUPN" +#define LN_ms_upn "Microsoft User Principal Name" +#define NID_ms_upn 649 +#define OBJ_ms_upn OBJ_ms_corp,20L,2L,3L + +#define SN_ms_ntds_sec_ext "ms-ntds-sec-ext" +#define LN_ms_ntds_sec_ext "Microsoft NTDS CA Extension" +#define NID_ms_ntds_sec_ext 1292 +#define OBJ_ms_ntds_sec_ext OBJ_ms_corp,25L,2L + +#define SN_ms_ntds_obj_sid "ms-ntds-obj-sid" +#define LN_ms_ntds_obj_sid "Microsoft NTDS AD objectSid" +#define NID_ms_ntds_obj_sid 1291 +#define OBJ_ms_ntds_obj_sid OBJ_ms_corp,25L,2L,1L + +#define SN_ms_cert_templ "ms-cert-templ" +#define LN_ms_cert_templ "Microsoft certificate template" +#define NID_ms_cert_templ 1293 +#define OBJ_ms_cert_templ OBJ_ms_corp,21L,7L + +#define SN_ms_app_policies "ms-app-policies" +#define LN_ms_app_policies "Microsoft Application Policies Extension" +#define NID_ms_app_policies 1294 +#define OBJ_ms_app_policies OBJ_ms_corp,21L,10L + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_pkix_mod "id-pkix-mod" +#define NID_id_pkix_mod 258 +#define OBJ_id_pkix_mod OBJ_id_pkix,0L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_qt "id-qt" +#define NID_id_qt 259 +#define OBJ_id_qt OBJ_id_pkix,2L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +#define SN_id_it "id-it" +#define NID_id_it 260 +#define OBJ_id_it OBJ_id_pkix,4L + +#define SN_id_pkip "id-pkip" +#define NID_id_pkip 261 +#define OBJ_id_pkip OBJ_id_pkix,5L + +#define SN_id_alg "id-alg" +#define NID_id_alg 262 +#define OBJ_id_alg OBJ_id_pkix,6L + +#define SN_id_cmc "id-cmc" +#define NID_id_cmc 263 +#define OBJ_id_cmc OBJ_id_pkix,7L + +#define SN_id_on "id-on" +#define NID_id_on 264 +#define OBJ_id_on OBJ_id_pkix,8L + +#define SN_id_pda "id-pda" +#define NID_id_pda 265 +#define OBJ_id_pda OBJ_id_pkix,9L + +#define SN_id_aca "id-aca" +#define NID_id_aca 266 +#define OBJ_id_aca OBJ_id_pkix,10L + +#define SN_id_qcs "id-qcs" +#define NID_id_qcs 267 +#define OBJ_id_qcs OBJ_id_pkix,11L + +#define SN_id_cp "id-cp" +#define NID_id_cp 1238 +#define OBJ_id_cp OBJ_id_pkix,14L + +#define SN_id_cct "id-cct" +#define NID_id_cct 268 +#define OBJ_id_cct OBJ_id_pkix,12L + +#define SN_id_ppl "id-ppl" +#define NID_id_ppl 662 +#define OBJ_id_ppl OBJ_id_pkix,21L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" +#define NID_id_pkix1_explicit_88 269 +#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L + +#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" +#define NID_id_pkix1_implicit_88 270 +#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L + +#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" +#define NID_id_pkix1_explicit_93 271 +#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L + +#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" +#define NID_id_pkix1_implicit_93 272 +#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L + +#define SN_id_mod_crmf "id-mod-crmf" +#define NID_id_mod_crmf 273 +#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L + +#define SN_id_mod_cmc "id-mod-cmc" +#define NID_id_mod_cmc 274 +#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L + +#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" +#define NID_id_mod_kea_profile_88 275 +#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L + +#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" +#define NID_id_mod_kea_profile_93 276 +#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L + +#define SN_id_mod_cmp "id-mod-cmp" +#define NID_id_mod_cmp 277 +#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L + +#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" +#define NID_id_mod_qualified_cert_88 278 +#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L + +#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" +#define NID_id_mod_qualified_cert_93 279 +#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L + +#define SN_id_mod_attribute_cert "id-mod-attribute-cert" +#define NID_id_mod_attribute_cert 280 +#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L + +#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" +#define NID_id_mod_timestamp_protocol 281 +#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L + +#define SN_id_mod_ocsp "id-mod-ocsp" +#define NID_id_mod_ocsp 282 +#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L + +#define SN_id_mod_dvcs "id-mod-dvcs" +#define NID_id_mod_dvcs 283 +#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L + +#define SN_id_mod_cmp2000 "id-mod-cmp2000" +#define NID_id_mod_cmp2000 284 +#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L + +#define SN_id_mod_cmp2000_02 "id-mod-cmp2000-02" +#define NID_id_mod_cmp2000_02 1251 +#define OBJ_id_mod_cmp2000_02 OBJ_id_pkix_mod,50L + +#define SN_id_mod_cmp2021_88 "id-mod-cmp2021-88" +#define NID_id_mod_cmp2021_88 1252 +#define OBJ_id_mod_cmp2021_88 OBJ_id_pkix_mod,99L + +#define SN_id_mod_cmp2021_02 "id-mod-cmp2021-02" +#define NID_id_mod_cmp2021_02 1253 +#define OBJ_id_mod_cmp2021_02 OBJ_id_pkix_mod,100L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_biometricInfo "biometricInfo" +#define LN_biometricInfo "Biometric Info" +#define NID_biometricInfo 285 +#define OBJ_biometricInfo OBJ_id_pe,2L + +#define SN_qcStatements "qcStatements" +#define NID_qcStatements 286 +#define OBJ_qcStatements OBJ_id_pe,3L + +#define SN_ac_auditIdentity "ac-auditIdentity" +#define LN_ac_auditIdentity "X509v3 Audit Identity" +#define NID_ac_auditIdentity 287 +#define OBJ_ac_auditIdentity OBJ_id_pe,4L + +#define NID_ac_auditEntity 1323 +#define OBJ_ac_auditEntity OBJ_ac_auditIdentity + +#define SN_ac_targeting "ac-targeting" +#define NID_ac_targeting 288 +#define OBJ_ac_targeting OBJ_id_pe,5L + +#define SN_aaControls "aaControls" +#define NID_aaControls 289 +#define OBJ_aaControls OBJ_id_pe,6L + +#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" +#define NID_sbgp_ipAddrBlock 290 +#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L + +#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" +#define NID_sbgp_autonomousSysNum 291 +#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L + +#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" +#define NID_sbgp_routerIdentifier 292 +#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L + +#define SN_ac_proxying "ac-proxying" +#define NID_ac_proxying 397 +#define OBJ_ac_proxying OBJ_id_pe,10L + +#define SN_sinfo_access "subjectInfoAccess" +#define LN_sinfo_access "Subject Information Access" +#define NID_sinfo_access 398 +#define OBJ_sinfo_access OBJ_id_pe,11L + +#define SN_proxyCertInfo "proxyCertInfo" +#define LN_proxyCertInfo "Proxy Certificate Information" +#define NID_proxyCertInfo 663 +#define OBJ_proxyCertInfo OBJ_id_pe,14L + +#define SN_tlsfeature "tlsfeature" +#define LN_tlsfeature "TLS Feature" +#define NID_tlsfeature 1020 +#define OBJ_tlsfeature OBJ_id_pe,24L + +#define SN_sbgp_ipAddrBlockv2 "sbgp-ipAddrBlockv2" +#define NID_sbgp_ipAddrBlockv2 1239 +#define OBJ_sbgp_ipAddrBlockv2 OBJ_id_pe,28L + +#define SN_sbgp_autonomousSysNumv2 "sbgp-autonomousSysNumv2" +#define NID_sbgp_autonomousSysNumv2 1240 +#define OBJ_sbgp_autonomousSysNumv2 OBJ_id_pe,29L + +#define SN_id_qt_cps "id-qt-cps" +#define LN_id_qt_cps "Policy Qualifier CPS" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_qt,1L + +#define SN_id_qt_unotice "id-qt-unotice" +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_qt,2L + +#define SN_textNotice "textNotice" +#define NID_textNotice 293 +#define OBJ_textNotice OBJ_id_qt,3L + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_ipsecEndSystem "ipsecEndSystem" +#define LN_ipsecEndSystem "IPSec End System" +#define NID_ipsecEndSystem 294 +#define OBJ_ipsecEndSystem OBJ_id_kp,5L + +#define SN_ipsecTunnel "ipsecTunnel" +#define LN_ipsecTunnel "IPSec Tunnel" +#define NID_ipsecTunnel 295 +#define OBJ_ipsecTunnel OBJ_id_kp,6L + +#define SN_ipsecUser "ipsecUser" +#define LN_ipsecUser "IPSec User" +#define NID_ipsecUser 296 +#define OBJ_ipsecUser OBJ_id_kp,7L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L + +#define SN_dvcs "DVCS" +#define LN_dvcs "dvcs" +#define NID_dvcs 297 +#define OBJ_dvcs OBJ_id_kp,10L + +#define SN_ipsec_IKE "ipsecIKE" +#define LN_ipsec_IKE "ipsec Internet Key Exchange" +#define NID_ipsec_IKE 1022 +#define OBJ_ipsec_IKE OBJ_id_kp,17L + +#define SN_capwapAC "capwapAC" +#define LN_capwapAC "Ctrl/provision WAP Access" +#define NID_capwapAC 1023 +#define OBJ_capwapAC OBJ_id_kp,18L + +#define SN_capwapWTP "capwapWTP" +#define LN_capwapWTP "Ctrl/Provision WAP Termination" +#define NID_capwapWTP 1024 +#define OBJ_capwapWTP OBJ_id_kp,19L + +#define SN_sshClient "secureShellClient" +#define LN_sshClient "SSH Client" +#define NID_sshClient 1025 +#define OBJ_sshClient OBJ_id_kp,21L + +#define SN_sshServer "secureShellServer" +#define LN_sshServer "SSH Server" +#define NID_sshServer 1026 +#define OBJ_sshServer OBJ_id_kp,22L + +#define SN_sendRouter "sendRouter" +#define LN_sendRouter "Send Router" +#define NID_sendRouter 1027 +#define OBJ_sendRouter OBJ_id_kp,23L + +#define SN_sendProxiedRouter "sendProxiedRouter" +#define LN_sendProxiedRouter "Send Proxied Router" +#define NID_sendProxiedRouter 1028 +#define OBJ_sendProxiedRouter OBJ_id_kp,24L + +#define SN_sendOwner "sendOwner" +#define LN_sendOwner "Send Owner" +#define NID_sendOwner 1029 +#define OBJ_sendOwner OBJ_id_kp,25L + +#define SN_sendProxiedOwner "sendProxiedOwner" +#define LN_sendProxiedOwner "Send Proxied Owner" +#define NID_sendProxiedOwner 1030 +#define OBJ_sendProxiedOwner OBJ_id_kp,26L + +#define SN_cmcCA "cmcCA" +#define LN_cmcCA "CMC Certificate Authority" +#define NID_cmcCA 1131 +#define OBJ_cmcCA OBJ_id_kp,27L + +#define SN_cmcRA "cmcRA" +#define LN_cmcRA "CMC Registration Authority" +#define NID_cmcRA 1132 +#define OBJ_cmcRA OBJ_id_kp,28L + +#define SN_cmcArchive "cmcArchive" +#define LN_cmcArchive "CMC Archive Server" +#define NID_cmcArchive 1219 +#define OBJ_cmcArchive OBJ_id_kp,29L + +#define SN_id_kp_bgpsec_router "id-kp-bgpsec-router" +#define LN_id_kp_bgpsec_router "BGPsec Router" +#define NID_id_kp_bgpsec_router 1220 +#define OBJ_id_kp_bgpsec_router OBJ_id_kp,30L + +#define SN_id_kp_BrandIndicatorforMessageIdentification "id-kp-BrandIndicatorforMessageIdentification" +#define LN_id_kp_BrandIndicatorforMessageIdentification "Brand Indicator for Message Identification" +#define NID_id_kp_BrandIndicatorforMessageIdentification 1221 +#define OBJ_id_kp_BrandIndicatorforMessageIdentification OBJ_id_kp,31L + +#define SN_cmKGA "cmKGA" +#define LN_cmKGA "Certificate Management Key Generation Authority" +#define NID_cmKGA 1222 +#define OBJ_cmKGA OBJ_id_kp,32L + +#define SN_id_it_caProtEncCert "id-it-caProtEncCert" +#define NID_id_it_caProtEncCert 298 +#define OBJ_id_it_caProtEncCert OBJ_id_it,1L + +#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" +#define NID_id_it_signKeyPairTypes 299 +#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L + +#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" +#define NID_id_it_encKeyPairTypes 300 +#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L + +#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" +#define NID_id_it_preferredSymmAlg 301 +#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L + +#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" +#define NID_id_it_caKeyUpdateInfo 302 +#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L + +#define SN_id_it_currentCRL "id-it-currentCRL" +#define NID_id_it_currentCRL 303 +#define OBJ_id_it_currentCRL OBJ_id_it,6L + +#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" +#define NID_id_it_unsupportedOIDs 304 +#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L + +#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" +#define NID_id_it_subscriptionRequest 305 +#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L + +#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" +#define NID_id_it_subscriptionResponse 306 +#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L + +#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" +#define NID_id_it_keyPairParamReq 307 +#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L + +#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" +#define NID_id_it_keyPairParamRep 308 +#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L + +#define SN_id_it_revPassphrase "id-it-revPassphrase" +#define NID_id_it_revPassphrase 309 +#define OBJ_id_it_revPassphrase OBJ_id_it,12L + +#define SN_id_it_implicitConfirm "id-it-implicitConfirm" +#define NID_id_it_implicitConfirm 310 +#define OBJ_id_it_implicitConfirm OBJ_id_it,13L + +#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" +#define NID_id_it_confirmWaitTime 311 +#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L + +#define SN_id_it_origPKIMessage "id-it-origPKIMessage" +#define NID_id_it_origPKIMessage 312 +#define OBJ_id_it_origPKIMessage OBJ_id_it,15L + +#define SN_id_it_suppLangTags "id-it-suppLangTags" +#define NID_id_it_suppLangTags 784 +#define OBJ_id_it_suppLangTags OBJ_id_it,16L + +#define SN_id_it_caCerts "id-it-caCerts" +#define NID_id_it_caCerts 1223 +#define OBJ_id_it_caCerts OBJ_id_it,17L + +#define SN_id_it_rootCaKeyUpdate "id-it-rootCaKeyUpdate" +#define NID_id_it_rootCaKeyUpdate 1224 +#define OBJ_id_it_rootCaKeyUpdate OBJ_id_it,18L + +#define SN_id_it_certReqTemplate "id-it-certReqTemplate" +#define NID_id_it_certReqTemplate 1225 +#define OBJ_id_it_certReqTemplate OBJ_id_it,19L + +#define SN_id_it_rootCaCert "id-it-rootCaCert" +#define NID_id_it_rootCaCert 1254 +#define OBJ_id_it_rootCaCert OBJ_id_it,20L + +#define SN_id_it_certProfile "id-it-certProfile" +#define NID_id_it_certProfile 1255 +#define OBJ_id_it_certProfile OBJ_id_it,21L + +#define SN_id_it_crlStatusList "id-it-crlStatusList" +#define NID_id_it_crlStatusList 1256 +#define OBJ_id_it_crlStatusList OBJ_id_it,22L + +#define SN_id_it_crls "id-it-crls" +#define NID_id_it_crls 1257 +#define OBJ_id_it_crls OBJ_id_it,23L + +#define SN_id_regCtrl "id-regCtrl" +#define NID_id_regCtrl 313 +#define OBJ_id_regCtrl OBJ_id_pkip,1L + +#define SN_id_regInfo "id-regInfo" +#define NID_id_regInfo 314 +#define OBJ_id_regInfo OBJ_id_pkip,2L + +#define SN_id_regCtrl_regToken "id-regCtrl-regToken" +#define NID_id_regCtrl_regToken 315 +#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L + +#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" +#define NID_id_regCtrl_authenticator 316 +#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L + +#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" +#define NID_id_regCtrl_pkiPublicationInfo 317 +#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L + +#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" +#define NID_id_regCtrl_pkiArchiveOptions 318 +#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L + +#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" +#define NID_id_regCtrl_oldCertID 319 +#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L + +#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" +#define NID_id_regCtrl_protocolEncrKey 320 +#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L + +#define SN_id_regCtrl_altCertTemplate "id-regCtrl-altCertTemplate" +#define NID_id_regCtrl_altCertTemplate 1258 +#define OBJ_id_regCtrl_altCertTemplate OBJ_id_regCtrl,7L + +#define SN_id_regCtrl_algId "id-regCtrl-algId" +#define NID_id_regCtrl_algId 1259 +#define OBJ_id_regCtrl_algId OBJ_id_regCtrl,11L + +#define SN_id_regCtrl_rsaKeyLen "id-regCtrl-rsaKeyLen" +#define NID_id_regCtrl_rsaKeyLen 1260 +#define OBJ_id_regCtrl_rsaKeyLen OBJ_id_regCtrl,12L + +#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" +#define NID_id_regInfo_utf8Pairs 321 +#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L + +#define SN_id_regInfo_certReq "id-regInfo-certReq" +#define NID_id_regInfo_certReq 322 +#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L + +#define SN_id_alg_des40 "id-alg-des40" +#define NID_id_alg_des40 323 +#define OBJ_id_alg_des40 OBJ_id_alg,1L + +#define SN_id_alg_noSignature "id-alg-noSignature" +#define NID_id_alg_noSignature 324 +#define OBJ_id_alg_noSignature OBJ_id_alg,2L + +#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" +#define NID_id_alg_dh_sig_hmac_sha1 325 +#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L + +#define SN_id_alg_dh_pop "id-alg-dh-pop" +#define NID_id_alg_dh_pop 326 +#define OBJ_id_alg_dh_pop OBJ_id_alg,4L + +#define SN_id_cmc_statusInfo "id-cmc-statusInfo" +#define NID_id_cmc_statusInfo 327 +#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L + +#define SN_id_cmc_identification "id-cmc-identification" +#define NID_id_cmc_identification 328 +#define OBJ_id_cmc_identification OBJ_id_cmc,2L + +#define SN_id_cmc_identityProof "id-cmc-identityProof" +#define NID_id_cmc_identityProof 329 +#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L + +#define SN_id_cmc_dataReturn "id-cmc-dataReturn" +#define NID_id_cmc_dataReturn 330 +#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L + +#define SN_id_cmc_transactionId "id-cmc-transactionId" +#define NID_id_cmc_transactionId 331 +#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L + +#define SN_id_cmc_senderNonce "id-cmc-senderNonce" +#define NID_id_cmc_senderNonce 332 +#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L + +#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" +#define NID_id_cmc_recipientNonce 333 +#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L + +#define SN_id_cmc_addExtensions "id-cmc-addExtensions" +#define NID_id_cmc_addExtensions 334 +#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L + +#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" +#define NID_id_cmc_encryptedPOP 335 +#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L + +#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" +#define NID_id_cmc_decryptedPOP 336 +#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L + +#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" +#define NID_id_cmc_lraPOPWitness 337 +#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L + +#define SN_id_cmc_getCert "id-cmc-getCert" +#define NID_id_cmc_getCert 338 +#define OBJ_id_cmc_getCert OBJ_id_cmc,15L + +#define SN_id_cmc_getCRL "id-cmc-getCRL" +#define NID_id_cmc_getCRL 339 +#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L + +#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" +#define NID_id_cmc_revokeRequest 340 +#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L + +#define SN_id_cmc_regInfo "id-cmc-regInfo" +#define NID_id_cmc_regInfo 341 +#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L + +#define SN_id_cmc_responseInfo "id-cmc-responseInfo" +#define NID_id_cmc_responseInfo 342 +#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L + +#define SN_id_cmc_queryPending "id-cmc-queryPending" +#define NID_id_cmc_queryPending 343 +#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L + +#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" +#define NID_id_cmc_popLinkRandom 344 +#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L + +#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" +#define NID_id_cmc_popLinkWitness 345 +#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L + +#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" +#define NID_id_cmc_confirmCertAcceptance 346 +#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L + +#define SN_id_on_personalData "id-on-personalData" +#define NID_id_on_personalData 347 +#define OBJ_id_on_personalData OBJ_id_on,1L + +#define SN_id_on_permanentIdentifier "id-on-permanentIdentifier" +#define LN_id_on_permanentIdentifier "Permanent Identifier" +#define NID_id_on_permanentIdentifier 858 +#define OBJ_id_on_permanentIdentifier OBJ_id_on,3L + +#define SN_id_on_hardwareModuleName "id-on-hardwareModuleName" +#define LN_id_on_hardwareModuleName "Hardware Module Name" +#define NID_id_on_hardwareModuleName 1321 +#define OBJ_id_on_hardwareModuleName OBJ_id_on,4L + +#define SN_XmppAddr "id-on-xmppAddr" +#define LN_XmppAddr "XmppAddr" +#define NID_XmppAddr 1209 +#define OBJ_XmppAddr OBJ_id_on,5L + +#define SN_SRVName "id-on-dnsSRV" +#define LN_SRVName "SRVName" +#define NID_SRVName 1210 +#define OBJ_SRVName OBJ_id_on,7L + +#define SN_NAIRealm "id-on-NAIRealm" +#define LN_NAIRealm "NAIRealm" +#define NID_NAIRealm 1211 +#define OBJ_NAIRealm OBJ_id_on,8L + +#define SN_id_on_SmtpUTF8Mailbox "id-on-SmtpUTF8Mailbox" +#define LN_id_on_SmtpUTF8Mailbox "Smtp UTF8 Mailbox" +#define NID_id_on_SmtpUTF8Mailbox 1208 +#define OBJ_id_on_SmtpUTF8Mailbox OBJ_id_on,9L + +#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" +#define NID_id_pda_dateOfBirth 348 +#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L + +#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" +#define NID_id_pda_placeOfBirth 349 +#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L + +#define SN_id_pda_gender "id-pda-gender" +#define NID_id_pda_gender 351 +#define OBJ_id_pda_gender OBJ_id_pda,3L + +#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" +#define NID_id_pda_countryOfCitizenship 352 +#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L + +#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" +#define NID_id_pda_countryOfResidence 353 +#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L + +#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" +#define NID_id_aca_authenticationInfo 354 +#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L + +#define SN_id_aca_accessIdentity "id-aca-accessIdentity" +#define NID_id_aca_accessIdentity 355 +#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L + +#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" +#define NID_id_aca_chargingIdentity 356 +#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L + +#define SN_id_aca_group "id-aca-group" +#define NID_id_aca_group 357 +#define OBJ_id_aca_group OBJ_id_aca,4L + +#define SN_id_aca_role "id-aca-role" +#define NID_id_aca_role 358 +#define OBJ_id_aca_role OBJ_id_aca,5L + +#define SN_id_aca_encAttrs "id-aca-encAttrs" +#define NID_id_aca_encAttrs 399 +#define OBJ_id_aca_encAttrs OBJ_id_aca,6L + +#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" +#define NID_id_qcs_pkixQCSyntax_v1 359 +#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L + +#define SN_ipAddr_asNumber "ipAddr-asNumber" +#define NID_ipAddr_asNumber 1241 +#define OBJ_ipAddr_asNumber OBJ_id_cp,2L + +#define SN_ipAddr_asNumberv2 "ipAddr-asNumberv2" +#define NID_ipAddr_asNumberv2 1242 +#define OBJ_ipAddr_asNumberv2 OBJ_id_cp,3L + +#define SN_id_cct_crs "id-cct-crs" +#define NID_id_cct_crs 360 +#define OBJ_id_cct_crs OBJ_id_cct,1L + +#define SN_id_cct_PKIData "id-cct-PKIData" +#define NID_id_cct_PKIData 361 +#define OBJ_id_cct_PKIData OBJ_id_cct,2L + +#define SN_id_cct_PKIResponse "id-cct-PKIResponse" +#define NID_id_cct_PKIResponse 362 +#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L + +#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" +#define LN_id_ppl_anyLanguage "Any language" +#define NID_id_ppl_anyLanguage 664 +#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L + +#define SN_id_ppl_inheritAll "id-ppl-inheritAll" +#define LN_id_ppl_inheritAll "Inherit all" +#define NID_id_ppl_inheritAll 665 +#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L + +#define SN_Independent "id-ppl-independent" +#define LN_Independent "Independent" +#define NID_Independent 667 +#define OBJ_Independent OBJ_id_ppl,2L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_ad_timeStamping "ad_timestamping" +#define LN_ad_timeStamping "AD Time Stamping" +#define NID_ad_timeStamping 363 +#define OBJ_ad_timeStamping OBJ_id_ad,3L + +#define SN_ad_dvcs "AD_DVCS" +#define LN_ad_dvcs "ad dvcs" +#define NID_ad_dvcs 364 +#define OBJ_ad_dvcs OBJ_id_ad,4L + +#define SN_caRepository "caRepository" +#define LN_caRepository "CA Repository" +#define NID_caRepository 785 +#define OBJ_caRepository OBJ_id_ad,5L + +#define SN_rpkiManifest "rpkiManifest" +#define LN_rpkiManifest "RPKI Manifest" +#define NID_rpkiManifest 1243 +#define OBJ_rpkiManifest OBJ_id_ad,10L + +#define SN_signedObject "signedObject" +#define LN_signedObject "Signed Object" +#define NID_signedObject 1244 +#define OBJ_signedObject OBJ_id_ad,11L + +#define SN_rpkiNotify "rpkiNotify" +#define LN_rpkiNotify "RPKI Notify" +#define NID_rpkiNotify 1245 +#define OBJ_rpkiNotify OBJ_id_ad,13L + +#define OBJ_id_pkix_OCSP OBJ_ad_OCSP + +#define SN_id_pkix_OCSP_basic "basicOCSPResponse" +#define LN_id_pkix_OCSP_basic "Basic OCSP Response" +#define NID_id_pkix_OCSP_basic 365 +#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L + +#define SN_id_pkix_OCSP_Nonce "Nonce" +#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" +#define NID_id_pkix_OCSP_Nonce 366 +#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L + +#define SN_id_pkix_OCSP_CrlID "CrlID" +#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" +#define NID_id_pkix_OCSP_CrlID 367 +#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L + +#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" +#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" +#define NID_id_pkix_OCSP_acceptableResponses 368 +#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L + +#define SN_id_pkix_OCSP_noCheck "noCheck" +#define LN_id_pkix_OCSP_noCheck "OCSP No Check" +#define NID_id_pkix_OCSP_noCheck 369 +#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L + +#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" +#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" +#define NID_id_pkix_OCSP_archiveCutoff 370 +#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L + +#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" +#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" +#define NID_id_pkix_OCSP_serviceLocator 371 +#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L + +#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" +#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" +#define NID_id_pkix_OCSP_extendedStatus 372 +#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L + +#define SN_id_pkix_OCSP_valid "valid" +#define NID_id_pkix_OCSP_valid 373 +#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L + +#define SN_id_pkix_OCSP_path "path" +#define NID_id_pkix_OCSP_path 374 +#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L + +#define SN_id_pkix_OCSP_trustRoot "trustRoot" +#define LN_id_pkix_OCSP_trustRoot "Trust Root" +#define NID_id_pkix_OCSP_trustRoot 375 +#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L + +#define SN_algorithm "algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 376 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_rsaSignature "rsaSignature" +#define NID_rsaSignature 377 +#define OBJ_rsaSignature OBJ_algorithm,11L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_ecb "DES-EDE" +#define LN_des_ede_ecb "des-ede" +#define NID_des_ede_ecb 32 +#define OBJ_des_ede_ecb OBJ_algorithm,17L + +#define SN_des_ede3_ecb "DES-EDE3" +#define LN_des_ede3_ecb "des-ede3" +#define NID_des_ede3_ecb 33 + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +#define SN_blake2bmac "BLAKE2BMAC" +#define LN_blake2bmac "blake2bmac" +#define NID_blake2bmac 1201 +#define OBJ_blake2bmac 1L,3L,6L,1L,4L,1L,1722L,12L,2L,1L + +#define SN_blake2smac "BLAKE2SMAC" +#define LN_blake2smac "blake2smac" +#define NID_blake2smac 1202 +#define OBJ_blake2smac 1L,3L,6L,1L,4L,1L,1722L,12L,2L,2L + +#define SN_blake2b512 "BLAKE2b512" +#define LN_blake2b512 "blake2b512" +#define NID_blake2b512 1056 +#define OBJ_blake2b512 OBJ_blake2bmac,16L + +#define SN_blake2s256 "BLAKE2s256" +#define LN_blake2s256 "blake2s256" +#define NID_blake2s256 1057 +#define OBJ_blake2s256 OBJ_blake2smac,8L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +#define SN_X500 "X500" +#define LN_X500 "directory services (X.500)" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define SN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_surname "SN" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define SN_streetAddress "street" +#define LN_streetAddress "streetAddress" +#define NID_streetAddress 660 +#define OBJ_streetAddress OBJ_X509,9L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define SN_title "title" +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +#define LN_searchGuide "searchGuide" +#define NID_searchGuide 859 +#define OBJ_searchGuide OBJ_X509,14L + +#define LN_businessCategory "businessCategory" +#define NID_businessCategory 860 +#define OBJ_businessCategory OBJ_X509,15L + +#define LN_postalAddress "postalAddress" +#define NID_postalAddress 861 +#define OBJ_postalAddress OBJ_X509,16L + +#define LN_postalCode "postalCode" +#define NID_postalCode 661 +#define OBJ_postalCode OBJ_X509,17L + +#define LN_postOfficeBox "postOfficeBox" +#define NID_postOfficeBox 862 +#define OBJ_postOfficeBox OBJ_X509,18L + +#define LN_physicalDeliveryOfficeName "physicalDeliveryOfficeName" +#define NID_physicalDeliveryOfficeName 863 +#define OBJ_physicalDeliveryOfficeName OBJ_X509,19L + +#define LN_telephoneNumber "telephoneNumber" +#define NID_telephoneNumber 864 +#define OBJ_telephoneNumber OBJ_X509,20L + +#define LN_telexNumber "telexNumber" +#define NID_telexNumber 865 +#define OBJ_telexNumber OBJ_X509,21L + +#define LN_teletexTerminalIdentifier "teletexTerminalIdentifier" +#define NID_teletexTerminalIdentifier 866 +#define OBJ_teletexTerminalIdentifier OBJ_X509,22L + +#define LN_facsimileTelephoneNumber "facsimileTelephoneNumber" +#define NID_facsimileTelephoneNumber 867 +#define OBJ_facsimileTelephoneNumber OBJ_X509,23L + +#define LN_x121Address "x121Address" +#define NID_x121Address 868 +#define OBJ_x121Address OBJ_X509,24L + +#define LN_internationaliSDNNumber "internationaliSDNNumber" +#define NID_internationaliSDNNumber 869 +#define OBJ_internationaliSDNNumber OBJ_X509,25L + +#define LN_registeredAddress "registeredAddress" +#define NID_registeredAddress 870 +#define OBJ_registeredAddress OBJ_X509,26L + +#define LN_destinationIndicator "destinationIndicator" +#define NID_destinationIndicator 871 +#define OBJ_destinationIndicator OBJ_X509,27L + +#define LN_preferredDeliveryMethod "preferredDeliveryMethod" +#define NID_preferredDeliveryMethod 872 +#define OBJ_preferredDeliveryMethod OBJ_X509,28L + +#define LN_presentationAddress "presentationAddress" +#define NID_presentationAddress 873 +#define OBJ_presentationAddress OBJ_X509,29L + +#define LN_supportedApplicationContext "supportedApplicationContext" +#define NID_supportedApplicationContext 874 +#define OBJ_supportedApplicationContext OBJ_X509,30L + +#define SN_member "member" +#define NID_member 875 +#define OBJ_member OBJ_X509,31L + +#define SN_owner "owner" +#define NID_owner 876 +#define OBJ_owner OBJ_X509,32L + +#define LN_roleOccupant "roleOccupant" +#define NID_roleOccupant 877 +#define OBJ_roleOccupant OBJ_X509,33L + +#define SN_seeAlso "seeAlso" +#define NID_seeAlso 878 +#define OBJ_seeAlso OBJ_X509,34L + +#define LN_userPassword "userPassword" +#define NID_userPassword 879 +#define OBJ_userPassword OBJ_X509,35L + +#define LN_userCertificate "userCertificate" +#define NID_userCertificate 880 +#define OBJ_userCertificate OBJ_X509,36L + +#define LN_cACertificate "cACertificate" +#define NID_cACertificate 881 +#define OBJ_cACertificate OBJ_X509,37L + +#define LN_authorityRevocationList "authorityRevocationList" +#define NID_authorityRevocationList 882 +#define OBJ_authorityRevocationList OBJ_X509,38L + +#define LN_certificateRevocationList "certificateRevocationList" +#define NID_certificateRevocationList 883 +#define OBJ_certificateRevocationList OBJ_X509,39L + +#define LN_crossCertificatePair "crossCertificatePair" +#define NID_crossCertificatePair 884 +#define OBJ_crossCertificatePair OBJ_X509,40L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_givenName "GN" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define SN_initials "initials" +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define LN_generationQualifier "generationQualifier" +#define NID_generationQualifier 509 +#define OBJ_generationQualifier OBJ_X509,44L + +#define LN_x500UniqueIdentifier "x500UniqueIdentifier" +#define NID_x500UniqueIdentifier 503 +#define OBJ_x500UniqueIdentifier OBJ_X509,45L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define LN_enhancedSearchGuide "enhancedSearchGuide" +#define NID_enhancedSearchGuide 885 +#define OBJ_enhancedSearchGuide OBJ_X509,47L + +#define LN_protocolInformation "protocolInformation" +#define NID_protocolInformation 886 +#define OBJ_protocolInformation OBJ_X509,48L + +#define LN_distinguishedName "distinguishedName" +#define NID_distinguishedName 887 +#define OBJ_distinguishedName OBJ_X509,49L + +#define LN_uniqueMember "uniqueMember" +#define NID_uniqueMember 888 +#define OBJ_uniqueMember OBJ_X509,50L + +#define LN_houseIdentifier "houseIdentifier" +#define NID_houseIdentifier 889 +#define OBJ_houseIdentifier OBJ_X509,51L + +#define LN_supportedAlgorithms "supportedAlgorithms" +#define NID_supportedAlgorithms 890 +#define OBJ_supportedAlgorithms OBJ_X509,52L + +#define LN_deltaRevocationList "deltaRevocationList" +#define NID_deltaRevocationList 891 +#define OBJ_deltaRevocationList OBJ_X509,53L + +#define SN_dmdName "dmdName" +#define NID_dmdName 892 +#define OBJ_dmdName OBJ_X509,54L + +#define LN_pseudonym "pseudonym" +#define NID_pseudonym 510 +#define OBJ_pseudonym OBJ_X509,65L + +#define SN_role "role" +#define LN_role "role" +#define NID_role 400 +#define OBJ_role OBJ_X509,72L + +#define LN_organizationIdentifier "organizationIdentifier" +#define NID_organizationIdentifier 1089 +#define OBJ_organizationIdentifier OBJ_X509,97L + +#define SN_countryCode3c "c3" +#define LN_countryCode3c "countryCode3c" +#define NID_countryCode3c 1090 +#define OBJ_countryCode3c OBJ_X509,98L + +#define SN_countryCode3n "n3" +#define LN_countryCode3n "countryCode3n" +#define NID_countryCode3n 1091 +#define OBJ_countryCode3n OBJ_X509,99L + +#define LN_dnsName "dnsName" +#define NID_dnsName 1092 +#define OBJ_dnsName OBJ_X509,100L + +#define SN_X500algorithms "X500algorithms" +#define LN_X500algorithms "directory services - algorithms" +#define NID_X500algorithms 378 +#define OBJ_X500algorithms OBJ_X500,8L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500algorithms,1L,1L + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2WithRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 OBJ_X500algorithms,3L,101L + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce OBJ_X500,29L + +#define SN_subject_directory_attributes "subjectDirectoryAttributes" +#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes" +#define NID_subject_directory_attributes 769 +#define OBJ_subject_directory_attributes OBJ_id_ce,9L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "X509v3 CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_issuing_distribution_point "issuingDistributionPoint" +#define LN_issuing_distribution_point "X509v3 Issuing Distribution Point" +#define NID_issuing_distribution_point 770 +#define OBJ_issuing_distribution_point OBJ_id_ce,28L + +#define SN_certificate_issuer "certificateIssuer" +#define LN_certificate_issuer "X509v3 Certificate Issuer" +#define NID_certificate_issuer 771 +#define OBJ_certificate_issuer OBJ_id_ce,29L + +#define SN_name_constraints "nameConstraints" +#define LN_name_constraints "X509v3 Name Constraints" +#define NID_name_constraints 666 +#define OBJ_name_constraints OBJ_id_ce,30L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_any_policy "anyPolicy" +#define LN_any_policy "X509v3 Any Policy" +#define NID_any_policy 746 +#define OBJ_any_policy OBJ_certificate_policies,0L + +#define SN_policy_mappings "policyMappings" +#define LN_policy_mappings "X509v3 Policy Mappings" +#define NID_policy_mappings 747 +#define OBJ_policy_mappings OBJ_id_ce,33L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_policy_constraints "policyConstraints" +#define LN_policy_constraints "X509v3 Policy Constraints" +#define NID_policy_constraints 401 +#define OBJ_policy_constraints OBJ_id_ce,36L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37L + +#define SN_authority_attribute_identifier "authorityAttributeIdentifier" +#define LN_authority_attribute_identifier "X509v3 Authority Attribute Identifier" +#define NID_authority_attribute_identifier 1295 +#define OBJ_authority_attribute_identifier OBJ_id_ce,38L + +#define SN_role_spec_cert_identifier "roleSpecCertIdentifier" +#define LN_role_spec_cert_identifier "X509v3 Role Specification Certificate Identifier" +#define NID_role_spec_cert_identifier 1296 +#define OBJ_role_spec_cert_identifier OBJ_id_ce,39L + +#define SN_basic_att_constraints "basicAttConstraints" +#define LN_basic_att_constraints "X509v3 Basic Attribute Certificate Constraints" +#define NID_basic_att_constraints 1297 +#define OBJ_basic_att_constraints OBJ_id_ce,41L + +#define SN_delegated_name_constraints "delegatedNameConstraints" +#define LN_delegated_name_constraints "X509v3 Delegated Name Constraints" +#define NID_delegated_name_constraints 1298 +#define OBJ_delegated_name_constraints OBJ_id_ce,42L + +#define SN_time_specification "timeSpecification" +#define LN_time_specification "X509v3 Time Specification" +#define NID_time_specification 1299 +#define OBJ_time_specification OBJ_id_ce,43L + +#define SN_freshest_crl "freshestCRL" +#define LN_freshest_crl "X509v3 Freshest CRL" +#define NID_freshest_crl 857 +#define OBJ_freshest_crl OBJ_id_ce,46L + +#define SN_attribute_descriptor "attributeDescriptor" +#define LN_attribute_descriptor "X509v3 Attribute Descriptor" +#define NID_attribute_descriptor 1300 +#define OBJ_attribute_descriptor OBJ_id_ce,48L + +#define SN_user_notice "userNotice" +#define LN_user_notice "X509v3 User Notice" +#define NID_user_notice 1301 +#define OBJ_user_notice OBJ_id_ce,49L + +#define SN_soa_identifier "sOAIdentifier" +#define LN_soa_identifier "X509v3 Source of Authority Identifier" +#define NID_soa_identifier 1302 +#define OBJ_soa_identifier OBJ_id_ce,50L + +#define SN_acceptable_cert_policies "acceptableCertPolicies" +#define LN_acceptable_cert_policies "X509v3 Acceptable Certification Policies" +#define NID_acceptable_cert_policies 1303 +#define OBJ_acceptable_cert_policies OBJ_id_ce,52L + +#define SN_inhibit_any_policy "inhibitAnyPolicy" +#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" +#define NID_inhibit_any_policy 748 +#define OBJ_inhibit_any_policy OBJ_id_ce,54L + +#define SN_target_information "targetInformation" +#define LN_target_information "X509v3 AC Targeting" +#define NID_target_information 402 +#define OBJ_target_information OBJ_id_ce,55L + +#define SN_no_rev_avail "noRevAvail" +#define LN_no_rev_avail "X509v3 No Revocation Available" +#define NID_no_rev_avail 403 +#define OBJ_no_rev_avail OBJ_id_ce,56L + +#define SN_acceptable_privilege_policies "acceptablePrivPolicies" +#define LN_acceptable_privilege_policies "X509v3 Acceptable Privilege Policies" +#define NID_acceptable_privilege_policies 1304 +#define OBJ_acceptable_privilege_policies OBJ_id_ce,57L + +#define SN_indirect_issuer "indirectIssuer" +#define LN_indirect_issuer "X509v3 Indirect Issuer" +#define NID_indirect_issuer 1305 +#define OBJ_indirect_issuer OBJ_id_ce,61L + +#define SN_no_assertion "noAssertion" +#define LN_no_assertion "X509v3 No Assertion" +#define NID_no_assertion 1306 +#define OBJ_no_assertion OBJ_id_ce,62L + +#define SN_id_aa_issuing_distribution_point "aAissuingDistributionPoint" +#define LN_id_aa_issuing_distribution_point "X509v3 Attribute Authority Issuing Distribution Point" +#define NID_id_aa_issuing_distribution_point 1307 +#define OBJ_id_aa_issuing_distribution_point OBJ_id_ce,63L + +#define SN_issued_on_behalf_of "issuedOnBehalfOf" +#define LN_issued_on_behalf_of "X509v3 Issued On Behalf Of" +#define NID_issued_on_behalf_of 1308 +#define OBJ_issued_on_behalf_of OBJ_id_ce,64L + +#define SN_single_use "singleUse" +#define LN_single_use "X509v3 Single Use" +#define NID_single_use 1309 +#define OBJ_single_use OBJ_id_ce,65L + +#define SN_group_ac "groupAC" +#define LN_group_ac "X509v3 Group Attribute Certificate" +#define NID_group_ac 1310 +#define OBJ_group_ac OBJ_id_ce,66L + +#define SN_allowed_attribute_assignments "allowedAttributeAssignments" +#define LN_allowed_attribute_assignments "X509v3 Allowed Attribute Assignments" +#define NID_allowed_attribute_assignments 1311 +#define OBJ_allowed_attribute_assignments OBJ_id_ce,67L + +#define SN_attribute_mappings "attributeMappings" +#define LN_attribute_mappings "X509v3 Attribute Mappings" +#define NID_attribute_mappings 1312 +#define OBJ_attribute_mappings OBJ_id_ce,68L + +#define SN_holder_name_constraints "holderNameConstraints" +#define LN_holder_name_constraints "X509v3 Holder Name Constraints" +#define NID_holder_name_constraints 1313 +#define OBJ_holder_name_constraints OBJ_id_ce,69L + +#define SN_authorization_validation "authorizationValidation" +#define LN_authorization_validation "X509v3 Authorization Validation" +#define NID_authorization_validation 1314 +#define OBJ_authorization_validation OBJ_id_ce,70L + +#define SN_prot_restrict "protRestrict" +#define LN_prot_restrict "X509v3 Protocol Restriction" +#define NID_prot_restrict 1315 +#define OBJ_prot_restrict OBJ_id_ce,71L + +#define SN_subject_alt_public_key_info "subjectAltPublicKeyInfo" +#define LN_subject_alt_public_key_info "X509v3 Subject Alternative Public Key Info" +#define NID_subject_alt_public_key_info 1316 +#define OBJ_subject_alt_public_key_info OBJ_id_ce,72L + +#define SN_alt_signature_algorithm "altSignatureAlgorithm" +#define LN_alt_signature_algorithm "X509v3 Alternative Signature Algorithm" +#define NID_alt_signature_algorithm 1317 +#define OBJ_alt_signature_algorithm OBJ_id_ce,73L + +#define SN_alt_signature_value "altSignatureValue" +#define LN_alt_signature_value "X509v3 Alternative Signature Value" +#define NID_alt_signature_value 1318 +#define OBJ_alt_signature_value OBJ_id_ce,74L + +#define SN_associated_information "associatedInformation" +#define LN_associated_information "X509v3 Associated Information" +#define NID_associated_information 1319 +#define OBJ_associated_information OBJ_id_ce,75L + +#define SN_anyExtendedKeyUsage "anyExtendedKeyUsage" +#define LN_anyExtendedKeyUsage "Any Extended Key Usage" +#define NID_anyExtendedKeyUsage 910 +#define OBJ_anyExtendedKeyUsage OBJ_ext_key_usage,0L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_org "ORG" +#define LN_org "org" +#define NID_org 379 +#define OBJ_org OBJ_iso,3L + +#define SN_dod "DOD" +#define LN_dod "dod" +#define NID_dod 380 +#define OBJ_dod OBJ_org,6L + +#define SN_iana "IANA" +#define LN_iana "iana" +#define NID_iana 381 +#define OBJ_iana OBJ_dod,1L + +#define OBJ_internet OBJ_iana + +#define SN_Directory "directory" +#define LN_Directory "Directory" +#define NID_Directory 382 +#define OBJ_Directory OBJ_internet,1L + +#define SN_Management "mgmt" +#define LN_Management "Management" +#define NID_Management 383 +#define OBJ_Management OBJ_internet,2L + +#define SN_Experimental "experimental" +#define LN_Experimental "Experimental" +#define NID_Experimental 384 +#define OBJ_Experimental OBJ_internet,3L + +#define SN_Private "private" +#define LN_Private "Private" +#define NID_Private 385 +#define OBJ_Private OBJ_internet,4L + +#define SN_Security "security" +#define LN_Security "Security" +#define NID_Security 386 +#define OBJ_Security OBJ_internet,5L + +#define SN_SNMPv2 "snmpv2" +#define LN_SNMPv2 "SNMPv2" +#define NID_SNMPv2 387 +#define OBJ_SNMPv2 OBJ_internet,6L + +#define LN_Mail "Mail" +#define NID_Mail 388 +#define OBJ_Mail OBJ_internet,7L + +#define SN_Enterprises "enterprises" +#define LN_Enterprises "Enterprises" +#define NID_Enterprises 389 +#define OBJ_Enterprises OBJ_Private,1L + +#define SN_dcObject "dcobject" +#define LN_dcObject "dcObject" +#define NID_dcObject 390 +#define OBJ_dcObject OBJ_Enterprises,1466L,344L + +#define SN_id_kp_wisun_fan_device "id-kp-wisun-fan-device" +#define LN_id_kp_wisun_fan_device "Wi-SUN Alliance Field Area Network (FAN)" +#define NID_id_kp_wisun_fan_device 1322 +#define OBJ_id_kp_wisun_fan_device OBJ_Enterprises,45605L,1L + +#define SN_mime_mhs "mime-mhs" +#define LN_mime_mhs "MIME MHS" +#define NID_mime_mhs 504 +#define OBJ_mime_mhs OBJ_Mail,1L + +#define SN_mime_mhs_headings "mime-mhs-headings" +#define LN_mime_mhs_headings "mime-mhs-headings" +#define NID_mime_mhs_headings 505 +#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L + +#define SN_mime_mhs_bodies "mime-mhs-bodies" +#define LN_mime_mhs_bodies "mime-mhs-bodies" +#define NID_mime_mhs_bodies 506 +#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L + +#define SN_id_hex_partial_message "id-hex-partial-message" +#define LN_id_hex_partial_message "id-hex-partial-message" +#define NID_id_hex_partial_message 507 +#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L + +#define SN_id_hex_multipart_message "id-hex-multipart-message" +#define LN_id_hex_multipart_message "id-hex-multipart-message" +#define NID_id_hex_multipart_message 508 +#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression OBJ_id_smime_alg,8L + +#define OBJ_csor 2L,16L,840L,1L,101L,3L + +#define OBJ_nistAlgorithms OBJ_csor,4L + +#define OBJ_aes OBJ_nistAlgorithms,1L + +#define SN_aes_128_ecb "AES-128-ECB" +#define LN_aes_128_ecb "aes-128-ecb" +#define NID_aes_128_ecb 418 +#define OBJ_aes_128_ecb OBJ_aes,1L + +#define SN_aes_128_cbc "AES-128-CBC" +#define LN_aes_128_cbc "aes-128-cbc" +#define NID_aes_128_cbc 419 +#define OBJ_aes_128_cbc OBJ_aes,2L + +#define SN_aes_128_ofb128 "AES-128-OFB" +#define LN_aes_128_ofb128 "aes-128-ofb" +#define NID_aes_128_ofb128 420 +#define OBJ_aes_128_ofb128 OBJ_aes,3L + +#define SN_aes_128_cfb128 "AES-128-CFB" +#define LN_aes_128_cfb128 "aes-128-cfb" +#define NID_aes_128_cfb128 421 +#define OBJ_aes_128_cfb128 OBJ_aes,4L + +#define SN_id_aes128_wrap "id-aes128-wrap" +#define NID_id_aes128_wrap 788 +#define OBJ_id_aes128_wrap OBJ_aes,5L + +#define SN_aes_128_gcm "id-aes128-GCM" +#define LN_aes_128_gcm "aes-128-gcm" +#define NID_aes_128_gcm 895 +#define OBJ_aes_128_gcm OBJ_aes,6L + +#define SN_aes_128_ccm "id-aes128-CCM" +#define LN_aes_128_ccm "aes-128-ccm" +#define NID_aes_128_ccm 896 +#define OBJ_aes_128_ccm OBJ_aes,7L + +#define SN_id_aes128_wrap_pad "id-aes128-wrap-pad" +#define NID_id_aes128_wrap_pad 897 +#define OBJ_id_aes128_wrap_pad OBJ_aes,8L + +#define SN_aes_192_ecb "AES-192-ECB" +#define LN_aes_192_ecb "aes-192-ecb" +#define NID_aes_192_ecb 422 +#define OBJ_aes_192_ecb OBJ_aes,21L + +#define SN_aes_192_cbc "AES-192-CBC" +#define LN_aes_192_cbc "aes-192-cbc" +#define NID_aes_192_cbc 423 +#define OBJ_aes_192_cbc OBJ_aes,22L + +#define SN_aes_192_ofb128 "AES-192-OFB" +#define LN_aes_192_ofb128 "aes-192-ofb" +#define NID_aes_192_ofb128 424 +#define OBJ_aes_192_ofb128 OBJ_aes,23L + +#define SN_aes_192_cfb128 "AES-192-CFB" +#define LN_aes_192_cfb128 "aes-192-cfb" +#define NID_aes_192_cfb128 425 +#define OBJ_aes_192_cfb128 OBJ_aes,24L + +#define SN_id_aes192_wrap "id-aes192-wrap" +#define NID_id_aes192_wrap 789 +#define OBJ_id_aes192_wrap OBJ_aes,25L + +#define SN_aes_192_gcm "id-aes192-GCM" +#define LN_aes_192_gcm "aes-192-gcm" +#define NID_aes_192_gcm 898 +#define OBJ_aes_192_gcm OBJ_aes,26L + +#define SN_aes_192_ccm "id-aes192-CCM" +#define LN_aes_192_ccm "aes-192-ccm" +#define NID_aes_192_ccm 899 +#define OBJ_aes_192_ccm OBJ_aes,27L + +#define SN_id_aes192_wrap_pad "id-aes192-wrap-pad" +#define NID_id_aes192_wrap_pad 900 +#define OBJ_id_aes192_wrap_pad OBJ_aes,28L + +#define SN_aes_256_ecb "AES-256-ECB" +#define LN_aes_256_ecb "aes-256-ecb" +#define NID_aes_256_ecb 426 +#define OBJ_aes_256_ecb OBJ_aes,41L + +#define SN_aes_256_cbc "AES-256-CBC" +#define LN_aes_256_cbc "aes-256-cbc" +#define NID_aes_256_cbc 427 +#define OBJ_aes_256_cbc OBJ_aes,42L + +#define SN_aes_256_ofb128 "AES-256-OFB" +#define LN_aes_256_ofb128 "aes-256-ofb" +#define NID_aes_256_ofb128 428 +#define OBJ_aes_256_ofb128 OBJ_aes,43L + +#define SN_aes_256_cfb128 "AES-256-CFB" +#define LN_aes_256_cfb128 "aes-256-cfb" +#define NID_aes_256_cfb128 429 +#define OBJ_aes_256_cfb128 OBJ_aes,44L + +#define SN_id_aes256_wrap "id-aes256-wrap" +#define NID_id_aes256_wrap 790 +#define OBJ_id_aes256_wrap OBJ_aes,45L + +#define SN_aes_256_gcm "id-aes256-GCM" +#define LN_aes_256_gcm "aes-256-gcm" +#define NID_aes_256_gcm 901 +#define OBJ_aes_256_gcm OBJ_aes,46L + +#define SN_aes_256_ccm "id-aes256-CCM" +#define LN_aes_256_ccm "aes-256-ccm" +#define NID_aes_256_ccm 902 +#define OBJ_aes_256_ccm OBJ_aes,47L + +#define SN_id_aes256_wrap_pad "id-aes256-wrap-pad" +#define NID_id_aes256_wrap_pad 903 +#define OBJ_id_aes256_wrap_pad OBJ_aes,48L + +#define SN_aes_128_xts "AES-128-XTS" +#define LN_aes_128_xts "aes-128-xts" +#define NID_aes_128_xts 913 +#define OBJ_aes_128_xts OBJ_ieee_siswg,0L,1L,1L + +#define SN_aes_256_xts "AES-256-XTS" +#define LN_aes_256_xts "aes-256-xts" +#define NID_aes_256_xts 914 +#define OBJ_aes_256_xts OBJ_ieee_siswg,0L,1L,2L + +#define SN_aes_128_cfb1 "AES-128-CFB1" +#define LN_aes_128_cfb1 "aes-128-cfb1" +#define NID_aes_128_cfb1 650 + +#define SN_aes_192_cfb1 "AES-192-CFB1" +#define LN_aes_192_cfb1 "aes-192-cfb1" +#define NID_aes_192_cfb1 651 + +#define SN_aes_256_cfb1 "AES-256-CFB1" +#define LN_aes_256_cfb1 "aes-256-cfb1" +#define NID_aes_256_cfb1 652 + +#define SN_aes_128_cfb8 "AES-128-CFB8" +#define LN_aes_128_cfb8 "aes-128-cfb8" +#define NID_aes_128_cfb8 653 + +#define SN_aes_192_cfb8 "AES-192-CFB8" +#define LN_aes_192_cfb8 "aes-192-cfb8" +#define NID_aes_192_cfb8 654 + +#define SN_aes_256_cfb8 "AES-256-CFB8" +#define LN_aes_256_cfb8 "aes-256-cfb8" +#define NID_aes_256_cfb8 655 + +#define SN_aes_128_ctr "AES-128-CTR" +#define LN_aes_128_ctr "aes-128-ctr" +#define NID_aes_128_ctr 904 + +#define SN_aes_192_ctr "AES-192-CTR" +#define LN_aes_192_ctr "aes-192-ctr" +#define NID_aes_192_ctr 905 + +#define SN_aes_256_ctr "AES-256-CTR" +#define LN_aes_256_ctr "aes-256-ctr" +#define NID_aes_256_ctr 906 + +#define SN_aes_128_ocb "AES-128-OCB" +#define LN_aes_128_ocb "aes-128-ocb" +#define NID_aes_128_ocb 958 + +#define SN_aes_192_ocb "AES-192-OCB" +#define LN_aes_192_ocb "aes-192-ocb" +#define NID_aes_192_ocb 959 + +#define SN_aes_256_ocb "AES-256-OCB" +#define LN_aes_256_ocb "aes-256-ocb" +#define NID_aes_256_ocb 960 + +#define SN_des_cfb1 "DES-CFB1" +#define LN_des_cfb1 "des-cfb1" +#define NID_des_cfb1 656 + +#define SN_des_cfb8 "DES-CFB8" +#define LN_des_cfb8 "des-cfb8" +#define NID_des_cfb8 657 + +#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" +#define LN_des_ede3_cfb1 "des-ede3-cfb1" +#define NID_des_ede3_cfb1 658 + +#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" +#define LN_des_ede3_cfb8 "des-ede3-cfb8" +#define NID_des_ede3_cfb8 659 + +#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L + +#define SN_sha256 "SHA256" +#define LN_sha256 "sha256" +#define NID_sha256 672 +#define OBJ_sha256 OBJ_nist_hashalgs,1L + +#define SN_sha384 "SHA384" +#define LN_sha384 "sha384" +#define NID_sha384 673 +#define OBJ_sha384 OBJ_nist_hashalgs,2L + +#define SN_sha512 "SHA512" +#define LN_sha512 "sha512" +#define NID_sha512 674 +#define OBJ_sha512 OBJ_nist_hashalgs,3L + +#define SN_sha224 "SHA224" +#define LN_sha224 "sha224" +#define NID_sha224 675 +#define OBJ_sha224 OBJ_nist_hashalgs,4L + +#define SN_sha512_224 "SHA512-224" +#define LN_sha512_224 "sha512-224" +#define NID_sha512_224 1094 +#define OBJ_sha512_224 OBJ_nist_hashalgs,5L + +#define SN_sha512_256 "SHA512-256" +#define LN_sha512_256 "sha512-256" +#define NID_sha512_256 1095 +#define OBJ_sha512_256 OBJ_nist_hashalgs,6L + +#define SN_sha3_224 "SHA3-224" +#define LN_sha3_224 "sha3-224" +#define NID_sha3_224 1096 +#define OBJ_sha3_224 OBJ_nist_hashalgs,7L + +#define SN_sha3_256 "SHA3-256" +#define LN_sha3_256 "sha3-256" +#define NID_sha3_256 1097 +#define OBJ_sha3_256 OBJ_nist_hashalgs,8L + +#define SN_sha3_384 "SHA3-384" +#define LN_sha3_384 "sha3-384" +#define NID_sha3_384 1098 +#define OBJ_sha3_384 OBJ_nist_hashalgs,9L + +#define SN_sha3_512 "SHA3-512" +#define LN_sha3_512 "sha3-512" +#define NID_sha3_512 1099 +#define OBJ_sha3_512 OBJ_nist_hashalgs,10L + +#define SN_shake128 "SHAKE128" +#define LN_shake128 "shake128" +#define NID_shake128 1100 +#define OBJ_shake128 OBJ_nist_hashalgs,11L + +#define SN_shake256 "SHAKE256" +#define LN_shake256 "shake256" +#define NID_shake256 1101 +#define OBJ_shake256 OBJ_nist_hashalgs,12L + +#define SN_hmac_sha3_224 "id-hmacWithSHA3-224" +#define LN_hmac_sha3_224 "hmac-sha3-224" +#define NID_hmac_sha3_224 1102 +#define OBJ_hmac_sha3_224 OBJ_nist_hashalgs,13L + +#define SN_hmac_sha3_256 "id-hmacWithSHA3-256" +#define LN_hmac_sha3_256 "hmac-sha3-256" +#define NID_hmac_sha3_256 1103 +#define OBJ_hmac_sha3_256 OBJ_nist_hashalgs,14L + +#define SN_hmac_sha3_384 "id-hmacWithSHA3-384" +#define LN_hmac_sha3_384 "hmac-sha3-384" +#define NID_hmac_sha3_384 1104 +#define OBJ_hmac_sha3_384 OBJ_nist_hashalgs,15L + +#define SN_hmac_sha3_512 "id-hmacWithSHA3-512" +#define LN_hmac_sha3_512 "hmac-sha3-512" +#define NID_hmac_sha3_512 1105 +#define OBJ_hmac_sha3_512 OBJ_nist_hashalgs,16L + +#define SN_kmac128 "KMAC128" +#define LN_kmac128 "kmac128" +#define NID_kmac128 1196 +#define OBJ_kmac128 OBJ_nist_hashalgs,19L + +#define SN_kmac256 "KMAC256" +#define LN_kmac256 "kmac256" +#define NID_kmac256 1197 +#define OBJ_kmac256 OBJ_nist_hashalgs,20L + +#define OBJ_dsa_with_sha2 OBJ_nistAlgorithms,3L + +#define SN_dsa_with_SHA224 "dsa_with_SHA224" +#define NID_dsa_with_SHA224 802 +#define OBJ_dsa_with_SHA224 OBJ_dsa_with_sha2,1L + +#define SN_dsa_with_SHA256 "dsa_with_SHA256" +#define NID_dsa_with_SHA256 803 +#define OBJ_dsa_with_SHA256 OBJ_dsa_with_sha2,2L + +#define OBJ_sigAlgs OBJ_nistAlgorithms,3L + +#define SN_dsa_with_SHA384 "id-dsa-with-sha384" +#define LN_dsa_with_SHA384 "dsa_with_SHA384" +#define NID_dsa_with_SHA384 1106 +#define OBJ_dsa_with_SHA384 OBJ_sigAlgs,3L + +#define SN_dsa_with_SHA512 "id-dsa-with-sha512" +#define LN_dsa_with_SHA512 "dsa_with_SHA512" +#define NID_dsa_with_SHA512 1107 +#define OBJ_dsa_with_SHA512 OBJ_sigAlgs,4L + +#define SN_dsa_with_SHA3_224 "id-dsa-with-sha3-224" +#define LN_dsa_with_SHA3_224 "dsa_with_SHA3-224" +#define NID_dsa_with_SHA3_224 1108 +#define OBJ_dsa_with_SHA3_224 OBJ_sigAlgs,5L + +#define SN_dsa_with_SHA3_256 "id-dsa-with-sha3-256" +#define LN_dsa_with_SHA3_256 "dsa_with_SHA3-256" +#define NID_dsa_with_SHA3_256 1109 +#define OBJ_dsa_with_SHA3_256 OBJ_sigAlgs,6L + +#define SN_dsa_with_SHA3_384 "id-dsa-with-sha3-384" +#define LN_dsa_with_SHA3_384 "dsa_with_SHA3-384" +#define NID_dsa_with_SHA3_384 1110 +#define OBJ_dsa_with_SHA3_384 OBJ_sigAlgs,7L + +#define SN_dsa_with_SHA3_512 "id-dsa-with-sha3-512" +#define LN_dsa_with_SHA3_512 "dsa_with_SHA3-512" +#define NID_dsa_with_SHA3_512 1111 +#define OBJ_dsa_with_SHA3_512 OBJ_sigAlgs,8L + +#define SN_ecdsa_with_SHA3_224 "id-ecdsa-with-sha3-224" +#define LN_ecdsa_with_SHA3_224 "ecdsa_with_SHA3-224" +#define NID_ecdsa_with_SHA3_224 1112 +#define OBJ_ecdsa_with_SHA3_224 OBJ_sigAlgs,9L + +#define SN_ecdsa_with_SHA3_256 "id-ecdsa-with-sha3-256" +#define LN_ecdsa_with_SHA3_256 "ecdsa_with_SHA3-256" +#define NID_ecdsa_with_SHA3_256 1113 +#define OBJ_ecdsa_with_SHA3_256 OBJ_sigAlgs,10L + +#define SN_ecdsa_with_SHA3_384 "id-ecdsa-with-sha3-384" +#define LN_ecdsa_with_SHA3_384 "ecdsa_with_SHA3-384" +#define NID_ecdsa_with_SHA3_384 1114 +#define OBJ_ecdsa_with_SHA3_384 OBJ_sigAlgs,11L + +#define SN_ecdsa_with_SHA3_512 "id-ecdsa-with-sha3-512" +#define LN_ecdsa_with_SHA3_512 "ecdsa_with_SHA3-512" +#define NID_ecdsa_with_SHA3_512 1115 +#define OBJ_ecdsa_with_SHA3_512 OBJ_sigAlgs,12L + +#define SN_RSA_SHA3_224 "id-rsassa-pkcs1-v1_5-with-sha3-224" +#define LN_RSA_SHA3_224 "RSA-SHA3-224" +#define NID_RSA_SHA3_224 1116 +#define OBJ_RSA_SHA3_224 OBJ_sigAlgs,13L + +#define SN_RSA_SHA3_256 "id-rsassa-pkcs1-v1_5-with-sha3-256" +#define LN_RSA_SHA3_256 "RSA-SHA3-256" +#define NID_RSA_SHA3_256 1117 +#define OBJ_RSA_SHA3_256 OBJ_sigAlgs,14L + +#define SN_RSA_SHA3_384 "id-rsassa-pkcs1-v1_5-with-sha3-384" +#define LN_RSA_SHA3_384 "RSA-SHA3-384" +#define NID_RSA_SHA3_384 1118 +#define OBJ_RSA_SHA3_384 OBJ_sigAlgs,15L + +#define SN_RSA_SHA3_512 "id-rsassa-pkcs1-v1_5-with-sha3-512" +#define LN_RSA_SHA3_512 "RSA-SHA3-512" +#define NID_RSA_SHA3_512 1119 +#define OBJ_RSA_SHA3_512 OBJ_sigAlgs,16L + +#define SN_ML_DSA_44 "id-ml-dsa-44" +#define LN_ML_DSA_44 "ML-DSA-44" +#define NID_ML_DSA_44 1457 +#define OBJ_ML_DSA_44 OBJ_sigAlgs,17L + +#define SN_ML_DSA_65 "id-ml-dsa-65" +#define LN_ML_DSA_65 "ML-DSA-65" +#define NID_ML_DSA_65 1458 +#define OBJ_ML_DSA_65 OBJ_sigAlgs,18L + +#define SN_ML_DSA_87 "id-ml-dsa-87" +#define LN_ML_DSA_87 "ML-DSA-87" +#define NID_ML_DSA_87 1459 +#define OBJ_ML_DSA_87 OBJ_sigAlgs,19L + +#define SN_SLH_DSA_SHA2_128s "id-slh-dsa-sha2-128s" +#define LN_SLH_DSA_SHA2_128s "SLH-DSA-SHA2-128s" +#define NID_SLH_DSA_SHA2_128s 1460 +#define OBJ_SLH_DSA_SHA2_128s OBJ_sigAlgs,20L + +#define SN_SLH_DSA_SHA2_128f "id-slh-dsa-sha2-128f" +#define LN_SLH_DSA_SHA2_128f "SLH-DSA-SHA2-128f" +#define NID_SLH_DSA_SHA2_128f 1461 +#define OBJ_SLH_DSA_SHA2_128f OBJ_sigAlgs,21L + +#define SN_SLH_DSA_SHA2_192s "id-slh-dsa-sha2-192s" +#define LN_SLH_DSA_SHA2_192s "SLH-DSA-SHA2-192s" +#define NID_SLH_DSA_SHA2_192s 1462 +#define OBJ_SLH_DSA_SHA2_192s OBJ_sigAlgs,22L + +#define SN_SLH_DSA_SHA2_192f "id-slh-dsa-sha2-192f" +#define LN_SLH_DSA_SHA2_192f "SLH-DSA-SHA2-192f" +#define NID_SLH_DSA_SHA2_192f 1463 +#define OBJ_SLH_DSA_SHA2_192f OBJ_sigAlgs,23L + +#define SN_SLH_DSA_SHA2_256s "id-slh-dsa-sha2-256s" +#define LN_SLH_DSA_SHA2_256s "SLH-DSA-SHA2-256s" +#define NID_SLH_DSA_SHA2_256s 1464 +#define OBJ_SLH_DSA_SHA2_256s OBJ_sigAlgs,24L + +#define SN_SLH_DSA_SHA2_256f "id-slh-dsa-sha2-256f" +#define LN_SLH_DSA_SHA2_256f "SLH-DSA-SHA2-256f" +#define NID_SLH_DSA_SHA2_256f 1465 +#define OBJ_SLH_DSA_SHA2_256f OBJ_sigAlgs,25L + +#define SN_SLH_DSA_SHAKE_128s "id-slh-dsa-shake-128s" +#define LN_SLH_DSA_SHAKE_128s "SLH-DSA-SHAKE-128s" +#define NID_SLH_DSA_SHAKE_128s 1466 +#define OBJ_SLH_DSA_SHAKE_128s OBJ_sigAlgs,26L + +#define SN_SLH_DSA_SHAKE_128f "id-slh-dsa-shake-128f" +#define LN_SLH_DSA_SHAKE_128f "SLH-DSA-SHAKE-128f" +#define NID_SLH_DSA_SHAKE_128f 1467 +#define OBJ_SLH_DSA_SHAKE_128f OBJ_sigAlgs,27L + +#define SN_SLH_DSA_SHAKE_192s "id-slh-dsa-shake-192s" +#define LN_SLH_DSA_SHAKE_192s "SLH-DSA-SHAKE-192s" +#define NID_SLH_DSA_SHAKE_192s 1468 +#define OBJ_SLH_DSA_SHAKE_192s OBJ_sigAlgs,28L + +#define SN_SLH_DSA_SHAKE_192f "id-slh-dsa-shake-192f" +#define LN_SLH_DSA_SHAKE_192f "SLH-DSA-SHAKE-192f" +#define NID_SLH_DSA_SHAKE_192f 1469 +#define OBJ_SLH_DSA_SHAKE_192f OBJ_sigAlgs,29L + +#define SN_SLH_DSA_SHAKE_256s "id-slh-dsa-shake-256s" +#define LN_SLH_DSA_SHAKE_256s "SLH-DSA-SHAKE-256s" +#define NID_SLH_DSA_SHAKE_256s 1470 +#define OBJ_SLH_DSA_SHAKE_256s OBJ_sigAlgs,30L + +#define SN_SLH_DSA_SHAKE_256f "id-slh-dsa-shake-256f" +#define LN_SLH_DSA_SHAKE_256f "SLH-DSA-SHAKE-256f" +#define NID_SLH_DSA_SHAKE_256f 1471 +#define OBJ_SLH_DSA_SHAKE_256f OBJ_sigAlgs,31L + +#define SN_HASH_ML_DSA_44_WITH_SHA512 "id-hash-ml-dsa-44-with-sha512" +#define LN_HASH_ML_DSA_44_WITH_SHA512 "HASH-ML-DSA-44-WITH-SHA512" +#define NID_HASH_ML_DSA_44_WITH_SHA512 1472 +#define OBJ_HASH_ML_DSA_44_WITH_SHA512 OBJ_sigAlgs,32L + +#define SN_HASH_ML_DSA_65_WITH_SHA512 "id-hash-ml-dsa-65-with-sha512" +#define LN_HASH_ML_DSA_65_WITH_SHA512 "HASH-ML-DSA-65-WITH-SHA512" +#define NID_HASH_ML_DSA_65_WITH_SHA512 1473 +#define OBJ_HASH_ML_DSA_65_WITH_SHA512 OBJ_sigAlgs,33L + +#define SN_HASH_ML_DSA_87_WITH_SHA512 "id-hash-ml-dsa-87-with-sha512" +#define LN_HASH_ML_DSA_87_WITH_SHA512 "HASH-ML-DSA-87-WITH-SHA512" +#define NID_HASH_ML_DSA_87_WITH_SHA512 1474 +#define OBJ_HASH_ML_DSA_87_WITH_SHA512 OBJ_sigAlgs,34L + +#define SN_SLH_DSA_SHA2_128s_WITH_SHA256 "id-hash-slh-dsa-sha2-128s-with-sha256" +#define LN_SLH_DSA_SHA2_128s_WITH_SHA256 "SLH-DSA-SHA2-128s-WITH-SHA256" +#define NID_SLH_DSA_SHA2_128s_WITH_SHA256 1475 +#define OBJ_SLH_DSA_SHA2_128s_WITH_SHA256 OBJ_sigAlgs,35L + +#define SN_SLH_DSA_SHA2_128f_WITH_SHA256 "id-hash-slh-dsa-sha2-128f-with-sha256" +#define LN_SLH_DSA_SHA2_128f_WITH_SHA256 "SLH-DSA-SHA2-128f-WITH-SHA256" +#define NID_SLH_DSA_SHA2_128f_WITH_SHA256 1476 +#define OBJ_SLH_DSA_SHA2_128f_WITH_SHA256 OBJ_sigAlgs,36L + +#define SN_SLH_DSA_SHA2_192s_WITH_SHA512 "id-hash-slh-dsa-sha2-192s-with-sha512" +#define LN_SLH_DSA_SHA2_192s_WITH_SHA512 "SLH-DSA-SHA2-192s-WITH-SHA512" +#define NID_SLH_DSA_SHA2_192s_WITH_SHA512 1477 +#define OBJ_SLH_DSA_SHA2_192s_WITH_SHA512 OBJ_sigAlgs,37L + +#define SN_SLH_DSA_SHA2_192f_WITH_SHA512 "id-hash-slh-dsa-sha2-192f-with-sha512" +#define LN_SLH_DSA_SHA2_192f_WITH_SHA512 "SLH-DSA-SHA2-192f-WITH-SHA512" +#define NID_SLH_DSA_SHA2_192f_WITH_SHA512 1478 +#define OBJ_SLH_DSA_SHA2_192f_WITH_SHA512 OBJ_sigAlgs,38L + +#define SN_SLH_DSA_SHA2_256s_WITH_SHA512 "id-hash-slh-dsa-sha2-256s-with-sha512" +#define LN_SLH_DSA_SHA2_256s_WITH_SHA512 "SLH-DSA-SHA2-256s-WITH-SHA512" +#define NID_SLH_DSA_SHA2_256s_WITH_SHA512 1479 +#define OBJ_SLH_DSA_SHA2_256s_WITH_SHA512 OBJ_sigAlgs,39L + +#define SN_SLH_DSA_SHA2_256f_WITH_SHA512 "id-hash-slh-dsa-sha2-256f-with-sha512" +#define LN_SLH_DSA_SHA2_256f_WITH_SHA512 "SLH-DSA-SHA2-256f-WITH-SHA512" +#define NID_SLH_DSA_SHA2_256f_WITH_SHA512 1480 +#define OBJ_SLH_DSA_SHA2_256f_WITH_SHA512 OBJ_sigAlgs,40L + +#define SN_SLH_DSA_SHAKE_128s_WITH_SHAKE128 "id-hash-slh-dsa-shake-128s-with-shake128" +#define LN_SLH_DSA_SHAKE_128s_WITH_SHAKE128 "SLH-DSA-SHAKE-128s-WITH-SHAKE128" +#define NID_SLH_DSA_SHAKE_128s_WITH_SHAKE128 1481 +#define OBJ_SLH_DSA_SHAKE_128s_WITH_SHAKE128 OBJ_sigAlgs,41L + +#define SN_SLH_DSA_SHAKE_128f_WITH_SHAKE128 "id-hash-slh-dsa-shake-128f-with-shake128" +#define LN_SLH_DSA_SHAKE_128f_WITH_SHAKE128 "SLH-DSA-SHAKE-128f-WITH-SHAKE128" +#define NID_SLH_DSA_SHAKE_128f_WITH_SHAKE128 1482 +#define OBJ_SLH_DSA_SHAKE_128f_WITH_SHAKE128 OBJ_sigAlgs,42L + +#define SN_SLH_DSA_SHAKE_192s_WITH_SHAKE256 "id-hash-slh-dsa-shake-192s-with-shake256" +#define LN_SLH_DSA_SHAKE_192s_WITH_SHAKE256 "SLH-DSA-SHAKE-192s-WITH-SHAKE256" +#define NID_SLH_DSA_SHAKE_192s_WITH_SHAKE256 1483 +#define OBJ_SLH_DSA_SHAKE_192s_WITH_SHAKE256 OBJ_sigAlgs,43L + +#define SN_SLH_DSA_SHAKE_192f_WITH_SHAKE256 "id-hash-slh-dsa-shake-192f-with-shake256" +#define LN_SLH_DSA_SHAKE_192f_WITH_SHAKE256 "SLH-DSA-SHAKE-192f-WITH-SHAKE256" +#define NID_SLH_DSA_SHAKE_192f_WITH_SHAKE256 1484 +#define OBJ_SLH_DSA_SHAKE_192f_WITH_SHAKE256 OBJ_sigAlgs,44L + +#define SN_SLH_DSA_SHAKE_256s_WITH_SHAKE256 "id-hash-slh-dsa-shake-256s-with-shake256" +#define LN_SLH_DSA_SHAKE_256s_WITH_SHAKE256 "SLH-DSA-SHAKE-256s-WITH-SHAKE256" +#define NID_SLH_DSA_SHAKE_256s_WITH_SHAKE256 1485 +#define OBJ_SLH_DSA_SHAKE_256s_WITH_SHAKE256 OBJ_sigAlgs,45L + +#define SN_SLH_DSA_SHAKE_256f_WITH_SHAKE256 "id-hash-slh-dsa-shake-256f-with-shake256" +#define LN_SLH_DSA_SHAKE_256f_WITH_SHAKE256 "SLH-DSA-SHAKE-256f-WITH-SHAKE256" +#define NID_SLH_DSA_SHAKE_256f_WITH_SHAKE256 1486 +#define OBJ_SLH_DSA_SHAKE_256f_WITH_SHAKE256 OBJ_sigAlgs,46L + +#define SN_hold_instruction_code "holdInstructionCode" +#define LN_hold_instruction_code "Hold Instruction Code" +#define NID_hold_instruction_code 430 +#define OBJ_hold_instruction_code OBJ_id_ce,23L + +#define OBJ_holdInstruction OBJ_X9_57,2L + +#define SN_hold_instruction_none "holdInstructionNone" +#define LN_hold_instruction_none "Hold Instruction None" +#define NID_hold_instruction_none 431 +#define OBJ_hold_instruction_none OBJ_holdInstruction,1L + +#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" +#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" +#define NID_hold_instruction_call_issuer 432 +#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L + +#define SN_hold_instruction_reject "holdInstructionReject" +#define LN_hold_instruction_reject "Hold Instruction Reject" +#define NID_hold_instruction_reject 433 +#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L + +#define SN_itu_t_identified_organization "itu-t-identified-organization" +#define NID_itu_t_identified_organization 1264 +#define OBJ_itu_t_identified_organization OBJ_itu_t,4L + +#define SN_etsi "etsi" +#define NID_etsi 1265 +#define OBJ_etsi OBJ_itu_t_identified_organization,0L + +#define SN_electronic_signature_standard "electronic-signature-standard" +#define NID_electronic_signature_standard 1266 +#define OBJ_electronic_signature_standard OBJ_etsi,1733L + +#define SN_ess_attributes "ess-attributes" +#define NID_ess_attributes 1267 +#define OBJ_ess_attributes OBJ_electronic_signature_standard,2L + +#define SN_id_aa_ets_mimeType "id-aa-ets-mimeType" +#define NID_id_aa_ets_mimeType 1268 +#define OBJ_id_aa_ets_mimeType OBJ_ess_attributes,1L + +#define SN_id_aa_ets_longTermValidation "id-aa-ets-longTermValidation" +#define NID_id_aa_ets_longTermValidation 1269 +#define OBJ_id_aa_ets_longTermValidation OBJ_ess_attributes,2L + +#define SN_id_aa_ets_SignaturePolicyDocument "id-aa-ets-SignaturePolicyDocument" +#define NID_id_aa_ets_SignaturePolicyDocument 1270 +#define OBJ_id_aa_ets_SignaturePolicyDocument OBJ_ess_attributes,3L + +#define SN_id_aa_ets_archiveTimestampV3 "id-aa-ets-archiveTimestampV3" +#define NID_id_aa_ets_archiveTimestampV3 1271 +#define OBJ_id_aa_ets_archiveTimestampV3 OBJ_ess_attributes,4L + +#define SN_id_aa_ATSHashIndex "id-aa-ATSHashIndex" +#define NID_id_aa_ATSHashIndex 1272 +#define OBJ_id_aa_ATSHashIndex OBJ_ess_attributes,5L + +#define SN_cades "cades" +#define NID_cades 1273 +#define OBJ_cades OBJ_etsi,19122L + +#define SN_cades_attributes "cades-attributes" +#define NID_cades_attributes 1274 +#define OBJ_cades_attributes OBJ_cades,1L + +#define SN_id_aa_ets_signerAttrV2 "id-aa-ets-signerAttrV2" +#define NID_id_aa_ets_signerAttrV2 1275 +#define OBJ_id_aa_ets_signerAttrV2 OBJ_cades_attributes,1L + +#define SN_id_aa_ets_sigPolicyStore "id-aa-ets-sigPolicyStore" +#define NID_id_aa_ets_sigPolicyStore 1276 +#define OBJ_id_aa_ets_sigPolicyStore OBJ_cades_attributes,3L + +#define SN_id_aa_ATSHashIndex_v2 "id-aa-ATSHashIndex-v2" +#define NID_id_aa_ATSHashIndex_v2 1277 +#define OBJ_id_aa_ATSHashIndex_v2 OBJ_cades_attributes,4L + +#define SN_id_aa_ATSHashIndex_v3 "id-aa-ATSHashIndex-v3" +#define NID_id_aa_ATSHashIndex_v3 1278 +#define OBJ_id_aa_ATSHashIndex_v3 OBJ_cades_attributes,5L + +#define SN_signedAssertion "signedAssertion" +#define NID_signedAssertion 1279 +#define OBJ_signedAssertion OBJ_cades_attributes,6L + +#define SN_data "data" +#define NID_data 434 +#define OBJ_data OBJ_itu_t,9L + +#define SN_pss "pss" +#define NID_pss 435 +#define OBJ_pss OBJ_data,2342L + +#define SN_ucl "ucl" +#define NID_ucl 436 +#define OBJ_ucl OBJ_pss,19200300L + +#define SN_pilot "pilot" +#define NID_pilot 437 +#define OBJ_pilot OBJ_ucl,100L + +#define LN_pilotAttributeType "pilotAttributeType" +#define NID_pilotAttributeType 438 +#define OBJ_pilotAttributeType OBJ_pilot,1L + +#define LN_pilotAttributeSyntax "pilotAttributeSyntax" +#define NID_pilotAttributeSyntax 439 +#define OBJ_pilotAttributeSyntax OBJ_pilot,3L + +#define LN_pilotObjectClass "pilotObjectClass" +#define NID_pilotObjectClass 440 +#define OBJ_pilotObjectClass OBJ_pilot,4L + +#define LN_pilotGroups "pilotGroups" +#define NID_pilotGroups 441 +#define OBJ_pilotGroups OBJ_pilot,10L + +#define LN_iA5StringSyntax "iA5StringSyntax" +#define NID_iA5StringSyntax 442 +#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L + +#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" +#define NID_caseIgnoreIA5StringSyntax 443 +#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L + +#define LN_pilotObject "pilotObject" +#define NID_pilotObject 444 +#define OBJ_pilotObject OBJ_pilotObjectClass,3L + +#define LN_pilotPerson "pilotPerson" +#define NID_pilotPerson 445 +#define OBJ_pilotPerson OBJ_pilotObjectClass,4L + +#define SN_account "account" +#define NID_account 446 +#define OBJ_account OBJ_pilotObjectClass,5L + +#define SN_document "document" +#define NID_document 447 +#define OBJ_document OBJ_pilotObjectClass,6L + +#define SN_room "room" +#define NID_room 448 +#define OBJ_room OBJ_pilotObjectClass,7L + +#define LN_documentSeries "documentSeries" +#define NID_documentSeries 449 +#define OBJ_documentSeries OBJ_pilotObjectClass,9L + +#define SN_Domain "domain" +#define LN_Domain "Domain" +#define NID_Domain 392 +#define OBJ_Domain OBJ_pilotObjectClass,13L + +#define LN_rFC822localPart "rFC822localPart" +#define NID_rFC822localPart 450 +#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L + +#define LN_dNSDomain "dNSDomain" +#define NID_dNSDomain 451 +#define OBJ_dNSDomain OBJ_pilotObjectClass,15L + +#define LN_domainRelatedObject "domainRelatedObject" +#define NID_domainRelatedObject 452 +#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L + +#define LN_friendlyCountry "friendlyCountry" +#define NID_friendlyCountry 453 +#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L + +#define LN_simpleSecurityObject "simpleSecurityObject" +#define NID_simpleSecurityObject 454 +#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L + +#define LN_pilotOrganization "pilotOrganization" +#define NID_pilotOrganization 455 +#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L + +#define LN_pilotDSA "pilotDSA" +#define NID_pilotDSA 456 +#define OBJ_pilotDSA OBJ_pilotObjectClass,21L + +#define LN_qualityLabelledData "qualityLabelledData" +#define NID_qualityLabelledData 457 +#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L + +#define SN_userId "UID" +#define LN_userId "userId" +#define NID_userId 458 +#define OBJ_userId OBJ_pilotAttributeType,1L + +#define LN_textEncodedORAddress "textEncodedORAddress" +#define NID_textEncodedORAddress 459 +#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L + +#define SN_rfc822Mailbox "mail" +#define LN_rfc822Mailbox "rfc822Mailbox" +#define NID_rfc822Mailbox 460 +#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L + +#define SN_info "info" +#define NID_info 461 +#define OBJ_info OBJ_pilotAttributeType,4L + +#define LN_favouriteDrink "favouriteDrink" +#define NID_favouriteDrink 462 +#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L + +#define LN_roomNumber "roomNumber" +#define NID_roomNumber 463 +#define OBJ_roomNumber OBJ_pilotAttributeType,6L + +#define SN_photo "photo" +#define NID_photo 464 +#define OBJ_photo OBJ_pilotAttributeType,7L + +#define LN_userClass "userClass" +#define NID_userClass 465 +#define OBJ_userClass OBJ_pilotAttributeType,8L + +#define SN_host "host" +#define NID_host 466 +#define OBJ_host OBJ_pilotAttributeType,9L + +#define SN_manager "manager" +#define NID_manager 467 +#define OBJ_manager OBJ_pilotAttributeType,10L + +#define LN_documentIdentifier "documentIdentifier" +#define NID_documentIdentifier 468 +#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L + +#define LN_documentTitle "documentTitle" +#define NID_documentTitle 469 +#define OBJ_documentTitle OBJ_pilotAttributeType,12L + +#define LN_documentVersion "documentVersion" +#define NID_documentVersion 470 +#define OBJ_documentVersion OBJ_pilotAttributeType,13L + +#define LN_documentAuthor "documentAuthor" +#define NID_documentAuthor 471 +#define OBJ_documentAuthor OBJ_pilotAttributeType,14L + +#define LN_documentLocation "documentLocation" +#define NID_documentLocation 472 +#define OBJ_documentLocation OBJ_pilotAttributeType,15L + +#define LN_homeTelephoneNumber "homeTelephoneNumber" +#define NID_homeTelephoneNumber 473 +#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L + +#define SN_secretary "secretary" +#define NID_secretary 474 +#define OBJ_secretary OBJ_pilotAttributeType,21L + +#define LN_otherMailbox "otherMailbox" +#define NID_otherMailbox 475 +#define OBJ_otherMailbox OBJ_pilotAttributeType,22L + +#define LN_lastModifiedTime "lastModifiedTime" +#define NID_lastModifiedTime 476 +#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L + +#define LN_lastModifiedBy "lastModifiedBy" +#define NID_lastModifiedBy 477 +#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L + +#define SN_domainComponent "DC" +#define LN_domainComponent "domainComponent" +#define NID_domainComponent 391 +#define OBJ_domainComponent OBJ_pilotAttributeType,25L + +#define LN_aRecord "aRecord" +#define NID_aRecord 478 +#define OBJ_aRecord OBJ_pilotAttributeType,26L + +#define LN_pilotAttributeType27 "pilotAttributeType27" +#define NID_pilotAttributeType27 479 +#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L + +#define LN_mXRecord "mXRecord" +#define NID_mXRecord 480 +#define OBJ_mXRecord OBJ_pilotAttributeType,28L + +#define LN_nSRecord "nSRecord" +#define NID_nSRecord 481 +#define OBJ_nSRecord OBJ_pilotAttributeType,29L + +#define LN_sOARecord "sOARecord" +#define NID_sOARecord 482 +#define OBJ_sOARecord OBJ_pilotAttributeType,30L + +#define LN_cNAMERecord "cNAMERecord" +#define NID_cNAMERecord 483 +#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L + +#define LN_associatedDomain "associatedDomain" +#define NID_associatedDomain 484 +#define OBJ_associatedDomain OBJ_pilotAttributeType,37L + +#define LN_associatedName "associatedName" +#define NID_associatedName 485 +#define OBJ_associatedName OBJ_pilotAttributeType,38L + +#define LN_homePostalAddress "homePostalAddress" +#define NID_homePostalAddress 486 +#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L + +#define LN_personalTitle "personalTitle" +#define NID_personalTitle 487 +#define OBJ_personalTitle OBJ_pilotAttributeType,40L + +#define LN_mobileTelephoneNumber "mobileTelephoneNumber" +#define NID_mobileTelephoneNumber 488 +#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L + +#define LN_pagerTelephoneNumber "pagerTelephoneNumber" +#define NID_pagerTelephoneNumber 489 +#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L + +#define LN_friendlyCountryName "friendlyCountryName" +#define NID_friendlyCountryName 490 +#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L + +#define SN_uniqueIdentifier "uid" +#define LN_uniqueIdentifier "uniqueIdentifier" +#define NID_uniqueIdentifier 102 +#define OBJ_uniqueIdentifier OBJ_pilotAttributeType,44L + +#define LN_organizationalStatus "organizationalStatus" +#define NID_organizationalStatus 491 +#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L + +#define LN_janetMailbox "janetMailbox" +#define NID_janetMailbox 492 +#define OBJ_janetMailbox OBJ_pilotAttributeType,46L + +#define LN_mailPreferenceOption "mailPreferenceOption" +#define NID_mailPreferenceOption 493 +#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L + +#define LN_buildingName "buildingName" +#define NID_buildingName 494 +#define OBJ_buildingName OBJ_pilotAttributeType,48L + +#define LN_dSAQuality "dSAQuality" +#define NID_dSAQuality 495 +#define OBJ_dSAQuality OBJ_pilotAttributeType,49L + +#define LN_singleLevelQuality "singleLevelQuality" +#define NID_singleLevelQuality 496 +#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L + +#define LN_subtreeMinimumQuality "subtreeMinimumQuality" +#define NID_subtreeMinimumQuality 497 +#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L + +#define LN_subtreeMaximumQuality "subtreeMaximumQuality" +#define NID_subtreeMaximumQuality 498 +#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L + +#define LN_personalSignature "personalSignature" +#define NID_personalSignature 499 +#define OBJ_personalSignature OBJ_pilotAttributeType,53L + +#define LN_dITRedirect "dITRedirect" +#define NID_dITRedirect 500 +#define OBJ_dITRedirect OBJ_pilotAttributeType,54L + +#define SN_audio "audio" +#define NID_audio 501 +#define OBJ_audio OBJ_pilotAttributeType,55L + +#define LN_documentPublisher "documentPublisher" +#define NID_documentPublisher 502 +#define OBJ_documentPublisher OBJ_pilotAttributeType,56L + +#define SN_id_set "id-set" +#define LN_id_set "Secure Electronic Transactions" +#define NID_id_set 512 +#define OBJ_id_set OBJ_international_organizations,42L + +#define SN_set_ctype "set-ctype" +#define LN_set_ctype "content types" +#define NID_set_ctype 513 +#define OBJ_set_ctype OBJ_id_set,0L + +#define SN_set_msgExt "set-msgExt" +#define LN_set_msgExt "message extensions" +#define NID_set_msgExt 514 +#define OBJ_set_msgExt OBJ_id_set,1L + +#define SN_set_attr "set-attr" +#define NID_set_attr 515 +#define OBJ_set_attr OBJ_id_set,3L + +#define SN_set_policy "set-policy" +#define NID_set_policy 516 +#define OBJ_set_policy OBJ_id_set,5L + +#define SN_set_certExt "set-certExt" +#define LN_set_certExt "certificate extensions" +#define NID_set_certExt 517 +#define OBJ_set_certExt OBJ_id_set,7L + +#define SN_set_brand "set-brand" +#define NID_set_brand 518 +#define OBJ_set_brand OBJ_id_set,8L + +#define SN_setct_PANData "setct-PANData" +#define NID_setct_PANData 519 +#define OBJ_setct_PANData OBJ_set_ctype,0L + +#define SN_setct_PANToken "setct-PANToken" +#define NID_setct_PANToken 520 +#define OBJ_setct_PANToken OBJ_set_ctype,1L + +#define SN_setct_PANOnly "setct-PANOnly" +#define NID_setct_PANOnly 521 +#define OBJ_setct_PANOnly OBJ_set_ctype,2L + +#define SN_setct_OIData "setct-OIData" +#define NID_setct_OIData 522 +#define OBJ_setct_OIData OBJ_set_ctype,3L + +#define SN_setct_PI "setct-PI" +#define NID_setct_PI 523 +#define OBJ_setct_PI OBJ_set_ctype,4L + +#define SN_setct_PIData "setct-PIData" +#define NID_setct_PIData 524 +#define OBJ_setct_PIData OBJ_set_ctype,5L + +#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" +#define NID_setct_PIDataUnsigned 525 +#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L + +#define SN_setct_HODInput "setct-HODInput" +#define NID_setct_HODInput 526 +#define OBJ_setct_HODInput OBJ_set_ctype,7L + +#define SN_setct_AuthResBaggage "setct-AuthResBaggage" +#define NID_setct_AuthResBaggage 527 +#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L + +#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" +#define NID_setct_AuthRevReqBaggage 528 +#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L + +#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" +#define NID_setct_AuthRevResBaggage 529 +#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L + +#define SN_setct_CapTokenSeq "setct-CapTokenSeq" +#define NID_setct_CapTokenSeq 530 +#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L + +#define SN_setct_PInitResData "setct-PInitResData" +#define NID_setct_PInitResData 531 +#define OBJ_setct_PInitResData OBJ_set_ctype,12L + +#define SN_setct_PI_TBS "setct-PI-TBS" +#define NID_setct_PI_TBS 532 +#define OBJ_setct_PI_TBS OBJ_set_ctype,13L + +#define SN_setct_PResData "setct-PResData" +#define NID_setct_PResData 533 +#define OBJ_setct_PResData OBJ_set_ctype,14L + +#define SN_setct_AuthReqTBS "setct-AuthReqTBS" +#define NID_setct_AuthReqTBS 534 +#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L + +#define SN_setct_AuthResTBS "setct-AuthResTBS" +#define NID_setct_AuthResTBS 535 +#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L + +#define SN_setct_AuthResTBSX "setct-AuthResTBSX" +#define NID_setct_AuthResTBSX 536 +#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L + +#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" +#define NID_setct_AuthTokenTBS 537 +#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L + +#define SN_setct_CapTokenData "setct-CapTokenData" +#define NID_setct_CapTokenData 538 +#define OBJ_setct_CapTokenData OBJ_set_ctype,20L + +#define SN_setct_CapTokenTBS "setct-CapTokenTBS" +#define NID_setct_CapTokenTBS 539 +#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L + +#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" +#define NID_setct_AcqCardCodeMsg 540 +#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L + +#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" +#define NID_setct_AuthRevReqTBS 541 +#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L + +#define SN_setct_AuthRevResData "setct-AuthRevResData" +#define NID_setct_AuthRevResData 542 +#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L + +#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" +#define NID_setct_AuthRevResTBS 543 +#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L + +#define SN_setct_CapReqTBS "setct-CapReqTBS" +#define NID_setct_CapReqTBS 544 +#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L + +#define SN_setct_CapReqTBSX "setct-CapReqTBSX" +#define NID_setct_CapReqTBSX 545 +#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L + +#define SN_setct_CapResData "setct-CapResData" +#define NID_setct_CapResData 546 +#define OBJ_setct_CapResData OBJ_set_ctype,28L + +#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" +#define NID_setct_CapRevReqTBS 547 +#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L + +#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" +#define NID_setct_CapRevReqTBSX 548 +#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L + +#define SN_setct_CapRevResData "setct-CapRevResData" +#define NID_setct_CapRevResData 549 +#define OBJ_setct_CapRevResData OBJ_set_ctype,31L + +#define SN_setct_CredReqTBS "setct-CredReqTBS" +#define NID_setct_CredReqTBS 550 +#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L + +#define SN_setct_CredReqTBSX "setct-CredReqTBSX" +#define NID_setct_CredReqTBSX 551 +#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L + +#define SN_setct_CredResData "setct-CredResData" +#define NID_setct_CredResData 552 +#define OBJ_setct_CredResData OBJ_set_ctype,34L + +#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" +#define NID_setct_CredRevReqTBS 553 +#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L + +#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" +#define NID_setct_CredRevReqTBSX 554 +#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L + +#define SN_setct_CredRevResData "setct-CredRevResData" +#define NID_setct_CredRevResData 555 +#define OBJ_setct_CredRevResData OBJ_set_ctype,37L + +#define SN_setct_PCertReqData "setct-PCertReqData" +#define NID_setct_PCertReqData 556 +#define OBJ_setct_PCertReqData OBJ_set_ctype,38L + +#define SN_setct_PCertResTBS "setct-PCertResTBS" +#define NID_setct_PCertResTBS 557 +#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L + +#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" +#define NID_setct_BatchAdminReqData 558 +#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L + +#define SN_setct_BatchAdminResData "setct-BatchAdminResData" +#define NID_setct_BatchAdminResData 559 +#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L + +#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" +#define NID_setct_CardCInitResTBS 560 +#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L + +#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" +#define NID_setct_MeAqCInitResTBS 561 +#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L + +#define SN_setct_RegFormResTBS "setct-RegFormResTBS" +#define NID_setct_RegFormResTBS 562 +#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L + +#define SN_setct_CertReqData "setct-CertReqData" +#define NID_setct_CertReqData 563 +#define OBJ_setct_CertReqData OBJ_set_ctype,45L + +#define SN_setct_CertReqTBS "setct-CertReqTBS" +#define NID_setct_CertReqTBS 564 +#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L + +#define SN_setct_CertResData "setct-CertResData" +#define NID_setct_CertResData 565 +#define OBJ_setct_CertResData OBJ_set_ctype,47L + +#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" +#define NID_setct_CertInqReqTBS 566 +#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L + +#define SN_setct_ErrorTBS "setct-ErrorTBS" +#define NID_setct_ErrorTBS 567 +#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L + +#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" +#define NID_setct_PIDualSignedTBE 568 +#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L + +#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" +#define NID_setct_PIUnsignedTBE 569 +#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L + +#define SN_setct_AuthReqTBE "setct-AuthReqTBE" +#define NID_setct_AuthReqTBE 570 +#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L + +#define SN_setct_AuthResTBE "setct-AuthResTBE" +#define NID_setct_AuthResTBE 571 +#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L + +#define SN_setct_AuthResTBEX "setct-AuthResTBEX" +#define NID_setct_AuthResTBEX 572 +#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L + +#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" +#define NID_setct_AuthTokenTBE 573 +#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L + +#define SN_setct_CapTokenTBE "setct-CapTokenTBE" +#define NID_setct_CapTokenTBE 574 +#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L + +#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" +#define NID_setct_CapTokenTBEX 575 +#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L + +#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" +#define NID_setct_AcqCardCodeMsgTBE 576 +#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L + +#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" +#define NID_setct_AuthRevReqTBE 577 +#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L + +#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" +#define NID_setct_AuthRevResTBE 578 +#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L + +#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" +#define NID_setct_AuthRevResTBEB 579 +#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L + +#define SN_setct_CapReqTBE "setct-CapReqTBE" +#define NID_setct_CapReqTBE 580 +#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L + +#define SN_setct_CapReqTBEX "setct-CapReqTBEX" +#define NID_setct_CapReqTBEX 581 +#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L + +#define SN_setct_CapResTBE "setct-CapResTBE" +#define NID_setct_CapResTBE 582 +#define OBJ_setct_CapResTBE OBJ_set_ctype,64L + +#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" +#define NID_setct_CapRevReqTBE 583 +#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L + +#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" +#define NID_setct_CapRevReqTBEX 584 +#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L + +#define SN_setct_CapRevResTBE "setct-CapRevResTBE" +#define NID_setct_CapRevResTBE 585 +#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L + +#define SN_setct_CredReqTBE "setct-CredReqTBE" +#define NID_setct_CredReqTBE 586 +#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L + +#define SN_setct_CredReqTBEX "setct-CredReqTBEX" +#define NID_setct_CredReqTBEX 587 +#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L + +#define SN_setct_CredResTBE "setct-CredResTBE" +#define NID_setct_CredResTBE 588 +#define OBJ_setct_CredResTBE OBJ_set_ctype,70L + +#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" +#define NID_setct_CredRevReqTBE 589 +#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L + +#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" +#define NID_setct_CredRevReqTBEX 590 +#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L + +#define SN_setct_CredRevResTBE "setct-CredRevResTBE" +#define NID_setct_CredRevResTBE 591 +#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L + +#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" +#define NID_setct_BatchAdminReqTBE 592 +#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L + +#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" +#define NID_setct_BatchAdminResTBE 593 +#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L + +#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" +#define NID_setct_RegFormReqTBE 594 +#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L + +#define SN_setct_CertReqTBE "setct-CertReqTBE" +#define NID_setct_CertReqTBE 595 +#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L + +#define SN_setct_CertReqTBEX "setct-CertReqTBEX" +#define NID_setct_CertReqTBEX 596 +#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L + +#define SN_setct_CertResTBE "setct-CertResTBE" +#define NID_setct_CertResTBE 597 +#define OBJ_setct_CertResTBE OBJ_set_ctype,79L + +#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" +#define NID_setct_CRLNotificationTBS 598 +#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L + +#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" +#define NID_setct_CRLNotificationResTBS 599 +#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L + +#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" +#define NID_setct_BCIDistributionTBS 600 +#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L + +#define SN_setext_genCrypt "setext-genCrypt" +#define LN_setext_genCrypt "generic cryptogram" +#define NID_setext_genCrypt 601 +#define OBJ_setext_genCrypt OBJ_set_msgExt,1L + +#define SN_setext_miAuth "setext-miAuth" +#define LN_setext_miAuth "merchant initiated auth" +#define NID_setext_miAuth 602 +#define OBJ_setext_miAuth OBJ_set_msgExt,3L + +#define SN_setext_pinSecure "setext-pinSecure" +#define NID_setext_pinSecure 603 +#define OBJ_setext_pinSecure OBJ_set_msgExt,4L + +#define SN_setext_pinAny "setext-pinAny" +#define NID_setext_pinAny 604 +#define OBJ_setext_pinAny OBJ_set_msgExt,5L + +#define SN_setext_track2 "setext-track2" +#define NID_setext_track2 605 +#define OBJ_setext_track2 OBJ_set_msgExt,7L + +#define SN_setext_cv "setext-cv" +#define LN_setext_cv "additional verification" +#define NID_setext_cv 606 +#define OBJ_setext_cv OBJ_set_msgExt,8L + +#define SN_set_policy_root "set-policy-root" +#define NID_set_policy_root 607 +#define OBJ_set_policy_root OBJ_set_policy,0L + +#define SN_setCext_hashedRoot "setCext-hashedRoot" +#define NID_setCext_hashedRoot 608 +#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L + +#define SN_setCext_certType "setCext-certType" +#define NID_setCext_certType 609 +#define OBJ_setCext_certType OBJ_set_certExt,1L + +#define SN_setCext_merchData "setCext-merchData" +#define NID_setCext_merchData 610 +#define OBJ_setCext_merchData OBJ_set_certExt,2L + +#define SN_setCext_cCertRequired "setCext-cCertRequired" +#define NID_setCext_cCertRequired 611 +#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L + +#define SN_setCext_tunneling "setCext-tunneling" +#define NID_setCext_tunneling 612 +#define OBJ_setCext_tunneling OBJ_set_certExt,4L + +#define SN_setCext_setExt "setCext-setExt" +#define NID_setCext_setExt 613 +#define OBJ_setCext_setExt OBJ_set_certExt,5L + +#define SN_setCext_setQualf "setCext-setQualf" +#define NID_setCext_setQualf 614 +#define OBJ_setCext_setQualf OBJ_set_certExt,6L + +#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" +#define NID_setCext_PGWYcapabilities 615 +#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L + +#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" +#define NID_setCext_TokenIdentifier 616 +#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L + +#define SN_setCext_Track2Data "setCext-Track2Data" +#define NID_setCext_Track2Data 617 +#define OBJ_setCext_Track2Data OBJ_set_certExt,9L + +#define SN_setCext_TokenType "setCext-TokenType" +#define NID_setCext_TokenType 618 +#define OBJ_setCext_TokenType OBJ_set_certExt,10L + +#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" +#define NID_setCext_IssuerCapabilities 619 +#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L + +#define SN_setAttr_Cert "setAttr-Cert" +#define NID_setAttr_Cert 620 +#define OBJ_setAttr_Cert OBJ_set_attr,0L + +#define SN_setAttr_PGWYcap "setAttr-PGWYcap" +#define LN_setAttr_PGWYcap "payment gateway capabilities" +#define NID_setAttr_PGWYcap 621 +#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L + +#define SN_setAttr_TokenType "setAttr-TokenType" +#define NID_setAttr_TokenType 622 +#define OBJ_setAttr_TokenType OBJ_set_attr,2L + +#define SN_setAttr_IssCap "setAttr-IssCap" +#define LN_setAttr_IssCap "issuer capabilities" +#define NID_setAttr_IssCap 623 +#define OBJ_setAttr_IssCap OBJ_set_attr,3L + +#define SN_set_rootKeyThumb "set-rootKeyThumb" +#define NID_set_rootKeyThumb 624 +#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L + +#define SN_set_addPolicy "set-addPolicy" +#define NID_set_addPolicy 625 +#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L + +#define SN_setAttr_Token_EMV "setAttr-Token-EMV" +#define NID_setAttr_Token_EMV 626 +#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L + +#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" +#define NID_setAttr_Token_B0Prime 627 +#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L + +#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" +#define NID_setAttr_IssCap_CVM 628 +#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L + +#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" +#define NID_setAttr_IssCap_T2 629 +#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L + +#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" +#define NID_setAttr_IssCap_Sig 630 +#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L + +#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" +#define LN_setAttr_GenCryptgrm "generate cryptogram" +#define NID_setAttr_GenCryptgrm 631 +#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L + +#define SN_setAttr_T2Enc "setAttr-T2Enc" +#define LN_setAttr_T2Enc "encrypted track 2" +#define NID_setAttr_T2Enc 632 +#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L + +#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" +#define LN_setAttr_T2cleartxt "cleartext track 2" +#define NID_setAttr_T2cleartxt 633 +#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L + +#define SN_setAttr_TokICCsig "setAttr-TokICCsig" +#define LN_setAttr_TokICCsig "ICC or token signature" +#define NID_setAttr_TokICCsig 634 +#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L + +#define SN_setAttr_SecDevSig "setAttr-SecDevSig" +#define LN_setAttr_SecDevSig "secure device signature" +#define NID_setAttr_SecDevSig 635 +#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L + +#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" +#define NID_set_brand_IATA_ATA 636 +#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L + +#define SN_set_brand_Diners "set-brand-Diners" +#define NID_set_brand_Diners 637 +#define OBJ_set_brand_Diners OBJ_set_brand,30L + +#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" +#define NID_set_brand_AmericanExpress 638 +#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L + +#define SN_set_brand_JCB "set-brand-JCB" +#define NID_set_brand_JCB 639 +#define OBJ_set_brand_JCB OBJ_set_brand,35L + +#define SN_set_brand_Visa "set-brand-Visa" +#define NID_set_brand_Visa 640 +#define OBJ_set_brand_Visa OBJ_set_brand,4L + +#define SN_set_brand_MasterCard "set-brand-MasterCard" +#define NID_set_brand_MasterCard 641 +#define OBJ_set_brand_MasterCard OBJ_set_brand,5L + +#define SN_set_brand_Novus "set-brand-Novus" +#define NID_set_brand_Novus 642 +#define OBJ_set_brand_Novus OBJ_set_brand,6011L + +#define SN_des_cdmf "DES-CDMF" +#define LN_des_cdmf "des-cdmf" +#define NID_des_cdmf 643 +#define OBJ_des_cdmf OBJ_rsadsi,3L,10L + +#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" +#define NID_rsaOAEPEncryptionSET 644 +#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L + +#define SN_ipsec3 "Oakley-EC2N-3" +#define LN_ipsec3 "ipsec3" +#define NID_ipsec3 749 + +#define SN_ipsec4 "Oakley-EC2N-4" +#define LN_ipsec4 "ipsec4" +#define NID_ipsec4 750 + +#define SN_whirlpool "whirlpool" +#define NID_whirlpool 804 +#define OBJ_whirlpool OBJ_iso,0L,10118L,3L,0L,55L + +#define SN_cryptopro "cryptopro" +#define NID_cryptopro 805 +#define OBJ_cryptopro OBJ_member_body,643L,2L,2L + +#define SN_cryptocom "cryptocom" +#define NID_cryptocom 806 +#define OBJ_cryptocom OBJ_member_body,643L,2L,9L + +#define SN_id_tc26 "id-tc26" +#define NID_id_tc26 974 +#define OBJ_id_tc26 OBJ_member_body,643L,7L,1L + +#define SN_id_GostR3411_94_with_GostR3410_2001 "id-GostR3411-94-with-GostR3410-2001" +#define LN_id_GostR3411_94_with_GostR3410_2001 "GOST R 34.11-94 with GOST R 34.10-2001" +#define NID_id_GostR3411_94_with_GostR3410_2001 807 +#define OBJ_id_GostR3411_94_with_GostR3410_2001 OBJ_cryptopro,3L + +#define SN_id_GostR3411_94_with_GostR3410_94 "id-GostR3411-94-with-GostR3410-94" +#define LN_id_GostR3411_94_with_GostR3410_94 "GOST R 34.11-94 with GOST R 34.10-94" +#define NID_id_GostR3411_94_with_GostR3410_94 808 +#define OBJ_id_GostR3411_94_with_GostR3410_94 OBJ_cryptopro,4L + +#define SN_id_GostR3411_94 "md_gost94" +#define LN_id_GostR3411_94 "GOST R 34.11-94" +#define NID_id_GostR3411_94 809 +#define OBJ_id_GostR3411_94 OBJ_cryptopro,9L + +#define SN_id_HMACGostR3411_94 "id-HMACGostR3411-94" +#define LN_id_HMACGostR3411_94 "HMAC GOST 34.11-94" +#define NID_id_HMACGostR3411_94 810 +#define OBJ_id_HMACGostR3411_94 OBJ_cryptopro,10L + +#define SN_id_GostR3410_2001 "gost2001" +#define LN_id_GostR3410_2001 "GOST R 34.10-2001" +#define NID_id_GostR3410_2001 811 +#define OBJ_id_GostR3410_2001 OBJ_cryptopro,19L + +#define SN_id_GostR3410_94 "gost94" +#define LN_id_GostR3410_94 "GOST R 34.10-94" +#define NID_id_GostR3410_94 812 +#define OBJ_id_GostR3410_94 OBJ_cryptopro,20L + +#define SN_id_Gost28147_89 "gost89" +#define LN_id_Gost28147_89 "GOST 28147-89" +#define NID_id_Gost28147_89 813 +#define OBJ_id_Gost28147_89 OBJ_cryptopro,21L + +#define SN_gost89_cnt "gost89-cnt" +#define NID_gost89_cnt 814 + +#define SN_gost89_cnt_12 "gost89-cnt-12" +#define NID_gost89_cnt_12 975 + +#define SN_gost89_cbc "gost89-cbc" +#define NID_gost89_cbc 1009 + +#define SN_gost89_ecb "gost89-ecb" +#define NID_gost89_ecb 1010 + +#define SN_gost89_ctr "gost89-ctr" +#define NID_gost89_ctr 1011 + +#define SN_id_Gost28147_89_MAC "gost-mac" +#define LN_id_Gost28147_89_MAC "GOST 28147-89 MAC" +#define NID_id_Gost28147_89_MAC 815 +#define OBJ_id_Gost28147_89_MAC OBJ_cryptopro,22L + +#define SN_gost_mac_12 "gost-mac-12" +#define NID_gost_mac_12 976 + +#define SN_id_GostR3411_94_prf "prf-gostr3411-94" +#define LN_id_GostR3411_94_prf "GOST R 34.11-94 PRF" +#define NID_id_GostR3411_94_prf 816 +#define OBJ_id_GostR3411_94_prf OBJ_cryptopro,23L + +#define SN_id_GostR3410_2001DH "id-GostR3410-2001DH" +#define LN_id_GostR3410_2001DH "GOST R 34.10-2001 DH" +#define NID_id_GostR3410_2001DH 817 +#define OBJ_id_GostR3410_2001DH OBJ_cryptopro,98L + +#define SN_id_GostR3410_94DH "id-GostR3410-94DH" +#define LN_id_GostR3410_94DH "GOST R 34.10-94 DH" +#define NID_id_GostR3410_94DH 818 +#define OBJ_id_GostR3410_94DH OBJ_cryptopro,99L + +#define SN_id_Gost28147_89_CryptoPro_KeyMeshing "id-Gost28147-89-CryptoPro-KeyMeshing" +#define NID_id_Gost28147_89_CryptoPro_KeyMeshing 819 +#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing OBJ_cryptopro,14L,1L + +#define SN_id_Gost28147_89_None_KeyMeshing "id-Gost28147-89-None-KeyMeshing" +#define NID_id_Gost28147_89_None_KeyMeshing 820 +#define OBJ_id_Gost28147_89_None_KeyMeshing OBJ_cryptopro,14L,0L + +#define SN_id_GostR3411_94_TestParamSet "id-GostR3411-94-TestParamSet" +#define NID_id_GostR3411_94_TestParamSet 821 +#define OBJ_id_GostR3411_94_TestParamSet OBJ_cryptopro,30L,0L + +#define SN_id_GostR3411_94_CryptoProParamSet "id-GostR3411-94-CryptoProParamSet" +#define NID_id_GostR3411_94_CryptoProParamSet 822 +#define OBJ_id_GostR3411_94_CryptoProParamSet OBJ_cryptopro,30L,1L + +#define SN_id_Gost28147_89_TestParamSet "id-Gost28147-89-TestParamSet" +#define NID_id_Gost28147_89_TestParamSet 823 +#define OBJ_id_Gost28147_89_TestParamSet OBJ_cryptopro,31L,0L + +#define SN_id_Gost28147_89_CryptoPro_A_ParamSet "id-Gost28147-89-CryptoPro-A-ParamSet" +#define NID_id_Gost28147_89_CryptoPro_A_ParamSet 824 +#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet OBJ_cryptopro,31L,1L + +#define SN_id_Gost28147_89_CryptoPro_B_ParamSet "id-Gost28147-89-CryptoPro-B-ParamSet" +#define NID_id_Gost28147_89_CryptoPro_B_ParamSet 825 +#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet OBJ_cryptopro,31L,2L + +#define SN_id_Gost28147_89_CryptoPro_C_ParamSet "id-Gost28147-89-CryptoPro-C-ParamSet" +#define NID_id_Gost28147_89_CryptoPro_C_ParamSet 826 +#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet OBJ_cryptopro,31L,3L + +#define SN_id_Gost28147_89_CryptoPro_D_ParamSet "id-Gost28147-89-CryptoPro-D-ParamSet" +#define NID_id_Gost28147_89_CryptoPro_D_ParamSet 827 +#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet OBJ_cryptopro,31L,4L + +#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" +#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 828 +#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet OBJ_cryptopro,31L,5L + +#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" +#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 829 +#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet OBJ_cryptopro,31L,6L + +#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" +#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 830 +#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet OBJ_cryptopro,31L,7L + +#define SN_id_GostR3410_94_TestParamSet "id-GostR3410-94-TestParamSet" +#define NID_id_GostR3410_94_TestParamSet 831 +#define OBJ_id_GostR3410_94_TestParamSet OBJ_cryptopro,32L,0L + +#define SN_id_GostR3410_94_CryptoPro_A_ParamSet "id-GostR3410-94-CryptoPro-A-ParamSet" +#define NID_id_GostR3410_94_CryptoPro_A_ParamSet 832 +#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet OBJ_cryptopro,32L,2L + +#define SN_id_GostR3410_94_CryptoPro_B_ParamSet "id-GostR3410-94-CryptoPro-B-ParamSet" +#define NID_id_GostR3410_94_CryptoPro_B_ParamSet 833 +#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet OBJ_cryptopro,32L,3L + +#define SN_id_GostR3410_94_CryptoPro_C_ParamSet "id-GostR3410-94-CryptoPro-C-ParamSet" +#define NID_id_GostR3410_94_CryptoPro_C_ParamSet 834 +#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet OBJ_cryptopro,32L,4L + +#define SN_id_GostR3410_94_CryptoPro_D_ParamSet "id-GostR3410-94-CryptoPro-D-ParamSet" +#define NID_id_GostR3410_94_CryptoPro_D_ParamSet 835 +#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet OBJ_cryptopro,32L,5L + +#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet "id-GostR3410-94-CryptoPro-XchA-ParamSet" +#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet 836 +#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet OBJ_cryptopro,33L,1L + +#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet "id-GostR3410-94-CryptoPro-XchB-ParamSet" +#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet 837 +#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet OBJ_cryptopro,33L,2L + +#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet "id-GostR3410-94-CryptoPro-XchC-ParamSet" +#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet 838 +#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet OBJ_cryptopro,33L,3L + +#define SN_id_GostR3410_2001_TestParamSet "id-GostR3410-2001-TestParamSet" +#define NID_id_GostR3410_2001_TestParamSet 839 +#define OBJ_id_GostR3410_2001_TestParamSet OBJ_cryptopro,35L,0L + +#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet "id-GostR3410-2001-CryptoPro-A-ParamSet" +#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet 840 +#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet OBJ_cryptopro,35L,1L + +#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet "id-GostR3410-2001-CryptoPro-B-ParamSet" +#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet 841 +#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet OBJ_cryptopro,35L,2L + +#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet "id-GostR3410-2001-CryptoPro-C-ParamSet" +#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet 842 +#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet OBJ_cryptopro,35L,3L + +#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet "id-GostR3410-2001-CryptoPro-XchA-ParamSet" +#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet 843 +#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet OBJ_cryptopro,36L,0L + +#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet "id-GostR3410-2001-CryptoPro-XchB-ParamSet" +#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet 844 +#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet OBJ_cryptopro,36L,1L + +#define SN_id_GostR3410_94_a "id-GostR3410-94-a" +#define NID_id_GostR3410_94_a 845 +#define OBJ_id_GostR3410_94_a OBJ_id_GostR3410_94,1L + +#define SN_id_GostR3410_94_aBis "id-GostR3410-94-aBis" +#define NID_id_GostR3410_94_aBis 846 +#define OBJ_id_GostR3410_94_aBis OBJ_id_GostR3410_94,2L + +#define SN_id_GostR3410_94_b "id-GostR3410-94-b" +#define NID_id_GostR3410_94_b 847 +#define OBJ_id_GostR3410_94_b OBJ_id_GostR3410_94,3L + +#define SN_id_GostR3410_94_bBis "id-GostR3410-94-bBis" +#define NID_id_GostR3410_94_bBis 848 +#define OBJ_id_GostR3410_94_bBis OBJ_id_GostR3410_94,4L + +#define SN_id_Gost28147_89_cc "id-Gost28147-89-cc" +#define LN_id_Gost28147_89_cc "GOST 28147-89 Cryptocom ParamSet" +#define NID_id_Gost28147_89_cc 849 +#define OBJ_id_Gost28147_89_cc OBJ_cryptocom,1L,6L,1L + +#define SN_id_GostR3410_94_cc "gost94cc" +#define LN_id_GostR3410_94_cc "GOST 34.10-94 Cryptocom" +#define NID_id_GostR3410_94_cc 850 +#define OBJ_id_GostR3410_94_cc OBJ_cryptocom,1L,5L,3L + +#define SN_id_GostR3410_2001_cc "gost2001cc" +#define LN_id_GostR3410_2001_cc "GOST 34.10-2001 Cryptocom" +#define NID_id_GostR3410_2001_cc 851 +#define OBJ_id_GostR3410_2001_cc OBJ_cryptocom,1L,5L,4L + +#define SN_id_GostR3411_94_with_GostR3410_94_cc "id-GostR3411-94-with-GostR3410-94-cc" +#define LN_id_GostR3411_94_with_GostR3410_94_cc "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" +#define NID_id_GostR3411_94_with_GostR3410_94_cc 852 +#define OBJ_id_GostR3411_94_with_GostR3410_94_cc OBJ_cryptocom,1L,3L,3L + +#define SN_id_GostR3411_94_with_GostR3410_2001_cc "id-GostR3411-94-with-GostR3410-2001-cc" +#define LN_id_GostR3411_94_with_GostR3410_2001_cc "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom" +#define NID_id_GostR3411_94_with_GostR3410_2001_cc 853 +#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc OBJ_cryptocom,1L,3L,4L + +#define SN_id_GostR3410_2001_ParamSet_cc "id-GostR3410-2001-ParamSet-cc" +#define LN_id_GostR3410_2001_ParamSet_cc "GOST R 3410-2001 Parameter Set Cryptocom" +#define NID_id_GostR3410_2001_ParamSet_cc 854 +#define OBJ_id_GostR3410_2001_ParamSet_cc OBJ_cryptocom,1L,8L,1L + +#define SN_id_tc26_algorithms "id-tc26-algorithms" +#define NID_id_tc26_algorithms 977 +#define OBJ_id_tc26_algorithms OBJ_id_tc26,1L + +#define SN_id_tc26_sign "id-tc26-sign" +#define NID_id_tc26_sign 978 +#define OBJ_id_tc26_sign OBJ_id_tc26_algorithms,1L + +#define SN_id_GostR3410_2012_256 "gost2012_256" +#define LN_id_GostR3410_2012_256 "GOST R 34.10-2012 with 256 bit modulus" +#define NID_id_GostR3410_2012_256 979 +#define OBJ_id_GostR3410_2012_256 OBJ_id_tc26_sign,1L + +#define SN_id_GostR3410_2012_512 "gost2012_512" +#define LN_id_GostR3410_2012_512 "GOST R 34.10-2012 with 512 bit modulus" +#define NID_id_GostR3410_2012_512 980 +#define OBJ_id_GostR3410_2012_512 OBJ_id_tc26_sign,2L + +#define SN_id_tc26_digest "id-tc26-digest" +#define NID_id_tc26_digest 981 +#define OBJ_id_tc26_digest OBJ_id_tc26_algorithms,2L + +#define SN_id_GostR3411_2012_256 "md_gost12_256" +#define LN_id_GostR3411_2012_256 "GOST R 34.11-2012 with 256 bit hash" +#define NID_id_GostR3411_2012_256 982 +#define OBJ_id_GostR3411_2012_256 OBJ_id_tc26_digest,2L + +#define SN_id_GostR3411_2012_512 "md_gost12_512" +#define LN_id_GostR3411_2012_512 "GOST R 34.11-2012 with 512 bit hash" +#define NID_id_GostR3411_2012_512 983 +#define OBJ_id_GostR3411_2012_512 OBJ_id_tc26_digest,3L + +#define SN_id_tc26_signwithdigest "id-tc26-signwithdigest" +#define NID_id_tc26_signwithdigest 984 +#define OBJ_id_tc26_signwithdigest OBJ_id_tc26_algorithms,3L + +#define SN_id_tc26_signwithdigest_gost3410_2012_256 "id-tc26-signwithdigest-gost3410-2012-256" +#define LN_id_tc26_signwithdigest_gost3410_2012_256 "GOST R 34.10-2012 with GOST R 34.11-2012 (256 bit)" +#define NID_id_tc26_signwithdigest_gost3410_2012_256 985 +#define OBJ_id_tc26_signwithdigest_gost3410_2012_256 OBJ_id_tc26_signwithdigest,2L + +#define SN_id_tc26_signwithdigest_gost3410_2012_512 "id-tc26-signwithdigest-gost3410-2012-512" +#define LN_id_tc26_signwithdigest_gost3410_2012_512 "GOST R 34.10-2012 with GOST R 34.11-2012 (512 bit)" +#define NID_id_tc26_signwithdigest_gost3410_2012_512 986 +#define OBJ_id_tc26_signwithdigest_gost3410_2012_512 OBJ_id_tc26_signwithdigest,3L + +#define SN_id_tc26_mac "id-tc26-mac" +#define NID_id_tc26_mac 987 +#define OBJ_id_tc26_mac OBJ_id_tc26_algorithms,4L + +#define SN_id_tc26_hmac_gost_3411_2012_256 "id-tc26-hmac-gost-3411-2012-256" +#define LN_id_tc26_hmac_gost_3411_2012_256 "HMAC GOST 34.11-2012 256 bit" +#define NID_id_tc26_hmac_gost_3411_2012_256 988 +#define OBJ_id_tc26_hmac_gost_3411_2012_256 OBJ_id_tc26_mac,1L + +#define SN_id_tc26_hmac_gost_3411_2012_512 "id-tc26-hmac-gost-3411-2012-512" +#define LN_id_tc26_hmac_gost_3411_2012_512 "HMAC GOST 34.11-2012 512 bit" +#define NID_id_tc26_hmac_gost_3411_2012_512 989 +#define OBJ_id_tc26_hmac_gost_3411_2012_512 OBJ_id_tc26_mac,2L + +#define SN_id_tc26_cipher "id-tc26-cipher" +#define NID_id_tc26_cipher 990 +#define OBJ_id_tc26_cipher OBJ_id_tc26_algorithms,5L + +#define SN_id_tc26_cipher_gostr3412_2015_magma "id-tc26-cipher-gostr3412-2015-magma" +#define NID_id_tc26_cipher_gostr3412_2015_magma 1173 +#define OBJ_id_tc26_cipher_gostr3412_2015_magma OBJ_id_tc26_cipher,1L + +#define SN_magma_ctr_acpkm "magma-ctr-acpkm" +#define NID_magma_ctr_acpkm 1174 +#define OBJ_magma_ctr_acpkm OBJ_id_tc26_cipher_gostr3412_2015_magma,1L + +#define SN_magma_ctr_acpkm_omac "magma-ctr-acpkm-omac" +#define NID_magma_ctr_acpkm_omac 1175 +#define OBJ_magma_ctr_acpkm_omac OBJ_id_tc26_cipher_gostr3412_2015_magma,2L + +#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik "id-tc26-cipher-gostr3412-2015-kuznyechik" +#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik 1176 +#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik OBJ_id_tc26_cipher,2L + +#define SN_kuznyechik_ctr_acpkm "kuznyechik-ctr-acpkm" +#define NID_kuznyechik_ctr_acpkm 1177 +#define OBJ_kuznyechik_ctr_acpkm OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik,1L + +#define SN_kuznyechik_ctr_acpkm_omac "kuznyechik-ctr-acpkm-omac" +#define NID_kuznyechik_ctr_acpkm_omac 1178 +#define OBJ_kuznyechik_ctr_acpkm_omac OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik,2L + +#define SN_id_tc26_agreement "id-tc26-agreement" +#define NID_id_tc26_agreement 991 +#define OBJ_id_tc26_agreement OBJ_id_tc26_algorithms,6L + +#define SN_id_tc26_agreement_gost_3410_2012_256 "id-tc26-agreement-gost-3410-2012-256" +#define NID_id_tc26_agreement_gost_3410_2012_256 992 +#define OBJ_id_tc26_agreement_gost_3410_2012_256 OBJ_id_tc26_agreement,1L + +#define SN_id_tc26_agreement_gost_3410_2012_512 "id-tc26-agreement-gost-3410-2012-512" +#define NID_id_tc26_agreement_gost_3410_2012_512 993 +#define OBJ_id_tc26_agreement_gost_3410_2012_512 OBJ_id_tc26_agreement,2L + +#define SN_id_tc26_wrap "id-tc26-wrap" +#define NID_id_tc26_wrap 1179 +#define OBJ_id_tc26_wrap OBJ_id_tc26_algorithms,7L + +#define SN_id_tc26_wrap_gostr3412_2015_magma "id-tc26-wrap-gostr3412-2015-magma" +#define NID_id_tc26_wrap_gostr3412_2015_magma 1180 +#define OBJ_id_tc26_wrap_gostr3412_2015_magma OBJ_id_tc26_wrap,1L + +#define SN_magma_kexp15 "magma-kexp15" +#define NID_magma_kexp15 1181 +#define OBJ_magma_kexp15 OBJ_id_tc26_wrap_gostr3412_2015_magma,1L + +#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik "id-tc26-wrap-gostr3412-2015-kuznyechik" +#define NID_id_tc26_wrap_gostr3412_2015_kuznyechik 1182 +#define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik OBJ_id_tc26_wrap,2L + +#define SN_kuznyechik_kexp15 "kuznyechik-kexp15" +#define NID_kuznyechik_kexp15 1183 +#define OBJ_kuznyechik_kexp15 OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik,1L + +#define SN_id_tc26_constants "id-tc26-constants" +#define NID_id_tc26_constants 994 +#define OBJ_id_tc26_constants OBJ_id_tc26,2L + +#define SN_id_tc26_sign_constants "id-tc26-sign-constants" +#define NID_id_tc26_sign_constants 995 +#define OBJ_id_tc26_sign_constants OBJ_id_tc26_constants,1L + +#define SN_id_tc26_gost_3410_2012_256_constants "id-tc26-gost-3410-2012-256-constants" +#define NID_id_tc26_gost_3410_2012_256_constants 1147 +#define OBJ_id_tc26_gost_3410_2012_256_constants OBJ_id_tc26_sign_constants,1L + +#define SN_id_tc26_gost_3410_2012_256_paramSetA "id-tc26-gost-3410-2012-256-paramSetA" +#define LN_id_tc26_gost_3410_2012_256_paramSetA "GOST R 34.10-2012 (256 bit) ParamSet A" +#define NID_id_tc26_gost_3410_2012_256_paramSetA 1148 +#define OBJ_id_tc26_gost_3410_2012_256_paramSetA OBJ_id_tc26_gost_3410_2012_256_constants,1L + +#define SN_id_tc26_gost_3410_2012_256_paramSetB "id-tc26-gost-3410-2012-256-paramSetB" +#define LN_id_tc26_gost_3410_2012_256_paramSetB "GOST R 34.10-2012 (256 bit) ParamSet B" +#define NID_id_tc26_gost_3410_2012_256_paramSetB 1184 +#define OBJ_id_tc26_gost_3410_2012_256_paramSetB OBJ_id_tc26_gost_3410_2012_256_constants,2L + +#define SN_id_tc26_gost_3410_2012_256_paramSetC "id-tc26-gost-3410-2012-256-paramSetC" +#define LN_id_tc26_gost_3410_2012_256_paramSetC "GOST R 34.10-2012 (256 bit) ParamSet C" +#define NID_id_tc26_gost_3410_2012_256_paramSetC 1185 +#define OBJ_id_tc26_gost_3410_2012_256_paramSetC OBJ_id_tc26_gost_3410_2012_256_constants,3L + +#define SN_id_tc26_gost_3410_2012_256_paramSetD "id-tc26-gost-3410-2012-256-paramSetD" +#define LN_id_tc26_gost_3410_2012_256_paramSetD "GOST R 34.10-2012 (256 bit) ParamSet D" +#define NID_id_tc26_gost_3410_2012_256_paramSetD 1186 +#define OBJ_id_tc26_gost_3410_2012_256_paramSetD OBJ_id_tc26_gost_3410_2012_256_constants,4L + +#define SN_id_tc26_gost_3410_2012_512_constants "id-tc26-gost-3410-2012-512-constants" +#define NID_id_tc26_gost_3410_2012_512_constants 996 +#define OBJ_id_tc26_gost_3410_2012_512_constants OBJ_id_tc26_sign_constants,2L + +#define SN_id_tc26_gost_3410_2012_512_paramSetTest "id-tc26-gost-3410-2012-512-paramSetTest" +#define LN_id_tc26_gost_3410_2012_512_paramSetTest "GOST R 34.10-2012 (512 bit) testing parameter set" +#define NID_id_tc26_gost_3410_2012_512_paramSetTest 997 +#define OBJ_id_tc26_gost_3410_2012_512_paramSetTest OBJ_id_tc26_gost_3410_2012_512_constants,0L + +#define SN_id_tc26_gost_3410_2012_512_paramSetA "id-tc26-gost-3410-2012-512-paramSetA" +#define LN_id_tc26_gost_3410_2012_512_paramSetA "GOST R 34.10-2012 (512 bit) ParamSet A" +#define NID_id_tc26_gost_3410_2012_512_paramSetA 998 +#define OBJ_id_tc26_gost_3410_2012_512_paramSetA OBJ_id_tc26_gost_3410_2012_512_constants,1L + +#define SN_id_tc26_gost_3410_2012_512_paramSetB "id-tc26-gost-3410-2012-512-paramSetB" +#define LN_id_tc26_gost_3410_2012_512_paramSetB "GOST R 34.10-2012 (512 bit) ParamSet B" +#define NID_id_tc26_gost_3410_2012_512_paramSetB 999 +#define OBJ_id_tc26_gost_3410_2012_512_paramSetB OBJ_id_tc26_gost_3410_2012_512_constants,2L + +#define SN_id_tc26_gost_3410_2012_512_paramSetC "id-tc26-gost-3410-2012-512-paramSetC" +#define LN_id_tc26_gost_3410_2012_512_paramSetC "GOST R 34.10-2012 (512 bit) ParamSet C" +#define NID_id_tc26_gost_3410_2012_512_paramSetC 1149 +#define OBJ_id_tc26_gost_3410_2012_512_paramSetC OBJ_id_tc26_gost_3410_2012_512_constants,3L + +#define SN_id_tc26_digest_constants "id-tc26-digest-constants" +#define NID_id_tc26_digest_constants 1000 +#define OBJ_id_tc26_digest_constants OBJ_id_tc26_constants,2L + +#define SN_id_tc26_cipher_constants "id-tc26-cipher-constants" +#define NID_id_tc26_cipher_constants 1001 +#define OBJ_id_tc26_cipher_constants OBJ_id_tc26_constants,5L + +#define SN_id_tc26_gost_28147_constants "id-tc26-gost-28147-constants" +#define NID_id_tc26_gost_28147_constants 1002 +#define OBJ_id_tc26_gost_28147_constants OBJ_id_tc26_cipher_constants,1L + +#define SN_id_tc26_gost_28147_param_Z "id-tc26-gost-28147-param-Z" +#define LN_id_tc26_gost_28147_param_Z "GOST 28147-89 TC26 parameter set" +#define NID_id_tc26_gost_28147_param_Z 1003 +#define OBJ_id_tc26_gost_28147_param_Z OBJ_id_tc26_gost_28147_constants,1L + +#define SN_INN "INN" +#define LN_INN "INN" +#define NID_INN 1004 +#define OBJ_INN OBJ_member_body,643L,3L,131L,1L,1L + +#define SN_OGRN "OGRN" +#define LN_OGRN "OGRN" +#define NID_OGRN 1005 +#define OBJ_OGRN OBJ_member_body,643L,100L,1L + +#define SN_SNILS "SNILS" +#define LN_SNILS "SNILS" +#define NID_SNILS 1006 +#define OBJ_SNILS OBJ_member_body,643L,100L,3L + +#define SN_OGRNIP "OGRNIP" +#define LN_OGRNIP "OGRNIP" +#define NID_OGRNIP 1226 +#define OBJ_OGRNIP OBJ_member_body,643L,100L,5L + +#define SN_subjectSignTool "subjectSignTool" +#define LN_subjectSignTool "Signing Tool of Subject" +#define NID_subjectSignTool 1007 +#define OBJ_subjectSignTool OBJ_member_body,643L,100L,111L + +#define SN_issuerSignTool "issuerSignTool" +#define LN_issuerSignTool "Signing Tool of Issuer" +#define NID_issuerSignTool 1008 +#define OBJ_issuerSignTool OBJ_member_body,643L,100L,112L + +#define SN_classSignTool "classSignTool" +#define LN_classSignTool "Class of Signing Tool" +#define NID_classSignTool 1227 +#define OBJ_classSignTool OBJ_member_body,643L,100L,113L + +#define SN_classSignToolKC1 "classSignToolKC1" +#define LN_classSignToolKC1 "Class of Signing Tool KC1" +#define NID_classSignToolKC1 1228 +#define OBJ_classSignToolKC1 OBJ_member_body,643L,100L,113L,1L + +#define SN_classSignToolKC2 "classSignToolKC2" +#define LN_classSignToolKC2 "Class of Signing Tool KC2" +#define NID_classSignToolKC2 1229 +#define OBJ_classSignToolKC2 OBJ_member_body,643L,100L,113L,2L + +#define SN_classSignToolKC3 "classSignToolKC3" +#define LN_classSignToolKC3 "Class of Signing Tool KC3" +#define NID_classSignToolKC3 1230 +#define OBJ_classSignToolKC3 OBJ_member_body,643L,100L,113L,3L + +#define SN_classSignToolKB1 "classSignToolKB1" +#define LN_classSignToolKB1 "Class of Signing Tool KB1" +#define NID_classSignToolKB1 1231 +#define OBJ_classSignToolKB1 OBJ_member_body,643L,100L,113L,4L + +#define SN_classSignToolKB2 "classSignToolKB2" +#define LN_classSignToolKB2 "Class of Signing Tool KB2" +#define NID_classSignToolKB2 1232 +#define OBJ_classSignToolKB2 OBJ_member_body,643L,100L,113L,5L + +#define SN_classSignToolKA1 "classSignToolKA1" +#define LN_classSignToolKA1 "Class of Signing Tool KA1" +#define NID_classSignToolKA1 1233 +#define OBJ_classSignToolKA1 OBJ_member_body,643L,100L,113L,6L + +#define SN_kuznyechik_ecb "kuznyechik-ecb" +#define NID_kuznyechik_ecb 1012 + +#define SN_kuznyechik_ctr "kuznyechik-ctr" +#define NID_kuznyechik_ctr 1013 + +#define SN_kuznyechik_ofb "kuznyechik-ofb" +#define NID_kuznyechik_ofb 1014 + +#define SN_kuznyechik_cbc "kuznyechik-cbc" +#define NID_kuznyechik_cbc 1015 + +#define SN_kuznyechik_cfb "kuznyechik-cfb" +#define NID_kuznyechik_cfb 1016 + +#define SN_kuznyechik_mac "kuznyechik-mac" +#define NID_kuznyechik_mac 1017 + +#define SN_magma_ecb "magma-ecb" +#define NID_magma_ecb 1187 + +#define SN_magma_ctr "magma-ctr" +#define NID_magma_ctr 1188 + +#define SN_magma_ofb "magma-ofb" +#define NID_magma_ofb 1189 + +#define SN_magma_cbc "magma-cbc" +#define NID_magma_cbc 1190 + +#define SN_magma_cfb "magma-cfb" +#define NID_magma_cfb 1191 + +#define SN_magma_mac "magma-mac" +#define NID_magma_mac 1192 + +#define SN_camellia_128_cbc "CAMELLIA-128-CBC" +#define LN_camellia_128_cbc "camellia-128-cbc" +#define NID_camellia_128_cbc 751 +#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L + +#define SN_camellia_192_cbc "CAMELLIA-192-CBC" +#define LN_camellia_192_cbc "camellia-192-cbc" +#define NID_camellia_192_cbc 752 +#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L + +#define SN_camellia_256_cbc "CAMELLIA-256-CBC" +#define LN_camellia_256_cbc "camellia-256-cbc" +#define NID_camellia_256_cbc 753 +#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L + +#define SN_id_camellia128_wrap "id-camellia128-wrap" +#define NID_id_camellia128_wrap 907 +#define OBJ_id_camellia128_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,2L + +#define SN_id_camellia192_wrap "id-camellia192-wrap" +#define NID_id_camellia192_wrap 908 +#define OBJ_id_camellia192_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,3L + +#define SN_id_camellia256_wrap "id-camellia256-wrap" +#define NID_id_camellia256_wrap 909 +#define OBJ_id_camellia256_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,4L + +#define OBJ_ntt_ds 0L,3L,4401L,5L + +#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L + +#define SN_camellia_128_ecb "CAMELLIA-128-ECB" +#define LN_camellia_128_ecb "camellia-128-ecb" +#define NID_camellia_128_ecb 754 +#define OBJ_camellia_128_ecb OBJ_camellia,1L + +#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB" +#define LN_camellia_128_ofb128 "camellia-128-ofb" +#define NID_camellia_128_ofb128 766 +#define OBJ_camellia_128_ofb128 OBJ_camellia,3L + +#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB" +#define LN_camellia_128_cfb128 "camellia-128-cfb" +#define NID_camellia_128_cfb128 757 +#define OBJ_camellia_128_cfb128 OBJ_camellia,4L + +#define SN_camellia_128_gcm "CAMELLIA-128-GCM" +#define LN_camellia_128_gcm "camellia-128-gcm" +#define NID_camellia_128_gcm 961 +#define OBJ_camellia_128_gcm OBJ_camellia,6L + +#define SN_camellia_128_ccm "CAMELLIA-128-CCM" +#define LN_camellia_128_ccm "camellia-128-ccm" +#define NID_camellia_128_ccm 962 +#define OBJ_camellia_128_ccm OBJ_camellia,7L + +#define SN_camellia_128_ctr "CAMELLIA-128-CTR" +#define LN_camellia_128_ctr "camellia-128-ctr" +#define NID_camellia_128_ctr 963 +#define OBJ_camellia_128_ctr OBJ_camellia,9L + +#define SN_camellia_128_cmac "CAMELLIA-128-CMAC" +#define LN_camellia_128_cmac "camellia-128-cmac" +#define NID_camellia_128_cmac 964 +#define OBJ_camellia_128_cmac OBJ_camellia,10L + +#define SN_camellia_192_ecb "CAMELLIA-192-ECB" +#define LN_camellia_192_ecb "camellia-192-ecb" +#define NID_camellia_192_ecb 755 +#define OBJ_camellia_192_ecb OBJ_camellia,21L + +#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB" +#define LN_camellia_192_ofb128 "camellia-192-ofb" +#define NID_camellia_192_ofb128 767 +#define OBJ_camellia_192_ofb128 OBJ_camellia,23L + +#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB" +#define LN_camellia_192_cfb128 "camellia-192-cfb" +#define NID_camellia_192_cfb128 758 +#define OBJ_camellia_192_cfb128 OBJ_camellia,24L + +#define SN_camellia_192_gcm "CAMELLIA-192-GCM" +#define LN_camellia_192_gcm "camellia-192-gcm" +#define NID_camellia_192_gcm 965 +#define OBJ_camellia_192_gcm OBJ_camellia,26L + +#define SN_camellia_192_ccm "CAMELLIA-192-CCM" +#define LN_camellia_192_ccm "camellia-192-ccm" +#define NID_camellia_192_ccm 966 +#define OBJ_camellia_192_ccm OBJ_camellia,27L + +#define SN_camellia_192_ctr "CAMELLIA-192-CTR" +#define LN_camellia_192_ctr "camellia-192-ctr" +#define NID_camellia_192_ctr 967 +#define OBJ_camellia_192_ctr OBJ_camellia,29L + +#define SN_camellia_192_cmac "CAMELLIA-192-CMAC" +#define LN_camellia_192_cmac "camellia-192-cmac" +#define NID_camellia_192_cmac 968 +#define OBJ_camellia_192_cmac OBJ_camellia,30L + +#define SN_camellia_256_ecb "CAMELLIA-256-ECB" +#define LN_camellia_256_ecb "camellia-256-ecb" +#define NID_camellia_256_ecb 756 +#define OBJ_camellia_256_ecb OBJ_camellia,41L + +#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB" +#define LN_camellia_256_ofb128 "camellia-256-ofb" +#define NID_camellia_256_ofb128 768 +#define OBJ_camellia_256_ofb128 OBJ_camellia,43L + +#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB" +#define LN_camellia_256_cfb128 "camellia-256-cfb" +#define NID_camellia_256_cfb128 759 +#define OBJ_camellia_256_cfb128 OBJ_camellia,44L + +#define SN_camellia_256_gcm "CAMELLIA-256-GCM" +#define LN_camellia_256_gcm "camellia-256-gcm" +#define NID_camellia_256_gcm 969 +#define OBJ_camellia_256_gcm OBJ_camellia,46L + +#define SN_camellia_256_ccm "CAMELLIA-256-CCM" +#define LN_camellia_256_ccm "camellia-256-ccm" +#define NID_camellia_256_ccm 970 +#define OBJ_camellia_256_ccm OBJ_camellia,47L + +#define SN_camellia_256_ctr "CAMELLIA-256-CTR" +#define LN_camellia_256_ctr "camellia-256-ctr" +#define NID_camellia_256_ctr 971 +#define OBJ_camellia_256_ctr OBJ_camellia,49L + +#define SN_camellia_256_cmac "CAMELLIA-256-CMAC" +#define LN_camellia_256_cmac "camellia-256-cmac" +#define NID_camellia_256_cmac 972 +#define OBJ_camellia_256_cmac OBJ_camellia,50L + +#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1" +#define LN_camellia_128_cfb1 "camellia-128-cfb1" +#define NID_camellia_128_cfb1 760 + +#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1" +#define LN_camellia_192_cfb1 "camellia-192-cfb1" +#define NID_camellia_192_cfb1 761 + +#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1" +#define LN_camellia_256_cfb1 "camellia-256-cfb1" +#define NID_camellia_256_cfb1 762 + +#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8" +#define LN_camellia_128_cfb8 "camellia-128-cfb8" +#define NID_camellia_128_cfb8 763 + +#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8" +#define LN_camellia_192_cfb8 "camellia-192-cfb8" +#define NID_camellia_192_cfb8 764 + +#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8" +#define LN_camellia_256_cfb8 "camellia-256-cfb8" +#define NID_camellia_256_cfb8 765 + +#define OBJ_aria 1L,2L,410L,200046L,1L,1L + +#define SN_aria_128_ecb "ARIA-128-ECB" +#define LN_aria_128_ecb "aria-128-ecb" +#define NID_aria_128_ecb 1065 +#define OBJ_aria_128_ecb OBJ_aria,1L + +#define SN_aria_128_cbc "ARIA-128-CBC" +#define LN_aria_128_cbc "aria-128-cbc" +#define NID_aria_128_cbc 1066 +#define OBJ_aria_128_cbc OBJ_aria,2L + +#define SN_aria_128_cfb128 "ARIA-128-CFB" +#define LN_aria_128_cfb128 "aria-128-cfb" +#define NID_aria_128_cfb128 1067 +#define OBJ_aria_128_cfb128 OBJ_aria,3L + +#define SN_aria_128_ofb128 "ARIA-128-OFB" +#define LN_aria_128_ofb128 "aria-128-ofb" +#define NID_aria_128_ofb128 1068 +#define OBJ_aria_128_ofb128 OBJ_aria,4L + +#define SN_aria_128_ctr "ARIA-128-CTR" +#define LN_aria_128_ctr "aria-128-ctr" +#define NID_aria_128_ctr 1069 +#define OBJ_aria_128_ctr OBJ_aria,5L + +#define SN_aria_192_ecb "ARIA-192-ECB" +#define LN_aria_192_ecb "aria-192-ecb" +#define NID_aria_192_ecb 1070 +#define OBJ_aria_192_ecb OBJ_aria,6L + +#define SN_aria_192_cbc "ARIA-192-CBC" +#define LN_aria_192_cbc "aria-192-cbc" +#define NID_aria_192_cbc 1071 +#define OBJ_aria_192_cbc OBJ_aria,7L + +#define SN_aria_192_cfb128 "ARIA-192-CFB" +#define LN_aria_192_cfb128 "aria-192-cfb" +#define NID_aria_192_cfb128 1072 +#define OBJ_aria_192_cfb128 OBJ_aria,8L + +#define SN_aria_192_ofb128 "ARIA-192-OFB" +#define LN_aria_192_ofb128 "aria-192-ofb" +#define NID_aria_192_ofb128 1073 +#define OBJ_aria_192_ofb128 OBJ_aria,9L + +#define SN_aria_192_ctr "ARIA-192-CTR" +#define LN_aria_192_ctr "aria-192-ctr" +#define NID_aria_192_ctr 1074 +#define OBJ_aria_192_ctr OBJ_aria,10L + +#define SN_aria_256_ecb "ARIA-256-ECB" +#define LN_aria_256_ecb "aria-256-ecb" +#define NID_aria_256_ecb 1075 +#define OBJ_aria_256_ecb OBJ_aria,11L + +#define SN_aria_256_cbc "ARIA-256-CBC" +#define LN_aria_256_cbc "aria-256-cbc" +#define NID_aria_256_cbc 1076 +#define OBJ_aria_256_cbc OBJ_aria,12L + +#define SN_aria_256_cfb128 "ARIA-256-CFB" +#define LN_aria_256_cfb128 "aria-256-cfb" +#define NID_aria_256_cfb128 1077 +#define OBJ_aria_256_cfb128 OBJ_aria,13L + +#define SN_aria_256_ofb128 "ARIA-256-OFB" +#define LN_aria_256_ofb128 "aria-256-ofb" +#define NID_aria_256_ofb128 1078 +#define OBJ_aria_256_ofb128 OBJ_aria,14L + +#define SN_aria_256_ctr "ARIA-256-CTR" +#define LN_aria_256_ctr "aria-256-ctr" +#define NID_aria_256_ctr 1079 +#define OBJ_aria_256_ctr OBJ_aria,15L + +#define SN_aria_128_cfb1 "ARIA-128-CFB1" +#define LN_aria_128_cfb1 "aria-128-cfb1" +#define NID_aria_128_cfb1 1080 + +#define SN_aria_192_cfb1 "ARIA-192-CFB1" +#define LN_aria_192_cfb1 "aria-192-cfb1" +#define NID_aria_192_cfb1 1081 + +#define SN_aria_256_cfb1 "ARIA-256-CFB1" +#define LN_aria_256_cfb1 "aria-256-cfb1" +#define NID_aria_256_cfb1 1082 + +#define SN_aria_128_cfb8 "ARIA-128-CFB8" +#define LN_aria_128_cfb8 "aria-128-cfb8" +#define NID_aria_128_cfb8 1083 + +#define SN_aria_192_cfb8 "ARIA-192-CFB8" +#define LN_aria_192_cfb8 "aria-192-cfb8" +#define NID_aria_192_cfb8 1084 + +#define SN_aria_256_cfb8 "ARIA-256-CFB8" +#define LN_aria_256_cfb8 "aria-256-cfb8" +#define NID_aria_256_cfb8 1085 + +#define SN_aria_128_ccm "ARIA-128-CCM" +#define LN_aria_128_ccm "aria-128-ccm" +#define NID_aria_128_ccm 1120 +#define OBJ_aria_128_ccm OBJ_aria,37L + +#define SN_aria_192_ccm "ARIA-192-CCM" +#define LN_aria_192_ccm "aria-192-ccm" +#define NID_aria_192_ccm 1121 +#define OBJ_aria_192_ccm OBJ_aria,38L + +#define SN_aria_256_ccm "ARIA-256-CCM" +#define LN_aria_256_ccm "aria-256-ccm" +#define NID_aria_256_ccm 1122 +#define OBJ_aria_256_ccm OBJ_aria,39L + +#define SN_aria_128_gcm "ARIA-128-GCM" +#define LN_aria_128_gcm "aria-128-gcm" +#define NID_aria_128_gcm 1123 +#define OBJ_aria_128_gcm OBJ_aria,34L + +#define SN_aria_192_gcm "ARIA-192-GCM" +#define LN_aria_192_gcm "aria-192-gcm" +#define NID_aria_192_gcm 1124 +#define OBJ_aria_192_gcm OBJ_aria,35L + +#define SN_aria_256_gcm "ARIA-256-GCM" +#define LN_aria_256_gcm "aria-256-gcm" +#define NID_aria_256_gcm 1125 +#define OBJ_aria_256_gcm OBJ_aria,36L + +#define SN_kisa "KISA" +#define LN_kisa "kisa" +#define NID_kisa 773 +#define OBJ_kisa OBJ_member_body,410L,200004L + +#define SN_seed_ecb "SEED-ECB" +#define LN_seed_ecb "seed-ecb" +#define NID_seed_ecb 776 +#define OBJ_seed_ecb OBJ_kisa,1L,3L + +#define SN_seed_cbc "SEED-CBC" +#define LN_seed_cbc "seed-cbc" +#define NID_seed_cbc 777 +#define OBJ_seed_cbc OBJ_kisa,1L,4L + +#define SN_seed_cfb128 "SEED-CFB" +#define LN_seed_cfb128 "seed-cfb" +#define NID_seed_cfb128 779 +#define OBJ_seed_cfb128 OBJ_kisa,1L,5L + +#define SN_seed_ofb128 "SEED-OFB" +#define LN_seed_ofb128 "seed-ofb" +#define NID_seed_ofb128 778 +#define OBJ_seed_ofb128 OBJ_kisa,1L,6L + +#define SN_sm4_ecb "SM4-ECB" +#define LN_sm4_ecb "sm4-ecb" +#define NID_sm4_ecb 1133 +#define OBJ_sm4_ecb OBJ_sm_scheme,104L,1L + +#define SN_sm4_cbc "SM4-CBC" +#define LN_sm4_cbc "sm4-cbc" +#define NID_sm4_cbc 1134 +#define OBJ_sm4_cbc OBJ_sm_scheme,104L,2L + +#define SN_sm4_ofb128 "SM4-OFB" +#define LN_sm4_ofb128 "sm4-ofb" +#define NID_sm4_ofb128 1135 +#define OBJ_sm4_ofb128 OBJ_sm_scheme,104L,3L + +#define SN_sm4_cfb128 "SM4-CFB" +#define LN_sm4_cfb128 "sm4-cfb" +#define NID_sm4_cfb128 1137 +#define OBJ_sm4_cfb128 OBJ_sm_scheme,104L,4L + +#define SN_sm4_cfb1 "SM4-CFB1" +#define LN_sm4_cfb1 "sm4-cfb1" +#define NID_sm4_cfb1 1136 +#define OBJ_sm4_cfb1 OBJ_sm_scheme,104L,5L + +#define SN_sm4_cfb8 "SM4-CFB8" +#define LN_sm4_cfb8 "sm4-cfb8" +#define NID_sm4_cfb8 1138 +#define OBJ_sm4_cfb8 OBJ_sm_scheme,104L,6L + +#define SN_sm4_ctr "SM4-CTR" +#define LN_sm4_ctr "sm4-ctr" +#define NID_sm4_ctr 1139 +#define OBJ_sm4_ctr OBJ_sm_scheme,104L,7L + +#define SN_sm4_gcm "SM4-GCM" +#define LN_sm4_gcm "sm4-gcm" +#define NID_sm4_gcm 1248 +#define OBJ_sm4_gcm OBJ_sm_scheme,104L,8L + +#define SN_sm4_ccm "SM4-CCM" +#define LN_sm4_ccm "sm4-ccm" +#define NID_sm4_ccm 1249 +#define OBJ_sm4_ccm OBJ_sm_scheme,104L,9L + +#define SN_sm4_xts "SM4-XTS" +#define LN_sm4_xts "sm4-xts" +#define NID_sm4_xts 1290 +#define OBJ_sm4_xts OBJ_sm_scheme,104L,10L + +#define SN_hmac "HMAC" +#define LN_hmac "hmac" +#define NID_hmac 855 + +#define SN_cmac "CMAC" +#define LN_cmac "cmac" +#define NID_cmac 894 + +#define SN_rc4_hmac_md5 "RC4-HMAC-MD5" +#define LN_rc4_hmac_md5 "rc4-hmac-md5" +#define NID_rc4_hmac_md5 915 + +#define SN_aes_128_cbc_hmac_sha1 "AES-128-CBC-HMAC-SHA1" +#define LN_aes_128_cbc_hmac_sha1 "aes-128-cbc-hmac-sha1" +#define NID_aes_128_cbc_hmac_sha1 916 + +#define SN_aes_192_cbc_hmac_sha1 "AES-192-CBC-HMAC-SHA1" +#define LN_aes_192_cbc_hmac_sha1 "aes-192-cbc-hmac-sha1" +#define NID_aes_192_cbc_hmac_sha1 917 + +#define SN_aes_256_cbc_hmac_sha1 "AES-256-CBC-HMAC-SHA1" +#define LN_aes_256_cbc_hmac_sha1 "aes-256-cbc-hmac-sha1" +#define NID_aes_256_cbc_hmac_sha1 918 + +#define SN_aes_128_cbc_hmac_sha256 "AES-128-CBC-HMAC-SHA256" +#define LN_aes_128_cbc_hmac_sha256 "aes-128-cbc-hmac-sha256" +#define NID_aes_128_cbc_hmac_sha256 948 + +#define SN_aes_192_cbc_hmac_sha256 "AES-192-CBC-HMAC-SHA256" +#define LN_aes_192_cbc_hmac_sha256 "aes-192-cbc-hmac-sha256" +#define NID_aes_192_cbc_hmac_sha256 949 + +#define SN_aes_256_cbc_hmac_sha256 "AES-256-CBC-HMAC-SHA256" +#define LN_aes_256_cbc_hmac_sha256 "aes-256-cbc-hmac-sha256" +#define NID_aes_256_cbc_hmac_sha256 950 + +#define SN_chacha20_poly1305 "ChaCha20-Poly1305" +#define LN_chacha20_poly1305 "chacha20-poly1305" +#define NID_chacha20_poly1305 1018 + +#define SN_chacha20 "ChaCha20" +#define LN_chacha20 "chacha20" +#define NID_chacha20 1019 + +#define SN_dhpublicnumber "dhpublicnumber" +#define LN_dhpublicnumber "X9.42 DH" +#define NID_dhpublicnumber 920 +#define OBJ_dhpublicnumber OBJ_ISO_US,10046L,2L,1L + +#define SN_brainpoolP160r1 "brainpoolP160r1" +#define NID_brainpoolP160r1 921 +#define OBJ_brainpoolP160r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,1L + +#define SN_brainpoolP160t1 "brainpoolP160t1" +#define NID_brainpoolP160t1 922 +#define OBJ_brainpoolP160t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,2L + +#define SN_brainpoolP192r1 "brainpoolP192r1" +#define NID_brainpoolP192r1 923 +#define OBJ_brainpoolP192r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,3L + +#define SN_brainpoolP192t1 "brainpoolP192t1" +#define NID_brainpoolP192t1 924 +#define OBJ_brainpoolP192t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,4L + +#define SN_brainpoolP224r1 "brainpoolP224r1" +#define NID_brainpoolP224r1 925 +#define OBJ_brainpoolP224r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,5L + +#define SN_brainpoolP224t1 "brainpoolP224t1" +#define NID_brainpoolP224t1 926 +#define OBJ_brainpoolP224t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,6L + +#define SN_brainpoolP256r1 "brainpoolP256r1" +#define NID_brainpoolP256r1 927 +#define OBJ_brainpoolP256r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,7L + +#define SN_brainpoolP256r1tls13 "brainpoolP256r1tls13" +#define NID_brainpoolP256r1tls13 1285 + +#define SN_brainpoolP256t1 "brainpoolP256t1" +#define NID_brainpoolP256t1 928 +#define OBJ_brainpoolP256t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,8L + +#define SN_brainpoolP320r1 "brainpoolP320r1" +#define NID_brainpoolP320r1 929 +#define OBJ_brainpoolP320r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,9L + +#define SN_brainpoolP320t1 "brainpoolP320t1" +#define NID_brainpoolP320t1 930 +#define OBJ_brainpoolP320t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,10L + +#define SN_brainpoolP384r1 "brainpoolP384r1" +#define NID_brainpoolP384r1 931 +#define OBJ_brainpoolP384r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,11L + +#define SN_brainpoolP384r1tls13 "brainpoolP384r1tls13" +#define NID_brainpoolP384r1tls13 1286 + +#define SN_brainpoolP384t1 "brainpoolP384t1" +#define NID_brainpoolP384t1 932 +#define OBJ_brainpoolP384t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,12L + +#define SN_brainpoolP512r1 "brainpoolP512r1" +#define NID_brainpoolP512r1 933 +#define OBJ_brainpoolP512r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,13L + +#define SN_brainpoolP512r1tls13 "brainpoolP512r1tls13" +#define NID_brainpoolP512r1tls13 1287 + +#define SN_brainpoolP512t1 "brainpoolP512t1" +#define NID_brainpoolP512t1 934 +#define OBJ_brainpoolP512t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,14L + +#define OBJ_x9_63_scheme 1L,3L,133L,16L,840L,63L,0L + +#define OBJ_secg_scheme OBJ_certicom_arc,1L + +#define SN_dhSinglePass_stdDH_sha1kdf_scheme "dhSinglePass-stdDH-sha1kdf-scheme" +#define NID_dhSinglePass_stdDH_sha1kdf_scheme 936 +#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme OBJ_x9_63_scheme,2L + +#define SN_dhSinglePass_stdDH_sha224kdf_scheme "dhSinglePass-stdDH-sha224kdf-scheme" +#define NID_dhSinglePass_stdDH_sha224kdf_scheme 937 +#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme OBJ_secg_scheme,11L,0L + +#define SN_dhSinglePass_stdDH_sha256kdf_scheme "dhSinglePass-stdDH-sha256kdf-scheme" +#define NID_dhSinglePass_stdDH_sha256kdf_scheme 938 +#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme OBJ_secg_scheme,11L,1L + +#define SN_dhSinglePass_stdDH_sha384kdf_scheme "dhSinglePass-stdDH-sha384kdf-scheme" +#define NID_dhSinglePass_stdDH_sha384kdf_scheme 939 +#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme OBJ_secg_scheme,11L,2L + +#define SN_dhSinglePass_stdDH_sha512kdf_scheme "dhSinglePass-stdDH-sha512kdf-scheme" +#define NID_dhSinglePass_stdDH_sha512kdf_scheme 940 +#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme OBJ_secg_scheme,11L,3L + +#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme "dhSinglePass-cofactorDH-sha1kdf-scheme" +#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme 941 +#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme OBJ_x9_63_scheme,3L + +#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme "dhSinglePass-cofactorDH-sha224kdf-scheme" +#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme 942 +#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme OBJ_secg_scheme,14L,0L + +#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme "dhSinglePass-cofactorDH-sha256kdf-scheme" +#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme 943 +#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme OBJ_secg_scheme,14L,1L + +#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme "dhSinglePass-cofactorDH-sha384kdf-scheme" +#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme 944 +#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme OBJ_secg_scheme,14L,2L + +#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme "dhSinglePass-cofactorDH-sha512kdf-scheme" +#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme 945 +#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme OBJ_secg_scheme,14L,3L + +#define SN_dh_std_kdf "dh-std-kdf" +#define NID_dh_std_kdf 946 + +#define SN_dh_cofactor_kdf "dh-cofactor-kdf" +#define NID_dh_cofactor_kdf 947 + +#define SN_ct_precert_scts "ct_precert_scts" +#define LN_ct_precert_scts "CT Precertificate SCTs" +#define NID_ct_precert_scts 951 +#define OBJ_ct_precert_scts 1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L + +#define SN_ct_precert_poison "ct_precert_poison" +#define LN_ct_precert_poison "CT Precertificate Poison" +#define NID_ct_precert_poison 952 +#define OBJ_ct_precert_poison 1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L + +#define SN_ct_precert_signer "ct_precert_signer" +#define LN_ct_precert_signer "CT Precertificate Signer" +#define NID_ct_precert_signer 953 +#define OBJ_ct_precert_signer 1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L + +#define SN_ct_cert_scts "ct_cert_scts" +#define LN_ct_cert_scts "CT Certificate SCTs" +#define NID_ct_cert_scts 954 +#define OBJ_ct_cert_scts 1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L + +#define SN_jurisdictionLocalityName "jurisdictionL" +#define LN_jurisdictionLocalityName "jurisdictionLocalityName" +#define NID_jurisdictionLocalityName 955 +#define OBJ_jurisdictionLocalityName OBJ_ms_corp,60L,2L,1L,1L + +#define SN_jurisdictionStateOrProvinceName "jurisdictionST" +#define LN_jurisdictionStateOrProvinceName "jurisdictionStateOrProvinceName" +#define NID_jurisdictionStateOrProvinceName 956 +#define OBJ_jurisdictionStateOrProvinceName OBJ_ms_corp,60L,2L,1L,2L + +#define SN_jurisdictionCountryName "jurisdictionC" +#define LN_jurisdictionCountryName "jurisdictionCountryName" +#define NID_jurisdictionCountryName 957 +#define OBJ_jurisdictionCountryName OBJ_ms_corp,60L,2L,1L,3L + +#define SN_id_scrypt "id-scrypt" +#define LN_id_scrypt "scrypt" +#define NID_id_scrypt 973 +#define OBJ_id_scrypt 1L,3L,6L,1L,4L,1L,11591L,4L,11L + +#define SN_tls1_prf "TLS1-PRF" +#define LN_tls1_prf "tls1-prf" +#define NID_tls1_prf 1021 + +#define SN_hkdf "HKDF" +#define LN_hkdf "hkdf" +#define NID_hkdf 1036 + +#define SN_sshkdf "SSHKDF" +#define LN_sshkdf "sshkdf" +#define NID_sshkdf 1203 + +#define SN_sskdf "SSKDF" +#define LN_sskdf "sskdf" +#define NID_sskdf 1205 + +#define SN_x942kdf "X942KDF" +#define LN_x942kdf "x942kdf" +#define NID_x942kdf 1207 + +#define SN_x963kdf "X963KDF" +#define LN_x963kdf "x963kdf" +#define NID_x963kdf 1206 + +#define SN_id_pkinit "id-pkinit" +#define NID_id_pkinit 1031 +#define OBJ_id_pkinit 1L,3L,6L,1L,5L,2L,3L + +#define SN_pkInitClientAuth "pkInitClientAuth" +#define LN_pkInitClientAuth "PKINIT Client Auth" +#define NID_pkInitClientAuth 1032 +#define OBJ_pkInitClientAuth OBJ_id_pkinit,4L + +#define SN_pkInitKDC "pkInitKDC" +#define LN_pkInitKDC "Signing KDC Response" +#define NID_pkInitKDC 1033 +#define OBJ_pkInitKDC OBJ_id_pkinit,5L + +#define SN_X25519 "X25519" +#define NID_X25519 1034 +#define OBJ_X25519 1L,3L,101L,110L + +#define SN_X448 "X448" +#define NID_X448 1035 +#define OBJ_X448 1L,3L,101L,111L + +#define SN_ED25519 "ED25519" +#define NID_ED25519 1087 +#define OBJ_ED25519 1L,3L,101L,112L + +#define SN_ED448 "ED448" +#define NID_ED448 1088 +#define OBJ_ED448 1L,3L,101L,113L + +#define SN_kx_rsa "KxRSA" +#define LN_kx_rsa "kx-rsa" +#define NID_kx_rsa 1037 + +#define SN_kx_ecdhe "KxECDHE" +#define LN_kx_ecdhe "kx-ecdhe" +#define NID_kx_ecdhe 1038 + +#define SN_kx_dhe "KxDHE" +#define LN_kx_dhe "kx-dhe" +#define NID_kx_dhe 1039 + +#define SN_kx_ecdhe_psk "KxECDHE-PSK" +#define LN_kx_ecdhe_psk "kx-ecdhe-psk" +#define NID_kx_ecdhe_psk 1040 + +#define SN_kx_dhe_psk "KxDHE-PSK" +#define LN_kx_dhe_psk "kx-dhe-psk" +#define NID_kx_dhe_psk 1041 + +#define SN_kx_rsa_psk "KxRSA_PSK" +#define LN_kx_rsa_psk "kx-rsa-psk" +#define NID_kx_rsa_psk 1042 + +#define SN_kx_psk "KxPSK" +#define LN_kx_psk "kx-psk" +#define NID_kx_psk 1043 + +#define SN_kx_srp "KxSRP" +#define LN_kx_srp "kx-srp" +#define NID_kx_srp 1044 + +#define SN_kx_gost "KxGOST" +#define LN_kx_gost "kx-gost" +#define NID_kx_gost 1045 + +#define SN_kx_gost18 "KxGOST18" +#define LN_kx_gost18 "kx-gost18" +#define NID_kx_gost18 1218 + +#define SN_kx_any "KxANY" +#define LN_kx_any "kx-any" +#define NID_kx_any 1063 + +#define SN_auth_rsa "AuthRSA" +#define LN_auth_rsa "auth-rsa" +#define NID_auth_rsa 1046 + +#define SN_auth_ecdsa "AuthECDSA" +#define LN_auth_ecdsa "auth-ecdsa" +#define NID_auth_ecdsa 1047 + +#define SN_auth_psk "AuthPSK" +#define LN_auth_psk "auth-psk" +#define NID_auth_psk 1048 + +#define SN_auth_dss "AuthDSS" +#define LN_auth_dss "auth-dss" +#define NID_auth_dss 1049 + +#define SN_auth_gost01 "AuthGOST01" +#define LN_auth_gost01 "auth-gost01" +#define NID_auth_gost01 1050 + +#define SN_auth_gost12 "AuthGOST12" +#define LN_auth_gost12 "auth-gost12" +#define NID_auth_gost12 1051 + +#define SN_auth_srp "AuthSRP" +#define LN_auth_srp "auth-srp" +#define NID_auth_srp 1052 + +#define SN_auth_null "AuthNULL" +#define LN_auth_null "auth-null" +#define NID_auth_null 1053 + +#define SN_auth_any "AuthANY" +#define LN_auth_any "auth-any" +#define NID_auth_any 1064 + +#define SN_poly1305 "Poly1305" +#define LN_poly1305 "poly1305" +#define NID_poly1305 1061 + +#define SN_siphash "SipHash" +#define LN_siphash "siphash" +#define NID_siphash 1062 + +#define SN_ffdhe2048 "ffdhe2048" +#define NID_ffdhe2048 1126 + +#define SN_ffdhe3072 "ffdhe3072" +#define NID_ffdhe3072 1127 + +#define SN_ffdhe4096 "ffdhe4096" +#define NID_ffdhe4096 1128 + +#define SN_ffdhe6144 "ffdhe6144" +#define NID_ffdhe6144 1129 + +#define SN_ffdhe8192 "ffdhe8192" +#define NID_ffdhe8192 1130 + +#define SN_modp_1536 "modp_1536" +#define NID_modp_1536 1212 + +#define SN_modp_2048 "modp_2048" +#define NID_modp_2048 1213 + +#define SN_modp_3072 "modp_3072" +#define NID_modp_3072 1214 + +#define SN_modp_4096 "modp_4096" +#define NID_modp_4096 1215 + +#define SN_modp_6144 "modp_6144" +#define NID_modp_6144 1216 + +#define SN_modp_8192 "modp_8192" +#define NID_modp_8192 1217 + +#define SN_ISO_UA "ISO-UA" +#define NID_ISO_UA 1150 +#define OBJ_ISO_UA OBJ_member_body,804L + +#define SN_ua_pki "ua-pki" +#define NID_ua_pki 1151 +#define OBJ_ua_pki OBJ_ISO_UA,2L,1L,1L,1L + +#define SN_dstu28147 "dstu28147" +#define LN_dstu28147 "DSTU Gost 28147-2009" +#define NID_dstu28147 1152 +#define OBJ_dstu28147 OBJ_ua_pki,1L,1L,1L + +#define SN_dstu28147_ofb "dstu28147-ofb" +#define LN_dstu28147_ofb "DSTU Gost 28147-2009 OFB mode" +#define NID_dstu28147_ofb 1153 +#define OBJ_dstu28147_ofb OBJ_dstu28147,2L + +#define SN_dstu28147_cfb "dstu28147-cfb" +#define LN_dstu28147_cfb "DSTU Gost 28147-2009 CFB mode" +#define NID_dstu28147_cfb 1154 +#define OBJ_dstu28147_cfb OBJ_dstu28147,3L + +#define SN_dstu28147_wrap "dstu28147-wrap" +#define LN_dstu28147_wrap "DSTU Gost 28147-2009 key wrap" +#define NID_dstu28147_wrap 1155 +#define OBJ_dstu28147_wrap OBJ_dstu28147,5L + +#define SN_hmacWithDstu34311 "hmacWithDstu34311" +#define LN_hmacWithDstu34311 "HMAC DSTU Gost 34311-95" +#define NID_hmacWithDstu34311 1156 +#define OBJ_hmacWithDstu34311 OBJ_ua_pki,1L,1L,2L + +#define SN_dstu34311 "dstu34311" +#define LN_dstu34311 "DSTU Gost 34311-95" +#define NID_dstu34311 1157 +#define OBJ_dstu34311 OBJ_ua_pki,1L,2L,1L + +#define SN_dstu4145le "dstu4145le" +#define LN_dstu4145le "DSTU 4145-2002 little endian" +#define NID_dstu4145le 1158 +#define OBJ_dstu4145le OBJ_ua_pki,1L,3L,1L,1L + +#define SN_dstu4145be "dstu4145be" +#define LN_dstu4145be "DSTU 4145-2002 big endian" +#define NID_dstu4145be 1159 +#define OBJ_dstu4145be OBJ_dstu4145le,1L,1L + +#define SN_uacurve0 "uacurve0" +#define LN_uacurve0 "DSTU curve 0" +#define NID_uacurve0 1160 +#define OBJ_uacurve0 OBJ_dstu4145le,2L,0L + +#define SN_uacurve1 "uacurve1" +#define LN_uacurve1 "DSTU curve 1" +#define NID_uacurve1 1161 +#define OBJ_uacurve1 OBJ_dstu4145le,2L,1L + +#define SN_uacurve2 "uacurve2" +#define LN_uacurve2 "DSTU curve 2" +#define NID_uacurve2 1162 +#define OBJ_uacurve2 OBJ_dstu4145le,2L,2L + +#define SN_uacurve3 "uacurve3" +#define LN_uacurve3 "DSTU curve 3" +#define NID_uacurve3 1163 +#define OBJ_uacurve3 OBJ_dstu4145le,2L,3L + +#define SN_uacurve4 "uacurve4" +#define LN_uacurve4 "DSTU curve 4" +#define NID_uacurve4 1164 +#define OBJ_uacurve4 OBJ_dstu4145le,2L,4L + +#define SN_uacurve5 "uacurve5" +#define LN_uacurve5 "DSTU curve 5" +#define NID_uacurve5 1165 +#define OBJ_uacurve5 OBJ_dstu4145le,2L,5L + +#define SN_uacurve6 "uacurve6" +#define LN_uacurve6 "DSTU curve 6" +#define NID_uacurve6 1166 +#define OBJ_uacurve6 OBJ_dstu4145le,2L,6L + +#define SN_uacurve7 "uacurve7" +#define LN_uacurve7 "DSTU curve 7" +#define NID_uacurve7 1167 +#define OBJ_uacurve7 OBJ_dstu4145le,2L,7L + +#define SN_uacurve8 "uacurve8" +#define LN_uacurve8 "DSTU curve 8" +#define NID_uacurve8 1168 +#define OBJ_uacurve8 OBJ_dstu4145le,2L,8L + +#define SN_uacurve9 "uacurve9" +#define LN_uacurve9 "DSTU curve 9" +#define NID_uacurve9 1169 +#define OBJ_uacurve9 OBJ_dstu4145le,2L,9L + +#define SN_aes_128_siv "AES-128-SIV" +#define LN_aes_128_siv "aes-128-siv" +#define NID_aes_128_siv 1198 + +#define SN_aes_192_siv "AES-192-SIV" +#define LN_aes_192_siv "aes-192-siv" +#define NID_aes_192_siv 1199 + +#define SN_aes_256_siv "AES-256-SIV" +#define LN_aes_256_siv "aes-256-siv" +#define NID_aes_256_siv 1200 + +#define SN_oracle "oracle-organization" +#define LN_oracle "Oracle organization" +#define NID_oracle 1282 +#define OBJ_oracle OBJ_joint_iso_itu_t,16L,840L,1L,113894L + +#define SN_oracle_jdk_trustedkeyusage "oracle-jdk-trustedkeyusage" +#define LN_oracle_jdk_trustedkeyusage "Trusted key usage (Oracle)" +#define NID_oracle_jdk_trustedkeyusage 1283 +#define OBJ_oracle_jdk_trustedkeyusage OBJ_oracle,746875L,1L,1L + +#define SN_brotli "brotli" +#define LN_brotli "Brotli compression" +#define NID_brotli 1288 + +#define SN_zstd "zstd" +#define LN_zstd "Zstandard compression" +#define NID_zstd 1289 + +#define SN_tcg "tcg" +#define LN_tcg "Trusted Computing Group" +#define NID_tcg 1324 +#define OBJ_tcg 2L,23L,133L + +#define SN_tcg_tcpaSpecVersion "tcg-tcpaSpecVersion" +#define NID_tcg_tcpaSpecVersion 1325 +#define OBJ_tcg_tcpaSpecVersion OBJ_tcg,1L + +#define SN_tcg_attribute "tcg-attribute" +#define LN_tcg_attribute "Trusted Computing Group Attributes" +#define NID_tcg_attribute 1326 +#define OBJ_tcg_attribute OBJ_tcg,2L + +#define SN_tcg_protocol "tcg-protocol" +#define LN_tcg_protocol "Trusted Computing Group Protocols" +#define NID_tcg_protocol 1327 +#define OBJ_tcg_protocol OBJ_tcg,3L + +#define SN_tcg_algorithm "tcg-algorithm" +#define LN_tcg_algorithm "Trusted Computing Group Algorithms" +#define NID_tcg_algorithm 1328 +#define OBJ_tcg_algorithm OBJ_tcg,4L + +#define SN_tcg_platformClass "tcg-platformClass" +#define LN_tcg_platformClass "Trusted Computing Group Platform Classes" +#define NID_tcg_platformClass 1329 +#define OBJ_tcg_platformClass OBJ_tcg,5L + +#define SN_tcg_ce "tcg-ce" +#define LN_tcg_ce "Trusted Computing Group Certificate Extensions" +#define NID_tcg_ce 1330 +#define OBJ_tcg_ce OBJ_tcg,6L + +#define SN_tcg_kp "tcg-kp" +#define LN_tcg_kp "Trusted Computing Group Key Purposes" +#define NID_tcg_kp 1331 +#define OBJ_tcg_kp OBJ_tcg,8L + +#define SN_tcg_ca "tcg-ca" +#define LN_tcg_ca "Trusted Computing Group Certificate Policies" +#define NID_tcg_ca 1332 +#define OBJ_tcg_ca OBJ_tcg,11L + +#define SN_tcg_address "tcg-address" +#define LN_tcg_address "Trusted Computing Group Address Formats" +#define NID_tcg_address 1333 +#define OBJ_tcg_address OBJ_tcg,17L + +#define SN_tcg_registry "tcg-registry" +#define LN_tcg_registry "Trusted Computing Group Registry" +#define NID_tcg_registry 1334 +#define OBJ_tcg_registry OBJ_tcg,18L + +#define SN_tcg_traits "tcg-traits" +#define LN_tcg_traits "Trusted Computing Group Traits" +#define NID_tcg_traits 1335 +#define OBJ_tcg_traits OBJ_tcg,19L + +#define SN_tcg_common "tcg-common" +#define LN_tcg_common "Trusted Computing Group Common" +#define NID_tcg_common 1336 +#define OBJ_tcg_common OBJ_tcg_platformClass,1L + +#define SN_tcg_at_platformManufacturerStr "tcg-at-platformManufacturerStr" +#define LN_tcg_at_platformManufacturerStr "TCG Platform Manufacturer String" +#define NID_tcg_at_platformManufacturerStr 1337 +#define OBJ_tcg_at_platformManufacturerStr OBJ_tcg_common,1L + +#define SN_tcg_at_platformManufacturerId "tcg-at-platformManufacturerId" +#define LN_tcg_at_platformManufacturerId "TCG Platform Manufacturer ID" +#define NID_tcg_at_platformManufacturerId 1338 +#define OBJ_tcg_at_platformManufacturerId OBJ_tcg_common,2L + +#define SN_tcg_at_platformConfigUri "tcg-at-platformConfigUri" +#define LN_tcg_at_platformConfigUri "TCG Platform Configuration URI" +#define NID_tcg_at_platformConfigUri 1339 +#define OBJ_tcg_at_platformConfigUri OBJ_tcg_common,3L + +#define SN_tcg_at_platformModel "tcg-at-platformModel" +#define LN_tcg_at_platformModel "TCG Platform Model" +#define NID_tcg_at_platformModel 1340 +#define OBJ_tcg_at_platformModel OBJ_tcg_common,4L + +#define SN_tcg_at_platformVersion "tcg-at-platformVersion" +#define LN_tcg_at_platformVersion "TCG Platform Version" +#define NID_tcg_at_platformVersion 1341 +#define OBJ_tcg_at_platformVersion OBJ_tcg_common,5L + +#define SN_tcg_at_platformSerial "tcg-at-platformSerial" +#define LN_tcg_at_platformSerial "TCG Platform Serial Number" +#define NID_tcg_at_platformSerial 1342 +#define OBJ_tcg_at_platformSerial OBJ_tcg_common,6L + +#define SN_tcg_at_platformConfiguration "tcg-at-platformConfiguration" +#define LN_tcg_at_platformConfiguration "TCG Platform Configuration" +#define NID_tcg_at_platformConfiguration 1343 +#define OBJ_tcg_at_platformConfiguration OBJ_tcg_common,7L + +#define SN_tcg_at_platformIdentifier "tcg-at-platformIdentifier" +#define LN_tcg_at_platformIdentifier "TCG Platform Identifier" +#define NID_tcg_at_platformIdentifier 1344 +#define OBJ_tcg_at_platformIdentifier OBJ_tcg_common,8L + +#define SN_tcg_at_tpmManufacturer "tcg-at-tpmManufacturer" +#define LN_tcg_at_tpmManufacturer "TPM Manufacturer" +#define NID_tcg_at_tpmManufacturer 1345 +#define OBJ_tcg_at_tpmManufacturer OBJ_tcg_attribute,1L + +#define SN_tcg_at_tpmModel "tcg-at-tpmModel" +#define LN_tcg_at_tpmModel "TPM Model" +#define NID_tcg_at_tpmModel 1346 +#define OBJ_tcg_at_tpmModel OBJ_tcg_attribute,2L + +#define SN_tcg_at_tpmVersion "tcg-at-tpmVersion" +#define LN_tcg_at_tpmVersion "TPM Version" +#define NID_tcg_at_tpmVersion 1347 +#define OBJ_tcg_at_tpmVersion OBJ_tcg_attribute,3L + +#define SN_tcg_at_securityQualities "tcg-at-securityQualities" +#define LN_tcg_at_securityQualities "Security Qualities" +#define NID_tcg_at_securityQualities 1348 +#define OBJ_tcg_at_securityQualities OBJ_tcg_attribute,10L + +#define SN_tcg_at_tpmProtectionProfile "tcg-at-tpmProtectionProfile" +#define LN_tcg_at_tpmProtectionProfile "TPM Protection Profile" +#define NID_tcg_at_tpmProtectionProfile 1349 +#define OBJ_tcg_at_tpmProtectionProfile OBJ_tcg_attribute,11L + +#define SN_tcg_at_tpmSecurityTarget "tcg-at-tpmSecurityTarget" +#define LN_tcg_at_tpmSecurityTarget "TPM Security Target" +#define NID_tcg_at_tpmSecurityTarget 1350 +#define OBJ_tcg_at_tpmSecurityTarget OBJ_tcg_attribute,12L + +#define SN_tcg_at_tbbProtectionProfile "tcg-at-tbbProtectionProfile" +#define LN_tcg_at_tbbProtectionProfile "TBB Protection Profile" +#define NID_tcg_at_tbbProtectionProfile 1351 +#define OBJ_tcg_at_tbbProtectionProfile OBJ_tcg_attribute,13L + +#define SN_tcg_at_tbbSecurityTarget "tcg-at-tbbSecurityTarget" +#define LN_tcg_at_tbbSecurityTarget "TBB Security Target" +#define NID_tcg_at_tbbSecurityTarget 1352 +#define OBJ_tcg_at_tbbSecurityTarget OBJ_tcg_attribute,14L + +#define SN_tcg_at_tpmIdLabel "tcg-at-tpmIdLabel" +#define LN_tcg_at_tpmIdLabel "TPM ID Label" +#define NID_tcg_at_tpmIdLabel 1353 +#define OBJ_tcg_at_tpmIdLabel OBJ_tcg_attribute,15L + +#define SN_tcg_at_tpmSpecification "tcg-at-tpmSpecification" +#define LN_tcg_at_tpmSpecification "TPM Specification" +#define NID_tcg_at_tpmSpecification 1354 +#define OBJ_tcg_at_tpmSpecification OBJ_tcg_attribute,16L + +#define SN_tcg_at_tcgPlatformSpecification "tcg-at-tcgPlatformSpecification" +#define LN_tcg_at_tcgPlatformSpecification "TPM Platform Specification" +#define NID_tcg_at_tcgPlatformSpecification 1355 +#define OBJ_tcg_at_tcgPlatformSpecification OBJ_tcg_attribute,17L + +#define SN_tcg_at_tpmSecurityAssertions "tcg-at-tpmSecurityAssertions" +#define LN_tcg_at_tpmSecurityAssertions "TPM Security Assertions" +#define NID_tcg_at_tpmSecurityAssertions 1356 +#define OBJ_tcg_at_tpmSecurityAssertions OBJ_tcg_attribute,18L + +#define SN_tcg_at_tbbSecurityAssertions "tcg-at-tbbSecurityAssertions" +#define LN_tcg_at_tbbSecurityAssertions "TBB Security Assertions" +#define NID_tcg_at_tbbSecurityAssertions 1357 +#define OBJ_tcg_at_tbbSecurityAssertions OBJ_tcg_attribute,19L + +#define SN_tcg_at_tcgCredentialSpecification "tcg-at-tcgCredentialSpecification" +#define LN_tcg_at_tcgCredentialSpecification "TCG Credential Specification" +#define NID_tcg_at_tcgCredentialSpecification 1358 +#define OBJ_tcg_at_tcgCredentialSpecification OBJ_tcg_attribute,23L + +#define SN_tcg_at_tcgCredentialType "tcg-at-tcgCredentialType" +#define LN_tcg_at_tcgCredentialType "TCG Credential Type" +#define NID_tcg_at_tcgCredentialType 1359 +#define OBJ_tcg_at_tcgCredentialType OBJ_tcg_attribute,25L + +#define SN_tcg_at_previousPlatformCertificates "tcg-at-previousPlatformCertificates" +#define LN_tcg_at_previousPlatformCertificates "TCG Previous Platform Certificates" +#define NID_tcg_at_previousPlatformCertificates 1360 +#define OBJ_tcg_at_previousPlatformCertificates OBJ_tcg_attribute,26L + +#define SN_tcg_at_tbbSecurityAssertions_v3 "tcg-at-tbbSecurityAssertions-v3" +#define LN_tcg_at_tbbSecurityAssertions_v3 "TCG TBB Security Assertions V3" +#define NID_tcg_at_tbbSecurityAssertions_v3 1361 +#define OBJ_tcg_at_tbbSecurityAssertions_v3 OBJ_tcg_attribute,27L + +#define SN_tcg_at_cryptographicAnchors "tcg-at-cryptographicAnchors" +#define LN_tcg_at_cryptographicAnchors "TCG Cryptographic Anchors" +#define NID_tcg_at_cryptographicAnchors 1362 +#define OBJ_tcg_at_cryptographicAnchors OBJ_tcg_attribute,28L + +#define SN_tcg_at_platformConfiguration_v1 "tcg-at-platformConfiguration-v1" +#define LN_tcg_at_platformConfiguration_v1 "Platform Configuration Version 1" +#define NID_tcg_at_platformConfiguration_v1 1363 +#define OBJ_tcg_at_platformConfiguration_v1 OBJ_tcg_at_platformConfiguration,1L + +#define SN_tcg_at_platformConfiguration_v2 "tcg-at-platformConfiguration-v2" +#define LN_tcg_at_platformConfiguration_v2 "Platform Configuration Version 2" +#define NID_tcg_at_platformConfiguration_v2 1364 +#define OBJ_tcg_at_platformConfiguration_v2 OBJ_tcg_at_platformConfiguration,2L + +#define SN_tcg_at_platformConfiguration_v3 "tcg-at-platformConfiguration-v3" +#define LN_tcg_at_platformConfiguration_v3 "Platform Configuration Version 3" +#define NID_tcg_at_platformConfiguration_v3 1365 +#define OBJ_tcg_at_platformConfiguration_v3 OBJ_tcg_at_platformConfiguration,3L + +#define SN_tcg_at_platformConfigUri_v3 "tcg-at-platformConfigUri-v3" +#define LN_tcg_at_platformConfigUri_v3 "Platform Configuration URI Version 3" +#define NID_tcg_at_platformConfigUri_v3 1366 +#define OBJ_tcg_at_platformConfigUri_v3 OBJ_tcg_at_platformConfiguration,4L + +#define SN_tcg_algorithm_null "tcg-algorithm-null" +#define LN_tcg_algorithm_null "TCG NULL Algorithm" +#define NID_tcg_algorithm_null 1367 +#define OBJ_tcg_algorithm_null OBJ_tcg_algorithm,1L + +#define SN_tcg_kp_EKCertificate "tcg-kp-EKCertificate" +#define LN_tcg_kp_EKCertificate "Endorsement Key Certificate" +#define NID_tcg_kp_EKCertificate 1368 +#define OBJ_tcg_kp_EKCertificate OBJ_tcg_kp,1L + +#define SN_tcg_kp_PlatformAttributeCertificate "tcg-kp-PlatformAttributeCertificate" +#define LN_tcg_kp_PlatformAttributeCertificate "Platform Attribute Certificate" +#define NID_tcg_kp_PlatformAttributeCertificate 1369 +#define OBJ_tcg_kp_PlatformAttributeCertificate OBJ_tcg_kp,2L + +#define SN_tcg_kp_AIKCertificate "tcg-kp-AIKCertificate" +#define LN_tcg_kp_AIKCertificate "Attestation Identity Key Certificate" +#define NID_tcg_kp_AIKCertificate 1370 +#define OBJ_tcg_kp_AIKCertificate OBJ_tcg_kp,3L + +#define SN_tcg_kp_PlatformKeyCertificate "tcg-kp-PlatformKeyCertificate" +#define LN_tcg_kp_PlatformKeyCertificate "Platform Key Certificate" +#define NID_tcg_kp_PlatformKeyCertificate 1371 +#define OBJ_tcg_kp_PlatformKeyCertificate OBJ_tcg_kp,4L + +#define SN_tcg_kp_DeltaPlatformAttributeCertificate "tcg-kp-DeltaPlatformAttributeCertificate" +#define LN_tcg_kp_DeltaPlatformAttributeCertificate "Delta Platform Attribute Certificate" +#define NID_tcg_kp_DeltaPlatformAttributeCertificate 1372 +#define OBJ_tcg_kp_DeltaPlatformAttributeCertificate OBJ_tcg_kp,5L + +#define SN_tcg_kp_DeltaPlatformKeyCertificate "tcg-kp-DeltaPlatformKeyCertificate" +#define LN_tcg_kp_DeltaPlatformKeyCertificate "Delta Platform Key Certificate" +#define NID_tcg_kp_DeltaPlatformKeyCertificate 1373 +#define OBJ_tcg_kp_DeltaPlatformKeyCertificate OBJ_tcg_kp,6L + +#define SN_tcg_kp_AdditionalPlatformAttributeCertificate "tcg-kp-AdditionalPlatformAttributeCertificate" +#define LN_tcg_kp_AdditionalPlatformAttributeCertificate "Additional Platform Attribute Certificate" +#define NID_tcg_kp_AdditionalPlatformAttributeCertificate 1374 +#define OBJ_tcg_kp_AdditionalPlatformAttributeCertificate OBJ_tcg_kp,7L + +#define SN_tcg_kp_AdditionalPlatformKeyCertificate "tcg-kp-AdditionalPlatformKeyCertificate" +#define LN_tcg_kp_AdditionalPlatformKeyCertificate "Additional Platform Key Certificate" +#define NID_tcg_kp_AdditionalPlatformKeyCertificate 1375 +#define OBJ_tcg_kp_AdditionalPlatformKeyCertificate OBJ_tcg_kp,8L + +#define SN_tcg_ce_relevantCredentials "tcg-ce-relevantCredentials" +#define LN_tcg_ce_relevantCredentials "Relevant Credentials" +#define NID_tcg_ce_relevantCredentials 1376 +#define OBJ_tcg_ce_relevantCredentials OBJ_tcg_ce,2L + +#define SN_tcg_ce_relevantManifests "tcg-ce-relevantManifests" +#define LN_tcg_ce_relevantManifests "Relevant Manifests" +#define NID_tcg_ce_relevantManifests 1377 +#define OBJ_tcg_ce_relevantManifests OBJ_tcg_ce,3L + +#define SN_tcg_ce_virtualPlatformAttestationService "tcg-ce-virtualPlatformAttestationService" +#define LN_tcg_ce_virtualPlatformAttestationService "Virtual Platform Attestation Service" +#define NID_tcg_ce_virtualPlatformAttestationService 1378 +#define OBJ_tcg_ce_virtualPlatformAttestationService OBJ_tcg_ce,4L + +#define SN_tcg_ce_migrationControllerAttestationService "tcg-ce-migrationControllerAttestationService" +#define LN_tcg_ce_migrationControllerAttestationService "Migration Controller Attestation Service" +#define NID_tcg_ce_migrationControllerAttestationService 1379 +#define OBJ_tcg_ce_migrationControllerAttestationService OBJ_tcg_ce,5L + +#define SN_tcg_ce_migrationControllerRegistrationService "tcg-ce-migrationControllerRegistrationService" +#define LN_tcg_ce_migrationControllerRegistrationService "Migration Controller Registration Service" +#define NID_tcg_ce_migrationControllerRegistrationService 1380 +#define OBJ_tcg_ce_migrationControllerRegistrationService OBJ_tcg_ce,6L + +#define SN_tcg_ce_virtualPlatformBackupService "tcg-ce-virtualPlatformBackupService" +#define LN_tcg_ce_virtualPlatformBackupService "Virtual Platform Backup Service" +#define NID_tcg_ce_virtualPlatformBackupService 1381 +#define OBJ_tcg_ce_virtualPlatformBackupService OBJ_tcg_ce,7L + +#define SN_tcg_prt_tpmIdProtocol "tcg-prt-tpmIdProtocol" +#define LN_tcg_prt_tpmIdProtocol "TCG TPM Protocol" +#define NID_tcg_prt_tpmIdProtocol 1382 +#define OBJ_tcg_prt_tpmIdProtocol OBJ_tcg_protocol,1L + +#define SN_tcg_address_ethernetmac "tcg-address-ethernetmac" +#define LN_tcg_address_ethernetmac "Ethernet MAC Address" +#define NID_tcg_address_ethernetmac 1383 +#define OBJ_tcg_address_ethernetmac OBJ_tcg_address,1L + +#define SN_tcg_address_wlanmac "tcg-address-wlanmac" +#define LN_tcg_address_wlanmac "WLAN MAC Address" +#define NID_tcg_address_wlanmac 1384 +#define OBJ_tcg_address_wlanmac OBJ_tcg_address,2L + +#define SN_tcg_address_bluetoothmac "tcg-address-bluetoothmac" +#define LN_tcg_address_bluetoothmac "Bluetooth MAC Address" +#define NID_tcg_address_bluetoothmac 1385 +#define OBJ_tcg_address_bluetoothmac OBJ_tcg_address,3L + +#define SN_tcg_registry_componentClass "tcg-registry-componentClass" +#define LN_tcg_registry_componentClass "TCG Component Class" +#define NID_tcg_registry_componentClass 1386 +#define OBJ_tcg_registry_componentClass OBJ_tcg_registry,3L + +#define SN_tcg_registry_componentClass_tcg "tcg-registry-componentClass-tcg" +#define LN_tcg_registry_componentClass_tcg "Trusted Computed Group Registry" +#define NID_tcg_registry_componentClass_tcg 1387 +#define OBJ_tcg_registry_componentClass_tcg OBJ_tcg_registry_componentClass,1L + +#define SN_tcg_registry_componentClass_ietf "tcg-registry-componentClass-ietf" +#define LN_tcg_registry_componentClass_ietf "Internet Engineering Task Force Registry" +#define NID_tcg_registry_componentClass_ietf 1388 +#define OBJ_tcg_registry_componentClass_ietf OBJ_tcg_registry_componentClass,2L + +#define SN_tcg_registry_componentClass_dmtf "tcg-registry-componentClass-dmtf" +#define LN_tcg_registry_componentClass_dmtf "Distributed Management Task Force Registry" +#define NID_tcg_registry_componentClass_dmtf 1389 +#define OBJ_tcg_registry_componentClass_dmtf OBJ_tcg_registry_componentClass,3L + +#define SN_tcg_registry_componentClass_pcie "tcg-registry-componentClass-pcie" +#define LN_tcg_registry_componentClass_pcie "PCIE Component Class" +#define NID_tcg_registry_componentClass_pcie 1390 +#define OBJ_tcg_registry_componentClass_pcie OBJ_tcg_registry_componentClass,4L + +#define SN_tcg_registry_componentClass_disk "tcg-registry-componentClass-disk" +#define LN_tcg_registry_componentClass_disk "Disk Component Class" +#define NID_tcg_registry_componentClass_disk 1391 +#define OBJ_tcg_registry_componentClass_disk OBJ_tcg_registry_componentClass,5L + +#define SN_tcg_cap_verifiedPlatformCertificate "tcg-cap-verifiedPlatformCertificate" +#define LN_tcg_cap_verifiedPlatformCertificate "TCG Verified Platform Certificate CA Policy" +#define NID_tcg_cap_verifiedPlatformCertificate 1392 +#define OBJ_tcg_cap_verifiedPlatformCertificate OBJ_tcg_ca,4L + +#define SN_tcg_tr_ID "tcg-tr-ID" +#define LN_tcg_tr_ID "TCG Trait Identifiers" +#define NID_tcg_tr_ID 1393 +#define OBJ_tcg_tr_ID OBJ_tcg_traits,1L + +#define SN_tcg_tr_category "tcg-tr-category" +#define LN_tcg_tr_category "TCG Trait Categories" +#define NID_tcg_tr_category 1394 +#define OBJ_tcg_tr_category OBJ_tcg_traits,2L + +#define SN_tcg_tr_registry "tcg-tr-registry" +#define LN_tcg_tr_registry "TCG Trait Registries" +#define NID_tcg_tr_registry 1395 +#define OBJ_tcg_tr_registry OBJ_tcg_traits,3L + +#define SN_tcg_tr_ID_Boolean "tcg-tr-ID-Boolean" +#define LN_tcg_tr_ID_Boolean "Boolean Trait" +#define NID_tcg_tr_ID_Boolean 1396 +#define OBJ_tcg_tr_ID_Boolean OBJ_tcg_tr_ID,1L + +#define SN_tcg_tr_ID_CertificateIdentifier "tcg-tr-ID-CertificateIdentifier" +#define LN_tcg_tr_ID_CertificateIdentifier "Certificate Identifier Trait" +#define NID_tcg_tr_ID_CertificateIdentifier 1397 +#define OBJ_tcg_tr_ID_CertificateIdentifier OBJ_tcg_tr_ID,2L + +#define SN_tcg_tr_ID_CommonCriteria "tcg-tr-ID-CommonCriteria" +#define LN_tcg_tr_ID_CommonCriteria "Common Criteria Trait" +#define NID_tcg_tr_ID_CommonCriteria 1398 +#define OBJ_tcg_tr_ID_CommonCriteria OBJ_tcg_tr_ID,3L + +#define SN_tcg_tr_ID_componentClass "tcg-tr-ID-componentClass" +#define LN_tcg_tr_ID_componentClass "Component Class Trait" +#define NID_tcg_tr_ID_componentClass 1399 +#define OBJ_tcg_tr_ID_componentClass OBJ_tcg_tr_ID,4L + +#define SN_tcg_tr_ID_componentIdentifierV11 "tcg-tr-ID-componentIdentifierV11" +#define LN_tcg_tr_ID_componentIdentifierV11 "Component Identifier V1.1 Trait" +#define NID_tcg_tr_ID_componentIdentifierV11 1400 +#define OBJ_tcg_tr_ID_componentIdentifierV11 OBJ_tcg_tr_ID,5L + +#define SN_tcg_tr_ID_FIPSLevel "tcg-tr-ID-FIPSLevel" +#define LN_tcg_tr_ID_FIPSLevel "FIPS Level Trait" +#define NID_tcg_tr_ID_FIPSLevel 1401 +#define OBJ_tcg_tr_ID_FIPSLevel OBJ_tcg_tr_ID,6L + +#define SN_tcg_tr_ID_ISO9000Level "tcg-tr-ID-ISO9000Level" +#define LN_tcg_tr_ID_ISO9000Level "ISO 9000 Level Trait" +#define NID_tcg_tr_ID_ISO9000Level 1402 +#define OBJ_tcg_tr_ID_ISO9000Level OBJ_tcg_tr_ID,7L + +#define SN_tcg_tr_ID_networkMAC "tcg-tr-ID-networkMAC" +#define LN_tcg_tr_ID_networkMAC "Network MAC Trait" +#define NID_tcg_tr_ID_networkMAC 1403 +#define OBJ_tcg_tr_ID_networkMAC OBJ_tcg_tr_ID,8L + +#define SN_tcg_tr_ID_OID "tcg-tr-ID-OID" +#define LN_tcg_tr_ID_OID "Object Identifier Trait" +#define NID_tcg_tr_ID_OID 1404 +#define OBJ_tcg_tr_ID_OID OBJ_tcg_tr_ID,9L + +#define SN_tcg_tr_ID_PEN "tcg-tr-ID-PEN" +#define LN_tcg_tr_ID_PEN "Private Enterprise Number Trait" +#define NID_tcg_tr_ID_PEN 1405 +#define OBJ_tcg_tr_ID_PEN OBJ_tcg_tr_ID,10L + +#define SN_tcg_tr_ID_platformFirmwareCapabilities "tcg-tr-ID-platformFirmwareCapabilities" +#define LN_tcg_tr_ID_platformFirmwareCapabilities "Platform Firmware Capabilities Trait" +#define NID_tcg_tr_ID_platformFirmwareCapabilities 1406 +#define OBJ_tcg_tr_ID_platformFirmwareCapabilities OBJ_tcg_tr_ID,11L + +#define SN_tcg_tr_ID_platformFirmwareSignatureVerification "tcg-tr-ID-platformFirmwareSignatureVerification" +#define LN_tcg_tr_ID_platformFirmwareSignatureVerification "Platform Firmware Signature Verification Trait" +#define NID_tcg_tr_ID_platformFirmwareSignatureVerification 1407 +#define OBJ_tcg_tr_ID_platformFirmwareSignatureVerification OBJ_tcg_tr_ID,12L + +#define SN_tcg_tr_ID_platformFirmwareUpdateCompliance "tcg-tr-ID-platformFirmwareUpdateCompliance" +#define LN_tcg_tr_ID_platformFirmwareUpdateCompliance "Platform Firmware Update Compliance Trait" +#define NID_tcg_tr_ID_platformFirmwareUpdateCompliance 1408 +#define OBJ_tcg_tr_ID_platformFirmwareUpdateCompliance OBJ_tcg_tr_ID,13L + +#define SN_tcg_tr_ID_platformHardwareCapabilities "tcg-tr-ID-platformHardwareCapabilities" +#define LN_tcg_tr_ID_platformHardwareCapabilities "Platform Hardware Capabilities Trait" +#define NID_tcg_tr_ID_platformHardwareCapabilities 1409 +#define OBJ_tcg_tr_ID_platformHardwareCapabilities OBJ_tcg_tr_ID,14L + +#define SN_tcg_tr_ID_RTM "tcg-tr-ID-RTM" +#define LN_tcg_tr_ID_RTM "Root of Trust for Measurement Trait" +#define NID_tcg_tr_ID_RTM 1410 +#define OBJ_tcg_tr_ID_RTM OBJ_tcg_tr_ID,15L + +#define SN_tcg_tr_ID_status "tcg-tr-ID-status" +#define LN_tcg_tr_ID_status "Attribute Status Trait" +#define NID_tcg_tr_ID_status 1411 +#define OBJ_tcg_tr_ID_status OBJ_tcg_tr_ID,16L + +#define SN_tcg_tr_ID_URI "tcg-tr-ID-URI" +#define LN_tcg_tr_ID_URI "Uniform Resource Identifier Trait" +#define NID_tcg_tr_ID_URI 1412 +#define OBJ_tcg_tr_ID_URI OBJ_tcg_tr_ID,17L + +#define SN_tcg_tr_ID_UTF8String "tcg-tr-ID-UTF8String" +#define LN_tcg_tr_ID_UTF8String "UTF8String Trait" +#define NID_tcg_tr_ID_UTF8String 1413 +#define OBJ_tcg_tr_ID_UTF8String OBJ_tcg_tr_ID,18L + +#define SN_tcg_tr_ID_IA5String "tcg-tr-ID-IA5String" +#define LN_tcg_tr_ID_IA5String "IA5String Trait" +#define NID_tcg_tr_ID_IA5String 1414 +#define OBJ_tcg_tr_ID_IA5String OBJ_tcg_tr_ID,19L + +#define SN_tcg_tr_ID_PEMCertString "tcg-tr-ID-PEMCertString" +#define LN_tcg_tr_ID_PEMCertString "PEM-Encoded Certificate String Trait" +#define NID_tcg_tr_ID_PEMCertString 1415 +#define OBJ_tcg_tr_ID_PEMCertString OBJ_tcg_tr_ID,20L + +#define SN_tcg_tr_ID_PublicKey "tcg-tr-ID-PublicKey" +#define LN_tcg_tr_ID_PublicKey "Public Key Trait" +#define NID_tcg_tr_ID_PublicKey 1416 +#define OBJ_tcg_tr_ID_PublicKey OBJ_tcg_tr_ID,21L + +#define SN_tcg_tr_cat_platformManufacturer "tcg-tr-cat-platformManufacturer" +#define LN_tcg_tr_cat_platformManufacturer "Platform Manufacturer Trait Category" +#define NID_tcg_tr_cat_platformManufacturer 1417 +#define OBJ_tcg_tr_cat_platformManufacturer OBJ_tcg_tr_category,1L + +#define SN_tcg_tr_cat_platformModel "tcg-tr-cat-platformModel" +#define LN_tcg_tr_cat_platformModel "Platform Model Trait Category" +#define NID_tcg_tr_cat_platformModel 1418 +#define OBJ_tcg_tr_cat_platformModel OBJ_tcg_tr_category,2L + +#define SN_tcg_tr_cat_platformVersion "tcg-tr-cat-platformVersion" +#define LN_tcg_tr_cat_platformVersion "Platform Version Trait Category" +#define NID_tcg_tr_cat_platformVersion 1419 +#define OBJ_tcg_tr_cat_platformVersion OBJ_tcg_tr_category,3L + +#define SN_tcg_tr_cat_platformSerial "tcg-tr-cat-platformSerial" +#define LN_tcg_tr_cat_platformSerial "Platform Serial Trait Category" +#define NID_tcg_tr_cat_platformSerial 1420 +#define OBJ_tcg_tr_cat_platformSerial OBJ_tcg_tr_category,4L + +#define SN_tcg_tr_cat_platformManufacturerIdentifier "tcg-tr-cat-platformManufacturerIdentifier" +#define LN_tcg_tr_cat_platformManufacturerIdentifier "Platform Manufacturer Identifier Trait Category" +#define NID_tcg_tr_cat_platformManufacturerIdentifier 1421 +#define OBJ_tcg_tr_cat_platformManufacturerIdentifier OBJ_tcg_tr_category,5L + +#define SN_tcg_tr_cat_platformOwnership "tcg-tr-cat-platformOwnership" +#define LN_tcg_tr_cat_platformOwnership "Platform Ownership Trait Category" +#define NID_tcg_tr_cat_platformOwnership 1422 +#define OBJ_tcg_tr_cat_platformOwnership OBJ_tcg_tr_category,6L + +#define SN_tcg_tr_cat_componentClass "tcg-tr-cat-componentClass" +#define LN_tcg_tr_cat_componentClass "Component Class Trait Category" +#define NID_tcg_tr_cat_componentClass 1423 +#define OBJ_tcg_tr_cat_componentClass OBJ_tcg_tr_category,7L + +#define SN_tcg_tr_cat_componentManufacturer "tcg-tr-cat-componentManufacturer" +#define LN_tcg_tr_cat_componentManufacturer "Component Manufacturer Trait Category" +#define NID_tcg_tr_cat_componentManufacturer 1424 +#define OBJ_tcg_tr_cat_componentManufacturer OBJ_tcg_tr_category,8L + +#define SN_tcg_tr_cat_componentModel "tcg-tr-cat-componentModel" +#define LN_tcg_tr_cat_componentModel "Component Model Trait Category" +#define NID_tcg_tr_cat_componentModel 1425 +#define OBJ_tcg_tr_cat_componentModel OBJ_tcg_tr_category,9L + +#define SN_tcg_tr_cat_componentSerial "tcg-tr-cat-componentSerial" +#define LN_tcg_tr_cat_componentSerial "Component Serial Trait Category" +#define NID_tcg_tr_cat_componentSerial 1426 +#define OBJ_tcg_tr_cat_componentSerial OBJ_tcg_tr_category,10L + +#define SN_tcg_tr_cat_componentStatus "tcg-tr-cat-componentStatus" +#define LN_tcg_tr_cat_componentStatus "Component Status Trait Category" +#define NID_tcg_tr_cat_componentStatus 1427 +#define OBJ_tcg_tr_cat_componentStatus OBJ_tcg_tr_category,11L + +#define SN_tcg_tr_cat_componentLocation "tcg-tr-cat-componentLocation" +#define LN_tcg_tr_cat_componentLocation "Component Location Trait Category" +#define NID_tcg_tr_cat_componentLocation 1428 +#define OBJ_tcg_tr_cat_componentLocation OBJ_tcg_tr_category,12L + +#define SN_tcg_tr_cat_componentRevision "tcg-tr-cat-componentRevision" +#define LN_tcg_tr_cat_componentRevision "Component Revision Trait Category" +#define NID_tcg_tr_cat_componentRevision 1429 +#define OBJ_tcg_tr_cat_componentRevision OBJ_tcg_tr_category,13L + +#define SN_tcg_tr_cat_componentFieldReplaceable "tcg-tr-cat-componentFieldReplaceable" +#define LN_tcg_tr_cat_componentFieldReplaceable "Component Field Replaceable Trait Category" +#define NID_tcg_tr_cat_componentFieldReplaceable 1430 +#define OBJ_tcg_tr_cat_componentFieldReplaceable OBJ_tcg_tr_category,14L + +#define SN_tcg_tr_cat_EKCertificate "tcg-tr-cat-EKCertificate" +#define LN_tcg_tr_cat_EKCertificate "EK Certificate Trait Category" +#define NID_tcg_tr_cat_EKCertificate 1431 +#define OBJ_tcg_tr_cat_EKCertificate OBJ_tcg_tr_category,15L + +#define SN_tcg_tr_cat_IAKCertificate "tcg-tr-cat-IAKCertificate" +#define LN_tcg_tr_cat_IAKCertificate "IAK Certificate Trait Category" +#define NID_tcg_tr_cat_IAKCertificate 1432 +#define OBJ_tcg_tr_cat_IAKCertificate OBJ_tcg_tr_category,16L + +#define SN_tcg_tr_cat_IDevIDCertificate "tcg-tr-cat-IDevIDCertificate" +#define LN_tcg_tr_cat_IDevIDCertificate "IDevID Certificate Trait Category" +#define NID_tcg_tr_cat_IDevIDCertificate 1433 +#define OBJ_tcg_tr_cat_IDevIDCertificate OBJ_tcg_tr_category,17L + +#define SN_tcg_tr_cat_DICECertificate "tcg-tr-cat-DICECertificate" +#define LN_tcg_tr_cat_DICECertificate "DICE Certificate Trait Category" +#define NID_tcg_tr_cat_DICECertificate 1434 +#define OBJ_tcg_tr_cat_DICECertificate OBJ_tcg_tr_category,18L + +#define SN_tcg_tr_cat_SPDMCertificate "tcg-tr-cat-SPDMCertificate" +#define LN_tcg_tr_cat_SPDMCertificate "SPDM Certificate Trait Category" +#define NID_tcg_tr_cat_SPDMCertificate 1435 +#define OBJ_tcg_tr_cat_SPDMCertificate OBJ_tcg_tr_category,19L + +#define SN_tcg_tr_cat_PEMCertificate "tcg-tr-cat-PEMCertificate" +#define LN_tcg_tr_cat_PEMCertificate "PEM Certificate Trait Category" +#define NID_tcg_tr_cat_PEMCertificate 1436 +#define OBJ_tcg_tr_cat_PEMCertificate OBJ_tcg_tr_category,20L + +#define SN_tcg_tr_cat_PlatformCertificate "tcg-tr-cat-PlatformCertificate" +#define LN_tcg_tr_cat_PlatformCertificate "Platform Certificate Trait Category" +#define NID_tcg_tr_cat_PlatformCertificate 1437 +#define OBJ_tcg_tr_cat_PlatformCertificate OBJ_tcg_tr_category,21L + +#define SN_tcg_tr_cat_DeltaPlatformCertificate "tcg-tr-cat-DeltaPlatformCertificate" +#define LN_tcg_tr_cat_DeltaPlatformCertificate "Delta Platform Certificate Trait Category" +#define NID_tcg_tr_cat_DeltaPlatformCertificate 1438 +#define OBJ_tcg_tr_cat_DeltaPlatformCertificate OBJ_tcg_tr_category,22L + +#define SN_tcg_tr_cat_RebasePlatformCertificate "tcg-tr-cat-RebasePlatformCertificate" +#define LN_tcg_tr_cat_RebasePlatformCertificate "Rebase Platform Certificate Trait Category" +#define NID_tcg_tr_cat_RebasePlatformCertificate 1439 +#define OBJ_tcg_tr_cat_RebasePlatformCertificate OBJ_tcg_tr_category,23L + +#define SN_tcg_tr_cat_genericCertificate "tcg-tr-cat-genericCertificate" +#define LN_tcg_tr_cat_genericCertificate "Generic Certificate Trait Category" +#define NID_tcg_tr_cat_genericCertificate 1440 +#define OBJ_tcg_tr_cat_genericCertificate OBJ_tcg_tr_category,24L + +#define SN_tcg_tr_cat_CommonCriteria "tcg-tr-cat-CommonCriteria" +#define LN_tcg_tr_cat_CommonCriteria "Common Criteria Trait Category" +#define NID_tcg_tr_cat_CommonCriteria 1441 +#define OBJ_tcg_tr_cat_CommonCriteria OBJ_tcg_tr_category,25L + +#define SN_tcg_tr_cat_componentIdentifierV11 "tcg-tr-cat-componentIdentifierV11" +#define LN_tcg_tr_cat_componentIdentifierV11 "Component Identifier V1.1 Trait Category" +#define NID_tcg_tr_cat_componentIdentifierV11 1442 +#define OBJ_tcg_tr_cat_componentIdentifierV11 OBJ_tcg_tr_category,26L + +#define SN_tcg_tr_cat_FIPSLevel "tcg-tr-cat-FIPSLevel" +#define LN_tcg_tr_cat_FIPSLevel "FIPS Level Trait Category" +#define NID_tcg_tr_cat_FIPSLevel 1443 +#define OBJ_tcg_tr_cat_FIPSLevel OBJ_tcg_tr_category,27L + +#define SN_tcg_tr_cat_ISO9000 "tcg-tr-cat-ISO9000" +#define LN_tcg_tr_cat_ISO9000 "ISO 9000 Trait Category" +#define NID_tcg_tr_cat_ISO9000 1444 +#define OBJ_tcg_tr_cat_ISO9000 OBJ_tcg_tr_category,28L + +#define SN_tcg_tr_cat_networkMAC "tcg-tr-cat-networkMAC" +#define LN_tcg_tr_cat_networkMAC "Network MAC Trait Category" +#define NID_tcg_tr_cat_networkMAC 1445 +#define OBJ_tcg_tr_cat_networkMAC OBJ_tcg_tr_category,29L + +#define SN_tcg_tr_cat_attestationProtocol "tcg-tr-cat-attestationProtocol" +#define LN_tcg_tr_cat_attestationProtocol "Attestation Protocol Trait Category" +#define NID_tcg_tr_cat_attestationProtocol 1446 +#define OBJ_tcg_tr_cat_attestationProtocol OBJ_tcg_tr_category,30L + +#define SN_tcg_tr_cat_PEN "tcg-tr-cat-PEN" +#define LN_tcg_tr_cat_PEN "Private Enterprise Number Trait Category" +#define NID_tcg_tr_cat_PEN 1447 +#define OBJ_tcg_tr_cat_PEN OBJ_tcg_tr_category,31L + +#define SN_tcg_tr_cat_platformFirmwareCapabilities "tcg-tr-cat-platformFirmwareCapabilities" +#define LN_tcg_tr_cat_platformFirmwareCapabilities "Platform Firmware Capabilities Trait Category" +#define NID_tcg_tr_cat_platformFirmwareCapabilities 1448 +#define OBJ_tcg_tr_cat_platformFirmwareCapabilities OBJ_tcg_tr_category,32L + +#define SN_tcg_tr_cat_platformHardwareCapabilities "tcg-tr-cat-platformHardwareCapabilities" +#define LN_tcg_tr_cat_platformHardwareCapabilities "Platform Hardware Capabilities Trait Category" +#define NID_tcg_tr_cat_platformHardwareCapabilities 1449 +#define OBJ_tcg_tr_cat_platformHardwareCapabilities OBJ_tcg_tr_category,33L + +#define SN_tcg_tr_cat_platformFirmwareSignatureVerification "tcg-tr-cat-platformFirmwareSignatureVerification" +#define LN_tcg_tr_cat_platformFirmwareSignatureVerification "Platform Firmware Signature Verification Trait Category" +#define NID_tcg_tr_cat_platformFirmwareSignatureVerification 1450 +#define OBJ_tcg_tr_cat_platformFirmwareSignatureVerification OBJ_tcg_tr_category,34L + +#define SN_tcg_tr_cat_platformFirmwareUpdateCompliance "tcg-tr-cat-platformFirmwareUpdateCompliance" +#define LN_tcg_tr_cat_platformFirmwareUpdateCompliance "Platform Firmware Update Compliance Trait Category" +#define NID_tcg_tr_cat_platformFirmwareUpdateCompliance 1451 +#define OBJ_tcg_tr_cat_platformFirmwareUpdateCompliance OBJ_tcg_tr_category,35L + +#define SN_tcg_tr_cat_RTM "tcg-tr-cat-RTM" +#define LN_tcg_tr_cat_RTM "Root of Trust of Measurement Trait Category" +#define NID_tcg_tr_cat_RTM 1452 +#define OBJ_tcg_tr_cat_RTM OBJ_tcg_tr_category,36L + +#define SN_tcg_tr_cat_PublicKey "tcg-tr-cat-PublicKey" +#define LN_tcg_tr_cat_PublicKey "Public Key Trait Category" +#define NID_tcg_tr_cat_PublicKey 1453 +#define OBJ_tcg_tr_cat_PublicKey OBJ_tcg_tr_category,37L + +#define OBJ_nistKems OBJ_nistAlgorithms,4L + +#define SN_ML_KEM_512 "id-alg-ml-kem-512" +#define LN_ML_KEM_512 "ML-KEM-512" +#define NID_ML_KEM_512 1454 +#define OBJ_ML_KEM_512 OBJ_nistKems,1L + +#define SN_ML_KEM_768 "id-alg-ml-kem-768" +#define LN_ML_KEM_768 "ML-KEM-768" +#define NID_ML_KEM_768 1455 +#define OBJ_ML_KEM_768 OBJ_nistKems,2L + +#define SN_ML_KEM_1024 "id-alg-ml-kem-1024" +#define LN_ML_KEM_1024 "ML-KEM-1024" +#define NID_ML_KEM_1024 1456 +#define OBJ_ML_KEM_1024 OBJ_nistKems,3L + +#endif /* OPENSSL_OBJ_MAC_H */ + +#ifndef OPENSSL_NO_DEPRECATED_3_0 + +#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm SN_magma_ctr_acpkm +#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm NID_magma_ctr_acpkm +#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm OBJ_magma_ctr_acpkm + +#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac SN_magma_ctr_acpkm_omac +#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac NID_magma_ctr_acpkm_omac +#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac OBJ_magma_ctr_acpkm_omac + +#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm SN_kuznyechik_ctr_acpkm +#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm NID_kuznyechik_ctr_acpkm +#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm OBJ_kuznyechik_ctr_acpkm + +#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac SN_kuznyechik_ctr_acpkm_omac +#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac NID_kuznyechik_ctr_acpkm_omac +#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac OBJ_kuznyechik_ctr_acpkm_omac + +#define SN_id_tc26_wrap_gostr3412_2015_magma_kexp15 SN_magma_kexp15 +#define NID_id_tc26_wrap_gostr3412_2015_magma_kexp15 NID_magma_kexp15 +#define OBJ_id_tc26_wrap_gostr3412_2015_magma_kexp15 OBJ_magma_kexp15 + +#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15 SN_kuznyechik_kexp15 +#define NID_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15 NID_kuznyechik_kexp15 +#define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15 OBJ_kuznyechik_kexp15 + +#define SN_grasshopper_ecb SN_kuznyechik_ecb +#define NID_grasshopper_ecb NID_kuznyechik_ecb + +#define SN_grasshopper_ctr SN_kuznyechik_ctr +#define NID_grasshopper_ctr NID_kuznyechik_ctr + +#define SN_grasshopper_ofb SN_kuznyechik_ofb +#define NID_grasshopper_ofb NID_kuznyechik_ofb + +#define SN_grasshopper_cbc SN_kuznyechik_cbc +#define NID_grasshopper_cbc NID_kuznyechik_cbc + +#define SN_grasshopper_cfb SN_kuznyechik_cfb +#define NID_grasshopper_cfb NID_kuznyechik_cfb + +#define SN_grasshopper_mac SN_kuznyechik_mac +#define NID_grasshopper_mac NID_kuznyechik_mac + +#endif /* OPENSSL_NO_DEPRECATED_3_0 */ diff --git a/illumos-x86_64/usr/include/openssl-3/objects.h b/illumos-x86_64/usr/include/openssl-3/objects.h new file mode 100644 index 00000000..cc9f3c51 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/objects.h @@ -0,0 +1,184 @@ +/* + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_OBJECTS_H +# define OPENSSL_OBJECTS_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_OBJECTS_H +# endif + +# include +# include +# include +# include + +# define OBJ_NAME_TYPE_UNDEF 0x00 +# define OBJ_NAME_TYPE_MD_METH 0x01 +# define OBJ_NAME_TYPE_CIPHER_METH 0x02 +# define OBJ_NAME_TYPE_PKEY_METH 0x03 +# define OBJ_NAME_TYPE_COMP_METH 0x04 +# define OBJ_NAME_TYPE_MAC_METH 0x05 +# define OBJ_NAME_TYPE_KDF_METH 0x06 +# define OBJ_NAME_TYPE_NUM 0x07 + +# define OBJ_NAME_ALIAS 0x8000 + +# define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 +# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct obj_name_st { + int type; + int alias; + const char *name; + const char *data; +} OBJ_NAME; + +# define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) + +int OBJ_NAME_init(void); +int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *), + int (*cmp_func) (const char *, const char *), + void (*free_func) (const char *, int, const char *)); +const char *OBJ_NAME_get(const char *name, int type); +int OBJ_NAME_add(const char *name, int type, const char *data); +int OBJ_NAME_remove(const char *name, int type); +void OBJ_NAME_cleanup(int type); /* -1 for everything */ +void OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg), + void *arg); +void OBJ_NAME_do_all_sorted(int type, + void (*fn) (const OBJ_NAME *, void *arg), + void *arg); + +DECLARE_ASN1_DUP_FUNCTION_name(ASN1_OBJECT, OBJ) +ASN1_OBJECT *OBJ_nid2obj(int n); +const char *OBJ_nid2ln(int n); +const char *OBJ_nid2sn(int n); +int OBJ_obj2nid(const ASN1_OBJECT *o); +ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name); +int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); +int OBJ_txt2nid(const char *s); +int OBJ_ln2nid(const char *s); +int OBJ_sn2nid(const char *s); +int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b); +const void *OBJ_bsearch_(const void *key, const void *base, int num, int size, + int (*cmp) (const void *, const void *)); +const void *OBJ_bsearch_ex_(const void *key, const void *base, int num, + int size, + int (*cmp) (const void *, const void *), + int flags); + +# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ + static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \ + static int nm##_cmp(type1 const *, type2 const *); \ + scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) + +# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \ + _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp) +# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ + type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) + +/*- + * Unsolved problem: if a type is actually a pointer type, like + * nid_triple is, then its impossible to get a const where you need + * it. Consider: + * + * typedef int nid_triple[3]; + * const void *a_; + * const nid_triple const *a = a_; + * + * The assignment discards a const because what you really want is: + * + * const int const * const *a = a_; + * + * But if you do that, you lose the fact that a is an array of 3 ints, + * which breaks comparison functions. + * + * Thus we end up having to cast, sadly, or unpack the + * declarations. Or, as I finally did in this case, declare nid_triple + * to be a struct, which it should have been in the first place. + * + * Ben, August 2008. + * + * Also, strictly speaking not all types need be const, but handling + * the non-constness means a lot of complication, and in practice + * comparison routines do always not touch their arguments. + */ + +# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \ + static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ + { \ + type1 const *a = a_; \ + type2 const *b = b_; \ + return nm##_cmp(a,b); \ + } \ + static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ + { \ + return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ + nm##_cmp_BSEARCH_CMP_FN); \ + } \ + extern void dummy_prototype(void) + +# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ + static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ + { \ + type1 const *a = a_; \ + type2 const *b = b_; \ + return nm##_cmp(a,b); \ + } \ + type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ + { \ + return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ + nm##_cmp_BSEARCH_CMP_FN); \ + } \ + extern void dummy_prototype(void) + +# define OBJ_bsearch(type1,key,type2,base,num,cmp) \ + ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \ + num,sizeof(type2), \ + ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \ + (void)CHECKED_PTR_OF(type2,cmp##_type_2), \ + cmp##_BSEARCH_CMP_FN))) + +# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags) \ + ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \ + num,sizeof(type2), \ + ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \ + (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \ + cmp##_BSEARCH_CMP_FN)),flags) + +int OBJ_new_nid(int num); +int OBJ_add_object(const ASN1_OBJECT *obj); +int OBJ_create(const char *oid, const char *sn, const char *ln); +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define OBJ_cleanup() while(0) continue +#endif +int OBJ_create_objects(BIO *in); + +size_t OBJ_length(const ASN1_OBJECT *obj); +const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj); + +int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid); +int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid); +int OBJ_add_sigid(int signid, int dig_id, int pkey_id); +void OBJ_sigid_free(void); + +#define SN_ac_auditEntity SN_ac_auditIdentity + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/objectserr.h b/illumos-x86_64/usr/include/openssl-3/objectserr.h new file mode 100644 index 00000000..585217f6 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/objectserr.h @@ -0,0 +1,28 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_OBJECTSERR_H +# define OPENSSL_OBJECTSERR_H +# pragma once + +# include +# include +# include + + + +/* + * OBJ reason codes. + */ +# define OBJ_R_OID_EXISTS 102 +# define OBJ_R_UNKNOWN_NID 101 +# define OBJ_R_UNKNOWN_OBJECT_NAME 103 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ocsp.h b/illumos-x86_64/usr/include/openssl-3/ocsp.h new file mode 100644 index 00000000..142b1831 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ocsp.h @@ -0,0 +1,483 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/ocsp.h.in + * + * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_OCSP_H +# define OPENSSL_OCSP_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_OCSP_H +# endif + +# include +# include +# include + +/* + * These definitions are outside the OPENSSL_NO_OCSP guard because although for + * historical reasons they have OCSP_* names, they can actually be used + * independently of OCSP. E.g. see RFC5280 + */ +/*- + * CRLReason ::= ENUMERATED { + * unspecified (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6), + * -- value 7 is not used + * removeFromCRL (8), + * privilegeWithdrawn (9), + * aACompromise (10) } + */ +# define OCSP_REVOKED_STATUS_NOSTATUS -1 +# define OCSP_REVOKED_STATUS_UNSPECIFIED 0 +# define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1 +# define OCSP_REVOKED_STATUS_CACOMPROMISE 2 +# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3 +# define OCSP_REVOKED_STATUS_SUPERSEDED 4 +# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5 +# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6 +# define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8 +# define OCSP_REVOKED_STATUS_PRIVILEGEWITHDRAWN 9 +# define OCSP_REVOKED_STATUS_AACOMPROMISE 10 + + +# ifndef OPENSSL_NO_OCSP + +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* Various flags and values */ + +# define OCSP_DEFAULT_NONCE_LENGTH 16 + +# define OCSP_NOCERTS 0x1 +# define OCSP_NOINTERN 0x2 +# define OCSP_NOSIGS 0x4 +# define OCSP_NOCHAIN 0x8 +# define OCSP_NOVERIFY 0x10 +# define OCSP_NOEXPLICIT 0x20 +# define OCSP_NOCASIGN 0x40 +# define OCSP_NODELEGATED 0x80 +# define OCSP_NOCHECKS 0x100 +# define OCSP_TRUSTOTHER 0x200 +# define OCSP_RESPID_KEY 0x400 +# define OCSP_NOTIME 0x800 +# define OCSP_PARTIAL_CHAIN 0x1000 + +typedef struct ocsp_cert_id_st OCSP_CERTID; +typedef struct ocsp_one_request_st OCSP_ONEREQ; +typedef struct ocsp_req_info_st OCSP_REQINFO; +typedef struct ocsp_signature_st OCSP_SIGNATURE; +typedef struct ocsp_request_st OCSP_REQUEST; + +SKM_DEFINE_STACK_OF_INTERNAL(OCSP_CERTID, OCSP_CERTID, OCSP_CERTID) +#define sk_OCSP_CERTID_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_CERTID_sk_type(sk)) +#define sk_OCSP_CERTID_value(sk, idx) ((OCSP_CERTID *)OPENSSL_sk_value(ossl_check_const_OCSP_CERTID_sk_type(sk), (idx))) +#define sk_OCSP_CERTID_new(cmp) ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new(ossl_check_OCSP_CERTID_compfunc_type(cmp))) +#define sk_OCSP_CERTID_new_null() ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new_null()) +#define sk_OCSP_CERTID_new_reserve(cmp, n) ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new_reserve(ossl_check_OCSP_CERTID_compfunc_type(cmp), (n))) +#define sk_OCSP_CERTID_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OCSP_CERTID_sk_type(sk), (n)) +#define sk_OCSP_CERTID_free(sk) OPENSSL_sk_free(ossl_check_OCSP_CERTID_sk_type(sk)) +#define sk_OCSP_CERTID_zero(sk) OPENSSL_sk_zero(ossl_check_OCSP_CERTID_sk_type(sk)) +#define sk_OCSP_CERTID_delete(sk, i) ((OCSP_CERTID *)OPENSSL_sk_delete(ossl_check_OCSP_CERTID_sk_type(sk), (i))) +#define sk_OCSP_CERTID_delete_ptr(sk, ptr) ((OCSP_CERTID *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr))) +#define sk_OCSP_CERTID_push(sk, ptr) OPENSSL_sk_push(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr)) +#define sk_OCSP_CERTID_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr)) +#define sk_OCSP_CERTID_pop(sk) ((OCSP_CERTID *)OPENSSL_sk_pop(ossl_check_OCSP_CERTID_sk_type(sk))) +#define sk_OCSP_CERTID_shift(sk) ((OCSP_CERTID *)OPENSSL_sk_shift(ossl_check_OCSP_CERTID_sk_type(sk))) +#define sk_OCSP_CERTID_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OCSP_CERTID_sk_type(sk),ossl_check_OCSP_CERTID_freefunc_type(freefunc)) +#define sk_OCSP_CERTID_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr), (idx)) +#define sk_OCSP_CERTID_set(sk, idx, ptr) ((OCSP_CERTID *)OPENSSL_sk_set(ossl_check_OCSP_CERTID_sk_type(sk), (idx), ossl_check_OCSP_CERTID_type(ptr))) +#define sk_OCSP_CERTID_find(sk, ptr) OPENSSL_sk_find(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr)) +#define sk_OCSP_CERTID_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr)) +#define sk_OCSP_CERTID_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr), pnum) +#define sk_OCSP_CERTID_sort(sk) OPENSSL_sk_sort(ossl_check_OCSP_CERTID_sk_type(sk)) +#define sk_OCSP_CERTID_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OCSP_CERTID_sk_type(sk)) +#define sk_OCSP_CERTID_dup(sk) ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_dup(ossl_check_const_OCSP_CERTID_sk_type(sk))) +#define sk_OCSP_CERTID_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_deep_copy(ossl_check_const_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_copyfunc_type(copyfunc), ossl_check_OCSP_CERTID_freefunc_type(freefunc))) +#define sk_OCSP_CERTID_set_cmp_func(sk, cmp) ((sk_OCSP_CERTID_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(OCSP_ONEREQ, OCSP_ONEREQ, OCSP_ONEREQ) +#define sk_OCSP_ONEREQ_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_ONEREQ_sk_type(sk)) +#define sk_OCSP_ONEREQ_value(sk, idx) ((OCSP_ONEREQ *)OPENSSL_sk_value(ossl_check_const_OCSP_ONEREQ_sk_type(sk), (idx))) +#define sk_OCSP_ONEREQ_new(cmp) ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new(ossl_check_OCSP_ONEREQ_compfunc_type(cmp))) +#define sk_OCSP_ONEREQ_new_null() ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new_null()) +#define sk_OCSP_ONEREQ_new_reserve(cmp, n) ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new_reserve(ossl_check_OCSP_ONEREQ_compfunc_type(cmp), (n))) +#define sk_OCSP_ONEREQ_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OCSP_ONEREQ_sk_type(sk), (n)) +#define sk_OCSP_ONEREQ_free(sk) OPENSSL_sk_free(ossl_check_OCSP_ONEREQ_sk_type(sk)) +#define sk_OCSP_ONEREQ_zero(sk) OPENSSL_sk_zero(ossl_check_OCSP_ONEREQ_sk_type(sk)) +#define sk_OCSP_ONEREQ_delete(sk, i) ((OCSP_ONEREQ *)OPENSSL_sk_delete(ossl_check_OCSP_ONEREQ_sk_type(sk), (i))) +#define sk_OCSP_ONEREQ_delete_ptr(sk, ptr) ((OCSP_ONEREQ *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr))) +#define sk_OCSP_ONEREQ_push(sk, ptr) OPENSSL_sk_push(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr)) +#define sk_OCSP_ONEREQ_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr)) +#define sk_OCSP_ONEREQ_pop(sk) ((OCSP_ONEREQ *)OPENSSL_sk_pop(ossl_check_OCSP_ONEREQ_sk_type(sk))) +#define sk_OCSP_ONEREQ_shift(sk) ((OCSP_ONEREQ *)OPENSSL_sk_shift(ossl_check_OCSP_ONEREQ_sk_type(sk))) +#define sk_OCSP_ONEREQ_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OCSP_ONEREQ_sk_type(sk),ossl_check_OCSP_ONEREQ_freefunc_type(freefunc)) +#define sk_OCSP_ONEREQ_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr), (idx)) +#define sk_OCSP_ONEREQ_set(sk, idx, ptr) ((OCSP_ONEREQ *)OPENSSL_sk_set(ossl_check_OCSP_ONEREQ_sk_type(sk), (idx), ossl_check_OCSP_ONEREQ_type(ptr))) +#define sk_OCSP_ONEREQ_find(sk, ptr) OPENSSL_sk_find(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr)) +#define sk_OCSP_ONEREQ_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr)) +#define sk_OCSP_ONEREQ_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr), pnum) +#define sk_OCSP_ONEREQ_sort(sk) OPENSSL_sk_sort(ossl_check_OCSP_ONEREQ_sk_type(sk)) +#define sk_OCSP_ONEREQ_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OCSP_ONEREQ_sk_type(sk)) +#define sk_OCSP_ONEREQ_dup(sk) ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_dup(ossl_check_const_OCSP_ONEREQ_sk_type(sk))) +#define sk_OCSP_ONEREQ_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_deep_copy(ossl_check_const_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_copyfunc_type(copyfunc), ossl_check_OCSP_ONEREQ_freefunc_type(freefunc))) +#define sk_OCSP_ONEREQ_set_cmp_func(sk, cmp) ((sk_OCSP_ONEREQ_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_compfunc_type(cmp))) + + +# define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 +# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 +# define OCSP_RESPONSE_STATUS_INTERNALERROR 2 +# define OCSP_RESPONSE_STATUS_TRYLATER 3 +# define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 +# define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 + +typedef struct ocsp_resp_bytes_st OCSP_RESPBYTES; + +# define V_OCSP_RESPID_NAME 0 +# define V_OCSP_RESPID_KEY 1 + +SKM_DEFINE_STACK_OF_INTERNAL(OCSP_RESPID, OCSP_RESPID, OCSP_RESPID) +#define sk_OCSP_RESPID_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_RESPID_sk_type(sk)) +#define sk_OCSP_RESPID_value(sk, idx) ((OCSP_RESPID *)OPENSSL_sk_value(ossl_check_const_OCSP_RESPID_sk_type(sk), (idx))) +#define sk_OCSP_RESPID_new(cmp) ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new(ossl_check_OCSP_RESPID_compfunc_type(cmp))) +#define sk_OCSP_RESPID_new_null() ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new_null()) +#define sk_OCSP_RESPID_new_reserve(cmp, n) ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new_reserve(ossl_check_OCSP_RESPID_compfunc_type(cmp), (n))) +#define sk_OCSP_RESPID_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OCSP_RESPID_sk_type(sk), (n)) +#define sk_OCSP_RESPID_free(sk) OPENSSL_sk_free(ossl_check_OCSP_RESPID_sk_type(sk)) +#define sk_OCSP_RESPID_zero(sk) OPENSSL_sk_zero(ossl_check_OCSP_RESPID_sk_type(sk)) +#define sk_OCSP_RESPID_delete(sk, i) ((OCSP_RESPID *)OPENSSL_sk_delete(ossl_check_OCSP_RESPID_sk_type(sk), (i))) +#define sk_OCSP_RESPID_delete_ptr(sk, ptr) ((OCSP_RESPID *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr))) +#define sk_OCSP_RESPID_push(sk, ptr) OPENSSL_sk_push(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr)) +#define sk_OCSP_RESPID_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr)) +#define sk_OCSP_RESPID_pop(sk) ((OCSP_RESPID *)OPENSSL_sk_pop(ossl_check_OCSP_RESPID_sk_type(sk))) +#define sk_OCSP_RESPID_shift(sk) ((OCSP_RESPID *)OPENSSL_sk_shift(ossl_check_OCSP_RESPID_sk_type(sk))) +#define sk_OCSP_RESPID_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OCSP_RESPID_sk_type(sk),ossl_check_OCSP_RESPID_freefunc_type(freefunc)) +#define sk_OCSP_RESPID_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr), (idx)) +#define sk_OCSP_RESPID_set(sk, idx, ptr) ((OCSP_RESPID *)OPENSSL_sk_set(ossl_check_OCSP_RESPID_sk_type(sk), (idx), ossl_check_OCSP_RESPID_type(ptr))) +#define sk_OCSP_RESPID_find(sk, ptr) OPENSSL_sk_find(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr)) +#define sk_OCSP_RESPID_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr)) +#define sk_OCSP_RESPID_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr), pnum) +#define sk_OCSP_RESPID_sort(sk) OPENSSL_sk_sort(ossl_check_OCSP_RESPID_sk_type(sk)) +#define sk_OCSP_RESPID_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OCSP_RESPID_sk_type(sk)) +#define sk_OCSP_RESPID_dup(sk) ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_dup(ossl_check_const_OCSP_RESPID_sk_type(sk))) +#define sk_OCSP_RESPID_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_deep_copy(ossl_check_const_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_copyfunc_type(copyfunc), ossl_check_OCSP_RESPID_freefunc_type(freefunc))) +#define sk_OCSP_RESPID_set_cmp_func(sk, cmp) ((sk_OCSP_RESPID_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_compfunc_type(cmp))) + + +typedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO; + +# define V_OCSP_CERTSTATUS_GOOD 0 +# define V_OCSP_CERTSTATUS_REVOKED 1 +# define V_OCSP_CERTSTATUS_UNKNOWN 2 + +typedef struct ocsp_cert_status_st OCSP_CERTSTATUS; +typedef struct ocsp_single_response_st OCSP_SINGLERESP; + +SKM_DEFINE_STACK_OF_INTERNAL(OCSP_SINGLERESP, OCSP_SINGLERESP, OCSP_SINGLERESP) +#define sk_OCSP_SINGLERESP_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_SINGLERESP_sk_type(sk)) +#define sk_OCSP_SINGLERESP_value(sk, idx) ((OCSP_SINGLERESP *)OPENSSL_sk_value(ossl_check_const_OCSP_SINGLERESP_sk_type(sk), (idx))) +#define sk_OCSP_SINGLERESP_new(cmp) ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new(ossl_check_OCSP_SINGLERESP_compfunc_type(cmp))) +#define sk_OCSP_SINGLERESP_new_null() ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new_null()) +#define sk_OCSP_SINGLERESP_new_reserve(cmp, n) ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new_reserve(ossl_check_OCSP_SINGLERESP_compfunc_type(cmp), (n))) +#define sk_OCSP_SINGLERESP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OCSP_SINGLERESP_sk_type(sk), (n)) +#define sk_OCSP_SINGLERESP_free(sk) OPENSSL_sk_free(ossl_check_OCSP_SINGLERESP_sk_type(sk)) +#define sk_OCSP_SINGLERESP_zero(sk) OPENSSL_sk_zero(ossl_check_OCSP_SINGLERESP_sk_type(sk)) +#define sk_OCSP_SINGLERESP_delete(sk, i) ((OCSP_SINGLERESP *)OPENSSL_sk_delete(ossl_check_OCSP_SINGLERESP_sk_type(sk), (i))) +#define sk_OCSP_SINGLERESP_delete_ptr(sk, ptr) ((OCSP_SINGLERESP *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_type(ptr))) +#define sk_OCSP_SINGLERESP_push(sk, ptr) OPENSSL_sk_push(ossl_check_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_type(ptr)) +#define sk_OCSP_SINGLERESP_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_type(ptr)) +#define sk_OCSP_SINGLERESP_pop(sk) ((OCSP_SINGLERESP *)OPENSSL_sk_pop(ossl_check_OCSP_SINGLERESP_sk_type(sk))) +#define sk_OCSP_SINGLERESP_shift(sk) ((OCSP_SINGLERESP *)OPENSSL_sk_shift(ossl_check_OCSP_SINGLERESP_sk_type(sk))) +#define sk_OCSP_SINGLERESP_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OCSP_SINGLERESP_sk_type(sk),ossl_check_OCSP_SINGLERESP_freefunc_type(freefunc)) +#define sk_OCSP_SINGLERESP_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_type(ptr), (idx)) +#define sk_OCSP_SINGLERESP_set(sk, idx, ptr) ((OCSP_SINGLERESP *)OPENSSL_sk_set(ossl_check_OCSP_SINGLERESP_sk_type(sk), (idx), ossl_check_OCSP_SINGLERESP_type(ptr))) +#define sk_OCSP_SINGLERESP_find(sk, ptr) OPENSSL_sk_find(ossl_check_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_type(ptr)) +#define sk_OCSP_SINGLERESP_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_type(ptr)) +#define sk_OCSP_SINGLERESP_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_type(ptr), pnum) +#define sk_OCSP_SINGLERESP_sort(sk) OPENSSL_sk_sort(ossl_check_OCSP_SINGLERESP_sk_type(sk)) +#define sk_OCSP_SINGLERESP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OCSP_SINGLERESP_sk_type(sk)) +#define sk_OCSP_SINGLERESP_dup(sk) ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_dup(ossl_check_const_OCSP_SINGLERESP_sk_type(sk))) +#define sk_OCSP_SINGLERESP_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_deep_copy(ossl_check_const_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_copyfunc_type(copyfunc), ossl_check_OCSP_SINGLERESP_freefunc_type(freefunc))) +#define sk_OCSP_SINGLERESP_set_cmp_func(sk, cmp) ((sk_OCSP_SINGLERESP_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OCSP_SINGLERESP_sk_type(sk), ossl_check_OCSP_SINGLERESP_compfunc_type(cmp))) + + +typedef struct ocsp_response_data_st OCSP_RESPDATA; + +typedef struct ocsp_basic_response_st OCSP_BASICRESP; + +typedef struct ocsp_crl_id_st OCSP_CRLID; +typedef struct ocsp_service_locator_st OCSP_SERVICELOC; + +# define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" +# define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" + +# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p) + +# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p) + +# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST, \ + bp,(char **)(x),cb,NULL) + +# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb) (OCSP_RESPONSE *)PEM_ASN1_read_bio(\ + (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE, \ + bp,(char **)(x),cb,NULL) + +# define PEM_write_bio_OCSP_REQUEST(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\ + bp,(char *)(o), NULL,NULL,0,NULL,NULL) + +# define PEM_write_bio_OCSP_RESPONSE(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\ + bp,(char *)(o), NULL,NULL,0,NULL,NULL) + +# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o) + +# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o) + +# define ASN1_BIT_STRING_digest(data,type,md,len) \ + ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) + +# define OCSP_CERTSTATUS_dup(cs)\ + (OCSP_CERTSTATUS*)ASN1_dup((i2d_of_void *)i2d_OCSP_CERTSTATUS,\ + (d2i_of_void *)d2i_OCSP_CERTSTATUS,(char *)(cs)) + +DECLARE_ASN1_DUP_FUNCTION(OCSP_CERTID) + +OSSL_HTTP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, + const OCSP_REQUEST *req, int buf_size); +OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef OSSL_HTTP_REQ_CTX OCSP_REQ_CTX; +# define OCSP_REQ_CTX_new(io, buf_size) \ + OSSL_HTTP_REQ_CTX_new(io, io, buf_size) +# define OCSP_REQ_CTX_free OSSL_HTTP_REQ_CTX_free +# define OCSP_REQ_CTX_http(rctx, op, path) \ + (OSSL_HTTP_REQ_CTX_set_expected(rctx, NULL, 1 /* asn1 */, 0, 0) && \ + OSSL_HTTP_REQ_CTX_set_request_line(rctx, strcmp(op, "POST") == 0, \ + NULL, NULL, path)) +# define OCSP_REQ_CTX_add1_header OSSL_HTTP_REQ_CTX_add1_header +# define OCSP_REQ_CTX_i2d(r, it, req) \ + OSSL_HTTP_REQ_CTX_set1_req(r, "application/ocsp-request", it, req) +# define OCSP_REQ_CTX_set1_req(r, req) \ + OCSP_REQ_CTX_i2d(r, ASN1_ITEM_rptr(OCSP_REQUEST), (ASN1_VALUE *)(req)) +# define OCSP_REQ_CTX_nbio OSSL_HTTP_REQ_CTX_nbio +# define OCSP_REQ_CTX_nbio_d2i OSSL_HTTP_REQ_CTX_nbio_d2i +# define OCSP_sendreq_nbio(p, r) \ + OSSL_HTTP_REQ_CTX_nbio_d2i(r, (ASN1_VALUE **)(p), \ + ASN1_ITEM_rptr(OCSP_RESPONSE)) +# define OCSP_REQ_CTX_get0_mem_bio OSSL_HTTP_REQ_CTX_get0_mem_bio +# define OCSP_set_max_response_length OSSL_HTTP_REQ_CTX_set_max_response_length +# endif + +OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject, + const X509 *issuer); + +OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, + const X509_NAME *issuerName, + const ASN1_BIT_STRING *issuerKey, + const ASN1_INTEGER *serialNumber); + +OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); + +int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len); +int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len); +int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs); +int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); + +int OCSP_request_set1_name(OCSP_REQUEST *req, const X509_NAME *nm); +int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); + +int OCSP_request_sign(OCSP_REQUEST *req, + X509 *signer, + EVP_PKEY *key, + const EVP_MD *dgst, + STACK_OF(X509) *certs, unsigned long flags); + +int OCSP_response_status(OCSP_RESPONSE *resp); +OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); + +const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs); +const X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs); +const OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs); +int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer, + STACK_OF(X509) *extra_certs); + +int OCSP_resp_count(OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); +const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(const OCSP_BASICRESP* bs); +const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs); +int OCSP_resp_get0_id(const OCSP_BASICRESP *bs, + const ASN1_OCTET_STRING **pid, + const X509_NAME **pname); +int OCSP_resp_get1_id(const OCSP_BASICRESP *bs, + ASN1_OCTET_STRING **pid, + X509_NAME **pname); + +int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); +int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, + int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, + ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec); + +int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, + X509_STORE *store, unsigned long flags); + +# define OCSP_parse_url(url, host, port, path, ssl) \ + OSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL) + +int OCSP_id_issuer_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b); +int OCSP_id_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b); + +int OCSP_request_onereq_count(OCSP_REQUEST *req); +OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); +OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); +int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, + ASN1_OCTET_STRING **pikeyHash, + ASN1_INTEGER **pserial, OCSP_CERTID *cid); +int OCSP_request_is_signed(OCSP_REQUEST *req); +OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, + OCSP_CERTID *cid, + int status, int reason, + ASN1_TIME *revtime, + ASN1_TIME *thisupd, + ASN1_TIME *nextupd); +int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); +int OCSP_basic_sign(OCSP_BASICRESP *brsp, + X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, + STACK_OF(X509) *certs, unsigned long flags); +int OCSP_basic_sign_ctx(OCSP_BASICRESP *brsp, + X509 *signer, EVP_MD_CTX *ctx, + STACK_OF(X509) *certs, unsigned long flags); +int OCSP_RESPID_set_by_name(OCSP_RESPID *respid, X509 *cert); +int OCSP_RESPID_set_by_key_ex(OCSP_RESPID *respid, X509 *cert, + OSSL_LIB_CTX *libctx, const char *propq); +int OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert); +int OCSP_RESPID_match_ex(OCSP_RESPID *respid, X509 *cert, OSSL_LIB_CTX *libctx, + const char *propq); +int OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert); + +X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim); + +X509_EXTENSION *OCSP_accept_responses_new(char **oids); + +X509_EXTENSION *OCSP_archive_cutoff_new(char *tim); + +X509_EXTENSION *OCSP_url_svcloc_new(const X509_NAME *issuer, const char **urls); + +int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); +int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); +int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj, + int lastpos); +int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); +X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); +X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); +void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, + int *idx); +int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); + +int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); +int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); +int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos); +int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); +X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); +X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); +void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); +int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); + +int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); +int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); +int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj, + int lastpos); +int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, + int lastpos); +X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); +X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); +void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, + int *idx); +int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, + int crit, unsigned long flags); +int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); + +int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); +int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); +int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj, + int lastpos); +int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, + int lastpos); +X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); +X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); +void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, + int *idx); +int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, + int crit, unsigned long flags); +int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); +const OCSP_CERTID *OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x); + +DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS) +DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES) +DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTID) +DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST) +DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE) +DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) +DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) + +const char *OCSP_response_status_str(long s); +const char *OCSP_cert_status_str(long s); +const char *OCSP_crl_reason_str(long s); + +int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags); +int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags); + +int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, + X509_STORE *st, unsigned long flags); + + +# ifdef __cplusplus +} +# endif +# endif /* !defined(OPENSSL_NO_OCSP) */ +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ocsperr.h b/illumos-x86_64/usr/include/openssl-3/ocsperr.h new file mode 100644 index 00000000..46a0523c --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ocsperr.h @@ -0,0 +1,53 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_OCSPERR_H +# define OPENSSL_OCSPERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_OCSP + + +/* + * OCSP reason codes. + */ +# define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 +# define OCSP_R_DIGEST_ERR 102 +# define OCSP_R_DIGEST_NAME_ERR 106 +# define OCSP_R_DIGEST_SIZE_ERR 107 +# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 +# define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 +# define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 +# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 +# define OCSP_R_NOT_BASIC_RESPONSE 104 +# define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 +# define OCSP_R_NO_RESPONSE_DATA 108 +# define OCSP_R_NO_REVOKED_TIME 109 +# define OCSP_R_NO_SIGNER_KEY 130 +# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 +# define OCSP_R_REQUEST_NOT_SIGNED 128 +# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 +# define OCSP_R_ROOT_CA_NOT_TRUSTED 112 +# define OCSP_R_SIGNATURE_FAILURE 117 +# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 +# define OCSP_R_STATUS_EXPIRED 125 +# define OCSP_R_STATUS_NOT_YET_VALID 126 +# define OCSP_R_STATUS_TOO_OLD 127 +# define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 +# define OCSP_R_UNKNOWN_NID 120 +# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/opensslconf.h b/illumos-x86_64/usr/include/openssl-3/opensslconf.h new file mode 100644 index 00000000..1e83371f --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/opensslconf.h @@ -0,0 +1,17 @@ +/* + * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_OPENSSLCONF_H +# define OPENSSL_OPENSSLCONF_H +# pragma once + +# include +# include + +#endif /* OPENSSL_OPENSSLCONF_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/opensslv.h b/illumos-x86_64/usr/include/openssl-3/opensslv.h new file mode 100644 index 00000000..05af9abc --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/opensslv.h @@ -0,0 +1,109 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/opensslv.h.in + * + * Copyright 1999-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_OPENSSLV_H +# define OPENSSL_OPENSSLV_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * SECTION 1: VERSION DATA. These will change for each release + */ + +/* + * Base version macros + * + * These macros express version number MAJOR.MINOR.PATCH exactly + */ +# define OPENSSL_VERSION_MAJOR 3 +# define OPENSSL_VERSION_MINOR 5 +# define OPENSSL_VERSION_PATCH 4 + +/* + * Additional version information + * + * These are also part of the new version scheme, but aren't part + * of the version number itself. + */ + +/* Could be: #define OPENSSL_VERSION_PRE_RELEASE "-alpha.1" */ +# define OPENSSL_VERSION_PRE_RELEASE "" +/* Could be: #define OPENSSL_VERSION_BUILD_METADATA "+fips" */ +/* Could be: #define OPENSSL_VERSION_BUILD_METADATA "+vendor.1" */ +# define OPENSSL_VERSION_BUILD_METADATA "" + +/* + * Note: The OpenSSL Project will never define OPENSSL_VERSION_BUILD_METADATA + * to be anything but the empty string. Its use is entirely reserved for + * others + */ + +/* + * Shared library version + * + * This is strictly to express ABI version, which may or may not + * be related to the API version expressed with the macros above. + * This is defined in free form. + */ +# define OPENSSL_SHLIB_VERSION 3 + +/* + * SECTION 2: USEFUL MACROS + */ + +/* For checking general API compatibility when preprocessing */ +# define OPENSSL_VERSION_PREREQ(maj,min) \ + ((OPENSSL_VERSION_MAJOR << 16) + OPENSSL_VERSION_MINOR >= ((maj) << 16) + (min)) + +/* + * Macros to get the version in easily digested string form, both the short + * "MAJOR.MINOR.PATCH" variant (where MAJOR, MINOR and PATCH are replaced + * with the values from the corresponding OPENSSL_VERSION_ macros) and the + * longer variant with OPENSSL_VERSION_PRE_RELEASE_STR and + * OPENSSL_VERSION_BUILD_METADATA_STR appended. + */ +# define OPENSSL_VERSION_STR "3.5.4" +# define OPENSSL_FULL_VERSION_STR "3.5.4" + +/* + * SECTION 3: ADDITIONAL METADATA + * + * These strings are defined separately to allow them to be parsable. + */ +# define OPENSSL_RELEASE_DATE "30 Sep 2025" + +/* + * SECTION 4: BACKWARD COMPATIBILITY + */ + +# define OPENSSL_VERSION_TEXT "OpenSSL 3.5.4 30 Sep 2025" + +/* Synthesize OPENSSL_VERSION_NUMBER with the layout 0xMNN00PP0L */ +# define OPENSSL_VERSION_NUMBER \ + ( (OPENSSL_VERSION_MAJOR<<28) \ + |(OPENSSL_VERSION_MINOR<<20) \ + |(OPENSSL_VERSION_PATCH<<4) \ + |0x0L ) + +# ifdef __cplusplus +} +# endif + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_OPENSSLV_H +# endif + +#endif /* OPENSSL_OPENSSLV_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/ossl_typ.h b/illumos-x86_64/usr/include/openssl-3/ossl_typ.h new file mode 100644 index 00000000..82a58988 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ossl_typ.h @@ -0,0 +1,16 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * The original was renamed to + * + * This header file only exists for compatibility reasons with older + * applications which #include . + */ +# include diff --git a/illumos-x86_64/usr/include/openssl-3/param_build.h b/illumos-x86_64/usr/include/openssl-3/param_build.h new file mode 100644 index 00000000..f29fdb29 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/param_build.h @@ -0,0 +1,63 @@ +/* + * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PARAM_BUILD_H +# define OPENSSL_PARAM_BUILD_H +# pragma once + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +OSSL_PARAM_BLD *OSSL_PARAM_BLD_new(void); +OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld); +void OSSL_PARAM_BLD_free(OSSL_PARAM_BLD *bld); + +int OSSL_PARAM_BLD_push_int(OSSL_PARAM_BLD *bld, const char *key, int val); +int OSSL_PARAM_BLD_push_uint(OSSL_PARAM_BLD *bld, const char *key, + unsigned int val); +int OSSL_PARAM_BLD_push_long(OSSL_PARAM_BLD *bld, const char *key, + long int val); +int OSSL_PARAM_BLD_push_ulong(OSSL_PARAM_BLD *bld, const char *key, + unsigned long int val); +int OSSL_PARAM_BLD_push_int32(OSSL_PARAM_BLD *bld, const char *key, + int32_t val); +int OSSL_PARAM_BLD_push_uint32(OSSL_PARAM_BLD *bld, const char *key, + uint32_t val); +int OSSL_PARAM_BLD_push_int64(OSSL_PARAM_BLD *bld, const char *key, + int64_t val); +int OSSL_PARAM_BLD_push_uint64(OSSL_PARAM_BLD *bld, const char *key, + uint64_t val); +int OSSL_PARAM_BLD_push_size_t(OSSL_PARAM_BLD *bld, const char *key, + size_t val); +int OSSL_PARAM_BLD_push_time_t(OSSL_PARAM_BLD *bld, const char *key, + time_t val); +int OSSL_PARAM_BLD_push_double(OSSL_PARAM_BLD *bld, const char *key, + double val); +int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key, + const BIGNUM *bn); +int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key, + const BIGNUM *bn, size_t sz); +int OSSL_PARAM_BLD_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key, + const char *buf, size_t bsize); +int OSSL_PARAM_BLD_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key, + char *buf, size_t bsize); +int OSSL_PARAM_BLD_push_octet_string(OSSL_PARAM_BLD *bld, const char *key, + const void *buf, size_t bsize); +int OSSL_PARAM_BLD_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key, + void *buf, size_t bsize); + +# ifdef __cplusplus +} +# endif +#endif /* OPENSSL_PARAM_BUILD_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/params.h b/illumos-x86_64/usr/include/openssl-3/params.h new file mode 100644 index 00000000..d4b855df --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/params.h @@ -0,0 +1,163 @@ +/* + * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PARAMS_H +# define OPENSSL_PARAMS_H +# pragma once + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define OSSL_PARAM_UNMODIFIED ((size_t)-1) + +# define OSSL_PARAM_END \ + { NULL, 0, NULL, 0, 0 } + +# define OSSL_PARAM_DEFN(key, type, addr, sz) \ + { (key), (type), (addr), (sz), OSSL_PARAM_UNMODIFIED } + +/* Basic parameter types without return sizes */ +# define OSSL_PARAM_int(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int)) +# define OSSL_PARAM_uint(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(unsigned int)) +# define OSSL_PARAM_long(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int)) +# define OSSL_PARAM_ulong(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(unsigned long int)) +# define OSSL_PARAM_int32(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t)) +# define OSSL_PARAM_uint32(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(uint32_t)) +# define OSSL_PARAM_int64(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t)) +# define OSSL_PARAM_uint64(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(uint64_t)) +# define OSSL_PARAM_size_t(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t)) +# define OSSL_PARAM_time_t(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(time_t)) +# define OSSL_PARAM_double(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double)) + +# define OSSL_PARAM_BN(key, bn, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (bn), (sz)) +# define OSSL_PARAM_utf8_string(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz) +# define OSSL_PARAM_octet_string(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz) + +# define OSSL_PARAM_utf8_ptr(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, (addr), sz) +# define OSSL_PARAM_octet_ptr(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, (addr), sz) + +/* Search an OSSL_PARAM array for a matching name */ +OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *p, const char *key); +const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *p, const char *key); + +/* Basic parameter type run-time construction */ +OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf); +OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf); +OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf); +OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf); +OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf); +OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf); +OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf); +OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf); +OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf); +OSSL_PARAM OSSL_PARAM_construct_time_t(const char *key, time_t *buf); +OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf); +OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_end(void); + +int OSSL_PARAM_allocate_from_text(OSSL_PARAM *to, + const OSSL_PARAM *paramdefs, + const char *key, const char *value, + size_t value_n, int *found); + +int OSSL_PARAM_print_to_bio(const OSSL_PARAM *params, BIO *bio, + int print_values); + +int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val); +int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val); +int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val); +int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val); +int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val); +int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val); +int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val); +int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val); +int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val); +int OSSL_PARAM_get_time_t(const OSSL_PARAM *p, time_t *val); + +int OSSL_PARAM_set_int(OSSL_PARAM *p, int val); +int OSSL_PARAM_set_uint(OSSL_PARAM *p, unsigned int val); +int OSSL_PARAM_set_long(OSSL_PARAM *p, long int val); +int OSSL_PARAM_set_ulong(OSSL_PARAM *p, unsigned long int val); +int OSSL_PARAM_set_int32(OSSL_PARAM *p, int32_t val); +int OSSL_PARAM_set_uint32(OSSL_PARAM *p, uint32_t val); +int OSSL_PARAM_set_int64(OSSL_PARAM *p, int64_t val); +int OSSL_PARAM_set_uint64(OSSL_PARAM *p, uint64_t val); +int OSSL_PARAM_set_size_t(OSSL_PARAM *p, size_t val); +int OSSL_PARAM_set_time_t(OSSL_PARAM *p, time_t val); + +int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val); +int OSSL_PARAM_set_double(OSSL_PARAM *p, double val); + +int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val); +int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val); + +int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len); +int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val); + +int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, + size_t *used_len); +int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len); + +int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val); +int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val); + +int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, + size_t *used_len); +int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, + size_t used_len); + +int OSSL_PARAM_get_utf8_string_ptr(const OSSL_PARAM *p, const char **val); +int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val, + size_t *used_len); + +int OSSL_PARAM_modified(const OSSL_PARAM *p); +void OSSL_PARAM_set_all_unmodified(OSSL_PARAM *p); + +OSSL_PARAM *OSSL_PARAM_dup(const OSSL_PARAM *p); +OSSL_PARAM *OSSL_PARAM_merge(const OSSL_PARAM *p1, const OSSL_PARAM *p2); +void OSSL_PARAM_free(OSSL_PARAM *p); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/pem.h b/illumos-x86_64/usr/include/openssl-3/pem.h new file mode 100644 index 00000000..de1b6581 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/pem.h @@ -0,0 +1,548 @@ +/* + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PEM_H +# define OPENSSL_PEM_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_PEM_H +# endif + +# include +# include +# include +# include +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +# define PEM_BUFSIZE 1024 + +# define PEM_STRING_X509_OLD "X509 CERTIFICATE" +# define PEM_STRING_X509 "CERTIFICATE" +# define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" +# define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" +# define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" +# define PEM_STRING_X509_CRL "X509 CRL" +# define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" +# define PEM_STRING_PUBLIC "PUBLIC KEY" +# define PEM_STRING_RSA "RSA PRIVATE KEY" +# define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" +# define PEM_STRING_DSA "DSA PRIVATE KEY" +# define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" +# define PEM_STRING_PKCS7 "PKCS7" +# define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA" +# define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" +# define PEM_STRING_PKCS8INF "PRIVATE KEY" +# define PEM_STRING_DHPARAMS "DH PARAMETERS" +# define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS" +# define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" +# define PEM_STRING_DSAPARAMS "DSA PARAMETERS" +# define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" +# define PEM_STRING_ECPARAMETERS "EC PARAMETERS" +# define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" +# define PEM_STRING_PARAMETERS "PARAMETERS" +# define PEM_STRING_CMS "CMS" +# define PEM_STRING_SM2PRIVATEKEY "SM2 PRIVATE KEY" +# define PEM_STRING_SM2PARAMETERS "SM2 PARAMETERS" +# define PEM_STRING_ACERT "ATTRIBUTE CERTIFICATE" + +# define PEM_TYPE_ENCRYPTED 10 +# define PEM_TYPE_MIC_ONLY 20 +# define PEM_TYPE_MIC_CLEAR 30 +# define PEM_TYPE_CLEAR 40 + +/* + * These macros make the PEM_read/PEM_write functions easier to maintain and + * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or + * IMPLEMENT_PEM_rw_cb(...) + */ + +# define PEM_read_cb_fnsig(name, type, INTYPE, readname) \ + type *PEM_##readname##_##name(INTYPE *out, type **x, \ + pem_password_cb *cb, void *u) +# define PEM_read_cb_ex_fnsig(name, type, INTYPE, readname) \ + type *PEM_##readname##_##name##_ex(INTYPE *out, type **x, \ + pem_password_cb *cb, void *u, \ + OSSL_LIB_CTX *libctx, \ + const char *propq) + +# define PEM_write_fnsig(name, type, OUTTYPE, writename) \ + int PEM_##writename##_##name(OUTTYPE *out, const type *x) +# define PEM_write_cb_fnsig(name, type, OUTTYPE, writename) \ + int PEM_##writename##_##name(OUTTYPE *out, const type *x, \ + const EVP_CIPHER *enc, \ + const unsigned char *kstr, int klen, \ + pem_password_cb *cb, void *u) +# define PEM_write_ex_fnsig(name, type, OUTTYPE, writename) \ + int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x, \ + OSSL_LIB_CTX *libctx, \ + const char *propq) +# define PEM_write_cb_ex_fnsig(name, type, OUTTYPE, writename) \ + int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x, \ + const EVP_CIPHER *enc, \ + const unsigned char *kstr, int klen, \ + pem_password_cb *cb, void *u, \ + OSSL_LIB_CTX *libctx, \ + const char *propq) + +# ifdef OPENSSL_NO_STDIO + +# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ +# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/ +# endif +# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/ +# endif +# else + +# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ + type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u) \ + { \ + return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str, fp, \ + (void **)x, cb, u); \ + } + +# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ + PEM_write_fnsig(name, type, FILE, write) \ + { \ + return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, \ + x, NULL, NULL, 0, NULL, NULL); \ + } + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp(name, type, str, asn1) +# endif + +# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ + PEM_write_cb_fnsig(name, type, FILE, write) \ + { \ + return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, \ + x, enc, kstr, klen, cb, u); \ + } + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) +# endif +# endif + +# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ + type *PEM_read_bio_##name(BIO *bp, type **x, \ + pem_password_cb *cb, void *u) \ + { \ + return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str, bp, \ + (void **)x, cb, u); \ + } + +# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ + PEM_write_fnsig(name, type, BIO, write_bio) \ + { \ + return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, \ + x, NULL,NULL,0,NULL,NULL); \ + } + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio(name, type, str, asn1) +# endif + +# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ + PEM_write_cb_fnsig(name, type, BIO, write_bio) \ + { \ + return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, \ + x, enc, kstr, klen, cb, u); \ + } + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) +# endif + +# define IMPLEMENT_PEM_write(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp(name, type, str, asn1) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) +# endif + +# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) +# endif + +# define IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_read_fp(name, type, str, asn1) + +# define IMPLEMENT_PEM_rw(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write(name, type, str, asn1) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_const(name, type, str, asn1) +# endif + +# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb(name, type, str, asn1) + +/* These are the same except they are for the declarations */ + +/* + * The mysterious 'extern' that's passed to some macros is innocuous, + * and is there to quiet pre-C99 compilers that may complain about empty + * arguments in macro calls. + */ +# if defined(OPENSSL_NO_STDIO) + +# define DECLARE_PEM_read_fp_attr(attr, name, type) /**/ +# define DECLARE_PEM_read_fp_ex_attr(attr, name, type) /**/ +# define DECLARE_PEM_write_fp_attr(attr, name, type) /**/ +# define DECLARE_PEM_write_fp_ex_attr(attr, name, type) /**/ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_write_fp_const_attr(attr, name, type) /**/ +# endif +# define DECLARE_PEM_write_cb_fp_attr(attr, name, type) /**/ +# define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) /**/ + +# else + +# define DECLARE_PEM_read_fp_attr(attr, name, type) \ + attr PEM_read_cb_fnsig(name, type, FILE, read); +# define DECLARE_PEM_read_fp_ex_attr(attr, name, type) \ + attr PEM_read_cb_fnsig(name, type, FILE, read); \ + attr PEM_read_cb_ex_fnsig(name, type, FILE, read); + +# define DECLARE_PEM_write_fp_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, FILE, write); +# define DECLARE_PEM_write_fp_ex_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, FILE, write); \ + attr PEM_write_ex_fnsig(name, type, FILE, write); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_write_fp_const_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, FILE, write); +# endif +# define DECLARE_PEM_write_cb_fp_attr(attr, name, type) \ + attr PEM_write_cb_fnsig(name, type, FILE, write); +# define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) \ + attr PEM_write_cb_fnsig(name, type, FILE, write); \ + attr PEM_write_cb_ex_fnsig(name, type, FILE, write); + +# endif + +# define DECLARE_PEM_read_fp(name, type) \ + DECLARE_PEM_read_fp_attr(extern, name, type) +# define DECLARE_PEM_write_fp(name, type) \ + DECLARE_PEM_write_fp_attr(extern, name, type) +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_write_fp_const(name, type) \ + DECLARE_PEM_write_fp_const_attr(extern, name, type) +# endif +# define DECLARE_PEM_write_cb_fp(name, type) \ + DECLARE_PEM_write_cb_fp_attr(extern, name, type) + +# define DECLARE_PEM_read_bio_attr(attr, name, type) \ + attr PEM_read_cb_fnsig(name, type, BIO, read_bio); +# define DECLARE_PEM_read_bio_ex_attr(attr, name, type) \ + attr PEM_read_cb_fnsig(name, type, BIO, read_bio); \ + attr PEM_read_cb_ex_fnsig(name, type, BIO, read_bio); +# define DECLARE_PEM_read_bio(name, type) \ + DECLARE_PEM_read_bio_attr(extern, name, type) +# define DECLARE_PEM_read_bio_ex(name, type) \ + DECLARE_PEM_read_bio_ex_attr(extern, name, type) + +# define DECLARE_PEM_write_bio_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, BIO, write_bio); +# define DECLARE_PEM_write_bio_ex_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, BIO, write_bio); \ + attr PEM_write_ex_fnsig(name, type, BIO, write_bio); +# define DECLARE_PEM_write_bio(name, type) \ + DECLARE_PEM_write_bio_attr(extern, name, type) +# define DECLARE_PEM_write_bio_ex(name, type) \ + DECLARE_PEM_write_bio_ex_attr(extern, name, type) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_write_bio_const_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, BIO, write_bio); +# define DECLARE_PEM_write_bio_const(name, type) \ + DECLARE_PEM_write_bio_const_attr(extern, name, type) +# endif + +# define DECLARE_PEM_write_cb_bio_attr(attr, name, type) \ + attr PEM_write_cb_fnsig(name, type, BIO, write_bio); +# define DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type) \ + attr PEM_write_cb_fnsig(name, type, BIO, write_bio); \ + attr PEM_write_cb_ex_fnsig(name, type, BIO, write_bio); +# define DECLARE_PEM_write_cb_bio(name, type) \ + DECLARE_PEM_write_cb_bio_attr(extern, name, type) +# define DECLARE_PEM_write_cb_ex_bio(name, type) \ + DECLARE_PEM_write_cb_bio_ex_attr(extern, name, type) + +# define DECLARE_PEM_write_attr(attr, name, type) \ + DECLARE_PEM_write_bio_attr(attr, name, type) \ + DECLARE_PEM_write_fp_attr(attr, name, type) +# define DECLARE_PEM_write_ex_attr(attr, name, type) \ + DECLARE_PEM_write_bio_ex_attr(attr, name, type) \ + DECLARE_PEM_write_fp_ex_attr(attr, name, type) +# define DECLARE_PEM_write(name, type) \ + DECLARE_PEM_write_attr(extern, name, type) +# define DECLARE_PEM_write_ex(name, type) \ + DECLARE_PEM_write_ex_attr(extern, name, type) +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_write_const_attr(attr, name, type) \ + DECLARE_PEM_write_bio_const_attr(attr, name, type) \ + DECLARE_PEM_write_fp_const_attr(attr, name, type) +# define DECLARE_PEM_write_const(name, type) \ + DECLARE_PEM_write_const_attr(extern, name, type) +# endif +# define DECLARE_PEM_write_cb_attr(attr, name, type) \ + DECLARE_PEM_write_cb_bio_attr(attr, name, type) \ + DECLARE_PEM_write_cb_fp_attr(attr, name, type) +# define DECLARE_PEM_write_cb_ex_attr(attr, name, type) \ + DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type) \ + DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) +# define DECLARE_PEM_write_cb(name, type) \ + DECLARE_PEM_write_cb_attr(extern, name, type) +# define DECLARE_PEM_write_cb_ex(name, type) \ + DECLARE_PEM_write_cb_ex_attr(extern, name, type) +# define DECLARE_PEM_read_attr(attr, name, type) \ + DECLARE_PEM_read_bio_attr(attr, name, type) \ + DECLARE_PEM_read_fp_attr(attr, name, type) +# define DECLARE_PEM_read_ex_attr(attr, name, type) \ + DECLARE_PEM_read_bio_ex_attr(attr, name, type) \ + DECLARE_PEM_read_fp_ex_attr(attr, name, type) +# define DECLARE_PEM_read(name, type) \ + DECLARE_PEM_read_attr(extern, name, type) +# define DECLARE_PEM_read_ex(name, type) \ + DECLARE_PEM_read_ex_attr(extern, name, type) +# define DECLARE_PEM_rw_attr(attr, name, type) \ + DECLARE_PEM_read_attr(attr, name, type) \ + DECLARE_PEM_write_attr(attr, name, type) +# define DECLARE_PEM_rw_ex_attr(attr, name, type) \ + DECLARE_PEM_read_ex_attr(attr, name, type) \ + DECLARE_PEM_write_ex_attr(attr, name, type) +# define DECLARE_PEM_rw(name, type) \ + DECLARE_PEM_rw_attr(extern, name, type) +# define DECLARE_PEM_rw_ex(name, type) \ + DECLARE_PEM_rw_ex_attr(extern, name, type) +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_rw_const_attr(attr, name, type) \ + DECLARE_PEM_read_attr(attr, name, type) \ + DECLARE_PEM_write_const_attr(attr, name, type) +# define DECLARE_PEM_rw_const(name, type) \ + DECLARE_PEM_rw_const_attr(extern, name, type) +# endif +# define DECLARE_PEM_rw_cb_attr(attr, name, type) \ + DECLARE_PEM_read_attr(attr, name, type) \ + DECLARE_PEM_write_cb_attr(attr, name, type) +# define DECLARE_PEM_rw_cb_ex_attr(attr, name, type) \ + DECLARE_PEM_read_ex_attr(attr, name, type) \ + DECLARE_PEM_write_cb_ex_attr(attr, name, type) +# define DECLARE_PEM_rw_cb(name, type) \ + DECLARE_PEM_rw_cb_attr(extern, name, type) +# define DECLARE_PEM_rw_cb_ex(name, type) \ + DECLARE_PEM_rw_cb_ex_attr(extern, name, type) + +int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); +int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len, + pem_password_cb *callback, void *u); + +int PEM_read_bio(BIO *bp, char **name, char **header, + unsigned char **data, long *len); +# define PEM_FLAG_SECURE 0x1 +# define PEM_FLAG_EAY_COMPATIBLE 0x2 +# define PEM_FLAG_ONLY_B64 0x4 +int PEM_read_bio_ex(BIO *bp, char **name, char **header, + unsigned char **data, long *len, unsigned int flags); +int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm, + const char *name, BIO *bp, pem_password_cb *cb, + void *u); +int PEM_write_bio(BIO *bp, const char *name, const char *hdr, + const unsigned char *data, long len); +int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, + const char *name, BIO *bp, pem_password_cb *cb, + void *u); +void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, + pem_password_cb *cb, void *u); +int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, + const void *x, const EVP_CIPHER *enc, + const unsigned char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_ASN1_write_bio_ctx(OSSL_i2d_of_void_ctx *i2d, void *vctx, + const char *name, BIO *bp, const void *x, + const EVP_CIPHER *enc, const unsigned char *kstr, + int klen, pem_password_cb *cb, void *u); + +STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, + pem_password_cb *cb, void *u); +STACK_OF(X509_INFO) +*PEM_X509_INFO_read_bio_ex(BIO *bp, STACK_OF(X509_INFO) *sk, + pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx, + const char *propq); + +int PEM_X509_INFO_write_bio(BIO *bp, const X509_INFO *xi, EVP_CIPHER *enc, + const unsigned char *kstr, int klen, + pem_password_cb *cd, void *u); + +#ifndef OPENSSL_NO_STDIO +int PEM_read(FILE *fp, char **name, char **header, + unsigned char **data, long *len); +int PEM_write(FILE *fp, const char *name, const char *hdr, + const unsigned char *data, long len); +void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, + pem_password_cb *cb, void *u); +int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, + const void *x, const EVP_CIPHER *enc, + const unsigned char *kstr, int klen, + pem_password_cb *callback, void *u); +STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, + pem_password_cb *cb, void *u); +STACK_OF(X509_INFO) +*PEM_X509_INFO_read_ex(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, + void *u, OSSL_LIB_CTX *libctx, const char *propq); +#endif + +int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); +int PEM_SignUpdate(EVP_MD_CTX *ctx, const unsigned char *d, unsigned int cnt); +int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + unsigned int *siglen, EVP_PKEY *pkey); + +/* The default pem_password_cb that's used internally */ +int PEM_def_callback(char *buf, int num, int rwflag, void *userdata); +void PEM_proc_type(char *buf, int type); +void PEM_dek_info(char *buf, const char *type, int len, const char *str); + +# include + +DECLARE_PEM_rw(X509, X509) +DECLARE_PEM_rw(X509_AUX, X509) +DECLARE_PEM_rw(X509_REQ, X509_REQ) +DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) +DECLARE_PEM_rw(X509_CRL, X509_CRL) +DECLARE_PEM_rw(X509_PUBKEY, X509_PUBKEY) +DECLARE_PEM_rw(PKCS7, PKCS7) +DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) +DECLARE_PEM_rw(PKCS8, X509_SIG) +DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) +# ifndef OPENSSL_NO_DEPRECATED_3_0 +DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, RSAPrivateKey, RSA) +DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSAPublicKey, RSA) +DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSA_PUBKEY, RSA) +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DSA +DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, DSAPrivateKey, DSA) +DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSA_PUBKEY, DSA) +DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSAparams, DSA) +# endif +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_EC +DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, ECPKParameters, EC_GROUP) +DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, ECPrivateKey, EC_KEY) +DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, EC_PUBKEY, EC_KEY) +# endif +# endif + +# ifndef OPENSSL_NO_DH +# ifndef OPENSSL_NO_DEPRECATED_3_0 +DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DHparams, DH) +DECLARE_PEM_write_attr(OSSL_DEPRECATEDIN_3_0, DHxparams, DH) +# endif +# endif +DECLARE_PEM_rw_cb_ex(PrivateKey, EVP_PKEY) +DECLARE_PEM_rw_ex(PUBKEY, EVP_PKEY) + +int PEM_write_bio_PrivateKey_traditional(BIO *bp, const EVP_PKEY *x, + const EVP_CIPHER *enc, + const unsigned char *kstr, int klen, + pem_password_cb *cb, void *u); + +/* Why do these take a signed char *kstr? */ +int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, int nid, + const char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_bio_PKCS8PrivateKey(BIO *, const EVP_PKEY *, const EVP_CIPHER *, + const char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc, + const char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid, + const char *kstr, int klen, + pem_password_cb *cb, void *u); +EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, + void *u); + +# ifndef OPENSSL_NO_STDIO +int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc, + const char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid, + const char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, int nid, + const char *kstr, int klen, + pem_password_cb *cb, void *u); + +EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, + void *u); + +int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc, + const char *kstr, int klen, + pem_password_cb *cd, void *u); +# endif +EVP_PKEY *PEM_read_bio_Parameters_ex(BIO *bp, EVP_PKEY **x, + OSSL_LIB_CTX *libctx, const char *propq); +EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); +int PEM_write_bio_Parameters(BIO *bp, const EVP_PKEY *x); + +EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length); +EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length); +EVP_PKEY *b2i_PrivateKey_bio(BIO *in); +EVP_PKEY *b2i_PublicKey_bio(BIO *in); +int i2b_PrivateKey_bio(BIO *out, const EVP_PKEY *pk); +int i2b_PublicKey_bio(BIO *out, const EVP_PKEY *pk); +EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u); +EVP_PKEY *b2i_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u, + OSSL_LIB_CTX *libctx, const char *propq); +int i2b_PVK_bio(BIO *out, const EVP_PKEY *pk, int enclevel, + pem_password_cb *cb, void *u); +int i2b_PVK_bio_ex(BIO *out, const EVP_PKEY *pk, int enclevel, + pem_password_cb *cb, void *u, + OSSL_LIB_CTX *libctx, const char *propq); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/pem2.h b/illumos-x86_64/usr/include/openssl-3/pem2.h new file mode 100644 index 00000000..a8a5325b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/pem2.h @@ -0,0 +1,19 @@ +/* + * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PEM2_H +# define OPENSSL_PEM2_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_PEM2_H +# endif +# include +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/pemerr.h b/illumos-x86_64/usr/include/openssl-3/pemerr.h new file mode 100644 index 00000000..3530775b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/pemerr.h @@ -0,0 +1,59 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PEMERR_H +# define OPENSSL_PEMERR_H +# pragma once + +# include +# include +# include + + + +/* + * PEM reason codes. + */ +# define PEM_R_BAD_BASE64_DECODE 100 +# define PEM_R_BAD_DECRYPT 101 +# define PEM_R_BAD_END_LINE 102 +# define PEM_R_BAD_IV_CHARS 103 +# define PEM_R_BAD_MAGIC_NUMBER 116 +# define PEM_R_BAD_PASSWORD_READ 104 +# define PEM_R_BAD_VERSION_NUMBER 117 +# define PEM_R_BIO_WRITE_FAILURE 118 +# define PEM_R_CIPHER_IS_NULL 127 +# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 +# define PEM_R_EXPECTING_DSS_KEY_BLOB 131 +# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119 +# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120 +# define PEM_R_EXPECTING_RSA_KEY_BLOB 132 +# define PEM_R_HEADER_TOO_LONG 128 +# define PEM_R_INCONSISTENT_HEADER 121 +# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122 +# define PEM_R_KEYBLOB_TOO_SHORT 123 +# define PEM_R_MISSING_DEK_IV 129 +# define PEM_R_NOT_DEK_INFO 105 +# define PEM_R_NOT_ENCRYPTED 106 +# define PEM_R_NOT_PROC_TYPE 107 +# define PEM_R_NO_START_LINE 108 +# define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +# define PEM_R_PVK_DATA_TOO_SHORT 124 +# define PEM_R_PVK_TOO_SHORT 125 +# define PEM_R_READ_KEY 111 +# define PEM_R_SHORT_HEADER 112 +# define PEM_R_UNEXPECTED_DEK_IV 130 +# define PEM_R_UNSUPPORTED_CIPHER 113 +# define PEM_R_UNSUPPORTED_ENCRYPTION 114 +# define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126 +# define PEM_R_UNSUPPORTED_PUBLIC_KEY_TYPE 110 +# define PEM_R_UNSUPPORTED_PVK_KEY_TYPE 133 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/pkcs12.h b/illumos-x86_64/usr/include/openssl-3/pkcs12.h new file mode 100644 index 00000000..0809645d --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/pkcs12.h @@ -0,0 +1,366 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/pkcs12.h.in + * + * Copyright 1999-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_PKCS12_H +# define OPENSSL_PKCS12_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_PKCS12_H +# endif + +# include +# include +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +# define PKCS12_KEY_ID 1 +# define PKCS12_IV_ID 2 +# define PKCS12_MAC_ID 3 + +/* Default iteration count */ +# ifndef PKCS12_DEFAULT_ITER +# define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER +# endif + +# define PKCS12_MAC_KEY_LENGTH 20 + +/* The macro is expected to be used only internally. Kept for backwards compatibility. */ +# define PKCS12_SALT_LEN 8 + +/* It's not clear if these are actually needed... */ +# define PKCS12_key_gen PKCS12_key_gen_utf8 +# define PKCS12_add_friendlyname PKCS12_add_friendlyname_utf8 + +/* MS key usage constants */ + +# define KEY_EX 0x10 +# define KEY_SIG 0x80 + +typedef struct PKCS12_MAC_DATA_st PKCS12_MAC_DATA; + +typedef struct PKCS12_st PKCS12; + +typedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG; + +SKM_DEFINE_STACK_OF_INTERNAL(PKCS12_SAFEBAG, PKCS12_SAFEBAG, PKCS12_SAFEBAG) +#define sk_PKCS12_SAFEBAG_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_value(sk, idx) ((PKCS12_SAFEBAG *)OPENSSL_sk_value(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk), (idx))) +#define sk_PKCS12_SAFEBAG_new(cmp) ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new(ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp))) +#define sk_PKCS12_SAFEBAG_new_null() ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new_null()) +#define sk_PKCS12_SAFEBAG_new_reserve(cmp, n) ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new_reserve(ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp), (n))) +#define sk_PKCS12_SAFEBAG_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PKCS12_SAFEBAG_sk_type(sk), (n)) +#define sk_PKCS12_SAFEBAG_free(sk) OPENSSL_sk_free(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_delete(sk, i) ((PKCS12_SAFEBAG *)OPENSSL_sk_delete(ossl_check_PKCS12_SAFEBAG_sk_type(sk), (i))) +#define sk_PKCS12_SAFEBAG_delete_ptr(sk, ptr) ((PKCS12_SAFEBAG *)OPENSSL_sk_delete_ptr(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr))) +#define sk_PKCS12_SAFEBAG_push(sk, ptr) OPENSSL_sk_push(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr)) +#define sk_PKCS12_SAFEBAG_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr)) +#define sk_PKCS12_SAFEBAG_pop(sk) ((PKCS12_SAFEBAG *)OPENSSL_sk_pop(ossl_check_PKCS12_SAFEBAG_sk_type(sk))) +#define sk_PKCS12_SAFEBAG_shift(sk) ((PKCS12_SAFEBAG *)OPENSSL_sk_shift(ossl_check_PKCS12_SAFEBAG_sk_type(sk))) +#define sk_PKCS12_SAFEBAG_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_PKCS12_SAFEBAG_sk_type(sk),ossl_check_PKCS12_SAFEBAG_freefunc_type(freefunc)) +#define sk_PKCS12_SAFEBAG_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr), (idx)) +#define sk_PKCS12_SAFEBAG_set(sk, idx, ptr) ((PKCS12_SAFEBAG *)OPENSSL_sk_set(ossl_check_PKCS12_SAFEBAG_sk_type(sk), (idx), ossl_check_PKCS12_SAFEBAG_type(ptr))) +#define sk_PKCS12_SAFEBAG_find(sk, ptr) OPENSSL_sk_find(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr)) +#define sk_PKCS12_SAFEBAG_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr)) +#define sk_PKCS12_SAFEBAG_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr), pnum) +#define sk_PKCS12_SAFEBAG_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_dup(sk) ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_dup(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk))) +#define sk_PKCS12_SAFEBAG_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_deep_copy(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_copyfunc_type(copyfunc), ossl_check_PKCS12_SAFEBAG_freefunc_type(freefunc))) +#define sk_PKCS12_SAFEBAG_set_cmp_func(sk, cmp) ((sk_PKCS12_SAFEBAG_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp))) + + +typedef struct pkcs12_bag_st PKCS12_BAGS; + +# define PKCS12_ERROR 0 +# define PKCS12_OK 1 + +/* Compatibility macros */ + +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 + +# define M_PKCS12_bag_type PKCS12_bag_type +# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type +# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type + +# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert +# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl +# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid +# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid +# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert +# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl +# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf +# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt + +#endif +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, + int attr_nid); +#endif + +ASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid); +int PKCS12_mac_present(const PKCS12 *p12); +void PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac, + const X509_ALGOR **pmacalg, + const ASN1_OCTET_STRING **psalt, + const ASN1_INTEGER **piter, + const PKCS12 *p12); + +const ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag, + int attr_nid); +const ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag); +int PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag); +int PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag); +const ASN1_TYPE *PKCS12_SAFEBAG_get0_bag_obj(const PKCS12_SAFEBAG *bag); +const ASN1_OBJECT *PKCS12_SAFEBAG_get0_bag_type(const PKCS12_SAFEBAG *bag); + +X509 *PKCS12_SAFEBAG_get1_cert_ex(const PKCS12_SAFEBAG *bag, OSSL_LIB_CTX *libctx, const char *propq); +X509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag); +X509_CRL *PKCS12_SAFEBAG_get1_crl_ex(const PKCS12_SAFEBAG *bag, OSSL_LIB_CTX *libctx, const char *propq); +X509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag); +const STACK_OF(PKCS12_SAFEBAG) * +PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag); +const PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag); +const X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag); + +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509); +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl); +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_secret(int type, int vtype, const unsigned char *value, int len); +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8); +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8); +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, + const char *pass, + int passlen, + unsigned char *salt, + int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8inf); +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt_ex(int pbe_nid, + const char *pass, + int passlen, + unsigned char *salt, + int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *ctx, + const char *propq); + +PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, + int nid1, int nid2); +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass, + int passlen); +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt_ex(const X509_SIG *p8, const char *pass, + int passlen, OSSL_LIB_CTX *ctx, + const char *propq); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, + const char *pass, int passlen); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey_ex(const PKCS12_SAFEBAG *bag, + const char *pass, int passlen, + OSSL_LIB_CTX *ctx, + const char *propq); +X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, + const char *pass, int passlen, unsigned char *salt, + int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8); +X509_SIG *PKCS8_encrypt_ex(int pbe_nid, const EVP_CIPHER *cipher, + const char *pass, int passlen, unsigned char *salt, + int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8, + OSSL_LIB_CTX *ctx, const char *propq); +X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen, + PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe); +X509_SIG *PKCS8_set0_pbe_ex(const char *pass, int passlen, + PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe, + OSSL_LIB_CTX *ctx, const char *propq); +PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); +PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + STACK_OF(PKCS12_SAFEBAG) *bags); +PKCS7 *PKCS12_pack_p7encdata_ex(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + STACK_OF(PKCS12_SAFEBAG) *bags, + OSSL_LIB_CTX *ctx, const char *propq); + +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, + int passlen); + +int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); +STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12); + +int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, + int namelen); +int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, + const unsigned char *name, int namelen); +int PKCS12_add1_attr_by_NID(PKCS12_SAFEBAG *bag, int nid, int type, + const unsigned char *bytes, int len); +int PKCS12_add1_attr_by_txt(PKCS12_SAFEBAG *bag, const char *attrname, int type, + const unsigned char *bytes, int len); +int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); +ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs, + int attr_nid); +char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); +const STACK_OF(X509_ATTRIBUTE) * +PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag); +void PKCS12_SAFEBAG_set0_attrs(PKCS12_SAFEBAG *bag, STACK_OF(X509_ATTRIBUTE) *attrs); +unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor, + const char *pass, int passlen, + const unsigned char *in, int inlen, + unsigned char **data, int *datalen, + int en_de); +unsigned char *PKCS12_pbe_crypt_ex(const X509_ALGOR *algor, + const char *pass, int passlen, + const unsigned char *in, int inlen, + unsigned char **data, int *datalen, + int en_de, OSSL_LIB_CTX *libctx, + const char *propq); +void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, + const ASN1_OCTET_STRING *oct, int zbuf); +void *PKCS12_item_decrypt_d2i_ex(const X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, + const ASN1_OCTET_STRING *oct, int zbuf, + OSSL_LIB_CTX *libctx, + const char *propq); +ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, + const ASN1_ITEM *it, + const char *pass, int passlen, + void *obj, int zbuf); +ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt_ex(X509_ALGOR *algor, + const ASN1_ITEM *it, + const char *pass, int passlen, + void *obj, int zbuf, + OSSL_LIB_CTX *ctx, + const char *propq); +PKCS12 *PKCS12_init(int mode); +PKCS12 *PKCS12_init_ex(int mode, OSSL_LIB_CTX *ctx, const char *propq); + +int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type); +int PKCS12_key_gen_asc_ex(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type, + OSSL_LIB_CTX *ctx, const char *propq); +int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type); +int PKCS12_key_gen_uni_ex(unsigned char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type, + OSSL_LIB_CTX *ctx, const char *propq); +int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type); +int PKCS12_key_gen_utf8_ex(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type, + OSSL_LIB_CTX *ctx, const char *propq); + +int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md_type, int en_de); +int PKCS12_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md_type, int en_de, + OSSL_LIB_CTX *libctx, const char *propq); +int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *mac, unsigned int *maclen); +int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); +int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + const EVP_MD *md_type); +int PKCS12_set_pbmac1_pbkdf2(PKCS12 *p12, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + const EVP_MD *md_type, const char *prf_md_name); +int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, + int saltlen, const EVP_MD *md_type); +unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, + unsigned char **uni, int *unilen); +char *OPENSSL_uni2asc(const unsigned char *uni, int unilen); +unsigned char *OPENSSL_utf82uni(const char *asc, int asclen, + unsigned char **uni, int *unilen); +char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen); + +DECLARE_ASN1_FUNCTIONS(PKCS12) +DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) +DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) +DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) + +DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) +DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) + +void PKCS12_PBE_add(void); +int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, + STACK_OF(X509) **ca); +typedef int PKCS12_create_cb(PKCS12_SAFEBAG *bag, void *cbarg); +PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, + X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, + int iter, int mac_iter, int keytype); +PKCS12 *PKCS12_create_ex(const char *pass, const char *name, EVP_PKEY *pkey, + X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, + int iter, int mac_iter, int keytype, + OSSL_LIB_CTX *ctx, const char *propq); +PKCS12 *PKCS12_create_ex2(const char *pass, const char *name, EVP_PKEY *pkey, + X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, + int iter, int mac_iter, int keytype, + OSSL_LIB_CTX *ctx, const char *propq, + PKCS12_create_cb *cb, void *cbarg); + +PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); +PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, + EVP_PKEY *key, int key_usage, int iter, + int key_nid, const char *pass); +PKCS12_SAFEBAG *PKCS12_add_key_ex(STACK_OF(PKCS12_SAFEBAG) **pbags, + EVP_PKEY *key, int key_usage, int iter, + int key_nid, const char *pass, + OSSL_LIB_CTX *ctx, const char *propq); + +PKCS12_SAFEBAG *PKCS12_add_secret(STACK_OF(PKCS12_SAFEBAG) **pbags, + int nid_type, const unsigned char *value, int len); +int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, + int safe_nid, int iter, const char *pass); +int PKCS12_add_safe_ex(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, + int safe_nid, int iter, const char *pass, + OSSL_LIB_CTX *ctx, const char *propq); + +PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); +PKCS12 *PKCS12_add_safes_ex(STACK_OF(PKCS7) *safes, int p7_nid, + OSSL_LIB_CTX *ctx, const char *propq); + +int i2d_PKCS12_bio(BIO *bp, const PKCS12 *p12); +# ifndef OPENSSL_NO_STDIO +int i2d_PKCS12_fp(FILE *fp, const PKCS12 *p12); +# endif +PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); +# ifndef OPENSSL_NO_STDIO +PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); +# endif +int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/pkcs12err.h b/illumos-x86_64/usr/include/openssl-3/pkcs12err.h new file mode 100644 index 00000000..abce3736 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/pkcs12err.h @@ -0,0 +1,46 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PKCS12ERR_H +# define OPENSSL_PKCS12ERR_H +# pragma once + +# include +# include +# include + + + +/* + * PKCS12 reason codes. + */ +# define PKCS12_R_CALLBACK_FAILED 115 +# define PKCS12_R_CANT_PACK_STRUCTURE 100 +# define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 +# define PKCS12_R_DECODE_ERROR 101 +# define PKCS12_R_ENCODE_ERROR 102 +# define PKCS12_R_ENCRYPT_ERROR 103 +# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 +# define PKCS12_R_INVALID_NULL_ARGUMENT 104 +# define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 +# define PKCS12_R_INVALID_TYPE 112 +# define PKCS12_R_IV_GEN_ERROR 106 +# define PKCS12_R_KEY_GEN_ERROR 107 +# define PKCS12_R_MAC_ABSENT 108 +# define PKCS12_R_MAC_GENERATION_ERROR 109 +# define PKCS12_R_MAC_SETUP_ERROR 110 +# define PKCS12_R_MAC_STRING_SET_ERROR 111 +# define PKCS12_R_MAC_VERIFY_FAILURE 113 +# define PKCS12_R_PARSE_ERROR 114 +# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 +# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 +# define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/pkcs7.h b/illumos-x86_64/usr/include/openssl-3/pkcs7.h new file mode 100644 index 00000000..fa68462a --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/pkcs7.h @@ -0,0 +1,430 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/pkcs7.h.in + * + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_PKCS7_H +# define OPENSSL_PKCS7_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_PKCS7_H +# endif + +# include +# include +# include + +# include +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/*- +Encryption_ID DES-CBC +Digest_ID MD5 +Digest_Encryption_ID rsaEncryption +Key_Encryption_ID rsaEncryption +*/ + +typedef struct PKCS7_CTX_st { + OSSL_LIB_CTX *libctx; + char *propq; +} PKCS7_CTX; + +typedef struct pkcs7_issuer_and_serial_st { + X509_NAME *issuer; + ASN1_INTEGER *serial; +} PKCS7_ISSUER_AND_SERIAL; + +typedef struct pkcs7_signer_info_st { + ASN1_INTEGER *version; /* version 1 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *digest_alg; + STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ + X509_ALGOR *digest_enc_alg; /* confusing name, actually used for signing */ + ASN1_OCTET_STRING *enc_digest; /* confusing name, actually signature */ + STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ + /* The private key to sign with */ + EVP_PKEY *pkey; + const PKCS7_CTX *ctx; +} PKCS7_SIGNER_INFO; +SKM_DEFINE_STACK_OF_INTERNAL(PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO) +#define sk_PKCS7_SIGNER_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_value(sk, idx) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_value(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk), (idx))) +#define sk_PKCS7_SIGNER_INFO_new(cmp) ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new(ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp))) +#define sk_PKCS7_SIGNER_INFO_new_null() ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new_null()) +#define sk_PKCS7_SIGNER_INFO_new_reserve(cmp, n) ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new_reserve(ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp), (n))) +#define sk_PKCS7_SIGNER_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (n)) +#define sk_PKCS7_SIGNER_INFO_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_delete(sk, i) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_delete(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (i))) +#define sk_PKCS7_SIGNER_INFO_delete_ptr(sk, ptr) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr))) +#define sk_PKCS7_SIGNER_INFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr)) +#define sk_PKCS7_SIGNER_INFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr)) +#define sk_PKCS7_SIGNER_INFO_pop(sk) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_pop(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk))) +#define sk_PKCS7_SIGNER_INFO_shift(sk) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_shift(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk))) +#define sk_PKCS7_SIGNER_INFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk),ossl_check_PKCS7_SIGNER_INFO_freefunc_type(freefunc)) +#define sk_PKCS7_SIGNER_INFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr), (idx)) +#define sk_PKCS7_SIGNER_INFO_set(sk, idx, ptr) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_set(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (idx), ossl_check_PKCS7_SIGNER_INFO_type(ptr))) +#define sk_PKCS7_SIGNER_INFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr)) +#define sk_PKCS7_SIGNER_INFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr)) +#define sk_PKCS7_SIGNER_INFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr), pnum) +#define sk_PKCS7_SIGNER_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_dup(sk) ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk))) +#define sk_PKCS7_SIGNER_INFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_deep_copy(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_copyfunc_type(copyfunc), ossl_check_PKCS7_SIGNER_INFO_freefunc_type(freefunc))) +#define sk_PKCS7_SIGNER_INFO_set_cmp_func(sk, cmp) ((sk_PKCS7_SIGNER_INFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp))) + + +typedef struct pkcs7_recip_info_st { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *key_enc_algor; + ASN1_OCTET_STRING *enc_key; + X509 *cert; /* get the pub-key from this */ + const PKCS7_CTX *ctx; +} PKCS7_RECIP_INFO; +SKM_DEFINE_STACK_OF_INTERNAL(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO, PKCS7_RECIP_INFO) +#define sk_PKCS7_RECIP_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_value(sk, idx) ((PKCS7_RECIP_INFO *)OPENSSL_sk_value(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk), (idx))) +#define sk_PKCS7_RECIP_INFO_new(cmp) ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new(ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp))) +#define sk_PKCS7_RECIP_INFO_new_null() ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new_null()) +#define sk_PKCS7_RECIP_INFO_new_reserve(cmp, n) ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new_reserve(ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp), (n))) +#define sk_PKCS7_RECIP_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (n)) +#define sk_PKCS7_RECIP_INFO_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_delete(sk, i) ((PKCS7_RECIP_INFO *)OPENSSL_sk_delete(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (i))) +#define sk_PKCS7_RECIP_INFO_delete_ptr(sk, ptr) ((PKCS7_RECIP_INFO *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr))) +#define sk_PKCS7_RECIP_INFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) +#define sk_PKCS7_RECIP_INFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) +#define sk_PKCS7_RECIP_INFO_pop(sk) ((PKCS7_RECIP_INFO *)OPENSSL_sk_pop(ossl_check_PKCS7_RECIP_INFO_sk_type(sk))) +#define sk_PKCS7_RECIP_INFO_shift(sk) ((PKCS7_RECIP_INFO *)OPENSSL_sk_shift(ossl_check_PKCS7_RECIP_INFO_sk_type(sk))) +#define sk_PKCS7_RECIP_INFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_PKCS7_RECIP_INFO_sk_type(sk),ossl_check_PKCS7_RECIP_INFO_freefunc_type(freefunc)) +#define sk_PKCS7_RECIP_INFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr), (idx)) +#define sk_PKCS7_RECIP_INFO_set(sk, idx, ptr) ((PKCS7_RECIP_INFO *)OPENSSL_sk_set(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (idx), ossl_check_PKCS7_RECIP_INFO_type(ptr))) +#define sk_PKCS7_RECIP_INFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) +#define sk_PKCS7_RECIP_INFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) +#define sk_PKCS7_RECIP_INFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr), pnum) +#define sk_PKCS7_RECIP_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_dup(sk) ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk))) +#define sk_PKCS7_RECIP_INFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_deep_copy(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_copyfunc_type(copyfunc), ossl_check_PKCS7_RECIP_INFO_freefunc_type(freefunc))) +#define sk_PKCS7_RECIP_INFO_set_cmp_func(sk, cmp) ((sk_PKCS7_RECIP_INFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp))) + + + +typedef struct pkcs7_signed_st { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ /* name should be 'certificates' */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ /* name should be 'crls' */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + struct pkcs7_st *contents; +} PKCS7_SIGNED; +/* + * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about + * merging the two + */ + +typedef struct pkcs7_enc_content_st { + ASN1_OBJECT *content_type; + X509_ALGOR *algorithm; + ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ + const EVP_CIPHER *cipher; + const PKCS7_CTX *ctx; +} PKCS7_ENC_CONTENT; + +typedef struct pkcs7_enveloped_st { + ASN1_INTEGER *version; /* version 0 */ + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + PKCS7_ENC_CONTENT *enc_data; +} PKCS7_ENVELOPE; + +typedef struct pkcs7_signedandenveloped_st { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ /* name should be 'certificates' */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ /* name should be 'crls' */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + PKCS7_ENC_CONTENT *enc_data; + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; +} PKCS7_SIGN_ENVELOPE; + +typedef struct pkcs7_digest_st { + ASN1_INTEGER *version; /* version 0 */ + X509_ALGOR *md; /* md used */ + struct pkcs7_st *contents; + ASN1_OCTET_STRING *digest; +} PKCS7_DIGEST; + +typedef struct pkcs7_encrypted_st { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ENC_CONTENT *enc_data; +} PKCS7_ENCRYPT; + +typedef struct pkcs7_st { + /* + * The following is non NULL if it contains ASN1 encoding of this + * structure + */ + unsigned char *asn1; + long length; +# define PKCS7_S_HEADER 0 +# define PKCS7_S_BODY 1 +# define PKCS7_S_TAIL 2 + int state; /* used during processing */ + int detached; + ASN1_OBJECT *type; + /* content as defined by the type */ + /* + * all encryption/message digests are applied to the 'contents', leaving + * out the 'type' field. + */ + union { + char *ptr; + /* NID_pkcs7_data */ + ASN1_OCTET_STRING *data; + /* NID_pkcs7_signed */ + PKCS7_SIGNED *sign; /* field name 'signed' would clash with C keyword */ + /* NID_pkcs7_enveloped */ + PKCS7_ENVELOPE *enveloped; + /* NID_pkcs7_signedAndEnveloped */ + PKCS7_SIGN_ENVELOPE *signed_and_enveloped; + /* NID_pkcs7_digest */ + PKCS7_DIGEST *digest; + /* NID_pkcs7_encrypted */ + PKCS7_ENCRYPT *encrypted; + /* Anything else */ + ASN1_TYPE *other; + } d; + PKCS7_CTX ctx; +} PKCS7; +SKM_DEFINE_STACK_OF_INTERNAL(PKCS7, PKCS7, PKCS7) +#define sk_PKCS7_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_sk_type(sk)) +#define sk_PKCS7_value(sk, idx) ((PKCS7 *)OPENSSL_sk_value(ossl_check_const_PKCS7_sk_type(sk), (idx))) +#define sk_PKCS7_new(cmp) ((STACK_OF(PKCS7) *)OPENSSL_sk_new(ossl_check_PKCS7_compfunc_type(cmp))) +#define sk_PKCS7_new_null() ((STACK_OF(PKCS7) *)OPENSSL_sk_new_null()) +#define sk_PKCS7_new_reserve(cmp, n) ((STACK_OF(PKCS7) *)OPENSSL_sk_new_reserve(ossl_check_PKCS7_compfunc_type(cmp), (n))) +#define sk_PKCS7_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PKCS7_sk_type(sk), (n)) +#define sk_PKCS7_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_sk_type(sk)) +#define sk_PKCS7_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_sk_type(sk)) +#define sk_PKCS7_delete(sk, i) ((PKCS7 *)OPENSSL_sk_delete(ossl_check_PKCS7_sk_type(sk), (i))) +#define sk_PKCS7_delete_ptr(sk, ptr) ((PKCS7 *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr))) +#define sk_PKCS7_push(sk, ptr) OPENSSL_sk_push(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) +#define sk_PKCS7_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) +#define sk_PKCS7_pop(sk) ((PKCS7 *)OPENSSL_sk_pop(ossl_check_PKCS7_sk_type(sk))) +#define sk_PKCS7_shift(sk) ((PKCS7 *)OPENSSL_sk_shift(ossl_check_PKCS7_sk_type(sk))) +#define sk_PKCS7_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_PKCS7_sk_type(sk),ossl_check_PKCS7_freefunc_type(freefunc)) +#define sk_PKCS7_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr), (idx)) +#define sk_PKCS7_set(sk, idx, ptr) ((PKCS7 *)OPENSSL_sk_set(ossl_check_PKCS7_sk_type(sk), (idx), ossl_check_PKCS7_type(ptr))) +#define sk_PKCS7_find(sk, ptr) OPENSSL_sk_find(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) +#define sk_PKCS7_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) +#define sk_PKCS7_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr), pnum) +#define sk_PKCS7_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_sk_type(sk)) +#define sk_PKCS7_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_sk_type(sk)) +#define sk_PKCS7_dup(sk) ((STACK_OF(PKCS7) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_sk_type(sk))) +#define sk_PKCS7_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(PKCS7) *)OPENSSL_sk_deep_copy(ossl_check_const_PKCS7_sk_type(sk), ossl_check_PKCS7_copyfunc_type(copyfunc), ossl_check_PKCS7_freefunc_type(freefunc))) +#define sk_PKCS7_set_cmp_func(sk, cmp) ((sk_PKCS7_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_compfunc_type(cmp))) + + + +# define PKCS7_OP_SET_DETACHED_SIGNATURE 1 +# define PKCS7_OP_GET_DETACHED_SIGNATURE 2 + +# define PKCS7_get_signed_attributes(si) ((si)->auth_attr) +# define PKCS7_get_attributes(si) ((si)->unauth_attr) + +# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) +# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) +# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) +# define PKCS7_type_is_signedAndEnveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) +# define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) +# define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) + +# define PKCS7_set_detached(p,v) \ + PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) +# define PKCS7_get_detached(p) \ + PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) + +# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) + +/* S/MIME related flags */ + +# define PKCS7_TEXT 0x1 +# define PKCS7_NOCERTS 0x2 +# define PKCS7_NOSIGS 0x4 +# define PKCS7_NOCHAIN 0x8 +# define PKCS7_NOINTERN 0x10 +# define PKCS7_NOVERIFY 0x20 +# define PKCS7_DETACHED 0x40 +# define PKCS7_BINARY 0x80 +# define PKCS7_NOATTR 0x100 +# define PKCS7_NOSMIMECAP 0x200 +# define PKCS7_NOOLDMIMETYPE 0x400 +# define PKCS7_CRLFEOL 0x800 +# define PKCS7_STREAM 0x1000 +# define PKCS7_NOCRL 0x2000 +# define PKCS7_PARTIAL 0x4000 +# define PKCS7_REUSE_DIGEST 0x8000 +# define PKCS7_NO_DUAL_CONTENT 0x10000 + +/* Flags: for compatibility with older code */ + +# define SMIME_TEXT PKCS7_TEXT +# define SMIME_NOCERTS PKCS7_NOCERTS +# define SMIME_NOSIGS PKCS7_NOSIGS +# define SMIME_NOCHAIN PKCS7_NOCHAIN +# define SMIME_NOINTERN PKCS7_NOINTERN +# define SMIME_NOVERIFY PKCS7_NOVERIFY +# define SMIME_DETACHED PKCS7_DETACHED +# define SMIME_BINARY PKCS7_BINARY +# define SMIME_NOATTR PKCS7_NOATTR + +/* CRLF ASCII canonicalisation */ +# define SMIME_ASCIICRLF 0x80000 + +DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) + +int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, + const EVP_MD *type, unsigned char *md, + unsigned int *len); +# ifndef OPENSSL_NO_STDIO +PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7); +int i2d_PKCS7_fp(FILE *fp, const PKCS7 *p7); +# endif +DECLARE_ASN1_DUP_FUNCTION(PKCS7) +PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7); +int i2d_PKCS7_bio(BIO *bp, const PKCS7 *p7); +int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags); +int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags); + +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) +DECLARE_ASN1_FUNCTIONS(PKCS7) +PKCS7 *PKCS7_new_ex(OSSL_LIB_CTX *libctx, const char *propq); + +DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) +DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) + +DECLARE_ASN1_NDEF_FUNCTION(PKCS7) +DECLARE_ASN1_PRINT_FUNCTION(PKCS7) + +long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); + +int PKCS7_type_is_other(PKCS7 *p7); +int PKCS7_set_type(PKCS7 *p7, int type); +int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); +int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); +int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, + const EVP_MD *dgst); +int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si); +int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); +int PKCS7_add_certificate(PKCS7 *p7, X509 *cert); +int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl); +int PKCS7_content_new(PKCS7 *p7, int nid); +int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, + BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, + X509 *signer); + +BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); +int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); +BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); + +PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, + EVP_PKEY *pkey, const EVP_MD *dgst); +X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); +STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); + +PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); +void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, + X509_ALGOR **pdig, X509_ALGOR **psig); +void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc); +int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); +int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); +int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); +int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7); + +PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); +ASN1_OCTET_STRING *PKCS7_get_octet_string(PKCS7 *p7); +ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type, + void *data); +int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, + void *value); +ASN1_TYPE *PKCS7_get_attribute(const PKCS7_SIGNER_INFO *si, int nid); +ASN1_TYPE *PKCS7_get_signed_attribute(const PKCS7_SIGNER_INFO *si, int nid); +int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, + STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, + STACK_OF(X509_ATTRIBUTE) *sk); + +PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, + BIO *data, int flags); +PKCS7 *PKCS7_sign_ex(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, + BIO *data, int flags, OSSL_LIB_CTX *libctx, + const char *propq); + +PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, + X509 *signcert, EVP_PKEY *pkey, + const EVP_MD *md, int flags); + +int PKCS7_final(PKCS7 *p7, BIO *data, int flags); +int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, + BIO *indata, BIO *out, int flags); +STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, + int flags); +PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, + int flags); +PKCS7 *PKCS7_encrypt_ex(STACK_OF(X509) *certs, BIO *in, + const EVP_CIPHER *cipher, int flags, + OSSL_LIB_CTX *libctx, const char *propq); +int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, + int flags); + +int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, + STACK_OF(X509_ALGOR) *cap); +STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); +int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); + +int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid); +int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t); +int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, + const unsigned char *md, int mdlen); + +int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); +PKCS7 *SMIME_read_PKCS7_ex(BIO *bio, BIO **bcont, PKCS7 **p7); +PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); + +BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/pkcs7err.h b/illumos-x86_64/usr/include/openssl-3/pkcs7err.h new file mode 100644 index 00000000..ceb1a501 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/pkcs7err.h @@ -0,0 +1,63 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PKCS7ERR_H +# define OPENSSL_PKCS7ERR_H +# pragma once + +# include +# include +# include + + + +/* + * PKCS7 reason codes. + */ +# define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117 +# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 +# define PKCS7_R_CIPHER_NOT_INITIALIZED 116 +# define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 +# define PKCS7_R_CTRL_ERROR 152 +# define PKCS7_R_DECRYPT_ERROR 119 +# define PKCS7_R_DIGEST_FAILURE 101 +# define PKCS7_R_ENCRYPTION_CTRL_FAILURE 149 +# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150 +# define PKCS7_R_ERROR_ADDING_RECIPIENT 120 +# define PKCS7_R_ERROR_SETTING_CIPHER 121 +# define PKCS7_R_INVALID_NULL_POINTER 143 +# define PKCS7_R_INVALID_SIGNED_DATA_TYPE 155 +# define PKCS7_R_NO_CONTENT 122 +# define PKCS7_R_NO_DEFAULT_DIGEST 151 +# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND 154 +# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 +# define PKCS7_R_NO_SIGNATURES_ON_DATA 123 +# define PKCS7_R_NO_SIGNERS 142 +# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 +# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 +# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR 153 +# define PKCS7_R_PKCS7_DATASIGN 145 +# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 +# define PKCS7_R_SIGNATURE_FAILURE 105 +# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 +# define PKCS7_R_SIGNING_CTRL_FAILURE 147 +# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 148 +# define PKCS7_R_SMIME_TEXT_ERROR 129 +# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 +# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 +# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 +# define PKCS7_R_UNKNOWN_DIGEST_TYPE 109 +# define PKCS7_R_UNKNOWN_OPERATION 110 +# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111 +# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112 +# define PKCS7_R_WRONG_CONTENT_TYPE 113 +# define PKCS7_R_WRONG_PKCS7_TYPE 114 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/prov_ssl.h b/illumos-x86_64/usr/include/openssl-3/prov_ssl.h new file mode 100644 index 00000000..76d01e1e --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/prov_ssl.h @@ -0,0 +1,38 @@ +/* + * Copyright 2021-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PROV_SSL_H +# define OPENSSL_PROV_SSL_H +# pragma once + +# ifdef __cplusplus +extern "C" { +# endif + +/* SSL/TLS related defines useful to providers */ + +# define SSL_MAX_MASTER_KEY_LENGTH 48 + +/* SSL/TLS uses a 2 byte unsigned version number */ +# define SSL3_VERSION 0x0300 +# define TLS1_VERSION 0x0301 +# define TLS1_1_VERSION 0x0302 +# define TLS1_2_VERSION 0x0303 +# define TLS1_3_VERSION 0x0304 +# define DTLS1_VERSION 0xFEFF +# define DTLS1_2_VERSION 0xFEFD +# define DTLS1_BAD_VER 0x0100 + +/* QUIC uses a 4 byte unsigned version number */ +# define OSSL_QUIC1_VERSION 0x0000001 + +# ifdef __cplusplus +} +# endif +#endif /* OPENSSL_PROV_SSL_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/proverr.h b/illumos-x86_64/usr/include/openssl-3/proverr.h new file mode 100644 index 00000000..10bcd427 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/proverr.h @@ -0,0 +1,170 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PROVERR_H +# define OPENSSL_PROVERR_H +# pragma once + +# include +# include +# include + + + +/* + * PROV reason codes. + */ +# define PROV_R_ADDITIONAL_INPUT_TOO_LONG 184 +# define PROV_R_ALGORITHM_MISMATCH 173 +# define PROV_R_ALREADY_INSTANTIATED 185 +# define PROV_R_BAD_DECRYPT 100 +# define PROV_R_BAD_ENCODING 141 +# define PROV_R_BAD_LENGTH 142 +# define PROV_R_BAD_TLS_CLIENT_VERSION 161 +# define PROV_R_BN_ERROR 160 +# define PROV_R_CIPHER_OPERATION_FAILED 102 +# define PROV_R_COFACTOR_REQUIRED 236 +# define PROV_R_DERIVATION_FUNCTION_INIT_FAILED 205 +# define PROV_R_DIGEST_NOT_ALLOWED 174 +# define PROV_R_EMS_NOT_ENABLED 233 +# define PROV_R_ENTROPY_SOURCE_FAILED_CONTINUOUS_TESTS 244 +# define PROV_R_ENTROPY_SOURCE_STRENGTH_TOO_WEAK 186 +# define PROV_R_ERROR_INSTANTIATING_DRBG 188 +# define PROV_R_ERROR_RETRIEVING_ENTROPY 189 +# define PROV_R_ERROR_RETRIEVING_NONCE 190 +# define PROV_R_FAILED_DURING_DERIVATION 164 +# define PROV_R_FAILED_TO_CREATE_LOCK 180 +# define PROV_R_FAILED_TO_DECRYPT 162 +# define PROV_R_FAILED_TO_GENERATE_KEY 121 +# define PROV_R_FAILED_TO_GET_PARAMETER 103 +# define PROV_R_FAILED_TO_SET_PARAMETER 104 +# define PROV_R_FAILED_TO_SIGN 175 +# define PROV_R_FINAL_CALL_OUT_OF_ORDER 237 +# define PROV_R_FIPS_MODULE_CONDITIONAL_ERROR 227 +# define PROV_R_FIPS_MODULE_ENTERING_ERROR_STATE 224 +# define PROV_R_FIPS_MODULE_IMPORT_PCT_ERROR 253 +# define PROV_R_FIPS_MODULE_IN_ERROR_STATE 225 +# define PROV_R_GENERATE_ERROR 191 +# define PROV_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 165 +# define PROV_R_INDICATOR_INTEGRITY_FAILURE 210 +# define PROV_R_INIT_CALL_OUT_OF_ORDER 238 +# define PROV_R_INSUFFICIENT_DRBG_STRENGTH 181 +# define PROV_R_INVALID_AAD 108 +# define PROV_R_INVALID_AEAD 231 +# define PROV_R_INVALID_CONFIG_DATA 211 +# define PROV_R_INVALID_CONSTANT_LENGTH 157 +# define PROV_R_INVALID_CURVE 176 +# define PROV_R_INVALID_CUSTOM_LENGTH 111 +# define PROV_R_INVALID_DATA 115 +# define PROV_R_INVALID_DIGEST 122 +# define PROV_R_INVALID_DIGEST_LENGTH 166 +# define PROV_R_INVALID_DIGEST_SIZE 218 +# define PROV_R_INVALID_EDDSA_INSTANCE_FOR_ATTEMPTED_OPERATION 243 +# define PROV_R_INVALID_INPUT_LENGTH 230 +# define PROV_R_INVALID_ITERATION_COUNT 123 +# define PROV_R_INVALID_IV_LENGTH 109 +# define PROV_R_INVALID_KDF 232 +# define PROV_R_INVALID_KEY 158 +# define PROV_R_INVALID_KEY_LENGTH 105 +# define PROV_R_INVALID_MAC 151 +# define PROV_R_INVALID_MEMORY_SIZE 235 +# define PROV_R_INVALID_MGF1_MD 167 +# define PROV_R_INVALID_MODE 125 +# define PROV_R_INVALID_OUTPUT_LENGTH 217 +# define PROV_R_INVALID_PADDING_MODE 168 +# define PROV_R_INVALID_PREHASHED_DIGEST_LENGTH 241 +# define PROV_R_INVALID_PUBINFO 198 +# define PROV_R_INVALID_SALT_LENGTH 112 +# define PROV_R_INVALID_SEED_LENGTH 154 +# define PROV_R_INVALID_SIGNATURE_SIZE 179 +# define PROV_R_INVALID_STATE 212 +# define PROV_R_INVALID_TAG 110 +# define PROV_R_INVALID_TAG_LENGTH 118 +# define PROV_R_INVALID_THREAD_POOL_SIZE 234 +# define PROV_R_INVALID_UKM_LENGTH 200 +# define PROV_R_INVALID_X931_DIGEST 170 +# define PROV_R_IN_ERROR_STATE 192 +# define PROV_R_KEY_SETUP_FAILED 101 +# define PROV_R_KEY_SIZE_TOO_SMALL 171 +# define PROV_R_LENGTH_TOO_LARGE 202 +# define PROV_R_MISMATCHING_DOMAIN_PARAMETERS 203 +# define PROV_R_MISSING_CEK_ALG 144 +# define PROV_R_MISSING_CIPHER 155 +# define PROV_R_MISSING_CONFIG_DATA 213 +# define PROV_R_MISSING_CONSTANT 156 +# define PROV_R_MISSING_KEY 128 +# define PROV_R_MISSING_MAC 150 +# define PROV_R_MISSING_MESSAGE_DIGEST 129 +# define PROV_R_MISSING_OID 209 +# define PROV_R_MISSING_PASS 130 +# define PROV_R_MISSING_SALT 131 +# define PROV_R_MISSING_SECRET 132 +# define PROV_R_MISSING_SEED 140 +# define PROV_R_MISSING_SESSION_ID 133 +# define PROV_R_MISSING_TYPE 134 +# define PROV_R_MISSING_XCGHASH 135 +# define PROV_R_ML_DSA_NO_FORMAT 245 +# define PROV_R_ML_KEM_NO_FORMAT 246 +# define PROV_R_MODULE_INTEGRITY_FAILURE 214 +# define PROV_R_NOT_A_PRIVATE_KEY 221 +# define PROV_R_NOT_A_PUBLIC_KEY 220 +# define PROV_R_NOT_INSTANTIATED 193 +# define PROV_R_NOT_PARAMETERS 226 +# define PROV_R_NOT_SUPPORTED 136 +# define PROV_R_NOT_XOF_OR_INVALID_LENGTH 113 +# define PROV_R_NO_INSTANCE_ALLOWED 242 +# define PROV_R_NO_KEY_SET 114 +# define PROV_R_NO_PARAMETERS_SET 177 +# define PROV_R_NULL_LENGTH_POINTER 247 +# define PROV_R_NULL_OUTPUT_BUFFER 248 +# define PROV_R_ONESHOT_CALL_OUT_OF_ORDER 239 +# define PROV_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 178 +# define PROV_R_OUTPUT_BUFFER_TOO_SMALL 106 +# define PROV_R_PARENT_CANNOT_GENERATE_RANDOM_NUMBERS 228 +# define PROV_R_PARENT_CANNOT_SUPPLY_ENTROPY_SEED 187 +# define PROV_R_PARENT_LOCKING_NOT_ENABLED 182 +# define PROV_R_PARENT_STRENGTH_TOO_WEAK 194 +# define PROV_R_PATH_MUST_BE_ABSOLUTE 219 +# define PROV_R_PERSONALISATION_STRING_TOO_LONG 195 +# define PROV_R_PSS_SALTLEN_TOO_SMALL 172 +# define PROV_R_REQUEST_TOO_LARGE_FOR_DRBG 196 +# define PROV_R_REQUIRE_CTR_MODE_CIPHER 206 +# define PROV_R_RESEED_ERROR 197 +# define PROV_R_SEARCH_ONLY_SUPPORTED_FOR_DIRECTORIES 222 +# define PROV_R_SEED_SOURCES_MUST_NOT_HAVE_A_PARENT 229 +# define PROV_R_SELF_TEST_KAT_FAILURE 215 +# define PROV_R_SELF_TEST_POST_FAILURE 216 +# define PROV_R_TAG_NOT_NEEDED 120 +# define PROV_R_TAG_NOT_SET 119 +# define PROV_R_TOO_MANY_RECORDS 126 +# define PROV_R_UNABLE_TO_FIND_CIPHERS 207 +# define PROV_R_UNABLE_TO_GET_PARENT_STRENGTH 199 +# define PROV_R_UNABLE_TO_GET_PASSPHRASE 159 +# define PROV_R_UNABLE_TO_INITIALISE_CIPHERS 208 +# define PROV_R_UNABLE_TO_LOAD_SHA256 147 +# define PROV_R_UNABLE_TO_LOCK_PARENT 201 +# define PROV_R_UNABLE_TO_RESEED 204 +# define PROV_R_UNEXPECTED_KEY_PARAMETERS 249 +# define PROV_R_UNSUPPORTED_CEK_ALG 145 +# define PROV_R_UNSUPPORTED_KEY_SIZE 153 +# define PROV_R_UNSUPPORTED_MAC_TYPE 137 +# define PROV_R_UNSUPPORTED_NUMBER_OF_ROUNDS 152 +# define PROV_R_UNSUPPORTED_SELECTION 250 +# define PROV_R_UPDATE_CALL_OUT_OF_ORDER 240 +# define PROV_R_URI_AUTHORITY_UNSUPPORTED 223 +# define PROV_R_VALUE_ERROR 138 +# define PROV_R_WRONG_CIPHERTEXT_SIZE 251 +# define PROV_R_WRONG_FINAL_BLOCK_LENGTH 107 +# define PROV_R_WRONG_OUTPUT_BUFFER_SIZE 139 +# define PROV_R_XOF_DIGESTS_NOT_ALLOWED 183 +# define PROV_R_XTS_DATA_UNIT_IS_TOO_LARGE 148 +# define PROV_R_XTS_DUPLICATED_KEYS 149 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/provider.h b/illumos-x86_64/usr/include/openssl-3/provider.h new file mode 100644 index 00000000..51443577 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/provider.h @@ -0,0 +1,94 @@ +/* + * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_PROVIDER_H +# define OPENSSL_PROVIDER_H +# pragma once + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* Set and Get a library context search path */ +int OSSL_PROVIDER_set_default_search_path(OSSL_LIB_CTX *, const char *path); +const char *OSSL_PROVIDER_get0_default_search_path(OSSL_LIB_CTX *libctx); + +/* Load and unload a provider */ +OSSL_PROVIDER *OSSL_PROVIDER_load(OSSL_LIB_CTX *, const char *name); +OSSL_PROVIDER *OSSL_PROVIDER_load_ex(OSSL_LIB_CTX *, const char *name, + OSSL_PARAM *params); +OSSL_PROVIDER *OSSL_PROVIDER_try_load(OSSL_LIB_CTX *, const char *name, + int retain_fallbacks); +OSSL_PROVIDER *OSSL_PROVIDER_try_load_ex(OSSL_LIB_CTX *, const char *name, + OSSL_PARAM *params, + int retain_fallbacks); +int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov); +int OSSL_PROVIDER_available(OSSL_LIB_CTX *, const char *name); +int OSSL_PROVIDER_do_all(OSSL_LIB_CTX *ctx, + int (*cb)(OSSL_PROVIDER *provider, void *cbdata), + void *cbdata); + +const OSSL_PARAM *OSSL_PROVIDER_gettable_params(const OSSL_PROVIDER *prov); +int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]); +int OSSL_PROVIDER_self_test(const OSSL_PROVIDER *prov); +int OSSL_PROVIDER_get_capabilities(const OSSL_PROVIDER *prov, + const char *capability, + OSSL_CALLBACK *cb, + void *arg); + +/*- + * Provider configuration parameters are normally set in the configuration file, + * but can also be set early in the main program before a provider is in use by + * multiple threads. + * + * Only UTF8-string values are supported. + */ +int OSSL_PROVIDER_add_conf_parameter(OSSL_PROVIDER *prov, const char *name, + const char *value); +/* + * Retrieves any of the requested configuration parameters for the given + * provider that were set in the configuration file or via the above + * OSSL_PROVIDER_add_parameter() function. + * + * The |params| array elements MUST have type OSSL_PARAM_UTF8_PTR, values are + * returned by reference, not as copies. + */ +int OSSL_PROVIDER_get_conf_parameters(const OSSL_PROVIDER *prov, + OSSL_PARAM params[]); +/* + * Parse a provider configuration parameter as a boolean value, + * or return a default value if unable to retrieve the parameter. + * Values like "1", "yes", "true", ... are true (nonzero). + * Values like "0", "no", "false", ... are false (zero). + */ +int OSSL_PROVIDER_conf_get_bool(const OSSL_PROVIDER *prov, + const char *name, int defval); + +const OSSL_ALGORITHM *OSSL_PROVIDER_query_operation(const OSSL_PROVIDER *prov, + int operation_id, + int *no_cache); +void OSSL_PROVIDER_unquery_operation(const OSSL_PROVIDER *prov, + int operation_id, const OSSL_ALGORITHM *algs); +void *OSSL_PROVIDER_get0_provider_ctx(const OSSL_PROVIDER *prov); +const OSSL_DISPATCH *OSSL_PROVIDER_get0_dispatch(const OSSL_PROVIDER *prov); + +/* Add a built in providers */ +int OSSL_PROVIDER_add_builtin(OSSL_LIB_CTX *, const char *name, + OSSL_provider_init_fn *init_fn); + +/* Information */ +const char *OSSL_PROVIDER_get0_name(const OSSL_PROVIDER *prov); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/quic.h b/illumos-x86_64/usr/include/openssl-3/quic.h new file mode 100644 index 00000000..8eacc631 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/quic.h @@ -0,0 +1,75 @@ +/* + * Copyright 2022-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_QUIC_H +# define OPENSSL_QUIC_H +# pragma once + +# include +# include + +# ifndef OPENSSL_NO_QUIC + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * Method used for non-thread-assisted QUIC client operation. + */ +__owur const SSL_METHOD *OSSL_QUIC_client_method(void); + +/* + * Method used for thread-assisted QUIC client operation. + */ +__owur const SSL_METHOD *OSSL_QUIC_client_thread_method(void); + +/* + * QUIC transport error codes (RFC 9000 s. 20.1) + */ +# define OSSL_QUIC_ERR_NO_ERROR 0x00 +# define OSSL_QUIC_ERR_INTERNAL_ERROR 0x01 +# define OSSL_QUIC_ERR_CONNECTION_REFUSED 0x02 +# define OSSL_QUIC_ERR_FLOW_CONTROL_ERROR 0x03 +# define OSSL_QUIC_ERR_STREAM_LIMIT_ERROR 0x04 +# define OSSL_QUIC_ERR_STREAM_STATE_ERROR 0x05 +# define OSSL_QUIC_ERR_FINAL_SIZE_ERROR 0x06 +# define OSSL_QUIC_ERR_FRAME_ENCODING_ERROR 0x07 +# define OSSL_QUIC_ERR_TRANSPORT_PARAMETER_ERROR 0x08 +# define OSSL_QUIC_ERR_CONNECTION_ID_LIMIT_ERROR 0x09 +# define OSSL_QUIC_ERR_PROTOCOL_VIOLATION 0x0A +# define OSSL_QUIC_ERR_INVALID_TOKEN 0x0B +# define OSSL_QUIC_ERR_APPLICATION_ERROR 0x0C +# define OSSL_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED 0x0D +# define OSSL_QUIC_ERR_KEY_UPDATE_ERROR 0x0E +# define OSSL_QUIC_ERR_AEAD_LIMIT_REACHED 0x0F +# define OSSL_QUIC_ERR_NO_VIABLE_PATH 0x10 + +/* Inclusive range for handshake-specific errors. */ +# define OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN 0x0100 +# define OSSL_QUIC_ERR_CRYPTO_ERR_END 0x01FF + +# define OSSL_QUIC_ERR_CRYPTO_ERR(X) \ + (OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN + (X)) + +/* Local errors. */ +# define OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT \ + ((uint64_t)0xFFFFFFFFFFFFFFFFULL) + +/* + * Method used for QUIC server operation. + */ +__owur const SSL_METHOD *OSSL_QUIC_server_method(void); + +# ifdef __cplusplus +} +# endif + +# endif /* OPENSSL_NO_QUIC */ +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/rand.h b/illumos-x86_64/usr/include/openssl-3/rand.h new file mode 100644 index 00000000..4e59e50f --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/rand.h @@ -0,0 +1,131 @@ +/* + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_RAND_H +# define OPENSSL_RAND_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_RAND_H +# endif + +# include +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * Default security strength (in the sense of [NIST SP 800-90Ar1]) + * + * NIST SP 800-90Ar1 supports the strength of the DRBG being smaller than that + * of the cipher by collecting less entropy. The current DRBG implementation + * does not take RAND_DRBG_STRENGTH into account and sets the strength of the + * DRBG to that of the cipher. + */ +# define RAND_DRBG_STRENGTH 256 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +struct rand_meth_st { + int (*seed) (const void *buf, int num); + int (*bytes) (unsigned char *buf, int num); + void (*cleanup) (void); + int (*add) (const void *buf, int num, double randomness); + int (*pseudorand) (unsigned char *buf, int num); + int (*status) (void); +}; + +OSSL_DEPRECATEDIN_3_0 int RAND_set_rand_method(const RAND_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 const RAND_METHOD *RAND_get_rand_method(void); +# ifndef OPENSSL_NO_ENGINE +OSSL_DEPRECATEDIN_3_0 int RAND_set_rand_engine(ENGINE *engine); +# endif + +OSSL_DEPRECATEDIN_3_0 RAND_METHOD *RAND_OpenSSL(void); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define RAND_cleanup() while(0) continue +# endif +int RAND_bytes(unsigned char *buf, int num); +int RAND_priv_bytes(unsigned char *buf, int num); + +/* + * Equivalent of RAND_priv_bytes() but additionally taking an OSSL_LIB_CTX and + * a strength. + */ +int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num, + unsigned int strength); + +/* + * Equivalent of RAND_bytes() but additionally taking an OSSL_LIB_CTX and + * a strength. + */ +int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num, + unsigned int strength); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 int RAND_pseudo_bytes(unsigned char *buf, int num); +# endif + +EVP_RAND_CTX *RAND_get0_primary(OSSL_LIB_CTX *ctx); +EVP_RAND_CTX *RAND_get0_public(OSSL_LIB_CTX *ctx); +EVP_RAND_CTX *RAND_get0_private(OSSL_LIB_CTX *ctx); +int RAND_set0_public(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand); +int RAND_set0_private(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand); + +int RAND_set_DRBG_type(OSSL_LIB_CTX *ctx, const char *drbg, const char *propq, + const char *cipher, const char *digest); +int RAND_set_seed_source_type(OSSL_LIB_CTX *ctx, const char *seed, + const char *propq); + +void RAND_seed(const void *buf, int num); +void RAND_keep_random_devices_open(int keep); + +# if defined(__ANDROID__) && defined(__NDK_FPABI__) +__NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */ +# endif +void RAND_add(const void *buf, int num, double randomness); +int RAND_load_file(const char *file, long max_bytes); +int RAND_write_file(const char *file); +const char *RAND_file_name(char *file, size_t num); +int RAND_status(void); + +# ifndef OPENSSL_NO_EGD +int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); +int RAND_egd(const char *path); +int RAND_egd_bytes(const char *path, int bytes); +# endif + +int RAND_poll(void); + +# if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H)) +/* application has to include in order to use these */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 void RAND_screen(void); +OSSL_DEPRECATEDIN_1_1_0 int RAND_event(UINT, WPARAM, LPARAM); +# endif +# endif + +int RAND_set1_random_provider(OSSL_LIB_CTX *ctx, OSSL_PROVIDER *p); + +/* Which parameter to provider_random call */ +# define OSSL_PROV_RANDOM_PUBLIC 0 +# define OSSL_PROV_RANDOM_PRIVATE 1 + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/randerr.h b/illumos-x86_64/usr/include/openssl-3/randerr.h new file mode 100644 index 00000000..5e1e6d79 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/randerr.h @@ -0,0 +1,70 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_RANDERR_H +# define OPENSSL_RANDERR_H +# pragma once + +# include +# include +# include + + + +/* + * RAND reason codes. + */ +# define RAND_R_ADDITIONAL_INPUT_TOO_LONG 102 +# define RAND_R_ALREADY_INSTANTIATED 103 +# define RAND_R_ARGUMENT_OUT_OF_RANGE 105 +# define RAND_R_CANNOT_OPEN_FILE 121 +# define RAND_R_DRBG_ALREADY_INITIALIZED 129 +# define RAND_R_DRBG_NOT_INITIALISED 104 +# define RAND_R_ENTROPY_INPUT_TOO_LONG 106 +# define RAND_R_ENTROPY_OUT_OF_RANGE 124 +# define RAND_R_ERROR_ENTROPY_POOL_WAS_IGNORED 127 +# define RAND_R_ERROR_INITIALISING_DRBG 107 +# define RAND_R_ERROR_INSTANTIATING_DRBG 108 +# define RAND_R_ERROR_RETRIEVING_ADDITIONAL_INPUT 109 +# define RAND_R_ERROR_RETRIEVING_ENTROPY 110 +# define RAND_R_ERROR_RETRIEVING_NONCE 111 +# define RAND_R_FAILED_TO_CREATE_LOCK 126 +# define RAND_R_FUNC_NOT_IMPLEMENTED 101 +# define RAND_R_FWRITE_ERROR 123 +# define RAND_R_GENERATE_ERROR 112 +# define RAND_R_INSUFFICIENT_DRBG_STRENGTH 139 +# define RAND_R_INTERNAL_ERROR 113 +# define RAND_R_INVALID_PROPERTY_QUERY 137 +# define RAND_R_IN_ERROR_STATE 114 +# define RAND_R_NOT_A_REGULAR_FILE 122 +# define RAND_R_NOT_INSTANTIATED 115 +# define RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED 128 +# define RAND_R_PARENT_LOCKING_NOT_ENABLED 130 +# define RAND_R_PARENT_STRENGTH_TOO_WEAK 131 +# define RAND_R_PERSONALISATION_STRING_TOO_LONG 116 +# define RAND_R_PREDICTION_RESISTANCE_NOT_SUPPORTED 133 +# define RAND_R_PRNG_NOT_SEEDED 100 +# define RAND_R_RANDOM_POOL_IS_EMPTY 142 +# define RAND_R_RANDOM_POOL_OVERFLOW 125 +# define RAND_R_RANDOM_POOL_UNDERFLOW 134 +# define RAND_R_REQUEST_TOO_LARGE_FOR_DRBG 117 +# define RAND_R_RESEED_ERROR 118 +# define RAND_R_SELFTEST_FAILURE 119 +# define RAND_R_TOO_LITTLE_NONCE_REQUESTED 135 +# define RAND_R_TOO_MUCH_NONCE_REQUESTED 136 +# define RAND_R_UNABLE_TO_CREATE_DRBG 143 +# define RAND_R_UNABLE_TO_FETCH_DRBG 144 +# define RAND_R_UNABLE_TO_GET_PARENT_RESEED_PROP_COUNTER 141 +# define RAND_R_UNABLE_TO_GET_PARENT_STRENGTH 138 +# define RAND_R_UNABLE_TO_LOCK_PARENT 140 +# define RAND_R_UNSUPPORTED_DRBG_FLAGS 132 +# define RAND_R_UNSUPPORTED_DRBG_TYPE 120 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/rc2.h b/illumos-x86_64/usr/include/openssl-3/rc2.h new file mode 100644 index 00000000..ff633fd8 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/rc2.h @@ -0,0 +1,68 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_RC2_H +# define OPENSSL_RC2_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_RC2_H +# endif + +# include + +# ifndef OPENSSL_NO_RC2 +# ifdef __cplusplus +extern "C" { +# endif + +# define RC2_BLOCK 8 +# define RC2_KEY_LENGTH 16 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef unsigned int RC2_INT; + +# define RC2_ENCRYPT 1 +# define RC2_DECRYPT 0 + +typedef struct rc2_key_st { + RC2_INT data[64]; +} RC2_KEY; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 void RC2_set_key(RC2_KEY *key, int len, + const unsigned char *data, int bits); +OSSL_DEPRECATEDIN_3_0 void RC2_ecb_encrypt(const unsigned char *in, + unsigned char *out, RC2_KEY *key, + int enc); +OSSL_DEPRECATEDIN_3_0 void RC2_encrypt(unsigned long *data, RC2_KEY *key); +OSSL_DEPRECATEDIN_3_0 void RC2_decrypt(unsigned long *data, RC2_KEY *key); +OSSL_DEPRECATEDIN_3_0 void RC2_cbc_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC2_KEY *ks, unsigned char *iv, + int enc); +OSSL_DEPRECATEDIN_3_0 void RC2_cfb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC2_KEY *schedule, + unsigned char *ivec, + int *num, int enc); +OSSL_DEPRECATEDIN_3_0 void RC2_ofb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC2_KEY *schedule, + unsigned char *ivec, + int *num); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/rc4.h b/illumos-x86_64/usr/include/openssl-3/rc4.h new file mode 100644 index 00000000..600b2885 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/rc4.h @@ -0,0 +1,47 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_RC4_H +# define OPENSSL_RC4_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_RC4_H +# endif + +# include + +# ifndef OPENSSL_NO_RC4 +# include +# ifdef __cplusplus +extern "C" { +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef struct rc4_key_st { + RC4_INT x, y; + RC4_INT data[256]; +} RC4_KEY; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 const char *RC4_options(void); +OSSL_DEPRECATEDIN_3_0 void RC4_set_key(RC4_KEY *key, int len, + const unsigned char *data); +OSSL_DEPRECATEDIN_3_0 void RC4(RC4_KEY *key, size_t len, + const unsigned char *indata, + unsigned char *outdata); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/rc5.h b/illumos-x86_64/usr/include/openssl-3/rc5.h new file mode 100644 index 00000000..de833523 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/rc5.h @@ -0,0 +1,79 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_RC5_H +# define OPENSSL_RC5_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_RC5_H +# endif + +# include + +# ifndef OPENSSL_NO_RC5 +# ifdef __cplusplus +extern "C" { +# endif + +# define RC5_32_BLOCK 8 +# define RC5_32_KEY_LENGTH 16/* This is a default, max is 255 */ + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define RC5_ENCRYPT 1 +# define RC5_DECRYPT 0 + +# define RC5_32_INT unsigned int + +/* + * This are the only values supported. Tweak the code if you want more The + * most supported modes will be RC5-32/12/16 RC5-32/16/8 + */ +# define RC5_8_ROUNDS 8 +# define RC5_12_ROUNDS 12 +# define RC5_16_ROUNDS 16 + +typedef struct rc5_key_st { + /* Number of rounds */ + int rounds; + RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; +} RC5_32_KEY; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int RC5_32_set_key(RC5_32_KEY *key, int len, + const unsigned char *data, + int rounds); +OSSL_DEPRECATEDIN_3_0 void RC5_32_ecb_encrypt(const unsigned char *in, + unsigned char *out, + RC5_32_KEY *key, + int enc); +OSSL_DEPRECATEDIN_3_0 void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key); +OSSL_DEPRECATEDIN_3_0 void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key); +OSSL_DEPRECATEDIN_3_0 void RC5_32_cbc_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC5_32_KEY *ks, unsigned char *iv, + int enc); +OSSL_DEPRECATEDIN_3_0 void RC5_32_cfb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC5_32_KEY *schedule, + unsigned char *ivec, int *num, + int enc); +OSSL_DEPRECATEDIN_3_0 void RC5_32_ofb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC5_32_KEY *schedule, + unsigned char *ivec, int *num); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ripemd.h b/illumos-x86_64/usr/include/openssl-3/ripemd.h new file mode 100644 index 00000000..900ee317 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ripemd.h @@ -0,0 +1,59 @@ +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_RIPEMD_H +# define OPENSSL_RIPEMD_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_RIPEMD_H +# endif + +# include + +# ifndef OPENSSL_NO_RMD160 +# include +# include + +# define RIPEMD160_DIGEST_LENGTH 20 + +# ifdef __cplusplus +extern "C" { +# endif +# if !defined(OPENSSL_NO_DEPRECATED_3_0) + +# define RIPEMD160_LONG unsigned int + +# define RIPEMD160_CBLOCK 64 +# define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) + +typedef struct RIPEMD160state_st { + RIPEMD160_LONG A, B, C, D, E; + RIPEMD160_LONG Nl, Nh; + RIPEMD160_LONG data[RIPEMD160_LBLOCK]; + unsigned int num; +} RIPEMD160_CTX; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int RIPEMD160_Init(RIPEMD160_CTX *c); +OSSL_DEPRECATEDIN_3_0 int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, + size_t len); +OSSL_DEPRECATEDIN_3_0 int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); +OSSL_DEPRECATEDIN_3_0 unsigned char *RIPEMD160(const unsigned char *d, size_t n, + unsigned char *md); +OSSL_DEPRECATEDIN_3_0 void RIPEMD160_Transform(RIPEMD160_CTX *c, + const unsigned char *b); +# endif + +# ifdef __cplusplus +} +# endif +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/rsa.h b/illumos-x86_64/usr/include/openssl-3/rsa.h new file mode 100644 index 00000000..167427d3 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/rsa.h @@ -0,0 +1,615 @@ +/* + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_RSA_H +# define OPENSSL_RSA_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_RSA_H +# endif + +# include + +# include +# include +# include +# include +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +# ifdef __cplusplus +extern "C" { +# endif + +# ifndef OPENSSL_RSA_MAX_MODULUS_BITS +# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 +# endif + +# define RSA_3 0x3L +# define RSA_F4 0x10001L + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* The types RSA and RSA_METHOD are defined in ossl_typ.h */ + +# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 2048 + +# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS +# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 +# endif + +/* exponent limit enforced for "large" modulus only */ +# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS +# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 +# endif +/* based on RFC 8017 appendix A.1.2 */ +# define RSA_ASN1_VERSION_DEFAULT 0 +# define RSA_ASN1_VERSION_MULTI 1 + +# define RSA_DEFAULT_PRIME_NUM 2 + +# define RSA_METHOD_FLAG_NO_CHECK 0x0001 +# define RSA_FLAG_CACHE_PUBLIC 0x0002 +# define RSA_FLAG_CACHE_PRIVATE 0x0004 +# define RSA_FLAG_BLINDING 0x0008 +# define RSA_FLAG_THREAD_SAFE 0x0010 +/* + * This flag means the private key operations will be handled by rsa_mod_exp + * and that they do not depend on the private key components being present: + * for example a key stored in external hardware. Without this flag + * bn_mod_exp gets called when private key components are absent. + */ +# define RSA_FLAG_EXT_PKEY 0x0020 + +/* + * new with 0.9.6j and 0.9.7b; the built-in + * RSA implementation now uses blinding by + * default (ignoring RSA_FLAG_BLINDING), + * but other engines might not need it + */ +# define RSA_FLAG_NO_BLINDING 0x0080 +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +/* + * Does nothing. Previously this switched off constant time behaviour. + */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define RSA_FLAG_NO_CONSTTIME 0x0000 +# endif +/* deprecated name for the flag*/ +/* + * new with 0.9.7h; the built-in RSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +# define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME +# endif + +/*- + * New with 3.0: use part of the flags to denote exact type of RSA key, + * some of which are limited to specific signature and encryption schemes. + * These different types share the same RSA structure, but indicate the + * use of certain fields in that structure. + * Currently known are: + * RSA - this is the "normal" unlimited RSA structure (typenum 0) + * RSASSA-PSS - indicates that the PSS parameters are used. + * RSAES-OAEP - no specific field used for the moment, but OAEP padding + * is expected. (currently unused) + * + * 4 bits allow for 16 types + */ +# define RSA_FLAG_TYPE_MASK 0xF000 +# define RSA_FLAG_TYPE_RSA 0x0000 +# define RSA_FLAG_TYPE_RSASSAPSS 0x1000 +# define RSA_FLAG_TYPE_RSAESOAEP 0x2000 + +int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad_mode); +int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx, int *pad_mode); + +int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int saltlen); +int EVP_PKEY_CTX_get_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int *saltlen); + +int EVP_PKEY_CTX_set_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int bits); +int EVP_PKEY_CTX_set1_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp); +int EVP_PKEY_CTX_set_rsa_keygen_primes(EVP_PKEY_CTX *ctx, int primes); +int EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(EVP_PKEY_CTX *ctx, int saltlen); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp); +# endif + +/* Salt length matches digest */ +# define RSA_PSS_SALTLEN_DIGEST -1 +/* Verify only: auto detect salt length */ +# define RSA_PSS_SALTLEN_AUTO -2 +/* Set salt length to maximum possible */ +# define RSA_PSS_SALTLEN_MAX -3 +/* Auto-detect on verify, set salt length to min(maximum possible, digest + * length) on sign */ +# define RSA_PSS_SALTLEN_AUTO_DIGEST_MAX -4 +/* Old compatible max salt length for sign only */ +# define RSA_PSS_SALTLEN_MAX_SIGN -2 + +int EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); +int EVP_PKEY_CTX_set_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, const char *mdname, + const char *mdprops); +int EVP_PKEY_CTX_get_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); +int EVP_PKEY_CTX_get_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, char *name, + size_t namelen); +int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); +int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name(EVP_PKEY_CTX *ctx, + const char *mdname); + +int EVP_PKEY_CTX_set_rsa_pss_keygen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); +int EVP_PKEY_CTX_set_rsa_pss_keygen_md_name(EVP_PKEY_CTX *ctx, + const char *mdname, + const char *mdprops); + +int EVP_PKEY_CTX_set_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); +int EVP_PKEY_CTX_set_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, const char *mdname, + const char *mdprops); +int EVP_PKEY_CTX_get_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); +int EVP_PKEY_CTX_get_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, char *name, + size_t namelen); +int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, int llen); +int EVP_PKEY_CTX_get0_rsa_oaep_label(EVP_PKEY_CTX *ctx, unsigned char **label); + +# define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1) +# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2) + +# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS (EVP_PKEY_ALG_CTRL + 3) +# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4) +# define EVP_PKEY_CTRL_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 5) + +# define EVP_PKEY_CTRL_GET_RSA_PADDING (EVP_PKEY_ALG_CTRL + 6) +# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 7) +# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 8) + +# define EVP_PKEY_CTRL_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 9) +# define EVP_PKEY_CTRL_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 10) + +# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 11) +# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12) + +# define EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES (EVP_PKEY_ALG_CTRL + 13) + +# define EVP_PKEY_CTRL_RSA_IMPLICIT_REJECTION (EVP_PKEY_ALG_CTRL + 14) + +# define RSA_PKCS1_PADDING 1 +# define RSA_NO_PADDING 3 +# define RSA_PKCS1_OAEP_PADDING 4 +# define RSA_X931_PADDING 5 + +/* EVP_PKEY_ only */ +# define RSA_PKCS1_PSS_PADDING 6 +# define RSA_PKCS1_WITH_TLS_PADDING 7 + +/* internal RSA_ only */ +# define RSA_PKCS1_NO_IMPLICIT_REJECT_PADDING 8 + +# define RSA_PKCS1_PADDING_SIZE 11 + +# define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) +# define RSA_get_app_data(s) RSA_get_ex_data(s,0) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 RSA *RSA_new(void); +OSSL_DEPRECATEDIN_3_0 RSA *RSA_new_method(ENGINE *engine); +OSSL_DEPRECATEDIN_3_0 int RSA_bits(const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 int RSA_size(const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 int RSA_security_bits(const RSA *rsa); + +OSSL_DEPRECATEDIN_3_0 int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); +OSSL_DEPRECATEDIN_3_0 int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); +OSSL_DEPRECATEDIN_3_0 int RSA_set0_crt_params(RSA *r, + BIGNUM *dmp1, BIGNUM *dmq1, + BIGNUM *iqmp); +OSSL_DEPRECATEDIN_3_0 int RSA_set0_multi_prime_params(RSA *r, + BIGNUM *primes[], + BIGNUM *exps[], + BIGNUM *coeffs[], + int pnum); +OSSL_DEPRECATEDIN_3_0 void RSA_get0_key(const RSA *r, + const BIGNUM **n, const BIGNUM **e, + const BIGNUM **d); +OSSL_DEPRECATEDIN_3_0 void RSA_get0_factors(const RSA *r, + const BIGNUM **p, const BIGNUM **q); +OSSL_DEPRECATEDIN_3_0 int RSA_get_multi_prime_extra_count(const RSA *r); +OSSL_DEPRECATEDIN_3_0 int RSA_get0_multi_prime_factors(const RSA *r, + const BIGNUM *primes[]); +OSSL_DEPRECATEDIN_3_0 void RSA_get0_crt_params(const RSA *r, + const BIGNUM **dmp1, + const BIGNUM **dmq1, + const BIGNUM **iqmp); +OSSL_DEPRECATEDIN_3_0 +int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[], + const BIGNUM *coeffs[]); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_n(const RSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_e(const RSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_d(const RSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_p(const RSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_q(const RSA *d); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_dmp1(const RSA *r); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_dmq1(const RSA *r); +OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_iqmp(const RSA *r); +OSSL_DEPRECATEDIN_3_0 const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r); +OSSL_DEPRECATEDIN_3_0 void RSA_clear_flags(RSA *r, int flags); +OSSL_DEPRECATEDIN_3_0 int RSA_test_flags(const RSA *r, int flags); +OSSL_DEPRECATEDIN_3_0 void RSA_set_flags(RSA *r, int flags); +OSSL_DEPRECATEDIN_3_0 int RSA_get_version(RSA *r); +OSSL_DEPRECATEDIN_3_0 ENGINE *RSA_get0_engine(const RSA *r); +# endif /* !OPENSSL_NO_DEPRECATED_3_0 */ + +# define EVP_RSA_gen(bits) \ + EVP_PKEY_Q_keygen(NULL, NULL, "RSA", (size_t)(0 + (bits))) + +/* Deprecated version */ +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +OSSL_DEPRECATEDIN_0_9_8 RSA *RSA_generate_key(int bits, unsigned long e, void + (*callback) (int, int, void *), + void *cb_arg); +# endif + +/* New version */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, + BN_GENCB *cb); +/* Multi-prime version */ +OSSL_DEPRECATEDIN_3_0 int RSA_generate_multi_prime_key(RSA *rsa, int bits, + int primes, BIGNUM *e, + BN_GENCB *cb); + +OSSL_DEPRECATEDIN_3_0 +int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, + BIGNUM *q1, BIGNUM *q2, + const BIGNUM *Xp1, const BIGNUM *Xp2, + const BIGNUM *Xp, const BIGNUM *Xq1, + const BIGNUM *Xq2, const BIGNUM *Xq, + const BIGNUM *e, BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 int RSA_X931_generate_key_ex(RSA *rsa, int bits, + const BIGNUM *e, + BN_GENCB *cb); + +OSSL_DEPRECATEDIN_3_0 int RSA_check_key(const RSA *); +OSSL_DEPRECATEDIN_3_0 int RSA_check_key_ex(const RSA *, BN_GENCB *cb); + /* next 4 return -1 on error */ +OSSL_DEPRECATEDIN_3_0 +int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to, + RSA *rsa, int padding); +OSSL_DEPRECATEDIN_3_0 +int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to, + RSA *rsa, int padding); +OSSL_DEPRECATEDIN_3_0 +int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to, + RSA *rsa, int padding); +OSSL_DEPRECATEDIN_3_0 +int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to, + RSA *rsa, int padding); +OSSL_DEPRECATEDIN_3_0 void RSA_free(RSA *r); +/* "up" the RSA object's reference count */ +OSSL_DEPRECATEDIN_3_0 int RSA_up_ref(RSA *r); +OSSL_DEPRECATEDIN_3_0 int RSA_flags(const RSA *r); + +OSSL_DEPRECATEDIN_3_0 void RSA_set_default_method(const RSA_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_get_default_method(void); +OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_null_method(void); +OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_get_method(const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); + +/* these are the actual RSA functions */ +OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_PKCS1_OpenSSL(void); + +DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0, + RSA, RSAPublicKey) +DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0, + RSA, RSAPrivateKey) +# endif /* !OPENSSL_NO_DEPRECATED_3_0 */ + +int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2); + +struct rsa_pss_params_st { + X509_ALGOR *hashAlgorithm; + X509_ALGOR *maskGenAlgorithm; + ASN1_INTEGER *saltLength; + ASN1_INTEGER *trailerField; + /* Decoded hash algorithm from maskGenAlgorithm */ + X509_ALGOR *maskHash; +}; + +DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS) +DECLARE_ASN1_DUP_FUNCTION(RSA_PSS_PARAMS) + +typedef struct rsa_oaep_params_st { + X509_ALGOR *hashFunc; + X509_ALGOR *maskGenFunc; + X509_ALGOR *pSourceFunc; + /* Decoded hash algorithm from maskGenFunc */ + X509_ALGOR *maskHash; +} RSA_OAEP_PARAMS; + +DECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_STDIO +OSSL_DEPRECATEDIN_3_0 int RSA_print_fp(FILE *fp, const RSA *r, int offset); +# endif + +OSSL_DEPRECATEDIN_3_0 int RSA_print(BIO *bp, const RSA *r, int offset); + +/* + * The following 2 functions sign and verify a X509_SIG ASN1 object inside + * PKCS#1 padded RSA encryption + */ +OSSL_DEPRECATEDIN_3_0 int RSA_sign(int type, const unsigned char *m, + unsigned int m_length, unsigned char *sigret, + unsigned int *siglen, RSA *rsa); +OSSL_DEPRECATEDIN_3_0 int RSA_verify(int type, const unsigned char *m, + unsigned int m_length, + const unsigned char *sigbuf, + unsigned int siglen, RSA *rsa); + +/* + * The following 2 function sign and verify a ASN1_OCTET_STRING object inside + * PKCS#1 padded RSA encryption + */ +OSSL_DEPRECATEDIN_3_0 +int RSA_sign_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, + RSA *rsa); +OSSL_DEPRECATEDIN_3_0 +int RSA_verify_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, + RSA *rsa); + +OSSL_DEPRECATEDIN_3_0 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 void RSA_blinding_off(RSA *rsa); +OSSL_DEPRECATEDIN_3_0 BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); + +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, + const unsigned char *f, int fl); +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, + const unsigned char *f, int fl, + int rsa_len); +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, + const unsigned char *f, int fl); +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, + const unsigned char *f, int fl, + int rsa_len); +OSSL_DEPRECATEDIN_3_0 int PKCS1_MGF1(unsigned char *mask, long len, + const unsigned char *seed, long seedlen, + const EVP_MD *dgst); +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, + const unsigned char *f, int fl, + const unsigned char *p, int pl); +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, + const unsigned char *f, int fl, int rsa_len, + const unsigned char *p, int pl); +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, + const unsigned char *from, int flen, + const unsigned char *param, int plen, + const EVP_MD *md, const EVP_MD *mgf1md); +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, + const unsigned char *from, int flen, + int num, + const unsigned char *param, int plen, + const EVP_MD *md, const EVP_MD *mgf1md); +OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_none(unsigned char *to, int tlen, + const unsigned char *f, int fl); +OSSL_DEPRECATEDIN_3_0 int RSA_padding_check_none(unsigned char *to, int tlen, + const unsigned char *f, int fl, + int rsa_len); +OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_X931(unsigned char *to, int tlen, + const unsigned char *f, int fl); +OSSL_DEPRECATEDIN_3_0 int RSA_padding_check_X931(unsigned char *to, int tlen, + const unsigned char *f, int fl, + int rsa_len); +OSSL_DEPRECATEDIN_3_0 int RSA_X931_hash_id(int nid); + +OSSL_DEPRECATEDIN_3_0 +int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, + const EVP_MD *Hash, const unsigned char *EM, + int sLen); +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, + const unsigned char *mHash, const EVP_MD *Hash, + int sLen); + +OSSL_DEPRECATEDIN_3_0 +int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, + const EVP_MD *Hash, const EVP_MD *mgf1Hash, + const unsigned char *EM, int sLen); + +OSSL_DEPRECATEDIN_3_0 +int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, + const unsigned char *mHash, + const EVP_MD *Hash, const EVP_MD *mgf1Hash, + int sLen); + +# define RSA_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef) +OSSL_DEPRECATEDIN_3_0 int RSA_set_ex_data(RSA *r, int idx, void *arg); +OSSL_DEPRECATEDIN_3_0 void *RSA_get_ex_data(const RSA *r, int idx); + +DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPublicKey) +DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPrivateKey) + +/* + * If this flag is set the RSA method is FIPS compliant and can be used in + * FIPS mode. This is set in the validated module method. If an application + * sets this flag in its own methods it is its responsibility to ensure the + * result is compliant. + */ + +# define RSA_FLAG_FIPS_METHOD 0x0400 + +/* + * If this flag is set the operations normally disabled in FIPS mode are + * permitted it is then the applications responsibility to ensure that the + * usage is compliant. + */ + +# define RSA_FLAG_NON_FIPS_ALLOW 0x0400 +/* + * Application has decided PRNG is good enough to generate a key: don't + * check. + */ +# define RSA_FLAG_CHECKED 0x0800 + +OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_new(const char *name, int flags); +OSSL_DEPRECATEDIN_3_0 void RSA_meth_free(RSA_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 const char *RSA_meth_get0_name(const RSA_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 int RSA_meth_set1_name(RSA_METHOD *meth, + const char *name); +OSSL_DEPRECATEDIN_3_0 int RSA_meth_get_flags(const RSA_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_flags(RSA_METHOD *meth, int flags); +OSSL_DEPRECATEDIN_3_0 void *RSA_meth_get0_app_data(const RSA_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 int RSA_meth_set0_app_data(RSA_METHOD *meth, + void *app_data); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth)) (int flen, + const unsigned char *from, + unsigned char *to, + RSA *rsa, int padding); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_pub_enc(RSA_METHOD *rsa, + int (*pub_enc) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth)) (int flen, + const unsigned char *from, + unsigned char *to, + RSA *rsa, int padding); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_pub_dec(RSA_METHOD *rsa, + int (*pub_dec) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth)) (int flen, + const unsigned char *from, + unsigned char *to, + RSA *rsa, int padding); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_priv_enc(RSA_METHOD *rsa, + int (*priv_enc) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth)) (int flen, + const unsigned char *from, + unsigned char *to, + RSA *rsa, int padding); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_priv_dec(RSA_METHOD *rsa, + int (*priv_dec) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth)) (BIGNUM *r0, + const BIGNUM *i, + RSA *rsa, BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_mod_exp(RSA_METHOD *rsa, + int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa, + BN_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth)) (BIGNUM *r, + const BIGNUM *a, + const BIGNUM *p, + const BIGNUM *m, + BN_CTX *ctx, + BN_MONT_CTX *m_ctx); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa, + int (*bn_mod_exp) (BIGNUM *r, + const BIGNUM *a, + const BIGNUM *p, + const BIGNUM *m, + BN_CTX *ctx, + BN_MONT_CTX *m_ctx)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_sign(const RSA_METHOD *meth)) (int type, + const unsigned char *m, + unsigned int m_length, + unsigned char *sigret, + unsigned int *siglen, + const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_sign(RSA_METHOD *rsa, + int (*sign) (int type, const unsigned char *m, + unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, + const RSA *rsa)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_verify(const RSA_METHOD *meth)) (int dtype, + const unsigned char *m, + unsigned int m_length, + const unsigned char *sigbuf, + unsigned int siglen, + const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_verify(RSA_METHOD *rsa, + int (*verify) (int dtype, const unsigned char *m, + unsigned int m_length, + const unsigned char *sigbuf, + unsigned int siglen, const RSA *rsa)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_keygen(const RSA_METHOD *meth)) (RSA *rsa, int bits, + BIGNUM *e, BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_keygen(RSA_METHOD *rsa, + int (*keygen) (RSA *rsa, int bits, BIGNUM *e, + BN_GENCB *cb)); +OSSL_DEPRECATEDIN_3_0 +int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth)) (RSA *rsa, + int bits, + int primes, + BIGNUM *e, + BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 +int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth, + int (*keygen) (RSA *rsa, int bits, + int primes, BIGNUM *e, + BN_GENCB *cb)); +#endif /* !OPENSSL_NO_DEPRECATED_3_0 */ + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/rsaerr.h b/illumos-x86_64/usr/include/openssl-3/rsaerr.h new file mode 100644 index 00000000..c58463c7 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/rsaerr.h @@ -0,0 +1,107 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_RSAERR_H +# define OPENSSL_RSAERR_H +# pragma once + +# include +# include +# include + + + +/* + * RSA reason codes. + */ +# define RSA_R_ALGORITHM_MISMATCH 100 +# define RSA_R_BAD_E_VALUE 101 +# define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 +# define RSA_R_BAD_PAD_BYTE_COUNT 103 +# define RSA_R_BAD_SIGNATURE 104 +# define RSA_R_BLOCK_TYPE_IS_NOT_01 106 +# define RSA_R_BLOCK_TYPE_IS_NOT_02 107 +# define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 +# define RSA_R_DATA_TOO_LARGE 109 +# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 +# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 +# define RSA_R_DATA_TOO_SMALL 111 +# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 +# define RSA_R_DIGEST_DOES_NOT_MATCH 158 +# define RSA_R_DIGEST_NOT_ALLOWED 145 +# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 +# define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 +# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 +# define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 +# define RSA_R_FIRST_OCTET_INVALID 133 +# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144 +# define RSA_R_INVALID_DIGEST 157 +# define RSA_R_INVALID_DIGEST_LENGTH 143 +# define RSA_R_INVALID_HEADER 137 +# define RSA_R_INVALID_KEYPAIR 171 +# define RSA_R_INVALID_KEY_LENGTH 173 +# define RSA_R_INVALID_LABEL 160 +# define RSA_R_INVALID_LENGTH 181 +# define RSA_R_INVALID_MESSAGE_LENGTH 131 +# define RSA_R_INVALID_MGF1_MD 156 +# define RSA_R_INVALID_MODULUS 174 +# define RSA_R_INVALID_MULTI_PRIME_KEY 167 +# define RSA_R_INVALID_OAEP_PARAMETERS 161 +# define RSA_R_INVALID_PADDING 138 +# define RSA_R_INVALID_PADDING_MODE 141 +# define RSA_R_INVALID_PSS_PARAMETERS 149 +# define RSA_R_INVALID_PSS_SALTLEN 146 +# define RSA_R_INVALID_REQUEST 175 +# define RSA_R_INVALID_SALT_LENGTH 150 +# define RSA_R_INVALID_STRENGTH 176 +# define RSA_R_INVALID_TRAILER 139 +# define RSA_R_INVALID_X931_DIGEST 142 +# define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 +# define RSA_R_KEY_PRIME_NUM_INVALID 165 +# define RSA_R_KEY_SIZE_TOO_SMALL 120 +# define RSA_R_LAST_OCTET_INVALID 134 +# define RSA_R_MGF1_DIGEST_NOT_ALLOWED 152 +# define RSA_R_MISSING_PRIVATE_KEY 179 +# define RSA_R_MODULUS_TOO_LARGE 105 +# define RSA_R_MP_COEFFICIENT_NOT_INVERSE_OF_R 168 +# define RSA_R_MP_EXPONENT_NOT_CONGRUENT_TO_D 169 +# define RSA_R_MP_R_NOT_PRIME 170 +# define RSA_R_NO_PUBLIC_EXPONENT 140 +# define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 +# define RSA_R_N_DOES_NOT_EQUAL_PRODUCT_OF_PRIMES 172 +# define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 +# define RSA_R_OAEP_DECODING_ERROR 121 +# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148 +# define RSA_R_PADDING_CHECK_FAILED 114 +# define RSA_R_PAIRWISE_TEST_FAILURE 177 +# define RSA_R_PKCS_DECODING_ERROR 159 +# define RSA_R_PSS_SALTLEN_TOO_SMALL 164 +# define RSA_R_PUB_EXPONENT_OUT_OF_RANGE 178 +# define RSA_R_P_NOT_PRIME 128 +# define RSA_R_Q_NOT_PRIME 129 +# define RSA_R_RANDOMNESS_SOURCE_STRENGTH_INSUFFICIENT 180 +# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 +# define RSA_R_SLEN_CHECK_FAILED 136 +# define RSA_R_SLEN_RECOVERY_FAILED 135 +# define RSA_R_SSLV3_ROLLBACK_ATTACK 115 +# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 +# define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 +# define RSA_R_UNKNOWN_DIGEST 166 +# define RSA_R_UNKNOWN_MASK_DIGEST 151 +# define RSA_R_UNKNOWN_PADDING_TYPE 118 +# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE 162 +# define RSA_R_UNSUPPORTED_LABEL_SOURCE 163 +# define RSA_R_UNSUPPORTED_MASK_ALGORITHM 153 +# define RSA_R_UNSUPPORTED_MASK_PARAMETER 154 +# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE 155 +# define RSA_R_VALUE_MISSING 147 +# define RSA_R_WRONG_SIGNATURE_LENGTH 119 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/safestack.h b/illumos-x86_64/usr/include/openssl-3/safestack.h new file mode 100644 index 00000000..0499700b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/safestack.h @@ -0,0 +1,297 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/safestack.h.in + * + * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_SAFESTACK_H +# define OPENSSL_SAFESTACK_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_SAFESTACK_H +# endif + +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +# define STACK_OF(type) struct stack_st_##type + +/* Helper macro for internal use */ +# define SKM_DEFINE_STACK_OF_INTERNAL(t1, t2, t3) \ + STACK_OF(t1); \ + typedef int (*sk_##t1##_compfunc)(const t3 * const *a, const t3 *const *b); \ + typedef void (*sk_##t1##_freefunc)(t3 *a); \ + typedef t3 * (*sk_##t1##_copyfunc)(const t3 *a); \ + static ossl_unused ossl_inline t2 *ossl_check_##t1##_type(t2 *ptr) \ + { \ + return ptr; \ + } \ + static ossl_unused ossl_inline const OPENSSL_STACK *ossl_check_const_##t1##_sk_type(const STACK_OF(t1) *sk) \ + { \ + return (const OPENSSL_STACK *)sk; \ + } \ + static ossl_unused ossl_inline OPENSSL_STACK *ossl_check_##t1##_sk_type(STACK_OF(t1) *sk) \ + { \ + return (OPENSSL_STACK *)sk; \ + } \ + static ossl_unused ossl_inline OPENSSL_sk_compfunc ossl_check_##t1##_compfunc_type(sk_##t1##_compfunc cmp) \ + { \ + return (OPENSSL_sk_compfunc)cmp; \ + } \ + static ossl_unused ossl_inline OPENSSL_sk_copyfunc ossl_check_##t1##_copyfunc_type(sk_##t1##_copyfunc cpy) \ + { \ + return (OPENSSL_sk_copyfunc)cpy; \ + } \ + static ossl_unused ossl_inline OPENSSL_sk_freefunc ossl_check_##t1##_freefunc_type(sk_##t1##_freefunc fr) \ + { \ + return (OPENSSL_sk_freefunc)fr; \ + } + +# define SKM_DEFINE_STACK_OF(t1, t2, t3) \ + STACK_OF(t1); \ + typedef int (*sk_##t1##_compfunc)(const t3 * const *a, const t3 *const *b); \ + typedef void (*sk_##t1##_freefunc)(t3 *a); \ + typedef t3 * (*sk_##t1##_copyfunc)(const t3 *a); \ + static ossl_unused ossl_inline int sk_##t1##_num(const STACK_OF(t1) *sk) \ + { \ + return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) *sk, int idx) \ + { \ + return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new(sk_##t1##_compfunc compare) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new_null(void) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new_reserve(sk_##t1##_compfunc compare, int n) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_new_reserve((OPENSSL_sk_compfunc)compare, n); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_reserve(STACK_OF(t1) *sk, int n) \ + { \ + return OPENSSL_sk_reserve((OPENSSL_STACK *)sk, n); \ + } \ + static ossl_unused ossl_inline void sk_##t1##_free(STACK_OF(t1) *sk) \ + { \ + OPENSSL_sk_free((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline void sk_##t1##_zero(STACK_OF(t1) *sk) \ + { \ + OPENSSL_sk_zero((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) *sk, int i) \ + { \ + return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) *sk, t2 *ptr) \ + { \ + return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \ + (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \ + { \ + return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_unshift(STACK_OF(t1) *sk, t2 *ptr) \ + { \ + return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) *sk) \ + { \ + return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) *sk) \ + { \ + return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline void sk_##t1##_pop_free(STACK_OF(t1) *sk, sk_##t1##_freefunc freefunc) \ + { \ + OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_insert(STACK_OF(t1) *sk, t2 *ptr, int idx) \ + { \ + return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) *sk, int idx, t2 *ptr) \ + { \ + return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \ + { \ + return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) *sk, t2 *ptr) \ + { \ + return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_find_all(STACK_OF(t1) *sk, t2 *ptr, int *pnum) \ + { \ + return OPENSSL_sk_find_all((OPENSSL_STACK *)sk, (const void *)ptr, pnum); \ + } \ + static ossl_unused ossl_inline void sk_##t1##_sort(STACK_OF(t1) *sk) \ + { \ + OPENSSL_sk_sort((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) *sk) \ + { \ + return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) * sk_##t1##_dup(const STACK_OF(t1) *sk) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_deep_copy(const STACK_OF(t1) *sk, \ + sk_##t1##_copyfunc copyfunc, \ + sk_##t1##_freefunc freefunc) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \ + (OPENSSL_sk_copyfunc)copyfunc, \ + (OPENSSL_sk_freefunc)freefunc); \ + } \ + static ossl_unused ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func(STACK_OF(t1) *sk, sk_##t1##_compfunc compare) \ + { \ + return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc)compare); \ + } + +# define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t) +# define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t) +# define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2) +# define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \ + SKM_DEFINE_STACK_OF(t1, const t2, t2) + +/*- + * Strings are special: normally an lhash entry will point to a single + * (somewhat) mutable object. In the case of strings: + * + * a) Instead of a single char, there is an array of chars, NUL-terminated. + * b) The string may have be immutable. + * + * So, they need their own declarations. Especially important for + * type-checking tools, such as Deputy. + * + * In practice, however, it appears to be hard to have a const + * string. For now, I'm settling for dealing with the fact it is a + * string at all. + */ +typedef char *OPENSSL_STRING; +typedef const char *OPENSSL_CSTRING; + +/*- + * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but + * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned + * above, instead of a single char each entry is a NUL-terminated array of + * chars. So, we have to implement STRING specially for STACK_OF. This is + * dealt with in the autogenerated macros below. + */ +SKM_DEFINE_STACK_OF_INTERNAL(OPENSSL_STRING, char, char) +#define sk_OPENSSL_STRING_num(sk) OPENSSL_sk_num(ossl_check_const_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_value(sk, idx) ((char *)OPENSSL_sk_value(ossl_check_const_OPENSSL_STRING_sk_type(sk), (idx))) +#define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new(ossl_check_OPENSSL_STRING_compfunc_type(cmp))) +#define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new_null()) +#define sk_OPENSSL_STRING_new_reserve(cmp, n) ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new_reserve(ossl_check_OPENSSL_STRING_compfunc_type(cmp), (n))) +#define sk_OPENSSL_STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OPENSSL_STRING_sk_type(sk), (n)) +#define sk_OPENSSL_STRING_free(sk) OPENSSL_sk_free(ossl_check_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_zero(sk) OPENSSL_sk_zero(ossl_check_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_delete(sk, i) ((char *)OPENSSL_sk_delete(ossl_check_OPENSSL_STRING_sk_type(sk), (i))) +#define sk_OPENSSL_STRING_delete_ptr(sk, ptr) ((char *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr))) +#define sk_OPENSSL_STRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr)) +#define sk_OPENSSL_STRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr)) +#define sk_OPENSSL_STRING_pop(sk) ((char *)OPENSSL_sk_pop(ossl_check_OPENSSL_STRING_sk_type(sk))) +#define sk_OPENSSL_STRING_shift(sk) ((char *)OPENSSL_sk_shift(ossl_check_OPENSSL_STRING_sk_type(sk))) +#define sk_OPENSSL_STRING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OPENSSL_STRING_sk_type(sk),ossl_check_OPENSSL_STRING_freefunc_type(freefunc)) +#define sk_OPENSSL_STRING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr), (idx)) +#define sk_OPENSSL_STRING_set(sk, idx, ptr) ((char *)OPENSSL_sk_set(ossl_check_OPENSSL_STRING_sk_type(sk), (idx), ossl_check_OPENSSL_STRING_type(ptr))) +#define sk_OPENSSL_STRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr)) +#define sk_OPENSSL_STRING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr)) +#define sk_OPENSSL_STRING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr), pnum) +#define sk_OPENSSL_STRING_sort(sk) OPENSSL_sk_sort(ossl_check_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_dup(sk) ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_dup(ossl_check_const_OPENSSL_STRING_sk_type(sk))) +#define sk_OPENSSL_STRING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_deep_copy(ossl_check_const_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_copyfunc_type(copyfunc), ossl_check_OPENSSL_STRING_freefunc_type(freefunc))) +#define sk_OPENSSL_STRING_set_cmp_func(sk, cmp) ((sk_OPENSSL_STRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(OPENSSL_CSTRING, const char, char) +#define sk_OPENSSL_CSTRING_num(sk) OPENSSL_sk_num(ossl_check_const_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_value(sk, idx) ((const char *)OPENSSL_sk_value(ossl_check_const_OPENSSL_CSTRING_sk_type(sk), (idx))) +#define sk_OPENSSL_CSTRING_new(cmp) ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new(ossl_check_OPENSSL_CSTRING_compfunc_type(cmp))) +#define sk_OPENSSL_CSTRING_new_null() ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new_null()) +#define sk_OPENSSL_CSTRING_new_reserve(cmp, n) ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new_reserve(ossl_check_OPENSSL_CSTRING_compfunc_type(cmp), (n))) +#define sk_OPENSSL_CSTRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OPENSSL_CSTRING_sk_type(sk), (n)) +#define sk_OPENSSL_CSTRING_free(sk) OPENSSL_sk_free(ossl_check_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_zero(sk) OPENSSL_sk_zero(ossl_check_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_delete(sk, i) ((const char *)OPENSSL_sk_delete(ossl_check_OPENSSL_CSTRING_sk_type(sk), (i))) +#define sk_OPENSSL_CSTRING_delete_ptr(sk, ptr) ((const char *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr))) +#define sk_OPENSSL_CSTRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr)) +#define sk_OPENSSL_CSTRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr)) +#define sk_OPENSSL_CSTRING_pop(sk) ((const char *)OPENSSL_sk_pop(ossl_check_OPENSSL_CSTRING_sk_type(sk))) +#define sk_OPENSSL_CSTRING_shift(sk) ((const char *)OPENSSL_sk_shift(ossl_check_OPENSSL_CSTRING_sk_type(sk))) +#define sk_OPENSSL_CSTRING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OPENSSL_CSTRING_sk_type(sk),ossl_check_OPENSSL_CSTRING_freefunc_type(freefunc)) +#define sk_OPENSSL_CSTRING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr), (idx)) +#define sk_OPENSSL_CSTRING_set(sk, idx, ptr) ((const char *)OPENSSL_sk_set(ossl_check_OPENSSL_CSTRING_sk_type(sk), (idx), ossl_check_OPENSSL_CSTRING_type(ptr))) +#define sk_OPENSSL_CSTRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr)) +#define sk_OPENSSL_CSTRING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr)) +#define sk_OPENSSL_CSTRING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr), pnum) +#define sk_OPENSSL_CSTRING_sort(sk) OPENSSL_sk_sort(ossl_check_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_dup(sk) ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_dup(ossl_check_const_OPENSSL_CSTRING_sk_type(sk))) +#define sk_OPENSSL_CSTRING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_deep_copy(ossl_check_const_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_copyfunc_type(copyfunc), ossl_check_OPENSSL_CSTRING_freefunc_type(freefunc))) +#define sk_OPENSSL_CSTRING_set_cmp_func(sk, cmp) ((sk_OPENSSL_CSTRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_compfunc_type(cmp))) + + +#if !defined(OPENSSL_NO_DEPRECATED_3_0) +/* + * This is not used by OpenSSL. A block of bytes, NOT nul-terminated. + * These should also be distinguished from "normal" stacks. + */ +typedef void *OPENSSL_BLOCK; +SKM_DEFINE_STACK_OF_INTERNAL(OPENSSL_BLOCK, void, void) +#define sk_OPENSSL_BLOCK_num(sk) OPENSSL_sk_num(ossl_check_const_OPENSSL_BLOCK_sk_type(sk)) +#define sk_OPENSSL_BLOCK_value(sk, idx) ((void *)OPENSSL_sk_value(ossl_check_const_OPENSSL_BLOCK_sk_type(sk), (idx))) +#define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new(ossl_check_OPENSSL_BLOCK_compfunc_type(cmp))) +#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new_null()) +#define sk_OPENSSL_BLOCK_new_reserve(cmp, n) ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new_reserve(ossl_check_OPENSSL_BLOCK_compfunc_type(cmp), (n))) +#define sk_OPENSSL_BLOCK_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OPENSSL_BLOCK_sk_type(sk), (n)) +#define sk_OPENSSL_BLOCK_free(sk) OPENSSL_sk_free(ossl_check_OPENSSL_BLOCK_sk_type(sk)) +#define sk_OPENSSL_BLOCK_zero(sk) OPENSSL_sk_zero(ossl_check_OPENSSL_BLOCK_sk_type(sk)) +#define sk_OPENSSL_BLOCK_delete(sk, i) ((void *)OPENSSL_sk_delete(ossl_check_OPENSSL_BLOCK_sk_type(sk), (i))) +#define sk_OPENSSL_BLOCK_delete_ptr(sk, ptr) ((void *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr))) +#define sk_OPENSSL_BLOCK_push(sk, ptr) OPENSSL_sk_push(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr)) +#define sk_OPENSSL_BLOCK_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr)) +#define sk_OPENSSL_BLOCK_pop(sk) ((void *)OPENSSL_sk_pop(ossl_check_OPENSSL_BLOCK_sk_type(sk))) +#define sk_OPENSSL_BLOCK_shift(sk) ((void *)OPENSSL_sk_shift(ossl_check_OPENSSL_BLOCK_sk_type(sk))) +#define sk_OPENSSL_BLOCK_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OPENSSL_BLOCK_sk_type(sk),ossl_check_OPENSSL_BLOCK_freefunc_type(freefunc)) +#define sk_OPENSSL_BLOCK_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr), (idx)) +#define sk_OPENSSL_BLOCK_set(sk, idx, ptr) ((void *)OPENSSL_sk_set(ossl_check_OPENSSL_BLOCK_sk_type(sk), (idx), ossl_check_OPENSSL_BLOCK_type(ptr))) +#define sk_OPENSSL_BLOCK_find(sk, ptr) OPENSSL_sk_find(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr)) +#define sk_OPENSSL_BLOCK_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr)) +#define sk_OPENSSL_BLOCK_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr), pnum) +#define sk_OPENSSL_BLOCK_sort(sk) OPENSSL_sk_sort(ossl_check_OPENSSL_BLOCK_sk_type(sk)) +#define sk_OPENSSL_BLOCK_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_BLOCK_sk_type(sk)) +#define sk_OPENSSL_BLOCK_dup(sk) ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_dup(ossl_check_const_OPENSSL_BLOCK_sk_type(sk))) +#define sk_OPENSSL_BLOCK_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_deep_copy(ossl_check_const_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_copyfunc_type(copyfunc), ossl_check_OPENSSL_BLOCK_freefunc_type(freefunc))) +#define sk_OPENSSL_BLOCK_set_cmp_func(sk, cmp) ((sk_OPENSSL_BLOCK_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_compfunc_type(cmp))) + +#endif + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/seed.h b/illumos-x86_64/usr/include/openssl-3/seed.h new file mode 100644 index 00000000..edb218ae --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/seed.h @@ -0,0 +1,113 @@ +/* + * Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Neither the name of author nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef OPENSSL_SEED_H +# define OPENSSL_SEED_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_SEED_H +# endif + +# include + +# ifndef OPENSSL_NO_SEED +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define SEED_BLOCK_SIZE 16 +# define SEED_KEY_LENGTH 16 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* look whether we need 'long' to get 32 bits */ +# ifdef AES_LONG +# ifndef SEED_LONG +# define SEED_LONG 1 +# endif +# endif + + +typedef struct seed_key_st { +# ifdef SEED_LONG + unsigned long data[32]; +# else + unsigned int data[32]; +# endif +} SEED_KEY_SCHEDULE; +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], + SEED_KEY_SCHEDULE *ks); +OSSL_DEPRECATEDIN_3_0 +void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], + unsigned char d[SEED_BLOCK_SIZE], + const SEED_KEY_SCHEDULE *ks); +OSSL_DEPRECATEDIN_3_0 +void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], + unsigned char d[SEED_BLOCK_SIZE], + const SEED_KEY_SCHEDULE *ks); +OSSL_DEPRECATEDIN_3_0 +void SEED_ecb_encrypt(const unsigned char *in, + unsigned char *out, + const SEED_KEY_SCHEDULE *ks, int enc); +OSSL_DEPRECATEDIN_3_0 +void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, + const SEED_KEY_SCHEDULE *ks, + unsigned char ivec[SEED_BLOCK_SIZE], + int enc); +OSSL_DEPRECATEDIN_3_0 +void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const SEED_KEY_SCHEDULE *ks, + unsigned char ivec[SEED_BLOCK_SIZE], + int *num, int enc); +OSSL_DEPRECATEDIN_3_0 +void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const SEED_KEY_SCHEDULE *ks, + unsigned char ivec[SEED_BLOCK_SIZE], + int *num); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/self_test.h b/illumos-x86_64/usr/include/openssl-3/self_test.h new file mode 100644 index 00000000..6c81cef4 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/self_test.h @@ -0,0 +1,114 @@ +/* + * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_SELF_TEST_H +# define OPENSSL_SELF_TEST_H +# pragma once + +# include /* OSSL_CALLBACK */ + +# ifdef __cplusplus +extern "C" { +# endif + +/* The test event phases */ +# define OSSL_SELF_TEST_PHASE_NONE "None" +# define OSSL_SELF_TEST_PHASE_START "Start" +# define OSSL_SELF_TEST_PHASE_CORRUPT "Corrupt" +# define OSSL_SELF_TEST_PHASE_PASS "Pass" +# define OSSL_SELF_TEST_PHASE_FAIL "Fail" + +/* Test event categories */ +# define OSSL_SELF_TEST_TYPE_NONE "None" +# define OSSL_SELF_TEST_TYPE_MODULE_INTEGRITY "Module_Integrity" +# define OSSL_SELF_TEST_TYPE_INSTALL_INTEGRITY "Install_Integrity" +# define OSSL_SELF_TEST_TYPE_CRNG "Continuous_RNG_Test" +# define OSSL_SELF_TEST_TYPE_PCT "Conditional_PCT" +# define OSSL_SELF_TEST_TYPE_PCT_KAT "Conditional_KAT" +# define OSSL_SELF_TEST_TYPE_PCT_IMPORT "Import_PCT" +# define OSSL_SELF_TEST_TYPE_KAT_INTEGRITY "KAT_Integrity" +# define OSSL_SELF_TEST_TYPE_KAT_CIPHER "KAT_Cipher" +# define OSSL_SELF_TEST_TYPE_KAT_ASYM_CIPHER "KAT_AsymmetricCipher" +# define OSSL_SELF_TEST_TYPE_KAT_ASYM_KEYGEN "KAT_AsymmetricKeyGeneration" +# define OSSL_SELF_TEST_TYPE_KAT_KEM "KAT_KEM" +# define OSSL_SELF_TEST_TYPE_KAT_DIGEST "KAT_Digest" +# define OSSL_SELF_TEST_TYPE_KAT_SIGNATURE "KAT_Signature" +# define OSSL_SELF_TEST_TYPE_PCT_SIGNATURE "PCT_Signature" +# define OSSL_SELF_TEST_TYPE_KAT_KDF "KAT_KDF" +# define OSSL_SELF_TEST_TYPE_KAT_KA "KAT_KA" +# define OSSL_SELF_TEST_TYPE_DRBG "DRBG" + +/* Test event sub categories */ +# define OSSL_SELF_TEST_DESC_NONE "None" +# define OSSL_SELF_TEST_DESC_INTEGRITY_HMAC "HMAC" +# define OSSL_SELF_TEST_DESC_PCT_RSA "RSA" +# define OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1 "RSA" +# define OSSL_SELF_TEST_DESC_PCT_ECDSA "ECDSA" +# define OSSL_SELF_TEST_DESC_PCT_EDDSA "EDDSA" +# define OSSL_SELF_TEST_DESC_PCT_DH "DH" +# define OSSL_SELF_TEST_DESC_PCT_DSA "DSA" +# define OSSL_SELF_TEST_DESC_PCT_ML_DSA "ML-DSA" +# define OSSL_SELF_TEST_DESC_PCT_ML_KEM "ML-KEM" +# define OSSL_SELF_TEST_DESC_PCT_SLH_DSA "SLH-DSA" +# define OSSL_SELF_TEST_DESC_CIPHER_AES_GCM "AES_GCM" +# define OSSL_SELF_TEST_DESC_CIPHER_AES_ECB "AES_ECB_Decrypt" +# define OSSL_SELF_TEST_DESC_CIPHER_TDES "TDES" +# define OSSL_SELF_TEST_DESC_ASYM_RSA_ENC "RSA_Encrypt" +# define OSSL_SELF_TEST_DESC_ASYM_RSA_DEC "RSA_Decrypt" +# define OSSL_SELF_TEST_DESC_MD_SHA1 "SHA1" +# define OSSL_SELF_TEST_DESC_MD_SHA2 "SHA2" +# define OSSL_SELF_TEST_DESC_MD_SHA3 "SHA3" +# define OSSL_SELF_TEST_DESC_SIGN_DSA "DSA" +# define OSSL_SELF_TEST_DESC_SIGN_RSA "RSA" +# define OSSL_SELF_TEST_DESC_SIGN_ECDSA "ECDSA" +# define OSSL_SELF_TEST_DESC_SIGN_EDDSA "EDDSA" +# define OSSL_SELF_TEST_DESC_SIGN_ML_DSA "ML-DSA" +# define OSSL_SELF_TEST_DESC_SIGN_SLH_DSA "SLH-DSA" +# define OSSL_SELF_TEST_DESC_KEM "KEM" +# define OSSL_SELF_TEST_DESC_DRBG_CTR "CTR" +# define OSSL_SELF_TEST_DESC_DRBG_HASH "HASH" +# define OSSL_SELF_TEST_DESC_DRBG_HMAC "HMAC" +# define OSSL_SELF_TEST_DESC_KA_DH "DH" +# define OSSL_SELF_TEST_DESC_KA_ECDH "ECDH" +# define OSSL_SELF_TEST_DESC_KDF_HKDF "HKDF" +# define OSSL_SELF_TEST_DESC_KDF_SSKDF "SSKDF" +# define OSSL_SELF_TEST_DESC_KDF_X963KDF "X963KDF" +# define OSSL_SELF_TEST_DESC_KDF_X942KDF "X942KDF" +# define OSSL_SELF_TEST_DESC_KDF_PBKDF2 "PBKDF2" +# define OSSL_SELF_TEST_DESC_KDF_SSHKDF "SSHKDF" +# define OSSL_SELF_TEST_DESC_KDF_TLS12_PRF "TLS12_PRF" +# define OSSL_SELF_TEST_DESC_KDF_KBKDF "KBKDF" +# define OSSL_SELF_TEST_DESC_KDF_KBKDF_KMAC "KBKDF_KMAC" +# define OSSL_SELF_TEST_DESC_KDF_TLS13_EXTRACT "TLS13_KDF_EXTRACT" +# define OSSL_SELF_TEST_DESC_KDF_TLS13_EXPAND "TLS13_KDF_EXPAND" +# define OSSL_SELF_TEST_DESC_RNG "RNG" +# define OSSL_SELF_TEST_DESC_KEYGEN_ML_DSA "ML-DSA" +# define OSSL_SELF_TEST_DESC_KEYGEN_ML_KEM "ML-KEM" +# define OSSL_SELF_TEST_DESC_KEYGEN_SLH_DSA "SLH-DSA" +# define OSSL_SELF_TEST_DESC_ENCAP_KEM "KEM_Encap" +# define OSSL_SELF_TEST_DESC_DECAP_KEM "KEM_Decap" +# define OSSL_SELF_TEST_DESC_DECAP_KEM_FAIL "KEM_Decap_Reject" + +void OSSL_SELF_TEST_set_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK *cb, + void *cbarg); +void OSSL_SELF_TEST_get_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK **cb, + void **cbarg); + +OSSL_SELF_TEST *OSSL_SELF_TEST_new(OSSL_CALLBACK *cb, void *cbarg); +void OSSL_SELF_TEST_free(OSSL_SELF_TEST *st); + +void OSSL_SELF_TEST_onbegin(OSSL_SELF_TEST *st, const char *type, + const char *desc); +int OSSL_SELF_TEST_oncorrupt_byte(OSSL_SELF_TEST *st, unsigned char *bytes); +void OSSL_SELF_TEST_onend(OSSL_SELF_TEST *st, int ret); + +# ifdef __cplusplus +} +# endif +#endif /* OPENSSL_SELF_TEST_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/sha.h b/illumos-x86_64/usr/include/openssl-3/sha.h new file mode 100644 index 00000000..163a7d58 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/sha.h @@ -0,0 +1,139 @@ +/* + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_SHA_H +# define OPENSSL_SHA_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_SHA_H +# endif + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define SHA_DIGEST_LENGTH 20 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/*- + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! SHA_LONG has to be at least 32 bits wide. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ +# define SHA_LONG unsigned int + +# define SHA_LBLOCK 16 +# define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a + * contiguous array of 32 bit wide + * big-endian values. */ +# define SHA_LAST_BLOCK (SHA_CBLOCK-8) + +typedef struct SHAstate_st { + SHA_LONG h0, h1, h2, h3, h4; + SHA_LONG Nl, Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num; +} SHA_CTX; + +OSSL_DEPRECATEDIN_3_0 int SHA1_Init(SHA_CTX *c); +OSSL_DEPRECATEDIN_3_0 int SHA1_Update(SHA_CTX *c, const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA1_Final(unsigned char *md, SHA_CTX *c); +OSSL_DEPRECATEDIN_3_0 void SHA1_Transform(SHA_CTX *c, const unsigned char *data); +# endif + +unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a + * contiguous array of 32 bit wide + * big-endian values. */ + +typedef struct SHA256state_st { + SHA_LONG h[8]; + SHA_LONG Nl, Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num, md_len; +} SHA256_CTX; + +OSSL_DEPRECATEDIN_3_0 int SHA224_Init(SHA256_CTX *c); +OSSL_DEPRECATEDIN_3_0 int SHA224_Update(SHA256_CTX *c, + const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA224_Final(unsigned char *md, SHA256_CTX *c); +OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c); +OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c, + const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c); +OSSL_DEPRECATEDIN_3_0 void SHA256_Transform(SHA256_CTX *c, + const unsigned char *data); +# endif + +unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md); +unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md); + +# define SHA256_192_DIGEST_LENGTH 24 +# define SHA224_DIGEST_LENGTH 28 +# define SHA256_DIGEST_LENGTH 32 +# define SHA384_DIGEST_LENGTH 48 +# define SHA512_DIGEST_LENGTH 64 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* + * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 + * being exactly 64-bit wide. See Implementation Notes in sha512.c + * for further details. + */ +/* + * SHA-512 treats input data as a + * contiguous array of 64 bit + * wide big-endian values. + */ +# define SHA512_CBLOCK (SHA_LBLOCK*8) +# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) +# define SHA_LONG64 unsigned __int64 +# elif defined(__arch64__) +# define SHA_LONG64 unsigned long +# else +# define SHA_LONG64 unsigned long long +# endif + +typedef struct SHA512state_st { + SHA_LONG64 h[8]; + SHA_LONG64 Nl, Nh; + union { + SHA_LONG64 d[SHA_LBLOCK]; + unsigned char p[SHA512_CBLOCK]; + } u; + unsigned int num, md_len; +} SHA512_CTX; + +OSSL_DEPRECATEDIN_3_0 int SHA384_Init(SHA512_CTX *c); +OSSL_DEPRECATEDIN_3_0 int SHA384_Update(SHA512_CTX *c, + const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA384_Final(unsigned char *md, SHA512_CTX *c); +OSSL_DEPRECATEDIN_3_0 int SHA512_Init(SHA512_CTX *c); +OSSL_DEPRECATEDIN_3_0 int SHA512_Update(SHA512_CTX *c, + const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA512_Final(unsigned char *md, SHA512_CTX *c); +OSSL_DEPRECATEDIN_3_0 void SHA512_Transform(SHA512_CTX *c, + const unsigned char *data); +# endif + +unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md); +unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/srp.h b/illumos-x86_64/usr/include/openssl-3/srp.h new file mode 100644 index 00000000..a48766c6 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/srp.h @@ -0,0 +1,285 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/srp.h.in + * + * Copyright 2004-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2004, EdelKey Project. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + * + * Originally written by Christophe Renou and Peter Sylvester, + * for the EdelKey project. + */ + + + +#ifndef OPENSSL_SRP_H +# define OPENSSL_SRP_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_SRP_H +# endif + +#include + +#ifndef OPENSSL_NO_SRP +# include +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 + +typedef struct SRP_gN_cache_st { + char *b64_bn; + BIGNUM *bn; +} SRP_gN_cache; +SKM_DEFINE_STACK_OF_INTERNAL(SRP_gN_cache, SRP_gN_cache, SRP_gN_cache) +#define sk_SRP_gN_cache_num(sk) OPENSSL_sk_num(ossl_check_const_SRP_gN_cache_sk_type(sk)) +#define sk_SRP_gN_cache_value(sk, idx) ((SRP_gN_cache *)OPENSSL_sk_value(ossl_check_const_SRP_gN_cache_sk_type(sk), (idx))) +#define sk_SRP_gN_cache_new(cmp) ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new(ossl_check_SRP_gN_cache_compfunc_type(cmp))) +#define sk_SRP_gN_cache_new_null() ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new_null()) +#define sk_SRP_gN_cache_new_reserve(cmp, n) ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new_reserve(ossl_check_SRP_gN_cache_compfunc_type(cmp), (n))) +#define sk_SRP_gN_cache_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SRP_gN_cache_sk_type(sk), (n)) +#define sk_SRP_gN_cache_free(sk) OPENSSL_sk_free(ossl_check_SRP_gN_cache_sk_type(sk)) +#define sk_SRP_gN_cache_zero(sk) OPENSSL_sk_zero(ossl_check_SRP_gN_cache_sk_type(sk)) +#define sk_SRP_gN_cache_delete(sk, i) ((SRP_gN_cache *)OPENSSL_sk_delete(ossl_check_SRP_gN_cache_sk_type(sk), (i))) +#define sk_SRP_gN_cache_delete_ptr(sk, ptr) ((SRP_gN_cache *)OPENSSL_sk_delete_ptr(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr))) +#define sk_SRP_gN_cache_push(sk, ptr) OPENSSL_sk_push(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr)) +#define sk_SRP_gN_cache_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr)) +#define sk_SRP_gN_cache_pop(sk) ((SRP_gN_cache *)OPENSSL_sk_pop(ossl_check_SRP_gN_cache_sk_type(sk))) +#define sk_SRP_gN_cache_shift(sk) ((SRP_gN_cache *)OPENSSL_sk_shift(ossl_check_SRP_gN_cache_sk_type(sk))) +#define sk_SRP_gN_cache_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SRP_gN_cache_sk_type(sk),ossl_check_SRP_gN_cache_freefunc_type(freefunc)) +#define sk_SRP_gN_cache_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr), (idx)) +#define sk_SRP_gN_cache_set(sk, idx, ptr) ((SRP_gN_cache *)OPENSSL_sk_set(ossl_check_SRP_gN_cache_sk_type(sk), (idx), ossl_check_SRP_gN_cache_type(ptr))) +#define sk_SRP_gN_cache_find(sk, ptr) OPENSSL_sk_find(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr)) +#define sk_SRP_gN_cache_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr)) +#define sk_SRP_gN_cache_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr), pnum) +#define sk_SRP_gN_cache_sort(sk) OPENSSL_sk_sort(ossl_check_SRP_gN_cache_sk_type(sk)) +#define sk_SRP_gN_cache_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SRP_gN_cache_sk_type(sk)) +#define sk_SRP_gN_cache_dup(sk) ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_dup(ossl_check_const_SRP_gN_cache_sk_type(sk))) +#define sk_SRP_gN_cache_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_deep_copy(ossl_check_const_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_copyfunc_type(copyfunc), ossl_check_SRP_gN_cache_freefunc_type(freefunc))) +#define sk_SRP_gN_cache_set_cmp_func(sk, cmp) ((sk_SRP_gN_cache_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_compfunc_type(cmp))) + + + +typedef struct SRP_user_pwd_st { + /* Owned by us. */ + char *id; + BIGNUM *s; + BIGNUM *v; + /* Not owned by us. */ + const BIGNUM *g; + const BIGNUM *N; + /* Owned by us. */ + char *info; +} SRP_user_pwd; +SKM_DEFINE_STACK_OF_INTERNAL(SRP_user_pwd, SRP_user_pwd, SRP_user_pwd) +#define sk_SRP_user_pwd_num(sk) OPENSSL_sk_num(ossl_check_const_SRP_user_pwd_sk_type(sk)) +#define sk_SRP_user_pwd_value(sk, idx) ((SRP_user_pwd *)OPENSSL_sk_value(ossl_check_const_SRP_user_pwd_sk_type(sk), (idx))) +#define sk_SRP_user_pwd_new(cmp) ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new(ossl_check_SRP_user_pwd_compfunc_type(cmp))) +#define sk_SRP_user_pwd_new_null() ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new_null()) +#define sk_SRP_user_pwd_new_reserve(cmp, n) ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new_reserve(ossl_check_SRP_user_pwd_compfunc_type(cmp), (n))) +#define sk_SRP_user_pwd_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SRP_user_pwd_sk_type(sk), (n)) +#define sk_SRP_user_pwd_free(sk) OPENSSL_sk_free(ossl_check_SRP_user_pwd_sk_type(sk)) +#define sk_SRP_user_pwd_zero(sk) OPENSSL_sk_zero(ossl_check_SRP_user_pwd_sk_type(sk)) +#define sk_SRP_user_pwd_delete(sk, i) ((SRP_user_pwd *)OPENSSL_sk_delete(ossl_check_SRP_user_pwd_sk_type(sk), (i))) +#define sk_SRP_user_pwd_delete_ptr(sk, ptr) ((SRP_user_pwd *)OPENSSL_sk_delete_ptr(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr))) +#define sk_SRP_user_pwd_push(sk, ptr) OPENSSL_sk_push(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr)) +#define sk_SRP_user_pwd_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr)) +#define sk_SRP_user_pwd_pop(sk) ((SRP_user_pwd *)OPENSSL_sk_pop(ossl_check_SRP_user_pwd_sk_type(sk))) +#define sk_SRP_user_pwd_shift(sk) ((SRP_user_pwd *)OPENSSL_sk_shift(ossl_check_SRP_user_pwd_sk_type(sk))) +#define sk_SRP_user_pwd_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SRP_user_pwd_sk_type(sk),ossl_check_SRP_user_pwd_freefunc_type(freefunc)) +#define sk_SRP_user_pwd_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr), (idx)) +#define sk_SRP_user_pwd_set(sk, idx, ptr) ((SRP_user_pwd *)OPENSSL_sk_set(ossl_check_SRP_user_pwd_sk_type(sk), (idx), ossl_check_SRP_user_pwd_type(ptr))) +#define sk_SRP_user_pwd_find(sk, ptr) OPENSSL_sk_find(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr)) +#define sk_SRP_user_pwd_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr)) +#define sk_SRP_user_pwd_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr), pnum) +#define sk_SRP_user_pwd_sort(sk) OPENSSL_sk_sort(ossl_check_SRP_user_pwd_sk_type(sk)) +#define sk_SRP_user_pwd_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SRP_user_pwd_sk_type(sk)) +#define sk_SRP_user_pwd_dup(sk) ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_dup(ossl_check_const_SRP_user_pwd_sk_type(sk))) +#define sk_SRP_user_pwd_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_deep_copy(ossl_check_const_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_copyfunc_type(copyfunc), ossl_check_SRP_user_pwd_freefunc_type(freefunc))) +#define sk_SRP_user_pwd_set_cmp_func(sk, cmp) ((sk_SRP_user_pwd_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_compfunc_type(cmp))) + + +OSSL_DEPRECATEDIN_3_0 +SRP_user_pwd *SRP_user_pwd_new(void); +OSSL_DEPRECATEDIN_3_0 +void SRP_user_pwd_free(SRP_user_pwd *user_pwd); + +OSSL_DEPRECATEDIN_3_0 +void SRP_user_pwd_set_gN(SRP_user_pwd *user_pwd, const BIGNUM *g, + const BIGNUM *N); +OSSL_DEPRECATEDIN_3_0 +int SRP_user_pwd_set1_ids(SRP_user_pwd *user_pwd, const char *id, + const char *info); +OSSL_DEPRECATEDIN_3_0 +int SRP_user_pwd_set0_sv(SRP_user_pwd *user_pwd, BIGNUM *s, BIGNUM *v); + +typedef struct SRP_VBASE_st { + STACK_OF(SRP_user_pwd) *users_pwd; + STACK_OF(SRP_gN_cache) *gN_cache; +/* to simulate a user */ + char *seed_key; + const BIGNUM *default_g; + const BIGNUM *default_N; +} SRP_VBASE; + +/* + * Internal structure storing N and g pair + */ +typedef struct SRP_gN_st { + char *id; + const BIGNUM *g; + const BIGNUM *N; +} SRP_gN; +SKM_DEFINE_STACK_OF_INTERNAL(SRP_gN, SRP_gN, SRP_gN) +#define sk_SRP_gN_num(sk) OPENSSL_sk_num(ossl_check_const_SRP_gN_sk_type(sk)) +#define sk_SRP_gN_value(sk, idx) ((SRP_gN *)OPENSSL_sk_value(ossl_check_const_SRP_gN_sk_type(sk), (idx))) +#define sk_SRP_gN_new(cmp) ((STACK_OF(SRP_gN) *)OPENSSL_sk_new(ossl_check_SRP_gN_compfunc_type(cmp))) +#define sk_SRP_gN_new_null() ((STACK_OF(SRP_gN) *)OPENSSL_sk_new_null()) +#define sk_SRP_gN_new_reserve(cmp, n) ((STACK_OF(SRP_gN) *)OPENSSL_sk_new_reserve(ossl_check_SRP_gN_compfunc_type(cmp), (n))) +#define sk_SRP_gN_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SRP_gN_sk_type(sk), (n)) +#define sk_SRP_gN_free(sk) OPENSSL_sk_free(ossl_check_SRP_gN_sk_type(sk)) +#define sk_SRP_gN_zero(sk) OPENSSL_sk_zero(ossl_check_SRP_gN_sk_type(sk)) +#define sk_SRP_gN_delete(sk, i) ((SRP_gN *)OPENSSL_sk_delete(ossl_check_SRP_gN_sk_type(sk), (i))) +#define sk_SRP_gN_delete_ptr(sk, ptr) ((SRP_gN *)OPENSSL_sk_delete_ptr(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr))) +#define sk_SRP_gN_push(sk, ptr) OPENSSL_sk_push(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr)) +#define sk_SRP_gN_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr)) +#define sk_SRP_gN_pop(sk) ((SRP_gN *)OPENSSL_sk_pop(ossl_check_SRP_gN_sk_type(sk))) +#define sk_SRP_gN_shift(sk) ((SRP_gN *)OPENSSL_sk_shift(ossl_check_SRP_gN_sk_type(sk))) +#define sk_SRP_gN_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SRP_gN_sk_type(sk),ossl_check_SRP_gN_freefunc_type(freefunc)) +#define sk_SRP_gN_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr), (idx)) +#define sk_SRP_gN_set(sk, idx, ptr) ((SRP_gN *)OPENSSL_sk_set(ossl_check_SRP_gN_sk_type(sk), (idx), ossl_check_SRP_gN_type(ptr))) +#define sk_SRP_gN_find(sk, ptr) OPENSSL_sk_find(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr)) +#define sk_SRP_gN_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr)) +#define sk_SRP_gN_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr), pnum) +#define sk_SRP_gN_sort(sk) OPENSSL_sk_sort(ossl_check_SRP_gN_sk_type(sk)) +#define sk_SRP_gN_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SRP_gN_sk_type(sk)) +#define sk_SRP_gN_dup(sk) ((STACK_OF(SRP_gN) *)OPENSSL_sk_dup(ossl_check_const_SRP_gN_sk_type(sk))) +#define sk_SRP_gN_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SRP_gN) *)OPENSSL_sk_deep_copy(ossl_check_const_SRP_gN_sk_type(sk), ossl_check_SRP_gN_copyfunc_type(copyfunc), ossl_check_SRP_gN_freefunc_type(freefunc))) +#define sk_SRP_gN_set_cmp_func(sk, cmp) ((sk_SRP_gN_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_compfunc_type(cmp))) + + + +OSSL_DEPRECATEDIN_3_0 +SRP_VBASE *SRP_VBASE_new(char *seed_key); +OSSL_DEPRECATEDIN_3_0 +void SRP_VBASE_free(SRP_VBASE *vb); +OSSL_DEPRECATEDIN_3_0 +int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file); + +OSSL_DEPRECATEDIN_3_0 +int SRP_VBASE_add0_user(SRP_VBASE *vb, SRP_user_pwd *user_pwd); + +/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/ +OSSL_DEPRECATEDIN_3_0 +SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username); + +OSSL_DEPRECATEDIN_3_0 +char *SRP_create_verifier_ex(const char *user, const char *pass, char **salt, + char **verifier, const char *N, const char *g, + OSSL_LIB_CTX *libctx, const char *propq); +OSSL_DEPRECATEDIN_3_0 +char *SRP_create_verifier(const char *user, const char *pass, char **salt, + char **verifier, const char *N, const char *g); +OSSL_DEPRECATEDIN_3_0 +int SRP_create_verifier_BN_ex(const char *user, const char *pass, BIGNUM **salt, + BIGNUM **verifier, const BIGNUM *N, + const BIGNUM *g, OSSL_LIB_CTX *libctx, + const char *propq); +OSSL_DEPRECATEDIN_3_0 +int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, + BIGNUM **verifier, const BIGNUM *N, + const BIGNUM *g); + +# define SRP_NO_ERROR 0 +# define SRP_ERR_VBASE_INCOMPLETE_FILE 1 +# define SRP_ERR_VBASE_BN_LIB 2 +# define SRP_ERR_OPEN_FILE 3 +# define SRP_ERR_MEMORY 4 + +# define DB_srptype 0 +# define DB_srpverifier 1 +# define DB_srpsalt 2 +# define DB_srpid 3 +# define DB_srpgN 4 +# define DB_srpinfo 5 +# undef DB_NUMBER +# define DB_NUMBER 6 + +# define DB_SRP_INDEX 'I' +# define DB_SRP_VALID 'V' +# define DB_SRP_REVOKED 'R' +# define DB_SRP_MODIF 'v' + +/* see srp.c */ +OSSL_DEPRECATEDIN_3_0 +char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N); +OSSL_DEPRECATEDIN_3_0 +SRP_gN *SRP_get_default_gN(const char *id); + +/* server side .... */ +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u, + const BIGNUM *b, const BIGNUM *N); +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_B_ex(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, + const BIGNUM *v, OSSL_LIB_CTX *libctx, const char *propq); +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, + const BIGNUM *v); + +OSSL_DEPRECATEDIN_3_0 +int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N); +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_u_ex(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N, + OSSL_LIB_CTX *libctx, const char *propq); +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N); + +/* client side .... */ + +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_x_ex(const BIGNUM *s, const char *user, const char *pass, + OSSL_LIB_CTX *libctx, const char *propq); +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass); +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g); +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_client_key_ex(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g, + const BIGNUM *x, const BIGNUM *a, const BIGNUM *u, + OSSL_LIB_CTX *libctx, const char *propq); +OSSL_DEPRECATEDIN_3_0 +BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g, + const BIGNUM *x, const BIGNUM *a, const BIGNUM *u); +OSSL_DEPRECATEDIN_3_0 +int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N); + +# define SRP_MINIMAL_N 1024 + +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +/* This method ignores the configured seed and fails for an unknown user. */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 +SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/srtp.h b/illumos-x86_64/usr/include/openssl-3/srtp.h new file mode 100644 index 00000000..2c2c3344 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/srtp.h @@ -0,0 +1,68 @@ +/* + * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * DTLS code by Eric Rescorla + * + * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc. + */ + +#ifndef OPENSSL_SRTP_H +# define OPENSSL_SRTP_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_D1_SRTP_H +# endif + +# include + +#ifdef __cplusplus +extern "C" { +#endif + +# define SRTP_AES128_CM_SHA1_80 0x0001 +# define SRTP_AES128_CM_SHA1_32 0x0002 +# define SRTP_AES128_F8_SHA1_80 0x0003 +# define SRTP_AES128_F8_SHA1_32 0x0004 +# define SRTP_NULL_SHA1_80 0x0005 +# define SRTP_NULL_SHA1_32 0x0006 + +/* AEAD SRTP protection profiles from RFC 7714 */ +# define SRTP_AEAD_AES_128_GCM 0x0007 +# define SRTP_AEAD_AES_256_GCM 0x0008 + +/* DOUBLE AEAD SRTP protection profiles from RFC 8723 */ +# define SRTP_DOUBLE_AEAD_AES_128_GCM_AEAD_AES_128_GCM 0x0009 +# define SRTP_DOUBLE_AEAD_AES_256_GCM_AEAD_AES_256_GCM 0x000A + +/* ARIA SRTP protection profiles from RFC 8269 */ +# define SRTP_ARIA_128_CTR_HMAC_SHA1_80 0x000B +# define SRTP_ARIA_128_CTR_HMAC_SHA1_32 0x000C +# define SRTP_ARIA_256_CTR_HMAC_SHA1_80 0x000D +# define SRTP_ARIA_256_CTR_HMAC_SHA1_32 0x000E +# define SRTP_AEAD_ARIA_128_GCM 0x000F +# define SRTP_AEAD_ARIA_256_GCM 0x0010 + +# ifndef OPENSSL_NO_SRTP + +__owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles); +__owur int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles); + +__owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl); +__owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); + +# endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ssl.h b/illumos-x86_64/usr/include/openssl-3/ssl.h new file mode 100644 index 00000000..7e3d89c7 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ssl.h @@ -0,0 +1,2933 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/ssl.h.in + * + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * Copyright 2005 Nokia. All rights reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_SSL_H +# define OPENSSL_SSL_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_SSL_H +# endif + +# include +# include +# include +# include +# include +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# include +# include +# endif +# include +# include +# include +# include + +# include +# include +# include +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* OpenSSL version number for ASN.1 encoding of the session information */ +/*- + * Version 0 - initial version + * Version 1 - added the optional peer certificate + */ +# define SSL_SESSION_ASN1_VERSION 0x0001 + +# define SSL_MAX_SSL_SESSION_ID_LENGTH 32 +# define SSL_MAX_SID_CTX_LENGTH 32 + +# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) +# define SSL_MAX_KEY_ARG_LENGTH 8 +/* SSL_MAX_MASTER_KEY_LENGTH is defined in prov_ssl.h */ + +/* The maximum number of encrypt/decrypt pipelines we can support */ +# define SSL_MAX_PIPELINES 32 + +/* text strings for the ciphers */ + +/* These are used to specify which ciphers to use and not to use */ + +# define SSL_TXT_LOW "LOW" +# define SSL_TXT_MEDIUM "MEDIUM" +# define SSL_TXT_HIGH "HIGH" +# define SSL_TXT_FIPS "FIPS" + +# define SSL_TXT_aNULL "aNULL" +# define SSL_TXT_eNULL "eNULL" +# define SSL_TXT_NULL "NULL" + +# define SSL_TXT_kRSA "kRSA" +# define SSL_TXT_kDHr "kDHr"/* this cipher class has been removed */ +# define SSL_TXT_kDHd "kDHd"/* this cipher class has been removed */ +# define SSL_TXT_kDH "kDH"/* this cipher class has been removed */ +# define SSL_TXT_kEDH "kEDH"/* alias for kDHE */ +# define SSL_TXT_kDHE "kDHE" +# define SSL_TXT_kECDHr "kECDHr"/* this cipher class has been removed */ +# define SSL_TXT_kECDHe "kECDHe"/* this cipher class has been removed */ +# define SSL_TXT_kECDH "kECDH"/* this cipher class has been removed */ +# define SSL_TXT_kEECDH "kEECDH"/* alias for kECDHE */ +# define SSL_TXT_kECDHE "kECDHE" +# define SSL_TXT_kPSK "kPSK" +# define SSL_TXT_kRSAPSK "kRSAPSK" +# define SSL_TXT_kECDHEPSK "kECDHEPSK" +# define SSL_TXT_kDHEPSK "kDHEPSK" +# define SSL_TXT_kGOST "kGOST" +# define SSL_TXT_kGOST18 "kGOST18" +# define SSL_TXT_kSRP "kSRP" + +# define SSL_TXT_aRSA "aRSA" +# define SSL_TXT_aDSS "aDSS" +# define SSL_TXT_aDH "aDH"/* this cipher class has been removed */ +# define SSL_TXT_aECDH "aECDH"/* this cipher class has been removed */ +# define SSL_TXT_aECDSA "aECDSA" +# define SSL_TXT_aPSK "aPSK" +# define SSL_TXT_aGOST94 "aGOST94" +# define SSL_TXT_aGOST01 "aGOST01" +# define SSL_TXT_aGOST12 "aGOST12" +# define SSL_TXT_aGOST "aGOST" +# define SSL_TXT_aSRP "aSRP" + +# define SSL_TXT_DSS "DSS" +# define SSL_TXT_DH "DH" +# define SSL_TXT_DHE "DHE"/* same as "kDHE:-ADH" */ +# define SSL_TXT_EDH "EDH"/* alias for DHE */ +# define SSL_TXT_ADH "ADH" +# define SSL_TXT_RSA "RSA" +# define SSL_TXT_ECDH "ECDH" +# define SSL_TXT_EECDH "EECDH"/* alias for ECDHE" */ +# define SSL_TXT_ECDHE "ECDHE"/* same as "kECDHE:-AECDH" */ +# define SSL_TXT_AECDH "AECDH" +# define SSL_TXT_ECDSA "ECDSA" +# define SSL_TXT_PSK "PSK" +# define SSL_TXT_SRP "SRP" + +# define SSL_TXT_DES "DES" +# define SSL_TXT_3DES "3DES" +# define SSL_TXT_RC4 "RC4" +# define SSL_TXT_RC2 "RC2" +# define SSL_TXT_IDEA "IDEA" +# define SSL_TXT_SEED "SEED" +# define SSL_TXT_AES128 "AES128" +# define SSL_TXT_AES256 "AES256" +# define SSL_TXT_AES "AES" +# define SSL_TXT_AES_GCM "AESGCM" +# define SSL_TXT_AES_CCM "AESCCM" +# define SSL_TXT_AES_CCM_8 "AESCCM8" +# define SSL_TXT_CAMELLIA128 "CAMELLIA128" +# define SSL_TXT_CAMELLIA256 "CAMELLIA256" +# define SSL_TXT_CAMELLIA "CAMELLIA" +# define SSL_TXT_CHACHA20 "CHACHA20" +# define SSL_TXT_GOST "GOST89" +# define SSL_TXT_ARIA "ARIA" +# define SSL_TXT_ARIA_GCM "ARIAGCM" +# define SSL_TXT_ARIA128 "ARIA128" +# define SSL_TXT_ARIA256 "ARIA256" +# define SSL_TXT_GOST2012_GOST8912_GOST8912 "GOST2012-GOST8912-GOST8912" +# define SSL_TXT_CBC "CBC" + +# define SSL_TXT_MD5 "MD5" +# define SSL_TXT_SHA1 "SHA1" +# define SSL_TXT_SHA "SHA"/* same as "SHA1" */ +# define SSL_TXT_GOST94 "GOST94" +# define SSL_TXT_GOST89MAC "GOST89MAC" +# define SSL_TXT_GOST12 "GOST12" +# define SSL_TXT_GOST89MAC12 "GOST89MAC12" +# define SSL_TXT_SHA256 "SHA256" +# define SSL_TXT_SHA384 "SHA384" + +# define SSL_TXT_SSLV3 "SSLv3" +# define SSL_TXT_TLSV1 "TLSv1" +# define SSL_TXT_TLSV1_1 "TLSv1.1" +# define SSL_TXT_TLSV1_2 "TLSv1.2" + +# define SSL_TXT_ALL "ALL" + +/*- + * COMPLEMENTOF* definitions. These identifiers are used to (de-select) + * ciphers normally not being used. + * Example: "RC4" will activate all ciphers using RC4 including ciphers + * without authentication, which would normally disabled by DEFAULT (due + * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" + * will make sure that it is also disabled in the specific selection. + * COMPLEMENTOF* identifiers are portable between version, as adjustments + * to the default cipher setup will also be included here. + * + * COMPLEMENTOFDEFAULT does not experience the same special treatment that + * DEFAULT gets, as only selection is being done and no sorting as needed + * for DEFAULT. + */ +# define SSL_TXT_CMPALL "COMPLEMENTOFALL" +# define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" + +/* + * The following cipher list is used by default. It also is substituted when + * an application-defined cipher list string starts with 'DEFAULT'. + * This applies to ciphersuites for TLSv1.2 and below. + * DEPRECATED IN 3.0.0, in favor of OSSL_default_cipher_list() + * Update both macro and function simultaneously + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL" +/* + * This is the default set of TLSv1.3 ciphersuites + * DEPRECATED IN 3.0.0, in favor of OSSL_default_ciphersuites() + * Update both macro and function simultaneously + */ +# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ + "TLS_CHACHA20_POLY1305_SHA256:" \ + "TLS_AES_128_GCM_SHA256" +# endif +/* + * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always + * starts with a reasonable order, and all we have to do for DEFAULT is + * throwing out anonymous and unencrypted ciphersuites! (The latter are not + * actually enabled by ALL, but "ALL:RSA" would enable some of them.) + */ + +/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ +# define SSL_SENT_SHUTDOWN 1 +# define SSL_RECEIVED_SHUTDOWN 2 + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +# define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 +# define SSL_FILETYPE_PEM X509_FILETYPE_PEM + +/* + * This is needed to stop compilers complaining about the 'struct ssl_st *' + * function parameters used to prototype callbacks in SSL_CTX. + */ +typedef struct ssl_st *ssl_crock_st; +typedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT; +typedef struct ssl_method_st SSL_METHOD; +typedef struct ssl_cipher_st SSL_CIPHER; +typedef struct ssl_session_st SSL_SESSION; +typedef struct tls_sigalgs_st TLS_SIGALGS; +typedef struct ssl_conf_ctx_st SSL_CONF_CTX; + +STACK_OF(SSL_CIPHER); + +/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/ +typedef struct srtp_protection_profile_st { + const char *name; + unsigned long id; +} SRTP_PROTECTION_PROFILE; +SKM_DEFINE_STACK_OF_INTERNAL(SRTP_PROTECTION_PROFILE, SRTP_PROTECTION_PROFILE, SRTP_PROTECTION_PROFILE) +#define sk_SRTP_PROTECTION_PROFILE_num(sk) OPENSSL_sk_num(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_value(sk, idx) ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_value(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk), (idx))) +#define sk_SRTP_PROTECTION_PROFILE_new(cmp) ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new(ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp))) +#define sk_SRTP_PROTECTION_PROFILE_new_null() ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new_null()) +#define sk_SRTP_PROTECTION_PROFILE_new_reserve(cmp, n) ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new_reserve(ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp), (n))) +#define sk_SRTP_PROTECTION_PROFILE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), (n)) +#define sk_SRTP_PROTECTION_PROFILE_free(sk) OPENSSL_sk_free(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_zero(sk) OPENSSL_sk_zero(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_delete(sk, i) ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_delete(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), (i))) +#define sk_SRTP_PROTECTION_PROFILE_delete_ptr(sk, ptr) ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_delete_ptr(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_type(ptr))) +#define sk_SRTP_PROTECTION_PROFILE_push(sk, ptr) OPENSSL_sk_push(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) +#define sk_SRTP_PROTECTION_PROFILE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) +#define sk_SRTP_PROTECTION_PROFILE_pop(sk) ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_pop(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk))) +#define sk_SRTP_PROTECTION_PROFILE_shift(sk) ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_shift(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk))) +#define sk_SRTP_PROTECTION_PROFILE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk),ossl_check_SRTP_PROTECTION_PROFILE_freefunc_type(freefunc)) +#define sk_SRTP_PROTECTION_PROFILE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_type(ptr), (idx)) +#define sk_SRTP_PROTECTION_PROFILE_set(sk, idx, ptr) ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_set(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), (idx), ossl_check_SRTP_PROTECTION_PROFILE_type(ptr))) +#define sk_SRTP_PROTECTION_PROFILE_find(sk, ptr) OPENSSL_sk_find(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) +#define sk_SRTP_PROTECTION_PROFILE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) +#define sk_SRTP_PROTECTION_PROFILE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_type(ptr), pnum) +#define sk_SRTP_PROTECTION_PROFILE_sort(sk) OPENSSL_sk_sort(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_dup(sk) ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_dup(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk))) +#define sk_SRTP_PROTECTION_PROFILE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_deep_copy(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_copyfunc_type(copyfunc), ossl_check_SRTP_PROTECTION_PROFILE_freefunc_type(freefunc))) +#define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(sk, cmp) ((sk_SRTP_PROTECTION_PROFILE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp))) + + + +typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data, + int len, void *arg); +typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len, + STACK_OF(SSL_CIPHER) *peer_ciphers, + const SSL_CIPHER **cipher, void *arg); + +/* Extension context codes */ +/* This extension is only allowed in TLS */ +#define SSL_EXT_TLS_ONLY 0x00001 +/* This extension is only allowed in DTLS */ +#define SSL_EXT_DTLS_ONLY 0x00002 +/* Some extensions may be allowed in DTLS but we don't implement them for it */ +#define SSL_EXT_TLS_IMPLEMENTATION_ONLY 0x00004 +/* Most extensions are not defined for SSLv3 but EXT_TYPE_renegotiate is */ +#define SSL_EXT_SSL3_ALLOWED 0x00008 +/* Extension is only defined for TLS1.2 and below */ +#define SSL_EXT_TLS1_2_AND_BELOW_ONLY 0x00010 +/* Extension is only defined for TLS1.3 and above */ +#define SSL_EXT_TLS1_3_ONLY 0x00020 +/* Ignore this extension during parsing if we are resuming */ +#define SSL_EXT_IGNORE_ON_RESUMPTION 0x00040 +#define SSL_EXT_CLIENT_HELLO 0x00080 +/* Really means TLS1.2 or below */ +#define SSL_EXT_TLS1_2_SERVER_HELLO 0x00100 +#define SSL_EXT_TLS1_3_SERVER_HELLO 0x00200 +#define SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS 0x00400 +#define SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST 0x00800 +#define SSL_EXT_TLS1_3_CERTIFICATE 0x01000 +#define SSL_EXT_TLS1_3_NEW_SESSION_TICKET 0x02000 +#define SSL_EXT_TLS1_3_CERTIFICATE_REQUEST 0x04000 +#define SSL_EXT_TLS1_3_CERTIFICATE_COMPRESSION 0x08000 +/* When sending a raw public key in a certificate message */ +#define SSL_EXT_TLS1_3_RAW_PUBLIC_KEY 0x10000 + +/* Typedefs for handling custom extensions */ + +typedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type, + const unsigned char **out, size_t *outlen, + int *al, void *add_arg); + +typedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type, + const unsigned char *out, void *add_arg); + +typedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type, + const unsigned char *in, size_t inlen, + int *al, void *parse_arg); + + +typedef int (*SSL_custom_ext_add_cb_ex)(SSL *s, unsigned int ext_type, + unsigned int context, + const unsigned char **out, + size_t *outlen, X509 *x, + size_t chainidx, + int *al, void *add_arg); + +typedef void (*SSL_custom_ext_free_cb_ex)(SSL *s, unsigned int ext_type, + unsigned int context, + const unsigned char *out, + void *add_arg); + +typedef int (*SSL_custom_ext_parse_cb_ex)(SSL *s, unsigned int ext_type, + unsigned int context, + const unsigned char *in, + size_t inlen, X509 *x, + size_t chainidx, + int *al, void *parse_arg); + +/* Typedef for verification callback */ +typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx); + +/* Typedef for SSL async callback */ +typedef int (*SSL_async_callback_fn)(SSL *s, void *arg); + +#define SSL_OP_BIT(n) ((uint64_t)1 << (uint64_t)n) + +/* + * SSL/TLS connection options. + */ + /* Disable Extended master secret */ +# define SSL_OP_NO_EXTENDED_MASTER_SECRET SSL_OP_BIT(0) + /* Cleanse plaintext copies of data delivered to the application */ +# define SSL_OP_CLEANSE_PLAINTEXT SSL_OP_BIT(1) + /* Allow initial connection to servers that don't support RI */ +# define SSL_OP_LEGACY_SERVER_CONNECT SSL_OP_BIT(2) + /* Enable support for Kernel TLS */ +# define SSL_OP_ENABLE_KTLS SSL_OP_BIT(3) +# define SSL_OP_TLSEXT_PADDING SSL_OP_BIT(4) +# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG SSL_OP_BIT(6) +# define SSL_OP_IGNORE_UNEXPECTED_EOF SSL_OP_BIT(7) +# define SSL_OP_ALLOW_CLIENT_RENEGOTIATION SSL_OP_BIT(8) +# define SSL_OP_DISABLE_TLSEXT_CA_NAMES SSL_OP_BIT(9) + /* In TLSv1.3 allow a non-(ec)dhe based kex_mode */ +# define SSL_OP_ALLOW_NO_DHE_KEX SSL_OP_BIT(10) + /* + * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added + * in OpenSSL 0.9.6d. Usually (depending on the application protocol) + * the workaround is not needed. Unfortunately some broken SSL/TLS + * implementations cannot handle it at all, which is why we include it + * in SSL_OP_ALL. Added in 0.9.6e + */ +# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS SSL_OP_BIT(11) + /* DTLS options */ +# define SSL_OP_NO_QUERY_MTU SSL_OP_BIT(12) + /* Turn on Cookie Exchange (on relevant for servers) */ +# define SSL_OP_COOKIE_EXCHANGE SSL_OP_BIT(13) + /* Don't use RFC4507 ticket extension */ +# define SSL_OP_NO_TICKET SSL_OP_BIT(14) +# ifndef OPENSSL_NO_DTLS1_METHOD + /* + * Use Cisco's version identifier of DTLS_BAD_VER + * (only with deprecated DTLSv1_client_method()) + */ +# define SSL_OP_CISCO_ANYCONNECT SSL_OP_BIT(15) +# endif + /* As server, disallow session resumption on renegotiation */ +# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION SSL_OP_BIT(16) + /* Don't use compression even if supported */ +# define SSL_OP_NO_COMPRESSION SSL_OP_BIT(17) + /* Permit unsafe legacy renegotiation */ +# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION SSL_OP_BIT(18) + /* Disable encrypt-then-mac */ +# define SSL_OP_NO_ENCRYPT_THEN_MAC SSL_OP_BIT(19) + /* + * Enable TLSv1.3 Compatibility mode. This is on by default. A future + * version of OpenSSL may have this disabled by default. + */ +# define SSL_OP_ENABLE_MIDDLEBOX_COMPAT SSL_OP_BIT(20) + /* + * Prioritize Chacha20Poly1305 when client does. + * Modifies SSL_OP_CIPHER_SERVER_PREFERENCE + */ +# define SSL_OP_PRIORITIZE_CHACHA SSL_OP_BIT(21) + /* + * Set on servers to choose the cipher according to server's preferences. + */ +# define SSL_OP_CIPHER_SERVER_PREFERENCE SSL_OP_BIT(22) + /* + * If set, a server will allow a client to issue an SSLv3.0 version + * number as latest version supported in the premaster secret, even when + * TLSv1.0 (version 3.1) was announced in the client hello. Normally + * this is forbidden to prevent version rollback attacks. + */ +# define SSL_OP_TLS_ROLLBACK_BUG SSL_OP_BIT(23) + /* + * Switches off automatic TLSv1.3 anti-replay protection for early data. + * This is a server-side option only (no effect on the client). + */ +# define SSL_OP_NO_ANTI_REPLAY SSL_OP_BIT(24) +# define SSL_OP_NO_SSLv3 SSL_OP_BIT(25) +# define SSL_OP_NO_TLSv1 SSL_OP_BIT(26) +# define SSL_OP_NO_TLSv1_2 SSL_OP_BIT(27) +# define SSL_OP_NO_TLSv1_1 SSL_OP_BIT(28) +# define SSL_OP_NO_TLSv1_3 SSL_OP_BIT(29) +# define SSL_OP_NO_DTLSv1 SSL_OP_BIT(26) +# define SSL_OP_NO_DTLSv1_2 SSL_OP_BIT(27) + /* Disallow all renegotiation */ +# define SSL_OP_NO_RENEGOTIATION SSL_OP_BIT(30) + /* + * Make server add server-hello extension from early version of + * cryptopro draft, when GOST ciphersuite is negotiated. Required for + * interoperability with CryptoPro CSP 3.x + */ +# define SSL_OP_CRYPTOPRO_TLSEXT_BUG SSL_OP_BIT(31) +/* + * Disable RFC8879 certificate compression + * SSL_OP_NO_TX_CERTIFICATE_COMPRESSION: don't send compressed certificates, + * and ignore the extension when received. + * SSL_OP_NO_RX_CERTIFICATE_COMPRESSION: don't send the extension, and + * subsequently indicating that receiving is not supported + */ +# define SSL_OP_NO_TX_CERTIFICATE_COMPRESSION SSL_OP_BIT(32) +# define SSL_OP_NO_RX_CERTIFICATE_COMPRESSION SSL_OP_BIT(33) + /* Enable KTLS TX zerocopy on Linux */ +# define SSL_OP_ENABLE_KTLS_TX_ZEROCOPY_SENDFILE SSL_OP_BIT(34) + +#define SSL_OP_PREFER_NO_DHE_KEX SSL_OP_BIT(35) + +/* + * Option "collections." + */ +# define SSL_OP_NO_SSL_MASK \ + ( SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 \ + | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_TLSv1_3 ) +# define SSL_OP_NO_DTLS_MASK \ + ( SSL_OP_NO_DTLSv1 | SSL_OP_NO_DTLSv1_2 ) + +/* Various bug workarounds that should be rather harmless. */ +# define SSL_OP_ALL \ + ( SSL_OP_CRYPTOPRO_TLSEXT_BUG | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS \ + | SSL_OP_TLSEXT_PADDING | SSL_OP_SAFARI_ECDHE_ECDSA_BUG ) + +/* + * OBSOLETE OPTIONS retained for compatibility + */ + +# define SSL_OP_MICROSOFT_SESS_ID_BUG 0x0 +# define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x0 +# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x0 +# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x0 +# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x0 +# define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x0 +# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x0 +# define SSL_OP_TLS_D5_BUG 0x0 +# define SSL_OP_TLS_BLOCK_PADDING_BUG 0x0 +# define SSL_OP_SINGLE_ECDH_USE 0x0 +# define SSL_OP_SINGLE_DH_USE 0x0 +# define SSL_OP_EPHEMERAL_RSA 0x0 +# define SSL_OP_NO_SSLv2 0x0 +# define SSL_OP_PKCS1_CHECK_1 0x0 +# define SSL_OP_PKCS1_CHECK_2 0x0 +# define SSL_OP_NETSCAPE_CA_DN_BUG 0x0 +# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x0 + +/* + * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success + * when just a single record has been written): + */ +# define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001U +/* + * Make it possible to retry SSL_write() with changed buffer location (buffer + * contents must stay the same!); this is not the default to avoid the + * misconception that non-blocking SSL_write() behaves like non-blocking + * write(): + */ +# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U +/* + * Never bother the application with retries if the transport is blocking: + */ +# define SSL_MODE_AUTO_RETRY 0x00000004U +/* Don't attempt to automatically build certificate chain */ +# define SSL_MODE_NO_AUTO_CHAIN 0x00000008U +/* + * Save RAM by releasing read and write buffers when they're empty. (SSL3 and + * TLS only.) Released buffers are freed. + */ +# define SSL_MODE_RELEASE_BUFFERS 0x00000010U +/* + * Send the current time in the Random fields of the ClientHello and + * ServerHello records for compatibility with hypothetical implementations + * that require it. + */ +# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020U +# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040U +/* + * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications + * that reconnect with a downgraded protocol version; see + * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your + * application attempts a normal handshake. Only use this in explicit + * fallback retries, following the guidance in + * draft-ietf-tls-downgrade-scsv-00. + */ +# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080U +/* + * Support Asynchronous operation + */ +# define SSL_MODE_ASYNC 0x00000100U + +/* + * When using DTLS/SCTP, include the terminating zero in the label + * used for computing the endpoint-pair shared secret. Required for + * interoperability with implementations having this bug like these + * older version of OpenSSL: + * - OpenSSL 1.0.0 series + * - OpenSSL 1.0.1 series + * - OpenSSL 1.0.2 series + * - OpenSSL 1.1.0 series + * - OpenSSL 1.1.1 and 1.1.1a + */ +# define SSL_MODE_DTLS_SCTP_LABEL_LENGTH_BUG 0x00000400U + +/* Cert related flags */ +/* + * Many implementations ignore some aspects of the TLS standards such as + * enforcing certificate chain algorithms. When this is set we enforce them. + */ +# define SSL_CERT_FLAG_TLS_STRICT 0x00000001U + +/* Suite B modes, takes same values as certificate verify flags */ +# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY 0x10000 +/* Suite B 192 bit only mode */ +# define SSL_CERT_FLAG_SUITEB_192_LOS 0x20000 +/* Suite B 128 bit mode allowing 192 bit algorithms */ +# define SSL_CERT_FLAG_SUITEB_128_LOS 0x30000 + +/* Perform all sorts of protocol violations for testing purposes */ +# define SSL_CERT_FLAG_BROKEN_PROTOCOL 0x10000000 + +/* Flags for building certificate chains */ +/* Treat any existing certificates as untrusted CAs */ +# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED 0x1 +/* Don't include root CA in chain */ +# define SSL_BUILD_CHAIN_FLAG_NO_ROOT 0x2 +/* Just check certificates already there */ +# define SSL_BUILD_CHAIN_FLAG_CHECK 0x4 +/* Ignore verification errors */ +# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR 0x8 +/* Clear verification errors from queue */ +# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR 0x10 + +/* Flags returned by SSL_check_chain */ +/* Certificate can be used with this session */ +# define CERT_PKEY_VALID 0x1 +/* Certificate can also be used for signing */ +# define CERT_PKEY_SIGN 0x2 +/* EE certificate signing algorithm OK */ +# define CERT_PKEY_EE_SIGNATURE 0x10 +/* CA signature algorithms OK */ +# define CERT_PKEY_CA_SIGNATURE 0x20 +/* EE certificate parameters OK */ +# define CERT_PKEY_EE_PARAM 0x40 +/* CA certificate parameters OK */ +# define CERT_PKEY_CA_PARAM 0x80 +/* Signing explicitly allowed as opposed to SHA1 fallback */ +# define CERT_PKEY_EXPLICIT_SIGN 0x100 +/* Client CA issuer names match (always set for server cert) */ +# define CERT_PKEY_ISSUER_NAME 0x200 +/* Cert type matches client types (always set for server cert) */ +# define CERT_PKEY_CERT_TYPE 0x400 +/* Cert chain suitable to Suite B */ +# define CERT_PKEY_SUITEB 0x800 +/* Cert pkey valid for raw public key use */ +# define CERT_PKEY_RPK 0x1000 + +# define SSL_CONF_FLAG_CMDLINE 0x1 +# define SSL_CONF_FLAG_FILE 0x2 +# define SSL_CONF_FLAG_CLIENT 0x4 +# define SSL_CONF_FLAG_SERVER 0x8 +# define SSL_CONF_FLAG_SHOW_ERRORS 0x10 +# define SSL_CONF_FLAG_CERTIFICATE 0x20 +# define SSL_CONF_FLAG_REQUIRE_PRIVATE 0x40 +/* Configuration value types */ +# define SSL_CONF_TYPE_UNKNOWN 0x0 +# define SSL_CONF_TYPE_STRING 0x1 +# define SSL_CONF_TYPE_FILE 0x2 +# define SSL_CONF_TYPE_DIR 0x3 +# define SSL_CONF_TYPE_NONE 0x4 +# define SSL_CONF_TYPE_STORE 0x5 + +/* Maximum length of the application-controlled segment of a a TLSv1.3 cookie */ +# define SSL_COOKIE_LENGTH 4096 + +/* + * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they + * cannot be used to clear bits. + */ + +uint64_t SSL_CTX_get_options(const SSL_CTX *ctx); +uint64_t SSL_get_options(const SSL *s); +uint64_t SSL_CTX_clear_options(SSL_CTX *ctx, uint64_t op); +uint64_t SSL_clear_options(SSL *s, uint64_t op); +uint64_t SSL_CTX_set_options(SSL_CTX *ctx, uint64_t op); +uint64_t SSL_set_options(SSL *s, uint64_t op); + +# define SSL_CTX_set_mode(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) +# define SSL_CTX_clear_mode(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL) +# define SSL_CTX_get_mode(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) +# define SSL_clear_mode(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL) +# define SSL_set_mode(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) +# define SSL_get_mode(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) +# define SSL_set_mtu(ssl, mtu) \ + SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL) +# define DTLS_set_link_mtu(ssl, mtu) \ + SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL) +# define DTLS_get_link_min_mtu(ssl) \ + SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL) + +# define SSL_get_secure_renegotiation_support(ssl) \ + SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL) + +# define SSL_CTX_set_cert_flags(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL) +# define SSL_set_cert_flags(s,op) \ + SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL) +# define SSL_CTX_clear_cert_flags(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL) +# define SSL_clear_cert_flags(s,op) \ + SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL) + +void SSL_CTX_set_msg_callback(SSL_CTX *ctx, + void (*cb) (int write_p, int version, + int content_type, const void *buf, + size_t len, SSL *ssl, void *arg)); +void SSL_set_msg_callback(SSL *ssl, + void (*cb) (int write_p, int version, + int content_type, const void *buf, + size_t len, SSL *ssl, void *arg)); +# define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) +# define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) + +# define SSL_get_extms_support(s) \ + SSL_ctrl((s),SSL_CTRL_GET_EXTMS_SUPPORT,0,NULL) + +# ifndef OPENSSL_NO_SRP +/* see tls_srp.c */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 __owur int SSL_SRP_CTX_init(SSL *s); +OSSL_DEPRECATEDIN_3_0 __owur int SSL_CTX_SRP_CTX_init(SSL_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int SSL_SRP_CTX_free(SSL *ctx); +OSSL_DEPRECATEDIN_3_0 int SSL_CTX_SRP_CTX_free(SSL_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 __owur int SSL_srp_server_param_with_username(SSL *s, + int *ad); +OSSL_DEPRECATEDIN_3_0 __owur int SRP_Calc_A_param(SSL *s); +# endif +# endif + +/* 100k max cert list */ +# define SSL_MAX_CERT_LIST_DEFAULT (1024*100) + +# define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) + +/* + * This callback type is used inside SSL_CTX, SSL, and in the functions that + * set them. It is used to override the generation of SSL/TLS session IDs in + * a server. Return value should be zero on an error, non-zero to proceed. + * Also, callbacks should themselves check if the id they generate is unique + * otherwise the SSL handshake will fail with an error - callbacks can do + * this using the 'ssl' value they're passed by; + * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in + * is set at the maximum size the session ID can be. In SSLv3/TLSv1 it is 32 + * bytes. The callback can alter this length to be less if desired. It is + * also an error for the callback to set the size to zero. + */ +typedef int (*GEN_SESSION_CB) (SSL *ssl, unsigned char *id, + unsigned int *id_len); + +# define SSL_SESS_CACHE_OFF 0x0000 +# define SSL_SESS_CACHE_CLIENT 0x0001 +# define SSL_SESS_CACHE_SERVER 0x0002 +# define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) +# define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 +/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ +# define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 +# define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 +# define SSL_SESS_CACHE_NO_INTERNAL \ + (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) +# define SSL_SESS_CACHE_UPDATE_TIME 0x0400 + +LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx); +# define SSL_CTX_sess_number(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) +# define SSL_CTX_sess_connect(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) +# define SSL_CTX_sess_connect_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) +# define SSL_CTX_sess_connect_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) +# define SSL_CTX_sess_accept(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) +# define SSL_CTX_sess_accept_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) +# define SSL_CTX_sess_accept_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) +# define SSL_CTX_sess_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) +# define SSL_CTX_sess_cb_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) +# define SSL_CTX_sess_misses(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) +# define SSL_CTX_sess_timeouts(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) +# define SSL_CTX_sess_cache_full(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) + +void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, + int (*new_session_cb) (struct ssl_st *ssl, + SSL_SESSION *sess)); +int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl, + SSL_SESSION *sess); +void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, + void (*remove_session_cb) (struct ssl_ctx_st + *ctx, + SSL_SESSION *sess)); +void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx, + SSL_SESSION *sess); +void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, + SSL_SESSION *(*get_session_cb) (struct ssl_st + *ssl, + const unsigned char + *data, int len, + int *copy)); +SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl, + const unsigned char *data, + int len, int *copy); +void SSL_CTX_set_info_callback(SSL_CTX *ctx, + void (*cb) (const SSL *ssl, int type, int val)); +void (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type, + int val); +void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, + int (*client_cert_cb) (SSL *ssl, X509 **x509, + EVP_PKEY **pkey)); +int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509, + EVP_PKEY **pkey); +# ifndef OPENSSL_NO_ENGINE +__owur int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e); +# endif +void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, + int (*app_gen_cookie_cb) (SSL *ssl, + unsigned char + *cookie, + unsigned int + *cookie_len)); +void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, + int (*app_verify_cookie_cb) (SSL *ssl, + const unsigned + char *cookie, + unsigned int + cookie_len)); + +void SSL_CTX_set_stateless_cookie_generate_cb( + SSL_CTX *ctx, + int (*gen_stateless_cookie_cb) (SSL *ssl, + unsigned char *cookie, + size_t *cookie_len)); +void SSL_CTX_set_stateless_cookie_verify_cb( + SSL_CTX *ctx, + int (*verify_stateless_cookie_cb) (SSL *ssl, + const unsigned char *cookie, + size_t cookie_len)); +# ifndef OPENSSL_NO_NEXTPROTONEG + +typedef int (*SSL_CTX_npn_advertised_cb_func)(SSL *ssl, + const unsigned char **out, + unsigned int *outlen, + void *arg); +void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s, + SSL_CTX_npn_advertised_cb_func cb, + void *arg); +# define SSL_CTX_set_npn_advertised_cb SSL_CTX_set_next_protos_advertised_cb + +typedef int (*SSL_CTX_npn_select_cb_func)(SSL *s, + unsigned char **out, + unsigned char *outlen, + const unsigned char *in, + unsigned int inlen, + void *arg); +void SSL_CTX_set_next_proto_select_cb(SSL_CTX *s, + SSL_CTX_npn_select_cb_func cb, + void *arg); +# define SSL_CTX_set_npn_select_cb SSL_CTX_set_next_proto_select_cb + +void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, + unsigned *len); +# define SSL_get0_npn_negotiated SSL_get0_next_proto_negotiated +# endif + +__owur int SSL_select_next_proto(unsigned char **out, unsigned char *outlen, + const unsigned char *in, unsigned int inlen, + const unsigned char *client, + unsigned int client_len); + +# define OPENSSL_NPN_UNSUPPORTED 0 +# define OPENSSL_NPN_NEGOTIATED 1 +# define OPENSSL_NPN_NO_OVERLAP 2 + +__owur int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, + unsigned int protos_len); +__owur int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, + unsigned int protos_len); +typedef int (*SSL_CTX_alpn_select_cb_func)(SSL *ssl, + const unsigned char **out, + unsigned char *outlen, + const unsigned char *in, + unsigned int inlen, + void *arg); +void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, + SSL_CTX_alpn_select_cb_func cb, + void *arg); +void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data, + unsigned int *len); + +# ifndef OPENSSL_NO_PSK +/* + * the maximum length of the buffer given to callbacks containing the + * resulting identity/psk + */ +# define PSK_MAX_IDENTITY_LEN 256 +# define PSK_MAX_PSK_LEN 512 +typedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl, + const char *hint, + char *identity, + unsigned int max_identity_len, + unsigned char *psk, + unsigned int max_psk_len); +void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb); +void SSL_set_psk_client_callback(SSL *ssl, SSL_psk_client_cb_func cb); + +typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl, + const char *identity, + unsigned char *psk, + unsigned int max_psk_len); +void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb); +void SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb); + +__owur int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint); +__owur int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint); +const char *SSL_get_psk_identity_hint(const SSL *s); +const char *SSL_get_psk_identity(const SSL *s); +# endif + +typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl, + const unsigned char *identity, + size_t identity_len, + SSL_SESSION **sess); +typedef int (*SSL_psk_use_session_cb_func)(SSL *ssl, const EVP_MD *md, + const unsigned char **id, + size_t *idlen, + SSL_SESSION **sess); + +void SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb); +void SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx, + SSL_psk_find_session_cb_func cb); +void SSL_set_psk_use_session_callback(SSL *s, SSL_psk_use_session_cb_func cb); +void SSL_CTX_set_psk_use_session_callback(SSL_CTX *ctx, + SSL_psk_use_session_cb_func cb); + +/* Register callbacks to handle custom TLS Extensions for client or server. */ + +__owur int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx, + unsigned int ext_type); + +__owur int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, + unsigned int ext_type, + custom_ext_add_cb add_cb, + custom_ext_free_cb free_cb, + void *add_arg, + custom_ext_parse_cb parse_cb, + void *parse_arg); + +__owur int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, + unsigned int ext_type, + custom_ext_add_cb add_cb, + custom_ext_free_cb free_cb, + void *add_arg, + custom_ext_parse_cb parse_cb, + void *parse_arg); + +__owur int SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type, + unsigned int context, + SSL_custom_ext_add_cb_ex add_cb, + SSL_custom_ext_free_cb_ex free_cb, + void *add_arg, + SSL_custom_ext_parse_cb_ex parse_cb, + void *parse_arg); + +__owur int SSL_extension_supported(unsigned int ext_type); + +# define SSL_NOTHING 1 +# define SSL_WRITING 2 +# define SSL_READING 3 +# define SSL_X509_LOOKUP 4 +# define SSL_ASYNC_PAUSED 5 +# define SSL_ASYNC_NO_JOBS 6 +# define SSL_CLIENT_HELLO_CB 7 +# define SSL_RETRY_VERIFY 8 + +/* These will only be used when doing non-blocking IO */ +# define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) +# define SSL_want_read(s) (SSL_want(s) == SSL_READING) +# define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) +# define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) +# define SSL_want_retry_verify(s) (SSL_want(s) == SSL_RETRY_VERIFY) +# define SSL_want_async(s) (SSL_want(s) == SSL_ASYNC_PAUSED) +# define SSL_want_async_job(s) (SSL_want(s) == SSL_ASYNC_NO_JOBS) +# define SSL_want_client_hello_cb(s) (SSL_want(s) == SSL_CLIENT_HELLO_CB) + +# define SSL_MAC_FLAG_READ_MAC_STREAM 1 +# define SSL_MAC_FLAG_WRITE_MAC_STREAM 2 +# define SSL_MAC_FLAG_READ_MAC_TLSTREE 4 +# define SSL_MAC_FLAG_WRITE_MAC_TLSTREE 8 + +/* + * A callback for logging out TLS key material. This callback should log out + * |line| followed by a newline. + */ +typedef void (*SSL_CTX_keylog_cb_func)(const SSL *ssl, const char *line); + +/* + * SSL_CTX_set_keylog_callback configures a callback to log key material. This + * is intended for debugging use with tools like Wireshark. The cb function + * should log line followed by a newline. + */ +void SSL_CTX_set_keylog_callback(SSL_CTX *ctx, SSL_CTX_keylog_cb_func cb); + +/* + * SSL_CTX_get_keylog_callback returns the callback configured by + * SSL_CTX_set_keylog_callback. + */ +SSL_CTX_keylog_cb_func SSL_CTX_get_keylog_callback(const SSL_CTX *ctx); + +int SSL_CTX_set_max_early_data(SSL_CTX *ctx, uint32_t max_early_data); +uint32_t SSL_CTX_get_max_early_data(const SSL_CTX *ctx); +int SSL_set_max_early_data(SSL *s, uint32_t max_early_data); +uint32_t SSL_get_max_early_data(const SSL *s); +int SSL_CTX_set_recv_max_early_data(SSL_CTX *ctx, uint32_t recv_max_early_data); +uint32_t SSL_CTX_get_recv_max_early_data(const SSL_CTX *ctx); +int SSL_set_recv_max_early_data(SSL *s, uint32_t recv_max_early_data); +uint32_t SSL_get_recv_max_early_data(const SSL *s); + +#ifdef __cplusplus +} +#endif + +# include +# include +# include /* This is mostly sslv3 with a few tweaks */ +# include /* Datagram TLS */ +# include /* Support for the use_srtp extension */ +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These need to be after the above set of includes due to a compiler bug + * in VisualStudio 2015 + */ +SKM_DEFINE_STACK_OF_INTERNAL(SSL_CIPHER, const SSL_CIPHER, SSL_CIPHER) +#define sk_SSL_CIPHER_num(sk) OPENSSL_sk_num(ossl_check_const_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_value(sk, idx) ((const SSL_CIPHER *)OPENSSL_sk_value(ossl_check_const_SSL_CIPHER_sk_type(sk), (idx))) +#define sk_SSL_CIPHER_new(cmp) ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_new(ossl_check_SSL_CIPHER_compfunc_type(cmp))) +#define sk_SSL_CIPHER_new_null() ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_new_null()) +#define sk_SSL_CIPHER_new_reserve(cmp, n) ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_new_reserve(ossl_check_SSL_CIPHER_compfunc_type(cmp), (n))) +#define sk_SSL_CIPHER_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SSL_CIPHER_sk_type(sk), (n)) +#define sk_SSL_CIPHER_free(sk) OPENSSL_sk_free(ossl_check_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_zero(sk) OPENSSL_sk_zero(ossl_check_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_delete(sk, i) ((const SSL_CIPHER *)OPENSSL_sk_delete(ossl_check_SSL_CIPHER_sk_type(sk), (i))) +#define sk_SSL_CIPHER_delete_ptr(sk, ptr) ((const SSL_CIPHER *)OPENSSL_sk_delete_ptr(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr))) +#define sk_SSL_CIPHER_push(sk, ptr) OPENSSL_sk_push(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr)) +#define sk_SSL_CIPHER_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr)) +#define sk_SSL_CIPHER_pop(sk) ((const SSL_CIPHER *)OPENSSL_sk_pop(ossl_check_SSL_CIPHER_sk_type(sk))) +#define sk_SSL_CIPHER_shift(sk) ((const SSL_CIPHER *)OPENSSL_sk_shift(ossl_check_SSL_CIPHER_sk_type(sk))) +#define sk_SSL_CIPHER_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SSL_CIPHER_sk_type(sk),ossl_check_SSL_CIPHER_freefunc_type(freefunc)) +#define sk_SSL_CIPHER_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr), (idx)) +#define sk_SSL_CIPHER_set(sk, idx, ptr) ((const SSL_CIPHER *)OPENSSL_sk_set(ossl_check_SSL_CIPHER_sk_type(sk), (idx), ossl_check_SSL_CIPHER_type(ptr))) +#define sk_SSL_CIPHER_find(sk, ptr) OPENSSL_sk_find(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr)) +#define sk_SSL_CIPHER_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr)) +#define sk_SSL_CIPHER_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr), pnum) +#define sk_SSL_CIPHER_sort(sk) OPENSSL_sk_sort(ossl_check_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_dup(sk) ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_dup(ossl_check_const_SSL_CIPHER_sk_type(sk))) +#define sk_SSL_CIPHER_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_deep_copy(ossl_check_const_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_copyfunc_type(copyfunc), ossl_check_SSL_CIPHER_freefunc_type(freefunc))) +#define sk_SSL_CIPHER_set_cmp_func(sk, cmp) ((sk_SSL_CIPHER_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_compfunc_type(cmp))) + + +/* compatibility */ +# define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)(arg))) +# define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) +# define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0, \ + (char *)(a))) +# define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0)) +# define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) +# define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0, \ + (char *)(arg))) +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 void SSL_set_debug(SSL *s, int debug); +# endif + +/* TLSv1.3 KeyUpdate message types */ +/* -1 used so that this is an invalid value for the on-the-wire protocol */ +#define SSL_KEY_UPDATE_NONE -1 +/* Values as defined for the on-the-wire protocol */ +#define SSL_KEY_UPDATE_NOT_REQUESTED 0 +#define SSL_KEY_UPDATE_REQUESTED 1 + +/* + * The valid handshake states (one for each type message sent and one for each + * type of message received). There are also two "special" states: + * TLS = TLS or DTLS state + * DTLS = DTLS specific state + * CR/SR = Client Read/Server Read + * CW/SW = Client Write/Server Write + * + * The "special" states are: + * TLS_ST_BEFORE = No handshake has been initiated yet + * TLS_ST_OK = A handshake has been successfully completed + */ +typedef enum { + TLS_ST_BEFORE, + TLS_ST_OK, + DTLS_ST_CR_HELLO_VERIFY_REQUEST, + TLS_ST_CR_SRVR_HELLO, + TLS_ST_CR_CERT, + TLS_ST_CR_COMP_CERT, + TLS_ST_CR_CERT_STATUS, + TLS_ST_CR_KEY_EXCH, + TLS_ST_CR_CERT_REQ, + TLS_ST_CR_SRVR_DONE, + TLS_ST_CR_SESSION_TICKET, + TLS_ST_CR_CHANGE, + TLS_ST_CR_FINISHED, + TLS_ST_CW_CLNT_HELLO, + TLS_ST_CW_CERT, + TLS_ST_CW_COMP_CERT, + TLS_ST_CW_KEY_EXCH, + TLS_ST_CW_CERT_VRFY, + TLS_ST_CW_CHANGE, + TLS_ST_CW_NEXT_PROTO, + TLS_ST_CW_FINISHED, + TLS_ST_SW_HELLO_REQ, + TLS_ST_SR_CLNT_HELLO, + DTLS_ST_SW_HELLO_VERIFY_REQUEST, + TLS_ST_SW_SRVR_HELLO, + TLS_ST_SW_CERT, + TLS_ST_SW_COMP_CERT, + TLS_ST_SW_KEY_EXCH, + TLS_ST_SW_CERT_REQ, + TLS_ST_SW_SRVR_DONE, + TLS_ST_SR_CERT, + TLS_ST_SR_COMP_CERT, + TLS_ST_SR_KEY_EXCH, + TLS_ST_SR_CERT_VRFY, + TLS_ST_SR_NEXT_PROTO, + TLS_ST_SR_CHANGE, + TLS_ST_SR_FINISHED, + TLS_ST_SW_SESSION_TICKET, + TLS_ST_SW_CERT_STATUS, + TLS_ST_SW_CHANGE, + TLS_ST_SW_FINISHED, + TLS_ST_SW_ENCRYPTED_EXTENSIONS, + TLS_ST_CR_ENCRYPTED_EXTENSIONS, + TLS_ST_CR_CERT_VRFY, + TLS_ST_SW_CERT_VRFY, + TLS_ST_CR_HELLO_REQ, + TLS_ST_SW_KEY_UPDATE, + TLS_ST_CW_KEY_UPDATE, + TLS_ST_SR_KEY_UPDATE, + TLS_ST_CR_KEY_UPDATE, + TLS_ST_EARLY_DATA, + TLS_ST_PENDING_EARLY_DATA_END, + TLS_ST_CW_END_OF_EARLY_DATA, + TLS_ST_SR_END_OF_EARLY_DATA +} OSSL_HANDSHAKE_STATE; + +/* + * Most of the following state values are no longer used and are defined to be + * the closest equivalent value in the current state machine code. Not all + * defines have an equivalent and are set to a dummy value (-1). SSL_ST_CONNECT + * and SSL_ST_ACCEPT are still in use in the definition of SSL_CB_ACCEPT_LOOP, + * SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP and SSL_CB_CONNECT_EXIT. + */ + +# define SSL_ST_CONNECT 0x1000 +# define SSL_ST_ACCEPT 0x2000 + +# define SSL_ST_MASK 0x0FFF + +# define SSL_CB_LOOP 0x01 +# define SSL_CB_EXIT 0x02 +# define SSL_CB_READ 0x04 +# define SSL_CB_WRITE 0x08 +# define SSL_CB_ALERT 0x4000/* used in callback */ +# define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) +# define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) +# define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) +# define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) +# define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) +# define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) +# define SSL_CB_HANDSHAKE_START 0x10 +# define SSL_CB_HANDSHAKE_DONE 0x20 + +/* Is the SSL_connection established? */ +# define SSL_in_connect_init(a) (SSL_in_init(a) && !SSL_is_server(a)) +# define SSL_in_accept_init(a) (SSL_in_init(a) && SSL_is_server(a)) +int SSL_in_init(const SSL *s); +int SSL_in_before(const SSL *s); +int SSL_is_init_finished(const SSL *s); + +/* + * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you + * should not need these + */ +# define SSL_ST_READ_HEADER 0xF0 +# define SSL_ST_READ_BODY 0xF1 +# define SSL_ST_READ_DONE 0xF2 + +/*- + * Obtain latest Finished message + * -- that we sent (SSL_get_finished) + * -- that we expected from peer (SSL_get_peer_finished). + * Returns length (0 == no Finished so far), copies up to 'count' bytes. + */ +size_t SSL_get_finished(const SSL *s, void *buf, size_t count); +size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); + +/* + * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 3 options are + * 'ored' with SSL_VERIFY_PEER if they are desired + */ +# define SSL_VERIFY_NONE 0x00 +# define SSL_VERIFY_PEER 0x01 +# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 +# define SSL_VERIFY_CLIENT_ONCE 0x04 +# define SSL_VERIFY_POST_HANDSHAKE 0x08 + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define OpenSSL_add_ssl_algorithms() SSL_library_init() +# define SSLeay_add_ssl_algorithms() SSL_library_init() +# endif + +/* More backward compatibility */ +# define SSL_get_cipher(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +# define SSL_get_cipher_bits(s,np) \ + SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) +# define SSL_get_cipher_version(s) \ + SSL_CIPHER_get_version(SSL_get_current_cipher(s)) +# define SSL_get_cipher_name(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +# define SSL_get_time(a) SSL_SESSION_get_time(a) +# define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b)) +# define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) +# define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) + +# define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id) +# define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id) + +DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) +# define SSL_AD_REASON_OFFSET 1000/* offset to get SSL_R_... value + * from SSL_AD_... */ +/* These alert types are for SSLv3 and TLSv1 */ +# define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY +/* fatal */ +# define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE +/* fatal */ +# define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC +# define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED +# define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW +/* fatal */ +# define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE +/* fatal */ +# define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE +/* Not for TLS */ +# define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE +# define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE +# define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE +# define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED +# define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED +# define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN +/* fatal */ +# define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER +/* fatal */ +# define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA +/* fatal */ +# define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED +/* fatal */ +# define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR +# define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR +/* fatal */ +# define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION +/* fatal */ +# define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION +/* fatal */ +# define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY +/* fatal */ +# define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR +# define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED +# define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION +# define SSL_AD_MISSING_EXTENSION TLS13_AD_MISSING_EXTENSION +# define SSL_AD_CERTIFICATE_REQUIRED TLS13_AD_CERTIFICATE_REQUIRED +# define SSL_AD_UNSUPPORTED_EXTENSION TLS1_AD_UNSUPPORTED_EXTENSION +# define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE +# define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME +# define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE +# define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE +/* fatal */ +# define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY +/* fatal */ +# define SSL_AD_INAPPROPRIATE_FALLBACK TLS1_AD_INAPPROPRIATE_FALLBACK +# define SSL_AD_NO_APPLICATION_PROTOCOL TLS1_AD_NO_APPLICATION_PROTOCOL +# define SSL_ERROR_NONE 0 +# define SSL_ERROR_SSL 1 +# define SSL_ERROR_WANT_READ 2 +# define SSL_ERROR_WANT_WRITE 3 +# define SSL_ERROR_WANT_X509_LOOKUP 4 +# define SSL_ERROR_SYSCALL 5/* look at error stack/return + * value/errno */ +# define SSL_ERROR_ZERO_RETURN 6 +# define SSL_ERROR_WANT_CONNECT 7 +# define SSL_ERROR_WANT_ACCEPT 8 +# define SSL_ERROR_WANT_ASYNC 9 +# define SSL_ERROR_WANT_ASYNC_JOB 10 +# define SSL_ERROR_WANT_CLIENT_HELLO_CB 11 +# define SSL_ERROR_WANT_RETRY_VERIFY 12 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_CTRL_SET_TMP_DH 3 +# define SSL_CTRL_SET_TMP_ECDH 4 +# define SSL_CTRL_SET_TMP_DH_CB 6 +# endif + +# define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 +# define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10 +# define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11 +# define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12 +# define SSL_CTRL_GET_FLAGS 13 +# define SSL_CTRL_EXTRA_CHAIN_CERT 14 +# define SSL_CTRL_SET_MSG_CALLBACK 15 +# define SSL_CTRL_SET_MSG_CALLBACK_ARG 16 +/* only applies to datagram connections */ +# define SSL_CTRL_SET_MTU 17 +/* Stats */ +# define SSL_CTRL_SESS_NUMBER 20 +# define SSL_CTRL_SESS_CONNECT 21 +# define SSL_CTRL_SESS_CONNECT_GOOD 22 +# define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 +# define SSL_CTRL_SESS_ACCEPT 24 +# define SSL_CTRL_SESS_ACCEPT_GOOD 25 +# define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 +# define SSL_CTRL_SESS_HIT 27 +# define SSL_CTRL_SESS_CB_HIT 28 +# define SSL_CTRL_SESS_MISSES 29 +# define SSL_CTRL_SESS_TIMEOUTS 30 +# define SSL_CTRL_SESS_CACHE_FULL 31 +# define SSL_CTRL_MODE 33 +# define SSL_CTRL_GET_READ_AHEAD 40 +# define SSL_CTRL_SET_READ_AHEAD 41 +# define SSL_CTRL_SET_SESS_CACHE_SIZE 42 +# define SSL_CTRL_GET_SESS_CACHE_SIZE 43 +# define SSL_CTRL_SET_SESS_CACHE_MODE 44 +# define SSL_CTRL_GET_SESS_CACHE_MODE 45 +# define SSL_CTRL_GET_MAX_CERT_LIST 50 +# define SSL_CTRL_SET_MAX_CERT_LIST 51 +# define SSL_CTRL_SET_MAX_SEND_FRAGMENT 52 +/* see tls1.h for macros based on these */ +# define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB 53 +# define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG 54 +# define SSL_CTRL_SET_TLSEXT_HOSTNAME 55 +# define SSL_CTRL_SET_TLSEXT_DEBUG_CB 56 +# define SSL_CTRL_SET_TLSEXT_DEBUG_ARG 57 +# define SSL_CTRL_GET_TLSEXT_TICKET_KEYS 58 +# define SSL_CTRL_SET_TLSEXT_TICKET_KEYS 59 +/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT 60 */ +/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61 */ +/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62 */ +# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB 63 +# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG 64 +# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE 65 +# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS 66 +# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS 67 +# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS 68 +# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS 69 +# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP 70 +# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP 71 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB 72 +# endif +# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB 75 +# define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB 76 +# define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB 77 +# define SSL_CTRL_SET_SRP_ARG 78 +# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME 79 +# define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH 80 +# define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD 81 +# define DTLS_CTRL_GET_TIMEOUT 73 +# define DTLS_CTRL_HANDLE_TIMEOUT 74 +# define SSL_CTRL_GET_RI_SUPPORT 76 +# define SSL_CTRL_CLEAR_MODE 78 +# define SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB 79 +# define SSL_CTRL_GET_EXTRA_CHAIN_CERTS 82 +# define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS 83 +# define SSL_CTRL_CHAIN 88 +# define SSL_CTRL_CHAIN_CERT 89 +# define SSL_CTRL_GET_GROUPS 90 +# define SSL_CTRL_SET_GROUPS 91 +# define SSL_CTRL_SET_GROUPS_LIST 92 +# define SSL_CTRL_GET_SHARED_GROUP 93 +# define SSL_CTRL_SET_SIGALGS 97 +# define SSL_CTRL_SET_SIGALGS_LIST 98 +# define SSL_CTRL_CERT_FLAGS 99 +# define SSL_CTRL_CLEAR_CERT_FLAGS 100 +# define SSL_CTRL_SET_CLIENT_SIGALGS 101 +# define SSL_CTRL_SET_CLIENT_SIGALGS_LIST 102 +# define SSL_CTRL_GET_CLIENT_CERT_TYPES 103 +# define SSL_CTRL_SET_CLIENT_CERT_TYPES 104 +# define SSL_CTRL_BUILD_CERT_CHAIN 105 +# define SSL_CTRL_SET_VERIFY_CERT_STORE 106 +# define SSL_CTRL_SET_CHAIN_CERT_STORE 107 +# define SSL_CTRL_GET_PEER_SIGNATURE_NID 108 +# define SSL_CTRL_GET_PEER_TMP_KEY 109 +# define SSL_CTRL_GET_RAW_CIPHERLIST 110 +# define SSL_CTRL_GET_EC_POINT_FORMATS 111 +# define SSL_CTRL_GET_CHAIN_CERTS 115 +# define SSL_CTRL_SELECT_CURRENT_CERT 116 +# define SSL_CTRL_SET_CURRENT_CERT 117 +# define SSL_CTRL_SET_DH_AUTO 118 +# define DTLS_CTRL_SET_LINK_MTU 120 +# define DTLS_CTRL_GET_LINK_MIN_MTU 121 +# define SSL_CTRL_GET_EXTMS_SUPPORT 122 +# define SSL_CTRL_SET_MIN_PROTO_VERSION 123 +# define SSL_CTRL_SET_MAX_PROTO_VERSION 124 +# define SSL_CTRL_SET_SPLIT_SEND_FRAGMENT 125 +# define SSL_CTRL_SET_MAX_PIPELINES 126 +# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE 127 +# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB 128 +# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG 129 +# define SSL_CTRL_GET_MIN_PROTO_VERSION 130 +# define SSL_CTRL_GET_MAX_PROTO_VERSION 131 +# define SSL_CTRL_GET_SIGNATURE_NID 132 +# define SSL_CTRL_GET_TMP_KEY 133 +# define SSL_CTRL_GET_NEGOTIATED_GROUP 134 +# define SSL_CTRL_GET_IANA_GROUPS 135 +# define SSL_CTRL_SET_RETRY_VERIFY 136 +# define SSL_CTRL_GET_VERIFY_CERT_STORE 137 +# define SSL_CTRL_GET_CHAIN_CERT_STORE 138 +# define SSL_CTRL_GET0_IMPLEMENTED_GROUPS 139 +# define SSL_CTRL_GET_SIGNATURE_NAME 140 +# define SSL_CTRL_GET_PEER_SIGNATURE_NAME 141 +# define SSL_CERT_SET_FIRST 1 +# define SSL_CERT_SET_NEXT 2 +# define SSL_CERT_SET_SERVER 3 +# define DTLSv1_get_timeout(ssl, arg) \ + SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)(arg)) +# define DTLSv1_handle_timeout(ssl) \ + SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL) +# define SSL_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL) +# define SSL_clear_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL) +# define SSL_total_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL) +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_CTX_set_tmp_dh(ctx,dh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)(dh)) +# endif +# define SSL_CTX_set_dh_auto(ctx, onoff) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_DH_AUTO,onoff,NULL) +# define SSL_set_dh_auto(s, onoff) \ + SSL_ctrl(s,SSL_CTRL_SET_DH_AUTO,onoff,NULL) +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_set_tmp_dh(ssl,dh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)(dh)) +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh)) +# define SSL_set_tmp_ecdh(ssl,ecdh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh)) +# endif +# define SSL_CTX_add_extra_chain_cert(ctx,x509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)(x509)) +# define SSL_CTX_get_extra_chain_certs(ctx,px509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509) +# define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509) +# define SSL_CTX_clear_extra_chain_certs(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL) +# define SSL_CTX_set0_chain(ctx,sk) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)(sk)) +# define SSL_CTX_set1_chain(ctx,sk) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)(sk)) +# define SSL_CTX_add0_chain_cert(ctx,x509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)(x509)) +# define SSL_CTX_add1_chain_cert(ctx,x509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)(x509)) +# define SSL_CTX_get0_chain_certs(ctx,px509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509) +# define SSL_CTX_clear_chain_certs(ctx) \ + SSL_CTX_set0_chain(ctx,NULL) +# define SSL_CTX_build_cert_chain(ctx, flags) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) +# define SSL_CTX_select_current_cert(ctx,x509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509)) +# define SSL_CTX_set_current_cert(ctx, op) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL) +# define SSL_CTX_set0_verify_cert_store(ctx,st) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st)) +# define SSL_CTX_set1_verify_cert_store(ctx,st) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st)) +# define SSL_CTX_get0_verify_cert_store(ctx,st) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_VERIFY_CERT_STORE,0,(char *)(st)) +# define SSL_CTX_set0_chain_cert_store(ctx,st) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st)) +# define SSL_CTX_set1_chain_cert_store(ctx,st) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st)) +# define SSL_CTX_get0_chain_cert_store(ctx,st) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERT_STORE,0,(char *)(st)) +# define SSL_set0_chain(s,sk) \ + SSL_ctrl(s,SSL_CTRL_CHAIN,0,(char *)(sk)) +# define SSL_set1_chain(s,sk) \ + SSL_ctrl(s,SSL_CTRL_CHAIN,1,(char *)(sk)) +# define SSL_add0_chain_cert(s,x509) \ + SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,0,(char *)(x509)) +# define SSL_add1_chain_cert(s,x509) \ + SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,1,(char *)(x509)) +# define SSL_get0_chain_certs(s,px509) \ + SSL_ctrl(s,SSL_CTRL_GET_CHAIN_CERTS,0,px509) +# define SSL_clear_chain_certs(s) \ + SSL_set0_chain(s,NULL) +# define SSL_build_cert_chain(s, flags) \ + SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) +# define SSL_select_current_cert(s,x509) \ + SSL_ctrl(s,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509)) +# define SSL_set_current_cert(s,op) \ + SSL_ctrl(s,SSL_CTRL_SET_CURRENT_CERT, op, NULL) +# define SSL_set0_verify_cert_store(s,st) \ + SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st)) +# define SSL_set1_verify_cert_store(s,st) \ + SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st)) +#define SSL_get0_verify_cert_store(s,st) \ + SSL_ctrl(s,SSL_CTRL_GET_VERIFY_CERT_STORE,0,(char *)(st)) +# define SSL_set0_chain_cert_store(s,st) \ + SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st)) +# define SSL_set1_chain_cert_store(s,st) \ + SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st)) +#define SSL_get0_chain_cert_store(s,st) \ + SSL_ctrl(s,SSL_CTRL_GET_CHAIN_CERT_STORE,0,(char *)(st)) + +# define SSL_get1_groups(s, glist) \ + SSL_ctrl(s,SSL_CTRL_GET_GROUPS,0,(int*)(glist)) +# define SSL_get0_iana_groups(s, plst) \ + SSL_ctrl(s,SSL_CTRL_GET_IANA_GROUPS,0,(uint16_t **)(plst)) +# define SSL_CTX_set1_groups(ctx, glist, glistlen) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS,glistlen,(int *)(glist)) +# define SSL_CTX_set1_groups_list(ctx, s) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(s)) +# define SSL_CTX_get0_implemented_groups(ctx, all, out) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET0_IMPLEMENTED_GROUPS, all, \ + (STACK_OF(OPENSSL_CSTRING) *)(out)) +# define SSL_set1_groups(s, glist, glistlen) \ + SSL_ctrl(s,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist)) +# define SSL_set1_groups_list(s, str) \ + SSL_ctrl(s,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(str)) +# define SSL_get_shared_group(s, n) \ + SSL_ctrl(s,SSL_CTRL_GET_SHARED_GROUP,n,NULL) +# define SSL_get_negotiated_group(s) \ + SSL_ctrl(s,SSL_CTRL_GET_NEGOTIATED_GROUP,0,NULL) +# define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist)) +# define SSL_CTX_set1_sigalgs_list(ctx, s) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(s)) +# define SSL_set1_sigalgs(s, slist, slistlen) \ + SSL_ctrl(s,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist)) +# define SSL_set1_sigalgs_list(s, str) \ + SSL_ctrl(s,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(str)) +# define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist)) +# define SSL_CTX_set1_client_sigalgs_list(ctx, s) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(s)) +# define SSL_set1_client_sigalgs(s, slist, slistlen) \ + SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist)) +# define SSL_set1_client_sigalgs_list(s, str) \ + SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(str)) +# define SSL_get0_certificate_types(s, clist) \ + SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)(clist)) +# define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen, \ + (char *)(clist)) +# define SSL_set1_client_certificate_types(s, clist, clistlen) \ + SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)(clist)) +# define SSL_get0_signature_name(s, str) \ + SSL_ctrl(s,SSL_CTRL_GET_SIGNATURE_NAME,0,(1?(str):(const char **)NULL)) +# define SSL_get_signature_nid(s, pn) \ + SSL_ctrl(s,SSL_CTRL_GET_SIGNATURE_NID,0,pn) +# define SSL_get0_peer_signature_name(s, str) \ + SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NAME,0,(1?(str):(const char **)NULL)) +# define SSL_get_peer_signature_nid(s, pn) \ + SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn) +# define SSL_get_peer_tmp_key(s, pk) \ + SSL_ctrl(s,SSL_CTRL_GET_PEER_TMP_KEY,0,pk) +# define SSL_get_tmp_key(s, pk) \ + SSL_ctrl(s,SSL_CTRL_GET_TMP_KEY,0,pk) +# define SSL_get0_raw_cipherlist(s, plst) \ + SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,plst) +# define SSL_get0_ec_point_formats(s, plst) \ + SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,plst) +# define SSL_CTX_set_min_proto_version(ctx, version) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) +# define SSL_CTX_set_max_proto_version(ctx, version) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) +# define SSL_CTX_get_min_proto_version(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL) +# define SSL_CTX_get_max_proto_version(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL) +# define SSL_set_min_proto_version(s, version) \ + SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) +# define SSL_set_max_proto_version(s, version) \ + SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) +# define SSL_get_min_proto_version(s) \ + SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL) +# define SSL_get_max_proto_version(s) \ + SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL) + +const char *SSL_get0_group_name(SSL *s); +const char *SSL_group_to_name(SSL *s, int id); + +/* Backwards compatibility, original 1.1.0 names */ +# define SSL_CTRL_GET_SERVER_TMP_KEY \ + SSL_CTRL_GET_PEER_TMP_KEY +# define SSL_get_server_tmp_key(s, pk) \ + SSL_get_peer_tmp_key(s, pk) + +int SSL_set0_tmp_dh_pkey(SSL *s, EVP_PKEY *dhpkey); +int SSL_CTX_set0_tmp_dh_pkey(SSL_CTX *ctx, EVP_PKEY *dhpkey); + +/* + * The following symbol names are old and obsolete. They are kept + * for compatibility reasons only and should not be used anymore. + */ +# define SSL_CTRL_GET_CURVES SSL_CTRL_GET_GROUPS +# define SSL_CTRL_SET_CURVES SSL_CTRL_SET_GROUPS +# define SSL_CTRL_SET_CURVES_LIST SSL_CTRL_SET_GROUPS_LIST +# define SSL_CTRL_GET_SHARED_CURVE SSL_CTRL_GET_SHARED_GROUP + +# define SSL_get1_curves SSL_get1_groups +# define SSL_CTX_set1_curves SSL_CTX_set1_groups +# define SSL_CTX_set1_curves_list SSL_CTX_set1_groups_list +# define SSL_set1_curves SSL_set1_groups +# define SSL_set1_curves_list SSL_set1_groups_list +# define SSL_get_shared_curve SSL_get_shared_group + + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +/* Provide some compatibility macros for removed functionality. */ +# define SSL_CTX_need_tmp_RSA(ctx) 0 +# define SSL_CTX_set_tmp_rsa(ctx,rsa) 1 +# define SSL_need_tmp_RSA(ssl) 0 +# define SSL_set_tmp_rsa(ssl,rsa) 1 +# define SSL_CTX_set_ecdh_auto(dummy, onoff) ((onoff) != 0) +# define SSL_set_ecdh_auto(dummy, onoff) ((onoff) != 0) +/* + * We "pretend" to call the callback to avoid warnings about unused static + * functions. + */ +# define SSL_CTX_set_tmp_rsa_callback(ctx, cb) while(0) (cb)(NULL, 0, 0) +# define SSL_set_tmp_rsa_callback(ssl, cb) while(0) (cb)(NULL, 0, 0) +# endif +__owur const BIO_METHOD *BIO_f_ssl(void); +__owur BIO *BIO_new_ssl(SSL_CTX *ctx, int client); +__owur BIO *BIO_new_ssl_connect(SSL_CTX *ctx); +__owur BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); +__owur int BIO_ssl_copy_session_id(BIO *to, BIO *from); +void BIO_ssl_shutdown(BIO *ssl_bio); + +__owur int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str); +__owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth); +__owur SSL_CTX *SSL_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq, + const SSL_METHOD *meth); +int SSL_CTX_up_ref(SSL_CTX *ctx); +void SSL_CTX_free(SSL_CTX *); +__owur long SSL_CTX_set_timeout(SSL_CTX *ctx, long t); +__owur long SSL_CTX_get_timeout(const SSL_CTX *ctx); +__owur X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); +void SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *); +void SSL_CTX_set1_cert_store(SSL_CTX *, X509_STORE *); +__owur int SSL_want(const SSL *s); +__owur int SSL_clear(SSL *s); + +#ifndef OPENSSL_NO_DEPRECATED_3_4 +OSSL_DEPRECATEDIN_3_4_FOR("not Y2038-safe, replace with SSL_CTX_flush_sessions_ex()") +void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm); +#endif +void SSL_CTX_flush_sessions_ex(SSL_CTX *ctx, time_t tm); + +__owur const SSL_CIPHER *SSL_get_current_cipher(const SSL *s); +__owur const SSL_CIPHER *SSL_get_pending_cipher(const SSL *s); +__owur int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits); +__owur const char *SSL_CIPHER_get_version(const SSL_CIPHER *c); +__owur const char *SSL_CIPHER_get_name(const SSL_CIPHER *c); +__owur const char *SSL_CIPHER_standard_name(const SSL_CIPHER *c); +__owur const char *OPENSSL_cipher_name(const char *rfc_name); +__owur uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c); +__owur uint16_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *c); +__owur int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c); +__owur int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c); +__owur const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c); +__owur int SSL_CIPHER_is_aead(const SSL_CIPHER *c); + +__owur int SSL_get_fd(const SSL *s); +__owur int SSL_get_rfd(const SSL *s); +__owur int SSL_get_wfd(const SSL *s); +__owur const char *SSL_get_cipher_list(const SSL *s, int n); +__owur char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size); +__owur int SSL_get_read_ahead(const SSL *s); +__owur int SSL_pending(const SSL *s); +__owur int SSL_has_pending(const SSL *s); +# ifndef OPENSSL_NO_SOCK +__owur int SSL_set_fd(SSL *s, int fd); +__owur int SSL_set_rfd(SSL *s, int fd); +__owur int SSL_set_wfd(SSL *s, int fd); +# endif +void SSL_set0_rbio(SSL *s, BIO *rbio); +void SSL_set0_wbio(SSL *s, BIO *wbio); +void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio); +__owur BIO *SSL_get_rbio(const SSL *s); +__owur BIO *SSL_get_wbio(const SSL *s); +__owur int SSL_set_cipher_list(SSL *s, const char *str); +__owur int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str); +__owur int SSL_set_ciphersuites(SSL *s, const char *str); +void SSL_set_read_ahead(SSL *s, int yes); +__owur int SSL_get_verify_mode(const SSL *s); +__owur int SSL_get_verify_depth(const SSL *s); +__owur SSL_verify_cb SSL_get_verify_callback(const SSL *s); +void SSL_set_verify(SSL *s, int mode, SSL_verify_cb callback); +void SSL_set_verify_depth(SSL *s, int depth); +void SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 __owur int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); +OSSL_DEPRECATEDIN_3_0 +__owur int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, + const unsigned char *d, long len); +# endif +__owur int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); +__owur int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, + long len); +__owur int SSL_use_certificate(SSL *ssl, X509 *x); +__owur int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); +__owur int SSL_use_cert_and_key(SSL *ssl, X509 *x509, EVP_PKEY *privatekey, + STACK_OF(X509) *chain, int override); + + +/* serverinfo file format versions */ +# define SSL_SERVERINFOV1 1 +# define SSL_SERVERINFOV2 2 + +/* Set serverinfo data for the current active cert. */ +__owur int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo, + size_t serverinfo_length); +__owur int SSL_CTX_use_serverinfo_ex(SSL_CTX *ctx, unsigned int version, + const unsigned char *serverinfo, + size_t serverinfo_length); +__owur int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file); + +#ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +__owur int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); +#endif + +__owur int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); +__owur int SSL_use_certificate_file(SSL *ssl, const char *file, int type); + +#ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +__owur int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, + int type); +#endif +__owur int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, + int type); +__owur int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, + int type); +/* PEM type */ +__owur int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); +__owur int SSL_use_certificate_chain_file(SSL *ssl, const char *file); +__owur STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); +__owur STACK_OF(X509_NAME) +*SSL_load_client_CA_file_ex(const char *file, OSSL_LIB_CTX *libctx, + const char *propq); +__owur int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *file); +int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *dir); +int SSL_add_store_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *uri); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define SSL_load_error_strings() \ + OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \ + | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) +# endif + +__owur const char *SSL_state_string(const SSL *s); +__owur const char *SSL_rstate_string(const SSL *s); +__owur const char *SSL_state_string_long(const SSL *s); +__owur const char *SSL_rstate_string_long(const SSL *s); + +#ifndef OPENSSL_NO_DEPRECATED_3_4 +OSSL_DEPRECATEDIN_3_4_FOR("not Y2038-safe, replace with SSL_SESSION_get_time_ex()") +__owur long SSL_SESSION_get_time(const SSL_SESSION *s); +OSSL_DEPRECATEDIN_3_4_FOR("not Y2038-safe, replace with SSL_SESSION_set_time_ex()") +__owur long SSL_SESSION_set_time(SSL_SESSION *s, long t); +#endif +__owur long SSL_SESSION_get_timeout(const SSL_SESSION *s); +__owur long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); +__owur int SSL_SESSION_get_protocol_version(const SSL_SESSION *s); +__owur int SSL_SESSION_set_protocol_version(SSL_SESSION *s, int version); + +__owur time_t SSL_SESSION_get_time_ex(const SSL_SESSION *s); +__owur time_t SSL_SESSION_set_time_ex(SSL_SESSION *s, time_t t); + +__owur const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s); +__owur int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname); +void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s, + const unsigned char **alpn, + size_t *len); +__owur int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, + const unsigned char *alpn, + size_t len); +__owur const SSL_CIPHER *SSL_SESSION_get0_cipher(const SSL_SESSION *s); +__owur int SSL_SESSION_set_cipher(SSL_SESSION *s, const SSL_CIPHER *cipher); +__owur int SSL_SESSION_has_ticket(const SSL_SESSION *s); +__owur unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s); +void SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick, + size_t *len); +__owur uint32_t SSL_SESSION_get_max_early_data(const SSL_SESSION *s); +__owur int SSL_SESSION_set_max_early_data(SSL_SESSION *s, + uint32_t max_early_data); +__owur int SSL_copy_session_id(SSL *to, const SSL *from); +__owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s); +__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s, + const unsigned char *sid_ctx, + unsigned int sid_ctx_len); +__owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid, + unsigned int sid_len); +__owur int SSL_SESSION_is_resumable(const SSL_SESSION *s); + +__owur SSL_SESSION *SSL_SESSION_new(void); +__owur SSL_SESSION *SSL_SESSION_dup(const SSL_SESSION *src); +const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, + unsigned int *len); +const unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s, + unsigned int *len); +__owur unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s); +# ifndef OPENSSL_NO_STDIO +int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses); +# endif +int SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses); +int SSL_SESSION_print_keylog(BIO *bp, const SSL_SESSION *x); +int SSL_SESSION_up_ref(SSL_SESSION *ses); +void SSL_SESSION_free(SSL_SESSION *ses); +__owur int i2d_SSL_SESSION(const SSL_SESSION *in, unsigned char **pp); +__owur int SSL_set_session(SSL *to, SSL_SESSION *session); +int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *session); +int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *session); +__owur int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb); +__owur int SSL_set_generate_session_id(SSL *s, GEN_SESSION_CB cb); +__owur int SSL_has_matching_session_id(const SSL *s, + const unsigned char *id, + unsigned int id_len); +SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, + long length); +SSL_SESSION *d2i_SSL_SESSION_ex(SSL_SESSION **a, const unsigned char **pp, + long length, OSSL_LIB_CTX *libctx, + const char *propq); + +# ifdef OPENSSL_X509_H +__owur X509 *SSL_get0_peer_certificate(const SSL *s); +__owur X509 *SSL_get1_peer_certificate(const SSL *s); +/* Deprecated in 3.0.0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_get_peer_certificate SSL_get1_peer_certificate +# endif +# endif + +__owur STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); + +__owur int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); +__owur int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); +__owur SSL_verify_cb SSL_CTX_get_verify_callback(const SSL_CTX *ctx); +void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, SSL_verify_cb callback); +void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth); +void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, + int (*cb) (X509_STORE_CTX *, void *), + void *arg); +void SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg), + void *arg); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +__owur int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); +OSSL_DEPRECATEDIN_3_0 +__owur int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, + long len); +# endif +__owur int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); +__owur int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, + const unsigned char *d, long len); +__owur int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); +__owur int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, + const unsigned char *d); +__owur int SSL_CTX_use_cert_and_key(SSL_CTX *ctx, X509 *x509, EVP_PKEY *privatekey, + STACK_OF(X509) *chain, int override); + +void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); +pem_password_cb *SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx); +void *SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx); +void SSL_set_default_passwd_cb(SSL *s, pem_password_cb *cb); +void SSL_set_default_passwd_cb_userdata(SSL *s, void *u); +pem_password_cb *SSL_get_default_passwd_cb(SSL *s); +void *SSL_get_default_passwd_cb_userdata(SSL *s); + +__owur int SSL_CTX_check_private_key(const SSL_CTX *ctx); +__owur int SSL_check_private_key(const SSL *ctx); + +__owur int SSL_CTX_set_session_id_context(SSL_CTX *ctx, + const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +SSL *SSL_new(SSL_CTX *ctx); +int SSL_up_ref(SSL *s); +int SSL_is_dtls(const SSL *s); +int SSL_is_tls(const SSL *s); +int SSL_is_quic(const SSL *s); +__owur int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +__owur int SSL_CTX_set_purpose(SSL_CTX *ctx, int purpose); +__owur int SSL_set_purpose(SSL *ssl, int purpose); +__owur int SSL_CTX_set_trust(SSL_CTX *ctx, int trust); +__owur int SSL_set_trust(SSL *ssl, int trust); + +__owur int SSL_set1_host(SSL *s, const char *host); +__owur int SSL_add1_host(SSL *s, const char *host); +__owur const char *SSL_get0_peername(SSL *s); +void SSL_set_hostflags(SSL *s, unsigned int flags); + +__owur int SSL_CTX_dane_enable(SSL_CTX *ctx); +__owur int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md, + uint8_t mtype, uint8_t ord); +__owur int SSL_dane_enable(SSL *s, const char *basedomain); +__owur int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector, + uint8_t mtype, const unsigned char *data, size_t dlen); +__owur int SSL_get0_dane_authority(SSL *s, X509 **mcert, EVP_PKEY **mspki); +__owur int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector, + uint8_t *mtype, const unsigned char **data, + size_t *dlen); +/* + * Bridge opacity barrier between libcrypt and libssl, also needed to support + * offline testing in test/danetest.c + */ +SSL_DANE *SSL_get0_dane(SSL *ssl); +/* + * DANE flags + */ +unsigned long SSL_CTX_dane_set_flags(SSL_CTX *ctx, unsigned long flags); +unsigned long SSL_CTX_dane_clear_flags(SSL_CTX *ctx, unsigned long flags); +unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags); +unsigned long SSL_dane_clear_flags(SSL *ssl, unsigned long flags); + +__owur int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm); +__owur int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm); + +__owur X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx); +__owur X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl); + +# ifndef OPENSSL_NO_SRP +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name); +OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password); +OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength); +OSSL_DEPRECATEDIN_3_0 +int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx, + char *(*cb) (SSL *, void *)); +OSSL_DEPRECATEDIN_3_0 +int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx, + int (*cb) (SSL *, void *)); +OSSL_DEPRECATEDIN_3_0 +int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx, + int (*cb) (SSL *, int *, void *)); +OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg); + +OSSL_DEPRECATEDIN_3_0 +int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g, + BIGNUM *sa, BIGNUM *v, char *info); +OSSL_DEPRECATEDIN_3_0 +int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass, + const char *grp); + +OSSL_DEPRECATEDIN_3_0 __owur BIGNUM *SSL_get_srp_g(SSL *s); +OSSL_DEPRECATEDIN_3_0 __owur BIGNUM *SSL_get_srp_N(SSL *s); + +OSSL_DEPRECATEDIN_3_0 __owur char *SSL_get_srp_username(SSL *s); +OSSL_DEPRECATEDIN_3_0 __owur char *SSL_get_srp_userinfo(SSL *s); +# endif +# endif + +/* + * ClientHello callback and helpers. + */ + +# define SSL_CLIENT_HELLO_SUCCESS 1 +# define SSL_CLIENT_HELLO_ERROR 0 +# define SSL_CLIENT_HELLO_RETRY (-1) + +typedef int (*SSL_client_hello_cb_fn) (SSL *s, int *al, void *arg); +void SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn cb, + void *arg); +typedef int (*SSL_new_pending_conn_cb_fn) (SSL_CTX *ctx, SSL *new_ssl, + void *arg); +void SSL_CTX_set_new_pending_conn_cb(SSL_CTX *c, SSL_new_pending_conn_cb_fn cb, + void *arg); + +int SSL_client_hello_isv2(SSL *s); +unsigned int SSL_client_hello_get0_legacy_version(SSL *s); +size_t SSL_client_hello_get0_random(SSL *s, const unsigned char **out); +size_t SSL_client_hello_get0_session_id(SSL *s, const unsigned char **out); +size_t SSL_client_hello_get0_ciphers(SSL *s, const unsigned char **out); +size_t SSL_client_hello_get0_compression_methods(SSL *s, + const unsigned char **out); +int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen); +int SSL_client_hello_get_extension_order(SSL *s, uint16_t *exts, + size_t *num_exts); +int SSL_client_hello_get0_ext(SSL *s, unsigned int type, + const unsigned char **out, size_t *outlen); + +void SSL_certs_clear(SSL *s); +void SSL_free(SSL *ssl); +# ifdef OSSL_ASYNC_FD +/* + * Windows application developer has to include windows.h to use these. + */ +__owur int SSL_waiting_for_async(SSL *s); +__owur int SSL_get_all_async_fds(SSL *s, OSSL_ASYNC_FD *fds, size_t *numfds); +__owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd, + size_t *numaddfds, OSSL_ASYNC_FD *delfd, + size_t *numdelfds); +__owur int SSL_CTX_set_async_callback(SSL_CTX *ctx, SSL_async_callback_fn callback); +__owur int SSL_CTX_set_async_callback_arg(SSL_CTX *ctx, void *arg); +__owur int SSL_set_async_callback(SSL *s, SSL_async_callback_fn callback); +__owur int SSL_set_async_callback_arg(SSL *s, void *arg); +__owur int SSL_get_async_status(SSL *s, int *status); + +# endif +__owur int SSL_accept(SSL *ssl); +__owur int SSL_stateless(SSL *s); +__owur int SSL_connect(SSL *ssl); +__owur int SSL_read(SSL *ssl, void *buf, int num); +__owur int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes); + +# define SSL_READ_EARLY_DATA_ERROR 0 +# define SSL_READ_EARLY_DATA_SUCCESS 1 +# define SSL_READ_EARLY_DATA_FINISH 2 + +__owur int SSL_read_early_data(SSL *s, void *buf, size_t num, + size_t *readbytes); +__owur int SSL_peek(SSL *ssl, void *buf, int num); +__owur int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes); +__owur ossl_ssize_t SSL_sendfile(SSL *s, int fd, off_t offset, size_t size, + int flags); +__owur int SSL_write(SSL *ssl, const void *buf, int num); +__owur int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written); +__owur int SSL_write_early_data(SSL *s, const void *buf, size_t num, + size_t *written); +long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg); +long SSL_callback_ctrl(SSL *, int, void (*)(void)); +long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); +long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void)); + +# define SSL_WRITE_FLAG_CONCLUDE (1U << 0) + +__owur int SSL_write_ex2(SSL *s, const void *buf, size_t num, + uint64_t flags, + size_t *written); + +# define SSL_EARLY_DATA_NOT_SENT 0 +# define SSL_EARLY_DATA_REJECTED 1 +# define SSL_EARLY_DATA_ACCEPTED 2 + +__owur int SSL_get_early_data_status(const SSL *s); + +__owur int SSL_get_error(const SSL *s, int ret_code); +__owur const char *SSL_get_version(const SSL *s); +__owur int SSL_get_handshake_rtt(const SSL *s, uint64_t *rtt); + +/* This sets the 'default' SSL version that SSL_new() will create */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +__owur int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth); +# endif + +# ifndef OPENSSL_NO_SSL3_METHOD +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *SSLv3_method(void); /* SSLv3 */ +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *SSLv3_server_method(void); +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *SSLv3_client_method(void); +# endif +# endif + +#define SSLv23_method TLS_method +#define SSLv23_server_method TLS_server_method +#define SSLv23_client_method TLS_client_method + +/* Negotiate highest available SSL/TLS version */ +__owur const SSL_METHOD *TLS_method(void); +__owur const SSL_METHOD *TLS_server_method(void); +__owur const SSL_METHOD *TLS_client_method(void); + +# ifndef OPENSSL_NO_TLS1_METHOD +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */ +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_server_method(void); +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_client_method(void); +# endif +# endif + +# ifndef OPENSSL_NO_TLS1_1_METHOD +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_1_method(void); /* TLSv1.1 */ +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_1_server_method(void); +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_1_client_method(void); +# endif +# endif + +# ifndef OPENSSL_NO_TLS1_2_METHOD +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */ +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_2_server_method(void); +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_2_client_method(void); +# endif +# endif + +# ifndef OPENSSL_NO_DTLS1_METHOD +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */ +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_server_method(void); +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_client_method(void); +# endif +# endif + +# ifndef OPENSSL_NO_DTLS1_2_METHOD +/* DTLSv1.2 */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_2_method(void); +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_2_server_method(void); +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_2_client_method(void); +# endif +# endif + +__owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */ +__owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */ +__owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */ + +__owur size_t DTLS_get_data_mtu(const SSL *s); + +__owur STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); +__owur STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx); +__owur STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s); +__owur STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s); + +__owur int SSL_do_handshake(SSL *s); +int SSL_key_update(SSL *s, int updatetype); +int SSL_get_key_update_type(const SSL *s); +int SSL_renegotiate(SSL *s); +int SSL_renegotiate_abbreviated(SSL *s); +__owur int SSL_renegotiate_pending(const SSL *s); +int SSL_new_session_ticket(SSL *s); +int SSL_shutdown(SSL *s); +__owur int SSL_verify_client_post_handshake(SSL *s); +void SSL_CTX_set_post_handshake_auth(SSL_CTX *ctx, int val); +void SSL_set_post_handshake_auth(SSL *s, int val); + +__owur const SSL_METHOD *SSL_CTX_get_ssl_method(const SSL_CTX *ctx); +__owur const SSL_METHOD *SSL_get_ssl_method(const SSL *s); +__owur int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method); +__owur const char *SSL_alert_type_string_long(int value); +__owur const char *SSL_alert_type_string(int value); +__owur const char *SSL_alert_desc_string_long(int value); +__owur const char *SSL_alert_desc_string(int value); + +void SSL_set0_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); +void SSL_CTX_set0_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); +__owur const STACK_OF(X509_NAME) *SSL_get0_CA_list(const SSL *s); +__owur const STACK_OF(X509_NAME) *SSL_CTX_get0_CA_list(const SSL_CTX *ctx); +__owur int SSL_add1_to_CA_list(SSL *ssl, const X509 *x); +__owur int SSL_CTX_add1_to_CA_list(SSL_CTX *ctx, const X509 *x); +__owur const STACK_OF(X509_NAME) *SSL_get0_peer_CA_list(const SSL *s); + +void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); +void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); +__owur STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); +__owur STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s); +__owur int SSL_add_client_CA(SSL *ssl, X509 *x); +__owur int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x); + +void SSL_set_connect_state(SSL *s); +void SSL_set_accept_state(SSL *s); + +__owur long SSL_get_default_timeout(const SSL *s); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define SSL_library_init() OPENSSL_init_ssl(0, NULL) +# endif + +__owur char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size); +__owur STACK_OF(X509_NAME) *SSL_dup_CA_list(const STACK_OF(X509_NAME) *sk); + +__owur SSL *SSL_dup(SSL *ssl); + +__owur X509 *SSL_get_certificate(const SSL *ssl); +/* + * EVP_PKEY + */ +struct evp_pkey_st *SSL_get_privatekey(const SSL *ssl); + +__owur X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx); +__owur EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx); + +void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode); +__owur int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); +void SSL_set_quiet_shutdown(SSL *ssl, int mode); +__owur int SSL_get_quiet_shutdown(const SSL *ssl); +void SSL_set_shutdown(SSL *ssl, int mode); +__owur int SSL_get_shutdown(const SSL *ssl); +__owur int SSL_version(const SSL *ssl); +__owur int SSL_client_version(const SSL *s); +__owur int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); +__owur int SSL_CTX_set_default_verify_dir(SSL_CTX *ctx); +__owur int SSL_CTX_set_default_verify_file(SSL_CTX *ctx); +__owur int SSL_CTX_set_default_verify_store(SSL_CTX *ctx); +__owur int SSL_CTX_load_verify_file(SSL_CTX *ctx, const char *CAfile); +__owur int SSL_CTX_load_verify_dir(SSL_CTX *ctx, const char *CApath); +__owur int SSL_CTX_load_verify_store(SSL_CTX *ctx, const char *CAstore); +__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx, + const char *CAfile, + const char *CApath); +# define SSL_get0_session SSL_get_session/* just peek at pointer */ +__owur SSL_SESSION *SSL_get_session(const SSL *ssl); +__owur SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ +__owur SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); +SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx); +void SSL_set_info_callback(SSL *ssl, + void (*cb) (const SSL *ssl, int type, int val)); +void (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type, + int val); +__owur OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl); + +void SSL_set_verify_result(SSL *ssl, long v); +__owur long SSL_get_verify_result(const SSL *ssl); +__owur STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s); + +__owur size_t SSL_get_client_random(const SSL *ssl, unsigned char *out, + size_t outlen); +__owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out, + size_t outlen); +__owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *sess, + unsigned char *out, size_t outlen); +__owur int SSL_SESSION_set1_master_key(SSL_SESSION *sess, + const unsigned char *in, size_t len); +uint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *sess); + +#define SSL_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef) +__owur int SSL_set_ex_data(SSL *ssl, int idx, void *data); +void *SSL_get_ex_data(const SSL *ssl, int idx); +#define SSL_SESSION_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, l, p, newf, dupf, freef) +__owur int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data); +void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx); +#define SSL_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef) +__owur int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data); +void *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx); + +__owur int SSL_get_ex_data_X509_STORE_CTX_idx(void); + +# define SSL_CTX_sess_set_cache_size(ctx,t) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) +# define SSL_CTX_sess_get_cache_size(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) +# define SSL_CTX_set_session_cache_mode(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) +# define SSL_CTX_get_session_cache_mode(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) + +# define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) +# define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) +# define SSL_CTX_get_read_ahead(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) +# define SSL_CTX_set_read_ahead(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) +# define SSL_CTX_get_max_cert_list(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +# define SSL_CTX_set_max_cert_list(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) +# define SSL_get_max_cert_list(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +# define SSL_set_max_cert_list(ssl,m) \ + SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) + +# define SSL_CTX_set_max_send_fragment(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL) +# define SSL_set_max_send_fragment(ssl,m) \ + SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL) +# define SSL_CTX_set_split_send_fragment(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL) +# define SSL_set_split_send_fragment(ssl,m) \ + SSL_ctrl(ssl,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL) +# define SSL_CTX_set_max_pipelines(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_PIPELINES,m,NULL) +# define SSL_set_max_pipelines(ssl,m) \ + SSL_ctrl(ssl,SSL_CTRL_SET_MAX_PIPELINES,m,NULL) +# define SSL_set_retry_verify(ssl) \ + (SSL_ctrl(ssl,SSL_CTRL_SET_RETRY_VERIFY,0,NULL) > 0) + +void SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len); +void SSL_set_default_read_buffer_len(SSL *s, size_t len); + +# ifndef OPENSSL_NO_DH +# ifndef OPENSSL_NO_DEPRECATED_3_0 +/* NB: the |keylength| is only applicable when is_export is true */ +OSSL_DEPRECATEDIN_3_0 +void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, + DH *(*dh) (SSL *ssl, int is_export, + int keylength)); +OSSL_DEPRECATEDIN_3_0 +void SSL_set_tmp_dh_callback(SSL *ssl, + DH *(*dh) (SSL *ssl, int is_export, + int keylength)); +# endif +# endif + +__owur const COMP_METHOD *SSL_get_current_compression(const SSL *s); +__owur const COMP_METHOD *SSL_get_current_expansion(const SSL *s); +__owur const char *SSL_COMP_get_name(const COMP_METHOD *comp); +__owur const char *SSL_COMP_get0_name(const SSL_COMP *comp); +__owur int SSL_COMP_get_id(const SSL_COMP *comp); +STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); +__owur STACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP) + *meths); +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define SSL_COMP_free_compression_methods() while(0) continue +# endif +__owur int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm); + +const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr); +int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c); +int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c); +int SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len, + int isv2format, STACK_OF(SSL_CIPHER) **sk, + STACK_OF(SSL_CIPHER) **scsvs); + +/* TLS extensions functions */ +__owur int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len); + +__owur int SSL_set_session_ticket_ext_cb(SSL *s, + tls_session_ticket_ext_cb_fn cb, + void *arg); + +/* Pre-shared secret session resumption functions */ +__owur int SSL_set_session_secret_cb(SSL *s, + tls_session_secret_cb_fn session_secret_cb, + void *arg); + +void SSL_CTX_set_not_resumable_session_callback(SSL_CTX *ctx, + int (*cb) (SSL *ssl, + int + is_forward_secure)); + +void SSL_set_not_resumable_session_callback(SSL *ssl, + int (*cb) (SSL *ssl, + int is_forward_secure)); + +void SSL_CTX_set_record_padding_callback(SSL_CTX *ctx, + size_t (*cb) (SSL *ssl, int type, + size_t len, void *arg)); +void SSL_CTX_set_record_padding_callback_arg(SSL_CTX *ctx, void *arg); +void *SSL_CTX_get_record_padding_callback_arg(const SSL_CTX *ctx); +int SSL_CTX_set_block_padding(SSL_CTX *ctx, size_t block_size); +int SSL_CTX_set_block_padding_ex(SSL_CTX *ctx, size_t app_block_size, + size_t hs_block_size); + +int SSL_set_record_padding_callback(SSL *ssl, + size_t (*cb) (SSL *ssl, int type, + size_t len, void *arg)); +void SSL_set_record_padding_callback_arg(SSL *ssl, void *arg); +void *SSL_get_record_padding_callback_arg(const SSL *ssl); +int SSL_set_block_padding(SSL *ssl, size_t block_size); +int SSL_set_block_padding_ex(SSL *ssl, size_t app_block_size, + size_t hs_block_size); +int SSL_set_num_tickets(SSL *s, size_t num_tickets); +size_t SSL_get_num_tickets(const SSL *s); +int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets); +size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx); + +/* QUIC support */ +int SSL_handle_events(SSL *s); +__owur int SSL_get_event_timeout(SSL *s, struct timeval *tv, int *is_infinite); +__owur int SSL_get_rpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *desc); +__owur int SSL_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *desc); +__owur int SSL_net_read_desired(SSL *s); +__owur int SSL_net_write_desired(SSL *s); +__owur int SSL_set_blocking_mode(SSL *s, int blocking); +__owur int SSL_get_blocking_mode(SSL *s); +__owur int SSL_set1_initial_peer_addr(SSL *s, const BIO_ADDR *peer_addr); +__owur SSL *SSL_get0_connection(SSL *s); +__owur int SSL_is_connection(SSL *s); + +__owur int SSL_is_listener(SSL *ssl); +__owur SSL *SSL_get0_listener(SSL *s); +#define SSL_LISTENER_FLAG_NO_VALIDATE (1UL << 1) +__owur SSL *SSL_new_listener(SSL_CTX *ctx, uint64_t flags); +__owur SSL *SSL_new_listener_from(SSL *ssl, uint64_t flags); +__owur SSL *SSL_new_from_listener(SSL *ssl, uint64_t flags); +#define SSL_ACCEPT_CONNECTION_NO_BLOCK (1UL << 0) +__owur SSL *SSL_accept_connection(SSL *ssl, uint64_t flags); +__owur size_t SSL_get_accept_connection_queue_len(SSL *ssl); +__owur int SSL_listen(SSL *ssl); + +__owur int SSL_is_domain(SSL *s); +__owur SSL *SSL_get0_domain(SSL *s); +__owur SSL *SSL_new_domain(SSL_CTX *ctx, uint64_t flags); + +#define SSL_DOMAIN_FLAG_SINGLE_THREAD (1U << 0) +#define SSL_DOMAIN_FLAG_MULTI_THREAD (1U << 1) +#define SSL_DOMAIN_FLAG_THREAD_ASSISTED (1U << 2) +#define SSL_DOMAIN_FLAG_BLOCKING (1U << 3) +#define SSL_DOMAIN_FLAG_LEGACY_BLOCKING (1U << 4) + +__owur int SSL_CTX_set_domain_flags(SSL_CTX *ctx, uint64_t domain_flags); +__owur int SSL_CTX_get_domain_flags(const SSL_CTX *ctx, uint64_t *domain_flags); +__owur int SSL_get_domain_flags(const SSL *ssl, uint64_t *domain_flags); + +#define SSL_STREAM_TYPE_NONE 0 +#define SSL_STREAM_TYPE_READ (1U << 0) +#define SSL_STREAM_TYPE_WRITE (1U << 1) +#define SSL_STREAM_TYPE_BIDI (SSL_STREAM_TYPE_READ | SSL_STREAM_TYPE_WRITE) +__owur int SSL_get_stream_type(SSL *s); + +__owur uint64_t SSL_get_stream_id(SSL *s); +__owur int SSL_is_stream_local(SSL *s); + +#define SSL_DEFAULT_STREAM_MODE_NONE 0 +#define SSL_DEFAULT_STREAM_MODE_AUTO_BIDI 1 +#define SSL_DEFAULT_STREAM_MODE_AUTO_UNI 2 +__owur int SSL_set_default_stream_mode(SSL *s, uint32_t mode); + +#define SSL_STREAM_FLAG_UNI (1U << 0) +#define SSL_STREAM_FLAG_NO_BLOCK (1U << 1) +#define SSL_STREAM_FLAG_ADVANCE (1U << 2) +__owur SSL *SSL_new_stream(SSL *s, uint64_t flags); + +#define SSL_INCOMING_STREAM_POLICY_AUTO 0 +#define SSL_INCOMING_STREAM_POLICY_ACCEPT 1 +#define SSL_INCOMING_STREAM_POLICY_REJECT 2 +__owur int SSL_set_incoming_stream_policy(SSL *s, int policy, uint64_t aec); + +#define SSL_ACCEPT_STREAM_NO_BLOCK (1U << 0) +__owur SSL *SSL_accept_stream(SSL *s, uint64_t flags); +__owur size_t SSL_get_accept_stream_queue_len(SSL *s); + +# ifndef OPENSSL_NO_QUIC +__owur int SSL_inject_net_dgram(SSL *s, const unsigned char *buf, + size_t buf_len, + const BIO_ADDR *peer, + const BIO_ADDR *local); +# endif + +typedef struct ssl_shutdown_ex_args_st { + uint64_t quic_error_code; + const char *quic_reason; +} SSL_SHUTDOWN_EX_ARGS; + +#define SSL_SHUTDOWN_FLAG_RAPID (1U << 0) +#define SSL_SHUTDOWN_FLAG_NO_STREAM_FLUSH (1U << 1) +#define SSL_SHUTDOWN_FLAG_NO_BLOCK (1U << 2) +#define SSL_SHUTDOWN_FLAG_WAIT_PEER (1U << 3) + +__owur int SSL_shutdown_ex(SSL *ssl, uint64_t flags, + const SSL_SHUTDOWN_EX_ARGS *args, + size_t args_len); + +__owur int SSL_stream_conclude(SSL *ssl, uint64_t flags); + +typedef struct ssl_stream_reset_args_st { + uint64_t quic_error_code; +} SSL_STREAM_RESET_ARGS; + +__owur int SSL_stream_reset(SSL *ssl, + const SSL_STREAM_RESET_ARGS *args, + size_t args_len); + +#define SSL_STREAM_STATE_NONE 0 +#define SSL_STREAM_STATE_OK 1 +#define SSL_STREAM_STATE_WRONG_DIR 2 +#define SSL_STREAM_STATE_FINISHED 3 +#define SSL_STREAM_STATE_RESET_LOCAL 4 +#define SSL_STREAM_STATE_RESET_REMOTE 5 +#define SSL_STREAM_STATE_CONN_CLOSED 6 +__owur int SSL_get_stream_read_state(SSL *ssl); +__owur int SSL_get_stream_write_state(SSL *ssl); + +__owur int SSL_get_stream_read_error_code(SSL *ssl, uint64_t *app_error_code); +__owur int SSL_get_stream_write_error_code(SSL *ssl, uint64_t *app_error_code); + +#define SSL_CONN_CLOSE_FLAG_LOCAL (1U << 0) +#define SSL_CONN_CLOSE_FLAG_TRANSPORT (1U << 1) + +typedef struct ssl_conn_close_info_st { + uint64_t error_code, frame_type; + const char *reason; + size_t reason_len; + uint32_t flags; +} SSL_CONN_CLOSE_INFO; + +__owur int SSL_get_conn_close_info(SSL *ssl, + SSL_CONN_CLOSE_INFO *info, + size_t info_len); + +# define SSL_VALUE_CLASS_GENERIC 0 +# define SSL_VALUE_CLASS_FEATURE_REQUEST 1 +# define SSL_VALUE_CLASS_FEATURE_PEER_REQUEST 2 +# define SSL_VALUE_CLASS_FEATURE_NEGOTIATED 3 + +# define SSL_VALUE_NONE 0 +# define SSL_VALUE_QUIC_STREAM_BIDI_LOCAL_AVAIL 1 +# define SSL_VALUE_QUIC_STREAM_BIDI_REMOTE_AVAIL 2 +# define SSL_VALUE_QUIC_STREAM_UNI_LOCAL_AVAIL 3 +# define SSL_VALUE_QUIC_STREAM_UNI_REMOTE_AVAIL 4 +# define SSL_VALUE_QUIC_IDLE_TIMEOUT 5 +# define SSL_VALUE_EVENT_HANDLING_MODE 6 +# define SSL_VALUE_STREAM_WRITE_BUF_SIZE 7 +# define SSL_VALUE_STREAM_WRITE_BUF_USED 8 +# define SSL_VALUE_STREAM_WRITE_BUF_AVAIL 9 + +# define SSL_VALUE_EVENT_HANDLING_MODE_INHERIT 0 +# define SSL_VALUE_EVENT_HANDLING_MODE_IMPLICIT 1 +# define SSL_VALUE_EVENT_HANDLING_MODE_EXPLICIT 2 + +int SSL_get_value_uint(SSL *s, uint32_t class_, uint32_t id, uint64_t *v); +int SSL_set_value_uint(SSL *s, uint32_t class_, uint32_t id, uint64_t v); + +# define SSL_get_generic_value_uint(ssl, id, v) \ + SSL_get_value_uint((ssl), SSL_VALUE_CLASS_GENERIC, (id), (v)) +# define SSL_set_generic_value_uint(ssl, id, v) \ + SSL_set_value_uint((ssl), SSL_VALUE_CLASS_GENERIC, (id), (v)) +# define SSL_get_feature_request_uint(ssl, id, v) \ + SSL_get_value_uint((ssl), SSL_VALUE_CLASS_FEATURE_REQUEST, (id), (v)) +# define SSL_set_feature_request_uint(ssl, id, v) \ + SSL_set_value_uint((ssl), SSL_VALUE_CLASS_FEATURE_REQUEST, (id), (v)) +# define SSL_get_feature_peer_request_uint(ssl, id, v) \ + SSL_get_value_uint((ssl), SSL_VALUE_CLASS_FEATURE_PEER_REQUEST, (id), (v)) +# define SSL_get_feature_negotiated_uint(ssl, id, v) \ + SSL_get_value_uint((ssl), SSL_VALUE_CLASS_FEATURE_NEGOTIATED, (id), (v)) + +# define SSL_get_quic_stream_bidi_local_avail(ssl, value) \ + SSL_get_generic_value_uint((ssl), SSL_VALUE_QUIC_STREAM_BIDI_LOCAL_AVAIL, \ + (value)) +# define SSL_get_quic_stream_bidi_remote_avail(ssl, value) \ + SSL_get_generic_value_uint((ssl), SSL_VALUE_QUIC_STREAM_BIDI_REMOTE_AVAIL, \ + (value)) +# define SSL_get_quic_stream_uni_local_avail(ssl, value) \ + SSL_get_generic_value_uint((ssl), SSL_VALUE_QUIC_STREAM_UNI_LOCAL_AVAIL, \ + (value)) +# define SSL_get_quic_stream_uni_remote_avail(ssl, value) \ + SSL_get_generic_value_uint((ssl), SSL_VALUE_QUIC_STREAM_UNI_REMOTE_AVAIL, \ + (value)) + +# define SSL_get_event_handling_mode(ssl, value) \ + SSL_get_generic_value_uint((ssl), SSL_VALUE_EVENT_HANDLING_MODE, \ + (value)) +# define SSL_set_event_handling_mode(ssl, value) \ + SSL_set_generic_value_uint((ssl), SSL_VALUE_EVENT_HANDLING_MODE, \ + (value)) + +# define SSL_get_stream_write_buf_size(ssl, value) \ + SSL_get_generic_value_uint((ssl), SSL_VALUE_STREAM_WRITE_BUF_SIZE, \ + (value)) +# define SSL_get_stream_write_buf_used(ssl, value) \ + SSL_get_generic_value_uint((ssl), SSL_VALUE_STREAM_WRITE_BUF_USED, \ + (value)) +# define SSL_get_stream_write_buf_avail(ssl, value) \ + SSL_get_generic_value_uint((ssl), SSL_VALUE_STREAM_WRITE_BUF_AVAIL, \ + (value)) + +# define SSL_POLL_EVENT_NONE 0 + +# define SSL_POLL_EVENT_F (1U << 0) /* F (Failure) */ +# define SSL_POLL_EVENT_EL (1U << 1) /* EL (Exception on Listener) */ +# define SSL_POLL_EVENT_EC (1U << 2) /* EC (Exception on Conn) */ +# define SSL_POLL_EVENT_ECD (1U << 3) /* ECD (Exception on Conn Drained) */ +# define SSL_POLL_EVENT_ER (1U << 4) /* ER (Exception on Read) */ +# define SSL_POLL_EVENT_EW (1U << 5) /* EW (Exception on Write) */ +# define SSL_POLL_EVENT_R (1U << 6) /* R (Readable) */ +# define SSL_POLL_EVENT_W (1U << 7) /* W (Writable) */ +# define SSL_POLL_EVENT_IC (1U << 8) /* IC (Incoming Connection) */ +# define SSL_POLL_EVENT_ISB (1U << 9) /* ISB (Incoming Stream: Bidi) */ +# define SSL_POLL_EVENT_ISU (1U << 10) /* ISU (Incoming Stream: Uni) */ +# define SSL_POLL_EVENT_OSB (1U << 11) /* OSB (Outgoing Stream: Bidi) */ +# define SSL_POLL_EVENT_OSU (1U << 12) /* OSU (Outgoing Stream: Uni) */ + +# define SSL_POLL_EVENT_RW (SSL_POLL_EVENT_R | SSL_POLL_EVENT_W) +# define SSL_POLL_EVENT_RE (SSL_POLL_EVENT_R | SSL_POLL_EVENT_ER) +# define SSL_POLL_EVENT_WE (SSL_POLL_EVENT_W | SSL_POLL_EVENT_EW) +# define SSL_POLL_EVENT_RWE (SSL_POLL_EVENT_RE | SSL_POLL_EVENT_WE) +# define SSL_POLL_EVENT_E (SSL_POLL_EVENT_EL | SSL_POLL_EVENT_EC \ + | SSL_POLL_EVENT_ER | SSL_POLL_EVENT_EW) +# define SSL_POLL_EVENT_IS (SSL_POLL_EVENT_ISB | SSL_POLL_EVENT_ISU) +# define SSL_POLL_EVENT_ISE (SSL_POLL_EVENT_IS | SSL_POLL_EVENT_EC) +# define SSL_POLL_EVENT_I (SSL_POLL_EVENT_IS | SSL_POLL_EVENT_IC) +# define SSL_POLL_EVENT_OS (SSL_POLL_EVENT_OSB | SSL_POLL_EVENT_OSU) +# define SSL_POLL_EVENT_OSE (SSL_POLL_EVENT_OS | SSL_POLL_EVENT_EC) + +typedef struct ssl_poll_item_st { + BIO_POLL_DESCRIPTOR desc; + uint64_t events, revents; +} SSL_POLL_ITEM; + +# define SSL_POLL_FLAG_NO_HANDLE_EVENTS (1U << 0) + +__owur int SSL_poll(SSL_POLL_ITEM *items, + size_t num_items, + size_t stride, + const struct timeval *timeout, + uint64_t flags, + size_t *result_count); + +static ossl_inline ossl_unused BIO_POLL_DESCRIPTOR +SSL_as_poll_descriptor(SSL *s) +{ + BIO_POLL_DESCRIPTOR d; + + d.type = BIO_POLL_DESCRIPTOR_TYPE_SSL; + d.value.ssl = s; + return d; +} + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define SSL_cache_hit(s) SSL_session_reused(s) +# endif + +__owur int SSL_session_reused(const SSL *s); +__owur int SSL_is_server(const SSL *s); + +__owur __owur SSL_CONF_CTX *SSL_CONF_CTX_new(void); +int SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx); +void SSL_CONF_CTX_free(SSL_CONF_CTX *cctx); +unsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags); +__owur unsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx, + unsigned int flags); +__owur int SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre); + +void SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl); +void SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx); + +__owur int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value); +__owur int SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv); +__owur int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd); + +void SSL_add_ssl_module(void); +int SSL_config(SSL *s, const char *name); +int SSL_CTX_config(SSL_CTX *ctx, const char *name); + +# ifndef OPENSSL_NO_SSL_TRACE +void SSL_trace(int write_p, int version, int content_type, + const void *buf, size_t len, SSL *ssl, void *arg); +# endif + +# ifndef OPENSSL_NO_SOCK +int DTLSv1_listen(SSL *s, BIO_ADDR *client); +# endif + +# ifndef OPENSSL_NO_CT + +/* + * A callback for verifying that the received SCTs are sufficient. + * Expected to return 1 if they are sufficient, otherwise 0. + * May return a negative integer if an error occurs. + * A connection should be aborted if the SCTs are deemed insufficient. + */ +typedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx, + const STACK_OF(SCT) *scts, void *arg); + +/* + * Sets a |callback| that is invoked upon receipt of ServerHelloDone to validate + * the received SCTs. + * If the callback returns a non-positive result, the connection is terminated. + * Call this function before beginning a handshake. + * If a NULL |callback| is provided, SCT validation is disabled. + * |arg| is arbitrary userdata that will be passed to the callback whenever it + * is invoked. Ownership of |arg| remains with the caller. + * + * NOTE: A side-effect of setting a CT callback is that an OCSP stapled response + * will be requested. + */ +int SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback, + void *arg); +int SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx, + ssl_ct_validation_cb callback, + void *arg); +#define SSL_disable_ct(s) \ + ((void) SSL_set_validation_callback((s), NULL, NULL)) +#define SSL_CTX_disable_ct(ctx) \ + ((void) SSL_CTX_set_validation_callback((ctx), NULL, NULL)) + +/* + * The validation type enumerates the available behaviours of the built-in SSL + * CT validation callback selected via SSL_enable_ct() and SSL_CTX_enable_ct(). + * The underlying callback is a static function in libssl. + */ +enum { + SSL_CT_VALIDATION_PERMISSIVE = 0, + SSL_CT_VALIDATION_STRICT +}; + +/* + * Enable CT by setting up a callback that implements one of the built-in + * validation variants. The SSL_CT_VALIDATION_PERMISSIVE variant always + * continues the handshake, the application can make appropriate decisions at + * handshake completion. The SSL_CT_VALIDATION_STRICT variant requires at + * least one valid SCT, or else handshake termination will be requested. The + * handshake may continue anyway if SSL_VERIFY_NONE is in effect. + */ +int SSL_enable_ct(SSL *s, int validation_mode); +int SSL_CTX_enable_ct(SSL_CTX *ctx, int validation_mode); + +/* + * Report whether a non-NULL callback is enabled. + */ +int SSL_ct_is_enabled(const SSL *s); +int SSL_CTX_ct_is_enabled(const SSL_CTX *ctx); + +/* Gets the SCTs received from a connection */ +const STACK_OF(SCT) *SSL_get0_peer_scts(SSL *s); + +/* + * Loads the CT log list from the default location. + * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store, + * the log information loaded from this file will be appended to the + * CTLOG_STORE. + * Returns 1 on success, 0 otherwise. + */ +int SSL_CTX_set_default_ctlog_list_file(SSL_CTX *ctx); + +/* + * Loads the CT log list from the specified file path. + * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store, + * the log information loaded from this file will be appended to the + * CTLOG_STORE. + * Returns 1 on success, 0 otherwise. + */ +int SSL_CTX_set_ctlog_list_file(SSL_CTX *ctx, const char *path); + +/* + * Sets the CT log list used by all SSL connections created from this SSL_CTX. + * Ownership of the CTLOG_STORE is transferred to the SSL_CTX. + */ +void SSL_CTX_set0_ctlog_store(SSL_CTX *ctx, CTLOG_STORE *logs); + +/* + * Gets the CT log list used by all SSL connections created from this SSL_CTX. + * This will be NULL unless one of the following functions has been called: + * - SSL_CTX_set_default_ctlog_list_file + * - SSL_CTX_set_ctlog_list_file + * - SSL_CTX_set_ctlog_store + */ +const CTLOG_STORE *SSL_CTX_get0_ctlog_store(const SSL_CTX *ctx); + +# endif /* OPENSSL_NO_CT */ + +/* What the "other" parameter contains in security callback */ +/* Mask for type */ +# define SSL_SECOP_OTHER_TYPE 0xffff0000 +# define SSL_SECOP_OTHER_NONE 0 +# define SSL_SECOP_OTHER_CIPHER (1 << 16) +# define SSL_SECOP_OTHER_CURVE (2 << 16) +# define SSL_SECOP_OTHER_DH (3 << 16) +# define SSL_SECOP_OTHER_PKEY (4 << 16) +# define SSL_SECOP_OTHER_SIGALG (5 << 16) +# define SSL_SECOP_OTHER_CERT (6 << 16) + +/* Indicated operation refers to peer key or certificate */ +# define SSL_SECOP_PEER 0x1000 + +/* Values for "op" parameter in security callback */ + +/* Called to filter ciphers */ +/* Ciphers client supports */ +# define SSL_SECOP_CIPHER_SUPPORTED (1 | SSL_SECOP_OTHER_CIPHER) +/* Cipher shared by client/server */ +# define SSL_SECOP_CIPHER_SHARED (2 | SSL_SECOP_OTHER_CIPHER) +/* Sanity check of cipher server selects */ +# define SSL_SECOP_CIPHER_CHECK (3 | SSL_SECOP_OTHER_CIPHER) +/* Curves supported by client */ +# define SSL_SECOP_CURVE_SUPPORTED (4 | SSL_SECOP_OTHER_CURVE) +/* Curves shared by client/server */ +# define SSL_SECOP_CURVE_SHARED (5 | SSL_SECOP_OTHER_CURVE) +/* Sanity check of curve server selects */ +# define SSL_SECOP_CURVE_CHECK (6 | SSL_SECOP_OTHER_CURVE) +/* Temporary DH key */ +# define SSL_SECOP_TMP_DH (7 | SSL_SECOP_OTHER_PKEY) +/* SSL/TLS version */ +# define SSL_SECOP_VERSION (9 | SSL_SECOP_OTHER_NONE) +/* Session tickets */ +# define SSL_SECOP_TICKET (10 | SSL_SECOP_OTHER_NONE) +/* Supported signature algorithms sent to peer */ +# define SSL_SECOP_SIGALG_SUPPORTED (11 | SSL_SECOP_OTHER_SIGALG) +/* Shared signature algorithm */ +# define SSL_SECOP_SIGALG_SHARED (12 | SSL_SECOP_OTHER_SIGALG) +/* Sanity check signature algorithm allowed */ +# define SSL_SECOP_SIGALG_CHECK (13 | SSL_SECOP_OTHER_SIGALG) +/* Used to get mask of supported public key signature algorithms */ +# define SSL_SECOP_SIGALG_MASK (14 | SSL_SECOP_OTHER_SIGALG) +/* Use to see if compression is allowed */ +# define SSL_SECOP_COMPRESSION (15 | SSL_SECOP_OTHER_NONE) +/* EE key in certificate */ +# define SSL_SECOP_EE_KEY (16 | SSL_SECOP_OTHER_CERT) +/* CA key in certificate */ +# define SSL_SECOP_CA_KEY (17 | SSL_SECOP_OTHER_CERT) +/* CA digest algorithm in certificate */ +# define SSL_SECOP_CA_MD (18 | SSL_SECOP_OTHER_CERT) +/* Peer EE key in certificate */ +# define SSL_SECOP_PEER_EE_KEY (SSL_SECOP_EE_KEY | SSL_SECOP_PEER) +/* Peer CA key in certificate */ +# define SSL_SECOP_PEER_CA_KEY (SSL_SECOP_CA_KEY | SSL_SECOP_PEER) +/* Peer CA digest algorithm in certificate */ +# define SSL_SECOP_PEER_CA_MD (SSL_SECOP_CA_MD | SSL_SECOP_PEER) + +void SSL_set_security_level(SSL *s, int level); +__owur int SSL_get_security_level(const SSL *s); +void SSL_set_security_callback(SSL *s, + int (*cb) (const SSL *s, const SSL_CTX *ctx, + int op, int bits, int nid, + void *other, void *ex)); +int (*SSL_get_security_callback(const SSL *s)) (const SSL *s, + const SSL_CTX *ctx, int op, + int bits, int nid, void *other, + void *ex); +void SSL_set0_security_ex_data(SSL *s, void *ex); +__owur void *SSL_get0_security_ex_data(const SSL *s); + +void SSL_CTX_set_security_level(SSL_CTX *ctx, int level); +__owur int SSL_CTX_get_security_level(const SSL_CTX *ctx); +void SSL_CTX_set_security_callback(SSL_CTX *ctx, + int (*cb) (const SSL *s, const SSL_CTX *ctx, + int op, int bits, int nid, + void *other, void *ex)); +int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx)) (const SSL *s, + const SSL_CTX *ctx, + int op, int bits, + int nid, + void *other, + void *ex); +void SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex); +__owur void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx); + +/* OPENSSL_INIT flag 0x010000 reserved for internal use */ +# define OPENSSL_INIT_NO_LOAD_SSL_STRINGS 0x00100000L +# define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L + +# define OPENSSL_INIT_SSL_DEFAULT \ + (OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS) + +int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); + +# ifndef OPENSSL_NO_UNIT_TEST +__owur const struct openssl_ssl_test_functions *SSL_test_functions(void); +# endif + +__owur int SSL_free_buffers(SSL *ssl); +__owur int SSL_alloc_buffers(SSL *ssl); + +/* Status codes passed to the decrypt session ticket callback. Some of these + * are for internal use only and are never passed to the callback. */ +typedef int SSL_TICKET_STATUS; + +/* Support for ticket appdata */ +/* fatal error, malloc failure */ +# define SSL_TICKET_FATAL_ERR_MALLOC 0 +/* fatal error, either from parsing or decrypting the ticket */ +# define SSL_TICKET_FATAL_ERR_OTHER 1 +/* No ticket present */ +# define SSL_TICKET_NONE 2 +/* Empty ticket present */ +# define SSL_TICKET_EMPTY 3 +/* the ticket couldn't be decrypted */ +# define SSL_TICKET_NO_DECRYPT 4 +/* a ticket was successfully decrypted */ +# define SSL_TICKET_SUCCESS 5 +/* same as above but the ticket needs to be renewed */ +# define SSL_TICKET_SUCCESS_RENEW 6 + +/* Return codes for the decrypt session ticket callback */ +typedef int SSL_TICKET_RETURN; + +/* An error occurred */ +#define SSL_TICKET_RETURN_ABORT 0 +/* Do not use the ticket, do not send a renewed ticket to the client */ +#define SSL_TICKET_RETURN_IGNORE 1 +/* Do not use the ticket, send a renewed ticket to the client */ +#define SSL_TICKET_RETURN_IGNORE_RENEW 2 +/* Use the ticket, do not send a renewed ticket to the client */ +#define SSL_TICKET_RETURN_USE 3 +/* Use the ticket, send a renewed ticket to the client */ +#define SSL_TICKET_RETURN_USE_RENEW 4 + +typedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg); +typedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss, + const unsigned char *keyname, + size_t keyname_length, + SSL_TICKET_STATUS status, + void *arg); +int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx, + SSL_CTX_generate_session_ticket_fn gen_cb, + SSL_CTX_decrypt_session_ticket_fn dec_cb, + void *arg); +int SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len); +int SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len); + +typedef unsigned int (*DTLS_timer_cb)(SSL *s, unsigned int timer_us); + +void DTLS_set_timer_cb(SSL *s, DTLS_timer_cb cb); + + +typedef int (*SSL_allow_early_data_cb_fn)(SSL *s, void *arg); +void SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx, + SSL_allow_early_data_cb_fn cb, + void *arg); +void SSL_set_allow_early_data_cb(SSL *s, + SSL_allow_early_data_cb_fn cb, + void *arg); + +/* store the default cipher strings inside the library */ +const char *OSSL_default_cipher_list(void); +const char *OSSL_default_ciphersuites(void); + +/* RFC8879 Certificate compression APIs */ + +int SSL_CTX_compress_certs(SSL_CTX *ctx, int alg); +int SSL_compress_certs(SSL *ssl, int alg); + +int SSL_CTX_set1_cert_comp_preference(SSL_CTX *ctx, int *algs, size_t len); +int SSL_set1_cert_comp_preference(SSL *ssl, int *algs, size_t len); + +int SSL_CTX_set1_compressed_cert(SSL_CTX *ctx, int algorithm, unsigned char *comp_data, + size_t comp_length, size_t orig_length); +int SSL_set1_compressed_cert(SSL *ssl, int algorithm, unsigned char *comp_data, + size_t comp_length, size_t orig_length); +size_t SSL_CTX_get1_compressed_cert(SSL_CTX *ctx, int alg, unsigned char **data, size_t *orig_len); +size_t SSL_get1_compressed_cert(SSL *ssl, int alg, unsigned char **data, size_t *orig_len); + +__owur int SSL_add_expected_rpk(SSL *s, EVP_PKEY *rpk); +__owur EVP_PKEY *SSL_get0_peer_rpk(const SSL *s); +__owur EVP_PKEY *SSL_SESSION_get0_peer_rpk(SSL_SESSION *s); +__owur int SSL_get_negotiated_client_cert_type(const SSL *s); +__owur int SSL_get_negotiated_server_cert_type(const SSL *s); + +__owur int SSL_set1_client_cert_type(SSL *s, const unsigned char *val, size_t len); +__owur int SSL_set1_server_cert_type(SSL *s, const unsigned char *val, size_t len); +__owur int SSL_CTX_set1_client_cert_type(SSL_CTX *ctx, const unsigned char *val, size_t len); +__owur int SSL_CTX_set1_server_cert_type(SSL_CTX *ctx, const unsigned char *val, size_t len); +__owur int SSL_get0_client_cert_type(const SSL *s, unsigned char **t, size_t *len); +__owur int SSL_get0_server_cert_type(const SSL *s, unsigned char **t, size_t *len); +__owur int SSL_CTX_get0_client_cert_type(const SSL_CTX *ctx, unsigned char **t, size_t *len); +__owur int SSL_CTX_get0_server_cert_type(const SSL_CTX *s, unsigned char **t, size_t *len); + +/* + * Protection level. For <= TLSv1.2 only "NONE" and "APPLICATION" are used. + */ +# define OSSL_RECORD_PROTECTION_LEVEL_NONE 0 +# define OSSL_RECORD_PROTECTION_LEVEL_EARLY 1 +# define OSSL_RECORD_PROTECTION_LEVEL_HANDSHAKE 2 +# define OSSL_RECORD_PROTECTION_LEVEL_APPLICATION 3 + +int SSL_set_quic_tls_cbs(SSL *s, const OSSL_DISPATCH *qtdis, void *arg); +int SSL_set_quic_tls_transport_params(SSL *s, + const unsigned char *params, + size_t params_len); + +int SSL_set_quic_tls_early_data_enabled(SSL *s, int enabled); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ssl2.h b/illumos-x86_64/usr/include/openssl-3/ssl2.h new file mode 100644 index 00000000..428ead05 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ssl2.h @@ -0,0 +1,30 @@ +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_SSL2_H +# define OPENSSL_SSL2_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_SSL2_H +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +# define SSL2_VERSION 0x0002 + +# define SSL2_MT_CLIENT_HELLO 1 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ssl3.h b/illumos-x86_64/usr/include/openssl-3/ssl3.h new file mode 100644 index 00000000..b8dada1b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ssl3.h @@ -0,0 +1,358 @@ +/* + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_SSL3_H +# define OPENSSL_SSL3_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_SSL3_H +# endif + +# include +# include +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Signalling cipher suite value from RFC 5746 + * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV) + */ +# define SSL3_CK_SCSV 0x030000FF + +/* + * Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00 + * (TLS_FALLBACK_SCSV) + */ +# define SSL3_CK_FALLBACK_SCSV 0x03005600 + +# define SSL3_CK_RSA_NULL_MD5 0x03000001 +# define SSL3_CK_RSA_NULL_SHA 0x03000002 +# define SSL3_CK_RSA_RC4_40_MD5 0x03000003 +# define SSL3_CK_RSA_RC4_128_MD5 0x03000004 +# define SSL3_CK_RSA_RC4_128_SHA 0x03000005 +# define SSL3_CK_RSA_RC2_40_MD5 0x03000006 +# define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 +# define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 +# define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 +# define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A + +# define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B +# define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C +# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D +# define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E +# define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F +# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 + +# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA 0x03000011 +# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA SSL3_CK_DHE_DSS_DES_40_CBC_SHA +# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA 0x03000012 +# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA SSL3_CK_DHE_DSS_DES_64_CBC_SHA +# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA 0x03000013 +# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA SSL3_CK_DHE_DSS_DES_192_CBC3_SHA +# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA 0x03000014 +# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA SSL3_CK_DHE_RSA_DES_40_CBC_SHA +# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA 0x03000015 +# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA SSL3_CK_DHE_RSA_DES_64_CBC_SHA +# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA 0x03000016 +# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA SSL3_CK_DHE_RSA_DES_192_CBC3_SHA + +# define SSL3_CK_ADH_RC4_40_MD5 0x03000017 +# define SSL3_CK_ADH_RC4_128_MD5 0x03000018 +# define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 +# define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A +# define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B + +/* a bundle of RFC standard cipher names, generated from ssl3_ciphers[] */ +# define SSL3_RFC_RSA_NULL_MD5 "TLS_RSA_WITH_NULL_MD5" +# define SSL3_RFC_RSA_NULL_SHA "TLS_RSA_WITH_NULL_SHA" +# define SSL3_RFC_RSA_DES_192_CBC3_SHA "TLS_RSA_WITH_3DES_EDE_CBC_SHA" +# define SSL3_RFC_DHE_DSS_DES_192_CBC3_SHA "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA" +# define SSL3_RFC_DHE_RSA_DES_192_CBC3_SHA "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA" +# define SSL3_RFC_ADH_DES_192_CBC_SHA "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA" +# define SSL3_RFC_RSA_IDEA_128_SHA "TLS_RSA_WITH_IDEA_CBC_SHA" +# define SSL3_RFC_RSA_RC4_128_MD5 "TLS_RSA_WITH_RC4_128_MD5" +# define SSL3_RFC_RSA_RC4_128_SHA "TLS_RSA_WITH_RC4_128_SHA" +# define SSL3_RFC_ADH_RC4_128_MD5 "TLS_DH_anon_WITH_RC4_128_MD5" + +# define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" +# define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" +# define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" +# define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" +# define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" +# define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" +# define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" +# define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" +# define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" +# define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" + +# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" +# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" +# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" +# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" +# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" +# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" + +# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA "EXP-DHE-DSS-DES-CBC-SHA" +# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA "DHE-DSS-DES-CBC-SHA" +# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA "DHE-DSS-DES-CBC3-SHA" +# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA "EXP-DHE-RSA-DES-CBC-SHA" +# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA "DHE-RSA-DES-CBC-SHA" +# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA "DHE-RSA-DES-CBC3-SHA" + +/* + * This next block of six "EDH" labels is for backward compatibility with + * older versions of OpenSSL. New code should use the six "DHE" labels above + * instead: + */ +# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" +# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" +# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" +# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" +# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" +# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" + +# define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" +# define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" +# define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" +# define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" +# define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" + +# define SSL3_SSL_SESSION_ID_LENGTH 32 +# define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 + +# define SSL3_MASTER_SECRET_SIZE 48 +# define SSL3_RANDOM_SIZE 32 +# define SSL3_SESSION_ID_SIZE 32 +# define SSL3_RT_HEADER_LENGTH 5 + +# define SSL3_HM_HEADER_LENGTH 4 + +# ifndef SSL3_ALIGN_PAYLOAD + /* + * Some will argue that this increases memory footprint, but it's not + * actually true. Point is that malloc has to return at least 64-bit aligned + * pointers, meaning that allocating 5 bytes wastes 3 bytes in either case. + * Suggested pre-gaping simply moves these wasted bytes from the end of + * allocated region to its front, but makes data payload aligned, which + * improves performance:-) + */ +# define SSL3_ALIGN_PAYLOAD 8 +# else +# if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0 +# error "insane SSL3_ALIGN_PAYLOAD" +# undef SSL3_ALIGN_PAYLOAD +# endif +# endif + +/* + * This is the maximum MAC (digest) size used by the SSL library. Currently + * maximum of 20 is used by SHA1, but we reserve for future extension for + * 512-bit hashes. + */ + +# define SSL3_RT_MAX_MD_SIZE 64 + +/* + * Maximum block size used in all ciphersuites. Currently 16 for AES. + */ + +# define SSL_RT_MAX_CIPHER_BLOCK_SIZE 16 + +# define SSL3_RT_MAX_EXTRA (16384) + +/* Maximum plaintext length: defined by SSL/TLS standards */ +# define SSL3_RT_MAX_PLAIN_LENGTH 16384 +/* Maximum compression overhead: defined by SSL/TLS standards */ +# define SSL3_RT_MAX_COMPRESSED_OVERHEAD 1024 + +/* + * The standards give a maximum encryption overhead of 1024 bytes. In + * practice the value is lower than this. The overhead is the maximum number + * of padding bytes (256) plus the mac size. + */ +# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD (256 + SSL3_RT_MAX_MD_SIZE) +# define SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD 256 + +/* + * OpenSSL currently only uses a padding length of at most one block so the + * send overhead is smaller. + */ + +# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \ + (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE) + +/* If compression isn't used don't include the compression overhead */ + +# ifdef OPENSSL_NO_COMP +# define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH +# else +# define SSL3_RT_MAX_COMPRESSED_LENGTH \ + (SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD) +# endif +# define SSL3_RT_MAX_ENCRYPTED_LENGTH \ + (SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH) +# define SSL3_RT_MAX_TLS13_ENCRYPTED_LENGTH \ + (SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD) +# define SSL3_RT_MAX_PACKET_SIZE \ + (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) + +# define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" +# define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" + +/* SSL3_VERSION is defined in prov_ssl.h */ +# define SSL3_VERSION_MAJOR 0x03 +# define SSL3_VERSION_MINOR 0x00 + +# define SSL3_RT_CHANGE_CIPHER_SPEC 20 +# define SSL3_RT_ALERT 21 +# define SSL3_RT_HANDSHAKE 22 +# define SSL3_RT_APPLICATION_DATA 23 + +/* Pseudo content types to indicate additional parameters */ +# define TLS1_RT_CRYPTO 0x1000 +# define TLS1_RT_CRYPTO_PREMASTER (TLS1_RT_CRYPTO | 0x1) +# define TLS1_RT_CRYPTO_CLIENT_RANDOM (TLS1_RT_CRYPTO | 0x2) +# define TLS1_RT_CRYPTO_SERVER_RANDOM (TLS1_RT_CRYPTO | 0x3) +# define TLS1_RT_CRYPTO_MASTER (TLS1_RT_CRYPTO | 0x4) + +# define TLS1_RT_CRYPTO_READ 0x0000 +# define TLS1_RT_CRYPTO_WRITE 0x0100 +# define TLS1_RT_CRYPTO_MAC (TLS1_RT_CRYPTO | 0x5) +# define TLS1_RT_CRYPTO_KEY (TLS1_RT_CRYPTO | 0x6) +# define TLS1_RT_CRYPTO_IV (TLS1_RT_CRYPTO | 0x7) +# define TLS1_RT_CRYPTO_FIXED_IV (TLS1_RT_CRYPTO | 0x8) + +/* Pseudo content types for SSL/TLS header info */ +# define SSL3_RT_HEADER 0x100 +# define SSL3_RT_INNER_CONTENT_TYPE 0x101 + +/* Pseudo content types for QUIC */ +# define SSL3_RT_QUIC_DATAGRAM 0x200 +# define SSL3_RT_QUIC_PACKET 0x201 +# define SSL3_RT_QUIC_FRAME_FULL 0x202 +# define SSL3_RT_QUIC_FRAME_HEADER 0x203 +# define SSL3_RT_QUIC_FRAME_PADDING 0x204 + +# define SSL3_AL_WARNING 1 +# define SSL3_AL_FATAL 2 + +# define SSL3_AD_CLOSE_NOTIFY 0 +# define SSL3_AD_UNEXPECTED_MESSAGE 10/* fatal */ +# define SSL3_AD_BAD_RECORD_MAC 20/* fatal */ +# define SSL3_AD_DECOMPRESSION_FAILURE 30/* fatal */ +# define SSL3_AD_HANDSHAKE_FAILURE 40/* fatal */ +# define SSL3_AD_NO_CERTIFICATE 41 +# define SSL3_AD_BAD_CERTIFICATE 42 +# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 +# define SSL3_AD_CERTIFICATE_REVOKED 44 +# define SSL3_AD_CERTIFICATE_EXPIRED 45 +# define SSL3_AD_CERTIFICATE_UNKNOWN 46 +# define SSL3_AD_ILLEGAL_PARAMETER 47/* fatal */ + +# define TLS1_HB_REQUEST 1 +# define TLS1_HB_RESPONSE 2 + + +# define SSL3_CT_RSA_SIGN 1 +# define SSL3_CT_DSS_SIGN 2 +# define SSL3_CT_RSA_FIXED_DH 3 +# define SSL3_CT_DSS_FIXED_DH 4 +# define SSL3_CT_RSA_EPHEMERAL_DH 5 +# define SSL3_CT_DSS_EPHEMERAL_DH 6 +# define SSL3_CT_FORTEZZA_DMS 20 +/* + * SSL3_CT_NUMBER is used to size arrays and it must be large enough to + * contain all of the cert types defined for *either* SSLv3 and TLSv1. + */ +# define SSL3_CT_NUMBER 12 + +# if defined(TLS_CT_NUMBER) +# if TLS_CT_NUMBER != SSL3_CT_NUMBER +# error "SSL/TLS CT_NUMBER values do not match" +# endif +# endif + +/* No longer used as of OpenSSL 1.1.1 */ +# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 + +/* Removed from OpenSSL 1.1.0 */ +# define TLS1_FLAGS_TLS_PADDING_BUG 0x0 + +# define TLS1_FLAGS_SKIP_CERT_VERIFY 0x0010 + +/* Set if we encrypt then mac instead of usual mac then encrypt */ +# define TLS1_FLAGS_ENCRYPT_THEN_MAC_READ 0x0100 +# define TLS1_FLAGS_ENCRYPT_THEN_MAC TLS1_FLAGS_ENCRYPT_THEN_MAC_READ + +/* Set if extended master secret extension received from peer */ +# define TLS1_FLAGS_RECEIVED_EXTMS 0x0200 + +# define TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE 0x0400 + +# define TLS1_FLAGS_STATELESS 0x0800 + +/* Set if extended master secret extension required on renegotiation */ +# define TLS1_FLAGS_REQUIRED_EXTMS 0x1000 + +/* 0x2000 is reserved for TLS1_FLAGS_QUIC (internal) */ +/* 0x4000 is reserved for TLS1_FLAGS_QUIC_INTERNAL (internal) */ + +# define SSL3_MT_HELLO_REQUEST 0 +# define SSL3_MT_CLIENT_HELLO 1 +# define SSL3_MT_SERVER_HELLO 2 +# define SSL3_MT_NEWSESSION_TICKET 4 +# define SSL3_MT_END_OF_EARLY_DATA 5 +# define SSL3_MT_ENCRYPTED_EXTENSIONS 8 +# define SSL3_MT_CERTIFICATE 11 +# define SSL3_MT_SERVER_KEY_EXCHANGE 12 +# define SSL3_MT_CERTIFICATE_REQUEST 13 +# define SSL3_MT_SERVER_DONE 14 +# define SSL3_MT_CERTIFICATE_VERIFY 15 +# define SSL3_MT_CLIENT_KEY_EXCHANGE 16 +# define SSL3_MT_FINISHED 20 +# define SSL3_MT_CERTIFICATE_URL 21 +# define SSL3_MT_CERTIFICATE_STATUS 22 +# define SSL3_MT_SUPPLEMENTAL_DATA 23 +# define SSL3_MT_KEY_UPDATE 24 +# define SSL3_MT_COMPRESSED_CERTIFICATE 25 +# ifndef OPENSSL_NO_NEXTPROTONEG +# define SSL3_MT_NEXT_PROTO 67 +# endif +# define SSL3_MT_MESSAGE_HASH 254 +# define DTLS1_MT_HELLO_VERIFY_REQUEST 3 + +/* Dummy message type for handling CCS like a normal handshake message */ +# define SSL3_MT_CHANGE_CIPHER_SPEC 0x0101 + +# define SSL3_MT_CCS 1 + +/* These are used when changing over to a new cipher */ +# define SSL3_CC_READ 0x001 +# define SSL3_CC_WRITE 0x002 +# define SSL3_CC_CLIENT 0x010 +# define SSL3_CC_SERVER 0x020 +# define SSL3_CC_EARLY 0x040 +# define SSL3_CC_HANDSHAKE 0x080 +# define SSL3_CC_APPLICATION 0x100 +# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) +# define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) +# define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) +# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/sslerr.h b/illumos-x86_64/usr/include/openssl-3/sslerr.h new file mode 100644 index 00000000..53e0decb --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/sslerr.h @@ -0,0 +1,382 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_SSLERR_H +# define OPENSSL_SSLERR_H +# pragma once + +# include +# include +# include + + + +/* + * SSL reason codes. + */ +# define SSL_R_APPLICATION_DATA_AFTER_CLOSE_NOTIFY 291 +# define SSL_R_APP_DATA_IN_HANDSHAKE 100 +# define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 +# define SSL_R_AT_LEAST_TLS_1_2_NEEDED_IN_SUITEB_MODE 158 +# define SSL_R_BAD_CERTIFICATE 348 +# define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 +# define SSL_R_BAD_CIPHER 186 +# define SSL_R_BAD_COMPRESSION_ALGORITHM 326 +# define SSL_R_BAD_DATA 390 +# define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 +# define SSL_R_BAD_DECOMPRESSION 107 +# define SSL_R_BAD_DH_VALUE 102 +# define SSL_R_BAD_DIGEST_LENGTH 111 +# define SSL_R_BAD_EARLY_DATA 233 +# define SSL_R_BAD_ECC_CERT 304 +# define SSL_R_BAD_ECPOINT 306 +# define SSL_R_BAD_EXTENSION 110 +# define SSL_R_BAD_HANDSHAKE_LENGTH 332 +# define SSL_R_BAD_HANDSHAKE_STATE 236 +# define SSL_R_BAD_HELLO_REQUEST 105 +# define SSL_R_BAD_HRR_VERSION 263 +# define SSL_R_BAD_KEY_SHARE 108 +# define SSL_R_BAD_KEY_UPDATE 122 +# define SSL_R_BAD_LEGACY_VERSION 292 +# define SSL_R_BAD_LENGTH 271 +# define SSL_R_BAD_PACKET 240 +# define SSL_R_BAD_PACKET_LENGTH 115 +# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 +# define SSL_R_BAD_PSK 219 +# define SSL_R_BAD_PSK_IDENTITY 114 +# define SSL_R_BAD_RECORD_TYPE 443 +# define SSL_R_BAD_RSA_ENCRYPT 119 +# define SSL_R_BAD_SIGNATURE 123 +# define SSL_R_BAD_SRP_A_LENGTH 347 +# define SSL_R_BAD_SRP_PARAMETERS 371 +# define SSL_R_BAD_SRTP_MKI_VALUE 352 +# define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST 353 +# define SSL_R_BAD_SSL_FILETYPE 124 +# define SSL_R_BAD_VALUE 384 +# define SSL_R_BAD_WRITE_RETRY 127 +# define SSL_R_BINDER_DOES_NOT_VERIFY 253 +# define SSL_R_BIO_NOT_SET 128 +# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 +# define SSL_R_BN_LIB 130 +# define SSL_R_CALLBACK_FAILED 234 +# define SSL_R_CANNOT_CHANGE_CIPHER 109 +# define SSL_R_CANNOT_GET_GROUP_NAME 299 +# define SSL_R_CA_DN_LENGTH_MISMATCH 131 +# define SSL_R_CA_KEY_TOO_SMALL 397 +# define SSL_R_CA_MD_TOO_WEAK 398 +# define SSL_R_CCS_RECEIVED_EARLY 133 +# define SSL_R_CERTIFICATE_VERIFY_FAILED 134 +# define SSL_R_CERT_CB_ERROR 377 +# define SSL_R_CERT_LENGTH_MISMATCH 135 +# define SSL_R_CIPHERSUITE_DIGEST_HAS_CHANGED 218 +# define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 +# define SSL_R_CLIENTHELLO_TLSEXT 226 +# define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 +# define SSL_R_COMPRESSION_DISABLED 343 +# define SSL_R_COMPRESSION_FAILURE 141 +# define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307 +# define SSL_R_COMPRESSION_LIBRARY_ERROR 142 +# define SSL_R_CONNECTION_TYPE_NOT_SET 144 +# define SSL_R_CONN_USE_ONLY 356 +# define SSL_R_CONTEXT_NOT_DANE_ENABLED 167 +# define SSL_R_COOKIE_GEN_CALLBACK_FAILURE 400 +# define SSL_R_COOKIE_MISMATCH 308 +# define SSL_R_COPY_PARAMETERS_FAILED 296 +# define SSL_R_CUSTOM_EXT_HANDLER_ALREADY_INSTALLED 206 +# define SSL_R_DANE_ALREADY_ENABLED 172 +# define SSL_R_DANE_CANNOT_OVERRIDE_MTYPE_FULL 173 +# define SSL_R_DANE_NOT_ENABLED 175 +# define SSL_R_DANE_TLSA_BAD_CERTIFICATE 180 +# define SSL_R_DANE_TLSA_BAD_CERTIFICATE_USAGE 184 +# define SSL_R_DANE_TLSA_BAD_DATA_LENGTH 189 +# define SSL_R_DANE_TLSA_BAD_DIGEST_LENGTH 192 +# define SSL_R_DANE_TLSA_BAD_MATCHING_TYPE 200 +# define SSL_R_DANE_TLSA_BAD_PUBLIC_KEY 201 +# define SSL_R_DANE_TLSA_BAD_SELECTOR 202 +# define SSL_R_DANE_TLSA_NULL_DATA 203 +# define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 +# define SSL_R_DATA_LENGTH_TOO_LONG 146 +# define SSL_R_DECRYPTION_FAILED 147 +# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281 +# define SSL_R_DH_KEY_TOO_SMALL 394 +# define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 +# define SSL_R_DIGEST_CHECK_FAILED 149 +# define SSL_R_DOMAIN_USE_ONLY 422 +# define SSL_R_DTLS_MESSAGE_TOO_BIG 334 +# define SSL_R_DUPLICATE_COMPRESSION_ID 309 +# define SSL_R_ECC_CERT_NOT_FOR_SIGNING 318 +# define SSL_R_ECDH_REQUIRED_FOR_SUITEB_MODE 374 +# define SSL_R_EE_KEY_TOO_SMALL 399 +# define SSL_R_EMPTY_RAW_PUBLIC_KEY 349 +# define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST 354 +# define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 +# define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 +# define SSL_R_ERROR_IN_SYSTEM_DEFAULT_CONFIG 419 +# define SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN 204 +# define SSL_R_EXCEEDS_MAX_FRAGMENT_SIZE 194 +# define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 +# define SSL_R_EXTENSION_NOT_RECEIVED 279 +# define SSL_R_EXTRA_DATA_IN_MESSAGE 153 +# define SSL_R_EXT_LENGTH_MISMATCH 163 +# define SSL_R_FAILED_TO_GET_PARAMETER 316 +# define SSL_R_FAILED_TO_INIT_ASYNC 405 +# define SSL_R_FEATURE_NEGOTIATION_NOT_COMPLETE 417 +# define SSL_R_FEATURE_NOT_RENEGOTIABLE 413 +# define SSL_R_FRAGMENTED_CLIENT_HELLO 401 +# define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 +# define SSL_R_HTTPS_PROXY_REQUEST 155 +# define SSL_R_HTTP_REQUEST 156 +# define SSL_R_ILLEGAL_POINT_COMPRESSION 162 +# define SSL_R_ILLEGAL_SUITEB_DIGEST 380 +# define SSL_R_INAPPROPRIATE_FALLBACK 373 +# define SSL_R_INCONSISTENT_COMPRESSION 340 +# define SSL_R_INCONSISTENT_EARLY_DATA_ALPN 222 +# define SSL_R_INCONSISTENT_EARLY_DATA_SNI 231 +# define SSL_R_INCONSISTENT_EXTMS 104 +# define SSL_R_INSUFFICIENT_SECURITY 241 +# define SSL_R_INVALID_ALERT 205 +# define SSL_R_INVALID_CCS_MESSAGE 260 +# define SSL_R_INVALID_CERTIFICATE_OR_ALG 238 +# define SSL_R_INVALID_COMMAND 280 +# define SSL_R_INVALID_COMPRESSION_ALGORITHM 341 +# define SSL_R_INVALID_CONFIG 283 +# define SSL_R_INVALID_CONFIGURATION_NAME 113 +# define SSL_R_INVALID_CONTEXT 282 +# define SSL_R_INVALID_CT_VALIDATION_TYPE 212 +# define SSL_R_INVALID_KEY_UPDATE_TYPE 120 +# define SSL_R_INVALID_MAX_EARLY_DATA 174 +# define SSL_R_INVALID_NULL_CMD_NAME 385 +# define SSL_R_INVALID_RAW_PUBLIC_KEY 350 +# define SSL_R_INVALID_RECORD 317 +# define SSL_R_INVALID_SEQUENCE_NUMBER 402 +# define SSL_R_INVALID_SERVERINFO_DATA 388 +# define SSL_R_INVALID_SESSION_ID 999 +# define SSL_R_INVALID_SRP_USERNAME 357 +# define SSL_R_INVALID_STATUS_RESPONSE 328 +# define SSL_R_INVALID_TICKET_KEYS_LENGTH 325 +# define SSL_R_LEGACY_SIGALG_DISALLOWED_OR_UNSUPPORTED 333 +# define SSL_R_LENGTH_MISMATCH 159 +# define SSL_R_LENGTH_TOO_LONG 404 +# define SSL_R_LENGTH_TOO_SHORT 160 +# define SSL_R_LIBRARY_BUG 274 +# define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 +# define SSL_R_LISTENER_USE_ONLY 421 +# define SSL_R_MAXIMUM_ENCRYPTED_PKTS_REACHED 395 +# define SSL_R_MISSING_DSA_SIGNING_CERT 165 +# define SSL_R_MISSING_ECDSA_SIGNING_CERT 381 +# define SSL_R_MISSING_FATAL 256 +# define SSL_R_MISSING_PARAMETERS 290 +# define SSL_R_MISSING_PSK_KEX_MODES_EXTENSION 310 +# define SSL_R_MISSING_QUIC_TLS_FUNCTIONS 423 +# define SSL_R_MISSING_RSA_CERTIFICATE 168 +# define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 +# define SSL_R_MISSING_RSA_SIGNING_CERT 170 +# define SSL_R_MISSING_SIGALGS_EXTENSION 112 +# define SSL_R_MISSING_SIGNING_CERT 221 +# define SSL_R_MISSING_SRP_PARAM 358 +# define SSL_R_MISSING_SUPPORTED_GROUPS_EXTENSION 209 +# define SSL_R_MISSING_SUPPORTED_VERSIONS_EXTENSION 420 +# define SSL_R_MISSING_TMP_DH_KEY 171 +# define SSL_R_MISSING_TMP_ECDH_KEY 311 +# define SSL_R_MIXED_HANDSHAKE_AND_NON_HANDSHAKE_DATA 293 +# define SSL_R_NOT_ON_RECORD_BOUNDARY 182 +# define SSL_R_NOT_REPLACING_CERTIFICATE 289 +# define SSL_R_NOT_SERVER 284 +# define SSL_R_NO_APPLICATION_PROTOCOL 235 +# define SSL_R_NO_CERTIFICATES_RETURNED 176 +# define SSL_R_NO_CERTIFICATE_ASSIGNED 177 +# define SSL_R_NO_CERTIFICATE_SET 179 +# define SSL_R_NO_CHANGE_FOLLOWING_HRR 214 +# define SSL_R_NO_CIPHERS_AVAILABLE 181 +# define SSL_R_NO_CIPHERS_SPECIFIED 183 +# define SSL_R_NO_CIPHER_MATCH 185 +# define SSL_R_NO_CLIENT_CERT_METHOD 331 +# define SSL_R_NO_COMPRESSION_SPECIFIED 187 +# define SSL_R_NO_COOKIE_CALLBACK_SET 287 +# define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER 330 +# define SSL_R_NO_METHOD_SPECIFIED 188 +# define SSL_R_NO_PEM_EXTENSIONS 389 +# define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 +# define SSL_R_NO_PROTOCOLS_AVAILABLE 191 +# define SSL_R_NO_RENEGOTIATION 339 +# define SSL_R_NO_REQUIRED_DIGEST 324 +# define SSL_R_NO_SHARED_CIPHER 193 +# define SSL_R_NO_SHARED_GROUPS 410 +# define SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS 376 +# define SSL_R_NO_SRTP_PROFILES 359 +# define SSL_R_NO_STREAM 355 +# define SSL_R_NO_SUITABLE_DIGEST_ALGORITHM 297 +# define SSL_R_NO_SUITABLE_GROUPS 295 +# define SSL_R_NO_SUITABLE_KEY_SHARE 101 +# define SSL_R_NO_SUITABLE_RECORD_LAYER 322 +# define SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM 118 +# define SSL_R_NO_VALID_SCTS 216 +# define SSL_R_NO_VERIFY_COOKIE_CALLBACK 403 +# define SSL_R_NULL_SSL_CTX 195 +# define SSL_R_NULL_SSL_METHOD_PASSED 196 +# define SSL_R_OCSP_CALLBACK_FAILURE 305 +# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 +# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344 +# define SSL_R_OVERFLOW_ERROR 237 +# define SSL_R_PACKET_LENGTH_TOO_LONG 198 +# define SSL_R_PARSE_TLSEXT 227 +# define SSL_R_PATH_TOO_LONG 270 +# define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 +# define SSL_R_PEM_NAME_BAD_PREFIX 391 +# define SSL_R_PEM_NAME_TOO_SHORT 392 +# define SSL_R_PIPELINE_FAILURE 406 +# define SSL_R_POLL_REQUEST_NOT_SUPPORTED 418 +# define SSL_R_POST_HANDSHAKE_AUTH_ENCODING_ERR 278 +# define SSL_R_PRIVATE_KEY_MISMATCH 288 +# define SSL_R_PROTOCOL_IS_SHUTDOWN 207 +# define SSL_R_PSK_IDENTITY_NOT_FOUND 223 +# define SSL_R_PSK_NO_CLIENT_CB 224 +# define SSL_R_PSK_NO_SERVER_CB 225 +# define SSL_R_QUIC_HANDSHAKE_LAYER_ERROR 393 +# define SSL_R_QUIC_NETWORK_ERROR 387 +# define SSL_R_QUIC_PROTOCOL_ERROR 382 +# define SSL_R_READ_BIO_NOT_SET 211 +# define SSL_R_READ_TIMEOUT_EXPIRED 312 +# define SSL_R_RECORDS_NOT_RELEASED 321 +# define SSL_R_RECORD_LAYER_FAILURE 313 +# define SSL_R_RECORD_LENGTH_MISMATCH 213 +# define SSL_R_RECORD_TOO_SMALL 298 +# define SSL_R_REMOTE_PEER_ADDRESS_NOT_SET 346 +# define SSL_R_RENEGOTIATE_EXT_TOO_LONG 335 +# define SSL_R_RENEGOTIATION_ENCODING_ERR 336 +# define SSL_R_RENEGOTIATION_MISMATCH 337 +# define SSL_R_REQUEST_PENDING 285 +# define SSL_R_REQUEST_SENT 286 +# define SSL_R_REQUIRED_CIPHER_MISSING 215 +# define SSL_R_REQUIRED_COMPRESSION_ALGORITHM_MISSING 342 +# define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING 345 +# define SSL_R_SCT_VERIFICATION_FAILED 208 +# define SSL_R_SEQUENCE_CTR_WRAPPED 327 +# define SSL_R_SERVERHELLO_TLSEXT 275 +# define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 +# define SSL_R_SHUTDOWN_WHILE_IN_INIT 407 +# define SSL_R_SIGNATURE_ALGORITHMS_ERROR 360 +# define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 +# define SSL_R_SRP_A_CALC 361 +# define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES 362 +# define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG 363 +# define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE 364 +# define SSL_R_SSL3_EXT_INVALID_MAX_FRAGMENT_LENGTH 232 +# define SSL_R_SSL3_EXT_INVALID_SERVERNAME 319 +# define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE 320 +# define SSL_R_SSL3_SESSION_ID_TOO_LONG 300 +# define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 +# define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 +# define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 +# define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 +# define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 +# define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 +# define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 +# define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 +# define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 +# define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 +# define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 +# define SSL_R_SSL_COMMAND_SECTION_EMPTY 117 +# define SSL_R_SSL_COMMAND_SECTION_NOT_FOUND 125 +# define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 +# define SSL_R_SSL_HANDSHAKE_FAILURE 229 +# define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 +# define SSL_R_SSL_NEGATIVE_LENGTH 372 +# define SSL_R_SSL_SECTION_EMPTY 126 +# define SSL_R_SSL_SECTION_NOT_FOUND 136 +# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301 +# define SSL_R_SSL_SESSION_ID_CONFLICT 302 +# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 +# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303 +# define SSL_R_SSL_SESSION_ID_TOO_LONG 408 +# define SSL_R_SSL_SESSION_VERSION_MISMATCH 210 +# define SSL_R_STILL_IN_INIT 121 +# define SSL_R_STREAM_COUNT_LIMITED 411 +# define SSL_R_STREAM_FINISHED 365 +# define SSL_R_STREAM_RECV_ONLY 366 +# define SSL_R_STREAM_RESET 375 +# define SSL_R_STREAM_SEND_ONLY 379 +# define SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED 1116 +# define SSL_R_TLSV13_ALERT_MISSING_EXTENSION 1109 +# define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 +# define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 +# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 +# define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 +# define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 +# define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086 +# define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 +# define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 +# define SSL_R_TLSV1_ALERT_NO_APPLICATION_PROTOCOL 1120 +# define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 +# define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 +# define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 +# define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 +# define SSL_R_TLSV1_ALERT_UNKNOWN_PSK_IDENTITY 1115 +# define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 +# define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114 +# define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113 +# define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111 +# define SSL_R_TLSV1_UNRECOGNIZED_NAME 1112 +# define SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110 +# define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL 367 +# define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST 157 +# define SSL_R_TOO_MANY_KEY_UPDATES 132 +# define SSL_R_TOO_MANY_WARN_ALERTS 409 +# define SSL_R_TOO_MUCH_EARLY_DATA 164 +# define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314 +# define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 +# define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 +# define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 +# define SSL_R_UNEXPECTED_CCS_MESSAGE 262 +# define SSL_R_UNEXPECTED_END_OF_EARLY_DATA 178 +# define SSL_R_UNEXPECTED_EOF_WHILE_READING 294 +# define SSL_R_UNEXPECTED_MESSAGE 244 +# define SSL_R_UNEXPECTED_RECORD 245 +# define SSL_R_UNINITIALIZED 276 +# define SSL_R_UNKNOWN_ALERT_TYPE 246 +# define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 +# define SSL_R_UNKNOWN_CIPHER_RETURNED 248 +# define SSL_R_UNKNOWN_CIPHER_TYPE 249 +# define SSL_R_UNKNOWN_CMD_NAME 386 +# define SSL_R_UNKNOWN_COMMAND 139 +# define SSL_R_UNKNOWN_DIGEST 368 +# define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 +# define SSL_R_UNKNOWN_MANDATORY_PARAMETER 323 +# define SSL_R_UNKNOWN_PKEY_TYPE 251 +# define SSL_R_UNKNOWN_PROTOCOL 252 +# define SSL_R_UNKNOWN_SSL_VERSION 254 +# define SSL_R_UNKNOWN_STATE 255 +# define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED 338 +# define SSL_R_UNSOLICITED_EXTENSION 217 +# define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 +# define SSL_R_UNSUPPORTED_CONFIG_VALUE 414 +# define SSL_R_UNSUPPORTED_CONFIG_VALUE_CLASS 415 +# define SSL_R_UNSUPPORTED_CONFIG_VALUE_OP 416 +# define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315 +# define SSL_R_UNSUPPORTED_PROTOCOL 258 +# define SSL_R_UNSUPPORTED_SSL_VERSION 259 +# define SSL_R_UNSUPPORTED_STATUS_TYPE 329 +# define SSL_R_UNSUPPORTED_WRITE_FLAG 412 +# define SSL_R_USE_SRTP_NOT_NEGOTIATED 369 +# define SSL_R_VERSION_TOO_HIGH 166 +# define SSL_R_VERSION_TOO_LOW 396 +# define SSL_R_WRONG_CERTIFICATE_TYPE 383 +# define SSL_R_WRONG_CIPHER_RETURNED 261 +# define SSL_R_WRONG_CURVE 378 +# define SSL_R_WRONG_RPK_TYPE 351 +# define SSL_R_WRONG_SIGNATURE_LENGTH 264 +# define SSL_R_WRONG_SIGNATURE_SIZE 265 +# define SSL_R_WRONG_SIGNATURE_TYPE 370 +# define SSL_R_WRONG_SSL_VERSION 266 +# define SSL_R_WRONG_VERSION_NUMBER 267 +# define SSL_R_X509_LIB 268 +# define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/sslerr_legacy.h b/illumos-x86_64/usr/include/openssl-3/sslerr_legacy.h new file mode 100644 index 00000000..4c353671 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/sslerr_legacy.h @@ -0,0 +1,467 @@ +/* + * Copyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * This header file preserves symbols from pre-3.0 OpenSSL. + * It should never be included directly, as it's already included + * by the public sslerr.h headers, and since it will go away some + * time in the future. + */ + +#ifndef OPENSSL_SSLERR_LEGACY_H +# define OPENSSL_SSLERR_LEGACY_H +# pragma once + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ERR_load_SSL_strings(void); + +/* Collected _F_ macros from OpenSSL 1.1.1 */ + +/* + * SSL function codes. + */ +# define SSL_F_ADD_CLIENT_KEY_SHARE_EXT 0 +# define SSL_F_ADD_KEY_SHARE 0 +# define SSL_F_BYTES_TO_CIPHER_LIST 0 +# define SSL_F_CHECK_SUITEB_CIPHER_LIST 0 +# define SSL_F_CIPHERSUITE_CB 0 +# define SSL_F_CONSTRUCT_CA_NAMES 0 +# define SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS 0 +# define SSL_F_CONSTRUCT_STATEFUL_TICKET 0 +# define SSL_F_CONSTRUCT_STATELESS_TICKET 0 +# define SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH 0 +# define SSL_F_CREATE_TICKET_PREQUEL 0 +# define SSL_F_CT_MOVE_SCTS 0 +# define SSL_F_CT_STRICT 0 +# define SSL_F_CUSTOM_EXT_ADD 0 +# define SSL_F_CUSTOM_EXT_PARSE 0 +# define SSL_F_D2I_SSL_SESSION 0 +# define SSL_F_DANE_CTX_ENABLE 0 +# define SSL_F_DANE_MTYPE_SET 0 +# define SSL_F_DANE_TLSA_ADD 0 +# define SSL_F_DERIVE_SECRET_KEY_AND_IV 0 +# define SSL_F_DO_DTLS1_WRITE 0 +# define SSL_F_DO_SSL3_WRITE 0 +# define SSL_F_DTLS1_BUFFER_RECORD 0 +# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM 0 +# define SSL_F_DTLS1_HEARTBEAT 0 +# define SSL_F_DTLS1_HM_FRAGMENT_NEW 0 +# define SSL_F_DTLS1_PREPROCESS_FRAGMENT 0 +# define SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS 0 +# define SSL_F_DTLS1_PROCESS_RECORD 0 +# define SSL_F_DTLS1_READ_BYTES 0 +# define SSL_F_DTLS1_READ_FAILED 0 +# define SSL_F_DTLS1_RETRANSMIT_MESSAGE 0 +# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 0 +# define SSL_F_DTLS1_WRITE_BYTES 0 +# define SSL_F_DTLSV1_LISTEN 0 +# define SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC 0 +# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST 0 +# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE 0 +# define SSL_F_DTLS_PROCESS_HELLO_VERIFY 0 +# define SSL_F_DTLS_RECORD_LAYER_NEW 0 +# define SSL_F_DTLS_WAIT_FOR_DRY 0 +# define SSL_F_EARLY_DATA_COUNT_OK 0 +# define SSL_F_FINAL_EARLY_DATA 0 +# define SSL_F_FINAL_EC_PT_FORMATS 0 +# define SSL_F_FINAL_EMS 0 +# define SSL_F_FINAL_KEY_SHARE 0 +# define SSL_F_FINAL_MAXFRAGMENTLEN 0 +# define SSL_F_FINAL_RENEGOTIATE 0 +# define SSL_F_FINAL_SERVER_NAME 0 +# define SSL_F_FINAL_SIG_ALGS 0 +# define SSL_F_GET_CERT_VERIFY_TBS_DATA 0 +# define SSL_F_NSS_KEYLOG_INT 0 +# define SSL_F_OPENSSL_INIT_SSL 0 +# define SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION 0 +# define SSL_F_OSSL_STATEM_CLIENT13_WRITE_TRANSITION 0 +# define SSL_F_OSSL_STATEM_CLIENT_CONSTRUCT_MESSAGE 0 +# define SSL_F_OSSL_STATEM_CLIENT_POST_PROCESS_MESSAGE 0 +# define SSL_F_OSSL_STATEM_CLIENT_PROCESS_MESSAGE 0 +# define SSL_F_OSSL_STATEM_CLIENT_READ_TRANSITION 0 +# define SSL_F_OSSL_STATEM_CLIENT_WRITE_TRANSITION 0 +# define SSL_F_OSSL_STATEM_SERVER13_READ_TRANSITION 0 +# define SSL_F_OSSL_STATEM_SERVER13_WRITE_TRANSITION 0 +# define SSL_F_OSSL_STATEM_SERVER_CONSTRUCT_MESSAGE 0 +# define SSL_F_OSSL_STATEM_SERVER_POST_PROCESS_MESSAGE 0 +# define SSL_F_OSSL_STATEM_SERVER_POST_WORK 0 +# define SSL_F_OSSL_STATEM_SERVER_PRE_WORK 0 +# define SSL_F_OSSL_STATEM_SERVER_PROCESS_MESSAGE 0 +# define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION 0 +# define SSL_F_OSSL_STATEM_SERVER_WRITE_TRANSITION 0 +# define SSL_F_PARSE_CA_NAMES 0 +# define SSL_F_PITEM_NEW 0 +# define SSL_F_PQUEUE_NEW 0 +# define SSL_F_PROCESS_KEY_SHARE_EXT 0 +# define SSL_F_READ_STATE_MACHINE 0 +# define SSL_F_SET_CLIENT_CIPHERSUITE 0 +# define SSL_F_SRP_GENERATE_CLIENT_MASTER_SECRET 0 +# define SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET 0 +# define SSL_F_SRP_VERIFY_SERVER_PARAM 0 +# define SSL_F_SSL3_CHANGE_CIPHER_STATE 0 +# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 0 +# define SSL_F_SSL3_CTRL 0 +# define SSL_F_SSL3_CTX_CTRL 0 +# define SSL_F_SSL3_DIGEST_CACHED_RECORDS 0 +# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC 0 +# define SSL_F_SSL3_ENC 0 +# define SSL_F_SSL3_FINAL_FINISH_MAC 0 +# define SSL_F_SSL3_FINISH_MAC 0 +# define SSL_F_SSL3_GENERATE_KEY_BLOCK 0 +# define SSL_F_SSL3_GENERATE_MASTER_SECRET 0 +# define SSL_F_SSL3_GET_RECORD 0 +# define SSL_F_SSL3_INIT_FINISHED_MAC 0 +# define SSL_F_SSL3_OUTPUT_CERT_CHAIN 0 +# define SSL_F_SSL3_READ_BYTES 0 +# define SSL_F_SSL3_READ_N 0 +# define SSL_F_SSL3_SETUP_KEY_BLOCK 0 +# define SSL_F_SSL3_SETUP_READ_BUFFER 0 +# define SSL_F_SSL3_SETUP_WRITE_BUFFER 0 +# define SSL_F_SSL3_WRITE_BYTES 0 +# define SSL_F_SSL3_WRITE_PENDING 0 +# define SSL_F_SSL_ADD_CERT_CHAIN 0 +# define SSL_F_SSL_ADD_CERT_TO_BUF 0 +# define SSL_F_SSL_ADD_CERT_TO_WPACKET 0 +# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT 0 +# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT 0 +# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT 0 +# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 0 +# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 0 +# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT 0 +# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT 0 +# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT 0 +# define SSL_F_SSL_BUILD_CERT_CHAIN 0 +# define SSL_F_SSL_BYTES_TO_CIPHER_LIST 0 +# define SSL_F_SSL_CACHE_CIPHERLIST 0 +# define SSL_F_SSL_CERT_ADD0_CHAIN_CERT 0 +# define SSL_F_SSL_CERT_DUP 0 +# define SSL_F_SSL_CERT_NEW 0 +# define SSL_F_SSL_CERT_SET0_CHAIN 0 +# define SSL_F_SSL_CHECK_PRIVATE_KEY 0 +# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT 0 +# define SSL_F_SSL_CHECK_SRP_EXT_CLIENTHELLO 0 +# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG 0 +# define SSL_F_SSL_CHOOSE_CLIENT_VERSION 0 +# define SSL_F_SSL_CIPHER_DESCRIPTION 0 +# define SSL_F_SSL_CIPHER_LIST_TO_BYTES 0 +# define SSL_F_SSL_CIPHER_PROCESS_RULESTR 0 +# define SSL_F_SSL_CIPHER_STRENGTH_SORT 0 +# define SSL_F_SSL_CLEAR 0 +# define SSL_F_SSL_CLIENT_HELLO_GET1_EXTENSIONS_PRESENT 0 +# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 0 +# define SSL_F_SSL_CONF_CMD 0 +# define SSL_F_SSL_CREATE_CIPHER_LIST 0 +# define SSL_F_SSL_CTRL 0 +# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 0 +# define SSL_F_SSL_CTX_ENABLE_CT 0 +# define SSL_F_SSL_CTX_MAKE_PROFILES 0 +# define SSL_F_SSL_CTX_NEW 0 +# define SSL_F_SSL_CTX_SET_ALPN_PROTOS 0 +# define SSL_F_SSL_CTX_SET_CIPHER_LIST 0 +# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE 0 +# define SSL_F_SSL_CTX_SET_CT_VALIDATION_CALLBACK 0 +# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 0 +# define SSL_F_SSL_CTX_SET_SSL_VERSION 0 +# define SSL_F_SSL_CTX_SET_TLSEXT_MAX_FRAGMENT_LENGTH 0 +# define SSL_F_SSL_CTX_USE_CERTIFICATE 0 +# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 0 +# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 0 +# define SSL_F_SSL_CTX_USE_PRIVATEKEY 0 +# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 0 +# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 0 +# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT 0 +# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 0 +# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 0 +# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 0 +# define SSL_F_SSL_CTX_USE_SERVERINFO 0 +# define SSL_F_SSL_CTX_USE_SERVERINFO_EX 0 +# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE 0 +# define SSL_F_SSL_DANE_DUP 0 +# define SSL_F_SSL_DANE_ENABLE 0 +# define SSL_F_SSL_DERIVE 0 +# define SSL_F_SSL_DO_CONFIG 0 +# define SSL_F_SSL_DO_HANDSHAKE 0 +# define SSL_F_SSL_DUP_CA_LIST 0 +# define SSL_F_SSL_ENABLE_CT 0 +# define SSL_F_SSL_GENERATE_PKEY_GROUP 0 +# define SSL_F_SSL_GENERATE_SESSION_ID 0 +# define SSL_F_SSL_GET_NEW_SESSION 0 +# define SSL_F_SSL_GET_PREV_SESSION 0 +# define SSL_F_SSL_GET_SERVER_CERT_INDEX 0 +# define SSL_F_SSL_GET_SIGN_PKEY 0 +# define SSL_F_SSL_HANDSHAKE_HASH 0 +# define SSL_F_SSL_INIT_WBIO_BUFFER 0 +# define SSL_F_SSL_KEY_UPDATE 0 +# define SSL_F_SSL_LOAD_CLIENT_CA_FILE 0 +# define SSL_F_SSL_LOG_MASTER_SECRET 0 +# define SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE 0 +# define SSL_F_SSL_MODULE_INIT 0 +# define SSL_F_SSL_NEW 0 +# define SSL_F_SSL_NEXT_PROTO_VALIDATE 0 +# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT 0 +# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT 0 +# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT 0 +# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT 0 +# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT 0 +# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT 0 +# define SSL_F_SSL_PEEK 0 +# define SSL_F_SSL_PEEK_EX 0 +# define SSL_F_SSL_PEEK_INTERNAL 0 +# define SSL_F_SSL_READ 0 +# define SSL_F_SSL_READ_EARLY_DATA 0 +# define SSL_F_SSL_READ_EX 0 +# define SSL_F_SSL_READ_INTERNAL 0 +# define SSL_F_SSL_RENEGOTIATE 0 +# define SSL_F_SSL_RENEGOTIATE_ABBREVIATED 0 +# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT 0 +# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT 0 +# define SSL_F_SSL_SESSION_DUP 0 +# define SSL_F_SSL_SESSION_NEW 0 +# define SSL_F_SSL_SESSION_PRINT_FP 0 +# define SSL_F_SSL_SESSION_SET1_ID 0 +# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT 0 +# define SSL_F_SSL_SET_ALPN_PROTOS 0 +# define SSL_F_SSL_SET_CERT 0 +# define SSL_F_SSL_SET_CERT_AND_KEY 0 +# define SSL_F_SSL_SET_CIPHER_LIST 0 +# define SSL_F_SSL_SET_CT_VALIDATION_CALLBACK 0 +# define SSL_F_SSL_SET_FD 0 +# define SSL_F_SSL_SET_PKEY 0 +# define SSL_F_SSL_SET_RFD 0 +# define SSL_F_SSL_SET_SESSION 0 +# define SSL_F_SSL_SET_SESSION_ID_CONTEXT 0 +# define SSL_F_SSL_SET_SESSION_TICKET_EXT 0 +# define SSL_F_SSL_SET_TLSEXT_MAX_FRAGMENT_LENGTH 0 +# define SSL_F_SSL_SET_WFD 0 +# define SSL_F_SSL_SHUTDOWN 0 +# define SSL_F_SSL_SRP_CTX_INIT 0 +# define SSL_F_SSL_START_ASYNC_JOB 0 +# define SSL_F_SSL_UNDEFINED_FUNCTION 0 +# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 0 +# define SSL_F_SSL_USE_CERTIFICATE 0 +# define SSL_F_SSL_USE_CERTIFICATE_ASN1 0 +# define SSL_F_SSL_USE_CERTIFICATE_FILE 0 +# define SSL_F_SSL_USE_PRIVATEKEY 0 +# define SSL_F_SSL_USE_PRIVATEKEY_ASN1 0 +# define SSL_F_SSL_USE_PRIVATEKEY_FILE 0 +# define SSL_F_SSL_USE_PSK_IDENTITY_HINT 0 +# define SSL_F_SSL_USE_RSAPRIVATEKEY 0 +# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 0 +# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 0 +# define SSL_F_SSL_VALIDATE_CT 0 +# define SSL_F_SSL_VERIFY_CERT_CHAIN 0 +# define SSL_F_SSL_VERIFY_CLIENT_POST_HANDSHAKE 0 +# define SSL_F_SSL_WRITE 0 +# define SSL_F_SSL_WRITE_EARLY_DATA 0 +# define SSL_F_SSL_WRITE_EARLY_FINISH 0 +# define SSL_F_SSL_WRITE_EX 0 +# define SSL_F_SSL_WRITE_INTERNAL 0 +# define SSL_F_STATE_MACHINE 0 +# define SSL_F_TLS12_CHECK_PEER_SIGALG 0 +# define SSL_F_TLS12_COPY_SIGALGS 0 +# define SSL_F_TLS13_CHANGE_CIPHER_STATE 0 +# define SSL_F_TLS13_ENC 0 +# define SSL_F_TLS13_FINAL_FINISH_MAC 0 +# define SSL_F_TLS13_GENERATE_SECRET 0 +# define SSL_F_TLS13_HKDF_EXPAND 0 +# define SSL_F_TLS13_RESTORE_HANDSHAKE_DIGEST_FOR_PHA 0 +# define SSL_F_TLS13_SAVE_HANDSHAKE_DIGEST_FOR_PHA 0 +# define SSL_F_TLS13_SETUP_KEY_BLOCK 0 +# define SSL_F_TLS1_CHANGE_CIPHER_STATE 0 +# define SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS 0 +# define SSL_F_TLS1_ENC 0 +# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL 0 +# define SSL_F_TLS1_GET_CURVELIST 0 +# define SSL_F_TLS1_PRF 0 +# define SSL_F_TLS1_SAVE_U16 0 +# define SSL_F_TLS1_SETUP_KEY_BLOCK 0 +# define SSL_F_TLS1_SET_GROUPS 0 +# define SSL_F_TLS1_SET_RAW_SIGALGS 0 +# define SSL_F_TLS1_SET_SERVER_SIGALGS 0 +# define SSL_F_TLS1_SET_SHARED_SIGALGS 0 +# define SSL_F_TLS1_SET_SIGALGS 0 +# define SSL_F_TLS_CHOOSE_SIGALG 0 +# define SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK 0 +# define SSL_F_TLS_COLLECT_EXTENSIONS 0 +# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES 0 +# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_CERT_STATUS 0 +# define SSL_F_TLS_CONSTRUCT_CERT_STATUS_BODY 0 +# define SSL_F_TLS_CONSTRUCT_CERT_VERIFY 0 +# define SSL_F_TLS_CONSTRUCT_CHANGE_CIPHER_SPEC 0 +# define SSL_F_TLS_CONSTRUCT_CKE_DHE 0 +# define SSL_F_TLS_CONSTRUCT_CKE_ECDHE 0 +# define SSL_F_TLS_CONSTRUCT_CKE_GOST 0 +# define SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE 0 +# define SSL_F_TLS_CONSTRUCT_CKE_RSA 0 +# define SSL_F_TLS_CONSTRUCT_CKE_SRP 0 +# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE 0 +# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO 0 +# define SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE 0 +# define SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_ALPN 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_CERTIFICATE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_COOKIE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_EARLY_DATA 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_EC_PT_FORMATS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_EMS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_ETM 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_HELLO 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_EXCHANGE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_SHARE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_MAXFRAGMENTLEN 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_NPN 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_PADDING 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_POST_HANDSHAKE_AUTH 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_PSK 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_PSK_KEX_MODES 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_RENEGOTIATE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SCT 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SERVER_NAME 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SESSION_TICKET 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SIG_ALGS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SRP 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_STATUS_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_VERSIONS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_USE_SRTP 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_VERIFY 0 +# define SSL_F_TLS_CONSTRUCT_ENCRYPTED_EXTENSIONS 0 +# define SSL_F_TLS_CONSTRUCT_END_OF_EARLY_DATA 0 +# define SSL_F_TLS_CONSTRUCT_EXTENSIONS 0 +# define SSL_F_TLS_CONSTRUCT_FINISHED 0 +# define SSL_F_TLS_CONSTRUCT_HELLO_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_HELLO_RETRY_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_KEY_UPDATE 0 +# define SSL_F_TLS_CONSTRUCT_NEW_SESSION_TICKET 0 +# define SSL_F_TLS_CONSTRUCT_NEXT_PROTO 0 +# define SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE 0 +# define SSL_F_TLS_CONSTRUCT_SERVER_HELLO 0 +# define SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_ALPN 0 +# define SSL_F_TLS_CONSTRUCT_STOC_CERTIFICATE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_COOKIE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_CRYPTOPRO_BUG 0 +# define SSL_F_TLS_CONSTRUCT_STOC_DONE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA 0 +# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA_INFO 0 +# define SSL_F_TLS_CONSTRUCT_STOC_EC_PT_FORMATS 0 +# define SSL_F_TLS_CONSTRUCT_STOC_EMS 0 +# define SSL_F_TLS_CONSTRUCT_STOC_ETM 0 +# define SSL_F_TLS_CONSTRUCT_STOC_HELLO 0 +# define SSL_F_TLS_CONSTRUCT_STOC_KEY_EXCHANGE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_KEY_SHARE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_MAXFRAGMENTLEN 0 +# define SSL_F_TLS_CONSTRUCT_STOC_NEXT_PROTO_NEG 0 +# define SSL_F_TLS_CONSTRUCT_STOC_PSK 0 +# define SSL_F_TLS_CONSTRUCT_STOC_RENEGOTIATE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_SERVER_NAME 0 +# define SSL_F_TLS_CONSTRUCT_STOC_SESSION_TICKET 0 +# define SSL_F_TLS_CONSTRUCT_STOC_STATUS_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_GROUPS 0 +# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_VERSIONS 0 +# define SSL_F_TLS_CONSTRUCT_STOC_USE_SRTP 0 +# define SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO 0 +# define SSL_F_TLS_FINISH_HANDSHAKE 0 +# define SSL_F_TLS_GET_MESSAGE_BODY 0 +# define SSL_F_TLS_GET_MESSAGE_HEADER 0 +# define SSL_F_TLS_HANDLE_ALPN 0 +# define SSL_F_TLS_HANDLE_STATUS_REQUEST 0 +# define SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES 0 +# define SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT 0 +# define SSL_F_TLS_PARSE_CTOS_ALPN 0 +# define SSL_F_TLS_PARSE_CTOS_COOKIE 0 +# define SSL_F_TLS_PARSE_CTOS_EARLY_DATA 0 +# define SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS 0 +# define SSL_F_TLS_PARSE_CTOS_EMS 0 +# define SSL_F_TLS_PARSE_CTOS_KEY_SHARE 0 +# define SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN 0 +# define SSL_F_TLS_PARSE_CTOS_POST_HANDSHAKE_AUTH 0 +# define SSL_F_TLS_PARSE_CTOS_PSK 0 +# define SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES 0 +# define SSL_F_TLS_PARSE_CTOS_RENEGOTIATE 0 +# define SSL_F_TLS_PARSE_CTOS_SERVER_NAME 0 +# define SSL_F_TLS_PARSE_CTOS_SESSION_TICKET 0 +# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS 0 +# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS_CERT 0 +# define SSL_F_TLS_PARSE_CTOS_SRP 0 +# define SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST 0 +# define SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS 0 +# define SSL_F_TLS_PARSE_CTOS_USE_SRTP 0 +# define SSL_F_TLS_PARSE_STOC_ALPN 0 +# define SSL_F_TLS_PARSE_STOC_COOKIE 0 +# define SSL_F_TLS_PARSE_STOC_EARLY_DATA 0 +# define SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO 0 +# define SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS 0 +# define SSL_F_TLS_PARSE_STOC_KEY_SHARE 0 +# define SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN 0 +# define SSL_F_TLS_PARSE_STOC_NPN 0 +# define SSL_F_TLS_PARSE_STOC_PSK 0 +# define SSL_F_TLS_PARSE_STOC_RENEGOTIATE 0 +# define SSL_F_TLS_PARSE_STOC_SCT 0 +# define SSL_F_TLS_PARSE_STOC_SERVER_NAME 0 +# define SSL_F_TLS_PARSE_STOC_SESSION_TICKET 0 +# define SSL_F_TLS_PARSE_STOC_STATUS_REQUEST 0 +# define SSL_F_TLS_PARSE_STOC_SUPPORTED_VERSIONS 0 +# define SSL_F_TLS_PARSE_STOC_USE_SRTP 0 +# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO 0 +# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE 0 +# define SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE 0 +# define SSL_F_TLS_PROCESS_AS_HELLO_RETRY_REQUEST 0 +# define SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST 0 +# define SSL_F_TLS_PROCESS_CERT_STATUS 0 +# define SSL_F_TLS_PROCESS_CERT_STATUS_BODY 0 +# define SSL_F_TLS_PROCESS_CERT_VERIFY 0 +# define SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC 0 +# define SSL_F_TLS_PROCESS_CKE_DHE 0 +# define SSL_F_TLS_PROCESS_CKE_ECDHE 0 +# define SSL_F_TLS_PROCESS_CKE_GOST 0 +# define SSL_F_TLS_PROCESS_CKE_PSK_PREAMBLE 0 +# define SSL_F_TLS_PROCESS_CKE_RSA 0 +# define SSL_F_TLS_PROCESS_CKE_SRP 0 +# define SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE 0 +# define SSL_F_TLS_PROCESS_CLIENT_HELLO 0 +# define SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE 0 +# define SSL_F_TLS_PROCESS_ENCRYPTED_EXTENSIONS 0 +# define SSL_F_TLS_PROCESS_END_OF_EARLY_DATA 0 +# define SSL_F_TLS_PROCESS_FINISHED 0 +# define SSL_F_TLS_PROCESS_HELLO_REQ 0 +# define SSL_F_TLS_PROCESS_HELLO_RETRY_REQUEST 0 +# define SSL_F_TLS_PROCESS_INITIAL_SERVER_FLIGHT 0 +# define SSL_F_TLS_PROCESS_KEY_EXCHANGE 0 +# define SSL_F_TLS_PROCESS_KEY_UPDATE 0 +# define SSL_F_TLS_PROCESS_NEW_SESSION_TICKET 0 +# define SSL_F_TLS_PROCESS_NEXT_PROTO 0 +# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE 0 +# define SSL_F_TLS_PROCESS_SERVER_DONE 0 +# define SSL_F_TLS_PROCESS_SERVER_HELLO 0 +# define SSL_F_TLS_PROCESS_SKE_DHE 0 +# define SSL_F_TLS_PROCESS_SKE_ECDHE 0 +# define SSL_F_TLS_PROCESS_SKE_PSK_PREAMBLE 0 +# define SSL_F_TLS_PROCESS_SKE_SRP 0 +# define SSL_F_TLS_PSK_DO_BINDER 0 +# define SSL_F_TLS_SCAN_CLIENTHELLO_TLSEXT 0 +# define SSL_F_TLS_SETUP_HANDSHAKE 0 +# define SSL_F_USE_CERTIFICATE_CHAIN_FILE 0 +# define SSL_F_WPACKET_INTERN_INIT_LEN 0 +# define SSL_F_WPACKET_START_SUB_PACKET_LEN__ 0 +# define SSL_F_WRITE_STATE_MACHINE 0 +# endif + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/stack.h b/illumos-x86_64/usr/include/openssl-3/stack.h new file mode 100644 index 00000000..f0c5c547 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/stack.h @@ -0,0 +1,90 @@ +/* + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_STACK_H +# define OPENSSL_STACK_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_STACK_H +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */ + +typedef int (*OPENSSL_sk_compfunc)(const void *, const void *); +typedef void (*OPENSSL_sk_freefunc)(void *); +typedef void *(*OPENSSL_sk_copyfunc)(const void *); + +int OPENSSL_sk_num(const OPENSSL_STACK *); +void *OPENSSL_sk_value(const OPENSSL_STACK *, int); + +void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data); + +OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp); +OPENSSL_STACK *OPENSSL_sk_new_null(void); +OPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n); +int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n); +void OPENSSL_sk_free(OPENSSL_STACK *); +void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *)); +OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, + OPENSSL_sk_copyfunc c, + OPENSSL_sk_freefunc f); +int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where); +void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc); +void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p); +int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data); +int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data); +int OPENSSL_sk_find_all(OPENSSL_STACK *st, const void *data, int *pnum); +int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data); +int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data); +void *OPENSSL_sk_shift(OPENSSL_STACK *st); +void *OPENSSL_sk_pop(OPENSSL_STACK *st); +void OPENSSL_sk_zero(OPENSSL_STACK *st); +OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, + OPENSSL_sk_compfunc cmp); +OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st); +void OPENSSL_sk_sort(OPENSSL_STACK *st); +int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define _STACK OPENSSL_STACK +# define sk_num OPENSSL_sk_num +# define sk_value OPENSSL_sk_value +# define sk_set OPENSSL_sk_set +# define sk_new OPENSSL_sk_new +# define sk_new_null OPENSSL_sk_new_null +# define sk_free OPENSSL_sk_free +# define sk_pop_free OPENSSL_sk_pop_free +# define sk_deep_copy OPENSSL_sk_deep_copy +# define sk_insert OPENSSL_sk_insert +# define sk_delete OPENSSL_sk_delete +# define sk_delete_ptr OPENSSL_sk_delete_ptr +# define sk_find OPENSSL_sk_find +# define sk_find_ex OPENSSL_sk_find_ex +# define sk_push OPENSSL_sk_push +# define sk_unshift OPENSSL_sk_unshift +# define sk_shift OPENSSL_sk_shift +# define sk_pop OPENSSL_sk_pop +# define sk_zero OPENSSL_sk_zero +# define sk_set_cmp_func OPENSSL_sk_set_cmp_func +# define sk_dup OPENSSL_sk_dup +# define sk_sort OPENSSL_sk_sort +# define sk_is_sorted OPENSSL_sk_is_sorted +# endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/store.h b/illumos-x86_64/usr/include/openssl-3/store.h new file mode 100644 index 00000000..e6ea3cf8 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/store.h @@ -0,0 +1,377 @@ +/* + * Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_STORE_H +# define OPENSSL_STORE_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_OSSL_STORE_H +# endif + +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/*- + * The main OSSL_STORE functions. + * ------------------------------ + * + * These allow applications to open a channel to a resource with supported + * data (keys, certs, crls, ...), read the data a piece at a time and decide + * what to do with it, and finally close. + */ + +typedef struct ossl_store_ctx_st OSSL_STORE_CTX; + +/* + * Typedef for the OSSL_STORE_INFO post processing callback. This can be used + * to massage the given OSSL_STORE_INFO, or to drop it entirely (by returning + * NULL). + */ +typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *, + void *); + +/* + * Open a channel given a URI. The given UI method will be used any time the + * loader needs extra input, for example when a password or pin is needed, and + * will be passed the same user data every time it's needed in this context. + * + * Returns a context reference which represents the channel to communicate + * through. + */ +OSSL_STORE_CTX * +OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method, void *ui_data, + OSSL_STORE_post_process_info_fn post_process, + void *post_process_data); +OSSL_STORE_CTX * +OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq, + const UI_METHOD *ui_method, void *ui_data, + const OSSL_PARAM params[], + OSSL_STORE_post_process_info_fn post_process, + void *post_process_data); + +/* + * Control / fine tune the OSSL_STORE channel. |cmd| determines what is to be + * done, and depends on the underlying loader (use OSSL_STORE_get0_scheme to + * determine which loader is used), except for common commands (see below). + * Each command takes different arguments. + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, + ... /* args */); +OSSL_DEPRECATEDIN_3_0 int OSSL_STORE_vctrl(OSSL_STORE_CTX *ctx, int cmd, + va_list args); +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 + +/* + * Common ctrl commands that different loaders may choose to support. + */ +/* int on = 0 or 1; STORE_ctrl(ctx, STORE_C_USE_SECMEM, &on); */ +# define OSSL_STORE_C_USE_SECMEM 1 +/* Where custom commands start */ +# define OSSL_STORE_C_CUSTOM_START 100 + +# endif + +/* + * Read one data item (a key, a cert, a CRL) that is supported by the OSSL_STORE + * functionality, given a context. + * Returns a OSSL_STORE_INFO pointer, from which OpenSSL typed data can be + * extracted with OSSL_STORE_INFO_get0_PKEY(), OSSL_STORE_INFO_get0_CERT(), ... + * NULL is returned on error, which may include that the data found at the URI + * can't be figured out for certain or is ambiguous. + */ +OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx); + +/* + * Deletes the object in the store by URI. + * Returns 1 on success, 0 otherwise. + */ +int OSSL_STORE_delete(const char *uri, OSSL_LIB_CTX *libctx, const char *propq, + const UI_METHOD *ui_method, void *ui_data, + const OSSL_PARAM params[]); + +/* + * Check if end of data (end of file) is reached + * Returns 1 on end, 0 otherwise. + */ +int OSSL_STORE_eof(OSSL_STORE_CTX *ctx); + +/* + * Check if an error occurred + * Returns 1 if it did, 0 otherwise. + */ +int OSSL_STORE_error(OSSL_STORE_CTX *ctx); + +/* + * Close the channel + * Returns 1 on success, 0 on error. + */ +int OSSL_STORE_close(OSSL_STORE_CTX *ctx); + +/* + * Attach to a BIO. This works like OSSL_STORE_open() except it takes a + * BIO instead of a uri, along with a scheme to use when reading. + * The given UI method will be used any time the loader needs extra input, + * for example when a password or pin is needed, and will be passed the + * same user data every time it's needed in this context. + * + * Returns a context reference which represents the channel to communicate + * through. + * + * Note that this function is considered unsafe, all depending on what the + * BIO actually reads. + */ +OSSL_STORE_CTX *OSSL_STORE_attach(BIO *bio, const char *scheme, + OSSL_LIB_CTX *libctx, const char *propq, + const UI_METHOD *ui_method, void *ui_data, + const OSSL_PARAM params[], + OSSL_STORE_post_process_info_fn post_process, + void *post_process_data); + +/*- + * Extracting OpenSSL types from and creating new OSSL_STORE_INFOs + * --------------------------------------------------------------- + */ + +/* + * Types of data that can be ossl_stored in a OSSL_STORE_INFO. + * OSSL_STORE_INFO_NAME is typically found when getting a listing of + * available "files" / "tokens" / what have you. + */ +# define OSSL_STORE_INFO_NAME 1 /* char * */ +# define OSSL_STORE_INFO_PARAMS 2 /* EVP_PKEY * */ +# define OSSL_STORE_INFO_PUBKEY 3 /* EVP_PKEY * */ +# define OSSL_STORE_INFO_PKEY 4 /* EVP_PKEY * */ +# define OSSL_STORE_INFO_CERT 5 /* X509 * */ +# define OSSL_STORE_INFO_CRL 6 /* X509_CRL * */ + +/* + * Functions to generate OSSL_STORE_INFOs, one function for each type we + * support having in them, as well as a generic constructor. + * + * In all cases, ownership of the object is transferred to the OSSL_STORE_INFO + * and will therefore be freed when the OSSL_STORE_INFO is freed. + */ +OSSL_STORE_INFO *OSSL_STORE_INFO_new(int type, void *data); +OSSL_STORE_INFO *OSSL_STORE_INFO_new_NAME(char *name); +int OSSL_STORE_INFO_set0_NAME_description(OSSL_STORE_INFO *info, char *desc); +OSSL_STORE_INFO *OSSL_STORE_INFO_new_PARAMS(EVP_PKEY *params); +OSSL_STORE_INFO *OSSL_STORE_INFO_new_PUBKEY(EVP_PKEY *pubkey); +OSSL_STORE_INFO *OSSL_STORE_INFO_new_PKEY(EVP_PKEY *pkey); +OSSL_STORE_INFO *OSSL_STORE_INFO_new_CERT(X509 *x509); +OSSL_STORE_INFO *OSSL_STORE_INFO_new_CRL(X509_CRL *crl); + +/* + * Functions to try to extract data from a OSSL_STORE_INFO. + */ +int OSSL_STORE_INFO_get_type(const OSSL_STORE_INFO *info); +void *OSSL_STORE_INFO_get0_data(int type, const OSSL_STORE_INFO *info); +const char *OSSL_STORE_INFO_get0_NAME(const OSSL_STORE_INFO *info); +char *OSSL_STORE_INFO_get1_NAME(const OSSL_STORE_INFO *info); +const char *OSSL_STORE_INFO_get0_NAME_description(const OSSL_STORE_INFO *info); +char *OSSL_STORE_INFO_get1_NAME_description(const OSSL_STORE_INFO *info); +EVP_PKEY *OSSL_STORE_INFO_get0_PARAMS(const OSSL_STORE_INFO *info); +EVP_PKEY *OSSL_STORE_INFO_get1_PARAMS(const OSSL_STORE_INFO *info); +EVP_PKEY *OSSL_STORE_INFO_get0_PUBKEY(const OSSL_STORE_INFO *info); +EVP_PKEY *OSSL_STORE_INFO_get1_PUBKEY(const OSSL_STORE_INFO *info); +EVP_PKEY *OSSL_STORE_INFO_get0_PKEY(const OSSL_STORE_INFO *info); +EVP_PKEY *OSSL_STORE_INFO_get1_PKEY(const OSSL_STORE_INFO *info); +X509 *OSSL_STORE_INFO_get0_CERT(const OSSL_STORE_INFO *info); +X509 *OSSL_STORE_INFO_get1_CERT(const OSSL_STORE_INFO *info); +X509_CRL *OSSL_STORE_INFO_get0_CRL(const OSSL_STORE_INFO *info); +X509_CRL *OSSL_STORE_INFO_get1_CRL(const OSSL_STORE_INFO *info); + +const char *OSSL_STORE_INFO_type_string(int type); + +/* + * Free the OSSL_STORE_INFO + */ +void OSSL_STORE_INFO_free(OSSL_STORE_INFO *info); + + +/*- + * Functions to construct a search URI from a base URI and search criteria + * ----------------------------------------------------------------------- + */ + +/* OSSL_STORE search types */ +# define OSSL_STORE_SEARCH_BY_NAME 1 /* subject in certs, issuer in CRLs */ +# define OSSL_STORE_SEARCH_BY_ISSUER_SERIAL 2 +# define OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT 3 +# define OSSL_STORE_SEARCH_BY_ALIAS 4 + +/* To check what search types the scheme handler supports */ +int OSSL_STORE_supports_search(OSSL_STORE_CTX *ctx, int search_type); + +/* Search term constructors */ +/* + * The input is considered to be owned by the caller, and must therefore + * remain present throughout the lifetime of the returned OSSL_STORE_SEARCH + */ +OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_name(X509_NAME *name); +OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_issuer_serial(X509_NAME *name, + const ASN1_INTEGER + *serial); +OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_key_fingerprint(const EVP_MD *digest, + const unsigned char + *bytes, size_t len); +OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_alias(const char *alias); + +/* Search term destructor */ +void OSSL_STORE_SEARCH_free(OSSL_STORE_SEARCH *search); + +/* Search term accessors */ +int OSSL_STORE_SEARCH_get_type(const OSSL_STORE_SEARCH *criterion); +X509_NAME *OSSL_STORE_SEARCH_get0_name(const OSSL_STORE_SEARCH *criterion); +const ASN1_INTEGER *OSSL_STORE_SEARCH_get0_serial(const OSSL_STORE_SEARCH + *criterion); +const unsigned char *OSSL_STORE_SEARCH_get0_bytes(const OSSL_STORE_SEARCH + *criterion, size_t *length); +const char *OSSL_STORE_SEARCH_get0_string(const OSSL_STORE_SEARCH *criterion); +const EVP_MD *OSSL_STORE_SEARCH_get0_digest(const OSSL_STORE_SEARCH *criterion); + +/* + * Add search criterion and expected return type (which can be unspecified) + * to the loading channel. This MUST happen before the first OSSL_STORE_load(). + */ +int OSSL_STORE_expect(OSSL_STORE_CTX *ctx, int expected_type); +int OSSL_STORE_find(OSSL_STORE_CTX *ctx, const OSSL_STORE_SEARCH *search); + + +/*- + * Function to fetch a loader and extract data from it + * --------------------------------------------------- + */ + +typedef struct ossl_store_loader_st OSSL_STORE_LOADER; + +OSSL_STORE_LOADER *OSSL_STORE_LOADER_fetch(OSSL_LIB_CTX *libctx, + const char *scheme, + const char *properties); +int OSSL_STORE_LOADER_up_ref(OSSL_STORE_LOADER *loader); +void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader); +const OSSL_PROVIDER *OSSL_STORE_LOADER_get0_provider(const OSSL_STORE_LOADER * + loader); +const char *OSSL_STORE_LOADER_get0_properties(const OSSL_STORE_LOADER *loader); +const char *OSSL_STORE_LOADER_get0_description(const OSSL_STORE_LOADER *loader); +int OSSL_STORE_LOADER_is_a(const OSSL_STORE_LOADER *loader, + const char *scheme); +void OSSL_STORE_LOADER_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(OSSL_STORE_LOADER *loader, + void *arg), + void *arg); +int OSSL_STORE_LOADER_names_do_all(const OSSL_STORE_LOADER *loader, + void (*fn)(const char *name, void *data), + void *data); + +/*- + * Function to register a loader for the given URI scheme. + * ------------------------------------------------------- + * + * The loader receives all the main components of an URI except for the + * scheme. + */ + +# ifndef OPENSSL_NO_DEPRECATED_3_0 + +/* struct ossl_store_loader_ctx_st is defined differently by each loader */ +typedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX; +typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn) + (const OSSL_STORE_LOADER *loader, const char *uri, + const UI_METHOD *ui_method, void *ui_data); +typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_ex_fn) + (const OSSL_STORE_LOADER *loader, + const char *uri, OSSL_LIB_CTX *libctx, const char *propq, + const UI_METHOD *ui_method, void *ui_data); + +typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_attach_fn) + (const OSSL_STORE_LOADER *loader, BIO *bio, + OSSL_LIB_CTX *libctx, const char *propq, + const UI_METHOD *ui_method, void *ui_data); +typedef int (*OSSL_STORE_ctrl_fn) + (OSSL_STORE_LOADER_CTX *ctx, int cmd, va_list args); +typedef int (*OSSL_STORE_expect_fn) + (OSSL_STORE_LOADER_CTX *ctx, int expected); +typedef int (*OSSL_STORE_find_fn) + (OSSL_STORE_LOADER_CTX *ctx, const OSSL_STORE_SEARCH *criteria); +typedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn) + (OSSL_STORE_LOADER_CTX *ctx, const UI_METHOD *ui_method, void *ui_data); +typedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx); +typedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx); +typedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx); + +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *loader, + OSSL_STORE_open_fn open_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_open_ex(OSSL_STORE_LOADER *loader, + OSSL_STORE_open_ex_fn open_ex_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_attach(OSSL_STORE_LOADER *loader, + OSSL_STORE_attach_fn attach_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *loader, + OSSL_STORE_ctrl_fn ctrl_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader, + OSSL_STORE_expect_fn expect_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader, + OSSL_STORE_find_fn find_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *loader, + OSSL_STORE_load_fn load_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *loader, + OSSL_STORE_eof_fn eof_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *loader, + OSSL_STORE_error_fn error_function); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *loader, + OSSL_STORE_close_fn close_function); +OSSL_DEPRECATEDIN_3_0 +const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER *loader); +OSSL_DEPRECATEDIN_3_0 +const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER *loader); +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader); +OSSL_DEPRECATEDIN_3_0 +OSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme); +# endif + +/*- + * Functions to list STORE loaders + * ------------------------------- + */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int OSSL_STORE_do_all_loaders(void (*do_function)(const OSSL_STORE_LOADER *loader, + void *do_arg), + void *do_arg); +# endif + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/storeerr.h b/illumos-x86_64/usr/include/openssl-3/storeerr.h new file mode 100644 index 00000000..00529c88 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/storeerr.h @@ -0,0 +1,49 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_STOREERR_H +# define OPENSSL_STOREERR_H +# pragma once + +# include +# include +# include + + + +/* + * OSSL_STORE reason codes. + */ +# define OSSL_STORE_R_AMBIGUOUS_CONTENT_TYPE 107 +# define OSSL_STORE_R_BAD_PASSWORD_READ 115 +# define OSSL_STORE_R_ERROR_VERIFYING_PKCS12_MAC 113 +# define OSSL_STORE_R_FINGERPRINT_SIZE_DOES_NOT_MATCH_DIGEST 121 +# define OSSL_STORE_R_INVALID_SCHEME 106 +# define OSSL_STORE_R_IS_NOT_A 112 +# define OSSL_STORE_R_LOADER_INCOMPLETE 116 +# define OSSL_STORE_R_LOADING_STARTED 117 +# define OSSL_STORE_R_NOT_A_CERTIFICATE 100 +# define OSSL_STORE_R_NOT_A_CRL 101 +# define OSSL_STORE_R_NOT_A_NAME 103 +# define OSSL_STORE_R_NOT_A_PRIVATE_KEY 102 +# define OSSL_STORE_R_NOT_A_PUBLIC_KEY 122 +# define OSSL_STORE_R_NOT_PARAMETERS 104 +# define OSSL_STORE_R_NO_LOADERS_FOUND 123 +# define OSSL_STORE_R_PASSPHRASE_CALLBACK_ERROR 114 +# define OSSL_STORE_R_PATH_MUST_BE_ABSOLUTE 108 +# define OSSL_STORE_R_SEARCH_ONLY_SUPPORTED_FOR_DIRECTORIES 119 +# define OSSL_STORE_R_UI_PROCESS_INTERRUPTED_OR_CANCELLED 109 +# define OSSL_STORE_R_UNREGISTERED_SCHEME 105 +# define OSSL_STORE_R_UNSUPPORTED_CONTENT_TYPE 110 +# define OSSL_STORE_R_UNSUPPORTED_OPERATION 118 +# define OSSL_STORE_R_UNSUPPORTED_SEARCH_TYPE 120 +# define OSSL_STORE_R_URI_AUTHORITY_UNSUPPORTED 111 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/symhacks.h b/illumos-x86_64/usr/include/openssl-3/symhacks.h new file mode 100644 index 00000000..816f8f99 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/symhacks.h @@ -0,0 +1,39 @@ +/* + * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_SYMHACKS_H +# define OPENSSL_SYMHACKS_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_SYMHACKS_H +# endif + +# include + +/* Case insensitive linking causes problems.... */ +# if defined(OPENSSL_SYS_VMS) +# undef ERR_load_CRYPTO_strings +# define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings +# undef OCSP_crlID_new +# define OCSP_crlID_new OCSP_crlID2_new + +# undef d2i_ECPARAMETERS +# define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS +# undef i2d_ECPARAMETERS +# define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS +# undef d2i_ECPKPARAMETERS +# define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS +# undef i2d_ECPKPARAMETERS +# define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS + +# endif + +#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/thread.h b/illumos-x86_64/usr/include/openssl-3/thread.h new file mode 100644 index 00000000..3926ce54 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/thread.h @@ -0,0 +1,31 @@ +/* + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_THREAD_H +# define OPENSSL_THREAD_H + +# define OSSL_THREAD_SUPPORT_FLAG_THREAD_POOL (1U<<0) +# define OSSL_THREAD_SUPPORT_FLAG_DEFAULT_SPAWN (1U<<1) + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +uint32_t OSSL_get_thread_support_flags(void); +int OSSL_set_max_threads(OSSL_LIB_CTX *ctx, uint64_t max_threads); +uint64_t OSSL_get_max_threads(OSSL_LIB_CTX *ctx); + +# ifdef __cplusplus +} +# endif + +#endif /* OPENSSL_THREAD_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/tls1.h b/illumos-x86_64/usr/include/openssl-3/tls1.h new file mode 100644 index 00000000..8e9b110b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/tls1.h @@ -0,0 +1,1220 @@ +/* + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * Copyright 2005 Nokia. All rights reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_TLS1_H +# define OPENSSL_TLS1_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_TLS1_H +# endif + +# include +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Default security level if not overridden at config time */ +# ifndef OPENSSL_TLS_SECURITY_LEVEL +# define OPENSSL_TLS_SECURITY_LEVEL 2 +# endif + +/* TLS*_VERSION constants are defined in prov_ssl.h */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define TLS_MAX_VERSION TLS1_3_VERSION +# endif + +/* Special value for method supporting multiple versions */ +# define TLS_ANY_VERSION 0x10000 + +# define TLS1_VERSION_MAJOR 0x03 +# define TLS1_VERSION_MINOR 0x01 + +# define TLS1_1_VERSION_MAJOR 0x03 +# define TLS1_1_VERSION_MINOR 0x02 + +# define TLS1_2_VERSION_MAJOR 0x03 +# define TLS1_2_VERSION_MINOR 0x03 + +# define TLS1_get_version(s) \ + ((SSL_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_version(s) : 0) + +# define TLS1_get_client_version(s) \ + ((SSL_client_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_client_version(s) : 0) + +# define TLS1_AD_DECRYPTION_FAILED 21 +# define TLS1_AD_RECORD_OVERFLOW 22 +# define TLS1_AD_UNKNOWN_CA 48/* fatal */ +# define TLS1_AD_ACCESS_DENIED 49/* fatal */ +# define TLS1_AD_DECODE_ERROR 50/* fatal */ +# define TLS1_AD_DECRYPT_ERROR 51 +# define TLS1_AD_EXPORT_RESTRICTION 60/* fatal */ +# define TLS1_AD_PROTOCOL_VERSION 70/* fatal */ +# define TLS1_AD_INSUFFICIENT_SECURITY 71/* fatal */ +# define TLS1_AD_INTERNAL_ERROR 80/* fatal */ +# define TLS1_AD_INAPPROPRIATE_FALLBACK 86/* fatal */ +# define TLS1_AD_USER_CANCELLED 90 +# define TLS1_AD_NO_RENEGOTIATION 100 +/* TLSv1.3 alerts */ +# define TLS13_AD_MISSING_EXTENSION 109 /* fatal */ +# define TLS13_AD_CERTIFICATE_REQUIRED 116 /* fatal */ +/* codes 110-114 are from RFC3546 */ +# define TLS1_AD_UNSUPPORTED_EXTENSION 110 +# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111 +# define TLS1_AD_UNRECOGNIZED_NAME 112 +# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113 +# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114 +# define TLS1_AD_UNKNOWN_PSK_IDENTITY 115/* fatal */ +# define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */ + +/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */ +# define TLSEXT_TYPE_server_name 0 +# define TLSEXT_TYPE_max_fragment_length 1 +# define TLSEXT_TYPE_client_certificate_url 2 +# define TLSEXT_TYPE_trusted_ca_keys 3 +# define TLSEXT_TYPE_truncated_hmac 4 +# define TLSEXT_TYPE_status_request 5 +/* ExtensionType values from RFC4681 */ +# define TLSEXT_TYPE_user_mapping 6 +/* ExtensionType values from RFC5878 */ +# define TLSEXT_TYPE_client_authz 7 +# define TLSEXT_TYPE_server_authz 8 +/* ExtensionType values from RFC6091 */ +# define TLSEXT_TYPE_cert_type 9 + +/* ExtensionType values from RFC4492 */ +/* + * Prior to TLSv1.3 the supported_groups extension was known as + * elliptic_curves + */ +# define TLSEXT_TYPE_supported_groups 10 +# define TLSEXT_TYPE_elliptic_curves TLSEXT_TYPE_supported_groups +# define TLSEXT_TYPE_ec_point_formats 11 + + +/* ExtensionType value from RFC5054 */ +# define TLSEXT_TYPE_srp 12 + +/* ExtensionType values from RFC5246 */ +# define TLSEXT_TYPE_signature_algorithms 13 + +/* ExtensionType value from RFC5764 */ +# define TLSEXT_TYPE_use_srtp 14 + +/* ExtensionType value from RFC7301 */ +# define TLSEXT_TYPE_application_layer_protocol_negotiation 16 + +/* + * Extension type for Certificate Transparency + * https://tools.ietf.org/html/rfc6962#section-3.3.1 + */ +# define TLSEXT_TYPE_signed_certificate_timestamp 18 + +/* + * Extension type for Raw Public Keys + * https://tools.ietf.org/html/rfc7250 + * https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml + */ +# define TLSEXT_TYPE_client_cert_type 19 +# define TLSEXT_TYPE_server_cert_type 20 + +/* + * ExtensionType value for TLS padding extension. + * http://tools.ietf.org/html/draft-agl-tls-padding + */ +# define TLSEXT_TYPE_padding 21 + +/* ExtensionType value from RFC7366 */ +# define TLSEXT_TYPE_encrypt_then_mac 22 + +/* ExtensionType value from RFC7627 */ +# define TLSEXT_TYPE_extended_master_secret 23 + +/* ExtensionType value from RFC8879 */ +# define TLSEXT_TYPE_compress_certificate 27 + +/* ExtensionType value from RFC4507 */ +# define TLSEXT_TYPE_session_ticket 35 + +/* As defined for TLS1.3 */ +# define TLSEXT_TYPE_psk 41 +# define TLSEXT_TYPE_early_data 42 +# define TLSEXT_TYPE_supported_versions 43 +# define TLSEXT_TYPE_cookie 44 +# define TLSEXT_TYPE_psk_kex_modes 45 +# define TLSEXT_TYPE_certificate_authorities 47 +# define TLSEXT_TYPE_post_handshake_auth 49 +# define TLSEXT_TYPE_signature_algorithms_cert 50 +# define TLSEXT_TYPE_key_share 51 +# define TLSEXT_TYPE_quic_transport_parameters 57 + +/* Temporary extension type */ +# define TLSEXT_TYPE_renegotiate 0xff01 + +# ifndef OPENSSL_NO_NEXTPROTONEG +/* This is not an IANA defined extension number */ +# define TLSEXT_TYPE_next_proto_neg 13172 +# endif + +/* NameType value from RFC3546 */ +# define TLSEXT_NAMETYPE_host_name 0 +/* status request value from RFC3546 */ +# define TLSEXT_STATUSTYPE_ocsp 1 + +/* ECPointFormat values from RFC4492 */ +# define TLSEXT_ECPOINTFORMAT_first 0 +# define TLSEXT_ECPOINTFORMAT_uncompressed 0 +# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 +# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 +# define TLSEXT_ECPOINTFORMAT_last 2 + +/* Signature and hash algorithms from RFC5246 */ +# define TLSEXT_signature_anonymous 0 +# define TLSEXT_signature_rsa 1 +# define TLSEXT_signature_dsa 2 +# define TLSEXT_signature_ecdsa 3 +# define TLSEXT_signature_gostr34102001 237 +# define TLSEXT_signature_gostr34102012_256 238 +# define TLSEXT_signature_gostr34102012_512 239 + +/* Total number of different signature algorithms */ +# define TLSEXT_signature_num 7 + +# define TLSEXT_hash_none 0 +# define TLSEXT_hash_md5 1 +# define TLSEXT_hash_sha1 2 +# define TLSEXT_hash_sha224 3 +# define TLSEXT_hash_sha256 4 +# define TLSEXT_hash_sha384 5 +# define TLSEXT_hash_sha512 6 +# define TLSEXT_hash_gostr3411 237 +# define TLSEXT_hash_gostr34112012_256 238 +# define TLSEXT_hash_gostr34112012_512 239 + +/* Total number of different digest algorithms */ + +# define TLSEXT_hash_num 10 + +/* Possible compression values from RFC8879 */ +/* Not defined in RFC8879, but used internally for no-compression */ +# define TLSEXT_comp_cert_none 0 +# define TLSEXT_comp_cert_zlib 1 +# define TLSEXT_comp_cert_brotli 2 +# define TLSEXT_comp_cert_zstd 3 +/* one more than the number of defined values - used as size of 0-terminated array */ +# define TLSEXT_comp_cert_limit 4 + +/* Flag set for unrecognised algorithms */ +# define TLSEXT_nid_unknown 0x1000000 + +/* ECC curves */ + +# define TLSEXT_curve_P_256 23 +# define TLSEXT_curve_P_384 24 + +/* OpenSSL value to disable maximum fragment length extension */ +# define TLSEXT_max_fragment_length_DISABLED 0 +/* Allowed values for max fragment length extension */ +# define TLSEXT_max_fragment_length_512 1 +# define TLSEXT_max_fragment_length_1024 2 +# define TLSEXT_max_fragment_length_2048 3 +# define TLSEXT_max_fragment_length_4096 4 +/* OpenSSL value for unset maximum fragment length extension */ +# define TLSEXT_max_fragment_length_UNSPECIFIED 255 + +/* + * TLS Certificate Type (for RFC7250) + * https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#tls-extensiontype-values-3 + */ +# define TLSEXT_cert_type_x509 0 +# define TLSEXT_cert_type_pgp 1 /* recognized, but not supported */ +# define TLSEXT_cert_type_rpk 2 +# define TLSEXT_cert_type_1609dot2 3 /* recognized, but not supported */ + +int SSL_CTX_set_tlsext_max_fragment_length(SSL_CTX *ctx, uint8_t mode); +int SSL_set_tlsext_max_fragment_length(SSL *ssl, uint8_t mode); + +# define TLSEXT_MAXLEN_host_name 255 + +__owur const char *SSL_get_servername(const SSL *s, const int type); +__owur int SSL_get_servername_type(const SSL *s); +/* + * SSL_export_keying_material exports a value derived from the master secret, + * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and + * optional context. (Since a zero length context is allowed, the |use_context| + * flag controls whether a context is included.) It returns 1 on success and + * 0 or -1 otherwise. + */ +__owur int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, + const char *label, size_t llen, + const unsigned char *context, + size_t contextlen, int use_context); + +/* + * SSL_export_keying_material_early exports a value derived from the + * early exporter master secret, as specified in + * https://tools.ietf.org/html/draft-ietf-tls-tls13-23. It writes + * |olen| bytes to |out| given a label and optional context. It + * returns 1 on success and 0 otherwise. + */ +__owur int SSL_export_keying_material_early(SSL *s, unsigned char *out, + size_t olen, const char *label, + size_t llen, + const unsigned char *context, + size_t contextlen); + +int SSL_get_peer_signature_type_nid(const SSL *s, int *pnid); +int SSL_get_signature_type_nid(const SSL *s, int *pnid); + +int SSL_get_sigalgs(SSL *s, int idx, + int *psign, int *phash, int *psignandhash, + unsigned char *rsig, unsigned char *rhash); + +char *SSL_get1_builtin_sigalgs(OSSL_LIB_CTX *libctx); + +int SSL_get_shared_sigalgs(SSL *s, int idx, + int *psign, int *phash, int *psignandhash, + unsigned char *rsig, unsigned char *rhash); + +__owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain); + +# define SSL_set_tlsext_host_name(s,name) \ + SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,\ + (void *)name) + +# define SSL_set_tlsext_debug_callback(ssl, cb) \ + SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,\ + (void (*)(void))cb) + +# define SSL_set_tlsext_debug_arg(ssl, arg) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0,arg) + +# define SSL_get_tlsext_status_type(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0,NULL) + +# define SSL_set_tlsext_status_type(ssl, type) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type,NULL) + +# define SSL_get_tlsext_status_exts(ssl, arg) \ + SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0,arg) + +# define SSL_set_tlsext_status_exts(ssl, arg) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0,arg) + +# define SSL_get_tlsext_status_ids(ssl, arg) \ + SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0,arg) + +# define SSL_set_tlsext_status_ids(ssl, arg) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0,arg) + +# define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \ + SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0,arg) + +# define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen,arg) + +# define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \ + SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,\ + (void (*)(void))cb) + +# define SSL_TLSEXT_ERR_OK 0 +# define SSL_TLSEXT_ERR_ALERT_WARNING 1 +# define SSL_TLSEXT_ERR_ALERT_FATAL 2 +# define SSL_TLSEXT_ERR_NOACK 3 + +# define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0,arg) + +# define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_TLSEXT_TICKET_KEYS,keylen,keys) +# define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_TICKET_KEYS,keylen,keys) + +# define SSL_CTX_get_tlsext_status_cb(ssl, cb) \ + SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB,0,(void *)cb) +# define SSL_CTX_set_tlsext_status_cb(ssl, cb) \ + SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,\ + (void (*)(void))cb) + +# define SSL_CTX_get_tlsext_status_arg(ssl, arg) \ + SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG,0,arg) +# define SSL_CTX_set_tlsext_status_arg(ssl, arg) \ + SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0,arg) + +# define SSL_CTX_set_tlsext_status_type(ssl, type) \ + SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type,NULL) + +# define SSL_CTX_get_tlsext_status_type(ssl) \ + SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0,NULL) + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \ + SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,\ + (void (*)(void))cb) +# endif +int SSL_CTX_set_tlsext_ticket_key_evp_cb + (SSL_CTX *ctx, int (*fp)(SSL *, unsigned char *, unsigned char *, + EVP_CIPHER_CTX *, EVP_MAC_CTX *, int)); + +/* PSK ciphersuites from 4279 */ +# define TLS1_CK_PSK_WITH_RC4_128_SHA 0x0300008A +# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008B +# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA 0x0300008C +# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA 0x0300008D +# define TLS1_CK_DHE_PSK_WITH_RC4_128_SHA 0x0300008E +# define TLS1_CK_DHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008F +# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA 0x03000090 +# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA 0x03000091 +# define TLS1_CK_RSA_PSK_WITH_RC4_128_SHA 0x03000092 +# define TLS1_CK_RSA_PSK_WITH_3DES_EDE_CBC_SHA 0x03000093 +# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA 0x03000094 +# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA 0x03000095 + +/* PSK ciphersuites from 5487 */ +# define TLS1_CK_PSK_WITH_AES_128_GCM_SHA256 0x030000A8 +# define TLS1_CK_PSK_WITH_AES_256_GCM_SHA384 0x030000A9 +# define TLS1_CK_DHE_PSK_WITH_AES_128_GCM_SHA256 0x030000AA +# define TLS1_CK_DHE_PSK_WITH_AES_256_GCM_SHA384 0x030000AB +# define TLS1_CK_RSA_PSK_WITH_AES_128_GCM_SHA256 0x030000AC +# define TLS1_CK_RSA_PSK_WITH_AES_256_GCM_SHA384 0x030000AD +# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA256 0x030000AE +# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA384 0x030000AF +# define TLS1_CK_PSK_WITH_NULL_SHA256 0x030000B0 +# define TLS1_CK_PSK_WITH_NULL_SHA384 0x030000B1 +# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA256 0x030000B2 +# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA384 0x030000B3 +# define TLS1_CK_DHE_PSK_WITH_NULL_SHA256 0x030000B4 +# define TLS1_CK_DHE_PSK_WITH_NULL_SHA384 0x030000B5 +# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA256 0x030000B6 +# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA384 0x030000B7 +# define TLS1_CK_RSA_PSK_WITH_NULL_SHA256 0x030000B8 +# define TLS1_CK_RSA_PSK_WITH_NULL_SHA384 0x030000B9 + +/* NULL PSK ciphersuites from RFC4785 */ +# define TLS1_CK_PSK_WITH_NULL_SHA 0x0300002C +# define TLS1_CK_DHE_PSK_WITH_NULL_SHA 0x0300002D +# define TLS1_CK_RSA_PSK_WITH_NULL_SHA 0x0300002E + +/* AES ciphersuites from RFC3268 */ +# define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F +# define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 +# define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 +# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 +# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 +# define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 +# define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 +# define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 +# define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 +# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 +# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 +# define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A + +/* TLS v1.2 ciphersuites */ +# define TLS1_CK_RSA_WITH_NULL_SHA256 0x0300003B +# define TLS1_CK_RSA_WITH_AES_128_SHA256 0x0300003C +# define TLS1_CK_RSA_WITH_AES_256_SHA256 0x0300003D +# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256 0x0300003E +# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256 0x0300003F +# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256 0x03000040 + +/* Camellia ciphersuites from RFC4132 */ +# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041 +# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042 +# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043 +# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044 +# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045 +# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046 + +/* TLS v1.2 ciphersuites */ +# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256 0x03000067 +# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256 0x03000068 +# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256 0x03000069 +# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256 0x0300006A +# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256 0x0300006B +# define TLS1_CK_ADH_WITH_AES_128_SHA256 0x0300006C +# define TLS1_CK_ADH_WITH_AES_256_SHA256 0x0300006D + +/* Camellia ciphersuites from RFC4132 */ +# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084 +# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085 +# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086 +# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087 +# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088 +# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089 + +/* SEED ciphersuites from RFC4162 */ +# define TLS1_CK_RSA_WITH_SEED_SHA 0x03000096 +# define TLS1_CK_DH_DSS_WITH_SEED_SHA 0x03000097 +# define TLS1_CK_DH_RSA_WITH_SEED_SHA 0x03000098 +# define TLS1_CK_DHE_DSS_WITH_SEED_SHA 0x03000099 +# define TLS1_CK_DHE_RSA_WITH_SEED_SHA 0x0300009A +# define TLS1_CK_ADH_WITH_SEED_SHA 0x0300009B + +/* TLS v1.2 GCM ciphersuites from RFC5288 */ +# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 0x0300009C +# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 0x0300009D +# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256 0x0300009E +# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384 0x0300009F +# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256 0x030000A0 +# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384 0x030000A1 +# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256 0x030000A2 +# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384 0x030000A3 +# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256 0x030000A4 +# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384 0x030000A5 +# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256 0x030000A6 +# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384 0x030000A7 + +/* CCM ciphersuites from RFC6655 */ +# define TLS1_CK_RSA_WITH_AES_128_CCM 0x0300C09C +# define TLS1_CK_RSA_WITH_AES_256_CCM 0x0300C09D +# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM 0x0300C09E +# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM 0x0300C09F +# define TLS1_CK_RSA_WITH_AES_128_CCM_8 0x0300C0A0 +# define TLS1_CK_RSA_WITH_AES_256_CCM_8 0x0300C0A1 +# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM_8 0x0300C0A2 +# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM_8 0x0300C0A3 +# define TLS1_CK_PSK_WITH_AES_128_CCM 0x0300C0A4 +# define TLS1_CK_PSK_WITH_AES_256_CCM 0x0300C0A5 +# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM 0x0300C0A6 +# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM 0x0300C0A7 +# define TLS1_CK_PSK_WITH_AES_128_CCM_8 0x0300C0A8 +# define TLS1_CK_PSK_WITH_AES_256_CCM_8 0x0300C0A9 +# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM_8 0x0300C0AA +# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM_8 0x0300C0AB + +/* CCM ciphersuites from RFC7251 */ +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM 0x0300C0AC +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM 0x0300C0AD +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM_8 0x0300C0AE +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM_8 0x0300C0AF + +/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */ +# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BA +# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 0x030000BB +# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BC +# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 0x030000BD +# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BE +# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256 0x030000BF + +# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C0 +# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 0x030000C1 +# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C2 +# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 0x030000C3 +# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C4 +# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256 0x030000C5 + +/* ECC ciphersuites from RFC4492 */ +# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 +# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 +# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 +# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 +# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 + +# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 +# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 +# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A + +# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B +# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C +# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D +# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E +# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F + +# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 +# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 +# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 +# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 +# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 + +# define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 +# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 +# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 +# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 +# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 + +/* SRP ciphersuites from RFC 5054 */ +# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA 0x0300C01A +# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA 0x0300C01B +# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA 0x0300C01C +# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA 0x0300C01D +# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA 0x0300C01E +# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA 0x0300C01F +# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA 0x0300C020 +# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA 0x0300C021 +# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA 0x0300C022 + +/* ECDH HMAC based ciphersuites from RFC5289 */ +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256 0x0300C023 +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384 0x0300C024 +# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256 0x0300C025 +# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384 0x0300C026 +# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256 0x0300C027 +# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384 0x0300C028 +# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256 0x0300C029 +# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384 0x0300C02A + +/* ECDH GCM based ciphersuites from RFC5289 */ +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02B +# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02C +# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02D +# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02E +# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0x0300C02F +# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0x0300C030 +# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256 0x0300C031 +# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384 0x0300C032 + +/* ECDHE PSK ciphersuites from RFC5489 */ +# define TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA 0x0300C033 +# define TLS1_CK_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300C034 +# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA 0x0300C035 +# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA 0x0300C036 + +# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0x0300C037 +# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA384 0x0300C038 + +/* NULL PSK ciphersuites from RFC4785 */ +# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA 0x0300C039 +# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA256 0x0300C03A +# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA384 0x0300C03B + +/* Camellia-CBC ciphersuites from RFC6367 */ +# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C072 +# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C073 +# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C074 +# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C075 +# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C076 +# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C077 +# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C078 +# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C079 + +# define TLS1_CK_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C094 +# define TLS1_CK_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C095 +# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C096 +# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C097 +# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C098 +# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C099 +# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C09A +# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C09B + +/* draft-ietf-tls-chacha20-poly1305-03 */ +# define TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCA8 +# define TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 0x0300CCA9 +# define TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCAA +# define TLS1_CK_PSK_WITH_CHACHA20_POLY1305 0x0300CCAB +# define TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305 0x0300CCAC +# define TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305 0x0300CCAD +# define TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305 0x0300CCAE + +/* TLS v1.3 ciphersuites */ +# define TLS1_3_CK_AES_128_GCM_SHA256 0x03001301 +# define TLS1_3_CK_AES_256_GCM_SHA384 0x03001302 +# define TLS1_3_CK_CHACHA20_POLY1305_SHA256 0x03001303 +# define TLS1_3_CK_AES_128_CCM_SHA256 0x03001304 +# define TLS1_3_CK_AES_128_CCM_8_SHA256 0x03001305 + +/* Integrity-only ciphersuites from RFC 9150 */ +# define TLS1_3_CK_SHA256_SHA256 0x0300C0B4 +# define TLS1_3_CK_SHA384_SHA384 0x0300C0B5 + +/* Aria ciphersuites from RFC6209 */ +# define TLS1_CK_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C050 +# define TLS1_CK_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C051 +# define TLS1_CK_DHE_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C052 +# define TLS1_CK_DHE_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C053 +# define TLS1_CK_DH_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C054 +# define TLS1_CK_DH_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C055 +# define TLS1_CK_DHE_DSS_WITH_ARIA_128_GCM_SHA256 0x0300C056 +# define TLS1_CK_DHE_DSS_WITH_ARIA_256_GCM_SHA384 0x0300C057 +# define TLS1_CK_DH_DSS_WITH_ARIA_128_GCM_SHA256 0x0300C058 +# define TLS1_CK_DH_DSS_WITH_ARIA_256_GCM_SHA384 0x0300C059 +# define TLS1_CK_DH_anon_WITH_ARIA_128_GCM_SHA256 0x0300C05A +# define TLS1_CK_DH_anon_WITH_ARIA_256_GCM_SHA384 0x0300C05B +# define TLS1_CK_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 0x0300C05C +# define TLS1_CK_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 0x0300C05D +# define TLS1_CK_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 0x0300C05E +# define TLS1_CK_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 0x0300C05F +# define TLS1_CK_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C060 +# define TLS1_CK_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C061 +# define TLS1_CK_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C062 +# define TLS1_CK_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C063 +# define TLS1_CK_PSK_WITH_ARIA_128_GCM_SHA256 0x0300C06A +# define TLS1_CK_PSK_WITH_ARIA_256_GCM_SHA384 0x0300C06B +# define TLS1_CK_DHE_PSK_WITH_ARIA_128_GCM_SHA256 0x0300C06C +# define TLS1_CK_DHE_PSK_WITH_ARIA_256_GCM_SHA384 0x0300C06D +# define TLS1_CK_RSA_PSK_WITH_ARIA_128_GCM_SHA256 0x0300C06E +# define TLS1_CK_RSA_PSK_WITH_ARIA_256_GCM_SHA384 0x0300C06F + +/* a bundle of RFC standard cipher names, generated from ssl3_ciphers[] */ +# define TLS1_RFC_RSA_WITH_AES_128_SHA "TLS_RSA_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA "TLS_DHE_DSS_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_ADH_WITH_AES_128_SHA "TLS_DH_anon_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_RSA_WITH_AES_256_SHA "TLS_RSA_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA "TLS_DHE_RSA_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_ADH_WITH_AES_256_SHA "TLS_DH_anon_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_RSA_WITH_NULL_SHA256 "TLS_RSA_WITH_NULL_SHA256" +# define TLS1_RFC_RSA_WITH_AES_128_SHA256 "TLS_RSA_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_RSA_WITH_AES_256_SHA256 "TLS_RSA_WITH_AES_256_CBC_SHA256" +# define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA256 "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA256 "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA256 "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" +# define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA256 "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256" +# define TLS1_RFC_ADH_WITH_AES_128_SHA256 "TLS_DH_anon_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_ADH_WITH_AES_256_SHA256 "TLS_DH_anon_WITH_AES_256_CBC_SHA256" +# define TLS1_RFC_RSA_WITH_AES_128_GCM_SHA256 "TLS_RSA_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_RSA_WITH_AES_256_GCM_SHA384 "TLS_RSA_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_DHE_RSA_WITH_AES_128_GCM_SHA256 "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_DHE_RSA_WITH_AES_256_GCM_SHA384 "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_DHE_DSS_WITH_AES_128_GCM_SHA256 "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_DHE_DSS_WITH_AES_256_GCM_SHA384 "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_ADH_WITH_AES_128_GCM_SHA256 "TLS_DH_anon_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_ADH_WITH_AES_256_GCM_SHA384 "TLS_DH_anon_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_RSA_WITH_AES_128_CCM "TLS_RSA_WITH_AES_128_CCM" +# define TLS1_RFC_RSA_WITH_AES_256_CCM "TLS_RSA_WITH_AES_256_CCM" +# define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM "TLS_DHE_RSA_WITH_AES_128_CCM" +# define TLS1_RFC_DHE_RSA_WITH_AES_256_CCM "TLS_DHE_RSA_WITH_AES_256_CCM" +# define TLS1_RFC_RSA_WITH_AES_128_CCM_8 "TLS_RSA_WITH_AES_128_CCM_8" +# define TLS1_RFC_RSA_WITH_AES_256_CCM_8 "TLS_RSA_WITH_AES_256_CCM_8" +# define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM_8 "TLS_DHE_RSA_WITH_AES_128_CCM_8" +# define TLS1_RFC_DHE_RSA_WITH_AES_256_CCM_8 "TLS_DHE_RSA_WITH_AES_256_CCM_8" +# define TLS1_RFC_PSK_WITH_AES_128_CCM "TLS_PSK_WITH_AES_128_CCM" +# define TLS1_RFC_PSK_WITH_AES_256_CCM "TLS_PSK_WITH_AES_256_CCM" +# define TLS1_RFC_DHE_PSK_WITH_AES_128_CCM "TLS_DHE_PSK_WITH_AES_128_CCM" +# define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM "TLS_DHE_PSK_WITH_AES_256_CCM" +# define TLS1_RFC_PSK_WITH_AES_128_CCM_8 "TLS_PSK_WITH_AES_128_CCM_8" +# define TLS1_RFC_PSK_WITH_AES_256_CCM_8 "TLS_PSK_WITH_AES_256_CCM_8" +# define TLS1_RFC_DHE_PSK_WITH_AES_128_CCM_8 "TLS_PSK_DHE_WITH_AES_128_CCM_8" +# define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM_8 "TLS_PSK_DHE_WITH_AES_256_CCM_8" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM "TLS_ECDHE_ECDSA_WITH_AES_128_CCM" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM "TLS_ECDHE_ECDSA_WITH_AES_256_CCM" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM_8 "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM_8 "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8" +# define TLS1_3_RFC_AES_128_GCM_SHA256 "TLS_AES_128_GCM_SHA256" +# define TLS1_3_RFC_AES_256_GCM_SHA384 "TLS_AES_256_GCM_SHA384" +# define TLS1_3_RFC_CHACHA20_POLY1305_SHA256 "TLS_CHACHA20_POLY1305_SHA256" +# define TLS1_3_RFC_SHA256_SHA256 "TLS_SHA256_SHA256" +# define TLS1_3_RFC_SHA384_SHA384 "TLS_SHA384_SHA384" +# define TLS1_3_RFC_AES_128_CCM_SHA256 "TLS_AES_128_CCM_SHA256" +# define TLS1_3_RFC_AES_128_CCM_8_SHA256 "TLS_AES_128_CCM_8_SHA256" +# define TLS1_RFC_ECDHE_ECDSA_WITH_NULL_SHA "TLS_ECDHE_ECDSA_WITH_NULL_SHA" +# define TLS1_RFC_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_ECDHE_RSA_WITH_NULL_SHA "TLS_ECDHE_RSA_WITH_NULL_SHA" +# define TLS1_RFC_ECDHE_RSA_WITH_DES_192_CBC3_SHA "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_CBC_SHA "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_CBC_SHA "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_ECDH_anon_WITH_NULL_SHA "TLS_ECDH_anon_WITH_NULL_SHA" +# define TLS1_RFC_ECDH_anon_WITH_DES_192_CBC3_SHA "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_ECDH_anon_WITH_AES_128_CBC_SHA "TLS_ECDH_anon_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_ECDH_anon_WITH_AES_256_CBC_SHA "TLS_ECDH_anon_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_SHA256 "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_SHA384 "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" +# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_SHA256 "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_SHA384 "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_PSK_WITH_NULL_SHA "TLS_PSK_WITH_NULL_SHA" +# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA "TLS_DHE_PSK_WITH_NULL_SHA" +# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA "TLS_RSA_PSK_WITH_NULL_SHA" +# define TLS1_RFC_PSK_WITH_3DES_EDE_CBC_SHA "TLS_PSK_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA "TLS_PSK_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA "TLS_PSK_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_DHE_PSK_WITH_3DES_EDE_CBC_SHA "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA "TLS_DHE_PSK_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA "TLS_DHE_PSK_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_RSA_PSK_WITH_3DES_EDE_CBC_SHA "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA "TLS_RSA_PSK_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA "TLS_RSA_PSK_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_PSK_WITH_AES_128_GCM_SHA256 "TLS_PSK_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_PSK_WITH_AES_256_GCM_SHA384 "TLS_PSK_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_DHE_PSK_WITH_AES_128_GCM_SHA256 "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_DHE_PSK_WITH_AES_256_GCM_SHA384 "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_RSA_PSK_WITH_AES_128_GCM_SHA256 "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256" +# define TLS1_RFC_RSA_PSK_WITH_AES_256_GCM_SHA384 "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384" +# define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA256 "TLS_PSK_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA384 "TLS_PSK_WITH_AES_256_CBC_SHA384" +# define TLS1_RFC_PSK_WITH_NULL_SHA256 "TLS_PSK_WITH_NULL_SHA256" +# define TLS1_RFC_PSK_WITH_NULL_SHA384 "TLS_PSK_WITH_NULL_SHA384" +# define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA256 "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA384 "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384" +# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA256 "TLS_DHE_PSK_WITH_NULL_SHA256" +# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA384 "TLS_DHE_PSK_WITH_NULL_SHA384" +# define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA256 "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA384 "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384" +# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA256 "TLS_RSA_PSK_WITH_NULL_SHA256" +# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA384 "TLS_RSA_PSK_WITH_NULL_SHA384" +# define TLS1_RFC_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA256 "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256" +# define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA384 "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384" +# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA "TLS_ECDHE_PSK_WITH_NULL_SHA" +# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA256 "TLS_ECDHE_PSK_WITH_NULL_SHA256" +# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA384 "TLS_ECDHE_PSK_WITH_NULL_SHA384" +# define TLS1_RFC_SRP_SHA_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA" +# define TLS1_RFC_SRP_SHA_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA" +# define TLS1_RFC_SRP_SHA_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA" +# define TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305 "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256" +# define TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305 "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" +# define TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" +# define TLS1_RFC_PSK_WITH_CHACHA20_POLY1305 "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256" +# define TLS1_RFC_ECDHE_PSK_WITH_CHACHA20_POLY1305 "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256" +# define TLS1_RFC_DHE_PSK_WITH_CHACHA20_POLY1305 "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256" +# define TLS1_RFC_RSA_PSK_WITH_CHACHA20_POLY1305 "TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256" +# define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA256 "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256" +# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256" +# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256" +# define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256" +# define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA" +# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA" +# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA" +# define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA" +# define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA" +# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA" +# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA" +# define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA" +# define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" +# define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384" +# define TLS1_RFC_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384" +# define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" +# define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384" +# define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" +# define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" +# define TLS1_RFC_RSA_WITH_SEED_SHA "TLS_RSA_WITH_SEED_CBC_SHA" +# define TLS1_RFC_DHE_DSS_WITH_SEED_SHA "TLS_DHE_DSS_WITH_SEED_CBC_SHA" +# define TLS1_RFC_DHE_RSA_WITH_SEED_SHA "TLS_DHE_RSA_WITH_SEED_CBC_SHA" +# define TLS1_RFC_ADH_WITH_SEED_SHA "TLS_DH_anon_WITH_SEED_CBC_SHA" +# define TLS1_RFC_ECDHE_PSK_WITH_RC4_128_SHA "TLS_ECDHE_PSK_WITH_RC4_128_SHA" +# define TLS1_RFC_ECDH_anon_WITH_RC4_128_SHA "TLS_ECDH_anon_WITH_RC4_128_SHA" +# define TLS1_RFC_ECDHE_ECDSA_WITH_RC4_128_SHA "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA" +# define TLS1_RFC_ECDHE_RSA_WITH_RC4_128_SHA "TLS_ECDHE_RSA_WITH_RC4_128_SHA" +# define TLS1_RFC_PSK_WITH_RC4_128_SHA "TLS_PSK_WITH_RC4_128_SHA" +# define TLS1_RFC_RSA_PSK_WITH_RC4_128_SHA "TLS_RSA_PSK_WITH_RC4_128_SHA" +# define TLS1_RFC_DHE_PSK_WITH_RC4_128_SHA "TLS_DHE_PSK_WITH_RC4_128_SHA" +# define TLS1_RFC_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_RSA_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_RSA_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_DHE_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_DHE_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_DH_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_DH_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_DHE_DSS_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_DHE_DSS_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_DH_DSS_WITH_ARIA_128_GCM_SHA256 "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_DH_DSS_WITH_ARIA_256_GCM_SHA384 "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_DH_anon_WITH_ARIA_128_GCM_SHA256 "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_DH_anon_WITH_ARIA_256_GCM_SHA384 "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_PSK_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_PSK_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_DHE_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_DHE_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384" +# define TLS1_RFC_RSA_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256" +# define TLS1_RFC_RSA_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384" + + +/* + * XXX Backward compatibility alert: Older versions of OpenSSL gave some DHE + * ciphers names with "EDH" instead of "DHE". Going forward, we should be + * using DHE everywhere, though we may indefinitely maintain aliases for + * users or configurations that used "EDH" + */ +# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" + +# define TLS1_TXT_PSK_WITH_NULL_SHA "PSK-NULL-SHA" +# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA "DHE-PSK-NULL-SHA" +# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA "RSA-PSK-NULL-SHA" + +/* AES ciphersuites from RFC3268 */ +# define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" +# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" +# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" +# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" +# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" +# define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" + +# define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" +# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" +# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" +# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" +# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" +# define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" + +/* ECC ciphersuites from RFC4492 */ +# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" +# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" +# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" +# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" +# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" + +# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" +# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" +# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" + +# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" +# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" +# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" +# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" +# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" + +# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" +# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" +# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" +# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" +# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" + +# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" +# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" +# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" +# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" +# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" + +/* PSK ciphersuites from RFC 4279 */ +# define TLS1_TXT_PSK_WITH_RC4_128_SHA "PSK-RC4-SHA" +# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA "PSK-3DES-EDE-CBC-SHA" +# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA "PSK-AES128-CBC-SHA" +# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA "PSK-AES256-CBC-SHA" + +# define TLS1_TXT_DHE_PSK_WITH_RC4_128_SHA "DHE-PSK-RC4-SHA" +# define TLS1_TXT_DHE_PSK_WITH_3DES_EDE_CBC_SHA "DHE-PSK-3DES-EDE-CBC-SHA" +# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA "DHE-PSK-AES128-CBC-SHA" +# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA "DHE-PSK-AES256-CBC-SHA" +# define TLS1_TXT_RSA_PSK_WITH_RC4_128_SHA "RSA-PSK-RC4-SHA" +# define TLS1_TXT_RSA_PSK_WITH_3DES_EDE_CBC_SHA "RSA-PSK-3DES-EDE-CBC-SHA" +# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA "RSA-PSK-AES128-CBC-SHA" +# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA "RSA-PSK-AES256-CBC-SHA" + +/* PSK ciphersuites from RFC 5487 */ +# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256 "PSK-AES128-GCM-SHA256" +# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384 "PSK-AES256-GCM-SHA384" +# define TLS1_TXT_DHE_PSK_WITH_AES_128_GCM_SHA256 "DHE-PSK-AES128-GCM-SHA256" +# define TLS1_TXT_DHE_PSK_WITH_AES_256_GCM_SHA384 "DHE-PSK-AES256-GCM-SHA384" +# define TLS1_TXT_RSA_PSK_WITH_AES_128_GCM_SHA256 "RSA-PSK-AES128-GCM-SHA256" +# define TLS1_TXT_RSA_PSK_WITH_AES_256_GCM_SHA384 "RSA-PSK-AES256-GCM-SHA384" + +# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA256 "PSK-AES128-CBC-SHA256" +# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA384 "PSK-AES256-CBC-SHA384" +# define TLS1_TXT_PSK_WITH_NULL_SHA256 "PSK-NULL-SHA256" +# define TLS1_TXT_PSK_WITH_NULL_SHA384 "PSK-NULL-SHA384" + +# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA256 "DHE-PSK-AES128-CBC-SHA256" +# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA384 "DHE-PSK-AES256-CBC-SHA384" +# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA256 "DHE-PSK-NULL-SHA256" +# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA384 "DHE-PSK-NULL-SHA384" + +# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA256 "RSA-PSK-AES128-CBC-SHA256" +# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA384 "RSA-PSK-AES256-CBC-SHA384" +# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA256 "RSA-PSK-NULL-SHA256" +# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA384 "RSA-PSK-NULL-SHA384" + +/* SRP ciphersuite from RFC 5054 */ +# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA "SRP-3DES-EDE-CBC-SHA" +# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "SRP-RSA-3DES-EDE-CBC-SHA" +# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "SRP-DSS-3DES-EDE-CBC-SHA" +# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA "SRP-AES-128-CBC-SHA" +# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "SRP-RSA-AES-128-CBC-SHA" +# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "SRP-DSS-AES-128-CBC-SHA" +# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA "SRP-AES-256-CBC-SHA" +# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "SRP-RSA-AES-256-CBC-SHA" +# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "SRP-DSS-AES-256-CBC-SHA" + +/* Camellia ciphersuites from RFC4132 */ +# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA" +# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA" +# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA" +# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA" +# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA" +# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA" + +# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA" +# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA" +# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA" +# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA" +# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA" +# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA" + +/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */ +# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256 "CAMELLIA128-SHA256" +# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DH-DSS-CAMELLIA128-SHA256" +# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DH-RSA-CAMELLIA128-SHA256" +# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DHE-DSS-CAMELLIA128-SHA256" +# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DHE-RSA-CAMELLIA128-SHA256" +# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256 "ADH-CAMELLIA128-SHA256" + +# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256 "CAMELLIA256-SHA256" +# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DH-DSS-CAMELLIA256-SHA256" +# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DH-RSA-CAMELLIA256-SHA256" +# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DHE-DSS-CAMELLIA256-SHA256" +# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DHE-RSA-CAMELLIA256-SHA256" +# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256 "ADH-CAMELLIA256-SHA256" + +# define TLS1_TXT_PSK_WITH_CAMELLIA_128_CBC_SHA256 "PSK-CAMELLIA128-SHA256" +# define TLS1_TXT_PSK_WITH_CAMELLIA_256_CBC_SHA384 "PSK-CAMELLIA256-SHA384" +# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "DHE-PSK-CAMELLIA128-SHA256" +# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "DHE-PSK-CAMELLIA256-SHA384" +# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 "RSA-PSK-CAMELLIA128-SHA256" +# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 "RSA-PSK-CAMELLIA256-SHA384" +# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-PSK-CAMELLIA128-SHA256" +# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-PSK-CAMELLIA256-SHA384" + +/* SEED ciphersuites from RFC4162 */ +# define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA" +# define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA" +# define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA" +# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA "DHE-DSS-SEED-SHA" +# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA "DHE-RSA-SEED-SHA" +# define TLS1_TXT_ADH_WITH_SEED_SHA "ADH-SEED-SHA" + +/* TLS v1.2 ciphersuites */ +# define TLS1_TXT_RSA_WITH_NULL_SHA256 "NULL-SHA256" +# define TLS1_TXT_RSA_WITH_AES_128_SHA256 "AES128-SHA256" +# define TLS1_TXT_RSA_WITH_AES_256_SHA256 "AES256-SHA256" +# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256 "DH-DSS-AES128-SHA256" +# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256 "DH-RSA-AES128-SHA256" +# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256 "DHE-DSS-AES128-SHA256" +# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256 "DHE-RSA-AES128-SHA256" +# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256 "DH-DSS-AES256-SHA256" +# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256 "DH-RSA-AES256-SHA256" +# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256 "DHE-DSS-AES256-SHA256" +# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256 "DHE-RSA-AES256-SHA256" +# define TLS1_TXT_ADH_WITH_AES_128_SHA256 "ADH-AES128-SHA256" +# define TLS1_TXT_ADH_WITH_AES_256_SHA256 "ADH-AES256-SHA256" + +/* TLS v1.2 GCM ciphersuites from RFC5288 */ +# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 "AES128-GCM-SHA256" +# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 "AES256-GCM-SHA384" +# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256 "DHE-RSA-AES128-GCM-SHA256" +# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384 "DHE-RSA-AES256-GCM-SHA384" +# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256 "DH-RSA-AES128-GCM-SHA256" +# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384 "DH-RSA-AES256-GCM-SHA384" +# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256 "DHE-DSS-AES128-GCM-SHA256" +# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384 "DHE-DSS-AES256-GCM-SHA384" +# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256 "DH-DSS-AES128-GCM-SHA256" +# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384 "DH-DSS-AES256-GCM-SHA384" +# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256 "ADH-AES128-GCM-SHA256" +# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384 "ADH-AES256-GCM-SHA384" + +/* CCM ciphersuites from RFC6655 */ +# define TLS1_TXT_RSA_WITH_AES_128_CCM "AES128-CCM" +# define TLS1_TXT_RSA_WITH_AES_256_CCM "AES256-CCM" +# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM "DHE-RSA-AES128-CCM" +# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM "DHE-RSA-AES256-CCM" + +# define TLS1_TXT_RSA_WITH_AES_128_CCM_8 "AES128-CCM8" +# define TLS1_TXT_RSA_WITH_AES_256_CCM_8 "AES256-CCM8" +# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM_8 "DHE-RSA-AES128-CCM8" +# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM_8 "DHE-RSA-AES256-CCM8" + +# define TLS1_TXT_PSK_WITH_AES_128_CCM "PSK-AES128-CCM" +# define TLS1_TXT_PSK_WITH_AES_256_CCM "PSK-AES256-CCM" +# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM "DHE-PSK-AES128-CCM" +# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM "DHE-PSK-AES256-CCM" + +# define TLS1_TXT_PSK_WITH_AES_128_CCM_8 "PSK-AES128-CCM8" +# define TLS1_TXT_PSK_WITH_AES_256_CCM_8 "PSK-AES256-CCM8" +# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM_8 "DHE-PSK-AES128-CCM8" +# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM_8 "DHE-PSK-AES256-CCM8" + +/* CCM ciphersuites from RFC7251 */ +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM "ECDHE-ECDSA-AES128-CCM" +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM "ECDHE-ECDSA-AES256-CCM" +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM_8 "ECDHE-ECDSA-AES128-CCM8" +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM_8 "ECDHE-ECDSA-AES256-CCM8" + +/* ECDH HMAC based ciphersuites from RFC5289 */ +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256 "ECDHE-ECDSA-AES128-SHA256" +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384 "ECDHE-ECDSA-AES256-SHA384" +# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256 "ECDH-ECDSA-AES128-SHA256" +# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384 "ECDH-ECDSA-AES256-SHA384" +# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256 "ECDHE-RSA-AES128-SHA256" +# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384 "ECDHE-RSA-AES256-SHA384" +# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256 "ECDH-RSA-AES128-SHA256" +# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 "ECDH-RSA-AES256-SHA384" + +/* ECDH GCM based ciphersuites from RFC5289 */ +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "ECDHE-ECDSA-AES128-GCM-SHA256" +# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "ECDHE-ECDSA-AES256-GCM-SHA384" +# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 "ECDH-ECDSA-AES128-GCM-SHA256" +# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 "ECDH-ECDSA-AES256-GCM-SHA384" +# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "ECDHE-RSA-AES128-GCM-SHA256" +# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "ECDHE-RSA-AES256-GCM-SHA384" +# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256 "ECDH-RSA-AES128-GCM-SHA256" +# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384 "ECDH-RSA-AES256-GCM-SHA384" + +/* TLS v1.2 PSK GCM ciphersuites from RFC5487 */ +# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256 "PSK-AES128-GCM-SHA256" +# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384 "PSK-AES256-GCM-SHA384" + +/* ECDHE PSK ciphersuites from RFC 5489 */ +# define TLS1_TXT_ECDHE_PSK_WITH_RC4_128_SHA "ECDHE-PSK-RC4-SHA" +# define TLS1_TXT_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA "ECDHE-PSK-3DES-EDE-CBC-SHA" +# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA "ECDHE-PSK-AES128-CBC-SHA" +# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA "ECDHE-PSK-AES256-CBC-SHA" + +# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA256 "ECDHE-PSK-AES128-CBC-SHA256" +# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA384 "ECDHE-PSK-AES256-CBC-SHA384" + +# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA "ECDHE-PSK-NULL-SHA" +# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA256 "ECDHE-PSK-NULL-SHA256" +# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA384 "ECDHE-PSK-NULL-SHA384" + +/* Camellia-CBC ciphersuites from RFC6367 */ +# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-ECDSA-CAMELLIA128-SHA256" +# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-ECDSA-CAMELLIA256-SHA384" +# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-ECDSA-CAMELLIA128-SHA256" +# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-ECDSA-CAMELLIA256-SHA384" +# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-RSA-CAMELLIA128-SHA256" +# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-RSA-CAMELLIA256-SHA384" +# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-RSA-CAMELLIA128-SHA256" +# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-RSA-CAMELLIA256-SHA384" + +/* draft-ietf-tls-chacha20-poly1305-03 */ +# define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305 "ECDHE-RSA-CHACHA20-POLY1305" +# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "ECDHE-ECDSA-CHACHA20-POLY1305" +# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305 "DHE-RSA-CHACHA20-POLY1305" +# define TLS1_TXT_PSK_WITH_CHACHA20_POLY1305 "PSK-CHACHA20-POLY1305" +# define TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305 "ECDHE-PSK-CHACHA20-POLY1305" +# define TLS1_TXT_DHE_PSK_WITH_CHACHA20_POLY1305 "DHE-PSK-CHACHA20-POLY1305" +# define TLS1_TXT_RSA_PSK_WITH_CHACHA20_POLY1305 "RSA-PSK-CHACHA20-POLY1305" + +/* Aria ciphersuites from RFC6209 */ +# define TLS1_TXT_RSA_WITH_ARIA_128_GCM_SHA256 "ARIA128-GCM-SHA256" +# define TLS1_TXT_RSA_WITH_ARIA_256_GCM_SHA384 "ARIA256-GCM-SHA384" +# define TLS1_TXT_DHE_RSA_WITH_ARIA_128_GCM_SHA256 "DHE-RSA-ARIA128-GCM-SHA256" +# define TLS1_TXT_DHE_RSA_WITH_ARIA_256_GCM_SHA384 "DHE-RSA-ARIA256-GCM-SHA384" +# define TLS1_TXT_DH_RSA_WITH_ARIA_128_GCM_SHA256 "DH-RSA-ARIA128-GCM-SHA256" +# define TLS1_TXT_DH_RSA_WITH_ARIA_256_GCM_SHA384 "DH-RSA-ARIA256-GCM-SHA384" +# define TLS1_TXT_DHE_DSS_WITH_ARIA_128_GCM_SHA256 "DHE-DSS-ARIA128-GCM-SHA256" +# define TLS1_TXT_DHE_DSS_WITH_ARIA_256_GCM_SHA384 "DHE-DSS-ARIA256-GCM-SHA384" +# define TLS1_TXT_DH_DSS_WITH_ARIA_128_GCM_SHA256 "DH-DSS-ARIA128-GCM-SHA256" +# define TLS1_TXT_DH_DSS_WITH_ARIA_256_GCM_SHA384 "DH-DSS-ARIA256-GCM-SHA384" +# define TLS1_TXT_DH_anon_WITH_ARIA_128_GCM_SHA256 "ADH-ARIA128-GCM-SHA256" +# define TLS1_TXT_DH_anon_WITH_ARIA_256_GCM_SHA384 "ADH-ARIA256-GCM-SHA384" +# define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 "ECDHE-ECDSA-ARIA128-GCM-SHA256" +# define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 "ECDHE-ECDSA-ARIA256-GCM-SHA384" +# define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 "ECDH-ECDSA-ARIA128-GCM-SHA256" +# define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 "ECDH-ECDSA-ARIA256-GCM-SHA384" +# define TLS1_TXT_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 "ECDHE-ARIA128-GCM-SHA256" +# define TLS1_TXT_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 "ECDHE-ARIA256-GCM-SHA384" +# define TLS1_TXT_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 "ECDH-ARIA128-GCM-SHA256" +# define TLS1_TXT_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 "ECDH-ARIA256-GCM-SHA384" +# define TLS1_TXT_PSK_WITH_ARIA_128_GCM_SHA256 "PSK-ARIA128-GCM-SHA256" +# define TLS1_TXT_PSK_WITH_ARIA_256_GCM_SHA384 "PSK-ARIA256-GCM-SHA384" +# define TLS1_TXT_DHE_PSK_WITH_ARIA_128_GCM_SHA256 "DHE-PSK-ARIA128-GCM-SHA256" +# define TLS1_TXT_DHE_PSK_WITH_ARIA_256_GCM_SHA384 "DHE-PSK-ARIA256-GCM-SHA384" +# define TLS1_TXT_RSA_PSK_WITH_ARIA_128_GCM_SHA256 "RSA-PSK-ARIA128-GCM-SHA256" +# define TLS1_TXT_RSA_PSK_WITH_ARIA_256_GCM_SHA384 "RSA-PSK-ARIA256-GCM-SHA384" + +# define TLS_CT_RSA_SIGN 1 +# define TLS_CT_DSS_SIGN 2 +# define TLS_CT_RSA_FIXED_DH 3 +# define TLS_CT_DSS_FIXED_DH 4 +# define TLS_CT_ECDSA_SIGN 64 +# define TLS_CT_RSA_FIXED_ECDH 65 +# define TLS_CT_ECDSA_FIXED_ECDH 66 +# define TLS_CT_GOST01_SIGN 22 +# define TLS_CT_GOST12_IANA_SIGN 67 +# define TLS_CT_GOST12_IANA_512_SIGN 68 +# define TLS_CT_GOST12_LEGACY_SIGN 238 +# define TLS_CT_GOST12_LEGACY_512_SIGN 239 + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define TLS_CT_GOST12_SIGN TLS_CT_GOST12_LEGACY_SIGN +# define TLS_CT_GOST12_512_SIGN TLS_CT_GOST12_LEGACY_512_SIGN +# endif + +/* + * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see + * comment there) + */ +# define TLS_CT_NUMBER 12 + +# if defined(SSL3_CT_NUMBER) +# if TLS_CT_NUMBER != SSL3_CT_NUMBER +# error "SSL/TLS CT_NUMBER values do not match" +# endif +# endif + +# define TLS1_FINISH_MAC_LENGTH 12 + +# define TLS_MD_MAX_CONST_SIZE 22 + +/* ASCII: "client finished", in hex for EBCDIC compatibility */ +# define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" +# define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 +/* ASCII: "server finished", in hex for EBCDIC compatibility */ +# define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" +# define TLS_MD_SERVER_FINISH_CONST_SIZE 15 +/* ASCII: "server write key", in hex for EBCDIC compatibility */ +# define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" +# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +/* ASCII: "key expansion", in hex for EBCDIC compatibility */ +# define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" +# define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 +/* ASCII: "client write key", in hex for EBCDIC compatibility */ +# define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" +# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 +/* ASCII: "server write key", in hex for EBCDIC compatibility */ +# define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" +# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +/* ASCII: "IV block", in hex for EBCDIC compatibility */ +# define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" +# define TLS_MD_IV_BLOCK_CONST_SIZE 8 +/* ASCII: "master secret", in hex for EBCDIC compatibility */ +# define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" +# define TLS_MD_MASTER_SECRET_CONST_SIZE 13 +/* ASCII: "extended master secret", in hex for EBCDIC compatibility */ +# define TLS_MD_EXTENDED_MASTER_SECRET_CONST "\x65\x78\x74\x65\x6e\x64\x65\x64\x20\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" +# define TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE 22 + +/* TLS Session Ticket extension struct */ +struct tls_session_ticket_ext_st { + unsigned short length; + void *data; +}; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/trace.h b/illumos-x86_64/usr/include/openssl-3/trace.h new file mode 100644 index 00000000..2ca07f74 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/trace.h @@ -0,0 +1,321 @@ +/* + * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_TRACE_H +# define OPENSSL_TRACE_H +# pragma once + +# include + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * TRACE CATEGORIES + */ + +/* + * The trace messages of the OpenSSL libraries are organized into different + * categories. For every trace category, the application can register a separate + * tracer callback. When a callback is registered, a so called trace channel is + * created for this category. This channel consists essentially of an internal + * BIO which sends all trace output it receives to the registered application + * callback. + * + * The ALL category can be used as a fallback category to register a single + * channel which receives the output from all categories. However, if the + * application intends to print the trace channel name in the line prefix, + * it is better to register channels for all categories separately. + * (This is how the openssl application does it.) + */ +# define OSSL_TRACE_CATEGORY_ALL 0 /* The fallback */ +# define OSSL_TRACE_CATEGORY_TRACE 1 +# define OSSL_TRACE_CATEGORY_INIT 2 +# define OSSL_TRACE_CATEGORY_TLS 3 +# define OSSL_TRACE_CATEGORY_TLS_CIPHER 4 +# define OSSL_TRACE_CATEGORY_CONF 5 +# define OSSL_TRACE_CATEGORY_ENGINE_TABLE 6 +# define OSSL_TRACE_CATEGORY_ENGINE_REF_COUNT 7 +# define OSSL_TRACE_CATEGORY_PKCS5V2 8 +# define OSSL_TRACE_CATEGORY_PKCS12_KEYGEN 9 +# define OSSL_TRACE_CATEGORY_PKCS12_DECRYPT 10 +# define OSSL_TRACE_CATEGORY_X509V3_POLICY 11 +# define OSSL_TRACE_CATEGORY_BN_CTX 12 +# define OSSL_TRACE_CATEGORY_CMP 13 +# define OSSL_TRACE_CATEGORY_STORE 14 +# define OSSL_TRACE_CATEGORY_DECODER 15 +# define OSSL_TRACE_CATEGORY_ENCODER 16 +# define OSSL_TRACE_CATEGORY_REF_COUNT 17 +# define OSSL_TRACE_CATEGORY_HTTP 18 +# define OSSL_TRACE_CATEGORY_PROVIDER 19 +# define OSSL_TRACE_CATEGORY_QUERY 20 +# define OSSL_TRACE_CATEGORY_NUM 21 +/* KEEP THIS LIST IN SYNC with trace_categories[] in crypto/trace.c */ + +/* Returns the trace category number for the given |name| */ +int OSSL_trace_get_category_num(const char *name); + +/* Returns the trace category name for the given |num| */ +const char *OSSL_trace_get_category_name(int num); + +/* + * TRACE CONSUMERS + */ + +/* + * Enables tracing for the given |category| by providing a BIO sink + * as |channel|. If a null pointer is passed as |channel|, an existing + * trace channel is removed and tracing for the category is disabled. + * + * Returns 1 on success and 0 on failure + */ +int OSSL_trace_set_channel(int category, BIO* channel); + +/* + * Attach a prefix and a suffix to the given |category|, to be printed at the + * beginning and at the end of each trace output group, i.e. when + * OSSL_trace_begin() and OSSL_trace_end() are called. + * If a null pointer is passed as argument, the existing prefix or suffix is + * removed. + * + * They return 1 on success and 0 on failure + */ +int OSSL_trace_set_prefix(int category, const char *prefix); +int OSSL_trace_set_suffix(int category, const char *suffix); + +/* + * OSSL_trace_cb is the type tracing callback provided by the application. + * It MUST return the number of bytes written, or 0 on error (in other words, + * it can never write zero bytes). + * + * The |buffer| will always contain text, which may consist of several lines. + * The |data| argument points to whatever data was provided by the application + * when registering the tracer function. + * + * The |category| number is given, as well as a |cmd| number, described below. + */ +typedef size_t (*OSSL_trace_cb)(const char *buffer, size_t count, + int category, int cmd, void *data); +/* + * Possible |cmd| numbers. + */ +# define OSSL_TRACE_CTRL_BEGIN 0 +# define OSSL_TRACE_CTRL_WRITE 1 +# define OSSL_TRACE_CTRL_END 2 + +/* + * Enables tracing for the given |category| by creating an internal + * trace channel which sends the output to the given |callback|. + * If a null pointer is passed as callback, an existing trace channel + * is removed and tracing for the category is disabled. + * + * NOTE: OSSL_trace_set_channel() and OSSL_trace_set_callback() are mutually + * exclusive. + * + * Returns 1 on success and 0 on failure + */ +int OSSL_trace_set_callback(int category, OSSL_trace_cb callback, void *data); + +/* + * TRACE PRODUCERS + */ + +/* + * Returns 1 if tracing for the specified category is enabled, otherwise 0 + */ +int OSSL_trace_enabled(int category); + +/* + * Wrap a group of tracing output calls. OSSL_trace_begin() locks tracing and + * returns the trace channel associated with the given category, or NULL if no + * channel is associated with the category. OSSL_trace_end() unlocks tracing. + * + * Usage: + * + * BIO *out; + * if ((out = OSSL_trace_begin(category)) != NULL) { + * ... + * BIO_fprintf(out, ...); + * ... + * OSSL_trace_end(category, out); + * } + * + * See also the convenience macros OSSL_TRACE_BEGIN and OSSL_TRACE_END below. + */ +BIO *OSSL_trace_begin(int category); +void OSSL_trace_end(int category, BIO *channel); + +/* + * OSSL_TRACE* Convenience Macros + */ + +/* + * When the tracing feature is disabled, these macros are defined to + * produce dead code, which a good compiler should eliminate. + */ + +/* + * OSSL_TRACE_BEGIN, OSSL_TRACE_END - Define a Trace Group + * + * These two macros can be used to create a block which is executed only + * if the corresponding trace category is enabled. Inside this block, a + * local variable named |trc_out| is defined, which points to the channel + * associated with the given trace category. + * + * Usage: (using 'TLS' as an example category) + * + * OSSL_TRACE_BEGIN(TLS) { + * + * BIO_fprintf(trc_out, ... ); + * + * } OSSL_TRACE_END(TLS); + * + * + * This expands to the following code + * + * do { + * BIO *trc_out = OSSL_trace_begin(OSSL_TRACE_CATEGORY_TLS); + * if (trc_out != NULL) { + * ... + * BIO_fprintf(trc_out, ...); + * } + * OSSL_trace_end(OSSL_TRACE_CATEGORY_TLS, trc_out); + * } while (0); + * + * The use of the inner '{...}' group and the trailing ';' is enforced + * by the definition of the macros in order to make the code look as much + * like C code as possible. + * + * Before returning from inside the trace block, it is necessary to + * call OSSL_TRACE_CANCEL(category). + */ + +# if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE + +# define OSSL_TRACE_BEGIN(category) \ + do { \ + BIO *trc_out = OSSL_trace_begin(OSSL_TRACE_CATEGORY_##category); \ + \ + if (trc_out != NULL) + +# define OSSL_TRACE_END(category) \ + OSSL_trace_end(OSSL_TRACE_CATEGORY_##category, trc_out); \ + } while (0) + +# define OSSL_TRACE_CANCEL(category) \ + OSSL_trace_end(OSSL_TRACE_CATEGORY_##category, trc_out) \ + +# else + +# define OSSL_TRACE_BEGIN(category) \ + do { \ + BIO *trc_out = NULL; \ + if (0) + +# define OSSL_TRACE_END(category) \ + } while(0) + +# define OSSL_TRACE_CANCEL(category) \ + ((void)0) + +# endif + +/* + * OSSL_TRACE_ENABLED() - Check whether tracing is enabled for |category| + * + * Usage: + * + * if (OSSL_TRACE_ENABLED(TLS)) { + * ... + * } + */ +# if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE + +# define OSSL_TRACE_ENABLED(category) \ + OSSL_trace_enabled(OSSL_TRACE_CATEGORY_##category) + +# else + +# define OSSL_TRACE_ENABLED(category) (0) + +# endif + +/* + * OSSL_TRACE*() - OneShot Trace Macros + * + * These macros are intended to produce a simple printf-style trace output. + * Unfortunately, C90 macros don't support variable arguments, so the + * "vararg" OSSL_TRACEV() macro has a rather weird usage pattern: + * + * OSSL_TRACEV(category, (trc_out, "format string", ...args...)); + * + * Where 'channel' is the literal symbol of this name, not a variable. + * For that reason, it is currently not intended to be used directly, + * but only as helper macro for the other oneshot trace macros + * OSSL_TRACE(), OSSL_TRACE1(), OSSL_TRACE2(), ... + * + * Usage: + * + * OSSL_TRACE(INIT, "Hello world!\n"); + * OSSL_TRACE1(TLS, "The answer is %d\n", 42); + * OSSL_TRACE2(TLS, "The ultimate question to answer %d is '%s'\n", + * 42, "What do you get when you multiply six by nine?"); + */ + +# if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE + +# define OSSL_TRACEV(category, args) \ + OSSL_TRACE_BEGIN(category) \ + BIO_printf args; \ + OSSL_TRACE_END(category) + +# else + +# define OSSL_TRACEV(category, args) ((void)0) + +# endif + +# define OSSL_TRACE(category, text) \ + OSSL_TRACEV(category, (trc_out, "%s", text)) + +# define OSSL_TRACE1(category, format, arg1) \ + OSSL_TRACEV(category, (trc_out, format, arg1)) +# define OSSL_TRACE2(category, format, arg1, arg2) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2)) +# define OSSL_TRACE3(category, format, arg1, arg2, arg3) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3)) +# define OSSL_TRACE4(category, format, arg1, arg2, arg3, arg4) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4)) +# define OSSL_TRACE5(category, format, arg1, arg2, arg3, arg4, arg5) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5)) +# define OSSL_TRACE6(category, format, arg1, arg2, arg3, arg4, arg5, arg6) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6)) +# define OSSL_TRACE7(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7)) +# define OSSL_TRACE8(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)) +# define OSSL_TRACE9(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)) + +#define OSSL_TRACE_STRING_MAX 80 +int OSSL_trace_string(BIO *out, int text, int full, + const unsigned char *data, size_t size); +#define OSSL_TRACE_STRING(category, text, full, data, len) \ + OSSL_TRACE_BEGIN(category) { \ + OSSL_trace_string(trc_out, text, full, data, len); \ + } OSSL_TRACE_END(category) + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/ts.h b/illumos-x86_64/usr/include/openssl-3/ts.h new file mode 100644 index 00000000..31c78b55 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ts.h @@ -0,0 +1,522 @@ +/* + * Copyright 2006-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_TS_H +# define OPENSSL_TS_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_TS_H +# endif + +# include + +# ifndef OPENSSL_NO_TS +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif +# ifdef __cplusplus +extern "C" { +# endif + +typedef struct TS_msg_imprint_st TS_MSG_IMPRINT; +typedef struct TS_req_st TS_REQ; +typedef struct TS_accuracy_st TS_ACCURACY; +typedef struct TS_tst_info_st TS_TST_INFO; + +/* Possible values for status. */ +# define TS_STATUS_GRANTED 0 +# define TS_STATUS_GRANTED_WITH_MODS 1 +# define TS_STATUS_REJECTION 2 +# define TS_STATUS_WAITING 3 +# define TS_STATUS_REVOCATION_WARNING 4 +# define TS_STATUS_REVOCATION_NOTIFICATION 5 + +/* Possible values for failure_info. */ +# define TS_INFO_BAD_ALG 0 +# define TS_INFO_BAD_REQUEST 2 +# define TS_INFO_BAD_DATA_FORMAT 5 +# define TS_INFO_TIME_NOT_AVAILABLE 14 +# define TS_INFO_UNACCEPTED_POLICY 15 +# define TS_INFO_UNACCEPTED_EXTENSION 16 +# define TS_INFO_ADD_INFO_NOT_AVAILABLE 17 +# define TS_INFO_SYSTEM_FAILURE 25 + + +typedef struct TS_status_info_st TS_STATUS_INFO; + +typedef struct TS_resp_st TS_RESP; + +DECLARE_ASN1_ALLOC_FUNCTIONS(TS_REQ) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_REQ, TS_REQ) +DECLARE_ASN1_DUP_FUNCTION(TS_REQ) + +#ifndef OPENSSL_NO_STDIO +TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a); +int i2d_TS_REQ_fp(FILE *fp, const TS_REQ *a); +#endif +TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a); +int i2d_TS_REQ_bio(BIO *fp, const TS_REQ *a); + +DECLARE_ASN1_ALLOC_FUNCTIONS(TS_MSG_IMPRINT) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_MSG_IMPRINT, TS_MSG_IMPRINT) +DECLARE_ASN1_DUP_FUNCTION(TS_MSG_IMPRINT) + +#ifndef OPENSSL_NO_STDIO +TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a); +int i2d_TS_MSG_IMPRINT_fp(FILE *fp, const TS_MSG_IMPRINT *a); +#endif +TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a); +int i2d_TS_MSG_IMPRINT_bio(BIO *bio, const TS_MSG_IMPRINT *a); + +DECLARE_ASN1_ALLOC_FUNCTIONS(TS_RESP) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_RESP, TS_RESP) +DECLARE_ASN1_DUP_FUNCTION(TS_RESP) + +#ifndef OPENSSL_NO_STDIO +TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a); +int i2d_TS_RESP_fp(FILE *fp, const TS_RESP *a); +#endif +TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a); +int i2d_TS_RESP_bio(BIO *bio, const TS_RESP *a); + +DECLARE_ASN1_ALLOC_FUNCTIONS(TS_STATUS_INFO) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_STATUS_INFO, TS_STATUS_INFO) +DECLARE_ASN1_DUP_FUNCTION(TS_STATUS_INFO) + +DECLARE_ASN1_ALLOC_FUNCTIONS(TS_TST_INFO) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_TST_INFO, TS_TST_INFO) +DECLARE_ASN1_DUP_FUNCTION(TS_TST_INFO) +TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token); + +#ifndef OPENSSL_NO_STDIO +TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a); +int i2d_TS_TST_INFO_fp(FILE *fp, const TS_TST_INFO *a); +#endif +TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a); +int i2d_TS_TST_INFO_bio(BIO *bio, const TS_TST_INFO *a); + +DECLARE_ASN1_ALLOC_FUNCTIONS(TS_ACCURACY) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_ACCURACY, TS_ACCURACY) +DECLARE_ASN1_DUP_FUNCTION(TS_ACCURACY) + +int TS_REQ_set_version(TS_REQ *a, long version); +long TS_REQ_get_version(const TS_REQ *a); + +int TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i); +const ASN1_INTEGER *TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *a); + +const STACK_OF(ASN1_UTF8STRING) * +TS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a); + +const ASN1_BIT_STRING * +TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a); + +int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint); +TS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a); + +int TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg); +X509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a); + +int TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len); +ASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a); + +int TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy); +ASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a); + +int TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce); +const ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a); + +int TS_REQ_set_cert_req(TS_REQ *a, int cert_req); +int TS_REQ_get_cert_req(const TS_REQ *a); + +STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a); +void TS_REQ_ext_free(TS_REQ *a); +int TS_REQ_get_ext_count(TS_REQ *a); +int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos); +int TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos); +int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos); +X509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc); +X509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc); +int TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc); +void *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx); + +/* Function declarations for TS_REQ defined in ts/ts_req_print.c */ + +int TS_REQ_print_bio(BIO *bio, TS_REQ *a); + +/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */ + +int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info); +TS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a); + +/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */ +void TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info); +PKCS7 *TS_RESP_get_token(TS_RESP *a); +TS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a); + +int TS_TST_INFO_set_version(TS_TST_INFO *a, long version); +long TS_TST_INFO_get_version(const TS_TST_INFO *a); + +int TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id); +ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a); + +int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint); +TS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a); + +int TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial); +const ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a); + +int TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime); +const ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a); + +int TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy); +TS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a); + +int TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds); +const ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a); + +int TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis); +const ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a); + +int TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros); +const ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a); + +int TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering); +int TS_TST_INFO_get_ordering(const TS_TST_INFO *a); + +int TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce); +const ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a); + +int TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa); +GENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a); + +STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a); +void TS_TST_INFO_ext_free(TS_TST_INFO *a); +int TS_TST_INFO_get_ext_count(TS_TST_INFO *a); +int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos); +int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, + int lastpos); +int TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos); +X509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc); +X509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc); +int TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc); +void *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx); + +/* + * Declarations related to response generation, defined in ts/ts_resp_sign.c. + */ + +/* Optional flags for response generation. */ + +/* Don't include the TSA name in response. */ +# define TS_TSA_NAME 0x01 + +/* Set ordering to true in response. */ +# define TS_ORDERING 0x02 + +/* + * Include the signer certificate and the other specified certificates in + * the ESS signing certificate attribute beside the PKCS7 signed data. + * Only the signer certificates is included by default. + */ +# define TS_ESS_CERT_ID_CHAIN 0x04 + +/* Forward declaration. */ +struct TS_resp_ctx; + +/* This must return a unique number less than 160 bits long. */ +typedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *); + +/* + * This must return the seconds and microseconds since Jan 1, 1970 in the sec + * and usec variables allocated by the caller. Return non-zero for success + * and zero for failure. + */ +typedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec, + long *usec); + +/* + * This must process the given extension. It can modify the TS_TST_INFO + * object of the context. Return values: !0 (processed), 0 (error, it must + * set the status info/failure info of the response). + */ +typedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *, + void *); + +typedef struct TS_resp_ctx TS_RESP_CTX; + +/* Creates a response context that can be used for generating responses. */ +TS_RESP_CTX *TS_RESP_CTX_new(void); +TS_RESP_CTX *TS_RESP_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq); +void TS_RESP_CTX_free(TS_RESP_CTX *ctx); + +/* This parameter must be set. */ +int TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer); + +/* This parameter must be set. */ +int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key); + +int TS_RESP_CTX_set_signer_digest(TS_RESP_CTX *ctx, + const EVP_MD *signer_digest); +int TS_RESP_CTX_set_ess_cert_id_digest(TS_RESP_CTX *ctx, const EVP_MD *md); + +/* This parameter must be set. */ +int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy); + +/* No additional certs are included in the response by default. */ +int TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs); + +/* + * Adds a new acceptable policy, only the default policy is accepted by + * default. + */ +int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy); + +/* + * Adds a new acceptable message digest. Note that no message digests are + * accepted by default. The md argument is shared with the caller. + */ +int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md); + +/* Accuracy is not included by default. */ +int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx, + int secs, int millis, int micros); + +/* + * Clock precision digits, i.e. the number of decimal digits: '0' means sec, + * '3' msec, '6' usec, and so on. Default is 0. + */ +int TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx, + unsigned clock_precision_digits); +/* At most we accept usec precision. */ +# define TS_MAX_CLOCK_PRECISION_DIGITS 6 + +/* Maximum status message length */ +# define TS_MAX_STATUS_LENGTH (1024 * 1024) + +/* No flags are set by default. */ +void TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags); + +/* Default callback always returns a constant. */ +void TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data); + +/* Default callback uses the gettimeofday() and gmtime() system calls. */ +void TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data); + +/* + * Default callback rejects all extensions. The extension callback is called + * when the TS_TST_INFO object is already set up and not signed yet. + */ +/* FIXME: extension handling is not tested yet. */ +void TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx, + TS_extension_cb cb, void *data); + +/* The following methods can be used in the callbacks. */ +int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx, + int status, const char *text); + +/* Sets the status info only if it is still TS_STATUS_GRANTED. */ +int TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx, + int status, const char *text); + +int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure); + +/* The get methods below can be used in the extension callback. */ +TS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx); + +TS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx); + +/* + * Creates the signed TS_TST_INFO and puts it in TS_RESP. + * In case of errors it sets the status info properly. + * Returns NULL only in case of memory allocation/fatal error. + */ +TS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio); + +/* + * Declarations related to response verification, + * they are defined in ts/ts_resp_verify.c. + */ + +int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs, + X509_STORE *store, X509 **signer_out); + +/* Context structure for the generic verify method. */ + +/* Verify the signer's certificate and the signature of the response. */ +# define TS_VFY_SIGNATURE (1u << 0) +/* Verify the version number of the response. */ +# define TS_VFY_VERSION (1u << 1) +/* Verify if the policy supplied by the user matches the policy of the TSA. */ +# define TS_VFY_POLICY (1u << 2) +/* + * Verify the message imprint provided by the user. This flag should not be + * specified with TS_VFY_DATA. + */ +# define TS_VFY_IMPRINT (1u << 3) +/* + * Verify the message imprint computed by the verify method from the user + * provided data and the MD algorithm of the response. This flag should not + * be specified with TS_VFY_IMPRINT. + */ +# define TS_VFY_DATA (1u << 4) +/* Verify the nonce value. */ +# define TS_VFY_NONCE (1u << 5) +/* Verify if the TSA name field matches the signer certificate. */ +# define TS_VFY_SIGNER (1u << 6) +/* Verify if the TSA name field equals to the user provided name. */ +# define TS_VFY_TSA_NAME (1u << 7) + +/* You can use the following convenience constants. */ +# define TS_VFY_ALL_IMPRINT (TS_VFY_SIGNATURE \ + | TS_VFY_VERSION \ + | TS_VFY_POLICY \ + | TS_VFY_IMPRINT \ + | TS_VFY_NONCE \ + | TS_VFY_SIGNER \ + | TS_VFY_TSA_NAME) +# define TS_VFY_ALL_DATA (TS_VFY_SIGNATURE \ + | TS_VFY_VERSION \ + | TS_VFY_POLICY \ + | TS_VFY_DATA \ + | TS_VFY_NONCE \ + | TS_VFY_SIGNER \ + | TS_VFY_TSA_NAME) + +typedef struct TS_verify_ctx TS_VERIFY_CTX; + +int TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response); +int TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token); + +/* + * Declarations related to response verification context, + */ +TS_VERIFY_CTX *TS_VERIFY_CTX_new(void); +void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx); +void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx); +void TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx); +int TS_VERIFY_CTX_set_flags(TS_VERIFY_CTX *ctx, int f); +int TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f); +# ifndef OPENSSL_NO_DEPRECATED_3_4 +OSSL_DEPRECATEDIN_3_4_FOR("Unclear semantics, replace with TS_VERIFY_CTX_set0_data().") +BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b); +# endif +int TS_VERIFY_CTX_set0_data(TS_VERIFY_CTX *ctx, BIO *b); +# ifndef OPENSSL_NO_DEPRECATED_3_4 +OSSL_DEPRECATEDIN_3_4_FOR("Unclear semantics, replace with TS_VERIFY_CTX_set0_imprint().") +unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx, + unsigned char *hexstr, long len); +# endif +int TS_VERIFY_CTX_set0_imprint(TS_VERIFY_CTX *ctx, + unsigned char *hexstr, long len); +# ifndef OPENSSL_NO_DEPRECATED_3_4 +OSSL_DEPRECATEDIN_3_4_FOR("Unclear semantics, replace with TS_VERIFY_CTX_set0_store().") +X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s); +# endif +int TS_VERIFY_CTX_set0_store(TS_VERIFY_CTX *ctx, X509_STORE *s); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define TS_VERIFY_CTS_set_certs(ctx, cert) TS_VERIFY_CTX_set_certs(ctx,cert) +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_4 +OSSL_DEPRECATEDIN_3_4_FOR("Unclear semantics, replace with TS_VERIFY_CTX_set0_certs().") +STACK_OF(X509) *TS_VERIFY_CTX_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs); +# endif +int TS_VERIFY_CTX_set0_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs); + +/*- + * If ctx is NULL, it allocates and returns a new object, otherwise + * it returns ctx. It initialises all the members as follows: + * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE) + * certs = NULL + * store = NULL + * policy = policy from the request or NULL if absent (in this case + * TS_VFY_POLICY is cleared from flags as well) + * md_alg = MD algorithm from request + * imprint, imprint_len = imprint from request + * data = NULL + * nonce, nonce_len = nonce from the request or NULL if absent (in this case + * TS_VFY_NONCE is cleared from flags as well) + * tsa_name = NULL + * Important: after calling this method TS_VFY_SIGNATURE should be added! + */ +TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx); + +/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */ + +int TS_RESP_print_bio(BIO *bio, TS_RESP *a); +int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a); +int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a); + +/* Common utility functions defined in ts/ts_lib.c */ + +int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num); +int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj); +int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions); +int TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg); +int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg); + +/* + * Function declarations for handling configuration options, defined in + * ts/ts_conf.c + */ + +X509 *TS_CONF_load_cert(const char *file); +STACK_OF(X509) *TS_CONF_load_certs(const char *file); +EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass); +const char *TS_CONF_get_tsa_section(CONF *conf, const char *section); +int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb, + TS_RESP_CTX *ctx); +#ifndef OPENSSL_NO_ENGINE +int TS_CONF_set_crypto_device(CONF *conf, const char *section, + const char *device); +int TS_CONF_set_default_engine(const char *name); +#endif +int TS_CONF_set_signer_cert(CONF *conf, const char *section, + const char *cert, TS_RESP_CTX *ctx); +int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs, + TS_RESP_CTX *ctx); +int TS_CONF_set_signer_key(CONF *conf, const char *section, + const char *key, const char *pass, + TS_RESP_CTX *ctx); +int TS_CONF_set_signer_digest(CONF *conf, const char *section, + const char *md, TS_RESP_CTX *ctx); +int TS_CONF_set_def_policy(CONF *conf, const char *section, + const char *policy, TS_RESP_CTX *ctx); +int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx); +int TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx); +int TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx); +int TS_CONF_set_clock_precision_digits(const CONF *conf, const char *section, + TS_RESP_CTX *ctx); +int TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx); +int TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx); +int TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section, + TS_RESP_CTX *ctx); +int TS_CONF_set_ess_cert_id_digest(CONF *conf, const char *section, + TS_RESP_CTX *ctx); + +# ifdef __cplusplus +} +# endif +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/tserr.h b/illumos-x86_64/usr/include/openssl-3/tserr.h new file mode 100644 index 00000000..e1b943e4 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/tserr.h @@ -0,0 +1,67 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_TSERR_H +# define OPENSSL_TSERR_H +# pragma once + +# include +# include +# include + + +# ifndef OPENSSL_NO_TS + + +/* + * TS reason codes. + */ +# define TS_R_BAD_PKCS7_TYPE 132 +# define TS_R_BAD_TYPE 133 +# define TS_R_CANNOT_LOAD_CERT 137 +# define TS_R_CANNOT_LOAD_KEY 138 +# define TS_R_CERTIFICATE_VERIFY_ERROR 100 +# define TS_R_COULD_NOT_SET_ENGINE 127 +# define TS_R_COULD_NOT_SET_TIME 115 +# define TS_R_DETACHED_CONTENT 134 +# define TS_R_ESS_ADD_SIGNING_CERT_ERROR 116 +# define TS_R_ESS_ADD_SIGNING_CERT_V2_ERROR 139 +# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR 101 +# define TS_R_INVALID_NULL_POINTER 102 +# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE 117 +# define TS_R_MESSAGE_IMPRINT_MISMATCH 103 +# define TS_R_NONCE_MISMATCH 104 +# define TS_R_NONCE_NOT_RETURNED 105 +# define TS_R_NO_CONTENT 106 +# define TS_R_NO_TIME_STAMP_TOKEN 107 +# define TS_R_PKCS7_ADD_SIGNATURE_ERROR 118 +# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR 119 +# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED 129 +# define TS_R_POLICY_MISMATCH 108 +# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 120 +# define TS_R_RESPONSE_SETUP_ERROR 121 +# define TS_R_SIGNATURE_FAILURE 109 +# define TS_R_THERE_MUST_BE_ONE_SIGNER 110 +# define TS_R_TIME_SYSCALL_ERROR 122 +# define TS_R_TOKEN_NOT_PRESENT 130 +# define TS_R_TOKEN_PRESENT 131 +# define TS_R_TSA_NAME_MISMATCH 111 +# define TS_R_TSA_UNTRUSTED 112 +# define TS_R_TST_INFO_SETUP_ERROR 123 +# define TS_R_TS_DATASIGN 124 +# define TS_R_UNACCEPTABLE_POLICY 125 +# define TS_R_UNSUPPORTED_MD_ALGORITHM 126 +# define TS_R_UNSUPPORTED_VERSION 113 +# define TS_R_VAR_BAD_VALUE 135 +# define TS_R_VAR_LOOKUP_FAILURE 136 +# define TS_R_WRONG_CONTENT_TYPE 114 + +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/txt_db.h b/illumos-x86_64/usr/include/openssl-3/txt_db.h new file mode 100644 index 00000000..af169a30 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/txt_db.h @@ -0,0 +1,63 @@ +/* + * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_TXT_DB_H +# define OPENSSL_TXT_DB_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_TXT_DB_H +# endif + +# include +# include +# include +# include + +# define DB_ERROR_OK 0 +# define DB_ERROR_MALLOC 1 +# define DB_ERROR_INDEX_CLASH 2 +# define DB_ERROR_INDEX_OUT_OF_RANGE 3 +# define DB_ERROR_NO_INDEX 4 +# define DB_ERROR_INSERT_INDEX_CLASH 5 +# define DB_ERROR_WRONG_NUM_FIELDS 6 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef OPENSSL_STRING *OPENSSL_PSTRING; +DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING) + +typedef struct txt_db_st { + int num_fields; + STACK_OF(OPENSSL_PSTRING) *data; + LHASH_OF(OPENSSL_STRING) **index; + int (**qual) (OPENSSL_STRING *); + long error; + long arg1; + long arg2; + OPENSSL_STRING *arg_row; +} TXT_DB; + +TXT_DB *TXT_DB_read(BIO *in, int num); +long TXT_DB_write(BIO *out, TXT_DB *db); +int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *), + OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp); +void TXT_DB_free(TXT_DB *db); +OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, + OPENSSL_STRING *value); +int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/types.h b/illumos-x86_64/usr/include/openssl-3/types.h new file mode 100644 index 00000000..344d892a --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/types.h @@ -0,0 +1,248 @@ +/* + * Copyright 2001-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * Unfortunate workaround to avoid symbol conflict with wincrypt.h + * See https://github.com/openssl/openssl/issues/9981 + */ +#ifdef _WIN32 +# define WINCRYPT_USE_SYMBOL_PREFIX +# undef X509_NAME +# undef X509_EXTENSIONS +# undef PKCS7_SIGNER_INFO +# undef OCSP_REQUEST +# undef OCSP_RESPONSE +#endif + +#ifndef OPENSSL_TYPES_H +# define OPENSSL_TYPES_H + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# include +# include +# include + +# if OPENSSL_VERSION_MAJOR >= 4 +# define OSSL_FUTURE_CONST const +# else +# define OSSL_FUTURE_CONST +# endif + +typedef struct ossl_provider_st OSSL_PROVIDER; /* Provider Object */ + +# ifdef NO_ASN1_TYPEDEFS +# define ASN1_INTEGER ASN1_STRING +# define ASN1_ENUMERATED ASN1_STRING +# define ASN1_BIT_STRING ASN1_STRING +# define ASN1_OCTET_STRING ASN1_STRING +# define ASN1_PRINTABLESTRING ASN1_STRING +# define ASN1_T61STRING ASN1_STRING +# define ASN1_IA5STRING ASN1_STRING +# define ASN1_UTCTIME ASN1_STRING +# define ASN1_GENERALIZEDTIME ASN1_STRING +# define ASN1_TIME ASN1_STRING +# define ASN1_GENERALSTRING ASN1_STRING +# define ASN1_UNIVERSALSTRING ASN1_STRING +# define ASN1_BMPSTRING ASN1_STRING +# define ASN1_VISIBLESTRING ASN1_STRING +# define ASN1_UTF8STRING ASN1_STRING +# define ASN1_BOOLEAN int +# define ASN1_NULL int +# else +typedef struct asn1_string_st ASN1_INTEGER; +typedef struct asn1_string_st ASN1_ENUMERATED; +typedef struct asn1_string_st ASN1_BIT_STRING; +typedef struct asn1_string_st ASN1_OCTET_STRING; +typedef struct asn1_string_st ASN1_PRINTABLESTRING; +typedef struct asn1_string_st ASN1_T61STRING; +typedef struct asn1_string_st ASN1_IA5STRING; +typedef struct asn1_string_st ASN1_GENERALSTRING; +typedef struct asn1_string_st ASN1_UNIVERSALSTRING; +typedef struct asn1_string_st ASN1_BMPSTRING; +typedef struct asn1_string_st ASN1_UTCTIME; +typedef struct asn1_string_st ASN1_TIME; +typedef struct asn1_string_st ASN1_GENERALIZEDTIME; +typedef struct asn1_string_st ASN1_VISIBLESTRING; +typedef struct asn1_string_st ASN1_UTF8STRING; +typedef struct asn1_string_st ASN1_STRING; +typedef int ASN1_BOOLEAN; +typedef int ASN1_NULL; +# endif + +typedef struct asn1_type_st ASN1_TYPE; +typedef struct asn1_object_st ASN1_OBJECT; +typedef struct asn1_string_table_st ASN1_STRING_TABLE; + +typedef struct ASN1_ITEM_st ASN1_ITEM; +typedef struct asn1_pctx_st ASN1_PCTX; +typedef struct asn1_sctx_st ASN1_SCTX; + +# ifdef BIGNUM +# undef BIGNUM +# endif + +typedef struct bio_st BIO; +typedef struct bignum_st BIGNUM; +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; + +typedef struct buf_mem_st BUF_MEM; + +STACK_OF(BIGNUM); +STACK_OF(BIGNUM_const); + +typedef struct err_state_st ERR_STATE; + +typedef struct evp_cipher_st EVP_CIPHER; +typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; +typedef struct evp_md_st EVP_MD; +typedef struct evp_md_ctx_st EVP_MD_CTX; +typedef struct evp_mac_st EVP_MAC; +typedef struct evp_mac_ctx_st EVP_MAC_CTX; +typedef struct evp_pkey_st EVP_PKEY; +typedef struct evp_skey_st EVP_SKEY; + +typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD; + +typedef struct evp_pkey_method_st EVP_PKEY_METHOD; +typedef struct evp_pkey_ctx_st EVP_PKEY_CTX; + +typedef struct evp_keymgmt_st EVP_KEYMGMT; + +typedef struct evp_kdf_st EVP_KDF; +typedef struct evp_kdf_ctx_st EVP_KDF_CTX; + +typedef struct evp_rand_st EVP_RAND; +typedef struct evp_rand_ctx_st EVP_RAND_CTX; + +typedef struct evp_keyexch_st EVP_KEYEXCH; + +typedef struct evp_signature_st EVP_SIGNATURE; + +typedef struct evp_skeymgmt_st EVP_SKEYMGMT; + +typedef struct evp_asym_cipher_st EVP_ASYM_CIPHER; + +typedef struct evp_kem_st EVP_KEM; + +typedef struct evp_Encode_Ctx_st EVP_ENCODE_CTX; + +typedef struct hmac_ctx_st HMAC_CTX; + +typedef struct dh_st DH; +typedef struct dh_method DH_METHOD; + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef struct dsa_st DSA; +typedef struct dsa_method DSA_METHOD; +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef struct rsa_st RSA; +typedef struct rsa_meth_st RSA_METHOD; +# endif +typedef struct rsa_pss_params_st RSA_PSS_PARAMS; + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +typedef struct ec_key_st EC_KEY; +typedef struct ec_key_method_st EC_KEY_METHOD; +# endif + +typedef struct rand_meth_st RAND_METHOD; +typedef struct rand_drbg_st RAND_DRBG; + +typedef struct ssl_dane_st SSL_DANE; +typedef struct x509_st X509; +typedef struct X509_algor_st X509_ALGOR; +typedef struct X509_crl_st X509_CRL; +typedef struct x509_crl_method_st X509_CRL_METHOD; +typedef struct x509_revoked_st X509_REVOKED; +typedef struct X509_name_st X509_NAME; +typedef struct X509_pubkey_st X509_PUBKEY; +typedef struct x509_store_st X509_STORE; +typedef struct x509_store_ctx_st X509_STORE_CTX; + +typedef struct x509_object_st X509_OBJECT; +typedef struct x509_lookup_st X509_LOOKUP; +typedef struct x509_lookup_method_st X509_LOOKUP_METHOD; +typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM; + +typedef struct x509_sig_info_st X509_SIG_INFO; + +typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO; + +typedef struct v3_ext_ctx X509V3_CTX; +typedef struct conf_st CONF; +typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS; + +typedef struct ui_st UI; +typedef struct ui_method_st UI_METHOD; + +typedef struct engine_st ENGINE; +typedef struct ssl_st SSL; +typedef struct ssl_ctx_st SSL_CTX; + +typedef struct comp_ctx_st COMP_CTX; +typedef struct comp_method_st COMP_METHOD; + +typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; +typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; +typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; +typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; + +typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID; +typedef struct DIST_POINT_st DIST_POINT; +typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT; +typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS; + +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; + +typedef struct ossl_http_req_ctx_st OSSL_HTTP_REQ_CTX; +typedef struct ocsp_response_st OCSP_RESPONSE; +typedef struct ocsp_responder_id_st OCSP_RESPID; + +typedef struct sct_st SCT; +typedef struct sct_ctx_st SCT_CTX; +typedef struct ctlog_st CTLOG; +typedef struct ctlog_store_st CTLOG_STORE; +typedef struct ct_policy_eval_ctx_st CT_POLICY_EVAL_CTX; + +typedef struct ossl_store_info_st OSSL_STORE_INFO; +typedef struct ossl_store_search_st OSSL_STORE_SEARCH; + +typedef struct ossl_lib_ctx_st OSSL_LIB_CTX; + +typedef struct ossl_dispatch_st OSSL_DISPATCH; +typedef struct ossl_item_st OSSL_ITEM; +typedef struct ossl_algorithm_st OSSL_ALGORITHM; +typedef struct ossl_param_st OSSL_PARAM; +typedef struct ossl_param_bld_st OSSL_PARAM_BLD; + +typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata); + +typedef struct ossl_encoder_st OSSL_ENCODER; +typedef struct ossl_encoder_ctx_st OSSL_ENCODER_CTX; +typedef struct ossl_decoder_st OSSL_DECODER; +typedef struct ossl_decoder_ctx_st OSSL_DECODER_CTX; + +typedef struct ossl_self_test_st OSSL_SELF_TEST; + +#ifdef __cplusplus +} +#endif + +#endif /* OPENSSL_TYPES_H */ diff --git a/illumos-x86_64/usr/include/openssl-3/ui.h b/illumos-x86_64/usr/include/openssl-3/ui.h new file mode 100644 index 00000000..e64ec3b3 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/ui.h @@ -0,0 +1,407 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/ui.h.in + * + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_UI_H +# define OPENSSL_UI_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_UI_H +# endif + +# include + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif +# include +# include +# include +# include + +/* For compatibility reasons, the macro OPENSSL_NO_UI is currently retained */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifdef OPENSSL_NO_UI_CONSOLE +# define OPENSSL_NO_UI +# endif +# endif + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * All the following functions return -1 or NULL on error and in some cases + * (UI_process()) -2 if interrupted or in some other way cancelled. When + * everything is fine, they return 0, a positive value or a non-NULL pointer, + * all depending on their purpose. + */ + +/* Creators and destructor. */ +UI *UI_new(void); +UI *UI_new_method(const UI_METHOD *method); +void UI_free(UI *ui); + +/*- + The following functions are used to add strings to be printed and prompt + strings to prompt for data. The names are UI_{add,dup}__string + and UI_{add,dup}_input_boolean. + + UI_{add,dup}__string have the following meanings: + add add a text or prompt string. The pointers given to these + functions are used verbatim, no copying is done. + dup make a copy of the text or prompt string, then add the copy + to the collection of strings in the user interface. + + The function is a name for the functionality that the given + string shall be used for. It can be one of: + input use the string as data prompt. + verify use the string as verification prompt. This + is used to verify a previous input. + info use the string for informational output. + error use the string for error output. + Honestly, there's currently no difference between info and error for the + moment. + + UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", + and are typically used when one wants to prompt for a yes/no response. + + All of the functions in this group take a UI and a prompt string. + The string input and verify addition functions also take a flag argument, + a buffer for the result to end up with, a minimum input size and a maximum + input size (the result buffer MUST be large enough to be able to contain + the maximum number of characters). Additionally, the verify addition + functions takes another buffer to compare the result against. + The boolean input functions take an action description string (which should + be safe to ignore if the expected user action is obvious, for example with + a dialog box with an OK button and a Cancel button), a string of acceptable + characters to mean OK and to mean Cancel. The two last strings are checked + to make sure they don't have common characters. Additionally, the same + flag argument as for the string input is taken, as well as a result buffer. + The result buffer is required to be at least one byte long. Depending on + the answer, the first character from the OK or the Cancel character strings + will be stored in the first byte of the result buffer. No NUL will be + added, so the result is *not* a string. + + On success, the all return an index of the added information. That index + is useful when retrieving results with UI_get0_result(). */ +int UI_add_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_dup_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_add_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, + const char *test_buf); +int UI_dup_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, + const char *test_buf); +int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_add_info_string(UI *ui, const char *text); +int UI_dup_info_string(UI *ui, const char *text); +int UI_add_error_string(UI *ui, const char *text); +int UI_dup_error_string(UI *ui, const char *text); + +/* These are the possible flags. They can be or'ed together. */ +/* Use to have echoing of input */ +# define UI_INPUT_FLAG_ECHO 0x01 +/* + * Use a default password. Where that password is found is completely up to + * the application, it might for example be in the user data set with + * UI_add_user_data(). It is not recommended to have more than one input in + * each UI being marked with this flag, or the application might get + * confused. + */ +# define UI_INPUT_FLAG_DEFAULT_PWD 0x02 + +/*- + * The user of these routines may want to define flags of their own. The core + * UI won't look at those, but will pass them on to the method routines. They + * must use higher bits so they don't get confused with the UI bits above. + * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good + * example of use is this: + * + * #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) + * +*/ +# define UI_INPUT_FLAG_USER_BASE 16 + +/*- + * The following function helps construct a prompt. + * phrase_desc is a textual short description of the phrase to enter, + * for example "pass phrase", and + * object_name is the name of the object + * (which might be a card name or a file name) or NULL. + * The returned string shall always be allocated on the heap with + * OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). + * + * If the ui_method doesn't contain a pointer to a user-defined prompt + * constructor, a default string is built, looking like this: + * + * "Enter {phrase_desc} for {object_name}:" + * + * So, if phrase_desc has the value "pass phrase" and object_name has + * the value "foo.key", the resulting string is: + * + * "Enter pass phrase for foo.key:" +*/ +char *UI_construct_prompt(UI *ui_method, + const char *phrase_desc, const char *object_name); + +/* + * The following function is used to store a pointer to user-specific data. + * Any previous such pointer will be returned and replaced. + * + * For callback purposes, this function makes a lot more sense than using + * ex_data, since the latter requires that different parts of OpenSSL or + * applications share the same ex_data index. + * + * Note that the UI_OpenSSL() method completely ignores the user data. Other + * methods may not, however. + */ +void *UI_add_user_data(UI *ui, void *user_data); +/* + * Alternatively, this function is used to duplicate the user data. + * This uses the duplicator method function. The destroy function will + * be used to free the user data in this case. + */ +int UI_dup_user_data(UI *ui, void *user_data); +/* We need a user data retrieving function as well. */ +void *UI_get0_user_data(UI *ui); + +/* Return the result associated with a prompt given with the index i. */ +const char *UI_get0_result(UI *ui, int i); +int UI_get_result_length(UI *ui, int i); + +/* When all strings have been added, process the whole thing. */ +int UI_process(UI *ui); + +/* + * Give a user interface parameterised control commands. This can be used to + * send down an integer, a data pointer or a function pointer, as well as be + * used to get information from a UI. + */ +int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)); + +/* The commands */ +/* + * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the + * OpenSSL error stack before printing any info or added error messages and + * before any prompting. + */ +# define UI_CTRL_PRINT_ERRORS 1 +/* + * Check if a UI_process() is possible to do again with the same instance of + * a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 + * if not. + */ +# define UI_CTRL_IS_REDOABLE 2 + +/* Some methods may use extra data */ +# define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) +# define UI_get_app_data(s) UI_get_ex_data(s,0) + +# define UI_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef) +int UI_set_ex_data(UI *r, int idx, void *arg); +void *UI_get_ex_data(const UI *r, int idx); + +/* Use specific methods instead of the built-in one */ +void UI_set_default_method(const UI_METHOD *meth); +const UI_METHOD *UI_get_default_method(void); +const UI_METHOD *UI_get_method(UI *ui); +const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); + +# ifndef OPENSSL_NO_UI_CONSOLE + +/* The method with all the built-in thingies */ +UI_METHOD *UI_OpenSSL(void); + +# endif + +/* + * NULL method. Literally does nothing, but may serve as a placeholder + * to avoid internal default. + */ +const UI_METHOD *UI_null(void); + +/* ---------- For method writers ---------- */ +/*- + A method contains a number of functions that implement the low level + of the User Interface. The functions are: + + an opener This function starts a session, maybe by opening + a channel to a tty, or by opening a window. + a writer This function is called to write a given string, + maybe to the tty, maybe as a field label in a + window. + a flusher This function is called to flush everything that + has been output so far. It can be used to actually + display a dialog box after it has been built. + a reader This function is called to read a given prompt, + maybe from the tty, maybe from a field in a + window. Note that it's called with all string + structures, not only the prompt ones, so it must + check such things itself. + a closer This function closes the session, maybe by closing + the channel to the tty, or closing the window. + + All these functions are expected to return: + + 0 on error. + 1 on success. + -1 on out-of-band events, for example if some prompting has + been canceled (by pressing Ctrl-C, for example). This is + only checked when returned by the flusher or the reader. + + The way this is used, the opener is first called, then the writer for all + strings, then the flusher, then the reader for all strings and finally the + closer. Note that if you want to prompt from a terminal or other command + line interface, the best is to have the reader also write the prompts + instead of having the writer do it. If you want to prompt from a dialog + box, the writer can be used to build up the contents of the box, and the + flusher to actually display the box and run the event loop until all data + has been given, after which the reader only grabs the given data and puts + them back into the UI strings. + + All method functions take a UI as argument. Additionally, the writer and + the reader take a UI_STRING. +*/ + +/* + * The UI_STRING type is the data structure that contains all the needed info + * about a string or a prompt, including test data for a verification prompt. + */ +typedef struct ui_string_st UI_STRING; + +SKM_DEFINE_STACK_OF_INTERNAL(UI_STRING, UI_STRING, UI_STRING) +#define sk_UI_STRING_num(sk) OPENSSL_sk_num(ossl_check_const_UI_STRING_sk_type(sk)) +#define sk_UI_STRING_value(sk, idx) ((UI_STRING *)OPENSSL_sk_value(ossl_check_const_UI_STRING_sk_type(sk), (idx))) +#define sk_UI_STRING_new(cmp) ((STACK_OF(UI_STRING) *)OPENSSL_sk_new(ossl_check_UI_STRING_compfunc_type(cmp))) +#define sk_UI_STRING_new_null() ((STACK_OF(UI_STRING) *)OPENSSL_sk_new_null()) +#define sk_UI_STRING_new_reserve(cmp, n) ((STACK_OF(UI_STRING) *)OPENSSL_sk_new_reserve(ossl_check_UI_STRING_compfunc_type(cmp), (n))) +#define sk_UI_STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_UI_STRING_sk_type(sk), (n)) +#define sk_UI_STRING_free(sk) OPENSSL_sk_free(ossl_check_UI_STRING_sk_type(sk)) +#define sk_UI_STRING_zero(sk) OPENSSL_sk_zero(ossl_check_UI_STRING_sk_type(sk)) +#define sk_UI_STRING_delete(sk, i) ((UI_STRING *)OPENSSL_sk_delete(ossl_check_UI_STRING_sk_type(sk), (i))) +#define sk_UI_STRING_delete_ptr(sk, ptr) ((UI_STRING *)OPENSSL_sk_delete_ptr(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr))) +#define sk_UI_STRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr)) +#define sk_UI_STRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr)) +#define sk_UI_STRING_pop(sk) ((UI_STRING *)OPENSSL_sk_pop(ossl_check_UI_STRING_sk_type(sk))) +#define sk_UI_STRING_shift(sk) ((UI_STRING *)OPENSSL_sk_shift(ossl_check_UI_STRING_sk_type(sk))) +#define sk_UI_STRING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_UI_STRING_sk_type(sk),ossl_check_UI_STRING_freefunc_type(freefunc)) +#define sk_UI_STRING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr), (idx)) +#define sk_UI_STRING_set(sk, idx, ptr) ((UI_STRING *)OPENSSL_sk_set(ossl_check_UI_STRING_sk_type(sk), (idx), ossl_check_UI_STRING_type(ptr))) +#define sk_UI_STRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr)) +#define sk_UI_STRING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr)) +#define sk_UI_STRING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr), pnum) +#define sk_UI_STRING_sort(sk) OPENSSL_sk_sort(ossl_check_UI_STRING_sk_type(sk)) +#define sk_UI_STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_UI_STRING_sk_type(sk)) +#define sk_UI_STRING_dup(sk) ((STACK_OF(UI_STRING) *)OPENSSL_sk_dup(ossl_check_const_UI_STRING_sk_type(sk))) +#define sk_UI_STRING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(UI_STRING) *)OPENSSL_sk_deep_copy(ossl_check_const_UI_STRING_sk_type(sk), ossl_check_UI_STRING_copyfunc_type(copyfunc), ossl_check_UI_STRING_freefunc_type(freefunc))) +#define sk_UI_STRING_set_cmp_func(sk, cmp) ((sk_UI_STRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_compfunc_type(cmp))) + + +/* + * The different types of strings that are currently supported. This is only + * needed by method authors. + */ +enum UI_string_types { + UIT_NONE = 0, + UIT_PROMPT, /* Prompt for a string */ + UIT_VERIFY, /* Prompt for a string and verify */ + UIT_BOOLEAN, /* Prompt for a yes/no response */ + UIT_INFO, /* Send info to the user */ + UIT_ERROR /* Send an error message to the user */ +}; + +/* Create and manipulate methods */ +UI_METHOD *UI_create_method(const char *name); +void UI_destroy_method(UI_METHOD *ui_method); +int UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui)); +int UI_method_set_writer(UI_METHOD *method, + int (*writer) (UI *ui, UI_STRING *uis)); +int UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui)); +int UI_method_set_reader(UI_METHOD *method, + int (*reader) (UI *ui, UI_STRING *uis)); +int UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui)); +int UI_method_set_data_duplicator(UI_METHOD *method, + void *(*duplicator) (UI *ui, void *ui_data), + void (*destructor)(UI *ui, void *ui_data)); +int UI_method_set_prompt_constructor(UI_METHOD *method, + char *(*prompt_constructor) (UI *ui, + const char + *phrase_desc, + const char + *object_name)); +int UI_method_set_ex_data(UI_METHOD *method, int idx, void *data); +int (*UI_method_get_opener(const UI_METHOD *method)) (UI *); +int (*UI_method_get_writer(const UI_METHOD *method)) (UI *, UI_STRING *); +int (*UI_method_get_flusher(const UI_METHOD *method)) (UI *); +int (*UI_method_get_reader(const UI_METHOD *method)) (UI *, UI_STRING *); +int (*UI_method_get_closer(const UI_METHOD *method)) (UI *); +char *(*UI_method_get_prompt_constructor(const UI_METHOD *method)) + (UI *, const char *, const char *); +void *(*UI_method_get_data_duplicator(const UI_METHOD *method)) (UI *, void *); +void (*UI_method_get_data_destructor(const UI_METHOD *method)) (UI *, void *); +const void *UI_method_get_ex_data(const UI_METHOD *method, int idx); + +/* + * The following functions are helpers for method writers to access relevant + * data from a UI_STRING. + */ + +/* Return type of the UI_STRING */ +enum UI_string_types UI_get_string_type(UI_STRING *uis); +/* Return input flags of the UI_STRING */ +int UI_get_input_flags(UI_STRING *uis); +/* Return the actual string to output (the prompt, info or error) */ +const char *UI_get0_output_string(UI_STRING *uis); +/* + * Return the optional action string to output (the boolean prompt + * instruction) + */ +const char *UI_get0_action_string(UI_STRING *uis); +/* Return the result of a prompt */ +const char *UI_get0_result_string(UI_STRING *uis); +int UI_get_result_string_length(UI_STRING *uis); +/* + * Return the string to test the result against. Only useful with verifies. + */ +const char *UI_get0_test_string(UI_STRING *uis); +/* Return the required minimum size of the result */ +int UI_get_result_minsize(UI_STRING *uis); +/* Return the required maximum size of the result */ +int UI_get_result_maxsize(UI_STRING *uis); +/* Set the result of a UI_STRING. */ +int UI_set_result(UI *ui, UI_STRING *uis, const char *result); +int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len); + +/* A couple of popular utility functions */ +int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, + int verify); +int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, + int verify); +UI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag); + + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/uierr.h b/illumos-x86_64/usr/include/openssl-3/uierr.h new file mode 100644 index 00000000..473b04ed --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/uierr.h @@ -0,0 +1,38 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_UIERR_H +# define OPENSSL_UIERR_H +# pragma once + +# include +# include +# include + + + +/* + * UI reason codes. + */ +# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 +# define UI_R_INDEX_TOO_LARGE 102 +# define UI_R_INDEX_TOO_SMALL 103 +# define UI_R_NO_RESULT_BUFFER 105 +# define UI_R_PROCESSING_ERROR 107 +# define UI_R_RESULT_TOO_LARGE 100 +# define UI_R_RESULT_TOO_SMALL 101 +# define UI_R_SYSASSIGN_ERROR 109 +# define UI_R_SYSDASSGN_ERROR 110 +# define UI_R_SYSQIOW_ERROR 111 +# define UI_R_UNKNOWN_CONTROL_COMMAND 106 +# define UI_R_UNKNOWN_TTYGET_ERRNO_VALUE 108 +# define UI_R_USER_DATA_DUPLICATION_UNSUPPORTED 112 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/whrlpool.h b/illumos-x86_64/usr/include/openssl-3/whrlpool.h new file mode 100644 index 00000000..05ba4632 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/whrlpool.h @@ -0,0 +1,62 @@ +/* + * Copyright 2005-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_WHRLPOOL_H +# define OPENSSL_WHRLPOOL_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_WHRLPOOL_H +# endif + +# include + +# ifndef OPENSSL_NO_WHIRLPOOL +# include +# include +# ifdef __cplusplus +extern "C" { +# endif + +# define WHIRLPOOL_DIGEST_LENGTH (512/8) + +# if !defined(OPENSSL_NO_DEPRECATED_3_0) + +# define WHIRLPOOL_BBLOCK 512 +# define WHIRLPOOL_COUNTER (256/8) + +typedef struct { + union { + unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; + /* double q is here to ensure 64-bit alignment */ + double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)]; + } H; + unsigned char data[WHIRLPOOL_BBLOCK / 8]; + unsigned int bitoff; + size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)]; +} WHIRLPOOL_CTX; +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int WHIRLPOOL_Init(WHIRLPOOL_CTX *c); +OSSL_DEPRECATEDIN_3_0 int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, + const void *inp, size_t bytes); +OSSL_DEPRECATEDIN_3_0 void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, + const void *inp, size_t bits); +OSSL_DEPRECATEDIN_3_0 int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c); +OSSL_DEPRECATEDIN_3_0 unsigned char *WHIRLPOOL(const void *inp, size_t bytes, + unsigned char *md); +# endif + +# ifdef __cplusplus +} +# endif +# endif + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/x509.h b/illumos-x86_64/usr/include/openssl-3/x509.h new file mode 100644 index 00000000..d013458c --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/x509.h @@ -0,0 +1,1303 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/x509.h.in + * + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_X509_H +# define OPENSSL_X509_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_X509_H +# endif + +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# include +# include +# endif + +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Needed stacks for types defined in other headers */ +SKM_DEFINE_STACK_OF_INTERNAL(X509_NAME, X509_NAME, X509_NAME) +#define sk_X509_NAME_num(sk) OPENSSL_sk_num(ossl_check_const_X509_NAME_sk_type(sk)) +#define sk_X509_NAME_value(sk, idx) ((X509_NAME *)OPENSSL_sk_value(ossl_check_const_X509_NAME_sk_type(sk), (idx))) +#define sk_X509_NAME_new(cmp) ((STACK_OF(X509_NAME) *)OPENSSL_sk_new(ossl_check_X509_NAME_compfunc_type(cmp))) +#define sk_X509_NAME_new_null() ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_null()) +#define sk_X509_NAME_new_reserve(cmp, n) ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_reserve(ossl_check_X509_NAME_compfunc_type(cmp), (n))) +#define sk_X509_NAME_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_NAME_sk_type(sk), (n)) +#define sk_X509_NAME_free(sk) OPENSSL_sk_free(ossl_check_X509_NAME_sk_type(sk)) +#define sk_X509_NAME_zero(sk) OPENSSL_sk_zero(ossl_check_X509_NAME_sk_type(sk)) +#define sk_X509_NAME_delete(sk, i) ((X509_NAME *)OPENSSL_sk_delete(ossl_check_X509_NAME_sk_type(sk), (i))) +#define sk_X509_NAME_delete_ptr(sk, ptr) ((X509_NAME *)OPENSSL_sk_delete_ptr(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr))) +#define sk_X509_NAME_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)) +#define sk_X509_NAME_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)) +#define sk_X509_NAME_pop(sk) ((X509_NAME *)OPENSSL_sk_pop(ossl_check_X509_NAME_sk_type(sk))) +#define sk_X509_NAME_shift(sk) ((X509_NAME *)OPENSSL_sk_shift(ossl_check_X509_NAME_sk_type(sk))) +#define sk_X509_NAME_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_NAME_sk_type(sk),ossl_check_X509_NAME_freefunc_type(freefunc)) +#define sk_X509_NAME_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr), (idx)) +#define sk_X509_NAME_set(sk, idx, ptr) ((X509_NAME *)OPENSSL_sk_set(ossl_check_X509_NAME_sk_type(sk), (idx), ossl_check_X509_NAME_type(ptr))) +#define sk_X509_NAME_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)) +#define sk_X509_NAME_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)) +#define sk_X509_NAME_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr), pnum) +#define sk_X509_NAME_sort(sk) OPENSSL_sk_sort(ossl_check_X509_NAME_sk_type(sk)) +#define sk_X509_NAME_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_sk_type(sk)) +#define sk_X509_NAME_dup(sk) ((STACK_OF(X509_NAME) *)OPENSSL_sk_dup(ossl_check_const_X509_NAME_sk_type(sk))) +#define sk_X509_NAME_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_NAME) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_NAME_sk_type(sk), ossl_check_X509_NAME_copyfunc_type(copyfunc), ossl_check_X509_NAME_freefunc_type(freefunc))) +#define sk_X509_NAME_set_cmp_func(sk, cmp) ((sk_X509_NAME_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(X509, X509, X509) +#define sk_X509_num(sk) OPENSSL_sk_num(ossl_check_const_X509_sk_type(sk)) +#define sk_X509_value(sk, idx) ((X509 *)OPENSSL_sk_value(ossl_check_const_X509_sk_type(sk), (idx))) +#define sk_X509_new(cmp) ((STACK_OF(X509) *)OPENSSL_sk_new(ossl_check_X509_compfunc_type(cmp))) +#define sk_X509_new_null() ((STACK_OF(X509) *)OPENSSL_sk_new_null()) +#define sk_X509_new_reserve(cmp, n) ((STACK_OF(X509) *)OPENSSL_sk_new_reserve(ossl_check_X509_compfunc_type(cmp), (n))) +#define sk_X509_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_sk_type(sk), (n)) +#define sk_X509_free(sk) OPENSSL_sk_free(ossl_check_X509_sk_type(sk)) +#define sk_X509_zero(sk) OPENSSL_sk_zero(ossl_check_X509_sk_type(sk)) +#define sk_X509_delete(sk, i) ((X509 *)OPENSSL_sk_delete(ossl_check_X509_sk_type(sk), (i))) +#define sk_X509_delete_ptr(sk, ptr) ((X509 *)OPENSSL_sk_delete_ptr(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))) +#define sk_X509_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) +#define sk_X509_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) +#define sk_X509_pop(sk) ((X509 *)OPENSSL_sk_pop(ossl_check_X509_sk_type(sk))) +#define sk_X509_shift(sk) ((X509 *)OPENSSL_sk_shift(ossl_check_X509_sk_type(sk))) +#define sk_X509_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_sk_type(sk),ossl_check_X509_freefunc_type(freefunc)) +#define sk_X509_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), (idx)) +#define sk_X509_set(sk, idx, ptr) ((X509 *)OPENSSL_sk_set(ossl_check_X509_sk_type(sk), (idx), ossl_check_X509_type(ptr))) +#define sk_X509_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) +#define sk_X509_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) +#define sk_X509_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), pnum) +#define sk_X509_sort(sk) OPENSSL_sk_sort(ossl_check_X509_sk_type(sk)) +#define sk_X509_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_sk_type(sk)) +#define sk_X509_dup(sk) ((STACK_OF(X509) *)OPENSSL_sk_dup(ossl_check_const_X509_sk_type(sk))) +#define sk_X509_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_sk_type(sk), ossl_check_X509_copyfunc_type(copyfunc), ossl_check_X509_freefunc_type(freefunc))) +#define sk_X509_set_cmp_func(sk, cmp) ((sk_X509_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_sk_type(sk), ossl_check_X509_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(X509_REVOKED, X509_REVOKED, X509_REVOKED) +#define sk_X509_REVOKED_num(sk) OPENSSL_sk_num(ossl_check_const_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_value(sk, idx) ((X509_REVOKED *)OPENSSL_sk_value(ossl_check_const_X509_REVOKED_sk_type(sk), (idx))) +#define sk_X509_REVOKED_new(cmp) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new(ossl_check_X509_REVOKED_compfunc_type(cmp))) +#define sk_X509_REVOKED_new_null() ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_null()) +#define sk_X509_REVOKED_new_reserve(cmp, n) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_reserve(ossl_check_X509_REVOKED_compfunc_type(cmp), (n))) +#define sk_X509_REVOKED_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_REVOKED_sk_type(sk), (n)) +#define sk_X509_REVOKED_free(sk) OPENSSL_sk_free(ossl_check_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_zero(sk) OPENSSL_sk_zero(ossl_check_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_delete(sk, i) ((X509_REVOKED *)OPENSSL_sk_delete(ossl_check_X509_REVOKED_sk_type(sk), (i))) +#define sk_X509_REVOKED_delete_ptr(sk, ptr) ((X509_REVOKED *)OPENSSL_sk_delete_ptr(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr))) +#define sk_X509_REVOKED_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)) +#define sk_X509_REVOKED_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)) +#define sk_X509_REVOKED_pop(sk) ((X509_REVOKED *)OPENSSL_sk_pop(ossl_check_X509_REVOKED_sk_type(sk))) +#define sk_X509_REVOKED_shift(sk) ((X509_REVOKED *)OPENSSL_sk_shift(ossl_check_X509_REVOKED_sk_type(sk))) +#define sk_X509_REVOKED_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_REVOKED_sk_type(sk),ossl_check_X509_REVOKED_freefunc_type(freefunc)) +#define sk_X509_REVOKED_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr), (idx)) +#define sk_X509_REVOKED_set(sk, idx, ptr) ((X509_REVOKED *)OPENSSL_sk_set(ossl_check_X509_REVOKED_sk_type(sk), (idx), ossl_check_X509_REVOKED_type(ptr))) +#define sk_X509_REVOKED_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)) +#define sk_X509_REVOKED_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)) +#define sk_X509_REVOKED_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr), pnum) +#define sk_X509_REVOKED_sort(sk) OPENSSL_sk_sort(ossl_check_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_dup(sk) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_dup(ossl_check_const_X509_REVOKED_sk_type(sk))) +#define sk_X509_REVOKED_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_copyfunc_type(copyfunc), ossl_check_X509_REVOKED_freefunc_type(freefunc))) +#define sk_X509_REVOKED_set_cmp_func(sk, cmp) ((sk_X509_REVOKED_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(X509_CRL, X509_CRL, X509_CRL) +#define sk_X509_CRL_num(sk) OPENSSL_sk_num(ossl_check_const_X509_CRL_sk_type(sk)) +#define sk_X509_CRL_value(sk, idx) ((X509_CRL *)OPENSSL_sk_value(ossl_check_const_X509_CRL_sk_type(sk), (idx))) +#define sk_X509_CRL_new(cmp) ((STACK_OF(X509_CRL) *)OPENSSL_sk_new(ossl_check_X509_CRL_compfunc_type(cmp))) +#define sk_X509_CRL_new_null() ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_null()) +#define sk_X509_CRL_new_reserve(cmp, n) ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_reserve(ossl_check_X509_CRL_compfunc_type(cmp), (n))) +#define sk_X509_CRL_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_CRL_sk_type(sk), (n)) +#define sk_X509_CRL_free(sk) OPENSSL_sk_free(ossl_check_X509_CRL_sk_type(sk)) +#define sk_X509_CRL_zero(sk) OPENSSL_sk_zero(ossl_check_X509_CRL_sk_type(sk)) +#define sk_X509_CRL_delete(sk, i) ((X509_CRL *)OPENSSL_sk_delete(ossl_check_X509_CRL_sk_type(sk), (i))) +#define sk_X509_CRL_delete_ptr(sk, ptr) ((X509_CRL *)OPENSSL_sk_delete_ptr(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr))) +#define sk_X509_CRL_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)) +#define sk_X509_CRL_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)) +#define sk_X509_CRL_pop(sk) ((X509_CRL *)OPENSSL_sk_pop(ossl_check_X509_CRL_sk_type(sk))) +#define sk_X509_CRL_shift(sk) ((X509_CRL *)OPENSSL_sk_shift(ossl_check_X509_CRL_sk_type(sk))) +#define sk_X509_CRL_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_CRL_sk_type(sk),ossl_check_X509_CRL_freefunc_type(freefunc)) +#define sk_X509_CRL_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr), (idx)) +#define sk_X509_CRL_set(sk, idx, ptr) ((X509_CRL *)OPENSSL_sk_set(ossl_check_X509_CRL_sk_type(sk), (idx), ossl_check_X509_CRL_type(ptr))) +#define sk_X509_CRL_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)) +#define sk_X509_CRL_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)) +#define sk_X509_CRL_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr), pnum) +#define sk_X509_CRL_sort(sk) OPENSSL_sk_sort(ossl_check_X509_CRL_sk_type(sk)) +#define sk_X509_CRL_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_CRL_sk_type(sk)) +#define sk_X509_CRL_dup(sk) ((STACK_OF(X509_CRL) *)OPENSSL_sk_dup(ossl_check_const_X509_CRL_sk_type(sk))) +#define sk_X509_CRL_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_CRL) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_CRL_sk_type(sk), ossl_check_X509_CRL_copyfunc_type(copyfunc), ossl_check_X509_CRL_freefunc_type(freefunc))) +#define sk_X509_CRL_set_cmp_func(sk, cmp) ((sk_X509_CRL_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_compfunc_type(cmp))) + + +/* Flags for X509_get_signature_info() */ +/* Signature info is valid */ +# define X509_SIG_INFO_VALID 0x1 +/* Signature is suitable for TLS use */ +# define X509_SIG_INFO_TLS 0x2 + +# define X509_FILETYPE_PEM 1 +# define X509_FILETYPE_ASN1 2 +# define X509_FILETYPE_DEFAULT 3 + +/*- + * : + * The KeyUsage BITSTRING is treated as a little-endian integer, hence bit `0` + * is 0x80, while bit `7` is 0x01 (the LSB of the integer value), bit `8` is + * then the MSB of the second octet, or 0x8000. + */ +# define X509v3_KU_DIGITAL_SIGNATURE 0x0080 /* (0) */ +# define X509v3_KU_NON_REPUDIATION 0x0040 /* (1) */ +# define X509v3_KU_KEY_ENCIPHERMENT 0x0020 /* (2) */ +# define X509v3_KU_DATA_ENCIPHERMENT 0x0010 /* (3) */ +# define X509v3_KU_KEY_AGREEMENT 0x0008 /* (4) */ +# define X509v3_KU_KEY_CERT_SIGN 0x0004 /* (5) */ +# define X509v3_KU_CRL_SIGN 0x0002 /* (6) */ +# define X509v3_KU_ENCIPHER_ONLY 0x0001 /* (7) */ +# define X509v3_KU_DECIPHER_ONLY 0x8000 /* (8) */ +# ifndef OPENSSL_NO_DEPRECATED_3_4 +# define X509v3_KU_UNDEF 0xffff /* vestigial, not used */ +# endif + +struct X509_algor_st { + ASN1_OBJECT *algorithm; + ASN1_TYPE *parameter; +} /* X509_ALGOR */ ; + +typedef STACK_OF(X509_ALGOR) X509_ALGORS; + +typedef struct X509_val_st { + ASN1_TIME *notBefore; + ASN1_TIME *notAfter; +} X509_VAL; + +typedef struct X509_sig_st X509_SIG; + +typedef struct X509_name_entry_st X509_NAME_ENTRY; + +SKM_DEFINE_STACK_OF_INTERNAL(X509_NAME_ENTRY, X509_NAME_ENTRY, X509_NAME_ENTRY) +#define sk_X509_NAME_ENTRY_num(sk) OPENSSL_sk_num(ossl_check_const_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_value(sk, idx) ((X509_NAME_ENTRY *)OPENSSL_sk_value(ossl_check_const_X509_NAME_ENTRY_sk_type(sk), (idx))) +#define sk_X509_NAME_ENTRY_new(cmp) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new(ossl_check_X509_NAME_ENTRY_compfunc_type(cmp))) +#define sk_X509_NAME_ENTRY_new_null() ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_null()) +#define sk_X509_NAME_ENTRY_new_reserve(cmp, n) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_reserve(ossl_check_X509_NAME_ENTRY_compfunc_type(cmp), (n))) +#define sk_X509_NAME_ENTRY_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_NAME_ENTRY_sk_type(sk), (n)) +#define sk_X509_NAME_ENTRY_free(sk) OPENSSL_sk_free(ossl_check_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_zero(sk) OPENSSL_sk_zero(ossl_check_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_delete(sk, i) ((X509_NAME_ENTRY *)OPENSSL_sk_delete(ossl_check_X509_NAME_ENTRY_sk_type(sk), (i))) +#define sk_X509_NAME_ENTRY_delete_ptr(sk, ptr) ((X509_NAME_ENTRY *)OPENSSL_sk_delete_ptr(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr))) +#define sk_X509_NAME_ENTRY_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)) +#define sk_X509_NAME_ENTRY_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)) +#define sk_X509_NAME_ENTRY_pop(sk) ((X509_NAME_ENTRY *)OPENSSL_sk_pop(ossl_check_X509_NAME_ENTRY_sk_type(sk))) +#define sk_X509_NAME_ENTRY_shift(sk) ((X509_NAME_ENTRY *)OPENSSL_sk_shift(ossl_check_X509_NAME_ENTRY_sk_type(sk))) +#define sk_X509_NAME_ENTRY_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_NAME_ENTRY_sk_type(sk),ossl_check_X509_NAME_ENTRY_freefunc_type(freefunc)) +#define sk_X509_NAME_ENTRY_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr), (idx)) +#define sk_X509_NAME_ENTRY_set(sk, idx, ptr) ((X509_NAME_ENTRY *)OPENSSL_sk_set(ossl_check_X509_NAME_ENTRY_sk_type(sk), (idx), ossl_check_X509_NAME_ENTRY_type(ptr))) +#define sk_X509_NAME_ENTRY_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)) +#define sk_X509_NAME_ENTRY_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)) +#define sk_X509_NAME_ENTRY_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr), pnum) +#define sk_X509_NAME_ENTRY_sort(sk) OPENSSL_sk_sort(ossl_check_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_dup(sk) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_dup(ossl_check_const_X509_NAME_ENTRY_sk_type(sk))) +#define sk_X509_NAME_ENTRY_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_copyfunc_type(copyfunc), ossl_check_X509_NAME_ENTRY_freefunc_type(freefunc))) +#define sk_X509_NAME_ENTRY_set_cmp_func(sk, cmp) ((sk_X509_NAME_ENTRY_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_compfunc_type(cmp))) + + +# define X509_EX_V_NETSCAPE_HACK 0x8000 +# define X509_EX_V_INIT 0x0001 +typedef struct X509_extension_st X509_EXTENSION; +SKM_DEFINE_STACK_OF_INTERNAL(X509_EXTENSION, X509_EXTENSION, X509_EXTENSION) +#define sk_X509_EXTENSION_num(sk) OPENSSL_sk_num(ossl_check_const_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_value(sk, idx) ((X509_EXTENSION *)OPENSSL_sk_value(ossl_check_const_X509_EXTENSION_sk_type(sk), (idx))) +#define sk_X509_EXTENSION_new(cmp) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new(ossl_check_X509_EXTENSION_compfunc_type(cmp))) +#define sk_X509_EXTENSION_new_null() ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_null()) +#define sk_X509_EXTENSION_new_reserve(cmp, n) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_reserve(ossl_check_X509_EXTENSION_compfunc_type(cmp), (n))) +#define sk_X509_EXTENSION_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_EXTENSION_sk_type(sk), (n)) +#define sk_X509_EXTENSION_free(sk) OPENSSL_sk_free(ossl_check_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_zero(sk) OPENSSL_sk_zero(ossl_check_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_delete(sk, i) ((X509_EXTENSION *)OPENSSL_sk_delete(ossl_check_X509_EXTENSION_sk_type(sk), (i))) +#define sk_X509_EXTENSION_delete_ptr(sk, ptr) ((X509_EXTENSION *)OPENSSL_sk_delete_ptr(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr))) +#define sk_X509_EXTENSION_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)) +#define sk_X509_EXTENSION_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)) +#define sk_X509_EXTENSION_pop(sk) ((X509_EXTENSION *)OPENSSL_sk_pop(ossl_check_X509_EXTENSION_sk_type(sk))) +#define sk_X509_EXTENSION_shift(sk) ((X509_EXTENSION *)OPENSSL_sk_shift(ossl_check_X509_EXTENSION_sk_type(sk))) +#define sk_X509_EXTENSION_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_EXTENSION_sk_type(sk),ossl_check_X509_EXTENSION_freefunc_type(freefunc)) +#define sk_X509_EXTENSION_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr), (idx)) +#define sk_X509_EXTENSION_set(sk, idx, ptr) ((X509_EXTENSION *)OPENSSL_sk_set(ossl_check_X509_EXTENSION_sk_type(sk), (idx), ossl_check_X509_EXTENSION_type(ptr))) +#define sk_X509_EXTENSION_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)) +#define sk_X509_EXTENSION_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)) +#define sk_X509_EXTENSION_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr), pnum) +#define sk_X509_EXTENSION_sort(sk) OPENSSL_sk_sort(ossl_check_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_dup(sk) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_dup(ossl_check_const_X509_EXTENSION_sk_type(sk))) +#define sk_X509_EXTENSION_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_copyfunc_type(copyfunc), ossl_check_X509_EXTENSION_freefunc_type(freefunc))) +#define sk_X509_EXTENSION_set_cmp_func(sk, cmp) ((sk_X509_EXTENSION_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_compfunc_type(cmp))) + +typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS; +typedef struct x509_attributes_st X509_ATTRIBUTE; +SKM_DEFINE_STACK_OF_INTERNAL(X509_ATTRIBUTE, X509_ATTRIBUTE, X509_ATTRIBUTE) +#define sk_X509_ATTRIBUTE_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_value(sk, idx) ((X509_ATTRIBUTE *)OPENSSL_sk_value(ossl_check_const_X509_ATTRIBUTE_sk_type(sk), (idx))) +#define sk_X509_ATTRIBUTE_new(cmp) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new(ossl_check_X509_ATTRIBUTE_compfunc_type(cmp))) +#define sk_X509_ATTRIBUTE_new_null() ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_null()) +#define sk_X509_ATTRIBUTE_new_reserve(cmp, n) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_reserve(ossl_check_X509_ATTRIBUTE_compfunc_type(cmp), (n))) +#define sk_X509_ATTRIBUTE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_ATTRIBUTE_sk_type(sk), (n)) +#define sk_X509_ATTRIBUTE_free(sk) OPENSSL_sk_free(ossl_check_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_delete(sk, i) ((X509_ATTRIBUTE *)OPENSSL_sk_delete(ossl_check_X509_ATTRIBUTE_sk_type(sk), (i))) +#define sk_X509_ATTRIBUTE_delete_ptr(sk, ptr) ((X509_ATTRIBUTE *)OPENSSL_sk_delete_ptr(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr))) +#define sk_X509_ATTRIBUTE_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)) +#define sk_X509_ATTRIBUTE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)) +#define sk_X509_ATTRIBUTE_pop(sk) ((X509_ATTRIBUTE *)OPENSSL_sk_pop(ossl_check_X509_ATTRIBUTE_sk_type(sk))) +#define sk_X509_ATTRIBUTE_shift(sk) ((X509_ATTRIBUTE *)OPENSSL_sk_shift(ossl_check_X509_ATTRIBUTE_sk_type(sk))) +#define sk_X509_ATTRIBUTE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_ATTRIBUTE_sk_type(sk),ossl_check_X509_ATTRIBUTE_freefunc_type(freefunc)) +#define sk_X509_ATTRIBUTE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr), (idx)) +#define sk_X509_ATTRIBUTE_set(sk, idx, ptr) ((X509_ATTRIBUTE *)OPENSSL_sk_set(ossl_check_X509_ATTRIBUTE_sk_type(sk), (idx), ossl_check_X509_ATTRIBUTE_type(ptr))) +#define sk_X509_ATTRIBUTE_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)) +#define sk_X509_ATTRIBUTE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)) +#define sk_X509_ATTRIBUTE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr), pnum) +#define sk_X509_ATTRIBUTE_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_dup(sk) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_dup(ossl_check_const_X509_ATTRIBUTE_sk_type(sk))) +#define sk_X509_ATTRIBUTE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_copyfunc_type(copyfunc), ossl_check_X509_ATTRIBUTE_freefunc_type(freefunc))) +#define sk_X509_ATTRIBUTE_set_cmp_func(sk, cmp) ((sk_X509_ATTRIBUTE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_compfunc_type(cmp))) + +typedef struct X509_req_info_st X509_REQ_INFO; +typedef struct X509_req_st X509_REQ; +typedef struct x509_cert_aux_st X509_CERT_AUX; +typedef struct x509_cinf_st X509_CINF; + +/* Flags for X509_print_ex() */ + +# define X509_FLAG_COMPAT 0 +# define X509_FLAG_NO_HEADER 1L +# define X509_FLAG_NO_VERSION (1L << 1) +# define X509_FLAG_NO_SERIAL (1L << 2) +# define X509_FLAG_NO_SIGNAME (1L << 3) +# define X509_FLAG_NO_ISSUER (1L << 4) +# define X509_FLAG_NO_VALIDITY (1L << 5) +# define X509_FLAG_NO_SUBJECT (1L << 6) +# define X509_FLAG_NO_PUBKEY (1L << 7) +# define X509_FLAG_NO_EXTENSIONS (1L << 8) +# define X509_FLAG_NO_SIGDUMP (1L << 9) +# define X509_FLAG_NO_AUX (1L << 10) +# define X509_FLAG_NO_ATTRIBUTES (1L << 11) +# define X509_FLAG_NO_IDS (1L << 12) +# define X509_FLAG_EXTENSIONS_ONLY_KID (1L << 13) + +/* Flags specific to X509_NAME_print_ex() */ + +/* The field separator information */ + +# define XN_FLAG_SEP_MASK (0xf << 16) + +# define XN_FLAG_COMPAT 0/* Traditional; use old X509_NAME_print */ +# define XN_FLAG_SEP_COMMA_PLUS (1 << 16)/* RFC2253 ,+ */ +# define XN_FLAG_SEP_CPLUS_SPC (2 << 16)/* ,+ spaced: more readable */ +# define XN_FLAG_SEP_SPLUS_SPC (3 << 16)/* ;+ spaced */ +# define XN_FLAG_SEP_MULTILINE (4 << 16)/* One line per field */ + +# define XN_FLAG_DN_REV (1 << 20)/* Reverse DN order */ + +/* How the field name is shown */ + +# define XN_FLAG_FN_MASK (0x3 << 21) + +# define XN_FLAG_FN_SN 0/* Object short name */ +# define XN_FLAG_FN_LN (1 << 21)/* Object long name */ +# define XN_FLAG_FN_OID (2 << 21)/* Always use OIDs */ +# define XN_FLAG_FN_NONE (3 << 21)/* No field names */ + +# define XN_FLAG_SPC_EQ (1 << 23)/* Put spaces round '=' */ + +/* + * This determines if we dump fields we don't recognise: RFC2253 requires + * this. + */ + +# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) + +# define XN_FLAG_FN_ALIGN (1 << 25)/* Align field names to 20 + * characters */ + +/* Complete set of RFC2253 flags */ + +# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ + XN_FLAG_SEP_COMMA_PLUS | \ + XN_FLAG_DN_REV | \ + XN_FLAG_FN_SN | \ + XN_FLAG_DUMP_UNKNOWN_FIELDS) + +/* readable oneline form */ + +# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ + ASN1_STRFLGS_ESC_QUOTE | \ + XN_FLAG_SEP_CPLUS_SPC | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_SN) + +/* readable multiline form */ + +# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + XN_FLAG_SEP_MULTILINE | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_LN | \ + XN_FLAG_FN_ALIGN) + +typedef struct X509_crl_info_st X509_CRL_INFO; + +typedef struct private_key_st { + int version; + /* The PKCS#8 data types */ + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ + /* When decrypted, the following will not be NULL */ + EVP_PKEY *dec_pkey; + /* used to encrypt and decrypt */ + int key_length; + char *key_data; + int key_free; /* true if we should auto free key_data */ + /* expanded version of 'enc_algor' */ + EVP_CIPHER_INFO cipher; +} X509_PKEY; + +typedef struct X509_info_st { + X509 *x509; + X509_CRL *crl; + X509_PKEY *x_pkey; + EVP_CIPHER_INFO enc_cipher; + int enc_len; + char *enc_data; +} X509_INFO; +SKM_DEFINE_STACK_OF_INTERNAL(X509_INFO, X509_INFO, X509_INFO) +#define sk_X509_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_X509_INFO_sk_type(sk)) +#define sk_X509_INFO_value(sk, idx) ((X509_INFO *)OPENSSL_sk_value(ossl_check_const_X509_INFO_sk_type(sk), (idx))) +#define sk_X509_INFO_new(cmp) ((STACK_OF(X509_INFO) *)OPENSSL_sk_new(ossl_check_X509_INFO_compfunc_type(cmp))) +#define sk_X509_INFO_new_null() ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_null()) +#define sk_X509_INFO_new_reserve(cmp, n) ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_reserve(ossl_check_X509_INFO_compfunc_type(cmp), (n))) +#define sk_X509_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_INFO_sk_type(sk), (n)) +#define sk_X509_INFO_free(sk) OPENSSL_sk_free(ossl_check_X509_INFO_sk_type(sk)) +#define sk_X509_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_X509_INFO_sk_type(sk)) +#define sk_X509_INFO_delete(sk, i) ((X509_INFO *)OPENSSL_sk_delete(ossl_check_X509_INFO_sk_type(sk), (i))) +#define sk_X509_INFO_delete_ptr(sk, ptr) ((X509_INFO *)OPENSSL_sk_delete_ptr(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr))) +#define sk_X509_INFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)) +#define sk_X509_INFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)) +#define sk_X509_INFO_pop(sk) ((X509_INFO *)OPENSSL_sk_pop(ossl_check_X509_INFO_sk_type(sk))) +#define sk_X509_INFO_shift(sk) ((X509_INFO *)OPENSSL_sk_shift(ossl_check_X509_INFO_sk_type(sk))) +#define sk_X509_INFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_INFO_sk_type(sk),ossl_check_X509_INFO_freefunc_type(freefunc)) +#define sk_X509_INFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr), (idx)) +#define sk_X509_INFO_set(sk, idx, ptr) ((X509_INFO *)OPENSSL_sk_set(ossl_check_X509_INFO_sk_type(sk), (idx), ossl_check_X509_INFO_type(ptr))) +#define sk_X509_INFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)) +#define sk_X509_INFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)) +#define sk_X509_INFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr), pnum) +#define sk_X509_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_X509_INFO_sk_type(sk)) +#define sk_X509_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_INFO_sk_type(sk)) +#define sk_X509_INFO_dup(sk) ((STACK_OF(X509_INFO) *)OPENSSL_sk_dup(ossl_check_const_X509_INFO_sk_type(sk))) +#define sk_X509_INFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_INFO) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_INFO_sk_type(sk), ossl_check_X509_INFO_copyfunc_type(copyfunc), ossl_check_X509_INFO_freefunc_type(freefunc))) +#define sk_X509_INFO_set_cmp_func(sk, cmp) ((sk_X509_INFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_compfunc_type(cmp))) + + +/* + * The next 2 structures and their 8 routines are used to manipulate Netscape's + * spki structures - useful if you are writing a CA web page + */ +typedef struct Netscape_spkac_st { + X509_PUBKEY *pubkey; + ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ +} NETSCAPE_SPKAC; + +typedef struct Netscape_spki_st { + NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ + X509_ALGOR sig_algor; + ASN1_BIT_STRING *signature; +} NETSCAPE_SPKI; + +/* Netscape certificate sequence structure */ +typedef struct Netscape_certificate_sequence { + ASN1_OBJECT *type; + STACK_OF(X509) *certs; +} NETSCAPE_CERT_SEQUENCE; + +/*- Unused (and iv length is wrong) +typedef struct CBCParameter_st + { + unsigned char iv[8]; + } CBC_PARAM; +*/ + +/* Password based encryption structure */ + +typedef struct PBEPARAM_st { + ASN1_OCTET_STRING *salt; + ASN1_INTEGER *iter; +} PBEPARAM; + +/* Password based encryption V2 structures */ + +typedef struct PBE2PARAM_st { + X509_ALGOR *keyfunc; + X509_ALGOR *encryption; +} PBE2PARAM; + +typedef struct PBKDF2PARAM_st { +/* Usually OCTET STRING but could be anything */ + ASN1_TYPE *salt; + ASN1_INTEGER *iter; + ASN1_INTEGER *keylength; + X509_ALGOR *prf; +} PBKDF2PARAM; + +typedef struct { + X509_ALGOR *keyDerivationFunc; + X509_ALGOR *messageAuthScheme; +} PBMAC1PARAM; + +# ifndef OPENSSL_NO_SCRYPT +typedef struct SCRYPT_PARAMS_st { + ASN1_OCTET_STRING *salt; + ASN1_INTEGER *costParameter; + ASN1_INTEGER *blockSize; + ASN1_INTEGER *parallelizationParameter; + ASN1_INTEGER *keyLength; +} SCRYPT_PARAMS; +# endif + +#ifdef __cplusplus +} +#endif + +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +# define X509_EXT_PACK_UNKNOWN 1 +# define X509_EXT_PACK_STRING 2 + +# define X509_extract_key(x) X509_get_pubkey(x)/*****/ +# define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) +# define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) + +void X509_CRL_set_default_method(const X509_CRL_METHOD *meth); +X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl), + int (*crl_free) (X509_CRL *crl), + int (*crl_lookup) (X509_CRL *crl, + X509_REVOKED **ret, + const + ASN1_INTEGER *serial, + const + X509_NAME *issuer), + int (*crl_verify) (X509_CRL *crl, + EVP_PKEY *pk)); +void X509_CRL_METHOD_free(X509_CRL_METHOD *m); + +void X509_CRL_set_meth_data(X509_CRL *crl, void *dat); +void *X509_CRL_get_meth_data(X509_CRL *crl); + +const char *X509_verify_cert_error_string(long n); + +int X509_verify(X509 *a, EVP_PKEY *r); +int X509_self_signed(X509 *cert, int verify_signature); + +int X509_REQ_verify_ex(X509_REQ *a, EVP_PKEY *r, OSSL_LIB_CTX *libctx, + const char *propq); +int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); +int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); +int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); + +NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len); +char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); +EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); +int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); + +int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); + +int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent); +int X509_signature_print(BIO *bp, const X509_ALGOR *alg, + const ASN1_STRING *sig); + +int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx); +int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx); +int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx); +int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); + +int X509_pubkey_digest(const X509 *data, const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_digest(const X509 *data, const EVP_MD *type, + unsigned char *md, unsigned int *len); +ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert, + EVP_MD **md_used, int *md_is_fallback); +int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, + unsigned char *md, unsigned int *len); + +X509 *X509_load_http(const char *url, BIO *bio, BIO *rbio, int timeout); +X509_CRL *X509_CRL_load_http(const char *url, BIO *bio, BIO *rbio, int timeout); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# include /* OSSL_HTTP_REQ_CTX_nbio_d2i */ +# define X509_http_nbio(rctx, pcert) \ + OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcert, ASN1_ITEM_rptr(X509)) +# define X509_CRL_http_nbio(rctx, pcrl) \ + OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcrl, ASN1_ITEM_rptr(X509_CRL)) +# endif + +# ifndef OPENSSL_NO_STDIO +X509 *d2i_X509_fp(FILE *fp, X509 **x509); +int i2d_X509_fp(FILE *fp, const X509 *x509); +X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl); +int i2d_X509_CRL_fp(FILE *fp, const X509_CRL *crl); +X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req); +int i2d_X509_REQ_fp(FILE *fp, const X509_REQ *req); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa); +OSSL_DEPRECATEDIN_3_0 int i2d_RSAPrivateKey_fp(FILE *fp, const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa); +OSSL_DEPRECATEDIN_3_0 int i2d_RSAPublicKey_fp(FILE *fp, const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa); +OSSL_DEPRECATEDIN_3_0 int i2d_RSA_PUBKEY_fp(FILE *fp, const RSA *rsa); +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DSA +OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); +OSSL_DEPRECATEDIN_3_0 int i2d_DSA_PUBKEY_fp(FILE *fp, const DSA *dsa); +OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); +OSSL_DEPRECATEDIN_3_0 int i2d_DSAPrivateKey_fp(FILE *fp, const DSA *dsa); +# endif +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_EC +OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); +OSSL_DEPRECATEDIN_3_0 int i2d_EC_PUBKEY_fp(FILE *fp, const EC_KEY *eckey); +OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); +OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey_fp(FILE *fp, const EC_KEY *eckey); +# endif /* OPENSSL_NO_EC */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8); +int i2d_PKCS8_fp(FILE *fp, const X509_SIG *p8); +X509_PUBKEY *d2i_X509_PUBKEY_fp(FILE *fp, X509_PUBKEY **xpk); +int i2d_X509_PUBKEY_fp(FILE *fp, const X509_PUBKEY *xpk); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, const PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, const EVP_PKEY *key); +int i2d_PrivateKey_fp(FILE *fp, const EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, + const char *propq); +EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); +int i2d_PUBKEY_fp(FILE *fp, const EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, + const char *propq); +EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); +# endif + +X509 *d2i_X509_bio(BIO *bp, X509 **x509); +int i2d_X509_bio(BIO *bp, const X509 *x509); +X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl); +int i2d_X509_CRL_bio(BIO *bp, const X509_CRL *crl); +X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req); +int i2d_X509_REQ_bio(BIO *bp, const X509_REQ *req); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa); +OSSL_DEPRECATEDIN_3_0 int i2d_RSAPrivateKey_bio(BIO *bp, const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa); +OSSL_DEPRECATEDIN_3_0 int i2d_RSAPublicKey_bio(BIO *bp, const RSA *rsa); +OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa); +OSSL_DEPRECATEDIN_3_0 int i2d_RSA_PUBKEY_bio(BIO *bp, const RSA *rsa); +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DSA +OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); +OSSL_DEPRECATEDIN_3_0 int i2d_DSA_PUBKEY_bio(BIO *bp, const DSA *dsa); +OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); +OSSL_DEPRECATEDIN_3_0 int i2d_DSAPrivateKey_bio(BIO *bp, const DSA *dsa); +# endif +# endif + +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_EC +OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); +OSSL_DEPRECATEDIN_3_0 int i2d_EC_PUBKEY_bio(BIO *bp, const EC_KEY *eckey); +OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); +OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey_bio(BIO *bp, const EC_KEY *eckey); +# endif /* OPENSSL_NO_EC */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ + +X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8); +int i2d_PKCS8_bio(BIO *bp, const X509_SIG *p8); +X509_PUBKEY *d2i_X509_PUBKEY_bio(BIO *bp, X509_PUBKEY **xpk); +int i2d_X509_PUBKEY_bio(BIO *bp, const X509_PUBKEY *xpk); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, const PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, const EVP_PKEY *key); +int i2d_PrivateKey_bio(BIO *bp, const EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, + const char *propq); +EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); +int i2d_PUBKEY_bio(BIO *bp, const EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, + const char *propq); +EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); + +DECLARE_ASN1_DUP_FUNCTION(X509) +DECLARE_ASN1_DUP_FUNCTION(X509_ALGOR) +DECLARE_ASN1_DUP_FUNCTION(X509_ATTRIBUTE) +DECLARE_ASN1_DUP_FUNCTION(X509_CRL) +DECLARE_ASN1_DUP_FUNCTION(X509_EXTENSION) +DECLARE_ASN1_DUP_FUNCTION(X509_PUBKEY) +DECLARE_ASN1_DUP_FUNCTION(X509_REQ) +DECLARE_ASN1_DUP_FUNCTION(X509_REVOKED) +int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, + void *pval); +void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, + const void **ppval, const X509_ALGOR *algor); +void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md); +int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b); +int X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src); + +DECLARE_ASN1_DUP_FUNCTION(X509_NAME) +DECLARE_ASN1_DUP_FUNCTION(X509_NAME_ENTRY) + +int X509_cmp_time(const ASN1_TIME *s, time_t *t); +int X509_cmp_current_time(const ASN1_TIME *s); +int X509_cmp_timeframe(const X509_VERIFY_PARAM *vpm, + const ASN1_TIME *start, const ASN1_TIME *end); +ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t); +ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, + int offset_day, long offset_sec, time_t *t); +ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj); + +const char *X509_get_default_cert_area(void); +const char *X509_get_default_cert_dir(void); +const char *X509_get_default_cert_file(void); +const char *X509_get_default_cert_dir_env(void); +const char *X509_get_default_cert_file_env(void); +const char *X509_get_default_private_dir(void); + +X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey); + +DECLARE_ASN1_FUNCTIONS(X509_ALGOR) +DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS) +DECLARE_ASN1_FUNCTIONS(X509_VAL) + +DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) + +X509_PUBKEY *X509_PUBKEY_new_ex(OSSL_LIB_CTX *libctx, const char *propq); +int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); +EVP_PKEY *X509_PUBKEY_get0(const X509_PUBKEY *key); +EVP_PKEY *X509_PUBKEY_get(const X509_PUBKEY *key); +int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain); +long X509_get_pathlen(X509 *x); +DECLARE_ASN1_ENCODE_FUNCTIONS_only(EVP_PKEY, PUBKEY) +EVP_PKEY *d2i_PUBKEY_ex(EVP_PKEY **a, const unsigned char **pp, long length, + OSSL_LIB_CTX *libctx, const char *propq); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,RSA, RSA_PUBKEY) +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DSA +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,DSA, DSA_PUBKEY) +# endif +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_EC +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, EC_KEY, EC_PUBKEY) +# endif +# endif + +DECLARE_ASN1_FUNCTIONS(X509_SIG) +void X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg, + const ASN1_OCTET_STRING **pdigest); +void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg, + ASN1_OCTET_STRING **pdigest); + +DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) +DECLARE_ASN1_FUNCTIONS(X509_REQ) +X509_REQ *X509_REQ_new_ex(OSSL_LIB_CTX *libctx, const char *propq); + +DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) +X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); + +DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) +DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS) + +DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) + +DECLARE_ASN1_FUNCTIONS(X509_NAME) + +int X509_NAME_set(X509_NAME **xn, const X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(X509_CINF) +DECLARE_ASN1_FUNCTIONS(X509) +X509 *X509_new_ex(OSSL_LIB_CTX *libctx, const char *propq); +DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) + +#define X509_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef) +int X509_set_ex_data(X509 *r, int idx, void *arg); +void *X509_get_ex_data(const X509 *r, int idx); +DECLARE_ASN1_ENCODE_FUNCTIONS_only(X509,X509_AUX) + +int i2d_re_X509_tbs(X509 *x, unsigned char **pp); + +int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid, + int *secbits, uint32_t *flags); +void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid, + int secbits, uint32_t flags); + +int X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits, + uint32_t *flags); + +void X509_get0_signature(const ASN1_BIT_STRING **psig, + const X509_ALGOR **palg, const X509 *x); +int X509_get_signature_nid(const X509 *x); + +void X509_set0_distinguishing_id(X509 *x, ASN1_OCTET_STRING *d_id); +ASN1_OCTET_STRING *X509_get0_distinguishing_id(X509 *x); +void X509_REQ_set0_distinguishing_id(X509_REQ *x, ASN1_OCTET_STRING *d_id); +ASN1_OCTET_STRING *X509_REQ_get0_distinguishing_id(X509_REQ *x); + +int X509_alias_set1(X509 *x, const unsigned char *name, int len); +int X509_keyid_set1(X509 *x, const unsigned char *id, int len); +unsigned char *X509_alias_get0(X509 *x, int *len); +unsigned char *X509_keyid_get0(X509 *x, int *len); + +DECLARE_ASN1_FUNCTIONS(X509_REVOKED) +DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) +DECLARE_ASN1_FUNCTIONS(X509_CRL) +X509_CRL *X509_CRL_new_ex(OSSL_LIB_CTX *libctx, const char *propq); + +int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); +int X509_CRL_get0_by_serial(X509_CRL *crl, + X509_REVOKED **ret, const ASN1_INTEGER *serial); +int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x); + +X509_PKEY *X509_PKEY_new(void); +void X509_PKEY_free(X509_PKEY *a); + +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) + +X509_INFO *X509_INFO_new(void); +void X509_INFO_free(X509_INFO *a); +char *X509_NAME_oneline(const X509_NAME *a, char *buf, int size); + +#ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 +int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey); +OSSL_DEPRECATEDIN_3_0 +int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, + unsigned char *md, unsigned int *len); +OSSL_DEPRECATEDIN_3_0 +int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2, + ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey, + const EVP_MD *type); +#endif +int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data, + unsigned char *md, unsigned int *len); +int ASN1_item_verify(const ASN1_ITEM *it, const X509_ALGOR *alg, + const ASN1_BIT_STRING *signature, const void *data, + EVP_PKEY *pkey); +int ASN1_item_verify_ctx(const ASN1_ITEM *it, const X509_ALGOR *alg, + const ASN1_BIT_STRING *signature, const void *data, + EVP_MD_CTX *ctx); +int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, + ASN1_BIT_STRING *signature, const void *data, + EVP_PKEY *pkey, const EVP_MD *md); +int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, + X509_ALGOR *algor2, ASN1_BIT_STRING *signature, + const void *data, EVP_MD_CTX *ctx); + +#define X509_VERSION_1 0 +#define X509_VERSION_2 1 +#define X509_VERSION_3 2 + +long X509_get_version(const X509 *x); +int X509_set_version(X509 *x, long version); +int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); +ASN1_INTEGER *X509_get_serialNumber(X509 *x); +const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x); +int X509_set_issuer_name(X509 *x, const X509_NAME *name); +X509_NAME *X509_get_issuer_name(const X509 *a); +int X509_set_subject_name(X509 *x, const X509_NAME *name); +X509_NAME *X509_get_subject_name(const X509 *a); +const ASN1_TIME * X509_get0_notBefore(const X509 *x); +ASN1_TIME *X509_getm_notBefore(const X509 *x); +int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm); +const ASN1_TIME *X509_get0_notAfter(const X509 *x); +ASN1_TIME *X509_getm_notAfter(const X509 *x); +int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm); +int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); +int X509_up_ref(X509 *x); +int X509_get_signature_type(const X509 *x); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define X509_get_notBefore X509_getm_notBefore +# define X509_get_notAfter X509_getm_notAfter +# define X509_set_notBefore X509_set1_notBefore +# define X509_set_notAfter X509_set1_notAfter +#endif + + +/* + * This one is only used so that a binary form can output, as in + * i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &buf) + */ +X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x); +const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x); +void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid, + const ASN1_BIT_STRING **psuid); +const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x); + +EVP_PKEY *X509_get0_pubkey(const X509 *x); +EVP_PKEY *X509_get_pubkey(X509 *x); +ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x); + +#define X509_REQ_VERSION_1 0 + +long X509_REQ_get_version(const X509_REQ *req); +int X509_REQ_set_version(X509_REQ *x, long version); +X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req); +int X509_REQ_set_subject_name(X509_REQ *req, const X509_NAME *name); +void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig, + const X509_ALGOR **palg); +void X509_REQ_set0_signature(X509_REQ *req, ASN1_BIT_STRING *psig); +int X509_REQ_set1_signature_algo(X509_REQ *req, X509_ALGOR *palg); +int X509_REQ_get_signature_nid(const X509_REQ *req); +int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp); +int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); +EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req); +EVP_PKEY *X509_REQ_get0_pubkey(const X509_REQ *req); +X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req); +int X509_REQ_extension_nid(int nid); +int *X509_REQ_get_extension_nids(void); +void X509_REQ_set_extension_nids(int *nids); +STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(OSSL_FUTURE_CONST X509_REQ *req); +int X509_REQ_add_extensions_nid(X509_REQ *req, + const STACK_OF(X509_EXTENSION) *exts, int nid); +int X509_REQ_add_extensions(X509_REQ *req, const STACK_OF(X509_EXTENSION) *ext); +int X509_REQ_get_attr_count(const X509_REQ *req); +int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos); +int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); +X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); +int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); +int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_NID(X509_REQ *req, + int nid, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_txt(X509_REQ *req, + const char *attrname, int type, + const unsigned char *bytes, int len); + +#define X509_CRL_VERSION_1 0 +#define X509_CRL_VERSION_2 1 + +int X509_CRL_set_version(X509_CRL *x, long version); +int X509_CRL_set_issuer_name(X509_CRL *x, const X509_NAME *name); +int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm); +int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm); +int X509_CRL_sort(X509_CRL *crl); +int X509_CRL_up_ref(X509_CRL *crl); + +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate +# define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate +#endif + +long X509_CRL_get_version(const X509_CRL *crl); +const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl); +const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl); +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl); +OSSL_DEPRECATEDIN_1_1_0 ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl); +#endif +X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl); +const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl); +STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl); +void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, + const X509_ALGOR **palg); +int X509_CRL_get_signature_nid(const X509_CRL *crl); +int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp); + +const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x); +int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); +const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x); +int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); +const STACK_OF(X509_EXTENSION) * +X509_REVOKED_get0_extensions(const X509_REVOKED *r); + +X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, + EVP_PKEY *skey, const EVP_MD *md, unsigned int flags); + +int X509_REQ_check_private_key(const X509_REQ *req, EVP_PKEY *pkey); + +int X509_check_private_key(const X509 *cert, const EVP_PKEY *pkey); +int X509_chain_check_suiteb(int *perror_depth, + X509 *x, STACK_OF(X509) *chain, + unsigned long flags); +int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags); +void OSSL_STACK_OF_X509_free(STACK_OF(X509) *certs); +STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain); + +int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_and_serial_hash(X509 *a); + +int X509_issuer_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_name_hash(X509 *a); + +int X509_subject_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_subject_name_hash(X509 *x); + +# ifndef OPENSSL_NO_MD5 +unsigned long X509_issuer_name_hash_old(X509 *a); +unsigned long X509_subject_name_hash_old(X509 *x); +# endif + +# define X509_ADD_FLAG_DEFAULT 0 +# define X509_ADD_FLAG_UP_REF 0x1 +# define X509_ADD_FLAG_PREPEND 0x2 +# define X509_ADD_FLAG_NO_DUP 0x4 +# define X509_ADD_FLAG_NO_SS 0x8 +int X509_add_cert(STACK_OF(X509) *sk, X509 *cert, int flags); +int X509_add_certs(STACK_OF(X509) *sk, STACK_OF(X509) *certs, int flags); + +int X509_cmp(const X509 *a, const X509 *b); +int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); +#ifndef OPENSSL_NO_DEPRECATED_3_0 +# define X509_NAME_hash(x) X509_NAME_hash_ex(x, NULL, NULL, NULL) +OSSL_DEPRECATEDIN_3_0 int X509_certificate_type(const X509 *x, + const EVP_PKEY *pubkey); +#endif +unsigned long X509_NAME_hash_ex(const X509_NAME *x, OSSL_LIB_CTX *libctx, + const char *propq, int *ok); +unsigned long X509_NAME_hash_old(const X509_NAME *x); + +int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); +int X509_CRL_match(const X509_CRL *a, const X509_CRL *b); +int X509_aux_print(BIO *out, X509 *x, int indent); +# ifndef OPENSSL_NO_STDIO +int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag, + unsigned long cflag); +int X509_print_fp(FILE *bp, X509 *x); +int X509_CRL_print_fp(FILE *bp, X509_CRL *x); +int X509_REQ_print_fp(FILE *bp, X509_REQ *req); +int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent, + unsigned long flags); +# endif + +int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase); +int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, + unsigned long flags); +int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag, + unsigned long cflag); +int X509_print(BIO *bp, X509 *x); +int X509_ocspid_print(BIO *bp, X509 *x); +int X509_CRL_print_ex(BIO *out, X509_CRL *x, unsigned long nmflag); +int X509_CRL_print(BIO *bp, X509_CRL *x); +int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, + unsigned long cflag); +int X509_REQ_print(BIO *bp, X509_REQ *req); + +int X509_NAME_entry_count(const X509_NAME *name); +int X509_NAME_get_text_by_NID(const X509_NAME *name, int nid, + char *buf, int len); +int X509_NAME_get_text_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, + char *buf, int len); + +/* + * NOTE: you should be passing -1, not 0 as lastpos. The functions that use + * lastpos, search after that position on. + */ +int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos); +int X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, + int lastpos); +X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc); +X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); +int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, + int loc, int set); +int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len, int loc, + int set); +int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, + const unsigned char *bytes, int len, int loc, + int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, + const char *field, int type, + const unsigned char *bytes, + int len); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, + int type, + const unsigned char *bytes, + int len); +int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, + const unsigned char *bytes, int len, int loc, + int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, + int len); +int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj); +int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, + const unsigned char *bytes, int len); +ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne); +ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne); +int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne); + +int X509_NAME_get0_der(const X509_NAME *nm, const unsigned char **pder, + size_t *pderlen); + +int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); +int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, + int nid, int lastpos); +int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, + const ASN1_OBJECT *obj, int lastpos); +int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, + int crit, int lastpos); +X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); +X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); +STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, + X509_EXTENSION *ex, int loc); +STACK_OF(X509_EXTENSION) *X509v3_add_extensions(STACK_OF(X509_EXTENSION) **target, + const STACK_OF(X509_EXTENSION) *exts); + +int X509_get_ext_count(const X509 *x); +int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos); +int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos); +int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos); +X509_EXTENSION *X509_get_ext(const X509 *x, int loc); +X509_EXTENSION *X509_delete_ext(X509 *x, int loc); +int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); +void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx); +int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_CRL_get_ext_count(const X509_CRL *x); +int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos); +int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, + int lastpos); +int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos); +X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc); +X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); +int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); +void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx); +int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_REVOKED_get_ext_count(const X509_REVOKED *x); +int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos); +int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, + int lastpos); +int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, + int lastpos); +X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc); +X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); +int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); +void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit, + int *idx); +int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, + unsigned long flags); + +X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, + int nid, int crit, + ASN1_OCTET_STRING *data); +X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, + const ASN1_OBJECT *obj, int crit, + ASN1_OCTET_STRING *data); +int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj); +int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); +int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data); +ASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex); +ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); +int X509_EXTENSION_get_critical(const X509_EXTENSION *ex); + +int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); +int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, + int lastpos); +int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, + const ASN1_OBJECT *obj, int lastpos); +X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); +X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, + X509_ATTRIBUTE *attr); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) + **x, const ASN1_OBJECT *obj, + int type, + const unsigned char *bytes, + int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) + **x, int nid, int type, + const unsigned char *bytes, + int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) + **x, const char *attrname, + int type, + const unsigned char *bytes, + int len); +void *X509at_get0_data_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *x, + const ASN1_OBJECT *obj, int lastpos, int type); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, + int atrtype, const void *data, + int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, + const ASN1_OBJECT *obj, + int atrtype, const void *data, + int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, + const char *atrname, int type, + const unsigned char *bytes, + int len); +int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); +int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, + const void *data, int len); +void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, + void *data); +int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr); +ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); +ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); + +int EVP_PKEY_get_attr_count(const EVP_PKEY *key); +int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos); +int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); +X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); +int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); +int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, + int nid, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, + const char *attrname, int type, + const unsigned char *bytes, int len); + +/* lookup a cert from a X509 STACK */ +X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, const X509_NAME *name, + const ASN1_INTEGER *serial); +X509 *X509_find_by_subject(STACK_OF(X509) *sk, const X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(PBEPARAM) +DECLARE_ASN1_FUNCTIONS(PBE2PARAM) +DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) +DECLARE_ASN1_FUNCTIONS(PBMAC1PARAM) +# ifndef OPENSSL_NO_SCRYPT +DECLARE_ASN1_FUNCTIONS(SCRYPT_PARAMS) +# endif + +int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, + const unsigned char *salt, int saltlen); +int PKCS5_pbe_set0_algor_ex(X509_ALGOR *algor, int alg, int iter, + const unsigned char *salt, int saltlen, + OSSL_LIB_CTX *libctx); + +X509_ALGOR *PKCS5_pbe_set(int alg, int iter, + const unsigned char *salt, int saltlen); +X509_ALGOR *PKCS5_pbe_set_ex(int alg, int iter, + const unsigned char *salt, int saltlen, + OSSL_LIB_CTX *libctx); + +X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen); +X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen, + unsigned char *aiv, int prf_nid); +X509_ALGOR *PKCS5_pbe2_set_iv_ex(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen, + unsigned char *aiv, int prf_nid, + OSSL_LIB_CTX *libctx); + +#ifndef OPENSSL_NO_SCRYPT +X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher, + const unsigned char *salt, int saltlen, + unsigned char *aiv, uint64_t N, uint64_t r, + uint64_t p); +#endif + +X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, + int prf_nid, int keylen); +X509_ALGOR *PKCS5_pbkdf2_set_ex(int iter, unsigned char *salt, int saltlen, + int prf_nid, int keylen, + OSSL_LIB_CTX *libctx); + +PBKDF2PARAM *PBMAC1_get1_pbkdf2_param(const X509_ALGOR *macalg); +/* PKCS#8 utilities */ + +DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) + +EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8); +EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx, + const char *propq); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey); + +int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, + int version, int ptype, void *pval, + unsigned char *penc, int penclen); +int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, + const unsigned char **pk, int *ppklen, + const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8); + +const STACK_OF(X509_ATTRIBUTE) * +PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8); +int PKCS8_pkey_add1_attr(PKCS8_PRIV_KEY_INFO *p8, X509_ATTRIBUTE *attr); +int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type, + const unsigned char *bytes, int len); +int PKCS8_pkey_add1_attr_by_OBJ(PKCS8_PRIV_KEY_INFO *p8, const ASN1_OBJECT *obj, + int type, const unsigned char *bytes, int len); + + +void X509_PUBKEY_set0_public_key(X509_PUBKEY *pub, + unsigned char *penc, int penclen); +int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, + int ptype, void *pval, + unsigned char *penc, int penclen); +int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, + const unsigned char **pk, int *ppklen, + X509_ALGOR **pa, const X509_PUBKEY *pub); +int X509_PUBKEY_eq(const X509_PUBKEY *a, const X509_PUBKEY *b); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/x509_acert.h b/illumos-x86_64/usr/include/openssl-3/x509_acert.h new file mode 100644 index 00000000..9dde6256 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/x509_acert.h @@ -0,0 +1,294 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/x509_acert.h.in + * + * Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_X509_ACERT_H +# define OPENSSL_X509_ACERT_H +# pragma once + +# include +# include +# include + +typedef struct X509_acert_st X509_ACERT; +typedef struct X509_acert_info_st X509_ACERT_INFO; +typedef struct ossl_object_digest_info_st OSSL_OBJECT_DIGEST_INFO; +typedef struct ossl_issuer_serial_st OSSL_ISSUER_SERIAL; +typedef struct X509_acert_issuer_v2form_st X509_ACERT_ISSUER_V2FORM; + +DECLARE_ASN1_FUNCTIONS(X509_ACERT) +DECLARE_ASN1_DUP_FUNCTION(X509_ACERT) +DECLARE_ASN1_ITEM(X509_ACERT_INFO) +DECLARE_ASN1_ALLOC_FUNCTIONS(X509_ACERT_INFO) +DECLARE_ASN1_ALLOC_FUNCTIONS(OSSL_OBJECT_DIGEST_INFO) +DECLARE_ASN1_ALLOC_FUNCTIONS(OSSL_ISSUER_SERIAL) +DECLARE_ASN1_ALLOC_FUNCTIONS(X509_ACERT_ISSUER_V2FORM) + +# ifndef OPENSSL_NO_STDIO +X509_ACERT *d2i_X509_ACERT_fp(FILE *fp, X509_ACERT **acert); +int i2d_X509_ACERT_fp(FILE *fp, const X509_ACERT *acert); +# endif + +DECLARE_PEM_rw(X509_ACERT, X509_ACERT) + +X509_ACERT *d2i_X509_ACERT_bio(BIO *bp, X509_ACERT **acert); +int i2d_X509_ACERT_bio(BIO *bp, const X509_ACERT *acert); + +int X509_ACERT_sign(X509_ACERT *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_ACERT_sign_ctx(X509_ACERT *x, EVP_MD_CTX *ctx); +int X509_ACERT_verify(X509_ACERT *a, EVP_PKEY *r); + +# define X509_ACERT_VERSION_2 1 + +const GENERAL_NAMES *X509_ACERT_get0_holder_entityName(const X509_ACERT *x); +const OSSL_ISSUER_SERIAL *X509_ACERT_get0_holder_baseCertId(const X509_ACERT *x); +const OSSL_OBJECT_DIGEST_INFO * X509_ACERT_get0_holder_digest(const X509_ACERT *x); +const X509_NAME *X509_ACERT_get0_issuerName(const X509_ACERT *x); +long X509_ACERT_get_version(const X509_ACERT *x); +void X509_ACERT_get0_signature(const X509_ACERT *x, + const ASN1_BIT_STRING **psig, + const X509_ALGOR **palg); +int X509_ACERT_get_signature_nid(const X509_ACERT *x); +const X509_ALGOR *X509_ACERT_get0_info_sigalg(const X509_ACERT *x); +const ASN1_INTEGER *X509_ACERT_get0_serialNumber(const X509_ACERT *x); +const ASN1_TIME *X509_ACERT_get0_notBefore(const X509_ACERT *x); +const ASN1_TIME *X509_ACERT_get0_notAfter(const X509_ACERT *x); +const ASN1_BIT_STRING *X509_ACERT_get0_issuerUID(const X509_ACERT *x); + +int X509_ACERT_print(BIO *bp, X509_ACERT *x); +int X509_ACERT_print_ex(BIO *bp, X509_ACERT *x, unsigned long nmflags, + unsigned long cflag); + +int X509_ACERT_get_attr_count(const X509_ACERT *x); +int X509_ACERT_get_attr_by_NID(const X509_ACERT *x, int nid, int lastpos); +int X509_ACERT_get_attr_by_OBJ(const X509_ACERT *x, const ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509_ACERT_get_attr(const X509_ACERT *x, int loc); +X509_ATTRIBUTE *X509_ACERT_delete_attr(X509_ACERT *x, int loc); + +void *X509_ACERT_get_ext_d2i(const X509_ACERT *x, int nid, int *crit, int *idx); +int X509_ACERT_add1_ext_i2d(X509_ACERT *x, int nid, void *value, int crit, + unsigned long flags); +const STACK_OF(X509_EXTENSION) *X509_ACERT_get0_extensions(const X509_ACERT *x); + +# define OSSL_OBJECT_DIGEST_INFO_PUBLIC_KEY 0 +# define OSSL_OBJECT_DIGEST_INFO_PUBLIC_KEY_CERT 1 +# define OSSL_OBJECT_DIGEST_INFO_OTHER 2 /* must not be used in RFC 5755 profile */ +int X509_ACERT_set_version(X509_ACERT *x, long version); +void X509_ACERT_set0_holder_entityName(X509_ACERT *x, GENERAL_NAMES *name); +void X509_ACERT_set0_holder_baseCertId(X509_ACERT *x, OSSL_ISSUER_SERIAL *isss); +void X509_ACERT_set0_holder_digest(X509_ACERT *x, + OSSL_OBJECT_DIGEST_INFO *dinfo); + +int X509_ACERT_add1_attr(X509_ACERT *x, X509_ATTRIBUTE *attr); +int X509_ACERT_add1_attr_by_OBJ(X509_ACERT *x, const ASN1_OBJECT *obj, + int type, const void *bytes, int len); +int X509_ACERT_add1_attr_by_NID(X509_ACERT *x, int nid, int type, + const void *bytes, int len); +int X509_ACERT_add1_attr_by_txt(X509_ACERT *x, const char *attrname, int type, + const unsigned char *bytes, int len); +int X509_ACERT_add_attr_nconf(CONF *conf, const char *section, + X509_ACERT *acert); + +int X509_ACERT_set1_issuerName(X509_ACERT *x, const X509_NAME *name); +int X509_ACERT_set1_serialNumber(X509_ACERT *x, const ASN1_INTEGER *serial); +int X509_ACERT_set1_notBefore(X509_ACERT *x, const ASN1_GENERALIZEDTIME *time); +int X509_ACERT_set1_notAfter(X509_ACERT *x, const ASN1_GENERALIZEDTIME *time); + +void OSSL_OBJECT_DIGEST_INFO_get0_digest(const OSSL_OBJECT_DIGEST_INFO *o, + int *digestedObjectType, + const X509_ALGOR **digestAlgorithm, + const ASN1_BIT_STRING **digest); + +int OSSL_OBJECT_DIGEST_INFO_set1_digest(OSSL_OBJECT_DIGEST_INFO *o, + int digestedObjectType, + X509_ALGOR *digestAlgorithm, + ASN1_BIT_STRING *digest); + +const X509_NAME *OSSL_ISSUER_SERIAL_get0_issuer(const OSSL_ISSUER_SERIAL *isss); +const ASN1_INTEGER *OSSL_ISSUER_SERIAL_get0_serial(const OSSL_ISSUER_SERIAL *isss); +const ASN1_BIT_STRING *OSSL_ISSUER_SERIAL_get0_issuerUID(const OSSL_ISSUER_SERIAL *isss); + +int OSSL_ISSUER_SERIAL_set1_issuer(OSSL_ISSUER_SERIAL *isss, + const X509_NAME *issuer); +int OSSL_ISSUER_SERIAL_set1_serial(OSSL_ISSUER_SERIAL *isss, + const ASN1_INTEGER *serial); +int OSSL_ISSUER_SERIAL_set1_issuerUID(OSSL_ISSUER_SERIAL *isss, + const ASN1_BIT_STRING *uid); + +# define OSSL_IETFAS_OCTETS 0 +# define OSSL_IETFAS_OID 1 +# define OSSL_IETFAS_STRING 2 + +typedef struct OSSL_IETF_ATTR_SYNTAX_VALUE_st OSSL_IETF_ATTR_SYNTAX_VALUE; +typedef struct OSSL_IETF_ATTR_SYNTAX_st OSSL_IETF_ATTR_SYNTAX; +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_IETF_ATTR_SYNTAX_VALUE, OSSL_IETF_ATTR_SYNTAX_VALUE, OSSL_IETF_ATTR_SYNTAX_VALUE) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_value(sk, idx) ((OSSL_IETF_ATTR_SYNTAX_VALUE *)OPENSSL_sk_value(ossl_check_const_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), (idx))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_new(cmp) ((STACK_OF(OSSL_IETF_ATTR_SYNTAX_VALUE) *)OPENSSL_sk_new(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_compfunc_type(cmp))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_new_null() ((STACK_OF(OSSL_IETF_ATTR_SYNTAX_VALUE) *)OPENSSL_sk_new_null()) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_new_reserve(cmp, n) ((STACK_OF(OSSL_IETF_ATTR_SYNTAX_VALUE) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_compfunc_type(cmp), (n))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), (n)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_free(sk) OPENSSL_sk_free(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_delete(sk, i) ((OSSL_IETF_ATTR_SYNTAX_VALUE *)OPENSSL_sk_delete(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), (i))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_delete_ptr(sk, ptr) ((OSSL_IETF_ATTR_SYNTAX_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_type(ptr))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_type(ptr)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_type(ptr)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_pop(sk) ((OSSL_IETF_ATTR_SYNTAX_VALUE *)OPENSSL_sk_pop(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_shift(sk) ((OSSL_IETF_ATTR_SYNTAX_VALUE *)OPENSSL_sk_shift(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk),ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_freefunc_type(freefunc)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_type(ptr), (idx)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_set(sk, idx, ptr) ((OSSL_IETF_ATTR_SYNTAX_VALUE *)OPENSSL_sk_set(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), (idx), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_type(ptr))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_type(ptr)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_type(ptr)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_type(ptr), pnum) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk)) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_dup(sk) ((STACK_OF(OSSL_IETF_ATTR_SYNTAX_VALUE) *)OPENSSL_sk_dup(ossl_check_const_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_IETF_ATTR_SYNTAX_VALUE) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_copyfunc_type(copyfunc), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_freefunc_type(freefunc))) +#define sk_OSSL_IETF_ATTR_SYNTAX_VALUE_set_cmp_func(sk, cmp) ((sk_OSSL_IETF_ATTR_SYNTAX_VALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_sk_type(sk), ossl_check_OSSL_IETF_ATTR_SYNTAX_VALUE_compfunc_type(cmp))) + + +DECLARE_ASN1_ITEM(OSSL_IETF_ATTR_SYNTAX_VALUE) +DECLARE_ASN1_ALLOC_FUNCTIONS(OSSL_IETF_ATTR_SYNTAX_VALUE) +DECLARE_ASN1_FUNCTIONS(OSSL_IETF_ATTR_SYNTAX) + +const GENERAL_NAMES * +OSSL_IETF_ATTR_SYNTAX_get0_policyAuthority(const OSSL_IETF_ATTR_SYNTAX *a); +void OSSL_IETF_ATTR_SYNTAX_set0_policyAuthority(OSSL_IETF_ATTR_SYNTAX *a, + GENERAL_NAMES *names); + +int OSSL_IETF_ATTR_SYNTAX_get_value_num(const OSSL_IETF_ATTR_SYNTAX *a); +void *OSSL_IETF_ATTR_SYNTAX_get0_value(const OSSL_IETF_ATTR_SYNTAX *a, + int ind, int *type); +int OSSL_IETF_ATTR_SYNTAX_add1_value(OSSL_IETF_ATTR_SYNTAX *a, int type, + void *data); +int OSSL_IETF_ATTR_SYNTAX_print(BIO *bp, OSSL_IETF_ATTR_SYNTAX *a, int indent); + +struct TARGET_CERT_st { + OSSL_ISSUER_SERIAL *targetCertificate; + GENERAL_NAME *targetName; + OSSL_OBJECT_DIGEST_INFO *certDigestInfo; +}; + +typedef struct TARGET_CERT_st OSSL_TARGET_CERT; + +# define OSSL_TGT_TARGET_NAME 0 +# define OSSL_TGT_TARGET_GROUP 1 +# define OSSL_TGT_TARGET_CERT 2 + +typedef struct TARGET_st { + int type; + union { + GENERAL_NAME *targetName; + GENERAL_NAME *targetGroup; + OSSL_TARGET_CERT *targetCert; + } choice; +} OSSL_TARGET; + +typedef STACK_OF(OSSL_TARGET) OSSL_TARGETS; +typedef STACK_OF(OSSL_TARGETS) OSSL_TARGETING_INFORMATION; + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_TARGET, OSSL_TARGET, OSSL_TARGET) +#define sk_OSSL_TARGET_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_TARGET_sk_type(sk)) +#define sk_OSSL_TARGET_value(sk, idx) ((OSSL_TARGET *)OPENSSL_sk_value(ossl_check_const_OSSL_TARGET_sk_type(sk), (idx))) +#define sk_OSSL_TARGET_new(cmp) ((STACK_OF(OSSL_TARGET) *)OPENSSL_sk_new(ossl_check_OSSL_TARGET_compfunc_type(cmp))) +#define sk_OSSL_TARGET_new_null() ((STACK_OF(OSSL_TARGET) *)OPENSSL_sk_new_null()) +#define sk_OSSL_TARGET_new_reserve(cmp, n) ((STACK_OF(OSSL_TARGET) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_TARGET_compfunc_type(cmp), (n))) +#define sk_OSSL_TARGET_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_TARGET_sk_type(sk), (n)) +#define sk_OSSL_TARGET_free(sk) OPENSSL_sk_free(ossl_check_OSSL_TARGET_sk_type(sk)) +#define sk_OSSL_TARGET_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_TARGET_sk_type(sk)) +#define sk_OSSL_TARGET_delete(sk, i) ((OSSL_TARGET *)OPENSSL_sk_delete(ossl_check_OSSL_TARGET_sk_type(sk), (i))) +#define sk_OSSL_TARGET_delete_ptr(sk, ptr) ((OSSL_TARGET *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_type(ptr))) +#define sk_OSSL_TARGET_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_type(ptr)) +#define sk_OSSL_TARGET_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_type(ptr)) +#define sk_OSSL_TARGET_pop(sk) ((OSSL_TARGET *)OPENSSL_sk_pop(ossl_check_OSSL_TARGET_sk_type(sk))) +#define sk_OSSL_TARGET_shift(sk) ((OSSL_TARGET *)OPENSSL_sk_shift(ossl_check_OSSL_TARGET_sk_type(sk))) +#define sk_OSSL_TARGET_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_TARGET_sk_type(sk),ossl_check_OSSL_TARGET_freefunc_type(freefunc)) +#define sk_OSSL_TARGET_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_type(ptr), (idx)) +#define sk_OSSL_TARGET_set(sk, idx, ptr) ((OSSL_TARGET *)OPENSSL_sk_set(ossl_check_OSSL_TARGET_sk_type(sk), (idx), ossl_check_OSSL_TARGET_type(ptr))) +#define sk_OSSL_TARGET_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_type(ptr)) +#define sk_OSSL_TARGET_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_type(ptr)) +#define sk_OSSL_TARGET_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_type(ptr), pnum) +#define sk_OSSL_TARGET_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_TARGET_sk_type(sk)) +#define sk_OSSL_TARGET_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_TARGET_sk_type(sk)) +#define sk_OSSL_TARGET_dup(sk) ((STACK_OF(OSSL_TARGET) *)OPENSSL_sk_dup(ossl_check_const_OSSL_TARGET_sk_type(sk))) +#define sk_OSSL_TARGET_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_TARGET) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_copyfunc_type(copyfunc), ossl_check_OSSL_TARGET_freefunc_type(freefunc))) +#define sk_OSSL_TARGET_set_cmp_func(sk, cmp) ((sk_OSSL_TARGET_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_TARGET_sk_type(sk), ossl_check_OSSL_TARGET_compfunc_type(cmp))) + + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_TARGETS, OSSL_TARGETS, OSSL_TARGETS) +#define sk_OSSL_TARGETS_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_TARGETS_sk_type(sk)) +#define sk_OSSL_TARGETS_value(sk, idx) ((OSSL_TARGETS *)OPENSSL_sk_value(ossl_check_const_OSSL_TARGETS_sk_type(sk), (idx))) +#define sk_OSSL_TARGETS_new(cmp) ((STACK_OF(OSSL_TARGETS) *)OPENSSL_sk_new(ossl_check_OSSL_TARGETS_compfunc_type(cmp))) +#define sk_OSSL_TARGETS_new_null() ((STACK_OF(OSSL_TARGETS) *)OPENSSL_sk_new_null()) +#define sk_OSSL_TARGETS_new_reserve(cmp, n) ((STACK_OF(OSSL_TARGETS) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_TARGETS_compfunc_type(cmp), (n))) +#define sk_OSSL_TARGETS_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_TARGETS_sk_type(sk), (n)) +#define sk_OSSL_TARGETS_free(sk) OPENSSL_sk_free(ossl_check_OSSL_TARGETS_sk_type(sk)) +#define sk_OSSL_TARGETS_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_TARGETS_sk_type(sk)) +#define sk_OSSL_TARGETS_delete(sk, i) ((OSSL_TARGETS *)OPENSSL_sk_delete(ossl_check_OSSL_TARGETS_sk_type(sk), (i))) +#define sk_OSSL_TARGETS_delete_ptr(sk, ptr) ((OSSL_TARGETS *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_type(ptr))) +#define sk_OSSL_TARGETS_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_type(ptr)) +#define sk_OSSL_TARGETS_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_type(ptr)) +#define sk_OSSL_TARGETS_pop(sk) ((OSSL_TARGETS *)OPENSSL_sk_pop(ossl_check_OSSL_TARGETS_sk_type(sk))) +#define sk_OSSL_TARGETS_shift(sk) ((OSSL_TARGETS *)OPENSSL_sk_shift(ossl_check_OSSL_TARGETS_sk_type(sk))) +#define sk_OSSL_TARGETS_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_TARGETS_sk_type(sk),ossl_check_OSSL_TARGETS_freefunc_type(freefunc)) +#define sk_OSSL_TARGETS_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_type(ptr), (idx)) +#define sk_OSSL_TARGETS_set(sk, idx, ptr) ((OSSL_TARGETS *)OPENSSL_sk_set(ossl_check_OSSL_TARGETS_sk_type(sk), (idx), ossl_check_OSSL_TARGETS_type(ptr))) +#define sk_OSSL_TARGETS_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_type(ptr)) +#define sk_OSSL_TARGETS_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_type(ptr)) +#define sk_OSSL_TARGETS_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_type(ptr), pnum) +#define sk_OSSL_TARGETS_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_TARGETS_sk_type(sk)) +#define sk_OSSL_TARGETS_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_TARGETS_sk_type(sk)) +#define sk_OSSL_TARGETS_dup(sk) ((STACK_OF(OSSL_TARGETS) *)OPENSSL_sk_dup(ossl_check_const_OSSL_TARGETS_sk_type(sk))) +#define sk_OSSL_TARGETS_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_TARGETS) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_copyfunc_type(copyfunc), ossl_check_OSSL_TARGETS_freefunc_type(freefunc))) +#define sk_OSSL_TARGETS_set_cmp_func(sk, cmp) ((sk_OSSL_TARGETS_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_TARGETS_sk_type(sk), ossl_check_OSSL_TARGETS_compfunc_type(cmp))) + + +DECLARE_ASN1_FUNCTIONS(OSSL_TARGET) +DECLARE_ASN1_FUNCTIONS(OSSL_TARGETS) +DECLARE_ASN1_FUNCTIONS(OSSL_TARGETING_INFORMATION) + +typedef STACK_OF(OSSL_ISSUER_SERIAL) OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX; +DECLARE_ASN1_FUNCTIONS(OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX) + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_ISSUER_SERIAL, OSSL_ISSUER_SERIAL, OSSL_ISSUER_SERIAL) +#define sk_OSSL_ISSUER_SERIAL_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_ISSUER_SERIAL_sk_type(sk)) +#define sk_OSSL_ISSUER_SERIAL_value(sk, idx) ((OSSL_ISSUER_SERIAL *)OPENSSL_sk_value(ossl_check_const_OSSL_ISSUER_SERIAL_sk_type(sk), (idx))) +#define sk_OSSL_ISSUER_SERIAL_new(cmp) ((STACK_OF(OSSL_ISSUER_SERIAL) *)OPENSSL_sk_new(ossl_check_OSSL_ISSUER_SERIAL_compfunc_type(cmp))) +#define sk_OSSL_ISSUER_SERIAL_new_null() ((STACK_OF(OSSL_ISSUER_SERIAL) *)OPENSSL_sk_new_null()) +#define sk_OSSL_ISSUER_SERIAL_new_reserve(cmp, n) ((STACK_OF(OSSL_ISSUER_SERIAL) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_ISSUER_SERIAL_compfunc_type(cmp), (n))) +#define sk_OSSL_ISSUER_SERIAL_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), (n)) +#define sk_OSSL_ISSUER_SERIAL_free(sk) OPENSSL_sk_free(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk)) +#define sk_OSSL_ISSUER_SERIAL_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk)) +#define sk_OSSL_ISSUER_SERIAL_delete(sk, i) ((OSSL_ISSUER_SERIAL *)OPENSSL_sk_delete(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), (i))) +#define sk_OSSL_ISSUER_SERIAL_delete_ptr(sk, ptr) ((OSSL_ISSUER_SERIAL *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_type(ptr))) +#define sk_OSSL_ISSUER_SERIAL_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_type(ptr)) +#define sk_OSSL_ISSUER_SERIAL_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_type(ptr)) +#define sk_OSSL_ISSUER_SERIAL_pop(sk) ((OSSL_ISSUER_SERIAL *)OPENSSL_sk_pop(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk))) +#define sk_OSSL_ISSUER_SERIAL_shift(sk) ((OSSL_ISSUER_SERIAL *)OPENSSL_sk_shift(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk))) +#define sk_OSSL_ISSUER_SERIAL_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk),ossl_check_OSSL_ISSUER_SERIAL_freefunc_type(freefunc)) +#define sk_OSSL_ISSUER_SERIAL_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_type(ptr), (idx)) +#define sk_OSSL_ISSUER_SERIAL_set(sk, idx, ptr) ((OSSL_ISSUER_SERIAL *)OPENSSL_sk_set(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), (idx), ossl_check_OSSL_ISSUER_SERIAL_type(ptr))) +#define sk_OSSL_ISSUER_SERIAL_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_type(ptr)) +#define sk_OSSL_ISSUER_SERIAL_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_type(ptr)) +#define sk_OSSL_ISSUER_SERIAL_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_type(ptr), pnum) +#define sk_OSSL_ISSUER_SERIAL_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk)) +#define sk_OSSL_ISSUER_SERIAL_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_ISSUER_SERIAL_sk_type(sk)) +#define sk_OSSL_ISSUER_SERIAL_dup(sk) ((STACK_OF(OSSL_ISSUER_SERIAL) *)OPENSSL_sk_dup(ossl_check_const_OSSL_ISSUER_SERIAL_sk_type(sk))) +#define sk_OSSL_ISSUER_SERIAL_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_ISSUER_SERIAL) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_copyfunc_type(copyfunc), ossl_check_OSSL_ISSUER_SERIAL_freefunc_type(freefunc))) +#define sk_OSSL_ISSUER_SERIAL_set_cmp_func(sk, cmp) ((sk_OSSL_ISSUER_SERIAL_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_ISSUER_SERIAL_sk_type(sk), ossl_check_OSSL_ISSUER_SERIAL_compfunc_type(cmp))) + + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/x509_vfy.h b/illumos-x86_64/usr/include/openssl-3/x509_vfy.h new file mode 100644 index 00000000..c9bdc3b3 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/x509_vfy.h @@ -0,0 +1,903 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/x509_vfy.h.in + * + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_X509_VFY_H +# define OPENSSL_X509_VFY_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_X509_VFY_H +# endif + +/* + * Protect against recursion, x509.h and x509_vfy.h each include the other. + */ +# ifndef OPENSSL_X509_H +# include +# endif + +# include +# include +# include +# include +# include + +#ifdef __cplusplus +extern "C" { +#endif + +/*- +SSL_CTX -> X509_STORE + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + +SSL -> X509_STORE_CTX + ->X509_STORE + +The X509_STORE holds the tables etc for verification stuff. +A X509_STORE_CTX is used while validating a single certificate. +The X509_STORE has X509_LOOKUPs for looking up certs. +The X509_STORE then calls a function to actually verify the +certificate chain. +*/ + +typedef enum { + X509_LU_NONE = 0, + X509_LU_X509, X509_LU_CRL +} X509_LOOKUP_TYPE; + +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +#define X509_LU_RETRY -1 +#define X509_LU_FAIL 0 +#endif + +SKM_DEFINE_STACK_OF_INTERNAL(X509_LOOKUP, X509_LOOKUP, X509_LOOKUP) +#define sk_X509_LOOKUP_num(sk) OPENSSL_sk_num(ossl_check_const_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_value(sk, idx) ((X509_LOOKUP *)OPENSSL_sk_value(ossl_check_const_X509_LOOKUP_sk_type(sk), (idx))) +#define sk_X509_LOOKUP_new(cmp) ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new(ossl_check_X509_LOOKUP_compfunc_type(cmp))) +#define sk_X509_LOOKUP_new_null() ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new_null()) +#define sk_X509_LOOKUP_new_reserve(cmp, n) ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new_reserve(ossl_check_X509_LOOKUP_compfunc_type(cmp), (n))) +#define sk_X509_LOOKUP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_LOOKUP_sk_type(sk), (n)) +#define sk_X509_LOOKUP_free(sk) OPENSSL_sk_free(ossl_check_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_zero(sk) OPENSSL_sk_zero(ossl_check_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_delete(sk, i) ((X509_LOOKUP *)OPENSSL_sk_delete(ossl_check_X509_LOOKUP_sk_type(sk), (i))) +#define sk_X509_LOOKUP_delete_ptr(sk, ptr) ((X509_LOOKUP *)OPENSSL_sk_delete_ptr(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr))) +#define sk_X509_LOOKUP_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)) +#define sk_X509_LOOKUP_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)) +#define sk_X509_LOOKUP_pop(sk) ((X509_LOOKUP *)OPENSSL_sk_pop(ossl_check_X509_LOOKUP_sk_type(sk))) +#define sk_X509_LOOKUP_shift(sk) ((X509_LOOKUP *)OPENSSL_sk_shift(ossl_check_X509_LOOKUP_sk_type(sk))) +#define sk_X509_LOOKUP_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_LOOKUP_sk_type(sk),ossl_check_X509_LOOKUP_freefunc_type(freefunc)) +#define sk_X509_LOOKUP_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr), (idx)) +#define sk_X509_LOOKUP_set(sk, idx, ptr) ((X509_LOOKUP *)OPENSSL_sk_set(ossl_check_X509_LOOKUP_sk_type(sk), (idx), ossl_check_X509_LOOKUP_type(ptr))) +#define sk_X509_LOOKUP_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)) +#define sk_X509_LOOKUP_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)) +#define sk_X509_LOOKUP_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr), pnum) +#define sk_X509_LOOKUP_sort(sk) OPENSSL_sk_sort(ossl_check_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_dup(sk) ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_dup(ossl_check_const_X509_LOOKUP_sk_type(sk))) +#define sk_X509_LOOKUP_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_copyfunc_type(copyfunc), ossl_check_X509_LOOKUP_freefunc_type(freefunc))) +#define sk_X509_LOOKUP_set_cmp_func(sk, cmp) ((sk_X509_LOOKUP_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(X509_OBJECT, X509_OBJECT, X509_OBJECT) +#define sk_X509_OBJECT_num(sk) OPENSSL_sk_num(ossl_check_const_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_value(sk, idx) ((X509_OBJECT *)OPENSSL_sk_value(ossl_check_const_X509_OBJECT_sk_type(sk), (idx))) +#define sk_X509_OBJECT_new(cmp) ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new(ossl_check_X509_OBJECT_compfunc_type(cmp))) +#define sk_X509_OBJECT_new_null() ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new_null()) +#define sk_X509_OBJECT_new_reserve(cmp, n) ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new_reserve(ossl_check_X509_OBJECT_compfunc_type(cmp), (n))) +#define sk_X509_OBJECT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_OBJECT_sk_type(sk), (n)) +#define sk_X509_OBJECT_free(sk) OPENSSL_sk_free(ossl_check_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_zero(sk) OPENSSL_sk_zero(ossl_check_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_delete(sk, i) ((X509_OBJECT *)OPENSSL_sk_delete(ossl_check_X509_OBJECT_sk_type(sk), (i))) +#define sk_X509_OBJECT_delete_ptr(sk, ptr) ((X509_OBJECT *)OPENSSL_sk_delete_ptr(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr))) +#define sk_X509_OBJECT_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)) +#define sk_X509_OBJECT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)) +#define sk_X509_OBJECT_pop(sk) ((X509_OBJECT *)OPENSSL_sk_pop(ossl_check_X509_OBJECT_sk_type(sk))) +#define sk_X509_OBJECT_shift(sk) ((X509_OBJECT *)OPENSSL_sk_shift(ossl_check_X509_OBJECT_sk_type(sk))) +#define sk_X509_OBJECT_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_OBJECT_sk_type(sk),ossl_check_X509_OBJECT_freefunc_type(freefunc)) +#define sk_X509_OBJECT_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr), (idx)) +#define sk_X509_OBJECT_set(sk, idx, ptr) ((X509_OBJECT *)OPENSSL_sk_set(ossl_check_X509_OBJECT_sk_type(sk), (idx), ossl_check_X509_OBJECT_type(ptr))) +#define sk_X509_OBJECT_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)) +#define sk_X509_OBJECT_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)) +#define sk_X509_OBJECT_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr), pnum) +#define sk_X509_OBJECT_sort(sk) OPENSSL_sk_sort(ossl_check_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_dup(sk) ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_dup(ossl_check_const_X509_OBJECT_sk_type(sk))) +#define sk_X509_OBJECT_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_copyfunc_type(copyfunc), ossl_check_X509_OBJECT_freefunc_type(freefunc))) +#define sk_X509_OBJECT_set_cmp_func(sk, cmp) ((sk_X509_OBJECT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(X509_VERIFY_PARAM, X509_VERIFY_PARAM, X509_VERIFY_PARAM) +#define sk_X509_VERIFY_PARAM_num(sk) OPENSSL_sk_num(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_value(sk, idx) ((X509_VERIFY_PARAM *)OPENSSL_sk_value(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk), (idx))) +#define sk_X509_VERIFY_PARAM_new(cmp) ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new(ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp))) +#define sk_X509_VERIFY_PARAM_new_null() ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new_null()) +#define sk_X509_VERIFY_PARAM_new_reserve(cmp, n) ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new_reserve(ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp), (n))) +#define sk_X509_VERIFY_PARAM_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (n)) +#define sk_X509_VERIFY_PARAM_free(sk) OPENSSL_sk_free(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_zero(sk) OPENSSL_sk_zero(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_delete(sk, i) ((X509_VERIFY_PARAM *)OPENSSL_sk_delete(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (i))) +#define sk_X509_VERIFY_PARAM_delete_ptr(sk, ptr) ((X509_VERIFY_PARAM *)OPENSSL_sk_delete_ptr(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr))) +#define sk_X509_VERIFY_PARAM_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr)) +#define sk_X509_VERIFY_PARAM_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr)) +#define sk_X509_VERIFY_PARAM_pop(sk) ((X509_VERIFY_PARAM *)OPENSSL_sk_pop(ossl_check_X509_VERIFY_PARAM_sk_type(sk))) +#define sk_X509_VERIFY_PARAM_shift(sk) ((X509_VERIFY_PARAM *)OPENSSL_sk_shift(ossl_check_X509_VERIFY_PARAM_sk_type(sk))) +#define sk_X509_VERIFY_PARAM_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_VERIFY_PARAM_sk_type(sk),ossl_check_X509_VERIFY_PARAM_freefunc_type(freefunc)) +#define sk_X509_VERIFY_PARAM_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr), (idx)) +#define sk_X509_VERIFY_PARAM_set(sk, idx, ptr) ((X509_VERIFY_PARAM *)OPENSSL_sk_set(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (idx), ossl_check_X509_VERIFY_PARAM_type(ptr))) +#define sk_X509_VERIFY_PARAM_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr)) +#define sk_X509_VERIFY_PARAM_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr)) +#define sk_X509_VERIFY_PARAM_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr), pnum) +#define sk_X509_VERIFY_PARAM_sort(sk) OPENSSL_sk_sort(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_dup(sk) ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_dup(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk))) +#define sk_X509_VERIFY_PARAM_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_copyfunc_type(copyfunc), ossl_check_X509_VERIFY_PARAM_freefunc_type(freefunc))) +#define sk_X509_VERIFY_PARAM_set_cmp_func(sk, cmp) ((sk_X509_VERIFY_PARAM_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp))) + + +/* This is used for a table of trust checking functions */ +typedef struct x509_trust_st { + int trust; + int flags; + int (*check_trust) (struct x509_trust_st *, X509 *, int); + char *name; + int arg1; + void *arg2; +} X509_TRUST; +SKM_DEFINE_STACK_OF_INTERNAL(X509_TRUST, X509_TRUST, X509_TRUST) +#define sk_X509_TRUST_num(sk) OPENSSL_sk_num(ossl_check_const_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_value(sk, idx) ((X509_TRUST *)OPENSSL_sk_value(ossl_check_const_X509_TRUST_sk_type(sk), (idx))) +#define sk_X509_TRUST_new(cmp) ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new(ossl_check_X509_TRUST_compfunc_type(cmp))) +#define sk_X509_TRUST_new_null() ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new_null()) +#define sk_X509_TRUST_new_reserve(cmp, n) ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new_reserve(ossl_check_X509_TRUST_compfunc_type(cmp), (n))) +#define sk_X509_TRUST_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_TRUST_sk_type(sk), (n)) +#define sk_X509_TRUST_free(sk) OPENSSL_sk_free(ossl_check_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_zero(sk) OPENSSL_sk_zero(ossl_check_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_delete(sk, i) ((X509_TRUST *)OPENSSL_sk_delete(ossl_check_X509_TRUST_sk_type(sk), (i))) +#define sk_X509_TRUST_delete_ptr(sk, ptr) ((X509_TRUST *)OPENSSL_sk_delete_ptr(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr))) +#define sk_X509_TRUST_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)) +#define sk_X509_TRUST_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)) +#define sk_X509_TRUST_pop(sk) ((X509_TRUST *)OPENSSL_sk_pop(ossl_check_X509_TRUST_sk_type(sk))) +#define sk_X509_TRUST_shift(sk) ((X509_TRUST *)OPENSSL_sk_shift(ossl_check_X509_TRUST_sk_type(sk))) +#define sk_X509_TRUST_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_TRUST_sk_type(sk),ossl_check_X509_TRUST_freefunc_type(freefunc)) +#define sk_X509_TRUST_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr), (idx)) +#define sk_X509_TRUST_set(sk, idx, ptr) ((X509_TRUST *)OPENSSL_sk_set(ossl_check_X509_TRUST_sk_type(sk), (idx), ossl_check_X509_TRUST_type(ptr))) +#define sk_X509_TRUST_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)) +#define sk_X509_TRUST_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)) +#define sk_X509_TRUST_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr), pnum) +#define sk_X509_TRUST_sort(sk) OPENSSL_sk_sort(ossl_check_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_dup(sk) ((STACK_OF(X509_TRUST) *)OPENSSL_sk_dup(ossl_check_const_X509_TRUST_sk_type(sk))) +#define sk_X509_TRUST_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_TRUST) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_copyfunc_type(copyfunc), ossl_check_X509_TRUST_freefunc_type(freefunc))) +#define sk_X509_TRUST_set_cmp_func(sk, cmp) ((sk_X509_TRUST_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_compfunc_type(cmp))) + + +/* standard trust ids */ +# define X509_TRUST_DEFAULT 0 /* Only valid in purpose settings */ +# define X509_TRUST_COMPAT 1 +# define X509_TRUST_SSL_CLIENT 2 +# define X509_TRUST_SSL_SERVER 3 +# define X509_TRUST_EMAIL 4 +# define X509_TRUST_OBJECT_SIGN 5 +# define X509_TRUST_OCSP_SIGN 6 +# define X509_TRUST_OCSP_REQUEST 7 +# define X509_TRUST_TSA 8 +/* Keep these up to date! */ +# define X509_TRUST_MIN 1 +# define X509_TRUST_MAX 8 + +/* trust_flags values */ +# define X509_TRUST_DYNAMIC (1U << 0) +# define X509_TRUST_DYNAMIC_NAME (1U << 1) +/* No compat trust if self-signed, preempts "DO_SS" */ +# define X509_TRUST_NO_SS_COMPAT (1U << 2) +/* Compat trust if no explicit accepted trust EKUs */ +# define X509_TRUST_DO_SS_COMPAT (1U << 3) +/* Accept "anyEKU" as a wildcard rejection OID and as a wildcard trust OID */ +# define X509_TRUST_OK_ANY_EKU (1U << 4) + +/* check_trust return codes */ +# define X509_TRUST_TRUSTED 1 +# define X509_TRUST_REJECTED 2 +# define X509_TRUST_UNTRUSTED 3 + +int X509_TRUST_set(int *t, int trust); +int X509_TRUST_get_count(void); +X509_TRUST *X509_TRUST_get0(int idx); +int X509_TRUST_get_by_id(int id); +int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int), + const char *name, int arg1, void *arg2); +void X509_TRUST_cleanup(void); +int X509_TRUST_get_flags(const X509_TRUST *xp); +char *X509_TRUST_get0_name(const X509_TRUST *xp); +int X509_TRUST_get_trust(const X509_TRUST *xp); + +int X509_trusted(const X509 *x); +int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj); +int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj); +void X509_trust_clear(X509 *x); +void X509_reject_clear(X509 *x); +STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x); +STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x); + +int (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *, + int); +int X509_check_trust(X509 *x, int id, int flags); + +int X509_verify_cert(X509_STORE_CTX *ctx); +int X509_STORE_CTX_verify(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_build_chain(X509 *target, STACK_OF(X509) *certs, + X509_STORE *store, int with_self_signed, + OSSL_LIB_CTX *libctx, const char *propq); + +int X509_STORE_set_depth(X509_STORE *store, int depth); + +typedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *); +int X509_STORE_CTX_print_verify_cb(int ok, X509_STORE_CTX *ctx); +typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *); +typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer, + X509_STORE_CTX *ctx, X509 *x); +typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx, + X509 *x, X509 *issuer); +typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx); +typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx, + X509_CRL **crl, X509 *x); +typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl); +typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx, + X509_CRL *crl, X509 *x); +typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx); +typedef STACK_OF(X509) + *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx, + const X509_NAME *nm); +typedef STACK_OF(X509_CRL) + *(*X509_STORE_CTX_lookup_crls_fn)(const X509_STORE_CTX *ctx, + const X509_NAME *nm); +typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx); + +void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); + +# define X509_STORE_CTX_set_app_data(ctx,data) \ + X509_STORE_CTX_set_ex_data(ctx,0,data) +# define X509_STORE_CTX_get_app_data(ctx) \ + X509_STORE_CTX_get_ex_data(ctx,0) + +# define X509_L_FILE_LOAD 1 +# define X509_L_ADD_DIR 2 +# define X509_L_ADD_STORE 3 +# define X509_L_LOAD_STORE 4 + +# define X509_LOOKUP_load_file(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) + +# define X509_LOOKUP_add_dir(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) + +# define X509_LOOKUP_add_store(x,name) \ + X509_LOOKUP_ctrl((x),X509_L_ADD_STORE,(name),0,NULL) + +# define X509_LOOKUP_load_store(x,name) \ + X509_LOOKUP_ctrl((x),X509_L_LOAD_STORE,(name),0,NULL) + +# define X509_LOOKUP_load_file_ex(x, name, type, libctx, propq) \ +X509_LOOKUP_ctrl_ex((x), X509_L_FILE_LOAD, (name), (long)(type), NULL,\ + (libctx), (propq)) + +# define X509_LOOKUP_load_store_ex(x, name, libctx, propq) \ +X509_LOOKUP_ctrl_ex((x), X509_L_LOAD_STORE, (name), 0, NULL, \ + (libctx), (propq)) + +# define X509_LOOKUP_add_store_ex(x, name, libctx, propq) \ +X509_LOOKUP_ctrl_ex((x), X509_L_ADD_STORE, (name), 0, NULL, \ + (libctx), (propq)) + +# define X509_V_OK 0 +# define X509_V_ERR_UNSPECIFIED 1 +# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 +# define X509_V_ERR_UNABLE_TO_GET_CRL 3 +# define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 +# define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 +# define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 +# define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 +# define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 +# define X509_V_ERR_CERT_NOT_YET_VALID 9 +# define X509_V_ERR_CERT_HAS_EXPIRED 10 +# define X509_V_ERR_CRL_NOT_YET_VALID 11 +# define X509_V_ERR_CRL_HAS_EXPIRED 12 +# define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 +# define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 +# define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 +# define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 +# define X509_V_ERR_OUT_OF_MEM 17 +# define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 +# define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 +# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 +# define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 +# define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 +# define X509_V_ERR_CERT_REVOKED 23 +# define X509_V_ERR_NO_ISSUER_PUBLIC_KEY 24 +# define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 +# define X509_V_ERR_INVALID_PURPOSE 26 +# define X509_V_ERR_CERT_UNTRUSTED 27 +# define X509_V_ERR_CERT_REJECTED 28 + +/* These are 'informational' when looking for issuer cert */ +# define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 +# define X509_V_ERR_AKID_SKID_MISMATCH 30 +# define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 +# define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 +# define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 +# define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 +# define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 +# define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 +# define X509_V_ERR_INVALID_NON_CA 37 +# define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 +# define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 +# define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 +# define X509_V_ERR_INVALID_EXTENSION 41 +# define X509_V_ERR_INVALID_POLICY_EXTENSION 42 +# define X509_V_ERR_NO_EXPLICIT_POLICY 43 +# define X509_V_ERR_DIFFERENT_CRL_SCOPE 44 +# define X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45 +# define X509_V_ERR_UNNESTED_RESOURCE 46 +# define X509_V_ERR_PERMITTED_VIOLATION 47 +# define X509_V_ERR_EXCLUDED_VIOLATION 48 +# define X509_V_ERR_SUBTREE_MINMAX 49 +/* The application is not happy */ +# define X509_V_ERR_APPLICATION_VERIFICATION 50 +# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51 +# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52 +# define X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53 +# define X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54 +/* Another issuer check debug option */ +# define X509_V_ERR_PATH_LOOP 55 +/* Suite B mode algorithm violation */ +# define X509_V_ERR_SUITE_B_INVALID_VERSION 56 +# define X509_V_ERR_SUITE_B_INVALID_ALGORITHM 57 +# define X509_V_ERR_SUITE_B_INVALID_CURVE 58 +# define X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM 59 +# define X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED 60 +# define X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61 +/* Host, email and IP check errors */ +# define X509_V_ERR_HOSTNAME_MISMATCH 62 +# define X509_V_ERR_EMAIL_MISMATCH 63 +# define X509_V_ERR_IP_ADDRESS_MISMATCH 64 +/* DANE TLSA errors */ +# define X509_V_ERR_DANE_NO_MATCH 65 +/* security level errors */ +# define X509_V_ERR_EE_KEY_TOO_SMALL 66 +# define X509_V_ERR_CA_KEY_TOO_SMALL 67 +# define X509_V_ERR_CA_MD_TOO_WEAK 68 +/* Caller error */ +# define X509_V_ERR_INVALID_CALL 69 +/* Issuer lookup error */ +# define X509_V_ERR_STORE_LOOKUP 70 +/* Certificate transparency */ +# define X509_V_ERR_NO_VALID_SCTS 71 + +# define X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION 72 +/* OCSP status errors */ +# define X509_V_ERR_OCSP_VERIFY_NEEDED 73 /* Need OCSP verification */ +# define X509_V_ERR_OCSP_VERIFY_FAILED 74 /* Couldn't verify cert through OCSP */ +# define X509_V_ERR_OCSP_CERT_UNKNOWN 75 /* Certificate wasn't recognized by the OCSP responder */ + +# define X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM 76 +# define X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH 77 + +/* Errors in case a check in X509_V_FLAG_X509_STRICT mode fails */ +# define X509_V_ERR_SIGNATURE_ALGORITHM_INCONSISTENCY 78 +# define X509_V_ERR_INVALID_CA 79 +# define X509_V_ERR_PATHLEN_INVALID_FOR_NON_CA 80 +# define X509_V_ERR_PATHLEN_WITHOUT_KU_KEY_CERT_SIGN 81 +# define X509_V_ERR_KU_KEY_CERT_SIGN_INVALID_FOR_NON_CA 82 +# define X509_V_ERR_ISSUER_NAME_EMPTY 83 +# define X509_V_ERR_SUBJECT_NAME_EMPTY 84 +# define X509_V_ERR_MISSING_AUTHORITY_KEY_IDENTIFIER 85 +# define X509_V_ERR_MISSING_SUBJECT_KEY_IDENTIFIER 86 +# define X509_V_ERR_EMPTY_SUBJECT_ALT_NAME 87 +# define X509_V_ERR_EMPTY_SUBJECT_SAN_NOT_CRITICAL 88 +# define X509_V_ERR_CA_BCONS_NOT_CRITICAL 89 +# define X509_V_ERR_AUTHORITY_KEY_IDENTIFIER_CRITICAL 90 +# define X509_V_ERR_SUBJECT_KEY_IDENTIFIER_CRITICAL 91 +# define X509_V_ERR_CA_CERT_MISSING_KEY_USAGE 92 +# define X509_V_ERR_EXTENSIONS_REQUIRE_VERSION_3 93 +# define X509_V_ERR_EC_KEY_EXPLICIT_PARAMS 94 +# define X509_V_ERR_RPK_UNTRUSTED 95 + +/* Certificate verify flags */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Deprecated */ +# endif +/* Use check time instead of current time */ +# define X509_V_FLAG_USE_CHECK_TIME 0x2 +/* Lookup CRLs */ +# define X509_V_FLAG_CRL_CHECK 0x4 +/* Lookup CRLs for whole chain */ +# define X509_V_FLAG_CRL_CHECK_ALL 0x8 +/* Ignore unhandled critical extensions */ +# define X509_V_FLAG_IGNORE_CRITICAL 0x10 +/* Disable workarounds for broken certificates */ +# define X509_V_FLAG_X509_STRICT 0x20 +/* Enable proxy certificate validation */ +# define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 +/* Enable policy checking */ +# define X509_V_FLAG_POLICY_CHECK 0x80 +/* Policy variable require-explicit-policy */ +# define X509_V_FLAG_EXPLICIT_POLICY 0x100 +/* Policy variable inhibit-any-policy */ +# define X509_V_FLAG_INHIBIT_ANY 0x200 +/* Policy variable inhibit-policy-mapping */ +# define X509_V_FLAG_INHIBIT_MAP 0x400 +/* Notify callback that policy is OK */ +# define X509_V_FLAG_NOTIFY_POLICY 0x800 +/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */ +# define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000 +/* Delta CRL support */ +# define X509_V_FLAG_USE_DELTAS 0x2000 +/* Check self-signed CA signature */ +# define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000 +/* Use trusted store first */ +# define X509_V_FLAG_TRUSTED_FIRST 0x8000 +/* Suite B 128 bit only mode: not normally used */ +# define X509_V_FLAG_SUITEB_128_LOS_ONLY 0x10000 +/* Suite B 192 bit only mode */ +# define X509_V_FLAG_SUITEB_192_LOS 0x20000 +/* Suite B 128 bit mode allowing 192 bit algorithms */ +# define X509_V_FLAG_SUITEB_128_LOS 0x30000 +/* Allow partial chains if at least one certificate is in trusted store */ +# define X509_V_FLAG_PARTIAL_CHAIN 0x80000 +/* + * If the initial chain is not trusted, do not attempt to build an alternative + * chain. Alternate chain checking was introduced in 1.1.0. Setting this flag + * will force the behaviour to match that of previous versions. + */ +# define X509_V_FLAG_NO_ALT_CHAINS 0x100000 +/* Do not check certificate/CRL validity against current time */ +# define X509_V_FLAG_NO_CHECK_TIME 0x200000 + +# define X509_VP_FLAG_DEFAULT 0x1 +# define X509_VP_FLAG_OVERWRITE 0x2 +# define X509_VP_FLAG_RESET_FLAGS 0x4 +# define X509_VP_FLAG_LOCKED 0x8 +# define X509_VP_FLAG_ONCE 0x10 + +/* Internal use: mask of policy related options */ +# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ + | X509_V_FLAG_EXPLICIT_POLICY \ + | X509_V_FLAG_INHIBIT_ANY \ + | X509_V_FLAG_INHIBIT_MAP) + +int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, + const X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, + X509_LOOKUP_TYPE type, + const X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, + X509_OBJECT *x); +int X509_OBJECT_up_ref_count(X509_OBJECT *a); +X509_OBJECT *X509_OBJECT_new(void); +void X509_OBJECT_free(X509_OBJECT *a); +X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a); +X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a); +int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj); +X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a); +int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj); +X509_STORE *X509_STORE_new(void); +void X509_STORE_free(X509_STORE *xs); +int X509_STORE_lock(X509_STORE *xs); +int X509_STORE_unlock(X509_STORE *xs); +int X509_STORE_up_ref(X509_STORE *xs); +STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *xs); +STACK_OF(X509_OBJECT) *X509_STORE_get1_objects(X509_STORE *xs); +STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *xs); +STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *xs, + const X509_NAME *nm); +STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *st, + const X509_NAME *nm); +int X509_STORE_set_flags(X509_STORE *xs, unsigned long flags); +int X509_STORE_set_purpose(X509_STORE *xs, int purpose); +int X509_STORE_set_trust(X509_STORE *xs, int trust); +int X509_STORE_set1_param(X509_STORE *xs, const X509_VERIFY_PARAM *pm); +X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *xs); + +void X509_STORE_set_verify(X509_STORE *xs, X509_STORE_CTX_verify_fn verify); +#define X509_STORE_set_verify_func(ctx, func) \ + X509_STORE_set_verify((ctx),(func)) +void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, + X509_STORE_CTX_verify_fn verify); +X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *xs); +void X509_STORE_set_verify_cb(X509_STORE *xs, + X509_STORE_CTX_verify_cb verify_cb); +# define X509_STORE_set_verify_cb_func(ctx,func) \ + X509_STORE_set_verify_cb((ctx),(func)) +X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *xs); +void X509_STORE_set_get_issuer(X509_STORE *xs, + X509_STORE_CTX_get_issuer_fn get_issuer); +X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *xs); +void X509_STORE_set_check_issued(X509_STORE *xs, + X509_STORE_CTX_check_issued_fn check_issued); +X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *s); +void X509_STORE_set_check_revocation(X509_STORE *xs, + X509_STORE_CTX_check_revocation_fn check_revocation); +X509_STORE_CTX_check_revocation_fn + X509_STORE_get_check_revocation(const X509_STORE *xs); +void X509_STORE_set_get_crl(X509_STORE *xs, + X509_STORE_CTX_get_crl_fn get_crl); +X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *xs); +void X509_STORE_set_check_crl(X509_STORE *xs, + X509_STORE_CTX_check_crl_fn check_crl); +X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *xs); +void X509_STORE_set_cert_crl(X509_STORE *xs, + X509_STORE_CTX_cert_crl_fn cert_crl); +X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *xs); +void X509_STORE_set_check_policy(X509_STORE *xs, + X509_STORE_CTX_check_policy_fn check_policy); +X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *s); +void X509_STORE_set_lookup_certs(X509_STORE *xs, + X509_STORE_CTX_lookup_certs_fn lookup_certs); +X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *s); +void X509_STORE_set_lookup_crls(X509_STORE *xs, + X509_STORE_CTX_lookup_crls_fn lookup_crls); +#define X509_STORE_set_lookup_crls_cb(ctx, func) \ + X509_STORE_set_lookup_crls((ctx), (func)) +X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *xs); +void X509_STORE_set_cleanup(X509_STORE *xs, + X509_STORE_CTX_cleanup_fn cleanup); +X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *xs); + +#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef) +int X509_STORE_set_ex_data(X509_STORE *xs, int idx, void *data); +void *X509_STORE_get_ex_data(const X509_STORE *xs, int idx); + +X509_STORE_CTX *X509_STORE_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq); +X509_STORE_CTX *X509_STORE_CTX_new(void); + +int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); + +void X509_STORE_CTX_free(X509_STORE_CTX *ctx); +int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *trust_store, + X509 *target, STACK_OF(X509) *untrusted); +int X509_STORE_CTX_init_rpk(X509_STORE_CTX *ctx, X509_STORE *trust_store, + EVP_PKEY* rpk); +void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); +void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); + +X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx); +X509 *X509_STORE_CTX_get0_cert(const X509_STORE_CTX *ctx); +EVP_PKEY *X509_STORE_CTX_get0_rpk(const X509_STORE_CTX *ctx); +STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx); +void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); +void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, + X509_STORE_CTX_verify_cb verify); +X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(const X509_STORE_CTX *ctx); +X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx); +X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(const X509_STORE_CTX *ctx); +X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(const X509_STORE_CTX *ctx); +X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(const X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_get_crl(X509_STORE_CTX *ctx, + X509_STORE_CTX_get_crl_fn get_crl); +X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(const X509_STORE_CTX *ctx); +X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(const X509_STORE_CTX *ctx); +X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(const X509_STORE_CTX *ctx); +X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(const X509_STORE_CTX *ctx); +X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(const X509_STORE_CTX *ctx); +X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(const X509_STORE_CTX *ctx); +X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(const X509_STORE_CTX *ctx); + +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain +# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted +# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack +# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject +# define X509_STORE_get1_certs X509_STORE_CTX_get1_certs +# define X509_STORE_get1_crls X509_STORE_CTX_get1_crls +/* the following macro is misspelled; use X509_STORE_get1_certs instead */ +# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs +/* the following macro is misspelled; use X509_STORE_get1_crls instead */ +# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls +#endif + +X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *xs, X509_LOOKUP_METHOD *m); +X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); +X509_LOOKUP_METHOD *X509_LOOKUP_file(void); +X509_LOOKUP_METHOD *X509_LOOKUP_store(void); + +typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc, + long argl, char **ret); +typedef int (*X509_LOOKUP_ctrl_ex_fn)( + X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret, + OSSL_LIB_CTX *libctx, const char *propq); + +typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, + const X509_NAME *name, + X509_OBJECT *ret); +typedef int (*X509_LOOKUP_get_by_subject_ex_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, + const X509_NAME *name, + X509_OBJECT *ret, + OSSL_LIB_CTX *libctx, + const char *propq); +typedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, + const X509_NAME *name, + const ASN1_INTEGER *serial, + X509_OBJECT *ret); +typedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, + const unsigned char* bytes, + int len, + X509_OBJECT *ret); +typedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, + const char *str, + int len, + X509_OBJECT *ret); + +X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name); +void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method); + +int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method, + int (*new_item) (X509_LOOKUP *ctx)); +int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method)) + (X509_LOOKUP *ctx); + +int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method, + void (*free_fn) (X509_LOOKUP *ctx)); +void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method)) + (X509_LOOKUP *ctx); + +int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method, + int (*init) (X509_LOOKUP *ctx)); +int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method)) + (X509_LOOKUP *ctx); + +int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method, + int (*shutdown) (X509_LOOKUP *ctx)); +int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method)) + (X509_LOOKUP *ctx); + +int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method, + X509_LOOKUP_ctrl_fn ctrl_fn); +X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method); + +int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method, + X509_LOOKUP_get_by_subject_fn fn); +X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject( + const X509_LOOKUP_METHOD *method); + +int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method, + X509_LOOKUP_get_by_issuer_serial_fn fn); +X509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial( + const X509_LOOKUP_METHOD *method); + +int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method, + X509_LOOKUP_get_by_fingerprint_fn fn); +X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint( + const X509_LOOKUP_METHOD *method); + +int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method, + X509_LOOKUP_get_by_alias_fn fn); +X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias( + const X509_LOOKUP_METHOD *method); + + +int X509_STORE_add_cert(X509_STORE *xs, X509 *x); +int X509_STORE_add_crl(X509_STORE *xs, X509_CRL *x); + +int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs, + X509_LOOKUP_TYPE type, + const X509_NAME *name, X509_OBJECT *ret); +X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, + X509_LOOKUP_TYPE type, + const X509_NAME *name); + +int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, + long argl, char **ret); +int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, + char **ret, OSSL_LIB_CTX *libctx, const char *propq); + +int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_cert_file_ex(X509_LOOKUP *ctx, const char *file, int type, + OSSL_LIB_CTX *libctx, const char *propq); +int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_cert_crl_file_ex(X509_LOOKUP *ctx, const char *file, int type, + OSSL_LIB_CTX *libctx, const char *propq); + +X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); +void X509_LOOKUP_free(X509_LOOKUP *ctx); +int X509_LOOKUP_init(X509_LOOKUP *ctx); +int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const X509_NAME *name, X509_OBJECT *ret); +int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const X509_NAME *name, X509_OBJECT *ret, + OSSL_LIB_CTX *libctx, const char *propq); +int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const X509_NAME *name, + const ASN1_INTEGER *serial, + X509_OBJECT *ret); +int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const unsigned char *bytes, int len, + X509_OBJECT *ret); +int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const char *str, int len, X509_OBJECT *ret); +int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data); +void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx); +X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx); +int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); + +int X509_STORE_load_file(X509_STORE *xs, const char *file); +int X509_STORE_load_path(X509_STORE *xs, const char *path); +int X509_STORE_load_store(X509_STORE *xs, const char *store); +int X509_STORE_load_locations(X509_STORE *s, const char *file, const char *dir); +int X509_STORE_set_default_paths(X509_STORE *xs); + +int X509_STORE_load_file_ex(X509_STORE *xs, const char *file, + OSSL_LIB_CTX *libctx, const char *propq); +int X509_STORE_load_store_ex(X509_STORE *xs, const char *store, + OSSL_LIB_CTX *libctx, const char *propq); +int X509_STORE_load_locations_ex(X509_STORE *xs, + const char *file, const char *dir, + OSSL_LIB_CTX *libctx, const char *propq); +int X509_STORE_set_default_paths_ex(X509_STORE *xs, + OSSL_LIB_CTX *libctx, const char *propq); + +#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef) +int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data); +void *X509_STORE_CTX_get_ex_data(const X509_STORE_CTX *ctx, int idx); +int X509_STORE_CTX_get_error(const X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s); +int X509_STORE_CTX_get_error_depth(const X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth); +X509 *X509_STORE_CTX_get_current_cert(const X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x); +X509 *X509_STORE_CTX_get0_current_issuer(const X509_STORE_CTX *ctx); +X509_CRL *X509_STORE_CTX_get0_current_crl(const X509_STORE_CTX *ctx); +X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(const X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get0_chain(const X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get1_chain(const X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *target); +void X509_STORE_CTX_set0_rpk(X509_STORE_CTX *ctx, EVP_PKEY *target); +void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk); +void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk); +int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); +int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); +int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, + int purpose, int trust); +void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); +void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, + time_t t); +void X509_STORE_CTX_set_current_reasons(X509_STORE_CTX *ctx, + unsigned int current_reasons); + +X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(const X509_STORE_CTX *ctx); +int X509_STORE_CTX_get_explicit_policy(const X509_STORE_CTX *ctx); +int X509_STORE_CTX_get_num_untrusted(const X509_STORE_CTX *ctx); + +X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(const X509_STORE_CTX *ctx); +void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); +int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); + +/* + * Bridge opacity barrier between libcrypt and libssl, also needed to support + * offline testing in test/danetest.c + */ +void X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane); +#define DANE_FLAG_NO_DANE_EE_NAMECHECKS (1L << 0) + +/* X509_VERIFY_PARAM functions */ + +X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); +void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); +int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, + unsigned long flags); +int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, + unsigned long flags); +unsigned long X509_VERIFY_PARAM_get_flags(const X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); +int X509_VERIFY_PARAM_get_purpose(const X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); +void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); +void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level); +time_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param); +void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); +int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, + ASN1_OBJECT *policy); +int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, + STACK_OF(ASN1_OBJECT) *policies); + +int X509_VERIFY_PARAM_set_inh_flags(X509_VERIFY_PARAM *param, + uint32_t flags); +uint32_t X509_VERIFY_PARAM_get_inh_flags(const X509_VERIFY_PARAM *param); + +char *X509_VERIFY_PARAM_get0_host(X509_VERIFY_PARAM *param, int idx); +int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, + const char *name, size_t namelen); +int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, + const char *name, size_t namelen); +void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, + unsigned int flags); +unsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param); +char *X509_VERIFY_PARAM_get0_peername(const X509_VERIFY_PARAM *param); +void X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *); +char *X509_VERIFY_PARAM_get0_email(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, + const char *email, size_t emaillen); +char *X509_VERIFY_PARAM_get1_ip_asc(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, + const unsigned char *ip, size_t iplen); +int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, + const char *ipasc); + +int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param); +const char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param); + +int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_get_count(void); +const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id); +const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); +void X509_VERIFY_PARAM_table_cleanup(void); + +/* Non positive return values are errors */ +#define X509_PCY_TREE_FAILURE -2 /* Failure to satisfy explicit policy */ +#define X509_PCY_TREE_INVALID -1 /* Inconsistent or invalid extensions */ +#define X509_PCY_TREE_INTERNAL 0 /* Internal error, most likely malloc */ + +/* + * Positive return values form a bit mask, all but the first are internal to + * the library and don't appear in results from X509_policy_check(). + */ +#define X509_PCY_TREE_VALID 1 /* The policy tree is valid */ +#define X509_PCY_TREE_EMPTY 2 /* The policy tree is empty */ +#define X509_PCY_TREE_EXPLICIT 4 /* Explicit policy required */ + +int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, + STACK_OF(X509) *certs, + STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags); + +void X509_policy_tree_free(X509_POLICY_TREE *tree); + +int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); +X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, + int i); + +STACK_OF(X509_POLICY_NODE) + *X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); + +STACK_OF(X509_POLICY_NODE) + *X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); + +int X509_policy_level_node_count(X509_POLICY_LEVEL *level); + +X509_POLICY_NODE *X509_policy_level_get0_node(const X509_POLICY_LEVEL *level, + int i); + +const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); + +STACK_OF(POLICYQUALINFO) + *X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); +const X509_POLICY_NODE + *X509_policy_node_get0_parent(const X509_POLICY_NODE *node); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/x509err.h b/illumos-x86_64/usr/include/openssl-3/x509err.h new file mode 100644 index 00000000..77b91c8b --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/x509err.h @@ -0,0 +1,70 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_X509ERR_H +# define OPENSSL_X509ERR_H +# pragma once + +# include +# include +# include + + + +/* + * X509 reason codes. + */ +# define X509_R_AKID_MISMATCH 110 +# define X509_R_BAD_SELECTOR 133 +# define X509_R_BAD_X509_FILETYPE 100 +# define X509_R_BASE64_DECODE_ERROR 118 +# define X509_R_CANT_CHECK_DH_KEY 114 +# define X509_R_CERTIFICATE_VERIFICATION_FAILED 139 +# define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 +# define X509_R_CRL_ALREADY_DELTA 127 +# define X509_R_CRL_VERIFY_FAILURE 131 +# define X509_R_DUPLICATE_ATTRIBUTE 140 +# define X509_R_ERROR_GETTING_MD_BY_NID 141 +# define X509_R_ERROR_USING_SIGINF_SET 142 +# define X509_R_IDP_MISMATCH 128 +# define X509_R_INVALID_ATTRIBUTES 138 +# define X509_R_INVALID_DIRECTORY 113 +# define X509_R_INVALID_DISTPOINT 143 +# define X509_R_INVALID_FIELD_NAME 119 +# define X509_R_INVALID_TRUST 123 +# define X509_R_ISSUER_MISMATCH 129 +# define X509_R_KEY_TYPE_MISMATCH 115 +# define X509_R_KEY_VALUES_MISMATCH 116 +# define X509_R_LOADING_CERT_DIR 103 +# define X509_R_LOADING_DEFAULTS 104 +# define X509_R_METHOD_NOT_SUPPORTED 124 +# define X509_R_NAME_TOO_LONG 134 +# define X509_R_NEWER_CRL_NOT_NEWER 132 +# define X509_R_NO_CERTIFICATE_FOUND 135 +# define X509_R_NO_CERTIFICATE_OR_CRL_FOUND 136 +# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 +# define X509_R_NO_CRL_FOUND 137 +# define X509_R_NO_CRL_NUMBER 130 +# define X509_R_PUBLIC_KEY_DECODE_ERROR 125 +# define X509_R_PUBLIC_KEY_ENCODE_ERROR 126 +# define X509_R_SHOULD_RETRY 106 +# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 +# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 +# define X509_R_UNKNOWN_KEY_TYPE 117 +# define X509_R_UNKNOWN_NID 109 +# define X509_R_UNKNOWN_PURPOSE_ID 121 +# define X509_R_UNKNOWN_SIGID_ALGS 144 +# define X509_R_UNKNOWN_TRUST_ID 120 +# define X509_R_UNSUPPORTED_ALGORITHM 111 +# define X509_R_UNSUPPORTED_VERSION 145 +# define X509_R_WRONG_LOOKUP_TYPE 112 +# define X509_R_WRONG_TYPE 122 + +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/x509v3.h b/illumos-x86_64/usr/include/openssl-3/x509v3.h new file mode 100644 index 00000000..b8dabac3 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/x509v3.h @@ -0,0 +1,1968 @@ +/* + * WARNING: do not edit! + * Generated by Makefile from include/openssl/x509v3.h.in + * + * Copyright 1999-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + + +#ifndef OPENSSL_X509V3_H +# define OPENSSL_X509V3_H +# pragma once + +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_X509V3_H +# endif + +# include +# include +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward reference */ +struct v3_ext_method; +struct v3_ext_ctx; + +/* Useful typedefs */ + +typedef void *(*X509V3_EXT_NEW)(void); +typedef void (*X509V3_EXT_FREE) (void *); +typedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long); +typedef int (*X509V3_EXT_I2D) (const void *, unsigned char **); +typedef STACK_OF(CONF_VALUE) * + (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext, + STACK_OF(CONF_VALUE) *extlist); +typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method, + struct v3_ext_ctx *ctx, + STACK_OF(CONF_VALUE) *values); +typedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method, + void *ext); +typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method, + struct v3_ext_ctx *ctx, const char *str); +typedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext, + BIO *out, int indent); +typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method, + struct v3_ext_ctx *ctx, const char *str); + +/* V3 extension structure */ + +struct v3_ext_method { + int ext_nid; + int ext_flags; +/* If this is set the following four fields are ignored */ + ASN1_ITEM_EXP *it; +/* Old style ASN1 calls */ + X509V3_EXT_NEW ext_new; + X509V3_EXT_FREE ext_free; + X509V3_EXT_D2I d2i; + X509V3_EXT_I2D i2d; +/* The following pair is used for string extensions */ + X509V3_EXT_I2S i2s; + X509V3_EXT_S2I s2i; +/* The following pair is used for multi-valued extensions */ + X509V3_EXT_I2V i2v; + X509V3_EXT_V2I v2i; +/* The following are used for raw extensions */ + X509V3_EXT_I2R i2r; + X509V3_EXT_R2I r2i; + void *usr_data; /* Any extension specific data */ +}; + +typedef struct X509V3_CONF_METHOD_st { + char *(*get_string) (void *db, const char *section, const char *value); + STACK_OF(CONF_VALUE) *(*get_section) (void *db, const char *section); + void (*free_string) (void *db, char *string); + void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section); +} X509V3_CONF_METHOD; + +/* Context specific info for producing X509 v3 extensions*/ +struct v3_ext_ctx { +# define X509V3_CTX_TEST 0x1 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define CTX_TEST X509V3_CTX_TEST +# endif +# define X509V3_CTX_REPLACE 0x2 + int flags; + X509 *issuer_cert; + X509 *subject_cert; + X509_REQ *subject_req; + X509_CRL *crl; + X509V3_CONF_METHOD *db_meth; + void *db; + EVP_PKEY *issuer_pkey; +/* Maybe more here */ +}; + +typedef struct v3_ext_method X509V3_EXT_METHOD; + +SKM_DEFINE_STACK_OF_INTERNAL(X509V3_EXT_METHOD, X509V3_EXT_METHOD, X509V3_EXT_METHOD) +#define sk_X509V3_EXT_METHOD_num(sk) OPENSSL_sk_num(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_value(sk, idx) ((X509V3_EXT_METHOD *)OPENSSL_sk_value(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk), (idx))) +#define sk_X509V3_EXT_METHOD_new(cmp) ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new(ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp))) +#define sk_X509V3_EXT_METHOD_new_null() ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new_null()) +#define sk_X509V3_EXT_METHOD_new_reserve(cmp, n) ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new_reserve(ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp), (n))) +#define sk_X509V3_EXT_METHOD_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509V3_EXT_METHOD_sk_type(sk), (n)) +#define sk_X509V3_EXT_METHOD_free(sk) OPENSSL_sk_free(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_zero(sk) OPENSSL_sk_zero(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_delete(sk, i) ((X509V3_EXT_METHOD *)OPENSSL_sk_delete(ossl_check_X509V3_EXT_METHOD_sk_type(sk), (i))) +#define sk_X509V3_EXT_METHOD_delete_ptr(sk, ptr) ((X509V3_EXT_METHOD *)OPENSSL_sk_delete_ptr(ossl_check_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_type(ptr))) +#define sk_X509V3_EXT_METHOD_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_type(ptr)) +#define sk_X509V3_EXT_METHOD_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_type(ptr)) +#define sk_X509V3_EXT_METHOD_pop(sk) ((X509V3_EXT_METHOD *)OPENSSL_sk_pop(ossl_check_X509V3_EXT_METHOD_sk_type(sk))) +#define sk_X509V3_EXT_METHOD_shift(sk) ((X509V3_EXT_METHOD *)OPENSSL_sk_shift(ossl_check_X509V3_EXT_METHOD_sk_type(sk))) +#define sk_X509V3_EXT_METHOD_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509V3_EXT_METHOD_sk_type(sk),ossl_check_X509V3_EXT_METHOD_freefunc_type(freefunc)) +#define sk_X509V3_EXT_METHOD_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_type(ptr), (idx)) +#define sk_X509V3_EXT_METHOD_set(sk, idx, ptr) ((X509V3_EXT_METHOD *)OPENSSL_sk_set(ossl_check_X509V3_EXT_METHOD_sk_type(sk), (idx), ossl_check_X509V3_EXT_METHOD_type(ptr))) +#define sk_X509V3_EXT_METHOD_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_type(ptr)) +#define sk_X509V3_EXT_METHOD_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_type(ptr)) +#define sk_X509V3_EXT_METHOD_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_type(ptr), pnum) +#define sk_X509V3_EXT_METHOD_sort(sk) OPENSSL_sk_sort(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_dup(sk) ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_dup(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk))) +#define sk_X509V3_EXT_METHOD_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_deep_copy(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_copyfunc_type(copyfunc), ossl_check_X509V3_EXT_METHOD_freefunc_type(freefunc))) +#define sk_X509V3_EXT_METHOD_set_cmp_func(sk, cmp) ((sk_X509V3_EXT_METHOD_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp))) + + +/* ext_flags values */ +# define X509V3_EXT_DYNAMIC 0x1 +# define X509V3_EXT_CTX_DEP 0x2 +# define X509V3_EXT_MULTILINE 0x4 + +typedef BIT_STRING_BITNAME ENUMERATED_NAMES; + +typedef struct BASIC_CONSTRAINTS_st { + int ca; + ASN1_INTEGER *pathlen; +} BASIC_CONSTRAINTS; + +typedef struct OSSL_BASIC_ATTR_CONSTRAINTS_st { + int authority; + ASN1_INTEGER *pathlen; +} OSSL_BASIC_ATTR_CONSTRAINTS; + +typedef struct PKEY_USAGE_PERIOD_st { + ASN1_GENERALIZEDTIME *notBefore; + ASN1_GENERALIZEDTIME *notAfter; +} PKEY_USAGE_PERIOD; + +typedef struct otherName_st { + ASN1_OBJECT *type_id; + ASN1_TYPE *value; +} OTHERNAME; + +typedef struct EDIPartyName_st { + ASN1_STRING *nameAssigner; + ASN1_STRING *partyName; +} EDIPARTYNAME; + +typedef struct GENERAL_NAME_st { +# define GEN_OTHERNAME 0 +# define GEN_EMAIL 1 +# define GEN_DNS 2 +# define GEN_X400 3 +# define GEN_DIRNAME 4 +# define GEN_EDIPARTY 5 +# define GEN_URI 6 +# define GEN_IPADD 7 +# define GEN_RID 8 + int type; + union { + char *ptr; + OTHERNAME *otherName; /* otherName */ + ASN1_IA5STRING *rfc822Name; + ASN1_IA5STRING *dNSName; + ASN1_STRING *x400Address; + X509_NAME *directoryName; + EDIPARTYNAME *ediPartyName; + ASN1_IA5STRING *uniformResourceIdentifier; + ASN1_OCTET_STRING *iPAddress; + ASN1_OBJECT *registeredID; + /* Old names */ + ASN1_OCTET_STRING *ip; /* iPAddress */ + X509_NAME *dirn; /* dirn */ + ASN1_IA5STRING *ia5; /* rfc822Name, dNSName, + * uniformResourceIdentifier */ + ASN1_OBJECT *rid; /* registeredID */ + ASN1_TYPE *other; /* x400Address */ + } d; +} GENERAL_NAME; + +typedef struct ACCESS_DESCRIPTION_st { + ASN1_OBJECT *method; + GENERAL_NAME *location; +} ACCESS_DESCRIPTION; + +int GENERAL_NAME_set1_X509_NAME(GENERAL_NAME **tgt, const X509_NAME *src); + +SKM_DEFINE_STACK_OF_INTERNAL(ACCESS_DESCRIPTION, ACCESS_DESCRIPTION, ACCESS_DESCRIPTION) +#define sk_ACCESS_DESCRIPTION_num(sk) OPENSSL_sk_num(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_value(sk, idx) ((ACCESS_DESCRIPTION *)OPENSSL_sk_value(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk), (idx))) +#define sk_ACCESS_DESCRIPTION_new(cmp) ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new(ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp))) +#define sk_ACCESS_DESCRIPTION_new_null() ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new_null()) +#define sk_ACCESS_DESCRIPTION_new_reserve(cmp, n) ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new_reserve(ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp), (n))) +#define sk_ACCESS_DESCRIPTION_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (n)) +#define sk_ACCESS_DESCRIPTION_free(sk) OPENSSL_sk_free(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_zero(sk) OPENSSL_sk_zero(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_delete(sk, i) ((ACCESS_DESCRIPTION *)OPENSSL_sk_delete(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (i))) +#define sk_ACCESS_DESCRIPTION_delete_ptr(sk, ptr) ((ACCESS_DESCRIPTION *)OPENSSL_sk_delete_ptr(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_type(ptr))) +#define sk_ACCESS_DESCRIPTION_push(sk, ptr) OPENSSL_sk_push(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_type(ptr)) +#define sk_ACCESS_DESCRIPTION_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_type(ptr)) +#define sk_ACCESS_DESCRIPTION_pop(sk) ((ACCESS_DESCRIPTION *)OPENSSL_sk_pop(ossl_check_ACCESS_DESCRIPTION_sk_type(sk))) +#define sk_ACCESS_DESCRIPTION_shift(sk) ((ACCESS_DESCRIPTION *)OPENSSL_sk_shift(ossl_check_ACCESS_DESCRIPTION_sk_type(sk))) +#define sk_ACCESS_DESCRIPTION_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ACCESS_DESCRIPTION_sk_type(sk),ossl_check_ACCESS_DESCRIPTION_freefunc_type(freefunc)) +#define sk_ACCESS_DESCRIPTION_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_type(ptr), (idx)) +#define sk_ACCESS_DESCRIPTION_set(sk, idx, ptr) ((ACCESS_DESCRIPTION *)OPENSSL_sk_set(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (idx), ossl_check_ACCESS_DESCRIPTION_type(ptr))) +#define sk_ACCESS_DESCRIPTION_find(sk, ptr) OPENSSL_sk_find(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_type(ptr)) +#define sk_ACCESS_DESCRIPTION_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_type(ptr)) +#define sk_ACCESS_DESCRIPTION_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_type(ptr), pnum) +#define sk_ACCESS_DESCRIPTION_sort(sk) OPENSSL_sk_sort(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_dup(sk) ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_dup(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk))) +#define sk_ACCESS_DESCRIPTION_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_deep_copy(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_copyfunc_type(copyfunc), ossl_check_ACCESS_DESCRIPTION_freefunc_type(freefunc))) +#define sk_ACCESS_DESCRIPTION_set_cmp_func(sk, cmp) ((sk_ACCESS_DESCRIPTION_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(GENERAL_NAME, GENERAL_NAME, GENERAL_NAME) +#define sk_GENERAL_NAME_num(sk) OPENSSL_sk_num(ossl_check_const_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_value(sk, idx) ((GENERAL_NAME *)OPENSSL_sk_value(ossl_check_const_GENERAL_NAME_sk_type(sk), (idx))) +#define sk_GENERAL_NAME_new(cmp) ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new(ossl_check_GENERAL_NAME_compfunc_type(cmp))) +#define sk_GENERAL_NAME_new_null() ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new_null()) +#define sk_GENERAL_NAME_new_reserve(cmp, n) ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new_reserve(ossl_check_GENERAL_NAME_compfunc_type(cmp), (n))) +#define sk_GENERAL_NAME_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_GENERAL_NAME_sk_type(sk), (n)) +#define sk_GENERAL_NAME_free(sk) OPENSSL_sk_free(ossl_check_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_zero(sk) OPENSSL_sk_zero(ossl_check_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_delete(sk, i) ((GENERAL_NAME *)OPENSSL_sk_delete(ossl_check_GENERAL_NAME_sk_type(sk), (i))) +#define sk_GENERAL_NAME_delete_ptr(sk, ptr) ((GENERAL_NAME *)OPENSSL_sk_delete_ptr(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr))) +#define sk_GENERAL_NAME_push(sk, ptr) OPENSSL_sk_push(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr)) +#define sk_GENERAL_NAME_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr)) +#define sk_GENERAL_NAME_pop(sk) ((GENERAL_NAME *)OPENSSL_sk_pop(ossl_check_GENERAL_NAME_sk_type(sk))) +#define sk_GENERAL_NAME_shift(sk) ((GENERAL_NAME *)OPENSSL_sk_shift(ossl_check_GENERAL_NAME_sk_type(sk))) +#define sk_GENERAL_NAME_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_GENERAL_NAME_sk_type(sk),ossl_check_GENERAL_NAME_freefunc_type(freefunc)) +#define sk_GENERAL_NAME_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr), (idx)) +#define sk_GENERAL_NAME_set(sk, idx, ptr) ((GENERAL_NAME *)OPENSSL_sk_set(ossl_check_GENERAL_NAME_sk_type(sk), (idx), ossl_check_GENERAL_NAME_type(ptr))) +#define sk_GENERAL_NAME_find(sk, ptr) OPENSSL_sk_find(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr)) +#define sk_GENERAL_NAME_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr)) +#define sk_GENERAL_NAME_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr), pnum) +#define sk_GENERAL_NAME_sort(sk) OPENSSL_sk_sort(ossl_check_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_dup(sk) ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_dup(ossl_check_const_GENERAL_NAME_sk_type(sk))) +#define sk_GENERAL_NAME_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_deep_copy(ossl_check_const_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_copyfunc_type(copyfunc), ossl_check_GENERAL_NAME_freefunc_type(freefunc))) +#define sk_GENERAL_NAME_set_cmp_func(sk, cmp) ((sk_GENERAL_NAME_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_compfunc_type(cmp))) + + +typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; +typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; +typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE; +typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; + +SKM_DEFINE_STACK_OF_INTERNAL(GENERAL_NAMES, GENERAL_NAMES, GENERAL_NAMES) +#define sk_GENERAL_NAMES_num(sk) OPENSSL_sk_num(ossl_check_const_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_value(sk, idx) ((GENERAL_NAMES *)OPENSSL_sk_value(ossl_check_const_GENERAL_NAMES_sk_type(sk), (idx))) +#define sk_GENERAL_NAMES_new(cmp) ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new(ossl_check_GENERAL_NAMES_compfunc_type(cmp))) +#define sk_GENERAL_NAMES_new_null() ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new_null()) +#define sk_GENERAL_NAMES_new_reserve(cmp, n) ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new_reserve(ossl_check_GENERAL_NAMES_compfunc_type(cmp), (n))) +#define sk_GENERAL_NAMES_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_GENERAL_NAMES_sk_type(sk), (n)) +#define sk_GENERAL_NAMES_free(sk) OPENSSL_sk_free(ossl_check_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_zero(sk) OPENSSL_sk_zero(ossl_check_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_delete(sk, i) ((GENERAL_NAMES *)OPENSSL_sk_delete(ossl_check_GENERAL_NAMES_sk_type(sk), (i))) +#define sk_GENERAL_NAMES_delete_ptr(sk, ptr) ((GENERAL_NAMES *)OPENSSL_sk_delete_ptr(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr))) +#define sk_GENERAL_NAMES_push(sk, ptr) OPENSSL_sk_push(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr)) +#define sk_GENERAL_NAMES_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr)) +#define sk_GENERAL_NAMES_pop(sk) ((GENERAL_NAMES *)OPENSSL_sk_pop(ossl_check_GENERAL_NAMES_sk_type(sk))) +#define sk_GENERAL_NAMES_shift(sk) ((GENERAL_NAMES *)OPENSSL_sk_shift(ossl_check_GENERAL_NAMES_sk_type(sk))) +#define sk_GENERAL_NAMES_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_GENERAL_NAMES_sk_type(sk),ossl_check_GENERAL_NAMES_freefunc_type(freefunc)) +#define sk_GENERAL_NAMES_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr), (idx)) +#define sk_GENERAL_NAMES_set(sk, idx, ptr) ((GENERAL_NAMES *)OPENSSL_sk_set(ossl_check_GENERAL_NAMES_sk_type(sk), (idx), ossl_check_GENERAL_NAMES_type(ptr))) +#define sk_GENERAL_NAMES_find(sk, ptr) OPENSSL_sk_find(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr)) +#define sk_GENERAL_NAMES_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr)) +#define sk_GENERAL_NAMES_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr), pnum) +#define sk_GENERAL_NAMES_sort(sk) OPENSSL_sk_sort(ossl_check_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_dup(sk) ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_dup(ossl_check_const_GENERAL_NAMES_sk_type(sk))) +#define sk_GENERAL_NAMES_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_deep_copy(ossl_check_const_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_copyfunc_type(copyfunc), ossl_check_GENERAL_NAMES_freefunc_type(freefunc))) +#define sk_GENERAL_NAMES_set_cmp_func(sk, cmp) ((sk_GENERAL_NAMES_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_compfunc_type(cmp))) + + +typedef struct DIST_POINT_NAME_st { + int type; + union { + GENERAL_NAMES *fullname; + STACK_OF(X509_NAME_ENTRY) *relativename; + } name; +/* If relativename then this contains the full distribution point name */ + X509_NAME *dpname; +} DIST_POINT_NAME; +DECLARE_ASN1_DUP_FUNCTION(DIST_POINT_NAME) +/* All existing reasons */ +# define CRLDP_ALL_REASONS 0x807f + +# define CRL_REASON_NONE -1 +# define CRL_REASON_UNSPECIFIED 0 +# define CRL_REASON_KEY_COMPROMISE 1 +# define CRL_REASON_CA_COMPROMISE 2 +# define CRL_REASON_AFFILIATION_CHANGED 3 +# define CRL_REASON_SUPERSEDED 4 +# define CRL_REASON_CESSATION_OF_OPERATION 5 +# define CRL_REASON_CERTIFICATE_HOLD 6 +# define CRL_REASON_REMOVE_FROM_CRL 8 +# define CRL_REASON_PRIVILEGE_WITHDRAWN 9 +# define CRL_REASON_AA_COMPROMISE 10 + +struct DIST_POINT_st { + DIST_POINT_NAME *distpoint; + ASN1_BIT_STRING *reasons; + GENERAL_NAMES *CRLissuer; + int dp_reasons; +}; + +SKM_DEFINE_STACK_OF_INTERNAL(DIST_POINT, DIST_POINT, DIST_POINT) +#define sk_DIST_POINT_num(sk) OPENSSL_sk_num(ossl_check_const_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_value(sk, idx) ((DIST_POINT *)OPENSSL_sk_value(ossl_check_const_DIST_POINT_sk_type(sk), (idx))) +#define sk_DIST_POINT_new(cmp) ((STACK_OF(DIST_POINT) *)OPENSSL_sk_new(ossl_check_DIST_POINT_compfunc_type(cmp))) +#define sk_DIST_POINT_new_null() ((STACK_OF(DIST_POINT) *)OPENSSL_sk_new_null()) +#define sk_DIST_POINT_new_reserve(cmp, n) ((STACK_OF(DIST_POINT) *)OPENSSL_sk_new_reserve(ossl_check_DIST_POINT_compfunc_type(cmp), (n))) +#define sk_DIST_POINT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_DIST_POINT_sk_type(sk), (n)) +#define sk_DIST_POINT_free(sk) OPENSSL_sk_free(ossl_check_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_zero(sk) OPENSSL_sk_zero(ossl_check_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_delete(sk, i) ((DIST_POINT *)OPENSSL_sk_delete(ossl_check_DIST_POINT_sk_type(sk), (i))) +#define sk_DIST_POINT_delete_ptr(sk, ptr) ((DIST_POINT *)OPENSSL_sk_delete_ptr(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr))) +#define sk_DIST_POINT_push(sk, ptr) OPENSSL_sk_push(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr)) +#define sk_DIST_POINT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr)) +#define sk_DIST_POINT_pop(sk) ((DIST_POINT *)OPENSSL_sk_pop(ossl_check_DIST_POINT_sk_type(sk))) +#define sk_DIST_POINT_shift(sk) ((DIST_POINT *)OPENSSL_sk_shift(ossl_check_DIST_POINT_sk_type(sk))) +#define sk_DIST_POINT_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_DIST_POINT_sk_type(sk),ossl_check_DIST_POINT_freefunc_type(freefunc)) +#define sk_DIST_POINT_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr), (idx)) +#define sk_DIST_POINT_set(sk, idx, ptr) ((DIST_POINT *)OPENSSL_sk_set(ossl_check_DIST_POINT_sk_type(sk), (idx), ossl_check_DIST_POINT_type(ptr))) +#define sk_DIST_POINT_find(sk, ptr) OPENSSL_sk_find(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr)) +#define sk_DIST_POINT_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr)) +#define sk_DIST_POINT_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr), pnum) +#define sk_DIST_POINT_sort(sk) OPENSSL_sk_sort(ossl_check_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_dup(sk) ((STACK_OF(DIST_POINT) *)OPENSSL_sk_dup(ossl_check_const_DIST_POINT_sk_type(sk))) +#define sk_DIST_POINT_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(DIST_POINT) *)OPENSSL_sk_deep_copy(ossl_check_const_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_copyfunc_type(copyfunc), ossl_check_DIST_POINT_freefunc_type(freefunc))) +#define sk_DIST_POINT_set_cmp_func(sk, cmp) ((sk_DIST_POINT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_compfunc_type(cmp))) + + +typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; + +struct AUTHORITY_KEYID_st { + ASN1_OCTET_STRING *keyid; + GENERAL_NAMES *issuer; + ASN1_INTEGER *serial; +}; + +/* Strong extranet structures */ + +typedef struct SXNET_ID_st { + ASN1_INTEGER *zone; + ASN1_OCTET_STRING *user; +} SXNETID; + +SKM_DEFINE_STACK_OF_INTERNAL(SXNETID, SXNETID, SXNETID) +#define sk_SXNETID_num(sk) OPENSSL_sk_num(ossl_check_const_SXNETID_sk_type(sk)) +#define sk_SXNETID_value(sk, idx) ((SXNETID *)OPENSSL_sk_value(ossl_check_const_SXNETID_sk_type(sk), (idx))) +#define sk_SXNETID_new(cmp) ((STACK_OF(SXNETID) *)OPENSSL_sk_new(ossl_check_SXNETID_compfunc_type(cmp))) +#define sk_SXNETID_new_null() ((STACK_OF(SXNETID) *)OPENSSL_sk_new_null()) +#define sk_SXNETID_new_reserve(cmp, n) ((STACK_OF(SXNETID) *)OPENSSL_sk_new_reserve(ossl_check_SXNETID_compfunc_type(cmp), (n))) +#define sk_SXNETID_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SXNETID_sk_type(sk), (n)) +#define sk_SXNETID_free(sk) OPENSSL_sk_free(ossl_check_SXNETID_sk_type(sk)) +#define sk_SXNETID_zero(sk) OPENSSL_sk_zero(ossl_check_SXNETID_sk_type(sk)) +#define sk_SXNETID_delete(sk, i) ((SXNETID *)OPENSSL_sk_delete(ossl_check_SXNETID_sk_type(sk), (i))) +#define sk_SXNETID_delete_ptr(sk, ptr) ((SXNETID *)OPENSSL_sk_delete_ptr(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr))) +#define sk_SXNETID_push(sk, ptr) OPENSSL_sk_push(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) +#define sk_SXNETID_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) +#define sk_SXNETID_pop(sk) ((SXNETID *)OPENSSL_sk_pop(ossl_check_SXNETID_sk_type(sk))) +#define sk_SXNETID_shift(sk) ((SXNETID *)OPENSSL_sk_shift(ossl_check_SXNETID_sk_type(sk))) +#define sk_SXNETID_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SXNETID_sk_type(sk),ossl_check_SXNETID_freefunc_type(freefunc)) +#define sk_SXNETID_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr), (idx)) +#define sk_SXNETID_set(sk, idx, ptr) ((SXNETID *)OPENSSL_sk_set(ossl_check_SXNETID_sk_type(sk), (idx), ossl_check_SXNETID_type(ptr))) +#define sk_SXNETID_find(sk, ptr) OPENSSL_sk_find(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) +#define sk_SXNETID_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) +#define sk_SXNETID_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr), pnum) +#define sk_SXNETID_sort(sk) OPENSSL_sk_sort(ossl_check_SXNETID_sk_type(sk)) +#define sk_SXNETID_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SXNETID_sk_type(sk)) +#define sk_SXNETID_dup(sk) ((STACK_OF(SXNETID) *)OPENSSL_sk_dup(ossl_check_const_SXNETID_sk_type(sk))) +#define sk_SXNETID_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SXNETID) *)OPENSSL_sk_deep_copy(ossl_check_const_SXNETID_sk_type(sk), ossl_check_SXNETID_copyfunc_type(copyfunc), ossl_check_SXNETID_freefunc_type(freefunc))) +#define sk_SXNETID_set_cmp_func(sk, cmp) ((sk_SXNETID_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_compfunc_type(cmp))) + + + +typedef struct SXNET_st { + ASN1_INTEGER *version; + STACK_OF(SXNETID) *ids; +} SXNET; + +typedef struct ISSUER_SIGN_TOOL_st { + ASN1_UTF8STRING *signTool; + ASN1_UTF8STRING *cATool; + ASN1_UTF8STRING *signToolCert; + ASN1_UTF8STRING *cAToolCert; +} ISSUER_SIGN_TOOL; + +typedef struct NOTICEREF_st { + ASN1_STRING *organization; + STACK_OF(ASN1_INTEGER) *noticenos; +} NOTICEREF; + +typedef struct USERNOTICE_st { + NOTICEREF *noticeref; + ASN1_STRING *exptext; +} USERNOTICE; + +typedef struct POLICYQUALINFO_st { + ASN1_OBJECT *pqualid; + union { + ASN1_IA5STRING *cpsuri; + USERNOTICE *usernotice; + ASN1_TYPE *other; + } d; +} POLICYQUALINFO; + +SKM_DEFINE_STACK_OF_INTERNAL(POLICYQUALINFO, POLICYQUALINFO, POLICYQUALINFO) +#define sk_POLICYQUALINFO_num(sk) OPENSSL_sk_num(ossl_check_const_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_value(sk, idx) ((POLICYQUALINFO *)OPENSSL_sk_value(ossl_check_const_POLICYQUALINFO_sk_type(sk), (idx))) +#define sk_POLICYQUALINFO_new(cmp) ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new(ossl_check_POLICYQUALINFO_compfunc_type(cmp))) +#define sk_POLICYQUALINFO_new_null() ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new_null()) +#define sk_POLICYQUALINFO_new_reserve(cmp, n) ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new_reserve(ossl_check_POLICYQUALINFO_compfunc_type(cmp), (n))) +#define sk_POLICYQUALINFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_POLICYQUALINFO_sk_type(sk), (n)) +#define sk_POLICYQUALINFO_free(sk) OPENSSL_sk_free(ossl_check_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_zero(sk) OPENSSL_sk_zero(ossl_check_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_delete(sk, i) ((POLICYQUALINFO *)OPENSSL_sk_delete(ossl_check_POLICYQUALINFO_sk_type(sk), (i))) +#define sk_POLICYQUALINFO_delete_ptr(sk, ptr) ((POLICYQUALINFO *)OPENSSL_sk_delete_ptr(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr))) +#define sk_POLICYQUALINFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr)) +#define sk_POLICYQUALINFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr)) +#define sk_POLICYQUALINFO_pop(sk) ((POLICYQUALINFO *)OPENSSL_sk_pop(ossl_check_POLICYQUALINFO_sk_type(sk))) +#define sk_POLICYQUALINFO_shift(sk) ((POLICYQUALINFO *)OPENSSL_sk_shift(ossl_check_POLICYQUALINFO_sk_type(sk))) +#define sk_POLICYQUALINFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_POLICYQUALINFO_sk_type(sk),ossl_check_POLICYQUALINFO_freefunc_type(freefunc)) +#define sk_POLICYQUALINFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr), (idx)) +#define sk_POLICYQUALINFO_set(sk, idx, ptr) ((POLICYQUALINFO *)OPENSSL_sk_set(ossl_check_POLICYQUALINFO_sk_type(sk), (idx), ossl_check_POLICYQUALINFO_type(ptr))) +#define sk_POLICYQUALINFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr)) +#define sk_POLICYQUALINFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr)) +#define sk_POLICYQUALINFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr), pnum) +#define sk_POLICYQUALINFO_sort(sk) OPENSSL_sk_sort(ossl_check_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_dup(sk) ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_dup(ossl_check_const_POLICYQUALINFO_sk_type(sk))) +#define sk_POLICYQUALINFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_deep_copy(ossl_check_const_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_copyfunc_type(copyfunc), ossl_check_POLICYQUALINFO_freefunc_type(freefunc))) +#define sk_POLICYQUALINFO_set_cmp_func(sk, cmp) ((sk_POLICYQUALINFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_compfunc_type(cmp))) + + + +typedef struct POLICYINFO_st { + ASN1_OBJECT *policyid; + STACK_OF(POLICYQUALINFO) *qualifiers; +} POLICYINFO; + +SKM_DEFINE_STACK_OF_INTERNAL(POLICYINFO, POLICYINFO, POLICYINFO) +#define sk_POLICYINFO_num(sk) OPENSSL_sk_num(ossl_check_const_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_value(sk, idx) ((POLICYINFO *)OPENSSL_sk_value(ossl_check_const_POLICYINFO_sk_type(sk), (idx))) +#define sk_POLICYINFO_new(cmp) ((STACK_OF(POLICYINFO) *)OPENSSL_sk_new(ossl_check_POLICYINFO_compfunc_type(cmp))) +#define sk_POLICYINFO_new_null() ((STACK_OF(POLICYINFO) *)OPENSSL_sk_new_null()) +#define sk_POLICYINFO_new_reserve(cmp, n) ((STACK_OF(POLICYINFO) *)OPENSSL_sk_new_reserve(ossl_check_POLICYINFO_compfunc_type(cmp), (n))) +#define sk_POLICYINFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_POLICYINFO_sk_type(sk), (n)) +#define sk_POLICYINFO_free(sk) OPENSSL_sk_free(ossl_check_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_zero(sk) OPENSSL_sk_zero(ossl_check_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_delete(sk, i) ((POLICYINFO *)OPENSSL_sk_delete(ossl_check_POLICYINFO_sk_type(sk), (i))) +#define sk_POLICYINFO_delete_ptr(sk, ptr) ((POLICYINFO *)OPENSSL_sk_delete_ptr(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr))) +#define sk_POLICYINFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr)) +#define sk_POLICYINFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr)) +#define sk_POLICYINFO_pop(sk) ((POLICYINFO *)OPENSSL_sk_pop(ossl_check_POLICYINFO_sk_type(sk))) +#define sk_POLICYINFO_shift(sk) ((POLICYINFO *)OPENSSL_sk_shift(ossl_check_POLICYINFO_sk_type(sk))) +#define sk_POLICYINFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_POLICYINFO_sk_type(sk),ossl_check_POLICYINFO_freefunc_type(freefunc)) +#define sk_POLICYINFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr), (idx)) +#define sk_POLICYINFO_set(sk, idx, ptr) ((POLICYINFO *)OPENSSL_sk_set(ossl_check_POLICYINFO_sk_type(sk), (idx), ossl_check_POLICYINFO_type(ptr))) +#define sk_POLICYINFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr)) +#define sk_POLICYINFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr)) +#define sk_POLICYINFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr), pnum) +#define sk_POLICYINFO_sort(sk) OPENSSL_sk_sort(ossl_check_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_dup(sk) ((STACK_OF(POLICYINFO) *)OPENSSL_sk_dup(ossl_check_const_POLICYINFO_sk_type(sk))) +#define sk_POLICYINFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(POLICYINFO) *)OPENSSL_sk_deep_copy(ossl_check_const_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_copyfunc_type(copyfunc), ossl_check_POLICYINFO_freefunc_type(freefunc))) +#define sk_POLICYINFO_set_cmp_func(sk, cmp) ((sk_POLICYINFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_compfunc_type(cmp))) + + +typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; + +typedef struct POLICY_MAPPING_st { + ASN1_OBJECT *issuerDomainPolicy; + ASN1_OBJECT *subjectDomainPolicy; +} POLICY_MAPPING; + +SKM_DEFINE_STACK_OF_INTERNAL(POLICY_MAPPING, POLICY_MAPPING, POLICY_MAPPING) +#define sk_POLICY_MAPPING_num(sk) OPENSSL_sk_num(ossl_check_const_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_value(sk, idx) ((POLICY_MAPPING *)OPENSSL_sk_value(ossl_check_const_POLICY_MAPPING_sk_type(sk), (idx))) +#define sk_POLICY_MAPPING_new(cmp) ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new(ossl_check_POLICY_MAPPING_compfunc_type(cmp))) +#define sk_POLICY_MAPPING_new_null() ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new_null()) +#define sk_POLICY_MAPPING_new_reserve(cmp, n) ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new_reserve(ossl_check_POLICY_MAPPING_compfunc_type(cmp), (n))) +#define sk_POLICY_MAPPING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_POLICY_MAPPING_sk_type(sk), (n)) +#define sk_POLICY_MAPPING_free(sk) OPENSSL_sk_free(ossl_check_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_zero(sk) OPENSSL_sk_zero(ossl_check_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_delete(sk, i) ((POLICY_MAPPING *)OPENSSL_sk_delete(ossl_check_POLICY_MAPPING_sk_type(sk), (i))) +#define sk_POLICY_MAPPING_delete_ptr(sk, ptr) ((POLICY_MAPPING *)OPENSSL_sk_delete_ptr(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr))) +#define sk_POLICY_MAPPING_push(sk, ptr) OPENSSL_sk_push(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr)) +#define sk_POLICY_MAPPING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr)) +#define sk_POLICY_MAPPING_pop(sk) ((POLICY_MAPPING *)OPENSSL_sk_pop(ossl_check_POLICY_MAPPING_sk_type(sk))) +#define sk_POLICY_MAPPING_shift(sk) ((POLICY_MAPPING *)OPENSSL_sk_shift(ossl_check_POLICY_MAPPING_sk_type(sk))) +#define sk_POLICY_MAPPING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_POLICY_MAPPING_sk_type(sk),ossl_check_POLICY_MAPPING_freefunc_type(freefunc)) +#define sk_POLICY_MAPPING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr), (idx)) +#define sk_POLICY_MAPPING_set(sk, idx, ptr) ((POLICY_MAPPING *)OPENSSL_sk_set(ossl_check_POLICY_MAPPING_sk_type(sk), (idx), ossl_check_POLICY_MAPPING_type(ptr))) +#define sk_POLICY_MAPPING_find(sk, ptr) OPENSSL_sk_find(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr)) +#define sk_POLICY_MAPPING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr)) +#define sk_POLICY_MAPPING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr), pnum) +#define sk_POLICY_MAPPING_sort(sk) OPENSSL_sk_sort(ossl_check_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_dup(sk) ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_dup(ossl_check_const_POLICY_MAPPING_sk_type(sk))) +#define sk_POLICY_MAPPING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_deep_copy(ossl_check_const_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_copyfunc_type(copyfunc), ossl_check_POLICY_MAPPING_freefunc_type(freefunc))) +#define sk_POLICY_MAPPING_set_cmp_func(sk, cmp) ((sk_POLICY_MAPPING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_compfunc_type(cmp))) + + +typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; + +typedef struct GENERAL_SUBTREE_st { + GENERAL_NAME *base; + ASN1_INTEGER *minimum; + ASN1_INTEGER *maximum; +} GENERAL_SUBTREE; + +SKM_DEFINE_STACK_OF_INTERNAL(GENERAL_SUBTREE, GENERAL_SUBTREE, GENERAL_SUBTREE) +#define sk_GENERAL_SUBTREE_num(sk) OPENSSL_sk_num(ossl_check_const_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_value(sk, idx) ((GENERAL_SUBTREE *)OPENSSL_sk_value(ossl_check_const_GENERAL_SUBTREE_sk_type(sk), (idx))) +#define sk_GENERAL_SUBTREE_new(cmp) ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new(ossl_check_GENERAL_SUBTREE_compfunc_type(cmp))) +#define sk_GENERAL_SUBTREE_new_null() ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new_null()) +#define sk_GENERAL_SUBTREE_new_reserve(cmp, n) ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new_reserve(ossl_check_GENERAL_SUBTREE_compfunc_type(cmp), (n))) +#define sk_GENERAL_SUBTREE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_GENERAL_SUBTREE_sk_type(sk), (n)) +#define sk_GENERAL_SUBTREE_free(sk) OPENSSL_sk_free(ossl_check_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_zero(sk) OPENSSL_sk_zero(ossl_check_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_delete(sk, i) ((GENERAL_SUBTREE *)OPENSSL_sk_delete(ossl_check_GENERAL_SUBTREE_sk_type(sk), (i))) +#define sk_GENERAL_SUBTREE_delete_ptr(sk, ptr) ((GENERAL_SUBTREE *)OPENSSL_sk_delete_ptr(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr))) +#define sk_GENERAL_SUBTREE_push(sk, ptr) OPENSSL_sk_push(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr)) +#define sk_GENERAL_SUBTREE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr)) +#define sk_GENERAL_SUBTREE_pop(sk) ((GENERAL_SUBTREE *)OPENSSL_sk_pop(ossl_check_GENERAL_SUBTREE_sk_type(sk))) +#define sk_GENERAL_SUBTREE_shift(sk) ((GENERAL_SUBTREE *)OPENSSL_sk_shift(ossl_check_GENERAL_SUBTREE_sk_type(sk))) +#define sk_GENERAL_SUBTREE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_GENERAL_SUBTREE_sk_type(sk),ossl_check_GENERAL_SUBTREE_freefunc_type(freefunc)) +#define sk_GENERAL_SUBTREE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr), (idx)) +#define sk_GENERAL_SUBTREE_set(sk, idx, ptr) ((GENERAL_SUBTREE *)OPENSSL_sk_set(ossl_check_GENERAL_SUBTREE_sk_type(sk), (idx), ossl_check_GENERAL_SUBTREE_type(ptr))) +#define sk_GENERAL_SUBTREE_find(sk, ptr) OPENSSL_sk_find(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr)) +#define sk_GENERAL_SUBTREE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr)) +#define sk_GENERAL_SUBTREE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr), pnum) +#define sk_GENERAL_SUBTREE_sort(sk) OPENSSL_sk_sort(ossl_check_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_dup(sk) ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_dup(ossl_check_const_GENERAL_SUBTREE_sk_type(sk))) +#define sk_GENERAL_SUBTREE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_deep_copy(ossl_check_const_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_copyfunc_type(copyfunc), ossl_check_GENERAL_SUBTREE_freefunc_type(freefunc))) +#define sk_GENERAL_SUBTREE_set_cmp_func(sk, cmp) ((sk_GENERAL_SUBTREE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_compfunc_type(cmp))) + + +struct NAME_CONSTRAINTS_st { + STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; + STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; +}; + +typedef struct POLICY_CONSTRAINTS_st { + ASN1_INTEGER *requireExplicitPolicy; + ASN1_INTEGER *inhibitPolicyMapping; +} POLICY_CONSTRAINTS; + +/* Proxy certificate structures, see RFC 3820 */ +typedef struct PROXY_POLICY_st { + ASN1_OBJECT *policyLanguage; + ASN1_OCTET_STRING *policy; +} PROXY_POLICY; + +typedef struct PROXY_CERT_INFO_EXTENSION_st { + ASN1_INTEGER *pcPathLengthConstraint; + PROXY_POLICY *proxyPolicy; +} PROXY_CERT_INFO_EXTENSION; + +DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) +DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) + +struct ISSUING_DIST_POINT_st { + DIST_POINT_NAME *distpoint; + int onlyuser; + int onlyCA; + ASN1_BIT_STRING *onlysomereasons; + int indirectCRL; + int onlyattr; +}; + +/* Values in idp_flags field */ +/* IDP present */ +# define IDP_PRESENT 0x1 +/* IDP values inconsistent */ +# define IDP_INVALID 0x2 +/* onlyuser true */ +# define IDP_ONLYUSER 0x4 +/* onlyCA true */ +# define IDP_ONLYCA 0x8 +/* onlyattr true */ +# define IDP_ONLYATTR 0x10 +/* indirectCRL true */ +# define IDP_INDIRECT 0x20 +/* onlysomereasons present */ +# define IDP_REASONS 0x40 + +# define X509V3_conf_err(val) ERR_add_error_data(6, \ + "section:", (val)->section, \ + ",name:", (val)->name, ",value:", (val)->value) + +# define X509V3_set_ctx_test(ctx) \ + X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, X509V3_CTX_TEST) +# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; + +# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ + 0,0,0,0, \ + 0,0, \ + (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ + (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ + NULL, NULL, \ + table} + +# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ + 0,0,0,0, \ + (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ + (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ + 0,0,0,0, \ + NULL} + +#define EXT_UTF8STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_UTF8STRING), \ + 0,0,0,0, \ + (X509V3_EXT_I2S)i2s_ASN1_UTF8STRING, \ + (X509V3_EXT_S2I)s2i_ASN1_UTF8STRING, \ + 0,0,0,0, \ + NULL} + +# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + +/* X509_PURPOSE stuff */ + +# define EXFLAG_BCONS 0x1 +# define EXFLAG_KUSAGE 0x2 +# define EXFLAG_XKUSAGE 0x4 +# define EXFLAG_NSCERT 0x8 + +# define EXFLAG_CA 0x10 +# define EXFLAG_SI 0x20 /* self-issued, maybe not self-signed */ +# define EXFLAG_V1 0x40 +# define EXFLAG_INVALID 0x80 +/* EXFLAG_SET is set to indicate that some values have been precomputed */ +# define EXFLAG_SET 0x100 +# define EXFLAG_CRITICAL 0x200 +# define EXFLAG_PROXY 0x400 + +# define EXFLAG_INVALID_POLICY 0x800 +# define EXFLAG_FRESHEST 0x1000 +# define EXFLAG_SS 0x2000 /* cert is apparently self-signed */ + +# define EXFLAG_BCONS_CRITICAL 0x10000 +# define EXFLAG_AKID_CRITICAL 0x20000 +# define EXFLAG_SKID_CRITICAL 0x40000 +# define EXFLAG_SAN_CRITICAL 0x80000 +# define EXFLAG_NO_FINGERPRINT 0x100000 + +/* https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.3 */ +# define KU_DIGITAL_SIGNATURE X509v3_KU_DIGITAL_SIGNATURE +# define KU_NON_REPUDIATION X509v3_KU_NON_REPUDIATION +# define KU_KEY_ENCIPHERMENT X509v3_KU_KEY_ENCIPHERMENT +# define KU_DATA_ENCIPHERMENT X509v3_KU_DATA_ENCIPHERMENT +# define KU_KEY_AGREEMENT X509v3_KU_KEY_AGREEMENT +# define KU_KEY_CERT_SIGN X509v3_KU_KEY_CERT_SIGN +# define KU_CRL_SIGN X509v3_KU_CRL_SIGN +# define KU_ENCIPHER_ONLY X509v3_KU_ENCIPHER_ONLY +# define KU_DECIPHER_ONLY X509v3_KU_DECIPHER_ONLY + +# define NS_SSL_CLIENT 0x80 +# define NS_SSL_SERVER 0x40 +# define NS_SMIME 0x20 +# define NS_OBJSIGN 0x10 +# define NS_SSL_CA 0x04 +# define NS_SMIME_CA 0x02 +# define NS_OBJSIGN_CA 0x01 +# define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) + +# define XKU_SSL_SERVER 0x1 +# define XKU_SSL_CLIENT 0x2 +# define XKU_SMIME 0x4 +# define XKU_CODE_SIGN 0x8 +# define XKU_SGC 0x10 /* Netscape or MS Server-Gated Crypto */ +# define XKU_OCSP_SIGN 0x20 +# define XKU_TIMESTAMP 0x40 +# define XKU_DVCS 0x80 +# define XKU_ANYEKU 0x100 + +# define X509_PURPOSE_DYNAMIC 0x1 +# define X509_PURPOSE_DYNAMIC_NAME 0x2 + +typedef struct x509_purpose_st { + int purpose; + int trust; /* Default trust ID */ + int flags; + int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int); + char *name; + char *sname; + void *usr_data; +} X509_PURPOSE; + +SKM_DEFINE_STACK_OF_INTERNAL(X509_PURPOSE, X509_PURPOSE, X509_PURPOSE) +#define sk_X509_PURPOSE_num(sk) OPENSSL_sk_num(ossl_check_const_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_value(sk, idx) ((X509_PURPOSE *)OPENSSL_sk_value(ossl_check_const_X509_PURPOSE_sk_type(sk), (idx))) +#define sk_X509_PURPOSE_new(cmp) ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new(ossl_check_X509_PURPOSE_compfunc_type(cmp))) +#define sk_X509_PURPOSE_new_null() ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new_null()) +#define sk_X509_PURPOSE_new_reserve(cmp, n) ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new_reserve(ossl_check_X509_PURPOSE_compfunc_type(cmp), (n))) +#define sk_X509_PURPOSE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_PURPOSE_sk_type(sk), (n)) +#define sk_X509_PURPOSE_free(sk) OPENSSL_sk_free(ossl_check_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_zero(sk) OPENSSL_sk_zero(ossl_check_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_delete(sk, i) ((X509_PURPOSE *)OPENSSL_sk_delete(ossl_check_X509_PURPOSE_sk_type(sk), (i))) +#define sk_X509_PURPOSE_delete_ptr(sk, ptr) ((X509_PURPOSE *)OPENSSL_sk_delete_ptr(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr))) +#define sk_X509_PURPOSE_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr)) +#define sk_X509_PURPOSE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr)) +#define sk_X509_PURPOSE_pop(sk) ((X509_PURPOSE *)OPENSSL_sk_pop(ossl_check_X509_PURPOSE_sk_type(sk))) +#define sk_X509_PURPOSE_shift(sk) ((X509_PURPOSE *)OPENSSL_sk_shift(ossl_check_X509_PURPOSE_sk_type(sk))) +#define sk_X509_PURPOSE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_PURPOSE_sk_type(sk),ossl_check_X509_PURPOSE_freefunc_type(freefunc)) +#define sk_X509_PURPOSE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr), (idx)) +#define sk_X509_PURPOSE_set(sk, idx, ptr) ((X509_PURPOSE *)OPENSSL_sk_set(ossl_check_X509_PURPOSE_sk_type(sk), (idx), ossl_check_X509_PURPOSE_type(ptr))) +#define sk_X509_PURPOSE_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr)) +#define sk_X509_PURPOSE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr)) +#define sk_X509_PURPOSE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr), pnum) +#define sk_X509_PURPOSE_sort(sk) OPENSSL_sk_sort(ossl_check_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_dup(sk) ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_dup(ossl_check_const_X509_PURPOSE_sk_type(sk))) +#define sk_X509_PURPOSE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_copyfunc_type(copyfunc), ossl_check_X509_PURPOSE_freefunc_type(freefunc))) +#define sk_X509_PURPOSE_set_cmp_func(sk, cmp) ((sk_X509_PURPOSE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_compfunc_type(cmp))) + + +# define X509_PURPOSE_DEFAULT_ANY 0 +# define X509_PURPOSE_SSL_CLIENT 1 +# define X509_PURPOSE_SSL_SERVER 2 +# define X509_PURPOSE_NS_SSL_SERVER 3 +# define X509_PURPOSE_SMIME_SIGN 4 +# define X509_PURPOSE_SMIME_ENCRYPT 5 +# define X509_PURPOSE_CRL_SIGN 6 +# define X509_PURPOSE_ANY 7 +# define X509_PURPOSE_OCSP_HELPER 8 +# define X509_PURPOSE_TIMESTAMP_SIGN 9 +# define X509_PURPOSE_CODE_SIGN 10 + +# define X509_PURPOSE_MIN 1 +# define X509_PURPOSE_MAX 10 + +/* Flags for X509V3_EXT_print() */ + +# define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) +/* Return error for unknown extensions */ +# define X509V3_EXT_DEFAULT 0 +/* Print error for unknown extensions */ +# define X509V3_EXT_ERROR_UNKNOWN (1L << 16) +/* ASN1 parse unknown extensions */ +# define X509V3_EXT_PARSE_UNKNOWN (2L << 16) +/* BIO_dump unknown extensions */ +# define X509V3_EXT_DUMP_UNKNOWN (3L << 16) + +/* Flags for X509V3_add1_i2d */ + +# define X509V3_ADD_OP_MASK 0xfL +# define X509V3_ADD_DEFAULT 0L +# define X509V3_ADD_APPEND 1L +# define X509V3_ADD_REPLACE 2L +# define X509V3_ADD_REPLACE_EXISTING 3L +# define X509V3_ADD_KEEP_EXISTING 4L +# define X509V3_ADD_DELETE 5L +# define X509V3_ADD_SILENT 0x10 + +DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) +DECLARE_ASN1_FUNCTIONS(OSSL_BASIC_ATTR_CONSTRAINTS) + +DECLARE_ASN1_FUNCTIONS(SXNET) +DECLARE_ASN1_FUNCTIONS(SXNETID) + +DECLARE_ASN1_FUNCTIONS(ISSUER_SIGN_TOOL) + +int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen); +int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, + int userlen); +int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user, + int userlen); + +ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone); +ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); +ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); + +DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) + +DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) +DECLARE_ASN1_DUP_FUNCTION(GENERAL_NAME) +int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b); + +ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, + STACK_OF(CONF_VALUE) *nval); +STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + ASN1_BIT_STRING *bits, + STACK_OF(CONF_VALUE) *extlist); +char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); +ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, const char *str); +char *i2s_ASN1_UTF8STRING(X509V3_EXT_METHOD *method, ASN1_UTF8STRING *utf8); +ASN1_UTF8STRING *s2i_ASN1_UTF8STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, const char *str); + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, + GENERAL_NAME *gen, + STACK_OF(CONF_VALUE) *ret); +int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, + GENERAL_NAMES *gen, + STACK_OF(CONF_VALUE) *extlist); +GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); + +DECLARE_ASN1_FUNCTIONS(OTHERNAME) +DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) +int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b); +void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value); +void *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype); +int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, + ASN1_OBJECT *oid, ASN1_TYPE *value); +int GENERAL_NAME_get0_otherName(const GENERAL_NAME *gen, + ASN1_OBJECT **poid, ASN1_TYPE **pvalue); + +char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, + const ASN1_OCTET_STRING *ia5); +ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, const char *str); + +DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) +int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a); + +DECLARE_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE) + +DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) +DECLARE_ASN1_FUNCTIONS(POLICYINFO) +DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) +DECLARE_ASN1_FUNCTIONS(USERNOTICE) +DECLARE_ASN1_FUNCTIONS(NOTICEREF) + +DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) +DECLARE_ASN1_FUNCTIONS(DIST_POINT) +DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) +DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT) + +int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, const X509_NAME *iname); + +int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc); +int NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc); + +DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) +DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) + +DECLARE_ASN1_ITEM(POLICY_MAPPING) +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) +DECLARE_ASN1_ITEM(POLICY_MAPPINGS) + +DECLARE_ASN1_ITEM(GENERAL_SUBTREE) +DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) + +DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) +DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) +DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) + +GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, + const X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, int gen_type, + const char *value, int is_nc); + +# ifdef OPENSSL_CONF_H +GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, CONF_VALUE *cnf); +GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, + const X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, CONF_VALUE *cnf, + int is_nc); + +void X509V3_conf_free(CONF_VALUE *val); + +X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, + const char *value); +X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name, + const char *value); +int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section, + STACK_OF(X509_EXTENSION) **sk); +int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509 *cert); +int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509_REQ *req); +int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509_CRL *crl); + +X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, + X509V3_CTX *ctx, int ext_nid, + const char *value); +X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, + const char *name, const char *value); +int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, + const char *section, X509 *cert); +int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, + const char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, + const char *section, X509_CRL *crl); + +int X509V3_add_value_bool_nf(const char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool); +int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint); +void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); +void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash); +# endif + +char *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section); +STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section); +void X509V3_string_free(X509V3_CTX *ctx, char *str); +void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); +void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, + X509_REQ *req, X509_CRL *crl, int flags); +/* For API backward compatibility, this is separate from X509V3_set_ctx(): */ +int X509V3_set_issuer_pkey(X509V3_CTX *ctx, EVP_PKEY *pkey); + +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_uchar(const char *name, const unsigned char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_bool(const char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, + STACK_OF(CONF_VALUE) **extlist); +char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint); +ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value); +char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint); +char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, + const ASN1_ENUMERATED *aint); +int X509V3_EXT_add(X509V3_EXT_METHOD *ext); +int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); +int X509V3_EXT_add_alias(int nid_to, int nid_from); +void X509V3_EXT_cleanup(void); + +const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); +const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); +int X509V3_add_standard_extensions(void); +STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); +void *X509V3_EXT_d2i(X509_EXTENSION *ext); +void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, + int *idx); + +X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); +int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, + int crit, unsigned long flags); + +#ifndef OPENSSL_NO_DEPRECATED_1_1_0 +/* The new declarations are in crypto.h, but the old ones were here. */ +# define hex_to_string OPENSSL_buf2hexstr +# define string_to_hex OPENSSL_hexstr2buf +#endif + +void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, + int ml); +int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, + int indent); +#ifndef OPENSSL_NO_STDIO +int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); +#endif +int X509V3_extensions_print(BIO *out, const char *title, + const STACK_OF(X509_EXTENSION) *exts, + unsigned long flag, int indent); + +int X509_check_ca(X509 *x); +int X509_check_purpose(X509 *x, int id, int ca); +int X509_supported_extension(X509_EXTENSION *ex); +int X509_check_issued(X509 *issuer, X509 *subject); +int X509_check_akid(const X509 *issuer, const AUTHORITY_KEYID *akid); +void X509_set_proxy_flag(X509 *x); +void X509_set_proxy_pathlen(X509 *x, long l); +long X509_get_proxy_pathlen(X509 *x); + +uint32_t X509_get_extension_flags(X509 *x); +uint32_t X509_get_key_usage(X509 *x); +uint32_t X509_get_extended_key_usage(X509 *x); +const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x); +const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x); +const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x); +const ASN1_INTEGER *X509_get0_authority_serial(X509 *x); + +int X509_PURPOSE_get_count(void); +int X509_PURPOSE_get_unused_id(OSSL_LIB_CTX *libctx); +int X509_PURPOSE_get_by_sname(const char *sname); +int X509_PURPOSE_get_by_id(int id); +int X509_PURPOSE_add(int id, int trust, int flags, + int (*ck) (const X509_PURPOSE *, const X509 *, int), + const char *name, const char *sname, void *arg); +void X509_PURPOSE_cleanup(void); + +X509_PURPOSE *X509_PURPOSE_get0(int idx); +int X509_PURPOSE_get_id(const X509_PURPOSE *); +char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp); +char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp); +int X509_PURPOSE_get_trust(const X509_PURPOSE *xp); +int X509_PURPOSE_set(int *p, int purpose); + +STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x); +STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x); +void X509_email_free(STACK_OF(OPENSSL_STRING) *sk); +STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x); + +/* Flags for X509_check_* functions */ + +/* + * Always check subject name for host match even if subject alt names present + */ +# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1 +/* Disable wildcard matching for dnsName fields and common name. */ +# define X509_CHECK_FLAG_NO_WILDCARDS 0x2 +/* Wildcards must not match a partial label. */ +# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4 +/* Allow (non-partial) wildcards to match multiple labels. */ +# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8 +/* Constraint verifier subdomain patterns to match a single labels. */ +# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10 +/* Never check the subject CN */ +# define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT 0x20 +/* + * Match reference identifiers starting with "." to any sub-domain. + * This is a non-public flag, turned on implicitly when the subject + * reference identity is a DNS name. + */ +# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000 + +int X509_check_host(X509 *x, const char *chk, size_t chklen, + unsigned int flags, char **peername); +int X509_check_email(X509 *x, const char *chk, size_t chklen, + unsigned int flags); +int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, + unsigned int flags); +int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags); + +ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); +ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); +int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk, + unsigned long chtype); + +void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); +SKM_DEFINE_STACK_OF_INTERNAL(X509_POLICY_NODE, X509_POLICY_NODE, X509_POLICY_NODE) +#define sk_X509_POLICY_NODE_num(sk) OPENSSL_sk_num(ossl_check_const_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_value(sk, idx) ((X509_POLICY_NODE *)OPENSSL_sk_value(ossl_check_const_X509_POLICY_NODE_sk_type(sk), (idx))) +#define sk_X509_POLICY_NODE_new(cmp) ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new(ossl_check_X509_POLICY_NODE_compfunc_type(cmp))) +#define sk_X509_POLICY_NODE_new_null() ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new_null()) +#define sk_X509_POLICY_NODE_new_reserve(cmp, n) ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new_reserve(ossl_check_X509_POLICY_NODE_compfunc_type(cmp), (n))) +#define sk_X509_POLICY_NODE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_POLICY_NODE_sk_type(sk), (n)) +#define sk_X509_POLICY_NODE_free(sk) OPENSSL_sk_free(ossl_check_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_zero(sk) OPENSSL_sk_zero(ossl_check_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_delete(sk, i) ((X509_POLICY_NODE *)OPENSSL_sk_delete(ossl_check_X509_POLICY_NODE_sk_type(sk), (i))) +#define sk_X509_POLICY_NODE_delete_ptr(sk, ptr) ((X509_POLICY_NODE *)OPENSSL_sk_delete_ptr(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr))) +#define sk_X509_POLICY_NODE_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr)) +#define sk_X509_POLICY_NODE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr)) +#define sk_X509_POLICY_NODE_pop(sk) ((X509_POLICY_NODE *)OPENSSL_sk_pop(ossl_check_X509_POLICY_NODE_sk_type(sk))) +#define sk_X509_POLICY_NODE_shift(sk) ((X509_POLICY_NODE *)OPENSSL_sk_shift(ossl_check_X509_POLICY_NODE_sk_type(sk))) +#define sk_X509_POLICY_NODE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_POLICY_NODE_sk_type(sk),ossl_check_X509_POLICY_NODE_freefunc_type(freefunc)) +#define sk_X509_POLICY_NODE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr), (idx)) +#define sk_X509_POLICY_NODE_set(sk, idx, ptr) ((X509_POLICY_NODE *)OPENSSL_sk_set(ossl_check_X509_POLICY_NODE_sk_type(sk), (idx), ossl_check_X509_POLICY_NODE_type(ptr))) +#define sk_X509_POLICY_NODE_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr)) +#define sk_X509_POLICY_NODE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr)) +#define sk_X509_POLICY_NODE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr), pnum) +#define sk_X509_POLICY_NODE_sort(sk) OPENSSL_sk_sort(ossl_check_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_dup(sk) ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_dup(ossl_check_const_X509_POLICY_NODE_sk_type(sk))) +#define sk_X509_POLICY_NODE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_copyfunc_type(copyfunc), ossl_check_X509_POLICY_NODE_freefunc_type(freefunc))) +#define sk_X509_POLICY_NODE_set_cmp_func(sk, cmp) ((sk_X509_POLICY_NODE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_compfunc_type(cmp))) + + + +#ifndef OPENSSL_NO_RFC3779 +typedef struct ASRange_st { + ASN1_INTEGER *min, *max; +} ASRange; + +# define ASIdOrRange_id 0 +# define ASIdOrRange_range 1 + +typedef struct ASIdOrRange_st { + int type; + union { + ASN1_INTEGER *id; + ASRange *range; + } u; +} ASIdOrRange; + +SKM_DEFINE_STACK_OF_INTERNAL(ASIdOrRange, ASIdOrRange, ASIdOrRange) +#define sk_ASIdOrRange_num(sk) OPENSSL_sk_num(ossl_check_const_ASIdOrRange_sk_type(sk)) +#define sk_ASIdOrRange_value(sk, idx) ((ASIdOrRange *)OPENSSL_sk_value(ossl_check_const_ASIdOrRange_sk_type(sk), (idx))) +#define sk_ASIdOrRange_new(cmp) ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new(ossl_check_ASIdOrRange_compfunc_type(cmp))) +#define sk_ASIdOrRange_new_null() ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new_null()) +#define sk_ASIdOrRange_new_reserve(cmp, n) ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new_reserve(ossl_check_ASIdOrRange_compfunc_type(cmp), (n))) +#define sk_ASIdOrRange_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASIdOrRange_sk_type(sk), (n)) +#define sk_ASIdOrRange_free(sk) OPENSSL_sk_free(ossl_check_ASIdOrRange_sk_type(sk)) +#define sk_ASIdOrRange_zero(sk) OPENSSL_sk_zero(ossl_check_ASIdOrRange_sk_type(sk)) +#define sk_ASIdOrRange_delete(sk, i) ((ASIdOrRange *)OPENSSL_sk_delete(ossl_check_ASIdOrRange_sk_type(sk), (i))) +#define sk_ASIdOrRange_delete_ptr(sk, ptr) ((ASIdOrRange *)OPENSSL_sk_delete_ptr(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr))) +#define sk_ASIdOrRange_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr)) +#define sk_ASIdOrRange_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr)) +#define sk_ASIdOrRange_pop(sk) ((ASIdOrRange *)OPENSSL_sk_pop(ossl_check_ASIdOrRange_sk_type(sk))) +#define sk_ASIdOrRange_shift(sk) ((ASIdOrRange *)OPENSSL_sk_shift(ossl_check_ASIdOrRange_sk_type(sk))) +#define sk_ASIdOrRange_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASIdOrRange_sk_type(sk),ossl_check_ASIdOrRange_freefunc_type(freefunc)) +#define sk_ASIdOrRange_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr), (idx)) +#define sk_ASIdOrRange_set(sk, idx, ptr) ((ASIdOrRange *)OPENSSL_sk_set(ossl_check_ASIdOrRange_sk_type(sk), (idx), ossl_check_ASIdOrRange_type(ptr))) +#define sk_ASIdOrRange_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr)) +#define sk_ASIdOrRange_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr)) +#define sk_ASIdOrRange_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr), pnum) +#define sk_ASIdOrRange_sort(sk) OPENSSL_sk_sort(ossl_check_ASIdOrRange_sk_type(sk)) +#define sk_ASIdOrRange_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASIdOrRange_sk_type(sk)) +#define sk_ASIdOrRange_dup(sk) ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_dup(ossl_check_const_ASIdOrRange_sk_type(sk))) +#define sk_ASIdOrRange_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_deep_copy(ossl_check_const_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_copyfunc_type(copyfunc), ossl_check_ASIdOrRange_freefunc_type(freefunc))) +#define sk_ASIdOrRange_set_cmp_func(sk, cmp) ((sk_ASIdOrRange_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_compfunc_type(cmp))) + + +typedef STACK_OF(ASIdOrRange) ASIdOrRanges; + +# define ASIdentifierChoice_inherit 0 +# define ASIdentifierChoice_asIdsOrRanges 1 + +typedef struct ASIdentifierChoice_st { + int type; + union { + ASN1_NULL *inherit; + ASIdOrRanges *asIdsOrRanges; + } u; +} ASIdentifierChoice; + +typedef struct ASIdentifiers_st { + ASIdentifierChoice *asnum, *rdi; +} ASIdentifiers; + +DECLARE_ASN1_FUNCTIONS(ASRange) +DECLARE_ASN1_FUNCTIONS(ASIdOrRange) +DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice) +DECLARE_ASN1_FUNCTIONS(ASIdentifiers) + +typedef struct IPAddressRange_st { + ASN1_BIT_STRING *min, *max; +} IPAddressRange; + +# define IPAddressOrRange_addressPrefix 0 +# define IPAddressOrRange_addressRange 1 + +typedef struct IPAddressOrRange_st { + int type; + union { + ASN1_BIT_STRING *addressPrefix; + IPAddressRange *addressRange; + } u; +} IPAddressOrRange; + +SKM_DEFINE_STACK_OF_INTERNAL(IPAddressOrRange, IPAddressOrRange, IPAddressOrRange) +#define sk_IPAddressOrRange_num(sk) OPENSSL_sk_num(ossl_check_const_IPAddressOrRange_sk_type(sk)) +#define sk_IPAddressOrRange_value(sk, idx) ((IPAddressOrRange *)OPENSSL_sk_value(ossl_check_const_IPAddressOrRange_sk_type(sk), (idx))) +#define sk_IPAddressOrRange_new(cmp) ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new(ossl_check_IPAddressOrRange_compfunc_type(cmp))) +#define sk_IPAddressOrRange_new_null() ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new_null()) +#define sk_IPAddressOrRange_new_reserve(cmp, n) ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new_reserve(ossl_check_IPAddressOrRange_compfunc_type(cmp), (n))) +#define sk_IPAddressOrRange_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_IPAddressOrRange_sk_type(sk), (n)) +#define sk_IPAddressOrRange_free(sk) OPENSSL_sk_free(ossl_check_IPAddressOrRange_sk_type(sk)) +#define sk_IPAddressOrRange_zero(sk) OPENSSL_sk_zero(ossl_check_IPAddressOrRange_sk_type(sk)) +#define sk_IPAddressOrRange_delete(sk, i) ((IPAddressOrRange *)OPENSSL_sk_delete(ossl_check_IPAddressOrRange_sk_type(sk), (i))) +#define sk_IPAddressOrRange_delete_ptr(sk, ptr) ((IPAddressOrRange *)OPENSSL_sk_delete_ptr(ossl_check_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_type(ptr))) +#define sk_IPAddressOrRange_push(sk, ptr) OPENSSL_sk_push(ossl_check_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_type(ptr)) +#define sk_IPAddressOrRange_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_type(ptr)) +#define sk_IPAddressOrRange_pop(sk) ((IPAddressOrRange *)OPENSSL_sk_pop(ossl_check_IPAddressOrRange_sk_type(sk))) +#define sk_IPAddressOrRange_shift(sk) ((IPAddressOrRange *)OPENSSL_sk_shift(ossl_check_IPAddressOrRange_sk_type(sk))) +#define sk_IPAddressOrRange_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_IPAddressOrRange_sk_type(sk),ossl_check_IPAddressOrRange_freefunc_type(freefunc)) +#define sk_IPAddressOrRange_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_type(ptr), (idx)) +#define sk_IPAddressOrRange_set(sk, idx, ptr) ((IPAddressOrRange *)OPENSSL_sk_set(ossl_check_IPAddressOrRange_sk_type(sk), (idx), ossl_check_IPAddressOrRange_type(ptr))) +#define sk_IPAddressOrRange_find(sk, ptr) OPENSSL_sk_find(ossl_check_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_type(ptr)) +#define sk_IPAddressOrRange_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_type(ptr)) +#define sk_IPAddressOrRange_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_type(ptr), pnum) +#define sk_IPAddressOrRange_sort(sk) OPENSSL_sk_sort(ossl_check_IPAddressOrRange_sk_type(sk)) +#define sk_IPAddressOrRange_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_IPAddressOrRange_sk_type(sk)) +#define sk_IPAddressOrRange_dup(sk) ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_dup(ossl_check_const_IPAddressOrRange_sk_type(sk))) +#define sk_IPAddressOrRange_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_deep_copy(ossl_check_const_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_copyfunc_type(copyfunc), ossl_check_IPAddressOrRange_freefunc_type(freefunc))) +#define sk_IPAddressOrRange_set_cmp_func(sk, cmp) ((sk_IPAddressOrRange_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_IPAddressOrRange_sk_type(sk), ossl_check_IPAddressOrRange_compfunc_type(cmp))) + + +typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; + +# define IPAddressChoice_inherit 0 +# define IPAddressChoice_addressesOrRanges 1 + +typedef struct IPAddressChoice_st { + int type; + union { + ASN1_NULL *inherit; + IPAddressOrRanges *addressesOrRanges; + } u; +} IPAddressChoice; + +typedef struct IPAddressFamily_st { + ASN1_OCTET_STRING *addressFamily; + IPAddressChoice *ipAddressChoice; +} IPAddressFamily; + +SKM_DEFINE_STACK_OF_INTERNAL(IPAddressFamily, IPAddressFamily, IPAddressFamily) +#define sk_IPAddressFamily_num(sk) OPENSSL_sk_num(ossl_check_const_IPAddressFamily_sk_type(sk)) +#define sk_IPAddressFamily_value(sk, idx) ((IPAddressFamily *)OPENSSL_sk_value(ossl_check_const_IPAddressFamily_sk_type(sk), (idx))) +#define sk_IPAddressFamily_new(cmp) ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new(ossl_check_IPAddressFamily_compfunc_type(cmp))) +#define sk_IPAddressFamily_new_null() ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new_null()) +#define sk_IPAddressFamily_new_reserve(cmp, n) ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new_reserve(ossl_check_IPAddressFamily_compfunc_type(cmp), (n))) +#define sk_IPAddressFamily_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_IPAddressFamily_sk_type(sk), (n)) +#define sk_IPAddressFamily_free(sk) OPENSSL_sk_free(ossl_check_IPAddressFamily_sk_type(sk)) +#define sk_IPAddressFamily_zero(sk) OPENSSL_sk_zero(ossl_check_IPAddressFamily_sk_type(sk)) +#define sk_IPAddressFamily_delete(sk, i) ((IPAddressFamily *)OPENSSL_sk_delete(ossl_check_IPAddressFamily_sk_type(sk), (i))) +#define sk_IPAddressFamily_delete_ptr(sk, ptr) ((IPAddressFamily *)OPENSSL_sk_delete_ptr(ossl_check_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_type(ptr))) +#define sk_IPAddressFamily_push(sk, ptr) OPENSSL_sk_push(ossl_check_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_type(ptr)) +#define sk_IPAddressFamily_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_type(ptr)) +#define sk_IPAddressFamily_pop(sk) ((IPAddressFamily *)OPENSSL_sk_pop(ossl_check_IPAddressFamily_sk_type(sk))) +#define sk_IPAddressFamily_shift(sk) ((IPAddressFamily *)OPENSSL_sk_shift(ossl_check_IPAddressFamily_sk_type(sk))) +#define sk_IPAddressFamily_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_IPAddressFamily_sk_type(sk),ossl_check_IPAddressFamily_freefunc_type(freefunc)) +#define sk_IPAddressFamily_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_type(ptr), (idx)) +#define sk_IPAddressFamily_set(sk, idx, ptr) ((IPAddressFamily *)OPENSSL_sk_set(ossl_check_IPAddressFamily_sk_type(sk), (idx), ossl_check_IPAddressFamily_type(ptr))) +#define sk_IPAddressFamily_find(sk, ptr) OPENSSL_sk_find(ossl_check_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_type(ptr)) +#define sk_IPAddressFamily_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_type(ptr)) +#define sk_IPAddressFamily_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_type(ptr), pnum) +#define sk_IPAddressFamily_sort(sk) OPENSSL_sk_sort(ossl_check_IPAddressFamily_sk_type(sk)) +#define sk_IPAddressFamily_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_IPAddressFamily_sk_type(sk)) +#define sk_IPAddressFamily_dup(sk) ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_dup(ossl_check_const_IPAddressFamily_sk_type(sk))) +#define sk_IPAddressFamily_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_deep_copy(ossl_check_const_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_copyfunc_type(copyfunc), ossl_check_IPAddressFamily_freefunc_type(freefunc))) +#define sk_IPAddressFamily_set_cmp_func(sk, cmp) ((sk_IPAddressFamily_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_IPAddressFamily_sk_type(sk), ossl_check_IPAddressFamily_compfunc_type(cmp))) + + + +typedef STACK_OF(IPAddressFamily) IPAddrBlocks; + +DECLARE_ASN1_FUNCTIONS(IPAddressRange) +DECLARE_ASN1_FUNCTIONS(IPAddressOrRange) +DECLARE_ASN1_FUNCTIONS(IPAddressChoice) +DECLARE_ASN1_FUNCTIONS(IPAddressFamily) + +/* + * API tag for elements of the ASIdentifer SEQUENCE. + */ +# define V3_ASID_ASNUM 0 +# define V3_ASID_RDI 1 + +/* + * AFI values, assigned by IANA. It'd be nice to make the AFI + * handling code totally generic, but there are too many little things + * that would need to be defined for other address families for it to + * be worth the trouble. + */ +# define IANA_AFI_IPV4 1 +# define IANA_AFI_IPV6 2 + +/* + * Utilities to construct and extract values from RFC3779 extensions, + * since some of the encodings (particularly for IP address prefixes + * and ranges) are a bit tedious to work with directly. + */ +int X509v3_asid_add_inherit(ASIdentifiers *asid, int which); +int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which, + ASN1_INTEGER *min, ASN1_INTEGER *max); +int X509v3_addr_add_inherit(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi); +int X509v3_addr_add_prefix(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi, + unsigned char *a, const int prefixlen); +int X509v3_addr_add_range(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi, + unsigned char *min, unsigned char *max); +unsigned X509v3_addr_get_afi(const IPAddressFamily *f); +int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, + unsigned char *min, unsigned char *max, + const int length); + +/* + * Canonical forms. + */ +int X509v3_asid_is_canonical(ASIdentifiers *asid); +int X509v3_addr_is_canonical(IPAddrBlocks *addr); +int X509v3_asid_canonize(ASIdentifiers *asid); +int X509v3_addr_canonize(IPAddrBlocks *addr); + +/* + * Tests for inheritance and containment. + */ +int X509v3_asid_inherits(ASIdentifiers *asid); +int X509v3_addr_inherits(IPAddrBlocks *addr); +int X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b); +int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); + +/* + * Check whether RFC 3779 extensions nest properly in chains. + */ +int X509v3_asid_validate_path(X509_STORE_CTX *); +int X509v3_addr_validate_path(X509_STORE_CTX *); +int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain, + ASIdentifiers *ext, + int allow_inheritance); +int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain, + IPAddrBlocks *ext, int allow_inheritance); + +#endif /* OPENSSL_NO_RFC3779 */ + +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_STRING, ASN1_STRING, ASN1_STRING) +#define sk_ASN1_STRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_value(sk, idx) ((ASN1_STRING *)OPENSSL_sk_value(ossl_check_const_ASN1_STRING_sk_type(sk), (idx))) +#define sk_ASN1_STRING_new(cmp) ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new(ossl_check_ASN1_STRING_compfunc_type(cmp))) +#define sk_ASN1_STRING_new_null() ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new_null()) +#define sk_ASN1_STRING_new_reserve(cmp, n) ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_STRING_compfunc_type(cmp), (n))) +#define sk_ASN1_STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_STRING_sk_type(sk), (n)) +#define sk_ASN1_STRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_delete(sk, i) ((ASN1_STRING *)OPENSSL_sk_delete(ossl_check_ASN1_STRING_sk_type(sk), (i))) +#define sk_ASN1_STRING_delete_ptr(sk, ptr) ((ASN1_STRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr))) +#define sk_ASN1_STRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr)) +#define sk_ASN1_STRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr)) +#define sk_ASN1_STRING_pop(sk) ((ASN1_STRING *)OPENSSL_sk_pop(ossl_check_ASN1_STRING_sk_type(sk))) +#define sk_ASN1_STRING_shift(sk) ((ASN1_STRING *)OPENSSL_sk_shift(ossl_check_ASN1_STRING_sk_type(sk))) +#define sk_ASN1_STRING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_STRING_sk_type(sk),ossl_check_ASN1_STRING_freefunc_type(freefunc)) +#define sk_ASN1_STRING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr), (idx)) +#define sk_ASN1_STRING_set(sk, idx, ptr) ((ASN1_STRING *)OPENSSL_sk_set(ossl_check_ASN1_STRING_sk_type(sk), (idx), ossl_check_ASN1_STRING_type(ptr))) +#define sk_ASN1_STRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr)) +#define sk_ASN1_STRING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr)) +#define sk_ASN1_STRING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr), pnum) +#define sk_ASN1_STRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_dup(sk) ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_STRING_sk_type(sk))) +#define sk_ASN1_STRING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_copyfunc_type(copyfunc), ossl_check_ASN1_STRING_freefunc_type(freefunc))) +#define sk_ASN1_STRING_set_cmp_func(sk, cmp) ((sk_ASN1_STRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_compfunc_type(cmp))) + + +/* + * Admission Syntax + */ +typedef struct NamingAuthority_st NAMING_AUTHORITY; +typedef struct ProfessionInfo_st PROFESSION_INFO; +typedef struct Admissions_st ADMISSIONS; +typedef struct AdmissionSyntax_st ADMISSION_SYNTAX; +DECLARE_ASN1_FUNCTIONS(NAMING_AUTHORITY) +DECLARE_ASN1_FUNCTIONS(PROFESSION_INFO) +DECLARE_ASN1_FUNCTIONS(ADMISSIONS) +DECLARE_ASN1_FUNCTIONS(ADMISSION_SYNTAX) +SKM_DEFINE_STACK_OF_INTERNAL(PROFESSION_INFO, PROFESSION_INFO, PROFESSION_INFO) +#define sk_PROFESSION_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_value(sk, idx) ((PROFESSION_INFO *)OPENSSL_sk_value(ossl_check_const_PROFESSION_INFO_sk_type(sk), (idx))) +#define sk_PROFESSION_INFO_new(cmp) ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new(ossl_check_PROFESSION_INFO_compfunc_type(cmp))) +#define sk_PROFESSION_INFO_new_null() ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new_null()) +#define sk_PROFESSION_INFO_new_reserve(cmp, n) ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new_reserve(ossl_check_PROFESSION_INFO_compfunc_type(cmp), (n))) +#define sk_PROFESSION_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PROFESSION_INFO_sk_type(sk), (n)) +#define sk_PROFESSION_INFO_free(sk) OPENSSL_sk_free(ossl_check_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_delete(sk, i) ((PROFESSION_INFO *)OPENSSL_sk_delete(ossl_check_PROFESSION_INFO_sk_type(sk), (i))) +#define sk_PROFESSION_INFO_delete_ptr(sk, ptr) ((PROFESSION_INFO *)OPENSSL_sk_delete_ptr(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr))) +#define sk_PROFESSION_INFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr)) +#define sk_PROFESSION_INFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr)) +#define sk_PROFESSION_INFO_pop(sk) ((PROFESSION_INFO *)OPENSSL_sk_pop(ossl_check_PROFESSION_INFO_sk_type(sk))) +#define sk_PROFESSION_INFO_shift(sk) ((PROFESSION_INFO *)OPENSSL_sk_shift(ossl_check_PROFESSION_INFO_sk_type(sk))) +#define sk_PROFESSION_INFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_PROFESSION_INFO_sk_type(sk),ossl_check_PROFESSION_INFO_freefunc_type(freefunc)) +#define sk_PROFESSION_INFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr), (idx)) +#define sk_PROFESSION_INFO_set(sk, idx, ptr) ((PROFESSION_INFO *)OPENSSL_sk_set(ossl_check_PROFESSION_INFO_sk_type(sk), (idx), ossl_check_PROFESSION_INFO_type(ptr))) +#define sk_PROFESSION_INFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr)) +#define sk_PROFESSION_INFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr)) +#define sk_PROFESSION_INFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr), pnum) +#define sk_PROFESSION_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_dup(sk) ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_dup(ossl_check_const_PROFESSION_INFO_sk_type(sk))) +#define sk_PROFESSION_INFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_deep_copy(ossl_check_const_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_copyfunc_type(copyfunc), ossl_check_PROFESSION_INFO_freefunc_type(freefunc))) +#define sk_PROFESSION_INFO_set_cmp_func(sk, cmp) ((sk_PROFESSION_INFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(ADMISSIONS, ADMISSIONS, ADMISSIONS) +#define sk_ADMISSIONS_num(sk) OPENSSL_sk_num(ossl_check_const_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_value(sk, idx) ((ADMISSIONS *)OPENSSL_sk_value(ossl_check_const_ADMISSIONS_sk_type(sk), (idx))) +#define sk_ADMISSIONS_new(cmp) ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_new(ossl_check_ADMISSIONS_compfunc_type(cmp))) +#define sk_ADMISSIONS_new_null() ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_new_null()) +#define sk_ADMISSIONS_new_reserve(cmp, n) ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_new_reserve(ossl_check_ADMISSIONS_compfunc_type(cmp), (n))) +#define sk_ADMISSIONS_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ADMISSIONS_sk_type(sk), (n)) +#define sk_ADMISSIONS_free(sk) OPENSSL_sk_free(ossl_check_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_zero(sk) OPENSSL_sk_zero(ossl_check_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_delete(sk, i) ((ADMISSIONS *)OPENSSL_sk_delete(ossl_check_ADMISSIONS_sk_type(sk), (i))) +#define sk_ADMISSIONS_delete_ptr(sk, ptr) ((ADMISSIONS *)OPENSSL_sk_delete_ptr(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr))) +#define sk_ADMISSIONS_push(sk, ptr) OPENSSL_sk_push(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr)) +#define sk_ADMISSIONS_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr)) +#define sk_ADMISSIONS_pop(sk) ((ADMISSIONS *)OPENSSL_sk_pop(ossl_check_ADMISSIONS_sk_type(sk))) +#define sk_ADMISSIONS_shift(sk) ((ADMISSIONS *)OPENSSL_sk_shift(ossl_check_ADMISSIONS_sk_type(sk))) +#define sk_ADMISSIONS_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ADMISSIONS_sk_type(sk),ossl_check_ADMISSIONS_freefunc_type(freefunc)) +#define sk_ADMISSIONS_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr), (idx)) +#define sk_ADMISSIONS_set(sk, idx, ptr) ((ADMISSIONS *)OPENSSL_sk_set(ossl_check_ADMISSIONS_sk_type(sk), (idx), ossl_check_ADMISSIONS_type(ptr))) +#define sk_ADMISSIONS_find(sk, ptr) OPENSSL_sk_find(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr)) +#define sk_ADMISSIONS_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr)) +#define sk_ADMISSIONS_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr), pnum) +#define sk_ADMISSIONS_sort(sk) OPENSSL_sk_sort(ossl_check_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_dup(sk) ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_dup(ossl_check_const_ADMISSIONS_sk_type(sk))) +#define sk_ADMISSIONS_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_deep_copy(ossl_check_const_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_copyfunc_type(copyfunc), ossl_check_ADMISSIONS_freefunc_type(freefunc))) +#define sk_ADMISSIONS_set_cmp_func(sk, cmp) ((sk_ADMISSIONS_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_compfunc_type(cmp))) + +typedef STACK_OF(PROFESSION_INFO) PROFESSION_INFOS; + +const ASN1_OBJECT *NAMING_AUTHORITY_get0_authorityId( + const NAMING_AUTHORITY *n); +const ASN1_IA5STRING *NAMING_AUTHORITY_get0_authorityURL( + const NAMING_AUTHORITY *n); +const ASN1_STRING *NAMING_AUTHORITY_get0_authorityText( + const NAMING_AUTHORITY *n); +void NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n, + ASN1_OBJECT* namingAuthorityId); +void NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n, + ASN1_IA5STRING* namingAuthorityUrl); +void NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n, + ASN1_STRING* namingAuthorityText); + +const GENERAL_NAME *ADMISSION_SYNTAX_get0_admissionAuthority( + const ADMISSION_SYNTAX *as); +void ADMISSION_SYNTAX_set0_admissionAuthority( + ADMISSION_SYNTAX *as, GENERAL_NAME *aa); +const STACK_OF(ADMISSIONS) *ADMISSION_SYNTAX_get0_contentsOfAdmissions( + const ADMISSION_SYNTAX *as); +void ADMISSION_SYNTAX_set0_contentsOfAdmissions( + ADMISSION_SYNTAX *as, STACK_OF(ADMISSIONS) *a); +const GENERAL_NAME *ADMISSIONS_get0_admissionAuthority(const ADMISSIONS *a); +void ADMISSIONS_set0_admissionAuthority(ADMISSIONS *a, GENERAL_NAME *aa); +const NAMING_AUTHORITY *ADMISSIONS_get0_namingAuthority(const ADMISSIONS *a); +void ADMISSIONS_set0_namingAuthority(ADMISSIONS *a, NAMING_AUTHORITY *na); +const PROFESSION_INFOS *ADMISSIONS_get0_professionInfos(const ADMISSIONS *a); +void ADMISSIONS_set0_professionInfos(ADMISSIONS *a, PROFESSION_INFOS *pi); +const ASN1_OCTET_STRING *PROFESSION_INFO_get0_addProfessionInfo( + const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_addProfessionInfo( + PROFESSION_INFO *pi, ASN1_OCTET_STRING *aos); +const NAMING_AUTHORITY *PROFESSION_INFO_get0_namingAuthority( + const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_namingAuthority( + PROFESSION_INFO *pi, NAMING_AUTHORITY *na); +const STACK_OF(ASN1_STRING) *PROFESSION_INFO_get0_professionItems( + const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_professionItems( + PROFESSION_INFO *pi, STACK_OF(ASN1_STRING) *as); +const STACK_OF(ASN1_OBJECT) *PROFESSION_INFO_get0_professionOIDs( + const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_professionOIDs( + PROFESSION_INFO *pi, STACK_OF(ASN1_OBJECT) *po); +const ASN1_PRINTABLESTRING *PROFESSION_INFO_get0_registrationNumber( + const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_registrationNumber( + PROFESSION_INFO *pi, ASN1_PRINTABLESTRING *rn); + +int OSSL_GENERAL_NAMES_print(BIO *out, GENERAL_NAMES *gens, int indent); + +typedef STACK_OF(X509_ATTRIBUTE) OSSL_ATTRIBUTES_SYNTAX; +DECLARE_ASN1_FUNCTIONS(OSSL_ATTRIBUTES_SYNTAX) + +typedef STACK_OF(USERNOTICE) OSSL_USER_NOTICE_SYNTAX; +DECLARE_ASN1_FUNCTIONS(OSSL_USER_NOTICE_SYNTAX) + +SKM_DEFINE_STACK_OF_INTERNAL(USERNOTICE, USERNOTICE, USERNOTICE) +#define sk_USERNOTICE_num(sk) OPENSSL_sk_num(ossl_check_const_USERNOTICE_sk_type(sk)) +#define sk_USERNOTICE_value(sk, idx) ((USERNOTICE *)OPENSSL_sk_value(ossl_check_const_USERNOTICE_sk_type(sk), (idx))) +#define sk_USERNOTICE_new(cmp) ((STACK_OF(USERNOTICE) *)OPENSSL_sk_new(ossl_check_USERNOTICE_compfunc_type(cmp))) +#define sk_USERNOTICE_new_null() ((STACK_OF(USERNOTICE) *)OPENSSL_sk_new_null()) +#define sk_USERNOTICE_new_reserve(cmp, n) ((STACK_OF(USERNOTICE) *)OPENSSL_sk_new_reserve(ossl_check_USERNOTICE_compfunc_type(cmp), (n))) +#define sk_USERNOTICE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_USERNOTICE_sk_type(sk), (n)) +#define sk_USERNOTICE_free(sk) OPENSSL_sk_free(ossl_check_USERNOTICE_sk_type(sk)) +#define sk_USERNOTICE_zero(sk) OPENSSL_sk_zero(ossl_check_USERNOTICE_sk_type(sk)) +#define sk_USERNOTICE_delete(sk, i) ((USERNOTICE *)OPENSSL_sk_delete(ossl_check_USERNOTICE_sk_type(sk), (i))) +#define sk_USERNOTICE_delete_ptr(sk, ptr) ((USERNOTICE *)OPENSSL_sk_delete_ptr(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_type(ptr))) +#define sk_USERNOTICE_push(sk, ptr) OPENSSL_sk_push(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_type(ptr)) +#define sk_USERNOTICE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_type(ptr)) +#define sk_USERNOTICE_pop(sk) ((USERNOTICE *)OPENSSL_sk_pop(ossl_check_USERNOTICE_sk_type(sk))) +#define sk_USERNOTICE_shift(sk) ((USERNOTICE *)OPENSSL_sk_shift(ossl_check_USERNOTICE_sk_type(sk))) +#define sk_USERNOTICE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_USERNOTICE_sk_type(sk),ossl_check_USERNOTICE_freefunc_type(freefunc)) +#define sk_USERNOTICE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_type(ptr), (idx)) +#define sk_USERNOTICE_set(sk, idx, ptr) ((USERNOTICE *)OPENSSL_sk_set(ossl_check_USERNOTICE_sk_type(sk), (idx), ossl_check_USERNOTICE_type(ptr))) +#define sk_USERNOTICE_find(sk, ptr) OPENSSL_sk_find(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_type(ptr)) +#define sk_USERNOTICE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_type(ptr)) +#define sk_USERNOTICE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_type(ptr), pnum) +#define sk_USERNOTICE_sort(sk) OPENSSL_sk_sort(ossl_check_USERNOTICE_sk_type(sk)) +#define sk_USERNOTICE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_USERNOTICE_sk_type(sk)) +#define sk_USERNOTICE_dup(sk) ((STACK_OF(USERNOTICE) *)OPENSSL_sk_dup(ossl_check_const_USERNOTICE_sk_type(sk))) +#define sk_USERNOTICE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(USERNOTICE) *)OPENSSL_sk_deep_copy(ossl_check_const_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_copyfunc_type(copyfunc), ossl_check_USERNOTICE_freefunc_type(freefunc))) +#define sk_USERNOTICE_set_cmp_func(sk, cmp) ((sk_USERNOTICE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_compfunc_type(cmp))) + + +typedef struct OSSL_ROLE_SPEC_CERT_ID_st { + GENERAL_NAME *roleName; + GENERAL_NAME *roleCertIssuer; + ASN1_INTEGER *roleCertSerialNumber; + GENERAL_NAMES *roleCertLocator; +} OSSL_ROLE_SPEC_CERT_ID; + +DECLARE_ASN1_FUNCTIONS(OSSL_ROLE_SPEC_CERT_ID) + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_ROLE_SPEC_CERT_ID, OSSL_ROLE_SPEC_CERT_ID, OSSL_ROLE_SPEC_CERT_ID) +#define sk_OSSL_ROLE_SPEC_CERT_ID_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_value(sk, idx) ((OSSL_ROLE_SPEC_CERT_ID *)OPENSSL_sk_value(ossl_check_const_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), (idx))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_new(cmp) ((STACK_OF(OSSL_ROLE_SPEC_CERT_ID) *)OPENSSL_sk_new(ossl_check_OSSL_ROLE_SPEC_CERT_ID_compfunc_type(cmp))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_new_null() ((STACK_OF(OSSL_ROLE_SPEC_CERT_ID) *)OPENSSL_sk_new_null()) +#define sk_OSSL_ROLE_SPEC_CERT_ID_new_reserve(cmp, n) ((STACK_OF(OSSL_ROLE_SPEC_CERT_ID) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_ROLE_SPEC_CERT_ID_compfunc_type(cmp), (n))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), (n)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_free(sk) OPENSSL_sk_free(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_delete(sk, i) ((OSSL_ROLE_SPEC_CERT_ID *)OPENSSL_sk_delete(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), (i))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_delete_ptr(sk, ptr) ((OSSL_ROLE_SPEC_CERT_ID *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_type(ptr))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_type(ptr)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_type(ptr)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_pop(sk) ((OSSL_ROLE_SPEC_CERT_ID *)OPENSSL_sk_pop(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_shift(sk) ((OSSL_ROLE_SPEC_CERT_ID *)OPENSSL_sk_shift(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk),ossl_check_OSSL_ROLE_SPEC_CERT_ID_freefunc_type(freefunc)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_type(ptr), (idx)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_set(sk, idx, ptr) ((OSSL_ROLE_SPEC_CERT_ID *)OPENSSL_sk_set(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), (idx), ossl_check_OSSL_ROLE_SPEC_CERT_ID_type(ptr))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_type(ptr)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_type(ptr)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_type(ptr), pnum) +#define sk_OSSL_ROLE_SPEC_CERT_ID_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk)) +#define sk_OSSL_ROLE_SPEC_CERT_ID_dup(sk) ((STACK_OF(OSSL_ROLE_SPEC_CERT_ID) *)OPENSSL_sk_dup(ossl_check_const_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_ROLE_SPEC_CERT_ID) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_copyfunc_type(copyfunc), ossl_check_OSSL_ROLE_SPEC_CERT_ID_freefunc_type(freefunc))) +#define sk_OSSL_ROLE_SPEC_CERT_ID_set_cmp_func(sk, cmp) ((sk_OSSL_ROLE_SPEC_CERT_ID_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), ossl_check_OSSL_ROLE_SPEC_CERT_ID_compfunc_type(cmp))) + + +typedef STACK_OF(OSSL_ROLE_SPEC_CERT_ID) OSSL_ROLE_SPEC_CERT_ID_SYNTAX; + +DECLARE_ASN1_FUNCTIONS(OSSL_ROLE_SPEC_CERT_ID_SYNTAX) +typedef struct OSSL_HASH_st { + X509_ALGOR *algorithmIdentifier; + ASN1_BIT_STRING *hashValue; +} OSSL_HASH; + +typedef struct OSSL_INFO_SYNTAX_POINTER_st { + GENERAL_NAMES *name; + OSSL_HASH *hash; +} OSSL_INFO_SYNTAX_POINTER; + +# define OSSL_INFO_SYNTAX_TYPE_CONTENT 0 +# define OSSL_INFO_SYNTAX_TYPE_POINTER 1 + +typedef struct OSSL_INFO_SYNTAX_st { + int type; + union { + ASN1_STRING *content; + OSSL_INFO_SYNTAX_POINTER *pointer; + } choice; +} OSSL_INFO_SYNTAX; + +typedef struct OSSL_PRIVILEGE_POLICY_ID_st { + ASN1_OBJECT *privilegePolicy; + OSSL_INFO_SYNTAX *privPolSyntax; +} OSSL_PRIVILEGE_POLICY_ID; + +typedef struct OSSL_ATTRIBUTE_DESCRIPTOR_st { + ASN1_OBJECT *identifier; + ASN1_STRING *attributeSyntax; + ASN1_UTF8STRING *name; + ASN1_UTF8STRING *description; + OSSL_PRIVILEGE_POLICY_ID *dominationRule; +} OSSL_ATTRIBUTE_DESCRIPTOR; + +DECLARE_ASN1_FUNCTIONS(OSSL_HASH) +DECLARE_ASN1_FUNCTIONS(OSSL_INFO_SYNTAX) +DECLARE_ASN1_FUNCTIONS(OSSL_INFO_SYNTAX_POINTER) +DECLARE_ASN1_FUNCTIONS(OSSL_PRIVILEGE_POLICY_ID) +DECLARE_ASN1_FUNCTIONS(OSSL_ATTRIBUTE_DESCRIPTOR) + +typedef struct OSSL_TIME_SPEC_ABSOLUTE_st { + ASN1_GENERALIZEDTIME *startTime; + ASN1_GENERALIZEDTIME *endTime; +} OSSL_TIME_SPEC_ABSOLUTE; + +typedef struct OSSL_DAY_TIME_st { + ASN1_INTEGER *hour; + ASN1_INTEGER *minute; + ASN1_INTEGER *second; +} OSSL_DAY_TIME; + +typedef struct OSSL_DAY_TIME_BAND_st { + OSSL_DAY_TIME *startDayTime; + OSSL_DAY_TIME *endDayTime; +} OSSL_DAY_TIME_BAND; + +# define OSSL_NAMED_DAY_TYPE_INT 0 +# define OSSL_NAMED_DAY_TYPE_BIT 1 +# define OSSL_NAMED_DAY_INT_SUN 1 +# define OSSL_NAMED_DAY_INT_MON 2 +# define OSSL_NAMED_DAY_INT_TUE 3 +# define OSSL_NAMED_DAY_INT_WED 4 +# define OSSL_NAMED_DAY_INT_THU 5 +# define OSSL_NAMED_DAY_INT_FRI 6 +# define OSSL_NAMED_DAY_INT_SAT 7 +# define OSSL_NAMED_DAY_BIT_SUN 0 +# define OSSL_NAMED_DAY_BIT_MON 1 +# define OSSL_NAMED_DAY_BIT_TUE 2 +# define OSSL_NAMED_DAY_BIT_WED 3 +# define OSSL_NAMED_DAY_BIT_THU 4 +# define OSSL_NAMED_DAY_BIT_FRI 5 +# define OSSL_NAMED_DAY_BIT_SAT 6 + +typedef struct OSSL_NAMED_DAY_st { + int type; + union { + ASN1_INTEGER *intNamedDays; + ASN1_BIT_STRING *bitNamedDays; + } choice; +} OSSL_NAMED_DAY; + +# define OSSL_TIME_SPEC_X_DAY_OF_FIRST 0 +# define OSSL_TIME_SPEC_X_DAY_OF_SECOND 1 +# define OSSL_TIME_SPEC_X_DAY_OF_THIRD 2 +# define OSSL_TIME_SPEC_X_DAY_OF_FOURTH 3 +# define OSSL_TIME_SPEC_X_DAY_OF_FIFTH 4 + +typedef struct OSSL_TIME_SPEC_X_DAY_OF_st { + int type; + union { + OSSL_NAMED_DAY *first; + OSSL_NAMED_DAY *second; + OSSL_NAMED_DAY *third; + OSSL_NAMED_DAY *fourth; + OSSL_NAMED_DAY *fifth; + } choice; +} OSSL_TIME_SPEC_X_DAY_OF; + +# define OSSL_TIME_SPEC_DAY_TYPE_INT 0 +# define OSSL_TIME_SPEC_DAY_TYPE_BIT 1 +# define OSSL_TIME_SPEC_DAY_TYPE_DAY_OF 2 +# define OSSL_TIME_SPEC_DAY_BIT_SUN 0 +# define OSSL_TIME_SPEC_DAY_BIT_MON 1 +# define OSSL_TIME_SPEC_DAY_BIT_TUE 2 +# define OSSL_TIME_SPEC_DAY_BIT_WED 3 +# define OSSL_TIME_SPEC_DAY_BIT_THU 4 +# define OSSL_TIME_SPEC_DAY_BIT_FRI 5 +# define OSSL_TIME_SPEC_DAY_BIT_SAT 6 +# define OSSL_TIME_SPEC_DAY_INT_SUN 1 +# define OSSL_TIME_SPEC_DAY_INT_MON 2 +# define OSSL_TIME_SPEC_DAY_INT_TUE 3 +# define OSSL_TIME_SPEC_DAY_INT_WED 4 +# define OSSL_TIME_SPEC_DAY_INT_THU 5 +# define OSSL_TIME_SPEC_DAY_INT_FRI 6 +# define OSSL_TIME_SPEC_DAY_INT_SAT 7 + +typedef struct OSSL_TIME_SPEC_DAY_st { + int type; + union { + STACK_OF(ASN1_INTEGER) *intDay; + ASN1_BIT_STRING *bitDay; + OSSL_TIME_SPEC_X_DAY_OF *dayOf; + } choice; +} OSSL_TIME_SPEC_DAY; + +# define OSSL_TIME_SPEC_WEEKS_TYPE_ALL 0 +# define OSSL_TIME_SPEC_WEEKS_TYPE_INT 1 +# define OSSL_TIME_SPEC_WEEKS_TYPE_BIT 2 +# define OSSL_TIME_SPEC_BIT_WEEKS_1 0 +# define OSSL_TIME_SPEC_BIT_WEEKS_2 1 +# define OSSL_TIME_SPEC_BIT_WEEKS_3 2 +# define OSSL_TIME_SPEC_BIT_WEEKS_4 3 +# define OSSL_TIME_SPEC_BIT_WEEKS_5 4 + +typedef struct OSSL_TIME_SPEC_WEEKS_st { + int type; + union { + ASN1_NULL *allWeeks; + STACK_OF(ASN1_INTEGER) *intWeek; + ASN1_BIT_STRING *bitWeek; + } choice; +} OSSL_TIME_SPEC_WEEKS; + +# define OSSL_TIME_SPEC_MONTH_TYPE_ALL 0 +# define OSSL_TIME_SPEC_MONTH_TYPE_INT 1 +# define OSSL_TIME_SPEC_MONTH_TYPE_BIT 2 +# define OSSL_TIME_SPEC_INT_MONTH_JAN 1 +# define OSSL_TIME_SPEC_INT_MONTH_FEB 2 +# define OSSL_TIME_SPEC_INT_MONTH_MAR 3 +# define OSSL_TIME_SPEC_INT_MONTH_APR 4 +# define OSSL_TIME_SPEC_INT_MONTH_MAY 5 +# define OSSL_TIME_SPEC_INT_MONTH_JUN 6 +# define OSSL_TIME_SPEC_INT_MONTH_JUL 7 +# define OSSL_TIME_SPEC_INT_MONTH_AUG 8 +# define OSSL_TIME_SPEC_INT_MONTH_SEP 9 +# define OSSL_TIME_SPEC_INT_MONTH_OCT 10 +# define OSSL_TIME_SPEC_INT_MONTH_NOV 11 +# define OSSL_TIME_SPEC_INT_MONTH_DEC 12 +# define OSSL_TIME_SPEC_BIT_MONTH_JAN 0 +# define OSSL_TIME_SPEC_BIT_MONTH_FEB 1 +# define OSSL_TIME_SPEC_BIT_MONTH_MAR 2 +# define OSSL_TIME_SPEC_BIT_MONTH_APR 3 +# define OSSL_TIME_SPEC_BIT_MONTH_MAY 4 +# define OSSL_TIME_SPEC_BIT_MONTH_JUN 5 +# define OSSL_TIME_SPEC_BIT_MONTH_JUL 6 +# define OSSL_TIME_SPEC_BIT_MONTH_AUG 7 +# define OSSL_TIME_SPEC_BIT_MONTH_SEP 8 +# define OSSL_TIME_SPEC_BIT_MONTH_OCT 9 +# define OSSL_TIME_SPEC_BIT_MONTH_NOV 10 +# define OSSL_TIME_SPEC_BIT_MONTH_DEC 11 + +typedef struct OSSL_TIME_SPEC_MONTH_st { + int type; + union { + ASN1_NULL *allMonths; + STACK_OF(ASN1_INTEGER) *intMonth; + ASN1_BIT_STRING *bitMonth; + } choice; +} OSSL_TIME_SPEC_MONTH; + +typedef struct OSSL_TIME_PERIOD_st { + STACK_OF(OSSL_DAY_TIME_BAND) *timesOfDay; + OSSL_TIME_SPEC_DAY *days; + OSSL_TIME_SPEC_WEEKS *weeks; + OSSL_TIME_SPEC_MONTH *months; + STACK_OF(ASN1_INTEGER) *years; +} OSSL_TIME_PERIOD; + +# define OSSL_TIME_SPEC_TIME_TYPE_ABSOLUTE 0 +# define OSSL_TIME_SPEC_TIME_TYPE_PERIODIC 1 + +typedef struct OSSL_TIME_SPEC_TIME_st { + int type; + union { + OSSL_TIME_SPEC_ABSOLUTE *absolute; + STACK_OF(OSSL_TIME_PERIOD) *periodic; + } choice; +} OSSL_TIME_SPEC_TIME; + +typedef struct OSSL_TIME_SPEC_st { + OSSL_TIME_SPEC_TIME *time; + ASN1_BOOLEAN notThisTime; + ASN1_INTEGER *timeZone; +} OSSL_TIME_SPEC; + +DECLARE_ASN1_FUNCTIONS(OSSL_DAY_TIME) +DECLARE_ASN1_FUNCTIONS(OSSL_DAY_TIME_BAND) +DECLARE_ASN1_FUNCTIONS(OSSL_TIME_SPEC_DAY) +DECLARE_ASN1_FUNCTIONS(OSSL_TIME_SPEC_WEEKS) +DECLARE_ASN1_FUNCTIONS(OSSL_TIME_SPEC_MONTH) +DECLARE_ASN1_FUNCTIONS(OSSL_NAMED_DAY) +DECLARE_ASN1_FUNCTIONS(OSSL_TIME_SPEC_X_DAY_OF) +DECLARE_ASN1_FUNCTIONS(OSSL_TIME_SPEC_ABSOLUTE) +DECLARE_ASN1_FUNCTIONS(OSSL_TIME_SPEC_TIME) +DECLARE_ASN1_FUNCTIONS(OSSL_TIME_SPEC) +DECLARE_ASN1_FUNCTIONS(OSSL_TIME_PERIOD) + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_TIME_PERIOD, OSSL_TIME_PERIOD, OSSL_TIME_PERIOD) +#define sk_OSSL_TIME_PERIOD_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_TIME_PERIOD_sk_type(sk)) +#define sk_OSSL_TIME_PERIOD_value(sk, idx) ((OSSL_TIME_PERIOD *)OPENSSL_sk_value(ossl_check_const_OSSL_TIME_PERIOD_sk_type(sk), (idx))) +#define sk_OSSL_TIME_PERIOD_new(cmp) ((STACK_OF(OSSL_TIME_PERIOD) *)OPENSSL_sk_new(ossl_check_OSSL_TIME_PERIOD_compfunc_type(cmp))) +#define sk_OSSL_TIME_PERIOD_new_null() ((STACK_OF(OSSL_TIME_PERIOD) *)OPENSSL_sk_new_null()) +#define sk_OSSL_TIME_PERIOD_new_reserve(cmp, n) ((STACK_OF(OSSL_TIME_PERIOD) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_TIME_PERIOD_compfunc_type(cmp), (n))) +#define sk_OSSL_TIME_PERIOD_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), (n)) +#define sk_OSSL_TIME_PERIOD_free(sk) OPENSSL_sk_free(ossl_check_OSSL_TIME_PERIOD_sk_type(sk)) +#define sk_OSSL_TIME_PERIOD_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_TIME_PERIOD_sk_type(sk)) +#define sk_OSSL_TIME_PERIOD_delete(sk, i) ((OSSL_TIME_PERIOD *)OPENSSL_sk_delete(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), (i))) +#define sk_OSSL_TIME_PERIOD_delete_ptr(sk, ptr) ((OSSL_TIME_PERIOD *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_type(ptr))) +#define sk_OSSL_TIME_PERIOD_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_type(ptr)) +#define sk_OSSL_TIME_PERIOD_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_type(ptr)) +#define sk_OSSL_TIME_PERIOD_pop(sk) ((OSSL_TIME_PERIOD *)OPENSSL_sk_pop(ossl_check_OSSL_TIME_PERIOD_sk_type(sk))) +#define sk_OSSL_TIME_PERIOD_shift(sk) ((OSSL_TIME_PERIOD *)OPENSSL_sk_shift(ossl_check_OSSL_TIME_PERIOD_sk_type(sk))) +#define sk_OSSL_TIME_PERIOD_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_TIME_PERIOD_sk_type(sk),ossl_check_OSSL_TIME_PERIOD_freefunc_type(freefunc)) +#define sk_OSSL_TIME_PERIOD_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_type(ptr), (idx)) +#define sk_OSSL_TIME_PERIOD_set(sk, idx, ptr) ((OSSL_TIME_PERIOD *)OPENSSL_sk_set(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), (idx), ossl_check_OSSL_TIME_PERIOD_type(ptr))) +#define sk_OSSL_TIME_PERIOD_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_type(ptr)) +#define sk_OSSL_TIME_PERIOD_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_type(ptr)) +#define sk_OSSL_TIME_PERIOD_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_type(ptr), pnum) +#define sk_OSSL_TIME_PERIOD_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_TIME_PERIOD_sk_type(sk)) +#define sk_OSSL_TIME_PERIOD_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_TIME_PERIOD_sk_type(sk)) +#define sk_OSSL_TIME_PERIOD_dup(sk) ((STACK_OF(OSSL_TIME_PERIOD) *)OPENSSL_sk_dup(ossl_check_const_OSSL_TIME_PERIOD_sk_type(sk))) +#define sk_OSSL_TIME_PERIOD_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_TIME_PERIOD) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_copyfunc_type(copyfunc), ossl_check_OSSL_TIME_PERIOD_freefunc_type(freefunc))) +#define sk_OSSL_TIME_PERIOD_set_cmp_func(sk, cmp) ((sk_OSSL_TIME_PERIOD_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_TIME_PERIOD_sk_type(sk), ossl_check_OSSL_TIME_PERIOD_compfunc_type(cmp))) + + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_DAY_TIME_BAND, OSSL_DAY_TIME_BAND, OSSL_DAY_TIME_BAND) +#define sk_OSSL_DAY_TIME_BAND_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_DAY_TIME_BAND_sk_type(sk)) +#define sk_OSSL_DAY_TIME_BAND_value(sk, idx) ((OSSL_DAY_TIME_BAND *)OPENSSL_sk_value(ossl_check_const_OSSL_DAY_TIME_BAND_sk_type(sk), (idx))) +#define sk_OSSL_DAY_TIME_BAND_new(cmp) ((STACK_OF(OSSL_DAY_TIME_BAND) *)OPENSSL_sk_new(ossl_check_OSSL_DAY_TIME_BAND_compfunc_type(cmp))) +#define sk_OSSL_DAY_TIME_BAND_new_null() ((STACK_OF(OSSL_DAY_TIME_BAND) *)OPENSSL_sk_new_null()) +#define sk_OSSL_DAY_TIME_BAND_new_reserve(cmp, n) ((STACK_OF(OSSL_DAY_TIME_BAND) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_DAY_TIME_BAND_compfunc_type(cmp), (n))) +#define sk_OSSL_DAY_TIME_BAND_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), (n)) +#define sk_OSSL_DAY_TIME_BAND_free(sk) OPENSSL_sk_free(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk)) +#define sk_OSSL_DAY_TIME_BAND_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk)) +#define sk_OSSL_DAY_TIME_BAND_delete(sk, i) ((OSSL_DAY_TIME_BAND *)OPENSSL_sk_delete(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), (i))) +#define sk_OSSL_DAY_TIME_BAND_delete_ptr(sk, ptr) ((OSSL_DAY_TIME_BAND *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_type(ptr))) +#define sk_OSSL_DAY_TIME_BAND_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_type(ptr)) +#define sk_OSSL_DAY_TIME_BAND_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_type(ptr)) +#define sk_OSSL_DAY_TIME_BAND_pop(sk) ((OSSL_DAY_TIME_BAND *)OPENSSL_sk_pop(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk))) +#define sk_OSSL_DAY_TIME_BAND_shift(sk) ((OSSL_DAY_TIME_BAND *)OPENSSL_sk_shift(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk))) +#define sk_OSSL_DAY_TIME_BAND_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk),ossl_check_OSSL_DAY_TIME_BAND_freefunc_type(freefunc)) +#define sk_OSSL_DAY_TIME_BAND_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_type(ptr), (idx)) +#define sk_OSSL_DAY_TIME_BAND_set(sk, idx, ptr) ((OSSL_DAY_TIME_BAND *)OPENSSL_sk_set(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), (idx), ossl_check_OSSL_DAY_TIME_BAND_type(ptr))) +#define sk_OSSL_DAY_TIME_BAND_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_type(ptr)) +#define sk_OSSL_DAY_TIME_BAND_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_type(ptr)) +#define sk_OSSL_DAY_TIME_BAND_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_type(ptr), pnum) +#define sk_OSSL_DAY_TIME_BAND_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk)) +#define sk_OSSL_DAY_TIME_BAND_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_DAY_TIME_BAND_sk_type(sk)) +#define sk_OSSL_DAY_TIME_BAND_dup(sk) ((STACK_OF(OSSL_DAY_TIME_BAND) *)OPENSSL_sk_dup(ossl_check_const_OSSL_DAY_TIME_BAND_sk_type(sk))) +#define sk_OSSL_DAY_TIME_BAND_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_DAY_TIME_BAND) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_copyfunc_type(copyfunc), ossl_check_OSSL_DAY_TIME_BAND_freefunc_type(freefunc))) +#define sk_OSSL_DAY_TIME_BAND_set_cmp_func(sk, cmp) ((sk_OSSL_DAY_TIME_BAND_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_DAY_TIME_BAND_sk_type(sk), ossl_check_OSSL_DAY_TIME_BAND_compfunc_type(cmp))) + + +/* Attribute Type and Value */ +typedef struct atav_st { + ASN1_OBJECT *type; + ASN1_TYPE *value; +} OSSL_ATAV; + +typedef struct ATTRIBUTE_TYPE_MAPPING_st { + ASN1_OBJECT *local; + ASN1_OBJECT *remote; +} OSSL_ATTRIBUTE_TYPE_MAPPING; + +typedef struct ATTRIBUTE_VALUE_MAPPING_st { + OSSL_ATAV *local; + OSSL_ATAV *remote; +} OSSL_ATTRIBUTE_VALUE_MAPPING; + +# define OSSL_ATTR_MAP_TYPE 0 +# define OSSL_ATTR_MAP_VALUE 1 + +typedef struct ATTRIBUTE_MAPPING_st { + int type; + union { + OSSL_ATTRIBUTE_TYPE_MAPPING *typeMappings; + OSSL_ATTRIBUTE_VALUE_MAPPING *typeValueMappings; + } choice; +} OSSL_ATTRIBUTE_MAPPING; + +typedef STACK_OF(OSSL_ATTRIBUTE_MAPPING) OSSL_ATTRIBUTE_MAPPINGS; +DECLARE_ASN1_FUNCTIONS(OSSL_ATAV) +DECLARE_ASN1_FUNCTIONS(OSSL_ATTRIBUTE_TYPE_MAPPING) +DECLARE_ASN1_FUNCTIONS(OSSL_ATTRIBUTE_VALUE_MAPPING) +DECLARE_ASN1_FUNCTIONS(OSSL_ATTRIBUTE_MAPPING) +DECLARE_ASN1_FUNCTIONS(OSSL_ATTRIBUTE_MAPPINGS) + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_ATTRIBUTE_MAPPING, OSSL_ATTRIBUTE_MAPPING, OSSL_ATTRIBUTE_MAPPING) +#define sk_OSSL_ATTRIBUTE_MAPPING_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_ATTRIBUTE_MAPPING_sk_type(sk)) +#define sk_OSSL_ATTRIBUTE_MAPPING_value(sk, idx) ((OSSL_ATTRIBUTE_MAPPING *)OPENSSL_sk_value(ossl_check_const_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), (idx))) +#define sk_OSSL_ATTRIBUTE_MAPPING_new(cmp) ((STACK_OF(OSSL_ATTRIBUTE_MAPPING) *)OPENSSL_sk_new(ossl_check_OSSL_ATTRIBUTE_MAPPING_compfunc_type(cmp))) +#define sk_OSSL_ATTRIBUTE_MAPPING_new_null() ((STACK_OF(OSSL_ATTRIBUTE_MAPPING) *)OPENSSL_sk_new_null()) +#define sk_OSSL_ATTRIBUTE_MAPPING_new_reserve(cmp, n) ((STACK_OF(OSSL_ATTRIBUTE_MAPPING) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_ATTRIBUTE_MAPPING_compfunc_type(cmp), (n))) +#define sk_OSSL_ATTRIBUTE_MAPPING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), (n)) +#define sk_OSSL_ATTRIBUTE_MAPPING_free(sk) OPENSSL_sk_free(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk)) +#define sk_OSSL_ATTRIBUTE_MAPPING_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk)) +#define sk_OSSL_ATTRIBUTE_MAPPING_delete(sk, i) ((OSSL_ATTRIBUTE_MAPPING *)OPENSSL_sk_delete(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), (i))) +#define sk_OSSL_ATTRIBUTE_MAPPING_delete_ptr(sk, ptr) ((OSSL_ATTRIBUTE_MAPPING *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_type(ptr))) +#define sk_OSSL_ATTRIBUTE_MAPPING_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_type(ptr)) +#define sk_OSSL_ATTRIBUTE_MAPPING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_type(ptr)) +#define sk_OSSL_ATTRIBUTE_MAPPING_pop(sk) ((OSSL_ATTRIBUTE_MAPPING *)OPENSSL_sk_pop(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk))) +#define sk_OSSL_ATTRIBUTE_MAPPING_shift(sk) ((OSSL_ATTRIBUTE_MAPPING *)OPENSSL_sk_shift(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk))) +#define sk_OSSL_ATTRIBUTE_MAPPING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk),ossl_check_OSSL_ATTRIBUTE_MAPPING_freefunc_type(freefunc)) +#define sk_OSSL_ATTRIBUTE_MAPPING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_type(ptr), (idx)) +#define sk_OSSL_ATTRIBUTE_MAPPING_set(sk, idx, ptr) ((OSSL_ATTRIBUTE_MAPPING *)OPENSSL_sk_set(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), (idx), ossl_check_OSSL_ATTRIBUTE_MAPPING_type(ptr))) +#define sk_OSSL_ATTRIBUTE_MAPPING_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_type(ptr)) +#define sk_OSSL_ATTRIBUTE_MAPPING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_type(ptr)) +#define sk_OSSL_ATTRIBUTE_MAPPING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_type(ptr), pnum) +#define sk_OSSL_ATTRIBUTE_MAPPING_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk)) +#define sk_OSSL_ATTRIBUTE_MAPPING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_ATTRIBUTE_MAPPING_sk_type(sk)) +#define sk_OSSL_ATTRIBUTE_MAPPING_dup(sk) ((STACK_OF(OSSL_ATTRIBUTE_MAPPING) *)OPENSSL_sk_dup(ossl_check_const_OSSL_ATTRIBUTE_MAPPING_sk_type(sk))) +#define sk_OSSL_ATTRIBUTE_MAPPING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_ATTRIBUTE_MAPPING) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_copyfunc_type(copyfunc), ossl_check_OSSL_ATTRIBUTE_MAPPING_freefunc_type(freefunc))) +#define sk_OSSL_ATTRIBUTE_MAPPING_set_cmp_func(sk, cmp) ((sk_OSSL_ATTRIBUTE_MAPPING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_ATTRIBUTE_MAPPING_sk_type(sk), ossl_check_OSSL_ATTRIBUTE_MAPPING_compfunc_type(cmp))) + + +# define OSSL_AAA_ATTRIBUTE_TYPE 0 +# define OSSL_AAA_ATTRIBUTE_VALUES 1 + +typedef struct ALLOWED_ATTRIBUTES_CHOICE_st { + int type; + union { + ASN1_OBJECT *attributeType; + X509_ATTRIBUTE *attributeTypeandValues; + } choice; +} OSSL_ALLOWED_ATTRIBUTES_CHOICE; + +typedef struct ALLOWED_ATTRIBUTES_ITEM_st { + STACK_OF(OSSL_ALLOWED_ATTRIBUTES_CHOICE) *attributes; + GENERAL_NAME *holderDomain; +} OSSL_ALLOWED_ATTRIBUTES_ITEM; + +typedef STACK_OF(OSSL_ALLOWED_ATTRIBUTES_ITEM) OSSL_ALLOWED_ATTRIBUTES_SYNTAX; + +DECLARE_ASN1_FUNCTIONS(OSSL_ALLOWED_ATTRIBUTES_CHOICE) +DECLARE_ASN1_FUNCTIONS(OSSL_ALLOWED_ATTRIBUTES_ITEM) +DECLARE_ASN1_FUNCTIONS(OSSL_ALLOWED_ATTRIBUTES_SYNTAX) + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_ALLOWED_ATTRIBUTES_CHOICE, OSSL_ALLOWED_ATTRIBUTES_CHOICE, OSSL_ALLOWED_ATTRIBUTES_CHOICE) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_value(sk, idx) ((OSSL_ALLOWED_ATTRIBUTES_CHOICE *)OPENSSL_sk_value(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), (idx))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_new(cmp) ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_CHOICE) *)OPENSSL_sk_new(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_compfunc_type(cmp))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_new_null() ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_CHOICE) *)OPENSSL_sk_new_null()) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_new_reserve(cmp, n) ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_CHOICE) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_compfunc_type(cmp), (n))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), (n)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_free(sk) OPENSSL_sk_free(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_delete(sk, i) ((OSSL_ALLOWED_ATTRIBUTES_CHOICE *)OPENSSL_sk_delete(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), (i))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_delete_ptr(sk, ptr) ((OSSL_ALLOWED_ATTRIBUTES_CHOICE *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_type(ptr))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_type(ptr)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_type(ptr)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_pop(sk) ((OSSL_ALLOWED_ATTRIBUTES_CHOICE *)OPENSSL_sk_pop(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_shift(sk) ((OSSL_ALLOWED_ATTRIBUTES_CHOICE *)OPENSSL_sk_shift(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk),ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_freefunc_type(freefunc)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_type(ptr), (idx)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_set(sk, idx, ptr) ((OSSL_ALLOWED_ATTRIBUTES_CHOICE *)OPENSSL_sk_set(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), (idx), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_type(ptr))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_type(ptr)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_type(ptr)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_type(ptr), pnum) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_dup(sk) ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_CHOICE) *)OPENSSL_sk_dup(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_CHOICE) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_copyfunc_type(copyfunc), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_freefunc_type(freefunc))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_set_cmp_func(sk, cmp) ((sk_OSSL_ALLOWED_ATTRIBUTES_CHOICE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_CHOICE_compfunc_type(cmp))) + + +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_ALLOWED_ATTRIBUTES_ITEM, OSSL_ALLOWED_ATTRIBUTES_ITEM, OSSL_ALLOWED_ATTRIBUTES_ITEM) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_value(sk, idx) ((OSSL_ALLOWED_ATTRIBUTES_ITEM *)OPENSSL_sk_value(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), (idx))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_new(cmp) ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_ITEM) *)OPENSSL_sk_new(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_compfunc_type(cmp))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_new_null() ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_ITEM) *)OPENSSL_sk_new_null()) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_new_reserve(cmp, n) ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_ITEM) *)OPENSSL_sk_new_reserve(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_compfunc_type(cmp), (n))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), (n)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_free(sk) OPENSSL_sk_free(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_delete(sk, i) ((OSSL_ALLOWED_ATTRIBUTES_ITEM *)OPENSSL_sk_delete(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), (i))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_delete_ptr(sk, ptr) ((OSSL_ALLOWED_ATTRIBUTES_ITEM *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_type(ptr))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_type(ptr)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_type(ptr)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_pop(sk) ((OSSL_ALLOWED_ATTRIBUTES_ITEM *)OPENSSL_sk_pop(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_shift(sk) ((OSSL_ALLOWED_ATTRIBUTES_ITEM *)OPENSSL_sk_shift(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk),ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_freefunc_type(freefunc)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_type(ptr), (idx)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_set(sk, idx, ptr) ((OSSL_ALLOWED_ATTRIBUTES_ITEM *)OPENSSL_sk_set(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), (idx), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_type(ptr))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_find(sk, ptr) OPENSSL_sk_find(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_type(ptr)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_type(ptr)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_type(ptr), pnum) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk)) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_dup(sk) ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_ITEM) *)OPENSSL_sk_dup(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(OSSL_ALLOWED_ATTRIBUTES_ITEM) *)OPENSSL_sk_deep_copy(ossl_check_const_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_copyfunc_type(copyfunc), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_freefunc_type(freefunc))) +#define sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_set_cmp_func(sk, cmp) ((sk_OSSL_ALLOWED_ATTRIBUTES_ITEM_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_sk_type(sk), ossl_check_OSSL_ALLOWED_ATTRIBUTES_ITEM_compfunc_type(cmp))) + + +typedef struct AA_DIST_POINT_st { + DIST_POINT_NAME *distpoint; + ASN1_BIT_STRING *reasons; + int dp_reasons; + ASN1_BOOLEAN indirectCRL; + ASN1_BOOLEAN containsUserAttributeCerts; + ASN1_BOOLEAN containsAACerts; + ASN1_BOOLEAN containsSOAPublicKeyCerts; +} OSSL_AA_DIST_POINT; + +DECLARE_ASN1_FUNCTIONS(OSSL_AA_DIST_POINT) + +# ifdef __cplusplus +} +# endif +#endif diff --git a/illumos-x86_64/usr/include/openssl-3/x509v3err.h b/illumos-x86_64/usr/include/openssl-3/x509v3err.h new file mode 100644 index 00000000..4bbcfc23 --- /dev/null +++ b/illumos-x86_64/usr/include/openssl-3/x509v3err.h @@ -0,0 +1,97 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_X509V3ERR_H +# define OPENSSL_X509V3ERR_H +# pragma once + +# include +# include +# include + + + +/* + * X509V3 reason codes. + */ +# define X509V3_R_BAD_IP_ADDRESS 118 +# define X509V3_R_BAD_OBJECT 119 +# define X509V3_R_BAD_OPTION 170 +# define X509V3_R_BAD_VALUE 171 +# define X509V3_R_BN_DEC2BN_ERROR 100 +# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 +# define X509V3_R_DIRNAME_ERROR 149 +# define X509V3_R_DISTPOINT_ALREADY_SET 160 +# define X509V3_R_DUPLICATE_ZONE_ID 133 +# define X509V3_R_EMPTY_KEY_USAGE 169 +# define X509V3_R_ERROR_CONVERTING_ZONE 131 +# define X509V3_R_ERROR_CREATING_EXTENSION 144 +# define X509V3_R_ERROR_IN_EXTENSION 128 +# define X509V3_R_EXPECTED_A_SECTION_NAME 137 +# define X509V3_R_EXTENSION_EXISTS 145 +# define X509V3_R_EXTENSION_NAME_ERROR 115 +# define X509V3_R_EXTENSION_NOT_FOUND 102 +# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 +# define X509V3_R_EXTENSION_VALUE_ERROR 116 +# define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 +# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 +# define X509V3_R_INVALID_ASNUMBER 162 +# define X509V3_R_INVALID_ASRANGE 163 +# define X509V3_R_INVALID_BOOLEAN_STRING 104 +# define X509V3_R_INVALID_CERTIFICATE 158 +# define X509V3_R_INVALID_EMPTY_NAME 108 +# define X509V3_R_INVALID_EXTENSION_STRING 105 +# define X509V3_R_INVALID_INHERITANCE 165 +# define X509V3_R_INVALID_IPADDRESS 166 +# define X509V3_R_INVALID_MULTIPLE_RDNS 161 +# define X509V3_R_INVALID_NAME 106 +# define X509V3_R_INVALID_NULL_ARGUMENT 107 +# define X509V3_R_INVALID_NULL_VALUE 109 +# define X509V3_R_INVALID_NUMBER 140 +# define X509V3_R_INVALID_NUMBERS 141 +# define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 +# define X509V3_R_INVALID_OPTION 138 +# define X509V3_R_INVALID_POLICY_IDENTIFIER 134 +# define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 +# define X509V3_R_INVALID_PURPOSE 146 +# define X509V3_R_INVALID_SAFI 164 +# define X509V3_R_INVALID_SECTION 135 +# define X509V3_R_INVALID_SYNTAX 143 +# define X509V3_R_ISSUER_DECODE_ERROR 126 +# define X509V3_R_MISSING_VALUE 124 +# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 +# define X509V3_R_NEGATIVE_PATHLEN 168 +# define X509V3_R_NO_CONFIG_DATABASE 136 +# define X509V3_R_NO_ISSUER_CERTIFICATE 121 +# define X509V3_R_NO_ISSUER_DETAILS 127 +# define X509V3_R_NO_POLICY_IDENTIFIER 139 +# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 +# define X509V3_R_NO_PUBLIC_KEY 114 +# define X509V3_R_NO_SUBJECT_DETAILS 125 +# define X509V3_R_OPERATION_NOT_DEFINED 148 +# define X509V3_R_OTHERNAME_ERROR 147 +# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 155 +# define X509V3_R_POLICY_PATH_LENGTH 156 +# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 157 +# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 +# define X509V3_R_PURPOSE_NOT_UNIQUE 173 +# define X509V3_R_SECTION_NOT_FOUND 150 +# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 +# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 +# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 +# define X509V3_R_UNKNOWN_EXTENSION 129 +# define X509V3_R_UNKNOWN_EXTENSION_NAME 130 +# define X509V3_R_UNKNOWN_OPTION 120 +# define X509V3_R_UNKNOWN_VALUE 172 +# define X509V3_R_UNSUPPORTED_OPTION 117 +# define X509V3_R_UNSUPPORTED_TYPE 167 +# define X509V3_R_USER_TOO_LONG 132 + +#endif diff --git a/illumos-x86_64/usr/include/panel.h b/illumos-x86_64/usr/include/panel.h new file mode 100644 index 00000000..dd213d2e --- /dev/null +++ b/illumos-x86_64/usr/include/panel.h @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _PANEL_H +#define _PANEL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _obscured_list + { + struct PANEL *panel_p; + int start, end; + struct _obscured_list *next; + } _obscured_list; + +typedef struct PANEL + { + WINDOW *win; + int wstarty; + int wendy; + int wstartx; + int wendx; + struct _obscured_list *obscured; + struct PANEL *below, *above; + char *user; + } PANEL; + +#ifdef __STDC__ + +extern PANEL *new_panel(WINDOW *); +extern int del_panel(PANEL *); +extern int hide_panel(PANEL *); +extern int show_panel(PANEL *); +extern int panel_hidden(PANEL *); +extern int move_panel(PANEL *, int, int); +extern int replace_panel(PANEL *, WINDOW *); +extern int top_panel(PANEL *); +extern int bottom_panel(PANEL *); +extern void update_panels(void); +extern WINDOW *panel_window(PANEL *); +extern int set_panel_userptr(PANEL *, char *); +extern char *panel_userptr(PANEL *); +extern PANEL *panel_above(PANEL *); +extern PANEL *panel_below(PANEL *); + +#else /* old style extern's */ + +extern PANEL *new_panel(); +extern int del_panel(); +extern int hide_panel(); +extern int show_panel(); +extern int panel_hidden(); +extern int move_panel(); +extern int replace_panel(); +extern int top_panel(); +extern int bottom_panel(); +extern void update_panels(); +extern WINDOW *panel_window(); +extern int set_panel_userptr(); +extern char *panel_userptr(); +extern PANEL *panel_above(); +extern PANEL *panel_below(); + +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PANEL_H */ diff --git a/illumos-x86_64/usr/include/paths.h b/illumos-x86_64/usr/include/paths.h new file mode 100644 index 00000000..91a0642d --- /dev/null +++ b/illumos-x86_64/usr/include/paths.h @@ -0,0 +1,77 @@ +/* $NetBSD: paths.h,v 1.39 2010/12/29 15:53:57 pooka Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)paths.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PATHS_H +#define _PATHS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define _PATH_DEFPATH "/usr/ccs/bin:/usr/bin:/bin" +#define _PATH_STDPATH _PATH_DEFPATH ":/usr/sbin:/sbin" + +#define _PATH_BPF "/dev/bpf" +#define _PATH_BSHELL "/usr/bin/sh" +#define _PATH_CONSOLE "/dev/console" +#define _PATH_CSHELL "/usr/bin/csh" +#define _PATH_DEVNULL "/dev/null" +#define _PATH_FTPUSERS "/etc/ftpusers" +#define _PATH_KMEM "/dev/kmem" +#define _PATH_LOCALE "/usr/share/locale" +#define _PATH_MAILDIR "/var/mail" +#define _PATH_MAN "/usr/share/man" +#define _PATH_MEM "/dev/mem" +#define _PATH_NOLOGIN "/etc/nologin" +#define _PATH_RANDOM "/dev/random" +#define _PATH_SENDMAIL "/usr/sbin/sendmail" +#define _PATH_SHELLS "/etc/shells" +#define _PATH_TTY "/dev/tty" +#define _PATH_URANDOM "/dev/urandom" +#define _PATH_VI "/usr/bin/vi" + +/* + * Provide trailing slash, since mostly used for building pathnames. + */ +#define _PATH_DEV "/dev/" +#define _PATH_DEV_PTS "/dev/pts/" +#define _PATH_TMP "/tmp/" +#define _PATH_VARDB "/var/db/" +#define _PATH_VARRUN "/var/run/" +#define _PATH_VARTMP "/var/tmp/" + + +#ifdef __cplusplus +} +#endif +#endif /* !_PATHS_H */ diff --git a/illumos-x86_64/usr/include/pcap-bpf.h b/illumos-x86_64/usr/include/pcap-bpf.h new file mode 100644 index 00000000..ebb64c3f --- /dev/null +++ b/illumos-x86_64/usr/include/pcap-bpf.h @@ -0,0 +1,45 @@ +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * For backwards compatibility. + * + * Note to OS vendors: do NOT get rid of this file! Some applications + * might expect to be able to include . + */ +#include diff --git a/illumos-x86_64/usr/include/pcap-namedb.h b/illumos-x86_64/usr/include/pcap-namedb.h new file mode 100644 index 00000000..d5908c92 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap-namedb.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 1994, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * For backwards compatibility. + * + * Note to OS vendors: do NOT get rid of this file! Some applications + * might expect to be able to include . + */ +#include diff --git a/illumos-x86_64/usr/include/pcap.h b/illumos-x86_64/usr/include/pcap.h new file mode 100644 index 00000000..174e32d2 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * For backwards compatibility. + * + * Note to OS vendors: do NOT get rid of this file! Many applications + * expect to be able to include , and at least some of them + * go through contortions in their configure scripts to try to detect + * OSes that have "helpfully" moved pcap.h to without + * leaving behind a file. + */ +#include diff --git a/illumos-x86_64/usr/include/pcap/bluetooth.h b/illumos-x86_64/usr/include/pcap/bluetooth.h new file mode 100644 index 00000000..15dc5a82 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/bluetooth.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2006 Paolo Abeni (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * bluetooth data struct + * By Paolo Abeni + */ + +#ifndef lib_pcap_bluetooth_h +#define lib_pcap_bluetooth_h + +#include + +/* + * Header prepended libpcap to each bluetooth h4 frame, + * fields are in network byte order + */ +typedef struct _pcap_bluetooth_h4_header { + uint32_t direction; /* if first bit is set direction is incoming */ +} pcap_bluetooth_h4_header; + +/* + * Header prepended libpcap to each bluetooth linux monitor frame, + * fields are in network byte order + */ +typedef struct _pcap_bluetooth_linux_monitor_header { + uint16_t adapter_id; + uint16_t opcode; +} pcap_bluetooth_linux_monitor_header; + +#endif diff --git a/illumos-x86_64/usr/include/pcap/bpf.h b/illumos-x86_64/usr/include/pcap/bpf.h new file mode 100644 index 00000000..3970d0a1 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/bpf.h @@ -0,0 +1,291 @@ +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bpf.h 7.1 (Berkeley) 5/7/91 + */ + +/* + * This is libpcap's cut-down version of bpf.h; it includes only + * the stuff needed for the code generator and the userland BPF + * interpreter, and the libpcap APIs for setting filters, etc.. + * + * "pcap-bpf.c" will include the native OS version, as it deals with + * the OS's BPF implementation. + * + * At least two programs found by Google Code Search explicitly includes + * (even though / includes it for you), + * so moving that stuff to would break the build for some + * programs. + */ + +/* + * If we've already included , don't re-define this stuff. + * We assume BSD-style multiple-include protection in , + * which is true of all but the oldest versions of FreeBSD and NetBSD, + * or Tru64 UNIX-style multiple-include protection (or, at least, + * Tru64 UNIX 5.x-style; I don't have earlier versions available to check), + * or AIX-style multiple-include protection (or, at least, AIX 5.x-style; + * I don't have earlier versions available to check), or QNX-style + * multiple-include protection (as per GitHub pull request #394). + * + * We trust that they will define structures and macros and types in + * a fashion that's source-compatible and binary-compatible with our + * definitions. + * + * We do not check for BPF_MAJOR_VERSION, as that's defined by + * , which is directly or indirectly included in some + * programs that also include pcap.h, and doesn't + * define stuff we need. We *do* protect against + * defining various macros for BPF code itself; says + * + * Try and keep these values and structures similar to BSD, especially + * the BPF code definitions which need to match so you can share filters + * + * so we trust that it will define them in a fashion that's source-compatible + * and binary-compatible with our definitions. + * + * This also provides our own multiple-include protection. + */ +#if !defined(_NET_BPF_H_) && !defined(_NET_BPF_H_INCLUDED) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h) +#define lib_pcap_bpf_h + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* BSD style release date */ +#define BPF_RELEASE 199606 + +#ifdef MSDOS /* must be 32-bit */ +typedef long bpf_int32; +typedef unsigned long bpf_u_int32; +#else +typedef int bpf_int32; +typedef u_int bpf_u_int32; +#endif + +/* + * Alignment macros. BPF_WORDALIGN rounds up to the next + * even multiple of BPF_ALIGNMENT. + * + * Tcpdump's print-pflog.c uses this, so we define it here. + */ +#ifndef __NetBSD__ +#define BPF_ALIGNMENT sizeof(bpf_int32) +#else +#define BPF_ALIGNMENT sizeof(long) +#endif +#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) + +/* + * Structure for "pcap_compile()", "pcap_setfilter()", etc.. + */ +struct bpf_program { + u_int bf_len; + struct bpf_insn *bf_insns; +}; + +/* + * The instruction encodings. + * + * Please inform tcpdump-workers@lists.tcpdump.org if you use any + * of the reserved values, so that we can note that they're used + * (and perhaps implement it in the reference BPF implementation + * and encourage its implementation elsewhere). + */ + +/* + * The upper 8 bits of the opcode aren't used. BSD/OS used 0x8000. + */ + +/* instruction classes */ +#define BPF_CLASS(code) ((code) & 0x07) +#define BPF_LD 0x00 +#define BPF_LDX 0x01 +#define BPF_ST 0x02 +#define BPF_STX 0x03 +#define BPF_ALU 0x04 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_MISC 0x07 + +/* ld/ldx fields */ +#define BPF_SIZE(code) ((code) & 0x18) +#define BPF_W 0x00 +#define BPF_H 0x08 +#define BPF_B 0x10 +/* 0x18 reserved; used by BSD/OS */ +#define BPF_MODE(code) ((code) & 0xe0) +#define BPF_IMM 0x00 +#define BPF_ABS 0x20 +#define BPF_IND 0x40 +#define BPF_MEM 0x60 +#define BPF_LEN 0x80 +#define BPF_MSH 0xa0 +/* 0xc0 reserved; used by BSD/OS */ +/* 0xe0 reserved; used by BSD/OS */ + +/* alu/jmp fields */ +#define BPF_OP(code) ((code) & 0xf0) +#define BPF_ADD 0x00 +#define BPF_SUB 0x10 +#define BPF_MUL 0x20 +#define BPF_DIV 0x30 +#define BPF_OR 0x40 +#define BPF_AND 0x50 +#define BPF_LSH 0x60 +#define BPF_RSH 0x70 +#define BPF_NEG 0x80 +#define BPF_MOD 0x90 +#define BPF_XOR 0xa0 +/* 0xb0 reserved */ +/* 0xc0 reserved */ +/* 0xd0 reserved */ +/* 0xe0 reserved */ +/* 0xf0 reserved */ + +#define BPF_JA 0x00 +#define BPF_JEQ 0x10 +#define BPF_JGT 0x20 +#define BPF_JGE 0x30 +#define BPF_JSET 0x40 +/* 0x50 reserved; used on BSD/OS */ +/* 0x60 reserved */ +/* 0x70 reserved */ +/* 0x80 reserved */ +/* 0x90 reserved */ +/* 0xa0 reserved */ +/* 0xb0 reserved */ +/* 0xc0 reserved */ +/* 0xd0 reserved */ +/* 0xe0 reserved */ +/* 0xf0 reserved */ +#define BPF_SRC(code) ((code) & 0x08) +#define BPF_K 0x00 +#define BPF_X 0x08 + +/* ret - BPF_K and BPF_X also apply */ +#define BPF_RVAL(code) ((code) & 0x18) +#define BPF_A 0x10 +/* 0x18 reserved */ + +/* misc */ +#define BPF_MISCOP(code) ((code) & 0xf8) +#define BPF_TAX 0x00 +/* 0x08 reserved */ +/* 0x10 reserved */ +/* 0x18 reserved */ +/* #define BPF_COP 0x20 NetBSD "coprocessor" extensions */ +/* 0x28 reserved */ +/* 0x30 reserved */ +/* 0x38 reserved */ +/* #define BPF_COPX 0x40 NetBSD "coprocessor" extensions */ +/* also used on BSD/OS */ +/* 0x48 reserved */ +/* 0x50 reserved */ +/* 0x58 reserved */ +/* 0x60 reserved */ +/* 0x68 reserved */ +/* 0x70 reserved */ +/* 0x78 reserved */ +#define BPF_TXA 0x80 +/* 0x88 reserved */ +/* 0x90 reserved */ +/* 0x98 reserved */ +/* 0xa0 reserved */ +/* 0xa8 reserved */ +/* 0xb0 reserved */ +/* 0xb8 reserved */ +/* 0xc0 reserved; used on BSD/OS */ +/* 0xc8 reserved */ +/* 0xd0 reserved */ +/* 0xd8 reserved */ +/* 0xe0 reserved */ +/* 0xe8 reserved */ +/* 0xf0 reserved */ +/* 0xf8 reserved */ + +/* + * The instruction data structure. + */ +struct bpf_insn { + u_short code; + u_char jt; + u_char jf; + bpf_u_int32 k; +}; + +/* + * Macros for insn array initializers. + * + * In case somebody's included , or something else that + * gives the kernel's definitions of BPF statements, get rid of its + * definitions, so we can supply ours instead. If some kernel's + * definitions aren't *binary-compatible* with what BPF has had + * since it first sprung from the brows of Van Jacobson and Steve + * McCanne, that kernel should be fixed. + */ +#ifdef BPF_STMT +#undef BPF_STMT +#endif +#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k } +#ifdef BPF_JUMP +#undef BPF_JUMP +#endif +#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } + +PCAP_AVAILABLE_0_4 +PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int); + +PCAP_AVAILABLE_0_6 +PCAP_API int bpf_validate(const struct bpf_insn *f, int len); + +PCAP_AVAILABLE_0_4 +PCAP_API char *bpf_image(const struct bpf_insn *, int); + +PCAP_AVAILABLE_0_6 +PCAP_API void bpf_dump(const struct bpf_program *, int); + +/* + * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). + */ +#define BPF_MEMWORDS 16 + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(_NET_BPF_H_) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h) */ diff --git a/illumos-x86_64/usr/include/pcap/can_socketcan.h b/illumos-x86_64/usr/include/pcap/can_socketcan.h new file mode 100644 index 00000000..662bfe22 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/can_socketcan.h @@ -0,0 +1,82 @@ +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lib_pcap_can_socketcan_h +#define lib_pcap_can_socketcan_h + +#include + +/* + * SocketCAN header for CAN and CAN FD frames, as per + * Documentation/networking/can.rst in the Linux source. + */ +typedef struct { + uint32_t can_id; + uint8_t payload_length; + uint8_t fd_flags; + uint8_t reserved1; + uint8_t reserved2; +} pcap_can_socketcan_hdr; + +/* Bits in the fd_flags field */ +#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */ +#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */ +#define CANFD_FDF 0x04 /* mark CAN FD for dual use of CAN format */ + +/* + * SocketCAN header for CAN XL frames, as per Linux's can.h header. + * This is different from pcap_can_socketcan_hdr; the flags field + * overlaps with the payload_length field in pcap_can_socketcan_hdr - + * the payload_length field in a CAN or CAN FD frame never has the + * 0x80 bit set, and the flags field in a CAN XL frame always has + * it set, allowing code reading the frame to determine whether + * it's CAN XL or not. + */ +typedef struct { + uint32_t priority_vcid; + uint8_t flags; + uint8_t sdu_type; + uint16_t payload_length; + uint32_t acceptance_field; +} pcap_can_socketcan_xl_hdr; + +/* Bits in the flags field */ +#define CANXL_SEC 0x01 /* Simple Extended Context */ +#define CANXL_XLF 0x80 /* mark to distinguish CAN XL from CAN/CAN FD frames */ + +#endif diff --git a/illumos-x86_64/usr/include/pcap/compiler-tests.h b/illumos-x86_64/usr/include/pcap/compiler-tests.h new file mode 100644 index 00000000..2d98a707 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/compiler-tests.h @@ -0,0 +1,189 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lib_pcap_compiler_tests_h +#define lib_pcap_compiler_tests_h + +/* + * This was introduced by Clang: + * + * https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute + * + * in some version (which version?); it has been picked up by GCC 5.0. + */ +#ifndef __has_attribute + /* + * It's a macro, so you can check whether it's defined to check + * whether it's supported. + * + * If it's not, define it to always return 0, so that we move on to + * the fallback checks. + */ + #define __has_attribute(x) 0 +#endif + +/* + * Note that the C90 spec's "6.8.1 Conditional inclusion" and the + * C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say: + * + * Prior to evaluation, macro invocations in the list of preprocessing + * tokens that will become the controlling constant expression are + * replaced (except for those macro names modified by the defined unary + * operator), just as in normal text. If the token "defined" is + * generated as a result of this replacement process or use of the + * "defined" unary operator does not match one of the two specified + * forms prior to macro replacement, the behavior is undefined. + * + * so you shouldn't use defined() in a #define that's used in #if or + * #elif. Some versions of Clang, for example, will warn about this. + * + * Instead, we check whether the pre-defined macros for particular + * compilers are defined and, if not, define the "is this version XXX + * or a later version of this compiler" macros as 0. + */ + +/* + * Check whether this is GCC major.minor or a later release, or some + * compiler that claims to be "just like GCC" of that version or a + * later release. + */ + +#if ! defined(__GNUC__) + /* Not GCC and not "just like GCC" */ + #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0 +#else + /* GCC or "just like GCC" */ + #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \ + (__GNUC__ > (major) || \ + (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) +#endif + +/* + * Check whether this is Clang major.minor or a later release. + */ + +#if !defined(__clang__) + /* Not Clang */ + #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0 +#else + /* Clang */ + #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \ + (__clang_major__ > (major) || \ + (__clang_major__ == (major) && __clang_minor__ >= (minor))) +#endif + +/* + * Check whether this is Sun C/SunPro C/Oracle Studio major.minor + * or a later release. + * + * The version number in __SUNPRO_C is encoded in hex BCD, with the + * uppermost hex digit being the major version number, the next + * one or two hex digits being the minor version number, and + * the last digit being the patch version. + * + * It represents the *compiler* version, not the product version; + * see + * + * https://sourceforge.net/p/predef/wiki/Compilers/ + * + * for a partial mapping, which we assume continues for later + * 12.x product releases. + */ + +#if ! defined(__SUNPRO_C) + /* Not Sun/Oracle C */ + #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0 +#else + /* Sun/Oracle C */ + #define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \ + (((minor) >= 10) ? \ + (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \ + (((major) << 8) | ((minor) << 4))) + #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \ + (__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor))) +#endif + +/* + * Check whether this is IBM XL C major.minor or a later release. + * + * The version number in __xlC__ has the major version in the + * upper 8 bits and the minor version in the lower 8 bits. + * On AIX __xlC__ is always defined, __ibmxl__ becomes defined in XL C 16.1. + * On Linux since XL C 13.1.6 __xlC__ is not defined by default anymore, but + * __ibmxl__ is defined since at least XL C 13.1.1. + */ + +#if ! defined(__xlC__) && ! defined(__ibmxl__) + /* Not XL C */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 +#else + /* XL C */ + #if defined(__ibmxl__) + /* + * Later Linux version of XL C; use __ibmxl_version__ to test + * the version. + */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + (__ibmxl_version__ > (major) || \ + (__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor))) + #else /* __ibmxl__ */ + /* + * __ibmxl__ not defined; use __xlC__ to test the version. + */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + (__xlC__ >= (((major) << 8) | (minor))) + #endif /* __ibmxl__ */ +#endif + +/* + * Check whether this is HP aC++/HP C major.minor or a later release. + * + * The version number in __HP_aCC is encoded in zero-padded decimal BCD, + * with the "A." stripped off, the uppermost two decimal digits being + * the major version number, the next two decimal digits being the minor + * version number, and the last two decimal digits being the patch version. + * (Strip off the A., remove the . between the major and minor version + * number, and add two digits of patch.) + */ + +#if ! defined(__HP_aCC) + /* Not HP C */ + #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0 +#else + /* HP C */ + #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \ + (__HP_aCC >= ((major)*10000 + (minor)*100)) +#endif + +#endif /* lib_pcap_compiler_tests_h */ diff --git a/illumos-x86_64/usr/include/pcap/dlt.h b/illumos-x86_64/usr/include/pcap/dlt.h new file mode 100644 index 00000000..7f5f5aa4 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/dlt.h @@ -0,0 +1,1593 @@ +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bpf.h 7.1 (Berkeley) 5/7/91 + */ + +#ifndef lib_pcap_dlt_h +#define lib_pcap_dlt_h + +/* + * Link-layer header type codes. + * + * Do *NOT* add new values to this list without asking + * "tcpdump-workers@lists.tcpdump.org" for a value. Otherwise, you run + * the risk of using a value that's already being used for some other + * purpose, and of having tools that read libpcap-format captures not + * being able to handle captures with your new DLT_ value, with no hope + * that they will ever be changed to do so (as that would destroy their + * ability to read captures using that value for that other purpose). + * + * See + * + * https://www.tcpdump.org/linktypes.html + * + * for detailed descriptions of some of these link-layer header types. + */ + +/* + * These are the types that are the same on all platforms, and that + * have been defined by for ages. + * + * DLT_LOW_MATCHING_MIN is the lowest such value; DLT_LOW_MATCHING_MAX + * is the highest such value. + */ +#define DLT_LOW_MATCHING_MIN 0 + +#define DLT_NULL 0 /* BSD loopback encapsulation */ +#define DLT_EN10MB 1 /* Ethernet (10Mb) */ +#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */ +#define DLT_AX25 3 /* Amateur Radio AX.25 */ +#define DLT_PRONET 4 /* Proteon ProNET Token Ring */ +#define DLT_CHAOS 5 /* Chaos */ +#define DLT_IEEE802 6 /* 802.5 Token Ring */ +#define DLT_ARCNET 7 /* ARCNET, with BSD-style header */ +#define DLT_SLIP 8 /* Serial Line IP */ +#define DLT_PPP 9 /* Point-to-point Protocol */ +#define DLT_FDDI 10 /* FDDI */ + +/* + * In case the code that includes this file (directly or indirectly) + * has also included OS files that happen to define DLT_LOW_MATCHING_MAX, + * with a different value (perhaps because that OS hasn't picked up + * the latest version of our DLT definitions), we undefine the + * previous value of DLT_LOW_MATCHING_MAX. + * + * (They shouldn't, because only those 10 values were assigned in + * the Good Old Days, before DLT_ code assignment became a bit of + * a free-for-all. Perhaps 11 is DLT_ATM_RFC1483 everywhere 11 + * is used at all, but 12 is DLT_RAW on some platforms but not + * OpenBSD, and the fun continues for several other values.) + */ +#ifdef DLT_LOW_MATCHING_MAX +#undef DLT_LOW_MATCHING_MAX +#endif + +#define DLT_LOW_MATCHING_MAX DLT_FDDI /* highest value in this "matching" range */ + +/* + * These are types that are different on some platforms, and that + * have been defined by for ages. We use #ifdefs to + * detect the BSDs that define them differently from the traditional + * libpcap + * + * XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS, + * but I don't know what the right #define is for BSD/OS. The last + * release was in October 2003; if anybody cares about making this + * work on BSD/OS, give us a pull request for a change to make it work. + */ +#define DLT_ATM_RFC1483 11 /* LLC-encapsulated ATM */ + +#ifdef __OpenBSD__ +#define DLT_RAW 14 /* raw IP */ +#else +#define DLT_RAW 12 /* raw IP */ +#endif + +/* + * Given that the only OS that currently generates BSD/OS SLIP or PPP + * is, well, BSD/OS, arguably everybody should have chosen its values + * for DLT_SLIP_BSDOS and DLT_PPP_BSDOS, which are 15 and 16, but they + * didn't. So it goes. + */ +#if defined(__NetBSD__) || defined(__FreeBSD__) +#ifndef DLT_SLIP_BSDOS +#define DLT_SLIP_BSDOS 13 /* BSD/OS Serial Line IP */ +#define DLT_PPP_BSDOS 14 /* BSD/OS Point-to-point Protocol */ +#endif +#else +#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */ +#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */ +#endif + +/* + * NetBSD uses 15 for HIPPI. + * + * From a quick look at sys/net/if_hippi.h and sys/net/if_hippisubr.c + * in an older version of NetBSD , the header appears to be: + * + * a 1-byte ULP field (ULP-id)? + * + * a 1-byte flags field; + * + * a 2-byte "offsets" field; + * + * a 4-byte "D2 length" field (D2_Size?); + * + * a 4-byte "destination switch" field (or a 1-byte field + * containing the Forwarding Class, Double_Wide, and Message_Type + * sub fields, followed by a 3-byte Destination_Switch_Address + * field?, HIPPI-LE 3.4-style?); + * + * a 4-byte "source switch" field (or a 1-byte field containing the + * Destination_Address_type and Source_Address_Type fields, followed + * by a 3-byte Source_Switch_Address field, HIPPI-LE 3.4-style?); + * + * a 2-byte reserved field; + * + * a 6-byte destination address field; + * + * a 2-byte "local admin" field; + * + * a 6-byte source address field; + * + * followed by an 802.2 LLC header. + * + * This looks somewhat like something derived from the HIPPI-FP 4.4 + * Header_Area, followed an HIPPI-FP 4.4 D1_Area containing a D1 data set + * with the header in HIPPI-LE 3.4 (ANSI X3.218-1993), followed by an + * HIPPI-FP 4.4 D2_Area (with no Offset) containing the 802.2 LLC header + * and payload? Or does the "offsets" field contain the D2_Offset, + * with that many bytes of offset before the payload? + * + * See http://wotug.org/parallel/standards/hippi/ for an archive of + * HIPPI specifications. + * + * RFC 2067 imposes some additional restrictions. It says that the + * Offset is always zero + * + * HIPPI is long-gone, and the source files found in an older version + * of NetBSD don't appear to be in the main CVS branch, so we may never + * see a capture with this link-layer type. + */ +#if defined(__NetBSD__) +#define DLT_HIPPI 15 /* HIPPI */ +#endif + +/* + * NetBSD uses 16 for DLT_HDLC; see below. + * BSD/OS uses it for PPP; see above. + * As far as I know, no other OS uses it for anything; don't use it + * for anything else. + */ + +/* + * 17 was used for DLT_PFLOG in OpenBSD; it no longer is. + * + * It was DLT_LANE8023 in SuSE 6.3, so we defined LINKTYPE_PFLOG + * as 117 so that pflog captures would use a link-layer header type + * value that didn't collide with any other values. On all + * platforms other than OpenBSD, we defined DLT_PFLOG as 117, + * and we mapped between LINKTYPE_PFLOG and DLT_PFLOG. + * + * OpenBSD eventually switched to using 117 for DLT_PFLOG as well. + * + * Don't use 17 for anything else. + */ + +/* + * 18 is used for DLT_PFSYNC in OpenBSD, NetBSD, DragonFly BSD and + * macOS; don't use it for anything else. (FreeBSD uses 121, which + * collides with DLT_HHDLC, even though it doesn't use 18 for + * anything and doesn't appear to have ever used it for anything.) + * + * We define it as 18 on those platforms; it is, unfortunately, used + * for DLT_CIP in SUSE 6.3, so we don't define it as 18 on all + * platforms. We define it as 121 on FreeBSD and as the same + * value that we assigned to LINKTYPE_PFSYNC on all remaining + * platforms. + */ +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__) +#define DLT_PFSYNC 18 +#endif + +#define DLT_ATM_CLIP 19 /* Linux Classical IP over ATM */ + +/* + * Apparently Redback uses this for its SmartEdge 400/800. I hope + * nobody else decided to use it, too. + */ +#define DLT_REDBACK_SMARTEDGE 32 + +/* + * These values are defined by NetBSD; other platforms should refrain from + * using them for other purposes, so that NetBSD savefiles with link + * types of 50 or 51 can be read as this type on all platforms. + */ +#define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */ +#define DLT_PPP_ETHER 51 /* PPP over Ethernet */ + +/* + * The Axent Raptor firewall - now the Symantec Enterprise Firewall - uses + * a link-layer type of 99 for the tcpdump it supplies. The link-layer + * header has 6 bytes of unknown data, something that appears to be an + * Ethernet type, and 36 bytes that appear to be 0 in at least one capture + * I've seen. + */ +#define DLT_SYMANTEC_FIREWALL 99 + +/* + * Values between 100 and 103 are used in capture file headers as + * link-layer header type LINKTYPE_ values corresponding to DLT_ types + * that differ between platforms; don't use those values for new DLT_ + * new types. + */ + +/* + * Values starting with 104 are used for newly-assigned link-layer + * header type values; for those link-layer header types, the DLT_ + * value returned by pcap_datalink() and passed to pcap_open_dead(), + * and the LINKTYPE_ value that appears in capture files, are the + * same. + * + * DLT_HIGH_MATCHING_MIN is the lowest such value; DLT_HIGH_MATCHING_MAX is + * the highest such value. + */ +#define DLT_HIGH_MATCHING_MIN 104 + +/* + * This value was defined by libpcap 0.5; platforms that have defined + * it with a different value should define it here with that value - + * a link type of 104 in a save file will be mapped to DLT_C_HDLC, + * whatever value that happens to be, so programs will correctly + * handle files with that link type regardless of the value of + * DLT_C_HDLC. + * + * The name DLT_C_HDLC was used by BSD/OS; we use that name for source + * compatibility with programs written for BSD/OS. + * + * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well, + * for source compatibility with programs written for libpcap 0.5. + */ +#define DLT_C_HDLC 104 /* Cisco HDLC */ +#define DLT_CHDLC DLT_C_HDLC + +#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */ + +/* + * 106 is reserved for Linux Classical IP over ATM; it's like DLT_RAW, + * except when it isn't. (I.e., sometimes it's just raw IP, and + * sometimes it isn't.) We currently handle it as DLT_LINUX_SLL, + * so that we don't have to worry about the link-layer header.) + */ + +/* + * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides + * with other values. + * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header + * (DLCI, etc.). + */ +#define DLT_FRELAY 107 + +/* + * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except + * that the AF_ type in the link-layer header is in network byte order. + * + * DLT_LOOP is 12 in OpenBSD, but that's DLT_RAW in other OSes, so + * we don't use 12 for it in OSes other than OpenBSD; instead, we + * use the same value as LINKTYPE_LOOP. + */ +#ifdef __OpenBSD__ +#define DLT_LOOP 12 +#else +#define DLT_LOOP 108 +#endif + +/* + * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's + * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other + * than OpenBSD; instead, we use the same value as LINKTYPE_ENC. + */ +#ifdef __OpenBSD__ +#define DLT_ENC 13 +#else +#define DLT_ENC 109 +#endif + +/* + * Values 110 and 111 are reserved for use in capture file headers + * as link-layer types corresponding to DLT_ types that might differ + * between platforms; don't use those values for new DLT_ types + * other than the corresponding DLT_ types. + */ + +/* + * NetBSD uses 16 for (Cisco) "HDLC framing". For other platforms, + * we define it to have the same value as LINKTYPE_NETBSD_HDLC. + */ +#if defined(__NetBSD__) +#define DLT_HDLC 16 /* Cisco HDLC */ +#else +#define DLT_HDLC 112 +#endif + +/* + * Linux cooked sockets. + */ +#define DLT_LINUX_SLL 113 + +/* + * Apple LocalTalk hardware. + */ +#define DLT_LTALK 114 + +/* + * Acorn Econet. + */ +#define DLT_ECONET 115 + +/* + * Reserved for use with OpenBSD ipfilter. + */ +#define DLT_IPFILTER 116 + +/* + * OpenBSD DLT_PFLOG. + */ +#define DLT_PFLOG 117 + +/* + * Registered for Cisco-internal use. + */ +#define DLT_CISCO_IOS 118 + +/* + * For 802.11 cards using the Prism II chips, with a link-layer + * header including Prism monitor mode information plus an 802.11 + * header. + */ +#define DLT_PRISM_HEADER 119 + +/* + * Reserved for Aironet 802.11 cards, with an Aironet link-layer header + * (see Doug Ambrisko's FreeBSD patches). + */ +#define DLT_AIRONET_HEADER 120 + +/* + * Sigh. + * + * 121 was reserved for Siemens HiPath HDLC on 2002-01-25, as + * requested by Tomas Kukosa. + * + * On 2004-02-25, a FreeBSD checkin to sys/net/bpf.h was made that + * assigned 121 as DLT_PFSYNC. In current versions, its libpcap + * does DLT_ <-> LINKTYPE_ mapping, mapping DLT_PFSYNC to a + * LINKTYPE_PFSYNC value of 246, so it should write out DLT_PFSYNC + * dump files with 246 as the link-layer header type. (Earlier + * versions might not have done mapping, in which case they would + * have written them out with a link-layer header type of 121.) + * + * OpenBSD, from which pf came, however, uses 18 for DLT_PFSYNC; + * its libpcap does no DLT_ <-> LINKTYPE_ mapping, so it would + * write out DLT_PFSYNC dump files with use 18 as the link-layer + * header type. + * + * NetBSD, DragonFly BSD, and Darwin also use 18 for DLT_PFSYNC; in + * current versions, their libpcaps do DLT_ <-> LINKTYPE_ mapping, + * mapping DLT_PFSYNC to a LINKTYPE_PFSYNC value of 246, so they + * should write out DLT_PFSYNC dump files with 246 as the link-layer + * header type. (Earlier versions might not have done mapping, + * in which case they'd work the same way OpenBSD does, writing + * them out with a link-layer header type of 18.) + * + * We'll define DLT_PFSYNC as: + * + * 18 on NetBSD, OpenBSD, DragonFly BSD, and Darwin; + * + * 121 on FreeBSD; + * + * 246 everywhere else. + * + * We'll define DLT_HHDLC as 121 on everything except for FreeBSD; + * anybody who wants to compile, on FreeBSD, code that uses DLT_HHDLC + * is out of luck. + * + * We'll define LINKTYPE_PFSYNC as 246 on *all* platforms, so that + * savefiles written using *this* code won't use 18 or 121 for PFSYNC, + * they'll all use 246. + * + * Code that uses pcap_datalink() to determine the link-layer header + * type of a savefile won't, when built and run on FreeBSD, be able + * to distinguish between LINKTYPE_PFSYNC and LINKTYPE_HHDLC capture + * files, as pcap_datalink() will give 121 for both of them. Code + * that doesn't, such as the code in Wireshark, will be able to + * distinguish between them. + * + * FreeBSD's libpcap won't map a link-layer header type of 18 - i.e., + * DLT_PFSYNC files from OpenBSD and possibly older versions of NetBSD, + * DragonFly BSD, and macOS - to DLT_PFSYNC, so code built with FreeBSD's + * libpcap won't treat those files as DLT_PFSYNC files. + * + * Other libpcaps won't map a link-layer header type of 121 to DLT_PFSYNC; + * this means they can read DLT_HHDLC files, if any exist, but won't + * treat pcap files written by any older versions of FreeBSD libpcap that + * didn't map to 246 as DLT_PFSYNC files. + */ +#ifdef __FreeBSD__ +#define DLT_PFSYNC 121 +#else +#define DLT_HHDLC 121 +#endif + +/* + * This is for RFC 2625 IP-over-Fibre Channel. + * + * This is not for use with raw Fibre Channel, where the link-layer + * header starts with a Fibre Channel frame header; it's for IP-over-FC, + * where the link-layer header starts with an RFC 2625 Network_Header + * field. + */ +#define DLT_IP_OVER_FC 122 + +/* + * This is for Full Frontal ATM on Solaris with SunATM, with a + * pseudo-header followed by an AALn PDU. + * + * There may be other forms of Full Frontal ATM on other OSes, + * with different pseudo-headers. + * + * If ATM software returns a pseudo-header with VPI/VCI information + * (and, ideally, packet type information, e.g. signalling, ILMI, + * LANE, LLC-multiplexed traffic, etc.), it should not use + * DLT_ATM_RFC1483, but should get a new DLT_ value, so tcpdump + * and the like don't have to infer the presence or absence of a + * pseudo-header and the form of the pseudo-header. + */ +#define DLT_SUNATM 123 /* Solaris+SunATM */ + +/* + * Reserved as per request from Kent Dahlgren + * for private use. + */ +#define DLT_RIO 124 /* RapidIO */ +#define DLT_PCI_EXP 125 /* PCI Express */ +#define DLT_AURORA 126 /* Xilinx Aurora link layer */ + +/* + * Header for 802.11 plus a number of bits of link-layer information + * including radio information, used by some recent BSD drivers as + * well as the madwifi Atheros driver for Linux. + */ +#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus radiotap radio header */ + +/* + * Reserved for the TZSP encapsulation, as per request from + * Chris Waters + * TZSP is a generic encapsulation for any other link type, + * which includes a means to include meta-information + * with the packet, e.g. signal strength and channel + * for 802.11 packets. + */ +#define DLT_TZSP 128 /* Tazmen Sniffer Protocol */ + +/* + * BSD's ARCNET headers have the source host, destination host, + * and type at the beginning of the packet; that's what's handed + * up to userland via BPF. + * + * Linux's ARCNET headers, however, have a 2-byte offset field + * between the host IDs and the type; that's what's handed up + * to userland via PF_PACKET sockets. + * + * We therefore have to have separate DLT_ values for them. + */ +#define DLT_ARCNET_LINUX 129 /* ARCNET */ + +/* + * Juniper-private data link types, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, etc.. + */ +#define DLT_JUNIPER_MLPPP 130 +#define DLT_JUNIPER_MLFR 131 +#define DLT_JUNIPER_ES 132 +#define DLT_JUNIPER_GGSN 133 +#define DLT_JUNIPER_MFR 134 +#define DLT_JUNIPER_ATM2 135 +#define DLT_JUNIPER_SERVICES 136 +#define DLT_JUNIPER_ATM1 137 + +/* + * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund + * . The header that's presented is an Ethernet-like + * header: + * + * #define FIREWIRE_EUI64_LEN 8 + * struct firewire_header { + * u_char firewire_dhost[FIREWIRE_EUI64_LEN]; + * u_char firewire_shost[FIREWIRE_EUI64_LEN]; + * u_short firewire_type; + * }; + * + * with "firewire_type" being an Ethernet type value, rather than, + * for example, raw GASP frames being handed up. + */ +#define DLT_APPLE_IP_OVER_IEEE1394 138 + +/* + * Various SS7 encapsulations, as per a request from Jeff Morriss + * and subsequent discussions. + */ +#define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */ +#define DLT_MTP2 140 /* MTP2, without pseudo-header */ +#define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */ +#define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */ + +/* + * DOCSIS MAC frames. + */ +#define DLT_DOCSIS 143 + +/* + * Linux-IrDA packets. Protocol defined at https://www.irda.org. + * Those packets include IrLAP headers and above (IrLMP...), but + * don't include Phy framing (SOF/EOF/CRC & byte stuffing), because Phy + * framing can be handled by the hardware and depend on the bitrate. + * This is exactly the format you would get capturing on a Linux-IrDA + * interface (irdaX), but not on a raw serial port. + * Note the capture is done in "Linux-cooked" mode, so each packet include + * a fake packet header (struct sll_header). This is because IrDA packet + * decoding is dependent on the direction of the packet (incoming or + * outgoing). + * When/if other platform implement IrDA capture, we may revisit the + * issue and define a real DLT_IRDA... + * Jean II + */ +#define DLT_LINUX_IRDA 144 + +/* + * Reserved for IBM SP switch and IBM Next Federation switch. + */ +#define DLT_IBM_SP 145 +#define DLT_IBM_SN 146 + +/* + * Reserved for private use. If you have some link-layer header type + * that you want to use within your organization, with the capture files + * using that link-layer header type not ever be sent outside your + * organization, you can use these values. + * + * No libpcap release will use these for any purpose, nor will any + * tcpdump release use them, either. + * + * Do *NOT* use these in capture files that you expect anybody not using + * your private versions of capture-file-reading tools to read; in + * particular, do *NOT* use them in products, otherwise you may find that + * people won't be able to use tcpdump, or snort, or Ethereal, or... to + * read capture files from your firewall/intrusion detection/traffic + * monitoring/etc. appliance, or whatever product uses that DLT_ value, + * and you may also find that the developers of those applications will + * not accept patches to let them read those files. + * + * Also, do not use them if somebody might send you a capture using them + * for *their* private type and tools using them for *your* private type + * would have to read them. + * + * Instead, ask "tcpdump-workers@lists.tcpdump.org" for a new DLT_ value, + * as per the comment above, and use the type you're given. + */ +#define DLT_USER0 147 +#define DLT_USER1 148 +#define DLT_USER2 149 +#define DLT_USER3 150 +#define DLT_USER4 151 +#define DLT_USER5 152 +#define DLT_USER6 153 +#define DLT_USER7 154 +#define DLT_USER8 155 +#define DLT_USER9 156 +#define DLT_USER10 157 +#define DLT_USER11 158 +#define DLT_USER12 159 +#define DLT_USER13 160 +#define DLT_USER14 161 +#define DLT_USER15 162 + +/* + * For future use with 802.11 captures - defined by AbsoluteValue + * Systems to store a number of bits of link-layer information + * including radio information: + * + * http://www.shaftnet.org/~pizza/software/capturefrm.txt + * + * but it might be used by some non-AVS drivers now or in the + * future. + */ +#define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, etc.. + */ +#define DLT_JUNIPER_MONITOR 164 + +/* + * BACnet MS/TP frames. + */ +#define DLT_BACNET_MS_TP 165 + +/* + * Another PPP variant as per request from Karsten Keil . + * + * This is used in some OSes to allow a kernel socket filter to distinguish + * between incoming and outgoing packets, on a socket intended to + * supply pppd with outgoing packets so it can do dial-on-demand and + * hangup-on-lack-of-demand; incoming packets are filtered out so they + * don't cause pppd to hold the connection up (you don't want random + * input packets such as port scans, packets from old lost connections, + * etc. to force the connection to stay up). + * + * The first byte of the PPP header (0xff03) is modified to accommodate + * the direction - 0x00 = IN, 0x01 = OUT. + */ +#define DLT_PPP_PPPD 166 + +/* + * Names for backwards compatibility with older versions of some PPP + * software; new software should use DLT_PPP_PPPD. + */ +#define DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD +#define DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, cookies, etc.. + */ +#define DLT_JUNIPER_PPPOE 167 +#define DLT_JUNIPER_PPPOE_ATM 168 + +#define DLT_GPRS_LLC 169 /* GPRS LLC */ +#define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */ +#define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */ + +/* + * Requested by Oolan Zimmer for use in Gcom's T1/E1 line + * monitoring equipment. + */ +#define DLT_GCOM_T1E1 172 +#define DLT_GCOM_SERIAL 173 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_ is used + * for internal communication to Physical Interface Cards (PIC) + */ +#define DLT_JUNIPER_PIC_PEER 174 + +/* + * Link types requested by Gregor Maier of Endace + * Measurement Systems. They add an ERF header (see + * https://www.endace.com/support/EndaceRecordFormat.pdf) in front of + * the link-layer header. + */ +#define DLT_ERF_ETH 175 /* Ethernet */ +#define DLT_ERF_POS 176 /* Packet-over-SONET */ + +/* + * Requested by Daniele Orlandi for raw LAPD + * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header + * includes additional information before the LAPD header, so it's + * not necessarily a generic LAPD header. + */ +#define DLT_LINUX_LAPD 177 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ are used for prepending meta-information + * like interface index, interface name + * before standard Ethernet, PPP, Frelay & C-HDLC Frames + */ +#define DLT_JUNIPER_ETHER 178 +#define DLT_JUNIPER_PPP 179 +#define DLT_JUNIPER_FRELAY 180 +#define DLT_JUNIPER_CHDLC 181 + +/* + * Multi Link Frame Relay (FRF.16) + */ +#define DLT_MFR 182 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for internal communication with a + * voice Adapter Card (PIC) + */ +#define DLT_JUNIPER_VP 183 + +/* + * Arinc 429 frames. + * DLT_ requested by Gianluca Varenni . + * Every frame contains a 32bit A429 label. + * More documentation on Arinc 429 can be found at + * https://web.archive.org/web/20040616233302/https://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf + */ +#define DLT_A429 184 + +/* + * Arinc 653 Interpartition Communication messages. + * DLT_ requested by Gianluca Varenni . + * Please refer to the A653-1 standard for more information. + */ +#define DLT_A653_ICM 185 + +/* + * This used to be "USB packets, beginning with a USB setup header; + * requested by Paolo Abeni ." + * + * However, that header didn't work all that well - it left out some + * useful information - and was abandoned in favor of the DLT_USB_LINUX + * header. + * + * This is now used by FreeBSD for its BPF taps for USB; that has its + * own headers. So it is written, so it is done. + * + * For source-code compatibility, we also define DLT_USB to have this + * value. We do it numerically so that, if code that includes this + * file (directly or indirectly) also includes an OS header that also + * defines DLT_USB as 186, we don't get a redefinition warning. + * (NetBSD 7 does that.) + */ +#define DLT_USB_FREEBSD 186 +#define DLT_USB 186 + +/* + * Bluetooth HCI UART transport layer (part H:4); requested by + * Paolo Abeni. + */ +#define DLT_BLUETOOTH_HCI_H4 187 + +/* + * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz + * . + */ +#define DLT_IEEE802_16_MAC_CPS 188 + +/* + * USB packets, beginning with a Linux USB header; requested by + * Paolo Abeni . + */ +#define DLT_USB_LINUX 189 + +/* + * Controller Area Network (CAN) v. 2.0B packets. + * DLT_ requested by Gianluca Varenni . + * Used to dump CAN packets coming from a CAN Vector board. + * More documentation on the CAN v2.0B frames can be found at + * http://www.can-cia.org/downloads/?269 + */ +#define DLT_CAN20B 190 + +/* + * IEEE 802.15.4, with address fields padded, as is done by Linux + * drivers; requested by Juergen Schimmer. + */ +#define DLT_IEEE802_15_4_LINUX 191 + +/* + * Per Packet Information encapsulated packets. + * DLT_ requested by Gianluca Varenni . + */ +#define DLT_PPI 192 + +/* + * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header; + * requested by Charles Clancy. + */ +#define DLT_IEEE802_16_MAC_CPS_RADIO 193 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for internal communication with a + * integrated service module (ISM). + */ +#define DLT_JUNIPER_ISM 194 + +/* + * IEEE 802.15.4, exactly as it appears in the spec (no padding, no + * nothing); requested by Mikko Saarnivala . + * For this one, we expect the FCS to be present at the end of the frame; + * if the frame has no FCS, DLT_IEEE802_15_4_NOFCS should be used. + * + * We keep the name DLT_IEEE802_15_4 as an alias for backwards + * compatibility, but, again, this should *only* be used for 802.15.4 + * frames that include the FCS. + */ +#define DLT_IEEE802_15_4_WITHFCS 195 +#define DLT_IEEE802_15_4 DLT_IEEE802_15_4_WITHFCS + +/* + * Various link-layer types, with a pseudo-header, for SITA + * (https://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com). + */ +#define DLT_SITA 196 + +/* + * Various link-layer types, with a pseudo-header, for Endace DAG cards; + * encapsulates Endace ERF records. Requested by Stephen Donnelly + * . + */ +#define DLT_ERF 197 + +/* + * Special header prepended to Ethernet packets when capturing from a + * u10 Networks board. Requested by Phil Mulholland + * . + */ +#define DLT_RAIF1 198 + +/* + * IPMB packet for IPMI, beginning with a 2-byte header, followed by + * the I2C slave address, followed by the netFn and LUN, etc.. + * Requested by Chanthy Toeung . + * + * XXX - this used to be called DLT_IPMB, back when we got the + * impression from the email thread requesting it that the packet + * had no extra 2-byte header. We've renamed it; if anybody used + * DLT_IPMB and assumed no 2-byte header, this will cause the compile + * to fail, at which point we'll have to figure out what to do about + * the two header types using the same DLT_/LINKTYPE_ value. If that + * doesn't happen, we'll assume nobody used it and that the redefinition + * is safe. + */ +#define DLT_IPMB_KONTRON 199 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for capturing data on a secure tunnel interface. + */ +#define DLT_JUNIPER_ST 200 + +/* + * Bluetooth HCI UART transport layer (part H:4), with pseudo-header + * that includes direction information; requested by Paolo Abeni. + */ +#define DLT_BLUETOOTH_HCI_H4_WITH_PHDR 201 + +/* + * AX.25 packet with a 1-byte KISS header; see + * + * http://www.ax25.net/kiss.htm + * + * as per Richard Stearn . + */ +#define DLT_AX25_KISS 202 + +/* + * LAPD packets from an ISDN channel, starting with the address field, + * with no pseudo-header. + * Requested by Varuna De Silva . + */ +#define DLT_LAPD 203 + +/* + * PPP, with a one-byte direction pseudo-header prepended - zero means + * "received by this host", non-zero (any non-zero value) means "sent by + * this host" - as per Will Barker . + * + * Don't confuse this with DLT_PPP_WITH_DIRECTION, which is an old + * name for what is now called DLT_PPP_PPPD. + */ +#define DLT_PPP_WITH_DIR 204 + +/* + * Cisco HDLC, with a one-byte direction pseudo-header prepended - zero + * means "received by this host", non-zero (any non-zero value) means + * "sent by this host" - as per Will Barker . + */ +#define DLT_C_HDLC_WITH_DIR 205 + +/* + * Frame Relay, with a one-byte direction pseudo-header prepended - zero + * means "received by this host" (DCE -> DTE), non-zero (any non-zero + * value) means "sent by this host" (DTE -> DCE) - as per Will Barker + * . + */ +#define DLT_FRELAY_WITH_DIR 206 + +/* + * LAPB, with a one-byte direction pseudo-header prepended - zero means + * "received by this host" (DCE -> DTE), non-zero (any non-zero value) + * means "sent by this host" (DTE -> DCE)- as per Will Barker + * . + */ +#define DLT_LAPB_WITH_DIR 207 + +/* + * 208 is reserved for an as-yet-unspecified proprietary link-layer + * type, as requested by Will Barker. + */ + +/* + * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman + * . + */ +#define DLT_IPMB_LINUX 209 + +/* + * FlexRay automotive bus - http://www.flexray.com/ - as requested + * by Hannes Kaelber . + */ +#define DLT_FLEXRAY 210 + +/* + * Media Oriented Systems Transport (MOST) bus for multimedia + * transport - https://www.mostcooperation.com/ - as requested + * by Hannes Kaelber . + */ +#define DLT_MOST 211 + +/* + * Local Interconnect Network (LIN) bus for vehicle networks - + * http://www.lin-subbus.org/ - as requested by Hannes Kaelber + * . + */ +#define DLT_LIN 212 + +/* + * X2E-private data link type used for serial line capture, + * as requested by Hannes Kaelber . + */ +#define DLT_X2E_SERIAL 213 + +/* + * X2E-private data link type used for the Xoraya data logger + * family, as requested by Hannes Kaelber . + */ +#define DLT_X2E_XORAYA 214 + +/* + * IEEE 802.15.4, exactly as it appears in the spec (no padding, no + * nothing), but with the PHY-level data for non-ASK PHYs (4 octets + * of 0 as preamble, one octet of SFD, one octet of frame length+ + * reserved bit, and then the MAC-layer data, starting with the + * frame control field). + * + * Requested by Max Filippov . + */ +#define DLT_IEEE802_15_4_NONASK_PHY 215 + +/* + * David Gibson requested this for + * captures from the Linux kernel /dev/input/eventN devices. This + * is used to communicate keystrokes and mouse movements from the + * Linux kernel to display systems, such as Xorg. + */ +#define DLT_LINUX_EVDEV 216 + +/* + * GSM Um and Abis interfaces, preceded by a "gsmtap" header. + * + * Requested by Harald Welte . + */ +#define DLT_GSMTAP_UM 217 +#define DLT_GSMTAP_ABIS 218 + +/* + * MPLS, with an MPLS label as the link-layer header. + * Requested by Michele Marchetto on behalf + * of OpenBSD. + */ +#define DLT_MPLS 219 + +/* + * USB packets, beginning with a Linux USB header, with the USB header + * padded to 64 bytes; required for memory-mapped access. + */ +#define DLT_USB_LINUX_MMAPPED 220 + +/* + * DECT packets, with a pseudo-header; requested by + * Matthias Wenzel . + */ +#define DLT_DECT 221 + +/* + * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" + * Date: Mon, 11 May 2009 11:18:30 -0500 + * + * DLT_AOS. We need it for AOS Space Data Link Protocol. + * I have already written dissectors for but need an OK from + * legal before I can submit a patch. + * + */ +#define DLT_AOS 222 + +/* + * WirelessHART (Highway Addressable Remote Transducer) + * From the HART Communication Foundation + * IEC/PAS 62591 + * + * Requested by Sam Roberts . + */ +#define DLT_WIHART 223 + +/* + * Fibre Channel FC-2 frames, beginning with a Frame_Header. + * Requested by Kahou Lei . + */ +#define DLT_FC_2 224 + +/* + * Fibre Channel FC-2 frames, beginning with an encoding of the + * SOF, and ending with an encoding of the EOF. + * + * The encodings represent the frame delimiters as 4-byte sequences + * representing the corresponding ordered sets, with K28.5 + * represented as 0xBC, and the D symbols as the corresponding + * byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2, + * is represented as 0xBC 0xB5 0x55 0x55. + * + * Requested by Kahou Lei . + */ +#define DLT_FC_2_WITH_FRAME_DELIMS 225 + +/* + * Solaris ipnet pseudo-header; requested by Darren Reed . + * + * The pseudo-header starts with a one-byte version number; for version 2, + * the pseudo-header is: + * + * struct dl_ipnetinfo { + * uint8_t dli_version; + * uint8_t dli_family; + * uint16_t dli_htype; + * uint32_t dli_pktlen; + * uint32_t dli_ifindex; + * uint32_t dli_grifindex; + * uint32_t dli_zsrc; + * uint32_t dli_zdst; + * }; + * + * dli_version is 2 for the current version of the pseudo-header. + * + * dli_family is a Solaris address family value, so it's 2 for IPv4 + * and 26 for IPv6. + * + * dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing + * packets, and 2 for packets arriving from another zone on the same + * machine. + * + * dli_pktlen is the length of the packet data following the pseudo-header + * (so the captured length minus dli_pktlen is the length of the + * pseudo-header, assuming the entire pseudo-header was captured). + * + * dli_ifindex is the interface index of the interface on which the + * packet arrived. + * + * dli_grifindex is the group interface index number (for IPMP interfaces). + * + * dli_zsrc is the zone identifier for the source of the packet. + * + * dli_zdst is the zone identifier for the destination of the packet. + * + * A zone number of 0 is the global zone; a zone number of 0xffffffff + * means that the packet arrived from another host on the network, not + * from another zone on the same machine. + * + * An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates + * which of those it is. + */ +#define DLT_IPNET 226 + +/* + * CAN (Controller Area Network) frames, with a pseudo-header as supplied + * by Linux SocketCAN, and with multi-byte numerical fields in that header + * in big-endian byte order. + * + * See Documentation/networking/can.txt in the Linux source. + * + * Requested by Felix Obenhuber . + */ +#define DLT_CAN_SOCKETCAN 227 + +/* + * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies + * whether it's v4 or v6. Requested by Darren Reed . + */ +#define DLT_IPV4 228 +#define DLT_IPV6 229 + +/* + * IEEE 802.15.4, exactly as it appears in the spec (no padding, no + * nothing), and with no FCS at the end of the frame; requested by + * Jon Smirl . + */ +#define DLT_IEEE802_15_4_NOFCS 230 + +/* + * Raw D-Bus: + * + * https://www.freedesktop.org/wiki/Software/dbus + * + * messages: + * + * https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages + * + * starting with the endianness flag, followed by the message type, etc., + * but without the authentication handshake before the message sequence: + * + * https://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol + * + * Requested by Martin Vidner . + */ +#define DLT_DBUS 231 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + */ +#define DLT_JUNIPER_VS 232 +#define DLT_JUNIPER_SRX_E2E 233 +#define DLT_JUNIPER_FIBRECHANNEL 234 + +/* + * DVB-CI (DVB Common Interface for communication between a PC Card + * module and a DVB receiver). See + * + * https://www.kaiser.cx/pcap-dvbci.html + * + * for the specification. + * + * Requested by Martin Kaiser . + */ +#define DLT_DVB_CI 235 + +/* + * Variant of 3GPP TS 27.010 multiplexing protocol (similar to, but + * *not* the same as, 27.010). Requested by Hans-Christoph Schemmel + * . + */ +#define DLT_MUX27010 236 + +/* + * STANAG 5066 D_PDUs. Requested by M. Baris Demiray + * . + */ +#define DLT_STANAG_5066_D_PDU 237 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + */ +#define DLT_JUNIPER_ATM_CEMIC 238 + +/* + * NetFilter LOG messages + * (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets) + * + * Requested by Jakub Zawadzki + */ +#define DLT_NFLOG 239 + +/* + * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type + * for Ethernet packets with a 4-byte pseudo-header and always + * with the payload including the FCS, as supplied by their + * netANALYZER hardware and software. + * + * Requested by Holger P. Frommer + */ +#define DLT_NETANALYZER 240 + +/* + * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type + * for Ethernet packets with a 4-byte pseudo-header and FCS and + * with the Ethernet header preceded by 7 bytes of preamble and + * 1 byte of SFD, as supplied by their netANALYZER hardware and + * software. + * + * Requested by Holger P. Frommer + */ +#define DLT_NETANALYZER_TRANSPARENT 241 + +/* + * IP-over-InfiniBand, as specified by RFC 4391. + * + * Requested by Petr Sumbera . + */ +#define DLT_IPOIB 242 + +/* + * MPEG-2 transport stream (ISO 13818-1/ITU-T H.222.0). + * + * Requested by Guy Martin . + */ +#define DLT_MPEG_2_TS 243 + +/* + * ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as + * used by their ng40 protocol tester. + * + * Requested by Jens Grimmer . + */ +#define DLT_NG40 244 + +/* + * Pseudo-header giving adapter number and flags, followed by an NFC + * (Near-Field Communications) Logical Link Control Protocol (LLCP) PDU, + * as specified by NFC Forum Logical Link Control Protocol Technical + * Specification LLCP 1.1. + * + * Requested by Mike Wakerly . + */ +#define DLT_NFC_LLCP 245 + +/* + * 246 is used as LINKTYPE_PFSYNC; do not use it for any other purpose. + * + * DLT_PFSYNC has different values on different platforms, and all of + * them collide with something used elsewhere. On platforms that + * don't already define it, define it as 246. + */ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) && !defined(__APPLE__) +#define DLT_PFSYNC 246 +#endif + +/* + * Raw InfiniBand packets, starting with the Local Routing Header. + * + * Requested by Oren Kladnitsky . + */ +#define DLT_INFINIBAND 247 + +/* + * SCTP, with no lower-level protocols (i.e., no IPv4 or IPv6). + * + * Requested by Michael Tuexen . + */ +#define DLT_SCTP 248 + +/* + * USB packets, beginning with a USBPcap header. + * + * Requested by Tomasz Mon + */ +#define DLT_USBPCAP 249 + +/* + * Schweitzer Engineering Laboratories "RTAC" product serial-line + * packets. + * + * Requested by Chris Bontje . + */ +#define DLT_RTAC_SERIAL 250 + +/* + * Bluetooth Low Energy air interface link-layer packets. + * + * Requested by Mike Kershaw . + */ +#define DLT_BLUETOOTH_LE_LL 251 + +/* + * DLT type for upper-protocol layer PDU saves from Wireshark. + * + * the actual contents are determined by two TAGs, one or more of + * which is stored with each packet: + * + * EXP_PDU_TAG_DISSECTOR_NAME the name of the Wireshark dissector + * that can make sense of the data stored. + * + * EXP_PDU_TAG_HEUR_DISSECTOR_NAME the name of the Wireshark heuristic + * dissector that can make sense of the + * data stored. + */ +#define DLT_WIRESHARK_UPPER_PDU 252 + +/* + * DLT type for the netlink protocol (nlmon devices). + */ +#define DLT_NETLINK 253 + +/* + * Bluetooth Linux Monitor headers for the BlueZ stack. + */ +#define DLT_BLUETOOTH_LINUX_MONITOR 254 + +/* + * Bluetooth Basic Rate/Enhanced Data Rate baseband packets, as + * captured by Ubertooth. + */ +#define DLT_BLUETOOTH_BREDR_BB 255 + +/* + * Bluetooth Low Energy link layer packets, as captured by Ubertooth. + */ +#define DLT_BLUETOOTH_LE_LL_WITH_PHDR 256 + +/* + * PROFIBUS data link layer. + */ +#define DLT_PROFIBUS_DL 257 + +/* + * Apple's DLT_PKTAP headers. + * + * Sadly, the folks at Apple either had no clue that the DLT_USERn values + * are for internal use within an organization and partners only, and + * didn't know that the right way to get a link-layer header type is to + * ask tcpdump.org for one, or knew and didn't care, so they just + * used DLT_USER2, which causes problems for everything except for + * their version of tcpdump. + * + * So I'll just give them one; hopefully this will show up in a + * libpcap release in time for them to get this into 10.10 Big Sur + * or whatever Mavericks' successor is called. LINKTYPE_PKTAP + * will be 258 *even on macOS*; that is *intentional*, so that + * PKTAP files look the same on *all* OSes (different OSes can have + * different numerical values for a given DLT_, but *MUST NOT* have + * different values for what goes in a file, as files can be moved + * between OSes!). + * + * When capturing, on a system with a Darwin-based OS, on a device + * that returns 149 (DLT_USER2 and Apple's DLT_PKTAP) with this + * version of libpcap, the DLT_ value for the pcap_t will be DLT_PKTAP, + * and that will continue to be DLT_USER2 on Darwin-based OSes. That way, + * binary compatibility with Mavericks is preserved for programs using + * this version of libpcap. This does mean that if you were using + * DLT_USER2 for some capture device on macOS, you can't do so with + * this version of libpcap, just as you can't with Apple's libpcap - + * on macOS, they define DLT_PKTAP to be DLT_USER2, so programs won't + * be able to distinguish between PKTAP and whatever you were using + * DLT_USER2 for. + * + * If the program saves the capture to a file using this version of + * libpcap's pcap_dump code, the LINKTYPE_ value in the file will be + * LINKTYPE_PKTAP, which will be 258, even on Darwin-based OSes. + * That way, the file will *not* be a DLT_USER2 file. That means + * that the latest version of tcpdump, when built with this version + * of libpcap, and sufficiently recent versions of Wireshark will + * be able to read those files and interpret them correctly; however, + * Apple's version of tcpdump in OS X 10.9 won't be able to handle + * them. (Hopefully, Apple will pick up this version of libpcap, + * and the corresponding version of tcpdump, so that tcpdump will + * be able to handle the old LINKTYPE_USER2 captures *and* the new + * LINKTYPE_PKTAP captures.) + */ +#ifdef __APPLE__ +#define DLT_PKTAP DLT_USER2 +#else +#define DLT_PKTAP 258 +#endif + +/* + * Ethernet packets preceded by a header giving the last 6 octets + * of the preamble specified by 802.3-2012 Clause 65, section + * 65.1.3.2 "Transmit". + */ +#define DLT_EPON 259 + +/* + * IPMI trace packets, as specified by Table 3-20 "Trace Data Block Format" + * in the PICMG HPM.2 specification. + */ +#define DLT_IPMI_HPM_2 260 + +/* + * per Joshua Wright , formats for Zwave captures. + */ +#define DLT_ZWAVE_R1_R2 261 +#define DLT_ZWAVE_R3 262 + +/* + * per Steve Karg , formats for Wattstopper + * Digital Lighting Management room bus serial protocol captures. + */ +#define DLT_WATTSTOPPER_DLM 263 + +/* + * ISO 14443 contactless smart card messages. + */ +#define DLT_ISO_14443 264 + +/* + * Radio data system (RDS) groups. IEC 62106. + * Per Jonathan Brucker . + */ +#define DLT_RDS 265 + +/* + * USB packets, beginning with a Darwin (macOS, etc.) header. + */ +#define DLT_USB_DARWIN 266 + +/* + * OpenBSD DLT_OPENFLOW. + */ +#define DLT_OPENFLOW 267 + +/* + * SDLC frames containing SNA PDUs. + */ +#define DLT_SDLC 268 + +/* + * per "Selvig, Bjorn" used for + * TI protocol sniffer. + */ +#define DLT_TI_LLN_SNIFFER 269 + +/* + * per: Erik de Jong for + * https://github.com/eriknl/LoRaTap/releases/tag/v0.1 + */ +#define DLT_LORATAP 270 + +/* + * per: Stefanha at gmail.com for + * https://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html + * and: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vsockmon.h + * for: https://qemu-project.org/Features/VirtioVsock + */ +#define DLT_VSOCK 271 + +/* + * Nordic Semiconductor Bluetooth LE sniffer. + */ +#define DLT_NORDIC_BLE 272 + +/* + * Excentis DOCSIS 3.1 RF sniffer (XRA-31) + * per: bruno.verstuyft at excentis.com + * https://www.xra31.com/xra-header + */ +#define DLT_DOCSIS31_XRA31 273 + +/* + * mPackets, as specified by IEEE 802.3br Figure 99-4, starting + * with the preamble and always ending with a CRC field. + */ +#define DLT_ETHERNET_MPACKET 274 + +/* + * DisplayPort AUX channel monitoring data as specified by VESA + * DisplayPort(DP) Standard preceded by a pseudo-header. + * per dirk.eibach at gdsys.cc + */ +#define DLT_DISPLAYPORT_AUX 275 + +/* + * Linux cooked sockets v2. + */ +#define DLT_LINUX_SLL2 276 + +/* + * Sercos Monitor, per Manuel Jacob + */ +#define DLT_SERCOS_MONITOR 277 + +/* + * OpenVizsla http://openvizsla.org is open source USB analyzer hardware. + * It consists of FPGA with attached USB phy and FTDI chip for streaming + * the data to the host PC. + * + * Current OpenVizsla data encapsulation format is described here: + * https://github.com/matwey/libopenvizsla/wiki/OpenVizsla-protocol-description + * + */ +#define DLT_OPENVIZSLA 278 + +/* + * The Elektrobit High Speed Capture and Replay (EBHSCR) protocol is produced + * by a PCIe Card for interfacing high speed automotive interfaces. + * + * The specification for this frame format can be found at: + * https://www.elektrobit.com/ebhscr + * + * for Guenter.Ebermann at elektrobit.com + * + */ +#define DLT_EBHSCR 279 + +/* + * The https://fd.io vpp graph dispatch tracer produces pcap trace files + * in the format documented here: + * https://fdio-vpp.readthedocs.io/en/latest/gettingstarted/developers/vnet.html#graph-dispatcher-pcap-tracing + */ +#define DLT_VPP_DISPATCH 280 + +/* + * Broadcom Ethernet switches (ROBO switch) 4 bytes proprietary tagging format. + */ +#define DLT_DSA_TAG_BRCM 281 +#define DLT_DSA_TAG_BRCM_PREPEND 282 + +/* + * IEEE 802.15.4 with pseudo-header and optional meta-data TLVs, PHY payload + * exactly as it appears in the spec (no padding, no nothing), and FCS if + * specified by FCS Type TLV; requested by James Ko . + * Specification at https://github.com/jkcko/ieee802.15.4-tap + */ +#define DLT_IEEE802_15_4_TAP 283 + +/* + * Marvell (Ethertype) Distributed Switch Architecture proprietary tagging format. + */ +#define DLT_DSA_TAG_DSA 284 +#define DLT_DSA_TAG_EDSA 285 + +/* + * Payload of lawful intercept packets using the ELEE protocol; + * https://socket.hr/draft-dfranusic-opsawg-elee-00.xml + * https://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc.cgi?url=https://socket.hr/draft-dfranusic-opsawg-elee-00.xml&modeAsFormat=html/ascii + */ +#define DLT_ELEE 286 + +/* + * Serial frames transmitted between a host and a Z-Wave chip. + */ +#define DLT_Z_WAVE_SERIAL 287 + +/* + * USB 2.0, 1.1, and 1.0 packets as transmitted over the cable. + */ +#define DLT_USB_2_0 288 + +/* + * ATSC Link-Layer Protocol (A/330) packets. + */ +#define DLT_ATSC_ALP 289 + +/* + * In case the code that includes this file (directly or indirectly) + * has also included OS files that happen to define DLT_HIGH_MATCHING_MAX, + * with a different value (perhaps because that OS hasn't picked up + * the latest version of our DLT definitions), we undefine the + * previous value of DLT_HIGH_MATCHING_MAX. + */ +#ifdef DLT_HIGH_MATCHING_MAX +#undef DLT_HIGH_MATCHING_MAX +#endif +#define DLT_HIGH_MATCHING_MAX 289 /* highest value in the "matching" range */ + +#endif /* !defined(lib_pcap_dlt_h) */ diff --git a/illumos-x86_64/usr/include/pcap/funcattrs.h b/illumos-x86_64/usr/include/pcap/funcattrs.h new file mode 100644 index 00000000..f6baf851 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/funcattrs.h @@ -0,0 +1,359 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lib_pcap_funcattrs_h +#define lib_pcap_funcattrs_h + +#include + +/* + * Attributes to apply to functions and their arguments, using various + * compiler-specific extensions. + */ + +/* + * PCAP_API_DEF must be used when defining *data* exported from + * libpcap. It can be used when defining *functions* exported + * from libpcap, but it doesn't have to be used there. It + * should not be used in declarations in headers. + * + * PCAP_API must be used when *declaring* data or functions + * exported from libpcap; PCAP_API_DEF won't work on all platforms. + */ + +#if defined(_WIN32) + /* + * For Windows: + * + * when building libpcap: + * + * if we're building it as a DLL, we have to declare API + * functions with __declspec(dllexport); + * + * if we're building it as a static library, we don't want + * to do so. + * + * when using libpcap: + * + * if we're using the DLL, calls to its functions are a + * little more efficient if they're declared with + * __declspec(dllimport); + * + * if we're not using the dll, we don't want to declare + * them that way. + * + * So: + * + * if pcap_EXPORTS is defined, we define PCAP_API_DEF as + * __declspec(dllexport); + * + * if PCAP_DLL is defined, we define PCAP_API_DEF as + * __declspec(dllimport); + * + * otherwise, we define PCAP_API_DEF as nothing. + */ + #if defined(pcap_EXPORTS) + /* + * We're compiling libpcap as a DLL, so we should export functions + * in our API. + */ + #define PCAP_API_DEF __declspec(dllexport) + #elif defined(PCAP_DLL) + /* + * We're using libpcap as a DLL, so the calls will be a little more + * efficient if we explicitly import the functions. + */ + #define PCAP_API_DEF __declspec(dllimport) + #else + /* + * Either we're building libpcap as a static library, or we're using + * it as a static library, or we don't know for certain that we're + * using it as a dynamic library, so neither import nor export the + * functions explicitly. + */ + #define PCAP_API_DEF + #endif +#elif defined(MSDOS) + /* XXX - does this need special treatment? */ + #define PCAP_API_DEF +#else /* UN*X */ + #ifdef pcap_EXPORTS + /* + * We're compiling libpcap as a (dynamic) shared library, so we should + * export functions in our API. The compiler might be configured not + * to export functions from a shared library by default, so we might + * have to explicitly mark functions as exported. + */ + #if PCAP_IS_AT_LEAST_GNUC_VERSION(3,4) \ + || PCAP_IS_AT_LEAST_XL_C_VERSION(12,0) + /* + * GCC 3.4 and later, or some compiler asserting compatibility with + * GCC 3.4 and later, or XL C 13.0 and later, so we have + * __attribute__((visibility()). + */ + #define PCAP_API_DEF __attribute__((visibility("default"))) + #elif PCAP_IS_AT_LEAST_SUNC_VERSION(5,5) + /* + * Sun C 5.5 and later, so we have __global. + * (Sun C 5.9 and later also have __attribute__((visibility()), + * but there's no reason to prefer it with Sun C.) + */ + #define PCAP_API_DEF __global + #else + /* + * We don't have anything to say. + */ + #define PCAP_API_DEF + #endif + #else + /* + * We're not building libpcap. + */ + #define PCAP_API_DEF + #endif +#endif /* _WIN32/MSDOS/UN*X */ + +#define PCAP_API PCAP_API_DEF extern + +/* + * Definitions to 1) indicate what version of libpcap first had a given + * API and 2) allow upstream providers whose build environments allow + * APIs to be designated as "first available in this release" to do so + * by appropriately defining them. + * + * On macOS, Apple can tweak this to make various APIs "weakly exported + * symbols" to make it easier for software that's distributed in binary + * form and that uses libpcap to run on multiple macOS versions and use + * new APIs when available. (Yes, such third-party software exists - + * Wireshark provides binary packages for macOS, for example. tcpdump + * doesn't count, as that's provided by Apple, so each release can + * come with a version compiled to use the APIs present in that release.) + * + * We don't tweak it that way ourselves because, if you're building + * and installing libpcap on macOS yourself, the APIs will be available + * no matter what OS version you're installing it on. + * + * For other platforms, we don't define them, leaving it up to + * others to do so based on their OS versions, if appropriate. + * + * We start with libpcap 0.4, as that was the last LBL release, and + * I've never seen earlier releases. + */ +#ifdef __APPLE__ +/* + * Apple - insert #include here, and replace the two + * #defines below with: + * + * #define PCAP_API_AVAILABLE API_AVAILABLE + * + * and adjust availabilities as necessary, including adding information + * about operating systems other than macOS. + */ +#define PCAP_API_AVAILABLE(...) +#define PCAP_AVAILABLE_0_4 PCAP_API_AVAILABLE(macos(10.0)) +#define PCAP_AVAILABLE_0_5 PCAP_API_AVAILABLE(macos(10.0)) +#define PCAP_AVAILABLE_0_6 PCAP_API_AVAILABLE(macos(10.1)) +#define PCAP_AVAILABLE_0_7 PCAP_API_AVAILABLE(macos(10.4)) +#define PCAP_AVAILABLE_0_8 PCAP_API_AVAILABLE(macos(10.4)) +#define PCAP_AVAILABLE_0_9 PCAP_API_AVAILABLE(macos(10.5)) +#define PCAP_AVAILABLE_1_0 PCAP_API_AVAILABLE(macos(10.6)) +/* #define PCAP_AVAILABLE_1_1 no routines added to the API */ +#define PCAP_AVAILABLE_1_2 PCAP_API_AVAILABLE(macos(10.9)) +/* #define PCAP_AVAILABLE_1_3 no routines added to the API */ +/* #define PCAP_AVAILABLE_1_4 no routines added to the API */ +#define PCAP_AVAILABLE_1_5 PCAP_API_AVAILABLE(macos(10.10)) +/* #define PCAP_AVAILABLE_1_6 no routines added to the API */ +#define PCAP_AVAILABLE_1_7 PCAP_API_AVAILABLE(macos(10.12)) +#define PCAP_AVAILABLE_1_8 PCAP_API_AVAILABLE(macos(10.13)) +#define PCAP_AVAILABLE_1_9 PCAP_API_AVAILABLE(macos(10.13)) +/* + * The remote capture APIs are, in 1.9 and 1.10, usually only + * available in the library if the library was built with + * remote capture enabled. + * + * However, macOS Sonoma provides stub versions of those routine, + * which return an error. This means that we need a separate + * availability indicator macro for those routines, so that + * progras built on macOS Sonoma that attempt to use weak + * importing and availability tests to use those routines + * if they're available will get those routines weakly imported, + * so that if they're run on releases prior to Sonoma, they + * won't get an error from dyld about those routines being + * missing in libpcap. (If they don't use run-time availability + * tests, they will, instead, get crashes if they call one of + * those routines, as the addresses of those routines will be + * set to 0 by dyld, meaning the program will dereference a + * null pointer and crash when trying to call them.) + * + * (Not that it's useful to use those routines *anyway*, as they're + * stubs that always fail. The stubs were necessary in order to + * support weak exporting at all.) + */ +#define PCAP_AVAILABLE_1_9_REMOTE PCAP_API_AVAILABLE(macos(14.0)) +#define PCAP_AVAILABLE_1_10 PCAP_API_AVAILABLE(macos(12.1)) +#define PCAP_AVAILABLE_1_10_REMOTE PCAP_API_AVAILABLE(macos(14.0)) +#define PCAP_AVAILABLE_1_11 /* not released yet, so not in macOS yet */ +#else /* __APPLE__ */ +#define PCAP_AVAILABLE_0_4 +#define PCAP_AVAILABLE_0_5 +#define PCAP_AVAILABLE_0_6 +#define PCAP_AVAILABLE_0_7 +#define PCAP_AVAILABLE_0_8 +#define PCAP_AVAILABLE_0_9 +#define PCAP_AVAILABLE_1_0 +/* #define PCAP_AVAILABLE_1_1 no routines added to the API */ +#define PCAP_AVAILABLE_1_2 +/* #define PCAP_AVAILABLE_1_3 no routines added to the API */ +/* #define PCAP_AVAILABLE_1_4 no routines added to the API */ +#define PCAP_AVAILABLE_1_5 +/* #define PCAP_AVAILABLE_1_6 no routines added to the API */ +#define PCAP_AVAILABLE_1_7 +#define PCAP_AVAILABLE_1_8 +#define PCAP_AVAILABLE_1_9 +#define PCAP_AVAILABLE_1_9_REMOTE +#define PCAP_AVAILABLE_1_10 +#define PCAP_AVAILABLE_1_10_REMOTE +#define PCAP_AVAILABLE_1_11 +#endif /* __APPLE__ */ + +/* + * PCAP_NORETURN, before a function declaration, means "this function + * never returns". (It must go before the function declaration, e.g. + * "extern PCAP_NORETURN func(...)" rather than after the function + * declaration, as the MSVC version has to go before the declaration.) + * + * PCAP_NORETURN_DEF, before a function *definition*, means "this + * function never returns"; it would be used only for static functions + * that are defined before any use, and thus have no declaration. + * (MSVC doesn't support that; I guess the "decl" in "__declspec" + * means "declaration", and __declspec doesn't work with definitions.) + */ +#if __has_attribute(noreturn) \ + || PCAP_IS_AT_LEAST_GNUC_VERSION(2,5) \ + || PCAP_IS_AT_LEAST_SUNC_VERSION(5,9) \ + || PCAP_IS_AT_LEAST_XL_C_VERSION(7,0) \ + || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10) \ + || __TINYC__ + /* + * Compiler with support for __attribute((noreturn)), or GCC 2.5 and + * later, or some compiler asserting compatibility with GCC 2.5 and + * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 7.0 + * and later (do any earlier versions of XL C support this?), or HP aCC + * A.06.10 and later, or current TinyCC. + */ + #define PCAP_NORETURN __attribute((noreturn)) + #define PCAP_NORETURN_DEF __attribute((noreturn)) +#elif defined(_MSC_VER) + /* + * MSVC. + */ + #define PCAP_NORETURN __declspec(noreturn) + #define PCAP_NORETURN_DEF +#else + #define PCAP_NORETURN + #define PCAP_NORETURN_DEF +#endif + +/* + * PCAP_PRINTFLIKE(x,y), after a function declaration, means "this function + * does printf-style formatting, with the xth argument being the format + * string and the yth argument being the first argument for the format + * string". + */ +#if __has_attribute(__format__) \ + || PCAP_IS_AT_LEAST_GNUC_VERSION(2,3) \ + || PCAP_IS_AT_LEAST_XL_C_VERSION(7,0) \ + || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10) + /* + * Compiler with support for it, or GCC 2.3 and later, or some compiler + * asserting compatibility with GCC 2.3 and later, or IBM XL C 7.0 + * and later (do any earlier versions of XL C support this?), + * or HP aCC A.06.10 and later. + */ + #define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y))) +#else + #define PCAP_PRINTFLIKE(x,y) +#endif + +/* + * PCAP_DEPRECATED(func, msg), after a function declaration, marks the + * function as deprecated. + * + * The argument is a string giving the warning message to use if the + * compiler supports that. + */ +#if __has_attribute(deprecated) \ + || PCAP_IS_AT_LEAST_GNUC_VERSION(4,5) \ + || PCAP_IS_AT_LEAST_SUNC_VERSION(5,13) + /* + * Compiler that supports __has_attribute and __attribute__((deprecated)), + * or GCC 4.5 and later, or Sun/Oracle C 12.4 (Sun C 5.13) and later. + * + * Those support __attribute__((deprecated(msg))) (we assume, perhaps + * incorrectly, that anything that supports __has_attribute() is + * recent enough to support __attribute__((deprecated(msg)))). + */ + #define PCAP_DEPRECATED(msg) __attribute__((deprecated(msg))) +#elif PCAP_IS_AT_LEAST_GNUC_VERSION(3,1) + /* + * GCC 3.1 through 4.4. + * + * Those support __attribute__((deprecated)) but not + * __attribute__((deprecated(msg))). + */ + #define PCAP_DEPRECATED(msg) __attribute__((deprecated)) +#elif defined(_MSC_VER) && !defined(BUILDING_PCAP) + /* + * MSVC, and we're not building libpcap itself; it's VS 2015 + * and later, so we have __declspec(deprecated(...)). + * + * If we *are* building libpcap, we don't want this, as it'll warn + * us even if we *define* the function. + */ + #define PCAP_DEPRECATED(msg) _declspec(deprecated(msg)) +#else + #define PCAP_DEPRECATED(msg) +#endif + +/* + * For flagging arguments as format strings in MSVC. + */ +#ifdef _MSC_VER + #include + #define PCAP_FORMAT_STRING(p) _Printf_format_string_ p +#else + #define PCAP_FORMAT_STRING(p) p +#endif + +#endif /* lib_pcap_funcattrs_h */ diff --git a/illumos-x86_64/usr/include/pcap/ipnet.h b/illumos-x86_64/usr/include/pcap/ipnet.h new file mode 100644 index 00000000..53308470 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/ipnet.h @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */ +#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */ + +#define IPNET_OUTBOUND 1 +#define IPNET_INBOUND 2 diff --git a/illumos-x86_64/usr/include/pcap/namedb.h b/illumos-x86_64/usr/include/pcap/namedb.h new file mode 100644 index 00000000..28a60a4c --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/namedb.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 1994, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lib_pcap_namedb_h +#define lib_pcap_namedb_h + +#include /* FILE */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * As returned by the pcap_next_etherent() + * XXX this stuff doesn't belong in this interface, but this + * library already must do name to address translation, so + * on systems that don't have support for /etc/ethers, we + * export these hooks since they're already being used by + * some applications (such as tcpdump) and already being + * marked as exported in some OSes offering libpcap (such + * as Debian). + */ +struct pcap_etherent { + u_char addr[6]; + char name[122]; +}; +#ifndef PCAP_ETHERS_FILE +#define PCAP_ETHERS_FILE "/etc/ethers" +#endif + +PCAP_AVAILABLE_0_4 +PCAP_API struct pcap_etherent *pcap_next_etherent(FILE *); + +PCAP_AVAILABLE_0_4 +PCAP_API u_char *pcap_ether_hostton(const char*); + +PCAP_AVAILABLE_0_4 +PCAP_API u_char *pcap_ether_aton(const char *); + +PCAP_AVAILABLE_0_4 +PCAP_API +PCAP_DEPRECATED("this is not reentrant; use 'pcap_nametoaddrinfo' instead") +bpf_u_int32 **pcap_nametoaddr(const char *); + +PCAP_AVAILABLE_0_7 +PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *); + +PCAP_AVAILABLE_0_4 +PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_nametoport(const char *, int *, int *); + +PCAP_AVAILABLE_0_9 +PCAP_API int pcap_nametoportrange(const char *, int *, int *, int *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_nametoproto(const char *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_nametoeproto(const char *); + +PCAP_AVAILABLE_0_9 +PCAP_API int pcap_nametollc(const char *); + +/* + * If a protocol is unknown, PROTO_UNDEF is returned. + * Also, pcap_nametoport() returns the protocol along with the port number. + * If there are ambiguous entries in /etc/services (i.e. domain + * can be either tcp or udp) PROTO_UNDEF is returned. + */ +#define PROTO_UNDEF -1 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/illumos-x86_64/usr/include/pcap/nflog.h b/illumos-x86_64/usr/include/pcap/nflog.h new file mode 100644 index 00000000..919c88d2 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/nflog.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2013, Petar Alilovic, + * Faculty of Electrical Engineering and Computing, University of Zagreb + * All rights reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + */ + +#ifndef lib_pcap_nflog_h +#define lib_pcap_nflog_h + +#include + +/* + * Structure of an NFLOG header and TLV parts, as described at + * https://www.tcpdump.org/linktypes/LINKTYPE_NFLOG.html + * + * The NFLOG header is big-endian. + * + * The TLV length and type are in host byte order. The value is either + * big-endian or is an array of bytes in some externally-specified byte + * order (text string, link-layer address, link-layer header, packet + * data, etc.). + */ +typedef struct nflog_hdr { + uint8_t nflog_family; /* address family */ + uint8_t nflog_version; /* version */ + uint16_t nflog_rid; /* resource ID */ +} nflog_hdr_t; + +typedef struct nflog_tlv { + uint16_t tlv_length; /* tlv length */ + uint16_t tlv_type; /* tlv type */ + /* value follows this */ +} nflog_tlv_t; + +typedef struct nflog_packet_hdr { + uint16_t hw_protocol; /* hw protocol */ + uint8_t hook; /* netfilter hook */ + uint8_t pad; /* padding to 32 bits */ +} nflog_packet_hdr_t; + +typedef struct nflog_hwaddr { + uint16_t hw_addrlen; /* address length */ + uint16_t pad; /* padding to 32-bit boundary */ + uint8_t hw_addr[8]; /* address, up to 8 bytes */ +} nflog_hwaddr_t; + +typedef struct nflog_timestamp { + uint64_t sec; + uint64_t usec; +} nflog_timestamp_t; + +/* + * TLV types. + */ +#define NFULA_PACKET_HDR 1 /* nflog_packet_hdr_t */ +#define NFULA_MARK 2 /* packet mark from skbuff */ +#define NFULA_TIMESTAMP 3 /* nflog_timestamp_t for skbuff's time stamp */ +#define NFULA_IFINDEX_INDEV 4 /* ifindex of device on which packet received (possibly bridge group) */ +#define NFULA_IFINDEX_OUTDEV 5 /* ifindex of device on which packet transmitted (possibly bridge group) */ +#define NFULA_IFINDEX_PHYSINDEV 6 /* ifindex of physical device on which packet received (not bridge group) */ +#define NFULA_IFINDEX_PHYSOUTDEV 7 /* ifindex of physical device on which packet transmitted (not bridge group) */ +#define NFULA_HWADDR 8 /* nflog_hwaddr_t for hardware address */ +#define NFULA_PAYLOAD 9 /* packet payload */ +#define NFULA_PREFIX 10 /* text string - null-terminated, count includes NUL */ +#define NFULA_UID 11 /* UID owning socket on which packet was sent/received */ +#define NFULA_SEQ 12 /* sequence number of packets on this NFLOG socket */ +#define NFULA_SEQ_GLOBAL 13 /* sequence number of packets on all NFLOG sockets */ +#define NFULA_GID 14 /* GID owning socket on which packet was sent/received */ +#define NFULA_HWTYPE 15 /* ARPHRD_ type of skbuff's device */ +#define NFULA_HWHEADER 16 /* skbuff's MAC-layer header */ +#define NFULA_HWLEN 17 /* length of skbuff's MAC-layer header */ + +#endif diff --git a/illumos-x86_64/usr/include/pcap/pcap-inttypes.h b/illumos-x86_64/usr/include/pcap/pcap-inttypes.h new file mode 100644 index 00000000..efaf6081 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/pcap-inttypes.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) + * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef pcap_pcap_inttypes_h +#define pcap_pcap_inttypes_h + +/* + * If we're compiling with Visual Studio, make sure the C99 integer + * types are defined, by hook or by crook. + * + * XXX - verify that we have at least C99 support on UN*Xes? + * + * What about MinGW or various DOS toolchains? We're currently assuming + * sufficient C99 support there. + */ +#if defined(_MSC_VER) + /* + * Compiler is MSVC. + */ + #if _MSC_VER >= 1800 + /* + * VS 2013 or newer; we have . + */ + #include + #else + /* + * Earlier VS; we have to define this stuff ourselves. + * We don't support building libpcap with earlier versions of VS, + * but SDKs for Npcap have to support building applications using + * earlier versions of VS, so we work around this by defining + * those types ourselves, as some files use them. + */ + typedef unsigned char uint8_t; + typedef signed char int8_t; + typedef unsigned short uint16_t; + typedef signed short int16_t; + typedef unsigned int uint32_t; + typedef signed int int32_t; + #ifdef _MSC_EXTENSIONS + typedef unsigned _int64 uint64_t; + typedef _int64 int64_t; + #else /* _MSC_EXTENSIONS */ + typedef unsigned long long uint64_t; + typedef long long int64_t; + #endif + #endif +#else /* defined(_MSC_VER) */ + /* + * Not Visual Studio. + * Include to get the integer types and PRI[doux]64 values + * defined. + * + * If the compiler is MinGW, we assume we have - and + * support for %zu in the formatted printing functions. + * + * If the target is UN*X, we assume we have a C99-or-later development + * environment, and thus have - and support for %zu in + * the formatted printing functions. + * + * If the target is MS-DOS, we assume we have - and support + * for %zu in the formatted printing functions. + * + * I.e., assume we have and that it suffices. + */ + + /* + * XXX - somehow make sure we have enough C99 support with other + * compilers and support libraries? + */ + + #include +#endif /* defined(_MSC_VER) */ + +#endif /* pcap/pcap-inttypes.h */ diff --git a/illumos-x86_64/usr/include/pcap/pcap.h b/illumos-x86_64/usr/include/pcap/pcap.h new file mode 100644 index 00000000..e014335b --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/pcap.h @@ -0,0 +1,1270 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Remote packet capture mechanisms and extensions from WinPcap: + * + * Copyright (c) 2002 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef lib_pcap_pcap_h +#define lib_pcap_pcap_h + +/* + * Some software that uses libpcap/WinPcap/Npcap defines _MSC_VER before + * including pcap.h if it's not defined - and it defines it to 1500. + * (I'm looking at *you*, lwIP!) + * + * Attempt to detect this, and undefine _MSC_VER so that we can *reliably* + * use it to know what compiler is being used and, if it's Visual Studio, + * what version is being used. + */ +#if defined(_MSC_VER) + /* + * We assume here that software such as that doesn't define _MSC_FULL_VER + * as well and that it defines _MSC_VER with a value > 1200. + * + * DO NOT BREAK THESE ASSUMPTIONS. IF YOU FEEL YOU MUST DEFINE _MSC_VER + * WITH A COMPILER THAT'S NOT MICROSOFT'S C COMPILER, PLEASE CONTACT + * US SO THAT WE CAN MAKE IT SO THAT YOU DON'T HAVE TO DO THAT. THANK + * YOU. + * + * OK, is _MSC_FULL_VER defined? + */ + #if !defined(_MSC_FULL_VER) + /* + * According to + * + * https://sourceforge.net/p/predef/wiki/Compilers/ + * + * with "Visual C++ 6.0 Processor Pack"/Visual C++ 6.0 SP6 and + * later, _MSC_FULL_VER is defined, so either this is an older + * version of Visual C++ or it's not Visual C++ at all. + * + * For Visual C++ 6.0, _MSC_VER is defined as 1200. + */ + #if _MSC_VER > 1200 + /* + * If this is Visual C++, _MSC_FULL_VER should be defined, so we + * assume this isn't Visual C++, and undo the lie that it is. + */ + #undef _MSC_VER + #endif + #endif +#endif + +#include + +#include + +#if defined(_WIN32) + #include /* u_int, u_char etc. */ + #include /* _get_osfhandle() */ +#elif defined(MSDOS) + #include /* u_int, u_char etc. */ + #include +#else /* UN*X */ + #include /* u_int, u_char etc. */ + #include +#endif /* _WIN32/MSDOS/UN*X */ + +#include /* for PCAP_SOCKET, as the active-mode rpcap APIs use it */ + +#ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Version number of the current version of the pcap file format. + * + * NOTE: this is *NOT* the version number of the libpcap library. + * To fetch the version information for the version of libpcap + * you're using, use pcap_lib_version(). + */ +#define PCAP_VERSION_MAJOR 2 +#define PCAP_VERSION_MINOR 4 + +#define PCAP_ERRBUF_SIZE 256 + +/* + * Compatibility for systems that have a bpf.h that + * predates the bpf typedefs for 64-bit support. + */ +#if BPF_RELEASE - 0 < 199406 +typedef int bpf_int32; +typedef u_int bpf_u_int32; +#endif + +typedef struct pcap pcap_t; +typedef struct pcap_dumper pcap_dumper_t; +typedef struct pcap_if pcap_if_t; +typedef struct pcap_addr pcap_addr_t; + +/* + * The first record in the file contains saved values for some + * of the flags used in the printout phases of tcpdump. + * Many fields here are 32 bit ints so compilers won't insert unwanted + * padding; these files need to be interchangeable across architectures. + * Documentation: https://www.tcpdump.org/manpages/pcap-savefile.5.txt. + * + * Do not change the layout of this structure, in any way (this includes + * changes that only affect the length of fields in this structure). + * + * Also, do not change the interpretation of any of the members of this + * structure, in any way (this includes using values other than + * LINKTYPE_ values, as defined in "savefile.c", in the "linktype" + * field). + * + * Instead: + * + * introduce a new structure for the new format, if the layout + * of the structure changed; + * + * send mail to "tcpdump-workers@lists.tcpdump.org", requesting + * a new magic number for your new capture file format, and, when + * you get the new magic number, put it in "savefile.c"; + * + * use that magic number for save files with the changed file + * header; + * + * make the code in "savefile.c" capable of reading files with + * the old file header as well as files with the new file header + * (using the magic number to determine the header format). + * + * Then supply the changes by forking the branch at + * + * https://github.com/the-tcpdump-group/libpcap/tree/master + * + * and issuing a pull request, so that future versions of libpcap and + * programs that use it (such as tcpdump) will be able to read your new + * capture file format. + */ +struct pcap_file_header { + bpf_u_int32 magic; + u_short version_major; + u_short version_minor; + bpf_int32 thiszone; /* not used - SHOULD be filled with 0 */ + bpf_u_int32 sigfigs; /* not used - SHOULD be filled with 0 */ + bpf_u_int32 snaplen; /* max length saved portion of each pkt */ + bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */ +}; + +/* + * Subfields of the field containing the link-layer header type. + * + * Link-layer header types are assigned for both pcap and + * pcapng, and the same value must work with both. In pcapng, + * the link-layer header type field in an Interface Description + * Block is 16 bits, so only the bottommost 16 bits of the + * link-layer header type in a pcap file can be used for the + * header type value. + * + * In libpcap, the upper 16 bits, from the top down, are divided into: + * + * A 4-bit "FCS length" field, to allow the FCS length to + * be specified, just as it can be specified in the if_fcslen + * field of the pcapng IDB. The field is in units of 16 bits, + * i.e. 1 means 16 bits of FCS, 2 means 32 bits of FCS, etc.. + * + * A reserved bit, which must be zero. + * + * An "FCS length present" flag; if 0, the "FCS length" field + * should be ignored, and if 1, the "FCS length" field should + * be used. + * + * 10 reserved bits, which must be zero. They were originally + * intended to be used as a "class" field, allowing additional + * classes of link-layer types to be defined, with a class value + * of 0 indicating that the link-layer type is a LINKTYPE_ value. + * A value of 0x224 was, at one point, used by NetBSD to define + * "raw" packet types, with the lower 16 bits containing a + * NetBSD AF_ value; see + * + * https://marc.info/?l=tcpdump-workers&m=98296750229149&w=2 + * + * It's unknown whether those were ever used in capture files, + * or if the intent was just to use it as a link-layer type + * for BPF programs; NetBSD's libpcap used to support them in + * the BPF code generator, but it no longer does so. If it + * was ever used in capture files, or if classes other than + * "LINKTYPE_ value" are ever useful in capture files, we could + * re-enable this, and use the reserved 16 bits following the + * link-layer type in pcapng files to hold the class information + * there. (Note, BTW, that LINKTYPE_RAW/DLT_RAW is now being + * interpreted by libpcap, tcpdump, and Wireshark as "raw IP", + * including both IPv4 and IPv6, with the version number in the + * header being checked to see which it is, not just "raw IPv4"; + * there are LINKTYPE_IPV4/DLT_IPV4 and LINKTYPE_IPV6/DLT_IPV6 + * values if "these are IPv{4,6} and only IPv{4,6} packets" + * types are needed.) + * + * Or we might be able to use it for other purposes. + */ +#define LT_LINKTYPE(x) ((x) & 0x0000FFFF) +#define LT_LINKTYPE_EXT(x) ((x) & 0xFFFF0000) +#define LT_RESERVED1(x) ((x) & 0x03FF0000) +#define LT_FCS_LENGTH_PRESENT(x) ((x) & 0x04000000) +#define LT_FCS_LENGTH(x) (((x) & 0xF0000000) >> 28) +#define LT_FCS_DATALINK_EXT(x) ((((x) & 0xF) << 28) | 0x04000000) + +typedef enum { + PCAP_D_INOUT = 0, + PCAP_D_IN, + PCAP_D_OUT +} pcap_direction_t; + +/* + * Generic per-packet information, as supplied by libpcap. + * + * The time stamp can and should be a "struct timeval", regardless of + * whether your system supports 32-bit tv_sec in "struct timeval", + * 64-bit tv_sec in "struct timeval", or both if it supports both 32-bit + * and 64-bit applications. The on-disk format of savefiles uses 32-bit + * tv_sec (and tv_usec); this structure is irrelevant to that. 32-bit + * and 64-bit versions of libpcap, even if they're on the same platform, + * should supply the appropriate version of "struct timeval", even if + * that's not what the underlying packet capture mechanism supplies. + */ +struct pcap_pkthdr { + struct timeval ts; /* time stamp */ + bpf_u_int32 caplen; /* length of portion present */ + bpf_u_int32 len; /* length of this packet (off wire) */ +}; + +/* + * As returned by the pcap_stats() + */ +struct pcap_stat { + u_int ps_recv; /* number of packets received */ + u_int ps_drop; /* number of packets dropped */ + u_int ps_ifdrop; /* drops by interface -- only supported on some platforms */ +#ifdef _WIN32 + u_int ps_capt; /* number of packets that reach the application */ + u_int ps_sent; /* number of packets sent by the server on the network */ + u_int ps_netdrop; /* number of packets lost on the network */ +#endif /* _WIN32 */ +}; + +#ifdef MSDOS +/* + * As returned by the pcap_stats_ex() + */ +struct pcap_stat_ex { + u_long rx_packets; /* total packets received */ + u_long tx_packets; /* total packets transmitted */ + u_long rx_bytes; /* total bytes received */ + u_long tx_bytes; /* total bytes transmitted */ + u_long rx_errors; /* bad packets received */ + u_long tx_errors; /* packet transmit problems */ + u_long rx_dropped; /* no space in Rx buffers */ + u_long tx_dropped; /* no space available for Tx */ + u_long multicast; /* multicast packets received */ + u_long collisions; + + /* detailed rx_errors: */ + u_long rx_length_errors; + u_long rx_over_errors; /* receiver ring buff overflow */ + u_long rx_crc_errors; /* recv'd pkt with crc error */ + u_long rx_frame_errors; /* recv'd frame alignment error */ + u_long rx_fifo_errors; /* recv'r fifo overrun */ + u_long rx_missed_errors; /* recv'r missed packet */ + + /* detailed tx_errors */ + u_long tx_aborted_errors; + u_long tx_carrier_errors; + u_long tx_fifo_errors; + u_long tx_heartbeat_errors; + u_long tx_window_errors; + }; +#endif + +/* + * Item in a list of interfaces. + */ +struct pcap_if { + struct pcap_if *next; + char *name; /* name to hand to "pcap_open_live()" */ + char *description; /* textual description of interface, or NULL */ + struct pcap_addr *addresses; + bpf_u_int32 flags; /* PCAP_IF_ interface flags */ +}; + +#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */ +#define PCAP_IF_UP 0x00000002 /* interface is up */ +#define PCAP_IF_RUNNING 0x00000004 /* interface is running */ +#define PCAP_IF_WIRELESS 0x00000008 /* interface is wireless (*NOT* necessarily Wi-Fi!) */ +#define PCAP_IF_CONNECTION_STATUS 0x00000030 /* connection status: */ +#define PCAP_IF_CONNECTION_STATUS_UNKNOWN 0x00000000 /* unknown */ +#define PCAP_IF_CONNECTION_STATUS_CONNECTED 0x00000010 /* connected */ +#define PCAP_IF_CONNECTION_STATUS_DISCONNECTED 0x00000020 /* disconnected */ +#define PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE 0x00000030 /* not applicable */ + +/* + * Representation of an interface address. + */ +struct pcap_addr { + struct pcap_addr *next; + struct sockaddr *addr; /* address */ + struct sockaddr *netmask; /* netmask for that address */ + struct sockaddr *broadaddr; /* broadcast address for that address */ + struct sockaddr *dstaddr; /* P2P destination address for that address */ +}; + +typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *, + const u_char *); + +/* + * Error codes for the pcap API. + * These will all be negative, so you can check for the success or + * failure of a call that returns these codes by checking for a + * negative value. + */ +#define PCAP_ERROR -1 /* generic error code */ +#define PCAP_ERROR_BREAK -2 /* loop terminated by pcap_breakloop */ +#define PCAP_ERROR_NOT_ACTIVATED -3 /* the capture needs to be activated */ +#define PCAP_ERROR_ACTIVATED -4 /* the operation can't be performed on already activated captures */ +#define PCAP_ERROR_NO_SUCH_DEVICE -5 /* no such device exists */ +#define PCAP_ERROR_RFMON_NOTSUP -6 /* this device doesn't support rfmon (monitor) mode */ +#define PCAP_ERROR_NOT_RFMON -7 /* operation supported only in monitor mode */ +#define PCAP_ERROR_PERM_DENIED -8 /* no permission to open the device */ +#define PCAP_ERROR_IFACE_NOT_UP -9 /* interface isn't up */ +#define PCAP_ERROR_CANTSET_TSTAMP_TYPE -10 /* this device doesn't support setting the time stamp type */ +#define PCAP_ERROR_PROMISC_PERM_DENIED -11 /* you don't have permission to capture in promiscuous mode */ +#define PCAP_ERROR_TSTAMP_PRECISION_NOTSUP -12 /* the requested time stamp precision is not supported */ +#define PCAP_ERROR_CAPTURE_NOTSUP -13 /* capture mechanism not available */ + +/* + * Warning codes for the pcap API. + * These will all be positive and non-zero, so they won't look like + * errors. + */ +#define PCAP_WARNING 1 /* generic warning code */ +#define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */ +#define PCAP_WARNING_TSTAMP_TYPE_NOTSUP 3 /* the requested time stamp type is not supported */ + +/* + * Value to pass to pcap_compile() as the netmask if you don't know what + * the netmask is. + */ +#define PCAP_NETMASK_UNKNOWN 0xffffffff + +/* + * Initialize pcap. If this isn't called, pcap is initialized to + * a mode source-compatible and binary-compatible with older versions + * that lack this routine. + */ + +/* + * Initialization options. + * All bits not listed here are reserved for expansion. + * + * On UNIX-like systems, the local character encoding is assumed to be + * UTF-8, so no character encoding transformations are done. + * + * On Windows, the local character encoding is the local ANSI code page. + */ +#define PCAP_CHAR_ENC_LOCAL 0x00000000U /* strings are in the local character encoding */ +#define PCAP_CHAR_ENC_UTF_8 0x00000001U /* strings are in UTF-8 */ + +PCAP_AVAILABLE_1_10 +PCAP_API int pcap_init(unsigned int, char *); + +/* + * We're deprecating pcap_lookupdev() for various reasons (not + * thread-safe, can behave weirdly with WinPcap). Callers + * should use pcap_findalldevs() and use the first device. + */ +PCAP_AVAILABLE_0_4 +PCAP_DEPRECATED("use 'pcap_findalldevs' and use the first device") +PCAP_API char *pcap_lookupdev(char *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *); + +PCAP_AVAILABLE_1_0 +PCAP_API pcap_t *pcap_create(const char *, char *); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_set_snaplen(pcap_t *, int); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_set_promisc(pcap_t *, int); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_can_set_rfmon(pcap_t *); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_set_rfmon(pcap_t *, int); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_set_timeout(pcap_t *, int); + +PCAP_AVAILABLE_1_2 +PCAP_API int pcap_set_tstamp_type(pcap_t *, int); + +PCAP_AVAILABLE_1_5 +PCAP_API int pcap_set_immediate_mode(pcap_t *, int); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_set_buffer_size(pcap_t *, int); + +PCAP_AVAILABLE_1_5 +PCAP_API int pcap_set_tstamp_precision(pcap_t *, int); + +PCAP_AVAILABLE_1_5 +PCAP_API int pcap_get_tstamp_precision(pcap_t *); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_activate(pcap_t *); + +PCAP_AVAILABLE_1_2 +PCAP_API int pcap_list_tstamp_types(pcap_t *, int **); + +PCAP_AVAILABLE_1_2 +PCAP_API void pcap_free_tstamp_types(int *); + +PCAP_AVAILABLE_1_2 +PCAP_API int pcap_tstamp_type_name_to_val(const char *); + +PCAP_AVAILABLE_1_2 +PCAP_API const char *pcap_tstamp_type_val_to_name(int); + +PCAP_AVAILABLE_1_2 +PCAP_API const char *pcap_tstamp_type_val_to_description(int); + +#ifdef __linux__ +PCAP_AVAILABLE_1_9 +PCAP_API int pcap_set_protocol_linux(pcap_t *, int); +#endif + +/* + * Time stamp types. + * Not all systems and interfaces will necessarily support all of these. + * + * A system that supports PCAP_TSTAMP_HOST is offering time stamps + * provided by the host machine, rather than by the capture device, + * but not committing to any characteristics of the time stamp. + * + * PCAP_TSTAMP_HOST_LOWPREC is a time stamp, provided by the host machine, + * that's low-precision but relatively cheap to fetch; it's normally done + * using the system clock, so it's normally synchronized with times you'd + * fetch from system calls. + * + * PCAP_TSTAMP_HOST_HIPREC is a time stamp, provided by the host machine, + * that's high-precision; it might be more expensive to fetch. It is + * synchronized with the system clock. + * + * PCAP_TSTAMP_HOST_HIPREC_UNSYNCED is a time stamp, provided by the host + * machine, that's high-precision; it might be more expensive to fetch. + * It is not synchronized with the system clock, and might have + * problems with time stamps for packets received on different CPUs, + * depending on the platform. It might be more likely to be strictly + * monotonic than PCAP_TSTAMP_HOST_HIPREC. + * + * PCAP_TSTAMP_ADAPTER is a high-precision time stamp supplied by the + * capture device; it's synchronized with the system clock. + * + * PCAP_TSTAMP_ADAPTER_UNSYNCED is a high-precision time stamp supplied by + * the capture device; it's not synchronized with the system clock. + * + * Note that time stamps synchronized with the system clock can go + * backwards, as the system clock can go backwards. If a clock is + * not in sync with the system clock, that could be because the + * system clock isn't keeping accurate time, because the other + * clock isn't keeping accurate time, or both. + * + * Note that host-provided time stamps generally correspond to the + * time when the time-stamping code sees the packet; this could + * be some unknown amount of time after the first or last bit of + * the packet is received by the network adapter, due to batching + * of interrupts for packet arrival, queueing delays, etc.. + */ +#define PCAP_TSTAMP_HOST 0 /* host-provided, unknown characteristics */ +#define PCAP_TSTAMP_HOST_LOWPREC 1 /* host-provided, low precision, synced with the system clock */ +#define PCAP_TSTAMP_HOST_HIPREC 2 /* host-provided, high precision, synced with the system clock */ +#define PCAP_TSTAMP_ADAPTER 3 /* device-provided, synced with the system clock */ +#define PCAP_TSTAMP_ADAPTER_UNSYNCED 4 /* device-provided, not synced with the system clock */ +#define PCAP_TSTAMP_HOST_HIPREC_UNSYNCED 5 /* host-provided, high precision, not synced with the system clock */ + +/* + * Time stamp resolution types. + * Not all systems and interfaces will necessarily support all of these + * resolutions when doing live captures; all of them can be requested + * when reading a savefile. + */ +#define PCAP_TSTAMP_PRECISION_MICRO 0 /* use timestamps with microsecond precision, default */ +#define PCAP_TSTAMP_PRECISION_NANO 1 /* use timestamps with nanosecond precision */ + +PCAP_AVAILABLE_0_4 +PCAP_API pcap_t *pcap_open_live(const char *, int, int, int, char *); + +PCAP_AVAILABLE_0_6 +PCAP_API pcap_t *pcap_open_dead(int, int); + +PCAP_AVAILABLE_1_5 +PCAP_API pcap_t *pcap_open_dead_with_tstamp_precision(int, int, u_int); + +PCAP_AVAILABLE_1_5 +PCAP_API pcap_t *pcap_open_offline_with_tstamp_precision(const char *, u_int, char *); + +PCAP_AVAILABLE_0_4 +PCAP_API pcap_t *pcap_open_offline(const char *, char *); + +#ifdef _WIN32 + PCAP_AVAILABLE_1_5 + PCAP_API pcap_t *pcap_hopen_offline_with_tstamp_precision(intptr_t, u_int, char *); + + PCAP_API pcap_t *pcap_hopen_offline(intptr_t, char *); + /* + * If we're building libpcap, these are internal routines in savefile.c, + * so we must not define them as macros. + * + * If we're not building libpcap, given that the version of the C runtime + * with which libpcap was built might be different from the version + * of the C runtime with which an application using libpcap was built, + * and that a FILE structure may differ between the two versions of the + * C runtime, calls to _fileno() must use the version of _fileno() in + * the C runtime used to open the FILE *, not the version in the C + * runtime with which libpcap was built. (Maybe once the Universal CRT + * rules the world, this will cease to be a problem.) + */ + #ifndef BUILDING_PCAP + #define pcap_fopen_offline_with_tstamp_precision(f,p,b) \ + pcap_hopen_offline_with_tstamp_precision(_get_osfhandle(_fileno(f)), p, b) + #define pcap_fopen_offline(f,b) \ + pcap_hopen_offline(_get_osfhandle(_fileno(f)), b) + #endif +#else /*_WIN32*/ + PCAP_AVAILABLE_1_5 + PCAP_API pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *, u_int, char *); + + PCAP_AVAILABLE_0_9 + PCAP_API pcap_t *pcap_fopen_offline(FILE *, char *); +#endif /*_WIN32*/ + +PCAP_AVAILABLE_0_4 +PCAP_API void pcap_close(pcap_t *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_loop(pcap_t *, int, pcap_handler, u_char *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *); + +PCAP_AVAILABLE_0_4 +PCAP_API const u_char *pcap_next(pcap_t *, struct pcap_pkthdr *); + +PCAP_AVAILABLE_0_8 +PCAP_API int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **); + +PCAP_AVAILABLE_0_8 +PCAP_API void pcap_breakloop(pcap_t *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_stats(pcap_t *, struct pcap_stat *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_setfilter(pcap_t *, struct bpf_program *); + +PCAP_AVAILABLE_0_9 +PCAP_API int pcap_setdirection(pcap_t *, pcap_direction_t); + +PCAP_AVAILABLE_0_7 +PCAP_API int pcap_getnonblock(pcap_t *, char *); + +PCAP_AVAILABLE_0_7 +PCAP_API int pcap_setnonblock(pcap_t *, int, char *); + +PCAP_AVAILABLE_0_9 +PCAP_API int pcap_inject(pcap_t *, const void *, size_t); + +PCAP_AVAILABLE_0_8 +PCAP_API int pcap_sendpacket(pcap_t *, const u_char *, int); + +PCAP_AVAILABLE_1_0 +PCAP_API const char *pcap_statustostr(int); + +PCAP_AVAILABLE_0_4 +PCAP_API const char *pcap_strerror(int); + +PCAP_AVAILABLE_0_4 +PCAP_API char *pcap_geterr(pcap_t *); + +PCAP_AVAILABLE_0_4 +PCAP_API void pcap_perror(pcap_t *, const char *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_compile(pcap_t *, struct bpf_program *, const char *, int, + bpf_u_int32); + +PCAP_AVAILABLE_0_5 +PCAP_DEPRECATED("use pcap_open_dead(), pcap_compile() and pcap_close()") +PCAP_API int pcap_compile_nopcap(int, int, struct bpf_program *, + const char *, int, bpf_u_int32); + +/* XXX - this took two arguments in 0.4 and 0.5 */ +PCAP_AVAILABLE_0_6 +PCAP_API void pcap_freecode(struct bpf_program *); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_offline_filter(const struct bpf_program *, + const struct pcap_pkthdr *, const u_char *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_datalink(pcap_t *); + +PCAP_AVAILABLE_1_0 +PCAP_API int pcap_datalink_ext(pcap_t *); + +PCAP_AVAILABLE_0_8 +PCAP_API int pcap_list_datalinks(pcap_t *, int **); + +PCAP_AVAILABLE_0_8 +PCAP_API int pcap_set_datalink(pcap_t *, int); + +PCAP_AVAILABLE_0_8 +PCAP_API void pcap_free_datalinks(int *); + +PCAP_AVAILABLE_0_8 +PCAP_API int pcap_datalink_name_to_val(const char *); + +PCAP_AVAILABLE_0_8 +PCAP_API const char *pcap_datalink_val_to_name(int); + +PCAP_AVAILABLE_0_8 +PCAP_API const char *pcap_datalink_val_to_description(int); + +PCAP_AVAILABLE_1_9 +PCAP_API const char *pcap_datalink_val_to_description_or_dlt(int); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_snapshot(pcap_t *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_is_swapped(pcap_t *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_major_version(pcap_t *); + +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_minor_version(pcap_t *); + +PCAP_AVAILABLE_1_9 +PCAP_API int pcap_bufsize(pcap_t *); + +/* XXX */ +PCAP_AVAILABLE_0_4 +PCAP_API FILE *pcap_file(pcap_t *); + +#ifdef _WIN32 +/* + * This probably shouldn't have been kept in WinPcap; most if not all + * UN*X code that used it won't work on Windows. We deprecate it; if + * anybody really needs access to whatever HANDLE may be associated + * with a pcap_t (there's no guarantee that there is one), we can add + * a Windows-only pcap_handle() API that returns the HANDLE. + */ +PCAP_AVAILABLE_0_4 +PCAP_DEPRECATED("request a 'pcap_handle' that returns a HANDLE if you need it") +PCAP_API int pcap_fileno(pcap_t *); +#else /* _WIN32 */ +PCAP_AVAILABLE_0_4 +PCAP_API int pcap_fileno(pcap_t *); +#endif /* _WIN32 */ + +#ifdef _WIN32 + PCAP_API int pcap_wsockinit(void); +#endif + +PCAP_AVAILABLE_0_4 +PCAP_API pcap_dumper_t *pcap_dump_open(pcap_t *, const char *); + +#ifdef _WIN32 + PCAP_AVAILABLE_0_9 + PCAP_API pcap_dumper_t *pcap_dump_hopen(pcap_t *, intptr_t); + + /* + * If we're building libpcap, this is an internal routine in sf-pcap.c, so + * we must not define it as a macro. + * + * If we're not building libpcap, given that the version of the C runtime + * with which libpcap was built might be different from the version + * of the C runtime with which an application using libpcap was built, + * and that a FILE structure may differ between the two versions of the + * C runtime, calls to _fileno() must use the version of _fileno() in + * the C runtime used to open the FILE *, not the version in the C + * runtime with which libpcap was built. (Maybe once the Universal CRT + * rules the world, this will cease to be a problem.) + */ + #ifndef BUILDING_PCAP + #define pcap_dump_fopen(p,f) \ + pcap_dump_hopen(p, _get_osfhandle(_fileno(f))) + #endif +#else /*_WIN32*/ + PCAP_AVAILABLE_0_9 + PCAP_API pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp); +#endif /*_WIN32*/ + +PCAP_AVAILABLE_1_7 +PCAP_API pcap_dumper_t *pcap_dump_open_append(pcap_t *, const char *); + +PCAP_AVAILABLE_0_8 +PCAP_API FILE *pcap_dump_file(pcap_dumper_t *); + +PCAP_AVAILABLE_0_9 +PCAP_API long pcap_dump_ftell(pcap_dumper_t *); + +PCAP_AVAILABLE_1_9 +PCAP_API int64_t pcap_dump_ftell64(pcap_dumper_t *); + +PCAP_AVAILABLE_0_8 +PCAP_API int pcap_dump_flush(pcap_dumper_t *); + +PCAP_AVAILABLE_0_4 +PCAP_API void pcap_dump_close(pcap_dumper_t *); + +PCAP_AVAILABLE_0_4 +PCAP_API void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *); + +PCAP_AVAILABLE_0_7 +PCAP_API int pcap_findalldevs(pcap_if_t **, char *); + +PCAP_AVAILABLE_0_7 +PCAP_API void pcap_freealldevs(pcap_if_t *); + +/* + * We return a pointer to the version string, rather than exporting the + * version string directly. + * + * On at least some UNIXes, if you import data from a shared library into + * a program, the data is bound into the program binary, so if the string + * in the version of the library with which the program was linked isn't + * the same as the string in the version of the library with which the + * program is being run, various undesirable things may happen (warnings, + * the string being the one from the version of the library with which the + * program was linked, or even weirder things, such as the string being the + * one from the library but being truncated). + * + * On Windows, the string is constructed at run time. + */ +PCAP_AVAILABLE_0_8 +PCAP_API const char *pcap_lib_version(void); + +#if defined(_WIN32) + + /* + * Win32 definitions + */ + + /*! + \brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit(). + */ + struct pcap_send_queue + { + u_int maxlen; /* Maximum size of the queue, in bytes. This + variable contains the size of the buffer field. */ + u_int len; /* Current size of the queue, in bytes. */ + char *buffer; /* Buffer containing the packets to be sent. */ + }; + + typedef struct pcap_send_queue pcap_send_queue; + + /*! + \brief This typedef is a support for the pcap_get_airpcap_handle() function + */ + #if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_) + #define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ + typedef struct _AirpcapHandle *PAirpcapHandle; + #endif + + PCAP_API int pcap_setbuff(pcap_t *p, int dim); + PCAP_API int pcap_setmode(pcap_t *p, int mode); + PCAP_API int pcap_setmintocopy(pcap_t *p, int size); + + PCAP_API HANDLE pcap_getevent(pcap_t *p); + + PCAP_AVAILABLE_1_8 + PCAP_API int pcap_oid_get_request(pcap_t *, bpf_u_int32, void *, size_t *); + + PCAP_AVAILABLE_1_8 + PCAP_API int pcap_oid_set_request(pcap_t *, bpf_u_int32, const void *, size_t *); + + PCAP_API pcap_send_queue* pcap_sendqueue_alloc(u_int memsize); + + PCAP_API void pcap_sendqueue_destroy(pcap_send_queue* queue); + + PCAP_API int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data); + + PCAP_API u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync); + + PCAP_API struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size); + + PCAP_API int pcap_setuserbuffer(pcap_t *p, int size); + + PCAP_API int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks); + + PCAP_API int pcap_live_dump_ended(pcap_t *p, int sync); + + PCAP_API int pcap_start_oem(char* err_str, int flags); + + PCAP_API PAirpcapHandle pcap_get_airpcap_handle(pcap_t *p); + + #define MODE_CAPT 0 + #define MODE_STAT 1 + #define MODE_MON 2 + +#elif defined(MSDOS) + + /* + * MS-DOS definitions + */ + + PCAP_API int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *); + PCAP_API void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait); + PCAP_API u_long pcap_mac_packets (void); + +#else /* UN*X */ + + /* + * UN*X definitions + */ + + PCAP_AVAILABLE_0_8 + PCAP_API int pcap_get_selectable_fd(pcap_t *); + + PCAP_AVAILABLE_1_9 + PCAP_API const struct timeval *pcap_get_required_select_timeout(pcap_t *); + +#endif /* _WIN32/MSDOS/UN*X */ + +/* + * Remote capture definitions. + * + * These routines are only present if libpcap has been configured to + * include remote capture support. + */ + +/* + * The maximum buffer size in which address, port, interface names are kept. + * + * In case the adapter name or such is larger than this value, it is truncated. + * This is not used by the user; however it must be aware that an hostname / interface + * name longer than this value will be truncated. + */ +#define PCAP_BUF_SIZE 1024 + +/* + * The type of input source, passed to pcap_open(). + */ +#define PCAP_SRC_FILE 2 /* local savefile */ +#define PCAP_SRC_IFLOCAL 3 /* local network interface */ +#define PCAP_SRC_IFREMOTE 4 /* interface on a remote host, using RPCAP */ + +/* + * The formats allowed by pcap_open() are the following: + * - file://path_and_filename [opens a local file] + * - rpcap://devicename [opens the selected device available on the local host, without using the RPCAP protocol] + * - rpcap://host/devicename [opens the selected device available on a remote host] + * - rpcap://host:port/devicename [opens the selected device available on a remote host, using a non-standard port for RPCAP] + * - adaptername [to open a local adapter; kept for compatibility, but it is strongly discouraged] + * - (NULL) [to open the first local adapter; kept for compatibility, but it is strongly discouraged] + * + * The formats allowed by the pcap_findalldevs_ex() are the following: + * - file://folder/ [lists all the files in the given folder] + * - rpcap:// [lists all local adapters] + * - rpcap://host:port/ [lists the devices available on a remote host] + * + * In all the above, "rpcaps://" can be substituted for "rpcap://" to enable + * SSL (if it has been compiled in). + * + * Referring to the 'host' and 'port' parameters, they can be either numeric or literal. Since + * IPv6 is fully supported, these are the allowed formats: + * + * - host (literal): e.g. host.foo.bar + * - host (numeric IPv4): e.g. 10.11.12.13 + * - host (numeric IPv4, IPv6 style): e.g. [10.11.12.13] + * - host (numeric IPv6): e.g. [1:2:3::4] + * - port: can be either numeric (e.g. '80') or literal (e.g. 'http') + * + * Here you find some allowed examples: + * - rpcap://host.foo.bar/devicename [everything literal, no port number] + * - rpcap://host.foo.bar:1234/devicename [everything literal, with port number] + * - rpcap://10.11.12.13/devicename [IPv4 numeric, no port number] + * - rpcap://10.11.12.13:1234/devicename [IPv4 numeric, with port number] + * - rpcap://[10.11.12.13]:1234/devicename [IPv4 numeric with IPv6 format, with port number] + * - rpcap://[1:2:3::4]/devicename [IPv6 numeric, no port number] + * - rpcap://[1:2:3::4]:1234/devicename [IPv6 numeric, with port number] + * - rpcap://[1:2:3::4]:http/devicename [IPv6 numeric, with literal port number] + */ + +/* + * URL schemes for capture source. + */ +/* + * This string indicates that the user wants to open a capture from a + * local file. + */ +#define PCAP_SRC_FILE_STRING "file://" +/* + * This string indicates that the user wants to open a capture from a + * network interface. This string does not necessarily involve the use + * of the RPCAP protocol. If the interface required resides on the local + * host, the RPCAP protocol is not involved and the local functions are used. + */ +#define PCAP_SRC_IF_STRING "rpcap://" + +/* + * Flags to pass to pcap_open(). + */ + +/* + * Specifies whether promiscuous mode is to be used. + */ +#define PCAP_OPENFLAG_PROMISCUOUS 0x00000001 + +/* + * Specifies, for an RPCAP capture, whether the data transfer (in + * case of a remote capture) has to be done with UDP protocol. + * + * If it is '1' if you want a UDP data connection, '0' if you want + * a TCP data connection; control connection is always TCP-based. + * A UDP connection is much lighter, but it does not guarantee that all + * the captured packets arrive to the client workstation. Moreover, + * it could be harmful in case of network congestion. + * This flag is meaningless if the source is not a remote interface. + * In that case, it is simply ignored. + */ +#define PCAP_OPENFLAG_DATATX_UDP 0x00000002 + +/* + * Specifies whether the remote probe will capture its own generated + * traffic. + * + * In case the remote probe uses the same interface to capture traffic + * and to send data back to the caller, the captured traffic includes + * the RPCAP traffic as well. If this flag is turned on, the RPCAP + * traffic is excluded from the capture, so that the trace returned + * back to the collector is does not include this traffic. + * + * Has no effect on local interfaces or savefiles. + */ +#define PCAP_OPENFLAG_NOCAPTURE_RPCAP 0x00000004 + +/* + * Specifies whether the local adapter will capture its own generated traffic. + * + * This flag tells the underlying capture driver to drop the packets + * that were sent by itself. This is useful when building applications + * such as bridges that should ignore the traffic they just sent. + * + * Supported only on Windows. + */ +#define PCAP_OPENFLAG_NOCAPTURE_LOCAL 0x00000008 + +/* + * This flag configures the adapter for maximum responsiveness. + * + * In presence of a large value for nbytes, WinPcap waits for the arrival + * of several packets before copying the data to the user. This guarantees + * a low number of system calls, i.e. lower processor usage, i.e. better + * performance, which is good for applications like sniffers. If the user + * sets the PCAP_OPENFLAG_MAX_RESPONSIVENESS flag, the capture driver will + * copy the packets as soon as the application is ready to receive them. + * This is suggested for real time applications (such as, for example, + * a bridge) that need the best responsiveness. + * + * The equivalent with pcap_create()/pcap_activate() is "immediate mode". + */ +#define PCAP_OPENFLAG_MAX_RESPONSIVENESS 0x00000010 + +/* + * Remote authentication methods. + * These are used in the 'type' member of the pcap_rmtauth structure. + */ + +/* + * NULL authentication. + * + * The 'NULL' authentication has to be equal to 'zero', so that old + * applications can just put every field of struct pcap_rmtauth to zero, + * and it does work. + */ +#define RPCAP_RMTAUTH_NULL 0 +/* + * Username/password authentication. + * + * With this type of authentication, the RPCAP protocol will use the username/ + * password provided to authenticate the user on the remote machine. If the + * authentication is successful (and the user has the right to open network + * devices) the RPCAP connection will continue; otherwise it will be dropped. + * + * *******NOTE********: unless TLS is being used, the username and password + * are sent over the network to the capture server *IN CLEAR TEXT*. Don't + * use this, without TLS (i.e., with rpcap:// rather than rpcaps://) on + * a network that you don't completely control! (And be *really* careful + * in your definition of "completely"!) + */ +#define RPCAP_RMTAUTH_PWD 1 + +/* + * This structure keeps the information needed to authenticate the user + * on a remote machine. + * + * The remote machine can either grant or refuse the access according + * to the information provided. + * In case the NULL authentication is required, both 'username' and + * 'password' can be NULL pointers. + * + * This structure is meaningless if the source is not a remote interface; + * in that case, the functions which requires such a structure can accept + * a NULL pointer as well. + */ +struct pcap_rmtauth +{ + /* + * \brief Type of the authentication required. + * + * In order to provide maximum flexibility, we can support different types + * of authentication based on the value of this 'type' variable. The currently + * supported authentication methods are defined into the + * \link remote_auth_methods Remote Authentication Methods Section\endlink. + */ + int type; + /* + * \brief Zero-terminated string containing the username that has to be + * used on the remote machine for authentication. + * + * This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication + * and it can be NULL. + */ + char *username; + /* + * \brief Zero-terminated string containing the password that has to be + * used on the remote machine for authentication. + * + * This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication + * and it can be NULL. + */ + char *password; +}; + +/* + * This routine can open a savefile, a local device, or a device on + * a remote machine running an RPCAP server. + * + * For opening a savefile, the pcap_open_offline routines can be used, + * and will work just as well; code using them will work on more + * platforms than code using pcap_open() to open savefiles. + * + * For opening a local device, pcap_open_live() can be used; it supports + * most of the capabilities that pcap_open() supports, and code using it + * will work on more platforms than code using pcap_open(). pcap_create() + * and pcap_activate() can also be used; they support all capabilities + * that pcap_open() supports, except for the Windows-only + * PCAP_OPENFLAG_NOCAPTURE_LOCAL, and support additional capabilities. + * + * For opening a remote capture, pcap_open() is currently the only + * API available. + */ +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API pcap_t *pcap_open(const char *source, int snaplen, int flags, + int read_timeout, struct pcap_rmtauth *auth, char *errbuf); + +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API int pcap_createsrcstr(char *source, int type, const char *host, + const char *port, const char *name, char *errbuf); + +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API int pcap_parsesrcstr(const char *source, int *type, char *host, + char *port, char *name, char *errbuf); + +/* + * This routine can scan a directory for savefiles, list local capture + * devices, or list capture devices on a remote machine running an RPCAP + * server. + * + * For scanning for savefiles, it can be used on both UN*X systems and + * Windows systems; for each directory entry it sees, it tries to open + * the file as a savefile using pcap_open_offline(), and only includes + * it in the list of files if the open succeeds, so it filters out + * files for which the user doesn't have read permission, as well as + * files that aren't valid savefiles readable by libpcap. + * + * For listing local capture devices, it's just a wrapper around + * pcap_findalldevs(); code using pcap_findalldevs() will work on more + * platforms than code using pcap_findalldevs_ex(). + * + * For listing remote capture devices, pcap_findalldevs_ex() is currently + * the only API available. + */ +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API int pcap_findalldevs_ex(const char *source, + struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf); + +/* + * Sampling methods. + * + * These allow pcap_loop(), pcap_dispatch(), pcap_next(), and pcap_next_ex() + * to see only a sample of packets, rather than all packets. + * + * Currently, they work only on Windows local captures. + */ + +/* + * Specifies that no sampling is to be done on the current capture. + * + * In this case, no sampling algorithms are applied to the current capture. + */ +#define PCAP_SAMP_NOSAMP 0 + +/* + * Specifies that only 1 out of N packets must be returned to the user. + * + * In this case, the 'value' field of the 'pcap_samp' structure indicates the + * number of packets (minus 1) that must be discarded before one packet got + * accepted. + * In other words, if 'value = 10', the first packet is returned to the + * caller, while the following 9 are discarded. + */ +#define PCAP_SAMP_1_EVERY_N 1 + +/* + * Specifies that we have to return 1 packet every N milliseconds. + * + * In this case, the 'value' field of the 'pcap_samp' structure indicates + * the 'waiting time' in milliseconds before one packet got accepted. + * In other words, if 'value = 10', the first packet is returned to the + * caller; the next returned one will be the first packet that arrives + * when 10ms have elapsed. + */ +#define PCAP_SAMP_FIRST_AFTER_N_MS 2 + +/* + * This structure defines the information related to sampling. + * + * In case the sampling is requested, the capturing device should read + * only a subset of the packets coming from the source. The returned packets + * depend on the sampling parameters. + * + * WARNING: The sampling process is applied *after* the filtering process. + * In other words, packets are filtered first, then the sampling process + * selects a subset of the 'filtered' packets and it returns them to the + * caller. + */ +struct pcap_samp +{ + /* + * Method used for sampling; see above. + */ + int method; + + /* + * This value depends on the sampling method defined. + * For its meaning, see above. + */ + int value; +}; + +/* + * New functions. + */ +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p); + +/* + * RPCAP active mode. + */ + +/* Maximum length of an host name (needed for the RPCAP active mode) */ +#define RPCAP_HOSTLIST_SIZE 1024 + +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API PCAP_SOCKET pcap_remoteact_accept(const char *address, const char *port, + const char *hostlist, char *connectinghost, + struct pcap_rmtauth *auth, char *errbuf); + +PCAP_AVAILABLE_1_10_REMOTE +PCAP_API PCAP_SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, + const char *hostlist, char *connectinghost, + struct pcap_rmtauth *auth, int uses_ssl, char *errbuf); + +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API int pcap_remoteact_list(char *hostlist, char sep, int size, + char *errbuf); + +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API int pcap_remoteact_close(const char *host, char *errbuf); + +PCAP_AVAILABLE_1_9_REMOTE +PCAP_API void pcap_remoteact_cleanup(void); + +#ifdef __cplusplus +} +#endif + +#endif /* lib_pcap_pcap_h */ diff --git a/illumos-x86_64/usr/include/pcap/sll.h b/illumos-x86_64/usr/include/pcap/sll.h new file mode 100644 index 00000000..3d8c9020 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/sll.h @@ -0,0 +1,150 @@ +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * For captures on Linux cooked sockets, we construct a fake header + * that includes: + * + * a 2-byte "packet type" which is one of: + * + * LINUX_SLL_HOST packet was sent to us + * LINUX_SLL_BROADCAST packet was broadcast + * LINUX_SLL_MULTICAST packet was multicast + * LINUX_SLL_OTHERHOST packet was sent to somebody else + * LINUX_SLL_OUTGOING packet was sent *by* us; + * + * a 2-byte Ethernet protocol field; + * + * a 2-byte link-layer type; + * + * a 2-byte link-layer address length; + * + * an 8-byte source link-layer address, whose actual length is + * specified by the previous value. + * + * All fields except for the link-layer address are in network byte order. + * + * DO NOT change the layout of this structure, or change any of the + * LINUX_SLL_ values below. If you must change the link-layer header + * for a "cooked" Linux capture, introduce a new DLT_ type (ask + * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it + * a value that collides with a value already being used), and use the + * new header in captures of that type, so that programs that can + * handle DLT_LINUX_SLL captures will continue to handle them correctly + * without any change, and so that capture files with different headers + * can be told apart and programs that read them can dissect the + * packets in them. + */ + +#ifndef lib_pcap_sll_h +#define lib_pcap_sll_h + +#include + +/* + * A DLT_LINUX_SLL fake link-layer header. + */ +#define SLL_HDR_LEN 16 /* total header length */ +#define SLL_ADDRLEN 8 /* length of address field */ + +struct sll_header { + uint16_t sll_pkttype; /* packet type */ + uint16_t sll_hatype; /* link-layer address type */ + uint16_t sll_halen; /* link-layer address length */ + uint8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ + uint16_t sll_protocol; /* protocol */ +}; + +/* + * A DLT_LINUX_SLL2 fake link-layer header. + */ +#define SLL2_HDR_LEN 20 /* total header length */ + +struct sll2_header { + uint16_t sll2_protocol; /* protocol */ + uint16_t sll2_reserved_mbz; /* reserved - must be zero */ + uint32_t sll2_if_index; /* 1-based interface index */ + uint16_t sll2_hatype; /* link-layer address type */ + uint8_t sll2_pkttype; /* packet type */ + uint8_t sll2_halen; /* link-layer address length */ + uint8_t sll2_addr[SLL_ADDRLEN]; /* link-layer address */ +}; + +/* + * The LINUX_SLL_ values for "sll_pkttype" and LINUX_SLL2_ values for + * "sll2_pkttype"; these correspond to the PACKET_ values on Linux, + * which are defined by a header under include/uapi in the current + * kernel source, and are thus not going to change on Linux. We + * define them here so that they're available even on systems other + * than Linux. + */ +#define LINUX_SLL_HOST 0 +#define LINUX_SLL_BROADCAST 1 +#define LINUX_SLL_MULTICAST 2 +#define LINUX_SLL_OTHERHOST 3 +#define LINUX_SLL_OUTGOING 4 + +/* + * The LINUX_SLL_ values for "sll_protocol" and LINUX_SLL2_ values for + * "sll2_protocol"; these correspond to the ETH_P_ values on Linux, but + * are defined here so that they're available even on systems other than + * Linux. We assume, for now, that the ETH_P_ values won't change in + * Linux; if they do, then: + * + * if we don't translate them in "pcap-linux.c", capture files + * won't necessarily be readable if captured on a system that + * defines ETH_P_ values that don't match these values; + * + * if we do translate them in "pcap-linux.c", that makes life + * unpleasant for the BPF code generator, as the values you test + * for in the kernel aren't the values that you test for when + * reading a capture file, so the fixup code run on BPF programs + * handed to the kernel ends up having to do more work. + * + * Add other values here as necessary, for handling packet types that + * might show up on non-Ethernet, non-802.x networks. (Not all the ones + * in the Linux "if_ether.h" will, I suspect, actually show up in + * captures.) + */ +#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */ +#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */ +#define LINUX_SLL_P_CAN 0x000C /* CAN frames, with SocketCAN pseudo-headers */ +#define LINUX_SLL_P_CANFD 0x000D /* CAN FD frames, with SocketCAN pseudo-headers */ +#define LINUX_SLL_P_CANXL 0x000E /* CAN XL frames, with SocketCAN pseudo-headers */ + +#endif diff --git a/illumos-x86_64/usr/include/pcap/socket.h b/illumos-x86_64/usr/include/pcap/socket.h new file mode 100644 index 00000000..b1a864b5 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/socket.h @@ -0,0 +1,128 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lib_pcap_socket_h +#define lib_pcap_socket_h + +/* + * Some minor differences between sockets on various platforms. + * We include whatever sockets are needed for Internet-protocol + * socket access on UN*X and Windows. + */ +#ifdef _WIN32 + /* Need windef.h for defines used in winsock2.h under MingW32 */ + #ifdef __MINGW32__ + #include + #endif + #include + #include + + /*! + * \brief In Winsock, a socket handle is of type SOCKET; in UN*X, it's + * a file descriptor, and therefore a signed integer. + * We define PCAP_SOCKET to be a signed integer on UN*X and a + * SOCKET on Windows, so that it can be used on both platforms. + * + * We used to use SOCKET rather than PCAP_SOCKET, but that collided + * with other software, such as barnyard2, which had their own + * definitions of SOCKET, so we changed it to PCAP_SOCKET. + * + * On Windows, this shouldn't break any APIs, as any code using + * the two active-mode APIs that return a socket handle would + * probably be assigning their return values to a SOCKET, and + * as, on Windows, we're defining PCAP_SOCKET as SOCKET, there + * would be no type clash. + */ + #ifndef PCAP_SOCKET + #define PCAP_SOCKET SOCKET + #endif + + /* + * Winsock doesn't have this POSIX type; it's used for the + * tv_usec value of struct timeval. + */ + typedef long suseconds_t; +#else /* _WIN32 */ + #include + #include + #include /* for struct addrinfo/getaddrinfo() */ + #include /* for sockaddr_in, in BSD at least */ + #include + + /*! + * \brief In Winsock, a socket handle is of type SOCKET; in UN*Xes, + * it's a file descriptor, and therefore a signed integer. + * We define PCAP_SOCKET to be a signed integer on UN*X and a + * SOCKET on Windows, so that it can be used on both platforms. + * + * We used to use SOCKET rather than PCAP_SOCKET, but that collided + * with other software, such as barnyard2, which had their own + * definitions of SOCKET, so we changed it to PCAP_SOCKET. + * + * On UN*Xes, this might break code that uses one of the two + * active-mode APIs that return a socket handle if those programs + * were written to assign the return values of those APIs to a + * SOCKET, as we're no longer defining SOCKET. However, as + * those APIs are only provided if libpcap is built with remote + * capture support - which is not the default - and as they're + * somewhat painful to use, there's probably little if any code + * that needs to compile for UN*X and that uses them. If there + * *is* any such code, it could do + * + * #ifndef PCAP_SOCKET + * #ifdef _WIN32 + * #define PCAP_SOCKET SOCKET + * #else + * #defube PCAP_SOCKET int + * #endif + * #endif + * + * and use PCAP_SOCKET. + */ + #ifndef PCAP_SOCKET + #define PCAP_SOCKET int + #endif + + /*! + * \brief In Winsock, the error return if socket() fails is INVALID_SOCKET; + * in UN*X, it's -1. + * We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on + * both platforms. + */ + #ifndef INVALID_SOCKET + #define INVALID_SOCKET -1 + #endif +#endif /* _WIN32 */ + +#endif /* lib_pcap_socket_h */ diff --git a/illumos-x86_64/usr/include/pcap/usb.h b/illumos-x86_64/usr/include/pcap/usb.h new file mode 100644 index 00000000..48dc9064 --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/usb.h @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2006 Paolo Abeni (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Basic USB data struct + * By Paolo Abeni + */ + +#ifndef lib_pcap_usb_h +#define lib_pcap_usb_h + +#include + +/* + * possible transfer mode + */ +#define URB_TRANSFER_IN 0x80 +#define URB_ISOCHRONOUS 0x0 +#define URB_INTERRUPT 0x1 +#define URB_CONTROL 0x2 +#define URB_BULK 0x3 + +/* + * possible event type + */ +#define URB_SUBMIT 'S' +#define URB_COMPLETE 'C' +#define URB_ERROR 'E' + +/* + * USB setup header as defined in USB specification. + * Appears at the front of each Control S-type packet in DLT_USB captures. + */ +typedef struct _usb_setup { + uint8_t bmRequestType; + uint8_t bRequest; + uint16_t wValue; + uint16_t wIndex; + uint16_t wLength; +} pcap_usb_setup; + +/* + * Information from the URB for Isochronous transfers. + */ +typedef struct _iso_rec { + int32_t error_count; + int32_t numdesc; +} iso_rec; + +/* + * Header prepended by linux kernel to each event. + * Appears at the front of each packet in DLT_USB_LINUX captures. + */ +typedef struct _usb_header { + uint64_t id; + uint8_t event_type; + uint8_t transfer_type; + uint8_t endpoint_number; + uint8_t device_address; + uint16_t bus_id; + char setup_flag;/*if !=0 the urb setup header is not present*/ + char data_flag; /*if !=0 no urb data is present*/ + int64_t ts_sec; + int32_t ts_usec; + int32_t status; + uint32_t urb_len; + uint32_t data_len; /* amount of urb data really present in this event*/ + pcap_usb_setup setup; +} pcap_usb_header; + +/* + * Header prepended by linux kernel to each event for the 2.6.31 + * and later kernels; for the 2.6.21 through 2.6.30 kernels, the + * "iso_rec" information, and the fields starting with "interval" + * are zeroed-out padding fields. + * + * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures. + */ +typedef struct _usb_header_mmapped { + uint64_t id; + uint8_t event_type; + uint8_t transfer_type; + uint8_t endpoint_number; + uint8_t device_address; + uint16_t bus_id; + char setup_flag;/*if !=0 the urb setup header is not present*/ + char data_flag; /*if !=0 no urb data is present*/ + int64_t ts_sec; + int32_t ts_usec; + int32_t status; + uint32_t urb_len; + uint32_t data_len; /* amount of urb data really present in this event*/ + union { + pcap_usb_setup setup; + iso_rec iso; + } s; + int32_t interval; /* for Interrupt and Isochronous events */ + int32_t start_frame; /* for Isochronous events */ + uint32_t xfer_flags; /* copy of URB's transfer flags */ + uint32_t ndesc; /* number of isochronous descriptors */ +} pcap_usb_header_mmapped; + +/* + * Maximum number of descriptors supported. + * It's currently 128 in the Linux binary USB monitoring code. + */ +#define USB_MAXDESC 128 + +/* + * Isochronous descriptors; for isochronous transfers there might be + * one or more of these at the beginning of the packet data. The + * number of descriptors is given by the "ndesc" field in the header; + * as indicated, in older kernels that don't put the descriptors at + * the beginning of the packet, that field is zeroed out, so that field + * can be trusted even in captures from older kernels. + */ +typedef struct _usb_isodesc { + int32_t status; + uint32_t offset; + uint32_t len; + uint8_t pad[4]; +} usb_isodesc; + +#endif diff --git a/illumos-x86_64/usr/include/pcap/vlan.h b/illumos-x86_64/usr/include/pcap/vlan.h new file mode 100644 index 00000000..b29dd73c --- /dev/null +++ b/illumos-x86_64/usr/include/pcap/vlan.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lib_pcap_vlan_h +#define lib_pcap_vlan_h + +#include + +struct vlan_tag { + uint16_t vlan_tpid; /* ETH_P_8021Q */ + uint16_t vlan_tci; /* VLAN TCI */ +}; + +#define VLAN_TAG_LEN 4 + +#endif diff --git a/illumos-x86_64/usr/include/pcre.h b/illumos-x86_64/usr/include/pcre.h new file mode 100644 index 00000000..bee1fe6f --- /dev/null +++ b/illumos-x86_64/usr/include/pcre.h @@ -0,0 +1,677 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* This is the public header file for the PCRE library, to be #included by +applications that call the PCRE functions. + + Copyright (c) 1997-2014 University of Cambridge + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +#ifndef _PCRE_H +#define _PCRE_H + +/* The current PCRE version information. */ + +#define PCRE_MAJOR 8 +#define PCRE_MINOR 45 +#define PCRE_PRERELEASE +#define PCRE_DATE 2021-06-15 + +/* When an application links to a PCRE DLL in Windows, the symbols that are +imported have to be identified as such. When building PCRE, the appropriate +export setting is defined in pcre_internal.h, which includes this file. So we +don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */ + +#if defined(_WIN32) && !defined(PCRE_STATIC) +# ifndef PCRE_EXP_DECL +# define PCRE_EXP_DECL extern __declspec(dllimport) +# endif +# ifdef __cplusplus +# ifndef PCRECPP_EXP_DECL +# define PCRECPP_EXP_DECL extern __declspec(dllimport) +# endif +# ifndef PCRECPP_EXP_DEFN +# define PCRECPP_EXP_DEFN __declspec(dllimport) +# endif +# endif +#endif + +/* By default, we use the standard "extern" declarations. */ + +#ifndef PCRE_EXP_DECL +# ifdef __cplusplus +# define PCRE_EXP_DECL extern "C" +# else +# define PCRE_EXP_DECL extern +# endif +#endif + +#ifdef __cplusplus +# ifndef PCRECPP_EXP_DECL +# define PCRECPP_EXP_DECL extern +# endif +# ifndef PCRECPP_EXP_DEFN +# define PCRECPP_EXP_DEFN +# endif +#endif + +/* Have to include stdlib.h in order to ensure that size_t is defined; +it is needed here for malloc. */ + +#include + +/* Allow for C++ users */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public options. Some are compile-time only, some are run-time only, and some +are both. Most of the compile-time options are saved with the compiled regex so +that they can be inspected during studying (and therefore JIT compiling). Note +that pcre_study() has its own set of options. Originally, all the options +defined here used distinct bits. However, almost all the bits in a 32-bit word +are now used, so in order to conserve them, option bits that were previously +only recognized at matching time (i.e. by pcre_exec() or pcre_dfa_exec()) may +also be used for compile-time options that affect only compiling and are not +relevant for studying or JIT compiling. + +Some options for pcre_compile() change its behaviour but do not affect the +behaviour of the execution functions. Other options are passed through to the +execution functions and affect their behaviour, with or without affecting the +behaviour of pcre_compile(). + +Options that can be passed to pcre_compile() are tagged Cx below, with these +variants: + +C1 Affects compile only +C2 Does not affect compile; affects exec, dfa_exec +C3 Affects compile, exec, dfa_exec +C4 Affects compile, exec, dfa_exec, study +C5 Affects compile, exec, study + +Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged with +E and D, respectively. They take precedence over C3, C4, and C5 settings passed +from pcre_compile(). Those that are compatible with JIT execution are flagged +with J. */ + +#define PCRE_CASELESS 0x00000001 /* C1 */ +#define PCRE_MULTILINE 0x00000002 /* C1 */ +#define PCRE_DOTALL 0x00000004 /* C1 */ +#define PCRE_EXTENDED 0x00000008 /* C1 */ +#define PCRE_ANCHORED 0x00000010 /* C4 E D */ +#define PCRE_DOLLAR_ENDONLY 0x00000020 /* C2 */ +#define PCRE_EXTRA 0x00000040 /* C1 */ +#define PCRE_NOTBOL 0x00000080 /* E D J */ +#define PCRE_NOTEOL 0x00000100 /* E D J */ +#define PCRE_UNGREEDY 0x00000200 /* C1 */ +#define PCRE_NOTEMPTY 0x00000400 /* E D J */ +#define PCRE_UTF8 0x00000800 /* C4 ) */ +#define PCRE_UTF16 0x00000800 /* C4 ) Synonyms */ +#define PCRE_UTF32 0x00000800 /* C4 ) */ +#define PCRE_NO_AUTO_CAPTURE 0x00001000 /* C1 */ +#define PCRE_NO_UTF8_CHECK 0x00002000 /* C1 E D J ) */ +#define PCRE_NO_UTF16_CHECK 0x00002000 /* C1 E D J ) Synonyms */ +#define PCRE_NO_UTF32_CHECK 0x00002000 /* C1 E D J ) */ +#define PCRE_AUTO_CALLOUT 0x00004000 /* C1 */ +#define PCRE_PARTIAL_SOFT 0x00008000 /* E D J ) Synonyms */ +#define PCRE_PARTIAL 0x00008000 /* E D J ) */ + +/* This pair use the same bit. */ +#define PCRE_NEVER_UTF 0x00010000 /* C1 ) Overlaid */ +#define PCRE_DFA_SHORTEST 0x00010000 /* D ) Overlaid */ + +/* This pair use the same bit. */ +#define PCRE_NO_AUTO_POSSESS 0x00020000 /* C1 ) Overlaid */ +#define PCRE_DFA_RESTART 0x00020000 /* D ) Overlaid */ + +#define PCRE_FIRSTLINE 0x00040000 /* C3 */ +#define PCRE_DUPNAMES 0x00080000 /* C1 */ +#define PCRE_NEWLINE_CR 0x00100000 /* C3 E D */ +#define PCRE_NEWLINE_LF 0x00200000 /* C3 E D */ +#define PCRE_NEWLINE_CRLF 0x00300000 /* C3 E D */ +#define PCRE_NEWLINE_ANY 0x00400000 /* C3 E D */ +#define PCRE_NEWLINE_ANYCRLF 0x00500000 /* C3 E D */ +#define PCRE_BSR_ANYCRLF 0x00800000 /* C3 E D */ +#define PCRE_BSR_UNICODE 0x01000000 /* C3 E D */ +#define PCRE_JAVASCRIPT_COMPAT 0x02000000 /* C5 */ +#define PCRE_NO_START_OPTIMIZE 0x04000000 /* C2 E D ) Synonyms */ +#define PCRE_NO_START_OPTIMISE 0x04000000 /* C2 E D ) */ +#define PCRE_PARTIAL_HARD 0x08000000 /* E D J */ +#define PCRE_NOTEMPTY_ATSTART 0x10000000 /* E D J */ +#define PCRE_UCP 0x20000000 /* C3 */ + +/* Exec-time and get/set-time error codes */ + +#define PCRE_ERROR_NOMATCH (-1) +#define PCRE_ERROR_NULL (-2) +#define PCRE_ERROR_BADOPTION (-3) +#define PCRE_ERROR_BADMAGIC (-4) +#define PCRE_ERROR_UNKNOWN_OPCODE (-5) +#define PCRE_ERROR_UNKNOWN_NODE (-5) /* For backward compatibility */ +#define PCRE_ERROR_NOMEMORY (-6) +#define PCRE_ERROR_NOSUBSTRING (-7) +#define PCRE_ERROR_MATCHLIMIT (-8) +#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */ +#define PCRE_ERROR_BADUTF8 (-10) /* Same for 8/16/32 */ +#define PCRE_ERROR_BADUTF16 (-10) /* Same for 8/16/32 */ +#define PCRE_ERROR_BADUTF32 (-10) /* Same for 8/16/32 */ +#define PCRE_ERROR_BADUTF8_OFFSET (-11) /* Same for 8/16 */ +#define PCRE_ERROR_BADUTF16_OFFSET (-11) /* Same for 8/16 */ +#define PCRE_ERROR_PARTIAL (-12) +#define PCRE_ERROR_BADPARTIAL (-13) +#define PCRE_ERROR_INTERNAL (-14) +#define PCRE_ERROR_BADCOUNT (-15) +#define PCRE_ERROR_DFA_UITEM (-16) +#define PCRE_ERROR_DFA_UCOND (-17) +#define PCRE_ERROR_DFA_UMLIMIT (-18) +#define PCRE_ERROR_DFA_WSSIZE (-19) +#define PCRE_ERROR_DFA_RECURSE (-20) +#define PCRE_ERROR_RECURSIONLIMIT (-21) +#define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */ +#define PCRE_ERROR_BADNEWLINE (-23) +#define PCRE_ERROR_BADOFFSET (-24) +#define PCRE_ERROR_SHORTUTF8 (-25) +#define PCRE_ERROR_SHORTUTF16 (-25) /* Same for 8/16 */ +#define PCRE_ERROR_RECURSELOOP (-26) +#define PCRE_ERROR_JIT_STACKLIMIT (-27) +#define PCRE_ERROR_BADMODE (-28) +#define PCRE_ERROR_BADENDIANNESS (-29) +#define PCRE_ERROR_DFA_BADRESTART (-30) +#define PCRE_ERROR_JIT_BADOPTION (-31) +#define PCRE_ERROR_BADLENGTH (-32) +#define PCRE_ERROR_UNSET (-33) + +/* Specific error codes for UTF-8 validity checks */ + +#define PCRE_UTF8_ERR0 0 +#define PCRE_UTF8_ERR1 1 +#define PCRE_UTF8_ERR2 2 +#define PCRE_UTF8_ERR3 3 +#define PCRE_UTF8_ERR4 4 +#define PCRE_UTF8_ERR5 5 +#define PCRE_UTF8_ERR6 6 +#define PCRE_UTF8_ERR7 7 +#define PCRE_UTF8_ERR8 8 +#define PCRE_UTF8_ERR9 9 +#define PCRE_UTF8_ERR10 10 +#define PCRE_UTF8_ERR11 11 +#define PCRE_UTF8_ERR12 12 +#define PCRE_UTF8_ERR13 13 +#define PCRE_UTF8_ERR14 14 +#define PCRE_UTF8_ERR15 15 +#define PCRE_UTF8_ERR16 16 +#define PCRE_UTF8_ERR17 17 +#define PCRE_UTF8_ERR18 18 +#define PCRE_UTF8_ERR19 19 +#define PCRE_UTF8_ERR20 20 +#define PCRE_UTF8_ERR21 21 +#define PCRE_UTF8_ERR22 22 /* Unused (was non-character) */ + +/* Specific error codes for UTF-16 validity checks */ + +#define PCRE_UTF16_ERR0 0 +#define PCRE_UTF16_ERR1 1 +#define PCRE_UTF16_ERR2 2 +#define PCRE_UTF16_ERR3 3 +#define PCRE_UTF16_ERR4 4 /* Unused (was non-character) */ + +/* Specific error codes for UTF-32 validity checks */ + +#define PCRE_UTF32_ERR0 0 +#define PCRE_UTF32_ERR1 1 +#define PCRE_UTF32_ERR2 2 /* Unused (was non-character) */ +#define PCRE_UTF32_ERR3 3 + +/* Request types for pcre_fullinfo() */ + +#define PCRE_INFO_OPTIONS 0 +#define PCRE_INFO_SIZE 1 +#define PCRE_INFO_CAPTURECOUNT 2 +#define PCRE_INFO_BACKREFMAX 3 +#define PCRE_INFO_FIRSTBYTE 4 +#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */ +#define PCRE_INFO_FIRSTTABLE 5 +#define PCRE_INFO_LASTLITERAL 6 +#define PCRE_INFO_NAMEENTRYSIZE 7 +#define PCRE_INFO_NAMECOUNT 8 +#define PCRE_INFO_NAMETABLE 9 +#define PCRE_INFO_STUDYSIZE 10 +#define PCRE_INFO_DEFAULT_TABLES 11 +#define PCRE_INFO_OKPARTIAL 12 +#define PCRE_INFO_JCHANGED 13 +#define PCRE_INFO_HASCRORLF 14 +#define PCRE_INFO_MINLENGTH 15 +#define PCRE_INFO_JIT 16 +#define PCRE_INFO_JITSIZE 17 +#define PCRE_INFO_MAXLOOKBEHIND 18 +#define PCRE_INFO_FIRSTCHARACTER 19 +#define PCRE_INFO_FIRSTCHARACTERFLAGS 20 +#define PCRE_INFO_REQUIREDCHAR 21 +#define PCRE_INFO_REQUIREDCHARFLAGS 22 +#define PCRE_INFO_MATCHLIMIT 23 +#define PCRE_INFO_RECURSIONLIMIT 24 +#define PCRE_INFO_MATCH_EMPTY 25 + +/* Request types for pcre_config(). Do not re-arrange, in order to remain +compatible. */ + +#define PCRE_CONFIG_UTF8 0 +#define PCRE_CONFIG_NEWLINE 1 +#define PCRE_CONFIG_LINK_SIZE 2 +#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3 +#define PCRE_CONFIG_MATCH_LIMIT 4 +#define PCRE_CONFIG_STACKRECURSE 5 +#define PCRE_CONFIG_UNICODE_PROPERTIES 6 +#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7 +#define PCRE_CONFIG_BSR 8 +#define PCRE_CONFIG_JIT 9 +#define PCRE_CONFIG_UTF16 10 +#define PCRE_CONFIG_JITTARGET 11 +#define PCRE_CONFIG_UTF32 12 +#define PCRE_CONFIG_PARENS_LIMIT 13 + +/* Request types for pcre_study(). Do not re-arrange, in order to remain +compatible. */ + +#define PCRE_STUDY_JIT_COMPILE 0x0001 +#define PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE 0x0002 +#define PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE 0x0004 +#define PCRE_STUDY_EXTRA_NEEDED 0x0008 + +/* Bit flags for the pcre[16|32]_extra structure. Do not re-arrange or redefine +these bits, just add new ones on the end, in order to remain compatible. */ + +#define PCRE_EXTRA_STUDY_DATA 0x0001 +#define PCRE_EXTRA_MATCH_LIMIT 0x0002 +#define PCRE_EXTRA_CALLOUT_DATA 0x0004 +#define PCRE_EXTRA_TABLES 0x0008 +#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010 +#define PCRE_EXTRA_MARK 0x0020 +#define PCRE_EXTRA_EXECUTABLE_JIT 0x0040 + +/* Types */ + +struct real_pcre8_or_16; /* declaration; the definition is private */ +typedef struct real_pcre8_or_16 pcre; + +struct real_pcre8_or_16; /* declaration; the definition is private */ +typedef struct real_pcre8_or_16 pcre16; + +struct real_pcre32; /* declaration; the definition is private */ +typedef struct real_pcre32 pcre32; + +struct real_pcre_jit_stack; /* declaration; the definition is private */ +typedef struct real_pcre_jit_stack pcre_jit_stack; + +struct real_pcre16_jit_stack; /* declaration; the definition is private */ +typedef struct real_pcre16_jit_stack pcre16_jit_stack; + +struct real_pcre32_jit_stack; /* declaration; the definition is private */ +typedef struct real_pcre32_jit_stack pcre32_jit_stack; + +/* If PCRE is compiled with 16 bit character support, PCRE_UCHAR16 must contain +a 16 bit wide signed data type. Otherwise it can be a dummy data type since +pcre16 functions are not implemented. There is a check for this in pcre_internal.h. */ +#ifndef PCRE_UCHAR16 +#define PCRE_UCHAR16 unsigned short +#endif + +#ifndef PCRE_SPTR16 +#define PCRE_SPTR16 const PCRE_UCHAR16 * +#endif + +/* If PCRE is compiled with 32 bit character support, PCRE_UCHAR32 must contain +a 32 bit wide signed data type. Otherwise it can be a dummy data type since +pcre32 functions are not implemented. There is a check for this in pcre_internal.h. */ +#ifndef PCRE_UCHAR32 +#define PCRE_UCHAR32 unsigned int +#endif + +#ifndef PCRE_SPTR32 +#define PCRE_SPTR32 const PCRE_UCHAR32 * +#endif + +/* When PCRE is compiled as a C++ library, the subject pointer type can be +replaced with a custom type. For conventional use, the public interface is a +const char *. */ + +#ifndef PCRE_SPTR +#define PCRE_SPTR const char * +#endif + +/* The structure for passing additional data to pcre_exec(). This is defined in +such as way as to be extensible. Always add new fields at the end, in order to +remain compatible. */ + +typedef struct pcre_extra { + unsigned long int flags; /* Bits for which fields are set */ + void *study_data; /* Opaque data from pcre_study() */ + unsigned long int match_limit; /* Maximum number of calls to match() */ + void *callout_data; /* Data passed back in callouts */ + const unsigned char *tables; /* Pointer to character tables */ + unsigned long int match_limit_recursion; /* Max recursive calls to match() */ + unsigned char **mark; /* For passing back a mark pointer */ + void *executable_jit; /* Contains a pointer to a compiled jit code */ +} pcre_extra; + +/* Same structure as above, but with 16 bit char pointers. */ + +typedef struct pcre16_extra { + unsigned long int flags; /* Bits for which fields are set */ + void *study_data; /* Opaque data from pcre_study() */ + unsigned long int match_limit; /* Maximum number of calls to match() */ + void *callout_data; /* Data passed back in callouts */ + const unsigned char *tables; /* Pointer to character tables */ + unsigned long int match_limit_recursion; /* Max recursive calls to match() */ + PCRE_UCHAR16 **mark; /* For passing back a mark pointer */ + void *executable_jit; /* Contains a pointer to a compiled jit code */ +} pcre16_extra; + +/* Same structure as above, but with 32 bit char pointers. */ + +typedef struct pcre32_extra { + unsigned long int flags; /* Bits for which fields are set */ + void *study_data; /* Opaque data from pcre_study() */ + unsigned long int match_limit; /* Maximum number of calls to match() */ + void *callout_data; /* Data passed back in callouts */ + const unsigned char *tables; /* Pointer to character tables */ + unsigned long int match_limit_recursion; /* Max recursive calls to match() */ + PCRE_UCHAR32 **mark; /* For passing back a mark pointer */ + void *executable_jit; /* Contains a pointer to a compiled jit code */ +} pcre32_extra; + +/* The structure for passing out data via the pcre_callout_function. We use a +structure so that new fields can be added on the end in future versions, +without changing the API of the function, thereby allowing old clients to work +without modification. */ + +typedef struct pcre_callout_block { + int version; /* Identifies version of block */ + /* ------------------------ Version 0 ------------------------------- */ + int callout_number; /* Number compiled into pattern */ + int *offset_vector; /* The offset vector */ + PCRE_SPTR subject; /* The subject being matched */ + int subject_length; /* The length of the subject */ + int start_match; /* Offset to start of this match attempt */ + int current_position; /* Where we currently are in the subject */ + int capture_top; /* Max current capture */ + int capture_last; /* Most recently closed capture */ + void *callout_data; /* Data passed in with the call */ + /* ------------------- Added for Version 1 -------------------------- */ + int pattern_position; /* Offset to next item in the pattern */ + int next_item_length; /* Length of next item in the pattern */ + /* ------------------- Added for Version 2 -------------------------- */ + const unsigned char *mark; /* Pointer to current mark or NULL */ + /* ------------------------------------------------------------------ */ +} pcre_callout_block; + +/* Same structure as above, but with 16 bit char pointers. */ + +typedef struct pcre16_callout_block { + int version; /* Identifies version of block */ + /* ------------------------ Version 0 ------------------------------- */ + int callout_number; /* Number compiled into pattern */ + int *offset_vector; /* The offset vector */ + PCRE_SPTR16 subject; /* The subject being matched */ + int subject_length; /* The length of the subject */ + int start_match; /* Offset to start of this match attempt */ + int current_position; /* Where we currently are in the subject */ + int capture_top; /* Max current capture */ + int capture_last; /* Most recently closed capture */ + void *callout_data; /* Data passed in with the call */ + /* ------------------- Added for Version 1 -------------------------- */ + int pattern_position; /* Offset to next item in the pattern */ + int next_item_length; /* Length of next item in the pattern */ + /* ------------------- Added for Version 2 -------------------------- */ + const PCRE_UCHAR16 *mark; /* Pointer to current mark or NULL */ + /* ------------------------------------------------------------------ */ +} pcre16_callout_block; + +/* Same structure as above, but with 32 bit char pointers. */ + +typedef struct pcre32_callout_block { + int version; /* Identifies version of block */ + /* ------------------------ Version 0 ------------------------------- */ + int callout_number; /* Number compiled into pattern */ + int *offset_vector; /* The offset vector */ + PCRE_SPTR32 subject; /* The subject being matched */ + int subject_length; /* The length of the subject */ + int start_match; /* Offset to start of this match attempt */ + int current_position; /* Where we currently are in the subject */ + int capture_top; /* Max current capture */ + int capture_last; /* Most recently closed capture */ + void *callout_data; /* Data passed in with the call */ + /* ------------------- Added for Version 1 -------------------------- */ + int pattern_position; /* Offset to next item in the pattern */ + int next_item_length; /* Length of next item in the pattern */ + /* ------------------- Added for Version 2 -------------------------- */ + const PCRE_UCHAR32 *mark; /* Pointer to current mark or NULL */ + /* ------------------------------------------------------------------ */ +} pcre32_callout_block; + +/* Indirection for store get and free functions. These can be set to +alternative malloc/free functions if required. Special ones are used in the +non-recursive case for "frames". There is also an optional callout function +that is triggered by the (?) regex item. For Virtual Pascal, these definitions +have to take another form. */ + +#ifndef VPCOMPAT +PCRE_EXP_DECL void *(*pcre_malloc)(size_t); +PCRE_EXP_DECL void (*pcre_free)(void *); +PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t); +PCRE_EXP_DECL void (*pcre_stack_free)(void *); +PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *); +PCRE_EXP_DECL int (*pcre_stack_guard)(void); + +PCRE_EXP_DECL void *(*pcre16_malloc)(size_t); +PCRE_EXP_DECL void (*pcre16_free)(void *); +PCRE_EXP_DECL void *(*pcre16_stack_malloc)(size_t); +PCRE_EXP_DECL void (*pcre16_stack_free)(void *); +PCRE_EXP_DECL int (*pcre16_callout)(pcre16_callout_block *); +PCRE_EXP_DECL int (*pcre16_stack_guard)(void); + +PCRE_EXP_DECL void *(*pcre32_malloc)(size_t); +PCRE_EXP_DECL void (*pcre32_free)(void *); +PCRE_EXP_DECL void *(*pcre32_stack_malloc)(size_t); +PCRE_EXP_DECL void (*pcre32_stack_free)(void *); +PCRE_EXP_DECL int (*pcre32_callout)(pcre32_callout_block *); +PCRE_EXP_DECL int (*pcre32_stack_guard)(void); +#else /* VPCOMPAT */ +PCRE_EXP_DECL void *pcre_malloc(size_t); +PCRE_EXP_DECL void pcre_free(void *); +PCRE_EXP_DECL void *pcre_stack_malloc(size_t); +PCRE_EXP_DECL void pcre_stack_free(void *); +PCRE_EXP_DECL int pcre_callout(pcre_callout_block *); +PCRE_EXP_DECL int pcre_stack_guard(void); + +PCRE_EXP_DECL void *pcre16_malloc(size_t); +PCRE_EXP_DECL void pcre16_free(void *); +PCRE_EXP_DECL void *pcre16_stack_malloc(size_t); +PCRE_EXP_DECL void pcre16_stack_free(void *); +PCRE_EXP_DECL int pcre16_callout(pcre16_callout_block *); +PCRE_EXP_DECL int pcre16_stack_guard(void); + +PCRE_EXP_DECL void *pcre32_malloc(size_t); +PCRE_EXP_DECL void pcre32_free(void *); +PCRE_EXP_DECL void *pcre32_stack_malloc(size_t); +PCRE_EXP_DECL void pcre32_stack_free(void *); +PCRE_EXP_DECL int pcre32_callout(pcre32_callout_block *); +PCRE_EXP_DECL int pcre32_stack_guard(void); +#endif /* VPCOMPAT */ + +/* User defined callback which provides a stack just before the match starts. */ + +typedef pcre_jit_stack *(*pcre_jit_callback)(void *); +typedef pcre16_jit_stack *(*pcre16_jit_callback)(void *); +typedef pcre32_jit_stack *(*pcre32_jit_callback)(void *); + +/* Exported PCRE functions */ + +PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *, + const unsigned char *); +PCRE_EXP_DECL pcre16 *pcre16_compile(PCRE_SPTR16, int, const char **, int *, + const unsigned char *); +PCRE_EXP_DECL pcre32 *pcre32_compile(PCRE_SPTR32, int, const char **, int *, + const unsigned char *); +PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **, + int *, const unsigned char *); +PCRE_EXP_DECL pcre16 *pcre16_compile2(PCRE_SPTR16, int, int *, const char **, + int *, const unsigned char *); +PCRE_EXP_DECL pcre32 *pcre32_compile2(PCRE_SPTR32, int, int *, const char **, + int *, const unsigned char *); +PCRE_EXP_DECL int pcre_config(int, void *); +PCRE_EXP_DECL int pcre16_config(int, void *); +PCRE_EXP_DECL int pcre32_config(int, void *); +PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *, + int *, int, const char *, char *, int); +PCRE_EXP_DECL int pcre16_copy_named_substring(const pcre16 *, PCRE_SPTR16, + int *, int, PCRE_SPTR16, PCRE_UCHAR16 *, int); +PCRE_EXP_DECL int pcre32_copy_named_substring(const pcre32 *, PCRE_SPTR32, + int *, int, PCRE_SPTR32, PCRE_UCHAR32 *, int); +PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int, + char *, int); +PCRE_EXP_DECL int pcre16_copy_substring(PCRE_SPTR16, int *, int, int, + PCRE_UCHAR16 *, int); +PCRE_EXP_DECL int pcre32_copy_substring(PCRE_SPTR32, int *, int, int, + PCRE_UCHAR32 *, int); +PCRE_EXP_DECL int pcre_dfa_exec(const pcre *, const pcre_extra *, + const char *, int, int, int, int *, int , int *, int); +PCRE_EXP_DECL int pcre16_dfa_exec(const pcre16 *, const pcre16_extra *, + PCRE_SPTR16, int, int, int, int *, int , int *, int); +PCRE_EXP_DECL int pcre32_dfa_exec(const pcre32 *, const pcre32_extra *, + PCRE_SPTR32, int, int, int, int *, int , int *, int); +PCRE_EXP_DECL int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR, + int, int, int, int *, int); +PCRE_EXP_DECL int pcre16_exec(const pcre16 *, const pcre16_extra *, + PCRE_SPTR16, int, int, int, int *, int); +PCRE_EXP_DECL int pcre32_exec(const pcre32 *, const pcre32_extra *, + PCRE_SPTR32, int, int, int, int *, int); +PCRE_EXP_DECL int pcre_jit_exec(const pcre *, const pcre_extra *, + PCRE_SPTR, int, int, int, int *, int, + pcre_jit_stack *); +PCRE_EXP_DECL int pcre16_jit_exec(const pcre16 *, const pcre16_extra *, + PCRE_SPTR16, int, int, int, int *, int, + pcre16_jit_stack *); +PCRE_EXP_DECL int pcre32_jit_exec(const pcre32 *, const pcre32_extra *, + PCRE_SPTR32, int, int, int, int *, int, + pcre32_jit_stack *); +PCRE_EXP_DECL void pcre_free_substring(const char *); +PCRE_EXP_DECL void pcre16_free_substring(PCRE_SPTR16); +PCRE_EXP_DECL void pcre32_free_substring(PCRE_SPTR32); +PCRE_EXP_DECL void pcre_free_substring_list(const char **); +PCRE_EXP_DECL void pcre16_free_substring_list(PCRE_SPTR16 *); +PCRE_EXP_DECL void pcre32_free_substring_list(PCRE_SPTR32 *); +PCRE_EXP_DECL int pcre_fullinfo(const pcre *, const pcre_extra *, int, + void *); +PCRE_EXP_DECL int pcre16_fullinfo(const pcre16 *, const pcre16_extra *, int, + void *); +PCRE_EXP_DECL int pcre32_fullinfo(const pcre32 *, const pcre32_extra *, int, + void *); +PCRE_EXP_DECL int pcre_get_named_substring(const pcre *, const char *, + int *, int, const char *, const char **); +PCRE_EXP_DECL int pcre16_get_named_substring(const pcre16 *, PCRE_SPTR16, + int *, int, PCRE_SPTR16, PCRE_SPTR16 *); +PCRE_EXP_DECL int pcre32_get_named_substring(const pcre32 *, PCRE_SPTR32, + int *, int, PCRE_SPTR32, PCRE_SPTR32 *); +PCRE_EXP_DECL int pcre_get_stringnumber(const pcre *, const char *); +PCRE_EXP_DECL int pcre16_get_stringnumber(const pcre16 *, PCRE_SPTR16); +PCRE_EXP_DECL int pcre32_get_stringnumber(const pcre32 *, PCRE_SPTR32); +PCRE_EXP_DECL int pcre_get_stringtable_entries(const pcre *, const char *, + char **, char **); +PCRE_EXP_DECL int pcre16_get_stringtable_entries(const pcre16 *, PCRE_SPTR16, + PCRE_UCHAR16 **, PCRE_UCHAR16 **); +PCRE_EXP_DECL int pcre32_get_stringtable_entries(const pcre32 *, PCRE_SPTR32, + PCRE_UCHAR32 **, PCRE_UCHAR32 **); +PCRE_EXP_DECL int pcre_get_substring(const char *, int *, int, int, + const char **); +PCRE_EXP_DECL int pcre16_get_substring(PCRE_SPTR16, int *, int, int, + PCRE_SPTR16 *); +PCRE_EXP_DECL int pcre32_get_substring(PCRE_SPTR32, int *, int, int, + PCRE_SPTR32 *); +PCRE_EXP_DECL int pcre_get_substring_list(const char *, int *, int, + const char ***); +PCRE_EXP_DECL int pcre16_get_substring_list(PCRE_SPTR16, int *, int, + PCRE_SPTR16 **); +PCRE_EXP_DECL int pcre32_get_substring_list(PCRE_SPTR32, int *, int, + PCRE_SPTR32 **); +PCRE_EXP_DECL const unsigned char *pcre_maketables(void); +PCRE_EXP_DECL const unsigned char *pcre16_maketables(void); +PCRE_EXP_DECL const unsigned char *pcre32_maketables(void); +PCRE_EXP_DECL int pcre_refcount(pcre *, int); +PCRE_EXP_DECL int pcre16_refcount(pcre16 *, int); +PCRE_EXP_DECL int pcre32_refcount(pcre32 *, int); +PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **); +PCRE_EXP_DECL pcre16_extra *pcre16_study(const pcre16 *, int, const char **); +PCRE_EXP_DECL pcre32_extra *pcre32_study(const pcre32 *, int, const char **); +PCRE_EXP_DECL void pcre_free_study(pcre_extra *); +PCRE_EXP_DECL void pcre16_free_study(pcre16_extra *); +PCRE_EXP_DECL void pcre32_free_study(pcre32_extra *); +PCRE_EXP_DECL const char *pcre_version(void); +PCRE_EXP_DECL const char *pcre16_version(void); +PCRE_EXP_DECL const char *pcre32_version(void); + +/* Utility functions for byte order swaps. */ +PCRE_EXP_DECL int pcre_pattern_to_host_byte_order(pcre *, pcre_extra *, + const unsigned char *); +PCRE_EXP_DECL int pcre16_pattern_to_host_byte_order(pcre16 *, pcre16_extra *, + const unsigned char *); +PCRE_EXP_DECL int pcre32_pattern_to_host_byte_order(pcre32 *, pcre32_extra *, + const unsigned char *); +PCRE_EXP_DECL int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *, + PCRE_SPTR16, int, int *, int); +PCRE_EXP_DECL int pcre32_utf32_to_host_byte_order(PCRE_UCHAR32 *, + PCRE_SPTR32, int, int *, int); + +/* JIT compiler related functions. */ + +PCRE_EXP_DECL pcre_jit_stack *pcre_jit_stack_alloc(int, int); +PCRE_EXP_DECL pcre16_jit_stack *pcre16_jit_stack_alloc(int, int); +PCRE_EXP_DECL pcre32_jit_stack *pcre32_jit_stack_alloc(int, int); +PCRE_EXP_DECL void pcre_jit_stack_free(pcre_jit_stack *); +PCRE_EXP_DECL void pcre16_jit_stack_free(pcre16_jit_stack *); +PCRE_EXP_DECL void pcre32_jit_stack_free(pcre32_jit_stack *); +PCRE_EXP_DECL void pcre_assign_jit_stack(pcre_extra *, + pcre_jit_callback, void *); +PCRE_EXP_DECL void pcre16_assign_jit_stack(pcre16_extra *, + pcre16_jit_callback, void *); +PCRE_EXP_DECL void pcre32_assign_jit_stack(pcre32_extra *, + pcre32_jit_callback, void *); +PCRE_EXP_DECL void pcre_jit_free_unused_memory(void); +PCRE_EXP_DECL void pcre16_jit_free_unused_memory(void); +PCRE_EXP_DECL void pcre32_jit_free_unused_memory(void); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* End of pcre.h */ diff --git a/illumos-x86_64/usr/include/pcre/pcre.h b/illumos-x86_64/usr/include/pcre/pcre.h new file mode 120000 index 00000000..5818b038 --- /dev/null +++ b/illumos-x86_64/usr/include/pcre/pcre.h @@ -0,0 +1 @@ +../pcre.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/pcre/pcre_scanner.h b/illumos-x86_64/usr/include/pcre/pcre_scanner.h new file mode 120000 index 00000000..83d976c6 --- /dev/null +++ b/illumos-x86_64/usr/include/pcre/pcre_scanner.h @@ -0,0 +1 @@ +../pcre_scanner.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/pcre/pcre_stringpiece.h b/illumos-x86_64/usr/include/pcre/pcre_stringpiece.h new file mode 120000 index 00000000..db8e3fe3 --- /dev/null +++ b/illumos-x86_64/usr/include/pcre/pcre_stringpiece.h @@ -0,0 +1 @@ +../pcre_stringpiece.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/pcre/pcrecpp.h b/illumos-x86_64/usr/include/pcre/pcrecpp.h new file mode 120000 index 00000000..e75ac36d --- /dev/null +++ b/illumos-x86_64/usr/include/pcre/pcrecpp.h @@ -0,0 +1 @@ +../pcrecpp.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/pcre/pcrecpparg.h b/illumos-x86_64/usr/include/pcre/pcrecpparg.h new file mode 120000 index 00000000..1a371cac --- /dev/null +++ b/illumos-x86_64/usr/include/pcre/pcrecpparg.h @@ -0,0 +1 @@ +../pcrecpparg.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/pcre/pcreposix.h b/illumos-x86_64/usr/include/pcre/pcreposix.h new file mode 120000 index 00000000..8a690887 --- /dev/null +++ b/illumos-x86_64/usr/include/pcre/pcreposix.h @@ -0,0 +1 @@ +../pcreposix.h \ No newline at end of file diff --git a/illumos-x86_64/usr/include/pcre2.h b/illumos-x86_64/usr/include/pcre2.h new file mode 100644 index 00000000..a6c739fb --- /dev/null +++ b/illumos-x86_64/usr/include/pcre2.h @@ -0,0 +1,1069 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* This is the public header file for the PCRE library, second API, to be +#included by applications that call PCRE2 functions. + + Copyright (c) 2016-2024 University of Cambridge + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +#ifndef PCRE2_H_IDEMPOTENT_GUARD +#define PCRE2_H_IDEMPOTENT_GUARD + +/* The current PCRE version information. */ + +#define PCRE2_MAJOR 10 +#define PCRE2_MINOR 46 +#define PCRE2_PRERELEASE +#define PCRE2_DATE 2025-08-27 + +/* When an application links to a PCRE DLL in Windows, the symbols that are +imported have to be identified as such. When building PCRE2, the appropriate +export setting is defined in pcre2_internal.h, which includes this file. So we +don't change existing definitions of PCRE2_EXP_DECL. */ + +#if defined(_WIN32) && !defined(PCRE2_STATIC) +# ifndef PCRE2_EXP_DECL +# define PCRE2_EXP_DECL extern __declspec(dllimport) +# endif +#endif + +/* By default, we use the standard "extern" declarations. */ + +#ifndef PCRE2_EXP_DECL +# ifdef __cplusplus +# define PCRE2_EXP_DECL extern "C" +# else +# define PCRE2_EXP_DECL extern +# endif +#endif + +/* When compiling with the MSVC compiler, it is sometimes necessary to include +a "calling convention" before exported function names. (This is secondhand +information; I know nothing about MSVC myself). For example, something like + + void __cdecl function(....) + +might be needed. In order so make this easy, all the exported functions have +PCRE2_CALL_CONVENTION just before their names. It is rarely needed; if not +set, we ensure here that it has no effect. */ + +#ifndef PCRE2_CALL_CONVENTION +#define PCRE2_CALL_CONVENTION +#endif + +/* Have to include limits.h, stdlib.h, and inttypes.h to ensure that size_t and +uint8_t, UCHAR_MAX, etc are defined. Some systems that do have inttypes.h do +not have stdint.h, which is why we use inttypes.h, which according to the C +standard is a superset of stdint.h. If inttypes.h is not available the build +will break and the relevant values must be provided by some other means. */ + +#include +#include +#include + +/* Allow for C++ users compiling this directly. */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* The following option bits can be passed to pcre2_compile(), pcre2_match(), +or pcre2_dfa_match(). PCRE2_NO_UTF_CHECK affects only the function to which it +is passed. Put these bits at the most significant end of the options word so +others can be added next to them */ + +#define PCRE2_ANCHORED 0x80000000u +#define PCRE2_NO_UTF_CHECK 0x40000000u +#define PCRE2_ENDANCHORED 0x20000000u + +/* The following option bits can be passed only to pcre2_compile(). However, +they may affect compilation, JIT compilation, and/or interpretive execution. +The following tags indicate which: + +C alters what is compiled by pcre2_compile() +J alters what is compiled by pcre2_jit_compile() +M is inspected during pcre2_match() execution +D is inspected during pcre2_dfa_match() execution +*/ + +#define PCRE2_ALLOW_EMPTY_CLASS 0x00000001u /* C */ +#define PCRE2_ALT_BSUX 0x00000002u /* C */ +#define PCRE2_AUTO_CALLOUT 0x00000004u /* C */ +#define PCRE2_CASELESS 0x00000008u /* C */ +#define PCRE2_DOLLAR_ENDONLY 0x00000010u /* J M D */ +#define PCRE2_DOTALL 0x00000020u /* C */ +#define PCRE2_DUPNAMES 0x00000040u /* C */ +#define PCRE2_EXTENDED 0x00000080u /* C */ +#define PCRE2_FIRSTLINE 0x00000100u /* J M D */ +#define PCRE2_MATCH_UNSET_BACKREF 0x00000200u /* C J M */ +#define PCRE2_MULTILINE 0x00000400u /* C */ +#define PCRE2_NEVER_UCP 0x00000800u /* C */ +#define PCRE2_NEVER_UTF 0x00001000u /* C */ +#define PCRE2_NO_AUTO_CAPTURE 0x00002000u /* C */ +#define PCRE2_NO_AUTO_POSSESS 0x00004000u /* C */ +#define PCRE2_NO_DOTSTAR_ANCHOR 0x00008000u /* C */ +#define PCRE2_NO_START_OPTIMIZE 0x00010000u /* J M D */ +#define PCRE2_UCP 0x00020000u /* C J M D */ +#define PCRE2_UNGREEDY 0x00040000u /* C */ +#define PCRE2_UTF 0x00080000u /* C J M D */ +#define PCRE2_NEVER_BACKSLASH_C 0x00100000u /* C */ +#define PCRE2_ALT_CIRCUMFLEX 0x00200000u /* J M D */ +#define PCRE2_ALT_VERBNAMES 0x00400000u /* C */ +#define PCRE2_USE_OFFSET_LIMIT 0x00800000u /* J M D */ +#define PCRE2_EXTENDED_MORE 0x01000000u /* C */ +#define PCRE2_LITERAL 0x02000000u /* C */ +#define PCRE2_MATCH_INVALID_UTF 0x04000000u /* J M D */ +#define PCRE2_ALT_EXTENDED_CLASS 0x08000000u /* C */ + +/* An additional compile options word is available in the compile context. */ + +#define PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES 0x00000001u /* C */ +#define PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL 0x00000002u /* C */ +#define PCRE2_EXTRA_MATCH_WORD 0x00000004u /* C */ +#define PCRE2_EXTRA_MATCH_LINE 0x00000008u /* C */ +#define PCRE2_EXTRA_ESCAPED_CR_IS_LF 0x00000010u /* C */ +#define PCRE2_EXTRA_ALT_BSUX 0x00000020u /* C */ +#define PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK 0x00000040u /* C */ +#define PCRE2_EXTRA_CASELESS_RESTRICT 0x00000080u /* C */ +#define PCRE2_EXTRA_ASCII_BSD 0x00000100u /* C */ +#define PCRE2_EXTRA_ASCII_BSS 0x00000200u /* C */ +#define PCRE2_EXTRA_ASCII_BSW 0x00000400u /* C */ +#define PCRE2_EXTRA_ASCII_POSIX 0x00000800u /* C */ +#define PCRE2_EXTRA_ASCII_DIGIT 0x00001000u /* C */ +#define PCRE2_EXTRA_PYTHON_OCTAL 0x00002000u /* C */ +#define PCRE2_EXTRA_NO_BS0 0x00004000u /* C */ +#define PCRE2_EXTRA_NEVER_CALLOUT 0x00008000u /* C */ +#define PCRE2_EXTRA_TURKISH_CASING 0x00010000u /* C */ + +/* These are for pcre2_jit_compile(). */ + +#define PCRE2_JIT_COMPLETE 0x00000001u /* For full matching */ +#define PCRE2_JIT_PARTIAL_SOFT 0x00000002u +#define PCRE2_JIT_PARTIAL_HARD 0x00000004u +#define PCRE2_JIT_INVALID_UTF 0x00000100u +#define PCRE2_JIT_TEST_ALLOC 0x00000200u + +/* These are for pcre2_match(), pcre2_dfa_match(), pcre2_jit_match(), and +pcre2_substitute(). Some are allowed only for one of the functions, and in +these cases it is noted below. Note that PCRE2_ANCHORED, PCRE2_ENDANCHORED and +PCRE2_NO_UTF_CHECK can also be passed to these functions (though +pcre2_jit_match() ignores the latter since it bypasses all sanity checks). */ + +#define PCRE2_NOTBOL 0x00000001u +#define PCRE2_NOTEOL 0x00000002u +#define PCRE2_NOTEMPTY 0x00000004u /* ) These two must be kept */ +#define PCRE2_NOTEMPTY_ATSTART 0x00000008u /* ) adjacent to each other. */ +#define PCRE2_PARTIAL_SOFT 0x00000010u +#define PCRE2_PARTIAL_HARD 0x00000020u +#define PCRE2_DFA_RESTART 0x00000040u /* pcre2_dfa_match() only */ +#define PCRE2_DFA_SHORTEST 0x00000080u /* pcre2_dfa_match() only */ +#define PCRE2_SUBSTITUTE_GLOBAL 0x00000100u /* pcre2_substitute() only */ +#define PCRE2_SUBSTITUTE_EXTENDED 0x00000200u /* pcre2_substitute() only */ +#define PCRE2_SUBSTITUTE_UNSET_EMPTY 0x00000400u /* pcre2_substitute() only */ +#define PCRE2_SUBSTITUTE_UNKNOWN_UNSET 0x00000800u /* pcre2_substitute() only */ +#define PCRE2_SUBSTITUTE_OVERFLOW_LENGTH 0x00001000u /* pcre2_substitute() only */ +#define PCRE2_NO_JIT 0x00002000u /* not for pcre2_dfa_match() */ +#define PCRE2_COPY_MATCHED_SUBJECT 0x00004000u +#define PCRE2_SUBSTITUTE_LITERAL 0x00008000u /* pcre2_substitute() only */ +#define PCRE2_SUBSTITUTE_MATCHED 0x00010000u /* pcre2_substitute() only */ +#define PCRE2_SUBSTITUTE_REPLACEMENT_ONLY 0x00020000u /* pcre2_substitute() only */ +#define PCRE2_DISABLE_RECURSELOOP_CHECK 0x00040000u /* not for pcre2_dfa_match() or pcre2_jit_match() */ + +/* Options for pcre2_pattern_convert(). */ + +#define PCRE2_CONVERT_UTF 0x00000001u +#define PCRE2_CONVERT_NO_UTF_CHECK 0x00000002u +#define PCRE2_CONVERT_POSIX_BASIC 0x00000004u +#define PCRE2_CONVERT_POSIX_EXTENDED 0x00000008u +#define PCRE2_CONVERT_GLOB 0x00000010u +#define PCRE2_CONVERT_GLOB_NO_WILD_SEPARATOR 0x00000030u +#define PCRE2_CONVERT_GLOB_NO_STARSTAR 0x00000050u + +/* Newline and \R settings, for use in compile contexts. The newline values +must be kept in step with values set in config.h and both sets must all be +greater than zero. */ + +#define PCRE2_NEWLINE_CR 1 +#define PCRE2_NEWLINE_LF 2 +#define PCRE2_NEWLINE_CRLF 3 +#define PCRE2_NEWLINE_ANY 4 +#define PCRE2_NEWLINE_ANYCRLF 5 +#define PCRE2_NEWLINE_NUL 6 + +#define PCRE2_BSR_UNICODE 1 +#define PCRE2_BSR_ANYCRLF 2 + +/* Error codes for pcre2_compile(). Some of these are also used by +pcre2_pattern_convert(). */ + +#define PCRE2_ERROR_END_BACKSLASH 101 +#define PCRE2_ERROR_END_BACKSLASH_C 102 +#define PCRE2_ERROR_UNKNOWN_ESCAPE 103 +#define PCRE2_ERROR_QUANTIFIER_OUT_OF_ORDER 104 +#define PCRE2_ERROR_QUANTIFIER_TOO_BIG 105 +#define PCRE2_ERROR_MISSING_SQUARE_BRACKET 106 +#define PCRE2_ERROR_ESCAPE_INVALID_IN_CLASS 107 +#define PCRE2_ERROR_CLASS_RANGE_ORDER 108 +#define PCRE2_ERROR_QUANTIFIER_INVALID 109 +#define PCRE2_ERROR_INTERNAL_UNEXPECTED_REPEAT 110 +#define PCRE2_ERROR_INVALID_AFTER_PARENS_QUERY 111 +#define PCRE2_ERROR_POSIX_CLASS_NOT_IN_CLASS 112 +#define PCRE2_ERROR_POSIX_NO_SUPPORT_COLLATING 113 +#define PCRE2_ERROR_MISSING_CLOSING_PARENTHESIS 114 +#define PCRE2_ERROR_BAD_SUBPATTERN_REFERENCE 115 +#define PCRE2_ERROR_NULL_PATTERN 116 +#define PCRE2_ERROR_BAD_OPTIONS 117 +#define PCRE2_ERROR_MISSING_COMMENT_CLOSING 118 +#define PCRE2_ERROR_PARENTHESES_NEST_TOO_DEEP 119 +#define PCRE2_ERROR_PATTERN_TOO_LARGE 120 +#define PCRE2_ERROR_HEAP_FAILED 121 +#define PCRE2_ERROR_UNMATCHED_CLOSING_PARENTHESIS 122 +#define PCRE2_ERROR_INTERNAL_CODE_OVERFLOW 123 +#define PCRE2_ERROR_MISSING_CONDITION_CLOSING 124 +#define PCRE2_ERROR_LOOKBEHIND_NOT_FIXED_LENGTH 125 +#define PCRE2_ERROR_ZERO_RELATIVE_REFERENCE 126 +#define PCRE2_ERROR_TOO_MANY_CONDITION_BRANCHES 127 +#define PCRE2_ERROR_CONDITION_ASSERTION_EXPECTED 128 +#define PCRE2_ERROR_BAD_RELATIVE_REFERENCE 129 +#define PCRE2_ERROR_UNKNOWN_POSIX_CLASS 130 +#define PCRE2_ERROR_INTERNAL_STUDY_ERROR 131 +#define PCRE2_ERROR_UNICODE_NOT_SUPPORTED 132 +#define PCRE2_ERROR_PARENTHESES_STACK_CHECK 133 +#define PCRE2_ERROR_CODE_POINT_TOO_BIG 134 +#define PCRE2_ERROR_LOOKBEHIND_TOO_COMPLICATED 135 +#define PCRE2_ERROR_LOOKBEHIND_INVALID_BACKSLASH_C 136 +#define PCRE2_ERROR_UNSUPPORTED_ESCAPE_SEQUENCE 137 +#define PCRE2_ERROR_CALLOUT_NUMBER_TOO_BIG 138 +#define PCRE2_ERROR_MISSING_CALLOUT_CLOSING 139 +#define PCRE2_ERROR_ESCAPE_INVALID_IN_VERB 140 +#define PCRE2_ERROR_UNRECOGNIZED_AFTER_QUERY_P 141 +#define PCRE2_ERROR_MISSING_NAME_TERMINATOR 142 +#define PCRE2_ERROR_DUPLICATE_SUBPATTERN_NAME 143 +#define PCRE2_ERROR_INVALID_SUBPATTERN_NAME 144 +#define PCRE2_ERROR_UNICODE_PROPERTIES_UNAVAILABLE 145 +#define PCRE2_ERROR_MALFORMED_UNICODE_PROPERTY 146 +#define PCRE2_ERROR_UNKNOWN_UNICODE_PROPERTY 147 +#define PCRE2_ERROR_SUBPATTERN_NAME_TOO_LONG 148 +#define PCRE2_ERROR_TOO_MANY_NAMED_SUBPATTERNS 149 +#define PCRE2_ERROR_CLASS_INVALID_RANGE 150 +#define PCRE2_ERROR_OCTAL_BYTE_TOO_BIG 151 +#define PCRE2_ERROR_INTERNAL_OVERRAN_WORKSPACE 152 +#define PCRE2_ERROR_INTERNAL_MISSING_SUBPATTERN 153 +#define PCRE2_ERROR_DEFINE_TOO_MANY_BRANCHES 154 +#define PCRE2_ERROR_BACKSLASH_O_MISSING_BRACE 155 +#define PCRE2_ERROR_INTERNAL_UNKNOWN_NEWLINE 156 +#define PCRE2_ERROR_BACKSLASH_G_SYNTAX 157 +#define PCRE2_ERROR_PARENS_QUERY_R_MISSING_CLOSING 158 +/* Error 159 is obsolete and should now never occur */ +#define PCRE2_ERROR_VERB_ARGUMENT_NOT_ALLOWED 159 +#define PCRE2_ERROR_VERB_UNKNOWN 160 +#define PCRE2_ERROR_SUBPATTERN_NUMBER_TOO_BIG 161 +#define PCRE2_ERROR_SUBPATTERN_NAME_EXPECTED 162 +#define PCRE2_ERROR_INTERNAL_PARSED_OVERFLOW 163 +#define PCRE2_ERROR_INVALID_OCTAL 164 +#define PCRE2_ERROR_SUBPATTERN_NAMES_MISMATCH 165 +#define PCRE2_ERROR_MARK_MISSING_ARGUMENT 166 +#define PCRE2_ERROR_INVALID_HEXADECIMAL 167 +#define PCRE2_ERROR_BACKSLASH_C_SYNTAX 168 +#define PCRE2_ERROR_BACKSLASH_K_SYNTAX 169 +#define PCRE2_ERROR_INTERNAL_BAD_CODE_LOOKBEHINDS 170 +#define PCRE2_ERROR_BACKSLASH_N_IN_CLASS 171 +#define PCRE2_ERROR_CALLOUT_STRING_TOO_LONG 172 +#define PCRE2_ERROR_UNICODE_DISALLOWED_CODE_POINT 173 +#define PCRE2_ERROR_UTF_IS_DISABLED 174 +#define PCRE2_ERROR_UCP_IS_DISABLED 175 +#define PCRE2_ERROR_VERB_NAME_TOO_LONG 176 +#define PCRE2_ERROR_BACKSLASH_U_CODE_POINT_TOO_BIG 177 +#define PCRE2_ERROR_MISSING_OCTAL_OR_HEX_DIGITS 178 +#define PCRE2_ERROR_VERSION_CONDITION_SYNTAX 179 +#define PCRE2_ERROR_INTERNAL_BAD_CODE_AUTO_POSSESS 180 +#define PCRE2_ERROR_CALLOUT_NO_STRING_DELIMITER 181 +#define PCRE2_ERROR_CALLOUT_BAD_STRING_DELIMITER 182 +#define PCRE2_ERROR_BACKSLASH_C_CALLER_DISABLED 183 +#define PCRE2_ERROR_QUERY_BARJX_NEST_TOO_DEEP 184 +#define PCRE2_ERROR_BACKSLASH_C_LIBRARY_DISABLED 185 +#define PCRE2_ERROR_PATTERN_TOO_COMPLICATED 186 +#define PCRE2_ERROR_LOOKBEHIND_TOO_LONG 187 +#define PCRE2_ERROR_PATTERN_STRING_TOO_LONG 188 +#define PCRE2_ERROR_INTERNAL_BAD_CODE 189 +#define PCRE2_ERROR_INTERNAL_BAD_CODE_IN_SKIP 190 +#define PCRE2_ERROR_NO_SURROGATES_IN_UTF16 191 +#define PCRE2_ERROR_BAD_LITERAL_OPTIONS 192 +#define PCRE2_ERROR_SUPPORTED_ONLY_IN_UNICODE 193 +#define PCRE2_ERROR_INVALID_HYPHEN_IN_OPTIONS 194 +#define PCRE2_ERROR_ALPHA_ASSERTION_UNKNOWN 195 +#define PCRE2_ERROR_SCRIPT_RUN_NOT_AVAILABLE 196 +#define PCRE2_ERROR_TOO_MANY_CAPTURES 197 +#define PCRE2_ERROR_MISSING_OCTAL_DIGIT 198 +#define PCRE2_ERROR_BACKSLASH_K_IN_LOOKAROUND 199 +#define PCRE2_ERROR_MAX_VAR_LOOKBEHIND_EXCEEDED 200 +#define PCRE2_ERROR_PATTERN_COMPILED_SIZE_TOO_BIG 201 +#define PCRE2_ERROR_OVERSIZE_PYTHON_OCTAL 202 +#define PCRE2_ERROR_CALLOUT_CALLER_DISABLED 203 +#define PCRE2_ERROR_EXTRA_CASING_REQUIRES_UNICODE 204 +#define PCRE2_ERROR_TURKISH_CASING_REQUIRES_UTF 205 +#define PCRE2_ERROR_EXTRA_CASING_INCOMPATIBLE 206 +#define PCRE2_ERROR_ECLASS_NEST_TOO_DEEP 207 +#define PCRE2_ERROR_ECLASS_INVALID_OPERATOR 208 +#define PCRE2_ERROR_ECLASS_UNEXPECTED_OPERATOR 209 +#define PCRE2_ERROR_ECLASS_EXPECTED_OPERAND 210 +#define PCRE2_ERROR_ECLASS_MIXED_OPERATORS 211 +#define PCRE2_ERROR_ECLASS_HINT_SQUARE_BRACKET 212 +#define PCRE2_ERROR_PERL_ECLASS_UNEXPECTED_EXPR 213 +#define PCRE2_ERROR_PERL_ECLASS_EMPTY_EXPR 214 +#define PCRE2_ERROR_PERL_ECLASS_MISSING_CLOSE 215 +#define PCRE2_ERROR_PERL_ECLASS_UNEXPECTED_CHAR 216 + +/* "Expected" matching error codes: no match and partial match. */ + +#define PCRE2_ERROR_NOMATCH (-1) +#define PCRE2_ERROR_PARTIAL (-2) + +/* Error codes for UTF-8 validity checks */ + +#define PCRE2_ERROR_UTF8_ERR1 (-3) +#define PCRE2_ERROR_UTF8_ERR2 (-4) +#define PCRE2_ERROR_UTF8_ERR3 (-5) +#define PCRE2_ERROR_UTF8_ERR4 (-6) +#define PCRE2_ERROR_UTF8_ERR5 (-7) +#define PCRE2_ERROR_UTF8_ERR6 (-8) +#define PCRE2_ERROR_UTF8_ERR7 (-9) +#define PCRE2_ERROR_UTF8_ERR8 (-10) +#define PCRE2_ERROR_UTF8_ERR9 (-11) +#define PCRE2_ERROR_UTF8_ERR10 (-12) +#define PCRE2_ERROR_UTF8_ERR11 (-13) +#define PCRE2_ERROR_UTF8_ERR12 (-14) +#define PCRE2_ERROR_UTF8_ERR13 (-15) +#define PCRE2_ERROR_UTF8_ERR14 (-16) +#define PCRE2_ERROR_UTF8_ERR15 (-17) +#define PCRE2_ERROR_UTF8_ERR16 (-18) +#define PCRE2_ERROR_UTF8_ERR17 (-19) +#define PCRE2_ERROR_UTF8_ERR18 (-20) +#define PCRE2_ERROR_UTF8_ERR19 (-21) +#define PCRE2_ERROR_UTF8_ERR20 (-22) +#define PCRE2_ERROR_UTF8_ERR21 (-23) + +/* Error codes for UTF-16 validity checks */ + +#define PCRE2_ERROR_UTF16_ERR1 (-24) +#define PCRE2_ERROR_UTF16_ERR2 (-25) +#define PCRE2_ERROR_UTF16_ERR3 (-26) + +/* Error codes for UTF-32 validity checks */ + +#define PCRE2_ERROR_UTF32_ERR1 (-27) +#define PCRE2_ERROR_UTF32_ERR2 (-28) + +/* Miscellaneous error codes for pcre2[_dfa]_match(), substring extraction +functions, context functions, and serializing functions. They are in numerical +order. Originally they were in alphabetical order too, but now that PCRE2 is +released, the numbers must not be changed. */ + +#define PCRE2_ERROR_BADDATA (-29) +#define PCRE2_ERROR_MIXEDTABLES (-30) /* Name was changed */ +#define PCRE2_ERROR_BADMAGIC (-31) +#define PCRE2_ERROR_BADMODE (-32) +#define PCRE2_ERROR_BADOFFSET (-33) +#define PCRE2_ERROR_BADOPTION (-34) +#define PCRE2_ERROR_BADREPLACEMENT (-35) +#define PCRE2_ERROR_BADUTFOFFSET (-36) +#define PCRE2_ERROR_CALLOUT (-37) /* Never used by PCRE2 itself */ +#define PCRE2_ERROR_DFA_BADRESTART (-38) +#define PCRE2_ERROR_DFA_RECURSE (-39) +#define PCRE2_ERROR_DFA_UCOND (-40) +#define PCRE2_ERROR_DFA_UFUNC (-41) +#define PCRE2_ERROR_DFA_UITEM (-42) +#define PCRE2_ERROR_DFA_WSSIZE (-43) +#define PCRE2_ERROR_INTERNAL (-44) +#define PCRE2_ERROR_JIT_BADOPTION (-45) +#define PCRE2_ERROR_JIT_STACKLIMIT (-46) +#define PCRE2_ERROR_MATCHLIMIT (-47) +#define PCRE2_ERROR_NOMEMORY (-48) +#define PCRE2_ERROR_NOSUBSTRING (-49) +#define PCRE2_ERROR_NOUNIQUESUBSTRING (-50) +#define PCRE2_ERROR_NULL (-51) +#define PCRE2_ERROR_RECURSELOOP (-52) +#define PCRE2_ERROR_DEPTHLIMIT (-53) +#define PCRE2_ERROR_RECURSIONLIMIT (-53) /* Obsolete synonym */ +#define PCRE2_ERROR_UNAVAILABLE (-54) +#define PCRE2_ERROR_UNSET (-55) +#define PCRE2_ERROR_BADOFFSETLIMIT (-56) +#define PCRE2_ERROR_BADREPESCAPE (-57) +#define PCRE2_ERROR_REPMISSINGBRACE (-58) +#define PCRE2_ERROR_BADSUBSTITUTION (-59) +#define PCRE2_ERROR_BADSUBSPATTERN (-60) +#define PCRE2_ERROR_TOOMANYREPLACE (-61) +#define PCRE2_ERROR_BADSERIALIZEDDATA (-62) +#define PCRE2_ERROR_HEAPLIMIT (-63) +#define PCRE2_ERROR_CONVERT_SYNTAX (-64) +#define PCRE2_ERROR_INTERNAL_DUPMATCH (-65) +#define PCRE2_ERROR_DFA_UINVALID_UTF (-66) +#define PCRE2_ERROR_INVALIDOFFSET (-67) +#define PCRE2_ERROR_JIT_UNSUPPORTED (-68) +#define PCRE2_ERROR_REPLACECASE (-69) +#define PCRE2_ERROR_TOOLARGEREPLACE (-70) + + +/* Request types for pcre2_pattern_info() */ + +#define PCRE2_INFO_ALLOPTIONS 0 +#define PCRE2_INFO_ARGOPTIONS 1 +#define PCRE2_INFO_BACKREFMAX 2 +#define PCRE2_INFO_BSR 3 +#define PCRE2_INFO_CAPTURECOUNT 4 +#define PCRE2_INFO_FIRSTCODEUNIT 5 +#define PCRE2_INFO_FIRSTCODETYPE 6 +#define PCRE2_INFO_FIRSTBITMAP 7 +#define PCRE2_INFO_HASCRORLF 8 +#define PCRE2_INFO_JCHANGED 9 +#define PCRE2_INFO_JITSIZE 10 +#define PCRE2_INFO_LASTCODEUNIT 11 +#define PCRE2_INFO_LASTCODETYPE 12 +#define PCRE2_INFO_MATCHEMPTY 13 +#define PCRE2_INFO_MATCHLIMIT 14 +#define PCRE2_INFO_MAXLOOKBEHIND 15 +#define PCRE2_INFO_MINLENGTH 16 +#define PCRE2_INFO_NAMECOUNT 17 +#define PCRE2_INFO_NAMEENTRYSIZE 18 +#define PCRE2_INFO_NAMETABLE 19 +#define PCRE2_INFO_NEWLINE 20 +#define PCRE2_INFO_DEPTHLIMIT 21 +#define PCRE2_INFO_RECURSIONLIMIT 21 /* Obsolete synonym */ +#define PCRE2_INFO_SIZE 22 +#define PCRE2_INFO_HASBACKSLASHC 23 +#define PCRE2_INFO_FRAMESIZE 24 +#define PCRE2_INFO_HEAPLIMIT 25 +#define PCRE2_INFO_EXTRAOPTIONS 26 + +/* Request types for pcre2_config(). */ + +#define PCRE2_CONFIG_BSR 0 +#define PCRE2_CONFIG_JIT 1 +#define PCRE2_CONFIG_JITTARGET 2 +#define PCRE2_CONFIG_LINKSIZE 3 +#define PCRE2_CONFIG_MATCHLIMIT 4 +#define PCRE2_CONFIG_NEWLINE 5 +#define PCRE2_CONFIG_PARENSLIMIT 6 +#define PCRE2_CONFIG_DEPTHLIMIT 7 +#define PCRE2_CONFIG_RECURSIONLIMIT 7 /* Obsolete synonym */ +#define PCRE2_CONFIG_STACKRECURSE 8 /* Obsolete */ +#define PCRE2_CONFIG_UNICODE 9 +#define PCRE2_CONFIG_UNICODE_VERSION 10 +#define PCRE2_CONFIG_VERSION 11 +#define PCRE2_CONFIG_HEAPLIMIT 12 +#define PCRE2_CONFIG_NEVER_BACKSLASH_C 13 +#define PCRE2_CONFIG_COMPILED_WIDTHS 14 +#define PCRE2_CONFIG_TABLES_LENGTH 15 + +/* Optimization directives for pcre2_set_optimize(). +For binary compatibility, only add to this list; do not renumber. */ + +#define PCRE2_OPTIMIZATION_NONE 0 +#define PCRE2_OPTIMIZATION_FULL 1 + +#define PCRE2_AUTO_POSSESS 64 +#define PCRE2_AUTO_POSSESS_OFF 65 +#define PCRE2_DOTSTAR_ANCHOR 66 +#define PCRE2_DOTSTAR_ANCHOR_OFF 67 +#define PCRE2_START_OPTIMIZE 68 +#define PCRE2_START_OPTIMIZE_OFF 69 + +/* Types used in pcre2_set_substitute_case_callout(). + +PCRE2_SUBSTITUTE_CASE_LOWER and PCRE2_SUBSTITUTE_CASE_UPPER are passed to the +callout to indicate that the case of the entire callout input should be +case-transformed. PCRE2_SUBSTITUTE_CASE_TITLE_FIRST is passed to indicate that +only the first character or glyph should be transformed to Unicode titlecase, +and the rest to lowercase. */ + +#define PCRE2_SUBSTITUTE_CASE_LOWER 1 +#define PCRE2_SUBSTITUTE_CASE_UPPER 2 +#define PCRE2_SUBSTITUTE_CASE_TITLE_FIRST 3 + +/* Types for code units in patterns and subject strings. */ + +typedef uint8_t PCRE2_UCHAR8; +typedef uint16_t PCRE2_UCHAR16; +typedef uint32_t PCRE2_UCHAR32; + +typedef const PCRE2_UCHAR8 *PCRE2_SPTR8; +typedef const PCRE2_UCHAR16 *PCRE2_SPTR16; +typedef const PCRE2_UCHAR32 *PCRE2_SPTR32; + +/* The PCRE2_SIZE type is used for all string lengths and offsets in PCRE2, +including pattern offsets for errors and subject offsets after a match. We +define special values to indicate zero-terminated strings and unset offsets in +the offset vector (ovector). */ + +#define PCRE2_SIZE size_t +#define PCRE2_SIZE_MAX SIZE_MAX +#define PCRE2_ZERO_TERMINATED (~(PCRE2_SIZE)0) +#define PCRE2_UNSET (~(PCRE2_SIZE)0) + +/* Generic types for opaque structures and JIT callback functions. These +declarations are defined in a macro that is expanded for each width later. */ + +#define PCRE2_TYPES_LIST \ +struct pcre2_real_general_context; \ +typedef struct pcre2_real_general_context pcre2_general_context; \ +\ +struct pcre2_real_compile_context; \ +typedef struct pcre2_real_compile_context pcre2_compile_context; \ +\ +struct pcre2_real_match_context; \ +typedef struct pcre2_real_match_context pcre2_match_context; \ +\ +struct pcre2_real_convert_context; \ +typedef struct pcre2_real_convert_context pcre2_convert_context; \ +\ +struct pcre2_real_code; \ +typedef struct pcre2_real_code pcre2_code; \ +\ +struct pcre2_real_match_data; \ +typedef struct pcre2_real_match_data pcre2_match_data; \ +\ +struct pcre2_real_jit_stack; \ +typedef struct pcre2_real_jit_stack pcre2_jit_stack; \ +\ +typedef pcre2_jit_stack *(*pcre2_jit_callback)(void *); + + +/* The structures for passing out data via callout functions. We use structures +so that new fields can be added on the end in future versions, without changing +the API of the function, thereby allowing old clients to work without +modification. Define the generic versions in a macro; the width-specific +versions are generated from this macro below. */ + +/* Flags for the callout_flags field. These are cleared after a callout. */ + +#define PCRE2_CALLOUT_STARTMATCH 0x00000001u /* Set for each bumpalong */ +#define PCRE2_CALLOUT_BACKTRACK 0x00000002u /* Set after a backtrack */ + +#define PCRE2_STRUCTURE_LIST \ +typedef struct pcre2_callout_block { \ + uint32_t version; /* Identifies version of block */ \ + /* ------------------------ Version 0 ------------------------------- */ \ + uint32_t callout_number; /* Number compiled into pattern */ \ + uint32_t capture_top; /* Max current capture */ \ + uint32_t capture_last; /* Most recently closed capture */ \ + PCRE2_SIZE *offset_vector; /* The offset vector */ \ + PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \ + PCRE2_SPTR subject; /* The subject being matched */ \ + PCRE2_SIZE subject_length; /* The length of the subject */ \ + PCRE2_SIZE start_match; /* Offset to start of this match attempt */ \ + PCRE2_SIZE current_position; /* Where we currently are in the subject */ \ + PCRE2_SIZE pattern_position; /* Offset to next item in the pattern */ \ + PCRE2_SIZE next_item_length; /* Length of next item in the pattern */ \ + /* ------------------- Added for Version 1 -------------------------- */ \ + PCRE2_SIZE callout_string_offset; /* Offset to string within pattern */ \ + PCRE2_SIZE callout_string_length; /* Length of string compiled into pattern */ \ + PCRE2_SPTR callout_string; /* String compiled into pattern */ \ + /* ------------------- Added for Version 2 -------------------------- */ \ + uint32_t callout_flags; /* See above for list */ \ + /* ------------------------------------------------------------------ */ \ +} pcre2_callout_block; \ +\ +typedef struct pcre2_callout_enumerate_block { \ + uint32_t version; /* Identifies version of block */ \ + /* ------------------------ Version 0 ------------------------------- */ \ + PCRE2_SIZE pattern_position; /* Offset to next item in the pattern */ \ + PCRE2_SIZE next_item_length; /* Length of next item in the pattern */ \ + uint32_t callout_number; /* Number compiled into pattern */ \ + PCRE2_SIZE callout_string_offset; /* Offset to string within pattern */ \ + PCRE2_SIZE callout_string_length; /* Length of string compiled into pattern */ \ + PCRE2_SPTR callout_string; /* String compiled into pattern */ \ + /* ------------------------------------------------------------------ */ \ +} pcre2_callout_enumerate_block; \ +\ +typedef struct pcre2_substitute_callout_block { \ + uint32_t version; /* Identifies version of block */ \ + /* ------------------------ Version 0 ------------------------------- */ \ + PCRE2_SPTR input; /* Pointer to input subject string */ \ + PCRE2_SPTR output; /* Pointer to output buffer */ \ + PCRE2_SIZE output_offsets[2]; /* Changed portion of the output */ \ + PCRE2_SIZE *ovector; /* Pointer to current ovector */ \ + uint32_t oveccount; /* Count of pairs set in ovector */ \ + uint32_t subscount; /* Substitution number */ \ + /* ------------------------------------------------------------------ */ \ +} pcre2_substitute_callout_block; + + +/* List the generic forms of all other functions in macros, which will be +expanded for each width below. Start with functions that give general +information. */ + +#define PCRE2_GENERAL_INFO_FUNCTIONS \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION pcre2_config(uint32_t, void *); + + +/* Functions for manipulating contexts. */ + +#define PCRE2_GENERAL_CONTEXT_FUNCTIONS \ +PCRE2_EXP_DECL pcre2_general_context *PCRE2_CALL_CONVENTION \ + pcre2_general_context_copy(pcre2_general_context *); \ +PCRE2_EXP_DECL pcre2_general_context *PCRE2_CALL_CONVENTION \ + pcre2_general_context_create(void *(*)(size_t, void *), \ + void (*)(void *, void *), void *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_general_context_free(pcre2_general_context *); + +#define PCRE2_COMPILE_CONTEXT_FUNCTIONS \ +PCRE2_EXP_DECL pcre2_compile_context *PCRE2_CALL_CONVENTION \ + pcre2_compile_context_copy(pcre2_compile_context *); \ +PCRE2_EXP_DECL pcre2_compile_context *PCRE2_CALL_CONVENTION \ + pcre2_compile_context_create(pcre2_general_context *);\ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_compile_context_free(pcre2_compile_context *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_bsr(pcre2_compile_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_character_tables(pcre2_compile_context *, const uint8_t *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_compile_extra_options(pcre2_compile_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_max_pattern_length(pcre2_compile_context *, PCRE2_SIZE); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_max_pattern_compiled_length(pcre2_compile_context *, PCRE2_SIZE); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_max_varlookbehind(pcre2_compile_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_newline(pcre2_compile_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_parens_nest_limit(pcre2_compile_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_compile_recursion_guard(pcre2_compile_context *, \ + int (*)(uint32_t, void *), void *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_optimize(pcre2_compile_context *, uint32_t); + +#define PCRE2_MATCH_CONTEXT_FUNCTIONS \ +PCRE2_EXP_DECL pcre2_match_context *PCRE2_CALL_CONVENTION \ + pcre2_match_context_copy(pcre2_match_context *); \ +PCRE2_EXP_DECL pcre2_match_context *PCRE2_CALL_CONVENTION \ + pcre2_match_context_create(pcre2_general_context *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_match_context_free(pcre2_match_context *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_callout(pcre2_match_context *, \ + int (*)(pcre2_callout_block *, void *), void *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_substitute_callout(pcre2_match_context *, \ + int (*)(pcre2_substitute_callout_block *, void *), void *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_substitute_case_callout(pcre2_match_context *, \ + PCRE2_SIZE (*)(PCRE2_SPTR, PCRE2_SIZE, PCRE2_UCHAR *, PCRE2_SIZE, int, \ + void *), \ + void *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_depth_limit(pcre2_match_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_heap_limit(pcre2_match_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_match_limit(pcre2_match_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_offset_limit(pcre2_match_context *, PCRE2_SIZE); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_recursion_limit(pcre2_match_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_recursion_memory_management(pcre2_match_context *, \ + void *(*)(size_t, void *), void (*)(void *, void *), void *); + +#define PCRE2_CONVERT_CONTEXT_FUNCTIONS \ +PCRE2_EXP_DECL pcre2_convert_context *PCRE2_CALL_CONVENTION \ + pcre2_convert_context_copy(pcre2_convert_context *); \ +PCRE2_EXP_DECL pcre2_convert_context *PCRE2_CALL_CONVENTION \ + pcre2_convert_context_create(pcre2_general_context *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_convert_context_free(pcre2_convert_context *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_glob_escape(pcre2_convert_context *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_set_glob_separator(pcre2_convert_context *, uint32_t); + + +/* Functions concerned with compiling a pattern to PCRE internal code. */ + +#define PCRE2_COMPILE_FUNCTIONS \ +PCRE2_EXP_DECL pcre2_code *PCRE2_CALL_CONVENTION \ + pcre2_compile(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_SIZE *, \ + pcre2_compile_context *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_code_free(pcre2_code *); \ +PCRE2_EXP_DECL pcre2_code *PCRE2_CALL_CONVENTION \ + pcre2_code_copy(const pcre2_code *); \ +PCRE2_EXP_DECL pcre2_code *PCRE2_CALL_CONVENTION \ + pcre2_code_copy_with_tables(const pcre2_code *); + + +/* Functions that give information about a compiled pattern. */ + +#define PCRE2_PATTERN_INFO_FUNCTIONS \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_pattern_info(const pcre2_code *, uint32_t, void *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_callout_enumerate(const pcre2_code *, \ + int (*)(pcre2_callout_enumerate_block *, void *), void *); + + +/* Functions for running a match and inspecting the result. */ + +#define PCRE2_MATCH_FUNCTIONS \ +PCRE2_EXP_DECL pcre2_match_data *PCRE2_CALL_CONVENTION \ + pcre2_match_data_create(uint32_t, pcre2_general_context *); \ +PCRE2_EXP_DECL pcre2_match_data *PCRE2_CALL_CONVENTION \ + pcre2_match_data_create_from_pattern(const pcre2_code *, \ + pcre2_general_context *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_dfa_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \ + uint32_t, pcre2_match_data *, pcre2_match_context *, int *, PCRE2_SIZE); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \ + uint32_t, pcre2_match_data *, pcre2_match_context *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_match_data_free(pcre2_match_data *); \ +PCRE2_EXP_DECL PCRE2_SPTR PCRE2_CALL_CONVENTION \ + pcre2_get_mark(pcre2_match_data *); \ +PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \ + pcre2_get_match_data_size(pcre2_match_data *); \ +PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \ + pcre2_get_match_data_heapframes_size(pcre2_match_data *); \ +PCRE2_EXP_DECL uint32_t PCRE2_CALL_CONVENTION \ + pcre2_get_ovector_count(pcre2_match_data *); \ +PCRE2_EXP_DECL PCRE2_SIZE *PCRE2_CALL_CONVENTION \ + pcre2_get_ovector_pointer(pcre2_match_data *); \ +PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \ + pcre2_get_startchar(pcre2_match_data *); + + +/* Convenience functions for handling matched substrings. */ + +#define PCRE2_SUBSTRING_FUNCTIONS \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_copy_byname(pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR *, \ + PCRE2_SIZE *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_copy_bynumber(pcre2_match_data *, uint32_t, PCRE2_UCHAR *, \ + PCRE2_SIZE *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_substring_free(PCRE2_UCHAR *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_get_byname(pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR **, \ + PCRE2_SIZE *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_get_bynumber(pcre2_match_data *, uint32_t, PCRE2_UCHAR **, \ + PCRE2_SIZE *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_length_byname(pcre2_match_data *, PCRE2_SPTR, PCRE2_SIZE *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_length_bynumber(pcre2_match_data *, uint32_t, PCRE2_SIZE *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_nametable_scan(const pcre2_code *, PCRE2_SPTR, PCRE2_SPTR *, \ + PCRE2_SPTR *); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_number_from_name(const pcre2_code *, PCRE2_SPTR); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_substring_list_free(PCRE2_UCHAR **); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substring_list_get(pcre2_match_data *, PCRE2_UCHAR ***, PCRE2_SIZE **); + + +/* Functions for serializing / deserializing compiled patterns. */ + +#define PCRE2_SERIALIZE_FUNCTIONS \ +PCRE2_EXP_DECL int32_t PCRE2_CALL_CONVENTION \ + pcre2_serialize_encode(const pcre2_code **, int32_t, uint8_t **, \ + PCRE2_SIZE *, pcre2_general_context *); \ +PCRE2_EXP_DECL int32_t PCRE2_CALL_CONVENTION \ + pcre2_serialize_decode(pcre2_code **, int32_t, const uint8_t *, \ + pcre2_general_context *); \ +PCRE2_EXP_DECL int32_t PCRE2_CALL_CONVENTION \ + pcre2_serialize_get_number_of_codes(const uint8_t *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_serialize_free(uint8_t *); + + +/* Convenience function for match + substitute. */ + +#define PCRE2_SUBSTITUTE_FUNCTION \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_substitute(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \ + uint32_t, pcre2_match_data *, pcre2_match_context *, PCRE2_SPTR, \ + PCRE2_SIZE, PCRE2_UCHAR *, PCRE2_SIZE *); + + +/* Functions for converting pattern source strings. */ + +#define PCRE2_CONVERT_FUNCTIONS \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_pattern_convert(PCRE2_SPTR, PCRE2_SIZE, uint32_t, PCRE2_UCHAR **, \ + PCRE2_SIZE *, pcre2_convert_context *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_converted_pattern_free(PCRE2_UCHAR *); + + +/* Functions for JIT processing */ + +#define PCRE2_JIT_FUNCTIONS \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_jit_compile(pcre2_code *, uint32_t); \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_jit_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \ + uint32_t, pcre2_match_data *, pcre2_match_context *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_jit_free_unused_memory(pcre2_general_context *); \ +PCRE2_EXP_DECL pcre2_jit_stack *PCRE2_CALL_CONVENTION \ + pcre2_jit_stack_create(size_t, size_t, pcre2_general_context *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_jit_stack_assign(pcre2_match_context *, pcre2_jit_callback, void *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_jit_stack_free(pcre2_jit_stack *); + + +/* Other miscellaneous functions. */ + +#define PCRE2_OTHER_FUNCTIONS \ +PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ + pcre2_get_error_message(int, PCRE2_UCHAR *, PCRE2_SIZE); \ +PCRE2_EXP_DECL const uint8_t *PCRE2_CALL_CONVENTION \ + pcre2_maketables(pcre2_general_context *); \ +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_maketables_free(pcre2_general_context *, const uint8_t *); + +/* Define macros that generate width-specific names from generic versions. The +three-level macro scheme is necessary to get the macros expanded when we want +them to be. First we get the width from PCRE2_LOCAL_WIDTH, which is used for +generating three versions of everything below. After that, PCRE2_SUFFIX will be +re-defined to use PCRE2_CODE_UNIT_WIDTH, for use when macros such as +pcre2_compile are called by application code. */ + +#define PCRE2_JOIN(a,b) a ## b +#define PCRE2_GLUE(a,b) PCRE2_JOIN(a,b) +#define PCRE2_SUFFIX(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH) + + +/* Data types */ + +#define PCRE2_UCHAR PCRE2_SUFFIX(PCRE2_UCHAR) +#define PCRE2_SPTR PCRE2_SUFFIX(PCRE2_SPTR) + +#define pcre2_code PCRE2_SUFFIX(pcre2_code_) +#define pcre2_jit_callback PCRE2_SUFFIX(pcre2_jit_callback_) +#define pcre2_jit_stack PCRE2_SUFFIX(pcre2_jit_stack_) + +#define pcre2_real_code PCRE2_SUFFIX(pcre2_real_code_) +#define pcre2_real_general_context PCRE2_SUFFIX(pcre2_real_general_context_) +#define pcre2_real_compile_context PCRE2_SUFFIX(pcre2_real_compile_context_) +#define pcre2_real_convert_context PCRE2_SUFFIX(pcre2_real_convert_context_) +#define pcre2_real_match_context PCRE2_SUFFIX(pcre2_real_match_context_) +#define pcre2_real_jit_stack PCRE2_SUFFIX(pcre2_real_jit_stack_) +#define pcre2_real_match_data PCRE2_SUFFIX(pcre2_real_match_data_) + + +/* Data blocks */ + +#define pcre2_callout_block PCRE2_SUFFIX(pcre2_callout_block_) +#define pcre2_callout_enumerate_block PCRE2_SUFFIX(pcre2_callout_enumerate_block_) +#define pcre2_substitute_callout_block PCRE2_SUFFIX(pcre2_substitute_callout_block_) +#define pcre2_general_context PCRE2_SUFFIX(pcre2_general_context_) +#define pcre2_compile_context PCRE2_SUFFIX(pcre2_compile_context_) +#define pcre2_convert_context PCRE2_SUFFIX(pcre2_convert_context_) +#define pcre2_match_context PCRE2_SUFFIX(pcre2_match_context_) +#define pcre2_match_data PCRE2_SUFFIX(pcre2_match_data_) + + +/* Functions: the complete list in alphabetical order */ + +#define pcre2_callout_enumerate PCRE2_SUFFIX(pcre2_callout_enumerate_) +#define pcre2_code_copy PCRE2_SUFFIX(pcre2_code_copy_) +#define pcre2_code_copy_with_tables PCRE2_SUFFIX(pcre2_code_copy_with_tables_) +#define pcre2_code_free PCRE2_SUFFIX(pcre2_code_free_) +#define pcre2_compile PCRE2_SUFFIX(pcre2_compile_) +#define pcre2_compile_context_copy PCRE2_SUFFIX(pcre2_compile_context_copy_) +#define pcre2_compile_context_create PCRE2_SUFFIX(pcre2_compile_context_create_) +#define pcre2_compile_context_free PCRE2_SUFFIX(pcre2_compile_context_free_) +#define pcre2_config PCRE2_SUFFIX(pcre2_config_) +#define pcre2_convert_context_copy PCRE2_SUFFIX(pcre2_convert_context_copy_) +#define pcre2_convert_context_create PCRE2_SUFFIX(pcre2_convert_context_create_) +#define pcre2_convert_context_free PCRE2_SUFFIX(pcre2_convert_context_free_) +#define pcre2_converted_pattern_free PCRE2_SUFFIX(pcre2_converted_pattern_free_) +#define pcre2_dfa_match PCRE2_SUFFIX(pcre2_dfa_match_) +#define pcre2_general_context_copy PCRE2_SUFFIX(pcre2_general_context_copy_) +#define pcre2_general_context_create PCRE2_SUFFIX(pcre2_general_context_create_) +#define pcre2_general_context_free PCRE2_SUFFIX(pcre2_general_context_free_) +#define pcre2_get_error_message PCRE2_SUFFIX(pcre2_get_error_message_) +#define pcre2_get_mark PCRE2_SUFFIX(pcre2_get_mark_) +#define pcre2_get_match_data_heapframes_size PCRE2_SUFFIX(pcre2_get_match_data_heapframes_size_) +#define pcre2_get_match_data_size PCRE2_SUFFIX(pcre2_get_match_data_size_) +#define pcre2_get_ovector_pointer PCRE2_SUFFIX(pcre2_get_ovector_pointer_) +#define pcre2_get_ovector_count PCRE2_SUFFIX(pcre2_get_ovector_count_) +#define pcre2_get_startchar PCRE2_SUFFIX(pcre2_get_startchar_) +#define pcre2_jit_compile PCRE2_SUFFIX(pcre2_jit_compile_) +#define pcre2_jit_match PCRE2_SUFFIX(pcre2_jit_match_) +#define pcre2_jit_free_unused_memory PCRE2_SUFFIX(pcre2_jit_free_unused_memory_) +#define pcre2_jit_stack_assign PCRE2_SUFFIX(pcre2_jit_stack_assign_) +#define pcre2_jit_stack_create PCRE2_SUFFIX(pcre2_jit_stack_create_) +#define pcre2_jit_stack_free PCRE2_SUFFIX(pcre2_jit_stack_free_) +#define pcre2_maketables PCRE2_SUFFIX(pcre2_maketables_) +#define pcre2_maketables_free PCRE2_SUFFIX(pcre2_maketables_free_) +#define pcre2_match PCRE2_SUFFIX(pcre2_match_) +#define pcre2_match_context_copy PCRE2_SUFFIX(pcre2_match_context_copy_) +#define pcre2_match_context_create PCRE2_SUFFIX(pcre2_match_context_create_) +#define pcre2_match_context_free PCRE2_SUFFIX(pcre2_match_context_free_) +#define pcre2_match_data_create PCRE2_SUFFIX(pcre2_match_data_create_) +#define pcre2_match_data_create_from_pattern PCRE2_SUFFIX(pcre2_match_data_create_from_pattern_) +#define pcre2_match_data_free PCRE2_SUFFIX(pcre2_match_data_free_) +#define pcre2_pattern_convert PCRE2_SUFFIX(pcre2_pattern_convert_) +#define pcre2_pattern_info PCRE2_SUFFIX(pcre2_pattern_info_) +#define pcre2_serialize_decode PCRE2_SUFFIX(pcre2_serialize_decode_) +#define pcre2_serialize_encode PCRE2_SUFFIX(pcre2_serialize_encode_) +#define pcre2_serialize_free PCRE2_SUFFIX(pcre2_serialize_free_) +#define pcre2_serialize_get_number_of_codes PCRE2_SUFFIX(pcre2_serialize_get_number_of_codes_) +#define pcre2_set_bsr PCRE2_SUFFIX(pcre2_set_bsr_) +#define pcre2_set_callout PCRE2_SUFFIX(pcre2_set_callout_) +#define pcre2_set_character_tables PCRE2_SUFFIX(pcre2_set_character_tables_) +#define pcre2_set_compile_extra_options PCRE2_SUFFIX(pcre2_set_compile_extra_options_) +#define pcre2_set_compile_recursion_guard PCRE2_SUFFIX(pcre2_set_compile_recursion_guard_) +#define pcre2_set_depth_limit PCRE2_SUFFIX(pcre2_set_depth_limit_) +#define pcre2_set_glob_escape PCRE2_SUFFIX(pcre2_set_glob_escape_) +#define pcre2_set_glob_separator PCRE2_SUFFIX(pcre2_set_glob_separator_) +#define pcre2_set_heap_limit PCRE2_SUFFIX(pcre2_set_heap_limit_) +#define pcre2_set_match_limit PCRE2_SUFFIX(pcre2_set_match_limit_) +#define pcre2_set_max_varlookbehind PCRE2_SUFFIX(pcre2_set_max_varlookbehind_) +#define pcre2_set_max_pattern_length PCRE2_SUFFIX(pcre2_set_max_pattern_length_) +#define pcre2_set_max_pattern_compiled_length PCRE2_SUFFIX(pcre2_set_max_pattern_compiled_length_) +#define pcre2_set_newline PCRE2_SUFFIX(pcre2_set_newline_) +#define pcre2_set_parens_nest_limit PCRE2_SUFFIX(pcre2_set_parens_nest_limit_) +#define pcre2_set_offset_limit PCRE2_SUFFIX(pcre2_set_offset_limit_) +#define pcre2_set_optimize PCRE2_SUFFIX(pcre2_set_optimize_) +#define pcre2_set_substitute_callout PCRE2_SUFFIX(pcre2_set_substitute_callout_) +#define pcre2_set_substitute_case_callout PCRE2_SUFFIX(pcre2_set_substitute_case_callout_) +#define pcre2_substitute PCRE2_SUFFIX(pcre2_substitute_) +#define pcre2_substring_copy_byname PCRE2_SUFFIX(pcre2_substring_copy_byname_) +#define pcre2_substring_copy_bynumber PCRE2_SUFFIX(pcre2_substring_copy_bynumber_) +#define pcre2_substring_free PCRE2_SUFFIX(pcre2_substring_free_) +#define pcre2_substring_get_byname PCRE2_SUFFIX(pcre2_substring_get_byname_) +#define pcre2_substring_get_bynumber PCRE2_SUFFIX(pcre2_substring_get_bynumber_) +#define pcre2_substring_length_byname PCRE2_SUFFIX(pcre2_substring_length_byname_) +#define pcre2_substring_length_bynumber PCRE2_SUFFIX(pcre2_substring_length_bynumber_) +#define pcre2_substring_list_get PCRE2_SUFFIX(pcre2_substring_list_get_) +#define pcre2_substring_list_free PCRE2_SUFFIX(pcre2_substring_list_free_) +#define pcre2_substring_nametable_scan PCRE2_SUFFIX(pcre2_substring_nametable_scan_) +#define pcre2_substring_number_from_name PCRE2_SUFFIX(pcre2_substring_number_from_name_) + +/* Keep this old function name for backwards compatibility */ +#define pcre2_set_recursion_limit PCRE2_SUFFIX(pcre2_set_recursion_limit_) + +/* Keep this obsolete function for backwards compatibility: it is now a noop. */ +#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_) + +/* Now generate all three sets of width-specific structures and function +prototypes. */ + +#define PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS \ +PCRE2_TYPES_LIST \ +PCRE2_STRUCTURE_LIST \ +PCRE2_GENERAL_INFO_FUNCTIONS \ +PCRE2_GENERAL_CONTEXT_FUNCTIONS \ +PCRE2_COMPILE_CONTEXT_FUNCTIONS \ +PCRE2_CONVERT_CONTEXT_FUNCTIONS \ +PCRE2_CONVERT_FUNCTIONS \ +PCRE2_MATCH_CONTEXT_FUNCTIONS \ +PCRE2_COMPILE_FUNCTIONS \ +PCRE2_PATTERN_INFO_FUNCTIONS \ +PCRE2_MATCH_FUNCTIONS \ +PCRE2_SUBSTRING_FUNCTIONS \ +PCRE2_SERIALIZE_FUNCTIONS \ +PCRE2_SUBSTITUTE_FUNCTION \ +PCRE2_JIT_FUNCTIONS \ +PCRE2_OTHER_FUNCTIONS + +#define PCRE2_LOCAL_WIDTH 8 +PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS +#undef PCRE2_LOCAL_WIDTH + +#define PCRE2_LOCAL_WIDTH 16 +PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS +#undef PCRE2_LOCAL_WIDTH + +#define PCRE2_LOCAL_WIDTH 32 +PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS +#undef PCRE2_LOCAL_WIDTH + +/* Undefine the list macros; they are no longer needed. */ + +#undef PCRE2_TYPES_LIST +#undef PCRE2_STRUCTURE_LIST +#undef PCRE2_GENERAL_INFO_FUNCTIONS +#undef PCRE2_GENERAL_CONTEXT_FUNCTIONS +#undef PCRE2_COMPILE_CONTEXT_FUNCTIONS +#undef PCRE2_CONVERT_CONTEXT_FUNCTIONS +#undef PCRE2_MATCH_CONTEXT_FUNCTIONS +#undef PCRE2_COMPILE_FUNCTIONS +#undef PCRE2_PATTERN_INFO_FUNCTIONS +#undef PCRE2_MATCH_FUNCTIONS +#undef PCRE2_SUBSTRING_FUNCTIONS +#undef PCRE2_SERIALIZE_FUNCTIONS +#undef PCRE2_SUBSTITUTE_FUNCTION +#undef PCRE2_JIT_FUNCTIONS +#undef PCRE2_OTHER_FUNCTIONS +#undef PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS + +/* PCRE2_CODE_UNIT_WIDTH must be defined. If it is 8, 16, or 32, redefine +PCRE2_SUFFIX to use it. If it is 0, undefine the other macros and make +PCRE2_SUFFIX a no-op. Otherwise, generate an error. */ + +#undef PCRE2_SUFFIX +#ifndef PCRE2_CODE_UNIT_WIDTH +#error PCRE2_CODE_UNIT_WIDTH must be defined before including pcre2.h. +#error Use 8, 16, or 32; or 0 for a multi-width application. +#else /* PCRE2_CODE_UNIT_WIDTH is defined */ +#if PCRE2_CODE_UNIT_WIDTH == 8 || \ + PCRE2_CODE_UNIT_WIDTH == 16 || \ + PCRE2_CODE_UNIT_WIDTH == 32 +#define PCRE2_SUFFIX(a) PCRE2_GLUE(a, PCRE2_CODE_UNIT_WIDTH) +#elif PCRE2_CODE_UNIT_WIDTH == 0 +#undef PCRE2_JOIN +#undef PCRE2_GLUE +#define PCRE2_SUFFIX(a) a +#else +#error PCRE2_CODE_UNIT_WIDTH must be 0, 8, 16, or 32. +#endif +#endif /* PCRE2_CODE_UNIT_WIDTH is defined */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PCRE2_H_IDEMPOTENT_GUARD */ + +/* End of pcre2.h */ diff --git a/illumos-x86_64/usr/include/pcre2posix.h b/illumos-x86_64/usr/include/pcre2posix.h new file mode 100644 index 00000000..cccea57e --- /dev/null +++ b/illumos-x86_64/usr/include/pcre2posix.h @@ -0,0 +1,187 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* PCRE2 is a library of functions to support regular expressions whose syntax +and semantics are as close as possible to those of the Perl 5 language. This is +the public header file to be #included by applications that call PCRE2 via the +POSIX wrapper interface. + + Written by Philip Hazel + Original API code Copyright (c) 1997-2012 University of Cambridge + New API code Copyright (c) 2016-2023 University of Cambridge + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +#ifndef PCRE2POSIX_H_IDEMPOTENT_GUARD +#define PCRE2POSIX_H_IDEMPOTENT_GUARD + +/* Have to include stdlib.h in order to ensure that size_t is defined. */ + +#include + +/* Allow for C++ users */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Options, mostly defined by POSIX, but with some extras. */ + +#define REG_ICASE 0x0001 /* Maps to PCRE2_CASELESS */ +#define REG_NEWLINE 0x0002 /* Maps to PCRE2_MULTILINE */ +#define REG_NOTBOL 0x0004 /* Maps to PCRE2_NOTBOL */ +#define REG_NOTEOL 0x0008 /* Maps to PCRE2_NOTEOL */ +#define REG_DOTALL 0x0010 /* NOT defined by POSIX; maps to PCRE2_DOTALL */ +#define REG_NOSUB 0x0020 /* Do not report what was matched */ +#define REG_UTF 0x0040 /* NOT defined by POSIX; maps to PCRE2_UTF */ +#define REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */ +#define REG_NOTEMPTY 0x0100 /* NOT defined by POSIX; maps to PCRE2_NOTEMPTY */ +#define REG_UNGREEDY 0x0200 /* NOT defined by POSIX; maps to PCRE2_UNGREEDY */ +#define REG_UCP 0x0400 /* NOT defined by POSIX; maps to PCRE2_UCP */ +#define REG_PEND 0x0800 /* GNU feature: pass end pattern by re_endp */ +#define REG_NOSPEC 0x1000 /* Maps to PCRE2_LITERAL */ + +/* This is not used by PCRE2, but by defining it we make it easier +to slot PCRE2 into existing programs that make POSIX calls. */ + +#define REG_EXTENDED 0 + +/* Error values. Not all these are relevant or used by the wrapper. */ + +enum { + REG_ASSERT = 1, /* internal error ? */ + REG_BADBR, /* invalid repeat counts in {} */ + REG_BADPAT, /* pattern error */ + REG_BADRPT, /* ? * + invalid */ + REG_EBRACE, /* unbalanced {} */ + REG_EBRACK, /* unbalanced [] */ + REG_ECOLLATE, /* collation error - not relevant */ + REG_ECTYPE, /* bad class */ + REG_EESCAPE, /* bad escape sequence */ + REG_EMPTY, /* empty expression */ + REG_EPAREN, /* unbalanced () */ + REG_ERANGE, /* bad range inside [] */ + REG_ESIZE, /* expression too big */ + REG_ESPACE, /* failed to get memory */ + REG_ESUBREG, /* bad back reference */ + REG_INVARG, /* bad argument */ + REG_NOMATCH /* match failed */ +}; + + +/* The structure representing a compiled regular expression. It is also used +for passing the pattern end pointer when REG_PEND is set. */ + +typedef struct { + void *re_pcre2_code; + void *re_match_data; + const char *re_endp; + size_t re_nsub; + size_t re_erroffset; + int re_cflags; +} regex_t; + +/* The structure in which a captured offset is returned. */ + +typedef int regoff_t; + +typedef struct { + regoff_t rm_so; + regoff_t rm_eo; +} regmatch_t; + +/* When compiling with the MSVC compiler, it is sometimes necessary to include +a "calling convention" before exported function names. (This is secondhand +information; I know nothing about MSVC myself). For example, something like + + void __cdecl function(....) + +might be needed. In order to make this easy, all the exported functions have +PCRE2_CALL_CONVENTION just before their names. It is rarely needed; if not +set, we ensure here that it has no effect. */ + +#ifndef PCRE2_CALL_CONVENTION +#define PCRE2_CALL_CONVENTION +#endif + +#ifndef PCRE2_EXPORT +#define PCRE2_EXPORT +#endif + +/* When an application links to a PCRE2 DLL in Windows, the symbols that are +imported have to be identified as such. When building PCRE2, the appropriate +export settings are needed, and are set in pcre2posix.c before including this +file. */ + +/* By default, we use the standard "extern" declarations. */ + +#ifndef PCRE2POSIX_EXP_DECL +# if defined(_WIN32) && defined(PCRE2POSIX_SHARED) && !defined(PCRE2_STATIC) +# define PCRE2POSIX_EXP_DECL extern __declspec(dllimport) +# define PCRE2POSIX_EXP_DEFN __declspec(dllimport) +# else +# define PCRE2POSIX_EXP_DECL extern PCRE2_EXPORT +# define PCRE2POSIX_EXP_DEFN +# endif +#endif + +/* The functions. The actual code is in functions with pcre2_xxx names for +uniqueness. POSIX names are provided as macros for API compatibility with POSIX +regex functions. It's done this way to ensure to they are always linked from +the PCRE2 library and not by accident from elsewhere (regex_t differs in size +elsewhere). */ + +PCRE2POSIX_EXP_DECL int PCRE2_CALL_CONVENTION pcre2_regcomp(regex_t *, const char *, int); +PCRE2POSIX_EXP_DECL int PCRE2_CALL_CONVENTION pcre2_regexec(const regex_t *, const char *, size_t, + regmatch_t *, int); +PCRE2POSIX_EXP_DECL size_t PCRE2_CALL_CONVENTION pcre2_regerror(int, const regex_t *, char *, size_t); +PCRE2POSIX_EXP_DECL void PCRE2_CALL_CONVENTION pcre2_regfree(regex_t *); + +#define regcomp pcre2_regcomp +#define regexec pcre2_regexec +#define regerror pcre2_regerror +#define regfree pcre2_regfree + +/* Debian had a patch that used different names. These are now here to save +them having to maintain their own patch, but are not documented by PCRE2. */ + +#define PCRE2regcomp pcre2_regcomp +#define PCRE2regexec pcre2_regexec +#define PCRE2regerror pcre2_regerror +#define PCRE2regfree pcre2_regfree + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PCRE2POSIX_H_IDEMPOTENT_GUARD */ + +/* End of pcre2posix.h */ diff --git a/illumos-x86_64/usr/include/pcre_scanner.h b/illumos-x86_64/usr/include/pcre_scanner.h new file mode 100644 index 00000000..5617e451 --- /dev/null +++ b/illumos-x86_64/usr/include/pcre_scanner.h @@ -0,0 +1,172 @@ +// Copyright (c) 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Sanjay Ghemawat +// +// Regular-expression based scanner for parsing an input stream. +// +// Example 1: parse a sequence of "var = number" entries from input: +// +// Scanner scanner(input); +// string var; +// int number; +// scanner.SetSkipExpression("\\s+"); // Skip any white space we encounter +// while (scanner.Consume("(\\w+) = (\\d+)", &var, &number)) { +// ...; +// } + +#ifndef _PCRE_SCANNER_H +#define _PCRE_SCANNER_H + +#include +#include +#include + +#include +#include + +namespace pcrecpp { + +class PCRECPP_EXP_DEFN Scanner { + public: + Scanner(); + explicit Scanner(const std::string& input); + ~Scanner(); + + // Return current line number. The returned line-number is + // one-based. I.e. it returns 1 + the number of consumed newlines. + // + // Note: this method may be slow. It may take time proportional to + // the size of the input. + int LineNumber() const; + + // Return the byte-offset that the scanner is looking in the + // input data; + int Offset() const; + + // Return true iff the start of the remaining input matches "re" + bool LookingAt(const RE& re) const; + + // Return true iff all of the following are true + // a. the start of the remaining input matches "re", + // b. if any arguments are supplied, matched sub-patterns can be + // parsed and stored into the arguments. + // If it returns true, it skips over the matched input and any + // following input that matches the "skip" regular expression. + bool Consume(const RE& re, + const Arg& arg0 = RE::no_arg, + const Arg& arg1 = RE::no_arg, + const Arg& arg2 = RE::no_arg + // TODO: Allow more arguments? + ); + + // Set the "skip" regular expression. If after consuming some data, + // a prefix of the input matches this RE, it is automatically + // skipped. For example, a programming language scanner would use + // a skip RE that matches white space and comments. + // + // scanner.SetSkipExpression("\\s+|//.*|/[*](.|\n)*?[*]/"); + // + // Skipping repeats as long as it succeeds. We used to let people do + // this by writing "(...)*" in the regular expression, but that added + // up to lots of recursive calls within the pcre library, so now we + // control repetition explicitly via the function call API. + // + // You can pass NULL for "re" if you do not want any data to be skipped. + void Skip(const char* re); // DEPRECATED; does *not* repeat + void SetSkipExpression(const char* re); + + // Temporarily pause "skip"ing. This + // Skip("Foo"); code ; DisableSkip(); code; EnableSkip() + // is similar to + // Skip("Foo"); code ; Skip(NULL); code ; Skip("Foo"); + // but avoids creating/deleting new RE objects. + void DisableSkip(); + + // Reenable previously paused skipping. Any prefix of the input + // that matches the skip pattern is immediately dropped. + void EnableSkip(); + + /***** Special wrappers around SetSkip() for some common idioms *****/ + + // Arranges to skip whitespace, C comments, C++ comments. + // The overall RE is a disjunction of the following REs: + // \\s whitespace + // //.*\n C++ comment + // /[*](.|\n)*?[*]/ C comment (x*? means minimal repetitions of x) + // We get repetition via the semantics of SetSkipExpression, not by using * + void SkipCXXComments() { + SetSkipExpression("\\s|//.*\n|/[*](?:\n|.)*?[*]/"); + } + + void set_save_comments(bool comments) { + save_comments_ = comments; + } + + bool save_comments() { + return save_comments_; + } + + // Append to vector ranges the comments found in the + // byte range [start,end] (inclusive) of the input data. + // Only comments that were extracted entirely within that + // range are returned: no range splitting of atomically-extracted + // comments is performed. + void GetComments(int start, int end, std::vector *ranges); + + // Append to vector ranges the comments added + // since the last time this was called. This + // functionality is provided for efficiency when + // interleaving scanning with parsing. + void GetNextComments(std::vector *ranges); + + private: + std::string data_; // All the input data + StringPiece input_; // Unprocessed input + RE* skip_; // If non-NULL, RE for skipping input + bool should_skip_; // If true, use skip_ + bool skip_repeat_; // If true, repeat skip_ as long as it works + bool save_comments_; // If true, aggregate the skip expression + + // the skipped comments + // TODO: later consider requiring that the StringPieces be added + // in order by their start position + std::vector *comments_; + + // the offset into comments_ that has been returned by GetNextComments + int comments_offset_; + + // helper function to consume *skip_ and honour + // save_comments_ + void ConsumeSkip(); +}; + +} // namespace pcrecpp + +#endif /* _PCRE_SCANNER_H */ diff --git a/illumos-x86_64/usr/include/pcre_stringpiece.h b/illumos-x86_64/usr/include/pcre_stringpiece.h new file mode 100644 index 00000000..cb94f52a --- /dev/null +++ b/illumos-x86_64/usr/include/pcre_stringpiece.h @@ -0,0 +1,180 @@ +// Copyright (c) 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Sanjay Ghemawat +// +// A string like object that points into another piece of memory. +// Useful for providing an interface that allows clients to easily +// pass in either a "const char*" or a "string". +// +// Arghh! I wish C++ literals were automatically of type "string". + +#ifndef _PCRE_STRINGPIECE_H +#define _PCRE_STRINGPIECE_H + +#include +#include +#include // for ostream forward-declaration + +#if 0 +#define HAVE_TYPE_TRAITS +#include +#elif 0 +#define HAVE_TYPE_TRAITS +#include +#endif + +#include + +namespace pcrecpp { + +using std::memcmp; +using std::strlen; +using std::string; + +class PCRECPP_EXP_DEFN StringPiece { + private: + const char* ptr_; + int length_; + + public: + // We provide non-explicit singleton constructors so users can pass + // in a "const char*" or a "string" wherever a "StringPiece" is + // expected. + StringPiece() + : ptr_(NULL), length_(0) { } + StringPiece(const char* str) + : ptr_(str), length_(static_cast(strlen(ptr_))) { } + StringPiece(const unsigned char* str) + : ptr_(reinterpret_cast(str)), + length_(static_cast(strlen(ptr_))) { } + StringPiece(const string& str) + : ptr_(str.data()), length_(static_cast(str.size())) { } + StringPiece(const char* offset, int len) + : ptr_(offset), length_(len) { } + + // data() may return a pointer to a buffer with embedded NULs, and the + // returned buffer may or may not be null terminated. Therefore it is + // typically a mistake to pass data() to a routine that expects a NUL + // terminated string. Use "as_string().c_str()" if you really need to do + // this. Or better yet, change your routine so it does not rely on NUL + // termination. + const char* data() const { return ptr_; } + int size() const { return length_; } + bool empty() const { return length_ == 0; } + + void clear() { ptr_ = NULL; length_ = 0; } + void set(const char* buffer, int len) { ptr_ = buffer; length_ = len; } + void set(const char* str) { + ptr_ = str; + length_ = static_cast(strlen(str)); + } + void set(const void* buffer, int len) { + ptr_ = reinterpret_cast(buffer); + length_ = len; + } + + char operator[](int i) const { return ptr_[i]; } + + void remove_prefix(int n) { + ptr_ += n; + length_ -= n; + } + + void remove_suffix(int n) { + length_ -= n; + } + + bool operator==(const StringPiece& x) const { + return ((length_ == x.length_) && + (memcmp(ptr_, x.ptr_, length_) == 0)); + } + bool operator!=(const StringPiece& x) const { + return !(*this == x); + } + +#define STRINGPIECE_BINARY_PREDICATE(cmp,auxcmp) \ + bool operator cmp (const StringPiece& x) const { \ + int r = memcmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_); \ + return ((r auxcmp 0) || ((r == 0) && (length_ cmp x.length_))); \ + } + STRINGPIECE_BINARY_PREDICATE(<, <); + STRINGPIECE_BINARY_PREDICATE(<=, <); + STRINGPIECE_BINARY_PREDICATE(>=, >); + STRINGPIECE_BINARY_PREDICATE(>, >); +#undef STRINGPIECE_BINARY_PREDICATE + + int compare(const StringPiece& x) const { + int r = memcmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_); + if (r == 0) { + if (length_ < x.length_) r = -1; + else if (length_ > x.length_) r = +1; + } + return r; + } + + string as_string() const { + return string(data(), size()); + } + + void CopyToString(string* target) const { + target->assign(ptr_, length_); + } + + // Does "this" start with "x" + bool starts_with(const StringPiece& x) const { + return ((length_ >= x.length_) && (memcmp(ptr_, x.ptr_, x.length_) == 0)); + } +}; + +} // namespace pcrecpp + +// ------------------------------------------------------------------ +// Functions used to create STL containers that use StringPiece +// Remember that a StringPiece's lifetime had better be less than +// that of the underlying string or char*. If it is not, then you +// cannot safely store a StringPiece into an STL container +// ------------------------------------------------------------------ + +#ifdef HAVE_TYPE_TRAITS +// This makes vector really fast for some STL implementations +template<> struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; +#endif + +// allow StringPiece to be logged +PCRECPP_EXP_DECL std::ostream& operator<<(std::ostream& o, + const pcrecpp::StringPiece& piece); + +#endif /* _PCRE_STRINGPIECE_H */ diff --git a/illumos-x86_64/usr/include/pcrecpp.h b/illumos-x86_64/usr/include/pcrecpp.h new file mode 100644 index 00000000..3e594b0d --- /dev/null +++ b/illumos-x86_64/usr/include/pcrecpp.h @@ -0,0 +1,710 @@ +// Copyright (c) 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Sanjay Ghemawat +// Support for PCRE_XXX modifiers added by Giuseppe Maxia, July 2005 + +#ifndef _PCRECPP_H +#define _PCRECPP_H + +// C++ interface to the pcre regular-expression library. RE supports +// Perl-style regular expressions (with extensions like \d, \w, \s, +// ...). +// +// ----------------------------------------------------------------------- +// REGEXP SYNTAX: +// +// This module is part of the pcre library and hence supports its syntax +// for regular expressions. +// +// The syntax is pretty similar to Perl's. For those not familiar +// with Perl's regular expressions, here are some examples of the most +// commonly used extensions: +// +// "hello (\\w+) world" -- \w matches a "word" character +// "version (\\d+)" -- \d matches a digit +// "hello\\s+world" -- \s matches any whitespace character +// "\\b(\\w+)\\b" -- \b matches empty string at a word boundary +// "(?i)hello" -- (?i) turns on case-insensitive matching +// "/\\*(.*?)\\*/" -- .*? matches . minimum no. of times possible +// +// ----------------------------------------------------------------------- +// MATCHING INTERFACE: +// +// The "FullMatch" operation checks that supplied text matches a +// supplied pattern exactly. +// +// Example: successful match +// pcrecpp::RE re("h.*o"); +// re.FullMatch("hello"); +// +// Example: unsuccessful match (requires full match): +// pcrecpp::RE re("e"); +// !re.FullMatch("hello"); +// +// Example: creating a temporary RE object: +// pcrecpp::RE("h.*o").FullMatch("hello"); +// +// You can pass in a "const char*" or a "string" for "text". The +// examples below tend to use a const char*. +// +// You can, as in the different examples above, store the RE object +// explicitly in a variable or use a temporary RE object. The +// examples below use one mode or the other arbitrarily. Either +// could correctly be used for any of these examples. +// +// ----------------------------------------------------------------------- +// MATCHING WITH SUB-STRING EXTRACTION: +// +// You can supply extra pointer arguments to extract matched subpieces. +// +// Example: extracts "ruby" into "s" and 1234 into "i" +// int i; +// string s; +// pcrecpp::RE re("(\\w+):(\\d+)"); +// re.FullMatch("ruby:1234", &s, &i); +// +// Example: does not try to extract any extra sub-patterns +// re.FullMatch("ruby:1234", &s); +// +// Example: does not try to extract into NULL +// re.FullMatch("ruby:1234", NULL, &i); +// +// Example: integer overflow causes failure +// !re.FullMatch("ruby:1234567891234", NULL, &i); +// +// Example: fails because there aren't enough sub-patterns: +// !pcrecpp::RE("\\w+:\\d+").FullMatch("ruby:1234", &s); +// +// Example: fails because string cannot be stored in integer +// !pcrecpp::RE("(.*)").FullMatch("ruby", &i); +// +// The provided pointer arguments can be pointers to any scalar numeric +// type, or one of +// string (matched piece is copied to string) +// StringPiece (StringPiece is mutated to point to matched piece) +// T (where "bool T::ParseFrom(const char*, int)" exists) +// NULL (the corresponding matched sub-pattern is not copied) +// +// CAVEAT: An optional sub-pattern that does not exist in the matched +// string is assigned the empty string. Therefore, the following will +// return false (because the empty string is not a valid number): +// int number; +// pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number); +// +// ----------------------------------------------------------------------- +// DO_MATCH +// +// The matching interface supports at most 16 arguments per call. +// If you need more, consider using the more general interface +// pcrecpp::RE::DoMatch(). See pcrecpp.h for the signature for DoMatch. +// +// ----------------------------------------------------------------------- +// PARTIAL MATCHES +// +// You can use the "PartialMatch" operation when you want the pattern +// to match any substring of the text. +// +// Example: simple search for a string: +// pcrecpp::RE("ell").PartialMatch("hello"); +// +// Example: find first number in a string: +// int number; +// pcrecpp::RE re("(\\d+)"); +// re.PartialMatch("x*100 + 20", &number); +// assert(number == 100); +// +// ----------------------------------------------------------------------- +// UTF-8 AND THE MATCHING INTERFACE: +// +// By default, pattern and text are plain text, one byte per character. +// The UTF8 flag, passed to the constructor, causes both pattern +// and string to be treated as UTF-8 text, still a byte stream but +// potentially multiple bytes per character. In practice, the text +// is likelier to be UTF-8 than the pattern, but the match returned +// may depend on the UTF8 flag, so always use it when matching +// UTF8 text. E.g., "." will match one byte normally but with UTF8 +// set may match up to three bytes of a multi-byte character. +// +// Example: +// pcrecpp::RE_Options options; +// options.set_utf8(); +// pcrecpp::RE re(utf8_pattern, options); +// re.FullMatch(utf8_string); +// +// Example: using the convenience function UTF8(): +// pcrecpp::RE re(utf8_pattern, pcrecpp::UTF8()); +// re.FullMatch(utf8_string); +// +// NOTE: The UTF8 option is ignored if pcre was not configured with the +// --enable-utf8 flag. +// +// ----------------------------------------------------------------------- +// PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE +// +// PCRE defines some modifiers to change the behavior of the regular +// expression engine. +// The C++ wrapper defines an auxiliary class, RE_Options, as a vehicle +// to pass such modifiers to a RE class. +// +// Currently, the following modifiers are supported +// +// modifier description Perl corresponding +// +// PCRE_CASELESS case insensitive match /i +// PCRE_MULTILINE multiple lines match /m +// PCRE_DOTALL dot matches newlines /s +// PCRE_DOLLAR_ENDONLY $ matches only at end N/A +// PCRE_EXTRA strict escape parsing N/A +// PCRE_EXTENDED ignore whitespaces /x +// PCRE_UTF8 handles UTF8 chars built-in +// PCRE_UNGREEDY reverses * and *? N/A +// PCRE_NO_AUTO_CAPTURE disables matching parens N/A (*) +// +// (For a full account on how each modifier works, please check the +// PCRE API reference manual). +// +// (*) Both Perl and PCRE allow non matching parentheses by means of the +// "?:" modifier within the pattern itself. e.g. (?:ab|cd) does not +// capture, while (ab|cd) does. +// +// For each modifier, there are two member functions whose name is made +// out of the modifier in lowercase, without the "PCRE_" prefix. For +// instance, PCRE_CASELESS is handled by +// bool caseless(), +// which returns true if the modifier is set, and +// RE_Options & set_caseless(bool), +// which sets or unsets the modifier. +// +// Moreover, PCRE_EXTRA_MATCH_LIMIT can be accessed through the +// set_match_limit() and match_limit() member functions. +// Setting match_limit to a non-zero value will limit the executation of +// pcre to keep it from doing bad things like blowing the stack or taking +// an eternity to return a result. A value of 5000 is good enough to stop +// stack blowup in a 2MB thread stack. Setting match_limit to zero will +// disable match limiting. Alternately, you can set match_limit_recursion() +// which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much pcre +// recurses. match_limit() caps the number of matches pcre does; +// match_limit_recrusion() caps the depth of recursion. +// +// Normally, to pass one or more modifiers to a RE class, you declare +// a RE_Options object, set the appropriate options, and pass this +// object to a RE constructor. Example: +// +// RE_options opt; +// opt.set_caseless(true); +// +// if (RE("HELLO", opt).PartialMatch("hello world")) ... +// +// RE_options has two constructors. The default constructor takes no +// arguments and creates a set of flags that are off by default. +// +// The optional parameter 'option_flags' is to facilitate transfer +// of legacy code from C programs. This lets you do +// RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str); +// +// But new code is better off doing +// RE(pattern, +// RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str); +// (See below) +// +// If you are going to pass one of the most used modifiers, there are some +// convenience functions that return a RE_Options class with the +// appropriate modifier already set: +// CASELESS(), UTF8(), MULTILINE(), DOTALL(), EXTENDED() +// +// If you need to set several options at once, and you don't want to go +// through the pains of declaring a RE_Options object and setting several +// options, there is a parallel method that give you such ability on the +// fly. You can concatenate several set_xxxxx member functions, since each +// of them returns a reference to its class object. e.g.: to pass +// PCRE_CASELESS, PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one +// statement, you may write +// +// RE(" ^ xyz \\s+ .* blah$", RE_Options() +// .set_caseless(true) +// .set_extended(true) +// .set_multiline(true)).PartialMatch(sometext); +// +// ----------------------------------------------------------------------- +// SCANNING TEXT INCREMENTALLY +// +// The "Consume" operation may be useful if you want to repeatedly +// match regular expressions at the front of a string and skip over +// them as they match. This requires use of the "StringPiece" type, +// which represents a sub-range of a real string. Like RE, StringPiece +// is defined in the pcrecpp namespace. +// +// Example: read lines of the form "var = value" from a string. +// string contents = ...; // Fill string somehow +// pcrecpp::StringPiece input(contents); // Wrap in a StringPiece +// +// string var; +// int value; +// pcrecpp::RE re("(\\w+) = (\\d+)\n"); +// while (re.Consume(&input, &var, &value)) { +// ...; +// } +// +// Each successful call to "Consume" will set "var/value", and also +// advance "input" so it points past the matched text. +// +// The "FindAndConsume" operation is similar to "Consume" but does not +// anchor your match at the beginning of the string. For example, you +// could extract all words from a string by repeatedly calling +// pcrecpp::RE("(\\w+)").FindAndConsume(&input, &word) +// +// ----------------------------------------------------------------------- +// PARSING HEX/OCTAL/C-RADIX NUMBERS +// +// By default, if you pass a pointer to a numeric value, the +// corresponding text is interpreted as a base-10 number. You can +// instead wrap the pointer with a call to one of the operators Hex(), +// Octal(), or CRadix() to interpret the text in another base. The +// CRadix operator interprets C-style "0" (base-8) and "0x" (base-16) +// prefixes, but defaults to base-10. +// +// Example: +// int a, b, c, d; +// pcrecpp::RE re("(.*) (.*) (.*) (.*)"); +// re.FullMatch("100 40 0100 0x40", +// pcrecpp::Octal(&a), pcrecpp::Hex(&b), +// pcrecpp::CRadix(&c), pcrecpp::CRadix(&d)); +// will leave 64 in a, b, c, and d. +// +// ----------------------------------------------------------------------- +// REPLACING PARTS OF STRINGS +// +// You can replace the first match of "pattern" in "str" with +// "rewrite". Within "rewrite", backslash-escaped digits (\1 to \9) +// can be used to insert text matching corresponding parenthesized +// group from the pattern. \0 in "rewrite" refers to the entire +// matching text. E.g., +// +// string s = "yabba dabba doo"; +// pcrecpp::RE("b+").Replace("d", &s); +// +// will leave "s" containing "yada dabba doo". The result is true if +// the pattern matches and a replacement occurs, or false otherwise. +// +// GlobalReplace() is like Replace(), except that it replaces all +// occurrences of the pattern in the string with the rewrite. +// Replacements are not subject to re-matching. E.g., +// +// string s = "yabba dabba doo"; +// pcrecpp::RE("b+").GlobalReplace("d", &s); +// +// will leave "s" containing "yada dada doo". It returns the number +// of replacements made. +// +// Extract() is like Replace(), except that if the pattern matches, +// "rewrite" is copied into "out" (an additional argument) with +// substitutions. The non-matching portions of "text" are ignored. +// Returns true iff a match occurred and the extraction happened +// successfully. If no match occurs, the string is left unaffected. + + +#include +#include +#include // defines the Arg class +// This isn't technically needed here, but we include it +// anyway so folks who include pcrecpp.h don't have to. +#include + +namespace pcrecpp { + +#define PCRE_SET_OR_CLEAR(b, o) \ + if (b) all_options_ |= (o); else all_options_ &= ~(o); \ + return *this + +#define PCRE_IS_SET(o) \ + (all_options_ & o) == o + +/***** Compiling regular expressions: the RE class *****/ + +// RE_Options allow you to set options to be passed along to pcre, +// along with other options we put on top of pcre. +// Only 9 modifiers, plus match_limit and match_limit_recursion, +// are supported now. +class PCRECPP_EXP_DEFN RE_Options { + public: + // constructor + RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {} + + // alternative constructor. + // To facilitate transfer of legacy code from C programs + // + // This lets you do + // RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str); + // But new code is better off doing + // RE(pattern, + // RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str); + RE_Options(int option_flags) : match_limit_(0), match_limit_recursion_(0), + all_options_(option_flags) {} + // we're fine with the default destructor, copy constructor, etc. + + // accessors and mutators + int match_limit() const { return match_limit_; }; + RE_Options &set_match_limit(int limit) { + match_limit_ = limit; + return *this; + } + + int match_limit_recursion() const { return match_limit_recursion_; }; + RE_Options &set_match_limit_recursion(int limit) { + match_limit_recursion_ = limit; + return *this; + } + + bool caseless() const { + return PCRE_IS_SET(PCRE_CASELESS); + } + RE_Options &set_caseless(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_CASELESS); + } + + bool multiline() const { + return PCRE_IS_SET(PCRE_MULTILINE); + } + RE_Options &set_multiline(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_MULTILINE); + } + + bool dotall() const { + return PCRE_IS_SET(PCRE_DOTALL); + } + RE_Options &set_dotall(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_DOTALL); + } + + bool extended() const { + return PCRE_IS_SET(PCRE_EXTENDED); + } + RE_Options &set_extended(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_EXTENDED); + } + + bool dollar_endonly() const { + return PCRE_IS_SET(PCRE_DOLLAR_ENDONLY); + } + RE_Options &set_dollar_endonly(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_DOLLAR_ENDONLY); + } + + bool extra() const { + return PCRE_IS_SET(PCRE_EXTRA); + } + RE_Options &set_extra(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_EXTRA); + } + + bool ungreedy() const { + return PCRE_IS_SET(PCRE_UNGREEDY); + } + RE_Options &set_ungreedy(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_UNGREEDY); + } + + bool utf8() const { + return PCRE_IS_SET(PCRE_UTF8); + } + RE_Options &set_utf8(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_UTF8); + } + + bool no_auto_capture() const { + return PCRE_IS_SET(PCRE_NO_AUTO_CAPTURE); + } + RE_Options &set_no_auto_capture(bool x) { + PCRE_SET_OR_CLEAR(x, PCRE_NO_AUTO_CAPTURE); + } + + RE_Options &set_all_options(int opt) { + all_options_ = opt; + return *this; + } + int all_options() const { + return all_options_ ; + } + + // TODO: add other pcre flags + + private: + int match_limit_; + int match_limit_recursion_; + int all_options_; +}; + +// These functions return some common RE_Options +static inline RE_Options UTF8() { + return RE_Options().set_utf8(true); +} + +static inline RE_Options CASELESS() { + return RE_Options().set_caseless(true); +} +static inline RE_Options MULTILINE() { + return RE_Options().set_multiline(true); +} + +static inline RE_Options DOTALL() { + return RE_Options().set_dotall(true); +} + +static inline RE_Options EXTENDED() { + return RE_Options().set_extended(true); +} + +// Interface for regular expression matching. Also corresponds to a +// pre-compiled regular expression. An "RE" object is safe for +// concurrent use by multiple threads. +class PCRECPP_EXP_DEFN RE { + public: + // We provide implicit conversions from strings so that users can + // pass in a string or a "const char*" wherever an "RE" is expected. + RE(const string& pat) { Init(pat, NULL); } + RE(const string& pat, const RE_Options& option) { Init(pat, &option); } + RE(const char* pat) { Init(pat, NULL); } + RE(const char* pat, const RE_Options& option) { Init(pat, &option); } + RE(const unsigned char* pat) { + Init(reinterpret_cast(pat), NULL); + } + RE(const unsigned char* pat, const RE_Options& option) { + Init(reinterpret_cast(pat), &option); + } + + // Copy constructor & assignment - note that these are expensive + // because they recompile the expression. + RE(const RE& re) { Init(re.pattern_, &re.options_); } + const RE& operator=(const RE& re) { + if (this != &re) { + Cleanup(); + + // This is the code that originally came from Google + // Init(re.pattern_.c_str(), &re.options_); + + // This is the replacement from Ari Pollak + Init(re.pattern_, &re.options_); + } + return *this; + } + + + ~RE(); + + // The string specification for this RE. E.g. + // RE re("ab*c?d+"); + // re.pattern(); // "ab*c?d+" + const string& pattern() const { return pattern_; } + + // If RE could not be created properly, returns an error string. + // Else returns the empty string. + const string& error() const { return *error_; } + + /***** The useful part: the matching interface *****/ + + // This is provided so one can do pattern.ReplaceAll() just as + // easily as ReplaceAll(pattern-text, ....) + + bool FullMatch(const StringPiece& text, + const Arg& ptr1 = no_arg, + const Arg& ptr2 = no_arg, + const Arg& ptr3 = no_arg, + const Arg& ptr4 = no_arg, + const Arg& ptr5 = no_arg, + const Arg& ptr6 = no_arg, + const Arg& ptr7 = no_arg, + const Arg& ptr8 = no_arg, + const Arg& ptr9 = no_arg, + const Arg& ptr10 = no_arg, + const Arg& ptr11 = no_arg, + const Arg& ptr12 = no_arg, + const Arg& ptr13 = no_arg, + const Arg& ptr14 = no_arg, + const Arg& ptr15 = no_arg, + const Arg& ptr16 = no_arg) const; + + bool PartialMatch(const StringPiece& text, + const Arg& ptr1 = no_arg, + const Arg& ptr2 = no_arg, + const Arg& ptr3 = no_arg, + const Arg& ptr4 = no_arg, + const Arg& ptr5 = no_arg, + const Arg& ptr6 = no_arg, + const Arg& ptr7 = no_arg, + const Arg& ptr8 = no_arg, + const Arg& ptr9 = no_arg, + const Arg& ptr10 = no_arg, + const Arg& ptr11 = no_arg, + const Arg& ptr12 = no_arg, + const Arg& ptr13 = no_arg, + const Arg& ptr14 = no_arg, + const Arg& ptr15 = no_arg, + const Arg& ptr16 = no_arg) const; + + bool Consume(StringPiece* input, + const Arg& ptr1 = no_arg, + const Arg& ptr2 = no_arg, + const Arg& ptr3 = no_arg, + const Arg& ptr4 = no_arg, + const Arg& ptr5 = no_arg, + const Arg& ptr6 = no_arg, + const Arg& ptr7 = no_arg, + const Arg& ptr8 = no_arg, + const Arg& ptr9 = no_arg, + const Arg& ptr10 = no_arg, + const Arg& ptr11 = no_arg, + const Arg& ptr12 = no_arg, + const Arg& ptr13 = no_arg, + const Arg& ptr14 = no_arg, + const Arg& ptr15 = no_arg, + const Arg& ptr16 = no_arg) const; + + bool FindAndConsume(StringPiece* input, + const Arg& ptr1 = no_arg, + const Arg& ptr2 = no_arg, + const Arg& ptr3 = no_arg, + const Arg& ptr4 = no_arg, + const Arg& ptr5 = no_arg, + const Arg& ptr6 = no_arg, + const Arg& ptr7 = no_arg, + const Arg& ptr8 = no_arg, + const Arg& ptr9 = no_arg, + const Arg& ptr10 = no_arg, + const Arg& ptr11 = no_arg, + const Arg& ptr12 = no_arg, + const Arg& ptr13 = no_arg, + const Arg& ptr14 = no_arg, + const Arg& ptr15 = no_arg, + const Arg& ptr16 = no_arg) const; + + bool Replace(const StringPiece& rewrite, + string *str) const; + + int GlobalReplace(const StringPiece& rewrite, + string *str) const; + + bool Extract(const StringPiece &rewrite, + const StringPiece &text, + string *out) const; + + // Escapes all potentially meaningful regexp characters in + // 'unquoted'. The returned string, used as a regular expression, + // will exactly match the original string. For example, + // 1.5-2.0? + // may become: + // 1\.5\-2\.0\? + // Note QuoteMeta behaves the same as perl's QuoteMeta function, + // *except* that it escapes the NUL character (\0) as backslash + 0, + // rather than backslash + NUL. + static string QuoteMeta(const StringPiece& unquoted); + + + /***** Generic matching interface *****/ + + // Type of match (TODO: Should be restructured as part of RE_Options) + enum Anchor { + UNANCHORED, // No anchoring + ANCHOR_START, // Anchor at start only + ANCHOR_BOTH // Anchor at start and end + }; + + // General matching routine. Stores the length of the match in + // "*consumed" if successful. + bool DoMatch(const StringPiece& text, + Anchor anchor, + int* consumed, + const Arg* const* args, int n) const; + + // Return the number of capturing subpatterns, or -1 if the + // regexp wasn't valid on construction. + int NumberOfCapturingGroups() const; + + // The default value for an argument, to indicate the end of the argument + // list. This must be used only in optional argument defaults. It should NOT + // be passed explicitly. Some people have tried to use it like this: + // + // FullMatch(x, y, &z, no_arg, &w); + // + // This is a mistake, and will not work. + static Arg no_arg; + + private: + + void Init(const string& pattern, const RE_Options* options); + void Cleanup(); + + // Match against "text", filling in "vec" (up to "vecsize" * 2/3) with + // pairs of integers for the beginning and end positions of matched + // text. The first pair corresponds to the entire matched text; + // subsequent pairs correspond, in order, to parentheses-captured + // matches. Returns the number of pairs (one more than the number of + // the last subpattern with a match) if matching was successful + // and zero if the match failed. + // I.e. for RE("(foo)|(bar)|(baz)") it will return 2, 3, and 4 when matching + // against "foo", "bar", and "baz" respectively. + // When matching RE("(foo)|hello") against "hello", it will return 1. + // But the values for all subpattern are filled in into "vec". + int TryMatch(const StringPiece& text, + int startpos, + Anchor anchor, + bool empty_ok, + int *vec, + int vecsize) const; + + // Append the "rewrite" string, with backslash subsitutions from "text" + // and "vec", to string "out". + bool Rewrite(string *out, + const StringPiece& rewrite, + const StringPiece& text, + int *vec, + int veclen) const; + + // internal implementation for DoMatch + bool DoMatchImpl(const StringPiece& text, + Anchor anchor, + int* consumed, + const Arg* const args[], + int n, + int* vec, + int vecsize) const; + + // Compile the regexp for the specified anchoring mode + pcre* Compile(Anchor anchor); + + string pattern_; + RE_Options options_; + pcre* re_full_; // For full matches + pcre* re_partial_; // For partial matches + const string* error_; // Error indicator (or points to empty string) +}; + +} // namespace pcrecpp + +#endif /* _PCRECPP_H */ diff --git a/illumos-x86_64/usr/include/pcrecpparg.h b/illumos-x86_64/usr/include/pcrecpparg.h new file mode 100644 index 00000000..b4f9c3f4 --- /dev/null +++ b/illumos-x86_64/usr/include/pcrecpparg.h @@ -0,0 +1,174 @@ +// Copyright (c) 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Sanjay Ghemawat + +#ifndef _PCRECPPARG_H +#define _PCRECPPARG_H + +#include // for NULL +#include + +#include + +namespace pcrecpp { + +class StringPiece; + +// Hex/Octal/Binary? + +// Special class for parsing into objects that define a ParseFrom() method +template +class _RE_MatchObject { + public: + static inline bool Parse(const char* str, int n, void* dest) { + if (dest == NULL) return true; + T* object = reinterpret_cast(dest); + return object->ParseFrom(str, n); + } +}; + +class PCRECPP_EXP_DEFN Arg { + public: + // Empty constructor so we can declare arrays of Arg + Arg(); + + // Constructor specially designed for NULL arguments + Arg(void*); + + typedef bool (*Parser)(const char* str, int n, void* dest); + +// Type-specific parsers +#define PCRE_MAKE_PARSER(type,name) \ + Arg(type* p) : arg_(p), parser_(name) { } \ + Arg(type* p, Parser parser) : arg_(p), parser_(parser) { } + + + PCRE_MAKE_PARSER(char, parse_char); + PCRE_MAKE_PARSER(unsigned char, parse_uchar); + PCRE_MAKE_PARSER(short, parse_short); + PCRE_MAKE_PARSER(unsigned short, parse_ushort); + PCRE_MAKE_PARSER(int, parse_int); + PCRE_MAKE_PARSER(unsigned int, parse_uint); + PCRE_MAKE_PARSER(long, parse_long); + PCRE_MAKE_PARSER(unsigned long, parse_ulong); +#if 1 + PCRE_MAKE_PARSER(long long, parse_longlong); +#endif +#if 1 + PCRE_MAKE_PARSER(unsigned long long, parse_ulonglong); +#endif + PCRE_MAKE_PARSER(float, parse_float); + PCRE_MAKE_PARSER(double, parse_double); + PCRE_MAKE_PARSER(std::string, parse_string); + PCRE_MAKE_PARSER(StringPiece, parse_stringpiece); + +#undef PCRE_MAKE_PARSER + + // Generic constructor + template Arg(T*, Parser parser); + // Generic constructor template + template Arg(T* p) + : arg_(p), parser_(_RE_MatchObject::Parse) { + } + + // Parse the data + bool Parse(const char* str, int n) const; + + private: + void* arg_; + Parser parser_; + + static bool parse_null (const char* str, int n, void* dest); + static bool parse_char (const char* str, int n, void* dest); + static bool parse_uchar (const char* str, int n, void* dest); + static bool parse_float (const char* str, int n, void* dest); + static bool parse_double (const char* str, int n, void* dest); + static bool parse_string (const char* str, int n, void* dest); + static bool parse_stringpiece (const char* str, int n, void* dest); + +#define PCRE_DECLARE_INTEGER_PARSER(name) \ + private: \ + static bool parse_ ## name(const char* str, int n, void* dest); \ + static bool parse_ ## name ## _radix( \ + const char* str, int n, void* dest, int radix); \ + public: \ + static bool parse_ ## name ## _hex(const char* str, int n, void* dest); \ + static bool parse_ ## name ## _octal(const char* str, int n, void* dest); \ + static bool parse_ ## name ## _cradix(const char* str, int n, void* dest) + + PCRE_DECLARE_INTEGER_PARSER(short); + PCRE_DECLARE_INTEGER_PARSER(ushort); + PCRE_DECLARE_INTEGER_PARSER(int); + PCRE_DECLARE_INTEGER_PARSER(uint); + PCRE_DECLARE_INTEGER_PARSER(long); + PCRE_DECLARE_INTEGER_PARSER(ulong); + PCRE_DECLARE_INTEGER_PARSER(longlong); + PCRE_DECLARE_INTEGER_PARSER(ulonglong); + +#undef PCRE_DECLARE_INTEGER_PARSER +}; + +inline Arg::Arg() : arg_(NULL), parser_(parse_null) { } +inline Arg::Arg(void* p) : arg_(p), parser_(parse_null) { } + +inline bool Arg::Parse(const char* str, int n) const { + return (*parser_)(str, n, arg_); +} + +// This part of the parser, appropriate only for ints, deals with bases +#define MAKE_INTEGER_PARSER(type, name) \ + inline Arg Hex(type* ptr) { \ + return Arg(ptr, Arg::parse_ ## name ## _hex); } \ + inline Arg Octal(type* ptr) { \ + return Arg(ptr, Arg::parse_ ## name ## _octal); } \ + inline Arg CRadix(type* ptr) { \ + return Arg(ptr, Arg::parse_ ## name ## _cradix); } + +MAKE_INTEGER_PARSER(short, short) /* */ +MAKE_INTEGER_PARSER(unsigned short, ushort) /* */ +MAKE_INTEGER_PARSER(int, int) /* Don't use semicolons */ +MAKE_INTEGER_PARSER(unsigned int, uint) /* after these statement */ +MAKE_INTEGER_PARSER(long, long) /* because they can cause */ +MAKE_INTEGER_PARSER(unsigned long, ulong) /* compiler warnings if */ +#if 1 /* the checking level is */ +MAKE_INTEGER_PARSER(long long, longlong) /* turned up high enough. */ +#endif /* */ +#if 1 /* */ +MAKE_INTEGER_PARSER(unsigned long long, ulonglong) /* */ +#endif + +#undef PCRE_IS_SET +#undef PCRE_SET_OR_CLEAR +#undef MAKE_INTEGER_PARSER + +} // namespace pcrecpp + + +#endif /* _PCRECPPARG_H */ diff --git a/illumos-x86_64/usr/include/pcreposix.h b/illumos-x86_64/usr/include/pcreposix.h new file mode 100644 index 00000000..c77c0b05 --- /dev/null +++ b/illumos-x86_64/usr/include/pcreposix.h @@ -0,0 +1,146 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +#ifndef _PCREPOSIX_H +#define _PCREPOSIX_H + +/* This is the header for the POSIX wrapper interface to the PCRE Perl- +Compatible Regular Expression library. It defines the things POSIX says should +be there. I hope. + + Copyright (c) 1997-2012 University of Cambridge + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +/* Have to include stdlib.h in order to ensure that size_t is defined. */ + +#include + +/* Allow for C++ users */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Options, mostly defined by POSIX, but with some extras. */ + +#define REG_ICASE 0x0001 /* Maps to PCRE_CASELESS */ +#define REG_NEWLINE 0x0002 /* Maps to PCRE_MULTILINE */ +#define REG_NOTBOL 0x0004 /* Maps to PCRE_NOTBOL */ +#define REG_NOTEOL 0x0008 /* Maps to PCRE_NOTEOL */ +#define REG_DOTALL 0x0010 /* NOT defined by POSIX; maps to PCRE_DOTALL */ +#define REG_NOSUB 0x0020 /* Maps to PCRE_NO_AUTO_CAPTURE */ +#define REG_UTF8 0x0040 /* NOT defined by POSIX; maps to PCRE_UTF8 */ +#define REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */ +#define REG_NOTEMPTY 0x0100 /* NOT defined by POSIX; maps to PCRE_NOTEMPTY */ +#define REG_UNGREEDY 0x0200 /* NOT defined by POSIX; maps to PCRE_UNGREEDY */ +#define REG_UCP 0x0400 /* NOT defined by POSIX; maps to PCRE_UCP */ + +/* This is not used by PCRE, but by defining it we make it easier +to slot PCRE into existing programs that make POSIX calls. */ + +#define REG_EXTENDED 0 + +/* Error values. Not all these are relevant or used by the wrapper. */ + +enum { + REG_ASSERT = 1, /* internal error ? */ + REG_BADBR, /* invalid repeat counts in {} */ + REG_BADPAT, /* pattern error */ + REG_BADRPT, /* ? * + invalid */ + REG_EBRACE, /* unbalanced {} */ + REG_EBRACK, /* unbalanced [] */ + REG_ECOLLATE, /* collation error - not relevant */ + REG_ECTYPE, /* bad class */ + REG_EESCAPE, /* bad escape sequence */ + REG_EMPTY, /* empty expression */ + REG_EPAREN, /* unbalanced () */ + REG_ERANGE, /* bad range inside [] */ + REG_ESIZE, /* expression too big */ + REG_ESPACE, /* failed to get memory */ + REG_ESUBREG, /* bad back reference */ + REG_INVARG, /* bad argument */ + REG_NOMATCH /* match failed */ +}; + + +/* The structure representing a compiled regular expression. */ + +typedef struct { + void *re_pcre; + size_t re_nsub; + size_t re_erroffset; +} regex_t; + +/* The structure in which a captured offset is returned. */ + +typedef int regoff_t; + +typedef struct { + regoff_t rm_so; + regoff_t rm_eo; +} regmatch_t; + +/* When an application links to a PCRE DLL in Windows, the symbols that are +imported have to be identified as such. When building PCRE, the appropriate +export settings are needed, and are set in pcreposix.c before including this +file. */ + +#if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL) +# define PCREPOSIX_EXP_DECL extern __declspec(dllimport) +# define PCREPOSIX_EXP_DEFN __declspec(dllimport) +#endif + +/* By default, we use the standard "extern" declarations. */ + +#ifndef PCREPOSIX_EXP_DECL +# ifdef __cplusplus +# define PCREPOSIX_EXP_DECL extern "C" +# define PCREPOSIX_EXP_DEFN extern "C" +# else +# define PCREPOSIX_EXP_DECL extern +# define PCREPOSIX_EXP_DEFN extern +# endif +#endif + +/* The functions */ + +PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int); +PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t, + regmatch_t *, int); +PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t); +PCREPOSIX_EXP_DECL void regfree(regex_t *); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* End of pcreposix.h */ diff --git a/illumos-x86_64/usr/include/pcsample.h b/illumos-x86_64/usr/include/pcsample.h new file mode 100644 index 00000000..4a3d28df --- /dev/null +++ b/illumos-x86_64/usr/include/pcsample.h @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PCSAMPLE_H +#define _PCSAMPLE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * PC sampling profiling + */ +long pcsample(uintptr_t [], long); + +#ifdef __cplusplus +} +#endif + +#endif /* _PCSAMPLE_H */ diff --git a/illumos-x86_64/usr/include/pfmt.h b/illumos-x86_64/usr/include/pfmt.h new file mode 100644 index 00000000..7542fc15 --- /dev/null +++ b/illumos-x86_64/usr/include/pfmt.h @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _PFMT_H +#define _PFMT_H + +#include +#ifndef va_args +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define MM_STD 0 +#define MM_NOSTD 0x100 +#define MM_GET 0 +#define MM_NOGET 0x200 + +#define MM_ACTION 0x400 + +#define MM_NOCONSOLE 0 +#define MM_CONSOLE 0x800 + +/* Classification */ +#define MM_NULLMC 0 +#define MM_HARD 0x1000 +#define MM_SOFT 0x2000 +#define MM_FIRM 0x4000 +#define MM_APPL 0x8000 +#define MM_UTIL 0x10000 +#define MM_OPSYS 0x20000 + +/* Most commonly used combinations */ +#define MM_SVCMD MM_UTIL|MM_SOFT + +#define MM_ERROR 0 +#define MM_HALT 1 +#define MM_WARNING 2 +#define MM_INFO 3 + +int pfmt(FILE *, long, const char *, ...); +int lfmt(FILE *, long, const char *, ...); +int vpfmt(FILE *, long, const char *, va_list); +int vlfmt(FILE *, long, const char *, va_list); +const char *setcat(const char *); +int setlabel(const char *); +int addsev(int, const char *); + +#define DB_NAME_LEN 15 +#define MAXLABEL 25 + +#ifdef __cplusplus +} +#endif + +#endif /* _PFMT_H */ diff --git a/illumos-x86_64/usr/include/pkgdev.h b/illumos-x86_64/usr/include/pkgdev.h new file mode 100644 index 00000000..9d5222b7 --- /dev/null +++ b/illumos-x86_64/usr/include/pkgdev.h @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _PKGDEV_H +#define _PKGDEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct pkgdev { + int rdonly; + int mntflg; + longlong_t capacity; /* number of 512-blocks on device */ + char *name; + char *dirname; + char *pathname; + char *mount; + char *fstyp; + char *cdevice; + char *bdevice; + char *norewind; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _PKGDEV_H */ diff --git a/illumos-x86_64/usr/include/pkginfo.h b/illumos-x86_64/usr/include/pkginfo.h new file mode 100644 index 00000000..702f9e03 --- /dev/null +++ b/illumos-x86_64/usr/include/pkginfo.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _PKGINFO_H +#define _PKGINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define PI_INSTALLED 0 +#define PI_PARTIAL 1 +#define PI_PRESVR4 2 +#define PI_UNKNOWN 3 +#define PI_SPOOLED 4 + +struct pkginfo { + char *pkginst; + char *name; + char *arch; + char *version; + char *vendor; + char *basedir; + char *catg; + char status; +}; + +extern char *pkgdir; + +extern char *pkgparam(char *, char *); +extern int pkginfo(struct pkginfo *, char *, ...), + pkgnmchk(char *, char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _PKGINFO_H */ diff --git a/illumos-x86_64/usr/include/pkglocs.h b/illumos-x86_64/usr/include/pkglocs.h new file mode 100644 index 00000000..24876a26 --- /dev/null +++ b/illumos-x86_64/usr/include/pkglocs.h @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _PKGLOCS_H +#define _PKGLOCS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define PKGLOC "/var/sadm/pkg" +#define PKGADM "/var/sadm/install" +#define PKGBIN "/usr/sadm/install/bin" +#define PKGSCR "/usr/sadm/install/scripts" + +#ifdef __cplusplus +} +#endif + +#endif /* _PKGLOCS_H */ diff --git a/illumos-x86_64/usr/include/pkgstrct.h b/illumos-x86_64/usr/include/pkgstrct.h new file mode 100644 index 00000000..a022aa89 --- /dev/null +++ b/illumos-x86_64/usr/include/pkgstrct.h @@ -0,0 +1,103 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PKGSTRCT_H +#define _PKGSTRCT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CLSSIZ 64 +#define PKGSIZ 64 +#define ATRSIZ 64 + +#define BADFTYPE '?' +#define BADMODE (mode_t)ULONG_MAX +#define BADOWNER "?" +#define BADGROUP "?" +#define BADMAJOR (major_t)ULONG_MAX +#define BADMINOR (minor_t)ULONG_MAX +#define BADCLASS "none" +#define BADINPUT 1 /* not EOF */ +#define BADCONT (-1L) + +extern char *errstr; + +struct ainfo { + char *local; + mode_t mode; + char owner[ATRSIZ+1]; + char group[ATRSIZ+1]; + major_t major; + minor_t minor; +}; + +struct cinfo { + long cksum; + fsblkcnt_t size; + time_t modtime; +}; + +struct pinfo { + char status; + char pkg[PKGSIZ+1]; + char editflag; + char aclass[ATRSIZ+1]; + struct pinfo + *next; +}; + +struct cfent { + short volno; + char ftype; + char pkg_class[CLSSIZ+1]; + int pkg_class_idx; + char *path; + struct ainfo ainfo; + struct cinfo cinfo; + short npkgs; + struct pinfo + *pinfo; +}; + +/* averify() & cverify() error codes */ +#define VE_EXIST 0x0001 +#define VE_FTYPE 0x0002 +#define VE_ATTR 0x0004 +#define VE_CONT 0x0008 +#define VE_FAIL 0x0010 +#define VE_TIME 0x0020 + +#ifdef __cplusplus +} +#endif + +#endif /* _PKGSTRCT_H */ diff --git a/illumos-x86_64/usr/include/pkgtrans.h b/illumos-x86_64/usr/include/pkgtrans.h new file mode 100644 index 00000000..3fe52418 --- /dev/null +++ b/illumos-x86_64/usr/include/pkgtrans.h @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _PKGTRANS_H +#define _PKGTRANS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define PT_OVERWRITE 0x01 +#define PT_INFO_ONLY 0x02 +#define PT_RENAME 0x04 +#define PT_DEBUG 0x08 +#define PT_SILENT 0x10 +#define PT_ODTSTREAM 0x40 + +#ifdef __cplusplus +} +#endif + +#endif /* _PKGTRANS_H */ diff --git a/illumos-x86_64/usr/include/plugin-api.h b/illumos-x86_64/usr/include/plugin-api.h new file mode 100644 index 00000000..2598a76f --- /dev/null +++ b/illumos-x86_64/usr/include/plugin-api.h @@ -0,0 +1,622 @@ +/* plugin-api.h -- External linker plugin API. */ + +/* Copyright (C) 2009-2025 Free Software Foundation, Inc. + Written by Cary Coutant . + + This file is part of binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +/* This file defines the interface for writing a linker plugin, which is + described at < http://gcc.gnu.org/wiki/whopr/driver >. */ + +#ifndef PLUGIN_API_H +#define PLUGIN_API_H + +#ifdef HAVE_STDINT_H +#include +#elif defined(HAVE_INTTYPES_H) +#include +#endif +#include +#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && \ + !defined(UINT64_MAX) && !defined(uint64_t) +#error cannot find uint64_t type +#endif + +/* Detect endianess based on gcc's (>=4.6.0) __BYTE_ORDER__ macro. */ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ + defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_PDP_ENDIAN__) +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define PLUGIN_LITTLE_ENDIAN 1 +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define PLUGIN_BIG_ENDIAN 1 +#elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ +#define PLUGIN_PDP_ENDIAN 1 +#endif + +#else +/* Include header files to define endian macros. */ +#if defined(__GLIBC__) || defined(__GNU_LIBRARY__) || defined(__ANDROID__) +#include + +#elif defined(__SVR4) && defined(__sun) +#include + +#elif defined(__FreeBSD__) || defined(__NetBSD__) || \ + defined(__DragonFly__) || defined(__minix) +#include + +#elif defined(__OpenBSD__) +#include +#endif + +/* Detect endianess based on __BYTE_ORDER. */ +#ifdef __BYTE_ORDER +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define PLUGIN_LITTLE_ENDIAN 1 +#elif __BYTE_ORDER == __BIG_ENDIAN +#define PLUGIN_BIG_ENDIAN 1 +#endif + +/* Detect endianess based on _BYTE_ORDER. */ +#elif defined _BYTE_ORDER +#if _BYTE_ORDER == _LITTLE_ENDIAN +#define PLUGIN_LITTLE_ENDIAN 1 +#elif _BYTE_ORDER == _BIG_ENDIAN +#define PLUGIN_BIG_ENDIAN 1 +#endif + +/* Detect based on _WIN32. */ +#elif defined _WIN32 +#define PLUGIN_LITTLE_ENDIAN 1 + +/* Detect based on __BIG_ENDIAN__ and __LITTLE_ENDIAN__ */ +#elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN +#define PLUGIN_LITTLE_ENDIAN 1 +#elif defined __BIG_ENDIAN__ || defined _BIG_ENDIAN +#define PLUGIN_BIG_ENDIAN 1 +#endif +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Status code returned by most API routines. */ + +enum ld_plugin_status +{ + LDPS_OK = 0, + LDPS_NO_SYMS, /* Attempt to get symbols that haven't been added. */ + LDPS_BAD_HANDLE, /* No claimed object associated with given handle. */ + LDPS_ERR + /* Additional Error codes TBD. */ +}; + +/* The version of the API specification. */ + +enum ld_plugin_api_version +{ + LD_PLUGIN_API_VERSION = 1 +}; + +/* The type of output file being generated by the linker. */ + +enum ld_plugin_output_file_type +{ + LDPO_REL, + LDPO_EXEC, + LDPO_DYN, + LDPO_PIE +}; + +/* An input file managed by the plugin library. */ + +struct ld_plugin_input_file +{ + const char *name; + int fd; + off_t offset; + off_t filesize; + void *handle; +}; + +/* A symbol belonging to an input file managed by the plugin library. */ + +struct ld_plugin_symbol +{ + char *name; + char *version; + /* This is for compatibility with older ABIs. The older ABI defined + only 'def' field. */ +#if PLUGIN_BIG_ENDIAN == 1 + char unused; + char section_kind; + char symbol_type; + char def; +#elif PLUGIN_LITTLE_ENDIAN == 1 + char def; + char symbol_type; + char section_kind; + char unused; +#elif PLUGIN_PDP_ENDIAN == 1 + char symbol_type; + char def; + char unused; + char section_kind; +#else +#error "Could not detect architecture endianess" +#endif + int visibility; + uint64_t size; + char *comdat_key; + int resolution; +}; + +/* An object's section. */ + +struct ld_plugin_section +{ + const void* handle; + unsigned int shndx; +}; + +/* Whether the symbol is a definition, reference, or common, weak or not. */ + +enum ld_plugin_symbol_kind +{ + LDPK_DEF, + LDPK_WEAKDEF, + LDPK_UNDEF, + LDPK_WEAKUNDEF, + LDPK_COMMON +}; + +/* The visibility of the symbol. */ + +enum ld_plugin_symbol_visibility +{ + LDPV_DEFAULT, + LDPV_PROTECTED, + LDPV_INTERNAL, + LDPV_HIDDEN +}; + +/* The type of the symbol. */ + +enum ld_plugin_symbol_type +{ + LDST_UNKNOWN, + LDST_FUNCTION, + LDST_VARIABLE +}; + +enum ld_plugin_symbol_section_kind +{ + LDSSK_DEFAULT, + LDSSK_BSS +}; + +/* How a symbol is resolved. */ + +enum ld_plugin_symbol_resolution +{ + LDPR_UNKNOWN = 0, + + /* Symbol is still undefined at this point. */ + LDPR_UNDEF, + + /* This is the prevailing definition of the symbol, with references from + regular object code. */ + LDPR_PREVAILING_DEF, + + /* This is the prevailing definition of the symbol, with no + references from regular objects. It is only referenced from IR + code. */ + LDPR_PREVAILING_DEF_IRONLY, + + /* This definition was pre-empted by a definition in a regular + object file. */ + LDPR_PREEMPTED_REG, + + /* This definition was pre-empted by a definition in another IR file. */ + LDPR_PREEMPTED_IR, + + /* This symbol was resolved by a definition in another IR file. */ + LDPR_RESOLVED_IR, + + /* This symbol was resolved by a definition in a regular object + linked into the main executable. */ + LDPR_RESOLVED_EXEC, + + /* This symbol was resolved by a definition in a shared object. */ + LDPR_RESOLVED_DYN, + + /* This is the prevailing definition of the symbol, with no + references from regular objects. It is only referenced from IR + code, but the symbol is exported and may be referenced from + a dynamic object (not seen at link time). */ + LDPR_PREVAILING_DEF_IRONLY_EXP +}; + +/* The plugin library's "claim file" handler. */ + +typedef +enum ld_plugin_status +(*ld_plugin_claim_file_handler) ( + const struct ld_plugin_input_file *file, int *claimed); + +/* The plugin library's "claim file" handler, version 2. */ + +typedef +enum ld_plugin_status +(*ld_plugin_claim_file_handler_v2) ( + const struct ld_plugin_input_file *file, int *claimed, int known_used); + +/* The plugin library's "all symbols read" handler. */ + +typedef +enum ld_plugin_status +(*ld_plugin_all_symbols_read_handler) (void); + +/* The plugin library's cleanup handler. */ + +typedef +enum ld_plugin_status +(*ld_plugin_cleanup_handler) (void); + +/* The linker's interface for registering the "claim file" handler. */ + +typedef +enum ld_plugin_status +(*ld_plugin_register_claim_file) (ld_plugin_claim_file_handler handler); + +/* The linker's interface for registering the "claim file" handler, + version 2. */ + +typedef +enum ld_plugin_status +(*ld_plugin_register_claim_file_v2) (ld_plugin_claim_file_handler_v2 handler); + +/* The linker's interface for registering the "all symbols read" handler. */ + +typedef +enum ld_plugin_status +(*ld_plugin_register_all_symbols_read) ( + ld_plugin_all_symbols_read_handler handler); + +/* The linker's interface for registering the cleanup handler. */ + +typedef +enum ld_plugin_status +(*ld_plugin_register_cleanup) (ld_plugin_cleanup_handler handler); + +/* The linker's interface for adding symbols from a claimed input file. */ + +typedef +enum ld_plugin_status +(*ld_plugin_add_symbols) (void *handle, int nsyms, + const struct ld_plugin_symbol *syms); + +/* The linker's interface for getting the input file information with + an open (possibly re-opened) file descriptor. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_input_file) (const void *handle, + struct ld_plugin_input_file *file); + +typedef +enum ld_plugin_status +(*ld_plugin_get_view) (const void *handle, const void **viewp); + +/* The linker's interface for releasing the input file. */ + +typedef +enum ld_plugin_status +(*ld_plugin_release_input_file) (const void *handle); + +/* The linker's interface for retrieving symbol resolution information. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_symbols) (const void *handle, int nsyms, + struct ld_plugin_symbol *syms); + +/* The linker's interface for adding a compiled input file. */ + +typedef +enum ld_plugin_status +(*ld_plugin_add_input_file) (const char *pathname); + +/* The linker's interface for adding a library that should be searched. */ + +typedef +enum ld_plugin_status +(*ld_plugin_add_input_library) (const char *libname); + +/* The linker's interface for adding a library path that should be searched. */ + +typedef +enum ld_plugin_status +(*ld_plugin_set_extra_library_path) (const char *path); + +/* The linker's interface for issuing a warning or error message. */ + +typedef +enum ld_plugin_status +(*ld_plugin_message) (int level, const char *format, ...); + +/* The linker's interface for retrieving the number of sections in an object. + The handle is obtained in the claim_file handler. This interface should + only be invoked in the claim_file handler. This function sets *COUNT to + the number of sections in the object. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_input_section_count) (const void* handle, unsigned int *count); + +/* The linker's interface for retrieving the section type of a specific + section in an object. This interface should only be invoked in the + claim_file handler. This function sets *TYPE to an ELF SHT_xxx value. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_input_section_type) (const struct ld_plugin_section section, + unsigned int *type); + +/* The linker's interface for retrieving the name of a specific section in + an object. This interface should only be invoked in the claim_file handler. + This function sets *SECTION_NAME_PTR to a null-terminated buffer allocated + by malloc. The plugin must free *SECTION_NAME_PTR. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_input_section_name) (const struct ld_plugin_section section, + char **section_name_ptr); + +/* The linker's interface for retrieving the contents of a specific section + in an object. This interface should only be invoked in the claim_file + handler. This function sets *SECTION_CONTENTS to point to a buffer that is + valid until clam_file handler returns. It sets *LEN to the size of the + buffer. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_input_section_contents) (const struct ld_plugin_section section, + const unsigned char **section_contents, + size_t* len); + +/* The linker's interface for specifying the desired order of sections. + The sections should be specifed using the array SECTION_LIST in the + order in which they should appear in the final layout. NUM_SECTIONS + specifies the number of entries in each array. This should be invoked + in the all_symbols_read handler. */ + +typedef +enum ld_plugin_status +(*ld_plugin_update_section_order) (const struct ld_plugin_section *section_list, + unsigned int num_sections); + +/* The linker's interface for specifying that reordering of sections is + desired so that the linker can prepare for it. This should be invoked + before update_section_order, preferably in the claim_file handler. */ + +typedef +enum ld_plugin_status +(*ld_plugin_allow_section_ordering) (void); + +/* The linker's interface for specifying that a subset of sections is + to be mapped to a unique segment. If the plugin wants to call + unique_segment_for_sections, it must call this function from a + claim_file_handler or when it is first loaded. */ + +typedef +enum ld_plugin_status +(*ld_plugin_allow_unique_segment_for_sections) (void); + +/* The linker's interface for specifying that a specific set of sections + must be mapped to a unique segment. ELF segments do not have names + and the NAME is used as the name of the newly created output section + that is then placed in the unique PT_LOAD segment. FLAGS is used to + specify if any additional segment flags need to be set. For instance, + a specific segment flag can be set to identify this segment. Unsetting + segment flags that would be set by default is not possible. The + parameter SEGMENT_ALIGNMENT when non-zero will override the default. */ + +typedef +enum ld_plugin_status +(*ld_plugin_unique_segment_for_sections) ( + const char* segment_name, + uint64_t segment_flags, + uint64_t segment_alignment, + const struct ld_plugin_section * section_list, + unsigned int num_sections); + +/* The linker's interface for retrieving the section alignment requirement + of a specific section in an object. This interface should only be invoked in the + claim_file handler. This function sets *ADDRALIGN to the ELF sh_addralign + value of the input section. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_input_section_alignment) (const struct ld_plugin_section section, + unsigned int *addralign); + +/* The linker's interface for retrieving the section size of a specific section + in an object. This interface should only be invoked in the claim_file handler. + This function sets *SECSIZE to the ELF sh_size + value of the input section. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_input_section_size) (const struct ld_plugin_section section, + uint64_t *secsize); + +typedef +enum ld_plugin_status +(*ld_plugin_new_input_handler) (const struct ld_plugin_input_file *file); + +/* The linker's interface for registering the "new_input" handler. This handler + will be notified when a new input file has been added after the + all_symbols_read event, allowing the plugin to, for example, set a unique + segment for sections in plugin-generated input files. */ + +typedef +enum ld_plugin_status +(*ld_plugin_register_new_input) (ld_plugin_new_input_handler handler); + +/* The linker's interface for getting the list of wrapped symbols using the + --wrap option. This sets *NUM_SYMBOLS to number of wrapped symbols and + *WRAP_SYMBOL_LIST to the list of wrapped symbols. */ + +typedef +enum ld_plugin_status +(*ld_plugin_get_wrap_symbols) (uint64_t *num_symbols, + const char ***wrap_symbol_list); + +enum ld_plugin_level +{ + LDPL_INFO, + LDPL_WARNING, + LDPL_ERROR, + LDPL_FATAL +}; + +/* Contract between a plug-in and a linker. */ + +enum linker_api_version +{ + /* The linker/plugin do not implement any of the API levels below, the API + is determined solely via the transfer vector. */ + LAPI_V0, + + /* API level v1. The linker provides get_symbols_v3, add_symbols_v2, + the plugin will use that and not any lower versions. + claim_file is thread-safe on the plugin side and + add_symbols on the linker side. */ + LAPI_V1 +}; + +/* The linker's interface for API version negotiation. A plug-in calls + the function (with its IDENTIFIER and VERSION), plus minimal and maximal + version of linker_api_version is provided. Linker then returns selected + API version and provides its IDENTIFIER and VERSION. The returned value + by linker must be in range [MINIMAL_API_SUPPORTED, MAXIMAL_API_SUPPORTED]. + Identifier pointers remain valid as long as the plugin is loaded. */ + +typedef +int +(*ld_plugin_get_api_version) (const char *plugin_identifier, + const char *plugin_version, + int minimal_api_supported, + int maximal_api_supported, + const char **linker_identifier, + const char **linker_version); + +/* Values for the tv_tag field of the transfer vector. */ + +enum ld_plugin_tag +{ + LDPT_NULL, + LDPT_API_VERSION, + LDPT_GOLD_VERSION, + LDPT_LINKER_OUTPUT, + LDPT_OPTION, + LDPT_REGISTER_CLAIM_FILE_HOOK, + LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK, + LDPT_REGISTER_CLEANUP_HOOK, + LDPT_ADD_SYMBOLS, + LDPT_GET_SYMBOLS, + LDPT_ADD_INPUT_FILE, + LDPT_MESSAGE, + LDPT_GET_INPUT_FILE, + LDPT_RELEASE_INPUT_FILE, + LDPT_ADD_INPUT_LIBRARY, + LDPT_OUTPUT_NAME, + LDPT_SET_EXTRA_LIBRARY_PATH, + LDPT_GNU_LD_VERSION, + LDPT_GET_VIEW, + LDPT_GET_INPUT_SECTION_COUNT, + LDPT_GET_INPUT_SECTION_TYPE, + LDPT_GET_INPUT_SECTION_NAME, + LDPT_GET_INPUT_SECTION_CONTENTS, + LDPT_UPDATE_SECTION_ORDER, + LDPT_ALLOW_SECTION_ORDERING, + LDPT_GET_SYMBOLS_V2, + LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS, + LDPT_UNIQUE_SEGMENT_FOR_SECTIONS, + LDPT_GET_SYMBOLS_V3, + LDPT_GET_INPUT_SECTION_ALIGNMENT, + LDPT_GET_INPUT_SECTION_SIZE, + LDPT_REGISTER_NEW_INPUT_HOOK, + LDPT_GET_WRAP_SYMBOLS, + LDPT_ADD_SYMBOLS_V2, + LDPT_GET_API_VERSION, + LDPT_REGISTER_CLAIM_FILE_HOOK_V2 +}; + +/* The plugin transfer vector. */ + +struct ld_plugin_tv +{ + enum ld_plugin_tag tv_tag; + union + { + int tv_val; + const char *tv_string; + ld_plugin_register_claim_file tv_register_claim_file; + ld_plugin_register_claim_file_v2 tv_register_claim_file_v2; + ld_plugin_register_all_symbols_read tv_register_all_symbols_read; + ld_plugin_register_cleanup tv_register_cleanup; + ld_plugin_add_symbols tv_add_symbols; + ld_plugin_get_symbols tv_get_symbols; + ld_plugin_add_input_file tv_add_input_file; + ld_plugin_message tv_message; + ld_plugin_get_input_file tv_get_input_file; + ld_plugin_get_view tv_get_view; + ld_plugin_release_input_file tv_release_input_file; + ld_plugin_add_input_library tv_add_input_library; + ld_plugin_set_extra_library_path tv_set_extra_library_path; + ld_plugin_get_input_section_count tv_get_input_section_count; + ld_plugin_get_input_section_type tv_get_input_section_type; + ld_plugin_get_input_section_name tv_get_input_section_name; + ld_plugin_get_input_section_contents tv_get_input_section_contents; + ld_plugin_update_section_order tv_update_section_order; + ld_plugin_allow_section_ordering tv_allow_section_ordering; + ld_plugin_allow_unique_segment_for_sections tv_allow_unique_segment_for_sections; + ld_plugin_unique_segment_for_sections tv_unique_segment_for_sections; + ld_plugin_get_input_section_alignment tv_get_input_section_alignment; + ld_plugin_get_input_section_size tv_get_input_section_size; + ld_plugin_register_new_input tv_register_new_input; + ld_plugin_get_wrap_symbols tv_get_wrap_symbols; + ld_plugin_get_api_version tv_get_api_version; + } tv_u; +}; + +/* The plugin library's "onload" entry point. */ + +typedef +enum ld_plugin_status +(*ld_plugin_onload) (struct ld_plugin_tv *tv); + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(PLUGIN_API_H) */ diff --git a/illumos-x86_64/usr/include/poll.h b/illumos-x86_64/usr/include/poll.h new file mode 100644 index 00000000..4f348b38 --- /dev/null +++ b/illumos-x86_64/usr/include/poll.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _POLL_H +#define _POLL_H + +/* + * Poll system call interface definitions. + */ + +#include +#include +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +#include +#include +#endif /* defined(__EXTENSIONS__) ... */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) + +extern int ppoll(struct pollfd *_RESTRICT_KYWD, nfds_t, + const struct timespec *_RESTRICT_KYWD, const sigset_t *_RESTRICT_KYWD); + +#endif /* defined(__EXTENSIONS__) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _POLL_H */ diff --git a/illumos-x86_64/usr/include/pool.h b/illumos-x86_64/usr/include/pool.h new file mode 100644 index 00000000..92c01b01 --- /dev/null +++ b/illumos-x86_64/usr/include/pool.h @@ -0,0 +1,278 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * NOTE + * + * The following contents of this file are private to the + * implementation of the Solaris system and are subject to change at + * any time without notice. Applications using these interfaces may + * fail to run on future releases. + */ + +#ifndef _POOL_H +#define _POOL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Library versioning support (c.f. elf_version(3elf)). + * + * You can enquire about the version number of the library + * by passing POOL_VER_NONE. POOL_VER_CURRENT is the current + * (most capable) version. + * + * You can set the version used by the library by passing the + * required version number. If this is not possible, the version + * returned will be POOL_VER_NONE. + */ +#define POOL_VER_CURRENT 1 +#define POOL_VER_NONE 0 + +extern uint_t pool_version(uint_t ver); + +#ifndef PO_TRUE +#define PO_TRUE 1 +#endif + +#ifndef PO_FALSE +#define PO_FALSE 0 +#endif + +#ifndef PO_SUCCESS +#define PO_SUCCESS 0 +#endif + +#ifndef PO_FAIL +#define PO_FAIL -1 +#endif + +/* Error codes */ +#define POE_OK 0 +#define POE_BAD_PROP_TYPE 1 +#define POE_INVALID_CONF 2 +#define POE_NOTSUP 3 +#define POE_INVALID_SEARCH 4 +#define POE_BADPARAM 5 +#define POE_PUTPROP 6 +#define POE_DATASTORE 7 +#define POE_SYSTEM 8 +#define POE_ACCESS 9 + +/* Open Flags */ +#define PO_RDONLY 0x0 +#define PO_RDWR 0x1 +#define PO_CREAT 0x2 +#define PO_DISCO 0x4 +#define PO_UPDATE 0x8 +#define PO_TEMP 0x10 + +/* Allocation policy */ +#define POA_IMPORTANCE "importance based" +#define POA_SURPLUS_TO_DEFAULT "surplus to default" + +/* Pools updates */ +#define POU_SYSTEM 0x1 +#define POU_POOL 0x2 +#define POU_PSET 0x4 +#define POU_CPU 0x8 + +/* Data Export Formats */ +typedef enum pool_export_format { + POX_NATIVE, /* Native data representation format */ + POX_TEXT /* Text */ +} pool_export_format_t; + +/* Property data types */ +typedef enum pool_value_class { + POC_INVAL = -1, + POC_UINT, + POC_INT, + POC_DOUBLE, + POC_BOOL, + POC_STRING +} pool_value_class_t; + +/* Validation levels */ +typedef enum pool_valid_level { + POV_NONE = 0, /* No validation */ + POV_LOOSE, /* Loose validation */ + POV_STRICT, /* Strict validation */ + POV_RUNTIME /* Validate instantiation on current machine */ +} pool_valid_level_t; + +/* conf states */ +typedef enum pool_conf_state { + POF_INVALID = -1, + POF_VALID, + POF_DESTROY +} pool_conf_state_t; + +/* Element data values */ +typedef struct pool_value pool_value_t; + +/* Elements */ +typedef struct pool_elem pool_elem_t; +typedef struct pool pool_t; +typedef struct pool_resource pool_resource_t; +typedef struct pool_component pool_component_t; + +/* + * Resource management configuration + */ +typedef struct pool_conf pool_conf_t; + +extern int pool_error(void); +extern const char *pool_strerror(int); +extern int pool_resource_type_list(const char **, uint_t *); +extern int pool_get_status(int *); +extern int pool_set_status(int); + +/* Configuration manipulation */ +extern pool_conf_t *pool_conf_alloc(void); +extern void pool_conf_free(pool_conf_t *); +extern pool_conf_state_t pool_conf_status(const pool_conf_t *); + +extern int pool_conf_close(pool_conf_t *); +extern int pool_conf_remove(pool_conf_t *); +extern int pool_conf_open(pool_conf_t *, const char *, int); +extern int pool_conf_rollback(pool_conf_t *); +extern int pool_conf_commit(pool_conf_t *, int); +extern int pool_conf_export(const pool_conf_t *, const char *, + pool_export_format_t); +extern int pool_conf_validate(const pool_conf_t *, pool_valid_level_t); +extern int pool_conf_update(const pool_conf_t *, int *); +extern pool_t *pool_get_pool(const pool_conf_t *, const char *); +extern pool_t **pool_query_pools(const pool_conf_t *, uint_t *, + pool_value_t **); +extern pool_resource_t *pool_get_resource(const pool_conf_t *, const char *, + const char *); +extern pool_resource_t **pool_query_resources(const pool_conf_t *, uint_t *, + pool_value_t **); +extern pool_component_t **pool_query_components(const pool_conf_t *, uint_t *, + pool_value_t **); +extern const char *pool_conf_location(const pool_conf_t *); +extern char *pool_conf_info(const pool_conf_t *, int); + +/* Resource manipulation */ +extern pool_resource_t *pool_resource_create(pool_conf_t *, const char *, + const char *); +extern int pool_resource_destroy(pool_conf_t *, pool_resource_t *); +extern int pool_resource_transfer(pool_conf_t *, pool_resource_t *, + pool_resource_t *, uint64_t); +extern int pool_resource_xtransfer(pool_conf_t *, pool_resource_t *, + pool_resource_t *, pool_component_t **); +extern pool_component_t **pool_query_resource_components(const pool_conf_t *, + const pool_resource_t *, uint_t *, pool_value_t **); +extern char *pool_resource_info(const pool_conf_t *, const pool_resource_t *, + int); + +/* Pool manipulation */ +extern pool_t *pool_create(pool_conf_t *, const char *); +extern int pool_destroy(pool_conf_t *, pool_t *); +extern int pool_associate(pool_conf_t *, pool_t *, const pool_resource_t *); +extern int pool_dissociate(pool_conf_t *, pool_t *, const pool_resource_t *); +extern char *pool_info(const pool_conf_t *, const pool_t *, int); +extern pool_resource_t **pool_query_pool_resources(const pool_conf_t *, + const pool_t *, uint_t *, pool_value_t **); + +/* Resource Component Manipulation */ +extern pool_resource_t *pool_get_owning_resource(const pool_conf_t *, + const pool_component_t *); +extern char *pool_component_info(const pool_conf_t *, const pool_component_t *, + int); + +/* Property manipulation */ +extern pool_value_class_t pool_get_property(const pool_conf_t *, + const pool_elem_t *, const char *, pool_value_t *); +extern int pool_put_property(pool_conf_t *, pool_elem_t *, const char *, + const pool_value_t *); +extern int pool_rm_property(pool_conf_t *, pool_elem_t *, const char *); + +/* + * Walk the associated properties of the supplied element calling the supplied + * function for each property in turn. There is no implied order in the walk. + * The arg parameter allows caller-specific data to be passed to the call. + */ +extern int pool_walk_properties(pool_conf_t *, pool_elem_t *, void *, + int (*)(pool_conf_t *, pool_elem_t *, const char *, pool_value_t *, + void *)); + +/* Get the underlying element */ +extern pool_elem_t *pool_conf_to_elem(const pool_conf_t *); +extern pool_elem_t *pool_to_elem(const pool_conf_t *, const pool_t *); +extern pool_elem_t *pool_resource_to_elem(const pool_conf_t *, + const pool_resource_t *); +extern pool_elem_t *pool_component_to_elem(const pool_conf_t *, + const pool_component_t *); + +/* Pool Property Value Manipulation */ +/* Get/Set Pool Property Values and Type */ +extern int pool_value_get_uint64(const pool_value_t *, uint64_t *); +extern int pool_value_get_int64(const pool_value_t *, int64_t *); +extern int pool_value_get_double(const pool_value_t *, double *); +extern int pool_value_get_bool(const pool_value_t *, uchar_t *); +extern int pool_value_get_string(const pool_value_t *, const char **); +extern pool_value_class_t pool_value_get_type(const pool_value_t *); +extern void pool_value_set_uint64(pool_value_t *, uint64_t); +extern void pool_value_set_int64(pool_value_t *, int64_t); +extern void pool_value_set_double(pool_value_t *, double); +extern void pool_value_set_bool(pool_value_t *, uchar_t); +extern int pool_value_set_string(pool_value_t *, const char *); +extern const char *pool_value_get_name(const pool_value_t *); +extern int pool_value_set_name(pool_value_t *, const char *); + +/* Pool Property Value Creation/Destruction */ +extern pool_value_t *pool_value_alloc(void); +extern void pool_value_free(pool_value_t *); + +/* Default pool data store locations */ +extern const char *pool_static_location(void); +extern const char *pool_dynamic_location(void); + +/* Binding */ +extern int pool_set_binding(const char *, idtype_t, id_t); +extern char *pool_get_binding(pid_t); +extern char *pool_get_resource_binding(const char *, pid_t); + +/* Walking */ +extern int pool_walk_pools(pool_conf_t *, void *, + int (*)(pool_conf_t *, pool_t *, void *)); +extern int pool_walk_resources(pool_conf_t *, pool_t *, void *, + int (*)(pool_conf_t *, pool_resource_t *, void *)); +extern int pool_walk_components(pool_conf_t *, pool_resource_t *, void *, + int (*)(pool_conf_t *, pool_component_t *, void *)); + +#ifdef __cplusplus +} +#endif + +#endif /* _POOL_H */ diff --git a/illumos-x86_64/usr/include/port.h b/illumos-x86_64/usr/include/port.h new file mode 100644 index 00000000..b26fd990 --- /dev/null +++ b/illumos-x86_64/usr/include/port.h @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PORT_H +#define _PORT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ports API + */ + +int port_create(void); +int port_associate(int, int, uintptr_t, int, void *); +int port_dissociate(int, int, uintptr_t); +int port_send(int, int, void *); +int port_sendn(int [], int [], uint_t, int, void *); +int port_get(int, port_event_t *, struct timespec *); +int port_getn(int, port_event_t [], uint_t, uint_t *, struct timespec *); +int port_alert(int, int, int, void *); + +#ifdef __cplusplus +} +#endif + +#endif /* _PORT_H */ diff --git a/illumos-x86_64/usr/include/pr29.h b/illumos-x86_64/usr/include/pr29.h new file mode 100644 index 00000000..16ef6c86 --- /dev/null +++ b/illumos-x86_64/usr/include/pr29.h @@ -0,0 +1,81 @@ +/* pr29.h --- Detect strings which are non-idempotent under NFKC. + Copyright (C) 2004-2025 Simon Josefsson + + This file is part of GNU Libidn. + + GNU Libidn is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version. + + or both in parallel, as here. + + GNU Libidn is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see . */ + +#ifndef PR29_H +# define PR29_H + +/** + * SECTION:pr29 + * @title: pr29.h + * @short_description: PR29-related functions + * + * PR29-related functions. + */ + +# ifndef IDNAPI +# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY +# define IDNAPI __attribute__((__visibility__("default"))) +# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllexport) +# elif defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllimport) +# else +# define IDNAPI +# endif +# endif + +# ifdef __cplusplus +extern "C" +{ +# endif + + /* Get size_t. */ +# include + + /* Get uint32_t. */ +# include + + /* Error codes. */ + typedef enum + { + PR29_SUCCESS = 0, + PR29_PROBLEM = 1, /* String is a problem sequence. */ + PR29_STRINGPREP_ERROR = 2 /* Charset conversion failed (p29_8*). */ + } Pr29_rc; + + extern IDNAPI const char *pr29_strerror (Pr29_rc rc); + + extern IDNAPI int pr29_4 (const uint32_t * in, size_t len); + extern IDNAPI int pr29_4z (const uint32_t * in); + extern IDNAPI int pr29_8z (const char *in); + +# ifdef __cplusplus +} +# endif +#endif /* PR29_H */ diff --git a/illumos-x86_64/usr/include/priv.h b/illumos-x86_64/usr/include/priv.h new file mode 100644 index 00000000..47125ac9 --- /dev/null +++ b/illumos-x86_64/usr/include/priv.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PRIV_H_ +#define _PRIV_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PRIV_STR_PORT 0x00 /* portable output */ +#define PRIV_STR_LIT 0x01 /* literal output */ +#define PRIV_STR_SHORT 0x02 /* shortest output */ + +#define PRIV_ALLSETS ((priv_ptype_t)0) /* for priv_set() */ + +/* + * library functions prototype. + */ + +extern int setppriv(priv_op_t, priv_ptype_t, const priv_set_t *); +extern int getppriv(priv_ptype_t, priv_set_t *); +extern int setpflags(uint_t, uint_t); +extern uint_t getpflags(uint_t); +extern const priv_impl_info_t *getprivimplinfo(void); + +extern int priv_set(priv_op_t, priv_ptype_t, ...); +extern boolean_t priv_ineffect(const char *); +extern priv_set_t *priv_str_to_set(const char *, const char *, const char **); +extern char *priv_set_to_str(const priv_set_t *, char, int); + +extern int priv_getbyname(const char *); +extern const char *priv_getbynum(int); +extern int priv_getsetbyname(const char *); +extern const char *priv_getsetbynum(int); +extern char *priv_gettext(const char *); + +extern priv_set_t *priv_allocset(void); +extern void priv_freeset(priv_set_t *); + +extern void priv_emptyset(priv_set_t *); +extern void priv_basicset(priv_set_t *); +extern void priv_fillset(priv_set_t *); +extern boolean_t priv_isemptyset(const priv_set_t *); +extern boolean_t priv_isfullset(const priv_set_t *); +extern boolean_t priv_isequalset(const priv_set_t *, const priv_set_t *); +extern boolean_t priv_issubset(const priv_set_t *, const priv_set_t *); +extern void priv_intersect(const priv_set_t *, priv_set_t *); +extern void priv_union(const priv_set_t *, priv_set_t *); +extern void priv_inverse(priv_set_t *); +extern int priv_addset(priv_set_t *, const char *); +extern void priv_copyset(const priv_set_t *, priv_set_t *); +extern int priv_delset(priv_set_t *, const char *); +extern boolean_t priv_ismember(const priv_set_t *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _PRIV_H_ */ diff --git a/illumos-x86_64/usr/include/proc_service.h b/illumos-x86_64/usr/include/proc_service.h new file mode 100644 index 00000000..634e179c --- /dev/null +++ b/illumos-x86_64/usr/include/proc_service.h @@ -0,0 +1,143 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PROC_SERVICE_H +#define _PROC_SERVICE_H + +/* + * Description: + * Types, global variables, and function definitions for provider + * of import functions for users of libc_db and librtld_db. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#if defined(__i386) || defined(__amd64) /* for struct ssd */ +#include +#include +#endif + + +typedef unsigned long psaddr_t; + +typedef enum { + PS_OK, /* generic "call succeeded" */ + PS_ERR, /* generic error */ + PS_BADPID, /* bad process handle */ + PS_BADLID, /* bad lwp identifier */ + PS_BADADDR, /* bad address */ + PS_NOSYM, /* p_lookup() could not find given symbol */ + PS_NOFREGS, /* FPU register set not available for given lwp */ + PS_NOXREGS /* extended register set not available for given lwp */ +} ps_err_e; + +struct ps_prochandle; + +/* + * See for possible values of data_model. + */ +extern ps_err_e ps_pdmodel(struct ps_prochandle *, int *data_model); + +/* + * Special values for 'object_name' to refer to certain well-known objects. + */ +#define PS_OBJ_EXEC ((const char *)0x0) /* the executable file */ +#define PS_OBJ_LDSO ((const char *)0x1) /* the dynamic linker */ + +extern ps_err_e ps_pglobal_lookup(struct ps_prochandle *, + const char *object_name, const char *sym_name, psaddr_t *sym_addr); + +#ifdef _LP64 +typedef Elf64_Sym ps_sym_t; +#else +typedef Elf32_Sym ps_sym_t; +#endif +extern ps_err_e ps_pglobal_sym(struct ps_prochandle *, + const char *object_name, const char *sym_name, ps_sym_t *sym); + +/* + * To read and write the process's address space. + */ +extern ps_err_e ps_pread(struct ps_prochandle *, + psaddr_t, void *, size_t); +extern ps_err_e ps_pwrite(struct ps_prochandle *, + psaddr_t, const void *, size_t); +/* + * The following four functions can be implemented as simple aliases for + * the corresponding primary two functions above (#pragma weak ...). + * They are artifacts of history that must be maintained. + */ +extern ps_err_e ps_pdread(struct ps_prochandle *, + psaddr_t, void *, size_t); +extern ps_err_e ps_pdwrite(struct ps_prochandle *, + psaddr_t, const void *, size_t); +extern ps_err_e ps_ptread(struct ps_prochandle *, + psaddr_t, void *, size_t); +extern ps_err_e ps_ptwrite(struct ps_prochandle *, + psaddr_t, const void *, size_t); + +extern ps_err_e ps_pstop(struct ps_prochandle *); +extern ps_err_e ps_pcontinue(struct ps_prochandle *); +extern ps_err_e ps_lstop(struct ps_prochandle *, lwpid_t); +extern ps_err_e ps_lcontinue(struct ps_prochandle *, lwpid_t); + +extern ps_err_e ps_lgetregs(struct ps_prochandle *, + lwpid_t, prgregset_t); +extern ps_err_e ps_lsetregs(struct ps_prochandle *, + lwpid_t, const prgregset_t); +extern ps_err_e ps_lgetfpregs(struct ps_prochandle *, + lwpid_t, prfpregset_t *); +extern ps_err_e ps_lsetfpregs(struct ps_prochandle *, + lwpid_t, const prfpregset_t *); + +extern ps_err_e ps_lgetxregsize(struct ps_prochandle *, lwpid_t, int *); +extern ps_err_e ps_lgetxregs(struct ps_prochandle *, lwpid_t, caddr_t); +extern ps_err_e ps_lsetxregs(struct ps_prochandle *, lwpid_t, caddr_t); + +#if defined(__i386) || defined(__amd64) +extern ps_err_e ps_lgetLDT(struct ps_prochandle *, lwpid_t, struct ssd *); +#endif + +extern ps_err_e ps_pauxv(struct ps_prochandle *, const auxv_t **); +extern ps_err_e ps_pbrandname(struct ps_prochandle *, char *, size_t); + +extern ps_err_e ps_kill(struct ps_prochandle *, int sig); +extern ps_err_e ps_lrolltoaddr(struct ps_prochandle *, + lwpid_t, psaddr_t go_addr, psaddr_t stop_addr); + +extern void ps_plog(const char *fmt, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROC_SERVICE_H */ diff --git a/illumos-x86_64/usr/include/procfs.h b/illumos-x86_64/usr/include/procfs.h new file mode 100644 index 00000000..8ac5836a --- /dev/null +++ b/illumos-x86_64/usr/include/procfs.h @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _PROCFS_H +#define _PROCFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This include file forces the new structured /proc definitions. + * The structured /proc interface is the preferred API, and the + * older ioctl()-based /proc interface will be removed in a future + * version of Solaris. + */ +#ifdef _STRUCTURED_PROC +#undef _STRUCTURED_PROC +#endif +#define _STRUCTURED_PROC 1 + +#include + +/* + * libproc API + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PROCFS_H */ diff --git a/illumos-x86_64/usr/include/prof.h b/illumos-x86_64/usr/include/prof.h new file mode 100644 index 00000000..91bb6c8e --- /dev/null +++ b/illumos-x86_64/usr/include/prof.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1996-1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _PROF_H +#define _PROF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MARK +#define MARK(K) {} +#else +#undef MARK + +#if defined(__i386) +#define MARK(K) {\ + asm(" .data"); \ + asm(" .align 4"); \ + asm("."#K".:"); \ + asm(" .long 0"); \ + asm(" .text"); \ + asm("M."#K":"); \ + asm(" movl $."#K"., %edx"); \ + asm(" call _mcount"); \ + } +#endif + +#if defined(__sparc) +#define MARK(K) {\ + asm(" .reserve ."#K"., 4, \".bss\", 4"); \ + asm("M."#K":"); \ + asm(" sethi %hi(."#K".), %o0"); \ + asm(" call _mcount"); \ + asm(" or %o0, %lo(."#K".), %o0"); \ + } +#endif + +#endif /* MARK */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PROF_H */ diff --git a/illumos-x86_64/usr/include/prof_attr.h b/illumos-x86_64/usr/include/prof_attr.h new file mode 100644 index 00000000..ce84812b --- /dev/null +++ b/illumos-x86_64/usr/include/prof_attr.h @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _PROF_ATTR_H +#define _PROF_ATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include +#include + + +#define PROFATTR_FILENAME "/etc/security/prof_attr" +#define PROFATTR_DB_NAME "prof_attr.org_dir" +#define PROFATTR_DB_NCOL 5 /* total columns */ +#define PROFATTR_DB_NKEYCOL 1 /* total searchable columns */ +#define PROFATTR_DB_TBLT "prof_attr_tbl" +#define PROFATTR_NAME_DEFAULT_KW "nobody" + +#define PROFATTR_COL0_KW "name" +#define PROFATTR_COL1_KW "res1" +#define PROFATTR_COL2_KW "res2" +#define PROFATTR_COL3_KW "desc" +#define PROFATTR_COL4_KW "attr" + +#define PROFILE_STOP "Stop" + +#define DEF_PROF "PROFS_GRANTED=" +#define DEF_CONSUSER "CONSOLE_USER=" + +#define MAXPROFS 4096 + +/* + * indices of searchable columns + */ +#define PROFATTR_KEYCOL0 0 /* name */ + + +/* + * Key words used in the prof_attr database + */ +#define PROFATTR_AUTHS_KW "auths" +#define PROFATTR_PROFS_KW "profiles" +#define PROFATTR_PRIVS_KW "privs" + + +/* + * Nsswitch representation of profile attributes. + */ + +typedef struct profstr_s { + char *name; /* proforization name */ + char *res1; /* RESERVED */ + char *res2; /* RESERVED */ + char *desc; /* description */ + char *attr; /* string of key-value pair attributes */ +} profstr_t; + +typedef struct profattr_s { + char *name; /* proforization name */ + char *res1; /* RESERVED */ + char *res2; /* RESERVED */ + char *desc; /* description */ + kva_t *attr; /* array of key-value pair attributes */ +} profattr_t; + +extern profattr_t *getprofnam(const char *); +extern profattr_t *getprofattr(void); +extern void getproflist(const char *, char **, int *); +extern void setprofattr(void); +extern void endprofattr(void); +extern void free_profattr(profattr_t *); +extern void free_proflist(char **, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROF_ATTR_H */ diff --git a/illumos-x86_64/usr/include/project.h b/illumos-x86_64/usr/include/project.h new file mode 100644 index 00000000..d1e98568 --- /dev/null +++ b/illumos-x86_64/usr/include/project.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _PROJECT_H +#define _PROJECT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PROJF_PATH "/etc/project" /* pathname of the "project" file */ +#define PROJNAME_MAX 64 /* maximum project name size */ +#define PROJECT_BUFSZ 4096 /* default buffer size */ + +#define SETPROJ_ERR_TASK (-1) /* error creating new task */ +#define SETPROJ_ERR_POOL (-2) /* error binding to pool */ + +struct project { + char *pj_name; /* name of the project */ + projid_t pj_projid; /* numerical project id */ + char *pj_comment; /* project description */ + char **pj_users; /* vector of pointers to project user names */ + char **pj_groups; /* vector of pointers to project group names */ + char *pj_attr; /* project attributes string */ +}; + +extern void setprojent(void); +extern void endprojent(void); +extern struct project *getprojent(struct project *, void *, size_t); +extern struct project *getprojbyname(const char *, + struct project *, void *, size_t); +extern struct project *getprojbyid(projid_t, struct project *, void *, size_t); +extern struct project *getdefaultproj(const char *, + struct project *, void *, size_t); +extern struct project *fgetprojent(FILE *, struct project *, void *, size_t); +extern int inproj(const char *, const char *, void *, size_t); +extern projid_t getprojidbyname(const char *); + +extern projid_t getprojid(void); + +extern projid_t setproject(const char *, const char *, int); +extern int project_walk(int (*)(projid_t, void *), void *); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROJECT_H */ diff --git a/illumos-x86_64/usr/include/protocols/dumprestore.h b/illumos-x86_64/usr/include/protocols/dumprestore.h new file mode 100644 index 00000000..aa081a3e --- /dev/null +++ b/illumos-x86_64/usr/include/protocols/dumprestore.h @@ -0,0 +1,184 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. */ +/* All rights reserved. */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _PROTOCOLS_DUMPRESTORE_H +#define _PROTOCOLS_DUMPRESTORE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This header file defines two different versions of the + * ufsdump/ufsrestore interface. If the defined constant + * SUPPORTS_MTB_TAPE_FORMAT is set, the data structures in + * this header file will support backups of more than 2 terabytes + * of data. + * + * In the old format (the format that only supports dumps + * of less than 2 terabytes), TP_BSIZE is the size of file blocks + * on the dump tapes. + * Note that TP_BSIZE must be a multiple of DEV_BSIZE. + * + * In the new format, tp_bsize is used to store the + * tape block size, which is variable. The tape block size + * is like 'fragsize', in that 'c_tapea' in each tape record + * contains the 'tape block record' number in a signed int. + * We set TP_BSIZE_MAX to 65536, which will handle 128TB + * of data. The new format is indicated by a magic number + * in the tape header of MTB_MAGIC. The new format is only + * used when the size of the backup exceeds 2 TB. If the + * backup can be stored in less thatn 2 TB, ufsdump still + * uses the format indicated by the NFS_MAGIC magic number. + * Therefore, backups of less than 2 TB are still readable + * by earlier versions of ufsrestore. + * + * NTREC is the number of TP_BSIZE blocks that are written + * in each tape record. HIGHDENSITYTREC is the number of + * TP_BSIZE blocks that are written in each tape record on + * 6250 BPI or higher density tapes. CARTRIDGETREC is the + * number of TP_BSIZE (or tp_bsize) blocks that are written + * in each tape record on cartridge tapes. + * + * TP_NINDIR is the number of indirect pointers in a TS_INODE + * or TS_ADDR record. Note that it must be a power of two. + * + */ +#define TP_BSIZE_MAX 65536 +#define TP_BSIZE_MIN 1024 +#define ESIZE_SHIFT_MAX 6 /* shift TP_BSIZE_MIN to TP_BSIZE_MAX */ + +#ifdef SUPPORTS_MTB_TAPE_FORMAT +#define TP_BUFSIZE TP_BSIZE_MAX +extern int32_t tp_bsize; +#else +#define TP_BSIZE 1024 +#define TP_BUFSIZE TP_BSIZE +#endif /* SUPPORTS_MTB_TAPE_FORMAT */ + +#define NTREC 10 +#define HIGHDENSITYTREC 32 +#define CARTRIDGETREC 63 +#define TP_NINDIR (TP_BSIZE_MIN/2) +#define TP_NINOS (TP_NINDIR / sizeof (long)) +#define LBLSIZE 16 +#define NAMELEN 64 + +#define OFS_MAGIC (int)60011 +#define NFS_MAGIC (int)60012 +#define MTB_MAGIC (int)60013 +#define CHECKSUM (int)84446 + +union u_data { + char s_addrs[TP_NINDIR]; /* 1 => data; 0 => hole in inode */ + int32_t s_inos[TP_NINOS]; /* starting inodes on tape */ +}; + +union u_shadow { + struct s_nonsh { + int32_t c_level; /* level of this dump */ + char c_filesys[NAMELEN]; /* dumpped file system name */ + char c_dev[NAMELEN]; /* name of dumpped device */ + char c_host[NAMELEN]; /* name of dumpped host */ + } c_nonsh; + char c_shadow[1]; +}; + +/* if you change anything here, be sure to change normspcl in byteorder.c */ + +extern union u_spcl { + char dummy[TP_BUFSIZE]; + struct s_spcl { + int32_t c_type; /* record type (see below) */ + time32_t c_date; /* date of previous dump */ + time32_t c_ddate; /* date of this dump */ + int32_t c_volume; /* dump volume number */ + daddr32_t c_tapea; /* logical block of this record */ + ino32_t c_inumber; /* number of inode */ + int32_t c_magic; /* magic number (see above) */ + int32_t c_checksum; /* record checksum */ + struct dinode c_dinode; /* ownership and mode of inode */ + int32_t c_count; /* number of valid c_addr entries */ + union u_data c_data; /* see union above */ + char c_label[LBLSIZE]; /* dump label */ + union u_shadow c_shadow; /* see union above */ + int32_t c_flags; /* additional information */ + int32_t c_firstrec; /* first record on volume */ +#ifdef SUPPORTS_MTB_TAPE_FORMAT + int32_t c_tpbsize; /* tape block size */ + int32_t c_spare[31]; /* reserved for future uses */ +#else + int32_t c_spare[32]; +#endif /* SUPPORTS_MTB_TAPE_FORMAT */ + } s_spcl; +} u_spcl; +#define spcl u_spcl.s_spcl +#define c_addr c_data.s_addrs +#define c_inos c_data.s_inos +#define c_level c_shadow.c_nonsh.c_level +#define c_filesys c_shadow.c_nonsh.c_filesys +#define c_dev c_shadow.c_nonsh.c_dev +#define c_host c_shadow.c_nonsh.c_host + +/* + * special record types + */ +#define TS_TAPE 1 /* dump tape header */ +#define TS_INODE 2 /* beginning of file record */ +#define TS_ADDR 4 /* continuation of file record */ +#define TS_BITS 3 /* map of inodes on tape */ +#define TS_CLRI 6 /* map of inodes deleted since last dump */ +#define TS_END 5 /* end of volume marker */ +#define TS_EOM 7 /* floppy EOM - restore compat w/ old dump */ + +/* + * flag values + */ +#define DR_NEWHEADER 1 /* new format tape header */ +#define DR_INODEINFO 2 /* header contains starting inode info */ +#define DR_REDUMP 4 /* dump contains recopies of active files */ +#define DR_TRUEINC 8 /* dump is a "true incremental" */ +#define DR_HASMETA 16 /* metadata in this header */ + + + +#define DUMPOUTFMT "%-32s %c %s" /* for printf */ + /* name, incno, ctime(date) */ +#define DUMPINFMT "%258s %c %128[^\n]\n" /* inverse for scanf */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_PROTOCOLS_DUMPRESTORE_H */ diff --git a/illumos-x86_64/usr/include/protocols/routed.h b/illumos-x86_64/usr/include/protocols/routed.h new file mode 100644 index 00000000..232eb1ad --- /dev/null +++ b/illumos-x86_64/usr/include/protocols/routed.h @@ -0,0 +1,235 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgment: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Routing Information Protocol + * + * Derived from Xerox NS Routing Information Protocol + * by changing 32-bit net numbers to sockaddr's and + * padding stuff to 32-bit boundaries. + */ + +#ifndef _PROTOCOLS_ROUTED_H +#define _PROTOCOLS_ROUTED_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* The RIPv2 protocol is described in RFC 2453 */ + +#define RIPv1 1 +#define RIPv2 2 +#ifndef RIPVERSION +#define RIPVERSION RIPv1 +#endif + +#define RIP_PORT 520 + +#if RIPVERSION == RIPv1 +struct netinfo { + struct sockaddr rip_dst; /* destination net/host */ + uint32_t rip_metric; /* cost of route */ +}; +#else +struct netinfo { + uint16_t n_family; +#define RIP_AF_INET htons(AF_INET) +#define RIP_AF_UNSPEC 0 +#define RIP_AF_AUTH 0xffff + uint16_t n_tag; /* optional in RIPv2 */ + uint32_t n_dst; /* destination net or host */ +#define RIP_DEFAULT 0 + uint32_t n_mask; /* netmask in RIPv2 */ + uint32_t n_nhop; /* optional next hop in RIPv2 */ + uint32_t n_metric; /* cost of route */ +}; +#endif /* RIPv1 */ + +/* RIPv2 authentication */ +struct netauth { + uint16_t a_family; /* always RIP_AF_AUTH */ + uint16_t a_type; +#define RIP_AUTH_NONE 0 +#define RIP_AUTH_TRAILER htons(1) /* authentication data */ +#define RIP_AUTH_PW htons(2) /* password type */ +#define RIP_AUTH_MD5 htons(3) /* Keyed MD5 */ + union { +#define RIP_AUTH_PW_LEN 16 + uint8_t au_pw[RIP_AUTH_PW_LEN]; + struct a_md5 { + int16_t md5_pkt_len; /* RIP-II packet length */ + int8_t md5_keyid; /* key ID and auth data len */ + int8_t md5_auth_len; /* 16 */ + uint32_t md5_seqno; /* sequence number */ + uint32_t rsvd[2]; /* must be 0 */ +#define RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN + } a_md5; + } au; +}; + +struct rip_emetric { + uint16_t rip_metric; + uint16_t rip_mask; + uint32_t rip_token[1]; +}; + +struct rip_sec_entry { + uint32_t rip_dst; + uint32_t rip_count; + struct rip_emetric rip_emetric[1]; +}; + +struct rip { + uint8_t rip_cmd; /* request/response */ + uint8_t rip_vers; /* protocol version # */ + uint16_t rip_res1; /* pad to 32-bit boundary */ + union { /* variable length... */ + struct netinfo ru_nets[1]; /* variable length... */ + char ru_tracefile[1]; /* ditto ... */ + struct netauth ru_auth[1]; + struct { + uint32_t rip_generation; + struct rip_sec_entry rip_sec_entry[1]; + } ru_tsol; + } ripun; +#define rip_nets ripun.ru_nets +#define rip_tracefile ripun.ru_tracefile +#define rip_auths ripun.ru_auth +#define rip_tsol ripun.ru_tsol +}; + +struct entryinfo { + struct sockaddr rtu_dst; + struct sockaddr rtu_router; + short rtu_flags; + short rtu_state; + int rtu_timer; + int rtu_metric; + int int_flags; + char int_name[16]; +}; + +typedef struct rdisc_info_s { + uint_t info_type; + uint_t info_version; + uint_t info_num_of_routers; +} rdisc_info_t; + +/* + * Structure that is returned with the default router info. + */ +typedef struct defr_s { + uint32_t defr_info_type; + uint32_t defr_version; + struct in_addr defr_addr; + uint32_t defr_index; + uint32_t defr_life; + uint32_t defr_pref; +} defr_t; + + +/* + * Packet types. + */ +#define RIPCMD_REQUEST 1 /* want info - from suppliers */ +#define RIPCMD_RESPONSE 2 /* responding to request */ +#define RIPCMD_TRACEON 3 /* turn tracing on */ +#define RIPCMD_TRACEOFF 4 /* turn it off */ + +/* + * Gated extended RIP to include a "poll" command instead of using + * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says + * command 5 is used by Sun Microsystems for its own purposes. + */ +#define RIPCMD_POLL 5 /* like request, but anyone answers */ +#define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */ + +#define RIPCMD_SEC_RESPONSE 51 /* response includes E-metrics */ +#define RIPCMD_SEC_T_RESPONSE 52 /* tunneling */ + +#define RIPCMD_MAX 7 + +#define RDISC_SNMP_SOCKET "/var/run/in.rdisc_mib" + +#define RDISC_SNMP_INFO_REQ 1 +#define RDISC_SNMP_INFO_RESPONSE 2 +#define RDISC_DEF_ROUTER_INFO 3 + +#define RDISC_SNMP_INFO_VER 1 +#define RDISC_DEF_ROUTER_VER 1 + +#define HOPCNT_INFINITY 16 /* per Xerox NS */ +#define MAXPACKETSIZE 512 /* max broadcast size */ +#define NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip)) \ + / sizeof (struct netinfo) +1) + +#define INADDR_RIP_GROUP 0xe0000009U /* 224.0.0.9 */ + +/* + * Timer values used in managing the routing table. + * + * Complete tables are broadcast every SUPPLY_INTERVAL seconds. + * If changes occur between updates, dynamic updates containing only changes + * may be sent. When these are sent, a timer is set for a random value + * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates + * are sent until the timer expires. + * + * Every update of a routing entry forces an entry's timer to be reset. + * After EXPIRE_TIME without updates, the entry is marked invalid, + * but held onto until GARBAGE_TIME so that others may see it, to + * "poison" the bad route. + */ +#define TIMER_RATE 30 /* alarm clocks every 30 seconds */ + +#define SUPPLY_INTERVAL 30 /* time to supply tables */ +#define MIN_WAITTIME 2 /* min sec until next flash updates */ +#define MAX_WAITTIME 5 /* max sec until flash update */ + +#define STALE_TIME 90 /* switch to a new gateway */ +#define EXPIRE_TIME 180 /* time to mark entry invalid */ +#define GARBAGE_TIME 300 /* time to garbage collect */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PROTOCOLS_ROUTED_H */ diff --git a/illumos-x86_64/usr/include/protocols/rwhod.h b/illumos-x86_64/usr/include/protocols/rwhod.h new file mode 100644 index 00000000..dfcab41b --- /dev/null +++ b/illumos-x86_64/usr/include/protocols/rwhod.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1989 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +/* + * rwho protocol packet format. + */ + +#ifndef _PROTOCOLS_RWHOD_H +#define _PROTOCOLS_RWHOD_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct outmp { + char out_line[8]; /* tty name */ + char out_name[8]; /* user id */ + long out_time; /* time on */ +}; + +struct whod { + char wd_vers; /* protocol version # */ + char wd_type; /* packet type, see below */ + char wd_pad[2]; + int wd_sendtime; /* time stamp by sender */ + int wd_recvtime; /* time stamp applied by receiver */ + char wd_hostname[32]; /* hosts's name */ + int wd_loadav[3]; /* load average as in uptime */ + int wd_boottime; /* time system booted */ + struct whoent { + struct outmp we_utmp; /* active tty info */ + int we_idle; /* tty idle time */ + } wd_we[1024 / sizeof (struct whoent)]; +}; + +#define WHODVERSION 1 +#define WHODTYPE_STATUS 1 /* host status */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PROTOCOLS_RWHOD_H */ diff --git a/illumos-x86_64/usr/include/protocols/timed.h b/illumos-x86_64/usr/include/protocols/timed.h new file mode 100644 index 00000000..6c44afe5 --- /dev/null +++ b/illumos-x86_64/usr/include/protocols/timed.h @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +/* + * Time Synchronization Protocol + */ + +#ifndef _PROTOCOLS_TIMED_H +#define _PROTOCOLS_TIMED_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define TSPVERSION 1 +#define ANYADDR NULL + +struct tsp { + uchar_t tsp_type; + uchar_t tsp_vers; + short tsp_seq; + struct timeval tsp_time; + char tsp_name[MAXHOSTNAMELEN]; +}; + +/* + * Command types. + */ +#define TSP_ANY 0 /* match any types */ +#define TSP_ADJTIME 1 /* send adjtime */ +#define TSP_ACK 2 /* generic acknowledgement */ +#define TSP_MASTERREQ 3 /* ask for master's name */ +#define TSP_MASTERACK 4 /* acknowledge master request */ +#define TSP_SETTIME 5 /* send network time */ +#define TSP_MASTERUP 6 /* inform slaves that master is up */ +#define TSP_SLAVEUP 7 /* slave is up but not polled */ +#define TSP_ELECTION 8 /* advance candidature for master */ +#define TSP_ACCEPT 9 /* support candidature of master */ +#define TSP_REFUSE 10 /* reject candidature of master */ +#define TSP_CONFLICT 11 /* two or more masters present */ +#define TSP_RESOLVE 12 /* masters' conflict resolution */ +#define TSP_QUIT 13 /* reject candidature if master is up */ +#define TSP_DATE 14 /* reset the time (date command) */ +#define TSP_DATEREQ 15 /* remote request to reset the time */ +#define TSP_DATEACK 16 /* acknowledge time setting */ +#define TSP_TRACEON 17 /* turn tracing on */ +#define TSP_TRACEOFF 18 /* turn tracing off */ +#define TSP_MSITE 19 /* find out master's site */ +#define TSP_MSITEREQ 20 /* remote master's site request */ +#define TSP_TEST 21 /* for testing election algo */ + +#define TSPTYPENUMBER 22 + +#ifdef TSPTYPES +char *tsptype[TSPTYPENUMBER] = + {"ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", + "MASTERUP", "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", + "RESOLVE", "QUIT", "DATE", "DATEREQ", "DATEACK", "TRACEON", + "TRACEOFF", "MSITE", "MSITEREQ", "TEST"}; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _PROTOCOLS_TIMED_H */ diff --git a/illumos-x86_64/usr/include/pthread.h b/illumos-x86_64/usr/include/pthread.h new file mode 100644 index 00000000..95849ee2 --- /dev/null +++ b/illumos-x86_64/usr/include/pthread.h @@ -0,0 +1,390 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2018 Joyent, Inc. + * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PTHREAD_H +#define _PTHREAD_H + +#include + +#ifndef _ASM +#include +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Thread related attribute values defined as in thread.h. + * These are defined as bit pattern in thread.h. + * Any change here should be reflected in thread.h. + */ +/* detach */ +#define PTHREAD_CREATE_DETACHED 0x40 /* = THR_DETACHED */ +#define PTHREAD_CREATE_JOINABLE 0 +/* scope */ +#define PTHREAD_SCOPE_SYSTEM 0x01 /* = THR_BOUND */ +#define PTHREAD_SCOPE_PROCESS 0 + +/* + * Other attributes which are not defined in thread.h + */ +/* inherit */ +#define PTHREAD_INHERIT_SCHED 1 +#define PTHREAD_EXPLICIT_SCHED 0 + +/* + * Value of process-shared attribute + * These are defined as values defined in sys/synch.h + * Any change here should be reflected in sys/synch.h. + */ +#define PTHREAD_PROCESS_SHARED 1 /* = USYNC_PROCESS */ +#define PTHREAD_PROCESS_PRIVATE 0 /* = USYNC_THREAD */ + +/* + * mutex types + * + * _ERRORCHECK and _RERCURSIVE are kept in line with their corresponding values + * in sys/synch.h; however, in general these types have their own semantics. + */ +#define PTHREAD_MUTEX_NORMAL 0x0 +#define PTHREAD_MUTEX_ERRORCHECK 0x2 +#define PTHREAD_MUTEX_RECURSIVE 0x4 +#define PTHREAD_MUTEX_DEFAULT 0x8 + +/* + * Mutex protocol values. Keep these in synch with sys/synch.h lock types. + */ +#define PTHREAD_PRIO_NONE 0x0 +#define PTHREAD_PRIO_INHERIT 0x10 +#define PTHREAD_PRIO_PROTECT 0x20 + +/* + * Mutex robust attribute values. + * Keep these in synch with sys/synch.h lock types. + */ +#define PTHREAD_MUTEX_STALLED 0x0 +#define PTHREAD_MUTEX_ROBUST 0x40 +/* + * Historical solaris-specific names, + * from before pthread_mutexattr_getrobust() became standardized + */ +#define PTHREAD_MUTEX_STALL_NP PTHREAD_MUTEX_STALLED +#define PTHREAD_MUTEX_ROBUST_NP PTHREAD_MUTEX_ROBUST + +/* + * macros - default initializers defined as in synch.h + * Any change here should be reflected in synch.h. + * + * NOTE: + * Make sure that any change in the macros is consistent with the definition + * of the corresponding types in sys/types.h (e.g. PTHREAD_MUTEX_INITIALIZER + * should be consistent with the definition for pthread_mutex_t). + */ +#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \ + {{0, 0, 0, PTHREAD_PROCESS_PRIVATE, _MUTEX_MAGIC}, {{{0}}}, 0} + +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP /* = ERRORCHECKMUTEX */ \ + {{0, 0, 0, PTHREAD_PROCESS_PRIVATE | PTHREAD_MUTEX_ERRORCHECK, \ + _MUTEX_MAGIC}, {{{0}}}, 0} + +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP /* = RECURSIVEMUTEX */ \ + {{0, 0, 0, PTHREAD_PROCESS_PRIVATE | PTHREAD_MUTEX_RECURSIVE | \ + PTHREAD_MUTEX_ERRORCHECK, _MUTEX_MAGIC}, {{{0}}}, 0} + +#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \ + {{{0, 0, 0, 0}, PTHREAD_PROCESS_PRIVATE, _COND_MAGIC}, 0} + +#define PTHREAD_RWLOCK_INITIALIZER /* = DEFAULTRWLOCK */ \ + {0, PTHREAD_PROCESS_PRIVATE, _RWL_MAGIC, PTHREAD_MUTEX_INITIALIZER, \ + PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER} + +/* cancellation type and state */ +#define PTHREAD_CANCEL_ENABLE 0x00 +#define PTHREAD_CANCEL_DISABLE 0x01 +#define PTHREAD_CANCEL_DEFERRED 0x00 +#define PTHREAD_CANCEL_ASYNCHRONOUS 0x02 +#define PTHREAD_CANCELED (void *)-19 + +/* pthread_once related values */ +#define PTHREAD_ONCE_NOTDONE 0 +#define PTHREAD_ONCE_DONE 1 +#define PTHREAD_ONCE_INIT { {0, 0, 0, PTHREAD_ONCE_NOTDONE} } + +/* + * The key to be created by pthread_key_create_once_np() + * must be statically initialized with PTHREAD_ONCE_KEY_NP. + * This must be the same as THR_ONCE_KEY in + */ +#define PTHREAD_ONCE_KEY_NP (pthread_key_t)(-1) + +/* barriers */ +#define PTHREAD_BARRIER_SERIAL_THREAD -2 + +/* For pthread_{get,set}name_np(). */ +#define PTHREAD_MAX_NAMELEN_NP (32) + +#ifndef _ASM + +/* + * cancellation cleanup structure + */ +typedef struct _cleanup { + uintptr_t pthread_cleanup_pad[4]; +} _cleanup_t; + +void __pthread_cleanup_push(void (*)(void *), void *, caddr_t, _cleanup_t *); +void __pthread_cleanup_pop(int, _cleanup_t *); +caddr_t _getfp(void); + +#if __cplusplus +extern "C" { +#endif + +typedef void (*_Voidfp)(void*); /* pointer to extern "C" function */ + +#if __cplusplus +} /* extern "C" */ +#endif + +#define pthread_cleanup_push(routine, args) { \ + _cleanup_t _cleanup_info; \ + __pthread_cleanup_push((_Voidfp)(routine), (void *)(args), \ + (caddr_t)_getfp(), &_cleanup_info); + +#define pthread_cleanup_pop(ex) \ + __pthread_cleanup_pop(ex, &_cleanup_info); \ +} + +/* + * function prototypes - thread related calls + */ + +/* + * pthread_atfork() is also declared in as per SUSv2. The + * declarations are identical. A change to either one may also require + * appropriate namespace updates in order to avoid redeclaration + * warnings in the case where both prototypes are exposed via inclusion + * of both and . + */ +extern int pthread_atfork(void (*) (void), void (*) (void), void (*) (void)); +extern int pthread_attr_init(pthread_attr_t *); +extern int pthread_attr_destroy(pthread_attr_t *); +extern int pthread_attr_setstack(pthread_attr_t *, void *, size_t); +extern int pthread_attr_getstack(const pthread_attr_t *_RESTRICT_KYWD, + void **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD); +extern int pthread_attr_setstacksize(pthread_attr_t *, size_t); +extern int pthread_attr_getstacksize(const pthread_attr_t *_RESTRICT_KYWD, + size_t *_RESTRICT_KYWD); +extern int pthread_attr_setstackaddr(pthread_attr_t *, void *); +extern int pthread_attr_getstackaddr(const pthread_attr_t *_RESTRICT_KYWD, + void **_RESTRICT_KYWD); +extern int pthread_attr_setdetachstate(pthread_attr_t *, int); +extern int pthread_attr_getdetachstate(const pthread_attr_t *, int *); +extern int pthread_attr_setscope(pthread_attr_t *, int); +extern int pthread_attr_getscope(const pthread_attr_t *_RESTRICT_KYWD, + int *_RESTRICT_KYWD); +extern int pthread_attr_setinheritsched(pthread_attr_t *, int); +extern int pthread_attr_getinheritsched(const pthread_attr_t *_RESTRICT_KYWD, + int *_RESTRICT_KYWD); +extern int pthread_attr_setschedpolicy(pthread_attr_t *, int); +extern int pthread_attr_getschedpolicy(const pthread_attr_t *_RESTRICT_KYWD, + int *_RESTRICT_KYWD); +extern int pthread_attr_setschedparam(pthread_attr_t *_RESTRICT_KYWD, + const struct sched_param *_RESTRICT_KYWD); +extern int pthread_attr_getschedparam(const pthread_attr_t *_RESTRICT_KYWD, + struct sched_param *_RESTRICT_KYWD); +extern int pthread_attr_setname_np(pthread_attr_t *_RESTRICT_KYWD, + const char *_RESTRICT_KYWD); +extern int pthread_attr_getname_np(pthread_attr_t *_RESTRICT_KYWD, + char *_RESTRICT_KYWD, size_t); +extern int pthread_create(pthread_t *_RESTRICT_KYWD, + const pthread_attr_t *_RESTRICT_KYWD, void * (*)(void *), + void *_RESTRICT_KYWD); +extern int pthread_once(pthread_once_t *, void (*)(void)); +extern int pthread_join(pthread_t, void **); +extern int pthread_detach(pthread_t); +extern void pthread_exit(void *) __NORETURN; +extern int pthread_cancel(pthread_t); +extern int pthread_setschedparam(pthread_t, int, const struct sched_param *); +extern int pthread_getschedparam(pthread_t, int *_RESTRICT_KYWD, + struct sched_param *_RESTRICT_KYWD); +extern int pthread_setschedprio(pthread_t, int); +extern int pthread_setcancelstate(int, int *); +extern int pthread_setcanceltype(int, int *); +extern void pthread_testcancel(void); +extern int pthread_equal(pthread_t, pthread_t); +extern int pthread_key_create(pthread_key_t *, void (*)(void *)); +extern int pthread_key_create_once_np(pthread_key_t *, void (*)(void *)); +extern int pthread_key_delete(pthread_key_t); +extern int pthread_setspecific(pthread_key_t, const void *); +extern void *pthread_getspecific(pthread_key_t); +extern pthread_t pthread_self(void); +extern int pthread_setname_np(pthread_t, const char *); +extern int pthread_getname_np(pthread_t, char *, size_t); + +/* + * function prototypes - synchronization related calls + */ +extern int pthread_mutexattr_init(pthread_mutexattr_t *); +extern int pthread_mutexattr_destroy(pthread_mutexattr_t *); +extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); +extern int pthread_mutexattr_getpshared( + const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); +extern int pthread_mutexattr_getprotocol( + const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int); +extern int pthread_mutexattr_getprioceiling( + const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int); +extern int pthread_mutexattr_getrobust( + const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern int pthread_mutex_init(pthread_mutex_t *_RESTRICT_KYWD, + const pthread_mutexattr_t *_RESTRICT_KYWD); +extern int pthread_mutex_consistent(pthread_mutex_t *); +extern int pthread_mutex_destroy(pthread_mutex_t *); +extern int pthread_mutex_lock(pthread_mutex_t *); +extern int pthread_mutex_clocklock(pthread_mutex_t *_RESTRICT_KYWD, + clockid_t, const struct timespec *_RESTRICT_KYWD); +extern int pthread_mutex_timedlock(pthread_mutex_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +extern int pthread_mutex_relclocklock_np(pthread_mutex_t *_RESTRICT_KYWD, + clockid_t, const struct timespec *_RESTRICT_KYWD); +extern int pthread_mutex_reltimedlock_np(pthread_mutex_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +extern int pthread_mutex_unlock(pthread_mutex_t *); +extern int pthread_mutex_trylock(pthread_mutex_t *); +extern int pthread_mutex_setprioceiling(pthread_mutex_t *_RESTRICT_KYWD, + int, int *_RESTRICT_KYWD); +extern int pthread_mutex_getprioceiling(const pthread_mutex_t *_RESTRICT_KYWD, + int *_RESTRICT_KYWD); +extern int pthread_condattr_init(pthread_condattr_t *); +extern int pthread_condattr_destroy(pthread_condattr_t *); +extern int pthread_condattr_setclock(pthread_condattr_t *, clockid_t); +extern int pthread_condattr_getclock(const pthread_condattr_t *_RESTRICT_KYWD, + clockid_t *_RESTRICT_KYWD); +extern int pthread_condattr_setpshared(pthread_condattr_t *, int); +extern int pthread_condattr_getpshared(const pthread_condattr_t *_RESTRICT_KYWD, + int *_RESTRICT_KYWD); +extern int pthread_cond_init(pthread_cond_t *_RESTRICT_KYWD, + const pthread_condattr_t *_RESTRICT_KYWD); +extern int pthread_cond_destroy(pthread_cond_t *); +extern int pthread_cond_broadcast(pthread_cond_t *); +extern int pthread_cond_signal(pthread_cond_t *); +extern int pthread_cond_wait(pthread_cond_t *_RESTRICT_KYWD, + pthread_mutex_t *_RESTRICT_KYWD); +extern int pthread_cond_clockwait(pthread_cond_t *_RESTRICT_KYWD, + pthread_mutex_t *_RESTRICT_KYWD, clockid_t, + const struct timespec *_RESTRICT_KYWD); +extern int pthread_cond_timedwait(pthread_cond_t *_RESTRICT_KYWD, + pthread_mutex_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD); +extern int pthread_cond_relclockwait_np(pthread_cond_t *_RESTRICT_KYWD, + pthread_mutex_t *_RESTRICT_KYWD, clockid_t, + const struct timespec *_RESTRICT_KYWD); +extern int pthread_cond_reltimedwait_np(pthread_cond_t *_RESTRICT_KYWD, + pthread_mutex_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD); +extern int pthread_attr_getguardsize(const pthread_attr_t *_RESTRICT_KYWD, + size_t *_RESTRICT_KYWD); +extern int pthread_attr_setguardsize(pthread_attr_t *, size_t); +extern int pthread_getconcurrency(void); +extern int pthread_setconcurrency(int); +extern int pthread_mutexattr_settype(pthread_mutexattr_t *, int); +extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *_RESTRICT_KYWD, + int *_RESTRICT_KYWD); +extern int pthread_rwlock_init(pthread_rwlock_t *_RESTRICT_KYWD, + const pthread_rwlockattr_t *_RESTRICT_KYWD); +extern int pthread_rwlock_destroy(pthread_rwlock_t *); +extern int pthread_rwlock_rdlock(pthread_rwlock_t *); +extern int pthread_rwlock_clockrdlock(pthread_rwlock_t *_RESTRICT_KYWD, + clockid_t, const struct timespec *_RESTRICT_KYWD); +extern int pthread_rwlock_timedrdlock(pthread_rwlock_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +extern int pthread_rwlock_relclockrdlock_np(pthread_rwlock_t *_RESTRICT_KYWD, + clockid_t, const struct timespec *_RESTRICT_KYWD); +extern int pthread_rwlock_reltimedrdlock_np(pthread_rwlock_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +extern int pthread_rwlock_tryrdlock(pthread_rwlock_t *); +extern int pthread_rwlock_wrlock(pthread_rwlock_t *); +extern int pthread_rwlock_clockwrlock(pthread_rwlock_t *_RESTRICT_KYWD, + clockid_t, const struct timespec *_RESTRICT_KYWD); +extern int pthread_rwlock_timedwrlock(pthread_rwlock_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +extern int pthread_rwlock_relclockwrlock_np(pthread_rwlock_t *_RESTRICT_KYWD, + clockid_t, const struct timespec *_RESTRICT_KYWD); +extern int pthread_rwlock_reltimedwrlock_np(pthread_rwlock_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +extern int pthread_rwlock_trywrlock(pthread_rwlock_t *); +extern int pthread_rwlock_unlock(pthread_rwlock_t *); +extern int pthread_rwlockattr_init(pthread_rwlockattr_t *); +extern int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); +extern int pthread_rwlockattr_getpshared( + const pthread_rwlockattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); +extern int pthread_spin_init(pthread_spinlock_t *, int); +extern int pthread_spin_destroy(pthread_spinlock_t *); +extern int pthread_spin_lock(pthread_spinlock_t *); +extern int pthread_spin_trylock(pthread_spinlock_t *); +extern int pthread_spin_unlock(pthread_spinlock_t *); +extern int pthread_barrierattr_init(pthread_barrierattr_t *); +extern int pthread_barrierattr_destroy(pthread_barrierattr_t *); +extern int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); +extern int pthread_barrierattr_getpshared( + const pthread_barrierattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern int pthread_barrier_init(pthread_barrier_t *_RESTRICT_KYWD, + const pthread_barrierattr_t *_RESTRICT_KYWD, uint_t); +extern int pthread_barrier_destroy(pthread_barrier_t *); +extern int pthread_barrier_wait(pthread_barrier_t *); + +/* Historical names -- present only for binary compatibility */ +extern int pthread_mutex_consistent_np(pthread_mutex_t *); +extern int pthread_mutexattr_setrobust_np(pthread_mutexattr_t *, int); +extern int pthread_mutexattr_getrobust_np( + const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); + +/* + * These are non-standardized extensions that we provide. Their origins are + * documented in their manual pages. + */ +#if !defined(_STRICT_SYMBOLS) +extern int pthread_attr_get_np(pthread_t, pthread_attr_t *); +extern void pthread_mutex_enter_np(pthread_mutex_t *); +extern void pthread_mutex_exit_np(pthread_mutex_t *); +#endif /* !_STRICT_SYMBOLS */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PTHREAD_H */ diff --git a/illumos-x86_64/usr/include/punycode.h b/illumos-x86_64/usr/include/punycode.h new file mode 100644 index 00000000..17dcc37d --- /dev/null +++ b/illumos-x86_64/usr/include/punycode.h @@ -0,0 +1,247 @@ +/* punycode.h --- Declarations for punycode functions. + Copyright (C) 2002-2025 Simon Josefsson + + This file is part of GNU Libidn. + + GNU Libidn is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version. + + or both in parallel, as here. + + GNU Libidn is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see . */ + +/* + * This file is derived from RFC 3492bis written by Adam M. Costello, + * downloaded from http://www.nicemice.net/idn/punycode-spec.gz on + * 2015-03-02 with SHA1 a966a8017f6be579d74a50a226accc7607c40133, a + * copy of which is stored in the GNU Libidn version controlled + * repository under doc/specification/punycode-spec.gz. + * + * The changes compared to Adam's file include: re-indentation, adding + * the license boilerplate and this comment, adding the #ifndef + * PUNYCODE_H and IDNAPI blocks, changing the return code of + * punycode_encode and punycode_decode from enum to int, simplifying + * the definition of punycode_uint by #include'ing idn-int.h and using + * uint32_t instead of limit.h-based code, adding Punycode_status and + * punycode_strerror, adding 'extern IDNAPI' declarations to function + * prototypes, and mentioning variable names in function prototypes. + * + * Adam's file contains the following: + * + * punycode-sample.c 2.0.0 (2004-Mar-21-Sun) + * http://www.nicemice.net/idn/ + * Adam M. Costello + * http://www.nicemice.net/amc/ + * + * This is ANSI C code (C89) implementing Punycode 1.0.x. + * + * Disclaimer and license: Regarding this entire document or any + * portion of it (including the pseudocode and C code), the author + * makes no guarantees and is not responsible for any damage resulting + * from its use. The author grants irrevocable permission to anyone + * to use, modify, and distribute it in any way that does not diminish + * the rights of anyone else to use, modify, and distribute it, + * provided that redistributed derivative works do not contain + * misleading author or version information. Derivative works need + * not be licensed under similar terms. + */ + +#ifndef PUNYCODE_H +# define PUNYCODE_H + +/** + * SECTION:punycode + * @title: punycode.h + * @short_description: Punycode-related functions + * + * Punycode-related functions. + */ + +# ifndef IDNAPI +# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY +# define IDNAPI __attribute__((__visibility__("default"))) +# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllexport) +# elif defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllimport) +# else +# define IDNAPI +# endif +# endif + +# ifdef __cplusplus +extern "C" +{ +# endif + +/************************************************************/ +/* Public interface (would normally go in its own .h file): */ + +# include /* size_t */ +# include /* uint32_t */ + + enum punycode_status + { + punycode_success = 0, + punycode_bad_input = 1, /* Input is invalid. */ + punycode_big_output = 2, /* Output would exceed the space provided. */ + punycode_overflow = 3 /* Wider integers needed to process input. */ + }; + + typedef enum + { + PUNYCODE_SUCCESS = punycode_success, + PUNYCODE_BAD_INPUT = punycode_bad_input, + PUNYCODE_BIG_OUTPUT = punycode_big_output, + PUNYCODE_OVERFLOW = punycode_overflow + } Punycode_status; + + extern IDNAPI const char *punycode_strerror (Punycode_status rc); + +/* punycode_uint needs to be unsigned and needs to be */ +/* at least 26 bits wide. The particular type can be */ +/* specified by defining PUNYCODE_UINT, otherwise a */ +/* suitable type will be chosen automatically. */ + + typedef uint32_t punycode_uint; + + extern IDNAPI int punycode_encode (size_t input_length, + const punycode_uint input[], + const unsigned char case_flags[], + size_t *output_length, char output[]); + +/* + punycode_encode() converts a sequence of code points (presumed to be + Unicode code points) to Punycode. + + Input arguments (to be supplied by the caller): + + input_length + The number of code points in the input array and the number + of flags in the case_flags array. + + input + An array of code points. They are presumed to be Unicode + code points, but that is not strictly necessary. The + array contains code points, not code units. UTF-16 uses + code units D800 through DFFF to refer to code points + 10000..10FFFF. The code points D800..DFFF do not occur in + any valid Unicode string. The code points that can occur in + Unicode strings (0..D7FF and E000..10FFFF) are also called + Unicode scalar values. + + case_flags + A null pointer or an array of boolean values parallel to + the input array. Nonzero (true, flagged) suggests that the + corresponding Unicode character be forced to uppercase after + being decoded (if possible), and zero (false, unflagged) + suggests that it be forced to lowercase (if possible). + ASCII code points (0..7F) are encoded literally, except that + ASCII letters are forced to uppercase or lowercase according + to the corresponding case flags. If case_flags is a null + pointer then ASCII letters are left as they are, and other + code points are treated as unflagged. + + Output arguments (to be filled in by the function): + + output + An array of ASCII code points. It is *not* null-terminated; + it will contain zeros if and only if the input contains + zeros. (Of course the caller can leave room for a + terminator and add one if needed.) + + Input/output arguments (to be supplied by the caller and overwritten + by the function): + + output_length + The caller passes in the maximum number of ASCII code points + that it can receive. On successful return it will contain + the number of ASCII code points actually output. + + Return value: + + Can be any of the punycode_status values defined above except + punycode_bad_input. If not punycode_success, then output_size + and output might contain garbage. +*/ + + extern IDNAPI int punycode_decode (size_t input_length, + const char input[], + size_t *output_length, + punycode_uint output[], + unsigned char case_flags[]); + +/* + punycode_decode() converts Punycode to a sequence of code points + (presumed to be Unicode code points). + + Input arguments (to be supplied by the caller): + + input_length + The number of ASCII code points in the input array. + + input + An array of ASCII code points (0..7F). + + Output arguments (to be filled in by the function): + + output + An array of code points like the input argument of + punycode_encode() (see above). + + case_flags + A null pointer (if the flags are not needed by the caller) + or an array of boolean values parallel to the output array. + Nonzero (true, flagged) suggests that the corresponding + Unicode character be forced to uppercase by the caller (if + possible), and zero (false, unflagged) suggests that it + be forced to lowercase (if possible). ASCII code points + (0..7F) are output already in the proper case, but their + flags will be set appropriately so that applying the flags + would be harmless. + + Input/output arguments (to be supplied by the caller and overwritten + by the function): + + output_length + The caller passes in the maximum number of code points + that it can receive into the output array (which is also + the maximum number of flags that it can receive into the + case_flags array, if case_flags is not a null pointer). On + successful return it will contain the number of code points + actually output (which is also the number of flags actually + output, if case_flags is not a null pointer). The decoder + will never need to output more code points than the number + of ASCII code points in the input, because of the way the + encoding is defined. The number of code points output + cannot exceed the maximum possible value of a punycode_uint, + even if the supplied output_length is greater than that. + + Return value: + + Can be any of the punycode_status values defined above. If not + punycode_success, then output_length, output, and case_flags + might contain garbage. +*/ + +# ifdef __cplusplus +} +# endif +#endif /* PUNYCODE_H */ diff --git a/illumos-x86_64/usr/include/pw.h b/illumos-x86_64/usr/include/pw.h new file mode 100644 index 00000000..d52f4017 --- /dev/null +++ b/illumos-x86_64/usr/include/pw.h @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _PW_H +#define _PW_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern char *logname(void); +extern char *regcmp(const char *, ...); +extern char *regex(const char *, const char *, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _PW_H */ diff --git a/illumos-x86_64/usr/include/pwd.h b/illumos-x86_64/usr/include/pwd.h new file mode 100644 index 00000000..a0fa0381 --- /dev/null +++ b/illumos-x86_64/usr/include/pwd.h @@ -0,0 +1,177 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PWD_H +#define _PWD_H + +#include + +#include + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct passwd { + char *pw_name; + char *pw_passwd; + uid_t pw_uid; + gid_t pw_gid; + char *pw_age; + char *pw_comment; + char *pw_gecos; + char *pw_dir; + char *pw_shell; +}; + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +struct comment { + char *c_dept; + char *c_name; + char *c_acct; + char *c_bin; +}; +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +extern struct passwd *getpwuid(uid_t); /* MT-unsafe */ +extern struct passwd *getpwnam(const char *); /* MT-unsafe */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern struct passwd *getpwent_r(struct passwd *, char *, int); +extern struct passwd *fgetpwent_r(FILE *, struct passwd *, char *, int); +extern struct passwd *fgetpwent(FILE *); /* MT-unsafe */ +extern int putpwent(const struct passwd *, FILE *); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ + defined(__EXTENSIONS__) +extern void endpwent(void); +extern struct passwd *getpwent(void); /* MT-unsafe */ +extern void setpwent(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */ + +/* + * getpwuid_r() & getpwnam_r() prototypes are defined here. + */ + +/* + * Previous releases of Solaris, starting at 2.3, provided definitions of + * various functions as specified in POSIX.1c, Draft 6. For some of these + * functions, the final POSIX 1003.1c standard had a different number of + * arguments and return values. + * + * The following segment of this header provides support for the standard + * interfaces while supporting applications written under earlier + * releases. The application defines appropriate values of the feature + * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate + * whether it was written to expect the Draft 6 or standard versions of + * these interfaces, before including this header. This header then + * provides a mapping from the source version of the interface to an + * appropriate binary interface. Such mappings permit an application + * to be built from libraries and objects which have mixed expectations + * of the definitions of these functions. + * + * For applications using the Draft 6 definitions, the binary symbol is the + * same as the source symbol, and no explicit mapping is needed. For the + * standard interface, the function func() is mapped to the binary symbol + * _posix_func(). The preferred mechanism for the remapping is a compiler + * #pragma. If the compiler does not provide such a #pragma, the header file + * defines a static function func() which calls the _posix_func() version; + * this has to be done instead of #define since POSIX specifies that an + * application can #undef the symbol and still be bound to the correct + * implementation. Unfortunately, the statics confuse lint so we fallback to + * #define in that case. + * + * NOTE: Support for the Draft 6 definitions is provided for compatibility + * only. New applications/libraries should use the standard definitions. + */ + +#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \ + defined(_POSIX_PTHREAD_SEMANTICS) || defined(__EXTENSIONS__) + +#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getpwuid_r __posix_getpwuid_r +#pragma redefine_extname getpwnam_r __posix_getpwnam_r +extern int getpwuid_r(uid_t, struct passwd *, char *, + size_t, struct passwd **); +extern int getpwnam_r(const char *, struct passwd *, char *, + size_t, struct passwd **); +#else /* __PRAGMA_REDEFINE_EXTNAME */ + +extern int __posix_getpwuid_r(uid_t, struct passwd *, char *, size_t, + struct passwd **); +extern int __posix_getpwnam_r(const char *, struct passwd *, char *, + size_t, struct passwd **); + +#ifdef __lint + +#define getpwuid_r __posix_getpwuid_r +#define getpwnam_r __posix_getpwnam_r + +#else /* !__lint */ + +static int +getpwuid_r(uid_t __uid, struct passwd *__pwd, char *__buf, size_t __len, + struct passwd **__res) +{ + return (__posix_getpwuid_r(__uid, __pwd, __buf, __len, __res)); +} +static int +getpwnam_r(const char *__cb, struct passwd *__pwd, char *__buf, size_t __len, + struct passwd **__res) +{ + return (__posix_getpwnam_r(__cb, __pwd, __buf, __len, __res)); +} + +#endif /* !__lint */ +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +extern struct passwd *getpwuid_r(uid_t, struct passwd *, char *, int); +extern struct passwd *getpwnam_r(const char *, struct passwd *, char *, int); + +#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L)... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PWD_H */ diff --git a/illumos-x86_64/usr/include/python3.13/Python.h b/illumos-x86_64/usr/include/python3.13/Python.h new file mode 100644 index 00000000..0f75de6c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/Python.h @@ -0,0 +1,140 @@ +// Entry point of the Python C API. +// C extensions should only #include , and not include directly +// the other Python header files included by . + +#ifndef Py_PYTHON_H +#define Py_PYTHON_H + +// Since this is a "meta-include" file, "#ifdef __cplusplus / extern "C" {" +// is not needed. + + +// Include Python header files +#include "patchlevel.h" +#include "pyconfig.h" +#include "pymacconfig.h" + + +// Include standard header files +// When changing these files, remember to update Doc/extending/extending.rst. +#include // assert() +#include // uintptr_t +#include // INT_MAX +#include // HUGE_VAL +#include // va_list +#include // wchar_t +#ifdef HAVE_SYS_TYPES_H +# include // ssize_t +#endif + +// , , and headers are no longer used +// by Python, but kept for the backward compatibility of existing third party C +// extensions. They are not included by limited C API version 3.11 and newer. +// +// The and headers are not included by limited C API +// version 3.13 and newer. +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# include // errno +# include // FILE* +# include // getenv() +# include // memcpy() +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030d0000 +# include // tolower() +# ifndef MS_WINDOWS +# include // close() +# endif +#endif + +// gh-111506: The free-threaded build is not compatible with the limited API +// or the stable ABI. +#if defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED) +# error "The limited API is not currently supported in the free-threaded build" +#endif + +#if defined(Py_GIL_DISABLED) && defined(_MSC_VER) +# include // __readgsqword() +#endif + +#if defined(Py_GIL_DISABLED) && defined(__MINGW32__) +# include // __readgsqword() +#endif + +// Include Python header files +#include "pyport.h" +#include "pymacro.h" +#include "pymath.h" +#include "pymem.h" +#include "pytypedefs.h" +#include "pybuffer.h" +#include "pystats.h" +#include "pyatomic.h" +#include "lock.h" +#include "object.h" +#include "objimpl.h" +#include "typeslots.h" +#include "pyhash.h" +#include "cpython/pydebug.h" +#include "bytearrayobject.h" +#include "bytesobject.h" +#include "unicodeobject.h" +#include "pyerrors.h" +#include "longobject.h" +#include "cpython/longintrepr.h" +#include "boolobject.h" +#include "floatobject.h" +#include "complexobject.h" +#include "rangeobject.h" +#include "memoryobject.h" +#include "tupleobject.h" +#include "listobject.h" +#include "dictobject.h" +#include "cpython/odictobject.h" +#include "enumobject.h" +#include "setobject.h" +#include "methodobject.h" +#include "moduleobject.h" +#include "monitoring.h" +#include "cpython/funcobject.h" +#include "cpython/classobject.h" +#include "fileobject.h" +#include "pycapsule.h" +#include "cpython/code.h" +#include "pyframe.h" +#include "traceback.h" +#include "sliceobject.h" +#include "cpython/cellobject.h" +#include "iterobject.h" +#include "cpython/initconfig.h" +#include "pystate.h" +#include "cpython/genobject.h" +#include "descrobject.h" +#include "genericaliasobject.h" +#include "warnings.h" +#include "weakrefobject.h" +#include "structseq.h" +#include "cpython/picklebufobject.h" +#include "cpython/pytime.h" +#include "codecs.h" +#include "pythread.h" +#include "cpython/context.h" +#include "modsupport.h" +#include "compile.h" +#include "pythonrun.h" +#include "pylifecycle.h" +#include "ceval.h" +#include "sysmodule.h" +#include "osmodule.h" +#include "intrcheck.h" +#include "import.h" +#include "abstract.h" +#include "bltinmodule.h" +#include "critical_section.h" +#include "cpython/pyctype.h" +#include "pystrtod.h" +#include "pystrcmp.h" +#include "fileutils.h" +#include "cpython/pyfpe.h" +#include "cpython/tracemalloc.h" + +#endif /* !Py_PYTHON_H */ diff --git a/illumos-x86_64/usr/include/python3.13/abstract.h b/illumos-x86_64/usr/include/python3.13/abstract.h new file mode 100644 index 00000000..98e1bbe4 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/abstract.h @@ -0,0 +1,921 @@ +/* Abstract Object Interface (many thanks to Jim Fulton) */ + +#ifndef Py_ABSTRACTOBJECT_H +#define Py_ABSTRACTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* === Object Protocol ================================================== */ + +/* Implemented elsewhere: + + int PyObject_Print(PyObject *o, FILE *fp, int flags); + + Print an object 'o' on file 'fp'. Returns -1 on error. The flags argument + is used to enable certain printing options. The only option currently + supported is Py_PRINT_RAW. By default (flags=0), PyObject_Print() formats + the object by calling PyObject_Repr(). If flags equals to Py_PRINT_RAW, it + formats the object by calling PyObject_Str(). */ + + +/* Implemented elsewhere: + + int PyObject_HasAttrString(PyObject *o, const char *attr_name); + + Returns 1 if object 'o' has the attribute attr_name, and 0 otherwise. + + This is equivalent to the Python expression: hasattr(o,attr_name). + + This function always succeeds. */ + + +/* Implemented elsewhere: + + PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name); + + Retrieve an attributed named attr_name form object o. + Returns the attribute value on success, or NULL on failure. + + This is the equivalent of the Python expression: o.attr_name. */ + + +/* Implemented elsewhere: + + int PyObject_HasAttr(PyObject *o, PyObject *attr_name); + + Returns 1 if o has the attribute attr_name, and 0 otherwise. + + This is equivalent to the Python expression: hasattr(o,attr_name). + + This function always succeeds. */ + + +/* Implemented elsewhere: + + int PyObject_HasAttrStringWithError(PyObject *o, const char *attr_name); + + Returns 1 if object 'o' has the attribute attr_name, and 0 otherwise. + This is equivalent to the Python expression: hasattr(o,attr_name). + Returns -1 on failure. */ + + +/* Implemented elsewhere: + + int PyObject_HasAttrWithError(PyObject *o, PyObject *attr_name); + + Returns 1 if o has the attribute attr_name, and 0 otherwise. + This is equivalent to the Python expression: hasattr(o,attr_name). + Returns -1 on failure. */ + + +/* Implemented elsewhere: + + PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name); + + Retrieve an attributed named 'attr_name' form object 'o'. + Returns the attribute value on success, or NULL on failure. + + This is the equivalent of the Python expression: o.attr_name. */ + + +/* Implemented elsewhere: + + int PyObject_GetOptionalAttr(PyObject *obj, PyObject *attr_name, PyObject **result); + + Variant of PyObject_GetAttr() which doesn't raise AttributeError + if the attribute is not found. + + If the attribute is found, return 1 and set *result to a new strong + reference to the attribute. + If the attribute is not found, return 0 and set *result to NULL; + the AttributeError is silenced. + If an error other than AttributeError is raised, return -1 and + set *result to NULL. +*/ + + +/* Implemented elsewhere: + + int PyObject_GetOptionalAttrString(PyObject *obj, const char *attr_name, PyObject **result); + + Variant of PyObject_GetAttrString() which doesn't raise AttributeError + if the attribute is not found. + + If the attribute is found, return 1 and set *result to a new strong + reference to the attribute. + If the attribute is not found, return 0 and set *result to NULL; + the AttributeError is silenced. + If an error other than AttributeError is raised, return -1 and + set *result to NULL. +*/ + + +/* Implemented elsewhere: + + int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v); + + Set the value of the attribute named attr_name, for object 'o', + to the value 'v'. Raise an exception and return -1 on failure; return 0 on + success. + + This is the equivalent of the Python statement o.attr_name=v. */ + + +/* Implemented elsewhere: + + int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); + + Set the value of the attribute named attr_name, for object 'o', to the value + 'v'. an exception and return -1 on failure; return 0 on success. + + This is the equivalent of the Python statement o.attr_name=v. */ + +/* Implemented elsewhere: + + int PyObject_DelAttrString(PyObject *o, const char *attr_name); + + Delete attribute named attr_name, for object o. Returns + -1 on failure. + + This is the equivalent of the Python statement: del o.attr_name. + + Implemented as a macro in the limited C API 3.12 and older. */ +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030d0000 +# define PyObject_DelAttrString(O, A) PyObject_SetAttrString((O), (A), NULL) +#endif + + +/* Implemented elsewhere: + + int PyObject_DelAttr(PyObject *o, PyObject *attr_name); + + Delete attribute named attr_name, for object o. Returns -1 + on failure. This is the equivalent of the Python + statement: del o.attr_name. + + Implemented as a macro in the limited C API 3.12 and older. */ +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030d0000 +# define PyObject_DelAttr(O, A) PyObject_SetAttr((O), (A), NULL) +#endif + + +/* Implemented elsewhere: + + PyObject *PyObject_Repr(PyObject *o); + + Compute the string representation of object 'o'. Returns the + string representation on success, NULL on failure. + + This is the equivalent of the Python expression: repr(o). + + Called by the repr() built-in function. */ + + +/* Implemented elsewhere: + + PyObject *PyObject_Str(PyObject *o); + + Compute the string representation of object, o. Returns the + string representation on success, NULL on failure. + + This is the equivalent of the Python expression: str(o). + + Called by the str() and print() built-in functions. */ + + +/* Declared elsewhere + + PyAPI_FUNC(int) PyCallable_Check(PyObject *o); + + Determine if the object, o, is callable. Return 1 if the object is callable + and 0 otherwise. + + This function always succeeds. */ + + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 +/* Call a callable Python object without any arguments */ +PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func); +#endif + + +/* Call a callable Python object 'callable' with arguments given by the + tuple 'args' and keywords arguments given by the dictionary 'kwargs'. + + 'args' must not be NULL, use an empty tuple if no arguments are + needed. If no named arguments are needed, 'kwargs' can be NULL. + + This is the equivalent of the Python expression: + callable(*args, **kwargs). */ +PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable, + PyObject *args, PyObject *kwargs); + + +/* Call a callable Python object 'callable', with arguments given by the + tuple 'args'. If no arguments are needed, then 'args' can be NULL. + + Returns the result of the call on success, or NULL on failure. + + This is the equivalent of the Python expression: + callable(*args). */ +PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable, + PyObject *args); + +/* Call a callable Python object, callable, with a variable number of C + arguments. The C arguments are described using a mkvalue-style format + string. + + The format may be NULL, indicating that no arguments are provided. + + Returns the result of the call on success, or NULL on failure. + + This is the equivalent of the Python expression: + callable(arg1, arg2, ...). */ +PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable, + const char *format, ...); + +/* Call the method named 'name' of object 'obj' with a variable number of + C arguments. The C arguments are described by a mkvalue format string. + + The format can be NULL, indicating that no arguments are provided. + + Returns the result of the call on success, or NULL on failure. + + This is the equivalent of the Python expression: + obj.name(arg1, arg2, ...). */ +PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *obj, + const char *name, + const char *format, ...); + +/* Call a callable Python object 'callable' with a variable number of C + arguments. The C arguments are provided as PyObject* values, terminated + by a NULL. + + Returns the result of the call on success, or NULL on failure. + + This is the equivalent of the Python expression: + callable(arg1, arg2, ...). */ +PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, + ...); + +/* Call the method named 'name' of object 'obj' with a variable number of + C arguments. The C arguments are provided as PyObject* values, terminated + by NULL. + + Returns the result of the call on success, or NULL on failure. + + This is the equivalent of the Python expression: obj.name(*args). */ + +PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs( + PyObject *obj, + PyObject *name, + ...); + +/* Given a vectorcall nargsf argument, return the actual number of arguments. + * (For use outside the limited API, this is re-defined as a static inline + * function in cpython/abstract.h) + */ +PyAPI_FUNC(Py_ssize_t) PyVectorcall_NARGS(size_t nargsf); + +/* Call "callable" (which must support vectorcall) with positional arguments + "tuple" and keyword arguments "dict". "dict" may also be NULL */ +PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +#define PY_VECTORCALL_ARGUMENTS_OFFSET \ + (_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1)) + +/* Perform a PEP 590-style vector call on 'callable' */ +PyAPI_FUNC(PyObject *) PyObject_Vectorcall( + PyObject *callable, + PyObject *const *args, + size_t nargsf, + PyObject *kwnames); + +/* Call the method 'name' on args[0] with arguments in args[1..nargsf-1]. */ +PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod( + PyObject *name, PyObject *const *args, + size_t nargsf, PyObject *kwnames); +#endif + +/* Implemented elsewhere: + + Py_hash_t PyObject_Hash(PyObject *o); + + Compute and return the hash, hash_value, of an object, o. On + failure, return -1. + + This is the equivalent of the Python expression: hash(o). */ + + +/* Implemented elsewhere: + + int PyObject_IsTrue(PyObject *o); + + Returns 1 if the object, o, is considered to be true, 0 if o is + considered to be false and -1 on failure. + + This is equivalent to the Python expression: not not o. */ + + +/* Implemented elsewhere: + + int PyObject_Not(PyObject *o); + + Returns 0 if the object, o, is considered to be true, 1 if o is + considered to be false and -1 on failure. + + This is equivalent to the Python expression: not o. */ + + +/* Get the type of an object. + + On success, returns a type object corresponding to the object type of object + 'o'. On failure, returns NULL. + + This is equivalent to the Python expression: type(o) */ +PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o); + + +/* Return the size of object 'o'. If the object 'o' provides both sequence and + mapping protocols, the sequence size is returned. + + On error, -1 is returned. + + This is the equivalent to the Python expression: len(o) */ +PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o); + + +/* For DLL compatibility */ +#undef PyObject_Length +PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o); +#define PyObject_Length PyObject_Size + +/* Return element of 'o' corresponding to the object 'key'. Return NULL + on failure. + + This is the equivalent of the Python expression: o[key] */ +PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key); + + +/* Map the object 'key' to the value 'v' into 'o'. + + Raise an exception and return -1 on failure; return 0 on success. + + This is the equivalent of the Python statement: o[key]=v. */ +PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v); + +/* Remove the mapping for the string 'key' from the object 'o'. + Returns -1 on failure. + + This is equivalent to the Python statement: del o[key]. */ +PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key); + +/* Delete the mapping for the object 'key' from the object 'o'. + Returns -1 on failure. + + This is the equivalent of the Python statement: del o[key]. */ +PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key); + + +/* Takes an arbitrary object and returns the result of calling + obj.__format__(format_spec). */ +PyAPI_FUNC(PyObject *) PyObject_Format(PyObject *obj, + PyObject *format_spec); + + +/* ==== Iterators ================================================ */ + +/* Takes an object and returns an iterator for it. + This is typically a new iterator but if the argument is an iterator, this + returns itself. */ +PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *); + +/* Takes an AsyncIterable object and returns an AsyncIterator for it. + This is typically a new iterator but if the argument is an AsyncIterator, + this returns itself. */ +PyAPI_FUNC(PyObject *) PyObject_GetAIter(PyObject *); + +/* Returns non-zero if the object 'obj' provides iterator protocols, and 0 otherwise. + + This function always succeeds. */ +PyAPI_FUNC(int) PyIter_Check(PyObject *); + +/* Returns non-zero if the object 'obj' provides AsyncIterator protocols, and 0 otherwise. + + This function always succeeds. */ +PyAPI_FUNC(int) PyAIter_Check(PyObject *); + +/* Takes an iterator object and calls its tp_iternext slot, + returning the next value. + + If the iterator is exhausted, this returns NULL without setting an + exception. + + NULL with an exception means an error occurred. */ +PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 + +/* Takes generator, coroutine or iterator object and sends the value into it. + Returns: + - PYGEN_RETURN (0) if generator has returned. + 'result' parameter is filled with return value + - PYGEN_ERROR (-1) if exception was raised. + 'result' parameter is NULL + - PYGEN_NEXT (1) if generator has yielded. + 'result' parameter is filled with yielded value. */ +PyAPI_FUNC(PySendResult) PyIter_Send(PyObject *, PyObject *, PyObject **); +#endif + + +/* === Number Protocol ================================================== */ + +/* Returns 1 if the object 'o' provides numeric protocols, and 0 otherwise. + + This function always succeeds. */ +PyAPI_FUNC(int) PyNumber_Check(PyObject *o); + +/* Returns the result of adding o1 and o2, or NULL on failure. + + This is the equivalent of the Python expression: o1 + o2. */ +PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2); + +/* Returns the result of subtracting o2 from o1, or NULL on failure. + + This is the equivalent of the Python expression: o1 - o2. */ +PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2); + +/* Returns the result of multiplying o1 and o2, or NULL on failure. + + This is the equivalent of the Python expression: o1 * o2. */ +PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* This is the equivalent of the Python expression: o1 @ o2. */ +PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2); +#endif + +/* Returns the result of dividing o1 by o2 giving an integral result, + or NULL on failure. + + This is the equivalent of the Python expression: o1 // o2. */ +PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2); + +/* Returns the result of dividing o1 by o2 giving a float result, or NULL on + failure. + + This is the equivalent of the Python expression: o1 / o2. */ +PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2); + +/* Returns the remainder of dividing o1 by o2, or NULL on failure. + + This is the equivalent of the Python expression: o1 % o2. */ +PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2); + +/* See the built-in function divmod. + + Returns NULL on failure. + + This is the equivalent of the Python expression: divmod(o1, o2). */ +PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2); + +/* See the built-in function pow. Returns NULL on failure. + + This is the equivalent of the Python expression: pow(o1, o2, o3), + where o3 is optional. */ +PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2, + PyObject *o3); + +/* Returns the negation of o on success, or NULL on failure. + + This is the equivalent of the Python expression: -o. */ +PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o); + +/* Returns the positive of o on success, or NULL on failure. + + This is the equivalent of the Python expression: +o. */ +PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o); + +/* Returns the absolute value of 'o', or NULL on failure. + + This is the equivalent of the Python expression: abs(o). */ +PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o); + +/* Returns the bitwise negation of 'o' on success, or NULL on failure. + + This is the equivalent of the Python expression: ~o. */ +PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o); + +/* Returns the result of left shifting o1 by o2 on success, or NULL on failure. + + This is the equivalent of the Python expression: o1 << o2. */ +PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2); + +/* Returns the result of right shifting o1 by o2 on success, or NULL on + failure. + + This is the equivalent of the Python expression: o1 >> o2. */ +PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2); + +/* Returns the result of bitwise and of o1 and o2 on success, or NULL on + failure. + + This is the equivalent of the Python expression: o1 & o2. */ +PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2); + +/* Returns the bitwise exclusive or of o1 by o2 on success, or NULL on failure. + + This is the equivalent of the Python expression: o1 ^ o2. */ +PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2); + +/* Returns the result of bitwise or on o1 and o2 on success, or NULL on + failure. + + This is the equivalent of the Python expression: o1 | o2. */ +PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2); + +/* Returns 1 if obj is an index integer (has the nb_index slot of the + tp_as_number structure filled in), and 0 otherwise. */ +PyAPI_FUNC(int) PyIndex_Check(PyObject *); + +/* Returns the object 'o' converted to a Python int, or NULL with an exception + raised on failure. */ +PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o); + +/* Returns the object 'o' converted to Py_ssize_t by going through + PyNumber_Index() first. + + If an overflow error occurs while converting the int to Py_ssize_t, then the + second argument 'exc' is the error-type to return. If it is NULL, then the + overflow error is cleared and the value is clipped. */ +PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc); + +/* Returns the object 'o' converted to an integer object on success, or NULL + on failure. + + This is the equivalent of the Python expression: int(o). */ +PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o); + +/* Returns the object 'o' converted to a float object on success, or NULL + on failure. + + This is the equivalent of the Python expression: float(o). */ +PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o); + + +/* --- In-place variants of (some of) the above number protocol functions -- */ + +/* Returns the result of adding o2 to o1, possibly in-place, or NULL + on failure. + + This is the equivalent of the Python expression: o1 += o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2); + +/* Returns the result of subtracting o2 from o1, possibly in-place or + NULL on failure. + + This is the equivalent of the Python expression: o1 -= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2); + +/* Returns the result of multiplying o1 by o2, possibly in-place, or NULL on + failure. + + This is the equivalent of the Python expression: o1 *= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* This is the equivalent of the Python expression: o1 @= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2); +#endif + +/* Returns the result of dividing o1 by o2 giving an integral result, possibly + in-place, or NULL on failure. + + This is the equivalent of the Python expression: o1 /= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, + PyObject *o2); + +/* Returns the result of dividing o1 by o2 giving a float result, possibly + in-place, or null on failure. + + This is the equivalent of the Python expression: o1 /= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1, + PyObject *o2); + +/* Returns the remainder of dividing o1 by o2, possibly in-place, or NULL on + failure. + + This is the equivalent of the Python expression: o1 %= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2); + +/* Returns the result of raising o1 to the power of o2, possibly in-place, + or NULL on failure. + + This is the equivalent of the Python expression: o1 **= o2, + or o1 = pow(o1, o2, o3) if o3 is present. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2, + PyObject *o3); + +/* Returns the result of left shifting o1 by o2, possibly in-place, or NULL + on failure. + + This is the equivalent of the Python expression: o1 <<= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2); + +/* Returns the result of right shifting o1 by o2, possibly in-place or NULL + on failure. + + This is the equivalent of the Python expression: o1 >>= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2); + +/* Returns the result of bitwise and of o1 and o2, possibly in-place, or NULL + on failure. + + This is the equivalent of the Python expression: o1 &= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2); + +/* Returns the bitwise exclusive or of o1 by o2, possibly in-place, or NULL + on failure. + + This is the equivalent of the Python expression: o1 ^= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2); + +/* Returns the result of bitwise or of o1 and o2, possibly in-place, + or NULL on failure. + + This is the equivalent of the Python expression: o1 |= o2. */ +PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2); + +/* Returns the integer n converted to a string with a base, with a base + marker of 0b, 0o or 0x prefixed if applicable. + + If n is not an int object, it is converted with PyNumber_Index first. */ +PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base); + + +/* === Sequence protocol ================================================ */ + +/* Return 1 if the object provides sequence protocol, and zero + otherwise. + + This function always succeeds. */ +PyAPI_FUNC(int) PySequence_Check(PyObject *o); + +/* Return the size of sequence object o, or -1 on failure. */ +PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o); + +/* For DLL compatibility */ +#undef PySequence_Length +PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o); +#define PySequence_Length PySequence_Size + + +/* Return the concatenation of o1 and o2 on success, and NULL on failure. + + This is the equivalent of the Python expression: o1 + o2. */ +PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2); + +/* Return the result of repeating sequence object 'o' 'count' times, + or NULL on failure. + + This is the equivalent of the Python expression: o * count. */ +PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count); + +/* Return the ith element of o, or NULL on failure. + + This is the equivalent of the Python expression: o[i]. */ +PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i); + +/* Return the slice of sequence object o between i1 and i2, or NULL on failure. + + This is the equivalent of the Python expression: o[i1:i2]. */ +PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); + +/* Assign object 'v' to the ith element of the sequence 'o'. Raise an exception + and return -1 on failure; return 0 on success. + + This is the equivalent of the Python statement o[i] = v. */ +PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v); + +/* Delete the 'i'-th element of the sequence 'v'. Returns -1 on failure. + + This is the equivalent of the Python statement: del o[i]. */ +PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i); + +/* Assign the sequence object 'v' to the slice in sequence object 'o', + from 'i1' to 'i2'. Returns -1 on failure. + + This is the equivalent of the Python statement: o[i1:i2] = v. */ +PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, + PyObject *v); + +/* Delete the slice in sequence object 'o' from 'i1' to 'i2'. + Returns -1 on failure. + + This is the equivalent of the Python statement: del o[i1:i2]. */ +PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); + +/* Returns the sequence 'o' as a tuple on success, and NULL on failure. + + This is equivalent to the Python expression: tuple(o). */ +PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o); + +/* Returns the sequence 'o' as a list on success, and NULL on failure. + This is equivalent to the Python expression: list(o) */ +PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o); + +/* Return the sequence 'o' as a list, unless it's already a tuple or list. + + Use PySequence_Fast_GET_ITEM to access the members of this list, and + PySequence_Fast_GET_SIZE to get its length. + + Returns NULL on failure. If the object does not support iteration, raises a + TypeError exception with 'm' as the message text. */ +PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m); + +/* Return the size of the sequence 'o', assuming that 'o' was returned by + PySequence_Fast and is not NULL. */ +#define PySequence_Fast_GET_SIZE(o) \ + (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o)) + +/* Return the 'i'-th element of the sequence 'o', assuming that o was returned + by PySequence_Fast, and that i is within bounds. */ +#define PySequence_Fast_GET_ITEM(o, i)\ + (PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i))) + +/* Return a pointer to the underlying item array for + an object returned by PySequence_Fast */ +#define PySequence_Fast_ITEMS(sf) \ + (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \ + : ((PyTupleObject *)(sf))->ob_item) + +/* Return the number of occurrences on value on 'o', that is, return + the number of keys for which o[key] == value. + + On failure, return -1. This is equivalent to the Python expression: + o.count(value). */ +PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value); + +/* Return 1 if 'ob' is in the sequence 'seq'; 0 if 'ob' is not in the sequence + 'seq'; -1 on error. + + Use __contains__ if possible, else _PySequence_IterSearch(). */ +PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob); + +/* For DLL-level backwards compatibility */ +#undef PySequence_In +/* Determine if the sequence 'o' contains 'value'. If an item in 'o' is equal + to 'value', return 1, otherwise return 0. On error, return -1. + + This is equivalent to the Python expression: value in o. */ +PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value); + +/* For source-level backwards compatibility */ +#define PySequence_In PySequence_Contains + + +/* Return the first index for which o[i] == value. + On error, return -1. + + This is equivalent to the Python expression: o.index(value). */ +PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value); + + +/* --- In-place versions of some of the above Sequence functions --- */ + +/* Append sequence 'o2' to sequence 'o1', in-place when possible. Return the + resulting object, which could be 'o1', or NULL on failure. + + This is the equivalent of the Python expression: o1 += o2. */ +PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2); + +/* Repeat sequence 'o' by 'count', in-place when possible. Return the resulting + object, which could be 'o', or NULL on failure. + + This is the equivalent of the Python expression: o1 *= count. */ +PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count); + + +/* === Mapping protocol ================================================= */ + +/* Return 1 if the object provides mapping protocol, and 0 otherwise. + + This function always succeeds. */ +PyAPI_FUNC(int) PyMapping_Check(PyObject *o); + +/* Returns the number of keys in mapping object 'o' on success, and -1 on + failure. This is equivalent to the Python expression: len(o). */ +PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o); + +/* For DLL compatibility */ +#undef PyMapping_Length +PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o); +#define PyMapping_Length PyMapping_Size + + +/* Implemented as a macro: + + int PyMapping_DelItemString(PyObject *o, const char *key); + + Remove the mapping for the string 'key' from the mapping 'o'. Returns -1 on + failure. + + This is equivalent to the Python statement: del o[key]. */ +#define PyMapping_DelItemString(O, K) PyObject_DelItemString((O), (K)) + +/* Implemented as a macro: + + int PyMapping_DelItem(PyObject *o, PyObject *key); + + Remove the mapping for the object 'key' from the mapping object 'o'. + Returns -1 on failure. + + This is equivalent to the Python statement: del o[key]. */ +#define PyMapping_DelItem(O, K) PyObject_DelItem((O), (K)) + +/* On success, return 1 if the mapping object 'o' has the key 'key', + and 0 otherwise. + + This is equivalent to the Python expression: key in o. + + This function always succeeds. */ +PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key); + +/* Return 1 if the mapping object has the key 'key', and 0 otherwise. + + This is equivalent to the Python expression: key in o. + + This function always succeeds. */ +PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key); + +/* Return 1 if the mapping object has the key 'key', and 0 otherwise. + This is equivalent to the Python expression: key in o. + On failure, return -1. */ + +PyAPI_FUNC(int) PyMapping_HasKeyWithError(PyObject *o, PyObject *key); + +/* Return 1 if the mapping object has the key 'key', and 0 otherwise. + This is equivalent to the Python expression: key in o. + On failure, return -1. */ + +PyAPI_FUNC(int) PyMapping_HasKeyStringWithError(PyObject *o, const char *key); + +/* On success, return a list or tuple of the keys in mapping object 'o'. + On failure, return NULL. */ +PyAPI_FUNC(PyObject *) PyMapping_Keys(PyObject *o); + +/* On success, return a list or tuple of the values in mapping object 'o'. + On failure, return NULL. */ +PyAPI_FUNC(PyObject *) PyMapping_Values(PyObject *o); + +/* On success, return a list or tuple of the items in mapping object 'o', + where each item is a tuple containing a key-value pair. On failure, return + NULL. */ +PyAPI_FUNC(PyObject *) PyMapping_Items(PyObject *o); + +/* Return element of 'o' corresponding to the string 'key' or NULL on failure. + + This is the equivalent of the Python expression: o[key]. */ +PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, + const char *key); + +/* Variants of PyObject_GetItem() and PyMapping_GetItemString() which don't + raise KeyError if the key is not found. + + If the key is found, return 1 and set *result to a new strong + reference to the corresponding value. + If the key is not found, return 0 and set *result to NULL; + the KeyError is silenced. + If an error other than KeyError is raised, return -1 and + set *result to NULL. +*/ +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(int) PyMapping_GetOptionalItem(PyObject *, PyObject *, PyObject **); +PyAPI_FUNC(int) PyMapping_GetOptionalItemString(PyObject *, const char *, PyObject **); +#endif + +/* Map the string 'key' to the value 'v' in the mapping 'o'. + Returns -1 on failure. + + This is the equivalent of the Python statement: o[key]=v. */ +PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key, + PyObject *value); + +/* isinstance(object, typeorclass) */ +PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass); + +/* issubclass(object, typeorclass) */ +PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_ABSTRACTOBJECT_H +# include "cpython/abstract.h" +# undef Py_CPYTHON_ABSTRACTOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* Py_ABSTRACTOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/bltinmodule.h b/illumos-x86_64/usr/include/python3.13/bltinmodule.h new file mode 100644 index 00000000..868c9e64 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/bltinmodule.h @@ -0,0 +1,14 @@ +#ifndef Py_BLTINMODULE_H +#define Py_BLTINMODULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyFilter_Type; +PyAPI_DATA(PyTypeObject) PyMap_Type; +PyAPI_DATA(PyTypeObject) PyZip_Type; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BLTINMODULE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/boolobject.h b/illumos-x86_64/usr/include/python3.13/boolobject.h new file mode 100644 index 00000000..b56e2bae --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/boolobject.h @@ -0,0 +1,54 @@ +/* Boolean object interface */ + +#ifndef Py_BOOLOBJECT_H +#define Py_BOOLOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +// PyBool_Type is declared by object.h + +#define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type) + +/* Py_False and Py_True are the only two bools in existence. */ + +/* Don't use these directly */ +PyAPI_DATA(PyLongObject) _Py_FalseStruct; +PyAPI_DATA(PyLongObject) _Py_TrueStruct; + +/* Use these macros */ +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000 +# define Py_False Py_GetConstantBorrowed(Py_CONSTANT_FALSE) +# define Py_True Py_GetConstantBorrowed(Py_CONSTANT_TRUE) +#else +# define Py_False _PyObject_CAST(&_Py_FalseStruct) +# define Py_True _PyObject_CAST(&_Py_TrueStruct) +#endif + +// Test if an object is the True singleton, the same as "x is True" in Python. +PyAPI_FUNC(int) Py_IsTrue(PyObject *x); +#define Py_IsTrue(x) Py_Is((x), Py_True) + +// Test if an object is the False singleton, the same as "x is False" in Python. +PyAPI_FUNC(int) Py_IsFalse(PyObject *x); +#define Py_IsFalse(x) Py_Is((x), Py_False) + +/* Macros for returning Py_True or Py_False, respectively. + * Only treat Py_True and Py_False as immortal in the limited C API 3.12 + * and newer. */ +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030c0000 +# define Py_RETURN_TRUE return Py_NewRef(Py_True) +# define Py_RETURN_FALSE return Py_NewRef(Py_False) +#else +# define Py_RETURN_TRUE return Py_True +# define Py_RETURN_FALSE return Py_False +#endif + +/* Function to return a bool from a C long */ +PyAPI_FUNC(PyObject *) PyBool_FromLong(long); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BOOLOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/bytearrayobject.h b/illumos-x86_64/usr/include/python3.13/bytearrayobject.h new file mode 100644 index 00000000..3d53fdba --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/bytearrayobject.h @@ -0,0 +1,44 @@ +/* ByteArray object interface */ + +#ifndef Py_BYTEARRAYOBJECT_H +#define Py_BYTEARRAYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Type PyByteArrayObject represents a mutable array of bytes. + * The Python API is that of a sequence; + * the bytes are mapped to ints in [0, 256). + * Bytes are not characters; they may be used to encode characters. + * The only way to go between bytes and str/unicode is via encoding + * and decoding. + * For the convenience of C programmers, the bytes type is considered + * to contain a char pointer, not an unsigned char pointer. + */ + +/* Type object */ +PyAPI_DATA(PyTypeObject) PyByteArray_Type; +PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type; + +/* Type check macros */ +#define PyByteArray_Check(self) PyObject_TypeCheck((self), &PyByteArray_Type) +#define PyByteArray_CheckExact(self) Py_IS_TYPE((self), &PyByteArray_Type) + +/* Direct API functions */ +PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *); +PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t); +PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *); +PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *); +PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_BYTEARRAYOBJECT_H +# include "cpython/bytearrayobject.h" +# undef Py_CPYTHON_BYTEARRAYOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BYTEARRAYOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/bytesobject.h b/illumos-x86_64/usr/include/python3.13/bytesobject.h new file mode 100644 index 00000000..c5a24195 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/bytesobject.h @@ -0,0 +1,66 @@ +// Bytes object interface + +#ifndef Py_BYTESOBJECT_H +#define Py_BYTESOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* +Type PyBytesObject represents a byte string. An extra zero byte is +reserved at the end to ensure it is zero-terminated, but a size is +present so strings with null bytes in them can be represented. This +is an immutable object type. + +There are functions to create new bytes objects, to test +an object for bytes-ness, and to get the +byte string value. The latter function returns a null pointer +if the object is not of the proper type. +There is a variant that takes an explicit size as well as a +variant that assumes a zero-terminated string. Note that none of the +functions should be applied to NULL pointer. +*/ + +PyAPI_DATA(PyTypeObject) PyBytes_Type; +PyAPI_DATA(PyTypeObject) PyBytesIter_Type; + +#define PyBytes_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS) +#define PyBytes_CheckExact(op) Py_IS_TYPE((op), &PyBytes_Type) + +PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *); +PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *); +PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list) + Py_GCC_ATTRIBUTE((format(printf, 1, 0))); +PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *); +PyAPI_FUNC(char *) PyBytes_AsString(PyObject *); +PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int); +PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *); +PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *); +PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t, + const char *, Py_ssize_t, + const char *); + +/* Provides access to the internal data buffer and size of a bytes object. + Passing NULL as len parameter will force the string buffer to be + 0-terminated (passing a string with embedded NUL characters will + cause an exception). */ +PyAPI_FUNC(int) PyBytes_AsStringAndSize( + PyObject *obj, /* bytes object */ + char **s, /* pointer to buffer variable */ + Py_ssize_t *len /* pointer to length variable or NULL */ + ); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_BYTESOBJECT_H +# include "cpython/bytesobject.h" +# undef Py_CPYTHON_BYTESOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BYTESOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/ceval.h b/illumos-x86_64/usr/include/python3.13/ceval.h new file mode 100644 index 00000000..1ec746c3 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/ceval.h @@ -0,0 +1,145 @@ +/* Interface to random parts in ceval.c */ + +#ifndef Py_CEVAL_H +#define Py_CEVAL_H +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co, + PyObject *globals, + PyObject *locals, + PyObject *const *args, int argc, + PyObject *const *kwds, int kwdc, + PyObject *const *defs, int defc, + PyObject *kwdefs, PyObject *closure); + +PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void); +PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); +PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); +PyAPI_FUNC(PyFrameObject *) PyEval_GetFrame(void); + +PyAPI_FUNC(PyObject *) PyEval_GetFrameBuiltins(void); +PyAPI_FUNC(PyObject *) PyEval_GetFrameGlobals(void); +PyAPI_FUNC(PyObject *) PyEval_GetFrameLocals(void); + +PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg); +PyAPI_FUNC(int) Py_MakePendingCalls(void); + +/* Protection against deeply nested recursive calls + + In Python 3.0, this protection has two levels: + * normal anti-recursion protection is triggered when the recursion level + exceeds the current recursion limit. It raises a RecursionError, and sets + the "overflowed" flag in the thread state structure. This flag + temporarily *disables* the normal protection; this allows cleanup code + to potentially outgrow the recursion limit while processing the + RecursionError. + * "last chance" anti-recursion protection is triggered when the recursion + level exceeds "current recursion limit + 50". By construction, this + protection can only be triggered when the "overflowed" flag is set. It + means the cleanup code has itself gone into an infinite loop, or the + RecursionError has been mistakingly ignored. When this protection is + triggered, the interpreter aborts with a Fatal Error. + + In addition, the "overflowed" flag is automatically reset when the + recursion level drops below "current recursion limit - 50". This heuristic + is meant to ensure that the normal anti-recursion protection doesn't get + disabled too long. + + Please note: this scheme has its own limitations. See: + http://mail.python.org/pipermail/python-dev/2008-August/082106.html + for some observations. +*/ +PyAPI_FUNC(void) Py_SetRecursionLimit(int); +PyAPI_FUNC(int) Py_GetRecursionLimit(void); + +PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where); +PyAPI_FUNC(void) Py_LeaveRecursiveCall(void); + +PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *); +PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *); + +PyAPI_FUNC(PyObject *) PyEval_EvalFrame(PyFrameObject *); +PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(PyFrameObject *f, int exc); + +/* Interface for threads. + + A module that plans to do a blocking system call (or something else + that lasts a long time and doesn't touch Python data) can allow other + threads to run as follows: + + ...preparations here... + Py_BEGIN_ALLOW_THREADS + ...blocking system call here... + Py_END_ALLOW_THREADS + ...interpret result here... + + The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a + {}-surrounded block. + To leave the block in the middle (e.g., with return), you must insert + a line containing Py_BLOCK_THREADS before the return, e.g. + + if (...premature_exit...) { + Py_BLOCK_THREADS + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + + An alternative is: + + Py_BLOCK_THREADS + if (...premature_exit...) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + Py_UNBLOCK_THREADS + + For convenience, that the value of 'errno' is restored across + Py_END_ALLOW_THREADS and Py_BLOCK_THREADS. + + WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND + Py_END_ALLOW_THREADS!!! + + Note that not yet all candidates have been converted to use this + mechanism! +*/ + +PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void); +PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *); + +Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void); + +PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); +PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); + +#define Py_BEGIN_ALLOW_THREADS { \ + PyThreadState *_save; \ + _save = PyEval_SaveThread(); +#define Py_BLOCK_THREADS PyEval_RestoreThread(_save); +#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); +#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ + } + +/* Masks and values used by FORMAT_VALUE opcode. */ +#define FVC_MASK 0x3 +#define FVC_NONE 0x0 +#define FVC_STR 0x1 +#define FVC_REPR 0x2 +#define FVC_ASCII 0x3 +#define FVS_MASK 0x4 +#define FVS_HAVE_SPEC 0x4 + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_CEVAL_H +# include "cpython/ceval.h" +# undef Py_CPYTHON_CEVAL_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CEVAL_H */ diff --git a/illumos-x86_64/usr/include/python3.13/codecs.h b/illumos-x86_64/usr/include/python3.13/codecs.h new file mode 100644 index 00000000..512a3c72 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/codecs.h @@ -0,0 +1,176 @@ +#ifndef Py_CODECREGISTRY_H +#define Py_CODECREGISTRY_H +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------------------------------------------------------------------ + + Python Codec Registry and support functions + + +Written by Marc-Andre Lemburg (mal@lemburg.com). + +Copyright (c) Corporation for National Research Initiatives. + + ------------------------------------------------------------------------ */ + +/* Register a new codec search function. + + As side effect, this tries to load the encodings package, if not + yet done, to make sure that it is always first in the list of + search functions. + + The search_function's refcount is incremented by this function. */ + +PyAPI_FUNC(int) PyCodec_Register( + PyObject *search_function + ); + +/* Unregister a codec search function and clear the registry's cache. + If the search function is not registered, do nothing. + Return 0 on success. Raise an exception and return -1 on error. */ + +PyAPI_FUNC(int) PyCodec_Unregister( + PyObject *search_function + ); + +/* Codec registry encoding check API. + + Returns 1/0 depending on whether there is a registered codec for + the given encoding. + +*/ + +PyAPI_FUNC(int) PyCodec_KnownEncoding( + const char *encoding + ); + +/* Generic codec based encoding API. + + object is passed through the encoder function found for the given + encoding using the error handling method defined by errors. errors + may be NULL to use the default method defined for the codec. + + Raises a LookupError in case no encoder can be found. + + */ + +PyAPI_FUNC(PyObject *) PyCodec_Encode( + PyObject *object, + const char *encoding, + const char *errors + ); + +/* Generic codec based decoding API. + + object is passed through the decoder function found for the given + encoding using the error handling method defined by errors. errors + may be NULL to use the default method defined for the codec. + + Raises a LookupError in case no encoder can be found. + + */ + +PyAPI_FUNC(PyObject *) PyCodec_Decode( + PyObject *object, + const char *encoding, + const char *errors + ); + +// --- Codec Lookup APIs -------------------------------------------------- + +/* Codec registry lookup API. + + Looks up the given encoding and returns a CodecInfo object with + function attributes which implement the different aspects of + processing the encoding. + + The encoding string is looked up converted to all lower-case + characters. This makes encodings looked up through this mechanism + effectively case-insensitive. + + If no codec is found, a KeyError is set and NULL returned. + + As side effect, this tries to load the encodings package, if not + yet done. This is part of the lazy load strategy for the encodings + package. + */ + +/* Get an encoder function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_Encoder(const char *encoding); + +/* Get a decoder function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_Decoder(const char *encoding); + +/* Get an IncrementalEncoder object for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder( + const char *encoding, + const char *errors); + +/* Get an IncrementalDecoder object function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder( + const char *encoding, + const char *errors); + +/* Get a StreamReader factory function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_StreamReader( + const char *encoding, + PyObject *stream, + const char *errors); + +/* Get a StreamWriter factory function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_StreamWriter( + const char *encoding, + PyObject *stream, + const char *errors); + +/* Unicode encoding error handling callback registry API */ + +/* Register the error handling callback function error under the given + name. This function will be called by the codec when it encounters + unencodable characters/undecodable bytes and doesn't know the + callback name, when name is specified as the error parameter + in the call to the encode/decode function. + Return 0 on success, -1 on error */ +PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error); + +/* Lookup the error handling callback function registered under the given + name. As a special case NULL can be passed, in which case + the error handling callback for "strict" will be returned. */ +PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name); + +/* raise exc as an exception */ +PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc); + +/* ignore the unicode error, skipping the faulty input */ +PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc); + +/* replace the unicode encode error with ? or U+FFFD */ +PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with XML character references */ +PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with backslash escapes (\x, \u and \U) */ +PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */ +PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc); +#endif + +#ifndef Py_LIMITED_API +PyAPI_DATA(const char *) Py_hexdigits; +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CODECREGISTRY_H */ diff --git a/illumos-x86_64/usr/include/python3.13/compile.h b/illumos-x86_64/usr/include/python3.13/compile.h new file mode 100644 index 00000000..52d0bc76 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/compile.h @@ -0,0 +1,22 @@ +#ifndef Py_COMPILE_H +#define Py_COMPILE_H +#ifdef __cplusplus +extern "C" { +#endif + +/* These definitions must match corresponding definitions in graminit.h. */ +#define Py_single_input 256 +#define Py_file_input 257 +#define Py_eval_input 258 +#define Py_func_type_input 345 + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_COMPILE_H +# include "cpython/compile.h" +# undef Py_CPYTHON_COMPILE_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COMPILE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/complexobject.h b/illumos-x86_64/usr/include/python3.13/complexobject.h new file mode 100644 index 00000000..ebe49a83 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/complexobject.h @@ -0,0 +1,30 @@ +/* Complex number structure */ + +#ifndef Py_COMPLEXOBJECT_H +#define Py_COMPLEXOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Complex object interface */ + +PyAPI_DATA(PyTypeObject) PyComplex_Type; + +#define PyComplex_Check(op) PyObject_TypeCheck((op), &PyComplex_Type) +#define PyComplex_CheckExact(op) Py_IS_TYPE((op), &PyComplex_Type) + +PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); + +PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); +PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_COMPLEXOBJECT_H +# include "cpython/complexobject.h" +# undef Py_CPYTHON_COMPLEXOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COMPLEXOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/abstract.h b/illumos-x86_64/usr/include/python3.13/cpython/abstract.h new file mode 100644 index 00000000..4e7b7a46 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/abstract.h @@ -0,0 +1,87 @@ +#ifndef Py_CPYTHON_ABSTRACTOBJECT_H +# error "this header file must not be included directly" +#endif + +/* === Object Protocol ================================================== */ + +/* Like PyObject_CallMethod(), but expect a _Py_Identifier* + as the method name. */ +PyAPI_FUNC(PyObject*) _PyObject_CallMethodId( + PyObject *obj, + _Py_Identifier *name, + const char *format, ...); + +/* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple) + format to a Python dictionary ("kwargs" dict). + + The type of kwnames keys is not checked. The final function getting + arguments is responsible to check if all keys are strings, for example using + PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments(). + + Duplicate keys are merged using the last value. If duplicate keys must raise + an exception, the caller is responsible to implement an explicit keys on + kwnames. */ +PyAPI_FUNC(PyObject*) _PyStack_AsDict(PyObject *const *values, PyObject *kwnames); + + +/* === Vectorcall protocol (PEP 590) ============================= */ + +// PyVectorcall_NARGS() is exported as a function for the stable ABI. +// Here (when we are not using the stable ABI), the name is overridden to +// call a static inline function for best performance. +static inline Py_ssize_t +_PyVectorcall_NARGS(size_t n) +{ + return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET; +} +#define PyVectorcall_NARGS(n) _PyVectorcall_NARGS(n) + +PyAPI_FUNC(vectorcallfunc) PyVectorcall_Function(PyObject *callable); + +// Backwards compatibility aliases (PEP 590) for API that was provisional +// in Python 3.8 +#define _PyObject_Vectorcall PyObject_Vectorcall +#define _PyObject_VectorcallMethod PyObject_VectorcallMethod +#define _PyObject_FastCallDict PyObject_VectorcallDict +#define _PyVectorcall_Function PyVectorcall_Function +#define _PyObject_CallOneArg PyObject_CallOneArg +#define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs +#define _PyObject_CallMethodOneArg PyObject_CallMethodOneArg + +/* Same as PyObject_Vectorcall except that keyword arguments are passed as + dict, which may be NULL if there are no keyword arguments. */ +PyAPI_FUNC(PyObject *) PyObject_VectorcallDict( + PyObject *callable, + PyObject *const *args, + size_t nargsf, + PyObject *kwargs); + +PyAPI_FUNC(PyObject *) PyObject_CallOneArg(PyObject *func, PyObject *arg); + +static inline PyObject * +PyObject_CallMethodNoArgs(PyObject *self, PyObject *name) +{ + size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET; + return PyObject_VectorcallMethod(name, &self, nargsf, _Py_NULL); +} + +static inline PyObject * +PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) +{ + PyObject *args[2] = {self, arg}; + size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET; + assert(arg != NULL); + return PyObject_VectorcallMethod(name, args, nargsf, _Py_NULL); +} + +/* Guess the size of object 'o' using len(o) or o.__length_hint__(). + If neither of those return a non-negative value, then return the default + value. If one of the calls fails, this function returns -1. */ +PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t); + +/* === Sequence protocol ================================================ */ + +/* Assume tp_as_sequence and sq_item exist and that 'i' does not + need to be corrected for a negative index. */ +#define PySequence_ITEM(o, i)\ + ( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) ) diff --git a/illumos-x86_64/usr/include/python3.13/cpython/bytearrayobject.h b/illumos-x86_64/usr/include/python3.13/cpython/bytearrayobject.h new file mode 100644 index 00000000..9ba176eb --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/bytearrayobject.h @@ -0,0 +1,34 @@ +#ifndef Py_CPYTHON_BYTEARRAYOBJECT_H +# error "this header file must not be included directly" +#endif + +/* Object layout */ +typedef struct { + PyObject_VAR_HEAD + Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */ + char *ob_bytes; /* Physical backing buffer */ + char *ob_start; /* Logical start inside ob_bytes */ + Py_ssize_t ob_exports; /* How many buffer exports */ +} PyByteArrayObject; + +PyAPI_DATA(char) _PyByteArray_empty_string[]; + +/* Macros and static inline functions, trading safety for speed */ +#define _PyByteArray_CAST(op) \ + (assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op)) + +static inline char* PyByteArray_AS_STRING(PyObject *op) +{ + PyByteArrayObject *self = _PyByteArray_CAST(op); + if (Py_SIZE(self)) { + return self->ob_start; + } + return _PyByteArray_empty_string; +} +#define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self)) + +static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) { + PyByteArrayObject *self = _PyByteArray_CAST(op); + return Py_SIZE(self); +} +#define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self)) diff --git a/illumos-x86_64/usr/include/python3.13/cpython/bytesobject.h b/illumos-x86_64/usr/include/python3.13/cpython/bytesobject.h new file mode 100644 index 00000000..41537210 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/bytesobject.h @@ -0,0 +1,37 @@ +#ifndef Py_CPYTHON_BYTESOBJECT_H +# error "this header file must not be included directly" +#endif + +typedef struct { + PyObject_VAR_HEAD + Py_DEPRECATED(3.11) Py_hash_t ob_shash; + char ob_sval[1]; + + /* Invariants: + * ob_sval contains space for 'ob_size+1' elements. + * ob_sval[ob_size] == 0. + * ob_shash is the hash of the byte string or -1 if not computed yet. + */ +} PyBytesObject; + +PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t); + +/* Macros and static inline functions, trading safety for speed */ +#define _PyBytes_CAST(op) \ + (assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op)) + +static inline char* PyBytes_AS_STRING(PyObject *op) +{ + return _PyBytes_CAST(op)->ob_sval; +} +#define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op)) + +static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) { + PyBytesObject *self = _PyBytes_CAST(op); + return Py_SIZE(self); +} +#define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self)) + +/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*, + x must be an iterable object. */ +PyAPI_FUNC(PyObject*) _PyBytes_Join(PyObject *sep, PyObject *x); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/cellobject.h b/illumos-x86_64/usr/include/python3.13/cpython/cellobject.h new file mode 100644 index 00000000..47a6a491 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/cellobject.h @@ -0,0 +1,44 @@ +/* Cell object interface */ + +#ifndef Py_LIMITED_API +#ifndef Py_CELLOBJECT_H +#define Py_CELLOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + /* Content of the cell or NULL when empty */ + PyObject *ob_ref; +} PyCellObject; + +PyAPI_DATA(PyTypeObject) PyCell_Type; + +#define PyCell_Check(op) Py_IS_TYPE((op), &PyCell_Type) + +PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); +PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); +PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); + +static inline PyObject* PyCell_GET(PyObject *op) { + PyCellObject *cell; + assert(PyCell_Check(op)); + cell = _Py_CAST(PyCellObject*, op); + return cell->ob_ref; +} +#define PyCell_GET(op) PyCell_GET(_PyObject_CAST(op)) + +static inline void PyCell_SET(PyObject *op, PyObject *value) { + PyCellObject *cell; + assert(PyCell_Check(op)); + cell = _Py_CAST(PyCellObject*, op); + cell->ob_ref = value; +} +#define PyCell_SET(op, value) PyCell_SET(_PyObject_CAST(op), (value)) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TUPLEOBJECT_H */ +#endif /* Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/ceval.h b/illumos-x86_64/usr/include/python3.13/cpython/ceval.h new file mode 100644 index 00000000..78f74056 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/ceval.h @@ -0,0 +1,25 @@ +#ifndef Py_CPYTHON_CEVAL_H +# error "this header file must not be included directly" +#endif + +PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); +PyAPI_FUNC(void) PyEval_SetProfileAllThreads(Py_tracefunc, PyObject *); +PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); +PyAPI_FUNC(void) PyEval_SetTraceAllThreads(Py_tracefunc, PyObject *); + +/* Look at the current frame's (if any) code's co_flags, and turn on + the corresponding compiler flags in cf->cf_flags. Return 1 if any + flag was set, else return 0. */ +PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); + +PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _PyInterpreterFrame *f, int exc); + +PyAPI_FUNC(Py_ssize_t) PyUnstable_Eval_RequestCodeExtraIndex(freefunc); +// Old name -- remove when this API changes: +_Py_DEPRECATED_EXTERNALLY(3.12) static inline Py_ssize_t +_PyEval_RequestCodeExtraIndex(freefunc f) { + return PyUnstable_Eval_RequestCodeExtraIndex(f); +} + +PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/classobject.h b/illumos-x86_64/usr/include/python3.13/cpython/classobject.h new file mode 100644 index 00000000..d7c9ddd1 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/classobject.h @@ -0,0 +1,71 @@ +/* Former class object interface -- now only bound methods are here */ + +/* Revealing some structures (not for general use) */ + +#ifndef Py_LIMITED_API +#ifndef Py_CLASSOBJECT_H +#define Py_CLASSOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + PyObject *im_func; /* The callable object implementing the method */ + PyObject *im_self; /* The instance it is bound to */ + PyObject *im_weakreflist; /* List of weak references */ + vectorcallfunc vectorcall; +} PyMethodObject; + +PyAPI_DATA(PyTypeObject) PyMethod_Type; + +#define PyMethod_Check(op) Py_IS_TYPE((op), &PyMethod_Type) + +PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); +PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); + +#define _PyMethod_CAST(meth) \ + (assert(PyMethod_Check(meth)), _Py_CAST(PyMethodObject*, meth)) + +/* Static inline functions for direct access to these values. + Type checks are *not* done, so use with care. */ +static inline PyObject* PyMethod_GET_FUNCTION(PyObject *meth) { + return _PyMethod_CAST(meth)->im_func; +} +#define PyMethod_GET_FUNCTION(meth) PyMethod_GET_FUNCTION(_PyObject_CAST(meth)) + +static inline PyObject* PyMethod_GET_SELF(PyObject *meth) { + return _PyMethod_CAST(meth)->im_self; +} +#define PyMethod_GET_SELF(meth) PyMethod_GET_SELF(_PyObject_CAST(meth)) + +typedef struct { + PyObject_HEAD + PyObject *func; +} PyInstanceMethodObject; + +PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type; + +#define PyInstanceMethod_Check(op) Py_IS_TYPE((op), &PyInstanceMethod_Type) + +PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *); +PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); + +#define _PyInstanceMethod_CAST(meth) \ + (assert(PyInstanceMethod_Check(meth)), \ + _Py_CAST(PyInstanceMethodObject*, meth)) + +/* Static inline function for direct access to these values. + Type checks are *not* done, so use with care. */ +static inline PyObject* PyInstanceMethod_GET_FUNCTION(PyObject *meth) { + return _PyInstanceMethod_CAST(meth)->func; +} +#define PyInstanceMethod_GET_FUNCTION(meth) PyInstanceMethod_GET_FUNCTION(_PyObject_CAST(meth)) + +#ifdef __cplusplus +} +#endif +#endif // !Py_CLASSOBJECT_H +#endif // !Py_LIMITED_API diff --git a/illumos-x86_64/usr/include/python3.13/cpython/code.h b/illumos-x86_64/usr/include/python3.13/cpython/code.h new file mode 100644 index 00000000..bd8afab8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/code.h @@ -0,0 +1,358 @@ +/* Definitions for bytecode */ + +#ifndef Py_LIMITED_API +#ifndef Py_CODE_H +#define Py_CODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Count of all local monitoring events */ +#define _PY_MONITORING_LOCAL_EVENTS 10 +/* Count of all "real" monitoring events (not derived from other events) */ +#define _PY_MONITORING_UNGROUPED_EVENTS 15 +/* Count of all monitoring events */ +#define _PY_MONITORING_EVENTS 17 + +/* Tables of which tools are active for each monitored event. */ +typedef struct _Py_LocalMonitors { + uint8_t tools[_PY_MONITORING_LOCAL_EVENTS]; +} _Py_LocalMonitors; + +typedef struct _Py_GlobalMonitors { + uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS]; +} _Py_GlobalMonitors; + + +typedef struct { + PyObject *_co_code; + PyObject *_co_varnames; + PyObject *_co_cellvars; + PyObject *_co_freevars; +} _PyCoCached; + +/* Ancillary data structure used for instrumentation. + Line instrumentation creates this with sufficient + space for one entry per code unit. The total size + of the data will be `bytes_per_entry * Py_SIZE(code)` */ +typedef struct { + uint8_t bytes_per_entry; + uint8_t data[1]; +} _PyCoLineInstrumentationData; + + +typedef struct { + int size; + int capacity; + struct _PyExecutorObject *executors[1]; +} _PyExecutorArray; + +/* Main data structure used for instrumentation. + * This is allocated when needed for instrumentation + */ +typedef struct { + /* Monitoring specific to this code object */ + _Py_LocalMonitors local_monitors; + /* Monitoring that is active on this code object */ + _Py_LocalMonitors active_monitors; + /* The tools that are to be notified for events for the matching code unit */ + uint8_t *tools; + /* Information to support line events */ + _PyCoLineInstrumentationData *lines; + /* The tools that are to be notified for line events for the matching code unit */ + uint8_t *line_tools; + /* Information to support instruction events */ + /* The underlying instructions, which can themselves be instrumented */ + uint8_t *per_instruction_opcodes; + /* The tools that are to be notified for instruction events for the matching code unit */ + uint8_t *per_instruction_tools; +} _PyCoMonitoringData; + +// To avoid repeating ourselves in deepfreeze.py, all PyCodeObject members are +// defined in this macro: +#define _PyCode_DEF(SIZE) { \ + PyObject_VAR_HEAD \ + \ + /* Note only the following fields are used in hash and/or comparisons \ + * \ + * - co_name \ + * - co_argcount \ + * - co_posonlyargcount \ + * - co_kwonlyargcount \ + * - co_nlocals \ + * - co_stacksize \ + * - co_flags \ + * - co_firstlineno \ + * - co_consts \ + * - co_names \ + * - co_localsplusnames \ + * This is done to preserve the name and line number for tracebacks \ + * and debuggers; otherwise, constant de-duplication would collapse \ + * identical functions/lambdas defined on different lines. \ + */ \ + \ + /* These fields are set with provided values on new code objects. */ \ + \ + /* The hottest fields (in the eval loop) are grouped here at the top. */ \ + PyObject *co_consts; /* list (constants used) */ \ + PyObject *co_names; /* list of strings (names used) */ \ + PyObject *co_exceptiontable; /* Byte string encoding exception handling \ + table */ \ + int co_flags; /* CO_..., see below */ \ + \ + /* The rest are not so impactful on performance. */ \ + int co_argcount; /* #arguments, except *args */ \ + int co_posonlyargcount; /* #positional only arguments */ \ + int co_kwonlyargcount; /* #keyword only arguments */ \ + int co_stacksize; /* #entries needed for evaluation stack */ \ + int co_firstlineno; /* first source line number */ \ + \ + /* redundant values (derived from co_localsplusnames and \ + co_localspluskinds) */ \ + int co_nlocalsplus; /* number of local + cell + free variables */ \ + int co_framesize; /* Size of frame in words */ \ + int co_nlocals; /* number of local variables */ \ + int co_ncellvars; /* total number of cell variables */ \ + int co_nfreevars; /* number of free variables */ \ + uint32_t co_version; /* version number */ \ + \ + PyObject *co_localsplusnames; /* tuple mapping offsets to names */ \ + PyObject *co_localspluskinds; /* Bytes mapping to local kinds (one byte \ + per variable) */ \ + PyObject *co_filename; /* unicode (where it was loaded from) */ \ + PyObject *co_name; /* unicode (name, for reference) */ \ + PyObject *co_qualname; /* unicode (qualname, for reference) */ \ + PyObject *co_linetable; /* bytes object that holds location info */ \ + PyObject *co_weakreflist; /* to support weakrefs to code objects */ \ + _PyExecutorArray *co_executors; /* executors from optimizer */ \ + _PyCoCached *_co_cached; /* cached co_* attributes */ \ + uintptr_t _co_instrumentation_version; /* current instrumentation version */ \ + _PyCoMonitoringData *_co_monitoring; /* Monitoring data */ \ + int _co_firsttraceable; /* index of first traceable instruction */ \ + /* Scratch space for extra data relating to the code object. \ + Type is a void* to keep the format private in codeobject.c to force \ + people to go through the proper APIs. */ \ + void *co_extra; \ + char co_code_adaptive[(SIZE)]; \ +} + +/* Bytecode object */ +struct PyCodeObject _PyCode_DEF(1); + +/* Masks for co_flags above */ +#define CO_OPTIMIZED 0x0001 +#define CO_NEWLOCALS 0x0002 +#define CO_VARARGS 0x0004 +#define CO_VARKEYWORDS 0x0008 +#define CO_NESTED 0x0010 +#define CO_GENERATOR 0x0020 + +/* The CO_COROUTINE flag is set for coroutine functions (defined with + ``async def`` keywords) */ +#define CO_COROUTINE 0x0080 +#define CO_ITERABLE_COROUTINE 0x0100 +#define CO_ASYNC_GENERATOR 0x0200 + +/* bpo-39562: These constant values are changed in Python 3.9 + to prevent collision with compiler flags. CO_FUTURE_ and PyCF_ + constants must be kept unique. PyCF_ constants can use bits from + 0x0100 to 0x10000. CO_FUTURE_ constants use bits starting at 0x20000. */ +#define CO_FUTURE_DIVISION 0x20000 +#define CO_FUTURE_ABSOLUTE_IMPORT 0x40000 /* do absolute imports by default */ +#define CO_FUTURE_WITH_STATEMENT 0x80000 +#define CO_FUTURE_PRINT_FUNCTION 0x100000 +#define CO_FUTURE_UNICODE_LITERALS 0x200000 + +#define CO_FUTURE_BARRY_AS_BDFL 0x400000 +#define CO_FUTURE_GENERATOR_STOP 0x800000 +#define CO_FUTURE_ANNOTATIONS 0x1000000 + +#define CO_NO_MONITORING_EVENTS 0x2000000 + +/* This should be defined if a future statement modifies the syntax. + For example, when a keyword is added. +*/ +#define PY_PARSER_REQUIRES_FUTURE_KEYWORD + +#define CO_MAXBLOCKS 21 /* Max static block nesting within a function */ + +PyAPI_DATA(PyTypeObject) PyCode_Type; + +#define PyCode_Check(op) Py_IS_TYPE((op), &PyCode_Type) + +static inline Py_ssize_t PyCode_GetNumFree(PyCodeObject *op) { + assert(PyCode_Check(op)); + return op->co_nfreevars; +} + +static inline int PyUnstable_Code_GetFirstFree(PyCodeObject *op) { + assert(PyCode_Check(op)); + return op->co_nlocalsplus - op->co_nfreevars; +} + +Py_DEPRECATED(3.13) static inline int PyCode_GetFirstFree(PyCodeObject *op) { + return PyUnstable_Code_GetFirstFree(op); +} + +/* Unstable public interface */ +PyAPI_FUNC(PyCodeObject *) PyUnstable_Code_New( + int, int, int, int, int, PyObject *, PyObject *, + PyObject *, PyObject *, PyObject *, PyObject *, + PyObject *, PyObject *, PyObject *, int, PyObject *, + PyObject *); + +PyAPI_FUNC(PyCodeObject *) PyUnstable_Code_NewWithPosOnlyArgs( + int, int, int, int, int, int, PyObject *, PyObject *, + PyObject *, PyObject *, PyObject *, PyObject *, + PyObject *, PyObject *, PyObject *, int, PyObject *, + PyObject *); + /* same as struct above */ +// Old names -- remove when this API changes: +_Py_DEPRECATED_EXTERNALLY(3.12) static inline PyCodeObject * +PyCode_New( + int a, int b, int c, int d, int e, PyObject *f, PyObject *g, + PyObject *h, PyObject *i, PyObject *j, PyObject *k, + PyObject *l, PyObject *m, PyObject *n, int o, PyObject *p, + PyObject *q) +{ + return PyUnstable_Code_New( + a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q); +} +_Py_DEPRECATED_EXTERNALLY(3.12) static inline PyCodeObject * +PyCode_NewWithPosOnlyArgs( + int a, int poac, int b, int c, int d, int e, PyObject *f, PyObject *g, + PyObject *h, PyObject *i, PyObject *j, PyObject *k, + PyObject *l, PyObject *m, PyObject *n, int o, PyObject *p, + PyObject *q) +{ + return PyUnstable_Code_NewWithPosOnlyArgs( + a, poac, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q); +} + +/* Creates a new empty code object with the specified source location. */ +PyAPI_FUNC(PyCodeObject *) +PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); + +/* Return the line number associated with the specified bytecode index + in this code object. If you just need the line number of a frame, + use PyFrame_GetLineNumber() instead. */ +PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); + +PyAPI_FUNC(int) PyCode_Addr2Location(PyCodeObject *, int, int *, int *, int *, int *); + +#define PY_FOREACH_CODE_EVENT(V) \ + V(CREATE) \ + V(DESTROY) + +typedef enum { + #define PY_DEF_EVENT(op) PY_CODE_EVENT_##op, + PY_FOREACH_CODE_EVENT(PY_DEF_EVENT) + #undef PY_DEF_EVENT +} PyCodeEvent; + + +/* + * A callback that is invoked for different events in a code object's lifecycle. + * + * The callback is invoked with a borrowed reference to co, after it is + * created and before it is destroyed. + * + * If the callback sets an exception, it must return -1. Otherwise + * it should return 0. + */ +typedef int (*PyCode_WatchCallback)( + PyCodeEvent event, + PyCodeObject* co); + +/* + * Register a per-interpreter callback that will be invoked for code object + * lifecycle events. + * + * Returns a handle that may be passed to PyCode_ClearWatcher on success, + * or -1 and sets an error if no more handles are available. + */ +PyAPI_FUNC(int) PyCode_AddWatcher(PyCode_WatchCallback callback); + +/* + * Clear the watcher associated with the watcher_id handle. + * + * Returns 0 on success or -1 if no watcher exists for the provided id. + */ +PyAPI_FUNC(int) PyCode_ClearWatcher(int watcher_id); + +/* for internal use only */ +struct _opaque { + int computed_line; + const uint8_t *lo_next; + const uint8_t *limit; +}; + +typedef struct _line_offsets { + int ar_start; + int ar_end; + int ar_line; + struct _opaque opaque; +} PyCodeAddressRange; + +/* Update *bounds to describe the first and one-past-the-last instructions in the + same line as lasti. Return the number of that line. +*/ +PyAPI_FUNC(int) _PyCode_CheckLineNumber(int lasti, PyCodeAddressRange *bounds); + +/* Create a comparable key used to compare constants taking in account the + * object type. It is used to make sure types are not coerced (e.g., float and + * complex) _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms + * + * Return (type(obj), obj, ...): a tuple with variable size (at least 2 items) + * depending on the type and the value. The type is the first item to not + * compare bytes and str which can raise a BytesWarning exception. */ +PyAPI_FUNC(PyObject*) _PyCode_ConstantKey(PyObject *obj); + +PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, + PyObject *names, PyObject *lnotab); + +PyAPI_FUNC(int) PyUnstable_Code_GetExtra( + PyObject *code, Py_ssize_t index, void **extra); +PyAPI_FUNC(int) PyUnstable_Code_SetExtra( + PyObject *code, Py_ssize_t index, void *extra); +// Old names -- remove when this API changes: +_Py_DEPRECATED_EXTERNALLY(3.12) static inline int +_PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra) +{ + return PyUnstable_Code_GetExtra(code, index, extra); +} +_Py_DEPRECATED_EXTERNALLY(3.12) static inline int +_PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra) +{ + return PyUnstable_Code_SetExtra(code, index, extra); +} + +/* Equivalent to getattr(code, 'co_code') in Python. + Returns a strong reference to a bytes object. */ +PyAPI_FUNC(PyObject *) PyCode_GetCode(PyCodeObject *code); +/* Equivalent to getattr(code, 'co_varnames') in Python. */ +PyAPI_FUNC(PyObject *) PyCode_GetVarnames(PyCodeObject *code); +/* Equivalent to getattr(code, 'co_cellvars') in Python. */ +PyAPI_FUNC(PyObject *) PyCode_GetCellvars(PyCodeObject *code); +/* Equivalent to getattr(code, 'co_freevars') in Python. */ +PyAPI_FUNC(PyObject *) PyCode_GetFreevars(PyCodeObject *code); + +typedef enum _PyCodeLocationInfoKind { + /* short forms are 0 to 9 */ + PY_CODE_LOCATION_INFO_SHORT0 = 0, + /* one lineforms are 10 to 12 */ + PY_CODE_LOCATION_INFO_ONE_LINE0 = 10, + PY_CODE_LOCATION_INFO_ONE_LINE1 = 11, + PY_CODE_LOCATION_INFO_ONE_LINE2 = 12, + + PY_CODE_LOCATION_INFO_NO_COLUMNS = 13, + PY_CODE_LOCATION_INFO_LONG = 14, + PY_CODE_LOCATION_INFO_NONE = 15 +} _PyCodeLocationInfoKind; + +#ifdef __cplusplus +} +#endif +#endif // !Py_CODE_H +#endif // !Py_LIMITED_API diff --git a/illumos-x86_64/usr/include/python3.13/cpython/compile.h b/illumos-x86_64/usr/include/python3.13/cpython/compile.h new file mode 100644 index 00000000..cfdb7080 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/compile.h @@ -0,0 +1,50 @@ +#ifndef Py_CPYTHON_COMPILE_H +# error "this header file must not be included directly" +#endif + +/* Public interface */ +#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \ + CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \ + CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \ + CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS) +#define PyCF_MASK_OBSOLETE (CO_NESTED) + +/* bpo-39562: CO_FUTURE_ and PyCF_ constants must be kept unique. + PyCF_ constants can use bits from 0x0100 to 0x10000. + CO_FUTURE_ constants use bits starting at 0x20000. */ +#define PyCF_SOURCE_IS_UTF8 0x0100 +#define PyCF_DONT_IMPLY_DEDENT 0x0200 +#define PyCF_ONLY_AST 0x0400 +#define PyCF_IGNORE_COOKIE 0x0800 +#define PyCF_TYPE_COMMENTS 0x1000 +#define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000 +#define PyCF_ALLOW_INCOMPLETE_INPUT 0x4000 +#define PyCF_OPTIMIZED_AST (0x8000 | PyCF_ONLY_AST) +#define PyCF_COMPILE_MASK (PyCF_ONLY_AST | PyCF_ALLOW_TOP_LEVEL_AWAIT | \ + PyCF_TYPE_COMMENTS | PyCF_DONT_IMPLY_DEDENT | \ + PyCF_ALLOW_INCOMPLETE_INPUT | PyCF_OPTIMIZED_AST) + +typedef struct { + int cf_flags; /* bitmask of CO_xxx flags relevant to future */ + int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */ +} PyCompilerFlags; + +#define _PyCompilerFlags_INIT \ + (PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION} + +/* Future feature support */ + +#define FUTURE_NESTED_SCOPES "nested_scopes" +#define FUTURE_GENERATORS "generators" +#define FUTURE_DIVISION "division" +#define FUTURE_ABSOLUTE_IMPORT "absolute_import" +#define FUTURE_WITH_STATEMENT "with_statement" +#define FUTURE_PRINT_FUNCTION "print_function" +#define FUTURE_UNICODE_LITERALS "unicode_literals" +#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL" +#define FUTURE_GENERATOR_STOP "generator_stop" +#define FUTURE_ANNOTATIONS "annotations" + +#define PY_INVALID_STACK_EFFECT INT_MAX +PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg); +PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/complexobject.h b/illumos-x86_64/usr/include/python3.13/cpython/complexobject.h new file mode 100644 index 00000000..fbdc6a91 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/complexobject.h @@ -0,0 +1,33 @@ +#ifndef Py_CPYTHON_COMPLEXOBJECT_H +# error "this header file must not be included directly" +#endif + +typedef struct { + double real; + double imag; +} Py_complex; + +// Operations on complex numbers. +PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex); +PyAPI_FUNC(double) _Py_c_abs(Py_complex); + + +/* Complex object interface */ + +/* +PyComplexObject represents a complex number with double-precision +real and imaginary parts. +*/ +typedef struct { + PyObject_HEAD + Py_complex cval; +} PyComplexObject; + +PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); + +PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/context.h b/illumos-x86_64/usr/include/python3.13/cpython/context.h new file mode 100644 index 00000000..a3249fc2 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/context.h @@ -0,0 +1,74 @@ +#ifndef Py_LIMITED_API +#ifndef Py_CONTEXT_H +#define Py_CONTEXT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyContext_Type; +typedef struct _pycontextobject PyContext; + +PyAPI_DATA(PyTypeObject) PyContextVar_Type; +typedef struct _pycontextvarobject PyContextVar; + +PyAPI_DATA(PyTypeObject) PyContextToken_Type; +typedef struct _pycontexttokenobject PyContextToken; + + +#define PyContext_CheckExact(o) Py_IS_TYPE((o), &PyContext_Type) +#define PyContextVar_CheckExact(o) Py_IS_TYPE((o), &PyContextVar_Type) +#define PyContextToken_CheckExact(o) Py_IS_TYPE((o), &PyContextToken_Type) + + +PyAPI_FUNC(PyObject *) PyContext_New(void); +PyAPI_FUNC(PyObject *) PyContext_Copy(PyObject *); +PyAPI_FUNC(PyObject *) PyContext_CopyCurrent(void); + +PyAPI_FUNC(int) PyContext_Enter(PyObject *); +PyAPI_FUNC(int) PyContext_Exit(PyObject *); + + +/* Create a new context variable. + + default_value can be NULL. +*/ +PyAPI_FUNC(PyObject *) PyContextVar_New( + const char *name, PyObject *default_value); + + +/* Get a value for the variable. + + Returns -1 if an error occurred during lookup. + + Returns 0 if value either was or was not found. + + If value was found, *value will point to it. + If not, it will point to: + + - default_value, if not NULL; + - the default value of "var", if not NULL; + - NULL. + + '*value' will be a new ref, if not NULL. +*/ +PyAPI_FUNC(int) PyContextVar_Get( + PyObject *var, PyObject *default_value, PyObject **value); + + +/* Set a new value for the variable. + Returns NULL if an error occurs. +*/ +PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value); + + +/* Reset a variable to its previous value. + Returns 0 on success, -1 on error. +*/ +PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CONTEXT_H */ +#endif /* !Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/critical_section.h b/illumos-x86_64/usr/include/python3.13/cpython/critical_section.h new file mode 100644 index 00000000..35db3fb6 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/critical_section.h @@ -0,0 +1,134 @@ +#ifndef Py_CPYTHON_CRITICAL_SECTION_H +# error "this header file must not be included directly" +#endif + +// Python critical sections +// +// Conceptually, critical sections are a deadlock avoidance layer on top of +// per-object locks. These helpers, in combination with those locks, replace +// our usage of the global interpreter lock to provide thread-safety for +// otherwise thread-unsafe objects, such as dict. +// +// NOTE: These APIs are no-ops in non-free-threaded builds. +// +// Straightforward per-object locking could introduce deadlocks that were not +// present when running with the GIL. Threads may hold locks for multiple +// objects simultaneously because Python operations can nest. If threads were +// to acquire the same locks in different orders, they would deadlock. +// +// One way to avoid deadlocks is to allow threads to hold only the lock (or +// locks) for a single operation at a time (typically a single lock, but some +// operations involve two locks). When a thread begins a nested operation it +// could suspend the locks for any outer operation: before beginning the nested +// operation, the locks for the outer operation are released and when the +// nested operation completes, the locks for the outer operation are +// reacquired. +// +// To improve performance, this API uses a variation of the above scheme. +// Instead of immediately suspending locks any time a nested operation begins, +// locks are only suspended if the thread would block. This reduces the number +// of lock acquisitions and releases for nested operations, while still +// avoiding deadlocks. +// +// Additionally, the locks for any active operation are suspended around +// other potentially blocking operations, such as I/O. This is because the +// interaction between locks and blocking operations can lead to deadlocks in +// the same way as the interaction between multiple locks. +// +// Each thread's critical sections and their corresponding locks are tracked in +// a stack in `PyThreadState.critical_section`. When a thread calls +// `_PyThreadState_Detach()`, such as before a blocking I/O operation or when +// waiting to acquire a lock, the thread suspends all of its active critical +// sections, temporarily releasing the associated locks. When the thread calls +// `_PyThreadState_Attach()`, it resumes the top-most (i.e., most recent) +// critical section by reacquiring the associated lock or locks. See +// `_PyCriticalSection_Resume()`. +// +// NOTE: Only the top-most critical section is guaranteed to be active. +// Operations that need to lock two objects at once must use +// `Py_BEGIN_CRITICAL_SECTION2()`. You *CANNOT* use nested critical sections +// to lock more than one object at once, because the inner critical section +// may suspend the outer critical sections. This API does not provide a way +// to lock more than two objects at once (though it could be added later +// if actually needed). +// +// NOTE: Critical sections implicitly behave like reentrant locks because +// attempting to acquire the same lock will suspend any outer (earlier) +// critical sections. However, they are less efficient for this use case than +// purposefully designed reentrant locks. +// +// Example usage: +// Py_BEGIN_CRITICAL_SECTION(op); +// ... +// Py_END_CRITICAL_SECTION(); +// +// To lock two objects at once: +// Py_BEGIN_CRITICAL_SECTION2(op1, op2); +// ... +// Py_END_CRITICAL_SECTION2(); + +typedef struct PyCriticalSection PyCriticalSection; +typedef struct PyCriticalSection2 PyCriticalSection2; + +PyAPI_FUNC(void) +PyCriticalSection_Begin(PyCriticalSection *c, PyObject *op); + +PyAPI_FUNC(void) +PyCriticalSection_End(PyCriticalSection *c); + +PyAPI_FUNC(void) +PyCriticalSection2_Begin(PyCriticalSection2 *c, PyObject *a, PyObject *b); + +PyAPI_FUNC(void) +PyCriticalSection2_End(PyCriticalSection2 *c); + +#ifndef Py_GIL_DISABLED +# define Py_BEGIN_CRITICAL_SECTION(op) \ + { +# define Py_END_CRITICAL_SECTION() \ + } +# define Py_BEGIN_CRITICAL_SECTION2(a, b) \ + { +# define Py_END_CRITICAL_SECTION2() \ + } +#else /* !Py_GIL_DISABLED */ + +// NOTE: the contents of this struct are private and may change betweeen +// Python releases without a deprecation period. +struct PyCriticalSection { + // Tagged pointer to an outer active critical section (or 0). + uintptr_t _cs_prev; + + // Mutex used to protect critical section + PyMutex *_cs_mutex; +}; + +// A critical section protected by two mutexes. Use +// Py_BEGIN_CRITICAL_SECTION2 and Py_END_CRITICAL_SECTION2. +// NOTE: the contents of this struct are private and may change betweeen +// Python releases without a deprecation period. +struct PyCriticalSection2 { + PyCriticalSection _cs_base; + + PyMutex *_cs_mutex2; +}; + +# define Py_BEGIN_CRITICAL_SECTION(op) \ + { \ + PyCriticalSection _py_cs; \ + PyCriticalSection_Begin(&_py_cs, _PyObject_CAST(op)) + +# define Py_END_CRITICAL_SECTION() \ + PyCriticalSection_End(&_py_cs); \ + } + +# define Py_BEGIN_CRITICAL_SECTION2(a, b) \ + { \ + PyCriticalSection2 _py_cs2; \ + PyCriticalSection2_Begin(&_py_cs2, _PyObject_CAST(a), _PyObject_CAST(b)) + +# define Py_END_CRITICAL_SECTION2() \ + PyCriticalSection2_End(&_py_cs2); \ + } + +#endif diff --git a/illumos-x86_64/usr/include/python3.13/cpython/descrobject.h b/illumos-x86_64/usr/include/python3.13/cpython/descrobject.h new file mode 100644 index 00000000..bbad8b59 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/descrobject.h @@ -0,0 +1,62 @@ +#ifndef Py_CPYTHON_DESCROBJECT_H +# error "this header file must not be included directly" +#endif + +typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, + void *wrapped); + +typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, + void *wrapped, PyObject *kwds); + +struct wrapperbase { + const char *name; + int offset; + void *function; + wrapperfunc wrapper; + const char *doc; + int flags; + PyObject *name_strobj; +}; + +/* Flags for above struct */ +#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ + +/* Various kinds of descriptor objects */ + +typedef struct { + PyObject_HEAD + PyTypeObject *d_type; + PyObject *d_name; + PyObject *d_qualname; +} PyDescrObject; + +#define PyDescr_COMMON PyDescrObject d_common + +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) + +typedef struct { + PyDescr_COMMON; + PyMethodDef *d_method; + vectorcallfunc vectorcall; +} PyMethodDescrObject; + +typedef struct { + PyDescr_COMMON; + PyMemberDef *d_member; +} PyMemberDescrObject; + +typedef struct { + PyDescr_COMMON; + PyGetSetDef *d_getset; +} PyGetSetDescrObject; + +typedef struct { + PyDescr_COMMON; + struct wrapperbase *d_base; + void *d_wrapped; /* This can be any function pointer */ +} PyWrapperDescrObject; + +PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, + struct wrapperbase *, void *); +PyAPI_FUNC(int) PyDescr_IsData(PyObject *); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/dictobject.h b/illumos-x86_64/usr/include/python3.13/cpython/dictobject.h new file mode 100644 index 00000000..3fd23b93 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/dictobject.h @@ -0,0 +1,102 @@ +#ifndef Py_CPYTHON_DICTOBJECT_H +# error "this header file must not be included directly" +#endif + +typedef struct _dictkeysobject PyDictKeysObject; +typedef struct _dictvalues PyDictValues; + +/* The ma_values pointer is NULL for a combined table + * or points to an array of PyObject* for a split table + */ +typedef struct { + PyObject_HEAD + + /* Number of items in the dictionary */ + Py_ssize_t ma_used; + + /* Dictionary version: globally unique, value change each time + the dictionary is modified */ +#ifdef Py_BUILD_CORE + /* Bits 0-7 are for dict watchers. + * Bits 8-11 are for the watched mutation counter (used by tier2 optimization) + * The remaining bits (12-63) are the actual version tag. */ + uint64_t ma_version_tag; +#else + Py_DEPRECATED(3.12) uint64_t ma_version_tag; +#endif + + PyDictKeysObject *ma_keys; + + /* If ma_values is NULL, the table is "combined": keys and values + are stored in ma_keys. + + If ma_values is not NULL, the table is split: + keys are stored in ma_keys and values are stored in ma_values */ + PyDictValues *ma_values; +} PyDictObject; + +PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key, + Py_hash_t hash); +PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *); +PyAPI_FUNC(PyObject *) PyDict_SetDefault( + PyObject *mp, PyObject *key, PyObject *defaultobj); + +// Inserts `key` with a value `default_value`, if `key` is not already present +// in the dictionary. If `result` is not NULL, then the value associated +// with `key` is returned in `*result` (either the existing value, or the now +// inserted `default_value`). +// Returns: +// -1 on error +// 0 if `key` was not present and `default_value` was inserted +// 1 if `key` was present and `default_value` was not inserted +PyAPI_FUNC(int) PyDict_SetDefaultRef(PyObject *mp, PyObject *key, PyObject *default_value, PyObject **result); + +/* Get the number of items of a dictionary. */ +static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { + PyDictObject *mp; + assert(PyDict_Check(op)); + mp = _Py_CAST(PyDictObject*, op); +#ifdef Py_GIL_DISABLED + return _Py_atomic_load_ssize_relaxed(&mp->ma_used); +#else + return mp->ma_used; +#endif +} +#define PyDict_GET_SIZE(op) PyDict_GET_SIZE(_PyObject_CAST(op)) + +PyAPI_FUNC(int) PyDict_ContainsString(PyObject *mp, const char *key); + +PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); + +PyAPI_FUNC(int) PyDict_Pop(PyObject *dict, PyObject *key, PyObject **result); +PyAPI_FUNC(int) PyDict_PopString(PyObject *dict, const char *key, PyObject **result); +PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *dict, PyObject *key, PyObject *default_value); + +/* Dictionary watchers */ + +#define PY_FOREACH_DICT_EVENT(V) \ + V(ADDED) \ + V(MODIFIED) \ + V(DELETED) \ + V(CLONED) \ + V(CLEARED) \ + V(DEALLOCATED) + +typedef enum { + #define PY_DEF_EVENT(EVENT) PyDict_EVENT_##EVENT, + PY_FOREACH_DICT_EVENT(PY_DEF_EVENT) + #undef PY_DEF_EVENT +} PyDict_WatchEvent; + +// Callback to be invoked when a watched dict is cleared, dealloced, or modified. +// In clear/dealloc case, key and new_value will be NULL. Otherwise, new_value will be the +// new value for key, NULL if key is being deleted. +typedef int(*PyDict_WatchCallback)(PyDict_WatchEvent event, PyObject* dict, PyObject* key, PyObject* new_value); + +// Register/unregister a dict-watcher callback +PyAPI_FUNC(int) PyDict_AddWatcher(PyDict_WatchCallback callback); +PyAPI_FUNC(int) PyDict_ClearWatcher(int watcher_id); + +// Mark given dictionary as "watched" (callback will be called if it is modified) +PyAPI_FUNC(int) PyDict_Watch(int watcher_id, PyObject* dict); +PyAPI_FUNC(int) PyDict_Unwatch(int watcher_id, PyObject* dict); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/fileobject.h b/illumos-x86_64/usr/include/python3.13/cpython/fileobject.h new file mode 100644 index 00000000..e2d89c52 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/fileobject.h @@ -0,0 +1,16 @@ +#ifndef Py_CPYTHON_FILEOBJECT_H +# error "this header file must not be included directly" +#endif + +PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); + +/* The std printer acts as a preliminary sys.stderr until the new io + infrastructure is in place. */ +PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int); +PyAPI_DATA(PyTypeObject) PyStdPrinter_Type; + +typedef PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *); + +PyAPI_FUNC(PyObject *) PyFile_OpenCode(const char *utf8path); +PyAPI_FUNC(PyObject *) PyFile_OpenCodeObject(PyObject *path); +PyAPI_FUNC(int) PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction hook, void *userData); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/fileutils.h b/illumos-x86_64/usr/include/python3.13/cpython/fileutils.h new file mode 100644 index 00000000..b386ad10 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/fileutils.h @@ -0,0 +1,8 @@ +#ifndef Py_CPYTHON_FILEUTILS_H +# error "this header file must not be included directly" +#endif + +// Used by _testcapi which must not use the internal C API +PyAPI_FUNC(FILE*) _Py_fopen_obj( + PyObject *path, + const char *mode); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/floatobject.h b/illumos-x86_64/usr/include/python3.13/cpython/floatobject.h new file mode 100644 index 00000000..12709309 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/floatobject.h @@ -0,0 +1,27 @@ +#ifndef Py_CPYTHON_FLOATOBJECT_H +# error "this header file must not be included directly" +#endif + +typedef struct { + PyObject_HEAD + double ob_fval; +} PyFloatObject; + +#define _PyFloat_CAST(op) \ + (assert(PyFloat_Check(op)), _Py_CAST(PyFloatObject*, op)) + +// Static inline version of PyFloat_AsDouble() trading safety for speed. +// It doesn't check if op is a double object. +static inline double PyFloat_AS_DOUBLE(PyObject *op) { + return _PyFloat_CAST(op)->ob_fval; +} +#define PyFloat_AS_DOUBLE(op) PyFloat_AS_DOUBLE(_PyObject_CAST(op)) + + +PyAPI_FUNC(int) PyFloat_Pack2(double x, char *p, int le); +PyAPI_FUNC(int) PyFloat_Pack4(double x, char *p, int le); +PyAPI_FUNC(int) PyFloat_Pack8(double x, char *p, int le); + +PyAPI_FUNC(double) PyFloat_Unpack2(const char *p, int le); +PyAPI_FUNC(double) PyFloat_Unpack4(const char *p, int le); +PyAPI_FUNC(double) PyFloat_Unpack8(const char *p, int le); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/frameobject.h b/illumos-x86_64/usr/include/python3.13/cpython/frameobject.h new file mode 100644 index 00000000..dbbfbb51 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/frameobject.h @@ -0,0 +1,35 @@ +/* Frame object interface */ + +#ifndef Py_CPYTHON_FRAMEOBJECT_H +# error "this header file must not be included directly" +#endif + +/* Standard object interface */ + +PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, + PyObject *, PyObject *); + +/* The rest of the interface is specific for frame objects */ + +/* Conversions between "fast locals" and locals in dictionary */ + +PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); + +/* -- Caveat emptor -- + * The concept of entry frames is an implementation detail of the CPython + * interpreter. This API is considered unstable and is provided for the + * convenience of debuggers, profilers and state-inspecting tools. Notice that + * this API can be changed in future minor versions if the underlying frame + * mechanism change or the concept of an 'entry frame' or its semantics becomes + * obsolete or outdated. */ + +PyAPI_FUNC(int) _PyFrame_IsEntryFrame(PyFrameObject *frame); + +PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f); +PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); + + +typedef struct { + PyObject_HEAD + PyFrameObject* frame; +} PyFrameLocalsProxyObject; diff --git a/illumos-x86_64/usr/include/python3.13/cpython/funcobject.h b/illumos-x86_64/usr/include/python3.13/cpython/funcobject.h new file mode 100644 index 00000000..5433ba48 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/funcobject.h @@ -0,0 +1,184 @@ +/* Function object interface */ + +#ifndef Py_LIMITED_API +#ifndef Py_FUNCOBJECT_H +#define Py_FUNCOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +#define _Py_COMMON_FIELDS(PREFIX) \ + PyObject *PREFIX ## globals; \ + PyObject *PREFIX ## builtins; \ + PyObject *PREFIX ## name; \ + PyObject *PREFIX ## qualname; \ + PyObject *PREFIX ## code; /* A code object, the __code__ attribute */ \ + PyObject *PREFIX ## defaults; /* NULL or a tuple */ \ + PyObject *PREFIX ## kwdefaults; /* NULL or a dict */ \ + PyObject *PREFIX ## closure; /* NULL or a tuple of cell objects */ + +typedef struct { + _Py_COMMON_FIELDS(fc_) +} PyFrameConstructor; + +/* Function objects and code objects should not be confused with each other: + * + * Function objects are created by the execution of the 'def' statement. + * They reference a code object in their __code__ attribute, which is a + * purely syntactic object, i.e. nothing more than a compiled version of some + * source code lines. There is one code object per source code "fragment", + * but each code object can be referenced by zero or many function objects + * depending only on how many times the 'def' statement in the source was + * executed so far. + */ + +typedef struct { + PyObject_HEAD + _Py_COMMON_FIELDS(func_) + PyObject *func_doc; /* The __doc__ attribute, can be anything */ + PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */ + PyObject *func_weakreflist; /* List of weak references */ + PyObject *func_module; /* The __module__ attribute, can be anything */ + PyObject *func_annotations; /* Annotations, a dict or NULL */ + PyObject *func_typeparams; /* Tuple of active type variables or NULL */ + vectorcallfunc vectorcall; + /* Version number for use by specializer. + * Can set to non-zero when we want to specialize. + * Will be set to zero if any of these change: + * defaults + * kwdefaults (only if the object changes, not the contents of the dict) + * code + * annotations + * vectorcall function pointer */ + uint32_t func_version; + + /* Invariant: + * func_closure contains the bindings for func_code->co_freevars, so + * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code) + * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0). + */ +} PyFunctionObject; + +#undef _Py_COMMON_FIELDS + +PyAPI_DATA(PyTypeObject) PyFunction_Type; + +#define PyFunction_Check(op) Py_IS_TYPE((op), &PyFunction_Type) + +PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); +PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); +PyAPI_FUNC(void) PyFunction_SetVectorcall(PyFunctionObject *, vectorcallfunc); +PyAPI_FUNC(PyObject *) PyFunction_GetKwDefaults(PyObject *); +PyAPI_FUNC(int) PyFunction_SetKwDefaults(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); +PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *); +PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *); + +#define _PyFunction_CAST(func) \ + (assert(PyFunction_Check(func)), _Py_CAST(PyFunctionObject*, func)) + +/* Static inline functions for direct access to these values. + Type checks are *not* done, so use with care. */ +static inline PyObject* PyFunction_GET_CODE(PyObject *func) { + return _PyFunction_CAST(func)->func_code; +} +#define PyFunction_GET_CODE(func) PyFunction_GET_CODE(_PyObject_CAST(func)) + +static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) { + return _PyFunction_CAST(func)->func_globals; +} +#define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func)) + +static inline PyObject* PyFunction_GET_MODULE(PyObject *func) { + return _PyFunction_CAST(func)->func_module; +} +#define PyFunction_GET_MODULE(func) PyFunction_GET_MODULE(_PyObject_CAST(func)) + +static inline PyObject* PyFunction_GET_DEFAULTS(PyObject *func) { + return _PyFunction_CAST(func)->func_defaults; +} +#define PyFunction_GET_DEFAULTS(func) PyFunction_GET_DEFAULTS(_PyObject_CAST(func)) + +static inline PyObject* PyFunction_GET_KW_DEFAULTS(PyObject *func) { + return _PyFunction_CAST(func)->func_kwdefaults; +} +#define PyFunction_GET_KW_DEFAULTS(func) PyFunction_GET_KW_DEFAULTS(_PyObject_CAST(func)) + +static inline PyObject* PyFunction_GET_CLOSURE(PyObject *func) { + return _PyFunction_CAST(func)->func_closure; +} +#define PyFunction_GET_CLOSURE(func) PyFunction_GET_CLOSURE(_PyObject_CAST(func)) + +static inline PyObject* PyFunction_GET_ANNOTATIONS(PyObject *func) { + return _PyFunction_CAST(func)->func_annotations; +} +#define PyFunction_GET_ANNOTATIONS(func) PyFunction_GET_ANNOTATIONS(_PyObject_CAST(func)) + +/* The classmethod and staticmethod types lives here, too */ +PyAPI_DATA(PyTypeObject) PyClassMethod_Type; +PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; + +PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); +PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); + +#define PY_FOREACH_FUNC_EVENT(V) \ + V(CREATE) \ + V(DESTROY) \ + V(MODIFY_CODE) \ + V(MODIFY_DEFAULTS) \ + V(MODIFY_KWDEFAULTS) + +typedef enum { + #define PY_DEF_EVENT(EVENT) PyFunction_EVENT_##EVENT, + PY_FOREACH_FUNC_EVENT(PY_DEF_EVENT) + #undef PY_DEF_EVENT +} PyFunction_WatchEvent; + +/* + * A callback that is invoked for different events in a function's lifecycle. + * + * The callback is invoked with a borrowed reference to func, after it is + * created and before it is modified or destroyed. The callback should not + * modify func. + * + * When a function's code object, defaults, or kwdefaults are modified the + * callback will be invoked with the respective event and new_value will + * contain a borrowed reference to the new value that is about to be stored in + * the function. Otherwise the third argument is NULL. + * + * If the callback returns with an exception set, it must return -1. Otherwise + * it should return 0. + */ +typedef int (*PyFunction_WatchCallback)( + PyFunction_WatchEvent event, + PyFunctionObject *func, + PyObject *new_value); + +/* + * Register a per-interpreter callback that will be invoked for function lifecycle + * events. + * + * Returns a handle that may be passed to PyFunction_ClearWatcher on success, + * or -1 and sets an error if no more handles are available. + */ +PyAPI_FUNC(int) PyFunction_AddWatcher(PyFunction_WatchCallback callback); + +/* + * Clear the watcher associated with the watcher_id handle. + * + * Returns 0 on success or -1 if no watcher exists for the supplied id. + */ +PyAPI_FUNC(int) PyFunction_ClearWatcher(int watcher_id); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FUNCOBJECT_H */ +#endif /* Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/genobject.h b/illumos-x86_64/usr/include/python3.13/cpython/genobject.h new file mode 100644 index 00000000..49e46c27 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/genobject.h @@ -0,0 +1,83 @@ +/* Generator object interface */ + +#ifndef Py_LIMITED_API +#ifndef Py_GENOBJECT_H +#define Py_GENOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* --- Generators --------------------------------------------------------- */ + +/* _PyGenObject_HEAD defines the initial segment of generator + and coroutine objects. */ +#define _PyGenObject_HEAD(prefix) \ + PyObject_HEAD \ + /* List of weak reference. */ \ + PyObject *prefix##_weakreflist; \ + /* Name of the generator. */ \ + PyObject *prefix##_name; \ + /* Qualified name of the generator. */ \ + PyObject *prefix##_qualname; \ + _PyErr_StackItem prefix##_exc_state; \ + PyObject *prefix##_origin_or_finalizer; \ + char prefix##_hooks_inited; \ + char prefix##_closed; \ + char prefix##_running_async; \ + /* The frame */ \ + int8_t prefix##_frame_state; \ + PyObject *prefix##_iframe[1]; \ + +typedef struct { + /* The gi_ prefix is intended to remind of generator-iterator. */ + _PyGenObject_HEAD(gi) +} PyGenObject; + +PyAPI_DATA(PyTypeObject) PyGen_Type; + +#define PyGen_Check(op) PyObject_TypeCheck((op), &PyGen_Type) +#define PyGen_CheckExact(op) Py_IS_TYPE((op), &PyGen_Type) + +PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *); +PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *, + PyObject *name, PyObject *qualname); +PyAPI_FUNC(PyCodeObject *) PyGen_GetCode(PyGenObject *gen); + + +/* --- PyCoroObject ------------------------------------------------------- */ + +typedef struct { + _PyGenObject_HEAD(cr) +} PyCoroObject; + +PyAPI_DATA(PyTypeObject) PyCoro_Type; + +#define PyCoro_CheckExact(op) Py_IS_TYPE((op), &PyCoro_Type) +PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *, + PyObject *name, PyObject *qualname); + + +/* --- Asynchronous Generators -------------------------------------------- */ + +typedef struct { + _PyGenObject_HEAD(ag) +} PyAsyncGenObject; + +PyAPI_DATA(PyTypeObject) PyAsyncGen_Type; +PyAPI_DATA(PyTypeObject) _PyAsyncGenASend_Type; + +PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *, + PyObject *name, PyObject *qualname); + +#define PyAsyncGen_CheckExact(op) Py_IS_TYPE((op), &PyAsyncGen_Type) + +#define PyAsyncGenASend_CheckExact(op) Py_IS_TYPE((op), &_PyAsyncGenASend_Type) + + +#undef _PyGenObject_HEAD + +#ifdef __cplusplus +} +#endif +#endif /* !Py_GENOBJECT_H */ +#endif /* Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/import.h b/illumos-x86_64/usr/include/python3.13/cpython/import.h new file mode 100644 index 00000000..7daf0b84 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/import.h @@ -0,0 +1,25 @@ +#ifndef Py_CPYTHON_IMPORT_H +# error "this header file must not be included directly" +#endif + +PyMODINIT_FUNC PyInit__imp(void); + +struct _inittab { + const char *name; /* ASCII encoded string */ + PyObject* (*initfunc)(void); +}; +// This is not used after Py_Initialize() is called. +PyAPI_DATA(struct _inittab *) PyImport_Inittab; +PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); + +struct _frozen { + const char *name; /* ASCII encoded string */ + const unsigned char *code; + int size; + int is_package; +}; + +/* Embedding apps may change this pointer to point to their favorite + collection of frozen modules: */ + +PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules; diff --git a/illumos-x86_64/usr/include/python3.13/cpython/initconfig.h b/illumos-x86_64/usr/include/python3.13/cpython/initconfig.h new file mode 100644 index 00000000..5da5ef9e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/initconfig.h @@ -0,0 +1,274 @@ +#ifndef Py_PYCORECONFIG_H +#define Py_PYCORECONFIG_H +#ifndef Py_LIMITED_API +#ifdef __cplusplus +extern "C" { +#endif + +/* --- PyStatus ----------------------------------------------- */ + +typedef struct { + enum { + _PyStatus_TYPE_OK=0, + _PyStatus_TYPE_ERROR=1, + _PyStatus_TYPE_EXIT=2 + } _type; + const char *func; + const char *err_msg; + int exitcode; +} PyStatus; + +PyAPI_FUNC(PyStatus) PyStatus_Ok(void); +PyAPI_FUNC(PyStatus) PyStatus_Error(const char *err_msg); +PyAPI_FUNC(PyStatus) PyStatus_NoMemory(void); +PyAPI_FUNC(PyStatus) PyStatus_Exit(int exitcode); +PyAPI_FUNC(int) PyStatus_IsError(PyStatus err); +PyAPI_FUNC(int) PyStatus_IsExit(PyStatus err); +PyAPI_FUNC(int) PyStatus_Exception(PyStatus err); + +/* --- PyWideStringList ------------------------------------------------ */ + +typedef struct { + /* If length is greater than zero, items must be non-NULL + and all items strings must be non-NULL */ + Py_ssize_t length; + wchar_t **items; +} PyWideStringList; + +PyAPI_FUNC(PyStatus) PyWideStringList_Append(PyWideStringList *list, + const wchar_t *item); +PyAPI_FUNC(PyStatus) PyWideStringList_Insert(PyWideStringList *list, + Py_ssize_t index, + const wchar_t *item); + + +/* --- PyPreConfig ----------------------------------------------- */ + +typedef struct PyPreConfig { + int _config_init; /* _PyConfigInitEnum value */ + + /* Parse Py_PreInitializeFromBytesArgs() arguments? + See PyConfig.parse_argv */ + int parse_argv; + + /* If greater than 0, enable isolated mode: sys.path contains + neither the script's directory nor the user's site-packages directory. + + Set to 1 by the -I command line option. If set to -1 (default), inherit + Py_IsolatedFlag value. */ + int isolated; + + /* If greater than 0: use environment variables. + Set to 0 by -E command line option. If set to -1 (default), it is + set to !Py_IgnoreEnvironmentFlag. */ + int use_environment; + + /* Set the LC_CTYPE locale to the user preferred locale? If equals to 0, + set coerce_c_locale and coerce_c_locale_warn to 0. */ + int configure_locale; + + /* Coerce the LC_CTYPE locale if it's equal to "C"? (PEP 538) + + Set to 0 by PYTHONCOERCECLOCALE=0. Set to 1 by PYTHONCOERCECLOCALE=1. + Set to 2 if the user preferred LC_CTYPE locale is "C". + + If it is equal to 1, LC_CTYPE locale is read to decide if it should be + coerced or not (ex: PYTHONCOERCECLOCALE=1). Internally, it is set to 2 + if the LC_CTYPE locale must be coerced. + + Disable by default (set to 0). Set it to -1 to let Python decide if it + should be enabled or not. */ + int coerce_c_locale; + + /* Emit a warning if the LC_CTYPE locale is coerced? + + Set to 1 by PYTHONCOERCECLOCALE=warn. + + Disable by default (set to 0). Set it to -1 to let Python decide if it + should be enabled or not. */ + int coerce_c_locale_warn; + +#ifdef MS_WINDOWS + /* If greater than 1, use the "mbcs" encoding instead of the UTF-8 + encoding for the filesystem encoding. + + Set to 1 if the PYTHONLEGACYWINDOWSFSENCODING environment variable is + set to a non-empty string. If set to -1 (default), inherit + Py_LegacyWindowsFSEncodingFlag value. + + See PEP 529 for more details. */ + int legacy_windows_fs_encoding; +#endif + + /* Enable UTF-8 mode? (PEP 540) + + Disabled by default (equals to 0). + + Set to 1 by "-X utf8" and "-X utf8=1" command line options. + Set to 1 by PYTHONUTF8=1 environment variable. + + Set to 0 by "-X utf8=0" and PYTHONUTF8=0. + + If equals to -1, it is set to 1 if the LC_CTYPE locale is "C" or + "POSIX", otherwise it is set to 0. Inherit Py_UTF8Mode value value. */ + int utf8_mode; + + /* If non-zero, enable the Python Development Mode. + + Set to 1 by the -X dev command line option. Set by the PYTHONDEVMODE + environment variable. */ + int dev_mode; + + /* Memory allocator: PYTHONMALLOC env var. + See PyMemAllocatorName for valid values. */ + int allocator; +} PyPreConfig; + +PyAPI_FUNC(void) PyPreConfig_InitPythonConfig(PyPreConfig *config); +PyAPI_FUNC(void) PyPreConfig_InitIsolatedConfig(PyPreConfig *config); + + +/* --- PyConfig ---------------------------------------------- */ + +/* This structure is best documented in the Doc/c-api/init_config.rst file. */ +typedef struct PyConfig { + int _config_init; /* _PyConfigInitEnum value */ + + int isolated; + int use_environment; + int dev_mode; + int install_signal_handlers; + int use_hash_seed; + unsigned long hash_seed; + int faulthandler; + int tracemalloc; + int perf_profiling; + int import_time; + int code_debug_ranges; + int show_ref_count; + int dump_refs; + wchar_t *dump_refs_file; + int malloc_stats; + wchar_t *filesystem_encoding; + wchar_t *filesystem_errors; + wchar_t *pycache_prefix; + int parse_argv; + PyWideStringList orig_argv; + PyWideStringList argv; + PyWideStringList xoptions; + PyWideStringList warnoptions; + int site_import; + int bytes_warning; + int warn_default_encoding; + int inspect; + int interactive; + int optimization_level; + int parser_debug; + int write_bytecode; + int verbose; + int quiet; + int user_site_directory; + int configure_c_stdio; + int buffered_stdio; + wchar_t *stdio_encoding; + wchar_t *stdio_errors; +#ifdef MS_WINDOWS + int legacy_windows_stdio; +#endif + wchar_t *check_hash_pycs_mode; + int use_frozen_modules; + int safe_path; + int int_max_str_digits; + + int cpu_count; +#ifdef Py_GIL_DISABLED + int enable_gil; +#endif + + /* --- Path configuration inputs ------------ */ + int pathconfig_warnings; + wchar_t *program_name; + wchar_t *pythonpath_env; + wchar_t *home; + wchar_t *platlibdir; + + /* --- Path configuration outputs ----------- */ + int module_search_paths_set; + PyWideStringList module_search_paths; + wchar_t *stdlib_dir; + wchar_t *executable; + wchar_t *base_executable; + wchar_t *prefix; + wchar_t *base_prefix; + wchar_t *exec_prefix; + wchar_t *base_exec_prefix; + + /* --- Parameter only used by Py_Main() ---------- */ + int skip_source_first_line; + wchar_t *run_command; + wchar_t *run_module; + wchar_t *run_filename; + + /* --- Set by Py_Main() -------------------------- */ + wchar_t *sys_path_0; + + /* --- Private fields ---------------------------- */ + + // Install importlib? If equals to 0, importlib is not initialized at all. + // Needed by freeze_importlib. + int _install_importlib; + + // If equal to 0, stop Python initialization before the "main" phase. + int _init_main; + + // If non-zero, we believe we're running from a source tree. + int _is_python_build; + +#ifdef Py_STATS + // If non-zero, turns on statistics gathering. + int _pystats; +#endif + +#ifdef Py_DEBUG + // If not empty, import a non-__main__ module before site.py is executed. + // PYTHON_PRESITE=package.module or -X presite=package.module + wchar_t *run_presite; +#endif +} PyConfig; + +PyAPI_FUNC(void) PyConfig_InitPythonConfig(PyConfig *config); +PyAPI_FUNC(void) PyConfig_InitIsolatedConfig(PyConfig *config); +PyAPI_FUNC(void) PyConfig_Clear(PyConfig *); +PyAPI_FUNC(PyStatus) PyConfig_SetString( + PyConfig *config, + wchar_t **config_str, + const wchar_t *str); +PyAPI_FUNC(PyStatus) PyConfig_SetBytesString( + PyConfig *config, + wchar_t **config_str, + const char *str); +PyAPI_FUNC(PyStatus) PyConfig_Read(PyConfig *config); +PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv( + PyConfig *config, + Py_ssize_t argc, + char * const *argv); +PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config, + Py_ssize_t argc, + wchar_t * const *argv); +PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config, + PyWideStringList *list, + Py_ssize_t length, wchar_t **items); + + +/* --- Helper functions --------------------------------------- */ + +/* Get the original command line arguments, before Python modified them. + + See also PyConfig.orig_argv. */ +PyAPI_FUNC(void) Py_GetArgcArgv(int *argc, wchar_t ***argv); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LIMITED_API */ +#endif /* !Py_PYCORECONFIG_H */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/listobject.h b/illumos-x86_64/usr/include/python3.13/cpython/listobject.h new file mode 100644 index 00000000..49f5e8d6 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/listobject.h @@ -0,0 +1,53 @@ +#ifndef Py_CPYTHON_LISTOBJECT_H +# error "this header file must not be included directly" +#endif + +typedef struct { + PyObject_VAR_HEAD + /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ + PyObject **ob_item; + + /* ob_item contains space for 'allocated' elements. The number + * currently in use is ob_size. + * Invariants: + * 0 <= ob_size <= allocated + * len(list) == ob_size + * ob_item == NULL implies ob_size == allocated == 0 + * list.sort() temporarily sets allocated to -1 to detect mutations. + * + * Items must normally not be NULL, except during construction when + * the list is not yet visible outside the function that builds it. + */ + Py_ssize_t allocated; +} PyListObject; + +/* Cast argument to PyListObject* type. */ +#define _PyList_CAST(op) \ + (assert(PyList_Check(op)), _Py_CAST(PyListObject*, (op))) + +// Macros and static inline functions, trading safety for speed + +static inline Py_ssize_t PyList_GET_SIZE(PyObject *op) { + PyListObject *list = _PyList_CAST(op); +#ifdef Py_GIL_DISABLED + return _Py_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(list)->ob_size)); +#else + return Py_SIZE(list); +#endif +} +#define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyObject_CAST(op)) + +#define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[(index)]) + +static inline void +PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { + PyListObject *list = _PyList_CAST(op); + assert(0 <= index); + assert(index < list->allocated); + list->ob_item[index] = value; +} +#define PyList_SET_ITEM(op, index, value) \ + PyList_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value)) + +PyAPI_FUNC(int) PyList_Extend(PyObject *self, PyObject *iterable); +PyAPI_FUNC(int) PyList_Clear(PyObject *self); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/lock.h b/illumos-x86_64/usr/include/python3.13/cpython/lock.h new file mode 100644 index 00000000..8ee03e82 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/lock.h @@ -0,0 +1,63 @@ +#ifndef Py_CPYTHON_LOCK_H +# error "this header file must not be included directly" +#endif + +#define _Py_UNLOCKED 0 +#define _Py_LOCKED 1 + +// A mutex that occupies one byte. The lock can be zero initialized to +// represent the unlocked state. +// +// Typical initialization: +// PyMutex m = (PyMutex){0}; +// +// Or initialize as global variables: +// static PyMutex m; +// +// Typical usage: +// PyMutex_Lock(&m); +// ... +// PyMutex_Unlock(&m); +// +// The contents of the PyMutex are not part of the public API, but are +// described to aid in understanding the implementation and debugging. Only +// the two least significant bits are used. The remaining bits are always zero: +// 0b00: unlocked +// 0b01: locked +// 0b10: unlocked and has parked threads +// 0b11: locked and has parked threads +typedef struct PyMutex { + uint8_t _bits; // (private) +} PyMutex; + +// exported function for locking the mutex +PyAPI_FUNC(void) PyMutex_Lock(PyMutex *m); + +// exported function for unlocking the mutex +PyAPI_FUNC(void) PyMutex_Unlock(PyMutex *m); + +// Locks the mutex. +// +// If the mutex is currently locked, the calling thread will be parked until +// the mutex is unlocked. If the current thread holds the GIL, then the GIL +// will be released while the thread is parked. +static inline void +_PyMutex_Lock(PyMutex *m) +{ + uint8_t expected = _Py_UNLOCKED; + if (!_Py_atomic_compare_exchange_uint8(&m->_bits, &expected, _Py_LOCKED)) { + PyMutex_Lock(m); + } +} +#define PyMutex_Lock _PyMutex_Lock + +// Unlocks the mutex. +static inline void +_PyMutex_Unlock(PyMutex *m) +{ + uint8_t expected = _Py_LOCKED; + if (!_Py_atomic_compare_exchange_uint8(&m->_bits, &expected, _Py_UNLOCKED)) { + PyMutex_Unlock(m); + } +} +#define PyMutex_Unlock _PyMutex_Unlock diff --git a/illumos-x86_64/usr/include/python3.13/cpython/longintrepr.h b/illumos-x86_64/usr/include/python3.13/cpython/longintrepr.h new file mode 100644 index 00000000..3246908b --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/longintrepr.h @@ -0,0 +1,146 @@ +#ifndef Py_LIMITED_API +#ifndef Py_LONGINTREPR_H +#define Py_LONGINTREPR_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* This is published for the benefit of "friends" marshal.c and _decimal.c. */ + +/* Parameters of the integer representation. There are two different + sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit + integer type, and one set for 15-bit digits with each digit stored in an + unsigned short. The value of PYLONG_BITS_IN_DIGIT, defined either at + configure time or in pyport.h, is used to decide which digit size to use. + + Type 'digit' should be able to hold 2*PyLong_BASE-1, and type 'twodigits' + should be an unsigned integer type able to hold all integers up to + PyLong_BASE*PyLong_BASE-1. x_sub assumes that 'digit' is an unsigned type, + and that overflow is handled by taking the result modulo 2**N for some N > + PyLong_SHIFT. The majority of the code doesn't care about the precise + value of PyLong_SHIFT, but there are some notable exceptions: + + - PyLong_{As,From}ByteArray require that PyLong_SHIFT be at least 8 + + - long_hash() requires that PyLong_SHIFT is *strictly* less than the number + of bits in an unsigned long, as do the PyLong <-> long (or unsigned long) + conversion functions + + - the Python int <-> size_t/Py_ssize_t conversion functions expect that + PyLong_SHIFT is strictly less than the number of bits in a size_t + + - the marshal code currently expects that PyLong_SHIFT is a multiple of 15 + + - NSMALLNEGINTS and NSMALLPOSINTS should be small enough to fit in a single + digit; with the current values this forces PyLong_SHIFT >= 9 + + The values 15 and 30 should fit all of the above requirements, on any + platform. +*/ + +#if PYLONG_BITS_IN_DIGIT == 30 +typedef uint32_t digit; +typedef int32_t sdigit; /* signed variant of digit */ +typedef uint64_t twodigits; +typedef int64_t stwodigits; /* signed variant of twodigits */ +#define PyLong_SHIFT 30 +#define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */ +#elif PYLONG_BITS_IN_DIGIT == 15 +typedef unsigned short digit; +typedef short sdigit; /* signed variant of digit */ +typedef unsigned long twodigits; +typedef long stwodigits; /* signed variant of twodigits */ +#define PyLong_SHIFT 15 +#define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */ +#else +#error "PYLONG_BITS_IN_DIGIT should be 15 or 30" +#endif +#define PyLong_BASE ((digit)1 << PyLong_SHIFT) +#define PyLong_MASK ((digit)(PyLong_BASE - 1)) + +/* Long integer representation. + + Long integers are made up of a number of 30- or 15-bit digits, depending on + the platform. The number of digits (ndigits) is stored in the high bits of + the lv_tag field (lvtag >> _PyLong_NON_SIZE_BITS). + + The absolute value of a number is equal to + SUM(for i=0 through ndigits-1) ob_digit[i] * 2**(PyLong_SHIFT*i) + + The sign of the value is stored in the lower 2 bits of lv_tag. + + - 0: Positive + - 1: Zero + - 2: Negative + + The third lowest bit of lv_tag is reserved for an immortality flag, but is + not currently used. + + In a normalized number, ob_digit[ndigits-1] (the most significant + digit) is never zero. Also, in all cases, for all valid i, + 0 <= ob_digit[i] <= PyLong_MASK. + + The allocation function takes care of allocating extra memory + so that ob_digit[0] ... ob_digit[ndigits-1] are actually available. + We always allocate memory for at least one digit, so accessing ob_digit[0] + is always safe. However, in the case ndigits == 0, the contents of + ob_digit[0] may be undefined. +*/ + +typedef struct _PyLongValue { + uintptr_t lv_tag; /* Number of digits, sign and flags */ + digit ob_digit[1]; +} _PyLongValue; + +struct _longobject { + PyObject_HEAD + _PyLongValue long_value; +}; + +PyAPI_FUNC(PyLongObject*) _PyLong_New(Py_ssize_t); + +// Return a copy of src. +PyAPI_FUNC(PyObject*) _PyLong_Copy(PyLongObject *src); + +PyAPI_FUNC(PyLongObject*) _PyLong_FromDigits( + int negative, + Py_ssize_t digit_count, + digit *digits); + + +/* Inline some internals for speed. These should be in pycore_long.h + * if user code didn't need them inlined. */ + +#define _PyLong_SIGN_MASK 3 +#define _PyLong_NON_SIZE_BITS 3 + + +static inline int +_PyLong_IsCompact(const PyLongObject* op) { + assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS)); + return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS); +} + +#define PyUnstable_Long_IsCompact _PyLong_IsCompact + +static inline Py_ssize_t +_PyLong_CompactValue(const PyLongObject *op) +{ + Py_ssize_t sign; + assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS)); + assert(PyUnstable_Long_IsCompact(op)); + sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK); + return sign * (Py_ssize_t)op->long_value.ob_digit[0]; +} + +#define PyUnstable_Long_CompactValue _PyLong_CompactValue + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LONGINTREPR_H */ +#endif /* Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/longobject.h b/illumos-x86_64/usr/include/python3.13/cpython/longobject.h new file mode 100644 index 00000000..0d49242f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/longobject.h @@ -0,0 +1,116 @@ +#ifndef Py_CPYTHON_LONGOBJECT_H +# error "this header file must not be included directly" +#endif + +PyAPI_FUNC(PyObject*) PyLong_FromUnicodeObject(PyObject *u, int base); + +#define Py_ASNATIVEBYTES_DEFAULTS -1 +#define Py_ASNATIVEBYTES_BIG_ENDIAN 0 +#define Py_ASNATIVEBYTES_LITTLE_ENDIAN 1 +#define Py_ASNATIVEBYTES_NATIVE_ENDIAN 3 +#define Py_ASNATIVEBYTES_UNSIGNED_BUFFER 4 +#define Py_ASNATIVEBYTES_REJECT_NEGATIVE 8 +#define Py_ASNATIVEBYTES_ALLOW_INDEX 16 + +/* PyLong_AsNativeBytes: Copy the integer value to a native variable. + buffer points to the first byte of the variable. + n_bytes is the number of bytes available in the buffer. Pass 0 to request + the required size for the value. + flags is a bitfield of the following flags: + * 1 - little endian + * 2 - native endian + * 4 - unsigned destination (e.g. don't reject copying 255 into one byte) + * 8 - raise an exception for negative inputs + * 16 - call __index__ on non-int types + If flags is -1 (all bits set), native endian is used, value truncation + behaves most like C (allows negative inputs and allow MSB set), and non-int + objects will raise a TypeError. + Big endian mode will write the most significant byte into the address + directly referenced by buffer; little endian will write the least significant + byte into that address. + + If an exception is raised, returns a negative value. + Otherwise, returns the number of bytes that are required to store the value. + To check that the full value is represented, ensure that the return value is + equal or less than n_bytes. + All n_bytes are guaranteed to be written (unless an exception occurs), and + so ignoring a positive return value is the equivalent of a downcast in C. + In cases where the full value could not be represented, the returned value + may be larger than necessary - this function is not an accurate way to + calculate the bit length of an integer object. + */ +PyAPI_FUNC(Py_ssize_t) PyLong_AsNativeBytes(PyObject* v, void* buffer, + Py_ssize_t n_bytes, int flags); + +/* PyLong_FromNativeBytes: Create an int value from a native integer + n_bytes is the number of bytes to read from the buffer. Passing 0 will + always produce the zero int. + PyLong_FromUnsignedNativeBytes always produces a non-negative int. + flags is the same as for PyLong_AsNativeBytes, but only supports selecting + the endianness or forcing an unsigned buffer. + + Returns the int object, or NULL with an exception set. */ +PyAPI_FUNC(PyObject*) PyLong_FromNativeBytes(const void* buffer, size_t n_bytes, + int flags); +PyAPI_FUNC(PyObject*) PyLong_FromUnsignedNativeBytes(const void* buffer, + size_t n_bytes, int flags); + +PyAPI_FUNC(int) PyUnstable_Long_IsCompact(const PyLongObject* op); +PyAPI_FUNC(Py_ssize_t) PyUnstable_Long_CompactValue(const PyLongObject* op); + +// _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0. +// v must not be NULL, and must be a normalized long. +// There are no error cases. +PyAPI_FUNC(int) _PyLong_Sign(PyObject *v); + +/* _PyLong_NumBits. Return the number of bits needed to represent the + absolute value of a long. For example, this returns 1 for 1 and -1, 2 + for 2 and -2, and 2 for 3 and -3. It returns 0 for 0. + v must not be NULL, and must be a normalized long. + (size_t)-1 is returned and OverflowError set if the true result doesn't + fit in a size_t. +*/ +PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); + +/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in + base 256, and return a Python int with the same numeric value. + If n is 0, the integer is 0. Else: + If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB; + else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the + LSB. + If is_signed is 0/false, view the bytes as a non-negative integer. + If is_signed is 1/true, view the bytes as a 2's-complement integer, + non-negative if bit 0x80 of the MSB is clear, negative if set. + Error returns: + + Return NULL with the appropriate exception set if there's not + enough memory to create the Python int. +*/ +PyAPI_FUNC(PyObject *) _PyLong_FromByteArray( + const unsigned char* bytes, size_t n, + int little_endian, int is_signed); + +/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long + v to a base-256 integer, stored in array bytes. Normally return 0, + return -1 on error. + If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at + bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and + the LSB at bytes[n-1]. + If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes + are filled and there's nothing special about bit 0x80 of the MSB. + If is_signed is 1/true, bytes is filled with the 2's-complement + representation of v's value. Bit 0x80 of the MSB is the sign bit. + Error returns (-1): + + is_signed is 0 and v < 0. TypeError is set in this case, and bytes + isn't altered. + + n isn't big enough to hold the full mathematical value of v. For + example, if is_signed is 0 and there are more digits in the v than + fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of + being large enough to hold a sign bit. OverflowError is set in this + case, but bytes holds the least-significant n bytes of the true value. +*/ +PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, + unsigned char* bytes, size_t n, + int little_endian, int is_signed, int with_exceptions); + +/* For use by the gcd function in mathmodule.c */ +PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/memoryobject.h b/illumos-x86_64/usr/include/python3.13/cpython/memoryobject.h new file mode 100644 index 00000000..961161b7 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/memoryobject.h @@ -0,0 +1,50 @@ +#ifndef Py_CPYTHON_MEMORYOBJECT_H +# error "this header file must not be included directly" +#endif + +/* The structs are declared here so that macros can work, but they shouldn't + be considered public. Don't access their fields directly, use the macros + and functions instead! */ +#define _Py_MANAGED_BUFFER_RELEASED 0x001 /* access to exporter blocked */ +#define _Py_MANAGED_BUFFER_FREE_FORMAT 0x002 /* free format */ + +typedef struct { + PyObject_HEAD + int flags; /* state flags */ + Py_ssize_t exports; /* number of direct memoryview exports */ + Py_buffer master; /* snapshot buffer obtained from the original exporter */ +} _PyManagedBufferObject; + + +/* memoryview state flags */ +#define _Py_MEMORYVIEW_RELEASED 0x001 /* access to master buffer blocked */ +#define _Py_MEMORYVIEW_C 0x002 /* C-contiguous layout */ +#define _Py_MEMORYVIEW_FORTRAN 0x004 /* Fortran contiguous layout */ +#define _Py_MEMORYVIEW_SCALAR 0x008 /* scalar: ndim = 0 */ +#define _Py_MEMORYVIEW_PIL 0x010 /* PIL-style layout */ +#define _Py_MEMORYVIEW_RESTRICTED 0x020 /* Disallow new references to the memoryview's buffer */ + +typedef struct { + PyObject_VAR_HEAD + _PyManagedBufferObject *mbuf; /* managed buffer */ + Py_hash_t hash; /* hash value for read-only views */ + int flags; /* state flags */ + Py_ssize_t exports; /* number of buffer re-exports */ + Py_buffer view; /* private copy of the exporter's view */ + PyObject *weakreflist; + Py_ssize_t ob_array[1]; /* shape, strides, suboffsets */ +} PyMemoryViewObject; + +#define _PyMemoryView_CAST(op) _Py_CAST(PyMemoryViewObject*, op) + +/* Get a pointer to the memoryview's private copy of the exporter's buffer. */ +static inline Py_buffer* PyMemoryView_GET_BUFFER(PyObject *op) { + return (&_PyMemoryView_CAST(op)->view); +} +#define PyMemoryView_GET_BUFFER(op) PyMemoryView_GET_BUFFER(_PyObject_CAST(op)) + +/* Get a pointer to the exporting object (this may be NULL!). */ +static inline PyObject* PyMemoryView_GET_BASE(PyObject *op) { + return _PyMemoryView_CAST(op)->view.obj; +} +#define PyMemoryView_GET_BASE(op) PyMemoryView_GET_BASE(_PyObject_CAST(op)) diff --git a/illumos-x86_64/usr/include/python3.13/cpython/methodobject.h b/illumos-x86_64/usr/include/python3.13/cpython/methodobject.h new file mode 100644 index 00000000..d541e154 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/methodobject.h @@ -0,0 +1,66 @@ +#ifndef Py_CPYTHON_METHODOBJECT_H +# error "this header file must not be included directly" +#endif + +// PyCFunctionObject structure + +typedef struct { + PyObject_HEAD + PyMethodDef *m_ml; /* Description of the C function to call */ + PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ + PyObject *m_module; /* The __module__ attribute, can be anything */ + PyObject *m_weakreflist; /* List of weak references */ + vectorcallfunc vectorcall; +} PyCFunctionObject; + +#define _PyCFunctionObject_CAST(func) \ + (assert(PyCFunction_Check(func)), \ + _Py_CAST(PyCFunctionObject*, (func))) + + +// PyCMethodObject structure + +typedef struct { + PyCFunctionObject func; + PyTypeObject *mm_class; /* Class that defines this method */ +} PyCMethodObject; + +#define _PyCMethodObject_CAST(func) \ + (assert(PyCMethod_Check(func)), \ + _Py_CAST(PyCMethodObject*, (func))) + +PyAPI_DATA(PyTypeObject) PyCMethod_Type; + +#define PyCMethod_CheckExact(op) Py_IS_TYPE((op), &PyCMethod_Type) +#define PyCMethod_Check(op) PyObject_TypeCheck((op), &PyCMethod_Type) + + +/* Static inline functions for direct access to these values. + Type checks are *not* done, so use with care. */ +static inline PyCFunction PyCFunction_GET_FUNCTION(PyObject *func) { + return _PyCFunctionObject_CAST(func)->m_ml->ml_meth; +} +#define PyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(_PyObject_CAST(func)) + +static inline PyObject* PyCFunction_GET_SELF(PyObject *func_obj) { + PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj); + if (func->m_ml->ml_flags & METH_STATIC) { + return _Py_NULL; + } + return func->m_self; +} +#define PyCFunction_GET_SELF(func) PyCFunction_GET_SELF(_PyObject_CAST(func)) + +static inline int PyCFunction_GET_FLAGS(PyObject *func) { + return _PyCFunctionObject_CAST(func)->m_ml->ml_flags; +} +#define PyCFunction_GET_FLAGS(func) PyCFunction_GET_FLAGS(_PyObject_CAST(func)) + +static inline PyTypeObject* PyCFunction_GET_CLASS(PyObject *func_obj) { + PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj); + if (func->m_ml->ml_flags & METH_METHOD) { + return _PyCMethodObject_CAST(func)->mm_class; + } + return _Py_NULL; +} +#define PyCFunction_GET_CLASS(func) PyCFunction_GET_CLASS(_PyObject_CAST(func)) diff --git a/illumos-x86_64/usr/include/python3.13/cpython/modsupport.h b/illumos-x86_64/usr/include/python3.13/cpython/modsupport.h new file mode 100644 index 00000000..d3b88f58 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/modsupport.h @@ -0,0 +1,26 @@ +#ifndef Py_CPYTHON_MODSUPPORT_H +# error "this header file must not be included directly" +#endif + +// A data structure that can be used to run initialization code once in a +// thread-safe manner. The C++11 equivalent is std::call_once. +typedef struct { + uint8_t v; +} _PyOnceFlag; + +typedef struct _PyArg_Parser { + const char *format; + const char * const *keywords; + const char *fname; + const char *custom_msg; + _PyOnceFlag once; /* atomic one-time initialization flag */ + int is_kwtuple_owned; /* does this parser own the kwtuple object? */ + int pos; /* number of positional-only arguments */ + int min; /* minimal number of arguments */ + int max; /* maximal number of positional arguments */ + PyObject *kwtuple; /* tuple of keyword parameter names */ + struct _PyArg_Parser *next; +} _PyArg_Parser; + +PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *, + struct _PyArg_Parser *, ...); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/monitoring.h b/illumos-x86_64/usr/include/python3.13/cpython/monitoring.h new file mode 100644 index 00000000..797ba512 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/monitoring.h @@ -0,0 +1,250 @@ +#ifndef Py_CPYTHON_MONITORING_H +# error "this header file must not be included directly" +#endif + +/* Local events. + * These require bytecode instrumentation */ + +#define PY_MONITORING_EVENT_PY_START 0 +#define PY_MONITORING_EVENT_PY_RESUME 1 +#define PY_MONITORING_EVENT_PY_RETURN 2 +#define PY_MONITORING_EVENT_PY_YIELD 3 +#define PY_MONITORING_EVENT_CALL 4 +#define PY_MONITORING_EVENT_LINE 5 +#define PY_MONITORING_EVENT_INSTRUCTION 6 +#define PY_MONITORING_EVENT_JUMP 7 +#define PY_MONITORING_EVENT_BRANCH 8 +#define PY_MONITORING_EVENT_STOP_ITERATION 9 + +#define PY_MONITORING_IS_INSTRUMENTED_EVENT(ev) \ + ((ev) < _PY_MONITORING_LOCAL_EVENTS) + +/* Other events, mainly exceptions */ + +#define PY_MONITORING_EVENT_RAISE 10 +#define PY_MONITORING_EVENT_EXCEPTION_HANDLED 11 +#define PY_MONITORING_EVENT_PY_UNWIND 12 +#define PY_MONITORING_EVENT_PY_THROW 13 +#define PY_MONITORING_EVENT_RERAISE 14 + + +/* Ancillary events */ + +#define PY_MONITORING_EVENT_C_RETURN 15 +#define PY_MONITORING_EVENT_C_RAISE 16 + + +typedef struct _PyMonitoringState { + uint8_t active; + uint8_t opaque; +} PyMonitoringState; + + +PyAPI_FUNC(int) +PyMonitoring_EnterScope(PyMonitoringState *state_array, uint64_t *version, + const uint8_t *event_types, Py_ssize_t length); + +PyAPI_FUNC(int) +PyMonitoring_ExitScope(void); + + +PyAPI_FUNC(int) +_PyMonitoring_FirePyStartEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset); + +PyAPI_FUNC(int) +_PyMonitoring_FirePyResumeEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset); + +PyAPI_FUNC(int) +_PyMonitoring_FirePyReturnEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *retval); + +PyAPI_FUNC(int) +_PyMonitoring_FirePyYieldEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *retval); + +PyAPI_FUNC(int) +_PyMonitoring_FireCallEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject* callable, PyObject *arg0); + +PyAPI_FUNC(int) +_PyMonitoring_FireLineEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + int lineno); + +PyAPI_FUNC(int) +_PyMonitoring_FireJumpEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *target_offset); + +PyAPI_FUNC(int) +_PyMonitoring_FireBranchEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *target_offset); + +PyAPI_FUNC(int) +_PyMonitoring_FireCReturnEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *retval); + +PyAPI_FUNC(int) +_PyMonitoring_FirePyThrowEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset); + +PyAPI_FUNC(int) +_PyMonitoring_FireRaiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset); + +PyAPI_FUNC(int) +_PyMonitoring_FireReraiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset); + +PyAPI_FUNC(int) +_PyMonitoring_FireExceptionHandledEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset); + +PyAPI_FUNC(int) +_PyMonitoring_FireCRaiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset); + +PyAPI_FUNC(int) +_PyMonitoring_FirePyUnwindEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset); + +PyAPI_FUNC(int) +_PyMonitoring_FireStopIterationEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *value); + + +#define _PYMONITORING_IF_ACTIVE(STATE, X) \ + if ((STATE)->active) { \ + return (X); \ + } \ + else { \ + return 0; \ + } + +static inline int +PyMonitoring_FirePyStartEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FirePyStartEvent(state, codelike, offset)); +} + +static inline int +PyMonitoring_FirePyResumeEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FirePyResumeEvent(state, codelike, offset)); +} + +static inline int +PyMonitoring_FirePyReturnEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *retval) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FirePyReturnEvent(state, codelike, offset, retval)); +} + +static inline int +PyMonitoring_FirePyYieldEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *retval) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FirePyYieldEvent(state, codelike, offset, retval)); +} + +static inline int +PyMonitoring_FireCallEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject* callable, PyObject *arg0) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireCallEvent(state, codelike, offset, callable, arg0)); +} + +static inline int +PyMonitoring_FireLineEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + int lineno) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireLineEvent(state, codelike, offset, lineno)); +} + +static inline int +PyMonitoring_FireJumpEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *target_offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireJumpEvent(state, codelike, offset, target_offset)); +} + +static inline int +PyMonitoring_FireBranchEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *target_offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireBranchEvent(state, codelike, offset, target_offset)); +} + +static inline int +PyMonitoring_FireCReturnEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, + PyObject *retval) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireCReturnEvent(state, codelike, offset, retval)); +} + +static inline int +PyMonitoring_FirePyThrowEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FirePyThrowEvent(state, codelike, offset)); +} + +static inline int +PyMonitoring_FireRaiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireRaiseEvent(state, codelike, offset)); +} + +static inline int +PyMonitoring_FireReraiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireReraiseEvent(state, codelike, offset)); +} + +static inline int +PyMonitoring_FireExceptionHandledEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireExceptionHandledEvent(state, codelike, offset)); +} + +static inline int +PyMonitoring_FireCRaiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireCRaiseEvent(state, codelike, offset)); +} + +static inline int +PyMonitoring_FirePyUnwindEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FirePyUnwindEvent(state, codelike, offset)); +} + +static inline int +PyMonitoring_FireStopIterationEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *value) +{ + _PYMONITORING_IF_ACTIVE( + state, + _PyMonitoring_FireStopIterationEvent(state, codelike, offset, value)); +} + +#undef _PYMONITORING_IF_ACTIVE diff --git a/illumos-x86_64/usr/include/python3.13/cpython/object.h b/illumos-x86_64/usr/include/python3.13/cpython/object.h new file mode 100644 index 00000000..6cb2c40f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/object.h @@ -0,0 +1,525 @@ +#ifndef Py_CPYTHON_OBJECT_H +# error "this header file must not be included directly" +#endif + +PyAPI_FUNC(void) _Py_NewReference(PyObject *op); +PyAPI_FUNC(void) _Py_NewReferenceNoTotal(PyObject *op); +PyAPI_FUNC(void) _Py_ResurrectReference(PyObject *op); + +#ifdef Py_REF_DEBUG +/* These are useful as debugging aids when chasing down refleaks. */ +PyAPI_FUNC(Py_ssize_t) _Py_GetGlobalRefTotal(void); +# define _Py_GetRefTotal() _Py_GetGlobalRefTotal() +PyAPI_FUNC(Py_ssize_t) _Py_GetLegacyRefTotal(void); +PyAPI_FUNC(Py_ssize_t) _PyInterpreterState_GetRefTotal(PyInterpreterState *); +#endif + + +/********************* String Literals ****************************************/ +/* This structure helps managing static strings. The basic usage goes like this: + Instead of doing + + r = PyObject_CallMethod(o, "foo", "args", ...); + + do + + _Py_IDENTIFIER(foo); + ... + r = _PyObject_CallMethodId(o, &PyId_foo, "args", ...); + + PyId_foo is a static variable, either on block level or file level. On first + usage, the string "foo" is interned, and the structures are linked. On interpreter + shutdown, all strings are released. + + Alternatively, _Py_static_string allows choosing the variable name. + _PyUnicode_FromId returns a borrowed reference to the interned string. + _PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*. +*/ +typedef struct _Py_Identifier { + const char* string; + // Index in PyInterpreterState.unicode.ids.array. It is process-wide + // unique and must be initialized to -1. + Py_ssize_t index; + // Hidden PyMutex struct for non free-threaded build. + struct { + uint8_t v; + } mutex; +} _Py_Identifier; + +#ifndef Py_BUILD_CORE +// For now we are keeping _Py_IDENTIFIER for continued use +// in non-builtin extensions (and naughty PyPI modules). + +#define _Py_static_string_init(value) { .string = (value), .index = -1 } +#define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value) +#define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname) + +#endif /* !Py_BUILD_CORE */ + + +typedef struct { + /* Number implementations must check *both* + arguments for proper type and implement the necessary conversions + in the slot functions themselves. */ + + binaryfunc nb_add; + binaryfunc nb_subtract; + binaryfunc nb_multiply; + binaryfunc nb_remainder; + binaryfunc nb_divmod; + ternaryfunc nb_power; + unaryfunc nb_negative; + unaryfunc nb_positive; + unaryfunc nb_absolute; + inquiry nb_bool; + unaryfunc nb_invert; + binaryfunc nb_lshift; + binaryfunc nb_rshift; + binaryfunc nb_and; + binaryfunc nb_xor; + binaryfunc nb_or; + unaryfunc nb_int; + void *nb_reserved; /* the slot formerly known as nb_long */ + unaryfunc nb_float; + + binaryfunc nb_inplace_add; + binaryfunc nb_inplace_subtract; + binaryfunc nb_inplace_multiply; + binaryfunc nb_inplace_remainder; + ternaryfunc nb_inplace_power; + binaryfunc nb_inplace_lshift; + binaryfunc nb_inplace_rshift; + binaryfunc nb_inplace_and; + binaryfunc nb_inplace_xor; + binaryfunc nb_inplace_or; + + binaryfunc nb_floor_divide; + binaryfunc nb_true_divide; + binaryfunc nb_inplace_floor_divide; + binaryfunc nb_inplace_true_divide; + + unaryfunc nb_index; + + binaryfunc nb_matrix_multiply; + binaryfunc nb_inplace_matrix_multiply; +} PyNumberMethods; + +typedef struct { + lenfunc sq_length; + binaryfunc sq_concat; + ssizeargfunc sq_repeat; + ssizeargfunc sq_item; + void *was_sq_slice; + ssizeobjargproc sq_ass_item; + void *was_sq_ass_slice; + objobjproc sq_contains; + + binaryfunc sq_inplace_concat; + ssizeargfunc sq_inplace_repeat; +} PySequenceMethods; + +typedef struct { + lenfunc mp_length; + binaryfunc mp_subscript; + objobjargproc mp_ass_subscript; +} PyMappingMethods; + +typedef PySendResult (*sendfunc)(PyObject *iter, PyObject *value, PyObject **result); + +typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + sendfunc am_send; +} PyAsyncMethods; + +typedef struct { + getbufferproc bf_getbuffer; + releasebufferproc bf_releasebuffer; +} PyBufferProcs; + +/* Allow printfunc in the tp_vectorcall_offset slot for + * backwards-compatibility */ +typedef Py_ssize_t printfunc; + +// If this structure is modified, Doc/includes/typestruct.h should be updated +// as well. +struct _typeobject { + PyObject_VAR_HEAD + const char *tp_name; /* For printing, in format "." */ + Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */ + + /* Methods to implement standard operations */ + + destructor tp_dealloc; + Py_ssize_t tp_vectorcall_offset; + getattrfunc tp_getattr; + setattrfunc tp_setattr; + PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2) + or tp_reserved (Python 3) */ + reprfunc tp_repr; + + /* Method suites for standard classes */ + + PyNumberMethods *tp_as_number; + PySequenceMethods *tp_as_sequence; + PyMappingMethods *tp_as_mapping; + + /* More standard operations (here for binary compatibility) */ + + hashfunc tp_hash; + ternaryfunc tp_call; + reprfunc tp_str; + getattrofunc tp_getattro; + setattrofunc tp_setattro; + + /* Functions to access object as input/output buffer */ + PyBufferProcs *tp_as_buffer; + + /* Flags to define presence of optional/expanded features */ + unsigned long tp_flags; + + const char *tp_doc; /* Documentation string */ + + /* Assigned meaning in release 2.0 */ + /* call function for all accessible objects */ + traverseproc tp_traverse; + + /* delete references to contained objects */ + inquiry tp_clear; + + /* Assigned meaning in release 2.1 */ + /* rich comparisons */ + richcmpfunc tp_richcompare; + + /* weak reference enabler */ + Py_ssize_t tp_weaklistoffset; + + /* Iterators */ + getiterfunc tp_iter; + iternextfunc tp_iternext; + + /* Attribute descriptor and subclassing stuff */ + PyMethodDef *tp_methods; + PyMemberDef *tp_members; + PyGetSetDef *tp_getset; + // Strong reference on a heap type, borrowed reference on a static type + PyTypeObject *tp_base; + PyObject *tp_dict; + descrgetfunc tp_descr_get; + descrsetfunc tp_descr_set; + Py_ssize_t tp_dictoffset; + initproc tp_init; + allocfunc tp_alloc; + newfunc tp_new; + freefunc tp_free; /* Low-level free-memory routine */ + inquiry tp_is_gc; /* For PyObject_IS_GC */ + PyObject *tp_bases; + PyObject *tp_mro; /* method resolution order */ + PyObject *tp_cache; /* no longer used */ + void *tp_subclasses; /* for static builtin types this is an index */ + PyObject *tp_weaklist; /* not used for static builtin types */ + destructor tp_del; + + /* Type attribute cache version tag. Added in version 2.6 */ + unsigned int tp_version_tag; + + destructor tp_finalize; + vectorcallfunc tp_vectorcall; + + /* bitset of which type-watchers care about this type */ + unsigned char tp_watched; + uint16_t tp_versions_used; +}; + +/* This struct is used by the specializer + * It should be treated as an opaque blob + * by code other than the specializer and interpreter. */ +struct _specialization_cache { + // In order to avoid bloating the bytecode with lots of inline caches, the + // members of this structure have a somewhat unique contract. They are set + // by the specialization machinery, and are invalidated by PyType_Modified. + // The rules for using them are as follows: + // - If getitem is non-NULL, then it is the same Python function that + // PyType_Lookup(cls, "__getitem__") would return. + // - If getitem is NULL, then getitem_version is meaningless. + // - If getitem->func_version == getitem_version, then getitem can be called + // with two positional arguments and no keyword arguments, and has neither + // *args nor **kwargs (as required by BINARY_SUBSCR_GETITEM): + PyObject *getitem; + uint32_t getitem_version; + PyObject *init; +}; + +/* The *real* layout of a type object when allocated on the heap */ +typedef struct _heaptypeobject { + /* Note: there's a dependency on the order of these members + in slotptr() in typeobject.c . */ + PyTypeObject ht_type; + PyAsyncMethods as_async; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; /* as_sequence comes after as_mapping, + so that the mapping wins when both + the mapping and the sequence define + a given operator (e.g. __getitem__). + see add_operators() in typeobject.c . */ + PyBufferProcs as_buffer; + PyObject *ht_name, *ht_slots, *ht_qualname; + struct _dictkeysobject *ht_cached_keys; + PyObject *ht_module; + char *_ht_tpname; // Storage for "tp_name"; see PyType_FromModuleAndSpec + struct _specialization_cache _spec_cache; // For use by the specializer. + /* here are optional user slots, followed by the members. */ +} PyHeapTypeObject; + +PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *); +PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyType_LookupRef(PyTypeObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyType_GetDict(PyTypeObject *); + +PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int); +PyAPI_FUNC(void) _Py_BreakPoint(void); +PyAPI_FUNC(void) _PyObject_Dump(PyObject *); + +PyAPI_FUNC(PyObject*) _PyObject_GetAttrId(PyObject *, _Py_Identifier *); + +PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *); +PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *); +PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *); + +PyAPI_FUNC(void) PyUnstable_Object_ClearWeakRefsNoCallbacks(PyObject *); + +/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes + dict as the last parameter. */ +PyAPI_FUNC(PyObject *) +_PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *, int); +PyAPI_FUNC(int) +_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *, + PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) _PyObject_FunctionStr(PyObject *); + +/* Safely decref `dst` and set `dst` to `src`. + * + * As in case of Py_CLEAR "the obvious" code can be deadly: + * + * Py_DECREF(dst); + * dst = src; + * + * The safe way is: + * + * Py_SETREF(dst, src); + * + * That arranges to set `dst` to `src` _before_ decref'ing, so that any code + * triggered as a side-effect of `dst` getting torn down no longer believes + * `dst` points to a valid object. + * + * Temporary variables are used to only evalutate macro arguments once and so + * avoid the duplication of side effects. _Py_TYPEOF() or memcpy() is used to + * avoid a miscompilation caused by type punning. See Py_CLEAR() comment for + * implementation details about type punning. + * + * The memcpy() implementation does not emit a compiler warning if 'src' has + * not the same type than 'src': any pointer type is accepted for 'src'. + */ +#ifdef _Py_TYPEOF +#define Py_SETREF(dst, src) \ + do { \ + _Py_TYPEOF(dst)* _tmp_dst_ptr = &(dst); \ + _Py_TYPEOF(dst) _tmp_old_dst = (*_tmp_dst_ptr); \ + *_tmp_dst_ptr = (src); \ + Py_DECREF(_tmp_old_dst); \ + } while (0) +#else +#define Py_SETREF(dst, src) \ + do { \ + PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); \ + PyObject *_tmp_old_dst = (*_tmp_dst_ptr); \ + PyObject *_tmp_src = _PyObject_CAST(src); \ + memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(PyObject*)); \ + Py_DECREF(_tmp_old_dst); \ + } while (0) +#endif + +/* Py_XSETREF() is a variant of Py_SETREF() that uses Py_XDECREF() instead of + * Py_DECREF(). + */ +#ifdef _Py_TYPEOF +#define Py_XSETREF(dst, src) \ + do { \ + _Py_TYPEOF(dst)* _tmp_dst_ptr = &(dst); \ + _Py_TYPEOF(dst) _tmp_old_dst = (*_tmp_dst_ptr); \ + *_tmp_dst_ptr = (src); \ + Py_XDECREF(_tmp_old_dst); \ + } while (0) +#else +#define Py_XSETREF(dst, src) \ + do { \ + PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); \ + PyObject *_tmp_old_dst = (*_tmp_dst_ptr); \ + PyObject *_tmp_src = _PyObject_CAST(src); \ + memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(PyObject*)); \ + Py_XDECREF(_tmp_old_dst); \ + } while (0) +#endif + + +/* Define a pair of assertion macros: + _PyObject_ASSERT_FROM(), _PyObject_ASSERT_WITH_MSG() and _PyObject_ASSERT(). + + These work like the regular C assert(), in that they will abort the + process with a message on stderr if the given condition fails to hold, + but compile away to nothing if NDEBUG is defined. + + However, before aborting, Python will also try to call _PyObject_Dump() on + the given object. This may be of use when investigating bugs in which a + particular object is corrupt (e.g. buggy a tp_visit method in an extension + module breaking the garbage collector), to help locate the broken objects. + + The WITH_MSG variant allows you to supply an additional message that Python + will attempt to print to stderr, after the object dump. */ +#ifdef NDEBUG + /* No debugging: compile away the assertions: */ +# define _PyObject_ASSERT_FROM(obj, expr, msg, filename, lineno, func) \ + ((void)0) +#else + /* With debugging: generate checks: */ +# define _PyObject_ASSERT_FROM(obj, expr, msg, filename, lineno, func) \ + ((expr) \ + ? (void)(0) \ + : _PyObject_AssertFailed((obj), Py_STRINGIFY(expr), \ + (msg), (filename), (lineno), (func))) +#endif + +#define _PyObject_ASSERT_WITH_MSG(obj, expr, msg) \ + _PyObject_ASSERT_FROM((obj), expr, (msg), __FILE__, __LINE__, __func__) +#define _PyObject_ASSERT(obj, expr) \ + _PyObject_ASSERT_WITH_MSG((obj), expr, NULL) + +#define _PyObject_ASSERT_FAILED_MSG(obj, msg) \ + _PyObject_AssertFailed((obj), NULL, (msg), __FILE__, __LINE__, __func__) + +/* Declare and define _PyObject_AssertFailed() even when NDEBUG is defined, + to avoid causing compiler/linker errors when building extensions without + NDEBUG against a Python built with NDEBUG defined. + + msg, expr and function can be NULL. */ +PyAPI_FUNC(void) _Py_NO_RETURN _PyObject_AssertFailed( + PyObject *obj, + const char *expr, + const char *msg, + const char *file, + int line, + const char *function); + + +/* Trashcan mechanism, thanks to Christian Tismer. + +When deallocating a container object, it's possible to trigger an unbounded +chain of deallocations, as each Py_DECREF in turn drops the refcount on "the +next" object in the chain to 0. This can easily lead to stack overflows, +especially in threads (which typically have less stack space to work with). + +A container object can avoid this by bracketing the body of its tp_dealloc +function with a pair of macros: + +static void +mytype_dealloc(mytype *p) +{ + ... declarations go here ... + + PyObject_GC_UnTrack(p); // must untrack first + Py_TRASHCAN_BEGIN(p, mytype_dealloc) + ... The body of the deallocator goes here, including all calls ... + ... to Py_DECREF on contained objects. ... + Py_TRASHCAN_END // there should be no code after this +} + +CAUTION: Never return from the middle of the body! If the body needs to +"get out early", put a label immediately before the Py_TRASHCAN_END +call, and goto it. Else the call-depth counter (see below) will stay +above 0 forever, and the trashcan will never get emptied. + +How it works: The BEGIN macro increments a call-depth counter. So long +as this counter is small, the body of the deallocator is run directly without +further ado. But if the counter gets large, it instead adds p to a list of +objects to be deallocated later, skips the body of the deallocator, and +resumes execution after the END macro. The tp_dealloc routine then returns +without deallocating anything (and so unbounded call-stack depth is avoided). + +When the call stack finishes unwinding again, code generated by the END macro +notices this, and calls another routine to deallocate all the objects that +may have been added to the list of deferred deallocations. In effect, a +chain of N deallocations is broken into (N-1)/(Py_TRASHCAN_HEADROOM-1) pieces, +with the call stack never exceeding a depth of Py_TRASHCAN_HEADROOM. + +Since the tp_dealloc of a subclass typically calls the tp_dealloc of the base +class, we need to ensure that the trashcan is only triggered on the tp_dealloc +of the actual class being deallocated. Otherwise we might end up with a +partially-deallocated object. To check this, the tp_dealloc function must be +passed as second argument to Py_TRASHCAN_BEGIN(). +*/ + +/* Python 3.9 private API, invoked by the macros below. */ +PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op); +PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate); + +PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyThreadState *tstate, PyObject *op); +PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(PyThreadState *tstate); + + +/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */ + +/* To avoid raising recursion errors during dealloc trigger trashcan before we reach + * recursion limit. To avoid trashing, we don't attempt to empty the trashcan until + * we have headroom above the trigger limit */ +#define Py_TRASHCAN_HEADROOM 50 + +#define Py_TRASHCAN_BEGIN(op, dealloc) \ +do { \ + PyThreadState *tstate = PyThreadState_Get(); \ + if (tstate->c_recursion_remaining <= Py_TRASHCAN_HEADROOM && Py_TYPE(op)->tp_dealloc == (destructor)dealloc) { \ + _PyTrash_thread_deposit_object(tstate, (PyObject *)op); \ + break; \ + } \ + tstate->c_recursion_remaining--; + /* The body of the deallocator is here. */ +#define Py_TRASHCAN_END \ + tstate->c_recursion_remaining++; \ + if (tstate->delete_later && tstate->c_recursion_remaining > (Py_TRASHCAN_HEADROOM*2)) { \ + _PyTrash_thread_destroy_chain(tstate); \ + } \ +} while (0); + + +PyAPI_FUNC(void *) PyObject_GetItemData(PyObject *obj); + +PyAPI_FUNC(int) PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg); +PyAPI_FUNC(int) _PyObject_SetManagedDict(PyObject *obj, PyObject *new_dict); +PyAPI_FUNC(void) PyObject_ClearManagedDict(PyObject *obj); + +#define TYPE_MAX_WATCHERS 8 + +typedef int(*PyType_WatchCallback)(PyTypeObject *); +PyAPI_FUNC(int) PyType_AddWatcher(PyType_WatchCallback callback); +PyAPI_FUNC(int) PyType_ClearWatcher(int watcher_id); +PyAPI_FUNC(int) PyType_Watch(int watcher_id, PyObject *type); +PyAPI_FUNC(int) PyType_Unwatch(int watcher_id, PyObject *type); + +/* Attempt to assign a version tag to the given type. + * + * Returns 1 if the type already had a valid version tag or a new one was + * assigned, or 0 if a new tag could not be assigned. + */ +PyAPI_FUNC(int) PyUnstable_Type_AssignVersionTag(PyTypeObject *type); + + +typedef enum { + PyRefTracer_CREATE = 0, + PyRefTracer_DESTROY = 1, +} PyRefTracerEvent; + +typedef int (*PyRefTracer)(PyObject *, PyRefTracerEvent event, void *); +PyAPI_FUNC(int) PyRefTracer_SetTracer(PyRefTracer tracer, void *data); +PyAPI_FUNC(PyRefTracer) PyRefTracer_GetTracer(void**); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/objimpl.h b/illumos-x86_64/usr/include/python3.13/cpython/objimpl.h new file mode 100644 index 00000000..e0c2ce28 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/objimpl.h @@ -0,0 +1,104 @@ +#ifndef Py_CPYTHON_OBJIMPL_H +# error "this header file must not be included directly" +#endif + +static inline size_t _PyObject_SIZE(PyTypeObject *type) { + return _Py_STATIC_CAST(size_t, type->tp_basicsize); +} + +/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a + vrbl-size object with nitems items, exclusive of gc overhead (if any). The + value is rounded up to the closest multiple of sizeof(void *), in order to + ensure that pointer fields at the end of the object are correctly aligned + for the platform (this is of special importance for subclasses of, e.g., + str or int, so that pointers can be stored after the embedded data). + + Note that there's no memory wastage in doing this, as malloc has to + return (at worst) pointer-aligned memory anyway. +*/ +#if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0 +# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" +#endif + +static inline size_t _PyObject_VAR_SIZE(PyTypeObject *type, Py_ssize_t nitems) { + size_t size = _Py_STATIC_CAST(size_t, type->tp_basicsize); + size += _Py_STATIC_CAST(size_t, nitems) * _Py_STATIC_CAST(size_t, type->tp_itemsize); + return _Py_SIZE_ROUND_UP(size, SIZEOF_VOID_P); +} + + +/* This example code implements an object constructor with a custom + allocator, where PyObject_New is inlined, and shows the important + distinction between two steps (at least): + 1) the actual allocation of the object storage; + 2) the initialization of the Python specific fields + in this storage with PyObject_{Init, InitVar}. + + PyObject * + YourObject_New(...) + { + PyObject *op; + + op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); + if (op == NULL) { + return PyErr_NoMemory(); + } + + PyObject_Init(op, &YourTypeStruct); + + op->ob_field = value; + ... + return op; + } + + Note that in C++, the use of the new operator usually implies that + the 1st step is performed automatically for you, so in a C++ class + constructor you would start directly with PyObject_Init/InitVar. */ + + +typedef struct { + /* user context passed as the first argument to the 2 functions */ + void *ctx; + + /* allocate an arena of size bytes */ + void* (*alloc) (void *ctx, size_t size); + + /* free an arena */ + void (*free) (void *ctx, void *ptr, size_t size); +} PyObjectArenaAllocator; + +/* Get the arena allocator. */ +PyAPI_FUNC(void) PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator); + +/* Set the arena allocator. */ +PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator); + + +/* Test if an object implements the garbage collector protocol */ +PyAPI_FUNC(int) PyObject_IS_GC(PyObject *obj); + + +// Test if a type supports weak references +PyAPI_FUNC(int) PyType_SUPPORTS_WEAKREFS(PyTypeObject *type); + +PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op); + +PyAPI_FUNC(PyObject *) PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *, + size_t); + + +/* Visit all live GC-capable objects, similar to gc.get_objects(None). The + * supplied callback is called on every such object with the void* arg set + * to the supplied arg. Returning 0 from the callback ends iteration, returning + * 1 allows iteration to continue. Returning any other value may result in + * undefined behaviour. + * + * If new objects are (de)allocated by the callback it is undefined if they + * will be visited. + + * Garbage collection is disabled during operation. Explicitly running a + * collection in the callback may lead to undefined behaviour e.g. visiting the + * same objects multiple times or not at all. + */ +typedef int (*gcvisitobjects_t)(PyObject*, void*); +PyAPI_FUNC(void) PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void* arg); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/odictobject.h b/illumos-x86_64/usr/include/python3.13/cpython/odictobject.h new file mode 100644 index 00000000..3822d554 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/odictobject.h @@ -0,0 +1,43 @@ +#ifndef Py_ODICTOBJECT_H +#define Py_ODICTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* OrderedDict */ +/* This API is optional and mostly redundant. */ + +#ifndef Py_LIMITED_API + +typedef struct _odictobject PyODictObject; + +PyAPI_DATA(PyTypeObject) PyODict_Type; +PyAPI_DATA(PyTypeObject) PyODictIter_Type; +PyAPI_DATA(PyTypeObject) PyODictKeys_Type; +PyAPI_DATA(PyTypeObject) PyODictItems_Type; +PyAPI_DATA(PyTypeObject) PyODictValues_Type; + +#define PyODict_Check(op) PyObject_TypeCheck((op), &PyODict_Type) +#define PyODict_CheckExact(op) Py_IS_TYPE((op), &PyODict_Type) +#define PyODict_SIZE(op) PyDict_GET_SIZE((op)) + +PyAPI_FUNC(PyObject *) PyODict_New(void); +PyAPI_FUNC(int) PyODict_SetItem(PyObject *od, PyObject *key, PyObject *item); +PyAPI_FUNC(int) PyODict_DelItem(PyObject *od, PyObject *key); + +/* wrappers around PyDict* functions */ +#define PyODict_GetItem(od, key) PyDict_GetItem(_PyObject_CAST(od), (key)) +#define PyODict_GetItemWithError(od, key) \ + PyDict_GetItemWithError(_PyObject_CAST(od), (key)) +#define PyODict_Contains(od, key) PyDict_Contains(_PyObject_CAST(od), (key)) +#define PyODict_Size(od) PyDict_Size(_PyObject_CAST(od)) +#define PyODict_GetItemString(od, key) \ + PyDict_GetItemString(_PyObject_CAST(od), (key)) + +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ODICTOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/picklebufobject.h b/illumos-x86_64/usr/include/python3.13/cpython/picklebufobject.h new file mode 100644 index 00000000..f3cbaeef --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/picklebufobject.h @@ -0,0 +1,31 @@ +/* PickleBuffer object. This is built-in for ease of use from third-party + * C extensions. + */ + +#ifndef Py_PICKLEBUFOBJECT_H +#define Py_PICKLEBUFOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API + +PyAPI_DATA(PyTypeObject) PyPickleBuffer_Type; + +#define PyPickleBuffer_Check(op) Py_IS_TYPE((op), &PyPickleBuffer_Type) + +/* Create a PickleBuffer redirecting to the given buffer-enabled object */ +PyAPI_FUNC(PyObject *) PyPickleBuffer_FromObject(PyObject *); +/* Get the PickleBuffer's underlying view to the original object + * (NULL if released) + */ +PyAPI_FUNC(const Py_buffer *) PyPickleBuffer_GetBuffer(PyObject *); +/* Release the PickleBuffer. Returns 0 on success, -1 on error. */ +PyAPI_FUNC(int) PyPickleBuffer_Release(PyObject *); + +#endif /* !Py_LIMITED_API */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PICKLEBUFOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pthread_stubs.h b/illumos-x86_64/usr/include/python3.13/cpython/pthread_stubs.h new file mode 100644 index 00000000..e542eaa5 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pthread_stubs.h @@ -0,0 +1,105 @@ +#ifndef Py_CPYTHON_PTRHEAD_STUBS_H +#define Py_CPYTHON_PTRHEAD_STUBS_H + +#if !defined(HAVE_PTHREAD_STUBS) +# error "this header file requires stubbed pthreads." +#endif + +#ifndef _POSIX_THREADS +# define _POSIX_THREADS 1 +#endif + +/* Minimal pthread stubs for CPython. + * + * The stubs implement the minimum pthread API for CPython. + * - pthread_create() fails. + * - pthread_exit() calls exit(0). + * - pthread_key_*() functions implement minimal TSS without destructor. + * - all other functions do nothing and return 0. + */ + +#ifdef __wasi__ +// WASI's bits/alltypes.h provides type definitions when __NEED_ is set. +// The header file can be included multiple times. +// +// may also define these macros. +# ifndef __NEED_pthread_cond_t +# define __NEED_pthread_cond_t 1 +# endif +# ifndef __NEED_pthread_condattr_t +# define __NEED_pthread_condattr_t 1 +# endif +# ifndef __NEED_pthread_mutex_t +# define __NEED_pthread_mutex_t 1 +# endif +# ifndef __NEED_pthread_mutexattr_t +# define __NEED_pthread_mutexattr_t 1 +# endif +# ifndef __NEED_pthread_key_t +# define __NEED_pthread_key_t 1 +# endif +# ifndef __NEED_pthread_t +# define __NEED_pthread_t 1 +# endif +# ifndef __NEED_pthread_attr_t +# define __NEED_pthread_attr_t 1 +# endif +# include +#else +typedef struct { void *__x; } pthread_cond_t; +typedef struct { unsigned __attr; } pthread_condattr_t; +typedef struct { void *__x; } pthread_mutex_t; +typedef struct { unsigned __attr; } pthread_mutexattr_t; +typedef unsigned pthread_key_t; +typedef unsigned pthread_t; +typedef struct { unsigned __attr; } pthread_attr_t; +#endif + +// mutex +PyAPI_FUNC(int) pthread_mutex_init(pthread_mutex_t *restrict mutex, + const pthread_mutexattr_t *restrict attr); +PyAPI_FUNC(int) pthread_mutex_destroy(pthread_mutex_t *mutex); +PyAPI_FUNC(int) pthread_mutex_trylock(pthread_mutex_t *mutex); +PyAPI_FUNC(int) pthread_mutex_lock(pthread_mutex_t *mutex); +PyAPI_FUNC(int) pthread_mutex_unlock(pthread_mutex_t *mutex); + +// condition +PyAPI_FUNC(int) pthread_cond_init(pthread_cond_t *restrict cond, + const pthread_condattr_t *restrict attr); +PyAPI_FUNC(int) pthread_cond_destroy(pthread_cond_t *cond); +PyAPI_FUNC(int) pthread_cond_wait(pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex); +PyAPI_FUNC(int) pthread_cond_timedwait(pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime); +PyAPI_FUNC(int) pthread_cond_signal(pthread_cond_t *cond); +PyAPI_FUNC(int) pthread_condattr_init(pthread_condattr_t *attr); +PyAPI_FUNC(int) pthread_condattr_setclock( + pthread_condattr_t *attr, clockid_t clock_id); + +// pthread +PyAPI_FUNC(int) pthread_create(pthread_t *restrict thread, + const pthread_attr_t *restrict attr, + void *(*start_routine)(void *), + void *restrict arg); +PyAPI_FUNC(int) pthread_detach(pthread_t thread); +PyAPI_FUNC(int) pthread_join(pthread_t thread, void** value_ptr); +PyAPI_FUNC(pthread_t) pthread_self(void); +PyAPI_FUNC(int) pthread_exit(void *retval) __attribute__ ((__noreturn__)); +PyAPI_FUNC(int) pthread_attr_init(pthread_attr_t *attr); +PyAPI_FUNC(int) pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); +PyAPI_FUNC(int) pthread_attr_destroy(pthread_attr_t *attr); + + +// pthread_key +#ifndef PTHREAD_KEYS_MAX +# define PTHREAD_KEYS_MAX 128 +#endif + +PyAPI_FUNC(int) pthread_key_create(pthread_key_t *key, + void (*destr_function)(void *)); +PyAPI_FUNC(int) pthread_key_delete(pthread_key_t key); +PyAPI_FUNC(void *) pthread_getspecific(pthread_key_t key); +PyAPI_FUNC(int) pthread_setspecific(pthread_key_t key, const void *value); + +#endif // Py_CPYTHON_PTRHEAD_STUBS_H diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyatomic.h b/illumos-x86_64/usr/include/python3.13/cpython/pyatomic.h new file mode 100644 index 00000000..28029859 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyatomic.h @@ -0,0 +1,569 @@ +// This header provides cross-platform low-level atomic operations +// similar to C11 atomics. +// +// Operations are sequentially consistent unless they have a suffix indicating +// otherwise. If in doubt, prefer the sequentially consistent operations. +// +// The "_relaxed" suffix for load and store operations indicates the "relaxed" +// memory order. They don't provide synchronization, but (roughly speaking) +// guarantee somewhat sane behavior for races instead of undefined behavior. +// In practice, they correspond to "normal" hardware load and store +// instructions, so they are almost as inexpensive as plain loads and stores +// in C. +// +// Note that atomic read-modify-write operations like _Py_atomic_add_* return +// the previous value of the atomic variable, not the new value. +// +// See https://en.cppreference.com/w/c/atomic for more information on C11 +// atomics. +// See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2055r0.pdf +// "A Relaxed Guide to memory_order_relaxed" for discussion of and common usage +// or relaxed atomics. +// +// Functions with pseudo Python code: +// +// def _Py_atomic_load(obj): +// return obj # sequential consistency +// +// def _Py_atomic_load_relaxed(obj): +// return obj # relaxed consistency +// +// def _Py_atomic_store(obj, value): +// obj = value # sequential consistency +// +// def _Py_atomic_store_relaxed(obj, value): +// obj = value # relaxed consistency +// +// def _Py_atomic_exchange(obj, value): +// # sequential consistency +// old_obj = obj +// obj = value +// return old_obj +// +// def _Py_atomic_compare_exchange(obj, expected, desired): +// # sequential consistency +// if obj == expected: +// obj = desired +// return True +// else: +// expected = obj +// return False +// +// def _Py_atomic_add(obj, value): +// # sequential consistency +// old_obj = obj +// obj += value +// return old_obj +// +// def _Py_atomic_and(obj, value): +// # sequential consistency +// old_obj = obj +// obj &= value +// return old_obj +// +// def _Py_atomic_or(obj, value): +// # sequential consistency +// old_obj = obj +// obj |= value +// return old_obj +// +// Other functions: +// +// def _Py_atomic_load_ptr_acquire(obj): +// return obj # acquire +// +// def _Py_atomic_store_ptr_release(obj): +// return obj # release +// +// def _Py_atomic_fence_seq_cst(): +// # sequential consistency +// ... +// +// def _Py_atomic_fence_release(): +// # release +// ... + +#ifndef Py_CPYTHON_ATOMIC_H +# error "this header file must not be included directly" +#endif + +// --- _Py_atomic_add -------------------------------------------------------- +// Atomically adds `value` to `obj` and returns the previous value + +static inline int +_Py_atomic_add_int(int *obj, int value); + +static inline int8_t +_Py_atomic_add_int8(int8_t *obj, int8_t value); + +static inline int16_t +_Py_atomic_add_int16(int16_t *obj, int16_t value); + +static inline int32_t +_Py_atomic_add_int32(int32_t *obj, int32_t value); + +static inline int64_t +_Py_atomic_add_int64(int64_t *obj, int64_t value); + +static inline intptr_t +_Py_atomic_add_intptr(intptr_t *obj, intptr_t value); + +static inline unsigned int +_Py_atomic_add_uint(unsigned int *obj, unsigned int value); + +static inline uint8_t +_Py_atomic_add_uint8(uint8_t *obj, uint8_t value); + +static inline uint16_t +_Py_atomic_add_uint16(uint16_t *obj, uint16_t value); + +static inline uint32_t +_Py_atomic_add_uint32(uint32_t *obj, uint32_t value); + +static inline uint64_t +_Py_atomic_add_uint64(uint64_t *obj, uint64_t value); + +static inline uintptr_t +_Py_atomic_add_uintptr(uintptr_t *obj, uintptr_t value); + +static inline Py_ssize_t +_Py_atomic_add_ssize(Py_ssize_t *obj, Py_ssize_t value); + + +// --- _Py_atomic_compare_exchange ------------------------------------------- +// Performs an atomic compare-and-exchange. +// +// - If `*obj` and `*expected` are equal, store `desired` into `*obj` +// and return 1 (success). +// - Otherwise, store the `*obj` current value into `*expected` +// and return 0 (failure). +// +// These correspond to the C11 atomic_compare_exchange_strong() function. + +static inline int +_Py_atomic_compare_exchange_int(int *obj, int *expected, int desired); + +static inline int +_Py_atomic_compare_exchange_int8(int8_t *obj, int8_t *expected, int8_t desired); + +static inline int +_Py_atomic_compare_exchange_int16(int16_t *obj, int16_t *expected, int16_t desired); + +static inline int +_Py_atomic_compare_exchange_int32(int32_t *obj, int32_t *expected, int32_t desired); + +static inline int +_Py_atomic_compare_exchange_int64(int64_t *obj, int64_t *expected, int64_t desired); + +static inline int +_Py_atomic_compare_exchange_intptr(intptr_t *obj, intptr_t *expected, intptr_t desired); + +static inline int +_Py_atomic_compare_exchange_uint(unsigned int *obj, unsigned int *expected, unsigned int desired); + +static inline int +_Py_atomic_compare_exchange_uint8(uint8_t *obj, uint8_t *expected, uint8_t desired); + +static inline int +_Py_atomic_compare_exchange_uint16(uint16_t *obj, uint16_t *expected, uint16_t desired); + +static inline int +_Py_atomic_compare_exchange_uint32(uint32_t *obj, uint32_t *expected, uint32_t desired); + +static inline int +_Py_atomic_compare_exchange_uint64(uint64_t *obj, uint64_t *expected, uint64_t desired); + +static inline int +_Py_atomic_compare_exchange_uintptr(uintptr_t *obj, uintptr_t *expected, uintptr_t desired); + +static inline int +_Py_atomic_compare_exchange_ssize(Py_ssize_t *obj, Py_ssize_t *expected, Py_ssize_t desired); + +// NOTE: `obj` and `expected` are logically `void**` types, but we use `void*` +// so that we can pass types like `PyObject**` without a cast. +static inline int +_Py_atomic_compare_exchange_ptr(void *obj, void *expected, void *value); + + +// --- _Py_atomic_exchange --------------------------------------------------- +// Atomically replaces `*obj` with `value` and returns the previous value of `*obj`. + +static inline int +_Py_atomic_exchange_int(int *obj, int value); + +static inline int8_t +_Py_atomic_exchange_int8(int8_t *obj, int8_t value); + +static inline int16_t +_Py_atomic_exchange_int16(int16_t *obj, int16_t value); + +static inline int32_t +_Py_atomic_exchange_int32(int32_t *obj, int32_t value); + +static inline int64_t +_Py_atomic_exchange_int64(int64_t *obj, int64_t value); + +static inline intptr_t +_Py_atomic_exchange_intptr(intptr_t *obj, intptr_t value); + +static inline unsigned int +_Py_atomic_exchange_uint(unsigned int *obj, unsigned int value); + +static inline uint8_t +_Py_atomic_exchange_uint8(uint8_t *obj, uint8_t value); + +static inline uint16_t +_Py_atomic_exchange_uint16(uint16_t *obj, uint16_t value); + +static inline uint32_t +_Py_atomic_exchange_uint32(uint32_t *obj, uint32_t value); + +static inline uint64_t +_Py_atomic_exchange_uint64(uint64_t *obj, uint64_t value); + +static inline uintptr_t +_Py_atomic_exchange_uintptr(uintptr_t *obj, uintptr_t value); + +static inline Py_ssize_t +_Py_atomic_exchange_ssize(Py_ssize_t *obj, Py_ssize_t value); + +static inline void * +_Py_atomic_exchange_ptr(void *obj, void *value); + + +// --- _Py_atomic_and -------------------------------------------------------- +// Performs `*obj &= value` atomically and returns the previous value of `*obj`. + +static inline uint8_t +_Py_atomic_and_uint8(uint8_t *obj, uint8_t value); + +static inline uint16_t +_Py_atomic_and_uint16(uint16_t *obj, uint16_t value); + +static inline uint32_t +_Py_atomic_and_uint32(uint32_t *obj, uint32_t value); + +static inline uint64_t +_Py_atomic_and_uint64(uint64_t *obj, uint64_t value); + +static inline uintptr_t +_Py_atomic_and_uintptr(uintptr_t *obj, uintptr_t value); + + +// --- _Py_atomic_or --------------------------------------------------------- +// Performs `*obj |= value` atomically and returns the previous value of `*obj`. + +static inline uint8_t +_Py_atomic_or_uint8(uint8_t *obj, uint8_t value); + +static inline uint16_t +_Py_atomic_or_uint16(uint16_t *obj, uint16_t value); + +static inline uint32_t +_Py_atomic_or_uint32(uint32_t *obj, uint32_t value); + +static inline uint64_t +_Py_atomic_or_uint64(uint64_t *obj, uint64_t value); + +static inline uintptr_t +_Py_atomic_or_uintptr(uintptr_t *obj, uintptr_t value); + + +// --- _Py_atomic_load ------------------------------------------------------- +// Atomically loads `*obj` (sequential consistency) + +static inline int +_Py_atomic_load_int(const int *obj); + +static inline int8_t +_Py_atomic_load_int8(const int8_t *obj); + +static inline int16_t +_Py_atomic_load_int16(const int16_t *obj); + +static inline int32_t +_Py_atomic_load_int32(const int32_t *obj); + +static inline int64_t +_Py_atomic_load_int64(const int64_t *obj); + +static inline intptr_t +_Py_atomic_load_intptr(const intptr_t *obj); + +static inline uint8_t +_Py_atomic_load_uint8(const uint8_t *obj); + +static inline uint16_t +_Py_atomic_load_uint16(const uint16_t *obj); + +static inline uint32_t +_Py_atomic_load_uint32(const uint32_t *obj); + +static inline uint64_t +_Py_atomic_load_uint64(const uint64_t *obj); + +static inline uintptr_t +_Py_atomic_load_uintptr(const uintptr_t *obj); + +static inline unsigned int +_Py_atomic_load_uint(const unsigned int *obj); + +static inline Py_ssize_t +_Py_atomic_load_ssize(const Py_ssize_t *obj); + +static inline void * +_Py_atomic_load_ptr(const void *obj); + + +// --- _Py_atomic_load_relaxed ----------------------------------------------- +// Loads `*obj` (relaxed consistency, i.e., no ordering) + +static inline int +_Py_atomic_load_int_relaxed(const int *obj); + +static inline int8_t +_Py_atomic_load_int8_relaxed(const int8_t *obj); + +static inline int16_t +_Py_atomic_load_int16_relaxed(const int16_t *obj); + +static inline int32_t +_Py_atomic_load_int32_relaxed(const int32_t *obj); + +static inline int64_t +_Py_atomic_load_int64_relaxed(const int64_t *obj); + +static inline intptr_t +_Py_atomic_load_intptr_relaxed(const intptr_t *obj); + +static inline uint8_t +_Py_atomic_load_uint8_relaxed(const uint8_t *obj); + +static inline uint16_t +_Py_atomic_load_uint16_relaxed(const uint16_t *obj); + +static inline uint32_t +_Py_atomic_load_uint32_relaxed(const uint32_t *obj); + +static inline uint64_t +_Py_atomic_load_uint64_relaxed(const uint64_t *obj); + +static inline uintptr_t +_Py_atomic_load_uintptr_relaxed(const uintptr_t *obj); + +static inline unsigned int +_Py_atomic_load_uint_relaxed(const unsigned int *obj); + +static inline Py_ssize_t +_Py_atomic_load_ssize_relaxed(const Py_ssize_t *obj); + +static inline void * +_Py_atomic_load_ptr_relaxed(const void *obj); + +static inline unsigned long long +_Py_atomic_load_ullong_relaxed(const unsigned long long *obj); + +// --- _Py_atomic_store ------------------------------------------------------ +// Atomically performs `*obj = value` (sequential consistency) + +static inline void +_Py_atomic_store_int(int *obj, int value); + +static inline void +_Py_atomic_store_int8(int8_t *obj, int8_t value); + +static inline void +_Py_atomic_store_int16(int16_t *obj, int16_t value); + +static inline void +_Py_atomic_store_int32(int32_t *obj, int32_t value); + +static inline void +_Py_atomic_store_int64(int64_t *obj, int64_t value); + +static inline void +_Py_atomic_store_intptr(intptr_t *obj, intptr_t value); + +static inline void +_Py_atomic_store_uint8(uint8_t *obj, uint8_t value); + +static inline void +_Py_atomic_store_uint16(uint16_t *obj, uint16_t value); + +static inline void +_Py_atomic_store_uint32(uint32_t *obj, uint32_t value); + +static inline void +_Py_atomic_store_uint64(uint64_t *obj, uint64_t value); + +static inline void +_Py_atomic_store_uintptr(uintptr_t *obj, uintptr_t value); + +static inline void +_Py_atomic_store_uint(unsigned int *obj, unsigned int value); + +static inline void +_Py_atomic_store_ptr(void *obj, void *value); + +static inline void +_Py_atomic_store_ssize(Py_ssize_t* obj, Py_ssize_t value); + + +// --- _Py_atomic_store_relaxed ---------------------------------------------- +// Stores `*obj = value` (relaxed consistency, i.e., no ordering) + +static inline void +_Py_atomic_store_int_relaxed(int *obj, int value); + +static inline void +_Py_atomic_store_int8_relaxed(int8_t *obj, int8_t value); + +static inline void +_Py_atomic_store_int16_relaxed(int16_t *obj, int16_t value); + +static inline void +_Py_atomic_store_int32_relaxed(int32_t *obj, int32_t value); + +static inline void +_Py_atomic_store_int64_relaxed(int64_t *obj, int64_t value); + +static inline void +_Py_atomic_store_intptr_relaxed(intptr_t *obj, intptr_t value); + +static inline void +_Py_atomic_store_uint8_relaxed(uint8_t* obj, uint8_t value); + +static inline void +_Py_atomic_store_uint16_relaxed(uint16_t *obj, uint16_t value); + +static inline void +_Py_atomic_store_uint32_relaxed(uint32_t *obj, uint32_t value); + +static inline void +_Py_atomic_store_uint64_relaxed(uint64_t *obj, uint64_t value); + +static inline void +_Py_atomic_store_uintptr_relaxed(uintptr_t *obj, uintptr_t value); + +static inline void +_Py_atomic_store_uint_relaxed(unsigned int *obj, unsigned int value); + +static inline void +_Py_atomic_store_ptr_relaxed(void *obj, void *value); + +static inline void +_Py_atomic_store_ssize_relaxed(Py_ssize_t *obj, Py_ssize_t value); + +static inline void +_Py_atomic_store_ullong_relaxed(unsigned long long *obj, + unsigned long long value); + + +// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ + +// Loads `*obj` (acquire operation) +static inline void * +_Py_atomic_load_ptr_acquire(const void *obj); + +static inline uintptr_t +_Py_atomic_load_uintptr_acquire(const uintptr_t *obj); + +// Stores `*obj = value` (release operation) +static inline void +_Py_atomic_store_ptr_release(void *obj, void *value); + +static inline void +_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value); + +static inline void +_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value); + +static inline void +_Py_atomic_store_int_release(int *obj, int value); + +static inline int +_Py_atomic_load_int_acquire(const int *obj); + +static inline void +_Py_atomic_store_uint32_release(uint32_t *obj, uint32_t value); + +static inline void +_Py_atomic_store_uint64_release(uint64_t *obj, uint64_t value); + +static inline uint64_t +_Py_atomic_load_uint64_acquire(const uint64_t *obj); + +static inline uint32_t +_Py_atomic_load_uint32_acquire(const uint32_t *obj); + +static inline Py_ssize_t +_Py_atomic_load_ssize_acquire(const Py_ssize_t *obj); + + + + +// --- _Py_atomic_fence ------------------------------------------------------ + +// Sequential consistency fence. C11 fences have complex semantics. When +// possible, use the atomic operations on variables defined above, which +// generally do not require explicit use of a fence. +// See https://en.cppreference.com/w/cpp/atomic/atomic_thread_fence +static inline void _Py_atomic_fence_seq_cst(void); + +// Acquire fence +static inline void _Py_atomic_fence_acquire(void); + +// Release fence +static inline void _Py_atomic_fence_release(void); + + +#ifndef _Py_USE_GCC_BUILTIN_ATOMICS +# if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) +# define _Py_USE_GCC_BUILTIN_ATOMICS 1 +# elif defined(__clang__) +# if __has_builtin(__atomic_load) +# define _Py_USE_GCC_BUILTIN_ATOMICS 1 +# endif +# endif +#endif + +#if _Py_USE_GCC_BUILTIN_ATOMICS +# define Py_ATOMIC_GCC_H +# include "pyatomic_gcc.h" +# undef Py_ATOMIC_GCC_H +#elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) +# define Py_ATOMIC_STD_H +# include "pyatomic_std.h" +# undef Py_ATOMIC_STD_H +#elif defined(_MSC_VER) +# define Py_ATOMIC_MSC_H +# include "pyatomic_msc.h" +# undef Py_ATOMIC_MSC_H +#else +# error "no available pyatomic implementation for this platform/compiler" +#endif + + +// --- aliases --------------------------------------------------------------- + +#if SIZEOF_LONG == 8 +# define _Py_atomic_load_ulong(p) \ + _Py_atomic_load_uint64((uint64_t *)p) +# define _Py_atomic_load_ulong_relaxed(p) \ + _Py_atomic_load_uint64_relaxed((uint64_t *)p) +# define _Py_atomic_store_ulong(p, v) \ + _Py_atomic_store_uint64((uint64_t *)p, v) +# define _Py_atomic_store_ulong_relaxed(p, v) \ + _Py_atomic_store_uint64_relaxed((uint64_t *)p, v) +#elif SIZEOF_LONG == 4 +# define _Py_atomic_load_ulong(p) \ + _Py_atomic_load_uint32((uint32_t *)p) +# define _Py_atomic_load_ulong_relaxed(p) \ + _Py_atomic_load_uint32_relaxed((uint32_t *)p) +# define _Py_atomic_store_ulong(p, v) \ + _Py_atomic_store_uint32((uint32_t *)p, v) +# define _Py_atomic_store_ulong_relaxed(p, v) \ + _Py_atomic_store_uint32_relaxed((uint32_t *)p, v) +#else +# error "long must be 4 or 8 bytes in size" +#endif // SIZEOF_LONG diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_gcc.h b/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_gcc.h new file mode 100644 index 00000000..ef09954d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_gcc.h @@ -0,0 +1,551 @@ +// This is the implementation of Python atomic operations using GCC's built-in +// functions that match the C+11 memory model. This implementation is preferred +// for GCC compatible compilers, such as Clang. These functions are available +// in GCC 4.8+ without needing to compile with --std=c11 or --std=gnu11. + +#ifndef Py_ATOMIC_GCC_H +# error "this header file must not be included directly" +#endif + + +// --- _Py_atomic_add -------------------------------------------------------- + +static inline int +_Py_atomic_add_int(int *obj, int value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline int8_t +_Py_atomic_add_int8(int8_t *obj, int8_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline int16_t +_Py_atomic_add_int16(int16_t *obj, int16_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline int32_t +_Py_atomic_add_int32(int32_t *obj, int32_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline int64_t +_Py_atomic_add_int64(int64_t *obj, int64_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline intptr_t +_Py_atomic_add_intptr(intptr_t *obj, intptr_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline unsigned int +_Py_atomic_add_uint(unsigned int *obj, unsigned int value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint8_t +_Py_atomic_add_uint8(uint8_t *obj, uint8_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint16_t +_Py_atomic_add_uint16(uint16_t *obj, uint16_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint32_t +_Py_atomic_add_uint32(uint32_t *obj, uint32_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint64_t +_Py_atomic_add_uint64(uint64_t *obj, uint64_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline uintptr_t +_Py_atomic_add_uintptr(uintptr_t *obj, uintptr_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + +static inline Py_ssize_t +_Py_atomic_add_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); } + + +// --- _Py_atomic_compare_exchange ------------------------------------------- + +static inline int +_Py_atomic_compare_exchange_int(int *obj, int *expected, int desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_int8(int8_t *obj, int8_t *expected, int8_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_int16(int16_t *obj, int16_t *expected, int16_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_int32(int32_t *obj, int32_t *expected, int32_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_int64(int64_t *obj, int64_t *expected, int64_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_intptr(intptr_t *obj, intptr_t *expected, intptr_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_uint(unsigned int *obj, unsigned int *expected, unsigned int desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_uint8(uint8_t *obj, uint8_t *expected, uint8_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_uint16(uint16_t *obj, uint16_t *expected, uint16_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_uint32(uint32_t *obj, uint32_t *expected, uint32_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_uint64(uint64_t *obj, uint64_t *expected, uint64_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_uintptr(uintptr_t *obj, uintptr_t *expected, uintptr_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_ssize(Py_ssize_t *obj, Py_ssize_t *expected, Py_ssize_t desired) +{ return __atomic_compare_exchange_n(obj, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + +static inline int +_Py_atomic_compare_exchange_ptr(void *obj, void *expected, void *desired) +{ return __atomic_compare_exchange_n((void **)obj, (void **)expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } + + +// --- _Py_atomic_exchange --------------------------------------------------- + +static inline int +_Py_atomic_exchange_int(int *obj, int value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline int8_t +_Py_atomic_exchange_int8(int8_t *obj, int8_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline int16_t +_Py_atomic_exchange_int16(int16_t *obj, int16_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline int32_t +_Py_atomic_exchange_int32(int32_t *obj, int32_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline int64_t +_Py_atomic_exchange_int64(int64_t *obj, int64_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline intptr_t +_Py_atomic_exchange_intptr(intptr_t *obj, intptr_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline unsigned int +_Py_atomic_exchange_uint(unsigned int *obj, unsigned int value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint8_t +_Py_atomic_exchange_uint8(uint8_t *obj, uint8_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint16_t +_Py_atomic_exchange_uint16(uint16_t *obj, uint16_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint32_t +_Py_atomic_exchange_uint32(uint32_t *obj, uint32_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint64_t +_Py_atomic_exchange_uint64(uint64_t *obj, uint64_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline uintptr_t +_Py_atomic_exchange_uintptr(uintptr_t *obj, uintptr_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline Py_ssize_t +_Py_atomic_exchange_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void * +_Py_atomic_exchange_ptr(void *obj, void *value) +{ return __atomic_exchange_n((void **)obj, value, __ATOMIC_SEQ_CST); } + + +// --- _Py_atomic_and -------------------------------------------------------- + +static inline uint8_t +_Py_atomic_and_uint8(uint8_t *obj, uint8_t value) +{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint16_t +_Py_atomic_and_uint16(uint16_t *obj, uint16_t value) +{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint32_t +_Py_atomic_and_uint32(uint32_t *obj, uint32_t value) +{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint64_t +_Py_atomic_and_uint64(uint64_t *obj, uint64_t value) +{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); } + +static inline uintptr_t +_Py_atomic_and_uintptr(uintptr_t *obj, uintptr_t value) +{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); } + + +// --- _Py_atomic_or --------------------------------------------------------- + +static inline uint8_t +_Py_atomic_or_uint8(uint8_t *obj, uint8_t value) +{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint16_t +_Py_atomic_or_uint16(uint16_t *obj, uint16_t value) +{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint32_t +_Py_atomic_or_uint32(uint32_t *obj, uint32_t value) +{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); } + +static inline uint64_t +_Py_atomic_or_uint64(uint64_t *obj, uint64_t value) +{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); } + +static inline uintptr_t +_Py_atomic_or_uintptr(uintptr_t *obj, uintptr_t value) +{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); } + + +// --- _Py_atomic_load ------------------------------------------------------- + +static inline int +_Py_atomic_load_int(const int *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline int8_t +_Py_atomic_load_int8(const int8_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline int16_t +_Py_atomic_load_int16(const int16_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline int32_t +_Py_atomic_load_int32(const int32_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline int64_t +_Py_atomic_load_int64(const int64_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline intptr_t +_Py_atomic_load_intptr(const intptr_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline uint8_t +_Py_atomic_load_uint8(const uint8_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline uint16_t +_Py_atomic_load_uint16(const uint16_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline uint32_t +_Py_atomic_load_uint32(const uint32_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline uint64_t +_Py_atomic_load_uint64(const uint64_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline uintptr_t +_Py_atomic_load_uintptr(const uintptr_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline unsigned int +_Py_atomic_load_uint(const unsigned int *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline Py_ssize_t +_Py_atomic_load_ssize(const Py_ssize_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); } + +static inline void * +_Py_atomic_load_ptr(const void *obj) +{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_SEQ_CST); } + + +// --- _Py_atomic_load_relaxed ----------------------------------------------- + +static inline int +_Py_atomic_load_int_relaxed(const int *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline int8_t +_Py_atomic_load_int8_relaxed(const int8_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline int16_t +_Py_atomic_load_int16_relaxed(const int16_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline int32_t +_Py_atomic_load_int32_relaxed(const int32_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline int64_t +_Py_atomic_load_int64_relaxed(const int64_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline intptr_t +_Py_atomic_load_intptr_relaxed(const intptr_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline uint8_t +_Py_atomic_load_uint8_relaxed(const uint8_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline uint16_t +_Py_atomic_load_uint16_relaxed(const uint16_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline uint32_t +_Py_atomic_load_uint32_relaxed(const uint32_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline uint64_t +_Py_atomic_load_uint64_relaxed(const uint64_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline uintptr_t +_Py_atomic_load_uintptr_relaxed(const uintptr_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline unsigned int +_Py_atomic_load_uint_relaxed(const unsigned int *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline Py_ssize_t +_Py_atomic_load_ssize_relaxed(const Py_ssize_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + +static inline void * +_Py_atomic_load_ptr_relaxed(const void *obj) +{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_RELAXED); } + +static inline unsigned long long +_Py_atomic_load_ullong_relaxed(const unsigned long long *obj) +{ return __atomic_load_n(obj, __ATOMIC_RELAXED); } + + +// --- _Py_atomic_store ------------------------------------------------------ + +static inline void +_Py_atomic_store_int(int *obj, int value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_int8(int8_t *obj, int8_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_int16(int16_t *obj, int16_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_int32(int32_t *obj, int32_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_int64(int64_t *obj, int64_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_intptr(intptr_t *obj, intptr_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_uint8(uint8_t *obj, uint8_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_uint16(uint16_t *obj, uint16_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_uint32(uint32_t *obj, uint32_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_uint64(uint64_t *obj, uint64_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_uintptr(uintptr_t *obj, uintptr_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_uint(unsigned int *obj, unsigned int value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_ptr(void *obj, void *value) +{ __atomic_store_n((void **)obj, value, __ATOMIC_SEQ_CST); } + +static inline void +_Py_atomic_store_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); } + + +// --- _Py_atomic_store_relaxed ---------------------------------------------- + +static inline void +_Py_atomic_store_int_relaxed(int *obj, int value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_int8_relaxed(int8_t *obj, int8_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_int16_relaxed(int16_t *obj, int16_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_int32_relaxed(int32_t *obj, int32_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_int64_relaxed(int64_t *obj, int64_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_intptr_relaxed(intptr_t *obj, intptr_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_uint8_relaxed(uint8_t *obj, uint8_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_uint16_relaxed(uint16_t *obj, uint16_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_uint32_relaxed(uint32_t *obj, uint32_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_uint64_relaxed(uint64_t *obj, uint64_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_uintptr_relaxed(uintptr_t *obj, uintptr_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_uint_relaxed(unsigned int *obj, unsigned int value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_ptr_relaxed(void *obj, void *value) +{ __atomic_store_n((void **)obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_ssize_relaxed(Py_ssize_t *obj, Py_ssize_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + +static inline void +_Py_atomic_store_ullong_relaxed(unsigned long long *obj, + unsigned long long value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } + + +// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ + +static inline void * +_Py_atomic_load_ptr_acquire(const void *obj) +{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_ACQUIRE); } + +static inline uintptr_t +_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) +{ return (uintptr_t)__atomic_load_n(obj, __ATOMIC_ACQUIRE); } + +static inline void +_Py_atomic_store_ptr_release(void *obj, void *value) +{ __atomic_store_n((void **)obj, value, __ATOMIC_RELEASE); } + +static inline void +_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } + +static inline void +_Py_atomic_store_int_release(int *obj, int value) +{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } + +static inline void +_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } + +static inline int +_Py_atomic_load_int_acquire(const int *obj) +{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); } + +static inline void +_Py_atomic_store_uint32_release(uint32_t *obj, uint32_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } + +static inline void +_Py_atomic_store_uint64_release(uint64_t *obj, uint64_t value) +{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } + +static inline uint64_t +_Py_atomic_load_uint64_acquire(const uint64_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); } + +static inline uint32_t +_Py_atomic_load_uint32_acquire(const uint32_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); } + +static inline Py_ssize_t +_Py_atomic_load_ssize_acquire(const Py_ssize_t *obj) +{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); } + +// --- _Py_atomic_fence ------------------------------------------------------ + +static inline void +_Py_atomic_fence_seq_cst(void) +{ __atomic_thread_fence(__ATOMIC_SEQ_CST); } + + static inline void +_Py_atomic_fence_acquire(void) +{ __atomic_thread_fence(__ATOMIC_ACQUIRE); } + + static inline void +_Py_atomic_fence_release(void) +{ __atomic_thread_fence(__ATOMIC_RELEASE); } diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_msc.h b/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_msc.h new file mode 100644 index 00000000..84da21bd --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_msc.h @@ -0,0 +1,1095 @@ +// This is the implementation of Python atomic operations for MSVC if the +// compiler does not support C11 or C++11 atomics. +// +// MSVC intrinsics are defined on char, short, long, __int64, and pointer +// types. Note that long and int are both 32-bits even on 64-bit Windows, +// so operations on int are cast to long. +// +// The volatile keyword has additional memory ordering semantics on MSVC. On +// x86 and x86-64, volatile accesses have acquire-release semantics. On ARM64, +// volatile accesses behave like C11's memory_order_relaxed. + +#ifndef Py_ATOMIC_MSC_H +# error "this header file must not be included directly" +#endif + +#include + +#define _Py_atomic_ASSERT_ARG_TYPE(TYPE) \ + Py_BUILD_ASSERT(sizeof(*obj) == sizeof(TYPE)) + + +// --- _Py_atomic_add -------------------------------------------------------- + +static inline int8_t +_Py_atomic_add_int8(int8_t *obj, int8_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(char); + return (int8_t)_InterlockedExchangeAdd8((volatile char *)obj, (char)value); +} + +static inline int16_t +_Py_atomic_add_int16(int16_t *obj, int16_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(short); + return (int16_t)_InterlockedExchangeAdd16((volatile short *)obj, (short)value); +} + +static inline int32_t +_Py_atomic_add_int32(int32_t *obj, int32_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(long); + return (int32_t)_InterlockedExchangeAdd((volatile long *)obj, (long)value); +} + +static inline int64_t +_Py_atomic_add_int64(int64_t *obj, int64_t value) +{ +#if defined(_M_X64) || defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(__int64); + return (int64_t)_InterlockedExchangeAdd64((volatile __int64 *)obj, (__int64)value); +#else + int64_t old_value = _Py_atomic_load_int64_relaxed(obj); + for (;;) { + int64_t new_value = old_value + value; + if (_Py_atomic_compare_exchange_int64(obj, &old_value, new_value)) { + return old_value; + } + } +#endif +} + + +static inline uint8_t +_Py_atomic_add_uint8(uint8_t *obj, uint8_t value) +{ + return (uint8_t)_Py_atomic_add_int8((int8_t *)obj, (int8_t)value); +} + +static inline uint16_t +_Py_atomic_add_uint16(uint16_t *obj, uint16_t value) +{ + return (uint16_t)_Py_atomic_add_int16((int16_t *)obj, (int16_t)value); +} + +static inline uint32_t +_Py_atomic_add_uint32(uint32_t *obj, uint32_t value) +{ + return (uint32_t)_Py_atomic_add_int32((int32_t *)obj, (int32_t)value); +} + +static inline int +_Py_atomic_add_int(int *obj, int value) +{ + _Py_atomic_ASSERT_ARG_TYPE(int32_t); + return (int)_Py_atomic_add_int32((int32_t *)obj, (int32_t)value); +} + +static inline unsigned int +_Py_atomic_add_uint(unsigned int *obj, unsigned int value) +{ + _Py_atomic_ASSERT_ARG_TYPE(int32_t); + return (unsigned int)_Py_atomic_add_int32((int32_t *)obj, (int32_t)value); +} + +static inline uint64_t +_Py_atomic_add_uint64(uint64_t *obj, uint64_t value) +{ + return (uint64_t)_Py_atomic_add_int64((int64_t *)obj, (int64_t)value); +} + +static inline intptr_t +_Py_atomic_add_intptr(intptr_t *obj, intptr_t value) +{ +#if SIZEOF_VOID_P == 8 + _Py_atomic_ASSERT_ARG_TYPE(int64_t); + return (intptr_t)_Py_atomic_add_int64((int64_t *)obj, (int64_t)value); +#else + _Py_atomic_ASSERT_ARG_TYPE(int32_t); + return (intptr_t)_Py_atomic_add_int32((int32_t *)obj, (int32_t)value); +#endif +} + +static inline uintptr_t +_Py_atomic_add_uintptr(uintptr_t *obj, uintptr_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(intptr_t); + return (uintptr_t)_Py_atomic_add_intptr((intptr_t *)obj, (intptr_t)value); +} + +static inline Py_ssize_t +_Py_atomic_add_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(intptr_t); + return (Py_ssize_t)_Py_atomic_add_intptr((intptr_t *)obj, (intptr_t)value); +} + + +// --- _Py_atomic_compare_exchange ------------------------------------------- + +static inline int +_Py_atomic_compare_exchange_int8(int8_t *obj, int8_t *expected, int8_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(char); + int8_t initial = (int8_t)_InterlockedCompareExchange8( + (volatile char *)obj, + (char)value, + (char)*expected); + if (initial == *expected) { + return 1; + } + *expected = initial; + return 0; +} + +static inline int +_Py_atomic_compare_exchange_int16(int16_t *obj, int16_t *expected, int16_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(short); + int16_t initial = (int16_t)_InterlockedCompareExchange16( + (volatile short *)obj, + (short)value, + (short)*expected); + if (initial == *expected) { + return 1; + } + *expected = initial; + return 0; +} + +static inline int +_Py_atomic_compare_exchange_int32(int32_t *obj, int32_t *expected, int32_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(long); + int32_t initial = (int32_t)_InterlockedCompareExchange( + (volatile long *)obj, + (long)value, + (long)*expected); + if (initial == *expected) { + return 1; + } + *expected = initial; + return 0; +} + +static inline int +_Py_atomic_compare_exchange_int64(int64_t *obj, int64_t *expected, int64_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(__int64); + int64_t initial = (int64_t)_InterlockedCompareExchange64( + (volatile __int64 *)obj, + (__int64)value, + (__int64)*expected); + if (initial == *expected) { + return 1; + } + *expected = initial; + return 0; +} + +static inline int +_Py_atomic_compare_exchange_ptr(void *obj, void *expected, void *value) +{ + void *initial = _InterlockedCompareExchangePointer( + (void**)obj, + value, + *(void**)expected); + if (initial == *(void**)expected) { + return 1; + } + *(void**)expected = initial; + return 0; +} + + +static inline int +_Py_atomic_compare_exchange_uint8(uint8_t *obj, uint8_t *expected, uint8_t value) +{ + return _Py_atomic_compare_exchange_int8((int8_t *)obj, + (int8_t *)expected, + (int8_t)value); +} + +static inline int +_Py_atomic_compare_exchange_uint16(uint16_t *obj, uint16_t *expected, uint16_t value) +{ + return _Py_atomic_compare_exchange_int16((int16_t *)obj, + (int16_t *)expected, + (int16_t)value); +} + +static inline int +_Py_atomic_compare_exchange_uint32(uint32_t *obj, uint32_t *expected, uint32_t value) +{ + return _Py_atomic_compare_exchange_int32((int32_t *)obj, + (int32_t *)expected, + (int32_t)value); +} + +static inline int +_Py_atomic_compare_exchange_int(int *obj, int *expected, int value) +{ + _Py_atomic_ASSERT_ARG_TYPE(int32_t); + return _Py_atomic_compare_exchange_int32((int32_t *)obj, + (int32_t *)expected, + (int32_t)value); +} + +static inline int +_Py_atomic_compare_exchange_uint(unsigned int *obj, unsigned int *expected, unsigned int value) +{ + _Py_atomic_ASSERT_ARG_TYPE(int32_t); + return _Py_atomic_compare_exchange_int32((int32_t *)obj, + (int32_t *)expected, + (int32_t)value); +} + +static inline int +_Py_atomic_compare_exchange_uint64(uint64_t *obj, uint64_t *expected, uint64_t value) +{ + return _Py_atomic_compare_exchange_int64((int64_t *)obj, + (int64_t *)expected, + (int64_t)value); +} + +static inline int +_Py_atomic_compare_exchange_intptr(intptr_t *obj, intptr_t *expected, intptr_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return _Py_atomic_compare_exchange_ptr((void**)obj, + (void**)expected, + (void*)value); +} + +static inline int +_Py_atomic_compare_exchange_uintptr(uintptr_t *obj, uintptr_t *expected, uintptr_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return _Py_atomic_compare_exchange_ptr((void**)obj, + (void**)expected, + (void*)value); +} + +static inline int +_Py_atomic_compare_exchange_ssize(Py_ssize_t *obj, Py_ssize_t *expected, Py_ssize_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return _Py_atomic_compare_exchange_ptr((void**)obj, + (void**)expected, + (void*)value); +} + + +// --- _Py_atomic_exchange --------------------------------------------------- + +static inline int8_t +_Py_atomic_exchange_int8(int8_t *obj, int8_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(char); + return (int8_t)_InterlockedExchange8((volatile char *)obj, (char)value); +} + +static inline int16_t +_Py_atomic_exchange_int16(int16_t *obj, int16_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(short); + return (int16_t)_InterlockedExchange16((volatile short *)obj, (short)value); +} + +static inline int32_t +_Py_atomic_exchange_int32(int32_t *obj, int32_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(long); + return (int32_t)_InterlockedExchange((volatile long *)obj, (long)value); +} + +static inline int64_t +_Py_atomic_exchange_int64(int64_t *obj, int64_t value) +{ +#if defined(_M_X64) || defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(__int64); + return (int64_t)_InterlockedExchange64((volatile __int64 *)obj, (__int64)value); +#else + int64_t old_value = _Py_atomic_load_int64_relaxed(obj); + for (;;) { + if (_Py_atomic_compare_exchange_int64(obj, &old_value, value)) { + return old_value; + } + } +#endif +} + +static inline void* +_Py_atomic_exchange_ptr(void *obj, void *value) +{ + return (void*)_InterlockedExchangePointer((void * volatile *)obj, (void *)value); +} + + +static inline uint8_t +_Py_atomic_exchange_uint8(uint8_t *obj, uint8_t value) +{ + return (uint8_t)_Py_atomic_exchange_int8((int8_t *)obj, + (int8_t)value); +} + +static inline uint16_t +_Py_atomic_exchange_uint16(uint16_t *obj, uint16_t value) +{ + return (uint16_t)_Py_atomic_exchange_int16((int16_t *)obj, + (int16_t)value); +} + +static inline uint32_t +_Py_atomic_exchange_uint32(uint32_t *obj, uint32_t value) +{ + return (uint32_t)_Py_atomic_exchange_int32((int32_t *)obj, + (int32_t)value); +} + +static inline int +_Py_atomic_exchange_int(int *obj, int value) +{ + _Py_atomic_ASSERT_ARG_TYPE(int32_t); + return (int)_Py_atomic_exchange_int32((int32_t *)obj, + (int32_t)value); +} + +static inline unsigned int +_Py_atomic_exchange_uint(unsigned int *obj, unsigned int value) +{ + _Py_atomic_ASSERT_ARG_TYPE(int32_t); + return (unsigned int)_Py_atomic_exchange_int32((int32_t *)obj, + (int32_t)value); +} + +static inline uint64_t +_Py_atomic_exchange_uint64(uint64_t *obj, uint64_t value) +{ + return (uint64_t)_Py_atomic_exchange_int64((int64_t *)obj, + (int64_t)value); +} + +static inline intptr_t +_Py_atomic_exchange_intptr(intptr_t *obj, intptr_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return (intptr_t)_Py_atomic_exchange_ptr((void**)obj, + (void*)value); +} + +static inline uintptr_t +_Py_atomic_exchange_uintptr(uintptr_t *obj, uintptr_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return (uintptr_t)_Py_atomic_exchange_ptr((void**)obj, + (void*)value); +} + +static inline Py_ssize_t +_Py_atomic_exchange_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return (Py_ssize_t)_Py_atomic_exchange_ptr((void**)obj, + (void*)value); +} + + +// --- _Py_atomic_and -------------------------------------------------------- + +static inline uint8_t +_Py_atomic_and_uint8(uint8_t *obj, uint8_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(char); + return (uint8_t)_InterlockedAnd8((volatile char *)obj, (char)value); +} + +static inline uint16_t +_Py_atomic_and_uint16(uint16_t *obj, uint16_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(short); + return (uint16_t)_InterlockedAnd16((volatile short *)obj, (short)value); +} + +static inline uint32_t +_Py_atomic_and_uint32(uint32_t *obj, uint32_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(long); + return (uint32_t)_InterlockedAnd((volatile long *)obj, (long)value); +} + +static inline uint64_t +_Py_atomic_and_uint64(uint64_t *obj, uint64_t value) +{ +#if defined(_M_X64) || defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(__int64); + return (uint64_t)_InterlockedAnd64((volatile __int64 *)obj, (__int64)value); +#else + uint64_t old_value = _Py_atomic_load_uint64_relaxed(obj); + for (;;) { + uint64_t new_value = old_value & value; + if (_Py_atomic_compare_exchange_uint64(obj, &old_value, new_value)) { + return old_value; + } + } +#endif +} + +static inline uintptr_t +_Py_atomic_and_uintptr(uintptr_t *obj, uintptr_t value) +{ +#if SIZEOF_VOID_P == 8 + _Py_atomic_ASSERT_ARG_TYPE(uint64_t); + return (uintptr_t)_Py_atomic_and_uint64((uint64_t *)obj, + (uint64_t)value); +#else + _Py_atomic_ASSERT_ARG_TYPE(uint32_t); + return (uintptr_t)_Py_atomic_and_uint32((uint32_t *)obj, + (uint32_t)value); +#endif +} + + +// --- _Py_atomic_or --------------------------------------------------------- + +static inline uint8_t +_Py_atomic_or_uint8(uint8_t *obj, uint8_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(char); + return (uint8_t)_InterlockedOr8((volatile char *)obj, (char)value); +} + +static inline uint16_t +_Py_atomic_or_uint16(uint16_t *obj, uint16_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(short); + return (uint16_t)_InterlockedOr16((volatile short *)obj, (short)value); +} + +static inline uint32_t +_Py_atomic_or_uint32(uint32_t *obj, uint32_t value) +{ + _Py_atomic_ASSERT_ARG_TYPE(long); + return (uint32_t)_InterlockedOr((volatile long *)obj, (long)value); +} + +static inline uint64_t +_Py_atomic_or_uint64(uint64_t *obj, uint64_t value) +{ +#if defined(_M_X64) || defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(__int64); + return (uint64_t)_InterlockedOr64((volatile __int64 *)obj, (__int64)value); +#else + uint64_t old_value = _Py_atomic_load_uint64_relaxed(obj); + for (;;) { + uint64_t new_value = old_value | value; + if (_Py_atomic_compare_exchange_uint64(obj, &old_value, new_value)) { + return old_value; + } + } +#endif +} + + +static inline uintptr_t +_Py_atomic_or_uintptr(uintptr_t *obj, uintptr_t value) +{ +#if SIZEOF_VOID_P == 8 + _Py_atomic_ASSERT_ARG_TYPE(uint64_t); + return (uintptr_t)_Py_atomic_or_uint64((uint64_t *)obj, + (uint64_t)value); +#else + _Py_atomic_ASSERT_ARG_TYPE(uint32_t); + return (uintptr_t)_Py_atomic_or_uint32((uint32_t *)obj, + (uint32_t)value); +#endif +} + + +// --- _Py_atomic_load ------------------------------------------------------- + +static inline uint8_t +_Py_atomic_load_uint8(const uint8_t *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(volatile uint8_t *)obj; +#elif defined(_M_ARM64) + return (uint8_t)__ldar8((unsigned __int8 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_uint8" +#endif +} + +static inline uint16_t +_Py_atomic_load_uint16(const uint16_t *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(volatile uint16_t *)obj; +#elif defined(_M_ARM64) + return (uint16_t)__ldar16((unsigned __int16 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_uint16" +#endif +} + +static inline uint32_t +_Py_atomic_load_uint32(const uint32_t *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(volatile uint32_t *)obj; +#elif defined(_M_ARM64) + return (uint32_t)__ldar32((unsigned __int32 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_uint32" +#endif +} + +static inline uint64_t +_Py_atomic_load_uint64(const uint64_t *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(volatile uint64_t *)obj; +#elif defined(_M_ARM64) + return (uint64_t)__ldar64((unsigned __int64 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_uint64" +#endif +} + +static inline int8_t +_Py_atomic_load_int8(const int8_t *obj) +{ + return (int8_t)_Py_atomic_load_uint8((const uint8_t *)obj); +} + +static inline int16_t +_Py_atomic_load_int16(const int16_t *obj) +{ + return (int16_t)_Py_atomic_load_uint16((const uint16_t *)obj); +} + +static inline int32_t +_Py_atomic_load_int32(const int32_t *obj) +{ + return (int32_t)_Py_atomic_load_uint32((const uint32_t *)obj); +} + +static inline int +_Py_atomic_load_int(const int *obj) +{ + _Py_atomic_ASSERT_ARG_TYPE(uint32_t); + return (int)_Py_atomic_load_uint32((uint32_t *)obj); +} + +static inline unsigned int +_Py_atomic_load_uint(const unsigned int *obj) +{ + _Py_atomic_ASSERT_ARG_TYPE(uint32_t); + return (unsigned int)_Py_atomic_load_uint32((uint32_t *)obj); +} + +static inline int64_t +_Py_atomic_load_int64(const int64_t *obj) +{ + return (int64_t)_Py_atomic_load_uint64((const uint64_t *)obj); +} + +static inline void* +_Py_atomic_load_ptr(const void *obj) +{ +#if SIZEOF_VOID_P == 8 + return (void*)_Py_atomic_load_uint64((const uint64_t *)obj); +#else + return (void*)_Py_atomic_load_uint32((const uint32_t *)obj); +#endif +} + +static inline intptr_t +_Py_atomic_load_intptr(const intptr_t *obj) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return (intptr_t)_Py_atomic_load_ptr((void*)obj); +} + +static inline uintptr_t +_Py_atomic_load_uintptr(const uintptr_t *obj) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return (uintptr_t)_Py_atomic_load_ptr((void*)obj); +} + +static inline Py_ssize_t +_Py_atomic_load_ssize(const Py_ssize_t *obj) +{ + _Py_atomic_ASSERT_ARG_TYPE(void*); + return (Py_ssize_t)_Py_atomic_load_ptr((void*)obj); +} + + +// --- _Py_atomic_load_relaxed ----------------------------------------------- + +static inline int +_Py_atomic_load_int_relaxed(const int *obj) +{ + return *(volatile int *)obj; +} + +static inline int8_t +_Py_atomic_load_int8_relaxed(const int8_t *obj) +{ + return *(volatile int8_t *)obj; +} + +static inline int16_t +_Py_atomic_load_int16_relaxed(const int16_t *obj) +{ + return *(volatile int16_t *)obj; +} + +static inline int32_t +_Py_atomic_load_int32_relaxed(const int32_t *obj) +{ + return *(volatile int32_t *)obj; +} + +static inline int64_t +_Py_atomic_load_int64_relaxed(const int64_t *obj) +{ + return *(volatile int64_t *)obj; +} + +static inline intptr_t +_Py_atomic_load_intptr_relaxed(const intptr_t *obj) +{ + return *(volatile intptr_t *)obj; +} + +static inline uint8_t +_Py_atomic_load_uint8_relaxed(const uint8_t *obj) +{ + return *(volatile uint8_t *)obj; +} + +static inline uint16_t +_Py_atomic_load_uint16_relaxed(const uint16_t *obj) +{ + return *(volatile uint16_t *)obj; +} + +static inline uint32_t +_Py_atomic_load_uint32_relaxed(const uint32_t *obj) +{ + return *(volatile uint32_t *)obj; +} + +static inline uint64_t +_Py_atomic_load_uint64_relaxed(const uint64_t *obj) +{ + return *(volatile uint64_t *)obj; +} + +static inline uintptr_t +_Py_atomic_load_uintptr_relaxed(const uintptr_t *obj) +{ + return *(volatile uintptr_t *)obj; +} + +static inline unsigned int +_Py_atomic_load_uint_relaxed(const unsigned int *obj) +{ + return *(volatile unsigned int *)obj; +} + +static inline Py_ssize_t +_Py_atomic_load_ssize_relaxed(const Py_ssize_t *obj) +{ + return *(volatile Py_ssize_t *)obj; +} + +static inline void* +_Py_atomic_load_ptr_relaxed(const void *obj) +{ + return *(void * volatile *)obj; +} + +static inline unsigned long long +_Py_atomic_load_ullong_relaxed(const unsigned long long *obj) +{ + return *(volatile unsigned long long *)obj; +} + + +// --- _Py_atomic_store ------------------------------------------------------ + +static inline void +_Py_atomic_store_int(int *obj, int value) +{ + (void)_Py_atomic_exchange_int(obj, value); +} + +static inline void +_Py_atomic_store_int8(int8_t *obj, int8_t value) +{ + (void)_Py_atomic_exchange_int8(obj, value); +} + +static inline void +_Py_atomic_store_int16(int16_t *obj, int16_t value) +{ + (void)_Py_atomic_exchange_int16(obj, value); +} + +static inline void +_Py_atomic_store_int32(int32_t *obj, int32_t value) +{ + (void)_Py_atomic_exchange_int32(obj, value); +} + +static inline void +_Py_atomic_store_int64(int64_t *obj, int64_t value) +{ + (void)_Py_atomic_exchange_int64(obj, value); +} + +static inline void +_Py_atomic_store_intptr(intptr_t *obj, intptr_t value) +{ + (void)_Py_atomic_exchange_intptr(obj, value); +} + +static inline void +_Py_atomic_store_uint8(uint8_t *obj, uint8_t value) +{ + (void)_Py_atomic_exchange_uint8(obj, value); +} + +static inline void +_Py_atomic_store_uint16(uint16_t *obj, uint16_t value) +{ + (void)_Py_atomic_exchange_uint16(obj, value); +} + +static inline void +_Py_atomic_store_uint32(uint32_t *obj, uint32_t value) +{ + (void)_Py_atomic_exchange_uint32(obj, value); +} + +static inline void +_Py_atomic_store_uint64(uint64_t *obj, uint64_t value) +{ + (void)_Py_atomic_exchange_uint64(obj, value); +} + +static inline void +_Py_atomic_store_uintptr(uintptr_t *obj, uintptr_t value) +{ + (void)_Py_atomic_exchange_uintptr(obj, value); +} + +static inline void +_Py_atomic_store_uint(unsigned int *obj, unsigned int value) +{ + (void)_Py_atomic_exchange_uint(obj, value); +} + +static inline void +_Py_atomic_store_ptr(void *obj, void *value) +{ + (void)_Py_atomic_exchange_ptr(obj, value); +} + +static inline void +_Py_atomic_store_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ + (void)_Py_atomic_exchange_ssize(obj, value); +} + + +// --- _Py_atomic_store_relaxed ---------------------------------------------- + +static inline void +_Py_atomic_store_int_relaxed(int *obj, int value) +{ + *(volatile int *)obj = value; +} + +static inline void +_Py_atomic_store_int8_relaxed(int8_t *obj, int8_t value) +{ + *(volatile int8_t *)obj = value; +} + +static inline void +_Py_atomic_store_int16_relaxed(int16_t *obj, int16_t value) +{ + *(volatile int16_t *)obj = value; +} + +static inline void +_Py_atomic_store_int32_relaxed(int32_t *obj, int32_t value) +{ + *(volatile int32_t *)obj = value; +} + +static inline void +_Py_atomic_store_int64_relaxed(int64_t *obj, int64_t value) +{ + *(volatile int64_t *)obj = value; +} + +static inline void +_Py_atomic_store_intptr_relaxed(intptr_t *obj, intptr_t value) +{ + *(volatile intptr_t *)obj = value; +} + +static inline void +_Py_atomic_store_uint8_relaxed(uint8_t *obj, uint8_t value) +{ + *(volatile uint8_t *)obj = value; +} + +static inline void +_Py_atomic_store_uint16_relaxed(uint16_t *obj, uint16_t value) +{ + *(volatile uint16_t *)obj = value; +} + +static inline void +_Py_atomic_store_uint32_relaxed(uint32_t *obj, uint32_t value) +{ + *(volatile uint32_t *)obj = value; +} + +static inline void +_Py_atomic_store_uint64_relaxed(uint64_t *obj, uint64_t value) +{ + *(volatile uint64_t *)obj = value; +} + +static inline void +_Py_atomic_store_uintptr_relaxed(uintptr_t *obj, uintptr_t value) +{ + *(volatile uintptr_t *)obj = value; +} + +static inline void +_Py_atomic_store_uint_relaxed(unsigned int *obj, unsigned int value) +{ + *(volatile unsigned int *)obj = value; +} + +static inline void +_Py_atomic_store_ptr_relaxed(void *obj, void* value) +{ + *(void * volatile *)obj = value; +} + +static inline void +_Py_atomic_store_ssize_relaxed(Py_ssize_t *obj, Py_ssize_t value) +{ + *(volatile Py_ssize_t *)obj = value; +} + +static inline void +_Py_atomic_store_ullong_relaxed(unsigned long long *obj, + unsigned long long value) +{ + *(volatile unsigned long long *)obj = value; +} + + +// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ + +static inline void * +_Py_atomic_load_ptr_acquire(const void *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(void * volatile *)obj; +#elif defined(_M_ARM64) + return (void *)__ldar64((unsigned __int64 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_ptr_acquire" +#endif +} + +static inline uintptr_t +_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(uintptr_t volatile *)obj; +#elif defined(_M_ARM64) + return (uintptr_t)__ldar64((unsigned __int64 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_uintptr_acquire" +#endif +} + +static inline void +_Py_atomic_store_ptr_release(void *obj, void *value) +{ +#if defined(_M_X64) || defined(_M_IX86) + *(void * volatile *)obj = value; +#elif defined(_M_ARM64) + __stlr64((unsigned __int64 volatile *)obj, (uintptr_t)value); +#else +# error "no implementation of _Py_atomic_store_ptr_release" +#endif +} + +static inline void +_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) +{ +#if defined(_M_X64) || defined(_M_IX86) + *(uintptr_t volatile *)obj = value; +#elif defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(unsigned __int64); + __stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value); +#else +# error "no implementation of _Py_atomic_store_uintptr_release" +#endif +} + +static inline void +_Py_atomic_store_int_release(int *obj, int value) +{ +#if defined(_M_X64) || defined(_M_IX86) + *(int volatile *)obj = value; +#elif defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(unsigned __int32); + __stlr32((unsigned __int32 volatile *)obj, (unsigned __int32)value); +#else +# error "no implementation of _Py_atomic_store_int_release" +#endif +} + +static inline void +_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value) +{ +#if defined(_M_X64) || defined(_M_IX86) + *(Py_ssize_t volatile *)obj = value; +#elif defined(_M_ARM64) + __stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value); +#else +# error "no implementation of _Py_atomic_store_ssize_release" +#endif +} + +static inline int +_Py_atomic_load_int_acquire(const int *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(int volatile *)obj; +#elif defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(unsigned __int32); + return (int)__ldar32((unsigned __int32 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_int_acquire" +#endif +} + +static inline void +_Py_atomic_store_uint32_release(uint32_t *obj, uint32_t value) +{ +#if defined(_M_X64) || defined(_M_IX86) + *(uint32_t volatile *)obj = value; +#elif defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(unsigned __int32); + __stlr32((unsigned __int32 volatile *)obj, (unsigned __int32)value); +#else +# error "no implementation of _Py_atomic_store_uint32_release" +#endif +} + +static inline void +_Py_atomic_store_uint64_release(uint64_t *obj, uint64_t value) +{ +#if defined(_M_X64) || defined(_M_IX86) + *(uint64_t volatile *)obj = value; +#elif defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(unsigned __int64); + __stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value); +#else +# error "no implementation of _Py_atomic_store_uint64_release" +#endif +} + +static inline uint64_t +_Py_atomic_load_uint64_acquire(const uint64_t *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(uint64_t volatile *)obj; +#elif defined(_M_ARM64) + _Py_atomic_ASSERT_ARG_TYPE(__int64); + return (uint64_t)__ldar64((unsigned __int64 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_uint64_acquire" +#endif +} + +static inline uint32_t +_Py_atomic_load_uint32_acquire(const uint32_t *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(uint32_t volatile *)obj; +#elif defined(_M_ARM64) + return (uint32_t)__ldar32((uint32_t volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_uint32_acquire" +#endif +} + +static inline Py_ssize_t +_Py_atomic_load_ssize_acquire(const Py_ssize_t *obj) +{ +#if defined(_M_X64) || defined(_M_IX86) + return *(Py_ssize_t volatile *)obj; +#elif defined(_M_ARM64) + return (Py_ssize_t)__ldar64((unsigned __int64 volatile *)obj); +#else +# error "no implementation of _Py_atomic_load_ssize_acquire" +#endif +} + +// --- _Py_atomic_fence ------------------------------------------------------ + + static inline void +_Py_atomic_fence_seq_cst(void) +{ +#if defined(_M_ARM64) + __dmb(_ARM64_BARRIER_ISH); +#elif defined(_M_X64) + __faststorefence(); +#elif defined(_M_IX86) + _mm_mfence(); +#else +# error "no implementation of _Py_atomic_fence_seq_cst" +#endif +} + + static inline void +_Py_atomic_fence_acquire(void) +{ +#if defined(_M_ARM64) + __dmb(_ARM64_BARRIER_ISHLD); +#elif defined(_M_X64) || defined(_M_IX86) + _ReadBarrier(); +#else +# error "no implementation of _Py_atomic_fence_acquire" +#endif +} + + static inline void +_Py_atomic_fence_release(void) +{ +#if defined(_M_ARM64) + __dmb(_ARM64_BARRIER_ISH); +#elif defined(_M_X64) || defined(_M_IX86) + _ReadWriteBarrier(); +#else +# error "no implementation of _Py_atomic_fence_release" +#endif +} + +#undef _Py_atomic_ASSERT_ARG_TYPE diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_std.h b/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_std.h new file mode 100644 index 00000000..7c71e94c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyatomic_std.h @@ -0,0 +1,976 @@ +// This is the implementation of Python atomic operations using C++11 or C11 +// atomics. Note that the pyatomic_gcc.h implementation is preferred for GCC +// compatible compilers, even if they support C++11 atomics. + +#ifndef Py_ATOMIC_STD_H +# error "this header file must not be included directly" +#endif + +#ifdef __cplusplus +extern "C++" { +# include +} +# define _Py_USING_STD using namespace std +# define _Atomic(tp) atomic +#else +# define _Py_USING_STD +# include +#endif + + +// --- _Py_atomic_add -------------------------------------------------------- + +static inline int +_Py_atomic_add_int(int *obj, int value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(int)*)obj, value); +} + +static inline int8_t +_Py_atomic_add_int8(int8_t *obj, int8_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(int8_t)*)obj, value); +} + +static inline int16_t +_Py_atomic_add_int16(int16_t *obj, int16_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(int16_t)*)obj, value); +} + +static inline int32_t +_Py_atomic_add_int32(int32_t *obj, int32_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(int32_t)*)obj, value); +} + +static inline int64_t +_Py_atomic_add_int64(int64_t *obj, int64_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(int64_t)*)obj, value); +} + +static inline intptr_t +_Py_atomic_add_intptr(intptr_t *obj, intptr_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(intptr_t)*)obj, value); +} + +static inline unsigned int +_Py_atomic_add_uint(unsigned int *obj, unsigned int value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(unsigned int)*)obj, value); +} + +static inline uint8_t +_Py_atomic_add_uint8(uint8_t *obj, uint8_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(uint8_t)*)obj, value); +} + +static inline uint16_t +_Py_atomic_add_uint16(uint16_t *obj, uint16_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(uint16_t)*)obj, value); +} + +static inline uint32_t +_Py_atomic_add_uint32(uint32_t *obj, uint32_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(uint32_t)*)obj, value); +} + +static inline uint64_t +_Py_atomic_add_uint64(uint64_t *obj, uint64_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(uint64_t)*)obj, value); +} + +static inline uintptr_t +_Py_atomic_add_uintptr(uintptr_t *obj, uintptr_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(uintptr_t)*)obj, value); +} + +static inline Py_ssize_t +_Py_atomic_add_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ + _Py_USING_STD; + return atomic_fetch_add((_Atomic(Py_ssize_t)*)obj, value); +} + + +// --- _Py_atomic_compare_exchange ------------------------------------------- + +static inline int +_Py_atomic_compare_exchange_int(int *obj, int *expected, int desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(int)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_int8(int8_t *obj, int8_t *expected, int8_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(int8_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_int16(int16_t *obj, int16_t *expected, int16_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(int16_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_int32(int32_t *obj, int32_t *expected, int32_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(int32_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_int64(int64_t *obj, int64_t *expected, int64_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(int64_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_intptr(intptr_t *obj, intptr_t *expected, intptr_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(intptr_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_uint(unsigned int *obj, unsigned int *expected, unsigned int desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(unsigned int)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_uint8(uint8_t *obj, uint8_t *expected, uint8_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(uint8_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_uint16(uint16_t *obj, uint16_t *expected, uint16_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(uint16_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_uint32(uint32_t *obj, uint32_t *expected, uint32_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(uint32_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_uint64(uint64_t *obj, uint64_t *expected, uint64_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(uint64_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_uintptr(uintptr_t *obj, uintptr_t *expected, uintptr_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(uintptr_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_ssize(Py_ssize_t *obj, Py_ssize_t *expected, Py_ssize_t desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(Py_ssize_t)*)obj, + expected, desired); +} + +static inline int +_Py_atomic_compare_exchange_ptr(void *obj, void *expected, void *desired) +{ + _Py_USING_STD; + return atomic_compare_exchange_strong((_Atomic(void *)*)obj, + (void **)expected, desired); +} + + +// --- _Py_atomic_exchange --------------------------------------------------- + +static inline int +_Py_atomic_exchange_int(int *obj, int value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(int)*)obj, value); +} + +static inline int8_t +_Py_atomic_exchange_int8(int8_t *obj, int8_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(int8_t)*)obj, value); +} + +static inline int16_t +_Py_atomic_exchange_int16(int16_t *obj, int16_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(int16_t)*)obj, value); +} + +static inline int32_t +_Py_atomic_exchange_int32(int32_t *obj, int32_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(int32_t)*)obj, value); +} + +static inline int64_t +_Py_atomic_exchange_int64(int64_t *obj, int64_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(int64_t)*)obj, value); +} + +static inline intptr_t +_Py_atomic_exchange_intptr(intptr_t *obj, intptr_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(intptr_t)*)obj, value); +} + +static inline unsigned int +_Py_atomic_exchange_uint(unsigned int *obj, unsigned int value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(unsigned int)*)obj, value); +} + +static inline uint8_t +_Py_atomic_exchange_uint8(uint8_t *obj, uint8_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(uint8_t)*)obj, value); +} + +static inline uint16_t +_Py_atomic_exchange_uint16(uint16_t *obj, uint16_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(uint16_t)*)obj, value); +} + +static inline uint32_t +_Py_atomic_exchange_uint32(uint32_t *obj, uint32_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(uint32_t)*)obj, value); +} + +static inline uint64_t +_Py_atomic_exchange_uint64(uint64_t *obj, uint64_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(uint64_t)*)obj, value); +} + +static inline uintptr_t +_Py_atomic_exchange_uintptr(uintptr_t *obj, uintptr_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(uintptr_t)*)obj, value); +} + +static inline Py_ssize_t +_Py_atomic_exchange_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(Py_ssize_t)*)obj, value); +} + +static inline void* +_Py_atomic_exchange_ptr(void *obj, void *value) +{ + _Py_USING_STD; + return atomic_exchange((_Atomic(void *)*)obj, value); +} + + +// --- _Py_atomic_and -------------------------------------------------------- + +static inline uint8_t +_Py_atomic_and_uint8(uint8_t *obj, uint8_t value) +{ + _Py_USING_STD; + return atomic_fetch_and((_Atomic(uint8_t)*)obj, value); +} + +static inline uint16_t +_Py_atomic_and_uint16(uint16_t *obj, uint16_t value) +{ + _Py_USING_STD; + return atomic_fetch_and((_Atomic(uint16_t)*)obj, value); +} + +static inline uint32_t +_Py_atomic_and_uint32(uint32_t *obj, uint32_t value) +{ + _Py_USING_STD; + return atomic_fetch_and((_Atomic(uint32_t)*)obj, value); +} + +static inline uint64_t +_Py_atomic_and_uint64(uint64_t *obj, uint64_t value) +{ + _Py_USING_STD; + return atomic_fetch_and((_Atomic(uint64_t)*)obj, value); +} + +static inline uintptr_t +_Py_atomic_and_uintptr(uintptr_t *obj, uintptr_t value) +{ + _Py_USING_STD; + return atomic_fetch_and((_Atomic(uintptr_t)*)obj, value); +} + + +// --- _Py_atomic_or --------------------------------------------------------- + +static inline uint8_t +_Py_atomic_or_uint8(uint8_t *obj, uint8_t value) +{ + _Py_USING_STD; + return atomic_fetch_or((_Atomic(uint8_t)*)obj, value); +} + +static inline uint16_t +_Py_atomic_or_uint16(uint16_t *obj, uint16_t value) +{ + _Py_USING_STD; + return atomic_fetch_or((_Atomic(uint16_t)*)obj, value); +} + +static inline uint32_t +_Py_atomic_or_uint32(uint32_t *obj, uint32_t value) +{ + _Py_USING_STD; + return atomic_fetch_or((_Atomic(uint32_t)*)obj, value); +} + +static inline uint64_t +_Py_atomic_or_uint64(uint64_t *obj, uint64_t value) +{ + _Py_USING_STD; + return atomic_fetch_or((_Atomic(uint64_t)*)obj, value); +} + +static inline uintptr_t +_Py_atomic_or_uintptr(uintptr_t *obj, uintptr_t value) +{ + _Py_USING_STD; + return atomic_fetch_or((_Atomic(uintptr_t)*)obj, value); +} + + +// --- _Py_atomic_load ------------------------------------------------------- + +static inline int +_Py_atomic_load_int(const int *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(int)*)obj); +} + +static inline int8_t +_Py_atomic_load_int8(const int8_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(int8_t)*)obj); +} + +static inline int16_t +_Py_atomic_load_int16(const int16_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(int16_t)*)obj); +} + +static inline int32_t +_Py_atomic_load_int32(const int32_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(int32_t)*)obj); +} + +static inline int64_t +_Py_atomic_load_int64(const int64_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(int64_t)*)obj); +} + +static inline intptr_t +_Py_atomic_load_intptr(const intptr_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(intptr_t)*)obj); +} + +static inline uint8_t +_Py_atomic_load_uint8(const uint8_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(uint8_t)*)obj); +} + +static inline uint16_t +_Py_atomic_load_uint16(const uint16_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(uint32_t)*)obj); +} + +static inline uint32_t +_Py_atomic_load_uint32(const uint32_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(uint32_t)*)obj); +} + +static inline uint64_t +_Py_atomic_load_uint64(const uint64_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(uint64_t)*)obj); +} + +static inline uintptr_t +_Py_atomic_load_uintptr(const uintptr_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(uintptr_t)*)obj); +} + +static inline unsigned int +_Py_atomic_load_uint(const unsigned int *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(unsigned int)*)obj); +} + +static inline Py_ssize_t +_Py_atomic_load_ssize(const Py_ssize_t *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(Py_ssize_t)*)obj); +} + +static inline void* +_Py_atomic_load_ptr(const void *obj) +{ + _Py_USING_STD; + return atomic_load((const _Atomic(void*)*)obj); +} + + +// --- _Py_atomic_load_relaxed ----------------------------------------------- + +static inline int +_Py_atomic_load_int_relaxed(const int *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(int)*)obj, + memory_order_relaxed); +} + +static inline int8_t +_Py_atomic_load_int8_relaxed(const int8_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(int8_t)*)obj, + memory_order_relaxed); +} + +static inline int16_t +_Py_atomic_load_int16_relaxed(const int16_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(int16_t)*)obj, + memory_order_relaxed); +} + +static inline int32_t +_Py_atomic_load_int32_relaxed(const int32_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(int32_t)*)obj, + memory_order_relaxed); +} + +static inline int64_t +_Py_atomic_load_int64_relaxed(const int64_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(int64_t)*)obj, + memory_order_relaxed); +} + +static inline intptr_t +_Py_atomic_load_intptr_relaxed(const intptr_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(intptr_t)*)obj, + memory_order_relaxed); +} + +static inline uint8_t +_Py_atomic_load_uint8_relaxed(const uint8_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(uint8_t)*)obj, + memory_order_relaxed); +} + +static inline uint16_t +_Py_atomic_load_uint16_relaxed(const uint16_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(uint16_t)*)obj, + memory_order_relaxed); +} + +static inline uint32_t +_Py_atomic_load_uint32_relaxed(const uint32_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(uint32_t)*)obj, + memory_order_relaxed); +} + +static inline uint64_t +_Py_atomic_load_uint64_relaxed(const uint64_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(uint64_t)*)obj, + memory_order_relaxed); +} + +static inline uintptr_t +_Py_atomic_load_uintptr_relaxed(const uintptr_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(uintptr_t)*)obj, + memory_order_relaxed); +} + +static inline unsigned int +_Py_atomic_load_uint_relaxed(const unsigned int *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(unsigned int)*)obj, + memory_order_relaxed); +} + +static inline Py_ssize_t +_Py_atomic_load_ssize_relaxed(const Py_ssize_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(Py_ssize_t)*)obj, + memory_order_relaxed); +} + +static inline void* +_Py_atomic_load_ptr_relaxed(const void *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(void*)*)obj, + memory_order_relaxed); +} + +static inline unsigned long long +_Py_atomic_load_ullong_relaxed(const unsigned long long *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(unsigned long long)*)obj, + memory_order_relaxed); +} + + +// --- _Py_atomic_store ------------------------------------------------------ + +static inline void +_Py_atomic_store_int(int *obj, int value) +{ + _Py_USING_STD; + atomic_store((_Atomic(int)*)obj, value); +} + +static inline void +_Py_atomic_store_int8(int8_t *obj, int8_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(int8_t)*)obj, value); +} + +static inline void +_Py_atomic_store_int16(int16_t *obj, int16_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(int16_t)*)obj, value); +} + +static inline void +_Py_atomic_store_int32(int32_t *obj, int32_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(int32_t)*)obj, value); +} + +static inline void +_Py_atomic_store_int64(int64_t *obj, int64_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(int64_t)*)obj, value); +} + +static inline void +_Py_atomic_store_intptr(intptr_t *obj, intptr_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(intptr_t)*)obj, value); +} + +static inline void +_Py_atomic_store_uint8(uint8_t *obj, uint8_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(uint8_t)*)obj, value); +} + +static inline void +_Py_atomic_store_uint16(uint16_t *obj, uint16_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(uint16_t)*)obj, value); +} + +static inline void +_Py_atomic_store_uint32(uint32_t *obj, uint32_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(uint32_t)*)obj, value); +} + +static inline void +_Py_atomic_store_uint64(uint64_t *obj, uint64_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(uint64_t)*)obj, value); +} + +static inline void +_Py_atomic_store_uintptr(uintptr_t *obj, uintptr_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(uintptr_t)*)obj, value); +} + +static inline void +_Py_atomic_store_uint(unsigned int *obj, unsigned int value) +{ + _Py_USING_STD; + atomic_store((_Atomic(unsigned int)*)obj, value); +} + +static inline void +_Py_atomic_store_ptr(void *obj, void *value) +{ + _Py_USING_STD; + atomic_store((_Atomic(void*)*)obj, value); +} + +static inline void +_Py_atomic_store_ssize(Py_ssize_t *obj, Py_ssize_t value) +{ + _Py_USING_STD; + atomic_store((_Atomic(Py_ssize_t)*)obj, value); +} + + +// --- _Py_atomic_store_relaxed ---------------------------------------------- + +static inline void +_Py_atomic_store_int_relaxed(int *obj, int value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(int)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_int8_relaxed(int8_t *obj, int8_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(int8_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_int16_relaxed(int16_t *obj, int16_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(int16_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_int32_relaxed(int32_t *obj, int32_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(int32_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_int64_relaxed(int64_t *obj, int64_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(int64_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_intptr_relaxed(intptr_t *obj, intptr_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(intptr_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_uint8_relaxed(uint8_t *obj, uint8_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(uint8_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_uint16_relaxed(uint16_t *obj, uint16_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(uint16_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_uint32_relaxed(uint32_t *obj, uint32_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(uint32_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_uint64_relaxed(uint64_t *obj, uint64_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(uint64_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_uintptr_relaxed(uintptr_t *obj, uintptr_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(uintptr_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_uint_relaxed(unsigned int *obj, unsigned int value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(unsigned int)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_ptr_relaxed(void *obj, void *value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(void*)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_ssize_relaxed(Py_ssize_t *obj, Py_ssize_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(Py_ssize_t)*)obj, value, + memory_order_relaxed); +} + +static inline void +_Py_atomic_store_ullong_relaxed(unsigned long long *obj, + unsigned long long value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(unsigned long long)*)obj, value, + memory_order_relaxed); +} + + +// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ + +static inline void * +_Py_atomic_load_ptr_acquire(const void *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(void*)*)obj, + memory_order_acquire); +} + +static inline uintptr_t +_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(uintptr_t)*)obj, + memory_order_acquire); +} + +static inline void +_Py_atomic_store_ptr_release(void *obj, void *value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(void*)*)obj, value, + memory_order_release); +} + +static inline void +_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(uintptr_t)*)obj, value, + memory_order_release); +} + +static inline void +_Py_atomic_store_int_release(int *obj, int value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(int)*)obj, value, + memory_order_release); +} + +static inline void +_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(Py_ssize_t)*)obj, value, + memory_order_release); +} + +static inline int +_Py_atomic_load_int_acquire(const int *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(int)*)obj, + memory_order_acquire); +} + +static inline void +_Py_atomic_store_uint32_release(uint32_t *obj, uint32_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(uint32_t)*)obj, value, + memory_order_release); +} + +static inline void +_Py_atomic_store_uint64_release(uint64_t *obj, uint64_t value) +{ + _Py_USING_STD; + atomic_store_explicit((_Atomic(uint64_t)*)obj, value, + memory_order_release); +} + +static inline uint64_t +_Py_atomic_load_uint64_acquire(const uint64_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(uint64_t)*)obj, + memory_order_acquire); +} + +static inline uint32_t +_Py_atomic_load_uint32_acquire(const uint32_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(uint32_t)*)obj, + memory_order_acquire); +} + +static inline Py_ssize_t +_Py_atomic_load_ssize_acquire(const Py_ssize_t *obj) +{ + _Py_USING_STD; + return atomic_load_explicit((const _Atomic(Py_ssize_t)*)obj, + memory_order_acquire); +} + + +// --- _Py_atomic_fence ------------------------------------------------------ + + static inline void +_Py_atomic_fence_seq_cst(void) +{ + _Py_USING_STD; + atomic_thread_fence(memory_order_seq_cst); +} + + static inline void +_Py_atomic_fence_acquire(void) +{ + _Py_USING_STD; + atomic_thread_fence(memory_order_acquire); +} + + static inline void +_Py_atomic_fence_release(void) +{ + _Py_USING_STD; + atomic_thread_fence(memory_order_release); +} diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyctype.h b/illumos-x86_64/usr/include/python3.13/cpython/pyctype.h new file mode 100644 index 00000000..729d9327 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyctype.h @@ -0,0 +1,39 @@ +#ifndef Py_LIMITED_API +#ifndef PYCTYPE_H +#define PYCTYPE_H +#ifdef __cplusplus +extern "C" { +#endif + +#define PY_CTF_LOWER 0x01 +#define PY_CTF_UPPER 0x02 +#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER) +#define PY_CTF_DIGIT 0x04 +#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT) +#define PY_CTF_SPACE 0x08 +#define PY_CTF_XDIGIT 0x10 + +PyAPI_DATA(const unsigned int) _Py_ctype_table[256]; + +/* Unlike their C counterparts, the following macros are not meant to + * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument + * must be a signed/unsigned char. */ +#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER) +#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER) +#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA) +#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT) +#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT) +#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM) +#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE) + +PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256]; +PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256]; + +#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) +#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) + +#ifdef __cplusplus +} +#endif +#endif /* !PYCTYPE_H */ +#endif /* !Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pydebug.h b/illumos-x86_64/usr/include/python3.13/cpython/pydebug.h new file mode 100644 index 00000000..f6ebd99e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pydebug.h @@ -0,0 +1,38 @@ +#ifndef Py_LIMITED_API +#ifndef Py_PYDEBUG_H +#define Py_PYDEBUG_H +#ifdef __cplusplus +extern "C" { +#endif + +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_DebugFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_VerboseFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_QuietFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_InteractiveFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_InspectFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_OptimizeFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_NoSiteFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_BytesWarningFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_FrozenFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_IgnoreEnvironmentFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_DontWriteBytecodeFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_NoUserSiteDirectory; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_UnbufferedStdioFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_HashRandomizationFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_IsolatedFlag; + +#ifdef MS_WINDOWS +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_LegacyWindowsFSEncodingFlag; +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_LegacyWindowsStdioFlag; +#endif + +/* this is a wrapper around getenv() that pays attention to + Py_IgnoreEnvironmentFlag. It should be used for getting variables like + PYTHONPATH and PYTHONHOME from the environment */ +PyAPI_FUNC(char*) Py_GETENV(const char *name); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYDEBUG_H */ +#endif /* Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyerrors.h b/illumos-x86_64/usr/include/python3.13/cpython/pyerrors.h new file mode 100644 index 00000000..b36b4681 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyerrors.h @@ -0,0 +1,131 @@ +#ifndef Py_CPYTHON_ERRORS_H +# error "this header file must not be included directly" +#endif + +/* Error objects */ + +/* PyException_HEAD defines the initial segment of every exception class. */ +#define PyException_HEAD PyObject_HEAD PyObject *dict;\ + PyObject *args; PyObject *notes; PyObject *traceback;\ + PyObject *context; PyObject *cause;\ + char suppress_context; + +typedef struct { + PyException_HEAD +} PyBaseExceptionObject; + +typedef struct { + PyException_HEAD + PyObject *msg; + PyObject *excs; +} PyBaseExceptionGroupObject; + +typedef struct { + PyException_HEAD + PyObject *msg; + PyObject *filename; + PyObject *lineno; + PyObject *offset; + PyObject *end_lineno; + PyObject *end_offset; + PyObject *text; + PyObject *print_file_and_line; +} PySyntaxErrorObject; + +typedef struct { + PyException_HEAD + PyObject *msg; + PyObject *name; + PyObject *path; + PyObject *name_from; +} PyImportErrorObject; + +typedef struct { + PyException_HEAD + PyObject *encoding; + PyObject *object; + Py_ssize_t start; + Py_ssize_t end; + PyObject *reason; +} PyUnicodeErrorObject; + +typedef struct { + PyException_HEAD + PyObject *code; +} PySystemExitObject; + +typedef struct { + PyException_HEAD + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; + PyObject *filename2; +#ifdef MS_WINDOWS + PyObject *winerror; +#endif + Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */ +} PyOSErrorObject; + +typedef struct { + PyException_HEAD + PyObject *value; +} PyStopIterationObject; + +typedef struct { + PyException_HEAD + PyObject *name; +} PyNameErrorObject; + +typedef struct { + PyException_HEAD + PyObject *obj; + PyObject *name; +} PyAttributeErrorObject; + +/* Compatibility typedefs */ +typedef PyOSErrorObject PyEnvironmentErrorObject; +#ifdef MS_WINDOWS +typedef PyOSErrorObject PyWindowsErrorObject; +#endif + +/* Context manipulation (PEP 3134) */ + +PyAPI_FUNC(void) _PyErr_ChainExceptions1(PyObject *); + +/* In exceptions.c */ + +PyAPI_FUNC(PyObject*) PyUnstable_Exc_PrepReraiseStar( + PyObject *orig, + PyObject *excs); + +/* In signalmodule.c */ + +PyAPI_FUNC(int) PySignal_SetWakeupFd(int fd); + +/* Support for adding program text to SyntaxErrors */ + +PyAPI_FUNC(void) PyErr_SyntaxLocationObject( + PyObject *filename, + int lineno, + int col_offset); + +PyAPI_FUNC(void) PyErr_RangedSyntaxLocationObject( + PyObject *filename, + int lineno, + int col_offset, + int end_lineno, + int end_col_offset); + +PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject( + PyObject *filename, + int lineno); + +PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFunc( + const char *func, + const char *message); + +PyAPI_FUNC(void) PyErr_FormatUnraisable(const char *, ...); + +PyAPI_DATA(PyObject *) PyExc_PythonFinalizationError; + +#define Py_FatalError(message) _Py_FatalErrorFunc(__func__, (message)) diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyfpe.h b/illumos-x86_64/usr/include/python3.13/cpython/pyfpe.h new file mode 100644 index 00000000..cc2def63 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyfpe.h @@ -0,0 +1,15 @@ +#ifndef Py_PYFPE_H +#define Py_PYFPE_H +/* Header excluded from the stable API */ +#ifndef Py_LIMITED_API + +/* These macros used to do something when Python was built with --with-fpectl, + * but support for that was dropped in 3.7. We continue to define them though, + * to avoid breaking API users. + */ + +#define PyFPE_START_PROTECT(err_string, leave_stmt) +#define PyFPE_END_PROTECT(v) + +#endif /* !defined(Py_LIMITED_API) */ +#endif /* !Py_PYFPE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyframe.h b/illumos-x86_64/usr/include/python3.13/cpython/pyframe.h new file mode 100644 index 00000000..eeafbb17 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyframe.h @@ -0,0 +1,45 @@ +#ifndef Py_CPYTHON_PYFRAME_H +# error "this header file must not be included directly" +#endif + +PyAPI_DATA(PyTypeObject) PyFrame_Type; +PyAPI_DATA(PyTypeObject) PyFrameLocalsProxy_Type; + +#define PyFrame_Check(op) Py_IS_TYPE((op), &PyFrame_Type) +#define PyFrameLocalsProxy_Check(op) Py_IS_TYPE((op), &PyFrameLocalsProxy_Type) + +PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame); +PyAPI_FUNC(PyObject *) PyFrame_GetLocals(PyFrameObject *frame); + +PyAPI_FUNC(PyObject *) PyFrame_GetGlobals(PyFrameObject *frame); +PyAPI_FUNC(PyObject *) PyFrame_GetBuiltins(PyFrameObject *frame); + +PyAPI_FUNC(PyObject *) PyFrame_GetGenerator(PyFrameObject *frame); +PyAPI_FUNC(int) PyFrame_GetLasti(PyFrameObject *frame); +PyAPI_FUNC(PyObject*) PyFrame_GetVar(PyFrameObject *frame, PyObject *name); +PyAPI_FUNC(PyObject*) PyFrame_GetVarString(PyFrameObject *frame, const char *name); + +/* The following functions are for use by debuggers and other tools + * implementing custom frame evaluators with PEP 523. */ + +struct _PyInterpreterFrame; + +/* Returns the code object of the frame (strong reference). + * Does not raise an exception. */ +PyAPI_FUNC(PyObject *) PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame); + +/* Returns a byte ofsset into the last executed instruction. + * Does not raise an exception. */ +PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame *frame); + +/* Returns the currently executing line number, or -1 if there is no line number. + * Does not raise an exception. */ +PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrame *frame); + +#define PyUnstable_EXECUTABLE_KIND_SKIP 0 +#define PyUnstable_EXECUTABLE_KIND_PY_FUNCTION 1 +#define PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION 3 +#define PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR 4 +#define PyUnstable_EXECUTABLE_KINDS 5 + +PyAPI_DATA(const PyTypeObject *) const PyUnstable_ExecutableKinds[PyUnstable_EXECUTABLE_KINDS+1]; diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pyhash.h b/illumos-x86_64/usr/include/python3.13/cpython/pyhash.h new file mode 100644 index 00000000..825c034a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pyhash.h @@ -0,0 +1,47 @@ +#ifndef Py_CPYTHON_HASH_H +# error "this header file must not be included directly" +#endif + +/* Prime multiplier used in string and various other hashes. */ +#define PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */ + +/* Parameters used for the numeric hash implementation. See notes for + _Py_HashDouble in Python/pyhash.c. Numeric hashes are based on + reduction modulo the prime 2**_PyHASH_BITS - 1. */ + +#if SIZEOF_VOID_P >= 8 +# define PyHASH_BITS 61 +#else +# define PyHASH_BITS 31 +#endif + +#define PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1) +#define PyHASH_INF 314159 +#define PyHASH_IMAG PyHASH_MULTIPLIER + +/* Aliases kept for backward compatibility with Python 3.12 */ +#define _PyHASH_MULTIPLIER PyHASH_MULTIPLIER +#define _PyHASH_BITS PyHASH_BITS +#define _PyHASH_MODULUS PyHASH_MODULUS +#define _PyHASH_INF PyHASH_INF +#define _PyHASH_IMAG PyHASH_IMAG + +/* Helpers for hash functions */ +PyAPI_FUNC(Py_hash_t) _Py_HashDouble(PyObject *, double); + +// Kept for backward compatibility +#define _Py_HashPointer Py_HashPointer + + +/* hash function definition */ +typedef struct { + Py_hash_t (*const hash)(const void *, Py_ssize_t); + const char *name; + const int hash_bits; + const int seed_bits; +} PyHash_FuncDef; + +PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void); + +PyAPI_FUNC(Py_hash_t) Py_HashPointer(const void *ptr); +PyAPI_FUNC(Py_hash_t) PyObject_GenericHash(PyObject *); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pylifecycle.h b/illumos-x86_64/usr/include/python3.13/cpython/pylifecycle.h new file mode 100644 index 00000000..e46dfe59 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pylifecycle.h @@ -0,0 +1,92 @@ +#ifndef Py_CPYTHON_PYLIFECYCLE_H +# error "this header file must not be included directly" +#endif + +/* Py_FrozenMain is kept out of the Limited API until documented and present + in all builds of Python */ +PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv); + +/* PEP 432 Multi-phase initialization API (Private while provisional!) */ + +PyAPI_FUNC(PyStatus) Py_PreInitialize( + const PyPreConfig *src_config); +PyAPI_FUNC(PyStatus) Py_PreInitializeFromBytesArgs( + const PyPreConfig *src_config, + Py_ssize_t argc, + char **argv); +PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs( + const PyPreConfig *src_config, + Py_ssize_t argc, + wchar_t **argv); + + +/* Initialization and finalization */ + +PyAPI_FUNC(PyStatus) Py_InitializeFromConfig( + const PyConfig *config); + +// Python 3.8 provisional API (PEP 587) +PyAPI_FUNC(PyStatus) _Py_InitializeMain(void); + +PyAPI_FUNC(int) Py_RunMain(void); + + +PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err); + +PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); + +/* --- PyInterpreterConfig ------------------------------------ */ + +#define PyInterpreterConfig_DEFAULT_GIL (0) +#define PyInterpreterConfig_SHARED_GIL (1) +#define PyInterpreterConfig_OWN_GIL (2) + +typedef struct { + // XXX "allow_object_sharing"? "own_objects"? + int use_main_obmalloc; + int allow_fork; + int allow_exec; + int allow_threads; + int allow_daemon_threads; + int check_multi_interp_extensions; + int gil; +} PyInterpreterConfig; + +#define _PyInterpreterConfig_INIT \ + { \ + .use_main_obmalloc = 0, \ + .allow_fork = 0, \ + .allow_exec = 0, \ + .allow_threads = 1, \ + .allow_daemon_threads = 0, \ + .check_multi_interp_extensions = 1, \ + .gil = PyInterpreterConfig_OWN_GIL, \ + } + +// gh-117649: The free-threaded build does not currently support single-phase +// init extensions in subinterpreters. For now, we ensure that +// `check_multi_interp_extensions` is always `1`, even in the legacy config. +#ifdef Py_GIL_DISABLED +# define _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS 1 +#else +# define _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS 0 +#endif + +#define _PyInterpreterConfig_LEGACY_INIT \ + { \ + .use_main_obmalloc = 1, \ + .allow_fork = 1, \ + .allow_exec = 1, \ + .allow_threads = 1, \ + .allow_daemon_threads = 1, \ + .check_multi_interp_extensions = _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS, \ + .gil = PyInterpreterConfig_SHARED_GIL, \ + } + +PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig( + PyThreadState **tstate_p, + const PyInterpreterConfig *config); + +typedef void (*atexit_datacallbackfunc)(void *); +PyAPI_FUNC(int) PyUnstable_AtExit( + PyInterpreterState *, atexit_datacallbackfunc, void *); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pymem.h b/illumos-x86_64/usr/include/python3.13/cpython/pymem.h new file mode 100644 index 00000000..76b3221f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pymem.h @@ -0,0 +1,84 @@ +#ifndef Py_CPYTHON_PYMEM_H +# error "this header file must not be included directly" +#endif + +typedef enum { + /* PyMem_RawMalloc(), PyMem_RawRealloc() and PyMem_RawFree() */ + PYMEM_DOMAIN_RAW, + + /* PyMem_Malloc(), PyMem_Realloc() and PyMem_Free() */ + PYMEM_DOMAIN_MEM, + + /* PyObject_Malloc(), PyObject_Realloc() and PyObject_Free() */ + PYMEM_DOMAIN_OBJ +} PyMemAllocatorDomain; + +typedef enum { + PYMEM_ALLOCATOR_NOT_SET = 0, + PYMEM_ALLOCATOR_DEFAULT = 1, + PYMEM_ALLOCATOR_DEBUG = 2, + PYMEM_ALLOCATOR_MALLOC = 3, + PYMEM_ALLOCATOR_MALLOC_DEBUG = 4, +#ifdef WITH_PYMALLOC + PYMEM_ALLOCATOR_PYMALLOC = 5, + PYMEM_ALLOCATOR_PYMALLOC_DEBUG = 6, +#endif +#ifdef WITH_MIMALLOC + PYMEM_ALLOCATOR_MIMALLOC = 7, + PYMEM_ALLOCATOR_MIMALLOC_DEBUG = 8, +#endif +} PyMemAllocatorName; + + +typedef struct { + /* user context passed as the first argument to the 4 functions */ + void *ctx; + + /* allocate a memory block */ + void* (*malloc) (void *ctx, size_t size); + + /* allocate a memory block initialized by zeros */ + void* (*calloc) (void *ctx, size_t nelem, size_t elsize); + + /* allocate or resize a memory block */ + void* (*realloc) (void *ctx, void *ptr, size_t new_size); + + /* release a memory block */ + void (*free) (void *ctx, void *ptr); +} PyMemAllocatorEx; + +/* Get the memory block allocator of the specified domain. */ +PyAPI_FUNC(void) PyMem_GetAllocator(PyMemAllocatorDomain domain, + PyMemAllocatorEx *allocator); + +/* Set the memory block allocator of the specified domain. + + The new allocator must return a distinct non-NULL pointer when requesting + zero bytes. + + For the PYMEM_DOMAIN_RAW domain, the allocator must be thread-safe: the GIL + is not held when the allocator is called. + + If the new allocator is not a hook (don't call the previous allocator), the + PyMem_SetupDebugHooks() function must be called to reinstall the debug hooks + on top on the new allocator. */ +PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain, + PyMemAllocatorEx *allocator); + +/* Setup hooks to detect bugs in the following Python memory allocator + functions: + + - PyMem_RawMalloc(), PyMem_RawRealloc(), PyMem_RawFree() + - PyMem_Malloc(), PyMem_Realloc(), PyMem_Free() + - PyObject_Malloc(), PyObject_Realloc() and PyObject_Free() + + Newly allocated memory is filled with the byte 0xCB, freed memory is filled + with the byte 0xDB. Additional checks: + + - detect API violations, ex: PyObject_Free() called on a buffer allocated + by PyMem_Malloc() + - detect write before the start of the buffer (buffer underflow) + - detect write after the end of the buffer (buffer overflow) + + The function does nothing if Python is not compiled is debug mode. */ +PyAPI_FUNC(void) PyMem_SetupDebugHooks(void); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pystate.h b/illumos-x86_64/usr/include/python3.13/cpython/pystate.h new file mode 100644 index 00000000..f005729f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pystate.h @@ -0,0 +1,277 @@ +#ifndef Py_CPYTHON_PYSTATE_H +# error "this header file must not be included directly" +#endif + + +/* private interpreter helpers */ + +PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *); +PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int); + +PyAPI_FUNC(PyObject *) PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *); + +/* State unique per thread */ + +/* Py_tracefunc return -1 when raising an exception, or 0 for success. */ +typedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *); + +/* The following values are used for 'what' for tracefunc functions + * + * To add a new kind of trace event, also update "trace_init" in + * Python/sysmodule.c to define the Python level event name + */ +#define PyTrace_CALL 0 +#define PyTrace_EXCEPTION 1 +#define PyTrace_LINE 2 +#define PyTrace_RETURN 3 +#define PyTrace_C_CALL 4 +#define PyTrace_C_EXCEPTION 5 +#define PyTrace_C_RETURN 6 +#define PyTrace_OPCODE 7 + +typedef struct _err_stackitem { + /* This struct represents a single execution context where we might + * be currently handling an exception. It is a per-coroutine state + * (coroutine in the computer science sense, including the thread + * and generators). + * + * This is used as an entry on the exception stack, where each + * entry indicates if it is currently handling an exception. + * This ensures that the exception state is not impacted + * by "yields" from an except handler. The thread + * always has an entry (the bottom-most one). + */ + + /* The exception currently being handled in this context, if any. */ + PyObject *exc_value; + + struct _err_stackitem *previous_item; + +} _PyErr_StackItem; + +typedef struct _stack_chunk { + struct _stack_chunk *previous; + size_t size; + size_t top; + PyObject * data[1]; /* Variable sized */ +} _PyStackChunk; + +struct _ts { + /* See Python/ceval.c for comments explaining most fields */ + + PyThreadState *prev; + PyThreadState *next; + PyInterpreterState *interp; + + /* The global instrumentation version in high bits, plus flags indicating + when to break out of the interpreter loop in lower bits. See details in + pycore_ceval.h. */ + uintptr_t eval_breaker; + + struct { + /* Has been initialized to a safe state. + + In order to be effective, this must be set to 0 during or right + after allocation. */ + unsigned int initialized:1; + + /* Has been bound to an OS thread. */ + unsigned int bound:1; + /* Has been unbound from its OS thread. */ + unsigned int unbound:1; + /* Has been bound aa current for the GILState API. */ + unsigned int bound_gilstate:1; + /* Currently in use (maybe holds the GIL). */ + unsigned int active:1; + /* Currently holds the GIL. */ + unsigned int holds_gil:1; + + /* various stages of finalization */ + unsigned int finalizing:1; + unsigned int cleared:1; + unsigned int finalized:1; + + /* padding to align to 4 bytes */ + unsigned int :23; + } _status; +#ifdef Py_BUILD_CORE +# define _PyThreadState_WHENCE_NOTSET -1 +# define _PyThreadState_WHENCE_UNKNOWN 0 +# define _PyThreadState_WHENCE_INIT 1 +# define _PyThreadState_WHENCE_FINI 2 +# define _PyThreadState_WHENCE_THREADING 3 +# define _PyThreadState_WHENCE_GILSTATE 4 +# define _PyThreadState_WHENCE_EXEC 5 +#endif + int _whence; + + /* Thread state (_Py_THREAD_ATTACHED, _Py_THREAD_DETACHED, _Py_THREAD_SUSPENDED). + See Include/internal/pycore_pystate.h for more details. */ + int state; + + int py_recursion_remaining; + int py_recursion_limit; + + int c_recursion_remaining; + int recursion_headroom; /* Allow 50 more calls to handle any errors. */ + + /* 'tracing' keeps track of the execution depth when tracing/profiling. + This is to prevent the actual trace/profile code from being recorded in + the trace/profile. */ + int tracing; + int what_event; /* The event currently being monitored, if any. */ + + /* Pointer to currently executing frame. */ + struct _PyInterpreterFrame *current_frame; + + Py_tracefunc c_profilefunc; + Py_tracefunc c_tracefunc; + PyObject *c_profileobj; + PyObject *c_traceobj; + + /* The exception currently being raised */ + PyObject *current_exception; + + /* Pointer to the top of the exception stack for the exceptions + * we may be currently handling. (See _PyErr_StackItem above.) + * This is never NULL. */ + _PyErr_StackItem *exc_info; + + PyObject *dict; /* Stores per-thread state */ + + int gilstate_counter; + + PyObject *async_exc; /* Asynchronous exception to raise */ + unsigned long thread_id; /* Thread id where this tstate was created */ + + /* Native thread id where this tstate was created. This will be 0 except on + * those platforms that have the notion of native thread id, for which the + * macro PY_HAVE_THREAD_NATIVE_ID is then defined. + */ + unsigned long native_thread_id; + + PyObject *delete_later; + + /* Tagged pointer to top-most critical section, or zero if there is no + * active critical section. Critical sections are only used in + * `--disable-gil` builds (i.e., when Py_GIL_DISABLED is defined to 1). In the + * default build, this field is always zero. + */ + uintptr_t critical_section; + + int coroutine_origin_tracking_depth; + + PyObject *async_gen_firstiter; + PyObject *async_gen_finalizer; + + PyObject *context; + uint64_t context_ver; + + /* Unique thread state id. */ + uint64_t id; + + _PyStackChunk *datastack_chunk; + PyObject **datastack_top; + PyObject **datastack_limit; + /* XXX signal handlers should also be here */ + + /* The following fields are here to avoid allocation during init. + The data is exposed through PyThreadState pointer fields. + These fields should not be accessed directly outside of init. + This is indicated by an underscore prefix on the field names. + + All other PyInterpreterState pointer fields are populated when + needed and default to NULL. + */ + // Note some fields do not have a leading underscore for backward + // compatibility. See https://bugs.python.org/issue45953#msg412046. + + /* The thread's exception stack entry. (Always the last entry.) */ + _PyErr_StackItem exc_state; + + PyObject *previous_executor; + + uint64_t dict_global_version; + + /* Used to store/retrieve `threading.local` keys/values for this thread */ + PyObject *threading_local_key; + + /* Used by `threading.local`s to be remove keys/values for dying threads. + The PyThreadObject must hold the only reference to this value. + */ + PyObject *threading_local_sentinel; +}; + +#ifdef Py_DEBUG + // A debug build is likely built with low optimization level which implies + // higher stack memory usage than a release build: use a lower limit. +# define Py_C_RECURSION_LIMIT 500 +#elif defined(__s390x__) +# define Py_C_RECURSION_LIMIT 800 +#elif defined(_WIN32) && defined(_M_ARM64) +# define Py_C_RECURSION_LIMIT 1000 +#elif defined(_WIN32) +# define Py_C_RECURSION_LIMIT 3000 +#elif defined(__ANDROID__) + // On an ARM64 emulator, API level 34 was OK with 10000, but API level 21 + // crashed in test_compiler_recursion_limit. +# define Py_C_RECURSION_LIMIT 3000 +#elif defined(_Py_ADDRESS_SANITIZER) +# define Py_C_RECURSION_LIMIT 4000 +#elif defined(__wasi__) + // Based on wasmtime 16. +# define Py_C_RECURSION_LIMIT 5000 +#else + // This value is duplicated in Lib/test/support/__init__.py +# define Py_C_RECURSION_LIMIT 10000 +#endif + + +/* other API */ + +/* Similar to PyThreadState_Get(), but don't issue a fatal error + * if it is NULL. */ +PyAPI_FUNC(PyThreadState *) PyThreadState_GetUnchecked(void); + +// Alias kept for backward compatibility +#define _PyThreadState_UncheckedGet PyThreadState_GetUnchecked + + +// Disable tracing and profiling. +PyAPI_FUNC(void) PyThreadState_EnterTracing(PyThreadState *tstate); + +// Reset tracing and profiling: enable them if a trace function or a profile +// function is set, otherwise disable them. +PyAPI_FUNC(void) PyThreadState_LeaveTracing(PyThreadState *tstate); + +/* PyGILState */ + +/* Helper/diagnostic function - return 1 if the current thread + currently holds the GIL, 0 otherwise. + + The function returns 1 if _PyGILState_check_enabled is non-zero. */ +PyAPI_FUNC(int) PyGILState_Check(void); + +/* The implementation of sys._current_frames() Returns a dict mapping + thread id to that thread's current frame. +*/ +PyAPI_FUNC(PyObject*) _PyThread_CurrentFrames(void); + +/* Routines for advanced debuggers, requested by David Beazley. + Don't use unless you know what you are doing! */ +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Main(void); +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void); +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *); +PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void); + +/* Frame evaluation API */ + +typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _PyInterpreterFrame *, int); + +PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc( + PyInterpreterState *interp); +PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc( + PyInterpreterState *interp, + _PyFrameEvalFunction eval_frame); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pystats.h b/illumos-x86_64/usr/include/python3.13/cpython/pystats.h new file mode 100644 index 00000000..378c2760 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pystats.h @@ -0,0 +1,175 @@ +// Statistics on Python performance. +// +// API: +// +// - _Py_INCREF_STAT_INC() and _Py_DECREF_STAT_INC() used by Py_INCREF() +// and Py_DECREF(). +// - _Py_stats variable +// +// Functions of the sys module: +// +// - sys._stats_on() +// - sys._stats_off() +// - sys._stats_clear() +// - sys._stats_dump() +// +// Python must be built with ./configure --enable-pystats to define the +// Py_STATS macro. +// +// Define _PY_INTERPRETER macro to increment interpreter_increfs and +// interpreter_decrefs. Otherwise, increment increfs and decrefs. +// +// The number of incref operations counted by `incref` and +// `interpreter_incref` is the number of increment operations, which is +// not equal to the total of all reference counts. A single increment +// operation may increase the reference count of an object by more than +// one. For example, see `_Py_RefcntAdd`. + +#ifndef Py_CPYTHON_PYSTATS_H +# error "this header file must not be included directly" +#endif + +#define PYSTATS_MAX_UOP_ID 512 + +#define SPECIALIZATION_FAILURE_KINDS 36 + +/* Stats for determining who is calling PyEval_EvalFrame */ +#define EVAL_CALL_TOTAL 0 +#define EVAL_CALL_VECTOR 1 +#define EVAL_CALL_GENERATOR 2 +#define EVAL_CALL_LEGACY 3 +#define EVAL_CALL_FUNCTION_VECTORCALL 4 +#define EVAL_CALL_BUILD_CLASS 5 +#define EVAL_CALL_SLOT 6 +#define EVAL_CALL_FUNCTION_EX 7 +#define EVAL_CALL_API 8 +#define EVAL_CALL_METHOD 9 + +#define EVAL_CALL_KINDS 10 + +typedef struct _specialization_stats { + uint64_t success; + uint64_t failure; + uint64_t hit; + uint64_t deferred; + uint64_t miss; + uint64_t deopt; + uint64_t failure_kinds[SPECIALIZATION_FAILURE_KINDS]; +} SpecializationStats; + +typedef struct _opcode_stats { + SpecializationStats specialization; + uint64_t execution_count; + uint64_t pair_count[256]; +} OpcodeStats; + +typedef struct _call_stats { + uint64_t inlined_py_calls; + uint64_t pyeval_calls; + uint64_t frames_pushed; + uint64_t frame_objects_created; + uint64_t eval_calls[EVAL_CALL_KINDS]; +} CallStats; + +typedef struct _object_stats { + uint64_t increfs; + uint64_t decrefs; + uint64_t interpreter_increfs; + uint64_t interpreter_decrefs; + uint64_t allocations; + uint64_t allocations512; + uint64_t allocations4k; + uint64_t allocations_big; + uint64_t frees; + uint64_t to_freelist; + uint64_t from_freelist; + uint64_t inline_values; + uint64_t dict_materialized_on_request; + uint64_t dict_materialized_new_key; + uint64_t dict_materialized_too_big; + uint64_t dict_materialized_str_subclass; + uint64_t type_cache_hits; + uint64_t type_cache_misses; + uint64_t type_cache_dunder_hits; + uint64_t type_cache_dunder_misses; + uint64_t type_cache_collisions; + /* Temporary value used during GC */ + uint64_t object_visits; +} ObjectStats; + +typedef struct _gc_stats { + uint64_t collections; + uint64_t object_visits; + uint64_t objects_collected; +} GCStats; + +typedef struct _uop_stats { + uint64_t execution_count; + uint64_t miss; + uint64_t pair_count[PYSTATS_MAX_UOP_ID + 1]; +} UOpStats; + +#define _Py_UOP_HIST_SIZE 32 + +typedef struct _optimization_stats { + uint64_t attempts; + uint64_t traces_created; + uint64_t traces_executed; + uint64_t uops_executed; + uint64_t trace_stack_overflow; + uint64_t trace_stack_underflow; + uint64_t trace_too_long; + uint64_t trace_too_short; + uint64_t inner_loop; + uint64_t recursive_call; + uint64_t low_confidence; + uint64_t executors_invalidated; + UOpStats opcode[PYSTATS_MAX_UOP_ID + 1]; + uint64_t unsupported_opcode[256]; + uint64_t trace_length_hist[_Py_UOP_HIST_SIZE]; + uint64_t trace_run_length_hist[_Py_UOP_HIST_SIZE]; + uint64_t optimized_trace_length_hist[_Py_UOP_HIST_SIZE]; + uint64_t optimizer_attempts; + uint64_t optimizer_successes; + uint64_t optimizer_failure_reason_no_memory; + uint64_t remove_globals_builtins_changed; + uint64_t remove_globals_incorrect_keys; + uint64_t error_in_opcode[PYSTATS_MAX_UOP_ID + 1]; +} OptimizationStats; + +typedef struct _rare_event_stats { + /* Setting an object's class, obj.__class__ = ... */ + uint64_t set_class; + /* Setting the bases of a class, cls.__bases__ = ... */ + uint64_t set_bases; + /* Setting the PEP 523 frame eval function, _PyInterpreterState_SetFrameEvalFunc() */ + uint64_t set_eval_frame_func; + /* Modifying the builtins, __builtins__.__dict__[var] = ... */ + uint64_t builtin_dict; + /* Modifying a function, e.g. func.__defaults__ = ..., etc. */ + uint64_t func_modification; + /* Modifying a dict that is being watched */ + uint64_t watched_dict_modification; + uint64_t watched_globals_modification; +} RareEventStats; + +typedef struct _stats { + OpcodeStats opcode_stats[256]; + CallStats call_stats; + ObjectStats object_stats; + OptimizationStats optimization_stats; + RareEventStats rare_event_stats; + GCStats *gc_stats; +} PyStats; + + +// Export for shared extensions like 'math' +PyAPI_DATA(PyStats*) _Py_stats; + +#ifdef _PY_INTERPRETER +# define _Py_INCREF_STAT_INC() do { if (_Py_stats) _Py_stats->object_stats.interpreter_increfs++; } while (0) +# define _Py_DECREF_STAT_INC() do { if (_Py_stats) _Py_stats->object_stats.interpreter_decrefs++; } while (0) +#else +# define _Py_INCREF_STAT_INC() do { if (_Py_stats) _Py_stats->object_stats.increfs++; } while (0) +# define _Py_DECREF_STAT_INC() do { if (_Py_stats) _Py_stats->object_stats.decrefs++; } while (0) +#endif diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pythonrun.h b/illumos-x86_64/usr/include/python3.13/cpython/pythonrun.h new file mode 100644 index 00000000..edc40952 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pythonrun.h @@ -0,0 +1,96 @@ +#ifndef Py_CPYTHON_PYTHONRUN_H +# error "this header file must not be included directly" +#endif + +PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_AnyFileExFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + int closeit, + PyCompilerFlags *flags); +PyAPI_FUNC(int) PyRun_SimpleFileExFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + int closeit, + PyCompilerFlags *flags); +PyAPI_FUNC(int) PyRun_InteractiveOneFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + PyCompilerFlags *flags); +PyAPI_FUNC(int) PyRun_InteractiveOneObject( + FILE *fp, + PyObject *filename, + PyCompilerFlags *flags); +PyAPI_FUNC(int) PyRun_InteractiveLoopFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + PyCompilerFlags *flags); + + +PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, + PyObject *, PyCompilerFlags *); + +PyAPI_FUNC(PyObject *) PyRun_FileExFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + int start, + PyObject *globals, + PyObject *locals, + int closeit, + PyCompilerFlags *flags); + + +PyAPI_FUNC(PyObject *) Py_CompileStringExFlags( + const char *str, + const char *filename, /* decoded from the filesystem encoding */ + int start, + PyCompilerFlags *flags, + int optimize); +PyAPI_FUNC(PyObject *) Py_CompileStringObject( + const char *str, + PyObject *filename, int start, + PyCompilerFlags *flags, + int optimize); + +#define Py_CompileString(str, p, s) Py_CompileStringExFlags((str), (p), (s), NULL, -1) +#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags((str), (p), (s), (f), -1) + +/* A function flavor is also exported by libpython. It is required when + libpython is accessed directly rather than using header files which defines + macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to + export functions in pythonXX.dll. */ +PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l); +PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name); +PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit); +PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_SimpleString(const char *s); +PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p); +PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c); +PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p); +PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p); +PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l); +PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c); +PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags); + +/* Use macros for a bunch of old variants */ +#define PyRun_String(str, s, g, l) PyRun_StringFlags((str), (s), (g), (l), NULL) +#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags((fp), (name), 0, NULL) +#define PyRun_AnyFileEx(fp, name, closeit) \ + PyRun_AnyFileExFlags((fp), (name), (closeit), NULL) +#define PyRun_AnyFileFlags(fp, name, flags) \ + PyRun_AnyFileExFlags((fp), (name), 0, (flags)) +#define PyRun_SimpleString(s) PyRun_SimpleStringFlags((s), NULL) +#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags((f), (p), 0, NULL) +#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags((f), (p), (c), NULL) +#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags((f), (p), NULL) +#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags((f), (p), NULL) +#define PyRun_File(fp, p, s, g, l) \ + PyRun_FileExFlags((fp), (p), (s), (g), (l), 0, NULL) +#define PyRun_FileEx(fp, p, s, g, l, c) \ + PyRun_FileExFlags((fp), (p), (s), (g), (l), (c), NULL) +#define PyRun_FileFlags(fp, p, s, g, l, flags) \ + PyRun_FileExFlags((fp), (p), (s), (g), (l), 0, (flags)) + +/* Stuff with no proper home (yet) */ +PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *); +PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pythread.h b/illumos-x86_64/usr/include/python3.13/cpython/pythread.h new file mode 100644 index 00000000..e658b35b --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pythread.h @@ -0,0 +1,43 @@ +#ifndef Py_CPYTHON_PYTHREAD_H +# error "this header file must not be included directly" +#endif + +// PY_TIMEOUT_MAX is the highest usable value (in microseconds) of PY_TIMEOUT_T +// type, and depends on the system threading API. +// +// NOTE: this isn't the same value as `_thread.TIMEOUT_MAX`. The _thread module +// exposes a higher-level API, with timeouts expressed in seconds and +// floating-point numbers allowed. +PyAPI_DATA(const long long) PY_TIMEOUT_MAX; + +#define PYTHREAD_INVALID_THREAD_ID ((unsigned long)-1) + +#ifdef HAVE_PTHREAD_H + /* Darwin needs pthread.h to know type name the pthread_key_t. */ +# include +# define NATIVE_TSS_KEY_T pthread_key_t +#elif defined(NT_THREADS) + /* In Windows, native TSS key type is DWORD, + but hardcode the unsigned long to avoid errors for include directive. + */ +# define NATIVE_TSS_KEY_T unsigned long +#elif defined(HAVE_PTHREAD_STUBS) +# include "pthread_stubs.h" +# define NATIVE_TSS_KEY_T pthread_key_t +#else +# error "Require native threads. See https://bugs.python.org/issue31370" +#endif + +/* When Py_LIMITED_API is not defined, the type layout of Py_tss_t is + exposed to allow static allocation in the API clients. Even in this case, + you must handle TSS keys through API functions due to compatibility. +*/ +struct _Py_tss_t { + int _is_initialized; + NATIVE_TSS_KEY_T _key; +}; + +#undef NATIVE_TSS_KEY_T + +/* When static allocation, you must initialize with Py_tss_NEEDS_INIT. */ +#define Py_tss_NEEDS_INIT {0} diff --git a/illumos-x86_64/usr/include/python3.13/cpython/pytime.h b/illumos-x86_64/usr/include/python3.13/cpython/pytime.h new file mode 100644 index 00000000..5c68110a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/pytime.h @@ -0,0 +1,27 @@ +// PyTime_t C API: see Doc/c-api/time.rst for the documentation. + +#ifndef Py_LIMITED_API +#ifndef Py_PYTIME_H +#define Py_PYTIME_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef int64_t PyTime_t; +#define PyTime_MIN INT64_MIN +#define PyTime_MAX INT64_MAX + +PyAPI_FUNC(double) PyTime_AsSecondsDouble(PyTime_t t); +PyAPI_FUNC(int) PyTime_Monotonic(PyTime_t *result); +PyAPI_FUNC(int) PyTime_PerfCounter(PyTime_t *result); +PyAPI_FUNC(int) PyTime_Time(PyTime_t *result); + +PyAPI_FUNC(int) PyTime_MonotonicRaw(PyTime_t *result); +PyAPI_FUNC(int) PyTime_PerfCounterRaw(PyTime_t *result); +PyAPI_FUNC(int) PyTime_TimeRaw(PyTime_t *result); + +#ifdef __cplusplus +} +#endif +#endif /* Py_PYTIME_H */ +#endif /* Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/cpython/setobject.h b/illumos-x86_64/usr/include/python3.13/cpython/setobject.h new file mode 100644 index 00000000..89565cb2 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/setobject.h @@ -0,0 +1,71 @@ +#ifndef Py_CPYTHON_SETOBJECT_H +# error "this header file must not be included directly" +#endif + +/* There are three kinds of entries in the table: + +1. Unused: key == NULL and hash == 0 +2. Dummy: key == dummy and hash == -1 +3. Active: key != NULL and key != dummy and hash != -1 + +The hash field of Unused slots is always zero. + +The hash field of Dummy slots are set to -1 +meaning that dummy entries can be detected by +either entry->key==dummy or by entry->hash==-1. +*/ + +#define PySet_MINSIZE 8 + +typedef struct { + PyObject *key; + Py_hash_t hash; /* Cached hash code of the key */ +} setentry; + +/* The SetObject data structure is shared by set and frozenset objects. + +Invariant for sets: + - hash is -1 + +Invariants for frozensets: + - data is immutable. + - hash is the hash of the frozenset or -1 if not computed yet. + +*/ + +typedef struct { + PyObject_HEAD + + Py_ssize_t fill; /* Number active and dummy entries*/ + Py_ssize_t used; /* Number active entries */ + + /* The table contains mask + 1 slots, and that's a power of 2. + * We store the mask instead of the size because the mask is more + * frequently needed. + */ + Py_ssize_t mask; + + /* The table points to a fixed-size smalltable for small tables + * or to additional malloc'ed memory for bigger tables. + * The table pointer is never NULL which saves us from repeated + * runtime null-tests. + */ + setentry *table; + Py_hash_t hash; /* Only used by frozenset objects */ + Py_ssize_t finger; /* Search finger for pop() */ + + setentry smalltable[PySet_MINSIZE]; + PyObject *weakreflist; /* List of weak references */ +} PySetObject; + +#define _PySet_CAST(so) \ + (assert(PyAnySet_Check(so)), _Py_CAST(PySetObject*, so)) + +static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) { +#ifdef Py_GIL_DISABLED + return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used)); +#else + return _PySet_CAST(so)->used; +#endif +} +#define PySet_GET_SIZE(so) PySet_GET_SIZE(_PyObject_CAST(so)) diff --git a/illumos-x86_64/usr/include/python3.13/cpython/sysmodule.h b/illumos-x86_64/usr/include/python3.13/cpython/sysmodule.h new file mode 100644 index 00000000..a3ac07f5 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/sysmodule.h @@ -0,0 +1,22 @@ +#ifndef Py_CPYTHON_SYSMODULE_H +# error "this header file must not be included directly" +#endif + +typedef int(*Py_AuditHookFunction)(const char *, PyObject *, void *); + +PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*); + +typedef struct { + FILE* perf_map; + PyThread_type_lock map_lock; +} PerfMapState; + +PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void); +PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry( + const void *code_addr, + unsigned int code_size, + const char *entry_name); +PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void); +PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename); +PyAPI_FUNC(int) PyUnstable_PerfTrampoline_CompileCode(PyCodeObject *); +PyAPI_FUNC(int) PyUnstable_PerfTrampoline_SetPersistAfterFork(int enable); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/traceback.h b/illumos-x86_64/usr/include/python3.13/cpython/traceback.h new file mode 100644 index 00000000..81c51944 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/traceback.h @@ -0,0 +1,13 @@ +#ifndef Py_CPYTHON_TRACEBACK_H +# error "this header file must not be included directly" +#endif + +typedef struct _traceback PyTracebackObject; + +struct _traceback { + PyObject_HEAD + PyTracebackObject *tb_next; + PyFrameObject *tb_frame; + int tb_lasti; + int tb_lineno; +}; diff --git a/illumos-x86_64/usr/include/python3.13/cpython/tracemalloc.h b/illumos-x86_64/usr/include/python3.13/cpython/tracemalloc.h new file mode 100644 index 00000000..6d094291 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/tracemalloc.h @@ -0,0 +1,32 @@ +#ifndef Py_LIMITED_API +#ifndef Py_TRACEMALLOC_H +#define Py_TRACEMALLOC_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Track an allocated memory block in the tracemalloc module. + Return 0 on success, return -1 on error (failed to allocate memory to store + the trace). + + Return -2 if tracemalloc is disabled. + + If memory block is already tracked, update the existing trace. */ +PyAPI_FUNC(int) PyTraceMalloc_Track( + unsigned int domain, + uintptr_t ptr, + size_t size); + +/* Untrack an allocated memory block in the tracemalloc module. + Do nothing if the block was not tracked. + + Return -2 if tracemalloc is disabled, otherwise return 0. */ +PyAPI_FUNC(int) PyTraceMalloc_Untrack( + unsigned int domain, + uintptr_t ptr); + +#ifdef __cplusplus +} +#endif +#endif // !Py_TRACEMALLOC_H +#endif // !Py_LIMITED_API diff --git a/illumos-x86_64/usr/include/python3.13/cpython/tupleobject.h b/illumos-x86_64/usr/include/python3.13/cpython/tupleobject.h new file mode 100644 index 00000000..e530c8be --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/tupleobject.h @@ -0,0 +1,38 @@ +#ifndef Py_CPYTHON_TUPLEOBJECT_H +# error "this header file must not be included directly" +#endif + +typedef struct { + PyObject_VAR_HEAD + /* ob_item contains space for 'ob_size' elements. + Items must normally not be NULL, except during construction when + the tuple is not yet visible outside the function that builds it. */ + PyObject *ob_item[1]; +} PyTupleObject; + +PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); + +/* Cast argument to PyTupleObject* type. */ +#define _PyTuple_CAST(op) \ + (assert(PyTuple_Check(op)), _Py_CAST(PyTupleObject*, (op))) + +// Macros and static inline functions, trading safety for speed + +static inline Py_ssize_t PyTuple_GET_SIZE(PyObject *op) { + PyTupleObject *tuple = _PyTuple_CAST(op); + return Py_SIZE(tuple); +} +#define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyObject_CAST(op)) + +#define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[(index)]) + +/* Function *only* to be used to fill in brand new tuples */ +static inline void +PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { + PyTupleObject *tuple = _PyTuple_CAST(op); + assert(0 <= index); + assert(index < Py_SIZE(tuple)); + tuple->ob_item[index] = value; +} +#define PyTuple_SET_ITEM(op, index, value) \ + PyTuple_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value)) diff --git a/illumos-x86_64/usr/include/python3.13/cpython/unicodeobject.h b/illumos-x86_64/usr/include/python3.13/cpython/unicodeobject.h new file mode 100644 index 00000000..d9b54bce --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/unicodeobject.h @@ -0,0 +1,703 @@ +#ifndef Py_CPYTHON_UNICODEOBJECT_H +# error "this header file must not be included directly" +#endif + +/* Py_UNICODE was the native Unicode storage format (code unit) used by + Python and represents a single Unicode element in the Unicode type. + With PEP 393, Py_UNICODE is deprecated and replaced with a + typedef to wchar_t. */ +Py_DEPRECATED(3.13) typedef wchar_t PY_UNICODE_TYPE; +Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE; + + +/* --- Internal Unicode Operations ---------------------------------------- */ + +// Static inline functions to work with surrogates +static inline int Py_UNICODE_IS_SURROGATE(Py_UCS4 ch) { + return (0xD800 <= ch && ch <= 0xDFFF); +} +static inline int Py_UNICODE_IS_HIGH_SURROGATE(Py_UCS4 ch) { + return (0xD800 <= ch && ch <= 0xDBFF); +} +static inline int Py_UNICODE_IS_LOW_SURROGATE(Py_UCS4 ch) { + return (0xDC00 <= ch && ch <= 0xDFFF); +} + +// Join two surrogate characters and return a single Py_UCS4 value. +static inline Py_UCS4 Py_UNICODE_JOIN_SURROGATES(Py_UCS4 high, Py_UCS4 low) { + assert(Py_UNICODE_IS_HIGH_SURROGATE(high)); + assert(Py_UNICODE_IS_LOW_SURROGATE(low)); + return 0x10000 + (((high & 0x03FF) << 10) | (low & 0x03FF)); +} + +// High surrogate = top 10 bits added to 0xD800. +// The character must be in the range [U+10000; U+10ffff]. +static inline Py_UCS4 Py_UNICODE_HIGH_SURROGATE(Py_UCS4 ch) { + assert(0x10000 <= ch && ch <= 0x10ffff); + return (0xD800 - (0x10000 >> 10) + (ch >> 10)); +} + +// Low surrogate = bottom 10 bits added to 0xDC00. +// The character must be in the range [U+10000; U+10ffff]. +static inline Py_UCS4 Py_UNICODE_LOW_SURROGATE(Py_UCS4 ch) { + assert(0x10000 <= ch && ch <= 0x10ffff); + return (0xDC00 + (ch & 0x3FF)); +} + + +/* --- Unicode Type ------------------------------------------------------- */ + +/* ASCII-only strings created through PyUnicode_New use the PyASCIIObject + structure. state.ascii and state.compact are set, and the data + immediately follow the structure. utf8_length can be found + in the length field; the utf8 pointer is equal to the data pointer. */ +typedef struct { + /* There are 4 forms of Unicode strings: + + - compact ascii: + + * structure = PyASCIIObject + * test: PyUnicode_IS_COMPACT_ASCII(op) + * kind = PyUnicode_1BYTE_KIND + * compact = 1 + * ascii = 1 + * (length is the length of the utf8) + * (data starts just after the structure) + * (since ASCII is decoded from UTF-8, the utf8 string are the data) + + - compact: + + * structure = PyCompactUnicodeObject + * test: PyUnicode_IS_COMPACT(op) && !PyUnicode_IS_ASCII(op) + * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or + PyUnicode_4BYTE_KIND + * compact = 1 + * ascii = 0 + * utf8 is not shared with data + * utf8_length = 0 if utf8 is NULL + * (data starts just after the structure) + + - legacy string: + + * structure = PyUnicodeObject structure + * test: !PyUnicode_IS_COMPACT(op) + * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or + PyUnicode_4BYTE_KIND + * compact = 0 + * data.any is not NULL + * utf8 is shared and utf8_length = length with data.any if ascii = 1 + * utf8_length = 0 if utf8 is NULL + + Compact strings use only one memory block (structure + characters), + whereas legacy strings use one block for the structure and one block + for characters. + + Legacy strings are created by subclasses of Unicode. + + See also _PyUnicode_CheckConsistency(). + */ + PyObject_HEAD + Py_ssize_t length; /* Number of code points in the string */ + Py_hash_t hash; /* Hash value; -1 if not set */ + struct { + /* If interned is non-zero, the two references from the + dictionary to this object are *not* counted in ob_refcnt. + The possible values here are: + 0: Not Interned + 1: Interned + 2: Interned and Immortal + 3: Interned, Immortal, and Static + This categorization allows the runtime to determine the right + cleanup mechanism at runtime shutdown. */ + unsigned int interned:2; + /* Character size: + + - PyUnicode_1BYTE_KIND (1): + + * character type = Py_UCS1 (8 bits, unsigned) + * all characters are in the range U+0000-U+00FF (latin1) + * if ascii is set, all characters are in the range U+0000-U+007F + (ASCII), otherwise at least one character is in the range + U+0080-U+00FF + + - PyUnicode_2BYTE_KIND (2): + + * character type = Py_UCS2 (16 bits, unsigned) + * all characters are in the range U+0000-U+FFFF (BMP) + * at least one character is in the range U+0100-U+FFFF + + - PyUnicode_4BYTE_KIND (4): + + * character type = Py_UCS4 (32 bits, unsigned) + * all characters are in the range U+0000-U+10FFFF + * at least one character is in the range U+10000-U+10FFFF + */ + unsigned int kind:3; + /* Compact is with respect to the allocation scheme. Compact unicode + objects only require one memory block while non-compact objects use + one block for the PyUnicodeObject struct and another for its data + buffer. */ + unsigned int compact:1; + /* The string only contains characters in the range U+0000-U+007F (ASCII) + and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is + set, use the PyASCIIObject structure. */ + unsigned int ascii:1; + /* The object is statically allocated. */ + unsigned int statically_allocated:1; + /* Padding to ensure that PyUnicode_DATA() is always aligned to + 4 bytes (see issue #19537 on m68k). */ + unsigned int :24; + } state; +} PyASCIIObject; + +/* Non-ASCII strings allocated through PyUnicode_New use the + PyCompactUnicodeObject structure. state.compact is set, and the data + immediately follow the structure. */ +typedef struct { + PyASCIIObject _base; + Py_ssize_t utf8_length; /* Number of bytes in utf8, excluding the + * terminating \0. */ + char *utf8; /* UTF-8 representation (null-terminated) */ +} PyCompactUnicodeObject; + +/* Object format for Unicode subclasses. */ +typedef struct { + PyCompactUnicodeObject _base; + union { + void *any; + Py_UCS1 *latin1; + Py_UCS2 *ucs2; + Py_UCS4 *ucs4; + } data; /* Canonical, smallest-form Unicode buffer */ +} PyUnicodeObject; + + +#define _PyASCIIObject_CAST(op) \ + (assert(PyUnicode_Check(op)), \ + _Py_CAST(PyASCIIObject*, (op))) +#define _PyCompactUnicodeObject_CAST(op) \ + (assert(PyUnicode_Check(op)), \ + _Py_CAST(PyCompactUnicodeObject*, (op))) +#define _PyUnicodeObject_CAST(op) \ + (assert(PyUnicode_Check(op)), \ + _Py_CAST(PyUnicodeObject*, (op))) + + +/* --- Flexible String Representation Helper Macros (PEP 393) -------------- */ + +/* Values for PyASCIIObject.state: */ + +/* Interning state. */ +#define SSTATE_NOT_INTERNED 0 +#define SSTATE_INTERNED_MORTAL 1 +#define SSTATE_INTERNED_IMMORTAL 2 +#define SSTATE_INTERNED_IMMORTAL_STATIC 3 + +/* Use only if you know it's a string */ +static inline unsigned int PyUnicode_CHECK_INTERNED(PyObject *op) { + return _PyASCIIObject_CAST(op)->state.interned; +} +#define PyUnicode_CHECK_INTERNED(op) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op)) + +/* For backward compatibility */ +static inline unsigned int PyUnicode_IS_READY(PyObject* Py_UNUSED(op)) { + return 1; +} +#define PyUnicode_IS_READY(op) PyUnicode_IS_READY(_PyObject_CAST(op)) + +/* Return true if the string contains only ASCII characters, or 0 if not. The + string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be + ready. */ +static inline unsigned int PyUnicode_IS_ASCII(PyObject *op) { + return _PyASCIIObject_CAST(op)->state.ascii; +} +#define PyUnicode_IS_ASCII(op) PyUnicode_IS_ASCII(_PyObject_CAST(op)) + +/* Return true if the string is compact or 0 if not. + No type checks or Ready calls are performed. */ +static inline unsigned int PyUnicode_IS_COMPACT(PyObject *op) { + return _PyASCIIObject_CAST(op)->state.compact; +} +#define PyUnicode_IS_COMPACT(op) PyUnicode_IS_COMPACT(_PyObject_CAST(op)) + +/* Return true if the string is a compact ASCII string (use PyASCIIObject + structure), or 0 if not. No type checks or Ready calls are performed. */ +static inline int PyUnicode_IS_COMPACT_ASCII(PyObject *op) { + return (_PyASCIIObject_CAST(op)->state.ascii && PyUnicode_IS_COMPACT(op)); +} +#define PyUnicode_IS_COMPACT_ASCII(op) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op)) + +enum PyUnicode_Kind { +/* Return values of the PyUnicode_KIND() function: */ + PyUnicode_1BYTE_KIND = 1, + PyUnicode_2BYTE_KIND = 2, + PyUnicode_4BYTE_KIND = 4 +}; + +// PyUnicode_KIND(): Return one of the PyUnicode_*_KIND values defined above. +// +// gh-89653: Converting this macro to a static inline function would introduce +// new compiler warnings on "kind < PyUnicode_KIND(str)" (compare signed and +// unsigned numbers) where kind type is an int or on +// "unsigned int kind = PyUnicode_KIND(str)" (cast signed to unsigned). +#define PyUnicode_KIND(op) _Py_RVALUE(_PyASCIIObject_CAST(op)->state.kind) + +/* Return a void pointer to the raw unicode buffer. */ +static inline void* _PyUnicode_COMPACT_DATA(PyObject *op) { + if (PyUnicode_IS_ASCII(op)) { + return _Py_STATIC_CAST(void*, (_PyASCIIObject_CAST(op) + 1)); + } + return _Py_STATIC_CAST(void*, (_PyCompactUnicodeObject_CAST(op) + 1)); +} + +static inline void* _PyUnicode_NONCOMPACT_DATA(PyObject *op) { + void *data; + assert(!PyUnicode_IS_COMPACT(op)); + data = _PyUnicodeObject_CAST(op)->data.any; + assert(data != NULL); + return data; +} + +static inline void* PyUnicode_DATA(PyObject *op) { + if (PyUnicode_IS_COMPACT(op)) { + return _PyUnicode_COMPACT_DATA(op); + } + return _PyUnicode_NONCOMPACT_DATA(op); +} +#define PyUnicode_DATA(op) PyUnicode_DATA(_PyObject_CAST(op)) + +/* Return pointers to the canonical representation cast to unsigned char, + Py_UCS2, or Py_UCS4 for direct character access. + No checks are performed, use PyUnicode_KIND() before to ensure + these will work correctly. */ + +#define PyUnicode_1BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS1*, PyUnicode_DATA(op)) +#define PyUnicode_2BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS2*, PyUnicode_DATA(op)) +#define PyUnicode_4BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS4*, PyUnicode_DATA(op)) + +/* Returns the length of the unicode string. */ +static inline Py_ssize_t PyUnicode_GET_LENGTH(PyObject *op) { + return _PyASCIIObject_CAST(op)->length; +} +#define PyUnicode_GET_LENGTH(op) PyUnicode_GET_LENGTH(_PyObject_CAST(op)) + +/* Write into the canonical representation, this function does not do any sanity + checks and is intended for usage in loops. The caller should cache the + kind and data pointers obtained from other function calls. + index is the index in the string (starts at 0) and value is the new + code point value which should be written to that location. */ +static inline void PyUnicode_WRITE(int kind, void *data, + Py_ssize_t index, Py_UCS4 value) +{ + assert(index >= 0); + if (kind == PyUnicode_1BYTE_KIND) { + assert(value <= 0xffU); + _Py_STATIC_CAST(Py_UCS1*, data)[index] = _Py_STATIC_CAST(Py_UCS1, value); + } + else if (kind == PyUnicode_2BYTE_KIND) { + assert(value <= 0xffffU); + _Py_STATIC_CAST(Py_UCS2*, data)[index] = _Py_STATIC_CAST(Py_UCS2, value); + } + else { + assert(kind == PyUnicode_4BYTE_KIND); + assert(value <= 0x10ffffU); + _Py_STATIC_CAST(Py_UCS4*, data)[index] = value; + } +} +#define PyUnicode_WRITE(kind, data, index, value) \ + PyUnicode_WRITE(_Py_STATIC_CAST(int, kind), _Py_CAST(void*, data), \ + (index), _Py_STATIC_CAST(Py_UCS4, value)) + +/* Read a code point from the string's canonical representation. No checks + or ready calls are performed. */ +static inline Py_UCS4 PyUnicode_READ(int kind, + const void *data, Py_ssize_t index) +{ + assert(index >= 0); + if (kind == PyUnicode_1BYTE_KIND) { + return _Py_STATIC_CAST(const Py_UCS1*, data)[index]; + } + if (kind == PyUnicode_2BYTE_KIND) { + return _Py_STATIC_CAST(const Py_UCS2*, data)[index]; + } + assert(kind == PyUnicode_4BYTE_KIND); + return _Py_STATIC_CAST(const Py_UCS4*, data)[index]; +} +#define PyUnicode_READ(kind, data, index) \ + PyUnicode_READ(_Py_STATIC_CAST(int, kind), \ + _Py_STATIC_CAST(const void*, data), \ + (index)) + +/* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it + calls PyUnicode_KIND() and might call it twice. For single reads, use + PyUnicode_READ_CHAR, for multiple consecutive reads callers should + cache kind and use PyUnicode_READ instead. */ +static inline Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index) +{ + int kind; + + assert(index >= 0); + // Tolerate reading the NUL character at str[len(str)] + assert(index <= PyUnicode_GET_LENGTH(unicode)); + + kind = PyUnicode_KIND(unicode); + if (kind == PyUnicode_1BYTE_KIND) { + return PyUnicode_1BYTE_DATA(unicode)[index]; + } + if (kind == PyUnicode_2BYTE_KIND) { + return PyUnicode_2BYTE_DATA(unicode)[index]; + } + assert(kind == PyUnicode_4BYTE_KIND); + return PyUnicode_4BYTE_DATA(unicode)[index]; +} +#define PyUnicode_READ_CHAR(unicode, index) \ + PyUnicode_READ_CHAR(_PyObject_CAST(unicode), (index)) + +/* Return a maximum character value which is suitable for creating another + string based on op. This is always an approximation but more efficient + than iterating over the string. */ +static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op) +{ + int kind; + + if (PyUnicode_IS_ASCII(op)) { + return 0x7fU; + } + + kind = PyUnicode_KIND(op); + if (kind == PyUnicode_1BYTE_KIND) { + return 0xffU; + } + if (kind == PyUnicode_2BYTE_KIND) { + return 0xffffU; + } + assert(kind == PyUnicode_4BYTE_KIND); + return 0x10ffffU; +} +#define PyUnicode_MAX_CHAR_VALUE(op) \ + PyUnicode_MAX_CHAR_VALUE(_PyObject_CAST(op)) + + +/* === Public API ========================================================= */ + +/* With PEP 393, this is the recommended way to allocate a new unicode object. + This function will allocate the object and its buffer in a single memory + block. Objects created using this function are not resizable. */ +PyAPI_FUNC(PyObject*) PyUnicode_New( + Py_ssize_t size, /* Number of code points in the new string */ + Py_UCS4 maxchar /* maximum code point value in the string */ + ); + +/* For backward compatibility */ +static inline int PyUnicode_READY(PyObject* Py_UNUSED(op)) +{ + return 0; +} +#define PyUnicode_READY(op) PyUnicode_READY(_PyObject_CAST(op)) + +/* Copy character from one unicode object into another, this function performs + character conversion when necessary and falls back to memcpy() if possible. + + Fail if to is too small (smaller than *how_many* or smaller than + len(from)-from_start), or if kind(from[from_start:from_start+how_many]) > + kind(to), or if *to* has more than 1 reference. + + Return the number of written character, or return -1 and raise an exception + on error. + + Pseudo-code: + + how_many = min(how_many, len(from) - from_start) + to[to_start:to_start+how_many] = from[from_start:from_start+how_many] + return how_many + + Note: The function doesn't write a terminating null character. + */ +PyAPI_FUNC(Py_ssize_t) PyUnicode_CopyCharacters( + PyObject *to, + Py_ssize_t to_start, + PyObject *from, + Py_ssize_t from_start, + Py_ssize_t how_many + ); + +/* Fill a string with a character: write fill_char into + unicode[start:start+length]. + + Fail if fill_char is bigger than the string maximum character, or if the + string has more than 1 reference. + + Return the number of written character, or return -1 and raise an exception + on error. */ +PyAPI_FUNC(Py_ssize_t) PyUnicode_Fill( + PyObject *unicode, + Py_ssize_t start, + Py_ssize_t length, + Py_UCS4 fill_char + ); + +/* Create a new string from a buffer of Py_UCS1, Py_UCS2 or Py_UCS4 characters. + Scan the string to find the maximum character. */ +PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData( + int kind, + const void *buffer, + Py_ssize_t size); + + +/* --- _PyUnicodeWriter API ----------------------------------------------- */ + +typedef struct { + PyObject *buffer; + void *data; + int kind; + Py_UCS4 maxchar; + Py_ssize_t size; + Py_ssize_t pos; + + /* minimum number of allocated characters (default: 0) */ + Py_ssize_t min_length; + + /* minimum character (default: 127, ASCII) */ + Py_UCS4 min_char; + + /* If non-zero, overallocate the buffer (default: 0). */ + unsigned char overallocate; + + /* If readonly is 1, buffer is a shared string (cannot be modified) + and size is set to 0. */ + unsigned char readonly; +} _PyUnicodeWriter ; + +// Initialize a Unicode writer. +// +// By default, the minimum buffer size is 0 character and overallocation is +// disabled. Set min_length, min_char and overallocate attributes to control +// the allocation of the buffer. +PyAPI_FUNC(void) +_PyUnicodeWriter_Init(_PyUnicodeWriter *writer); + +/* Prepare the buffer to write 'length' characters + with the specified maximum character. + + Return 0 on success, raise an exception and return -1 on error. */ +#define _PyUnicodeWriter_Prepare(WRITER, LENGTH, MAXCHAR) \ + (((MAXCHAR) <= (WRITER)->maxchar \ + && (LENGTH) <= (WRITER)->size - (WRITER)->pos) \ + ? 0 \ + : (((LENGTH) == 0) \ + ? 0 \ + : _PyUnicodeWriter_PrepareInternal((WRITER), (LENGTH), (MAXCHAR)))) + +/* Don't call this function directly, use the _PyUnicodeWriter_Prepare() macro + instead. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer, + Py_ssize_t length, Py_UCS4 maxchar); + +/* Prepare the buffer to have at least the kind KIND. + For example, kind=PyUnicode_2BYTE_KIND ensures that the writer will + support characters in range U+000-U+FFFF. + + Return 0 on success, raise an exception and return -1 on error. */ +#define _PyUnicodeWriter_PrepareKind(WRITER, KIND) \ + ((KIND) <= (WRITER)->kind \ + ? 0 \ + : _PyUnicodeWriter_PrepareKindInternal((WRITER), (KIND))) + +/* Don't call this function directly, use the _PyUnicodeWriter_PrepareKind() + macro instead. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer, + int kind); + +/* Append a Unicode character. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteChar(_PyUnicodeWriter *writer, + Py_UCS4 ch + ); + +/* Append a Unicode string. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, + PyObject *str /* Unicode string */ + ); + +/* Append a substring of a Unicode string. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer, + PyObject *str, /* Unicode string */ + Py_ssize_t start, + Py_ssize_t end + ); + +/* Append an ASCII-encoded byte string. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer, + const char *str, /* ASCII-encoded byte string */ + Py_ssize_t len /* number of bytes, or -1 if unknown */ + ); + +/* Append a latin1-encoded byte string. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer, + const char *str, /* latin1-encoded byte string */ + Py_ssize_t len /* length in bytes */ + ); + +/* Get the value of the writer as a Unicode string. Clear the + buffer of the writer. Raise an exception and return NULL + on error. */ +PyAPI_FUNC(PyObject *) +_PyUnicodeWriter_Finish(_PyUnicodeWriter *writer); + +/* Deallocate memory of a writer (clear its internal buffer). */ +PyAPI_FUNC(void) +_PyUnicodeWriter_Dealloc(_PyUnicodeWriter *writer); + + +/* --- Manage the default encoding ---------------------------------------- */ + +/* Returns a pointer to the default encoding (UTF-8) of the + Unicode object unicode. + + Like PyUnicode_AsUTF8AndSize(), this also caches the UTF-8 representation + in the unicodeobject. + + _PyUnicode_AsString is a #define for PyUnicode_AsUTF8 to + support the previous internal function with the same behaviour. + + Use of this API is DEPRECATED since no size information can be + extracted from the returned data. +*/ + +PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode); + +// Alias kept for backward compatibility +#define _PyUnicode_AsString PyUnicode_AsUTF8 + + +/* === Characters Type APIs =============================================== */ + +/* These should not be used directly. Use the Py_UNICODE_IS* and + Py_UNICODE_TO* macros instead. + + These APIs are implemented in Objects/unicodectype.c. + +*/ + +PyAPI_FUNC(int) _PyUnicode_IsLowercase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsUppercase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsTitlecase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsWhitespace( + const Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsLinebreak( + const Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UCS4) _PyUnicode_ToLowercase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UCS4) _PyUnicode_ToUppercase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UCS4) _PyUnicode_ToTitlecase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToDigit( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(double) _PyUnicode_ToNumeric( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsDigit( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsNumeric( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsPrintable( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsAlpha( + Py_UCS4 ch /* Unicode character */ + ); + +// Helper array used by Py_UNICODE_ISSPACE(). +PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[]; + +// Since splitting on whitespace is an important use case, and +// whitespace in most situations is solely ASCII whitespace, we +// optimize for the common case by using a quick look-up table +// _Py_ascii_whitespace (see below) with an inlined check. +static inline int Py_UNICODE_ISSPACE(Py_UCS4 ch) { + if (ch < 128) { + return _Py_ascii_whitespace[ch]; + } + return _PyUnicode_IsWhitespace(ch); +} + +#define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) +#define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) +#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) +#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) + +#define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) +#define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) +#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) + +#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) +#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) +#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) +#define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch) + +#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) +#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) +#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) + +#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) + +static inline int Py_UNICODE_ISALNUM(Py_UCS4 ch) { + return (Py_UNICODE_ISALPHA(ch) + || Py_UNICODE_ISDECIMAL(ch) + || Py_UNICODE_ISDIGIT(ch) + || Py_UNICODE_ISNUMERIC(ch)); +} + + +/* === Misc functions ===================================================== */ + +// Return an interned Unicode object for an Identifier; may fail if there is no +// memory. +PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/warnings.h b/illumos-x86_64/usr/include/python3.13/cpython/warnings.h new file mode 100644 index 00000000..8731fd2e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/warnings.h @@ -0,0 +1,26 @@ +#ifndef Py_CPYTHON_WARNINGS_H +# error "this header file must not be included directly" +#endif + +PyAPI_FUNC(int) PyErr_WarnExplicitObject( + PyObject *category, + PyObject *message, + PyObject *filename, + int lineno, + PyObject *module, + PyObject *registry); + +PyAPI_FUNC(int) PyErr_WarnExplicitFormat( + PyObject *category, + const char *filename, int lineno, + const char *module, PyObject *registry, + const char *format, ...); + +// DEPRECATED: Use PyErr_WarnEx() instead. +#define PyErr_Warn(category, msg) PyErr_WarnEx((category), (msg), 1) + +int _PyErr_WarnExplicitObjectWithContext( + PyObject *category, + PyObject *message, + PyObject *filename, + int lineno); diff --git a/illumos-x86_64/usr/include/python3.13/cpython/weakrefobject.h b/illumos-x86_64/usr/include/python3.13/cpython/weakrefobject.h new file mode 100644 index 00000000..28acf726 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/cpython/weakrefobject.h @@ -0,0 +1,63 @@ +#ifndef Py_CPYTHON_WEAKREFOBJECT_H +# error "this header file must not be included directly" +#endif + +/* PyWeakReference is the base struct for the Python ReferenceType, ProxyType, + * and CallableProxyType. + */ +struct _PyWeakReference { + PyObject_HEAD + + /* The object to which this is a weak reference, or Py_None if none. + * Note that this is a stealth reference: wr_object's refcount is + * not incremented to reflect this pointer. + */ + PyObject *wr_object; + + /* A callable to invoke when wr_object dies, or NULL if none. */ + PyObject *wr_callback; + + /* A cache for wr_object's hash code. As usual for hashes, this is -1 + * if the hash code isn't known yet. + */ + Py_hash_t hash; + + /* If wr_object is weakly referenced, wr_object has a doubly-linked NULL- + * terminated list of weak references to it. These are the list pointers. + * If wr_object goes away, wr_object is set to Py_None, and these pointers + * have no meaning then. + */ + PyWeakReference *wr_prev; + PyWeakReference *wr_next; + vectorcallfunc vectorcall; + +#ifdef Py_GIL_DISABLED + /* Pointer to the lock used when clearing in free-threaded builds. + * Normally this can be derived from wr_object, but in some cases we need + * to lock after wr_object has been set to Py_None. + */ + PyMutex *weakrefs_lock; +#endif +}; + +PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); + +Py_DEPRECATED(3.13) static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj) +{ + PyWeakReference *ref; + PyObject *obj; + assert(PyWeakref_Check(ref_obj)); + ref = _Py_CAST(PyWeakReference*, ref_obj); + obj = ref->wr_object; + // Explanation for the Py_REFCNT() check: when a weakref's target is part + // of a long chain of deallocations which triggers the trashcan mechanism, + // clearing the weakrefs can be delayed long after the target's refcount + // has dropped to zero. In the meantime, code accessing the weakref will + // be able to "see" the target object even though it is supposed to be + // unreachable. See issue gh-60806. + if (Py_REFCNT(obj) > 0) { + return obj; + } + return Py_None; +} +#define PyWeakref_GET_OBJECT(ref) PyWeakref_GET_OBJECT(_PyObject_CAST(ref)) diff --git a/illumos-x86_64/usr/include/python3.13/critical_section.h b/illumos-x86_64/usr/include/python3.13/critical_section.h new file mode 100644 index 00000000..3b37615a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/critical_section.h @@ -0,0 +1,16 @@ +#ifndef Py_CRITICAL_SECTION_H +#define Py_CRITICAL_SECTION_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_CRITICAL_SECTION_H +# include "cpython/critical_section.h" +# undef Py_CPYTHON_CRITICAL_SECTION_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CRITICAL_SECTION_H */ diff --git a/illumos-x86_64/usr/include/python3.13/datetime.h b/illumos-x86_64/usr/include/python3.13/datetime.h new file mode 100644 index 00000000..b78cc0e8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/datetime.h @@ -0,0 +1,267 @@ +/* datetime.h + */ +#ifndef Py_LIMITED_API +#ifndef DATETIME_H +#define DATETIME_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Fields are packed into successive bytes, each viewed as unsigned and + * big-endian, unless otherwise noted: + * + * byte offset + * 0 year 2 bytes, 1-9999 + * 2 month 1 byte, 1-12 + * 3 day 1 byte, 1-31 + * 4 hour 1 byte, 0-23 + * 5 minute 1 byte, 0-59 + * 6 second 1 byte, 0-59 + * 7 usecond 3 bytes, 0-999999 + * 10 + */ + +/* # of bytes for year, month, and day. */ +#define _PyDateTime_DATE_DATASIZE 4 + +/* # of bytes for hour, minute, second, and usecond. */ +#define _PyDateTime_TIME_DATASIZE 6 + +/* # of bytes for year, month, day, hour, minute, second, and usecond. */ +#define _PyDateTime_DATETIME_DATASIZE 10 + + +typedef struct +{ + PyObject_HEAD + Py_hash_t hashcode; /* -1 when unknown */ + int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */ + int seconds; /* 0 <= seconds < 24*3600 is invariant */ + int microseconds; /* 0 <= microseconds < 1000000 is invariant */ +} PyDateTime_Delta; + +typedef struct +{ + PyObject_HEAD /* a pure abstract base class */ +} PyDateTime_TZInfo; + + +/* The datetime and time types have hashcodes, and an optional tzinfo member, + * present if and only if hastzinfo is true. + */ +#define _PyTZINFO_HEAD \ + PyObject_HEAD \ + Py_hash_t hashcode; \ + char hastzinfo; /* boolean flag */ + +/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something + * convenient to cast to, when getting at the hastzinfo member of objects + * starting with _PyTZINFO_HEAD. + */ +typedef struct +{ + _PyTZINFO_HEAD +} _PyDateTime_BaseTZInfo; + +/* All time objects are of PyDateTime_TimeType, but that can be allocated + * in two ways, with or without a tzinfo member. Without is the same as + * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an + * internal struct used to allocate the right amount of space for the + * "without" case. + */ +#define _PyDateTime_TIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_TIME_DATASIZE]; + +typedef struct +{ + _PyDateTime_TIMEHEAD +} _PyDateTime_BaseTime; /* hastzinfo false */ + +typedef struct +{ + _PyDateTime_TIMEHEAD + unsigned char fold; + PyObject *tzinfo; +} PyDateTime_Time; /* hastzinfo true */ + + +/* All datetime objects are of PyDateTime_DateTimeType, but that can be + * allocated in two ways too, just like for time objects above. In addition, + * the plain date type is a base class for datetime, so it must also have + * a hastzinfo member (although it's unused there). + */ +typedef struct +{ + _PyTZINFO_HEAD + unsigned char data[_PyDateTime_DATE_DATASIZE]; +} PyDateTime_Date; + +#define _PyDateTime_DATETIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_DATETIME_DATASIZE]; + +typedef struct +{ + _PyDateTime_DATETIMEHEAD +} _PyDateTime_BaseDateTime; /* hastzinfo false */ + +typedef struct +{ + _PyDateTime_DATETIMEHEAD + unsigned char fold; + PyObject *tzinfo; +} PyDateTime_DateTime; /* hastzinfo true */ + + +/* Apply for date and datetime instances. */ + +// o is a pointer to a time or a datetime object. +#define _PyDateTime_HAS_TZINFO(o) (((_PyDateTime_BaseTZInfo *)(o))->hastzinfo) + +#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)(o))->data[0] << 8) | \ + ((PyDateTime_Date*)(o))->data[1]) +#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)(o))->data[2]) +#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)(o))->data[3]) + +#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)(o))->data[4]) +#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)(o))->data[5]) +#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)(o))->data[6]) +#define PyDateTime_DATE_GET_MICROSECOND(o) \ + ((((PyDateTime_DateTime*)(o))->data[7] << 16) | \ + (((PyDateTime_DateTime*)(o))->data[8] << 8) | \ + ((PyDateTime_DateTime*)(o))->data[9]) +#define PyDateTime_DATE_GET_FOLD(o) (((PyDateTime_DateTime*)(o))->fold) +#define PyDateTime_DATE_GET_TZINFO(o) (_PyDateTime_HAS_TZINFO((o)) ? \ + ((PyDateTime_DateTime *)(o))->tzinfo : Py_None) + +/* Apply for time instances. */ +#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)(o))->data[0]) +#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)(o))->data[1]) +#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)(o))->data[2]) +#define PyDateTime_TIME_GET_MICROSECOND(o) \ + ((((PyDateTime_Time*)(o))->data[3] << 16) | \ + (((PyDateTime_Time*)(o))->data[4] << 8) | \ + ((PyDateTime_Time*)(o))->data[5]) +#define PyDateTime_TIME_GET_FOLD(o) (((PyDateTime_Time*)(o))->fold) +#define PyDateTime_TIME_GET_TZINFO(o) (_PyDateTime_HAS_TZINFO(o) ? \ + ((PyDateTime_Time *)(o))->tzinfo : Py_None) + +/* Apply for time delta instances */ +#define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)(o))->days) +#define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)(o))->seconds) +#define PyDateTime_DELTA_GET_MICROSECONDS(o) \ + (((PyDateTime_Delta*)(o))->microseconds) + + +/* Define structure for C API. */ +typedef struct { + /* type objects */ + PyTypeObject *DateType; + PyTypeObject *DateTimeType; + PyTypeObject *TimeType; + PyTypeObject *DeltaType; + PyTypeObject *TZInfoType; + + /* singletons */ + PyObject *TimeZone_UTC; + + /* constructors */ + PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*); + PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, + PyObject*, PyTypeObject*); + PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*); + PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*); + PyObject *(*TimeZone_FromTimeZone)(PyObject *offset, PyObject *name); + + /* constructors for the DB API */ + PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*); + PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*); + + /* PEP 495 constructors */ + PyObject *(*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int, + PyObject*, int, PyTypeObject*); + PyObject *(*Time_FromTimeAndFold)(int, int, int, int, PyObject*, int, PyTypeObject*); + +} PyDateTime_CAPI; + +#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI" + + +/* This block is only used as part of the public API and should not be + * included in _datetimemodule.c, which does not use the C API capsule. + * See bpo-35081 for more details. + * */ +#ifndef _PY_DATETIME_IMPL +/* Define global variable for the C API and a macro for setting it. */ +static PyDateTime_CAPI *PyDateTimeAPI = NULL; + +#define PyDateTime_IMPORT \ + PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) + +/* Macro for access to the UTC singleton */ +#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC + +/* Macros for type checking when not building the Python core. */ +#define PyDate_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DateType) +#define PyDate_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DateType) + +#define PyDateTime_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DateTimeType) +#define PyDateTime_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DateTimeType) + +#define PyTime_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->TimeType) +#define PyTime_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->TimeType) + +#define PyDelta_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DeltaType) +#define PyDelta_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DeltaType) + +#define PyTZInfo_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->TZInfoType) +#define PyTZInfo_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->TZInfoType) + + +/* Macros for accessing constructors in a simplified fashion. */ +#define PyDate_FromDate(year, month, day) \ + PyDateTimeAPI->Date_FromDate((year), (month), (day), PyDateTimeAPI->DateType) + +#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \ + PyDateTimeAPI->DateTime_FromDateAndTime((year), (month), (day), (hour), \ + (min), (sec), (usec), Py_None, PyDateTimeAPI->DateTimeType) + +#define PyDateTime_FromDateAndTimeAndFold(year, month, day, hour, min, sec, usec, fold) \ + PyDateTimeAPI->DateTime_FromDateAndTimeAndFold((year), (month), (day), (hour), \ + (min), (sec), (usec), Py_None, (fold), PyDateTimeAPI->DateTimeType) + +#define PyTime_FromTime(hour, minute, second, usecond) \ + PyDateTimeAPI->Time_FromTime((hour), (minute), (second), (usecond), \ + Py_None, PyDateTimeAPI->TimeType) + +#define PyTime_FromTimeAndFold(hour, minute, second, usecond, fold) \ + PyDateTimeAPI->Time_FromTimeAndFold((hour), (minute), (second), (usecond), \ + Py_None, (fold), PyDateTimeAPI->TimeType) + +#define PyDelta_FromDSU(days, seconds, useconds) \ + PyDateTimeAPI->Delta_FromDelta((days), (seconds), (useconds), 1, \ + PyDateTimeAPI->DeltaType) + +#define PyTimeZone_FromOffset(offset) \ + PyDateTimeAPI->TimeZone_FromTimeZone((offset), NULL) + +#define PyTimeZone_FromOffsetAndName(offset, name) \ + PyDateTimeAPI->TimeZone_FromTimeZone((offset), (name)) + +/* Macros supporting the DB API. */ +#define PyDateTime_FromTimestamp(args) \ + PyDateTimeAPI->DateTime_FromTimestamp( \ + (PyObject*) (PyDateTimeAPI->DateTimeType), (args), NULL) + +#define PyDate_FromTimestamp(args) \ + PyDateTimeAPI->Date_FromTimestamp( \ + (PyObject*) (PyDateTimeAPI->DateType), (args)) + +#endif /* !defined(_PY_DATETIME_IMPL) */ + +#ifdef __cplusplus +} +#endif +#endif +#endif /* !Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/descrobject.h b/illumos-x86_64/usr/include/python3.13/descrobject.h new file mode 100644 index 00000000..fd66d17b --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/descrobject.h @@ -0,0 +1,100 @@ +/* Descriptors */ +#ifndef Py_DESCROBJECT_H +#define Py_DESCROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef PyObject *(*getter)(PyObject *, void *); +typedef int (*setter)(PyObject *, PyObject *, void *); + +struct PyGetSetDef { + const char *name; + getter get; + setter set; + const char *doc; + void *closure; +}; + +PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type; +PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; +PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; +PyAPI_DATA(PyTypeObject) PyMethodDescr_Type; +PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; +PyAPI_DATA(PyTypeObject) PyDictProxy_Type; +PyAPI_DATA(PyTypeObject) PyProperty_Type; + +PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, PyMemberDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, PyGetSetDef *); + +PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); +PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); + + +/* An array of PyMemberDef structures defines the name, type and offset + of selected members of a C structure. These can be read by + PyMember_GetOne() and set by PyMember_SetOne() (except if their READONLY + flag is set). The array must be terminated with an entry whose name + pointer is NULL. */ +struct PyMemberDef { + const char *name; + int type; + Py_ssize_t offset; + int flags; + const char *doc; +}; + +// These constants used to be in structmember.h, not prefixed by Py_. +// (structmember.h now has aliases to the new names.) + +/* Types */ +#define Py_T_SHORT 0 +#define Py_T_INT 1 +#define Py_T_LONG 2 +#define Py_T_FLOAT 3 +#define Py_T_DOUBLE 4 +#define Py_T_STRING 5 +#define _Py_T_OBJECT 6 // Deprecated, use Py_T_OBJECT_EX instead +/* the ordering here is weird for binary compatibility */ +#define Py_T_CHAR 7 /* 1-character string */ +#define Py_T_BYTE 8 /* 8-bit signed int */ +/* unsigned variants: */ +#define Py_T_UBYTE 9 +#define Py_T_USHORT 10 +#define Py_T_UINT 11 +#define Py_T_ULONG 12 + +/* Added by Jack: strings contained in the structure */ +#define Py_T_STRING_INPLACE 13 + +/* Added by Lillo: bools contained in the structure (assumed char) */ +#define Py_T_BOOL 14 + +#define Py_T_OBJECT_EX 16 +#define Py_T_LONGLONG 17 +#define Py_T_ULONGLONG 18 + +#define Py_T_PYSSIZET 19 /* Py_ssize_t */ +#define _Py_T_NONE 20 // Deprecated. Value is always None. + +/* Flags */ +#define Py_READONLY 1 +#define Py_AUDIT_READ 2 // Added in 3.10, harmless no-op before that +#define _Py_WRITE_RESTRICTED 4 // Deprecated, no-op. Do not reuse the value. +#define Py_RELATIVE_OFFSET 8 + +PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, PyMemberDef *); +PyAPI_FUNC(int) PyMember_SetOne(char *, PyMemberDef *, PyObject *); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_DESCROBJECT_H +# include "cpython/descrobject.h" +# undef Py_CPYTHON_DESCROBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_DESCROBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/dictobject.h b/illumos-x86_64/usr/include/python3.13/dictobject.h new file mode 100644 index 00000000..1bbeec1a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/dictobject.h @@ -0,0 +1,108 @@ +#ifndef Py_DICTOBJECT_H +#define Py_DICTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Dictionary object type -- mapping from hashable object to object */ + +/* The distribution includes a separate file, Objects/dictnotes.txt, + describing explorations into dictionary design and optimization. + It covers typical dictionary use patterns, the parameters for + tuning dictionaries, and several ideas for possible optimizations. +*/ + +PyAPI_DATA(PyTypeObject) PyDict_Type; + +#define PyDict_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) +#define PyDict_CheckExact(op) Py_IS_TYPE((op), &PyDict_Type) + +PyAPI_FUNC(PyObject *) PyDict_New(void); +PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); +PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key); +PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); +PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); +PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); +PyAPI_FUNC(int) PyDict_Next( + PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value); +PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp); +PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); +PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); + +/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ +PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); + +/* PyDict_Merge updates/merges from a mapping object (an object that + supports PyMapping_Keys() and PyObject_GetItem()). If override is true, + the last occurrence of a key wins, else the first. The Python + dict.update(other) is equivalent to PyDict_Merge(dict, other, 1). +*/ +PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, + PyObject *other, + int override); + +/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing + iterable objects of length 2. If override is true, the last occurrence + of a key wins, else the first. The Python dict constructor dict(seq2) + is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1). +*/ +PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, + PyObject *seq2, + int override); + +PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); +PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); +PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +// Return the object from dictionary *op* which has a key *key*. +// - If the key is present, set *result to a new strong reference to the value +// and return 1. +// - If the key is missing, set *result to NULL and return 0 . +// - On error, raise an exception and return -1. +PyAPI_FUNC(int) PyDict_GetItemRef(PyObject *mp, PyObject *key, PyObject **result); +PyAPI_FUNC(int) PyDict_GetItemStringRef(PyObject *mp, const char *key, PyObject **result); +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *); +#endif + +/* Dictionary (keys, values, items) views */ + +PyAPI_DATA(PyTypeObject) PyDictKeys_Type; +PyAPI_DATA(PyTypeObject) PyDictValues_Type; +PyAPI_DATA(PyTypeObject) PyDictItems_Type; + +#define PyDictKeys_Check(op) PyObject_TypeCheck((op), &PyDictKeys_Type) +#define PyDictValues_Check(op) PyObject_TypeCheck((op), &PyDictValues_Type) +#define PyDictItems_Check(op) PyObject_TypeCheck((op), &PyDictItems_Type) +/* This excludes Values, since they are not sets. */ +# define PyDictViewSet_Check(op) \ + (PyDictKeys_Check(op) || PyDictItems_Check(op)) + +/* Dictionary (key, value, items) iterators */ + +PyAPI_DATA(PyTypeObject) PyDictIterKey_Type; +PyAPI_DATA(PyTypeObject) PyDictIterValue_Type; +PyAPI_DATA(PyTypeObject) PyDictIterItem_Type; + +PyAPI_DATA(PyTypeObject) PyDictRevIterKey_Type; +PyAPI_DATA(PyTypeObject) PyDictRevIterItem_Type; +PyAPI_DATA(PyTypeObject) PyDictRevIterValue_Type; + + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_DICTOBJECT_H +# include "cpython/dictobject.h" +# undef Py_CPYTHON_DICTOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_DICTOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/dynamic_annotations.h b/illumos-x86_64/usr/include/python3.13/dynamic_annotations.h new file mode 100644 index 00000000..4d4def9b --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/dynamic_annotations.h @@ -0,0 +1,499 @@ +/* Copyright (c) 2008-2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Kostya Serebryany + * Copied to CPython by Jeffrey Yasskin, with all macros renamed to + * start with _Py_ to avoid colliding with users embedding Python, and + * with deprecated macros removed. + */ + +/* This file defines dynamic annotations for use with dynamic analysis + tool such as valgrind, PIN, etc. + + Dynamic annotation is a source code annotation that affects + the generated code (that is, the annotation is not a comment). + Each such annotation is attached to a particular + instruction and/or to a particular object (address) in the program. + + The annotations that should be used by users are macros in all upper-case + (e.g., _Py_ANNOTATE_NEW_MEMORY). + + Actual implementation of these macros may differ depending on the + dynamic analysis tool being used. + + See https://code.google.com/p/data-race-test/ for more information. + + This file supports the following dynamic analysis tools: + - None (DYNAMIC_ANNOTATIONS_ENABLED is not defined or zero). + Macros are defined empty. + - ThreadSanitizer, Helgrind, DRD (DYNAMIC_ANNOTATIONS_ENABLED is 1). + Macros are defined as calls to non-inlinable empty functions + that are intercepted by Valgrind. */ + +#ifndef __DYNAMIC_ANNOTATIONS_H__ +#define __DYNAMIC_ANNOTATIONS_H__ + +#ifndef DYNAMIC_ANNOTATIONS_ENABLED +# define DYNAMIC_ANNOTATIONS_ENABLED 0 +#endif + +#if DYNAMIC_ANNOTATIONS_ENABLED != 0 + + /* ------------------------------------------------------------- + Annotations useful when implementing condition variables such as CondVar, + using conditional critical sections (Await/LockWhen) and when constructing + user-defined synchronization mechanisms. + + The annotations _Py_ANNOTATE_HAPPENS_BEFORE() and + _Py_ANNOTATE_HAPPENS_AFTER() can be used to define happens-before arcs in + user-defined synchronization mechanisms: the race detector will infer an + arc from the former to the latter when they share the same argument + pointer. + + Example 1 (reference counting): + + void Unref() { + _Py_ANNOTATE_HAPPENS_BEFORE(&refcount_); + if (AtomicDecrementByOne(&refcount_) == 0) { + _Py_ANNOTATE_HAPPENS_AFTER(&refcount_); + delete this; + } + } + + Example 2 (message queue): + + void MyQueue::Put(Type *e) { + MutexLock lock(&mu_); + _Py_ANNOTATE_HAPPENS_BEFORE(e); + PutElementIntoMyQueue(e); + } + + Type *MyQueue::Get() { + MutexLock lock(&mu_); + Type *e = GetElementFromMyQueue(); + _Py_ANNOTATE_HAPPENS_AFTER(e); + return e; + } + + Note: when possible, please use the existing reference counting and message + queue implementations instead of inventing new ones. */ + + /* Report that wait on the condition variable at address "cv" has succeeded + and the lock at address "lock" is held. */ +#define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) \ + AnnotateCondVarWait(__FILE__, __LINE__, cv, lock) + + /* Report that wait on the condition variable at "cv" has succeeded. Variant + w/o lock. */ +#define _Py_ANNOTATE_CONDVAR_WAIT(cv) \ + AnnotateCondVarWait(__FILE__, __LINE__, cv, NULL) + + /* Report that we are about to signal on the condition variable at address + "cv". */ +#define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) \ + AnnotateCondVarSignal(__FILE__, __LINE__, cv) + + /* Report that we are about to signal_all on the condition variable at "cv". */ +#define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) \ + AnnotateCondVarSignalAll(__FILE__, __LINE__, cv) + + /* Annotations for user-defined synchronization mechanisms. */ +#define _Py_ANNOTATE_HAPPENS_BEFORE(obj) _Py_ANNOTATE_CONDVAR_SIGNAL(obj) +#define _Py_ANNOTATE_HAPPENS_AFTER(obj) _Py_ANNOTATE_CONDVAR_WAIT(obj) + + /* Report that the bytes in the range [pointer, pointer+size) are about + to be published safely. The race checker will create a happens-before + arc from the call _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) to + subsequent accesses to this memory. + Note: this annotation may not work properly if the race detector uses + sampling, i.e. does not observe all memory accesses. + */ +#define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) \ + AnnotatePublishMemoryRange(__FILE__, __LINE__, pointer, size) + + /* Instruct the tool to create a happens-before arc between mu->Unlock() and + mu->Lock(). This annotation may slow down the race detector and hide real + races. Normally it is used only when it would be difficult to annotate each + of the mutex's critical sections individually using the annotations above. + This annotation makes sense only for hybrid race detectors. For pure + happens-before detectors this is a no-op. For more details see + https://code.google.com/p/data-race-test/wiki/PureHappensBeforeVsHybrid . */ +#define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) \ + AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu) + + /* ------------------------------------------------------------- + Annotations useful when defining memory allocators, or when memory that + was protected in one way starts to be protected in another. */ + + /* Report that a new memory at "address" of size "size" has been allocated. + This might be used when the memory has been retrieved from a free list and + is about to be reused, or when the locking discipline for a variable + changes. */ +#define _Py_ANNOTATE_NEW_MEMORY(address, size) \ + AnnotateNewMemory(__FILE__, __LINE__, address, size) + + /* ------------------------------------------------------------- + Annotations useful when defining FIFO queues that transfer data between + threads. */ + + /* Report that the producer-consumer queue (such as ProducerConsumerQueue) at + address "pcq" has been created. The _Py_ANNOTATE_PCQ_* annotations should + be used only for FIFO queues. For non-FIFO queues use + _Py_ANNOTATE_HAPPENS_BEFORE (for put) and _Py_ANNOTATE_HAPPENS_AFTER (for + get). */ +#define _Py_ANNOTATE_PCQ_CREATE(pcq) \ + AnnotatePCQCreate(__FILE__, __LINE__, pcq) + + /* Report that the queue at address "pcq" is about to be destroyed. */ +#define _Py_ANNOTATE_PCQ_DESTROY(pcq) \ + AnnotatePCQDestroy(__FILE__, __LINE__, pcq) + + /* Report that we are about to put an element into a FIFO queue at address + "pcq". */ +#define _Py_ANNOTATE_PCQ_PUT(pcq) \ + AnnotatePCQPut(__FILE__, __LINE__, pcq) + + /* Report that we've just got an element from a FIFO queue at address "pcq". */ +#define _Py_ANNOTATE_PCQ_GET(pcq) \ + AnnotatePCQGet(__FILE__, __LINE__, pcq) + + /* ------------------------------------------------------------- + Annotations that suppress errors. It is usually better to express the + program's synchronization using the other annotations, but these can + be used when all else fails. */ + + /* Report that we may have a benign race at "pointer", with size + "sizeof(*(pointer))". "pointer" must be a non-void* pointer. Insert at the + point where "pointer" has been allocated, preferably close to the point + where the race happens. See also _Py_ANNOTATE_BENIGN_RACE_STATIC. */ +#define _Py_ANNOTATE_BENIGN_RACE(pointer, description) \ + AnnotateBenignRaceSized(__FILE__, __LINE__, pointer, \ + sizeof(*(pointer)), description) + + /* Same as _Py_ANNOTATE_BENIGN_RACE(address, description), but applies to + the memory range [address, address+size). */ +#define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \ + AnnotateBenignRaceSized(__FILE__, __LINE__, address, size, description) + + /* Request the analysis tool to ignore all reads in the current thread + until _Py_ANNOTATE_IGNORE_READS_END is called. + Useful to ignore intentional racey reads, while still checking + other reads and all writes. + See also _Py_ANNOTATE_UNPROTECTED_READ. */ +#define _Py_ANNOTATE_IGNORE_READS_BEGIN() \ + AnnotateIgnoreReadsBegin(__FILE__, __LINE__) + + /* Stop ignoring reads. */ +#define _Py_ANNOTATE_IGNORE_READS_END() \ + AnnotateIgnoreReadsEnd(__FILE__, __LINE__) + + /* Similar to _Py_ANNOTATE_IGNORE_READS_BEGIN, but ignore writes. */ +#define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() \ + AnnotateIgnoreWritesBegin(__FILE__, __LINE__) + + /* Stop ignoring writes. */ +#define _Py_ANNOTATE_IGNORE_WRITES_END() \ + AnnotateIgnoreWritesEnd(__FILE__, __LINE__) + + /* Start ignoring all memory accesses (reads and writes). */ +#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \ + do {\ + _Py_ANNOTATE_IGNORE_READS_BEGIN();\ + _Py_ANNOTATE_IGNORE_WRITES_BEGIN();\ + }while(0)\ + + /* Stop ignoring all memory accesses. */ +#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() \ + do {\ + _Py_ANNOTATE_IGNORE_WRITES_END();\ + _Py_ANNOTATE_IGNORE_READS_END();\ + }while(0)\ + + /* Similar to _Py_ANNOTATE_IGNORE_READS_BEGIN, but ignore synchronization events: + RWLOCK* and CONDVAR*. */ +#define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() \ + AnnotateIgnoreSyncBegin(__FILE__, __LINE__) + + /* Stop ignoring sync events. */ +#define _Py_ANNOTATE_IGNORE_SYNC_END() \ + AnnotateIgnoreSyncEnd(__FILE__, __LINE__) + + + /* Enable (enable!=0) or disable (enable==0) race detection for all threads. + This annotation could be useful if you want to skip expensive race analysis + during some period of program execution, e.g. during initialization. */ +#define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) \ + AnnotateEnableRaceDetection(__FILE__, __LINE__, enable) + + /* ------------------------------------------------------------- + Annotations useful for debugging. */ + + /* Request to trace every access to "address". */ +#define _Py_ANNOTATE_TRACE_MEMORY(address) \ + AnnotateTraceMemory(__FILE__, __LINE__, address) + + /* Report the current thread name to a race detector. */ +#define _Py_ANNOTATE_THREAD_NAME(name) \ + AnnotateThreadName(__FILE__, __LINE__, name) + + /* ------------------------------------------------------------- + Annotations useful when implementing locks. They are not + normally needed by modules that merely use locks. + The "lock" argument is a pointer to the lock object. */ + + /* Report that a lock has been created at address "lock". */ +#define _Py_ANNOTATE_RWLOCK_CREATE(lock) \ + AnnotateRWLockCreate(__FILE__, __LINE__, lock) + + /* Report that the lock at address "lock" is about to be destroyed. */ +#define _Py_ANNOTATE_RWLOCK_DESTROY(lock) \ + AnnotateRWLockDestroy(__FILE__, __LINE__, lock) + + /* Report that the lock at address "lock" has been acquired. + is_w=1 for writer lock, is_w=0 for reader lock. */ +#define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \ + AnnotateRWLockAcquired(__FILE__, __LINE__, lock, is_w) + + /* Report that the lock at address "lock" is about to be released. */ +#define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) \ + AnnotateRWLockReleased(__FILE__, __LINE__, lock, is_w) + + /* ------------------------------------------------------------- + Annotations useful when implementing barriers. They are not + normally needed by modules that merely use barriers. + The "barrier" argument is a pointer to the barrier object. */ + + /* Report that the "barrier" has been initialized with initial "count". + If 'reinitialization_allowed' is true, initialization is allowed to happen + multiple times w/o calling barrier_destroy() */ +#define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) \ + AnnotateBarrierInit(__FILE__, __LINE__, barrier, count, \ + reinitialization_allowed) + + /* Report that we are about to enter barrier_wait("barrier"). */ +#define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) \ + AnnotateBarrierWaitBefore(__FILE__, __LINE__, barrier) + + /* Report that we just exited barrier_wait("barrier"). */ +#define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) \ + AnnotateBarrierWaitAfter(__FILE__, __LINE__, barrier) + + /* Report that the "barrier" has been destroyed. */ +#define _Py_ANNOTATE_BARRIER_DESTROY(barrier) \ + AnnotateBarrierDestroy(__FILE__, __LINE__, barrier) + + /* ------------------------------------------------------------- + Annotations useful for testing race detectors. */ + + /* Report that we expect a race on the variable at "address". + Use only in unit tests for a race detector. */ +#define _Py_ANNOTATE_EXPECT_RACE(address, description) \ + AnnotateExpectRace(__FILE__, __LINE__, address, description) + + /* A no-op. Insert where you like to test the interceptors. */ +#define _Py_ANNOTATE_NO_OP(arg) \ + AnnotateNoOp(__FILE__, __LINE__, arg) + + /* Force the race detector to flush its state. The actual effect depends on + * the implementation of the detector. */ +#define _Py_ANNOTATE_FLUSH_STATE() \ + AnnotateFlushState(__FILE__, __LINE__) + + +#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */ + +#define _Py_ANNOTATE_RWLOCK_CREATE(lock) /* empty */ +#define _Py_ANNOTATE_RWLOCK_DESTROY(lock) /* empty */ +#define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) /* empty */ +#define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) /* empty */ +#define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) /* */ +#define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) /* empty */ +#define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) /* empty */ +#define _Py_ANNOTATE_BARRIER_DESTROY(barrier) /* empty */ +#define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) /* empty */ +#define _Py_ANNOTATE_CONDVAR_WAIT(cv) /* empty */ +#define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) /* empty */ +#define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) /* empty */ +#define _Py_ANNOTATE_HAPPENS_BEFORE(obj) /* empty */ +#define _Py_ANNOTATE_HAPPENS_AFTER(obj) /* empty */ +#define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(address, size) /* empty */ +#define _Py_ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size) /* empty */ +#define _Py_ANNOTATE_SWAP_MEMORY_RANGE(address, size) /* empty */ +#define _Py_ANNOTATE_PCQ_CREATE(pcq) /* empty */ +#define _Py_ANNOTATE_PCQ_DESTROY(pcq) /* empty */ +#define _Py_ANNOTATE_PCQ_PUT(pcq) /* empty */ +#define _Py_ANNOTATE_PCQ_GET(pcq) /* empty */ +#define _Py_ANNOTATE_NEW_MEMORY(address, size) /* empty */ +#define _Py_ANNOTATE_EXPECT_RACE(address, description) /* empty */ +#define _Py_ANNOTATE_BENIGN_RACE(address, description) /* empty */ +#define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) /* empty */ +#define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) /* empty */ +#define _Py_ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) /* empty */ +#define _Py_ANNOTATE_TRACE_MEMORY(arg) /* empty */ +#define _Py_ANNOTATE_THREAD_NAME(name) /* empty */ +#define _Py_ANNOTATE_IGNORE_READS_BEGIN() /* empty */ +#define _Py_ANNOTATE_IGNORE_READS_END() /* empty */ +#define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() /* empty */ +#define _Py_ANNOTATE_IGNORE_WRITES_END() /* empty */ +#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() /* empty */ +#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() /* empty */ +#define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() /* empty */ +#define _Py_ANNOTATE_IGNORE_SYNC_END() /* empty */ +#define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) /* empty */ +#define _Py_ANNOTATE_NO_OP(arg) /* empty */ +#define _Py_ANNOTATE_FLUSH_STATE() /* empty */ + +#endif /* DYNAMIC_ANNOTATIONS_ENABLED */ + +/* Use the macros above rather than using these functions directly. */ +#ifdef __cplusplus +extern "C" { +#endif +void AnnotateRWLockCreate(const char *file, int line, + const volatile void *lock); +void AnnotateRWLockDestroy(const char *file, int line, + const volatile void *lock); +void AnnotateRWLockAcquired(const char *file, int line, + const volatile void *lock, long is_w); +void AnnotateRWLockReleased(const char *file, int line, + const volatile void *lock, long is_w); +void AnnotateBarrierInit(const char *file, int line, + const volatile void *barrier, long count, + long reinitialization_allowed); +void AnnotateBarrierWaitBefore(const char *file, int line, + const volatile void *barrier); +void AnnotateBarrierWaitAfter(const char *file, int line, + const volatile void *barrier); +void AnnotateBarrierDestroy(const char *file, int line, + const volatile void *barrier); +void AnnotateCondVarWait(const char *file, int line, + const volatile void *cv, + const volatile void *lock); +void AnnotateCondVarSignal(const char *file, int line, + const volatile void *cv); +void AnnotateCondVarSignalAll(const char *file, int line, + const volatile void *cv); +void AnnotatePublishMemoryRange(const char *file, int line, + const volatile void *address, + long size); +void AnnotateUnpublishMemoryRange(const char *file, int line, + const volatile void *address, + long size); +void AnnotatePCQCreate(const char *file, int line, + const volatile void *pcq); +void AnnotatePCQDestroy(const char *file, int line, + const volatile void *pcq); +void AnnotatePCQPut(const char *file, int line, + const volatile void *pcq); +void AnnotatePCQGet(const char *file, int line, + const volatile void *pcq); +void AnnotateNewMemory(const char *file, int line, + const volatile void *address, + long size); +void AnnotateExpectRace(const char *file, int line, + const volatile void *address, + const char *description); +void AnnotateBenignRace(const char *file, int line, + const volatile void *address, + const char *description); +void AnnotateBenignRaceSized(const char *file, int line, + const volatile void *address, + long size, + const char *description); +void AnnotateMutexIsUsedAsCondVar(const char *file, int line, + const volatile void *mu); +void AnnotateTraceMemory(const char *file, int line, + const volatile void *arg); +void AnnotateThreadName(const char *file, int line, + const char *name); +void AnnotateIgnoreReadsBegin(const char *file, int line); +void AnnotateIgnoreReadsEnd(const char *file, int line); +void AnnotateIgnoreWritesBegin(const char *file, int line); +void AnnotateIgnoreWritesEnd(const char *file, int line); +void AnnotateEnableRaceDetection(const char *file, int line, int enable); +void AnnotateNoOp(const char *file, int line, + const volatile void *arg); +void AnnotateFlushState(const char *file, int line); + +/* Return non-zero value if running under valgrind. + + If "valgrind.h" is included into dynamic_annotations.c, + the regular valgrind mechanism will be used. + See http://valgrind.org/docs/manual/manual-core-adv.html about + RUNNING_ON_VALGRIND and other valgrind "client requests". + The file "valgrind.h" may be obtained by doing + svn co svn://svn.valgrind.org/valgrind/trunk/include + + If for some reason you can't use "valgrind.h" or want to fake valgrind, + there are two ways to make this function return non-zero: + - Use environment variable: export RUNNING_ON_VALGRIND=1 + - Make your tool intercept the function RunningOnValgrind() and + change its return value. + */ +int RunningOnValgrind(void); + +#ifdef __cplusplus +} +#endif + +#if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus) + + /* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads. + + Instead of doing + _Py_ANNOTATE_IGNORE_READS_BEGIN(); + ... = x; + _Py_ANNOTATE_IGNORE_READS_END(); + one can use + ... = _Py_ANNOTATE_UNPROTECTED_READ(x); */ + template + inline T _Py_ANNOTATE_UNPROTECTED_READ(const volatile T &x) { + _Py_ANNOTATE_IGNORE_READS_BEGIN(); + T res = x; + _Py_ANNOTATE_IGNORE_READS_END(); + return res; + } + /* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */ +#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \ + namespace { \ + class static_var ## _annotator { \ + public: \ + static_var ## _annotator() { \ + _Py_ANNOTATE_BENIGN_RACE_SIZED(&static_var, \ + sizeof(static_var), \ + # static_var ": " description); \ + } \ + }; \ + static static_var ## _annotator the ## static_var ## _annotator;\ + } +#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */ + +#define _Py_ANNOTATE_UNPROTECTED_READ(x) (x) +#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) /* empty */ + +#endif /* DYNAMIC_ANNOTATIONS_ENABLED */ + +#endif /* __DYNAMIC_ANNOTATIONS_H__ */ diff --git a/illumos-x86_64/usr/include/python3.13/enumobject.h b/illumos-x86_64/usr/include/python3.13/enumobject.h new file mode 100644 index 00000000..c14dbfc8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/enumobject.h @@ -0,0 +1,17 @@ +#ifndef Py_ENUMOBJECT_H +#define Py_ENUMOBJECT_H + +/* Enumerate Object */ + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyEnum_Type; +PyAPI_DATA(PyTypeObject) PyReversed_Type; + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_ENUMOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/errcode.h b/illumos-x86_64/usr/include/python3.13/errcode.h new file mode 100644 index 00000000..dac5cf06 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/errcode.h @@ -0,0 +1,45 @@ +// Error codes passed around between file input, tokenizer, parser and +// interpreter. This is necessary so we can turn them into Python +// exceptions at a higher level. Note that some errors have a +// slightly different meaning when passed from the tokenizer to the +// parser than when passed from the parser to the interpreter; e.g. +// the parser only returns E_EOF when it hits EOF immediately, and it +// never returns E_OK. +// +// The public PyRun_InteractiveOneObjectEx() function can return E_EOF, +// same as its variants: +// +// * PyRun_InteractiveOneObject() +// * PyRun_InteractiveOneFlags() +// * PyRun_InteractiveOne() + +#ifndef Py_ERRCODE_H +#define Py_ERRCODE_H +#ifdef __cplusplus +extern "C" { +#endif + +#define E_OK 10 /* No error */ +#define E_EOF 11 /* End Of File */ +#define E_INTR 12 /* Interrupted */ +#define E_TOKEN 13 /* Bad token */ +#define E_SYNTAX 14 /* Syntax error */ +#define E_NOMEM 15 /* Ran out of memory */ +#define E_DONE 16 /* Parsing complete */ +#define E_ERROR 17 /* Execution error */ +#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */ +#define E_OVERFLOW 19 /* Node had too many children */ +#define E_TOODEEP 20 /* Too many indentation levels */ +#define E_DEDENT 21 /* No matching outer block for dedent */ +#define E_DECODE 22 /* Error in decoding into Unicode */ +#define E_EOFS 23 /* EOF in triple-quoted string */ +#define E_EOLS 24 /* EOL in single-quoted string */ +#define E_LINECONT 25 /* Unexpected characters after a line continuation */ +#define E_BADSINGLE 27 /* Ill-formed single statement input */ +#define E_INTERACT_STOP 28 /* Interactive mode stopped tokenization */ +#define E_COLUMNOVERFLOW 29 /* Column offset overflow */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ERRCODE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/exports.h b/illumos-x86_64/usr/include/python3.13/exports.h new file mode 100644 index 00000000..ce601216 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/exports.h @@ -0,0 +1,108 @@ +#ifndef Py_EXPORTS_H +#define Py_EXPORTS_H + +/* Declarations for symbol visibility. + + PyAPI_FUNC(type): Declares a public Python API function and return type + PyAPI_DATA(type): Declares public Python data and its type + PyMODINIT_FUNC: A Python module init function. If these functions are + inside the Python core, they are private to the core. + If in an extension module, it may be declared with + external linkage depending on the platform. + + As a number of platforms support/require "__declspec(dllimport/dllexport)", + we support a HAVE_DECLSPEC_DLL macro to save duplication. +*/ + +/* + All windows ports, except cygwin, are handled in PC/pyconfig.h. + + Cygwin is the only other autoconf platform requiring special + linkage handling and it uses __declspec(). +*/ +#if defined(__CYGWIN__) +# define HAVE_DECLSPEC_DLL +#endif + +#if defined(_WIN32) || defined(__CYGWIN__) + #if defined(Py_ENABLE_SHARED) + #define Py_IMPORTED_SYMBOL __declspec(dllimport) + #define Py_EXPORTED_SYMBOL __declspec(dllexport) + #define Py_LOCAL_SYMBOL + #else + #define Py_IMPORTED_SYMBOL + #define Py_EXPORTED_SYMBOL + #define Py_LOCAL_SYMBOL + #endif +#else +/* + * If we only ever used gcc >= 5, we could use __has_attribute(visibility) + * as a cross-platform way to determine if visibility is supported. However, + * we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions + * have 4 < gcc < 5. + */ + #ifndef __has_attribute + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. + #endif + #if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\ + (defined(__clang__) && __has_attribute(visibility)) + #define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default"))) + #define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default"))) + #define Py_LOCAL_SYMBOL __attribute__ ((visibility ("hidden"))) + #else + #define Py_IMPORTED_SYMBOL + #define Py_EXPORTED_SYMBOL + #define Py_LOCAL_SYMBOL + #endif +#endif + +/* only get special linkage if built as shared or platform is Cygwin */ +#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) +# if defined(HAVE_DECLSPEC_DLL) +# if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) +# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE +# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE + /* module init functions inside the core need no external linkage */ + /* except for Cygwin to handle embedding */ +# if defined(__CYGWIN__) +# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject* +# else /* __CYGWIN__ */ +# define PyMODINIT_FUNC PyObject* +# endif /* __CYGWIN__ */ +# else /* Py_BUILD_CORE */ + /* Building an extension module, or an embedded situation */ + /* public Python functions and data are imported */ + /* Under Cygwin, auto-import functions to prevent compilation */ + /* failures similar to those described at the bottom of 4.1: */ + /* http://docs.python.org/extending/windows.html#a-cookbook-approach */ +# if !defined(__CYGWIN__) +# define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE +# endif /* !__CYGWIN__ */ +# define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE + /* module init functions outside the core must be exported */ +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject* +# else /* __cplusplus */ +# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject* +# endif /* __cplusplus */ +# endif /* Py_BUILD_CORE */ +# endif /* HAVE_DECLSPEC_DLL */ +#endif /* Py_ENABLE_SHARED */ + +/* If no external linkage macros defined by now, create defaults */ +#ifndef PyAPI_FUNC +# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE +#endif +#ifndef PyAPI_DATA +# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE +#endif +#ifndef PyMODINIT_FUNC +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject* +# else /* __cplusplus */ +# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject* +# endif /* __cplusplus */ +#endif + + +#endif /* Py_EXPORTS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/fileobject.h b/illumos-x86_64/usr/include/python3.13/fileobject.h new file mode 100644 index 00000000..6a6d1140 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/fileobject.h @@ -0,0 +1,41 @@ +/* File object interface (what's left of it -- see io.py) */ + +#ifndef Py_FILEOBJECT_H +#define Py_FILEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#define PY_STDIOTEXTMODE "b" + +PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int, + const char *, const char *, + const char *, int); +PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); +PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); +PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); +PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); + +/* The default encoding used by the platform file system APIs + If non-NULL, this is different than the default encoding for strings +*/ +Py_DEPRECATED(3.12) PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000 +Py_DEPRECATED(3.12) PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors; +#endif +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding; + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 +Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_UTF8Mode; +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_FILEOBJECT_H +# include "cpython/fileobject.h" +# undef Py_CPYTHON_FILEOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FILEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/fileutils.h b/illumos-x86_64/usr/include/python3.13/fileutils.h new file mode 100644 index 00000000..1509198e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/fileutils.h @@ -0,0 +1,62 @@ +#ifndef Py_FILEUTILS_H +#define Py_FILEUTILS_H + +/******************************* + * stat() and fstat() fiddling * + *******************************/ + +#ifdef HAVE_SYS_STAT_H +# include // S_ISREG() +#elif defined(HAVE_STAT_H) +# include // S_ISREG() +#endif + +#ifndef S_IFMT + // VisualAge C/C++ Failed to Define MountType Field in sys/stat.h. +# define S_IFMT 0170000 +#endif +#ifndef S_IFLNK + // Windows doesn't define S_IFLNK, but posixmodule.c maps + // IO_REPARSE_TAG_SYMLINK to S_IFLNK. +# define S_IFLNK 0120000 +#endif +#ifndef S_ISREG +# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) +#endif +#ifndef S_ISDIR +# define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif +#ifndef S_ISCHR +# define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR) +#endif +#ifndef S_ISLNK +# define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) +#endif + + +// Move this down here since some C++ #include's don't like to be included +// inside an extern "C". +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +PyAPI_FUNC(wchar_t *) Py_DecodeLocale( + const char *arg, + size_t *size); + +PyAPI_FUNC(char*) Py_EncodeLocale( + const wchar_t *text, + size_t *error_pos); +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_FILEUTILS_H +# include "cpython/fileutils.h" +# undef Py_CPYTHON_FILEUTILS_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FILEUTILS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/floatobject.h b/illumos-x86_64/usr/include/python3.13/floatobject.h new file mode 100644 index 00000000..8963c168 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/floatobject.h @@ -0,0 +1,54 @@ + +/* Float object interface */ + +/* +PyFloatObject represents a (double precision) floating-point number. +*/ + +#ifndef Py_FLOATOBJECT_H +#define Py_FLOATOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyFloat_Type; + +#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) +#define PyFloat_CheckExact(op) Py_IS_TYPE((op), &PyFloat_Type) + +#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN) + +#define Py_RETURN_INF(sign) \ + do { \ + if (copysign(1., sign) == 1.) { \ + return PyFloat_FromDouble(Py_HUGE_VAL); \ + } \ + else { \ + return PyFloat_FromDouble(-Py_HUGE_VAL); \ + } \ + } while(0) + +PyAPI_FUNC(double) PyFloat_GetMax(void); +PyAPI_FUNC(double) PyFloat_GetMin(void); +PyAPI_FUNC(PyObject*) PyFloat_GetInfo(void); + +/* Return Python float from string PyObject. */ +PyAPI_FUNC(PyObject*) PyFloat_FromString(PyObject*); + +/* Return Python float from C double. */ +PyAPI_FUNC(PyObject*) PyFloat_FromDouble(double); + +/* Extract C double from Python float. The macro version trades safety for + speed. */ +PyAPI_FUNC(double) PyFloat_AsDouble(PyObject*); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_FLOATOBJECT_H +# include "cpython/floatobject.h" +# undef Py_CPYTHON_FLOATOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FLOATOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/frameobject.h b/illumos-x86_64/usr/include/python3.13/frameobject.h new file mode 100644 index 00000000..adb628f6 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/frameobject.h @@ -0,0 +1,20 @@ +/* Frame object interface */ + +#ifndef Py_FRAMEOBJECT_H +#define Py_FRAMEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "pyframe.h" + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_FRAMEOBJECT_H +# include "cpython/frameobject.h" +# undef Py_CPYTHON_FRAMEOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FRAMEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/genericaliasobject.h b/illumos-x86_64/usr/include/python3.13/genericaliasobject.h new file mode 100644 index 00000000..cf002976 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/genericaliasobject.h @@ -0,0 +1,14 @@ +// Implementation of PEP 585: support list[int] etc. +#ifndef Py_GENERICALIASOBJECT_H +#define Py_GENERICALIASOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) Py_GenericAlias(PyObject *, PyObject *); +PyAPI_DATA(PyTypeObject) Py_GenericAliasType; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_GENERICALIASOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/import.h b/illumos-x86_64/usr/include/python3.13/import.h new file mode 100644 index 00000000..24b23b91 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/import.h @@ -0,0 +1,103 @@ +/* Module definition and import interface */ + +#ifndef Py_IMPORT_H +#define Py_IMPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(long) PyImport_GetMagicNumber(void); +PyAPI_FUNC(const char *) PyImport_GetMagicTag(void); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule( + const char *name, /* UTF-8 encoded string */ + PyObject *co + ); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( + const char *name, /* UTF-8 encoded string */ + PyObject *co, + const char *pathname /* decoded from the filesystem encoding */ + ); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames( + const char *name, /* UTF-8 encoded string */ + PyObject *co, + const char *pathname, /* decoded from the filesystem encoding */ + const char *cpathname /* decoded from the filesystem encoding */ + ); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject( + PyObject *name, + PyObject *co, + PyObject *pathname, + PyObject *cpathname + ); +#endif +PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 +PyAPI_FUNC(PyObject *) PyImport_GetModule(PyObject *name); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject *) PyImport_AddModuleObject( + PyObject *name + ); +#endif +PyAPI_FUNC(PyObject *) PyImport_AddModule( + const char *name /* UTF-8 encoded string */ + ); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(PyObject *) PyImport_AddModuleRef( + const char *name /* UTF-8 encoded string */ + ); +#endif +PyAPI_FUNC(PyObject *) PyImport_ImportModule( + const char *name /* UTF-8 encoded string */ + ); +Py_DEPRECATED(3.13) PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock( + const char *name /* UTF-8 encoded string */ + ); +PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel( + const char *name, /* UTF-8 encoded string */ + PyObject *globals, + PyObject *locals, + PyObject *fromlist, + int level + ); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject( + PyObject *name, + PyObject *globals, + PyObject *locals, + PyObject *fromlist, + int level + ); +#endif + +#define PyImport_ImportModuleEx(n, g, l, f) \ + PyImport_ImportModuleLevel((n), (g), (l), (f), 0) + +PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path); +PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); +PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject( + PyObject *name + ); +#endif +PyAPI_FUNC(int) PyImport_ImportFrozenModule( + const char *name /* UTF-8 encoded string */ + ); + +PyAPI_FUNC(int) PyImport_AppendInittab( + const char *name, /* ASCII encoded string */ + PyObject* (*initfunc)(void) + ); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_IMPORT_H +# include "cpython/import.h" +# undef Py_CPYTHON_IMPORT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_IMPORT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc.h b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc.h new file mode 100644 index 00000000..821129e7 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc.h @@ -0,0 +1,565 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2023, Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ +#pragma once +#ifndef MIMALLOC_H +#define MIMALLOC_H + +#define MI_MALLOC_VERSION 212 // major + 2 digits minor + +// ------------------------------------------------------ +// Compiler specific attributes +// ------------------------------------------------------ + +#ifdef __cplusplus + #if (__cplusplus >= 201103L) || (_MSC_VER > 1900) // C++11 + #define mi_attr_noexcept noexcept + #else + #define mi_attr_noexcept throw() + #endif +#else + #define mi_attr_noexcept +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201703) + #define mi_decl_nodiscard [[nodiscard]] +#elif (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) // includes clang, icc, and clang-cl + #define mi_decl_nodiscard __attribute__((warn_unused_result)) +#elif defined(_HAS_NODISCARD) + #define mi_decl_nodiscard _NODISCARD +#elif (_MSC_VER >= 1700) + #define mi_decl_nodiscard _Check_return_ +#else + #define mi_decl_nodiscard +#endif + +#if defined(_MSC_VER) || defined(__MINGW32__) + #if !defined(MI_SHARED_LIB) + #define mi_decl_export + #elif defined(MI_SHARED_LIB_EXPORT) + #define mi_decl_export __declspec(dllexport) + #else + #define mi_decl_export __declspec(dllimport) + #endif + #if defined(__MINGW32__) + #define mi_decl_restrict + #define mi_attr_malloc __attribute__((malloc)) + #else + #if (_MSC_VER >= 1900) && !defined(__EDG__) + #define mi_decl_restrict __declspec(allocator) __declspec(restrict) + #else + #define mi_decl_restrict __declspec(restrict) + #endif + #define mi_attr_malloc + #endif + #define mi_cdecl __cdecl + #define mi_attr_alloc_size(s) + #define mi_attr_alloc_size2(s1,s2) + #define mi_attr_alloc_align(p) +#elif defined(__GNUC__) // includes clang and icc + #if defined(MI_SHARED_LIB) && defined(MI_SHARED_LIB_EXPORT) + #define mi_decl_export __attribute__((visibility("default"))) + #else + #define mi_decl_export + #endif + #define mi_cdecl // leads to warnings... __attribute__((cdecl)) + #define mi_decl_restrict + #define mi_attr_malloc __attribute__((malloc)) + #if (defined(__clang_major__) && (__clang_major__ < 4)) || (__GNUC__ < 5) + #define mi_attr_alloc_size(s) + #define mi_attr_alloc_size2(s1,s2) + #define mi_attr_alloc_align(p) + #elif defined(__INTEL_COMPILER) + #define mi_attr_alloc_size(s) __attribute__((alloc_size(s))) + #define mi_attr_alloc_size2(s1,s2) __attribute__((alloc_size(s1,s2))) + #define mi_attr_alloc_align(p) + #else + #define mi_attr_alloc_size(s) __attribute__((alloc_size(s))) + #define mi_attr_alloc_size2(s1,s2) __attribute__((alloc_size(s1,s2))) + #define mi_attr_alloc_align(p) __attribute__((alloc_align(p))) + #endif +#else + #define mi_cdecl + #define mi_decl_export + #define mi_decl_restrict + #define mi_attr_malloc + #define mi_attr_alloc_size(s) + #define mi_attr_alloc_size2(s1,s2) + #define mi_attr_alloc_align(p) +#endif + +// ------------------------------------------------------ +// Includes +// ------------------------------------------------------ + +#include // size_t +#include // bool +#include // INTPTR_MAX + +#ifdef __cplusplus +extern "C" { +#endif + +// ------------------------------------------------------ +// Standard malloc interface +// ------------------------------------------------------ + +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_calloc(size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(1,2); +mi_decl_nodiscard mi_decl_export void* mi_realloc(void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(2); +mi_decl_export void* mi_expand(void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(2); + +mi_decl_export void mi_free(void* p) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_strdup(const char* s) mi_attr_noexcept mi_attr_malloc; +mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_strndup(const char* s, size_t n) mi_attr_noexcept mi_attr_malloc; +mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_realpath(const char* fname, char* resolved_name) mi_attr_noexcept mi_attr_malloc; + +// ------------------------------------------------------ +// Extended functionality +// ------------------------------------------------------ +#define MI_SMALL_WSIZE_MAX (128) +#define MI_SMALL_SIZE_MAX (MI_SMALL_WSIZE_MAX*sizeof(void*)) + +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_small(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_zalloc_small(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_zalloc(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); + +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_mallocn(size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(1,2); +mi_decl_nodiscard mi_decl_export void* mi_reallocn(void* p, size_t count, size_t size) mi_attr_noexcept mi_attr_alloc_size2(2,3); +mi_decl_nodiscard mi_decl_export void* mi_reallocf(void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(2); + +mi_decl_nodiscard mi_decl_export size_t mi_usable_size(const void* p) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export size_t mi_good_size(size_t size) mi_attr_noexcept; + + +// ------------------------------------------------------ +// Internals +// ------------------------------------------------------ + +typedef void (mi_cdecl mi_deferred_free_fun)(bool force, unsigned long long heartbeat, void* arg); +mi_decl_export void mi_register_deferred_free(mi_deferred_free_fun* deferred_free, void* arg) mi_attr_noexcept; + +typedef void (mi_cdecl mi_output_fun)(const char* msg, void* arg); +mi_decl_export void mi_register_output(mi_output_fun* out, void* arg) mi_attr_noexcept; + +typedef void (mi_cdecl mi_error_fun)(int err, void* arg); +mi_decl_export void mi_register_error(mi_error_fun* fun, void* arg); + +mi_decl_export void mi_collect(bool force) mi_attr_noexcept; +mi_decl_export int mi_version(void) mi_attr_noexcept; +mi_decl_export void mi_stats_reset(void) mi_attr_noexcept; +mi_decl_export void mi_stats_merge(void) mi_attr_noexcept; +mi_decl_export void mi_stats_print(void* out) mi_attr_noexcept; // backward compatibility: `out` is ignored and should be NULL +mi_decl_export void mi_stats_print_out(mi_output_fun* out, void* arg) mi_attr_noexcept; + +mi_decl_export void mi_process_init(void) mi_attr_noexcept; +mi_decl_export void mi_thread_init(void) mi_attr_noexcept; +mi_decl_export void mi_thread_done(void) mi_attr_noexcept; +mi_decl_export void mi_thread_stats_print_out(mi_output_fun* out, void* arg) mi_attr_noexcept; + +mi_decl_export void mi_process_info(size_t* elapsed_msecs, size_t* user_msecs, size_t* system_msecs, + size_t* current_rss, size_t* peak_rss, + size_t* current_commit, size_t* peak_commit, size_t* page_faults) mi_attr_noexcept; + +// ------------------------------------------------------------------------------------- +// Aligned allocation +// Note that `alignment` always follows `size` for consistency with unaligned +// allocation, but unfortunately this differs from `posix_memalign` and `aligned_alloc`. +// ------------------------------------------------------------------------------------- + +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_zalloc_aligned(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_calloc_aligned(size_t count, size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(1,2) mi_attr_alloc_align(3); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(1,2); +mi_decl_nodiscard mi_decl_export void* mi_realloc_aligned(void* p, size_t newsize, size_t alignment) mi_attr_noexcept mi_attr_alloc_size(2) mi_attr_alloc_align(3); +mi_decl_nodiscard mi_decl_export void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size(2); + + +// ------------------------------------------------------------------------------------- +// Heaps: first-class, but can only allocate from the same thread that created it. +// ------------------------------------------------------------------------------------- + +struct mi_heap_s; +typedef struct mi_heap_s mi_heap_t; + +mi_decl_nodiscard mi_decl_export mi_heap_t* mi_heap_new(void); +mi_decl_export void mi_heap_delete(mi_heap_t* heap); +mi_decl_export void mi_heap_destroy(mi_heap_t* heap); +mi_decl_export mi_heap_t* mi_heap_set_default(mi_heap_t* heap); +mi_decl_export mi_heap_t* mi_heap_get_default(void); +mi_decl_export mi_heap_t* mi_heap_get_backing(void); +mi_decl_export void mi_heap_collect(mi_heap_t* heap, bool force) mi_attr_noexcept; + +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_malloc(mi_heap_t* heap, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_zalloc(mi_heap_t* heap, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2, 3); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2, 3); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_malloc_small(mi_heap_t* heap, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2); + +mi_decl_nodiscard mi_decl_export void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(3); +mi_decl_nodiscard mi_decl_export void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size) mi_attr_noexcept mi_attr_alloc_size2(3,4); +mi_decl_nodiscard mi_decl_export void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(3); + +mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_heap_strdup(mi_heap_t* heap, const char* s) mi_attr_noexcept mi_attr_malloc; +mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n) mi_attr_noexcept mi_attr_malloc; +mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept mi_attr_malloc; + +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2) mi_attr_alloc_align(3); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2) mi_attr_alloc_align(3); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2, 3) mi_attr_alloc_align(4); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2, 3); +mi_decl_nodiscard mi_decl_export void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment) mi_attr_noexcept mi_attr_alloc_size(3) mi_attr_alloc_align(4); +mi_decl_nodiscard mi_decl_export void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size(3); + + +// -------------------------------------------------------------------------------- +// Zero initialized re-allocation. +// Only valid on memory that was originally allocated with zero initialization too. +// e.g. `mi_calloc`, `mi_zalloc`, `mi_zalloc_aligned` etc. +// see +// -------------------------------------------------------------------------------- + +mi_decl_nodiscard mi_decl_export void* mi_rezalloc(void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(2); +mi_decl_nodiscard mi_decl_export void* mi_recalloc(void* p, size_t newcount, size_t size) mi_attr_noexcept mi_attr_alloc_size2(2,3); + +mi_decl_nodiscard mi_decl_export void* mi_rezalloc_aligned(void* p, size_t newsize, size_t alignment) mi_attr_noexcept mi_attr_alloc_size(2) mi_attr_alloc_align(3); +mi_decl_nodiscard mi_decl_export void* mi_rezalloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size(2); +mi_decl_nodiscard mi_decl_export void* mi_recalloc_aligned(void* p, size_t newcount, size_t size, size_t alignment) mi_attr_noexcept mi_attr_alloc_size2(2,3) mi_attr_alloc_align(4); +mi_decl_nodiscard mi_decl_export void* mi_recalloc_aligned_at(void* p, size_t newcount, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size2(2,3); + +mi_decl_nodiscard mi_decl_export void* mi_heap_rezalloc(mi_heap_t* heap, void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(3); +mi_decl_nodiscard mi_decl_export void* mi_heap_recalloc(mi_heap_t* heap, void* p, size_t newcount, size_t size) mi_attr_noexcept mi_attr_alloc_size2(3,4); + +mi_decl_nodiscard mi_decl_export void* mi_heap_rezalloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment) mi_attr_noexcept mi_attr_alloc_size(3) mi_attr_alloc_align(4); +mi_decl_nodiscard mi_decl_export void* mi_heap_rezalloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size(3); +mi_decl_nodiscard mi_decl_export void* mi_heap_recalloc_aligned(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment) mi_attr_noexcept mi_attr_alloc_size2(3,4) mi_attr_alloc_align(5); +mi_decl_nodiscard mi_decl_export void* mi_heap_recalloc_aligned_at(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size2(3,4); + + +// ------------------------------------------------------ +// Analysis +// ------------------------------------------------------ + +mi_decl_export bool mi_heap_contains_block(mi_heap_t* heap, const void* p); +mi_decl_export bool mi_heap_check_owned(mi_heap_t* heap, const void* p); +mi_decl_export bool mi_check_owned(const void* p); + +// An area of heap space contains blocks of a single size. +typedef struct mi_heap_area_s { + void* blocks; // start of the area containing heap blocks + size_t reserved; // bytes reserved for this area (virtual) + size_t committed; // current available bytes for this area + size_t used; // number of allocated blocks + size_t block_size; // size in bytes of each block + size_t full_block_size; // size in bytes of a full block including padding and metadata. +} mi_heap_area_t; + +typedef bool (mi_cdecl mi_block_visit_fun)(const mi_heap_t* heap, const mi_heap_area_t* area, void* block, size_t block_size, void* arg); + +mi_decl_export bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_all_blocks, mi_block_visit_fun* visitor, void* arg); + +// Experimental +mi_decl_nodiscard mi_decl_export bool mi_is_in_heap_region(const void* p) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export bool mi_is_redirected(void) mi_attr_noexcept; + +mi_decl_export int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t timeout_msecs) mi_attr_noexcept; +mi_decl_export int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msecs) mi_attr_noexcept; + +mi_decl_export int mi_reserve_os_memory(size_t size, bool commit, bool allow_large) mi_attr_noexcept; +mi_decl_export bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node) mi_attr_noexcept; + +mi_decl_export void mi_debug_show_arenas(void) mi_attr_noexcept; + +// Experimental: heaps associated with specific memory arena's +typedef int mi_arena_id_t; +mi_decl_export void* mi_arena_area(mi_arena_id_t arena_id, size_t* size); +mi_decl_export int mi_reserve_huge_os_pages_at_ex(size_t pages, int numa_node, size_t timeout_msecs, bool exclusive, mi_arena_id_t* arena_id) mi_attr_noexcept; +mi_decl_export int mi_reserve_os_memory_ex(size_t size, bool commit, bool allow_large, bool exclusive, mi_arena_id_t* arena_id) mi_attr_noexcept; +mi_decl_export bool mi_manage_os_memory_ex(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node, bool exclusive, mi_arena_id_t* arena_id) mi_attr_noexcept; + +#if MI_MALLOC_VERSION >= 182 +// Create a heap that only allocates in the specified arena +mi_decl_nodiscard mi_decl_export mi_heap_t* mi_heap_new_in_arena(mi_arena_id_t arena_id); +#endif + +// deprecated +mi_decl_export int mi_reserve_huge_os_pages(size_t pages, double max_secs, size_t* pages_reserved) mi_attr_noexcept; + + +// ------------------------------------------------------ +// Convenience +// ------------------------------------------------------ + +#define mi_malloc_tp(tp) ((tp*)mi_malloc(sizeof(tp))) +#define mi_zalloc_tp(tp) ((tp*)mi_zalloc(sizeof(tp))) +#define mi_calloc_tp(tp,n) ((tp*)mi_calloc(n,sizeof(tp))) +#define mi_mallocn_tp(tp,n) ((tp*)mi_mallocn(n,sizeof(tp))) +#define mi_reallocn_tp(p,tp,n) ((tp*)mi_reallocn(p,n,sizeof(tp))) +#define mi_recalloc_tp(p,tp,n) ((tp*)mi_recalloc(p,n,sizeof(tp))) + +#define mi_heap_malloc_tp(hp,tp) ((tp*)mi_heap_malloc(hp,sizeof(tp))) +#define mi_heap_zalloc_tp(hp,tp) ((tp*)mi_heap_zalloc(hp,sizeof(tp))) +#define mi_heap_calloc_tp(hp,tp,n) ((tp*)mi_heap_calloc(hp,n,sizeof(tp))) +#define mi_heap_mallocn_tp(hp,tp,n) ((tp*)mi_heap_mallocn(hp,n,sizeof(tp))) +#define mi_heap_reallocn_tp(hp,p,tp,n) ((tp*)mi_heap_reallocn(hp,p,n,sizeof(tp))) +#define mi_heap_recalloc_tp(hp,p,tp,n) ((tp*)mi_heap_recalloc(hp,p,n,sizeof(tp))) + + +// ------------------------------------------------------ +// Options +// ------------------------------------------------------ + +typedef enum mi_option_e { + // stable options + mi_option_show_errors, // print error messages + mi_option_show_stats, // print statistics on termination + mi_option_verbose, // print verbose messages + // the following options are experimental (see src/options.h) + mi_option_eager_commit, // eager commit segments? (after `eager_commit_delay` segments) (=1) + mi_option_arena_eager_commit, // eager commit arenas? Use 2 to enable just on overcommit systems (=2) + mi_option_purge_decommits, // should a memory purge decommit (or only reset) (=1) + mi_option_allow_large_os_pages, // allow large (2MiB) OS pages, implies eager commit + mi_option_reserve_huge_os_pages, // reserve N huge OS pages (1GiB/page) at startup + mi_option_reserve_huge_os_pages_at, // reserve huge OS pages at a specific NUMA node + mi_option_reserve_os_memory, // reserve specified amount of OS memory in an arena at startup + mi_option_deprecated_segment_cache, + mi_option_deprecated_page_reset, + mi_option_abandoned_page_purge, // immediately purge delayed purges on thread termination + mi_option_deprecated_segment_reset, + mi_option_eager_commit_delay, + mi_option_purge_delay, // memory purging is delayed by N milli seconds; use 0 for immediate purging or -1 for no purging at all. + mi_option_use_numa_nodes, // 0 = use all available numa nodes, otherwise use at most N nodes. + mi_option_limit_os_alloc, // 1 = do not use OS memory for allocation (but only programmatically reserved arenas) + mi_option_os_tag, // tag used for OS logging (macOS only for now) + mi_option_max_errors, // issue at most N error messages + mi_option_max_warnings, // issue at most N warning messages + mi_option_max_segment_reclaim, + mi_option_destroy_on_exit, // if set, release all memory on exit; sometimes used for dynamic unloading but can be unsafe. + mi_option_arena_reserve, // initial memory size in KiB for arena reservation (1GiB on 64-bit) + mi_option_arena_purge_mult, + mi_option_purge_extend_delay, + _mi_option_last, + // legacy option names + mi_option_large_os_pages = mi_option_allow_large_os_pages, + mi_option_eager_region_commit = mi_option_arena_eager_commit, + mi_option_reset_decommits = mi_option_purge_decommits, + mi_option_reset_delay = mi_option_purge_delay, + mi_option_abandoned_page_reset = mi_option_abandoned_page_purge +} mi_option_t; + + +mi_decl_nodiscard mi_decl_export bool mi_option_is_enabled(mi_option_t option); +mi_decl_export void mi_option_enable(mi_option_t option); +mi_decl_export void mi_option_disable(mi_option_t option); +mi_decl_export void mi_option_set_enabled(mi_option_t option, bool enable); +mi_decl_export void mi_option_set_enabled_default(mi_option_t option, bool enable); + +mi_decl_nodiscard mi_decl_export long mi_option_get(mi_option_t option); +mi_decl_nodiscard mi_decl_export long mi_option_get_clamp(mi_option_t option, long min, long max); +mi_decl_nodiscard mi_decl_export size_t mi_option_get_size(mi_option_t option); +mi_decl_export void mi_option_set(mi_option_t option, long value); +mi_decl_export void mi_option_set_default(mi_option_t option, long value); + + +// ------------------------------------------------------------------------------------------------------- +// "mi" prefixed implementations of various posix, Unix, Windows, and C++ allocation functions. +// (This can be convenient when providing overrides of these functions as done in `mimalloc-override.h`.) +// note: we use `mi_cfree` as "checked free" and it checks if the pointer is in our heap before free-ing. +// ------------------------------------------------------------------------------------------------------- + +mi_decl_export void mi_cfree(void* p) mi_attr_noexcept; +mi_decl_export void* mi__expand(void* p, size_t newsize) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export size_t mi_malloc_size(const void* p) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export size_t mi_malloc_good_size(size_t size) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export size_t mi_malloc_usable_size(const void *p) mi_attr_noexcept; + +mi_decl_export int mi_posix_memalign(void** p, size_t alignment, size_t size) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_memalign(size_t alignment, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2) mi_attr_alloc_align(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_valloc(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_pvalloc(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_aligned_alloc(size_t alignment, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2) mi_attr_alloc_align(1); + +mi_decl_nodiscard mi_decl_export void* mi_reallocarray(void* p, size_t count, size_t size) mi_attr_noexcept mi_attr_alloc_size2(2,3); +mi_decl_nodiscard mi_decl_export int mi_reallocarr(void* p, size_t count, size_t size) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export void* mi_aligned_recalloc(void* p, size_t newcount, size_t size, size_t alignment) mi_attr_noexcept; +mi_decl_nodiscard mi_decl_export void* mi_aligned_offset_recalloc(void* p, size_t newcount, size_t size, size_t alignment, size_t offset) mi_attr_noexcept; + +mi_decl_nodiscard mi_decl_export mi_decl_restrict unsigned short* mi_wcsdup(const unsigned short* s) mi_attr_noexcept mi_attr_malloc; +mi_decl_nodiscard mi_decl_export mi_decl_restrict unsigned char* mi_mbsdup(const unsigned char* s) mi_attr_noexcept mi_attr_malloc; +mi_decl_export int mi_dupenv_s(char** buf, size_t* size, const char* name) mi_attr_noexcept; +mi_decl_export int mi_wdupenv_s(unsigned short** buf, size_t* size, const unsigned short* name) mi_attr_noexcept; + +mi_decl_export void mi_free_size(void* p, size_t size) mi_attr_noexcept; +mi_decl_export void mi_free_size_aligned(void* p, size_t size, size_t alignment) mi_attr_noexcept; +mi_decl_export void mi_free_aligned(void* p, size_t alignment) mi_attr_noexcept; + +// The `mi_new` wrappers implement C++ semantics on out-of-memory instead of directly returning `NULL`. +// (and call `std::get_new_handler` and potentially raise a `std::bad_alloc` exception). +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new(size_t size) mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_aligned(size_t size, size_t alignment) mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_nothrow(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_aligned_nothrow(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_n(size_t count, size_t size) mi_attr_malloc mi_attr_alloc_size2(1, 2); +mi_decl_nodiscard mi_decl_export void* mi_new_realloc(void* p, size_t newsize) mi_attr_alloc_size(2); +mi_decl_nodiscard mi_decl_export void* mi_new_reallocn(void* p, size_t newcount, size_t size) mi_attr_alloc_size2(2, 3); + +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_alloc_new(mi_heap_t* heap, size_t size) mi_attr_malloc mi_attr_alloc_size(2); +mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_alloc_new_n(mi_heap_t* heap, size_t count, size_t size) mi_attr_malloc mi_attr_alloc_size2(2, 3); + +#ifdef __cplusplus +} +#endif + +// --------------------------------------------------------------------------------------------- +// Implement the C++ std::allocator interface for use in STL containers. +// (note: see `mimalloc-new-delete.h` for overriding the new/delete operators globally) +// --------------------------------------------------------------------------------------------- +#ifdef __cplusplus + +#include // std::size_t +#include // PTRDIFF_MAX +#if (__cplusplus >= 201103L) || (_MSC_VER > 1900) // C++11 +#include // std::true_type +#include // std::forward +#endif + +template struct _mi_stl_allocator_common { + typedef T value_type; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef value_type& reference; + typedef value_type const& const_reference; + typedef value_type* pointer; + typedef value_type const* const_pointer; + + #if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11 + using propagate_on_container_copy_assignment = std::true_type; + using propagate_on_container_move_assignment = std::true_type; + using propagate_on_container_swap = std::true_type; + template void construct(U* p, Args&& ...args) { ::new(p) U(std::forward(args)...); } + template void destroy(U* p) mi_attr_noexcept { p->~U(); } + #else + void construct(pointer p, value_type const& val) { ::new(p) value_type(val); } + void destroy(pointer p) { p->~value_type(); } + #endif + + size_type max_size() const mi_attr_noexcept { return (PTRDIFF_MAX/sizeof(value_type)); } + pointer address(reference x) const { return &x; } + const_pointer address(const_reference x) const { return &x; } +}; + +template struct mi_stl_allocator : public _mi_stl_allocator_common { + using typename _mi_stl_allocator_common::size_type; + using typename _mi_stl_allocator_common::value_type; + using typename _mi_stl_allocator_common::pointer; + template struct rebind { typedef mi_stl_allocator other; }; + + mi_stl_allocator() mi_attr_noexcept = default; + mi_stl_allocator(const mi_stl_allocator&) mi_attr_noexcept = default; + template mi_stl_allocator(const mi_stl_allocator&) mi_attr_noexcept { } + mi_stl_allocator select_on_container_copy_construction() const { return *this; } + void deallocate(T* p, size_type) { mi_free(p); } + + #if (__cplusplus >= 201703L) // C++17 + mi_decl_nodiscard T* allocate(size_type count) { return static_cast(mi_new_n(count, sizeof(T))); } + mi_decl_nodiscard T* allocate(size_type count, const void*) { return allocate(count); } + #else + mi_decl_nodiscard pointer allocate(size_type count, const void* = 0) { return static_cast(mi_new_n(count, sizeof(value_type))); } + #endif + + #if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11 + using is_always_equal = std::true_type; + #endif +}; + +template bool operator==(const mi_stl_allocator& , const mi_stl_allocator& ) mi_attr_noexcept { return true; } +template bool operator!=(const mi_stl_allocator& , const mi_stl_allocator& ) mi_attr_noexcept { return false; } + + +#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900) // C++11 +#define MI_HAS_HEAP_STL_ALLOCATOR 1 + +#include // std::shared_ptr + +// Common base class for STL allocators in a specific heap +template struct _mi_heap_stl_allocator_common : public _mi_stl_allocator_common { + using typename _mi_stl_allocator_common::size_type; + using typename _mi_stl_allocator_common::value_type; + using typename _mi_stl_allocator_common::pointer; + + _mi_heap_stl_allocator_common(mi_heap_t* hp) : heap(hp) { } /* will not delete nor destroy the passed in heap */ + + #if (__cplusplus >= 201703L) // C++17 + mi_decl_nodiscard T* allocate(size_type count) { return static_cast(mi_heap_alloc_new_n(this->heap.get(), count, sizeof(T))); } + mi_decl_nodiscard T* allocate(size_type count, const void*) { return allocate(count); } + #else + mi_decl_nodiscard pointer allocate(size_type count, const void* = 0) { return static_cast(mi_heap_alloc_new_n(this->heap.get(), count, sizeof(value_type))); } + #endif + + #if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11 + using is_always_equal = std::false_type; + #endif + + void collect(bool force) { mi_heap_collect(this->heap.get(), force); } + template bool is_equal(const _mi_heap_stl_allocator_common& x) const { return (this->heap == x.heap); } + +protected: + std::shared_ptr heap; + template friend struct _mi_heap_stl_allocator_common; + + _mi_heap_stl_allocator_common() { + mi_heap_t* hp = mi_heap_new(); + this->heap.reset(hp, (_mi_destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */ + } + _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { } + template _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { } + +private: + static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } } + static void heap_destroy(mi_heap_t* hp) { if (hp != NULL) { mi_heap_destroy(hp); } } +}; + +// STL allocator allocation in a specific heap +template struct mi_heap_stl_allocator : public _mi_heap_stl_allocator_common { + using typename _mi_heap_stl_allocator_common::size_type; + mi_heap_stl_allocator() : _mi_heap_stl_allocator_common() { } // creates fresh heap that is deleted when the destructor is called + mi_heap_stl_allocator(mi_heap_t* hp) : _mi_heap_stl_allocator_common(hp) { } // no delete nor destroy on the passed in heap + template mi_heap_stl_allocator(const mi_heap_stl_allocator& x) mi_attr_noexcept : _mi_heap_stl_allocator_common(x) { } + + mi_heap_stl_allocator select_on_container_copy_construction() const { return *this; } + void deallocate(T* p, size_type) { mi_free(p); } + template struct rebind { typedef mi_heap_stl_allocator other; }; +}; + +template bool operator==(const mi_heap_stl_allocator& x, const mi_heap_stl_allocator& y) mi_attr_noexcept { return (x.is_equal(y)); } +template bool operator!=(const mi_heap_stl_allocator& x, const mi_heap_stl_allocator& y) mi_attr_noexcept { return (!x.is_equal(y)); } + + +// STL allocator allocation in a specific heap, where `free` does nothing and +// the heap is destroyed in one go on destruction -- use with care! +template struct mi_heap_destroy_stl_allocator : public _mi_heap_stl_allocator_common { + using typename _mi_heap_stl_allocator_common::size_type; + mi_heap_destroy_stl_allocator() : _mi_heap_stl_allocator_common() { } // creates fresh heap that is destroyed when the destructor is called + mi_heap_destroy_stl_allocator(mi_heap_t* hp) : _mi_heap_stl_allocator_common(hp) { } // no delete nor destroy on the passed in heap + template mi_heap_destroy_stl_allocator(const mi_heap_destroy_stl_allocator& x) mi_attr_noexcept : _mi_heap_stl_allocator_common(x) { } + + mi_heap_destroy_stl_allocator select_on_container_copy_construction() const { return *this; } + void deallocate(T*, size_type) { /* do nothing as we destroy the heap on destruct. */ } + template struct rebind { typedef mi_heap_destroy_stl_allocator other; }; +}; + +template bool operator==(const mi_heap_destroy_stl_allocator& x, const mi_heap_destroy_stl_allocator& y) mi_attr_noexcept { return (x.is_equal(y)); } +template bool operator!=(const mi_heap_destroy_stl_allocator& x, const mi_heap_destroy_stl_allocator& y) mi_attr_noexcept { return (!x.is_equal(y)); } + +#endif // C++11 + +#endif // __cplusplus + +#endif diff --git a/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/atomic.h b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/atomic.h new file mode 100644 index 00000000..a46a7676 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/atomic.h @@ -0,0 +1,392 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2023 Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ +#pragma once +#ifndef MIMALLOC_ATOMIC_H +#define MIMALLOC_ATOMIC_H + +// -------------------------------------------------------------------------------------------- +// Atomics +// We need to be portable between C, C++, and MSVC. +// We base the primitives on the C/C++ atomics and create a mimimal wrapper for MSVC in C compilation mode. +// This is why we try to use only `uintptr_t` and `*` as atomic types. +// To gain better insight in the range of used atomics, we use explicitly named memory order operations +// instead of passing the memory order as a parameter. +// ----------------------------------------------------------------------------------------------- + +#if defined(__cplusplus) +// Use C++ atomics +#include +#define _Atomic(tp) std::atomic +#define mi_atomic(name) std::atomic_##name +#define mi_memory_order(name) std::memory_order_##name +#if (__cplusplus >= 202002L) // c++20, see issue #571 + #define MI_ATOMIC_VAR_INIT(x) x +#elif !defined(ATOMIC_VAR_INIT) + #define MI_ATOMIC_VAR_INIT(x) x +#else + #define MI_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x) +#endif +#elif defined(_MSC_VER) +// Use MSVC C wrapper for C11 atomics +#define _Atomic(tp) tp +#define MI_ATOMIC_VAR_INIT(x) x +#define mi_atomic(name) mi_atomic_##name +#define mi_memory_order(name) mi_memory_order_##name +#else +// Use C11 atomics +#include +#define mi_atomic(name) atomic_##name +#define mi_memory_order(name) memory_order_##name +#if (__STDC_VERSION__ >= 201710L) // c17, see issue #735 + #define MI_ATOMIC_VAR_INIT(x) x +#elif !defined(ATOMIC_VAR_INIT) + #define MI_ATOMIC_VAR_INIT(x) x +#else + #define MI_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x) +#endif +#endif + +// Various defines for all used memory orders in mimalloc +#define mi_atomic_cas_weak(p,expected,desired,mem_success,mem_fail) \ + mi_atomic(compare_exchange_weak_explicit)(p,expected,desired,mem_success,mem_fail) + +#define mi_atomic_cas_strong(p,expected,desired,mem_success,mem_fail) \ + mi_atomic(compare_exchange_strong_explicit)(p,expected,desired,mem_success,mem_fail) + +#define mi_atomic_load_acquire(p) mi_atomic(load_explicit)(p,mi_memory_order(acquire)) +#define mi_atomic_load_relaxed(p) mi_atomic(load_explicit)(p,mi_memory_order(relaxed)) +#define mi_atomic_store_release(p,x) mi_atomic(store_explicit)(p,x,mi_memory_order(release)) +#define mi_atomic_store_relaxed(p,x) mi_atomic(store_explicit)(p,x,mi_memory_order(relaxed)) +#define mi_atomic_exchange_release(p,x) mi_atomic(exchange_explicit)(p,x,mi_memory_order(release)) +#define mi_atomic_exchange_acq_rel(p,x) mi_atomic(exchange_explicit)(p,x,mi_memory_order(acq_rel)) +#define mi_atomic_cas_weak_release(p,exp,des) mi_atomic_cas_weak(p,exp,des,mi_memory_order(release),mi_memory_order(relaxed)) +#define mi_atomic_cas_weak_acq_rel(p,exp,des) mi_atomic_cas_weak(p,exp,des,mi_memory_order(acq_rel),mi_memory_order(acquire)) +#define mi_atomic_cas_strong_release(p,exp,des) mi_atomic_cas_strong(p,exp,des,mi_memory_order(release),mi_memory_order(relaxed)) +#define mi_atomic_cas_strong_acq_rel(p,exp,des) mi_atomic_cas_strong(p,exp,des,mi_memory_order(acq_rel),mi_memory_order(acquire)) + +#define mi_atomic_add_relaxed(p,x) mi_atomic(fetch_add_explicit)(p,x,mi_memory_order(relaxed)) +#define mi_atomic_sub_relaxed(p,x) mi_atomic(fetch_sub_explicit)(p,x,mi_memory_order(relaxed)) +#define mi_atomic_add_acq_rel(p,x) mi_atomic(fetch_add_explicit)(p,x,mi_memory_order(acq_rel)) +#define mi_atomic_sub_acq_rel(p,x) mi_atomic(fetch_sub_explicit)(p,x,mi_memory_order(acq_rel)) +#define mi_atomic_and_acq_rel(p,x) mi_atomic(fetch_and_explicit)(p,x,mi_memory_order(acq_rel)) +#define mi_atomic_or_acq_rel(p,x) mi_atomic(fetch_or_explicit)(p,x,mi_memory_order(acq_rel)) + +#define mi_atomic_increment_relaxed(p) mi_atomic_add_relaxed(p,(uintptr_t)1) +#define mi_atomic_decrement_relaxed(p) mi_atomic_sub_relaxed(p,(uintptr_t)1) +#define mi_atomic_increment_acq_rel(p) mi_atomic_add_acq_rel(p,(uintptr_t)1) +#define mi_atomic_decrement_acq_rel(p) mi_atomic_sub_acq_rel(p,(uintptr_t)1) + +static inline void mi_atomic_yield(void); +static inline intptr_t mi_atomic_addi(_Atomic(intptr_t)*p, intptr_t add); +static inline intptr_t mi_atomic_subi(_Atomic(intptr_t)*p, intptr_t sub); + + +#if defined(__cplusplus) || !defined(_MSC_VER) + +// In C++/C11 atomics we have polymorphic atomics so can use the typed `ptr` variants (where `tp` is the type of atomic value) +// We use these macros so we can provide a typed wrapper in MSVC in C compilation mode as well +#define mi_atomic_load_ptr_acquire(tp,p) mi_atomic_load_acquire(p) +#define mi_atomic_load_ptr_relaxed(tp,p) mi_atomic_load_relaxed(p) + +// In C++ we need to add casts to help resolve templates if NULL is passed +#if defined(__cplusplus) +#define mi_atomic_store_ptr_release(tp,p,x) mi_atomic_store_release(p,(tp*)x) +#define mi_atomic_store_ptr_relaxed(tp,p,x) mi_atomic_store_relaxed(p,(tp*)x) +#define mi_atomic_cas_ptr_weak_release(tp,p,exp,des) mi_atomic_cas_weak_release(p,exp,(tp*)des) +#define mi_atomic_cas_ptr_weak_acq_rel(tp,p,exp,des) mi_atomic_cas_weak_acq_rel(p,exp,(tp*)des) +#define mi_atomic_cas_ptr_strong_release(tp,p,exp,des) mi_atomic_cas_strong_release(p,exp,(tp*)des) +#define mi_atomic_exchange_ptr_release(tp,p,x) mi_atomic_exchange_release(p,(tp*)x) +#define mi_atomic_exchange_ptr_acq_rel(tp,p,x) mi_atomic_exchange_acq_rel(p,(tp*)x) +#else +#define mi_atomic_store_ptr_release(tp,p,x) mi_atomic_store_release(p,x) +#define mi_atomic_store_ptr_relaxed(tp,p,x) mi_atomic_store_relaxed(p,x) +#define mi_atomic_cas_ptr_weak_release(tp,p,exp,des) mi_atomic_cas_weak_release(p,exp,des) +#define mi_atomic_cas_ptr_weak_acq_rel(tp,p,exp,des) mi_atomic_cas_weak_acq_rel(p,exp,des) +#define mi_atomic_cas_ptr_strong_release(tp,p,exp,des) mi_atomic_cas_strong_release(p,exp,des) +#define mi_atomic_exchange_ptr_release(tp,p,x) mi_atomic_exchange_release(p,x) +#define mi_atomic_exchange_ptr_acq_rel(tp,p,x) mi_atomic_exchange_acq_rel(p,x) +#endif + +// These are used by the statistics +static inline int64_t mi_atomic_addi64_relaxed(volatile int64_t* p, int64_t add) { + return mi_atomic(fetch_add_explicit)((_Atomic(int64_t)*)p, add, mi_memory_order(relaxed)); +} +static inline void mi_atomic_maxi64_relaxed(volatile int64_t* p, int64_t x) { + int64_t current = mi_atomic_load_relaxed((_Atomic(int64_t)*)p); + while (current < x && !mi_atomic_cas_weak_release((_Atomic(int64_t)*)p, ¤t, x)) { /* nothing */ }; +} + +// Used by timers +#define mi_atomic_loadi64_acquire(p) mi_atomic(load_explicit)(p,mi_memory_order(acquire)) +#define mi_atomic_loadi64_relaxed(p) mi_atomic(load_explicit)(p,mi_memory_order(relaxed)) +#define mi_atomic_storei64_release(p,x) mi_atomic(store_explicit)(p,x,mi_memory_order(release)) +#define mi_atomic_storei64_relaxed(p,x) mi_atomic(store_explicit)(p,x,mi_memory_order(relaxed)) + +#define mi_atomic_casi64_strong_acq_rel(p,e,d) mi_atomic_cas_strong_acq_rel(p,e,d) +#define mi_atomic_addi64_acq_rel(p,i) mi_atomic_add_acq_rel(p,i) + + +#elif defined(_MSC_VER) + +// MSVC C compilation wrapper that uses Interlocked operations to model C11 atomics. +#define WIN32_LEAN_AND_MEAN +#include +#include +#ifdef _WIN64 +typedef LONG64 msc_intptr_t; +#define MI_64(f) f##64 +#else +typedef LONG msc_intptr_t; +#define MI_64(f) f +#endif + +typedef enum mi_memory_order_e { + mi_memory_order_relaxed, + mi_memory_order_consume, + mi_memory_order_acquire, + mi_memory_order_release, + mi_memory_order_acq_rel, + mi_memory_order_seq_cst +} mi_memory_order; + +static inline uintptr_t mi_atomic_fetch_add_explicit(_Atomic(uintptr_t)*p, uintptr_t add, mi_memory_order mo) { + (void)(mo); + return (uintptr_t)MI_64(_InterlockedExchangeAdd)((volatile msc_intptr_t*)p, (msc_intptr_t)add); +} +static inline uintptr_t mi_atomic_fetch_sub_explicit(_Atomic(uintptr_t)*p, uintptr_t sub, mi_memory_order mo) { + (void)(mo); + return (uintptr_t)MI_64(_InterlockedExchangeAdd)((volatile msc_intptr_t*)p, -((msc_intptr_t)sub)); +} +static inline uintptr_t mi_atomic_fetch_and_explicit(_Atomic(uintptr_t)*p, uintptr_t x, mi_memory_order mo) { + (void)(mo); + return (uintptr_t)MI_64(_InterlockedAnd)((volatile msc_intptr_t*)p, (msc_intptr_t)x); +} +static inline uintptr_t mi_atomic_fetch_or_explicit(_Atomic(uintptr_t)*p, uintptr_t x, mi_memory_order mo) { + (void)(mo); + return (uintptr_t)MI_64(_InterlockedOr)((volatile msc_intptr_t*)p, (msc_intptr_t)x); +} +static inline bool mi_atomic_compare_exchange_strong_explicit(_Atomic(uintptr_t)*p, uintptr_t* expected, uintptr_t desired, mi_memory_order mo1, mi_memory_order mo2) { + (void)(mo1); (void)(mo2); + uintptr_t read = (uintptr_t)MI_64(_InterlockedCompareExchange)((volatile msc_intptr_t*)p, (msc_intptr_t)desired, (msc_intptr_t)(*expected)); + if (read == *expected) { + return true; + } + else { + *expected = read; + return false; + } +} +static inline bool mi_atomic_compare_exchange_weak_explicit(_Atomic(uintptr_t)*p, uintptr_t* expected, uintptr_t desired, mi_memory_order mo1, mi_memory_order mo2) { + return mi_atomic_compare_exchange_strong_explicit(p, expected, desired, mo1, mo2); +} +static inline uintptr_t mi_atomic_exchange_explicit(_Atomic(uintptr_t)*p, uintptr_t exchange, mi_memory_order mo) { + (void)(mo); + return (uintptr_t)MI_64(_InterlockedExchange)((volatile msc_intptr_t*)p, (msc_intptr_t)exchange); +} +static inline void mi_atomic_thread_fence(mi_memory_order mo) { + (void)(mo); + _Atomic(uintptr_t) x = 0; + mi_atomic_exchange_explicit(&x, 1, mo); +} +static inline uintptr_t mi_atomic_load_explicit(_Atomic(uintptr_t) const* p, mi_memory_order mo) { + (void)(mo); +#if defined(_M_IX86) || defined(_M_X64) + return *p; +#else + uintptr_t x = *p; + if (mo > mi_memory_order_relaxed) { + while (!mi_atomic_compare_exchange_weak_explicit((_Atomic(uintptr_t)*)p, &x, x, mo, mi_memory_order_relaxed)) { /* nothing */ }; + } + return x; +#endif +} +static inline void mi_atomic_store_explicit(_Atomic(uintptr_t)*p, uintptr_t x, mi_memory_order mo) { + (void)(mo); +#if defined(_M_IX86) || defined(_M_X64) + *p = x; +#else + mi_atomic_exchange_explicit(p, x, mo); +#endif +} +static inline int64_t mi_atomic_loadi64_explicit(_Atomic(int64_t)*p, mi_memory_order mo) { + (void)(mo); +#if defined(_M_X64) + return *p; +#else + int64_t old = *p; + int64_t x = old; + while ((old = InterlockedCompareExchange64(p, x, old)) != x) { + x = old; + } + return x; +#endif +} +static inline void mi_atomic_storei64_explicit(_Atomic(int64_t)*p, int64_t x, mi_memory_order mo) { + (void)(mo); +#if defined(x_M_IX86) || defined(_M_X64) + *p = x; +#else + InterlockedExchange64(p, x); +#endif +} + +// These are used by the statistics +static inline int64_t mi_atomic_addi64_relaxed(volatile _Atomic(int64_t)*p, int64_t add) { +#ifdef _WIN64 + return (int64_t)mi_atomic_addi((int64_t*)p, add); +#else + int64_t current; + int64_t sum; + do { + current = *p; + sum = current + add; + } while (_InterlockedCompareExchange64(p, sum, current) != current); + return current; +#endif +} +static inline void mi_atomic_maxi64_relaxed(volatile _Atomic(int64_t)*p, int64_t x) { + int64_t current; + do { + current = *p; + } while (current < x && _InterlockedCompareExchange64(p, x, current) != current); +} + +static inline void mi_atomic_addi64_acq_rel(volatile _Atomic(int64_t*)p, int64_t i) { + mi_atomic_addi64_relaxed(p, i); +} + +static inline bool mi_atomic_casi64_strong_acq_rel(volatile _Atomic(int64_t*)p, int64_t* exp, int64_t des) { + int64_t read = _InterlockedCompareExchange64(p, des, *exp); + if (read == *exp) { + return true; + } + else { + *exp = read; + return false; + } +} + +// The pointer macros cast to `uintptr_t`. +#define mi_atomic_load_ptr_acquire(tp,p) (tp*)mi_atomic_load_acquire((_Atomic(uintptr_t)*)(p)) +#define mi_atomic_load_ptr_relaxed(tp,p) (tp*)mi_atomic_load_relaxed((_Atomic(uintptr_t)*)(p)) +#define mi_atomic_store_ptr_release(tp,p,x) mi_atomic_store_release((_Atomic(uintptr_t)*)(p),(uintptr_t)(x)) +#define mi_atomic_store_ptr_relaxed(tp,p,x) mi_atomic_store_relaxed((_Atomic(uintptr_t)*)(p),(uintptr_t)(x)) +#define mi_atomic_cas_ptr_weak_release(tp,p,exp,des) mi_atomic_cas_weak_release((_Atomic(uintptr_t)*)(p),(uintptr_t*)exp,(uintptr_t)des) +#define mi_atomic_cas_ptr_weak_acq_rel(tp,p,exp,des) mi_atomic_cas_weak_acq_rel((_Atomic(uintptr_t)*)(p),(uintptr_t*)exp,(uintptr_t)des) +#define mi_atomic_cas_ptr_strong_release(tp,p,exp,des) mi_atomic_cas_strong_release((_Atomic(uintptr_t)*)(p),(uintptr_t*)exp,(uintptr_t)des) +#define mi_atomic_exchange_ptr_release(tp,p,x) (tp*)mi_atomic_exchange_release((_Atomic(uintptr_t)*)(p),(uintptr_t)x) +#define mi_atomic_exchange_ptr_acq_rel(tp,p,x) (tp*)mi_atomic_exchange_acq_rel((_Atomic(uintptr_t)*)(p),(uintptr_t)x) + +#define mi_atomic_loadi64_acquire(p) mi_atomic(loadi64_explicit)(p,mi_memory_order(acquire)) +#define mi_atomic_loadi64_relaxed(p) mi_atomic(loadi64_explicit)(p,mi_memory_order(relaxed)) +#define mi_atomic_storei64_release(p,x) mi_atomic(storei64_explicit)(p,x,mi_memory_order(release)) +#define mi_atomic_storei64_relaxed(p,x) mi_atomic(storei64_explicit)(p,x,mi_memory_order(relaxed)) + + +#endif + + +// Atomically add a signed value; returns the previous value. +static inline intptr_t mi_atomic_addi(_Atomic(intptr_t)*p, intptr_t add) { + return (intptr_t)mi_atomic_add_acq_rel((_Atomic(uintptr_t)*)p, (uintptr_t)add); +} + +// Atomically subtract a signed value; returns the previous value. +static inline intptr_t mi_atomic_subi(_Atomic(intptr_t)*p, intptr_t sub) { + return (intptr_t)mi_atomic_addi(p, -sub); +} + +typedef _Atomic(uintptr_t) mi_atomic_once_t; + +// Returns true only on the first invocation +static inline bool mi_atomic_once( mi_atomic_once_t* once ) { + if (mi_atomic_load_relaxed(once) != 0) return false; // quick test + uintptr_t expected = 0; + return mi_atomic_cas_strong_acq_rel(once, &expected, (uintptr_t)1); // try to set to 1 +} + +typedef _Atomic(uintptr_t) mi_atomic_guard_t; + +// Allows only one thread to execute at a time +#define mi_atomic_guard(guard) \ + uintptr_t _mi_guard_expected = 0; \ + for(bool _mi_guard_once = true; \ + _mi_guard_once && mi_atomic_cas_strong_acq_rel(guard,&_mi_guard_expected,(uintptr_t)1); \ + (mi_atomic_store_release(guard,(uintptr_t)0), _mi_guard_once = false) ) + + + +// Yield +#if defined(__cplusplus) +#include +static inline void mi_atomic_yield(void) { + std::this_thread::yield(); +} +#elif defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +static inline void mi_atomic_yield(void) { + YieldProcessor(); +} +#elif defined(__SSE2__) +#include +static inline void mi_atomic_yield(void) { + _mm_pause(); +} +#elif (defined(__GNUC__) || defined(__clang__)) && \ + (defined(__x86_64__) || defined(__i386__) || \ + defined(__aarch64__) || defined(__arm__) || \ + defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(__POWERPC__)) +#if defined(__x86_64__) || defined(__i386__) +static inline void mi_atomic_yield(void) { + __asm__ volatile ("pause" ::: "memory"); +} +#elif defined(__aarch64__) +static inline void mi_atomic_yield(void) { + __asm__ volatile("wfe"); +} +#elif defined(__arm__) +#if __ARM_ARCH >= 7 +static inline void mi_atomic_yield(void) { + __asm__ volatile("yield" ::: "memory"); +} +#else +static inline void mi_atomic_yield(void) { + __asm__ volatile ("nop" ::: "memory"); +} +#endif +#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(__POWERPC__) +#ifdef __APPLE__ +static inline void mi_atomic_yield(void) { + __asm__ volatile ("or r27,r27,r27" ::: "memory"); +} +#else +static inline void mi_atomic_yield(void) { + __asm__ __volatile__ ("or 27,27,27" ::: "memory"); +} +#endif +#endif +#elif defined(__sun) +// Fallback for other archs +#include +static inline void mi_atomic_yield(void) { + smt_pause(); +} +#elif defined(__wasi__) +#include +static inline void mi_atomic_yield(void) { + sched_yield(); +} +#else +#include +static inline void mi_atomic_yield(void) { + sleep(0); +} +#endif + + +#endif // __MIMALLOC_ATOMIC_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/internal.h b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/internal.h new file mode 100644 index 00000000..1c16152d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/internal.h @@ -0,0 +1,969 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2023, Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ +#pragma once +#ifndef MIMALLOC_INTERNAL_H +#define MIMALLOC_INTERNAL_H + + +// -------------------------------------------------------------------------- +// This file contains the interal API's of mimalloc and various utility +// functions and macros. +// -------------------------------------------------------------------------- + +#include "types.h" +#include "track.h" + +#if (MI_DEBUG>0) +#define mi_trace_message(...) _mi_trace_message(__VA_ARGS__) +#else +#define mi_trace_message(...) +#endif + +#if defined(__EMSCRIPTEN__) && !defined(__wasi__) +#define __wasi__ +#endif + +#if defined(__cplusplus) +#define mi_decl_externc extern "C" +#else +#define mi_decl_externc +#endif + +// pthreads +#if !defined(_WIN32) && !defined(__wasi__) +#define MI_USE_PTHREADS +#include +#endif + +// "options.c" +void _mi_fputs(mi_output_fun* out, void* arg, const char* prefix, const char* message); +void _mi_fprintf(mi_output_fun* out, void* arg, const char* fmt, ...); +void _mi_warning_message(const char* fmt, ...); +void _mi_verbose_message(const char* fmt, ...); +void _mi_trace_message(const char* fmt, ...); +void _mi_options_init(void); +void _mi_error_message(int err, const char* fmt, ...); + +// random.c +void _mi_random_init(mi_random_ctx_t* ctx); +void _mi_random_init_weak(mi_random_ctx_t* ctx); +void _mi_random_reinit_if_weak(mi_random_ctx_t * ctx); +void _mi_random_split(mi_random_ctx_t* ctx, mi_random_ctx_t* new_ctx); +uintptr_t _mi_random_next(mi_random_ctx_t* ctx); +uintptr_t _mi_heap_random_next(mi_heap_t* heap); +uintptr_t _mi_os_random_weak(uintptr_t extra_seed); +static inline uintptr_t _mi_random_shuffle(uintptr_t x); + +// init.c +extern mi_decl_cache_align mi_stats_t _mi_stats_main; +extern mi_decl_cache_align const mi_page_t _mi_page_empty; +bool _mi_is_main_thread(void); +size_t _mi_current_thread_count(void); +bool _mi_preloading(void); // true while the C runtime is not initialized yet +mi_threadid_t _mi_thread_id(void) mi_attr_noexcept; +mi_heap_t* _mi_heap_main_get(void); // statically allocated main backing heap +void _mi_thread_done(mi_heap_t* heap); +void _mi_thread_data_collect(void); +void _mi_tld_init(mi_tld_t* tld, mi_heap_t* bheap); + +// os.c +void _mi_os_init(void); // called from process init +void* _mi_os_alloc(size_t size, mi_memid_t* memid, mi_stats_t* stats); +void _mi_os_free(void* p, size_t size, mi_memid_t memid, mi_stats_t* stats); +void _mi_os_free_ex(void* p, size_t size, bool still_committed, mi_memid_t memid, mi_stats_t* stats); + +size_t _mi_os_page_size(void); +size_t _mi_os_good_alloc_size(size_t size); +bool _mi_os_has_overcommit(void); +bool _mi_os_has_virtual_reserve(void); + +bool _mi_os_purge(void* p, size_t size, mi_stats_t* stats); +bool _mi_os_reset(void* addr, size_t size, mi_stats_t* tld_stats); +bool _mi_os_commit(void* p, size_t size, bool* is_zero, mi_stats_t* stats); +bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* stats); +bool _mi_os_protect(void* addr, size_t size); +bool _mi_os_unprotect(void* addr, size_t size); +bool _mi_os_purge(void* p, size_t size, mi_stats_t* stats); +bool _mi_os_purge_ex(void* p, size_t size, bool allow_reset, mi_stats_t* stats); + +void* _mi_os_alloc_aligned(size_t size, size_t alignment, bool commit, bool allow_large, mi_memid_t* memid, mi_stats_t* stats); +void* _mi_os_alloc_aligned_at_offset(size_t size, size_t alignment, size_t align_offset, bool commit, bool allow_large, mi_memid_t* memid, mi_stats_t* tld_stats); + +void* _mi_os_get_aligned_hint(size_t try_alignment, size_t size); +bool _mi_os_use_large_page(size_t size, size_t alignment); +size_t _mi_os_large_page_size(void); + +void* _mi_os_alloc_huge_os_pages(size_t pages, int numa_node, mi_msecs_t max_secs, size_t* pages_reserved, size_t* psize, mi_memid_t* memid); + +// arena.c +mi_arena_id_t _mi_arena_id_none(void); +void _mi_arena_free(void* p, size_t size, size_t still_committed_size, mi_memid_t memid, mi_stats_t* stats); +void* _mi_arena_alloc(size_t size, bool commit, bool allow_large, mi_arena_id_t req_arena_id, mi_memid_t* memid, mi_os_tld_t* tld); +void* _mi_arena_alloc_aligned(size_t size, size_t alignment, size_t align_offset, bool commit, bool allow_large, mi_arena_id_t req_arena_id, mi_memid_t* memid, mi_os_tld_t* tld); +bool _mi_arena_memid_is_suitable(mi_memid_t memid, mi_arena_id_t request_arena_id); +bool _mi_arena_contains(const void* p); +void _mi_arena_collect(bool force_purge, mi_stats_t* stats); +void _mi_arena_unsafe_destroy_all(mi_stats_t* stats); + +// "segment-map.c" +void _mi_segment_map_allocated_at(const mi_segment_t* segment); +void _mi_segment_map_freed_at(const mi_segment_t* segment); + +// "segment.c" +extern mi_abandoned_pool_t _mi_abandoned_default; // global abandoned pool +mi_page_t* _mi_segment_page_alloc(mi_heap_t* heap, size_t block_size, size_t page_alignment, mi_segments_tld_t* tld, mi_os_tld_t* os_tld); +void _mi_segment_page_free(mi_page_t* page, bool force, mi_segments_tld_t* tld); +void _mi_segment_page_abandon(mi_page_t* page, mi_segments_tld_t* tld); +bool _mi_segment_try_reclaim_abandoned( mi_heap_t* heap, bool try_all, mi_segments_tld_t* tld); +void _mi_segment_thread_collect(mi_segments_tld_t* tld); +bool _mi_abandoned_pool_visit_blocks(mi_abandoned_pool_t* pool, uint8_t page_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg); + + +#if MI_HUGE_PAGE_ABANDON +void _mi_segment_huge_page_free(mi_segment_t* segment, mi_page_t* page, mi_block_t* block); +#else +void _mi_segment_huge_page_reset(mi_segment_t* segment, mi_page_t* page, mi_block_t* block); +#endif + +uint8_t* _mi_segment_page_start(const mi_segment_t* segment, const mi_page_t* page, size_t* page_size); // page start for any page +void _mi_abandoned_reclaim_all(mi_heap_t* heap, mi_segments_tld_t* tld); +void _mi_abandoned_await_readers(mi_abandoned_pool_t *pool); +void _mi_abandoned_collect(mi_heap_t* heap, bool force, mi_segments_tld_t* tld); + +// "page.c" +void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_alignment) mi_attr_noexcept mi_attr_malloc; + +void _mi_page_retire(mi_page_t* page) mi_attr_noexcept; // free the page if there are no other pages with many free blocks +void _mi_page_unfull(mi_page_t* page); +void _mi_page_free(mi_page_t* page, mi_page_queue_t* pq, bool force); // free the page +void _mi_page_abandon(mi_page_t* page, mi_page_queue_t* pq); // abandon the page, to be picked up by another thread... +void _mi_heap_delayed_free_all(mi_heap_t* heap); +bool _mi_heap_delayed_free_partial(mi_heap_t* heap); +void _mi_heap_collect_retired(mi_heap_t* heap, bool force); + +void _mi_page_use_delayed_free(mi_page_t* page, mi_delayed_t delay, bool override_never); +bool _mi_page_try_use_delayed_free(mi_page_t* page, mi_delayed_t delay, bool override_never); +size_t _mi_page_queue_append(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_queue_t* append); +void _mi_deferred_free(mi_heap_t* heap, bool force); + +void _mi_page_free_collect(mi_page_t* page,bool force); +void _mi_page_reclaim(mi_heap_t* heap, mi_page_t* page); // callback from segments + +size_t _mi_bin_size(uint8_t bin); // for stats +uint8_t _mi_bin(size_t size); // for stats + +// "heap.c" +void _mi_heap_init_ex(mi_heap_t* heap, mi_tld_t* tld, mi_arena_id_t arena_id, bool no_reclaim, uint8_t tag); +void _mi_heap_destroy_pages(mi_heap_t* heap); +void _mi_heap_collect_abandon(mi_heap_t* heap); +void _mi_heap_set_default_direct(mi_heap_t* heap); +bool _mi_heap_memid_is_suitable(mi_heap_t* heap, mi_memid_t memid); +void _mi_heap_unsafe_destroy_all(void); +void _mi_heap_area_init(mi_heap_area_t* area, mi_page_t* page); +bool _mi_heap_area_visit_blocks(const mi_heap_area_t* area, mi_page_t *page, mi_block_visit_fun* visitor, void* arg); + +// "stats.c" +void _mi_stats_done(mi_stats_t* stats); +mi_msecs_t _mi_clock_now(void); +mi_msecs_t _mi_clock_end(mi_msecs_t start); +mi_msecs_t _mi_clock_start(void); + +// "alloc.c" +void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t size, bool zero) mi_attr_noexcept; // called from `_mi_malloc_generic` +void* _mi_heap_malloc_zero(mi_heap_t* heap, size_t size, bool zero) mi_attr_noexcept; +void* _mi_heap_malloc_zero_ex(mi_heap_t* heap, size_t size, bool zero, size_t huge_alignment) mi_attr_noexcept; // called from `_mi_heap_malloc_aligned` +void* _mi_heap_realloc_zero(mi_heap_t* heap, void* p, size_t newsize, bool zero) mi_attr_noexcept; +mi_block_t* _mi_page_ptr_unalign(const mi_segment_t* segment, const mi_page_t* page, const void* p); +bool _mi_free_delayed_block(mi_block_t* block); +void _mi_free_generic(const mi_segment_t* segment, mi_page_t* page, bool is_local, void* p) mi_attr_noexcept; // for runtime integration +void _mi_padding_shrink(const mi_page_t* page, const mi_block_t* block, const size_t min_size); + +// option.c, c primitives +char _mi_toupper(char c); +int _mi_strnicmp(const char* s, const char* t, size_t n); +void _mi_strlcpy(char* dest, const char* src, size_t dest_size); +void _mi_strlcat(char* dest, const char* src, size_t dest_size); +size_t _mi_strlen(const char* s); +size_t _mi_strnlen(const char* s, size_t max_len); + + +#if MI_DEBUG>1 +bool _mi_page_is_valid(mi_page_t* page); +#endif + + +// ------------------------------------------------------ +// Branches +// ------------------------------------------------------ + +#if defined(__GNUC__) || defined(__clang__) +#define mi_unlikely(x) (__builtin_expect(!!(x),false)) +#define mi_likely(x) (__builtin_expect(!!(x),true)) +#elif (defined(__cplusplus) && (__cplusplus >= 202002L)) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) +#define mi_unlikely(x) (x) [[unlikely]] +#define mi_likely(x) (x) [[likely]] +#else +#define mi_unlikely(x) (x) +#define mi_likely(x) (x) +#endif + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + + +/* ----------------------------------------------------------- + Error codes passed to `_mi_fatal_error` + All are recoverable but EFAULT is a serious error and aborts by default in secure mode. + For portability define undefined error codes using common Unix codes: + +----------------------------------------------------------- */ +#include +#ifndef EAGAIN // double free +#define EAGAIN (11) +#endif +#ifndef ENOMEM // out of memory +#define ENOMEM (12) +#endif +#ifndef EFAULT // corrupted free-list or meta-data +#define EFAULT (14) +#endif +#ifndef EINVAL // trying to free an invalid pointer +#define EINVAL (22) +#endif +#ifndef EOVERFLOW // count*size overflow +#define EOVERFLOW (75) +#endif + + +/* ----------------------------------------------------------- + Inlined definitions +----------------------------------------------------------- */ +#define MI_UNUSED(x) (void)(x) +#if (MI_DEBUG>0) +#define MI_UNUSED_RELEASE(x) +#else +#define MI_UNUSED_RELEASE(x) MI_UNUSED(x) +#endif + +#define MI_INIT4(x) x(),x(),x(),x() +#define MI_INIT8(x) MI_INIT4(x),MI_INIT4(x) +#define MI_INIT16(x) MI_INIT8(x),MI_INIT8(x) +#define MI_INIT32(x) MI_INIT16(x),MI_INIT16(x) +#define MI_INIT64(x) MI_INIT32(x),MI_INIT32(x) +#define MI_INIT128(x) MI_INIT64(x),MI_INIT64(x) +#define MI_INIT256(x) MI_INIT128(x),MI_INIT128(x) + + +#include +// initialize a local variable to zero; use memset as compilers optimize constant sized memset's +#define _mi_memzero_var(x) memset(&x,0,sizeof(x)) + +// Is `x` a power of two? (0 is considered a power of two) +static inline bool _mi_is_power_of_two(uintptr_t x) { + return ((x & (x - 1)) == 0); +} + +// Is a pointer aligned? +static inline bool _mi_is_aligned(void* p, size_t alignment) { + mi_assert_internal(alignment != 0); + return (((uintptr_t)p % alignment) == 0); +} + +// Align upwards +static inline uintptr_t _mi_align_up(uintptr_t sz, size_t alignment) { + mi_assert_internal(alignment != 0); + uintptr_t mask = alignment - 1; + if ((alignment & mask) == 0) { // power of two? + return ((sz + mask) & ~mask); + } + else { + return (((sz + mask)/alignment)*alignment); + } +} + +// Align downwards +static inline uintptr_t _mi_align_down(uintptr_t sz, size_t alignment) { + mi_assert_internal(alignment != 0); + uintptr_t mask = alignment - 1; + if ((alignment & mask) == 0) { // power of two? + return (sz & ~mask); + } + else { + return ((sz / alignment) * alignment); + } +} + +// Divide upwards: `s <= _mi_divide_up(s,d)*d < s+d`. +static inline uintptr_t _mi_divide_up(uintptr_t size, size_t divider) { + mi_assert_internal(divider != 0); + return (divider == 0 ? size : ((size + divider - 1) / divider)); +} + +// Is memory zero initialized? +static inline bool mi_mem_is_zero(const void* p, size_t size) { + for (size_t i = 0; i < size; i++) { + if (((uint8_t*)p)[i] != 0) return false; + } + return true; +} + + +// Align a byte size to a size in _machine words_, +// i.e. byte size == `wsize*sizeof(void*)`. +static inline size_t _mi_wsize_from_size(size_t size) { + mi_assert_internal(size <= SIZE_MAX - sizeof(uintptr_t)); + return (size + sizeof(uintptr_t) - 1) / sizeof(uintptr_t); +} + +// Overflow detecting multiply +#if __has_builtin(__builtin_umul_overflow) || (defined(__GNUC__) && (__GNUC__ >= 5)) +#include // UINT_MAX, ULONG_MAX +#if defined(_CLOCK_T) // for Illumos +#undef _CLOCK_T +#endif +static inline bool mi_mul_overflow(size_t count, size_t size, size_t* total) { + #if (SIZE_MAX == ULONG_MAX) + return __builtin_umull_overflow(count, size, (unsigned long *)total); + #elif (SIZE_MAX == UINT_MAX) + return __builtin_umul_overflow(count, size, (unsigned int *)total); + #else + return __builtin_umulll_overflow(count, size, (unsigned long long *)total); + #endif +} +#else /* __builtin_umul_overflow is unavailable */ +static inline bool mi_mul_overflow(size_t count, size_t size, size_t* total) { + #define MI_MUL_NO_OVERFLOW ((size_t)1 << (4*sizeof(size_t))) // sqrt(SIZE_MAX) + *total = count * size; + // note: gcc/clang optimize this to directly check the overflow flag + return ((size >= MI_MUL_NO_OVERFLOW || count >= MI_MUL_NO_OVERFLOW) && size > 0 && (SIZE_MAX / size) < count); +} +#endif + +// Safe multiply `count*size` into `total`; return `true` on overflow. +static inline bool mi_count_size_overflow(size_t count, size_t size, size_t* total) { + if (count==1) { // quick check for the case where count is one (common for C++ allocators) + *total = size; + return false; + } + else if mi_unlikely(mi_mul_overflow(count, size, total)) { + #if MI_DEBUG > 0 + _mi_error_message(EOVERFLOW, "allocation request is too large (%zu * %zu bytes)\n", count, size); + #endif + *total = SIZE_MAX; + return true; + } + else return false; +} + + +/*---------------------------------------------------------------------------------------- + Heap functions +------------------------------------------------------------------------------------------- */ + +extern const mi_heap_t _mi_heap_empty; // read-only empty heap, initial value of the thread local default heap + +static inline bool mi_heap_is_backing(const mi_heap_t* heap) { + return (heap->tld->heap_backing == heap); +} + +static inline bool mi_heap_is_initialized(mi_heap_t* heap) { + mi_assert_internal(heap != NULL); + return (heap != &_mi_heap_empty); +} + +static inline uintptr_t _mi_ptr_cookie(const void* p) { + extern mi_heap_t _mi_heap_main; + mi_assert_internal(_mi_heap_main.cookie != 0); + return ((uintptr_t)p ^ _mi_heap_main.cookie); +} + +/* ----------------------------------------------------------- + Pages +----------------------------------------------------------- */ + +static inline mi_page_t* _mi_heap_get_free_small_page(mi_heap_t* heap, size_t size) { + mi_assert_internal(size <= (MI_SMALL_SIZE_MAX + MI_PADDING_SIZE)); + const size_t idx = _mi_wsize_from_size(size); + mi_assert_internal(idx < MI_PAGES_DIRECT); + return heap->pages_free_direct[idx]; +} + +// Segment that contains the pointer +// Large aligned blocks may be aligned at N*MI_SEGMENT_SIZE (inside a huge segment > MI_SEGMENT_SIZE), +// and we need align "down" to the segment info which is `MI_SEGMENT_SIZE` bytes before it; +// therefore we align one byte before `p`. +static inline mi_segment_t* _mi_ptr_segment(const void* p) { + mi_assert_internal(p != NULL); + return (mi_segment_t*)(((uintptr_t)p - 1) & ~MI_SEGMENT_MASK); +} + +static inline mi_page_t* mi_slice_to_page(mi_slice_t* s) { + mi_assert_internal(s->slice_offset== 0 && s->slice_count > 0); + return (mi_page_t*)(s); +} + +static inline mi_slice_t* mi_page_to_slice(mi_page_t* p) { + mi_assert_internal(p->slice_offset== 0 && p->slice_count > 0); + return (mi_slice_t*)(p); +} + +// Segment belonging to a page +static inline mi_segment_t* _mi_page_segment(const mi_page_t* page) { + mi_segment_t* segment = _mi_ptr_segment(page); + mi_assert_internal(segment == NULL || ((mi_slice_t*)page >= segment->slices && (mi_slice_t*)page < segment->slices + segment->slice_entries)); + return segment; +} + +static inline mi_slice_t* mi_slice_first(const mi_slice_t* slice) { + mi_slice_t* start = (mi_slice_t*)((uint8_t*)slice - slice->slice_offset); + mi_assert_internal(start >= _mi_ptr_segment(slice)->slices); + mi_assert_internal(start->slice_offset == 0); + mi_assert_internal(start + start->slice_count > slice); + return start; +} + +// Get the page containing the pointer (performance critical as it is called in mi_free) +static inline mi_page_t* _mi_segment_page_of(const mi_segment_t* segment, const void* p) { + mi_assert_internal(p > (void*)segment); + ptrdiff_t diff = (uint8_t*)p - (uint8_t*)segment; + mi_assert_internal(diff > 0 && diff <= (ptrdiff_t)MI_SEGMENT_SIZE); + size_t idx = (size_t)diff >> MI_SEGMENT_SLICE_SHIFT; + mi_assert_internal(idx <= segment->slice_entries); + mi_slice_t* slice0 = (mi_slice_t*)&segment->slices[idx]; + mi_slice_t* slice = mi_slice_first(slice0); // adjust to the block that holds the page data + mi_assert_internal(slice->slice_offset == 0); + mi_assert_internal(slice >= segment->slices && slice < segment->slices + segment->slice_entries); + return mi_slice_to_page(slice); +} + +// Quick page start for initialized pages +static inline uint8_t* _mi_page_start(const mi_segment_t* segment, const mi_page_t* page, size_t* page_size) { + return _mi_segment_page_start(segment, page, page_size); +} + +// Get the page containing the pointer +static inline mi_page_t* _mi_ptr_page(void* p) { + return _mi_segment_page_of(_mi_ptr_segment(p), p); +} + +// Get the block size of a page (special case for huge objects) +static inline size_t mi_page_block_size(const mi_page_t* page) { + const size_t bsize = page->xblock_size; + mi_assert_internal(bsize > 0); + if mi_likely(bsize < MI_HUGE_BLOCK_SIZE) { + return bsize; + } + else { + size_t psize; + _mi_segment_page_start(_mi_page_segment(page), page, &psize); + return psize; + } +} + +static inline bool mi_page_is_huge(const mi_page_t* page) { + return (_mi_page_segment(page)->kind == MI_SEGMENT_HUGE); +} + +// Get the usable block size of a page without fixed padding. +// This may still include internal padding due to alignment and rounding up size classes. +static inline size_t mi_page_usable_block_size(const mi_page_t* page) { + return mi_page_block_size(page) - MI_PADDING_SIZE; +} + +// size of a segment +static inline size_t mi_segment_size(mi_segment_t* segment) { + return segment->segment_slices * MI_SEGMENT_SLICE_SIZE; +} + +static inline uint8_t* mi_segment_end(mi_segment_t* segment) { + return (uint8_t*)segment + mi_segment_size(segment); +} + +// Thread free access +static inline mi_block_t* mi_page_thread_free(const mi_page_t* page) { + return (mi_block_t*)(mi_atomic_load_relaxed(&((mi_page_t*)page)->xthread_free) & ~3); +} + +static inline mi_delayed_t mi_page_thread_free_flag(const mi_page_t* page) { + return (mi_delayed_t)(mi_atomic_load_relaxed(&((mi_page_t*)page)->xthread_free) & 3); +} + +// Heap access +static inline mi_heap_t* mi_page_heap(const mi_page_t* page) { + return (mi_heap_t*)(mi_atomic_load_relaxed(&((mi_page_t*)page)->xheap)); +} + +static inline void mi_page_set_heap(mi_page_t* page, mi_heap_t* heap) { + mi_assert_internal(mi_page_thread_free_flag(page) != MI_DELAYED_FREEING); + mi_atomic_store_release(&page->xheap,(uintptr_t)heap); +} + +// Thread free flag helpers +static inline mi_block_t* mi_tf_block(mi_thread_free_t tf) { + return (mi_block_t*)(tf & ~0x03); +} +static inline mi_delayed_t mi_tf_delayed(mi_thread_free_t tf) { + return (mi_delayed_t)(tf & 0x03); +} +static inline mi_thread_free_t mi_tf_make(mi_block_t* block, mi_delayed_t delayed) { + return (mi_thread_free_t)((uintptr_t)block | (uintptr_t)delayed); +} +static inline mi_thread_free_t mi_tf_set_delayed(mi_thread_free_t tf, mi_delayed_t delayed) { + return mi_tf_make(mi_tf_block(tf),delayed); +} +static inline mi_thread_free_t mi_tf_set_block(mi_thread_free_t tf, mi_block_t* block) { + return mi_tf_make(block, mi_tf_delayed(tf)); +} + +// are all blocks in a page freed? +// note: needs up-to-date used count, (as the `xthread_free` list may not be empty). see `_mi_page_collect_free`. +static inline bool mi_page_all_free(const mi_page_t* page) { + mi_assert_internal(page != NULL); + return (page->used == 0); +} + +// are there any available blocks? +static inline bool mi_page_has_any_available(const mi_page_t* page) { + mi_assert_internal(page != NULL && page->reserved > 0); + return (page->used < page->reserved || (mi_page_thread_free(page) != NULL)); +} + +// are there immediately available blocks, i.e. blocks available on the free list. +static inline bool mi_page_immediate_available(const mi_page_t* page) { + mi_assert_internal(page != NULL); + return (page->free != NULL); +} + +// is more than 7/8th of a page in use? +static inline bool mi_page_mostly_used(const mi_page_t* page) { + if (page==NULL) return true; + uint16_t frac = page->reserved / 8U; + return (page->reserved - page->used <= frac); +} + +static inline mi_page_queue_t* mi_page_queue(const mi_heap_t* heap, size_t size) { + return &((mi_heap_t*)heap)->pages[_mi_bin(size)]; +} + + + +//----------------------------------------------------------- +// Page flags +//----------------------------------------------------------- +static inline bool mi_page_is_in_full(const mi_page_t* page) { + return page->flags.x.in_full; +} + +static inline void mi_page_set_in_full(mi_page_t* page, bool in_full) { + page->flags.x.in_full = in_full; +} + +static inline bool mi_page_has_aligned(const mi_page_t* page) { + return page->flags.x.has_aligned; +} + +static inline void mi_page_set_has_aligned(mi_page_t* page, bool has_aligned) { + page->flags.x.has_aligned = has_aligned; +} + + +/* ------------------------------------------------------------------- +Encoding/Decoding the free list next pointers + +This is to protect against buffer overflow exploits where the +free list is mutated. Many hardened allocators xor the next pointer `p` +with a secret key `k1`, as `p^k1`. This prevents overwriting with known +values but might be still too weak: if the attacker can guess +the pointer `p` this can reveal `k1` (since `p^k1^p == k1`). +Moreover, if multiple blocks can be read as well, the attacker can +xor both as `(p1^k1) ^ (p2^k1) == p1^p2` which may reveal a lot +about the pointers (and subsequently `k1`). + +Instead mimalloc uses an extra key `k2` and encodes as `((p^k2)<<> (MI_INTPTR_BITS - shift)))); +} +static inline uintptr_t mi_rotr(uintptr_t x, uintptr_t shift) { + shift %= MI_INTPTR_BITS; + return (shift==0 ? x : ((x >> shift) | (x << (MI_INTPTR_BITS - shift)))); +} + +static inline void* mi_ptr_decode(const void* null, const mi_encoded_t x, const uintptr_t* keys) { + void* p = (void*)(mi_rotr(x - keys[0], keys[0]) ^ keys[1]); + return (p==null ? NULL : p); +} + +static inline mi_encoded_t mi_ptr_encode(const void* null, const void* p, const uintptr_t* keys) { + uintptr_t x = (uintptr_t)(p==NULL ? null : p); + return mi_rotl(x ^ keys[1], keys[0]) + keys[0]; +} + +static inline mi_block_t* mi_block_nextx( const void* null, const mi_block_t* block, const uintptr_t* keys ) { + mi_track_mem_defined(block,sizeof(mi_block_t)); + mi_block_t* next; + #ifdef MI_ENCODE_FREELIST + next = (mi_block_t*)mi_ptr_decode(null, mi_atomic_load_relaxed((_Atomic(mi_encoded_t)*)&block->next), keys); + #else + MI_UNUSED(keys); MI_UNUSED(null); + next = (mi_block_t*)mi_atomic_load_relaxed((_Atomic(mi_encoded_t)*)&block->next); + #endif + mi_track_mem_noaccess(block,sizeof(mi_block_t)); + return next; +} + +static inline void mi_block_set_nextx(const void* null, mi_block_t* block, const mi_block_t* next, const uintptr_t* keys) { + mi_track_mem_undefined(block,sizeof(mi_block_t)); + #ifdef MI_ENCODE_FREELIST + mi_atomic_store_relaxed(&block->next, mi_ptr_encode(null, next, keys)); + #else + MI_UNUSED(keys); MI_UNUSED(null); + mi_atomic_store_relaxed(&block->next, (mi_encoded_t)next); + #endif + mi_track_mem_noaccess(block,sizeof(mi_block_t)); +} + +static inline mi_block_t* mi_block_next(const mi_page_t* page, const mi_block_t* block) { + #ifdef MI_ENCODE_FREELIST + mi_block_t* next = mi_block_nextx(page,block,page->keys); + // check for free list corruption: is `next` at least in the same page? + // TODO: check if `next` is `page->block_size` aligned? + if mi_unlikely(next!=NULL && !mi_is_in_same_page(block, next)) { + _mi_error_message(EFAULT, "corrupted free list entry of size %zub at %p: value 0x%zx\n", mi_page_block_size(page), block, (uintptr_t)next); + next = NULL; + } + return next; + #else + MI_UNUSED(page); + return mi_block_nextx(page,block,NULL); + #endif +} + +static inline void mi_block_set_next(const mi_page_t* page, mi_block_t* block, const mi_block_t* next) { + #ifdef MI_ENCODE_FREELIST + mi_block_set_nextx(page,block,next, page->keys); + #else + MI_UNUSED(page); + mi_block_set_nextx(page,block,next,NULL); + #endif +} + + +// ------------------------------------------------------------------- +// commit mask +// ------------------------------------------------------------------- + +static inline void mi_commit_mask_create_empty(mi_commit_mask_t* cm) { + for (size_t i = 0; i < MI_COMMIT_MASK_FIELD_COUNT; i++) { + cm->mask[i] = 0; + } +} + +static inline void mi_commit_mask_create_full(mi_commit_mask_t* cm) { + for (size_t i = 0; i < MI_COMMIT_MASK_FIELD_COUNT; i++) { + cm->mask[i] = ~((size_t)0); + } +} + +static inline bool mi_commit_mask_is_empty(const mi_commit_mask_t* cm) { + for (size_t i = 0; i < MI_COMMIT_MASK_FIELD_COUNT; i++) { + if (cm->mask[i] != 0) return false; + } + return true; +} + +static inline bool mi_commit_mask_is_full(const mi_commit_mask_t* cm) { + for (size_t i = 0; i < MI_COMMIT_MASK_FIELD_COUNT; i++) { + if (cm->mask[i] != ~((size_t)0)) return false; + } + return true; +} + +// defined in `segment.c`: +size_t _mi_commit_mask_committed_size(const mi_commit_mask_t* cm, size_t total); +size_t _mi_commit_mask_next_run(const mi_commit_mask_t* cm, size_t* idx); + +#define mi_commit_mask_foreach(cm,idx,count) \ + idx = 0; \ + while ((count = _mi_commit_mask_next_run(cm,&idx)) > 0) { + +#define mi_commit_mask_foreach_end() \ + idx += count; \ + } + + + +/* ----------------------------------------------------------- + memory id's +----------------------------------------------------------- */ + +static inline mi_memid_t _mi_memid_create(mi_memkind_t memkind) { + mi_memid_t memid; + _mi_memzero_var(memid); + memid.memkind = memkind; + return memid; +} + +static inline mi_memid_t _mi_memid_none(void) { + return _mi_memid_create(MI_MEM_NONE); +} + +static inline mi_memid_t _mi_memid_create_os(bool committed, bool is_zero, bool is_large) { + mi_memid_t memid = _mi_memid_create(MI_MEM_OS); + memid.initially_committed = committed; + memid.initially_zero = is_zero; + memid.is_pinned = is_large; + return memid; +} + + +// ------------------------------------------------------------------- +// Fast "random" shuffle +// ------------------------------------------------------------------- + +static inline uintptr_t _mi_random_shuffle(uintptr_t x) { + if (x==0) { x = 17; } // ensure we don't get stuck in generating zeros +#if (MI_INTPTR_SIZE==8) + // by Sebastiano Vigna, see: + x ^= x >> 30; + x *= 0xbf58476d1ce4e5b9UL; + x ^= x >> 27; + x *= 0x94d049bb133111ebUL; + x ^= x >> 31; +#elif (MI_INTPTR_SIZE==4) + // by Chris Wellons, see: + x ^= x >> 16; + x *= 0x7feb352dUL; + x ^= x >> 15; + x *= 0x846ca68bUL; + x ^= x >> 16; +#endif + return x; +} + +// ------------------------------------------------------------------- +// Optimize numa node access for the common case (= one node) +// ------------------------------------------------------------------- + +int _mi_os_numa_node_get(mi_os_tld_t* tld); +size_t _mi_os_numa_node_count_get(void); + +extern _Atomic(size_t) _mi_numa_node_count; +static inline int _mi_os_numa_node(mi_os_tld_t* tld) { + if mi_likely(mi_atomic_load_relaxed(&_mi_numa_node_count) == 1) { return 0; } + else return _mi_os_numa_node_get(tld); +} +static inline size_t _mi_os_numa_node_count(void) { + const size_t count = mi_atomic_load_relaxed(&_mi_numa_node_count); + if mi_likely(count > 0) { return count; } + else return _mi_os_numa_node_count_get(); +} + + + +// ----------------------------------------------------------------------- +// Count bits: trailing or leading zeros (with MI_INTPTR_BITS on all zero) +// ----------------------------------------------------------------------- + +#if defined(__GNUC__) + +#include // LONG_MAX +#define MI_HAVE_FAST_BITSCAN +static inline size_t mi_clz(uintptr_t x) { + if (x==0) return MI_INTPTR_BITS; +#if (INTPTR_MAX == LONG_MAX) + return __builtin_clzl(x); +#else + return __builtin_clzll(x); +#endif +} +static inline size_t mi_ctz(uintptr_t x) { + if (x==0) return MI_INTPTR_BITS; +#if (INTPTR_MAX == LONG_MAX) + return __builtin_ctzl(x); +#else + return __builtin_ctzll(x); +#endif +} + +#elif defined(_MSC_VER) + +#include // LONG_MAX +#include // BitScanReverse64 +#define MI_HAVE_FAST_BITSCAN +static inline size_t mi_clz(uintptr_t x) { + if (x==0) return MI_INTPTR_BITS; + unsigned long idx; +#if (INTPTR_MAX == LONG_MAX) + _BitScanReverse(&idx, x); +#else + _BitScanReverse64(&idx, x); +#endif + return ((MI_INTPTR_BITS - 1) - idx); +} +static inline size_t mi_ctz(uintptr_t x) { + if (x==0) return MI_INTPTR_BITS; + unsigned long idx; +#if (INTPTR_MAX == LONG_MAX) + _BitScanForward(&idx, x); +#else + _BitScanForward64(&idx, x); +#endif + return idx; +} + +#else +static inline size_t mi_ctz32(uint32_t x) { + // de Bruijn multiplication, see + static const unsigned char debruijn[32] = { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 + }; + if (x==0) return 32; + return debruijn[((x & -(int32_t)x) * 0x077CB531UL) >> 27]; +} +static inline size_t mi_clz32(uint32_t x) { + // de Bruijn multiplication, see + static const uint8_t debruijn[32] = { + 31, 22, 30, 21, 18, 10, 29, 2, 20, 17, 15, 13, 9, 6, 28, 1, + 23, 19, 11, 3, 16, 14, 7, 24, 12, 4, 8, 25, 5, 26, 27, 0 + }; + if (x==0) return 32; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + return debruijn[(uint32_t)(x * 0x07C4ACDDUL) >> 27]; +} + +static inline size_t mi_clz(uintptr_t x) { + if (x==0) return MI_INTPTR_BITS; +#if (MI_INTPTR_BITS <= 32) + return mi_clz32((uint32_t)x); +#else + size_t count = mi_clz32((uint32_t)(x >> 32)); + if (count < 32) return count; + return (32 + mi_clz32((uint32_t)x)); +#endif +} +static inline size_t mi_ctz(uintptr_t x) { + if (x==0) return MI_INTPTR_BITS; +#if (MI_INTPTR_BITS <= 32) + return mi_ctz32((uint32_t)x); +#else + size_t count = mi_ctz32((uint32_t)x); + if (count < 32) return count; + return (32 + mi_ctz32((uint32_t)(x>>32))); +#endif +} + +#endif + +// "bit scan reverse": Return index of the highest bit (or MI_INTPTR_BITS if `x` is zero) +static inline size_t mi_bsr(uintptr_t x) { + return (x==0 ? MI_INTPTR_BITS : MI_INTPTR_BITS - 1 - mi_clz(x)); +} + + +// --------------------------------------------------------------------------------- +// Provide our own `_mi_memcpy` for potential performance optimizations. +// +// For now, only on Windows with msvc/clang-cl we optimize to `rep movsb` if +// we happen to run on x86/x64 cpu's that have "fast short rep movsb" (FSRM) support +// (AMD Zen3+ (~2020) or Intel Ice Lake+ (~2017). See also issue #201 and pr #253. +// --------------------------------------------------------------------------------- + +#if !MI_TRACK_ENABLED && defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64)) +#include +extern bool _mi_cpu_has_fsrm; +static inline void _mi_memcpy(void* dst, const void* src, size_t n) { + if (_mi_cpu_has_fsrm) { + __movsb((unsigned char*)dst, (const unsigned char*)src, n); + } + else { + memcpy(dst, src, n); + } +} +static inline void _mi_memzero(void* dst, size_t n) { + if (_mi_cpu_has_fsrm) { + __stosb((unsigned char*)dst, 0, n); + } + else { + memset(dst, 0, n); + } +} +#else +static inline void _mi_memcpy(void* dst, const void* src, size_t n) { + memcpy(dst, src, n); +} +static inline void _mi_memzero(void* dst, size_t n) { + memset(dst, 0, n); +} +#endif + +// ------------------------------------------------------------------------------- +// The `_mi_memcpy_aligned` can be used if the pointers are machine-word aligned +// This is used for example in `mi_realloc`. +// ------------------------------------------------------------------------------- + +#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) +// On GCC/CLang we provide a hint that the pointers are word aligned. +static inline void _mi_memcpy_aligned(void* dst, const void* src, size_t n) { + mi_assert_internal(((uintptr_t)dst % MI_INTPTR_SIZE == 0) && ((uintptr_t)src % MI_INTPTR_SIZE == 0)); + void* adst = __builtin_assume_aligned(dst, MI_INTPTR_SIZE); + const void* asrc = __builtin_assume_aligned(src, MI_INTPTR_SIZE); + _mi_memcpy(adst, asrc, n); +} + +static inline void _mi_memzero_aligned(void* dst, size_t n) { + mi_assert_internal((uintptr_t)dst % MI_INTPTR_SIZE == 0); + void* adst = __builtin_assume_aligned(dst, MI_INTPTR_SIZE); + _mi_memzero(adst, n); +} +#else +// Default fallback on `_mi_memcpy` +static inline void _mi_memcpy_aligned(void* dst, const void* src, size_t n) { + mi_assert_internal(((uintptr_t)dst % MI_INTPTR_SIZE == 0) && ((uintptr_t)src % MI_INTPTR_SIZE == 0)); + _mi_memcpy(dst, src, n); +} + +static inline void _mi_memzero_aligned(void* dst, size_t n) { + mi_assert_internal((uintptr_t)dst % MI_INTPTR_SIZE == 0); + _mi_memzero(dst, n); +} +#endif + + +#endif diff --git a/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/prim.h b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/prim.h new file mode 100644 index 00000000..322ab29e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/prim.h @@ -0,0 +1,329 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2023, Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ +#pragma once +#ifndef MIMALLOC_PRIM_H +#define MIMALLOC_PRIM_H + + +// -------------------------------------------------------------------------- +// This file specifies the primitive portability API. +// Each OS/host needs to implement these primitives, see `src/prim` +// for implementations on Window, macOS, WASI, and Linux/Unix. +// +// note: on all primitive functions, we always have result parameters != NUL, and: +// addr != NULL and page aligned +// size > 0 and page aligned +// return value is an error code an int where 0 is success. +// -------------------------------------------------------------------------- + +// OS memory configuration +typedef struct mi_os_mem_config_s { + size_t page_size; // 4KiB + size_t large_page_size; // 2MiB + size_t alloc_granularity; // smallest allocation size (on Windows 64KiB) + bool has_overcommit; // can we reserve more memory than can be actually committed? + bool must_free_whole; // must allocated blocks be freed as a whole (false for mmap, true for VirtualAlloc) + bool has_virtual_reserve; // supports virtual address space reservation? (if true we can reserve virtual address space without using commit or physical memory) +} mi_os_mem_config_t; + +// Initialize +void _mi_prim_mem_init( mi_os_mem_config_t* config ); + +// Free OS memory +int _mi_prim_free(void* addr, size_t size ); + +// Allocate OS memory. Return NULL on error. +// The `try_alignment` is just a hint and the returned pointer does not have to be aligned. +// If `commit` is false, the virtual memory range only needs to be reserved (with no access) +// which will later be committed explicitly using `_mi_prim_commit`. +// `is_zero` is set to true if the memory was zero initialized (as on most OS's) +// pre: !commit => !allow_large +// try_alignment >= _mi_os_page_size() and a power of 2 +int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr); + +// Commit memory. Returns error code or 0 on success. +// For example, on Linux this would make the memory PROT_READ|PROT_WRITE. +// `is_zero` is set to true if the memory was zero initialized (e.g. on Windows) +int _mi_prim_commit(void* addr, size_t size, bool* is_zero); + +// Decommit memory. Returns error code or 0 on success. The `needs_recommit` result is true +// if the memory would need to be re-committed. For example, on Windows this is always true, +// but on Linux we could use MADV_DONTNEED to decommit which does not need a recommit. +// pre: needs_recommit != NULL +int _mi_prim_decommit(void* addr, size_t size, bool* needs_recommit); + +// Reset memory. The range keeps being accessible but the content might be reset. +// Returns error code or 0 on success. +int _mi_prim_reset(void* addr, size_t size); + +// Protect memory. Returns error code or 0 on success. +int _mi_prim_protect(void* addr, size_t size, bool protect); + +// Allocate huge (1GiB) pages possibly associated with a NUMA node. +// `is_zero` is set to true if the memory was zero initialized (as on most OS's) +// pre: size > 0 and a multiple of 1GiB. +// numa_node is either negative (don't care), or a numa node number. +int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, bool* is_zero, void** addr); + +// Return the current NUMA node +size_t _mi_prim_numa_node(void); + +// Return the number of logical NUMA nodes +size_t _mi_prim_numa_node_count(void); + +// Clock ticks +mi_msecs_t _mi_prim_clock_now(void); + +// Return process information (only for statistics) +typedef struct mi_process_info_s { + mi_msecs_t elapsed; + mi_msecs_t utime; + mi_msecs_t stime; + size_t current_rss; + size_t peak_rss; + size_t current_commit; + size_t peak_commit; + size_t page_faults; +} mi_process_info_t; + +void _mi_prim_process_info(mi_process_info_t* pinfo); + +// Default stderr output. (only for warnings etc. with verbose enabled) +// msg != NULL && _mi_strlen(msg) > 0 +void _mi_prim_out_stderr( const char* msg ); + +// Get an environment variable. (only for options) +// name != NULL, result != NULL, result_size >= 64 +bool _mi_prim_getenv(const char* name, char* result, size_t result_size); + + +// Fill a buffer with strong randomness; return `false` on error or if +// there is no strong randomization available. +bool _mi_prim_random_buf(void* buf, size_t buf_len); + +// Called on the first thread start, and should ensure `_mi_thread_done` is called on thread termination. +void _mi_prim_thread_init_auto_done(void); + +// Called on process exit and may take action to clean up resources associated with the thread auto done. +void _mi_prim_thread_done_auto_done(void); + +// Called when the default heap for a thread changes +void _mi_prim_thread_associate_default_heap(mi_heap_t* heap); + + +//------------------------------------------------------------------- +// Thread id: `_mi_prim_thread_id()` +// +// Getting the thread id should be performant as it is called in the +// fast path of `_mi_free` and we specialize for various platforms as +// inlined definitions. Regular code should call `init.c:_mi_thread_id()`. +// We only require _mi_prim_thread_id() to return a unique id +// for each thread (unequal to zero). +//------------------------------------------------------------------- + +// defined in `init.c`; do not use these directly +extern mi_decl_thread mi_heap_t* _mi_heap_default; // default heap to allocate from +extern bool _mi_process_is_initialized; // has mi_process_init been called? + +static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept; + +#ifdef MI_PRIM_THREAD_ID + +static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { + return MI_PRIM_THREAD_ID(); +} + +#elif defined(_WIN32) + +#define WIN32_LEAN_AND_MEAN +#include +static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { + // Windows: works on Intel and ARM in both 32- and 64-bit + return (uintptr_t)NtCurrentTeb(); +} + +// We use assembly for a fast thread id on the main platforms. The TLS layout depends on +// both the OS and libc implementation so we use specific tests for each main platform. +// If you test on another platform and it works please send a PR :-) +// see also https://akkadia.org/drepper/tls.pdf for more info on the TLS register. +#elif defined(__GNUC__) && ( \ + (defined(__GLIBC__) && (defined(__x86_64__) || defined(__i386__) || (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__))) \ + || (defined(__APPLE__) && (defined(__x86_64__) || defined(__aarch64__))) \ + || (defined(__BIONIC__) && (defined(__x86_64__) || defined(__i386__) || (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__))) \ + || (defined(__FreeBSD__) && (defined(__x86_64__) || defined(__i386__) || defined(__aarch64__))) \ + || (defined(__OpenBSD__) && (defined(__x86_64__) || defined(__i386__) || defined(__aarch64__))) \ + ) + +static inline void* mi_prim_tls_slot(size_t slot) mi_attr_noexcept { + void* res; + const size_t ofs = (slot*sizeof(void*)); + #if defined(__i386__) + __asm__("movl %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86 32-bit always uses GS + #elif defined(__APPLE__) && defined(__x86_64__) + __asm__("movq %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 macOSX uses GS + #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4) + __asm__("movl %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x32 ABI + #elif defined(__x86_64__) + __asm__("movq %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 Linux, BSD uses FS + #elif defined(__arm__) + void** tcb; MI_UNUSED(ofs); + __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb)); + res = tcb[slot]; + #elif defined(__aarch64__) + void** tcb; MI_UNUSED(ofs); + #if defined(__APPLE__) // M1, issue #343 + __asm__ volatile ("mrs %0, tpidrro_el0\nbic %0, %0, #7" : "=r" (tcb)); + #else + __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb)); + #endif + res = tcb[slot]; + #endif + return res; +} + +// setting a tls slot is only used on macOS for now +static inline void mi_prim_tls_slot_set(size_t slot, void* value) mi_attr_noexcept { + const size_t ofs = (slot*sizeof(void*)); + #if defined(__i386__) + __asm__("movl %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // 32-bit always uses GS + #elif defined(__APPLE__) && defined(__x86_64__) + __asm__("movq %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 macOS uses GS + #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4) + __asm__("movl %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x32 ABI + #elif defined(__x86_64__) + __asm__("movq %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 Linux, BSD uses FS + #elif defined(__arm__) + void** tcb; MI_UNUSED(ofs); + __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb)); + tcb[slot] = value; + #elif defined(__aarch64__) + void** tcb; MI_UNUSED(ofs); + #if defined(__APPLE__) // M1, issue #343 + __asm__ volatile ("mrs %0, tpidrro_el0\nbic %0, %0, #7" : "=r" (tcb)); + #else + __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb)); + #endif + tcb[slot] = value; + #endif +} + +static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { + #if defined(__BIONIC__) + // issue #384, #495: on the Bionic libc (Android), slot 1 is the thread id + // see: https://github.com/aosp-mirror/platform_bionic/blob/c44b1d0676ded732df4b3b21c5f798eacae93228/libc/platform/bionic/tls_defines.h#L86 + return (uintptr_t)mi_prim_tls_slot(1); + #else + // in all our other targets, slot 0 is the thread id + // glibc: https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/x86_64/nptl/tls.h + // apple: https://github.com/apple/darwin-xnu/blob/main/libsyscall/os/tsd.h#L36 + return (uintptr_t)mi_prim_tls_slot(0); + #endif +} + +#else + +// otherwise use portable C, taking the address of a thread local variable (this is still very fast on most platforms). +static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { + return (uintptr_t)&_mi_heap_default; +} + +#endif + + + +/* ---------------------------------------------------------------------------------------- +The thread local default heap: `_mi_prim_get_default_heap()` +This is inlined here as it is on the fast path for allocation functions. + +On most platforms (Windows, Linux, FreeBSD, NetBSD, etc), this just returns a +__thread local variable (`_mi_heap_default`). With the initial-exec TLS model this ensures +that the storage will always be available (allocated on the thread stacks). + +On some platforms though we cannot use that when overriding `malloc` since the underlying +TLS implementation (or the loader) will call itself `malloc` on a first access and recurse. +We try to circumvent this in an efficient way: +- macOSX : we use an unused TLS slot from the OS allocated slots (MI_TLS_SLOT). On OSX, the + loader itself calls `malloc` even before the modules are initialized. +- OpenBSD: we use an unused slot from the pthread block (MI_TLS_PTHREAD_SLOT_OFS). +- DragonFly: defaults are working but seem slow compared to freeBSD (see PR #323) +------------------------------------------------------------------------------------------- */ + +static inline mi_heap_t* mi_prim_get_default_heap(void); + +#if defined(MI_MALLOC_OVERRIDE) +#if defined(__APPLE__) // macOS + #define MI_TLS_SLOT 89 // seems unused? + // #define MI_TLS_RECURSE_GUARD 1 + // other possible unused ones are 9, 29, __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY4 (94), __PTK_FRAMEWORK_GC_KEY9 (112) and __PTK_FRAMEWORK_OLDGC_KEY9 (89) + // see +#elif defined(__OpenBSD__) + // use end bytes of a name; goes wrong if anyone uses names > 23 characters (ptrhread specifies 16) + // see + #define MI_TLS_PTHREAD_SLOT_OFS (6*sizeof(int) + 4*sizeof(void*) + 24) + // #elif defined(__DragonFly__) + // #warning "mimalloc is not working correctly on DragonFly yet." + // #define MI_TLS_PTHREAD_SLOT_OFS (4 + 1*sizeof(void*)) // offset `uniqueid` (also used by gdb?) +#elif defined(__ANDROID__) + // See issue #381 + #define MI_TLS_PTHREAD +#endif +#endif + + +#if defined(MI_TLS_SLOT) + +static inline mi_heap_t* mi_prim_get_default_heap(void) { + mi_heap_t* heap = (mi_heap_t*)mi_prim_tls_slot(MI_TLS_SLOT); + if mi_unlikely(heap == NULL) { + #ifdef __GNUC__ + __asm(""); // prevent conditional load of the address of _mi_heap_empty + #endif + heap = (mi_heap_t*)&_mi_heap_empty; + } + return heap; +} + +#elif defined(MI_TLS_PTHREAD_SLOT_OFS) + +static inline mi_heap_t** mi_prim_tls_pthread_heap_slot(void) { + pthread_t self = pthread_self(); + #if defined(__DragonFly__) + if (self==NULL) return NULL; + #endif + return (mi_heap_t**)((uint8_t*)self + MI_TLS_PTHREAD_SLOT_OFS); +} + +static inline mi_heap_t* mi_prim_get_default_heap(void) { + mi_heap_t** pheap = mi_prim_tls_pthread_heap_slot(); + if mi_unlikely(pheap == NULL) return _mi_heap_main_get(); + mi_heap_t* heap = *pheap; + if mi_unlikely(heap == NULL) return (mi_heap_t*)&_mi_heap_empty; + return heap; +} + +#elif defined(MI_TLS_PTHREAD) + +extern pthread_key_t _mi_heap_default_key; +static inline mi_heap_t* mi_prim_get_default_heap(void) { + mi_heap_t* heap = (mi_unlikely(_mi_heap_default_key == (pthread_key_t)(-1)) ? _mi_heap_main_get() : (mi_heap_t*)pthread_getspecific(_mi_heap_default_key)); + return (mi_unlikely(heap == NULL) ? (mi_heap_t*)&_mi_heap_empty : heap); +} + +#else // default using a thread local variable; used on most platforms. + +static inline mi_heap_t* mi_prim_get_default_heap(void) { + #if defined(MI_TLS_RECURSE_GUARD) + if (mi_unlikely(!_mi_process_is_initialized)) return _mi_heap_main_get(); + #endif + return _mi_heap_default; +} + +#endif // mi_prim_get_default_heap() + + + +#endif // MIMALLOC_PRIM_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/track.h b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/track.h new file mode 100644 index 00000000..fa1a048d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/track.h @@ -0,0 +1,147 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2023, Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ +#pragma once +#ifndef MIMALLOC_TRACK_H +#define MIMALLOC_TRACK_H + +/* ------------------------------------------------------------------------------------------------------ +Track memory ranges with macros for tools like Valgrind address sanitizer, or other memory checkers. +These can be defined for tracking allocation: + + #define mi_track_malloc_size(p,reqsize,size,zero) + #define mi_track_free_size(p,_size) + +The macros are set up such that the size passed to `mi_track_free_size` +always matches the size of `mi_track_malloc_size`. (currently, `size == mi_usable_size(p)`). +The `reqsize` is what the user requested, and `size >= reqsize`. +The `size` is either byte precise (and `size==reqsize`) if `MI_PADDING` is enabled, +or otherwise it is the usable block size which may be larger than the original request. +Use `_mi_block_size_of(void* p)` to get the full block size that was allocated (including padding etc). +The `zero` parameter is `true` if the allocated block is zero initialized. + +Optional: + + #define mi_track_align(p,alignedp,offset,size) + #define mi_track_resize(p,oldsize,newsize) + #define mi_track_init() + +The `mi_track_align` is called right after a `mi_track_malloc` for aligned pointers in a block. +The corresponding `mi_track_free` still uses the block start pointer and original size (corresponding to the `mi_track_malloc`). +The `mi_track_resize` is currently unused but could be called on reallocations within a block. +`mi_track_init` is called at program start. + +The following macros are for tools like asan and valgrind to track whether memory is +defined, undefined, or not accessible at all: + + #define mi_track_mem_defined(p,size) + #define mi_track_mem_undefined(p,size) + #define mi_track_mem_noaccess(p,size) + +-------------------------------------------------------------------------------------------------------*/ + +#if MI_TRACK_VALGRIND +// valgrind tool + +#define MI_TRACK_ENABLED 1 +#define MI_TRACK_HEAP_DESTROY 1 // track free of individual blocks on heap_destroy +#define MI_TRACK_TOOL "valgrind" + +#include +#include + +#define mi_track_malloc_size(p,reqsize,size,zero) VALGRIND_MALLOCLIKE_BLOCK(p,size,MI_PADDING_SIZE /*red zone*/,zero) +#define mi_track_free_size(p,_size) VALGRIND_FREELIKE_BLOCK(p,MI_PADDING_SIZE /*red zone*/) +#define mi_track_resize(p,oldsize,newsize) VALGRIND_RESIZEINPLACE_BLOCK(p,oldsize,newsize,MI_PADDING_SIZE /*red zone*/) +#define mi_track_mem_defined(p,size) VALGRIND_MAKE_MEM_DEFINED(p,size) +#define mi_track_mem_undefined(p,size) VALGRIND_MAKE_MEM_UNDEFINED(p,size) +#define mi_track_mem_noaccess(p,size) VALGRIND_MAKE_MEM_NOACCESS(p,size) + +#elif MI_TRACK_ASAN +// address sanitizer + +#define MI_TRACK_ENABLED 1 +#define MI_TRACK_HEAP_DESTROY 0 +#define MI_TRACK_TOOL "asan" + +#include + +#define mi_track_malloc_size(p,reqsize,size,zero) ASAN_UNPOISON_MEMORY_REGION(p,size) +#define mi_track_free_size(p,size) ASAN_POISON_MEMORY_REGION(p,size) +#define mi_track_mem_defined(p,size) ASAN_UNPOISON_MEMORY_REGION(p,size) +#define mi_track_mem_undefined(p,size) ASAN_UNPOISON_MEMORY_REGION(p,size) +#define mi_track_mem_noaccess(p,size) ASAN_POISON_MEMORY_REGION(p,size) + +#elif MI_TRACK_ETW +// windows event tracing + +#define MI_TRACK_ENABLED 1 +#define MI_TRACK_HEAP_DESTROY 1 +#define MI_TRACK_TOOL "ETW" + +#define WIN32_LEAN_AND_MEAN +#include +#include "../src/prim/windows/etw.h" + +#define mi_track_init() EventRegistermicrosoft_windows_mimalloc(); +#define mi_track_malloc_size(p,reqsize,size,zero) EventWriteETW_MI_ALLOC((UINT64)(p), size) +#define mi_track_free_size(p,size) EventWriteETW_MI_FREE((UINT64)(p), size) + +#else +// no tracking + +#define MI_TRACK_ENABLED 0 +#define MI_TRACK_HEAP_DESTROY 0 +#define MI_TRACK_TOOL "none" + +#define mi_track_malloc_size(p,reqsize,size,zero) +#define mi_track_free_size(p,_size) + +#endif + +// ------------------- +// Utility definitions + +#ifndef mi_track_resize +#define mi_track_resize(p,oldsize,newsize) mi_track_free_size(p,oldsize); mi_track_malloc(p,newsize,false) +#endif + +#ifndef mi_track_align +#define mi_track_align(p,alignedp,offset,size) mi_track_mem_noaccess(p,offset) +#endif + +#ifndef mi_track_init +#define mi_track_init() +#endif + +#ifndef mi_track_mem_defined +#define mi_track_mem_defined(p,size) +#endif + +#ifndef mi_track_mem_undefined +#define mi_track_mem_undefined(p,size) +#endif + +#ifndef mi_track_mem_noaccess +#define mi_track_mem_noaccess(p,size) +#endif + + +#if MI_PADDING +#define mi_track_malloc(p,reqsize,zero) \ + if ((p)!=NULL) { \ + mi_assert_internal(mi_usable_size(p)==(reqsize)); \ + mi_track_malloc_size(p,reqsize,reqsize,zero); \ + } +#else +#define mi_track_malloc(p,reqsize,zero) \ + if ((p)!=NULL) { \ + mi_assert_internal(mi_usable_size(p)>=(reqsize)); \ + mi_track_malloc_size(p,reqsize,mi_usable_size(p),zero); \ + } +#endif + +#endif diff --git a/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/types.h b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/types.h new file mode 100644 index 00000000..70c600e9 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/mimalloc/mimalloc/types.h @@ -0,0 +1,721 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2023, Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ +#pragma once +#ifndef MIMALLOC_TYPES_H +#define MIMALLOC_TYPES_H + +// -------------------------------------------------------------------------- +// This file contains the main type definitions for mimalloc: +// mi_heap_t : all data for a thread-local heap, contains +// lists of all managed heap pages. +// mi_segment_t : a larger chunk of memory (32GiB) from where pages +// are allocated. +// mi_page_t : a mimalloc page (usually 64KiB or 512KiB) from +// where objects are allocated. +// -------------------------------------------------------------------------- + + +#include // ptrdiff_t +#include // uintptr_t, uint16_t, etc +#include "atomic.h" // _Atomic + +#ifdef _MSC_VER +#pragma warning(disable:4214) // bitfield is not int +#endif + +// Minimal alignment necessary. On most platforms 16 bytes are needed +// due to SSE registers for example. This must be at least `sizeof(void*)` +#ifndef MI_MAX_ALIGN_SIZE +#define MI_MAX_ALIGN_SIZE 16 // sizeof(max_align_t) +#endif + +#define MI_CACHE_LINE 64 +#if defined(_MSC_VER) +#pragma warning(disable:4127) // suppress constant conditional warning (due to MI_SECURE paths) +#pragma warning(disable:26812) // unscoped enum warning +#define mi_decl_noinline __declspec(noinline) +#define mi_decl_thread __declspec(thread) +#define mi_decl_cache_align __declspec(align(MI_CACHE_LINE)) +#elif (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__clang__) // includes clang and icc +#define mi_decl_noinline __attribute__((noinline)) +#define mi_decl_thread __thread +#define mi_decl_cache_align __attribute__((aligned(MI_CACHE_LINE))) +#else +#define mi_decl_noinline +#define mi_decl_thread __thread // hope for the best :-) +#define mi_decl_cache_align +#endif + +// ------------------------------------------------------ +// Variants +// ------------------------------------------------------ + +// Define NDEBUG in the release version to disable assertions. +// #define NDEBUG + +// Define MI_TRACK_ to enable tracking support +// #define MI_TRACK_VALGRIND 1 +// #define MI_TRACK_ASAN 1 +// #define MI_TRACK_ETW 1 + +// Define MI_STAT as 1 to maintain statistics; set it to 2 to have detailed statistics (but costs some performance). +// #define MI_STAT 1 + +// Define MI_SECURE to enable security mitigations +// #define MI_SECURE 1 // guard page around metadata +// #define MI_SECURE 2 // guard page around each mimalloc page +// #define MI_SECURE 3 // encode free lists (detect corrupted free list (buffer overflow), and invalid pointer free) +// #define MI_SECURE 4 // checks for double free. (may be more expensive) + +#if !defined(MI_SECURE) +#define MI_SECURE 0 +#endif + +// Define MI_DEBUG for debug mode +// #define MI_DEBUG 1 // basic assertion checks and statistics, check double free, corrupted free list, and invalid pointer free. +// #define MI_DEBUG 2 // + internal assertion checks +// #define MI_DEBUG 3 // + extensive internal invariant checking (cmake -DMI_DEBUG_FULL=ON) +#if !defined(MI_DEBUG) +#if !defined(NDEBUG) || defined(_DEBUG) +#define MI_DEBUG 2 +#else +#define MI_DEBUG 0 +#endif +#endif + +// Reserve extra padding at the end of each block to be more resilient against heap block overflows. +// The padding can detect buffer overflow on free. +#if !defined(MI_PADDING) && (MI_SECURE>=3 || MI_DEBUG>=1 || (MI_TRACK_VALGRIND || MI_TRACK_ASAN || MI_TRACK_ETW)) +#define MI_PADDING 1 +#endif + +// Check padding bytes; allows byte-precise buffer overflow detection +#if !defined(MI_PADDING_CHECK) && MI_PADDING && (MI_SECURE>=3 || MI_DEBUG>=1) +#define MI_PADDING_CHECK 1 +#endif + + +// Encoded free lists allow detection of corrupted free lists +// and can detect buffer overflows, modify after free, and double `free`s. +#if (MI_SECURE>=3 || MI_DEBUG>=1) +#define MI_ENCODE_FREELIST 1 +#endif + + +// We used to abandon huge pages but to eagerly deallocate if freed from another thread, +// but that makes it not possible to visit them during a heap walk or include them in a +// `mi_heap_destroy`. We therefore instead reset/decommit the huge blocks if freed from +// another thread so most memory is available until it gets properly freed by the owning thread. +// #define MI_HUGE_PAGE_ABANDON 1 + + +// ------------------------------------------------------ +// Platform specific values +// ------------------------------------------------------ + +// ------------------------------------------------------ +// Size of a pointer. +// We assume that `sizeof(void*)==sizeof(intptr_t)` +// and it holds for all platforms we know of. +// +// However, the C standard only requires that: +// p == (void*)((intptr_t)p)) +// but we also need: +// i == (intptr_t)((void*)i) +// or otherwise one might define an intptr_t type that is larger than a pointer... +// ------------------------------------------------------ + +#if INTPTR_MAX > INT64_MAX +# define MI_INTPTR_SHIFT (4) // assume 128-bit (as on arm CHERI for example) +#elif INTPTR_MAX == INT64_MAX +# define MI_INTPTR_SHIFT (3) +#elif INTPTR_MAX == INT32_MAX +# define MI_INTPTR_SHIFT (2) +#else +#error platform pointers must be 32, 64, or 128 bits +#endif + +#if SIZE_MAX == UINT64_MAX +# define MI_SIZE_SHIFT (3) +typedef int64_t mi_ssize_t; +#elif SIZE_MAX == UINT32_MAX +# define MI_SIZE_SHIFT (2) +typedef int32_t mi_ssize_t; +#else +#error platform objects must be 32 or 64 bits +#endif + +#if (SIZE_MAX/2) > LONG_MAX +# define MI_ZU(x) x##ULL +# define MI_ZI(x) x##LL +#else +# define MI_ZU(x) x##UL +# define MI_ZI(x) x##L +#endif + +#define MI_INTPTR_SIZE (1< 4 +#define MI_SEGMENT_SHIFT ( 9 + MI_SEGMENT_SLICE_SHIFT) // 32MiB +#else +#define MI_SEGMENT_SHIFT ( 7 + MI_SEGMENT_SLICE_SHIFT) // 4MiB on 32-bit +#endif + +#define MI_SMALL_PAGE_SHIFT (MI_SEGMENT_SLICE_SHIFT) // 64KiB +#define MI_MEDIUM_PAGE_SHIFT ( 3 + MI_SMALL_PAGE_SHIFT) // 512KiB + + +// Derived constants +#define MI_SEGMENT_SIZE (MI_ZU(1)<= 655360) +#error "mimalloc internal: define more bins" +#endif + +// Maximum slice offset (15) +#define MI_MAX_SLICE_OFFSET ((MI_ALIGNMENT_MAX / MI_SEGMENT_SLICE_SIZE) - 1) + +// Used as a special value to encode block sizes in 32 bits. +#define MI_HUGE_BLOCK_SIZE ((uint32_t)(2*MI_GiB)) + +// blocks up to this size are always allocated aligned +#define MI_MAX_ALIGN_GUARANTEE (8*MI_MAX_ALIGN_SIZE) + +// Alignments over MI_ALIGNMENT_MAX are allocated in dedicated huge page segments +#define MI_ALIGNMENT_MAX (MI_SEGMENT_SIZE >> 1) + + +// ------------------------------------------------------ +// Mimalloc pages contain allocated blocks +// ------------------------------------------------------ + +// The free lists use encoded next fields +// (Only actually encodes when MI_ENCODED_FREELIST is defined.) +typedef uintptr_t mi_encoded_t; + +// thread id's +typedef size_t mi_threadid_t; + +// free lists contain blocks +typedef struct mi_block_s { + _Atomic(mi_encoded_t) next; +} mi_block_t; + + +// The delayed flags are used for efficient multi-threaded free-ing +typedef enum mi_delayed_e { + MI_USE_DELAYED_FREE = 0, // push on the owning heap thread delayed list + MI_DELAYED_FREEING = 1, // temporary: another thread is accessing the owning heap + MI_NO_DELAYED_FREE = 2, // optimize: push on page local thread free queue if another block is already in the heap thread delayed free list + MI_NEVER_DELAYED_FREE = 3 // sticky, only resets on page reclaim +} mi_delayed_t; + + +// The `in_full` and `has_aligned` page flags are put in a union to efficiently +// test if both are false (`full_aligned == 0`) in the `mi_free` routine. +#if !MI_TSAN +typedef union mi_page_flags_s { + uint8_t full_aligned; + struct { + uint8_t in_full : 1; + uint8_t has_aligned : 1; + } x; +} mi_page_flags_t; +#else +// under thread sanitizer, use a byte for each flag to suppress warning, issue #130 +typedef union mi_page_flags_s { + uint16_t full_aligned; + struct { + uint8_t in_full; + uint8_t has_aligned; + } x; +} mi_page_flags_t; +#endif + +// Thread free list. +// We use the bottom 2 bits of the pointer for mi_delayed_t flags +typedef uintptr_t mi_thread_free_t; + +// A page contains blocks of one specific size (`block_size`). +// Each page has three list of free blocks: +// `free` for blocks that can be allocated, +// `local_free` for freed blocks that are not yet available to `mi_malloc` +// `thread_free` for freed blocks by other threads +// The `local_free` and `thread_free` lists are migrated to the `free` list +// when it is exhausted. The separate `local_free` list is necessary to +// implement a monotonic heartbeat. The `thread_free` list is needed for +// avoiding atomic operations in the common case. +// +// +// `used - |thread_free|` == actual blocks that are in use (alive) +// `used - |thread_free| + |free| + |local_free| == capacity` +// +// We don't count `freed` (as |free|) but use `used` to reduce +// the number of memory accesses in the `mi_page_all_free` function(s). +// +// Notes: +// - Access is optimized for `mi_free` and `mi_page_alloc` (in `alloc.c`) +// - Using `uint16_t` does not seem to slow things down +// - The size is 8 words on 64-bit which helps the page index calculations +// (and 10 words on 32-bit, and encoded free lists add 2 words. Sizes 10 +// and 12 are still good for address calculation) +// - To limit the structure size, the `xblock_size` is 32-bits only; for +// blocks > MI_HUGE_BLOCK_SIZE the size is determined from the segment page size +// - `thread_free` uses the bottom bits as a delayed-free flags to optimize +// concurrent frees where only the first concurrent free adds to the owning +// heap `thread_delayed_free` list (see `alloc.c:mi_free_block_mt`). +// The invariant is that no-delayed-free is only set if there is +// at least one block that will be added, or as already been added, to +// the owning heap `thread_delayed_free` list. This guarantees that pages +// will be freed correctly even if only other threads free blocks. +typedef struct mi_page_s { + // "owned" by the segment + uint32_t slice_count; // slices in this page (0 if not a page) + uint32_t slice_offset; // distance from the actual page data slice (0 if a page) + uint8_t is_committed : 1; // `true` if the page virtual memory is committed + uint8_t is_zero_init : 1; // `true` if the page was initially zero initialized + uint8_t use_qsbr : 1; // delay page freeing using qsbr + uint8_t tag : 4; // tag from the owning heap + uint8_t debug_offset; // number of bytes to preserve when filling freed or uninitialized memory + + // layout like this to optimize access in `mi_malloc` and `mi_free` + uint16_t capacity; // number of blocks committed, must be the first field, see `segment.c:page_clear` + uint16_t reserved; // number of blocks reserved in memory + mi_page_flags_t flags; // `in_full` and `has_aligned` flags (8 bits) + uint8_t free_is_zero : 1; // `true` if the blocks in the free list are zero initialized + uint8_t retire_expire : 7; // expiration count for retired blocks + + mi_block_t* free; // list of available free blocks (`malloc` allocates from this list) + uint32_t used; // number of blocks in use (including blocks in `local_free` and `thread_free`) + uint32_t xblock_size; // size available in each block (always `>0`) + mi_block_t* local_free; // list of deferred free blocks by this thread (migrates to `free`) + + #if (MI_ENCODE_FREELIST || MI_PADDING) + uintptr_t keys[2]; // two random keys to encode the free lists (see `_mi_block_next`) or padding canary + #endif + + _Atomic(mi_thread_free_t) xthread_free; // list of deferred free blocks freed by other threads + _Atomic(uintptr_t) xheap; + + struct mi_page_s* next; // next page owned by this thread with the same `block_size` + struct mi_page_s* prev; // previous page owned by this thread with the same `block_size` + +#ifdef Py_GIL_DISABLED + struct llist_node qsbr_node; + uint64_t qsbr_goal; +#endif + + // 64-bit 9 words, 32-bit 12 words, (+2 for secure) + #if MI_INTPTR_SIZE==8 && !defined(Py_GIL_DISABLED) + uintptr_t padding[1]; + #endif +} mi_page_t; + + + +// ------------------------------------------------------ +// Mimalloc segments contain mimalloc pages +// ------------------------------------------------------ + +typedef enum mi_page_kind_e { + MI_PAGE_SMALL, // small blocks go into 64KiB pages inside a segment + MI_PAGE_MEDIUM, // medium blocks go into medium pages inside a segment + MI_PAGE_LARGE, // larger blocks go into a page of just one block + MI_PAGE_HUGE, // huge blocks (> 16 MiB) are put into a single page in a single segment. +} mi_page_kind_t; + +typedef enum mi_segment_kind_e { + MI_SEGMENT_NORMAL, // MI_SEGMENT_SIZE size with pages inside. + MI_SEGMENT_HUGE, // > MI_LARGE_SIZE_MAX segment with just one huge page inside. +} mi_segment_kind_t; + +// ------------------------------------------------------ +// A segment holds a commit mask where a bit is set if +// the corresponding MI_COMMIT_SIZE area is committed. +// The MI_COMMIT_SIZE must be a multiple of the slice +// size. If it is equal we have the most fine grained +// decommit (but setting it higher can be more efficient). +// The MI_MINIMAL_COMMIT_SIZE is the minimal amount that will +// be committed in one go which can be set higher than +// MI_COMMIT_SIZE for efficiency (while the decommit mask +// is still tracked in fine-grained MI_COMMIT_SIZE chunks) +// ------------------------------------------------------ + +#define MI_MINIMAL_COMMIT_SIZE (1*MI_SEGMENT_SLICE_SIZE) +#define MI_COMMIT_SIZE (MI_SEGMENT_SLICE_SIZE) // 64KiB +#define MI_COMMIT_MASK_BITS (MI_SEGMENT_SIZE / MI_COMMIT_SIZE) +#define MI_COMMIT_MASK_FIELD_BITS MI_SIZE_BITS +#define MI_COMMIT_MASK_FIELD_COUNT (MI_COMMIT_MASK_BITS / MI_COMMIT_MASK_FIELD_BITS) + +#if (MI_COMMIT_MASK_BITS != (MI_COMMIT_MASK_FIELD_COUNT * MI_COMMIT_MASK_FIELD_BITS)) +#error "the segment size must be exactly divisible by the (commit size * size_t bits)" +#endif + +typedef struct mi_commit_mask_s { + size_t mask[MI_COMMIT_MASK_FIELD_COUNT]; +} mi_commit_mask_t; + +typedef mi_page_t mi_slice_t; +typedef int64_t mi_msecs_t; + + +// Memory can reside in arena's, direct OS allocated, or statically allocated. The memid keeps track of this. +typedef enum mi_memkind_e { + MI_MEM_NONE, // not allocated + MI_MEM_EXTERNAL, // not owned by mimalloc but provided externally (via `mi_manage_os_memory` for example) + MI_MEM_STATIC, // allocated in a static area and should not be freed (for arena meta data for example) + MI_MEM_OS, // allocated from the OS + MI_MEM_OS_HUGE, // allocated as huge os pages + MI_MEM_OS_REMAP, // allocated in a remapable area (i.e. using `mremap`) + MI_MEM_ARENA // allocated from an arena (the usual case) +} mi_memkind_t; + +static inline bool mi_memkind_is_os(mi_memkind_t memkind) { + return (memkind >= MI_MEM_OS && memkind <= MI_MEM_OS_REMAP); +} + +typedef struct mi_memid_os_info { + void* base; // actual base address of the block (used for offset aligned allocations) + size_t alignment; // alignment at allocation +} mi_memid_os_info_t; + +typedef struct mi_memid_arena_info { + size_t block_index; // index in the arena + mi_arena_id_t id; // arena id (>= 1) + bool is_exclusive; // the arena can only be used for specific arena allocations +} mi_memid_arena_info_t; + +typedef struct mi_memid_s { + union { + mi_memid_os_info_t os; // only used for MI_MEM_OS + mi_memid_arena_info_t arena; // only used for MI_MEM_ARENA + } mem; + bool is_pinned; // `true` if we cannot decommit/reset/protect in this memory (e.g. when allocated using large OS pages) + bool initially_committed;// `true` if the memory was originally allocated as committed + bool initially_zero; // `true` if the memory was originally zero initialized + mi_memkind_t memkind; +} mi_memid_t; + + +// Segments are large allocated memory blocks (8mb on 64 bit) from +// the OS. Inside segments we allocated fixed size _pages_ that +// contain blocks. +typedef struct mi_segment_s { + // constant fields + mi_memid_t memid; // memory id for arena allocation + bool allow_decommit; + bool allow_purge; + size_t segment_size; + + // segment fields + mi_msecs_t purge_expire; + mi_commit_mask_t purge_mask; + mi_commit_mask_t commit_mask; + + _Atomic(struct mi_segment_s*) abandoned_next; + + // from here is zero initialized + struct mi_segment_s* next; // the list of freed segments in the cache (must be first field, see `segment.c:mi_segment_init`) + + size_t abandoned; // abandoned pages (i.e. the original owning thread stopped) (`abandoned <= used`) + size_t abandoned_visits; // count how often this segment is visited in the abandoned list (to force reclaim it it is too long) + size_t used; // count of pages in use + uintptr_t cookie; // verify addresses in debug mode: `mi_ptr_cookie(segment) == segment->cookie` + + size_t segment_slices; // for huge segments this may be different from `MI_SLICES_PER_SEGMENT` + size_t segment_info_slices; // initial slices we are using segment info and possible guard pages. + + // layout like this to optimize access in `mi_free` + mi_segment_kind_t kind; + size_t slice_entries; // entries in the `slices` array, at most `MI_SLICES_PER_SEGMENT` + _Atomic(mi_threadid_t) thread_id; // unique id of the thread owning this segment + + mi_slice_t slices[MI_SLICES_PER_SEGMENT+1]; // one more for huge blocks with large alignment +} mi_segment_t; + +typedef uintptr_t mi_tagged_segment_t; + +// Segments unowned by any thread are put in a shared pool +typedef struct mi_abandoned_pool_s { + // This is a list of visited abandoned pages that were full at the time. + // this list migrates to `abandoned` when that becomes NULL. The use of + // this list reduces contention and the rate at which segments are visited. + mi_decl_cache_align _Atomic(mi_segment_t*) abandoned_visited; // = NULL + + // The abandoned page list (tagged as it supports pop) + mi_decl_cache_align _Atomic(mi_tagged_segment_t) abandoned; // = NULL + + // Maintain these for debug purposes (these counts may be a bit off) + mi_decl_cache_align _Atomic(size_t) abandoned_count; + mi_decl_cache_align _Atomic(size_t) abandoned_visited_count; + + // We also maintain a count of current readers of the abandoned list + // in order to prevent resetting/decommitting segment memory if it might + // still be read. + mi_decl_cache_align _Atomic(size_t) abandoned_readers; // = 0 +} mi_abandoned_pool_t; + + +// ------------------------------------------------------ +// Heaps +// Provide first-class heaps to allocate from. +// A heap just owns a set of pages for allocation and +// can only be allocate/reallocate from the thread that created it. +// Freeing blocks can be done from any thread though. +// Per thread, the segments are shared among its heaps. +// Per thread, there is always a default heap that is +// used for allocation; it is initialized to statically +// point to an empty heap to avoid initialization checks +// in the fast path. +// ------------------------------------------------------ + +// Thread local data +typedef struct mi_tld_s mi_tld_t; + +// Pages of a certain block size are held in a queue. +typedef struct mi_page_queue_s { + mi_page_t* first; + mi_page_t* last; + size_t block_size; +} mi_page_queue_t; + +#define MI_BIN_FULL (MI_BIN_HUGE+1) + +// Random context +typedef struct mi_random_cxt_s { + uint32_t input[16]; + uint32_t output[16]; + int output_available; + bool weak; +} mi_random_ctx_t; + + +// In debug mode there is a padding structure at the end of the blocks to check for buffer overflows +#if (MI_PADDING) +typedef struct mi_padding_s { + uint32_t canary; // encoded block value to check validity of the padding (in case of overflow) + uint32_t delta; // padding bytes before the block. (mi_usable_size(p) - delta == exact allocated bytes) +} mi_padding_t; +#define MI_PADDING_SIZE (sizeof(mi_padding_t)) +#define MI_PADDING_WSIZE ((MI_PADDING_SIZE + MI_INTPTR_SIZE - 1) / MI_INTPTR_SIZE) +#else +#define MI_PADDING_SIZE 0 +#define MI_PADDING_WSIZE 0 +#endif + +#define MI_PAGES_DIRECT (MI_SMALL_WSIZE_MAX + MI_PADDING_WSIZE + 1) + + +// A heap owns a set of pages. +struct mi_heap_s { + mi_tld_t* tld; + mi_page_t* pages_free_direct[MI_PAGES_DIRECT]; // optimize: array where every entry points a page with possibly free blocks in the corresponding queue for that size. + mi_page_queue_t pages[MI_BIN_FULL + 1]; // queue of pages for each size class (or "bin") + _Atomic(mi_block_t*) thread_delayed_free; + mi_threadid_t thread_id; // thread this heap belongs too + mi_arena_id_t arena_id; // arena id if the heap belongs to a specific arena (or 0) + uintptr_t cookie; // random cookie to verify pointers (see `_mi_ptr_cookie`) + uintptr_t keys[2]; // two random keys used to encode the `thread_delayed_free` list + mi_random_ctx_t random; // random number context used for secure allocation + size_t page_count; // total number of pages in the `pages` queues. + size_t page_retired_min; // smallest retired index (retired pages are fully free, but still in the page queues) + size_t page_retired_max; // largest retired index into the `pages` array. + mi_heap_t* next; // list of heaps per thread + bool no_reclaim; // `true` if this heap should not reclaim abandoned pages + uint8_t tag; // custom identifier for this heap + uint8_t debug_offset; // number of bytes to preserve when filling freed or uninitialized memory + bool page_use_qsbr; // should freeing pages be delayed using QSBR +}; + + + +// ------------------------------------------------------ +// Debug +// ------------------------------------------------------ + +#if !defined(MI_DEBUG_UNINIT) +#define MI_DEBUG_UNINIT (0xD0) +#endif +#if !defined(MI_DEBUG_FREED) +#define MI_DEBUG_FREED (0xDF) +#endif +#if !defined(MI_DEBUG_PADDING) +#define MI_DEBUG_PADDING (0xDE) +#endif + +#if (MI_DEBUG) +// use our own assertion to print without memory allocation +void _mi_assert_fail(const char* assertion, const char* fname, unsigned int line, const char* func ); +#define mi_assert(expr) ((expr) ? (void)0 : _mi_assert_fail(#expr,__FILE__,__LINE__,__func__)) +#else +#define mi_assert(x) +#endif + +#if (MI_DEBUG>1) +#define mi_assert_internal mi_assert +#else +#define mi_assert_internal(x) +#endif + +#if (MI_DEBUG>2) +#define mi_assert_expensive mi_assert +#else +#define mi_assert_expensive(x) +#endif + +// ------------------------------------------------------ +// Statistics +// ------------------------------------------------------ + +#ifndef MI_STAT +#if (MI_DEBUG>0) +#define MI_STAT 2 +#else +#define MI_STAT 0 +#endif +#endif + +typedef struct mi_stat_count_s { + int64_t allocated; + int64_t freed; + int64_t peak; + int64_t current; +} mi_stat_count_t; + +typedef struct mi_stat_counter_s { + int64_t total; + int64_t count; +} mi_stat_counter_t; + +typedef struct mi_stats_s { + mi_stat_count_t segments; + mi_stat_count_t pages; + mi_stat_count_t reserved; + mi_stat_count_t committed; + mi_stat_count_t reset; + mi_stat_count_t purged; + mi_stat_count_t page_committed; + mi_stat_count_t segments_abandoned; + mi_stat_count_t pages_abandoned; + mi_stat_count_t threads; + mi_stat_count_t normal; + mi_stat_count_t huge; + mi_stat_count_t large; + mi_stat_count_t malloc; + mi_stat_count_t segments_cache; + mi_stat_counter_t pages_extended; + mi_stat_counter_t mmap_calls; + mi_stat_counter_t commit_calls; + mi_stat_counter_t reset_calls; + mi_stat_counter_t purge_calls; + mi_stat_counter_t page_no_retire; + mi_stat_counter_t searches; + mi_stat_counter_t normal_count; + mi_stat_counter_t huge_count; + mi_stat_counter_t large_count; +#if MI_STAT>1 + mi_stat_count_t normal_bins[MI_BIN_HUGE+1]; +#endif +} mi_stats_t; + + +void _mi_stat_increase(mi_stat_count_t* stat, size_t amount); +void _mi_stat_decrease(mi_stat_count_t* stat, size_t amount); +void _mi_stat_counter_increase(mi_stat_counter_t* stat, size_t amount); + +#if (MI_STAT) +#define mi_stat_increase(stat,amount) _mi_stat_increase( &(stat), amount) +#define mi_stat_decrease(stat,amount) _mi_stat_decrease( &(stat), amount) +#define mi_stat_counter_increase(stat,amount) _mi_stat_counter_increase( &(stat), amount) +#else +#define mi_stat_increase(stat,amount) (void)0 +#define mi_stat_decrease(stat,amount) (void)0 +#define mi_stat_counter_increase(stat,amount) (void)0 +#endif + +#define mi_heap_stat_counter_increase(heap,stat,amount) mi_stat_counter_increase( (heap)->tld->stats.stat, amount) +#define mi_heap_stat_increase(heap,stat,amount) mi_stat_increase( (heap)->tld->stats.stat, amount) +#define mi_heap_stat_decrease(heap,stat,amount) mi_stat_decrease( (heap)->tld->stats.stat, amount) + +// ------------------------------------------------------ +// Thread Local data +// ------------------------------------------------------ + +// A "span" is an available range of slices. The span queues keep +// track of slice spans of at most the given `slice_count` (but more than the previous size class). +typedef struct mi_span_queue_s { + mi_slice_t* first; + mi_slice_t* last; + size_t slice_count; +} mi_span_queue_t; + +#define MI_SEGMENT_BIN_MAX (35) // 35 == mi_segment_bin(MI_SLICES_PER_SEGMENT) + +// OS thread local data +typedef struct mi_os_tld_s { + size_t region_idx; // start point for next allocation + mi_stats_t* stats; // points to tld stats +} mi_os_tld_t; + + +// Segments thread local data +typedef struct mi_segments_tld_s { + mi_span_queue_t spans[MI_SEGMENT_BIN_MAX+1]; // free slice spans inside segments + size_t count; // current number of segments; + size_t peak_count; // peak number of segments + size_t current_size; // current size of all segments + size_t peak_size; // peak size of all segments + mi_stats_t* stats; // points to tld stats + mi_os_tld_t* os; // points to os stats + mi_abandoned_pool_t* abandoned; // pool of abandoned segments +} mi_segments_tld_t; + +// Thread local data +struct mi_tld_s { + unsigned long long heartbeat; // monotonic heartbeat count + bool recurse; // true if deferred was called; used to prevent infinite recursion. + mi_heap_t* heap_backing; // backing heap of this thread (cannot be deleted) + mi_heap_t* heaps; // list of heaps in this thread (so we can abandon all when the thread terminates) + mi_segments_tld_t segments; // segment tld + mi_os_tld_t os; // os tld + mi_stats_t stats; // statistics +}; + +#endif diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_abstract.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_abstract.h new file mode 100644 index 00000000..3cc0afac --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_abstract.h @@ -0,0 +1,61 @@ +#ifndef Py_INTERNAL_ABSTRACT_H +#define Py_INTERNAL_ABSTRACT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Fast inlined version of PyIndex_Check() +static inline int +_PyIndex_Check(PyObject *obj) +{ + PyNumberMethods *tp_as_number = Py_TYPE(obj)->tp_as_number; + return (tp_as_number != NULL && tp_as_number->nb_index != NULL); +} + +PyObject *_PyNumber_PowerNoMod(PyObject *lhs, PyObject *rhs); +PyObject *_PyNumber_InPlacePowerNoMod(PyObject *lhs, PyObject *rhs); + +extern int _PyObject_HasLen(PyObject *o); + +/* === Sequence protocol ================================================ */ + +#define PY_ITERSEARCH_COUNT 1 +#define PY_ITERSEARCH_INDEX 2 +#define PY_ITERSEARCH_CONTAINS 3 + +/* Iterate over seq. + + Result depends on the operation: + + PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if + error. + PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of + obj in seq; set ValueError and return -1 if none found; + also return -1 on error. + PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on + error. */ +extern Py_ssize_t _PySequence_IterSearch(PyObject *seq, + PyObject *obj, int operation); + +/* === Mapping protocol ================================================= */ + +extern int _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); + +extern int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); + +// Convert Python int to Py_ssize_t. Do nothing if the argument is None. +// Export for '_bisect' shared extension. +PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *); + +// Same as PyNumber_Index() but can return an instance of a subclass of int. +// Export for 'math' shared extension. +PyAPI_FUNC(PyObject*) _PyNumber_Index(PyObject *o); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_ABSTRACT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_asdl.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_asdl.h new file mode 100644 index 00000000..afeada88 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_asdl.h @@ -0,0 +1,112 @@ +#ifndef Py_INTERNAL_ASDL_H +#define Py_INTERNAL_ASDL_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_pyarena.h" // _PyArena_Malloc() + +typedef PyObject * identifier; +typedef PyObject * string; +typedef PyObject * object; +typedef PyObject * constant; + +/* It would be nice if the code generated by asdl_c.py was completely + independent of Python, but it is a goal the requires too much work + at this stage. So, for example, I'll represent identifiers as + interned Python strings. +*/ + +#define _ASDL_SEQ_HEAD \ + Py_ssize_t size; \ + void **elements; + +typedef struct { + _ASDL_SEQ_HEAD +} asdl_seq; + +typedef struct { + _ASDL_SEQ_HEAD + void *typed_elements[1]; +} asdl_generic_seq; + +typedef struct { + _ASDL_SEQ_HEAD + PyObject *typed_elements[1]; +} asdl_identifier_seq; + +typedef struct { + _ASDL_SEQ_HEAD + int typed_elements[1]; +} asdl_int_seq; + +asdl_generic_seq *_Py_asdl_generic_seq_new(Py_ssize_t size, PyArena *arena); +asdl_identifier_seq *_Py_asdl_identifier_seq_new(Py_ssize_t size, PyArena *arena); +asdl_int_seq *_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena); + + +#define GENERATE_ASDL_SEQ_CONSTRUCTOR(NAME, TYPE) \ +asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \ +{ \ + asdl_ ## NAME ## _seq *seq = NULL; \ + size_t n; \ + /* check size is sane */ \ + if (size < 0 || \ + (size && (((size_t)size - 1) > (SIZE_MAX / sizeof(void *))))) { \ + PyErr_NoMemory(); \ + return NULL; \ + } \ + n = (size ? (sizeof(TYPE *) * (size - 1)) : 0); \ + /* check if size can be added safely */ \ + if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \ + PyErr_NoMemory(); \ + return NULL; \ + } \ + n += sizeof(asdl_ ## NAME ## _seq); \ + seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \ + if (!seq) { \ + PyErr_NoMemory(); \ + return NULL; \ + } \ + memset(seq, 0, n); \ + seq->size = size; \ + seq->elements = (void**)seq->typed_elements; \ + return seq; \ +} + +#define asdl_seq_GET_UNTYPED(S, I) _Py_RVALUE((S)->elements[(I)]) +#define asdl_seq_GET(S, I) _Py_RVALUE((S)->typed_elements[(I)]) +#define asdl_seq_LEN(S) _Py_RVALUE(((S) == NULL ? 0 : (S)->size)) + +#ifdef Py_DEBUG +# define asdl_seq_SET(S, I, V) \ + do { \ + Py_ssize_t _asdl_i = (I); \ + assert((S) != NULL); \ + assert(0 <= _asdl_i && _asdl_i < (S)->size); \ + (S)->typed_elements[_asdl_i] = (V); \ + } while (0) +#else +# define asdl_seq_SET(S, I, V) _Py_RVALUE((S)->typed_elements[(I)] = (V)) +#endif + +#ifdef Py_DEBUG +# define asdl_seq_SET_UNTYPED(S, I, V) \ + do { \ + Py_ssize_t _asdl_i = (I); \ + assert((S) != NULL); \ + assert(0 <= _asdl_i && _asdl_i < (S)->size); \ + (S)->elements[_asdl_i] = (V); \ + } while (0) +#else +# define asdl_seq_SET_UNTYPED(S, I, V) _Py_RVALUE((S)->elements[(I)] = (V)) +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_ASDL_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_ast.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_ast.h new file mode 100644 index 00000000..f5bf1205 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_ast.h @@ -0,0 +1,926 @@ +// File automatically generated by Parser/asdl_c.py. + +#ifndef Py_INTERNAL_AST_H +#define Py_INTERNAL_AST_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_asdl.h" // _ASDL_SEQ_HEAD + +typedef struct _mod *mod_ty; + +typedef struct _stmt *stmt_ty; + +typedef struct _expr *expr_ty; + +typedef enum _expr_context { Load=1, Store=2, Del=3 } expr_context_ty; + +typedef enum _boolop { And=1, Or=2 } boolop_ty; + +typedef enum _operator { Add=1, Sub=2, Mult=3, MatMult=4, Div=5, Mod=6, Pow=7, + LShift=8, RShift=9, BitOr=10, BitXor=11, BitAnd=12, + FloorDiv=13 } operator_ty; + +typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty; + +typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8, + In=9, NotIn=10 } cmpop_ty; + +typedef struct _comprehension *comprehension_ty; + +typedef struct _excepthandler *excepthandler_ty; + +typedef struct _arguments *arguments_ty; + +typedef struct _arg *arg_ty; + +typedef struct _keyword *keyword_ty; + +typedef struct _alias *alias_ty; + +typedef struct _withitem *withitem_ty; + +typedef struct _match_case *match_case_ty; + +typedef struct _pattern *pattern_ty; + +typedef struct _type_ignore *type_ignore_ty; + +typedef struct _type_param *type_param_ty; + + +typedef struct { + _ASDL_SEQ_HEAD + mod_ty typed_elements[1]; +} asdl_mod_seq; + +asdl_mod_seq *_Py_asdl_mod_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + stmt_ty typed_elements[1]; +} asdl_stmt_seq; + +asdl_stmt_seq *_Py_asdl_stmt_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + expr_ty typed_elements[1]; +} asdl_expr_seq; + +asdl_expr_seq *_Py_asdl_expr_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + comprehension_ty typed_elements[1]; +} asdl_comprehension_seq; + +asdl_comprehension_seq *_Py_asdl_comprehension_seq_new(Py_ssize_t size, PyArena + *arena); + +typedef struct { + _ASDL_SEQ_HEAD + excepthandler_ty typed_elements[1]; +} asdl_excepthandler_seq; + +asdl_excepthandler_seq *_Py_asdl_excepthandler_seq_new(Py_ssize_t size, PyArena + *arena); + +typedef struct { + _ASDL_SEQ_HEAD + arguments_ty typed_elements[1]; +} asdl_arguments_seq; + +asdl_arguments_seq *_Py_asdl_arguments_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + arg_ty typed_elements[1]; +} asdl_arg_seq; + +asdl_arg_seq *_Py_asdl_arg_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + keyword_ty typed_elements[1]; +} asdl_keyword_seq; + +asdl_keyword_seq *_Py_asdl_keyword_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + alias_ty typed_elements[1]; +} asdl_alias_seq; + +asdl_alias_seq *_Py_asdl_alias_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + withitem_ty typed_elements[1]; +} asdl_withitem_seq; + +asdl_withitem_seq *_Py_asdl_withitem_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + match_case_ty typed_elements[1]; +} asdl_match_case_seq; + +asdl_match_case_seq *_Py_asdl_match_case_seq_new(Py_ssize_t size, PyArena + *arena); + +typedef struct { + _ASDL_SEQ_HEAD + pattern_ty typed_elements[1]; +} asdl_pattern_seq; + +asdl_pattern_seq *_Py_asdl_pattern_seq_new(Py_ssize_t size, PyArena *arena); + +typedef struct { + _ASDL_SEQ_HEAD + type_ignore_ty typed_elements[1]; +} asdl_type_ignore_seq; + +asdl_type_ignore_seq *_Py_asdl_type_ignore_seq_new(Py_ssize_t size, PyArena + *arena); + +typedef struct { + _ASDL_SEQ_HEAD + type_param_ty typed_elements[1]; +} asdl_type_param_seq; + +asdl_type_param_seq *_Py_asdl_type_param_seq_new(Py_ssize_t size, PyArena + *arena); + + +enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3, + FunctionType_kind=4}; +struct _mod { + enum _mod_kind kind; + union { + struct { + asdl_stmt_seq *body; + asdl_type_ignore_seq *type_ignores; + } Module; + + struct { + asdl_stmt_seq *body; + } Interactive; + + struct { + expr_ty body; + } Expression; + + struct { + asdl_expr_seq *argtypes; + expr_ty returns; + } FunctionType; + + } v; +}; + +enum _stmt_kind {FunctionDef_kind=1, AsyncFunctionDef_kind=2, ClassDef_kind=3, + Return_kind=4, Delete_kind=5, Assign_kind=6, + TypeAlias_kind=7, AugAssign_kind=8, AnnAssign_kind=9, + For_kind=10, AsyncFor_kind=11, While_kind=12, If_kind=13, + With_kind=14, AsyncWith_kind=15, Match_kind=16, + Raise_kind=17, Try_kind=18, TryStar_kind=19, Assert_kind=20, + Import_kind=21, ImportFrom_kind=22, Global_kind=23, + Nonlocal_kind=24, Expr_kind=25, Pass_kind=26, Break_kind=27, + Continue_kind=28}; +struct _stmt { + enum _stmt_kind kind; + union { + struct { + identifier name; + arguments_ty args; + asdl_stmt_seq *body; + asdl_expr_seq *decorator_list; + expr_ty returns; + string type_comment; + asdl_type_param_seq *type_params; + } FunctionDef; + + struct { + identifier name; + arguments_ty args; + asdl_stmt_seq *body; + asdl_expr_seq *decorator_list; + expr_ty returns; + string type_comment; + asdl_type_param_seq *type_params; + } AsyncFunctionDef; + + struct { + identifier name; + asdl_expr_seq *bases; + asdl_keyword_seq *keywords; + asdl_stmt_seq *body; + asdl_expr_seq *decorator_list; + asdl_type_param_seq *type_params; + } ClassDef; + + struct { + expr_ty value; + } Return; + + struct { + asdl_expr_seq *targets; + } Delete; + + struct { + asdl_expr_seq *targets; + expr_ty value; + string type_comment; + } Assign; + + struct { + expr_ty name; + asdl_type_param_seq *type_params; + expr_ty value; + } TypeAlias; + + struct { + expr_ty target; + operator_ty op; + expr_ty value; + } AugAssign; + + struct { + expr_ty target; + expr_ty annotation; + expr_ty value; + int simple; + } AnnAssign; + + struct { + expr_ty target; + expr_ty iter; + asdl_stmt_seq *body; + asdl_stmt_seq *orelse; + string type_comment; + } For; + + struct { + expr_ty target; + expr_ty iter; + asdl_stmt_seq *body; + asdl_stmt_seq *orelse; + string type_comment; + } AsyncFor; + + struct { + expr_ty test; + asdl_stmt_seq *body; + asdl_stmt_seq *orelse; + } While; + + struct { + expr_ty test; + asdl_stmt_seq *body; + asdl_stmt_seq *orelse; + } If; + + struct { + asdl_withitem_seq *items; + asdl_stmt_seq *body; + string type_comment; + } With; + + struct { + asdl_withitem_seq *items; + asdl_stmt_seq *body; + string type_comment; + } AsyncWith; + + struct { + expr_ty subject; + asdl_match_case_seq *cases; + } Match; + + struct { + expr_ty exc; + expr_ty cause; + } Raise; + + struct { + asdl_stmt_seq *body; + asdl_excepthandler_seq *handlers; + asdl_stmt_seq *orelse; + asdl_stmt_seq *finalbody; + } Try; + + struct { + asdl_stmt_seq *body; + asdl_excepthandler_seq *handlers; + asdl_stmt_seq *orelse; + asdl_stmt_seq *finalbody; + } TryStar; + + struct { + expr_ty test; + expr_ty msg; + } Assert; + + struct { + asdl_alias_seq *names; + } Import; + + struct { + identifier module; + asdl_alias_seq *names; + int level; + } ImportFrom; + + struct { + asdl_identifier_seq *names; + } Global; + + struct { + asdl_identifier_seq *names; + } Nonlocal; + + struct { + expr_ty value; + } Expr; + + } v; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + +enum _expr_kind {BoolOp_kind=1, NamedExpr_kind=2, BinOp_kind=3, UnaryOp_kind=4, + Lambda_kind=5, IfExp_kind=6, Dict_kind=7, Set_kind=8, + ListComp_kind=9, SetComp_kind=10, DictComp_kind=11, + GeneratorExp_kind=12, Await_kind=13, Yield_kind=14, + YieldFrom_kind=15, Compare_kind=16, Call_kind=17, + FormattedValue_kind=18, JoinedStr_kind=19, Constant_kind=20, + Attribute_kind=21, Subscript_kind=22, Starred_kind=23, + Name_kind=24, List_kind=25, Tuple_kind=26, Slice_kind=27}; +struct _expr { + enum _expr_kind kind; + union { + struct { + boolop_ty op; + asdl_expr_seq *values; + } BoolOp; + + struct { + expr_ty target; + expr_ty value; + } NamedExpr; + + struct { + expr_ty left; + operator_ty op; + expr_ty right; + } BinOp; + + struct { + unaryop_ty op; + expr_ty operand; + } UnaryOp; + + struct { + arguments_ty args; + expr_ty body; + } Lambda; + + struct { + expr_ty test; + expr_ty body; + expr_ty orelse; + } IfExp; + + struct { + asdl_expr_seq *keys; + asdl_expr_seq *values; + } Dict; + + struct { + asdl_expr_seq *elts; + } Set; + + struct { + expr_ty elt; + asdl_comprehension_seq *generators; + } ListComp; + + struct { + expr_ty elt; + asdl_comprehension_seq *generators; + } SetComp; + + struct { + expr_ty key; + expr_ty value; + asdl_comprehension_seq *generators; + } DictComp; + + struct { + expr_ty elt; + asdl_comprehension_seq *generators; + } GeneratorExp; + + struct { + expr_ty value; + } Await; + + struct { + expr_ty value; + } Yield; + + struct { + expr_ty value; + } YieldFrom; + + struct { + expr_ty left; + asdl_int_seq *ops; + asdl_expr_seq *comparators; + } Compare; + + struct { + expr_ty func; + asdl_expr_seq *args; + asdl_keyword_seq *keywords; + } Call; + + struct { + expr_ty value; + int conversion; + expr_ty format_spec; + } FormattedValue; + + struct { + asdl_expr_seq *values; + } JoinedStr; + + struct { + constant value; + string kind; + } Constant; + + struct { + expr_ty value; + identifier attr; + expr_context_ty ctx; + } Attribute; + + struct { + expr_ty value; + expr_ty slice; + expr_context_ty ctx; + } Subscript; + + struct { + expr_ty value; + expr_context_ty ctx; + } Starred; + + struct { + identifier id; + expr_context_ty ctx; + } Name; + + struct { + asdl_expr_seq *elts; + expr_context_ty ctx; + } List; + + struct { + asdl_expr_seq *elts; + expr_context_ty ctx; + } Tuple; + + struct { + expr_ty lower; + expr_ty upper; + expr_ty step; + } Slice; + + } v; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + +struct _comprehension { + expr_ty target; + expr_ty iter; + asdl_expr_seq *ifs; + int is_async; +}; + +enum _excepthandler_kind {ExceptHandler_kind=1}; +struct _excepthandler { + enum _excepthandler_kind kind; + union { + struct { + expr_ty type; + identifier name; + asdl_stmt_seq *body; + } ExceptHandler; + + } v; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + +struct _arguments { + asdl_arg_seq *posonlyargs; + asdl_arg_seq *args; + arg_ty vararg; + asdl_arg_seq *kwonlyargs; + asdl_expr_seq *kw_defaults; + arg_ty kwarg; + asdl_expr_seq *defaults; +}; + +struct _arg { + identifier arg; + expr_ty annotation; + string type_comment; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + +struct _keyword { + identifier arg; + expr_ty value; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + +struct _alias { + identifier name; + identifier asname; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + +struct _withitem { + expr_ty context_expr; + expr_ty optional_vars; +}; + +struct _match_case { + pattern_ty pattern; + expr_ty guard; + asdl_stmt_seq *body; +}; + +enum _pattern_kind {MatchValue_kind=1, MatchSingleton_kind=2, + MatchSequence_kind=3, MatchMapping_kind=4, + MatchClass_kind=5, MatchStar_kind=6, MatchAs_kind=7, + MatchOr_kind=8}; +struct _pattern { + enum _pattern_kind kind; + union { + struct { + expr_ty value; + } MatchValue; + + struct { + constant value; + } MatchSingleton; + + struct { + asdl_pattern_seq *patterns; + } MatchSequence; + + struct { + asdl_expr_seq *keys; + asdl_pattern_seq *patterns; + identifier rest; + } MatchMapping; + + struct { + expr_ty cls; + asdl_pattern_seq *patterns; + asdl_identifier_seq *kwd_attrs; + asdl_pattern_seq *kwd_patterns; + } MatchClass; + + struct { + identifier name; + } MatchStar; + + struct { + pattern_ty pattern; + identifier name; + } MatchAs; + + struct { + asdl_pattern_seq *patterns; + } MatchOr; + + } v; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + +enum _type_ignore_kind {TypeIgnore_kind=1}; +struct _type_ignore { + enum _type_ignore_kind kind; + union { + struct { + int lineno; + string tag; + } TypeIgnore; + + } v; +}; + +enum _type_param_kind {TypeVar_kind=1, ParamSpec_kind=2, TypeVarTuple_kind=3}; +struct _type_param { + enum _type_param_kind kind; + union { + struct { + identifier name; + expr_ty bound; + expr_ty default_value; + } TypeVar; + + struct { + identifier name; + expr_ty default_value; + } ParamSpec; + + struct { + identifier name; + expr_ty default_value; + } TypeVarTuple; + + } v; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + + +// Note: these macros affect function definitions, not only call sites. +mod_ty _PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores, + PyArena *arena); +mod_ty _PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena); +mod_ty _PyAST_Expression(expr_ty body, PyArena *arena); +mod_ty _PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena + *arena); +stmt_ty _PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * + body, asdl_expr_seq * decorator_list, expr_ty + returns, string type_comment, asdl_type_param_seq * + type_params, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_AsyncFunctionDef(identifier name, arguments_ty args, + asdl_stmt_seq * body, asdl_expr_seq * + decorator_list, expr_ty returns, string + type_comment, asdl_type_param_seq * + type_params, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_ClassDef(identifier name, asdl_expr_seq * bases, + asdl_keyword_seq * keywords, asdl_stmt_seq * body, + asdl_expr_seq * decorator_list, asdl_type_param_seq * + type_params, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_Return(expr_ty value, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string + type_comment, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena); +stmt_ty _PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, + expr_ty value, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int + lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +stmt_ty _PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int + simple, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena); +stmt_ty _PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, + asdl_stmt_seq * orelse, string type_comment, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +stmt_ty _PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body, + asdl_stmt_seq * orelse, string type_comment, int + lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +stmt_ty _PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * + orelse, int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +stmt_ty _PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, + int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +stmt_ty _PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string + type_comment, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena); +stmt_ty _PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, + string type_comment, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, + int col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +stmt_ty _PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers, + asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int + lineno, int col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +stmt_ty _PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers, + asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int + lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +stmt_ty _PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, + int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +stmt_ty _PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +stmt_ty _PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena); +stmt_ty _PyAST_Pass(int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +stmt_ty _PyAST_Break(int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +stmt_ty _PyAST_Continue(int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +expr_ty _PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int + col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +expr_ty _PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, + int col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +expr_ty _PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, + int col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +expr_ty _PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, + int col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +expr_ty _PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int + lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +expr_ty _PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int + lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +expr_ty _PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq * + generators, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena); +expr_ty _PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, + int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +expr_ty _PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena); +expr_ty _PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena); +expr_ty _PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +expr_ty _PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * + comparators, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena); +expr_ty _PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * + keywords, int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +expr_ty _PyAST_FormattedValue(expr_ty value, int conversion, expr_ty + format_spec, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +expr_ty _PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena *arena); +expr_ty _PyAST_Constant(constant value, string kind, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, + int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +expr_ty _PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int + lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +expr_ty _PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +expr_ty _PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, + int col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +comprehension_ty _PyAST_comprehension(expr_ty target, expr_ty iter, + asdl_expr_seq * ifs, int is_async, + PyArena *arena); +excepthandler_ty _PyAST_ExceptHandler(expr_ty type, identifier name, + asdl_stmt_seq * body, int lineno, int + col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +arguments_ty _PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, + arg_ty vararg, asdl_arg_seq * kwonlyargs, + asdl_expr_seq * kw_defaults, arg_ty kwarg, + asdl_expr_seq * defaults, PyArena *arena); +arg_ty _PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int + lineno, int col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +keyword_ty _PyAST_keyword(identifier arg, expr_ty value, int lineno, int + col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +alias_ty _PyAST_alias(identifier name, identifier asname, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); +withitem_ty _PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, + PyArena *arena); +match_case_ty _PyAST_match_case(pattern_ty pattern, expr_ty guard, + asdl_stmt_seq * body, PyArena *arena); +pattern_ty _PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +pattern_ty _PyAST_MatchSingleton(constant value, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena + *arena); +pattern_ty _PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int + col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +pattern_ty _PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * + patterns, identifier rest, int lineno, int + col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +pattern_ty _PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, + asdl_identifier_seq * kwd_attrs, asdl_pattern_seq + * kwd_patterns, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +pattern_ty _PyAST_MatchStar(identifier name, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +pattern_ty _PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int + col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +pattern_ty _PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int + col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +type_ignore_ty _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena); +type_param_ty _PyAST_TypeVar(identifier name, expr_ty bound, expr_ty + default_value, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +type_param_ty _PyAST_ParamSpec(identifier name, expr_ty default_value, int + lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); +type_param_ty _PyAST_TypeVarTuple(identifier name, expr_ty default_value, int + lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); + + +PyObject* PyAST_mod2obj(mod_ty t); +mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode); +int PyAST_Check(PyObject* obj); + +extern int _PyAST_Validate(mod_ty); + +/* _PyAST_ExprAsUnicode is defined in ast_unparse.c */ +extern PyObject* _PyAST_ExprAsUnicode(expr_ty); + +/* Return the borrowed reference to the first literal string in the + sequence of statements or NULL if it doesn't start from a literal string. + Doesn't set exception. */ +extern PyObject* _PyAST_GetDocString(asdl_stmt_seq *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_AST_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_ast_state.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_ast_state.h new file mode 100644 index 00000000..09ae9546 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_ast_state.h @@ -0,0 +1,268 @@ +// File automatically generated by Parser/asdl_c.py. + +#ifndef Py_INTERNAL_AST_STATE_H +#define Py_INTERNAL_AST_STATE_H + +#include "pycore_lock.h" // _PyOnceFlag + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +struct ast_state { + _PyOnceFlag once; + int finalized; + PyObject *AST_type; + PyObject *Add_singleton; + PyObject *Add_type; + PyObject *And_singleton; + PyObject *And_type; + PyObject *AnnAssign_type; + PyObject *Assert_type; + PyObject *Assign_type; + PyObject *AsyncFor_type; + PyObject *AsyncFunctionDef_type; + PyObject *AsyncWith_type; + PyObject *Attribute_type; + PyObject *AugAssign_type; + PyObject *Await_type; + PyObject *BinOp_type; + PyObject *BitAnd_singleton; + PyObject *BitAnd_type; + PyObject *BitOr_singleton; + PyObject *BitOr_type; + PyObject *BitXor_singleton; + PyObject *BitXor_type; + PyObject *BoolOp_type; + PyObject *Break_type; + PyObject *Call_type; + PyObject *ClassDef_type; + PyObject *Compare_type; + PyObject *Constant_type; + PyObject *Continue_type; + PyObject *Del_singleton; + PyObject *Del_type; + PyObject *Delete_type; + PyObject *DictComp_type; + PyObject *Dict_type; + PyObject *Div_singleton; + PyObject *Div_type; + PyObject *Eq_singleton; + PyObject *Eq_type; + PyObject *ExceptHandler_type; + PyObject *Expr_type; + PyObject *Expression_type; + PyObject *FloorDiv_singleton; + PyObject *FloorDiv_type; + PyObject *For_type; + PyObject *FormattedValue_type; + PyObject *FunctionDef_type; + PyObject *FunctionType_type; + PyObject *GeneratorExp_type; + PyObject *Global_type; + PyObject *GtE_singleton; + PyObject *GtE_type; + PyObject *Gt_singleton; + PyObject *Gt_type; + PyObject *IfExp_type; + PyObject *If_type; + PyObject *ImportFrom_type; + PyObject *Import_type; + PyObject *In_singleton; + PyObject *In_type; + PyObject *Interactive_type; + PyObject *Invert_singleton; + PyObject *Invert_type; + PyObject *IsNot_singleton; + PyObject *IsNot_type; + PyObject *Is_singleton; + PyObject *Is_type; + PyObject *JoinedStr_type; + PyObject *LShift_singleton; + PyObject *LShift_type; + PyObject *Lambda_type; + PyObject *ListComp_type; + PyObject *List_type; + PyObject *Load_singleton; + PyObject *Load_type; + PyObject *LtE_singleton; + PyObject *LtE_type; + PyObject *Lt_singleton; + PyObject *Lt_type; + PyObject *MatMult_singleton; + PyObject *MatMult_type; + PyObject *MatchAs_type; + PyObject *MatchClass_type; + PyObject *MatchMapping_type; + PyObject *MatchOr_type; + PyObject *MatchSequence_type; + PyObject *MatchSingleton_type; + PyObject *MatchStar_type; + PyObject *MatchValue_type; + PyObject *Match_type; + PyObject *Mod_singleton; + PyObject *Mod_type; + PyObject *Module_type; + PyObject *Mult_singleton; + PyObject *Mult_type; + PyObject *Name_type; + PyObject *NamedExpr_type; + PyObject *Nonlocal_type; + PyObject *NotEq_singleton; + PyObject *NotEq_type; + PyObject *NotIn_singleton; + PyObject *NotIn_type; + PyObject *Not_singleton; + PyObject *Not_type; + PyObject *Or_singleton; + PyObject *Or_type; + PyObject *ParamSpec_type; + PyObject *Pass_type; + PyObject *Pow_singleton; + PyObject *Pow_type; + PyObject *RShift_singleton; + PyObject *RShift_type; + PyObject *Raise_type; + PyObject *Return_type; + PyObject *SetComp_type; + PyObject *Set_type; + PyObject *Slice_type; + PyObject *Starred_type; + PyObject *Store_singleton; + PyObject *Store_type; + PyObject *Sub_singleton; + PyObject *Sub_type; + PyObject *Subscript_type; + PyObject *TryStar_type; + PyObject *Try_type; + PyObject *Tuple_type; + PyObject *TypeAlias_type; + PyObject *TypeIgnore_type; + PyObject *TypeVarTuple_type; + PyObject *TypeVar_type; + PyObject *UAdd_singleton; + PyObject *UAdd_type; + PyObject *USub_singleton; + PyObject *USub_type; + PyObject *UnaryOp_type; + PyObject *While_type; + PyObject *With_type; + PyObject *YieldFrom_type; + PyObject *Yield_type; + PyObject *__dict__; + PyObject *__doc__; + PyObject *__match_args__; + PyObject *__module__; + PyObject *_attributes; + PyObject *_fields; + PyObject *alias_type; + PyObject *annotation; + PyObject *arg; + PyObject *arg_type; + PyObject *args; + PyObject *argtypes; + PyObject *arguments_type; + PyObject *asname; + PyObject *ast; + PyObject *attr; + PyObject *bases; + PyObject *body; + PyObject *boolop_type; + PyObject *bound; + PyObject *cases; + PyObject *cause; + PyObject *cls; + PyObject *cmpop_type; + PyObject *col_offset; + PyObject *comparators; + PyObject *comprehension_type; + PyObject *context_expr; + PyObject *conversion; + PyObject *ctx; + PyObject *decorator_list; + PyObject *default_value; + PyObject *defaults; + PyObject *elt; + PyObject *elts; + PyObject *end_col_offset; + PyObject *end_lineno; + PyObject *exc; + PyObject *excepthandler_type; + PyObject *expr_context_type; + PyObject *expr_type; + PyObject *finalbody; + PyObject *format_spec; + PyObject *func; + PyObject *generators; + PyObject *guard; + PyObject *handlers; + PyObject *id; + PyObject *ifs; + PyObject *is_async; + PyObject *items; + PyObject *iter; + PyObject *key; + PyObject *keys; + PyObject *keyword_type; + PyObject *keywords; + PyObject *kind; + PyObject *kw_defaults; + PyObject *kwarg; + PyObject *kwd_attrs; + PyObject *kwd_patterns; + PyObject *kwonlyargs; + PyObject *left; + PyObject *level; + PyObject *lineno; + PyObject *lower; + PyObject *match_case_type; + PyObject *mod_type; + PyObject *module; + PyObject *msg; + PyObject *name; + PyObject *names; + PyObject *op; + PyObject *operand; + PyObject *operator_type; + PyObject *ops; + PyObject *optional_vars; + PyObject *orelse; + PyObject *pattern; + PyObject *pattern_type; + PyObject *patterns; + PyObject *posonlyargs; + PyObject *rest; + PyObject *returns; + PyObject *right; + PyObject *simple; + PyObject *slice; + PyObject *step; + PyObject *stmt_type; + PyObject *subject; + PyObject *tag; + PyObject *target; + PyObject *targets; + PyObject *test; + PyObject *type; + PyObject *type_comment; + PyObject *type_ignore_type; + PyObject *type_ignores; + PyObject *type_param_type; + PyObject *type_params; + PyObject *unaryop_type; + PyObject *upper; + PyObject *value; + PyObject *values; + PyObject *vararg; + PyObject *withitem_type; +}; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_AST_STATE_H */ + diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_atexit.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_atexit.h new file mode 100644 index 00000000..72c66a05 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_atexit.h @@ -0,0 +1,67 @@ +#ifndef Py_INTERNAL_ATEXIT_H +#define Py_INTERNAL_ATEXIT_H + +#include "pycore_lock.h" // PyMutex + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +//############### +// runtime atexit + +typedef void (*atexit_callbackfunc)(void); + +struct _atexit_runtime_state { + PyMutex mutex; +#define NEXITFUNCS 32 + atexit_callbackfunc callbacks[NEXITFUNCS]; + int ncallbacks; +}; + + +//################### +// interpreter atexit + +typedef void (*atexit_datacallbackfunc)(void *); + +typedef struct atexit_callback { + atexit_datacallbackfunc func; + void *data; + struct atexit_callback *next; +} atexit_callback; + +typedef struct { + PyObject *func; + PyObject *args; + PyObject *kwargs; +} atexit_py_callback; + +struct atexit_state { + atexit_callback *ll_callbacks; + // Kept for ABI compatibility--do not use! (See GH-127791.) + atexit_callback *last_ll_callback; + + // XXX The rest of the state could be moved to the atexit module state + // and a low-level callback added for it during module exec. + // For the moment we leave it here. + atexit_py_callback **callbacks; + int ncallbacks; + int callback_len; +}; + +// Export for '_interpchannels' shared extension +PyAPI_FUNC(int) _Py_AtExit( + PyInterpreterState *interp, + atexit_datacallbackfunc func, + void *data); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_ATEXIT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_backoff.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_backoff.h new file mode 100644 index 00000000..0bcca1e7 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_backoff.h @@ -0,0 +1,145 @@ + +#ifndef Py_INTERNAL_BACKOFF_H +#define Py_INTERNAL_BACKOFF_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include +#include +#include + + +typedef struct { + union { + struct { + uint16_t backoff : 4; + uint16_t value : 12; + }; + uint16_t as_counter; // For printf("%#x", ...) + }; +} _Py_BackoffCounter; + + +/* 16-bit countdown counters using exponential backoff. + + These are used by the adaptive specializer to count down until + it is time to specialize an instruction. If specialization fails + the counter is reset using exponential backoff. + + Another use is for the Tier 2 optimizer to decide when to create + a new Tier 2 trace (executor). Again, exponential backoff is used. + + The 16-bit counter is structured as a 12-bit unsigned 'value' + and a 4-bit 'backoff' field. When resetting the counter, the + backoff field is incremented (until it reaches a limit) and the + value is set to a bit mask representing the value 2**backoff - 1. + The maximum backoff is 12 (the number of value bits). + + There is an exceptional value which must not be updated, 0xFFFF. +*/ + +#define UNREACHABLE_BACKOFF 0xFFFF + +static inline bool +is_unreachable_backoff_counter(_Py_BackoffCounter counter) +{ + return counter.as_counter == UNREACHABLE_BACKOFF; +} + +static inline _Py_BackoffCounter +make_backoff_counter(uint16_t value, uint16_t backoff) +{ + assert(backoff <= 15); + assert(value <= 0xFFF); + _Py_BackoffCounter result; + result.value = value; + result.backoff = backoff; + return result; +} + +static inline _Py_BackoffCounter +forge_backoff_counter(uint16_t counter) +{ + _Py_BackoffCounter result; + result.as_counter = counter; + return result; +} + +static inline _Py_BackoffCounter +restart_backoff_counter(_Py_BackoffCounter counter) +{ + assert(!is_unreachable_backoff_counter(counter)); + if (counter.backoff < 12) { + return make_backoff_counter((1 << (counter.backoff + 1)) - 1, counter.backoff + 1); + } + else { + return make_backoff_counter((1 << 12) - 1, 12); + } +} + +static inline _Py_BackoffCounter +pause_backoff_counter(_Py_BackoffCounter counter) +{ + return make_backoff_counter(counter.value | 1, counter.backoff); +} + +static inline _Py_BackoffCounter +advance_backoff_counter(_Py_BackoffCounter counter) +{ + if (!is_unreachable_backoff_counter(counter)) { + return make_backoff_counter((counter.value - 1) & 0xFFF, counter.backoff); + } + else { + return counter; + } +} + +static inline bool +backoff_counter_triggers(_Py_BackoffCounter counter) +{ + return counter.value == 0; +} + +/* Initial JUMP_BACKWARD counter. + * This determines when we create a trace for a loop. +* Backoff sequence 16, 32, 64, 128, 256, 512, 1024, 2048, 4096. */ +#define JUMP_BACKWARD_INITIAL_VALUE 16 +#define JUMP_BACKWARD_INITIAL_BACKOFF 4 +static inline _Py_BackoffCounter +initial_jump_backoff_counter(void) +{ + return make_backoff_counter(JUMP_BACKWARD_INITIAL_VALUE, + JUMP_BACKWARD_INITIAL_BACKOFF); +} + +/* Initial exit temperature. + * Must be larger than ADAPTIVE_COOLDOWN_VALUE, + * otherwise when a side exit warms up we may construct + * a new trace before the Tier 1 code has properly re-specialized. + * Backoff sequence 64, 128, 256, 512, 1024, 2048, 4096. */ +#define COLD_EXIT_INITIAL_VALUE 64 +#define COLD_EXIT_INITIAL_BACKOFF 6 + +static inline _Py_BackoffCounter +initial_temperature_backoff_counter(void) +{ + return make_backoff_counter(COLD_EXIT_INITIAL_VALUE, + COLD_EXIT_INITIAL_BACKOFF); +} + +/* Unreachable backoff counter. */ +static inline _Py_BackoffCounter +initial_unreachable_backoff_counter(void) +{ + return forge_backoff_counter(UNREACHABLE_BACKOFF); +} + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_BACKOFF_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_bitutils.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_bitutils.h new file mode 100644 index 00000000..50f69377 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_bitutils.h @@ -0,0 +1,186 @@ +/* Bit and bytes utilities. + + Bytes swap functions, reverse order of bytes: + + - _Py_bswap16(uint16_t) + - _Py_bswap32(uint32_t) + - _Py_bswap64(uint64_t) +*/ + +#ifndef Py_INTERNAL_BITUTILS_H +#define Py_INTERNAL_BITUTILS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#if defined(__GNUC__) \ + && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) + /* __builtin_bswap16() is available since GCC 4.8, + __builtin_bswap32() is available since GCC 4.3, + __builtin_bswap64() is available since GCC 4.3. */ +# define _PY_HAVE_BUILTIN_BSWAP +#endif + +#ifdef _MSC_VER +# include // _byteswap_uint64() +#endif + + +static inline uint16_t +_Py_bswap16(uint16_t word) +{ +#if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap16) + return __builtin_bswap16(word); +#elif defined(_MSC_VER) + Py_BUILD_ASSERT(sizeof(word) == sizeof(unsigned short)); + return _byteswap_ushort(word); +#else + // Portable implementation which doesn't rely on circular bit shift + return ( ((word & UINT16_C(0x00FF)) << 8) + | ((word & UINT16_C(0xFF00)) >> 8)); +#endif +} + +static inline uint32_t +_Py_bswap32(uint32_t word) +{ +#if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap32) + return __builtin_bswap32(word); +#elif defined(_MSC_VER) + Py_BUILD_ASSERT(sizeof(word) == sizeof(unsigned long)); + return _byteswap_ulong(word); +#else + // Portable implementation which doesn't rely on circular bit shift + return ( ((word & UINT32_C(0x000000FF)) << 24) + | ((word & UINT32_C(0x0000FF00)) << 8) + | ((word & UINT32_C(0x00FF0000)) >> 8) + | ((word & UINT32_C(0xFF000000)) >> 24)); +#endif +} + +static inline uint64_t +_Py_bswap64(uint64_t word) +{ +#if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap64) + return __builtin_bswap64(word); +#elif defined(_MSC_VER) + return _byteswap_uint64(word); +#else + // Portable implementation which doesn't rely on circular bit shift + return ( ((word & UINT64_C(0x00000000000000FF)) << 56) + | ((word & UINT64_C(0x000000000000FF00)) << 40) + | ((word & UINT64_C(0x0000000000FF0000)) << 24) + | ((word & UINT64_C(0x00000000FF000000)) << 8) + | ((word & UINT64_C(0x000000FF00000000)) >> 8) + | ((word & UINT64_C(0x0000FF0000000000)) >> 24) + | ((word & UINT64_C(0x00FF000000000000)) >> 40) + | ((word & UINT64_C(0xFF00000000000000)) >> 56)); +#endif +} + + +// Population count: count the number of 1's in 'x' +// (number of bits set to 1), also known as the hamming weight. +// +// Implementation note. CPUID is not used, to test if x86 POPCNT instruction +// can be used, to keep the implementation simple. For example, Visual Studio +// __popcnt() is not used this reason. The clang and GCC builtin function can +// use the x86 POPCNT instruction if the target architecture has SSE4a or +// newer. +static inline int +_Py_popcount32(uint32_t x) +{ +#if (defined(__clang__) || defined(__GNUC__)) + +#if SIZEOF_INT >= 4 + Py_BUILD_ASSERT(sizeof(x) <= sizeof(unsigned int)); + return __builtin_popcount(x); +#else + // The C standard guarantees that unsigned long will always be big enough + // to hold a uint32_t value without losing information. + Py_BUILD_ASSERT(sizeof(x) <= sizeof(unsigned long)); + return __builtin_popcountl(x); +#endif + +#else + // 32-bit SWAR (SIMD Within A Register) popcount + + // Binary: 0 1 0 1 ... + const uint32_t M1 = 0x55555555; + // Binary: 00 11 00 11. .. + const uint32_t M2 = 0x33333333; + // Binary: 0000 1111 0000 1111 ... + const uint32_t M4 = 0x0F0F0F0F; + + // Put count of each 2 bits into those 2 bits + x = x - ((x >> 1) & M1); + // Put count of each 4 bits into those 4 bits + x = (x & M2) + ((x >> 2) & M2); + // Put count of each 8 bits into those 8 bits + x = (x + (x >> 4)) & M4; + // Sum of the 4 byte counts. + // Take care when considering changes to the next line. Portability and + // correctness are delicate here, thanks to C's "integer promotions" (C99 + // §6.3.1.1p2). On machines where the `int` type has width greater than 32 + // bits, `x` will be promoted to an `int`, and following C's "usual + // arithmetic conversions" (C99 §6.3.1.8), the multiplication will be + // performed as a multiplication of two `unsigned int` operands. In this + // case it's critical that we cast back to `uint32_t` in order to keep only + // the least significant 32 bits. On machines where the `int` type has + // width no greater than 32, the multiplication is of two 32-bit unsigned + // integer types, and the (uint32_t) cast is a no-op. In both cases, we + // avoid the risk of undefined behaviour due to overflow of a + // multiplication of signed integer types. + return (uint32_t)(x * 0x01010101U) >> 24; +#endif +} + + +// Return the index of the most significant 1 bit in 'x'. This is the smallest +// integer k such that x < 2**k. Equivalent to floor(log2(x)) + 1 for x != 0. +static inline int +_Py_bit_length(unsigned long x) +{ +#if (defined(__clang__) || defined(__GNUC__)) + if (x != 0) { + // __builtin_clzl() is available since GCC 3.4. + // Undefined behavior for x == 0. + return (int)sizeof(unsigned long) * 8 - __builtin_clzl(x); + } + else { + return 0; + } +#elif defined(_MSC_VER) + // _BitScanReverse() is documented to search 32 bits. + Py_BUILD_ASSERT(sizeof(unsigned long) <= 4); + unsigned long msb; + if (_BitScanReverse(&msb, x)) { + return (int)msb + 1; + } + else { + return 0; + } +#else + const int BIT_LENGTH_TABLE[32] = { + 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 + }; + int msb = 0; + while (x >= 32) { + msb += 6; + x >>= 6; + } + msb += BIT_LENGTH_TABLE[x]; + return msb; +#endif +} + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_BITUTILS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_blocks_output_buffer.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_blocks_output_buffer.h new file mode 100644 index 00000000..573e1035 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_blocks_output_buffer.h @@ -0,0 +1,321 @@ +/* + _BlocksOutputBuffer is used to maintain an output buffer + that has unpredictable size. Suitable for compression/decompression + API (bz2/lzma/zlib) that has stream->next_out and stream->avail_out: + + stream->next_out: point to the next output position. + stream->avail_out: the number of available bytes left in the buffer. + + It maintains a list of bytes object, so there is no overhead of resizing + the buffer. + + Usage: + + 1, Initialize the struct instance like this: + _BlocksOutputBuffer buffer = {.list = NULL}; + Set .list to NULL for _BlocksOutputBuffer_OnError() + + 2, Initialize the buffer use one of these functions: + _BlocksOutputBuffer_InitAndGrow() + _BlocksOutputBuffer_InitWithSize() + + 3, If (avail_out == 0), grow the buffer: + _BlocksOutputBuffer_Grow() + + 4, Get the current outputted data size: + _BlocksOutputBuffer_GetDataSize() + + 5, Finish the buffer, and return a bytes object: + _BlocksOutputBuffer_Finish() + + 6, Clean up the buffer when an error occurred: + _BlocksOutputBuffer_OnError() +*/ + +#ifndef Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H +#define Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "Python.h" + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +typedef struct { + // List of bytes objects + PyObject *list; + // Number of whole allocated size + Py_ssize_t allocated; + // Max length of the buffer, negative number means unlimited length. + Py_ssize_t max_length; +} _BlocksOutputBuffer; + +static const char unable_allocate_msg[] = "Unable to allocate output buffer."; + +/* In 32-bit build, the max block size should <= INT32_MAX. */ +#define OUTPUT_BUFFER_MAX_BLOCK_SIZE (256*1024*1024) + +/* Block size sequence */ +#define KB (1024) +#define MB (1024*1024) +static const Py_ssize_t BUFFER_BLOCK_SIZE[] = + { 32*KB, 64*KB, 256*KB, 1*MB, 4*MB, 8*MB, 16*MB, 16*MB, + 32*MB, 32*MB, 32*MB, 32*MB, 64*MB, 64*MB, 128*MB, 128*MB, + OUTPUT_BUFFER_MAX_BLOCK_SIZE }; +#undef KB +#undef MB + +/* According to the block sizes defined by BUFFER_BLOCK_SIZE, the whole + allocated size growth step is: + 1 32 KB +32 KB + 2 96 KB +64 KB + 3 352 KB +256 KB + 4 1.34 MB +1 MB + 5 5.34 MB +4 MB + 6 13.34 MB +8 MB + 7 29.34 MB +16 MB + 8 45.34 MB +16 MB + 9 77.34 MB +32 MB + 10 109.34 MB +32 MB + 11 141.34 MB +32 MB + 12 173.34 MB +32 MB + 13 237.34 MB +64 MB + 14 301.34 MB +64 MB + 15 429.34 MB +128 MB + 16 557.34 MB +128 MB + 17 813.34 MB +256 MB + 18 1069.34 MB +256 MB + 19 1325.34 MB +256 MB + 20 1581.34 MB +256 MB + 21 1837.34 MB +256 MB + 22 2093.34 MB +256 MB + ... +*/ + +/* Initialize the buffer, and grow the buffer. + + max_length: Max length of the buffer, -1 for unlimited length. + + On success, return allocated size (>=0) + On failure, return -1 +*/ +static inline Py_ssize_t +_BlocksOutputBuffer_InitAndGrow(_BlocksOutputBuffer *buffer, + const Py_ssize_t max_length, + void **next_out) +{ + PyObject *b; + Py_ssize_t block_size; + + // ensure .list was set to NULL + assert(buffer->list == NULL); + + // get block size + if (0 <= max_length && max_length < BUFFER_BLOCK_SIZE[0]) { + block_size = max_length; + } else { + block_size = BUFFER_BLOCK_SIZE[0]; + } + + // the first block + b = PyBytes_FromStringAndSize(NULL, block_size); + if (b == NULL) { + return -1; + } + + // create the list + buffer->list = PyList_New(1); + if (buffer->list == NULL) { + Py_DECREF(b); + return -1; + } + PyList_SET_ITEM(buffer->list, 0, b); + + // set variables + buffer->allocated = block_size; + buffer->max_length = max_length; + + *next_out = PyBytes_AS_STRING(b); + return block_size; +} + +/* Initialize the buffer, with an initial size. + + Check block size limit in the outer wrapper function. For example, some libs + accept UINT32_MAX as the maximum block size, then init_size should <= it. + + On success, return allocated size (>=0) + On failure, return -1 +*/ +static inline Py_ssize_t +_BlocksOutputBuffer_InitWithSize(_BlocksOutputBuffer *buffer, + const Py_ssize_t init_size, + void **next_out) +{ + PyObject *b; + + // ensure .list was set to NULL + assert(buffer->list == NULL); + + // the first block + b = PyBytes_FromStringAndSize(NULL, init_size); + if (b == NULL) { + PyErr_SetString(PyExc_MemoryError, unable_allocate_msg); + return -1; + } + + // create the list + buffer->list = PyList_New(1); + if (buffer->list == NULL) { + Py_DECREF(b); + return -1; + } + PyList_SET_ITEM(buffer->list, 0, b); + + // set variables + buffer->allocated = init_size; + buffer->max_length = -1; + + *next_out = PyBytes_AS_STRING(b); + return init_size; +} + +/* Grow the buffer. The avail_out must be 0, please check it before calling. + + On success, return allocated size (>=0) + On failure, return -1 +*/ +static inline Py_ssize_t +_BlocksOutputBuffer_Grow(_BlocksOutputBuffer *buffer, + void **next_out, + const Py_ssize_t avail_out) +{ + PyObject *b; + const Py_ssize_t list_len = Py_SIZE(buffer->list); + Py_ssize_t block_size; + + // ensure no gaps in the data + if (avail_out != 0) { + PyErr_SetString(PyExc_SystemError, + "avail_out is non-zero in _BlocksOutputBuffer_Grow()."); + return -1; + } + + // get block size + if (list_len < (Py_ssize_t) Py_ARRAY_LENGTH(BUFFER_BLOCK_SIZE)) { + block_size = BUFFER_BLOCK_SIZE[list_len]; + } else { + block_size = BUFFER_BLOCK_SIZE[Py_ARRAY_LENGTH(BUFFER_BLOCK_SIZE) - 1]; + } + + // check max_length + if (buffer->max_length >= 0) { + // if (rest == 0), should not grow the buffer. + Py_ssize_t rest = buffer->max_length - buffer->allocated; + assert(rest > 0); + + // block_size of the last block + if (block_size > rest) { + block_size = rest; + } + } + + // check buffer->allocated overflow + if (block_size > PY_SSIZE_T_MAX - buffer->allocated) { + PyErr_SetString(PyExc_MemoryError, unable_allocate_msg); + return -1; + } + + // create the block + b = PyBytes_FromStringAndSize(NULL, block_size); + if (b == NULL) { + PyErr_SetString(PyExc_MemoryError, unable_allocate_msg); + return -1; + } + if (PyList_Append(buffer->list, b) < 0) { + Py_DECREF(b); + return -1; + } + Py_DECREF(b); + + // set variables + buffer->allocated += block_size; + + *next_out = PyBytes_AS_STRING(b); + return block_size; +} + +/* Return the current outputted data size. */ +static inline Py_ssize_t +_BlocksOutputBuffer_GetDataSize(_BlocksOutputBuffer *buffer, + const Py_ssize_t avail_out) +{ + return buffer->allocated - avail_out; +} + +/* Finish the buffer. + + Return a bytes object on success + Return NULL on failure +*/ +static inline PyObject * +_BlocksOutputBuffer_Finish(_BlocksOutputBuffer *buffer, + const Py_ssize_t avail_out) +{ + PyObject *result, *block; + const Py_ssize_t list_len = Py_SIZE(buffer->list); + + // fast path for single block + if ((list_len == 1 && avail_out == 0) || + (list_len == 2 && Py_SIZE(PyList_GET_ITEM(buffer->list, 1)) == avail_out)) + { + block = PyList_GET_ITEM(buffer->list, 0); + Py_INCREF(block); + + Py_CLEAR(buffer->list); + return block; + } + + // final bytes object + result = PyBytes_FromStringAndSize(NULL, buffer->allocated - avail_out); + if (result == NULL) { + PyErr_SetString(PyExc_MemoryError, unable_allocate_msg); + return NULL; + } + + // memory copy + if (list_len > 0) { + char *posi = PyBytes_AS_STRING(result); + + // blocks except the last one + Py_ssize_t i = 0; + for (; i < list_len-1; i++) { + block = PyList_GET_ITEM(buffer->list, i); + memcpy(posi, PyBytes_AS_STRING(block), Py_SIZE(block)); + posi += Py_SIZE(block); + } + // the last block + block = PyList_GET_ITEM(buffer->list, i); + memcpy(posi, PyBytes_AS_STRING(block), Py_SIZE(block) - avail_out); + } else { + assert(Py_SIZE(result) == 0); + } + + Py_CLEAR(buffer->list); + return result; +} + +/* Clean up the buffer when an error occurred. */ +static inline void +_BlocksOutputBuffer_OnError(_BlocksOutputBuffer *buffer) +{ + Py_CLEAR(buffer->list); +} + +#ifdef __cplusplus +} +#endif +#endif /* Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_brc.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_brc.h new file mode 100644 index 00000000..3453d83b --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_brc.h @@ -0,0 +1,74 @@ +#ifndef Py_INTERNAL_BRC_H +#define Py_INTERNAL_BRC_H + +#include +#include "pycore_llist.h" // struct llist_node +#include "pycore_lock.h" // PyMutex +#include "pycore_object_stack.h" // _PyObjectStack + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#ifdef Py_GIL_DISABLED + +// Prime number to avoid correlations with memory addresses. +#define _Py_BRC_NUM_BUCKETS 257 + +// Hash table bucket +struct _brc_bucket { + // Mutex protects both the bucket and thread state queues in this bucket. + PyMutex mutex; + + // Linked list of _PyThreadStateImpl objects hashed to this bucket. + struct llist_node root; +}; + +// Per-interpreter biased reference counting state +struct _brc_state { + // Hash table of thread states by thread-id. Thread states within a bucket + // are chained using a doubly-linked list. + struct _brc_bucket table[_Py_BRC_NUM_BUCKETS]; +}; + +// Per-thread biased reference counting state +struct _brc_thread_state { + // Linked-list of thread states per hash bucket + struct llist_node bucket_node; + + // Thread-id as determined by _PyThread_Id() + uintptr_t tid; + + // Objects with refcounts to be merged (protected by bucket mutex) + _PyObjectStack objects_to_merge; + + // Local stack of objects to be merged (not accessed by other threads) + _PyObjectStack local_objects_to_merge; +}; + +// Initialize/finalize the per-thread biased reference counting state +void _Py_brc_init_thread(PyThreadState *tstate); +void _Py_brc_remove_thread(PyThreadState *tstate); + +// Initialize per-interpreter state +void _Py_brc_init_state(PyInterpreterState *interp); + +void _Py_brc_after_fork(PyInterpreterState *interp); + +// Enqueues an object to be merged by it's owning thread (tid). This +// steals a reference to the object. +void _Py_brc_queue_object(PyObject *ob); + +// Merge the refcounts of queued objects for the current thread. +void _Py_brc_merge_refcounts(PyThreadState *tstate); + +#endif /* Py_GIL_DISABLED */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_BRC_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_bytes_methods.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_bytes_methods.h new file mode 100644 index 00000000..059dc259 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_bytes_methods.h @@ -0,0 +1,82 @@ +#ifndef Py_LIMITED_API +#ifndef Py_BYTES_CTYPE_H +#define Py_BYTES_CTYPE_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* + * The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray) + * methods of the given names, they operate on ASCII byte strings. + */ +extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isascii(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len); + +/* These store their len sized answer in the given preallocated *result arg. */ +extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len); +extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len); +extern void _Py_bytes_title(char *result, const char *s, Py_ssize_t len); +extern void _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len); +extern void _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len); + +extern PyObject *_Py_bytes_find(const char *str, Py_ssize_t len, PyObject *sub, + Py_ssize_t start, Py_ssize_t end); +extern PyObject *_Py_bytes_index(const char *str, Py_ssize_t len, PyObject *sub, + Py_ssize_t start, Py_ssize_t end); +extern PyObject *_Py_bytes_rfind(const char *str, Py_ssize_t len, PyObject *sub, + Py_ssize_t start, Py_ssize_t end); +extern PyObject *_Py_bytes_rindex(const char *str, Py_ssize_t len, PyObject *sub, + Py_ssize_t start, Py_ssize_t end); +extern PyObject *_Py_bytes_count(const char *str, Py_ssize_t len, PyObject *sub, + Py_ssize_t start, Py_ssize_t end); +extern int _Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg); +extern PyObject *_Py_bytes_startswith(const char *str, Py_ssize_t len, + PyObject *subobj, Py_ssize_t start, + Py_ssize_t end); +extern PyObject *_Py_bytes_endswith(const char *str, Py_ssize_t len, + PyObject *subobj, Py_ssize_t start, + Py_ssize_t end); + +/* The maketrans() static method. */ +extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to); + +/* Shared __doc__ strings. */ +extern const char _Py_isspace__doc__[]; +extern const char _Py_isalpha__doc__[]; +extern const char _Py_isalnum__doc__[]; +extern const char _Py_isascii__doc__[]; +extern const char _Py_isdigit__doc__[]; +extern const char _Py_islower__doc__[]; +extern const char _Py_isupper__doc__[]; +extern const char _Py_istitle__doc__[]; +extern const char _Py_lower__doc__[]; +extern const char _Py_upper__doc__[]; +extern const char _Py_title__doc__[]; +extern const char _Py_capitalize__doc__[]; +extern const char _Py_swapcase__doc__[]; +extern const char _Py_count__doc__[]; +extern const char _Py_find__doc__[]; +extern const char _Py_index__doc__[]; +extern const char _Py_rfind__doc__[]; +extern const char _Py_rindex__doc__[]; +extern const char _Py_startswith__doc__[]; +extern const char _Py_endswith__doc__[]; +extern const char _Py_maketrans__doc__[]; +extern const char _Py_expandtabs__doc__[]; +extern const char _Py_ljust__doc__[]; +extern const char _Py_rjust__doc__[]; +extern const char _Py_center__doc__[]; +extern const char _Py_zfill__doc__[]; + +/* this is needed because some docs are shared from the .o, not static */ +#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str) + +#endif /* !Py_BYTES_CTYPE_H */ +#endif /* !Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_bytesobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_bytesobject.h new file mode 100644 index 00000000..8c922a4f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_bytesobject.h @@ -0,0 +1,152 @@ +#ifndef Py_INTERNAL_BYTESOBJECT_H +#define Py_INTERNAL_BYTESOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern PyObject* _PyBytes_FormatEx( + const char *format, + Py_ssize_t format_len, + PyObject *args, + int use_bytearray); + +extern PyObject* _PyBytes_FromHex( + PyObject *string, + int use_bytearray); + +// Helper for PyBytes_DecodeEscape that detects invalid escape chars. +// Export for test_peg_generator. +PyAPI_FUNC(PyObject*) _PyBytes_DecodeEscape2(const char *, Py_ssize_t, + const char *, + int *, const char **); +// Export for binary compatibility. +PyAPI_FUNC(PyObject*) _PyBytes_DecodeEscape(const char *, Py_ssize_t, + const char *, const char **); + + +// Substring Search. +// +// Returns the index of the first occurrence of +// a substring ("needle") in a larger text ("haystack"). +// If the needle is not found, return -1. +// If the needle is found, add offset to the index. +// +// Export for 'mmap' shared extension. +PyAPI_FUNC(Py_ssize_t) +_PyBytes_Find(const char *haystack, Py_ssize_t len_haystack, + const char *needle, Py_ssize_t len_needle, + Py_ssize_t offset); + +// Same as above, but search right-to-left. +// Export for 'mmap' shared extension. +PyAPI_FUNC(Py_ssize_t) +_PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack, + const char *needle, Py_ssize_t len_needle, + Py_ssize_t offset); + + +// Helper function to implement the repeat and inplace repeat methods on a +// buffer. +// +// len_dest is assumed to be an integer multiple of len_src. +// If src equals dest, then assume the operation is inplace. +// +// This method repeately doubles the number of bytes copied to reduce +// the number of invocations of memcpy. +// +// Export for 'array' shared extension. +PyAPI_FUNC(void) +_PyBytes_Repeat(char* dest, Py_ssize_t len_dest, + const char* src, Py_ssize_t len_src); + +/* --- _PyBytesWriter ----------------------------------------------------- */ + +/* The _PyBytesWriter structure is big: it contains an embedded "stack buffer". + A _PyBytesWriter variable must be declared at the end of variables in a + function to optimize the memory allocation on the stack. */ +typedef struct { + /* bytes, bytearray or NULL (when the small buffer is used) */ + PyObject *buffer; + + /* Number of allocated size. */ + Py_ssize_t allocated; + + /* Minimum number of allocated bytes, + incremented by _PyBytesWriter_Prepare() */ + Py_ssize_t min_size; + + /* If non-zero, use a bytearray instead of a bytes object for buffer. */ + int use_bytearray; + + /* If non-zero, overallocate the buffer (default: 0). + This flag must be zero if use_bytearray is non-zero. */ + int overallocate; + + /* Stack buffer */ + int use_small_buffer; + char small_buffer[512]; +} _PyBytesWriter; + +/* Initialize a bytes writer + + By default, the overallocation is disabled. Set the overallocate attribute + to control the allocation of the buffer. + + Export _PyBytesWriter API for '_pickle' shared extension. */ +PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer); + +/* Get the buffer content and reset the writer. + Return a bytes object, or a bytearray object if use_bytearray is non-zero. + Raise an exception and return NULL on error. */ +PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer, + void *str); + +/* Deallocate memory of a writer (clear its internal buffer). */ +PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer); + +/* Allocate the buffer to write size bytes. + Return the pointer to the beginning of buffer data. + Raise an exception and return NULL on error. */ +PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer, + Py_ssize_t size); + +/* Ensure that the buffer is large enough to write *size* bytes. + Add size to the writer minimum size (min_size attribute). + + str is the current pointer inside the buffer. + Return the updated current pointer inside the buffer. + Raise an exception and return NULL on error. */ +PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer, + void *str, + Py_ssize_t size); + +/* Resize the buffer to make it larger. + The new buffer may be larger than size bytes because of overallocation. + Return the updated current pointer inside the buffer. + Raise an exception and return NULL on error. + + Note: size must be greater than the number of allocated bytes in the writer. + + This function doesn't use the writer minimum size (min_size attribute). + + See also _PyBytesWriter_Prepare(). + */ +PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer, + void *str, + Py_ssize_t size); + +/* Write bytes. + Raise an exception and return NULL on error. */ +PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer, + void *str, + const void *bytes, + Py_ssize_t size); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_BYTESOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_call.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_call.h new file mode 100644 index 00000000..c92028a0 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_call.h @@ -0,0 +1,205 @@ +#ifndef Py_INTERNAL_CALL_H +#define Py_INTERNAL_CALL_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_identifier.h" // _Py_Identifier +#include "pycore_pystate.h" // _PyThreadState_GET() + +/* Suggested size (number of positional arguments) for arrays of PyObject* + allocated on a C stack to avoid allocating memory on the heap memory. Such + array is used to pass positional arguments to call functions of the + PyObject_Vectorcall() family. + + The size is chosen to not abuse the C stack and so limit the risk of stack + overflow. The size is also chosen to allow using the small stack for most + function calls of the Python standard library. On 64-bit CPU, it allocates + 40 bytes on the stack. */ +#define _PY_FASTCALL_SMALL_STACK 5 + + +// Export for 'math' shared extension, used via _PyObject_VectorcallTstate() +// static inline function. +PyAPI_FUNC(PyObject*) _Py_CheckFunctionResult( + PyThreadState *tstate, + PyObject *callable, + PyObject *result, + const char *where); + +extern PyObject* _PyObject_Call_Prepend( + PyThreadState *tstate, + PyObject *callable, + PyObject *obj, + PyObject *args, + PyObject *kwargs); + +extern PyObject* _PyObject_VectorcallDictTstate( + PyThreadState *tstate, + PyObject *callable, + PyObject *const *args, + size_t nargsf, + PyObject *kwargs); + +extern PyObject* _PyObject_Call( + PyThreadState *tstate, + PyObject *callable, + PyObject *args, + PyObject *kwargs); + +extern PyObject * _PyObject_CallMethodFormat( + PyThreadState *tstate, + PyObject *callable, + const char *format, + ...); + +// Export for 'array' shared extension +PyAPI_FUNC(PyObject*) _PyObject_CallMethod( + PyObject *obj, + PyObject *name, + const char *format, ...); + +extern PyObject* _PyObject_CallMethodIdObjArgs( + PyObject *obj, + _Py_Identifier *name, + ...); + +static inline PyObject * +_PyObject_VectorcallMethodId( + _Py_Identifier *name, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *oname = _PyUnicode_FromId(name); /* borrowed */ + if (!oname) { + return _Py_NULL; + } + return PyObject_VectorcallMethod(oname, args, nargsf, kwnames); +} + +static inline PyObject * +_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name) +{ + size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET; + return _PyObject_VectorcallMethodId(name, &self, nargsf, _Py_NULL); +} + +static inline PyObject * +_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg) +{ + PyObject *args[2] = {self, arg}; + size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET; + assert(arg != NULL); + return _PyObject_VectorcallMethodId(name, args, nargsf, _Py_NULL); +} + + +/* === Vectorcall protocol (PEP 590) ============================= */ + +// Call callable using tp_call. Arguments are like PyObject_Vectorcall(), +// except that nargs is plainly the number of arguments without flags. +// +// Export for 'math' shared extension, used via _PyObject_VectorcallTstate() +// static inline function. +PyAPI_FUNC(PyObject*) _PyObject_MakeTpCall( + PyThreadState *tstate, + PyObject *callable, + PyObject *const *args, Py_ssize_t nargs, + PyObject *keywords); + +// Static inline variant of public PyVectorcall_Function(). +static inline vectorcallfunc +_PyVectorcall_FunctionInline(PyObject *callable) +{ + assert(callable != NULL); + + PyTypeObject *tp = Py_TYPE(callable); + if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { + return NULL; + } + assert(PyCallable_Check(callable)); + + Py_ssize_t offset = tp->tp_vectorcall_offset; + assert(offset > 0); + + vectorcallfunc ptr; + memcpy(&ptr, (char *) callable + offset, sizeof(ptr)); + return ptr; +} + + +/* Call the callable object 'callable' with the "vectorcall" calling + convention. + + args is a C array for positional arguments. + + nargsf is the number of positional arguments plus optionally the flag + PY_VECTORCALL_ARGUMENTS_OFFSET which means that the caller is allowed to + modify args[-1]. + + kwnames is a tuple of keyword names. The values of the keyword arguments + are stored in "args" after the positional arguments (note that the number + of keyword arguments does not change nargsf). kwnames can also be NULL if + there are no keyword arguments. + + keywords must only contain strings and all keys must be unique. + + Return the result on success. Raise an exception and return NULL on + error. */ +static inline PyObject * +_PyObject_VectorcallTstate(PyThreadState *tstate, PyObject *callable, + PyObject *const *args, size_t nargsf, + PyObject *kwnames) +{ + vectorcallfunc func; + PyObject *res; + + assert(kwnames == NULL || PyTuple_Check(kwnames)); + assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0); + + func = _PyVectorcall_FunctionInline(callable); + if (func == NULL) { + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + return _PyObject_MakeTpCall(tstate, callable, args, nargs, kwnames); + } + res = func(callable, args, nargsf, kwnames); + return _Py_CheckFunctionResult(tstate, callable, res, NULL); +} + + +static inline PyObject * +_PyObject_CallNoArgsTstate(PyThreadState *tstate, PyObject *func) { + return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL); +} + + +// Private static inline function variant of public PyObject_CallNoArgs() +static inline PyObject * +_PyObject_CallNoArgs(PyObject *func) { + EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, func); + PyThreadState *tstate = _PyThreadState_GET(); + return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL); +} + + +extern PyObject *const * +_PyStack_UnpackDict(PyThreadState *tstate, + PyObject *const *args, Py_ssize_t nargs, + PyObject *kwargs, PyObject **p_kwnames); + +extern void _PyStack_UnpackDict_Free( + PyObject *const *stack, + Py_ssize_t nargs, + PyObject *kwnames); + +extern void _PyStack_UnpackDict_FreeNoDecRef( + PyObject *const *stack, + PyObject *kwnames); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CALL_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_capsule.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_capsule.h new file mode 100644 index 00000000..aa2c67f3 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_capsule.h @@ -0,0 +1,17 @@ +#ifndef Py_INTERNAL_PYCAPSULE_H +#define Py_INTERNAL_PYCAPSULE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Export for '_socket' shared extension +PyAPI_FUNC(int) _PyCapsule_SetTraverse(PyObject *op, traverseproc traverse_func, inquiry clear_func); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PYCAPSULE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_cell.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_cell.h new file mode 100644 index 00000000..27f67d57 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_cell.h @@ -0,0 +1,48 @@ +#ifndef Py_INTERNAL_CELL_H +#define Py_INTERNAL_CELL_H + +#include "pycore_critical_section.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Sets the cell contents to `value` and return previous contents. Steals a +// reference to `value`. +static inline PyObject * +PyCell_SwapTakeRef(PyCellObject *cell, PyObject *value) +{ + PyObject *old_value; + Py_BEGIN_CRITICAL_SECTION(cell); + old_value = cell->ob_ref; + cell->ob_ref = value; + Py_END_CRITICAL_SECTION(); + return old_value; +} + +static inline void +PyCell_SetTakeRef(PyCellObject *cell, PyObject *value) +{ + PyObject *old_value = PyCell_SwapTakeRef(cell, value); + Py_XDECREF(old_value); +} + +// Gets the cell contents. Returns a new reference. +static inline PyObject * +PyCell_GetRef(PyCellObject *cell) +{ + PyObject *res; + Py_BEGIN_CRITICAL_SECTION(cell); + res = Py_XNewRef(cell->ob_ref); + Py_END_CRITICAL_SECTION(); + return res; +} + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CELL_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_ceval.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_ceval.h new file mode 100644 index 00000000..043f5957 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_ceval.h @@ -0,0 +1,303 @@ +#ifndef Py_INTERNAL_CEVAL_H +#define Py_INTERNAL_CEVAL_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "dynamic_annotations.h" // _Py_ANNOTATE_RWLOCK_CREATE + +#include "pycore_interp.h" // PyInterpreterState.eval_frame +#include "pycore_pystate.h" // _PyThreadState_GET() + +/* Forward declarations */ +struct pyruntimestate; +struct _ceval_runtime_state; + +// Export for '_lsprof' shared extension +PyAPI_FUNC(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg); + +extern int _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg); + +extern int _PyEval_SetOpcodeTrace(PyFrameObject *f, bool enable); + +// Helper to look up a builtin object +// Export for 'array' shared extension +PyAPI_FUNC(PyObject*) _PyEval_GetBuiltin(PyObject *); + +extern PyObject* _PyEval_GetBuiltinId(_Py_Identifier *); + +extern void _PyEval_SetSwitchInterval(unsigned long microseconds); +extern unsigned long _PyEval_GetSwitchInterval(void); + +// Export for '_queue' shared extension +PyAPI_FUNC(int) _PyEval_MakePendingCalls(PyThreadState *); + +#ifndef Py_DEFAULT_RECURSION_LIMIT +# define Py_DEFAULT_RECURSION_LIMIT 1000 +#endif + +extern void _Py_FinishPendingCalls(PyThreadState *tstate); +extern void _PyEval_InitState(PyInterpreterState *); +extern void _PyEval_SignalReceived(void); + +// bitwise flags: +#define _Py_PENDING_MAINTHREADONLY 1 +#define _Py_PENDING_RAWFREE 2 + +typedef int _Py_add_pending_call_result; +#define _Py_ADD_PENDING_SUCCESS 0 +#define _Py_ADD_PENDING_FULL -1 + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(_Py_add_pending_call_result) _PyEval_AddPendingCall( + PyInterpreterState *interp, + _Py_pending_call_func func, + void *arg, + int flags); + +#ifdef HAVE_FORK +extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate); +#endif + +// Used by sys.call_tracing() +extern PyObject* _PyEval_CallTracing(PyObject *func, PyObject *args); + +// Used by sys.get_asyncgen_hooks() +extern PyObject* _PyEval_GetAsyncGenFirstiter(void); +extern PyObject* _PyEval_GetAsyncGenFinalizer(void); + +// Used by sys.set_asyncgen_hooks() +extern int _PyEval_SetAsyncGenFirstiter(PyObject *); +extern int _PyEval_SetAsyncGenFinalizer(PyObject *); + +// Used by sys.get_coroutine_origin_tracking_depth() +// and sys.set_coroutine_origin_tracking_depth() +extern int _PyEval_GetCoroutineOriginTrackingDepth(void); +extern int _PyEval_SetCoroutineOriginTrackingDepth(int depth); + +extern void _PyEval_Fini(void); + + +extern PyObject* _PyEval_GetBuiltins(PyThreadState *tstate); +extern PyObject* _PyEval_BuiltinsFromGlobals( + PyThreadState *tstate, + PyObject *globals); + +// Trampoline API + +typedef struct { + // Callback to initialize the trampoline state + void* (*init_state)(void); + // Callback to register every trampoline being created + void (*write_state)(void* state, const void *code_addr, + unsigned int code_size, PyCodeObject* code); + // Callback to free the trampoline state + int (*free_state)(void* state); +} _PyPerf_Callbacks; + +extern int _PyPerfTrampoline_SetCallbacks(_PyPerf_Callbacks *); +extern void _PyPerfTrampoline_GetCallbacks(_PyPerf_Callbacks *); +extern int _PyPerfTrampoline_Init(int activate); +extern int _PyPerfTrampoline_Fini(void); +extern void _PyPerfTrampoline_FreeArenas(void); +extern int _PyIsPerfTrampolineActive(void); +extern PyStatus _PyPerfTrampoline_AfterFork_Child(void); +#ifdef PY_HAVE_PERF_TRAMPOLINE +extern _PyPerf_Callbacks _Py_perfmap_callbacks; +extern _PyPerf_Callbacks _Py_perfmap_jit_callbacks; +#endif + +static inline PyObject* +_PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag) +{ + EVAL_CALL_STAT_INC(EVAL_CALL_TOTAL); + if (tstate->interp->eval_frame == NULL) { + return _PyEval_EvalFrameDefault(tstate, frame, throwflag); + } + return tstate->interp->eval_frame(tstate, frame, throwflag); +} + +extern PyObject* +_PyEval_Vector(PyThreadState *tstate, + PyFunctionObject *func, PyObject *locals, + PyObject* const* args, size_t argcount, + PyObject *kwnames); + +extern int _PyEval_ThreadsInitialized(void); +extern void _PyEval_InitGIL(PyThreadState *tstate, int own_gil); +extern void _PyEval_FiniGIL(PyInterpreterState *interp); + +extern void _PyEval_AcquireLock(PyThreadState *tstate); + +extern void _PyEval_ReleaseLock(PyInterpreterState *, PyThreadState *, + int final_release); + +#ifdef Py_GIL_DISABLED +// Returns 0 or 1 if the GIL for the given thread's interpreter is disabled or +// enabled, respectively. +// +// The enabled state of the GIL will not change while one or more threads are +// attached. +static inline int +_PyEval_IsGILEnabled(PyThreadState *tstate) +{ + struct _gil_runtime_state *gil = tstate->interp->ceval.gil; + return _Py_atomic_load_int_relaxed(&gil->enabled) != 0; +} + +// Enable or disable the GIL used by the interpreter that owns tstate, which +// must be the current thread. This may affect other interpreters, if the GIL +// is shared. All three functions will be no-ops (and return 0) if the +// interpreter's `enable_gil' config is not _PyConfig_GIL_DEFAULT. +// +// Every call to _PyEval_EnableGILTransient() must be paired with exactly one +// call to either _PyEval_EnableGILPermanent() or +// _PyEval_DisableGIL(). _PyEval_EnableGILPermanent() and _PyEval_DisableGIL() +// must only be called while the GIL is enabled from a call to +// _PyEval_EnableGILTransient(). +// +// _PyEval_EnableGILTransient() returns 1 if it enabled the GIL, or 0 if the +// GIL was already enabled, whether transiently or permanently. The caller will +// hold the GIL upon return. +// +// _PyEval_EnableGILPermanent() returns 1 if it permanently enabled the GIL +// (which must already be enabled), or 0 if it was already permanently +// enabled. Once _PyEval_EnableGILPermanent() has been called once, all +// subsequent calls to any of the three functions will be no-ops. +// +// _PyEval_DisableGIL() returns 1 if it disabled the GIL, or 0 if the GIL was +// kept enabled because of another request, whether transient or permanent. +// +// All three functions must be called by an attached thread (this implies that +// if the GIL is enabled, the current thread must hold it). +extern int _PyEval_EnableGILTransient(PyThreadState *tstate); +extern int _PyEval_EnableGILPermanent(PyThreadState *tstate); +extern int _PyEval_DisableGIL(PyThreadState *state); +#endif + +extern void _PyEval_DeactivateOpCache(void); + + +/* --- _Py_EnterRecursiveCall() ----------------------------------------- */ + +#ifdef USE_STACKCHECK +/* With USE_STACKCHECK macro defined, trigger stack checks in + _Py_CheckRecursiveCall() on every 64th call to _Py_EnterRecursiveCall. */ +static inline int _Py_MakeRecCheck(PyThreadState *tstate) { + return (tstate->c_recursion_remaining-- < 0 + || (tstate->c_recursion_remaining & 63) == 0); +} +#else +static inline int _Py_MakeRecCheck(PyThreadState *tstate) { + return tstate->c_recursion_remaining-- < 0; +} +#endif + +// Export for '_json' shared extension, used via _Py_EnterRecursiveCall() +// static inline function. +PyAPI_FUNC(int) _Py_CheckRecursiveCall( + PyThreadState *tstate, + const char *where); + +int _Py_CheckRecursiveCallPy( + PyThreadState *tstate); + +static inline int _Py_EnterRecursiveCallTstate(PyThreadState *tstate, + const char *where) { + return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)); +} + +static inline void _Py_EnterRecursiveCallTstateUnchecked(PyThreadState *tstate) { + assert(tstate->c_recursion_remaining > 0); + tstate->c_recursion_remaining--; +} + +static inline int _Py_EnterRecursiveCall(const char *where) { + PyThreadState *tstate = _PyThreadState_GET(); + return _Py_EnterRecursiveCallTstate(tstate, where); +} + +static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { + tstate->c_recursion_remaining++; +} + +static inline void _Py_LeaveRecursiveCall(void) { + PyThreadState *tstate = _PyThreadState_GET(); + _Py_LeaveRecursiveCallTstate(tstate); +} + +extern struct _PyInterpreterFrame* _PyEval_GetFrame(void); + +PyAPI_FUNC(PyObject *)_Py_MakeCoro(PyFunctionObject *func); + +/* Handle signals, pending calls, GIL drop request + and asynchronous exception */ +PyAPI_FUNC(int) _Py_HandlePending(PyThreadState *tstate); + +extern PyObject * _PyEval_GetFrameLocals(void); + +typedef PyObject *(*conversion_func)(PyObject *); + +PyAPI_DATA(const binaryfunc) _PyEval_BinaryOps[]; +PyAPI_DATA(const conversion_func) _PyEval_ConversionFuncs[]; + +PyAPI_FUNC(int) _PyEval_CheckExceptStarTypeValid(PyThreadState *tstate, PyObject* right); +PyAPI_FUNC(int) _PyEval_CheckExceptTypeValid(PyThreadState *tstate, PyObject* right); +PyAPI_FUNC(int) _PyEval_ExceptionGroupMatch(PyObject* exc_value, PyObject *match_type, PyObject **match, PyObject **rest); +PyAPI_FUNC(void) _PyEval_FormatAwaitableError(PyThreadState *tstate, PyTypeObject *type, int oparg); +PyAPI_FUNC(void) _PyEval_FormatExcCheckArg(PyThreadState *tstate, PyObject *exc, const char *format_str, PyObject *obj); +PyAPI_FUNC(void) _PyEval_FormatExcUnbound(PyThreadState *tstate, PyCodeObject *co, int oparg); +PyAPI_FUNC(void) _PyEval_FormatKwargsError(PyThreadState *tstate, PyObject *func, PyObject *kwargs); +PyAPI_FUNC(PyObject *)_PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type, Py_ssize_t nargs, PyObject *kwargs); +PyAPI_FUNC(PyObject *)_PyEval_MatchKeys(PyThreadState *tstate, PyObject *map, PyObject *keys); +PyAPI_FUNC(int) _PyEval_UnpackIterable(PyThreadState *tstate, PyObject *v, int argcnt, int argcntafter, PyObject **sp); +PyAPI_FUNC(void) _PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr); +PyAPI_FUNC(void) _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame *frame); + + +/* Bits that can be set in PyThreadState.eval_breaker */ +#define _PY_GIL_DROP_REQUEST_BIT (1U << 0) +#define _PY_SIGNALS_PENDING_BIT (1U << 1) +#define _PY_CALLS_TO_DO_BIT (1U << 2) +#define _PY_ASYNC_EXCEPTION_BIT (1U << 3) +#define _PY_GC_SCHEDULED_BIT (1U << 4) +#define _PY_EVAL_PLEASE_STOP_BIT (1U << 5) +#define _PY_EVAL_EXPLICIT_MERGE_BIT (1U << 6) + +/* Reserve a few bits for future use */ +#define _PY_EVAL_EVENTS_BITS 8 +#define _PY_EVAL_EVENTS_MASK ((1 << _PY_EVAL_EVENTS_BITS)-1) + +static inline void +_Py_set_eval_breaker_bit(PyThreadState *tstate, uintptr_t bit) +{ + _Py_atomic_or_uintptr(&tstate->eval_breaker, bit); +} + +static inline void +_Py_unset_eval_breaker_bit(PyThreadState *tstate, uintptr_t bit) +{ + _Py_atomic_and_uintptr(&tstate->eval_breaker, ~bit); +} + +static inline int +_Py_eval_breaker_bit_is_set(PyThreadState *tstate, uintptr_t bit) +{ + uintptr_t b = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker); + return (b & bit) != 0; +} + +// Free-threaded builds use these functions to set or unset a bit on all +// threads in the given interpreter. +void _Py_set_eval_breaker_bit_all(PyInterpreterState *interp, uintptr_t bit); +void _Py_unset_eval_breaker_bit_all(PyInterpreterState *interp, uintptr_t bit); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CEVAL_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_ceval_state.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_ceval_state.h new file mode 100644 index 00000000..009a1ea4 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_ceval_state.h @@ -0,0 +1,134 @@ +#ifndef Py_INTERNAL_CEVAL_STATE_H +#define Py_INTERNAL_CEVAL_STATE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_lock.h" // PyMutex +#include "pycore_gil.h" // struct _gil_runtime_state + + +typedef int (*_Py_pending_call_func)(void *); + +struct _pending_call { + _Py_pending_call_func func; + void *arg; + int flags; +}; + +#define PENDINGCALLSARRAYSIZE 300 + +#define MAXPENDINGCALLS PENDINGCALLSARRAYSIZE +/* For interpreter-level pending calls, we want to avoid spending too + much time on pending calls in any one thread, so we apply a limit. */ +#if MAXPENDINGCALLS > 100 +# define MAXPENDINGCALLSLOOP 100 +#else +# define MAXPENDINGCALLSLOOP MAXPENDINGCALLS +#endif + +/* We keep the number small to preserve as much compatibility + as possible with earlier versions. */ +#define MAXPENDINGCALLS_MAIN 32 +/* For the main thread, we want to make sure all pending calls are + run at once, for the sake of prompt signal handling. This is + unlikely to cause any problems since there should be very few + pending calls for the main thread. */ +#define MAXPENDINGCALLSLOOP_MAIN 0 + +struct _pending_calls { + PyThreadState *handling_thread; + PyMutex mutex; + /* Request for running pending calls. */ + int32_t npending; + /* The maximum allowed number of pending calls. + If the queue fills up to this point then _PyEval_AddPendingCall() + will return _Py_ADD_PENDING_FULL. */ + int32_t max; + /* We don't want a flood of pending calls to interrupt any one thread + for too long, so we keep a limit on the number handled per pass. + A value of 0 means there is no limit (other than the maximum + size of the list of pending calls). */ + int32_t maxloop; + struct _pending_call calls[PENDINGCALLSARRAYSIZE]; + int first; + int next; +}; + + +typedef enum { + PERF_STATUS_FAILED = -1, // Perf trampoline is in an invalid state + PERF_STATUS_NO_INIT = 0, // Perf trampoline is not initialized + PERF_STATUS_OK = 1, // Perf trampoline is ready to be executed +} perf_status_t; + +#ifdef PY_HAVE_PERF_TRAMPOLINE +struct code_arena_st; + +struct trampoline_api_st { + void* (*init_state)(void); + void (*write_state)(void* state, const void *code_addr, + unsigned int code_size, PyCodeObject* code); + int (*free_state)(void* state); + void *state; + Py_ssize_t code_padding; +}; +#endif + + +struct _ceval_runtime_state { + struct { +#ifdef PY_HAVE_PERF_TRAMPOLINE + perf_status_t status; + int perf_trampoline_type; + Py_ssize_t extra_code_index; + struct code_arena_st *code_arena; + struct trampoline_api_st trampoline_api; + FILE *map_file; + Py_ssize_t persist_after_fork; +#else + int _not_used; +#endif + } perf; + /* Pending calls to be made only on the main thread. */ + // The signal machinery falls back on this + // so it must be especially stable and efficient. + // For example, we use a preallocated array + // for the list of pending calls. + struct _pending_calls pending_mainthread; + PyMutex sys_trace_profile_mutex; +}; + + +#ifdef PY_HAVE_PERF_TRAMPOLINE +# define _PyEval_RUNTIME_PERF_INIT \ + { \ + .status = PERF_STATUS_NO_INIT, \ + .extra_code_index = -1, \ + .persist_after_fork = 0, \ + } +#else +# define _PyEval_RUNTIME_PERF_INIT {0} +#endif + + +struct _ceval_state { + /* This variable holds the global instrumentation version. When a thread is + running, this value is overlaid onto PyThreadState.eval_breaker so that + changes in the instrumentation version will trigger the eval breaker. */ + uintptr_t instrumentation_version; + int recursion_limit; + struct _gil_runtime_state *gil; + int own_gil; + struct _pending_calls pending; +}; + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CEVAL_STATE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_code.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_code.h new file mode 100644 index 00000000..1fb8cc47 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_code.h @@ -0,0 +1,596 @@ +#ifndef Py_INTERNAL_CODE_H +#define Py_INTERNAL_CODE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_lock.h" // PyMutex +#include "pycore_backoff.h" // _Py_BackoffCounter + + +/* Each instruction in a code object is a fixed-width value, + * currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG + * opcode allows for larger values but the current limit is 3 uses + * of EXTENDED_ARG (see Python/compile.c), for a maximum + * 32-bit value. This aligns with the note in Python/compile.c + * (compiler_addop_i_line) indicating that the max oparg value is + * 2**32 - 1, rather than INT_MAX. + */ + +typedef union { + uint16_t cache; + struct { + uint8_t code; + uint8_t arg; + } op; + _Py_BackoffCounter counter; // First cache entry of specializable op +} _Py_CODEUNIT; + +#define _PyCode_CODE(CO) _Py_RVALUE((_Py_CODEUNIT *)(CO)->co_code_adaptive) +#define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT)) + + +/* These macros only remain defined for compatibility. */ +#define _Py_OPCODE(word) ((word).op.code) +#define _Py_OPARG(word) ((word).op.arg) + +static inline _Py_CODEUNIT +_py_make_codeunit(uint8_t opcode, uint8_t oparg) +{ + // No designated initialisers because of C++ compat + _Py_CODEUNIT word; + word.op.code = opcode; + word.op.arg = oparg; + return word; +} + +static inline void +_py_set_opcode(_Py_CODEUNIT *word, uint8_t opcode) +{ + word->op.code = opcode; +} + +#define _Py_MAKE_CODEUNIT(opcode, oparg) _py_make_codeunit((opcode), (oparg)) +#define _Py_SET_OPCODE(word, opcode) _py_set_opcode(&(word), (opcode)) + + +// We hide some of the newer PyCodeObject fields behind macros. +// This helps with backporting certain changes to 3.12. +#define _PyCode_HAS_EXECUTORS(CODE) \ + (CODE->co_executors != NULL) +#define _PyCode_HAS_INSTRUMENTATION(CODE) \ + (CODE->_co_instrumentation_version > 0) + +struct _py_code_state { + PyMutex mutex; + // Interned constants from code objects. Used by the free-threaded build. + struct _Py_hashtable_t *constants; +}; + +extern PyStatus _PyCode_Init(PyInterpreterState *interp); +extern void _PyCode_Fini(PyInterpreterState *interp); + +#define CODE_MAX_WATCHERS 8 + +/* PEP 659 + * Specialization and quickening structs and helper functions + */ + + +// Inline caches. If you change the number of cache entries for an instruction, +// you must *also* update the number of cache entries in Lib/opcode.py and bump +// the magic number in Lib/importlib/_bootstrap_external.py! + +#define CACHE_ENTRIES(cache) (sizeof(cache)/sizeof(_Py_CODEUNIT)) + +typedef struct { + _Py_BackoffCounter counter; + uint16_t module_keys_version; + uint16_t builtin_keys_version; + uint16_t index; +} _PyLoadGlobalCache; + +#define INLINE_CACHE_ENTRIES_LOAD_GLOBAL CACHE_ENTRIES(_PyLoadGlobalCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PyBinaryOpCache; + +#define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PyUnpackSequenceCache; + +#define INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE \ + CACHE_ENTRIES(_PyUnpackSequenceCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PyCompareOpCache; + +#define INLINE_CACHE_ENTRIES_COMPARE_OP CACHE_ENTRIES(_PyCompareOpCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PyBinarySubscrCache; + +#define INLINE_CACHE_ENTRIES_BINARY_SUBSCR CACHE_ENTRIES(_PyBinarySubscrCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PySuperAttrCache; + +#define INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR CACHE_ENTRIES(_PySuperAttrCache) + +typedef struct { + _Py_BackoffCounter counter; + uint16_t version[2]; + uint16_t index; +} _PyAttrCache; + +typedef struct { + _Py_BackoffCounter counter; + uint16_t type_version[2]; + union { + uint16_t keys_version[2]; + uint16_t dict_offset; + }; + uint16_t descr[4]; +} _PyLoadMethodCache; + + +// MUST be the max(_PyAttrCache, _PyLoadMethodCache) +#define INLINE_CACHE_ENTRIES_LOAD_ATTR CACHE_ENTRIES(_PyLoadMethodCache) + +#define INLINE_CACHE_ENTRIES_STORE_ATTR CACHE_ENTRIES(_PyAttrCache) + +typedef struct { + _Py_BackoffCounter counter; + uint16_t func_version[2]; +} _PyCallCache; + +#define INLINE_CACHE_ENTRIES_CALL CACHE_ENTRIES(_PyCallCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PyStoreSubscrCache; + +#define INLINE_CACHE_ENTRIES_STORE_SUBSCR CACHE_ENTRIES(_PyStoreSubscrCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PyForIterCache; + +#define INLINE_CACHE_ENTRIES_FOR_ITER CACHE_ENTRIES(_PyForIterCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PySendCache; + +#define INLINE_CACHE_ENTRIES_SEND CACHE_ENTRIES(_PySendCache) + +typedef struct { + _Py_BackoffCounter counter; + uint16_t version[2]; +} _PyToBoolCache; + +#define INLINE_CACHE_ENTRIES_TO_BOOL CACHE_ENTRIES(_PyToBoolCache) + +typedef struct { + _Py_BackoffCounter counter; +} _PyContainsOpCache; + +#define INLINE_CACHE_ENTRIES_CONTAINS_OP CACHE_ENTRIES(_PyContainsOpCache) + +// Borrowed references to common callables: +struct callable_cache { + PyObject *isinstance; + PyObject *len; + PyObject *list_append; + PyObject *object__getattribute__; +}; + +/* "Locals plus" for a code object is the set of locals + cell vars + + * free vars. This relates to variable names as well as offsets into + * the "fast locals" storage array of execution frames. The compiler + * builds the list of names, their offsets, and the corresponding + * kind of local. + * + * Those kinds represent the source of the initial value and the + * variable's scope (as related to closures). A "local" is an + * argument or other variable defined in the current scope. A "free" + * variable is one that is defined in an outer scope and comes from + * the function's closure. A "cell" variable is a local that escapes + * into an inner function as part of a closure, and thus must be + * wrapped in a cell. Any "local" can also be a "cell", but the + * "free" kind is mutually exclusive with both. + */ + +// Note that these all fit within a byte, as do combinations. +// Later, we will use the smaller numbers to differentiate the different +// kinds of locals (e.g. pos-only arg, varkwargs, local-only). +#define CO_FAST_HIDDEN 0x10 +#define CO_FAST_LOCAL 0x20 +#define CO_FAST_CELL 0x40 +#define CO_FAST_FREE 0x80 + +typedef unsigned char _PyLocals_Kind; + +static inline _PyLocals_Kind +_PyLocals_GetKind(PyObject *kinds, int i) +{ + assert(PyBytes_Check(kinds)); + assert(0 <= i && i < PyBytes_GET_SIZE(kinds)); + char *ptr = PyBytes_AS_STRING(kinds); + return (_PyLocals_Kind)(ptr[i]); +} + +static inline void +_PyLocals_SetKind(PyObject *kinds, int i, _PyLocals_Kind kind) +{ + assert(PyBytes_Check(kinds)); + assert(0 <= i && i < PyBytes_GET_SIZE(kinds)); + char *ptr = PyBytes_AS_STRING(kinds); + ptr[i] = (char) kind; +} + + +struct _PyCodeConstructor { + /* metadata */ + PyObject *filename; + PyObject *name; + PyObject *qualname; + int flags; + + /* the code */ + PyObject *code; + int firstlineno; + PyObject *linetable; + + /* used by the code */ + PyObject *consts; + PyObject *names; + + /* mapping frame offsets to information */ + PyObject *localsplusnames; // Tuple of strings + PyObject *localspluskinds; // Bytes object, one byte per variable + + /* args (within varnames) */ + int argcount; + int posonlyargcount; + // XXX Replace argcount with posorkwargcount (argcount - posonlyargcount). + int kwonlyargcount; + + /* needed to create the frame */ + int stacksize; + + /* used by the eval loop */ + PyObject *exceptiontable; +}; + +// Using an "arguments struct" like this is helpful for maintainability +// in a case such as this with many parameters. It does bear a risk: +// if the struct changes and callers are not updated properly then the +// compiler will not catch problems (like a missing argument). This can +// cause hard-to-debug problems. The risk is mitigated by the use of +// check_code() in codeobject.c. However, we may decide to switch +// back to a regular function signature. Regardless, this approach +// wouldn't be appropriate if this weren't a strictly internal API. +// (See the comments in https://github.com/python/cpython/pull/26258.) +extern int _PyCode_Validate(struct _PyCodeConstructor *); +extern PyCodeObject* _PyCode_New(struct _PyCodeConstructor *); + + +/* Private API */ + +/* Getters for internal PyCodeObject data. */ +extern PyObject* _PyCode_GetVarnames(PyCodeObject *); +extern PyObject* _PyCode_GetCellvars(PyCodeObject *); +extern PyObject* _PyCode_GetFreevars(PyCodeObject *); +extern PyObject* _PyCode_GetCode(PyCodeObject *); + +/** API for initializing the line number tables. */ +extern int _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds); + +/** Out of process API for initializing the location table. */ +extern void _PyLineTable_InitAddressRange( + const char *linetable, + Py_ssize_t length, + int firstlineno, + PyCodeAddressRange *range); + +/** API for traversing the line number table. */ +extern int _PyLineTable_NextAddressRange(PyCodeAddressRange *range); +extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range); + +/** API for executors */ +extern void _PyCode_Clear_Executors(PyCodeObject *code); + +#ifdef Py_GIL_DISABLED +// gh-115999 tracks progress on addressing this. +#define ENABLE_SPECIALIZATION 0 +#else +#define ENABLE_SPECIALIZATION 1 +#endif + +/* Specialization functions */ + +extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *cls, + _Py_CODEUNIT *instr, int load_method); +extern void _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, + PyObject *name); +extern void _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, + PyObject *name); +extern void _Py_Specialize_LoadGlobal(PyObject *globals, PyObject *builtins, + _Py_CODEUNIT *instr, PyObject *name); +extern void _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, + _Py_CODEUNIT *instr); +extern void _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, + _Py_CODEUNIT *instr); +extern void _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, + int nargs); +extern void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, + int oparg, PyObject **locals); +extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, + _Py_CODEUNIT *instr, int oparg); +extern void _Py_Specialize_UnpackSequence(PyObject *seq, _Py_CODEUNIT *instr, + int oparg); +extern void _Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr, int oparg); +extern void _Py_Specialize_Send(PyObject *receiver, _Py_CODEUNIT *instr); +extern void _Py_Specialize_ToBool(PyObject *value, _Py_CODEUNIT *instr); +extern void _Py_Specialize_ContainsOp(PyObject *value, _Py_CODEUNIT *instr); + +#ifdef Py_STATS + +#include "pycore_bitutils.h" // _Py_bit_length + +#define STAT_INC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name++; } while (0) +#define STAT_DEC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name--; } while (0) +#define OPCODE_EXE_INC(opname) do { if (_Py_stats) _Py_stats->opcode_stats[opname].execution_count++; } while (0) +#define CALL_STAT_INC(name) do { if (_Py_stats) _Py_stats->call_stats.name++; } while (0) +#define OBJECT_STAT_INC(name) do { if (_Py_stats) _Py_stats->object_stats.name++; } while (0) +#define OBJECT_STAT_INC_COND(name, cond) \ + do { if (_Py_stats && cond) _Py_stats->object_stats.name++; } while (0) +#define EVAL_CALL_STAT_INC(name) do { if (_Py_stats) _Py_stats->call_stats.eval_calls[name]++; } while (0) +#define EVAL_CALL_STAT_INC_IF_FUNCTION(name, callable) \ + do { if (_Py_stats && PyFunction_Check(callable)) _Py_stats->call_stats.eval_calls[name]++; } while (0) +#define GC_STAT_ADD(gen, name, n) do { if (_Py_stats) _Py_stats->gc_stats[(gen)].name += (n); } while (0) +#define OPT_STAT_INC(name) do { if (_Py_stats) _Py_stats->optimization_stats.name++; } while (0) +#define UOP_STAT_INC(opname, name) do { if (_Py_stats) { assert(opname < 512); _Py_stats->optimization_stats.opcode[opname].name++; } } while (0) +#define UOP_PAIR_INC(uopcode, lastuop) \ + do { \ + if (lastuop && _Py_stats) { \ + _Py_stats->optimization_stats.opcode[lastuop].pair_count[uopcode]++; \ + } \ + lastuop = uopcode; \ + } while (0) +#define OPT_UNSUPPORTED_OPCODE(opname) do { if (_Py_stats) _Py_stats->optimization_stats.unsupported_opcode[opname]++; } while (0) +#define OPT_ERROR_IN_OPCODE(opname) do { if (_Py_stats) _Py_stats->optimization_stats.error_in_opcode[opname]++; } while (0) +#define OPT_HIST(length, name) \ + do { \ + if (_Py_stats) { \ + int bucket = _Py_bit_length(length >= 1 ? length - 1 : 0); \ + bucket = (bucket >= _Py_UOP_HIST_SIZE) ? _Py_UOP_HIST_SIZE - 1 : bucket; \ + _Py_stats->optimization_stats.name[bucket]++; \ + } \ + } while (0) +#define RARE_EVENT_STAT_INC(name) do { if (_Py_stats) _Py_stats->rare_event_stats.name++; } while (0) + +// Export for '_opcode' shared extension +PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void); + +#else +#define STAT_INC(opname, name) ((void)0) +#define STAT_DEC(opname, name) ((void)0) +#define OPCODE_EXE_INC(opname) ((void)0) +#define CALL_STAT_INC(name) ((void)0) +#define OBJECT_STAT_INC(name) ((void)0) +#define OBJECT_STAT_INC_COND(name, cond) ((void)0) +#define EVAL_CALL_STAT_INC(name) ((void)0) +#define EVAL_CALL_STAT_INC_IF_FUNCTION(name, callable) ((void)0) +#define GC_STAT_ADD(gen, name, n) ((void)0) +#define OPT_STAT_INC(name) ((void)0) +#define UOP_STAT_INC(opname, name) ((void)0) +#define UOP_PAIR_INC(uopcode, lastuop) ((void)0) +#define OPT_UNSUPPORTED_OPCODE(opname) ((void)0) +#define OPT_ERROR_IN_OPCODE(opname) ((void)0) +#define OPT_HIST(length, name) ((void)0) +#define RARE_EVENT_STAT_INC(name) ((void)0) +#endif // !Py_STATS + +// Utility functions for reading/writing 32/64-bit values in the inline caches. +// Great care should be taken to ensure that these functions remain correct and +// performant! They should compile to just "move" instructions on all supported +// compilers and platforms. + +// We use memcpy to let the C compiler handle unaligned accesses and endianness +// issues for us. It also seems to produce better code than manual copying for +// most compilers (see https://blog.regehr.org/archives/959 for more info). + +static inline void +write_u32(uint16_t *p, uint32_t val) +{ + memcpy(p, &val, sizeof(val)); +} + +static inline void +write_u64(uint16_t *p, uint64_t val) +{ + memcpy(p, &val, sizeof(val)); +} + +static inline void +write_obj(uint16_t *p, PyObject *val) +{ + memcpy(p, &val, sizeof(val)); +} + +static inline uint16_t +read_u16(uint16_t *p) +{ + return *p; +} + +static inline uint32_t +read_u32(uint16_t *p) +{ + uint32_t val; + memcpy(&val, p, sizeof(val)); + return val; +} + +static inline uint64_t +read_u64(uint16_t *p) +{ + uint64_t val; + memcpy(&val, p, sizeof(val)); + return val; +} + +static inline PyObject * +read_obj(uint16_t *p) +{ + PyObject *val; + memcpy(&val, p, sizeof(val)); + return val; +} + +/* See Objects/exception_handling_notes.txt for details. + */ +static inline unsigned char * +parse_varint(unsigned char *p, int *result) { + int val = p[0] & 63; + while (p[0] & 64) { + p++; + val = (val << 6) | (p[0] & 63); + } + *result = val; + return p+1; +} + +static inline int +write_varint(uint8_t *ptr, unsigned int val) +{ + int written = 1; + while (val >= 64) { + *ptr++ = 64 | (val & 63); + val >>= 6; + written++; + } + *ptr = (uint8_t)val; + return written; +} + +static inline int +write_signed_varint(uint8_t *ptr, int val) +{ + unsigned int uval; + if (val < 0) { + // (unsigned int)(-val) has an undefined behavior for INT_MIN + uval = ((0 - (unsigned int)val) << 1) | 1; + } + else { + uval = (unsigned int)val << 1; + } + return write_varint(ptr, uval); +} + +static inline int +write_location_entry_start(uint8_t *ptr, int code, int length) +{ + assert((code & 15) == code); + *ptr = 128 | (uint8_t)(code << 3) | (uint8_t)(length - 1); + return 1; +} + + +/** Counters + * The first 16-bit value in each inline cache is a counter. + * + * When counting executions until the next specialization attempt, + * exponential backoff is used to reduce the number of specialization failures. + * See pycore_backoff.h for more details. + * On a specialization failure, the backoff counter is restarted. + */ + +#include "pycore_backoff.h" + +// A value of 1 means that we attempt to specialize the *second* time each +// instruction is executed. Executing twice is a much better indicator of +// "hotness" than executing once, but additional warmup delays only prevent +// specialization. Most types stabilize by the second execution, too: +#define ADAPTIVE_WARMUP_VALUE 1 +#define ADAPTIVE_WARMUP_BACKOFF 1 + +// A value of 52 means that we attempt to re-specialize after 53 misses (a prime +// number, useful for avoiding artifacts if every nth value is a different type +// or something). Setting the backoff to 0 means that the counter is reset to +// the same state as a warming-up instruction (value == 1, backoff == 1) after +// deoptimization. This isn't strictly necessary, but it is bit easier to reason +// about when thinking about the opcode transitions as a state machine: +#define ADAPTIVE_COOLDOWN_VALUE 52 +#define ADAPTIVE_COOLDOWN_BACKOFF 0 + +// Can't assert this in pycore_backoff.h because of header order dependencies +#if COLD_EXIT_INITIAL_VALUE <= ADAPTIVE_COOLDOWN_VALUE +# error "Cold exit value should be larger than adaptive cooldown value" +#endif + +static inline _Py_BackoffCounter +adaptive_counter_bits(uint16_t value, uint16_t backoff) { + return make_backoff_counter(value, backoff); +} + +static inline _Py_BackoffCounter +adaptive_counter_warmup(void) { + return adaptive_counter_bits(ADAPTIVE_WARMUP_VALUE, + ADAPTIVE_WARMUP_BACKOFF); +} + +static inline _Py_BackoffCounter +adaptive_counter_cooldown(void) { + return adaptive_counter_bits(ADAPTIVE_COOLDOWN_VALUE, + ADAPTIVE_COOLDOWN_BACKOFF); +} + +static inline _Py_BackoffCounter +adaptive_counter_backoff(_Py_BackoffCounter counter) { + return restart_backoff_counter(counter); +} + + +/* Comparison bit masks. */ + +/* Note this evaluates its arguments twice each */ +#define COMPARISON_BIT(x, y) (1 << (2 * ((x) >= (y)) + ((x) <= (y)))) + +/* + * The following bits are chosen so that the value of + * COMPARSION_BIT(left, right) + * masked by the values below will be non-zero if the + * comparison is true, and zero if it is false */ + +/* This is for values that are unordered, ie. NaN, not types that are unordered, e.g. sets */ +#define COMPARISON_UNORDERED 1 + +#define COMPARISON_LESS_THAN 2 +#define COMPARISON_GREATER_THAN 4 +#define COMPARISON_EQUALS 8 + +#define COMPARISON_NOT_EQUALS (COMPARISON_UNORDERED | COMPARISON_LESS_THAN | COMPARISON_GREATER_THAN) + +extern int _Py_Instrument(PyCodeObject *co, PyInterpreterState *interp); + +extern int _Py_GetBaseOpcode(PyCodeObject *code, int offset); + +extern int _PyInstruction_GetLength(PyCodeObject *code, int offset); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CODE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_codecs.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_codecs.h new file mode 100644 index 00000000..5e2d5c5c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_codecs.h @@ -0,0 +1,86 @@ +#ifndef Py_INTERNAL_CODECS_H +#define Py_INTERNAL_CODECS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_lock.h" // PyMutex + +/* Initialize codecs-related state for the given interpreter, including + registering the first codec search function. Must be called before any other + PyCodec-related functions, and while only one thread is active. */ +extern PyStatus _PyCodec_InitRegistry(PyInterpreterState *interp); + +/* Finalize codecs-related state for the given interpreter. No PyCodec-related + functions other than PyCodec_Unregister() may be called after this. */ +extern void _PyCodec_Fini(PyInterpreterState *interp); + +extern PyObject* _PyCodec_Lookup(const char *encoding); + +/* Text codec specific encoding and decoding API. + + Checks the encoding against a list of codecs which do not + implement a str<->bytes encoding before attempting the + operation. + + Please note that these APIs are internal and should not + be used in Python C extensions. + + XXX (ncoghlan): should we make these, or something like them, public + in Python 3.5+? + + */ +extern PyObject* _PyCodec_LookupTextEncoding( + const char *encoding, + const char *alternate_command); + +extern PyObject* _PyCodec_EncodeText( + PyObject *object, + const char *encoding, + const char *errors); + +extern PyObject* _PyCodec_DecodeText( + PyObject *object, + const char *encoding, + const char *errors); + +/* These two aren't actually text encoding specific, but _io.TextIOWrapper + * is the only current API consumer. + */ +extern PyObject* _PyCodecInfo_GetIncrementalDecoder( + PyObject *codec_info, + const char *errors); + +extern PyObject* _PyCodecInfo_GetIncrementalEncoder( + PyObject *codec_info, + const char *errors); + +// Per-interpreter state used by codecs.c. +struct codecs_state { + // A list of callable objects used to search for codecs. + PyObject *search_path; + + // A dict mapping codec names to codecs returned from a callable in + // search_path. + PyObject *search_cache; + + // A dict mapping error handling strategies to functions to implement them. + PyObject *error_registry; + +#ifdef Py_GIL_DISABLED + // Used to safely delete a specific item from search_path. + PyMutex search_path_mutex; +#endif + + // Whether or not the rest of the state is initialized. + int initialized; +}; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CODECS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_compile.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_compile.h new file mode 100644 index 00000000..3c21f83a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_compile.h @@ -0,0 +1,118 @@ +#ifndef Py_INTERNAL_COMPILE_H +#define Py_INTERNAL_COMPILE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_symtable.h" // _Py_SourceLocation +#include "pycore_instruction_sequence.h" + +struct _arena; // Type defined in pycore_pyarena.h +struct _mod; // Type defined in pycore_ast.h + +// Export for 'test_peg_generator' shared extension +PyAPI_FUNC(PyCodeObject*) _PyAST_Compile( + struct _mod *mod, + PyObject *filename, + PyCompilerFlags *flags, + int optimize, + struct _arena *arena); + +/* AST optimizations */ +extern int _PyCompile_AstOptimize( + struct _mod *mod, + PyObject *filename, + PyCompilerFlags *flags, + int optimize, + struct _arena *arena); + +struct _Py_SourceLocation; + +extern int _PyAST_Optimize( + struct _mod *, + struct _arena *arena, + int optimize, + int ff_features); + + +typedef struct { + PyObject *u_name; + PyObject *u_qualname; /* dot-separated qualified name (lazy) */ + + /* The following fields are dicts that map objects to + the index of them in co_XXX. The index is used as + the argument for opcodes that refer to those collections. + */ + PyObject *u_consts; /* all constants */ + PyObject *u_names; /* all names */ + PyObject *u_varnames; /* local variables */ + PyObject *u_cellvars; /* cell variables */ + PyObject *u_freevars; /* free variables */ + PyObject *u_fasthidden; /* dict; keys are names that are fast-locals only + temporarily within an inlined comprehension. When + value is True, treat as fast-local. */ + + Py_ssize_t u_argcount; /* number of arguments for block */ + Py_ssize_t u_posonlyargcount; /* number of positional only arguments for block */ + Py_ssize_t u_kwonlyargcount; /* number of keyword only arguments for block */ + + int u_firstlineno; /* the first lineno of the block */ +} _PyCompile_CodeUnitMetadata; + + +/* Utility for a number of growing arrays used in the compiler */ +int _PyCompile_EnsureArrayLargeEnough( + int idx, + void **array, + int *alloc, + int default_alloc, + size_t item_size); + +int _PyCompile_ConstCacheMergeOne(PyObject *const_cache, PyObject **obj); + + +// Export for '_opcode' extension module +PyAPI_FUNC(int) _PyCompile_OpcodeIsValid(int opcode); +PyAPI_FUNC(int) _PyCompile_OpcodeHasArg(int opcode); +PyAPI_FUNC(int) _PyCompile_OpcodeHasConst(int opcode); +PyAPI_FUNC(int) _PyCompile_OpcodeHasName(int opcode); +PyAPI_FUNC(int) _PyCompile_OpcodeHasJump(int opcode); +PyAPI_FUNC(int) _PyCompile_OpcodeHasFree(int opcode); +PyAPI_FUNC(int) _PyCompile_OpcodeHasLocal(int opcode); +PyAPI_FUNC(int) _PyCompile_OpcodeHasExc(int opcode); + +PyAPI_FUNC(PyObject*) _PyCompile_GetUnaryIntrinsicName(int index); +PyAPI_FUNC(PyObject*) _PyCompile_GetBinaryIntrinsicName(int index); + +/* Access compiler internals for unit testing */ + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(PyObject*) _PyCompile_CleanDoc(PyObject *doc); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(PyObject*) _PyCompile_CodeGen( + PyObject *ast, + PyObject *filename, + PyCompilerFlags *flags, + int optimize, + int compile_mode); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(PyObject*) _PyCompile_OptimizeCfg( + PyObject *instructions, + PyObject *consts, + int nlocals); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(PyCodeObject*) +_PyCompile_Assemble(_PyCompile_CodeUnitMetadata *umd, PyObject *filename, + PyObject *instructions); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_COMPILE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_complexobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_complexobject.h new file mode 100644 index 00000000..54713536 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_complexobject.h @@ -0,0 +1,25 @@ +#ifndef Py_INTERNAL_COMPLEXOBJECT_H +#define Py_INTERNAL_COMPLEXOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_unicodeobject.h" // _PyUnicodeWriter + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +extern int _PyComplex_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_COMPLEXOBJECT_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_condvar.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_condvar.h new file mode 100644 index 00000000..55271f0a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_condvar.h @@ -0,0 +1,93 @@ +#ifndef Py_INTERNAL_CONDVAR_H +#define Py_INTERNAL_CONDVAR_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_pythread.h" // _POSIX_THREADS + + +#ifdef _POSIX_THREADS +/* + * POSIX support + */ +#define Py_HAVE_CONDVAR + +#ifdef HAVE_PTHREAD_H +# include // pthread_mutex_t +#endif + +#define PyMUTEX_T pthread_mutex_t +#define PyCOND_T pthread_cond_t + +#elif defined(NT_THREADS) +/* + * Windows (XP, 2003 server and later, as well as (hopefully) CE) support + * + * Emulated condition variables ones that work with XP and later, plus + * example native support on VISTA and onwards. + */ +#define Py_HAVE_CONDVAR + +/* include windows if it hasn't been done before */ +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include // CRITICAL_SECTION + +/* options */ +/* emulated condition variables are provided for those that want + * to target Windows XP or earlier. Modify this macro to enable them. + */ +#ifndef _PY_EMULATED_WIN_CV +#define _PY_EMULATED_WIN_CV 0 /* use non-emulated condition variables */ +#endif + +/* fall back to emulation if targeting earlier than Vista */ +#if !defined NTDDI_VISTA || NTDDI_VERSION < NTDDI_VISTA +#undef _PY_EMULATED_WIN_CV +#define _PY_EMULATED_WIN_CV 1 +#endif + +#if _PY_EMULATED_WIN_CV + +typedef CRITICAL_SECTION PyMUTEX_T; + +/* The ConditionVariable object. From XP onwards it is easily emulated + with a Semaphore. + Semaphores are available on Windows XP (2003 server) and later. + We use a Semaphore rather than an auto-reset event, because although + an auto-reset event might appear to solve the lost-wakeup bug (race + condition between releasing the outer lock and waiting) because it + maintains state even though a wait hasn't happened, there is still + a lost wakeup problem if more than one thread are interrupted in the + critical place. A semaphore solves that, because its state is + counted, not Boolean. + Because it is ok to signal a condition variable with no one + waiting, we need to keep track of the number of + waiting threads. Otherwise, the semaphore's state could rise + without bound. This also helps reduce the number of "spurious wakeups" + that would otherwise happen. + */ + +typedef struct _PyCOND_T +{ + HANDLE sem; + int waiting; /* to allow PyCOND_SIGNAL to be a no-op */ +} PyCOND_T; + +#else /* !_PY_EMULATED_WIN_CV */ + +/* Use native Windows primitives if build target is Vista or higher */ + +/* SRWLOCK is faster and better than CriticalSection */ +typedef SRWLOCK PyMUTEX_T; + +typedef CONDITION_VARIABLE PyCOND_T; + +#endif /* _PY_EMULATED_WIN_CV */ + +#endif /* _POSIX_THREADS, NT_THREADS */ + +#endif /* Py_INTERNAL_CONDVAR_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_context.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_context.h new file mode 100644 index 00000000..10c1f1e5 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_context.h @@ -0,0 +1,61 @@ +#ifndef Py_INTERNAL_CONTEXT_H +#define Py_INTERNAL_CONTEXT_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_freelist.h" // _PyFreeListState +#include "pycore_hamt.h" // PyHamtObject + + +extern PyTypeObject _PyContextTokenMissing_Type; + +/* runtime lifecycle */ + +PyStatus _PyContext_Init(PyInterpreterState *); + + +/* other API */ + +typedef struct { + PyObject_HEAD +} _PyContextTokenMissing; + +struct _pycontextobject { + PyObject_HEAD + PyContext *ctx_prev; + PyHamtObject *ctx_vars; + PyObject *ctx_weakreflist; + int ctx_entered; +}; + + +struct _pycontextvarobject { + PyObject_HEAD + PyObject *var_name; + PyObject *var_default; +#ifndef Py_GIL_DISABLED + PyObject *var_cached; + uint64_t var_cached_tsid; + uint64_t var_cached_tsver; +#endif + Py_hash_t var_hash; +}; + + +struct _pycontexttokenobject { + PyObject_HEAD + PyContext *tok_ctx; + PyContextVar *tok_var; + PyObject *tok_oldval; + int tok_used; +}; + + +// _testinternalcapi.hamt() used by tests. +// Export for '_testcapi' shared extension +PyAPI_FUNC(PyObject*) _PyContext_NewHamtForTests(void); + + +#endif /* !Py_INTERNAL_CONTEXT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_critical_section.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_critical_section.h new file mode 100644 index 00000000..78cd0d54 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_critical_section.h @@ -0,0 +1,233 @@ +#ifndef Py_INTERNAL_CRITICAL_SECTION_H +#define Py_INTERNAL_CRITICAL_SECTION_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_lock.h" // PyMutex +#include "pycore_pystate.h" // _PyThreadState_GET() +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Tagged pointers to critical sections use the two least significant bits to +// mark if the pointed-to critical section is inactive and whether it is a +// PyCriticalSection2 object. +#define _Py_CRITICAL_SECTION_INACTIVE 0x1 +#define _Py_CRITICAL_SECTION_TWO_MUTEXES 0x2 +#define _Py_CRITICAL_SECTION_MASK 0x3 + +#ifdef Py_GIL_DISABLED +# define Py_BEGIN_CRITICAL_SECTION_MUT(mutex) \ + { \ + PyCriticalSection _py_cs; \ + _PyCriticalSection_BeginMutex(&_py_cs, mutex) + +# define Py_BEGIN_CRITICAL_SECTION2_MUT(m1, m2) \ + { \ + PyCriticalSection2 _py_cs2; \ + _PyCriticalSection2_BeginMutex(&_py_cs2, m1, m2) + +// Specialized version of critical section locking to safely use +// PySequence_Fast APIs without the GIL. For performance, the argument *to* +// PySequence_Fast() is provided to the macro, not the *result* of +// PySequence_Fast(), which would require an extra test to determine if the +// lock must be acquired. +# define Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST(original) \ + { \ + PyObject *_orig_seq = _PyObject_CAST(original); \ + const bool _should_lock_cs = PyList_CheckExact(_orig_seq); \ + PyCriticalSection _cs; \ + if (_should_lock_cs) { \ + _PyCriticalSection_Begin(&_cs, _orig_seq); \ + } + +# define Py_END_CRITICAL_SECTION_SEQUENCE_FAST() \ + if (_should_lock_cs) { \ + PyCriticalSection_End(&_cs); \ + } \ + } + +// Asserts that the mutex is locked. The mutex must be held by the +// top-most critical section otherwise there's the possibility +// that the mutex would be swalled out in some code paths. +#define _Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(mutex) \ + _PyCriticalSection_AssertHeld(mutex) + +// Asserts that the mutex for the given object is locked. The mutex must +// be held by the top-most critical section otherwise there's the +// possibility that the mutex would be swalled out in some code paths. +#ifdef Py_DEBUG + +# define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op) \ + if (Py_REFCNT(op) != 1) { \ + _Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(&_PyObject_CAST(op)->ob_mutex); \ + } + +#else /* Py_DEBUG */ + +# define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op) + +#endif /* Py_DEBUG */ + +#else /* !Py_GIL_DISABLED */ +// The critical section APIs are no-ops with the GIL. +# define Py_BEGIN_CRITICAL_SECTION_MUT(mut) { +# define Py_BEGIN_CRITICAL_SECTION2_MUT(m1, m2) { +# define Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST(original) { +# define Py_END_CRITICAL_SECTION_SEQUENCE_FAST() } +# define _Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(mutex) +# define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op) +#endif /* !Py_GIL_DISABLED */ + +// Resumes the top-most critical section. +PyAPI_FUNC(void) +_PyCriticalSection_Resume(PyThreadState *tstate); + +// (private) slow path for locking the mutex +PyAPI_FUNC(void) +_PyCriticalSection_BeginSlow(PyCriticalSection *c, PyMutex *m); + +PyAPI_FUNC(void) +_PyCriticalSection2_BeginSlow(PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2, + int is_m1_locked); + +PyAPI_FUNC(void) +_PyCriticalSection_SuspendAll(PyThreadState *tstate); + +#ifdef Py_GIL_DISABLED + +static inline int +_PyCriticalSection_IsActive(uintptr_t tag) +{ + return tag != 0 && (tag & _Py_CRITICAL_SECTION_INACTIVE) == 0; +} + +static inline void +_PyCriticalSection_BeginMutex(PyCriticalSection *c, PyMutex *m) +{ + if (PyMutex_LockFast(&m->_bits)) { + PyThreadState *tstate = _PyThreadState_GET(); + c->_cs_mutex = m; + c->_cs_prev = tstate->critical_section; + tstate->critical_section = (uintptr_t)c; + } + else { + _PyCriticalSection_BeginSlow(c, m); + } +} + +static inline void +_PyCriticalSection_Begin(PyCriticalSection *c, PyObject *op) +{ + _PyCriticalSection_BeginMutex(c, &op->ob_mutex); +} +#define PyCriticalSection_Begin _PyCriticalSection_Begin + +// Removes the top-most critical section from the thread's stack of critical +// sections. If the new top-most critical section is inactive, then it is +// resumed. +static inline void +_PyCriticalSection_Pop(PyCriticalSection *c) +{ + PyThreadState *tstate = _PyThreadState_GET(); + uintptr_t prev = c->_cs_prev; + tstate->critical_section = prev; + + if ((prev & _Py_CRITICAL_SECTION_INACTIVE) != 0) { + _PyCriticalSection_Resume(tstate); + } +} + +static inline void +_PyCriticalSection_End(PyCriticalSection *c) +{ + PyMutex_Unlock(c->_cs_mutex); + _PyCriticalSection_Pop(c); +} +#define PyCriticalSection_End _PyCriticalSection_End + +static inline void +_PyCriticalSection2_BeginMutex(PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2) +{ + if (m1 == m2) { + // If the two mutex arguments are the same, treat this as a critical + // section with a single mutex. + c->_cs_mutex2 = NULL; + _PyCriticalSection_BeginMutex(&c->_cs_base, m1); + return; + } + + if ((uintptr_t)m2 < (uintptr_t)m1) { + // Sort the mutexes so that the lower address is locked first. + // The exact order does not matter, but we need to acquire the mutexes + // in a consistent order to avoid lock ordering deadlocks. + PyMutex *tmp = m1; + m1 = m2; + m2 = tmp; + } + + if (PyMutex_LockFast(&m1->_bits)) { + if (PyMutex_LockFast(&m2->_bits)) { + PyThreadState *tstate = _PyThreadState_GET(); + c->_cs_base._cs_mutex = m1; + c->_cs_mutex2 = m2; + c->_cs_base._cs_prev = tstate->critical_section; + + uintptr_t p = (uintptr_t)c | _Py_CRITICAL_SECTION_TWO_MUTEXES; + tstate->critical_section = p; + } + else { + _PyCriticalSection2_BeginSlow(c, m1, m2, 1); + } + } + else { + _PyCriticalSection2_BeginSlow(c, m1, m2, 0); + } +} + +static inline void +_PyCriticalSection2_Begin(PyCriticalSection2 *c, PyObject *a, PyObject *b) +{ + _PyCriticalSection2_BeginMutex(c, &a->ob_mutex, &b->ob_mutex); +} +#define PyCriticalSection2_Begin _PyCriticalSection2_Begin + +static inline void +_PyCriticalSection2_End(PyCriticalSection2 *c) +{ + if (c->_cs_mutex2) { + PyMutex_Unlock(c->_cs_mutex2); + } + PyMutex_Unlock(c->_cs_base._cs_mutex); + _PyCriticalSection_Pop(&c->_cs_base); +} +#define PyCriticalSection2_End _PyCriticalSection2_End + +static inline void +_PyCriticalSection_AssertHeld(PyMutex *mutex) +{ +#ifdef Py_DEBUG + PyThreadState *tstate = _PyThreadState_GET(); + uintptr_t prev = tstate->critical_section; + if (prev & _Py_CRITICAL_SECTION_TWO_MUTEXES) { + PyCriticalSection2 *cs = (PyCriticalSection2 *)(prev & ~_Py_CRITICAL_SECTION_MASK); + assert(cs != NULL && (cs->_cs_base._cs_mutex == mutex || cs->_cs_mutex2 == mutex)); + } + else { + PyCriticalSection *cs = (PyCriticalSection *)(tstate->critical_section & ~_Py_CRITICAL_SECTION_MASK); + assert(cs != NULL && cs->_cs_mutex == mutex); + } + +#endif +} + +#endif /* Py_GIL_DISABLED */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CRITICAL_SECTION_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_crossinterp.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_crossinterp.h new file mode 100644 index 00000000..2dd165ea --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_crossinterp.h @@ -0,0 +1,340 @@ +#ifndef Py_INTERNAL_CROSSINTERP_H +#define Py_INTERNAL_CROSSINTERP_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_lock.h" // PyMutex +#include "pycore_pyerrors.h" + +/**************/ +/* exceptions */ +/**************/ + +PyAPI_DATA(PyObject *) PyExc_InterpreterError; +PyAPI_DATA(PyObject *) PyExc_InterpreterNotFoundError; + + +/***************************/ +/* cross-interpreter calls */ +/***************************/ + +typedef int (*_Py_simple_func)(void *); +extern int _Py_CallInInterpreter( + PyInterpreterState *interp, + _Py_simple_func func, + void *arg); +extern int _Py_CallInInterpreterAndRawFree( + PyInterpreterState *interp, + _Py_simple_func func, + void *arg); + + +/**************************/ +/* cross-interpreter data */ +/**************************/ + +typedef struct _xid _PyCrossInterpreterData; +typedef PyObject *(*xid_newobjectfunc)(_PyCrossInterpreterData *); +typedef void (*xid_freefunc)(void *); + +// _PyCrossInterpreterData is similar to Py_buffer as an effectively +// opaque struct that holds data outside the object machinery. This +// is necessary to pass safely between interpreters in the same process. +struct _xid { + // data is the cross-interpreter-safe derivation of a Python object + // (see _PyObject_GetCrossInterpreterData). It will be NULL if the + // new_object func (below) encodes the data. + void *data; + // obj is the Python object from which the data was derived. This + // is non-NULL only if the data remains bound to the object in some + // way, such that the object must be "released" (via a decref) when + // the data is released. In that case the code that sets the field, + // likely a registered "crossinterpdatafunc", is responsible for + // ensuring it owns the reference (i.e. incref). + PyObject *obj; + // interp is the ID of the owning interpreter of the original + // object. It corresponds to the active interpreter when + // _PyObject_GetCrossInterpreterData() was called. This should only + // be set by the cross-interpreter machinery. + // + // We use the ID rather than the PyInterpreterState to avoid issues + // with deleted interpreters. Note that IDs are never re-used, so + // each one will always correspond to a specific interpreter + // (whether still alive or not). + int64_t interpid; + // new_object is a function that returns a new object in the current + // interpreter given the data. The resulting object (a new + // reference) will be equivalent to the original object. This field + // is required. + xid_newobjectfunc new_object; + // free is called when the data is released. If it is NULL then + // nothing will be done to free the data. For some types this is + // okay (e.g. bytes) and for those types this field should be set + // to NULL. However, for most the data was allocated just for + // cross-interpreter use, so it must be freed when + // _PyCrossInterpreterData_Release is called or the memory will + // leak. In that case, at the very least this field should be set + // to PyMem_RawFree (the default if not explicitly set to NULL). + // The call will happen with the original interpreter activated. + xid_freefunc free; +}; + +PyAPI_FUNC(_PyCrossInterpreterData *) _PyCrossInterpreterData_New(void); +PyAPI_FUNC(void) _PyCrossInterpreterData_Free(_PyCrossInterpreterData *data); + +#define _PyCrossInterpreterData_DATA(DATA) ((DATA)->data) +#define _PyCrossInterpreterData_OBJ(DATA) ((DATA)->obj) +#define _PyCrossInterpreterData_INTERPID(DATA) ((DATA)->interpid) +// Users should not need getters for "new_object" or "free". + + +/* defining cross-interpreter data */ + +PyAPI_FUNC(void) _PyCrossInterpreterData_Init( + _PyCrossInterpreterData *data, + PyInterpreterState *interp, void *shared, PyObject *obj, + xid_newobjectfunc new_object); +PyAPI_FUNC(int) _PyCrossInterpreterData_InitWithSize( + _PyCrossInterpreterData *, + PyInterpreterState *interp, const size_t, PyObject *, + xid_newobjectfunc); +PyAPI_FUNC(void) _PyCrossInterpreterData_Clear( + PyInterpreterState *, _PyCrossInterpreterData *); + +// Normally the Init* functions are sufficient. The only time +// additional initialization might be needed is to set the "free" func, +// though that should be infrequent. +#define _PyCrossInterpreterData_SET_FREE(DATA, FUNC) \ + do { \ + (DATA)->free = (FUNC); \ + } while (0) +// Additionally, some shareable types are essentially light wrappers +// around other shareable types. The crossinterpdatafunc of the wrapper +// can often be implemented by calling the wrapped object's +// crossinterpdatafunc and then changing the "new_object" function. +// We have _PyCrossInterpreterData_SET_NEW_OBJECT() here for that, +// but might be better to have a function like +// _PyCrossInterpreterData_AdaptToWrapper() instead. +#define _PyCrossInterpreterData_SET_NEW_OBJECT(DATA, FUNC) \ + do { \ + (DATA)->new_object = (FUNC); \ + } while (0) + + +/* using cross-interpreter data */ + +PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *); +PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *); +PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *); +PyAPI_FUNC(int) _PyCrossInterpreterData_Release(_PyCrossInterpreterData *); +PyAPI_FUNC(int) _PyCrossInterpreterData_ReleaseAndRawFree(_PyCrossInterpreterData *); + + +/* cross-interpreter data registry */ + +// For now we use a global registry of shareable classes. An +// alternative would be to add a tp_* slot for a class's +// crossinterpdatafunc. It would be simpler and more efficient. + +typedef int (*crossinterpdatafunc)(PyThreadState *tstate, PyObject *, + _PyCrossInterpreterData *); + +struct _xidregitem; + +struct _xidregitem { + struct _xidregitem *prev; + struct _xidregitem *next; + /* This can be a dangling pointer, but only if weakref is set. */ + PyTypeObject *cls; + /* This is NULL for builtin types. */ + PyObject *weakref; + size_t refcount; + crossinterpdatafunc getdata; +}; + +struct _xidregistry { + int global; /* builtin types or heap types */ + int initialized; + PyMutex mutex; + struct _xidregitem *head; +}; + +PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc); +PyAPI_FUNC(int) _PyCrossInterpreterData_UnregisterClass(PyTypeObject *); +PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *); + + +/*****************************/ +/* runtime state & lifecycle */ +/*****************************/ + +struct _xi_runtime_state { + // builtin types + // XXX Remove this field once we have a tp_* slot. + struct _xidregistry registry; +}; + +struct _xi_state { + // heap types + // XXX Remove this field once we have a tp_* slot. + struct _xidregistry registry; + + // heap types + PyObject *PyExc_NotShareableError; +}; + +extern PyStatus _PyXI_Init(PyInterpreterState *interp); +extern void _PyXI_Fini(PyInterpreterState *interp); + +extern PyStatus _PyXI_InitTypes(PyInterpreterState *interp); +extern void _PyXI_FiniTypes(PyInterpreterState *interp); + +#define _PyInterpreterState_GetXIState(interp) (&(interp)->xi) + + +/***************************/ +/* short-term data sharing */ +/***************************/ + +// Ultimately we'd like to preserve enough information about the +// exception and traceback that we could re-constitute (or at least +// simulate, a la traceback.TracebackException), and even chain, a copy +// of the exception in the calling interpreter. + +typedef struct _excinfo { + struct _excinfo_type { + PyTypeObject *builtin; + const char *name; + const char *qualname; + const char *module; + } type; + const char *msg; + const char *errdisplay; +} _PyXI_excinfo; + +PyAPI_FUNC(int) _PyXI_InitExcInfo(_PyXI_excinfo *info, PyObject *exc); +PyAPI_FUNC(PyObject *) _PyXI_FormatExcInfo(_PyXI_excinfo *info); +PyAPI_FUNC(PyObject *) _PyXI_ExcInfoAsObject(_PyXI_excinfo *info); +PyAPI_FUNC(void) _PyXI_ClearExcInfo(_PyXI_excinfo *info); + + +typedef enum error_code { + _PyXI_ERR_NO_ERROR = 0, + _PyXI_ERR_UNCAUGHT_EXCEPTION = -1, + _PyXI_ERR_OTHER = -2, + _PyXI_ERR_NO_MEMORY = -3, + _PyXI_ERR_ALREADY_RUNNING = -4, + _PyXI_ERR_MAIN_NS_FAILURE = -5, + _PyXI_ERR_APPLY_NS_FAILURE = -6, + _PyXI_ERR_NOT_SHAREABLE = -7, +} _PyXI_errcode; + + +typedef struct _sharedexception { + // The originating interpreter. + PyInterpreterState *interp; + // The kind of error to propagate. + _PyXI_errcode code; + // The exception information to propagate, if applicable. + // This is populated only for some error codes, + // but always for _PyXI_ERR_UNCAUGHT_EXCEPTION. + _PyXI_excinfo uncaught; +} _PyXI_error; + +PyAPI_FUNC(PyObject *) _PyXI_ApplyError(_PyXI_error *err); + + +typedef struct xi_session _PyXI_session; +typedef struct _sharedns _PyXI_namespace; + +PyAPI_FUNC(void) _PyXI_FreeNamespace(_PyXI_namespace *ns); +PyAPI_FUNC(_PyXI_namespace *) _PyXI_NamespaceFromNames(PyObject *names); +PyAPI_FUNC(int) _PyXI_FillNamespaceFromDict( + _PyXI_namespace *ns, + PyObject *nsobj, + _PyXI_session *session); +PyAPI_FUNC(int) _PyXI_ApplyNamespace( + _PyXI_namespace *ns, + PyObject *nsobj, + PyObject *dflt); + + +// A cross-interpreter session involves entering an interpreter +// (_PyXI_Enter()), doing some work with it, and finally exiting +// that interpreter (_PyXI_Exit()). +// +// At the boundaries of the session, both entering and exiting, +// data may be exchanged between the previous interpreter and the +// target one in a thread-safe way that does not violate the +// isolation between interpreters. This includes setting objects +// in the target's __main__ module on the way in, and capturing +// uncaught exceptions on the way out. +struct xi_session { + // Once a session has been entered, this is the tstate that was + // current before the session. If it is different from cur_tstate + // then we must have switched interpreters. Either way, this will + // be the current tstate once we exit the session. + PyThreadState *prev_tstate; + // Once a session has been entered, this is the current tstate. + // It must be current when the session exits. + PyThreadState *init_tstate; + // This is true if init_tstate needs cleanup during exit. + int own_init_tstate; + + // This is true if, while entering the session, init_thread took + // "ownership" of the interpreter's __main__ module. This means + // it is the only thread that is allowed to run code there. + // (Caveat: for now, users may still run exec() against the + // __main__ module's dict, though that isn't advisable.) + int running; + // This is a cached reference to the __dict__ of the entered + // interpreter's __main__ module. It is looked up when at the + // beginning of the session as a convenience. + PyObject *main_ns; + + // This is set if the interpreter is entered and raised an exception + // that needs to be handled in some special way during exit. + _PyXI_errcode *error_override; + // This is set if exit captured an exception to propagate. + _PyXI_error *error; + + // -- pre-allocated memory -- + _PyXI_error _error; + _PyXI_errcode _error_override; +}; + +PyAPI_FUNC(int) _PyXI_Enter( + _PyXI_session *session, + PyInterpreterState *interp, + PyObject *nsupdates); +PyAPI_FUNC(void) _PyXI_Exit(_PyXI_session *session); + +PyAPI_FUNC(PyObject *) _PyXI_ApplyCapturedException(_PyXI_session *session); +PyAPI_FUNC(int) _PyXI_HasCapturedException(_PyXI_session *session); + + +/*************/ +/* other API */ +/*************/ + +// Export for _testinternalcapi shared extension +PyAPI_FUNC(PyInterpreterState *) _PyXI_NewInterpreter( + PyInterpreterConfig *config, + long *maybe_whence, + PyThreadState **p_tstate, + PyThreadState **p_save_tstate); +PyAPI_FUNC(void) _PyXI_EndInterpreter( + PyInterpreterState *interp, + PyThreadState *tstate, + PyThreadState **p_save_tstate); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CROSSINTERP_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_descrobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_descrobject.h new file mode 100644 index 00000000..3cec59a6 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_descrobject.h @@ -0,0 +1,28 @@ +#ifndef Py_INTERNAL_DESCROBJECT_H +#define Py_INTERNAL_DESCROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +typedef struct { + PyObject_HEAD + PyObject *prop_get; + PyObject *prop_set; + PyObject *prop_del; + PyObject *prop_doc; + PyObject *prop_name; + int getter_doc; +} propertyobject; + +typedef propertyobject _PyPropertyObject; + +extern PyTypeObject _PyMethodWrapper_Type; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_DESCROBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_dict.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_dict.h new file mode 100644 index 00000000..36da498d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_dict.h @@ -0,0 +1,340 @@ +#ifndef Py_INTERNAL_DICT_H +#define Py_INTERNAL_DICT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_freelist.h" // _PyFreeListState +#include "pycore_identifier.h" // _Py_Identifier +#include "pycore_object.h" // PyManagedDictPointer +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_SSIZE_ACQUIRE + +// Unsafe flavor of PyDict_GetItemWithError(): no error checking +extern PyObject* _PyDict_GetItemWithError(PyObject *dp, PyObject *key); + +// Delete an item from a dict if a predicate is true +// Returns -1 on error, 1 if the item was deleted, 0 otherwise +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key, + int (*predicate)(PyObject *value, void *arg), + void *arg); + +// "KnownHash" variants +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key, + PyObject *item, Py_hash_t hash); +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key, + Py_hash_t hash); +extern int _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t); + +// "Id" variants +extern PyObject* _PyDict_GetItemIdWithError(PyObject *dp, + _Py_Identifier *key); +extern int _PyDict_ContainsId(PyObject *, _Py_Identifier *); +extern int _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item); +extern int _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key); + +extern int _PyDict_Next( + PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash); + +extern int _PyDict_HasOnlyStringKeys(PyObject *mp); + +extern void _PyDict_MaybeUntrack(PyObject *mp); + +// Export for '_ctypes' shared extension +PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *); + +#define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL) + +/* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0, + the first occurrence of a key wins, if override is 1, the last occurrence + of a key wins, if override is 2, a KeyError with conflicting key as + argument is raised. +*/ +PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override); + +extern void _PyDict_DebugMallocStats(FILE *out); + + +/* _PyDictView */ + +typedef struct { + PyObject_HEAD + PyDictObject *dv_dict; +} _PyDictViewObject; + +extern PyObject* _PyDictView_New(PyObject *, PyTypeObject *); +extern PyObject* _PyDictView_Intersect(PyObject* self, PyObject *other); + +/* other API */ + +typedef struct { + /* Cached hash code of me_key. */ + Py_hash_t me_hash; + PyObject *me_key; + PyObject *me_value; /* This field is only meaningful for combined tables */ +} PyDictKeyEntry; + +typedef struct { + PyObject *me_key; /* The key must be Unicode and have hash. */ + PyObject *me_value; /* This field is only meaningful for combined tables */ +} PyDictUnicodeEntry; + +extern PyDictKeysObject *_PyDict_NewKeysForClass(void); +extern PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *); + +/* Gets a version number unique to the current state of the keys of dict, if possible. + * Returns the version number, or zero if it was not possible to get a version number. */ +extern uint32_t _PyDictKeys_GetVersionForCurrentState( + PyInterpreterState *interp, PyDictKeysObject *dictkeys); + +extern size_t _PyDict_KeysSize(PyDictKeysObject *keys); + +extern void _PyDictKeys_DecRef(PyDictKeysObject *keys); + +/* _Py_dict_lookup() returns index of entry which can be used like DK_ENTRIES(dk)[index]. + * -1 when no entry found, -3 when compare raises error. + */ +extern Py_ssize_t _Py_dict_lookup(PyDictObject *mp, PyObject *key, Py_hash_t hash, PyObject **value_addr); +extern Py_ssize_t _Py_dict_lookup_threadsafe(PyDictObject *mp, PyObject *key, Py_hash_t hash, PyObject **value_addr); + +extern Py_ssize_t _PyDict_LookupIndex(PyDictObject *, PyObject *); +extern Py_ssize_t _PyDictKeys_StringLookup(PyDictKeysObject* dictkeys, PyObject *key); +PyAPI_FUNC(PyObject *)_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *); + +/* Consumes references to key and value */ +PyAPI_FUNC(int) _PyDict_SetItem_Take2(PyDictObject *op, PyObject *key, PyObject *value); +extern int _PyDict_SetItem_LockHeld(PyDictObject *dict, PyObject *name, PyObject *value); +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _PyDict_SetItem_KnownHash_LockHeld(PyDictObject *mp, PyObject *key, + PyObject *value, Py_hash_t hash); +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _PyDict_GetItemRef_KnownHash_LockHeld(PyDictObject *op, PyObject *key, Py_hash_t hash, PyObject **result); +extern int _PyDict_GetItemRef_KnownHash(PyDictObject *op, PyObject *key, Py_hash_t hash, PyObject **result); +extern int _PyDict_GetItemRef_Unicode_LockHeld(PyDictObject *op, PyObject *key, PyObject **result); +extern int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject *obj, PyObject **dictptr, PyObject *name, PyObject *value); + +extern int _PyDict_Pop_KnownHash( + PyDictObject *dict, + PyObject *key, + Py_hash_t hash, + PyObject **result); + +#define DKIX_EMPTY (-1) +#define DKIX_DUMMY (-2) /* Used internally */ +#define DKIX_ERROR (-3) +#define DKIX_KEY_CHANGED (-4) /* Used internally */ + +typedef enum { + DICT_KEYS_GENERAL = 0, + DICT_KEYS_UNICODE = 1, + DICT_KEYS_SPLIT = 2 +} DictKeysKind; + +/* See dictobject.c for actual layout of DictKeysObject */ +struct _dictkeysobject { + Py_ssize_t dk_refcnt; + + /* Size of the hash table (dk_indices). It must be a power of 2. */ + uint8_t dk_log2_size; + + /* Size of the hash table (dk_indices) by bytes. */ + uint8_t dk_log2_index_bytes; + + /* Kind of keys */ + uint8_t dk_kind; + +#ifdef Py_GIL_DISABLED + /* Lock used to protect shared keys */ + PyMutex dk_mutex; +#endif + + /* Version number -- Reset to 0 by any modification to keys */ + uint32_t dk_version; + + /* Number of usable entries in dk_entries. */ + Py_ssize_t dk_usable; + + /* Number of used entries in dk_entries. */ + Py_ssize_t dk_nentries; + + + /* Actual hash table of dk_size entries. It holds indices in dk_entries, + or DKIX_EMPTY(-1) or DKIX_DUMMY(-2). + + Indices must be: 0 <= indice < USABLE_FRACTION(dk_size). + + The size in bytes of an indice depends on dk_size: + + - 1 byte if dk_size <= 0xff (char*) + - 2 bytes if dk_size <= 0xffff (int16_t*) + - 4 bytes if dk_size <= 0xffffffff (int32_t*) + - 8 bytes otherwise (int64_t*) + + Dynamically sized, SIZEOF_VOID_P is minimum. */ + char dk_indices[]; /* char is required to avoid strict aliasing. */ + + /* "PyDictKeyEntry or PyDictUnicodeEntry dk_entries[USABLE_FRACTION(DK_SIZE(dk))];" array follows: + see the DK_ENTRIES() / DK_UNICODE_ENTRIES() functions below */ +}; + +/* This must be no more than 250, for the prefix size to fit in one byte. */ +#define SHARED_KEYS_MAX_SIZE 30 +#define NEXT_LOG2_SHARED_KEYS_MAX_SIZE 6 + +/* Layout of dict values: + * + * The PyObject *values are preceded by an array of bytes holding + * the insertion order and size. + * [-1] = prefix size. [-2] = used size. size[-2-n...] = insertion order. + */ +struct _dictvalues { + uint8_t capacity; + uint8_t size; + uint8_t embedded; + uint8_t valid; + PyObject *values[1]; +}; + +#define DK_LOG_SIZE(dk) _Py_RVALUE((dk)->dk_log2_size) +#if SIZEOF_VOID_P > 4 +#define DK_SIZE(dk) (((int64_t)1)<dk_indices); + size_t index = (size_t)1 << dk->dk_log2_index_bytes; + return (&indices[index]); +} + +static inline PyDictKeyEntry* DK_ENTRIES(PyDictKeysObject *dk) { + assert(dk->dk_kind == DICT_KEYS_GENERAL); + return (PyDictKeyEntry*)_DK_ENTRIES(dk); +} +static inline PyDictUnicodeEntry* DK_UNICODE_ENTRIES(PyDictKeysObject *dk) { + assert(dk->dk_kind != DICT_KEYS_GENERAL); + return (PyDictUnicodeEntry*)_DK_ENTRIES(dk); +} + +#define DK_IS_UNICODE(dk) ((dk)->dk_kind != DICT_KEYS_GENERAL) + +#define DICT_VERSION_INCREMENT (1 << (DICT_MAX_WATCHERS + DICT_WATCHED_MUTATION_BITS)) +#define DICT_WATCHER_MASK ((1 << DICT_MAX_WATCHERS) - 1) +#define DICT_WATCHER_AND_MODIFICATION_MASK ((1 << (DICT_MAX_WATCHERS + DICT_WATCHED_MUTATION_BITS)) - 1) + +#ifdef Py_GIL_DISABLED + +#define THREAD_LOCAL_DICT_VERSION_COUNT 256 +#define THREAD_LOCAL_DICT_VERSION_BATCH THREAD_LOCAL_DICT_VERSION_COUNT * DICT_VERSION_INCREMENT + +static inline uint64_t +dict_next_version(PyInterpreterState *interp) +{ + PyThreadState *tstate = PyThreadState_GET(); + uint64_t cur_progress = (tstate->dict_global_version & + (THREAD_LOCAL_DICT_VERSION_BATCH - 1)); + if (cur_progress == 0) { + uint64_t next = _Py_atomic_add_uint64(&interp->dict_state.global_version, + THREAD_LOCAL_DICT_VERSION_BATCH); + tstate->dict_global_version = next; + } + return tstate->dict_global_version += DICT_VERSION_INCREMENT; +} + +#define DICT_NEXT_VERSION(INTERP) dict_next_version(INTERP) + +#else +#define DICT_NEXT_VERSION(INTERP) \ + ((INTERP)->dict_state.global_version += DICT_VERSION_INCREMENT) +#endif + +void +_PyDict_SendEvent(int watcher_bits, + PyDict_WatchEvent event, + PyDictObject *mp, + PyObject *key, + PyObject *value); + +static inline uint64_t +_PyDict_NotifyEvent(PyInterpreterState *interp, + PyDict_WatchEvent event, + PyDictObject *mp, + PyObject *key, + PyObject *value) +{ + assert(Py_REFCNT((PyObject*)mp) > 0); + int watcher_bits = mp->ma_version_tag & DICT_WATCHER_MASK; + if (watcher_bits) { + RARE_EVENT_STAT_INC(watched_dict_modification); + _PyDict_SendEvent(watcher_bits, event, mp, key, value); + } + return DICT_NEXT_VERSION(interp) | (mp->ma_version_tag & DICT_WATCHER_AND_MODIFICATION_MASK); +} + +extern PyDictObject *_PyObject_MaterializeManagedDict(PyObject *obj); + +PyAPI_FUNC(PyObject *)_PyDict_FromItems( + PyObject *const *keys, Py_ssize_t keys_offset, + PyObject *const *values, Py_ssize_t values_offset, + Py_ssize_t length); + +static inline uint8_t * +get_insertion_order_array(PyDictValues *values) +{ + return (uint8_t *)&values->values[values->capacity]; +} + +static inline void +_PyDictValues_AddToInsertionOrder(PyDictValues *values, Py_ssize_t ix) +{ + assert(ix < SHARED_KEYS_MAX_SIZE); + int size = values->size; + uint8_t *array = get_insertion_order_array(values); + assert(size < values->capacity); + assert(((uint8_t)ix) == ix); + array[size] = (uint8_t)ix; + values->size = size+1; +} + +static inline size_t +shared_keys_usable_size(PyDictKeysObject *keys) +{ + // dk_usable will decrease for each instance that is created and each + // value that is added. dk_nentries will increase for each value that + // is added. We want to always return the right value or larger. + // We therefore increase dk_nentries first and we decrease dk_usable + // second, and conversely here we read dk_usable first and dk_entries + // second (to avoid the case where we read entries before the increment + // and read usable after the decrement) + Py_ssize_t dk_usable = FT_ATOMIC_LOAD_SSIZE_ACQUIRE(keys->dk_usable); + Py_ssize_t dk_nentries = FT_ATOMIC_LOAD_SSIZE_ACQUIRE(keys->dk_nentries); + return dk_nentries + dk_usable; +} + +static inline size_t +_PyInlineValuesSize(PyTypeObject *tp) +{ + PyDictKeysObject *keys = ((PyHeapTypeObject*)tp)->ht_cached_keys; + assert(keys != NULL); + size_t size = shared_keys_usable_size(keys); + size_t prefix_size = _Py_SIZE_ROUND_UP(size, sizeof(PyObject *)); + assert(prefix_size < 256); + return prefix_size + (size + 1) * sizeof(PyObject *); +} + +int +_PyDict_DetachFromObject(PyDictObject *dict, PyObject *obj); + +PyDictObject *_PyObject_MaterializeManagedDict_LockHeld(PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_DICT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_dict_state.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_dict_state.h new file mode 100644 index 00000000..1a44755c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_dict_state.h @@ -0,0 +1,32 @@ +#ifndef Py_INTERNAL_DICT_STATE_H +#define Py_INTERNAL_DICT_STATE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#define DICT_MAX_WATCHERS 8 +#define DICT_WATCHED_MUTATION_BITS 4 + +struct _Py_dict_state { + /*Global counter used to set ma_version_tag field of dictionary. + * It is incremented each time that a dictionary is created and each + * time that a dictionary is modified. */ + uint64_t global_version; + uint32_t next_keys_version; + PyDict_WatchCallback watchers[DICT_MAX_WATCHERS]; +}; + +#define _dict_state_INIT \ + { \ + .next_keys_version = 2, \ + } + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_DICT_STATE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_dtoa.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_dtoa.h new file mode 100644 index 00000000..e4222c52 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_dtoa.h @@ -0,0 +1,75 @@ +#ifndef Py_INTERNAL_DTOA_H +#define Py_INTERNAL_DTOA_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR + + +typedef uint32_t ULong; + +struct +Bigint { + struct Bigint *next; + int k, maxwds, sign, wds; + ULong x[1]; +}; + +#if defined(Py_USING_MEMORY_DEBUGGER) || _PY_SHORT_FLOAT_REPR == 0 + +struct _dtoa_state { + int _not_used; +}; +#define _dtoa_state_INIT(INTERP) \ + {0} + +#else // !Py_USING_MEMORY_DEBUGGER && _PY_SHORT_FLOAT_REPR != 0 + +/* The size of the Bigint freelist */ +#define Bigint_Kmax 7 + +/* The size of the cached powers of 5 array */ +#define Bigint_Pow5size 8 + +#ifndef PRIVATE_MEM +#define PRIVATE_MEM 2304 +#endif +#define Bigint_PREALLOC_SIZE \ + ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) + +struct _dtoa_state { + // p5s is an array of powers of 5 of the form: + // 5**(2**(i+2)) for 0 <= i < Bigint_Pow5size + struct Bigint *p5s[Bigint_Pow5size]; + // XXX This should be freed during runtime fini. + struct Bigint *freelist[Bigint_Kmax+1]; + double preallocated[Bigint_PREALLOC_SIZE]; + double *preallocated_next; +}; +#define _dtoa_state_INIT(INTERP) \ + { \ + .preallocated_next = (INTERP)->dtoa.preallocated, \ + } + +#endif // !Py_USING_MEMORY_DEBUGGER + + +extern double _Py_dg_strtod(const char *str, char **ptr); +extern char* _Py_dg_dtoa(double d, int mode, int ndigits, + int *decpt, int *sign, char **rve); +extern void _Py_dg_freedtoa(char *s); + + +extern PyStatus _PyDtoa_Init(PyInterpreterState *interp); +extern void _PyDtoa_Fini(PyInterpreterState *interp); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_DTOA_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_emscripten_signal.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_emscripten_signal.h new file mode 100644 index 00000000..754193e2 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_emscripten_signal.h @@ -0,0 +1,30 @@ +#ifndef Py_EMSCRIPTEN_SIGNAL_H +#define Py_EMSCRIPTEN_SIGNAL_H + +#if defined(__EMSCRIPTEN__) + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +void +_Py_CheckEmscriptenSignals(void); + +void +_Py_CheckEmscriptenSignalsPeriodically(void); + +#define _Py_CHECK_EMSCRIPTEN_SIGNALS() _Py_CheckEmscriptenSignals() + +#define _Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY() _Py_CheckEmscriptenSignalsPeriodically() + +extern int Py_EMSCRIPTEN_SIGNAL_HANDLING; +extern int _Py_emscripten_signal_clock; + +#else + +#define _Py_CHECK_EMSCRIPTEN_SIGNALS() +#define _Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY() + +#endif // defined(__EMSCRIPTEN__) + +#endif // ndef Py_EMSCRIPTEN_SIGNAL_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_emscripten_trampoline.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_emscripten_trampoline.h new file mode 100644 index 00000000..e519c99a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_emscripten_trampoline.h @@ -0,0 +1,81 @@ +#ifndef Py_EMSCRIPTEN_TRAMPOLINE_H +#define Py_EMSCRIPTEN_TRAMPOLINE_H + +#include "pycore_runtime.h" // _PyRuntimeState + +/** + * C function call trampolines to mitigate bad function pointer casts. + * + * Section 6.3.2.3, paragraph 8 reads: + * + * A pointer to a function of one type may be converted to a pointer to a + * function of another type and back again; the result shall compare equal to + * the original pointer. If a converted pointer is used to call a function + * whose type is not compatible with the pointed-to type, the behavior is + * undefined. + * + * Typical native ABIs ignore additional arguments or fill in missing values + * with 0/NULL in function pointer cast. Compilers do not show warnings when a + * function pointer is explicitly casted to an incompatible type. + * + * Bad fpcasts are an issue in WebAssembly. WASM's indirect_call has strict + * function signature checks. Argument count, types, and return type must match. + * + * Third party code unintentionally rely on problematic fpcasts. The call + * trampoline mitigates common occurrences of bad fpcasts on Emscripten. + */ + +#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE) + +void _Py_EmscriptenTrampoline_Init(_PyRuntimeState *runtime); + +PyObject* +_PyEM_TrampolineCall_JavaScript(PyCFunctionWithKeywords func, + PyObject* self, + PyObject* args, + PyObject* kw); + +PyObject* +_PyEM_TrampolineCall_Reflection(PyCFunctionWithKeywords func, + PyObject* self, + PyObject* args, + PyObject* kw); + +#define _PyEM_TrampolineCall(meth, self, args, kw) \ + ((_PyRuntime.wasm_type_reflection_available) ? \ + (_PyEM_TrampolineCall_Reflection((PyCFunctionWithKeywords)(meth), (self), (args), (kw))) : \ + (_PyEM_TrampolineCall_JavaScript((PyCFunctionWithKeywords)(meth), (self), (args), (kw)))) + +#define _PyCFunction_TrampolineCall(meth, self, args) \ + _PyEM_TrampolineCall( \ + (*(PyCFunctionWithKeywords)(void(*)(void))(meth)), (self), (args), NULL) + +#define _PyCFunctionWithKeywords_TrampolineCall(meth, self, args, kw) \ + _PyEM_TrampolineCall((meth), (self), (args), (kw)) + +#define descr_set_trampoline_call(set, obj, value, closure) \ + ((int)_PyEM_TrampolineCall((PyCFunctionWithKeywords)(set), (obj), (value), (PyObject*)(closure))) + +#define descr_get_trampoline_call(get, obj, closure) \ + _PyEM_TrampolineCall((PyCFunctionWithKeywords)(get), (obj), (PyObject*)(closure), NULL) + + +#else // defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE) + +#define _Py_EmscriptenTrampoline_Init(runtime) + +#define _PyCFunction_TrampolineCall(meth, self, args) \ + (meth)((self), (args)) + +#define _PyCFunctionWithKeywords_TrampolineCall(meth, self, args, kw) \ + (meth)((self), (args), (kw)) + +#define descr_set_trampoline_call(set, obj, value, closure) \ + (set)((obj), (value), (closure)) + +#define descr_get_trampoline_call(get, obj, closure) \ + (get)((obj), (closure)) + +#endif // defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE) + +#endif // ndef Py_EMSCRIPTEN_SIGNAL_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_exceptions.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_exceptions.h new file mode 100644 index 00000000..26456d19 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_exceptions.h @@ -0,0 +1,40 @@ +#ifndef Py_INTERNAL_EXCEPTIONS_H +#define Py_INTERNAL_EXCEPTIONS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +/* runtime lifecycle */ + +extern PyStatus _PyExc_InitState(PyInterpreterState *); +extern PyStatus _PyExc_InitGlobalObjects(PyInterpreterState *); +extern int _PyExc_InitTypes(PyInterpreterState *); +extern void _PyExc_Fini(PyInterpreterState *); + + +/* other API */ + +struct _Py_exc_state { + // The dict mapping from errno codes to OSError subclasses + PyObject *errnomap; + PyBaseExceptionObject *memerrors_freelist; + int memerrors_numfree; +#ifdef Py_GIL_DISABLED + PyMutex memerrors_lock; +#endif + // The ExceptionGroup type + PyObject *PyExc_ExceptionGroup; +}; + +extern void _PyExc_ClearExceptionGroupType(PyInterpreterState *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_EXCEPTIONS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_faulthandler.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_faulthandler.h new file mode 100644 index 00000000..6dd7d8d7 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_faulthandler.h @@ -0,0 +1,99 @@ +#ifndef Py_INTERNAL_FAULTHANDLER_H +#define Py_INTERNAL_FAULTHANDLER_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#ifdef HAVE_SIGACTION +# include // sigaction +#endif + + +#ifndef MS_WINDOWS + /* register() is useless on Windows, because only SIGSEGV, SIGABRT and + SIGILL can be handled by the process, and these signals can only be used + with enable(), not using register() */ +# define FAULTHANDLER_USER +#endif + + +#ifdef HAVE_SIGACTION +/* Using an alternative stack requires sigaltstack() + and sigaction() SA_ONSTACK */ +# ifdef HAVE_SIGALTSTACK +# define FAULTHANDLER_USE_ALT_STACK +# endif +typedef struct sigaction _Py_sighandler_t; +#else +typedef PyOS_sighandler_t _Py_sighandler_t; +#endif // HAVE_SIGACTION + + +#ifdef FAULTHANDLER_USER +struct faulthandler_user_signal { + int enabled; + PyObject *file; + int fd; + int all_threads; + int chain; + _Py_sighandler_t previous; + PyInterpreterState *interp; +}; +#endif /* FAULTHANDLER_USER */ + + +struct _faulthandler_runtime_state { + struct { + int enabled; + PyObject *file; + int fd; + int all_threads; + PyInterpreterState *interp; +#ifdef MS_WINDOWS + void *exc_handler; +#endif + } fatal_error; + + struct { + PyObject *file; + int fd; + PY_TIMEOUT_T timeout_us; /* timeout in microseconds */ + int repeat; + PyInterpreterState *interp; + int exit; + char *header; + size_t header_len; + /* The main thread always holds this lock. It is only released when + faulthandler_thread() is interrupted before this thread exits, or at + Python exit. */ + PyThread_type_lock cancel_event; + /* released by child thread when joined */ + PyThread_type_lock running; + } thread; + +#ifdef FAULTHANDLER_USER + struct faulthandler_user_signal *user_signals; +#endif + +#ifdef FAULTHANDLER_USE_ALT_STACK + stack_t stack; + stack_t old_stack; +#endif +}; + +#define _faulthandler_runtime_state_INIT \ + { \ + .fatal_error = { \ + .fd = -1, \ + }, \ + } + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_FAULTHANDLER_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_fileutils.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_fileutils.h new file mode 100644 index 00000000..13f86b01 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_fileutils.h @@ -0,0 +1,335 @@ +#ifndef Py_INTERNAL_FILEUTILS_H +#define Py_INTERNAL_FILEUTILS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include // struct lconv + + +/* A routine to check if a file descriptor can be select()-ed. */ +#ifdef _MSC_VER + /* On Windows, any socket fd can be select()-ed, no matter how high */ + #define _PyIsSelectable_fd(FD) (1) +#else + #define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE) +#endif + +struct _fileutils_state { + int force_ascii; +}; + +typedef enum { + _Py_ERROR_UNKNOWN=0, + _Py_ERROR_STRICT, + _Py_ERROR_SURROGATEESCAPE, + _Py_ERROR_REPLACE, + _Py_ERROR_IGNORE, + _Py_ERROR_BACKSLASHREPLACE, + _Py_ERROR_SURROGATEPASS, + _Py_ERROR_XMLCHARREFREPLACE, + _Py_ERROR_OTHER +} _Py_error_handler; + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(_Py_error_handler) _Py_GetErrorHandler(const char *errors); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(int) _Py_DecodeLocaleEx( + const char *arg, + wchar_t **wstr, + size_t *wlen, + const char **reason, + int current_locale, + _Py_error_handler errors); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(int) _Py_EncodeLocaleEx( + const wchar_t *text, + char **str, + size_t *error_pos, + const char **reason, + int current_locale, + _Py_error_handler errors); + +extern char* _Py_EncodeLocaleRaw( + const wchar_t *text, + size_t *error_pos); + +extern PyObject* _Py_device_encoding(int); + +#if defined(MS_WINDOWS) || defined(__APPLE__) + /* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611). + On macOS 10.13, read() and write() with more than INT_MAX bytes + fail with EINVAL (bpo-24658). */ +# define _PY_READ_MAX INT_MAX +# define _PY_WRITE_MAX INT_MAX +#else + /* write() should truncate the input to PY_SSIZE_T_MAX bytes, + but it's safer to do it ourself to have a portable behaviour */ +# define _PY_READ_MAX PY_SSIZE_T_MAX +# define _PY_WRITE_MAX PY_SSIZE_T_MAX +#endif + +#ifdef MS_WINDOWS +struct _Py_stat_struct { + uint64_t st_dev; + uint64_t st_ino; + unsigned short st_mode; + int st_nlink; + int st_uid; + int st_gid; + unsigned long st_rdev; + __int64 st_size; + time_t st_atime; + int st_atime_nsec; + time_t st_mtime; + int st_mtime_nsec; + time_t st_ctime; + int st_ctime_nsec; + time_t st_birthtime; + int st_birthtime_nsec; + unsigned long st_file_attributes; + unsigned long st_reparse_tag; + uint64_t st_ino_high; +}; +#else +# define _Py_stat_struct stat +#endif + +// Export for 'mmap' shared extension +PyAPI_FUNC(int) _Py_fstat( + int fd, + struct _Py_stat_struct *status); + +// Export for 'mmap' shared extension +PyAPI_FUNC(int) _Py_fstat_noraise( + int fd, + struct _Py_stat_struct *status); + +// Export for '_tkinter' shared extension +PyAPI_FUNC(int) _Py_stat( + PyObject *path, + struct stat *status); + +// Export for 'select' shared extension (Solaris newDevPollObject()) +PyAPI_FUNC(int) _Py_open( + const char *pathname, + int flags); + +// Export for '_posixsubprocess' shared extension +PyAPI_FUNC(int) _Py_open_noraise( + const char *pathname, + int flags); + +extern FILE* _Py_wfopen( + const wchar_t *path, + const wchar_t *mode); + +extern Py_ssize_t _Py_read( + int fd, + void *buf, + size_t count); + +// Export for 'select' shared extension (Solaris devpoll_flush()) +PyAPI_FUNC(Py_ssize_t) _Py_write( + int fd, + const void *buf, + size_t count); + +// Export for '_posixsubprocess' shared extension +PyAPI_FUNC(Py_ssize_t) _Py_write_noraise( + int fd, + const void *buf, + size_t count); + +#ifdef HAVE_READLINK +extern int _Py_wreadlink( + const wchar_t *path, + wchar_t *buf, + /* Number of characters of 'buf' buffer + including the trailing NUL character */ + size_t buflen); +#endif + +#ifdef HAVE_REALPATH +extern wchar_t* _Py_wrealpath( + const wchar_t *path, + wchar_t *resolved_path, + /* Number of characters of 'resolved_path' buffer + including the trailing NUL character */ + size_t resolved_path_len); +#endif + +extern wchar_t* _Py_wgetcwd( + wchar_t *buf, + /* Number of characters of 'buf' buffer + including the trailing NUL character */ + size_t buflen); + +extern int _Py_get_inheritable(int fd); + +// Export for '_socket' shared extension +PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable, + int *atomic_flag_works); + +// Export for '_posixsubprocess' shared extension +PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable, + int *atomic_flag_works); + +// Export for '_socket' shared extension +PyAPI_FUNC(int) _Py_dup(int fd); + +extern int _Py_get_blocking(int fd); + +extern int _Py_set_blocking(int fd, int blocking); + +#ifdef MS_WINDOWS +extern void* _Py_get_osfhandle_noraise(int fd); + +// Export for '_testconsole' shared extension +PyAPI_FUNC(void*) _Py_get_osfhandle(int fd); + +extern int _Py_open_osfhandle_noraise(void *handle, int flags); + +extern int _Py_open_osfhandle(void *handle, int flags); +#endif /* MS_WINDOWS */ + +// This is used after getting NULL back from Py_DecodeLocale(). +#define DECODE_LOCALE_ERR(NAME, LEN) \ + ((LEN) == (size_t)-2) \ + ? _PyStatus_ERR("cannot decode " NAME) \ + : _PyStatus_NO_MEMORY() + +extern int _Py_HasFileSystemDefaultEncodeErrors; + +extern int _Py_DecodeUTF8Ex( + const char *arg, + Py_ssize_t arglen, + wchar_t **wstr, + size_t *wlen, + const char **reason, + _Py_error_handler errors); + +extern int _Py_EncodeUTF8Ex( + const wchar_t *text, + char **str, + size_t *error_pos, + const char **reason, + int raw_malloc, + _Py_error_handler errors); + +extern wchar_t* _Py_DecodeUTF8_surrogateescape( + const char *arg, + Py_ssize_t arglen, + size_t *wlen); + +extern int +_Py_wstat(const wchar_t *, struct stat *); + +extern int _Py_GetForceASCII(void); + +/* Reset "force ASCII" mode (if it was initialized). + + This function should be called when Python changes the LC_CTYPE locale, + so the "force ASCII" mode can be detected again on the new locale + encoding. */ +extern void _Py_ResetForceASCII(void); + + +extern int _Py_GetLocaleconvNumeric( + struct lconv *lc, + PyObject **decimal_point, + PyObject **thousands_sep); + +// Export for '_posixsubprocess' (on macOS) +PyAPI_FUNC(void) _Py_closerange(int first, int last); + +extern wchar_t* _Py_GetLocaleEncoding(void); +extern PyObject* _Py_GetLocaleEncodingObject(void); + +#ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION +extern int _Py_LocaleUsesNonUnicodeWchar(void); + +extern wchar_t* _Py_DecodeNonUnicodeWchar( + const wchar_t* native, + Py_ssize_t size); + +extern int _Py_EncodeNonUnicodeWchar_InPlace( + wchar_t* unicode, + Py_ssize_t size); +#endif + +extern int _Py_isabs(const wchar_t *path); +extern int _Py_abspath(const wchar_t *path, wchar_t **abspath_p); +#ifdef MS_WINDOWS +extern int _PyOS_getfullpathname(const wchar_t *path, wchar_t **abspath_p); +#endif +extern wchar_t* _Py_join_relfile(const wchar_t *dirname, + const wchar_t *relfile); +extern int _Py_add_relfile(wchar_t *dirname, + const wchar_t *relfile, + size_t bufsize); +extern size_t _Py_find_basename(const wchar_t *filename); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(wchar_t*) _Py_normpath(wchar_t *path, Py_ssize_t size); + +extern wchar_t *_Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *length); + +// The Windows Games API family does not provide these functions +// so provide our own implementations. Remove them in case they get added +// to the Games API family +#if defined(MS_WINDOWS_GAMES) && !defined(MS_WINDOWS_DESKTOP) +#include // HRESULT + +extern HRESULT PathCchSkipRoot(const wchar_t *pszPath, const wchar_t **ppszRootEnd); +#endif /* defined(MS_WINDOWS_GAMES) && !defined(MS_WINDOWS_DESKTOP) */ + +extern void _Py_skiproot(const wchar_t *path, Py_ssize_t size, Py_ssize_t *drvsize, Py_ssize_t *rootsize); + +// Macros to protect CRT calls against instant termination when passed an +// invalid parameter (bpo-23524). IPH stands for Invalid Parameter Handler. +// Usage: +// +// _Py_BEGIN_SUPPRESS_IPH +// ... +// _Py_END_SUPPRESS_IPH +#if defined _MSC_VER && _MSC_VER >= 1900 + +# include // _set_thread_local_invalid_parameter_handler() + + extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; +# define _Py_BEGIN_SUPPRESS_IPH \ + { _invalid_parameter_handler _Py_old_handler = \ + _set_thread_local_invalid_parameter_handler(_Py_silent_invalid_parameter_handler); +# define _Py_END_SUPPRESS_IPH \ + _set_thread_local_invalid_parameter_handler(_Py_old_handler); } +#else +# define _Py_BEGIN_SUPPRESS_IPH +# define _Py_END_SUPPRESS_IPH +#endif /* _MSC_VER >= 1900 */ + +// Export for 'select' shared extension (Argument Clinic code) +PyAPI_FUNC(int) _PyLong_FileDescriptor_Converter(PyObject *, void *); + +// Export for test_peg_generator +PyAPI_FUNC(char*) _Py_UniversalNewlineFgetsWithSize(char *, int, FILE*, PyObject *, size_t*); + +extern int _PyFile_Flush(PyObject *); + +#ifndef MS_WINDOWS +extern int _Py_GetTicksPerSecond(long *ticks_per_second); +#endif + +// Export for '_testcapi' shared extension +PyAPI_FUNC(int) _Py_IsValidFD(int fd); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_FILEUTILS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_fileutils_windows.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_fileutils_windows.h new file mode 100644 index 00000000..b79aa9fb --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_fileutils_windows.h @@ -0,0 +1,98 @@ +#ifndef Py_INTERNAL_FILEUTILS_WINDOWS_H +#define Py_INTERNAL_FILEUTILS_WINDOWS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#ifdef MS_WINDOWS + +#if !defined(NTDDI_WIN10_NI) || !(NTDDI_VERSION >= NTDDI_WIN10_NI) +typedef struct _FILE_STAT_BASIC_INFORMATION { + LARGE_INTEGER FileId; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG FileAttributes; + ULONG ReparseTag; + ULONG NumberOfLinks; + ULONG DeviceType; + ULONG DeviceCharacteristics; + ULONG Reserved; + LARGE_INTEGER VolumeSerialNumber; + FILE_ID_128 FileId128; +} FILE_STAT_BASIC_INFORMATION; + +typedef enum _FILE_INFO_BY_NAME_CLASS { + FileStatByNameInfo, + FileStatLxByNameInfo, + FileCaseSensitiveByNameInfo, + FileStatBasicByNameInfo, + MaximumFileInfoByNameClass +} FILE_INFO_BY_NAME_CLASS; +#endif + +typedef BOOL (WINAPI *PGetFileInformationByName)( + PCWSTR FileName, + FILE_INFO_BY_NAME_CLASS FileInformationClass, + PVOID FileInfoBuffer, + ULONG FileInfoBufferSize +); + +static inline BOOL _Py_GetFileInformationByName( + PCWSTR FileName, + FILE_INFO_BY_NAME_CLASS FileInformationClass, + PVOID FileInfoBuffer, + ULONG FileInfoBufferSize +) { + static PGetFileInformationByName GetFileInformationByName = NULL; + static int GetFileInformationByName_init = -1; + + if (GetFileInformationByName_init < 0) { + HMODULE hMod = LoadLibraryW(L"api-ms-win-core-file-l2-1-4"); + GetFileInformationByName_init = 0; + if (hMod) { + GetFileInformationByName = (PGetFileInformationByName)GetProcAddress( + hMod, "GetFileInformationByName"); + if (GetFileInformationByName) { + GetFileInformationByName_init = 1; + } else { + FreeLibrary(hMod); + } + } + } + + if (GetFileInformationByName_init <= 0) { + SetLastError(ERROR_NOT_SUPPORTED); + return FALSE; + } + return GetFileInformationByName(FileName, FileInformationClass, FileInfoBuffer, FileInfoBufferSize); +} + +static inline BOOL _Py_GetFileInformationByName_ErrorIsTrustworthy(int error) +{ + switch(error) { + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + case ERROR_NOT_READY: + case ERROR_BAD_NET_NAME: + case ERROR_BAD_NETPATH: + case ERROR_BAD_PATHNAME: + case ERROR_INVALID_NAME: + case ERROR_FILENAME_EXCED_RANGE: + return TRUE; + case ERROR_NOT_SUPPORTED: + return FALSE; + } + return FALSE; +} + +#endif + +#endif diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_floatobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_floatobject.h new file mode 100644 index 00000000..f984df69 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_floatobject.h @@ -0,0 +1,62 @@ +#ifndef Py_INTERNAL_FLOATOBJECT_H +#define Py_INTERNAL_FLOATOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_freelist.h" // _PyFreeListState +#include "pycore_unicodeobject.h" // _PyUnicodeWriter + +/* runtime lifecycle */ + +extern void _PyFloat_InitState(PyInterpreterState *); +extern PyStatus _PyFloat_InitTypes(PyInterpreterState *); +extern void _PyFloat_FiniType(PyInterpreterState *); + + +/* other API */ + +enum _py_float_format_type { + _py_float_format_unknown, + _py_float_format_ieee_big_endian, + _py_float_format_ieee_little_endian, +}; + +struct _Py_float_runtime_state { + enum _py_float_format_type float_format; + enum _py_float_format_type double_format; +}; + + + + +PyAPI_FUNC(void) _PyFloat_ExactDealloc(PyObject *op); + + +extern void _PyFloat_DebugMallocStats(FILE* out); + + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +extern int _PyFloat_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); + +extern PyObject* _Py_string_to_number_with_underscores( + const char *str, Py_ssize_t len, const char *what, PyObject *obj, void *arg, + PyObject *(*innerfunc)(const char *, Py_ssize_t, void *)); + +extern double _Py_parse_inf_or_nan(const char *p, char **endptr); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_FLOATOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_flowgraph.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_flowgraph.h new file mode 100644 index 00000000..819117b8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_flowgraph.h @@ -0,0 +1,40 @@ +#ifndef Py_INTERNAL_CFG_H +#define Py_INTERNAL_CFG_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_compile.h" +#include "pycore_instruction_sequence.h" +#include "pycore_opcode_utils.h" + +struct _PyCfgBuilder; + +int _PyCfgBuilder_UseLabel(struct _PyCfgBuilder *g, _PyJumpTargetLabel lbl); +int _PyCfgBuilder_Addop(struct _PyCfgBuilder *g, int opcode, int oparg, _Py_SourceLocation loc); + +struct _PyCfgBuilder* _PyCfgBuilder_New(void); +void _PyCfgBuilder_Free(struct _PyCfgBuilder *g); +int _PyCfgBuilder_CheckSize(struct _PyCfgBuilder* g); + +int _PyCfg_OptimizeCodeUnit(struct _PyCfgBuilder *g, PyObject *consts, PyObject *const_cache, + int nlocals, int nparams, int firstlineno); + +int _PyCfg_ToInstructionSequence(struct _PyCfgBuilder *g, _PyInstructionSequence *seq); +int _PyCfg_OptimizedCfgToInstructionSequence(struct _PyCfgBuilder *g, _PyCompile_CodeUnitMetadata *umd, + int code_flags, int *stackdepth, int *nlocalsplus, + _PyInstructionSequence *seq); + +PyCodeObject * +_PyAssemble_MakeCodeObject(_PyCompile_CodeUnitMetadata *u, PyObject *const_cache, + PyObject *consts, int maxdepth, _PyInstructionSequence *instrs, + int nlocalsplus, int code_flags, PyObject *filename); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CFG_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_format.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_format.h new file mode 100644 index 00000000..1b8d5753 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_format.h @@ -0,0 +1,27 @@ +#ifndef Py_INTERNAL_FORMAT_H +#define Py_INTERNAL_FORMAT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* Format codes + * F_LJUST '-' + * F_SIGN '+' + * F_BLANK ' ' + * F_ALT '#' + * F_ZERO '0' + */ +#define F_LJUST (1<<0) +#define F_SIGN (1<<1) +#define F_BLANK (1<<2) +#define F_ALT (1<<3) +#define F_ZERO (1<<4) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_FORMAT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_frame.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_frame.h new file mode 100644 index 00000000..af181e37 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_frame.h @@ -0,0 +1,330 @@ +#ifndef Py_INTERNAL_FRAME_H +#define Py_INTERNAL_FRAME_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include +#include // offsetof() +#include "pycore_code.h" // STATS + +/* See Objects/frame_layout.md for an explanation of the frame stack + * including explanation of the PyFrameObject and _PyInterpreterFrame + * structs. */ + + +struct _frame { + PyObject_HEAD + PyFrameObject *f_back; /* previous frame, or NULL */ + struct _PyInterpreterFrame *f_frame; /* points to the frame data */ + PyObject *f_trace; /* Trace function */ + int f_lineno; /* Current line number. Only valid if non-zero */ + char f_trace_lines; /* Emit per-line trace events? */ + char f_trace_opcodes; /* Emit per-opcode trace events? */ + PyObject *f_extra_locals; /* Dict for locals set by users using f_locals, could be NULL */ + /* This is purely for backwards compatibility for PyEval_GetLocals. + PyEval_GetLocals requires a borrowed reference so the actual reference + is stored here */ + PyObject *f_locals_cache; + /* The frame data, if this frame object owns the frame */ + PyObject *_f_frame_data[1]; +}; + +extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code); + + +/* other API */ + +typedef enum _framestate { + FRAME_CREATED = -3, + FRAME_SUSPENDED = -2, + FRAME_SUSPENDED_YIELD_FROM = -1, + FRAME_EXECUTING = 0, + FRAME_COMPLETED = 1, + FRAME_CLEARED = 4 +} PyFrameState; + +#define FRAME_STATE_SUSPENDED(S) ((S) == FRAME_SUSPENDED || (S) == FRAME_SUSPENDED_YIELD_FROM) +#define FRAME_STATE_FINISHED(S) ((S) >= FRAME_COMPLETED) + +enum _frameowner { + FRAME_OWNED_BY_THREAD = 0, + FRAME_OWNED_BY_GENERATOR = 1, + FRAME_OWNED_BY_FRAME_OBJECT = 2, + FRAME_OWNED_BY_CSTACK = 3, +}; + +typedef struct _PyInterpreterFrame { + PyObject *f_executable; /* Strong reference (code object or None) */ + struct _PyInterpreterFrame *previous; + PyObject *f_funcobj; /* Strong reference. Only valid if not on C stack */ + PyObject *f_globals; /* Borrowed reference. Only valid if not on C stack */ + PyObject *f_builtins; /* Borrowed reference. Only valid if not on C stack */ + PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */ + PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */ + _Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to begin) */ + int stacktop; /* Offset of TOS from localsplus */ + uint16_t return_offset; /* Only relevant during a function call */ + char owner; + /* Locals and stack */ + PyObject *localsplus[1]; +} _PyInterpreterFrame; + +#define _PyInterpreterFrame_LASTI(IF) \ + ((int)((IF)->instr_ptr - _PyCode_CODE(_PyFrame_GetCode(IF)))) + +static inline PyCodeObject *_PyFrame_GetCode(_PyInterpreterFrame *f) { + assert(PyCode_Check(f->f_executable)); + return (PyCodeObject *)f->f_executable; +} + +static inline PyObject **_PyFrame_Stackbase(_PyInterpreterFrame *f) { + return f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus; +} + +static inline PyObject *_PyFrame_StackPeek(_PyInterpreterFrame *f) { + assert(f->stacktop > _PyFrame_GetCode(f)->co_nlocalsplus); + assert(f->localsplus[f->stacktop-1] != NULL); + return f->localsplus[f->stacktop-1]; +} + +static inline PyObject *_PyFrame_StackPop(_PyInterpreterFrame *f) { + assert(f->stacktop > _PyFrame_GetCode(f)->co_nlocalsplus); + f->stacktop--; + return f->localsplus[f->stacktop]; +} + +static inline void _PyFrame_StackPush(_PyInterpreterFrame *f, PyObject *value) { + f->localsplus[f->stacktop] = value; + f->stacktop++; +} + +#define FRAME_SPECIALS_SIZE ((int)((sizeof(_PyInterpreterFrame)-1)/sizeof(PyObject *))) + +static inline int +_PyFrame_NumSlotsForCodeObject(PyCodeObject *code) +{ + /* This function needs to remain in sync with the calculation of + * co_framesize in Tools/build/deepfreeze.py */ + assert(code->co_framesize >= FRAME_SPECIALS_SIZE); + return code->co_framesize - FRAME_SPECIALS_SIZE; +} + +static inline void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest) +{ + assert(src->stacktop >= _PyFrame_GetCode(src)->co_nlocalsplus); + *dest = *src; + for (int i = 1; i < src->stacktop; i++) { + dest->localsplus[i] = src->localsplus[i]; + } + // Don't leave a dangling pointer to the old frame when creating generators + // and coroutines: + dest->previous = NULL; +} + +/* Consumes reference to func and locals. + Does not initialize frame->previous, which happens + when frame is linked into the frame stack. + */ +static inline void +_PyFrame_Initialize( + _PyInterpreterFrame *frame, PyFunctionObject *func, + PyObject *locals, PyCodeObject *code, int null_locals_from) +{ + frame->f_funcobj = (PyObject *)func; + frame->f_executable = Py_NewRef(code); + frame->f_builtins = func->func_builtins; + frame->f_globals = func->func_globals; + frame->f_locals = locals; + frame->stacktop = code->co_nlocalsplus; + frame->frame_obj = NULL; + frame->instr_ptr = _PyCode_CODE(code); + frame->return_offset = 0; + frame->owner = FRAME_OWNED_BY_THREAD; + + for (int i = null_locals_from; i < code->co_nlocalsplus; i++) { + frame->localsplus[i] = NULL; + } +} + +/* Gets the pointer to the locals array + * that precedes this frame. + */ +static inline PyObject** +_PyFrame_GetLocalsArray(_PyInterpreterFrame *frame) +{ + return frame->localsplus; +} + +/* Fetches the stack pointer, and sets stacktop to -1. + Having stacktop <= 0 ensures that invalid + values are not visible to the cycle GC. + We choose -1 rather than 0 to assist debugging. */ +static inline PyObject** +_PyFrame_GetStackPointer(_PyInterpreterFrame *frame) +{ + PyObject **sp = frame->localsplus + frame->stacktop; + frame->stacktop = -1; + return sp; +} + +static inline void +_PyFrame_SetStackPointer(_PyInterpreterFrame *frame, PyObject **stack_pointer) +{ + frame->stacktop = (int)(stack_pointer - frame->localsplus); +} + +/* Determine whether a frame is incomplete. + * A frame is incomplete if it is part way through + * creating cell objects or a generator or coroutine. + * + * Frames on the frame stack are incomplete until the + * first RESUME instruction. + * Frames owned by a generator are always complete. + */ +static inline bool +_PyFrame_IsIncomplete(_PyInterpreterFrame *frame) +{ + if (frame->owner == FRAME_OWNED_BY_CSTACK) { + return true; + } + return frame->owner != FRAME_OWNED_BY_GENERATOR && + frame->instr_ptr < _PyCode_CODE(_PyFrame_GetCode(frame)) + _PyFrame_GetCode(frame)->_co_firsttraceable; +} + +static inline _PyInterpreterFrame * +_PyFrame_GetFirstComplete(_PyInterpreterFrame *frame) +{ + while (frame && _PyFrame_IsIncomplete(frame)) { + frame = frame->previous; + } + return frame; +} + +static inline _PyInterpreterFrame * +_PyThreadState_GetFrame(PyThreadState *tstate) +{ + return _PyFrame_GetFirstComplete(tstate->current_frame); +} + +/* For use by _PyFrame_GetFrameObject + Do not call directly. */ +PyFrameObject * +_PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame); + +/* Gets the PyFrameObject for this frame, lazily + * creating it if necessary. + * Returns a borrowed reference */ +static inline PyFrameObject * +_PyFrame_GetFrameObject(_PyInterpreterFrame *frame) +{ + + assert(!_PyFrame_IsIncomplete(frame)); + PyFrameObject *res = frame->frame_obj; + if (res != NULL) { + return res; + } + return _PyFrame_MakeAndSetFrameObject(frame); +} + +void +_PyFrame_ClearLocals(_PyInterpreterFrame *frame); + +/* Clears all references in the frame. + * If take is non-zero, then the _PyInterpreterFrame frame + * may be transferred to the frame object it references + * instead of being cleared. Either way + * the caller no longer owns the references + * in the frame. + * take should be set to 1 for heap allocated + * frames like the ones in generators and coroutines. + */ +void +_PyFrame_ClearExceptCode(_PyInterpreterFrame * frame); + +int +_PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg); + +bool +_PyFrame_HasHiddenLocals(_PyInterpreterFrame *frame); + +PyObject * +_PyFrame_GetLocals(_PyInterpreterFrame *frame); + +static inline bool +_PyThreadState_HasStackSpace(PyThreadState *tstate, int size) +{ + assert( + (tstate->datastack_top == NULL && tstate->datastack_limit == NULL) + || + (tstate->datastack_top != NULL && tstate->datastack_limit != NULL) + ); + return tstate->datastack_top != NULL && + size < tstate->datastack_limit - tstate->datastack_top; +} + +extern _PyInterpreterFrame * +_PyThreadState_PushFrame(PyThreadState *tstate, size_t size); + +PyAPI_FUNC(void) _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFrame *frame); + +/* Pushes a frame without checking for space. + * Must be guarded by _PyThreadState_HasStackSpace() + * Consumes reference to func. */ +static inline _PyInterpreterFrame * +_PyFrame_PushUnchecked(PyThreadState *tstate, PyFunctionObject *func, int null_locals_from) +{ + CALL_STAT_INC(frames_pushed); + PyCodeObject *code = (PyCodeObject *)func->func_code; + _PyInterpreterFrame *new_frame = (_PyInterpreterFrame *)tstate->datastack_top; + tstate->datastack_top += code->co_framesize; + assert(tstate->datastack_top < tstate->datastack_limit); + _PyFrame_Initialize(new_frame, func, NULL, code, null_locals_from); + return new_frame; +} + +/* Pushes a trampoline frame without checking for space. + * Must be guarded by _PyThreadState_HasStackSpace() */ +static inline _PyInterpreterFrame * +_PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int stackdepth) +{ + CALL_STAT_INC(frames_pushed); + _PyInterpreterFrame *frame = (_PyInterpreterFrame *)tstate->datastack_top; + tstate->datastack_top += code->co_framesize; + assert(tstate->datastack_top < tstate->datastack_limit); + frame->f_funcobj = Py_None; + frame->f_executable = Py_NewRef(code); +#ifdef Py_DEBUG + frame->f_builtins = NULL; + frame->f_globals = NULL; +#endif + frame->f_locals = NULL; + frame->stacktop = code->co_nlocalsplus + stackdepth; + frame->frame_obj = NULL; + frame->instr_ptr = _PyCode_CODE(code); + frame->owner = FRAME_OWNED_BY_THREAD; + frame->return_offset = 0; + return frame; +} + +static inline +PyGenObject *_PyFrame_GetGenerator(_PyInterpreterFrame *frame) +{ + assert(frame->owner == FRAME_OWNED_BY_GENERATOR); + size_t offset_in_gen = offsetof(PyGenObject, gi_iframe); + return (PyGenObject *)(((char *)frame) - offset_in_gen); +} + +PyAPI_FUNC(_PyInterpreterFrame *) +_PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func, + PyObject *locals, PyObject* const* args, + size_t argcount, PyObject *kwnames); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_FRAME_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_freelist.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_freelist.h new file mode 100644 index 00000000..e684e084 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_freelist.h @@ -0,0 +1,153 @@ +#ifndef Py_INTERNAL_FREELIST_H +#define Py_INTERNAL_FREELIST_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// PyTuple_MAXSAVESIZE - largest tuple to save on free list +// PyTuple_MAXFREELIST - maximum number of tuples of each size to save + +#ifdef WITH_FREELISTS +// with freelists +# define PyTuple_MAXSAVESIZE 20 +# define PyTuple_NFREELISTS PyTuple_MAXSAVESIZE +# define PyTuple_MAXFREELIST 2000 +# define PyList_MAXFREELIST 80 +# define PyDict_MAXFREELIST 80 +# define PyFloat_MAXFREELIST 100 +# define PyContext_MAXFREELIST 255 +# define _PyAsyncGen_MAXFREELIST 80 +# define _PyObjectStackChunk_MAXFREELIST 4 +#else +# define PyTuple_NFREELISTS 0 +# define PyTuple_MAXFREELIST 0 +# define PyList_MAXFREELIST 0 +# define PyDict_MAXFREELIST 0 +# define PyFloat_MAXFREELIST 0 +# define PyContext_MAXFREELIST 0 +# define _PyAsyncGen_MAXFREELIST 0 +# define _PyObjectStackChunk_MAXFREELIST 0 +#endif + +struct _Py_list_freelist { +#ifdef WITH_FREELISTS + PyListObject *items[PyList_MAXFREELIST]; + int numfree; +#endif +}; + +struct _Py_tuple_freelist { +#if WITH_FREELISTS + /* There is one freelist for each size from 1 to PyTuple_MAXSAVESIZE. + The empty tuple is handled separately. + + Each tuple stored in the array is the head of the linked list + (and the next available tuple) for that size. The actual tuple + object is used as the linked list node, with its first item + (ob_item[0]) pointing to the next node (i.e. the previous head). + Each linked list is initially NULL. */ + PyTupleObject *items[PyTuple_NFREELISTS]; + int numfree[PyTuple_NFREELISTS]; +#else + char _unused; // Empty structs are not allowed. +#endif +}; + +struct _Py_float_freelist { +#ifdef WITH_FREELISTS + /* Special free list + free_list is a singly-linked list of available PyFloatObjects, + linked via abuse of their ob_type members. */ + int numfree; + PyFloatObject *items; +#endif +}; + +struct _Py_dict_freelist { +#ifdef WITH_FREELISTS + /* Dictionary reuse scheme to save calls to malloc and free */ + PyDictObject *items[PyDict_MAXFREELIST]; + int numfree; +#endif +}; + +struct _Py_dictkeys_freelist { +#ifdef WITH_FREELISTS + /* Dictionary keys reuse scheme to save calls to malloc and free */ + PyDictKeysObject *items[PyDict_MAXFREELIST]; + int numfree; +#endif +}; + +struct _Py_slice_freelist { +#ifdef WITH_FREELISTS + /* Using a cache is very effective since typically only a single slice is + created and then deleted again. */ + PySliceObject *slice_cache; +#endif +}; + +struct _Py_context_freelist { +#ifdef WITH_FREELISTS + // List of free PyContext objects + PyContext *items; + int numfree; +#endif +}; + +struct _Py_async_gen_freelist { +#ifdef WITH_FREELISTS + /* Freelists boost performance 6-10%; they also reduce memory + fragmentation, as _PyAsyncGenWrappedValue and PyAsyncGenASend + are short-living objects that are instantiated for every + __anext__() call. */ + struct _PyAsyncGenWrappedValue* items[_PyAsyncGen_MAXFREELIST]; + int numfree; +#endif +}; + +struct _Py_async_gen_asend_freelist { +#ifdef WITH_FREELISTS + struct PyAsyncGenASend* items[_PyAsyncGen_MAXFREELIST]; + int numfree; +#endif +}; + +struct _PyObjectStackChunk; + +struct _Py_object_stack_freelist { + struct _PyObjectStackChunk *items; + Py_ssize_t numfree; +}; + +struct _Py_object_freelists { + struct _Py_float_freelist floats; + struct _Py_tuple_freelist tuples; + struct _Py_list_freelist lists; + struct _Py_dict_freelist dicts; + struct _Py_dictkeys_freelist dictkeys; + struct _Py_slice_freelist slices; + struct _Py_context_freelist contexts; + struct _Py_async_gen_freelist async_gens; + struct _Py_async_gen_asend_freelist async_gen_asends; + struct _Py_object_stack_freelist object_stacks; +}; + +extern void _PyObject_ClearFreeLists(struct _Py_object_freelists *freelists, int is_finalization); +extern void _PyTuple_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); +extern void _PyFloat_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); +extern void _PyList_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); +extern void _PySlice_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); +extern void _PyDict_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); +extern void _PyAsyncGen_ClearFreeLists(struct _Py_object_freelists *freelists, int is_finalization); +extern void _PyContext_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); +extern void _PyObjectStackChunk_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_FREELIST_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_function.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_function.h new file mode 100644 index 00000000..6d44e933 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_function.h @@ -0,0 +1,55 @@ +#ifndef Py_INTERNAL_FUNCTION_H +#define Py_INTERNAL_FUNCTION_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "pycore_lock.h" + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern PyObject* _PyFunction_Vectorcall( + PyObject *func, + PyObject *const *stack, + size_t nargsf, + PyObject *kwnames); + +#define FUNC_MAX_WATCHERS 8 + +#define FUNC_VERSION_CACHE_SIZE (1<<12) /* Must be a power of 2 */ + +struct _func_version_cache_item { + PyFunctionObject *func; + PyObject *code; +}; + +struct _py_func_state { +#ifdef Py_GIL_DISABLED + // Protects next_version + PyMutex mutex; +#endif + + uint32_t next_version; + // Borrowed references to function and code objects whose + // func_version % FUNC_VERSION_CACHE_SIZE + // once was equal to the index in the table. + // They are cleared when the function or code object is deallocated. + struct _func_version_cache_item func_version_cache[FUNC_VERSION_CACHE_SIZE]; +}; + +extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr); + +extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func); +PyAPI_FUNC(void) _PyFunction_SetVersion(PyFunctionObject *func, uint32_t version); +void _PyFunction_ClearCodeByVersion(uint32_t version); +PyFunctionObject *_PyFunction_LookupByVersion(uint32_t version, PyObject **p_code); + +extern PyObject *_Py_set_function_type_params( + PyThreadState* unused, PyObject *func, PyObject *type_params); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_FUNCTION_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_gc.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_gc.h new file mode 100644 index 00000000..357177bc --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_gc.h @@ -0,0 +1,365 @@ +#ifndef Py_INTERNAL_GC_H +#define Py_INTERNAL_GC_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_freelist.h" // _PyFreeListState + +/* GC information is stored BEFORE the object structure. */ +typedef struct { + // Pointer to next object in the list. + // 0 means the object is not tracked + uintptr_t _gc_next; + + // Pointer to previous object in the list. + // Lowest two bits are used for flags documented later. + uintptr_t _gc_prev; +} PyGC_Head; + +#define _PyGC_Head_UNUSED PyGC_Head + + +/* Get an object's GC head */ +static inline PyGC_Head* _Py_AS_GC(PyObject *op) { + char *gc = ((char*)op) - sizeof(PyGC_Head); + return (PyGC_Head*)gc; +} + +/* Get the object given the GC head */ +static inline PyObject* _Py_FROM_GC(PyGC_Head *gc) { + char *op = ((char *)gc) + sizeof(PyGC_Head); + return (PyObject *)op; +} + + +/* Bit flags for ob_gc_bits (in Py_GIL_DISABLED builds) + * + * Setting the bits requires a relaxed store. The per-object lock must also be + * held, except when the object is only visible to a single thread (e.g. during + * object initialization or destruction). + * + * Reading the bits requires using a relaxed load, but does not require holding + * the per-object lock. + */ +#ifdef Py_GIL_DISABLED +# define _PyGC_BITS_TRACKED (1) // Tracked by the GC +# define _PyGC_BITS_FINALIZED (2) // tp_finalize was called +# define _PyGC_BITS_UNREACHABLE (4) +# define _PyGC_BITS_FROZEN (8) +# define _PyGC_BITS_SHARED (16) +# define _PyGC_BITS_SHARED_INLINE (32) +# define _PyGC_BITS_DEFERRED (64) // Use deferred reference counting +#endif + +#ifdef Py_GIL_DISABLED + +static inline void +_PyObject_SET_GC_BITS(PyObject *op, uint8_t new_bits) +{ + uint8_t bits = _Py_atomic_load_uint8_relaxed(&op->ob_gc_bits); + _Py_atomic_store_uint8_relaxed(&op->ob_gc_bits, bits | new_bits); +} + +static inline int +_PyObject_HAS_GC_BITS(PyObject *op, uint8_t bits) +{ + return (_Py_atomic_load_uint8_relaxed(&op->ob_gc_bits) & bits) != 0; +} + +static inline void +_PyObject_CLEAR_GC_BITS(PyObject *op, uint8_t bits_to_clear) +{ + uint8_t bits = _Py_atomic_load_uint8_relaxed(&op->ob_gc_bits); + _Py_atomic_store_uint8_relaxed(&op->ob_gc_bits, bits & ~bits_to_clear); +} + +#endif + +/* True if the object is currently tracked by the GC. */ +static inline int _PyObject_GC_IS_TRACKED(PyObject *op) { +#ifdef Py_GIL_DISABLED + return _PyObject_HAS_GC_BITS(op, _PyGC_BITS_TRACKED); +#else + PyGC_Head *gc = _Py_AS_GC(op); + return (gc->_gc_next != 0); +#endif +} +#define _PyObject_GC_IS_TRACKED(op) _PyObject_GC_IS_TRACKED(_Py_CAST(PyObject*, op)) + +/* True if the object may be tracked by the GC in the future, or already is. + This can be useful to implement some optimizations. */ +static inline int _PyObject_GC_MAY_BE_TRACKED(PyObject *obj) { + if (!PyObject_IS_GC(obj)) { + return 0; + } + if (PyTuple_CheckExact(obj)) { + return _PyObject_GC_IS_TRACKED(obj); + } + return 1; +} + +#ifdef Py_GIL_DISABLED + +/* True if memory the object references is shared between + * multiple threads and needs special purpose when freeing + * those references due to the possibility of in-flight + * lock-free reads occurring. The object is responsible + * for calling _PyMem_FreeDelayed on the referenced + * memory. */ +static inline int _PyObject_GC_IS_SHARED(PyObject *op) { + return _PyObject_HAS_GC_BITS(op, _PyGC_BITS_SHARED); +} +#define _PyObject_GC_IS_SHARED(op) _PyObject_GC_IS_SHARED(_Py_CAST(PyObject*, op)) + +static inline void _PyObject_GC_SET_SHARED(PyObject *op) { + _PyObject_SET_GC_BITS(op, _PyGC_BITS_SHARED); +} +#define _PyObject_GC_SET_SHARED(op) _PyObject_GC_SET_SHARED(_Py_CAST(PyObject*, op)) + +/* True if the memory of the object is shared between multiple + * threads and needs special purpose when freeing due to + * the possibility of in-flight lock-free reads occurring. + * Objects with this bit that are GC objects will automatically + * delay-freed by PyObject_GC_Del. */ +static inline int _PyObject_GC_IS_SHARED_INLINE(PyObject *op) { + return _PyObject_HAS_GC_BITS(op, _PyGC_BITS_SHARED_INLINE); +} +#define _PyObject_GC_IS_SHARED_INLINE(op) \ + _PyObject_GC_IS_SHARED_INLINE(_Py_CAST(PyObject*, op)) + +static inline void _PyObject_GC_SET_SHARED_INLINE(PyObject *op) { + _PyObject_SET_GC_BITS(op, _PyGC_BITS_SHARED_INLINE); +} +#define _PyObject_GC_SET_SHARED_INLINE(op) \ + _PyObject_GC_SET_SHARED_INLINE(_Py_CAST(PyObject*, op)) + +#endif + +/* Bit flags for _gc_prev */ +/* Bit 0 is set when tp_finalize is called */ +#define _PyGC_PREV_MASK_FINALIZED (1) +/* Bit 1 is set when the object is in generation which is GCed currently. */ +#define _PyGC_PREV_MASK_COLLECTING (2) +/* The (N-2) most significant bits contain the real address. */ +#define _PyGC_PREV_SHIFT (2) +#define _PyGC_PREV_MASK (((uintptr_t) -1) << _PyGC_PREV_SHIFT) + +/* set for debugging information */ +#define _PyGC_DEBUG_STATS (1<<0) /* print collection statistics */ +#define _PyGC_DEBUG_COLLECTABLE (1<<1) /* print collectable objects */ +#define _PyGC_DEBUG_UNCOLLECTABLE (1<<2) /* print uncollectable objects */ +#define _PyGC_DEBUG_SAVEALL (1<<5) /* save all garbage in gc.garbage */ +#define _PyGC_DEBUG_LEAK _PyGC_DEBUG_COLLECTABLE | \ + _PyGC_DEBUG_UNCOLLECTABLE | \ + _PyGC_DEBUG_SAVEALL + +typedef enum { + // GC was triggered by heap allocation + _Py_GC_REASON_HEAP, + + // GC was called during shutdown + _Py_GC_REASON_SHUTDOWN, + + // GC was called by gc.collect() or PyGC_Collect() + _Py_GC_REASON_MANUAL +} _PyGC_Reason; + +// Lowest bit of _gc_next is used for flags only in GC. +// But it is always 0 for normal code. +static inline PyGC_Head* _PyGCHead_NEXT(PyGC_Head *gc) { + uintptr_t next = gc->_gc_next; + return (PyGC_Head*)next; +} +static inline void _PyGCHead_SET_NEXT(PyGC_Head *gc, PyGC_Head *next) { + gc->_gc_next = (uintptr_t)next; +} + +// Lowest two bits of _gc_prev is used for _PyGC_PREV_MASK_* flags. +static inline PyGC_Head* _PyGCHead_PREV(PyGC_Head *gc) { + uintptr_t prev = (gc->_gc_prev & _PyGC_PREV_MASK); + return (PyGC_Head*)prev; +} +static inline void _PyGCHead_SET_PREV(PyGC_Head *gc, PyGC_Head *prev) { + uintptr_t uprev = (uintptr_t)prev; + assert((uprev & ~_PyGC_PREV_MASK) == 0); + gc->_gc_prev = ((gc->_gc_prev & ~_PyGC_PREV_MASK) | uprev); +} + +static inline int _PyGC_FINALIZED(PyObject *op) { +#ifdef Py_GIL_DISABLED + return _PyObject_HAS_GC_BITS(op, _PyGC_BITS_FINALIZED); +#else + PyGC_Head *gc = _Py_AS_GC(op); + return ((gc->_gc_prev & _PyGC_PREV_MASK_FINALIZED) != 0); +#endif +} +static inline void _PyGC_SET_FINALIZED(PyObject *op) { +#ifdef Py_GIL_DISABLED + _PyObject_SET_GC_BITS(op, _PyGC_BITS_FINALIZED); +#else + PyGC_Head *gc = _Py_AS_GC(op); + gc->_gc_prev |= _PyGC_PREV_MASK_FINALIZED; +#endif +} +static inline void _PyGC_CLEAR_FINALIZED(PyObject *op) { +#ifdef Py_GIL_DISABLED + _PyObject_CLEAR_GC_BITS(op, _PyGC_BITS_FINALIZED); +#else + PyGC_Head *gc = _Py_AS_GC(op); + gc->_gc_prev &= ~_PyGC_PREV_MASK_FINALIZED; +#endif +} + + +/* GC runtime state */ + +/* If we change this, we need to change the default value in the + signature of gc.collect. */ +#define NUM_GENERATIONS 3 +/* + NOTE: about untracking of mutable objects. + + Certain types of container cannot participate in a reference cycle, and + so do not need to be tracked by the garbage collector. Untracking these + objects reduces the cost of garbage collections. However, determining + which objects may be untracked is not free, and the costs must be + weighed against the benefits for garbage collection. + + There are two possible strategies for when to untrack a container: + + i) When the container is created. + ii) When the container is examined by the garbage collector. + + Tuples containing only immutable objects (integers, strings etc, and + recursively, tuples of immutable objects) do not need to be tracked. + The interpreter creates a large number of tuples, many of which will + not survive until garbage collection. It is therefore not worthwhile + to untrack eligible tuples at creation time. + + Instead, all tuples except the empty tuple are tracked when created. + During garbage collection it is determined whether any surviving tuples + can be untracked. A tuple can be untracked if all of its contents are + already not tracked. Tuples are examined for untracking in all garbage + collection cycles. It may take more than one cycle to untrack a tuple. + + Dictionaries containing only immutable objects also do not need to be + tracked. Dictionaries are untracked when created. If a tracked item is + inserted into a dictionary (either as a key or value), the dictionary + becomes tracked. During a full garbage collection (all generations), + the collector will untrack any dictionaries whose contents are not + tracked. + + The module provides the python function is_tracked(obj), which returns + the CURRENT tracking status of the object. Subsequent garbage + collections may change the tracking status of the object. + + Untracking of certain containers was introduced in issue #4688, and + the algorithm was refined in response to issue #14775. +*/ + +struct gc_generation { + PyGC_Head head; + int threshold; /* collection threshold */ + int count; /* count of allocations or collections of younger + generations */ +}; + +/* Running stats per generation */ +struct gc_generation_stats { + /* total number of collections */ + Py_ssize_t collections; + /* total number of collected objects */ + Py_ssize_t collected; + /* total number of uncollectable objects (put into gc.garbage) */ + Py_ssize_t uncollectable; +}; + +struct _gc_runtime_state { + /* List of objects that still need to be cleaned up, singly linked + * via their gc headers' gc_prev pointers. */ + PyObject *trash_delete_later; + /* Current call-stack depth of tp_dealloc calls. */ + int trash_delete_nesting; + + /* Is automatic collection enabled? */ + int enabled; + int debug; + /* linked lists of container objects */ + struct gc_generation generations[NUM_GENERATIONS]; + PyGC_Head *generation0; + /* a permanent generation which won't be collected */ + struct gc_generation permanent_generation; + struct gc_generation_stats generation_stats[NUM_GENERATIONS]; + /* true if we are currently running the collector */ + int collecting; + /* list of uncollectable objects */ + PyObject *garbage; + /* a list of callbacks to be invoked when collection is performed */ + PyObject *callbacks; + + /* This is the number of objects that survived the last full + collection. It approximates the number of long lived objects + tracked by the GC. + + (by "full collection", we mean a collection of the oldest + generation). */ + Py_ssize_t long_lived_total; + /* This is the number of objects that survived all "non-full" + collections, and are awaiting to undergo a full collection for + the first time. */ + Py_ssize_t long_lived_pending; + +#ifdef Py_GIL_DISABLED + /* gh-117783: Deferred reference counting is not fully implemented yet, so + as a temporary measure we treat objects using deferred reference + counting as immortal. The value may be zero, one, or a negative number: + 0: immortalize deferred RC objects once the first thread is created + 1: immortalize all deferred RC objects immediately + <0: suppressed; don't immortalize objects */ + int immortalize; +#endif +}; + +#ifdef Py_GIL_DISABLED +struct _gc_thread_state { + /* Thread-local allocation count. */ + Py_ssize_t alloc_count; +}; +#endif + + +extern void _PyGC_InitState(struct _gc_runtime_state *); + +extern Py_ssize_t _PyGC_Collect(PyThreadState *tstate, int generation, + _PyGC_Reason reason); +extern void _PyGC_CollectNoFail(PyThreadState *tstate); + +/* Freeze objects tracked by the GC and ignore them in future collections. */ +extern void _PyGC_Freeze(PyInterpreterState *interp); +/* Unfreezes objects placing them in the oldest generation */ +extern void _PyGC_Unfreeze(PyInterpreterState *interp); +/* Number of frozen objects */ +extern Py_ssize_t _PyGC_GetFreezeCount(PyInterpreterState *interp); + +extern PyObject *_PyGC_GetObjects(PyInterpreterState *interp, int generation); +extern PyObject *_PyGC_GetReferrers(PyInterpreterState *interp, PyObject *objs); + +// Functions to clear types free lists +extern void _PyGC_ClearAllFreeLists(PyInterpreterState *interp); +extern void _Py_ScheduleGC(PyThreadState *tstate); +extern void _Py_RunGC(PyThreadState *tstate); + +#ifdef Py_GIL_DISABLED +// gh-117783: Immortalize objects that use deferred reference counting +extern void _PyGC_ImmortalizeDeferredObjects(PyInterpreterState *interp); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_GC_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_genobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_genobject.h new file mode 100644 index 00000000..9463c822 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_genobject.h @@ -0,0 +1,32 @@ +#ifndef Py_INTERNAL_GENOBJECT_H +#define Py_INTERNAL_GENOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_freelist.h" + +PyAPI_FUNC(PyObject *)_PyGen_yf(PyGenObject *); +extern void _PyGen_Finalize(PyObject *self); + +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *); + +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **); + +PyAPI_FUNC(PyObject *)_PyCoro_GetAwaitableIter(PyObject *o); +extern PyObject *_PyAsyncGenValueWrapperNew(PyThreadState *state, PyObject *); + +extern PyTypeObject _PyCoroWrapper_Type; +extern PyTypeObject _PyAsyncGenWrappedValue_Type; +extern PyTypeObject _PyAsyncGenAThrow_Type; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_GENOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_getopt.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_getopt.h new file mode 100644 index 00000000..7f0dd13a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_getopt.h @@ -0,0 +1,22 @@ +#ifndef Py_INTERNAL_PYGETOPT_H +#define Py_INTERNAL_PYGETOPT_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern int _PyOS_opterr; +extern Py_ssize_t _PyOS_optind; +extern const wchar_t *_PyOS_optarg; + +extern void _PyOS_ResetGetOpt(void); + +typedef struct { + const wchar_t *name; + int has_arg; + int val; +} _PyOS_LongOption; + +extern int _PyOS_GetOpt(Py_ssize_t argc, wchar_t * const *argv, int *longindex); + +#endif /* !Py_INTERNAL_PYGETOPT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_gil.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_gil.h new file mode 100644 index 00000000..a2de5077 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_gil.h @@ -0,0 +1,66 @@ +#ifndef Py_INTERNAL_GIL_H +#define Py_INTERNAL_GIL_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_condvar.h" // PyCOND_T + +#ifndef Py_HAVE_CONDVAR +# error You need either a POSIX-compatible or a Windows system! +#endif + +/* Enable if you want to force the switching of threads at least + every `interval`. */ +#undef FORCE_SWITCHING +#define FORCE_SWITCHING + +struct _gil_runtime_state { +#ifdef Py_GIL_DISABLED + /* If this GIL is disabled, enabled == 0. + + If this GIL is enabled transiently (most likely to initialize a module + of unknown safety), enabled indicates the number of active transient + requests. + + If this GIL is enabled permanently, enabled == INT_MAX. + + It must not be modified directly; use _PyEval_EnableGILTransiently(), + _PyEval_EnableGILPermanently(), and _PyEval_DisableGIL() + + It is always read and written atomically, but a thread can assume its + value will be stable as long as that thread is attached or knows that no + other threads are attached (e.g., during a stop-the-world.). */ + int enabled; +#endif + /* microseconds (the Python API uses seconds, though) */ + unsigned long interval; + /* Last PyThreadState holding / having held the GIL. This helps us + know whether anyone else was scheduled after we dropped the GIL. */ + PyThreadState* last_holder; + /* Whether the GIL is already taken (-1 if uninitialized). This is + atomic because it can be read without any lock taken in ceval.c. */ + int locked; + /* Number of GIL switches since the beginning. */ + unsigned long switch_number; + /* This condition variable allows one or several threads to wait + until the GIL is released. In addition, the mutex also protects + the above variables. */ + PyCOND_T cond; + PyMUTEX_T mutex; +#ifdef FORCE_SWITCHING + /* This condition variable helps the GIL-releasing thread wait for + a GIL-awaiting thread to be scheduled and take the GIL. */ + PyCOND_T switch_cond; + PyMUTEX_T switch_mutex; +#endif +}; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_GIL_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_global_objects.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_global_objects.h new file mode 100644 index 00000000..9d376e7d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_global_objects.h @@ -0,0 +1,105 @@ +#ifndef Py_INTERNAL_GLOBAL_OBJECTS_H +#define Py_INTERNAL_GLOBAL_OBJECTS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_context.h" // _PyContextTokenMissing +#include "pycore_gc.h" // _PyGC_Head_UNUSED +#include "pycore_global_strings.h" // struct _Py_global_strings +#include "pycore_hamt.h" // PyHamtNode_Bitmap +#include "pycore_hashtable.h" // _Py_hashtable_t +#include "pycore_typeobject.h" // pytype_slotdef + + +// These would be in pycore_long.h if it weren't for an include cycle. +#define _PY_NSMALLPOSINTS 257 +#define _PY_NSMALLNEGINTS 5 + + +// Only immutable objects should be considered runtime-global. +// All others must be per-interpreter. + +#define _Py_GLOBAL_OBJECT(NAME) \ + _PyRuntime.static_objects.NAME +#define _Py_SINGLETON(NAME) \ + _Py_GLOBAL_OBJECT(singletons.NAME) + +struct _Py_cached_objects { + // XXX We could statically allocate the hashtable. + _Py_hashtable_t *interned_strings; +}; + +struct _Py_static_objects { + struct { + /* Small integers are preallocated in this array so that they + * can be shared. + * The integers that are preallocated are those in the range + * -_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (exclusive). + */ + PyLongObject small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS]; + + PyBytesObject bytes_empty; + struct { + PyBytesObject ob; + char eos; + } bytes_characters[256]; + + struct _Py_global_strings strings; + + _PyGC_Head_UNUSED _tuple_empty_gc_not_used; + PyTupleObject tuple_empty; + + _PyGC_Head_UNUSED _hamt_bitmap_node_empty_gc_not_used; + PyHamtNode_Bitmap hamt_bitmap_node_empty; + _PyContextTokenMissing context_token_missing; + } singletons; +}; + +#define _Py_INTERP_CACHED_OBJECT(interp, NAME) \ + (interp)->cached_objects.NAME + +struct _Py_interp_cached_objects { + PyObject *interned_strings; + + /* AST */ + PyObject *_unused_str_replace_inf; // kept in 3.13 for ABI compatibility + + /* object.__reduce__ */ + PyObject *objreduce; + PyObject *type_slots_pname; + pytype_slotdef *type_slots_ptrs[MAX_EQUIV]; + + /* TypeVar and related types */ + PyTypeObject *generic_type; + PyTypeObject *typevar_type; + PyTypeObject *typevartuple_type; + PyTypeObject *paramspec_type; + PyTypeObject *paramspecargs_type; + PyTypeObject *paramspeckwargs_type; +}; + +#define _Py_INTERP_STATIC_OBJECT(interp, NAME) \ + (interp)->static_objects.NAME +#define _Py_INTERP_SINGLETON(interp, NAME) \ + _Py_INTERP_STATIC_OBJECT(interp, singletons.NAME) + +struct _Py_interp_static_objects { + struct { + int _not_used; + // hamt_empty is here instead of global because of its weakreflist. + _PyGC_Head_UNUSED _hamt_empty_gc_not_used; + PyHamtObject hamt_empty; + PyBaseExceptionObject last_resort_memory_error; + } singletons; +}; + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_GLOBAL_OBJECTS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_global_objects_fini_generated.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_global_objects_fini_generated.h new file mode 100644 index 00000000..cd56ffde --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_global_objects_fini_generated.h @@ -0,0 +1,1554 @@ +#ifndef Py_INTERNAL_GLOBAL_OBJECTS_FINI_GENERATED_INIT_H +#define Py_INTERNAL_GLOBAL_OBJECTS_FINI_GENERATED_INIT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#ifdef Py_DEBUG +static inline void +_PyStaticObject_CheckRefcnt(PyObject *obj) { + if (Py_REFCNT(obj) < _Py_IMMORTAL_REFCNT) { + fprintf(stderr, "Immortal Object has less refcnt than expected.\n"); + _PyObject_Dump(obj); + } +} +#endif + +/* The following is auto-generated by Tools/build/generate_global_objects.py. */ +#ifdef Py_DEBUG +static inline void +_PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { + /* generated runtime-global */ + // (see pycore_runtime_init_generated.h) + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + -5]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + -4]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + -3]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + -2]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + -1]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 0]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 1]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 2]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 3]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 4]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 5]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 6]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 7]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 8]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 9]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 10]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 11]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 12]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 13]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 14]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 15]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 16]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 17]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 18]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 19]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 20]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 21]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 22]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 23]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 24]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 25]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 26]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 27]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 28]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 29]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 30]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 31]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 32]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 33]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 34]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 35]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 36]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 37]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 38]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 39]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 40]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 41]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 42]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 43]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 44]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 45]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 46]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 47]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 48]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 49]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 50]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 51]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 52]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 53]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 54]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 55]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 56]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 57]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 58]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 59]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 60]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 61]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 62]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 63]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 64]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 65]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 66]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 67]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 68]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 69]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 70]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 71]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 72]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 73]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 74]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 75]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 76]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 77]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 78]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 79]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 80]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 81]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 82]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 83]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 84]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 85]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 86]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 87]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 88]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 89]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 90]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 91]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 92]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 93]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 94]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 95]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 96]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 97]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 98]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 99]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 100]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 101]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 102]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 103]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 104]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 105]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 106]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 107]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 108]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 109]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 110]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 111]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 112]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 113]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 114]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 115]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 116]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 117]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 118]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 119]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 120]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 121]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 122]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 123]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 124]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 125]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 126]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 127]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 129]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 130]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 131]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 132]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 133]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 134]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 135]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 136]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 137]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 138]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 139]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 140]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 141]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 142]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 143]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 144]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 145]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 146]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 147]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 148]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 149]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 150]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 151]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 152]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 153]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 154]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 155]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 156]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 157]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 158]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 159]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 160]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 161]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 162]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 163]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 164]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 165]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 166]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 167]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 168]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 169]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 170]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 171]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 172]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 173]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 174]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 175]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 176]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 177]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 178]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 179]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 180]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 181]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 182]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 183]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 184]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 185]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 186]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 187]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 188]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 189]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 190]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 191]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 192]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 193]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 194]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 195]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 196]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 197]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 198]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 199]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 200]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 201]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 202]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 203]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 204]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 205]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 206]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 207]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 208]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 209]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 210]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 211]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 212]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 213]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 214]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 215]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 216]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 217]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 218]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 219]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 220]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 221]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 222]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 223]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 224]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 225]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 226]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 227]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 228]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 229]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 230]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 231]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 232]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 233]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 234]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 235]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 236]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 237]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 238]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 239]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 240]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 241]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 242]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 243]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 244]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 245]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 246]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 247]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 248]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 249]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 250]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 251]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 252]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 253]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 254]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 255]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + 256]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[0]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[1]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[2]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[3]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[4]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[5]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[6]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[7]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[8]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[9]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[10]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[11]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[12]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[13]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[14]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[15]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[16]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[17]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[18]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[19]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[20]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[21]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[22]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[23]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[24]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[25]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[26]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[27]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[28]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[29]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[30]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[31]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[32]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[33]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[34]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[35]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[36]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[37]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[38]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[39]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[40]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[41]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[42]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[43]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[44]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[45]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[46]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[47]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[48]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[49]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[50]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[51]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[52]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[53]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[54]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[55]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[56]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[57]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[58]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[59]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[60]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[61]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[62]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[63]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[64]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[65]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[66]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[67]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[68]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[69]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[70]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[71]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[72]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[73]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[74]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[75]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[76]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[77]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[78]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[79]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[80]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[81]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[82]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[83]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[84]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[85]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[86]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[87]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[88]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[89]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[90]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[91]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[92]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[93]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[94]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[95]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[96]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[97]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[98]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[99]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[100]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[101]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[102]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[103]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[104]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[105]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[106]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[107]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[108]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[109]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[110]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[111]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[112]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[113]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[114]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[115]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[116]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[117]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[118]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[119]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[120]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[121]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[122]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[123]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[124]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[125]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[126]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[127]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[129]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[130]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[131]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[132]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[133]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[134]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[135]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[136]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[137]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[138]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[139]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[140]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[141]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[142]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[143]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[144]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[145]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[146]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[147]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[148]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[149]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[150]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[151]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[152]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[153]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[154]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[155]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[156]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[157]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[158]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[159]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[160]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[161]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[162]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[163]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[164]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[165]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[166]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[167]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[168]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[169]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[170]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[171]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[172]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[173]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[174]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[175]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[176]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[177]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[178]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[179]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[180]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[181]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[182]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[183]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[184]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[185]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[186]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[187]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[188]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[189]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[190]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[191]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[192]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[193]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[194]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[195]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[196]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[197]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[198]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[199]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[200]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[201]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[202]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[203]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[204]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[205]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[206]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[207]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[208]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[209]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[210]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[211]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[212]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[213]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[214]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[215]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[216]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[217]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[218]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[219]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[220]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[221]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[222]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[223]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[224]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[225]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[226]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[227]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[228]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[229]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[230]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[231]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[232]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[233]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[234]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[235]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[236]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[237]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[238]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[239]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[240]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[241]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[242]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[243]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[244]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[245]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[246]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[247]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[248]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[249]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[250]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[251]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[252]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[253]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[254]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_characters)[255]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_dictcomp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_genexpr)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_lambda)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_listcomp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_module)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_null)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_setcomp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_string)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_unknown)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_close_br)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_open_br)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_percent)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(defaults)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dot_locals)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(empty)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(generic_base)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(json_decoder)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(kwdefaults)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(list_err)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(str_replace_inf)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(type_params)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(utf_8)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(CANCELLED)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(FINISHED)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(False)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(JSONDecodeError)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(PENDING)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(Py_Repr)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(TextIOWrapper)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(True)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(WarningMessage)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_WindowsConsoleIO)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__IOBase_closed)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__abc_tpflags__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__abs__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__abstractmethods__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__add__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__aenter__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__aexit__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__aiter__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__all__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__and__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__anext__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__annotations__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__args__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__await__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__bases__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__bool__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__buffer__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__build_class__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__builtins__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__bytes__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__call__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__cantrace__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__class__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__class_getitem__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__classcell__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__classdict__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__classdictcell__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__complex__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__contains__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__copy__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ctypes_from_outparam__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__del__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__delattr__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__delete__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__delitem__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__dict__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__dictoffset__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__dir__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__divmod__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__doc__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__enter__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__eq__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__exit__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__file__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__firstlineno__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__float__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__floordiv__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__format__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__fspath__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ge__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__get__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getattr__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getattribute__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getinitargs__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getitem__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getnewargs__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getnewargs_ex__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getstate__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__gt__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__hash__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__iadd__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__iand__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ifloordiv__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ilshift__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__imatmul__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__imod__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__import__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__imul__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__index__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__init__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__init_subclass__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__instancecheck__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__int__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__invert__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ior__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ipow__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__irshift__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__isabstractmethod__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__isub__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__iter__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__itruediv__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ixor__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__le__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__len__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__length_hint__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__lltrace__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__loader__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__lshift__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__lt__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__main__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__match_args__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__matmul__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__missing__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__mod__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__module__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__mro_entries__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__mul__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__name__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ne__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__neg__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__new__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__newobj__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__newobj_ex__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__next__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__notes__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__or__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__orig_class__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__origin__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__package__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__parameters__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__path__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__pos__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__pow__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__prepare__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__qualname__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__radd__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rand__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rdivmod__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__reduce__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__reduce_ex__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__release_buffer__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__repr__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__reversed__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rfloordiv__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rlshift__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rmatmul__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rmod__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rmul__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__ror__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__round__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rpow__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rrshift__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rshift__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rsub__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rtruediv__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__rxor__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__set__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__set_name__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__setattr__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__setitem__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__setstate__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__sizeof__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__slotnames__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__slots__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__spec__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__static_attributes__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__str__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__sub__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__subclasscheck__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__subclasshook__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__truediv__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__trunc__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__type_params__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_is_unpacked_typevartuple__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_prepare_subst__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_subst__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_unpacked_tuple_args__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__warningregistry__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__weaklistoffset__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__weakref__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__xor__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_abc_impl)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_abstract_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_active)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_align_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_annotation)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_anonymous_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_argtypes_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_as_parameter_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_asyncio_future_blocking)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_blksize)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_bootstrap)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_check_retval_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_dealloc_warn)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_feature_version)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_field_types)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_fields_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_finalizing)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_find_and_load)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_fix_up_module)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_flags_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_get_sourcefile)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_handle_fromlist)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_initializing)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_io)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_is_text_encoding)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_length_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_limbo)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_lock_unlock_module)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_loop)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_needs_com_addref_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_only_immortal)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_pack_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_restype_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_showwarnmsg)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_shutdown)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_slotnames)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_strptime)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_strptime_datetime)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_swappedbytes_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_type_)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_uninitialized_submodules)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_warn_unawaited_coroutine)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_xoptions)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(abs_tol)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(access)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(aclose)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(add)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(add_done_callback)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(after_in_child)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(after_in_parent)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(aggregate_class)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(alias)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(allow_code)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(append)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arg)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(argdefs)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(args)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arguments)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(argv)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(as_integer_ratio)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(asend)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ast)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(athrow)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(attribute)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(authorizer_callback)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(autocommit)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(backtick)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(base)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(before)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(big)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(binary_form)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(block)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(bound)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(buffer)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(buffer_callback)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(buffer_size)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(buffering)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(buffers)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(bufsize)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(builtins)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(byteorder)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(bytes)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(bytes_per_sep)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(c_call)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(c_exception)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(c_return)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cached_datetime_module)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cached_statements)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cadata)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cafile)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(call)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(call_exception_handler)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(call_soon)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(callback)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cancel)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(capath)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(category)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cb_type)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(certfile)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(check_same_thread)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(clear)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(close)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(closed)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(closefd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(closure)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_argcount)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_cellvars)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_code)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_consts)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_exceptiontable)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_filename)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_firstlineno)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_flags)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_freevars)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_kwonlyargcount)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_linetable)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_name)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_names)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_nlocals)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_posonlyargcount)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_qualname)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_stacksize)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(co_varnames)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(code)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(col_offset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(command)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(comment_factory)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(compile_mode)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(consts)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(context)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(contravariant)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cookie)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(copy)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(copyreg)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(coro)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(count)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(covariant)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cwd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(data)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(database)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(day)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(decode)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(decoder)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(default)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(defaultaction)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(delete)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(depth)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(desired_access)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(detect_types)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(deterministic)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(device)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dict)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dictcomp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(difference_update)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(digest)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(digest_size)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(digestmod)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dir_fd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(discard)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dispatch_table)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(displayhook)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dklen)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(doc)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dont_inherit)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dst)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dst_dir_fd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(eager_start)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(effective_ids)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(element_factory)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(encode)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(encoding)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end_col_offset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end_lineno)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end_offset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(endpos)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(entrypoint)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(env)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(errors)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(event)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(eventmask)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(exc_type)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(exc_value)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(excepthook)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(exception)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(existing_file_name)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(exp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(extend)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(extra_tokens)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(facility)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(factory)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(false)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(family)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fanout)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fd2)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fdel)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fget)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(file)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(file_actions)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(filename)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fileno)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(filepath)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fillvalue)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(filter)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(filters)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(final)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(find_class)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fix_imports)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(flags)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(flush)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fold)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(follow_symlinks)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(format)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(from_param)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fromlist)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fromtimestamp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fromutc)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(func)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(future)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(generation)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(genexpr)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(get)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(get_debug)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(get_event_loop)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(get_loop)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(get_source)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(getattr)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(getstate)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(gid)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(globals)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(groupindex)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(groups)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(handle)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(handle_seq)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(has_location)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(hash_name)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(header)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(headers)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(hi)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(hook)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(hour)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ident)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(identity_hint)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ignore)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(imag)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(importlib)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(in_fd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(incoming)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(indexgroup)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(inf)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(infer_variance)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(inherit_handle)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(inheritable)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(initial)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(initial_bytes)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(initial_owner)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(initial_state)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(initial_value)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(initval)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(inner_size)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(input)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(insert_comments)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(insert_pis)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(instructions)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(intern)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(intersection)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(interval)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(is_running)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(isatty)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(isinstance)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(isoformat)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(isolation_level)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(istext)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(item)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(items)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(iter)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(iterable)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(iterations)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(join)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(jump)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(keepends)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(key)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(keyfile)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(keys)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(kind)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(kw)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(kw1)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(kw2)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(kwdefaults)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(label)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(lambda)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(last)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(last_exc)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(last_node)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(last_traceback)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(last_type)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(last_value)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(latin1)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(leaf_size)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(len)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(length)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(level)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(limit)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(line)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(line_buffering)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(lineno)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(listcomp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(little)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(lo)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(locale)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(locals)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(logoption)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(loop)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(manual_reset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mapping)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(match)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(max_length)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxdigits)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxevents)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxlen)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxmem)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxsplit)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxvalue)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(memLevel)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(memlimit)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(message)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(metaclass)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(metadata)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(method)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(microsecond)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(milliseconds)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(minute)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mod)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mode)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(module)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(module_globals)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(modules)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(month)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mro)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(msg)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mutex)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mycmp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_arg)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_fields)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_sequence_fields)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(n_unnamed_fields)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(name)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(name_from)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(namespace_separator)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(namespaces)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(narg)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ndigits)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(nested)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(new_file_name)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(new_limit)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(newline)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(newlines)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(next)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(nlocals)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(node_depth)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(node_offset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ns)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(nstype)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(nt)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(null)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(number)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(obj)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(object)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(offset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(offset_dst)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(offset_src)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(on_type_read)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(onceregistry)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(only_keys)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(oparg)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(opcode)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(open)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(opener)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(operation)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(optimize)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(options)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(order)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(origin)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(out_fd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(outgoing)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(overlapped)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(owner)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(pages)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(parent)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(password)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(path)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(pattern)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(peek)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(persistent_id)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(persistent_load)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(person)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(pi_factory)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(pid)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(policy)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(pos)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(pos1)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(pos2)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(posix)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(print_file_and_line)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(priority)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(progress)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(progress_handler)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(progress_routine)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(proto)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(protocol)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ps1)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ps2)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(query)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(quotetabs)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(raw)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(read)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(read1)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(readable)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(readall)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(readinto)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(readinto1)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(readline)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(readonly)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(real)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reducer_override)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(registry)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(rel_tol)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(release)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reload)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(repl)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(replace)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reserved)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(resetids)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(return)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reverse)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reversed)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(salt)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sched_priority)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(scheduler)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(second)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(security_attributes)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(seek)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(seekable)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(selectors)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(self)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(send)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sep)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sequence)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(server_hostname)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(server_side)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(session)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(setcomp)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(setpgroup)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(setsid)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(setsigdef)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(setsigmask)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(setstate)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(shape)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(show_cmd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(signed)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(size)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sizehint)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(skip_file_prefixes)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sleep)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sock)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sort)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(source)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(source_traceback)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(spam)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(src)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(src_dir_fd)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(stacklevel)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(start)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(statement)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(status)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(stderr)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(stdin)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(stdout)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(step)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(steps)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(store_name)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(strategy)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(strftime)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(strict)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(strict_mode)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(string)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sub_key)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(symmetric_difference_update)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tabsize)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tag)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(target)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(target_is_directory)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(task)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tb_frame)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tb_lasti)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tb_lineno)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tb_next)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tell)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(template)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(term)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(text)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(threading)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(throw)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(timeout)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(times)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(timetuple)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(top)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(trace_callback)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(traceback)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(trailers)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(translate)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(true)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(truncate)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(twice)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(txt)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(type)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(type_params)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tz)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tzinfo)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tzname)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(uid)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(unlink)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(unraisablehook)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(uri)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(usedforsecurity)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(value)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(values)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(version)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(volume)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(wait_all)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(warn_on_full_buffer)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(warnings)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(warnoptions)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(wbits)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(week)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(weekday)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(which)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(who)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(withdata)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(writable)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(write)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(write_through)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(year)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(zdict)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[0]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[1]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[2]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[3]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[4]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[5]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[6]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[7]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[8]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[9]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[10]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[11]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[12]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[13]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[14]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[15]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[16]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[17]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[18]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[19]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[20]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[21]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[22]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[23]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[24]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[25]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[26]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[27]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[28]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[29]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[30]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[31]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[32]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[33]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[34]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[35]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[36]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[37]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[38]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[39]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[40]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[41]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[42]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[43]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[44]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[45]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[46]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[47]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[48]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[49]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[50]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[51]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[52]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[53]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[54]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[55]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[56]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[57]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[58]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[59]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[60]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[61]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[62]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[63]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[64]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[65]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[66]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[67]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[68]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[69]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[70]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[71]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[72]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[73]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[74]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[75]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[76]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[77]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[78]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[79]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[80]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[81]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[82]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[83]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[84]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[85]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[86]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[87]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[88]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[89]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[90]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[91]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[92]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[93]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[94]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[95]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[96]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[97]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[98]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[99]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[100]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[101]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[102]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[103]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[104]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[105]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[106]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[107]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[108]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[109]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[110]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[111]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[112]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[113]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[114]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[115]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[116]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[117]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[118]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[119]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[120]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[121]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[122]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[123]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[124]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[125]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[126]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).ascii[127]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[128 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[129 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[130 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[131 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[132 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[133 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[134 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[135 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[136 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[137 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[138 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[139 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[140 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[141 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[142 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[143 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[144 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[145 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[146 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[147 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[148 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[149 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[150 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[151 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[152 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[153 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[154 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[155 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[156 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[157 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[158 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[159 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[160 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[161 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[162 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[163 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[164 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[165 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[166 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[167 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[168 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[169 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[170 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[171 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[172 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[173 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[174 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[175 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[176 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[177 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[178 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[179 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[180 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[181 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[182 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[183 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[184 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[185 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[186 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[187 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[188 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[189 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[190 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[191 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[192 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[193 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[194 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[195 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[196 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[197 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[198 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[199 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[200 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[201 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[202 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[203 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[204 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[205 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[206 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[207 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[208 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[209 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[210 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[211 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[212 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[213 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[214 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[215 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[216 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[217 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[218 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[219 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[220 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[221 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[222 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[223 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[224 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[225 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[226 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[227 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[228 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[229 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[230 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[231 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[232 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[233 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[234 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[235 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[236 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[237 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[238 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[239 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[240 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[241 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[242 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[243 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[244 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[245 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[246 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[247 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[248 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[249 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[250 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[251 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[252 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[253 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[254 - 128]); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(strings).latin1[255 - 128]); + /* non-generated */ + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(bytes_empty)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(tuple_empty)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(hamt_bitmap_node_empty)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_INTERP_SINGLETON(interp, hamt_empty)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_SINGLETON(context_token_missing)); +} +#endif // Py_DEBUG +/* End auto-generated code */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_GLOBAL_OBJECTS_FINI_GENERATED_INIT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_global_strings.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_global_strings.h new file mode 100644 index 00000000..cad2d1a8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_global_strings.h @@ -0,0 +1,814 @@ +#ifndef Py_INTERNAL_GLOBAL_STRINGS_H +#define Py_INTERNAL_GLOBAL_STRINGS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// The data structure & init here are inspired by Tools/build/deepfreeze.py. + +// All field names generated by ASCII_STR() have a common prefix, +// to help avoid collisions with keywords, macros, etc. + +#define STRUCT_FOR_ASCII_STR(LITERAL) \ + struct { \ + PyASCIIObject _ascii; \ + uint8_t _data[sizeof(LITERAL)]; \ + } +#define STRUCT_FOR_STR(NAME, LITERAL) \ + STRUCT_FOR_ASCII_STR(LITERAL) _py_ ## NAME; +#define STRUCT_FOR_ID(NAME) \ + STRUCT_FOR_ASCII_STR(#NAME) _py_ ## NAME; + +// XXX Order by frequency of use? + +/* The following is auto-generated by Tools/build/generate_global_objects.py. */ +struct _Py_global_strings { + struct { + STRUCT_FOR_STR(anon_dictcomp, "") + STRUCT_FOR_STR(anon_genexpr, "") + STRUCT_FOR_STR(anon_lambda, "") + STRUCT_FOR_STR(anon_listcomp, "") + STRUCT_FOR_STR(anon_module, "") + STRUCT_FOR_STR(anon_null, "") + STRUCT_FOR_STR(anon_setcomp, "") + STRUCT_FOR_STR(anon_string, "") + STRUCT_FOR_STR(anon_unknown, "") + STRUCT_FOR_STR(dbl_close_br, "}}") + STRUCT_FOR_STR(dbl_open_br, "{{") + STRUCT_FOR_STR(dbl_percent, "%%") + STRUCT_FOR_STR(defaults, ".defaults") + STRUCT_FOR_STR(dot_locals, ".") + STRUCT_FOR_STR(empty, "") + STRUCT_FOR_STR(generic_base, ".generic_base") + STRUCT_FOR_STR(json_decoder, "json.decoder") + STRUCT_FOR_STR(kwdefaults, ".kwdefaults") + STRUCT_FOR_STR(list_err, "list index out of range") + STRUCT_FOR_STR(str_replace_inf, "1e309") + STRUCT_FOR_STR(type_params, ".type_params") + STRUCT_FOR_STR(utf_8, "utf-8") + } literals; + + struct { + STRUCT_FOR_ID(CANCELLED) + STRUCT_FOR_ID(FINISHED) + STRUCT_FOR_ID(False) + STRUCT_FOR_ID(JSONDecodeError) + STRUCT_FOR_ID(PENDING) + STRUCT_FOR_ID(Py_Repr) + STRUCT_FOR_ID(TextIOWrapper) + STRUCT_FOR_ID(True) + STRUCT_FOR_ID(WarningMessage) + STRUCT_FOR_ID(_WindowsConsoleIO) + STRUCT_FOR_ID(__IOBase_closed) + STRUCT_FOR_ID(__abc_tpflags__) + STRUCT_FOR_ID(__abs__) + STRUCT_FOR_ID(__abstractmethods__) + STRUCT_FOR_ID(__add__) + STRUCT_FOR_ID(__aenter__) + STRUCT_FOR_ID(__aexit__) + STRUCT_FOR_ID(__aiter__) + STRUCT_FOR_ID(__all__) + STRUCT_FOR_ID(__and__) + STRUCT_FOR_ID(__anext__) + STRUCT_FOR_ID(__annotations__) + STRUCT_FOR_ID(__args__) + STRUCT_FOR_ID(__await__) + STRUCT_FOR_ID(__bases__) + STRUCT_FOR_ID(__bool__) + STRUCT_FOR_ID(__buffer__) + STRUCT_FOR_ID(__build_class__) + STRUCT_FOR_ID(__builtins__) + STRUCT_FOR_ID(__bytes__) + STRUCT_FOR_ID(__call__) + STRUCT_FOR_ID(__cantrace__) + STRUCT_FOR_ID(__class__) + STRUCT_FOR_ID(__class_getitem__) + STRUCT_FOR_ID(__classcell__) + STRUCT_FOR_ID(__classdict__) + STRUCT_FOR_ID(__classdictcell__) + STRUCT_FOR_ID(__complex__) + STRUCT_FOR_ID(__contains__) + STRUCT_FOR_ID(__copy__) + STRUCT_FOR_ID(__ctypes_from_outparam__) + STRUCT_FOR_ID(__del__) + STRUCT_FOR_ID(__delattr__) + STRUCT_FOR_ID(__delete__) + STRUCT_FOR_ID(__delitem__) + STRUCT_FOR_ID(__dict__) + STRUCT_FOR_ID(__dictoffset__) + STRUCT_FOR_ID(__dir__) + STRUCT_FOR_ID(__divmod__) + STRUCT_FOR_ID(__doc__) + STRUCT_FOR_ID(__enter__) + STRUCT_FOR_ID(__eq__) + STRUCT_FOR_ID(__exit__) + STRUCT_FOR_ID(__file__) + STRUCT_FOR_ID(__firstlineno__) + STRUCT_FOR_ID(__float__) + STRUCT_FOR_ID(__floordiv__) + STRUCT_FOR_ID(__format__) + STRUCT_FOR_ID(__fspath__) + STRUCT_FOR_ID(__ge__) + STRUCT_FOR_ID(__get__) + STRUCT_FOR_ID(__getattr__) + STRUCT_FOR_ID(__getattribute__) + STRUCT_FOR_ID(__getinitargs__) + STRUCT_FOR_ID(__getitem__) + STRUCT_FOR_ID(__getnewargs__) + STRUCT_FOR_ID(__getnewargs_ex__) + STRUCT_FOR_ID(__getstate__) + STRUCT_FOR_ID(__gt__) + STRUCT_FOR_ID(__hash__) + STRUCT_FOR_ID(__iadd__) + STRUCT_FOR_ID(__iand__) + STRUCT_FOR_ID(__ifloordiv__) + STRUCT_FOR_ID(__ilshift__) + STRUCT_FOR_ID(__imatmul__) + STRUCT_FOR_ID(__imod__) + STRUCT_FOR_ID(__import__) + STRUCT_FOR_ID(__imul__) + STRUCT_FOR_ID(__index__) + STRUCT_FOR_ID(__init__) + STRUCT_FOR_ID(__init_subclass__) + STRUCT_FOR_ID(__instancecheck__) + STRUCT_FOR_ID(__int__) + STRUCT_FOR_ID(__invert__) + STRUCT_FOR_ID(__ior__) + STRUCT_FOR_ID(__ipow__) + STRUCT_FOR_ID(__irshift__) + STRUCT_FOR_ID(__isabstractmethod__) + STRUCT_FOR_ID(__isub__) + STRUCT_FOR_ID(__iter__) + STRUCT_FOR_ID(__itruediv__) + STRUCT_FOR_ID(__ixor__) + STRUCT_FOR_ID(__le__) + STRUCT_FOR_ID(__len__) + STRUCT_FOR_ID(__length_hint__) + STRUCT_FOR_ID(__lltrace__) + STRUCT_FOR_ID(__loader__) + STRUCT_FOR_ID(__lshift__) + STRUCT_FOR_ID(__lt__) + STRUCT_FOR_ID(__main__) + STRUCT_FOR_ID(__match_args__) + STRUCT_FOR_ID(__matmul__) + STRUCT_FOR_ID(__missing__) + STRUCT_FOR_ID(__mod__) + STRUCT_FOR_ID(__module__) + STRUCT_FOR_ID(__mro_entries__) + STRUCT_FOR_ID(__mul__) + STRUCT_FOR_ID(__name__) + STRUCT_FOR_ID(__ne__) + STRUCT_FOR_ID(__neg__) + STRUCT_FOR_ID(__new__) + STRUCT_FOR_ID(__newobj__) + STRUCT_FOR_ID(__newobj_ex__) + STRUCT_FOR_ID(__next__) + STRUCT_FOR_ID(__notes__) + STRUCT_FOR_ID(__or__) + STRUCT_FOR_ID(__orig_class__) + STRUCT_FOR_ID(__origin__) + STRUCT_FOR_ID(__package__) + STRUCT_FOR_ID(__parameters__) + STRUCT_FOR_ID(__path__) + STRUCT_FOR_ID(__pos__) + STRUCT_FOR_ID(__pow__) + STRUCT_FOR_ID(__prepare__) + STRUCT_FOR_ID(__qualname__) + STRUCT_FOR_ID(__radd__) + STRUCT_FOR_ID(__rand__) + STRUCT_FOR_ID(__rdivmod__) + STRUCT_FOR_ID(__reduce__) + STRUCT_FOR_ID(__reduce_ex__) + STRUCT_FOR_ID(__release_buffer__) + STRUCT_FOR_ID(__repr__) + STRUCT_FOR_ID(__reversed__) + STRUCT_FOR_ID(__rfloordiv__) + STRUCT_FOR_ID(__rlshift__) + STRUCT_FOR_ID(__rmatmul__) + STRUCT_FOR_ID(__rmod__) + STRUCT_FOR_ID(__rmul__) + STRUCT_FOR_ID(__ror__) + STRUCT_FOR_ID(__round__) + STRUCT_FOR_ID(__rpow__) + STRUCT_FOR_ID(__rrshift__) + STRUCT_FOR_ID(__rshift__) + STRUCT_FOR_ID(__rsub__) + STRUCT_FOR_ID(__rtruediv__) + STRUCT_FOR_ID(__rxor__) + STRUCT_FOR_ID(__set__) + STRUCT_FOR_ID(__set_name__) + STRUCT_FOR_ID(__setattr__) + STRUCT_FOR_ID(__setitem__) + STRUCT_FOR_ID(__setstate__) + STRUCT_FOR_ID(__sizeof__) + STRUCT_FOR_ID(__slotnames__) + STRUCT_FOR_ID(__slots__) + STRUCT_FOR_ID(__spec__) + STRUCT_FOR_ID(__static_attributes__) + STRUCT_FOR_ID(__str__) + STRUCT_FOR_ID(__sub__) + STRUCT_FOR_ID(__subclasscheck__) + STRUCT_FOR_ID(__subclasshook__) + STRUCT_FOR_ID(__truediv__) + STRUCT_FOR_ID(__trunc__) + STRUCT_FOR_ID(__type_params__) + STRUCT_FOR_ID(__typing_is_unpacked_typevartuple__) + STRUCT_FOR_ID(__typing_prepare_subst__) + STRUCT_FOR_ID(__typing_subst__) + STRUCT_FOR_ID(__typing_unpacked_tuple_args__) + STRUCT_FOR_ID(__warningregistry__) + STRUCT_FOR_ID(__weaklistoffset__) + STRUCT_FOR_ID(__weakref__) + STRUCT_FOR_ID(__xor__) + STRUCT_FOR_ID(_abc_impl) + STRUCT_FOR_ID(_abstract_) + STRUCT_FOR_ID(_active) + STRUCT_FOR_ID(_align_) + STRUCT_FOR_ID(_annotation) + STRUCT_FOR_ID(_anonymous_) + STRUCT_FOR_ID(_argtypes_) + STRUCT_FOR_ID(_as_parameter_) + STRUCT_FOR_ID(_asyncio_future_blocking) + STRUCT_FOR_ID(_blksize) + STRUCT_FOR_ID(_bootstrap) + STRUCT_FOR_ID(_check_retval_) + STRUCT_FOR_ID(_dealloc_warn) + STRUCT_FOR_ID(_feature_version) + STRUCT_FOR_ID(_field_types) + STRUCT_FOR_ID(_fields_) + STRUCT_FOR_ID(_finalizing) + STRUCT_FOR_ID(_find_and_load) + STRUCT_FOR_ID(_fix_up_module) + STRUCT_FOR_ID(_flags_) + STRUCT_FOR_ID(_get_sourcefile) + STRUCT_FOR_ID(_handle_fromlist) + STRUCT_FOR_ID(_initializing) + STRUCT_FOR_ID(_io) + STRUCT_FOR_ID(_is_text_encoding) + STRUCT_FOR_ID(_length_) + STRUCT_FOR_ID(_limbo) + STRUCT_FOR_ID(_lock_unlock_module) + STRUCT_FOR_ID(_loop) + STRUCT_FOR_ID(_needs_com_addref_) + STRUCT_FOR_ID(_only_immortal) + STRUCT_FOR_ID(_pack_) + STRUCT_FOR_ID(_restype_) + STRUCT_FOR_ID(_showwarnmsg) + STRUCT_FOR_ID(_shutdown) + STRUCT_FOR_ID(_slotnames) + STRUCT_FOR_ID(_strptime) + STRUCT_FOR_ID(_strptime_datetime) + STRUCT_FOR_ID(_swappedbytes_) + STRUCT_FOR_ID(_type_) + STRUCT_FOR_ID(_uninitialized_submodules) + STRUCT_FOR_ID(_warn_unawaited_coroutine) + STRUCT_FOR_ID(_xoptions) + STRUCT_FOR_ID(abs_tol) + STRUCT_FOR_ID(access) + STRUCT_FOR_ID(aclose) + STRUCT_FOR_ID(add) + STRUCT_FOR_ID(add_done_callback) + STRUCT_FOR_ID(after_in_child) + STRUCT_FOR_ID(after_in_parent) + STRUCT_FOR_ID(aggregate_class) + STRUCT_FOR_ID(alias) + STRUCT_FOR_ID(allow_code) + STRUCT_FOR_ID(append) + STRUCT_FOR_ID(arg) + STRUCT_FOR_ID(argdefs) + STRUCT_FOR_ID(args) + STRUCT_FOR_ID(arguments) + STRUCT_FOR_ID(argv) + STRUCT_FOR_ID(as_integer_ratio) + STRUCT_FOR_ID(asend) + STRUCT_FOR_ID(ast) + STRUCT_FOR_ID(athrow) + STRUCT_FOR_ID(attribute) + STRUCT_FOR_ID(authorizer_callback) + STRUCT_FOR_ID(autocommit) + STRUCT_FOR_ID(backtick) + STRUCT_FOR_ID(base) + STRUCT_FOR_ID(before) + STRUCT_FOR_ID(big) + STRUCT_FOR_ID(binary_form) + STRUCT_FOR_ID(block) + STRUCT_FOR_ID(bound) + STRUCT_FOR_ID(buffer) + STRUCT_FOR_ID(buffer_callback) + STRUCT_FOR_ID(buffer_size) + STRUCT_FOR_ID(buffering) + STRUCT_FOR_ID(buffers) + STRUCT_FOR_ID(bufsize) + STRUCT_FOR_ID(builtins) + STRUCT_FOR_ID(byteorder) + STRUCT_FOR_ID(bytes) + STRUCT_FOR_ID(bytes_per_sep) + STRUCT_FOR_ID(c_call) + STRUCT_FOR_ID(c_exception) + STRUCT_FOR_ID(c_return) + STRUCT_FOR_ID(cached_datetime_module) + STRUCT_FOR_ID(cached_statements) + STRUCT_FOR_ID(cadata) + STRUCT_FOR_ID(cafile) + STRUCT_FOR_ID(call) + STRUCT_FOR_ID(call_exception_handler) + STRUCT_FOR_ID(call_soon) + STRUCT_FOR_ID(callback) + STRUCT_FOR_ID(cancel) + STRUCT_FOR_ID(capath) + STRUCT_FOR_ID(category) + STRUCT_FOR_ID(cb_type) + STRUCT_FOR_ID(certfile) + STRUCT_FOR_ID(check_same_thread) + STRUCT_FOR_ID(clear) + STRUCT_FOR_ID(close) + STRUCT_FOR_ID(closed) + STRUCT_FOR_ID(closefd) + STRUCT_FOR_ID(closure) + STRUCT_FOR_ID(co_argcount) + STRUCT_FOR_ID(co_cellvars) + STRUCT_FOR_ID(co_code) + STRUCT_FOR_ID(co_consts) + STRUCT_FOR_ID(co_exceptiontable) + STRUCT_FOR_ID(co_filename) + STRUCT_FOR_ID(co_firstlineno) + STRUCT_FOR_ID(co_flags) + STRUCT_FOR_ID(co_freevars) + STRUCT_FOR_ID(co_kwonlyargcount) + STRUCT_FOR_ID(co_linetable) + STRUCT_FOR_ID(co_name) + STRUCT_FOR_ID(co_names) + STRUCT_FOR_ID(co_nlocals) + STRUCT_FOR_ID(co_posonlyargcount) + STRUCT_FOR_ID(co_qualname) + STRUCT_FOR_ID(co_stacksize) + STRUCT_FOR_ID(co_varnames) + STRUCT_FOR_ID(code) + STRUCT_FOR_ID(col_offset) + STRUCT_FOR_ID(command) + STRUCT_FOR_ID(comment_factory) + STRUCT_FOR_ID(compile_mode) + STRUCT_FOR_ID(consts) + STRUCT_FOR_ID(context) + STRUCT_FOR_ID(contravariant) + STRUCT_FOR_ID(cookie) + STRUCT_FOR_ID(copy) + STRUCT_FOR_ID(copyreg) + STRUCT_FOR_ID(coro) + STRUCT_FOR_ID(count) + STRUCT_FOR_ID(covariant) + STRUCT_FOR_ID(cwd) + STRUCT_FOR_ID(data) + STRUCT_FOR_ID(database) + STRUCT_FOR_ID(day) + STRUCT_FOR_ID(decode) + STRUCT_FOR_ID(decoder) + STRUCT_FOR_ID(default) + STRUCT_FOR_ID(defaultaction) + STRUCT_FOR_ID(delete) + STRUCT_FOR_ID(depth) + STRUCT_FOR_ID(desired_access) + STRUCT_FOR_ID(detect_types) + STRUCT_FOR_ID(deterministic) + STRUCT_FOR_ID(device) + STRUCT_FOR_ID(dict) + STRUCT_FOR_ID(dictcomp) + STRUCT_FOR_ID(difference_update) + STRUCT_FOR_ID(digest) + STRUCT_FOR_ID(digest_size) + STRUCT_FOR_ID(digestmod) + STRUCT_FOR_ID(dir_fd) + STRUCT_FOR_ID(discard) + STRUCT_FOR_ID(dispatch_table) + STRUCT_FOR_ID(displayhook) + STRUCT_FOR_ID(dklen) + STRUCT_FOR_ID(doc) + STRUCT_FOR_ID(dont_inherit) + STRUCT_FOR_ID(dst) + STRUCT_FOR_ID(dst_dir_fd) + STRUCT_FOR_ID(eager_start) + STRUCT_FOR_ID(effective_ids) + STRUCT_FOR_ID(element_factory) + STRUCT_FOR_ID(encode) + STRUCT_FOR_ID(encoding) + STRUCT_FOR_ID(end) + STRUCT_FOR_ID(end_col_offset) + STRUCT_FOR_ID(end_lineno) + STRUCT_FOR_ID(end_offset) + STRUCT_FOR_ID(endpos) + STRUCT_FOR_ID(entrypoint) + STRUCT_FOR_ID(env) + STRUCT_FOR_ID(errors) + STRUCT_FOR_ID(event) + STRUCT_FOR_ID(eventmask) + STRUCT_FOR_ID(exc_type) + STRUCT_FOR_ID(exc_value) + STRUCT_FOR_ID(excepthook) + STRUCT_FOR_ID(exception) + STRUCT_FOR_ID(existing_file_name) + STRUCT_FOR_ID(exp) + STRUCT_FOR_ID(extend) + STRUCT_FOR_ID(extra_tokens) + STRUCT_FOR_ID(facility) + STRUCT_FOR_ID(factory) + STRUCT_FOR_ID(false) + STRUCT_FOR_ID(family) + STRUCT_FOR_ID(fanout) + STRUCT_FOR_ID(fd) + STRUCT_FOR_ID(fd2) + STRUCT_FOR_ID(fdel) + STRUCT_FOR_ID(fget) + STRUCT_FOR_ID(file) + STRUCT_FOR_ID(file_actions) + STRUCT_FOR_ID(filename) + STRUCT_FOR_ID(fileno) + STRUCT_FOR_ID(filepath) + STRUCT_FOR_ID(fillvalue) + STRUCT_FOR_ID(filter) + STRUCT_FOR_ID(filters) + STRUCT_FOR_ID(final) + STRUCT_FOR_ID(find_class) + STRUCT_FOR_ID(fix_imports) + STRUCT_FOR_ID(flags) + STRUCT_FOR_ID(flush) + STRUCT_FOR_ID(fold) + STRUCT_FOR_ID(follow_symlinks) + STRUCT_FOR_ID(format) + STRUCT_FOR_ID(from_param) + STRUCT_FOR_ID(fromlist) + STRUCT_FOR_ID(fromtimestamp) + STRUCT_FOR_ID(fromutc) + STRUCT_FOR_ID(fset) + STRUCT_FOR_ID(func) + STRUCT_FOR_ID(future) + STRUCT_FOR_ID(generation) + STRUCT_FOR_ID(genexpr) + STRUCT_FOR_ID(get) + STRUCT_FOR_ID(get_debug) + STRUCT_FOR_ID(get_event_loop) + STRUCT_FOR_ID(get_loop) + STRUCT_FOR_ID(get_source) + STRUCT_FOR_ID(getattr) + STRUCT_FOR_ID(getstate) + STRUCT_FOR_ID(gid) + STRUCT_FOR_ID(globals) + STRUCT_FOR_ID(groupindex) + STRUCT_FOR_ID(groups) + STRUCT_FOR_ID(handle) + STRUCT_FOR_ID(handle_seq) + STRUCT_FOR_ID(has_location) + STRUCT_FOR_ID(hash_name) + STRUCT_FOR_ID(header) + STRUCT_FOR_ID(headers) + STRUCT_FOR_ID(hi) + STRUCT_FOR_ID(hook) + STRUCT_FOR_ID(hour) + STRUCT_FOR_ID(ident) + STRUCT_FOR_ID(identity_hint) + STRUCT_FOR_ID(ignore) + STRUCT_FOR_ID(imag) + STRUCT_FOR_ID(importlib) + STRUCT_FOR_ID(in_fd) + STRUCT_FOR_ID(incoming) + STRUCT_FOR_ID(indexgroup) + STRUCT_FOR_ID(inf) + STRUCT_FOR_ID(infer_variance) + STRUCT_FOR_ID(inherit_handle) + STRUCT_FOR_ID(inheritable) + STRUCT_FOR_ID(initial) + STRUCT_FOR_ID(initial_bytes) + STRUCT_FOR_ID(initial_owner) + STRUCT_FOR_ID(initial_state) + STRUCT_FOR_ID(initial_value) + STRUCT_FOR_ID(initval) + STRUCT_FOR_ID(inner_size) + STRUCT_FOR_ID(input) + STRUCT_FOR_ID(insert_comments) + STRUCT_FOR_ID(insert_pis) + STRUCT_FOR_ID(instructions) + STRUCT_FOR_ID(intern) + STRUCT_FOR_ID(intersection) + STRUCT_FOR_ID(interval) + STRUCT_FOR_ID(is_running) + STRUCT_FOR_ID(isatty) + STRUCT_FOR_ID(isinstance) + STRUCT_FOR_ID(isoformat) + STRUCT_FOR_ID(isolation_level) + STRUCT_FOR_ID(istext) + STRUCT_FOR_ID(item) + STRUCT_FOR_ID(items) + STRUCT_FOR_ID(iter) + STRUCT_FOR_ID(iterable) + STRUCT_FOR_ID(iterations) + STRUCT_FOR_ID(join) + STRUCT_FOR_ID(jump) + STRUCT_FOR_ID(keepends) + STRUCT_FOR_ID(key) + STRUCT_FOR_ID(keyfile) + STRUCT_FOR_ID(keys) + STRUCT_FOR_ID(kind) + STRUCT_FOR_ID(kw) + STRUCT_FOR_ID(kw1) + STRUCT_FOR_ID(kw2) + STRUCT_FOR_ID(kwdefaults) + STRUCT_FOR_ID(label) + STRUCT_FOR_ID(lambda) + STRUCT_FOR_ID(last) + STRUCT_FOR_ID(last_exc) + STRUCT_FOR_ID(last_node) + STRUCT_FOR_ID(last_traceback) + STRUCT_FOR_ID(last_type) + STRUCT_FOR_ID(last_value) + STRUCT_FOR_ID(latin1) + STRUCT_FOR_ID(leaf_size) + STRUCT_FOR_ID(len) + STRUCT_FOR_ID(length) + STRUCT_FOR_ID(level) + STRUCT_FOR_ID(limit) + STRUCT_FOR_ID(line) + STRUCT_FOR_ID(line_buffering) + STRUCT_FOR_ID(lineno) + STRUCT_FOR_ID(listcomp) + STRUCT_FOR_ID(little) + STRUCT_FOR_ID(lo) + STRUCT_FOR_ID(locale) + STRUCT_FOR_ID(locals) + STRUCT_FOR_ID(logoption) + STRUCT_FOR_ID(loop) + STRUCT_FOR_ID(manual_reset) + STRUCT_FOR_ID(mapping) + STRUCT_FOR_ID(match) + STRUCT_FOR_ID(max_length) + STRUCT_FOR_ID(maxdigits) + STRUCT_FOR_ID(maxevents) + STRUCT_FOR_ID(maxlen) + STRUCT_FOR_ID(maxmem) + STRUCT_FOR_ID(maxsplit) + STRUCT_FOR_ID(maxvalue) + STRUCT_FOR_ID(memLevel) + STRUCT_FOR_ID(memlimit) + STRUCT_FOR_ID(message) + STRUCT_FOR_ID(metaclass) + STRUCT_FOR_ID(metadata) + STRUCT_FOR_ID(method) + STRUCT_FOR_ID(microsecond) + STRUCT_FOR_ID(milliseconds) + STRUCT_FOR_ID(minute) + STRUCT_FOR_ID(mod) + STRUCT_FOR_ID(mode) + STRUCT_FOR_ID(module) + STRUCT_FOR_ID(module_globals) + STRUCT_FOR_ID(modules) + STRUCT_FOR_ID(month) + STRUCT_FOR_ID(mro) + STRUCT_FOR_ID(msg) + STRUCT_FOR_ID(mutex) + STRUCT_FOR_ID(mycmp) + STRUCT_FOR_ID(n_arg) + STRUCT_FOR_ID(n_fields) + STRUCT_FOR_ID(n_sequence_fields) + STRUCT_FOR_ID(n_unnamed_fields) + STRUCT_FOR_ID(name) + STRUCT_FOR_ID(name_from) + STRUCT_FOR_ID(namespace_separator) + STRUCT_FOR_ID(namespaces) + STRUCT_FOR_ID(narg) + STRUCT_FOR_ID(ndigits) + STRUCT_FOR_ID(nested) + STRUCT_FOR_ID(new_file_name) + STRUCT_FOR_ID(new_limit) + STRUCT_FOR_ID(newline) + STRUCT_FOR_ID(newlines) + STRUCT_FOR_ID(next) + STRUCT_FOR_ID(nlocals) + STRUCT_FOR_ID(node_depth) + STRUCT_FOR_ID(node_offset) + STRUCT_FOR_ID(ns) + STRUCT_FOR_ID(nstype) + STRUCT_FOR_ID(nt) + STRUCT_FOR_ID(null) + STRUCT_FOR_ID(number) + STRUCT_FOR_ID(obj) + STRUCT_FOR_ID(object) + STRUCT_FOR_ID(offset) + STRUCT_FOR_ID(offset_dst) + STRUCT_FOR_ID(offset_src) + STRUCT_FOR_ID(on_type_read) + STRUCT_FOR_ID(onceregistry) + STRUCT_FOR_ID(only_keys) + STRUCT_FOR_ID(oparg) + STRUCT_FOR_ID(opcode) + STRUCT_FOR_ID(open) + STRUCT_FOR_ID(opener) + STRUCT_FOR_ID(operation) + STRUCT_FOR_ID(optimize) + STRUCT_FOR_ID(options) + STRUCT_FOR_ID(order) + STRUCT_FOR_ID(origin) + STRUCT_FOR_ID(out_fd) + STRUCT_FOR_ID(outgoing) + STRUCT_FOR_ID(overlapped) + STRUCT_FOR_ID(owner) + STRUCT_FOR_ID(pages) + STRUCT_FOR_ID(parent) + STRUCT_FOR_ID(password) + STRUCT_FOR_ID(path) + STRUCT_FOR_ID(pattern) + STRUCT_FOR_ID(peek) + STRUCT_FOR_ID(persistent_id) + STRUCT_FOR_ID(persistent_load) + STRUCT_FOR_ID(person) + STRUCT_FOR_ID(pi_factory) + STRUCT_FOR_ID(pid) + STRUCT_FOR_ID(policy) + STRUCT_FOR_ID(pos) + STRUCT_FOR_ID(pos1) + STRUCT_FOR_ID(pos2) + STRUCT_FOR_ID(posix) + STRUCT_FOR_ID(print_file_and_line) + STRUCT_FOR_ID(priority) + STRUCT_FOR_ID(progress) + STRUCT_FOR_ID(progress_handler) + STRUCT_FOR_ID(progress_routine) + STRUCT_FOR_ID(proto) + STRUCT_FOR_ID(protocol) + STRUCT_FOR_ID(ps1) + STRUCT_FOR_ID(ps2) + STRUCT_FOR_ID(query) + STRUCT_FOR_ID(quotetabs) + STRUCT_FOR_ID(raw) + STRUCT_FOR_ID(read) + STRUCT_FOR_ID(read1) + STRUCT_FOR_ID(readable) + STRUCT_FOR_ID(readall) + STRUCT_FOR_ID(readinto) + STRUCT_FOR_ID(readinto1) + STRUCT_FOR_ID(readline) + STRUCT_FOR_ID(readonly) + STRUCT_FOR_ID(real) + STRUCT_FOR_ID(reducer_override) + STRUCT_FOR_ID(registry) + STRUCT_FOR_ID(rel_tol) + STRUCT_FOR_ID(release) + STRUCT_FOR_ID(reload) + STRUCT_FOR_ID(repl) + STRUCT_FOR_ID(replace) + STRUCT_FOR_ID(reserved) + STRUCT_FOR_ID(reset) + STRUCT_FOR_ID(resetids) + STRUCT_FOR_ID(return) + STRUCT_FOR_ID(reverse) + STRUCT_FOR_ID(reversed) + STRUCT_FOR_ID(salt) + STRUCT_FOR_ID(sched_priority) + STRUCT_FOR_ID(scheduler) + STRUCT_FOR_ID(second) + STRUCT_FOR_ID(security_attributes) + STRUCT_FOR_ID(seek) + STRUCT_FOR_ID(seekable) + STRUCT_FOR_ID(selectors) + STRUCT_FOR_ID(self) + STRUCT_FOR_ID(send) + STRUCT_FOR_ID(sep) + STRUCT_FOR_ID(sequence) + STRUCT_FOR_ID(server_hostname) + STRUCT_FOR_ID(server_side) + STRUCT_FOR_ID(session) + STRUCT_FOR_ID(setcomp) + STRUCT_FOR_ID(setpgroup) + STRUCT_FOR_ID(setsid) + STRUCT_FOR_ID(setsigdef) + STRUCT_FOR_ID(setsigmask) + STRUCT_FOR_ID(setstate) + STRUCT_FOR_ID(shape) + STRUCT_FOR_ID(show_cmd) + STRUCT_FOR_ID(signed) + STRUCT_FOR_ID(size) + STRUCT_FOR_ID(sizehint) + STRUCT_FOR_ID(skip_file_prefixes) + STRUCT_FOR_ID(sleep) + STRUCT_FOR_ID(sock) + STRUCT_FOR_ID(sort) + STRUCT_FOR_ID(source) + STRUCT_FOR_ID(source_traceback) + STRUCT_FOR_ID(spam) + STRUCT_FOR_ID(src) + STRUCT_FOR_ID(src_dir_fd) + STRUCT_FOR_ID(stacklevel) + STRUCT_FOR_ID(start) + STRUCT_FOR_ID(statement) + STRUCT_FOR_ID(status) + STRUCT_FOR_ID(stderr) + STRUCT_FOR_ID(stdin) + STRUCT_FOR_ID(stdout) + STRUCT_FOR_ID(step) + STRUCT_FOR_ID(steps) + STRUCT_FOR_ID(store_name) + STRUCT_FOR_ID(strategy) + STRUCT_FOR_ID(strftime) + STRUCT_FOR_ID(strict) + STRUCT_FOR_ID(strict_mode) + STRUCT_FOR_ID(string) + STRUCT_FOR_ID(sub_key) + STRUCT_FOR_ID(symmetric_difference_update) + STRUCT_FOR_ID(tabsize) + STRUCT_FOR_ID(tag) + STRUCT_FOR_ID(target) + STRUCT_FOR_ID(target_is_directory) + STRUCT_FOR_ID(task) + STRUCT_FOR_ID(tb_frame) + STRUCT_FOR_ID(tb_lasti) + STRUCT_FOR_ID(tb_lineno) + STRUCT_FOR_ID(tb_next) + STRUCT_FOR_ID(tell) + STRUCT_FOR_ID(template) + STRUCT_FOR_ID(term) + STRUCT_FOR_ID(text) + STRUCT_FOR_ID(threading) + STRUCT_FOR_ID(throw) + STRUCT_FOR_ID(timeout) + STRUCT_FOR_ID(times) + STRUCT_FOR_ID(timetuple) + STRUCT_FOR_ID(top) + STRUCT_FOR_ID(trace_callback) + STRUCT_FOR_ID(traceback) + STRUCT_FOR_ID(trailers) + STRUCT_FOR_ID(translate) + STRUCT_FOR_ID(true) + STRUCT_FOR_ID(truncate) + STRUCT_FOR_ID(twice) + STRUCT_FOR_ID(txt) + STRUCT_FOR_ID(type) + STRUCT_FOR_ID(type_params) + STRUCT_FOR_ID(tz) + STRUCT_FOR_ID(tzinfo) + STRUCT_FOR_ID(tzname) + STRUCT_FOR_ID(uid) + STRUCT_FOR_ID(unlink) + STRUCT_FOR_ID(unraisablehook) + STRUCT_FOR_ID(uri) + STRUCT_FOR_ID(usedforsecurity) + STRUCT_FOR_ID(value) + STRUCT_FOR_ID(values) + STRUCT_FOR_ID(version) + STRUCT_FOR_ID(volume) + STRUCT_FOR_ID(wait_all) + STRUCT_FOR_ID(warn_on_full_buffer) + STRUCT_FOR_ID(warnings) + STRUCT_FOR_ID(warnoptions) + STRUCT_FOR_ID(wbits) + STRUCT_FOR_ID(week) + STRUCT_FOR_ID(weekday) + STRUCT_FOR_ID(which) + STRUCT_FOR_ID(who) + STRUCT_FOR_ID(withdata) + STRUCT_FOR_ID(writable) + STRUCT_FOR_ID(write) + STRUCT_FOR_ID(write_through) + STRUCT_FOR_ID(year) + STRUCT_FOR_ID(zdict) + } identifiers; + struct { + PyASCIIObject _ascii; + uint8_t _data[2]; + } ascii[128]; + struct { + PyCompactUnicodeObject _latin1; + uint8_t _data[2]; + } latin1[128]; +}; +/* End auto-generated code */ + +#undef ID +#undef STR + + +#define _Py_ID(NAME) \ + (_Py_SINGLETON(strings.identifiers._py_ ## NAME._ascii.ob_base)) +#define _Py_STR(NAME) \ + (_Py_SINGLETON(strings.literals._py_ ## NAME._ascii.ob_base)) +#define _Py_LATIN1_CHR(CH) \ + ((CH) < 128 \ + ? (PyObject*)&_Py_SINGLETON(strings).ascii[(CH)] \ + : (PyObject*)&_Py_SINGLETON(strings).latin1[(CH) - 128]) + +/* _Py_DECLARE_STR() should precede all uses of _Py_STR() in a function. + + This is true even if the same string has already been declared + elsewhere, even in the same file. Mismatched duplicates are detected + by Tools/scripts/generate-global-objects.py. + + Pairing _Py_DECLARE_STR() with every use of _Py_STR() makes sure the + string keeps working even if the declaration is removed somewhere + else. It also makes it clear what the actual string is at every + place it is being used. */ +#define _Py_DECLARE_STR(name, str) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_GLOBAL_STRINGS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_hamt.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_hamt.h new file mode 100644 index 00000000..d8742c7c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_hamt.h @@ -0,0 +1,134 @@ +#ifndef Py_INTERNAL_HAMT_H +#define Py_INTERNAL_HAMT_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +/* +HAMT tree is shaped by hashes of keys. Every group of 5 bits of a hash denotes +the exact position of the key in one level of the tree. Since we're using +32 bit hashes, we can have at most 7 such levels. Although if there are +two distinct keys with equal hashes, they will have to occupy the same +cell in the 7th level of the tree -- so we'd put them in a "collision" node. +Which brings the total possible tree depth to 8. Read more about the actual +layout of the HAMT tree in `hamt.c`. + +This constant is used to define a datastucture for storing iteration state. +*/ +#define _Py_HAMT_MAX_TREE_DEPTH 8 + + +extern PyTypeObject _PyHamt_Type; +extern PyTypeObject _PyHamt_ArrayNode_Type; +extern PyTypeObject _PyHamt_BitmapNode_Type; +extern PyTypeObject _PyHamt_CollisionNode_Type; +extern PyTypeObject _PyHamtKeys_Type; +extern PyTypeObject _PyHamtValues_Type; +extern PyTypeObject _PyHamtItems_Type; + + +/* other API */ + +#define PyHamt_Check(o) Py_IS_TYPE((o), &_PyHamt_Type) + + +/* Abstract tree node. */ +typedef struct { + PyObject_HEAD +} PyHamtNode; + + +/* An HAMT immutable mapping collection. */ +typedef struct { + PyObject_HEAD + PyHamtNode *h_root; + PyObject *h_weakreflist; + Py_ssize_t h_count; +} PyHamtObject; + + +typedef struct { + PyObject_VAR_HEAD + uint32_t b_bitmap; + PyObject *b_array[1]; +} PyHamtNode_Bitmap; + + +/* A struct to hold the state of depth-first traverse of the tree. + + HAMT is an immutable collection. Iterators will hold a strong reference + to it, and every node in the HAMT has strong references to its children. + + So for iterators, we can implement zero allocations and zero reference + inc/dec depth-first iteration. + + - i_nodes: an array of seven pointers to tree nodes + - i_level: the current node in i_nodes + - i_pos: an array of positions within nodes in i_nodes. +*/ +typedef struct { + PyHamtNode *i_nodes[_Py_HAMT_MAX_TREE_DEPTH]; + Py_ssize_t i_pos[_Py_HAMT_MAX_TREE_DEPTH]; + int8_t i_level; +} PyHamtIteratorState; + + +/* Base iterator object. + + Contains the iteration state, a pointer to the HAMT tree, + and a pointer to the 'yield function'. The latter is a simple + function that returns a key/value tuple for the 'Items' iterator, + just a key for the 'Keys' iterator, and a value for the 'Values' + iterator. +*/ +typedef struct { + PyObject_HEAD + PyHamtObject *hi_obj; + PyHamtIteratorState hi_iter; + binaryfunc hi_yield; +} PyHamtIterator; + + +/* Create a new HAMT immutable mapping. */ +PyHamtObject * _PyHamt_New(void); + +/* Return a new collection based on "o", but with an additional + key/val pair. */ +PyHamtObject * _PyHamt_Assoc(PyHamtObject *o, PyObject *key, PyObject *val); + +/* Return a new collection based on "o", but without "key". */ +PyHamtObject * _PyHamt_Without(PyHamtObject *o, PyObject *key); + +/* Find "key" in the "o" collection. + + Return: + - -1: An error occurred. + - 0: "key" wasn't found in "o". + - 1: "key" is in "o"; "*val" is set to its value (a borrowed ref). +*/ +int _PyHamt_Find(PyHamtObject *o, PyObject *key, PyObject **val); + +/* Check if "v" is equal to "w". + + Return: + - 0: v != w + - 1: v == w + - -1: An error occurred. +*/ +int _PyHamt_Eq(PyHamtObject *v, PyHamtObject *w); + +/* Return the size of "o"; equivalent of "len(o)". */ +Py_ssize_t _PyHamt_Len(PyHamtObject *o); + +/* Return a Keys iterator over "o". */ +PyObject * _PyHamt_NewIterKeys(PyHamtObject *o); + +/* Return a Values iterator over "o". */ +PyObject * _PyHamt_NewIterValues(PyHamtObject *o); + +/* Return a Items iterator over "o". */ +PyObject * _PyHamt_NewIterItems(PyHamtObject *o); + +#endif /* !Py_INTERNAL_HAMT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_hashtable.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_hashtable.h new file mode 100644 index 00000000..369d49c4 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_hashtable.h @@ -0,0 +1,150 @@ +#ifndef Py_INTERNAL_HASHTABLE_H +#define Py_INTERNAL_HASHTABLE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* Single linked list */ + +typedef struct _Py_slist_item_s { + struct _Py_slist_item_s *next; +} _Py_slist_item_t; + +typedef struct { + _Py_slist_item_t *head; +} _Py_slist_t; + +#define _Py_SLIST_ITEM_NEXT(ITEM) _Py_RVALUE(((_Py_slist_item_t *)(ITEM))->next) + +#define _Py_SLIST_HEAD(SLIST) _Py_RVALUE(((_Py_slist_t *)(SLIST))->head) + + +/* _Py_hashtable: table entry */ + +typedef struct { + /* used by _Py_hashtable_t.buckets to link entries */ + _Py_slist_item_t _Py_slist_item; + + Py_uhash_t key_hash; + void *key; + void *value; +} _Py_hashtable_entry_t; + + +/* _Py_hashtable: prototypes */ + +/* Forward declaration */ +struct _Py_hashtable_t; +typedef struct _Py_hashtable_t _Py_hashtable_t; + +typedef Py_uhash_t (*_Py_hashtable_hash_func) (const void *key); +typedef int (*_Py_hashtable_compare_func) (const void *key1, const void *key2); +typedef void (*_Py_hashtable_destroy_func) (void *key); +typedef _Py_hashtable_entry_t* (*_Py_hashtable_get_entry_func)(_Py_hashtable_t *ht, + const void *key); + +typedef struct { + // Allocate a memory block + void* (*malloc) (size_t size); + + // Release a memory block + void (*free) (void *ptr); +} _Py_hashtable_allocator_t; + + +/* _Py_hashtable: table */ +struct _Py_hashtable_t { + size_t nentries; // Total number of entries in the table + size_t nbuckets; + _Py_slist_t *buckets; + + _Py_hashtable_get_entry_func get_entry_func; + _Py_hashtable_hash_func hash_func; + _Py_hashtable_compare_func compare_func; + _Py_hashtable_destroy_func key_destroy_func; + _Py_hashtable_destroy_func value_destroy_func; + _Py_hashtable_allocator_t alloc; +}; + +// Export _Py_hashtable functions for '_testinternalcapi' shared extension +PyAPI_FUNC(_Py_hashtable_t *) _Py_hashtable_new( + _Py_hashtable_hash_func hash_func, + _Py_hashtable_compare_func compare_func); + +/* Hash a pointer (void*) */ +PyAPI_FUNC(Py_uhash_t) _Py_hashtable_hash_ptr(const void *key); + +/* Comparison using memcmp() */ +PyAPI_FUNC(int) _Py_hashtable_compare_direct( + const void *key1, + const void *key2); + +PyAPI_FUNC(_Py_hashtable_t *) _Py_hashtable_new_full( + _Py_hashtable_hash_func hash_func, + _Py_hashtable_compare_func compare_func, + _Py_hashtable_destroy_func key_destroy_func, + _Py_hashtable_destroy_func value_destroy_func, + _Py_hashtable_allocator_t *allocator); + +PyAPI_FUNC(void) _Py_hashtable_destroy(_Py_hashtable_t *ht); + +PyAPI_FUNC(void) _Py_hashtable_clear(_Py_hashtable_t *ht); + +typedef int (*_Py_hashtable_foreach_func) (_Py_hashtable_t *ht, + const void *key, const void *value, + void *user_data); + +/* Call func() on each entry of the hashtable. + Iteration stops if func() result is non-zero, in this case it's the result + of the call. Otherwise, the function returns 0. */ +PyAPI_FUNC(int) _Py_hashtable_foreach( + _Py_hashtable_t *ht, + _Py_hashtable_foreach_func func, + void *user_data); + +PyAPI_FUNC(size_t) _Py_hashtable_size(const _Py_hashtable_t *ht); +PyAPI_FUNC(size_t) _Py_hashtable_len(const _Py_hashtable_t *ht); + +/* Add a new entry to the hash. The key must not be present in the hash table. + Return 0 on success, -1 on memory error. */ +PyAPI_FUNC(int) _Py_hashtable_set( + _Py_hashtable_t *ht, + const void *key, + void *value); + + +/* Get an entry. + Return NULL if the key does not exist. */ +static inline _Py_hashtable_entry_t * +_Py_hashtable_get_entry(_Py_hashtable_t *ht, const void *key) +{ + return ht->get_entry_func(ht, key); +} + + +/* Get value from an entry. + Return NULL if the entry is not found. + + Use _Py_hashtable_get_entry() to distinguish entry value equal to NULL + and entry not found. */ +PyAPI_FUNC(void*) _Py_hashtable_get(_Py_hashtable_t *ht, const void *key); + + +/* Remove a key and its associated value without calling key and value destroy + functions. + + Return the removed value if the key was found. + Return NULL if the key was not found. */ +PyAPI_FUNC(void*) _Py_hashtable_steal( + _Py_hashtable_t *ht, + const void *key); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_HASHTABLE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_identifier.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_identifier.h new file mode 100644 index 00000000..cda28810 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_identifier.h @@ -0,0 +1,20 @@ +/* String Literals: _Py_Identifier API */ + +#ifndef Py_INTERNAL_IDENTIFIER_H +#define Py_INTERNAL_IDENTIFIER_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern PyObject* _PyType_LookupId(PyTypeObject *, _Py_Identifier *); +extern PyObject* _PyObject_LookupSpecialId(PyObject *, _Py_Identifier *); +extern int _PyObject_SetAttrId(PyObject *, _Py_Identifier *, PyObject *); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_IDENTIFIER_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_import.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_import.h new file mode 100644 index 00000000..55029abd --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_import.h @@ -0,0 +1,213 @@ +#ifndef Py_LIMITED_API +#ifndef Py_INTERNAL_IMPORT_H +#define Py_INTERNAL_IMPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_lock.h" // PyMutex +#include "pycore_hashtable.h" // _Py_hashtable_t + +extern int _PyImport_IsInitialized(PyInterpreterState *); + +// Export for 'pyexpat' shared extension +PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module); + +extern int _PyImport_SetModuleString(const char *name, PyObject* module); + +extern void _PyImport_AcquireLock(PyInterpreterState *interp); +extern void _PyImport_ReleaseLock(PyInterpreterState *interp); +extern void _PyImport_ReInitLock(PyInterpreterState *interp); + +// This is used exclusively for the sys and builtins modules: +extern int _PyImport_FixupBuiltin( + PyThreadState *tstate, + PyObject *mod, + const char *name, /* UTF-8 encoded string */ + PyObject *modules + ); + +// Export for many shared extensions, like '_json' +PyAPI_FUNC(PyObject*) _PyImport_GetModuleAttr(PyObject *, PyObject *); + +// Export for many shared extensions, like '_datetime' +PyAPI_FUNC(PyObject*) _PyImport_GetModuleAttrString(const char *, const char *); + + +struct _import_runtime_state { + /* The builtin modules (defined in config.c). */ + struct _inittab *inittab; + /* The most recent value assigned to a PyModuleDef.m_base.m_index. + This is incremented each time PyModuleDef_Init() is called, + which is just about every time an extension module is imported. + See PyInterpreterState.modules_by_index for more info. */ + Py_ssize_t last_module_index; + struct { + /* A lock to guard the cache. */ + PyMutex mutex; + /* The actual cache of (filename, name, PyModuleDef) for modules. + Only legacy (single-phase init) extension modules are added + and only if they support multiple initialization (m_size >- 0) + or are imported in the main interpreter. + This is initialized lazily in fix_up_extension() in import.c. + Modules are added there and looked up in _imp.find_extension(). */ + _Py_hashtable_t *hashtable; + } extensions; + /* Package context -- the full module name for package imports */ + const char * pkgcontext; +}; + +struct _import_state { + /* cached sys.modules dictionary */ + PyObject *modules; + /* This is the list of module objects for all legacy (single-phase init) + extension modules ever loaded in this process (i.e. imported + in this interpreter or in any other). Py_None stands in for + modules that haven't actually been imported in this interpreter. + + A module's index (PyModuleDef.m_base.m_index) is used to look up + the corresponding module object for this interpreter, if any. + (See PyState_FindModule().) When any extension module + is initialized during import, its moduledef gets initialized by + PyModuleDef_Init(), and the first time that happens for each + PyModuleDef, its index gets set to the current value of + a global counter (see _PyRuntimeState.imports.last_module_index). + The entry for that index in this interpreter remains unset until + the module is actually imported here. (Py_None is used as + a placeholder.) Note that multi-phase init modules always get + an index for which there will never be a module set. + + This is initialized lazily in PyState_AddModule(), which is also + where modules get added. */ + PyObject *modules_by_index; + /* importlib module._bootstrap */ + PyObject *importlib; + /* override for config->use_frozen_modules (for tests) + (-1: "off", 1: "on", 0: no override) */ + int override_frozen_modules; + int override_multi_interp_extensions_check; +#ifdef HAVE_DLOPEN + int dlopenflags; +#endif + PyObject *import_func; + /* The global import lock. */ + _PyRecursiveMutex lock; + /* diagnostic info in PyImport_ImportModuleLevelObject() */ + struct { + int import_level; + PyTime_t accumulated; + int header; + } find_and_load; +}; + +#ifdef HAVE_DLOPEN +# include // RTLD_NOW, RTLD_LAZY +# if HAVE_DECL_RTLD_NOW +# define _Py_DLOPEN_FLAGS RTLD_NOW +# else +# define _Py_DLOPEN_FLAGS RTLD_LAZY +# endif +# define DLOPENFLAGS_INIT .dlopenflags = _Py_DLOPEN_FLAGS, +#else +# define _Py_DLOPEN_FLAGS 0 +# define DLOPENFLAGS_INIT +#endif + +#define IMPORTS_INIT \ + { \ + DLOPENFLAGS_INIT \ + .find_and_load = { \ + .header = 1, \ + }, \ + } + +extern void _PyImport_ClearCore(PyInterpreterState *interp); + +extern Py_ssize_t _PyImport_GetNextModuleIndex(void); +extern const char * _PyImport_ResolveNameWithPackageContext(const char *name); +extern const char * _PyImport_SwapPackageContext(const char *newcontext); + +extern int _PyImport_GetDLOpenFlags(PyInterpreterState *interp); +extern void _PyImport_SetDLOpenFlags(PyInterpreterState *interp, int new_val); + +extern PyObject * _PyImport_InitModules(PyInterpreterState *interp); +extern PyObject * _PyImport_GetModules(PyInterpreterState *interp); +extern void _PyImport_ClearModules(PyInterpreterState *interp); + +extern void _PyImport_ClearModulesByIndex(PyInterpreterState *interp); + +extern int _PyImport_InitDefaultImportFunc(PyInterpreterState *interp); +extern int _PyImport_IsDefaultImportFunc( + PyInterpreterState *interp, + PyObject *func); + +extern PyObject * _PyImport_GetImportlibLoader( + PyInterpreterState *interp, + const char *loader_name); +extern PyObject * _PyImport_GetImportlibExternalLoader( + PyInterpreterState *interp, + const char *loader_name); +extern PyObject * _PyImport_BlessMyLoader( + PyInterpreterState *interp, + PyObject *module_globals); +extern PyObject * _PyImport_ImportlibModuleRepr( + PyInterpreterState *interp, + PyObject *module); + + +extern PyStatus _PyImport_Init(void); +extern void _PyImport_Fini(void); +extern void _PyImport_Fini2(void); + +extern PyStatus _PyImport_InitCore( + PyThreadState *tstate, + PyObject *sysmod, + int importlib); +extern PyStatus _PyImport_InitExternal(PyThreadState *tstate); +extern void _PyImport_FiniCore(PyInterpreterState *interp); +extern void _PyImport_FiniExternal(PyInterpreterState *interp); + + +extern PyObject* _PyImport_GetBuiltinModuleNames(void); + +struct _module_alias { + const char *name; /* ASCII encoded string */ + const char *orig; /* ASCII encoded string */ +}; + +// Export these 3 symbols for test_ctypes +PyAPI_DATA(const struct _frozen*) _PyImport_FrozenBootstrap; +PyAPI_DATA(const struct _frozen*) _PyImport_FrozenStdlib; +PyAPI_DATA(const struct _frozen*) _PyImport_FrozenTest; + +extern const struct _module_alias * _PyImport_FrozenAliases; + +extern int _PyImport_CheckSubinterpIncompatibleExtensionAllowed( + const char *name); + + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(int) _PyImport_ClearExtension(PyObject *name, PyObject *filename); + +#ifdef Py_GIL_DISABLED +// Assuming that the GIL is enabled from a call to +// _PyEval_EnableGILTransient(), resolve the transient request depending on the +// state of the module argument: +// - If module is NULL or a PyModuleObject with md_gil == Py_MOD_GIL_NOT_USED, +// call _PyEval_DisableGIL(). +// - Otherwise, call _PyEval_EnableGILPermanent(). If the GIL was not already +// enabled permanently, issue a warning referencing the module's name. +// +// This function may raise an exception. +extern int _PyImport_CheckGILForModule(PyObject *module, PyObject *module_name); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_IMPORT_H */ +#endif /* !Py_LIMITED_API */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_importdl.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_importdl.h new file mode 100644 index 00000000..525a16f6 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_importdl.h @@ -0,0 +1,139 @@ +#ifndef Py_INTERNAL_IMPORTDL_H +#define Py_INTERNAL_IMPORTDL_H + +#include "patchlevel.h" // PY_MAJOR_VERSION + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +extern const char *_PyImport_DynLoadFiletab[]; + + +typedef enum ext_module_kind { + _Py_ext_module_kind_UNKNOWN = 0, + _Py_ext_module_kind_SINGLEPHASE = 1, + _Py_ext_module_kind_MULTIPHASE = 2, + _Py_ext_module_kind_INVALID = 3, +} _Py_ext_module_kind; + +typedef enum ext_module_origin { + _Py_ext_module_origin_CORE = 1, + _Py_ext_module_origin_BUILTIN = 2, + _Py_ext_module_origin_DYNAMIC = 3, +} _Py_ext_module_origin; + +/* Input for loading an extension module. */ +struct _Py_ext_module_loader_info { + PyObject *filename; +#ifndef MS_WINDOWS + PyObject *filename_encoded; +#endif + PyObject *name; + PyObject *name_encoded; + /* path is always a borrowed ref of name or filename, + * depending on if it's builtin or not. */ + PyObject *path; + _Py_ext_module_origin origin; + const char *hook_prefix; + const char *newcontext; +}; +extern void _Py_ext_module_loader_info_clear( + struct _Py_ext_module_loader_info *info); +extern int _Py_ext_module_loader_info_init( + struct _Py_ext_module_loader_info *info, + PyObject *name, + PyObject *filename, + _Py_ext_module_origin origin); +extern int _Py_ext_module_loader_info_init_for_core( + struct _Py_ext_module_loader_info *p_info, + PyObject *name); +extern int _Py_ext_module_loader_info_init_for_builtin( + struct _Py_ext_module_loader_info *p_info, + PyObject *name); +#ifdef HAVE_DYNAMIC_LOADING +extern int _Py_ext_module_loader_info_init_from_spec( + struct _Py_ext_module_loader_info *info, + PyObject *spec); +#endif + +/* The result from running an extension module's init function. */ +struct _Py_ext_module_loader_result { + PyModuleDef *def; + PyObject *module; + _Py_ext_module_kind kind; + struct _Py_ext_module_loader_result_error *err; + struct _Py_ext_module_loader_result_error { + enum _Py_ext_module_loader_result_error_kind { + _Py_ext_module_loader_result_EXCEPTION = 0, + _Py_ext_module_loader_result_ERR_MISSING = 1, + _Py_ext_module_loader_result_ERR_UNREPORTED_EXC = 2, + _Py_ext_module_loader_result_ERR_UNINITIALIZED = 3, + _Py_ext_module_loader_result_ERR_NONASCII_NOT_MULTIPHASE = 4, + _Py_ext_module_loader_result_ERR_NOT_MODULE = 5, + _Py_ext_module_loader_result_ERR_MISSING_DEF = 6, + } kind; + PyObject *exc; + } _err; +}; +extern void _Py_ext_module_loader_result_clear( + struct _Py_ext_module_loader_result *res); +extern void _Py_ext_module_loader_result_apply_error( + struct _Py_ext_module_loader_result *res, + const char *name); + +/* The module init function. */ +typedef PyObject *(*PyModInitFunction)(void); +#ifdef HAVE_DYNAMIC_LOADING +extern PyModInitFunction _PyImport_GetModInitFunc( + struct _Py_ext_module_loader_info *info, + FILE *fp); +#endif +extern int _PyImport_RunModInitFunc( + PyModInitFunction p0, + struct _Py_ext_module_loader_info *info, + struct _Py_ext_module_loader_result *p_res); + + +/* Max length of module suffix searched for -- accommodates "module.slb" */ +#define MAXSUFFIXSIZE 12 + +#ifdef MS_WINDOWS +#include +typedef FARPROC dl_funcptr; + +#ifdef _DEBUG +# define PYD_DEBUG_SUFFIX "_d" +#else +# define PYD_DEBUG_SUFFIX "" +#endif + +#ifdef Py_GIL_DISABLED +# define PYD_THREADING_TAG "t" +#else +# define PYD_THREADING_TAG "" +#endif + +#ifdef PYD_PLATFORM_TAG +# define PYD_SOABI "cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) PYD_THREADING_TAG "-" PYD_PLATFORM_TAG +#else +# define PYD_SOABI "cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) PYD_THREADING_TAG +#endif + +#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX "." PYD_SOABI ".pyd" +#define PYD_UNTAGGED_SUFFIX PYD_DEBUG_SUFFIX ".pyd" + +#else +typedef void (*dl_funcptr)(void); +#endif + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_IMPORTDL_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_initconfig.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_initconfig.h new file mode 100644 index 00000000..1c681613 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_initconfig.h @@ -0,0 +1,200 @@ +#ifndef Py_INTERNAL_CORECONFIG_H +#define Py_INTERNAL_CORECONFIG_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* Forward declaration */ +struct pyruntimestate; + +/* --- PyStatus ----------------------------------------------- */ + +/* Almost all errors causing Python initialization to fail */ +#ifdef _MSC_VER + /* Visual Studio 2015 doesn't implement C99 __func__ in C */ +# define _PyStatus_GET_FUNC() __FUNCTION__ +#else +# define _PyStatus_GET_FUNC() __func__ +#endif + +#define _PyStatus_OK() \ + (PyStatus){._type = _PyStatus_TYPE_OK} + /* other fields are set to 0 */ +#define _PyStatus_ERR(ERR_MSG) \ + (PyStatus){ \ + ._type = _PyStatus_TYPE_ERROR, \ + .func = _PyStatus_GET_FUNC(), \ + .err_msg = (ERR_MSG)} + /* other fields are set to 0 */ +#define _PyStatus_NO_MEMORY_ERRMSG "memory allocation failed" +#define _PyStatus_NO_MEMORY() _PyStatus_ERR(_PyStatus_NO_MEMORY_ERRMSG) +#define _PyStatus_EXIT(EXITCODE) \ + (PyStatus){ \ + ._type = _PyStatus_TYPE_EXIT, \ + .exitcode = (EXITCODE)} +#define _PyStatus_IS_ERROR(err) \ + ((err)._type == _PyStatus_TYPE_ERROR) +#define _PyStatus_IS_EXIT(err) \ + ((err)._type == _PyStatus_TYPE_EXIT) +#define _PyStatus_EXCEPTION(err) \ + ((err)._type != _PyStatus_TYPE_OK) +#define _PyStatus_UPDATE_FUNC(err) \ + do { (err).func = _PyStatus_GET_FUNC(); } while (0) + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(void) _PyErr_SetFromPyStatus(PyStatus status); + + +/* --- PyWideStringList ------------------------------------------------ */ + +#define _PyWideStringList_INIT (PyWideStringList){.length = 0, .items = NULL} + +#ifndef NDEBUG +extern int _PyWideStringList_CheckConsistency(const PyWideStringList *list); +#endif +extern void _PyWideStringList_Clear(PyWideStringList *list); +extern int _PyWideStringList_Copy(PyWideStringList *list, + const PyWideStringList *list2); +extern PyStatus _PyWideStringList_Extend(PyWideStringList *list, + const PyWideStringList *list2); +extern PyObject* _PyWideStringList_AsList(const PyWideStringList *list); + + +/* --- _PyArgv ---------------------------------------------------- */ + +typedef struct _PyArgv { + Py_ssize_t argc; + int use_bytes_argv; + char * const *bytes_argv; + wchar_t * const *wchar_argv; +} _PyArgv; + +extern PyStatus _PyArgv_AsWstrList(const _PyArgv *args, + PyWideStringList *list); + + +/* --- Helper functions ------------------------------------------- */ + +extern int _Py_str_to_int( + const char *str, + int *result); +extern const wchar_t* _Py_get_xoption( + const PyWideStringList *xoptions, + const wchar_t *name); +extern const char* _Py_GetEnv( + int use_environment, + const char *name); +extern void _Py_get_env_flag( + int use_environment, + int *flag, + const char *name); + +/* Py_GetArgcArgv() helper */ +extern void _Py_ClearArgcArgv(void); + + +/* --- _PyPreCmdline ------------------------------------------------- */ + +typedef struct { + PyWideStringList argv; + PyWideStringList xoptions; /* "-X value" option */ + int isolated; /* -I option */ + int use_environment; /* -E option */ + int dev_mode; /* -X dev and PYTHONDEVMODE */ + int warn_default_encoding; /* -X warn_default_encoding and PYTHONWARNDEFAULTENCODING */ +} _PyPreCmdline; + +#define _PyPreCmdline_INIT \ + (_PyPreCmdline){ \ + .use_environment = -1, \ + .isolated = -1, \ + .dev_mode = -1} +/* Note: _PyPreCmdline_INIT sets other fields to 0/NULL */ + +extern void _PyPreCmdline_Clear(_PyPreCmdline *cmdline); +extern PyStatus _PyPreCmdline_SetArgv(_PyPreCmdline *cmdline, + const _PyArgv *args); +extern PyStatus _PyPreCmdline_SetConfig( + const _PyPreCmdline *cmdline, + PyConfig *config); +extern PyStatus _PyPreCmdline_Read(_PyPreCmdline *cmdline, + const PyPreConfig *preconfig); + + +/* --- PyPreConfig ----------------------------------------------- */ + +// Export for '_testembed' program +PyAPI_FUNC(void) _PyPreConfig_InitCompatConfig(PyPreConfig *preconfig); + +extern void _PyPreConfig_InitFromConfig( + PyPreConfig *preconfig, + const PyConfig *config); +extern PyStatus _PyPreConfig_InitFromPreConfig( + PyPreConfig *preconfig, + const PyPreConfig *config2); +extern PyObject* _PyPreConfig_AsDict(const PyPreConfig *preconfig); +extern void _PyPreConfig_GetConfig(PyPreConfig *preconfig, + const PyConfig *config); +extern PyStatus _PyPreConfig_Read(PyPreConfig *preconfig, + const _PyArgv *args); +extern PyStatus _PyPreConfig_Write(const PyPreConfig *preconfig); + + +/* --- PyConfig ---------------------------------------------- */ + +typedef enum { + /* Py_Initialize() API: backward compatibility with Python 3.6 and 3.7 */ + _PyConfig_INIT_COMPAT = 1, + _PyConfig_INIT_PYTHON = 2, + _PyConfig_INIT_ISOLATED = 3 +} _PyConfigInitEnum; + +typedef enum { + /* For now, this means the GIL is enabled. + + gh-116329: This will eventually change to "the GIL is disabled but can + be reenabled by loading an incompatible extension module." */ + _PyConfig_GIL_DEFAULT = -1, + + /* The GIL has been forced off or on, and will not be affected by module loading. */ + _PyConfig_GIL_DISABLE = 0, + _PyConfig_GIL_ENABLE = 1, +} _PyConfigGILEnum; + +// Export for '_testembed' program +PyAPI_FUNC(void) _PyConfig_InitCompatConfig(PyConfig *config); + +extern PyStatus _PyConfig_Copy( + PyConfig *config, + const PyConfig *config2); +extern PyStatus _PyConfig_InitPathConfig( + PyConfig *config, + int compute_path_config); +extern PyStatus _PyConfig_InitImportConfig(PyConfig *config); +extern PyStatus _PyConfig_Read(PyConfig *config, int compute_path_config); +extern PyStatus _PyConfig_Write(const PyConfig *config, + struct pyruntimestate *runtime); +extern PyStatus _PyConfig_SetPyArgv( + PyConfig *config, + const _PyArgv *args); + + +extern void _Py_DumpPathConfig(PyThreadState *tstate); + + +/* --- Function used for testing ---------------------------------- */ + +// Export these functions for '_testinternalcapi' shared extension +PyAPI_FUNC(PyObject*) _PyConfig_AsDict(const PyConfig *config); +PyAPI_FUNC(int) _PyConfig_FromDict(PyConfig *config, PyObject *dict); +PyAPI_FUNC(PyObject*) _Py_Get_Getpath_CodeObject(void); +PyAPI_FUNC(PyObject*) _Py_GetConfigsAsDict(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_CORECONFIG_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_instruction_sequence.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_instruction_sequence.h new file mode 100644 index 00000000..d6a79616 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_instruction_sequence.h @@ -0,0 +1,73 @@ +#ifndef Py_INTERNAL_INSTRUCTION_SEQUENCE_H +#define Py_INTERNAL_INSTRUCTION_SEQUENCE_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_symtable.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct { + int h_label; + int h_startdepth; + int h_preserve_lasti; +} _PyExceptHandlerInfo; + +typedef struct { + int i_opcode; + int i_oparg; + _Py_SourceLocation i_loc; + _PyExceptHandlerInfo i_except_handler_info; + + /* Temporary fields, used by the assembler and in instr_sequence_to_cfg */ + int i_target; + int i_offset; +} _PyInstruction; + +typedef struct instruction_sequence { + PyObject_HEAD + _PyInstruction *s_instrs; + int s_allocated; + int s_used; + + int s_next_free_label; /* next free label id */ + + /* Map of a label id to instruction offset (index into s_instrs). + * If s_labelmap is NULL, then each label id is the offset itself. + */ + int *s_labelmap; + int s_labelmap_size; + + /* PyList of instruction sequences of nested functions */ + PyObject *s_nested; +} _PyInstructionSequence; + +typedef struct { + int id; +} _PyJumpTargetLabel; + +PyAPI_FUNC(PyObject*)_PyInstructionSequence_New(void); + +int _PyInstructionSequence_UseLabel(_PyInstructionSequence *seq, int lbl); +int _PyInstructionSequence_Addop(_PyInstructionSequence *seq, + int opcode, int oparg, + _Py_SourceLocation loc); +_PyJumpTargetLabel _PyInstructionSequence_NewLabel(_PyInstructionSequence *seq); +int _PyInstructionSequence_ApplyLabelMap(_PyInstructionSequence *seq); +int _PyInstructionSequence_InsertInstruction(_PyInstructionSequence *seq, int pos, + int opcode, int oparg, _Py_SourceLocation loc); +int _PyInstructionSequence_AddNested(_PyInstructionSequence *seq, _PyInstructionSequence *nested); +void PyInstructionSequence_Fini(_PyInstructionSequence *seq); + +extern PyTypeObject _PyInstructionSequence_Type; +#define _PyInstructionSequence_Check(v) Py_IS_TYPE((v), &_PyInstructionSequence_Type) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_INSTRUCTION_SEQUENCE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_instruments.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_instruments.h new file mode 100644 index 00000000..c98e82c8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_instruments.h @@ -0,0 +1,75 @@ +#ifndef Py_INTERNAL_INSTRUMENT_H +#define Py_INTERNAL_INSTRUMENT_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_frame.h" // _PyInterpreterFrame + +#ifdef __cplusplus +extern "C" { +#endif + +#define PY_MONITORING_TOOL_IDS 8 + +typedef uint32_t _PyMonitoringEventSet; + +/* Tool IDs */ + +/* These are defined in PEP 669 for convenience to avoid clashes */ +#define PY_MONITORING_DEBUGGER_ID 0 +#define PY_MONITORING_COVERAGE_ID 1 +#define PY_MONITORING_PROFILER_ID 2 +#define PY_MONITORING_OPTIMIZER_ID 5 + +/* Internal IDs used to suuport sys.setprofile() and sys.settrace() */ +#define PY_MONITORING_SYS_PROFILE_ID 6 +#define PY_MONITORING_SYS_TRACE_ID 7 + + +PyObject *_PyMonitoring_RegisterCallback(int tool_id, int event_id, PyObject *obj); + +int _PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events); +int _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet events); +int _PyMonitoring_GetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet *events); + +extern int +_Py_call_instrumentation(PyThreadState *tstate, int event, + _PyInterpreterFrame *frame, _Py_CODEUNIT *instr); + +extern int +_Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame, + _Py_CODEUNIT *instr, _Py_CODEUNIT *prev); + +extern int +_Py_call_instrumentation_instruction( + PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr); + +_Py_CODEUNIT * +_Py_call_instrumentation_jump( + PyThreadState *tstate, int event, + _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *target); + +extern int +_Py_call_instrumentation_arg(PyThreadState *tstate, int event, + _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg); + +extern int +_Py_call_instrumentation_2args(PyThreadState *tstate, int event, + _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1); + +extern void +_Py_call_instrumentation_exc2(PyThreadState *tstate, int event, + _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1); + +extern int +_Py_Instrumentation_GetLine(PyCodeObject *code, int index); + +extern PyObject _PyInstrumentation_MISSING; +extern PyObject _PyInstrumentation_DISABLE; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_INSTRUMENT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_interp.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_interp.h new file mode 100644 index 00000000..075d35a3 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_interp.h @@ -0,0 +1,423 @@ +#ifndef Py_INTERNAL_INTERP_H +#define Py_INTERNAL_INTERP_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include // bool + +#include "pycore_ast_state.h" // struct ast_state +#include "pycore_atexit.h" // struct atexit_state +#include "pycore_ceval_state.h" // struct _ceval_state +#include "pycore_code.h" // struct callable_cache +#include "pycore_codecs.h" // struct codecs_state +#include "pycore_context.h" // struct _Py_context_state +#include "pycore_crossinterp.h" // struct _xidregistry +#include "pycore_dict_state.h" // struct _Py_dict_state +#include "pycore_dtoa.h" // struct _dtoa_state +#include "pycore_exceptions.h" // struct _Py_exc_state +#include "pycore_floatobject.h" // struct _Py_float_state +#include "pycore_function.h" // FUNC_MAX_WATCHERS +#include "pycore_gc.h" // struct _gc_runtime_state +#include "pycore_genobject.h" // struct _Py_async_gen_state +#include "pycore_global_objects.h"// struct _Py_interp_cached_objects +#include "pycore_import.h" // struct _import_state +#include "pycore_instruments.h" // _PY_MONITORING_EVENTS +#include "pycore_list.h" // struct _Py_list_state +#include "pycore_mimalloc.h" // struct _mimalloc_interp_state +#include "pycore_object_state.h" // struct _py_object_state +#include "pycore_optimizer.h" // _PyOptimizerObject +#include "pycore_obmalloc.h" // struct _obmalloc_state +#include "pycore_qsbr.h" // struct _qsbr_state +#include "pycore_tstate.h" // _PyThreadStateImpl +#include "pycore_tuple.h" // struct _Py_tuple_state +#include "pycore_typeobject.h" // struct types_state +#include "pycore_unicodeobject.h" // struct _Py_unicode_state +#include "pycore_warnings.h" // struct _warnings_runtime_state + + +struct _Py_long_state { + int max_str_digits; +}; + +// Support for stop-the-world events. This exists in both the PyRuntime struct +// for global pauses and in each PyInterpreterState for per-interpreter pauses. +struct _stoptheworld_state { + PyMutex mutex; // Serializes stop-the-world attempts. + + // NOTE: The below fields are protected by HEAD_LOCK(runtime), not by the + // above mutex. + bool requested; // Set when a pause is requested. + bool world_stopped; // Set when the world is stopped. + bool is_global; // Set when contained in PyRuntime struct. + + PyEvent stop_event; // Set when thread_countdown reaches zero. + Py_ssize_t thread_countdown; // Number of threads that must pause. + + PyThreadState *requester; // Thread that requested the pause (may be NULL). +}; + +#ifdef Py_GIL_DISABLED +// This should be prime but otherwise the choice is arbitrary. A larger value +// increases concurrency at the expense of memory. +# define NUM_WEAKREF_LIST_LOCKS 127 +#endif + +/* cross-interpreter data registry */ + +/* Tracks some rare events per-interpreter, used by the optimizer to turn on/off + specific optimizations. */ +typedef struct _rare_events { + /* Setting an object's class, obj.__class__ = ... */ + uint8_t set_class; + /* Setting the bases of a class, cls.__bases__ = ... */ + uint8_t set_bases; + /* Setting the PEP 523 frame eval function, _PyInterpreterState_SetFrameEvalFunc() */ + uint8_t set_eval_frame_func; + /* Modifying the builtins, __builtins__.__dict__[var] = ... */ + uint8_t builtin_dict; + /* Modifying a function, e.g. func.__defaults__ = ..., etc. */ + uint8_t func_modification; +} _rare_events; + +/* interpreter state */ + +/* PyInterpreterState holds the global state for one of the runtime's + interpreters. Typically the initial (main) interpreter is the only one. + + The PyInterpreterState typedef is in Include/pytypedefs.h. + */ +struct _is { + + /* This struct contains the eval_breaker, + * which is by far the hottest field in this struct + * and should be placed at the beginning. */ + struct _ceval_state ceval; + + PyInterpreterState *next; + + int64_t id; + int64_t id_refcount; + int requires_idref; + PyThread_type_lock id_mutex; + +#define _PyInterpreterState_WHENCE_NOTSET -1 +#define _PyInterpreterState_WHENCE_UNKNOWN 0 +#define _PyInterpreterState_WHENCE_RUNTIME 1 +#define _PyInterpreterState_WHENCE_LEGACY_CAPI 2 +#define _PyInterpreterState_WHENCE_CAPI 3 +#define _PyInterpreterState_WHENCE_XI 4 +#define _PyInterpreterState_WHENCE_STDLIB 5 +#define _PyInterpreterState_WHENCE_MAX 5 + long _whence; + + /* Has been initialized to a safe state. + + In order to be effective, this must be set to 0 during or right + after allocation. */ + int _initialized; + /* Has been fully initialized via pylifecycle.c. */ + int _ready; + int finalizing; + + uintptr_t last_restart_version; + struct pythreads { + uint64_t next_unique_id; + /* The linked list of threads, newest first. */ + PyThreadState *head; + /* The thread currently executing in the __main__ module, if any. */ + PyThreadState *main; + /* Used in Modules/_threadmodule.c. */ + Py_ssize_t count; + /* Support for runtime thread stack size tuning. + A value of 0 means using the platform's default stack size + or the size specified by the THREAD_STACK_SIZE macro. */ + /* Used in Python/thread.c. */ + size_t stacksize; + } threads; + + /* Reference to the _PyRuntime global variable. This field exists + to not have to pass runtime in addition to tstate to a function. + Get runtime from tstate: tstate->interp->runtime. */ + struct pyruntimestate *runtime; + + /* Set by Py_EndInterpreter(). + + Use _PyInterpreterState_GetFinalizing() + and _PyInterpreterState_SetFinalizing() + to access it, don't access it directly. */ + PyThreadState* _finalizing; + /* The ID of the OS thread in which we are finalizing. */ + unsigned long _finalizing_id; + + struct _gc_runtime_state gc; + + /* The following fields are here to avoid allocation during init. + The data is exposed through PyInterpreterState pointer fields. + These fields should not be accessed directly outside of init. + + All other PyInterpreterState pointer fields are populated when + needed and default to NULL. + + For now there are some exceptions to that rule, which require + allocation during init. These will be addressed on a case-by-case + basis. Also see _PyRuntimeState regarding the various mutex fields. + */ + + // Dictionary of the sys module + PyObject *sysdict; + + // Dictionary of the builtins module + PyObject *builtins; + + struct _import_state imports; + + /* The per-interpreter GIL, which might not be used. */ + struct _gil_runtime_state _gil; + + /* ---------- IMPORTANT --------------------------- + The fields above this line are declared as early as + possible to facilitate out-of-process observability + tools. */ + + struct codecs_state codecs; + + PyConfig config; + unsigned long feature_flags; + + PyObject *dict; /* Stores per-interpreter state */ + + PyObject *sysdict_copy; + PyObject *builtins_copy; + // Initialized to _PyEval_EvalFrameDefault(). + _PyFrameEvalFunction eval_frame; + + PyFunction_WatchCallback func_watchers[FUNC_MAX_WATCHERS]; + // One bit is set for each non-NULL entry in func_watchers + uint8_t active_func_watchers; + + Py_ssize_t co_extra_user_count; + freefunc co_extra_freefuncs[MAX_CO_EXTRA_USERS]; + + /* cross-interpreter data and utils */ + struct _xi_state xi; + +#ifdef HAVE_FORK + PyObject *before_forkers; + PyObject *after_forkers_parent; + PyObject *after_forkers_child; +#endif + + struct _warnings_runtime_state warnings; + struct atexit_state atexit; + struct _stoptheworld_state stoptheworld; + struct _qsbr_shared qsbr; + +#if defined(Py_GIL_DISABLED) + struct _mimalloc_interp_state mimalloc; + struct _brc_state brc; // biased reference counting state + PyMutex weakref_locks[NUM_WEAKREF_LIST_LOCKS]; +#endif + + // Per-interpreter state for the obmalloc allocator. For the main + // interpreter and for all interpreters that don't have their + // own obmalloc state, this points to the static structure in + // obmalloc.c obmalloc_state_main. For other interpreters, it is + // heap allocated by _PyMem_init_obmalloc() and freed when the + // interpreter structure is freed. In the case of a heap allocated + // obmalloc state, it is not safe to hold on to or use memory after + // the interpreter is freed. The obmalloc state corresponding to + // that allocated memory is gone. See free_obmalloc_arenas() for + // more comments. + struct _obmalloc_state *obmalloc; + + PyObject *audit_hooks; + PyType_WatchCallback type_watchers[TYPE_MAX_WATCHERS]; + PyCode_WatchCallback code_watchers[CODE_MAX_WATCHERS]; + // One bit is set for each non-NULL entry in code_watchers + uint8_t active_code_watchers; + + struct _py_object_state object_state; + struct _Py_unicode_state unicode; + struct _Py_long_state long_state; + struct _dtoa_state dtoa; + struct _py_func_state func_state; + struct _py_code_state code_state; + + struct _Py_dict_state dict_state; + struct _Py_exc_state exc_state; + struct _Py_mem_interp_free_queue mem_free_queue; + + struct ast_state ast; + struct types_state types; + struct callable_cache callable_cache; + _PyOptimizerObject *optimizer; + _PyExecutorObject *executor_list_head; + + _rare_events rare_events; + PyDict_WatchCallback builtins_dict_watcher; + + _Py_GlobalMonitors monitors; + bool sys_profile_initialized; + bool sys_trace_initialized; + Py_ssize_t sys_profiling_threads; /* Count of threads with c_profilefunc set */ + Py_ssize_t sys_tracing_threads; /* Count of threads with c_tracefunc set */ + PyObject *monitoring_callables[PY_MONITORING_TOOL_IDS][_PY_MONITORING_EVENTS]; + PyObject *monitoring_tool_names[PY_MONITORING_TOOL_IDS]; + + struct _Py_interp_cached_objects cached_objects; + struct _Py_interp_static_objects static_objects; + + /* the initial PyInterpreterState.threads.head */ + _PyThreadStateImpl _initial_thread; + Py_ssize_t _interactive_src_count; + // In 3.14+ this is interp->threads.preallocated. + _PyThreadStateImpl *threads_preallocated; +}; + + +/* other API */ + +extern void _PyInterpreterState_Clear(PyThreadState *tstate); + + +static inline PyThreadState* +_PyInterpreterState_GetFinalizing(PyInterpreterState *interp) { + return (PyThreadState*)_Py_atomic_load_ptr_relaxed(&interp->_finalizing); +} + +static inline unsigned long +_PyInterpreterState_GetFinalizingID(PyInterpreterState *interp) { + return _Py_atomic_load_ulong_relaxed(&interp->_finalizing_id); +} + +static inline void +_PyInterpreterState_SetFinalizing(PyInterpreterState *interp, PyThreadState *tstate) { + _Py_atomic_store_ptr_relaxed(&interp->_finalizing, tstate); + if (tstate == NULL) { + _Py_atomic_store_ulong_relaxed(&interp->_finalizing_id, 0); + } + else { + // XXX Re-enable this assert once gh-109860 is fixed. + //assert(tstate->thread_id == PyThread_get_thread_ident()); + _Py_atomic_store_ulong_relaxed(&interp->_finalizing_id, + tstate->thread_id); + } +} + + + +// Exports for the _testinternalcapi module. +PyAPI_FUNC(int64_t) _PyInterpreterState_ObjectToID(PyObject *); +PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpID(int64_t); +PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpIDObject(PyObject *); +PyAPI_FUNC(int) _PyInterpreterState_IDInitref(PyInterpreterState *); +PyAPI_FUNC(int) _PyInterpreterState_IDIncref(PyInterpreterState *); +PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *); + +PyAPI_FUNC(int) _PyInterpreterState_IsReady(PyInterpreterState *interp); + +PyAPI_FUNC(long) _PyInterpreterState_GetWhence(PyInterpreterState *interp); +extern void _PyInterpreterState_SetWhence( + PyInterpreterState *interp, + long whence); + +extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp); + +// Get a copy of the current interpreter configuration. +// +// Return 0 on success. Raise an exception and return -1 on error. +// +// The caller must initialize 'config', using PyConfig_InitPythonConfig() +// for example. +// +// Python must be preinitialized to call this method. +// The caller must hold the GIL. +// +// Once done with the configuration, PyConfig_Clear() must be called to clear +// it. +// +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy( + struct PyConfig *config); + +// Set the configuration of the current interpreter. +// +// This function should be called during or just after the Python +// initialization. +// +// Update the sys module with the new configuration. If the sys module was +// modified directly after the Python initialization, these changes are lost. +// +// Some configuration like faulthandler or warnoptions can be updated in the +// configuration, but don't reconfigure Python (don't enable/disable +// faulthandler and don't reconfigure warnings filters). +// +// Return 0 on success. Raise an exception and return -1 on error. +// +// The configuration should come from _PyInterpreterState_GetConfigCopy(). +// +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(int) _PyInterpreterState_SetConfig( + const struct PyConfig *config); + + +/* +Runtime Feature Flags + +Each flag indicate whether or not a specific runtime feature +is available in a given context. For example, forking the process +might not be allowed in the current interpreter (i.e. os.fork() would fail). +*/ + +/* Set if the interpreter share obmalloc runtime state + with the main interpreter. */ +#define Py_RTFLAGS_USE_MAIN_OBMALLOC (1UL << 5) + +/* Set if import should check a module for subinterpreter support. */ +#define Py_RTFLAGS_MULTI_INTERP_EXTENSIONS (1UL << 8) + +/* Set if threads are allowed. */ +#define Py_RTFLAGS_THREADS (1UL << 10) + +/* Set if daemon threads are allowed. */ +#define Py_RTFLAGS_DAEMON_THREADS (1UL << 11) + +/* Set if os.fork() is allowed. */ +#define Py_RTFLAGS_FORK (1UL << 15) + +/* Set if os.exec*() is allowed. */ +#define Py_RTFLAGS_EXEC (1UL << 16) + +extern int _PyInterpreterState_HasFeature(PyInterpreterState *interp, + unsigned long feature); + +PyAPI_FUNC(PyStatus) _PyInterpreterState_New( + PyThreadState *tstate, + PyInterpreterState **pinterp); + + +#define RARE_EVENT_INTERP_INC(interp, name) \ + do { \ + /* saturating add */ \ + int val = FT_ATOMIC_LOAD_UINT8_RELAXED(interp->rare_events.name); \ + if (val < UINT8_MAX) { \ + FT_ATOMIC_STORE_UINT8(interp->rare_events.name, val + 1); \ + } \ + RARE_EVENT_STAT_INC(name); \ + } while (0); \ + +#define RARE_EVENT_INC(name) \ + do { \ + PyInterpreterState *interp = PyInterpreterState_Get(); \ + RARE_EVENT_INTERP_INC(interp, name); \ + } while (0); \ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_INTERP_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_intrinsics.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_intrinsics.h new file mode 100644 index 00000000..39c2a30f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_intrinsics.h @@ -0,0 +1,51 @@ +#ifndef Py_INTERNAL_INTRINSIC_H +#define Py_INTERNAL_INTRINSIC_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* Unary Functions: */ +#define INTRINSIC_1_INVALID 0 +#define INTRINSIC_PRINT 1 +#define INTRINSIC_IMPORT_STAR 2 +#define INTRINSIC_STOPITERATION_ERROR 3 +#define INTRINSIC_ASYNC_GEN_WRAP 4 +#define INTRINSIC_UNARY_POSITIVE 5 +#define INTRINSIC_LIST_TO_TUPLE 6 +#define INTRINSIC_TYPEVAR 7 +#define INTRINSIC_PARAMSPEC 8 +#define INTRINSIC_TYPEVARTUPLE 9 +#define INTRINSIC_SUBSCRIPT_GENERIC 10 +#define INTRINSIC_TYPEALIAS 11 + +#define MAX_INTRINSIC_1 11 + + +/* Binary Functions: */ +#define INTRINSIC_2_INVALID 0 +#define INTRINSIC_PREP_RERAISE_STAR 1 +#define INTRINSIC_TYPEVAR_WITH_BOUND 2 +#define INTRINSIC_TYPEVAR_WITH_CONSTRAINTS 3 +#define INTRINSIC_SET_FUNCTION_TYPE_PARAMS 4 +#define INTRINSIC_SET_TYPEPARAM_DEFAULT 5 + +#define MAX_INTRINSIC_2 5 + +typedef PyObject *(*intrinsic_func1)(PyThreadState* tstate, PyObject *value); +typedef PyObject *(*intrinsic_func2)(PyThreadState* tstate, PyObject *value1, PyObject *value2); + +typedef struct { + intrinsic_func1 func; + const char *name; +} intrinsic_func1_info; + +typedef struct { + intrinsic_func2 func; + const char *name; +} intrinsic_func2_info; + +PyAPI_DATA(const intrinsic_func1_info) _PyIntrinsics_UnaryFunctions[]; +PyAPI_DATA(const intrinsic_func2_info) _PyIntrinsics_BinaryFunctions[]; + +#endif // !Py_INTERNAL_INTRINSIC_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_jit.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_jit.h new file mode 100644 index 00000000..17bd23f0 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_jit.h @@ -0,0 +1,25 @@ +#ifndef Py_INTERNAL_JIT_H +#define Py_INTERNAL_JIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#ifdef _Py_JIT + +typedef _Py_CODEUNIT *(*jit_func)(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *tstate); + +int _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction *trace, size_t length); +void _PyJIT_Free(_PyExecutorObject *executor); + +#endif // _Py_JIT + +#ifdef __cplusplus +} +#endif + +#endif // !Py_INTERNAL_JIT_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_list.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_list.h new file mode 100644 index 00000000..73695d10 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_list.h @@ -0,0 +1,66 @@ +#ifndef Py_INTERNAL_LIST_H +#define Py_INTERNAL_LIST_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_freelist.h" // _PyFreeListState + +PyAPI_FUNC(PyObject*) _PyList_Extend(PyListObject *, PyObject *); +extern void _PyList_DebugMallocStats(FILE *out); + +#define _PyList_ITEMS(op) _Py_RVALUE(_PyList_CAST(op)->ob_item) + +PyAPI_FUNC(int) +_PyList_AppendTakeRefListResize(PyListObject *self, PyObject *newitem); + +// In free-threaded build: self should be locked by the caller, if it should be thread-safe. +static inline int +_PyList_AppendTakeRef(PyListObject *self, PyObject *newitem) +{ + assert(self != NULL && newitem != NULL); + assert(PyList_Check(self)); + Py_ssize_t len = Py_SIZE(self); + Py_ssize_t allocated = self->allocated; + assert((size_t)len + 1 < PY_SSIZE_T_MAX); + if (allocated > len) { +#ifdef Py_GIL_DISABLED + _Py_atomic_store_ptr_release(&self->ob_item[len], newitem); +#else + PyList_SET_ITEM(self, len, newitem); +#endif + Py_SET_SIZE(self, len + 1); + return 0; + } + return _PyList_AppendTakeRefListResize(self, newitem); +} + +// Repeat the bytes of a buffer in place +static inline void +_Py_memory_repeat(char* dest, Py_ssize_t len_dest, Py_ssize_t len_src) +{ + assert(len_src > 0); + Py_ssize_t copied = len_src; + while (copied < len_dest) { + Py_ssize_t bytes_to_copy = Py_MIN(copied, len_dest - copied); + memcpy(dest + copied, dest, bytes_to_copy); + copied += bytes_to_copy; + } +} + +typedef struct { + PyObject_HEAD + Py_ssize_t it_index; + PyListObject *it_seq; /* Set to NULL when iterator is exhausted */ +} _PyListIterObject; + +PyAPI_FUNC(PyObject *)_PyList_FromArraySteal(PyObject *const *src, Py_ssize_t n); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_LIST_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_llist.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_llist.h new file mode 100644 index 00000000..f629902f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_llist.h @@ -0,0 +1,106 @@ +// A doubly-linked list that can be embedded in a struct. +// +// Usage: +// struct llist_node head = LLIST_INIT(head); +// typedef struct { +// ... +// struct llist_node node; +// ... +// } MyObj; +// +// llist_insert_tail(&head, &obj->node); +// llist_remove(&obj->node); +// +// struct llist_node *node; +// llist_for_each(node, &head) { +// MyObj *obj = llist_data(node, MyObj, node); +// ... +// } +// + +#ifndef Py_INTERNAL_LLIST_H +#define Py_INTERNAL_LLIST_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "Py_BUILD_CORE must be defined to include this header" +#endif + +struct llist_node { + struct llist_node *next; + struct llist_node *prev; +}; + +// Get the struct containing a node. +#define llist_data(node, type, member) (_Py_CONTAINER_OF(node, type, member)) + +// Iterate over a list. +#define llist_for_each(node, head) \ + for (node = (head)->next; node != (head); node = node->next) + +// Iterate over a list, but allow removal of the current node. +#define llist_for_each_safe(node, head) \ + for (struct llist_node *_next = (node = (head)->next, node->next); \ + node != (head); node = _next, _next = node->next) + +#define LLIST_INIT(head) { &head, &head } + +static inline void +llist_init(struct llist_node *head) +{ + head->next = head; + head->prev = head; +} + +// Returns 1 if the list is empty, 0 otherwise. +static inline int +llist_empty(struct llist_node *head) +{ + return head->next == head; +} + +// Appends to the tail of the list. +static inline void +llist_insert_tail(struct llist_node *head, struct llist_node *node) +{ + node->prev = head->prev; + node->next = head; + head->prev->next = node; + head->prev = node; +} + +// Remove a node from the list. +static inline void +llist_remove(struct llist_node *node) +{ + struct llist_node *prev = node->prev; + struct llist_node *next = node->next; + prev->next = next; + next->prev = prev; + node->prev = NULL; + node->next = NULL; +} + +// Append all nodes from head2 onto head1. head2 is left empty. +static inline void +llist_concat(struct llist_node *head1, struct llist_node *head2) +{ + if (!llist_empty(head2)) { + head1->prev->next = head2->next; + head2->next->prev = head1->prev; + + head1->prev = head2->prev; + head2->prev->next = head1; + llist_init(head2); + } +} + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_LLIST_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_lock.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_lock.h new file mode 100644 index 00000000..2a18bb76 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_lock.h @@ -0,0 +1,241 @@ +// Lightweight locks and other synchronization mechanisms. +// +// These implementations are based on WebKit's WTF::Lock. See +// https://webkit.org/blog/6161/locking-in-webkit/ for a description of the +// design. +#ifndef Py_INTERNAL_LOCK_H +#define Py_INTERNAL_LOCK_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +//_Py_UNLOCKED is defined as 0 and _Py_LOCKED as 1 in Include/cpython/lock.h +#define _Py_HAS_PARKED 2 +#define _Py_ONCE_INITIALIZED 4 + +static inline int +PyMutex_LockFast(uint8_t *lock_bits) +{ + uint8_t expected = _Py_UNLOCKED; + return _Py_atomic_compare_exchange_uint8(lock_bits, &expected, _Py_LOCKED); +} + +// Checks if the mutex is currently locked. +static inline int +PyMutex_IsLocked(PyMutex *m) +{ + return (_Py_atomic_load_uint8(&m->_bits) & _Py_LOCKED) != 0; +} + +// Re-initializes the mutex after a fork to the unlocked state. +static inline void +_PyMutex_at_fork_reinit(PyMutex *m) +{ + memset(m, 0, sizeof(*m)); +} + +typedef enum _PyLockFlags { + // Do not detach/release the GIL when waiting on the lock. + _Py_LOCK_DONT_DETACH = 0, + + // Detach/release the GIL while waiting on the lock. + _PY_LOCK_DETACH = 1, + + // Handle signals if interrupted while waiting on the lock. + _PY_LOCK_HANDLE_SIGNALS = 2, +} _PyLockFlags; + +// Lock a mutex with an optional timeout and additional options. See +// _PyLockFlags for details. +extern PyLockStatus +_PyMutex_LockTimed(PyMutex *m, PyTime_t timeout_ns, _PyLockFlags flags); + +// Lock a mutex with aditional options. See _PyLockFlags for details. +static inline void +PyMutex_LockFlags(PyMutex *m, _PyLockFlags flags) +{ + uint8_t expected = _Py_UNLOCKED; + if (!_Py_atomic_compare_exchange_uint8(&m->_bits, &expected, _Py_LOCKED)) { + _PyMutex_LockTimed(m, -1, flags); + } +} + +// Unlock a mutex, returns 0 if the mutex is not locked (used for improved +// error messages). +extern int _PyMutex_TryUnlock(PyMutex *m); + + +// PyEvent is a one-time event notification +typedef struct { + uint8_t v; +} PyEvent; + +// Check if the event is set without blocking. Returns 1 if the event is set or +// 0 otherwise. +PyAPI_FUNC(int) _PyEvent_IsSet(PyEvent *evt); + +// Set the event and notify any waiting threads. +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(void) _PyEvent_Notify(PyEvent *evt); + +// Wait for the event to be set. If the event is already set, then this returns +// immediately. +PyAPI_FUNC(void) PyEvent_Wait(PyEvent *evt); + +// Wait for the event to be set, or until the timeout expires. If the event is +// already set, then this returns immediately. Returns 1 if the event was set, +// and 0 if the timeout expired or thread was interrupted. If `detach` is +// true, then the thread will detach/release the GIL while waiting. +PyAPI_FUNC(int) +PyEvent_WaitTimed(PyEvent *evt, PyTime_t timeout_ns, int detach); + +// _PyRawMutex implements a word-sized mutex that that does not depend on the +// parking lot API, and therefore can be used in the parking lot +// implementation. +// +// The mutex uses a packed representation: the least significant bit is used to +// indicate whether the mutex is locked or not. The remaining bits are either +// zero or a pointer to a `struct raw_mutex_entry` (see lock.c). +typedef struct { + uintptr_t v; +} _PyRawMutex; + +// Slow paths for lock/unlock +extern void _PyRawMutex_LockSlow(_PyRawMutex *m); +extern void _PyRawMutex_UnlockSlow(_PyRawMutex *m); + +static inline void +_PyRawMutex_Lock(_PyRawMutex *m) +{ + uintptr_t unlocked = _Py_UNLOCKED; + if (_Py_atomic_compare_exchange_uintptr(&m->v, &unlocked, _Py_LOCKED)) { + return; + } + _PyRawMutex_LockSlow(m); +} + +static inline void +_PyRawMutex_Unlock(_PyRawMutex *m) +{ + uintptr_t locked = _Py_LOCKED; + if (_Py_atomic_compare_exchange_uintptr(&m->v, &locked, _Py_UNLOCKED)) { + return; + } + _PyRawMutex_UnlockSlow(m); +} + +// Type signature for one-time initialization functions. The function should +// return 0 on success and -1 on failure. +typedef int _Py_once_fn_t(void *arg); + +// (private) slow path for one time initialization +PyAPI_FUNC(int) +_PyOnceFlag_CallOnceSlow(_PyOnceFlag *flag, _Py_once_fn_t *fn, void *arg); + +// Calls `fn` once using `flag`. The `arg` is passed to the call to `fn`. +// +// Returns 0 on success and -1 on failure. +// +// If `fn` returns 0 (success), then subsequent calls immediately return 0. +// If `fn` returns -1 (failure), then subsequent calls will retry the call. +static inline int +_PyOnceFlag_CallOnce(_PyOnceFlag *flag, _Py_once_fn_t *fn, void *arg) +{ + if (_Py_atomic_load_uint8(&flag->v) == _Py_ONCE_INITIALIZED) { + return 0; + } + return _PyOnceFlag_CallOnceSlow(flag, fn, arg); +} + +// A recursive mutex. The mutex should zero-initialized. +typedef struct { + PyMutex mutex; + unsigned long long thread; // i.e., PyThread_get_thread_ident_ex() + size_t level; +} _PyRecursiveMutex; + +PyAPI_FUNC(int) _PyRecursiveMutex_IsLockedByCurrentThread(_PyRecursiveMutex *m); +PyAPI_FUNC(void) _PyRecursiveMutex_Lock(_PyRecursiveMutex *m); +PyAPI_FUNC(void) _PyRecursiveMutex_Unlock(_PyRecursiveMutex *m); + + +// A readers-writer (RW) lock. The lock supports multiple concurrent readers or +// a single writer. The lock is write-preferring: if a writer is waiting while +// the lock is read-locked then, new readers will be blocked. This avoids +// starvation of writers. +// +// In C++, the equivalent synchronization primitive is std::shared_mutex +// with shared ("read") and exclusive ("write") locking. +// +// The two least significant bits are used to indicate if the lock is +// write-locked and if there are parked threads (either readers or writers) +// waiting to acquire the lock. The remaining bits are used to indicate the +// number of readers holding the lock. +// +// 0b000..00000: unlocked +// 0bnnn..nnn00: nnn..nnn readers holding the lock +// 0bnnn..nnn10: nnn..nnn readers holding the lock and a writer is waiting +// 0b00000..010: unlocked with awoken writer about to acquire lock +// 0b00000..001: write-locked +// 0b00000..011: write-locked and readers or other writers are waiting +// +// Note that reader_count must be zero if the lock is held by a writer, and +// vice versa. The lock can only be held by readers or a writer, but not both. +// +// The design is optimized for simplicity of the implementation. The lock is +// not fair: if fairness is desired, use an additional PyMutex to serialize +// writers. The lock is also not reentrant. +typedef struct { + uintptr_t bits; +} _PyRWMutex; + +// Read lock (i.e., shared lock) +PyAPI_FUNC(void) _PyRWMutex_RLock(_PyRWMutex *rwmutex); +PyAPI_FUNC(void) _PyRWMutex_RUnlock(_PyRWMutex *rwmutex); + +// Write lock (i.e., exclusive lock) +PyAPI_FUNC(void) _PyRWMutex_Lock(_PyRWMutex *rwmutex); +PyAPI_FUNC(void) _PyRWMutex_Unlock(_PyRWMutex *rwmutex); + +// Similar to linux seqlock: https://en.wikipedia.org/wiki/Seqlock +// We use a sequence number to lock the writer, an even sequence means we're unlocked, an odd +// sequence means we're locked. Readers will read the sequence before attempting to read the +// underlying data and then read the sequence number again after reading the data. If the +// sequence has not changed the data is valid. +// +// Differs a little bit in that we use CAS on sequence as the lock, instead of a separate spin lock. +// The writer can also detect that the undelering data has not changed and abandon the write +// and restore the previous sequence. +typedef struct { + uint32_t sequence; +} _PySeqLock; + +// Lock the sequence lock for the writer +PyAPI_FUNC(void) _PySeqLock_LockWrite(_PySeqLock *seqlock); + +// Unlock the sequence lock and move to the next sequence number. +PyAPI_FUNC(void) _PySeqLock_UnlockWrite(_PySeqLock *seqlock); + +// Abandon the current update indicating that no mutations have occurred +// and restore the previous sequence value. +PyAPI_FUNC(void) _PySeqLock_AbandonWrite(_PySeqLock *seqlock); + +// Begin a read operation and return the current sequence number. +PyAPI_FUNC(uint32_t) _PySeqLock_BeginRead(_PySeqLock *seqlock); + +// End the read operation and confirm that the sequence number has not changed. +// Returns 1 if the read was successful or 0 if the read should be retried. +PyAPI_FUNC(int) _PySeqLock_EndRead(_PySeqLock *seqlock, uint32_t previous); + +// Check if the lock was held during a fork and clear the lock. Returns 1 +// if the lock was held and any associated data should be cleared. +PyAPI_FUNC(int) _PySeqLock_AfterFork(_PySeqLock *seqlock); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_LOCK_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_long.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_long.h new file mode 100644 index 00000000..ff7d9afc --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_long.h @@ -0,0 +1,310 @@ +#ifndef Py_INTERNAL_LONG_H +#define Py_INTERNAL_LONG_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_bytesobject.h" // _PyBytesWriter +#include "pycore_global_objects.h"// _PY_NSMALLNEGINTS +#include "pycore_runtime.h" // _PyRuntime + +/* + * Default int base conversion size limitation: Denial of Service prevention. + * + * Chosen such that this isn't wildly slow on modern hardware and so that + * everyone's existing deployed numpy test suite passes before + * https://github.com/numpy/numpy/issues/22098 is widely available. + * + * $ python -m timeit -s 's = "1"*4300' 'int(s)' + * 2000 loops, best of 5: 125 usec per loop + * $ python -m timeit -s 's = "1"*4300; v = int(s)' 'str(v)' + * 1000 loops, best of 5: 311 usec per loop + * (zen2 cloud VM) + * + * 4300 decimal digits fits a ~14284 bit number. + */ +#define _PY_LONG_DEFAULT_MAX_STR_DIGITS 4300 +/* + * Threshold for max digits check. For performance reasons int() and + * int.__str__() don't checks values that are smaller than this + * threshold. Acts as a guaranteed minimum size limit for bignums that + * applications can expect from CPython. + * + * % python -m timeit -s 's = "1"*640; v = int(s)' 'str(int(s))' + * 20000 loops, best of 5: 12 usec per loop + * + * "640 digits should be enough for anyone." - gps + * fits a ~2126 bit decimal number. + */ +#define _PY_LONG_MAX_STR_DIGITS_THRESHOLD 640 + +#if ((_PY_LONG_DEFAULT_MAX_STR_DIGITS != 0) && \ + (_PY_LONG_DEFAULT_MAX_STR_DIGITS < _PY_LONG_MAX_STR_DIGITS_THRESHOLD)) +# error "_PY_LONG_DEFAULT_MAX_STR_DIGITS smaller than threshold." +#endif + +/* runtime lifecycle */ + +extern PyStatus _PyLong_InitTypes(PyInterpreterState *); +extern void _PyLong_FiniTypes(PyInterpreterState *interp); + + +/* other API */ + +#define _PyLong_SMALL_INTS _Py_SINGLETON(small_ints) + +// _PyLong_GetZero() and _PyLong_GetOne() must always be available +// _PyLong_FromUnsignedChar must always be available +#if _PY_NSMALLPOSINTS < 257 +# error "_PY_NSMALLPOSINTS must be greater than or equal to 257" +#endif + +// Return a reference to the immortal zero singleton. +// The function cannot return NULL. +static inline PyObject* _PyLong_GetZero(void) +{ return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS]; } + +// Return a reference to the immortal one singleton. +// The function cannot return NULL. +static inline PyObject* _PyLong_GetOne(void) +{ return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS+1]; } + +static inline PyObject* _PyLong_FromUnsignedChar(unsigned char i) +{ + return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS+i]; +} + +// _PyLong_Frexp returns a double x and an exponent e such that the +// true value is approximately equal to x * 2**e. e is >= 0. x is +// 0.0 if and only if the input is 0 (in which case, e and x are both +// zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is +// possible if the number of bits doesn't fit into a Py_ssize_t, sets +// OverflowError and returns -1.0 for x, 0 for e. +// +// Export for 'math' shared extension +PyAPI_DATA(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e); + +extern PyObject* _PyLong_FromBytes(const char *, Py_ssize_t, int); + +// _PyLong_DivmodNear. Given integers a and b, compute the nearest +// integer q to the exact quotient a / b, rounding to the nearest even integer +// in the case of a tie. Return (q, r), where r = a - q*b. The remainder r +// will satisfy abs(r) <= abs(b)/2, with equality possible only if q is +// even. +// +// Export for '_datetime' shared extension. +PyAPI_DATA(PyObject*) _PyLong_DivmodNear(PyObject *, PyObject *); + +// _PyLong_Format: Convert the long to a string object with given base, +// appending a base prefix of 0[box] if base is 2, 8 or 16. +// Export for '_tkinter' shared extension. +PyAPI_DATA(PyObject*) _PyLong_Format(PyObject *obj, int base); + +// Export for 'math' shared extension +PyAPI_DATA(PyObject*) _PyLong_Rshift(PyObject *, size_t); + +// Export for 'math' shared extension +PyAPI_DATA(PyObject*) _PyLong_Lshift(PyObject *, size_t); + +PyAPI_FUNC(PyObject*) _PyLong_Add(PyLongObject *left, PyLongObject *right); +PyAPI_FUNC(PyObject*) _PyLong_Multiply(PyLongObject *left, PyLongObject *right); +PyAPI_FUNC(PyObject*) _PyLong_Subtract(PyLongObject *left, PyLongObject *right); + +// Export for 'binascii' shared extension. +PyAPI_DATA(unsigned char) _PyLong_DigitValue[256]; + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +extern int _PyLong_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); + +extern int _PyLong_FormatWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + int base, + int alternate); + +extern char* _PyLong_FormatBytesWriter( + _PyBytesWriter *writer, + char *str, + PyObject *obj, + int base, + int alternate); + +// Argument converters used by Argument Clinic + +// Export for 'select' shared extension (Argument Clinic code) +PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *); + +// Export for '_testclinic' shared extension (Argument Clinic code) +PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *); + +// Export for '_blake2' shared extension (Argument Clinic code) +PyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *); + +// Export for '_blake2' shared extension (Argument Clinic code) +PyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *); + +// Export for '_testclinic' shared extension (Argument Clinic code) +PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *); + +/* Long value tag bits: + * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1. + * 2: Reserved for immortality bit + * 3+ Unsigned digit count + */ +#define SIGN_MASK 3 +#define SIGN_ZERO 1 +#define SIGN_NEGATIVE 2 +#define NON_SIZE_BITS 3 + +/* The functions _PyLong_IsCompact and _PyLong_CompactValue are defined + * in Include/cpython/longobject.h, since they need to be inline. + * + * "Compact" values have at least one bit to spare, + * so that addition and subtraction can be performed on the values + * without risk of overflow. + * + * The inline functions need tag bits. + * For readability, rather than do `#define SIGN_MASK _PyLong_SIGN_MASK` + * we define them to the numbers in both places and then assert that + * they're the same. + */ +#if SIGN_MASK != _PyLong_SIGN_MASK +# error "SIGN_MASK does not match _PyLong_SIGN_MASK" +#endif +#if NON_SIZE_BITS != _PyLong_NON_SIZE_BITS +# error "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS" +#endif + +/* All *compact" values are guaranteed to fit into + * a Py_ssize_t with at least one bit to spare. + * In other words, for 64 bit machines, compact + * will be signed 63 (or fewer) bit values + */ + +/* Return 1 if the argument is compact int */ +static inline int +_PyLong_IsNonNegativeCompact(const PyLongObject* op) { + assert(PyLong_Check(op)); + return op->long_value.lv_tag <= (1 << NON_SIZE_BITS); +} + + +static inline int +_PyLong_BothAreCompact(const PyLongObject* a, const PyLongObject* b) { + assert(PyLong_Check(a)); + assert(PyLong_Check(b)); + return (a->long_value.lv_tag | b->long_value.lv_tag) < (2 << NON_SIZE_BITS); +} + +static inline bool +_PyLong_IsZero(const PyLongObject *op) +{ + return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO; +} + +static inline bool +_PyLong_IsNegative(const PyLongObject *op) +{ + return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE; +} + +static inline bool +_PyLong_IsPositive(const PyLongObject *op) +{ + return (op->long_value.lv_tag & SIGN_MASK) == 0; +} + +static inline Py_ssize_t +_PyLong_DigitCount(const PyLongObject *op) +{ + assert(PyLong_Check(op)); + return op->long_value.lv_tag >> NON_SIZE_BITS; +} + +/* Equivalent to _PyLong_DigitCount(op) * _PyLong_NonCompactSign(op) */ +static inline Py_ssize_t +_PyLong_SignedDigitCount(const PyLongObject *op) +{ + assert(PyLong_Check(op)); + Py_ssize_t sign = 1 - (op->long_value.lv_tag & SIGN_MASK); + return sign * (Py_ssize_t)(op->long_value.lv_tag >> NON_SIZE_BITS); +} + +static inline int +_PyLong_CompactSign(const PyLongObject *op) +{ + assert(PyLong_Check(op)); + assert(_PyLong_IsCompact(op)); + return 1 - (op->long_value.lv_tag & SIGN_MASK); +} + +static inline int +_PyLong_NonCompactSign(const PyLongObject *op) +{ + assert(PyLong_Check(op)); + assert(!_PyLong_IsCompact(op)); + return 1 - (op->long_value.lv_tag & SIGN_MASK); +} + +/* Do a and b have the same sign? */ +static inline int +_PyLong_SameSign(const PyLongObject *a, const PyLongObject *b) +{ + return (a->long_value.lv_tag & SIGN_MASK) == (b->long_value.lv_tag & SIGN_MASK); +} + +#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS)) + +static inline void +_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size) +{ + assert(size >= 0); + assert(-1 <= sign && sign <= 1); + assert(sign != 0 || size == 0); + op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size); +} + +static inline void +_PyLong_SetDigitCount(PyLongObject *op, Py_ssize_t size) +{ + assert(size >= 0); + op->long_value.lv_tag = (((size_t)size) << NON_SIZE_BITS) | (op->long_value.lv_tag & SIGN_MASK); +} + +#define NON_SIZE_MASK ~((1 << NON_SIZE_BITS) - 1) + +static inline void +_PyLong_FlipSign(PyLongObject *op) { + unsigned int flipped_sign = 2 - (op->long_value.lv_tag & SIGN_MASK); + op->long_value.lv_tag &= NON_SIZE_MASK; + op->long_value.lv_tag |= flipped_sign; +} + +#define _PyLong_DIGIT_INIT(val) \ + { \ + .ob_base = _PyObject_HEAD_INIT(&PyLong_Type), \ + .long_value = { \ + .lv_tag = TAG_FROM_SIGN_AND_SIZE( \ + (val) == 0 ? 0 : ((val) < 0 ? -1 : 1), \ + (val) == 0 ? 0 : 1), \ + { ((val) >= 0 ? (val) : -(val)) }, \ + } \ + } + +#define _PyLong_FALSE_TAG TAG_FROM_SIGN_AND_SIZE(0, 0) +#define _PyLong_TRUE_TAG TAG_FROM_SIGN_AND_SIZE(1, 1) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_LONG_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_memoryobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_memoryobject.h new file mode 100644 index 00000000..62e204fc --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_memoryobject.h @@ -0,0 +1,20 @@ +#ifndef Py_INTERNAL_MEMORYOBJECT_H +#define Py_INTERNAL_MEMORYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern PyTypeObject _PyManagedBuffer_Type; + +PyObject * +_PyMemoryView_FromBufferProc(PyObject *v, int flags, + getbufferproc bufferproc); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_MEMORYOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_mimalloc.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_mimalloc.h new file mode 100644 index 00000000..d870d01b --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_mimalloc.h @@ -0,0 +1,69 @@ +#ifndef Py_INTERNAL_MIMALLOC_H +#define Py_INTERNAL_MIMALLOC_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#if defined(MIMALLOC_H) || defined(MIMALLOC_TYPES_H) +# error "pycore_mimalloc.h must be included before mimalloc.h" +#endif + +typedef enum { + _Py_MIMALLOC_HEAP_MEM = 0, // PyMem_Malloc() and friends + _Py_MIMALLOC_HEAP_OBJECT = 1, // non-GC objects + _Py_MIMALLOC_HEAP_GC = 2, // GC objects without pre-header + _Py_MIMALLOC_HEAP_GC_PRE = 3, // GC objects with pre-header + _Py_MIMALLOC_HEAP_COUNT +} _Py_mimalloc_heap_id; + +#include "pycore_pymem.h" + +#ifdef WITH_MIMALLOC +# ifdef Py_GIL_DISABLED +# define MI_PRIM_THREAD_ID _Py_ThreadId +# endif +# define MI_DEBUG_UNINIT PYMEM_CLEANBYTE +# define MI_DEBUG_FREED PYMEM_DEADBYTE +# define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE +#ifdef Py_DEBUG +# define MI_DEBUG 2 +#else +# define MI_DEBUG 0 +#endif + +#ifdef _Py_THREAD_SANITIZER +# define MI_TSAN 1 +#endif + +#ifdef __cplusplus +extern "C++" { +#endif + +#include "mimalloc/mimalloc.h" +#include "mimalloc/mimalloc/types.h" +#include "mimalloc/mimalloc/internal.h" + +#ifdef __cplusplus +} +#endif + +#endif + +#ifdef Py_GIL_DISABLED +struct _mimalloc_interp_state { + // When exiting, threads place any segments with live blocks in this + // shared pool for other threads to claim and reuse. + mi_abandoned_pool_t abandoned_pool; +}; + +struct _mimalloc_thread_state { + mi_heap_t *current_object_heap; + mi_heap_t heaps[_Py_MIMALLOC_HEAP_COUNT]; + mi_tld_t tld; + int initialized; + struct llist_node page_list; +}; +#endif + +#endif // Py_INTERNAL_MIMALLOC_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_modsupport.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_modsupport.h new file mode 100644 index 00000000..11fde814 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_modsupport.h @@ -0,0 +1,107 @@ +#ifndef Py_INTERNAL_MODSUPPORT_H +#define Py_INTERNAL_MODSUPPORT_H + +#include "pycore_lock.h" // _PyOnceFlag + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +extern int _PyArg_NoKwnames(const char *funcname, PyObject *kwnames); +#define _PyArg_NoKwnames(funcname, kwnames) \ + ((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames))) + +// Export for '_bz2' shared extension +PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args); +#define _PyArg_NoPositional(funcname, args) \ + ((args) == NULL || _PyArg_NoPositional((funcname), (args))) + +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kwargs); +#define _PyArg_NoKeywords(funcname, kwargs) \ + ((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs))) + +// Export for 'zlib' shared extension +PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t, + Py_ssize_t, Py_ssize_t); +#define _Py_ANY_VARARGS(n) ((n) == PY_SSIZE_T_MAX) +#define _PyArg_CheckPositional(funcname, nargs, min, max) \ + ((!_Py_ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \ + || _PyArg_CheckPositional((funcname), (nargs), (min), (max))) + +extern PyObject ** _Py_VaBuildStack( + PyObject **small_stack, + Py_ssize_t small_stack_len, + const char *format, + va_list va, + Py_ssize_t *p_nargs); + +extern PyObject* _PyModule_CreateInitialized(PyModuleDef*, int apiver); + +// Export for '_curses' shared extension +PyAPI_FUNC(int) _PyArg_ParseStack( + PyObject *const *args, + Py_ssize_t nargs, + const char *format, + ...); + +extern int _PyArg_UnpackStack( + PyObject *const *args, + Py_ssize_t nargs, + const char *name, + Py_ssize_t min, + Py_ssize_t max, + ...); + +// Export for '_heapq' shared extension +PyAPI_FUNC(void) _PyArg_BadArgument( + const char *fname, + const char *displayname, + const char *expected, + PyObject *arg); + +// --- _PyArg_Parser API --------------------------------------------------- + +// Export for '_dbm' shared extension +PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords( + PyObject *const *args, + Py_ssize_t nargs, + PyObject *kwnames, + struct _PyArg_Parser *, + ...); + +// Export for 'math' shared extension +PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords( + PyObject *const *args, + Py_ssize_t nargs, + PyObject *kwargs, + PyObject *kwnames, + struct _PyArg_Parser *parser, + int minpos, + int maxpos, + int minkw, + PyObject **buf); +#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \ + (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \ + (minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \ + _PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \ + (minpos), (maxpos), (minkw), (buf))) + +// Export for '_testclinic' shared extension +PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsWithVararg( + PyObject *const *args, Py_ssize_t nargs, + PyObject *kwargs, PyObject *kwnames, + struct _PyArg_Parser *parser, + int minpos, int maxpos, int minkw, + int vararg, PyObject **buf); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_MODSUPPORT_H + diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_moduleobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_moduleobject.h new file mode 100644 index 00000000..dacc00db --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_moduleobject.h @@ -0,0 +1,56 @@ +#ifndef Py_INTERNAL_MODULEOBJECT_H +#define Py_INTERNAL_MODULEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern void _PyModule_Clear(PyObject *); +extern void _PyModule_ClearDict(PyObject *); +extern int _PyModuleSpec_IsInitializing(PyObject *); +extern int _PyModuleSpec_GetFileOrigin(PyObject *, PyObject **); +extern int _PyModule_IsPossiblyShadowing(PyObject *); + +extern int _PyModule_IsExtension(PyObject *obj); + +typedef struct { + PyObject_HEAD + PyObject *md_dict; + PyModuleDef *md_def; + void *md_state; + PyObject *md_weaklist; + // for logging purposes after md_dict is cleared + PyObject *md_name; +#ifdef Py_GIL_DISABLED + void *md_gil; +#endif +} PyModuleObject; + +static inline PyModuleDef* _PyModule_GetDef(PyObject *mod) { + assert(PyModule_Check(mod)); + return ((PyModuleObject *)mod)->md_def; +} + +static inline void* _PyModule_GetState(PyObject* mod) { + assert(PyModule_Check(mod)); + return ((PyModuleObject *)mod)->md_state; +} + +static inline PyObject* _PyModule_GetDict(PyObject *mod) { + assert(PyModule_Check(mod)); + PyObject *dict = ((PyModuleObject *)mod) -> md_dict; + // _PyModule_GetDict(mod) must not be used after calling module_clear(mod) + assert(dict != NULL); + return dict; // borrowed reference +} + +PyObject* _Py_module_getattro_impl(PyModuleObject *m, PyObject *name, int suppress); +PyObject* _Py_module_getattro(PyModuleObject *m, PyObject *name); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_MODULEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_namespace.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_namespace.h new file mode 100644 index 00000000..f165cf15 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_namespace.h @@ -0,0 +1,21 @@ +// Simple namespace object interface + +#ifndef Py_INTERNAL_NAMESPACE_H +#define Py_INTERNAL_NAMESPACE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern PyTypeObject _PyNamespace_Type; + +// Export for '_testmultiphase' shared extension +PyAPI_FUNC(PyObject*) _PyNamespace_New(PyObject *kwds); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_NAMESPACE_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_object.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_object.h new file mode 100644 index 00000000..5877d43f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_object.h @@ -0,0 +1,867 @@ +#ifndef Py_INTERNAL_OBJECT_H +#define Py_INTERNAL_OBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include +#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED() +#include "pycore_emscripten_trampoline.h" // _PyCFunction_TrampolineCall() +#include "pycore_interp.h" // PyInterpreterState.gc +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_STORE_PTR_RELAXED +#include "pycore_pystate.h" // _PyInterpreterState_GET() + + +#define _Py_IMMORTAL_REFCNT_LOOSE ((_Py_IMMORTAL_REFCNT >> 1) + 1) + +// gh-121528, gh-118997: Similar to _Py_IsImmortal() but be more loose when +// comparing the reference count to stay compatible with C extensions built +// with the stable ABI 3.11 or older. Such extensions implement INCREF/DECREF +// as refcnt++ and refcnt-- without taking in account immortal objects. For +// example, the reference count of an immortal object can change from +// _Py_IMMORTAL_REFCNT to _Py_IMMORTAL_REFCNT+1 (INCREF) or +// _Py_IMMORTAL_REFCNT-1 (DECREF). +// +// This function should only be used in assertions. Otherwise, _Py_IsImmortal() +// must be used instead. +static inline int _Py_IsImmortalLoose(PyObject *op) +{ +#if defined(Py_GIL_DISABLED) + return _Py_IsImmortal(op); +#else + return (op->ob_refcnt >= _Py_IMMORTAL_REFCNT_LOOSE); +#endif +} +#define _Py_IsImmortalLoose(op) _Py_IsImmortalLoose(_PyObject_CAST(op)) + + +/* Check if an object is consistent. For example, ensure that the reference + counter is greater than or equal to 1, and ensure that ob_type is not NULL. + + Call _PyObject_AssertFailed() if the object is inconsistent. + + If check_content is zero, only check header fields: reduce the overhead. + + The function always return 1. The return value is just here to be able to + write: + + assert(_PyObject_CheckConsistency(obj, 1)); */ +extern int _PyObject_CheckConsistency(PyObject *op, int check_content); + +extern void _PyDebugAllocatorStats(FILE *out, const char *block_name, + int num_blocks, size_t sizeof_block); + +extern void _PyObject_DebugTypeStats(FILE *out); + +#ifdef Py_TRACE_REFS +// Forget a reference registered by _Py_NewReference(). Function called by +// _Py_Dealloc(). +// +// On a free list, the function can be used before modifying an object to +// remove the object from traced objects. Then _Py_NewReference() or +// _Py_NewReferenceNoTotal() should be called again on the object to trace +// it again. +extern void _Py_ForgetReference(PyObject *); +#endif + +// Export for shared _testinternalcapi extension +PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *); + +/* We need to maintain an internal copy of Py{Var}Object_HEAD_INIT to avoid + designated initializer conflicts in C++20. If we use the definition in + object.h, we will be mixing designated and non-designated initializers in + pycore objects which is forbiddent in C++20. However, if we then use + designated initializers in object.h then Extensions without designated break. + Furthermore, we can't use designated initializers in Extensions since these + are not supported pre-C++20. Thus, keeping an internal copy here is the most + backwards compatible solution */ +#if defined(Py_GIL_DISABLED) +#define _PyObject_HEAD_INIT(type) \ + { \ + .ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL, \ + .ob_type = (type) \ + } +#else +#define _PyObject_HEAD_INIT(type) \ + { \ + .ob_refcnt = _Py_IMMORTAL_REFCNT, \ + .ob_type = (type) \ + } +#endif +#define _PyVarObject_HEAD_INIT(type, size) \ + { \ + .ob_base = _PyObject_HEAD_INIT(type), \ + .ob_size = size \ + } + +PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalRefcountErrorFunc( + const char *func, + const char *message); + +#define _Py_FatalRefcountError(message) \ + _Py_FatalRefcountErrorFunc(__func__, (message)) + +#define _PyReftracerTrack(obj, operation) \ + do { \ + struct _reftracer_runtime_state *tracer = &_PyRuntime.ref_tracer; \ + if (tracer->tracer_func != NULL) { \ + void *data = tracer->tracer_data; \ + tracer->tracer_func((obj), (operation), data); \ + } \ + } while(0) + +#ifdef Py_REF_DEBUG +/* The symbol is only exposed in the API for the sake of extensions + built against the pre-3.12 stable ABI. */ +PyAPI_DATA(Py_ssize_t) _Py_RefTotal; + +extern void _Py_AddRefTotal(PyThreadState *, Py_ssize_t); +extern void _Py_IncRefTotal(PyThreadState *); +extern void _Py_DecRefTotal(PyThreadState *); + +# define _Py_DEC_REFTOTAL(interp) \ + interp->object_state.reftotal-- +#endif + +// Increment reference count by n +static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n) +{ + if (_Py_IsImmortal(op)) { + return; + } +#ifdef Py_REF_DEBUG + _Py_AddRefTotal(_PyThreadState_GET(), n); +#endif +#if !defined(Py_GIL_DISABLED) + op->ob_refcnt += n; +#else + if (_Py_IsOwnedByCurrentThread(op)) { + uint32_t local = op->ob_ref_local; + Py_ssize_t refcnt = (Py_ssize_t)local + n; +# if PY_SSIZE_T_MAX > UINT32_MAX + if (refcnt > (Py_ssize_t)UINT32_MAX) { + // Make the object immortal if the 32-bit local reference count + // would overflow. + refcnt = _Py_IMMORTAL_REFCNT_LOCAL; + } +# endif + _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, (uint32_t)refcnt); + } + else { + _Py_atomic_add_ssize(&op->ob_ref_shared, (n << _Py_REF_SHARED_SHIFT)); + } +#endif + // Although the ref count was increased by `n` (which may be greater than 1) + // it is only a single increment (i.e. addition) operation, so only 1 refcnt + // increment operation is counted. + _Py_INCREF_STAT_INC(); +} +#define _Py_RefcntAdd(op, n) _Py_RefcntAdd(_PyObject_CAST(op), n) + +extern void _Py_SetImmortal(PyObject *op); +extern void _Py_SetImmortalUntracked(PyObject *op); + +// Checks if an object has a single, unique reference. If the caller holds a +// unique reference, it may be able to safely modify the object in-place. +static inline int +_PyObject_IsUniquelyReferenced(PyObject *ob) +{ +#if !defined(Py_GIL_DISABLED) + return Py_REFCNT(ob) == 1; +#else + // NOTE: the entire ob_ref_shared field must be zero, including flags, to + // ensure that other threads cannot concurrently create new references to + // this object. + return (_Py_IsOwnedByCurrentThread(ob) && + _Py_atomic_load_uint32_relaxed(&ob->ob_ref_local) == 1 && + _Py_atomic_load_ssize_relaxed(&ob->ob_ref_shared) == 0); +#endif +} + +// Makes an immortal object mortal again with the specified refcnt. Should only +// be used during runtime finalization. +static inline void _Py_SetMortal(PyObject *op, Py_ssize_t refcnt) +{ + if (op) { + assert(_Py_IsImmortalLoose(op)); +#ifdef Py_GIL_DISABLED + op->ob_tid = _Py_UNOWNED_TID; + op->ob_ref_local = 0; + op->ob_ref_shared = _Py_REF_SHARED(refcnt, _Py_REF_MERGED); +#else + op->ob_refcnt = refcnt; +#endif + } +} + +/* _Py_ClearImmortal() should only be used during runtime finalization. */ +static inline void _Py_ClearImmortal(PyObject *op) +{ + if (op) { + _Py_SetMortal(op, 1); + Py_DECREF(op); + } +} +#define _Py_ClearImmortal(op) \ + do { \ + _Py_ClearImmortal(_PyObject_CAST(op)); \ + op = NULL; \ + } while (0) + +// Mark an object as supporting deferred reference counting. This is a no-op +// in the default (with GIL) build. Objects that use deferred reference +// counting should be tracked by the GC so that they are eventually collected. +extern void _PyObject_SetDeferredRefcount(PyObject *op); + +static inline int +_PyObject_HasDeferredRefcount(PyObject *op) +{ +#ifdef Py_GIL_DISABLED + return _PyObject_HAS_GC_BITS(op, _PyGC_BITS_DEFERRED); +#else + return 0; +#endif +} + +#if !defined(Py_GIL_DISABLED) +static inline void +_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct) +{ + if (_Py_IsImmortal(op)) { + return; + } + _Py_DECREF_STAT_INC(); +#ifdef Py_REF_DEBUG + _Py_DEC_REFTOTAL(PyInterpreterState_Get()); +#endif + if (--op->ob_refcnt != 0) { + assert(op->ob_refcnt > 0); + } + else { +#ifdef Py_TRACE_REFS + _Py_ForgetReference(op); +#endif + _PyReftracerTrack(op, PyRefTracer_DESTROY); + destruct(op); + } +} + +static inline void +_Py_DECREF_NO_DEALLOC(PyObject *op) +{ + if (_Py_IsImmortal(op)) { + return; + } + _Py_DECREF_STAT_INC(); +#ifdef Py_REF_DEBUG + _Py_DEC_REFTOTAL(PyInterpreterState_Get()); +#endif + op->ob_refcnt--; +#ifdef Py_DEBUG + if (op->ob_refcnt <= 0) { + _Py_FatalRefcountError("Expected a positive remaining refcount"); + } +#endif +} + +#else +// TODO: implement Py_DECREF specializations for Py_GIL_DISABLED build +static inline void +_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct) +{ + Py_DECREF(op); +} + +static inline void +_Py_DECREF_NO_DEALLOC(PyObject *op) +{ + Py_DECREF(op); +} + +static inline int +_Py_REF_IS_MERGED(Py_ssize_t ob_ref_shared) +{ + return (ob_ref_shared & _Py_REF_SHARED_FLAG_MASK) == _Py_REF_MERGED; +} + +static inline int +_Py_REF_IS_QUEUED(Py_ssize_t ob_ref_shared) +{ + return (ob_ref_shared & _Py_REF_SHARED_FLAG_MASK) == _Py_REF_QUEUED; +} + +// Merge the local and shared reference count fields and add `extra` to the +// refcount when merging. +Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *op, Py_ssize_t extra); +#endif // !defined(Py_GIL_DISABLED) + +#ifdef Py_REF_DEBUG +# undef _Py_DEC_REFTOTAL +#endif + + +extern int _PyType_CheckConsistency(PyTypeObject *type); +extern int _PyDict_CheckConsistency(PyObject *mp, int check_content); + +/* Update the Python traceback of an object. This function must be called + when a memory block is reused from a free list. + + Internal function called by _Py_NewReference(). */ +extern int _PyTraceMalloc_TraceRef(PyObject *op, PyRefTracerEvent event, void*); + +// Fast inlined version of PyType_HasFeature() +static inline int +_PyType_HasFeature(PyTypeObject *type, unsigned long feature) { + return ((FT_ATOMIC_LOAD_ULONG_RELAXED(type->tp_flags) & feature) != 0); +} + +extern void _PyType_InitCache(PyInterpreterState *interp); + +extern PyStatus _PyObject_InitState(PyInterpreterState *interp); +extern void _PyObject_FiniState(PyInterpreterState *interp); +extern bool _PyRefchain_IsTraced(PyInterpreterState *interp, PyObject *obj); + +/* Inline functions trading binary compatibility for speed: + _PyObject_Init() is the fast version of PyObject_Init(), and + _PyObject_InitVar() is the fast version of PyObject_InitVar(). + + These inline functions must not be called with op=NULL. */ +static inline void +_PyObject_Init(PyObject *op, PyTypeObject *typeobj) +{ + assert(op != NULL); + Py_SET_TYPE(op, typeobj); + assert(_PyType_HasFeature(typeobj, Py_TPFLAGS_HEAPTYPE) || _Py_IsImmortalLoose(typeobj)); + Py_INCREF(typeobj); + _Py_NewReference(op); +} + +static inline void +_PyObject_InitVar(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size) +{ + assert(op != NULL); + assert(typeobj != &PyLong_Type); + _PyObject_Init((PyObject *)op, typeobj); + Py_SET_SIZE(op, size); +} + + +/* Tell the GC to track this object. + * + * The object must not be tracked by the GC. + * + * NB: While the object is tracked by the collector, it must be safe to call the + * ob_traverse method. + * + * Internal note: interp->gc.generation0->_gc_prev doesn't have any bit flags + * because it's not object header. So we don't use _PyGCHead_PREV() and + * _PyGCHead_SET_PREV() for it to avoid unnecessary bitwise operations. + * + * See also the public PyObject_GC_Track() function. + */ +static inline void _PyObject_GC_TRACK( +// The preprocessor removes _PyObject_ASSERT_FROM() calls if NDEBUG is defined +#ifndef NDEBUG + const char *filename, int lineno, +#endif + PyObject *op) +{ + _PyObject_ASSERT_FROM(op, !_PyObject_GC_IS_TRACKED(op), + "object already tracked by the garbage collector", + filename, lineno, __func__); +#ifdef Py_GIL_DISABLED + _PyObject_SET_GC_BITS(op, _PyGC_BITS_TRACKED); +#else + PyGC_Head *gc = _Py_AS_GC(op); + _PyObject_ASSERT_FROM(op, + (gc->_gc_prev & _PyGC_PREV_MASK_COLLECTING) == 0, + "object is in generation which is garbage collected", + filename, lineno, __func__); + + PyInterpreterState *interp = _PyInterpreterState_GET(); + PyGC_Head *generation0 = interp->gc.generation0; + PyGC_Head *last = (PyGC_Head*)(generation0->_gc_prev); + _PyGCHead_SET_NEXT(last, gc); + _PyGCHead_SET_PREV(gc, last); + _PyGCHead_SET_NEXT(gc, generation0); + generation0->_gc_prev = (uintptr_t)gc; +#endif +} + +/* Tell the GC to stop tracking this object. + * + * Internal note: This may be called while GC. So _PyGC_PREV_MASK_COLLECTING + * must be cleared. But _PyGC_PREV_MASK_FINALIZED bit is kept. + * + * The object must be tracked by the GC. + * + * See also the public PyObject_GC_UnTrack() which accept an object which is + * not tracked. + */ +static inline void _PyObject_GC_UNTRACK( +// The preprocessor removes _PyObject_ASSERT_FROM() calls if NDEBUG is defined +#ifndef NDEBUG + const char *filename, int lineno, +#endif + PyObject *op) +{ + _PyObject_ASSERT_FROM(op, _PyObject_GC_IS_TRACKED(op), + "object not tracked by the garbage collector", + filename, lineno, __func__); + +#ifdef Py_GIL_DISABLED + _PyObject_CLEAR_GC_BITS(op, _PyGC_BITS_TRACKED); +#else + PyGC_Head *gc = _Py_AS_GC(op); + PyGC_Head *prev = _PyGCHead_PREV(gc); + PyGC_Head *next = _PyGCHead_NEXT(gc); + _PyGCHead_SET_NEXT(prev, next); + _PyGCHead_SET_PREV(next, prev); + gc->_gc_next = 0; + gc->_gc_prev &= _PyGC_PREV_MASK_FINALIZED; +#endif +} + +// Macros to accept any type for the parameter, and to automatically pass +// the filename and the filename (if NDEBUG is not defined) where the macro +// is called. +#ifdef NDEBUG +# define _PyObject_GC_TRACK(op) \ + _PyObject_GC_TRACK(_PyObject_CAST(op)) +# define _PyObject_GC_UNTRACK(op) \ + _PyObject_GC_UNTRACK(_PyObject_CAST(op)) +#else +# define _PyObject_GC_TRACK(op) \ + _PyObject_GC_TRACK(__FILE__, __LINE__, _PyObject_CAST(op)) +# define _PyObject_GC_UNTRACK(op) \ + _PyObject_GC_UNTRACK(__FILE__, __LINE__, _PyObject_CAST(op)) +#endif + +#ifdef Py_GIL_DISABLED + +/* Tries to increment an object's reference count + * + * This is a specialized version of _Py_TryIncref that only succeeds if the + * object is immortal or local to this thread. It does not handle the case + * where the reference count modification requires an atomic operation. This + * allows call sites to specialize for the immortal/local case. + */ +static inline int +_Py_TryIncrefFast(PyObject *op) { + uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local); + local += 1; + if (local == 0) { + // immortal + return 1; + } + if (_Py_IsOwnedByCurrentThread(op)) { + _Py_INCREF_STAT_INC(); + _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, local); +#ifdef Py_REF_DEBUG + _Py_IncRefTotal(_PyThreadState_GET()); +#endif + return 1; + } + return 0; +} + +static inline int +_Py_TryIncRefShared(PyObject *op) +{ + Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared); + for (;;) { + // If the shared refcount is zero and the object is either merged + // or may not have weak references, then we cannot incref it. + if (shared == 0 || shared == _Py_REF_MERGED) { + return 0; + } + + if (_Py_atomic_compare_exchange_ssize( + &op->ob_ref_shared, + &shared, + shared + (1 << _Py_REF_SHARED_SHIFT))) { +#ifdef Py_REF_DEBUG + _Py_IncRefTotal(_PyThreadState_GET()); +#endif + _Py_INCREF_STAT_INC(); + return 1; + } + } +} + +/* Tries to incref the object op and ensures that *src still points to it. */ +static inline int +_Py_TryIncrefCompare(PyObject **src, PyObject *op) +{ + if (_Py_TryIncrefFast(op)) { + return 1; + } + if (!_Py_TryIncRefShared(op)) { + return 0; + } + if (op != _Py_atomic_load_ptr(src)) { + Py_DECREF(op); + return 0; + } + return 1; +} + +/* Loads and increfs an object from ptr, which may contain a NULL value. + Safe with concurrent (atomic) updates to ptr. + NOTE: The writer must set maybe-weakref on the stored object! */ +static inline PyObject * +_Py_XGetRef(PyObject **ptr) +{ + for (;;) { + PyObject *value = _Py_atomic_load_ptr(ptr); + if (value == NULL) { + return value; + } + if (_Py_TryIncrefCompare(ptr, value)) { + return value; + } + } +} + +/* Attempts to loads and increfs an object from ptr. Returns NULL + on failure, which may be due to a NULL value or a concurrent update. */ +static inline PyObject * +_Py_TryXGetRef(PyObject **ptr) +{ + PyObject *value = _Py_atomic_load_ptr(ptr); + if (value == NULL) { + return value; + } + if (_Py_TryIncrefCompare(ptr, value)) { + return value; + } + return NULL; +} + +/* Like Py_NewRef but also optimistically sets _Py_REF_MAYBE_WEAKREF + on objects owned by a different thread. */ +static inline PyObject * +_Py_NewRefWithLock(PyObject *op) +{ + if (_Py_TryIncrefFast(op)) { + return op; + } +#ifdef Py_REF_DEBUG + _Py_IncRefTotal(_PyThreadState_GET()); +#endif + _Py_INCREF_STAT_INC(); + for (;;) { + Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared); + Py_ssize_t new_shared = shared + (1 << _Py_REF_SHARED_SHIFT); + if ((shared & _Py_REF_SHARED_FLAG_MASK) == 0) { + new_shared |= _Py_REF_MAYBE_WEAKREF; + } + if (_Py_atomic_compare_exchange_ssize( + &op->ob_ref_shared, + &shared, + new_shared)) { + return op; + } + } +} + +static inline PyObject * +_Py_XNewRefWithLock(PyObject *obj) +{ + if (obj == NULL) { + return NULL; + } + return _Py_NewRefWithLock(obj); +} + +static inline void +_PyObject_SetMaybeWeakref(PyObject *op) +{ + if (_Py_IsImmortal(op)) { + return; + } + for (;;) { + Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared); + if ((shared & _Py_REF_SHARED_FLAG_MASK) != 0) { + // Nothing to do if it's in WEAKREFS, QUEUED, or MERGED states. + return; + } + if (_Py_atomic_compare_exchange_ssize( + &op->ob_ref_shared, &shared, shared | _Py_REF_MAYBE_WEAKREF)) { + return; + } + } +} + +extern int _PyObject_ResurrectEndSlow(PyObject *op); +#endif + +// Temporarily resurrects an object during deallocation. The refcount is set +// to one. +static inline void +_PyObject_ResurrectStart(PyObject *op) +{ + assert(Py_REFCNT(op) == 0); +#ifdef Py_REF_DEBUG + _Py_IncRefTotal(_PyThreadState_GET()); +#endif +#ifdef Py_GIL_DISABLED + _Py_atomic_store_uintptr_relaxed(&op->ob_tid, _Py_ThreadId()); + _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, 1); + _Py_atomic_store_ssize_relaxed(&op->ob_ref_shared, 0); +#else + Py_SET_REFCNT(op, 1); +#endif +} + +// Undoes an object resurrection by decrementing the refcount without calling +// _Py_Dealloc(). Returns 0 if the object is dead (the normal case), and +// deallocation should continue. Returns 1 if the object is still alive. +static inline int +_PyObject_ResurrectEnd(PyObject *op) +{ +#ifdef Py_REF_DEBUG + _Py_DecRefTotal(_PyThreadState_GET()); +#endif +#ifndef Py_GIL_DISABLED + Py_SET_REFCNT(op, Py_REFCNT(op) - 1); + return Py_REFCNT(op) != 0; +#else + uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local); + Py_ssize_t shared = _Py_atomic_load_ssize_acquire(&op->ob_ref_shared); + if (_Py_IsOwnedByCurrentThread(op) && local == 1 && shared == 0) { + // Fast-path: object has a single refcount and is owned by this thread + _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, 0); + return 0; + } + // Slow-path: object has a shared refcount or is not owned by this thread + return _PyObject_ResurrectEndSlow(op); +#endif +} + +/* Tries to incref op and returns 1 if successful or 0 otherwise. */ +static inline int +_Py_TryIncref(PyObject *op) +{ +#ifdef Py_GIL_DISABLED + return _Py_TryIncrefFast(op) || _Py_TryIncRefShared(op); +#else + if (Py_REFCNT(op) > 0) { + Py_INCREF(op); + return 1; + } + return 0; +#endif +} + +#ifdef Py_REF_DEBUG +extern void _PyInterpreterState_FinalizeRefTotal(PyInterpreterState *); +extern void _Py_FinalizeRefTotal(_PyRuntimeState *); +extern void _PyDebug_PrintTotalRefs(void); +#endif + +#ifdef Py_TRACE_REFS +extern void _Py_AddToAllObjects(PyObject *op); +extern void _Py_PrintReferences(PyInterpreterState *, FILE *); +extern void _Py_PrintReferenceAddresses(PyInterpreterState *, FILE *); +#endif + + +/* Return the *address* of the object's weaklist. The address may be + * dereferenced to get the current head of the weaklist. This is useful + * for iterating over the linked list of weakrefs, especially when the + * list is being modified externally (e.g. refs getting removed). + * + * The returned pointer should not be used to change the head of the list + * nor should it be used to add, remove, or swap any refs in the list. + * That is the sole responsibility of the code in weakrefobject.c. + */ +static inline PyObject ** +_PyObject_GET_WEAKREFS_LISTPTR(PyObject *op) +{ + if (PyType_Check(op) && + ((PyTypeObject *)op)->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) { + PyInterpreterState *interp = _PyInterpreterState_GET(); + managed_static_type_state *state = _PyStaticType_GetState( + interp, (PyTypeObject *)op); + return _PyStaticType_GET_WEAKREFS_LISTPTR(state); + } + // Essentially _PyObject_GET_WEAKREFS_LISTPTR_FROM_OFFSET(): + Py_ssize_t offset = Py_TYPE(op)->tp_weaklistoffset; + return (PyObject **)((char *)op + offset); +} + +/* This is a special case of _PyObject_GET_WEAKREFS_LISTPTR(). + * Only the most fundamental lookup path is used. + * Consequently, static types should not be used. + * + * For static builtin types the returned pointer will always point + * to a NULL tp_weaklist. This is fine for any deallocation cases, + * since static types are never deallocated and static builtin types + * are only finalized at the end of runtime finalization. + * + * If the weaklist for static types is actually needed then use + * _PyObject_GET_WEAKREFS_LISTPTR(). + */ +static inline PyWeakReference ** +_PyObject_GET_WEAKREFS_LISTPTR_FROM_OFFSET(PyObject *op) +{ + assert(!PyType_Check(op) || + ((PyTypeObject *)op)->tp_flags & Py_TPFLAGS_HEAPTYPE); + Py_ssize_t offset = Py_TYPE(op)->tp_weaklistoffset; + return (PyWeakReference **)((char *)op + offset); +} + +// Fast inlined version of PyObject_IS_GC() +static inline int +_PyObject_IS_GC(PyObject *obj) +{ + PyTypeObject *type = Py_TYPE(obj); + return (PyType_IS_GC(type) + && (type->tp_is_gc == NULL || type->tp_is_gc(obj))); +} + +// Fast inlined version of PyObject_Hash() +static inline Py_hash_t +_PyObject_HashFast(PyObject *op) +{ + if (PyUnicode_CheckExact(op)) { + Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED( + _PyASCIIObject_CAST(op)->hash); + if (hash != -1) { + return hash; + } + } + return PyObject_Hash(op); +} + +// Fast inlined version of PyType_IS_GC() +#define _PyType_IS_GC(t) _PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) + +static inline size_t +_PyType_PreHeaderSize(PyTypeObject *tp) +{ + return ( +#ifndef Py_GIL_DISABLED + _PyType_IS_GC(tp) * sizeof(PyGC_Head) + +#endif + _PyType_HasFeature(tp, Py_TPFLAGS_PREHEADER) * 2 * sizeof(PyObject *) + ); +} + +void _PyObject_GC_Link(PyObject *op); + +// Usage: assert(_Py_CheckSlotResult(obj, "__getitem__", result != NULL)); +extern int _Py_CheckSlotResult( + PyObject *obj, + const char *slot_name, + int success); + +// Test if a type supports weak references +static inline int _PyType_SUPPORTS_WEAKREFS(PyTypeObject *type) { + return (type->tp_weaklistoffset != 0); +} + +extern PyObject* _PyType_AllocNoTrack(PyTypeObject *type, Py_ssize_t nitems); +extern PyObject *_PyType_NewManagedObject(PyTypeObject *type); + +extern PyTypeObject* _PyType_CalculateMetaclass(PyTypeObject *, PyObject *); +extern PyObject* _PyType_GetDocFromInternalDoc(const char *, const char *); +extern PyObject* _PyType_GetTextSignatureFromInternalDoc(const char *, const char *, int); +extern int _PyObject_SetAttributeErrorContext(PyObject *v, PyObject* name); + +void _PyObject_InitInlineValues(PyObject *obj, PyTypeObject *tp); +extern int _PyObject_StoreInstanceAttribute(PyObject *obj, + PyObject *name, PyObject *value); +extern bool _PyObject_TryGetInstanceAttribute(PyObject *obj, PyObject *name, + PyObject **attr); + +#ifdef Py_GIL_DISABLED +# define MANAGED_DICT_OFFSET (((Py_ssize_t)sizeof(PyObject *))*-1) +# define MANAGED_WEAKREF_OFFSET (((Py_ssize_t)sizeof(PyObject *))*-2) +#else +# define MANAGED_DICT_OFFSET (((Py_ssize_t)sizeof(PyObject *))*-3) +# define MANAGED_WEAKREF_OFFSET (((Py_ssize_t)sizeof(PyObject *))*-4) +#endif + +typedef union { + PyDictObject *dict; +} PyManagedDictPointer; + +static inline PyManagedDictPointer * +_PyObject_ManagedDictPointer(PyObject *obj) +{ + assert(Py_TYPE(obj)->tp_flags & Py_TPFLAGS_MANAGED_DICT); + return (PyManagedDictPointer *)((char *)obj + MANAGED_DICT_OFFSET); +} + +static inline PyDictObject * +_PyObject_GetManagedDict(PyObject *obj) +{ + PyManagedDictPointer *dorv = _PyObject_ManagedDictPointer(obj); + return (PyDictObject *)FT_ATOMIC_LOAD_PTR_ACQUIRE(dorv->dict); +} + +static inline PyDictValues * +_PyObject_InlineValues(PyObject *obj) +{ + assert(Py_TYPE(obj)->tp_flags & Py_TPFLAGS_INLINE_VALUES); + assert(Py_TYPE(obj)->tp_flags & Py_TPFLAGS_MANAGED_DICT); + assert(Py_TYPE(obj)->tp_basicsize == sizeof(PyObject)); + return (PyDictValues *)((char *)obj + sizeof(PyObject)); +} + +extern PyObject ** _PyObject_ComputedDictPointer(PyObject *); +extern int _PyObject_IsInstanceDictEmpty(PyObject *); + +// Export for 'math' shared extension +PyAPI_FUNC(PyObject*) _PyObject_LookupSpecial(PyObject *, PyObject *); + +extern int _PyObject_IsAbstract(PyObject *); + +PyAPI_FUNC(int) _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); +extern PyObject* _PyObject_NextNotImplemented(PyObject *); + +// Pickle support. +// Export for '_datetime' shared extension +PyAPI_FUNC(PyObject*) _PyObject_GetState(PyObject *); + +/* C function call trampolines to mitigate bad function pointer casts. + * + * Typical native ABIs ignore additional arguments or fill in missing + * values with 0/NULL in function pointer cast. Compilers do not show + * warnings when a function pointer is explicitly casted to an + * incompatible type. + * + * Bad fpcasts are an issue in WebAssembly. WASM's indirect_call has strict + * function signature checks. Argument count, types, and return type must + * match. + * + * Third party code unintentionally rely on problematic fpcasts. The call + * trampoline mitigates common occurrences of bad fpcasts on Emscripten. + */ +#if !(defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)) +#define _PyCFunction_TrampolineCall(meth, self, args) \ + (meth)((self), (args)) +#define _PyCFunctionWithKeywords_TrampolineCall(meth, self, args, kw) \ + (meth)((self), (args), (kw)) +#endif // __EMSCRIPTEN__ && PY_CALL_TRAMPOLINE + +// Export these 2 symbols for '_pickle' shared extension +PyAPI_DATA(PyTypeObject) _PyNone_Type; +PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type; + +// Maps Py_LT to Py_GT, ..., Py_GE to Py_LE. +// Export for the stable ABI. +PyAPI_DATA(int) _Py_SwappedOp[]; + +extern void _Py_GetConstant_Init(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_OBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_object_alloc.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_object_alloc.h new file mode 100644 index 00000000..8cc7a444 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_object_alloc.h @@ -0,0 +1,71 @@ +#ifndef Py_INTERNAL_OBJECT_ALLOC_H +#define Py_INTERNAL_OBJECT_ALLOC_H + +#include "pycore_object.h" // _PyType_HasFeature() +#include "pycore_pystate.h" // _PyThreadState_GET() +#include "pycore_tstate.h" // _PyThreadStateImpl + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#ifdef Py_GIL_DISABLED +static inline mi_heap_t * +_PyObject_GetAllocationHeap(_PyThreadStateImpl *tstate, PyTypeObject *tp) +{ + struct _mimalloc_thread_state *m = &tstate->mimalloc; + if (_PyType_HasFeature(tp, Py_TPFLAGS_PREHEADER)) { + return &m->heaps[_Py_MIMALLOC_HEAP_GC_PRE]; + } + else if (_PyType_IS_GC(tp)) { + return &m->heaps[_Py_MIMALLOC_HEAP_GC]; + } + else { + return &m->heaps[_Py_MIMALLOC_HEAP_OBJECT]; + } +} +#endif + +// Sets the heap used for PyObject_Malloc(), PyObject_Realloc(), etc. calls in +// Py_GIL_DISABLED builds. We use different heaps depending on if the object +// supports GC and if it has a pre-header. We smuggle the choice of heap +// through the _mimalloc_thread_state. In the default build, this simply +// calls PyObject_Malloc(). +static inline void * +_PyObject_MallocWithType(PyTypeObject *tp, size_t size) +{ +#ifdef Py_GIL_DISABLED + _PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET(); + struct _mimalloc_thread_state *m = &tstate->mimalloc; + m->current_object_heap = _PyObject_GetAllocationHeap(tstate, tp); +#endif + void *mem = PyObject_Malloc(size); +#ifdef Py_GIL_DISABLED + m->current_object_heap = &m->heaps[_Py_MIMALLOC_HEAP_OBJECT]; +#endif + return mem; +} + +static inline void * +_PyObject_ReallocWithType(PyTypeObject *tp, void *ptr, size_t size) +{ +#ifdef Py_GIL_DISABLED + _PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET(); + struct _mimalloc_thread_state *m = &tstate->mimalloc; + m->current_object_heap = _PyObject_GetAllocationHeap(tstate, tp); +#endif + void *mem = PyObject_Realloc(ptr, size); +#ifdef Py_GIL_DISABLED + m->current_object_heap = &m->heaps[_Py_MIMALLOC_HEAP_OBJECT]; +#endif + return mem; +} + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_OBJECT_ALLOC_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_object_stack.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_object_stack.h new file mode 100644 index 00000000..639f3c0c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_object_stack.h @@ -0,0 +1,97 @@ +#ifndef Py_INTERNAL_OBJECT_STACK_H +#define Py_INTERNAL_OBJECT_STACK_H + +#include "pycore_freelist.h" // _PyFreeListState + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// _PyObjectStack is a stack of Python objects implemented as a linked list of +// fixed size buffers. + +// Chosen so that _PyObjectStackChunk is a power-of-two size. +#define _Py_OBJECT_STACK_CHUNK_SIZE 254 + +typedef struct _PyObjectStackChunk { + struct _PyObjectStackChunk *prev; + Py_ssize_t n; + PyObject *objs[_Py_OBJECT_STACK_CHUNK_SIZE]; +} _PyObjectStackChunk; + +typedef struct _PyObjectStack { + _PyObjectStackChunk *head; +} _PyObjectStack; + + +extern _PyObjectStackChunk * +_PyObjectStackChunk_New(void); + +extern void +_PyObjectStackChunk_Free(_PyObjectStackChunk *); + +// Push an item onto the stack. Return -1 on allocation failure, 0 on success. +static inline int +_PyObjectStack_Push(_PyObjectStack *stack, PyObject *obj) +{ + _PyObjectStackChunk *buf = stack->head; + if (buf == NULL || buf->n == _Py_OBJECT_STACK_CHUNK_SIZE) { + buf = _PyObjectStackChunk_New(); + if (buf == NULL) { + return -1; + } + buf->prev = stack->head; + buf->n = 0; + stack->head = buf; + } + + assert(buf->n >= 0 && buf->n < _Py_OBJECT_STACK_CHUNK_SIZE); + buf->objs[buf->n] = obj; + buf->n++; + return 0; +} + +// Pop the top item from the stack. Return NULL if the stack is empty. +static inline PyObject * +_PyObjectStack_Pop(_PyObjectStack *stack) +{ + _PyObjectStackChunk *buf = stack->head; + if (buf == NULL) { + return NULL; + } + assert(buf->n > 0 && buf->n <= _Py_OBJECT_STACK_CHUNK_SIZE); + buf->n--; + PyObject *obj = buf->objs[buf->n]; + if (buf->n == 0) { + stack->head = buf->prev; + _PyObjectStackChunk_Free(buf); + } + return obj; +} + +static inline Py_ssize_t +_PyObjectStack_Size(_PyObjectStack *stack) +{ + Py_ssize_t size = 0; + for (_PyObjectStackChunk *buf = stack->head; buf != NULL; buf = buf->prev) { + size += buf->n; + } + return size; +} + +// Merge src into dst, leaving src empty +extern void +_PyObjectStack_Merge(_PyObjectStack *dst, _PyObjectStack *src); + +// Remove all items from the stack +extern void +_PyObjectStack_Clear(_PyObjectStack *stack); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_OBJECT_STACK_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_object_state.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_object_state.h new file mode 100644 index 00000000..cd7c9335 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_object_state.h @@ -0,0 +1,41 @@ +#ifndef Py_INTERNAL_OBJECT_STATE_H +#define Py_INTERNAL_OBJECT_STATE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_freelist.h" // _PyObject_freelists +#include "pycore_hashtable.h" // _Py_hashtable_t + +struct _py_object_runtime_state { +#ifdef Py_REF_DEBUG + Py_ssize_t interpreter_leaks; +#endif + int _not_used; +}; + +struct _py_object_state { +#if !defined(Py_GIL_DISABLED) + struct _Py_object_freelists freelists; +#endif +#ifdef Py_REF_DEBUG + Py_ssize_t reftotal; +#endif +#ifdef Py_TRACE_REFS + // Hash table storing all objects. The key is the object pointer + // (PyObject*) and the value is always the number 1 (as uintptr_t). + // See _PyRefchain_IsTraced() and _PyRefchain_Trace() functions. + _Py_hashtable_t *refchain; +#endif + int _not_used; +}; + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_OBJECT_STATE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_obmalloc.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_obmalloc.h new file mode 100644 index 00000000..9140d8f0 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_obmalloc.h @@ -0,0 +1,702 @@ +#ifndef Py_INTERNAL_OBMALLOC_H +#define Py_INTERNAL_OBMALLOC_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +typedef unsigned int pymem_uint; /* assuming >= 16 bits */ + +#undef uint +#define uint pymem_uint + + +/* An object allocator for Python. + + Here is an introduction to the layers of the Python memory architecture, + showing where the object allocator is actually used (layer +2), It is + called for every object allocation and deallocation (PyObject_New/Del), + unless the object-specific allocators implement a proprietary allocation + scheme (ex.: ints use a simple free list). This is also the place where + the cyclic garbage collector operates selectively on container objects. + + + Object-specific allocators + _____ ______ ______ ________ + [ int ] [ dict ] [ list ] ... [ string ] Python core | ++3 | <----- Object-specific memory -----> | <-- Non-object memory --> | + _______________________________ | | + [ Python's object allocator ] | | ++2 | ####### Object memory ####### | <------ Internal buffers ------> | + ______________________________________________________________ | + [ Python's raw memory allocator (PyMem_ API) ] | ++1 | <----- Python memory (under PyMem manager's control) ------> | | + __________________________________________________________________ + [ Underlying general-purpose allocator (ex: C library malloc) ] + 0 | <------ Virtual memory allocated for the python process -------> | + + ========================================================================= + _______________________________________________________________________ + [ OS-specific Virtual Memory Manager (VMM) ] +-1 | <--- Kernel dynamic storage allocation & management (page-based) ---> | + __________________________________ __________________________________ + [ ] [ ] +-2 | <-- Physical memory: ROM/RAM --> | | <-- Secondary storage (swap) --> | + +*/ +/*==========================================================================*/ + +/* A fast, special-purpose memory allocator for small blocks, to be used + on top of a general-purpose malloc -- heavily based on previous art. */ + +/* Vladimir Marangozov -- August 2000 */ + +/* + * "Memory management is where the rubber meets the road -- if we do the wrong + * thing at any level, the results will not be good. And if we don't make the + * levels work well together, we are in serious trouble." (1) + * + * (1) Paul R. Wilson, Mark S. Johnstone, Michael Neely, and David Boles, + * "Dynamic Storage Allocation: A Survey and Critical Review", + * in Proc. 1995 Int'l. Workshop on Memory Management, September 1995. + */ + +/* #undef WITH_MEMORY_LIMITS */ /* disable mem limit checks */ + +/*==========================================================================*/ + +/* + * Allocation strategy abstract: + * + * For small requests, the allocator sub-allocates blocks of memory. + * Requests greater than SMALL_REQUEST_THRESHOLD bytes are routed to the + * system's allocator. + * + * Small requests are grouped in size classes spaced 8 bytes apart, due + * to the required valid alignment of the returned address. Requests of + * a particular size are serviced from memory pools of 4K (one VMM page). + * Pools are fragmented on demand and contain free lists of blocks of one + * particular size class. In other words, there is a fixed-size allocator + * for each size class. Free pools are shared by the different allocators + * thus minimizing the space reserved for a particular size class. + * + * This allocation strategy is a variant of what is known as "simple + * segregated storage based on array of free lists". The main drawback of + * simple segregated storage is that we might end up with lot of reserved + * memory for the different free lists, which degenerate in time. To avoid + * this, we partition each free list in pools and we share dynamically the + * reserved space between all free lists. This technique is quite efficient + * for memory intensive programs which allocate mainly small-sized blocks. + * + * For small requests we have the following table: + * + * Request in bytes Size of allocated block Size class idx + * ---------------------------------------------------------------- + * 1-8 8 0 + * 9-16 16 1 + * 17-24 24 2 + * 25-32 32 3 + * 33-40 40 4 + * 41-48 48 5 + * 49-56 56 6 + * 57-64 64 7 + * 65-72 72 8 + * ... ... ... + * 497-504 504 62 + * 505-512 512 63 + * + * 0, SMALL_REQUEST_THRESHOLD + 1 and up: routed to the underlying + * allocator. + */ + +/*==========================================================================*/ + +/* + * -- Main tunable settings section -- + */ + +/* + * Alignment of addresses returned to the user. 8-bytes alignment works + * on most current architectures (with 32-bit or 64-bit address buses). + * The alignment value is also used for grouping small requests in size + * classes spaced ALIGNMENT bytes apart. + * + * You shouldn't change this unless you know what you are doing. + */ + +#if SIZEOF_VOID_P > 4 +#define ALIGNMENT 16 /* must be 2^N */ +#define ALIGNMENT_SHIFT 4 +#else +#define ALIGNMENT 8 /* must be 2^N */ +#define ALIGNMENT_SHIFT 3 +#endif + +/* Return the number of bytes in size class I, as a uint. */ +#define INDEX2SIZE(I) (((pymem_uint)(I) + 1) << ALIGNMENT_SHIFT) + +/* + * Max size threshold below which malloc requests are considered to be + * small enough in order to use preallocated memory pools. You can tune + * this value according to your application behaviour and memory needs. + * + * Note: a size threshold of 512 guarantees that newly created dictionaries + * will be allocated from preallocated memory pools on 64-bit. + * + * The following invariants must hold: + * 1) ALIGNMENT <= SMALL_REQUEST_THRESHOLD <= 512 + * 2) SMALL_REQUEST_THRESHOLD is evenly divisible by ALIGNMENT + * + * Although not required, for better performance and space efficiency, + * it is recommended that SMALL_REQUEST_THRESHOLD is set to a power of 2. + */ +#define SMALL_REQUEST_THRESHOLD 512 +#define NB_SMALL_SIZE_CLASSES (SMALL_REQUEST_THRESHOLD / ALIGNMENT) + +/* + * The system's VMM page size can be obtained on most unices with a + * getpagesize() call or deduced from various header files. To make + * things simpler, we assume that it is 4K, which is OK for most systems. + * It is probably better if this is the native page size, but it doesn't + * have to be. In theory, if SYSTEM_PAGE_SIZE is larger than the native page + * size, then `POOL_ADDR(p)->arenaindex' could rarely cause a segmentation + * violation fault. 4K is apparently OK for all the platforms that python + * currently targets. + */ +#define SYSTEM_PAGE_SIZE (4 * 1024) + +/* + * Maximum amount of memory managed by the allocator for small requests. + */ +#ifdef WITH_MEMORY_LIMITS +#ifndef SMALL_MEMORY_LIMIT +#define SMALL_MEMORY_LIMIT (64 * 1024 * 1024) /* 64 MB -- more? */ +#endif +#endif + +#if !defined(WITH_PYMALLOC_RADIX_TREE) +/* Use radix-tree to track arena memory regions, for address_in_range(). + * Enable by default since it allows larger pool sizes. Can be disabled + * using -DWITH_PYMALLOC_RADIX_TREE=0 */ +#define WITH_PYMALLOC_RADIX_TREE 1 +#endif + +#if SIZEOF_VOID_P > 4 +/* on 64-bit platforms use larger pools and arenas if we can */ +#define USE_LARGE_ARENAS +#if WITH_PYMALLOC_RADIX_TREE +/* large pools only supported if radix-tree is enabled */ +#define USE_LARGE_POOLS +#endif +#endif + +/* + * The allocator sub-allocates blocks of memory (called arenas) aligned + * on a page boundary. This is a reserved virtual address space for the + * current process (obtained through a malloc()/mmap() call). In no way this + * means that the memory arenas will be used entirely. A malloc() is + * usually an address range reservation for bytes, unless all pages within + * this space are referenced subsequently. So malloc'ing big blocks and not + * using them does not mean "wasting memory". It's an addressable range + * wastage... + * + * Arenas are allocated with mmap() on systems supporting anonymous memory + * mappings to reduce heap fragmentation. + */ +#ifdef USE_LARGE_ARENAS +#define ARENA_BITS 20 /* 1 MiB */ +#else +#define ARENA_BITS 18 /* 256 KiB */ +#endif +#define ARENA_SIZE (1 << ARENA_BITS) +#define ARENA_SIZE_MASK (ARENA_SIZE - 1) + +#ifdef WITH_MEMORY_LIMITS +#define MAX_ARENAS (SMALL_MEMORY_LIMIT / ARENA_SIZE) +#endif + +/* + * Size of the pools used for small blocks. Must be a power of 2. + */ +#ifdef USE_LARGE_POOLS +#define POOL_BITS 14 /* 16 KiB */ +#else +#define POOL_BITS 12 /* 4 KiB */ +#endif +#define POOL_SIZE (1 << POOL_BITS) +#define POOL_SIZE_MASK (POOL_SIZE - 1) + +#if !WITH_PYMALLOC_RADIX_TREE +#if POOL_SIZE != SYSTEM_PAGE_SIZE +# error "pool size must be equal to system page size" +#endif +#endif + +#define MAX_POOLS_IN_ARENA (ARENA_SIZE / POOL_SIZE) +#if MAX_POOLS_IN_ARENA * POOL_SIZE != ARENA_SIZE +# error "arena size not an exact multiple of pool size" +#endif + +/* + * -- End of tunable settings section -- + */ + +/*==========================================================================*/ + +/* When you say memory, my mind reasons in terms of (pointers to) blocks */ +typedef uint8_t pymem_block; + +/* Pool for small blocks. */ +struct pool_header { + union { pymem_block *_padding; + uint count; } ref; /* number of allocated blocks */ + pymem_block *freeblock; /* pool's free list head */ + struct pool_header *nextpool; /* next pool of this size class */ + struct pool_header *prevpool; /* previous pool "" */ + uint arenaindex; /* index into arenas of base adr */ + uint szidx; /* block size class index */ + uint nextoffset; /* bytes to virgin block */ + uint maxnextoffset; /* largest valid nextoffset */ +}; + +typedef struct pool_header *poolp; + +/* Record keeping for arenas. */ +struct arena_object { + /* The address of the arena, as returned by malloc. Note that 0 + * will never be returned by a successful malloc, and is used + * here to mark an arena_object that doesn't correspond to an + * allocated arena. + */ + uintptr_t address; + + /* Pool-aligned pointer to the next pool to be carved off. */ + pymem_block* pool_address; + + /* The number of available pools in the arena: free pools + never- + * allocated pools. + */ + uint nfreepools; + + /* The total number of pools in the arena, whether or not available. */ + uint ntotalpools; + + /* Singly-linked list of available pools. */ + struct pool_header* freepools; + + /* Whenever this arena_object is not associated with an allocated + * arena, the nextarena member is used to link all unassociated + * arena_objects in the singly-linked `unused_arena_objects` list. + * The prevarena member is unused in this case. + * + * When this arena_object is associated with an allocated arena + * with at least one available pool, both members are used in the + * doubly-linked `usable_arenas` list, which is maintained in + * increasing order of `nfreepools` values. + * + * Else this arena_object is associated with an allocated arena + * all of whose pools are in use. `nextarena` and `prevarena` + * are both meaningless in this case. + */ + struct arena_object* nextarena; + struct arena_object* prevarena; +}; + +#define POOL_OVERHEAD _Py_SIZE_ROUND_UP(sizeof(struct pool_header), ALIGNMENT) + +#define DUMMY_SIZE_IDX 0xffff /* size class of newly cached pools */ + +/* Round pointer P down to the closest pool-aligned address <= P, as a poolp */ +#define POOL_ADDR(P) ((poolp)_Py_ALIGN_DOWN((P), POOL_SIZE)) + +/* Return total number of blocks in pool of size index I, as a uint. */ +#define NUMBLOCKS(I) ((pymem_uint)(POOL_SIZE - POOL_OVERHEAD) / INDEX2SIZE(I)) + +/*==========================================================================*/ + +/* + * Pool table -- headed, circular, doubly-linked lists of partially used pools. + +This is involved. For an index i, usedpools[i+i] is the header for a list of +all partially used pools holding small blocks with "size class idx" i. So +usedpools[0] corresponds to blocks of size 8, usedpools[2] to blocks of size +16, and so on: index 2*i <-> blocks of size (i+1)<freeblock points to +the start of a singly-linked list of free blocks within the pool. When a +block is freed, it's inserted at the front of its pool's freeblock list. Note +that the available blocks in a pool are *not* linked all together when a pool +is initialized. Instead only "the first two" (lowest addresses) blocks are +set up, returning the first such block, and setting pool->freeblock to a +one-block list holding the second such block. This is consistent with that +pymalloc strives at all levels (arena, pool, and block) never to touch a piece +of memory until it's actually needed. + +So long as a pool is in the used state, we're certain there *is* a block +available for allocating, and pool->freeblock is not NULL. If pool->freeblock +points to the end of the free list before we've carved the entire pool into +blocks, that means we simply haven't yet gotten to one of the higher-address +blocks. The offset from the pool_header to the start of "the next" virgin +block is stored in the pool_header nextoffset member, and the largest value +of nextoffset that makes sense is stored in the maxnextoffset member when a +pool is initialized. All the blocks in a pool have been passed out at least +once when and only when nextoffset > maxnextoffset. + + +Major obscurity: While the usedpools vector is declared to have poolp +entries, it doesn't really. It really contains two pointers per (conceptual) +poolp entry, the nextpool and prevpool members of a pool_header. The +excruciating initialization code below fools C so that + + usedpool[i+i] + +"acts like" a genuine poolp, but only so long as you only reference its +nextpool and prevpool members. The "- 2*sizeof(pymem_block *)" gibberish is +compensating for that a pool_header's nextpool and prevpool members +immediately follow a pool_header's first two members: + + union { pymem_block *_padding; + uint count; } ref; + pymem_block *freeblock; + +each of which consume sizeof(pymem_block *) bytes. So what usedpools[i+i] really +contains is a fudged-up pointer p such that *if* C believes it's a poolp +pointer, then p->nextpool and p->prevpool are both p (meaning that the headed +circular list is empty). + +It's unclear why the usedpools setup is so convoluted. It could be to +minimize the amount of cache required to hold this heavily-referenced table +(which only *needs* the two interpool pointer members of a pool_header). OTOH, +referencing code has to remember to "double the index" and doing so isn't +free, usedpools[0] isn't a strictly legal pointer, and we're crucially relying +on that C doesn't insert any padding anywhere in a pool_header at or before +the prevpool member. +**************************************************************************** */ + +#define OBMALLOC_USED_POOLS_SIZE (2 * ((NB_SMALL_SIZE_CLASSES + 7) / 8) * 8) + +struct _obmalloc_pools { + poolp used[OBMALLOC_USED_POOLS_SIZE]; +}; + + +/*========================================================================== +Arena management. + +`arenas` is a vector of arena_objects. It contains maxarenas entries, some of +which may not be currently used (== they're arena_objects that aren't +currently associated with an allocated arena). Note that arenas proper are +separately malloc'ed. + +Prior to Python 2.5, arenas were never free()'ed. Starting with Python 2.5, +we do try to free() arenas, and use some mild heuristic strategies to increase +the likelihood that arenas eventually can be freed. + +unused_arena_objects + + This is a singly-linked list of the arena_objects that are currently not + being used (no arena is associated with them). Objects are taken off the + head of the list in new_arena(), and are pushed on the head of the list in + PyObject_Free() when the arena is empty. Key invariant: an arena_object + is on this list if and only if its .address member is 0. + +usable_arenas + + This is a doubly-linked list of the arena_objects associated with arenas + that have pools available. These pools are either waiting to be reused, + or have not been used before. The list is sorted to have the most- + allocated arenas first (ascending order based on the nfreepools member). + This means that the next allocation will come from a heavily used arena, + which gives the nearly empty arenas a chance to be returned to the system. + In my unscientific tests this dramatically improved the number of arenas + that could be freed. + +Note that an arena_object associated with an arena all of whose pools are +currently in use isn't on either list. + +Changed in Python 3.8: keeping usable_arenas sorted by number of free pools +used to be done by one-at-a-time linear search when an arena's number of +free pools changed. That could, overall, consume time quadratic in the +number of arenas. That didn't really matter when there were only a few +hundred arenas (typical!), but could be a timing disaster when there were +hundreds of thousands. See bpo-37029. + +Now we have a vector of "search fingers" to eliminate the need to search: +nfp2lasta[nfp] returns the last ("rightmost") arena in usable_arenas +with nfp free pools. This is NULL if and only if there is no arena with +nfp free pools in usable_arenas. +*/ + +/* How many arena_objects do we initially allocate? + * 16 = can allocate 16 arenas = 16 * ARENA_SIZE = 4MB before growing the + * `arenas` vector. + */ +#define INITIAL_ARENA_OBJECTS 16 + +struct _obmalloc_mgmt { + /* Array of objects used to track chunks of memory (arenas). */ + struct arena_object* arenas; + /* Number of slots currently allocated in the `arenas` vector. */ + uint maxarenas; + + /* The head of the singly-linked, NULL-terminated list of available + * arena_objects. + */ + struct arena_object* unused_arena_objects; + + /* The head of the doubly-linked, NULL-terminated at each end, list of + * arena_objects associated with arenas that have pools available. + */ + struct arena_object* usable_arenas; + + /* nfp2lasta[nfp] is the last arena in usable_arenas with nfp free pools */ + struct arena_object* nfp2lasta[MAX_POOLS_IN_ARENA + 1]; + + /* Number of arenas allocated that haven't been free()'d. */ + size_t narenas_currently_allocated; + + /* Total number of times malloc() called to allocate an arena. */ + size_t ntimes_arena_allocated; + /* High water mark (max value ever seen) for narenas_currently_allocated. */ + size_t narenas_highwater; + + Py_ssize_t raw_allocated_blocks; +}; + + +#if WITH_PYMALLOC_RADIX_TREE +/*==========================================================================*/ +/* radix tree for tracking arena usage. If enabled, used to implement + address_in_range(). + + memory address bit allocation for keys + + 64-bit pointers, IGNORE_BITS=0 and 2^20 arena size: + 15 -> MAP_TOP_BITS + 15 -> MAP_MID_BITS + 14 -> MAP_BOT_BITS + 20 -> ideal aligned arena + ---- + 64 + + 64-bit pointers, IGNORE_BITS=16, and 2^20 arena size: + 16 -> IGNORE_BITS + 10 -> MAP_TOP_BITS + 10 -> MAP_MID_BITS + 8 -> MAP_BOT_BITS + 20 -> ideal aligned arena + ---- + 64 + + 32-bit pointers and 2^18 arena size: + 14 -> MAP_BOT_BITS + 18 -> ideal aligned arena + ---- + 32 + +*/ + +#if SIZEOF_VOID_P == 8 + +/* number of bits in a pointer */ +#define POINTER_BITS 64 + +/* High bits of memory addresses that will be ignored when indexing into the + * radix tree. Setting this to zero is the safe default. For most 64-bit + * machines, setting this to 16 would be safe. The kernel would not give + * user-space virtual memory addresses that have significant information in + * those high bits. The main advantage to setting IGNORE_BITS > 0 is that less + * virtual memory will be used for the top and middle radix tree arrays. Those + * arrays are allocated in the BSS segment and so will typically consume real + * memory only if actually accessed. + */ +#define IGNORE_BITS 0 + +/* use the top and mid layers of the radix tree */ +#define USE_INTERIOR_NODES + +#elif SIZEOF_VOID_P == 4 + +#define POINTER_BITS 32 +#define IGNORE_BITS 0 + +#else + + /* Currently this code works for 64-bit or 32-bit pointers only. */ +#error "obmalloc radix tree requires 64-bit or 32-bit pointers." + +#endif /* SIZEOF_VOID_P */ + +/* arena_coverage_t members require this to be true */ +#if ARENA_BITS >= 32 +# error "arena size must be < 2^32" +#endif + +/* the lower bits of the address that are not ignored */ +#define ADDRESS_BITS (POINTER_BITS - IGNORE_BITS) + +#ifdef USE_INTERIOR_NODES +/* number of bits used for MAP_TOP and MAP_MID nodes */ +#define INTERIOR_BITS ((ADDRESS_BITS - ARENA_BITS + 2) / 3) +#else +#define INTERIOR_BITS 0 +#endif + +#define MAP_TOP_BITS INTERIOR_BITS +#define MAP_TOP_LENGTH (1 << MAP_TOP_BITS) +#define MAP_TOP_MASK (MAP_TOP_LENGTH - 1) + +#define MAP_MID_BITS INTERIOR_BITS +#define MAP_MID_LENGTH (1 << MAP_MID_BITS) +#define MAP_MID_MASK (MAP_MID_LENGTH - 1) + +#define MAP_BOT_BITS (ADDRESS_BITS - ARENA_BITS - 2*INTERIOR_BITS) +#define MAP_BOT_LENGTH (1 << MAP_BOT_BITS) +#define MAP_BOT_MASK (MAP_BOT_LENGTH - 1) + +#define MAP_BOT_SHIFT ARENA_BITS +#define MAP_MID_SHIFT (MAP_BOT_BITS + MAP_BOT_SHIFT) +#define MAP_TOP_SHIFT (MAP_MID_BITS + MAP_MID_SHIFT) + +#define AS_UINT(p) ((uintptr_t)(p)) +#define MAP_BOT_INDEX(p) ((AS_UINT(p) >> MAP_BOT_SHIFT) & MAP_BOT_MASK) +#define MAP_MID_INDEX(p) ((AS_UINT(p) >> MAP_MID_SHIFT) & MAP_MID_MASK) +#define MAP_TOP_INDEX(p) ((AS_UINT(p) >> MAP_TOP_SHIFT) & MAP_TOP_MASK) + +#if IGNORE_BITS > 0 +/* Return the ignored part of the pointer address. Those bits should be same + * for all valid pointers if IGNORE_BITS is set correctly. + */ +#define HIGH_BITS(p) (AS_UINT(p) >> ADDRESS_BITS) +#else +#define HIGH_BITS(p) 0 +#endif + + +/* This is the leaf of the radix tree. See arena_map_mark_used() for the + * meaning of these members. */ +typedef struct { + int32_t tail_hi; + int32_t tail_lo; +} arena_coverage_t; + +typedef struct arena_map_bot { + /* The members tail_hi and tail_lo are accessed together. So, it + * better to have them as an array of structs, rather than two + * arrays. + */ + arena_coverage_t arenas[MAP_BOT_LENGTH]; +} arena_map_bot_t; + +#ifdef USE_INTERIOR_NODES +typedef struct arena_map_mid { + struct arena_map_bot *ptrs[MAP_MID_LENGTH]; +} arena_map_mid_t; + +typedef struct arena_map_top { + struct arena_map_mid *ptrs[MAP_TOP_LENGTH]; +} arena_map_top_t; +#endif + +struct _obmalloc_usage { + /* The root of radix tree. Note that by initializing like this, the memory + * should be in the BSS. The OS will only memory map pages as the MAP_MID + * nodes get used (OS pages are demand loaded as needed). + */ +#ifdef USE_INTERIOR_NODES + arena_map_top_t arena_map_root; + /* accounting for number of used interior nodes */ + int arena_map_mid_count; + int arena_map_bot_count; +#else + arena_map_bot_t arena_map_root; +#endif +}; + +#endif /* WITH_PYMALLOC_RADIX_TREE */ + + +struct _obmalloc_global_state { + int dump_debug_stats; + Py_ssize_t interpreter_leaks; +}; + +struct _obmalloc_state { + struct _obmalloc_pools pools; + struct _obmalloc_mgmt mgmt; +#if WITH_PYMALLOC_RADIX_TREE + struct _obmalloc_usage usage; +#endif +}; + + +#undef uint + + +/* Allocate memory directly from the O/S virtual memory system, + * where supported. Otherwise fallback on malloc */ +void *_PyObject_VirtualAlloc(size_t size); +void _PyObject_VirtualFree(void *, size_t size); + + +/* This function returns the number of allocated memory blocks, regardless of size */ +extern Py_ssize_t _Py_GetGlobalAllocatedBlocks(void); +#define _Py_GetAllocatedBlocks() \ + _Py_GetGlobalAllocatedBlocks() +extern Py_ssize_t _PyInterpreterState_GetAllocatedBlocks(PyInterpreterState *); +extern void _PyInterpreterState_FinalizeAllocatedBlocks(PyInterpreterState *); +extern int _PyMem_init_obmalloc(PyInterpreterState *interp); +extern bool _PyMem_obmalloc_state_on_heap(PyInterpreterState *interp); + + +#ifdef WITH_PYMALLOC +// Export the symbol for the 3rd party 'guppy3' project +PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out); +#endif + + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_OBMALLOC_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_obmalloc_init.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_obmalloc_init.h new file mode 100644 index 00000000..e6811b7a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_obmalloc_init.h @@ -0,0 +1,66 @@ +#ifndef Py_INTERNAL_OBMALLOC_INIT_H +#define Py_INTERNAL_OBMALLOC_INIT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +/****************************************************/ +/* the default object allocator's state initializer */ + +#define PTA(pools, x) \ + ((poolp )((uint8_t *)&(pools.used[2*(x)]) - 2*sizeof(pymem_block *))) +#define PT(p, x) PTA(p, x), PTA(p, x) + +#define PT_8(p, start) \ + PT(p, start), \ + PT(p, start+1), \ + PT(p, start+2), \ + PT(p, start+3), \ + PT(p, start+4), \ + PT(p, start+5), \ + PT(p, start+6), \ + PT(p, start+7) + +#if NB_SMALL_SIZE_CLASSES <= 8 +# define _obmalloc_pools_INIT(p) \ + { PT_8(p, 0) } +#elif NB_SMALL_SIZE_CLASSES <= 16 +# define _obmalloc_pools_INIT(p) \ + { PT_8(p, 0), PT_8(p, 8) } +#elif NB_SMALL_SIZE_CLASSES <= 24 +# define _obmalloc_pools_INIT(p) \ + { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16) } +#elif NB_SMALL_SIZE_CLASSES <= 32 +# define _obmalloc_pools_INIT(p) \ + { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24) } +#elif NB_SMALL_SIZE_CLASSES <= 40 +# define _obmalloc_pools_INIT(p) \ + { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24), PT_8(p, 32) } +#elif NB_SMALL_SIZE_CLASSES <= 48 +# define _obmalloc_pools_INIT(p) \ + { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24), PT_8(p, 32), PT_8(p, 40) } +#elif NB_SMALL_SIZE_CLASSES <= 56 +# define _obmalloc_pools_INIT(p) \ + { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24), PT_8(p, 32), PT_8(p, 40), PT_8(p, 48) } +#elif NB_SMALL_SIZE_CLASSES <= 64 +# define _obmalloc_pools_INIT(p) \ + { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24), PT_8(p, 32), PT_8(p, 40), PT_8(p, 48), PT_8(p, 56) } +#else +# error "NB_SMALL_SIZE_CLASSES should be less than 64" +#endif + +#define _obmalloc_global_state_INIT \ + { \ + .dump_debug_stats = -1, \ + } + + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_OBMALLOC_INIT_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_opcode_metadata.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_opcode_metadata.h new file mode 100644 index 00000000..bbba0bbb --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_opcode_metadata.h @@ -0,0 +1,1922 @@ +// This file is generated by Tools/cases_generator/opcode_metadata_generator.py +// from: +// Python/bytecodes.c +// Do not edit! + +#ifndef Py_CORE_OPCODE_METADATA_H +#define Py_CORE_OPCODE_METADATA_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include // bool +#include "opcode_ids.h" + + +#define IS_PSEUDO_INSTR(OP) ( \ + ((OP) == LOAD_CLOSURE) || \ + ((OP) == STORE_FAST_MAYBE_NULL) || \ + ((OP) == LOAD_SUPER_METHOD) || \ + ((OP) == LOAD_ZERO_SUPER_METHOD) || \ + ((OP) == LOAD_ZERO_SUPER_ATTR) || \ + ((OP) == LOAD_METHOD) || \ + ((OP) == JUMP) || \ + ((OP) == JUMP_NO_INTERRUPT) || \ + ((OP) == SETUP_FINALLY) || \ + ((OP) == SETUP_CLEANUP) || \ + ((OP) == SETUP_WITH) || \ + ((OP) == POP_BLOCK) || \ + 0) + +#include "pycore_uop_ids.h" +extern int _PyOpcode_num_popped(int opcode, int oparg); +#ifdef NEED_OPCODE_METADATA +int _PyOpcode_num_popped(int opcode, int oparg) { + switch(opcode) { + case BEFORE_ASYNC_WITH: + return 1; + case BEFORE_WITH: + return 1; + case BINARY_OP: + return 2; + case BINARY_OP_ADD_FLOAT: + return 2; + case BINARY_OP_ADD_INT: + return 2; + case BINARY_OP_ADD_UNICODE: + return 2; + case BINARY_OP_INPLACE_ADD_UNICODE: + return 2; + case BINARY_OP_MULTIPLY_FLOAT: + return 2; + case BINARY_OP_MULTIPLY_INT: + return 2; + case BINARY_OP_SUBTRACT_FLOAT: + return 2; + case BINARY_OP_SUBTRACT_INT: + return 2; + case BINARY_SLICE: + return 3; + case BINARY_SUBSCR: + return 2; + case BINARY_SUBSCR_DICT: + return 2; + case BINARY_SUBSCR_GETITEM: + return 2; + case BINARY_SUBSCR_LIST_INT: + return 2; + case BINARY_SUBSCR_STR_INT: + return 2; + case BINARY_SUBSCR_TUPLE_INT: + return 2; + case BUILD_CONST_KEY_MAP: + return 1 + oparg; + case BUILD_LIST: + return oparg; + case BUILD_MAP: + return oparg*2; + case BUILD_SET: + return oparg; + case BUILD_SLICE: + return 2 + ((oparg == 3) ? 1 : 0); + case BUILD_STRING: + return oparg; + case BUILD_TUPLE: + return oparg; + case CACHE: + return 0; + case CALL: + return 2 + oparg; + case CALL_ALLOC_AND_ENTER_INIT: + return 2 + oparg; + case CALL_BOUND_METHOD_EXACT_ARGS: + return 2 + oparg; + case CALL_BOUND_METHOD_GENERAL: + return 2 + oparg; + case CALL_BUILTIN_CLASS: + return 2 + oparg; + case CALL_BUILTIN_FAST: + return 2 + oparg; + case CALL_BUILTIN_FAST_WITH_KEYWORDS: + return 2 + oparg; + case CALL_BUILTIN_O: + return 2 + oparg; + case CALL_FUNCTION_EX: + return 3 + (oparg & 1); + case CALL_INTRINSIC_1: + return 1; + case CALL_INTRINSIC_2: + return 2; + case CALL_ISINSTANCE: + return 2 + oparg; + case CALL_KW: + return 3 + oparg; + case CALL_LEN: + return 2 + oparg; + case CALL_LIST_APPEND: + return 3; + case CALL_METHOD_DESCRIPTOR_FAST: + return 2 + oparg; + case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: + return 2 + oparg; + case CALL_METHOD_DESCRIPTOR_NOARGS: + return 2 + oparg; + case CALL_METHOD_DESCRIPTOR_O: + return 2 + oparg; + case CALL_NON_PY_GENERAL: + return 2 + oparg; + case CALL_PY_EXACT_ARGS: + return 2 + oparg; + case CALL_PY_GENERAL: + return 2 + oparg; + case CALL_STR_1: + return 3; + case CALL_TUPLE_1: + return 3; + case CALL_TYPE_1: + return 3; + case CHECK_EG_MATCH: + return 2; + case CHECK_EXC_MATCH: + return 2; + case CLEANUP_THROW: + return 3; + case COMPARE_OP: + return 2; + case COMPARE_OP_FLOAT: + return 2; + case COMPARE_OP_INT: + return 2; + case COMPARE_OP_STR: + return 2; + case CONTAINS_OP: + return 2; + case CONTAINS_OP_DICT: + return 2; + case CONTAINS_OP_SET: + return 2; + case CONVERT_VALUE: + return 1; + case COPY: + return 1 + (oparg-1); + case COPY_FREE_VARS: + return 0; + case DELETE_ATTR: + return 1; + case DELETE_DEREF: + return 0; + case DELETE_FAST: + return 0; + case DELETE_GLOBAL: + return 0; + case DELETE_NAME: + return 0; + case DELETE_SUBSCR: + return 2; + case DICT_MERGE: + return 5 + (oparg - 1); + case DICT_UPDATE: + return 2 + (oparg - 1); + case END_ASYNC_FOR: + return 2; + case END_FOR: + return 1; + case END_SEND: + return 2; + case ENTER_EXECUTOR: + return 0; + case EXIT_INIT_CHECK: + return 1; + case EXTENDED_ARG: + return 0; + case FORMAT_SIMPLE: + return 1; + case FORMAT_WITH_SPEC: + return 2; + case FOR_ITER: + return 1; + case FOR_ITER_GEN: + return 1; + case FOR_ITER_LIST: + return 1; + case FOR_ITER_RANGE: + return 1; + case FOR_ITER_TUPLE: + return 1; + case GET_AITER: + return 1; + case GET_ANEXT: + return 1; + case GET_AWAITABLE: + return 1; + case GET_ITER: + return 1; + case GET_LEN: + return 1; + case GET_YIELD_FROM_ITER: + return 1; + case IMPORT_FROM: + return 1; + case IMPORT_NAME: + return 2; + case INSTRUMENTED_CALL: + return 0; + case INSTRUMENTED_CALL_FUNCTION_EX: + return 0; + case INSTRUMENTED_CALL_KW: + return 0; + case INSTRUMENTED_END_FOR: + return 2; + case INSTRUMENTED_END_SEND: + return 2; + case INSTRUMENTED_FOR_ITER: + return 0; + case INSTRUMENTED_INSTRUCTION: + return 0; + case INSTRUMENTED_JUMP_BACKWARD: + return 0; + case INSTRUMENTED_JUMP_FORWARD: + return 0; + case INSTRUMENTED_LOAD_SUPER_ATTR: + return 3; + case INSTRUMENTED_POP_JUMP_IF_FALSE: + return 0; + case INSTRUMENTED_POP_JUMP_IF_NONE: + return 0; + case INSTRUMENTED_POP_JUMP_IF_NOT_NONE: + return 0; + case INSTRUMENTED_POP_JUMP_IF_TRUE: + return 0; + case INSTRUMENTED_RESUME: + return 0; + case INSTRUMENTED_RETURN_CONST: + return 0; + case INSTRUMENTED_RETURN_VALUE: + return 1; + case INSTRUMENTED_YIELD_VALUE: + return 1; + case INTERPRETER_EXIT: + return 1; + case IS_OP: + return 2; + case JUMP_BACKWARD: + return 0; + case JUMP_BACKWARD_NO_INTERRUPT: + return 0; + case JUMP_FORWARD: + return 0; + case LIST_APPEND: + return 2 + (oparg-1); + case LIST_EXTEND: + return 2 + (oparg-1); + case LOAD_ASSERTION_ERROR: + return 0; + case LOAD_ATTR: + return 1; + case LOAD_ATTR_CLASS: + return 1; + case LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN: + return 1; + case LOAD_ATTR_INSTANCE_VALUE: + return 1; + case LOAD_ATTR_METHOD_LAZY_DICT: + return 1; + case LOAD_ATTR_METHOD_NO_DICT: + return 1; + case LOAD_ATTR_METHOD_WITH_VALUES: + return 1; + case LOAD_ATTR_MODULE: + return 1; + case LOAD_ATTR_NONDESCRIPTOR_NO_DICT: + return 1; + case LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES: + return 1; + case LOAD_ATTR_PROPERTY: + return 1; + case LOAD_ATTR_SLOT: + return 1; + case LOAD_ATTR_WITH_HINT: + return 1; + case LOAD_BUILD_CLASS: + return 0; + case LOAD_CONST: + return 0; + case LOAD_DEREF: + return 0; + case LOAD_FAST: + return 0; + case LOAD_FAST_AND_CLEAR: + return 0; + case LOAD_FAST_CHECK: + return 0; + case LOAD_FAST_LOAD_FAST: + return 0; + case LOAD_FROM_DICT_OR_DEREF: + return 1; + case LOAD_FROM_DICT_OR_GLOBALS: + return 1; + case LOAD_GLOBAL: + return 0; + case LOAD_GLOBAL_BUILTIN: + return 0; + case LOAD_GLOBAL_MODULE: + return 0; + case LOAD_LOCALS: + return 0; + case LOAD_NAME: + return 0; + case LOAD_SUPER_ATTR: + return 3; + case LOAD_SUPER_ATTR_ATTR: + return 3; + case LOAD_SUPER_ATTR_METHOD: + return 3; + case MAKE_CELL: + return 0; + case MAKE_FUNCTION: + return 1; + case MAP_ADD: + return 3 + (oparg - 1); + case MATCH_CLASS: + return 3; + case MATCH_KEYS: + return 2; + case MATCH_MAPPING: + return 1; + case MATCH_SEQUENCE: + return 1; + case NOP: + return 0; + case POP_EXCEPT: + return 1; + case POP_JUMP_IF_FALSE: + return 1; + case POP_JUMP_IF_NONE: + return 1; + case POP_JUMP_IF_NOT_NONE: + return 1; + case POP_JUMP_IF_TRUE: + return 1; + case POP_TOP: + return 1; + case PUSH_EXC_INFO: + return 1; + case PUSH_NULL: + return 0; + case RAISE_VARARGS: + return oparg; + case RERAISE: + return 1 + oparg; + case RESERVED: + return 0; + case RESUME: + return 0; + case RESUME_CHECK: + return 0; + case RETURN_CONST: + return 0; + case RETURN_GENERATOR: + return 0; + case RETURN_VALUE: + return 1; + case SEND: + return 2; + case SEND_GEN: + return 2; + case SETUP_ANNOTATIONS: + return 0; + case SET_ADD: + return 2 + (oparg-1); + case SET_FUNCTION_ATTRIBUTE: + return 2; + case SET_UPDATE: + return 2 + (oparg-1); + case STORE_ATTR: + return 2; + case STORE_ATTR_INSTANCE_VALUE: + return 2; + case STORE_ATTR_SLOT: + return 2; + case STORE_ATTR_WITH_HINT: + return 2; + case STORE_DEREF: + return 1; + case STORE_FAST: + return 1; + case STORE_FAST_LOAD_FAST: + return 1; + case STORE_FAST_STORE_FAST: + return 2; + case STORE_GLOBAL: + return 1; + case STORE_NAME: + return 1; + case STORE_SLICE: + return 4; + case STORE_SUBSCR: + return 3; + case STORE_SUBSCR_DICT: + return 3; + case STORE_SUBSCR_LIST_INT: + return 3; + case SWAP: + return 2 + (oparg-2); + case TO_BOOL: + return 1; + case TO_BOOL_ALWAYS_TRUE: + return 1; + case TO_BOOL_BOOL: + return 1; + case TO_BOOL_INT: + return 1; + case TO_BOOL_LIST: + return 1; + case TO_BOOL_NONE: + return 1; + case TO_BOOL_STR: + return 1; + case UNARY_INVERT: + return 1; + case UNARY_NEGATIVE: + return 1; + case UNARY_NOT: + return 1; + case UNPACK_EX: + return 1; + case UNPACK_SEQUENCE: + return 1; + case UNPACK_SEQUENCE_LIST: + return 1; + case UNPACK_SEQUENCE_TUPLE: + return 1; + case UNPACK_SEQUENCE_TWO_TUPLE: + return 1; + case WITH_EXCEPT_START: + return 4; + case YIELD_VALUE: + return 1; + default: + return -1; + } +} + +#endif + +extern int _PyOpcode_num_pushed(int opcode, int oparg); +#ifdef NEED_OPCODE_METADATA +int _PyOpcode_num_pushed(int opcode, int oparg) { + switch(opcode) { + case BEFORE_ASYNC_WITH: + return 2; + case BEFORE_WITH: + return 2; + case BINARY_OP: + return 1; + case BINARY_OP_ADD_FLOAT: + return 1; + case BINARY_OP_ADD_INT: + return 1; + case BINARY_OP_ADD_UNICODE: + return 1; + case BINARY_OP_INPLACE_ADD_UNICODE: + return 0; + case BINARY_OP_MULTIPLY_FLOAT: + return 1; + case BINARY_OP_MULTIPLY_INT: + return 1; + case BINARY_OP_SUBTRACT_FLOAT: + return 1; + case BINARY_OP_SUBTRACT_INT: + return 1; + case BINARY_SLICE: + return 1; + case BINARY_SUBSCR: + return 1; + case BINARY_SUBSCR_DICT: + return 1; + case BINARY_SUBSCR_GETITEM: + return 1; + case BINARY_SUBSCR_LIST_INT: + return 1; + case BINARY_SUBSCR_STR_INT: + return 1; + case BINARY_SUBSCR_TUPLE_INT: + return 1; + case BUILD_CONST_KEY_MAP: + return 1; + case BUILD_LIST: + return 1; + case BUILD_MAP: + return 1; + case BUILD_SET: + return 1; + case BUILD_SLICE: + return 1; + case BUILD_STRING: + return 1; + case BUILD_TUPLE: + return 1; + case CACHE: + return 0; + case CALL: + return 1; + case CALL_ALLOC_AND_ENTER_INIT: + return 1; + case CALL_BOUND_METHOD_EXACT_ARGS: + return 0; + case CALL_BOUND_METHOD_GENERAL: + return 0; + case CALL_BUILTIN_CLASS: + return 1; + case CALL_BUILTIN_FAST: + return 1; + case CALL_BUILTIN_FAST_WITH_KEYWORDS: + return 1; + case CALL_BUILTIN_O: + return 1; + case CALL_FUNCTION_EX: + return 1; + case CALL_INTRINSIC_1: + return 1; + case CALL_INTRINSIC_2: + return 1; + case CALL_ISINSTANCE: + return 1; + case CALL_KW: + return 1; + case CALL_LEN: + return 1; + case CALL_LIST_APPEND: + return 1; + case CALL_METHOD_DESCRIPTOR_FAST: + return 1; + case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: + return 1; + case CALL_METHOD_DESCRIPTOR_NOARGS: + return 1; + case CALL_METHOD_DESCRIPTOR_O: + return 1; + case CALL_NON_PY_GENERAL: + return 1; + case CALL_PY_EXACT_ARGS: + return 0; + case CALL_PY_GENERAL: + return 0; + case CALL_STR_1: + return 1; + case CALL_TUPLE_1: + return 1; + case CALL_TYPE_1: + return 1; + case CHECK_EG_MATCH: + return 2; + case CHECK_EXC_MATCH: + return 2; + case CLEANUP_THROW: + return 2; + case COMPARE_OP: + return 1; + case COMPARE_OP_FLOAT: + return 1; + case COMPARE_OP_INT: + return 1; + case COMPARE_OP_STR: + return 1; + case CONTAINS_OP: + return 1; + case CONTAINS_OP_DICT: + return 1; + case CONTAINS_OP_SET: + return 1; + case CONVERT_VALUE: + return 1; + case COPY: + return 2 + (oparg-1); + case COPY_FREE_VARS: + return 0; + case DELETE_ATTR: + return 0; + case DELETE_DEREF: + return 0; + case DELETE_FAST: + return 0; + case DELETE_GLOBAL: + return 0; + case DELETE_NAME: + return 0; + case DELETE_SUBSCR: + return 0; + case DICT_MERGE: + return 4 + (oparg - 1); + case DICT_UPDATE: + return 1 + (oparg - 1); + case END_ASYNC_FOR: + return 0; + case END_FOR: + return 0; + case END_SEND: + return 1; + case ENTER_EXECUTOR: + return 0; + case EXIT_INIT_CHECK: + return 0; + case EXTENDED_ARG: + return 0; + case FORMAT_SIMPLE: + return 1; + case FORMAT_WITH_SPEC: + return 1; + case FOR_ITER: + return 2; + case FOR_ITER_GEN: + return 1; + case FOR_ITER_LIST: + return 2; + case FOR_ITER_RANGE: + return 2; + case FOR_ITER_TUPLE: + return 2; + case GET_AITER: + return 1; + case GET_ANEXT: + return 2; + case GET_AWAITABLE: + return 1; + case GET_ITER: + return 1; + case GET_LEN: + return 2; + case GET_YIELD_FROM_ITER: + return 1; + case IMPORT_FROM: + return 2; + case IMPORT_NAME: + return 1; + case INSTRUMENTED_CALL: + return 0; + case INSTRUMENTED_CALL_FUNCTION_EX: + return 0; + case INSTRUMENTED_CALL_KW: + return 0; + case INSTRUMENTED_END_FOR: + return 1; + case INSTRUMENTED_END_SEND: + return 1; + case INSTRUMENTED_FOR_ITER: + return 0; + case INSTRUMENTED_INSTRUCTION: + return 0; + case INSTRUMENTED_JUMP_BACKWARD: + return 0; + case INSTRUMENTED_JUMP_FORWARD: + return 0; + case INSTRUMENTED_LOAD_SUPER_ATTR: + return 1 + (oparg & 1); + case INSTRUMENTED_POP_JUMP_IF_FALSE: + return 0; + case INSTRUMENTED_POP_JUMP_IF_NONE: + return 0; + case INSTRUMENTED_POP_JUMP_IF_NOT_NONE: + return 0; + case INSTRUMENTED_POP_JUMP_IF_TRUE: + return 0; + case INSTRUMENTED_RESUME: + return 0; + case INSTRUMENTED_RETURN_CONST: + return 0; + case INSTRUMENTED_RETURN_VALUE: + return 0; + case INSTRUMENTED_YIELD_VALUE: + return 1; + case INTERPRETER_EXIT: + return 0; + case IS_OP: + return 1; + case JUMP_BACKWARD: + return 0; + case JUMP_BACKWARD_NO_INTERRUPT: + return 0; + case JUMP_FORWARD: + return 0; + case LIST_APPEND: + return 1 + (oparg-1); + case LIST_EXTEND: + return 1 + (oparg-1); + case LOAD_ASSERTION_ERROR: + return 1; + case LOAD_ATTR: + return 1 + (oparg & 1); + case LOAD_ATTR_CLASS: + return 1 + (oparg & 1); + case LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN: + return 1; + case LOAD_ATTR_INSTANCE_VALUE: + return 1 + (oparg & 1); + case LOAD_ATTR_METHOD_LAZY_DICT: + return 2; + case LOAD_ATTR_METHOD_NO_DICT: + return 2; + case LOAD_ATTR_METHOD_WITH_VALUES: + return 2; + case LOAD_ATTR_MODULE: + return 1 + (oparg & 1); + case LOAD_ATTR_NONDESCRIPTOR_NO_DICT: + return 1; + case LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES: + return 1; + case LOAD_ATTR_PROPERTY: + return 1; + case LOAD_ATTR_SLOT: + return 1 + (oparg & 1); + case LOAD_ATTR_WITH_HINT: + return 1 + (oparg & 1); + case LOAD_BUILD_CLASS: + return 1; + case LOAD_CONST: + return 1; + case LOAD_DEREF: + return 1; + case LOAD_FAST: + return 1; + case LOAD_FAST_AND_CLEAR: + return 1; + case LOAD_FAST_CHECK: + return 1; + case LOAD_FAST_LOAD_FAST: + return 2; + case LOAD_FROM_DICT_OR_DEREF: + return 1; + case LOAD_FROM_DICT_OR_GLOBALS: + return 1; + case LOAD_GLOBAL: + return 1 + (oparg & 1); + case LOAD_GLOBAL_BUILTIN: + return 1 + (oparg & 1); + case LOAD_GLOBAL_MODULE: + return 1 + (oparg & 1); + case LOAD_LOCALS: + return 1; + case LOAD_NAME: + return 1; + case LOAD_SUPER_ATTR: + return 1 + (oparg & 1); + case LOAD_SUPER_ATTR_ATTR: + return 1; + case LOAD_SUPER_ATTR_METHOD: + return 2; + case MAKE_CELL: + return 0; + case MAKE_FUNCTION: + return 1; + case MAP_ADD: + return 1 + (oparg - 1); + case MATCH_CLASS: + return 1; + case MATCH_KEYS: + return 3; + case MATCH_MAPPING: + return 2; + case MATCH_SEQUENCE: + return 2; + case NOP: + return 0; + case POP_EXCEPT: + return 0; + case POP_JUMP_IF_FALSE: + return 0; + case POP_JUMP_IF_NONE: + return 0; + case POP_JUMP_IF_NOT_NONE: + return 0; + case POP_JUMP_IF_TRUE: + return 0; + case POP_TOP: + return 0; + case PUSH_EXC_INFO: + return 2; + case PUSH_NULL: + return 1; + case RAISE_VARARGS: + return 0; + case RERAISE: + return oparg; + case RESERVED: + return 0; + case RESUME: + return 0; + case RESUME_CHECK: + return 0; + case RETURN_CONST: + return 0; + case RETURN_GENERATOR: + return 1; + case RETURN_VALUE: + return 0; + case SEND: + return 2; + case SEND_GEN: + return 2; + case SETUP_ANNOTATIONS: + return 0; + case SET_ADD: + return 1 + (oparg-1); + case SET_FUNCTION_ATTRIBUTE: + return 1; + case SET_UPDATE: + return 1 + (oparg-1); + case STORE_ATTR: + return 0; + case STORE_ATTR_INSTANCE_VALUE: + return 0; + case STORE_ATTR_SLOT: + return 0; + case STORE_ATTR_WITH_HINT: + return 0; + case STORE_DEREF: + return 0; + case STORE_FAST: + return 0; + case STORE_FAST_LOAD_FAST: + return 1; + case STORE_FAST_STORE_FAST: + return 0; + case STORE_GLOBAL: + return 0; + case STORE_NAME: + return 0; + case STORE_SLICE: + return 0; + case STORE_SUBSCR: + return 0; + case STORE_SUBSCR_DICT: + return 0; + case STORE_SUBSCR_LIST_INT: + return 0; + case SWAP: + return 2 + (oparg-2); + case TO_BOOL: + return 1; + case TO_BOOL_ALWAYS_TRUE: + return 1; + case TO_BOOL_BOOL: + return 1; + case TO_BOOL_INT: + return 1; + case TO_BOOL_LIST: + return 1; + case TO_BOOL_NONE: + return 1; + case TO_BOOL_STR: + return 1; + case UNARY_INVERT: + return 1; + case UNARY_NEGATIVE: + return 1; + case UNARY_NOT: + return 1; + case UNPACK_EX: + return 1 + (oparg >> 8) + (oparg & 0xFF); + case UNPACK_SEQUENCE: + return oparg; + case UNPACK_SEQUENCE_LIST: + return oparg; + case UNPACK_SEQUENCE_TUPLE: + return oparg; + case UNPACK_SEQUENCE_TWO_TUPLE: + return 2; + case WITH_EXCEPT_START: + return 5; + case YIELD_VALUE: + return 1; + default: + return -1; + } +} + +#endif + +enum InstructionFormat { + INSTR_FMT_IB = 1, + INSTR_FMT_IBC = 2, + INSTR_FMT_IBC00 = 3, + INSTR_FMT_IBC000 = 4, + INSTR_FMT_IBC00000000 = 5, + INSTR_FMT_IX = 6, + INSTR_FMT_IXC = 7, + INSTR_FMT_IXC00 = 8, + INSTR_FMT_IXC000 = 9, +}; + +#define IS_VALID_OPCODE(OP) \ + (((OP) >= 0) && ((OP) < 268) && \ + (_PyOpcode_opcode_metadata[(OP)].valid_entry)) + +#define HAS_ARG_FLAG (1) +#define HAS_CONST_FLAG (2) +#define HAS_NAME_FLAG (4) +#define HAS_JUMP_FLAG (8) +#define HAS_FREE_FLAG (16) +#define HAS_LOCAL_FLAG (32) +#define HAS_EVAL_BREAK_FLAG (64) +#define HAS_DEOPT_FLAG (128) +#define HAS_ERROR_FLAG (256) +#define HAS_ESCAPES_FLAG (512) +#define HAS_EXIT_FLAG (1024) +#define HAS_PURE_FLAG (2048) +#define HAS_PASSTHROUGH_FLAG (4096) +#define HAS_OPARG_AND_1_FLAG (8192) +#define HAS_ERROR_NO_POP_FLAG (16384) +#define OPCODE_HAS_ARG(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_ARG_FLAG)) +#define OPCODE_HAS_CONST(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_CONST_FLAG)) +#define OPCODE_HAS_NAME(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_NAME_FLAG)) +#define OPCODE_HAS_JUMP(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_JUMP_FLAG)) +#define OPCODE_HAS_FREE(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_FREE_FLAG)) +#define OPCODE_HAS_LOCAL(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_LOCAL_FLAG)) +#define OPCODE_HAS_EVAL_BREAK(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_EVAL_BREAK_FLAG)) +#define OPCODE_HAS_DEOPT(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_DEOPT_FLAG)) +#define OPCODE_HAS_ERROR(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_ERROR_FLAG)) +#define OPCODE_HAS_ESCAPES(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_ESCAPES_FLAG)) +#define OPCODE_HAS_EXIT(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_EXIT_FLAG)) +#define OPCODE_HAS_PURE(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_PURE_FLAG)) +#define OPCODE_HAS_PASSTHROUGH(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_PASSTHROUGH_FLAG)) +#define OPCODE_HAS_OPARG_AND_1(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_OPARG_AND_1_FLAG)) +#define OPCODE_HAS_ERROR_NO_POP(OP) (_PyOpcode_opcode_metadata[OP].flags & (HAS_ERROR_NO_POP_FLAG)) + +#define OPARG_FULL 0 +#define OPARG_CACHE_1 1 +#define OPARG_CACHE_2 2 +#define OPARG_CACHE_4 4 +#define OPARG_TOP 5 +#define OPARG_BOTTOM 6 +#define OPARG_SAVE_RETURN_OFFSET 7 +#define OPARG_REPLACED 9 + +struct opcode_metadata { + uint8_t valid_entry; + int8_t instr_format; + int16_t flags; +}; + +extern const struct opcode_metadata _PyOpcode_opcode_metadata[268]; +#ifdef NEED_OPCODE_METADATA +const struct opcode_metadata _PyOpcode_opcode_metadata[268] = { + [BEFORE_ASYNC_WITH] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [BEFORE_WITH] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [BINARY_OP] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [BINARY_OP_ADD_FLOAT] = { true, INSTR_FMT_IXC, HAS_EXIT_FLAG }, + [BINARY_OP_ADD_INT] = { true, INSTR_FMT_IXC, HAS_EXIT_FLAG | HAS_ERROR_FLAG }, + [BINARY_OP_ADD_UNICODE] = { true, INSTR_FMT_IXC, HAS_EXIT_FLAG | HAS_ERROR_FLAG }, + [BINARY_OP_INPLACE_ADD_UNICODE] = { true, INSTR_FMT_IXC, HAS_LOCAL_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [BINARY_OP_MULTIPLY_FLOAT] = { true, INSTR_FMT_IXC, HAS_EXIT_FLAG }, + [BINARY_OP_MULTIPLY_INT] = { true, INSTR_FMT_IXC, HAS_EXIT_FLAG | HAS_ERROR_FLAG }, + [BINARY_OP_SUBTRACT_FLOAT] = { true, INSTR_FMT_IXC, HAS_EXIT_FLAG }, + [BINARY_OP_SUBTRACT_INT] = { true, INSTR_FMT_IXC, HAS_EXIT_FLAG | HAS_ERROR_FLAG }, + [BINARY_SLICE] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [BINARY_SUBSCR] = { true, INSTR_FMT_IXC, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [BINARY_SUBSCR_DICT] = { true, INSTR_FMT_IXC, HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [BINARY_SUBSCR_GETITEM] = { true, INSTR_FMT_IXC, HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG }, + [BINARY_SUBSCR_LIST_INT] = { true, INSTR_FMT_IXC, HAS_DEOPT_FLAG }, + [BINARY_SUBSCR_STR_INT] = { true, INSTR_FMT_IXC, HAS_DEOPT_FLAG }, + [BINARY_SUBSCR_TUPLE_INT] = { true, INSTR_FMT_IXC, HAS_DEOPT_FLAG }, + [BUILD_CONST_KEY_MAP] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [BUILD_LIST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG }, + [BUILD_MAP] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [BUILD_SET] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [BUILD_SLICE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG }, + [BUILD_STRING] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG }, + [BUILD_TUPLE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG }, + [CACHE] = { true, INSTR_FMT_IX, 0 }, + [CALL] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_ALLOC_AND_ENTER_INIT] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_BOUND_METHOD_EXACT_ARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [CALL_BOUND_METHOD_GENERAL] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_BUILTIN_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_BUILTIN_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_FUNCTION_EX] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_INTRINSIC_1] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_INTRINSIC_2] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_ISINSTANCE] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_KW] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_LEN] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_LIST_APPEND] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG }, + [CALL_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_METHOD_DESCRIPTOR_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_NON_PY_GENERAL] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_PY_EXACT_ARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [CALL_PY_GENERAL] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_STR_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_TUPLE_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_TYPE_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [CHECK_EG_MATCH] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CHECK_EXC_MATCH] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CLEANUP_THROW] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [COMPARE_OP] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [COMPARE_OP_FLOAT] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_EXIT_FLAG }, + [COMPARE_OP_INT] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [COMPARE_OP_STR] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_EXIT_FLAG }, + [CONTAINS_OP] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CONTAINS_OP_DICT] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CONTAINS_OP_SET] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CONVERT_VALUE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG }, + [COPY] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_PURE_FLAG }, + [COPY_FREE_VARS] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, + [DELETE_ATTR] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [DELETE_DEREF] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [DELETE_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [DELETE_GLOBAL] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [DELETE_NAME] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [DELETE_SUBSCR] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [DICT_MERGE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [DICT_UPDATE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [END_ASYNC_FOR] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [END_FOR] = { true, INSTR_FMT_IX, HAS_PURE_FLAG }, + [END_SEND] = { true, INSTR_FMT_IX, HAS_PURE_FLAG }, + [ENTER_EXECUTOR] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, + [EXIT_INIT_CHECK] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [EXTENDED_ARG] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, + [FORMAT_SIMPLE] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [FORMAT_WITH_SPEC] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [FOR_ITER] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [FOR_ITER_GEN] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [FOR_ITER_LIST] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG | HAS_EXIT_FLAG }, + [FOR_ITER_RANGE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG }, + [FOR_ITER_TUPLE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG | HAS_EXIT_FLAG }, + [GET_AITER] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [GET_ANEXT] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [GET_AWAITABLE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [GET_ITER] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [GET_LEN] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [GET_YIELD_FROM_ITER] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [IMPORT_FROM] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [IMPORT_NAME] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [INSTRUMENTED_CALL] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [INSTRUMENTED_CALL_FUNCTION_EX] = { true, INSTR_FMT_IX, 0 }, + [INSTRUMENTED_CALL_KW] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [INSTRUMENTED_END_FOR] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG }, + [INSTRUMENTED_END_SEND] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG }, + [INSTRUMENTED_FOR_ITER] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [INSTRUMENTED_INSTRUCTION] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [INSTRUMENTED_JUMP_BACKWARD] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, + [INSTRUMENTED_JUMP_FORWARD] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, + [INSTRUMENTED_LOAD_SUPER_ATTR] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG }, + [INSTRUMENTED_POP_JUMP_IF_FALSE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG }, + [INSTRUMENTED_POP_JUMP_IF_NONE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG }, + [INSTRUMENTED_POP_JUMP_IF_NOT_NONE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG }, + [INSTRUMENTED_POP_JUMP_IF_TRUE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG }, + [INSTRUMENTED_RESUME] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [INSTRUMENTED_RETURN_CONST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_CONST_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [INSTRUMENTED_RETURN_VALUE] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [INSTRUMENTED_YIELD_VALUE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [INTERPRETER_EXIT] = { true, INSTR_FMT_IX, HAS_ESCAPES_FLAG }, + [IS_OP] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, + [JUMP_BACKWARD] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [JUMP_BACKWARD_NO_INTERRUPT] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_JUMP_FLAG }, + [JUMP_FORWARD] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_JUMP_FLAG }, + [LIST_APPEND] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG }, + [LIST_EXTEND] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_ASSERTION_ERROR] = { true, INSTR_FMT_IX, 0 }, + [LOAD_ATTR] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_ATTR_CLASS] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [LOAD_ATTR_METHOD_LAZY_DICT] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [LOAD_ATTR_METHOD_NO_DICT] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_EXIT_FLAG }, + [LOAD_ATTR_METHOD_WITH_VALUES] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [LOAD_ATTR_MODULE] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_EXIT_FLAG }, + [LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [LOAD_ATTR_PROPERTY] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_ATTR_SLOT] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [LOAD_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [LOAD_BUILD_CLASS] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_CONST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_CONST_FLAG | HAS_PURE_FLAG }, + [LOAD_DEREF] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG | HAS_PURE_FLAG }, + [LOAD_FAST_AND_CLEAR] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG }, + [LOAD_FAST_CHECK] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_FAST_LOAD_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG }, + [LOAD_FROM_DICT_OR_DEREF] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_FROM_DICT_OR_GLOBALS] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_GLOBAL] = { true, INSTR_FMT_IBC000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_GLOBAL_BUILTIN] = { true, INSTR_FMT_IBC000, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [LOAD_LOCALS] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_NAME] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_SUPER_ATTR] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_SUPER_ATTR_ATTR] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_SUPER_ATTR_METHOD] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [MAKE_CELL] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG }, + [MAKE_FUNCTION] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [MAP_ADD] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [MATCH_CLASS] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [MATCH_KEYS] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [MATCH_MAPPING] = { true, INSTR_FMT_IX, 0 }, + [MATCH_SEQUENCE] = { true, INSTR_FMT_IX, 0 }, + [NOP] = { true, INSTR_FMT_IX, HAS_PURE_FLAG }, + [POP_EXCEPT] = { true, INSTR_FMT_IX, HAS_ESCAPES_FLAG }, + [POP_JUMP_IF_FALSE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG }, + [POP_JUMP_IF_NONE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG }, + [POP_JUMP_IF_NOT_NONE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG }, + [POP_JUMP_IF_TRUE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG }, + [POP_TOP] = { true, INSTR_FMT_IX, HAS_PURE_FLAG }, + [PUSH_EXC_INFO] = { true, INSTR_FMT_IX, 0 }, + [PUSH_NULL] = { true, INSTR_FMT_IX, HAS_PURE_FLAG }, + [RAISE_VARARGS] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [RERAISE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [RESERVED] = { true, INSTR_FMT_IX, 0 }, + [RESUME] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [RESUME_CHECK] = { true, INSTR_FMT_IX, HAS_DEOPT_FLAG }, + [RETURN_CONST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_CONST_FLAG }, + [RETURN_GENERATOR] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [RETURN_VALUE] = { true, INSTR_FMT_IX, 0 }, + [SEND] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_JUMP_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [SEND_GEN] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [SETUP_ANNOTATIONS] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [SET_ADD] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [SET_FUNCTION_ATTRIBUTE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ESCAPES_FLAG }, + [SET_UPDATE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [STORE_ATTR] = { true, INSTR_FMT_IBC000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [STORE_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IXC000, HAS_DEOPT_FLAG | HAS_EXIT_FLAG }, + [STORE_ATTR_SLOT] = { true, INSTR_FMT_IXC000, HAS_EXIT_FLAG }, + [STORE_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG }, + [STORE_DEREF] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ESCAPES_FLAG }, + [STORE_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG }, + [STORE_FAST_LOAD_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG }, + [STORE_FAST_STORE_FAST] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_LOCAL_FLAG }, + [STORE_GLOBAL] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [STORE_NAME] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [STORE_SLICE] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [STORE_SUBSCR] = { true, INSTR_FMT_IXC, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [STORE_SUBSCR_DICT] = { true, INSTR_FMT_IXC, HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [STORE_SUBSCR_LIST_INT] = { true, INSTR_FMT_IXC, HAS_DEOPT_FLAG }, + [SWAP] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_PURE_FLAG }, + [TO_BOOL] = { true, INSTR_FMT_IXC00, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [TO_BOOL_ALWAYS_TRUE] = { true, INSTR_FMT_IXC00, HAS_EXIT_FLAG }, + [TO_BOOL_BOOL] = { true, INSTR_FMT_IXC00, HAS_EXIT_FLAG }, + [TO_BOOL_INT] = { true, INSTR_FMT_IXC00, HAS_EXIT_FLAG | HAS_ESCAPES_FLAG }, + [TO_BOOL_LIST] = { true, INSTR_FMT_IXC00, HAS_EXIT_FLAG }, + [TO_BOOL_NONE] = { true, INSTR_FMT_IXC00, HAS_EXIT_FLAG }, + [TO_BOOL_STR] = { true, INSTR_FMT_IXC00, HAS_EXIT_FLAG | HAS_ESCAPES_FLAG }, + [UNARY_INVERT] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [UNARY_NEGATIVE] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [UNARY_NOT] = { true, INSTR_FMT_IX, HAS_PURE_FLAG }, + [UNPACK_EX] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [UNPACK_SEQUENCE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [UNPACK_SEQUENCE_LIST] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [UNPACK_SEQUENCE_TUPLE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [UNPACK_SEQUENCE_TWO_TUPLE] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [WITH_EXCEPT_START] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [YIELD_VALUE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ESCAPES_FLAG }, + [JUMP] = { true, -1, HAS_ARG_FLAG | HAS_JUMP_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [JUMP_NO_INTERRUPT] = { true, -1, HAS_ARG_FLAG | HAS_JUMP_FLAG }, + [LOAD_CLOSURE] = { true, -1, HAS_ARG_FLAG | HAS_LOCAL_FLAG | HAS_PURE_FLAG }, + [LOAD_METHOD] = { true, -1, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_SUPER_METHOD] = { true, -1, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_ZERO_SUPER_ATTR] = { true, -1, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_ZERO_SUPER_METHOD] = { true, -1, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [POP_BLOCK] = { true, -1, HAS_PURE_FLAG }, + [SETUP_CLEANUP] = { true, -1, HAS_PURE_FLAG | HAS_ARG_FLAG }, + [SETUP_FINALLY] = { true, -1, HAS_PURE_FLAG | HAS_ARG_FLAG }, + [SETUP_WITH] = { true, -1, HAS_PURE_FLAG | HAS_ARG_FLAG }, + [STORE_FAST_MAYBE_NULL] = { true, -1, HAS_ARG_FLAG | HAS_LOCAL_FLAG }, +}; +#endif + +#define MAX_UOP_PER_EXPANSION 8 +struct opcode_macro_expansion { + int nuops; + struct { int16_t uop; int8_t size; int8_t offset; } uops[MAX_UOP_PER_EXPANSION]; +}; +extern const struct opcode_macro_expansion _PyOpcode_macro_expansion[256]; + +#ifdef NEED_OPCODE_METADATA +const struct opcode_macro_expansion +_PyOpcode_macro_expansion[256] = { + [BINARY_OP] = { .nuops = 1, .uops = { { _BINARY_OP, 0, 0 } } }, + [BINARY_OP_ADD_FLOAT] = { .nuops = 2, .uops = { { _GUARD_BOTH_FLOAT, 0, 0 }, { _BINARY_OP_ADD_FLOAT, 0, 0 } } }, + [BINARY_OP_ADD_INT] = { .nuops = 2, .uops = { { _GUARD_BOTH_INT, 0, 0 }, { _BINARY_OP_ADD_INT, 0, 0 } } }, + [BINARY_OP_ADD_UNICODE] = { .nuops = 2, .uops = { { _GUARD_BOTH_UNICODE, 0, 0 }, { _BINARY_OP_ADD_UNICODE, 0, 0 } } }, + [BINARY_OP_MULTIPLY_FLOAT] = { .nuops = 2, .uops = { { _GUARD_BOTH_FLOAT, 0, 0 }, { _BINARY_OP_MULTIPLY_FLOAT, 0, 0 } } }, + [BINARY_OP_MULTIPLY_INT] = { .nuops = 2, .uops = { { _GUARD_BOTH_INT, 0, 0 }, { _BINARY_OP_MULTIPLY_INT, 0, 0 } } }, + [BINARY_OP_SUBTRACT_FLOAT] = { .nuops = 2, .uops = { { _GUARD_BOTH_FLOAT, 0, 0 }, { _BINARY_OP_SUBTRACT_FLOAT, 0, 0 } } }, + [BINARY_OP_SUBTRACT_INT] = { .nuops = 2, .uops = { { _GUARD_BOTH_INT, 0, 0 }, { _BINARY_OP_SUBTRACT_INT, 0, 0 } } }, + [BINARY_SLICE] = { .nuops = 1, .uops = { { _BINARY_SLICE, 0, 0 } } }, + [BINARY_SUBSCR] = { .nuops = 1, .uops = { { _BINARY_SUBSCR, 0, 0 } } }, + [BINARY_SUBSCR_DICT] = { .nuops = 1, .uops = { { _BINARY_SUBSCR_DICT, 0, 0 } } }, + [BINARY_SUBSCR_LIST_INT] = { .nuops = 1, .uops = { { _BINARY_SUBSCR_LIST_INT, 0, 0 } } }, + [BINARY_SUBSCR_STR_INT] = { .nuops = 1, .uops = { { _BINARY_SUBSCR_STR_INT, 0, 0 } } }, + [BINARY_SUBSCR_TUPLE_INT] = { .nuops = 1, .uops = { { _BINARY_SUBSCR_TUPLE_INT, 0, 0 } } }, + [BUILD_CONST_KEY_MAP] = { .nuops = 1, .uops = { { _BUILD_CONST_KEY_MAP, 0, 0 } } }, + [BUILD_LIST] = { .nuops = 1, .uops = { { _BUILD_LIST, 0, 0 } } }, + [BUILD_MAP] = { .nuops = 1, .uops = { { _BUILD_MAP, 0, 0 } } }, + [BUILD_SLICE] = { .nuops = 1, .uops = { { _BUILD_SLICE, 0, 0 } } }, + [BUILD_STRING] = { .nuops = 1, .uops = { { _BUILD_STRING, 0, 0 } } }, + [BUILD_TUPLE] = { .nuops = 1, .uops = { { _BUILD_TUPLE, 0, 0 } } }, + [CALL_BOUND_METHOD_EXACT_ARGS] = { .nuops = 8, .uops = { { _CHECK_PEP_523, 0, 0 }, { _CHECK_CALL_BOUND_METHOD_EXACT_ARGS, 0, 0 }, { _INIT_CALL_BOUND_METHOD_EXACT_ARGS, 0, 0 }, { _CHECK_FUNCTION_EXACT_ARGS, 2, 1 }, { _CHECK_STACK_SPACE, 0, 0 }, { _INIT_CALL_PY_EXACT_ARGS, 0, 0 }, { _SAVE_RETURN_OFFSET, 7, 3 }, { _PUSH_FRAME, 0, 0 } } }, + [CALL_BOUND_METHOD_GENERAL] = { .nuops = 6, .uops = { { _CHECK_PEP_523, 0, 0 }, { _CHECK_METHOD_VERSION, 2, 1 }, { _EXPAND_METHOD, 0, 0 }, { _PY_FRAME_GENERAL, 0, 0 }, { _SAVE_RETURN_OFFSET, 7, 3 }, { _PUSH_FRAME, 0, 0 } } }, + [CALL_BUILTIN_CLASS] = { .nuops = 2, .uops = { { _CALL_BUILTIN_CLASS, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_BUILTIN_FAST] = { .nuops = 2, .uops = { { _CALL_BUILTIN_FAST, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .nuops = 2, .uops = { { _CALL_BUILTIN_FAST_WITH_KEYWORDS, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_BUILTIN_O] = { .nuops = 2, .uops = { { _CALL_BUILTIN_O, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_INTRINSIC_1] = { .nuops = 1, .uops = { { _CALL_INTRINSIC_1, 0, 0 } } }, + [CALL_INTRINSIC_2] = { .nuops = 1, .uops = { { _CALL_INTRINSIC_2, 0, 0 } } }, + [CALL_ISINSTANCE] = { .nuops = 1, .uops = { { _CALL_ISINSTANCE, 0, 0 } } }, + [CALL_LEN] = { .nuops = 1, .uops = { { _CALL_LEN, 0, 0 } } }, + [CALL_METHOD_DESCRIPTOR_FAST] = { .nuops = 2, .uops = { { _CALL_METHOD_DESCRIPTOR_FAST, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { .nuops = 2, .uops = { { _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_METHOD_DESCRIPTOR_NOARGS] = { .nuops = 2, .uops = { { _CALL_METHOD_DESCRIPTOR_NOARGS, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_METHOD_DESCRIPTOR_O] = { .nuops = 2, .uops = { { _CALL_METHOD_DESCRIPTOR_O, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_NON_PY_GENERAL] = { .nuops = 3, .uops = { { _CHECK_IS_NOT_PY_CALLABLE, 0, 0 }, { _CALL_NON_PY_GENERAL, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_PY_EXACT_ARGS] = { .nuops = 6, .uops = { { _CHECK_PEP_523, 0, 0 }, { _CHECK_FUNCTION_EXACT_ARGS, 2, 1 }, { _CHECK_STACK_SPACE, 0, 0 }, { _INIT_CALL_PY_EXACT_ARGS, 0, 0 }, { _SAVE_RETURN_OFFSET, 7, 3 }, { _PUSH_FRAME, 0, 0 } } }, + [CALL_PY_GENERAL] = { .nuops = 5, .uops = { { _CHECK_PEP_523, 0, 0 }, { _CHECK_FUNCTION_VERSION, 2, 1 }, { _PY_FRAME_GENERAL, 0, 0 }, { _SAVE_RETURN_OFFSET, 7, 3 }, { _PUSH_FRAME, 0, 0 } } }, + [CALL_STR_1] = { .nuops = 2, .uops = { { _CALL_STR_1, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_TUPLE_1] = { .nuops = 2, .uops = { { _CALL_TUPLE_1, 0, 0 }, { _CHECK_PERIODIC, 0, 0 } } }, + [CALL_TYPE_1] = { .nuops = 1, .uops = { { _CALL_TYPE_1, 0, 0 } } }, + [CHECK_EG_MATCH] = { .nuops = 1, .uops = { { _CHECK_EG_MATCH, 0, 0 } } }, + [CHECK_EXC_MATCH] = { .nuops = 1, .uops = { { _CHECK_EXC_MATCH, 0, 0 } } }, + [COMPARE_OP] = { .nuops = 1, .uops = { { _COMPARE_OP, 0, 0 } } }, + [COMPARE_OP_FLOAT] = { .nuops = 2, .uops = { { _GUARD_BOTH_FLOAT, 0, 0 }, { _COMPARE_OP_FLOAT, 0, 0 } } }, + [COMPARE_OP_INT] = { .nuops = 2, .uops = { { _GUARD_BOTH_INT, 0, 0 }, { _COMPARE_OP_INT, 0, 0 } } }, + [COMPARE_OP_STR] = { .nuops = 2, .uops = { { _GUARD_BOTH_UNICODE, 0, 0 }, { _COMPARE_OP_STR, 0, 0 } } }, + [CONTAINS_OP] = { .nuops = 1, .uops = { { _CONTAINS_OP, 0, 0 } } }, + [CONTAINS_OP_DICT] = { .nuops = 1, .uops = { { _CONTAINS_OP_DICT, 0, 0 } } }, + [CONTAINS_OP_SET] = { .nuops = 1, .uops = { { _CONTAINS_OP_SET, 0, 0 } } }, + [CONVERT_VALUE] = { .nuops = 1, .uops = { { _CONVERT_VALUE, 0, 0 } } }, + [COPY] = { .nuops = 1, .uops = { { _COPY, 0, 0 } } }, + [COPY_FREE_VARS] = { .nuops = 1, .uops = { { _COPY_FREE_VARS, 0, 0 } } }, + [DELETE_ATTR] = { .nuops = 1, .uops = { { _DELETE_ATTR, 0, 0 } } }, + [DELETE_DEREF] = { .nuops = 1, .uops = { { _DELETE_DEREF, 0, 0 } } }, + [DELETE_FAST] = { .nuops = 1, .uops = { { _DELETE_FAST, 0, 0 } } }, + [DELETE_GLOBAL] = { .nuops = 1, .uops = { { _DELETE_GLOBAL, 0, 0 } } }, + [DELETE_NAME] = { .nuops = 1, .uops = { { _DELETE_NAME, 0, 0 } } }, + [DELETE_SUBSCR] = { .nuops = 1, .uops = { { _DELETE_SUBSCR, 0, 0 } } }, + [DICT_MERGE] = { .nuops = 1, .uops = { { _DICT_MERGE, 0, 0 } } }, + [DICT_UPDATE] = { .nuops = 1, .uops = { { _DICT_UPDATE, 0, 0 } } }, + [END_FOR] = { .nuops = 1, .uops = { { _POP_TOP, 0, 0 } } }, + [END_SEND] = { .nuops = 1, .uops = { { _END_SEND, 0, 0 } } }, + [EXIT_INIT_CHECK] = { .nuops = 1, .uops = { { _EXIT_INIT_CHECK, 0, 0 } } }, + [FORMAT_SIMPLE] = { .nuops = 1, .uops = { { _FORMAT_SIMPLE, 0, 0 } } }, + [FORMAT_WITH_SPEC] = { .nuops = 1, .uops = { { _FORMAT_WITH_SPEC, 0, 0 } } }, + [FOR_ITER] = { .nuops = 1, .uops = { { _FOR_ITER, 9, 0 } } }, + [FOR_ITER_GEN] = { .nuops = 3, .uops = { { _CHECK_PEP_523, 0, 0 }, { _FOR_ITER_GEN_FRAME, 0, 0 }, { _PUSH_FRAME, 0, 0 } } }, + [FOR_ITER_LIST] = { .nuops = 3, .uops = { { _ITER_CHECK_LIST, 0, 0 }, { _ITER_JUMP_LIST, 9, 1 }, { _ITER_NEXT_LIST, 0, 0 } } }, + [FOR_ITER_RANGE] = { .nuops = 3, .uops = { { _ITER_CHECK_RANGE, 0, 0 }, { _ITER_JUMP_RANGE, 9, 1 }, { _ITER_NEXT_RANGE, 0, 0 } } }, + [FOR_ITER_TUPLE] = { .nuops = 3, .uops = { { _ITER_CHECK_TUPLE, 0, 0 }, { _ITER_JUMP_TUPLE, 9, 1 }, { _ITER_NEXT_TUPLE, 0, 0 } } }, + [GET_AITER] = { .nuops = 1, .uops = { { _GET_AITER, 0, 0 } } }, + [GET_ANEXT] = { .nuops = 1, .uops = { { _GET_ANEXT, 0, 0 } } }, + [GET_AWAITABLE] = { .nuops = 1, .uops = { { _GET_AWAITABLE, 0, 0 } } }, + [GET_ITER] = { .nuops = 1, .uops = { { _GET_ITER, 0, 0 } } }, + [GET_LEN] = { .nuops = 1, .uops = { { _GET_LEN, 0, 0 } } }, + [GET_YIELD_FROM_ITER] = { .nuops = 1, .uops = { { _GET_YIELD_FROM_ITER, 0, 0 } } }, + [IS_OP] = { .nuops = 1, .uops = { { _IS_OP, 0, 0 } } }, + [LIST_APPEND] = { .nuops = 1, .uops = { { _LIST_APPEND, 0, 0 } } }, + [LIST_EXTEND] = { .nuops = 1, .uops = { { _LIST_EXTEND, 0, 0 } } }, + [LOAD_ASSERTION_ERROR] = { .nuops = 1, .uops = { { _LOAD_ASSERTION_ERROR, 0, 0 } } }, + [LOAD_ATTR] = { .nuops = 1, .uops = { { _LOAD_ATTR, 0, 0 } } }, + [LOAD_ATTR_CLASS] = { .nuops = 2, .uops = { { _CHECK_ATTR_CLASS, 2, 1 }, { _LOAD_ATTR_CLASS, 4, 5 } } }, + [LOAD_ATTR_INSTANCE_VALUE] = { .nuops = 3, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _CHECK_MANAGED_OBJECT_HAS_VALUES, 0, 0 }, { _LOAD_ATTR_INSTANCE_VALUE, 1, 3 } } }, + [LOAD_ATTR_METHOD_LAZY_DICT] = { .nuops = 3, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _CHECK_ATTR_METHOD_LAZY_DICT, 1, 3 }, { _LOAD_ATTR_METHOD_LAZY_DICT, 4, 5 } } }, + [LOAD_ATTR_METHOD_NO_DICT] = { .nuops = 2, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _LOAD_ATTR_METHOD_NO_DICT, 4, 5 } } }, + [LOAD_ATTR_METHOD_WITH_VALUES] = { .nuops = 4, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT, 0, 0 }, { _GUARD_KEYS_VERSION, 2, 3 }, { _LOAD_ATTR_METHOD_WITH_VALUES, 4, 5 } } }, + [LOAD_ATTR_MODULE] = { .nuops = 2, .uops = { { _CHECK_ATTR_MODULE, 2, 1 }, { _LOAD_ATTR_MODULE, 1, 3 } } }, + [LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = { .nuops = 2, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _LOAD_ATTR_NONDESCRIPTOR_NO_DICT, 4, 5 } } }, + [LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = { .nuops = 4, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT, 0, 0 }, { _GUARD_KEYS_VERSION, 2, 3 }, { _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES, 4, 5 } } }, + [LOAD_ATTR_SLOT] = { .nuops = 2, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _LOAD_ATTR_SLOT, 1, 3 } } }, + [LOAD_ATTR_WITH_HINT] = { .nuops = 3, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _CHECK_ATTR_WITH_HINT, 0, 0 }, { _LOAD_ATTR_WITH_HINT, 1, 3 } } }, + [LOAD_BUILD_CLASS] = { .nuops = 1, .uops = { { _LOAD_BUILD_CLASS, 0, 0 } } }, + [LOAD_CONST] = { .nuops = 1, .uops = { { _LOAD_CONST, 0, 0 } } }, + [LOAD_DEREF] = { .nuops = 1, .uops = { { _LOAD_DEREF, 0, 0 } } }, + [LOAD_FAST] = { .nuops = 1, .uops = { { _LOAD_FAST, 0, 0 } } }, + [LOAD_FAST_AND_CLEAR] = { .nuops = 1, .uops = { { _LOAD_FAST_AND_CLEAR, 0, 0 } } }, + [LOAD_FAST_CHECK] = { .nuops = 1, .uops = { { _LOAD_FAST_CHECK, 0, 0 } } }, + [LOAD_FAST_LOAD_FAST] = { .nuops = 2, .uops = { { _LOAD_FAST, 5, 0 }, { _LOAD_FAST, 6, 0 } } }, + [LOAD_FROM_DICT_OR_DEREF] = { .nuops = 1, .uops = { { _LOAD_FROM_DICT_OR_DEREF, 0, 0 } } }, + [LOAD_GLOBAL] = { .nuops = 1, .uops = { { _LOAD_GLOBAL, 0, 0 } } }, + [LOAD_GLOBAL_BUILTIN] = { .nuops = 3, .uops = { { _GUARD_GLOBALS_VERSION, 1, 1 }, { _GUARD_BUILTINS_VERSION, 1, 2 }, { _LOAD_GLOBAL_BUILTINS, 1, 3 } } }, + [LOAD_GLOBAL_MODULE] = { .nuops = 2, .uops = { { _GUARD_GLOBALS_VERSION, 1, 1 }, { _LOAD_GLOBAL_MODULE, 1, 3 } } }, + [LOAD_LOCALS] = { .nuops = 1, .uops = { { _LOAD_LOCALS, 0, 0 } } }, + [LOAD_SUPER_ATTR_ATTR] = { .nuops = 1, .uops = { { _LOAD_SUPER_ATTR_ATTR, 0, 0 } } }, + [LOAD_SUPER_ATTR_METHOD] = { .nuops = 1, .uops = { { _LOAD_SUPER_ATTR_METHOD, 0, 0 } } }, + [MAKE_CELL] = { .nuops = 1, .uops = { { _MAKE_CELL, 0, 0 } } }, + [MAKE_FUNCTION] = { .nuops = 1, .uops = { { _MAKE_FUNCTION, 0, 0 } } }, + [MAP_ADD] = { .nuops = 1, .uops = { { _MAP_ADD, 0, 0 } } }, + [MATCH_CLASS] = { .nuops = 1, .uops = { { _MATCH_CLASS, 0, 0 } } }, + [MATCH_KEYS] = { .nuops = 1, .uops = { { _MATCH_KEYS, 0, 0 } } }, + [MATCH_MAPPING] = { .nuops = 1, .uops = { { _MATCH_MAPPING, 0, 0 } } }, + [MATCH_SEQUENCE] = { .nuops = 1, .uops = { { _MATCH_SEQUENCE, 0, 0 } } }, + [NOP] = { .nuops = 1, .uops = { { _NOP, 0, 0 } } }, + [POP_EXCEPT] = { .nuops = 1, .uops = { { _POP_EXCEPT, 0, 0 } } }, + [POP_JUMP_IF_FALSE] = { .nuops = 1, .uops = { { _POP_JUMP_IF_FALSE, 9, 1 } } }, + [POP_JUMP_IF_NONE] = { .nuops = 2, .uops = { { _IS_NONE, 0, 0 }, { _POP_JUMP_IF_TRUE, 9, 1 } } }, + [POP_JUMP_IF_NOT_NONE] = { .nuops = 2, .uops = { { _IS_NONE, 0, 0 }, { _POP_JUMP_IF_FALSE, 9, 1 } } }, + [POP_JUMP_IF_TRUE] = { .nuops = 1, .uops = { { _POP_JUMP_IF_TRUE, 9, 1 } } }, + [POP_TOP] = { .nuops = 1, .uops = { { _POP_TOP, 0, 0 } } }, + [PUSH_EXC_INFO] = { .nuops = 1, .uops = { { _PUSH_EXC_INFO, 0, 0 } } }, + [PUSH_NULL] = { .nuops = 1, .uops = { { _PUSH_NULL, 0, 0 } } }, + [RESUME_CHECK] = { .nuops = 1, .uops = { { _RESUME_CHECK, 0, 0 } } }, + [RETURN_CONST] = { .nuops = 2, .uops = { { _LOAD_CONST, 0, 0 }, { _POP_FRAME, 0, 0 } } }, + [RETURN_GENERATOR] = { .nuops = 1, .uops = { { _RETURN_GENERATOR, 0, 0 } } }, + [RETURN_VALUE] = { .nuops = 1, .uops = { { _POP_FRAME, 0, 0 } } }, + [SETUP_ANNOTATIONS] = { .nuops = 1, .uops = { { _SETUP_ANNOTATIONS, 0, 0 } } }, + [SET_ADD] = { .nuops = 1, .uops = { { _SET_ADD, 0, 0 } } }, + [SET_FUNCTION_ATTRIBUTE] = { .nuops = 1, .uops = { { _SET_FUNCTION_ATTRIBUTE, 0, 0 } } }, + [SET_UPDATE] = { .nuops = 1, .uops = { { _SET_UPDATE, 0, 0 } } }, + [STORE_ATTR] = { .nuops = 1, .uops = { { _STORE_ATTR, 0, 0 } } }, + [STORE_ATTR_INSTANCE_VALUE] = { .nuops = 3, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _GUARD_DORV_NO_DICT, 0, 0 }, { _STORE_ATTR_INSTANCE_VALUE, 1, 3 } } }, + [STORE_ATTR_SLOT] = { .nuops = 2, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _STORE_ATTR_SLOT, 1, 3 } } }, + [STORE_DEREF] = { .nuops = 1, .uops = { { _STORE_DEREF, 0, 0 } } }, + [STORE_FAST] = { .nuops = 1, .uops = { { _STORE_FAST, 0, 0 } } }, + [STORE_FAST_LOAD_FAST] = { .nuops = 2, .uops = { { _STORE_FAST, 5, 0 }, { _LOAD_FAST, 6, 0 } } }, + [STORE_FAST_STORE_FAST] = { .nuops = 2, .uops = { { _STORE_FAST, 5, 0 }, { _STORE_FAST, 6, 0 } } }, + [STORE_GLOBAL] = { .nuops = 1, .uops = { { _STORE_GLOBAL, 0, 0 } } }, + [STORE_NAME] = { .nuops = 1, .uops = { { _STORE_NAME, 0, 0 } } }, + [STORE_SLICE] = { .nuops = 1, .uops = { { _STORE_SLICE, 0, 0 } } }, + [STORE_SUBSCR] = { .nuops = 1, .uops = { { _STORE_SUBSCR, 0, 0 } } }, + [STORE_SUBSCR_DICT] = { .nuops = 1, .uops = { { _STORE_SUBSCR_DICT, 0, 0 } } }, + [STORE_SUBSCR_LIST_INT] = { .nuops = 1, .uops = { { _STORE_SUBSCR_LIST_INT, 0, 0 } } }, + [SWAP] = { .nuops = 1, .uops = { { _SWAP, 0, 0 } } }, + [TO_BOOL] = { .nuops = 1, .uops = { { _TO_BOOL, 0, 0 } } }, + [TO_BOOL_ALWAYS_TRUE] = { .nuops = 2, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _REPLACE_WITH_TRUE, 0, 0 } } }, + [TO_BOOL_BOOL] = { .nuops = 1, .uops = { { _TO_BOOL_BOOL, 0, 0 } } }, + [TO_BOOL_INT] = { .nuops = 1, .uops = { { _TO_BOOL_INT, 0, 0 } } }, + [TO_BOOL_LIST] = { .nuops = 1, .uops = { { _TO_BOOL_LIST, 0, 0 } } }, + [TO_BOOL_NONE] = { .nuops = 1, .uops = { { _TO_BOOL_NONE, 0, 0 } } }, + [TO_BOOL_STR] = { .nuops = 1, .uops = { { _TO_BOOL_STR, 0, 0 } } }, + [UNARY_INVERT] = { .nuops = 1, .uops = { { _UNARY_INVERT, 0, 0 } } }, + [UNARY_NEGATIVE] = { .nuops = 1, .uops = { { _UNARY_NEGATIVE, 0, 0 } } }, + [UNARY_NOT] = { .nuops = 1, .uops = { { _UNARY_NOT, 0, 0 } } }, + [UNPACK_EX] = { .nuops = 1, .uops = { { _UNPACK_EX, 0, 0 } } }, + [UNPACK_SEQUENCE] = { .nuops = 1, .uops = { { _UNPACK_SEQUENCE, 0, 0 } } }, + [UNPACK_SEQUENCE_LIST] = { .nuops = 1, .uops = { { _UNPACK_SEQUENCE_LIST, 0, 0 } } }, + [UNPACK_SEQUENCE_TUPLE] = { .nuops = 1, .uops = { { _UNPACK_SEQUENCE_TUPLE, 0, 0 } } }, + [UNPACK_SEQUENCE_TWO_TUPLE] = { .nuops = 1, .uops = { { _UNPACK_SEQUENCE_TWO_TUPLE, 0, 0 } } }, + [WITH_EXCEPT_START] = { .nuops = 1, .uops = { { _WITH_EXCEPT_START, 0, 0 } } }, + [YIELD_VALUE] = { .nuops = 1, .uops = { { _YIELD_VALUE, 0, 0 } } }, +}; +#endif // NEED_OPCODE_METADATA + +extern const char *_PyOpcode_OpName[268]; +#ifdef NEED_OPCODE_METADATA +const char *_PyOpcode_OpName[268] = { + [BEFORE_ASYNC_WITH] = "BEFORE_ASYNC_WITH", + [BEFORE_WITH] = "BEFORE_WITH", + [BINARY_OP] = "BINARY_OP", + [BINARY_OP_ADD_FLOAT] = "BINARY_OP_ADD_FLOAT", + [BINARY_OP_ADD_INT] = "BINARY_OP_ADD_INT", + [BINARY_OP_ADD_UNICODE] = "BINARY_OP_ADD_UNICODE", + [BINARY_OP_INPLACE_ADD_UNICODE] = "BINARY_OP_INPLACE_ADD_UNICODE", + [BINARY_OP_MULTIPLY_FLOAT] = "BINARY_OP_MULTIPLY_FLOAT", + [BINARY_OP_MULTIPLY_INT] = "BINARY_OP_MULTIPLY_INT", + [BINARY_OP_SUBTRACT_FLOAT] = "BINARY_OP_SUBTRACT_FLOAT", + [BINARY_OP_SUBTRACT_INT] = "BINARY_OP_SUBTRACT_INT", + [BINARY_SLICE] = "BINARY_SLICE", + [BINARY_SUBSCR] = "BINARY_SUBSCR", + [BINARY_SUBSCR_DICT] = "BINARY_SUBSCR_DICT", + [BINARY_SUBSCR_GETITEM] = "BINARY_SUBSCR_GETITEM", + [BINARY_SUBSCR_LIST_INT] = "BINARY_SUBSCR_LIST_INT", + [BINARY_SUBSCR_STR_INT] = "BINARY_SUBSCR_STR_INT", + [BINARY_SUBSCR_TUPLE_INT] = "BINARY_SUBSCR_TUPLE_INT", + [BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP", + [BUILD_LIST] = "BUILD_LIST", + [BUILD_MAP] = "BUILD_MAP", + [BUILD_SET] = "BUILD_SET", + [BUILD_SLICE] = "BUILD_SLICE", + [BUILD_STRING] = "BUILD_STRING", + [BUILD_TUPLE] = "BUILD_TUPLE", + [CACHE] = "CACHE", + [CALL] = "CALL", + [CALL_ALLOC_AND_ENTER_INIT] = "CALL_ALLOC_AND_ENTER_INIT", + [CALL_BOUND_METHOD_EXACT_ARGS] = "CALL_BOUND_METHOD_EXACT_ARGS", + [CALL_BOUND_METHOD_GENERAL] = "CALL_BOUND_METHOD_GENERAL", + [CALL_BUILTIN_CLASS] = "CALL_BUILTIN_CLASS", + [CALL_BUILTIN_FAST] = "CALL_BUILTIN_FAST", + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = "CALL_BUILTIN_FAST_WITH_KEYWORDS", + [CALL_BUILTIN_O] = "CALL_BUILTIN_O", + [CALL_FUNCTION_EX] = "CALL_FUNCTION_EX", + [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", + [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", + [CALL_ISINSTANCE] = "CALL_ISINSTANCE", + [CALL_KW] = "CALL_KW", + [CALL_LEN] = "CALL_LEN", + [CALL_LIST_APPEND] = "CALL_LIST_APPEND", + [CALL_METHOD_DESCRIPTOR_FAST] = "CALL_METHOD_DESCRIPTOR_FAST", + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", + [CALL_METHOD_DESCRIPTOR_NOARGS] = "CALL_METHOD_DESCRIPTOR_NOARGS", + [CALL_METHOD_DESCRIPTOR_O] = "CALL_METHOD_DESCRIPTOR_O", + [CALL_NON_PY_GENERAL] = "CALL_NON_PY_GENERAL", + [CALL_PY_EXACT_ARGS] = "CALL_PY_EXACT_ARGS", + [CALL_PY_GENERAL] = "CALL_PY_GENERAL", + [CALL_STR_1] = "CALL_STR_1", + [CALL_TUPLE_1] = "CALL_TUPLE_1", + [CALL_TYPE_1] = "CALL_TYPE_1", + [CHECK_EG_MATCH] = "CHECK_EG_MATCH", + [CHECK_EXC_MATCH] = "CHECK_EXC_MATCH", + [CLEANUP_THROW] = "CLEANUP_THROW", + [COMPARE_OP] = "COMPARE_OP", + [COMPARE_OP_FLOAT] = "COMPARE_OP_FLOAT", + [COMPARE_OP_INT] = "COMPARE_OP_INT", + [COMPARE_OP_STR] = "COMPARE_OP_STR", + [CONTAINS_OP] = "CONTAINS_OP", + [CONTAINS_OP_DICT] = "CONTAINS_OP_DICT", + [CONTAINS_OP_SET] = "CONTAINS_OP_SET", + [CONVERT_VALUE] = "CONVERT_VALUE", + [COPY] = "COPY", + [COPY_FREE_VARS] = "COPY_FREE_VARS", + [DELETE_ATTR] = "DELETE_ATTR", + [DELETE_DEREF] = "DELETE_DEREF", + [DELETE_FAST] = "DELETE_FAST", + [DELETE_GLOBAL] = "DELETE_GLOBAL", + [DELETE_NAME] = "DELETE_NAME", + [DELETE_SUBSCR] = "DELETE_SUBSCR", + [DICT_MERGE] = "DICT_MERGE", + [DICT_UPDATE] = "DICT_UPDATE", + [END_ASYNC_FOR] = "END_ASYNC_FOR", + [END_FOR] = "END_FOR", + [END_SEND] = "END_SEND", + [ENTER_EXECUTOR] = "ENTER_EXECUTOR", + [EXIT_INIT_CHECK] = "EXIT_INIT_CHECK", + [EXTENDED_ARG] = "EXTENDED_ARG", + [FORMAT_SIMPLE] = "FORMAT_SIMPLE", + [FORMAT_WITH_SPEC] = "FORMAT_WITH_SPEC", + [FOR_ITER] = "FOR_ITER", + [FOR_ITER_GEN] = "FOR_ITER_GEN", + [FOR_ITER_LIST] = "FOR_ITER_LIST", + [FOR_ITER_RANGE] = "FOR_ITER_RANGE", + [FOR_ITER_TUPLE] = "FOR_ITER_TUPLE", + [GET_AITER] = "GET_AITER", + [GET_ANEXT] = "GET_ANEXT", + [GET_AWAITABLE] = "GET_AWAITABLE", + [GET_ITER] = "GET_ITER", + [GET_LEN] = "GET_LEN", + [GET_YIELD_FROM_ITER] = "GET_YIELD_FROM_ITER", + [IMPORT_FROM] = "IMPORT_FROM", + [IMPORT_NAME] = "IMPORT_NAME", + [INSTRUMENTED_CALL] = "INSTRUMENTED_CALL", + [INSTRUMENTED_CALL_FUNCTION_EX] = "INSTRUMENTED_CALL_FUNCTION_EX", + [INSTRUMENTED_CALL_KW] = "INSTRUMENTED_CALL_KW", + [INSTRUMENTED_END_FOR] = "INSTRUMENTED_END_FOR", + [INSTRUMENTED_END_SEND] = "INSTRUMENTED_END_SEND", + [INSTRUMENTED_FOR_ITER] = "INSTRUMENTED_FOR_ITER", + [INSTRUMENTED_INSTRUCTION] = "INSTRUMENTED_INSTRUCTION", + [INSTRUMENTED_JUMP_BACKWARD] = "INSTRUMENTED_JUMP_BACKWARD", + [INSTRUMENTED_JUMP_FORWARD] = "INSTRUMENTED_JUMP_FORWARD", + [INSTRUMENTED_LINE] = "INSTRUMENTED_LINE", + [INSTRUMENTED_LOAD_SUPER_ATTR] = "INSTRUMENTED_LOAD_SUPER_ATTR", + [INSTRUMENTED_POP_JUMP_IF_FALSE] = "INSTRUMENTED_POP_JUMP_IF_FALSE", + [INSTRUMENTED_POP_JUMP_IF_NONE] = "INSTRUMENTED_POP_JUMP_IF_NONE", + [INSTRUMENTED_POP_JUMP_IF_NOT_NONE] = "INSTRUMENTED_POP_JUMP_IF_NOT_NONE", + [INSTRUMENTED_POP_JUMP_IF_TRUE] = "INSTRUMENTED_POP_JUMP_IF_TRUE", + [INSTRUMENTED_RESUME] = "INSTRUMENTED_RESUME", + [INSTRUMENTED_RETURN_CONST] = "INSTRUMENTED_RETURN_CONST", + [INSTRUMENTED_RETURN_VALUE] = "INSTRUMENTED_RETURN_VALUE", + [INSTRUMENTED_YIELD_VALUE] = "INSTRUMENTED_YIELD_VALUE", + [INTERPRETER_EXIT] = "INTERPRETER_EXIT", + [IS_OP] = "IS_OP", + [JUMP] = "JUMP", + [JUMP_BACKWARD] = "JUMP_BACKWARD", + [JUMP_BACKWARD_NO_INTERRUPT] = "JUMP_BACKWARD_NO_INTERRUPT", + [JUMP_FORWARD] = "JUMP_FORWARD", + [JUMP_NO_INTERRUPT] = "JUMP_NO_INTERRUPT", + [LIST_APPEND] = "LIST_APPEND", + [LIST_EXTEND] = "LIST_EXTEND", + [LOAD_ASSERTION_ERROR] = "LOAD_ASSERTION_ERROR", + [LOAD_ATTR] = "LOAD_ATTR", + [LOAD_ATTR_CLASS] = "LOAD_ATTR_CLASS", + [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = "LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN", + [LOAD_ATTR_INSTANCE_VALUE] = "LOAD_ATTR_INSTANCE_VALUE", + [LOAD_ATTR_METHOD_LAZY_DICT] = "LOAD_ATTR_METHOD_LAZY_DICT", + [LOAD_ATTR_METHOD_NO_DICT] = "LOAD_ATTR_METHOD_NO_DICT", + [LOAD_ATTR_METHOD_WITH_VALUES] = "LOAD_ATTR_METHOD_WITH_VALUES", + [LOAD_ATTR_MODULE] = "LOAD_ATTR_MODULE", + [LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = "LOAD_ATTR_NONDESCRIPTOR_NO_DICT", + [LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = "LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES", + [LOAD_ATTR_PROPERTY] = "LOAD_ATTR_PROPERTY", + [LOAD_ATTR_SLOT] = "LOAD_ATTR_SLOT", + [LOAD_ATTR_WITH_HINT] = "LOAD_ATTR_WITH_HINT", + [LOAD_BUILD_CLASS] = "LOAD_BUILD_CLASS", + [LOAD_CLOSURE] = "LOAD_CLOSURE", + [LOAD_CONST] = "LOAD_CONST", + [LOAD_DEREF] = "LOAD_DEREF", + [LOAD_FAST] = "LOAD_FAST", + [LOAD_FAST_AND_CLEAR] = "LOAD_FAST_AND_CLEAR", + [LOAD_FAST_CHECK] = "LOAD_FAST_CHECK", + [LOAD_FAST_LOAD_FAST] = "LOAD_FAST_LOAD_FAST", + [LOAD_FROM_DICT_OR_DEREF] = "LOAD_FROM_DICT_OR_DEREF", + [LOAD_FROM_DICT_OR_GLOBALS] = "LOAD_FROM_DICT_OR_GLOBALS", + [LOAD_GLOBAL] = "LOAD_GLOBAL", + [LOAD_GLOBAL_BUILTIN] = "LOAD_GLOBAL_BUILTIN", + [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE", + [LOAD_LOCALS] = "LOAD_LOCALS", + [LOAD_METHOD] = "LOAD_METHOD", + [LOAD_NAME] = "LOAD_NAME", + [LOAD_SUPER_ATTR] = "LOAD_SUPER_ATTR", + [LOAD_SUPER_ATTR_ATTR] = "LOAD_SUPER_ATTR_ATTR", + [LOAD_SUPER_ATTR_METHOD] = "LOAD_SUPER_ATTR_METHOD", + [LOAD_SUPER_METHOD] = "LOAD_SUPER_METHOD", + [LOAD_ZERO_SUPER_ATTR] = "LOAD_ZERO_SUPER_ATTR", + [LOAD_ZERO_SUPER_METHOD] = "LOAD_ZERO_SUPER_METHOD", + [MAKE_CELL] = "MAKE_CELL", + [MAKE_FUNCTION] = "MAKE_FUNCTION", + [MAP_ADD] = "MAP_ADD", + [MATCH_CLASS] = "MATCH_CLASS", + [MATCH_KEYS] = "MATCH_KEYS", + [MATCH_MAPPING] = "MATCH_MAPPING", + [MATCH_SEQUENCE] = "MATCH_SEQUENCE", + [NOP] = "NOP", + [POP_BLOCK] = "POP_BLOCK", + [POP_EXCEPT] = "POP_EXCEPT", + [POP_JUMP_IF_FALSE] = "POP_JUMP_IF_FALSE", + [POP_JUMP_IF_NONE] = "POP_JUMP_IF_NONE", + [POP_JUMP_IF_NOT_NONE] = "POP_JUMP_IF_NOT_NONE", + [POP_JUMP_IF_TRUE] = "POP_JUMP_IF_TRUE", + [POP_TOP] = "POP_TOP", + [PUSH_EXC_INFO] = "PUSH_EXC_INFO", + [PUSH_NULL] = "PUSH_NULL", + [RAISE_VARARGS] = "RAISE_VARARGS", + [RERAISE] = "RERAISE", + [RESERVED] = "RESERVED", + [RESUME] = "RESUME", + [RESUME_CHECK] = "RESUME_CHECK", + [RETURN_CONST] = "RETURN_CONST", + [RETURN_GENERATOR] = "RETURN_GENERATOR", + [RETURN_VALUE] = "RETURN_VALUE", + [SEND] = "SEND", + [SEND_GEN] = "SEND_GEN", + [SETUP_ANNOTATIONS] = "SETUP_ANNOTATIONS", + [SETUP_CLEANUP] = "SETUP_CLEANUP", + [SETUP_FINALLY] = "SETUP_FINALLY", + [SETUP_WITH] = "SETUP_WITH", + [SET_ADD] = "SET_ADD", + [SET_FUNCTION_ATTRIBUTE] = "SET_FUNCTION_ATTRIBUTE", + [SET_UPDATE] = "SET_UPDATE", + [STORE_ATTR] = "STORE_ATTR", + [STORE_ATTR_INSTANCE_VALUE] = "STORE_ATTR_INSTANCE_VALUE", + [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT", + [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", + [STORE_DEREF] = "STORE_DEREF", + [STORE_FAST] = "STORE_FAST", + [STORE_FAST_LOAD_FAST] = "STORE_FAST_LOAD_FAST", + [STORE_FAST_MAYBE_NULL] = "STORE_FAST_MAYBE_NULL", + [STORE_FAST_STORE_FAST] = "STORE_FAST_STORE_FAST", + [STORE_GLOBAL] = "STORE_GLOBAL", + [STORE_NAME] = "STORE_NAME", + [STORE_SLICE] = "STORE_SLICE", + [STORE_SUBSCR] = "STORE_SUBSCR", + [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", + [STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT", + [SWAP] = "SWAP", + [TO_BOOL] = "TO_BOOL", + [TO_BOOL_ALWAYS_TRUE] = "TO_BOOL_ALWAYS_TRUE", + [TO_BOOL_BOOL] = "TO_BOOL_BOOL", + [TO_BOOL_INT] = "TO_BOOL_INT", + [TO_BOOL_LIST] = "TO_BOOL_LIST", + [TO_BOOL_NONE] = "TO_BOOL_NONE", + [TO_BOOL_STR] = "TO_BOOL_STR", + [UNARY_INVERT] = "UNARY_INVERT", + [UNARY_NEGATIVE] = "UNARY_NEGATIVE", + [UNARY_NOT] = "UNARY_NOT", + [UNPACK_EX] = "UNPACK_EX", + [UNPACK_SEQUENCE] = "UNPACK_SEQUENCE", + [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", + [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE", + [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", + [WITH_EXCEPT_START] = "WITH_EXCEPT_START", + [YIELD_VALUE] = "YIELD_VALUE", +}; +#endif + +extern const uint8_t _PyOpcode_Caches[256]; +#ifdef NEED_OPCODE_METADATA +const uint8_t _PyOpcode_Caches[256] = { + [JUMP_BACKWARD] = 1, + [TO_BOOL] = 3, + [BINARY_SUBSCR] = 1, + [STORE_SUBSCR] = 1, + [SEND] = 1, + [UNPACK_SEQUENCE] = 1, + [STORE_ATTR] = 4, + [LOAD_GLOBAL] = 4, + [LOAD_SUPER_ATTR] = 1, + [LOAD_ATTR] = 9, + [COMPARE_OP] = 1, + [CONTAINS_OP] = 1, + [POP_JUMP_IF_TRUE] = 1, + [POP_JUMP_IF_FALSE] = 1, + [POP_JUMP_IF_NONE] = 1, + [POP_JUMP_IF_NOT_NONE] = 1, + [FOR_ITER] = 1, + [CALL] = 3, + [BINARY_OP] = 1, +}; +#endif + +extern const uint8_t _PyOpcode_Deopt[256]; +#ifdef NEED_OPCODE_METADATA +const uint8_t _PyOpcode_Deopt[256] = { + [BEFORE_ASYNC_WITH] = BEFORE_ASYNC_WITH, + [BEFORE_WITH] = BEFORE_WITH, + [BINARY_OP] = BINARY_OP, + [BINARY_OP_ADD_FLOAT] = BINARY_OP, + [BINARY_OP_ADD_INT] = BINARY_OP, + [BINARY_OP_ADD_UNICODE] = BINARY_OP, + [BINARY_OP_INPLACE_ADD_UNICODE] = BINARY_OP, + [BINARY_OP_MULTIPLY_FLOAT] = BINARY_OP, + [BINARY_OP_MULTIPLY_INT] = BINARY_OP, + [BINARY_OP_SUBTRACT_FLOAT] = BINARY_OP, + [BINARY_OP_SUBTRACT_INT] = BINARY_OP, + [BINARY_SLICE] = BINARY_SLICE, + [BINARY_SUBSCR] = BINARY_SUBSCR, + [BINARY_SUBSCR_DICT] = BINARY_SUBSCR, + [BINARY_SUBSCR_GETITEM] = BINARY_SUBSCR, + [BINARY_SUBSCR_LIST_INT] = BINARY_SUBSCR, + [BINARY_SUBSCR_STR_INT] = BINARY_SUBSCR, + [BINARY_SUBSCR_TUPLE_INT] = BINARY_SUBSCR, + [BUILD_CONST_KEY_MAP] = BUILD_CONST_KEY_MAP, + [BUILD_LIST] = BUILD_LIST, + [BUILD_MAP] = BUILD_MAP, + [BUILD_SET] = BUILD_SET, + [BUILD_SLICE] = BUILD_SLICE, + [BUILD_STRING] = BUILD_STRING, + [BUILD_TUPLE] = BUILD_TUPLE, + [CACHE] = CACHE, + [CALL] = CALL, + [CALL_ALLOC_AND_ENTER_INIT] = CALL, + [CALL_BOUND_METHOD_EXACT_ARGS] = CALL, + [CALL_BOUND_METHOD_GENERAL] = CALL, + [CALL_BUILTIN_CLASS] = CALL, + [CALL_BUILTIN_FAST] = CALL, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = CALL, + [CALL_BUILTIN_O] = CALL, + [CALL_FUNCTION_EX] = CALL_FUNCTION_EX, + [CALL_INTRINSIC_1] = CALL_INTRINSIC_1, + [CALL_INTRINSIC_2] = CALL_INTRINSIC_2, + [CALL_ISINSTANCE] = CALL, + [CALL_KW] = CALL_KW, + [CALL_LEN] = CALL, + [CALL_LIST_APPEND] = CALL, + [CALL_METHOD_DESCRIPTOR_FAST] = CALL, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL, + [CALL_METHOD_DESCRIPTOR_NOARGS] = CALL, + [CALL_METHOD_DESCRIPTOR_O] = CALL, + [CALL_NON_PY_GENERAL] = CALL, + [CALL_PY_EXACT_ARGS] = CALL, + [CALL_PY_GENERAL] = CALL, + [CALL_STR_1] = CALL, + [CALL_TUPLE_1] = CALL, + [CALL_TYPE_1] = CALL, + [CHECK_EG_MATCH] = CHECK_EG_MATCH, + [CHECK_EXC_MATCH] = CHECK_EXC_MATCH, + [CLEANUP_THROW] = CLEANUP_THROW, + [COMPARE_OP] = COMPARE_OP, + [COMPARE_OP_FLOAT] = COMPARE_OP, + [COMPARE_OP_INT] = COMPARE_OP, + [COMPARE_OP_STR] = COMPARE_OP, + [CONTAINS_OP] = CONTAINS_OP, + [CONTAINS_OP_DICT] = CONTAINS_OP, + [CONTAINS_OP_SET] = CONTAINS_OP, + [CONVERT_VALUE] = CONVERT_VALUE, + [COPY] = COPY, + [COPY_FREE_VARS] = COPY_FREE_VARS, + [DELETE_ATTR] = DELETE_ATTR, + [DELETE_DEREF] = DELETE_DEREF, + [DELETE_FAST] = DELETE_FAST, + [DELETE_GLOBAL] = DELETE_GLOBAL, + [DELETE_NAME] = DELETE_NAME, + [DELETE_SUBSCR] = DELETE_SUBSCR, + [DICT_MERGE] = DICT_MERGE, + [DICT_UPDATE] = DICT_UPDATE, + [END_ASYNC_FOR] = END_ASYNC_FOR, + [END_FOR] = END_FOR, + [END_SEND] = END_SEND, + [ENTER_EXECUTOR] = ENTER_EXECUTOR, + [EXIT_INIT_CHECK] = EXIT_INIT_CHECK, + [EXTENDED_ARG] = EXTENDED_ARG, + [FORMAT_SIMPLE] = FORMAT_SIMPLE, + [FORMAT_WITH_SPEC] = FORMAT_WITH_SPEC, + [FOR_ITER] = FOR_ITER, + [FOR_ITER_GEN] = FOR_ITER, + [FOR_ITER_LIST] = FOR_ITER, + [FOR_ITER_RANGE] = FOR_ITER, + [FOR_ITER_TUPLE] = FOR_ITER, + [GET_AITER] = GET_AITER, + [GET_ANEXT] = GET_ANEXT, + [GET_AWAITABLE] = GET_AWAITABLE, + [GET_ITER] = GET_ITER, + [GET_LEN] = GET_LEN, + [GET_YIELD_FROM_ITER] = GET_YIELD_FROM_ITER, + [IMPORT_FROM] = IMPORT_FROM, + [IMPORT_NAME] = IMPORT_NAME, + [INSTRUMENTED_CALL] = INSTRUMENTED_CALL, + [INSTRUMENTED_CALL_FUNCTION_EX] = INSTRUMENTED_CALL_FUNCTION_EX, + [INSTRUMENTED_CALL_KW] = INSTRUMENTED_CALL_KW, + [INSTRUMENTED_END_FOR] = INSTRUMENTED_END_FOR, + [INSTRUMENTED_END_SEND] = INSTRUMENTED_END_SEND, + [INSTRUMENTED_FOR_ITER] = INSTRUMENTED_FOR_ITER, + [INSTRUMENTED_INSTRUCTION] = INSTRUMENTED_INSTRUCTION, + [INSTRUMENTED_JUMP_BACKWARD] = INSTRUMENTED_JUMP_BACKWARD, + [INSTRUMENTED_JUMP_FORWARD] = INSTRUMENTED_JUMP_FORWARD, + [INSTRUMENTED_LINE] = INSTRUMENTED_LINE, + [INSTRUMENTED_LOAD_SUPER_ATTR] = INSTRUMENTED_LOAD_SUPER_ATTR, + [INSTRUMENTED_POP_JUMP_IF_FALSE] = INSTRUMENTED_POP_JUMP_IF_FALSE, + [INSTRUMENTED_POP_JUMP_IF_NONE] = INSTRUMENTED_POP_JUMP_IF_NONE, + [INSTRUMENTED_POP_JUMP_IF_NOT_NONE] = INSTRUMENTED_POP_JUMP_IF_NOT_NONE, + [INSTRUMENTED_POP_JUMP_IF_TRUE] = INSTRUMENTED_POP_JUMP_IF_TRUE, + [INSTRUMENTED_RESUME] = INSTRUMENTED_RESUME, + [INSTRUMENTED_RETURN_CONST] = INSTRUMENTED_RETURN_CONST, + [INSTRUMENTED_RETURN_VALUE] = INSTRUMENTED_RETURN_VALUE, + [INSTRUMENTED_YIELD_VALUE] = INSTRUMENTED_YIELD_VALUE, + [INTERPRETER_EXIT] = INTERPRETER_EXIT, + [IS_OP] = IS_OP, + [JUMP_BACKWARD] = JUMP_BACKWARD, + [JUMP_BACKWARD_NO_INTERRUPT] = JUMP_BACKWARD_NO_INTERRUPT, + [JUMP_FORWARD] = JUMP_FORWARD, + [LIST_APPEND] = LIST_APPEND, + [LIST_EXTEND] = LIST_EXTEND, + [LOAD_ASSERTION_ERROR] = LOAD_ASSERTION_ERROR, + [LOAD_ATTR] = LOAD_ATTR, + [LOAD_ATTR_CLASS] = LOAD_ATTR, + [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = LOAD_ATTR, + [LOAD_ATTR_INSTANCE_VALUE] = LOAD_ATTR, + [LOAD_ATTR_METHOD_LAZY_DICT] = LOAD_ATTR, + [LOAD_ATTR_METHOD_NO_DICT] = LOAD_ATTR, + [LOAD_ATTR_METHOD_WITH_VALUES] = LOAD_ATTR, + [LOAD_ATTR_MODULE] = LOAD_ATTR, + [LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = LOAD_ATTR, + [LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = LOAD_ATTR, + [LOAD_ATTR_PROPERTY] = LOAD_ATTR, + [LOAD_ATTR_SLOT] = LOAD_ATTR, + [LOAD_ATTR_WITH_HINT] = LOAD_ATTR, + [LOAD_BUILD_CLASS] = LOAD_BUILD_CLASS, + [LOAD_CONST] = LOAD_CONST, + [LOAD_DEREF] = LOAD_DEREF, + [LOAD_FAST] = LOAD_FAST, + [LOAD_FAST_AND_CLEAR] = LOAD_FAST_AND_CLEAR, + [LOAD_FAST_CHECK] = LOAD_FAST_CHECK, + [LOAD_FAST_LOAD_FAST] = LOAD_FAST_LOAD_FAST, + [LOAD_FROM_DICT_OR_DEREF] = LOAD_FROM_DICT_OR_DEREF, + [LOAD_FROM_DICT_OR_GLOBALS] = LOAD_FROM_DICT_OR_GLOBALS, + [LOAD_GLOBAL] = LOAD_GLOBAL, + [LOAD_GLOBAL_BUILTIN] = LOAD_GLOBAL, + [LOAD_GLOBAL_MODULE] = LOAD_GLOBAL, + [LOAD_LOCALS] = LOAD_LOCALS, + [LOAD_NAME] = LOAD_NAME, + [LOAD_SUPER_ATTR] = LOAD_SUPER_ATTR, + [LOAD_SUPER_ATTR_ATTR] = LOAD_SUPER_ATTR, + [LOAD_SUPER_ATTR_METHOD] = LOAD_SUPER_ATTR, + [MAKE_CELL] = MAKE_CELL, + [MAKE_FUNCTION] = MAKE_FUNCTION, + [MAP_ADD] = MAP_ADD, + [MATCH_CLASS] = MATCH_CLASS, + [MATCH_KEYS] = MATCH_KEYS, + [MATCH_MAPPING] = MATCH_MAPPING, + [MATCH_SEQUENCE] = MATCH_SEQUENCE, + [NOP] = NOP, + [POP_EXCEPT] = POP_EXCEPT, + [POP_JUMP_IF_FALSE] = POP_JUMP_IF_FALSE, + [POP_JUMP_IF_NONE] = POP_JUMP_IF_NONE, + [POP_JUMP_IF_NOT_NONE] = POP_JUMP_IF_NOT_NONE, + [POP_JUMP_IF_TRUE] = POP_JUMP_IF_TRUE, + [POP_TOP] = POP_TOP, + [PUSH_EXC_INFO] = PUSH_EXC_INFO, + [PUSH_NULL] = PUSH_NULL, + [RAISE_VARARGS] = RAISE_VARARGS, + [RERAISE] = RERAISE, + [RESERVED] = RESERVED, + [RESUME] = RESUME, + [RESUME_CHECK] = RESUME, + [RETURN_CONST] = RETURN_CONST, + [RETURN_GENERATOR] = RETURN_GENERATOR, + [RETURN_VALUE] = RETURN_VALUE, + [SEND] = SEND, + [SEND_GEN] = SEND, + [SETUP_ANNOTATIONS] = SETUP_ANNOTATIONS, + [SET_ADD] = SET_ADD, + [SET_FUNCTION_ATTRIBUTE] = SET_FUNCTION_ATTRIBUTE, + [SET_UPDATE] = SET_UPDATE, + [STORE_ATTR] = STORE_ATTR, + [STORE_ATTR_INSTANCE_VALUE] = STORE_ATTR, + [STORE_ATTR_SLOT] = STORE_ATTR, + [STORE_ATTR_WITH_HINT] = STORE_ATTR, + [STORE_DEREF] = STORE_DEREF, + [STORE_FAST] = STORE_FAST, + [STORE_FAST_LOAD_FAST] = STORE_FAST_LOAD_FAST, + [STORE_FAST_STORE_FAST] = STORE_FAST_STORE_FAST, + [STORE_GLOBAL] = STORE_GLOBAL, + [STORE_NAME] = STORE_NAME, + [STORE_SLICE] = STORE_SLICE, + [STORE_SUBSCR] = STORE_SUBSCR, + [STORE_SUBSCR_DICT] = STORE_SUBSCR, + [STORE_SUBSCR_LIST_INT] = STORE_SUBSCR, + [SWAP] = SWAP, + [TO_BOOL] = TO_BOOL, + [TO_BOOL_ALWAYS_TRUE] = TO_BOOL, + [TO_BOOL_BOOL] = TO_BOOL, + [TO_BOOL_INT] = TO_BOOL, + [TO_BOOL_LIST] = TO_BOOL, + [TO_BOOL_NONE] = TO_BOOL, + [TO_BOOL_STR] = TO_BOOL, + [UNARY_INVERT] = UNARY_INVERT, + [UNARY_NEGATIVE] = UNARY_NEGATIVE, + [UNARY_NOT] = UNARY_NOT, + [UNPACK_EX] = UNPACK_EX, + [UNPACK_SEQUENCE] = UNPACK_SEQUENCE, + [UNPACK_SEQUENCE_LIST] = UNPACK_SEQUENCE, + [UNPACK_SEQUENCE_TUPLE] = UNPACK_SEQUENCE, + [UNPACK_SEQUENCE_TWO_TUPLE] = UNPACK_SEQUENCE, + [WITH_EXCEPT_START] = WITH_EXCEPT_START, + [YIELD_VALUE] = YIELD_VALUE, +}; + +#endif // NEED_OPCODE_METADATA + +#define EXTRA_CASES \ + case 119: \ + case 120: \ + case 121: \ + case 122: \ + case 123: \ + case 124: \ + case 125: \ + case 126: \ + case 127: \ + case 128: \ + case 129: \ + case 130: \ + case 131: \ + case 132: \ + case 133: \ + case 134: \ + case 135: \ + case 136: \ + case 137: \ + case 138: \ + case 139: \ + case 140: \ + case 141: \ + case 142: \ + case 143: \ + case 144: \ + case 145: \ + case 146: \ + case 147: \ + case 148: \ + case 223: \ + case 224: \ + case 225: \ + case 226: \ + case 227: \ + case 228: \ + case 229: \ + case 230: \ + case 231: \ + case 232: \ + case 233: \ + case 234: \ + case 235: \ + case 255: \ + ; +struct pseudo_targets { + uint8_t targets[3]; +}; +extern const struct pseudo_targets _PyOpcode_PseudoTargets[12]; +#ifdef NEED_OPCODE_METADATA +const struct pseudo_targets _PyOpcode_PseudoTargets[12] = { + [LOAD_CLOSURE-256] = { { LOAD_FAST, 0, 0 } }, + [STORE_FAST_MAYBE_NULL-256] = { { STORE_FAST, 0, 0 } }, + [LOAD_SUPER_METHOD-256] = { { LOAD_SUPER_ATTR, 0, 0 } }, + [LOAD_ZERO_SUPER_METHOD-256] = { { LOAD_SUPER_ATTR, 0, 0 } }, + [LOAD_ZERO_SUPER_ATTR-256] = { { LOAD_SUPER_ATTR, 0, 0 } }, + [LOAD_METHOD-256] = { { LOAD_ATTR, 0, 0 } }, + [JUMP-256] = { { JUMP_FORWARD, JUMP_BACKWARD, 0 } }, + [JUMP_NO_INTERRUPT-256] = { { JUMP_FORWARD, JUMP_BACKWARD_NO_INTERRUPT, 0 } }, + [SETUP_FINALLY-256] = { { NOP, 0, 0 } }, + [SETUP_CLEANUP-256] = { { NOP, 0, 0 } }, + [SETUP_WITH-256] = { { NOP, 0, 0 } }, + [POP_BLOCK-256] = { { NOP, 0, 0 } }, +}; + +#endif // NEED_OPCODE_METADATA +static inline bool +is_pseudo_target(int pseudo, int target) { + if (pseudo < 256 || pseudo >= 268) { + return false; + } + for (int i = 0; _PyOpcode_PseudoTargets[pseudo-256].targets[i]; i++) { + if (_PyOpcode_PseudoTargets[pseudo-256].targets[i] == target) return true; + } + return false; +} + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CORE_OPCODE_METADATA_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_opcode_utils.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_opcode_utils.h new file mode 100644 index 00000000..208bfb2f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_opcode_utils.h @@ -0,0 +1,73 @@ +#ifndef Py_INTERNAL_OPCODE_UTILS_H +#define Py_INTERNAL_OPCODE_UTILS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "opcode_ids.h" + +#define MAX_REAL_OPCODE 254 + +#define IS_WITHIN_OPCODE_RANGE(opcode) \ + (((opcode) >= 0 && (opcode) <= MAX_REAL_OPCODE) || \ + IS_PSEUDO_INSTR(opcode)) + +#define IS_BLOCK_PUSH_OPCODE(opcode) \ + ((opcode) == SETUP_FINALLY || \ + (opcode) == SETUP_WITH || \ + (opcode) == SETUP_CLEANUP) + +#define HAS_TARGET(opcode) \ + (OPCODE_HAS_JUMP(opcode) || IS_BLOCK_PUSH_OPCODE(opcode)) + +/* opcodes that must be last in the basicblock */ +#define IS_TERMINATOR_OPCODE(opcode) \ + (OPCODE_HAS_JUMP(opcode) || IS_SCOPE_EXIT_OPCODE(opcode)) + +/* opcodes which are not emitted in codegen stage, only by the assembler */ +#define IS_ASSEMBLER_OPCODE(opcode) \ + ((opcode) == JUMP_FORWARD || \ + (opcode) == JUMP_BACKWARD || \ + (opcode) == JUMP_BACKWARD_NO_INTERRUPT) + +#define IS_BACKWARDS_JUMP_OPCODE(opcode) \ + ((opcode) == JUMP_BACKWARD || \ + (opcode) == JUMP_BACKWARD_NO_INTERRUPT) + +#define IS_UNCONDITIONAL_JUMP_OPCODE(opcode) \ + ((opcode) == JUMP || \ + (opcode) == JUMP_NO_INTERRUPT || \ + (opcode) == JUMP_FORWARD || \ + (opcode) == JUMP_BACKWARD || \ + (opcode) == JUMP_BACKWARD_NO_INTERRUPT) + +#define IS_SCOPE_EXIT_OPCODE(opcode) \ + ((opcode) == RETURN_VALUE || \ + (opcode) == RETURN_CONST || \ + (opcode) == RAISE_VARARGS || \ + (opcode) == RERAISE) + + +/* Flags used in the oparg for MAKE_FUNCTION */ +#define MAKE_FUNCTION_DEFAULTS 0x01 +#define MAKE_FUNCTION_KWDEFAULTS 0x02 +#define MAKE_FUNCTION_ANNOTATIONS 0x04 +#define MAKE_FUNCTION_CLOSURE 0x08 + +/* Values used in the oparg for RESUME */ +#define RESUME_AT_FUNC_START 0 +#define RESUME_AFTER_YIELD 1 +#define RESUME_AFTER_YIELD_FROM 2 +#define RESUME_AFTER_AWAIT 3 + +#define RESUME_OPARG_LOCATION_MASK 0x3 +#define RESUME_OPARG_DEPTH1_MASK 0x4 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_OPCODE_UTILS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_optimizer.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_optimizer.h new file mode 100644 index 00000000..49aa67c6 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_optimizer.h @@ -0,0 +1,272 @@ +#ifndef Py_INTERNAL_OPTIMIZER_H +#define Py_INTERNAL_OPTIMIZER_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_uop_ids.h" +#include + + +typedef struct _PyExecutorLinkListNode { + struct _PyExecutorObject *next; + struct _PyExecutorObject *previous; +} _PyExecutorLinkListNode; + + +/* Bloom filter with m = 256 + * https://en.wikipedia.org/wiki/Bloom_filter */ +#define BLOOM_FILTER_WORDS 8 + +typedef struct _bloom_filter { + uint32_t bits[BLOOM_FILTER_WORDS]; +} _PyBloomFilter; + +typedef struct { + uint8_t opcode; + uint8_t oparg; + uint8_t valid; + uint8_t linked; + int index; // Index of ENTER_EXECUTOR (if code isn't NULL, below). + _PyBloomFilter bloom; + _PyExecutorLinkListNode links; + PyCodeObject *code; // Weak (NULL if no corresponding ENTER_EXECUTOR). +} _PyVMData; + +#define UOP_FORMAT_TARGET 0 +#define UOP_FORMAT_EXIT 1 +#define UOP_FORMAT_JUMP 2 +#define UOP_FORMAT_UNUSED 3 + +/* Depending on the format, + * the 32 bits between the oparg and operand are: + * UOP_FORMAT_TARGET: + * uint32_t target; + * UOP_FORMAT_EXIT + * uint16_t exit_index; + * uint16_t error_target; + * UOP_FORMAT_JUMP + * uint16_t jump_target; + * uint16_t error_target; + */ +typedef struct { + uint16_t opcode:14; + uint16_t format:2; + uint16_t oparg; + union { + uint32_t target; + struct { + union { + uint16_t exit_index; + uint16_t jump_target; + }; + uint16_t error_target; + }; + }; + uint64_t operand; // A cache entry +} _PyUOpInstruction; + +static inline uint32_t uop_get_target(const _PyUOpInstruction *inst) +{ + assert(inst->format == UOP_FORMAT_TARGET); + return inst->target; +} + +static inline uint16_t uop_get_exit_index(const _PyUOpInstruction *inst) +{ + assert(inst->format == UOP_FORMAT_EXIT); + return inst->exit_index; +} + +static inline uint16_t uop_get_jump_target(const _PyUOpInstruction *inst) +{ + assert(inst->format == UOP_FORMAT_JUMP); + return inst->jump_target; +} + +static inline uint16_t uop_get_error_target(const _PyUOpInstruction *inst) +{ + assert(inst->format != UOP_FORMAT_TARGET); + return inst->error_target; +} + +typedef struct _exit_data { + uint32_t target; + _Py_BackoffCounter temperature; + const struct _PyExecutorObject *executor; +} _PyExitData; + +typedef struct _PyExecutorObject { + PyObject_VAR_HEAD + const _PyUOpInstruction *trace; + _PyVMData vm_data; /* Used by the VM, but opaque to the optimizer */ + uint32_t exit_count; + uint32_t code_size; + size_t jit_size; + void *jit_code; + void *jit_side_entry; + _PyExitData exits[1]; +} _PyExecutorObject; + +typedef struct _PyOptimizerObject _PyOptimizerObject; + +/* Should return > 0 if a new executor is created. O if no executor is produced and < 0 if an error occurred. */ +typedef int (*optimize_func)( + _PyOptimizerObject* self, struct _PyInterpreterFrame *frame, + _Py_CODEUNIT *instr, _PyExecutorObject **exec_ptr, + int curr_stackentries); + +struct _PyOptimizerObject { + PyObject_HEAD + optimize_func optimize; + /* Data needed by the optimizer goes here, but is opaque to the VM */ +}; + +/** Test support **/ +typedef struct { + _PyOptimizerObject base; + int64_t count; +} _PyCounterOptimizerObject; + +_PyOptimizerObject *_Py_SetOptimizer(PyInterpreterState *interp, _PyOptimizerObject* optimizer); + +PyAPI_FUNC(int) _Py_SetTier2Optimizer(_PyOptimizerObject* optimizer); + +PyAPI_FUNC(_PyOptimizerObject *) _Py_GetOptimizer(void); + +PyAPI_FUNC(_PyExecutorObject *) _Py_GetExecutor(PyCodeObject *code, int offset); + +void _Py_ExecutorInit(_PyExecutorObject *, const _PyBloomFilter *); +void _Py_ExecutorDetach(_PyExecutorObject *); +void _Py_BloomFilter_Init(_PyBloomFilter *); +void _Py_BloomFilter_Add(_PyBloomFilter *bloom, void *obj); +PyAPI_FUNC(void) _Py_Executor_DependsOn(_PyExecutorObject *executor, void *obj); +/* For testing */ +PyAPI_FUNC(PyObject *) _PyOptimizer_NewCounter(void); +PyAPI_FUNC(PyObject *) _PyOptimizer_NewUOpOptimizer(void); + +#define _Py_MAX_ALLOWED_BUILTINS_MODIFICATIONS 3 +#define _Py_MAX_ALLOWED_GLOBALS_MODIFICATIONS 6 + +#ifdef _Py_TIER2 +PyAPI_FUNC(void) _Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj, int is_invalidation); +PyAPI_FUNC(void) _Py_Executors_InvalidateAll(PyInterpreterState *interp, int is_invalidation); +#else +# define _Py_Executors_InvalidateDependency(A, B, C) ((void)0) +# define _Py_Executors_InvalidateAll(A, B) ((void)0) +#endif + + +// This is the length of the trace we project initially. +#define UOP_MAX_TRACE_LENGTH 800 + +#define TRACE_STACK_SIZE 5 + +int _Py_uop_analyze_and_optimize(struct _PyInterpreterFrame *frame, + _PyUOpInstruction *trace, int trace_len, int curr_stackentries, + _PyBloomFilter *dependencies); + +extern PyTypeObject _PyCounterExecutor_Type; +extern PyTypeObject _PyCounterOptimizer_Type; +extern PyTypeObject _PyDefaultOptimizer_Type; +extern PyTypeObject _PyUOpExecutor_Type; +extern PyTypeObject _PyUOpOptimizer_Type; + +/* Symbols */ +/* See explanation in optimizer_symbols.c */ + +struct _Py_UopsSymbol { + int flags; // 0 bits: Top; 2 or more bits: Bottom + PyTypeObject *typ; // Borrowed reference + PyObject *const_val; // Owned reference (!) +}; + +// Holds locals, stack, locals, stack ... co_consts (in that order) +#define MAX_ABSTRACT_INTERP_SIZE 4096 + +#define TY_ARENA_SIZE (UOP_MAX_TRACE_LENGTH * 5) + +// Need extras for root frame and for overflow frame (see TRACE_STACK_PUSH()) +#define MAX_ABSTRACT_FRAME_DEPTH (TRACE_STACK_SIZE + 2) + +typedef struct _Py_UopsSymbol _Py_UopsSymbol; + +struct _Py_UOpsAbstractFrame { + // Max stacklen + int stack_len; + int locals_len; + + _Py_UopsSymbol **stack_pointer; + _Py_UopsSymbol **stack; + _Py_UopsSymbol **locals; +}; + +typedef struct _Py_UOpsAbstractFrame _Py_UOpsAbstractFrame; + +typedef struct ty_arena { + int ty_curr_number; + int ty_max_number; + _Py_UopsSymbol arena[TY_ARENA_SIZE]; +} ty_arena; + +struct _Py_UOpsContext { + PyObject_HEAD + // The current "executing" frame. + _Py_UOpsAbstractFrame *frame; + _Py_UOpsAbstractFrame frames[MAX_ABSTRACT_FRAME_DEPTH]; + int curr_frame_depth; + + // Arena for the symbolic types. + ty_arena t_arena; + + _Py_UopsSymbol **n_consumed; + _Py_UopsSymbol **limit; + _Py_UopsSymbol *locals_and_stack[MAX_ABSTRACT_INTERP_SIZE]; +}; + +typedef struct _Py_UOpsContext _Py_UOpsContext; + +extern bool _Py_uop_sym_is_null(_Py_UopsSymbol *sym); +extern bool _Py_uop_sym_is_not_null(_Py_UopsSymbol *sym); +extern bool _Py_uop_sym_is_const(_Py_UopsSymbol *sym); +extern PyObject *_Py_uop_sym_get_const(_Py_UopsSymbol *sym); +extern _Py_UopsSymbol *_Py_uop_sym_new_unknown(_Py_UOpsContext *ctx); +extern _Py_UopsSymbol *_Py_uop_sym_new_not_null(_Py_UOpsContext *ctx); +extern _Py_UopsSymbol *_Py_uop_sym_new_type( + _Py_UOpsContext *ctx, PyTypeObject *typ); +extern _Py_UopsSymbol *_Py_uop_sym_new_const(_Py_UOpsContext *ctx, PyObject *const_val); +extern _Py_UopsSymbol *_Py_uop_sym_new_null(_Py_UOpsContext *ctx); +extern bool _Py_uop_sym_has_type(_Py_UopsSymbol *sym); +extern bool _Py_uop_sym_matches_type(_Py_UopsSymbol *sym, PyTypeObject *typ); +extern bool _Py_uop_sym_set_null(_Py_UopsSymbol *sym); +extern bool _Py_uop_sym_set_non_null(_Py_UopsSymbol *sym); +extern bool _Py_uop_sym_set_type(_Py_UopsSymbol *sym, PyTypeObject *typ); +extern bool _Py_uop_sym_set_const(_Py_UopsSymbol *sym, PyObject *const_val); +extern bool _Py_uop_sym_is_bottom(_Py_UopsSymbol *sym); +extern int _Py_uop_sym_truthiness(_Py_UopsSymbol *sym); +extern PyTypeObject *_Py_uop_sym_get_type(_Py_UopsSymbol *sym); + + +extern int _Py_uop_abstractcontext_init(_Py_UOpsContext *ctx); +extern void _Py_uop_abstractcontext_fini(_Py_UOpsContext *ctx); + +extern _Py_UOpsAbstractFrame *_Py_uop_frame_new( + _Py_UOpsContext *ctx, + PyCodeObject *co, + int curr_stackentries, + _Py_UopsSymbol **args, + int arg_len); +extern int _Py_uop_frame_pop(_Py_UOpsContext *ctx); + +PyAPI_FUNC(PyObject *) _Py_uop_symbols_test(PyObject *self, PyObject *ignored); + +PyAPI_FUNC(int) _PyOptimizer_Optimize(struct _PyInterpreterFrame *frame, _Py_CODEUNIT *start, PyObject **stack_pointer, _PyExecutorObject **exec_ptr); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_OPTIMIZER_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_parking_lot.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_parking_lot.h new file mode 100644 index 00000000..8c9260e2 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_parking_lot.h @@ -0,0 +1,97 @@ +// ParkingLot is an internal API for building efficient synchronization +// primitives like mutexes and events. +// +// The API and name is inspired by WebKit's WTF::ParkingLot, which in turn +// is inspired Linux's futex API. +// See https://webkit.org/blog/6161/locking-in-webkit/. +// +// The core functionality is an atomic "compare-and-sleep" operation along with +// an atomic "wake-up" operation. + +#ifndef Py_INTERNAL_PARKING_LOT_H +#define Py_INTERNAL_PARKING_LOT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +enum { + // The thread was unparked by another thread. + Py_PARK_OK = 0, + + // The value of `address` did not match `expected`. + Py_PARK_AGAIN = -1, + + // The thread was unparked due to a timeout. + Py_PARK_TIMEOUT = -2, + + // The thread was interrupted by a signal. + Py_PARK_INTR = -3, +}; + +// Checks that `*address == *expected` and puts the thread to sleep until an +// unpark operation is called on the same `address`. Otherwise, the function +// returns `Py_PARK_AGAIN`. The comparison behaves like memcmp, but is +// performed atomically with respect to unpark operations. +// +// The `address_size` argument is the size of the data pointed to by the +// `address` and `expected` pointers (i.e., sizeof(*address)). It must be +// 1, 2, 4, or 8. +// +// The `timeout_ns` argument specifies the maximum amount of time to wait, with +// -1 indicating an infinite wait. +// +// `park_arg`, which can be NULL, is passed to the unpark operation. +// +// If `detach` is true, then the thread will detach/release the GIL while +// waiting. +// +// Example usage: +// +// if (_Py_atomic_compare_exchange_uint8(address, &expected, new_value)) { +// int res = _PyParkingLot_Park(address, &new_value, sizeof(*address), +// timeout_ns, NULL, 1); +// ... +// } +PyAPI_FUNC(int) +_PyParkingLot_Park(const void *address, const void *expected, + size_t address_size, PyTime_t timeout_ns, + void *park_arg, int detach); + +// Callback for _PyParkingLot_Unpark: +// +// `arg` is the data of the same name provided to the _PyParkingLot_Unpark() +// call. +// `park_arg` is the data provided to _PyParkingLot_Park() call or NULL if +// no waiting thread was found. +// `has_more_waiters` is true if there are more threads waiting on the same +// address. May be true in cases where threads are waiting on a different +// address that map to the same internal bucket. +typedef void _Py_unpark_fn_t(void *arg, void *park_arg, int has_more_waiters); + +// Unparks a single thread waiting on `address`. +// +// Note that fn() is called regardless of whether a thread was unparked. If +// no threads are waiting on `address` then the `park_arg` argument to fn() +// will be NULL. +// +// Example usage: +// void callback(void *arg, void *park_arg, int has_more_waiters); +// _PyParkingLot_Unpark(address, &callback, arg); +PyAPI_FUNC(void) +_PyParkingLot_Unpark(const void *address, _Py_unpark_fn_t *fn, void *arg); + +// Unparks all threads waiting on `address`. +PyAPI_FUNC(void) _PyParkingLot_UnparkAll(const void *address); + +// Resets the parking lot state after a fork. Forgets all parked threads. +PyAPI_FUNC(void) _PyParkingLot_AfterFork(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PARKING_LOT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_parser.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_parser.h new file mode 100644 index 00000000..b16084aa --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_parser.h @@ -0,0 +1,95 @@ +#ifndef Py_INTERNAL_PARSER_H +#define Py_INTERNAL_PARSER_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +#include "pycore_ast.h" // struct _expr +#include "pycore_global_strings.h" // _Py_DECLARE_STR() +#include "pycore_pyarena.h" // PyArena + + +#ifdef Py_DEBUG +#define _PYPEGEN_NSTATISTICS 2000 +#endif + +struct _parser_runtime_state { +#ifdef Py_DEBUG + long memo_statistics[_PYPEGEN_NSTATISTICS]; +#ifdef Py_GIL_DISABLED + PyMutex mutex; +#endif +#else + int _not_used; +#endif + struct _expr dummy_name; +}; + +_Py_DECLARE_STR(empty, "") +#if defined(Py_DEBUG) && defined(Py_GIL_DISABLED) +#define _parser_runtime_state_INIT \ + { \ + .mutex = {0}, \ + .dummy_name = { \ + .kind = Name_kind, \ + .v.Name.id = &_Py_STR(empty), \ + .v.Name.ctx = Load, \ + .lineno = 1, \ + .col_offset = 0, \ + .end_lineno = 1, \ + .end_col_offset = 0, \ + }, \ + } +#else +#define _parser_runtime_state_INIT \ + { \ + .dummy_name = { \ + .kind = Name_kind, \ + .v.Name.id = &_Py_STR(empty), \ + .v.Name.ctx = Load, \ + .lineno = 1, \ + .col_offset = 0, \ + .end_lineno = 1, \ + .end_col_offset = 0, \ + }, \ + } +#endif + +extern struct _mod* _PyParser_ASTFromString( + const char *str, + PyObject* filename, + int mode, + PyCompilerFlags *flags, + PyArena *arena); + +extern struct _mod* _PyParser_ASTFromFile( + FILE *fp, + PyObject *filename_ob, + const char *enc, + int mode, + const char *ps1, + const char *ps2, + PyCompilerFlags *flags, + int *errcode, + PyArena *arena); +extern struct _mod* _PyParser_InteractiveASTFromFile( + FILE *fp, + PyObject *filename_ob, + const char *enc, + int mode, + const char *ps1, + const char *ps2, + PyCompilerFlags *flags, + int *errcode, + PyObject **interactive_src, + PyArena *arena); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PARSER_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pathconfig.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pathconfig.h new file mode 100644 index 00000000..a1ce1b19 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pathconfig.h @@ -0,0 +1,26 @@ +#ifndef Py_INTERNAL_PATHCONFIG_H +#define Py_INTERNAL_PATHCONFIG_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(void) _PyPathConfig_ClearGlobal(void); + +extern PyStatus _PyPathConfig_ReadGlobal(PyConfig *config); +extern PyStatus _PyPathConfig_UpdateGlobal(const PyConfig *config); +extern const wchar_t * _PyPathConfig_GetGlobalModuleSearchPath(void); + +extern int _PyPathConfig_ComputeSysPath0( + const PyWideStringList *argv, + PyObject **path0); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PATHCONFIG_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pyarena.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pyarena.h new file mode 100644 index 00000000..1f07479f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pyarena.h @@ -0,0 +1,68 @@ +// An arena-like memory interface for the compiler. + +#ifndef Py_INTERNAL_PYARENA_H +#define Py_INTERNAL_PYARENA_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +typedef struct _arena PyArena; + +// _PyArena_New() and _PyArena_Free() create a new arena and free it, +// respectively. Once an arena has been created, it can be used +// to allocate memory via _PyArena_Malloc(). Pointers to PyObject can +// also be registered with the arena via _PyArena_AddPyObject(), and the +// arena will ensure that the PyObjects stay alive at least until +// _PyArena_Free() is called. When an arena is freed, all the memory it +// allocated is freed, the arena releases internal references to registered +// PyObject*, and none of its pointers are valid. +// XXX (tim) What does "none of its pointers are valid" mean? Does it +// XXX mean that pointers previously obtained via _PyArena_Malloc() are +// XXX no longer valid? (That's clearly true, but not sure that's what +// XXX the text is trying to say.) +// +// _PyArena_New() returns an arena pointer. On error, it +// returns a negative number and sets an exception. +// XXX (tim): Not true. On error, _PyArena_New() actually returns NULL, +// XXX and looks like it may or may not set an exception (e.g., if the +// XXX internal PyList_New(0) returns NULL, _PyArena_New() passes that on +// XXX and an exception is set; OTOH, if the internal +// XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but +// XXX an exception is not set in that case). +// +// Export for test_peg_generator +PyAPI_FUNC(PyArena*) _PyArena_New(void); + +// Export for test_peg_generator +PyAPI_FUNC(void) _PyArena_Free(PyArena *); + +// Mostly like malloc(), return the address of a block of memory spanning +// `size` bytes, or return NULL (without setting an exception) if enough +// new memory can't be obtained. Unlike malloc(0), _PyArena_Malloc() with +// size=0 does not guarantee to return a unique pointer (the pointer +// returned may equal one or more other pointers obtained from +// _PyArena_Malloc()). +// Note that pointers obtained via _PyArena_Malloc() must never be passed to +// the system free() or realloc(), or to any of Python's similar memory- +// management functions. _PyArena_Malloc()-obtained pointers remain valid +// until _PyArena_Free(ar) is called, at which point all pointers obtained +// from the arena `ar` become invalid simultaneously. +// +// Export for test_peg_generator +PyAPI_FUNC(void*) _PyArena_Malloc(PyArena *, size_t size); + +// This routine isn't a proper arena allocation routine. It takes +// a PyObject* and records it so that it can be DECREFed when the +// arena is freed. +// +// Export for test_peg_generator +PyAPI_FUNC(int) _PyArena_AddPyObject(PyArena *, PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PYARENA_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pyatomic_ft_wrappers.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pyatomic_ft_wrappers.h new file mode 100644 index 00000000..d755d03a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pyatomic_ft_wrappers.h @@ -0,0 +1,165 @@ +// This header file provides wrappers around the atomic operations found in +// `pyatomic.h` that are only atomic in free-threaded builds. +// +// These are intended to be used in places where atomics are required in +// free-threaded builds, but not in the default build, and we don't want to +// introduce the potential performance overhead of an atomic operation in the +// default build. +// +// All usages of these macros should be replaced with unconditionally atomic or +// non-atomic versions, and this file should be removed, once the dust settles +// on free threading. +#ifndef Py_ATOMIC_FT_WRAPPERS_H +#define Py_ATOMIC_FT_WRAPPERS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +#error "this header requires Py_BUILD_CORE define" +#endif + +#ifdef Py_GIL_DISABLED +#define FT_ATOMIC_LOAD_PTR(value) _Py_atomic_load_ptr(&value) +#define FT_ATOMIC_STORE_PTR(value, new_value) _Py_atomic_store_ptr(&value, new_value) +#define FT_ATOMIC_LOAD_SSIZE(value) _Py_atomic_load_ssize(&value) +#define FT_ATOMIC_LOAD_SSIZE_ACQUIRE(value) \ + _Py_atomic_load_ssize_acquire(&value) +#define FT_ATOMIC_LOAD_SSIZE_RELAXED(value) \ + _Py_atomic_load_ssize_relaxed(&value) +#define FT_ATOMIC_STORE_PTR(value, new_value) \ + _Py_atomic_store_ptr(&value, new_value) +#define FT_ATOMIC_LOAD_PTR_ACQUIRE(value) \ + _Py_atomic_load_ptr_acquire(&value) +#define FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(value) \ + _Py_atomic_load_uintptr_acquire(&value) +#define FT_ATOMIC_LOAD_PTR_RELAXED(value) \ + _Py_atomic_load_ptr_relaxed(&value) +#define FT_ATOMIC_LOAD_UINT8(value) \ + _Py_atomic_load_uint8(&value) +#define FT_ATOMIC_STORE_UINT8(value, new_value) \ + _Py_atomic_store_uint8(&value, new_value) +#define FT_ATOMIC_LOAD_UINT8_RELAXED(value) \ + _Py_atomic_load_uint8_relaxed(&value) +#define FT_ATOMIC_LOAD_UINT16_RELAXED(value) \ + _Py_atomic_load_uint16_relaxed(&value) +#define FT_ATOMIC_LOAD_UINT32_RELAXED(value) \ + _Py_atomic_load_uint32_relaxed(&value) +#define FT_ATOMIC_LOAD_ULONG_RELAXED(value) \ + _Py_atomic_load_ulong_relaxed(&value) +#define FT_ATOMIC_STORE_PTR_RELAXED(value, new_value) \ + _Py_atomic_store_ptr_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_PTR_RELEASE(value, new_value) \ + _Py_atomic_store_ptr_release(&value, new_value) +#define FT_ATOMIC_STORE_UINTPTR_RELEASE(value, new_value) \ + _Py_atomic_store_uintptr_release(&value, new_value) +#define FT_ATOMIC_STORE_SSIZE_RELAXED(value, new_value) \ + _Py_atomic_store_ssize_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_UINT8_RELAXED(value, new_value) \ + _Py_atomic_store_uint8_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_UINT16_RELAXED(value, new_value) \ + _Py_atomic_store_uint16_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_UINT32_RELAXED(value, new_value) \ + _Py_atomic_store_uint32_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_CHAR_RELAXED(value, new_value) \ + _Py_atomic_store_char_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_CHAR_RELAXED(value) \ + _Py_atomic_load_char_relaxed(&value) +#define FT_ATOMIC_STORE_UCHAR_RELAXED(value, new_value) \ + _Py_atomic_store_uchar_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_UCHAR_RELAXED(value) \ + _Py_atomic_load_uchar_relaxed(&value) +#define FT_ATOMIC_STORE_SHORT_RELAXED(value, new_value) \ + _Py_atomic_store_short_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_SHORT_RELAXED(value) \ + _Py_atomic_load_short_relaxed(&value) +#define FT_ATOMIC_STORE_USHORT_RELAXED(value, new_value) \ + _Py_atomic_store_ushort_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_USHORT_RELAXED(value) \ + _Py_atomic_load_ushort_relaxed(&value) +#define FT_ATOMIC_STORE_INT_RELAXED(value, new_value) \ + _Py_atomic_store_int_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_INT_RELAXED(value) \ + _Py_atomic_load_int_relaxed(&value) +#define FT_ATOMIC_STORE_UINT_RELAXED(value, new_value) \ + _Py_atomic_store_uint_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_UINT_RELAXED(value) \ + _Py_atomic_load_uint_relaxed(&value) +#define FT_ATOMIC_STORE_LONG_RELAXED(value, new_value) \ + _Py_atomic_store_long_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_LONG_RELAXED(value) \ + _Py_atomic_load_long_relaxed(&value) +#define FT_ATOMIC_STORE_ULONG_RELAXED(value, new_value) \ + _Py_atomic_store_ulong_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_SSIZE_RELAXED(value, new_value) \ + _Py_atomic_store_ssize_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_FLOAT_RELAXED(value, new_value) \ + _Py_atomic_store_float_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_FLOAT_RELAXED(value) \ + _Py_atomic_load_float_relaxed(&value) +#define FT_ATOMIC_STORE_DOUBLE_RELAXED(value, new_value) \ + _Py_atomic_store_double_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_DOUBLE_RELAXED(value) \ + _Py_atomic_load_double_relaxed(&value) +#define FT_ATOMIC_STORE_LLONG_RELAXED(value, new_value) \ + _Py_atomic_store_llong_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_LLONG_RELAXED(value) \ + _Py_atomic_load_llong_relaxed(&value) +#define FT_ATOMIC_STORE_ULLONG_RELAXED(value, new_value) \ + _Py_atomic_store_ullong_relaxed(&value, new_value) +#define FT_ATOMIC_LOAD_ULLONG_RELAXED(value) \ + _Py_atomic_load_ullong_relaxed(&value) + +#else +#define FT_ATOMIC_LOAD_PTR(value) value +#define FT_ATOMIC_STORE_PTR(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_SSIZE(value) value +#define FT_ATOMIC_LOAD_SSIZE_ACQUIRE(value) value +#define FT_ATOMIC_LOAD_SSIZE_RELAXED(value) value +#define FT_ATOMIC_LOAD_PTR_ACQUIRE(value) value +#define FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(value) value +#define FT_ATOMIC_LOAD_PTR_RELAXED(value) value +#define FT_ATOMIC_LOAD_UINT8(value) value +#define FT_ATOMIC_STORE_UINT8(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_UINT8_RELAXED(value) value +#define FT_ATOMIC_LOAD_UINT16_RELAXED(value) value +#define FT_ATOMIC_LOAD_UINT32_RELAXED(value) value +#define FT_ATOMIC_LOAD_ULONG_RELAXED(value) value +#define FT_ATOMIC_STORE_PTR_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_STORE_PTR_RELEASE(value, new_value) value = new_value +#define FT_ATOMIC_STORE_UINTPTR_RELEASE(value, new_value) value = new_value +#define FT_ATOMIC_STORE_SSIZE_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_STORE_UINT8_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_STORE_UINT16_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_STORE_UINT32_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_CHAR_RELAXED(value) value +#define FT_ATOMIC_STORE_CHAR_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_UCHAR_RELAXED(value) value +#define FT_ATOMIC_STORE_UCHAR_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_SHORT_RELAXED(value) value +#define FT_ATOMIC_STORE_SHORT_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_USHORT_RELAXED(value) value +#define FT_ATOMIC_STORE_USHORT_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_INT_RELAXED(value) value +#define FT_ATOMIC_STORE_INT_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_UINT_RELAXED(value) value +#define FT_ATOMIC_STORE_UINT_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_LONG_RELAXED(value) value +#define FT_ATOMIC_STORE_LONG_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_STORE_ULONG_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_STORE_SSIZE_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_FLOAT_RELAXED(value) value +#define FT_ATOMIC_STORE_FLOAT_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_DOUBLE_RELAXED(value) value +#define FT_ATOMIC_STORE_DOUBLE_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_LLONG_RELAXED(value) value +#define FT_ATOMIC_STORE_LLONG_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_LOAD_ULLONG_RELAXED(value) value +#define FT_ATOMIC_STORE_ULLONG_RELAXED(value, new_value) value = new_value + +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ATOMIC_FT_WRAPPERS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pybuffer.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pybuffer.h new file mode 100644 index 00000000..9439d2bd --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pybuffer.h @@ -0,0 +1,21 @@ +#ifndef Py_INTERNAL_PYBUFFER_H +#define Py_INTERNAL_PYBUFFER_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +// Exported for the _interpchannels module. +PyAPI_FUNC(int) _PyBuffer_ReleaseInInterpreter( + PyInterpreterState *interp, Py_buffer *view); +PyAPI_FUNC(int) _PyBuffer_ReleaseInInterpreterAndRawFree( + PyInterpreterState *interp, Py_buffer *view); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PYBUFFER_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pyerrors.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pyerrors.h new file mode 100644 index 00000000..615cc23e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pyerrors.h @@ -0,0 +1,190 @@ +#ifndef Py_INTERNAL_PYERRORS_H +#define Py_INTERNAL_PYERRORS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +/* Error handling definitions */ + +extern _PyErr_StackItem* _PyErr_GetTopmostException(PyThreadState *tstate); +extern PyObject* _PyErr_GetHandledException(PyThreadState *); +extern void _PyErr_SetHandledException(PyThreadState *, PyObject *); +extern void _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, PyObject **); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *); + + +// Like PyErr_Format(), but saves current exception as __context__ and +// __cause__. +// Export for '_sqlite3' shared extension. +PyAPI_FUNC(PyObject*) _PyErr_FormatFromCause( + PyObject *exception, + const char *format, /* ASCII-encoded string */ + ... + ); + +extern int _PyException_AddNote( + PyObject *exc, + PyObject *note); + +extern int _PyErr_CheckSignals(void); + +/* Support for adding program text to SyntaxErrors */ + +// Export for test_peg_generator +PyAPI_FUNC(PyObject*) _PyErr_ProgramDecodedTextObject( + PyObject *filename, + int lineno, + const char* encoding); + +extern PyObject* _PyUnicodeTranslateError_Create( + PyObject *object, + Py_ssize_t start, + Py_ssize_t end, + const char *reason /* UTF-8 encoded string */ + ); + +extern void _Py_NO_RETURN _Py_FatalErrorFormat( + const char *func, + const char *format, + ...); + +extern PyObject* _PyErr_SetImportErrorWithNameFrom( + PyObject *, + PyObject *, + PyObject *, + PyObject *); + + +/* runtime lifecycle */ + +extern PyStatus _PyErr_InitTypes(PyInterpreterState *); +extern void _PyErr_FiniTypes(PyInterpreterState *); + + +/* other API */ + +static inline PyObject* _PyErr_Occurred(PyThreadState *tstate) +{ + assert(tstate != NULL); + if (tstate->current_exception == NULL) { + return NULL; + } + return (PyObject *)Py_TYPE(tstate->current_exception); +} + +static inline void _PyErr_ClearExcState(_PyErr_StackItem *exc_state) +{ + Py_CLEAR(exc_state->exc_value); +} + +extern PyObject* _PyErr_StackItemToExcInfoTuple( + _PyErr_StackItem *err_info); + +extern void _PyErr_Fetch( + PyThreadState *tstate, + PyObject **type, + PyObject **value, + PyObject **traceback); + +extern PyObject* _PyErr_GetRaisedException(PyThreadState *tstate); + +PyAPI_FUNC(int) _PyErr_ExceptionMatches( + PyThreadState *tstate, + PyObject *exc); + +extern void _PyErr_SetRaisedException(PyThreadState *tstate, PyObject *exc); + +extern void _PyErr_Restore( + PyThreadState *tstate, + PyObject *type, + PyObject *value, + PyObject *traceback); + +extern void _PyErr_SetObject( + PyThreadState *tstate, + PyObject *type, + PyObject *value); + +extern void _PyErr_ChainStackItem(void); + +PyAPI_FUNC(void) _PyErr_Clear(PyThreadState *tstate); + +extern void _PyErr_SetNone(PyThreadState *tstate, PyObject *exception); + +extern PyObject* _PyErr_NoMemory(PyThreadState *tstate); + +PyAPI_FUNC(void) _PyErr_SetString( + PyThreadState *tstate, + PyObject *exception, + const char *string); + +/* + * Set an exception with the error message decoded from the current locale + * encoding (LC_CTYPE). + * + * Exceptions occurring in decoding take priority over the desired exception. + * + * Exported for '_ctypes' shared extensions. + */ +PyAPI_FUNC(void) _PyErr_SetLocaleString( + PyObject *exception, + const char *string); + +PyAPI_FUNC(PyObject*) _PyErr_Format( + PyThreadState *tstate, + PyObject *exception, + const char *format, + ...); + +extern void _PyErr_NormalizeException( + PyThreadState *tstate, + PyObject **exc, + PyObject **val, + PyObject **tb); + +extern PyObject* _PyErr_FormatFromCauseTstate( + PyThreadState *tstate, + PyObject *exception, + const char *format, + ...); + +extern PyObject* _PyExc_CreateExceptionGroup( + const char *msg, + PyObject *excs); + +extern PyObject* _PyExc_PrepReraiseStar( + PyObject *orig, + PyObject *excs); + +extern int _PyErr_CheckSignalsTstate(PyThreadState *tstate); + +extern void _Py_DumpExtensionModules(int fd, PyInterpreterState *interp); +extern PyObject* _Py_CalculateSuggestions(PyObject *dir, PyObject *name); +extern PyObject* _Py_Offer_Suggestions(PyObject* exception); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(Py_ssize_t) _Py_UTF8_Edit_Cost(PyObject *str_a, PyObject *str_b, + Py_ssize_t max_cost); + +void _PyErr_FormatNote(const char *format, ...); + +/* Context manipulation (PEP 3134) */ + +Py_DEPRECATED(3.12) extern void _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *); + +// implementation detail for the codeop module. +// Exported for test.test_peg_generator.test_c_parser +PyAPI_DATA(PyTypeObject) _PyExc_IncompleteInputError; +#define PyExc_IncompleteInputError ((PyObject *)(&_PyExc_IncompleteInputError)) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PYERRORS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pyhash.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pyhash.h new file mode 100644 index 00000000..0ce08900 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pyhash.h @@ -0,0 +1,107 @@ +#ifndef Py_INTERNAL_PYHASH_H +#define Py_INTERNAL_PYHASH_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Similar to Py_HashPointer(), but don't replace -1 with -2. +static inline Py_hash_t +_Py_HashPointerRaw(const void *ptr) +{ + uintptr_t x = (uintptr_t)ptr; + Py_BUILD_ASSERT(sizeof(x) == sizeof(ptr)); + + // Bottom 3 or 4 bits are likely to be 0; rotate x by 4 to the right + // to avoid excessive hash collisions for dicts and sets. + x = (x >> 4) | (x << (8 * sizeof(uintptr_t) - 4)); + + Py_BUILD_ASSERT(sizeof(x) == sizeof(Py_hash_t)); + return (Py_hash_t)x; +} + +// Export for '_datetime' shared extension +PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void*, Py_ssize_t); + +/* Hash secret + * + * memory layout on 64 bit systems + * cccccccc cccccccc cccccccc uc -- unsigned char[24] + * pppppppp ssssssss ........ fnv -- two Py_hash_t + * k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t + * ........ ........ ssssssss djbx33a -- 16 bytes padding + one Py_hash_t + * ........ ........ eeeeeeee pyexpat XML hash salt + * + * memory layout on 32 bit systems + * cccccccc cccccccc cccccccc uc + * ppppssss ........ ........ fnv -- two Py_hash_t + * k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t (*) + * ........ ........ ssss.... djbx33a -- 16 bytes padding + one Py_hash_t + * ........ ........ eeee.... pyexpat XML hash salt + * + * (*) The siphash member may not be available on 32 bit platforms without + * an unsigned int64 data type. + */ +typedef union { + /* ensure 24 bytes */ + unsigned char uc[24]; + /* two Py_hash_t for FNV */ + struct { + Py_hash_t prefix; + Py_hash_t suffix; + } fnv; + /* two uint64 for SipHash24 */ + struct { + uint64_t k0; + uint64_t k1; + } siphash; + /* a different (!) Py_hash_t for small string optimization */ + struct { + unsigned char padding[16]; + Py_hash_t suffix; + } djbx33a; + struct { + unsigned char padding[16]; + Py_hash_t hashsalt; + } expat; +} _Py_HashSecret_t; + +// Export for '_elementtree' shared extension +PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret; + +#ifdef Py_DEBUG +extern int _Py_HashSecret_Initialized; +#endif + + +struct pyhash_runtime_state { + struct { +#ifndef MS_WINDOWS + int fd; + dev_t st_dev; + ino_t st_ino; +#else + // This is a placeholder so the struct isn't empty on Windows. + int _not_used; +#endif + } urandom_cache; +}; + +#ifndef MS_WINDOWS +# define _py_urandom_cache_INIT \ + { \ + .fd = -1, \ + } +#else +# define _py_urandom_cache_INIT {0} +#endif + +#define pyhash_state_INIT \ + { \ + .urandom_cache = _py_urandom_cache_INIT, \ + } + + +extern uint64_t _Py_KeyedHash(uint64_t key, const void *src, Py_ssize_t src_sz); + +#endif // !Py_INTERNAL_PYHASH_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pylifecycle.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pylifecycle.h new file mode 100644 index 00000000..f426ae0e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pylifecycle.h @@ -0,0 +1,136 @@ +#ifndef Py_INTERNAL_LIFECYCLE_H +#define Py_INTERNAL_LIFECYCLE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_runtime.h" // _PyRuntimeState + +/* Forward declarations */ +struct _PyArgv; +struct pyruntimestate; + +extern int _Py_SetFileSystemEncoding( + const char *encoding, + const char *errors); +extern void _Py_ClearFileSystemEncoding(void); +extern PyStatus _PyUnicode_InitEncodings(PyThreadState *tstate); +#ifdef MS_WINDOWS +extern int _PyUnicode_EnableLegacyWindowsFSEncoding(void); +#endif + +extern int _Py_IsLocaleCoercionTarget(const char *ctype_loc); + +/* Various one-time initializers */ + +extern void _Py_InitVersion(void); +extern PyStatus _PyFaulthandler_Init(int enable); +extern PyObject * _PyBuiltin_Init(PyInterpreterState *interp); +extern PyStatus _PySys_Create( + PyThreadState *tstate, + PyObject **sysmod_p); +extern PyStatus _PySys_ReadPreinitWarnOptions(PyWideStringList *options); +extern PyStatus _PySys_ReadPreinitXOptions(PyConfig *config); +extern int _PySys_UpdateConfig(PyThreadState *tstate); +extern void _PySys_FiniTypes(PyInterpreterState *interp); +extern int _PyBuiltins_AddExceptions(PyObject * bltinmod); +extern PyStatus _Py_HashRandomization_Init(const PyConfig *); + +extern PyStatus _PyGC_Init(PyInterpreterState *interp); +extern PyStatus _PyAtExit_Init(PyInterpreterState *interp); + +/* Various internal finalizers */ + +extern int _PySignal_Init(int install_signal_handlers); +extern void _PySignal_Fini(void); + +extern void _PyGC_Fini(PyInterpreterState *interp); +extern void _Py_HashRandomization_Fini(void); +extern void _PyFaulthandler_Fini(void); +extern void _PyHash_Fini(void); +extern void _PyTraceMalloc_Fini(void); +extern void _PyWarnings_Fini(PyInterpreterState *interp); +extern void _PyAST_Fini(PyInterpreterState *interp); +extern void _PyAtExit_Fini(PyInterpreterState *interp); +extern void _PyThread_FiniType(PyInterpreterState *interp); +extern void _PyArg_Fini(void); +extern void _Py_FinalizeAllocatedBlocks(_PyRuntimeState *); + +extern PyStatus _PyGILState_Init(PyInterpreterState *interp); +extern void _PyGILState_SetTstate(PyThreadState *tstate); +extern void _PyGILState_Fini(PyInterpreterState *interp); + +extern void _PyGC_DumpShutdownStats(PyInterpreterState *interp); + +extern PyStatus _Py_PreInitializeFromPyArgv( + const PyPreConfig *src_config, + const struct _PyArgv *args); +extern PyStatus _Py_PreInitializeFromConfig( + const PyConfig *config, + const struct _PyArgv *args); + +extern wchar_t * _Py_GetStdlibDir(void); + +extern int _Py_HandleSystemExit(int *exitcode_p); + +extern PyObject* _PyErr_WriteUnraisableDefaultHook(PyObject *unraisable); + +extern void _PyErr_Print(PyThreadState *tstate); +extern void _PyErr_Display(PyObject *file, PyObject *exception, + PyObject *value, PyObject *tb); +extern void _PyErr_DisplayException(PyObject *file, PyObject *exc); + +extern void _PyThreadState_DeleteCurrent(PyThreadState *tstate); + +extern void _PyAtExit_Call(PyInterpreterState *interp); + +extern int _Py_IsCoreInitialized(void); + +extern int _Py_FdIsInteractive(FILE *fp, PyObject *filename); + +extern const char* _Py_gitidentifier(void); +extern const char* _Py_gitversion(void); + +// Export for '_asyncio' shared extension +PyAPI_FUNC(int) _Py_IsInterpreterFinalizing(PyInterpreterState *interp); + +/* Random */ +extern int _PyOS_URandom(void *buffer, Py_ssize_t size); + +// Export for '_random' shared extension +PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size); + +/* Legacy locale support */ +extern int _Py_CoerceLegacyLocale(int warn); +extern int _Py_LegacyLocaleDetected(int warn); + +// Export for 'readline' shared extension +PyAPI_FUNC(char*) _Py_SetLocaleFromEnv(int category); + +// Export for special main.c string compiling with source tracebacks +int _PyRun_SimpleStringFlagsWithName(const char *command, const char* name, PyCompilerFlags *flags); + + +/* interpreter config */ + +// Export for _testinternalcapi shared extension +PyAPI_FUNC(int) _PyInterpreterConfig_InitFromState( + PyInterpreterConfig *, + PyInterpreterState *); +PyAPI_FUNC(PyObject *) _PyInterpreterConfig_AsDict(PyInterpreterConfig *); +PyAPI_FUNC(int) _PyInterpreterConfig_InitFromDict( + PyInterpreterConfig *, + PyObject *); +PyAPI_FUNC(int) _PyInterpreterConfig_UpdateFromDict( + PyInterpreterConfig *, + PyObject *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_LIFECYCLE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pymath.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pymath.h new file mode 100644 index 00000000..7a4e1c1e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pymath.h @@ -0,0 +1,205 @@ +#ifndef Py_INTERNAL_PYMATH_H +#define Py_INTERNAL_PYMATH_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +/* _Py_ADJUST_ERANGE1(x) + * _Py_ADJUST_ERANGE2(x, y) + * Set errno to 0 before calling a libm function, and invoke one of these + * macros after, passing the function result(s) (_Py_ADJUST_ERANGE2 is useful + * for functions returning complex results). This makes two kinds of + * adjustments to errno: (A) If it looks like the platform libm set + * errno=ERANGE due to underflow, clear errno. (B) If it looks like the + * platform libm overflowed but didn't set errno, force errno to ERANGE. In + * effect, we're trying to force a useful implementation of C89 errno + * behavior. + * Caution: + * This isn't reliable. C99 no longer requires libm to set errno under + * any exceptional condition, but does require +- HUGE_VAL return + * values on overflow. A 754 box *probably* maps HUGE_VAL to a + * double infinity, and we're cool if that's so, unless the input + * was an infinity and an infinity is the expected result. A C89 + * system sets errno to ERANGE, so we check for that too. We're + * out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or + * if the returned result is a NaN, or if a C89 box returns HUGE_VAL + * in non-overflow cases. + */ +static inline void _Py_ADJUST_ERANGE1(double x) +{ + if (errno == 0) { + if (x == Py_HUGE_VAL || x == -Py_HUGE_VAL) { + errno = ERANGE; + } + } + else if (errno == ERANGE && x == 0.0) { + errno = 0; + } +} + +static inline void _Py_ADJUST_ERANGE2(double x, double y) +{ + if (x == Py_HUGE_VAL || x == -Py_HUGE_VAL || + y == Py_HUGE_VAL || y == -Py_HUGE_VAL) + { + if (errno == 0) { + errno = ERANGE; + } + } + else if (errno == ERANGE) { + errno = 0; + } +} + + +//--- HAVE_PY_SET_53BIT_PRECISION macro ------------------------------------ +// +// The functions _Py_dg_strtod() and _Py_dg_dtoa() in Python/dtoa.c (which are +// required to support the short float repr introduced in Python 3.1) require +// that the floating-point unit that's being used for arithmetic operations on +// C doubles is set to use 53-bit precision. It also requires that the FPU +// rounding mode is round-half-to-even, but that's less often an issue. +// +// If your FPU isn't already set to 53-bit precision/round-half-to-even, and +// you want to make use of _Py_dg_strtod() and _Py_dg_dtoa(), then you should: +// +// #define HAVE_PY_SET_53BIT_PRECISION 1 +// +// and also give appropriate definitions for the following three macros: +// +// * _Py_SET_53BIT_PRECISION_HEADER: any variable declarations needed to +// use the two macros below. +// * _Py_SET_53BIT_PRECISION_START: store original FPU settings, and +// set FPU to 53-bit precision/round-half-to-even +// * _Py_SET_53BIT_PRECISION_END: restore original FPU settings +// +// The macros are designed to be used within a single C function: see +// Python/pystrtod.c for an example of their use. + + +// Get and set x87 control word for gcc/x86 +#ifdef HAVE_GCC_ASM_FOR_X87 +#define HAVE_PY_SET_53BIT_PRECISION 1 + +// Functions defined in Python/pymath.c +extern unsigned short _Py_get_387controlword(void); +extern void _Py_set_387controlword(unsigned short); + +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned short old_387controlword, new_387controlword +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + old_387controlword = _Py_get_387controlword(); \ + new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ + if (new_387controlword != old_387controlword) { \ + _Py_set_387controlword(new_387controlword); \ + } \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + do { \ + if (new_387controlword != old_387controlword) { \ + _Py_set_387controlword(old_387controlword); \ + } \ + } while (0) +#endif + +// Get and set x87 control word for VisualStudio/x86. +// x87 is not supported in 64-bit or ARM. +#if defined(_MSC_VER) && !defined(_WIN64) && !defined(_M_ARM) +#define HAVE_PY_SET_53BIT_PRECISION 1 + +#include // __control87_2() + +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned int old_387controlword, new_387controlword, out_387controlword + // We use the __control87_2 function to set only the x87 control word. + // The SSE control word is unaffected. +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + __control87_2(0, 0, &old_387controlword, NULL); \ + new_387controlword = \ + (old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \ + if (new_387controlword != old_387controlword) { \ + __control87_2(new_387controlword, _MCW_PC | _MCW_RC, \ + &out_387controlword, NULL); \ + } \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + do { \ + if (new_387controlword != old_387controlword) { \ + __control87_2(old_387controlword, _MCW_PC | _MCW_RC, \ + &out_387controlword, NULL); \ + } \ + } while (0) +#endif + + +// MC68881 +#ifdef HAVE_GCC_ASM_FOR_MC68881 +#define HAVE_PY_SET_53BIT_PRECISION 1 +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned int old_fpcr, new_fpcr +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + __asm__ ("fmove.l %%fpcr,%0" : "=g" (old_fpcr)); \ + /* Set double precision / round to nearest. */ \ + new_fpcr = (old_fpcr & ~0xf0) | 0x80; \ + if (new_fpcr != old_fpcr) { \ + __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (new_fpcr));\ + } \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + do { \ + if (new_fpcr != old_fpcr) { \ + __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (old_fpcr)); \ + } \ + } while (0) +#endif + +// Default definitions are empty +#ifndef _Py_SET_53BIT_PRECISION_HEADER +# define _Py_SET_53BIT_PRECISION_HEADER +# define _Py_SET_53BIT_PRECISION_START +# define _Py_SET_53BIT_PRECISION_END +#endif + + +//--- _PY_SHORT_FLOAT_REPR macro ------------------------------------------- + +// If we can't guarantee 53-bit precision, don't use the code +// in Python/dtoa.c, but fall back to standard code. This +// means that repr of a float will be long (17 significant digits). +// +// Realistically, there are two things that could go wrong: +// +// (1) doubles aren't IEEE 754 doubles, or +// (2) we're on x86 with the rounding precision set to 64-bits +// (extended precision), and we don't know how to change +// the rounding precision. +#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) +# define _PY_SHORT_FLOAT_REPR 0 +#endif + +// Double rounding is symptomatic of use of extended precision on x86. +// If we're seeing double rounding, and we don't have any mechanism available +// for changing the FPU rounding precision, then don't use Python/dtoa.c. +#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION) +# define _PY_SHORT_FLOAT_REPR 0 +#endif + +#ifndef _PY_SHORT_FLOAT_REPR +# define _PY_SHORT_FLOAT_REPR 1 +#endif + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PYMATH_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pymem.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pymem.h new file mode 100644 index 00000000..e9593dbf --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pymem.h @@ -0,0 +1,138 @@ +#ifndef Py_INTERNAL_PYMEM_H +#define Py_INTERNAL_PYMEM_H + +#include "pycore_llist.h" // struct llist_node +#include "pycore_lock.h" // PyMutex + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Try to get the allocators name set by _PyMem_SetupAllocators(). +// Return NULL if unknown. +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void); + +// strdup() using PyMem_RawMalloc() +extern char* _PyMem_RawStrdup(const char *str); + +// strdup() using PyMem_Malloc(). +// Export for '_pickle ' shared extension. +PyAPI_FUNC(char*) _PyMem_Strdup(const char *str); + +// wcsdup() using PyMem_RawMalloc() +extern wchar_t* _PyMem_RawWcsdup(const wchar_t *str); + +typedef struct { + /* We tag each block with an API ID in order to tag API violations */ + char api_id; + PyMemAllocatorEx alloc; +} debug_alloc_api_t; + +struct _pymem_allocators { + PyMutex mutex; + struct { + PyMemAllocatorEx raw; + PyMemAllocatorEx mem; + PyMemAllocatorEx obj; + } standard; + struct { + debug_alloc_api_t raw; + debug_alloc_api_t mem; + debug_alloc_api_t obj; + } debug; + int is_debug_enabled; + PyObjectArenaAllocator obj_arena; +}; + +struct _Py_mem_interp_free_queue { + int has_work; // true if the queue is not empty + PyMutex mutex; // protects the queue + struct llist_node head; // queue of _mem_work_chunk items +}; + +/* Set the memory allocator of the specified domain to the default. + Save the old allocator into *old_alloc if it's non-NULL. + Return on success, or return -1 if the domain is unknown. */ +extern int _PyMem_SetDefaultAllocator( + PyMemAllocatorDomain domain, + PyMemAllocatorEx *old_alloc); + +/* Special bytes broadcast into debug memory blocks at appropriate times. + Strings of these are unlikely to be valid addresses, floats, ints or + 7-bit ASCII. + + - PYMEM_CLEANBYTE: clean (newly allocated) memory + - PYMEM_DEADBYTE dead (newly freed) memory + - PYMEM_FORBIDDENBYTE: untouchable bytes at each end of a block + + Byte patterns 0xCB, 0xDB and 0xFB have been replaced with 0xCD, 0xDD and + 0xFD to use the same values as Windows CRT debug malloc() and free(). + If modified, _PyMem_IsPtrFreed() should be updated as well. */ +#define PYMEM_CLEANBYTE 0xCD +#define PYMEM_DEADBYTE 0xDD +#define PYMEM_FORBIDDENBYTE 0xFD + +/* Heuristic checking if a pointer value is newly allocated + (uninitialized), newly freed or NULL (is equal to zero). + + The pointer is not dereferenced, only the pointer value is checked. + + The heuristic relies on the debug hooks on Python memory allocators which + fills newly allocated memory with CLEANBYTE (0xCD) and newly freed memory + with DEADBYTE (0xDD). Detect also "untouchable bytes" marked + with FORBIDDENBYTE (0xFD). */ +static inline int _PyMem_IsPtrFreed(const void *ptr) +{ + uintptr_t value = (uintptr_t)ptr; +#if SIZEOF_VOID_P == 8 + return (value == 0 + || value == (uintptr_t)0xCDCDCDCDCDCDCDCD + || value == (uintptr_t)0xDDDDDDDDDDDDDDDD + || value == (uintptr_t)0xFDFDFDFDFDFDFDFD); +#elif SIZEOF_VOID_P == 4 + return (value == 0 + || value == (uintptr_t)0xCDCDCDCD + || value == (uintptr_t)0xDDDDDDDD + || value == (uintptr_t)0xFDFDFDFD); +#else +# error "unknown pointer size" +#endif +} + +extern int _PyMem_GetAllocatorName( + const char *name, + PyMemAllocatorName *allocator); + +/* Configure the Python memory allocators. + Pass PYMEM_ALLOCATOR_DEFAULT to use default allocators. + PYMEM_ALLOCATOR_NOT_SET does nothing. */ +extern int _PyMem_SetupAllocators(PyMemAllocatorName allocator); + +/* Is the debug allocator enabled? */ +extern int _PyMem_DebugEnabled(void); + +// Enqueue a pointer to be freed possibly after some delay. +extern void _PyMem_FreeDelayed(void *ptr, size_t size); + +// Enqueue an object to be freed possibly after some delay +extern void _PyObject_FreeDelayed(void *ptr); + +// Periodically process delayed free requests. +extern void _PyMem_ProcessDelayed(PyThreadState *tstate); + +// Abandon all thread-local delayed free requests and push them to the +// interpreter's queue. +extern void _PyMem_AbandonDelayed(PyThreadState *tstate); + +// On interpreter shutdown, frees all delayed free requests. +extern void _PyMem_FiniDelayed(PyInterpreterState *interp); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_PYMEM_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pymem_init.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pymem_init.h new file mode 100644 index 00000000..c593edc8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pymem_init.h @@ -0,0 +1,103 @@ +#ifndef Py_INTERNAL_PYMEM_INIT_H +#define Py_INTERNAL_PYMEM_INIT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +/********************************/ +/* the allocators' initializers */ + +extern void * _PyMem_RawMalloc(void *, size_t); +extern void * _PyMem_RawCalloc(void *, size_t, size_t); +extern void * _PyMem_RawRealloc(void *, void *, size_t); +extern void _PyMem_RawFree(void *, void *); +#define PYRAW_ALLOC {NULL, _PyMem_RawMalloc, _PyMem_RawCalloc, _PyMem_RawRealloc, _PyMem_RawFree} + +#ifdef Py_GIL_DISABLED +// Py_GIL_DISABLED requires mimalloc +extern void* _PyObject_MiMalloc(void *, size_t); +extern void* _PyObject_MiCalloc(void *, size_t, size_t); +extern void _PyObject_MiFree(void *, void *); +extern void* _PyObject_MiRealloc(void *, void *, size_t); +# define PYOBJ_ALLOC {NULL, _PyObject_MiMalloc, _PyObject_MiCalloc, _PyObject_MiRealloc, _PyObject_MiFree} +extern void* _PyMem_MiMalloc(void *, size_t); +extern void* _PyMem_MiCalloc(void *, size_t, size_t); +extern void _PyMem_MiFree(void *, void *); +extern void* _PyMem_MiRealloc(void *, void *, size_t); +# define PYMEM_ALLOC {NULL, _PyMem_MiMalloc, _PyMem_MiCalloc, _PyMem_MiRealloc, _PyMem_MiFree} +#elif defined(WITH_PYMALLOC) +extern void* _PyObject_Malloc(void *, size_t); +extern void* _PyObject_Calloc(void *, size_t, size_t); +extern void _PyObject_Free(void *, void *); +extern void* _PyObject_Realloc(void *, void *, size_t); +# define PYOBJ_ALLOC {NULL, _PyObject_Malloc, _PyObject_Calloc, _PyObject_Realloc, _PyObject_Free} +# define PYMEM_ALLOC PYOBJ_ALLOC +#else +# define PYOBJ_ALLOC PYRAW_ALLOC +# define PYMEM_ALLOC PYOBJ_ALLOC +#endif // WITH_PYMALLOC + + +extern void* _PyMem_DebugRawMalloc(void *, size_t); +extern void* _PyMem_DebugRawCalloc(void *, size_t, size_t); +extern void* _PyMem_DebugRawRealloc(void *, void *, size_t); +extern void _PyMem_DebugRawFree(void *, void *); + +extern void* _PyMem_DebugMalloc(void *, size_t); +extern void* _PyMem_DebugCalloc(void *, size_t, size_t); +extern void* _PyMem_DebugRealloc(void *, void *, size_t); +extern void _PyMem_DebugFree(void *, void *); + +#define PYDBGRAW_ALLOC(runtime) \ + {&(runtime).allocators.debug.raw, _PyMem_DebugRawMalloc, _PyMem_DebugRawCalloc, _PyMem_DebugRawRealloc, _PyMem_DebugRawFree} +#define PYDBGMEM_ALLOC(runtime) \ + {&(runtime).allocators.debug.mem, _PyMem_DebugMalloc, _PyMem_DebugCalloc, _PyMem_DebugRealloc, _PyMem_DebugFree} +#define PYDBGOBJ_ALLOC(runtime) \ + {&(runtime).allocators.debug.obj, _PyMem_DebugMalloc, _PyMem_DebugCalloc, _PyMem_DebugRealloc, _PyMem_DebugFree} + +extern void * _PyMem_ArenaAlloc(void *, size_t); +extern void _PyMem_ArenaFree(void *, void *, size_t); + +#ifdef Py_DEBUG +# define _pymem_allocators_standard_INIT(runtime) \ + { \ + PYDBGRAW_ALLOC(runtime), \ + PYDBGMEM_ALLOC(runtime), \ + PYDBGOBJ_ALLOC(runtime), \ + } +# define _pymem_is_debug_enabled_INIT 1 +#else +# define _pymem_allocators_standard_INIT(runtime) \ + { \ + PYRAW_ALLOC, \ + PYMEM_ALLOC, \ + PYOBJ_ALLOC, \ + } +# define _pymem_is_debug_enabled_INIT 0 +#endif + +#define _pymem_allocators_debug_INIT \ + { \ + {'r', PYRAW_ALLOC}, \ + {'m', PYMEM_ALLOC}, \ + {'o', PYOBJ_ALLOC}, \ + } + +# define _pymem_allocators_obj_arena_INIT \ + { NULL, _PyMem_ArenaAlloc, _PyMem_ArenaFree } + + +#define _Py_mem_free_queue_INIT(queue) \ + { \ + .head = LLIST_INIT(queue.head), \ + } + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_PYMEM_INIT_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pystate.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pystate.h new file mode 100644 index 00000000..b0e72523 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pystate.h @@ -0,0 +1,299 @@ +#ifndef Py_INTERNAL_PYSTATE_H +#define Py_INTERNAL_PYSTATE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_freelist.h" // _PyFreeListState +#include "pycore_runtime.h" // _PyRuntime +#include "pycore_tstate.h" // _PyThreadStateImpl + + +// Values for PyThreadState.state. A thread must be in the "attached" state +// before calling most Python APIs. If the GIL is enabled, then "attached" +// implies that the thread holds the GIL and "detached" implies that the +// thread does not hold the GIL (or is in the process of releasing it). In +// `--disable-gil` builds, multiple threads may be "attached" to the same +// interpreter at the same time. Only the "bound" thread may perform the +// transitions between "attached" and "detached" on its own PyThreadState. +// +// The "suspended" state is used to implement stop-the-world pauses, such as +// for cyclic garbage collection. It is only used in `--disable-gil` builds. +// The "suspended" state is similar to the "detached" state in that in both +// states the thread is not allowed to call most Python APIs. However, unlike +// the "detached" state, a thread may not transition itself out from the +// "suspended" state. Only the thread performing a stop-the-world pause may +// transition a thread from the "suspended" state back to the "detached" state. +// +// State transition diagram: +// +// (bound thread) (stop-the-world thread) +// [attached] <-> [detached] <-> [suspended] +// | ^ +// +---------------------------->---------------------------+ +// (bound thread) +// +// The (bound thread) and (stop-the-world thread) labels indicate which thread +// is allowed to perform the transition. +#define _Py_THREAD_DETACHED 0 +#define _Py_THREAD_ATTACHED 1 +#define _Py_THREAD_SUSPENDED 2 + + +/* Check if the current thread is the main thread. + Use _Py_IsMainInterpreter() to check if it's the main interpreter. */ +static inline int +_Py_IsMainThread(void) +{ + unsigned long thread = PyThread_get_thread_ident(); + return (thread == _PyRuntime.main_thread); +} + + +static inline PyInterpreterState * +_PyInterpreterState_Main(void) +{ + return _PyRuntime.interpreters.main; +} + +static inline int +_Py_IsMainInterpreter(PyInterpreterState *interp) +{ + return (interp == _PyInterpreterState_Main()); +} + +static inline int +_Py_IsMainInterpreterFinalizing(PyInterpreterState *interp) +{ + /* bpo-39877: Access _PyRuntime directly rather than using + tstate->interp->runtime to support calls from Python daemon threads. + After Py_Finalize() has been called, tstate can be a dangling pointer: + point to PyThreadState freed memory. */ + return (_PyRuntimeState_GetFinalizing(&_PyRuntime) != NULL && + interp == &_PyRuntime._main_interpreter); +} + +// Export for _interpreters module. +PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *); + +// Export for _interpreters module. +PyAPI_FUNC(int) _PyInterpreterState_SetRunningMain(PyInterpreterState *); +PyAPI_FUNC(void) _PyInterpreterState_SetNotRunningMain(PyInterpreterState *); +PyAPI_FUNC(int) _PyInterpreterState_IsRunningMain(PyInterpreterState *); +PyAPI_FUNC(int) _PyInterpreterState_FailIfRunningMain(PyInterpreterState *); + +extern int _PyThreadState_IsRunningMain(PyThreadState *); +extern void _PyInterpreterState_ReinitRunningMain(PyThreadState *); + + +static inline const PyConfig * +_Py_GetMainConfig(void) +{ + PyInterpreterState *interp = _PyInterpreterState_Main(); + if (interp == NULL) { + return NULL; + } + return _PyInterpreterState_GetConfig(interp); +} + + +/* Only handle signals on the main thread of the main interpreter. */ +static inline int +_Py_ThreadCanHandleSignals(PyInterpreterState *interp) +{ + return (_Py_IsMainThread() && _Py_IsMainInterpreter(interp)); +} + + +/* Variable and static inline functions for in-line access to current thread + and interpreter state */ + +#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE) +extern _Py_thread_local PyThreadState *_Py_tss_tstate; +#endif + +#ifndef NDEBUG +extern int _PyThreadState_CheckConsistency(PyThreadState *tstate); +#endif + +int _PyThreadState_MustExit(PyThreadState *tstate); + +// Export for most shared extensions, used via _PyThreadState_GET() static +// inline function. +PyAPI_FUNC(PyThreadState *) _PyThreadState_GetCurrent(void); + +/* Get the current Python thread state. + + This function is unsafe: it does not check for error and it can return NULL. + + The caller must hold the GIL. + + See also PyThreadState_Get() and PyThreadState_GetUnchecked(). */ +static inline PyThreadState* +_PyThreadState_GET(void) +{ +#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE) + return _Py_tss_tstate; +#else + return _PyThreadState_GetCurrent(); +#endif +} + +// Attaches the current thread to the interpreter. +// +// This may block while acquiring the GIL (if the GIL is enabled) or while +// waiting for a stop-the-world pause (if the GIL is disabled). +// +// High-level code should generally call PyEval_RestoreThread() instead, which +// calls this function. +extern void _PyThreadState_Attach(PyThreadState *tstate); + +// Detaches the current thread from the interpreter. +// +// High-level code should generally call PyEval_SaveThread() instead, which +// calls this function. +extern void _PyThreadState_Detach(PyThreadState *tstate); + +// Detaches the current thread to the "suspended" state if a stop-the-world +// pause is in progress. +// +// If there is no stop-the-world pause in progress, then the thread switches +// to the "detached" state. +extern void _PyThreadState_Suspend(PyThreadState *tstate); + +// Perform a stop-the-world pause for all threads in the all interpreters. +// +// Threads in the "attached" state are paused and transitioned to the "GC" +// state. Threads in the "detached" state switch to the "GC" state, preventing +// them from reattaching until the stop-the-world pause is complete. +// +// NOTE: This is a no-op outside of Py_GIL_DISABLED builds. +extern void _PyEval_StopTheWorldAll(_PyRuntimeState *runtime); +extern void _PyEval_StartTheWorldAll(_PyRuntimeState *runtime); + +// Perform a stop-the-world pause for threads in the specified interpreter. +// +// NOTE: This is a no-op outside of Py_GIL_DISABLED builds. +extern void _PyEval_StopTheWorld(PyInterpreterState *interp); +extern void _PyEval_StartTheWorld(PyInterpreterState *interp); + + +static inline void +_Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate) +{ + if (tstate == NULL) { + _Py_FatalErrorFunc(func, + "the function must be called with the GIL held, " + "after Python initialization and before Python finalization, " + "but the GIL is released (the current Python thread state is NULL)"); + } +} + +// Call Py_FatalError() if tstate is NULL +#define _Py_EnsureTstateNotNULL(tstate) \ + _Py_EnsureFuncTstateNotNULL(__func__, (tstate)) + + +/* Get the current interpreter state. + + The function is unsafe: it does not check for error and it can return NULL. + + The caller must hold the GIL. + + See also PyInterpreterState_Get() + and _PyGILState_GetInterpreterStateUnsafe(). */ +static inline PyInterpreterState* _PyInterpreterState_GET(void) { + PyThreadState *tstate = _PyThreadState_GET(); +#ifdef Py_DEBUG + _Py_EnsureTstateNotNULL(tstate); +#endif + return tstate->interp; +} + + +// PyThreadState functions + +// Export for _testinternalcapi +PyAPI_FUNC(PyThreadState *) _PyThreadState_New( + PyInterpreterState *interp, + int whence); +extern void _PyThreadState_Bind(PyThreadState *tstate); +PyAPI_FUNC(PyThreadState *) _PyThreadState_NewBound( + PyInterpreterState *interp, + int whence); +extern PyThreadState * _PyThreadState_RemoveExcept(PyThreadState *tstate); +extern void _PyThreadState_DeleteList(PyThreadState *list); +extern void _PyThreadState_ClearMimallocHeaps(PyThreadState *tstate); + +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(PyObject*) _PyThreadState_GetDict(PyThreadState *tstate); + +/* The implementation of sys._current_exceptions() Returns a dict mapping + thread id to that thread's current exception. +*/ +extern PyObject* _PyThread_CurrentExceptions(void); + + +/* Other */ + +extern PyThreadState * _PyThreadState_Swap( + _PyRuntimeState *runtime, + PyThreadState *newts); + +extern PyStatus _PyInterpreterState_Enable(_PyRuntimeState *runtime); + +#ifdef HAVE_FORK +extern PyStatus _PyInterpreterState_DeleteExceptMain(_PyRuntimeState *runtime); +extern void _PySignal_AfterFork(void); +#endif + +// Export for the stable ABI +PyAPI_FUNC(int) _PyState_AddModule( + PyThreadState *tstate, + PyObject* module, + PyModuleDef* def); + + +extern int _PyOS_InterruptOccurred(PyThreadState *tstate); + +#define HEAD_LOCK(runtime) \ + PyMutex_LockFlags(&(runtime)->interpreters.mutex, _Py_LOCK_DONT_DETACH) +#define HEAD_UNLOCK(runtime) \ + PyMutex_Unlock(&(runtime)->interpreters.mutex) + +// Get the configuration of the current interpreter. +// The caller must hold the GIL. +// Export for test_peg_generator. +PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void); + +// Get the single PyInterpreterState used by this process' GILState +// implementation. +// +// This function doesn't check for error. Return NULL before _PyGILState_Init() +// is called and after _PyGILState_Fini() is called. +// +// See also PyInterpreterState_Get() and _PyInterpreterState_GET(). +extern PyInterpreterState* _PyGILState_GetInterpreterStateUnsafe(void); + +static inline struct _Py_object_freelists* _Py_object_freelists_GET(void) +{ + PyThreadState *tstate = _PyThreadState_GET(); +#ifdef Py_DEBUG + _Py_EnsureTstateNotNULL(tstate); +#endif + +#ifdef Py_GIL_DISABLED + return &((_PyThreadStateImpl*)tstate)->freelists; +#else + return &tstate->interp->object_state.freelists; +#endif +} + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PYSTATE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pystats.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pystats.h new file mode 100644 index 00000000..f8af398a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pystats.h @@ -0,0 +1,21 @@ +#ifndef Py_INTERNAL_PYSTATS_H +#define Py_INTERNAL_PYSTATS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#ifdef Py_STATS +extern void _Py_StatsOn(void); +extern void _Py_StatsOff(void); +extern void _Py_StatsClear(void); +extern int _Py_PrintSpecializationStats(int to_file); +#endif + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_PYSTATS_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pythonrun.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pythonrun.h new file mode 100644 index 00000000..0bfc5704 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pythonrun.h @@ -0,0 +1,39 @@ +#ifndef Py_INTERNAL_PYTHONRUN_H +#define Py_INTERNAL_PYTHONRUN_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern int _PyRun_SimpleFileObject( + FILE *fp, + PyObject *filename, + int closeit, + PyCompilerFlags *flags); + +extern int _PyRun_AnyFileObject( + FILE *fp, + PyObject *filename, + int closeit, + PyCompilerFlags *flags); + +extern int _PyRun_InteractiveLoopObject( + FILE *fp, + PyObject *filename, + PyCompilerFlags *flags); + +extern const char* _Py_SourceAsString( + PyObject *cmd, + const char *funcname, + const char *what, + PyCompilerFlags *cf, + PyObject **cmd_copy); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_PYTHONRUN_H + diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_pythread.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_pythread.h new file mode 100644 index 00000000..3610c625 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_pythread.h @@ -0,0 +1,159 @@ +#ifndef Py_INTERNAL_PYTHREAD_H +#define Py_INTERNAL_PYTHREAD_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "dynamic_annotations.h" // _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX +#include "pycore_llist.h" // struct llist_node + +// Get _POSIX_THREADS and _POSIX_SEMAPHORES macros if available +#if (defined(HAVE_UNISTD_H) && !defined(_POSIX_THREADS) \ + && !defined(_POSIX_SEMAPHORES)) +# include // _POSIX_THREADS, _POSIX_SEMAPHORES +#endif +#if (defined(HAVE_PTHREAD_H) && !defined(_POSIX_THREADS) \ + && !defined(_POSIX_SEMAPHORES)) + // This means pthreads are not implemented in libc headers, hence the macro + // not present in . But they still can be implemented as an + // external library (e.g. gnu pth in pthread emulation) +# include // _POSIX_THREADS, _POSIX_SEMAPHORES +#endif +#if !defined(_POSIX_THREADS) && defined(__hpux) && defined(_SC_THREADS) + // Check if we're running on HP-UX and _SC_THREADS is defined. If so, then + // enough of the POSIX threads package is implemented to support Python + // threads. + // + // This is valid for HP-UX 11.23 running on an ia64 system. If needed, add + // a check of __ia64 to verify that we're running on an ia64 system instead + // of a pa-risc system. +# define _POSIX_THREADS +#endif + + +#if defined(_POSIX_THREADS) || defined(HAVE_PTHREAD_STUBS) +# define _USE_PTHREADS +#endif + +#if defined(_USE_PTHREADS) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) +// monotonic is supported statically. It doesn't mean it works on runtime. +# define CONDATTR_MONOTONIC +#endif + + +#if defined(HAVE_PTHREAD_STUBS) +#include "cpython/pthread_stubs.h" // PTHREAD_KEYS_MAX +#include // bool + +// pthread_key +struct py_stub_tls_entry { + bool in_use; + void *value; +}; +#endif + +struct _pythread_runtime_state { + int initialized; + +#ifdef _USE_PTHREADS + // This matches when thread_pthread.h is used. + struct { + /* NULL when pthread_condattr_setclock(CLOCK_MONOTONIC) is not supported. */ + pthread_condattr_t *ptr; +# ifdef CONDATTR_MONOTONIC + /* The value to which condattr_monotonic is set. */ + pthread_condattr_t val; +# endif + } _condattr_monotonic; + +#endif // USE_PTHREADS + +#if defined(HAVE_PTHREAD_STUBS) + struct { + struct py_stub_tls_entry tls_entries[PTHREAD_KEYS_MAX]; + } stubs; +#endif + + // Linked list of ThreadHandles + struct llist_node handles; +}; + +#define _pythread_RUNTIME_INIT(pythread) \ + { \ + .handles = LLIST_INIT(pythread.handles), \ + } + +#ifdef HAVE_FORK +/* Private function to reinitialize a lock at fork in the child process. + Reset the lock to the unlocked state. + Return 0 on success, return -1 on error. */ +extern int _PyThread_at_fork_reinit(PyThread_type_lock *lock); +extern void _PyThread_AfterFork(struct _pythread_runtime_state *state); +#endif /* HAVE_FORK */ + + +// unset: -1 seconds, in nanoseconds +#define PyThread_UNSET_TIMEOUT ((PyTime_t)(-1 * 1000 * 1000 * 1000)) + +// Exported for the _interpchannels module. +PyAPI_FUNC(int) PyThread_ParseTimeoutArg( + PyObject *arg, + int blocking, + PY_TIMEOUT_T *timeout); + +/* Helper to acquire an interruptible lock with a timeout. If the lock acquire + * is interrupted, signal handlers are run, and if they raise an exception, + * PY_LOCK_INTR is returned. Otherwise, PY_LOCK_ACQUIRED or PY_LOCK_FAILURE + * are returned, depending on whether the lock can be acquired within the + * timeout. + */ +// Exported for the _interpchannels module. +PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed_with_retries( + PyThread_type_lock, + PY_TIMEOUT_T microseconds); + +typedef unsigned long long PyThread_ident_t; +typedef Py_uintptr_t PyThread_handle_t; + +#define PY_FORMAT_THREAD_IDENT_T "llu" +#define Py_PARSE_THREAD_IDENT_T "K" + +PyAPI_FUNC(PyThread_ident_t) PyThread_get_thread_ident_ex(void); + +/* Thread joining APIs. + * + * These APIs have a strict contract: + * - Either PyThread_join_thread or PyThread_detach_thread must be called + * exactly once with the given handle. + * - Calling neither PyThread_join_thread nor PyThread_detach_thread results + * in a resource leak until the end of the process. + * - Any other usage, such as calling both PyThread_join_thread and + * PyThread_detach_thread, or calling them more than once (including + * simultaneously), results in undefined behavior. + */ +PyAPI_FUNC(int) PyThread_start_joinable_thread(void (*func)(void *), + void *arg, + PyThread_ident_t* ident, + PyThread_handle_t* handle); +/* + * Join a thread started with `PyThread_start_joinable_thread`. + * This function cannot be interrupted. It returns 0 on success, + * a non-zero value on failure. + */ +PyAPI_FUNC(int) PyThread_join_thread(PyThread_handle_t); +/* + * Detach a thread started with `PyThread_start_joinable_thread`, such + * that its resources are relased as soon as it exits. + * This function cannot be interrupted. It returns 0 on success, + * a non-zero value on failure. + */ +PyAPI_FUNC(int) PyThread_detach_thread(PyThread_handle_t); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PYTHREAD_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_qsbr.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_qsbr.h new file mode 100644 index 00000000..84e9d98d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_qsbr.h @@ -0,0 +1,173 @@ +// The QSBR APIs (quiescent state-based reclamation) provide a mechanism for +// the free-threaded build to safely reclaim memory when there may be +// concurrent accesses. +// +// Many operations in the free-threaded build are protected by locks. However, +// in some cases, we want to allow reads to happen concurrently with updates. +// In this case, we need to delay freeing ("reclaiming") any memory that may be +// concurrently accessed by a reader. The QSBR APIs provide a way to do this. +#ifndef Py_INTERNAL_QSBR_H +#define Py_INTERNAL_QSBR_H + +#include +#include +#include "pycore_lock.h" // PyMutex + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// The shared write sequence is always odd and incremented by two. Detached +// threads are indicated by a read sequence of zero. This avoids collisions +// between the offline state and any valid sequence number even if the +// sequences numbers wrap around. +#define QSBR_OFFLINE 0 +#define QSBR_INITIAL 1 +#define QSBR_INCR 2 + +// Wrap-around safe comparison. This is a holdover from the FreeBSD +// implementation, which uses 32-bit sequence numbers. We currently use 64-bit +// sequence numbers, so wrap-around is unlikely. +#define QSBR_LT(a, b) ((int64_t)((a)-(b)) < 0) +#define QSBR_LEQ(a, b) ((int64_t)((a)-(b)) <= 0) + +struct _qsbr_shared; +struct _PyThreadStateImpl; // forward declare to avoid circular dependency + +// Per-thread state +struct _qsbr_thread_state { + // Last observed write sequence (or 0 if detached) + uint64_t seq; + + // Shared (per-interpreter) QSBR state + struct _qsbr_shared *shared; + + // Thread state (or NULL) + PyThreadState *tstate; + + // Number of held items added by this thread since the last write sequence + // advance + int deferred_count; + + // Estimate for the amount of memory that is held by this thread since + // the last write sequence advance + size_t deferred_memory; + + // Amount of memory in mimalloc pages deferred from collection. When + // deferred, they are prevented from being used for a different size class + // and in a different thread. + size_t deferred_page_memory; + + // True if the deferred memory frees should be processed. + bool should_process; + + // Is this thread state allocated? + bool allocated; + struct _qsbr_thread_state *freelist_next; +}; + +// Padding to avoid false sharing +struct _qsbr_pad { + struct _qsbr_thread_state qsbr; + char __padding[64 - sizeof(struct _qsbr_thread_state)]; +}; + +// Per-interpreter state +struct _qsbr_shared { + // Write sequence: always odd, incremented by two + uint64_t wr_seq; + + // Minimum observed read sequence of all QSBR thread states + uint64_t rd_seq; + + // Array of QSBR thread states. + struct _qsbr_pad *array; + Py_ssize_t size; + + // Freelist of unused _qsbr_thread_states (protected by mutex) + PyMutex mutex; + struct _qsbr_thread_state *freelist; +}; + +static inline uint64_t +_Py_qsbr_shared_current(struct _qsbr_shared *shared) +{ + return _Py_atomic_load_uint64_acquire(&shared->wr_seq); +} + +// Reports a quiescent state: the caller no longer holds any pointer to shared +// data not protected by locks or reference counts. +static inline void +_Py_qsbr_quiescent_state(struct _qsbr_thread_state *qsbr) +{ + uint64_t seq = _Py_qsbr_shared_current(qsbr->shared); + _Py_atomic_store_uint64_release(&qsbr->seq, seq); +} + +// Have the read sequences advanced to the given goal? Like `_Py_qsbr_poll()`, +// but does not perform a scan of threads. +static inline bool +_Py_qbsr_goal_reached(struct _qsbr_thread_state *qsbr, uint64_t goal) +{ + uint64_t rd_seq = _Py_atomic_load_uint64(&qsbr->shared->rd_seq); + return QSBR_LEQ(goal, rd_seq); +} + +// Advance the write sequence and return the new goal. This should be called +// after data is removed. The returned goal is used with `_Py_qsbr_poll()` to +// determine when it is safe to reclaim (free) the memory. +extern uint64_t +_Py_qsbr_advance(struct _qsbr_shared *shared); + +// Return the next value for the write sequence (current plus the increment). +extern uint64_t +_Py_qsbr_shared_next(struct _qsbr_shared *shared); + +// Return true if deferred memory frees held by QSBR should be processed to +// determine if they can be safely freed. +static inline bool +_Py_qsbr_should_process(struct _qsbr_thread_state *qsbr) +{ + return qsbr->should_process; +} + +// Have the read sequences advanced to the given goal? If this returns true, +// it safe to reclaim any memory tagged with the goal (or earlier goal). +extern bool +_Py_qsbr_poll(struct _qsbr_thread_state *qsbr, uint64_t goal); + +// Called when thread attaches to interpreter +extern void +_Py_qsbr_attach(struct _qsbr_thread_state *qsbr); + +// Called when thread detaches from interpreter +extern void +_Py_qsbr_detach(struct _qsbr_thread_state *qsbr); + +// Reserves (allocates) a QSBR state and returns its index. +extern Py_ssize_t +_Py_qsbr_reserve(PyInterpreterState *interp); + +// Associates a PyThreadState with the QSBR state at the given index +extern void +_Py_qsbr_register(struct _PyThreadStateImpl *tstate, + PyInterpreterState *interp, Py_ssize_t index); + +// Disassociates a PyThreadState from the QSBR state and frees the QSBR state. +extern void +_Py_qsbr_unregister(PyThreadState *tstate); + +extern void +_Py_qsbr_fini(PyInterpreterState *interp); + +extern void +_Py_qsbr_after_fork(struct _PyThreadStateImpl *tstate); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_QSBR_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_range.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_range.h new file mode 100644 index 00000000..bf045ec4 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_range.h @@ -0,0 +1,21 @@ +#ifndef Py_INTERNAL_RANGE_H +#define Py_INTERNAL_RANGE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +typedef struct { + PyObject_HEAD + long start; + long step; + long len; +} _PyRangeIterObject; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_RANGE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime.h new file mode 100644 index 00000000..ed028944 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime.h @@ -0,0 +1,410 @@ +#ifndef Py_INTERNAL_RUNTIME_H +#define Py_INTERNAL_RUNTIME_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_atexit.h" // struct _atexit_runtime_state +#include "pycore_ceval_state.h" // struct _ceval_runtime_state +#include "pycore_crossinterp.h" // struct _xidregistry +#include "pycore_faulthandler.h" // struct _faulthandler_runtime_state +#include "pycore_floatobject.h" // struct _Py_float_runtime_state +#include "pycore_import.h" // struct _import_runtime_state +#include "pycore_interp.h" // PyInterpreterState +#include "pycore_object_state.h" // struct _py_object_runtime_state +#include "pycore_parser.h" // struct _parser_runtime_state +#include "pycore_pyhash.h" // struct pyhash_runtime_state +#include "pycore_pymem.h" // struct _pymem_allocators +#include "pycore_pythread.h" // struct _pythread_runtime_state +#include "pycore_signal.h" // struct _signals_runtime_state +#include "pycore_tracemalloc.h" // struct _tracemalloc_runtime_state +#include "pycore_typeobject.h" // struct _types_runtime_state +#include "pycore_unicodeobject.h" // struct _Py_unicode_runtime_state + +struct _getargs_runtime_state { + struct _PyArg_Parser *static_parsers; +}; + +/* GIL state */ + +struct _gilstate_runtime_state { + /* bpo-26558: Flag to disable PyGILState_Check(). + If set to non-zero, PyGILState_Check() always return 1. */ + int check_enabled; + /* The single PyInterpreterState used by this process' + GILState implementation + */ + /* TODO: Given interp_main, it may be possible to kill this ref */ + PyInterpreterState *autoInterpreterState; +}; + +/* Runtime audit hook state */ + +#define _Py_Debug_Cookie "xdebugpy" + +#ifdef Py_GIL_DISABLED +# define _Py_Debug_gilruntimestate_enabled offsetof(struct _gil_runtime_state, enabled) +# define _Py_Debug_Free_Threaded 1 +#else +# define _Py_Debug_gilruntimestate_enabled 0 +# define _Py_Debug_Free_Threaded 0 +#endif +typedef struct _Py_AuditHookEntry { + struct _Py_AuditHookEntry *next; + Py_AuditHookFunction hookCFunction; + void *userData; +} _Py_AuditHookEntry; + +typedef struct _Py_DebugOffsets { + char cookie[8] _Py_NONSTRING; + uint64_t version; + uint64_t free_threaded; + // Runtime state offset; + struct _runtime_state { + uint64_t size; + uint64_t finalizing; + uint64_t interpreters_head; + } runtime_state; + + // Interpreter state offset; + struct _interpreter_state { + uint64_t size; + uint64_t id; + uint64_t next; + uint64_t threads_head; + uint64_t gc; + uint64_t imports_modules; + uint64_t sysdict; + uint64_t builtins; + uint64_t ceval_gil; + uint64_t gil_runtime_state; + uint64_t gil_runtime_state_enabled; + uint64_t gil_runtime_state_locked; + uint64_t gil_runtime_state_holder; + } interpreter_state; + + // Thread state offset; + struct _thread_state{ + uint64_t size; + uint64_t prev; + uint64_t next; + uint64_t interp; + uint64_t current_frame; + uint64_t thread_id; + uint64_t native_thread_id; + uint64_t datastack_chunk; + uint64_t status; + } thread_state; + + // InterpreterFrame offset; + struct _interpreter_frame { + uint64_t size; + uint64_t previous; + uint64_t executable; + uint64_t instr_ptr; + uint64_t localsplus; + uint64_t owner; + } interpreter_frame; + + // Code object offset; + struct _code_object { + uint64_t size; + uint64_t filename; + uint64_t name; + uint64_t qualname; + uint64_t linetable; + uint64_t firstlineno; + uint64_t argcount; + uint64_t localsplusnames; + uint64_t localspluskinds; + uint64_t co_code_adaptive; + } code_object; + + // PyObject offset; + struct _pyobject { + uint64_t size; + uint64_t ob_type; + } pyobject; + + // PyTypeObject object offset; + struct _type_object { + uint64_t size; + uint64_t tp_name; + uint64_t tp_repr; + uint64_t tp_flags; + } type_object; + + // PyTuple object offset; + struct _tuple_object { + uint64_t size; + uint64_t ob_item; + uint64_t ob_size; + } tuple_object; + + // PyList object offset; + struct _list_object { + uint64_t size; + uint64_t ob_item; + uint64_t ob_size; + } list_object; + + // PyDict object offset; + struct _dict_object { + uint64_t size; + uint64_t ma_keys; + uint64_t ma_values; + } dict_object; + + // PyFloat object offset; + struct _float_object { + uint64_t size; + uint64_t ob_fval; + } float_object; + + // PyLong object offset; + struct _long_object { + uint64_t size; + uint64_t lv_tag; + uint64_t ob_digit; + } long_object; + + // PyBytes object offset; + struct _bytes_object { + uint64_t size; + uint64_t ob_size; + uint64_t ob_sval; + } bytes_object; + + // Unicode object offset; + struct _unicode_object { + uint64_t size; + uint64_t state; + uint64_t length; + uint64_t asciiobject_size; + } unicode_object; + + // GC runtime state offset; + struct _gc { + uint64_t size; + uint64_t collecting; + } gc; +} _Py_DebugOffsets; + +/* Reference tracer state */ +struct _reftracer_runtime_state { + PyRefTracer tracer_func; + void* tracer_data; +}; + +/* Full Python runtime state */ + +/* _PyRuntimeState holds the global state for the CPython runtime. + That data is exposed in the internal API as a static variable (_PyRuntime). + */ +typedef struct pyruntimestate { + /* This field must be first to facilitate locating it by out of process + * debuggers. Out of process debuggers will use the offsets contained in this + * field to be able to locate other fields in several interpreter structures + * in a way that doesn't require them to know the exact layout of those + * structures. + * + * IMPORTANT: + * This struct is **NOT** backwards compatible between minor version of the + * interpreter and the members, order of members and size can change between + * minor versions. This struct is only guaranteed to be stable between patch + * versions for a given minor version of the interpreter. + */ + _Py_DebugOffsets debug_offsets; + + /* Has been initialized to a safe state. + + In order to be effective, this must be set to 0 during or right + after allocation. */ + int _initialized; + + /* Is running Py_PreInitialize()? */ + int preinitializing; + + /* Is Python preinitialized? Set to 1 by Py_PreInitialize() */ + int preinitialized; + + /* Is Python core initialized? Set to 1 by _Py_InitializeCore() */ + int core_initialized; + + /* Is Python fully initialized? Set to 1 by Py_Initialize() */ + int initialized; + + /* Set by Py_FinalizeEx(). Only reset to NULL if Py_Initialize() + is called again. + + Use _PyRuntimeState_GetFinalizing() and _PyRuntimeState_SetFinalizing() + to access it, don't access it directly. */ + PyThreadState *_finalizing; + /* The ID of the OS thread in which we are finalizing. */ + unsigned long _finalizing_id; + + struct pyinterpreters { + PyMutex mutex; + /* The linked list of interpreters, newest first. */ + PyInterpreterState *head; + /* The runtime's initial interpreter, which has a special role + in the operation of the runtime. It is also often the only + interpreter. */ + PyInterpreterState *main; + /* next_id is an auto-numbered sequence of small + integers. It gets initialized in _PyInterpreterState_Enable(), + which is called in Py_Initialize(), and used in + PyInterpreterState_New(). A negative interpreter ID + indicates an error occurred. The main interpreter will + always have an ID of 0. Overflow results in a RuntimeError. + If that becomes a problem later then we can adjust, e.g. by + using a Python int. */ + int64_t next_id; + } interpreters; + + /* Platform-specific identifier and PyThreadState, respectively, for the + main thread in the main interpreter. */ + unsigned long main_thread; + PyThreadState *main_tstate; + + /* ---------- IMPORTANT --------------------------- + The fields above this line are declared as early as + possible to facilitate out-of-process observability + tools. */ + + /* cross-interpreter data and utils */ + struct _xi_runtime_state xi; + + struct _pymem_allocators allocators; + struct _obmalloc_global_state obmalloc; + struct pyhash_runtime_state pyhash_state; + struct _pythread_runtime_state threads; + struct _signals_runtime_state signals; + + /* Used for the thread state bound to the current thread. */ + Py_tss_t autoTSSkey; + + /* Used instead of PyThreadState.trash when there is not current tstate. */ + Py_tss_t trashTSSkey; + + PyWideStringList orig_argv; + + struct _parser_runtime_state parser; + + struct _atexit_runtime_state atexit; + + struct _import_runtime_state imports; + struct _ceval_runtime_state ceval; + struct _gilstate_runtime_state gilstate; + struct _getargs_runtime_state getargs; + struct _fileutils_state fileutils; + struct _faulthandler_runtime_state faulthandler; + struct _tracemalloc_runtime_state tracemalloc; + struct _reftracer_runtime_state ref_tracer; + + // The rwmutex is used to prevent overlapping global and per-interpreter + // stop-the-world events. Global stop-the-world events lock the mutex + // exclusively (as a "writer"), while per-interpreter stop-the-world events + // lock it non-exclusively (as "readers"). + _PyRWMutex stoptheworld_mutex; + struct _stoptheworld_state stoptheworld; + + PyPreConfig preconfig; + + // Audit values must be preserved when Py_Initialize()/Py_Finalize() + // is called multiple times. + Py_OpenCodeHookFunction open_code_hook; + void *open_code_userdata; + struct { + PyMutex mutex; + _Py_AuditHookEntry *head; + } audit_hooks; + + struct _py_object_runtime_state object_state; + struct _Py_float_runtime_state float_state; + struct _Py_unicode_runtime_state unicode_state; + struct _types_runtime_state types; + + /* All the objects that are shared by the runtime's interpreters. */ + struct _Py_cached_objects cached_objects; + struct _Py_static_objects static_objects; + + /* The following fields are here to avoid allocation during init. + The data is exposed through _PyRuntimeState pointer fields. + These fields should not be accessed directly outside of init. + + All other _PyRuntimeState pointer fields are populated when + needed and default to NULL. + + For now there are some exceptions to that rule, which require + allocation during init. These will be addressed on a case-by-case + basis. Most notably, we don't pre-allocated the several mutex + (PyThread_type_lock) fields, because on Windows we only ever get + a pointer type. + */ + + /* _PyRuntimeState.interpreters.main */ + PyInterpreterState _main_interpreter; + +#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE) + // Used in "Python/emscripten_trampoline.c" to choose between type + // reflection trampoline and EM_JS trampoline. + bool wasm_type_reflection_available; +#endif + +} _PyRuntimeState; + + +/* other API */ + +// Export _PyRuntime for shared extensions which use it in static inline +// functions for best performance, like _Py_IsMainThread() or _Py_ID(). +// It's also made accessible for debuggers and profilers. +PyAPI_DATA(_PyRuntimeState) _PyRuntime; + +extern PyStatus _PyRuntimeState_Init(_PyRuntimeState *runtime); +extern void _PyRuntimeState_Fini(_PyRuntimeState *runtime); + +#ifdef HAVE_FORK +extern PyStatus _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime); +#endif + +/* Initialize _PyRuntimeState. + Return NULL on success, or return an error message on failure. */ +extern PyStatus _PyRuntime_Initialize(void); + +extern void _PyRuntime_Finalize(void); + + +static inline PyThreadState* +_PyRuntimeState_GetFinalizing(_PyRuntimeState *runtime) { + return (PyThreadState*)_Py_atomic_load_ptr_relaxed(&runtime->_finalizing); +} + +static inline unsigned long +_PyRuntimeState_GetFinalizingID(_PyRuntimeState *runtime) { + return _Py_atomic_load_ulong_relaxed(&runtime->_finalizing_id); +} + +static inline void +_PyRuntimeState_SetFinalizing(_PyRuntimeState *runtime, PyThreadState *tstate) { + _Py_atomic_store_ptr_relaxed(&runtime->_finalizing, tstate); + if (tstate == NULL) { + _Py_atomic_store_ulong_relaxed(&runtime->_finalizing_id, 0); + } + else { + // XXX Re-enable this assert once gh-109860 is fixed. + //assert(tstate->thread_id == PyThread_get_thread_ident()); + _Py_atomic_store_ulong_relaxed(&runtime->_finalizing_id, + tstate->thread_id); + } +} + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_RUNTIME_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime_init.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime_init.h new file mode 100644 index 00000000..7eef9edc --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime_init.h @@ -0,0 +1,329 @@ +#ifndef Py_INTERNAL_RUNTIME_INIT_H +#define Py_INTERNAL_RUNTIME_INIT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_ceval_state.h" // _PyEval_RUNTIME_PERF_INIT +#include "pycore_faulthandler.h" // _faulthandler_runtime_state_INIT +#include "pycore_floatobject.h" // _py_float_format_unknown +#include "pycore_object.h" // _PyObject_HEAD_INIT +#include "pycore_obmalloc_init.h" // _obmalloc_global_state_INIT +#include "pycore_parser.h" // _parser_runtime_state_INIT +#include "pycore_pyhash.h" // pyhash_state_INIT +#include "pycore_pymem_init.h" // _pymem_allocators_standard_INIT +#include "pycore_pythread.h" // _pythread_RUNTIME_INIT +#include "pycore_qsbr.h" // QSBR_INITIAL +#include "pycore_runtime_init_generated.h" // _Py_bytes_characters_INIT +#include "pycore_signal.h" // _signals_RUNTIME_INIT +#include "pycore_tracemalloc.h" // _tracemalloc_runtime_state_INIT + + +extern PyTypeObject _PyExc_MemoryError; + + +/* The static initializers defined here should only be used + in the runtime init code (in pystate.c and pylifecycle.c). */ + +#define _PyRuntimeState_INIT(runtime, debug_cookie) \ + { \ + .debug_offsets = { \ + .cookie = debug_cookie, \ + .version = PY_VERSION_HEX, \ + .free_threaded = _Py_Debug_Free_Threaded, \ + .runtime_state = { \ + .size = sizeof(_PyRuntimeState), \ + .finalizing = offsetof(_PyRuntimeState, _finalizing), \ + .interpreters_head = offsetof(_PyRuntimeState, interpreters.head), \ + }, \ + .interpreter_state = { \ + .size = sizeof(PyInterpreterState), \ + .id = offsetof(PyInterpreterState, id), \ + .next = offsetof(PyInterpreterState, next), \ + .threads_head = offsetof(PyInterpreterState, threads.head), \ + .gc = offsetof(PyInterpreterState, gc), \ + .imports_modules = offsetof(PyInterpreterState, imports.modules), \ + .sysdict = offsetof(PyInterpreterState, sysdict), \ + .builtins = offsetof(PyInterpreterState, builtins), \ + .ceval_gil = offsetof(PyInterpreterState, ceval.gil), \ + .gil_runtime_state = offsetof(PyInterpreterState, _gil), \ + .gil_runtime_state_enabled = _Py_Debug_gilruntimestate_enabled, \ + .gil_runtime_state_locked = offsetof(PyInterpreterState, _gil.locked), \ + .gil_runtime_state_holder = offsetof(PyInterpreterState, _gil.last_holder), \ + }, \ + .thread_state = { \ + .size = sizeof(PyThreadState), \ + .prev = offsetof(PyThreadState, prev), \ + .next = offsetof(PyThreadState, next), \ + .interp = offsetof(PyThreadState, interp), \ + .current_frame = offsetof(PyThreadState, current_frame), \ + .thread_id = offsetof(PyThreadState, thread_id), \ + .native_thread_id = offsetof(PyThreadState, native_thread_id), \ + .datastack_chunk = offsetof(PyThreadState, datastack_chunk), \ + .status = offsetof(PyThreadState, _status), \ + }, \ + .interpreter_frame = { \ + .size = sizeof(_PyInterpreterFrame), \ + .previous = offsetof(_PyInterpreterFrame, previous), \ + .executable = offsetof(_PyInterpreterFrame, f_executable), \ + .instr_ptr = offsetof(_PyInterpreterFrame, instr_ptr), \ + .localsplus = offsetof(_PyInterpreterFrame, localsplus), \ + .owner = offsetof(_PyInterpreterFrame, owner), \ + }, \ + .code_object = { \ + .size = sizeof(PyCodeObject), \ + .filename = offsetof(PyCodeObject, co_filename), \ + .name = offsetof(PyCodeObject, co_name), \ + .qualname = offsetof(PyCodeObject, co_qualname), \ + .linetable = offsetof(PyCodeObject, co_linetable), \ + .firstlineno = offsetof(PyCodeObject, co_firstlineno), \ + .argcount = offsetof(PyCodeObject, co_argcount), \ + .localsplusnames = offsetof(PyCodeObject, co_localsplusnames), \ + .localspluskinds = offsetof(PyCodeObject, co_localspluskinds), \ + .co_code_adaptive = offsetof(PyCodeObject, co_code_adaptive), \ + }, \ + .pyobject = { \ + .size = sizeof(PyObject), \ + .ob_type = offsetof(PyObject, ob_type), \ + }, \ + .type_object = { \ + .size = sizeof(PyTypeObject), \ + .tp_name = offsetof(PyTypeObject, tp_name), \ + .tp_repr = offsetof(PyTypeObject, tp_repr), \ + .tp_flags = offsetof(PyTypeObject, tp_flags), \ + }, \ + .tuple_object = { \ + .size = sizeof(PyTupleObject), \ + .ob_item = offsetof(PyTupleObject, ob_item), \ + .ob_size = offsetof(PyTupleObject, ob_base.ob_size), \ + }, \ + .list_object = { \ + .size = sizeof(PyListObject), \ + .ob_item = offsetof(PyListObject, ob_item), \ + .ob_size = offsetof(PyListObject, ob_base.ob_size), \ + }, \ + .dict_object = { \ + .size = sizeof(PyDictObject), \ + .ma_keys = offsetof(PyDictObject, ma_keys), \ + .ma_values = offsetof(PyDictObject, ma_values), \ + }, \ + .float_object = { \ + .size = sizeof(PyFloatObject), \ + .ob_fval = offsetof(PyFloatObject, ob_fval), \ + }, \ + .long_object = { \ + .size = sizeof(PyLongObject), \ + .lv_tag = offsetof(PyLongObject, long_value.lv_tag), \ + .ob_digit = offsetof(PyLongObject, long_value.ob_digit), \ + }, \ + .bytes_object = { \ + .size = sizeof(PyBytesObject), \ + .ob_size = offsetof(PyBytesObject, ob_base.ob_size), \ + .ob_sval = offsetof(PyBytesObject, ob_sval), \ + }, \ + .unicode_object = { \ + .size = sizeof(PyUnicodeObject), \ + .state = offsetof(PyUnicodeObject, _base._base.state), \ + .length = offsetof(PyUnicodeObject, _base._base.length), \ + .asciiobject_size = sizeof(PyASCIIObject), \ + }, \ + .gc = { \ + .size = sizeof(struct _gc_runtime_state), \ + .collecting = offsetof(struct _gc_runtime_state, collecting), \ + }, \ + }, \ + .allocators = { \ + .standard = _pymem_allocators_standard_INIT(runtime), \ + .debug = _pymem_allocators_debug_INIT, \ + .obj_arena = _pymem_allocators_obj_arena_INIT, \ + .is_debug_enabled = _pymem_is_debug_enabled_INIT, \ + }, \ + .obmalloc = _obmalloc_global_state_INIT, \ + .pyhash_state = pyhash_state_INIT, \ + .threads = _pythread_RUNTIME_INIT(runtime.threads), \ + .signals = _signals_RUNTIME_INIT, \ + .interpreters = { \ + /* This prevents interpreters from getting created \ + until _PyInterpreterState_Enable() is called. */ \ + .next_id = -1, \ + }, \ + .xi = { \ + .registry = { \ + .global = 1, \ + }, \ + }, \ + /* A TSS key must be initialized with Py_tss_NEEDS_INIT \ + in accordance with the specification. */ \ + .autoTSSkey = Py_tss_NEEDS_INIT, \ + .parser = _parser_runtime_state_INIT, \ + .ceval = { \ + .pending_mainthread = { \ + .max = MAXPENDINGCALLS_MAIN, \ + .maxloop = MAXPENDINGCALLSLOOP_MAIN, \ + }, \ + .perf = _PyEval_RUNTIME_PERF_INIT, \ + }, \ + .gilstate = { \ + .check_enabled = 1, \ + }, \ + .fileutils = { \ + .force_ascii = -1, \ + }, \ + .faulthandler = _faulthandler_runtime_state_INIT, \ + .tracemalloc = _tracemalloc_runtime_state_INIT, \ + .ref_tracer = { \ + .tracer_func = NULL, \ + .tracer_data = NULL, \ + }, \ + .stoptheworld = { \ + .is_global = 1, \ + }, \ + .float_state = { \ + .float_format = _py_float_format_unknown, \ + .double_format = _py_float_format_unknown, \ + }, \ + .types = { \ + .next_version_tag = 1, \ + }, \ + .static_objects = { \ + .singletons = { \ + .small_ints = _Py_small_ints_INIT, \ + .bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \ + .bytes_characters = _Py_bytes_characters_INIT, \ + .strings = { \ + .literals = _Py_str_literals_INIT, \ + .identifiers = _Py_str_identifiers_INIT, \ + .ascii = _Py_str_ascii_INIT, \ + .latin1 = _Py_str_latin1_INIT, \ + }, \ + .tuple_empty = { \ + .ob_base = _PyVarObject_HEAD_INIT(&PyTuple_Type, 0), \ + }, \ + .hamt_bitmap_node_empty = { \ + .ob_base = _PyVarObject_HEAD_INIT(&_PyHamt_BitmapNode_Type, 0), \ + }, \ + .context_token_missing = { \ + .ob_base = _PyObject_HEAD_INIT(&_PyContextTokenMissing_Type), \ + }, \ + }, \ + }, \ + ._main_interpreter = _PyInterpreterState_INIT(runtime._main_interpreter), \ + } + +#define _PyInterpreterState_INIT(INTERP) \ + { \ + .id_refcount = -1, \ + ._whence = _PyInterpreterState_WHENCE_NOTSET, \ + .imports = IMPORTS_INIT, \ + .ceval = { \ + .recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \ + .pending = { \ + .max = MAXPENDINGCALLS, \ + .maxloop = MAXPENDINGCALLSLOOP, \ + }, \ + }, \ + .gc = { \ + .enabled = 1, \ + .generations = { \ + /* .head is set in _PyGC_InitState(). */ \ + { .threshold = 2000, }, \ + { .threshold = 10, }, \ + { .threshold = 10, }, \ + }, \ + }, \ + .qsbr = { \ + .wr_seq = QSBR_INITIAL, \ + .rd_seq = QSBR_INITIAL, \ + }, \ + .dtoa = _dtoa_state_INIT(&(INTERP)), \ + .dict_state = _dict_state_INIT, \ + .mem_free_queue = _Py_mem_free_queue_INIT(INTERP.mem_free_queue), \ + .func_state = { \ + .next_version = 1, \ + }, \ + .types = { \ + .next_version_tag = _Py_TYPE_BASE_VERSION_TAG, \ + }, \ + .static_objects = { \ + .singletons = { \ + ._not_used = 1, \ + .hamt_empty = { \ + .ob_base = _PyObject_HEAD_INIT(&_PyHamt_Type), \ + .h_root = (PyHamtNode*)&_Py_SINGLETON(hamt_bitmap_node_empty), \ + }, \ + .last_resort_memory_error = { \ + _PyObject_HEAD_INIT(&_PyExc_MemoryError), \ + .args = (PyObject*)&_Py_SINGLETON(tuple_empty) \ + }, \ + }, \ + }, \ + ._initial_thread = _PyThreadStateImpl_INIT, \ + } + +#define _PyThreadStateImpl_INIT \ + { \ + .base = _PyThreadState_INIT, \ + } + +#define _PyThreadState_INIT \ + { \ + ._whence = _PyThreadState_WHENCE_NOTSET, \ + .py_recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \ + .context_ver = 1, \ + } + + +// global objects + +#define _PyBytes_SIMPLE_INIT(CH, LEN) \ + { \ + _PyVarObject_HEAD_INIT(&PyBytes_Type, (LEN)), \ + .ob_shash = -1, \ + .ob_sval = { (CH) }, \ + } +#define _PyBytes_CHAR_INIT(CH) \ + { \ + _PyBytes_SIMPLE_INIT((CH), 1) \ + } + +#define _PyUnicode_ASCII_BASE_INIT(LITERAL, ASCII) \ + { \ + .ob_base = _PyObject_HEAD_INIT(&PyUnicode_Type), \ + .length = sizeof(LITERAL) - 1, \ + .hash = -1, \ + .state = { \ + .kind = 1, \ + .compact = 1, \ + .ascii = (ASCII), \ + .statically_allocated = 1, \ + }, \ + } +#define _PyASCIIObject_INIT(LITERAL) \ + { \ + ._ascii = _PyUnicode_ASCII_BASE_INIT((LITERAL), 1), \ + ._data = (LITERAL) \ + } +#define INIT_STR(NAME, LITERAL) \ + ._py_ ## NAME = _PyASCIIObject_INIT(LITERAL) +#define INIT_ID(NAME) \ + ._py_ ## NAME = _PyASCIIObject_INIT(#NAME) +#define _PyUnicode_LATIN1_INIT(LITERAL, UTF8) \ + { \ + ._latin1 = { \ + ._base = _PyUnicode_ASCII_BASE_INIT((LITERAL), 0), \ + .utf8 = (UTF8), \ + .utf8_length = sizeof(UTF8) - 1, \ + }, \ + ._data = (LITERAL), \ + } + +#include "pycore_runtime_init_generated.h" + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_RUNTIME_INIT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime_init_generated.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime_init_generated.h new file mode 100644 index 00000000..19a6b9b1 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_runtime_init_generated.h @@ -0,0 +1,1551 @@ +#ifndef Py_INTERNAL_RUNTIME_INIT_GENERATED_H +#define Py_INTERNAL_RUNTIME_INIT_GENERATED_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_long.h" // _PyLong_DIGIT_INIT() + + +/* The following is auto-generated by Tools/build/generate_global_objects.py. */ +#define _Py_small_ints_INIT { \ + _PyLong_DIGIT_INIT(-5), \ + _PyLong_DIGIT_INIT(-4), \ + _PyLong_DIGIT_INIT(-3), \ + _PyLong_DIGIT_INIT(-2), \ + _PyLong_DIGIT_INIT(-1), \ + _PyLong_DIGIT_INIT(0), \ + _PyLong_DIGIT_INIT(1), \ + _PyLong_DIGIT_INIT(2), \ + _PyLong_DIGIT_INIT(3), \ + _PyLong_DIGIT_INIT(4), \ + _PyLong_DIGIT_INIT(5), \ + _PyLong_DIGIT_INIT(6), \ + _PyLong_DIGIT_INIT(7), \ + _PyLong_DIGIT_INIT(8), \ + _PyLong_DIGIT_INIT(9), \ + _PyLong_DIGIT_INIT(10), \ + _PyLong_DIGIT_INIT(11), \ + _PyLong_DIGIT_INIT(12), \ + _PyLong_DIGIT_INIT(13), \ + _PyLong_DIGIT_INIT(14), \ + _PyLong_DIGIT_INIT(15), \ + _PyLong_DIGIT_INIT(16), \ + _PyLong_DIGIT_INIT(17), \ + _PyLong_DIGIT_INIT(18), \ + _PyLong_DIGIT_INIT(19), \ + _PyLong_DIGIT_INIT(20), \ + _PyLong_DIGIT_INIT(21), \ + _PyLong_DIGIT_INIT(22), \ + _PyLong_DIGIT_INIT(23), \ + _PyLong_DIGIT_INIT(24), \ + _PyLong_DIGIT_INIT(25), \ + _PyLong_DIGIT_INIT(26), \ + _PyLong_DIGIT_INIT(27), \ + _PyLong_DIGIT_INIT(28), \ + _PyLong_DIGIT_INIT(29), \ + _PyLong_DIGIT_INIT(30), \ + _PyLong_DIGIT_INIT(31), \ + _PyLong_DIGIT_INIT(32), \ + _PyLong_DIGIT_INIT(33), \ + _PyLong_DIGIT_INIT(34), \ + _PyLong_DIGIT_INIT(35), \ + _PyLong_DIGIT_INIT(36), \ + _PyLong_DIGIT_INIT(37), \ + _PyLong_DIGIT_INIT(38), \ + _PyLong_DIGIT_INIT(39), \ + _PyLong_DIGIT_INIT(40), \ + _PyLong_DIGIT_INIT(41), \ + _PyLong_DIGIT_INIT(42), \ + _PyLong_DIGIT_INIT(43), \ + _PyLong_DIGIT_INIT(44), \ + _PyLong_DIGIT_INIT(45), \ + _PyLong_DIGIT_INIT(46), \ + _PyLong_DIGIT_INIT(47), \ + _PyLong_DIGIT_INIT(48), \ + _PyLong_DIGIT_INIT(49), \ + _PyLong_DIGIT_INIT(50), \ + _PyLong_DIGIT_INIT(51), \ + _PyLong_DIGIT_INIT(52), \ + _PyLong_DIGIT_INIT(53), \ + _PyLong_DIGIT_INIT(54), \ + _PyLong_DIGIT_INIT(55), \ + _PyLong_DIGIT_INIT(56), \ + _PyLong_DIGIT_INIT(57), \ + _PyLong_DIGIT_INIT(58), \ + _PyLong_DIGIT_INIT(59), \ + _PyLong_DIGIT_INIT(60), \ + _PyLong_DIGIT_INIT(61), \ + _PyLong_DIGIT_INIT(62), \ + _PyLong_DIGIT_INIT(63), \ + _PyLong_DIGIT_INIT(64), \ + _PyLong_DIGIT_INIT(65), \ + _PyLong_DIGIT_INIT(66), \ + _PyLong_DIGIT_INIT(67), \ + _PyLong_DIGIT_INIT(68), \ + _PyLong_DIGIT_INIT(69), \ + _PyLong_DIGIT_INIT(70), \ + _PyLong_DIGIT_INIT(71), \ + _PyLong_DIGIT_INIT(72), \ + _PyLong_DIGIT_INIT(73), \ + _PyLong_DIGIT_INIT(74), \ + _PyLong_DIGIT_INIT(75), \ + _PyLong_DIGIT_INIT(76), \ + _PyLong_DIGIT_INIT(77), \ + _PyLong_DIGIT_INIT(78), \ + _PyLong_DIGIT_INIT(79), \ + _PyLong_DIGIT_INIT(80), \ + _PyLong_DIGIT_INIT(81), \ + _PyLong_DIGIT_INIT(82), \ + _PyLong_DIGIT_INIT(83), \ + _PyLong_DIGIT_INIT(84), \ + _PyLong_DIGIT_INIT(85), \ + _PyLong_DIGIT_INIT(86), \ + _PyLong_DIGIT_INIT(87), \ + _PyLong_DIGIT_INIT(88), \ + _PyLong_DIGIT_INIT(89), \ + _PyLong_DIGIT_INIT(90), \ + _PyLong_DIGIT_INIT(91), \ + _PyLong_DIGIT_INIT(92), \ + _PyLong_DIGIT_INIT(93), \ + _PyLong_DIGIT_INIT(94), \ + _PyLong_DIGIT_INIT(95), \ + _PyLong_DIGIT_INIT(96), \ + _PyLong_DIGIT_INIT(97), \ + _PyLong_DIGIT_INIT(98), \ + _PyLong_DIGIT_INIT(99), \ + _PyLong_DIGIT_INIT(100), \ + _PyLong_DIGIT_INIT(101), \ + _PyLong_DIGIT_INIT(102), \ + _PyLong_DIGIT_INIT(103), \ + _PyLong_DIGIT_INIT(104), \ + _PyLong_DIGIT_INIT(105), \ + _PyLong_DIGIT_INIT(106), \ + _PyLong_DIGIT_INIT(107), \ + _PyLong_DIGIT_INIT(108), \ + _PyLong_DIGIT_INIT(109), \ + _PyLong_DIGIT_INIT(110), \ + _PyLong_DIGIT_INIT(111), \ + _PyLong_DIGIT_INIT(112), \ + _PyLong_DIGIT_INIT(113), \ + _PyLong_DIGIT_INIT(114), \ + _PyLong_DIGIT_INIT(115), \ + _PyLong_DIGIT_INIT(116), \ + _PyLong_DIGIT_INIT(117), \ + _PyLong_DIGIT_INIT(118), \ + _PyLong_DIGIT_INIT(119), \ + _PyLong_DIGIT_INIT(120), \ + _PyLong_DIGIT_INIT(121), \ + _PyLong_DIGIT_INIT(122), \ + _PyLong_DIGIT_INIT(123), \ + _PyLong_DIGIT_INIT(124), \ + _PyLong_DIGIT_INIT(125), \ + _PyLong_DIGIT_INIT(126), \ + _PyLong_DIGIT_INIT(127), \ + _PyLong_DIGIT_INIT(128), \ + _PyLong_DIGIT_INIT(129), \ + _PyLong_DIGIT_INIT(130), \ + _PyLong_DIGIT_INIT(131), \ + _PyLong_DIGIT_INIT(132), \ + _PyLong_DIGIT_INIT(133), \ + _PyLong_DIGIT_INIT(134), \ + _PyLong_DIGIT_INIT(135), \ + _PyLong_DIGIT_INIT(136), \ + _PyLong_DIGIT_INIT(137), \ + _PyLong_DIGIT_INIT(138), \ + _PyLong_DIGIT_INIT(139), \ + _PyLong_DIGIT_INIT(140), \ + _PyLong_DIGIT_INIT(141), \ + _PyLong_DIGIT_INIT(142), \ + _PyLong_DIGIT_INIT(143), \ + _PyLong_DIGIT_INIT(144), \ + _PyLong_DIGIT_INIT(145), \ + _PyLong_DIGIT_INIT(146), \ + _PyLong_DIGIT_INIT(147), \ + _PyLong_DIGIT_INIT(148), \ + _PyLong_DIGIT_INIT(149), \ + _PyLong_DIGIT_INIT(150), \ + _PyLong_DIGIT_INIT(151), \ + _PyLong_DIGIT_INIT(152), \ + _PyLong_DIGIT_INIT(153), \ + _PyLong_DIGIT_INIT(154), \ + _PyLong_DIGIT_INIT(155), \ + _PyLong_DIGIT_INIT(156), \ + _PyLong_DIGIT_INIT(157), \ + _PyLong_DIGIT_INIT(158), \ + _PyLong_DIGIT_INIT(159), \ + _PyLong_DIGIT_INIT(160), \ + _PyLong_DIGIT_INIT(161), \ + _PyLong_DIGIT_INIT(162), \ + _PyLong_DIGIT_INIT(163), \ + _PyLong_DIGIT_INIT(164), \ + _PyLong_DIGIT_INIT(165), \ + _PyLong_DIGIT_INIT(166), \ + _PyLong_DIGIT_INIT(167), \ + _PyLong_DIGIT_INIT(168), \ + _PyLong_DIGIT_INIT(169), \ + _PyLong_DIGIT_INIT(170), \ + _PyLong_DIGIT_INIT(171), \ + _PyLong_DIGIT_INIT(172), \ + _PyLong_DIGIT_INIT(173), \ + _PyLong_DIGIT_INIT(174), \ + _PyLong_DIGIT_INIT(175), \ + _PyLong_DIGIT_INIT(176), \ + _PyLong_DIGIT_INIT(177), \ + _PyLong_DIGIT_INIT(178), \ + _PyLong_DIGIT_INIT(179), \ + _PyLong_DIGIT_INIT(180), \ + _PyLong_DIGIT_INIT(181), \ + _PyLong_DIGIT_INIT(182), \ + _PyLong_DIGIT_INIT(183), \ + _PyLong_DIGIT_INIT(184), \ + _PyLong_DIGIT_INIT(185), \ + _PyLong_DIGIT_INIT(186), \ + _PyLong_DIGIT_INIT(187), \ + _PyLong_DIGIT_INIT(188), \ + _PyLong_DIGIT_INIT(189), \ + _PyLong_DIGIT_INIT(190), \ + _PyLong_DIGIT_INIT(191), \ + _PyLong_DIGIT_INIT(192), \ + _PyLong_DIGIT_INIT(193), \ + _PyLong_DIGIT_INIT(194), \ + _PyLong_DIGIT_INIT(195), \ + _PyLong_DIGIT_INIT(196), \ + _PyLong_DIGIT_INIT(197), \ + _PyLong_DIGIT_INIT(198), \ + _PyLong_DIGIT_INIT(199), \ + _PyLong_DIGIT_INIT(200), \ + _PyLong_DIGIT_INIT(201), \ + _PyLong_DIGIT_INIT(202), \ + _PyLong_DIGIT_INIT(203), \ + _PyLong_DIGIT_INIT(204), \ + _PyLong_DIGIT_INIT(205), \ + _PyLong_DIGIT_INIT(206), \ + _PyLong_DIGIT_INIT(207), \ + _PyLong_DIGIT_INIT(208), \ + _PyLong_DIGIT_INIT(209), \ + _PyLong_DIGIT_INIT(210), \ + _PyLong_DIGIT_INIT(211), \ + _PyLong_DIGIT_INIT(212), \ + _PyLong_DIGIT_INIT(213), \ + _PyLong_DIGIT_INIT(214), \ + _PyLong_DIGIT_INIT(215), \ + _PyLong_DIGIT_INIT(216), \ + _PyLong_DIGIT_INIT(217), \ + _PyLong_DIGIT_INIT(218), \ + _PyLong_DIGIT_INIT(219), \ + _PyLong_DIGIT_INIT(220), \ + _PyLong_DIGIT_INIT(221), \ + _PyLong_DIGIT_INIT(222), \ + _PyLong_DIGIT_INIT(223), \ + _PyLong_DIGIT_INIT(224), \ + _PyLong_DIGIT_INIT(225), \ + _PyLong_DIGIT_INIT(226), \ + _PyLong_DIGIT_INIT(227), \ + _PyLong_DIGIT_INIT(228), \ + _PyLong_DIGIT_INIT(229), \ + _PyLong_DIGIT_INIT(230), \ + _PyLong_DIGIT_INIT(231), \ + _PyLong_DIGIT_INIT(232), \ + _PyLong_DIGIT_INIT(233), \ + _PyLong_DIGIT_INIT(234), \ + _PyLong_DIGIT_INIT(235), \ + _PyLong_DIGIT_INIT(236), \ + _PyLong_DIGIT_INIT(237), \ + _PyLong_DIGIT_INIT(238), \ + _PyLong_DIGIT_INIT(239), \ + _PyLong_DIGIT_INIT(240), \ + _PyLong_DIGIT_INIT(241), \ + _PyLong_DIGIT_INIT(242), \ + _PyLong_DIGIT_INIT(243), \ + _PyLong_DIGIT_INIT(244), \ + _PyLong_DIGIT_INIT(245), \ + _PyLong_DIGIT_INIT(246), \ + _PyLong_DIGIT_INIT(247), \ + _PyLong_DIGIT_INIT(248), \ + _PyLong_DIGIT_INIT(249), \ + _PyLong_DIGIT_INIT(250), \ + _PyLong_DIGIT_INIT(251), \ + _PyLong_DIGIT_INIT(252), \ + _PyLong_DIGIT_INIT(253), \ + _PyLong_DIGIT_INIT(254), \ + _PyLong_DIGIT_INIT(255), \ + _PyLong_DIGIT_INIT(256), \ +} + +#define _Py_bytes_characters_INIT { \ + _PyBytes_CHAR_INIT(0), \ + _PyBytes_CHAR_INIT(1), \ + _PyBytes_CHAR_INIT(2), \ + _PyBytes_CHAR_INIT(3), \ + _PyBytes_CHAR_INIT(4), \ + _PyBytes_CHAR_INIT(5), \ + _PyBytes_CHAR_INIT(6), \ + _PyBytes_CHAR_INIT(7), \ + _PyBytes_CHAR_INIT(8), \ + _PyBytes_CHAR_INIT(9), \ + _PyBytes_CHAR_INIT(10), \ + _PyBytes_CHAR_INIT(11), \ + _PyBytes_CHAR_INIT(12), \ + _PyBytes_CHAR_INIT(13), \ + _PyBytes_CHAR_INIT(14), \ + _PyBytes_CHAR_INIT(15), \ + _PyBytes_CHAR_INIT(16), \ + _PyBytes_CHAR_INIT(17), \ + _PyBytes_CHAR_INIT(18), \ + _PyBytes_CHAR_INIT(19), \ + _PyBytes_CHAR_INIT(20), \ + _PyBytes_CHAR_INIT(21), \ + _PyBytes_CHAR_INIT(22), \ + _PyBytes_CHAR_INIT(23), \ + _PyBytes_CHAR_INIT(24), \ + _PyBytes_CHAR_INIT(25), \ + _PyBytes_CHAR_INIT(26), \ + _PyBytes_CHAR_INIT(27), \ + _PyBytes_CHAR_INIT(28), \ + _PyBytes_CHAR_INIT(29), \ + _PyBytes_CHAR_INIT(30), \ + _PyBytes_CHAR_INIT(31), \ + _PyBytes_CHAR_INIT(32), \ + _PyBytes_CHAR_INIT(33), \ + _PyBytes_CHAR_INIT(34), \ + _PyBytes_CHAR_INIT(35), \ + _PyBytes_CHAR_INIT(36), \ + _PyBytes_CHAR_INIT(37), \ + _PyBytes_CHAR_INIT(38), \ + _PyBytes_CHAR_INIT(39), \ + _PyBytes_CHAR_INIT(40), \ + _PyBytes_CHAR_INIT(41), \ + _PyBytes_CHAR_INIT(42), \ + _PyBytes_CHAR_INIT(43), \ + _PyBytes_CHAR_INIT(44), \ + _PyBytes_CHAR_INIT(45), \ + _PyBytes_CHAR_INIT(46), \ + _PyBytes_CHAR_INIT(47), \ + _PyBytes_CHAR_INIT(48), \ + _PyBytes_CHAR_INIT(49), \ + _PyBytes_CHAR_INIT(50), \ + _PyBytes_CHAR_INIT(51), \ + _PyBytes_CHAR_INIT(52), \ + _PyBytes_CHAR_INIT(53), \ + _PyBytes_CHAR_INIT(54), \ + _PyBytes_CHAR_INIT(55), \ + _PyBytes_CHAR_INIT(56), \ + _PyBytes_CHAR_INIT(57), \ + _PyBytes_CHAR_INIT(58), \ + _PyBytes_CHAR_INIT(59), \ + _PyBytes_CHAR_INIT(60), \ + _PyBytes_CHAR_INIT(61), \ + _PyBytes_CHAR_INIT(62), \ + _PyBytes_CHAR_INIT(63), \ + _PyBytes_CHAR_INIT(64), \ + _PyBytes_CHAR_INIT(65), \ + _PyBytes_CHAR_INIT(66), \ + _PyBytes_CHAR_INIT(67), \ + _PyBytes_CHAR_INIT(68), \ + _PyBytes_CHAR_INIT(69), \ + _PyBytes_CHAR_INIT(70), \ + _PyBytes_CHAR_INIT(71), \ + _PyBytes_CHAR_INIT(72), \ + _PyBytes_CHAR_INIT(73), \ + _PyBytes_CHAR_INIT(74), \ + _PyBytes_CHAR_INIT(75), \ + _PyBytes_CHAR_INIT(76), \ + _PyBytes_CHAR_INIT(77), \ + _PyBytes_CHAR_INIT(78), \ + _PyBytes_CHAR_INIT(79), \ + _PyBytes_CHAR_INIT(80), \ + _PyBytes_CHAR_INIT(81), \ + _PyBytes_CHAR_INIT(82), \ + _PyBytes_CHAR_INIT(83), \ + _PyBytes_CHAR_INIT(84), \ + _PyBytes_CHAR_INIT(85), \ + _PyBytes_CHAR_INIT(86), \ + _PyBytes_CHAR_INIT(87), \ + _PyBytes_CHAR_INIT(88), \ + _PyBytes_CHAR_INIT(89), \ + _PyBytes_CHAR_INIT(90), \ + _PyBytes_CHAR_INIT(91), \ + _PyBytes_CHAR_INIT(92), \ + _PyBytes_CHAR_INIT(93), \ + _PyBytes_CHAR_INIT(94), \ + _PyBytes_CHAR_INIT(95), \ + _PyBytes_CHAR_INIT(96), \ + _PyBytes_CHAR_INIT(97), \ + _PyBytes_CHAR_INIT(98), \ + _PyBytes_CHAR_INIT(99), \ + _PyBytes_CHAR_INIT(100), \ + _PyBytes_CHAR_INIT(101), \ + _PyBytes_CHAR_INIT(102), \ + _PyBytes_CHAR_INIT(103), \ + _PyBytes_CHAR_INIT(104), \ + _PyBytes_CHAR_INIT(105), \ + _PyBytes_CHAR_INIT(106), \ + _PyBytes_CHAR_INIT(107), \ + _PyBytes_CHAR_INIT(108), \ + _PyBytes_CHAR_INIT(109), \ + _PyBytes_CHAR_INIT(110), \ + _PyBytes_CHAR_INIT(111), \ + _PyBytes_CHAR_INIT(112), \ + _PyBytes_CHAR_INIT(113), \ + _PyBytes_CHAR_INIT(114), \ + _PyBytes_CHAR_INIT(115), \ + _PyBytes_CHAR_INIT(116), \ + _PyBytes_CHAR_INIT(117), \ + _PyBytes_CHAR_INIT(118), \ + _PyBytes_CHAR_INIT(119), \ + _PyBytes_CHAR_INIT(120), \ + _PyBytes_CHAR_INIT(121), \ + _PyBytes_CHAR_INIT(122), \ + _PyBytes_CHAR_INIT(123), \ + _PyBytes_CHAR_INIT(124), \ + _PyBytes_CHAR_INIT(125), \ + _PyBytes_CHAR_INIT(126), \ + _PyBytes_CHAR_INIT(127), \ + _PyBytes_CHAR_INIT(128), \ + _PyBytes_CHAR_INIT(129), \ + _PyBytes_CHAR_INIT(130), \ + _PyBytes_CHAR_INIT(131), \ + _PyBytes_CHAR_INIT(132), \ + _PyBytes_CHAR_INIT(133), \ + _PyBytes_CHAR_INIT(134), \ + _PyBytes_CHAR_INIT(135), \ + _PyBytes_CHAR_INIT(136), \ + _PyBytes_CHAR_INIT(137), \ + _PyBytes_CHAR_INIT(138), \ + _PyBytes_CHAR_INIT(139), \ + _PyBytes_CHAR_INIT(140), \ + _PyBytes_CHAR_INIT(141), \ + _PyBytes_CHAR_INIT(142), \ + _PyBytes_CHAR_INIT(143), \ + _PyBytes_CHAR_INIT(144), \ + _PyBytes_CHAR_INIT(145), \ + _PyBytes_CHAR_INIT(146), \ + _PyBytes_CHAR_INIT(147), \ + _PyBytes_CHAR_INIT(148), \ + _PyBytes_CHAR_INIT(149), \ + _PyBytes_CHAR_INIT(150), \ + _PyBytes_CHAR_INIT(151), \ + _PyBytes_CHAR_INIT(152), \ + _PyBytes_CHAR_INIT(153), \ + _PyBytes_CHAR_INIT(154), \ + _PyBytes_CHAR_INIT(155), \ + _PyBytes_CHAR_INIT(156), \ + _PyBytes_CHAR_INIT(157), \ + _PyBytes_CHAR_INIT(158), \ + _PyBytes_CHAR_INIT(159), \ + _PyBytes_CHAR_INIT(160), \ + _PyBytes_CHAR_INIT(161), \ + _PyBytes_CHAR_INIT(162), \ + _PyBytes_CHAR_INIT(163), \ + _PyBytes_CHAR_INIT(164), \ + _PyBytes_CHAR_INIT(165), \ + _PyBytes_CHAR_INIT(166), \ + _PyBytes_CHAR_INIT(167), \ + _PyBytes_CHAR_INIT(168), \ + _PyBytes_CHAR_INIT(169), \ + _PyBytes_CHAR_INIT(170), \ + _PyBytes_CHAR_INIT(171), \ + _PyBytes_CHAR_INIT(172), \ + _PyBytes_CHAR_INIT(173), \ + _PyBytes_CHAR_INIT(174), \ + _PyBytes_CHAR_INIT(175), \ + _PyBytes_CHAR_INIT(176), \ + _PyBytes_CHAR_INIT(177), \ + _PyBytes_CHAR_INIT(178), \ + _PyBytes_CHAR_INIT(179), \ + _PyBytes_CHAR_INIT(180), \ + _PyBytes_CHAR_INIT(181), \ + _PyBytes_CHAR_INIT(182), \ + _PyBytes_CHAR_INIT(183), \ + _PyBytes_CHAR_INIT(184), \ + _PyBytes_CHAR_INIT(185), \ + _PyBytes_CHAR_INIT(186), \ + _PyBytes_CHAR_INIT(187), \ + _PyBytes_CHAR_INIT(188), \ + _PyBytes_CHAR_INIT(189), \ + _PyBytes_CHAR_INIT(190), \ + _PyBytes_CHAR_INIT(191), \ + _PyBytes_CHAR_INIT(192), \ + _PyBytes_CHAR_INIT(193), \ + _PyBytes_CHAR_INIT(194), \ + _PyBytes_CHAR_INIT(195), \ + _PyBytes_CHAR_INIT(196), \ + _PyBytes_CHAR_INIT(197), \ + _PyBytes_CHAR_INIT(198), \ + _PyBytes_CHAR_INIT(199), \ + _PyBytes_CHAR_INIT(200), \ + _PyBytes_CHAR_INIT(201), \ + _PyBytes_CHAR_INIT(202), \ + _PyBytes_CHAR_INIT(203), \ + _PyBytes_CHAR_INIT(204), \ + _PyBytes_CHAR_INIT(205), \ + _PyBytes_CHAR_INIT(206), \ + _PyBytes_CHAR_INIT(207), \ + _PyBytes_CHAR_INIT(208), \ + _PyBytes_CHAR_INIT(209), \ + _PyBytes_CHAR_INIT(210), \ + _PyBytes_CHAR_INIT(211), \ + _PyBytes_CHAR_INIT(212), \ + _PyBytes_CHAR_INIT(213), \ + _PyBytes_CHAR_INIT(214), \ + _PyBytes_CHAR_INIT(215), \ + _PyBytes_CHAR_INIT(216), \ + _PyBytes_CHAR_INIT(217), \ + _PyBytes_CHAR_INIT(218), \ + _PyBytes_CHAR_INIT(219), \ + _PyBytes_CHAR_INIT(220), \ + _PyBytes_CHAR_INIT(221), \ + _PyBytes_CHAR_INIT(222), \ + _PyBytes_CHAR_INIT(223), \ + _PyBytes_CHAR_INIT(224), \ + _PyBytes_CHAR_INIT(225), \ + _PyBytes_CHAR_INIT(226), \ + _PyBytes_CHAR_INIT(227), \ + _PyBytes_CHAR_INIT(228), \ + _PyBytes_CHAR_INIT(229), \ + _PyBytes_CHAR_INIT(230), \ + _PyBytes_CHAR_INIT(231), \ + _PyBytes_CHAR_INIT(232), \ + _PyBytes_CHAR_INIT(233), \ + _PyBytes_CHAR_INIT(234), \ + _PyBytes_CHAR_INIT(235), \ + _PyBytes_CHAR_INIT(236), \ + _PyBytes_CHAR_INIT(237), \ + _PyBytes_CHAR_INIT(238), \ + _PyBytes_CHAR_INIT(239), \ + _PyBytes_CHAR_INIT(240), \ + _PyBytes_CHAR_INIT(241), \ + _PyBytes_CHAR_INIT(242), \ + _PyBytes_CHAR_INIT(243), \ + _PyBytes_CHAR_INIT(244), \ + _PyBytes_CHAR_INIT(245), \ + _PyBytes_CHAR_INIT(246), \ + _PyBytes_CHAR_INIT(247), \ + _PyBytes_CHAR_INIT(248), \ + _PyBytes_CHAR_INIT(249), \ + _PyBytes_CHAR_INIT(250), \ + _PyBytes_CHAR_INIT(251), \ + _PyBytes_CHAR_INIT(252), \ + _PyBytes_CHAR_INIT(253), \ + _PyBytes_CHAR_INIT(254), \ + _PyBytes_CHAR_INIT(255), \ +} + +#define _Py_str_literals_INIT { \ + INIT_STR(anon_dictcomp, ""), \ + INIT_STR(anon_genexpr, ""), \ + INIT_STR(anon_lambda, ""), \ + INIT_STR(anon_listcomp, ""), \ + INIT_STR(anon_module, ""), \ + INIT_STR(anon_null, ""), \ + INIT_STR(anon_setcomp, ""), \ + INIT_STR(anon_string, ""), \ + INIT_STR(anon_unknown, ""), \ + INIT_STR(dbl_close_br, "}}"), \ + INIT_STR(dbl_open_br, "{{"), \ + INIT_STR(dbl_percent, "%%"), \ + INIT_STR(defaults, ".defaults"), \ + INIT_STR(dot_locals, "."), \ + INIT_STR(empty, ""), \ + INIT_STR(generic_base, ".generic_base"), \ + INIT_STR(json_decoder, "json.decoder"), \ + INIT_STR(kwdefaults, ".kwdefaults"), \ + INIT_STR(list_err, "list index out of range"), \ + INIT_STR(str_replace_inf, "1e309"), \ + INIT_STR(type_params, ".type_params"), \ + INIT_STR(utf_8, "utf-8"), \ +} + +#define _Py_str_identifiers_INIT { \ + INIT_ID(CANCELLED), \ + INIT_ID(FINISHED), \ + INIT_ID(False), \ + INIT_ID(JSONDecodeError), \ + INIT_ID(PENDING), \ + INIT_ID(Py_Repr), \ + INIT_ID(TextIOWrapper), \ + INIT_ID(True), \ + INIT_ID(WarningMessage), \ + INIT_ID(_WindowsConsoleIO), \ + INIT_ID(__IOBase_closed), \ + INIT_ID(__abc_tpflags__), \ + INIT_ID(__abs__), \ + INIT_ID(__abstractmethods__), \ + INIT_ID(__add__), \ + INIT_ID(__aenter__), \ + INIT_ID(__aexit__), \ + INIT_ID(__aiter__), \ + INIT_ID(__all__), \ + INIT_ID(__and__), \ + INIT_ID(__anext__), \ + INIT_ID(__annotations__), \ + INIT_ID(__args__), \ + INIT_ID(__await__), \ + INIT_ID(__bases__), \ + INIT_ID(__bool__), \ + INIT_ID(__buffer__), \ + INIT_ID(__build_class__), \ + INIT_ID(__builtins__), \ + INIT_ID(__bytes__), \ + INIT_ID(__call__), \ + INIT_ID(__cantrace__), \ + INIT_ID(__class__), \ + INIT_ID(__class_getitem__), \ + INIT_ID(__classcell__), \ + INIT_ID(__classdict__), \ + INIT_ID(__classdictcell__), \ + INIT_ID(__complex__), \ + INIT_ID(__contains__), \ + INIT_ID(__copy__), \ + INIT_ID(__ctypes_from_outparam__), \ + INIT_ID(__del__), \ + INIT_ID(__delattr__), \ + INIT_ID(__delete__), \ + INIT_ID(__delitem__), \ + INIT_ID(__dict__), \ + INIT_ID(__dictoffset__), \ + INIT_ID(__dir__), \ + INIT_ID(__divmod__), \ + INIT_ID(__doc__), \ + INIT_ID(__enter__), \ + INIT_ID(__eq__), \ + INIT_ID(__exit__), \ + INIT_ID(__file__), \ + INIT_ID(__firstlineno__), \ + INIT_ID(__float__), \ + INIT_ID(__floordiv__), \ + INIT_ID(__format__), \ + INIT_ID(__fspath__), \ + INIT_ID(__ge__), \ + INIT_ID(__get__), \ + INIT_ID(__getattr__), \ + INIT_ID(__getattribute__), \ + INIT_ID(__getinitargs__), \ + INIT_ID(__getitem__), \ + INIT_ID(__getnewargs__), \ + INIT_ID(__getnewargs_ex__), \ + INIT_ID(__getstate__), \ + INIT_ID(__gt__), \ + INIT_ID(__hash__), \ + INIT_ID(__iadd__), \ + INIT_ID(__iand__), \ + INIT_ID(__ifloordiv__), \ + INIT_ID(__ilshift__), \ + INIT_ID(__imatmul__), \ + INIT_ID(__imod__), \ + INIT_ID(__import__), \ + INIT_ID(__imul__), \ + INIT_ID(__index__), \ + INIT_ID(__init__), \ + INIT_ID(__init_subclass__), \ + INIT_ID(__instancecheck__), \ + INIT_ID(__int__), \ + INIT_ID(__invert__), \ + INIT_ID(__ior__), \ + INIT_ID(__ipow__), \ + INIT_ID(__irshift__), \ + INIT_ID(__isabstractmethod__), \ + INIT_ID(__isub__), \ + INIT_ID(__iter__), \ + INIT_ID(__itruediv__), \ + INIT_ID(__ixor__), \ + INIT_ID(__le__), \ + INIT_ID(__len__), \ + INIT_ID(__length_hint__), \ + INIT_ID(__lltrace__), \ + INIT_ID(__loader__), \ + INIT_ID(__lshift__), \ + INIT_ID(__lt__), \ + INIT_ID(__main__), \ + INIT_ID(__match_args__), \ + INIT_ID(__matmul__), \ + INIT_ID(__missing__), \ + INIT_ID(__mod__), \ + INIT_ID(__module__), \ + INIT_ID(__mro_entries__), \ + INIT_ID(__mul__), \ + INIT_ID(__name__), \ + INIT_ID(__ne__), \ + INIT_ID(__neg__), \ + INIT_ID(__new__), \ + INIT_ID(__newobj__), \ + INIT_ID(__newobj_ex__), \ + INIT_ID(__next__), \ + INIT_ID(__notes__), \ + INIT_ID(__or__), \ + INIT_ID(__orig_class__), \ + INIT_ID(__origin__), \ + INIT_ID(__package__), \ + INIT_ID(__parameters__), \ + INIT_ID(__path__), \ + INIT_ID(__pos__), \ + INIT_ID(__pow__), \ + INIT_ID(__prepare__), \ + INIT_ID(__qualname__), \ + INIT_ID(__radd__), \ + INIT_ID(__rand__), \ + INIT_ID(__rdivmod__), \ + INIT_ID(__reduce__), \ + INIT_ID(__reduce_ex__), \ + INIT_ID(__release_buffer__), \ + INIT_ID(__repr__), \ + INIT_ID(__reversed__), \ + INIT_ID(__rfloordiv__), \ + INIT_ID(__rlshift__), \ + INIT_ID(__rmatmul__), \ + INIT_ID(__rmod__), \ + INIT_ID(__rmul__), \ + INIT_ID(__ror__), \ + INIT_ID(__round__), \ + INIT_ID(__rpow__), \ + INIT_ID(__rrshift__), \ + INIT_ID(__rshift__), \ + INIT_ID(__rsub__), \ + INIT_ID(__rtruediv__), \ + INIT_ID(__rxor__), \ + INIT_ID(__set__), \ + INIT_ID(__set_name__), \ + INIT_ID(__setattr__), \ + INIT_ID(__setitem__), \ + INIT_ID(__setstate__), \ + INIT_ID(__sizeof__), \ + INIT_ID(__slotnames__), \ + INIT_ID(__slots__), \ + INIT_ID(__spec__), \ + INIT_ID(__static_attributes__), \ + INIT_ID(__str__), \ + INIT_ID(__sub__), \ + INIT_ID(__subclasscheck__), \ + INIT_ID(__subclasshook__), \ + INIT_ID(__truediv__), \ + INIT_ID(__trunc__), \ + INIT_ID(__type_params__), \ + INIT_ID(__typing_is_unpacked_typevartuple__), \ + INIT_ID(__typing_prepare_subst__), \ + INIT_ID(__typing_subst__), \ + INIT_ID(__typing_unpacked_tuple_args__), \ + INIT_ID(__warningregistry__), \ + INIT_ID(__weaklistoffset__), \ + INIT_ID(__weakref__), \ + INIT_ID(__xor__), \ + INIT_ID(_abc_impl), \ + INIT_ID(_abstract_), \ + INIT_ID(_active), \ + INIT_ID(_align_), \ + INIT_ID(_annotation), \ + INIT_ID(_anonymous_), \ + INIT_ID(_argtypes_), \ + INIT_ID(_as_parameter_), \ + INIT_ID(_asyncio_future_blocking), \ + INIT_ID(_blksize), \ + INIT_ID(_bootstrap), \ + INIT_ID(_check_retval_), \ + INIT_ID(_dealloc_warn), \ + INIT_ID(_feature_version), \ + INIT_ID(_field_types), \ + INIT_ID(_fields_), \ + INIT_ID(_finalizing), \ + INIT_ID(_find_and_load), \ + INIT_ID(_fix_up_module), \ + INIT_ID(_flags_), \ + INIT_ID(_get_sourcefile), \ + INIT_ID(_handle_fromlist), \ + INIT_ID(_initializing), \ + INIT_ID(_io), \ + INIT_ID(_is_text_encoding), \ + INIT_ID(_length_), \ + INIT_ID(_limbo), \ + INIT_ID(_lock_unlock_module), \ + INIT_ID(_loop), \ + INIT_ID(_needs_com_addref_), \ + INIT_ID(_only_immortal), \ + INIT_ID(_pack_), \ + INIT_ID(_restype_), \ + INIT_ID(_showwarnmsg), \ + INIT_ID(_shutdown), \ + INIT_ID(_slotnames), \ + INIT_ID(_strptime), \ + INIT_ID(_strptime_datetime), \ + INIT_ID(_swappedbytes_), \ + INIT_ID(_type_), \ + INIT_ID(_uninitialized_submodules), \ + INIT_ID(_warn_unawaited_coroutine), \ + INIT_ID(_xoptions), \ + INIT_ID(abs_tol), \ + INIT_ID(access), \ + INIT_ID(aclose), \ + INIT_ID(add), \ + INIT_ID(add_done_callback), \ + INIT_ID(after_in_child), \ + INIT_ID(after_in_parent), \ + INIT_ID(aggregate_class), \ + INIT_ID(alias), \ + INIT_ID(allow_code), \ + INIT_ID(append), \ + INIT_ID(arg), \ + INIT_ID(argdefs), \ + INIT_ID(args), \ + INIT_ID(arguments), \ + INIT_ID(argv), \ + INIT_ID(as_integer_ratio), \ + INIT_ID(asend), \ + INIT_ID(ast), \ + INIT_ID(athrow), \ + INIT_ID(attribute), \ + INIT_ID(authorizer_callback), \ + INIT_ID(autocommit), \ + INIT_ID(backtick), \ + INIT_ID(base), \ + INIT_ID(before), \ + INIT_ID(big), \ + INIT_ID(binary_form), \ + INIT_ID(block), \ + INIT_ID(bound), \ + INIT_ID(buffer), \ + INIT_ID(buffer_callback), \ + INIT_ID(buffer_size), \ + INIT_ID(buffering), \ + INIT_ID(buffers), \ + INIT_ID(bufsize), \ + INIT_ID(builtins), \ + INIT_ID(byteorder), \ + INIT_ID(bytes), \ + INIT_ID(bytes_per_sep), \ + INIT_ID(c_call), \ + INIT_ID(c_exception), \ + INIT_ID(c_return), \ + INIT_ID(cached_datetime_module), \ + INIT_ID(cached_statements), \ + INIT_ID(cadata), \ + INIT_ID(cafile), \ + INIT_ID(call), \ + INIT_ID(call_exception_handler), \ + INIT_ID(call_soon), \ + INIT_ID(callback), \ + INIT_ID(cancel), \ + INIT_ID(capath), \ + INIT_ID(category), \ + INIT_ID(cb_type), \ + INIT_ID(certfile), \ + INIT_ID(check_same_thread), \ + INIT_ID(clear), \ + INIT_ID(close), \ + INIT_ID(closed), \ + INIT_ID(closefd), \ + INIT_ID(closure), \ + INIT_ID(co_argcount), \ + INIT_ID(co_cellvars), \ + INIT_ID(co_code), \ + INIT_ID(co_consts), \ + INIT_ID(co_exceptiontable), \ + INIT_ID(co_filename), \ + INIT_ID(co_firstlineno), \ + INIT_ID(co_flags), \ + INIT_ID(co_freevars), \ + INIT_ID(co_kwonlyargcount), \ + INIT_ID(co_linetable), \ + INIT_ID(co_name), \ + INIT_ID(co_names), \ + INIT_ID(co_nlocals), \ + INIT_ID(co_posonlyargcount), \ + INIT_ID(co_qualname), \ + INIT_ID(co_stacksize), \ + INIT_ID(co_varnames), \ + INIT_ID(code), \ + INIT_ID(col_offset), \ + INIT_ID(command), \ + INIT_ID(comment_factory), \ + INIT_ID(compile_mode), \ + INIT_ID(consts), \ + INIT_ID(context), \ + INIT_ID(contravariant), \ + INIT_ID(cookie), \ + INIT_ID(copy), \ + INIT_ID(copyreg), \ + INIT_ID(coro), \ + INIT_ID(count), \ + INIT_ID(covariant), \ + INIT_ID(cwd), \ + INIT_ID(data), \ + INIT_ID(database), \ + INIT_ID(day), \ + INIT_ID(decode), \ + INIT_ID(decoder), \ + INIT_ID(default), \ + INIT_ID(defaultaction), \ + INIT_ID(delete), \ + INIT_ID(depth), \ + INIT_ID(desired_access), \ + INIT_ID(detect_types), \ + INIT_ID(deterministic), \ + INIT_ID(device), \ + INIT_ID(dict), \ + INIT_ID(dictcomp), \ + INIT_ID(difference_update), \ + INIT_ID(digest), \ + INIT_ID(digest_size), \ + INIT_ID(digestmod), \ + INIT_ID(dir_fd), \ + INIT_ID(discard), \ + INIT_ID(dispatch_table), \ + INIT_ID(displayhook), \ + INIT_ID(dklen), \ + INIT_ID(doc), \ + INIT_ID(dont_inherit), \ + INIT_ID(dst), \ + INIT_ID(dst_dir_fd), \ + INIT_ID(eager_start), \ + INIT_ID(effective_ids), \ + INIT_ID(element_factory), \ + INIT_ID(encode), \ + INIT_ID(encoding), \ + INIT_ID(end), \ + INIT_ID(end_col_offset), \ + INIT_ID(end_lineno), \ + INIT_ID(end_offset), \ + INIT_ID(endpos), \ + INIT_ID(entrypoint), \ + INIT_ID(env), \ + INIT_ID(errors), \ + INIT_ID(event), \ + INIT_ID(eventmask), \ + INIT_ID(exc_type), \ + INIT_ID(exc_value), \ + INIT_ID(excepthook), \ + INIT_ID(exception), \ + INIT_ID(existing_file_name), \ + INIT_ID(exp), \ + INIT_ID(extend), \ + INIT_ID(extra_tokens), \ + INIT_ID(facility), \ + INIT_ID(factory), \ + INIT_ID(false), \ + INIT_ID(family), \ + INIT_ID(fanout), \ + INIT_ID(fd), \ + INIT_ID(fd2), \ + INIT_ID(fdel), \ + INIT_ID(fget), \ + INIT_ID(file), \ + INIT_ID(file_actions), \ + INIT_ID(filename), \ + INIT_ID(fileno), \ + INIT_ID(filepath), \ + INIT_ID(fillvalue), \ + INIT_ID(filter), \ + INIT_ID(filters), \ + INIT_ID(final), \ + INIT_ID(find_class), \ + INIT_ID(fix_imports), \ + INIT_ID(flags), \ + INIT_ID(flush), \ + INIT_ID(fold), \ + INIT_ID(follow_symlinks), \ + INIT_ID(format), \ + INIT_ID(from_param), \ + INIT_ID(fromlist), \ + INIT_ID(fromtimestamp), \ + INIT_ID(fromutc), \ + INIT_ID(fset), \ + INIT_ID(func), \ + INIT_ID(future), \ + INIT_ID(generation), \ + INIT_ID(genexpr), \ + INIT_ID(get), \ + INIT_ID(get_debug), \ + INIT_ID(get_event_loop), \ + INIT_ID(get_loop), \ + INIT_ID(get_source), \ + INIT_ID(getattr), \ + INIT_ID(getstate), \ + INIT_ID(gid), \ + INIT_ID(globals), \ + INIT_ID(groupindex), \ + INIT_ID(groups), \ + INIT_ID(handle), \ + INIT_ID(handle_seq), \ + INIT_ID(has_location), \ + INIT_ID(hash_name), \ + INIT_ID(header), \ + INIT_ID(headers), \ + INIT_ID(hi), \ + INIT_ID(hook), \ + INIT_ID(hour), \ + INIT_ID(ident), \ + INIT_ID(identity_hint), \ + INIT_ID(ignore), \ + INIT_ID(imag), \ + INIT_ID(importlib), \ + INIT_ID(in_fd), \ + INIT_ID(incoming), \ + INIT_ID(indexgroup), \ + INIT_ID(inf), \ + INIT_ID(infer_variance), \ + INIT_ID(inherit_handle), \ + INIT_ID(inheritable), \ + INIT_ID(initial), \ + INIT_ID(initial_bytes), \ + INIT_ID(initial_owner), \ + INIT_ID(initial_state), \ + INIT_ID(initial_value), \ + INIT_ID(initval), \ + INIT_ID(inner_size), \ + INIT_ID(input), \ + INIT_ID(insert_comments), \ + INIT_ID(insert_pis), \ + INIT_ID(instructions), \ + INIT_ID(intern), \ + INIT_ID(intersection), \ + INIT_ID(interval), \ + INIT_ID(is_running), \ + INIT_ID(isatty), \ + INIT_ID(isinstance), \ + INIT_ID(isoformat), \ + INIT_ID(isolation_level), \ + INIT_ID(istext), \ + INIT_ID(item), \ + INIT_ID(items), \ + INIT_ID(iter), \ + INIT_ID(iterable), \ + INIT_ID(iterations), \ + INIT_ID(join), \ + INIT_ID(jump), \ + INIT_ID(keepends), \ + INIT_ID(key), \ + INIT_ID(keyfile), \ + INIT_ID(keys), \ + INIT_ID(kind), \ + INIT_ID(kw), \ + INIT_ID(kw1), \ + INIT_ID(kw2), \ + INIT_ID(kwdefaults), \ + INIT_ID(label), \ + INIT_ID(lambda), \ + INIT_ID(last), \ + INIT_ID(last_exc), \ + INIT_ID(last_node), \ + INIT_ID(last_traceback), \ + INIT_ID(last_type), \ + INIT_ID(last_value), \ + INIT_ID(latin1), \ + INIT_ID(leaf_size), \ + INIT_ID(len), \ + INIT_ID(length), \ + INIT_ID(level), \ + INIT_ID(limit), \ + INIT_ID(line), \ + INIT_ID(line_buffering), \ + INIT_ID(lineno), \ + INIT_ID(listcomp), \ + INIT_ID(little), \ + INIT_ID(lo), \ + INIT_ID(locale), \ + INIT_ID(locals), \ + INIT_ID(logoption), \ + INIT_ID(loop), \ + INIT_ID(manual_reset), \ + INIT_ID(mapping), \ + INIT_ID(match), \ + INIT_ID(max_length), \ + INIT_ID(maxdigits), \ + INIT_ID(maxevents), \ + INIT_ID(maxlen), \ + INIT_ID(maxmem), \ + INIT_ID(maxsplit), \ + INIT_ID(maxvalue), \ + INIT_ID(memLevel), \ + INIT_ID(memlimit), \ + INIT_ID(message), \ + INIT_ID(metaclass), \ + INIT_ID(metadata), \ + INIT_ID(method), \ + INIT_ID(microsecond), \ + INIT_ID(milliseconds), \ + INIT_ID(minute), \ + INIT_ID(mod), \ + INIT_ID(mode), \ + INIT_ID(module), \ + INIT_ID(module_globals), \ + INIT_ID(modules), \ + INIT_ID(month), \ + INIT_ID(mro), \ + INIT_ID(msg), \ + INIT_ID(mutex), \ + INIT_ID(mycmp), \ + INIT_ID(n_arg), \ + INIT_ID(n_fields), \ + INIT_ID(n_sequence_fields), \ + INIT_ID(n_unnamed_fields), \ + INIT_ID(name), \ + INIT_ID(name_from), \ + INIT_ID(namespace_separator), \ + INIT_ID(namespaces), \ + INIT_ID(narg), \ + INIT_ID(ndigits), \ + INIT_ID(nested), \ + INIT_ID(new_file_name), \ + INIT_ID(new_limit), \ + INIT_ID(newline), \ + INIT_ID(newlines), \ + INIT_ID(next), \ + INIT_ID(nlocals), \ + INIT_ID(node_depth), \ + INIT_ID(node_offset), \ + INIT_ID(ns), \ + INIT_ID(nstype), \ + INIT_ID(nt), \ + INIT_ID(null), \ + INIT_ID(number), \ + INIT_ID(obj), \ + INIT_ID(object), \ + INIT_ID(offset), \ + INIT_ID(offset_dst), \ + INIT_ID(offset_src), \ + INIT_ID(on_type_read), \ + INIT_ID(onceregistry), \ + INIT_ID(only_keys), \ + INIT_ID(oparg), \ + INIT_ID(opcode), \ + INIT_ID(open), \ + INIT_ID(opener), \ + INIT_ID(operation), \ + INIT_ID(optimize), \ + INIT_ID(options), \ + INIT_ID(order), \ + INIT_ID(origin), \ + INIT_ID(out_fd), \ + INIT_ID(outgoing), \ + INIT_ID(overlapped), \ + INIT_ID(owner), \ + INIT_ID(pages), \ + INIT_ID(parent), \ + INIT_ID(password), \ + INIT_ID(path), \ + INIT_ID(pattern), \ + INIT_ID(peek), \ + INIT_ID(persistent_id), \ + INIT_ID(persistent_load), \ + INIT_ID(person), \ + INIT_ID(pi_factory), \ + INIT_ID(pid), \ + INIT_ID(policy), \ + INIT_ID(pos), \ + INIT_ID(pos1), \ + INIT_ID(pos2), \ + INIT_ID(posix), \ + INIT_ID(print_file_and_line), \ + INIT_ID(priority), \ + INIT_ID(progress), \ + INIT_ID(progress_handler), \ + INIT_ID(progress_routine), \ + INIT_ID(proto), \ + INIT_ID(protocol), \ + INIT_ID(ps1), \ + INIT_ID(ps2), \ + INIT_ID(query), \ + INIT_ID(quotetabs), \ + INIT_ID(raw), \ + INIT_ID(read), \ + INIT_ID(read1), \ + INIT_ID(readable), \ + INIT_ID(readall), \ + INIT_ID(readinto), \ + INIT_ID(readinto1), \ + INIT_ID(readline), \ + INIT_ID(readonly), \ + INIT_ID(real), \ + INIT_ID(reducer_override), \ + INIT_ID(registry), \ + INIT_ID(rel_tol), \ + INIT_ID(release), \ + INIT_ID(reload), \ + INIT_ID(repl), \ + INIT_ID(replace), \ + INIT_ID(reserved), \ + INIT_ID(reset), \ + INIT_ID(resetids), \ + INIT_ID(return), \ + INIT_ID(reverse), \ + INIT_ID(reversed), \ + INIT_ID(salt), \ + INIT_ID(sched_priority), \ + INIT_ID(scheduler), \ + INIT_ID(second), \ + INIT_ID(security_attributes), \ + INIT_ID(seek), \ + INIT_ID(seekable), \ + INIT_ID(selectors), \ + INIT_ID(self), \ + INIT_ID(send), \ + INIT_ID(sep), \ + INIT_ID(sequence), \ + INIT_ID(server_hostname), \ + INIT_ID(server_side), \ + INIT_ID(session), \ + INIT_ID(setcomp), \ + INIT_ID(setpgroup), \ + INIT_ID(setsid), \ + INIT_ID(setsigdef), \ + INIT_ID(setsigmask), \ + INIT_ID(setstate), \ + INIT_ID(shape), \ + INIT_ID(show_cmd), \ + INIT_ID(signed), \ + INIT_ID(size), \ + INIT_ID(sizehint), \ + INIT_ID(skip_file_prefixes), \ + INIT_ID(sleep), \ + INIT_ID(sock), \ + INIT_ID(sort), \ + INIT_ID(source), \ + INIT_ID(source_traceback), \ + INIT_ID(spam), \ + INIT_ID(src), \ + INIT_ID(src_dir_fd), \ + INIT_ID(stacklevel), \ + INIT_ID(start), \ + INIT_ID(statement), \ + INIT_ID(status), \ + INIT_ID(stderr), \ + INIT_ID(stdin), \ + INIT_ID(stdout), \ + INIT_ID(step), \ + INIT_ID(steps), \ + INIT_ID(store_name), \ + INIT_ID(strategy), \ + INIT_ID(strftime), \ + INIT_ID(strict), \ + INIT_ID(strict_mode), \ + INIT_ID(string), \ + INIT_ID(sub_key), \ + INIT_ID(symmetric_difference_update), \ + INIT_ID(tabsize), \ + INIT_ID(tag), \ + INIT_ID(target), \ + INIT_ID(target_is_directory), \ + INIT_ID(task), \ + INIT_ID(tb_frame), \ + INIT_ID(tb_lasti), \ + INIT_ID(tb_lineno), \ + INIT_ID(tb_next), \ + INIT_ID(tell), \ + INIT_ID(template), \ + INIT_ID(term), \ + INIT_ID(text), \ + INIT_ID(threading), \ + INIT_ID(throw), \ + INIT_ID(timeout), \ + INIT_ID(times), \ + INIT_ID(timetuple), \ + INIT_ID(top), \ + INIT_ID(trace_callback), \ + INIT_ID(traceback), \ + INIT_ID(trailers), \ + INIT_ID(translate), \ + INIT_ID(true), \ + INIT_ID(truncate), \ + INIT_ID(twice), \ + INIT_ID(txt), \ + INIT_ID(type), \ + INIT_ID(type_params), \ + INIT_ID(tz), \ + INIT_ID(tzinfo), \ + INIT_ID(tzname), \ + INIT_ID(uid), \ + INIT_ID(unlink), \ + INIT_ID(unraisablehook), \ + INIT_ID(uri), \ + INIT_ID(usedforsecurity), \ + INIT_ID(value), \ + INIT_ID(values), \ + INIT_ID(version), \ + INIT_ID(volume), \ + INIT_ID(wait_all), \ + INIT_ID(warn_on_full_buffer), \ + INIT_ID(warnings), \ + INIT_ID(warnoptions), \ + INIT_ID(wbits), \ + INIT_ID(week), \ + INIT_ID(weekday), \ + INIT_ID(which), \ + INIT_ID(who), \ + INIT_ID(withdata), \ + INIT_ID(writable), \ + INIT_ID(write), \ + INIT_ID(write_through), \ + INIT_ID(year), \ + INIT_ID(zdict), \ +} + +#define _Py_str_ascii_INIT { \ + _PyASCIIObject_INIT("\x00"), \ + _PyASCIIObject_INIT("\x01"), \ + _PyASCIIObject_INIT("\x02"), \ + _PyASCIIObject_INIT("\x03"), \ + _PyASCIIObject_INIT("\x04"), \ + _PyASCIIObject_INIT("\x05"), \ + _PyASCIIObject_INIT("\x06"), \ + _PyASCIIObject_INIT("\x07"), \ + _PyASCIIObject_INIT("\x08"), \ + _PyASCIIObject_INIT("\x09"), \ + _PyASCIIObject_INIT("\x0a"), \ + _PyASCIIObject_INIT("\x0b"), \ + _PyASCIIObject_INIT("\x0c"), \ + _PyASCIIObject_INIT("\x0d"), \ + _PyASCIIObject_INIT("\x0e"), \ + _PyASCIIObject_INIT("\x0f"), \ + _PyASCIIObject_INIT("\x10"), \ + _PyASCIIObject_INIT("\x11"), \ + _PyASCIIObject_INIT("\x12"), \ + _PyASCIIObject_INIT("\x13"), \ + _PyASCIIObject_INIT("\x14"), \ + _PyASCIIObject_INIT("\x15"), \ + _PyASCIIObject_INIT("\x16"), \ + _PyASCIIObject_INIT("\x17"), \ + _PyASCIIObject_INIT("\x18"), \ + _PyASCIIObject_INIT("\x19"), \ + _PyASCIIObject_INIT("\x1a"), \ + _PyASCIIObject_INIT("\x1b"), \ + _PyASCIIObject_INIT("\x1c"), \ + _PyASCIIObject_INIT("\x1d"), \ + _PyASCIIObject_INIT("\x1e"), \ + _PyASCIIObject_INIT("\x1f"), \ + _PyASCIIObject_INIT("\x20"), \ + _PyASCIIObject_INIT("\x21"), \ + _PyASCIIObject_INIT("\x22"), \ + _PyASCIIObject_INIT("\x23"), \ + _PyASCIIObject_INIT("\x24"), \ + _PyASCIIObject_INIT("\x25"), \ + _PyASCIIObject_INIT("\x26"), \ + _PyASCIIObject_INIT("\x27"), \ + _PyASCIIObject_INIT("\x28"), \ + _PyASCIIObject_INIT("\x29"), \ + _PyASCIIObject_INIT("\x2a"), \ + _PyASCIIObject_INIT("\x2b"), \ + _PyASCIIObject_INIT("\x2c"), \ + _PyASCIIObject_INIT("\x2d"), \ + _PyASCIIObject_INIT("\x2e"), \ + _PyASCIIObject_INIT("\x2f"), \ + _PyASCIIObject_INIT("\x30"), \ + _PyASCIIObject_INIT("\x31"), \ + _PyASCIIObject_INIT("\x32"), \ + _PyASCIIObject_INIT("\x33"), \ + _PyASCIIObject_INIT("\x34"), \ + _PyASCIIObject_INIT("\x35"), \ + _PyASCIIObject_INIT("\x36"), \ + _PyASCIIObject_INIT("\x37"), \ + _PyASCIIObject_INIT("\x38"), \ + _PyASCIIObject_INIT("\x39"), \ + _PyASCIIObject_INIT("\x3a"), \ + _PyASCIIObject_INIT("\x3b"), \ + _PyASCIIObject_INIT("\x3c"), \ + _PyASCIIObject_INIT("\x3d"), \ + _PyASCIIObject_INIT("\x3e"), \ + _PyASCIIObject_INIT("\x3f"), \ + _PyASCIIObject_INIT("\x40"), \ + _PyASCIIObject_INIT("\x41"), \ + _PyASCIIObject_INIT("\x42"), \ + _PyASCIIObject_INIT("\x43"), \ + _PyASCIIObject_INIT("\x44"), \ + _PyASCIIObject_INIT("\x45"), \ + _PyASCIIObject_INIT("\x46"), \ + _PyASCIIObject_INIT("\x47"), \ + _PyASCIIObject_INIT("\x48"), \ + _PyASCIIObject_INIT("\x49"), \ + _PyASCIIObject_INIT("\x4a"), \ + _PyASCIIObject_INIT("\x4b"), \ + _PyASCIIObject_INIT("\x4c"), \ + _PyASCIIObject_INIT("\x4d"), \ + _PyASCIIObject_INIT("\x4e"), \ + _PyASCIIObject_INIT("\x4f"), \ + _PyASCIIObject_INIT("\x50"), \ + _PyASCIIObject_INIT("\x51"), \ + _PyASCIIObject_INIT("\x52"), \ + _PyASCIIObject_INIT("\x53"), \ + _PyASCIIObject_INIT("\x54"), \ + _PyASCIIObject_INIT("\x55"), \ + _PyASCIIObject_INIT("\x56"), \ + _PyASCIIObject_INIT("\x57"), \ + _PyASCIIObject_INIT("\x58"), \ + _PyASCIIObject_INIT("\x59"), \ + _PyASCIIObject_INIT("\x5a"), \ + _PyASCIIObject_INIT("\x5b"), \ + _PyASCIIObject_INIT("\x5c"), \ + _PyASCIIObject_INIT("\x5d"), \ + _PyASCIIObject_INIT("\x5e"), \ + _PyASCIIObject_INIT("\x5f"), \ + _PyASCIIObject_INIT("\x60"), \ + _PyASCIIObject_INIT("\x61"), \ + _PyASCIIObject_INIT("\x62"), \ + _PyASCIIObject_INIT("\x63"), \ + _PyASCIIObject_INIT("\x64"), \ + _PyASCIIObject_INIT("\x65"), \ + _PyASCIIObject_INIT("\x66"), \ + _PyASCIIObject_INIT("\x67"), \ + _PyASCIIObject_INIT("\x68"), \ + _PyASCIIObject_INIT("\x69"), \ + _PyASCIIObject_INIT("\x6a"), \ + _PyASCIIObject_INIT("\x6b"), \ + _PyASCIIObject_INIT("\x6c"), \ + _PyASCIIObject_INIT("\x6d"), \ + _PyASCIIObject_INIT("\x6e"), \ + _PyASCIIObject_INIT("\x6f"), \ + _PyASCIIObject_INIT("\x70"), \ + _PyASCIIObject_INIT("\x71"), \ + _PyASCIIObject_INIT("\x72"), \ + _PyASCIIObject_INIT("\x73"), \ + _PyASCIIObject_INIT("\x74"), \ + _PyASCIIObject_INIT("\x75"), \ + _PyASCIIObject_INIT("\x76"), \ + _PyASCIIObject_INIT("\x77"), \ + _PyASCIIObject_INIT("\x78"), \ + _PyASCIIObject_INIT("\x79"), \ + _PyASCIIObject_INIT("\x7a"), \ + _PyASCIIObject_INIT("\x7b"), \ + _PyASCIIObject_INIT("\x7c"), \ + _PyASCIIObject_INIT("\x7d"), \ + _PyASCIIObject_INIT("\x7e"), \ + _PyASCIIObject_INIT("\x7f"), \ +} + +#define _Py_str_latin1_INIT { \ + _PyUnicode_LATIN1_INIT("\x80", "\xc2\x80"), \ + _PyUnicode_LATIN1_INIT("\x81", "\xc2\x81"), \ + _PyUnicode_LATIN1_INIT("\x82", "\xc2\x82"), \ + _PyUnicode_LATIN1_INIT("\x83", "\xc2\x83"), \ + _PyUnicode_LATIN1_INIT("\x84", "\xc2\x84"), \ + _PyUnicode_LATIN1_INIT("\x85", "\xc2\x85"), \ + _PyUnicode_LATIN1_INIT("\x86", "\xc2\x86"), \ + _PyUnicode_LATIN1_INIT("\x87", "\xc2\x87"), \ + _PyUnicode_LATIN1_INIT("\x88", "\xc2\x88"), \ + _PyUnicode_LATIN1_INIT("\x89", "\xc2\x89"), \ + _PyUnicode_LATIN1_INIT("\x8a", "\xc2\x8a"), \ + _PyUnicode_LATIN1_INIT("\x8b", "\xc2\x8b"), \ + _PyUnicode_LATIN1_INIT("\x8c", "\xc2\x8c"), \ + _PyUnicode_LATIN1_INIT("\x8d", "\xc2\x8d"), \ + _PyUnicode_LATIN1_INIT("\x8e", "\xc2\x8e"), \ + _PyUnicode_LATIN1_INIT("\x8f", "\xc2\x8f"), \ + _PyUnicode_LATIN1_INIT("\x90", "\xc2\x90"), \ + _PyUnicode_LATIN1_INIT("\x91", "\xc2\x91"), \ + _PyUnicode_LATIN1_INIT("\x92", "\xc2\x92"), \ + _PyUnicode_LATIN1_INIT("\x93", "\xc2\x93"), \ + _PyUnicode_LATIN1_INIT("\x94", "\xc2\x94"), \ + _PyUnicode_LATIN1_INIT("\x95", "\xc2\x95"), \ + _PyUnicode_LATIN1_INIT("\x96", "\xc2\x96"), \ + _PyUnicode_LATIN1_INIT("\x97", "\xc2\x97"), \ + _PyUnicode_LATIN1_INIT("\x98", "\xc2\x98"), \ + _PyUnicode_LATIN1_INIT("\x99", "\xc2\x99"), \ + _PyUnicode_LATIN1_INIT("\x9a", "\xc2\x9a"), \ + _PyUnicode_LATIN1_INIT("\x9b", "\xc2\x9b"), \ + _PyUnicode_LATIN1_INIT("\x9c", "\xc2\x9c"), \ + _PyUnicode_LATIN1_INIT("\x9d", "\xc2\x9d"), \ + _PyUnicode_LATIN1_INIT("\x9e", "\xc2\x9e"), \ + _PyUnicode_LATIN1_INIT("\x9f", "\xc2\x9f"), \ + _PyUnicode_LATIN1_INIT("\xa0", "\xc2\xa0"), \ + _PyUnicode_LATIN1_INIT("\xa1", "\xc2\xa1"), \ + _PyUnicode_LATIN1_INIT("\xa2", "\xc2\xa2"), \ + _PyUnicode_LATIN1_INIT("\xa3", "\xc2\xa3"), \ + _PyUnicode_LATIN1_INIT("\xa4", "\xc2\xa4"), \ + _PyUnicode_LATIN1_INIT("\xa5", "\xc2\xa5"), \ + _PyUnicode_LATIN1_INIT("\xa6", "\xc2\xa6"), \ + _PyUnicode_LATIN1_INIT("\xa7", "\xc2\xa7"), \ + _PyUnicode_LATIN1_INIT("\xa8", "\xc2\xa8"), \ + _PyUnicode_LATIN1_INIT("\xa9", "\xc2\xa9"), \ + _PyUnicode_LATIN1_INIT("\xaa", "\xc2\xaa"), \ + _PyUnicode_LATIN1_INIT("\xab", "\xc2\xab"), \ + _PyUnicode_LATIN1_INIT("\xac", "\xc2\xac"), \ + _PyUnicode_LATIN1_INIT("\xad", "\xc2\xad"), \ + _PyUnicode_LATIN1_INIT("\xae", "\xc2\xae"), \ + _PyUnicode_LATIN1_INIT("\xaf", "\xc2\xaf"), \ + _PyUnicode_LATIN1_INIT("\xb0", "\xc2\xb0"), \ + _PyUnicode_LATIN1_INIT("\xb1", "\xc2\xb1"), \ + _PyUnicode_LATIN1_INIT("\xb2", "\xc2\xb2"), \ + _PyUnicode_LATIN1_INIT("\xb3", "\xc2\xb3"), \ + _PyUnicode_LATIN1_INIT("\xb4", "\xc2\xb4"), \ + _PyUnicode_LATIN1_INIT("\xb5", "\xc2\xb5"), \ + _PyUnicode_LATIN1_INIT("\xb6", "\xc2\xb6"), \ + _PyUnicode_LATIN1_INIT("\xb7", "\xc2\xb7"), \ + _PyUnicode_LATIN1_INIT("\xb8", "\xc2\xb8"), \ + _PyUnicode_LATIN1_INIT("\xb9", "\xc2\xb9"), \ + _PyUnicode_LATIN1_INIT("\xba", "\xc2\xba"), \ + _PyUnicode_LATIN1_INIT("\xbb", "\xc2\xbb"), \ + _PyUnicode_LATIN1_INIT("\xbc", "\xc2\xbc"), \ + _PyUnicode_LATIN1_INIT("\xbd", "\xc2\xbd"), \ + _PyUnicode_LATIN1_INIT("\xbe", "\xc2\xbe"), \ + _PyUnicode_LATIN1_INIT("\xbf", "\xc2\xbf"), \ + _PyUnicode_LATIN1_INIT("\xc0", "\xc3\x80"), \ + _PyUnicode_LATIN1_INIT("\xc1", "\xc3\x81"), \ + _PyUnicode_LATIN1_INIT("\xc2", "\xc3\x82"), \ + _PyUnicode_LATIN1_INIT("\xc3", "\xc3\x83"), \ + _PyUnicode_LATIN1_INIT("\xc4", "\xc3\x84"), \ + _PyUnicode_LATIN1_INIT("\xc5", "\xc3\x85"), \ + _PyUnicode_LATIN1_INIT("\xc6", "\xc3\x86"), \ + _PyUnicode_LATIN1_INIT("\xc7", "\xc3\x87"), \ + _PyUnicode_LATIN1_INIT("\xc8", "\xc3\x88"), \ + _PyUnicode_LATIN1_INIT("\xc9", "\xc3\x89"), \ + _PyUnicode_LATIN1_INIT("\xca", "\xc3\x8a"), \ + _PyUnicode_LATIN1_INIT("\xcb", "\xc3\x8b"), \ + _PyUnicode_LATIN1_INIT("\xcc", "\xc3\x8c"), \ + _PyUnicode_LATIN1_INIT("\xcd", "\xc3\x8d"), \ + _PyUnicode_LATIN1_INIT("\xce", "\xc3\x8e"), \ + _PyUnicode_LATIN1_INIT("\xcf", "\xc3\x8f"), \ + _PyUnicode_LATIN1_INIT("\xd0", "\xc3\x90"), \ + _PyUnicode_LATIN1_INIT("\xd1", "\xc3\x91"), \ + _PyUnicode_LATIN1_INIT("\xd2", "\xc3\x92"), \ + _PyUnicode_LATIN1_INIT("\xd3", "\xc3\x93"), \ + _PyUnicode_LATIN1_INIT("\xd4", "\xc3\x94"), \ + _PyUnicode_LATIN1_INIT("\xd5", "\xc3\x95"), \ + _PyUnicode_LATIN1_INIT("\xd6", "\xc3\x96"), \ + _PyUnicode_LATIN1_INIT("\xd7", "\xc3\x97"), \ + _PyUnicode_LATIN1_INIT("\xd8", "\xc3\x98"), \ + _PyUnicode_LATIN1_INIT("\xd9", "\xc3\x99"), \ + _PyUnicode_LATIN1_INIT("\xda", "\xc3\x9a"), \ + _PyUnicode_LATIN1_INIT("\xdb", "\xc3\x9b"), \ + _PyUnicode_LATIN1_INIT("\xdc", "\xc3\x9c"), \ + _PyUnicode_LATIN1_INIT("\xdd", "\xc3\x9d"), \ + _PyUnicode_LATIN1_INIT("\xde", "\xc3\x9e"), \ + _PyUnicode_LATIN1_INIT("\xdf", "\xc3\x9f"), \ + _PyUnicode_LATIN1_INIT("\xe0", "\xc3\xa0"), \ + _PyUnicode_LATIN1_INIT("\xe1", "\xc3\xa1"), \ + _PyUnicode_LATIN1_INIT("\xe2", "\xc3\xa2"), \ + _PyUnicode_LATIN1_INIT("\xe3", "\xc3\xa3"), \ + _PyUnicode_LATIN1_INIT("\xe4", "\xc3\xa4"), \ + _PyUnicode_LATIN1_INIT("\xe5", "\xc3\xa5"), \ + _PyUnicode_LATIN1_INIT("\xe6", "\xc3\xa6"), \ + _PyUnicode_LATIN1_INIT("\xe7", "\xc3\xa7"), \ + _PyUnicode_LATIN1_INIT("\xe8", "\xc3\xa8"), \ + _PyUnicode_LATIN1_INIT("\xe9", "\xc3\xa9"), \ + _PyUnicode_LATIN1_INIT("\xea", "\xc3\xaa"), \ + _PyUnicode_LATIN1_INIT("\xeb", "\xc3\xab"), \ + _PyUnicode_LATIN1_INIT("\xec", "\xc3\xac"), \ + _PyUnicode_LATIN1_INIT("\xed", "\xc3\xad"), \ + _PyUnicode_LATIN1_INIT("\xee", "\xc3\xae"), \ + _PyUnicode_LATIN1_INIT("\xef", "\xc3\xaf"), \ + _PyUnicode_LATIN1_INIT("\xf0", "\xc3\xb0"), \ + _PyUnicode_LATIN1_INIT("\xf1", "\xc3\xb1"), \ + _PyUnicode_LATIN1_INIT("\xf2", "\xc3\xb2"), \ + _PyUnicode_LATIN1_INIT("\xf3", "\xc3\xb3"), \ + _PyUnicode_LATIN1_INIT("\xf4", "\xc3\xb4"), \ + _PyUnicode_LATIN1_INIT("\xf5", "\xc3\xb5"), \ + _PyUnicode_LATIN1_INIT("\xf6", "\xc3\xb6"), \ + _PyUnicode_LATIN1_INIT("\xf7", "\xc3\xb7"), \ + _PyUnicode_LATIN1_INIT("\xf8", "\xc3\xb8"), \ + _PyUnicode_LATIN1_INIT("\xf9", "\xc3\xb9"), \ + _PyUnicode_LATIN1_INIT("\xfa", "\xc3\xba"), \ + _PyUnicode_LATIN1_INIT("\xfb", "\xc3\xbb"), \ + _PyUnicode_LATIN1_INIT("\xfc", "\xc3\xbc"), \ + _PyUnicode_LATIN1_INIT("\xfd", "\xc3\xbd"), \ + _PyUnicode_LATIN1_INIT("\xfe", "\xc3\xbe"), \ + _PyUnicode_LATIN1_INIT("\xff", "\xc3\xbf"), \ +} +/* End auto-generated code */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_RUNTIME_INIT_GENERATED_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_semaphore.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_semaphore.h new file mode 100644 index 00000000..26953838 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_semaphore.h @@ -0,0 +1,67 @@ +// The _PySemaphore API a simplified cross-platform semaphore used to implement +// wakeup/sleep. +#ifndef Py_INTERNAL_SEMAPHORE_H +#define Py_INTERNAL_SEMAPHORE_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_pythread.h" // _POSIX_SEMAPHORES + +#ifdef MS_WINDOWS +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include +#elif defined(HAVE_PTHREAD_H) +# include +#elif defined(HAVE_PTHREAD_STUBS) +# include "cpython/pthread_stubs.h" +#else +# error "Require native threads. See https://bugs.python.org/issue31370" +#endif + +#if (defined(_POSIX_SEMAPHORES) && (_POSIX_SEMAPHORES+0) != -1 && \ + defined(HAVE_SEM_TIMEDWAIT)) +# define _Py_USE_SEMAPHORES +# include +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _PySemaphore { +#if defined(MS_WINDOWS) + HANDLE platform_sem; +#elif defined(_Py_USE_SEMAPHORES) + sem_t platform_sem; +#else + pthread_mutex_t mutex; + pthread_cond_t cond; + int counter; +#endif +} _PySemaphore; + +// Puts the current thread to sleep until _PySemaphore_Wakeup() is called. +// If `detach` is true, then the thread will detach/release the GIL while +// sleeping. +PyAPI_FUNC(int) +_PySemaphore_Wait(_PySemaphore *sema, PyTime_t timeout_ns, int detach); + +// Wakes up a single thread waiting on sema. Note that _PySemaphore_Wakeup() +// can be called before _PySemaphore_Wait(). +PyAPI_FUNC(void) +_PySemaphore_Wakeup(_PySemaphore *sema); + +// Initializes/destroys a semaphore +PyAPI_FUNC(void) _PySemaphore_Init(_PySemaphore *sema); +PyAPI_FUNC(void) _PySemaphore_Destroy(_PySemaphore *sema); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_SEMAPHORE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_setobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_setobject.h new file mode 100644 index 00000000..0494c07f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_setobject.h @@ -0,0 +1,39 @@ +#ifndef Py_INTERNAL_SETOBJECT_H +#define Py_INTERNAL_SETOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Export for '_abc' shared extension +PyAPI_FUNC(int) _PySet_NextEntry( + PyObject *set, + Py_ssize_t *pos, + PyObject **key, + Py_hash_t *hash); + +// Export for '_pickle' shared extension +PyAPI_FUNC(int) _PySet_NextEntryRef( + PyObject *set, + Py_ssize_t *pos, + PyObject **key, + Py_hash_t *hash); + +// Export for '_pickle' shared extension +PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable); + +// Export for the gdb plugin's (python-gdb.py) benefit +PyAPI_DATA(PyObject *) _PySet_Dummy; + +PyAPI_FUNC(int) _PySet_Contains(PySetObject *so, PyObject *key); + +// Clears the set without acquiring locks. Used by _PyCode_Fini. +extern void _PySet_ClearInternal(PySetObject *so); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_SETOBJECT_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_signal.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_signal.h new file mode 100644 index 00000000..47213a34 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_signal.h @@ -0,0 +1,108 @@ +// Define Py_NSIG constant for signal handling. + +#ifndef Py_INTERNAL_SIGNAL_H +#define Py_INTERNAL_SIGNAL_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include // NSIG + + +// Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. +// Export for '_posixsubprocess' shared extension. +PyAPI_FUNC(void) _Py_RestoreSignals(void); + +#ifdef _SIG_MAXSIG + // gh-91145: On FreeBSD, defines NSIG as 32: it doesn't include + // realtime signals: [SIGRTMIN,SIGRTMAX]. Use _SIG_MAXSIG instead. For + // example on x86-64 FreeBSD 13, SIGRTMAX is 126 and _SIG_MAXSIG is 128. +# define Py_NSIG _SIG_MAXSIG +#elif defined(NSIG) +# define Py_NSIG NSIG +#elif defined(_NSIG) +# define Py_NSIG _NSIG // BSD/SysV +#elif defined(_SIGMAX) +# define Py_NSIG (_SIGMAX + 1) // QNX +#elif defined(SIGMAX) +# define Py_NSIG (SIGMAX + 1) // djgpp +#else +# define Py_NSIG 64 // Use a reasonable default value +#endif + +#define INVALID_FD (-1) + +struct _signals_runtime_state { + struct { + // tripped and func should be accessed using atomic ops. + int tripped; + PyObject* func; + } handlers[Py_NSIG]; + + volatile struct { +#ifdef MS_WINDOWS + /* This would be "SOCKET fd" if were always included. + It isn't so we must cast to SOCKET where appropriate. */ + volatile int fd; +#elif defined(__VXWORKS__) + int fd; +#else + sig_atomic_t fd; +#endif + + int warn_on_full_buffer; +#ifdef MS_WINDOWS + int use_send; +#endif + } wakeup; + + /* Speed up sigcheck() when none tripped. + is_tripped should be accessed using atomic ops. */ + int is_tripped; + + /* These objects necessarily belong to the main interpreter. */ + PyObject *default_handler; + PyObject *ignore_handler; + +#ifdef MS_WINDOWS + /* This would be "HANDLE sigint_event" if were always included. + It isn't so we must cast to HANDLE everywhere "sigint_event" is used. */ + void *sigint_event; +#endif + + /* True if the main interpreter thread exited due to an unhandled + * KeyboardInterrupt exception, suggesting the user pressed ^C. */ + int unhandled_keyboard_interrupt; +}; + +#ifdef MS_WINDOWS +# define _signals_WAKEUP_INIT \ + {.fd = INVALID_FD, .warn_on_full_buffer = 1, .use_send = 0} +#else +# define _signals_WAKEUP_INIT \ + {.fd = INVALID_FD, .warn_on_full_buffer = 1} +#endif + +#define _signals_RUNTIME_INIT \ + { \ + .wakeup = _signals_WAKEUP_INIT, \ + } + + +// Export for '_multiprocessing' shared extension +PyAPI_FUNC(int) _PyOS_IsMainThread(void); + +#ifdef MS_WINDOWS +// is not included by Python.h so use void* instead of HANDLE. +// Export for '_multiprocessing' shared extension +PyAPI_FUNC(void*) _PyOS_SigintEvent(void); +#endif + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_SIGNAL_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_sliceobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_sliceobject.h new file mode 100644 index 00000000..ba8b1f1c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_sliceobject.h @@ -0,0 +1,20 @@ +#ifndef Py_INTERNAL_SLICEOBJECT_H +#define Py_INTERNAL_SLICEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +/* runtime lifecycle */ + +PyAPI_FUNC(PyObject *) +_PyBuildSlice_ConsumeRefs(PyObject *start, PyObject *stop); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_SLICEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_stackref.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_stackref.h new file mode 100644 index 00000000..93898174 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_stackref.h @@ -0,0 +1,195 @@ +#ifndef Py_INTERNAL_STACKREF_H +#define Py_INTERNAL_STACKREF_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include + +typedef union { + uintptr_t bits; +} _PyStackRef; + +static const _PyStackRef Py_STACKREF_NULL = { .bits = 0 }; + +#define Py_TAG_DEFERRED (1) + +// Gets a PyObject * from a _PyStackRef +#if defined(Py_GIL_DISABLED) +static inline PyObject * +PyStackRef_Get(_PyStackRef tagged) +{ + PyObject *cleared = ((PyObject *)((tagged).bits & (~Py_TAG_DEFERRED))); + return cleared; +} +#else +# define PyStackRef_Get(tagged) ((PyObject *)((tagged).bits)) +#endif + +// Converts a PyObject * to a PyStackRef, stealing the reference. +#if defined(Py_GIL_DISABLED) +static inline _PyStackRef +_PyStackRef_StealRef(PyObject *obj) +{ + // Make sure we don't take an already tagged value. + assert(((uintptr_t)obj & Py_TAG_DEFERRED) == 0); + return ((_PyStackRef){.bits = ((uintptr_t)(obj))}); +} +# define PyStackRef_StealRef(obj) _PyStackRef_StealRef(_PyObject_CAST(obj)) +#else +# define PyStackRef_StealRef(obj) ((_PyStackRef){.bits = ((uintptr_t)(obj))}) +#endif + +// Converts a PyObject * to a PyStackRef, with a new reference +#if defined(Py_GIL_DISABLED) +static inline _PyStackRef +_PyStackRef_NewRefDeferred(PyObject *obj) +{ + // Make sure we don't take an already tagged value. + assert(((uintptr_t)obj & Py_TAG_DEFERRED) == 0); + assert(obj != NULL); + if (_PyObject_HasDeferredRefcount(obj)) { + return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_DEFERRED }; + } + else { + return (_PyStackRef){ .bits = (uintptr_t)Py_NewRef(obj) }; + } +} +# define PyStackRef_NewRefDeferred(obj) _PyStackRef_NewRefDeferred(_PyObject_CAST(obj)) +#else +# define PyStackRef_NewRefDeferred(obj) PyStackRef_NewRef(((_PyStackRef){.bits = ((uintptr_t)(obj))})) +#endif + +#if defined(Py_GIL_DISABLED) +static inline _PyStackRef +_PyStackRef_XNewRefDeferred(PyObject *obj) +{ + // Make sure we don't take an already tagged value. + assert(((uintptr_t)obj & Py_TAG_DEFERRED) == 0); + if (obj == NULL) { + return Py_STACKREF_NULL; + } + return _PyStackRef_NewRefDeferred(obj); +} +# define PyStackRef_XNewRefDeferred(obj) _PyStackRef_XNewRefDeferred(_PyObject_CAST(obj)) +#else +# define PyStackRef_XNewRefDeferred(obj) PyStackRef_XNewRef(((_PyStackRef){.bits = ((uintptr_t)(obj))})) +#endif + +// Converts a PyStackRef back to a PyObject *. +#if defined(Py_GIL_DISABLED) +static inline PyObject * +PyStackRef_StealObject(_PyStackRef tagged) +{ + if ((tagged.bits & Py_TAG_DEFERRED) == Py_TAG_DEFERRED) { + assert(_PyObject_HasDeferredRefcount(PyStackRef_Get(tagged))); + return Py_NewRef(PyStackRef_Get(tagged)); + } + return PyStackRef_Get(tagged); +} +#else +# define PyStackRef_StealObject(tagged) PyStackRef_Get(tagged) +#endif + +static inline void +_Py_untag_stack_borrowed(PyObject **dst, const _PyStackRef *src, size_t length) +{ + for (size_t i = 0; i < length; i++) { + dst[i] = PyStackRef_Get(src[i]); + } +} + +static inline void +_Py_untag_stack_steal(PyObject **dst, const _PyStackRef *src, size_t length) +{ + for (size_t i = 0; i < length; i++) { + dst[i] = PyStackRef_StealObject(src[i]); + } +} + + +#define PyStackRef_XSETREF(dst, src) \ + do { \ + _PyStackRef *_tmp_dst_ptr = &(dst); \ + _PyStackRef _tmp_old_dst = (*_tmp_dst_ptr); \ + *_tmp_dst_ptr = (src); \ + PyStackRef_XDECREF(_tmp_old_dst); \ + } while (0) + +#define PyStackRef_SETREF(dst, src) \ + do { \ + _PyStackRef *_tmp_dst_ptr = &(dst); \ + _PyStackRef _tmp_old_dst = (*_tmp_dst_ptr); \ + *_tmp_dst_ptr = (src); \ + PyStackRef_DECREF(_tmp_old_dst); \ + } while (0) + +#define PyStackRef_CLEAR(op) \ + do { \ + _PyStackRef *_tmp_op_ptr = &(op); \ + _PyStackRef _tmp_old_op = (*_tmp_op_ptr); \ + if (_tmp_old_op.bits != Py_STACKREF_NULL.bits) { \ + *_tmp_op_ptr = Py_STACKREF_NULL; \ + PyStackRef_DECREF(_tmp_old_op); \ + } \ + } while (0) + +#if defined(Py_GIL_DISABLED) +static inline void +PyStackRef_DECREF(_PyStackRef tagged) +{ + if ((tagged.bits & Py_TAG_DEFERRED) == Py_TAG_DEFERRED) { + return; + } + Py_DECREF(PyStackRef_Get(tagged)); +} +#else +# define PyStackRef_DECREF(op) Py_DECREF(PyStackRef_Get(op)) +#endif + +#if defined(Py_GIL_DISABLED) +static inline void +PyStackRef_INCREF(_PyStackRef tagged) +{ + if ((tagged.bits & Py_TAG_DEFERRED) == Py_TAG_DEFERRED) { + assert(_PyObject_HasDeferredRefcount(PyStackRef_Get(tagged))); + return; + } + Py_INCREF(PyStackRef_Get(tagged)); +} +#else +# define PyStackRef_INCREF(op) Py_INCREF(PyStackRef_Get(op)) +#endif + +static inline void +PyStackRef_XDECREF(_PyStackRef op) +{ + if (op.bits != Py_STACKREF_NULL.bits) { + PyStackRef_DECREF(op); + } +} + +static inline _PyStackRef +PyStackRef_NewRef(_PyStackRef obj) +{ + PyStackRef_INCREF(obj); + return obj; +} + +static inline _PyStackRef +PyStackRef_XNewRef(_PyStackRef obj) +{ + if (obj.bits == Py_STACKREF_NULL.bits) { + return obj; + } + return PyStackRef_NewRef(obj); +} + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_STACKREF_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_strhex.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_strhex.h new file mode 100644 index 00000000..225f4239 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_strhex.h @@ -0,0 +1,39 @@ +#ifndef Py_INTERNAL_STRHEX_H +#define Py_INTERNAL_STRHEX_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Returns a str() containing the hex representation of argbuf. +// Export for '_hashlib' shared extension. +PyAPI_FUNC(PyObject*) _Py_strhex(const + char* argbuf, + const Py_ssize_t arglen); + +// Returns a bytes() containing the ASCII hex representation of argbuf. +extern PyObject* _Py_strhex_bytes( + const char* argbuf, + const Py_ssize_t arglen); + +// These variants include support for a separator between every N bytes: +extern PyObject* _Py_strhex_with_sep( + const char* argbuf, + const Py_ssize_t arglen, + PyObject* sep, + const int bytes_per_group); + +// Export for 'binascii' shared extension +PyAPI_FUNC(PyObject*) _Py_strhex_bytes_with_sep( + const char* argbuf, + const Py_ssize_t arglen, + PyObject* sep, + const int bytes_per_group); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_STRHEX_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_structseq.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_structseq.h new file mode 100644 index 00000000..5cff1656 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_structseq.h @@ -0,0 +1,40 @@ +#ifndef Py_INTERNAL_STRUCTSEQ_H +#define Py_INTERNAL_STRUCTSEQ_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +/* other API */ + +// Export for '_curses' shared extension +PyAPI_FUNC(PyTypeObject*) _PyStructSequence_NewType( + PyStructSequence_Desc *desc, + unsigned long tp_flags); + +extern int _PyStructSequence_InitBuiltinWithFlags( + PyInterpreterState *interp, + PyTypeObject *type, + PyStructSequence_Desc *desc, + unsigned long tp_flags); + +static inline int +_PyStructSequence_InitBuiltin(PyInterpreterState *interp, + PyTypeObject *type, + PyStructSequence_Desc *desc) +{ + return _PyStructSequence_InitBuiltinWithFlags(interp, type, desc, 0); +} + +extern void _PyStructSequence_FiniBuiltin( + PyInterpreterState *interp, + PyTypeObject *type); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_STRUCTSEQ_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_symtable.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_symtable.h new file mode 100644 index 00000000..90252bf8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_symtable.h @@ -0,0 +1,204 @@ +#ifndef Py_INTERNAL_SYMTABLE_H +#define Py_INTERNAL_SYMTABLE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +struct _mod; // Type defined in pycore_ast.h + +typedef enum _block_type { + FunctionBlock, ClassBlock, ModuleBlock, + // Used for annotations if 'from __future__ import annotations' is active. + // Annotation blocks cannot bind names and are not evaluated. + AnnotationBlock, + + // The following blocks are used for generics and type aliases. These work + // mostly like functions (see PEP 695 for details). The three different + // blocks function identically; they are different enum entries only so + // that error messages can be more precise. + + // The block to enter when processing a "type" (PEP 695) construction, + // e.g., "type MyGeneric[T] = list[T]". + TypeAliasBlock, + // The block to enter when processing a "generic" (PEP 695) object, + // e.g., "def foo[T](): pass" or "class A[T]: pass". + TypeParametersBlock, + // The block to enter when processing the bound, the constraint tuple + // or the default value of a single "type variable" in the formal sense, + // i.e., a TypeVar, a TypeVarTuple or a ParamSpec object (the latter two + // do not support a bound or a constraint tuple). + TypeVariableBlock, +} _Py_block_ty; + +typedef enum _comprehension_type { + NoComprehension = 0, + ListComprehension = 1, + DictComprehension = 2, + SetComprehension = 3, + GeneratorExpression = 4 } _Py_comprehension_ty; + +/* source location information */ +typedef struct { + int lineno; + int end_lineno; + int col_offset; + int end_col_offset; +} _Py_SourceLocation; + +#define SRC_LOCATION_FROM_AST(n) \ + (_Py_SourceLocation){ \ + .lineno = (n)->lineno, \ + .end_lineno = (n)->end_lineno, \ + .col_offset = (n)->col_offset, \ + .end_col_offset = (n)->end_col_offset } + +static const _Py_SourceLocation NO_LOCATION = {-1, -1, -1, -1}; + +/* __future__ information */ +typedef struct { + int ff_features; /* flags set by future statements */ + _Py_SourceLocation ff_location; /* location of last future statement */ +} _PyFutureFeatures; + +struct _symtable_entry; + +struct symtable { + PyObject *st_filename; /* name of file being compiled, + decoded from the filesystem encoding */ + struct _symtable_entry *st_cur; /* current symbol table entry */ + struct _symtable_entry *st_top; /* symbol table entry for module */ + PyObject *st_blocks; /* dict: map AST node addresses + * to symbol table entries */ + PyObject *st_stack; /* list: stack of namespace info */ + PyObject *st_global; /* borrowed ref to st_top->ste_symbols */ + int st_nblocks; /* number of blocks used. kept for + consistency with the corresponding + compiler structure */ + PyObject *st_private; /* name of current class or NULL */ + _PyFutureFeatures *st_future; /* module's future features that affect + the symbol table */ + int recursion_depth; /* current recursion depth */ + int recursion_limit; /* recursion limit */ +}; + +typedef struct _symtable_entry { + PyObject_HEAD + PyObject *ste_id; /* int: key in ste_table->st_blocks */ + PyObject *ste_symbols; /* dict: variable names to flags */ + PyObject *ste_name; /* string: name of current block */ + PyObject *ste_varnames; /* list of function parameters */ + PyObject *ste_children; /* list of child blocks */ + PyObject *ste_directives;/* locations of global and nonlocal statements */ + PyObject *ste_mangled_names; /* set of names for which mangling should be applied */ + + _Py_block_ty ste_type; + // Optional string set by symtable.c and used when reporting errors. + // The content of that string is a description of the current "context". + // + // For instance, if we are processing the default value of the type + // variable "T" in "def foo[T = int](): pass", `ste_scope_info` is + // set to "a TypeVar default". + const char *ste_scope_info; + + int ste_nested; /* true if block is nested */ + unsigned ste_free : 1; /* true if block has free variables */ + unsigned ste_child_free : 1; /* true if a child block has free vars, + including free refs to globals */ + unsigned ste_generator : 1; /* true if namespace is a generator */ + unsigned ste_coroutine : 1; /* true if namespace is a coroutine */ + _Py_comprehension_ty ste_comprehension; /* Kind of comprehension (if any) */ + unsigned ste_varargs : 1; /* true if block has varargs */ + unsigned ste_varkeywords : 1; /* true if block has varkeywords */ + unsigned ste_returns_value : 1; /* true if namespace uses return with + an argument */ + unsigned ste_needs_class_closure : 1; /* for class scopes, true if a + closure over __class__ + should be created */ + unsigned ste_needs_classdict : 1; /* for class scopes, true if a closure + over the class dict should be created */ + unsigned ste_comp_inlined : 1; /* true if this comprehension is inlined */ + unsigned ste_comp_iter_target : 1; /* true if visiting comprehension target */ + unsigned ste_can_see_class_scope : 1; /* true if this block can see names bound in an + enclosing class scope */ + int ste_comp_iter_expr; /* non-zero if visiting a comprehension range expression */ + int ste_lineno; /* first line of block */ + int ste_col_offset; /* offset of first line of block */ + int ste_end_lineno; /* end line of block */ + int ste_end_col_offset; /* end offset of first line of block */ + int ste_opt_lineno; /* lineno of last exec or import * */ + int ste_opt_col_offset; /* offset of last exec or import * */ + struct symtable *ste_table; +} PySTEntryObject; + +extern PyTypeObject PySTEntry_Type; + +#define PySTEntry_Check(op) Py_IS_TYPE((op), &PySTEntry_Type) + +extern long _PyST_GetSymbol(PySTEntryObject *, PyObject *); +extern int _PyST_GetScope(PySTEntryObject *, PyObject *); +extern int _PyST_IsFunctionLike(PySTEntryObject *); + +extern struct symtable* _PySymtable_Build( + struct _mod *mod, + PyObject *filename, + _PyFutureFeatures *future); +extern PySTEntryObject* _PySymtable_Lookup(struct symtable *, void *); + +extern void _PySymtable_Free(struct symtable *); + +extern PyObject *_Py_MaybeMangle(PyObject *privateobj, PySTEntryObject *ste, PyObject *name); +extern PyObject* _Py_Mangle(PyObject *p, PyObject *name); + +/* Flags for def-use information */ + +#define DEF_GLOBAL 1 /* global stmt */ +#define DEF_LOCAL 2 /* assignment in code block */ +#define DEF_PARAM (2<<1) /* formal parameter */ +#define DEF_NONLOCAL (2<<2) /* nonlocal stmt */ +#define USE (2<<3) /* name is used */ +#define DEF_FREE (2<<4) /* name used but not defined in nested block */ +#define DEF_FREE_CLASS (2<<5) /* free variable from class's method */ +#define DEF_IMPORT (2<<6) /* assignment occurred via import */ +#define DEF_ANNOT (2<<7) /* this name is annotated */ +#define DEF_COMP_ITER (2<<8) /* this name is a comprehension iteration variable */ +#define DEF_TYPE_PARAM (2<<9) /* this name is a type parameter */ +#define DEF_COMP_CELL (2<<10) /* this name is a cell in an inlined comprehension */ + +#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) + +/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol + table. GLOBAL is returned from PyST_GetScope() for either of them. + It is stored in ste_symbols at bits 13-16. +*/ +#define SCOPE_OFFSET 12 +#define SCOPE_MASK (DEF_GLOBAL | DEF_LOCAL | DEF_PARAM | DEF_NONLOCAL) + +#define LOCAL 1 +#define GLOBAL_EXPLICIT 2 +#define GLOBAL_IMPLICIT 3 +#define FREE 4 +#define CELL 5 + +#define GENERATOR 1 +#define GENERATOR_EXPRESSION 2 + +// Used by symtablemodule.c +extern struct symtable* _Py_SymtableStringObjectFlags( + const char *str, + PyObject *filename, + int start, + PyCompilerFlags *flags); + +int _PyFuture_FromAST( + struct _mod * mod, + PyObject *filename, + _PyFutureFeatures* futures); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_SYMTABLE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_sysmodule.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_sysmodule.h new file mode 100644 index 00000000..6df57448 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_sysmodule.h @@ -0,0 +1,38 @@ +#ifndef Py_INTERNAL_SYSMODULE_H +#define Py_INTERNAL_SYSMODULE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +PyAPI_FUNC(PyObject *) _PySys_GetAttr(PyThreadState *, PyObject *); /* unused */ +PyAPI_FUNC(int) _PySys_GetOptionalAttr(PyObject *, PyObject **); +PyAPI_FUNC(int) _PySys_GetOptionalAttrString(const char *, PyObject **); +PyAPI_FUNC(PyObject *) _PySys_GetRequiredAttr(PyObject *); +PyAPI_FUNC(PyObject *) _PySys_GetRequiredAttrString(const char *); + +// Export for '_pickle' shared extension +PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *); + +extern int _PySys_Audit( + PyThreadState *tstate, + const char *event, + const char *argFormat, + ...); + +// _PySys_ClearAuditHooks() must not be exported: use extern rather than +// PyAPI_FUNC(). We want minimal exposure of this function. +extern void _PySys_ClearAuditHooks(PyThreadState *tstate); + +extern int _PySys_SetAttr(PyObject *, PyObject *); + +extern int _PySys_ClearAttrString(PyInterpreterState *interp, + const char *name, int verbose); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_SYSMODULE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_time.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_time.h new file mode 100644 index 00000000..205ac5d3 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_time.h @@ -0,0 +1,337 @@ +// Internal PyTime_t C API: see Doc/c-api/time.rst for the documentation. +// +// The PyTime_t type is an integer to support directly common arithmetic +// operations such as t1 + t2. +// +// Time formats: +// +// * Seconds. +// * Seconds as a floating-point number (C double). +// * Milliseconds (10^-3 seconds). +// * Microseconds (10^-6 seconds). +// * 100 nanoseconds (10^-7 seconds), used on Windows. +// * Nanoseconds (10^-9 seconds). +// * timeval structure, 1 microsecond (10^-6 seconds). +// * timespec structure, 1 nanosecond (10^-9 seconds). +// +// Note that PyTime_t is now specified as int64_t, in nanoseconds. +// (If we need to change this, we'll need new public API with new names.) +// Previously, PyTime_t was configurable (in theory); some comments and code +// might still allude to that. +// +// Integer overflows are detected and raise OverflowError. Conversion to a +// resolution larger than 1 nanosecond is rounded correctly with the requested +// rounding mode. Available rounding modes: +// +// * Round towards minus infinity (-inf). For example, used to read a clock. +// * Round towards infinity (+inf). For example, used for timeout to wait "at +// least" N seconds. +// * Round to nearest with ties going to nearest even integer. For example, used +// to round from a Python float. +// * Round away from zero. For example, used for timeout. +// +// Some functions clamp the result in the range [PyTime_MIN; PyTime_MAX]. The +// caller doesn't have to handle errors and so doesn't need to hold the GIL to +// handle exceptions. For example, _PyTime_Add(t1, t2) computes t1+t2 and +// clamps the result on overflow. +// +// Clocks: +// +// * System clock +// * Monotonic clock +// * Performance counter +// +// Internally, operations like (t * k / q) with integers are implemented in a +// way to reduce the risk of integer overflow. Such operation is used to convert a +// clock value expressed in ticks with a frequency to PyTime_t, like +// QueryPerformanceCounter() with QueryPerformanceFrequency() on Windows. + + +#ifndef Py_INTERNAL_TIME_H +#define Py_INTERNAL_TIME_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + + +#ifdef __clang__ +struct timeval; +#endif + +#define _SIZEOF_PYTIME_T 8 + +typedef enum { + // Round towards minus infinity (-inf). + // For example, used to read a clock. + _PyTime_ROUND_FLOOR=0, + + // Round towards infinity (+inf). + // For example, used for timeout to wait "at least" N seconds. + _PyTime_ROUND_CEILING=1, + + // Round to nearest with ties going to nearest even integer. + // For example, used to round from a Python float. + _PyTime_ROUND_HALF_EVEN=2, + + // Round away from zero + // For example, used for timeout. _PyTime_ROUND_CEILING rounds + // -1e-9 to 0 milliseconds which causes bpo-31786 issue. + // _PyTime_ROUND_UP rounds -1e-9 to -1 millisecond which keeps + // the timeout sign as expected. select.poll(timeout) must block + // for negative values. + _PyTime_ROUND_UP=3, + + // _PyTime_ROUND_TIMEOUT (an alias for _PyTime_ROUND_UP) should be + // used for timeouts. + _PyTime_ROUND_TIMEOUT = _PyTime_ROUND_UP +} _PyTime_round_t; + + +// Convert a time_t to a PyLong. +// Export for '_testinternalcapi' shared extension +PyAPI_FUNC(PyObject*) _PyLong_FromTime_t(time_t sec); + +// Convert a PyLong to a time_t. +// Export for '_datetime' shared extension +PyAPI_FUNC(time_t) _PyLong_AsTime_t(PyObject *obj); + +// Convert a number of seconds, int or float, to time_t. +// Export for '_datetime' shared extension. +PyAPI_FUNC(int) _PyTime_ObjectToTime_t( + PyObject *obj, + time_t *sec, + _PyTime_round_t); + +// Convert a number of seconds, int or float, to a timeval structure. +// usec is in the range [0; 999999] and rounded towards zero. +// For example, -1.2 is converted to (-2, 800000). +// Export for '_datetime' shared extension. +PyAPI_FUNC(int) _PyTime_ObjectToTimeval( + PyObject *obj, + time_t *sec, + long *usec, + _PyTime_round_t); + +// Convert a number of seconds, int or float, to a timespec structure. +// nsec is in the range [0; 999999999] and rounded towards zero. +// For example, -1.2 is converted to (-2, 800000000). +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(int) _PyTime_ObjectToTimespec( + PyObject *obj, + time_t *sec, + long *nsec, + _PyTime_round_t); + + +// Create a timestamp from a number of seconds. +// Export for '_socket' shared extension. +PyAPI_FUNC(PyTime_t) _PyTime_FromSeconds(int seconds); + +// Create a timestamp from a number of seconds in double. +extern int _PyTime_FromSecondsDouble( + double seconds, + _PyTime_round_t round, + PyTime_t *result); + +// Macro to create a timestamp from a number of seconds, no integer overflow. +// Only use the macro for small values, prefer _PyTime_FromSeconds(). +#define _PYTIME_FROMSECONDS(seconds) \ + ((PyTime_t)(seconds) * (1000 * 1000 * 1000)) + +// Create a timestamp from a number of microseconds. +// Clamp to [PyTime_MIN; PyTime_MAX] on overflow. +extern PyTime_t _PyTime_FromMicrosecondsClamp(PyTime_t us); + +// Create a timestamp from a Python int object (number of nanoseconds). +// Export for '_lsprof' shared extension. +PyAPI_FUNC(int) _PyTime_FromLong(PyTime_t *t, + PyObject *obj); + +// Convert a number of seconds (Python float or int) to a timestamp. +// Raise an exception and return -1 on error, return 0 on success. +// Export for '_socket' shared extension. +PyAPI_FUNC(int) _PyTime_FromSecondsObject(PyTime_t *t, + PyObject *obj, + _PyTime_round_t round); + +// Convert a number of milliseconds (Python float or int, 10^-3) to a timestamp. +// Raise an exception and return -1 on error, return 0 on success. +// Export for 'select' shared extension. +PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(PyTime_t *t, + PyObject *obj, + _PyTime_round_t round); + +// Convert timestamp to a number of milliseconds (10^-3 seconds). +// Export for '_ssl' shared extension. +PyAPI_FUNC(PyTime_t) _PyTime_AsMilliseconds(PyTime_t t, + _PyTime_round_t round); + +// Convert timestamp to a number of microseconds (10^-6 seconds). +// Export for '_queue' shared extension. +PyAPI_FUNC(PyTime_t) _PyTime_AsMicroseconds(PyTime_t t, + _PyTime_round_t round); + +#ifdef MS_WINDOWS +// Convert timestamp to a number of 100 nanoseconds (10^-7 seconds). +extern PyTime_t _PyTime_As100Nanoseconds(PyTime_t t, + _PyTime_round_t round); +#endif + +// Convert a timestamp (number of nanoseconds) as a Python int object. +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(PyObject*) _PyTime_AsLong(PyTime_t t); + +#ifndef MS_WINDOWS +// Create a timestamp from a timeval structure. +// Raise an exception and return -1 on overflow, return 0 on success. +extern int _PyTime_FromTimeval(PyTime_t *tp, struct timeval *tv); +#endif + +// Convert a timestamp to a timeval structure (microsecond resolution). +// tv_usec is always positive. +// Raise an exception and return -1 if the conversion overflowed, +// return 0 on success. +// Export for 'select' shared extension. +PyAPI_FUNC(int) _PyTime_AsTimeval(PyTime_t t, + struct timeval *tv, + _PyTime_round_t round); + +// Similar to _PyTime_AsTimeval() but don't raise an exception on overflow. +// On overflow, clamp tv_sec to PyTime_t min/max. +// Export for 'select' shared extension. +PyAPI_FUNC(void) _PyTime_AsTimeval_clamp(PyTime_t t, + struct timeval *tv, + _PyTime_round_t round); + +// Convert a timestamp to a number of seconds (secs) and microseconds (us). +// us is always positive. This function is similar to _PyTime_AsTimeval() +// except that secs is always a time_t type, whereas the timeval structure +// uses a C long for tv_sec on Windows. +// Raise an exception and return -1 if the conversion overflowed, +// return 0 on success. +// Export for '_datetime' shared extension. +PyAPI_FUNC(int) _PyTime_AsTimevalTime_t( + PyTime_t t, + time_t *secs, + int *us, + _PyTime_round_t round); + +#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE) +// Create a timestamp from a timespec structure. +// Raise an exception and return -1 on overflow, return 0 on success. +extern int _PyTime_FromTimespec(PyTime_t *tp, const struct timespec *ts); + +// Convert a timestamp to a timespec structure (nanosecond resolution). +// tv_nsec is always positive. +// Raise an exception and return -1 on error, return 0 on success. +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(int) _PyTime_AsTimespec(PyTime_t t, struct timespec *ts); + +// Similar to _PyTime_AsTimespec() but don't raise an exception on overflow. +// On overflow, clamp tv_sec to PyTime_t min/max. +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(void) _PyTime_AsTimespec_clamp(PyTime_t t, struct timespec *ts); +#endif + + +// Compute t1 + t2. Clamp to [PyTime_MIN; PyTime_MAX] on overflow. +extern PyTime_t _PyTime_Add(PyTime_t t1, PyTime_t t2); + +// Structure used by time.get_clock_info() +typedef struct { + const char *implementation; + int monotonic; + int adjustable; + double resolution; +} _Py_clock_info_t; + +// Get the current time from the system clock. +// On success, set *t and *info (if not NULL), and return 0. +// On error, raise an exception and return -1. +extern int _PyTime_TimeWithInfo( + PyTime_t *t, + _Py_clock_info_t *info); + +// Get the time of a monotonic clock, i.e. a clock that cannot go backwards. +// The clock is not affected by system clock updates. The reference point of +// the returned value is undefined, so that only the difference between the +// results of consecutive calls is valid. +// +// Fill info (if set) with information of the function used to get the time. +// +// Return 0 on success, raise an exception and return -1 on error. +// Export for '_testsinglephase' shared extension. +PyAPI_FUNC(int) _PyTime_MonotonicWithInfo( + PyTime_t *t, + _Py_clock_info_t *info); + + +// Converts a timestamp to the Gregorian time, using the local time zone. +// Return 0 on success, raise an exception and return -1 on error. +// Export for '_datetime' shared extension. +PyAPI_FUNC(int) _PyTime_localtime(time_t t, struct tm *tm); + +// Converts a timestamp to the Gregorian time, assuming UTC. +// Return 0 on success, raise an exception and return -1 on error. +// Export for '_datetime' shared extension. +PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm); + + +// Get the performance counter: clock with the highest available resolution to +// measure a short duration. +// +// Fill info (if set) with information of the function used to get the time. +// +// Return 0 on success, raise an exception and return -1 on error. +extern int _PyTime_PerfCounterWithInfo( + PyTime_t *t, + _Py_clock_info_t *info); + + +// --- _PyDeadline ----------------------------------------------------------- + +// Create a deadline. +// Pseudo code: return PyTime_MonotonicRaw() + timeout +// Export for '_ssl' shared extension. +PyAPI_FUNC(PyTime_t) _PyDeadline_Init(PyTime_t timeout); + +// Get remaining time from a deadline. +// Pseudo code: return deadline - PyTime_MonotonicRaw() +// Export for '_ssl' shared extension. +PyAPI_FUNC(PyTime_t) _PyDeadline_Get(PyTime_t deadline); + + +// --- _PyTimeFraction ------------------------------------------------------- + +typedef struct { + PyTime_t numer; + PyTime_t denom; +} _PyTimeFraction; + +// Set a fraction. +// Return 0 on success. +// Return -1 if the fraction is invalid. +extern int _PyTimeFraction_Set( + _PyTimeFraction *frac, + PyTime_t numer, + PyTime_t denom); + +// Compute ticks * frac.numer / frac.denom. +// Clamp to [PyTime_MIN; PyTime_MAX] on overflow. +extern PyTime_t _PyTimeFraction_Mul( + PyTime_t ticks, + const _PyTimeFraction *frac); + +// Compute a clock resolution: frac.numer / frac.denom / 1e9. +extern double _PyTimeFraction_Resolution( + const _PyTimeFraction *frac); + + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_TIME_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_token.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_token.h new file mode 100644 index 00000000..571cd624 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_token.h @@ -0,0 +1,106 @@ +// Auto-generated by Tools/build/generate_token.py + +/* Token types */ +#ifndef Py_INTERNAL_TOKEN_H +#define Py_INTERNAL_TOKEN_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */ + +#define ENDMARKER 0 +#define NAME 1 +#define NUMBER 2 +#define STRING 3 +#define NEWLINE 4 +#define INDENT 5 +#define DEDENT 6 +#define LPAR 7 +#define RPAR 8 +#define LSQB 9 +#define RSQB 10 +#define COLON 11 +#define COMMA 12 +#define SEMI 13 +#define PLUS 14 +#define MINUS 15 +#define STAR 16 +#define SLASH 17 +#define VBAR 18 +#define AMPER 19 +#define LESS 20 +#define GREATER 21 +#define EQUAL 22 +#define DOT 23 +#define PERCENT 24 +#define LBRACE 25 +#define RBRACE 26 +#define EQEQUAL 27 +#define NOTEQUAL 28 +#define LESSEQUAL 29 +#define GREATEREQUAL 30 +#define TILDE 31 +#define CIRCUMFLEX 32 +#define LEFTSHIFT 33 +#define RIGHTSHIFT 34 +#define DOUBLESTAR 35 +#define PLUSEQUAL 36 +#define MINEQUAL 37 +#define STAREQUAL 38 +#define SLASHEQUAL 39 +#define PERCENTEQUAL 40 +#define AMPEREQUAL 41 +#define VBAREQUAL 42 +#define CIRCUMFLEXEQUAL 43 +#define LEFTSHIFTEQUAL 44 +#define RIGHTSHIFTEQUAL 45 +#define DOUBLESTAREQUAL 46 +#define DOUBLESLASH 47 +#define DOUBLESLASHEQUAL 48 +#define AT 49 +#define ATEQUAL 50 +#define RARROW 51 +#define ELLIPSIS 52 +#define COLONEQUAL 53 +#define EXCLAMATION 54 +#define OP 55 +#define TYPE_IGNORE 56 +#define TYPE_COMMENT 57 +#define SOFT_KEYWORD 58 +#define FSTRING_START 59 +#define FSTRING_MIDDLE 60 +#define FSTRING_END 61 +#define COMMENT 62 +#define NL 63 +#define ERRORTOKEN 64 +#define N_TOKENS 66 +#define NT_OFFSET 256 + +/* Special definitions for cooperation with parser */ + +#define ISTERMINAL(x) ((x) < NT_OFFSET) +#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) +#define ISEOF(x) ((x) == ENDMARKER) +#define ISWHITESPACE(x) ((x) == ENDMARKER || \ + (x) == NEWLINE || \ + (x) == INDENT || \ + (x) == DEDENT) +#define ISSTRINGLIT(x) ((x) == STRING || \ + (x) == FSTRING_MIDDLE) + + +// Export these 4 symbols for 'test_peg_generator' +PyAPI_DATA(const char * const) _PyParser_TokenNames[]; /* Token names */ +PyAPI_FUNC(int) _PyToken_OneChar(int); +PyAPI_FUNC(int) _PyToken_TwoChars(int, int); +PyAPI_FUNC(int) _PyToken_ThreeChars(int, int, int); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_TOKEN_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_traceback.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_traceback.h new file mode 100644 index 00000000..10922bff --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_traceback.h @@ -0,0 +1,106 @@ +#ifndef Py_INTERNAL_TRACEBACK_H +#define Py_INTERNAL_TRACEBACK_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// Export for '_ctypes' shared extension +PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **); + +// Export for 'pyexact' shared extension +PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int); + +/* Write the Python traceback into the file 'fd'. For example: + + Traceback (most recent call first): + File "xxx", line xxx in + File "xxx", line xxx in + ... + File "xxx", line xxx in + + This function is written for debug purpose only, to dump the traceback in + the worst case: after a segmentation fault, at fatal error, etc. That's why, + it is very limited. Strings are truncated to 100 characters and encoded to + ASCII with backslashreplace. It doesn't write the source code, only the + function name, filename and line number of each frame. Write only the first + 100 frames: if the traceback is truncated, write the line " ...". + + This function is signal safe. */ + +extern void _Py_DumpTraceback( + int fd, + PyThreadState *tstate); + +/* Write the traceback of all threads into the file 'fd'. current_thread can be + NULL. + + Return NULL on success, or an error message on error. + + This function is written for debug purpose only. It calls + _Py_DumpTraceback() for each thread, and so has the same limitations. It + only write the traceback of the first 100 threads: write "..." if there are + more threads. + + If current_tstate is NULL, the function tries to get the Python thread state + of the current thread. It is not an error if the function is unable to get + the current Python thread state. + + If interp is NULL, the function tries to get the interpreter state from + the current Python thread state, or from + _PyGILState_GetInterpreterStateUnsafe() in last resort. + + It is better to pass NULL to interp and current_tstate, the function tries + different options to retrieve this information. + + This function is signal safe. */ + +extern const char* _Py_DumpTracebackThreads( + int fd, + PyInterpreterState *interp, + PyThreadState *current_tstate); + +/* Write a Unicode object into the file descriptor fd. Encode the string to + ASCII using the backslashreplace error handler. + + Do nothing if text is not a Unicode object. The function accepts Unicode + string which is not ready (PyUnicode_WCHAR_KIND). + + This function is signal safe. */ +extern void _Py_DumpASCII(int fd, PyObject *text); + +/* Format an integer as decimal into the file descriptor fd. + + This function is signal safe. */ +extern void _Py_DumpDecimal( + int fd, + size_t value); + +/* Format an integer as hexadecimal with width digits into fd file descriptor. + The function is signal safe. */ +extern void _Py_DumpHexadecimal( + int fd, + uintptr_t value, + Py_ssize_t width); + +extern PyObject* _PyTraceBack_FromFrame( + PyObject *tb_next, + PyFrameObject *frame); + +#define EXCEPTION_TB_HEADER "Traceback (most recent call last):\n" +#define EXCEPTION_GROUP_TB_HEADER "Exception Group Traceback (most recent call last):\n" + +/* Write the traceback tb to file f. Prefix each line with + indent spaces followed by the margin (if it is not NULL). */ +extern int _PyTraceBack_Print( + PyObject *tb, const char *header, PyObject *f); +extern int _Py_WriteIndentedMargin(int, const char*, PyObject *); +extern int _Py_WriteIndent(int, PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_TRACEBACK_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_tracemalloc.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_tracemalloc.h new file mode 100644 index 00000000..f70d4707 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_tracemalloc.h @@ -0,0 +1,170 @@ +#ifndef Py_INTERNAL_TRACEMALLOC_H +#define Py_INTERNAL_TRACEMALLOC_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_hashtable.h" // _Py_hashtable_t + + +/* Trace memory blocks allocated by PyMem_RawMalloc() */ +#define TRACE_RAW_MALLOC + + +struct _PyTraceMalloc_Config { + /* Module initialized? + Variable protected by the GIL */ + enum { + TRACEMALLOC_NOT_INITIALIZED, + TRACEMALLOC_INITIALIZED, + TRACEMALLOC_FINALIZED + } initialized; + + /* Is tracemalloc tracing memory allocations? + Variable protected by the GIL */ + int tracing; + + /* limit of the number of frames in a traceback, 1 by default. + Variable protected by the GIL. */ + int max_nframe; +}; + + +/* Pack the frame_t structure to reduce the memory footprint on 64-bit + architectures: 12 bytes instead of 16. */ +#if defined(_MSC_VER) +#pragma pack(push, 4) +#endif + +struct +#ifdef __GNUC__ +__attribute__((packed)) +#endif +tracemalloc_frame { + /* filename cannot be NULL: "" is used if the Python frame + filename is NULL */ + PyObject *filename; + unsigned int lineno; +}; +#ifdef _MSC_VER +#pragma pack(pop) +#endif + +struct tracemalloc_traceback { + Py_uhash_t hash; + /* Number of frames stored */ + uint16_t nframe; + /* Total number of frames the traceback had */ + uint16_t total_nframe; + struct tracemalloc_frame frames[1]; +}; + + +struct _tracemalloc_runtime_state { + struct _PyTraceMalloc_Config config; + + /* Protected by the GIL */ + struct { + PyMemAllocatorEx mem; + PyMemAllocatorEx raw; + PyMemAllocatorEx obj; + } allocators; + +#if defined(TRACE_RAW_MALLOC) + PyThread_type_lock tables_lock; +#endif + /* Size in bytes of currently traced memory. + Protected by TABLES_LOCK(). */ + size_t traced_memory; + /* Peak size in bytes of traced memory. + Protected by TABLES_LOCK(). */ + size_t peak_traced_memory; + /* Hash table used as a set to intern filenames: + PyObject* => PyObject*. + Protected by the GIL */ + _Py_hashtable_t *filenames; + /* Buffer to store a new traceback in traceback_new(). + Protected by the GIL. */ + struct tracemalloc_traceback *traceback; + /* Hash table used as a set to intern tracebacks: + traceback_t* => traceback_t* + Protected by the GIL */ + _Py_hashtable_t *tracebacks; + /* pointer (void*) => trace (trace_t*). + Protected by TABLES_LOCK(). */ + _Py_hashtable_t *traces; + /* domain (unsigned int) => traces (_Py_hashtable_t). + Protected by TABLES_LOCK(). */ + _Py_hashtable_t *domains; + + struct tracemalloc_traceback empty_traceback; + + Py_tss_t reentrant_key; +}; + +#define _tracemalloc_runtime_state_INIT \ + { \ + .config = { \ + .initialized = TRACEMALLOC_NOT_INITIALIZED, \ + .tracing = 0, \ + .max_nframe = 1, \ + }, \ + .reentrant_key = Py_tss_NEEDS_INIT, \ + } + + +// Get the traceback where a memory block was allocated. +// +// Return a tuple of (filename: str, lineno: int) tuples. +// +// Return None if the tracemalloc module is disabled or if the memory block +// is not tracked by tracemalloc. +// +// Raise an exception and return NULL on error. +// +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback( + unsigned int domain, + uintptr_t ptr); + +/* Return non-zero if tracemalloc is tracing */ +extern int _PyTraceMalloc_IsTracing(void); + +/* Clear the tracemalloc traces */ +extern void _PyTraceMalloc_ClearTraces(void); + +/* Clear the tracemalloc traces */ +extern PyObject* _PyTraceMalloc_GetTraces(void); + +/* Clear tracemalloc traceback for an object */ +extern PyObject* _PyTraceMalloc_GetObjectTraceback(PyObject *obj); + +/* Initialize tracemalloc */ +extern PyStatus _PyTraceMalloc_Init(void); + +/* Start tracemalloc */ +extern int _PyTraceMalloc_Start(int max_nframe); + +/* Stop tracemalloc */ +extern void _PyTraceMalloc_Stop(void); + +/* Get the tracemalloc traceback limit */ +extern int _PyTraceMalloc_GetTracebackLimit(void); + +/* Get the memory usage of tracemalloc in bytes */ +extern size_t _PyTraceMalloc_GetMemory(void); + +/* Get the current size and peak size of traced memory blocks as a 2-tuple */ +extern PyObject* _PyTraceMalloc_GetTracedMemory(void); + +/* Set the peak size of traced memory blocks to the current size */ +extern void _PyTraceMalloc_ResetPeak(void); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_TRACEMALLOC_H diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_tstate.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_tstate.h new file mode 100644 index 00000000..1ed5b1d8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_tstate.h @@ -0,0 +1,46 @@ +#ifndef Py_INTERNAL_TSTATE_H +#define Py_INTERNAL_TSTATE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_brc.h" // struct _brc_thread_state +#include "pycore_freelist.h" // struct _Py_freelist_state +#include "pycore_mimalloc.h" // struct _mimalloc_thread_state +#include "pycore_qsbr.h" // struct qsbr + + +// Every PyThreadState is actually allocated as a _PyThreadStateImpl. The +// PyThreadState fields are exposed as part of the C API, although most fields +// are intended to be private. The _PyThreadStateImpl fields not exposed. +typedef struct _PyThreadStateImpl { + // semi-public fields are in PyThreadState. + PyThreadState base; + + PyObject *asyncio_running_loop; // Strong reference + + struct _qsbr_thread_state *qsbr; // only used by free-threaded build + struct llist_node mem_free_queue; // delayed free queue + +#ifdef Py_GIL_DISABLED + struct _gc_thread_state gc; + struct _mimalloc_thread_state mimalloc; + struct _Py_object_freelists freelists; + struct _brc_thread_state brc; +#endif + +#if defined(Py_REF_DEBUG) && defined(Py_GIL_DISABLED) + Py_ssize_t reftotal; // this thread's total refcount operations +#endif + +} _PyThreadStateImpl; + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_TSTATE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_tuple.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_tuple.h new file mode 100644 index 00000000..14a9e42c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_tuple.h @@ -0,0 +1,35 @@ +#ifndef Py_INTERNAL_TUPLE_H +#define Py_INTERNAL_TUPLE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern void _PyTuple_MaybeUntrack(PyObject *); +extern void _PyTuple_DebugMallocStats(FILE *out); + +/* runtime lifecycle */ + +extern PyStatus _PyTuple_InitGlobalObjects(PyInterpreterState *); + + +/* other API */ + +#define _PyTuple_ITEMS(op) _Py_RVALUE(_PyTuple_CAST(op)->ob_item) + +extern PyObject *_PyTuple_FromArray(PyObject *const *, Py_ssize_t); +PyAPI_FUNC(PyObject *)_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t); + +typedef struct { + PyObject_HEAD + Py_ssize_t it_index; + PyTupleObject *it_seq; /* Set to NULL when iterator is exhausted */ +} _PyTupleIterObject; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_TUPLE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_typeobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_typeobject.h new file mode 100644 index 00000000..164b243d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_typeobject.h @@ -0,0 +1,245 @@ +#ifndef Py_INTERNAL_TYPEOBJECT_H +#define Py_INTERNAL_TYPEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_moduleobject.h" // PyModuleObject +#include "pycore_lock.h" // PyMutex + + +/* state */ + +#define _Py_TYPE_BASE_VERSION_TAG (2<<16) +#define _Py_MAX_GLOBAL_TYPE_VERSION_TAG (_Py_TYPE_BASE_VERSION_TAG - 1) + +/* For now we hard-code this to a value for which we are confident + all the static builtin types will fit (for all builds). */ +#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES 200 +#define _Py_MAX_MANAGED_STATIC_EXT_TYPES 10 +#define _Py_MAX_MANAGED_STATIC_TYPES \ + (_Py_MAX_MANAGED_STATIC_BUILTIN_TYPES + _Py_MAX_MANAGED_STATIC_EXT_TYPES) + +struct _types_runtime_state { + /* Used to set PyTypeObject.tp_version_tag for core static types. */ + // bpo-42745: next_version_tag remains shared by all interpreters + // because of static types. + unsigned int next_version_tag; + + struct { + struct { + PyTypeObject *type; + int64_t interp_count; + } types[_Py_MAX_MANAGED_STATIC_TYPES]; + } managed_static; +}; + + +// Type attribute lookup cache: speed up attribute and method lookups, +// see _PyType_Lookup(). +struct type_cache_entry { + unsigned int version; // initialized from type->tp_version_tag +#ifdef Py_GIL_DISABLED + _PySeqLock sequence; +#endif + PyObject *name; // reference to exactly a str or None + PyObject *value; // borrowed reference or NULL +}; + +#define MCACHE_SIZE_EXP 12 + +struct type_cache { + struct type_cache_entry hashtable[1 << MCACHE_SIZE_EXP]; +}; + +typedef struct { + PyTypeObject *type; + int isbuiltin; + int readying; + int ready; + // XXX tp_dict can probably be statically allocated, + // instead of dynamically and stored on the interpreter. + PyObject *tp_dict; + PyObject *tp_subclasses; + /* We never clean up weakrefs for static builtin types since + they will effectively never get triggered. However, there + are also some diagnostic uses for the list of weakrefs, + so we still keep it. */ + PyObject *tp_weaklist; +} managed_static_type_state; + +struct types_state { + /* Used to set PyTypeObject.tp_version_tag. + It starts at _Py_MAX_GLOBAL_TYPE_VERSION_TAG + 1, + where all those lower numbers are used for core static types. */ + unsigned int next_version_tag; + + struct type_cache type_cache; + + /* Every static builtin type is initialized for each interpreter + during its own initialization, including for the main interpreter + during global runtime initialization. This is done by calling + _PyStaticType_InitBuiltin(). + + The first time a static builtin type is initialized, all the + normal PyType_Ready() stuff happens. The only difference from + normal is that there are three PyTypeObject fields holding + objects which are stored here (on PyInterpreterState) rather + than in the corresponding PyTypeObject fields. Those are: + tp_dict (cls.__dict__), tp_subclasses (cls.__subclasses__), + and tp_weaklist. + + When a subinterpreter is initialized, each static builtin type + is still initialized, but only the interpreter-specific portion, + namely those three objects. + + Those objects are stored in the PyInterpreterState.types.builtins + array, at the index corresponding to each specific static builtin + type. That index (a size_t value) is stored in the tp_subclasses + field. For static builtin types, we re-purposed the now-unused + tp_subclasses to avoid adding another field to PyTypeObject. + In all other cases tp_subclasses holds a dict like before. + (The field was previously defined as PyObject*, but is now void* + to reflect its dual use.) + + The index for each static builtin type isn't statically assigned. + Instead it is calculated the first time a type is initialized + (by the main interpreter). The index matches the order in which + the type was initialized relative to the others. The actual + value comes from the current value of num_builtins_initialized, + as each type is initialized for the main interpreter. + + num_builtins_initialized is incremented once for each static + builtin type. Once initialization is over for a subinterpreter, + the value will be the same as for all other interpreters. */ + struct { + size_t num_initialized; + managed_static_type_state initialized[_Py_MAX_MANAGED_STATIC_BUILTIN_TYPES]; + } builtins; + /* We apply a similar strategy for managed extension modules. */ + struct { + size_t num_initialized; + size_t next_index; + managed_static_type_state initialized[_Py_MAX_MANAGED_STATIC_EXT_TYPES]; + } for_extensions; + PyMutex mutex; +}; + + +/* runtime lifecycle */ + +extern PyStatus _PyTypes_InitTypes(PyInterpreterState *); +extern void _PyTypes_FiniTypes(PyInterpreterState *); +extern void _PyTypes_FiniExtTypes(PyInterpreterState *interp); +extern void _PyTypes_Fini(PyInterpreterState *); +extern void _PyTypes_AfterFork(void); + +/* other API */ + +/* Length of array of slotdef pointers used to store slots with the + same __name__. There should be at most MAX_EQUIV-1 slotdef entries with + the same __name__, for any __name__. Since that's a static property, it is + appropriate to declare fixed-size arrays for this. */ +#define MAX_EQUIV 10 + +typedef struct wrapperbase pytype_slotdef; + + +static inline PyObject ** +_PyStaticType_GET_WEAKREFS_LISTPTR(managed_static_type_state *state) +{ + assert(state != NULL); + return &state->tp_weaklist; +} + +extern int _PyStaticType_InitBuiltin( + PyInterpreterState *interp, + PyTypeObject *type); +extern void _PyStaticType_FiniBuiltin( + PyInterpreterState *interp, + PyTypeObject *type); +extern void _PyStaticType_ClearWeakRefs( + PyInterpreterState *interp, + PyTypeObject *type); +extern managed_static_type_state * _PyStaticType_GetState( + PyInterpreterState *interp, + PyTypeObject *type); + +// Export for '_datetime' shared extension. +PyAPI_FUNC(int) _PyStaticType_InitForExtension( + PyInterpreterState *interp, + PyTypeObject *self); + + +/* Like PyType_GetModuleState, but skips verification + * that type is a heap type with an associated module */ +static inline void * +_PyType_GetModuleState(PyTypeObject *type) +{ + assert(PyType_Check(type)); + assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); + PyHeapTypeObject *et = (PyHeapTypeObject *)type; + assert(et->ht_module); + PyModuleObject *mod = (PyModuleObject *)(et->ht_module); + assert(mod != NULL); + return mod->md_state; +} + + +// Export for 'math' shared extension, used via _PyType_IsReady() static inline +// function +PyAPI_FUNC(PyObject *) _PyType_GetDict(PyTypeObject *); + +extern PyObject * _PyType_GetBases(PyTypeObject *type); +extern PyObject * _PyType_GetMRO(PyTypeObject *type); +extern PyObject* _PyType_GetSubclasses(PyTypeObject *); +extern int _PyType_HasSubclasses(PyTypeObject *); +PyAPI_FUNC(PyObject *) _PyType_GetModuleByDef2(PyTypeObject *, PyTypeObject *, PyModuleDef *); +PyAPI_FUNC(PyObject *) _PyType_GetModuleByDef3(PyTypeObject *, PyTypeObject *, PyTypeObject *, PyModuleDef *); + +// PyType_Ready() must be called if _PyType_IsReady() is false. +// See also the Py_TPFLAGS_READY flag. +static inline int +_PyType_IsReady(PyTypeObject *type) +{ + return _PyType_GetDict(type) != NULL; +} + +extern PyObject* _Py_type_getattro_impl(PyTypeObject *type, PyObject *name, + int *suppress_missing_attribute); +extern PyObject* _Py_type_getattro(PyObject *type, PyObject *name); + +extern PyObject* _Py_BaseObject_RichCompare(PyObject* self, PyObject* other, int op); + +extern PyObject* _Py_slot_tp_getattro(PyObject *self, PyObject *name); +extern PyObject* _Py_slot_tp_getattr_hook(PyObject *self, PyObject *name); + +extern PyTypeObject _PyBufferWrapper_Type; + +PyAPI_FUNC(PyObject*) _PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj, + PyObject *name, int *meth_found); + +extern PyObject* _PyType_GetFullyQualifiedName(PyTypeObject *type, char sep); + +// Perform the following operation, in a thread-safe way when required by the +// build mode. +// +// self->tp_flags = (self->tp_flags & ~mask) | flags; +extern void _PyType_SetFlags(PyTypeObject *self, unsigned long mask, + unsigned long flags); +extern int _PyType_AddMethod(PyTypeObject *, PyMethodDef *); + +// Like _PyType_SetFlags(), but apply the operation to self and any of its +// subclasses without Py_TPFLAGS_IMMUTABLETYPE set. +extern void _PyType_SetFlagsRecursive(PyTypeObject *self, unsigned long mask, + unsigned long flags); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_TYPEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_typevarobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_typevarobject.h new file mode 100644 index 00000000..a368edeb --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_typevarobject.h @@ -0,0 +1,27 @@ +#ifndef Py_INTERNAL_TYPEVAROBJECT_H +#define Py_INTERNAL_TYPEVAROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern PyObject *_Py_make_typevar(PyObject *, PyObject *, PyObject *); +extern PyObject *_Py_make_paramspec(PyThreadState *, PyObject *); +extern PyObject *_Py_make_typevartuple(PyThreadState *, PyObject *); +extern PyObject *_Py_make_typealias(PyThreadState *, PyObject *); +extern PyObject *_Py_subscript_generic(PyThreadState *, PyObject *); +extern PyObject *_Py_set_typeparam_default(PyThreadState *, PyObject *, PyObject *); +extern int _Py_initialize_generic(PyInterpreterState *); +extern void _Py_clear_generic_types(PyInterpreterState *); + +extern PyTypeObject _PyTypeAlias_Type; +extern PyTypeObject _PyNoDefault_Type; +extern PyObject _Py_NoDefaultStruct; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_TYPEVAROBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_ucnhash.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_ucnhash.h new file mode 100644 index 00000000..1561dfbb --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_ucnhash.h @@ -0,0 +1,36 @@ +/* Unicode name database interface */ +#ifndef Py_INTERNAL_UCNHASH_H +#define Py_INTERNAL_UCNHASH_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* revised ucnhash CAPI interface (exported through a "wrapper") */ + +#define PyUnicodeData_CAPSULE_NAME "unicodedata._ucnhash_CAPI" + +typedef struct { + + /* Get name for a given character code. + Returns non-zero if success, zero if not. + Does not set Python exceptions. */ + int (*getname)(Py_UCS4 code, char* buffer, int buflen, + int with_alias_and_seq); + + /* Get character code for a given name. + Same error handling as for getname(). */ + int (*getcode)(const char* name, int namelen, Py_UCS4* code, + int with_named_seq); + +} _PyUnicode_Name_CAPI; + +extern _PyUnicode_Name_CAPI* _PyUnicode_GetNameCAPI(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_UCNHASH_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_unicodeobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_unicodeobject.h new file mode 100644 index 00000000..5ebc7c12 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_unicodeobject.h @@ -0,0 +1,351 @@ +#ifndef Py_INTERNAL_UNICODEOBJECT_H +#define Py_INTERNAL_UNICODEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_lock.h" // PyMutex +#include "pycore_fileutils.h" // _Py_error_handler +#include "pycore_identifier.h" // _Py_Identifier +#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI +#include "pycore_global_objects.h" // _Py_SINGLETON + +/* --- Characters Type APIs ----------------------------------------------- */ + +extern int _PyUnicode_IsXidStart(Py_UCS4 ch); +extern int _PyUnicode_IsXidContinue(Py_UCS4 ch); +extern int _PyUnicode_ToLowerFull(Py_UCS4 ch, Py_UCS4 *res); +extern int _PyUnicode_ToTitleFull(Py_UCS4 ch, Py_UCS4 *res); +extern int _PyUnicode_ToUpperFull(Py_UCS4 ch, Py_UCS4 *res); +extern int _PyUnicode_ToFoldedFull(Py_UCS4 ch, Py_UCS4 *res); +extern int _PyUnicode_IsCaseIgnorable(Py_UCS4 ch); +extern int _PyUnicode_IsCased(Py_UCS4 ch); + +/* --- Unicode API -------------------------------------------------------- */ + +// Export for '_json' shared extension +PyAPI_FUNC(int) _PyUnicode_CheckConsistency( + PyObject *op, + int check_content); + +PyAPI_FUNC(void) _PyUnicode_ExactDealloc(PyObject *op); +extern Py_ssize_t _PyUnicode_InternedSize(void); +extern Py_ssize_t _PyUnicode_InternedSize_Immortal(void); + +// Get a copy of a Unicode string. +// Export for '_datetime' shared extension. +PyAPI_FUNC(PyObject*) _PyUnicode_Copy( + PyObject *unicode); + +/* Unsafe version of PyUnicode_Fill(): don't check arguments and so may crash + if parameters are invalid (e.g. if length is longer than the string). */ +extern void _PyUnicode_FastFill( + PyObject *unicode, + Py_ssize_t start, + Py_ssize_t length, + Py_UCS4 fill_char + ); + +/* Unsafe version of PyUnicode_CopyCharacters(): don't check arguments and so + may crash if parameters are invalid (e.g. if the output string + is too short). */ +extern void _PyUnicode_FastCopyCharacters( + PyObject *to, + Py_ssize_t to_start, + PyObject *from, + Py_ssize_t from_start, + Py_ssize_t how_many + ); + +/* Create a new string from a buffer of ASCII characters. + WARNING: Don't check if the string contains any non-ASCII character. */ +extern PyObject* _PyUnicode_FromASCII( + const char *buffer, + Py_ssize_t size); + +/* Compute the maximum character of the substring unicode[start:end]. + Return 127 for an empty string. */ +extern Py_UCS4 _PyUnicode_FindMaxChar ( + PyObject *unicode, + Py_ssize_t start, + Py_ssize_t end); + +/* --- _PyUnicodeWriter API ----------------------------------------------- */ + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +extern int _PyUnicode_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); + +/* --- UTF-7 Codecs ------------------------------------------------------- */ + +extern PyObject* _PyUnicode_EncodeUTF7( + PyObject *unicode, /* Unicode object */ + int base64SetO, /* Encode RFC2152 Set O characters in base64 */ + int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */ + const char *errors); /* error handling */ + +/* --- UTF-8 Codecs ------------------------------------------------------- */ + +// Export for '_tkinter' shared extension. +PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String( + PyObject *unicode, + const char *errors); + +/* --- UTF-32 Codecs ------------------------------------------------------ */ + +// Export for '_tkinter' shared extension +PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32( + PyObject *object, /* Unicode object */ + const char *errors, /* error handling */ + int byteorder); /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + +/* --- UTF-16 Codecs ------------------------------------------------------ */ + +// Returns a Python string object holding the UTF-16 encoded value of +// the Unicode data. +// +// If byteorder is not 0, output is written according to the following +// byte order: +// +// byteorder == -1: little endian +// byteorder == 0: native byte order (writes a BOM mark) +// byteorder == 1: big endian +// +// If byteorder is 0, the output string will always start with the +// Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is +// prepended. +// +// Export for '_tkinter' shared extension +PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16( + PyObject* unicode, /* Unicode object */ + const char *errors, /* error handling */ + int byteorder); /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + +/* --- Unicode-Escape Codecs ---------------------------------------------- */ + +/* Variant of PyUnicode_DecodeUnicodeEscape that supports partial decoding. */ +extern PyObject* _PyUnicode_DecodeUnicodeEscapeStateful( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed); /* bytes consumed */ + +// Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape +// chars. +// Export for test_peg_generator. +PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal2( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed, /* bytes consumed */ + int *first_invalid_escape_char, /* on return, if not -1, contain the first + invalid escaped char (<= 0xff) or invalid + octal escape (> 0xff) in string. */ + const char **first_invalid_escape_ptr); /* on return, if not NULL, may + point to the first invalid escaped + char in string. + May be NULL if errors is not NULL. */ +// Export for binary compatibility. +PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed, /* bytes consumed */ + const char **first_invalid_escape); /* on return, points to first + invalid escaped char in + string. */ + +/* --- Raw-Unicode-Escape Codecs ---------------------------------------------- */ + +/* Variant of PyUnicode_DecodeRawUnicodeEscape that supports partial decoding. */ +extern PyObject* _PyUnicode_DecodeRawUnicodeEscapeStateful( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed); /* bytes consumed */ + +/* --- Latin-1 Codecs ----------------------------------------------------- */ + +extern PyObject* _PyUnicode_AsLatin1String( + PyObject* unicode, + const char* errors); + +/* --- ASCII Codecs ------------------------------------------------------- */ + +extern PyObject* _PyUnicode_AsASCIIString( + PyObject* unicode, + const char* errors); + +/* --- Character Map Codecs ----------------------------------------------- */ + +/* Translate an Unicode object by applying a character mapping table to + it and return the resulting Unicode object. + + The mapping table must map Unicode ordinal integers to Unicode strings, + Unicode ordinal integers or None (causing deletion of the character). + + Mapping tables may be dictionaries or sequences. Unmapped character + ordinals (ones which cause a LookupError) are left untouched and + are copied as-is. +*/ +extern PyObject* _PyUnicode_EncodeCharmap( + PyObject *unicode, /* Unicode object */ + PyObject *mapping, /* encoding mapping */ + const char *errors); /* error handling */ + +/* --- Decimal Encoder ---------------------------------------------------- */ + +// Coverts a Unicode object holding a decimal value to an ASCII string +// for using in int, float and complex parsers. +// Transforms code points that have decimal digit property to the +// corresponding ASCII digit code points. Transforms spaces to ASCII. +// Transforms code points starting from the first non-ASCII code point that +// is neither a decimal digit nor a space to the end into '?'. +// +// Export for '_testinternalcapi' shared extension. +PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII( + PyObject *unicode); /* Unicode object */ + +/* --- Methods & Slots ---------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) _PyUnicode_JoinArray( + PyObject *separator, + PyObject *const *items, + Py_ssize_t seqlen + ); + +/* Test whether a unicode is equal to ASCII identifier. Return 1 if true, + 0 otherwise. The right argument must be ASCII identifier. + Any error occurs inside will be cleared before return. */ +extern int _PyUnicode_EqualToASCIIId( + PyObject *left, /* Left string */ + _Py_Identifier *right /* Right identifier */ + ); + +// Test whether a unicode is equal to ASCII string. Return 1 if true, +// 0 otherwise. The right argument must be ASCII-encoded string. +// Any error occurs inside will be cleared before return. +// Export for '_ctypes' shared extension +PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString( + PyObject *left, + const char *right /* ASCII-encoded string */ + ); + +/* Externally visible for str.strip(unicode) */ +extern PyObject* _PyUnicode_XStrip( + PyObject *self, + int striptype, + PyObject *sepobj + ); + + +/* Using explicit passed-in values, insert the thousands grouping + into the string pointed to by buffer. For the argument descriptions, + see Objects/stringlib/localeutil.h */ +extern Py_ssize_t _PyUnicode_InsertThousandsGrouping( + _PyUnicodeWriter *writer, + Py_ssize_t n_buffer, + PyObject *digits, + Py_ssize_t d_pos, + Py_ssize_t n_digits, + Py_ssize_t min_width, + const char *grouping, + PyObject *thousands_sep, + Py_UCS4 *maxchar); + +/* --- Misc functions ----------------------------------------------------- */ + +extern PyObject* _PyUnicode_FormatLong(PyObject *, int, int, int); + +/* Fast equality check when the inputs are known to be exact unicode types + and where the hash values are equal (i.e. a very probable match) */ +extern int _PyUnicode_EQ(PyObject *, PyObject *); + +// Equality check. +// Export for '_pickle' shared extension. +PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *, PyObject *); + +extern int _PyUnicode_WideCharString_Converter(PyObject *, void *); +extern int _PyUnicode_WideCharString_Opt_Converter(PyObject *, void *); + +// Export for test_peg_generator +PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *); + +/* --- Runtime lifecycle -------------------------------------------------- */ + +extern void _PyUnicode_InitState(PyInterpreterState *); +extern PyStatus _PyUnicode_InitGlobalObjects(PyInterpreterState *); +extern PyStatus _PyUnicode_InitTypes(PyInterpreterState *); +extern void _PyUnicode_Fini(PyInterpreterState *); +extern void _PyUnicode_FiniTypes(PyInterpreterState *); + +extern PyTypeObject _PyUnicodeASCIIIter_Type; + +/* --- Interning ---------------------------------------------------------- */ + +// All these are "ref-neutral", like the public PyUnicode_InternInPlace. + +// Explicit interning routines: +PyAPI_FUNC(void) _PyUnicode_InternMortal(PyInterpreterState *interp, PyObject **); +PyAPI_FUNC(void) _PyUnicode_InternImmortal(PyInterpreterState *interp, PyObject **); +// Left here to help backporting: +PyAPI_FUNC(void) _PyUnicode_InternInPlace(PyInterpreterState *interp, PyObject **p); +// Only for singletons in the _PyRuntime struct: +extern void _PyUnicode_InternStatic(PyInterpreterState *interp, PyObject **); + +/* --- Other API ---------------------------------------------------------- */ + +struct _Py_unicode_runtime_ids { + PyMutex mutex; + // next_index value must be preserved when Py_Initialize()/Py_Finalize() + // is called multiple times: see _PyUnicode_FromId() implementation. + Py_ssize_t next_index; +}; + +struct _Py_unicode_runtime_state { + struct _Py_unicode_runtime_ids ids; +}; + +/* fs_codec.encoding is initialized to NULL. + Later, it is set to a non-NULL string by _PyUnicode_InitEncodings(). */ +struct _Py_unicode_fs_codec { + char *encoding; // Filesystem encoding (encoded to UTF-8) + int utf8; // encoding=="utf-8"? + char *errors; // Filesystem errors (encoded to UTF-8) + _Py_error_handler error_handler; +}; + +struct _Py_unicode_ids { + Py_ssize_t size; + PyObject **array; +}; + +struct _Py_unicode_state { + struct _Py_unicode_fs_codec fs_codec; + + _PyUnicode_Name_CAPI *ucnhash_capi; + + // Unicode identifiers (_Py_Identifier): see _PyUnicode_FromId() + struct _Py_unicode_ids ids; +}; + +extern void _PyUnicode_ClearInterned(PyInterpreterState *interp); + +// Like PyUnicode_AsUTF8(), but check for embedded null characters. +// Export for '_sqlite3' shared extension. +PyAPI_FUNC(const char *) _PyUnicode_AsUTF8NoNUL(PyObject *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_UNICODEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_unicodeobject_generated.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_unicodeobject_generated.h new file mode 100644 index 00000000..7f6b6e07 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_unicodeobject_generated.h @@ -0,0 +1,2980 @@ +#ifndef Py_INTERNAL_UNICODEOBJECT_GENERATED_H +#define Py_INTERNAL_UNICODEOBJECT_GENERATED_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* The following is auto-generated by Tools/build/generate_global_objects.py. */ +static inline void +_PyUnicode_InitStaticStrings(PyInterpreterState *interp) { + PyObject *string; + string = &_Py_ID(CANCELLED); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(FINISHED); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(False); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(JSONDecodeError); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(PENDING); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(Py_Repr); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(TextIOWrapper); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(True); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(WarningMessage); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_WindowsConsoleIO); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__IOBase_closed); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__abc_tpflags__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__abs__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__abstractmethods__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__add__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__aenter__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__aexit__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__aiter__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__all__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__and__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__anext__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__annotations__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__args__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__await__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__bases__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__bool__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__buffer__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__build_class__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__builtins__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__bytes__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__call__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__cantrace__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__class__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__class_getitem__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__classcell__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__classdict__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__classdictcell__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__complex__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__contains__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__copy__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ctypes_from_outparam__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__del__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__delattr__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__delete__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__delitem__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__dict__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__dictoffset__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__dir__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__divmod__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__doc__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__enter__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__eq__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__exit__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__file__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__firstlineno__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__float__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__floordiv__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__format__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__fspath__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ge__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__get__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__getattr__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__getattribute__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__getinitargs__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__getitem__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__getnewargs__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__getnewargs_ex__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__getstate__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__gt__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__hash__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__iadd__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__iand__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ifloordiv__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ilshift__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__imatmul__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__imod__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__import__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__imul__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__index__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__init__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__init_subclass__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__instancecheck__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__int__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__invert__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ior__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ipow__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__irshift__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__isabstractmethod__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__isub__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__iter__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__itruediv__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ixor__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__le__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__len__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__length_hint__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__lltrace__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__loader__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__lshift__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__lt__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__main__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__match_args__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__matmul__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__missing__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__mod__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__module__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__mro_entries__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__mul__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__name__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ne__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__neg__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__new__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__newobj__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__newobj_ex__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__next__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__notes__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__or__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__orig_class__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__origin__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__package__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__parameters__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__path__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__pos__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__pow__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__prepare__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__qualname__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__radd__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rand__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rdivmod__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__reduce__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__reduce_ex__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__release_buffer__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__repr__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__reversed__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rfloordiv__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rlshift__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rmatmul__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rmod__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rmul__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__ror__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__round__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rpow__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rrshift__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rshift__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rsub__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rtruediv__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__rxor__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__set__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__set_name__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__setattr__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__setitem__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__setstate__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__sizeof__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__slotnames__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__slots__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__spec__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__static_attributes__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__str__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__sub__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__subclasscheck__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__subclasshook__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__truediv__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__trunc__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__type_params__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__typing_is_unpacked_typevartuple__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__typing_prepare_subst__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__typing_subst__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__typing_unpacked_tuple_args__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__warningregistry__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__weaklistoffset__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__weakref__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(__xor__); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_abc_impl); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_abstract_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_active); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_align_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_annotation); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_anonymous_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_argtypes_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_as_parameter_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_asyncio_future_blocking); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_blksize); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_bootstrap); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_check_retval_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_dealloc_warn); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_feature_version); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_field_types); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_fields_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_finalizing); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_find_and_load); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_fix_up_module); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_flags_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_get_sourcefile); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_handle_fromlist); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_initializing); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_io); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_is_text_encoding); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_length_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_limbo); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_lock_unlock_module); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_loop); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_needs_com_addref_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_only_immortal); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_pack_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_restype_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_showwarnmsg); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_shutdown); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_slotnames); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_strptime); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_strptime_datetime); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_swappedbytes_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_type_); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_uninitialized_submodules); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_warn_unawaited_coroutine); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(_xoptions); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(abs_tol); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(access); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(aclose); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(add); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(add_done_callback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(after_in_child); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(after_in_parent); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(aggregate_class); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(alias); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(allow_code); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(append); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(arg); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(argdefs); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(args); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(arguments); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(argv); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(as_integer_ratio); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(asend); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(ast); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(athrow); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(attribute); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(authorizer_callback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(autocommit); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(backtick); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(base); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(before); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(big); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(binary_form); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(block); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(bound); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(buffer); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(buffer_callback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(buffer_size); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(buffering); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(buffers); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(bufsize); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(builtins); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(byteorder); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(bytes); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(bytes_per_sep); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(c_call); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(c_exception); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(c_return); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(cached_datetime_module); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(cached_statements); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(cadata); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(cafile); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(call); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(call_exception_handler); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(call_soon); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(callback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(cancel); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(capath); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(category); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(cb_type); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(certfile); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(check_same_thread); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(clear); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(close); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(closed); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(closefd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(closure); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_argcount); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_cellvars); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_code); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_consts); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_exceptiontable); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_filename); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_firstlineno); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_flags); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_freevars); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_kwonlyargcount); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_linetable); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_name); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_names); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_nlocals); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_posonlyargcount); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_qualname); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_stacksize); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(co_varnames); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(code); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(col_offset); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(command); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(comment_factory); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(compile_mode); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(consts); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(context); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(contravariant); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(cookie); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(copy); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(copyreg); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(coro); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(count); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(covariant); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(cwd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(data); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(database); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(day); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(decode); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(decoder); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(default); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(defaultaction); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(delete); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(depth); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(desired_access); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(detect_types); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(deterministic); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(device); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(dict); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(dictcomp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(difference_update); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(digest); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(digest_size); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(digestmod); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(dir_fd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(discard); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(dispatch_table); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(displayhook); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(dklen); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(doc); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(dont_inherit); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(dst); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(dst_dir_fd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(eager_start); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(effective_ids); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(element_factory); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(encode); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(encoding); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(end); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(end_col_offset); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(end_lineno); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(end_offset); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(endpos); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(entrypoint); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(env); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(errors); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(event); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(eventmask); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(exc_type); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(exc_value); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(excepthook); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(exception); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(existing_file_name); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(exp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(extend); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(extra_tokens); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(facility); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(factory); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(false); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(family); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fanout); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fd2); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fdel); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fget); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(file); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(file_actions); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(filename); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fileno); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(filepath); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fillvalue); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(filter); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(filters); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(final); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(find_class); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fix_imports); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(flags); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(flush); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fold); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(follow_symlinks); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(format); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(from_param); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fromlist); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fromtimestamp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fromutc); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fset); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(func); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(future); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(generation); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(genexpr); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(get); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(get_debug); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(get_event_loop); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(get_loop); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(get_source); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(getattr); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(getstate); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(gid); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(globals); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(groupindex); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(groups); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(handle); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(handle_seq); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(has_location); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(hash_name); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(header); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(headers); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(hi); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(hook); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(hour); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(ident); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(identity_hint); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(ignore); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(imag); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(importlib); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(in_fd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(incoming); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(indexgroup); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(inf); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(infer_variance); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(inherit_handle); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(inheritable); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(initial); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(initial_bytes); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(initial_owner); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(initial_state); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(initial_value); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(initval); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(inner_size); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(input); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(insert_comments); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(insert_pis); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(instructions); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(intern); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(intersection); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(interval); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(is_running); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(isatty); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(isinstance); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(isoformat); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(isolation_level); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(istext); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(item); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(items); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(iter); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(iterable); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(iterations); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(join); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(jump); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(keepends); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(key); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(keyfile); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(keys); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(kind); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(kw); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(kw1); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(kw2); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(kwdefaults); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(label); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(lambda); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(last); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(last_exc); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(last_node); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(last_traceback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(last_type); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(last_value); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(latin1); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(leaf_size); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(len); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(length); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(level); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(limit); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(line); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(line_buffering); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(lineno); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(listcomp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(little); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(lo); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(locale); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(locals); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(logoption); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(loop); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(manual_reset); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(mapping); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(match); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(max_length); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(maxdigits); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(maxevents); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(maxlen); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(maxmem); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(maxsplit); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(maxvalue); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(memLevel); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(memlimit); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(message); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(metaclass); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(metadata); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(method); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(microsecond); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(milliseconds); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(minute); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(mod); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(mode); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(module); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(module_globals); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(modules); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(month); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(mro); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(msg); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(mutex); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(mycmp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(n_arg); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(n_fields); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(n_sequence_fields); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(n_unnamed_fields); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(name); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(name_from); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(namespace_separator); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(namespaces); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(narg); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(ndigits); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(nested); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(new_file_name); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(new_limit); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(newline); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(newlines); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(next); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(nlocals); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(node_depth); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(node_offset); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(ns); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(nstype); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(nt); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(null); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(number); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(obj); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(object); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(offset); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(offset_dst); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(offset_src); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(on_type_read); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(onceregistry); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(only_keys); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(oparg); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(opcode); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(open); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(opener); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(operation); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(optimize); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(options); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(order); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(origin); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(out_fd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(outgoing); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(overlapped); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(owner); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(pages); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(parent); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(password); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(path); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(pattern); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(peek); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(persistent_id); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(persistent_load); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(person); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(pi_factory); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(pid); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(policy); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(pos); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(pos1); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(pos2); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(posix); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(print_file_and_line); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(priority); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(progress); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(progress_handler); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(progress_routine); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(proto); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(protocol); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(ps1); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(ps2); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(query); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(quotetabs); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(raw); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(read); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(read1); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(readable); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(readall); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(readinto); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(readinto1); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(readline); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(readonly); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(real); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(reducer_override); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(registry); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(rel_tol); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(release); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(reload); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(repl); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(replace); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(reserved); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(reset); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(resetids); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(return); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(reverse); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(reversed); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(salt); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(sched_priority); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(scheduler); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(second); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(security_attributes); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(seek); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(seekable); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(selectors); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(self); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(send); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(sep); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(sequence); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(server_hostname); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(server_side); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(session); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(setcomp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(setpgroup); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(setsid); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(setsigdef); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(setsigmask); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(setstate); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(shape); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(show_cmd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(signed); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(size); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(sizehint); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(skip_file_prefixes); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(sleep); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(sock); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(sort); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(source); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(source_traceback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(spam); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(src); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(src_dir_fd); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(stacklevel); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(start); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(statement); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(status); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(stderr); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(stdin); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(stdout); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(step); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(steps); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(store_name); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(strategy); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(strftime); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(strict); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(strict_mode); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(string); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(sub_key); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(symmetric_difference_update); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tabsize); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tag); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(target); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(target_is_directory); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(task); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tb_frame); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tb_lasti); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tb_lineno); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tb_next); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tell); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(template); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(term); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(text); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(threading); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(throw); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(timeout); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(times); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(timetuple); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(top); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(trace_callback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(traceback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(trailers); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(translate); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(true); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(truncate); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(twice); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(txt); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(type); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(type_params); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tz); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tzinfo); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(tzname); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(uid); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(unlink); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(unraisablehook); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(uri); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(usedforsecurity); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(value); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(values); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(version); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(volume); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(wait_all); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(warn_on_full_buffer); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(warnings); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(warnoptions); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(wbits); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(week); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(weekday); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(which); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(who); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(withdata); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(writable); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(write); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(write_through); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(year); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(zdict); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(empty); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(dbl_percent); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(dot_locals); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(defaults); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(generic_base); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(kwdefaults); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(type_params); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(str_replace_inf); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_null); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_dictcomp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_genexpr); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_lambda); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_listcomp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_module); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_setcomp); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_string); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(anon_unknown); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(json_decoder); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(list_err); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(utf_8); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(dbl_open_br); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_STR(dbl_close_br); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); +} +/* End auto-generated code */ +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_UNICODEOBJECT_GENERATED_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_unionobject.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_unionobject.h new file mode 100644 index 00000000..6ece7134 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_unionobject.h @@ -0,0 +1,25 @@ +#ifndef Py_INTERNAL_UNIONOBJECT_H +#define Py_INTERNAL_UNIONOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +// For extensions created by test_peg_generator +PyAPI_DATA(PyTypeObject) _PyUnion_Type; +PyAPI_FUNC(PyObject *) _Py_union_type_or(PyObject *, PyObject *); + +#define _PyUnion_Check(op) Py_IS_TYPE((op), &_PyUnion_Type) + +#define _PyGenericAlias_Check(op) PyObject_TypeCheck((op), &Py_GenericAliasType) +extern PyObject *_Py_subs_parameters(PyObject *, PyObject *, PyObject *, PyObject *); +extern PyObject *_Py_make_parameters(PyObject *); +extern PyObject *_Py_union_args(PyObject *self); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_UNIONOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_uop_ids.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_uop_ids.h new file mode 100644 index 00000000..1e6ef8e5 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_uop_ids.h @@ -0,0 +1,294 @@ +// This file is generated by Tools/cases_generator/uop_id_generator.py +// from: +// Python/bytecodes.c +// Do not edit! + +#ifndef Py_CORE_UOP_IDS_H +#define Py_CORE_UOP_IDS_H +#ifdef __cplusplus +extern "C" { +#endif + +#define _EXIT_TRACE 300 +#define _SET_IP 301 +#define _BEFORE_ASYNC_WITH BEFORE_ASYNC_WITH +#define _BEFORE_WITH BEFORE_WITH +#define _BINARY_OP 302 +#define _BINARY_OP_ADD_FLOAT 303 +#define _BINARY_OP_ADD_INT 304 +#define _BINARY_OP_ADD_UNICODE 305 +#define _BINARY_OP_MULTIPLY_FLOAT 306 +#define _BINARY_OP_MULTIPLY_INT 307 +#define _BINARY_OP_SUBTRACT_FLOAT 308 +#define _BINARY_OP_SUBTRACT_INT 309 +#define _BINARY_SLICE BINARY_SLICE +#define _BINARY_SUBSCR 310 +#define _BINARY_SUBSCR_DICT BINARY_SUBSCR_DICT +#define _BINARY_SUBSCR_GETITEM BINARY_SUBSCR_GETITEM +#define _BINARY_SUBSCR_LIST_INT BINARY_SUBSCR_LIST_INT +#define _BINARY_SUBSCR_STR_INT BINARY_SUBSCR_STR_INT +#define _BINARY_SUBSCR_TUPLE_INT BINARY_SUBSCR_TUPLE_INT +#define _BUILD_CONST_KEY_MAP BUILD_CONST_KEY_MAP +#define _BUILD_LIST BUILD_LIST +#define _BUILD_MAP BUILD_MAP +#define _BUILD_SET BUILD_SET +#define _BUILD_SLICE BUILD_SLICE +#define _BUILD_STRING BUILD_STRING +#define _BUILD_TUPLE BUILD_TUPLE +#define _CALL 311 +#define _CALL_ALLOC_AND_ENTER_INIT CALL_ALLOC_AND_ENTER_INIT +#define _CALL_BUILTIN_CLASS 312 +#define _CALL_BUILTIN_FAST 313 +#define _CALL_BUILTIN_FAST_WITH_KEYWORDS 314 +#define _CALL_BUILTIN_O 315 +#define _CALL_FUNCTION_EX CALL_FUNCTION_EX +#define _CALL_INTRINSIC_1 CALL_INTRINSIC_1 +#define _CALL_INTRINSIC_2 CALL_INTRINSIC_2 +#define _CALL_ISINSTANCE CALL_ISINSTANCE +#define _CALL_KW CALL_KW +#define _CALL_LEN CALL_LEN +#define _CALL_METHOD_DESCRIPTOR_FAST 316 +#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 317 +#define _CALL_METHOD_DESCRIPTOR_NOARGS 318 +#define _CALL_METHOD_DESCRIPTOR_O 319 +#define _CALL_NON_PY_GENERAL 320 +#define _CALL_STR_1 321 +#define _CALL_TUPLE_1 322 +#define _CALL_TYPE_1 CALL_TYPE_1 +#define _CHECK_ATTR_CLASS 323 +#define _CHECK_ATTR_METHOD_LAZY_DICT 324 +#define _CHECK_ATTR_MODULE 325 +#define _CHECK_ATTR_WITH_HINT 326 +#define _CHECK_CALL_BOUND_METHOD_EXACT_ARGS 327 +#define _CHECK_EG_MATCH CHECK_EG_MATCH +#define _CHECK_EXC_MATCH CHECK_EXC_MATCH +#define _CHECK_FUNCTION 328 +#define _CHECK_FUNCTION_EXACT_ARGS 329 +#define _CHECK_FUNCTION_VERSION 330 +#define _CHECK_IS_NOT_PY_CALLABLE 331 +#define _CHECK_MANAGED_OBJECT_HAS_VALUES 332 +#define _CHECK_METHOD_VERSION 333 +#define _CHECK_PEP_523 334 +#define _CHECK_PERIODIC 335 +#define _CHECK_STACK_SPACE 336 +#define _CHECK_STACK_SPACE_OPERAND 337 +#define _CHECK_VALIDITY 338 +#define _CHECK_VALIDITY_AND_SET_IP 339 +#define _COLD_EXIT 340 +#define _COMPARE_OP 341 +#define _COMPARE_OP_FLOAT 342 +#define _COMPARE_OP_INT 343 +#define _COMPARE_OP_STR 344 +#define _CONTAINS_OP 345 +#define _CONTAINS_OP_DICT CONTAINS_OP_DICT +#define _CONTAINS_OP_SET CONTAINS_OP_SET +#define _CONVERT_VALUE CONVERT_VALUE +#define _COPY COPY +#define _COPY_FREE_VARS COPY_FREE_VARS +#define _DELETE_ATTR DELETE_ATTR +#define _DELETE_DEREF DELETE_DEREF +#define _DELETE_FAST DELETE_FAST +#define _DELETE_GLOBAL DELETE_GLOBAL +#define _DELETE_NAME DELETE_NAME +#define _DELETE_SUBSCR DELETE_SUBSCR +#define _DEOPT 346 +#define _DICT_MERGE DICT_MERGE +#define _DICT_UPDATE DICT_UPDATE +#define _DYNAMIC_EXIT 347 +#define _END_SEND END_SEND +#define _ERROR_POP_N 348 +#define _EXIT_INIT_CHECK EXIT_INIT_CHECK +#define _EXPAND_METHOD 349 +#define _FATAL_ERROR 350 +#define _FORMAT_SIMPLE FORMAT_SIMPLE +#define _FORMAT_WITH_SPEC FORMAT_WITH_SPEC +#define _FOR_ITER 351 +#define _FOR_ITER_GEN_FRAME 352 +#define _FOR_ITER_TIER_TWO 353 +#define _GET_AITER GET_AITER +#define _GET_ANEXT GET_ANEXT +#define _GET_AWAITABLE GET_AWAITABLE +#define _GET_ITER GET_ITER +#define _GET_LEN GET_LEN +#define _GET_YIELD_FROM_ITER GET_YIELD_FROM_ITER +#define _GUARD_BOTH_FLOAT 354 +#define _GUARD_BOTH_INT 355 +#define _GUARD_BOTH_UNICODE 356 +#define _GUARD_BUILTINS_VERSION 357 +#define _GUARD_DORV_NO_DICT 358 +#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT 359 +#define _GUARD_GLOBALS_VERSION 360 +#define _GUARD_IS_FALSE_POP 361 +#define _GUARD_IS_NONE_POP 362 +#define _GUARD_IS_NOT_NONE_POP 363 +#define _GUARD_IS_TRUE_POP 364 +#define _GUARD_KEYS_VERSION 365 +#define _GUARD_NOS_FLOAT 366 +#define _GUARD_NOS_INT 367 +#define _GUARD_NOT_EXHAUSTED_LIST 368 +#define _GUARD_NOT_EXHAUSTED_RANGE 369 +#define _GUARD_NOT_EXHAUSTED_TUPLE 370 +#define _GUARD_TOS_FLOAT 371 +#define _GUARD_TOS_INT 372 +#define _GUARD_TYPE_VERSION 373 +#define _INIT_CALL_BOUND_METHOD_EXACT_ARGS 374 +#define _INIT_CALL_PY_EXACT_ARGS 375 +#define _INIT_CALL_PY_EXACT_ARGS_0 376 +#define _INIT_CALL_PY_EXACT_ARGS_1 377 +#define _INIT_CALL_PY_EXACT_ARGS_2 378 +#define _INIT_CALL_PY_EXACT_ARGS_3 379 +#define _INIT_CALL_PY_EXACT_ARGS_4 380 +#define _INSTRUMENTED_CALL INSTRUMENTED_CALL +#define _INSTRUMENTED_CALL_FUNCTION_EX INSTRUMENTED_CALL_FUNCTION_EX +#define _INSTRUMENTED_CALL_KW INSTRUMENTED_CALL_KW +#define _INSTRUMENTED_FOR_ITER INSTRUMENTED_FOR_ITER +#define _INSTRUMENTED_INSTRUCTION INSTRUMENTED_INSTRUCTION +#define _INSTRUMENTED_JUMP_BACKWARD INSTRUMENTED_JUMP_BACKWARD +#define _INSTRUMENTED_JUMP_FORWARD INSTRUMENTED_JUMP_FORWARD +#define _INSTRUMENTED_LOAD_SUPER_ATTR INSTRUMENTED_LOAD_SUPER_ATTR +#define _INSTRUMENTED_POP_JUMP_IF_FALSE INSTRUMENTED_POP_JUMP_IF_FALSE +#define _INSTRUMENTED_POP_JUMP_IF_NONE INSTRUMENTED_POP_JUMP_IF_NONE +#define _INSTRUMENTED_POP_JUMP_IF_NOT_NONE INSTRUMENTED_POP_JUMP_IF_NOT_NONE +#define _INSTRUMENTED_POP_JUMP_IF_TRUE INSTRUMENTED_POP_JUMP_IF_TRUE +#define _INSTRUMENTED_RESUME INSTRUMENTED_RESUME +#define _INSTRUMENTED_RETURN_CONST INSTRUMENTED_RETURN_CONST +#define _INSTRUMENTED_RETURN_VALUE INSTRUMENTED_RETURN_VALUE +#define _INSTRUMENTED_YIELD_VALUE INSTRUMENTED_YIELD_VALUE +#define _INTERNAL_INCREMENT_OPT_COUNTER 381 +#define _IS_NONE 382 +#define _IS_OP IS_OP +#define _ITER_CHECK_LIST 383 +#define _ITER_CHECK_RANGE 384 +#define _ITER_CHECK_TUPLE 385 +#define _ITER_JUMP_LIST 386 +#define _ITER_JUMP_RANGE 387 +#define _ITER_JUMP_TUPLE 388 +#define _ITER_NEXT_LIST 389 +#define _ITER_NEXT_RANGE 390 +#define _ITER_NEXT_TUPLE 391 +#define _JUMP_TO_TOP 392 +#define _LIST_APPEND LIST_APPEND +#define _LIST_EXTEND LIST_EXTEND +#define _LOAD_ASSERTION_ERROR LOAD_ASSERTION_ERROR +#define _LOAD_ATTR 393 +#define _LOAD_ATTR_CLASS 394 +#define _LOAD_ATTR_CLASS_0 395 +#define _LOAD_ATTR_CLASS_1 396 +#define _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN +#define _LOAD_ATTR_INSTANCE_VALUE 397 +#define _LOAD_ATTR_INSTANCE_VALUE_0 398 +#define _LOAD_ATTR_INSTANCE_VALUE_1 399 +#define _LOAD_ATTR_METHOD_LAZY_DICT 400 +#define _LOAD_ATTR_METHOD_NO_DICT 401 +#define _LOAD_ATTR_METHOD_WITH_VALUES 402 +#define _LOAD_ATTR_MODULE 403 +#define _LOAD_ATTR_NONDESCRIPTOR_NO_DICT 404 +#define _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 405 +#define _LOAD_ATTR_PROPERTY LOAD_ATTR_PROPERTY +#define _LOAD_ATTR_SLOT 406 +#define _LOAD_ATTR_SLOT_0 407 +#define _LOAD_ATTR_SLOT_1 408 +#define _LOAD_ATTR_WITH_HINT 409 +#define _LOAD_BUILD_CLASS LOAD_BUILD_CLASS +#define _LOAD_CONST LOAD_CONST +#define _LOAD_CONST_INLINE 410 +#define _LOAD_CONST_INLINE_BORROW 411 +#define _LOAD_CONST_INLINE_BORROW_WITH_NULL 412 +#define _LOAD_CONST_INLINE_WITH_NULL 413 +#define _LOAD_DEREF LOAD_DEREF +#define _LOAD_FAST 414 +#define _LOAD_FAST_0 415 +#define _LOAD_FAST_1 416 +#define _LOAD_FAST_2 417 +#define _LOAD_FAST_3 418 +#define _LOAD_FAST_4 419 +#define _LOAD_FAST_5 420 +#define _LOAD_FAST_6 421 +#define _LOAD_FAST_7 422 +#define _LOAD_FAST_AND_CLEAR LOAD_FAST_AND_CLEAR +#define _LOAD_FAST_CHECK LOAD_FAST_CHECK +#define _LOAD_FAST_LOAD_FAST LOAD_FAST_LOAD_FAST +#define _LOAD_FROM_DICT_OR_DEREF LOAD_FROM_DICT_OR_DEREF +#define _LOAD_FROM_DICT_OR_GLOBALS LOAD_FROM_DICT_OR_GLOBALS +#define _LOAD_GLOBAL 423 +#define _LOAD_GLOBAL_BUILTINS 424 +#define _LOAD_GLOBAL_MODULE 425 +#define _LOAD_LOCALS LOAD_LOCALS +#define _LOAD_NAME LOAD_NAME +#define _LOAD_SUPER_ATTR_ATTR LOAD_SUPER_ATTR_ATTR +#define _LOAD_SUPER_ATTR_METHOD LOAD_SUPER_ATTR_METHOD +#define _MAKE_CELL MAKE_CELL +#define _MAKE_FUNCTION MAKE_FUNCTION +#define _MAP_ADD MAP_ADD +#define _MATCH_CLASS MATCH_CLASS +#define _MATCH_KEYS MATCH_KEYS +#define _MATCH_MAPPING MATCH_MAPPING +#define _MATCH_SEQUENCE MATCH_SEQUENCE +#define _NOP NOP +#define _POP_EXCEPT POP_EXCEPT +#define _POP_FRAME 426 +#define _POP_JUMP_IF_FALSE 427 +#define _POP_JUMP_IF_TRUE 428 +#define _POP_TOP POP_TOP +#define _POP_TOP_LOAD_CONST_INLINE_BORROW 429 +#define _PUSH_EXC_INFO PUSH_EXC_INFO +#define _PUSH_FRAME 430 +#define _PUSH_NULL PUSH_NULL +#define _PY_FRAME_GENERAL 431 +#define _REPLACE_WITH_TRUE 432 +#define _RESUME_CHECK RESUME_CHECK +#define _RETURN_GENERATOR RETURN_GENERATOR +#define _SAVE_RETURN_OFFSET 433 +#define _SEND 434 +#define _SEND_GEN SEND_GEN +#define _SETUP_ANNOTATIONS SETUP_ANNOTATIONS +#define _SET_ADD SET_ADD +#define _SET_FUNCTION_ATTRIBUTE SET_FUNCTION_ATTRIBUTE +#define _SET_UPDATE SET_UPDATE +#define _START_EXECUTOR 435 +#define _STORE_ATTR 436 +#define _STORE_ATTR_INSTANCE_VALUE 437 +#define _STORE_ATTR_SLOT 438 +#define _STORE_ATTR_WITH_HINT STORE_ATTR_WITH_HINT +#define _STORE_DEREF STORE_DEREF +#define _STORE_FAST 439 +#define _STORE_FAST_0 440 +#define _STORE_FAST_1 441 +#define _STORE_FAST_2 442 +#define _STORE_FAST_3 443 +#define _STORE_FAST_4 444 +#define _STORE_FAST_5 445 +#define _STORE_FAST_6 446 +#define _STORE_FAST_7 447 +#define _STORE_FAST_LOAD_FAST STORE_FAST_LOAD_FAST +#define _STORE_FAST_STORE_FAST STORE_FAST_STORE_FAST +#define _STORE_GLOBAL STORE_GLOBAL +#define _STORE_NAME STORE_NAME +#define _STORE_SLICE STORE_SLICE +#define _STORE_SUBSCR 448 +#define _STORE_SUBSCR_DICT STORE_SUBSCR_DICT +#define _STORE_SUBSCR_LIST_INT STORE_SUBSCR_LIST_INT +#define _SWAP SWAP +#define _TIER2_RESUME_CHECK 449 +#define _TO_BOOL 450 +#define _TO_BOOL_BOOL TO_BOOL_BOOL +#define _TO_BOOL_INT TO_BOOL_INT +#define _TO_BOOL_LIST TO_BOOL_LIST +#define _TO_BOOL_NONE TO_BOOL_NONE +#define _TO_BOOL_STR TO_BOOL_STR +#define _UNARY_INVERT UNARY_INVERT +#define _UNARY_NEGATIVE UNARY_NEGATIVE +#define _UNARY_NOT UNARY_NOT +#define _UNPACK_EX UNPACK_EX +#define _UNPACK_SEQUENCE 451 +#define _UNPACK_SEQUENCE_LIST UNPACK_SEQUENCE_LIST +#define _UNPACK_SEQUENCE_TUPLE UNPACK_SEQUENCE_TUPLE +#define _UNPACK_SEQUENCE_TWO_TUPLE UNPACK_SEQUENCE_TWO_TUPLE +#define _WITH_EXCEPT_START WITH_EXCEPT_START +#define _YIELD_VALUE YIELD_VALUE +#define MAX_UOP_ID 451 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CORE_UOP_IDS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_uop_metadata.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_uop_metadata.h new file mode 100644 index 00000000..02ffc769 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_uop_metadata.h @@ -0,0 +1,1006 @@ +// This file is generated by Tools/cases_generator/uop_metadata_generator.py +// from: +// Python/bytecodes.c +// Do not edit! + +#ifndef Py_CORE_UOP_METADATA_H +#define Py_CORE_UOP_METADATA_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "pycore_uop_ids.h" +extern const uint16_t _PyUop_Flags[MAX_UOP_ID+1]; +extern const uint8_t _PyUop_Replication[MAX_UOP_ID+1]; +extern const char * const _PyOpcode_uop_name[MAX_UOP_ID+1]; + +extern int _PyUop_num_popped(int opcode, int oparg); + +#ifdef NEED_OPCODE_METADATA +const uint16_t _PyUop_Flags[MAX_UOP_ID+1] = { + [_NOP] = HAS_PURE_FLAG, + [_RESUME_CHECK] = HAS_DEOPT_FLAG, + [_LOAD_FAST_CHECK] = HAS_ARG_FLAG | HAS_LOCAL_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_LOAD_FAST_0] = HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST_1] = HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST_2] = HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST_3] = HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST_4] = HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST_5] = HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST_6] = HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST_7] = HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST] = HAS_ARG_FLAG | HAS_LOCAL_FLAG | HAS_PURE_FLAG, + [_LOAD_FAST_AND_CLEAR] = HAS_ARG_FLAG | HAS_LOCAL_FLAG, + [_LOAD_FAST_LOAD_FAST] = HAS_ARG_FLAG | HAS_LOCAL_FLAG, + [_LOAD_CONST] = HAS_ARG_FLAG | HAS_CONST_FLAG | HAS_PURE_FLAG, + [_STORE_FAST_0] = HAS_LOCAL_FLAG, + [_STORE_FAST_1] = HAS_LOCAL_FLAG, + [_STORE_FAST_2] = HAS_LOCAL_FLAG, + [_STORE_FAST_3] = HAS_LOCAL_FLAG, + [_STORE_FAST_4] = HAS_LOCAL_FLAG, + [_STORE_FAST_5] = HAS_LOCAL_FLAG, + [_STORE_FAST_6] = HAS_LOCAL_FLAG, + [_STORE_FAST_7] = HAS_LOCAL_FLAG, + [_STORE_FAST] = HAS_ARG_FLAG | HAS_LOCAL_FLAG, + [_STORE_FAST_LOAD_FAST] = HAS_ARG_FLAG | HAS_LOCAL_FLAG, + [_STORE_FAST_STORE_FAST] = HAS_ARG_FLAG | HAS_LOCAL_FLAG, + [_POP_TOP] = HAS_PURE_FLAG, + [_PUSH_NULL] = HAS_PURE_FLAG, + [_END_SEND] = HAS_PURE_FLAG, + [_UNARY_NEGATIVE] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_UNARY_NOT] = HAS_PURE_FLAG, + [_TO_BOOL] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_TO_BOOL_BOOL] = HAS_EXIT_FLAG, + [_TO_BOOL_INT] = HAS_EXIT_FLAG | HAS_ESCAPES_FLAG, + [_TO_BOOL_LIST] = HAS_EXIT_FLAG, + [_TO_BOOL_NONE] = HAS_EXIT_FLAG, + [_TO_BOOL_STR] = HAS_EXIT_FLAG | HAS_ESCAPES_FLAG, + [_REPLACE_WITH_TRUE] = 0, + [_UNARY_INVERT] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_GUARD_BOTH_INT] = HAS_EXIT_FLAG, + [_GUARD_NOS_INT] = HAS_EXIT_FLAG, + [_GUARD_TOS_INT] = HAS_EXIT_FLAG, + [_BINARY_OP_MULTIPLY_INT] = HAS_ERROR_FLAG | HAS_PURE_FLAG, + [_BINARY_OP_ADD_INT] = HAS_ERROR_FLAG | HAS_PURE_FLAG, + [_BINARY_OP_SUBTRACT_INT] = HAS_ERROR_FLAG | HAS_PURE_FLAG, + [_GUARD_BOTH_FLOAT] = HAS_EXIT_FLAG, + [_GUARD_NOS_FLOAT] = HAS_EXIT_FLAG, + [_GUARD_TOS_FLOAT] = HAS_EXIT_FLAG, + [_BINARY_OP_MULTIPLY_FLOAT] = HAS_PURE_FLAG, + [_BINARY_OP_ADD_FLOAT] = HAS_PURE_FLAG, + [_BINARY_OP_SUBTRACT_FLOAT] = HAS_PURE_FLAG, + [_GUARD_BOTH_UNICODE] = HAS_EXIT_FLAG, + [_BINARY_OP_ADD_UNICODE] = HAS_ERROR_FLAG | HAS_PURE_FLAG, + [_BINARY_SUBSCR] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_BINARY_SLICE] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_STORE_SLICE] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_BINARY_SUBSCR_LIST_INT] = HAS_DEOPT_FLAG, + [_BINARY_SUBSCR_STR_INT] = HAS_DEOPT_FLAG, + [_BINARY_SUBSCR_TUPLE_INT] = HAS_DEOPT_FLAG, + [_BINARY_SUBSCR_DICT] = HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_LIST_APPEND] = HAS_ARG_FLAG | HAS_ERROR_FLAG, + [_SET_ADD] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_STORE_SUBSCR] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_STORE_SUBSCR_LIST_INT] = HAS_DEOPT_FLAG, + [_STORE_SUBSCR_DICT] = HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_DELETE_SUBSCR] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_INTRINSIC_1] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_INTRINSIC_2] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_POP_FRAME] = 0, + [_GET_AITER] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_GET_ANEXT] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_GET_AWAITABLE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_YIELD_VALUE] = HAS_ARG_FLAG | HAS_ESCAPES_FLAG, + [_POP_EXCEPT] = HAS_ESCAPES_FLAG, + [_LOAD_ASSERTION_ERROR] = 0, + [_LOAD_BUILD_CLASS] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_STORE_NAME] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_DELETE_NAME] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_UNPACK_SEQUENCE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_UNPACK_SEQUENCE_TWO_TUPLE] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_UNPACK_SEQUENCE_TUPLE] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_UNPACK_SEQUENCE_LIST] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_UNPACK_EX] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_STORE_ATTR] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_DELETE_ATTR] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_STORE_GLOBAL] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_DELETE_GLOBAL] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_LOAD_LOCALS] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_LOAD_GLOBAL] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_GUARD_GLOBALS_VERSION] = HAS_DEOPT_FLAG, + [_GUARD_BUILTINS_VERSION] = HAS_DEOPT_FLAG, + [_LOAD_GLOBAL_MODULE] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_LOAD_GLOBAL_BUILTINS] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_DELETE_FAST] = HAS_ARG_FLAG | HAS_LOCAL_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_MAKE_CELL] = HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG, + [_DELETE_DEREF] = HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_LOAD_FROM_DICT_OR_DEREF] = HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_LOAD_DEREF] = HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_STORE_DEREF] = HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ESCAPES_FLAG, + [_COPY_FREE_VARS] = HAS_ARG_FLAG, + [_BUILD_STRING] = HAS_ARG_FLAG | HAS_ERROR_FLAG, + [_BUILD_TUPLE] = HAS_ARG_FLAG | HAS_ERROR_FLAG, + [_BUILD_LIST] = HAS_ARG_FLAG | HAS_ERROR_FLAG, + [_LIST_EXTEND] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_SET_UPDATE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_BUILD_MAP] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_SETUP_ANNOTATIONS] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_BUILD_CONST_KEY_MAP] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_DICT_UPDATE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_DICT_MERGE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_MAP_ADD] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_LOAD_SUPER_ATTR_ATTR] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_LOAD_SUPER_ATTR_METHOD] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_LOAD_ATTR] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_GUARD_TYPE_VERSION] = HAS_EXIT_FLAG, + [_CHECK_MANAGED_OBJECT_HAS_VALUES] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_INSTANCE_VALUE_0] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_INSTANCE_VALUE_1] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_INSTANCE_VALUE] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_OPARG_AND_1_FLAG, + [_CHECK_ATTR_MODULE] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_MODULE] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_CHECK_ATTR_WITH_HINT] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_WITH_HINT] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG, + [_LOAD_ATTR_SLOT_0] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_SLOT_1] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_SLOT] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_OPARG_AND_1_FLAG, + [_CHECK_ATTR_CLASS] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_CLASS_0] = 0, + [_LOAD_ATTR_CLASS_1] = 0, + [_LOAD_ATTR_CLASS] = HAS_ARG_FLAG | HAS_OPARG_AND_1_FLAG, + [_GUARD_DORV_NO_DICT] = HAS_DEOPT_FLAG, + [_STORE_ATTR_INSTANCE_VALUE] = 0, + [_STORE_ATTR_SLOT] = 0, + [_COMPARE_OP] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_COMPARE_OP_FLOAT] = HAS_ARG_FLAG, + [_COMPARE_OP_INT] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_COMPARE_OP_STR] = HAS_ARG_FLAG, + [_IS_OP] = HAS_ARG_FLAG, + [_CONTAINS_OP] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CONTAINS_OP_SET] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CONTAINS_OP_DICT] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CHECK_EG_MATCH] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CHECK_EXC_MATCH] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_IS_NONE] = 0, + [_GET_LEN] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_MATCH_CLASS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_MATCH_MAPPING] = 0, + [_MATCH_SEQUENCE] = 0, + [_MATCH_KEYS] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_GET_ITER] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_GET_YIELD_FROM_ITER] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_FOR_ITER_TIER_TWO] = HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_ITER_CHECK_LIST] = HAS_EXIT_FLAG, + [_GUARD_NOT_EXHAUSTED_LIST] = HAS_EXIT_FLAG, + [_ITER_NEXT_LIST] = 0, + [_ITER_CHECK_TUPLE] = HAS_EXIT_FLAG, + [_GUARD_NOT_EXHAUSTED_TUPLE] = HAS_EXIT_FLAG, + [_ITER_NEXT_TUPLE] = 0, + [_ITER_CHECK_RANGE] = HAS_EXIT_FLAG, + [_GUARD_NOT_EXHAUSTED_RANGE] = HAS_EXIT_FLAG, + [_ITER_NEXT_RANGE] = HAS_ERROR_FLAG, + [_FOR_ITER_GEN_FRAME] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_WITH_EXCEPT_START] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_PUSH_EXC_INFO] = 0, + [_GUARD_DORV_VALUES_INST_ATTR_FROM_DICT] = HAS_DEOPT_FLAG, + [_GUARD_KEYS_VERSION] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_METHOD_WITH_VALUES] = HAS_ARG_FLAG, + [_LOAD_ATTR_METHOD_NO_DICT] = HAS_ARG_FLAG, + [_LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = HAS_ARG_FLAG, + [_LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = HAS_ARG_FLAG, + [_CHECK_ATTR_METHOD_LAZY_DICT] = HAS_DEOPT_FLAG, + [_LOAD_ATTR_METHOD_LAZY_DICT] = HAS_ARG_FLAG, + [_CHECK_PERIODIC] = HAS_EVAL_BREAK_FLAG, + [_PY_FRAME_GENERAL] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CHECK_FUNCTION_VERSION] = HAS_ARG_FLAG | HAS_EXIT_FLAG, + [_CHECK_METHOD_VERSION] = HAS_ARG_FLAG | HAS_EXIT_FLAG, + [_EXPAND_METHOD] = HAS_ARG_FLAG, + [_CHECK_IS_NOT_PY_CALLABLE] = HAS_ARG_FLAG | HAS_EXIT_FLAG, + [_CALL_NON_PY_GENERAL] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CHECK_CALL_BOUND_METHOD_EXACT_ARGS] = HAS_ARG_FLAG | HAS_EXIT_FLAG, + [_INIT_CALL_BOUND_METHOD_EXACT_ARGS] = HAS_ARG_FLAG, + [_CHECK_PEP_523] = HAS_DEOPT_FLAG, + [_CHECK_FUNCTION_EXACT_ARGS] = HAS_ARG_FLAG | HAS_EXIT_FLAG, + [_CHECK_STACK_SPACE] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_INIT_CALL_PY_EXACT_ARGS_0] = HAS_PURE_FLAG, + [_INIT_CALL_PY_EXACT_ARGS_1] = HAS_PURE_FLAG, + [_INIT_CALL_PY_EXACT_ARGS_2] = HAS_PURE_FLAG, + [_INIT_CALL_PY_EXACT_ARGS_3] = HAS_PURE_FLAG, + [_INIT_CALL_PY_EXACT_ARGS_4] = HAS_PURE_FLAG, + [_INIT_CALL_PY_EXACT_ARGS] = HAS_ARG_FLAG | HAS_PURE_FLAG, + [_PUSH_FRAME] = 0, + [_CALL_TYPE_1] = HAS_ARG_FLAG | HAS_DEOPT_FLAG, + [_CALL_STR_1] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_TUPLE_1] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_EXIT_INIT_CHECK] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CALL_BUILTIN_CLASS] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_BUILTIN_O] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_BUILTIN_FAST] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_BUILTIN_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_LEN] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CALL_ISINSTANCE] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_O] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_NOARGS] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_FAST] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_MAKE_FUNCTION] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_SET_FUNCTION_ATTRIBUTE] = HAS_ARG_FLAG | HAS_ESCAPES_FLAG, + [_RETURN_GENERATOR] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_BUILD_SLICE] = HAS_ARG_FLAG | HAS_ERROR_FLAG, + [_CONVERT_VALUE] = HAS_ARG_FLAG | HAS_ERROR_FLAG, + [_FORMAT_SIMPLE] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_FORMAT_WITH_SPEC] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_COPY] = HAS_ARG_FLAG | HAS_PURE_FLAG, + [_BINARY_OP] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_SWAP] = HAS_ARG_FLAG | HAS_PURE_FLAG, + [_GUARD_IS_TRUE_POP] = HAS_EXIT_FLAG, + [_GUARD_IS_FALSE_POP] = HAS_EXIT_FLAG, + [_GUARD_IS_NONE_POP] = HAS_EXIT_FLAG, + [_GUARD_IS_NOT_NONE_POP] = HAS_EXIT_FLAG, + [_JUMP_TO_TOP] = 0, + [_SET_IP] = 0, + [_CHECK_STACK_SPACE_OPERAND] = HAS_DEOPT_FLAG, + [_SAVE_RETURN_OFFSET] = HAS_ARG_FLAG, + [_EXIT_TRACE] = 0, + [_CHECK_VALIDITY] = HAS_DEOPT_FLAG, + [_LOAD_CONST_INLINE] = HAS_PURE_FLAG, + [_LOAD_CONST_INLINE_BORROW] = HAS_PURE_FLAG, + [_POP_TOP_LOAD_CONST_INLINE_BORROW] = HAS_PURE_FLAG, + [_LOAD_CONST_INLINE_WITH_NULL] = HAS_PURE_FLAG, + [_LOAD_CONST_INLINE_BORROW_WITH_NULL] = HAS_PURE_FLAG, + [_CHECK_FUNCTION] = HAS_DEOPT_FLAG, + [_INTERNAL_INCREMENT_OPT_COUNTER] = 0, + [_COLD_EXIT] = HAS_ARG_FLAG | HAS_ESCAPES_FLAG, + [_DYNAMIC_EXIT] = HAS_ARG_FLAG | HAS_ESCAPES_FLAG, + [_START_EXECUTOR] = HAS_DEOPT_FLAG, + [_FATAL_ERROR] = 0, + [_CHECK_VALIDITY_AND_SET_IP] = HAS_DEOPT_FLAG, + [_DEOPT] = 0, + [_ERROR_POP_N] = HAS_ARG_FLAG, + [_TIER2_RESUME_CHECK] = HAS_DEOPT_FLAG, +}; + +const uint8_t _PyUop_Replication[MAX_UOP_ID+1] = { + [_LOAD_FAST] = 8, + [_STORE_FAST] = 8, + [_INIT_CALL_PY_EXACT_ARGS] = 5, +}; + +const char *const _PyOpcode_uop_name[MAX_UOP_ID+1] = { + [_BINARY_OP] = "_BINARY_OP", + [_BINARY_OP_ADD_FLOAT] = "_BINARY_OP_ADD_FLOAT", + [_BINARY_OP_ADD_INT] = "_BINARY_OP_ADD_INT", + [_BINARY_OP_ADD_UNICODE] = "_BINARY_OP_ADD_UNICODE", + [_BINARY_OP_MULTIPLY_FLOAT] = "_BINARY_OP_MULTIPLY_FLOAT", + [_BINARY_OP_MULTIPLY_INT] = "_BINARY_OP_MULTIPLY_INT", + [_BINARY_OP_SUBTRACT_FLOAT] = "_BINARY_OP_SUBTRACT_FLOAT", + [_BINARY_OP_SUBTRACT_INT] = "_BINARY_OP_SUBTRACT_INT", + [_BINARY_SLICE] = "_BINARY_SLICE", + [_BINARY_SUBSCR] = "_BINARY_SUBSCR", + [_BINARY_SUBSCR_DICT] = "_BINARY_SUBSCR_DICT", + [_BINARY_SUBSCR_LIST_INT] = "_BINARY_SUBSCR_LIST_INT", + [_BINARY_SUBSCR_STR_INT] = "_BINARY_SUBSCR_STR_INT", + [_BINARY_SUBSCR_TUPLE_INT] = "_BINARY_SUBSCR_TUPLE_INT", + [_BUILD_CONST_KEY_MAP] = "_BUILD_CONST_KEY_MAP", + [_BUILD_LIST] = "_BUILD_LIST", + [_BUILD_MAP] = "_BUILD_MAP", + [_BUILD_SLICE] = "_BUILD_SLICE", + [_BUILD_STRING] = "_BUILD_STRING", + [_BUILD_TUPLE] = "_BUILD_TUPLE", + [_CALL_BUILTIN_CLASS] = "_CALL_BUILTIN_CLASS", + [_CALL_BUILTIN_FAST] = "_CALL_BUILTIN_FAST", + [_CALL_BUILTIN_FAST_WITH_KEYWORDS] = "_CALL_BUILTIN_FAST_WITH_KEYWORDS", + [_CALL_BUILTIN_O] = "_CALL_BUILTIN_O", + [_CALL_INTRINSIC_1] = "_CALL_INTRINSIC_1", + [_CALL_INTRINSIC_2] = "_CALL_INTRINSIC_2", + [_CALL_ISINSTANCE] = "_CALL_ISINSTANCE", + [_CALL_LEN] = "_CALL_LEN", + [_CALL_METHOD_DESCRIPTOR_FAST] = "_CALL_METHOD_DESCRIPTOR_FAST", + [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", + [_CALL_METHOD_DESCRIPTOR_NOARGS] = "_CALL_METHOD_DESCRIPTOR_NOARGS", + [_CALL_METHOD_DESCRIPTOR_O] = "_CALL_METHOD_DESCRIPTOR_O", + [_CALL_NON_PY_GENERAL] = "_CALL_NON_PY_GENERAL", + [_CALL_STR_1] = "_CALL_STR_1", + [_CALL_TUPLE_1] = "_CALL_TUPLE_1", + [_CALL_TYPE_1] = "_CALL_TYPE_1", + [_CHECK_ATTR_CLASS] = "_CHECK_ATTR_CLASS", + [_CHECK_ATTR_METHOD_LAZY_DICT] = "_CHECK_ATTR_METHOD_LAZY_DICT", + [_CHECK_ATTR_MODULE] = "_CHECK_ATTR_MODULE", + [_CHECK_ATTR_WITH_HINT] = "_CHECK_ATTR_WITH_HINT", + [_CHECK_CALL_BOUND_METHOD_EXACT_ARGS] = "_CHECK_CALL_BOUND_METHOD_EXACT_ARGS", + [_CHECK_EG_MATCH] = "_CHECK_EG_MATCH", + [_CHECK_EXC_MATCH] = "_CHECK_EXC_MATCH", + [_CHECK_FUNCTION] = "_CHECK_FUNCTION", + [_CHECK_FUNCTION_EXACT_ARGS] = "_CHECK_FUNCTION_EXACT_ARGS", + [_CHECK_FUNCTION_VERSION] = "_CHECK_FUNCTION_VERSION", + [_CHECK_IS_NOT_PY_CALLABLE] = "_CHECK_IS_NOT_PY_CALLABLE", + [_CHECK_MANAGED_OBJECT_HAS_VALUES] = "_CHECK_MANAGED_OBJECT_HAS_VALUES", + [_CHECK_METHOD_VERSION] = "_CHECK_METHOD_VERSION", + [_CHECK_PEP_523] = "_CHECK_PEP_523", + [_CHECK_PERIODIC] = "_CHECK_PERIODIC", + [_CHECK_STACK_SPACE] = "_CHECK_STACK_SPACE", + [_CHECK_STACK_SPACE_OPERAND] = "_CHECK_STACK_SPACE_OPERAND", + [_CHECK_VALIDITY] = "_CHECK_VALIDITY", + [_CHECK_VALIDITY_AND_SET_IP] = "_CHECK_VALIDITY_AND_SET_IP", + [_COLD_EXIT] = "_COLD_EXIT", + [_COMPARE_OP] = "_COMPARE_OP", + [_COMPARE_OP_FLOAT] = "_COMPARE_OP_FLOAT", + [_COMPARE_OP_INT] = "_COMPARE_OP_INT", + [_COMPARE_OP_STR] = "_COMPARE_OP_STR", + [_CONTAINS_OP] = "_CONTAINS_OP", + [_CONTAINS_OP_DICT] = "_CONTAINS_OP_DICT", + [_CONTAINS_OP_SET] = "_CONTAINS_OP_SET", + [_CONVERT_VALUE] = "_CONVERT_VALUE", + [_COPY] = "_COPY", + [_COPY_FREE_VARS] = "_COPY_FREE_VARS", + [_DELETE_ATTR] = "_DELETE_ATTR", + [_DELETE_DEREF] = "_DELETE_DEREF", + [_DELETE_FAST] = "_DELETE_FAST", + [_DELETE_GLOBAL] = "_DELETE_GLOBAL", + [_DELETE_NAME] = "_DELETE_NAME", + [_DELETE_SUBSCR] = "_DELETE_SUBSCR", + [_DEOPT] = "_DEOPT", + [_DICT_MERGE] = "_DICT_MERGE", + [_DICT_UPDATE] = "_DICT_UPDATE", + [_DYNAMIC_EXIT] = "_DYNAMIC_EXIT", + [_END_SEND] = "_END_SEND", + [_ERROR_POP_N] = "_ERROR_POP_N", + [_EXIT_INIT_CHECK] = "_EXIT_INIT_CHECK", + [_EXIT_TRACE] = "_EXIT_TRACE", + [_EXPAND_METHOD] = "_EXPAND_METHOD", + [_FATAL_ERROR] = "_FATAL_ERROR", + [_FORMAT_SIMPLE] = "_FORMAT_SIMPLE", + [_FORMAT_WITH_SPEC] = "_FORMAT_WITH_SPEC", + [_FOR_ITER_GEN_FRAME] = "_FOR_ITER_GEN_FRAME", + [_FOR_ITER_TIER_TWO] = "_FOR_ITER_TIER_TWO", + [_GET_AITER] = "_GET_AITER", + [_GET_ANEXT] = "_GET_ANEXT", + [_GET_AWAITABLE] = "_GET_AWAITABLE", + [_GET_ITER] = "_GET_ITER", + [_GET_LEN] = "_GET_LEN", + [_GET_YIELD_FROM_ITER] = "_GET_YIELD_FROM_ITER", + [_GUARD_BOTH_FLOAT] = "_GUARD_BOTH_FLOAT", + [_GUARD_BOTH_INT] = "_GUARD_BOTH_INT", + [_GUARD_BOTH_UNICODE] = "_GUARD_BOTH_UNICODE", + [_GUARD_BUILTINS_VERSION] = "_GUARD_BUILTINS_VERSION", + [_GUARD_DORV_NO_DICT] = "_GUARD_DORV_NO_DICT", + [_GUARD_DORV_VALUES_INST_ATTR_FROM_DICT] = "_GUARD_DORV_VALUES_INST_ATTR_FROM_DICT", + [_GUARD_GLOBALS_VERSION] = "_GUARD_GLOBALS_VERSION", + [_GUARD_IS_FALSE_POP] = "_GUARD_IS_FALSE_POP", + [_GUARD_IS_NONE_POP] = "_GUARD_IS_NONE_POP", + [_GUARD_IS_NOT_NONE_POP] = "_GUARD_IS_NOT_NONE_POP", + [_GUARD_IS_TRUE_POP] = "_GUARD_IS_TRUE_POP", + [_GUARD_KEYS_VERSION] = "_GUARD_KEYS_VERSION", + [_GUARD_NOS_FLOAT] = "_GUARD_NOS_FLOAT", + [_GUARD_NOS_INT] = "_GUARD_NOS_INT", + [_GUARD_NOT_EXHAUSTED_LIST] = "_GUARD_NOT_EXHAUSTED_LIST", + [_GUARD_NOT_EXHAUSTED_RANGE] = "_GUARD_NOT_EXHAUSTED_RANGE", + [_GUARD_NOT_EXHAUSTED_TUPLE] = "_GUARD_NOT_EXHAUSTED_TUPLE", + [_GUARD_TOS_FLOAT] = "_GUARD_TOS_FLOAT", + [_GUARD_TOS_INT] = "_GUARD_TOS_INT", + [_GUARD_TYPE_VERSION] = "_GUARD_TYPE_VERSION", + [_INIT_CALL_BOUND_METHOD_EXACT_ARGS] = "_INIT_CALL_BOUND_METHOD_EXACT_ARGS", + [_INIT_CALL_PY_EXACT_ARGS] = "_INIT_CALL_PY_EXACT_ARGS", + [_INIT_CALL_PY_EXACT_ARGS_0] = "_INIT_CALL_PY_EXACT_ARGS_0", + [_INIT_CALL_PY_EXACT_ARGS_1] = "_INIT_CALL_PY_EXACT_ARGS_1", + [_INIT_CALL_PY_EXACT_ARGS_2] = "_INIT_CALL_PY_EXACT_ARGS_2", + [_INIT_CALL_PY_EXACT_ARGS_3] = "_INIT_CALL_PY_EXACT_ARGS_3", + [_INIT_CALL_PY_EXACT_ARGS_4] = "_INIT_CALL_PY_EXACT_ARGS_4", + [_INTERNAL_INCREMENT_OPT_COUNTER] = "_INTERNAL_INCREMENT_OPT_COUNTER", + [_IS_NONE] = "_IS_NONE", + [_IS_OP] = "_IS_OP", + [_ITER_CHECK_LIST] = "_ITER_CHECK_LIST", + [_ITER_CHECK_RANGE] = "_ITER_CHECK_RANGE", + [_ITER_CHECK_TUPLE] = "_ITER_CHECK_TUPLE", + [_ITER_NEXT_LIST] = "_ITER_NEXT_LIST", + [_ITER_NEXT_RANGE] = "_ITER_NEXT_RANGE", + [_ITER_NEXT_TUPLE] = "_ITER_NEXT_TUPLE", + [_JUMP_TO_TOP] = "_JUMP_TO_TOP", + [_LIST_APPEND] = "_LIST_APPEND", + [_LIST_EXTEND] = "_LIST_EXTEND", + [_LOAD_ASSERTION_ERROR] = "_LOAD_ASSERTION_ERROR", + [_LOAD_ATTR] = "_LOAD_ATTR", + [_LOAD_ATTR_CLASS] = "_LOAD_ATTR_CLASS", + [_LOAD_ATTR_CLASS_0] = "_LOAD_ATTR_CLASS_0", + [_LOAD_ATTR_CLASS_1] = "_LOAD_ATTR_CLASS_1", + [_LOAD_ATTR_INSTANCE_VALUE] = "_LOAD_ATTR_INSTANCE_VALUE", + [_LOAD_ATTR_INSTANCE_VALUE_0] = "_LOAD_ATTR_INSTANCE_VALUE_0", + [_LOAD_ATTR_INSTANCE_VALUE_1] = "_LOAD_ATTR_INSTANCE_VALUE_1", + [_LOAD_ATTR_METHOD_LAZY_DICT] = "_LOAD_ATTR_METHOD_LAZY_DICT", + [_LOAD_ATTR_METHOD_NO_DICT] = "_LOAD_ATTR_METHOD_NO_DICT", + [_LOAD_ATTR_METHOD_WITH_VALUES] = "_LOAD_ATTR_METHOD_WITH_VALUES", + [_LOAD_ATTR_MODULE] = "_LOAD_ATTR_MODULE", + [_LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = "_LOAD_ATTR_NONDESCRIPTOR_NO_DICT", + [_LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = "_LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES", + [_LOAD_ATTR_SLOT] = "_LOAD_ATTR_SLOT", + [_LOAD_ATTR_SLOT_0] = "_LOAD_ATTR_SLOT_0", + [_LOAD_ATTR_SLOT_1] = "_LOAD_ATTR_SLOT_1", + [_LOAD_ATTR_WITH_HINT] = "_LOAD_ATTR_WITH_HINT", + [_LOAD_BUILD_CLASS] = "_LOAD_BUILD_CLASS", + [_LOAD_CONST] = "_LOAD_CONST", + [_LOAD_CONST_INLINE] = "_LOAD_CONST_INLINE", + [_LOAD_CONST_INLINE_BORROW] = "_LOAD_CONST_INLINE_BORROW", + [_LOAD_CONST_INLINE_BORROW_WITH_NULL] = "_LOAD_CONST_INLINE_BORROW_WITH_NULL", + [_LOAD_CONST_INLINE_WITH_NULL] = "_LOAD_CONST_INLINE_WITH_NULL", + [_LOAD_DEREF] = "_LOAD_DEREF", + [_LOAD_FAST] = "_LOAD_FAST", + [_LOAD_FAST_0] = "_LOAD_FAST_0", + [_LOAD_FAST_1] = "_LOAD_FAST_1", + [_LOAD_FAST_2] = "_LOAD_FAST_2", + [_LOAD_FAST_3] = "_LOAD_FAST_3", + [_LOAD_FAST_4] = "_LOAD_FAST_4", + [_LOAD_FAST_5] = "_LOAD_FAST_5", + [_LOAD_FAST_6] = "_LOAD_FAST_6", + [_LOAD_FAST_7] = "_LOAD_FAST_7", + [_LOAD_FAST_AND_CLEAR] = "_LOAD_FAST_AND_CLEAR", + [_LOAD_FAST_CHECK] = "_LOAD_FAST_CHECK", + [_LOAD_FAST_LOAD_FAST] = "_LOAD_FAST_LOAD_FAST", + [_LOAD_FROM_DICT_OR_DEREF] = "_LOAD_FROM_DICT_OR_DEREF", + [_LOAD_GLOBAL] = "_LOAD_GLOBAL", + [_LOAD_GLOBAL_BUILTINS] = "_LOAD_GLOBAL_BUILTINS", + [_LOAD_GLOBAL_MODULE] = "_LOAD_GLOBAL_MODULE", + [_LOAD_LOCALS] = "_LOAD_LOCALS", + [_LOAD_SUPER_ATTR_ATTR] = "_LOAD_SUPER_ATTR_ATTR", + [_LOAD_SUPER_ATTR_METHOD] = "_LOAD_SUPER_ATTR_METHOD", + [_MAKE_CELL] = "_MAKE_CELL", + [_MAKE_FUNCTION] = "_MAKE_FUNCTION", + [_MAP_ADD] = "_MAP_ADD", + [_MATCH_CLASS] = "_MATCH_CLASS", + [_MATCH_KEYS] = "_MATCH_KEYS", + [_MATCH_MAPPING] = "_MATCH_MAPPING", + [_MATCH_SEQUENCE] = "_MATCH_SEQUENCE", + [_NOP] = "_NOP", + [_POP_EXCEPT] = "_POP_EXCEPT", + [_POP_FRAME] = "_POP_FRAME", + [_POP_TOP] = "_POP_TOP", + [_POP_TOP_LOAD_CONST_INLINE_BORROW] = "_POP_TOP_LOAD_CONST_INLINE_BORROW", + [_PUSH_EXC_INFO] = "_PUSH_EXC_INFO", + [_PUSH_FRAME] = "_PUSH_FRAME", + [_PUSH_NULL] = "_PUSH_NULL", + [_PY_FRAME_GENERAL] = "_PY_FRAME_GENERAL", + [_REPLACE_WITH_TRUE] = "_REPLACE_WITH_TRUE", + [_RESUME_CHECK] = "_RESUME_CHECK", + [_RETURN_GENERATOR] = "_RETURN_GENERATOR", + [_SAVE_RETURN_OFFSET] = "_SAVE_RETURN_OFFSET", + [_SETUP_ANNOTATIONS] = "_SETUP_ANNOTATIONS", + [_SET_ADD] = "_SET_ADD", + [_SET_FUNCTION_ATTRIBUTE] = "_SET_FUNCTION_ATTRIBUTE", + [_SET_IP] = "_SET_IP", + [_SET_UPDATE] = "_SET_UPDATE", + [_START_EXECUTOR] = "_START_EXECUTOR", + [_STORE_ATTR] = "_STORE_ATTR", + [_STORE_ATTR_INSTANCE_VALUE] = "_STORE_ATTR_INSTANCE_VALUE", + [_STORE_ATTR_SLOT] = "_STORE_ATTR_SLOT", + [_STORE_DEREF] = "_STORE_DEREF", + [_STORE_FAST] = "_STORE_FAST", + [_STORE_FAST_0] = "_STORE_FAST_0", + [_STORE_FAST_1] = "_STORE_FAST_1", + [_STORE_FAST_2] = "_STORE_FAST_2", + [_STORE_FAST_3] = "_STORE_FAST_3", + [_STORE_FAST_4] = "_STORE_FAST_4", + [_STORE_FAST_5] = "_STORE_FAST_5", + [_STORE_FAST_6] = "_STORE_FAST_6", + [_STORE_FAST_7] = "_STORE_FAST_7", + [_STORE_FAST_LOAD_FAST] = "_STORE_FAST_LOAD_FAST", + [_STORE_FAST_STORE_FAST] = "_STORE_FAST_STORE_FAST", + [_STORE_GLOBAL] = "_STORE_GLOBAL", + [_STORE_NAME] = "_STORE_NAME", + [_STORE_SLICE] = "_STORE_SLICE", + [_STORE_SUBSCR] = "_STORE_SUBSCR", + [_STORE_SUBSCR_DICT] = "_STORE_SUBSCR_DICT", + [_STORE_SUBSCR_LIST_INT] = "_STORE_SUBSCR_LIST_INT", + [_SWAP] = "_SWAP", + [_TIER2_RESUME_CHECK] = "_TIER2_RESUME_CHECK", + [_TO_BOOL] = "_TO_BOOL", + [_TO_BOOL_BOOL] = "_TO_BOOL_BOOL", + [_TO_BOOL_INT] = "_TO_BOOL_INT", + [_TO_BOOL_LIST] = "_TO_BOOL_LIST", + [_TO_BOOL_NONE] = "_TO_BOOL_NONE", + [_TO_BOOL_STR] = "_TO_BOOL_STR", + [_UNARY_INVERT] = "_UNARY_INVERT", + [_UNARY_NEGATIVE] = "_UNARY_NEGATIVE", + [_UNARY_NOT] = "_UNARY_NOT", + [_UNPACK_EX] = "_UNPACK_EX", + [_UNPACK_SEQUENCE] = "_UNPACK_SEQUENCE", + [_UNPACK_SEQUENCE_LIST] = "_UNPACK_SEQUENCE_LIST", + [_UNPACK_SEQUENCE_TUPLE] = "_UNPACK_SEQUENCE_TUPLE", + [_UNPACK_SEQUENCE_TWO_TUPLE] = "_UNPACK_SEQUENCE_TWO_TUPLE", + [_WITH_EXCEPT_START] = "_WITH_EXCEPT_START", + [_YIELD_VALUE] = "_YIELD_VALUE", +}; +int _PyUop_num_popped(int opcode, int oparg) +{ + switch(opcode) { + case _NOP: + return 0; + case _RESUME_CHECK: + return 0; + case _LOAD_FAST_CHECK: + return 0; + case _LOAD_FAST_0: + return 0; + case _LOAD_FAST_1: + return 0; + case _LOAD_FAST_2: + return 0; + case _LOAD_FAST_3: + return 0; + case _LOAD_FAST_4: + return 0; + case _LOAD_FAST_5: + return 0; + case _LOAD_FAST_6: + return 0; + case _LOAD_FAST_7: + return 0; + case _LOAD_FAST: + return 0; + case _LOAD_FAST_AND_CLEAR: + return 0; + case _LOAD_FAST_LOAD_FAST: + return 0; + case _LOAD_CONST: + return 0; + case _STORE_FAST_0: + return 1; + case _STORE_FAST_1: + return 1; + case _STORE_FAST_2: + return 1; + case _STORE_FAST_3: + return 1; + case _STORE_FAST_4: + return 1; + case _STORE_FAST_5: + return 1; + case _STORE_FAST_6: + return 1; + case _STORE_FAST_7: + return 1; + case _STORE_FAST: + return 1; + case _STORE_FAST_LOAD_FAST: + return 1; + case _STORE_FAST_STORE_FAST: + return 2; + case _POP_TOP: + return 1; + case _PUSH_NULL: + return 0; + case _END_SEND: + return 2; + case _UNARY_NEGATIVE: + return 1; + case _UNARY_NOT: + return 1; + case _TO_BOOL: + return 1; + case _TO_BOOL_BOOL: + return 1; + case _TO_BOOL_INT: + return 1; + case _TO_BOOL_LIST: + return 1; + case _TO_BOOL_NONE: + return 1; + case _TO_BOOL_STR: + return 1; + case _REPLACE_WITH_TRUE: + return 1; + case _UNARY_INVERT: + return 1; + case _GUARD_BOTH_INT: + return 2; + case _GUARD_NOS_INT: + return 2; + case _GUARD_TOS_INT: + return 1; + case _BINARY_OP_MULTIPLY_INT: + return 2; + case _BINARY_OP_ADD_INT: + return 2; + case _BINARY_OP_SUBTRACT_INT: + return 2; + case _GUARD_BOTH_FLOAT: + return 2; + case _GUARD_NOS_FLOAT: + return 2; + case _GUARD_TOS_FLOAT: + return 1; + case _BINARY_OP_MULTIPLY_FLOAT: + return 2; + case _BINARY_OP_ADD_FLOAT: + return 2; + case _BINARY_OP_SUBTRACT_FLOAT: + return 2; + case _GUARD_BOTH_UNICODE: + return 2; + case _BINARY_OP_ADD_UNICODE: + return 2; + case _BINARY_SUBSCR: + return 2; + case _BINARY_SLICE: + return 3; + case _STORE_SLICE: + return 4; + case _BINARY_SUBSCR_LIST_INT: + return 2; + case _BINARY_SUBSCR_STR_INT: + return 2; + case _BINARY_SUBSCR_TUPLE_INT: + return 2; + case _BINARY_SUBSCR_DICT: + return 2; + case _LIST_APPEND: + return 2 + (oparg-1); + case _SET_ADD: + return 2 + (oparg-1); + case _STORE_SUBSCR: + return 3; + case _STORE_SUBSCR_LIST_INT: + return 3; + case _STORE_SUBSCR_DICT: + return 3; + case _DELETE_SUBSCR: + return 2; + case _CALL_INTRINSIC_1: + return 1; + case _CALL_INTRINSIC_2: + return 2; + case _POP_FRAME: + return 1; + case _GET_AITER: + return 1; + case _GET_ANEXT: + return 1; + case _GET_AWAITABLE: + return 1; + case _YIELD_VALUE: + return 1; + case _POP_EXCEPT: + return 1; + case _LOAD_ASSERTION_ERROR: + return 0; + case _LOAD_BUILD_CLASS: + return 0; + case _STORE_NAME: + return 1; + case _DELETE_NAME: + return 0; + case _UNPACK_SEQUENCE: + return 1; + case _UNPACK_SEQUENCE_TWO_TUPLE: + return 1; + case _UNPACK_SEQUENCE_TUPLE: + return 1; + case _UNPACK_SEQUENCE_LIST: + return 1; + case _UNPACK_EX: + return 1; + case _STORE_ATTR: + return 2; + case _DELETE_ATTR: + return 1; + case _STORE_GLOBAL: + return 1; + case _DELETE_GLOBAL: + return 0; + case _LOAD_LOCALS: + return 0; + case _LOAD_GLOBAL: + return 0; + case _GUARD_GLOBALS_VERSION: + return 0; + case _GUARD_BUILTINS_VERSION: + return 0; + case _LOAD_GLOBAL_MODULE: + return 0; + case _LOAD_GLOBAL_BUILTINS: + return 0; + case _DELETE_FAST: + return 0; + case _MAKE_CELL: + return 0; + case _DELETE_DEREF: + return 0; + case _LOAD_FROM_DICT_OR_DEREF: + return 1; + case _LOAD_DEREF: + return 0; + case _STORE_DEREF: + return 1; + case _COPY_FREE_VARS: + return 0; + case _BUILD_STRING: + return oparg; + case _BUILD_TUPLE: + return oparg; + case _BUILD_LIST: + return oparg; + case _LIST_EXTEND: + return 2 + (oparg-1); + case _SET_UPDATE: + return 2 + (oparg-1); + case _BUILD_MAP: + return oparg*2; + case _SETUP_ANNOTATIONS: + return 0; + case _BUILD_CONST_KEY_MAP: + return 1 + oparg; + case _DICT_UPDATE: + return 2 + (oparg - 1); + case _DICT_MERGE: + return 5 + (oparg - 1); + case _MAP_ADD: + return 3 + (oparg - 1); + case _LOAD_SUPER_ATTR_ATTR: + return 3; + case _LOAD_SUPER_ATTR_METHOD: + return 3; + case _LOAD_ATTR: + return 1; + case _GUARD_TYPE_VERSION: + return 1; + case _CHECK_MANAGED_OBJECT_HAS_VALUES: + return 1; + case _LOAD_ATTR_INSTANCE_VALUE_0: + return 1; + case _LOAD_ATTR_INSTANCE_VALUE_1: + return 1; + case _LOAD_ATTR_INSTANCE_VALUE: + return 1; + case _CHECK_ATTR_MODULE: + return 1; + case _LOAD_ATTR_MODULE: + return 1; + case _CHECK_ATTR_WITH_HINT: + return 1; + case _LOAD_ATTR_WITH_HINT: + return 1; + case _LOAD_ATTR_SLOT_0: + return 1; + case _LOAD_ATTR_SLOT_1: + return 1; + case _LOAD_ATTR_SLOT: + return 1; + case _CHECK_ATTR_CLASS: + return 1; + case _LOAD_ATTR_CLASS_0: + return 1; + case _LOAD_ATTR_CLASS_1: + return 1; + case _LOAD_ATTR_CLASS: + return 1; + case _GUARD_DORV_NO_DICT: + return 1; + case _STORE_ATTR_INSTANCE_VALUE: + return 2; + case _STORE_ATTR_SLOT: + return 2; + case _COMPARE_OP: + return 2; + case _COMPARE_OP_FLOAT: + return 2; + case _COMPARE_OP_INT: + return 2; + case _COMPARE_OP_STR: + return 2; + case _IS_OP: + return 2; + case _CONTAINS_OP: + return 2; + case _CONTAINS_OP_SET: + return 2; + case _CONTAINS_OP_DICT: + return 2; + case _CHECK_EG_MATCH: + return 2; + case _CHECK_EXC_MATCH: + return 2; + case _IS_NONE: + return 1; + case _GET_LEN: + return 1; + case _MATCH_CLASS: + return 3; + case _MATCH_MAPPING: + return 1; + case _MATCH_SEQUENCE: + return 1; + case _MATCH_KEYS: + return 2; + case _GET_ITER: + return 1; + case _GET_YIELD_FROM_ITER: + return 1; + case _FOR_ITER_TIER_TWO: + return 1; + case _ITER_CHECK_LIST: + return 1; + case _GUARD_NOT_EXHAUSTED_LIST: + return 1; + case _ITER_NEXT_LIST: + return 1; + case _ITER_CHECK_TUPLE: + return 1; + case _GUARD_NOT_EXHAUSTED_TUPLE: + return 1; + case _ITER_NEXT_TUPLE: + return 1; + case _ITER_CHECK_RANGE: + return 1; + case _GUARD_NOT_EXHAUSTED_RANGE: + return 1; + case _ITER_NEXT_RANGE: + return 1; + case _FOR_ITER_GEN_FRAME: + return 1; + case _WITH_EXCEPT_START: + return 4; + case _PUSH_EXC_INFO: + return 1; + case _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT: + return 1; + case _GUARD_KEYS_VERSION: + return 1; + case _LOAD_ATTR_METHOD_WITH_VALUES: + return 1; + case _LOAD_ATTR_METHOD_NO_DICT: + return 1; + case _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES: + return 1; + case _LOAD_ATTR_NONDESCRIPTOR_NO_DICT: + return 1; + case _CHECK_ATTR_METHOD_LAZY_DICT: + return 1; + case _LOAD_ATTR_METHOD_LAZY_DICT: + return 1; + case _CHECK_PERIODIC: + return 0; + case _PY_FRAME_GENERAL: + return 2 + oparg; + case _CHECK_FUNCTION_VERSION: + return 2 + oparg; + case _CHECK_METHOD_VERSION: + return 2 + oparg; + case _EXPAND_METHOD: + return 2 + oparg; + case _CHECK_IS_NOT_PY_CALLABLE: + return 2 + oparg; + case _CALL_NON_PY_GENERAL: + return 2 + oparg; + case _CHECK_CALL_BOUND_METHOD_EXACT_ARGS: + return 2 + oparg; + case _INIT_CALL_BOUND_METHOD_EXACT_ARGS: + return 2 + oparg; + case _CHECK_PEP_523: + return 0; + case _CHECK_FUNCTION_EXACT_ARGS: + return 2 + oparg; + case _CHECK_STACK_SPACE: + return 2 + oparg; + case _INIT_CALL_PY_EXACT_ARGS_0: + return 2 + oparg; + case _INIT_CALL_PY_EXACT_ARGS_1: + return 2 + oparg; + case _INIT_CALL_PY_EXACT_ARGS_2: + return 2 + oparg; + case _INIT_CALL_PY_EXACT_ARGS_3: + return 2 + oparg; + case _INIT_CALL_PY_EXACT_ARGS_4: + return 2 + oparg; + case _INIT_CALL_PY_EXACT_ARGS: + return 2 + oparg; + case _PUSH_FRAME: + return 1; + case _CALL_TYPE_1: + return 3; + case _CALL_STR_1: + return 3; + case _CALL_TUPLE_1: + return 3; + case _EXIT_INIT_CHECK: + return 1; + case _CALL_BUILTIN_CLASS: + return 2 + oparg; + case _CALL_BUILTIN_O: + return 2 + oparg; + case _CALL_BUILTIN_FAST: + return 2 + oparg; + case _CALL_BUILTIN_FAST_WITH_KEYWORDS: + return 2 + oparg; + case _CALL_LEN: + return 2 + oparg; + case _CALL_ISINSTANCE: + return 2 + oparg; + case _CALL_METHOD_DESCRIPTOR_O: + return 2 + oparg; + case _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: + return 2 + oparg; + case _CALL_METHOD_DESCRIPTOR_NOARGS: + return 2 + oparg; + case _CALL_METHOD_DESCRIPTOR_FAST: + return 2 + oparg; + case _MAKE_FUNCTION: + return 1; + case _SET_FUNCTION_ATTRIBUTE: + return 2; + case _RETURN_GENERATOR: + return 0; + case _BUILD_SLICE: + return 2 + ((oparg == 3) ? 1 : 0); + case _CONVERT_VALUE: + return 1; + case _FORMAT_SIMPLE: + return 1; + case _FORMAT_WITH_SPEC: + return 2; + case _COPY: + return 1 + (oparg-1); + case _BINARY_OP: + return 2; + case _SWAP: + return 2 + (oparg-2); + case _GUARD_IS_TRUE_POP: + return 1; + case _GUARD_IS_FALSE_POP: + return 1; + case _GUARD_IS_NONE_POP: + return 1; + case _GUARD_IS_NOT_NONE_POP: + return 1; + case _JUMP_TO_TOP: + return 0; + case _SET_IP: + return 0; + case _CHECK_STACK_SPACE_OPERAND: + return 0; + case _SAVE_RETURN_OFFSET: + return 0; + case _EXIT_TRACE: + return 0; + case _CHECK_VALIDITY: + return 0; + case _LOAD_CONST_INLINE: + return 0; + case _LOAD_CONST_INLINE_BORROW: + return 0; + case _POP_TOP_LOAD_CONST_INLINE_BORROW: + return 1; + case _LOAD_CONST_INLINE_WITH_NULL: + return 0; + case _LOAD_CONST_INLINE_BORROW_WITH_NULL: + return 0; + case _CHECK_FUNCTION: + return 0; + case _INTERNAL_INCREMENT_OPT_COUNTER: + return 1; + case _COLD_EXIT: + return 0; + case _DYNAMIC_EXIT: + return 0; + case _START_EXECUTOR: + return 0; + case _FATAL_ERROR: + return 0; + case _CHECK_VALIDITY_AND_SET_IP: + return 0; + case _DEOPT: + return 0; + case _ERROR_POP_N: + return oparg; + case _TIER2_RESUME_CHECK: + return 0; + default: + return -1; + } +} + +#endif // NEED_OPCODE_METADATA + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CORE_UOP_METADATA_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_warnings.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_warnings.h new file mode 100644 index 00000000..f9f65593 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_warnings.h @@ -0,0 +1,31 @@ +#ifndef Py_INTERNAL_WARNINGS_H +#define Py_INTERNAL_WARNINGS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +struct _warnings_runtime_state { + /* Both 'filters' and 'onceregistry' can be set in warnings.py; + get_warnings_attr() will reset these variables accordingly. */ + PyObject *filters; /* List */ + PyObject *once_registry; /* Dict */ + PyObject *default_action; /* String */ + PyMutex mutex; + long filters_version; +}; + +extern int _PyWarnings_InitState(PyInterpreterState *interp); + +extern PyObject* _PyWarnings_Init(void); + +extern void _PyErr_WarnUnawaitedCoroutine(PyObject *coro); +extern void _PyErr_WarnUnawaitedAgenMethod(PyAsyncGenObject *agen, PyObject *method); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_WARNINGS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/internal/pycore_weakref.h b/illumos-x86_64/usr/include/python3.13/internal/pycore_weakref.h new file mode 100644 index 00000000..ff1395ea --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/internal/pycore_weakref.h @@ -0,0 +1,133 @@ +#ifndef Py_INTERNAL_WEAKREF_H +#define Py_INTERNAL_WEAKREF_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION() +#include "pycore_lock.h" +#include "pycore_object.h" // _Py_REF_IS_MERGED() +#include "pycore_pyatomic_ft_wrappers.h" + +#ifdef Py_GIL_DISABLED + +#define WEAKREF_LIST_LOCK(obj) \ + _PyInterpreterState_GET() \ + ->weakref_locks[((uintptr_t)obj) % NUM_WEAKREF_LIST_LOCKS] + +// Lock using the referenced object +#define LOCK_WEAKREFS(obj) \ + PyMutex_LockFlags(&WEAKREF_LIST_LOCK(obj), _Py_LOCK_DONT_DETACH) +#define UNLOCK_WEAKREFS(obj) PyMutex_Unlock(&WEAKREF_LIST_LOCK(obj)) + +// Lock using a weakref +#define LOCK_WEAKREFS_FOR_WR(wr) \ + PyMutex_LockFlags(wr->weakrefs_lock, _Py_LOCK_DONT_DETACH) +#define UNLOCK_WEAKREFS_FOR_WR(wr) PyMutex_Unlock(wr->weakrefs_lock) + +#define FT_CLEAR_WEAKREFS(obj, weakref_list) \ + do { \ + assert(Py_REFCNT(obj) == 0); \ + PyObject_ClearWeakRefs(obj); \ + } while (0) + +#else + +#define LOCK_WEAKREFS(obj) +#define UNLOCK_WEAKREFS(obj) + +#define LOCK_WEAKREFS_FOR_WR(wr) +#define UNLOCK_WEAKREFS_FOR_WR(wr) + +#define FT_CLEAR_WEAKREFS(obj, weakref_list) \ + do { \ + assert(Py_REFCNT(obj) == 0); \ + if (weakref_list != NULL) { \ + PyObject_ClearWeakRefs(obj); \ + } \ + } while (0) + +#endif + +static inline int _is_dead(PyObject *obj) +{ + // Explanation for the Py_REFCNT() check: when a weakref's target is part + // of a long chain of deallocations which triggers the trashcan mechanism, + // clearing the weakrefs can be delayed long after the target's refcount + // has dropped to zero. In the meantime, code accessing the weakref will + // be able to "see" the target object even though it is supposed to be + // unreachable. See issue gh-60806. +#if defined(Py_GIL_DISABLED) + Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&obj->ob_ref_shared); + return shared == _Py_REF_SHARED(0, _Py_REF_MERGED); +#else + return (Py_REFCNT(obj) == 0); +#endif +} + +static inline PyObject* _PyWeakref_GET_REF(PyObject *ref_obj) +{ + assert(PyWeakref_Check(ref_obj)); + PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj); + + PyObject *obj = FT_ATOMIC_LOAD_PTR(ref->wr_object); + if (obj == Py_None) { + // clear_weakref() was called + return NULL; + } + + LOCK_WEAKREFS(obj); +#ifdef Py_GIL_DISABLED + if (ref->wr_object == Py_None) { + // clear_weakref() was called + UNLOCK_WEAKREFS(obj); + return NULL; + } +#endif + if (_Py_TryIncref(obj)) { + UNLOCK_WEAKREFS(obj); + return obj; + } + UNLOCK_WEAKREFS(obj); + return NULL; +} + +static inline int _PyWeakref_IS_DEAD(PyObject *ref_obj) +{ + assert(PyWeakref_Check(ref_obj)); + int ret = 0; + PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj); + PyObject *obj = FT_ATOMIC_LOAD_PTR(ref->wr_object); + if (obj == Py_None) { + // clear_weakref() was called + ret = 1; + } + else { + LOCK_WEAKREFS(obj); + // See _PyWeakref_GET_REF() for the rationale of this test +#ifdef Py_GIL_DISABLED + ret = (ref->wr_object == Py_None) || _is_dead(obj); +#else + ret = _is_dead(obj); +#endif + UNLOCK_WEAKREFS(obj); + } + return ret; +} + +extern Py_ssize_t _PyWeakref_GetWeakrefCount(PyObject *obj); + +// Clear all the weak references to obj but leave their callbacks uncalled and +// intact. +extern void _PyWeakref_ClearWeakRefsNoCallbacks(PyObject *obj); + +PyAPI_FUNC(int) _PyWeakref_IsDead(PyObject *weakref); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_WEAKREF_H */ diff --git a/illumos-x86_64/usr/include/python3.13/intrcheck.h b/illumos-x86_64/usr/include/python3.13/intrcheck.h new file mode 100644 index 00000000..1d1feee8 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/intrcheck.h @@ -0,0 +1,23 @@ +#ifndef Py_INTRCHECK_H +#define Py_INTRCHECK_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyOS_InterruptOccurred(void); + +#ifdef HAVE_FORK +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 +PyAPI_FUNC(void) PyOS_BeforeFork(void); +PyAPI_FUNC(void) PyOS_AfterFork_Parent(void); +PyAPI_FUNC(void) PyOS_AfterFork_Child(void); +#endif +#endif + +/* Deprecated, please use PyOS_AfterFork_Child() instead */ +Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyOS_AfterFork(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTRCHECK_H */ diff --git a/illumos-x86_64/usr/include/python3.13/iterobject.h b/illumos-x86_64/usr/include/python3.13/iterobject.h new file mode 100644 index 00000000..e69d0971 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/iterobject.h @@ -0,0 +1,24 @@ +#ifndef Py_ITEROBJECT_H +#define Py_ITEROBJECT_H +/* Iterators (the basic kind, over a sequence) */ +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PySeqIter_Type; +PyAPI_DATA(PyTypeObject) PyCallIter_Type; + +#define PySeqIter_Check(op) Py_IS_TYPE((op), &PySeqIter_Type) + +PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); + + +#define PyCallIter_Check(op) Py_IS_TYPE((op), &PyCallIter_Type) + +PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ITEROBJECT_H */ + diff --git a/illumos-x86_64/usr/include/python3.13/listobject.h b/illumos-x86_64/usr/include/python3.13/listobject.h new file mode 100644 index 00000000..e1e059b0 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/listobject.h @@ -0,0 +1,55 @@ +/* List object interface + + Another generally useful object type is a list of object pointers. + This is a mutable type: the list items can be changed, and items can be + added or removed. Out-of-range indices or non-list objects are ignored. + + WARNING: PyList_SetItem does not increment the new item's reference count, + but does decrement the reference count of the item it replaces, if not nil. + It does *decrement* the reference count if it is *not* inserted in the list. + Similarly, PyList_GetItem does not increment the returned item's reference + count. +*/ + +#ifndef Py_LISTOBJECT_H +#define Py_LISTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyList_Type; +PyAPI_DATA(PyTypeObject) PyListIter_Type; +PyAPI_DATA(PyTypeObject) PyListRevIter_Type; + +#define PyList_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) +#define PyList_CheckExact(op) Py_IS_TYPE((op), &PyList_Type) + +PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); +PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); + +PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(PyObject *) PyList_GetItemRef(PyObject *, Py_ssize_t); +#endif +PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); +PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); + +PyAPI_FUNC(int) PyList_Sort(PyObject *); +PyAPI_FUNC(int) PyList_Reverse(PyObject *); +PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_LISTOBJECT_H +# include "cpython/listobject.h" +# undef Py_CPYTHON_LISTOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LISTOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/lock.h b/illumos-x86_64/usr/include/python3.13/lock.h new file mode 100644 index 00000000..782b9dbc --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/lock.h @@ -0,0 +1,16 @@ +#ifndef Py_LOCK_H +#define Py_LOCK_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_LOCK_H +# include "cpython/lock.h" +# undef Py_CPYTHON_LOCK_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LOCK_H */ diff --git a/illumos-x86_64/usr/include/python3.13/longobject.h b/illumos-x86_64/usr/include/python3.13/longobject.h new file mode 100644 index 00000000..19104cd9 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/longobject.h @@ -0,0 +1,114 @@ +#ifndef Py_LONGOBJECT_H +#define Py_LONGOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Long (arbitrary precision) integer object interface */ + +// PyLong_Type is declared by object.h + +#define PyLong_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) +#define PyLong_CheckExact(op) Py_IS_TYPE((op), &PyLong_Type) + +PyAPI_FUNC(PyObject *) PyLong_FromLong(long); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); +PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t); +PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t); +PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); + +PyAPI_FUNC(long) PyLong_AsLong(PyObject *); +PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *); +PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); +PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *); +PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); +PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(int) PyLong_AsInt(PyObject *); +#endif + +PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); + +/* It may be useful in the future. I've added it in the PyInt -> PyLong + cleanup to keep the extra information. [CH] */ +#define PyLong_AS_LONG(op) PyLong_AsLong(op) + +/* Issue #1983: pid_t can be longer than a C long on some systems */ +#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT +#define _Py_PARSE_PID "i" +#define PyLong_FromPid PyLong_FromLong +# if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +# define PyLong_AsPid PyLong_AsInt +# elif SIZEOF_INT == SIZEOF_LONG +# define PyLong_AsPid PyLong_AsLong +# else +static inline int +PyLong_AsPid(PyObject *obj) +{ + int overflow; + long result = PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow || result > INT_MAX || result < INT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "Python int too large to convert to C int"); + return -1; + } + return (int)result; +} +# endif +#elif SIZEOF_PID_T == SIZEOF_LONG +#define _Py_PARSE_PID "l" +#define PyLong_FromPid PyLong_FromLong +#define PyLong_AsPid PyLong_AsLong +#elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG +#define _Py_PARSE_PID "L" +#define PyLong_FromPid PyLong_FromLongLong +#define PyLong_AsPid PyLong_AsLongLong +#else +#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)" +#endif /* SIZEOF_PID_T */ + +#if SIZEOF_VOID_P == SIZEOF_INT +# define _Py_PARSE_INTPTR "i" +# define _Py_PARSE_UINTPTR "I" +#elif SIZEOF_VOID_P == SIZEOF_LONG +# define _Py_PARSE_INTPTR "l" +# define _Py_PARSE_UINTPTR "k" +#elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG +# define _Py_PARSE_INTPTR "L" +# define _Py_PARSE_UINTPTR "K" +#else +# error "void* different in size from int, long and long long" +#endif /* SIZEOF_VOID_P */ + +PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); +PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); +PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); + +PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long); +PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *); +PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *); +PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *); +PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *); + +PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int); + +/* These aren't really part of the int object, but they're handy. The + functions are in Python/mystrtoul.c. + */ +PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int); +PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_LONGOBJECT_H +# include "cpython/longobject.h" +# undef Py_CPYTHON_LONGOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LONGOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/marshal.h b/illumos-x86_64/usr/include/python3.13/marshal.h new file mode 100644 index 00000000..f8b0de80 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/marshal.h @@ -0,0 +1,31 @@ + +/* Interface for marshal.c */ + +#ifndef Py_MARSHAL_H +#define Py_MARSHAL_H +#ifndef Py_LIMITED_API + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *, + Py_ssize_t); +PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int); + +#define Py_MARSHAL_VERSION 4 + +PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *); +PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *); + +PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int); +PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* Py_LIMITED_API */ +#endif /* !Py_MARSHAL_H */ diff --git a/illumos-x86_64/usr/include/python3.13/memoryobject.h b/illumos-x86_64/usr/include/python3.13/memoryobject.h new file mode 100644 index 00000000..2c9146aa --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/memoryobject.h @@ -0,0 +1,34 @@ +/* Memory view object. In Python this is available as "memoryview". */ + +#ifndef Py_MEMORYOBJECT_H +#define Py_MEMORYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyMemoryView_Type; + +#define PyMemoryView_Check(op) Py_IS_TYPE((op), &PyMemoryView_Type) + +PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject *) PyMemoryView_FromMemory(char *mem, Py_ssize_t size, + int flags); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 +PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(const Py_buffer *info); +#endif +PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, + int buffertype, + char order); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_MEMORYOBJECT_H +# include "cpython/memoryobject.h" +# undef Py_CPYTHON_MEMORYOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MEMORYOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/methodobject.h b/illumos-x86_64/usr/include/python3.13/methodobject.h new file mode 100644 index 00000000..39272815 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/methodobject.h @@ -0,0 +1,137 @@ + +/* Method object interface */ + +#ifndef Py_METHODOBJECT_H +#define Py_METHODOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* This is about the type 'builtin_function_or_method', + not Python methods in user-defined classes. See classobject.h + for the latter. */ + +PyAPI_DATA(PyTypeObject) PyCFunction_Type; + +#define PyCFunction_CheckExact(op) Py_IS_TYPE((op), &PyCFunction_Type) +#define PyCFunction_Check(op) PyObject_TypeCheck((op), &PyCFunction_Type) + +typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); +typedef PyObject *(*PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t); +typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, + PyObject *); +typedef PyObject *(*PyCFunctionFastWithKeywords) (PyObject *, + PyObject *const *, Py_ssize_t, + PyObject *); +typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, + size_t, PyObject *); + +// For backwards compatibility. `METH_FASTCALL` was added to the stable API in +// 3.10 alongside `_PyCFunctionFastWithKeywords` and `_PyCFunctionFast`. +// Note that the underscore-prefixed names were documented in public docs; +// people may be using them. +typedef PyCFunctionFast _PyCFunctionFast; +typedef PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords; + +// Cast an function to the PyCFunction type to use it with PyMethodDef. +// +// This macro can be used to prevent compiler warnings if the first parameter +// uses a different pointer type than PyObject* (ex: METH_VARARGS and METH_O +// calling conventions). +// +// The macro can also be used for METH_FASTCALL and METH_VARARGS|METH_KEYWORDS +// calling conventions to avoid compiler warnings because the function has more +// than 2 parameters. The macro first casts the function to the +// "void func(void)" type to prevent compiler warnings. +// +// If a function is declared with the METH_NOARGS calling convention, it must +// have 2 parameters. Since the second parameter is unused, Py_UNUSED() can be +// used to prevent a compiler warning. If the function has a single parameter, +// it triggers an undefined behavior when Python calls it with 2 parameters +// (bpo-33012). +#define _PyCFunction_CAST(func) \ + _Py_CAST(PyCFunction, _Py_CAST(void(*)(void), (func))) + +PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); +PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); +PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); + +struct PyMethodDef { + const char *ml_name; /* The name of the built-in function/method */ + PyCFunction ml_meth; /* The C function that implements it */ + int ml_flags; /* Combination of METH_xxx flags, which mostly + describe the args expected by the C func */ + const char *ml_doc; /* The __doc__ attribute, or NULL */ +}; + +/* PyCFunction_New is declared as a function for stable ABI (declaration is + * needed for e.g. GCC with -fvisibility=hidden), but redefined as a macro + * that calls PyCFunction_NewEx. */ +PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *); +#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL) + +/* PyCFunction_NewEx is similar: on 3.9+, this calls PyCMethod_New. */ +PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, + PyObject *); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 +#define PyCFunction_NewEx(ML, SELF, MOD) PyCMethod_New((ML), (SELF), (MOD), NULL) +PyAPI_FUNC(PyObject *) PyCMethod_New(PyMethodDef *, PyObject *, + PyObject *, PyTypeObject *); +#endif + + +/* Flag passed to newmethodobject */ +/* #define METH_OLDARGS 0x0000 -- unsupported now */ +#define METH_VARARGS 0x0001 +#define METH_KEYWORDS 0x0002 +/* METH_NOARGS and METH_O must not be combined with the flags above. */ +#define METH_NOARGS 0x0004 +#define METH_O 0x0008 + +/* METH_CLASS and METH_STATIC are a little different; these control + the construction of methods for a class. These cannot be used for + functions in modules. */ +#define METH_CLASS 0x0010 +#define METH_STATIC 0x0020 + +/* METH_COEXIST allows a method to be entered even though a slot has + already filled the entry. When defined, the flag allows a separate + method, "__contains__" for example, to coexist with a defined + slot like sq_contains. */ + +#define METH_COEXIST 0x0040 + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000 +# define METH_FASTCALL 0x0080 +#endif + +/* This bit is preserved for Stackless Python */ +#ifdef STACKLESS +# define METH_STACKLESS 0x0100 +#else +# define METH_STACKLESS 0x0000 +#endif + +/* METH_METHOD means the function stores an + * additional reference to the class that defines it; + * both self and class are passed to it. + * It uses PyCMethodObject instead of PyCFunctionObject. + * May not be combined with METH_NOARGS, METH_O, METH_CLASS or METH_STATIC. + */ + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 +#define METH_METHOD 0x0200 +#endif + + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_METHODOBJECT_H +# include "cpython/methodobject.h" +# undef Py_CPYTHON_METHODOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_METHODOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/modsupport.h b/illumos-x86_64/usr/include/python3.13/modsupport.h new file mode 100644 index 00000000..af995f56 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/modsupport.h @@ -0,0 +1,146 @@ +// Module support interface + +#ifndef Py_MODSUPPORT_H +#define Py_MODSUPPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); +PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...); +PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, + const char *, PY_CXX_CONST char * const *, ...); +PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); +PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, + const char *, PY_CXX_CONST char * const *, va_list); + +PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *); +PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); +PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); +PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000 +// Add an attribute with name 'name' and value 'obj' to the module 'mod. +// On success, return 0. +// On error, raise an exception and return -1. +PyAPI_FUNC(int) PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value); +#endif /* Py_LIMITED_API */ + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +// Similar to PyModule_AddObjectRef() but steal a reference to 'value'. +PyAPI_FUNC(int) PyModule_Add(PyObject *mod, const char *name, PyObject *value); +#endif /* Py_LIMITED_API */ + +// Similar to PyModule_AddObjectRef() and PyModule_Add() but steal +// a reference to 'value' on success and only on success. +// Errorprone. Should not be used in new code. +PyAPI_FUNC(int) PyModule_AddObject(PyObject *mod, const char *, PyObject *value); + +PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); +PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 +/* New in 3.9 */ +PyAPI_FUNC(int) PyModule_AddType(PyObject *module, PyTypeObject *type); +#endif /* Py_LIMITED_API */ + +#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant((m), #c, (c)) +#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant((m), #c, (c)) + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *); +PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *); +PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def); +#endif + +#define Py_CLEANUP_SUPPORTED 0x20000 + +#define PYTHON_API_VERSION 1013 +#define PYTHON_API_STRING "1013" +/* The API version is maintained (independently from the Python version) + so we can detect mismatches between the interpreter and dynamically + loaded modules. These are diagnosed by an error message but + the module is still loaded (because the mismatch can only be tested + after loading the module). The error message is intended to + explain the core dump a few seconds later. + + The symbol PYTHON_API_STRING defines the same value as a string + literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** + + Please add a line or two to the top of this log for each API + version change: + + 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths + + 19-Aug-2002 GvR 1012 Changes to string object struct for + interning changes, saving 3 bytes. + + 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side + + 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and + PyFrame_New(); Python 2.1a2 + + 14-Mar-2000 GvR 1009 Unicode API added + + 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) + + 3-Dec-1998 GvR 1008 Python 1.5.2b1 + + 18-Jan-1997 GvR 1007 string interning and other speedups + + 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( + + 30-Jul-1996 GvR Slice and ellipses syntax added + + 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) + + 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) + + 10-Jan-1995 GvR Renamed globals to new naming scheme + + 9-Jan-1995 GvR Initial version (incompatible with older API) +*/ + +/* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of + Python 3, it will stay at the value of 3; changes to the limited API + must be performed in a strictly backwards-compatible manner. */ +#define PYTHON_ABI_VERSION 3 +#define PYTHON_ABI_STRING "3" + +PyAPI_FUNC(PyObject *) PyModule_Create2(PyModuleDef*, int apiver); + +#ifdef Py_LIMITED_API +#define PyModule_Create(module) \ + PyModule_Create2((module), PYTHON_ABI_VERSION) +#else +#define PyModule_Create(module) \ + PyModule_Create2((module), PYTHON_API_VERSION) +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def, + PyObject *spec, + int module_api_version); + +#ifdef Py_LIMITED_API +#define PyModule_FromDefAndSpec(module, spec) \ + PyModule_FromDefAndSpec2((module), (spec), PYTHON_ABI_VERSION) +#else +#define PyModule_FromDefAndSpec(module, spec) \ + PyModule_FromDefAndSpec2((module), (spec), PYTHON_API_VERSION) +#endif /* Py_LIMITED_API */ + +#endif /* New in 3.5 */ + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_MODSUPPORT_H +# include "cpython/modsupport.h" +# undef Py_CPYTHON_MODSUPPORT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MODSUPPORT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/moduleobject.h b/illumos-x86_64/usr/include/python3.13/moduleobject.h new file mode 100644 index 00000000..2a17c891 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/moduleobject.h @@ -0,0 +1,122 @@ + +/* Module object interface */ + +#ifndef Py_MODULEOBJECT_H +#define Py_MODULEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyModule_Type; + +#define PyModule_Check(op) PyObject_TypeCheck((op), &PyModule_Type) +#define PyModule_CheckExact(op) Py_IS_TYPE((op), &PyModule_Type) + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject *) PyModule_NewObject( + PyObject *name + ); +#endif +PyAPI_FUNC(PyObject *) PyModule_New( + const char *name /* UTF-8 encoded string */ + ); +PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *); +#endif +PyAPI_FUNC(const char *) PyModule_GetName(PyObject *); +Py_DEPRECATED(3.2) PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *); +PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *); +PyAPI_FUNC(PyModuleDef*) PyModule_GetDef(PyObject*); +PyAPI_FUNC(void*) PyModule_GetState(PyObject*); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +PyAPI_FUNC(PyObject *) PyModuleDef_Init(PyModuleDef*); +PyAPI_DATA(PyTypeObject) PyModuleDef_Type; +#endif + +typedef struct PyModuleDef_Base { + PyObject_HEAD + /* The function used to re-initialize the module. + This is only set for legacy (single-phase init) extension modules + and only used for those that support multiple initializations + (m_size >= 0). + It is set by _PyImport_LoadDynamicModuleWithSpec() + and _imp.create_builtin(). */ + PyObject* (*m_init)(void); + /* The module's index into its interpreter's modules_by_index cache. + This is set for all extension modules but only used for legacy ones. + (See PyInterpreterState.modules_by_index for more info.) + It is set by PyModuleDef_Init(). */ + Py_ssize_t m_index; + /* A copy of the module's __dict__ after the first time it was loaded. + This is only set/used for legacy modules that do not support + multiple initializations. + It is set by fix_up_extension() in import.c. */ + PyObject* m_copy; +} PyModuleDef_Base; + +#define PyModuleDef_HEAD_INIT { \ + PyObject_HEAD_INIT(_Py_NULL) \ + _Py_NULL, /* m_init */ \ + 0, /* m_index */ \ + _Py_NULL, /* m_copy */ \ + } + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +struct PyModuleDef_Slot { + int slot; + void *value; +}; + +#define Py_mod_create 1 +#define Py_mod_exec 2 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 +# define Py_mod_multiple_interpreters 3 +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +# define Py_mod_gil 4 +#endif + + +#ifndef Py_LIMITED_API +#define _Py_mod_LAST_SLOT 4 +#endif + +#endif /* New in 3.5 */ + +/* for Py_mod_multiple_interpreters: */ +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 +# define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0) +# define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1) +# define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2) +#endif + +/* for Py_mod_gil: */ +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +# define Py_MOD_GIL_USED ((void *)0) +# define Py_MOD_GIL_NOT_USED ((void *)1) +#endif + +#if !defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED) +PyAPI_FUNC(int) PyUnstable_Module_SetGIL(PyObject *module, void *gil); +#endif + +struct PyModuleDef { + PyModuleDef_Base m_base; + const char* m_name; + const char* m_doc; + Py_ssize_t m_size; + PyMethodDef *m_methods; + PyModuleDef_Slot *m_slots; + traverseproc m_traverse; + inquiry m_clear; + freefunc m_free; +}; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MODULEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/monitoring.h b/illumos-x86_64/usr/include/python3.13/monitoring.h new file mode 100644 index 00000000..985f7f23 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/monitoring.h @@ -0,0 +1,18 @@ +#ifndef Py_MONITORING_H +#define Py_MONITORING_H +#ifdef __cplusplus +extern "C" { +#endif + +// There is currently no limited API for monitoring + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_MONITORING_H +# include "cpython/monitoring.h" +# undef Py_CPYTHON_MONITORING_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MONITORING_H */ diff --git a/illumos-x86_64/usr/include/python3.13/object.h b/illumos-x86_64/usr/include/python3.13/object.h new file mode 100644 index 00000000..0266d252 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/object.h @@ -0,0 +1,1275 @@ +#ifndef Py_OBJECT_H +#define Py_OBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Object and type object interface */ + +/* +Objects are structures allocated on the heap. Special rules apply to +the use of objects to ensure they are properly garbage-collected. +Objects are never allocated statically or on the stack; they must be +accessed through special macros and functions only. (Type objects are +exceptions to the first rule; the standard types are represented by +statically initialized type objects, although work on type/class unification +for Python 2.2 made it possible to have heap-allocated type objects too). + +An object has a 'reference count' that is increased or decreased when a +pointer to the object is copied or deleted; when the reference count +reaches zero there are no references to the object left and it can be +removed from the heap. + +An object has a 'type' that determines what it represents and what kind +of data it contains. An object's type is fixed when it is created. +Types themselves are represented as objects; an object contains a +pointer to the corresponding type object. The type itself has a type +pointer pointing to the object representing the type 'type', which +contains a pointer to itself!. + +Objects do not float around in memory; once allocated an object keeps +the same size and address. Objects that must hold variable-size data +can contain pointers to variable-size parts of the object. Not all +objects of the same type have the same size; but the size cannot change +after allocation. (These restrictions are made so a reference to an +object can be simply a pointer -- moving an object would require +updating all the pointers, and changing an object's size would require +moving it if there was another object right next to it.) + +Objects are always accessed through pointers of the type 'PyObject *'. +The type 'PyObject' is a structure that only contains the reference count +and the type pointer. The actual memory allocated for an object +contains other data that can only be accessed after casting the pointer +to a pointer to a longer structure type. This longer type must start +with the reference count and type fields; the macro PyObject_HEAD should be +used for this (to accommodate for future changes). The implementation +of a particular object type can cast the object pointer to the proper +type and back. + +A standard interface exists for objects that contain an array of items +whose size is determined when the object is allocated. +*/ + +/* Py_DEBUG implies Py_REF_DEBUG. */ +#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG) +# define Py_REF_DEBUG +#endif + +/* PyObject_HEAD defines the initial segment of every PyObject. */ +#define PyObject_HEAD PyObject ob_base; + +/* +Immortalization: + +The following indicates the immortalization strategy depending on the amount +of available bits in the reference count field. All strategies are backwards +compatible but the specific reference count value or immortalization check +might change depending on the specializations for the underlying system. + +Proper deallocation of immortal instances requires distinguishing between +statically allocated immortal instances vs those promoted by the runtime to be +immortal. The latter should be the only instances that require +cleanup during runtime finalization. +*/ + +#if SIZEOF_VOID_P > 4 +/* +In 64+ bit systems, an object will be marked as immortal by setting all of the +lower 32 bits of the reference count field, which is equal to: 0xFFFFFFFF + +Using the lower 32 bits makes the value backwards compatible by allowing +C-Extensions without the updated checks in Py_INCREF and Py_DECREF to safely +increase and decrease the objects reference count. The object would lose its +immortality, but the execution would still be correct. + +Reference count increases will use saturated arithmetic, taking advantage of +having all the lower 32 bits set, which will avoid the reference count to go +beyond the refcount limit. Immortality checks for reference count decreases will +be done by checking the bit sign flag in the lower 32 bits. +*/ +#define _Py_IMMORTAL_REFCNT _Py_CAST(Py_ssize_t, UINT_MAX) + +#else +/* +In 32 bit systems, an object will be marked as immortal by setting all of the +lower 30 bits of the reference count field, which is equal to: 0x3FFFFFFF + +Using the lower 30 bits makes the value backwards compatible by allowing +C-Extensions without the updated checks in Py_INCREF and Py_DECREF to safely +increase and decrease the objects reference count. The object would lose its +immortality, but the execution would still be correct. + +Reference count increases and decreases will first go through an immortality +check by comparing the reference count field to the immortality reference count. +*/ +#define _Py_IMMORTAL_REFCNT _Py_CAST(Py_ssize_t, UINT_MAX >> 2) +#endif + +// Py_GIL_DISABLED builds indicate immortal objects using `ob_ref_local`, which is +// always 32-bits. +#ifdef Py_GIL_DISABLED +#define _Py_IMMORTAL_REFCNT_LOCAL UINT32_MAX +#endif + +// Kept for backward compatibility. It was needed by Py_TRACE_REFS build. +#define _PyObject_EXTRA_INIT + +/* Make all uses of PyObject_HEAD_INIT immortal. + * + * Statically allocated objects might be shared between + * interpreters, so must be marked as immortal. + */ +#if defined(Py_GIL_DISABLED) +#define PyObject_HEAD_INIT(type) \ + { \ + 0, \ + 0, \ + { 0 }, \ + 0, \ + _Py_IMMORTAL_REFCNT_LOCAL, \ + 0, \ + (type), \ + }, +#else +#define PyObject_HEAD_INIT(type) \ + { \ + { _Py_IMMORTAL_REFCNT }, \ + (type) \ + }, +#endif + +#define PyVarObject_HEAD_INIT(type, size) \ + { \ + PyObject_HEAD_INIT(type) \ + (size) \ + }, + +/* PyObject_VAR_HEAD defines the initial segment of all variable-size + * container objects. These end with a declaration of an array with 1 + * element, but enough space is malloc'ed so that the array actually + * has room for ob_size elements. Note that ob_size is an element count, + * not necessarily a byte count. + */ +#define PyObject_VAR_HEAD PyVarObject ob_base; +#define Py_INVALID_SIZE (Py_ssize_t)-1 + +/* Nothing is actually declared to be a PyObject, but every pointer to + * a Python object can be cast to a PyObject*. This is inheritance built + * by hand. Similarly every pointer to a variable-size Python object can, + * in addition, be cast to PyVarObject*. + */ +#ifndef Py_GIL_DISABLED +struct _object { +#if (defined(__GNUC__) || defined(__clang__)) \ + && !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) + // On C99 and older, anonymous union is a GCC and clang extension + __extension__ +#endif +#ifdef _MSC_VER + // Ignore MSC warning C4201: "nonstandard extension used: + // nameless struct/union" + __pragma(warning(push)) + __pragma(warning(disable: 4201)) +#endif + union { + Py_ssize_t ob_refcnt; +#if SIZEOF_VOID_P > 4 + PY_UINT32_T ob_refcnt_split[2]; +#endif + }; +#ifdef _MSC_VER + __pragma(warning(pop)) +#endif + + PyTypeObject *ob_type; +}; +#else +// Objects that are not owned by any thread use a thread id (tid) of zero. +// This includes both immortal objects and objects whose reference count +// fields have been merged. +#define _Py_UNOWNED_TID 0 + +// The shared reference count uses the two least-significant bits to store +// flags. The remaining bits are used to store the reference count. +#define _Py_REF_SHARED_SHIFT 2 +#define _Py_REF_SHARED_FLAG_MASK 0x3 + +// The shared flags are initialized to zero. +#define _Py_REF_SHARED_INIT 0x0 +#define _Py_REF_MAYBE_WEAKREF 0x1 +#define _Py_REF_QUEUED 0x2 +#define _Py_REF_MERGED 0x3 + +// Create a shared field from a refcnt and desired flags +#define _Py_REF_SHARED(refcnt, flags) (((refcnt) << _Py_REF_SHARED_SHIFT) + (flags)) + +struct _object { + // ob_tid stores the thread id (or zero). It is also used by the GC and the + // trashcan mechanism as a linked list pointer and by the GC to store the + // computed "gc_refs" refcount. + uintptr_t ob_tid; + uint16_t _padding; + PyMutex ob_mutex; // per-object lock + uint8_t ob_gc_bits; // gc-related state + uint32_t ob_ref_local; // local reference count + Py_ssize_t ob_ref_shared; // shared (atomic) reference count + PyTypeObject *ob_type; +}; +#endif + +/* Cast argument to PyObject* type. */ +#define _PyObject_CAST(op) _Py_CAST(PyObject*, (op)) + +typedef struct { + PyObject ob_base; + Py_ssize_t ob_size; /* Number of items in variable part */ +} PyVarObject; + +/* Cast argument to PyVarObject* type. */ +#define _PyVarObject_CAST(op) _Py_CAST(PyVarObject*, (op)) + + +// Test if the 'x' object is the 'y' object, the same as "x is y" in Python. +PyAPI_FUNC(int) Py_Is(PyObject *x, PyObject *y); +#define Py_Is(x, y) ((x) == (y)) + +#if defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) +PyAPI_FUNC(uintptr_t) _Py_GetThreadLocal_Addr(void); + +static inline uintptr_t +_Py_ThreadId(void) +{ + uintptr_t tid; +#if defined(_MSC_VER) && defined(_M_X64) + tid = __readgsqword(48); +#elif defined(_MSC_VER) && defined(_M_IX86) + tid = __readfsdword(24); +#elif defined(_MSC_VER) && defined(_M_ARM64) + tid = __getReg(18); +#elif defined(__MINGW32__) && defined(_M_X64) + tid = __readgsqword(48); +#elif defined(__MINGW32__) && defined(_M_IX86) + tid = __readfsdword(24); +#elif defined(__MINGW32__) && defined(_M_ARM64) + tid = __getReg(18); +#elif defined(__i386__) + __asm__("movl %%gs:0, %0" : "=r" (tid)); // 32-bit always uses GS +#elif defined(__MACH__) && defined(__x86_64__) + __asm__("movq %%gs:0, %0" : "=r" (tid)); // x86_64 macOSX uses GS +#elif defined(__x86_64__) + __asm__("movq %%fs:0, %0" : "=r" (tid)); // x86_64 Linux, BSD uses FS +#elif defined(__arm__) && __ARM_ARCH >= 7 + __asm__ ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tid)); +#elif defined(__aarch64__) && defined(__APPLE__) + __asm__ ("mrs %0, tpidrro_el0" : "=r" (tid)); +#elif defined(__aarch64__) + __asm__ ("mrs %0, tpidr_el0" : "=r" (tid)); +#elif defined(__powerpc64__) + #if defined(__clang__) && _Py__has_builtin(__builtin_thread_pointer) + tid = (uintptr_t)__builtin_thread_pointer(); + #else + // r13 is reserved for use as system thread ID by the Power 64-bit ABI. + register uintptr_t tp __asm__ ("r13"); + __asm__("" : "=r" (tp)); + tid = tp; + #endif +#elif defined(__powerpc__) + #if defined(__clang__) && _Py__has_builtin(__builtin_thread_pointer) + tid = (uintptr_t)__builtin_thread_pointer(); + #else + // r2 is reserved for use as system thread ID by the Power 32-bit ABI. + register uintptr_t tp __asm__ ("r2"); + __asm__ ("" : "=r" (tp)); + tid = tp; + #endif +#elif defined(__s390__) && defined(__GNUC__) + // Both GCC and Clang have supported __builtin_thread_pointer + // for s390 from long time ago. + tid = (uintptr_t)__builtin_thread_pointer(); +#elif defined(__riscv) + #if defined(__clang__) && _Py__has_builtin(__builtin_thread_pointer) + tid = (uintptr_t)__builtin_thread_pointer(); + #else + // tp is Thread Pointer provided by the RISC-V ABI. + __asm__ ("mv %0, tp" : "=r" (tid)); + #endif +#else + // Fallback to a portable implementation if we do not have a faster + // platform-specific implementation. + tid = _Py_GetThreadLocal_Addr(); +#endif + return tid; +} + +static inline Py_ALWAYS_INLINE int +_Py_IsOwnedByCurrentThread(PyObject *ob) +{ +#ifdef _Py_THREAD_SANITIZER + return _Py_atomic_load_uintptr_relaxed(&ob->ob_tid) == _Py_ThreadId(); +#else + return ob->ob_tid == _Py_ThreadId(); +#endif +} +#endif + +static inline Py_ssize_t Py_REFCNT(PyObject *ob) { +#if !defined(Py_GIL_DISABLED) + return ob->ob_refcnt; +#else + uint32_t local = _Py_atomic_load_uint32_relaxed(&ob->ob_ref_local); + if (local == _Py_IMMORTAL_REFCNT_LOCAL) { + return _Py_IMMORTAL_REFCNT; + } + Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&ob->ob_ref_shared); + return _Py_STATIC_CAST(Py_ssize_t, local) + + Py_ARITHMETIC_RIGHT_SHIFT(Py_ssize_t, shared, _Py_REF_SHARED_SHIFT); +#endif +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_REFCNT(ob) Py_REFCNT(_PyObject_CAST(ob)) +#endif + + +// bpo-39573: The Py_SET_TYPE() function must be used to set an object type. +static inline PyTypeObject* Py_TYPE(PyObject *ob) { + return ob->ob_type; +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_TYPE(ob) Py_TYPE(_PyObject_CAST(ob)) +#endif + +PyAPI_DATA(PyTypeObject) PyLong_Type; +PyAPI_DATA(PyTypeObject) PyBool_Type; + +// bpo-39573: The Py_SET_SIZE() function must be used to set an object size. +static inline Py_ssize_t Py_SIZE(PyObject *ob) { + assert(ob->ob_type != &PyLong_Type); + assert(ob->ob_type != &PyBool_Type); + return _PyVarObject_CAST(ob)->ob_size; +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_SIZE(ob) Py_SIZE(_PyObject_CAST(ob)) +#endif + +static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op) +{ +#if defined(Py_GIL_DISABLED) + return (_Py_atomic_load_uint32_relaxed(&op->ob_ref_local) == + _Py_IMMORTAL_REFCNT_LOCAL); +#elif SIZEOF_VOID_P > 4 + return (_Py_CAST(PY_INT32_T, op->ob_refcnt) < 0); +#else + return (op->ob_refcnt == _Py_IMMORTAL_REFCNT); +#endif +} +#define _Py_IsImmortal(op) _Py_IsImmortal(_PyObject_CAST(op)) + +static inline int Py_IS_TYPE(PyObject *ob, PyTypeObject *type) { + return Py_TYPE(ob) == type; +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_IS_TYPE(ob, type) Py_IS_TYPE(_PyObject_CAST(ob), (type)) +#endif + + +// Py_SET_REFCNT() implementation for stable ABI +PyAPI_FUNC(void) _Py_SetRefcnt(PyObject *ob, Py_ssize_t refcnt); + +static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) { +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030d0000 + // Stable ABI implements Py_SET_REFCNT() as a function call + // on limited C API version 3.13 and newer. + _Py_SetRefcnt(ob, refcnt); +#else + // This immortal check is for code that is unaware of immortal objects. + // The runtime tracks these objects and we should avoid as much + // as possible having extensions inadvertently change the refcnt + // of an immortalized object. + if (_Py_IsImmortal(ob)) { + return; + } + +#ifndef Py_GIL_DISABLED + ob->ob_refcnt = refcnt; +#else + if (_Py_IsOwnedByCurrentThread(ob)) { + if ((size_t)refcnt > (size_t)UINT32_MAX) { + // On overflow, make the object immortal + ob->ob_tid = _Py_UNOWNED_TID; + ob->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL; + ob->ob_ref_shared = 0; + } + else { + // Set local refcount to desired refcount and shared refcount + // to zero, but preserve the shared refcount flags. + ob->ob_ref_local = _Py_STATIC_CAST(uint32_t, refcnt); + ob->ob_ref_shared &= _Py_REF_SHARED_FLAG_MASK; + } + } + else { + // Set local refcount to zero and shared refcount to desired refcount. + // Mark the object as merged. + ob->ob_tid = _Py_UNOWNED_TID; + ob->ob_ref_local = 0; + ob->ob_ref_shared = _Py_REF_SHARED(refcnt, _Py_REF_MERGED); + } +#endif // Py_GIL_DISABLED +#endif // Py_LIMITED_API+0 < 0x030d0000 +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_SET_REFCNT(ob, refcnt) Py_SET_REFCNT(_PyObject_CAST(ob), (refcnt)) +#endif + + +static inline void Py_SET_TYPE(PyObject *ob, PyTypeObject *type) { + ob->ob_type = type; +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_SET_TYPE(ob, type) Py_SET_TYPE(_PyObject_CAST(ob), type) +#endif + +static inline void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) { + assert(ob->ob_base.ob_type != &PyLong_Type); + assert(ob->ob_base.ob_type != &PyBool_Type); +#ifdef Py_GIL_DISABLED + _Py_atomic_store_ssize_relaxed(&ob->ob_size, size); +#else + ob->ob_size = size; +#endif +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_SET_SIZE(ob, size) Py_SET_SIZE(_PyVarObject_CAST(ob), (size)) +#endif + + +/* +Type objects contain a string containing the type name (to help somewhat +in debugging), the allocation parameters (see PyObject_New() and +PyObject_NewVar()), +and methods for accessing objects of the type. Methods are optional, a +nil pointer meaning that particular kind of access is not available for +this type. The Py_DECREF() macro uses the tp_dealloc method without +checking for a nil pointer; it should always be implemented except if +the implementation can guarantee that the reference count will never +reach zero (e.g., for statically allocated type objects). + +NB: the methods for certain type groups are now contained in separate +method blocks. +*/ + +typedef PyObject * (*unaryfunc)(PyObject *); +typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); +typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); +typedef int (*inquiry)(PyObject *); +typedef Py_ssize_t (*lenfunc)(PyObject *); +typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); +typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); +typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); +typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); +typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); + +typedef int (*objobjproc)(PyObject *, PyObject *); +typedef int (*visitproc)(PyObject *, void *); +typedef int (*traverseproc)(PyObject *, visitproc, void *); + + +typedef void (*freefunc)(void *); +typedef void (*destructor)(PyObject *); +typedef PyObject *(*getattrfunc)(PyObject *, char *); +typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); +typedef int (*setattrfunc)(PyObject *, char *, PyObject *); +typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); +typedef PyObject *(*reprfunc)(PyObject *); +typedef Py_hash_t (*hashfunc)(PyObject *); +typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); +typedef PyObject *(*getiterfunc) (PyObject *); +typedef PyObject *(*iternextfunc) (PyObject *); +typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); +typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); +typedef int (*initproc)(PyObject *, PyObject *, PyObject *); +typedef PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *); +typedef PyObject *(*allocfunc)(PyTypeObject *, Py_ssize_t); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 // 3.12 +typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args, + size_t nargsf, PyObject *kwnames); +#endif + +typedef struct{ + int slot; /* slot id, see below */ + void *pfunc; /* function pointer */ +} PyType_Slot; + +typedef struct{ + const char* name; + int basicsize; + int itemsize; + unsigned int flags; + PyType_Slot *slots; /* terminated by slot==0. */ +} PyType_Spec; + +PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject*) PyType_FromSpecWithBases(PyType_Spec*, PyObject*); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000 +PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 +PyAPI_FUNC(PyObject*) PyType_FromModuleAndSpec(PyObject *, PyType_Spec *, PyObject *); +PyAPI_FUNC(PyObject *) PyType_GetModule(PyTypeObject *); +PyAPI_FUNC(void *) PyType_GetModuleState(PyTypeObject *); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000 +PyAPI_FUNC(PyObject *) PyType_GetName(PyTypeObject *); +PyAPI_FUNC(PyObject *) PyType_GetQualName(PyTypeObject *); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +PyAPI_FUNC(PyObject *) PyType_GetFullyQualifiedName(PyTypeObject *type); +PyAPI_FUNC(PyObject *) PyType_GetModuleName(PyTypeObject *type); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +PyAPI_FUNC(PyObject *) PyType_FromMetaclass(PyTypeObject*, PyObject*, PyType_Spec*, PyObject*); +PyAPI_FUNC(void *) PyObject_GetTypeData(PyObject *obj, PyTypeObject *cls); +PyAPI_FUNC(Py_ssize_t) PyType_GetTypeDataSize(PyTypeObject *cls); +#endif + +/* Generic type check */ +PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); + +static inline int PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) { + return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type); +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define PyObject_TypeCheck(ob, type) PyObject_TypeCheck(_PyObject_CAST(ob), (type)) +#endif + +PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */ +PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */ +PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */ + +PyAPI_FUNC(unsigned long) PyType_GetFlags(PyTypeObject*); + +PyAPI_FUNC(int) PyType_Ready(PyTypeObject *); +PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *, + PyObject *, PyObject *); +PyAPI_FUNC(unsigned int) PyType_ClearCache(void); +PyAPI_FUNC(void) PyType_Modified(PyTypeObject *); + +/* Generic operations on objects */ +PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_Bytes(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); +PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); +PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *); +PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); +PyAPI_FUNC(int) PyObject_DelAttrString(PyObject *v, const char *name); +PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); +PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(int) PyObject_GetOptionalAttr(PyObject *, PyObject *, PyObject **); +PyAPI_FUNC(int) PyObject_GetOptionalAttrString(PyObject *, const char *, PyObject **); +#endif +PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_DelAttr(PyObject *v, PyObject *name); +PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(int) PyObject_HasAttrWithError(PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_HasAttrStringWithError(PyObject *, const char *); +#endif +PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, PyObject *, PyObject *); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(int) PyObject_GenericSetDict(PyObject *, PyObject *, void *); +#endif +PyAPI_FUNC(Py_hash_t) PyObject_Hash(PyObject *); +PyAPI_FUNC(Py_hash_t) PyObject_HashNotImplemented(PyObject *); +PyAPI_FUNC(int) PyObject_IsTrue(PyObject *); +PyAPI_FUNC(int) PyObject_Not(PyObject *); +PyAPI_FUNC(int) PyCallable_Check(PyObject *); +PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *); + +/* PyObject_Dir(obj) acts like Python builtins.dir(obj), returning a + list of strings. PyObject_Dir(NULL) is like builtins.dir(), + returning the names of the current locals. In this case, if there are + no current locals, NULL is returned, and PyErr_Occurred() is false. +*/ +PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *); + +/* Helpers for printing recursive container types */ +PyAPI_FUNC(int) Py_ReprEnter(PyObject *); +PyAPI_FUNC(void) Py_ReprLeave(PyObject *); + +/* Flag bits for printing: */ +#define Py_PRINT_RAW 1 /* No string quotes etc. */ + +/* +Type flags (tp_flags) + +These flags are used to change expected features and behavior for a +particular type. + +Arbitration of the flag bit positions will need to be coordinated among +all extension writers who publicly release their extensions (this will +be fewer than you might expect!). + +Most flags were removed as of Python 3.0 to make room for new flags. (Some +flags are not for backwards compatibility but to indicate the presence of an +optional feature; these flags remain of course.) + +Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value. + +Code can use PyType_HasFeature(type_ob, flag_value) to test whether the +given type object has a specified feature. +*/ + +#ifndef Py_LIMITED_API + +/* Track types initialized using _PyStaticType_InitBuiltin(). */ +#define _Py_TPFLAGS_STATIC_BUILTIN (1 << 1) + +/* The values array is placed inline directly after the rest of + * the object. Implies Py_TPFLAGS_HAVE_GC. + */ +#define Py_TPFLAGS_INLINE_VALUES (1 << 2) + +/* Placement of weakref pointers are managed by the VM, not by the type. + * The VM will automatically set tp_weaklistoffset. + */ +#define Py_TPFLAGS_MANAGED_WEAKREF (1 << 3) + +/* Placement of dict (and values) pointers are managed by the VM, not by the type. + * The VM will automatically set tp_dictoffset. Implies Py_TPFLAGS_HAVE_GC. + */ +#define Py_TPFLAGS_MANAGED_DICT (1 << 4) + +#define Py_TPFLAGS_PREHEADER (Py_TPFLAGS_MANAGED_WEAKREF | Py_TPFLAGS_MANAGED_DICT) + +/* Set if instances of the type object are treated as sequences for pattern matching */ +#define Py_TPFLAGS_SEQUENCE (1 << 5) +/* Set if instances of the type object are treated as mappings for pattern matching */ +#define Py_TPFLAGS_MAPPING (1 << 6) +#endif + +/* Disallow creating instances of the type: set tp_new to NULL and don't create + * the "__new__" key in the type dictionary. */ +#define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7) + +/* Set if the type object is immutable: type attributes cannot be set nor deleted */ +#define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8) + +/* Set if the type object is dynamically allocated */ +#define Py_TPFLAGS_HEAPTYPE (1UL << 9) + +/* Set if the type allows subclassing */ +#define Py_TPFLAGS_BASETYPE (1UL << 10) + +/* Set if the type implements the vectorcall protocol (PEP 590) */ +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +#define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11) +#ifndef Py_LIMITED_API +// Backwards compatibility alias for API that was provisional in Python 3.8 +#define _Py_TPFLAGS_HAVE_VECTORCALL Py_TPFLAGS_HAVE_VECTORCALL +#endif +#endif + +/* Set if the type is 'ready' -- fully initialized */ +#define Py_TPFLAGS_READY (1UL << 12) + +/* Set while the type is being 'readied', to prevent recursive ready calls */ +#define Py_TPFLAGS_READYING (1UL << 13) + +/* Objects support garbage collection (see objimpl.h) */ +#define Py_TPFLAGS_HAVE_GC (1UL << 14) + +/* These two bits are preserved for Stackless Python, next after this is 17 */ +#ifdef STACKLESS +#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3UL << 15) +#else +#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 +#endif + +/* Objects behave like an unbound method */ +#define Py_TPFLAGS_METHOD_DESCRIPTOR (1UL << 17) + +/* Unused. Legacy flag */ +#define Py_TPFLAGS_VALID_VERSION_TAG (1UL << 19) + +/* Type is abstract and cannot be instantiated */ +#define Py_TPFLAGS_IS_ABSTRACT (1UL << 20) + +// This undocumented flag gives certain built-ins their unique pattern-matching +// behavior, which allows a single positional subpattern to match against the +// subject itself (rather than a mapped attribute on it): +#define _Py_TPFLAGS_MATCH_SELF (1UL << 22) + +/* Items (ob_size*tp_itemsize) are found at the end of an instance's memory */ +#define Py_TPFLAGS_ITEMS_AT_END (1UL << 23) + +/* These flags are used to determine if a type is a subclass. */ +#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) +#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) +#define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26) +#define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27) +#define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28) +#define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29) +#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30) +#define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31) + +#define Py_TPFLAGS_DEFAULT ( \ + Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ + 0) + +/* NOTE: Some of the following flags reuse lower bits (removed as part of the + * Python 3.0 transition). */ + +/* The following flags are kept for compatibility; in previous + * versions they indicated presence of newer tp_* fields on the + * type struct. + * Starting with 3.8, binary compatibility of C extensions across + * feature releases of Python is not supported anymore (except when + * using the stable ABI, in which all classes are created dynamically, + * using the interpreter's memory layout.) + * Note that older extensions using the stable ABI set these flags, + * so the bits must not be repurposed. + */ +#define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0) +#define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18) + + +/* +The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement +reference counts. Py_DECREF calls the object's deallocator function when +the refcount falls to 0; for +objects that don't contain references to other objects or heap memory +this can be the standard function free(). Both macros can be used +wherever a void expression is allowed. The argument must not be a +NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead. +The macro _Py_NewReference(op) initialize reference counts to 1, and +in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional +bookkeeping appropriate to the special build. + +We assume that the reference count field can never overflow; this can +be proven when the size of the field is the same as the pointer size, so +we ignore the possibility. Provided a C int is at least 32 bits (which +is implicitly assumed in many parts of this code), that's enough for +about 2**31 references to an object. + +XXX The following became out of date in Python 2.2, but I'm not sure +XXX what the full truth is now. Certainly, heap-allocated type objects +XXX can and should be deallocated. +Type objects should never be deallocated; the type pointer in an object +is not considered to be a reference to the type object, to save +complications in the deallocation function. (This is actually a +decision that's up to the implementer of each new type so if you want, +you can count such references to the type object.) +*/ + +#if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API) +PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno, + PyObject *op); +PyAPI_FUNC(void) _Py_INCREF_IncRefTotal(void); +PyAPI_FUNC(void) _Py_DECREF_DecRefTotal(void); +#endif // Py_REF_DEBUG && !Py_LIMITED_API + +PyAPI_FUNC(void) _Py_Dealloc(PyObject *); + +/* +These are provided as conveniences to Python runtime embedders, so that +they can have object code that is not dependent on Python compilation flags. +*/ +PyAPI_FUNC(void) Py_IncRef(PyObject *); +PyAPI_FUNC(void) Py_DecRef(PyObject *); + +// Similar to Py_IncRef() and Py_DecRef() but the argument must be non-NULL. +// Private functions used by Py_INCREF() and Py_DECREF(). +PyAPI_FUNC(void) _Py_IncRef(PyObject *); +PyAPI_FUNC(void) _Py_DecRef(PyObject *); + +static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) +{ +#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) + // Stable ABI implements Py_INCREF() as a function call on limited C API + // version 3.12 and newer, and on Python built in debug mode. _Py_IncRef() + // was added to Python 3.10.0a7, use Py_IncRef() on older Python versions. + // Py_IncRef() accepts NULL whereas _Py_IncRef() doesn't. +# if Py_LIMITED_API+0 >= 0x030a00A7 + _Py_IncRef(op); +# else + Py_IncRef(op); +# endif +#else + // Non-limited C API and limited C API for Python 3.9 and older access + // directly PyObject.ob_refcnt. +#if defined(Py_GIL_DISABLED) + uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local); + uint32_t new_local = local + 1; + if (new_local == 0) { + // local is equal to _Py_IMMORTAL_REFCNT: do nothing + return; + } + if (_Py_IsOwnedByCurrentThread(op)) { + _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, new_local); + } + else { + _Py_atomic_add_ssize(&op->ob_ref_shared, (1 << _Py_REF_SHARED_SHIFT)); + } +#elif SIZEOF_VOID_P > 4 + // Portable saturated add, branching on the carry flag and set low bits + PY_UINT32_T cur_refcnt = op->ob_refcnt_split[PY_BIG_ENDIAN]; + PY_UINT32_T new_refcnt = cur_refcnt + 1; + if (new_refcnt == 0) { + // cur_refcnt is equal to _Py_IMMORTAL_REFCNT: the object is immortal, + // do nothing + return; + } + op->ob_refcnt_split[PY_BIG_ENDIAN] = new_refcnt; +#else + // Explicitly check immortality against the immortal value + if (_Py_IsImmortal(op)) { + return; + } + op->ob_refcnt++; +#endif + _Py_INCREF_STAT_INC(); +#ifdef Py_REF_DEBUG + _Py_INCREF_IncRefTotal(); +#endif +#endif +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op)) +#endif + + +#if !defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED) +// Implements Py_DECREF on objects not owned by the current thread. +PyAPI_FUNC(void) _Py_DecRefShared(PyObject *); +PyAPI_FUNC(void) _Py_DecRefSharedDebug(PyObject *, const char *, int); + +// Called from Py_DECREF by the owning thread when the local refcount reaches +// zero. The call will deallocate the object if the shared refcount is also +// zero. Otherwise, the thread gives up ownership and merges the reference +// count fields. +PyAPI_FUNC(void) _Py_MergeZeroLocalRefcount(PyObject *); +#endif + +#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) +// Stable ABI implements Py_DECREF() as a function call on limited C API +// version 3.12 and newer, and on Python built in debug mode. _Py_DecRef() was +// added to Python 3.10.0a7, use Py_DecRef() on older Python versions. +// Py_DecRef() accepts NULL whereas _Py_IncRef() doesn't. +static inline void Py_DECREF(PyObject *op) { +# if Py_LIMITED_API+0 >= 0x030a00A7 + _Py_DecRef(op); +# else + Py_DecRef(op); +# endif +} +#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op)) + +#elif defined(Py_GIL_DISABLED) && defined(Py_REF_DEBUG) +static inline void Py_DECREF(const char *filename, int lineno, PyObject *op) +{ + uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local); + if (local == _Py_IMMORTAL_REFCNT_LOCAL) { + return; + } + _Py_DECREF_STAT_INC(); + _Py_DECREF_DecRefTotal(); + if (_Py_IsOwnedByCurrentThread(op)) { + if (local == 0) { + _Py_NegativeRefcount(filename, lineno, op); + } + local--; + _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, local); + if (local == 0) { + _Py_MergeZeroLocalRefcount(op); + } + } + else { + _Py_DecRefSharedDebug(op, filename, lineno); + } +} +#define Py_DECREF(op) Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op)) + +#elif defined(Py_GIL_DISABLED) +static inline void Py_DECREF(PyObject *op) +{ + uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local); + if (local == _Py_IMMORTAL_REFCNT_LOCAL) { + return; + } + _Py_DECREF_STAT_INC(); + if (_Py_IsOwnedByCurrentThread(op)) { + local--; + _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, local); + if (local == 0) { + _Py_MergeZeroLocalRefcount(op); + } + } + else { + _Py_DecRefShared(op); + } +} +#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op)) + +#elif defined(Py_REF_DEBUG) +static inline void Py_DECREF(const char *filename, int lineno, PyObject *op) +{ + if (op->ob_refcnt <= 0) { + _Py_NegativeRefcount(filename, lineno, op); + } + if (_Py_IsImmortal(op)) { + return; + } + _Py_DECREF_STAT_INC(); + _Py_DECREF_DecRefTotal(); + if (--op->ob_refcnt == 0) { + _Py_Dealloc(op); + } +} +#define Py_DECREF(op) Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op)) + +#else +static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op) +{ + // Non-limited C API and limited C API for Python 3.9 and older access + // directly PyObject.ob_refcnt. + if (_Py_IsImmortal(op)) { + return; + } + _Py_DECREF_STAT_INC(); + if (--op->ob_refcnt == 0) { + _Py_Dealloc(op); + } +} +#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op)) +#endif + + +/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear + * and tp_dealloc implementations. + * + * Note that "the obvious" code can be deadly: + * + * Py_XDECREF(op); + * op = NULL; + * + * Typically, `op` is something like self->containee, and `self` is done + * using its `containee` member. In the code sequence above, suppose + * `containee` is non-NULL with a refcount of 1. Its refcount falls to + * 0 on the first line, which can trigger an arbitrary amount of code, + * possibly including finalizers (like __del__ methods or weakref callbacks) + * coded in Python, which in turn can release the GIL and allow other threads + * to run, etc. Such code may even invoke methods of `self` again, or cause + * cyclic gc to trigger, but-- oops! --self->containee still points to the + * object being torn down, and it may be in an insane state while being torn + * down. This has in fact been a rich historic source of miserable (rare & + * hard-to-diagnose) segfaulting (and other) bugs. + * + * The safe way is: + * + * Py_CLEAR(op); + * + * That arranges to set `op` to NULL _before_ decref'ing, so that any code + * triggered as a side-effect of `op` getting torn down no longer believes + * `op` points to a valid object. + * + * There are cases where it's safe to use the naive code, but they're brittle. + * For example, if `op` points to a Python integer, you know that destroying + * one of those can't cause problems -- but in part that relies on that + * Python integers aren't currently weakly referencable. Best practice is + * to use Py_CLEAR() even if you can't think of a reason for why you need to. + * + * gh-98724: Use a temporary variable to only evaluate the macro argument once, + * to avoid the duplication of side effects if the argument has side effects. + * + * gh-99701: If the PyObject* type is used with casting arguments to PyObject*, + * the code can be miscompiled with strict aliasing because of type punning. + * With strict aliasing, a compiler considers that two pointers of different + * types cannot read or write the same memory which enables optimization + * opportunities. + * + * If available, use _Py_TYPEOF() to use the 'op' type for temporary variables, + * and so avoid type punning. Otherwise, use memcpy() which causes type erasure + * and so prevents the compiler to reuse an old cached 'op' value after + * Py_CLEAR(). + */ +#ifdef _Py_TYPEOF +#define Py_CLEAR(op) \ + do { \ + _Py_TYPEOF(op)* _tmp_op_ptr = &(op); \ + _Py_TYPEOF(op) _tmp_old_op = (*_tmp_op_ptr); \ + if (_tmp_old_op != NULL) { \ + *_tmp_op_ptr = _Py_NULL; \ + Py_DECREF(_tmp_old_op); \ + } \ + } while (0) +#else +#define Py_CLEAR(op) \ + do { \ + PyObject **_tmp_op_ptr = _Py_CAST(PyObject**, &(op)); \ + PyObject *_tmp_old_op = (*_tmp_op_ptr); \ + if (_tmp_old_op != NULL) { \ + PyObject *_null_ptr = _Py_NULL; \ + memcpy(_tmp_op_ptr, &_null_ptr, sizeof(PyObject*)); \ + Py_DECREF(_tmp_old_op); \ + } \ + } while (0) +#endif + + +/* Function to use in case the object pointer can be NULL: */ +static inline void Py_XINCREF(PyObject *op) +{ + if (op != _Py_NULL) { + Py_INCREF(op); + } +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_XINCREF(op) Py_XINCREF(_PyObject_CAST(op)) +#endif + +static inline void Py_XDECREF(PyObject *op) +{ + if (op != _Py_NULL) { + Py_DECREF(op); + } +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_XDECREF(op) Py_XDECREF(_PyObject_CAST(op)) +#endif + +// Create a new strong reference to an object: +// increment the reference count of the object and return the object. +PyAPI_FUNC(PyObject*) Py_NewRef(PyObject *obj); + +// Similar to Py_NewRef(), but the object can be NULL. +PyAPI_FUNC(PyObject*) Py_XNewRef(PyObject *obj); + +static inline PyObject* _Py_NewRef(PyObject *obj) +{ + Py_INCREF(obj); + return obj; +} + +static inline PyObject* _Py_XNewRef(PyObject *obj) +{ + Py_XINCREF(obj); + return obj; +} + +// Py_NewRef() and Py_XNewRef() are exported as functions for the stable ABI. +// Names overridden with macros by static inline functions for best +// performances. +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj)) +# define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj)) +#else +# define Py_NewRef(obj) _Py_NewRef(obj) +# define Py_XNewRef(obj) _Py_XNewRef(obj) +#endif + + +#define Py_CONSTANT_NONE 0 +#define Py_CONSTANT_FALSE 1 +#define Py_CONSTANT_TRUE 2 +#define Py_CONSTANT_ELLIPSIS 3 +#define Py_CONSTANT_NOT_IMPLEMENTED 4 +#define Py_CONSTANT_ZERO 5 +#define Py_CONSTANT_ONE 6 +#define Py_CONSTANT_EMPTY_STR 7 +#define Py_CONSTANT_EMPTY_BYTES 8 +#define Py_CONSTANT_EMPTY_TUPLE 9 + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(PyObject*) Py_GetConstant(unsigned int constant_id); +PyAPI_FUNC(PyObject*) Py_GetConstantBorrowed(unsigned int constant_id); +#endif + + +/* +_Py_NoneStruct is an object of undefined type which can be used in contexts +where NULL (nil) is not suitable (since NULL often means 'error'). +*/ +PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */ + +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000 +# define Py_None Py_GetConstantBorrowed(Py_CONSTANT_NONE) +#else +# define Py_None (&_Py_NoneStruct) +#endif + +// Test if an object is the None singleton, the same as "x is None" in Python. +PyAPI_FUNC(int) Py_IsNone(PyObject *x); +#define Py_IsNone(x) Py_Is((x), Py_None) + +/* Macro for returning Py_None from a function. + * Only treat Py_None as immortal in the limited C API 3.12 and newer. */ +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030c0000 +# define Py_RETURN_NONE return Py_NewRef(Py_None) +#else +# define Py_RETURN_NONE return Py_None +#endif + +/* +Py_NotImplemented is a singleton used to signal that an operation is +not implemented for a given type combination. +*/ +PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ + +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000 +# define Py_NotImplemented Py_GetConstantBorrowed(Py_CONSTANT_NOT_IMPLEMENTED) +#else +# define Py_NotImplemented (&_Py_NotImplementedStruct) +#endif + +/* Macro for returning Py_NotImplemented from a function */ +#define Py_RETURN_NOTIMPLEMENTED return Py_NotImplemented + +/* Rich comparison opcodes */ +#define Py_LT 0 +#define Py_LE 1 +#define Py_EQ 2 +#define Py_NE 3 +#define Py_GT 4 +#define Py_GE 5 + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +/* Result of calling PyIter_Send */ +typedef enum { + PYGEN_RETURN = 0, + PYGEN_ERROR = -1, + PYGEN_NEXT = 1, +} PySendResult; +#endif + +/* + * Macro for implementing rich comparisons + * + * Needs to be a macro because any C-comparable type can be used. + */ +#define Py_RETURN_RICHCOMPARE(val1, val2, op) \ + do { \ + switch (op) { \ + case Py_EQ: if ((val1) == (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_NE: if ((val1) != (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_LT: if ((val1) < (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_GT: if ((val1) > (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_LE: if ((val1) <= (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_GE: if ((val1) >= (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + default: \ + Py_UNREACHABLE(); \ + } \ + } while (0) + + +/* +More conventions +================ + +Argument Checking +----------------- + +Functions that take objects as arguments normally don't check for nil +arguments, but they do check the type of the argument, and return an +error if the function doesn't apply to the type. + +Failure Modes +------------- + +Functions may fail for a variety of reasons, including running out of +memory. This is communicated to the caller in two ways: an error string +is set (see errors.h), and the function result differs: functions that +normally return a pointer return NULL for failure, functions returning +an integer return -1 (which could be a legal return value too!), and +other functions return 0 for success and -1 for failure. +Callers should always check for errors before using the result. If +an error was set, the caller must either explicitly clear it, or pass +the error on to its caller. + +Reference Counts +---------------- + +It takes a while to get used to the proper usage of reference counts. + +Functions that create an object set the reference count to 1; such new +objects must be stored somewhere or destroyed again with Py_DECREF(). +Some functions that 'store' objects, such as PyTuple_SetItem() and +PyList_SetItem(), +don't increment the reference count of the object, since the most +frequent use is to store a fresh object. Functions that 'retrieve' +objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also +don't increment +the reference count, since most frequently the object is only looked at +quickly. Thus, to retrieve an object and store it again, the caller +must call Py_INCREF() explicitly. + +NOTE: functions that 'consume' a reference count, like +PyList_SetItem(), consume the reference even if the object wasn't +successfully stored, to simplify error handling. + +It seems attractive to make other functions that take an object as +argument consume a reference count; however, this may quickly get +confusing (even the current practice is already confusing). Consider +it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at +times. +*/ + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_OBJECT_H +# include "cpython/object.h" +# undef Py_CPYTHON_OBJECT_H +#endif + + +static inline int +PyType_HasFeature(PyTypeObject *type, unsigned long feature) +{ + unsigned long flags; +#ifdef Py_LIMITED_API + // PyTypeObject is opaque in the limited C API + flags = PyType_GetFlags(type); +#else +# ifdef Py_GIL_DISABLED + flags = _Py_atomic_load_ulong_relaxed(&type->tp_flags); +# else + flags = type->tp_flags; +# endif +#endif + return ((flags & feature) != 0); +} + +#define PyType_FastSubclass(type, flag) PyType_HasFeature((type), (flag)) + +static inline int PyType_Check(PyObject *op) { + return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS); +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define PyType_Check(op) PyType_Check(_PyObject_CAST(op)) +#endif + +#define _PyType_CAST(op) \ + (assert(PyType_Check(op)), _Py_CAST(PyTypeObject*, (op))) + +static inline int PyType_CheckExact(PyObject *op) { + return Py_IS_TYPE(op, &PyType_Type); +} +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define PyType_CheckExact(op) PyType_CheckExact(_PyObject_CAST(op)) +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *); +#endif + +#ifdef __cplusplus +} +#endif +#endif // !Py_OBJECT_H diff --git a/illumos-x86_64/usr/include/python3.13/objimpl.h b/illumos-x86_64/usr/include/python3.13/objimpl.h new file mode 100644 index 00000000..56472a72 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/objimpl.h @@ -0,0 +1,211 @@ +// The PyObject_ memory family: high-level object memory interfaces. +// See pymem.h for the low-level PyMem_ family. + +#ifndef Py_OBJIMPL_H +#define Py_OBJIMPL_H +#ifdef __cplusplus +extern "C" { +#endif + +/* BEWARE: + + Each interface exports both functions and macros. Extension modules should + use the functions, to ensure binary compatibility across Python versions. + Because the Python implementation is free to change internal details, and + the macros may (or may not) expose details for speed, if you do use the + macros you must recompile your extensions with each Python release. + + Never mix calls to PyObject_ memory functions with calls to the platform + malloc/realloc/ calloc/free, or with calls to PyMem_. +*/ + +/* +Functions and macros for modules that implement new object types. + + - PyObject_New(type, typeobj) allocates memory for a new object of the given + type, and initializes part of it. 'type' must be the C structure type used + to represent the object, and 'typeobj' the address of the corresponding + type object. Reference count and type pointer are filled in; the rest of + the bytes of the object are *undefined*! The resulting expression type is + 'type *'. The size of the object is determined by the tp_basicsize field + of the type object. + + - PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size + object with room for n items. In addition to the refcount and type pointer + fields, this also fills in the ob_size field. + + - PyObject_Free(op) releases the memory allocated for an object. It does not + run a destructor -- it only frees the memory. + + - PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't + allocate memory. Instead of a 'type' parameter, they take a pointer to a + new object (allocated by an arbitrary allocator), and initialize its object + header fields. + +Note that objects created with PyObject_{New, NewVar} are allocated using the +specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is +enabled. In addition, a special debugging allocator is used if Py_DEBUG +macro is also defined. + +In case a specific form of memory management is needed (for example, if you +must use the platform malloc heap(s), or shared memory, or C++ local storage or +operator new), you must first allocate the object with your custom allocator, +then pass its pointer to PyObject_{Init, InitVar} for filling in its Python- +specific fields: reference count, type pointer, possibly others. You should +be aware that Python has no control over these objects because they don't +cooperate with the Python memory manager. Such objects may not be eligible +for automatic garbage collection and you have to make sure that they are +released accordingly whenever their destructor gets called (cf. the specific +form of memory management you're using). + +Unless you have specific memory management requirements, use +PyObject_{New, NewVar, Del}. +*/ + +/* + * Raw object memory interface + * =========================== + */ + +/* Functions to call the same malloc/realloc/free as used by Python's + object allocator. If WITH_PYMALLOC is enabled, these may differ from + the platform malloc/realloc/free. The Python object allocator is + designed for fast, cache-conscious allocation of many "small" objects, + and with low hidden memory overhead. + + PyObject_Malloc(0) returns a unique non-NULL pointer if possible. + + PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n). + PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory + at p. + + Returned pointers must be checked for NULL explicitly; no action is + performed on failure other than to return NULL (no warning it printed, no + exception is set, etc). + + For allocating objects, use PyObject_{New, NewVar} instead whenever + possible. The PyObject_{Malloc, Realloc, Free} family is exposed + so that you can exploit Python's small-block allocator for non-object + uses. If you must use these routines to allocate object memory, make sure + the object gets initialized via PyObject_{Init, InitVar} after obtaining + the raw memory. +*/ +PyAPI_FUNC(void *) PyObject_Malloc(size_t size); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +PyAPI_FUNC(void *) PyObject_Calloc(size_t nelem, size_t elsize); +#endif +PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size); +PyAPI_FUNC(void) PyObject_Free(void *ptr); + + +// Deprecated aliases only kept for backward compatibility. +// PyObject_Del and PyObject_DEL are defined with no parameter to be able to +// use them as function pointers (ex: tp_free = PyObject_Del). +#define PyObject_MALLOC PyObject_Malloc +#define PyObject_REALLOC PyObject_Realloc +#define PyObject_FREE PyObject_Free +#define PyObject_Del PyObject_Free +#define PyObject_DEL PyObject_Free + + +/* + * Generic object allocator interface + * ================================== + */ + +/* Functions */ +PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *); +PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *, + PyTypeObject *, Py_ssize_t); + +#define PyObject_INIT(op, typeobj) \ + PyObject_Init(_PyObject_CAST(op), (typeobj)) +#define PyObject_INIT_VAR(op, typeobj, size) \ + PyObject_InitVar(_PyVarObject_CAST(op), (typeobj), (size)) + + +PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *); +PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t); + +#define PyObject_New(type, typeobj) ((type *)_PyObject_New(typeobj)) + +// Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly +// PyObject_MALLOC() with _PyObject_SIZE(). +#define PyObject_NEW(type, typeobj) PyObject_New(type, (typeobj)) + +#define PyObject_NewVar(type, typeobj, n) \ + ( (type *) _PyObject_NewVar((typeobj), (n)) ) + +// Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called +// directly PyObject_MALLOC() with _PyObject_VAR_SIZE(). +#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, (typeobj), (n)) + + +/* + * Garbage Collection Support + * ========================== + */ + +/* C equivalent of gc.collect(). */ +PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void); +/* C API for controlling the state of the garbage collector */ +PyAPI_FUNC(int) PyGC_Enable(void); +PyAPI_FUNC(int) PyGC_Disable(void); +PyAPI_FUNC(int) PyGC_IsEnabled(void); + +/* Test if a type has a GC head */ +#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) + +PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t); +#define PyObject_GC_Resize(type, op, n) \ + ( (type *) _PyObject_GC_Resize(_PyVarObject_CAST(op), (n)) ) + + + +PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *); +PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t); + +/* Tell the GC to track this object. + * + * See also private _PyObject_GC_TRACK() macro. */ +PyAPI_FUNC(void) PyObject_GC_Track(void *); + +/* Tell the GC to stop tracking this object. + * + * See also private _PyObject_GC_UNTRACK() macro. */ +PyAPI_FUNC(void) PyObject_GC_UnTrack(void *); + +PyAPI_FUNC(void) PyObject_GC_Del(void *); + +#define PyObject_GC_New(type, typeobj) \ + _Py_CAST(type*, _PyObject_GC_New(typeobj)) +#define PyObject_GC_NewVar(type, typeobj, n) \ + _Py_CAST(type*, _PyObject_GC_NewVar((typeobj), (n))) + +PyAPI_FUNC(int) PyObject_GC_IsTracked(PyObject *); +PyAPI_FUNC(int) PyObject_GC_IsFinalized(PyObject *); + +/* Utility macro to help write tp_traverse functions. + * To use this macro, the tp_traverse function must name its arguments + * "visit" and "arg". This is intended to keep tp_traverse functions + * looking as much alike as possible. + */ +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit(_PyObject_CAST(op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_OBJIMPL_H +# include "cpython/objimpl.h" +# undef Py_CPYTHON_OBJIMPL_H +#endif + +#ifdef __cplusplus +} +#endif +#endif // !Py_OBJIMPL_H diff --git a/illumos-x86_64/usr/include/python3.13/opcode.h b/illumos-x86_64/usr/include/python3.13/opcode.h new file mode 100644 index 00000000..2619b690 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/opcode.h @@ -0,0 +1,42 @@ +#ifndef Py_OPCODE_H +#define Py_OPCODE_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "opcode_ids.h" + + +#define NB_ADD 0 +#define NB_AND 1 +#define NB_FLOOR_DIVIDE 2 +#define NB_LSHIFT 3 +#define NB_MATRIX_MULTIPLY 4 +#define NB_MULTIPLY 5 +#define NB_REMAINDER 6 +#define NB_OR 7 +#define NB_POWER 8 +#define NB_RSHIFT 9 +#define NB_SUBTRACT 10 +#define NB_TRUE_DIVIDE 11 +#define NB_XOR 12 +#define NB_INPLACE_ADD 13 +#define NB_INPLACE_AND 14 +#define NB_INPLACE_FLOOR_DIVIDE 15 +#define NB_INPLACE_LSHIFT 16 +#define NB_INPLACE_MATRIX_MULTIPLY 17 +#define NB_INPLACE_MULTIPLY 18 +#define NB_INPLACE_REMAINDER 19 +#define NB_INPLACE_OR 20 +#define NB_INPLACE_POWER 21 +#define NB_INPLACE_RSHIFT 22 +#define NB_INPLACE_SUBTRACT 23 +#define NB_INPLACE_TRUE_DIVIDE 24 +#define NB_INPLACE_XOR 25 + +#define NB_OPARG_LAST 25 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OPCODE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/opcode_ids.h b/illumos-x86_64/usr/include/python3.13/opcode_ids.h new file mode 100644 index 00000000..647f7c0e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/opcode_ids.h @@ -0,0 +1,244 @@ +// This file is generated by Tools/cases_generator/opcode_id_generator.py +// from: +// Python/bytecodes.c +// Do not edit! + +#ifndef Py_OPCODE_IDS_H +#define Py_OPCODE_IDS_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Instruction opcodes for compiled code */ +#define CACHE 0 +#define BEFORE_ASYNC_WITH 1 +#define BEFORE_WITH 2 +#define BINARY_OP_INPLACE_ADD_UNICODE 3 +#define BINARY_SLICE 4 +#define BINARY_SUBSCR 5 +#define CHECK_EG_MATCH 6 +#define CHECK_EXC_MATCH 7 +#define CLEANUP_THROW 8 +#define DELETE_SUBSCR 9 +#define END_ASYNC_FOR 10 +#define END_FOR 11 +#define END_SEND 12 +#define EXIT_INIT_CHECK 13 +#define FORMAT_SIMPLE 14 +#define FORMAT_WITH_SPEC 15 +#define GET_AITER 16 +#define RESERVED 17 +#define GET_ANEXT 18 +#define GET_ITER 19 +#define GET_LEN 20 +#define GET_YIELD_FROM_ITER 21 +#define INTERPRETER_EXIT 22 +#define LOAD_ASSERTION_ERROR 23 +#define LOAD_BUILD_CLASS 24 +#define LOAD_LOCALS 25 +#define MAKE_FUNCTION 26 +#define MATCH_KEYS 27 +#define MATCH_MAPPING 28 +#define MATCH_SEQUENCE 29 +#define NOP 30 +#define POP_EXCEPT 31 +#define POP_TOP 32 +#define PUSH_EXC_INFO 33 +#define PUSH_NULL 34 +#define RETURN_GENERATOR 35 +#define RETURN_VALUE 36 +#define SETUP_ANNOTATIONS 37 +#define STORE_SLICE 38 +#define STORE_SUBSCR 39 +#define TO_BOOL 40 +#define UNARY_INVERT 41 +#define UNARY_NEGATIVE 42 +#define UNARY_NOT 43 +#define WITH_EXCEPT_START 44 +#define BINARY_OP 45 +#define BUILD_CONST_KEY_MAP 46 +#define BUILD_LIST 47 +#define BUILD_MAP 48 +#define BUILD_SET 49 +#define BUILD_SLICE 50 +#define BUILD_STRING 51 +#define BUILD_TUPLE 52 +#define CALL 53 +#define CALL_FUNCTION_EX 54 +#define CALL_INTRINSIC_1 55 +#define CALL_INTRINSIC_2 56 +#define CALL_KW 57 +#define COMPARE_OP 58 +#define CONTAINS_OP 59 +#define CONVERT_VALUE 60 +#define COPY 61 +#define COPY_FREE_VARS 62 +#define DELETE_ATTR 63 +#define DELETE_DEREF 64 +#define DELETE_FAST 65 +#define DELETE_GLOBAL 66 +#define DELETE_NAME 67 +#define DICT_MERGE 68 +#define DICT_UPDATE 69 +#define ENTER_EXECUTOR 70 +#define EXTENDED_ARG 71 +#define FOR_ITER 72 +#define GET_AWAITABLE 73 +#define IMPORT_FROM 74 +#define IMPORT_NAME 75 +#define IS_OP 76 +#define JUMP_BACKWARD 77 +#define JUMP_BACKWARD_NO_INTERRUPT 78 +#define JUMP_FORWARD 79 +#define LIST_APPEND 80 +#define LIST_EXTEND 81 +#define LOAD_ATTR 82 +#define LOAD_CONST 83 +#define LOAD_DEREF 84 +#define LOAD_FAST 85 +#define LOAD_FAST_AND_CLEAR 86 +#define LOAD_FAST_CHECK 87 +#define LOAD_FAST_LOAD_FAST 88 +#define LOAD_FROM_DICT_OR_DEREF 89 +#define LOAD_FROM_DICT_OR_GLOBALS 90 +#define LOAD_GLOBAL 91 +#define LOAD_NAME 92 +#define LOAD_SUPER_ATTR 93 +#define MAKE_CELL 94 +#define MAP_ADD 95 +#define MATCH_CLASS 96 +#define POP_JUMP_IF_FALSE 97 +#define POP_JUMP_IF_NONE 98 +#define POP_JUMP_IF_NOT_NONE 99 +#define POP_JUMP_IF_TRUE 100 +#define RAISE_VARARGS 101 +#define RERAISE 102 +#define RETURN_CONST 103 +#define SEND 104 +#define SET_ADD 105 +#define SET_FUNCTION_ATTRIBUTE 106 +#define SET_UPDATE 107 +#define STORE_ATTR 108 +#define STORE_DEREF 109 +#define STORE_FAST 110 +#define STORE_FAST_LOAD_FAST 111 +#define STORE_FAST_STORE_FAST 112 +#define STORE_GLOBAL 113 +#define STORE_NAME 114 +#define SWAP 115 +#define UNPACK_EX 116 +#define UNPACK_SEQUENCE 117 +#define YIELD_VALUE 118 +#define RESUME 149 +#define BINARY_OP_ADD_FLOAT 150 +#define BINARY_OP_ADD_INT 151 +#define BINARY_OP_ADD_UNICODE 152 +#define BINARY_OP_MULTIPLY_FLOAT 153 +#define BINARY_OP_MULTIPLY_INT 154 +#define BINARY_OP_SUBTRACT_FLOAT 155 +#define BINARY_OP_SUBTRACT_INT 156 +#define BINARY_SUBSCR_DICT 157 +#define BINARY_SUBSCR_GETITEM 158 +#define BINARY_SUBSCR_LIST_INT 159 +#define BINARY_SUBSCR_STR_INT 160 +#define BINARY_SUBSCR_TUPLE_INT 161 +#define CALL_ALLOC_AND_ENTER_INIT 162 +#define CALL_BOUND_METHOD_EXACT_ARGS 163 +#define CALL_BOUND_METHOD_GENERAL 164 +#define CALL_BUILTIN_CLASS 165 +#define CALL_BUILTIN_FAST 166 +#define CALL_BUILTIN_FAST_WITH_KEYWORDS 167 +#define CALL_BUILTIN_O 168 +#define CALL_ISINSTANCE 169 +#define CALL_LEN 170 +#define CALL_LIST_APPEND 171 +#define CALL_METHOD_DESCRIPTOR_FAST 172 +#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 173 +#define CALL_METHOD_DESCRIPTOR_NOARGS 174 +#define CALL_METHOD_DESCRIPTOR_O 175 +#define CALL_NON_PY_GENERAL 176 +#define CALL_PY_EXACT_ARGS 177 +#define CALL_PY_GENERAL 178 +#define CALL_STR_1 179 +#define CALL_TUPLE_1 180 +#define CALL_TYPE_1 181 +#define COMPARE_OP_FLOAT 182 +#define COMPARE_OP_INT 183 +#define COMPARE_OP_STR 184 +#define CONTAINS_OP_DICT 185 +#define CONTAINS_OP_SET 186 +#define FOR_ITER_GEN 187 +#define FOR_ITER_LIST 188 +#define FOR_ITER_RANGE 189 +#define FOR_ITER_TUPLE 190 +#define LOAD_ATTR_CLASS 191 +#define LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN 192 +#define LOAD_ATTR_INSTANCE_VALUE 193 +#define LOAD_ATTR_METHOD_LAZY_DICT 194 +#define LOAD_ATTR_METHOD_NO_DICT 195 +#define LOAD_ATTR_METHOD_WITH_VALUES 196 +#define LOAD_ATTR_MODULE 197 +#define LOAD_ATTR_NONDESCRIPTOR_NO_DICT 198 +#define LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 199 +#define LOAD_ATTR_PROPERTY 200 +#define LOAD_ATTR_SLOT 201 +#define LOAD_ATTR_WITH_HINT 202 +#define LOAD_GLOBAL_BUILTIN 203 +#define LOAD_GLOBAL_MODULE 204 +#define LOAD_SUPER_ATTR_ATTR 205 +#define LOAD_SUPER_ATTR_METHOD 206 +#define RESUME_CHECK 207 +#define SEND_GEN 208 +#define STORE_ATTR_INSTANCE_VALUE 209 +#define STORE_ATTR_SLOT 210 +#define STORE_ATTR_WITH_HINT 211 +#define STORE_SUBSCR_DICT 212 +#define STORE_SUBSCR_LIST_INT 213 +#define TO_BOOL_ALWAYS_TRUE 214 +#define TO_BOOL_BOOL 215 +#define TO_BOOL_INT 216 +#define TO_BOOL_LIST 217 +#define TO_BOOL_NONE 218 +#define TO_BOOL_STR 219 +#define UNPACK_SEQUENCE_LIST 220 +#define UNPACK_SEQUENCE_TUPLE 221 +#define UNPACK_SEQUENCE_TWO_TUPLE 222 +#define INSTRUMENTED_RESUME 236 +#define INSTRUMENTED_END_FOR 237 +#define INSTRUMENTED_END_SEND 238 +#define INSTRUMENTED_RETURN_VALUE 239 +#define INSTRUMENTED_RETURN_CONST 240 +#define INSTRUMENTED_YIELD_VALUE 241 +#define INSTRUMENTED_LOAD_SUPER_ATTR 242 +#define INSTRUMENTED_FOR_ITER 243 +#define INSTRUMENTED_CALL 244 +#define INSTRUMENTED_CALL_KW 245 +#define INSTRUMENTED_CALL_FUNCTION_EX 246 +#define INSTRUMENTED_INSTRUCTION 247 +#define INSTRUMENTED_JUMP_FORWARD 248 +#define INSTRUMENTED_JUMP_BACKWARD 249 +#define INSTRUMENTED_POP_JUMP_IF_TRUE 250 +#define INSTRUMENTED_POP_JUMP_IF_FALSE 251 +#define INSTRUMENTED_POP_JUMP_IF_NONE 252 +#define INSTRUMENTED_POP_JUMP_IF_NOT_NONE 253 +#define INSTRUMENTED_LINE 254 +#define JUMP 256 +#define JUMP_NO_INTERRUPT 257 +#define LOAD_CLOSURE 258 +#define LOAD_METHOD 259 +#define LOAD_SUPER_METHOD 260 +#define LOAD_ZERO_SUPER_ATTR 261 +#define LOAD_ZERO_SUPER_METHOD 262 +#define POP_BLOCK 263 +#define SETUP_CLEANUP 264 +#define SETUP_FINALLY 265 +#define SETUP_WITH 266 +#define STORE_FAST_MAYBE_NULL 267 + +#define HAVE_ARGUMENT 44 +#define MIN_INSTRUMENTED_OPCODE 236 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OPCODE_IDS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/osdefs.h b/illumos-x86_64/usr/include/python3.13/osdefs.h new file mode 100644 index 00000000..2599e87a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/osdefs.h @@ -0,0 +1,57 @@ +// Operating system dependencies. +// +// Define constants: +// +// - ALTSEP +// - DELIM +// - MAXPATHLEN +// - SEP + +#ifndef Py_OSDEFS_H +#define Py_OSDEFS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef MS_WINDOWS +# define SEP L'\\' +# define ALTSEP L'/' +# define MAXPATHLEN 256 +# define DELIM L';' +#endif + +#ifdef __VXWORKS__ +# define DELIM L';' +#endif + +/* Filename separator */ +#ifndef SEP +# define SEP L'/' +#endif + +/* Max pathname length */ +#ifdef __hpux +# include +# include +# ifndef PATH_MAX +# define PATH_MAX MAXPATHLEN +# endif +#endif + +#ifndef MAXPATHLEN +# if defined(PATH_MAX) && PATH_MAX > 1024 +# define MAXPATHLEN PATH_MAX +# else +# define MAXPATHLEN 1024 +# endif +#endif + +/* Search path entry delimiter */ +#ifndef DELIM +# define DELIM L':' +#endif + +#ifdef __cplusplus +} +#endif +#endif // !Py_OSDEFS_H diff --git a/illumos-x86_64/usr/include/python3.13/osmodule.h b/illumos-x86_64/usr/include/python3.13/osmodule.h new file mode 100644 index 00000000..9095c2fd --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/osmodule.h @@ -0,0 +1,17 @@ + +/* os module interface */ + +#ifndef Py_OSMODULE_H +#define Py_OSMODULE_H +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000 +PyAPI_FUNC(PyObject *) PyOS_FSPath(PyObject *path); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OSMODULE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/patchlevel.h b/illumos-x86_64/usr/include/python3.13/patchlevel.h new file mode 100644 index 00000000..36b5ac25 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/patchlevel.h @@ -0,0 +1,35 @@ + +/* Python version identification scheme. + + When the major or minor version changes, the VERSION variable in + configure.ac must also be changed. + + There is also (independent) API version information in modsupport.h. +*/ + +/* Values for PY_RELEASE_LEVEL */ +#define PY_RELEASE_LEVEL_ALPHA 0xA +#define PY_RELEASE_LEVEL_BETA 0xB +#define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */ +#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */ + /* Higher for patch releases */ + +/* Version parsed out into numeric values */ +/*--start constants--*/ +#define PY_MAJOR_VERSION 3 +#define PY_MINOR_VERSION 13 +#define PY_MICRO_VERSION 7 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 + +/* Version as a string */ +#define PY_VERSION "3.13.7" +/*--end constants--*/ + +/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. + Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ +#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ + (PY_MINOR_VERSION << 16) | \ + (PY_MICRO_VERSION << 8) | \ + (PY_RELEASE_LEVEL << 4) | \ + (PY_RELEASE_SERIAL << 0)) diff --git a/illumos-x86_64/usr/include/python3.13/py_curses.h b/illumos-x86_64/usr/include/python3.13/py_curses.h new file mode 100644 index 00000000..3e8b16c2 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/py_curses.h @@ -0,0 +1,117 @@ + +#ifndef Py_CURSES_H +#define Py_CURSES_H + +#ifdef __APPLE__ +/* +** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards +** against multiple definition of wchar_t. +*/ +#ifdef _BSD_WCHAR_T_DEFINED_ +#define _WCHAR_T +#endif +#endif /* __APPLE__ */ + +/* On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards + against multiple definition of wchar_t and wint_t. */ +#if defined(__FreeBSD__) && defined(_XOPEN_SOURCE_EXTENDED) +# ifndef __wchar_t +# define __wchar_t +# endif +# ifndef __wint_t +# define __wint_t +# endif +#endif + +#if defined(WINDOW_HAS_FLAGS) && defined(__APPLE__) +/* gh-109617, gh-115383: we can rely on the default value for NCURSES_OPAQUE on + most platforms, but not on macOS. This is because, starting with Xcode 15, + Apple-provided ncurses.h comes from ncurses 6 (which defaults to opaque + structs) but can still be linked to older versions of ncurses dynamic + libraries which don't provide functions such as is_pad() to deal with opaque + structs. Setting NCURSES_OPAQUE to 0 is harmless in all ncurses releases to + this date (provided that a thread-safe implementation is not required), but + this might change in the future. This fix might become irrelevant once + support for macOS 13 or earlier is dropped. */ +#define NCURSES_OPAQUE 0 +#endif + +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +#ifdef NCURSES_VERSION +/* configure was checking , but we will + use , which has some or all these features. */ +#if !defined(WINDOW_HAS_FLAGS) && \ + (NCURSES_VERSION_PATCH+0 < 20070303 || !(NCURSES_OPAQUE+0)) +/* the WINDOW flags field was always accessible in ncurses prior to 20070303; + after that, it depends on the value of NCURSES_OPAQUE. */ +#define WINDOW_HAS_FLAGS 1 +#endif +#if !defined(HAVE_CURSES_IS_PAD) && NCURSES_VERSION_PATCH+0 >= 20090906 +#define HAVE_CURSES_IS_PAD 1 +#endif +#ifndef MVWDELCH_IS_EXPRESSION +#define MVWDELCH_IS_EXPRESSION 1 +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define PyCurses_API_pointers 4 + +/* Type declarations */ + +typedef struct PyCursesWindowObject { + PyObject_HEAD + WINDOW *win; + char *encoding; + struct PyCursesWindowObject *orig; +} PyCursesWindowObject; + +#define PyCursesWindow_Check(v) Py_IS_TYPE((v), &PyCursesWindow_Type) + +#define PyCurses_CAPSULE_NAME "_curses._C_API" + + +#ifdef CURSES_MODULE +/* This section is used when compiling _cursesmodule.c */ + +#else +/* This section is used in modules that use the _cursesmodule API */ + +static void **PyCurses_API; + +#define PyCursesWindow_Type (*_PyType_CAST(PyCurses_API[0])) +#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} +#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} +#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} + +#define import_curses() \ + PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1); + +#endif + +/* general error messages */ +static const char catchall_ERR[] = "curses function returned ERR"; +static const char catchall_NULL[] = "curses function returned NULL"; + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(Py_CURSES_H) */ + diff --git a/illumos-x86_64/usr/include/python3.13/pyatomic.h b/illumos-x86_64/usr/include/python3.13/pyatomic.h new file mode 100644 index 00000000..2ce2c81c --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pyatomic.h @@ -0,0 +1,16 @@ +#ifndef Py_ATOMIC_H +#define Py_ATOMIC_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_ATOMIC_H +# include "cpython/pyatomic.h" +# undef Py_CPYTHON_ATOMIC_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ATOMIC_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pybuffer.h b/illumos-x86_64/usr/include/python3.13/pybuffer.h new file mode 100644 index 00000000..ca1c6058 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pybuffer.h @@ -0,0 +1,145 @@ +/* Public Py_buffer API */ + +#ifndef Py_BUFFER_H +#define Py_BUFFER_H +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 + +/* === New Buffer API ============================================ + * Limited API and stable ABI since Python 3.11 + * + * Py_buffer struct layout and size is now part of the stable abi3. The + * struct layout and size must not be changed in any way, as it would + * break the ABI. + * + */ + +typedef struct { + void *buf; + PyObject *obj; /* owned reference */ + Py_ssize_t len; + Py_ssize_t itemsize; /* This is Py_ssize_t so it can be + pointed to by strides in simple case.*/ + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + void *internal; +} Py_buffer; + +typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); +typedef void (*releasebufferproc)(PyObject *, Py_buffer *); + +/* Return 1 if the getbuffer function is available, otherwise return 0. */ +PyAPI_FUNC(int) PyObject_CheckBuffer(PyObject *obj); + +/* This is a C-API version of the getbuffer function call. It checks + to make sure object has the required function pointer and issues the + call. + + Returns -1 and raises an error on failure and returns 0 on success. */ +PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view, + int flags); + +/* Get the memory area pointed to by the indices for the buffer given. + Note that view->ndim is the assumed size of indices. */ +PyAPI_FUNC(void *) PyBuffer_GetPointer(const Py_buffer *view, const Py_ssize_t *indices); + +/* Return the implied itemsize of the data-format area from a + struct-style description. */ +PyAPI_FUNC(Py_ssize_t) PyBuffer_SizeFromFormat(const char *format); + +/* Implementation in memoryobject.c */ +PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, const Py_buffer *view, + Py_ssize_t len, char order); + +PyAPI_FUNC(int) PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, + Py_ssize_t len, char order); + +/* Copy len bytes of data from the contiguous chunk of memory + pointed to by buf into the buffer exported by obj. Return + 0 on success and return -1 and raise a PyBuffer_Error on + error (i.e. the object does not have a buffer interface or + it is not working). + + If fort is 'F', then if the object is multi-dimensional, + then the data will be copied into the array in + Fortran-style (first dimension varies the fastest). If + fort is 'C', then the data will be copied into the array + in C-style (last dimension varies the fastest). If fort + is 'A', then it does not matter and the copy will be made + in whatever way is more efficient. */ +PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src); + +/* Copy the data from the src buffer to the buffer of destination. */ +PyAPI_FUNC(int) PyBuffer_IsContiguous(const Py_buffer *view, char fort); + +/*Fill the strides array with byte-strides of a contiguous + (Fortran-style if fort is 'F' or C-style otherwise) + array of the given shape with the given number of bytes + per element. */ +PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims, + Py_ssize_t *shape, + Py_ssize_t *strides, + int itemsize, + char fort); + +/* Fills in a buffer-info structure correctly for an exporter + that can only share a contiguous chunk of memory of + "unsigned bytes" of the given length. + + Returns 0 on success and -1 (with raising an error) on error. */ +PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf, + Py_ssize_t len, int readonly, + int flags); + +/* Releases a Py_buffer obtained from getbuffer ParseTuple's "s*". */ +PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view); + +/* Maximum number of dimensions */ +#define PyBUF_MAX_NDIM 64 + +/* Flags for getting buffers. Keep these in sync with inspect.BufferFlags. */ +#define PyBUF_SIMPLE 0 +#define PyBUF_WRITABLE 0x0001 + +#ifndef Py_LIMITED_API +/* we used to include an E, backwards compatible alias */ +#define PyBUF_WRITEABLE PyBUF_WRITABLE +#endif + +#define PyBUF_FORMAT 0x0004 +#define PyBUF_ND 0x0008 +#define PyBUF_STRIDES (0x0010 | PyBUF_ND) +#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) +#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) +#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) +#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + +#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE) +#define PyBUF_CONTIG_RO (PyBUF_ND) + +#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE) +#define PyBUF_STRIDED_RO (PyBUF_STRIDES) + +#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT) +#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT) + +#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT) +#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT) + + +#define PyBUF_READ 0x100 +#define PyBUF_WRITE 0x200 + +#endif /* !Py_LIMITED_API || Py_LIMITED_API >= 3.11 */ + +#ifdef __cplusplus +} +#endif +#endif /* Py_BUFFER_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pycapsule.h b/illumos-x86_64/usr/include/python3.13/pycapsule.h new file mode 100644 index 00000000..666b9f86 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pycapsule.h @@ -0,0 +1,58 @@ + +/* Capsule objects let you wrap a C "void *" pointer in a Python + object. They're a way of passing data through the Python interpreter + without creating your own custom type. + + Capsules are used for communication between extension modules. + They provide a way for an extension module to export a C interface + to other extension modules, so that extension modules can use the + Python import mechanism to link to one another. + + For more information, please see "c-api/capsule.html" in the + documentation. +*/ + +#ifndef Py_CAPSULE_H +#define Py_CAPSULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyCapsule_Type; + +typedef void (*PyCapsule_Destructor)(PyObject *); + +#define PyCapsule_CheckExact(op) Py_IS_TYPE((op), &PyCapsule_Type) + + +PyAPI_FUNC(PyObject *) PyCapsule_New( + void *pointer, + const char *name, + PyCapsule_Destructor destructor); + +PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name); + +PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule); + +PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule); + +PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule); + +PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name); + +PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer); + +PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor); + +PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name); + +PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context); + +PyAPI_FUNC(void *) PyCapsule_Import( + const char *name, /* UTF-8 encoded string */ + int no_block); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CAPSULE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pyconfig.h b/illumos-x86_64/usr/include/python3.13/pyconfig.h new file mode 100644 index 00000000..2bf1aae1 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pyconfig.h @@ -0,0 +1,2031 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the PEP425 tag of the + build system. */ +/* #undef AIX_BUILDDATE */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* The normal alignment of 'long', in bytes. */ +#define ALIGNOF_LONG 8 + +/* The normal alignment of 'max_align_t', in bytes. */ +#define ALIGNOF_MAX_ALIGN_T 16 + +/* The normal alignment of 'size_t', in bytes. */ +#define ALIGNOF_SIZE_T 8 + +/* Alternative SOABI used in debug build to load C extensions built in release + mode */ +/* #undef ALT_SOABI */ + +/* The Android API level. */ +/* #undef ANDROID_API_LEVEL */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if you have the 'accept' function. */ +#define HAVE_ACCEPT 1 + +/* Define to 1 if you have the 'accept4' function. */ +#define HAVE_ACCEPT4 1 + +/* Define to 1 if you have the 'acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the 'alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +/* #undef HAVE_ALIGNED_REQUIRED */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +#define HAVE_ALTZONE 1 + +/* Define to 1 if you have the 'asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ASM_TYPES_H */ + +/* Define to 1 if you have the 'atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if you have the 'bind' function. */ +#define HAVE_BIND 1 + +/* Define to 1 if you have the 'bind_textdomain_codeset' function. */ +#define HAVE_BIND_TEXTDOMAIN_CODESET 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +/* #undef HAVE_BROKEN_SEM_GETVALUE */ + +/* Define if 'unsetenv' does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin __atomic_load_n() and __atomic_store_n() functions */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_BZLIB_H 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the 'chmod' function. */ +#define HAVE_CHMOD 1 + +/* Define to 1 if you have the 'chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the 'clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the 'clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the 'clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define to 1 if you have the 'clock_nanosleep' function. */ +#define HAVE_CLOCK_NANOSLEEP 1 + +/* Define to 1 if you have the 'clock_settime' function. */ +#define HAVE_CLOCK_SETTIME 1 + +/* Define to 1 if the system has the type 'clock_t'. */ +#define HAVE_CLOCK_T 1 + +/* Define to 1 if you have the 'closefrom' function. */ +#define HAVE_CLOSEFROM 1 + +/* Define to 1 if you have the 'close_range' function. */ +/* #undef HAVE_CLOSE_RANGE */ + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the 'confstr' function. */ +#define HAVE_CONFSTR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define if you have the 'connect' function. */ +#define HAVE_CONNECT 1 + +/* Define to 1 if you have the 'copy_file_range' function. */ +/* #undef HAVE_COPY_FILE_RANGE */ + +/* Define to 1 if you have the 'ctermid' function. */ +#define HAVE_CTERMID 1 + +/* Define if you have the 'ctermid_r' function. */ +/* #undef HAVE_CTERMID_R */ + +/* Define if you have the 'filter' function. */ +#define HAVE_CURSES_FILTER 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the 'has_key' function. */ +#define HAVE_CURSES_HAS_KEY 1 + +/* Define if you have the 'immedok' function. */ +#define HAVE_CURSES_IMMEDOK 1 + +/* Define if you have the 'is_pad' function. */ +#define HAVE_CURSES_IS_PAD 1 + +/* Define if you have the 'is_term_resized' function. */ +#define HAVE_CURSES_IS_TERM_RESIZED 1 + +/* Define if you have the 'resizeterm' function. */ +#define HAVE_CURSES_RESIZETERM 1 + +/* Define if you have the 'resize_term' function. */ +#define HAVE_CURSES_RESIZE_TERM 1 + +/* Define if you have the 'syncok' function. */ +#define HAVE_CURSES_SYNCOK 1 + +/* Define if you have the 'typeahead' function. */ +#define HAVE_CURSES_TYPEAHEAD 1 + +/* Define if you have the 'use_env' function. */ +#define HAVE_CURSES_USE_ENV 1 + +/* Define if you have the 'wchgat' function. */ +#define HAVE_CURSES_WCHGAT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DB_H */ + +/* Define to 1 if you have the declaration of 'RTLD_DEEPBIND', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_DEEPBIND 0 + +/* Define to 1 if you have the declaration of 'RTLD_GLOBAL', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_GLOBAL 1 + +/* Define to 1 if you have the declaration of 'RTLD_LAZY', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_LAZY 1 + +/* Define to 1 if you have the declaration of 'RTLD_LOCAL', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_LOCAL 1 + +/* Define to 1 if you have the declaration of 'RTLD_MEMBER', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_MEMBER 0 + +/* Define to 1 if you have the declaration of 'RTLD_NODELETE', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_NODELETE 1 + +/* Define to 1 if you have the declaration of 'RTLD_NOLOAD', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_NOLOAD 1 + +/* Define to 1 if you have the declaration of 'RTLD_NOW', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_NOW 1 + +/* Define to 1 if you have the declaration of 'tzname', and to 0 if you don't. + */ +#define HAVE_DECL_TZNAME 1 + +/* Define to 1 if you have the declaration of 'UT_NAMESIZE', and to 0 if you + don't. */ +#define HAVE_DECL_UT_NAMESIZE 0 + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +#define HAVE_DEV_PTMX 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +/* #undef HAVE_DIRENT_D_TYPE */ + +/* Define to 1 if you have the header file, and it defines 'DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the 'dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the 'dup' function. */ +#define HAVE_DUP 1 + +/* Define to 1 if you have the 'dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the 'dup3' function. */ +#define HAVE_DUP3 1 + +/* Define if you have the '_dyld_shared_cache_contains_path' function. */ +/* #undef HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH */ + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EDITLINE_READLINE_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'NOepoll_create' function. */ +/* #undef HAVE_EPOLL */ + +/* Define to 1 if you have the 'erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the 'erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define if you have the 'eventfd' function. */ +#define HAVE_EVENTFD 1 + +/* Define to 1 if you have the 'execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the 'explicit_bzero' function. */ +#define HAVE_EXPLICIT_BZERO 1 + +/* Define to 1 if you have the 'explicit_memset' function. */ +/* #undef HAVE_EXPLICIT_MEMSET */ + +/* Define to 1 if you have the 'expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the 'faccessat' function. */ +#define HAVE_FACCESSAT 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the 'fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the 'fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the 'fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the 'fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the 'fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the 'fdwalk' function. */ +#define HAVE_FDWALK 1 + +/* Define to 1 if you have the 'fexecve' function. */ +#define HAVE_FEXECVE 1 + +/* Define if you have the 'ffi_closure_alloc' function. */ +#define HAVE_FFI_CLOSURE_ALLOC 1 + +/* Define if you have the 'ffi_prep_cif_var' function. */ +#define HAVE_FFI_PREP_CIF_VAR 1 + +/* Define if you have the 'ffi_prep_closure_loc' function. */ +#define HAVE_FFI_PREP_CLOSURE_LOC 1 + +/* Define to 1 if you have the 'flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the 'fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the 'fork1' function. */ +#define HAVE_FORK1 1 + +/* Define to 1 if you have the 'forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the 'fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the 'fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the 'fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the 'fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the 'fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the 'ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the 'ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the 'ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the 'ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the 'futimens' function. */ +#define HAVE_FUTIMENS 1 + +/* Define to 1 if you have the 'futimes' function. */ +#define HAVE_FUTIMES 1 + +/* Define to 1 if you have the 'futimesat' function. */ +#define HAVE_FUTIMESAT 1 + +/* Define to 1 if you have the 'gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +#define HAVE_GCC_ASM_FOR_X64 1 + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +#define HAVE_GCC_ASM_FOR_X87 1 + +/* Define if your compiler provides __uint128_t */ +#define HAVE_GCC_UINT128_T 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GDBM_DASH_NDBM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GDBM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GDBM_NDBM_H */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the 'getegid' function. */ +#define HAVE_GETEGID 1 + +/* Define to 1 if you have the 'getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the 'geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the 'getgid' function. */ +#define HAVE_GETGID 1 + +/* Define to 1 if you have the 'getgrent' function. */ +#define HAVE_GETGRENT 1 + +/* Define to 1 if you have the 'getgrgid' function. */ +#define HAVE_GETGRGID 1 + +/* Define to 1 if you have the 'getgrgid_r' function. */ +#define HAVE_GETGRGID_R 1 + +/* Define to 1 if you have the 'getgrnam_r' function. */ +#define HAVE_GETGRNAM_R 1 + +/* Define to 1 if you have the 'getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the 'getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define if you have the 'gethostbyaddr' function. */ +#define HAVE_GETHOSTBYADDR 1 + +/* Define to 1 if you have the 'gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +#define HAVE_GETHOSTBYNAME_R 1 + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +#define HAVE_GETHOSTBYNAME_R_5_ARG 1 + +/* Define to 1 if you have the 'gethostname' function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the 'getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the 'getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the 'getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the 'getlogin_r' function. */ +#define HAVE_GETLOGIN_R 1 + +/* Define to 1 if you have the 'getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the 'getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the 'getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the 'getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the 'getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the 'getppid' function. */ +#define HAVE_GETPPID 1 + +/* Define to 1 if you have the 'getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define if you have the 'getprotobyname' function. */ +#define HAVE_GETPROTOBYNAME 1 + +/* Define to 1 if you have the 'getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the 'getpwnam_r' function. */ +#define HAVE_GETPWNAM_R 1 + +/* Define to 1 if you have the 'getpwuid' function. */ +#define HAVE_GETPWUID 1 + +/* Define to 1 if you have the 'getpwuid_r' function. */ +#define HAVE_GETPWUID_R 1 + +/* Define to 1 if the getrandom() function is available */ +#define HAVE_GETRANDOM 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the 'getresgid' function. */ +/* #undef HAVE_GETRESGID */ + +/* Define to 1 if you have the 'getresuid' function. */ +/* #undef HAVE_GETRESUID */ + +/* Define to 1 if you have the 'getrusage' function. */ +#define HAVE_GETRUSAGE 1 + +/* Define if you have the 'getservbyname' function. */ +#define HAVE_GETSERVBYNAME 1 + +/* Define if you have the 'getservbyport' function. */ +#define HAVE_GETSERVBYPORT 1 + +/* Define to 1 if you have the 'getsid' function. */ +#define HAVE_GETSID 1 + +/* Define if you have the 'getsockname' function. */ +#define HAVE_GETSOCKNAME 1 + +/* Define to 1 if you have the 'getspent' function. */ +#define HAVE_GETSPENT 1 + +/* Define to 1 if you have the 'getspnam' function. */ +#define HAVE_GETSPNAM 1 + +/* Define to 1 if you have the 'getuid' function. */ +#define HAVE_GETUID 1 + +/* Define to 1 if you have the 'getwd' function. */ +#define HAVE_GETWD 1 + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the 'grantpt' function. */ +#define HAVE_GRANTPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +/* #undef HAVE_HSTRERROR */ + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the 'if_nameindex' function. */ +#define HAVE_IF_NAMEINDEX 1 + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_ntoa' function. */ +#define HAVE_INET_NTOA 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the 'initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the 'kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the 'killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' function. */ +/* #undef HAVE_KQUEUE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is at least as big as an off_t. You may need to add some + flags for configuration and compilation to enable this mode. (For Solaris + and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the 'lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the 'lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you want to build _blake2 module with libb2 */ +/* #undef HAVE_LIBB2 */ + +/* Define to 1 if you have the `db' library (-ldb). */ +/* #undef HAVE_LIBDB */ + +/* Define to 1 if you have the 'dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the 'dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the 'ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIBINTL_H 1 + +/* Define to 1 if you have the 'resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the 'sendfile' library (-lsendfile). */ +#define HAVE_LIBSENDFILE 1 + +/* Define to 1 if you have the 'sqlite3' library (-lsqlite3). */ +#define HAVE_LIBSQLITE3 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the 'linkat' function. */ +#define HAVE_LINKAT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_AUXVEC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_J1939_H */ + +/* Define if compiling using Linux 3.6 or later. */ +/* #undef HAVE_LINUX_CAN_RAW_FD_FRAMES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_RAW_H */ + +/* Define if compiling using Linux 4.1 or later. */ +/* #undef HAVE_LINUX_CAN_RAW_JOIN_FILTERS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_FS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_LIMITS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_MEMFD_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_NETLINK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_QRTR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_RANDOM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_SOUNDCARD_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_VM_SOCKETS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_WAIT_H */ + +/* Define if you have the 'listen' function. */ +#define HAVE_LISTEN 1 + +/* Define to 1 if you have the 'lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the 'log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the 'log2' function. */ +#define HAVE_LOG2 1 + +/* Define to 1 if you have the `login_tty' function. */ +/* #undef HAVE_LOGIN_TTY */ + +/* Define to 1 if the system has the type 'long double'. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define to 1 if you have the 'lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the 'lutimes' function. */ +#define HAVE_LUTIMES 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZMA_H */ + +/* Define to 1 if you have the 'madvise' function. */ +#define HAVE_MADVISE 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define if you have the 'MAXLOGNAME' constant. */ +/* #undef HAVE_MAXLOGNAME */ + +/* Define to 1 if you have the 'mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define if you have the 'memfd_create' function. */ +/* #undef HAVE_MEMFD_CREATE */ + +/* Define to 1 if you have the 'memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MINIX_CONFIG_H */ + +/* Define to 1 if you have the 'mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the 'mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the 'mkfifoat' function. */ +#define HAVE_MKFIFOAT 1 + +/* Define to 1 if you have the 'mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the 'mknodat' function. */ +#define HAVE_MKNODAT 1 + +/* Define to 1 if you have the 'mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the 'mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the 'mremap' function. */ +/* #undef HAVE_MREMAP */ + +/* Define to 1 if you have the 'nanosleep' function. */ +#define HAVE_NANOSLEEP 1 + +/* Define if you have the 'ncurses' library */ +#define HAVE_NCURSES 1 + +/* Define if you have the 'ncursesw' library */ +/* #undef HAVE_NCURSESW */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSESW_CURSES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSESW_NCURSES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSESW_PANEL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NCURSES_CURSES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NCURSES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NCURSES_NCURSES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NCURSES_PANEL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NDBM_H 1 + +/* Define to 1 if you have the header file, and it defines 'DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETCAN_CAN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETLINK_NETLINK_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NET_ETHERNET_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the 'nice' function. */ +#define HAVE_NICE 1 + +/* Define if you have the 'NOepoll_create1' function. */ +/* #undef HAVE_NOEPOLL_CREATE1 */ + +/* Define if the internal form of wchar_t in non-Unicode locales is not + Unicode. */ +/* #undef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION */ + +/* Define to 1 if you have the 'openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the 'opendir' function. */ +#define HAVE_OPENDIR 1 + +/* Define to 1 if you have the 'openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if you have the 'panel' library */ +#define HAVE_PANEL 1 + +/* Define if you have the 'panelw' library */ +/* #undef HAVE_PANELW */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PANEL_H 1 + +/* Define to 1 if you have the 'pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the 'pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the 'pipe' function. */ +#define HAVE_PIPE 1 + +/* Define to 1 if you have the 'pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the 'plock' function. */ +#define HAVE_PLOCK 1 + +/* Define to 1 if you have the 'poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the 'posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the 'posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the 'posix_openpt' function. */ +#define HAVE_POSIX_OPENPT 1 + +/* Define to 1 if you have the 'posix_spawn' function. */ +#define HAVE_POSIX_SPAWN 1 + +/* Define to 1 if you have the 'posix_spawnp' function. */ +#define HAVE_POSIX_SPAWNP 1 + +/* Define to 1 if you have the 'posix_spawn_file_actions_addclosefrom_np' + function. */ +#define HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSEFROM_NP 1 + +/* Define to 1 if you have the 'pread' function. */ +#define HAVE_PREAD 1 + +/* Define to 1 if you have the 'preadv' function. */ +#define HAVE_PREADV 1 + +/* Define to 1 if you have the 'preadv2' function. */ +/* #undef HAVE_PREADV2 */ + +/* Define if you have the 'prlimit' function. */ +/* #undef HAVE_PRLIMIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the 'process_vm_readv' function. */ +/* #undef HAVE_PROCESS_VM_READV */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the 'pthread_condattr_setclock' function. */ +#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1 + +/* Define to 1 if you have the 'pthread_cond_timedwait_relative_np' function. + */ +/* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the 'pthread_getcpuclockid' function. */ +/* #undef HAVE_PTHREAD_GETCPUCLOCKID */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the 'pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the 'pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the 'pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define if platform requires stubbed pthreads support */ +/* #undef HAVE_PTHREAD_STUBS */ + +/* Define to 1 if you have the 'ptsname' function. */ +#define HAVE_PTSNAME 1 + +/* Define to 1 if you have the 'ptsname_r' function. */ +#define HAVE_PTSNAME_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the 'pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define to 1 if you have the 'pwritev' function. */ +#define HAVE_PWRITEV 1 + +/* Define to 1 if you have the 'pwritev2' function. */ +/* #undef HAVE_PWRITEV2 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_READLINE_READLINE_H 1 + +/* Define to 1 if you have the 'readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the 'readlinkat' function. */ +#define HAVE_READLINKAT 1 + +/* Define to 1 if you have the 'readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the 'realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the 'recvfrom' function. */ +#define HAVE_RECVFROM 1 + +/* Define to 1 if you have the 'renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +#define HAVE_RL_APPEND_HISTORY 1 + +/* Define if you can turn off readline's signal handling. */ +#define HAVE_RL_CATCH_SIGNAL 1 + +/* Define to 1 if the system has the type 'rl_compdisp_func_t'. */ +#define HAVE_RL_COMPDISP_FUNC_T 1 + +/* Define if you have readline 2.2 */ +#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1 + +/* Define if you have readline 4.0 */ +#define HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1 + +/* Define if you have readline 4.2 */ +#define HAVE_RL_COMPLETION_MATCHES 1 + +/* Define if you have rl_completion_suppress_append */ +#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1 + +/* Define if you have readline 4.0 */ +#define HAVE_RL_PRE_INPUT_HOOK 1 + +/* Define if you have readline 4.0 */ +#define HAVE_RL_RESIZE_TERMINAL 1 + +/* Define to 1 if you have the 'rtpSpawn' function. */ +/* #undef HAVE_RTPSPAWN */ + +/* Define to 1 if you have the 'sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the 'sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the 'sched_setaffinity' function. */ +/* #undef HAVE_SCHED_SETAFFINITY */ + +/* Define to 1 if you have the 'sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the 'sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the 'sem_clockwait' function. */ +#define HAVE_SEM_CLOCKWAIT 1 + +/* Define to 1 if you have the 'sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the 'sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the 'sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the 'sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the 'sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define if you have the 'sendto' function. */ +#define HAVE_SENDTO 1 + +/* Define to 1 if you have the 'setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the 'seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the 'setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the 'sethostname' function. */ +#define HAVE_SETHOSTNAME 1 + +/* Define to 1 if you have the 'setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SETJMP_H 1 + +/* Define to 1 if you have the 'setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the 'setns' function. */ +/* #undef HAVE_SETNS */ + +/* Define to 1 if you have the 'setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the 'setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the 'setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the 'setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the 'setresgid' function. */ +/* #undef HAVE_SETRESGID */ + +/* Define to 1 if you have the 'setresuid' function. */ +/* #undef HAVE_SETRESUID */ + +/* Define to 1 if you have the 'setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the 'setsid' function. */ +#define HAVE_SETSID 1 + +/* Define if you have the 'setsockopt' function. */ +#define HAVE_SETSOCKOPT 1 + +/* Define to 1 if you have the 'setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the 'setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SHADOW_H 1 + +/* Define to 1 if you have the 'shm_open' function. */ +#define HAVE_SHM_OPEN 1 + +/* Define to 1 if you have the 'shm_unlink' function. */ +#define HAVE_SHM_UNLINK 1 + +/* Define to 1 if you have the 'shutdown' function. */ +#define HAVE_SHUTDOWN 1 + +/* Define to 1 if you have the 'sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the 'sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the 'sigfillset' function. */ +#define HAVE_SIGFILLSET 1 + +/* Define to 1 if 'si_band' is a member of 'siginfo_t'. */ +#define HAVE_SIGINFO_T_SI_BAND 1 + +/* Define to 1 if you have the 'siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the 'sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the 'sigrelse' function. */ +#define HAVE_SIGRELSE 1 + +/* Define to 1 if you have the 'sigtimedwait' function. */ +#define HAVE_SIGTIMEDWAIT 1 + +/* Define to 1 if you have the 'sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the 'sigwaitinfo' function. */ +#define HAVE_SIGWAITINFO 1 + +/* Define to 1 if you have the 'snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* struct sockaddr_alg (linux/if_alg.h) */ +/* #undef HAVE_SOCKADDR_ALG */ + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socket' function. */ +#define HAVE_SOCKET 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if the system has the type 'socklen_t'. */ +#define HAVE_SOCKLEN_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SPAWN_H 1 + +/* Define to 1 if you have the 'splice' function. */ +/* #undef HAVE_SPLICE */ + +/* Define to 1 if the system has the type 'ssize_t'. */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the 'statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +#define HAVE_STAT_TV_NSEC 1 + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h with atomic_int and atomic_uintptr_t */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the 'strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the 'strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STROPTS_H 1 + +/* Define to 1 if you have the 'strsignal' function. */ +#define HAVE_STRSIGNAL 1 + +/* Define to 1 if 'pw_gecos' is a member of 'struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_GECOS 1 + +/* Define to 1 if 'pw_passwd' is a member of 'struct passwd'. */ +#define HAVE_STRUCT_PASSWD_PW_PASSWD 1 + +/* Define to 1 if 'st_birthtime' is a member of 'struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if 'st_blksize' is a member of 'struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if 'st_blocks' is a member of 'struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if 'st_flags' is a member of 'struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if 'st_gen' is a member of 'struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if 'st_rdev' is a member of 'struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if 'tm_zone' is a member of 'struct tm'. */ +/* #undef HAVE_STRUCT_TM_TM_ZONE */ + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the 'symlinkat' function. */ +#define HAVE_SYMLINKAT 1 + +/* Define to 1 if you have the 'sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the 'sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the 'system' function. */ +#define HAVE_SYSTEM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_AUDIOIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_AUXV_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_DEVPOLL_H 1 + +/* Define to 1 if you have the header file, and it defines 'DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_ENDIAN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENTFD_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EVENT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_LOADAVG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_LOCK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MEMFD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MKDEV_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines 'DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PIDFD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RANDOM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOUNDCARD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSMACROS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TERMIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMERFD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_XATTR_H */ + +/* Define to 1 if you have the 'tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the 'tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the 'tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERM_H 1 + +/* Define to 1 if you have the 'timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define if you have the 'timerfd_create' function. */ +#define HAVE_TIMERFD_CREATE 1 + +/* Define to 1 if you have the 'times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the 'tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the 'tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the 'tmpnam_r' function. */ +#define HAVE_TMPNAM_R 1 + +/* Define to 1 if your 'struct tm' has 'tm_zone'. Deprecated, use + 'HAVE_STRUCT_TM_TM_ZONE' instead. */ +/* #undef HAVE_TM_ZONE */ + +/* Define to 1 if you have the 'truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you have the 'ttyname_r' function. */ +#define HAVE_TTYNAME_R 1 + +/* Define to 1 if you don't have 'tm_zone' but do have the external array + 'tzname'. */ +#define HAVE_TZNAME 1 + +/* Define to 1 if you have the 'umask' function. */ +#define HAVE_UMASK 1 + +/* Define to 1 if you have the 'uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the 'unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the 'unlockpt' function. */ +#define HAVE_UNLOCKPT 1 + +/* Define to 1 if you have the 'unshare' function. */ +/* #undef HAVE_UNSHARE */ + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UTIL_H */ + +/* Define to 1 if you have the 'utimensat' function. */ +#define HAVE_UTIMENSAT 1 + +/* Define to 1 if you have the 'utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTMP_H 1 + +/* Define if you have the 'HAVE_UT_NAMESIZE' constant. */ +/* #undef HAVE_UT_NAMESIZE */ + +/* Define to 1 if you have the 'uuid_create' function. */ +/* #undef HAVE_UUID_CREATE */ + +/* Define to 1 if you have the 'uuid_enc_be' function. */ +/* #undef HAVE_UUID_ENC_BE */ + +/* Define if uuid_generate_time_safe() exists. */ +/* #undef HAVE_UUID_GENERATE_TIME_SAFE */ + +/* Define if uuid_generate_time_safe() is able to deduce a MAC address. */ +/* #undef HAVE_UUID_GENERATE_TIME_SAFE_STABLE_MAC */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UUID_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UUID_UUID_H 1 + +/* Define to 1 if you have the 'vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the 'wait' function. */ +#define HAVE_WAIT 1 + +/* Define to 1 if you have the 'wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the 'wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the 'waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the 'waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the 'wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the 'wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the 'wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the 'wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +#define HAVE_WORKING_TZSET 1 + +/* Define to 1 if you have the 'writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ZLIB_H */ + +/* Define to 1 if you have the '_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define to 1 if the system has the type '__uint128_t'. */ +#define HAVE___UINT128_T 1 + +/* Define to 1 if 'major', 'minor', and 'makedev' are declared in . + */ +#define MAJOR_IN_MKDEV 1 + +/* Define to 1 if 'major', 'minor', and 'makedev' are declared in + . */ +/* #undef MAJOR_IN_SYSMACROS */ + +/* Define if mvwdelch in curses.h is an expression. */ +#define MVWDELCH_IS_EXPRESSION 1 + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Define if pthread_key_t is compatible with int. */ +#define PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT 1 + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +#define PTHREAD_SYSTEM_SCHED_SUPPORTED 1 + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* enabled builtin hash modules */ +#define PY_BUILTIN_HASHLIB_HASHES "md5,sha1,sha2,sha3,blake2" + +/* Define if you want to coerce the C locale to a UTF-8 based locale */ +#define PY_COERCE_C_LOCALE 1 + +/* Define to 1 if you have the perf trampoline. */ +/* #undef PY_HAVE_PERF_TRAMPOLINE */ + +/* Define to 1 to build the sqlite module with loadable extensions support. */ +/* #undef PY_SQLITE_ENABLE_LOAD_EXTENSION */ + +/* Define if SQLite was compiled with the serialize API */ +#define PY_SQLITE_HAVE_SERIALIZE 1 + +/* Default cipher suites list for ssl module. 1: Python's preferred selection, + 2: leave OpenSSL defaults untouched, 0: custom string */ +#define PY_SSL_DEFAULT_CIPHERS 1 + +/* Cipher suite string for PY_SSL_DEFAULT_CIPHERS=0 */ +/* #undef PY_SSL_DEFAULT_CIPHER_STRING */ + +/* PEP 11 Support tier (1, 2, 3 or 0 for unsupported) */ +#define PY_SUPPORT_TIER 0 + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define if you want to disable the GIL */ +/* #undef Py_GIL_DISABLED */ + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + SipHash13: 3, externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* Define if rl_startup_hook takes arguments */ +/* #undef Py_RL_STARTUP_HOOK_TAKES_ARGS */ + +/* Define if you want to enable internal statistics gathering. */ +/* #undef Py_STATS */ + +/* The version of SunOS/Solaris as reported by `uname -r' without the dot. */ +#define Py_SUNOS_VERSION 511 + +/* Define if you want to enable tracing references for debugging purpose */ +/* #undef Py_TRACE_REFS */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of 'double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of 'float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of 'fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 8 + +/* The size of 'int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of 'long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of 'long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 16 + +/* The size of 'long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of 'off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of 'pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of 'pthread_key_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_KEY_T 4 + +/* The size of 'pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of 'short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of 'size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of 'time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 8 + +/* The size of 'uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 8 + +/* The size of 'void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* The size of 'wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of '_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Custom thread stack size depending on chosen sanitizer runtimes. */ +/* #undef THREAD_STACK_SIZE */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if your declares 'struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +/* #undef USE_COMPUTED_GOTOS */ + +/* Enable extensions on AIX, Interix, z/OS. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable general extensions on macOS. */ +#ifndef _DARWIN_C_SOURCE +# define _DARWIN_C_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# define _HPUX_ALT_XOPEN_SOCKET_API 1 +#endif +/* Identify the host operating system as Minix. + This macro does not affect the system headers' behavior. + A future release of Autoconf may stop defining this macro. */ +#ifndef _MINIX +/* # undef _MINIX */ +#endif +/* Enable general extensions on NetBSD. + Enable NetBSD compatibility extensions on Minix. */ +#ifndef _NETBSD_SOURCE +# define _NETBSD_SOURCE 1 +#endif +/* Enable OpenBSD compatibility extensions on NetBSD. + Oddly enough, this does nothing on OpenBSD. */ +#ifndef _OPENBSD_SOURCE +# define _OPENBSD_SOURCE 1 +#endif +/* Define to 1 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_SOURCE +/* # undef _POSIX_SOURCE */ +#endif +/* Define to 2 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_1_SOURCE +/* # undef _POSIX_1_SOURCE */ +#endif +/* Enable POSIX-compatible threading on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# define __STDC_WANT_IEC_60559_BFP_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# define __STDC_WANT_IEC_60559_DFP_EXT__ 1 +#endif +/* Enable extensions specified by C23 Annex F. */ +#ifndef __STDC_WANT_IEC_60559_EXT__ +# define __STDC_WANT_IEC_60559_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 +#endif +/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# define __STDC_WANT_LIB_EXT2__ 1 +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# define __STDC_WANT_MATH_SPEC_FUNCS__ 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable X/Open extensions. Define to 500 only if necessary + to make mbstate_t available. */ +#ifndef _XOPEN_SOURCE +/* # undef _XOPEN_SOURCE */ +#endif + + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want build the _decimal module using a coroutine-local rather + than a thread-local context */ +#define WITH_DECIMAL_CONTEXTVAR 1 + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to compile in DTrace support */ +#define WITH_DTRACE 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to build the readline module against libedit. */ +/* #undef WITH_EDITLINE */ + +/* Define if you want to compile in object freelists optimization */ +#define WITH_FREELISTS 1 + +/* Define to 1 if libintl is needed for locale functions. */ +#define WITH_LIBINTL 1 + +/* Define if you want to compile in mimalloc memory allocator. */ +#define WITH_MIMALLOC 1 + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +/* #undef _POSIX_C_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* framework name */ +#define _PYTHONFRAMEWORK "" + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define to 1 if you want to emulate getpid() on WASI */ +/* #undef _WASI_EMULATED_GETPID */ + +/* Define to 1 if you want to emulate process clocks on WASI */ +/* #undef _WASI_EMULATED_PROCESS_CLOCKS */ + +/* Define to 1 if you want to emulate signals on WASI */ +/* #undef _WASI_EMULATED_SIGNAL */ + +/* Define to the level of X/Open that your system supports */ +/* #undef _XOPEN_SOURCE */ + +/* Define to activate Unix95-and-earlier features */ +/* #undef _XOPEN_SOURCE_EXTENDED */ + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 'long' if does not define clock_t. */ +/* #undef clock_t */ + +/* Define to empty if 'const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define as 'int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to 'int' if does not define. */ +/* #undef mode_t */ + +/* Define to 'long int' if does not define. */ +/* #undef off_t */ + +/* Define as a signed integer type capable of holding a process identifier. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define as 'unsigned int' if doesn't define. */ +/* #undef size_t */ + +/* Define to 'int' if does not define. */ +/* #undef socklen_t */ + +/* Define as 'int' if doesn't define. */ +/* #undef uid_t */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/illumos-x86_64/usr/include/python3.13/pydtrace.h b/illumos-x86_64/usr/include/python3.13/pydtrace.h new file mode 100644 index 00000000..e197d366 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pydtrace.h @@ -0,0 +1,59 @@ +/* Static DTrace probes interface */ + +#ifndef Py_DTRACE_H +#define Py_DTRACE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef WITH_DTRACE + +#include "pydtrace_probes.h" + +/* pydtrace_probes.h, on systems with DTrace, is auto-generated to include + `PyDTrace_{PROBE}` and `PyDTrace_{PROBE}_ENABLED()` macros for every probe + defined in pydtrace.d. + + Calling these functions must be guarded by a `PyDTrace_{PROBE}_ENABLED()` + check to minimize performance impact when probing is off. For example: + + if (PyDTrace_FUNCTION_ENTRY_ENABLED()) + PyDTrace_FUNCTION_ENTRY(f); +*/ + +#else + +/* Without DTrace, compile to nothing. */ + +static inline void PyDTrace_LINE(const char *arg0, const char *arg1, int arg2) {} +static inline void PyDTrace_FUNCTION_ENTRY(const char *arg0, const char *arg1, int arg2) {} +static inline void PyDTrace_FUNCTION_RETURN(const char *arg0, const char *arg1, int arg2) {} +static inline void PyDTrace_GC_START(int arg0) {} +static inline void PyDTrace_GC_DONE(Py_ssize_t arg0) {} +static inline void PyDTrace_INSTANCE_NEW_START(int arg0) {} +static inline void PyDTrace_INSTANCE_NEW_DONE(int arg0) {} +static inline void PyDTrace_INSTANCE_DELETE_START(int arg0) {} +static inline void PyDTrace_INSTANCE_DELETE_DONE(int arg0) {} +static inline void PyDTrace_IMPORT_FIND_LOAD_START(const char *arg0) {} +static inline void PyDTrace_IMPORT_FIND_LOAD_DONE(const char *arg0, int arg1) {} +static inline void PyDTrace_AUDIT(const char *arg0, void *arg1) {} + +static inline int PyDTrace_LINE_ENABLED(void) { return 0; } +static inline int PyDTrace_FUNCTION_ENTRY_ENABLED(void) { return 0; } +static inline int PyDTrace_FUNCTION_RETURN_ENABLED(void) { return 0; } +static inline int PyDTrace_GC_START_ENABLED(void) { return 0; } +static inline int PyDTrace_GC_DONE_ENABLED(void) { return 0; } +static inline int PyDTrace_INSTANCE_NEW_START_ENABLED(void) { return 0; } +static inline int PyDTrace_INSTANCE_NEW_DONE_ENABLED(void) { return 0; } +static inline int PyDTrace_INSTANCE_DELETE_START_ENABLED(void) { return 0; } +static inline int PyDTrace_INSTANCE_DELETE_DONE_ENABLED(void) { return 0; } +static inline int PyDTrace_IMPORT_FIND_LOAD_START_ENABLED(void) { return 0; } +static inline int PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED(void) { return 0; } +static inline int PyDTrace_AUDIT_ENABLED(void) { return 0; } + +#endif /* !WITH_DTRACE */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_DTRACE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pydtrace_probes.h b/illumos-x86_64/usr/include/python3.13/pydtrace_probes.h new file mode 100644 index 00000000..550a7ddf --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pydtrace_probes.h @@ -0,0 +1,233 @@ +/* + * Generated by dtrace(8). + */ + +#ifndef _PYDTRACE_PROBES_H +#define _PYDTRACE_PROBES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if _DTRACE_VERSION + +#define PyDTrace_AUDIT(arg0, arg1) \ + __dtrace_python___audit(arg0, arg1) +#ifndef __sparc +#define PyDTrace_AUDIT_ENABLED() \ + __dtraceenabled_python___audit() +#else +#define PyDTrace_AUDIT_ENABLED() \ + __dtraceenabled_python___audit(0) +#endif +#define PyDTrace_FUNCTION_ENTRY(arg0, arg1, arg2) \ + __dtrace_python___function__entry(arg0, arg1, arg2) +#ifndef __sparc +#define PyDTrace_FUNCTION_ENTRY_ENABLED() \ + __dtraceenabled_python___function__entry() +#else +#define PyDTrace_FUNCTION_ENTRY_ENABLED() \ + __dtraceenabled_python___function__entry(0) +#endif +#define PyDTrace_FUNCTION_RETURN(arg0, arg1, arg2) \ + __dtrace_python___function__return(arg0, arg1, arg2) +#ifndef __sparc +#define PyDTrace_FUNCTION_RETURN_ENABLED() \ + __dtraceenabled_python___function__return() +#else +#define PyDTrace_FUNCTION_RETURN_ENABLED() \ + __dtraceenabled_python___function__return(0) +#endif +#define PyDTrace_GC_DONE(arg0) \ + __dtrace_python___gc__done(arg0) +#ifndef __sparc +#define PyDTrace_GC_DONE_ENABLED() \ + __dtraceenabled_python___gc__done() +#else +#define PyDTrace_GC_DONE_ENABLED() \ + __dtraceenabled_python___gc__done(0) +#endif +#define PyDTrace_GC_START(arg0) \ + __dtrace_python___gc__start(arg0) +#ifndef __sparc +#define PyDTrace_GC_START_ENABLED() \ + __dtraceenabled_python___gc__start() +#else +#define PyDTrace_GC_START_ENABLED() \ + __dtraceenabled_python___gc__start(0) +#endif +#define PyDTrace_IMPORT_FIND_LOAD_DONE(arg0, arg1) \ + __dtrace_python___import__find__load__done(arg0, arg1) +#ifndef __sparc +#define PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED() \ + __dtraceenabled_python___import__find__load__done() +#else +#define PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED() \ + __dtraceenabled_python___import__find__load__done(0) +#endif +#define PyDTrace_IMPORT_FIND_LOAD_START(arg0) \ + __dtrace_python___import__find__load__start(arg0) +#ifndef __sparc +#define PyDTrace_IMPORT_FIND_LOAD_START_ENABLED() \ + __dtraceenabled_python___import__find__load__start() +#else +#define PyDTrace_IMPORT_FIND_LOAD_START_ENABLED() \ + __dtraceenabled_python___import__find__load__start(0) +#endif +#define PyDTrace_INSTANCE_DELETE_DONE(arg0, arg1) \ + __dtrace_python___instance__delete__done(arg0, arg1) +#ifndef __sparc +#define PyDTrace_INSTANCE_DELETE_DONE_ENABLED() \ + __dtraceenabled_python___instance__delete__done() +#else +#define PyDTrace_INSTANCE_DELETE_DONE_ENABLED() \ + __dtraceenabled_python___instance__delete__done(0) +#endif +#define PyDTrace_INSTANCE_DELETE_START(arg0, arg1) \ + __dtrace_python___instance__delete__start(arg0, arg1) +#ifndef __sparc +#define PyDTrace_INSTANCE_DELETE_START_ENABLED() \ + __dtraceenabled_python___instance__delete__start() +#else +#define PyDTrace_INSTANCE_DELETE_START_ENABLED() \ + __dtraceenabled_python___instance__delete__start(0) +#endif +#define PyDTrace_INSTANCE_NEW_DONE(arg0, arg1) \ + __dtrace_python___instance__new__done(arg0, arg1) +#ifndef __sparc +#define PyDTrace_INSTANCE_NEW_DONE_ENABLED() \ + __dtraceenabled_python___instance__new__done() +#else +#define PyDTrace_INSTANCE_NEW_DONE_ENABLED() \ + __dtraceenabled_python___instance__new__done(0) +#endif +#define PyDTrace_INSTANCE_NEW_START(arg0, arg1) \ + __dtrace_python___instance__new__start(arg0, arg1) +#ifndef __sparc +#define PyDTrace_INSTANCE_NEW_START_ENABLED() \ + __dtraceenabled_python___instance__new__start() +#else +#define PyDTrace_INSTANCE_NEW_START_ENABLED() \ + __dtraceenabled_python___instance__new__start(0) +#endif +#define PyDTrace_LINE(arg0, arg1, arg2) \ + __dtrace_python___line(arg0, arg1, arg2) +#ifndef __sparc +#define PyDTrace_LINE_ENABLED() \ + __dtraceenabled_python___line() +#else +#define PyDTrace_LINE_ENABLED() \ + __dtraceenabled_python___line(0) +#endif + + +extern void __dtrace_python___audit(char *, void *); +#ifndef __sparc +extern int __dtraceenabled_python___audit(void); +#else +extern int __dtraceenabled_python___audit(long); +#endif +extern void __dtrace_python___function__entry(char *, char *, int); +#ifndef __sparc +extern int __dtraceenabled_python___function__entry(void); +#else +extern int __dtraceenabled_python___function__entry(long); +#endif +extern void __dtrace_python___function__return(char *, char *, int); +#ifndef __sparc +extern int __dtraceenabled_python___function__return(void); +#else +extern int __dtraceenabled_python___function__return(long); +#endif +extern void __dtrace_python___gc__done(long); +#ifndef __sparc +extern int __dtraceenabled_python___gc__done(void); +#else +extern int __dtraceenabled_python___gc__done(long); +#endif +extern void __dtrace_python___gc__start(int); +#ifndef __sparc +extern int __dtraceenabled_python___gc__start(void); +#else +extern int __dtraceenabled_python___gc__start(long); +#endif +extern void __dtrace_python___import__find__load__done(char *, int); +#ifndef __sparc +extern int __dtraceenabled_python___import__find__load__done(void); +#else +extern int __dtraceenabled_python___import__find__load__done(long); +#endif +extern void __dtrace_python___import__find__load__start(char *); +#ifndef __sparc +extern int __dtraceenabled_python___import__find__load__start(void); +#else +extern int __dtraceenabled_python___import__find__load__start(long); +#endif +extern void __dtrace_python___instance__delete__done(char *, char *); +#ifndef __sparc +extern int __dtraceenabled_python___instance__delete__done(void); +#else +extern int __dtraceenabled_python___instance__delete__done(long); +#endif +extern void __dtrace_python___instance__delete__start(char *, char *); +#ifndef __sparc +extern int __dtraceenabled_python___instance__delete__start(void); +#else +extern int __dtraceenabled_python___instance__delete__start(long); +#endif +extern void __dtrace_python___instance__new__done(char *, char *); +#ifndef __sparc +extern int __dtraceenabled_python___instance__new__done(void); +#else +extern int __dtraceenabled_python___instance__new__done(long); +#endif +extern void __dtrace_python___instance__new__start(char *, char *); +#ifndef __sparc +extern int __dtraceenabled_python___instance__new__start(void); +#else +extern int __dtraceenabled_python___instance__new__start(long); +#endif +extern void __dtrace_python___line(char *, char *, int); +#ifndef __sparc +extern int __dtraceenabled_python___line(void); +#else +extern int __dtraceenabled_python___line(long); +#endif + +#else + +#define PyDTrace_AUDIT(arg0, arg1) +#define PyDTrace_AUDIT_ENABLED() (0) +#define PyDTrace_FUNCTION_ENTRY(arg0, arg1, arg2) +#define PyDTrace_FUNCTION_ENTRY_ENABLED() (0) +#define PyDTrace_FUNCTION_RETURN(arg0, arg1, arg2) +#define PyDTrace_FUNCTION_RETURN_ENABLED() (0) +#define PyDTrace_GC_DONE(arg0) +#define PyDTrace_GC_DONE_ENABLED() (0) +#define PyDTrace_GC_START(arg0) +#define PyDTrace_GC_START_ENABLED() (0) +#define PyDTrace_IMPORT_FIND_LOAD_DONE(arg0, arg1) +#define PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED() (0) +#define PyDTrace_IMPORT_FIND_LOAD_START(arg0) +#define PyDTrace_IMPORT_FIND_LOAD_START_ENABLED() (0) +#define PyDTrace_INSTANCE_DELETE_DONE(arg0, arg1) +#define PyDTrace_INSTANCE_DELETE_DONE_ENABLED() (0) +#define PyDTrace_INSTANCE_DELETE_START(arg0, arg1) +#define PyDTrace_INSTANCE_DELETE_START_ENABLED() (0) +#define PyDTrace_INSTANCE_NEW_DONE(arg0, arg1) +#define PyDTrace_INSTANCE_NEW_DONE_ENABLED() (0) +#define PyDTrace_INSTANCE_NEW_START(arg0, arg1) +#define PyDTrace_INSTANCE_NEW_START_ENABLED() (0) +#define PyDTrace_LINE(arg0, arg1, arg2) +#define PyDTrace_LINE_ENABLED() (0) + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _PYDTRACE_PROBES_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pyerrors.h b/illumos-x86_64/usr/include/python3.13/pyerrors.h new file mode 100644 index 00000000..5d0028c1 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pyerrors.h @@ -0,0 +1,335 @@ +// Error handling definitions + +#ifndef Py_ERRORS_H +#define Py_ERRORS_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(void) PyErr_SetNone(PyObject *); +PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *); +PyAPI_FUNC(void) PyErr_SetString( + PyObject *exception, + const char *string /* decoded from utf-8 */ + ); +PyAPI_FUNC(PyObject *) PyErr_Occurred(void); +PyAPI_FUNC(void) PyErr_Clear(void); +PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **); +PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_GetRaisedException(void); +PyAPI_FUNC(void) PyErr_SetRaisedException(PyObject *); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 +PyAPI_FUNC(PyObject*) PyErr_GetHandledException(void); +PyAPI_FUNC(void) PyErr_SetHandledException(PyObject *); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **); +PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *); +#endif + +/* Defined in Python/pylifecycle.c + + The Py_FatalError() function is replaced with a macro which logs + automatically the name of the current function, unless the Py_LIMITED_API + macro is defined. */ +PyAPI_FUNC(void) _Py_NO_RETURN Py_FatalError(const char *message); + +/* Error testing and normalization */ +PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *); +PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *); +PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); + +/* Traceback manipulation (PEP 3134) */ +PyAPI_FUNC(int) PyException_SetTraceback(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyException_GetTraceback(PyObject *); + +/* Cause manipulation (PEP 3134) */ +PyAPI_FUNC(PyObject *) PyException_GetCause(PyObject *); +PyAPI_FUNC(void) PyException_SetCause(PyObject *, PyObject *); + +/* Context manipulation (PEP 3134) */ +PyAPI_FUNC(PyObject *) PyException_GetContext(PyObject *); +PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *); + + +PyAPI_FUNC(PyObject *) PyException_GetArgs(PyObject *); +PyAPI_FUNC(void) PyException_SetArgs(PyObject *, PyObject *); + +/* */ + +#define PyExceptionClass_Check(x) \ + (PyType_Check((x)) && \ + PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)) + +#define PyExceptionInstance_Check(x) \ + PyType_FastSubclass(Py_TYPE(x), Py_TPFLAGS_BASE_EXC_SUBCLASS) + +PyAPI_FUNC(const char *) PyExceptionClass_Name(PyObject *); + +#define PyExceptionInstance_Class(x) _PyObject_CAST(Py_TYPE(x)) + +#define _PyBaseExceptionGroup_Check(x) \ + PyObject_TypeCheck((x), (PyTypeObject *)PyExc_BaseExceptionGroup) + +/* Predefined exceptions */ + +PyAPI_DATA(PyObject *) PyExc_BaseException; +PyAPI_DATA(PyObject *) PyExc_Exception; +PyAPI_DATA(PyObject *) PyExc_BaseExceptionGroup; +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +PyAPI_DATA(PyObject *) PyExc_StopAsyncIteration; +#endif +PyAPI_DATA(PyObject *) PyExc_StopIteration; +PyAPI_DATA(PyObject *) PyExc_GeneratorExit; +PyAPI_DATA(PyObject *) PyExc_ArithmeticError; +PyAPI_DATA(PyObject *) PyExc_LookupError; + +PyAPI_DATA(PyObject *) PyExc_AssertionError; +PyAPI_DATA(PyObject *) PyExc_AttributeError; +PyAPI_DATA(PyObject *) PyExc_BufferError; +PyAPI_DATA(PyObject *) PyExc_EOFError; +PyAPI_DATA(PyObject *) PyExc_FloatingPointError; +PyAPI_DATA(PyObject *) PyExc_OSError; +PyAPI_DATA(PyObject *) PyExc_ImportError; +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000 +PyAPI_DATA(PyObject *) PyExc_ModuleNotFoundError; +#endif +PyAPI_DATA(PyObject *) PyExc_IndexError; +PyAPI_DATA(PyObject *) PyExc_KeyError; +PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt; +PyAPI_DATA(PyObject *) PyExc_MemoryError; +PyAPI_DATA(PyObject *) PyExc_NameError; +PyAPI_DATA(PyObject *) PyExc_OverflowError; +PyAPI_DATA(PyObject *) PyExc_RuntimeError; +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +PyAPI_DATA(PyObject *) PyExc_RecursionError; +#endif +PyAPI_DATA(PyObject *) PyExc_NotImplementedError; +PyAPI_DATA(PyObject *) PyExc_SyntaxError; +PyAPI_DATA(PyObject *) PyExc_IndentationError; +PyAPI_DATA(PyObject *) PyExc_TabError; +PyAPI_DATA(PyObject *) PyExc_ReferenceError; +PyAPI_DATA(PyObject *) PyExc_SystemError; +PyAPI_DATA(PyObject *) PyExc_SystemExit; +PyAPI_DATA(PyObject *) PyExc_TypeError; +PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; +PyAPI_DATA(PyObject *) PyExc_UnicodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError; +PyAPI_DATA(PyObject *) PyExc_ValueError; +PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError; + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_DATA(PyObject *) PyExc_BlockingIOError; +PyAPI_DATA(PyObject *) PyExc_BrokenPipeError; +PyAPI_DATA(PyObject *) PyExc_ChildProcessError; +PyAPI_DATA(PyObject *) PyExc_ConnectionError; +PyAPI_DATA(PyObject *) PyExc_ConnectionAbortedError; +PyAPI_DATA(PyObject *) PyExc_ConnectionRefusedError; +PyAPI_DATA(PyObject *) PyExc_ConnectionResetError; +PyAPI_DATA(PyObject *) PyExc_FileExistsError; +PyAPI_DATA(PyObject *) PyExc_FileNotFoundError; +PyAPI_DATA(PyObject *) PyExc_InterruptedError; +PyAPI_DATA(PyObject *) PyExc_IsADirectoryError; +PyAPI_DATA(PyObject *) PyExc_NotADirectoryError; +PyAPI_DATA(PyObject *) PyExc_PermissionError; +PyAPI_DATA(PyObject *) PyExc_ProcessLookupError; +PyAPI_DATA(PyObject *) PyExc_TimeoutError; +#endif + + +/* Compatibility aliases */ +PyAPI_DATA(PyObject *) PyExc_EnvironmentError; +PyAPI_DATA(PyObject *) PyExc_IOError; +#ifdef MS_WINDOWS +PyAPI_DATA(PyObject *) PyExc_WindowsError; +#endif + +/* Predefined warning categories */ +PyAPI_DATA(PyObject *) PyExc_Warning; +PyAPI_DATA(PyObject *) PyExc_UserWarning; +PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; +PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; +PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; +PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; +PyAPI_DATA(PyObject *) PyExc_FutureWarning; +PyAPI_DATA(PyObject *) PyExc_ImportWarning; +PyAPI_DATA(PyObject *) PyExc_UnicodeWarning; +PyAPI_DATA(PyObject *) PyExc_BytesWarning; +PyAPI_DATA(PyObject *) PyExc_EncodingWarning; +PyAPI_DATA(PyObject *) PyExc_ResourceWarning; + + +/* Convenience functions */ + +PyAPI_FUNC(int) PyErr_BadArgument(void); +PyAPI_FUNC(PyObject *) PyErr_NoMemory(void); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject( + PyObject *, PyObject *); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000 +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObjects( + PyObject *, PyObject *, PyObject *); +#endif +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename( + PyObject *exc, + const char *filename /* decoded from the filesystem encoding */ + ); + +PyAPI_FUNC(PyObject *) PyErr_Format( + PyObject *exception, + const char *format, /* ASCII-encoded string */ + ... + ); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +PyAPI_FUNC(PyObject *) PyErr_FormatV( + PyObject *exception, + const char *format, + va_list vargs); +#endif + +#ifdef MS_WINDOWS +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename( + int ierr, + const char *filename /* decoded from the filesystem encoding */ + ); +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject( + PyObject *,int, PyObject *); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000 +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObjects( + PyObject *,int, PyObject *, PyObject *); +#endif +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename( + PyObject *exc, + int ierr, + const char *filename /* decoded from the filesystem encoding */ + ); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int); +#endif /* MS_WINDOWS */ + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000 +PyAPI_FUNC(PyObject *) PyErr_SetImportErrorSubclass(PyObject *, PyObject *, + PyObject *, PyObject *); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject *) PyErr_SetImportError(PyObject *, PyObject *, + PyObject *); +#endif + +/* Export the old function so that the existing API remains available: */ +PyAPI_FUNC(void) PyErr_BadInternalCall(void); +PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno); +/* Mask the old API with a call to the new API for code compiled under + Python 2.0: */ +#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) + +/* Function to create a new exception */ +PyAPI_FUNC(PyObject *) PyErr_NewException( + const char *name, PyObject *base, PyObject *dict); +PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc( + const char *name, const char *doc, PyObject *base, PyObject *dict); +PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); + + +/* In signalmodule.c */ +PyAPI_FUNC(int) PyErr_CheckSignals(void); +PyAPI_FUNC(void) PyErr_SetInterrupt(void); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +PyAPI_FUNC(int) PyErr_SetInterruptEx(int signum); +#endif + +/* Support for adding program text to SyntaxErrors */ +PyAPI_FUNC(void) PyErr_SyntaxLocation( + const char *filename, /* decoded from the filesystem encoding */ + int lineno); +PyAPI_FUNC(void) PyErr_SyntaxLocationEx( + const char *filename, /* decoded from the filesystem encoding */ + int lineno, + int col_offset); +PyAPI_FUNC(PyObject *) PyErr_ProgramText( + const char *filename, /* decoded from the filesystem encoding */ + int lineno); + +/* The following functions are used to create and modify unicode + exceptions from C */ + +/* create a UnicodeDecodeError object */ +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create( + const char *encoding, /* UTF-8 encoded string */ + const char *object, + Py_ssize_t length, + Py_ssize_t start, + Py_ssize_t end, + const char *reason /* UTF-8 encoded string */ + ); + +/* get the encoding attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *); + +/* get the object attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *); + +/* get the value of the start attribute (the int * may not be NULL) + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *); + +/* assign a new value to the start attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t); + +/* get the value of the end attribute (the int *may not be NULL) + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *); + +/* assign a new value to the end attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t); + +/* get the value of the reason attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *); + +/* assign a new value to the reason attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason( + PyObject *exc, + const char *reason /* UTF-8 encoded string */ + ); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( + PyObject *exc, + const char *reason /* UTF-8 encoded string */ + ); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( + PyObject *exc, + const char *reason /* UTF-8 encoded string */ + ); + +PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 3, 4))); +PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) + Py_GCC_ATTRIBUTE((format(printf, 3, 0))); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_ERRORS_H +# include "cpython/pyerrors.h" +# undef Py_CPYTHON_ERRORS_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ERRORS_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pyexpat.h b/illumos-x86_64/usr/include/python3.13/pyexpat.h new file mode 100644 index 00000000..9824d099 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pyexpat.h @@ -0,0 +1,57 @@ +/* Stuff to export relevant 'expat' entry points from pyexpat to other + * parser modules, such as cElementTree. */ + +/* note: you must import expat.h before importing this module! */ + +#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1" +#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI" + +struct PyExpat_CAPI +{ + char* magic; /* set to PyExpat_CAPI_MAGIC */ + int size; /* set to sizeof(struct PyExpat_CAPI) */ + int MAJOR_VERSION; + int MINOR_VERSION; + int MICRO_VERSION; + /* pointers to selected expat functions. add new functions at + the end, if needed */ + const XML_LChar * (*ErrorString)(enum XML_Error code); + enum XML_Error (*GetErrorCode)(XML_Parser parser); + XML_Size (*GetErrorColumnNumber)(XML_Parser parser); + XML_Size (*GetErrorLineNumber)(XML_Parser parser); + enum XML_Status (*Parse)( + XML_Parser parser, const char *s, int len, int isFinal); + XML_Parser (*ParserCreate_MM)( + const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, + const XML_Char *namespaceSeparator); + void (*ParserFree)(XML_Parser parser); + void (*SetCharacterDataHandler)( + XML_Parser parser, XML_CharacterDataHandler handler); + void (*SetCommentHandler)( + XML_Parser parser, XML_CommentHandler handler); + void (*SetDefaultHandlerExpand)( + XML_Parser parser, XML_DefaultHandler handler); + void (*SetElementHandler)( + XML_Parser parser, XML_StartElementHandler start, + XML_EndElementHandler end); + void (*SetNamespaceDeclHandler)( + XML_Parser parser, XML_StartNamespaceDeclHandler start, + XML_EndNamespaceDeclHandler end); + void (*SetProcessingInstructionHandler)( + XML_Parser parser, XML_ProcessingInstructionHandler handler); + void (*SetUnknownEncodingHandler)( + XML_Parser parser, XML_UnknownEncodingHandler handler, + void *encodingHandlerData); + void (*SetUserData)(XML_Parser parser, void *userData); + void (*SetStartDoctypeDeclHandler)(XML_Parser parser, + XML_StartDoctypeDeclHandler start); + enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding); + int (*DefaultUnknownEncodingHandler)( + void *encodingHandlerData, const XML_Char *name, XML_Encoding *info); + /* might be NULL for expat < 2.1.0 */ + int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt); + /* might be NULL for expat < 2.6.0 */ + XML_Bool (*SetReparseDeferralEnabled)(XML_Parser parser, XML_Bool enabled); + /* always add new stuff to the end! */ +}; + diff --git a/illumos-x86_64/usr/include/python3.13/pyframe.h b/illumos-x86_64/usr/include/python3.13/pyframe.h new file mode 100644 index 00000000..13d52312 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pyframe.h @@ -0,0 +1,26 @@ +/* Limited C API of PyFrame API + * + * Include "frameobject.h" to get the PyFrameObject structure. + */ + +#ifndef Py_PYFRAME_H +#define Py_PYFRAME_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Return the line of code the frame is currently executing. */ +PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *); + +PyAPI_FUNC(PyCodeObject *) PyFrame_GetCode(PyFrameObject *frame); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_PYFRAME_H +# include "cpython/pyframe.h" +# undef Py_CPYTHON_PYFRAME_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYFRAME_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pyhash.h b/illumos-x86_64/usr/include/python3.13/pyhash.h new file mode 100644 index 00000000..3e23e275 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pyhash.h @@ -0,0 +1,59 @@ +#ifndef Py_HASH_H +#define Py_HASH_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Cutoff for small string DJBX33A optimization in range [1, cutoff). + * + * About 50% of the strings in a typical Python application are smaller than + * 6 to 7 chars. However DJBX33A is vulnerable to hash collision attacks. + * NEVER use DJBX33A for long strings! + * + * A Py_HASH_CUTOFF of 0 disables small string optimization. 32 bit platforms + * should use a smaller cutoff because it is easier to create colliding + * strings. A cutoff of 7 on 64bit platforms and 5 on 32bit platforms should + * provide a decent safety margin. + */ +#ifndef Py_HASH_CUTOFF +# define Py_HASH_CUTOFF 0 +#elif (Py_HASH_CUTOFF > 7 || Py_HASH_CUTOFF < 0) +# error Py_HASH_CUTOFF must in range 0...7. +#endif /* Py_HASH_CUTOFF */ + + +/* Hash algorithm selection + * + * The values for Py_HASH_* are hard-coded in the + * configure script. + * + * - FNV and SIPHASH* are available on all platforms and architectures. + * - With EXTERNAL embedders can provide an alternative implementation with:: + * + * PyHash_FuncDef PyHash_Func = {...}; + * + * XXX: Figure out __declspec() for extern PyHash_FuncDef. + */ +#define Py_HASH_EXTERNAL 0 +#define Py_HASH_SIPHASH24 1 +#define Py_HASH_FNV 2 +#define Py_HASH_SIPHASH13 3 + +#ifndef Py_HASH_ALGORITHM +# ifndef HAVE_ALIGNED_REQUIRED +# define Py_HASH_ALGORITHM Py_HASH_SIPHASH13 +# else +# define Py_HASH_ALGORITHM Py_HASH_FNV +# endif /* uint64_t && uint32_t && aligned */ +#endif /* Py_HASH_ALGORITHM */ + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_HASH_H +# include "cpython/pyhash.h" +# undef Py_CPYTHON_HASH_H +#endif + +#ifdef __cplusplus +} +#endif +#endif // !Py_HASH_H diff --git a/illumos-x86_64/usr/include/python3.13/pylifecycle.h b/illumos-x86_64/usr/include/python3.13/pylifecycle.h new file mode 100644 index 00000000..de1bcb1d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pylifecycle.h @@ -0,0 +1,80 @@ + +/* Interfaces to configure, query, create & destroy the Python runtime */ + +#ifndef Py_PYLIFECYCLE_H +#define Py_PYLIFECYCLE_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Initialization and finalization */ +PyAPI_FUNC(void) Py_Initialize(void); +PyAPI_FUNC(void) Py_InitializeEx(int); +PyAPI_FUNC(void) Py_Finalize(void); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000 +PyAPI_FUNC(int) Py_FinalizeEx(void); +#endif +PyAPI_FUNC(int) Py_IsInitialized(void); + +/* Subinterpreter support */ +PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); +PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); + + +/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level + * exit functions. + */ +PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); + +PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int); + +/* Bootstrap __main__ (defined in Modules/main.c) */ +PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv); +PyAPI_FUNC(int) Py_BytesMain(int argc, char **argv); + +/* In pathconfig.c */ +Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *); +Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetProgramName(void); + +Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *); +Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void); + +Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void); +Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPrefix(void); +Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void); +Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPath(void); +#ifdef MS_WINDOWS +int _Py_CheckPython3(void); +#endif + +/* In their own files */ +PyAPI_FUNC(const char *) Py_GetVersion(void); +PyAPI_FUNC(const char *) Py_GetPlatform(void); +PyAPI_FUNC(const char *) Py_GetCopyright(void); +PyAPI_FUNC(const char *) Py_GetCompiler(void); +PyAPI_FUNC(const char *) Py_GetBuildInfo(void); + +/* Signals */ +typedef void (*PyOS_sighandler_t)(int); +PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); +PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000 +PyAPI_DATA(const unsigned long) Py_Version; +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +PyAPI_FUNC(int) Py_IsFinalizing(void); +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_PYLIFECYCLE_H +# include "cpython/pylifecycle.h" +# undef Py_CPYTHON_PYLIFECYCLE_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYLIFECYCLE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pymacconfig.h b/illumos-x86_64/usr/include/python3.13/pymacconfig.h new file mode 100644 index 00000000..615abe10 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pymacconfig.h @@ -0,0 +1,91 @@ +// This file moves some of the autoconf magic to compile-time when building on +// macOS. This is needed for building 4-way universal binaries and for 64-bit +// universal binaries because the values redefined below aren't configure-time +// constant but only compile-time constant in these scenarios. + +#ifndef PY_MACCONFIG_H +#define PY_MACCONFIG_H +#ifdef __APPLE__ + +#undef ALIGNOF_MAX_ALIGN_T +#undef SIZEOF_LONG +#undef SIZEOF_LONG_DOUBLE +#undef SIZEOF_PTHREAD_T +#undef SIZEOF_SIZE_T +#undef SIZEOF_TIME_T +#undef SIZEOF_VOID_P +#undef SIZEOF__BOOL +#undef SIZEOF_UINTPTR_T +#undef SIZEOF_PTHREAD_T +#undef WORDS_BIGENDIAN +#undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 +#undef DOUBLE_IS_BIG_ENDIAN_IEEE754 +#undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +#undef HAVE_GCC_ASM_FOR_X87 +#undef HAVE_GCC_ASM_FOR_X64 + +#undef VA_LIST_IS_ARRAY +#if defined(__LP64__) && defined(__x86_64__) +# define VA_LIST_IS_ARRAY 1 +#endif + +#undef HAVE_LARGEFILE_SUPPORT +#ifndef __LP64__ +# define HAVE_LARGEFILE_SUPPORT 1 +#endif + +#undef SIZEOF_LONG +#ifdef __LP64__ +# define SIZEOF__BOOL 1 +# define SIZEOF__BOOL 1 +# define SIZEOF_LONG 8 +# define SIZEOF_PTHREAD_T 8 +# define SIZEOF_SIZE_T 8 +# define SIZEOF_TIME_T 8 +# define SIZEOF_VOID_P 8 +# define SIZEOF_UINTPTR_T 8 +# define SIZEOF_PTHREAD_T 8 +#else +# ifdef __ppc__ +# define SIZEOF__BOOL 4 +# else +# define SIZEOF__BOOL 1 +# endif +# define SIZEOF_LONG 4 +# define SIZEOF_PTHREAD_T 4 +# define SIZEOF_SIZE_T 4 +# define SIZEOF_TIME_T 4 +# define SIZEOF_VOID_P 4 +# define SIZEOF_UINTPTR_T 4 +# define SIZEOF_PTHREAD_T 4 +#endif + +// macOS 10.4 (the first release to support 64-bit code +// at all) only supports 64-bit in the UNIX layer. +// Therefore suppress the toolbox-glue in 64-bit mode. +// +// In 64-bit mode setpgrp always has no arguments, in 32-bit +// mode that depends on the compilation environment +#if defined(__LP64__) +# undef SETPGRP_HAVE_ARG +#endif + +#ifdef __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# define DOUBLE_IS_BIG_ENDIAN_IEEE754 +#else +# define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +#endif + +#if defined(__i386__) || defined(__x86_64__) +# define HAVE_GCC_ASM_FOR_X87 +# define ALIGNOF_MAX_ALIGN_T 16 +# define HAVE_GCC_ASM_FOR_X64 1 +# define SIZEOF_LONG_DOUBLE 16 +#else +# define ALIGNOF_MAX_ALIGN_T 8 +# define SIZEOF_LONG_DOUBLE 8 +#endif + +#endif // __APPLE__ +#endif // !PY_MACCONFIG_H diff --git a/illumos-x86_64/usr/include/python3.13/pymacro.h b/illumos-x86_64/usr/include/python3.13/pymacro.h new file mode 100644 index 00000000..e0378f9d --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pymacro.h @@ -0,0 +1,193 @@ +#ifndef Py_PYMACRO_H +#define Py_PYMACRO_H + +// gh-91782: On FreeBSD 12, if the _POSIX_C_SOURCE and _XOPEN_SOURCE macros are +// defined, disables C11 support and does not define +// the static_assert() macro. +// https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255290 +// +// macOS <= 10.10 doesn't define static_assert in assert.h at all despite +// having C11 compiler support. +// +// static_assert is defined in glibc from version 2.16. Compiler support for +// the C11 _Static_assert keyword is in gcc >= 4.6. +// +// MSVC makes static_assert a keyword in C11-17, contrary to the standards. +// +// In C++11 and C2x, static_assert is a keyword, redefining is undefined +// behaviour. So only define if building as C, not C++ (if __cplusplus is +// not defined), and only for C11-17. +#if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \ + && !defined(__cplusplus) && defined(__STDC_VERSION__) \ + && __STDC_VERSION__ >= 201112L && __STDC_VERSION__ <= 201710L +# define static_assert _Static_assert +#endif + +/* Minimum value between x and y */ +#define Py_MIN(x, y) (((x) > (y)) ? (y) : (x)) + +/* Maximum value between x and y */ +#define Py_MAX(x, y) (((x) > (y)) ? (x) : (y)) + +/* Absolute value of the number x */ +#define Py_ABS(x) ((x) < 0 ? -(x) : (x)) + +#define _Py_XSTRINGIFY(x) #x + +/* Convert the argument to a string. For example, Py_STRINGIFY(123) is replaced + with "123" by the preprocessor. Defines are also replaced by their value. + For example Py_STRINGIFY(__LINE__) is replaced by the line number, not + by "__LINE__". */ +#define Py_STRINGIFY(x) _Py_XSTRINGIFY(x) + +/* Get the size of a structure member in bytes */ +#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) + +/* Argument must be a char or an int in [-128, 127] or [0, 255]. */ +#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ + && !defined(__cplusplus) && !defined(_MSC_VER)) +# define Py_BUILD_ASSERT_EXPR(cond) \ + ((void)sizeof(struct { int dummy; _Static_assert(cond, #cond); }), \ + 0) +#else + /* Assert a build-time dependency, as an expression. + * + * Your compile will fail if the condition isn't true, or can't be evaluated + * by the compiler. This can be used in an expression: its value is 0. + * + * Example: + * + * #define foo_to_char(foo) \ + * ((char *)(foo) \ + * + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0)) + * + * Written by Rusty Russell, public domain, http://ccodearchive.net/ + */ +# define Py_BUILD_ASSERT_EXPR(cond) \ + (sizeof(char [1 - 2*!(cond)]) - 1) +#endif + +#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \ + || (defined(__cplusplus) && __cplusplus >= 201103L)) + // Use static_assert() on C11 and newer +# define Py_BUILD_ASSERT(cond) \ + do { \ + static_assert((cond), #cond); \ + } while (0) +#else +# define Py_BUILD_ASSERT(cond) \ + do { \ + (void)Py_BUILD_ASSERT_EXPR(cond); \ + } while(0) +#endif + +/* Get the number of elements in a visible array + + This does not work on pointers, or arrays declared as [], or function + parameters. With correct compiler support, such usage will cause a build + error (see Py_BUILD_ASSERT_EXPR). + + Written by Rusty Russell, public domain, http://ccodearchive.net/ + + Requires at GCC 3.1+ */ +#if (defined(__GNUC__) && !defined(__STRICT_ANSI__) && \ + (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ >= 4))) +/* Two gcc extensions. + &a[0] degrades to a pointer: a different type from an array */ +#define Py_ARRAY_LENGTH(array) \ + (sizeof(array) / sizeof((array)[0]) \ + + Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \ + typeof(&(array)[0])))) +#else +#define Py_ARRAY_LENGTH(array) \ + (sizeof(array) / sizeof((array)[0])) +#endif + + +/* Define macros for inline documentation. */ +#define PyDoc_VAR(name) static const char name[] +#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) +#ifdef WITH_DOC_STRINGS +#define PyDoc_STR(str) str +#else +#define PyDoc_STR(str) "" +#endif + +/* Below "a" is a power of 2. */ +/* Round down size "n" to be a multiple of "a". */ +#define _Py_SIZE_ROUND_DOWN(n, a) ((size_t)(n) & ~(size_t)((a) - 1)) +/* Round up size "n" to be a multiple of "a". */ +#define _Py_SIZE_ROUND_UP(n, a) (((size_t)(n) + \ + (size_t)((a) - 1)) & ~(size_t)((a) - 1)) +/* Round pointer "p" down to the closest "a"-aligned address <= "p". */ +#define _Py_ALIGN_DOWN(p, a) ((void *)((uintptr_t)(p) & ~(uintptr_t)((a) - 1))) +/* Round pointer "p" up to the closest "a"-aligned address >= "p". */ +#define _Py_ALIGN_UP(p, a) ((void *)(((uintptr_t)(p) + \ + (uintptr_t)((a) - 1)) & ~(uintptr_t)((a) - 1))) +/* Check if pointer "p" is aligned to "a"-bytes boundary. */ +#define _Py_IS_ALIGNED(p, a) (!((uintptr_t)(p) & (uintptr_t)((a) - 1))) + +/* Use this for unused arguments in a function definition to silence compiler + * warnings. Example: + * + * int func(int a, int Py_UNUSED(b)) { return a; } + */ +#if defined(__GNUC__) || defined(__clang__) +# define Py_UNUSED(name) _unused_ ## name __attribute__((unused)) +#elif defined(_MSC_VER) + // Disable warning C4100: unreferenced formal parameter, + // declare the parameter, + // restore old compiler warnings. +# define Py_UNUSED(name) \ + __pragma(warning(push)) \ + __pragma(warning(suppress: 4100)) \ + _unused_ ## name \ + __pragma(warning(pop)) +#else +# define Py_UNUSED(name) _unused_ ## name +#endif + +#if defined(RANDALL_WAS_HERE) +# define Py_UNREACHABLE() \ + Py_FatalError( \ + "If you're seeing this, the code is in what I thought was\n" \ + "an unreachable state.\n\n" \ + "I could give you advice for what to do, but honestly, why\n" \ + "should you trust me? I clearly screwed this up. I'm writing\n" \ + "a message that should never appear, yet I know it will\n" \ + "probably appear someday.\n\n" \ + "On a deep level, I know I'm not up to this task.\n" \ + "I'm so sorry.\n" \ + "https://xkcd.com/2200") +#elif defined(Py_DEBUG) +# define Py_UNREACHABLE() \ + Py_FatalError( \ + "We've reached an unreachable state. Anything is possible.\n" \ + "The limits were in our heads all along. Follow your dreams.\n" \ + "https://xkcd.com/2200") +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) +# define Py_UNREACHABLE() __builtin_unreachable() +#elif defined(__clang__) || defined(__INTEL_COMPILER) +# define Py_UNREACHABLE() __builtin_unreachable() +#elif defined(_MSC_VER) +# define Py_UNREACHABLE() __assume(0) +#else +# define Py_UNREACHABLE() \ + Py_FatalError("Unreachable C code path reached") +#endif + +#define _Py_CONTAINER_OF(ptr, type, member) \ + (type*)((char*)ptr - offsetof(type, member)) + +// Prevent using an expression as a l-value. +// For example, "int x; _Py_RVALUE(x) = 1;" fails with a compiler error. +#define _Py_RVALUE(EXPR) ((void)0, (EXPR)) + +// Return non-zero if the type is signed, return zero if it's unsigned. +// Use "<= 0" rather than "< 0" to prevent the compiler warning: +// "comparison of unsigned expression in '< 0' is always false". +#define _Py_IS_TYPE_SIGNED(type) ((type)(-1) <= 0) + +#endif /* Py_PYMACRO_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pymath.h b/illumos-x86_64/usr/include/python3.13/pymath.h new file mode 100644 index 00000000..4c1e3d99 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pymath.h @@ -0,0 +1,62 @@ +// Symbols and macros to supply platform-independent interfaces to mathematical +// functions and constants. + +#ifndef Py_PYMATH_H +#define Py_PYMATH_H + +/* High precision definition of pi and e (Euler) + * The values are taken from libc6's math.h. + */ +#ifndef Py_MATH_PIl +#define Py_MATH_PIl 3.1415926535897932384626433832795029L +#endif +#ifndef Py_MATH_PI +#define Py_MATH_PI 3.14159265358979323846 +#endif + +#ifndef Py_MATH_El +#define Py_MATH_El 2.7182818284590452353602874713526625L +#endif + +#ifndef Py_MATH_E +#define Py_MATH_E 2.7182818284590452354 +#endif + +/* Tau (2pi) to 40 digits, taken from tauday.com/tau-digits. */ +#ifndef Py_MATH_TAU +#define Py_MATH_TAU 6.2831853071795864769252867665590057683943L +#endif + +// Py_IS_NAN(X) +// Return 1 if float or double arg is a NaN, else 0. +#define Py_IS_NAN(X) isnan(X) + +// Py_IS_INFINITY(X) +// Return 1 if float or double arg is an infinity, else 0. +#define Py_IS_INFINITY(X) isinf(X) + +// Py_IS_FINITE(X) +// Return 1 if float or double arg is neither infinite nor NAN, else 0. +#define Py_IS_FINITE(X) isfinite(X) + +// Py_INFINITY: Value that evaluates to a positive double infinity. +#ifndef Py_INFINITY +# define Py_INFINITY ((double)INFINITY) +#endif + +/* Py_HUGE_VAL should always be the same as Py_INFINITY. But historically + * this was not reliable and Python did not require IEEE floats and C99 + * conformity. Prefer Py_INFINITY for new code. + */ +#ifndef Py_HUGE_VAL +# define Py_HUGE_VAL HUGE_VAL +#endif + +/* Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN). The sign is + * undefined and normally not relevant, but e.g. fixed for float("nan"). + */ +#if !defined(Py_NAN) +# define Py_NAN ((double)NAN) +#endif + +#endif /* Py_PYMATH_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pymem.h b/illumos-x86_64/usr/include/python3.13/pymem.h new file mode 100644 index 00000000..a80da99e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pymem.h @@ -0,0 +1,110 @@ +// The PyMem_ family: low-level memory allocation interfaces. +// See objimpl.h for the PyObject_ memory family. + +#ifndef Py_PYMEM_H +#define Py_PYMEM_H +#ifdef __cplusplus +extern "C" { +#endif + +/* BEWARE: + + Each interface exports both functions and macros. Extension modules should + use the functions, to ensure binary compatibility across Python versions. + Because the Python implementation is free to change internal details, and + the macros may (or may not) expose details for speed, if you do use the + macros you must recompile your extensions with each Python release. + + Never mix calls to PyMem_ with calls to the platform malloc/realloc/ + calloc/free. For example, on Windows different DLLs may end up using + different heaps, and if you use PyMem_Malloc you'll get the memory from the + heap used by the Python DLL; it could be a disaster if you free()'ed that + directly in your own extension. Using PyMem_Free instead ensures Python + can return the memory to the proper heap. As another example, in + a debug build (Py_DEBUG macro), Python wraps all calls to all PyMem_ and + PyObject_ memory functions in special debugging wrappers that add additional + debugging info to dynamic memory blocks. The system routines have no idea + what to do with that stuff, and the Python wrappers have no idea what to do + with raw blocks obtained directly by the system routines then. + + The GIL must be held when using these APIs. +*/ + +/* + * Raw memory interface + * ==================== + */ + +/* Functions + + Functions supplying platform-independent semantics for malloc/realloc/ + free. These functions make sure that allocating 0 bytes returns a distinct + non-NULL pointer (whenever possible -- if we're flat out of memory, NULL + may be returned), even if the platform malloc and realloc don't. + Returned pointers must be checked for NULL explicitly. No action is + performed on failure (no exception is set, no warning is printed, etc). +*/ + +PyAPI_FUNC(void *) PyMem_Malloc(size_t size); +PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); +PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size); +PyAPI_FUNC(void) PyMem_Free(void *ptr); + +/* + * Type-oriented memory interface + * ============================== + * + * Allocate memory for n objects of the given type. Returns a new pointer + * or NULL if the request was too large or memory allocation failed. Use + * these macros rather than doing the multiplication yourself so that proper + * overflow checking is always done. + */ + +#define PyMem_New(type, n) \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (type *) PyMem_Malloc((n) * sizeof(type)) ) ) + +/* + * The value of (p) is always clobbered by this macro regardless of success. + * The caller MUST check if (p) is NULL afterwards and deal with the memory + * error if so. This means the original value of (p) MUST be saved for the + * caller's memory error handler to not lose track of it. + */ +#define PyMem_Resize(p, type, n) \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) + + +// Deprecated aliases only kept for backward compatibility. +// PyMem_Del and PyMem_DEL are defined with no parameter to be able to use +// them as function pointers (ex: dealloc = PyMem_Del). +#define PyMem_MALLOC(n) PyMem_Malloc((n)) +#define PyMem_NEW(type, n) PyMem_New(type, (n)) +#define PyMem_REALLOC(p, n) PyMem_Realloc((p), (n)) +#define PyMem_RESIZE(p, type, n) PyMem_Resize((p), type, (n)) +#define PyMem_FREE(p) PyMem_Free((p)) +#define PyMem_Del(p) PyMem_Free((p)) +#define PyMem_DEL(p) PyMem_Free((p)) + + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +// Memory allocator which doesn't require the GIL to be held. +// Usually, it's just a thin wrapper to functions of the standard C library: +// malloc(), calloc(), realloc() and free(). The difference is that +// tracemalloc can track these memory allocations. +PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size); +PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize); +PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size); +PyAPI_FUNC(void) PyMem_RawFree(void *ptr); +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_PYMEM_H +# include "cpython/pymem.h" +# undef Py_CPYTHON_PYMEM_H +#endif + +#ifdef __cplusplus +} +#endif +#endif // !Py_PYMEM_H diff --git a/illumos-x86_64/usr/include/python3.13/pyport.h b/illumos-x86_64/usr/include/python3.13/pyport.h new file mode 100644 index 00000000..72a157e6 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pyport.h @@ -0,0 +1,633 @@ +#ifndef Py_PYPORT_H +#define Py_PYPORT_H + +#ifndef UCHAR_MAX +# error " header must define UCHAR_MAX" +#endif +#if UCHAR_MAX != 255 +# error "Python's source code assumes C's unsigned char is an 8-bit type" +#endif + + +// Macro to use C++ static_cast<> in the Python C API. +#ifdef __cplusplus +# define _Py_STATIC_CAST(type, expr) static_cast(expr) +#else +# define _Py_STATIC_CAST(type, expr) ((type)(expr)) +#endif +// Macro to use the more powerful/dangerous C-style cast even in C++. +#define _Py_CAST(type, expr) ((type)(expr)) + +// Static inline functions should use _Py_NULL rather than using directly NULL +// to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer, +// _Py_NULL is defined as nullptr. +#if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \ + || (defined(__cplusplus) && __cplusplus >= 201103) +# define _Py_NULL nullptr +#else +# define _Py_NULL NULL +#endif + + +/* Defines to build Python and its standard library: + * + * - Py_BUILD_CORE: Build Python core. Give access to Python internals, but + * should not be used by third-party modules. + * - Py_BUILD_CORE_BUILTIN: Build a Python stdlib module as a built-in module. + * - Py_BUILD_CORE_MODULE: Build a Python stdlib module as a dynamic library. + * + * Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE imply Py_BUILD_CORE. + * + * On Windows, Py_BUILD_CORE_MODULE exports "PyInit_xxx" symbol, whereas + * Py_BUILD_CORE_BUILTIN does not. + */ +#if defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE) +# define Py_BUILD_CORE +#endif +#if defined(Py_BUILD_CORE_MODULE) && !defined(Py_BUILD_CORE) +# define Py_BUILD_CORE +#endif + + +/************************************************************************** +Symbols and macros to supply platform-independent interfaces to basic +C language & library operations whose spellings vary across platforms. + +Please try to make documentation here as clear as possible: by definition, +the stuff here is trying to illuminate C's darkest corners. + +Config #defines referenced here: + +SIGNED_RIGHT_SHIFT_ZERO_FILLS +Meaning: To be defined iff i>>j does not extend the sign bit when i is a + signed integral type and i < 0. +Used in: Py_ARITHMETIC_RIGHT_SHIFT + +Py_DEBUG +Meaning: Extra checks compiled in for debug mode. +Used in: Py_SAFE_DOWNCAST + +**************************************************************************/ + +/* typedefs for some C9X-defined synonyms for integral types. + * + * The names in Python are exactly the same as the C9X names, except with a + * Py_ prefix. Until C9X is universally implemented, this is the only way + * to ensure that Python gets reliable names that don't conflict with names + * in non-Python code that are playing their own tricks to define the C9X + * names. + * + * NOTE: don't go nuts here! Python has no use for *most* of the C9X + * integral synonyms. Only define the ones we actually need. + */ + +/* long long is required. Ensure HAVE_LONG_LONG is defined for compatibility. */ +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG 1 +#endif +#ifndef PY_LONG_LONG +#define PY_LONG_LONG long long +/* If LLONG_MAX is defined in limits.h, use that. */ +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX +#endif + +#define PY_UINT32_T uint32_t +#define PY_UINT64_T uint64_t + +/* Signed variants of the above */ +#define PY_INT32_T int32_t +#define PY_INT64_T int64_t + +/* PYLONG_BITS_IN_DIGIT describes the number of bits per "digit" (limb) in the + * PyLongObject implementation (longintrepr.h). It's currently either 30 or 15, + * defaulting to 30. The 15-bit digit option may be removed in the future. + */ +#ifndef PYLONG_BITS_IN_DIGIT +#define PYLONG_BITS_IN_DIGIT 30 +#endif + +/* uintptr_t is the C9X name for an unsigned integral type such that a + * legitimate void* can be cast to uintptr_t and then back to void* again + * without loss of information. Similarly for intptr_t, wrt a signed + * integral type. + */ +typedef uintptr_t Py_uintptr_t; +typedef intptr_t Py_intptr_t; + +/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) == + * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an + * unsigned integral type). See PEP 353 for details. + * PY_SSIZE_T_MAX is the largest positive value of type Py_ssize_t. + */ +#ifdef HAVE_PY_SSIZE_T + +#elif HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +# define PY_SSIZE_T_MAX SSIZE_MAX +#elif SIZEOF_VOID_P == SIZEOF_SIZE_T +typedef Py_intptr_t Py_ssize_t; +# define PY_SSIZE_T_MAX INTPTR_MAX +#else +# error "Python needs a typedef for Py_ssize_t in pyport.h." +#endif + +/* Smallest negative value of type Py_ssize_t. */ +#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) + +/* Py_hash_t is the same size as a pointer. */ +#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T +typedef Py_ssize_t Py_hash_t; +/* Py_uhash_t is the unsigned equivalent needed to calculate numeric hash. */ +#define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T +typedef size_t Py_uhash_t; + +/* Now PY_SSIZE_T_CLEAN is mandatory. This is just for backward compatibility. */ +typedef Py_ssize_t Py_ssize_clean_t; + +/* Largest possible value of size_t. */ +#define PY_SIZE_MAX SIZE_MAX + +/* Macro kept for backward compatibility: use directly "z" in new code. + * + * PY_FORMAT_SIZE_T is a modifier for use in a printf format to convert an + * argument with the width of a size_t or Py_ssize_t: "z" (C99). + */ +#ifndef PY_FORMAT_SIZE_T +# define PY_FORMAT_SIZE_T "z" +#endif + +/* Py_LOCAL can be used instead of static to get the fastest possible calling + * convention for functions that are local to a given module. + * + * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining, + * for platforms that support that. + * + * NOTE: You can only use this for functions that are entirely local to a + * module; functions that are exported via method tables, callbacks, etc, + * should keep using static. + */ + +#if defined(_MSC_VER) + /* ignore warnings if the compiler decides not to inline a function */ +# pragma warning(disable: 4710) + /* fastest possible local call under MSVC */ +# define Py_LOCAL(type) static type __fastcall +# define Py_LOCAL_INLINE(type) static __inline type __fastcall +#else +# define Py_LOCAL(type) static type +# define Py_LOCAL_INLINE(type) static inline type +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +# define Py_MEMCPY memcpy +#endif + +#ifdef __cplusplus +/* Move this down here since some C++ #include's don't like to be included + inside an extern "C" */ +extern "C" { +#endif + + +/* Py_ARITHMETIC_RIGHT_SHIFT + * C doesn't define whether a right-shift of a signed integer sign-extends + * or zero-fills. Here a macro to force sign extension: + * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) + * Return I >> J, forcing sign extension. Arithmetically, return the + * floor of I/2**J. + * Requirements: + * I should have signed integer type. In the terminology of C99, this can + * be either one of the five standard signed integer types (signed char, + * short, int, long, long long) or an extended signed integer type. + * J is an integer >= 0 and strictly less than the number of bits in the + * type of I (because C doesn't define what happens for J outside that + * range either). + * TYPE used to specify the type of I, but is now ignored. It's been left + * in for backwards compatibility with versions <= 2.6 or 3.0. + * Caution: + * I may be evaluated more than once. + */ +#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS +#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ + ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J)) +#else +#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J)) +#endif + +/* Py_FORCE_EXPANSION(X) + * "Simply" returns its argument. However, macro expansions within the + * argument are evaluated. This unfortunate trickery is needed to get + * token-pasting to work as desired in some cases. + */ +#define Py_FORCE_EXPANSION(X) X + +/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) + * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this + * assert-fails if any information is lost. + * Caution: + * VALUE may be evaluated more than once. + */ +#ifdef Py_DEBUG +# define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ + (assert(_Py_STATIC_CAST(WIDE, _Py_STATIC_CAST(NARROW, (VALUE))) == (VALUE)), \ + _Py_STATIC_CAST(NARROW, (VALUE))) +#else +# define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_STATIC_CAST(NARROW, (VALUE)) +#endif + + +/* Py_DEPRECATED(version) + * Declare a variable, type, or function deprecated. + * The macro must be placed before the declaration. + * Usage: + * Py_DEPRECATED(3.3) extern int old_var; + * Py_DEPRECATED(3.4) typedef int T1; + * Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void); + */ +#if defined(__GNUC__) \ + && ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) +#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) +#elif defined(_MSC_VER) +#define Py_DEPRECATED(VERSION) __declspec(deprecated( \ + "deprecated in " #VERSION)) +#else +#define Py_DEPRECATED(VERSION_UNUSED) +#endif + +// _Py_DEPRECATED_EXTERNALLY(version) +// Deprecated outside CPython core. +#ifdef Py_BUILD_CORE +#define _Py_DEPRECATED_EXTERNALLY(VERSION_UNUSED) +#else +#define _Py_DEPRECATED_EXTERNALLY(version) Py_DEPRECATED(version) +#endif + + +#if defined(__clang__) +#define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push") +#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) \ + && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) +#define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push") +#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop") +#elif defined(_MSC_VER) +#define _Py_COMP_DIAG_PUSH __pragma(warning(push)) +#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996)) +#define _Py_COMP_DIAG_POP __pragma(warning(pop)) +#else +#define _Py_COMP_DIAG_PUSH +#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS +#define _Py_COMP_DIAG_POP +#endif + +/* _Py_HOT_FUNCTION + * The hot attribute on a function is used to inform the compiler that the + * function is a hot spot of the compiled program. The function is optimized + * more aggressively and on many target it is placed into special subsection of + * the text section so all hot functions appears close together improving + * locality. + * + * Usage: + * int _Py_HOT_FUNCTION x(void) { return 3; } + * + * Issue #28618: This attribute must not be abused, otherwise it can have a + * negative effect on performance. Only the functions were Python spend most of + * its time must use it. Use a profiler when running performance benchmark + * suite to find these functions. + */ +#if defined(__GNUC__) \ + && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) +#define _Py_HOT_FUNCTION __attribute__((hot)) +#else +#define _Py_HOT_FUNCTION +#endif + +// Ask the compiler to always inline a static inline function. The compiler can +// ignore it and decides to not inline the function. +// +// It can be used to inline performance critical static inline functions when +// building Python in debug mode with function inlining disabled. For example, +// MSC disables function inlining when building in debug mode. +// +// Marking blindly a static inline function with Py_ALWAYS_INLINE can result in +// worse performances (due to increased code size for example). The compiler is +// usually smarter than the developer for the cost/benefit analysis. +// +// If Python is built in debug mode (if the Py_DEBUG macro is defined), the +// Py_ALWAYS_INLINE macro does nothing. +// +// It must be specified before the function return type. Usage: +// +// static inline Py_ALWAYS_INLINE int random(void) { return 4; } +#if defined(Py_DEBUG) + // If Python is built in debug mode, usually compiler optimizations are + // disabled. In this case, Py_ALWAYS_INLINE can increase a lot the stack + // memory usage. For example, forcing inlining using gcc -O0 increases the + // stack usage from 6 KB to 15 KB per Python function call. +# define Py_ALWAYS_INLINE +#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) +# define Py_ALWAYS_INLINE __attribute__((always_inline)) +#elif defined(_MSC_VER) +# define Py_ALWAYS_INLINE __forceinline +#else +# define Py_ALWAYS_INLINE +#endif + +// Py_NO_INLINE +// Disable inlining on a function. For example, it reduces the C stack +// consumption: useful on LTO+PGO builds which heavily inline code (see +// bpo-33720). +// +// Usage: +// +// Py_NO_INLINE static int random(void) { return 4; } +#if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) +# define Py_NO_INLINE __attribute__ ((noinline)) +#elif defined(_MSC_VER) +# define Py_NO_INLINE __declspec(noinline) +#else +# define Py_NO_INLINE +#endif + +#include "exports.h" + +#ifdef Py_LIMITED_API + // The internal C API must not be used with the limited C API: make sure + // that Py_BUILD_CORE macro is not defined in this case. These 3 macros are + // used by exports.h, so only undefine them afterwards. +# undef Py_BUILD_CORE +# undef Py_BUILD_CORE_BUILTIN +# undef Py_BUILD_CORE_MODULE +#endif + +/* limits.h constants that may be missing */ + +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif + +#ifndef LONG_MAX +#if SIZEOF_LONG == 4 +#define LONG_MAX 0X7FFFFFFFL +#elif SIZEOF_LONG == 8 +#define LONG_MAX 0X7FFFFFFFFFFFFFFFL +#else +#error "could not set LONG_MAX in pyport.h" +#endif +#endif + +#ifndef LONG_MIN +#define LONG_MIN (-LONG_MAX-1) +#endif + +#ifndef LONG_BIT +#define LONG_BIT (8 * SIZEOF_LONG) +#endif + +#if LONG_BIT != 8 * SIZEOF_LONG +/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent + * 32-bit platforms using gcc. We try to catch that here at compile-time + * rather than waiting for integer multiplication to trigger bogus + * overflows. + */ +#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." +#endif + +#ifdef __cplusplus +} +#endif + +/* + * Hide GCC attributes from compilers that don't support them. + */ +#if (!defined(__GNUC__) || __GNUC__ < 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) +#define Py_GCC_ATTRIBUTE(x) +#else +#define Py_GCC_ATTRIBUTE(x) __attribute__(x) +#endif + +/* + * Specify alignment on compilers that support it. + */ +#if defined(__GNUC__) && __GNUC__ >= 3 +#define Py_ALIGNED(x) __attribute__((aligned(x))) +#else +#define Py_ALIGNED(x) +#endif + +/* Eliminate end-of-loop code not reached warnings from SunPro C + * when using do{...}while(0) macros + */ +#ifdef __SUNPRO_C +#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) +#endif + +#ifndef Py_LL +#define Py_LL(x) x##LL +#endif + +#ifndef Py_ULL +#define Py_ULL(x) Py_LL(x##U) +#endif + +#define Py_VA_COPY va_copy + +/* + * Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is + * detected by configure and defined in pyconfig.h. The code in pyconfig.h + * also takes care of Apple's universal builds. + */ + +#ifdef WORDS_BIGENDIAN +# define PY_BIG_ENDIAN 1 +# define PY_LITTLE_ENDIAN 0 +#else +# define PY_BIG_ENDIAN 0 +# define PY_LITTLE_ENDIAN 1 +#endif + +#ifdef __ANDROID__ + /* The Android langinfo.h header is not used. */ +# undef HAVE_LANGINFO_H +# undef CODESET +#endif + +/* Maximum value of the Windows DWORD type */ +#define PY_DWORD_MAX 4294967295U + +/* This macro used to tell whether Python was built with multithreading + * enabled. Now multithreading is always enabled, but keep the macro + * for compatibility. + */ +#ifndef WITH_THREAD +# define WITH_THREAD +#endif + +/* Some WebAssembly platforms do not provide a working pthread implementation. + * Thread support is stubbed and any attempt to create a new thread fails. + */ +#if (!defined(HAVE_PTHREAD_STUBS) && \ + (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__))) +# define Py_CAN_START_THREADS 1 +#endif + +#ifdef WITH_THREAD +# ifdef Py_BUILD_CORE +# ifdef HAVE_THREAD_LOCAL +# error "HAVE_THREAD_LOCAL is already defined" +# endif +# define HAVE_THREAD_LOCAL 1 +# ifdef thread_local +# define _Py_thread_local thread_local +# elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) +# define _Py_thread_local _Thread_local +# elif defined(_MSC_VER) /* AKA NT_THREADS */ +# define _Py_thread_local __declspec(thread) +# elif defined(__GNUC__) /* includes clang */ +# define _Py_thread_local __thread +# else + // fall back to the PyThread_tss_*() API, or ignore. +# undef HAVE_THREAD_LOCAL +# endif +# endif +#endif + +#if defined(__ANDROID__) || defined(__VXWORKS__) + // Use UTF-8 as the locale encoding, ignore the LC_CTYPE locale. + // See _Py_GetLocaleEncoding(), PyUnicode_DecodeLocale() + // and PyUnicode_EncodeLocale(). +# define _Py_FORCE_UTF8_LOCALE +#endif + +#if defined(_Py_FORCE_UTF8_LOCALE) || defined(__APPLE__) + // Use UTF-8 as the filesystem encoding. + // See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(), + // Py_DecodeLocale() and Py_EncodeLocale(). +# define _Py_FORCE_UTF8_FS_ENCODING +#endif + +/* Mark a function which cannot return. Example: + PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void); + + XLC support is intentionally omitted due to bpo-40244 */ +#ifndef _Py_NO_RETURN +#if defined(__clang__) || \ + (defined(__GNUC__) && \ + ((__GNUC__ >= 3) || \ + (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))) +# define _Py_NO_RETURN __attribute__((__noreturn__)) +#elif defined(_MSC_VER) +# define _Py_NO_RETURN __declspec(noreturn) +#else +# define _Py_NO_RETURN +#endif +#endif + + +// Preprocessor check for a builtin preprocessor function. Always return 0 +// if __has_builtin() macro is not defined. +// +// __has_builtin() is available on clang and GCC 10. +#ifdef __has_builtin +# define _Py__has_builtin(x) __has_builtin(x) +#else +# define _Py__has_builtin(x) 0 +#endif + +// Preprocessor check for a compiler __attribute__. Always return 0 +// if __has_attribute() macro is not defined. +#ifdef __has_attribute +# define _Py__has_attribute(x) __has_attribute(x) +#else +# define _Py__has_attribute(x) 0 +#endif + +// _Py_TYPEOF(expr) gets the type of an expression. +// +// Example: _Py_TYPEOF(x) x_copy = (x); +// +// The macro is only defined if GCC or clang compiler is used. +#if defined(__GNUC__) || defined(__clang__) +# define _Py_TYPEOF(expr) __typeof__(expr) +#endif + + +/* A convenient way for code to know if sanitizers are enabled. */ +#if defined(__has_feature) +# if __has_feature(memory_sanitizer) +# if !defined(_Py_MEMORY_SANITIZER) +# define _Py_MEMORY_SANITIZER +# endif +# endif +# if __has_feature(address_sanitizer) +# if !defined(_Py_ADDRESS_SANITIZER) +# define _Py_ADDRESS_SANITIZER +# endif +# endif +# if __has_feature(thread_sanitizer) +# if !defined(_Py_THREAD_SANITIZER) +# define _Py_THREAD_SANITIZER +# endif +# endif +#elif defined(__GNUC__) +# if defined(__SANITIZE_ADDRESS__) +# define _Py_ADDRESS_SANITIZER +# endif +# if defined(__SANITIZE_THREAD__) +# define _Py_THREAD_SANITIZER +# endif +#endif + + +/* AIX has __bool__ redefined in it's system header file. */ +#if defined(_AIX) && defined(__bool__) +#undef __bool__ +#endif + +// Make sure we have maximum alignment, even if the current compiler +// does not support max_align_t. Note that: +// - Autoconf reports alignment of unknown types to 0. +// - 'long double' has maximum alignment on *most* platforms, +// looks like the best we can do for pre-C11 compilers. +// - The value is tested, see test_alignof_max_align_t +#if !defined(ALIGNOF_MAX_ALIGN_T) || ALIGNOF_MAX_ALIGN_T == 0 +# undef ALIGNOF_MAX_ALIGN_T +# define ALIGNOF_MAX_ALIGN_T _Alignof(long double) +#endif + +#ifndef PY_CXX_CONST +# ifdef __cplusplus +# define PY_CXX_CONST const +# else +# define PY_CXX_CONST +# endif +#endif + +#if defined(__sgi) && !defined(_SGI_MP_SOURCE) +# define _SGI_MP_SOURCE +#endif + + +// _Py_NONSTRING: The nonstring variable attribute specifies that an object or +// member declaration with type array of char, signed char, or unsigned char, +// or pointer to such a type is intended to store character arrays that do not +// necessarily contain a terminating NUL. +// +// Usage: +// +// char name [8] _Py_NONSTRING; +#if _Py__has_attribute(nonstring) +# define _Py_NONSTRING __attribute__((nonstring)) +#else +# define _Py_NONSTRING +#endif + + +#endif /* Py_PYPORT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pystate.h b/illumos-x86_64/usr/include/python3.13/pystate.h new file mode 100644 index 00000000..727b8fbf --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pystate.h @@ -0,0 +1,132 @@ +/* Thread and interpreter state structures and their interfaces */ + + +#ifndef Py_PYSTATE_H +#define Py_PYSTATE_H +#ifdef __cplusplus +extern "C" { +#endif + +/* This limitation is for performance and simplicity. If needed it can be +removed (with effort). */ +#define MAX_CO_EXTRA_USERS 255 + +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void); +PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *); +PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 +/* New in 3.9 */ +/* Get the current interpreter state. + + Issue a fatal error if there no current Python thread state or no current + interpreter. It cannot return NULL. + + The caller must hold the GIL. */ +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Get(void); +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000 +/* New in 3.8 */ +PyAPI_FUNC(PyObject *) PyInterpreterState_GetDict(PyInterpreterState *); +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 +/* New in 3.7 */ +PyAPI_FUNC(int64_t) PyInterpreterState_GetID(PyInterpreterState *); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 + +/* State unique per thread */ + +/* New in 3.3 */ +PyAPI_FUNC(int) PyState_AddModule(PyObject*, PyModuleDef*); +PyAPI_FUNC(int) PyState_RemoveModule(PyModuleDef*); +#endif +PyAPI_FUNC(PyObject*) PyState_FindModule(PyModuleDef*); + +PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *); +PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *); +PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *); + +/* Get the current thread state. + + When the current thread state is NULL, this issues a fatal error (so that + the caller needn't check for NULL). + + The caller must hold the GIL. + + See also PyThreadState_GetUnchecked() and _PyThreadState_GET(). */ +PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); + +// Alias to PyThreadState_Get() +#define PyThreadState_GET() PyThreadState_Get() + +PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *); +PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void); +PyAPI_FUNC(int) PyThreadState_SetAsyncExc(unsigned long, PyObject *); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 +/* New in 3.9 */ +PyAPI_FUNC(PyInterpreterState*) PyThreadState_GetInterpreter(PyThreadState *tstate); +PyAPI_FUNC(PyFrameObject*) PyThreadState_GetFrame(PyThreadState *tstate); +PyAPI_FUNC(uint64_t) PyThreadState_GetID(PyThreadState *tstate); +#endif + +typedef + enum {PyGILState_LOCKED, PyGILState_UNLOCKED} + PyGILState_STATE; + + +/* Ensure that the current thread is ready to call the Python + C API, regardless of the current state of Python, or of its + thread lock. This may be called as many times as desired + by a thread so long as each call is matched with a call to + PyGILState_Release(). In general, other thread-state APIs may + be used between _Ensure() and _Release() calls, so long as the + thread-state is restored to its previous state before the Release(). + For example, normal use of the Py_BEGIN_ALLOW_THREADS/ + Py_END_ALLOW_THREADS macros are acceptable. + + The return value is an opaque "handle" to the thread state when + PyGILState_Ensure() was called, and must be passed to + PyGILState_Release() to ensure Python is left in the same state. Even + though recursive calls are allowed, these handles can *not* be shared - + each unique call to PyGILState_Ensure must save the handle for its + call to PyGILState_Release. + + When the function returns, the current thread will hold the GIL. + + Failure is a fatal error. +*/ +PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void); + +/* Release any resources previously acquired. After this call, Python's + state will be the same as it was prior to the corresponding + PyGILState_Ensure() call (but generally this state will be unknown to + the caller, hence the use of the GILState API.) + + Every call to PyGILState_Ensure must be matched by a call to + PyGILState_Release on the same thread. +*/ +PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE); + +/* Helper/diagnostic function - get the current thread state for + this thread. May return NULL if no GILState API has been used + on the current thread. Note that the main thread always has such a + thread-state, even if no auto-thread-state call has been made + on the main thread. +*/ +PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void); + + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_PYSTATE_H +# include "cpython/pystate.h" +# undef Py_CPYTHON_PYSTATE_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYSTATE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pystats.h b/illumos-x86_64/usr/include/python3.13/pystats.h new file mode 100644 index 00000000..acfa3220 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pystats.h @@ -0,0 +1,26 @@ +// Statistics on Python performance (public API). +// +// Define _Py_INCREF_STAT_INC() and _Py_DECREF_STAT_INC() used by Py_INCREF() +// and Py_DECREF(). +// +// See Include/cpython/pystats.h for the full API. + +#ifndef Py_PYSTATS_H +#define Py_PYSTATS_H +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(Py_STATS) && !defined(Py_LIMITED_API) +# define Py_CPYTHON_PYSTATS_H +# include "cpython/pystats.h" +# undef Py_CPYTHON_PYSTATS_H +#else +# define _Py_INCREF_STAT_INC() ((void)0) +# define _Py_DECREF_STAT_INC() ((void)0) +#endif // !Py_STATS + +#ifdef __cplusplus +} +#endif +#endif // !Py_PYSTATS_H diff --git a/illumos-x86_64/usr/include/python3.13/pystrcmp.h b/illumos-x86_64/usr/include/python3.13/pystrcmp.h new file mode 100644 index 00000000..edb12397 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pystrcmp.h @@ -0,0 +1,23 @@ +#ifndef Py_STRCMP_H +#define Py_STRCMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t); +PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *); + +#ifdef MS_WINDOWS +#define PyOS_strnicmp strnicmp +#define PyOS_stricmp stricmp +#else +#define PyOS_strnicmp PyOS_mystrnicmp +#define PyOS_stricmp PyOS_mystricmp +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRCMP_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pystrtod.h b/illumos-x86_64/usr/include/python3.13/pystrtod.h new file mode 100644 index 00000000..e83d245e --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pystrtod.h @@ -0,0 +1,37 @@ +#ifndef Py_STRTOD_H +#define Py_STRTOD_H + +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_FUNC(double) PyOS_string_to_double(const char *str, + char **endptr, + PyObject *overflow_exception); + +/* The caller is responsible for calling PyMem_Free to free the buffer + that's is returned. */ +PyAPI_FUNC(char *) PyOS_double_to_string(double val, + char format_code, + int precision, + int flags, + int *type); + +/* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */ +#define Py_DTSF_SIGN 0x01 /* always add the sign */ +#define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */ +#define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code + specific */ +#define Py_DTSF_NO_NEG_0 0x08 /* negative zero result is coerced to 0 */ + +/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */ +#define Py_DTST_FINITE 0 +#define Py_DTST_INFINITE 1 +#define Py_DTST_NAN 2 + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRTOD_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pythonrun.h b/illumos-x86_64/usr/include/python3.13/pythonrun.h new file mode 100644 index 00000000..154c7450 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pythonrun.h @@ -0,0 +1,49 @@ + +/* Interfaces to parse and execute pieces of python code */ + +#ifndef Py_PYTHONRUN_H +#define Py_PYTHONRUN_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int); + +PyAPI_FUNC(void) PyErr_Print(void); +PyAPI_FUNC(void) PyErr_PrintEx(int); +PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 +PyAPI_FUNC(void) PyErr_DisplayException(PyObject *); +#endif + + +/* Stuff with no proper home (yet) */ +PyAPI_DATA(int) (*PyOS_InputHook)(void); + +/* Stack size, in "pointers" (so we get extra safety margins + on 64-bit platforms). On a 32-bit platform, this translates + to an 8k margin. */ +#define PYOS_STACK_MARGIN 2048 + +#if defined(WIN32) && !defined(MS_WIN64) && !defined(_M_ARM) && defined(_MSC_VER) && _MSC_VER >= 1300 +/* Enable stack checking under Microsoft C */ +// When changing the platforms, ensure PyOS_CheckStack() docs are still correct +#define USE_STACKCHECK +#endif + +#ifdef USE_STACKCHECK +/* Check that we aren't overflowing our stack */ +PyAPI_FUNC(int) PyOS_CheckStack(void); +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_PYTHONRUN_H +# include "cpython/pythonrun.h" +# undef Py_CPYTHON_PYTHONRUN_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYTHONRUN_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pythread.h b/illumos-x86_64/usr/include/python3.13/pythread.h new file mode 100644 index 00000000..a3216c51 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pythread.h @@ -0,0 +1,112 @@ +#ifndef Py_PYTHREAD_H +#define Py_PYTHREAD_H + +typedef void *PyThread_type_lock; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Return status codes for Python lock acquisition. Chosen for maximum + * backwards compatibility, ie failure -> 0, success -> 1. */ +typedef enum PyLockStatus { + PY_LOCK_FAILURE = 0, + PY_LOCK_ACQUIRED = 1, + PY_LOCK_INTR +} PyLockStatus; + +PyAPI_FUNC(void) PyThread_init_thread(void); +PyAPI_FUNC(unsigned long) PyThread_start_new_thread(void (*)(void *), void *); +PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void); +PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void); + +#if (defined(__APPLE__) || defined(__linux__) || defined(_WIN32) \ + || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ + || defined(__OpenBSD__) || defined(__NetBSD__) \ + || defined(__DragonFly__) || defined(_AIX)) +#define PY_HAVE_THREAD_NATIVE_ID +PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void); +#endif + +PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); +PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); +PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); +#define WAIT_LOCK 1 +#define NOWAIT_LOCK 0 + +// PY_TIMEOUT_T is the integral type used to specify timeouts when waiting +// on a lock (see PyThread_acquire_lock_timed() below). +#define PY_TIMEOUT_T long long + + +/* If microseconds == 0, the call is non-blocking: it returns immediately + even when the lock can't be acquired. + If microseconds > 0, the call waits up to the specified duration. + If microseconds < 0, the call waits until success (or abnormal failure) + + If *microseconds* is greater than PY_TIMEOUT_MAX, clamp the timeout to + PY_TIMEOUT_MAX microseconds. + + If intr_flag is true and the acquire is interrupted by a signal, then the + call will return PY_LOCK_INTR. The caller may reattempt to acquire the + lock. +*/ +PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock, + PY_TIMEOUT_T microseconds, + int intr_flag); + +PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); + +PyAPI_FUNC(size_t) PyThread_get_stacksize(void); +PyAPI_FUNC(int) PyThread_set_stacksize(size_t); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject*) PyThread_GetInfo(void); +#endif + + +/* Thread Local Storage (TLS) API + TLS API is DEPRECATED. Use Thread Specific Storage (TSS) API. + + The existing TLS API has used int to represent TLS keys across all + platforms, but it is not POSIX-compliant. Therefore, the new TSS API uses + opaque data type to represent TSS keys to be compatible (see PEP 539). +*/ +Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_create_key(void); +Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key(int key); +Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_set_key_value(int key, + void *value); +Py_DEPRECATED(3.7) PyAPI_FUNC(void *) PyThread_get_key_value(int key); +Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key_value(int key); + +/* Cleanup after a fork */ +Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_ReInitTLS(void); + + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 +/* New in 3.7 */ +/* Thread Specific Storage (TSS) API */ + +typedef struct _Py_tss_t Py_tss_t; /* opaque */ + +PyAPI_FUNC(Py_tss_t *) PyThread_tss_alloc(void); +PyAPI_FUNC(void) PyThread_tss_free(Py_tss_t *key); + +/* The parameter key must not be NULL. */ +PyAPI_FUNC(int) PyThread_tss_is_created(Py_tss_t *key); +PyAPI_FUNC(int) PyThread_tss_create(Py_tss_t *key); +PyAPI_FUNC(void) PyThread_tss_delete(Py_tss_t *key); +PyAPI_FUNC(int) PyThread_tss_set(Py_tss_t *key, void *value); +PyAPI_FUNC(void *) PyThread_tss_get(Py_tss_t *key); +#endif /* New in 3.7 */ + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_PYTHREAD_H +# include "cpython/pythread.h" +# undef Py_CPYTHON_PYTHREAD_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYTHREAD_H */ diff --git a/illumos-x86_64/usr/include/python3.13/pytypedefs.h b/illumos-x86_64/usr/include/python3.13/pytypedefs.h new file mode 100644 index 00000000..e78ed56a --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/pytypedefs.h @@ -0,0 +1,30 @@ +// Forward declarations of types of the Python C API. +// Declare them at the same place since redefining typedef is a C11 feature. +// Only use a forward declaration if there is an interdependency between two +// header files. + +#ifndef Py_PYTYPEDEFS_H +#define Py_PYTYPEDEFS_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct PyModuleDef PyModuleDef; +typedef struct PyModuleDef_Slot PyModuleDef_Slot; +typedef struct PyMethodDef PyMethodDef; +typedef struct PyGetSetDef PyGetSetDef; +typedef struct PyMemberDef PyMemberDef; + +typedef struct _object PyObject; +typedef struct _longobject PyLongObject; +typedef struct _typeobject PyTypeObject; +typedef struct PyCodeObject PyCodeObject; +typedef struct _frame PyFrameObject; + +typedef struct _ts PyThreadState; +typedef struct _is PyInterpreterState; + +#ifdef __cplusplus +} +#endif +#endif // !Py_PYTYPEDEFS_H diff --git a/illumos-x86_64/usr/include/python3.13/rangeobject.h b/illumos-x86_64/usr/include/python3.13/rangeobject.h new file mode 100644 index 00000000..d46ce7cd --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/rangeobject.h @@ -0,0 +1,27 @@ + +/* Range object interface */ + +#ifndef Py_RANGEOBJECT_H +#define Py_RANGEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* +A range object represents an integer range. This is an immutable object; +a range cannot change its value after creation. + +Range objects behave like the corresponding tuple objects except that +they are represented by a start, stop, and step datamembers. +*/ + +PyAPI_DATA(PyTypeObject) PyRange_Type; +PyAPI_DATA(PyTypeObject) PyRangeIter_Type; +PyAPI_DATA(PyTypeObject) PyLongRangeIter_Type; + +#define PyRange_Check(op) Py_IS_TYPE((op), &PyRange_Type) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_RANGEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/setobject.h b/illumos-x86_64/usr/include/python3.13/setobject.h new file mode 100644 index 00000000..62c9e6b1 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/setobject.h @@ -0,0 +1,49 @@ +/* Set object interface */ + +#ifndef Py_SETOBJECT_H +#define Py_SETOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PySet_Type; +PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; +PyAPI_DATA(PyTypeObject) PySetIter_Type; + +PyAPI_FUNC(PyObject *) PySet_New(PyObject *); +PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); + +PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key); +PyAPI_FUNC(int) PySet_Clear(PyObject *set); +PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key); +PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key); +PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set); +PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset); + +#define PyFrozenSet_CheckExact(ob) Py_IS_TYPE((ob), &PyFrozenSet_Type) +#define PyFrozenSet_Check(ob) \ + (Py_IS_TYPE((ob), &PyFrozenSet_Type) || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) + +#define PyAnySet_CheckExact(ob) \ + (Py_IS_TYPE((ob), &PySet_Type) || Py_IS_TYPE((ob), &PyFrozenSet_Type)) +#define PyAnySet_Check(ob) \ + (Py_IS_TYPE((ob), &PySet_Type) || Py_IS_TYPE((ob), &PyFrozenSet_Type) || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) + +#define PySet_CheckExact(op) Py_IS_TYPE(op, &PySet_Type) +#define PySet_Check(ob) \ + (Py_IS_TYPE((ob), &PySet_Type) || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_SETOBJECT_H +# include "cpython/setobject.h" +# undef Py_CPYTHON_SETOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SETOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/sliceobject.h b/illumos-x86_64/usr/include/python3.13/sliceobject.h new file mode 100644 index 00000000..35e2ea25 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/sliceobject.h @@ -0,0 +1,69 @@ +#ifndef Py_SLICEOBJECT_H +#define Py_SLICEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* The unique ellipsis object "..." */ + +PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */ + +#if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000 +# define Py_Ellipsis Py_GetConstantBorrowed(Py_CONSTANT_ELLIPSIS) +#else +# define Py_Ellipsis (&_Py_EllipsisObject) +#endif + +/* Slice object interface */ + +/* + +A slice object containing start, stop, and step data members (the +names are from range). After much talk with Guido, it was decided to +let these be any arbitrary python type. Py_None stands for omitted values. +*/ +#ifndef Py_LIMITED_API +typedef struct { + PyObject_HEAD + PyObject *start, *stop, *step; /* not NULL */ +} PySliceObject; +#endif + +PyAPI_DATA(PyTypeObject) PySlice_Type; +PyAPI_DATA(PyTypeObject) PyEllipsis_Type; + +#define PySlice_Check(op) Py_IS_TYPE((op), &PySlice_Type) + +PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, + PyObject* step); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop); +PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length, + PyObject **start_ptr, PyObject **stop_ptr, + PyObject **step_ptr); +#endif +PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); +Py_DEPRECATED(3.7) +PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, + Py_ssize_t *step, + Py_ssize_t *slicelength); + +#if !defined(Py_LIMITED_API) || (Py_LIMITED_API+0 >= 0x03050400 && Py_LIMITED_API+0 < 0x03060000) || Py_LIMITED_API+0 >= 0x03060100 +#define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \ + PySlice_Unpack((slice), (start), (stop), (step)) < 0 ? \ + ((*(slicelen) = 0), -1) : \ + ((*(slicelen) = PySlice_AdjustIndices((length), (start), (stop), *(step))), \ + 0)) +PyAPI_FUNC(int) PySlice_Unpack(PyObject *slice, + Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); +PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, + Py_ssize_t step); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SLICEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/structmember.h b/illumos-x86_64/usr/include/python3.13/structmember.h new file mode 100644 index 00000000..f6e8fd82 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/structmember.h @@ -0,0 +1,56 @@ +#ifndef Py_STRUCTMEMBER_H +#define Py_STRUCTMEMBER_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Interface to map C struct members to Python object attributes + * + * This header is deprecated: new code should not use stuff from here. + * New definitions are in descrobject.h. + * + * However, there's nothing wrong with old code continuing to use it, + * and there's not much mainenance overhead in maintaining a few aliases. + * So, don't be too eager to convert old code. + * + * It uses names not prefixed with Py_. + * It is also *not* included from Python.h and must be included individually. + */ + +#include /* For offsetof (not always provided by Python.h) */ + +/* Types */ +#define T_SHORT Py_T_SHORT +#define T_INT Py_T_INT +#define T_LONG Py_T_LONG +#define T_FLOAT Py_T_FLOAT +#define T_DOUBLE Py_T_DOUBLE +#define T_STRING Py_T_STRING +#define T_OBJECT _Py_T_OBJECT +#define T_CHAR Py_T_CHAR +#define T_BYTE Py_T_BYTE +#define T_UBYTE Py_T_UBYTE +#define T_USHORT Py_T_USHORT +#define T_UINT Py_T_UINT +#define T_ULONG Py_T_ULONG +#define T_STRING_INPLACE Py_T_STRING_INPLACE +#define T_BOOL Py_T_BOOL +#define T_OBJECT_EX Py_T_OBJECT_EX +#define T_LONGLONG Py_T_LONGLONG +#define T_ULONGLONG Py_T_ULONGLONG +#define T_PYSSIZET Py_T_PYSSIZET +#define T_NONE _Py_T_NONE + +/* Flags */ +#define READONLY Py_READONLY +#define PY_AUDIT_READ Py_AUDIT_READ +#define READ_RESTRICTED Py_AUDIT_READ +#define PY_WRITE_RESTRICTED _Py_WRITE_RESTRICTED +#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRUCTMEMBER_H */ diff --git a/illumos-x86_64/usr/include/python3.13/structseq.h b/illumos-x86_64/usr/include/python3.13/structseq.h new file mode 100644 index 00000000..29e24fee --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/structseq.h @@ -0,0 +1,46 @@ + +/* Named tuple object interface */ + +#ifndef Py_STRUCTSEQ_H +#define Py_STRUCTSEQ_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct PyStructSequence_Field { + const char *name; + const char *doc; +} PyStructSequence_Field; + +typedef struct PyStructSequence_Desc { + const char *name; + const char *doc; + PyStructSequence_Field *fields; + int n_in_sequence; +} PyStructSequence_Desc; + +PyAPI_DATA(const char * const) PyStructSequence_UnnamedField; + +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, + PyStructSequence_Desc *desc); +PyAPI_FUNC(int) PyStructSequence_InitType2(PyTypeObject *type, + PyStructSequence_Desc *desc); +#endif +PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc); + +PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); + +PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*); +PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t); + +#ifndef Py_LIMITED_API +typedef PyTupleObject PyStructSequence; +#define PyStructSequence_SET_ITEM PyStructSequence_SetItem +#define PyStructSequence_GET_ITEM PyStructSequence_GetItem +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRUCTSEQ_H */ diff --git a/illumos-x86_64/usr/include/python3.13/sysmodule.h b/illumos-x86_64/usr/include/python3.13/sysmodule.h new file mode 100644 index 00000000..5a0af2e1 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/sysmodule.h @@ -0,0 +1,44 @@ +#ifndef Py_SYSMODULE_H +#define Py_SYSMODULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) PySys_GetObject(const char *); +PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *); + +Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **); +Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int); + +PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...); +PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...); + +Py_DEPRECATED(3.13) PyAPI_FUNC(void) PySys_ResetWarnOptions(void); + +PyAPI_FUNC(PyObject *) PySys_GetXOptions(void); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +PyAPI_FUNC(int) PySys_Audit( + const char *event, + const char *argFormat, + ...); + +PyAPI_FUNC(int) PySys_AuditTuple( + const char *event, + PyObject *args); +#endif + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_SYSMODULE_H +# include "cpython/sysmodule.h" +# undef Py_CPYTHON_SYSMODULE_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SYSMODULE_H */ diff --git a/illumos-x86_64/usr/include/python3.13/traceback.h b/illumos-x86_64/usr/include/python3.13/traceback.h new file mode 100644 index 00000000..2b40cc9f --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/traceback.h @@ -0,0 +1,26 @@ +#ifndef Py_TRACEBACK_H +#define Py_TRACEBACK_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Traceback interface */ + +PyAPI_FUNC(int) PyTraceBack_Here(PyFrameObject *); +PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *); + +/* Reveal traceback type so we can typecheck traceback objects */ +PyAPI_DATA(PyTypeObject) PyTraceBack_Type; +#define PyTraceBack_Check(v) Py_IS_TYPE((v), &PyTraceBack_Type) + + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_TRACEBACK_H +# include "cpython/traceback.h" +# undef Py_CPYTHON_TRACEBACK_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TRACEBACK_H */ diff --git a/illumos-x86_64/usr/include/python3.13/tupleobject.h b/illumos-x86_64/usr/include/python3.13/tupleobject.h new file mode 100644 index 00000000..1f9ab54b --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/tupleobject.h @@ -0,0 +1,46 @@ +/* Tuple object interface */ + +#ifndef Py_TUPLEOBJECT_H +#define Py_TUPLEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* +Another generally useful object type is a tuple of object pointers. +For Python, this is an immutable type. C code can change the tuple items +(but not their number), and even use tuples as general-purpose arrays of +object references, but in general only brand new tuples should be mutated, +not ones that might already have been exposed to Python code. + +*** WARNING *** PyTuple_SetItem does not increment the new item's reference +count, but does decrement the reference count of the item it replaces, +if not nil. It does *decrement* the reference count if it is *not* +inserted in the tuple. Similarly, PyTuple_GetItem does not increment the +returned item's reference count. +*/ + +PyAPI_DATA(PyTypeObject) PyTuple_Type; +PyAPI_DATA(PyTypeObject) PyTupleIter_Type; + +#define PyTuple_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) +#define PyTuple_CheckExact(op) Py_IS_TYPE((op), &PyTuple_Type) + +PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); +PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); +PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_TUPLEOBJECT_H +# include "cpython/tupleobject.h" +# undef Py_CPYTHON_TUPLEOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TUPLEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/typeslots.h b/illumos-x86_64/usr/include/python3.13/typeslots.h new file mode 100644 index 00000000..506b0558 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/typeslots.h @@ -0,0 +1,88 @@ +/* Do not renumber the file; these numbers are part of the stable ABI. */ +#define Py_bf_getbuffer 1 +#define Py_bf_releasebuffer 2 +#define Py_mp_ass_subscript 3 +#define Py_mp_length 4 +#define Py_mp_subscript 5 +#define Py_nb_absolute 6 +#define Py_nb_add 7 +#define Py_nb_and 8 +#define Py_nb_bool 9 +#define Py_nb_divmod 10 +#define Py_nb_float 11 +#define Py_nb_floor_divide 12 +#define Py_nb_index 13 +#define Py_nb_inplace_add 14 +#define Py_nb_inplace_and 15 +#define Py_nb_inplace_floor_divide 16 +#define Py_nb_inplace_lshift 17 +#define Py_nb_inplace_multiply 18 +#define Py_nb_inplace_or 19 +#define Py_nb_inplace_power 20 +#define Py_nb_inplace_remainder 21 +#define Py_nb_inplace_rshift 22 +#define Py_nb_inplace_subtract 23 +#define Py_nb_inplace_true_divide 24 +#define Py_nb_inplace_xor 25 +#define Py_nb_int 26 +#define Py_nb_invert 27 +#define Py_nb_lshift 28 +#define Py_nb_multiply 29 +#define Py_nb_negative 30 +#define Py_nb_or 31 +#define Py_nb_positive 32 +#define Py_nb_power 33 +#define Py_nb_remainder 34 +#define Py_nb_rshift 35 +#define Py_nb_subtract 36 +#define Py_nb_true_divide 37 +#define Py_nb_xor 38 +#define Py_sq_ass_item 39 +#define Py_sq_concat 40 +#define Py_sq_contains 41 +#define Py_sq_inplace_concat 42 +#define Py_sq_inplace_repeat 43 +#define Py_sq_item 44 +#define Py_sq_length 45 +#define Py_sq_repeat 46 +#define Py_tp_alloc 47 +#define Py_tp_base 48 +#define Py_tp_bases 49 +#define Py_tp_call 50 +#define Py_tp_clear 51 +#define Py_tp_dealloc 52 +#define Py_tp_del 53 +#define Py_tp_descr_get 54 +#define Py_tp_descr_set 55 +#define Py_tp_doc 56 +#define Py_tp_getattr 57 +#define Py_tp_getattro 58 +#define Py_tp_hash 59 +#define Py_tp_init 60 +#define Py_tp_is_gc 61 +#define Py_tp_iter 62 +#define Py_tp_iternext 63 +#define Py_tp_methods 64 +#define Py_tp_new 65 +#define Py_tp_repr 66 +#define Py_tp_richcompare 67 +#define Py_tp_setattr 68 +#define Py_tp_setattro 69 +#define Py_tp_str 70 +#define Py_tp_traverse 71 +#define Py_tp_members 72 +#define Py_tp_getset 73 +#define Py_tp_free 74 +#define Py_nb_matrix_multiply 75 +#define Py_nb_inplace_matrix_multiply 76 +#define Py_am_await 77 +#define Py_am_aiter 78 +#define Py_am_anext 79 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +#define Py_tp_finalize 80 +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +/* New in 3.10 */ +#define Py_am_send 81 +#endif diff --git a/illumos-x86_64/usr/include/python3.13/unicodeobject.h b/illumos-x86_64/usr/include/python3.13/unicodeobject.h new file mode 100644 index 00000000..e93034c2 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/unicodeobject.h @@ -0,0 +1,1026 @@ +#ifndef Py_UNICODEOBJECT_H +#define Py_UNICODEOBJECT_H + +/* + +Unicode implementation based on original code by Fredrik Lundh, +modified by Marc-Andre Lemburg (mal@lemburg.com) according to the +Unicode Integration Proposal. (See +http://www.egenix.com/files/python/unicode-proposal.txt). + +Copyright (c) Corporation for National Research Initiatives. + + + Original header: + -------------------------------------------------------------------- + + * Yet another Unicode string type for Python. This type supports the + * 16-bit Basic Multilingual Plane (BMP) only. + * + * Written by Fredrik Lundh, January 1999. + * + * Copyright (c) 1999 by Secret Labs AB. + * Copyright (c) 1999 by Fredrik Lundh. + * + * fredrik@pythonware.com + * http://www.pythonware.com + * + * -------------------------------------------------------------------- + * This Unicode String Type is + * + * Copyright (c) 1999 by Secret Labs AB + * Copyright (c) 1999 by Fredrik Lundh + * + * By obtaining, using, and/or copying this software and/or its + * associated documentation, you agree that you have read, understood, + * and will comply with the following terms and conditions: + * + * Permission to use, copy, modify, and distribute this software and its + * associated documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appears in all + * copies, and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Secret Labs + * AB or the author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * -------------------------------------------------------------------- */ + +/* === Internal API ======================================================= */ + +/* --- Internal Unicode Format -------------------------------------------- */ + +/* Python 3.x requires unicode */ +#define Py_USING_UNICODE + +#ifndef SIZEOF_WCHAR_T +#error Must define SIZEOF_WCHAR_T +#endif + +#define Py_UNICODE_SIZE SIZEOF_WCHAR_T + +/* If wchar_t can be used for UCS-4 storage, set Py_UNICODE_WIDE. + Otherwise, Unicode strings are stored as UCS-2 (with limited support + for UTF-16) */ + +#if Py_UNICODE_SIZE >= 4 +#define Py_UNICODE_WIDE +#endif + +/* Set these flags if the platform has "wchar.h" and the + wchar_t type is a 16-bit unsigned type */ +/* #define HAVE_WCHAR_H */ +/* #define HAVE_USABLE_WCHAR_T */ + +/* If the compiler provides a wchar_t type we try to support it + through the interface functions PyUnicode_FromWideChar(), + PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). */ + +#ifdef HAVE_USABLE_WCHAR_T +# ifndef HAVE_WCHAR_H +# define HAVE_WCHAR_H +# endif +#endif + +#if defined(__sun) && defined(__SVR4) +# include +# include +#endif + +/* Py_UCS4 and Py_UCS2 are typedefs for the respective + unicode representations. */ +typedef uint32_t Py_UCS4; +typedef uint16_t Py_UCS2; +typedef uint8_t Py_UCS1; + +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_DATA(PyTypeObject) PyUnicode_Type; +PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; + +#define PyUnicode_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) +#define PyUnicode_CheckExact(op) Py_IS_TYPE((op), &PyUnicode_Type) + +/* --- Constants ---------------------------------------------------------- */ + +/* This Unicode character will be used as replacement character during + decoding if the errors argument is set to "replace". Note: the + Unicode character U+FFFD is the official REPLACEMENT CHARACTER in + Unicode 3.0. */ + +#define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UCS4) 0xFFFD) + +/* === Public API ========================================================= */ + +/* Similar to PyUnicode_FromUnicode(), but u points to UTF-8 encoded bytes */ +PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize( + const char *u, /* UTF-8 encoded string */ + Py_ssize_t size /* size of buffer */ + ); + +/* Similar to PyUnicode_FromUnicode(), but u points to null-terminated + UTF-8 encoded bytes. The size is determined with strlen(). */ +PyAPI_FUNC(PyObject*) PyUnicode_FromString( + const char *u /* UTF-8 encoded string */ + ); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject*) PyUnicode_Substring( + PyObject *str, + Py_ssize_t start, + Py_ssize_t end); +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +/* Copy the string into a UCS4 buffer including the null character if copy_null + is set. Return NULL and raise an exception on error. Raise a SystemError if + the buffer is smaller than the string. Return buffer on success. + + buflen is the length of the buffer in (Py_UCS4) characters. */ +PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4( + PyObject *unicode, + Py_UCS4* buffer, + Py_ssize_t buflen, + int copy_null); + +/* Copy the string into a UCS4 buffer. A new buffer is allocated using + * PyMem_Malloc; if this fails, NULL is returned with a memory error + exception set. */ +PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4Copy(PyObject *unicode); +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +/* Get the length of the Unicode object. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_GetLength( + PyObject *unicode +); +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +/* Read a character from the string. */ + +PyAPI_FUNC(Py_UCS4) PyUnicode_ReadChar( + PyObject *unicode, + Py_ssize_t index + ); + +/* Write a character to the string. The string must have been created through + PyUnicode_New, must not be shared, and must not have been hashed yet. + + Return 0 on success, -1 on error. */ + +PyAPI_FUNC(int) PyUnicode_WriteChar( + PyObject *unicode, + Py_ssize_t index, + Py_UCS4 character + ); +#endif + +/* Resize a Unicode object. The length is the number of codepoints. + + *unicode is modified to point to the new (resized) object and 0 + returned on success. + + Try to resize the string in place (which is usually faster than allocating + a new string and copy characters), or create a new string. + + Error handling is implemented as follows: an exception is set, -1 + is returned and *unicode left untouched. + + WARNING: The function doesn't check string content, the result may not be a + string in canonical representation. */ + +PyAPI_FUNC(int) PyUnicode_Resize( + PyObject **unicode, /* Pointer to the Unicode object */ + Py_ssize_t length /* New length */ + ); + +/* Decode obj to a Unicode object. + + bytes, bytearray and other bytes-like objects are decoded according to the + given encoding and error handler. The encoding and error handler can be + NULL to have the interface use UTF-8 and "strict". + + All other objects (including Unicode objects) raise an exception. + + The API returns NULL in case of an error. The caller is responsible + for decref'ing the returned objects. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( + PyObject *obj, /* Object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Copy an instance of a Unicode subtype to a new true Unicode object if + necessary. If obj is already a true Unicode object (not a subtype), return + the reference with *incremented* refcount. + + The API returns NULL in case of an error. The caller is responsible + for decref'ing the returned objects. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromObject( + PyObject *obj /* Object */ + ); + +PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV( + const char *format, /* ASCII-encoded string */ + va_list vargs + ); +PyAPI_FUNC(PyObject *) PyUnicode_FromFormat( + const char *format, /* ASCII-encoded string */ + ... + ); + +PyAPI_FUNC(void) PyUnicode_InternInPlace(PyObject **); +PyAPI_FUNC(PyObject *) PyUnicode_InternFromString( + const char *u /* UTF-8 encoded string */ + ); + +/* --- wchar_t support for platforms which support it --------------------- */ + +#ifdef HAVE_WCHAR_H + +/* Create a Unicode Object from the wchar_t buffer w of the given + size. + + The buffer is copied into the new object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( + const wchar_t *w, /* wchar_t buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Copies the Unicode Object contents into the wchar_t buffer w. At + most size wchar_t characters are copied. + + Note that the resulting wchar_t string may or may not be + 0-terminated. It is the responsibility of the caller to make sure + that the wchar_t string is 0-terminated in case this is required by + the application. + + Returns the number of wchar_t characters copied (excluding a + possibly trailing 0-termination character) or -1 in case of an + error. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar( + PyObject *unicode, /* Unicode object */ + wchar_t *w, /* wchar_t buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Convert the Unicode object to a wide character string. The output string + always ends with a nul character. If size is not NULL, write the number of + wide characters (excluding the null character) into *size. + + Returns a buffer allocated by PyMem_Malloc() (use PyMem_Free() to free it) + on success. On error, returns NULL, *size is undefined and raises a + MemoryError. */ + +PyAPI_FUNC(wchar_t*) PyUnicode_AsWideCharString( + PyObject *unicode, /* Unicode object */ + Py_ssize_t *size /* number of characters of the result */ + ); + +#endif + +/* --- Unicode ordinals --------------------------------------------------- */ + +/* Create a Unicode Object from the given Unicode code point ordinal. + + The ordinal must be in range(0x110000). A ValueError is + raised in case it is not. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); + +/* === Builtin Codecs ===================================================== + + Many of these APIs take two arguments encoding and errors. These + parameters encoding and errors have the same semantics as the ones + of the builtin str() API. + + Setting encoding to NULL causes the default encoding (UTF-8) to be used. + + Error handling is set by errors which may also be set to NULL + meaning to use the default handling defined for the codec. Default + error handling for all builtin codecs is "strict" (ValueErrors are + raised). + + The codecs all use a similar interface. Only deviation from the + generic ones are documented. + +*/ + +/* --- Manage the default encoding ---------------------------------------- */ + +/* Returns "utf-8". */ +PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); + +/* --- Generic Codecs ----------------------------------------------------- */ + +/* Create a Unicode object by decoding the encoded string s of the + given size. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Decode( + const char *s, /* encoded string */ + Py_ssize_t size, /* size of buffer */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decode a Unicode object unicode and return the result as Python + object. + + This API is DEPRECATED. The only supported standard encoding is rot13. + Use PyCodec_Decode() to decode with rot13 and non-standard codecs + that decode from str. */ + +Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decode a Unicode object unicode and return the result as Unicode + object. + + This API is DEPRECATED. The only supported standard encoding is rot13. + Use PyCodec_Decode() to decode with rot13 and non-standard codecs + that decode from str to str. */ + +Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Python + object. + + This API is DEPRECATED. It is superseded by PyUnicode_AsEncodedString() + since all standard encodings (except rot13) encode str to bytes. + Use PyCodec_Encode() for encoding with rot13 and non-standard codecs + that encode form str to non-bytes. */ + +Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Python string + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Unicode + object. + + This API is DEPRECATED. The only supported standard encodings is rot13. + Use PyCodec_Encode() to encode with rot13 and non-standard codecs + that encode from str to str. */ + +Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Build an encoding map. */ + +PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( + PyObject* string /* 256 character map */ + ); + +/* --- UTF-7 Codecs ------------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( + const char *string, /* UTF-7 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful( + const char *string, /* UTF-7 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* --- UTF-8 Codecs ------------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( + const char *string, /* UTF-8 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful( + const char *string, /* UTF-8 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( + PyObject *unicode /* Unicode object */ + ); + +/* Returns a pointer to the default encoding (UTF-8) of the + Unicode object unicode and the size of the encoded representation + in bytes stored in *size. + + In case of an error, no *size is set. + + This function caches the UTF-8 encoded string in the unicodeobject + and subsequent calls will return the same string. The memory is released + when the unicodeobject is deallocated. +*/ + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +PyAPI_FUNC(const char *) PyUnicode_AsUTF8AndSize( + PyObject *unicode, + Py_ssize_t *size); +#endif + +/* --- UTF-32 Codecs ------------------------------------------------------ */ + +/* Decodes length bytes from a UTF-32 encoded buffer string and returns + the corresponding Unicode object. + + errors (if non-NULL) defines the error handling. It defaults + to "strict". + + If byteorder is non-NULL, the decoder starts decoding using the + given byte order: + + *byteorder == -1: little endian + *byteorder == 0: native order + *byteorder == 1: big endian + + In native mode, the first four bytes of the stream are checked for a + BOM mark. If found, the BOM mark is analysed, the byte order + adjusted and the BOM skipped. In the other modes, no BOM mark + interpretation is done. After completion, *byteorder is set to the + current byte order at the end of input data. + + If byteorder is NULL, the codec starts in native order mode. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32( + const char *string, /* UTF-32 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32Stateful( + const char *string, /* UTF-32 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder, /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* Returns a Python string using the UTF-32 encoding in native byte + order. The string always starts with a BOM mark. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String( + PyObject *unicode /* Unicode object */ + ); + +/* Returns a Python string object holding the UTF-32 encoded value of + the Unicode data. + + If byteorder is not 0, output is written according to the following + byte order: + + byteorder == -1: little endian + byteorder == 0: native byte order (writes a BOM mark) + byteorder == 1: big endian + + If byteorder is 0, the output string will always start with the + Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is + prepended. + +*/ + +/* --- UTF-16 Codecs ------------------------------------------------------ */ + +/* Decodes length bytes from a UTF-16 encoded buffer string and returns + the corresponding Unicode object. + + errors (if non-NULL) defines the error handling. It defaults + to "strict". + + If byteorder is non-NULL, the decoder starts decoding using the + given byte order: + + *byteorder == -1: little endian + *byteorder == 0: native order + *byteorder == 1: big endian + + In native mode, the first two bytes of the stream are checked for a + BOM mark. If found, the BOM mark is analysed, the byte order + adjusted and the BOM skipped. In the other modes, no BOM mark + interpretation is done. After completion, *byteorder is set to the + current byte order at the end of input data. + + If byteorder is NULL, the codec starts in native order mode. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( + const char *string, /* UTF-16 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful( + const char *string, /* UTF-16 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder, /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* Returns a Python string using the UTF-16 encoding in native byte + order. The string always starts with a BOM mark. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( + PyObject *unicode /* Unicode object */ + ); + +/* --- Unicode-Escape Codecs ---------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( + PyObject *unicode /* Unicode object */ + ); + +/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( + const char *string, /* Raw-Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( + PyObject *unicode /* Unicode object */ + ); + +/* --- Latin-1 Codecs ----------------------------------------------------- + + Note: Latin-1 corresponds to the first 256 Unicode ordinals. */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( + const char *string, /* Latin-1 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( + PyObject *unicode /* Unicode object */ + ); + +/* --- ASCII Codecs ------------------------------------------------------- + + Only 7-bit ASCII data is expected. All other codes generate errors. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( + const char *string, /* ASCII encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( + PyObject *unicode /* Unicode object */ + ); + +/* --- Character Map Codecs ----------------------------------------------- + + This codec uses mappings to encode and decode characters. + + Decoding mappings must map byte ordinals (integers in the range from 0 to + 255) to Unicode strings, integers (which are then interpreted as Unicode + ordinals) or None. Unmapped data bytes (ones which cause a LookupError) + as well as mapped to None, 0xFFFE or '\ufffe' are treated as "undefined + mapping" and cause an error. + + Encoding mappings must map Unicode ordinal integers to bytes objects, + integers in the range from 0 to 255 or None. Unmapped character + ordinals (ones which cause a LookupError) as well as mapped to + None are treated as "undefined mapping" and cause an error. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( + const char *string, /* Encoded string */ + Py_ssize_t length, /* size of string */ + PyObject *mapping, /* decoding mapping */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( + PyObject *unicode, /* Unicode object */ + PyObject *mapping /* encoding mapping */ + ); + +/* --- MBCS codecs for Windows -------------------------------------------- */ + +#ifdef MS_WINDOWS +PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( + const char *string, /* MBCS encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful( + const char *string, /* MBCS encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject*) PyUnicode_DecodeCodePageStateful( + int code_page, /* code page number */ + const char *string, /* encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); +#endif + +PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( + PyObject *unicode /* Unicode object */ + ); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject*) PyUnicode_EncodeCodePage( + int code_page, /* code page number */ + PyObject *unicode, /* Unicode object */ + const char *errors /* error handling */ + ); +#endif + +#endif /* MS_WINDOWS */ + +/* --- Locale encoding --------------------------------------------------- */ + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +/* Decode a string from the current locale encoding. The decoder is strict if + *surrogateescape* is equal to zero, otherwise it uses the 'surrogateescape' + error handler (PEP 383) to escape undecodable bytes. If a byte sequence can + be decoded as a surrogate character and *surrogateescape* is not equal to + zero, the byte sequence is escaped using the 'surrogateescape' error handler + instead of being decoded. *str* must end with a null character but cannot + contain embedded null characters. */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeLocaleAndSize( + const char *str, + Py_ssize_t len, + const char *errors); + +/* Similar to PyUnicode_DecodeLocaleAndSize(), but compute the string + length using strlen(). */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeLocale( + const char *str, + const char *errors); + +/* Encode a Unicode object to the current locale encoding. The encoder is + strict is *surrogateescape* is equal to zero, otherwise the + "surrogateescape" error handler is used. Return a bytes object. The string + cannot contain embedded null characters. */ + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeLocale( + PyObject *unicode, + const char *errors + ); +#endif + +/* --- File system encoding ---------------------------------------------- */ + +/* ParseTuple converter: encode str objects to bytes using + PyUnicode_EncodeFSDefault(); bytes objects are output as-is. */ + +PyAPI_FUNC(int) PyUnicode_FSConverter(PyObject*, void*); + +/* ParseTuple converter: decode bytes objects to unicode using + PyUnicode_DecodeFSDefaultAndSize(); str objects are output as-is. */ + +PyAPI_FUNC(int) PyUnicode_FSDecoder(PyObject*, void*); + +/* Decode a null-terminated string from the Python filesystem encoding + and error handler. + + If the string length is known, use PyUnicode_DecodeFSDefaultAndSize(). */ +PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefault( + const char *s /* encoded string */ + ); + +/* Decode a string from the Python filesystem encoding and error handler. */ +PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefaultAndSize( + const char *s, /* encoded string */ + Py_ssize_t size /* size */ + ); + +/* Encode a Unicode object to the Python filesystem encoding and error handler. + Return bytes. */ +PyAPI_FUNC(PyObject*) PyUnicode_EncodeFSDefault( + PyObject *unicode + ); + +/* --- Methods & Slots ---------------------------------------------------- + + These are capable of handling Unicode objects and strings on input + (we refer to them as strings in the descriptions) and return + Unicode objects or integers as appropriate. */ + +/* Concat two strings giving a new Unicode string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Concat( + PyObject *left, /* Left string */ + PyObject *right /* Right string */ + ); + +/* Concat two strings and put the result in *pleft + (sets *pleft to NULL on error) */ + +PyAPI_FUNC(void) PyUnicode_Append( + PyObject **pleft, /* Pointer to left string */ + PyObject *right /* Right string */ + ); + +/* Concat two strings, put the result in *pleft and drop the right object + (sets *pleft to NULL on error) */ + +PyAPI_FUNC(void) PyUnicode_AppendAndDel( + PyObject **pleft, /* Pointer to left string */ + PyObject *right /* Right string */ + ); + +/* Split a string giving a list of Unicode strings. + + If sep is NULL, splitting will be done at all whitespace + substrings. Otherwise, splits occur at the given separator. + + At most maxsplit splits will be done. If negative, no limit is set. + + Separators are not included in the resulting list. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_Split( + PyObject *s, /* String to split */ + PyObject *sep, /* String separator */ + Py_ssize_t maxsplit /* Maxsplit count */ + ); + +/* Dito, but split at line breaks. + + CRLF is considered to be one line break. Line breaks are not + included in the resulting list. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( + PyObject *s, /* String to split */ + int keepends /* If true, line end markers are included */ + ); + +/* Partition a string using a given separator. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Partition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + +/* Partition a string using a given separator, searching from the end of the + string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_RPartition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + +/* Split a string giving a list of Unicode strings. + + If sep is NULL, splitting will be done at all whitespace + substrings. Otherwise, splits occur at the given separator. + + At most maxsplit splits will be done. But unlike PyUnicode_Split + PyUnicode_RSplit splits from the end of the string. If negative, + no limit is set. + + Separators are not included in the resulting list. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_RSplit( + PyObject *s, /* String to split */ + PyObject *sep, /* String separator */ + Py_ssize_t maxsplit /* Maxsplit count */ + ); + +/* Translate a string by applying a character mapping table to it and + return the resulting Unicode object. + + The mapping table must map Unicode ordinal integers to Unicode strings, + Unicode ordinal integers or None (causing deletion of the character). + + Mapping tables may be dictionaries or sequences. Unmapped character + ordinals (ones which cause a LookupError) are left untouched and + are copied as-is. + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_Translate( + PyObject *str, /* String */ + PyObject *table, /* Translate table */ + const char *errors /* error handling */ + ); + +/* Join a sequence of strings using the given separator and return + the resulting Unicode string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Join( + PyObject *separator, /* Separator string */ + PyObject *seq /* Sequence object */ + ); + +/* Return 1 if substr matches str[start:end] at the given tail end, 0 + otherwise. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch( + PyObject *str, /* String */ + PyObject *substr, /* Prefix or Suffix string */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end, /* Stop index */ + int direction /* Tail end: -1 prefix, +1 suffix */ + ); + +/* Return the first position of substr in str[start:end] using the + given search direction or -1 if not found. -2 is returned in case + an error occurred and an exception is set. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Find( + PyObject *str, /* String */ + PyObject *substr, /* Substring to find */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end, /* Stop index */ + int direction /* Find direction: +1 forward, -1 backward */ + ); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +/* Like PyUnicode_Find, but search for single character only. */ +PyAPI_FUNC(Py_ssize_t) PyUnicode_FindChar( + PyObject *str, + Py_UCS4 ch, + Py_ssize_t start, + Py_ssize_t end, + int direction + ); +#endif + +/* Count the number of occurrences of substr in str[start:end]. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Count( + PyObject *str, /* String */ + PyObject *substr, /* Substring to count */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end /* Stop index */ + ); + +/* Replace at most maxcount occurrences of substr in str with replstr + and return the resulting Unicode object. */ + +PyAPI_FUNC(PyObject *) PyUnicode_Replace( + PyObject *str, /* String */ + PyObject *substr, /* Substring to find */ + PyObject *replstr, /* Substring to replace */ + Py_ssize_t maxcount /* Max. number of replacements to apply; + -1 = all */ + ); + +/* Compare two strings and return -1, 0, 1 for less than, equal, + greater than resp. + Raise an exception and return -1 on error. */ + +PyAPI_FUNC(int) PyUnicode_Compare( + PyObject *left, /* Left string */ + PyObject *right /* Right string */ + ); + +/* Compare a Unicode object with C string and return -1, 0, 1 for less than, + equal, and greater than, respectively. It is best to pass only + ASCII-encoded strings, but the function interprets the input string as + ISO-8859-1 if it contains non-ASCII characters. + This function does not raise exceptions. */ + +PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString( + PyObject *left, + const char *right /* ASCII-encoded string */ + ); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +/* Compare a Unicode object with UTF-8 encoded C string. + Return 1 if they are equal, or 0 otherwise. + This function does not raise exceptions. */ + +PyAPI_FUNC(int) PyUnicode_EqualToUTF8(PyObject *, const char *); +PyAPI_FUNC(int) PyUnicode_EqualToUTF8AndSize(PyObject *, const char *, Py_ssize_t); +#endif + +/* Rich compare two strings and return one of the following: + + - NULL in case an exception was raised + - Py_True or Py_False for successful comparisons + - Py_NotImplemented in case the type combination is unknown + + Possible values for op: + + Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( + PyObject *left, /* Left string */ + PyObject *right, /* Right string */ + int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ + ); + +/* Apply an argument tuple or dictionary to a format string and return + the resulting Unicode string. */ + +PyAPI_FUNC(PyObject *) PyUnicode_Format( + PyObject *format, /* Format string */ + PyObject *args /* Argument tuple or dictionary */ + ); + +/* Checks whether element is contained in container and return 1/0 + accordingly. + + element has to coerce to a one element Unicode string. -1 is + returned in case of an error. */ + +PyAPI_FUNC(int) PyUnicode_Contains( + PyObject *container, /* Container string */ + PyObject *element /* Element string */ + ); + +/* Checks whether argument is a valid identifier. */ + +PyAPI_FUNC(int) PyUnicode_IsIdentifier(PyObject *s); + +/* === Characters Type APIs =============================================== */ + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_UNICODEOBJECT_H +# include "cpython/unicodeobject.h" +# undef Py_CPYTHON_UNICODEOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_UNICODEOBJECT_H */ diff --git a/illumos-x86_64/usr/include/python3.13/warnings.h b/illumos-x86_64/usr/include/python3.13/warnings.h new file mode 100644 index 00000000..18ac1543 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/warnings.h @@ -0,0 +1,45 @@ +#ifndef Py_WARNINGS_H +#define Py_WARNINGS_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyErr_WarnEx( + PyObject *category, + const char *message, /* UTF-8 encoded string */ + Py_ssize_t stack_level); + +PyAPI_FUNC(int) PyErr_WarnFormat( + PyObject *category, + Py_ssize_t stack_level, + const char *format, /* ASCII-encoded string */ + ...); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000 +/* Emit a ResourceWarning warning */ +PyAPI_FUNC(int) PyErr_ResourceWarning( + PyObject *source, + Py_ssize_t stack_level, + const char *format, /* ASCII-encoded string */ + ...); +#endif + +PyAPI_FUNC(int) PyErr_WarnExplicit( + PyObject *category, + const char *message, /* UTF-8 encoded string */ + const char *filename, /* decoded from the filesystem encoding */ + int lineno, + const char *module, /* UTF-8 encoded string */ + PyObject *registry); + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_WARNINGS_H +# include "cpython/warnings.h" +# undef Py_CPYTHON_WARNINGS_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_WARNINGS_H */ + diff --git a/illumos-x86_64/usr/include/python3.13/weakrefobject.h b/illumos-x86_64/usr/include/python3.13/weakrefobject.h new file mode 100644 index 00000000..a6e71eb1 --- /dev/null +++ b/illumos-x86_64/usr/include/python3.13/weakrefobject.h @@ -0,0 +1,46 @@ +/* Weak references objects for Python. */ + +#ifndef Py_WEAKREFOBJECT_H +#define Py_WEAKREFOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _PyWeakReference PyWeakReference; + +PyAPI_DATA(PyTypeObject) _PyWeakref_RefType; +PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType; +PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; + +#define PyWeakref_CheckRef(op) PyObject_TypeCheck((op), &_PyWeakref_RefType) +#define PyWeakref_CheckRefExact(op) \ + Py_IS_TYPE((op), &_PyWeakref_RefType) +#define PyWeakref_CheckProxy(op) \ + (Py_IS_TYPE((op), &_PyWeakref_ProxyType) \ + || Py_IS_TYPE((op), &_PyWeakref_CallableProxyType)) + +#define PyWeakref_Check(op) \ + (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) + + +PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob, + PyObject *callback); +PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob, + PyObject *callback); +Py_DEPRECATED(3.13) PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000 +PyAPI_FUNC(int) PyWeakref_GetRef(PyObject *ref, PyObject **pobj); +#endif + + +#ifndef Py_LIMITED_API +# define Py_CPYTHON_WEAKREFOBJECT_H +# include "cpython/weakrefobject.h" +# undef Py_CPYTHON_WEAKREFOBJECT_H +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_WEAKREFOBJECT_H */ diff --git a/illumos-x86_64/usr/include/rcm_module.h b/illumos-x86_64/usr/include/rcm_module.h new file mode 100644 index 00000000..b06d64a9 --- /dev/null +++ b/illumos-x86_64/usr/include/rcm_module.h @@ -0,0 +1,141 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999-2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _RCM_MODULE_H +#define _RCM_MODULE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Each RCM module is required to define + * + * struct rcm_mod_ops *rcm_mod_init(); + * const char *rcm_mod_info(); + * int rcm_mod_fini(); + * + * The rcm_mod_init() is always invoked when the module is loaded. It should + * return an rcm_mod_ops vector. + * + * Once the module is loaded, the regis() entry point is + * called to allow the module to inform the framework all the + * events and devices it cares about. + * + * If at any point of time, the module has no outstanding registration + * against any device, the module will be unloaded. The rcm_mod_fini() + * entry point, if defined, is always invoked before module unloading. + */ + + +/* + * ops vector: + * The ops version must have a valid version number and all function fields + * must be non-NULL. Non-conforming RCM modules are rejected. + * + * Valid ops versions are defined below. + */ + +#define RCM_MOD_OPS_V1 1 +#define RCM_MOD_OPS_V2 2 +#define RCM_MOD_OPS_VERSION RCM_MOD_OPS_V2 + +struct rcm_mod_ops { + int version; + int (*rcmop_register)(rcm_handle_t *); + int (*rcmop_unregister)(rcm_handle_t *); + int (*rcmop_get_info)(rcm_handle_t *, char *, id_t, uint_t, + char **, char **, nvlist_t *, rcm_info_t **); + int (*rcmop_request_suspend)(rcm_handle_t *, char *, id_t, + timespec_t *, uint_t, char **, rcm_info_t **); + int (*rcmop_notify_resume)(rcm_handle_t *, char *, id_t, uint_t, + char **, rcm_info_t **); + int (*rcmop_request_offline)(rcm_handle_t *, char *, id_t, uint_t, + char **, rcm_info_t **); + int (*rcmop_notify_online)(rcm_handle_t *, char *, id_t, uint_t, + char **, rcm_info_t **); + int (*rcmop_notify_remove)(rcm_handle_t *, char *, id_t, uint_t, + char **, rcm_info_t **); + /* + * Fields for version 2 and beyond + */ + int (*rcmop_request_capacity_change)(rcm_handle_t *, char *, id_t, + uint_t, nvlist_t *, char **, rcm_info_t **); + int (*rcmop_notify_capacity_change)(rcm_handle_t *, char *, id_t, + uint_t, nvlist_t *, char **, rcm_info_t **); + int (*rcmop_notify_event)(rcm_handle_t *, char *, id_t, uint_t, + char **, nvlist_t *, rcm_info_t **); +}; + +/* + * Version 1 struct for compatibility + */ +struct rcm_mod_ops_v1 { + int version; + int (*rcmop_register)(rcm_handle_t *); + int (*rcmop_unregister)(rcm_handle_t *); + int (*rcmop_get_info)(rcm_handle_t *, char *, id_t, uint_t, char **, + rcm_info_t **); + int (*rcmop_request_suspend)(rcm_handle_t *, char *, id_t, + timespec_t *, uint_t, char **, rcm_info_t **); + int (*rcmop_notify_resume)(rcm_handle_t *, char *, id_t, uint_t, + char **, rcm_info_t **); + int (*rcmop_request_offline)(rcm_handle_t *, char *, id_t, uint_t, + char **, rcm_info_t **); + int (*rcmop_notify_online)(rcm_handle_t *, char *, id_t, uint_t, + char **, rcm_info_t **); + int (*rcmop_notify_remove)(rcm_handle_t *, char *, id_t, uint_t, + char **, rcm_info_t **); +}; + +/* + * RCM modules should use rcm_log_message() instead of syslog(). + * This allows the daemon to control the amount of message to be + * printed and to redirect output to screen for debugging purposes. + */ + +/* message levels for rcm_log_message */ + +#define RCM_ERROR 0 /* error message */ +#define RCM_WARNING 1 +#define RCM_NOTICE 2 +#define RCM_INFO 3 + /* 4 is not used for now */ +#define RCM_DEBUG 5 /* debug message */ +#define RCM_TRACE1 6 /* tracing message */ +#define RCM_TRACE2 7 +#define RCM_TRACE3 8 +#define RCM_TRACE4 9 + +extern void rcm_log_message(int, char *, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _RCM_MODULE_H */ diff --git a/illumos-x86_64/usr/include/rctl.h b/illumos-x86_64/usr/include/rctl.h new file mode 100644 index 00000000..c1ebc686 --- /dev/null +++ b/illumos-x86_64/usr/include/rctl.h @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _RCTL_H +#define _RCTL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int rctl_walk(int (*)(const char *, void *), void *); + +hrtime_t rctlblk_get_firing_time(rctlblk_t *); +uint_t rctlblk_get_global_action(rctlblk_t *); +uint_t rctlblk_get_global_flags(rctlblk_t *); +uint_t rctlblk_get_local_action(rctlblk_t *, int *); +uint_t rctlblk_get_local_flags(rctlblk_t *); +id_t rctlblk_get_recipient_pid(rctlblk_t *); +rctl_priv_t rctlblk_get_privilege(rctlblk_t *); +rctl_qty_t rctlblk_get_value(rctlblk_t *); +rctl_qty_t rctlblk_get_enforced_value(rctlblk_t *); + +void rctlblk_set_local_action(rctlblk_t *, uint_t, int); +void rctlblk_set_local_flags(rctlblk_t *, uint_t); +void rctlblk_set_recipient_pid(rctlblk_t *, id_t); +void rctlblk_set_privilege(rctlblk_t *, rctl_priv_t); +void rctlblk_set_value(rctlblk_t *, rctl_qty_t); + +size_t rctlblk_size(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _RCTL_H */ diff --git a/illumos-x86_64/usr/include/re_comp.h b/illumos-x86_64/usr/include/re_comp.h new file mode 100644 index 00000000..ebec3cae --- /dev/null +++ b/illumos-x86_64/usr/include/re_comp.h @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1995, 2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _RE_COMP_H +#define _RE_COMP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern char *re_comp(const char *); +extern int re_exec(const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _RE_COMP_H */ diff --git a/illumos-x86_64/usr/include/readline/chardefs.h b/illumos-x86_64/usr/include/readline/chardefs.h new file mode 100644 index 00000000..02f7e17e --- /dev/null +++ b/illumos-x86_64/usr/include/readline/chardefs.h @@ -0,0 +1,165 @@ +/* chardefs.h -- Character definitions for readline. */ + +/* Copyright (C) 1994-2021 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#ifndef _CHARDEFS_H_ +#define _CHARDEFS_H_ + +#include + +#if defined (HAVE_CONFIG_H) +# if defined (HAVE_STRING_H) +# include +# endif /* HAVE_STRING_H */ +# if defined (HAVE_STRINGS_H) +# include +# endif /* HAVE_STRINGS_H */ +#else +# include +#endif /* !HAVE_CONFIG_H */ + +#ifndef whitespace +#define whitespace(c) (((c) == ' ') || ((c) == '\t')) +#endif + +#ifdef CTRL +# undef CTRL +#endif +#ifdef UNCTRL +# undef UNCTRL +#endif + +/* Some character stuff. */ +#define control_character_threshold 0x020 /* Smaller than this is control. */ +#define control_character_mask 0x1f /* 0x20 - 1 */ +#define meta_character_threshold 0x07f /* Larger than this is Meta. */ +#define control_character_bit 0x40 /* 0x000000, must be off. */ +#define meta_character_bit 0x080 /* x0000000, must be on. */ +#define largest_char 255 /* Largest character value. */ + +#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0)) +#define META_CHAR(c) ((unsigned char)(c) > meta_character_threshold && (unsigned char)(c) <= largest_char) + +#define CTRL(c) ((c) & control_character_mask) +#define META(c) ((c) | meta_character_bit) + +#define UNMETA(c) ((c) & (~meta_character_bit)) +#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit)) + +#ifndef UCHAR_MAX +# define UCHAR_MAX 255 +#endif +#ifndef CHAR_MAX +# define CHAR_MAX 127 +#endif + +/* use this as a proxy for C89 */ +#if defined (HAVE_STDLIB_H) && defined (HAVE_STRING_H) +# define IN_CTYPE_DOMAIN(c) 1 +# define NON_NEGATIVE(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) ((c) >= 0 && (c) <= CHAR_MAX) +# define NON_NEGATIVE(c) ((unsigned char)(c) == (c)) +#endif + +#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) && !defined (__cplusplus) +# define isxdigit(c) (isdigit((unsigned char)(c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) +#endif + +/* Some systems define these; we want our definitions. */ +#undef ISPRINT + +/* Beware: these only work with single-byte ASCII characters. */ + +#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum ((unsigned char)c)) +#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha ((unsigned char)c)) +#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit ((unsigned char)c)) +#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower ((unsigned char)c)) +#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint ((unsigned char)c)) +#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper ((unsigned char)c)) +#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit ((unsigned char)c)) + +#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c)) +#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c)) +#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9') + +#define _rl_alphabetic_p(c) (NON_NEGATIVE(c) && ISALNUM(c)) +#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c)) + +#ifndef _rl_to_upper +# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)(c)) : (c)) +# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)(c)) : (c)) +#endif + +#ifndef _rl_digit_value +# define _rl_digit_value(x) ((x) - '0') +#endif + +#ifndef _rl_isident +# define _rl_isident(c) (ISALNUM(c) || (c) == '_') +#endif + +#ifndef ISOCTAL +# define ISOCTAL(c) ((c) >= '0' && (c) <= '7') +#endif +#define OCTVALUE(c) ((c) - '0') + +#define HEXVALUE(c) \ + (((c) >= 'a' && (c) <= 'f') \ + ? (c)-'a'+10 \ + : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0') + +#ifndef NEWLINE +#define NEWLINE '\n' +#endif + +#ifndef RETURN +#define RETURN CTRL('M') +#endif + +#ifndef RUBOUT +#define RUBOUT 0x7f +#endif + +#ifndef TAB +#define TAB '\t' +#endif + +#ifdef ABORT_CHAR +#undef ABORT_CHAR +#endif +#define ABORT_CHAR CTRL('G') + +#ifdef PAGE +#undef PAGE +#endif +#define PAGE CTRL('L') + +#ifdef SPACE +#undef SPACE +#endif +#define SPACE ' ' /* XXX - was 0x20 */ + +#ifdef ESC +#undef ESC +#endif +#define ESC CTRL('[') + +#endif /* _CHARDEFS_H_ */ diff --git a/illumos-x86_64/usr/include/readline/history.h b/illumos-x86_64/usr/include/readline/history.h new file mode 100644 index 00000000..4721e3a2 --- /dev/null +++ b/illumos-x86_64/usr/include/readline/history.h @@ -0,0 +1,291 @@ +/* history.h -- the names of functions that you can call in history. */ + +/* Copyright (C) 1989-2023 Free Software Foundation, Inc. + + This file contains the GNU History Library (History), a set of + routines for managing the text of previously typed lines. + + History is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + History is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with History. If not, see . +*/ + +#ifndef _HISTORY_H_ +#define _HISTORY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include /* XXX - for history timestamp code */ + +#if defined READLINE_LIBRARY +# include "rlstdc.h" +# include "rltypedefs.h" +#else +# include +# include +#endif + +typedef void *histdata_t; + +/* Let's not step on anyone else's define for now, since we don't use this yet. */ +#ifndef HS_HISTORY_VERSION +# define HS_HISTORY_VERSION 0x0803 /* History 8.3 */ +#endif + +/* The structure used to store a history entry. */ +typedef struct _hist_entry { + char *line; + char *timestamp; /* char * rather than time_t for read/write */ + histdata_t data; +} HIST_ENTRY; + +#ifndef HIST_ENTRY_DEFINED +# define HIST_ENTRY_DEFINED +#endif + +/* Size of the history-library-managed space in history entry HS. */ +#define HISTENT_BYTES(hs) (strlen ((hs)->line) + strlen ((hs)->timestamp)) + +/* A structure used to pass the current state of the history stuff around. */ +typedef struct _hist_state { + HIST_ENTRY **entries; /* Pointer to the entries themselves. */ + int offset; /* The location pointer within this array. */ + int length; /* Number of elements within this array. */ + int size; /* Number of slots allocated to this array. */ + int flags; +} HISTORY_STATE; + +/* Flag values for the `flags' member of HISTORY_STATE. */ +#define HS_STIFLED 0x01 + +/* Initialization and state management. */ + +/* Begin a session in which the history functions might be used. This + just initializes the interactive variables. */ +extern void using_history (void); + +/* Return the current HISTORY_STATE of the history. */ +extern HISTORY_STATE *history_get_history_state (void); + +/* Set the state of the current history array to STATE. */ +extern void history_set_history_state (HISTORY_STATE *); + +/* Manage the history list. */ + +/* Place STRING at the end of the history list. + The associated data field (if any) is set to NULL. */ +extern void add_history (const char *); + +/* Change the timestamp associated with the most recent history entry to + STRING. */ +extern void add_history_time (const char *); + +/* Remove an entry from the history list. WHICH is the magic number that + tells us which element to delete. The elements are numbered from 0. */ +extern HIST_ENTRY *remove_history (int); + +/* Remove a set of entries from the history list: FIRST to LAST, inclusive */ +extern HIST_ENTRY **remove_history_range (int, int); + +/* Allocate a history entry consisting of STRING and TIMESTAMP and return + a pointer to it. */ +extern HIST_ENTRY *alloc_history_entry (char *, char *); + +/* Copy the history entry H, but not the (opaque) data pointer */ +extern HIST_ENTRY *copy_history_entry (HIST_ENTRY *); + +/* Free the history entry H and return any application-specific data + associated with it. */ +extern histdata_t free_history_entry (HIST_ENTRY *); + +/* Make the history entry at WHICH have LINE and DATA. This returns + the old entry so you can dispose of the data. In the case of an + invalid WHICH, a NULL pointer is returned. */ +extern HIST_ENTRY *replace_history_entry (int, const char *, histdata_t); + +/* Clear the history list and start over. */ +extern void clear_history (void); + +/* Stifle the history list, remembering only MAX number of entries. */ +extern void stifle_history (int); + +/* Stop stifling the history. This returns the previous amount the + history was stifled by. The value is positive if the history was + stifled, negative if it wasn't. */ +extern int unstifle_history (void); + +/* Return 1 if the history is stifled, 0 if it is not. */ +extern int history_is_stifled (void); + +/* Information about the history list. */ + +/* Return a NULL terminated array of HIST_ENTRY which is the current input + history. Element 0 of this list is the beginning of time. If there + is no history, return NULL. */ +extern HIST_ENTRY **history_list (void); + +/* Returns the number which says what history element we are now + looking at. */ +extern int where_history (void); + +/* Return the history entry at the current position, as determined by + history_offset. If there is no entry there, return a NULL pointer. */ +extern HIST_ENTRY *current_history (void); + +/* Return the history entry which is logically at OFFSET in the history + array. OFFSET is relative to history_base. */ +extern HIST_ENTRY *history_get (int); + +/* Return the timestamp associated with the HIST_ENTRY * passed as an + argument */ +extern time_t history_get_time (HIST_ENTRY *); + +/* Return the number of bytes that the primary history entries are using. + This just adds up the lengths of the_history->lines. */ +extern int history_total_bytes (void); + +/* Moving around the history list. */ + +/* Set the position in the history list to POS. */ +extern int history_set_pos (int); + +/* Back up history_offset to the previous history entry, and return + a pointer to that entry. If there is no previous entry, return + a NULL pointer. */ +extern HIST_ENTRY *previous_history (void); + +/* Move history_offset forward to the next item in the input_history, + and return the a pointer to that entry. If there is no next entry, + return a NULL pointer. */ +extern HIST_ENTRY *next_history (void); + +/* Searching the history list. */ + +/* Search the history for STRING, starting at history_offset. + If DIRECTION < 0, then the search is through previous entries, + else through subsequent. If the string is found, then + current_history () is the history entry, and the value of this function + is the offset in the line of that history entry that the string was + found in. Otherwise, nothing is changed, and a -1 is returned. */ +extern int history_search (const char *, int); + +/* Search the history for STRING, starting at history_offset. + The search is anchored: matching lines must begin with string. + DIRECTION is as in history_search(). */ +extern int history_search_prefix (const char *, int); + +/* Search for STRING in the history list, starting at POS, an + absolute index into the list. DIR, if negative, says to search + backwards from POS, else forwards. + Returns the absolute index of the history element where STRING + was found, or -1 otherwise. */ +extern int history_search_pos (const char *, int, int); + +/* Managing the history file. */ + +/* Add the contents of FILENAME to the history list, a line at a time. + If FILENAME is NULL, then read from ~/.history. Returns 0 if + successful, or errno if not. */ +extern int read_history (const char *); + +/* Read a range of lines from FILENAME, adding them to the history list. + Start reading at the FROM'th line and end at the TO'th. If FROM + is zero, start at the beginning. If TO is less than FROM, read + until the end of the file. If FILENAME is NULL, then read from + ~/.history. Returns 0 if successful, or errno if not. */ +extern int read_history_range (const char *, int, int); + +/* Write the current history to FILENAME. If FILENAME is NULL, + then write the history list to ~/.history. Values returned + are as in read_history (). */ +extern int write_history (const char *); + +/* Append NELEMENT entries to FILENAME. The entries appended are from + the end of the list minus NELEMENTs up to the end of the list. */ +extern int append_history (int, const char *); + +/* Truncate the history file, leaving only the last NLINES lines. */ +extern int history_truncate_file (const char *, int); + +/* History expansion. */ + +/* Expand the string STRING, placing the result into OUTPUT, a pointer + to a string. Returns: + + 0) If no expansions took place (or, if the only change in + the text was the de-slashifying of the history expansion + character) + 1) If expansions did take place + -1) If there was an error in expansion. + 2) If the returned line should just be printed. + + If an error occurred in expansion, then OUTPUT contains a descriptive + error message. */ +extern int history_expand (const char *, char **); + +/* Extract a string segment consisting of the FIRST through LAST + arguments present in STRING. Arguments are broken up as in + the shell. */ +extern char *history_arg_extract (int, int, const char *); + +/* Return the text of the history event beginning at the current + offset into STRING. Pass STRING with *INDEX equal to the + history_expansion_char that begins this specification. + DELIMITING_QUOTE is a character that is allowed to end the string + specification for what to search for in addition to the normal + characters `:', ` ', `\t', `\n', and sometimes `?'. */ +extern char *get_history_event (const char *, int *, int); + +/* Return an array of tokens, much as the shell might. The tokens are + parsed out of STRING. */ +extern char **history_tokenize (const char *); + +/* Exported history variables. */ +extern int history_base; +extern int history_length; +extern int history_max_entries; +extern int history_offset; + +extern int history_lines_read_from_file; +extern int history_lines_written_to_file; + +extern char history_expansion_char; +extern char history_subst_char; +extern char *history_word_delimiters; +extern char history_comment_char; +extern char *history_no_expand_chars; +extern char *history_search_delimiter_chars; + +extern int history_quotes_inhibit_expansion; +extern int history_quoting_state; + +extern int history_write_timestamps; + +/* These two are undocumented; the second is reserved for future use */ +extern int history_multiline_entries; +extern int history_file_version; + +/* Backwards compatibility */ +extern int max_input_history; + +/* If set, this function is called to decide whether or not a particular + history expansion should be treated as a special case for the calling + application and not expanded. */ +extern rl_linebuf_func_t *history_inhibit_expansion_function; + +#ifdef __cplusplus +} +#endif + +#endif /* !_HISTORY_H_ */ diff --git a/illumos-x86_64/usr/include/readline/keymaps.h b/illumos-x86_64/usr/include/readline/keymaps.h new file mode 100644 index 00000000..29038148 --- /dev/null +++ b/illumos-x86_64/usr/include/readline/keymaps.h @@ -0,0 +1,100 @@ +/* keymaps.h -- Manipulation of readline keymaps. */ + +/* Copyright (C) 1987, 1989, 1992-2021 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#ifndef _KEYMAPS_H_ +#define _KEYMAPS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (READLINE_LIBRARY) +# include "rlstdc.h" +# include "chardefs.h" +# include "rltypedefs.h" +#else +# include +# include +# include +#endif + +/* A keymap contains one entry for each key in the ASCII set. + Each entry consists of a type and a pointer. + FUNCTION is the address of a function to run, or the + address of a keymap to indirect through. + TYPE says which kind of thing FUNCTION is. */ +typedef struct _keymap_entry { + char type; + rl_command_func_t *function; +} KEYMAP_ENTRY; + +/* This must be large enough to hold bindings for all of the characters + in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x, + and so on) plus one for subsequence matching. */ +#define KEYMAP_SIZE 257 +#define ANYOTHERKEY KEYMAP_SIZE-1 + +typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; +typedef KEYMAP_ENTRY *Keymap; + +/* The values that TYPE can have in a keymap entry. */ +#define ISFUNC 0 +#define ISKMAP 1 +#define ISMACR 2 + +extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap; +extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap; + +/* Return a new, empty keymap. + Free it with free() when you are done. */ +extern Keymap rl_make_bare_keymap (void); + +/* Return a new keymap which is a copy of MAP. */ +extern Keymap rl_copy_keymap (Keymap); + +/* Return a new keymap with the printing characters bound to rl_insert, + the lowercase Meta characters bound to run their equivalents, and + the Meta digits bound to produce numeric arguments. */ +extern Keymap rl_make_keymap (void); + +/* Free the storage associated with a keymap. */ +extern void rl_discard_keymap (Keymap); + +/* These functions actually appear in bind.c */ + +/* Return the keymap corresponding to a given name. Names look like + `emacs' or `emacs-meta' or `vi-insert'. */ +extern Keymap rl_get_keymap_by_name (const char *); + +/* Return the current keymap. */ +extern Keymap rl_get_keymap (void); + +/* Set the current keymap to MAP. */ +extern void rl_set_keymap (Keymap); + +/* Set the name of MAP to NAME */ +extern int rl_set_keymap_name (const char *, Keymap); + +#ifdef __cplusplus +} +#endif + +#endif /* _KEYMAPS_H_ */ diff --git a/illumos-x86_64/usr/include/readline/readline.h b/illumos-x86_64/usr/include/readline/readline.h new file mode 100644 index 00000000..8a53b063 --- /dev/null +++ b/illumos-x86_64/usr/include/readline/readline.h @@ -0,0 +1,1012 @@ +/* Readline.h -- the names of functions callable from within readline. */ + +/* Copyright (C) 1987-2024 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#if !defined (_READLINE_H_) +#define _READLINE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (READLINE_LIBRARY) +# include "rlstdc.h" +# include "rltypedefs.h" +# include "keymaps.h" +# include "tilde.h" +#else +# include +# include +# include +# include +#endif + +/* Hex-encoded Readline version number. */ +#define RL_READLINE_VERSION 0x0803 /* Readline 8.3 */ +#define RL_VERSION_MAJOR 8 +#define RL_VERSION_MINOR 3 + +/* Readline data structures. */ + +/* Maintaining the state of undo. We remember individual deletes and inserts + on a chain of things to do. */ + +/* The actions that undo knows how to undo. Notice that UNDO_DELETE means + to insert some text, and UNDO_INSERT means to delete some text. I.e., + the code tells undo what to undo, not how to undo it. */ +enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END }; + +/* What an element of THE_UNDO_LIST looks like. */ +typedef struct undo_list { + struct undo_list *next; + int start, end; /* Where the change took place. */ + char *text; /* The text to insert, if undoing a delete. */ + enum undo_code what; /* Delete, Insert, Begin, End. */ +} UNDO_LIST; + +/* The current undo list for RL_LINE_BUFFER. */ +extern UNDO_LIST *rl_undo_list; + +/* The data structure for mapping textual names to code addresses. */ +typedef struct _funmap { + const char *name; + rl_command_func_t *function; +} FUNMAP; + +extern FUNMAP **funmap; + +/* **************************************************************** */ +/* */ +/* Functions available to bind to key sequences */ +/* */ +/* **************************************************************** */ + +/* Bindable commands for numeric arguments. */ +extern int rl_digit_argument (int, int); +extern int rl_universal_argument (int, int); + +/* Bindable commands for moving the cursor. */ +extern int rl_forward_byte (int, int); +extern int rl_forward_char (int, int); +extern int rl_forward (int, int); +extern int rl_backward_byte (int, int); +extern int rl_backward_char (int, int); +extern int rl_backward (int, int); +extern int rl_beg_of_line (int, int); +extern int rl_end_of_line (int, int); +extern int rl_forward_word (int, int); +extern int rl_backward_word (int, int); +extern int rl_refresh_line (int, int); +extern int rl_clear_screen (int, int); +extern int rl_clear_display (int, int); +extern int rl_skip_csi_sequence (int, int); +extern int rl_arrow_keys (int, int); + +extern int rl_previous_screen_line (int, int); +extern int rl_next_screen_line (int, int); + +/* Bindable commands for inserting and deleting text. */ +extern int rl_insert (int, int); +extern int rl_quoted_insert (int, int); +extern int rl_tab_insert (int, int); +extern int rl_newline (int, int); +extern int rl_do_lowercase_version (int, int); +extern int rl_rubout (int, int); +extern int rl_delete (int, int); +extern int rl_rubout_or_delete (int, int); +extern int rl_delete_horizontal_space (int, int); +extern int rl_delete_or_show_completions (int, int); +extern int rl_insert_comment (int, int); + +/* Bindable commands for changing case. */ +extern int rl_upcase_word (int, int); +extern int rl_downcase_word (int, int); +extern int rl_capitalize_word (int, int); + +/* Bindable commands for transposing characters and words. */ +extern int rl_transpose_words (int, int); +extern int rl_transpose_chars (int, int); + +/* Bindable commands for searching within a line. */ +extern int rl_char_search (int, int); +extern int rl_backward_char_search (int, int); + +/* Bindable commands for readline's interface to the command history. */ +extern int rl_beginning_of_history (int, int); +extern int rl_end_of_history (int, int); +extern int rl_get_next_history (int, int); +extern int rl_get_previous_history (int, int); +extern int rl_operate_and_get_next (int, int); +extern int rl_fetch_history (int, int); + +/* Bindable commands for managing the mark and region. */ +extern int rl_set_mark (int, int); +extern int rl_exchange_point_and_mark (int, int); + +/* Bindable commands to set the editing mode (emacs or vi). */ +extern int rl_vi_editing_mode (int, int); +extern int rl_emacs_editing_mode (int, int); + +/* Bindable commands to change the insert mode (insert or overwrite) */ +extern int rl_overwrite_mode (int, int); + +/* Bindable commands for managing key bindings. */ +extern int rl_re_read_init_file (int, int); +extern int rl_dump_functions (int, int); +extern int rl_dump_macros (int, int); +extern int rl_dump_variables (int, int); + +/* Bindable commands for word completion. */ +extern int rl_complete (int, int); +extern int rl_possible_completions (int, int); +extern int rl_insert_completions (int, int); +extern int rl_old_menu_complete (int, int); +extern int rl_menu_complete (int, int); +extern int rl_backward_menu_complete (int, int); +extern int rl_export_completions (int, int); + +/* Bindable commands for killing and yanking text, and managing the kill ring. */ +extern int rl_kill_word (int, int); +extern int rl_backward_kill_word (int, int); +extern int rl_kill_line (int, int); +extern int rl_backward_kill_line (int, int); +extern int rl_kill_full_line (int, int); +extern int rl_unix_word_rubout (int, int); +extern int rl_unix_filename_rubout (int, int); +extern int rl_unix_line_discard (int, int); +extern int rl_copy_region_to_kill (int, int); +extern int rl_kill_region (int, int); +extern int rl_copy_forward_word (int, int); +extern int rl_copy_backward_word (int, int); +extern int rl_yank (int, int); +extern int rl_yank_pop (int, int); +extern int rl_yank_nth_arg (int, int); +extern int rl_yank_last_arg (int, int); +extern int rl_bracketed_paste_begin (int, int); +/* Not available unless _WIN32 is defined. */ +#if defined (_WIN32) +extern int rl_paste_from_clipboard (int, int); +#endif + +/* Bindable commands for incremental searching. */ +extern int rl_reverse_search_history (int, int); +extern int rl_forward_search_history (int, int); + +/* Bindable keyboard macro commands. */ +extern int rl_start_kbd_macro (int, int); +extern int rl_end_kbd_macro (int, int); +extern int rl_call_last_kbd_macro (int, int); +extern int rl_print_last_kbd_macro (int, int); + +/* Bindable undo commands. */ +extern int rl_revert_line (int, int); +extern int rl_undo_command (int, int); + +/* Bindable tilde expansion commands. */ +extern int rl_tilde_expand (int, int); + +/* Bindable terminal control commands. */ +extern int rl_restart_output (int, int); +extern int rl_stop_output (int, int); + +/* Miscellaneous bindable commands. */ +extern int rl_abort (int, int); +extern int rl_tty_status (int, int); + +extern int rl_execute_named_command (int, int); + +/* Bindable commands for incremental and non-incremental history searching. */ +extern int rl_history_search_forward (int, int); +extern int rl_history_search_backward (int, int); +extern int rl_history_substr_search_forward (int, int); +extern int rl_history_substr_search_backward (int, int); +extern int rl_noninc_forward_search (int, int); +extern int rl_noninc_reverse_search (int, int); +extern int rl_noninc_forward_search_again (int, int); +extern int rl_noninc_reverse_search_again (int, int); + +/* Bindable command used when inserting a matching close character. */ +extern int rl_insert_close (int, int); + +/* Not available unless READLINE_CALLBACKS is defined. */ +extern void rl_callback_handler_install (const char *, rl_vcpfunc_t *); +extern void rl_callback_read_char (void); +extern void rl_callback_handler_remove (void); +extern void rl_callback_sigcleanup (void); + +/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */ +/* VI-mode bindable commands. */ +extern int rl_vi_redo (int, int); +extern int rl_vi_undo (int, int); +extern int rl_vi_yank_arg (int, int); +extern int rl_vi_fetch_history (int, int); +extern int rl_vi_search_again (int, int); +extern int rl_vi_search (int, int); +extern int rl_vi_complete (int, int); +extern int rl_vi_tilde_expand (int, int); +extern int rl_vi_prev_word (int, int); +extern int rl_vi_next_word (int, int); +extern int rl_vi_end_word (int, int); +extern int rl_vi_insert_beg (int, int); +extern int rl_vi_append_mode (int, int); +extern int rl_vi_append_eol (int, int); +extern int rl_vi_eof_maybe (int, int); +extern int rl_vi_insertion_mode (int, int); +extern int rl_vi_insert_mode (int, int); +extern int rl_vi_movement_mode (int, int); +extern int rl_vi_arg_digit (int, int); +extern int rl_vi_change_case (int, int); +extern int rl_vi_put (int, int); +extern int rl_vi_column (int, int); +extern int rl_vi_delete_to (int, int); +extern int rl_vi_change_to (int, int); +extern int rl_vi_yank_to (int, int); +extern int rl_vi_yank_pop (int, int); +extern int rl_vi_rubout (int, int); +extern int rl_vi_delete (int, int); +extern int rl_vi_back_to_indent (int, int); +extern int rl_vi_unix_word_rubout (int, int); +extern int rl_vi_first_print (int, int); +extern int rl_vi_char_search (int, int); +extern int rl_vi_match (int, int); +extern int rl_vi_change_char (int, int); +extern int rl_vi_subst (int, int); +extern int rl_vi_overstrike (int, int); +extern int rl_vi_overstrike_delete (int, int); +extern int rl_vi_replace (int, int); +extern int rl_vi_set_mark (int, int); +extern int rl_vi_goto_mark (int, int); + +/* VI-mode utility functions. */ +extern int rl_vi_check (void); +extern int rl_vi_domove (int, int *); +extern int rl_vi_bracktype (int); + +extern void rl_vi_start_inserting (int, int, int); + +/* VI-mode pseudo-bindable commands, used as utility functions. */ +extern int rl_vi_fWord (int, int); +extern int rl_vi_bWord (int, int); +extern int rl_vi_eWord (int, int); +extern int rl_vi_fword (int, int); +extern int rl_vi_bword (int, int); +extern int rl_vi_eword (int, int); + +/* **************************************************************** */ +/* */ +/* Well Published Functions */ +/* */ +/* **************************************************************** */ + +/* Readline functions. */ +/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */ +extern char *readline (const char *); + +extern int rl_set_prompt (const char *); +extern int rl_expand_prompt (char *); + +extern int rl_initialize (void); + +/* Undocumented; unused by readline */ +extern int rl_discard_argument (void); + +/* Utility functions to bind keys to readline commands. */ +extern int rl_add_defun (const char *, rl_command_func_t *, int); +extern int rl_bind_key (int, rl_command_func_t *); +extern int rl_bind_key_in_map (int, rl_command_func_t *, Keymap); +extern int rl_unbind_key (int); +extern int rl_unbind_key_in_map (int, Keymap); +extern int rl_bind_key_if_unbound (int, rl_command_func_t *); +extern int rl_bind_key_if_unbound_in_map (int, rl_command_func_t *, Keymap); +extern int rl_unbind_function_in_map (rl_command_func_t *, Keymap); +extern int rl_unbind_command_in_map (const char *, Keymap); +extern int rl_bind_keyseq (const char *, rl_command_func_t *); +extern int rl_bind_keyseq_in_map (const char *, rl_command_func_t *, Keymap); +extern int rl_bind_keyseq_if_unbound (const char *, rl_command_func_t *); +extern int rl_bind_keyseq_if_unbound_in_map (const char *, rl_command_func_t *, Keymap); +extern int rl_generic_bind (int, const char *, char *, Keymap); + +extern char *rl_variable_value (const char *); +extern int rl_variable_bind (const char *, const char *); + +/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */ +extern int rl_set_key (const char *, rl_command_func_t *, Keymap); + +/* Backwards compatibility, use rl_generic_bind instead. */ +extern int rl_macro_bind (const char *, const char *, Keymap); + +/* Undocumented in the texinfo manual; not really useful to programs. */ +extern int rl_translate_keyseq (const char *, char *, int *); +extern char *rl_untranslate_keyseq (int); + +extern rl_command_func_t *rl_named_function (const char *); +extern rl_command_func_t *rl_function_of_keyseq (const char *, Keymap, int *); +extern rl_command_func_t *rl_function_of_keyseq_len (const char *, size_t, Keymap, int *); +extern int rl_trim_arg_from_keyseq (const char *, size_t, Keymap); + +extern void rl_list_funmap_names (void); +extern char **rl_invoking_keyseqs_in_map (rl_command_func_t *, Keymap); +extern char **rl_invoking_keyseqs (rl_command_func_t *); + +extern void rl_print_keybinding (const char *, Keymap, int); + +extern void rl_function_dumper (int); +extern void rl_macro_dumper (int); +extern void rl_variable_dumper (int); + +extern int rl_read_init_file (const char *); +extern int rl_parse_and_bind (char *); + +/* Functions for manipulating keymaps. */ +extern Keymap rl_make_bare_keymap (void); +extern int rl_empty_keymap (Keymap); +extern Keymap rl_copy_keymap (Keymap); +extern Keymap rl_make_keymap (void); +extern void rl_discard_keymap (Keymap); +extern void rl_free_keymap (Keymap); + +extern Keymap rl_get_keymap_by_name (const char *); +extern char *rl_get_keymap_name (Keymap); +extern void rl_set_keymap (Keymap); +extern Keymap rl_get_keymap (void); + +extern int rl_set_keymap_name (const char *, Keymap); + +/* Undocumented; used internally only. */ +extern void rl_set_keymap_from_edit_mode (void); +extern char *rl_get_keymap_name_from_edit_mode (void); + +/* Functions for manipulating the funmap, which maps command names to functions. */ +extern int rl_add_funmap_entry (const char *, rl_command_func_t *); +extern const char **rl_funmap_names (void); +/* Undocumented, only used internally -- there is only one funmap, and this + function may be called only once. */ +extern void rl_initialize_funmap (void); + +/* Utility functions for managing keyboard macros. */ +extern void rl_push_macro_input (char *); + +/* Functions for undoing, from undo.c */ +extern void rl_add_undo (enum undo_code, int, int, char *); +extern void rl_free_undo_list (void); +extern int rl_do_undo (void); +extern int rl_begin_undo_group (void); +extern int rl_end_undo_group (void); +extern int rl_modifying (int, int); + +/* Functions for redisplay. */ +extern void rl_redisplay (void); +extern int rl_on_new_line (void); +extern int rl_on_new_line_with_prompt (void); +extern int rl_forced_update_display (void); +extern int rl_clear_visible_line (void); +extern int rl_clear_message (void); +extern int rl_reset_line_state (void); +extern int rl_crlf (void); + +/* Functions to manage the mark and region, especially the notion of an + active mark and an active region. */ +extern void rl_keep_mark_active (void); + +extern void rl_activate_mark (void); +extern void rl_deactivate_mark (void); +extern int rl_mark_active_p (void); + +extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2))); + +extern int rl_show_char (int); + +/* Undocumented in texinfo manual. */ +extern int rl_character_len (int, int); +extern void rl_redraw_prompt_last_line (void); + +/* Save and restore internal prompt redisplay information. */ +extern void rl_save_prompt (void); +extern void rl_restore_prompt (void); + +/* Modifying text. */ +extern void rl_replace_line (const char *, int); +extern int rl_insert_text (const char *); +extern int rl_delete_text (int, int); +extern int rl_kill_text (int, int); +extern char *rl_copy_text (int, int); + +/* Terminal and tty mode management. */ +extern void rl_prep_terminal (int); +extern void rl_deprep_terminal (void); +extern void rl_tty_set_default_bindings (Keymap); +extern void rl_tty_unset_default_bindings (Keymap); + +extern int rl_tty_set_echoing (int); +extern int rl_reset_terminal (const char *); +extern void rl_resize_terminal (void); +extern void rl_set_screen_size (int, int); +extern void rl_get_screen_size (int *, int *); +extern void rl_reset_screen_size (void); + +extern char *rl_get_termcap (const char *); +extern void rl_reparse_colors (void); + +/* Functions for character input. */ +extern int rl_stuff_char (int); +extern int rl_execute_next (int); +extern int rl_clear_pending_input (void); +extern int rl_read_key (void); +extern int rl_getc (FILE *); +extern int rl_set_keyboard_input_timeout (int); + +/* Functions to set and reset timeouts. */ +extern int rl_set_timeout (unsigned int, unsigned int); +extern int rl_timeout_remaining (unsigned int *, unsigned int *); + +#undef rl_clear_timeout +#define rl_clear_timeout() rl_set_timeout (0, 0) + +/* `Public' utility functions . */ +extern void rl_extend_line_buffer (int); +extern int rl_ding (void); +extern int rl_alphabetic (int); +extern void rl_free (void *); + +/* Readline signal handling, from signals.c */ +extern int rl_set_signals (void); +extern int rl_clear_signals (void); +extern void rl_cleanup_after_signal (void); +extern void rl_reset_after_signal (void); +extern void rl_free_line_state (void); + +extern int rl_pending_signal (void); +extern void rl_check_signals (void); + +extern void rl_echo_signal_char (int); + +extern int rl_set_paren_blink_timeout (int); + +/* History management functions. */ + +extern void rl_clear_history (void); + +/* Undocumented. */ +extern int rl_maybe_save_line (void); +extern int rl_maybe_unsave_line (void); +extern int rl_maybe_replace_line (void); + +/* Completion functions. */ +extern int rl_complete_internal (int); +extern void rl_display_match_list (char **, int, int); + +extern char **rl_completion_matches (const char *, rl_compentry_func_t *); +extern char *rl_username_completion_function (const char *, int); +extern char *rl_filename_completion_function (const char *, int); + +extern int rl_completion_mode (rl_command_func_t *); + +#if 0 +/* Backwards compatibility (compat.c). These will go away sometime. */ +extern void free_undo_list (void); +extern int maybe_save_line (void); +extern int maybe_unsave_line (void); +extern int maybe_replace_line (void); + +extern int ding (void); +extern int alphabetic (int); +extern int crlf (void); + +extern char **completion_matches (char *, rl_compentry_func_t *); +extern char *username_completion_function (const char *, int); +extern char *filename_completion_function (const char *, int); +#endif + +/* **************************************************************** */ +/* */ +/* Well Published Variables */ +/* */ +/* **************************************************************** */ + +/* The version of this incarnation of the readline library. */ +extern const char *rl_library_version; /* e.g., "4.2" */ +extern int rl_readline_version; /* e.g., 0x0402 */ + +/* True if this is real GNU readline. */ +extern int rl_gnu_readline_p; + +/* Flags word encapsulating the current readline state. */ +extern unsigned long rl_readline_state; + +/* Says which editing mode readline is currently using. 1 means emacs mode; + 0 means vi mode. */ +extern int rl_editing_mode; + +/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means + overwrite mode. Reset to insert mode on each input line. */ +extern int rl_insert_mode; + +/* The name of the calling program. You should initialize this to + whatever was in argv[0]. It is used when parsing conditionals. */ +extern const char *rl_readline_name; + +/* The prompt readline uses. This is set from the argument to + readline (), and should not be assigned to directly. */ +extern char *rl_prompt; + +/* The prompt string that is actually displayed by rl_redisplay. Public so + applications can more easily supply their own redisplay functions. */ +extern char *rl_display_prompt; + +/* The line buffer that is in use. */ +extern char *rl_line_buffer; + +/* The location of point, and end. */ +extern int rl_point; +extern int rl_end; + +/* The mark, or saved cursor position. */ +extern int rl_mark; + +/* Flag to indicate that readline has finished with the current input + line and should return it. */ +extern int rl_done; + +/* Flag to indicate that readline has read an EOF character or read has + returned 0 or error, and is returning a NULL line as a result. */ +extern int rl_eof_found; + +/* If set to a character value, that will be the next keystroke read. */ +extern int rl_pending_input; + +/* Non-zero if we called this function from _rl_dispatch(). It's present + so functions can find out whether they were called from a key binding + or directly from an application. */ +extern int rl_dispatching; + +/* Non-zero if the user typed a numeric argument before executing the + current function. */ +extern int rl_explicit_arg; + +/* The current value of the numeric argument specified by the user. */ +extern int rl_numeric_arg; + +/* The address of the last command function Readline executed. */ +extern rl_command_func_t *rl_last_func; + +/* The name of the terminal to use. */ +extern const char *rl_terminal_name; + +/* The input and output streams. */ +extern FILE *rl_instream; +extern FILE *rl_outstream; + +/* If non-zero, Readline gives values of LINES and COLUMNS from the environment + greater precedence than values fetched from the kernel when computing the + screen dimensions. */ +extern int rl_prefer_env_winsize; + +/* If non-zero, then this is the address of a function to call just + before readline_internal () prints the first prompt. */ +extern rl_hook_func_t *rl_startup_hook; + +/* If non-zero, this is the address of a function to call just before + readline_internal_setup () returns and readline_internal starts + reading input characters. */ +extern rl_hook_func_t *rl_pre_input_hook; + +/* The address of a function to call periodically while Readline is + awaiting character input, or NULL, for no event handling. */ +extern rl_hook_func_t *rl_event_hook; + +/* The address of a function to call if a read is interrupted by a signal. */ +extern rl_hook_func_t *rl_signal_event_hook; + +extern rl_hook_func_t *rl_timeout_event_hook; + +/* The address of a function to call if Readline needs to know whether or not + there is data available from the current input source. */ +extern rl_hook_func_t *rl_input_available_hook; + +/* The address of the function to call to fetch a character from the current + Readline input stream */ +extern rl_getc_func_t *rl_getc_function; + +extern rl_voidfunc_t *rl_redisplay_function; + +extern rl_vintfunc_t *rl_prep_term_function; +extern rl_voidfunc_t *rl_deprep_term_function; + +extern rl_macro_print_func_t *rl_macro_display_hook; + +/* Dispatch variables. */ +extern Keymap rl_executing_keymap; +extern Keymap rl_binding_keymap; + +extern int rl_executing_key; +extern char *rl_executing_keyseq; +extern int rl_key_sequence_length; + +/* Display variables. */ +/* If non-zero, readline will erase the entire line, including any prompt, + if the only thing typed on an otherwise-blank line is something bound to + rl_newline. */ +extern int rl_erase_empty_line; + +/* If non-zero, the application has already printed the prompt (rl_prompt) + before calling readline, so readline should not output it the first time + redisplay is done. */ +extern int rl_already_prompted; + +/* A non-zero value means to read only this many characters rather than + up to a character bound to accept-line. */ +extern int rl_num_chars_to_read; + +/* The text of a currently-executing keyboard macro. */ +extern char *rl_executing_macro; + +/* Variables to control readline signal handling. */ +/* If non-zero, readline will install its own signal handlers for + SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */ +extern int rl_catch_signals; + +/* If non-zero, readline will install a signal handler for SIGWINCH + that also attempts to call any calling application's SIGWINCH signal + handler. Note that the terminal is not cleaned up before the + application's signal handler is called; use rl_cleanup_after_signal() + to do that. */ +extern int rl_catch_sigwinch; + +/* If non-zero, the readline SIGWINCH handler will modify LINES and + COLUMNS in the environment. */ +extern int rl_change_environment; + +/* Completion variables. */ +/* Pointer to the generator function for completion_matches (). + NULL means to use rl_filename_completion_function (), the default + filename completer. */ +extern rl_compentry_func_t *rl_completion_entry_function; + +/* Optional generator for menu completion. Default is + rl_completion_entry_function (rl_filename_completion_function). */ +extern rl_compentry_func_t *rl_menu_completion_entry_function; + +/* If rl_ignore_some_completions_function is non-NULL it is the address + of a function to call after all of the possible matches have been + generated, but before the actual completion is done to the input line. + The function is called with one argument; a NULL terminated array + of (char *). If your function removes any of the elements, they + must be free()'ed. */ +extern rl_compignore_func_t *rl_ignore_some_completions_function; + +/* Pointer to alternative function to create matches. + Function is called with TEXT, START, and END. + START and END are indices in RL_LINE_BUFFER saying what the boundaries + of TEXT are. + If this function exists and returns NULL then call the value of + rl_completion_entry_function to try to match, otherwise use the + array of strings returned. */ +extern rl_completion_func_t *rl_attempted_completion_function; + +/* The basic list of characters that signal a break between words for the + completer routine. The initial contents of this variable is what + breaks words in the shell, i.e. "n\"\\'`@$>". */ +extern const char *rl_basic_word_break_characters; + +/* The list of characters that signal a break between words for + rl_complete_internal. The default list is the contents of + rl_basic_word_break_characters. */ +extern const char *rl_completer_word_break_characters; + +/* Hook function to allow an application to set the completion word + break characters before readline breaks up the line. Allows + position-dependent word break characters. */ +extern rl_cpvfunc_t *rl_completion_word_break_hook; + +/* List of characters which can be used to quote a substring of the line. + Completion occurs on the entire substring, and within the substring + rl_completer_word_break_characters are treated as any other character, + unless they also appear within this list. */ +extern const char *rl_completer_quote_characters; + +/* List of quote characters which cause a word break. */ +extern const char *rl_basic_quote_characters; + +/* List of characters that need to be quoted in filenames by the completer. */ +extern const char *rl_filename_quote_characters; + +/* List of characters that are word break characters, but should be left + in TEXT when it is passed to the completion function. The shell uses + this to help determine what kind of completing to do. */ +extern const char *rl_special_prefixes; + +/* If non-zero, then this is the address of a function to call when + completing on a directory name. The function is called with + the address of a string (the current directory name) as an arg. It + changes what is displayed when the possible completions are printed + or inserted. The directory completion hook should perform + any necessary dequoting. This function should return 1 if it modifies + the directory name pointer passed as an argument. If the directory + completion hook returns 0, it should not modify the directory name + pointer passed as an argument. */ +extern rl_icppfunc_t *rl_directory_completion_hook; + +/* If non-zero, this is the address of a function to call when completing + a directory name. This function takes the address of the directory name + to be modified as an argument. Unlike rl_directory_completion_hook, it + only modifies the directory name used in opendir(2), not what is displayed + when the possible completions are printed or inserted. If set, it takes + precedence over rl_directory_completion_hook. The directory rewrite + hook should perform any necessary dequoting. This function has the same + return value properties as the directory_completion_hook. + + I'm not happy with how this works yet, so it's undocumented. I'm trying + it in bash to see how well it goes. */ +extern rl_icppfunc_t *rl_directory_rewrite_hook; + +/* If non-zero, this is the address of a function for the completer to call + before deciding which character to append to a completed name. It should + modify the directory name passed as an argument if appropriate, and return + non-zero if it modifies the name. This should not worry about dequoting + the filename; that has already happened by the time it gets here. */ +extern rl_icppfunc_t *rl_filename_stat_hook; + +/* If non-zero, this is the address of a function to call when reading + directory entries from the filesystem for completion and comparing + them to the partial word to be completed. The function should + either return its first argument (if no conversion takes place) or + newly-allocated memory. This can, for instance, convert filenames + between character sets for comparison against what's typed at the + keyboard. The returned value is what is added to the list of + matches. The second argument is the length of the filename to be + converted. */ +extern rl_dequote_func_t *rl_filename_rewrite_hook; + +/* If non-zero, this is the address of a function to call before + comparing the filename portion of a word to be completed with directory + entries from the filesystem. This takes the address of the partial word + to be completed, after any rl_filename_dequoting_function has been applied. + The function should either return its first argument (if no conversion + takes place) or newly-allocated memory. This can, for instance, convert + the filename portion of the completion word to a character set suitable + for comparison against directory entries read from the filesystem (after + their potential modification by rl_filename_rewrite_hook). + The returned value is what is added to the list of matches. + The second argument is the length of the filename to be converted. */ +extern rl_dequote_func_t *rl_completion_rewrite_hook; + +/* Backwards compatibility with previous versions of readline. */ +#define rl_symbolic_link_hook rl_directory_completion_hook + +/* If non-zero, then this is the address of a function to call when + completing a word would normally display the list of possible matches. + This function is called instead of actually doing the display. + It takes three arguments: (char **matches, int num_matches, int max_length) + where MATCHES is the array of strings that matched, NUM_MATCHES is the + number of strings in that array, and MAX_LENGTH is the length of the + longest string in that array. */ +extern rl_compdisp_func_t *rl_completion_display_matches_hook; + +/* Non-zero means that the results of the matches are to be treated + as filenames. This is ALWAYS zero on entry, and can only be changed + within a completion entry finder function. */ +extern int rl_filename_completion_desired; + +/* Non-zero means that the results of the matches are to be quoted using + double quotes (or an application-specific quoting mechanism) if the + filename contains any characters in rl_word_break_chars. This is + ALWAYS non-zero on entry, and can only be changed within a completion + entry finder function. */ +extern int rl_filename_quoting_desired; + +/* Non-zero means we should apply filename-type quoting to all completions + even if we are not otherwise treating the matches as filenames. This is + ALWAYS zero on entry, and can only be changed within a completion entry + finder function. */ +extern int rl_full_quoting_desired; + +/* Set to a function to quote a filename in an application-specific fashion. + Called with the text to quote, the type of match found (single or multiple) + and a pointer to the quoting character to be used, which the function can + reset if desired. */ +extern rl_quote_func_t *rl_filename_quoting_function; + +/* Function to call to remove quoting characters from a filename. Called + before completion is attempted, so the embedded quotes do not interfere + with matching names in the file system. */ +extern rl_dequote_func_t *rl_filename_dequoting_function; + +/* Function to call to decide whether or not a word break character is + quoted. If a character is quoted, it does not break words for the + completer. */ +extern rl_linebuf_func_t *rl_char_is_quoted_p; + +/* Non-zero means to suppress normal filename completion after the + user-specified completion function has been called. */ +extern int rl_attempted_completion_over; + +/* Set to a character describing the type of completion being attempted by + rl_complete_internal; available for use by application completion + functions. */ +extern int rl_completion_type; + +/* Set to the last key used to invoke one of the completion functions */ +extern int rl_completion_invoking_key; + +/* Up to this many items will be displayed in response to a + possible-completions call. After that, we ask the user if she + is sure she wants to see them all. The default value is 100. */ +extern int rl_completion_query_items; + +/* Character appended to completed words when at the end of the line. The + default is a space. Nothing is added if this is '\0'. */ +extern int rl_completion_append_character; + +/* If set to non-zero by an application completion function, + rl_completion_append_character will not be appended. */ +extern int rl_completion_suppress_append; + +/* Set to any quote character readline thinks it finds before any application + completion function is called. */ +extern int rl_completion_quote_character; + +/* Set to a non-zero value if readline found quoting anywhere in the word to + be completed; set before any application completion function is called. */ +extern int rl_completion_found_quote; + +/* If non-zero, the completion functions don't append any closing quote. + This is set to 0 by rl_complete_internal and may be changed by an + application-specific completion function. */ +extern int rl_completion_suppress_quote; + +/* If non-zero, readline will sort the completion matches. On by default. */ +extern int rl_sort_completion_matches; + +/* If non-zero, a slash will be appended to completed filenames that are + symbolic links to directory names, subject to the value of the + mark-directories variable (which is user-settable). This exists so + that application completion functions can override the user's preference + (set via the mark-symlinked-directories variable) if appropriate. + It's set to the value of _rl_complete_mark_symlink_dirs in + rl_complete_internal before any application-specific completion + function is called, so without that function doing anything, the user's + preferences are honored. */ +extern int rl_completion_mark_symlink_dirs; + +/* If non-zero, then disallow duplicates in the matches. */ +extern int rl_ignore_completion_duplicates; + +/* If this is non-zero, completion is (temporarily) inhibited, and the + completion character will be inserted as any other. */ +extern int rl_inhibit_completion; + +/* Applications can set this to non-zero to have readline's signal handlers + installed during the entire duration of reading a complete line, as in + readline-6.2. This should be used with care, because it can result in + readline receiving signals and not handling them until it's called again + via rl_callback_read_char, thereby stealing them from the application. + By default, signal handlers are only active while readline is active. */ +extern int rl_persistent_signal_handlers; + +/* Input error; can be returned by (*rl_getc_function) if readline is reading + a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */ +#define READERR (-2) + +/* Definitions available for use by readline clients. */ +#define RL_PROMPT_START_IGNORE '\001' +#define RL_PROMPT_END_IGNORE '\002' + +/* Possible values for do_replace argument to rl_filename_quoting_function, + called by rl_complete_internal. */ +#define NO_MATCH 0 +#define SINGLE_MATCH 1 +#define MULT_MATCH 2 + +/* Possible state values for rl_readline_state */ +#define RL_STATE_NONE 0x0000000 /* no state; before first call */ + +#define RL_STATE_INITIALIZING 0x00000001 /* initializing */ +#define RL_STATE_INITIALIZED 0x00000002 /* initialization done */ +#define RL_STATE_TERMPREPPED 0x00000004 /* terminal is prepped */ +#define RL_STATE_READCMD 0x00000008 /* reading a command key */ +#define RL_STATE_METANEXT 0x00000010 /* reading input after ESC */ +#define RL_STATE_DISPATCHING 0x00000020 /* dispatching to a command */ +#define RL_STATE_MOREINPUT 0x00000040 /* reading more input in a command function */ +#define RL_STATE_ISEARCH 0x00000080 /* doing incremental search */ +#define RL_STATE_NSEARCH 0x00000100 /* doing non-inc search */ +#define RL_STATE_SEARCH 0x00000200 /* doing a history search */ +#define RL_STATE_NUMERICARG 0x00000400 /* reading numeric argument */ +#define RL_STATE_MACROINPUT 0x00000800 /* getting input from a macro */ +#define RL_STATE_MACRODEF 0x00001000 /* defining keyboard macro */ +#define RL_STATE_OVERWRITE 0x00002000 /* overwrite mode */ +#define RL_STATE_COMPLETING 0x00004000 /* doing completion */ +#define RL_STATE_SIGHANDLER 0x00008000 /* in readline sighandler */ +#define RL_STATE_UNDOING 0x00010000 /* doing an undo */ +#define RL_STATE_INPUTPENDING 0x00020000 /* rl_execute_next called */ +#define RL_STATE_TTYCSAVED 0x00040000 /* tty special chars saved */ +#define RL_STATE_CALLBACK 0x00080000 /* using the callback interface */ +#define RL_STATE_VIMOTION 0x00100000 /* reading vi motion arg */ +#define RL_STATE_MULTIKEY 0x00200000 /* reading multiple-key command */ +#define RL_STATE_VICMDONCE 0x00400000 /* entered vi command mode at least once */ +#define RL_STATE_CHARSEARCH 0x00800000 /* vi mode char search */ +#define RL_STATE_REDISPLAYING 0x01000000 /* updating terminal display */ + +#define RL_STATE_DONE 0x02000000 /* done; accepted line */ +#define RL_STATE_TIMEOUT 0x04000000 /* done; timed out */ +#define RL_STATE_EOF 0x08000000 /* done; got eof on read */ + +/* Rearrange these for next major version */ +#define RL_STATE_READSTR 0x10000000 /* reading a string for M-x */ + +#define RL_SETSTATE(x) (rl_readline_state |= (x)) +#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x)) +#define RL_ISSTATE(x) (rl_readline_state & (x)) + +struct readline_state { + /* line state */ + int point; + int end; + int mark; + int buflen; + char *buffer; + UNDO_LIST *ul; + char *prompt; + + /* global state */ + int rlstate; /* XXX -- needs to be unsigned long */ + int done; + Keymap kmap; + + /* input state */ + rl_command_func_t *lastfunc; + int insmode; + int edmode; + char *kseq; + int kseqlen; + + int pendingin; + FILE *inf; + FILE *outf; + char *macro; + + /* signal state */ + int catchsigs; + int catchsigwinch; + + /* search state */ + + /* completion state */ + rl_compentry_func_t *entryfunc; + rl_compentry_func_t *menuentryfunc; + rl_compignore_func_t *ignorefunc; + rl_completion_func_t *attemptfunc; + const char *wordbreakchars; + + /* options state */ + + /* hook state */ + + /* reserved for future expansion, so the struct size doesn't change */ + char reserved[64]; +}; + +extern int rl_save_state (struct readline_state *); +extern int rl_restore_state (struct readline_state *); + +#ifdef __cplusplus +} +#endif + +#endif /* _READLINE_H_ */ diff --git a/illumos-x86_64/usr/include/readline/rlconf.h b/illumos-x86_64/usr/include/readline/rlconf.h new file mode 100644 index 00000000..e0fd735b --- /dev/null +++ b/illumos-x86_64/usr/include/readline/rlconf.h @@ -0,0 +1,84 @@ +/* rlconf.h -- readline configuration definitions */ + +/* Copyright (C) 1992-2015 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#if !defined (_RLCONF_H_) +#define _RLCONF_H_ + +/* Define this if you want the vi-mode editing available. */ +#define VI_MODE + +/* Define this to get an indication of file type when listing completions. */ +#define VISIBLE_STATS + +/* Define this to get support for colors when listing completions and in + other places. */ +#define COLOR_SUPPORT + +/* This definition is needed by readline.c, rltty.c, and signals.c. */ +/* If on, then readline handles signals in a way that doesn't suck. */ +#define HANDLE_SIGNALS + +/* Ugly but working hack for binding prefix meta. */ +#define PREFIX_META_HACK + +/* The next-to-last-ditch effort file name for a user-specific init file. */ +#define DEFAULT_INPUTRC "~/.inputrc" + +/* The ultimate last-ditch filename for an init file -- system-wide. */ +#define SYS_INPUTRC "/etc/inputrc" + +/* If defined, expand tabs to spaces. */ +#define DISPLAY_TABS + +/* If defined, use the terminal escape sequence to move the cursor forward + over a character when updating the line rather than rewriting it. */ +/* #define HACK_TERMCAP_MOTION */ + +/* The string inserted by the `insert comment' command. */ +#define RL_COMMENT_BEGIN_DEFAULT "#" + +/* Define this if you want code that allows readline to be used in an + X `callback' style. */ +#define READLINE_CALLBACKS + +/* Define this if you want the cursor to indicate insert or overwrite mode. */ +/* #define CURSOR_MODE */ + +/* Define this if you want to enable code that talks to the Linux kernel + tty auditing system. */ +/* #define ENABLE_TTY_AUDIT_SUPPORT */ + +/* Defaults for the various editing mode indicators, inserted at the beginning + of the last (maybe only) line of the prompt if show-mode-in-prompt is on */ +#define RL_EMACS_MODESTR_DEFAULT "@" +#define RL_EMACS_MODESTR_DEFLEN 1 + +#define RL_VI_INS_MODESTR_DEFAULT "(ins)" +#define RL_VI_INS_MODESTR_DEFLEN 5 +#define RL_VI_CMD_MODESTR_DEFAULT "(cmd)" +#define RL_VI_CMD_MODESTR_DEFLEN 5 + +/* Do you want readline to assume it's running in an ANSI-compatible terminal + by default? If set to 0, readline tries to check and verify whether or not + it is. */ +#define RL_ANSI_TERM_DEFAULT 1 /* for now */ + +#endif /* _RLCONF_H_ */ diff --git a/illumos-x86_64/usr/include/readline/rlstdc.h b/illumos-x86_64/usr/include/readline/rlstdc.h new file mode 100644 index 00000000..0e5c4f47 --- /dev/null +++ b/illumos-x86_64/usr/include/readline/rlstdc.h @@ -0,0 +1,45 @@ +/* stdc.h -- macros to make source compile on both ANSI C and K&R C compilers. */ + +/* Copyright (C) 1993-2009,2023 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#if !defined (_RL_STDC_H_) +#define _RL_STDC_H_ + +/* Adapted from BSD /usr/include/sys/cdefs.h. */ + +/* A function can be defined using prototypes and compile on both ANSI C + and traditional C compilers with something like this: + extern char *func PARAMS((char *, char *, int)); */ + +#if !defined (PARAMS) +# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) +# define PARAMS(protos) protos +# else +# define PARAMS(protos) () +# endif +#endif + +#ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(x) +# endif +#endif + +#endif /* !_RL_STDC_H_ */ diff --git a/illumos-x86_64/usr/include/readline/rltypedefs.h b/illumos-x86_64/usr/include/readline/rltypedefs.h new file mode 100644 index 00000000..61b81316 --- /dev/null +++ b/illumos-x86_64/usr/include/readline/rltypedefs.h @@ -0,0 +1,96 @@ +/* rltypedefs.h -- Type declarations for readline functions. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#ifndef _RL_TYPEDEFS_H_ +#define _RL_TYPEDEFS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Old-style, attempt to mark as deprecated in some way people will notice. */ + +#if !defined (_FUNCTION_DEF) && defined (WANT_OBSOLETE_TYPEDEFS) +# define _FUNCTION_DEF + +typedef int Function () __attribute__((deprecated)); +typedef void VFunction () __attribute__((deprecated)); +typedef char *CPFunction () __attribute__((deprecated)); +typedef char **CPPFunction () __attribute__((deprecated)); + +#endif /* _FUNCTION_DEF && WANT_OBSOLETE_TYPEDEFS */ + +/* New style. */ + +#if !defined (_RL_FUNCTION_TYPEDEF) +# define _RL_FUNCTION_TYPEDEF + +/* Bindable functions */ +typedef int rl_command_func_t (int, int); + +/* Typedefs for the completion system */ +typedef char *rl_compentry_func_t (const char *, int); +typedef char **rl_completion_func_t (const char *, int, int); + +typedef char *rl_quote_func_t (char *, int, char *); +typedef char *rl_dequote_func_t (char *, int); + +typedef int rl_compignore_func_t (char **); + +typedef void rl_compdisp_func_t (char **, int, int); + +/* Functions for displaying key bindings. Currently only one. */ +typedef void rl_macro_print_func_t (const char *, const char *, int, const char *); + +/* Type for input and pre-read hook functions like rl_event_hook */ +typedef int rl_hook_func_t (void); + +/* Input function type */ +typedef int rl_getc_func_t (FILE *); + +/* Generic function that takes a character buffer (which could be the readline + line buffer) and an index into it (which could be rl_point) and returns + an int. */ +typedef int rl_linebuf_func_t (char *, int); + +/* `Generic' function pointer typedefs */ +typedef int rl_intfunc_t (int); +#define rl_ivoidfunc_t rl_hook_func_t +typedef int rl_icpfunc_t (char *); +typedef int rl_icppfunc_t (char **); + +typedef void rl_voidfunc_t (void); +typedef void rl_vintfunc_t (int); +typedef void rl_vcpfunc_t (char *); +typedef void rl_vcppfunc_t (char **); + +typedef char *rl_cpvfunc_t (void); +typedef char *rl_cpifunc_t (int); +typedef char *rl_cpcpfunc_t (char *); +typedef char *rl_cpcppfunc_t (char **); + +#endif /* _RL_FUNCTION_TYPEDEF */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RL_TYPEDEFS_H_ */ diff --git a/illumos-x86_64/usr/include/readline/tilde.h b/illumos-x86_64/usr/include/readline/tilde.h new file mode 100644 index 00000000..bc8022af --- /dev/null +++ b/illumos-x86_64/usr/include/readline/tilde.h @@ -0,0 +1,68 @@ +/* tilde.h: Externally available variables and function in libtilde.a. */ + +/* Copyright (C) 1992-2009,2021 Free Software Foundation, Inc. + + This file contains the Readline Library (Readline), a set of + routines for providing Emacs style line input to programs that ask + for it. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#if !defined (_TILDE_H_) +# define _TILDE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef char *tilde_hook_func_t (char *); + +/* If non-null, this contains the address of a function that the application + wants called before trying the standard tilde expansions. The function + is called with the text sans tilde, and returns a malloc()'ed string + which is the expansion, or a NULL pointer if the expansion fails. */ +extern tilde_hook_func_t *tilde_expansion_preexpansion_hook; + +/* If non-null, this contains the address of a function to call if the + standard meaning for expanding a tilde fails. The function is called + with the text (sans tilde, as in "foo"), and returns a malloc()'ed string + which is the expansion, or a NULL pointer if there is no expansion. */ +extern tilde_hook_func_t *tilde_expansion_failure_hook; + +/* When non-null, this is a NULL terminated array of strings which + are duplicates for a tilde prefix. Bash uses this to expand + `=~' and `:~'. */ +extern char **tilde_additional_prefixes; + +/* When non-null, this is a NULL terminated array of strings which match + the end of a username, instead of just "/". Bash sets this to + `:' and `=~'. */ +extern char **tilde_additional_suffixes; + +/* Return a new string which is the result of tilde expanding STRING. */ +extern char *tilde_expand (const char *); + +/* Do the work of tilde expansion on FILENAME. FILENAME starts with a + tilde. If there is no expansion, call tilde_expansion_failure_hook. */ +extern char *tilde_expand_word (const char *); + +/* Find the portion of the string beginning with ~ that should be expanded. */ +extern char *tilde_find_word (const char *, int, int *); + +#ifdef __cplusplus +} +#endif + +#endif /* _TILDE_H_ */ diff --git a/illumos-x86_64/usr/include/regex.h b/illumos-x86_64/usr/include/regex.h new file mode 100644 index 00000000..33e4bd7d --- /dev/null +++ b/illumos-x86_64/usr/include/regex.h @@ -0,0 +1,171 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 1989, 1994 by Mortice Kern Systems Inc. + * All rights reserved. + */ + +/* + * Copyright 2017 Nexenta Systems, Inc. + */ + +#ifndef _REGEX_H +#define _REGEX_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * wchar_t is a built-in type in standard C++ and as such is not + * defined here when using standard C++. However, the GNU compiler + * fixincludes utility nonetheless creates its own version of this + * header for use by gcc and g++. In that version it adds a redundant + * guard for __cplusplus. To avoid the creation of a gcc/g++ specific + * header we need to include the following magic comment: + * + * we must use the C++ compiler's type + * + * The above comment should not be removed or changed until GNU + * gcc/fixinc/inclhack.def is updated to bypass this header. + */ +#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__)) +#ifndef _WCHAR_T +#define _WCHAR_T +#if defined(_LP64) +typedef int wchar_t; +#else +typedef long wchar_t; +#endif +#endif /* !_WCHAR_T */ +#endif /* !defined(__cplusplus) ... */ + +typedef ssize_t regoff_t; + +/* regcomp flags */ +#define REG_BASIC 0x00000 +#define REG_EXTENDED 0x00001 /* Use Extended Regular Expressions */ +#define REG_NOSUB 0x00002 /* Don't set subexpression */ +#define REG_ICASE 0x00004 /* Ignore case in match */ +#define REG_NEWLINE 0x00008 /* Treat \n as regular character */ +#define REG_DELIM 0x00010 /* legacy, no effect */ +#define REG_DEBUG 0x00020 /* legacy, no effect */ +#define REG_ANCHOR 0x00040 /* legacy, no effect */ +#define REG_WORDS 0x00080 /* legacy, no effect */ +#define REG_EGREP 0x01000 /* legacy, no effect */ +#define REG_DUMP 0x02000 /* internal */ +#define REG_PEND 0x04000 /* NULs are ordinary characters */ +#define REG_NOSPEC 0x08000 /* no special characters */ + +/* internal flags */ +#define REG_MUST 0x00100 /* legacy, no effect */ + +/* regexec flags */ +#define REG_NOTBOL 0x00200 /* string is not BOL */ +#define REG_NOTEOL 0x00400 /* string has no EOL */ +#define REG_NOOPT 0x00800 /* legacy, no effect */ +#define REG_STARTEND 0x10000 /* match whole pattern */ +#define REG_TRACE 0x20000 /* tracing of execution */ +#define REG_LARGE 0x40000 /* force large representation */ +#define REG_BACKR 0x80000 /* force use of backref code */ + +/* regcomp and regexec return codes */ +#define REG_OK 0 /* success (non-standard) */ +#define REG_NOMATCH 1 /* regexec failed to match */ +#define REG_ECOLLATE 2 /* invalid collation element ref. */ +#define REG_EESCAPE 3 /* trailing \ in pattern */ +#define REG_ENEWLINE 4 /* \n found before end of pattern */ +#define REG_ENSUB 5 /* more than 9 \( \) pairs (OBS) */ +#define REG_ESUBREG 6 /* number in \[0-9] invalid */ +#define REG_EBRACK 7 /* [ ] imbalance */ +#define REG_EPAREN 8 /* ( ) imbalance */ +#define REG_EBRACE 9 /* \{ \} imbalance */ +#define REG_ERANGE 10 /* invalid endpoint in range */ +#define REG_ESPACE 11 /* no memory for compiled pattern */ +#define REG_BADRPT 12 /* invalid repetition */ +#define REG_ECTYPE 13 /* invalid char-class type */ +#define REG_BADPAT 14 /* syntax error */ +#define REG_BADBR 15 /* \{ \} contents bad */ +#define REG_EFATAL 16 /* internal error, not POSIX.2 */ +#define REG_ECHAR 17 /* invalid multibyte character */ +#define REG_STACK 18 /* backtrack stack overflow */ +#define REG_ENOSYS 19 /* function not supported (XPG4) */ +#define REG__LAST 20 /* first unused code */ +#define REG_EBOL 21 /* ^ anchor and not BOL */ +#define REG_EEOL 22 /* $ anchor and not EOL */ +#define REG_ATOI 255 /* convert name to number (!) */ +#define REG_ITOA 256 /* convert number to name (!) */ + +#define _REG_BACKREF_MAX 9 /* Max # of subexp. backreference */ + +typedef struct { /* regcomp() data saved for regexec() */ + size_t re_nsub; /* # of subexpressions in RE pattern */ + + /* + * Internal use only. Note that any changes to this structure + * have to preserve sizing, as it is baked into applications. + */ + struct re_guts *re_g; + int re_magic; + const char *re_endp; + + /* here for compat */ + size_t re_len; /* # wchar_t chars in compiled pattern */ + struct _regex_ext_t *re_sc; /* for binary compatibility */ +} regex_t; + +/* subexpression positions */ +typedef struct { + const char *rm_sp, *rm_ep; /* Start pointer, end pointer */ + regoff_t rm_so, rm_eo; /* Start offset, end offset */ + int rm_ss, rm_es; /* Used internally */ +} regmatch_t; + + +/* + * IEEE Std 1003.2 ("POSIX.2") regular expressions API. + */ + +extern int regcomp(regex_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, int); +extern int regexec(const regex_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + size_t, regmatch_t *_RESTRICT_KYWD, int); +extern size_t regerror(int, const regex_t *_RESTRICT_KYWD, char *_RESTRICT_KYWD, + size_t); +extern void regfree(regex_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _REGEX_H */ diff --git a/illumos-x86_64/usr/include/regexp.h b/illumos-x86_64/usr/include/regexp.h new file mode 100644 index 00000000..8dfa8ae5 --- /dev/null +++ b/illumos-x86_64/usr/include/regexp.h @@ -0,0 +1,569 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _REGEXP_H +#define _REGEXP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CBRA 2 +#define CCHR 4 +#define CDOT 8 +#define CCL 12 +#define CXCL 16 +#define CDOL 20 +#define CCEOF 22 +#define CKET 24 +#define CBACK 36 +#define NCCL 40 + +#define STAR 01 +#define RNGE 03 + +#define NBRA 9 + +#define PLACE(c) ep[c >> 3] |= bittab[c & 07] +#define ISTHERE(c) (ep[c >> 3] & bittab[c & 07]) +#define ecmp(s1, s2, n) (strncmp(s1, s2, n) == 0) + +static char *braslist[NBRA]; +static char *braelist[NBRA]; +int sed, nbra; +char *loc1, *loc2, *locs; +static int nodelim; + +int circf; +static int low; +static int size; + +static unsigned char bittab[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; + +int advance(const char *lp, const char *ep); +static void getrnge(const char *str); + +char * +compile(char *instring, char *ep, const char *endbuf, int seof) +{ + INIT /* Dependent declarations and initializations */ + register int c; + register int eof = seof; + char *lastep; + int cclcnt; + char bracket[NBRA], *bracketp; + int closed; + int neg; + int lc; + int i, cflg; + int iflag; /* used for non-ascii characters in brackets */ + +#ifdef __lint + /* make lint happy */ + c = nodelim; +#endif + + lastep = NULL; + if ((c = GETC()) == eof || c == '\n') { + if (c == '\n') { + UNGETC(c); + nodelim = 1; + } + if (*ep == 0 && !sed) + ERROR(41); + RETURN(ep); + } + bracketp = bracket; + circf = closed = nbra = 0; + if (c == '^') + circf++; + else + UNGETC(c); + for (;;) { + if (ep >= endbuf) + ERROR(50); + c = GETC(); + if (c != '*' && ((c != '\\') || (PEEKC() != '{'))) + lastep = ep; + if (c == eof) { + *ep++ = CCEOF; + if (bracketp != bracket) + ERROR(42); + RETURN(ep); + } + switch (c) { + + case '.': + *ep++ = CDOT; + continue; + + case '\n': + if (!sed) { + UNGETC(c); + *ep++ = CCEOF; + nodelim = 1; + if (bracketp != bracket) + ERROR(42); + RETURN(ep); + } else ERROR(36); + case '*': + if (lastep == NULL || *lastep == CBRA || + *lastep == CKET) + goto defchar; + *lastep |= STAR; + continue; + + case '$': + if (PEEKC() != eof && PEEKC() != '\n') + goto defchar; + *ep++ = CDOL; + continue; + + case '[': + if (&ep[17] >= endbuf) + ERROR(50); + + *ep++ = CCL; + lc = 0; + for (i = 0; i < 16; i++) + ep[i] = 0; + + neg = 0; + if ((c = GETC()) == '^') { + neg = 1; + c = GETC(); + } + iflag = 1; + do { + c &= 0377; + if (c == '\0' || c == '\n') + ERROR(49); + if ((c & 0200) && iflag) { + iflag = 0; + if (&ep[32] >= endbuf) + ERROR(50); + ep[-1] = CXCL; + for (i = 16; i < 32; i++) + ep[i] = 0; + } + if (c == '-' && lc != 0) { + if ((c = GETC()) == ']') { + PLACE('-'); + break; + } + if ((c & 0200) && iflag) { + iflag = 0; + if (&ep[32] >= endbuf) + ERROR(50); + ep[-1] = CXCL; + for (i = 16; i < 32; i++) + ep[i] = 0; + } + while (lc < c) { + PLACE(lc); + lc++; + } + } + lc = c; + PLACE(c); + } while ((c = GETC()) != ']'); + + if (iflag) + iflag = 16; + else + iflag = 32; + + if (neg) { + if (iflag == 32) { + for (cclcnt = 0; cclcnt < iflag; + cclcnt++) + ep[cclcnt] ^= 0377; + ep[0] &= 0376; + } else { + ep[-1] = NCCL; + /* make nulls match so test fails */ + ep[0] |= 01; + } + } + + ep += iflag; + + continue; + + case '\\': + switch (c = GETC()) { + + case '(': + if (nbra >= NBRA) + ERROR(43); + *bracketp++ = (char)nbra; + *ep++ = CBRA; + *ep++ = (char)nbra++; + continue; + + case ')': + if (bracketp <= bracket) + ERROR(42); + *ep++ = CKET; + *ep++ = *--bracketp; + closed++; + continue; + + case '{': + if (lastep == NULL) + goto defchar; + *lastep |= RNGE; + cflg = 0; + nlim: + c = GETC(); + i = 0; + do { + if ('0' <= c && c <= '9') + i = 10 * i + c - '0'; + else + ERROR(16); + } while (((c = GETC()) != '\\') && (c != ',')); + if (i >= 255) + ERROR(11); + *ep++ = (char)i; + if (c == ',') { + if (cflg++) + ERROR(44); + if ((c = GETC()) == '\\') + *ep++ = (char)255; + else { + UNGETC(c); + goto nlim; + /* get 2'nd number */ + } + } + if (GETC() != '}') + ERROR(45); + if (!cflg) /* one number */ + *ep++ = (char)i; + else if ((ep[-1] & 0377) < (ep[-2] & 0377)) + ERROR(46); + continue; + + case '\n': + ERROR(36); + + case 'n': + c = '\n'; + goto defchar; + + default: + if (c >= '1' && c <= '9') { + if ((c -= '1') >= closed) + ERROR(25); + *ep++ = CBACK; + *ep++ = (char)c; + continue; + } + /* FALLTHROUGH */ + } + /* FALLTHROUGH */ + /* Drop through to default to use \ to turn off special chars */ + + defchar: + default: + lastep = ep; + *ep++ = CCHR; + *ep++ = (char)c; + } + } + /*NOTREACHED*/ +} + +int +step(const char *p1, const char *p2) +{ + char c; + + + if (circf) { + loc1 = (char *)p1; + return (advance(p1, p2)); + } + /* fast check for first character */ + if (*p2 == CCHR) { + c = p2[1]; + do { + if (*p1 != c) + continue; + if (advance(p1, p2)) { + loc1 = (char *)p1; + return (1); + } + } while (*p1++); + return (0); + } + /* regular algorithm */ + do { + if (advance(p1, p2)) { + loc1 = (char *)p1; + return (1); + } + } while (*p1++); + return (0); +} + +int +advance(const char *lp, const char *ep) +{ + const char *curlp; + int c; + char *bbeg; + register char neg; + size_t ct; + + for (;;) { + neg = 0; + switch (*ep++) { + + case CCHR: + if (*ep++ == *lp++) + continue; + return (0); + /*FALLTHRU*/ + + case CDOT: + if (*lp++) + continue; + return (0); + /*FALLTHRU*/ + + case CDOL: + if (*lp == 0) + continue; + return (0); + /*FALLTHRU*/ + + case CCEOF: + loc2 = (char *)lp; + return (1); + /*FALLTHRU*/ + + case CXCL: + c = (unsigned char)*lp++; + if (ISTHERE(c)) { + ep += 32; + continue; + } + return (0); + /*FALLTHRU*/ + + case NCCL: + neg = 1; + /*FALLTHRU*/ + + case CCL: + c = *lp++; + if (((c & 0200) == 0 && ISTHERE(c)) ^ neg) { + ep += 16; + continue; + } + return (0); + /*FALLTHRU*/ + + case CBRA: + braslist[(int)*ep++] = (char *)lp; + continue; + /*FALLTHRU*/ + + case CKET: + braelist[(int)*ep++] = (char *)lp; + continue; + /*FALLTHRU*/ + + case CCHR | RNGE: + c = *ep++; + getrnge(ep); + while (low--) + if (*lp++ != c) + return (0); + curlp = lp; + while (size--) + if (*lp++ != c) + break; + if (size < 0) + lp++; + ep += 2; + goto star; + /*FALLTHRU*/ + + case CDOT | RNGE: + getrnge(ep); + while (low--) + if (*lp++ == '\0') + return (0); + curlp = lp; + while (size--) + if (*lp++ == '\0') + break; + if (size < 0) + lp++; + ep += 2; + goto star; + /*FALLTHRU*/ + + case CXCL | RNGE: + getrnge(ep + 32); + while (low--) { + c = (unsigned char)*lp++; + if (!ISTHERE(c)) + return (0); + } + curlp = lp; + while (size--) { + c = (unsigned char)*lp++; + if (!ISTHERE(c)) + break; + } + if (size < 0) + lp++; + ep += 34; /* 32 + 2 */ + goto star; + /*FALLTHRU*/ + + case NCCL | RNGE: + neg = 1; + /*FALLTHRU*/ + + case CCL | RNGE: + getrnge(ep + 16); + while (low--) { + c = *lp++; + if (((c & 0200) || !ISTHERE(c)) ^ neg) + return (0); + } + curlp = lp; + while (size--) { + c = *lp++; + if (((c & 0200) || !ISTHERE(c)) ^ neg) + break; + } + if (size < 0) + lp++; + ep += 18; /* 16 + 2 */ + goto star; + /*FALLTHRU*/ + + case CBACK: + bbeg = braslist[(int)*ep]; + ct = braelist[(int)*ep++] - bbeg; + + if (ecmp(bbeg, lp, ct)) { + lp += ct; + continue; + } + return (0); + /*FALLTHRU*/ + + case CBACK | STAR: + bbeg = braslist[(int)*ep]; + ct = braelist[(int)*ep++] - bbeg; + curlp = lp; + while (ecmp(bbeg, lp, ct)) + lp += ct; + + while (lp >= curlp) { + if (advance(lp, ep)) + return (1); + lp -= ct; + } + return (0); + /*FALLTHRU*/ + + case CDOT | STAR: + curlp = lp; + while (*lp++) + ; + goto star; + /*FALLTHRU*/ + + case CCHR | STAR: + curlp = lp; + while (*lp++ == *ep) + ; + ep++; + goto star; + /*FALLTHRU*/ + + case CXCL | STAR: + curlp = lp; + do { + c = (unsigned char)*lp++; + } while (ISTHERE(c)); + ep += 32; + goto star; + /*FALLTHRU*/ + + case NCCL | STAR: + neg = 1; + /*FALLTHRU*/ + + case CCL | STAR: + curlp = lp; + do { + c = *lp++; + } while (((c & 0200) == 0 && ISTHERE(c)) ^ neg); + ep += 16; + goto star; + /*FALLTHRU*/ + + star: + do { + if (--lp == locs) + break; + if (advance(lp, ep)) + return (1); + } while (lp > curlp); + return (0); + + } + } + /*NOTREACHED*/ +} + +static void +getrnge(const char *str) +{ + low = *str++ & 0377; + size = ((*str & 0377) == 255)? 20000: (*str &0377) - low; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _REGEXP_H */ diff --git a/illumos-x86_64/usr/include/regexpr.h b/illumos-x86_64/usr/include/regexpr.h new file mode 100644 index 00000000..b3197836 --- /dev/null +++ b/illumos-x86_64/usr/include/regexpr.h @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _REGEXPR_H +#define _REGEXPR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define NBRA 9 +#ifdef _REENTRANT +extern char **___braslist(); +#define braslist (___braslist()) +extern char **___braelist(); +#define braelist (___braelist()) +extern int *___nbra(); +#define nbra (*(___nbra())) +extern int *___regerrno(); +#define regerrno (*(___regerrno())) +extern int *___reglength(); +#define reglength (*(___reglength())) +extern char **___loc1(); +#define loc1 (*(___loc1())) +extern char **___loc2(); +#define loc2 (*(___loc2())) +extern char **___locs(); +#define locs (*(___locs())) +#else +extern char *braslist[NBRA]; +extern char *braelist[NBRA]; +extern int nbra, regerrno, reglength; +extern char *loc1, *loc2, *locs; +#endif +#ifdef __STDC__ +extern int step(const char *string, const char *expbuf); +extern int advance(const char *string, const char *expbuf); +extern char *compile(const char *instring, char *expbuf, char *endbuf); +#else +extern int step(); +extern int advance(); +extern char *compile(); +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _REGEXPR_H */ diff --git a/illumos-x86_64/usr/include/resolv.h b/illumos-x86_64/usr/include/resolv.h new file mode 100644 index 00000000..dcf06e95 --- /dev/null +++ b/illumos-x86_64/usr/include/resolv.h @@ -0,0 +1,445 @@ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + * + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the regents of the University of + * California. + */ + +/* + * BIND 4.9.4: + */ + +/* + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * --Copyright-- + * + * End BIND 4.9.4 + */ + +/* + * Copyright (c) 1983, 1987, 1989 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Portions Copyright (c) 1996-1999 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * @(#)resolv.h 8.1 (Berkeley) 6/2/93 + * $Id: resolv.h,v 8.52 2003/04/29 02:27:03 marka Exp $ + */ + +#ifndef _RESOLV_H_ +#define _RESOLV_H_ + +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Revision information. This is the release date in YYYYMMDD format. + * It can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__RES > 19931104)". Do not + * compare for equality; rather, use it to determine whether your resolver + * is new enough to contain a certain feature. + */ + +#define __RES 20090302 + +#define RES_SET_H_ERRNO(r, x) __h_errno_set(r, x) +struct __res_state; /* forward */ + +void __h_errno_set(struct __res_state *res, int err); + +/* + * Resolver configuration file. + * Normally not present, but may contain the address of the + * initial name server(s) to query and the domain search list. + */ + +#ifndef _PATH_RESCONF +#define _PATH_RESCONF "/etc/resolv.conf" +#endif + +#ifndef __P +#define __P(x) x +#endif + +typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } + res_sendhookact; + +typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr * const *ns, + const uchar_t **query, + int *querylen, + uchar_t *ans, + int anssiz, + int *resplen)); + +typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr *ns, + const uchar_t *query, + int querylen, + uchar_t *ans, + int anssiz, + int *resplen)); + +struct res_sym { + int number; /* Identifying number, like T_MX */ + const char *name; /* Its symbolic name, like "MX" */ + const char *humanname; /* Its fun name, like "mail exchanger" */ +}; + +/* + * Global defines and variables for resolver stub. + */ +/* ADDRSORT and MAXADDR retained for compatibility; not used */ +#define ADDRSORT 1 /* enable the address-sorting option */ +#define MAXADDR 10 /* max # addresses to sort by */ + +#define MAXNS 3 /* max # name servers we'll track */ +#define MAXDFLSRCH 3 /* # default domain levels to try */ +#define MAXDNSRCH 6 /* max # domains in search path */ +#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ + +#define RES_TIMEOUT 5 /* min. seconds between retries */ +#define MAXRESOLVSORT 10 /* number of net to sort on */ +#define RES_MAXNDOTS 15 /* should reflect bit field size */ +#define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */ +#define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */ +#define RES_DFLRETRY 2 /* Default #/tries. */ +#define RES_MAXTIME 65535 /* Infinity, in milliseconds. */ + +struct __res_state_ext; + +struct __res_state { + int retrans; /* retransmission time interval */ + int retry; /* number of times to retransmit */ +#ifdef __sun + uint_t options; /* option flags - see below. */ +#else + ulong_t options; /* option flags - see below. */ +#endif + int nscount; /* number of name servers */ + struct sockaddr_in + nsaddr_list[MAXNS]; /* address of name server */ +#define nsaddr nsaddr_list[0] /* for backward compatibility */ + ushort_t id; /* current packet id */ + char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ + char defdname[256]; /* default domain (deprecated) */ +#ifdef __sun + uint_t pfcode; /* RES_PRF_ flags - see below. */ +#else + ulong_t pfcode; /* RES_PRF_ flags - see below. */ +#endif + unsigned ndots:4; /* threshold for initial abs. query */ + unsigned nsort:4; /* number of elements in sort_list[] */ + char unused[3]; + struct { + struct in_addr addr; + unsigned int mask; + } sort_list[MAXRESOLVSORT]; + res_send_qhook qhook; /* query hook */ + res_send_rhook rhook; /* response hook */ + int res_h_errno; /* last one set for this context */ + int _vcsock; /* PRIVATE: for res_send VC i/o */ + uint_t _flags; /* PRIVATE: see below */ + uint_t _pad; /* make _u 64 bit aligned */ + union { + /* On an 32-bit arch this means 512b total. */ + char pad[72 - 4*sizeof (int) - 2*sizeof (void *)]; + struct { + uint16_t nscount; + uint16_t nstimes[MAXNS]; /* ms. */ + int nssocks[MAXNS]; + struct __res_state_ext *ext; /* extention for IPv6 */ + uchar_t _rnd[16]; /* PRIVATE: random state */ + } _ext; + } _u; +}; + +typedef struct __res_state *res_state; + +union res_sockaddr_union { + struct sockaddr_in sin; +#ifdef IN6ADDR_ANY_INIT + struct sockaddr_in6 sin6; +#endif +#ifdef ISC_ALIGN64 + int64_t __align64; /* 64bit alignment */ +#else + int32_t __align32; /* 32bit alignment */ +#endif + char __space[128]; /* max size */ +}; + +/* + * Resolver flags (used to be discrete per-module statics ints). + */ +#define RES_F_VC 0x00000001 /* socket is TCP */ +#define RES_F_CONN 0x00000002 /* socket is connected */ +#define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors */ +#define RES_F__UNUSED 0x00000008 /* (unused) */ +#define RES_F_LASTMASK 0x000000F0 /* ordinal server of last res_nsend */ +#define RES_F_LASTSHIFT 4 /* bit position of LASTMASK "flag" */ +#define RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT) + +/* res_findzonecut2() options */ +#define RES_EXHAUSTIVE 0x00000001 /* always do all queries */ +#define RES_IPV4ONLY 0x00000002 /* IPv4 only */ +#define RES_IPV6ONLY 0x00000004 /* IPv6 only */ + +/* + * Resolver options (keep these in synch with res_debug.c, please) + */ +#define RES_INIT 0x00000001 /* address initialized */ +#define RES_DEBUG 0x00000002 /* print debug messages */ +#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL) */ +#define RES_USEVC 0x00000008 /* use virtual circuit */ +#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */ +#define RES_IGNTC 0x00000020 /* ignore trucation errors */ +#define RES_RECURSE 0x00000040 /* recursion desired */ +#define RES_DEFNAMES 0x00000080 /* use default domain name */ +#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ +#define RES_DNSRCH 0x00000200 /* search up local domain tree */ +#define RES_INSECURE1 0x00000400 /* type 1 security disabled */ +#define RES_INSECURE2 0x00000800 /* type 2 security disabled */ +#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ +#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */ +#define RES_ROTATE 0x00004000 /* rotate ns list after each query */ +#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */ +#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */ +#define RES_BLAST 0x00020000 /* blast all recursive servers */ +#define RES_NO_NIBBLE 0x00040000 /* disable IPv6 nibble mode reverse */ +#define RES_NO_BITSTRING 0x00080000 /* disable IPv6 bitstring mode revrse */ +#define RES_NOTLDQUERY 0x00100000 /* don't unqualified name as a tld */ +#define RES_USE_DNSSEC 0x00200000 /* use DNSSEC using OK bit in OPT */ +/* KAME extensions: use higher bit to avoid conflict with ISC use */ +#define RES_USE_DNAME 0x10000000 /* use DNAME */ +#define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */ +#define RES_NO_NIBBLE2 0x80000000 /* disable alternate nibble lookup */ + +#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) + +/* + * Resolver "pfcode" values. Used by dig. + */ +#define RES_PRF_STATS 0x00000001 +#define RES_PRF_UPDATE 0x00000002 +#define RES_PRF_CLASS 0x00000004 +#define RES_PRF_CMD 0x00000008 +#define RES_PRF_QUES 0x00000010 +#define RES_PRF_ANS 0x00000020 +#define RES_PRF_AUTH 0x00000040 +#define RES_PRF_ADD 0x00000080 +#define RES_PRF_HEAD1 0x00000100 +#define RES_PRF_HEAD2 0x00000200 +#define RES_PRF_TTLID 0x00000400 +#define RES_PRF_HEADX 0x00000800 +#define RES_PRF_QUERY 0x00001000 +#define RES_PRF_REPLY 0x00002000 +#define RES_PRF_INIT 0x00004000 +#define RES_PRF_TRUNC 0x00008000 +/* 0x00010000 */ + +/* Things involving an internal (static) resolver context. */ +#ifdef _REENTRANT +extern struct __res_state *__res_state(void); +#define _res (*__res_state()) +#else +#ifndef __BIND_NOSTATIC +extern struct __res_state _res; +#endif +#endif + +#ifndef __BIND_NOSTATIC +void fp_nquery __P((const uchar_t *, int, FILE *)); +void fp_query __P((const uchar_t *, FILE *)); +const char *hostalias __P((const char *)); +void p_query __P((const uchar_t *)); +void res_close __P((void)); +int res_init __P((void)); +int res_isourserver __P((const struct sockaddr_in *)); +int res_mkquery __P((int, const char *, int, int, const uchar_t *, + int, const uchar_t *, uchar_t *, int)); +int res_query __P((const char *, int, int, uchar_t *, int)); +int res_querydomain __P((const char *, const char *, int, int, + uchar_t *, int)); +int res_search __P((const char *, int, int, uchar_t *, int)); +int res_send __P((const uchar_t *, int, uchar_t *, int)); +int res_sendsigned __P((const uchar_t *, int, ns_tsig_key *, + uchar_t *, int)); +#endif /* __BIND_NOSTATIC */ + +extern const struct res_sym __p_key_syms[]; +extern const struct res_sym __p_cert_syms[]; +extern const struct res_sym __p_class_syms[]; +extern const struct res_sym __p_type_syms[]; +extern const struct res_sym __p_rcode_syms[]; + +int res_hnok __P((const char *)); +int res_ownok __P((const char *)); +int res_mailok __P((const char *)); +int res_dnok __P((const char *)); +int sym_ston __P((const struct res_sym *, const char *, int *)); +const char *sym_ntos __P((const struct res_sym *, int, int *)); +const char *sym_ntop __P((const struct res_sym *, int, int *)); +int b64_ntop __P((uchar_t const *, size_t, char *, size_t)); +int b64_pton __P((char const *, uchar_t *, size_t)); +int loc_aton __P((const char *ascii, uchar_t *binary)); +const char *loc_ntoa __P((const uchar_t *binary, char *ascii)); +int dn_skipname __P((const uchar_t *, const uchar_t *)); +void putlong __P((unsigned int, uchar_t *)); +void putshort __P((unsigned short, uchar_t *)); +const char *p_class __P((int)); +const char *p_time __P((unsigned int)); +const char *p_type __P((int)); +const char *p_rcode __P((int)); +const char *p_sockun __P((union res_sockaddr_union, char *, size_t)); +const uchar_t *p_cdnname __P((const uchar_t *, const uchar_t *, int, + FILE *)); +const uchar_t *p_cdname __P((const uchar_t *, const uchar_t *, FILE *)); +const uchar_t *p_fqnname __P((const uchar_t *cp, const uchar_t *msg, + int, char *, int)); +const uchar_t *p_fqname __P((const uchar_t *, const uchar_t *, FILE *)); +const char *p_option __P((uint_t option)); +char *p_secstodate __P((uint_t)); +int dn_count_labels __P((const char *)); +int dn_comp __P((const char *, uchar_t *, int, + uchar_t **, uchar_t **)); +int dn_expand __P((const uchar_t *, const uchar_t *, + const uchar_t *, char *, int)); +void res_rndinit __P((res_state)); +uint_t res_randomid __P((void)); +uint_t res_nrandomid __P((res_state)); +int res_nameinquery __P((const char *, int, int, + const uchar_t *, const uchar_t *)); +int res_queriesmatch __P((const uchar_t *, const uchar_t *, + const uchar_t *, const uchar_t *)); +const char *p_section __P((int section, int opcode)); + + +/* Things involving a resolver context. */ +int res_ninit __P((res_state)); +int res_nisourserver __P((const res_state, + const struct sockaddr_in *)); +void fp_resstat __P((const res_state, FILE *)); +void res_pquery __P((const res_state, const uchar_t *, int, FILE *)); +const char *res_hostalias __P((const res_state, const char *, + char *, size_t)); +int res_nquery __P((res_state, + const char *, int, int, uchar_t *, int)); +int res_nsearch __P((res_state, const char *, int, + int, uchar_t *, int)); +int res_nquerydomain __P((res_state, + const char *, const char *, int, int, + uchar_t *, int)); +int res_nmkquery __P((res_state, + int, const char *, int, int, const uchar_t *, + int, const uchar_t *, uchar_t *, int)); +int res_nsend __P((res_state, const uchar_t *, int, uchar_t *, + int)); +int res_nsendsigned __P((res_state, const uchar_t *, int, + ns_tsig_key *, uchar_t *, int)); +int res_findzonecut __P((res_state, const char *, ns_class, int, + char *, size_t, struct in_addr *, int)); +int res_findzonecut2 __P((res_state, const char *, ns_class, int, + char *, size_t, union res_sockaddr_union *, + int)); +void res_nclose __P((res_state)); +int res_nopt __P((res_state, int, uchar_t *, int, int)); +int res_nopt_rdata __P((res_state, int, uchar_t *, int, uchar_t *, + ushort_t, ushort_t, uchar_t *)); +void res_send_setqhook __P((res_send_qhook hook)); +void res_send_setrhook __P((res_send_rhook hook)); +int __res_vinit __P((res_state, int)); +void res_destroyservicelist __P((void)); +const char *res_servicename __P((uint16_t port, const char *proto)); +const char *res_protocolname __P((int num)); +void res_destroyprotolist __P((void)); +void res_buildprotolist __P((void)); +const char *res_get_nibblesuffix __P((res_state)); +const char *res_get_nibblesuffix2 __P((res_state)); +void res_ndestroy __P((res_state)); +uint16_t res_nametoclass __P((const char *buf, int *success)); +uint16_t res_nametotype __P((const char *buf, int *success)); +void res_setservers __P((res_state, + const union res_sockaddr_union *, int)); +int res_getservers __P((res_state, + union res_sockaddr_union *, int)); + + +#ifdef __cplusplus +} +#endif + +#endif /* !_RESOLV_H_ */ diff --git a/illumos-x86_64/usr/include/rje.h b/illumos-x86_64/usr/include/rje.h new file mode 100644 index 00000000..70d43bf7 --- /dev/null +++ b/illumos-x86_64/usr/include/rje.h @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _RJE_H +#define _RJE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAXDEVS 7 /* Maximum number of devices (readers, etc.) */ +#define LINEFIL "/usr/rje/lines" + +#define RJECU "/dev/dn2" /* Dial-up RJE device */ +#define RJELOGIN "rje" /* rje login name */ +#define RJEUID 68 /* User-Id for "rje" */ +#define SHQUID 69 /* User-Id for "shqer" */ +#define RJEGID 8 /* Group-Id for "rje" and "shqer" */ +#define QUEDIR "/usr/rje/sque" /* shqer directory */ +#define QUELOG "log" /* shqer log file name */ +#define QUELEN 50 /* Length of a shqer log entry */ +#define QDELAY 180 /* Delay time for shqer */ +#define QNICE 0 +#define BOOTDLY 60 /* Reboot delay time (seconds) */ +#define RESPMAX 70000 /* Max resp file size */ + +#define DEVFD 0 /* KMC device file descriptor */ +#define XMTRD 1 /* xmit read file descriptor */ +#define ERRFD 2 /* errors file descriptor */ +#define XMTWR 3 /* xmit write file descriptor */ +#define DSPRD 4 /* disp read file descriptor */ +#define DSPWR 5 /* disp write file descriptor */ +#define JBLOG 6 /* joblog file descriptor */ + +#define NAMESZ 8 + +struct joblog { + char j_file[NAMESZ]; /* Name of file to be sent */ + unsigned j_uid; /* User ID of owner */ + int j_lvl; /* Message level */ + long j_cnt; /* Number of "cards" */ +}; + + /* joblog header info */ + +struct loghdr { + int h_pgrp; /* Process group Id */ +}; +#define LBUFMAX 100 +#define MAXLNS 6 +struct lines { + char *l_host; /* RJE host machine */ + char *l_sys; /* This system */ + char *l_dir; /* home directory */ + char *l_prefix; /* rje prefix */ + char *l_dev; /* device for transfer */ + char *l_peri; /* Peripherals field */ + char *l_parm; /* Parameters field */ + char l_buf[LBUFMAX]; /* buffer for fields */ +}; + +struct dsplog { + int d_type; /* Type of record */ + union { + struct { /* record from xmit */ + char d_file[NAMESZ]; /* file sent */ + long d_cnt; /* no. of cards sent */ + unsigned d_uid; /* who sent the file */ + int d_lvl; /* message level */ + int d_rdr; /* reader sent from (0-6) */ + } x; + struct { /* record from recv */ + char d_file[NAMESZ]; /* file received */ + long d_cnt; /* no. of records */ + int d_trunc; /* file truncation flag */ + } r; + } d_un; +}; + +struct sque { + char sq_exfil[140]; /* Executable file */ + char sq_infil[48]; /* Input file */ + char sq_jobnm[9]; /* Remote job name */ + char sq_pgrmr[25]; /* Programmer name */ + char sq_jobno[9]; /* Remote job number */ + char sq_login[9]; /* Login name from usr= */ + char sq_homed[48]; /* Login directory */ + long sq_min; /* Minimum file system space */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _RJE_H */ diff --git a/illumos-x86_64/usr/include/rp_plugin.h b/illumos-x86_64/usr/include/rp_plugin.h new file mode 100644 index 00000000..a12b4577 --- /dev/null +++ b/illumos-x86_64/usr/include/rp_plugin.h @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _RP_PLUGIN_H +#define _RP_PLUGIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define RP_LIB_DIR "/usr/lib/reparse" +#define RP_PLUGIN_V1 1 + +/* + * some error codes + */ +#define RP_OK 0 +#define RP_NO_PLUGIN ENOENT +#define RP_NO_MEMORY ENOMEM +#define RP_NO_PLUGIN_DIR ENOTDIR +#define RP_INVALID_PROTOCOL EINVAL + +extern int rp_plugin_init(); + +typedef struct rp_plugin_ops { + int rpo_version; + int (*rpo_init)(void); + int (*rpo_fini)(void); + char *(*rpo_svc_types)(void); + boolean_t (*rpo_supports_svc)(const char *); + int (*rpo_form)(const char *, const char *, char *, size_t *); + int (*rpo_deref)(const char *, const char *, char *, size_t *); +} rp_plugin_ops_t; + +typedef struct rp_proto_plugin { + struct rp_proto_plugin *plugin_next; + rp_plugin_ops_t *plugin_ops; + void *plugin_handle; +} rp_proto_plugin_t; + +typedef struct rp_proto_handle { + int rp_num_proto; + rp_plugin_ops_t **rp_ops; +} rp_proto_handle_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _RP_PLUGIN_H */ diff --git a/illumos-x86_64/usr/include/rpc/auth.h b/illumos-x86_64/usr/include/rpc/auth.h new file mode 100644 index 00000000..bf4a97cf --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/auth.h @@ -0,0 +1,513 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Copyright 2017 Joyent Inc + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * auth.h, Authentication interface. + * + * The data structures are completely opaque to the client. The client + * is required to pass a AUTH * to routines that create rpc + * "sessions". + */ + +#ifndef _RPC_AUTH_H +#define _RPC_AUTH_H + +#include +#include +#include +#include +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_AUTH_BYTES 400 /* maximum length of an auth type, from RFC */ +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ + +/* + * NOTE: this value *must* be kept larger than the maximum size of all the + * structs that rq_clntcred is cast to in the different authentication types. + * If changes are made to any of these *_area structs, double-check they all + * still fit. If any new authentication mechanisms are added, add a note here. + * + * Currently these structs can be found in: + * - __svcauth_sys (svc_auth_sys.c) + * - __svcauth_des (svcauth_des.c) + * - __svcauth_loopback (svc_auth_loopb.c) + */ +#define RQCRED_SIZE 700 /* size allocated for rq_clntcred */ + +/* + * Client side authentication/security data + */ +typedef struct sec_data { + uint_t secmod; /* security mode number e.g. in nfssec.conf */ + uint_t rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ + int flags; /* AUTH_F_xxx flags */ + uid_t uid; /* uid of caller for all sec flavors (NFSv4) */ + caddr_t data; /* opaque data per flavor */ +} sec_data_t; + +#ifdef _SYSCALL32_IMPL +struct sec_data32 { + uint32_t secmod; /* security mode number e.g. in nfssec.conf */ + uint32_t rpcflavor; /* AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ + int32_t flags; /* AUTH_F_xxx flags */ + uid_t uid; /* uid of caller for all sec flavors (NFSv4) */ + caddr32_t data; /* opaque data per flavor */ +}; +#endif /* _SYSCALL32_IMPL */ + +/* + * AUTH_DES flavor specific data from sec_data opaque data field. + * AUTH_KERB has the same structure. + */ +typedef struct des_clnt_data { + struct netbuf syncaddr; /* time sync addr */ + struct knetconfig *knconf; /* knetconfig info that associated */ + /* with the syncaddr. */ + char *netname; /* server's netname */ + int netnamelen; /* server's netname len */ +} dh_k4_clntdata_t; + +#ifdef _SYSCALL32_IMPL +struct des_clnt_data32 { + struct netbuf32 syncaddr; /* time sync addr */ + caddr32_t knconf; /* knetconfig info that associated */ + /* with the syncaddr. */ + caddr32_t netname; /* server's netname */ + int32_t netnamelen; /* server's netname len */ +}; +#endif /* _SYSCALL32_IMPL */ + +/* + * flavor specific data to hold the data for AUTH_DES/AUTH_KERB(v4) + * in sec_data->data opaque field. + */ +typedef struct krb4_svc_data { + int window; /* window option value */ +} krb4_svcdata_t; + +typedef struct krb4_svc_data des_svcdata_t; + +/* + * authentication/security specific flags + */ +#define AUTH_F_RPCTIMESYNC 0x001 /* use RPC to do time sync */ +#define AUTH_F_TRYNONE 0x002 /* allow fall back to AUTH_NONE */ + + +/* + * Status returned from authentication check + */ +enum auth_stat { + AUTH_OK = 0, + /* + * failed at remote end + */ + AUTH_BADCRED = 1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED = 2, /* client should begin new session */ + AUTH_BADVERF = 3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF = 4, /* verifier expired or was replayed */ + AUTH_TOOWEAK = 5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP = 6, /* bogus response verifier */ + AUTH_FAILED = 7, /* some unknown reason */ + /* + * kerberos errors + */ + AUTH_KERB_GENERIC = 8, /* kerberos generic error */ + AUTH_TIMEEXPIRE = 9, /* time of credential expired */ + AUTH_TKT_FILE = 10, /* something wrong with ticket file */ + AUTH_DECODE = 11, /* can't decode authenticator */ + AUTH_NET_ADDR = 12, /* wrong net address in ticket */ + /* + * GSS related errors + */ + RPCSEC_GSS_NOCRED = 13, /* no credentials for user */ + RPCSEC_GSS_FAILED = 14 /* GSS failure, credentials deleted */ +}; +typedef enum auth_stat AUTH_STAT; + +union des_block { + struct { + uint32_t high; + uint32_t low; + } key; + char c[8]; +}; +typedef union des_block des_block; + +#ifdef __STDC__ +extern bool_t xdr_des_block(XDR *, des_block *); +#else +extern bool_t xdr_des_block(); +#endif + + +/* + * Authentication info. Opaque to client. + */ +struct opaque_auth { + enum_t oa_flavor; /* flavor of auth */ + caddr_t oa_base; /* address of more auth stuff */ + uint_t oa_length; /* not to exceed MAX_AUTH_BYTES */ +}; + + +/* + * Auth handle, interface to client side authenticators. + */ +typedef struct __auth { + struct opaque_auth ah_cred; + struct opaque_auth ah_verf; + union des_block ah_key; + struct auth_ops { +#ifdef __STDC__ + void (*ah_nextverf)(struct __auth *); +#ifdef _KERNEL + int (*ah_marshal)(struct __auth *, XDR *, struct cred *); +#else + int (*ah_marshal)(struct __auth *, XDR *); +#endif + /* nextverf & serialize */ + int (*ah_validate)(struct __auth *, + struct opaque_auth *); + /* validate varifier */ +#ifdef _KERNEL + int (*ah_refresh)(struct __auth *, struct rpc_msg *, + cred_t *); +#else + int (*ah_refresh)(struct __auth *, void *); + /* refresh credentials */ +#endif + void (*ah_destroy)(struct __auth *); + /* destroy this structure */ + +#ifdef _KERNEL + int (*ah_wrap)(struct __auth *, caddr_t, uint_t, + XDR *, xdrproc_t, caddr_t); + int (*ah_unwrap)(struct __auth *, XDR *, xdrproc_t, + caddr_t); +#endif +#else + void (*ah_nextverf)(); + int (*ah_marshal)(); /* nextverf & serialize */ + int (*ah_validate)(); /* validate verifier */ + int (*ah_refresh)(); /* refresh credentials */ + void (*ah_destroy)(); /* destroy this structure */ +#ifdef _KERNEL + int (*ah_wrap)(); /* encode XDR data */ + int (*ah_unwrap)(); /* decode XDR data */ +#endif + +#endif + } *ah_ops; + caddr_t ah_private; +} AUTH; + + +/* + * Authentication ops. + * The ops and the auth handle provide the interface to the authenticators. + * + * AUTH *auth; + * XDR *xdrs; + * struct opaque_auth verf; + */ +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) + + +#ifdef _KERNEL +#define AUTH_MARSHALL(auth, xdrs, cred) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs, cred)) +#define auth_marshall(auth, xdrs, cred) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs, cred)) +#else +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#endif + + +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) + +#ifdef _KERNEL +#define AUTH_REFRESH(auth, msg, cr) \ + ((*((auth)->ah_ops->ah_refresh))(auth, msg, cr)) +#define auth_refresh(auth, msg, cr) \ + ((*((auth)->ah_ops->ah_refresh))(auth, msg, cr)) +#else +#define AUTH_REFRESH(auth, msg) \ + ((*((auth)->ah_ops->ah_refresh))(auth, msg)) +#define auth_refresh(auth, msg) \ + ((*((auth)->ah_ops->ah_refresh))(auth, msg)) +#endif + +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) + +/* + * Auth flavors can now apply a transformation in addition to simple XDR + * on the body of a call/response in ways that depend on the flavor being + * used. These interfaces provide a generic interface between the + * internal RPC frame and the auth flavor specific code to allow the + * auth flavor to encode (WRAP) or decode (UNWRAP) the body. + */ +#ifdef _KERNEL +#define AUTH_WRAP(auth, buf, buflen, xdrs, xfunc, xwhere) \ + ((*((auth)->ah_ops->ah_wrap))(auth, buf, buflen, \ + xdrs, xfunc, xwhere)) +#define auth_wrap(auth, buf, buflen, xdrs, xfunc, xwhere) \ + ((*((auth)->ah_ops->ah_wrap))(auth, buf, buflen, \ + xdrs, xfunc, xwhere)) + +#define AUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ + ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, xfunc, xwhere)) +#define auth_unwrap(auth, xdrs) \ + ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, xfunc, xwhere)) +#endif + +extern struct opaque_auth _null_auth; + +/* + * These are the various implementations of client side authenticators. + */ + +/* + * System style authentication + * AUTH *authsys_create(machname, uid, gid, len, aup_gids) + * const char *machname; + * const uid_t uid; + * const gid_t gid; + * const int len; + * const gid_t *aup_gids; + */ +#ifdef _KERNEL +extern AUTH *authkern_create(void); /* takes no parameters */ +extern int authkern_init(void *, void *, int); +extern struct kmem_cache *authkern_cache; +extern AUTH *authnone_create(void); /* takes no parameters */ +extern int authnone_init(void *, void *, int); +extern struct kmem_cache *authnone_cache; +extern AUTH *authloopback_create(void); /* takes no parameters */ +extern int authloopback_init(void *, void *, int); +extern struct kmem_cache *authloopback_cache; +#else /* _KERNEL */ +#ifdef __STDC__ +extern AUTH *authsys_create(const char *, const uid_t, const gid_t, const int, + const gid_t *); +extern AUTH *authsys_create_default(void); /* takes no parameters */ +extern AUTH *authnone_create(void); /* takes no parameters */ +#else /* __STDC__ */ +extern AUTH *authsys_create(); +extern AUTH *authsys_create_default(); /* takes no parameters */ +extern AUTH *authnone_create(); /* takes no parameters */ +#endif /* __STDC__ */ +/* Will get obsolete in near future */ +#define authunix_create authsys_create +#define authunix_create_default authsys_create_default +#endif /* _KERNEL */ + +/* + * DES style authentication + * AUTH *authdes_seccreate(servername, window, timehost, ckey) + * const char *servername; - network name of server + * const uint_t window; - time to live + * const char *timehost; - optional hostname to sync with + * const des_block *ckey; - optional conversation key to use + */ +/* Will get obsolete in near future */ +#ifdef _KERNEL +extern int authdes_create(char *, uint_t, struct netbuf *, struct knetconfig *, + des_block *, int, AUTH **retauth); +#else /* _KERNEL */ +#ifdef __STDC__ +extern AUTH *authdes_seccreate(const char *, const uint_t, const char *, + const des_block *); +#else +extern AUTH *authdes_seccreate(); +#endif /* __STDC__ */ +#endif /* _KERNEL */ + +/* + * Netname manipulating functions + */ + +#ifdef _KERNEL +extern enum clnt_stat netname2user(char *, uid_t *, gid_t *, int *, gid_t *); +#endif +#ifdef __STDC__ +extern int getnetname(char *); +extern int host2netname(char *, const char *, const char *); +extern int user2netname(char *, const uid_t, const char *); +#ifndef _KERNEL +extern int netname2user(const char *, uid_t *, gid_t *, int *, gid_t *); +#endif +extern int netname2host(const char *, char *, const int); +#else +extern int getnetname(); +extern int host2netname(); +extern int user2netname(); +extern int netname2host(); +#endif + +/* + * These routines interface to the keyserv daemon + */ + +#ifdef _KERNEL +extern enum clnt_stat key_decryptsession(); +extern enum clnt_stat key_encryptsession(); +extern enum clnt_stat key_gendes(); +extern enum clnt_stat key_getnetname(); +#endif + +#ifndef _KERNEL +#ifdef __STDC__ +extern int key_decryptsession(const char *, des_block *); +extern int key_encryptsession(const char *, des_block *); +extern int key_gendes(des_block *); +extern int key_setsecret(const char *); +extern int key_secretkey_is_set(void); +/* + * The following routines are private. + */ +extern int key_setnet_ruid(); +extern int key_setnet_g_ruid(); +extern int key_removesecret_g_ruid(); +extern int key_secretkey_is_set_g_ruid(); +extern AUTH *authsys_create_ruid(); +#else +extern int key_decryptsession(); +extern int key_encryptsession(); +extern int key_gendes(); +extern int key_setsecret(); +extern int key_secretkey_is_set(); +#endif +#endif + + +/* + * Kerberos style authentication + * AUTH *authkerb_seccreate(service, srv_inst, realm, window, timehost, status) + * const char *service; - service name + * const char *srv_inst; - server instance + * const char *realm; - server realm + * const uint_t window; - time to live + * const char *timehost; - optional hostname to sync with + * int *status; - kerberos status returned + */ +#ifdef _KERNEL +extern int authkerb_create(char *, char *, char *, uint_t, + struct netbuf *, int *, struct knetconfig *, int, AUTH **); +#else +#ifdef __STDC__ +extern AUTH *authkerb_seccreate(const char *, const char *, const char *, + const uint_t, const char *, int *); +#else +extern AUTH *authkerb_seccreate(); +#endif +#endif /* _KERNEL */ + +/* + * Map a kerberos credential into a unix cred. + * + * authkerb_getucred(rqst, uid, gid, grouplen, groups) + * const struct svc_req *rqst; - request pointer + * uid_t *uid; + * gid_t *gid; + * short *grouplen; + * int *groups; + * + */ +#ifdef __STDC__ +struct svc_req; +extern int authkerb_getucred(struct svc_req *, uid_t *, gid_t *, + short *, int *); +#else +extern int authkerb_getucred(); +#endif + +#ifdef _KERNEL +/* + * XDR an opaque authentication struct. See auth.h. + */ +extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *); +#endif + +#ifdef _KERNEL +extern int authany_wrap(AUTH *, caddr_t, uint_t, XDR *, xdrproc_t, caddr_t); +extern int authany_unwrap(AUTH *, XDR *, xdrproc_t, caddr_t); +#endif + +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_NULL 0 /* backward compatibility */ +#define AUTH_SYS 1 /* unix style (uid, gids) */ +#define AUTH_UNIX AUTH_SYS +#define AUTH_SHORT 2 /* short hand unix style */ +#define AUTH_DH 3 /* for Diffie-Hellman mechanism */ +#define AUTH_DES AUTH_DH /* for backward compatibility */ +#define AUTH_KERB 4 /* kerberos style */ +#define RPCSEC_GSS 6 /* GSS-API style */ + +#define AUTH_LOOPBACK 21982 /* unix style w/ expanded groups */ + /* for use over the local transport */ + +#ifdef _KERNEL +extern char loopback_name[]; + +extern zone_key_t auth_zone_key; +extern void * auth_zone_init(zoneid_t); +extern void auth_zone_fini(zoneid_t, void *); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_AUTH_H */ diff --git a/illumos-x86_64/usr/include/rpc/auth_des.h b/illumos-x86_64/usr/include/rpc/auth_des.h new file mode 100644 index 00000000..a292b234 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/auth_des.h @@ -0,0 +1,174 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +#ifndef _RPC_AUTH_DES_H +#define _RPC_AUTH_DES_H + +/* + * auth_des.h, Protocol for DES style authentication for RPC + * + */ + +#include +#ifdef _KERNEL +#include +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * There are two kinds of "names": fullnames and nicknames + */ +enum authdes_namekind { + ADN_FULLNAME, + ADN_NICKNAME +}; + +/* + * A fullname contains the network name of the client, + * a conversation key and the window + */ +struct authdes_fullname { + char *name; /* network name of client, up to MAXNETNAMELEN */ + des_block key; /* conversation key */ + uint32_t window; /* associated window */ +}; + + +/* + * A credential + */ +struct authdes_cred { + enum authdes_namekind adc_namekind; + struct authdes_fullname adc_fullname; + uint32_t adc_nickname; +}; + +/* + * A des authentication verifier + */ +struct authdes_verf { + union { + struct timeval adv_ctime; /* clear time */ + des_block adv_xtime; /* crypt time */ + } adv_time_u; + uint32_t adv_int_u; +}; + +/* + * des authentication verifier: client variety + * + * adv_timestamp is the current time. + * adv_winverf is the credential window + 1. + * Both are encrypted using the conversation key. + */ +#define adv_timestamp adv_time_u.adv_ctime +#define adv_xtimestamp adv_time_u.adv_xtime +#define adv_winverf adv_int_u + +/* + * des authentication verifier: server variety + * + * adv_timeverf is the client's timestamp + client's window + * adv_nickname is the server's nickname for the client. + * adv_timeverf is encrypted using the conversation key. + */ +#define adv_timeverf adv_time_u.adv_ctime +#define adv_xtimeverf adv_time_u.adv_xtime +#define adv_nickname adv_int_u + +/* + * Map a des credential into a unix cred. + * + * authdes_getucred(adc, uid, gid, grouplen, groups) + * struct authdes_cred *adc; + * uid_t *uid; + * gid_t *gid; + * short *grouplen; + * gid_t *groups; + * + */ + +#ifdef _KERNEL +extern int kauthdes_getucred(const struct authdes_cred *, cred_t *); +#else +#ifdef __STDC__ +extern int authdes_getucred(const struct authdes_cred *, + uid_t *, gid_t *, short *, gid_t *); +#else +extern int authdes_getucred(); +#endif +#endif + +#ifndef _KERNEL +#ifdef __STDC__ +extern int getpublickey(const char *, char *); +extern int getsecretkey(const char *, char *, const char *); +#else +extern int getpublickey(); +extern int getsecretkey(); +#endif +#endif + +#ifdef _KERNEL + +#ifdef __STDC__ +extern int authdes_create(char *, uint_t, struct netbuf *, + struct knetconfig *, des_block *, int, AUTH **); +extern bool_t xdr_authdes_cred(XDR *, struct authdes_cred *); +extern bool_t xdr_authdes_verf(XDR *, struct authdes_verf *); +extern int rtime(struct knetconfig *, struct netbuf *, int, + struct timeval *, struct timeval *); +extern enum clnt_stat kgetnetname(char *); +extern enum auth_stat _svcauth_des(struct svc_req *, struct rpc_msg *); +#else +extern int authdes_create(); +extern bool_t xdr_authdes_cred(); +extern bool_t xdr_authdes_verf(); +extern int rtime(); +extern enum clnt_stat kgetnetname(); +extern enum auth_stat _svcauth_des(); +#endif + +extern kmutex_t authdes_ops_lock; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_AUTH_DES_H */ diff --git a/illumos-x86_64/usr/include/rpc/auth_sys.h b/illumos-x86_64/usr/include/rpc/auth_sys.h new file mode 100644 index 00000000..ef664022 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/auth_sys.h @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 Joyent Inc + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * auth_sys.h, Protocol for UNIX style authentication parameters for RPC + */ + +#ifndef _RPC_AUTH_SYS_H +#define _RPC_AUTH_SYS_H + +/* + * The system is very weak. The client uses no encryption for it + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* The machine name is part of a credential; it may not exceed 255 bytes */ +#define MAX_MACHINE_NAME 255 + +/* gids compose part of a credential; there may not be more than 16 of them */ +#define NGRPS 16 + +/* + * "sys" (Old UNIX) style credentials. + */ +struct authsys_parms { + uint_t aup_time; + char *aup_machname; + uid_t aup_uid; + gid_t aup_gid; + uint_t aup_len; + gid_t *aup_gids; +}; +/* For backward compatibility */ +#define authunix_parms authsys_parms + +/* + * Ideally, we would like this to be NGROUPS_UMAX, but the RFC mandates that + * auth sections must not exceed 400 bytes. For AUTH_LOOPBACK, that means the + * largest number of groups we can have without breaking RFC compat is 92 + * groups. + * + * NOTE: changing this value changes the size of authlpbk_area in + * svc_auth_loopb.c, which means RQCRED_SIZE *must* be updated! + */ +#define NGRPS_LOOPBACK 92 + +#ifdef __STDC__ +extern bool_t xdr_authsys_parms(XDR *, struct authsys_parms *); +#else +extern bool_t xdr_authsys_parms(); +#endif + + +/* For backward compatibility */ +#define xdr_authunix_parms(xdrs, p) xdr_authsys_parms(xdrs, p) + +/* + * If a response verifier has flavor AUTH_SHORT, then the body of + * the response verifier encapsulates the following structure; + * again it is serialized in the obvious fashion. + */ +struct short_hand_verf { + struct opaque_auth new_cred; +}; + +struct svc_req; + +extern bool_t xdr_gid_t(XDR *, gid_t *); +extern bool_t xdr_uid_t(XDR *, uid_t *); + +#ifdef _KERNEL +extern bool_t xdr_authkern(XDR *, cred_t *); +extern bool_t xdr_authloopback(XDR *, cred_t *); +extern enum auth_stat _svcauth_unix(struct svc_req *, struct rpc_msg *); +extern enum auth_stat _svcauth_short(struct svc_req *, struct rpc_msg *); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_AUTH_SYS_H */ diff --git a/illumos-x86_64/usr/include/rpc/auth_unix.h b/illumos-x86_64/usr/include/rpc/auth_unix.h new file mode 100644 index 00000000..616c9617 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/auth_unix.h @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1991 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * auth_unix.h, Protocol for UNIX style authentication parameters for RPC + */ + +#ifndef _RPC_AUTH_UNIX_H +#define _RPC_AUTH_UNIX_H + +/* + * This file is now obsolete. Users should switch to + */ +#include + +#endif /* !_RPC_AUTH_UNIX_H */ diff --git a/illumos-x86_64/usr/include/rpc/bootparam.h b/illumos-x86_64/usr/include/rpc/bootparam.h new file mode 100644 index 00000000..42ae2365 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/bootparam.h @@ -0,0 +1,114 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_BOOTPARAM_H +#define _RPC_BOOTPARAM_H + +#ifndef _KERNEL +#include +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_MACHINE_NAME 255 +#define MAX_PATH_LEN 1024 +#define MAX_FILEID 32 +#define IP_ADDR_TYPE 1 + +typedef char *bp_machine_name_t; +typedef char *bp_path_t; +typedef char *bp_fileid_t; + +struct ip_addr_t { + char net; + char host; + char lh; + char impno; +}; +typedef struct ip_addr_t ip_addr_t; + +struct bp_address { + int address_type; + union { + ip_addr_t ip_addr; + } bp_address; +}; +typedef struct bp_address bp_address; + + +struct bp_whoami_arg { + bp_address client_address; +}; +typedef struct bp_whoami_arg bp_whoami_arg; + + +struct bp_whoami_res { + bp_machine_name_t client_name; + bp_machine_name_t domain_name; + bp_address router_address; +}; +typedef struct bp_whoami_res bp_whoami_res; + + +struct bp_getfile_arg { + bp_machine_name_t client_name; + bp_fileid_t file_id; +}; +typedef struct bp_getfile_arg bp_getfile_arg; + + +struct bp_getfile_res { + bp_machine_name_t server_name; + bp_address server_address; + bp_path_t server_path; +}; +typedef struct bp_getfile_res bp_getfile_res; + + +#define BOOTPARAMPROG 100026 +#define BOOTPARAMVERS 1 +#define BOOTPARAMPROC_WHOAMI 1 +#define BOOTPARAMPROC_GETFILE 2 + +bool_t xdr_bp_machine_name_t(); +bool_t xdr_bp_path_t(); +bool_t xdr_bp_fileid_t(); +bool_t xdr_ip_addr_t(); +bool_t xdr_bp_address(); +bool_t xdr_bp_whoami_arg(); +bool_t xdr_bp_whoami_res(); +bool_t xdr_bp_getfile_arg(); +bool_t xdr_bp_getfile_res(); + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_BOOTPARAM_H */ diff --git a/illumos-x86_64/usr/include/rpc/clnt.h b/illumos-x86_64/usr/include/rpc/clnt.h new file mode 100644 index 00000000..8c51c440 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/clnt.h @@ -0,0 +1,1110 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * clnt.h - Client side remote procedure call interface. + */ + +#ifndef _RPC_CLNT_H +#define _RPC_CLNT_H + +#include +#include +#include +#include + +/* + * rpc calls return an enum clnt_stat. This should be looked at more, + * since each implementation is required to live with this (implementation + * independent) list of errors. + */ +#include +#ifdef _KERNEL +#include +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Following defines the multicast group address used by IPV6 enabled + * client to do the broadcast. IPv6 doesn't have any broadcast support + * as IPv4 provides, thus it used this reserved address which is joined + * by all rpc clients. + */ + +#define RPCB_MULTICAST_ADDR "FF02::202" + +/* + * the following errors are in general unrecoverable. The caller + * should give up rather than retry. + */ +#define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \ + ((s) == RPC_CANTENCODEARGS) || \ + ((s) == RPC_CANTDECODERES) || \ + ((s) == RPC_VERSMISMATCH) || \ + ((s) == RPC_PROCUNAVAIL) || \ + ((s) == RPC_PROGUNAVAIL) || \ + ((s) == RPC_PROGVERSMISMATCH) || \ + ((s) == RPC_SYSTEMERROR) || \ + ((s) == RPC_CANTDECODEARGS)) + +/* Maximum rpc backoff time */ +#define RPC_MAX_BACKOFF 30 + +/* + * Error info. + */ +struct rpc_err { + enum clnt_stat re_status; + union { + struct { + int RE_errno; /* related system error */ + int RE_t_errno; /* related tli error number */ + } RE_err; + enum auth_stat RE_why; /* why the auth error occurred */ + struct { + rpcvers_t low; /* lowest verion supported */ + rpcvers_t high; /* highest verion supported */ + } RE_vers; + struct { /* maybe meaningful if RPC_FAILED */ + int32_t s1; + int32_t s2; + } RE_lb; /* life boot & debugging only */ + } ru; +#define re_errno ru.RE_err.RE_errno +#define re_terrno ru.RE_err.RE_t_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb +}; + + +/* + * Timers used for the pseudo-transport protocol when using datagrams + */ +struct rpc_timers { + clock_t rt_srtt; /* smoothed round-trip time */ + clock_t rt_deviate; /* estimated deviation */ + clock_t rt_rtxcur; /* current (backed-off) rto */ +}; + +/* + * PSARC 2003/523 Contract Private Interface + * CLIENT + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + * + * Client rpc handle. + * Created by individual implementations + * Client is responsible for initializing auth, see e.g. auth_none.c. + */ + +typedef struct __client { + AUTH *cl_auth; /* authenticator */ + struct clnt_ops { +#ifdef __STDC__ + /* call remote procedure */ + enum clnt_stat (*cl_call)(struct __client *, rpcproc_t, + xdrproc_t, caddr_t, xdrproc_t, + caddr_t, struct timeval); + /* abort a call */ + void (*cl_abort)(/* various */); + /* get specific error code */ + void (*cl_geterr)(struct __client *, + struct rpc_err *); + /* frees results */ + bool_t (*cl_freeres)(struct __client *, xdrproc_t, + caddr_t); + /* destroy this structure */ + void (*cl_destroy)(struct __client *); + /* the ioctl() of rpc */ + bool_t (*cl_control)(struct __client *, int, char *); + /* set rpc level timers */ + int (*cl_settimers)(struct __client *, + struct rpc_timers *, struct rpc_timers *, + int, void (*)(), caddr_t, uint32_t); +#ifndef _KERNEL + /* send a one-way asynchronous call to remote procedure */ + enum clnt_stat (*cl_send)(struct __client *, rpcproc_t, + xdrproc_t, caddr_t); +#endif /* !_KERNEL */ +#else + enum clnt_stat (*cl_call)(); /* call remote procedure */ + void (*cl_abort)(); /* abort a call */ + void (*cl_geterr)(); /* get specific error code */ + bool_t (*cl_freeres)(); /* frees results */ + void (*cl_destroy)(); /* destroy this structure */ + bool_t (*cl_control)(); /* the ioctl() of rpc */ + int (*cl_settimers)(); /* set rpc level timers */ +#ifndef _KERNEL + enum clnt_stat (*cl_send)(); /* send one-way request */ +#endif /* !_KERNEL */ +#endif + } *cl_ops; + caddr_t cl_private; /* private stuff */ +#ifndef _KERNEL + char *cl_netid; /* network token */ + char *cl_tp; /* device name */ +#else + bool_t cl_nosignal; /* to handle NOINTR */ +#endif +} CLIENT; + +/* + * Feedback values used for possible congestion and rate control + */ +#define FEEDBACK_REXMIT1 1 /* first retransmit */ +#define FEEDBACK_OK 2 /* no retransmits */ + +/* + * The following defines the control routines + * for rpcbind. + */ + +#define CLCR_GET_RPCB_TIMEOUT 1 +#define CLCR_SET_RPCB_TIMEOUT 2 +#define CLCR_SET_LOWVERS 3 +#define CLCR_GET_LOWVERS 4 +#define CLCR_SET_RPCB_RMTTIME 5 +#define CLCR_GET_RPCB_RMTTIME 6 +#define CLCR_SET_CRED_CACHE_SZ 7 +#define CLCR_GET_CRED_CACHE_SZ 8 + +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +#define KNC_STRSIZE 128 /* maximum length of knetconfig strings */ +/* + * PSARC 2003/523 Contract Private Interface + * knetconfig + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + * + * Note that the knetconfig strings can either be dynamically allocated, or + * they can be string literals. The code that sets up the knetconfig is + * responsible for keeping track of this and freeing the strings if + * necessary when the knetconfig is destroyed. + */ +struct knetconfig { + unsigned int knc_semantics; /* token name */ + caddr_t knc_protofmly; /* protocol family */ + caddr_t knc_proto; /* protocol */ + dev_t knc_rdev; /* device id */ + unsigned int knc_unused[8]; +}; + +#ifdef _SYSCALL32 +struct knetconfig32 { + uint32_t knc_semantics; /* token name */ + caddr32_t knc_protofmly; /* protocol family */ + caddr32_t knc_proto; /* protocol */ + dev32_t knc_rdev; /* device id */ + uint32_t knc_unused[8]; +}; +#endif /* _SYSCALL32 */ + +#ifdef _KERNEL + +/* + * Bucket defined for the call table. Padded out to 64 bytes so that + * false sharing won't be induced. + */ +typedef union call_table { + struct { + struct calllist_s *uct_call_next; + struct calllist_s *uct_call_prev; + uint_t uct_len; + kmutex_t uct_lock; + } ct_s; + char uct_pad[64]; +} call_table_t; + +/* + * Define some macros for easy access into the call table structure + */ +#define ct_call_next ct_s.uct_call_next +#define ct_call_prev ct_s.uct_call_prev +#define ct_len ct_s.uct_len +#define ct_lock ct_s.uct_lock + +/* + * List of outstanding calls awaiting replies, for COTS, CLTS + */ +typedef struct calllist_s { + struct calllist_s *call_next; /* hash chain, MUST BE FIRST */ + struct calllist_s *call_prev; + bool_t call_notified; + uint_t call_xid; /* the xid on the call */ + uint_t call_hash; /* hash value */ + call_table_t *call_bucket; /* back pointer to bucket */ + mblk_t *call_reply; /* the reply to the call */ + kcondvar_t call_cv; /* cv to notify when reply is done */ + kmutex_t call_lock; /* lock for cv */ + struct rpc_err call_err; /* status on reply */ +#define call_status call_err.re_status /* error on reply (rep is invalid) */ +#define call_reason call_err.re_errno /* reason code on T_DISCON_IND */ + queue_t *call_wq; /* the write queue the call is using */ + zoneid_t call_zoneid; /* zoneid the call was made from */ +} calllist_t; + +/* + * Define macros for call table hashing + */ +/* + * A simple hash function. Due to the way XID's get allocated, this may be + * sufficient. This hash function provides round robin bucket selection so + * that the next time a particular bucket gets picked is when there have + * been N-1 calls. N is the number of buckets. + */ +#define call_hash(xid, hashsize) \ + (xid % hashsize); + +#define call_table_enter(e) \ +{ \ + call_table_t *ctp = (e)->call_bucket; \ + mutex_enter(&ctp->ct_lock); \ + ctp->ct_len++; \ + (e)->call_next = ctp->ct_call_next; \ + (e)->call_prev = (calllist_t *)ctp; \ + ctp->ct_call_next->call_prev = (e); \ + ctp->ct_call_next = (e); \ + mutex_exit(&ctp->ct_lock); \ +} + +#define call_table_remove(e) \ +{ \ + call_table_t *ctp = (e)->call_bucket; \ + mutex_enter(&ctp->ct_lock); \ + ctp->ct_len--; \ + (e)->call_prev->call_next = (e)->call_next; \ + (e)->call_next->call_prev = (e)->call_prev; \ + mutex_exit(&ctp->ct_lock); \ +} + +#define call_table_find(ctp, xid, ele) \ +{ \ + calllist_t *cp; \ + (ele) = NULL; \ + mutex_enter(&(ctp)->ct_lock); \ + for (cp = (ctp)->ct_call_next; \ + cp != (calllist_t *)(ctp); \ + cp = cp->call_next) { \ + if (cp->call_xid == (xid)) \ + (ele) = cp; \ + } \ +} + +#define DEFAULT_MIN_HASH_SIZE 32 +#define DEFAULT_HASH_SIZE 1024 + +#define RESERVED_PORTSPACE (IPPORT_RESERVED - (IPPORT_RESERVED/2)) +#define NONRESERVED_PORTSPACE (0xFFFF - IPPORT_RESERVED) + +/* + * Alloc_xid presents an interface which kernel RPC clients + * should use to allocate their XIDs. Its implementation + * may change over time (for example, to allow sharing of + * XIDs between the kernel and user-level applications, so + * all XID allocation should be done by calling alloc_xid(). + */ +extern uint32_t alloc_xid(void); + +extern struct zone *rpc_zone(void); +extern zoneid_t rpc_zoneid(void); + +extern int clnt_tli_kcreate(struct knetconfig *config, struct netbuf *svcaddr, + rpcprog_t, rpcvers_t, uint_t max_msgsize, int retrys, + struct cred *cred, CLIENT **ncl); + +extern int clnt_tli_kinit(CLIENT *h, struct knetconfig *config, + struct netbuf *addr, uint_t max_msgsize, int retries, + struct cred *cred); + +extern int rpc_uaddr2port(int af, char *addr); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern int bindresvport(TIUSER *tiptr, struct netbuf *addr, + struct netbuf *bound_addr, bool_t istcp); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern int clnt_clts_kcreate(struct knetconfig *config, struct netbuf *addr, + rpcprog_t, rpcvers_t, int retries, struct cred *cred, CLIENT **cl); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern int clnt_cots_kcreate(dev_t dev, struct netbuf *addr, int family, + rpcprog_t, rpcvers_t, uint_t max_msgsize, struct cred *cred, + CLIENT **ncl); +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern int clnt_rdma_kcreate(char *proto, void *handle, struct netbuf *raddr, + int family, rpcprog_t pgm, rpcvers_t vers, struct cred *cred, + CLIENT **cl); +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern int rdma_reachable(int addr_type, struct netbuf *addr, + struct knetconfig **knconf); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_clts_kinit(CLIENT *h, struct netbuf *addr, int retries, + struct cred *cred); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_cots_kinit(CLIENT *h, dev_t dev, int family, + struct netbuf *addr, int max_msgsize, struct cred *cred); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_rdma_kinit(CLIENT *h, char *proto, void *handle, + struct netbuf *addr, struct cred *cred); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern bool_t clnt_dispatch_notify(mblk_t *, zoneid_t); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern bool_t clnt_dispatch_notifyconn(queue_t *, mblk_t *); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_dispatch_notifyall(queue_t *, int32_t, int32_t); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern enum clnt_stat clnt_clts_kcallit_addr(CLIENT *, rpcproc_t, xdrproc_t, + caddr_t, xdrproc_t, caddr_t, struct timeval, struct netbuf *); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern call_table_t *call_table_init(int); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_init(void); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_fini(void); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_clts_init(void); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_clts_fini(void); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_cots_init(void); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_cots_fini(void); + +/* + * kRPC internal function. Not for general use. Subject to rapid change. + */ +extern void clnt_clts_dispatch_notify(mblk_t *, int, zoneid_t); + +extern void rpc_poptimod(struct vnode *); +extern int kstr_push(struct vnode *, char *); +extern void t_kadvise(TIUSER *, uchar_t *, int); + +extern boolean_t connmgr_cpr_reset(void *, int); + +extern void put_inet_port(struct netbuf *, ushort_t); +extern void put_inet6_port(struct netbuf *, ushort_t); +extern void put_loopback_port(struct netbuf *, char *); +extern enum clnt_stat rpcbind_getaddr(struct knetconfig *, rpcprog_t, + rpcvers_t, struct netbuf *); + +/* + * Kstat stuff + */ +#include + +extern zone_key_t rpcstat_zone_key; + +struct rpc_clts_client; /* unix:0:rpc_clts_client */ +struct rpc_clts_server; /* unix:0:rpc_clts_server */ +struct rpc_cots_client; /* unix:0:rpc_cots_client */ +struct rpc_cots_server; /* unix:0:rpc_cots_server */ + +struct rpcstat { + struct rpc_clts_client *rpc_clts_client; + struct rpc_clts_server *rpc_clts_server; + struct rpc_cots_client *rpc_cots_client; + struct rpc_cots_server *rpc_cots_server; +}; + +extern kstat_named_t *rpcstat_zone_init_common(zoneid_t, const char *, + const char *, const kstat_named_t *, size_t); +extern void rpcstat_zone_fini_common(zoneid_t, const char *, const char *); + +extern void clnt_clts_stats_init(zoneid_t, struct rpc_clts_client **); +extern void clnt_clts_stats_fini(zoneid_t, struct rpc_clts_client **); + +extern void svc_clts_stats_init(zoneid_t, struct rpc_clts_server **); +extern void svc_clts_stats_fini(zoneid_t, struct rpc_clts_server **); + +extern void clnt_cots_stats_init(zoneid_t, struct rpc_cots_client **); +extern void clnt_cots_stats_fini(zoneid_t, struct rpc_cots_client **); + +extern void svc_cots_stats_init(zoneid_t, struct rpc_cots_server **); +extern void svc_cots_stats_fini(zoneid_t, struct rpc_cots_server **); + +#endif /* _KERNEL */ + +/* + * client side rpc interface ops + */ + +/* + * enum clnt_stat + * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) + * CLIENT *rh; + * rpcproc_t proc; + * xdrproc_t xargs; + * caddr_t argsp; + * xdrproc_t xres; + * caddr_t resp; + * struct timeval timeout; + * + * PSARC 2003/523 Contract Private Interface + * CLNT_CALL + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) + +#ifndef _KERNEL +/* + * enum clnt_stat + * CLNT_SEND(rh, proc, xargs, argsp) + * CLIENT *rh; + * rpcproc_t proc; + * xdrproc_t xargs; + * caddr_t argsp; + * + * PSARC 2000/428 Contract Private Interface + */ +#define CLNT_SEND(rh, proc, xargs, argsp) \ + ((*(rh)->cl_ops->cl_send)(rh, proc, xargs, argsp)) +#define clnt_send(rh, proc, xargs, argsp) \ + ((*(rh)->cl_ops->cl_send)(rh, proc, xargs, argsp)) +#endif /* !_KERNEL */ + +/* + * void + * CLNT_ABORT(rh); + * CLIENT *rh; + */ +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) + +/* + * struct rpc_err + * CLNT_GETERR(rh); + * CLIENT *rh; + */ +#define CLNT_GETERR(rh, errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh, errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) + +/* + * bool_t + * CLNT_FREERES(rh, xres, resp); + * CLIENT *rh; + * xdrproc_t xres; + * caddr_t resp; + */ +#define CLNT_FREERES(rh, xres, resp) \ + ((*(rh)->cl_ops->cl_freeres)(rh, xres, resp)) +#define clnt_freeres(rh, xres, resp) \ + ((*(rh)->cl_ops->cl_freeres)(rh, xres, resp)) + +/* + * bool_t + * CLNT_CONTROL(cl, request, info) + * CLIENT *cl; + * uint_t request; + * char *info; + * + * PSARC 2003/523 Contract Private Interface + * CLNT_CONTROL + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +#define CLNT_CONTROL(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in)) +#define clnt_control(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in)) + + +/* + * control operations that apply to all transports + */ +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +#define CLGET_FD 6 /* get connections file descriptor */ +#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ +#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ +#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ +#define CLGET_XID 10 /* Get xid */ +#define CLSET_XID 11 /* Set xid */ +#define CLGET_VERS 12 /* Get version number */ +#define CLSET_VERS 13 /* Set version number */ +#define CLGET_PROG 14 /* Get program number */ +#define CLSET_PROG 15 /* Set program number */ +#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */ +#define CLSET_PUSH_TIMOD 17 /* push timod if not already present */ +#define CLSET_POP_TIMOD 18 /* pop timod */ +#ifndef _KERNEL +/* 00-08-17 - NON STANDARD CONTROL PARAMETER */ +#define CLSET_IO_MODE 19 /* clnt_send behavior */ +#define CLGET_IO_MODE 20 /* clnt_send behavior */ +#define CLSET_FLUSH_MODE 21 /* flush behavior */ +#define CLGET_FLUSH_MODE 22 /* flush behavior */ +#define CLFLUSH 23 /* flush now (user wants it) */ +#define CLSET_CONNMAXREC_SIZE 24 /* set pending request buffer size */ +#define CLGET_CONNMAXREC_SIZE 25 /* set pending request buffer size */ +#define CLGET_CURRENT_REC_SIZE 26 /* get pending request buffer size */ + +typedef enum { + RPC_CL_BESTEFFORT_FLUSH = 100, /* flush as much as possible */ + /* without blocking */ + RPC_CL_BLOCKING_FLUSH, /* flush the buffer completely */ + /* (possibly blocking) */ + RPC_CL_DEFAULT_FLUSH /* flush according to the currently */ + /* defined policy. */ +} rpcflushmode_t; + + +typedef enum { + RPC_CL_BLOCKING = 10, /* PASSED CLNT_CONTROL SET_IO_MODE */ + RPC_CL_NONBLOCKING +} rpciomode_t; +#endif /* !_KERNEL */ +/* + * Connectionless only control operations + */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ + +#ifdef _KERNEL +/* + * Connection oriented only control operation. + */ +#define CLSET_PROGRESS 10000 /* Report RPC_INPROGRESS if a request */ + /* has been sent but no reply */ + /* received yet. */ +#define CLSET_BCAST 10001 /* Set RPC Broadcast hint */ +#define CLGET_BCAST 10002 /* Get RPC Broadcast hint */ +#define CLSET_NODELAYONERR 10003 /* Set enable/disable of delay on */ + /* connection setup error */ +#define CLGET_NODELAYONERR 10004 /* Get enable/disable of delay on */ + /* connection setup error */ +#define CLSET_BINDRESVPORT 10005 /* Set preference for reserve port */ +#define CLGET_BINDRESVPORT 10006 /* Get preference for reserve port */ +#endif + +/* + * void + * CLNT_SETTIMERS(rh); + * CLIENT *rh; + * struct rpc_timers *t; + * struct rpc_timers *all; + * unsigned int min; + * void (*fdbck)(); + * caddr_t arg; + * uint_t xid; + */ +#define CLNT_SETTIMERS(rh, t, all, min, fdbck, arg, xid) \ + ((*(rh)->cl_ops->cl_settimers)(rh, t, all, min, \ + fdbck, arg, xid)) +#define clnt_settimers(rh, t, all, min, fdbck, arg, xid) \ + ((*(rh)->cl_ops->cl_settimers)(rh, t, all, min, \ + fdbck, arg, xid)) + + +/* + * void + * CLNT_DESTROY(rh); + * CLIENT *rh; + * + * PSARC 2003/523 Contract Private Interface + * CLNT_DESTROY + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) + + +/* + * RPCTEST is a test program which is accessable on every rpc + * transport/port. It is used for testing, performance evaluation, + * and network administration. + */ + +#define RPCTEST_PROGRAM ((rpcprog_t)1) +#define RPCTEST_VERSION ((rpcvers_t)1) +#define RPCTEST_NULL_PROC ((rpcproc_t)2) +#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) + +/* + * By convention, procedure 0 takes null arguments and returns them + */ + +#define NULLPROC ((rpcproc_t)0) + +/* + * Below are the client handle creation routines for the various + * implementations of client side rpc. They can return NULL if a + * creation failure occurs. + */ + +#ifndef _KERNEL + +/* + * Generic client creation routine. Supported protocols are which belong + * to the nettype name space + */ +#ifdef __STDC__ +extern CLIENT * clnt_create(const char *, const rpcprog_t, const rpcvers_t, + const char *); +/* + * + * const char *hostname; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const char *nettype; -- network type + */ +#else +extern CLIENT * clnt_create(); +#endif + +/* + * Generic client creation routine. Just like clnt_create(), except + * it takes an additional timeout parameter. + */ +#ifdef __STDC__ +extern CLIENT * clnt_create_timed(const char *, const rpcprog_t, + const rpcvers_t, const char *, const struct timeval *); +/* + * + * const char *hostname; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const char *nettype; -- network type + * const struct timeval *tp; -- timeout + */ +#else +extern CLIENT * clnt_create_timed(); +#endif + +/* + * Generic client creation routine. Supported protocols are which belong + * to the nettype name space. + */ +#ifdef __STDC__ +extern CLIENT * clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *, + const rpcvers_t, const rpcvers_t, const char *); +/* + * const char *host; -- hostname + * const rpcprog_t prog; -- program number + * rpcvers_t *vers_out; -- servers highest available version number + * const rpcvers_t vers_low; -- low version number + * const rpcvers_t vers_high; -- high version number + * const char *nettype; -- network type + */ +#else +extern CLIENT * clnt_create_vers(); +#endif + +/* + * Generic client creation routine. Supported protocols are which belong + * to the nettype name space. + */ +#ifdef __STDC__ +extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t, + rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *, + const struct timeval *); +/* + * const char *host; -- hostname + * const rpcprog_t prog; -- program number + * rpcvers_t *vers_out; -- servers highest available version number + * const rpcvers_t vers_low; -- low version number + * const prcvers_t vers_high; -- high version number + * const char *nettype; -- network type + * const struct timeval *tp -- timeout + */ +#else +extern CLIENT * clnt_create_vers_timed(); +#endif + + +/* + * Generic client creation routine. It takes a netconfig structure + * instead of nettype + */ +#ifdef __STDC__ +extern CLIENT * clnt_tp_create(const char *, const rpcprog_t, const rpcvers_t, + const struct netconfig *); +/* + * const char *hostname; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const struct netconfig *netconf; -- network config structure + */ +#else +extern CLIENT * clnt_tp_create(); +#endif + +/* + * Generic client creation routine. Just like clnt_tp_create(), except + * it takes an additional timeout parameter. + */ +#ifdef __STDC__ +extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t, + const rpcvers_t, const struct netconfig *, const struct timeval *); +/* + * const char *hostname; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const struct netconfig *netconf; -- network config structure + * const struct timeval *tp; -- timeout + */ +#else +extern CLIENT * clnt_tp_create_timed(); +#endif + +/* + * Generic TLI create routine + */ + +#ifdef __STDC__ +extern CLIENT * clnt_tli_create(const int, const struct netconfig *, + struct netbuf *, const rpcprog_t, const rpcvers_t, const uint_t, + const uint_t); +/* + * const int fd; -- fd + * const struct netconfig *nconf; -- netconfig structure + * struct netbuf *svcaddr; -- servers address + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const uint_t sendsz; -- send size + * const uint_t recvsz; -- recv size + */ + +#else +extern CLIENT * clnt_tli_create(); +#endif + +/* + * Low level clnt create routine for connectionful transports, e.g. tcp. + */ +#ifdef __STDC__ +extern CLIENT * clnt_vc_create(const int, struct netbuf *, + const rpcprog_t, const rpcvers_t, const uint_t, const uint_t); +/* + * const int fd; -- open file descriptor + * const struct netbuf *svcaddr; -- servers address + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const uint_t sendsz; -- buffer recv size + * const uint_t recvsz; -- buffer send size + */ +#else +extern CLIENT * clnt_vc_create(); +#endif + +/* + * Low level clnt create routine for connectionless transports, e.g. udp. + */ +#ifdef __STDC__ +extern CLIENT * clnt_dg_create(const int, struct netbuf *, + const rpcprog_t, const rpcvers_t, const uint_t, const uint_t); +/* + * const int fd; -- open file descriptor + * const struct netbuf *svcaddr; -- servers address + * const rpcprog_t program; -- program number + * const rpcvers_t version; -- version number + * const uint_t sendsz; -- buffer recv size + * const uint_t recvsz; -- buffer send size + */ +#else +extern CLIENT * clnt_dg_create(); +#endif + +/* + * Memory based rpc (for speed check and testing) + * CLIENT * + * clnt_raw_create(prog, vers) + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + */ +#ifdef __STDC__ +extern CLIENT *clnt_raw_create(const rpcprog_t, const rpcvers_t); +#else +extern CLIENT *clnt_raw_create(); +#endif + +/* + * Client creation routine over doors transport. + */ +#ifdef __STDC__ +extern CLIENT * clnt_door_create(const rpcprog_t, const rpcvers_t, + const uint_t); +/* + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const uint_t sendsz; -- max send size + */ +#else +extern CLIENT * clnt_door_create(); +#endif + +/* + * internal function. Not for general use. Subject to rapid change. + */ +#ifdef __STDC__ +extern CLIENT *clnt_create_service_timed(const char *, + const char *, + const rpcprog_t, + const rpcvers_t, + const ushort_t, + const char *, + const struct timeval *); +#else +extern CLIENT *clnt_create_service_timed(); +#endif + +/* + * Print why creation failed + */ +#ifdef __STDC__ +void clnt_pcreateerror(const char *); /* stderr */ +char *clnt_spcreateerror(const char *); /* string */ +#else +void clnt_pcreateerror(); +char *clnt_spcreateerror(); +#endif + +/* + * Like clnt_perror(), but is more verbose in its output + */ +#ifdef __STDC__ +void clnt_perrno(const enum clnt_stat); /* stderr */ +#else +void clnt_perrno(); +#endif + +/* + * Print an error message, given the client error code + */ +#ifdef __STDC__ +void clnt_perror(const CLIENT *, const char *); +#else +void clnt_perror(); +#endif + +/* + * If a creation fails, the following allows the user to figure out why. + */ +struct rpc_createerr { + enum clnt_stat cf_stat; + struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ +}; + +#ifdef _REENTRANT +extern struct rpc_createerr *__rpc_createerr(); +#define rpc_createerr (*(__rpc_createerr())) +#else +extern struct rpc_createerr rpc_createerr; +#endif /* _REENTRANT */ + +/* + * The simplified interface: + * enum clnt_stat + * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) + * const char *host; + * const rpcprog_t prognum; + * const rpcvers_t versnum; + * const rpcproc_t procnum; + * const xdrproc_t inproc, outproc; + * const char *in; + * char *out; + * const char *nettype; + */ +#ifdef __STDC__ +extern enum clnt_stat rpc_call(const char *, const rpcprog_t, const rpcvers_t, + const rpcproc_t, const xdrproc_t, const char *, const xdrproc_t, + char *, const char *); +#else +extern enum clnt_stat rpc_call(); +#endif + +#ifdef _REENTRANT +extern struct rpc_err *__rpc_callerr(); +#define rpc_callerr (*(__rpc_callerr())) +#else +extern struct rpc_err rpc_callerr; +#endif /* _REENTRANT */ + +/* + * RPC broadcast interface + * The call is broadcasted to all locally connected nets. + * + * extern enum clnt_stat + * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, + * eachresult, nettype) + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const rpcproc_t proc; -- procedure number + * const xdrproc_t xargs; -- xdr routine for args + * caddr_t argsp; -- pointer to args + * const xdrproc_t xresults; -- xdr routine for results + * caddr_t resultsp; -- pointer to results + * const resultproc_t eachresult; -- call with each result + * const char *nettype; -- Transport type + * + * For each valid response received, the procedure eachresult is called. + * Its form is: + * done = eachresult(resp, raddr, nconf) + * bool_t done; + * caddr_t resp; + * struct netbuf *raddr; + * struct netconfig *nconf; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. nconf is the transport + * on which the response was received. + * + * extern enum clnt_stat + * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, + * eachresult, inittime, waittime, nettype) + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const rpcproc_t proc; -- procedure number + * const xdrproc_t xargs; -- xdr routine for args + * caddr_t argsp; -- pointer to args + * const xdrproc_t xresults; -- xdr routine for results + * caddr_t resultsp; -- pointer to results + * const resultproc_t eachresult; -- call with each result + * const int inittime; -- how long to wait initially + * const int waittime; -- maximum time to wait + * const char *nettype; -- Transport type + */ + +typedef bool_t(*resultproc_t)( +#ifdef __STDC__ + caddr_t, + ... /* for backward compatibility */ +#endif /* __STDC__ */ +); +#ifdef __STDC__ +extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t, + const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, + caddr_t, const resultproc_t, const char *); +extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t, + const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, caddr_t, + const resultproc_t, const int, const int, const char *); +#else +extern enum clnt_stat rpc_broadcast(); +extern enum clnt_stat rpc_broadcast_exp(); +#endif +#endif /* !_KERNEL */ + +/* + * Copy error message to buffer. + */ +#ifdef __STDC__ +const char *clnt_sperrno(const enum clnt_stat); +#else +char *clnt_sperrno(); /* string */ +#endif + +/* + * Print an error message, given the client error code + */ +#ifdef __STDC__ +char *clnt_sperror(const CLIENT *, const char *); +#else +char *clnt_sperror(); +#endif + +/* + * Client side rpc control routine for rpcbind. + */ +#ifdef __STDC__ +bool_t __rpc_control(int, void *); +#else +bool_t __rpc_control(); +#endif + +#ifdef __cplusplus +} +#endif + +#ifdef PORTMAP +/* For backward compatibility */ +#include +#endif + +#endif /* !_RPC_CLNT_H */ diff --git a/illumos-x86_64/usr/include/rpc/clnt_soc.h b/illumos-x86_64/usr/include/rpc/clnt_soc.h new file mode 100644 index 00000000..e5b3a5a4 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/clnt_soc.h @@ -0,0 +1,170 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * clnt.h - Client side remote procedure call interface. + */ + +#ifndef _RPC_CLNT_SOC_H +#define _RPC_CLNT_SOC_H + +/* + * All the following declarations are only for backward compatibility + * with SUNOS 4.0. + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ + +/* + * callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) + * char *host; + * rpcprog_t prognum; + * rpcvers_t versnum; + * rpcproc_t procnum; + * xdrproc_t inproc, outproc; + * char *in, *out; + */ +#ifdef __STDC__ +extern int callrpc(char *, rpcprog_t, rpcvers_t, rpcproc_t, xdrproc_t, char *, + xdrproc_t, char *); +#else +extern int callrpc(); +#endif + + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, fdp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * rpcprog_t prog; + * rpcvers_t version; + * int *fdp; + * uint_t sendsz; + * uint_t recvsz; + */ +#ifdef __STDC__ +extern CLIENT *clnttcp_create(struct sockaddr_in *, rpcprog_t, rpcvers_t, + int *, uint_t, uint_t); +#else +extern CLIENT *clnttcp_create(); +#endif + + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, fdp) + * struct sockaddr_in *raddr; + * rpcprog_t program; + * rpcvers_t version; + * struct timeval wait; + * int *fdp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, fdp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * rpcprog_t program; + * rpcvers_t version; + * struct timeval wait; + * int *fdp; + * uint_t sendsz; + * uint_t recvsz; + * + */ +#ifdef __STDC__ +extern CLIENT *clntudp_create(struct sockaddr_in *, rpcprog_t, rpcvers_t, + struct timeval, int *); +extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, rpcprog_t, rpcvers_t, + struct timeval, int *, uint_t, uint_t); +#else +extern CLIENT *clntudp_create(); +extern CLIENT *clntudp_bufcreate(); +#endif + +/* + * Memory based rpc (for speed check and testing) + * CLIENT * + * clntraw_create(prog, vers) + * rpcprog_t prog; + * rpcvers_t vers; + */ +#ifdef __STDC__ +extern CLIENT *clntraw_create(rpcprog_t, rpcvers_t); +#else +extern CLIENT *clntraw_create(); +#endif + +/* + * get the local host's IP address without consulting + * name service library functions + * void + * get_myaddress(addr) + * struct sockaddr_in *addr; + */ +#ifdef __STDC__ +extern void get_myaddress(struct sockaddr_in *); +#else +extern void get_myaddress(); +#endif + +/* + * get the port number on the host for the rpc program, version and proto + * void + * getrpcport(host, prognum, versnum, proto) + * char *host; + * rpcprog_t prognum; + * rpcvers_t versnum; + * rpcprot_t proto; + */ +#ifdef __STDC__ +extern ushort_t getrpcport(char *, rpcprog_t, rpcvers_t, rpcprot_t); +#else +extern ushort_t getrpcport(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_CLNT_SOC_H */ diff --git a/illumos-x86_64/usr/include/rpc/clnt_stat.h b/illumos-x86_64/usr/include/rpc/clnt_stat.h new file mode 100644 index 00000000..41d34eab --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/clnt_stat.h @@ -0,0 +1,106 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1986 - 1991, 1994, 1996, 1997, 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * clnt_stat.h - Client side remote procedure call enum + * + */ + +#ifndef _RPC_CLNT_STAT_H +#define _RPC_CLNT_STAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +enum clnt_stat { + RPC_SUCCESS = 0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS = 1, /* can't encode arguments */ + RPC_CANTDECODERES = 2, /* can't decode results */ + RPC_CANTSEND = 3, /* failure in sending call */ + RPC_CANTRECV = 4, + /* failure in receiving result */ + RPC_TIMEDOUT = 5, /* call timed out */ + RPC_INTR = 18, /* call interrupted */ + RPC_UDERROR = 23, /* recv got uderr indication */ + /* + * remote errors + */ + RPC_VERSMISMATCH = 6, /* rpc versions not compatible */ + RPC_AUTHERROR = 7, /* authentication error */ + RPC_PROGUNAVAIL = 8, /* program not available */ + RPC_PROGVERSMISMATCH = 9, /* program version mismatched */ + RPC_PROCUNAVAIL = 10, /* procedure unavailable */ + RPC_CANTDECODEARGS = 11, /* decode arguments error */ + RPC_SYSTEMERROR = 12, /* generic "other problem" */ + + /* + * rpc_call & clnt_create errors + */ + RPC_UNKNOWNHOST = 13, /* unknown host name */ + RPC_UNKNOWNPROTO = 17, /* unknown protocol */ + RPC_UNKNOWNADDR = 19, /* Remote address unknown */ + RPC_NOBROADCAST = 21, /* Broadcasting not supported */ + + /* + * rpcbind errors + */ + RPC_RPCBFAILURE = 14, /* the pmapper failed in its call */ +#define RPC_PMAPFAILURE RPC_RPCBFAILURE + RPC_PROGNOTREGISTERED = 15, /* remote program is not registered */ + RPC_N2AXLATEFAILURE = 22, + /* Name to address translation failed */ + /* + * Misc error in the TLI library + */ + RPC_TLIERROR = 20, + /* + * unspecified error + */ + RPC_FAILED = 16, + /* + * asynchronous errors + */ + RPC_INPROGRESS = 24, + RPC_STALERACHANDLE = 25, + RPC_CANTCONNECT = 26, /* couldn't make connection (cots) */ + RPC_XPRTFAILED = 27, /* received discon from remote (cots) */ + RPC_CANTCREATESTREAM = 28, /* can't push rpc module (cots) */ + /* + * non blocking mode errors + */ + RPC_CANTSTORE = 29 /* fail to store a pending message */ + +}; + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_CLNT_STAT_H */ diff --git a/illumos-x86_64/usr/include/rpc/des_crypt.h b/illumos-x86_64/usr/include/rpc/des_crypt.h new file mode 100644 index 00000000..2bff48e9 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/des_crypt.h @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * des_crypt.h, des library routine interface + */ + +#ifndef _DES_DES_CRYPT_H +#define _DES_DES_CRYPT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DES_MAXDATA 8192 /* max bytes encrypted in one call */ +#define DES_DIRMASK (1 << 0) +#define DES_ENCRYPT (0 * DES_DIRMASK) /* Encrypt */ +#define DES_DECRYPT (1 * DES_DIRMASK) /* Decrypt */ + + +#define DES_DEVMASK (1 << 1) +#define DES_HW (0 * DES_DEVMASK) /* Use hardware device */ +#define DES_SW (1 * DES_DEVMASK) /* Use software device */ + + +#define DESERR_NONE 0 /* succeeded */ +#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ +#define DESERR_HWERROR 2 /* failed, hardware/driver error */ +#define DESERR_BADPARAM 3 /* failed, bad parameter to call */ + +#define DES_FAILED(err) \ + ((err) > DESERR_NOHWDEVICE) + +/* + * cbc_crypt() + * ecb_crypt() + * + * Encrypt (or decrypt) len bytes of a buffer buf. + * The length must be a multiple of eight. + * The key should have odd parity in the low bit of each byte. + * ivec is the input vector, and is updated to the new one (cbc only). + * The mode is created by oring together the appropriate parameters. + * DESERR_NOHWDEVICE is returned if DES_HW was specified but + * there was no hardware to do it on (the data will still be + * encrypted though, in software). + */ + + +/* + * Cipher Block Chaining mode + */ +#ifdef __STDC__ +int cbc_crypt(char *key, char *buf, size_t len, unsigned int mode, char *ivec); +#else +int cbc_crypt(); +#endif + + +/* + * Electronic Code Book mode + */ +#ifdef __STDC__ +int ecb_crypt(char *key, char *buf, size_t len, unsigned int mode); +#else +int ecb_crypt(); +#endif + + +#ifndef _KERNEL +/* + * Set des parity for a key. + * DES parity is odd and in the low bit of each byte + */ +#ifdef __STDC__ +void des_setparity(char *key); +#else +void des_setparity(); +#endif +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DES_DES_CRYPT_H */ diff --git a/illumos-x86_64/usr/include/rpc/key_prot.h b/illumos-x86_64/usr/include/rpc/key_prot.h new file mode 100644 index 00000000..c403ddaa --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/key_prot.h @@ -0,0 +1,467 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _KEY_PROT_H_RPCGEN +#define _KEY_PROT_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ + +/* + * Compiled from key_prot.x using rpcgen. + * DO NOT EDIT THIS FILE! + * This is NOT source code! + */ +#define PROOT 3 +#define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b" +#define HEXKEYBYTES 48 +#define KEYSIZE 192 +#define KEYBYTES 24 +#define KEYCHECKSUMSIZE 16 + +enum keystatus { + KEY_SUCCESS = 0, + KEY_NOSECRET = 1, + KEY_UNKNOWN = 2, + KEY_SYSTEMERR = 3, + KEY_BADALG = 4, + KEY_BADLEN = 5 +}; +typedef enum keystatus keystatus; + +typedef char keybuf[HEXKEYBYTES]; + +typedef struct { + u_int keybuf3_len; + char *keybuf3_val; +} keybuf3; + +typedef char *netnamestr; + +typedef int keylen_t; + +typedef int algtype_t; + +struct mechtype { + keylen_t keylen; + algtype_t algtype; +}; +typedef struct mechtype mechtype; + +typedef int keynum_t; + +typedef struct { + u_int deskeyarray_len; + des_block *deskeyarray_val; +} deskeyarray; + +struct cryptkeyarg { + netnamestr remotename; + des_block deskey; +}; +typedef struct cryptkeyarg cryptkeyarg; + +struct cryptkeyarg2 { + netnamestr remotename; + netobj remotekey; + des_block deskey; +}; +typedef struct cryptkeyarg2 cryptkeyarg2; + +struct cryptkeyarg3 { + netnamestr remotename; + keybuf3 remotekey; + deskeyarray deskey; + algtype_t algtype; + keylen_t keylen; +}; +typedef struct cryptkeyarg3 cryptkeyarg3; + +struct cryptkeyres { + keystatus status; + union { + des_block deskey; + } cryptkeyres_u; +}; +typedef struct cryptkeyres cryptkeyres; + +struct cryptkeyres3 { + keystatus status; + union { + deskeyarray deskey; + } cryptkeyres3_u; +}; +typedef struct cryptkeyres3 cryptkeyres3; +#define MAXGIDS 16 + +struct unixcred { + u_int uid; + u_int gid; + struct { + u_int gids_len; + u_int *gids_val; + } gids; +}; +typedef struct unixcred unixcred; + +struct unixcred3 { + u_int uid; + u_int gid; + struct { + u_int gids_len; + u_int *gids_val; + } gids; +}; +typedef struct unixcred3 unixcred3; + +struct getcredres { + keystatus status; + union { + unixcred cred; + } getcredres_u; +}; +typedef struct getcredres getcredres; + +struct getcredres3 { + keystatus status; + union { + unixcred3 cred; + } getcredres3_u; +}; +typedef struct getcredres3 getcredres3; + +struct key_netstarg { + keybuf st_priv_key; + keybuf st_pub_key; + netnamestr st_netname; +}; +typedef struct key_netstarg key_netstarg; + +struct key_netstarg3 { + keybuf3 st_priv_key; + keybuf3 st_pub_key; + netnamestr st_netname; + algtype_t algtype; + keylen_t keylen; + des_block userkey; +}; +typedef struct key_netstarg3 key_netstarg3; + +struct key_netstres { + keystatus status; + union { + key_netstarg knet; + } key_netstres_u; +}; +typedef struct key_netstres key_netstres; + +struct key_netstres3 { + keystatus status; + union { + key_netstarg3 knet; + } key_netstres3_u; +}; +typedef struct key_netstres3 key_netstres3; + +struct deskeyarg3 { + keybuf3 pub_key; + int nkeys; + algtype_t algtype; + keylen_t keylen; +}; +typedef struct deskeyarg3 deskeyarg3; + +struct setkeyarg3 { + keybuf3 key; + des_block userkey; + algtype_t algtype; + keylen_t keylen; +}; +typedef struct setkeyarg3 setkeyarg3; + +#ifndef opaque +#define opaque char +#endif + + +#define KEY_PROG 100029 +#define KEY_VERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define KEY_SET 1 +extern keystatus * key_set_1(char *, CLIENT *); +extern keystatus * key_set_1_svc(char *, struct svc_req *); +#define KEY_ENCRYPT 2 +extern cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_DECRYPT 3 +extern cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_GEN 4 +extern des_block * key_gen_1(void *, CLIENT *); +extern des_block * key_gen_1_svc(void *, struct svc_req *); +#define KEY_GETCRED 5 +extern getcredres * key_getcred_1(netnamestr *, CLIENT *); +extern getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); +extern int key_prog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define KEY_SET 1 +extern keystatus * key_set_1(); +extern keystatus * key_set_1_svc(); +#define KEY_ENCRYPT 2 +extern cryptkeyres * key_encrypt_1(); +extern cryptkeyres * key_encrypt_1_svc(); +#define KEY_DECRYPT 3 +extern cryptkeyres * key_decrypt_1(); +extern cryptkeyres * key_decrypt_1_svc(); +#define KEY_GEN 4 +extern des_block * key_gen_1(); +extern des_block * key_gen_1_svc(); +#define KEY_GETCRED 5 +extern getcredres * key_getcred_1(); +extern getcredres * key_getcred_1_svc(); +extern int key_prog_1_freeresult(); +#endif /* K&R C */ +#define KEY_VERS2 2 + +#if defined(__STDC__) || defined(__cplusplus) +extern keystatus * key_set_2(char *, CLIENT *); +extern keystatus * key_set_2_svc(char *, struct svc_req *); +extern cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern des_block * key_gen_2(void *, CLIENT *); +extern des_block * key_gen_2_svc(void *, struct svc_req *); +extern getcredres * key_getcred_2(netnamestr *, CLIENT *); +extern getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); +#define KEY_ENCRYPT_PK 6 +extern cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_DECRYPT_PK 7 +extern cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_NET_PUT 8 +extern keystatus * key_net_put_2(key_netstarg *, CLIENT *); +extern keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); +#define KEY_NET_GET 9 +extern key_netstres * key_net_get_2(void *, CLIENT *); +extern key_netstres * key_net_get_2_svc(void *, struct svc_req *); +#define KEY_GET_CONV 10 +extern cryptkeyres * key_get_conv_2(char *, CLIENT *); +extern cryptkeyres * key_get_conv_2_svc(char *, struct svc_req *); +extern int key_prog_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +extern keystatus * key_set_2(); +extern keystatus * key_set_2_svc(); +extern cryptkeyres * key_encrypt_2(); +extern cryptkeyres * key_encrypt_2_svc(); +extern cryptkeyres * key_decrypt_2(); +extern cryptkeyres * key_decrypt_2_svc(); +extern des_block * key_gen_2(); +extern des_block * key_gen_2_svc(); +extern getcredres * key_getcred_2(); +extern getcredres * key_getcred_2_svc(); +#define KEY_ENCRYPT_PK 6 +extern cryptkeyres * key_encrypt_pk_2(); +extern cryptkeyres * key_encrypt_pk_2_svc(); +#define KEY_DECRYPT_PK 7 +extern cryptkeyres * key_decrypt_pk_2(); +extern cryptkeyres * key_decrypt_pk_2_svc(); +#define KEY_NET_PUT 8 +extern keystatus * key_net_put_2(); +extern keystatus * key_net_put_2_svc(); +#define KEY_NET_GET 9 +extern key_netstres * key_net_get_2(); +extern key_netstres * key_net_get_2_svc(); +#define KEY_GET_CONV 10 +extern cryptkeyres * key_get_conv_2(); +extern cryptkeyres * key_get_conv_2_svc(); +extern int key_prog_2_freeresult(); +#endif /* K&R C */ +#define KEY_VERS3 3 + +#if defined(__STDC__) || defined(__cplusplus) +extern keystatus * key_set_3(char *, CLIENT *); +extern keystatus * key_set_3_svc(char *, struct svc_req *); +extern cryptkeyres * key_encrypt_3(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_3_svc(cryptkeyarg *, struct svc_req *); +extern cryptkeyres * key_decrypt_3(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_3_svc(cryptkeyarg *, struct svc_req *); +extern des_block * key_gen_3(void *, CLIENT *); +extern des_block * key_gen_3_svc(void *, struct svc_req *); +extern getcredres * key_getcred_3(netnamestr *, CLIENT *); +extern getcredres * key_getcred_3_svc(netnamestr *, struct svc_req *); +extern cryptkeyres * key_encrypt_pk_3(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_encrypt_pk_3_svc(cryptkeyarg2 *, struct svc_req *); +extern cryptkeyres * key_decrypt_pk_3(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_decrypt_pk_3_svc(cryptkeyarg2 *, struct svc_req *); +extern keystatus * key_net_put_3(key_netstarg *, CLIENT *); +extern keystatus * key_net_put_3_svc(key_netstarg *, struct svc_req *); +extern key_netstres * key_net_get_3(void *, CLIENT *); +extern key_netstres * key_net_get_3_svc(void *, struct svc_req *); +extern cryptkeyres * key_get_conv_3(char *, CLIENT *); +extern cryptkeyres * key_get_conv_3_svc(char *, struct svc_req *); +#define KEY_SET_3 11 +extern keystatus * key_set_3_3(setkeyarg3 *, CLIENT *); +extern keystatus * key_set_3_3_svc(setkeyarg3 *, struct svc_req *); +#define KEY_ENCRYPT_3 12 +extern cryptkeyres3 * key_encrypt_3_3(cryptkeyarg3 *, CLIENT *); +extern cryptkeyres3 * key_encrypt_3_3_svc(cryptkeyarg3 *, struct svc_req *); +#define KEY_DECRYPT_3 13 +extern cryptkeyres3 * key_decrypt_3_3(cryptkeyarg3 *, CLIENT *); +extern cryptkeyres3 * key_decrypt_3_3_svc(cryptkeyarg3 *, struct svc_req *); +#define KEY_GEN_3 14 +extern deskeyarray * key_gen_3_3(keynum_t *, CLIENT *); +extern deskeyarray * key_gen_3_3_svc(keynum_t *, struct svc_req *); +#define KEY_GETCRED_3 15 +extern getcredres3 * key_getcred_3_3(netnamestr *, CLIENT *); +extern getcredres3 * key_getcred_3_3_svc(netnamestr *, struct svc_req *); +#define KEY_ENCRYPT_PK_3 16 +extern cryptkeyres3 * key_encrypt_pk_3_3(cryptkeyarg3 *, CLIENT *); +extern cryptkeyres3 * key_encrypt_pk_3_3_svc(cryptkeyarg3 *, struct svc_req *); +#define KEY_DECRYPT_PK_3 17 +extern cryptkeyres3 * key_decrypt_pk_3_3(cryptkeyarg3 *, CLIENT *); +extern cryptkeyres3 * key_decrypt_pk_3_3_svc(cryptkeyarg3 *, struct svc_req *); +#define KEY_NET_PUT_3 18 +extern keystatus * key_net_put_3_3(key_netstarg3 *, CLIENT *); +extern keystatus * key_net_put_3_3_svc(key_netstarg3 *, struct svc_req *); +#define KEY_NET_GET_3 19 +extern key_netstres3 * key_net_get_3_3(key_netstarg3 *, CLIENT *); +extern key_netstres3 * key_net_get_3_3_svc(key_netstarg3 *, struct svc_req *); +#define KEY_GET_CONV_3 20 +extern cryptkeyres3 * key_get_conv_3_3(deskeyarg3 *, CLIENT *); +extern cryptkeyres3 * key_get_conv_3_3_svc(deskeyarg3 *, struct svc_req *); +#define KEY_CLEAR_3 21 +extern keystatus * key_clear_3_3(void *, CLIENT *); +extern keystatus * key_clear_3_3_svc(void *, struct svc_req *); +extern int key_prog_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +extern keystatus * key_set_3(); +extern keystatus * key_set_3_svc(); +extern cryptkeyres * key_encrypt_3(); +extern cryptkeyres * key_encrypt_3_svc(); +extern cryptkeyres * key_decrypt_3(); +extern cryptkeyres * key_decrypt_3_svc(); +extern des_block * key_gen_3(); +extern des_block * key_gen_3_svc(); +extern getcredres * key_getcred_3(); +extern getcredres * key_getcred_3_svc(); +extern cryptkeyres * key_encrypt_pk_3(); +extern cryptkeyres * key_encrypt_pk_3_svc(); +extern cryptkeyres * key_decrypt_pk_3(); +extern cryptkeyres * key_decrypt_pk_3_svc(); +extern keystatus * key_net_put_3(); +extern keystatus * key_net_put_3_svc(); +extern key_netstres * key_net_get_3(); +extern key_netstres * key_net_get_3_svc(); +extern cryptkeyres * key_get_conv_3(); +extern cryptkeyres * key_get_conv_3_svc(); +#define KEY_SET_3 11 +extern keystatus * key_set_3_3(); +extern keystatus * key_set_3_3_svc(); +#define KEY_ENCRYPT_3 12 +extern cryptkeyres3 * key_encrypt_3_3(); +extern cryptkeyres3 * key_encrypt_3_3_svc(); +#define KEY_DECRYPT_3 13 +extern cryptkeyres3 * key_decrypt_3_3(); +extern cryptkeyres3 * key_decrypt_3_3_svc(); +#define KEY_GEN_3 14 +extern deskeyarray * key_gen_3_3(); +extern deskeyarray * key_gen_3_3_svc(); +#define KEY_GETCRED_3 15 +extern getcredres3 * key_getcred_3_3(); +extern getcredres3 * key_getcred_3_3_svc(); +#define KEY_ENCRYPT_PK_3 16 +extern cryptkeyres3 * key_encrypt_pk_3_3(); +extern cryptkeyres3 * key_encrypt_pk_3_3_svc(); +#define KEY_DECRYPT_PK_3 17 +extern cryptkeyres3 * key_decrypt_pk_3_3(); +extern cryptkeyres3 * key_decrypt_pk_3_3_svc(); +#define KEY_NET_PUT_3 18 +extern keystatus * key_net_put_3_3(); +extern keystatus * key_net_put_3_3_svc(); +#define KEY_NET_GET_3 19 +extern key_netstres3 * key_net_get_3_3(); +extern key_netstres3 * key_net_get_3_3_svc(); +#define KEY_GET_CONV_3 20 +extern cryptkeyres3 * key_get_conv_3_3(); +extern cryptkeyres3 * key_get_conv_3_3_svc(); +#define KEY_CLEAR_3 21 +extern keystatus * key_clear_3_3(); +extern keystatus * key_clear_3_3_svc(); +extern int key_prog_3_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_keystatus(XDR *, keystatus*); +extern bool_t xdr_keybuf(XDR *, keybuf); +extern bool_t xdr_keybuf3(XDR *, keybuf3*); +extern bool_t xdr_netnamestr(XDR *, netnamestr*); +extern bool_t xdr_keylen_t(XDR *, keylen_t*); +extern bool_t xdr_algtype_t(XDR *, algtype_t*); +extern bool_t xdr_mechtype(XDR *, mechtype*); +extern bool_t xdr_keynum_t(XDR *, keynum_t*); +extern bool_t xdr_deskeyarray(XDR *, deskeyarray*); +extern bool_t xdr_cryptkeyarg(XDR *, cryptkeyarg*); +extern bool_t xdr_cryptkeyarg2(XDR *, cryptkeyarg2*); +extern bool_t xdr_cryptkeyarg3(XDR *, cryptkeyarg3*); +extern bool_t xdr_cryptkeyres(XDR *, cryptkeyres*); +extern bool_t xdr_cryptkeyres3(XDR *, cryptkeyres3*); +extern bool_t xdr_unixcred(XDR *, unixcred*); +extern bool_t xdr_unixcred3(XDR *, unixcred3*); +extern bool_t xdr_getcredres(XDR *, getcredres*); +extern bool_t xdr_getcredres3(XDR *, getcredres3*); +extern bool_t xdr_key_netstarg(XDR *, key_netstarg*); +extern bool_t xdr_key_netstarg3(XDR *, key_netstarg3*); +extern bool_t xdr_key_netstres(XDR *, key_netstres*); +extern bool_t xdr_key_netstres3(XDR *, key_netstres3*); +extern bool_t xdr_deskeyarg3(XDR *, deskeyarg3*); +extern bool_t xdr_setkeyarg3(XDR *, setkeyarg3*); + +#else /* K&R C */ +extern bool_t xdr_keystatus(); +extern bool_t xdr_keybuf(); +extern bool_t xdr_keybuf3(); +extern bool_t xdr_netnamestr(); +extern bool_t xdr_keylen_t(); +extern bool_t xdr_algtype_t(); +extern bool_t xdr_mechtype(); +extern bool_t xdr_keynum_t(); +extern bool_t xdr_deskeyarray(); +extern bool_t xdr_cryptkeyarg(); +extern bool_t xdr_cryptkeyarg2(); +extern bool_t xdr_cryptkeyarg3(); +extern bool_t xdr_cryptkeyres(); +extern bool_t xdr_cryptkeyres3(); +extern bool_t xdr_unixcred(); +extern bool_t xdr_unixcred3(); +extern bool_t xdr_getcredres(); +extern bool_t xdr_getcredres3(); +extern bool_t xdr_key_netstarg(); +extern bool_t xdr_key_netstarg3(); +extern bool_t xdr_key_netstres(); +extern bool_t xdr_key_netstres3(); +extern bool_t xdr_deskeyarg3(); +extern bool_t xdr_setkeyarg3(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_KEY_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpc/nettype.h b/illumos-x86_64/usr/include/rpc/nettype.h new file mode 100644 index 00000000..07b30095 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/nettype.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1996 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * nettype.h, Nettype definitions. + * All for the topmost layer of rpc + * + */ + +#ifndef _RPC_NETTYPE_H +#define _RPC_NETTYPE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define _RPC_NONE 0 +#define _RPC_NETPATH 1 +#define _RPC_VISIBLE 2 +#define _RPC_CIRCUIT_V 3 +#define _RPC_DATAGRAM_V 4 +#define _RPC_CIRCUIT_N 5 +#define _RPC_DATAGRAM_N 6 +#define _RPC_TCP 7 +#define _RPC_UDP 8 +#define _RPC_LOCAL 9 +#define _RPC_DOOR 10 +#define _RPC_DOOR_LOCAL 11 +#define _RPC_DOOR_NETPATH 12 + +#ifdef __STDC__ +extern void *__rpc_setconf(char *); +extern void __rpc_endconf(void *); +extern struct netconfig *__rpc_getconf(void *); +extern struct netconfig *__rpc_getconfip(char *); +#else +extern void *__rpc_setconf(); +extern void __rpc_endconf(); +extern struct netconfig *__rpc_getconf(); +extern struct netconfig *__rpc_getconfip(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_NETTYPE_H */ diff --git a/illumos-x86_64/usr/include/rpc/pmap_clnt.h b/illumos-x86_64/usr/include/rpc/pmap_clnt.h new file mode 100644 index 00000000..b77a0cbe --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/pmap_clnt.h @@ -0,0 +1,102 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +#ifndef _RPC_PMAP_CLNT_H +#define _RPC_PMAP_CLNT_H + +/* + * pmap_clnt.h + * Supplies C routines to get to portmap services. + */ + +#include + +#ifdef __STDC__ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Usage: + * success = pmap_set(program, version, protocol, port); + * success = pmap_unset(program, version); + * port = pmap_getport(address, program, version, protocol); + * head = pmap_getmaps(address); + * clnt_stat = pmap_rmtcall(address, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, port_ptr) + * (works for udp only.) + * clnt_stat = clnt_broadcast(program, version, procedure, + * xdrargs, argsp, xdrres, resp, eachresult) + * (like pmap_rmtcall, except the call is broadcasted to all + * locally connected nets. For each valid response received, + * the procedure eachresult is called. Its form is: + * done = eachresult(resp, raddr) + * bool_t done; + * caddr_t resp; + * struct sockaddr_in raddr; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. + */ + +#ifdef __STDC__ +extern bool_t pmap_set(rpcprog_t, rpcvers_t, rpcprot_t, unsigned short port); +extern bool_t pmap_unset(rpcprog_t, rpcvers_t); +extern struct pmaplist *pmap_getmaps(struct sockaddr_in *); +extern ushort_t pmap_getport(struct sockaddr_in *, rpcprog_t, rpcvers_t, + rpcprot_t); +#ifndef _KERNEL +enum clnt_stat clnt_broadcast(rpcprog_t, rpcvers_t, rpcproc_t, xdrproc_t, + char *, xdrproc_t, char *, resultproc_t); +enum clnt_stat pmap_rmtcall(struct sockaddr_in *, rpcprog_t, rpcvers_t, + rpcproc_t, xdrproc_t, caddr_t, xdrproc_t, caddr_t, struct timeval, + rpcport_t *); +#endif +#else +extern bool_t pmap_set(); +extern bool_t pmap_unset(); +extern struct pmaplist *pmap_getmaps(); +extern ushort_t pmap_getport(); +#ifndef _KERNEL +enum clnt_stat clnt_broadcast(); +enum clnt_stat pmap_rmtcall(); +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_PMAP_CLNT_H */ diff --git a/illumos-x86_64/usr/include/rpc/pmap_prot.h b/illumos-x86_64/usr/include/rpc/pmap_prot.h new file mode 100644 index 00000000..e0ca6f54 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/pmap_prot.h @@ -0,0 +1,258 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _PMAP_PROT_H_RPCGEN +#define _PMAP_PROT_H_RPCGEN + +#include +#ifndef _KERNEL +#include +#include +#endif /* !_KERNEL */ +/* + * Copyright (c) 1984,1989 by Sun Microsystems, Inc. + */ +/* from pmap_prot.x */ + +#ifndef _KERNEL + +/* + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (rpcport_t). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist_ptr) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, + * encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#define PMAPPORT 111 + + +/* + * A mapping of (program, version, protocol) to port number + */ + +struct pmap { + rpcprog_t pm_prog; + rpcvers_t pm_vers; + rpcprot_t pm_prot; + rpcport_t pm_port; +}; +typedef struct pmap pmap; + +typedef pmap PMAP; + + +/* + * Supported values for the "prot" field + */ + +#define PMAP_IPPROTO_TCP 6 +#define PMAP_IPPROTO_UDP 17 + + +/* + * A list of mappings + * + * Below are two definitions for the pmaplist structure. This is done because + * xdr_pmaplist() is specified to take a struct pmaplist **, rather than a + * struct pmaplist * that rpcgen would produce. One version of the pmaplist + * structure (actually called pm__list) is used with rpcgen, and the other is + * defined only in the header file for compatibility with the specified + * interface. + */ + +struct pm__list { + pmap pml_map; + struct pm__list *pml_next; +}; +typedef struct pm__list pm__list; + +typedef pm__list *pmaplist_ptr; + +struct pmaplist { + PMAP pml_map; + struct pmaplist *pml_next; +}; + +typedef struct pmaplist pmaplist; +typedef struct pmaplist PMAPLIST; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __STDC__ +extern bool_t xdr_pmaplist(XDR *, pmaplist**); +#else /* K&R C */ +bool_t xdr_pmaplist(); +#endif +#ifdef __cplusplus +} +#endif + + +/* + * Arguments to callit + */ + +struct rmtcallargs { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + struct { + u_int args_len; + char *args_val; + } args; +}; +typedef struct rmtcallargs rmtcallargs; + +/* + * Client-side only representation of rmtcallargs structure. + * + * The routine that XDRs the rmtcallargs structure must deal with the + * opaque arguments in the "args" structure. xdr_rmtcall_args() needs to be + * passed the XDR routine that knows the args' structure. This routine + * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since + * the application being called knows the args structure already. So we use a + * different "XDR" structure on the client side, p_rmtcallargs, which includes + * the args' XDR routine. + */ +struct p_rmtcallargs { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + struct { + u_int args_len; + char *args_val; + } args; + xdrproc_t xdr_args; /* encodes args */ +}; + + + +/* + * Results of callit + */ + +struct rmtcallres { + rpcport_t port; + struct { + u_int res_len; + char *res_val; + } res; +}; +typedef struct rmtcallres rmtcallres; + +/* + * Client-side only representation of rmtcallres structure. + */ +struct p_rmtcallres { + rpcport_t port; + struct { + u_int res_len; + char *res_val; + } res; + xdrproc_t xdr_res; /* decodes res */ +}; + + +#define PMAPVERS_PROTO ((rpcvers_t)2) +#define PMAPVERS_ORIG ((rpcvers_t)1) + +#else /* ndef _KERNEL */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PMAPPORT 111 + +struct pmap { + rpcprog_t pm_prog; + rpcvers_t pm_vers; + rpcprot_t pm_prot; + rpcport_t pm_port; +}; +typedef struct pmap PMAP; +#ifdef __STDC__ +extern bool_t xdr_pmap (XDR *, struct pmap *); +#else +extern bool_t xdr_pmap (); +#endif + +struct pmaplist { + struct pmap pml_map; + struct pmaplist *pml_next; +}; +typedef struct pmaplist PMAPLIST; +typedef struct pmaplist *pmaplist_ptr; + + +#ifdef __cplusplus +} +#endif + +#endif /* ndef _KERNEL */ + +#define PMAPPROG 100000 +#define PMAPVERS 2 +#define PMAPPROC_NULL 0 +extern enum clnt_stat pmapproc_null_2(); +extern bool_t pmapproc_null_2_svc(); +#define PMAPPROC_SET 1 +extern enum clnt_stat pmapproc_set_2(); +extern bool_t pmapproc_set_2_svc(); +#define PMAPPROC_UNSET 2 +extern enum clnt_stat pmapproc_unset_2(); +extern bool_t pmapproc_unset_2_svc(); +#define PMAPPROC_GETPORT 3 +extern enum clnt_stat pmapproc_getport_2(); +extern bool_t pmapproc_getport_2_svc(); +#define PMAPPROC_DUMP 4 +extern enum clnt_stat pmapproc_dump_2(); +extern bool_t pmapproc_dump_2_svc(); +#define PMAPPROC_CALLIT 5 +extern enum clnt_stat pmapproc_callit_2(); +extern bool_t pmapproc_callit_2_svc(); +extern int pmapprog_2_freeresult(); + +/* the xdr functions */ +extern bool_t xdr_pmap(); +extern bool_t xdr_pm__list(); +extern bool_t xdr_pmaplist_ptr(); +extern bool_t xdr_rmtcallargs(); +extern bool_t xdr_rmtcallres(); + +#endif /* !_PMAP_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpc/pmap_prot.x b/illumos-x86_64/usr/include/rpc/pmap_prot.x new file mode 100644 index 00000000..99621a65 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/pmap_prot.x @@ -0,0 +1,274 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +%/* +% * Copyright (c) 1984,1989 by Sun Microsystems, Inc. +% */ + +%/* from pmap_prot.x */ + +#ifdef RPC_HDR +% +%#ifndef _KERNEL +% +#endif + +/* + * Port Mapper Protocol Specification (in RPC Language) + * derived from RFC 1057 + */ + +%/* +% * Protocol for the local binder service, or pmap. +% * +% * Copyright (C) 1984, Sun Microsystems, Inc. +% * +% * The following procedures are supported by the protocol: +% * +% * PMAPPROC_NULL() returns () +% * takes nothing, returns nothing +% * +% * PMAPPROC_SET(struct pmap) returns (bool_t) +% * TRUE is success, FALSE is failure. Registers the tuple +% * [prog, vers, prot, port]. +% * +% * PMAPPROC_UNSET(struct pmap) returns (bool_t) +% * TRUE is success, FALSE is failure. Un-registers pair +% * [prog, vers]. prot and port are ignored. +% * +% * PMAPPROC_GETPORT(struct pmap) returns (rpcport_t). +% * 0 is failure. Otherwise returns the port number where the pair +% * [prog, vers] is registered. It may lie! +% * +% * PMAPPROC_DUMP() RETURNS (struct pmaplist_ptr) +% * +% * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) +% * RETURNS (port, string<>); +% * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, +% * encapsulatedargs); +% * Calls the procedure on the local machine. If it is not registered, +% * this procedure is quite; ie it does not return error information!!! +% * This procedure only is supported on rpc/udp and calls via +% * rpc/udp. This routine only passes null authentication parameters. +% * This file has no interface to xdr routines for PMAPPROC_CALLIT. +% * +% * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. +% */ +% +const PMAPPORT = 111; /* portmapper port number */ +% +% +%/* +% * A mapping of (program, version, protocol) to port number +% */ + +struct pmap { + rpcprog_t pm_prog; + rpcvers_t pm_vers; + rpcprot_t pm_prot; + rpcport_t pm_port; +}; +#ifdef RPC_HDR +% +%typedef pmap PMAP; +% +#endif +% +%/* +% * Supported values for the "prot" field +% */ +% +const PMAP_IPPROTO_TCP = 6; /* protocol number for TCP/IP */ +const PMAP_IPPROTO_UDP = 17; /* protocol number for UDP/IP */ +% +% +%/* +% * A list of mappings +% * +% * Below are two definitions for the pmaplist structure. This is done because +% * xdr_pmaplist() is specified to take a struct pmaplist **, rather than a +% * struct pmaplist * that rpcgen would produce. One version of the pmaplist +% * structure (actually called pm__list) is used with rpcgen, and the other is +% * defined only in the header file for compatibility with the specified +% * interface. +% */ + +struct pm__list { + pmap pml_map; + struct pm__list *pml_next; +}; + +typedef pm__list *pmaplist_ptr; /* results of PMAPPROC_DUMP */ + +#ifdef RPC_HDR +% +%struct pmaplist { +% PMAP pml_map; +% struct pmaplist *pml_next; +%}; +% +%typedef struct pmaplist pmaplist; +%typedef struct pmaplist PMAPLIST; +% +%#ifdef __cplusplus +%extern "C" { +%#endif +%#ifdef __STDC__ +%extern bool_t xdr_pmaplist(XDR *, pmaplist**); +%#else /* K&R C */ +%bool_t xdr_pmaplist(); +%#endif +%#ifdef __cplusplus +%} +%#endif +% +#endif + +% +%/* +% * Arguments to callit +% */ + +struct rmtcallargs { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + opaque args<>; +}; +#ifdef RPC_HDR +% +%/* +% * Client-side only representation of rmtcallargs structure. +% * +% * The routine that XDRs the rmtcallargs structure must deal with the +% * opaque arguments in the "args" structure. xdr_rmtcall_args() needs to be +% * passed the XDR routine that knows the args' structure. This routine +% * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since +% * the application being called knows the args structure already. So we use a +% * different "XDR" structure on the client side, p_rmtcallargs, which includes +% * the args' XDR routine. +% */ +%struct p_rmtcallargs { +% rpcprog_t prog; +% rpcvers_t vers; +% rpcproc_t proc; +% struct { +% u_int args_len; +% char *args_val; +% } args; +% xdrproc_t xdr_args; /* encodes args */ +%}; +% +#endif /* def RPC_HDR */ +% +% +%/* +% * Results of callit +% */ + +struct rmtcallres { + rpcport_t port; + opaque res<>; +}; +#ifdef RPC_HDR +% +%/* +% * Client-side only representation of rmtcallres structure. +% */ +%struct p_rmtcallres { +% rpcport_t port; +% struct { +% u_int res_len; +% char *res_val; +% } res; +% xdrproc_t xdr_res; /* decodes res */ +%}; +% +#endif /* def RPC_HDR */ + +/* + * Port mapper procedures + */ + +program PMAPPROG { + version PMAPVERS { + void + PMAPPROC_NULL(void) = 0; + + bool + PMAPPROC_SET(pmap) = 1; + + bool + PMAPPROC_UNSET(pmap) = 2; + + rpcport_t + PMAPPROC_GETPORT(pmap) = 3; + + pmaplist_ptr + PMAPPROC_DUMP(void) = 4; + + rmtcallres + PMAPPROC_CALLIT(rmtcallargs) = 5; + } = 2; +} = 100000; +% +#ifdef RPC_HDR +%#define PMAPVERS_PROTO ((rpcvers_t)2) +%#define PMAPVERS_ORIG ((rpcvers_t)1) +% +%#else /* ndef _KERNEL */ +% +%#include +% +%#ifdef __cplusplus +%extern "C" { +%#endif +% +%#define PMAPPORT 111 +% +%struct pmap { +% rpcprog_t pm_prog; +% rpcvers_t pm_vers; +% rpcprot_t pm_prot; +% rpcport_t pm_port; +%}; +%typedef struct pmap PMAP; +%#ifdef __STDC__ +%extern bool_t xdr_pmap (XDR *, struct pmap *); +%#else +%extern bool_t xdr_pmap (); +%#endif +% +%struct pmaplist { +% struct pmap pml_map; +% struct pmaplist *pml_next; +%}; +%typedef struct pmaplist PMAPLIST; +%typedef struct pmaplist *pmaplist_ptr; +% +% +%#ifdef __cplusplus +%} +%#endif +% +%#endif /* ndef _KERNEL */ +#endif + diff --git a/illumos-x86_64/usr/include/rpc/pmap_rmt.h b/illumos-x86_64/usr/include/rpc/pmap_rmt.h new file mode 100644 index 00000000..6238a893 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/pmap_rmt.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +#ifndef _RPC_PMAP_RMT_H +#define _RPC_PMAP_RMT_H + +#ifndef _KERNEL + +#include + +#else /* ndef _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structures and XDR routines for parameters to and replies from + * the portmapper remote-call-service. + */ + +struct rmtcallargs { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + unsigned int arglen; + caddr_t args_ptr; + xdrproc_t xdr_args; +}; + +#ifdef __STDC__ +bool_t xdr_rmtcall_args(XDR *, struct rmtcallargs *); +#else +bool_t xdr_rmtcall_args(); +#endif + +struct rmtcallres { + rpcport_t *port_ptr; + uint_t resultslen; + caddr_t results_ptr; + xdrproc_t xdr_results; +}; +typedef struct rmtcallres rmtcallres; +#ifdef __STDC__ +bool_t xdr_rmtcall_args(XDR *, struct rmtcallargs *); +#else +bool_t xdr_rmtcall_args(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ndef _KERNEL */ + +#endif /* _RPC_PMAP_RMT_H */ diff --git a/illumos-x86_64/usr/include/rpc/rpc.h b/illumos-x86_64/usr/include/rpc/rpc.h new file mode 100644 index 00000000..2353e0e6 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpc.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * rpc.h, Just includes the billions of rpc header files necessary to + * do remote procedure calling. + * + */ + +#ifndef _RPC_RPC_H +#define _RPC_RPC_H + +#include /* some typedefs */ + +#ifndef _KERNEL +#include +#include +#include +#else +#include +#include +#include +#include +#endif + +#include /* generic (de)serializer */ +#include /* generic authenticator (client side) */ +#include /* generic client side rpc */ + +#include /* protocol for rpc messages */ +#include /* protocol for unix style cred */ +#include /* protocol for des style cred */ +#include /* generic socket info */ +#include /* GSS style security */ + +#include /* service manager and multiplexer */ +#include /* service side authenticator */ + +#ifndef _KERNEL +#ifndef _RPCB_PROT_H_RPCGEN /* Don't include before rpcb_prot defined */ +#include /* rpcbind interface functions */ +#endif +#include /* private server definitions */ +#endif + +#endif /* !_RPC_RPC_H */ diff --git a/illumos-x86_64/usr/include/rpc/rpc_com.h b/illumos-x86_64/usr/include/rpc/rpc_com.h new file mode 100644 index 00000000..0e02251d --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpc_com.h @@ -0,0 +1,134 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * rpc_com.h, Common definitions for both the server and client side. + * All for the topmost layer of rpc + * + */ + +#ifndef _RPC_RPC_COM_H +#define _RPC_RPC_COM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * File descriptor to be used on xxx_create calls to get default descriptor + */ +#define RPC_ANYSOCK -1 +#define RPC_ANYFD RPC_ANYSOCK +/* + * The max size of the transport, if the size cannot be determined + * by other means. + */ +#define RPC_MAXDATASIZE 9000 +#define RPC_MAXADDRSIZE 1024 + +/* + * Maximum size of universal address for INET/INET6 addressing. + * Computed as INET6_ADDRSTRLEN + (strlen(".255.255") for port) + */ +#define RPC_INET6_MAXUADDRSIZE 54 + +/* + * The type of user of the STREAMS module rpcmod. + */ +#define RPC_CLIENT 1 +#define RPC_SERVER 2 +#define RPC_TEST 3 + +#ifdef __STDC__ +extern uint_t __rpc_get_t_size(t_scalar_t, t_scalar_t); +extern uint_t __rpc_get_a_size(t_scalar_t); +extern int __rpc_dtbsize(void); +extern struct netconfig *__rpcfd_to_nconf(int, int); +extern int __rpc_matchserv(int, unsigned int); +extern int __rpc_get_default_domain(char **); +extern int __rpc_tli_set_options(int, int, int, int); /* internal use only */ +#else +extern uint_t __rpc_get_t_size(); +extern uint_t __rpc_get_a_size(); +extern int __rpc_dtbsize(); +extern struct netconfig *__rpcfd_to_nconf(); +extern int __rpc_matchserv(); +extern int __rpc_get_default_domain(); +extern int __rpc_tli_set_options(); /* internal use only */ +#endif + +#ifndef _KERNEL + +#ifdef __STDC__ +bool_t rpc_control(int, void *); +#else +bool_t rpc_control(); +#endif + +/* + * rpc_control commands + */ +#define RPC_SVC_MTMODE_SET 1 /* set MT mode */ +#define RPC_SVC_MTMODE_GET 2 /* get MT mode */ +#define RPC_SVC_THRMAX_SET 3 /* set maximum number of threads */ +#define RPC_SVC_THRMAX_GET 4 /* get maximum number of threads */ +#define RPC_SVC_THRTOTAL_GET 5 /* get total number of threads */ +#define RPC_SVC_THRCREATES_GET 6 /* get total threads created */ +#define RPC_SVC_THRERRORS_GET 7 /* get total thread create errors */ +#define RPC_SVC_USE_POLLFD 10 /* unlimit fd used beyond 1024 */ +#define RPC_SVC_CONNMAXREC_SET 11 /* set COT maximum record size */ +#define RPC_SVC_CONNMAXREC_GET 12 /* get COT maximum record size */ +/* EXCLBIND private interface start - for internal use only */ +#define __RPC_SVC_EXCLBIND_SET 13 /* set udp/tcp exclusive port access */ +#define __RPC_SVC_EXCLBIND_GET 14 /* get udp/tcp exclusive port access */ +/* EXCLBIND private interface end - for internal use only */ + +/* set inter record timeout for COTS RPC */ +#define RPC_SVC_IRTIMEOUT_SET 15 + +/* private interface for maximum number of outstanding connection indications */ +#define __RPC_SVC_LSTNBKLOG_SET 16 /* set listen backlog */ +#define __RPC_SVC_LSTNBKLOG_GET 17 /* get listen backlog */ + +#endif /* !_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_RPC_COM_H */ diff --git a/illumos-x86_64/usr/include/rpc/rpc_msg.h b/illumos-x86_64/usr/include/rpc/rpc_msg.h new file mode 100644 index 00000000..36fa49cb --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpc_msg.h @@ -0,0 +1,254 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +#ifndef _RPC_RPC_MSG_H +#define _RPC_RPC_MSG_H + +#include +/* + * rpc_msg.h + * rpc message definition + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define RPC_MSG_VERSION ((uint32_t)2) +#define RPC_SERVICE_PORT ((ushort_t)2048) + +/* + * Bottom up definition of an rpc message. + * NOTE: call and reply use the same overall stuct but + * different parts of unions within it. + */ + +enum msg_type { + CALL = 0, + REPLY = 1 +}; + +enum reply_stat { + MSG_ACCEPTED = 0, + MSG_DENIED = 1 +}; + +enum accept_stat { + SUCCESS = 0, + PROG_UNAVAIL = 1, + PROG_MISMATCH = 2, + PROC_UNAVAIL = 3, + GARBAGE_ARGS = 4, + SYSTEM_ERR = 5 +}; + +enum reject_stat { + RPC_MISMATCH = 0, + AUTH_ERROR = 1 +}; + +/* + * Reply part of an rpc exchange + */ + +/* + * Reply to an rpc request that was accepted by the server. + * Note: there could be an error even though the request was + * accepted. + */ +struct accepted_reply { + struct opaque_auth ar_verf; + enum accept_stat ar_stat; + union { + struct { + rpcvers_t low; + rpcvers_t high; + } AR_versions; + struct { + caddr_t where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions +}; + +/* + * Reply to an rpc request that was rejected by the server. + */ +struct rejected_reply { + enum reject_stat rj_stat; + union { + struct { + rpcvers_t low; + rpcvers_t high; + } RJ_versions; + enum auth_stat RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why +}; + +/* + * Body of a reply to an rpc request. + */ +struct reply_body { + enum reply_stat rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr +}; + +/* + * Body of an rpc request call. + */ +struct call_body { + rpcvers_t cb_rpcvers; /* must be equal to two */ + rpcprog_t cb_prog; + rpcvers_t cb_vers; + rpcproc_t cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ +}; + +/* + * The rpc message + */ +struct rpc_msg { + uint32_t rm_xid; + enum msg_type rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb +}; +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr + + +/* + * XDR routine to handle a rpc message. + * xdr_callmsg(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +#ifdef __STDC__ +extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); +#else +extern bool_t xdr_callmsg(); +#endif + + +/* + * XDR routine to pre-serialize the static part of a rpc message. + * xdr_callhdr(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +#ifdef __STDC__ +extern bool_t xdr_callhdr(XDR *, struct rpc_msg *); +#else +extern bool_t xdr_callhdr(); +#endif + + +/* + * XDR routine to handle a rpc reply. + * xdr_replymsg(xdrs, rmsg) + * XDR *xdrs; + * struct rpc_msg *rmsg; + * + * xdr_accepted_reply(xdrs, ar) + * XDR *xdrs; + * const struct accepted_reply *ar; + * + * xdr_rejected_reply(xdrs, rr) + * XDR *xdrs; + * const struct rejected_reply *rr; + */ +#ifdef __STDC__ +extern bool_t xdr_replymsg(XDR *, struct rpc_msg *); +extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *); +extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *); +#else +extern bool_t xdr_replymsg(); +extern bool_t xdr_accepted_reply(); +extern bool_t xdr_rejected_reply(); +#endif + + +#ifdef _KERNEL +/* + * Fills in the error part of a reply message. + * _seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +#ifdef __STDC__ +extern void _seterr_reply(struct rpc_msg *, struct rpc_err *); +#else +extern void _seterr_reply(); +#endif +#else +/* + * Fills in the error part of a reply message. + * __seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +#ifdef __STDC__ +extern void __seterr_reply(struct rpc_msg *, struct rpc_err *); +#else +extern void __seterr_reply(); +#endif +#endif + +#ifdef _KERNEL +/* + * Frees any verifier that xdr_replymsg() (DECODE) allocated. + */ +bool_t xdr_rpc_free_verifier(register XDR *xdrs, register struct rpc_msg *msg); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_RPC_MSG_H */ diff --git a/illumos-x86_64/usr/include/rpc/rpc_rdma.h b/illumos-x86_64/usr/include/rpc/rpc_rdma.h new file mode 100644 index 00000000..0cbb8ef4 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpc_rdma.h @@ -0,0 +1,583 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright (c) 2007, The Ohio State University. All rights reserved. + * + * Portions of this source code is developed by the team members of + * The Ohio State University's Network-Based Computing Laboratory (NBCL), + * headed by Professor Dhabaleswar K. (DK) Panda. + * + * Acknowledgements to contributions from developors: + * Ranjit Noronha: noronha@cse.ohio-state.edu + * Lei Chai : chail@cse.ohio-state.edu + * Weikuan Yu : yuw@cse.ohio-state.edu + * + */ + +#ifndef _RPC_RPC_RDMA_H +#define _RPC_RPC_RDMA_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RPCRDMA_VERS 1 /* Version of the RPC over RDMA protocol */ +#define RDMATF_VERS 1 /* Version of the API used by RPC for RDMA */ +#define RDMATF_VERS_1 1 /* Current version of RDMATF */ + +/* + * The size of an RPC call or reply message + */ +#define RPC_MSG_SZ 1024 + +/* + * RDMA chunk size + */ +#define RDMA_MINCHUNK 1024 + +/* + * Storage for a chunk list + */ +#define RPC_CL_SZ 1024 + +/* + * Chunk size + */ +#define MINCHUNK 1024 + +/* + * Size of receive buffer + */ +#define RPC_BUF_SIZE 2048 + +#define NOWAIT 0 /* don't wait for operation of complete */ +#define WAIT 1 /* wait and ensure that operation is complete */ + +/* + * RDMA xdr buffer control and other control flags. Add new flags here, + * set them in private structure for xdr over RDMA in xdr_rdma.c + */ +#define XDR_RDMA_CHUNK 0x1 +#define XDR_RDMA_WLIST_REG 0x2 +#define XDR_RDMA_RLIST_REG 0x4 + +#define LONG_REPLY_LEN 65536 +#define WCL_BUF_LEN 32768 +#define RCL_BUF_LEN 32768 + + +#define RDMA_BUFS_RQST 34 /* Num bufs requested by client */ +#define RDMA_BUFS_GRANT 32 /* Num bufs granted by server */ + +struct xdr_ops *xdrrdma_xops(void); + +/* + * Credit Control Structures. + */ +typedef enum rdma_cc_type { + RDMA_CC_CLNT, /* CONN is for a client */ + RDMA_CC_SRV /* CONN is for a server */ +} rdma_cc_type_t; + +/* + * Client side credit control data structure. + */ +typedef struct rdma_clnt_cred_ctrl { + uint32_t clnt_cc_granted_ops; + uint32_t clnt_cc_in_flight_ops; + kcondvar_t clnt_cc_cv; +} rdma_clnt_cred_ctrl_t; + +/* + * Server side credit control data structure. + */ +typedef struct rdma_srv_cred_ctrl { + uint32_t srv_cc_buffers_granted; + uint32_t srv_cc_cur_buffers_used; + uint32_t srv_cc_posted; + uint32_t srv_cc_max_buf_size; /* to be determined by CCP */ + uint32_t srv_cc_cur_buf_size; /* to be determined by CCP */ +} rdma_srv_cred_ctrl_t; + +typedef enum { + RPCCALL_WLIST, + RPCCALL_WCHUNK, + RPCCALL_NOWRITE +}rpccall_write_t; + +typedef enum { + CLIST_REG_SOURCE = 1, + CLIST_REG_DST +} clist_dstsrc; + +/* + * Return codes from RDMA operations + */ +typedef enum { + + RDMA_SUCCESS = 0, /* successful operation */ + + RDMA_INVAL = 1, /* invalid parameter */ + RDMA_TIMEDOUT = 2, /* operation timed out */ + RDMA_INTR = 3, /* operation interrupted */ + RDMA_NORESOURCE = 4, /* insufficient resource */ + /* + * connection errors + */ + RDMA_REJECT = 5, /* connection req rejected */ + RDMA_NOLISTENER = 6, /* no listener on server */ + RDMA_UNREACHABLE = 7, /* host unreachable */ + RDMA_CONNLOST = 8, /* connection lost */ + + RDMA_XPRTFAILED = 9, /* RDMA transport failed */ + RDMA_PROTECTERR = 10, /* memory protection error */ + RDMA_OVERRUN = 11, /* transport overrun */ + RDMA_RECVQEMPTY = 12, /* incoming pkt dropped, recv q empty */ + RDMA_PROTFAILED = 13, /* RDMA protocol failed */ + RDMA_NOTSUPP = 14, /* requested feature not supported */ + RDMA_REMOTERR = 15, /* error at remote end */ + /* + * RDMATF errors + */ + RDMA_BADVERS = 16, /* mismatch RDMATF versions */ + RDMA_REG_EXIST = 17, /* RDMATF registration already exists */ + RDMA_HCA_ATTACH = 18, + RDMA_HCA_DETACH = 19, + + /* + * fallback error + */ + RDMA_FAILED = 20 /* generic error */ +} rdma_stat; + +/* + * Memory region context. This is an RDMA provider generated + * handle for a registered arbitrary size contiguous virtual + * memory. The RDMA Interface Adapter needs this for local or + * remote memory access. + * + * The mrc_rmr field holds the remote memory region context + * which is sent over-the-wire to provide the remote host + * with RDMA access to the memory region. + */ +struct mrc { + uint32_t mrc_rmr; /* Remote MR context, sent OTW */ + union { + struct mr { + uint32_t lmr; /* Local MR context */ + uint64_t linfo; /* Local memory info */ + } mr; + } lhdl; +}; + +#define mrc_lmr lhdl.mr.lmr +#define mrc_linfo lhdl.mr.linfo + +/* + * Memory management for the RDMA buffers + */ +/* + * RDMA buffer types + */ +typedef enum { + SEND_BUFFER, /* buf for send msg */ + SEND_DESCRIPTOR, /* buf used for send msg descriptor in plugins only */ + RECV_BUFFER, /* buf for recv msg */ + RECV_DESCRIPTOR, /* buf used for recv msg descriptor in plugins only */ + RDMA_LONG_BUFFER /* chunk buf used in RDMATF only and not in plugins */ +} rdma_btype; + +/* + * RDMA buffer information + */ +typedef struct rdma_buf { + rdma_btype type; /* buffer type */ + uint_t len; /* length of buffer */ + caddr_t addr; /* buffer address */ + struct mrc handle; /* buffer registration handle */ + caddr_t rb_private; +} rdma_buf_t; + + +/* + * The XDR offset value is used by the XDR + * routine to identify the position in the + * RPC message where the opaque object would + * normally occur. Neither the data content + * of the chunk, nor its size field are included + * in the RPC message. The XDR offset is calculated + * as if the chunks were present. + * + * The remaining fields identify the chunk of data + * on the sender. The c_memhandle identifies a + * registered RDMA memory region and the c_addr + * and c_len fields identify the chunk within it. + */ +struct clist { + uint32 c_xdroff; /* XDR offset */ + uint32 c_len; /* Length */ + clist_dstsrc c_regtype; /* type of registration */ + struct mrc c_smemhandle; /* src memory handle */ + uint64 c_ssynchandle; /* src sync handle */ + union { + uint64 c_saddr; /* src address */ + caddr_t c_saddr3; + } w; + struct mrc c_dmemhandle; /* dst memory handle */ + uint64 c_dsynchandle; /* dst sync handle */ + union { + uint64 c_daddr; /* dst address */ + caddr_t c_daddr3; + } u; + struct as *c_adspc; /* address space for saddr/daddr */ + rdma_buf_t rb_longbuf; /* used for long requests/replies */ + struct clist *c_next; /* Next chunk */ +}; + +typedef struct clist clist; + +/* + * max 4M wlist xfer size + * This is defined because the rfs3_tsize service requires + * svc_req struct (which we don't have that in krecv). + */ +#define MAX_SVC_XFER_SIZE (4*1024*1024) + +enum rdma_proc { + RDMA_MSG = 0, /* chunk list and RPC msg follow */ + RDMA_NOMSG = 1, /* only chunk list follows */ + RDMA_MSGP = 2, /* chunk list and RPC msg with padding follow */ + RDMA_DONE = 3 /* signal completion of chunk transfer */ +}; + +/* + * Listener information for a service + */ +struct rdma_svc_data { + queue_t q; /* queue_t to place incoming pkts */ + int active; /* If active, after registeration startup */ + rdma_stat err_code; /* Error code from plugin layer */ + int32_t svcid; /* RDMA based service identifier */ +}; + +/* + * Per RDMA plugin module information. + * Will be populated by each plugin + * module during its initialization. + */ +typedef struct rdma_mod { + char *rdma_api; /* "kvipl", "ibtf", etc */ + uint_t rdma_version; /* RDMATF API version */ + int rdma_count; /* # of devices */ + struct rdmaops *rdma_ops; /* rdma op vector for api */ +} rdma_mod_t; + +/* + * Registry of RDMA plugins + */ +typedef struct rdma_registry { + rdma_mod_t *r_mod; /* plugin mod info */ + uint32_t r_mod_state; + struct rdma_registry *r_next; /* next registered RDMA plugin */ +} rdma_registry_t; + +/* + * RDMA MODULE state flags (r_mod_state). + */ +#define RDMA_MOD_ACTIVE 1 +#define RDMA_MOD_INACTIVE 0 + +/* + * RDMA transport information + */ +typedef struct rdma_info { + uint_t addrlen; /* address length */ + uint_t mts; /* max transfer size */ + uint_t mtu; /* native mtu size of unlerlying network */ +} rdma_info_t; + +typedef enum { + C_IDLE = 0x00000001, + C_CONN_PEND = 0x00000002, + C_CONNECTED = 0x00000004, + C_ERROR_CONN = 0x00000008, + C_DISCONN_PEND = 0x00000010, + C_REMOTE_DOWN = 0x00000020 +} conn_c_state; + +/* c_flags */ +#define C_CLOSE_NOTNEEDED 0x00000001 /* just free the channel */ +#define C_CLOSE_PENDING 0x00000002 /* a close in progress */ + +/* + * RDMA Connection information + */ +typedef struct conn { + rdma_mod_t *c_rdmamod; /* RDMA transport info for conn */ + char *c_netid; /* tcp or tcp6 token */ + struct netbuf c_raddr; /* remote address */ + struct netbuf c_laddr; /* local address */ + struct netbuf c_addrmask; /* Address Mask */ + int c_ref; /* no. of clients of connection */ + struct conn *c_next; /* next in list of connections */ + struct conn *c_prev; /* prev in list of connections */ + caddr_t c_private; /* transport specific stuff */ + conn_c_state c_state; /* state of connection */ + int c_flags; /* flags for connection management */ + rdma_cc_type_t c_cc_type; /* client or server, for credit cntrl */ + union { + rdma_clnt_cred_ctrl_t c_clnt_cc; + rdma_srv_cred_ctrl_t c_srv_cc; + } rdma_conn_cred_ctrl_u; + kmutex_t c_lock; /* protect c_state and c_ref fields */ + kcondvar_t c_cv; /* to signal when pending is done */ + timeout_id_t c_timeout; /* timeout id for untimeout() */ + time_t c_last_used; /* last time any activity on the conn */ +} CONN; + + +/* + * Data transferred from plugin interrupt to svc_queuereq() + */ +typedef struct rdma_recv_data { + CONN *conn; + int status; + rdma_buf_t rpcmsg; +} rdma_recv_data_t; + +/* structure used to pass information for READ over rdma write */ +typedef enum { + RCI_WRITE_UIO_CHUNK = 1, + RCI_WRITE_ADDR_CHUNK = 2, + RCI_REPLY_CHUNK = 3 +} rci_type_t; + +typedef struct { + rci_type_t rci_type; + union { + struct uio *rci_uiop; + caddr_t rci_addr; + } rci_a; + uint32 rci_len; + struct clist **rci_clpp; /* point to write chunk list in readargs */ +} rdma_chunkinfo_t; + +typedef struct { + uint_t rcil_len; + uint_t rcil_len_alt; +} rdma_chunkinfo_lengths_t; + +typedef struct { + struct clist *rwci_wlist; + CONN *rwci_conn; +} rdma_wlist_conn_info_t; + +/* + * Operations vector for RDMA transports. + */ +typedef struct rdmaops { + /* Network */ + rdma_stat (*rdma_reachable)(int addr_type, struct netbuf *, + void **handle); + /* Connection */ + rdma_stat (*rdma_get_conn)(struct netbuf *, struct netbuf *, + int addr_type, void *, CONN **); + rdma_stat (*rdma_rel_conn)(CONN *); + /* Server side listner start and stop routines */ + void (*rdma_svc_listen)(struct rdma_svc_data *); + void (*rdma_svc_stop)(struct rdma_svc_data *); + /* Memory */ + rdma_stat (*rdma_regmem)(CONN *, caddr_t, caddr_t, + uint_t, struct mrc *); + rdma_stat (*rdma_deregmem)(CONN *, caddr_t, struct mrc); + rdma_stat (*rdma_regmemsync)(CONN *, caddr_t, caddr_t, uint_t, + struct mrc *, void **, void *); + rdma_stat (*rdma_deregmemsync)(CONN *, caddr_t, struct mrc, + void *, void *); + rdma_stat (*rdma_syncmem)(CONN *, void *, caddr_t, int, int); + /* Buffer */ + rdma_stat (*rdma_buf_alloc)(CONN *, rdma_buf_t *); + void (*rdma_buf_free)(CONN *, rdma_buf_t *); + /* Transfer */ + rdma_stat (*rdma_send)(CONN *, clist *, uint32_t); + rdma_stat (*rdma_send_resp)(CONN *, clist *, uint32_t); + rdma_stat (*rdma_clnt_recvbuf)(CONN *, clist *, uint32_t); + rdma_stat (*rdma_clnt_recvbuf_remove)(CONN *, uint32_t); + rdma_stat (*rdma_svc_recvbuf)(CONN *, clist *); + rdma_stat (*rdma_recv)(CONN *, clist **, uint32_t); + /* RDMA */ + rdma_stat (*rdma_read)(CONN *, clist *, int); + rdma_stat (*rdma_write)(CONN *, clist *, int); + /* INFO */ + rdma_stat (*rdma_getinfo)(rdma_info_t *info); +} rdmaops_t; + +typedef struct rdma_svc_wait { + kmutex_t svc_lock; + kcondvar_t svc_cv; + rdma_stat svc_stat; +} rdma_svc_wait_t; + +extern rdma_svc_wait_t rdma_wait; + +/* + * RDMA operations. + */ +#define RDMA_REACHABLE(rdma_ops, addr_type, addr, handle) \ + (*(rdma_ops)->rdma_reachable)(addr_type, addr, handle) + +#define RDMA_GET_CONN(rdma_ops, saddr, daddr, addr_type, handle, conn) \ + (*(rdma_ops)->rdma_get_conn)(saddr, daddr, addr_type, handle, conn) + +#define RDMA_REL_CONN(conn) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_rel_conn)(conn) + +#define RDMA_REGMEM(conn, adsp, buff, len, handle) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_regmem)(conn, adsp, \ + buff, len, handle) + +#define RDMA_DEREGMEM(conn, buff, handle) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_deregmem)(conn, buff, handle) + +#define RDMA_REGMEMSYNC(conn, adsp, buff, len, handle, synchandle, lrc) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_regmemsync)(conn, adsp, buff, \ + len, handle, synchandle, lrc) + +#define RDMA_DEREGMEMSYNC(conn, buff, handle, synchandle, lrc) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_deregmemsync)(conn, buff, \ + handle, synchandle, lrc) + +#define RDMA_SYNCMEM(conn, handle, buff, len, direction) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_syncmem)(conn, handle, \ + buff, len, direction) + +#define RDMA_BUF_ALLOC(conn, rbuf) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_buf_alloc)(conn, rbuf) + +#define RDMA_BUF_FREE(conn, rbuf) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_buf_free)(conn, rbuf) + +#define RDMA_SEND(conn, sendlist, xid) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_send)(conn, sendlist, xid) + +#define RDMA_SEND_RESP(conn, sendlist, xid) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_send_resp)(conn, sendlist, xid) + +#define RDMA_CLNT_RECVBUF(conn, cl, xid) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_clnt_recvbuf)(conn, cl, xid) + +#define RDMA_CLNT_RECVBUF_REMOVE(conn, xid) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_clnt_recvbuf_remove)(conn, xid) + +#define RDMA_SVC_RECVBUF(conn, cl) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_svc_recvbuf)(conn, cl) + +#define RDMA_RECV(conn, recvlist, xid) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_recv)(conn, recvlist, xid) + +#define RDMA_READ(conn, cl, wait) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_read)(conn, cl, wait) + +#define RDMA_WRITE(conn, cl, wait) \ + (*(conn)->c_rdmamod->rdma_ops->rdma_write)(conn, cl, wait) + +#define RDMA_GETINFO(rdma_mod, info) \ + (*(rdma_mod)->rdma_ops->rdma_getinfo)(info) + +#ifdef _KERNEL +extern rdma_registry_t *rdma_mod_head; +extern krwlock_t rdma_lock; /* protects rdma_mod_head list */ +extern int rdma_modloaded; /* flag for loading RDMA plugins */ +extern int rdma_dev_available; /* rdma device is loaded or not */ +extern kmutex_t rdma_modload_lock; /* protects rdma_modloaded flag */ +extern uint_t rdma_minchunk; +extern ldi_ident_t rpcmod_li; /* needed by layed driver framework */ + +/* + * General RDMA routines + */ +extern struct clist *clist_alloc(void); +extern void clist_add(struct clist **, uint32_t, int, + struct mrc *, caddr_t, struct mrc *, caddr_t); +extern void clist_free(struct clist *); +extern uint32_t clist_len(struct clist *); +extern void clist_zero_len(struct clist *); +extern rdma_stat clist_register(CONN *conn, struct clist *cl, clist_dstsrc); +extern rdma_stat clist_deregister(CONN *conn, struct clist *cl); +extern rdma_stat clist_syncmem(CONN *conn, struct clist *cl, clist_dstsrc); +extern rdma_stat rdma_clnt_postrecv(CONN *conn, uint32_t xid); +extern rdma_stat rdma_clnt_postrecv_remove(CONN *conn, uint32_t xid); +extern rdma_stat rdma_svc_postrecv(CONN *conn); +extern rdma_stat rdma_register_mod(rdma_mod_t *mod); +extern rdma_stat rdma_unregister_mod(rdma_mod_t *mod); +extern rdma_stat rdma_buf_alloc(CONN *, rdma_buf_t *); +extern void rdma_buf_free(CONN *, rdma_buf_t *); +extern int rdma_modload(); +extern bool_t rdma_get_wchunk(struct svc_req *, iovec_t *, struct clist *); +extern rdma_stat rdma_kwait(void); +extern int rdma_setup_read_chunks(struct clist *, uint32_t, int *); + +/* + * RDMA XDR + */ +extern void xdrrdma_create(XDR *, caddr_t, uint_t, int, struct clist *, + enum xdr_op, CONN *); +extern void xdrrdma_destroy(XDR *); + +extern uint_t xdrrdma_getpos(XDR *); +extern bool_t xdrrdma_setpos(XDR *, uint_t); +extern bool_t xdr_clist(XDR *, clist *); +extern bool_t xdr_do_clist(XDR *, clist **); +extern uint_t xdr_getbufsize(XDR *); +extern unsigned int xdrrdma_sizeof(xdrproc_t, void *, int, uint_t *, uint_t *); +extern unsigned int xdrrdma_authsize(AUTH *, struct cred *, int); + +extern void xdrrdma_store_wlist(XDR *, struct clist *); +extern struct clist *xdrrdma_wclist(XDR *); +extern bool_t xdr_decode_reply_wchunk(XDR *, struct clist **); +extern bool_t xdr_decode_wlist(XDR *xdrs, struct clist **, bool_t *); +extern bool_t xdr_decode_wlist_svc(XDR *xdrs, struct clist **, bool_t *, + uint32_t *, CONN *); +extern bool_t xdr_encode_rlist_svc(XDR *, clist *); +extern bool_t xdr_encode_wlist(XDR *, clist *); +extern bool_t xdr_encode_reply_wchunk(XDR *, struct clist *, + uint32_t seg_array_len); +bool_t xdrrdma_getrdmablk(XDR *, struct clist **, uint_t *, + CONN **conn, const uint_t); +bool_t xdrrdma_read_from_client(struct clist *, CONN **, uint_t); +bool_t xdrrdma_send_read_data(XDR *, uint_t, struct clist *); +bool_t xdrrdma_free_clist(CONN *, struct clist *); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_RPC_RDMA_H */ diff --git a/illumos-x86_64/usr/include/rpc/rpc_sztypes.h b/illumos-x86_64/usr/include/rpc/rpc_sztypes.h new file mode 100644 index 00000000..74ca1f40 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpc_sztypes.h @@ -0,0 +1,44 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _RPC_SZTYPES_H_RPCGEN +#define _RPC_SZTYPES_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef u_longlong_t uint64; + +typedef longlong_t int64; + +typedef u_int uint32; + +typedef int int32; + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_uint64(XDR *, uint64*); +extern bool_t xdr_int64(XDR *, int64*); +extern bool_t xdr_uint32(XDR *, uint32*); +extern bool_t xdr_int32(XDR *, int32*); + +#else /* K&R C */ +extern bool_t xdr_uint64(); +extern bool_t xdr_int64(); +extern bool_t xdr_uint32(); +extern bool_t xdr_int32(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_SZTYPES_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpc/rpcb_clnt.h b/illumos-x86_64/usr/include/rpc/rpcb_clnt.h new file mode 100644 index 00000000..9f3d5b3d --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpcb_clnt.h @@ -0,0 +1,93 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * rpcb_clnt.h + * Supplies C routines to get to rpcbind services. + */ + +/* + * Usage: + * success = rpcb_set(program, version, nconf, address); + * success = rpcb_unset(program, version, nconf); + * success = rpcb_getaddr(program, version, nconf, host); + * head = rpcb_getmaps(nconf, host); + * clnt_stat = rpcb_rmtcall(nconf, host, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, addr_ptr) + * success = rpcb_gettime(host, timep) + * uaddr = rpcb_taddr2uaddr(nconf, taddr); + * taddr = rpcb_uaddr2uaddr(nconf, uaddr); + */ + +#ifndef _RPC_RPCB_CLNT_H +#define _RPC_RPCB_CLNT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __STDC__ +extern bool_t rpcb_set(const rpcprog_t, const rpcvers_t, + const struct netconfig *, const struct netbuf *); +extern bool_t rpcb_unset(const rpcprog_t, const rpcvers_t, + const struct netconfig *); +extern rpcblist *rpcb_getmaps(const struct netconfig *, const char *); +extern enum clnt_stat rpcb_rmtcall(const struct netconfig *, const char *, +const rpcprog_t, const rpcvers_t, const rpcproc_t, const xdrproc_t, + const caddr_t, const xdrproc_t, const caddr_t, + const struct timeval, struct netbuf *); +extern bool_t rpcb_getaddr(const rpcprog_t, const rpcvers_t, + const struct netconfig *, struct netbuf *, const char *); +extern bool_t rpcb_gettime(const char *, time_t *); +extern char *rpcb_taddr2uaddr(struct netconfig *, struct netbuf *); +extern struct netbuf *rpcb_uaddr2taddr(struct netconfig *, char *); +#else +extern bool_t rpcb_set(); +extern bool_t rpcb_unset(); +extern rpcblist *rpcb_getmaps(); +extern enum clnt_stat rpcb_rmtcall(); +extern bool_t rpcb_getaddr(); +extern bool_t rpcb_gettime(); +extern char *rpcb_taddr2uaddr(); +extern struct netbuf *rpcb_uaddr2taddr(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_RPCB_CLNT_H */ diff --git a/illumos-x86_64/usr/include/rpc/rpcb_prot.h b/illumos-x86_64/usr/include/rpc/rpcb_prot.h new file mode 100644 index 00000000..74e07026 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpcb_prot.h @@ -0,0 +1,544 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _RPCB_PROT_H_RPCGEN +#define _RPCB_PROT_H_RPCGEN + +#include +#ifndef _KERNEL +#include +#include +#endif /* !_KERNEL */ +/* + * Copyright (c) 1988,1994 by Sun Microsystems, Inc. + * All rights reserved. + */ +/* from rpcb_prot.x */ + +#ifndef _KERNEL + + +/* + * The following procedures are supported by the protocol in version 3: + * + * RPCBPROC_NULL() returns () + * takes nothing, returns nothing + * + * RPCBPROC_SET(rpcb) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, address, owner, netid]. + * Finds out owner and netid information on its own. + * + * RPCBPROC_UNSET(rpcb) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers tuple + * [prog, vers, netid]. addresses is ignored. + * If netid is NULL, unregister all. + * + * RPCBPROC_GETADDR(rpcb) returns (string). + * 0 is failure. Otherwise returns the universal address where the + * triple [prog, vers, netid] is registered. Ignore address and owner. + * + * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) + * used to dump the entire rpcbind maps + * + * RPCBPROC_CALLIT(rpcb_rmtcallargs) + * RETURNS (rpcb_rmtcallres); + * Calls the procedure on the remote machine. If it is not registered, + * this procedure is quiet; i.e. it does not return error information!!! + * This routine only passes null authentication parameters. + * It has no interface to xdr routines for RPCBPROC_CALLIT. + * + * RPCBPROC_GETTIME() returns (int). + * Gets the remote machines time + * + * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) + * Returns the netbuf address from universal address. + * + * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) + * Returns the universal address from netbuf address. + * + * END OF RPCBIND VERSION 3 PROCEDURES + */ +/* + * Except for RPCBPROC_CALLIT, the procedures above are carried over to + * rpcbind version 4. Those below are added or modified for version 4. + * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER + * AS RPCBPROC_CALLIT. + * + * RPCBPROC_BCAST(rpcb_rmtcallargs) + * RETURNS (rpcb_rmtcallres); + * Calls the procedure on the remote machine. If it is not registered, + * this procedure IS quiet; i.e. it DOES NOT return error information!!! + * This routine should be used for broadcasting and nothing else. + * + * RPCBPROC_GETVERSADDR(rpcb) returns (string). + * 0 is failure. Otherwise returns the universal address where the + * triple [prog, vers, netid] is registered. Ignore address and owner. + * Same as RPCBPROC_GETADDR except that if the given version number + * is not available, the address is not returned. + * + * RPCBPROC_INDIRECT(rpcb_rmtcallargs) + * RETURNS (rpcb_rmtcallres); + * Calls the procedure on the remote machine. If it is not registered, + * this procedure is NOT quiet; i.e. it DOES return error information!!! + * as any normal application would expect. + * + * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). + * Same as RPCBPROC_GETADDR except that it returns a list of all the + * addresses registered for the combination (prog, vers) (for all + * transports). + * + * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) + * Returns the statistics about the kind of requests received by rpcbind. + */ + +/* + * A mapping of (program, version, network ID) to address + */ + +struct rpcb { + rpcprog_t r_prog; + rpcvers_t r_vers; + char *r_netid; + char *r_addr; + char *r_owner; +}; +typedef struct rpcb rpcb; + +typedef rpcb RPCB; + + +/* + * A list of mappings + * + * Below are two definitions for the rpcblist structure. This is done because + * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a + * struct rpcblist * that rpcgen would produce. One version of the rpcblist + * structure (actually called rp__list) is used with rpcgen, and the other is + * defined only in the header file for compatibility with the specified + * interface. + */ + +struct rp__list { + rpcb rpcb_map; + struct rp__list *rpcb_next; +}; +typedef struct rp__list rp__list; + +typedef rp__list *rpcblist_ptr; + +typedef struct rp__list rpcblist; +typedef struct rp__list RPCBLIST; + +#ifndef __cplusplus +struct rpcblist { + RPCB rpcb_map; + struct rpcblist *rpcb_next; +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __STDC__ +extern bool_t xdr_rpcblist(XDR *, rpcblist**); +#else /* K&R C */ +bool_t xdr_rpcblist(); +#endif +#ifdef __cplusplus +} +#endif + + +/* + * Arguments of remote calls + */ + +struct rpcb_rmtcallargs { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + struct { + u_int args_len; + char *args_val; + } args; +}; +typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; + +/* + * Client-side only representation of rpcb_rmtcallargs structure. + * + * The routine that XDRs the rpcb_rmtcallargs structure must deal with the + * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to + * be passed the XDR routine that knows the args' structure. This routine + * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since + * the application being called already knows the args structure. So we use a + * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which + * includes the args' XDR routine. + */ +struct r_rpcb_rmtcallargs { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + struct { + uint32_t args_len; + char *args_val; + } args; + xdrproc_t xdr_args; /* encodes args */ +}; + + +/* + * Results of the remote call + */ + +struct rpcb_rmtcallres { + char *addr; + struct { + u_int results_len; + char *results_val; + } results; +}; +typedef struct rpcb_rmtcallres rpcb_rmtcallres; + +/* + * Client-side only representation of rpcb_rmtcallres structure. + */ +struct r_rpcb_rmtcallres { + char *addr; + struct { + uint32_t results_len; + char *results_val; + } results; + xdrproc_t xdr_res; /* decodes results */ +}; + +/* + * rpcb_entry contains a merged address of a service on a particular + * transport, plus associated netconfig information. A list of rpcb_entrys + * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used + * in r_nc_* fields. + */ + +struct rpcb_entry { + char *r_maddr; + char *r_nc_netid; + u_int r_nc_semantics; + char *r_nc_protofmly; + char *r_nc_proto; +}; +typedef struct rpcb_entry rpcb_entry; + +/* + * A list of addresses supported by a service. + */ + +struct rpcb_entry_list { + rpcb_entry rpcb_entry_map; + struct rpcb_entry_list *rpcb_entry_next; +}; +typedef struct rpcb_entry_list rpcb_entry_list; + +typedef rpcb_entry_list *rpcb_entry_list_ptr; + +/* + * rpcbind statistics + */ + +#define rpcb_highproc_2 RPCBPROC_CALLIT +#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR +#define rpcb_highproc_4 RPCBPROC_GETSTAT +#define RPCBSTAT_HIGHPROC 13 +#define RPCBVERS_STAT 3 +#define RPCBVERS_4_STAT 2 +#define RPCBVERS_3_STAT 1 +#define RPCBVERS_2_STAT 0 + +/* Link list of all the stats about getport and getaddr */ + +struct rpcbs_addrlist { + rpcprog_t prog; + rpcvers_t vers; + int success; + int failure; + char *netid; + struct rpcbs_addrlist *next; +}; +typedef struct rpcbs_addrlist rpcbs_addrlist; + +/* Link list of all the stats about rmtcall */ + +struct rpcbs_rmtcalllist { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + int success; + int failure; + int indirect; + char *netid; + struct rpcbs_rmtcalllist *next; +}; +typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; + +typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; + +typedef rpcbs_addrlist *rpcbs_addrlist_ptr; + +typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; + +struct rpcb_stat { + rpcbs_proc info; + int setinfo; + int unsetinfo; + rpcbs_addrlist_ptr addrinfo; + rpcbs_rmtcalllist_ptr rmtinfo; +}; +typedef struct rpcb_stat rpcb_stat; + +/* + * One rpcb_stat structure is returned for each version of rpcbind + * being monitored. + */ + +typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; + +/* + * We don't define netbuf in RPCL, since it would contain structure member + * names that would conflict with the definition of struct netbuf in + * . Instead we merely declare the XDR routine xdr_netbuf() here, + * and implement it ourselves in rpc/rpcb_prot.c. + */ +#ifdef __cplusplus +extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); + +#elif __STDC__ +extern bool_t xdr_netbuf(XDR *, struct netbuf *); + +#else /* K&R C */ +bool_t xdr_netbuf(); + +#endif /* K&R C */ + +#define RPCBVERS_3 RPCBVERS +#define RPCBVERS_4 RPCBVERS4 + +#else /* ndef _KERNEL */ +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A mapping of (program, version, network ID) to address + */ +struct rpcb { + rpcprog_t r_prog; /* program number */ + rpcvers_t r_vers; /* version number */ + char *r_netid; /* network id */ + char *r_addr; /* universal address */ + char *r_owner; /* owner of the mapping */ +}; +typedef struct rpcb RPCB; + +/* + * A list of mappings + */ +struct rpcblist { + RPCB rpcb_map; + struct rpcblist *rpcb_next; +}; +typedef struct rpcblist RPCBLIST; +typedef struct rpcblist *rpcblist_ptr; + +/* + * Remote calls arguments + */ +struct rpcb_rmtcallargs { + rpcprog_t prog; /* program number */ + rpcvers_t vers; /* version number */ + rpcproc_t proc; /* procedure number */ + unsigned int arglen; /* arg len */ + caddr_t args_ptr; /* argument */ + xdrproc_t xdr_args; /* XDR routine for argument */ +}; +typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; + +/* + * Remote calls results + */ +struct rpcb_rmtcallres { + char *addr_ptr; /* remote universal address */ + uint32_t resultslen; /* results length */ + caddr_t results_ptr; /* results */ + xdrproc_t xdr_results; /* XDR routine for result */ +}; +typedef struct rpcb_rmtcallres rpcb_rmtcallres; + +struct rpcb_entry { + char *r_maddr; + char *r_nc_netid; + unsigned int r_nc_semantics; + char *r_nc_protofmly; + char *r_nc_proto; +}; +typedef struct rpcb_entry rpcb_entry; + +/* + * A list of addresses supported by a service. + */ + +struct rpcb_entry_list { + rpcb_entry rpcb_entry_map; + struct rpcb_entry_list *rpcb_entry_next; +}; +typedef struct rpcb_entry_list rpcb_entry_list; + +typedef rpcb_entry_list *rpcb_entry_list_ptr; + +/* + * rpcbind statistics + */ + +#define rpcb_highproc_2 RPCBPROC_CALLIT +#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR +#define rpcb_highproc_4 RPCBPROC_GETSTAT +#define RPCBSTAT_HIGHPROC 13 +#define RPCBVERS_STAT 3 +#define RPCBVERS_4_STAT 2 +#define RPCBVERS_3_STAT 1 +#define RPCBVERS_2_STAT 0 + +/* Link list of all the stats about getport and getaddr */ + +struct rpcbs_addrlist { + rpcprog_t prog; + rpcvers_t vers; + int success; + int failure; + char *netid; + struct rpcbs_addrlist *next; +}; +typedef struct rpcbs_addrlist rpcbs_addrlist; + +/* Link list of all the stats about rmtcall */ + +struct rpcbs_rmtcalllist { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + int success; + int failure; + int indirect; + char *netid; + struct rpcbs_rmtcalllist *next; +}; +typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; + +typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; + +typedef rpcbs_addrlist *rpcbs_addrlist_ptr; + +typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; + +struct rpcb_stat { + rpcbs_proc info; + int setinfo; + int unsetinfo; + rpcbs_addrlist_ptr addrinfo; + rpcbs_rmtcalllist_ptr rmtinfo; +}; +typedef struct rpcb_stat rpcb_stat; + +/* + * One rpcb_stat structure is returned for each version of rpcbind + * being monitored. + */ + +typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; + +extern bool_t xdr_netbuf(XDR *, struct netbuf *); + +#ifdef __cplusplus +} +#endif + +#endif /* ndef _KERNEL */ + +#define RPCBPROG 100000 +#define RPCBVERS 3 +#define RPCBPROC_SET 1 +extern enum clnt_stat rpcbproc_set_3(); +extern bool_t rpcbproc_set_3_svc(); +#define RPCBPROC_UNSET 2 +extern enum clnt_stat rpcbproc_unset_3(); +extern bool_t rpcbproc_unset_3_svc(); +#define RPCBPROC_GETADDR 3 +extern enum clnt_stat rpcbproc_getaddr_3(); +extern bool_t rpcbproc_getaddr_3_svc(); +#define RPCBPROC_DUMP 4 +extern enum clnt_stat rpcbproc_dump_3(); +extern bool_t rpcbproc_dump_3_svc(); +#define RPCBPROC_CALLIT 5 +extern enum clnt_stat rpcbproc_callit_3(); +extern bool_t rpcbproc_callit_3_svc(); +#define RPCBPROC_GETTIME 6 +extern enum clnt_stat rpcbproc_gettime_3(); +extern bool_t rpcbproc_gettime_3_svc(); +#define RPCBPROC_UADDR2TADDR 7 +extern enum clnt_stat rpcbproc_uaddr2taddr_3(); +extern bool_t rpcbproc_uaddr2taddr_3_svc(); +#define RPCBPROC_TADDR2UADDR 8 +extern enum clnt_stat rpcbproc_taddr2uaddr_3(); +extern bool_t rpcbproc_taddr2uaddr_3_svc(); +extern int rpcbprog_3_freeresult(); +#define RPCBVERS4 4 +extern enum clnt_stat rpcbproc_set_4(); +extern bool_t rpcbproc_set_4_svc(); +extern enum clnt_stat rpcbproc_unset_4(); +extern bool_t rpcbproc_unset_4_svc(); +extern enum clnt_stat rpcbproc_getaddr_4(); +extern bool_t rpcbproc_getaddr_4_svc(); +extern enum clnt_stat rpcbproc_dump_4(); +extern bool_t rpcbproc_dump_4_svc(); +#define RPCBPROC_BCAST RPCBPROC_CALLIT +extern enum clnt_stat rpcbproc_bcast_4(); +extern bool_t rpcbproc_bcast_4_svc(); +extern enum clnt_stat rpcbproc_gettime_4(); +extern bool_t rpcbproc_gettime_4_svc(); +extern enum clnt_stat rpcbproc_uaddr2taddr_4(); +extern bool_t rpcbproc_uaddr2taddr_4_svc(); +extern enum clnt_stat rpcbproc_taddr2uaddr_4(); +extern bool_t rpcbproc_taddr2uaddr_4_svc(); +#define RPCBPROC_GETVERSADDR 9 +extern enum clnt_stat rpcbproc_getversaddr_4(); +extern bool_t rpcbproc_getversaddr_4_svc(); +#define RPCBPROC_INDIRECT 10 +extern enum clnt_stat rpcbproc_indirect_4(); +extern bool_t rpcbproc_indirect_4_svc(); +#define RPCBPROC_GETADDRLIST 11 +extern enum clnt_stat rpcbproc_getaddrlist_4(); +extern bool_t rpcbproc_getaddrlist_4_svc(); +#define RPCBPROC_GETSTAT 12 +extern enum clnt_stat rpcbproc_getstat_4(); +extern bool_t rpcbproc_getstat_4_svc(); +extern int rpcbprog_4_freeresult(); + +/* the xdr functions */ +extern bool_t xdr_rpcb(); +extern bool_t xdr_rp__list(); +extern bool_t xdr_rpcblist_ptr(); +extern bool_t xdr_rpcb_rmtcallargs(); +extern bool_t xdr_rpcb_rmtcallres(); +extern bool_t xdr_rpcb_entry(); +extern bool_t xdr_rpcb_entry_list(); +extern bool_t xdr_rpcb_entry_list_ptr(); +extern bool_t xdr_rpcbs_addrlist(); +extern bool_t xdr_rpcbs_rmtcalllist(); +extern bool_t xdr_rpcbs_proc(); +extern bool_t xdr_rpcbs_addrlist_ptr(); +extern bool_t xdr_rpcbs_rmtcalllist_ptr(); +extern bool_t xdr_rpcb_stat(); +extern bool_t xdr_rpcb_stat_byvers(); + +#endif /* !_RPCB_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpc/rpcb_prot.x b/illumos-x86_64/usr/include/rpc/rpcb_prot.x new file mode 100644 index 00000000..d69838c9 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpcb_prot.x @@ -0,0 +1,551 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +%/* +% * Copyright (c) 1988,1994 by Sun Microsystems, Inc. +% * All rights reserved. +% */ + +%/* from rpcb_prot.x */ + +#ifdef RPC_HDR +% +%#ifndef _KERNEL +% +#endif + +/* + * rpcb_prot.x + * rpcbind protocol, versions 3 and 4, in RPC Language + */ +% +%/* +% * The following procedures are supported by the protocol in version 3: +% * +% * RPCBPROC_NULL() returns () +% * takes nothing, returns nothing +% * +% * RPCBPROC_SET(rpcb) returns (bool_t) +% * TRUE is success, FALSE is failure. Registers the tuple +% * [prog, vers, address, owner, netid]. +% * Finds out owner and netid information on its own. +% * +% * RPCBPROC_UNSET(rpcb) returns (bool_t) +% * TRUE is success, FALSE is failure. Un-registers tuple +% * [prog, vers, netid]. addresses is ignored. +% * If netid is NULL, unregister all. +% * +% * RPCBPROC_GETADDR(rpcb) returns (string). +% * 0 is failure. Otherwise returns the universal address where the +% * triple [prog, vers, netid] is registered. Ignore address and owner. +% * +% * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) +% * used to dump the entire rpcbind maps +% * +% * RPCBPROC_CALLIT(rpcb_rmtcallargs) +% * RETURNS (rpcb_rmtcallres); +% * Calls the procedure on the remote machine. If it is not registered, +% * this procedure is quiet; i.e. it does not return error information!!! +% * This routine only passes null authentication parameters. +% * It has no interface to xdr routines for RPCBPROC_CALLIT. +% * +% * RPCBPROC_GETTIME() returns (int). +% * Gets the remote machines time +% * +% * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) +% * Returns the netbuf address from universal address. +% * +% * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) +% * Returns the universal address from netbuf address. +% * +% * END OF RPCBIND VERSION 3 PROCEDURES +% */ +%/* +% * Except for RPCBPROC_CALLIT, the procedures above are carried over to +% * rpcbind version 4. Those below are added or modified for version 4. +% * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER +% * AS RPCBPROC_CALLIT. +% * +% * RPCBPROC_BCAST(rpcb_rmtcallargs) +% * RETURNS (rpcb_rmtcallres); +% * Calls the procedure on the remote machine. If it is not registered, +% * this procedure IS quiet; i.e. it DOES NOT return error information!!! +% * This routine should be used for broadcasting and nothing else. +% * +% * RPCBPROC_GETVERSADDR(rpcb) returns (string). +% * 0 is failure. Otherwise returns the universal address where the +% * triple [prog, vers, netid] is registered. Ignore address and owner. +% * Same as RPCBPROC_GETADDR except that if the given version number +% * is not available, the address is not returned. +% * +% * RPCBPROC_INDIRECT(rpcb_rmtcallargs) +% * RETURNS (rpcb_rmtcallres); +% * Calls the procedure on the remote machine. If it is not registered, +% * this procedure is NOT quiet; i.e. it DOES return error information!!! +% * as any normal application would expect. +% * +% * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). +% * Same as RPCBPROC_GETADDR except that it returns a list of all the +% * addresses registered for the combination (prog, vers) (for all +% * transports). +% * +% * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) +% * Returns the statistics about the kind of requests received by rpcbind. +% */ +% +%/* +% * A mapping of (program, version, network ID) to address +% */ +struct rpcb { + rpcprog_t r_prog; /* program number */ + rpcvers_t r_vers; /* version number */ + string r_netid<>; /* network id */ + string r_addr<>; /* universal address */ + string r_owner<>; /* owner of this service */ +}; +#ifdef RPC_HDR +% +%typedef rpcb RPCB; +% +#endif +% +%/* +% * A list of mappings +% * +% * Below are two definitions for the rpcblist structure. This is done because +% * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a +% * struct rpcblist * that rpcgen would produce. One version of the rpcblist +% * structure (actually called rp__list) is used with rpcgen, and the other is +% * defined only in the header file for compatibility with the specified +% * interface. +% */ + +struct rp__list { + rpcb rpcb_map; + struct rp__list *rpcb_next; +}; + +typedef rp__list *rpcblist_ptr; /* results of RPCBPROC_DUMP */ + +#ifdef RPC_HDR +% +%typedef struct rp__list rpcblist; +%typedef struct rp__list RPCBLIST; +% +%#ifndef __cplusplus +%struct rpcblist { +% RPCB rpcb_map; +% struct rpcblist *rpcb_next; +%}; +%#endif +% +%#ifdef __cplusplus +%extern "C" { +%#endif +%#ifdef __STDC__ +%extern bool_t xdr_rpcblist(XDR *, rpcblist**); +%#else /* K&R C */ +%bool_t xdr_rpcblist(); +%#endif +%#ifdef __cplusplus +%} +%#endif +% +#endif + +% +%/* +% * Arguments of remote calls +% */ +struct rpcb_rmtcallargs { + rpcprog_t prog; /* program number */ + rpcvers_t vers; /* version number */ + rpcproc_t proc; /* procedure number */ + opaque args<>; /* argument */ +}; +#ifdef RPC_HDR +% +%/* +% * Client-side only representation of rpcb_rmtcallargs structure. +% * +% * The routine that XDRs the rpcb_rmtcallargs structure must deal with the +% * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to +% * be passed the XDR routine that knows the args' structure. This routine +% * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since +% * the application being called already knows the args structure. So we use a +% * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which +% * includes the args' XDR routine. +% */ +%struct r_rpcb_rmtcallargs { +% rpcprog_t prog; +% rpcvers_t vers; +% rpcproc_t proc; +% struct { +% uint32_t args_len; +% char *args_val; +% } args; +% xdrproc_t xdr_args; /* encodes args */ +%}; +% +#endif /* def RPC_HDR */ +% +%/* +% * Results of the remote call +% */ +struct rpcb_rmtcallres { + string addr<>; /* remote universal address */ + opaque results<>; /* result */ +}; +#ifdef RPC_HDR +% +%/* +% * Client-side only representation of rpcb_rmtcallres structure. +% */ +%struct r_rpcb_rmtcallres { +% char *addr; +% struct { +% uint32_t results_len; +% char *results_val; +% } results; +% xdrproc_t xdr_res; /* decodes results */ +%}; +#endif RPC_HDR +% +%/* +% * rpcb_entry contains a merged address of a service on a particular +% * transport, plus associated netconfig information. A list of rpcb_entrys +% * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used +% * in r_nc_* fields. +% */ +struct rpcb_entry { + string r_maddr<>; /* merged address of service */ + string r_nc_netid<>; /* netid field */ + unsigned int r_nc_semantics; /* semantics of transport */ + string r_nc_protofmly<>; /* protocol family */ + string r_nc_proto<>; /* protocol name */ +}; +% +%/* +% * A list of addresses supported by a service. +% */ +struct rpcb_entry_list { + rpcb_entry rpcb_entry_map; + struct rpcb_entry_list *rpcb_entry_next; +}; + +typedef rpcb_entry_list *rpcb_entry_list_ptr; + +% +%/* +% * rpcbind statistics +% */ +% +const rpcb_highproc_2 = RPCBPROC_CALLIT; +const rpcb_highproc_3 = RPCBPROC_TADDR2UADDR; +const rpcb_highproc_4 = RPCBPROC_GETSTAT; + +const RPCBSTAT_HIGHPROC = 13; /* # of procs in rpcbind V4 plus one */ +const RPCBVERS_STAT = 3; /* provide only for rpcbind V2, V3 and V4 */ +const RPCBVERS_4_STAT = 2; +const RPCBVERS_3_STAT = 1; +const RPCBVERS_2_STAT = 0; +% +%/* Link list of all the stats about getport and getaddr */ +struct rpcbs_addrlist { + rpcprog_t prog; + rpcvers_t vers; + int success; + int failure; + string netid<>; + struct rpcbs_addrlist *next; +}; +% +%/* Link list of all the stats about rmtcall */ +struct rpcbs_rmtcalllist { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + int success; + int failure; + int indirect; /* whether callit or indirect */ + string netid<>; + struct rpcbs_rmtcalllist *next; +}; + +typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; +typedef rpcbs_addrlist *rpcbs_addrlist_ptr; +typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; + +struct rpcb_stat { + rpcbs_proc info; + int setinfo; + int unsetinfo; + rpcbs_addrlist_ptr addrinfo; + rpcbs_rmtcalllist_ptr rmtinfo; +}; +% +%/* +% * One rpcb_stat structure is returned for each version of rpcbind +% * being monitored. +% */ + +typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; + +#ifdef RPC_HDR +% +%/* +% * We don't define netbuf in RPCL, since it would contain structure member +% * names that would conflict with the definition of struct netbuf in +% * . Instead we merely declare the XDR routine xdr_netbuf() here, +% * and implement it ourselves in rpc/rpcb_prot.c. +% */ +%#ifdef __cplusplus +%extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); +% +%#elif __STDC__ +%extern bool_t xdr_netbuf(XDR *, struct netbuf *); +% +%#else /* K&R C */ +%bool_t xdr_netbuf(); +% +%#endif /* K&R C */ +#endif /* def RPC_HDR */ + +/* + * rpcbind procedures + */ +program RPCBPROG { + version RPCBVERS { + bool + RPCBPROC_SET(rpcb) = 1; + + bool + RPCBPROC_UNSET(rpcb) = 2; + + string + RPCBPROC_GETADDR(rpcb) = 3; + + rpcblist_ptr + RPCBPROC_DUMP(void) = 4; + + rpcb_rmtcallres + RPCBPROC_CALLIT(rpcb_rmtcallargs) = 5; + + unsigned int + RPCBPROC_GETTIME(void) = 6; + + struct netbuf + RPCBPROC_UADDR2TADDR(string) = 7; + + string + RPCBPROC_TADDR2UADDR(struct netbuf) = 8; + } = 3; + + version RPCBVERS4 { + bool + RPCBPROC_SET(rpcb) = 1; + + bool + RPCBPROC_UNSET(rpcb) = 2; + + string + RPCBPROC_GETADDR(rpcb) = 3; + + rpcblist_ptr + RPCBPROC_DUMP(void) = 4; + + /* + * NOTE: RPCBPROC_BCAST has the same functionality as CALLIT; + * the new name is intended to indicate that this + * procedure should be used for broadcast RPC, and + * RPCBPROC_INDIRECT should be used for indirect calls. + */ + rpcb_rmtcallres + RPCBPROC_BCAST(rpcb_rmtcallargs) = RPCBPROC_CALLIT; + + unsigned int + RPCBPROC_GETTIME(void) = 6; + + struct netbuf + RPCBPROC_UADDR2TADDR(string) = 7; + + string + RPCBPROC_TADDR2UADDR(struct netbuf) = 8; + + string + RPCBPROC_GETVERSADDR(rpcb) = 9; + + rpcb_rmtcallres + RPCBPROC_INDIRECT(rpcb_rmtcallargs) = 10; + + rpcb_entry_list_ptr + RPCBPROC_GETADDRLIST(rpcb) = 11; + + rpcb_stat_byvers + RPCBPROC_GETSTAT(void) = 12; + } = 4; +} = 100000; +#ifdef RPC_HDR +% +%#define RPCBVERS_3 RPCBVERS +%#define RPCBVERS_4 RPCBVERS4 +% +%#else /* ndef _KERNEL */ +%#ifdef __cplusplus +%extern "C" { +%#endif +% +%/* +% * A mapping of (program, version, network ID) to address +% */ +%struct rpcb { +% rpcprog_t r_prog; /* program number */ +% rpcvers_t r_vers; /* version number */ +% char *r_netid; /* network id */ +% char *r_addr; /* universal address */ +% char *r_owner; /* owner of the mapping */ +%}; +%typedef struct rpcb RPCB; +% +%/* +% * A list of mappings +% */ +%struct rpcblist { +% RPCB rpcb_map; +% struct rpcblist *rpcb_next; +%}; +%typedef struct rpcblist RPCBLIST; +%typedef struct rpcblist *rpcblist_ptr; +% +%/* +% * Remote calls arguments +% */ +%struct rpcb_rmtcallargs { +% rpcprog_t prog; /* program number */ +% rpcvers_t vers; /* version number */ +% rpcproc_t proc; /* procedure number */ +% unsigned int arglen; /* arg len */ +% caddr_t args_ptr; /* argument */ +% xdrproc_t xdr_args; /* XDR routine for argument */ +%}; +%typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; +% +%/* +% * Remote calls results +% */ +%struct rpcb_rmtcallres { +% char *addr_ptr; /* remote universal address */ +% uint32_t resultslen; /* results length */ +% caddr_t results_ptr; /* results */ +% xdrproc_t xdr_results; /* XDR routine for result */ +%}; +%typedef struct rpcb_rmtcallres rpcb_rmtcallres; +% +%struct rpcb_entry { +% char *r_maddr; +% char *r_nc_netid; +% unsigned int r_nc_semantics; +% char *r_nc_protofmly; +% char *r_nc_proto; +%}; +%typedef struct rpcb_entry rpcb_entry; +% +%/* +% * A list of addresses supported by a service. +% */ +% +%struct rpcb_entry_list { +% rpcb_entry rpcb_entry_map; +% struct rpcb_entry_list *rpcb_entry_next; +%}; +%typedef struct rpcb_entry_list rpcb_entry_list; +% +%typedef rpcb_entry_list *rpcb_entry_list_ptr; +% +%/* +% * rpcbind statistics +% */ +% +%#define rpcb_highproc_2 RPCBPROC_CALLIT +%#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR +%#define rpcb_highproc_4 RPCBPROC_GETSTAT +%#define RPCBSTAT_HIGHPROC 13 +%#define RPCBVERS_STAT 3 +%#define RPCBVERS_4_STAT 2 +%#define RPCBVERS_3_STAT 1 +%#define RPCBVERS_2_STAT 0 +% +%/* Link list of all the stats about getport and getaddr */ +% +%struct rpcbs_addrlist { +% rpcprog_t prog; +% rpcvers_t vers; +% int success; +% int failure; +% char *netid; +% struct rpcbs_addrlist *next; +%}; +%typedef struct rpcbs_addrlist rpcbs_addrlist; +% +%/* Link list of all the stats about rmtcall */ +% +%struct rpcbs_rmtcalllist { +% rpcprog_t prog; +% rpcvers_t vers; +% rpcproc_t proc; +% int success; +% int failure; +% int indirect; +% char *netid; +% struct rpcbs_rmtcalllist *next; +%}; +%typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; +% +%typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; +% +%typedef rpcbs_addrlist *rpcbs_addrlist_ptr; +% +%typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; +% +%struct rpcb_stat { +% rpcbs_proc info; +% int setinfo; +% int unsetinfo; +% rpcbs_addrlist_ptr addrinfo; +% rpcbs_rmtcalllist_ptr rmtinfo; +%}; +%typedef struct rpcb_stat rpcb_stat; +% +%/* +% * One rpcb_stat structure is returned for each version of rpcbind +% * being monitored. +% */ +% +%typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; +% +%extern bool_t xdr_netbuf(XDR *, struct netbuf *); +% +%#ifdef __cplusplus +%} +%#endif +% +%#endif /* ndef _KERNEL */ +#endif /* RPC_HDR */ diff --git a/illumos-x86_64/usr/include/rpc/rpcent.h b/illumos-x86_64/usr/include/rpc/rpcent.h new file mode 100644 index 00000000..d513d523 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpcent.h @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1991 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * rpcent.h, + * For converting rpc program numbers to names etc. + * + */ + +#ifndef _RPC_RPCENT_H +#define _RPC_RPCENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct rpcent { + char *r_name; /* name of server for this rpc program */ + char **r_aliases; /* alias list */ + int r_number; /* rpc program number */ +}; + +#ifdef __STDC__ +extern struct rpcent *getrpcbyname_r + (const char *, struct rpcent *, char *, int); +extern struct rpcent *getrpcbynumber_r + (const int, struct rpcent *, char *, int); +extern struct rpcent *getrpcent_r(struct rpcent *, char *, int); + +/* Old interfaces that return a pointer to a static area; MT-unsafe */ +extern struct rpcent *getrpcbyname(const char *); +extern struct rpcent *getrpcbynumber(const int); +extern struct rpcent *getrpcent(void); +extern void setrpcent(const int); +extern void endrpcent(void); +#else +extern struct rpcent *getrpcbyname_r(); +extern struct rpcent *getrpcbynumber_r(); +extern struct rpcent *getrpcent_r(); + +/* Old interfaces that return a pointer to a static area; MT-unsafe */ +extern struct rpcent *getrpcbyname(); +extern struct rpcent *getrpcbynumber(); +extern struct rpcent *getrpcent(); +extern void setrpcent(); +extern void endrpcent(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_RPCENT_H */ diff --git a/illumos-x86_64/usr/include/rpc/rpcsec_gss.h b/illumos-x86_64/usr/include/rpc/rpcsec_gss.h new file mode 100644 index 00000000..4b73b61c --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpcsec_gss.h @@ -0,0 +1,337 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved. + */ + +/* + * rpcsec_gss.h, RPCSEC_GSS security service interface. + */ + +#ifndef _RPCSEC_GSS_H +#define _RPCSEC_GSS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * Interface definitions. + */ +#define MAX_NAME_LEN 64 +#define MAX_GSS_MECH 128 +#define MAX_GSS_NAME 128 + +typedef enum { + rpc_gss_svc_default = 0, + rpc_gss_svc_none = 1, + rpc_gss_svc_integrity = 2, + rpc_gss_svc_privacy = 3 +} rpc_gss_service_t; + +/* + * GSS-API based security mechanism type specified as + * object identifiers (OIDs). + * This type is derived from gss_OID_desc/gss_OID. + */ +#define rpc_gss_OID_s gss_OID_desc_struct +typedef struct rpc_gss_OID_s rpc_gss_OID_desc, *rpc_gss_OID; + +/* + * Interface data. + * This is already suitable for both LP64 and ILP32. + */ +typedef struct rpc_gss_principal { + int len; + char name[1]; +} *rpc_gss_principal_t; + +typedef struct { + int req_flags; + int time_req; + gss_cred_id_t my_cred; + gss_channel_bindings_t input_channel_bindings; +} rpc_gss_options_req_t; + +typedef struct { + int major_status; + int minor_status; + uint_t rpcsec_version; + int ret_flags; + int time_ret; + gss_ctx_id_t gss_context; +#ifdef _KERNEL + rpc_gss_OID actual_mechanism; +#else + char actual_mechanism[MAX_GSS_MECH]; +#endif +} rpc_gss_options_ret_t; + +/* + * raw credentials + */ +typedef struct { + uint_t version; +#ifdef _KERNEL + rpc_gss_OID mechanism; + uint_t qop; +#else + char *mechanism; + char *qop; +#endif + rpc_gss_principal_t client_principal; + char *svc_principal; /* service@server, e.g. nfs@caribe */ + rpc_gss_service_t service; +} rpc_gss_rawcred_t; + +/* + * unix credentials + */ +typedef struct { + uid_t uid; + gid_t gid; + short gidlen; + gid_t *gidlist; +} rpc_gss_ucred_t; + +/* + * for callback routine + */ +typedef struct { + uint_t program; + uint_t version; + bool_t (*callback)(); +} rpc_gss_callback_t; + +/* + * lock used for the callback routine + */ +typedef struct { + bool_t locked; + rpc_gss_rawcred_t *raw_cred; +} rpc_gss_lock_t; + + +/* + * This is for user RPC applications. + * Structure used to fetch the error code when one of + * the rpc_gss_* routines fails. + */ +typedef struct { + int rpc_gss_error; + int system_error; +} rpc_gss_error_t; + +#define RPC_GSS_ER_SUCCESS 0 /* no error */ +#define RPC_GSS_ER_SYSTEMERROR 1 /* system error */ + + +#ifdef _SYSCALL32 +struct gss_clnt_data32 { + gss_OID_desc32 mechanism; + rpc_gss_service_t service; + char uname[MAX_NAME_LEN]; /* server's service name */ + char inst[MAX_NAME_LEN]; /* server's instance name */ + char realm[MAX_NAME_LEN]; /* server's realm */ + uint_t qop; +}; +#endif + +/* + * This is for Kernel RPC applications. + * RPCSEC_GSS flavor specific data in sec_data opaque field. + */ +typedef struct gss_clnt_data { + rpc_gss_OID_desc mechanism; + rpc_gss_service_t service; + char uname[MAX_NAME_LEN]; /* server's service name */ + char inst[MAX_NAME_LEN]; /* server's instance name */ + char realm[MAX_NAME_LEN]; /* server's realm */ + uint_t qop; +} gss_clntdata_t; + + +struct svc_req; +/* + * KERNEL rpc_gss_* interfaces. + */ +#ifdef _KERNEL +int rpc_gss_secget(CLIENT *, char *, rpc_gss_OID, + rpc_gss_service_t, uint_t, rpc_gss_options_req_t *, + rpc_gss_options_ret_t *, void *, cred_t *, AUTH **); + +void rpc_gss_secfree(AUTH *); + +int rpc_gss_seccreate(CLIENT *, char *, rpc_gss_OID, + rpc_gss_service_t, uint_t, rpc_gss_options_req_t *, + rpc_gss_options_ret_t *, cred_t *, AUTH **); + +int rpc_gss_revauth(uid_t, rpc_gss_OID); +void rpc_gss_secpurge(void *); +enum auth_stat __svcrpcsec_gss(struct svc_req *, + struct rpc_msg *, bool_t *); +bool_t rpc_gss_set_defaults(AUTH *, rpc_gss_service_t, uint_t); +rpc_gss_service_t rpc_gss_get_service_type(AUTH *); + + +#else +/* + * USER rpc_gss_* public interfaces + */ +AUTH * +rpc_gss_seccreate( + CLIENT *clnt, /* associated client handle */ + char *principal, /* server service principal */ + char *mechanism, /* security mechanism */ + rpc_gss_service_t service_type, /* security service */ + char *qop, /* requested QOP */ + rpc_gss_options_req_t *options_req, /* requested options */ + rpc_gss_options_ret_t *options_ret /* returned options */ +); + +bool_t +rpc_gss_get_principal_name( + rpc_gss_principal_t *principal, + char *mechanism, + char *user_name, + char *node, + char *secdomain +); + +char **rpc_gss_get_mechanisms(); + +char **rpc_gss_get_mech_info( + char *mechanism, + rpc_gss_service_t *service +); + +bool_t +rpc_gss_is_installed( + char *mechanism +); + +bool_t +rpc_gss_mech_to_oid( + char *mech, + rpc_gss_OID *oid +); + +bool_t +rpc_gss_qop_to_num( + char *qop, + char *mech, + uint_t *num +); + +bool_t +rpc_gss_set_svc_name( + char *principal, + char *mechanism, + uint_t req_time, + uint_t program, + uint_t version +); + +bool_t +rpc_gss_set_defaults( + AUTH *auth, + rpc_gss_service_t service, + char *qop +); + +void +rpc_gss_get_error( + rpc_gss_error_t *error +); + +/* + * User level private interfaces + */ +enum auth_stat __svcrpcsec_gss(); +bool_t __rpc_gss_wrap(); +bool_t __rpc_gss_unwrap(); + +#endif + +/* + * USER and KERNEL rpc_gss_* interfaces. + */ +bool_t +rpc_gss_set_callback( + rpc_gss_callback_t *cb +); + +bool_t +rpc_gss_getcred( + struct svc_req *req, + rpc_gss_rawcred_t **rcred, + rpc_gss_ucred_t **ucred, + void **cookie +); + +int +rpc_gss_max_data_length( + AUTH *rpcgss_handle, + int max_tp_unit_len +); + +int +rpc_gss_svc_max_data_length( + struct svc_req *req, + int max_tp_unit_len +); + +bool_t +rpc_gss_get_versions( + uint_t *vers_hi, + uint_t *vers_lo +); + +#define RPCSEC_GSS_REFRESH_ATTEMPTS 20 + +/* + * Protocol data. + * + * The reason to put these definition in this header file + * is for 2.6 snoop to handle the RPCSEC_GSS protocol + * interpretation. + */ +#define RPCSEC_GSS_DATA 0 +#define RPCSEC_GSS_INIT 1 +#define RPCSEC_GSS_CONTINUE_INIT 2 +#define RPCSEC_GSS_DESTROY 3 + +#define RPCSEC_GSS_VERSION 1 + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPCSEC_GSS_H */ diff --git a/illumos-x86_64/usr/include/rpc/rpcsys.h b/illumos-x86_64/usr/include/rpc/rpcsys.h new file mode 100644 index 00000000..f7d72f9a --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/rpcsys.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _RPC_RPCSYS_H +#define _RPC_RPCSYS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum rpcsys_op { KRPC_REVAUTH }; + +/* + * Private definitions for the krpc_sys/rpcsys system call. + * + * flavor_data for AUTH_DES and AUTH_KERB is NULL. + * flavor_data for RPCSEC_GSS is rpc_gss_OID. + * + */ +struct krpc_revauth_1 { + uid_t uid; + int rpcsec_flavor; + void *flavor_data; +}; + +#ifdef _SYSCALL32 +struct krpc_revauth_132 { + uid32_t uid; + int32_t rpcsec_flavor; + caddr32_t flavor_data; +}; +#endif /* _SYSCALL32 */ + +struct krpc_revauth { + int version; /* initially 1 */ + union { + struct krpc_revauth_1 r; + } krpc_revauth_u; +}; +#define uid_1 krpc_revauth_u.r.uid +#define rpcsec_flavor_1 krpc_revauth_u.r.rpcsec_flavor +#define flavor_data_1 krpc_revauth_u.r.flavor_data + +#ifdef _SYSCALL32 +struct krpc_revauth32 { + int32_t version; /* initially 1 */ + union { + struct krpc_revauth_132 r; + } krpc_revauth_u; +}; +#endif /* _SYSCALL32 */ + + +#ifdef _KERNEL + +extern int rpcsys(enum rpcsys_op opcode, void *arg); +extern int sec_clnt_revoke(int, uid_t, cred_t *, void *, model_t); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_RPCSYS_H */ diff --git a/illumos-x86_64/usr/include/rpc/svc.h b/illumos-x86_64/usr/include/rpc/svc.h new file mode 100644 index 00000000..28d2f297 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/svc.h @@ -0,0 +1,1170 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Marcel Telka + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * svc.h, Server-side remote procedure call interface. + */ + +#ifndef _RPC_SVC_H +#define _RPC_SVC_H + +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#include +#endif /* _KERNEL */ + +/* + * This interface must manage two items concerning remote procedure calling: + * + * 1) An arbitrary number of transport connections upon which rpc requests + * are received. They are created and registered by routines in svc_generic.c, + * svc_vc.c and svc_dg.c; they in turn call xprt_register and + * xprt_unregister. + * + * 2) An arbitrary number of locally registered services. Services are + * described by the following four data: program number, version number, + * "service dispatch" function, a transport handle, and a boolean that + * indicates whether or not the exported program should be registered with a + * local binder service; if true the program's number and version and the + * address from the transport handle are registered with the binder. + * These data are registered with rpcbind via svc_reg(). + * + * A service's dispatch function is called whenever an rpc request comes in + * on a transport. The request's program and version numbers must match + * those of the registered service. The dispatch function is passed two + * parameters, struct svc_req * and SVCXPRT *, defined below. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Server-side transport handles. + * The actual type definitions are below. + */ +#ifdef _KERNEL +typedef struct __svcmasterxprt SVCMASTERXPRT; /* Master transport handle */ +typedef struct __svcxprt SVCXPRT; /* Per-thread clone handle */ +typedef struct __svcpool SVCPOOL; /* Kernel thread pool */ +#else /* _KERNEL */ +typedef struct __svcxprt SVCXPRT; /* Server transport handle */ +#endif /* _KERNEL */ + +/* + * Prototype of error handler callback + */ +#ifndef _KERNEL +typedef void (*svc_errorhandler_t)(const SVCXPRT* svc, const bool_t isAConn); +#endif + +/* + * Service request. + * + * PSARC 2003/523 Contract Private Interface + * svc_req + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +struct svc_req { + rpcprog_t rq_prog; /* service program number */ + rpcvers_t rq_vers; /* service protocol version */ + rpcproc_t rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + caddr_t rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ + bslabel_t *rq_label; /* TSOL label of the request */ +}; + +#ifdef _KERNEL +struct dupreq { + uint32_t dr_xid; + rpcproc_t dr_proc; + rpcvers_t dr_vers; + rpcprog_t dr_prog; + struct netbuf dr_addr; + struct netbuf dr_resp; + void (*dr_resfree)(); + int dr_status; + struct dupreq *dr_next; + struct dupreq *dr_chain; +}; + +/* + * States of requests for duplicate request caching. + */ +#define DUP_NEW 0x00 /* new entry */ +#define DUP_INPROGRESS 0x01 /* request already going */ +#define DUP_DONE 0x02 /* request done */ +#define DUP_DROP 0x03 /* request dropped */ +#define DUP_ERROR 0x04 /* error in dup req cache */ + +/* + * Prototype for a service dispatch routine. + */ +typedef void (SVC_DISPATCH)(struct svc_req *, SVCXPRT *); + +/* + * The service provider callout. + * Each entry identifies a dispatch routine to be called + * for a given RPC program number and a version fitting + * into the registered range. + */ +typedef struct { + rpcprog_t sc_prog; /* RPC Program number */ + rpcvers_t sc_versmin; /* Min version number */ + rpcvers_t sc_versmax; /* Max version number */ + SVC_DISPATCH *sc_dispatch; /* Dispatch routine */ +} SVC_CALLOUT; + +/* + * Table of service provider `callouts' for an RPC + * transport handle. If sct_free is TRUE then transport + * destructor is supposed to deallocate this table. + */ +typedef struct { + size_t sct_size; /* Number of entries */ + bool_t sct_free; /* Deallocate if true */ + SVC_CALLOUT *sct_sc; /* Callout entries */ +} SVC_CALLOUT_TABLE; + +struct svc_ops { + bool_t (*xp_recv)(SVCXPRT *, mblk_t *, struct rpc_msg *); + /* receive incoming requests */ + bool_t (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t); + /* get arguments */ + bool_t (*xp_reply)(SVCXPRT *, struct rpc_msg *); + /* send reply */ + bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t); + /* free mem allocated for args */ + void (*xp_destroy)(SVCMASTERXPRT *); + /* destroy this struct */ + int (*xp_dup)(struct svc_req *, caddr_t, int, + struct dupreq **, bool_t *); + /* check for dup */ + void (*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int); + /* mark dup entry as completed */ + int32_t *(*xp_getres)(SVCXPRT *, int); + /* get pointer to response buffer */ + void (*xp_freeres)(SVCXPRT *); + /* destroy pre-serialized response */ + void (*xp_clone_destroy)(SVCXPRT *); + /* destroy a clone xprt */ + void (*xp_start)(SVCMASTERXPRT *); + /* `ready-to-receive' */ + void (*xp_clone_xprt)(SVCXPRT *, SVCXPRT *); + /* transport specific clone function */ + void (*xp_tattrs)(SVCXPRT *, int, void **); + /* transport specific hold function */ + void (*xp_hold)(queue_t *); + /* transport specific release function */ + void (*xp_release)(queue_t *, mblk_t *, bool_t); +}; + +#define SVC_TATTR_ADDRMASK 1 + +#else /* _KERNEL */ +/* + * Service control requests + */ +#define SVCGET_VERSQUIET 1 +#define SVCSET_VERSQUIET 2 +#define SVCGET_XID 4 +#define SVCSET_KEEPALIVE 5 +#define SVCSET_CONNMAXREC 6 +#define SVCGET_CONNMAXREC 7 +#define SVCGET_RECVERRHANDLER 8 +#define SVCSET_RECVERRHANDLER 9 + +enum xprt_stat { + XPRT_DIED, + XPRT_MOREREQS, + XPRT_IDLE +}; + +struct xp_ops { +#ifdef __STDC__ + bool_t (*xp_recv)(SVCXPRT *, struct rpc_msg *); + /* receive incoming requests */ + enum xprt_stat (*xp_stat)(SVCXPRT *); + /* get transport status */ + bool_t (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t); + /* get arguments */ + bool_t (*xp_reply)(SVCXPRT *, struct rpc_msg *); + /* send reply */ + bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t); + /* free mem allocated for args */ + void (*xp_destroy)(SVCXPRT *); + /* destroy this struct */ + bool_t (*xp_control)(SVCXPRT *, const uint_t, void *); + /* catch-all control function */ +#else /* __STDC__ */ + bool_t (*xp_recv)(); /* receive incoming requests */ + enum xprt_stat (*xp_stat)(); /* get transport status */ + bool_t (*xp_getargs)(); /* get arguments */ + bool_t (*xp_reply)(); /* send reply */ + bool_t (*xp_freeargs)(); /* free mem allocated for args */ + void (*xp_destroy)(); /* destroy this struct */ + bool_t (*xp_control)(); /* catch-all control function */ +#endif /* __STDC__ */ +}; +#endif /* _KERNEL */ + +#ifdef _KERNEL +/* + * SVCPOOL + * Kernel RPC server-side thread pool structure. + */ +typedef struct __svcxprt_qnode __SVCXPRT_QNODE; /* Defined in svc.c */ + +struct __svcpool { + /* + * Thread pool variables. + * + * The pool's thread lock p_thread_lock protects: + * - p_threads, p_detached_threads, p_reserved_threads and p_closing + * The pool's request lock protects: + * - p_asleep, p_drowsy, p_reqs, p_size, p_walkers, p_req_cv. + * The following fields are `initialized constants': + * - p_id, p_stksize, p_timeout. + * Access to p_next and p_prev is protected by the pool + * list lock. + */ + SVCPOOL *p_next; /* Next pool in the list */ + SVCPOOL *p_prev; /* Prev pool in the list */ + int p_id; /* Pool id */ + int p_threads; /* Non-detached threads */ + int p_detached_threads; /* Detached threads */ + int p_maxthreads; /* Max threads in the pool */ + int p_redline; /* `Redline' for the pool */ + int p_reserved_threads; /* Reserved threads */ + kmutex_t p_thread_lock; /* Thread lock */ + int p_asleep; /* Asleep threads */ + int p_drowsy; /* Drowsy flag */ + kcondvar_t p_req_cv; /* svc_poll() sleep var. */ + clock_t p_timeout; /* svc_poll() timeout */ + kmutex_t p_req_lock; /* Request lock */ + int p_reqs; /* Pending requests */ + int p_walkers; /* Walking threads */ + int p_max_same_xprt; /* Max reqs from the xprt */ + int p_stksize; /* Stack size for svc_run */ + bool_t p_closing : 1; /* Pool is closing */ + + /* + * Thread creator variables. + * The `creator signaled' flag is turned on when a signal is send + * to the creator thread (to create a new service thread). The + * creator clears when the thread is created. The protocol is not + * to signal the creator thread when the flag is on. However, + * a new thread should signal the creator if there are more + * requests in the queue. + * + * When the pool is closing (ie it has been already unregistered from + * the pool list) the last thread on the last transport should turn + * the p_creator_exit flag on. This tells the creator thread to + * free the pool structure and exit. + */ + bool_t p_creator_signaled : 1; /* Create requested flag */ + bool_t p_creator_exit : 1; /* If true creator exits */ + kcondvar_t p_creator_cv; /* Creator cond. variable */ + kmutex_t p_creator_lock; /* Creator lock */ + + /* + * Doubly linked list containing `registered' master transport handles. + * There is no special structure for a list node. Instead the + * SVCMASTERXPRT structure has the xp_next and xp_prev fields. + * + * The p_lrwlock protects access to xprt->xp_next and xprt->xp_prev. + * A service thread should also acquire a reader lock before accessing + * any transports it is no longer linked to (to prevent them from + * being destroyed). + * + * The list lock governs also the `pool is closing' flag. + */ + size_t p_lcount; /* Current count */ + SVCMASTERXPRT *p_lhead; /* List head */ + krwlock_t p_lrwlock; /* R/W lock */ + + /* + * Circular linked list for the `xprt-ready' queue (FIFO). + * Must be initialized with svc_xprt_qinit() before it is used. + * + * The writer's end is protected by the pool's request lock + * (pool->p_req_lock). The reader's end is protected by q_end_lock. + * + * When the queue is full the p_qoverflow flag is raised. It stays + * on until all the pending request are drained. + */ + size_t p_qsize; /* Number of queue nodes */ + int p_qoverflow : 1; /* Overflow flag */ + __SVCXPRT_QNODE *p_qbody; /* Queue body (array) */ + __SVCXPRT_QNODE *p_qtop; /* Writer's end of FIFO */ + __SVCXPRT_QNODE *p_qend; /* Reader's end of FIFO */ + kmutex_t p_qend_lock; /* Reader's end lock */ + + /* + * Userspace thread creator variables. + * Thread creation is actually done in userland, via a thread + * that is parked in the kernel. When that thread is signaled, + * it returns back down to the daemon from whence it came and + * does the lwp create. + * + * A parallel "creator" thread runs in the kernel. That is the + * thread that will signal for the user thread to return to + * userland and do its work. + * + * Since the thread doesn't always exist (there could be a race + * if two threads are created in rapid succession), we set + * p_signal_create_thread to FALSE when we're ready to accept work. + * + * p_user_exit is set to true when the service pool is about + * to close. This is done so that the user creation thread + * can be informed and cleanup any userland state. + */ + + bool_t p_signal_create_thread : 1; /* Create requested flag */ + bool_t p_user_exit : 1; /* If true creator exits */ + bool_t p_user_waiting : 1; /* Thread waiting for work */ + kcondvar_t p_user_cv; /* Creator cond. variable */ + kmutex_t p_user_lock; /* Creator lock */ + void (*p_offline)(); /* callout for unregister */ + void (*p_shutdown)(); /* callout for shutdown */ + + size_t p_size; /* Total size of queued msgs */ +}; + +/* + * Server side transport handle (SVCMASTERXPRT). + * xprt->xp_req_lock governs the following fields in xprt: + * xp_req_head, xp_req_tail. + * xprt->xp_thread_lock governs the following fields in xprt: + * xp_threads, xp_detached_threads. + * + * xp_req_tail is only valid if xp_req_head is non-NULL + * + * The xp_threads count is the number of attached threads. These threads + * are able to handle new requests, and it is expected that they will not + * block for a very long time handling a given request. The + * xp_detached_threads count is the number of threads that have detached + * themselves from the transport. These threads can block indefinitely + * while handling a request. Once they complete the request, they exit. + * + * A kernel service provider may register a callback function "closeproc" + * for a transport. When the transport is closing the last exiting attached + * thread - xp_threads goes to zero - it calls the callback function, passing + * it a reference to the transport. This call is made with xp_thread_lock + * held, so any cleanup bookkeeping it does should be done quickly. + * + * When the transport is closing the last exiting thread is supposed + * to destroy/free the data structure. + */ +typedef struct __svcxprt_common { + struct file *xpc_fp; + struct svc_ops *xpc_ops; + queue_t *xpc_wq; /* queue to write onto */ + cred_t *xpc_cred; /* cached cred for server to use */ + int32_t xpc_type; /* transport type */ + int xpc_msg_size; /* TSDU or TIDU size */ + struct netbuf xpc_rtaddr; /* remote transport address */ + struct netbuf xpc_lcladdr; /* local transport address */ + char *xpc_netid; /* network token */ + SVC_CALLOUT_TABLE *xpc_sct; +} __SVCXPRT_COMMON; + +#define xp_fp xp_xpc.xpc_fp +#define xp_ops xp_xpc.xpc_ops +#define xp_wq xp_xpc.xpc_wq +#define xp_cred xp_xpc.xpc_cred +#define xp_type xp_xpc.xpc_type +#define xp_msg_size xp_xpc.xpc_msg_size +#define xp_rtaddr xp_xpc.xpc_rtaddr +#define xp_lcladdr xp_xpc.xpc_lcladdr +#define xp_sct xp_xpc.xpc_sct +#define xp_netid xp_xpc.xpc_netid + +struct __svcmasterxprt { + SVCMASTERXPRT *xp_next; /* Next transport in the list */ + SVCMASTERXPRT *xp_prev; /* Prev transport in the list */ + __SVCXPRT_COMMON xp_xpc; /* Fields common with the clone */ + SVCPOOL *xp_pool; /* Pointer to the pool */ + mblk_t *xp_req_head; /* Request queue head */ + mblk_t *xp_req_tail; /* Request queue tail */ + kmutex_t xp_req_lock; /* Request lock */ + int xp_threads; /* Current num. of attached threads */ + int xp_detached_threads; /* num. of detached threads */ + kmutex_t xp_thread_lock; /* Thread count lock */ + void (*xp_closeproc)(const SVCMASTERXPRT *); + /* optional; see comments above */ + struct netbuf xp_addrmask; /* address mask */ + + caddr_t xp_p2; /* private: for use by svc ops */ + + int xp_full : 1; /* xprt is full */ + int xp_enable : 1; /* xprt needs to be enabled */ + int xp_reqs; /* number of requests queued */ + size_t xp_size; /* total size of queued msgs */ +}; + +/* + * Service thread `clone' transport handle (SVCXPRT) + * + * PSARC 2003/523 Contract Private Interface + * SVCXPRT + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + * + * The xp_p2buf buffer is used as the storage for a transport type + * specific structure. It is private for the svc ops for a given + * transport type. + */ + +#define SVC_P2LEN 128 + +struct __svcxprt { + __SVCXPRT_COMMON xp_xpc; + SVCMASTERXPRT *xp_master; /* back ptr to master */ + + /* The following fileds are on a per-thread basis */ + callb_cpr_t *xp_cprp; /* unused padding for Contract */ + bool_t xp_reserved : 1; /* is thread reserved? */ + bool_t xp_detached : 1; /* is thread detached? */ + int xp_same_xprt; /* Reqs from the same xprt */ + + /* The following fields are used on a per-request basis */ + struct opaque_auth xp_verf; /* raw response verifier */ + SVCAUTH xp_auth; /* auth flavor of current req */ + void *xp_cookie; /* a cookie */ + uint32_t xp_xid; /* id */ + XDR xp_xdrin; /* input xdr stream */ + XDR xp_xdrout; /* output xdr stream */ + + /* Private for svc ops */ + char xp_p2buf[SVC_P2LEN]; /* udp_data or cots_data_t */ + /* or clone_rdma_data_t */ +}; +#else /* _KERNEL */ +struct __svcxprt { + int xp_fd; +#define xp_sock xp_fd + ushort_t xp_port; + /* + * associated port number. + * Obsolete, but still used to + * specify whether rendezvouser + * or normal connection + */ + struct xp_ops *xp_ops; + int xp_addrlen; /* length of remote addr. Obsoleted */ + char *xp_tp; /* transport provider device name */ + char *xp_netid; /* network token */ + struct netbuf xp_ltaddr; /* local transport address */ + struct netbuf xp_rtaddr; /* remote transport address */ + char xp_raddr[16]; /* remote address. Now obsoleted */ + struct opaque_auth xp_verf; /* raw response verifier */ + caddr_t xp_p1; /* private: for use by svc ops */ + caddr_t xp_p2; /* private: for use by svc ops */ + caddr_t xp_p3; /* private: for use by svc lib */ + int xp_type; /* transport type */ + /* + * callback on client death + * First parameter is the current structure, + * Second parameter : + * - FALSE for the service listener + * - TRUE for a real connected socket + */ + svc_errorhandler_t xp_closeclnt; +}; +#endif /* _KERNEL */ + +/* + * Approved way of getting address of caller, + * address mask, and netid of transport. + */ +#define svc_getrpccaller(x) (&(x)->xp_rtaddr) +#ifdef _KERNEL +#define svc_getcaller(x) (&(x)->xp_rtaddr.buf) +#define svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask) +#define svc_getnetid(x) ((x)->xp_netid) +#endif /* _KERNEL */ + +/* + * Operations defined on an SVCXPRT handle + */ + +#ifdef _KERNEL + +#define SVC_GETADDRMASK(clone_xprt, attrflag, tattr) \ +(*(clone_xprt)->xp_ops->xp_tattrs)((clone_xprt), (attrflag), (tattr)) + +#define SVC_CLONE_XPRT(src_xprt, dst_xprt) \ + if ((src_xprt)->xp_ops->xp_clone_xprt) \ + (*(src_xprt)->xp_ops->xp_clone_xprt) \ + (src_xprt, dst_xprt) + +#define SVC_HOLD(xprt) \ + if ((xprt)->xp_ops->xp_hold) \ + (*(xprt)->xp_ops->xp_hold)((xprt)->xp_wq) + +#define SVC_RELE(xprt, mp, enable) \ + if ((xprt)->xp_ops->xp_release) \ + (*(xprt)->xp_ops->xp_release)((xprt)->xp_wq, (mp), (enable)) + +#define SVC_RECV(clone_xprt, mp, msg) \ + (*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg)) + +/* + * PSARC 2003/523 Contract Private Interface + * SVC_GETARGS + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +#define SVC_GETARGS(clone_xprt, xargs, argsp) \ + (*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp)) + +#define SVC_REPLY(clone_xprt, msg) \ + (*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg)) + +#define SVC_FREEARGS(clone_xprt, xargs, argsp) \ + (*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp)) + +#define SVC_GETRES(clone_xprt, size) \ + (*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size)) + +#define SVC_FREERES(clone_xprt) \ + (*(clone_xprt)->xp_ops->xp_freeres)(clone_xprt) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + +/* + * PSARC 2003/523 Contract Private Interfaces + * SVC_DUP, SVC_DUPDONE, SVC_DUP_EXT, SVC_DUPDONE_EXT + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + * + * SVC_DUP and SVC_DUPDONE are defined here for backward compatibility. + */ +#define SVC_DUP_EXT(clone_xprt, req, res, size, drpp, dupcachedp) \ + (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, dupcachedp) + +#define SVC_DUPDONE_EXT(clone_xprt, dr, res, resfree, size, status) \ + (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, resfree, size, status) + +#define SVC_DUP(clone_xprt, req, res, size, drpp) \ + (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, NULL) + +#define SVC_DUPDONE(clone_xprt, dr, res, size, status) \ + (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, NULL, size, status) + +#define SVC_CLONE_DESTROY(clone_xprt) \ + (*(clone_xprt)->xp_ops->xp_clone_destroy)(clone_xprt) + + +#define SVC_START(xprt) \ + (*(xprt)->xp_ops->xp_start)(xprt) + +#else /* _KERNEL */ + +#define SVC_RECV(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) +#define svc_recv(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) + +#define SVC_STAT(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) +#define svc_stat(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) + +#define SVC_GETARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) +#define svc_getargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) + +#define SVC_REPLY(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) +#define svc_reply(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) + +#define SVC_FREEARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) +#define svc_freeargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) + +#define SVC_GETRES(xprt, size) \ + (*(xprt)->xp_ops->xp_getres)((xprt), (size)) +#define svc_getres(xprt, size) \ + (*(xprt)->xp_ops->xp_getres)((xprt), (size)) + +#define SVC_FREERES(xprt) \ + (*(xprt)->xp_ops->xp_freeres)(xprt) +#define svc_freeres(xprt) \ + (*(xprt)->xp_ops->xp_freeres)(xprt) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) +#define svc_destroy(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + +/* + * PSARC 2003/523 Contract Private Interface + * SVC_CONTROL + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +#define SVC_CONTROL(xprt, rq, in) \ + (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in)) +#endif /* _KERNEL */ + +/* + * Pool id's reserved for NFS, NLM, and the NFSv4 callback program. + */ +#define NFS_SVCPOOL_ID 0x01 +#define NLM_SVCPOOL_ID 0x02 +#define NFS_CB_SVCPOOL_ID 0x03 +#define RDC_SVCPOOL_ID 0x05 /* SNDR, PSARC 2001/699 */ + +struct svcpool_args { + uint32_t id; /* Pool id */ + uint32_t maxthreads; /* Max threads in the pool */ + uint32_t redline; /* `Redline' for the pool */ + uint32_t qsize; /* `xprt-ready' queue size */ + uint32_t timeout; /* svc_poll() timeout */ + uint32_t stksize; /* svc_run() stack size */ + uint32_t max_same_xprt; /* Max reqs from the same xprt */ +}; + + +#ifdef _KERNEL +/* + * Transport registration and thread pool creation. + */ +extern int svc_xprt_register(SVCMASTERXPRT *, int); +extern void svc_xprt_unregister(SVCMASTERXPRT *); +extern int svc_pool_create(struct svcpool_args *); +extern int svc_wait(int); +extern int svc_do_run(int); +#define SVCPSET_SHUTDOWN_PROC 1 +#define SVCPSET_UNREGISTER_PROC 2 +extern int svc_pool_control(int, int, void *); +#else /* _KERNEL */ +#ifdef __STDC__ +extern bool_t rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t, + char *(*)(char *), const xdrproc_t, const xdrproc_t, + const char *); + +/* + * Service registration + * + * svc_reg(xprt, prog, vers, dispatch, nconf) + * const SVCXPRT *xprt; + * const rpcprog_t prog; + * const rpcvers_t vers; + * const void (*dispatch)(); + * const struct netconfig *nconf; + */ +extern bool_t svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t, + void (*)(struct svc_req *, SVCXPRT *), + const struct netconfig *); + +/* + * Service authentication registration + * + * svc_auth_reg(cred_flavor, handler) + * int cred_flavor; + * enum auth_stat (*handler)(); + */ +extern int svc_auth_reg(int, enum auth_stat (*)()); + +/* + * Service un-registration + * + * svc_unreg(prog, vers) + * const rpcprog_t prog; + * const rpcvers_t vers; + */ +extern void svc_unreg(const rpcprog_t, const rpcvers_t); + +/* + * Transport registration/unregistration. + * + * xprt_register(xprt) + * const SVCXPRT *xprt; + * + * xprt_unregister(xprt) + * const SVCXPRT *xprt; + */ +extern void xprt_register(const SVCXPRT *); +extern void xprt_unregister(const SVCXPRT *); +#else /* __STDC__ */ +extern bool_t rpc_reg(); +extern bool_t svc_reg(); +extern bool_t svc_auth_reg(); +extern void svc_unreg(); +extern void xprt_register(); +extern void xprt_unregister(); +#endif /* __STDC__ */ +#endif /* _KERNEL */ + +#ifdef _KERNEL +/* + * Transport hold and release. + */ +extern void rpcmod_hold(queue_t *); +extern void rpcmod_release(queue_t *, mblk_t *, bool_t); +extern void mir_svc_hold(queue_t *); +extern void mir_svc_release(queue_t *, mblk_t *, bool_t); +#endif /* _KERNEL */ + +/* + * When the service routine is called, it must first check to see if it + * knows about the procedure; if not, it should call svcerr_noproc + * and return. If so, it should deserialize its arguments via + * SVC_GETARGS (defined above). If the deserialization does not work, + * svcerr_decode should be called followed by a return. Successful + * decoding of the arguments should be followed the execution of the + * procedure's code and a call to svc_sendreply. + * + * Also, if the service refuses to execute the procedure due to too- + * weak authentication parameters, svcerr_weakauth should be called. + * Note: do not confuse access-control failure with weak authentication! + * + * NB: In pure implementations of rpc, the caller always waits for a reply + * msg. This message is sent when svc_sendreply is called. + * Therefore pure service implementations should always call + * svc_sendreply even if the function logically returns void; use + * xdr.h - xdr_void for the xdr routine. HOWEVER, connectionful rpc allows + * for the abuse of pure rpc via batched calling or pipelining. In the + * case of a batched call, svc_sendreply should NOT be called since + * this would send a return message, which is what batching tries to avoid. + * It is the service/protocol writer's responsibility to know which calls are + * batched and which are not. Warning: responding to batch calls may + * deadlock the caller and server processes! + */ +#ifdef __STDC__ +extern bool_t svc_sendreply(const SVCXPRT *, const xdrproc_t, const caddr_t); +extern void svcerr_decode(const SVCXPRT *); +extern void svcerr_weakauth(const SVCXPRT *); +extern void svcerr_noproc(const SVCXPRT *); +extern void svcerr_progvers(const SVCXPRT *, const rpcvers_t, + const rpcvers_t); +extern void svcerr_auth(const SVCXPRT *, const enum auth_stat); +extern void svcerr_noprog(const SVCXPRT *); +extern void svcerr_systemerr(const SVCXPRT *); +extern void svcerr_badcred(const SVCXPRT *); +#else /* __STDC__ */ +extern bool_t svc_sendreply(); +extern void svcerr_decode(); +extern void svcerr_weakauth(); +extern void svcerr_noproc(); +extern void svcerr_progvers(); +extern void svcerr_auth(); +extern void svcerr_noprog(); +extern void svcerr_systemerr(); +extern void svcerr_badcred(); +#endif /* __STDC__ */ + +#ifdef _KERNEL +/* + * Kernel RPC functions. + */ +extern void svc_init(void); +extern void svc_cots_init(void); +extern void svc_clts_init(void); +extern void mt_kstat_init(void); +extern void mt_kstat_fini(void); +extern int svc_tli_kcreate(struct file *, uint_t, char *, + struct netbuf *, SVCMASTERXPRT **, + SVC_CALLOUT_TABLE *, + void (*closeproc)(const SVCMASTERXPRT *), + int, bool_t); +extern int svc_clts_kcreate(struct file *, uint_t, struct T_info_ack *, + SVCMASTERXPRT **); +extern int svc_cots_kcreate(struct file *, uint_t, struct T_info_ack *, + SVCMASTERXPRT **); +extern bool_t svc_queuereq(queue_t *, mblk_t *, bool_t); +extern void svc_queueclean(queue_t *); +extern void svc_queueclose(queue_t *); +extern int svc_reserve_thread(SVCXPRT *); +extern void svc_unreserve_thread(SVCXPRT *); +extern callb_cpr_t *svc_detach_thread(SVCXPRT *); + +/* + * For RDMA based kRPC. + * "rdma_xprt_record" is a reference to master transport handles + * in kRPC thread pools. This is an easy way of tracking and shuting + * down rdma based kRPC transports on demand. + * "rdma_xprt_group" is a list of RDMA based mster transport handles + * or records in a kRPC thread pool. + */ +typedef struct rdma_xprt_record rdma_xprt_record_t; +struct rdma_xprt_record { + int rtr_type; /* Type of rdma; IB/VI/RDDP */ + SVCMASTERXPRT *rtr_xprt_ptr; /* Ptr to master xprt handle */ + rdma_xprt_record_t *rtr_next; /* Ptr to next record */ +}; + +typedef struct { + int rtg_count; /* Number transport records */ + int rtg_poolid; /* Pool Id for this group */ + rdma_xprt_record_t *rtg_listhead; /* Head of the records list */ +} rdma_xprt_group_t; + +extern int svc_rdma_kcreate(char *, SVC_CALLOUT_TABLE *, int, + rdma_xprt_group_t *); +extern void svc_rdma_kstop(SVCMASTERXPRT *); +extern void svc_rdma_kdestroy(SVCMASTERXPRT *); +extern void rdma_stop(rdma_xprt_group_t *); + +/* + * GSS cleanup method. + */ +extern void rpc_gss_cleanup(SVCXPRT *); +#else /* _KERNEL */ +/* + * Lowest level dispatching -OR- who owns this process anyway. + * Somebody has to wait for incoming requests and then call the correct + * service routine. The routine svc_run does infinite waiting; i.e., + * svc_run never returns. + * Since another (co-existant) package may wish to selectively wait for + * incoming calls or other events outside of the rpc architecture, the + * routine svc_getreq_poll is provided. It must be passed pollfds, the + * "in-place" results of a poll call (see poll, section 2). + */ + +/* + * Global keeper of rpc service descriptors in use + * dynamic; must be inspected before each call to select or poll + */ +extern pollfd_t *svc_pollfd; +extern int svc_max_pollfd; +extern fd_set svc_fdset; +#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ + +/* + * A small program implemented by the svc_rpc implementation itself. + * Also see clnt.h for protocol numbers. + */ +#ifdef __STDC__ +extern void svc_getreq(int); +extern void svc_getreq_common(const int); +extern void svc_getreqset(fd_set *); /* takes fdset instead of int */ +extern void svc_getreq_poll(struct pollfd *, const int); +extern void svc_run(void); +extern void svc_exit(void); +#else /* __STDC__ */ +extern void rpctest_service(); +extern void svc_getreqset(); +extern void svc_getreq(); +extern void svc_getreq_common(); +extern void svc_getreqset(); /* takes fdset instead of int */ +extern void svc_getreq_poll(); +extern void svc_run(); +extern void svc_exit(); +#endif /* __STDC__ */ + +/* + * Functions used to manage user file descriptors + */ +typedef int svc_input_id_t; +typedef void (*svc_callback_t)(svc_input_id_t id, int fd, + unsigned int events, void* cookie); + +#ifdef __STDC__ +extern svc_input_id_t svc_add_input(int fd, unsigned int events, + svc_callback_t user_callback, + void* cookie); +extern int svc_remove_input(svc_input_id_t id); +#else /* __STDC__ */ +extern svc_input_id_t svc_add_input(); +extern int svc_remove_input(); +#endif + +/* + * These are the existing service side transport implementations. + * + * Transport independent svc_create routine. + */ +#ifdef __STDC__ +extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), + const rpcprog_t, const rpcvers_t, + const char *); + /* + * void (*dispatch)(); -- dispatch routine + * const rpcprog_t prognum; -- program number + * const rpcvers_t versnum; -- version number + * const char *nettype; -- network type + */ + +/* + * Generic server creation routine. It takes a netconfig structure + * instead of a nettype. + */ +extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), + const rpcprog_t, const rpcvers_t, + const struct netconfig *); + /* + * void (*dispatch)(); -- dispatch routine + * const rpcprog_t prognum; -- program number + * const rpcvers_t versnum; -- version number + * const struct netconfig *nconf; -- netconfig structure + */ + +/* + * Variant of svc_tp_create that accepts a binding address. + * If addr == NULL, this is the same as svc_tp_create(). + */ +extern SVCXPRT *svc_tp_create_addr(void (*)(struct svc_req *, SVCXPRT *), + const rpcprog_t, const rpcvers_t, + const struct netconfig *, + const struct netbuf *); + /* + * void (*dispatch)(); -- dispatch routine + * const rpcprog_t prognum; -- program number + * const rpcvers_t versnum; -- version number + * const struct netconfig *nconf; -- netconfig structure + * const struct netbuf *addr; -- address to bind + */ + +/* + * Generic TLI create routine + */ +extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, + const struct t_bind *, const uint_t, + const uint_t); + /* + * const int fd; -- connection end point + * const struct netconfig *nconf; -- netconfig structure + * const struct t_bind *bindaddr; -- local bind address + * const uint_t sendsz; -- max sendsize + * const uint_t recvsz; -- max recvsize + */ + +/* + * Connectionless and connectionful create routines. + */ +extern SVCXPRT *svc_vc_create(const int, const uint_t, const uint_t); + /* + * const int fd; -- open connection end point + * const uint_t sendsize; -- max send size + * const uint_t recvsize; -- max recv size + */ + +extern SVCXPRT *svc_dg_create(const int, const uint_t, const uint_t); + /* + * const int fd; -- open connection + * const uint_t sendsize; -- max send size + * const uint_t recvsize; -- max recv size + */ + +/* + * the routine takes any *open* TLI file + * descriptor as its first input and is used for open connections. + */ +extern SVCXPRT *svc_fd_create(const int, const uint_t, const uint_t); + /* + * const int fd; -- open connection end point + * const uint_t sendsize; -- max send size + * const uint_t recvsize; -- max recv size + */ + +/* + * Memory based rpc (for speed check and testing) + */ +extern SVCXPRT *svc_raw_create(void); + +/* + * Creation of service over doors transport. + */ +extern SVCXPRT *svc_door_create(void (*)(struct svc_req *, SVCXPRT *), + const rpcprog_t, const rpcvers_t, + const uint_t); + /* + * void (*dispatch)(); -- dispatch routine + * const rpcprog_t prognum; -- program number + * const rpcvers_t versnum; -- version number + * const uint_t sendsize; -- send buffer size + */ + +/* + * Service control interface + */ +extern bool_t svc_control(SVCXPRT *, const uint_t, void *); + /* + * SVCXPRT *svc; -- service to manipulate + * const uint_t req; -- request + * void *info; -- argument to request + */ + +/* + * svc_dg_enable_cache() enables the cache on dg transports. + */ +extern int svc_dg_enablecache(SVCXPRT *, const uint_t); +#else /* __STDC__ */ +extern int svc_create(); +extern SVCXPRT *svc_tp_create(); +extern SVCXPRT *svc_tli_create(); +extern SVCXPRT *svc_vc_create(); +extern SVCXPRT *svc_dg_create(); +extern SVCXPRT *svc_fd_create(); +extern SVCXPRT *svc_raw_create(); +extern SVCXPRT *svc_door_create(); +extern int svc_dg_enablecache(); +#endif /* __STDC__ */ + +extern boolean_t is_multilevel(rpcprog_t); + +#ifdef PORTMAP +/* For backward compatibility */ +#include +#endif /* PORTMAP */ + +/* + * For user level MT hot server functions + */ + +/* + * Different MT modes + */ +#define RPC_SVC_MT_NONE 0 /* default, single-threaded */ +#define RPC_SVC_MT_AUTO 1 /* automatic MT mode */ +#define RPC_SVC_MT_USER 2 /* user MT mode */ + +#ifdef __STDC__ +extern void svc_done(SVCXPRT *); +#else +extern void svc_done(); +#endif /* __STDC__ */ + +/* + * Obtaining local credentials. + */ +typedef struct __svc_local_cred_t { + uid_t euid; /* effective uid */ + gid_t egid; /* effective gid */ + uid_t ruid; /* real uid */ + gid_t rgid; /* real gid */ + pid_t pid; /* caller's pid, or -1 if not available */ +} svc_local_cred_t; + +#ifdef __STDC__ +struct ucred_s; +extern void svc_fd_negotiate_ucred(int); +extern int svc_getcallerucred(const SVCXPRT *, struct ucred_s **); +extern bool_t svc_get_local_cred(SVCXPRT *, svc_local_cred_t *); +#else +extern void svc_fd_negotiate_ucred(); +extern int svc_getcallerucred(); +extern bool_t svc_get_local_cred(); +#endif /* __STDC__ */ + +/* + * Private interfaces and structures for user level duplicate request caching. + * The interfaces and data structures are not committed and subject to + * change in future releases. Currently only intended for use by automountd. + */ +struct dupreq { + uint32_t dr_xid; + rpcproc_t dr_proc; + rpcvers_t dr_vers; + rpcprog_t dr_prog; + struct netbuf dr_addr; + struct netbuf dr_resp; + int dr_status; + time_t dr_time; + uint_t dr_hash; + struct dupreq *dr_next; + struct dupreq *dr_prev; + struct dupreq *dr_chain; + struct dupreq *dr_prevchain; +}; + +/* + * The fixedtime state is defined if we want to expand the routines to + * handle and encompass fixed size caches. + */ +#define DUPCACHE_FIXEDTIME 0 + +/* + * States of requests for duplicate request caching. + * These are the same as defined for the kernel. + */ +#define DUP_NEW 0x00 /* new entry */ +#define DUP_INPROGRESS 0x01 /* request already going */ +#define DUP_DONE 0x02 /* request done */ +#define DUP_DROP 0x03 /* request dropped */ +#define DUP_ERROR 0x04 /* error in dup req cache */ + +#ifdef __STDC__ +extern bool_t __svc_dupcache_init(void *, int, char **); +extern int __svc_dup(struct svc_req *, caddr_t *, uint_t *, char *); +extern int __svc_dupdone(struct svc_req *, caddr_t, uint_t, int, char *); +extern bool_t __svc_vc_dupcache_init(SVCXPRT *, void *, int); +extern int __svc_vc_dup(struct svc_req *, caddr_t *, uint_t *); +extern int __svc_vc_dupdone(struct svc_req *, caddr_t, uint_t, int); +#else +extern bool_t __svc_dupcache_init(); +extern int __svc_dup(); +extern int __svc_dupdone(); +extern bool_t __svc_vc_dupcache_init(); +extern int __svc_vc_dup(); +extern int __svc_vc_dupdone(); +#endif /* __STDC__ */ +#endif /* _KERNEL */ + +#ifdef _KERNEL +/* + * Private interfaces and structures for SVCXPRT cloning. + * The interfaces and data structures are not committed and subject to + * change in future releases. + */ +extern SVCXPRT *svc_clone_init(void); +extern void svc_clone_free(SVCXPRT *); +extern void svc_clone_link(SVCMASTERXPRT *, SVCXPRT *, SVCXPRT *); +extern void svc_clone_unlink(SVCXPRT *); + +/* Get cached preallocated cred */ +extern cred_t *svc_xprt_cred(SVCXPRT *); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_SVC_H */ diff --git a/illumos-x86_64/usr/include/rpc/svc_auth.h b/illumos-x86_64/usr/include/rpc/svc_auth.h new file mode 100644 index 00000000..754fbd28 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/svc_auth.h @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +#ifndef _RPC_SVC_AUTH_H +#define _RPC_SVC_AUTH_H + +/* + * svc_auth.h, Service side of rpc authentication. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Server side authenticator + */ +#ifdef _KERNEL +/* + * Copy of GSS parameters, needed for MT operation + */ +typedef struct { + bool_t established; + rpc_gss_service_t service; + uint_t qop_rcvd; + void *context; + uint_t seq_num; +} svc_rpc_gss_parms_t; + +/* + * sec_svc_control() commands + */ +#define RPC_SVC_SET_GSS_CALLBACK 1 /* set rpcsec_gss callback routine */ +extern bool_t sec_svc_control(uint_t, void *); + +/* + * Interface to server-side authentication flavors, may change on + * each request. + */ +typedef struct { + struct svc_auth_ops { + int (*svc_ah_wrap)(); + int (*svc_ah_unwrap)(); + } svc_ah_ops; + caddr_t svc_ah_private; + svc_rpc_gss_parms_t svc_gss_parms; + rpc_gss_rawcred_t raw_cred; +} SVCAUTH; + +#define SVCAUTH_GSSPARMS(auth) ((svc_rpc_gss_parms_t *)&(auth)->svc_gss_parms) + +/* + * Auth flavors can now apply a transformation in addition to simple XDR + * on the body of a call/response in ways that depend on the flavor being + * used. These interfaces provide a generic interface between the + * internal RPC frame and the auth flavor specific code to allow the + * auth flavor to encode (WRAP) or decode (UNWRAP) the body. + */ +#define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \ + ((*((auth)->svc_ah_ops.svc_ah_wrap))(auth, xdrs, xfunc, xwhere)) +#define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ + ((*((auth)->svc_ah_ops.svc_ah_unwrap))(auth, xdrs, xfunc, xwhere)) + +/* + * Server side authenticator + */ +extern enum auth_stat sec_svc_msg(struct svc_req *, struct rpc_msg *, + bool_t *); + +extern int sec_svc_getcred(struct svc_req *, cred_t *, caddr_t *, int *); + +#else + +extern enum auth_stat __gss_authenticate(struct svc_req *, struct rpc_msg *, + bool_t *); +extern enum auth_stat __authenticate(struct svc_req *, struct rpc_msg *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_SVC_AUTH_H */ diff --git a/illumos-x86_64/usr/include/rpc/svc_mt.h b/illumos-x86_64/usr/include/rpc/svc_mt.h new file mode 100644 index 00000000..d831388f --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/svc_mt.h @@ -0,0 +1,157 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _RPC_SVC_MT_H +#define _RPC_SVC_MT_H + +#include /* needed for mutex_t declaration */ + +/* + * Private service definitions + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SVC flags + */ +#define SVC_VERSQUIET 0x0001 /* keep quiet about version mismatch */ +#define SVC_DEFUNCT 0x0002 /* xprt is defunct, release asap */ +#define SVC_DGRAM 0x0004 /* datagram type */ +#define SVC_RENDEZVOUS 0x0008 /* rendezvous */ +#define SVC_CONNECTION 0x000c /* connection */ +#define SVC_DOOR 0x0010 /* door ipc */ +#define SVC_TYPE_MASK 0x001c /* type mask */ +#define SVC_FAILED 0x0020 /* send/receive failed, used for VC */ +#define SVC_ARGS_CHECK 0x0040 /* flag to check for argument completion */ + +#define svc_flags(xprt) (SVCEXT(xprt)->flags) +#define version_keepquiet(xprt) (svc_flags(xprt) & SVC_VERSQUIET) +#define svc_defunct(xprt) ((svc_flags(xprt) & SVC_DEFUNCT) ? TRUE : FALSE) +#define svc_failed(xprt) ((svc_flags(xprt) & SVC_FAILED) ? TRUE : FALSE) +#define svc_type(xprt) (svc_flags(xprt) & SVC_TYPE_MASK) +#define svc_send_mutex(xprt) (SVCEXT(xprt)->send_mutex) + + +/* + * Copy of GSS parameters, needed for MT operation + */ +typedef struct { + bool_t established; + rpc_gss_service_t service; + uint_t qop_rcvd; + void *context; + uint_t seq_num; +} svc_rpc_gss_parms_t; + +/* + * Interface to server-side authentication flavors, may vary with + * each request. + * + * NOTE: This structure is part of an interface, and must not change. + */ +typedef struct { + struct svc_auth_ops { + int (*svc_ah_wrap)(); + int (*svc_ah_unwrap)(); + } svc_ah_ops; + caddr_t svc_ah_private; + svc_rpc_gss_parms_t svc_gss_parms; + rpc_gss_rawcred_t raw_cred; +} SVCAUTH; + +/* + * The xp_p3 field the the service handle points to the SVCXPRT_EXT + * extension structure. + */ +typedef struct svcxprt_list_t { + struct svcxprt_list_t *next; + SVCXPRT *xprt; +} SVCXPRT_LIST; + +typedef struct svcxprt_ext_t { + int flags; /* VERSQUIET, DEFUNCT flag */ + SVCXPRT *parent; /* points to parent (NULL in parent) */ + + struct rpc_msg *msg; /* message */ + struct svc_req *req; /* request */ + char *cred_area; /* auth work area */ + int refcnt; /* number of parent references */ + SVCXPRT_LIST *my_xlist; /* list header for this copy */ + mutex_t send_mutex; /* for sequencing sends */ + SVCAUTH xp_auth; /* flavor of current request */ +} SVCXPRT_EXT; + +#define SVCEXT(xprt) ((SVCXPRT_EXT *)((xprt)->xp_p3)) +#define SVC_XP_AUTH(xprt) (SVCEXT(xprt)->xp_auth) + +#define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \ + ((*((auth)->svc_ah_ops.svc_ah_wrap))(auth, xdrs, xfunc, xwhere)) +#define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ + ((*((auth)->svc_ah_ops.svc_ah_unwrap))(auth, xdrs, xfunc, xwhere)) + +/* + * Global/module private data and functions + */ +extern SVCXPRT **svc_xports; +extern XDR **svc_xdrs; +extern int svc_mt_mode; +extern mutex_t svc_thr_mutex; +extern cond_t svc_thr_fdwait; +extern int svc_nfds; +extern int svc_nfds_set; +extern int svc_max_fd; +extern mutex_t svc_mutex; +extern mutex_t svc_exit_mutex; +extern int svc_pipe[2]; +extern bool_t svc_polling; + +SVCXPRT *svc_xprt_alloc(); +SVCXPRT *svc_dg_xprtcopy(); +SVCXPRT *svc_vc_xprtcopy(); +SVCXPRT *svc_fd_xprtcopy(); +SVCXPRT *svc_copy(); +void svc_xprt_free(); +void svc_xprt_destroy(); +void svc_dg_xprtfree(); +void svc_vc_xprtfree(); +void svc_fd_xprtfree(); +void svc_door_xprtfree(); +void svc_args_done(); +void _svc_dg_destroy_private(); +void _svc_vc_destroy_private(); +void _svc_destroy_private(); + +#define RPC_DOOR_DIR "/var/run/rpc_door" +#define RPC_DOOR_RENDEZVOUS "/var/run/rpc_door/rpc_%d.%d" + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_SVC_MT_H */ diff --git a/illumos-x86_64/usr/include/rpc/svc_soc.h b/illumos-x86_64/usr/include/rpc/svc_soc.h new file mode 100644 index 00000000..9c3215b0 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/svc_soc.h @@ -0,0 +1,115 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * svc_soc.h, Server-side remote procedure call interface. + * + * All the following declarations are only for backward compatibility + * with SUNOS 4.0. + */ + +#ifndef _RPC_SVC_SOC_H +#define _RPC_SVC_SOC_H + +#ifndef _KERNEL + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) ((struct sockaddr_in *)(x)->xp_rtaddr.buf) + +/* + * Service registration and unregistration. + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * svc_unregister(prog, vers); + */ +#ifdef __STDC__ +extern bool_t svc_register(SVCXPRT *, rpcprog_t, rpcvers_t, + void (*)(struct svc_req *, SVCXPRT *), int); +extern void svc_unregister(rpcprog_t, rpcvers_t); + +/* + * Memory based rpc for testing and timing. + */ +extern SVCXPRT *svcraw_create(void); + +/* + * Udp based rpc. For compatibility reasons + */ +extern SVCXPRT *svcudp_create(int); +extern SVCXPRT *svcudp_bufcreate(int, uint_t, uint_t); + +/* + * Tcp based rpc. + */ +extern SVCXPRT *svctcp_create(int, uint_t, uint_t); +extern SVCXPRT *svcfd_create(int, uint_t, uint_t); + +/* + * For connectionless kind of transport. Obsoleted by rpc_reg() + * + * registerrpc(prognum, versnum, procnum, progname, inproc, outproc) + * rpcprog_t prognum; + * rpcvers_t versnum; + * rpcproc_t procnum; + * char *(*progname)(); + * xdrproc_t inproc, outproc; + */ +extern int registerrpc(rpcprog_t, rpcvers_t, rpcproc_t, char *(*)(), + xdrproc_t, xdrproc_t); +#else /* __STDC__ */ +extern bool_t svc_register(); +extern void svc_unregister(); +extern SVCXPRT *svcraw_create(); +extern SVCXPRT *svcudp_create(); +extern SVCXPRT *svcudp_bufcreate(); +extern SVCXPRT *svctcp_create(); +extern SVCXPRT *svcfd_create(); +extern int registerrpc(); +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif +#endif /* _KERNEL */ + +#endif /* !_RPC_SVC_SOC_H */ diff --git a/illumos-x86_64/usr/include/rpc/types.h b/illumos-x86_64/usr/include/rpc/types.h new file mode 100644 index 00000000..2a692bdc --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/types.h @@ -0,0 +1,130 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +#ifndef _RPC_TYPES_H +#define _RPC_TYPES_H + +/* + * Rpc additions to + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int bool_t; +typedef int enum_t; + +/* + * The ulonglong_t type was introduced to workaround an rpcgen bug + * that has been fixed, this next typedef will be removed in a future release. + * Do *NOT* use! + */ +typedef u_longlong_t ulonglong_t; + +#if defined(_LP64) +typedef uint32_t rpcprog_t; +typedef uint32_t rpcvers_t; +typedef uint32_t rpcproc_t; +typedef uint32_t rpcprot_t; +typedef uint32_t rpcport_t; +typedef int32_t rpc_inline_t; +#else +typedef unsigned long rpcprog_t; +typedef unsigned long rpcvers_t; +typedef unsigned long rpcproc_t; +typedef unsigned long rpcprot_t; +typedef unsigned long rpcport_t; +typedef long rpc_inline_t; +#endif + + +#define __dontcare__ -1 + +#ifndef FALSE +#define FALSE (0) +#endif + +#ifndef TRUE +#define TRUE (1) +#endif + +#ifndef _KERNEL +#define mem_alloc(bsize) malloc(bsize) +#define mem_free(ptr, bsize) free(ptr) +#else +#include /* XXX */ + +#define mem_alloc(bsize) kmem_alloc(bsize, KM_SLEEP) +#define mem_free(ptr, bsize) kmem_free(ptr, bsize) + +extern const char *rpc_tpiprim2name(uint_t prim); +extern const char *rpc_tpierr2name(uint_t err); + +#if defined(DEBUG) && !defined(RPCDEBUG) +#define RPCDEBUG +#endif + +#ifdef RPCDEBUG +extern uint_t rpclog; + +#define RPCLOG(A, B, C) \ + ((void)((rpclog) && (rpclog & (A)) && (printf((B), (C)), TRUE))) +#define RPCLOG0(A, B) \ + ((void)((rpclog) && (rpclog & (A)) && (printf(B), TRUE))) +#else +#define RPCLOG(A, B, C) +#define RPCLOG0(A, B) +#endif + +#endif + +/* messaging stuff. */ +#ifndef _KERNEL +#ifdef __STDC__ +extern const char __nsl_dom[]; +#else +extern char __nsl_dom[]; +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _RPC_TYPES_H */ diff --git a/illumos-x86_64/usr/include/rpc/xdr.h b/illumos-x86_64/usr/include/rpc/xdr.h new file mode 100644 index 00000000..e6d0a054 --- /dev/null +++ b/illumos-x86_64/usr/include/rpc/xdr.h @@ -0,0 +1,615 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Portions of this source code were derived from Berkeley + * 4.3 BSD under license from the Regents of the University of + * California. + */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + */ + +#ifndef _RPC_XDR_H +#define _RPC_XDR_H + +#include /* For all ntoh* and hton*() kind of macros */ +#include /* For all ntoh* and hton*() kind of macros */ +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) +#include /* defines FILE *, used in ANSI C function prototypes */ +#else /* _KERNEL */ +#include +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * XDR provides a conventional way for converting between C data + * types and an external bit-string representation. Library supplied + * routines provide for the conversion on built-in C data types. These + * routines and utility routines defined here are used to help implement + * a type encode/decode routine for each user-defined type. + * + * Each data type provides a single procedure which takes two arguments: + * + * bool_t + * xdrproc(xdrs, argresp) + * XDR *xdrs; + * *argresp; + * + * xdrs is an instance of a XDR handle, to which or from which the data + * type is to be converted. argresp is a pointer to the structure to be + * converted. The XDR handle contains an operation field which indicates + * which of the operations (ENCODE, DECODE * or FREE) is to be performed. + * + * XDR_DECODE may allocate space if the pointer argresp is null. This + * data can be freed with the XDR_FREE operation. + * + * We write only one procedure per data type to make it easy + * to keep the encode and decode procedures for a data type consistent. + * In many cases the same code performs all operations on a user defined type, + * because all the hard work is done in the component type routines. + * decode as a series of calls on the nested data types. + */ + +/* + * Xdr operations. XDR_ENCODE causes the type to be encoded into the + * stream. XDR_DECODE causes the type to be extracted from the stream. + * XDR_FREE can be used to release the space allocated by an XDR_DECODE + * request. + */ +enum xdr_op { + XDR_ENCODE = 0, + XDR_DECODE = 1, + XDR_FREE = 2 +}; + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) +#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ + * BYTES_PER_XDR_UNIT) + +/* + * The XDR handle. + * Contains operation which is being applied to the stream, + * an operations vector for the paticular implementation (e.g. see xdr_mem.c), + * and two private fields for the use of the particular impelementation. + * + * PSARC 2003/523 Contract Private Interface + * XDR + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +typedef struct XDR { + enum xdr_op x_op; /* operation; fast additional param */ + struct xdr_ops *x_ops; + caddr_t x_public; /* users' data */ + caddr_t x_private; /* pointer to private data */ + caddr_t x_base; /* private used for position info */ + int x_handy; /* extra private word */ +} XDR; + +/* + * PSARC 2003/523 Contract Private Interface + * xdr_ops + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +struct xdr_ops { +#ifdef __STDC__ +#if !defined(_KERNEL) + bool_t (*x_getlong)(struct XDR *, long *); + /* get a long from underlying stream */ + bool_t (*x_putlong)(struct XDR *, long *); + /* put a long to " */ +#endif /* KERNEL */ + bool_t (*x_getbytes)(struct XDR *, caddr_t, int); + /* get some bytes from " */ + bool_t (*x_putbytes)(struct XDR *, caddr_t, int); + /* put some bytes to " */ + uint_t (*x_getpostn)(struct XDR *); + /* returns bytes off from beginning */ + bool_t (*x_setpostn)(struct XDR *, uint_t); + /* lets you reposition the stream */ + rpc_inline_t *(*x_inline)(struct XDR *, int); + /* buf quick ptr to buffered data */ + void (*x_destroy)(struct XDR *); + /* free privates of this xdr_stream */ + bool_t (*x_control)(struct XDR *, int, void *); +#if defined(_LP64) || defined(_KERNEL) + bool_t (*x_getint32)(struct XDR *, int32_t *); + /* get a int from underlying stream */ + bool_t (*x_putint32)(struct XDR *, int32_t *); + /* put an int to " */ +#endif /* _LP64 || _KERNEL */ +#else +#if !defined(_KERNEL) + bool_t (*x_getlong)(); /* get a long from underlying stream */ + bool_t (*x_putlong)(); /* put a long to " */ +#endif /* KERNEL */ + bool_t (*x_getbytes)(); /* get some bytes from " */ + bool_t (*x_putbytes)(); /* put some bytes to " */ + uint_t (*x_getpostn)(); /* returns bytes off from beginning */ + bool_t (*x_setpostn)(); /* lets you reposition the stream */ + rpc_inline_t *(*x_inline)(); + /* buf quick ptr to buffered data */ + void (*x_destroy)(); /* free privates of this xdr_stream */ + bool_t (*x_control)(); +#if defined(_LP64) || defined(_KERNEL) + bool_t (*x_getint32)(); + bool_t (*x_putint32)(); +#endif /* _LP64 || defined(_KERNEL) */ +#endif +}; + +/* + * Operations defined on a XDR handle + * + * XDR *xdrs; + * long *longp; + * caddr_t addr; + * uint_t len; + * uint_t pos; + */ +#if !defined(_KERNEL) +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#endif /* KERNEL */ + + +#if !defined(_LP64) && !defined(_KERNEL) + +/* + * For binary compatability on ILP32 we do not change the shape + * of the XDR structure and the GET/PUTINT32 functions just use + * the get/putlong vectors which operate on identically-sized + * units of data. + */ + +#define XDR_GETINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, (long *)int32p) +#define xdr_getint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, (long *)int32p) + +#define XDR_PUTINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, (long *)int32p) +#define xdr_putint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, (long *)int32p) + +#else /* !_LP64 && !_KERNEL */ + +#define XDR_GETINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) +#define xdr_getint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) + +#define XDR_PUTINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) +#define xdr_putint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) + +#endif /* !_LP64 && !_KERNEL */ + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) +#define xdr_destroy(xdrs) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) + +#define XDR_CONTROL(xdrs, req, op) \ + (*(xdrs)->x_ops->x_control)(xdrs, req, op) +#define xdr_control(xdrs, req, op) \ + (*(xdrs)->x_ops->x_control)(xdrs, req, op) + +/* + * Support struct for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * a entry with a null procedure pointer. The xdr_union routine gets + * the discriminant value and then searches the array of structures + * for a matching value. If a match is found the associated xdr routine + * is called to handle that part of the union. If there is + * no match, then a default routine may be called. + * If there is no match and no default routine it is an error. + */ + + +/* + * A xdrproc_t exists for each data type which is to be encoded or decoded. + * + * The second argument to the xdrproc_t is a pointer to an opaque pointer. + * The opaque pointer generally points to a structure of the data type + * to be decoded. If this pointer is 0, then the type routines should + * allocate dynamic storage of the appropriate size and return it. + * bool_t (*xdrproc_t)(XDR *, void *); + */ +#ifdef __cplusplus +typedef bool_t (*xdrproc_t)(XDR *, void *); +#else +#ifdef __STDC__ +typedef bool_t (*xdrproc_t)(); /* For Backward compatibility */ +#else +typedef bool_t (*xdrproc_t)(); +#endif +#endif + +#define NULL_xdrproc_t ((xdrproc_t)0) + +#if defined(_LP64) +#define xdr_rpcvers(xdrs, versp) xdr_u_int(xdrs, versp) +#define xdr_rpcprog(xdrs, progp) xdr_u_int(xdrs, progp) +#define xdr_rpcproc(xdrs, procp) xdr_u_int(xdrs, procp) +#define xdr_rpcprot(xdrs, protp) xdr_u_int(xdrs, protp) +#define xdr_rpcport(xdrs, portp) xdr_u_int(xdrs, portp) +#else +#define xdr_rpcvers(xdrs, versp) xdr_u_long(xdrs, versp) +#define xdr_rpcprog(xdrs, progp) xdr_u_long(xdrs, progp) +#define xdr_rpcproc(xdrs, procp) xdr_u_long(xdrs, procp) +#define xdr_rpcprot(xdrs, protp) xdr_u_long(xdrs, protp) +#define xdr_rpcport(xdrs, portp) xdr_u_long(xdrs, portp) +#endif + +struct xdr_discrim { + int value; + xdrproc_t proc; +}; + +/* + * In-line routines for fast encode/decode of primitve data types. + * Caveat emptor: these use single memory cycles to get the + * data from the underlying buffer, and will fail to operate + * properly if the data is not aligned. The standard way to use these + * is to say: + * if ((buf = XDR_INLINE(xdrs, count)) == NULL) + * return (FALSE); + * <<< macro calls >>> + * where ``count'' is the number of bytes of data occupied + * by the primitive data types. + * + * N.B. and frozen for all time: each data type here uses 4 bytes + * of external representation. + */ + +#define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t)*(buf)++)) +#define IXDR_PUT_INT32(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)v)) +#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) +#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) + +#if !defined(_KERNEL) && !defined(_LP64) + +#define IXDR_GET_LONG(buf) ((long)ntohl((ulong_t)*(buf)++)) +#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((ulong_t)v)) +#define IXDR_GET_U_LONG(buf) ((ulong_t)IXDR_GET_LONG(buf)) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_SHORT(buf) ((ushort_t)IXDR_GET_LONG(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) + +#else + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_INT32(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_INT32(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_INT32(buf)) +#define IXDR_GET_U_SHORT(buf) ((ushort_t)IXDR_GET_INT32(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_INT32((buf), ((int)(v))) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_INT32((buf), ((int)(v))) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_INT32((buf), ((int)(v))) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_INT32((buf), ((int)(v))) + +#endif + +#ifndef _LITTLE_ENDIAN +#define IXDR_GET_HYPER(buf, v) { \ + *((int32_t *)(&v)) = ntohl(*(uint32_t *)buf++); \ + *((int32_t *)(((char *)&v) + BYTES_PER_XDR_UNIT)) \ + = ntohl(*(uint32_t *)buf++); \ + } +#define IXDR_PUT_HYPER(buf, v) { \ + *(buf)++ = (int32_t)htonl(*(uint32_t *) \ + ((char *)&v)); \ + *(buf)++ = \ + (int32_t)htonl(*(uint32_t *)(((char *)&v) \ + + BYTES_PER_XDR_UNIT)); \ + } +#else + +#define IXDR_GET_HYPER(buf, v) { \ + *((int32_t *)(((char *)&v) + \ + BYTES_PER_XDR_UNIT)) \ + = ntohl(*(uint32_t *)buf++); \ + *((int32_t *)(&v)) = \ + ntohl(*(uint32_t *)buf++); \ + } + +#define IXDR_PUT_HYPER(buf, v) { \ + *(buf)++ = \ + (int32_t)htonl(*(uint32_t *)(((char *)&v) + \ + BYTES_PER_XDR_UNIT)); \ + *(buf)++ = \ + (int32_t)htonl(*(uint32_t *)((char *)&v)); \ + } +#endif +#define IXDR_GET_U_HYPER(buf, v) IXDR_GET_HYPER(buf, v) +#define IXDR_PUT_U_HYPER(buf, v) IXDR_PUT_HYPER(buf, v) + + +/* + * These are the "generic" xdr routines. + */ +#ifdef __STDC__ +extern bool_t xdr_void(void); +extern bool_t xdr_int(XDR *, int *); +extern bool_t xdr_u_int(XDR *, uint_t *); +extern bool_t xdr_long(XDR *, long *); +extern bool_t xdr_u_long(XDR *, ulong_t *); +extern bool_t xdr_short(XDR *, short *); +extern bool_t xdr_u_short(XDR *, ushort_t *); +extern bool_t xdr_bool(XDR *, bool_t *); +extern bool_t xdr_enum(XDR *, enum_t *); +extern bool_t xdr_array(XDR *, caddr_t *, uint_t *, const uint_t, + const uint_t, const xdrproc_t); +extern bool_t xdr_bytes(XDR *, char **, uint_t *, const uint_t); +extern bool_t xdr_opaque(XDR *, caddr_t, const uint_t); +extern bool_t xdr_string(XDR *, char **, const uint_t); +extern bool_t xdr_union(XDR *, enum_t *, char *, + const struct xdr_discrim *, const xdrproc_t); +extern bool_t xdr_vector(XDR *, char *, const uint_t, const uint_t, + const xdrproc_t); +extern unsigned int xdr_sizeof(xdrproc_t, void *); + +extern bool_t xdr_hyper(XDR *, longlong_t *); +extern bool_t xdr_longlong_t(XDR *, longlong_t *); +extern bool_t xdr_u_hyper(XDR *, u_longlong_t *); +extern bool_t xdr_u_longlong_t(XDR *, u_longlong_t *); + +extern bool_t xdr_char(XDR *, char *); +extern bool_t xdr_u_char(XDR *, uchar_t *); +extern bool_t xdr_wrapstring(XDR *, char **); +extern bool_t xdr_reference(XDR *, caddr_t *, uint_t, const xdrproc_t); +extern bool_t xdr_pointer(XDR *, char **, uint_t, const xdrproc_t); +extern void xdr_free(xdrproc_t, char *); +extern bool_t xdr_time_t(XDR *, time_t *); + +extern bool_t xdr_int8_t(XDR *, int8_t *); +extern bool_t xdr_uint8_t(XDR *, uint8_t *); +extern bool_t xdr_int16_t(XDR *, int16_t *); +extern bool_t xdr_uint16_t(XDR *, uint16_t *); +extern bool_t xdr_int32_t(XDR *, int32_t *); +extern bool_t xdr_uint32_t(XDR *, uint32_t *); +#if defined(_INT64_TYPE) +extern bool_t xdr_int64_t(XDR *, int64_t *); +extern bool_t xdr_uint64_t(XDR *, uint64_t *); +#endif + +#ifndef _KERNEL +extern bool_t xdr_float(XDR *, float *); +extern bool_t xdr_double(XDR *, double *); +extern bool_t xdr_quadruple(XDR *, long double *); +#endif /* !_KERNEL */ +#else +extern bool_t xdr_void(); +extern bool_t xdr_int(); +extern bool_t xdr_u_int(); +extern bool_t xdr_long(); +extern bool_t xdr_u_long(); +extern bool_t xdr_short(); +extern bool_t xdr_u_short(); +extern bool_t xdr_bool(); +extern bool_t xdr_enum(); +extern bool_t xdr_array(); +extern bool_t xdr_bytes(); +extern bool_t xdr_opaque(); +extern bool_t xdr_string(); +extern bool_t xdr_union(); +extern bool_t xdr_vector(); + +extern bool_t xdr_hyper(); +extern bool_t xdr_longlong_t(); +extern bool_t xdr_u_hyper(); +extern bool_t xdr_u_longlong_t(); +extern bool_t xdr_char(); +extern bool_t xdr_u_char(); +extern bool_t xdr_reference(); +extern bool_t xdr_pointer(); +extern void xdr_free(); +extern bool_t xdr_wrapstring(); +extern bool_t xdr_time_t(); + +extern bool_t xdr_int8_t(); +extern bool_t xdr_uint8_t(); +extern bool_t xdr_int16_t(); +extern bool_t xdr_uint16_t(); +extern bool_t xdr_int32_t(); +extern bool_t xdr_uint32_t(); +#if defined(_INT64_TYPE) +extern bool_t xdr_int64_t(); +extern bool_t xdr_uint64_t(); +#endif + +#ifndef _KERNEL +extern bool_t xdr_float(); +extern bool_t xdr_double(); +extern bool_t xdr_quadruple(); +#endif /* !_KERNEL */ +#endif + +/* + * Common opaque bytes objects used by many rpc protocols; + * declared here due to commonality. + */ +#define MAX_NETOBJ_SZ 1024 +struct netobj { + uint_t n_len; + char *n_bytes; +}; +typedef struct netobj netobj; + +#ifdef __STDC__ +extern bool_t xdr_netobj(XDR *, netobj *); +#else +extern bool_t xdr_netobj(); +#endif + +/* + * These are XDR control operators + */ + +#define XDR_GET_BYTES_AVAIL 1 + +struct xdr_bytesrec { + bool_t xc_is_last_record; + size_t xc_num_avail; +}; + +typedef struct xdr_bytesrec xdr_bytesrec; + +/* + * These are the request arguments to XDR_CONTROL. + * + * XDR_PEEK - returns the contents of the next XDR unit on the XDR stream. + * XDR_SKIPBYTES - skips the next N bytes in the XDR stream. + * XDR_RDMAGET - for xdr implementation over RDMA, gets private flags from + * the XDR stream being moved over RDMA + * XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in + * the XDR stream moving over RDMA. + */ +#ifdef _KERNEL +#define XDR_PEEK 2 +#define XDR_SKIPBYTES 3 +#define XDR_RDMA_GET_FLAGS 4 +#define XDR_RDMA_SET_FLAGS 5 +#define XDR_RDMA_ADD_CHUNK 6 +#define XDR_RDMA_GET_CHUNK_LEN 7 +#define XDR_RDMA_SET_WLIST 8 +#define XDR_RDMA_GET_WLIST 9 +#define XDR_RDMA_GET_WCINFO 10 +#define XDR_RDMA_GET_RLIST 11 +#endif + +/* + * These are the public routines for the various implementations of + * xdr streams. + */ +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) +#ifdef __STDC__ +extern void xdrmem_create(XDR *, const caddr_t, const uint_t, const enum +xdr_op); + /* XDR using memory buffers */ +extern void xdrstdio_create(XDR *, FILE *, const enum xdr_op); +/* XDR using stdio library */ +extern void xdrrec_create(XDR *, const uint_t, const uint_t, const caddr_t, +int (*) (void *, caddr_t, int), int (*) (void *, caddr_t, int)); +/* XDR pseudo records for tcp */ +extern bool_t xdrrec_endofrecord(XDR *, bool_t); +/* make end of xdr record */ +extern bool_t xdrrec_skiprecord(XDR *); +/* move to beginning of next record */ +extern bool_t xdrrec_eof(XDR *); +extern uint_t xdrrec_readbytes(XDR *, caddr_t, uint_t); +/* true if no more input */ +#else +extern void xdrmem_create(); +extern void xdrstdio_create(); +extern void xdrrec_create(); +extern bool_t xdrrec_endofrecord(); +extern bool_t xdrrec_skiprecord(); +extern bool_t xdrrec_eof(); +extern uint_t xdrrec_readbytes(); +#endif +#else + +#define DLEN(mp) (mp->b_cont ? msgdsize(mp) : (mp->b_wptr - mp->b_rptr)) + +extern void xdrmem_create(XDR *, caddr_t, uint_t, enum xdr_op); +extern void xdrmblk_init(XDR *, mblk_t *, enum xdr_op, int); +extern bool_t xdrmblk_getmblk(XDR *, mblk_t **, uint_t *); +extern bool_t xdrmblk_putmblk(XDR *, mblk_t *, uint_t); +extern bool_t xdrmblk_putmblk_raw(XDR *, mblk_t *); +extern struct xdr_ops xdrmblk_ops; +extern struct xdr_ops xdrrdmablk_ops; +extern struct xdr_ops xdrrdma_ops; + +struct rpc_msg; +extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); +extern bool_t xdr_replymsg_body(XDR *, struct rpc_msg *); +extern bool_t xdr_replymsg_hdr(XDR *, struct rpc_msg *); + +#endif /* !_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_XDR_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/autofs_prot.h b/illumos-x86_64/usr/include/rpcsvc/autofs_prot.h new file mode 100644 index 00000000..6cc25ce9 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/autofs_prot.h @@ -0,0 +1,237 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _AUTOFS_PROT_H_RPCGEN +#define _AUTOFS_PROT_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include +#include +#include +#include + +#define xdr_dev_t xdr_u_int +#define xdr_bool_t xdr_bool + +#define AUTOFS_MAXPATHLEN 1024 +#define AUTOFS_MAXCOMPONENTLEN 255 +#define AUTOFS_MAXOPTSLEN 1024 +#define AUTOFS_DAEMONCOOKIE 100000 + +enum autofs_stat { + AUTOFS_ACTION = 0, + AUTOFS_DONE = 1 +}; +typedef enum autofs_stat autofs_stat; + +enum autofs_action { + AUTOFS_MOUNT_RQ = 0, + AUTOFS_LINK_RQ = 1, + AUTOFS_NONE = 2 +}; +typedef enum autofs_action autofs_action; + +enum autofs_res { + AUTOFS_OK = 0, + AUTOFS_NOENT = 2, + AUTOFS_ECOMM = 5, + AUTOFS_NOMEM = 12, + AUTOFS_NOTDIR = 20, + AUTOFS_SHUTDOWN = 1000 +}; +typedef enum autofs_res autofs_res; + +struct autofs_lookupargs { + char *map; + char *path; + char *name; + char *subdir; + char *opts; + bool_t isdirect; + uid_t uid; +}; +typedef struct autofs_lookupargs autofs_lookupargs; + +struct linka { + char *dir; + char *link; +}; +typedef struct linka linka; + +struct autofs_args { + struct netbuf addr; + char *path; + char *opts; + char *map; + char *subdir; + char *key; + int mount_to; + int rpc_to; + int direct; +}; +typedef struct autofs_args autofs_args; +#ifdef _SYSCALL32 +/* + * This is an LP64 representation of the ILP32 autofs_args data structure + * for use by autofs_mount which may receive the data structure "raw" + * from a 32-bit program without being processed by XDR. rpcgen doesn't + * need to see this structure since RPC/XDR only deals with the "native" + * version of autofs_args. If this isn't hidden from rpcgen then it will + * insist on generating unnecessary code to deal with it. + */ +struct autofs_args32 { + struct netbuf32 addr; /* daemon address */ + caddr32_t path; /* autofs mountpoint */ + caddr32_t opts; /* default mount options */ + caddr32_t map; /* name of map */ + caddr32_t subdir; /* subdir within map */ + caddr32_t key; /* used in direct mounts */ + int32_t mount_to; /* time in sec the fs is to remain */ + /* mounted after last reference */ + int32_t rpc_to; /* timeout for rpc calls */ + int32_t direct; /* 1 = direct mount */ +}; +#endif /* _SYSCALL32 */ + +struct action_list_entry { + autofs_action action; + union { + struct mounta mounta; + struct linka linka; + } action_list_entry_u; +}; +typedef struct action_list_entry action_list_entry; + +struct action_list { + action_list_entry action; + struct action_list *next; +}; +typedef struct action_list action_list; + +struct mount_result_type { + autofs_stat status; + union { + action_list *list; + int error; + } mount_result_type_u; +}; +typedef struct mount_result_type mount_result_type; + +struct autofs_mountres { + mount_result_type mr_type; + int mr_verbose; +}; +typedef struct autofs_mountres autofs_mountres; + +struct lookup_result_type { + autofs_action action; + union { + struct linka lt_linka; + } lookup_result_type_u; +}; +typedef struct lookup_result_type lookup_result_type; + +struct autofs_lookupres { + enum autofs_res lu_res; + lookup_result_type lu_type; + int lu_verbose; +}; +typedef struct autofs_lookupres autofs_lookupres; + +struct umntrequest { + bool_t isdirect; + char *mntresource; + char *mntpnt; + char *fstype; + char *mntopts; + struct umntrequest *next; +}; +typedef struct umntrequest umntrequest; + +struct umntres { + int status; +}; +typedef struct umntres umntres; + +struct autofs_rddirargs { + char *rda_map; + u_int rda_offset; + u_int rda_count; + uid_t uid; +}; +typedef struct autofs_rddirargs autofs_rddirargs; + +struct autofsrddir { + u_int rddir_offset; + u_int rddir_size; + bool_t rddir_eof; + struct dirent64 *rddir_entries; +}; +typedef struct autofsrddir autofsrddir; + +struct autofs_rddirres { + enum autofs_res rd_status; + u_int rd_bufsize; + struct autofsrddir rd_rddir; +}; +typedef struct autofs_rddirres autofs_rddirres; + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_autofs_stat(XDR *, autofs_stat*); +extern bool_t xdr_autofs_action(XDR *, autofs_action*); +extern bool_t xdr_autofs_res(XDR *, autofs_res*); +extern bool_t xdr_autofs_lookupargs(XDR *, autofs_lookupargs*); +extern bool_t xdr_linka(XDR *, linka*); +extern bool_t xdr_autofs_args(XDR *, autofs_args*); +extern bool_t xdr_action_list_entry(XDR *, action_list_entry*); +extern bool_t xdr_action_list(XDR *, action_list*); +extern bool_t xdr_mount_result_type(XDR *, mount_result_type*); +extern bool_t xdr_autofs_mountres(XDR *, autofs_mountres*); +extern bool_t xdr_lookup_result_type(XDR *, lookup_result_type*); +extern bool_t xdr_autofs_lookupres(XDR *, autofs_lookupres*); +extern bool_t xdr_umntrequest(XDR *, umntrequest*); +extern bool_t xdr_umntres(XDR *, umntres*); +extern bool_t xdr_autofs_rddirargs(XDR *, autofs_rddirargs*); +extern bool_t xdr_autofsrddir(XDR *, autofsrddir*); +extern bool_t xdr_autofs_rddirres(XDR *, autofs_rddirres*); + +#else /* K&R C */ +extern bool_t xdr_autofs_stat(); +extern bool_t xdr_autofs_action(); +extern bool_t xdr_autofs_res(); +extern bool_t xdr_autofs_lookupargs(); +extern bool_t xdr_linka(); +extern bool_t xdr_autofs_args(); +extern bool_t xdr_action_list_entry(); +extern bool_t xdr_action_list(); +extern bool_t xdr_mount_result_type(); +extern bool_t xdr_autofs_mountres(); +extern bool_t xdr_lookup_result_type(); +extern bool_t xdr_autofs_lookupres(); +extern bool_t xdr_umntrequest(); +extern bool_t xdr_umntres(); +extern bool_t xdr_autofs_rddirargs(); +extern bool_t xdr_autofsrddir(); +extern bool_t xdr_autofs_rddirres(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_AUTOFS_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/autofs_prot.x b/illumos-x86_64/usr/include/rpcsvc/autofs_prot.x new file mode 100644 index 00000000..ba7f2855 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/autofs_prot.x @@ -0,0 +1,250 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +%/* +% * Copyright 2007 Sun Microsystems, Inc. All rights reserved. +% * Use is subject to license terms. +% */ +% +%#include +%#include +%#include +%#include +% +%#define xdr_dev_t xdr_u_int +%#define xdr_bool_t xdr_bool +% +/* + * Autofs/automountd communication protocol. + */ + +const AUTOFS_MAXPATHLEN = 1024; +const AUTOFS_MAXCOMPONENTLEN = 255; +const AUTOFS_MAXOPTSLEN = 1024; +const AUTOFS_DAEMONCOOKIE = 100000; + +/* + * Action Status + * Automountd replies to autofs indicating whether the operation is done, + * or further action needs to be taken by autofs. + */ +enum autofs_stat { + AUTOFS_ACTION=0, /* list of actions included */ + AUTOFS_DONE=1 /* no further action required by kernel */ +}; + +/* + * Used by autofs to either create a link, or mount a new filesystem. + */ +enum autofs_action { + AUTOFS_MOUNT_RQ=0, /* mount request */ + AUTOFS_LINK_RQ=1, /* link create */ + AUTOFS_NONE=2 /* no action */ +}; + +enum autofs_res { + AUTOFS_OK=0, + AUTOFS_NOENT=2, + AUTOFS_ECOMM=5, + AUTOFS_NOMEM=12, + AUTOFS_NOTDIR=20, + AUTOFS_SHUTDOWN=1000 +}; + +/* + * Lookup/Mount request. + * Argument structure passed to both autofs_lookup() and autofs_mount(). + * autofs_lookup(): + * Query automountd if 'path/subdir/name' exists in 'map' + * autofs_mount(): + * Request automountd to mount the map entry associated with + * 'path/subdir/name' in 'map' given 'opts' options. + */ +struct autofs_lookupargs { + string map; /* context or map name */ + string path; /* mountpoint */ + string name; /* entry we're looking for */ + string subdir; /* subdir within map */ + string opts; + bool_t isdirect; /* direct mountpoint? */ + uid_t uid; /* uid of caller */ +}; + +/* + * Symbolic link information. + */ +struct linka { + string dir; /* original name */ + string link; /* link (new) name */ +}; + +/* + * We don't define netbuf in RPCL, we include the header file that + * includes it, and implement the xdr function ourselves. + */ + +/* + * Autofs Mount specific information - used to mount a new + * autofs filesystem. + */ +struct autofs_args { + struct netbuf addr; /* daemon address */ + string path; /* autofs mountpoint */ + string opts; /* default mount options */ + string map; /* name of map */ + string subdir; /* subdir within map */ + string key; /* used in direct mounts only */ + int mount_to; /* time in sec the fs is to remain */ + /* mounted after last reference */ + int rpc_to; /* timeout for rpc calls */ + int direct; /* 1 = direct mount */ +}; + +%#ifdef _SYSCALL32 +%/* +% * This is an LP64 representation of the ILP32 autofs_args data structure +% * for use by autofs_mount which may receive the data structure "raw" +% * from a 32-bit program without being processed by XDR. rpcgen doesn't +% * need to see this structure since RPC/XDR only deals with the "native" +% * version of autofs_args. If this isn't hidden from rpcgen then it will +% * insist on generating unnecessary code to deal with it. +% */ +%struct autofs_args32 { +% struct netbuf32 addr; /* daemon address */ +% caddr32_t path; /* autofs mountpoint */ +% caddr32_t opts; /* default mount options */ +% caddr32_t map; /* name of map */ +% caddr32_t subdir; /* subdir within map */ +% caddr32_t key; /* used in direct mounts */ +% int32_t mount_to; /* time in sec the fs is to remain */ +% /* mounted after last reference */ +% int32_t rpc_to; /* timeout for rpc calls */ +% int32_t direct; /* 1 = direct mount */ +%}; +%#endif /* _SYSCALL32 */ + +/* + * Contains the necessary information to notify autofs to + * perfom either a new mount or create a symbolic link. + */ +union action_list_entry switch (autofs_action action) { +case AUTOFS_MOUNT_RQ: + struct mounta mounta; +case AUTOFS_LINK_RQ: + struct linka linka; +default: + void; +}; + +/* + * List of actions that need to be performed by autofs to + * finish the requested operation. + */ +struct action_list { + action_list_entry action; + action_list *next; +}; + +union mount_result_type switch (autofs_stat status) { +case AUTOFS_ACTION: + action_list *list; +case AUTOFS_DONE: + int error; +default: + void; +}; + +/* + * Result from mount operation. + */ +struct autofs_mountres { + mount_result_type mr_type; + int mr_verbose; +}; + +union lookup_result_type switch (autofs_action action) { +case AUTOFS_LINK_RQ: + struct linka lt_linka; +case AUTOFS_MOUNT_RQ: + void; +default: + void; +}; + +/* + * Result from lookup operation. + */ +struct autofs_lookupres { + enum autofs_res lu_res; + lookup_result_type lu_type; + int lu_verbose; +}; + +/* + * Unmount operation request + * Automountd will issue unmount system call for the + * given fstype on the given mntpnt. + */ + +struct umntrequest { + bool_t isdirect; /* direct mount? */ + string mntresource; /* mntpnt source */ + string mntpnt; /* mntpnt to unmount */ + string fstype; /* filesystem type to umount */ + string mntopts; /* mntpnt options */ + struct umntrequest *next; /* next unmount */ +}; + +/* + * Unmount operation result + * status = 0 if unmount was successful, + * otherwise status = errno. + */ +struct umntres { + int status; +}; + +/* + * AUTOFS readdir request + * Request list of entries in 'rda_map' map starting at the given + * offset 'rda_offset', for 'rda_count' bytes. + */ +struct autofs_rddirargs { + string rda_map; + u_int rda_offset; /* starting offset */ + u_int rda_count; /* total size requested */ + uid_t uid; /* uid of caller */ +}; + +struct autofsrddir { + u_int rddir_offset; /* last offset in list */ + u_int rddir_size; /* size in bytes of entries */ + bool_t rddir_eof; /* TRUE if last entry in result */ + struct dirent64 *rddir_entries; /* variable number of entries */ +}; + +/* + * AUTOFS readdir result. + */ +struct autofs_rddirres { + enum autofs_res rd_status; + u_int rd_bufsize; /* autofs request size (not xdr'ed) */ + struct autofsrddir rd_rddir; +}; diff --git a/illumos-x86_64/usr/include/rpcsvc/bootparam.h b/illumos-x86_64/usr/include/rpcsvc/bootparam.h new file mode 100644 index 00000000..f094b1b1 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/bootparam.h @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993, by Sun Microsystems, Inc. + */ + +#ifndef _RPCSVC_BOOTPARAM_H +#define _RPCSVC_BOOTPARAM_H + +#include + +#endif /* _RPCSVC_BOOTPARAM_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/bootparam_prot.h b/illumos-x86_64/usr/include/rpcsvc/bootparam_prot.h new file mode 100644 index 00000000..645f9e98 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/bootparam_prot.h @@ -0,0 +1,124 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _BOOTPARAM_PROT_H_RPCGEN +#define _BOOTPARAM_PROT_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* from bootparam_prot.x */ +#define MAX_MACHINE_NAME 255 +#define MAX_PATH_LEN 1024 +#define MAX_FILEID 32 +#define IP_ADDR_TYPE 1 + +typedef char *bp_machine_name_t; + +typedef char *bp_path_t; + +typedef char *bp_fileid_t; + +struct ip_addr_t { + char net; + char host; + char lh; + char impno; +}; +typedef struct ip_addr_t ip_addr_t; + +struct bp_address { + int address_type; + union { + ip_addr_t ip_addr; + } bp_address_u; +}; +typedef struct bp_address bp_address; + +struct bp_whoami_arg { + bp_address client_address; +}; +typedef struct bp_whoami_arg bp_whoami_arg; + +struct bp_whoami_res { + bp_machine_name_t client_name; + bp_machine_name_t domain_name; + bp_address router_address; +}; +typedef struct bp_whoami_res bp_whoami_res; + +struct bp_getfile_arg { + bp_machine_name_t client_name; + bp_fileid_t file_id; +}; +typedef struct bp_getfile_arg bp_getfile_arg; + +struct bp_getfile_res { + bp_machine_name_t server_name; + bp_address server_address; + bp_path_t server_path; +}; +typedef struct bp_getfile_res bp_getfile_res; + +#define BOOTPARAMPROG 100026 +#define BOOTPARAMVERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define BOOTPARAMPROC_WHOAMI 1 +extern bp_whoami_res * bootparamproc_whoami_1(bp_whoami_arg *, CLIENT *); +extern bp_whoami_res * bootparamproc_whoami_1_svc(bp_whoami_arg *, struct svc_req *); +#define BOOTPARAMPROC_GETFILE 2 +extern bp_getfile_res * bootparamproc_getfile_1(bp_getfile_arg *, CLIENT *); +extern bp_getfile_res * bootparamproc_getfile_1_svc(bp_getfile_arg *, struct svc_req *); +extern int bootparamprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define BOOTPARAMPROC_WHOAMI 1 +extern bp_whoami_res * bootparamproc_whoami_1(); +extern bp_whoami_res * bootparamproc_whoami_1_svc(); +#define BOOTPARAMPROC_GETFILE 2 +extern bp_getfile_res * bootparamproc_getfile_1(); +extern bp_getfile_res * bootparamproc_getfile_1_svc(); +extern int bootparamprog_1_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_bp_machine_name_t(XDR *, bp_machine_name_t*); +extern bool_t xdr_bp_path_t(XDR *, bp_path_t*); +extern bool_t xdr_bp_fileid_t(XDR *, bp_fileid_t*); +extern bool_t xdr_ip_addr_t(XDR *, ip_addr_t*); +extern bool_t xdr_bp_address(XDR *, bp_address*); +extern bool_t xdr_bp_whoami_arg(XDR *, bp_whoami_arg*); +extern bool_t xdr_bp_whoami_res(XDR *, bp_whoami_res*); +extern bool_t xdr_bp_getfile_arg(XDR *, bp_getfile_arg*); +extern bool_t xdr_bp_getfile_res(XDR *, bp_getfile_res*); + +#else /* K&R C */ +extern bool_t xdr_bp_machine_name_t(); +extern bool_t xdr_bp_path_t(); +extern bool_t xdr_bp_fileid_t(); +extern bool_t xdr_ip_addr_t(); +extern bool_t xdr_bp_address(); +extern bool_t xdr_bp_whoami_arg(); +extern bool_t xdr_bp_whoami_res(); +extern bool_t xdr_bp_getfile_arg(); +extern bool_t xdr_bp_getfile_res(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_BOOTPARAM_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/bootparam_prot.x b/illumos-x86_64/usr/include/rpcsvc/bootparam_prot.x new file mode 100644 index 00000000..6f75acab --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/bootparam_prot.x @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +%/* +% * Copyright 2004 Sun Microsystems, Inc. All rights reserved. +% * Use is subject to license terms. +% */ + +%/* from bootparam_prot.x */ + +/* + * RPC for bootparms service. + * There are two procedures: + * WHOAMI takes a net address and returns a client name and also a + * likely net address for routing + * GETFILE takes a client name and file identifier and returns the + * server name, server net address and pathname for the file. + * file identifiers typically include root, swap, pub and dump + */ +const MAX_MACHINE_NAME = 255; +const MAX_PATH_LEN = 1024; +const MAX_FILEID = 32; +const IP_ADDR_TYPE = 1; + +typedef string bp_machine_name_t; +typedef string bp_path_t; +typedef string bp_fileid_t; + +struct ip_addr_t { + char net; + char host; + char lh; + char impno; +}; + +union bp_address switch (int address_type) { + case IP_ADDR_TYPE: + ip_addr_t ip_addr; +}; + +struct bp_whoami_arg { + bp_address client_address; +}; + +struct bp_whoami_res { + bp_machine_name_t client_name; + bp_machine_name_t domain_name; + bp_address router_address; +}; + +struct bp_getfile_arg { + bp_machine_name_t client_name; + bp_fileid_t file_id; +}; + +struct bp_getfile_res { + bp_machine_name_t server_name; + bp_address server_address; + bp_path_t server_path; +}; + +program BOOTPARAMPROG { + version BOOTPARAMVERS { + bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1; + bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2; + } = 1; +} = 100026; diff --git a/illumos-x86_64/usr/include/rpcsvc/dbm.h b/illumos-x86_64/usr/include/rpcsvc/dbm.h new file mode 100644 index 00000000..022524d4 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/dbm.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014, 2016 PALO, Richard. + * + * Copyright 1989 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _RPCSVC_DBM_H +#define _RPCSVC_DBM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PBLKSIZ 1024 +#define DBLKSIZ 4096 +#define BYTESIZ 8 + +long bitno; +long maxbno; +long blkno; +long hmask; + +char pagbuf[PBLKSIZ]; +char dirbuf[DBLKSIZ]; + +int dirf; +int pagf; +int dbrdonly; + +typedef struct +{ + char *dptr; + int dsize; +} datum; + +datum fetch(datum); +datum makdatum(char *, int); +datum firstkey(void); +datum nextkey(datum); +datum firsthash(long); +long calchash(datum); +long hashinc(long); + +#ifdef __cplusplus +} +#endif + +#endif /* _RPCSVC_DBM_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/key_prot.x b/illumos-x86_64/usr/include/rpcsvc/key_prot.x new file mode 100644 index 00000000..d898c572 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/key_prot.x @@ -0,0 +1,525 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Key server protocol definition + * Copyright (C) 1990, 1991 Sun Microsystems, Inc. + * + * The keyserver is a public key storage/encryption/decryption service + * The encryption method used is based on the Diffie-Hellman exponential + * key exchange technology. + * + * The key server is local to each machine, akin to the portmapper. + * Under TI-RPC, communication with the keyserver is through the + * loopback transport. + * + * NOTE: This .x file generates the USER level headers for the keyserver. + * the KERNEL level headers are created by hand as they kernel has special + * requirements. + */ + +% +%/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ +% +%/* +% * Compiled from key_prot.x using rpcgen. +% * DO NOT EDIT THIS FILE! +% * This is NOT source code! +% */ + +/* + * PROOT and MODULUS define the way the Diffie-Hellman key is generated. + * + * MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1, + * where p is also prime. + * + * PROOT satisfies the following two conditions: + * (1) (PROOT ** 2) % MODULUS != 1 + * (2) (PROOT ** p) % MODULUS != 1 + * + */ + +const PROOT = 3; +const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b"; + +const HEXKEYBYTES = 48; /* HEXKEYBYTES == strlen(HEXMODULUS) */ +const KEYSIZE = 192; /* KEYSIZE == bit length of key */ +const KEYBYTES = 24; /* byte length of key */ + +/* + * The first 16 hex digits of the encrypted secret key are used as + * a checksum in the database. + */ +const KEYCHECKSUMSIZE = 16; + +/* + * status of operation + */ +enum keystatus { + KEY_SUCCESS, /* no problems */ + KEY_NOSECRET, /* no secret key stored */ + KEY_UNKNOWN, /* unknown netname */ + KEY_SYSTEMERR, /* system error (out of memory, encryption failure) */ + KEY_BADALG, /* unknown algorithm type */ + KEY_BADLEN /* unsupported keysize */ +}; + +typedef opaque keybuf[HEXKEYBYTES]; /* store key in hex */ +typedef opaque keybuf3<>; /* store key in binary */ + +typedef string netnamestr; + +/* + * algorithm type & key size + */ +typedef int keylen_t; +typedef int algtype_t; + +struct mechtype { + keylen_t keylen; + algtype_t algtype; +}; + +/* + * number of keys for KEY_GEN_3 to return + */ +typedef int keynum_t; + +/* + * Result of KEY_GEN_3 + */ +typedef des_block deskeyarray<>; + +/* + * Argument to ENCRYPT or DECRYPT + */ +struct cryptkeyarg { + netnamestr remotename; + des_block deskey; +}; + +/* + * Argument to ENCRYPT_PK or DECRYPT_PK + */ +struct cryptkeyarg2 { + netnamestr remotename; + netobj remotekey; /* Contains a length up to 1024 bytes */ + des_block deskey; +}; + +/* + * Argument to ENCRYPT_3, ENCRYPT_PK_3, DECRYPT_3, DECRYPT_PK_3 + */ +struct cryptkeyarg3 { + netnamestr remotename; + keybuf3 remotekey; + deskeyarray deskey; + algtype_t algtype; + keylen_t keylen; +}; + +/* + * Result of ENCRYPT, DECRYPT, ENCRYPT_PK, DECRYPT_PK, KEY_GET_CONV + */ +union cryptkeyres switch (keystatus status) { +case KEY_SUCCESS: + des_block deskey; +default: + void; +}; + +/* + * Result of ENCRYPT_3, DECRYPT_3, ENCRYPT_PK_3, DECRYPT_PK_3, KEY_GET_CONV_3 + */ +union cryptkeyres3 switch (keystatus status) { +case KEY_SUCCESS: + deskeyarray deskey; +default: + void; +}; + +const MAXGIDS = 16; /* max number of gids in gid list */ + +/* + * Unix credential + */ +struct unixcred { + u_int uid; + u_int gid; + u_int gids; +}; + +/* + * Unix credential, without arbitrary limit + */ +struct unixcred3 { + u_int uid; + u_int gid; + u_int gids<>; +}; + +/* + * Result returned from GETCRED + */ +union getcredres switch (keystatus status) { +case KEY_SUCCESS: + unixcred cred; +default: + void; +}; + +/* + * Result returned from GETCRED_3 + */ +union getcredres3 switch (keystatus status) { +case KEY_SUCCESS: + unixcred3 cred; +default: + void; +}; + +/* + * key_netstarg; + */ +struct key_netstarg { + keybuf st_priv_key; + keybuf st_pub_key; + netnamestr st_netname; +}; + +struct key_netstarg3 { + keybuf3 st_priv_key; + keybuf3 st_pub_key; + netnamestr st_netname; + algtype_t algtype; + keylen_t keylen; + des_block userkey; +}; + +union key_netstres switch (keystatus status){ +case KEY_SUCCESS: + key_netstarg knet; +default: + void; +}; + +union key_netstres3 switch (keystatus status){ +case KEY_SUCCESS: + key_netstarg3 knet; +default: + void; +}; + +/* + * Argument to KEY_GET_CONV_3 + */ +struct deskeyarg3 { + keybuf3 pub_key; + int nkeys; + algtype_t algtype ; + keylen_t keylen; +}; + +/* + * Argument to KEY_SET_3 + */ +struct setkeyarg3 { + keybuf3 key; + des_block userkey; + algtype_t algtype ; + keylen_t keylen; +}; + +#ifdef RPC_HDR +% +%#ifndef opaque +%#define opaque char +%#endif +% +#endif +program KEY_PROG { + version KEY_VERS { + + /* + * This is my secret key. + * Store it for me. + */ + keystatus + KEY_SET(keybuf) = 1; + + /* + * I want to talk to X. + * Encrypt a conversation key for me. + */ + cryptkeyres + KEY_ENCRYPT(cryptkeyarg) = 2; + + /* + * X just sent me a message. + * Decrypt the conversation key for me. + */ + cryptkeyres + KEY_DECRYPT(cryptkeyarg) = 3; + + /* + * Generate a secure conversation key for me + */ + des_block + KEY_GEN(void) = 4; + + /* + * Get me the uid, gid and group-access-list associated + * with this netname (for kernel which cannot use NIS) + */ + getcredres + KEY_GETCRED(netnamestr) = 5; + } = 1; + version KEY_VERS2 { + + /* + * ####### + * Procedures 1-5 are identical to version 1 + * ####### + */ + + /* + * This is my secret key. + * Store it for me. + */ + keystatus + KEY_SET(keybuf) = 1; + + /* + * I want to talk to X. + * Encrypt a conversation key for me. + */ + cryptkeyres + KEY_ENCRYPT(cryptkeyarg) = 2; + + /* + * X just sent me a message. + * Decrypt the conversation key for me. + */ + cryptkeyres + KEY_DECRYPT(cryptkeyarg) = 3; + + /* + * Generate a secure conversation key for me + */ + des_block + KEY_GEN(void) = 4; + + /* + * Get me the uid, gid and group-access-list associated + * with this netname (for kernel which cannot use NIS) + */ + getcredres + KEY_GETCRED(netnamestr) = 5; + + /* + * I want to talk to X. and I know X's public key + * Encrypt a conversation key for me. + */ + cryptkeyres + KEY_ENCRYPT_PK(cryptkeyarg2) = 6; + + /* + * X just sent me a message. and I know X's public key + * Decrypt the conversation key for me. + */ + cryptkeyres + KEY_DECRYPT_PK(cryptkeyarg2) = 7; + + /* + * Store my public key, netname and private key. + */ + keystatus + KEY_NET_PUT(key_netstarg) = 8; + + /* + * Retrieve my public key, netname and private key. + */ + key_netstres + KEY_NET_GET(void) = 9; + + /* + * Return me the conversation (common) key that is constructed + * from my secret key and this publickey. + */ + cryptkeyres + KEY_GET_CONV(keybuf) = 10; + } = 2; + version KEY_VERS3 { + + /* + * ####### + * Procedures 1-10 are identical to versions 1 & 2 + * ####### + */ + + /* + * This is my secret key. + * Store it for me. + */ + keystatus + KEY_SET(keybuf) = 1; + + /* + * I want to talk to X. + * Encrypt a conversation key for me. + */ + cryptkeyres + KEY_ENCRYPT(cryptkeyarg) = 2; + + /* + * X just sent me a message. + * Decrypt the conversation key for me. + */ + cryptkeyres + KEY_DECRYPT(cryptkeyarg) = 3; + + /* + * Generate a secure conversation key for me + */ + des_block + KEY_GEN(void) = 4; + + /* + * Get me the uid, gid and group-access-list associated + * with this netname (for kernel which cannot use NIS) + */ + getcredres + KEY_GETCRED(netnamestr) = 5; + + /* + * I want to talk to X. and I know X's public key + * Encrypt a conversation key for me. + */ + cryptkeyres + KEY_ENCRYPT_PK(cryptkeyarg2) = 6; + + /* + * X just sent me a message. and I know X's public key + * Decrypt the conversation key for me. + */ + cryptkeyres + KEY_DECRYPT_PK(cryptkeyarg2) = 7; + + /* + * Store my public key, netname and private key. + */ + keystatus + KEY_NET_PUT(key_netstarg) = 8; + + /* + * Retrieve my public key, netname and private key. + */ + key_netstres + KEY_NET_GET(void) = 9; + + /* + * Return me the conversation (common) key that is constructed + * from my secret key and this publickey. + */ + cryptkeyres + KEY_GET_CONV(keybuf) = 10; + + /* + * ####### + * Procedures new in version 3 follow... + * ####### + */ + + /* + * This is my secret key. + * Store it for me. + */ + keystatus + KEY_SET_3(setkeyarg3) = 11; + + /* + * I want to talk to X. + * Encrypt a conversation key for me. + */ + cryptkeyres3 + KEY_ENCRYPT_3(cryptkeyarg3) = 12; + + /* + * X just sent me a message. + * Decrypt the conversation key for me. + */ + cryptkeyres3 + KEY_DECRYPT_3(cryptkeyarg3) = 13; + + /* + * Generate secure conversation key(s) for me + */ + deskeyarray + KEY_GEN_3(keynum_t) = 14; + + /* + * Get me the uid, gid and group-access-list associated + * with this netname (for kernel which cannot use NIS) + */ + getcredres3 + KEY_GETCRED_3(netnamestr) = 15; + + /* + * I want to talk to X. and I know X's public key + * Encrypt a conversation key for me. + */ + cryptkeyres3 + KEY_ENCRYPT_PK_3(cryptkeyarg3) = 16; + + /* + * X just sent me a message. and I know X's public key + * Decrypt the conversation key for me. + */ + cryptkeyres3 + KEY_DECRYPT_PK_3(cryptkeyarg3) = 17; + + /* + * Store my public key, netname and private key. + */ + keystatus + KEY_NET_PUT_3(key_netstarg3) = 18; + + /* + * Retrieve my public key, netname and private key. + */ + key_netstres3 + KEY_NET_GET_3(key_netstarg3) = 19; + + /* + * Return me the conversation (common) key that is constructed + * from my secret key and this publickey. + */ + cryptkeyres3 + KEY_GET_CONV_3(deskeyarg3) = 20; + + /* + * Clear all the secret/public/netname triplets for the caller + */ + keystatus + KEY_CLEAR_3(void) = 21; + + } = 3; +} = 100029; diff --git a/illumos-x86_64/usr/include/rpcsvc/mount.h b/illumos-x86_64/usr/include/rpcsvc/mount.h new file mode 100644 index 00000000..84e519dc --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/mount.h @@ -0,0 +1,279 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _MOUNT_H_RPCGEN +#define _MOUNT_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MNTPATHLEN 1024 +#define MNTNAMLEN 255 +#define FHSIZE 32 +#define FHSIZE3 64 + +typedef char fhandle[FHSIZE]; + +typedef struct { + u_int fhandle3_len; + char *fhandle3_val; +} fhandle3; + +struct fhstatus { + u_int fhs_status; + union { + fhandle fhs_fhandle; + } fhstatus_u; +}; +typedef struct fhstatus fhstatus; + +#define fhs_fh fhstatus_u.fhs_fhandle + +enum mountstat3 { + MNT_OK = 0, + MNT3ERR_PERM = 1, + MNT3ERR_NOENT = 2, + MNT3ERR_IO = 5, + MNT3ERR_ACCES = 13, + MNT3ERR_NOTDIR = 20, + MNT3ERR_INVAL = 22, + MNT3ERR_NAMETOOLONG = 63, + MNT3ERR_NOTSUPP = 10004, + MNT3ERR_SERVERFAULT = 10006 +}; +typedef enum mountstat3 mountstat3; + +struct mountres3_ok { + fhandle3 fhandle; + struct { + u_int auth_flavors_len; + int *auth_flavors_val; + } auth_flavors; +}; +typedef struct mountres3_ok mountres3_ok; + +struct mountres3 { + mountstat3 fhs_status; + union { + mountres3_ok mountinfo; + } mountres3_u; +}; +typedef struct mountres3 mountres3; + +typedef char *dirpath; + +typedef char *name; + +typedef struct mountbody *mountlist; + +struct mountbody { + name ml_hostname; + dirpath ml_directory; + mountlist ml_next; +}; +typedef struct mountbody mountbody; + +typedef struct groupnode *groups; + +struct groupnode { + name gr_name; + groups gr_next; +}; +typedef struct groupnode groupnode; + +typedef struct exportnode *exports; + +struct exportnode { + dirpath ex_dir; + groups ex_groups; + exports ex_next; +}; +typedef struct exportnode exportnode; + +struct ppathcnf { + int pc_link_max; + short pc_max_canon; + short pc_max_input; + short pc_name_max; + short pc_path_max; + short pc_pipe_buf; + u_char pc_vdisable; + char pc_xxx; + short pc_mask[2]; +}; +typedef struct ppathcnf ppathcnf; + +#define MOUNTPROG 100005 +#define MOUNTVERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define MOUNTPROC_NULL 0 +extern void * mountproc_null_1(void *, CLIENT *); +extern void * mountproc_null_1_svc(void *, struct svc_req *); +#define MOUNTPROC_MNT 1 +extern fhstatus * mountproc_mnt_1(dirpath *, CLIENT *); +extern fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *); +#define MOUNTPROC_DUMP 2 +extern mountlist * mountproc_dump_1(void *, CLIENT *); +extern mountlist * mountproc_dump_1_svc(void *, struct svc_req *); +#define MOUNTPROC_UMNT 3 +extern void * mountproc_umnt_1(dirpath *, CLIENT *); +extern void * mountproc_umnt_1_svc(dirpath *, struct svc_req *); +#define MOUNTPROC_UMNTALL 4 +extern void * mountproc_umntall_1(void *, CLIENT *); +extern void * mountproc_umntall_1_svc(void *, struct svc_req *); +#define MOUNTPROC_EXPORT 5 +extern exports * mountproc_export_1(void *, CLIENT *); +extern exports * mountproc_export_1_svc(void *, struct svc_req *); +#define MOUNTPROC_EXPORTALL 6 +extern exports * mountproc_exportall_1(void *, CLIENT *); +extern exports * mountproc_exportall_1_svc(void *, struct svc_req *); +extern int mountprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define MOUNTPROC_NULL 0 +extern void * mountproc_null_1(); +extern void * mountproc_null_1_svc(); +#define MOUNTPROC_MNT 1 +extern fhstatus * mountproc_mnt_1(); +extern fhstatus * mountproc_mnt_1_svc(); +#define MOUNTPROC_DUMP 2 +extern mountlist * mountproc_dump_1(); +extern mountlist * mountproc_dump_1_svc(); +#define MOUNTPROC_UMNT 3 +extern void * mountproc_umnt_1(); +extern void * mountproc_umnt_1_svc(); +#define MOUNTPROC_UMNTALL 4 +extern void * mountproc_umntall_1(); +extern void * mountproc_umntall_1_svc(); +#define MOUNTPROC_EXPORT 5 +extern exports * mountproc_export_1(); +extern exports * mountproc_export_1_svc(); +#define MOUNTPROC_EXPORTALL 6 +extern exports * mountproc_exportall_1(); +extern exports * mountproc_exportall_1_svc(); +extern int mountprog_1_freeresult(); +#endif /* K&R C */ +#define MOUNTVERS_POSIX 2 + +#if defined(__STDC__) || defined(__cplusplus) +extern void * mountproc_null_2(void *, CLIENT *); +extern void * mountproc_null_2_svc(void *, struct svc_req *); +extern fhstatus * mountproc_mnt_2(dirpath *, CLIENT *); +extern fhstatus * mountproc_mnt_2_svc(dirpath *, struct svc_req *); +extern mountlist * mountproc_dump_2(void *, CLIENT *); +extern mountlist * mountproc_dump_2_svc(void *, struct svc_req *); +extern void * mountproc_umnt_2(dirpath *, CLIENT *); +extern void * mountproc_umnt_2_svc(dirpath *, struct svc_req *); +extern void * mountproc_umntall_2(void *, CLIENT *); +extern void * mountproc_umntall_2_svc(void *, struct svc_req *); +extern exports * mountproc_export_2(void *, CLIENT *); +extern exports * mountproc_export_2_svc(void *, struct svc_req *); +extern exports * mountproc_exportall_2(void *, CLIENT *); +extern exports * mountproc_exportall_2_svc(void *, struct svc_req *); +#define MOUNTPROC_PATHCONF 7 +extern ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *); +extern ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *); +extern int mountprog_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +extern void * mountproc_null_2(); +extern void * mountproc_null_2_svc(); +extern fhstatus * mountproc_mnt_2(); +extern fhstatus * mountproc_mnt_2_svc(); +extern mountlist * mountproc_dump_2(); +extern mountlist * mountproc_dump_2_svc(); +extern void * mountproc_umnt_2(); +extern void * mountproc_umnt_2_svc(); +extern void * mountproc_umntall_2(); +extern void * mountproc_umntall_2_svc(); +extern exports * mountproc_export_2(); +extern exports * mountproc_export_2_svc(); +extern exports * mountproc_exportall_2(); +extern exports * mountproc_exportall_2_svc(); +#define MOUNTPROC_PATHCONF 7 +extern ppathcnf * mountproc_pathconf_2(); +extern ppathcnf * mountproc_pathconf_2_svc(); +extern int mountprog_2_freeresult(); +#endif /* K&R C */ +#define MOUNTVERS3 3 + +#if defined(__STDC__) || defined(__cplusplus) +extern void * mountproc_null_3(void *, CLIENT *); +extern void * mountproc_null_3_svc(void *, struct svc_req *); +extern mountres3 * mountproc_mnt_3(dirpath *, CLIENT *); +extern mountres3 * mountproc_mnt_3_svc(dirpath *, struct svc_req *); +extern mountlist * mountproc_dump_3(void *, CLIENT *); +extern mountlist * mountproc_dump_3_svc(void *, struct svc_req *); +extern void * mountproc_umnt_3(dirpath *, CLIENT *); +extern void * mountproc_umnt_3_svc(dirpath *, struct svc_req *); +extern void * mountproc_umntall_3(void *, CLIENT *); +extern void * mountproc_umntall_3_svc(void *, struct svc_req *); +extern exports * mountproc_export_3(void *, CLIENT *); +extern exports * mountproc_export_3_svc(void *, struct svc_req *); +extern int mountprog_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +extern void * mountproc_null_3(); +extern void * mountproc_null_3_svc(); +extern mountres3 * mountproc_mnt_3(); +extern mountres3 * mountproc_mnt_3_svc(); +extern mountlist * mountproc_dump_3(); +extern mountlist * mountproc_dump_3_svc(); +extern void * mountproc_umnt_3(); +extern void * mountproc_umnt_3_svc(); +extern void * mountproc_umntall_3(); +extern void * mountproc_umntall_3_svc(); +extern exports * mountproc_export_3(); +extern exports * mountproc_export_3_svc(); +extern int mountprog_3_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_fhandle(XDR *, fhandle); +extern bool_t xdr_fhandle3(XDR *, fhandle3*); +extern bool_t xdr_fhstatus(XDR *, fhstatus*); +extern bool_t xdr_mountstat3(XDR *, mountstat3*); +extern bool_t xdr_mountres3_ok(XDR *, mountres3_ok*); +extern bool_t xdr_mountres3(XDR *, mountres3*); +extern bool_t xdr_dirpath(XDR *, dirpath*); +extern bool_t xdr_name(XDR *, name*); +extern bool_t xdr_mountlist(XDR *, mountlist*); +extern bool_t xdr_mountbody(XDR *, mountbody*); +extern bool_t xdr_groups(XDR *, groups*); +extern bool_t xdr_groupnode(XDR *, groupnode*); +extern bool_t xdr_exports(XDR *, exports*); +extern bool_t xdr_exportnode(XDR *, exportnode*); +extern bool_t xdr_ppathcnf(XDR *, ppathcnf*); + +#else /* K&R C */ +extern bool_t xdr_fhandle(); +extern bool_t xdr_fhandle3(); +extern bool_t xdr_fhstatus(); +extern bool_t xdr_mountstat3(); +extern bool_t xdr_mountres3_ok(); +extern bool_t xdr_mountres3(); +extern bool_t xdr_dirpath(); +extern bool_t xdr_name(); +extern bool_t xdr_mountlist(); +extern bool_t xdr_mountbody(); +extern bool_t xdr_groups(); +extern bool_t xdr_groupnode(); +extern bool_t xdr_exports(); +extern bool_t xdr_exportnode(); +extern bool_t xdr_ppathcnf(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_MOUNT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/mount.x b/illumos-x86_64/usr/include/rpcsvc/mount.x new file mode 100644 index 00000000..1aff7ecc --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/mount.x @@ -0,0 +1,381 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1988,1990-1992,1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Protocol description for the mount program + */ + +const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ +const MNTNAMLEN = 255; /* maximum bytes in a name argument */ +const FHSIZE = 32; /* size in bytes of a v2 file handle */ +const FHSIZE3 = 64; /* " " " " " v3 " " */ + +/* + * The fhandle is the file handle that the server passes to the client. + * All file operations are done using the file handles to refer to a file + * or a directory. The file handle can contain whatever information the + * server needs to distinguish an individual file. + * + * Versions 1 and 2 of the protocol share a filehandle of 32 bytes. + * + * Version 3 supports a 64 byte filehandle that can be used only + * with version 3 of the NFS protocol. + */ + +typedef opaque fhandle[FHSIZE]; +typedef opaque fhandle3; + +/* + * If a V2 status of zero is returned, the call completed successfully, and + * a file handle for the directory follows. A non-zero status indicates + * some sort of error. The status corresponds with UNIX error numbers. + */ +union fhstatus switch (unsigned fhs_status) { +case 0: + fhandle fhs_fhandle; +default: + void; +}; + +/* + * This #define is added for backwards compatability with applications + * which reference the old style fhstatus. The second element of that + * structure was called fhs_fh, instead of the current fhs_fhandle. + */ +% +%#define fhs_fh fhstatus_u.fhs_fhandle + +/* + * The following status codes are defined for the V3 mount service: + * Note that the precise enum encoding must be followed; the values + * are derived from existing implementation practice, and there is + * no good reason to disturb them. + */ +enum mountstat3 { + MNT_OK= 0, /* no error */ + MNT3ERR_PERM=1, /* Not owner */ + MNT3ERR_NOENT=2, /* No such file or directory */ + MNT3ERR_IO=5, /* I/O error */ + MNT3ERR_ACCES=13, /* Permission denied */ + MNT3ERR_NOTDIR=20, /* Not a directory*/ + MNT3ERR_INVAL=22, /* Invalid argument.*/ + MNT3ERR_NAMETOOLONG=63, /* File name too long */ + MNT3ERR_NOTSUPP=10004, /* operation not supported */ + MNT3ERR_SERVERFAULT=10006 /* An i/o or similar failure caused */ + /* the server to abandon the request */ + /* No attributes can be returned. The */ + /* client should translate this into EIO */ +}; + +/* + * A V3 server returns a file handle and a list of the authentication + * flavors that the server will accept for this mount. If the list + * is empty, AUTH_UNIX is required. Otherwise, any of the flavors + * listed in auth_flavors<> may be used (but no others). + * The values of the authentication flavors are defined in the + * underlying RPC protocol. + */ +struct mountres3_ok { + fhandle3 fhandle; + int auth_flavors<>; +}; + +/* + * If a V3 status of MNT_OK is returned, the call completed successfully, and + * a file handle for the directory follows. Any other status indicates + * some sort of error. + */ + +union mountres3 switch (mountstat3 fhs_status) { +case MNT_OK: + mountres3_ok mountinfo; +default: + void; +}; + +/* + * The type dirpath is the pathname of a directory + */ +typedef string dirpath; + +/* + * The type name is used for arbitrary names (hostnames, groupnames) + */ +typedef string name; + +/* + * A list of who has what mounted. This information is + * strictly advisory, since there is no mechanism to + * enforce the removal of stale information. The strongest + * assertion that can be made is that if a hostname:directory + * pair appears in the list, the server has exported the + * directory to that client at some point since the server + * export data base was (re)initialized. Note also that there + * is no limit on the length of the information returned + * in this structure, and this may cause problems if the + * mount service is accessed via a connectionless transport. + * + * The ifdef will ensure that these are only carried over to + * mount.h - no xdr routines will be generated. We want to + * do these by hand, to avoid the recursive stack-blowing ones + * that rpcgen will generate. + */ +#ifdef RPC_HDR +typedef struct mountbody *mountlist; +struct mountbody { + name ml_hostname; + dirpath ml_directory; + mountlist ml_next; +}; +#endif /* RPC_HDR */ + +/* + * A list of netgroups + */ +typedef struct groupnode *groups; +struct groupnode { + name gr_name; + groups gr_next; +}; + +/* + * A list of what is exported and to whom + */ +typedef struct exportnode *exports; +struct exportnode { + dirpath ex_dir; + groups ex_groups; + exports ex_next; +}; + +/* + * POSIX pathconf information + */ +struct ppathcnf { + int pc_link_max; /* max links allowed */ + short pc_max_canon; /* max line len for a tty */ + short pc_max_input; /* input a tty can eat all at once */ + short pc_name_max; /* max file name length (dir entry) */ + short pc_path_max; /* max path name length (/x/y/x/.. ) */ + short pc_pipe_buf; /* size of a pipe (bytes) */ + u_char pc_vdisable; /* safe char to turn off c_cc[i] */ + char pc_xxx; /* alignment padding; cc_t == char */ + short pc_mask[2]; /* validity and boolean bits */ +}; + +program MOUNTPROG { + /* + * Version one of the mount protocol communicates with version two + * of the NFS protocol. The only connecting point is the fhandle + * structure, which is the same for both protocols. + */ + version MOUNTVERS { + /* + * Does no work. It is made available in all RPC services + * to allow server reponse testing and timing + */ + void + MOUNTPROC_NULL(void) = 0; + + /* + * If fhs_status is 0, then fhs_fhandle contains the + * file handle for the directory. This file handle may + * be used in the NFS protocol. This procedure also adds + * a new entry to the mount list for this client mounting + * the directory. + * Unix authentication required. + */ + fhstatus + MOUNTPROC_MNT(dirpath) = 1; + + /* + * Returns the list of remotely mounted filesystems. The + * mountlist contains one entry for each hostname and + * directory pair. + */ + mountlist + MOUNTPROC_DUMP(void) = 2; + + /* + * Removes the mount list entry for the directory + * Unix authentication required. + */ + void + MOUNTPROC_UMNT(dirpath) = 3; + + /* + * Removes all of the mount list entries for this client + * Unix authentication required. + */ + void + MOUNTPROC_UMNTALL(void) = 4; + + /* + * Returns a list of all the exported filesystems, and which + * machines are allowed to import it. + */ + exports + MOUNTPROC_EXPORT(void) = 5; + + /* + * Identical to MOUNTPROC_EXPORT above + */ + exports + MOUNTPROC_EXPORTALL(void) = 6; + } = 1; + + /* + * Version two of the mount protocol communicates with version two + * of the NFS protocol. It is identical to version one except for a + * new procedure call for posix. + */ + version MOUNTVERS_POSIX { + /* + * Does no work. It is made available in all RPC services + * to allow server reponse testing and timing + */ + void + MOUNTPROC_NULL(void) = 0; + + /* + * If fhs_status is 0, then fhs_fhandle contains the + * file handle for the directory. This file handle may + * be used in the NFS protocol. This procedure also adds + * a new entry to the mount list for this client mounting + * the directory. + * Unix authentication required. + */ + fhstatus + MOUNTPROC_MNT(dirpath) = 1; + + /* + * Returns the list of remotely mounted filesystems. The + * mountlist contains one entry for each hostname and + * directory pair. + */ + mountlist + MOUNTPROC_DUMP(void) = 2; + + /* + * Removes the mount list entry for the directory + * Unix authentication required. + */ + void + MOUNTPROC_UMNT(dirpath) = 3; + + /* + * Removes all of the mount list entries for this client + * Unix authentication required. + */ + void + MOUNTPROC_UMNTALL(void) = 4; + + /* + * Returns a list of all the exported filesystems, and which + * machines are allowed to import it. + */ + exports + MOUNTPROC_EXPORT(void) = 5; + + /* + * Identical to MOUNTPROC_EXPORT above + */ + exports + MOUNTPROC_EXPORTALL(void) = 6; + + /* + * Posix info over the wire isn't supported in NFS version 2 + * so we get it here at mount time. + */ + ppathcnf + MOUNTPROC_PATHCONF(dirpath) = 7; + } = 2; + + /* + * Version 3 of the mount protocol communicates with version 3 + * of the NFS protocol. The only connecting point is the nfs_fh3 + * structure, which is the same for both protocols. + * + * The only significant change over version 2 is that MOUNTPROC_MNT + * returns a longer filehandle (64 bytes instead of 32) as well + * as authentication information. MOUNTPROC_PATHCONF is subsumed + * into V3 of the NFS protocol and MOUNTPROC_EXPORTALL is eliminated. + */ + version MOUNTVERS3 { + /* + * Does no work. It is made available in all RPC services + * to allow server reponse testing and timing + */ + void + MOUNTPROC_NULL(void) = 0; + + /* + * Mount a file system. + * + * If mountres.fhs_status is NFS_OK, then mountres.mountinfo + * contains the file handle for the directory and + * a list of acceptable authentication flavors. This file + * handle may only be used in version 3 of the NFS protocol. + * This procedure also results in the server adding a new + * entry to its mount list recording that this client has + * mounted the directory. Unix authentication or better + * is required. + */ + mountres3 + MOUNTPROC_MNT(dirpath) = 1; + + /* + * Returns the list of remotely mounted filesystems. The + * mountlist contains one entry for each hostname and + * directory pair. + */ + mountlist + MOUNTPROC_DUMP(void) = 2; + + /* + * Removes the mount list entry for the directory + * Unix authentication or better is required. + */ + void + MOUNTPROC_UMNT(dirpath) = 3; + + /* + * Removes all of the mount list entries for this client + * Unix authentication or better is required. + */ + void + MOUNTPROC_UMNTALL(void) = 4; + + /* + * Returns a list of all the exported filesystems, and which + * machines are allowed to import each one. + */ + exports + MOUNTPROC_EXPORT(void) = 5; + + } = 3; +} = 100005; diff --git a/illumos-x86_64/usr/include/rpcsvc/nfs4_prot.h b/illumos-x86_64/usr/include/rpcsvc/nfs4_prot.h new file mode 100644 index 00000000..0929f568 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nfs4_prot.h @@ -0,0 +1,4557 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _NFS4_PROT_H_RPCGEN +#define _NFS4_PROT_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _AUTH_SYS_DEFINE_FOR_NFSv42 +#define _AUTH_SYS_DEFINE_FOR_NFSv42 +#include +typedef struct authsys_parms authsys_parms; +#endif /* _AUTH_SYS_DEFINE_FOR_NFSv42 */ +#define NFS4_FHSIZE 128 +#define NFS4_VERIFIER_SIZE 8 +#define NFS4_OTHER_SIZE 12 +#define NFS4_OPAQUE_LIMIT 1024 +#define NFS4_SESSIONID_SIZE 16 +#define NFS4_INT64_MAX 0x7fffffffffffffff +#define NFS4_UINT64_MAX 0xffffffffffffffff +#define NFS4_INT32_MAX 0x7fffffff +#define NFS4_UINT32_MAX 0xffffffff +#define NFS4_MAXFILELEN 0xffffffffffffffff +#define NFS4_MAXFILEOFF 0xfffffffffffffffe + +enum nfs_ftype4 { + NF4REG = 1, + NF4DIR = 2, + NF4BLK = 3, + NF4CHR = 4, + NF4LNK = 5, + NF4SOCK = 6, + NF4FIFO = 7, + NF4ATTRDIR = 8, + NF4NAMEDATTR = 9 +}; +typedef enum nfs_ftype4 nfs_ftype4; + +enum nfsstat4 { + NFS4_OK = 0, + NFS4ERR_PERM = 1, + NFS4ERR_NOENT = 2, + NFS4ERR_IO = 5, + NFS4ERR_NXIO = 6, + NFS4ERR_ACCESS = 13, + NFS4ERR_EXIST = 17, + NFS4ERR_XDEV = 18, + NFS4ERR_NOTDIR = 20, + NFS4ERR_ISDIR = 21, + NFS4ERR_INVAL = 22, + NFS4ERR_FBIG = 27, + NFS4ERR_NOSPC = 28, + NFS4ERR_ROFS = 30, + NFS4ERR_MLINK = 31, + NFS4ERR_NAMETOOLONG = 63, + NFS4ERR_NOTEMPTY = 66, + NFS4ERR_DQUOT = 69, + NFS4ERR_STALE = 70, + NFS4ERR_BADHANDLE = 10001, + NFS4ERR_BAD_COOKIE = 10003, + NFS4ERR_NOTSUPP = 10004, + NFS4ERR_TOOSMALL = 10005, + NFS4ERR_SERVERFAULT = 10006, + NFS4ERR_BADTYPE = 10007, + NFS4ERR_DELAY = 10008, + NFS4ERR_SAME = 10009, + NFS4ERR_DENIED = 10010, + NFS4ERR_EXPIRED = 10011, + NFS4ERR_LOCKED = 10012, + NFS4ERR_GRACE = 10013, + NFS4ERR_FHEXPIRED = 10014, + NFS4ERR_SHARE_DENIED = 10015, + NFS4ERR_WRONGSEC = 10016, + NFS4ERR_CLID_INUSE = 10017, + NFS4ERR_RESOURCE = 10018, + NFS4ERR_MOVED = 10019, + NFS4ERR_NOFILEHANDLE = 10020, + NFS4ERR_MINOR_VERS_MISMATCH = 10021, + NFS4ERR_STALE_CLIENTID = 10022, + NFS4ERR_STALE_STATEID = 10023, + NFS4ERR_OLD_STATEID = 10024, + NFS4ERR_BAD_STATEID = 10025, + NFS4ERR_BAD_SEQID = 10026, + NFS4ERR_NOT_SAME = 10027, + NFS4ERR_LOCK_RANGE = 10028, + NFS4ERR_SYMLINK = 10029, + NFS4ERR_RESTOREFH = 10030, + NFS4ERR_LEASE_MOVED = 10031, + NFS4ERR_ATTRNOTSUPP = 10032, + NFS4ERR_NO_GRACE = 10033, + NFS4ERR_RECLAIM_BAD = 10034, + NFS4ERR_RECLAIM_CONFLICT = 10035, + NFS4ERR_BADXDR = 10036, + NFS4ERR_LOCKS_HELD = 10037, + NFS4ERR_OPENMODE = 10038, + NFS4ERR_BADOWNER = 10039, + NFS4ERR_BADCHAR = 10040, + NFS4ERR_BADNAME = 10041, + NFS4ERR_BAD_RANGE = 10042, + NFS4ERR_LOCK_NOTSUPP = 10043, + NFS4ERR_OP_ILLEGAL = 10044, + NFS4ERR_DEADLOCK = 10045, + NFS4ERR_FILE_OPEN = 10046, + NFS4ERR_ADMIN_REVOKED = 10047, + NFS4ERR_CB_PATH_DOWN = 10048, + NFS4ERR_BADIOMODE = 10049, + NFS4ERR_BADLAYOUT = 10050, + NFS4ERR_BAD_SESSION_DIGEST = 10051, + NFS4ERR_BADSESSION = 10052, + NFS4ERR_BADSLOT = 10053, + NFS4ERR_COMPLETE_ALREADY = 10054, + NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055, + NFS4ERR_DELEG_ALREADY_WANTED = 10056, + NFS4ERR_BACK_CHAN_BUSY = 10057, + NFS4ERR_LAYOUTTRYLATER = 10058, + NFS4ERR_LAYOUTUNAVAILABLE = 10059, + NFS4ERR_NOMATCHING_LAYOUT = 10060, + NFS4ERR_RECALLCONFLICT = 10061, + NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062, + NFS4ERR_SEQ_MISORDERED = 10063, + NFS4ERR_SEQUENCE_POS = 10064, + NFS4ERR_REQ_TOO_BIG = 10065, + NFS4ERR_REP_TOO_BIG = 10066, + NFS4ERR_REP_TOO_BIG_TO_CACHE = 10067, + NFS4ERR_RETRY_UNCACHED_REP = 10068, + NFS4ERR_UNSAFE_COMPOUND = 10069, + NFS4ERR_TOO_MANY_OPS = 10070, + NFS4ERR_OP_NOT_IN_SESSION = 10071, + NFS4ERR_HASH_ALG_UNSUPP = 10072, + NFS4ERR_CLIENTID_BUSY = 10074, + NFS4ERR_PNFS_IO_HOLE = 10075, + NFS4ERR_SEQ_FALSE_RETRY = 10076, + NFS4ERR_BAD_HIGH_SLOT = 10077, + NFS4ERR_DEADSESSION = 10078, + NFS4ERR_ENCR_ALG_UNSUPP = 10079, + NFS4ERR_PNFS_NO_LAYOUT = 10080, + NFS4ERR_NOT_ONLY_OP = 10081, + NFS4ERR_WRONG_CRED = 10082, + NFS4ERR_WRONG_TYPE = 10083, + NFS4ERR_DIRDELEG_UNAVAIL = 10084, + NFS4ERR_REJECT_DELEG = 10085, + NFS4ERR_RETURNCONFLICT = 10086, + NFS4ERR_DELEG_REVOKED = 10087, + NFS4ERR_PARTNER_NOTSUPP = 10088, + NFS4ERR_PARTNER_NO_AUTH = 10089, + NFS4ERR_UNION_NOTSUPP = 10090, + NFS4ERR_OFFLOAD_DENIED = 10091, + NFS4ERR_WRONG_LFS = 10092, + NFS4ERR_BADLABEL = 10093, + NFS4ERR_OFFLOAD_NO_REQS = 10094 +}; +typedef enum nfsstat4 nfsstat4; + +typedef struct { + u_int attrlist4_len; + char *attrlist4_val; +} attrlist4; + +typedef struct { + u_int bitmap4_len; + uint32_t *bitmap4_val; +} bitmap4; + +typedef uint64_t changeid4; + +typedef uint64_t clientid4; + +typedef uint32_t count4; + +typedef uint64_t length4; + +typedef uint32_t mode4; + +typedef uint64_t nfs_cookie4; + +typedef struct { + u_int nfs_fh4_len; + char *nfs_fh4_val; +} nfs_fh4; + +typedef uint64_t offset4; + +typedef uint32_t qop4; + +typedef struct { + u_int sec_oid4_len; + char *sec_oid4_val; +} sec_oid4; + +typedef uint32_t sequenceid4; + +typedef uint32_t seqid4; + +typedef char sessionid4[NFS4_SESSIONID_SIZE]; + +typedef uint32_t slotid4; + +typedef struct { + u_int utf8string_len; + char *utf8string_val; +} utf8string; + +typedef utf8string utf8str_cis; + +typedef utf8string utf8str_cs; + +typedef utf8string utf8str_mixed; + +typedef utf8str_cs component4; + +typedef struct { + u_int linktext4_len; + char *linktext4_val; +} linktext4; + +typedef utf8string ascii_REQUIRED4; + +typedef struct { + u_int pathname4_len; + component4 *pathname4_val; +} pathname4; + +typedef char verifier4[NFS4_VERIFIER_SIZE]; + +typedef char *secret4; + +typedef uint32_t policy4; + +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; +typedef struct nfstime4 nfstime4; + +enum time_how4 { + SET_TO_SERVER_TIME4 = 0, + SET_TO_CLIENT_TIME4 = 1 +}; +typedef enum time_how4 time_how4; + +struct settime4 { + time_how4 set_it; + union { + nfstime4 time; + } settime4_u; +}; +typedef struct settime4 settime4; + +typedef uint32_t nfs_lease4; + +struct fsid4 { + uint64_t major; + uint64_t minor; +}; +typedef struct fsid4 fsid4; + +struct change_policy4 { + uint64_t cp_major; + uint64_t cp_minor; +}; +typedef struct change_policy4 change_policy4; + +struct fs_location4 { + struct { + u_int server_len; + utf8str_cis *server_val; + } server; + pathname4 rootpath; +}; +typedef struct fs_location4 fs_location4; + +struct fs_locations4 { + pathname4 fs_root; + struct { + u_int locations_len; + fs_location4 *locations_val; + } locations; +}; +typedef struct fs_locations4 fs_locations4; +#define ACL4_SUPPORT_ALLOW_ACL 0x00000001 +#define ACL4_SUPPORT_DENY_ACL 0x00000002 +#define ACL4_SUPPORT_AUDIT_ACL 0x00000004 +#define ACL4_SUPPORT_ALARM_ACL 0x00000008 + +typedef uint32_t acetype4; +#define ACE4_ACCESS_ALLOWED_ACE_TYPE 0x00000000 +#define ACE4_ACCESS_DENIED_ACE_TYPE 0x00000001 +#define ACE4_SYSTEM_AUDIT_ACE_TYPE 0x00000002 +#define ACE4_SYSTEM_ALARM_ACE_TYPE 0x00000003 + +typedef uint32_t aceflag4; +#define ACE4_FILE_INHERIT_ACE 0x00000001 +#define ACE4_DIRECTORY_INHERIT_ACE 0x00000002 +#define ACE4_NO_PROPAGATE_INHERIT_ACE 0x00000004 +#define ACE4_INHERIT_ONLY_ACE 0x00000008 +#define ACE4_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010 +#define ACE4_FAILED_ACCESS_ACE_FLAG 0x00000020 +#define ACE4_IDENTIFIER_GROUP 0x00000040 +#define ACE4_INHERITED_ACE 0x00000080 + +typedef uint32_t acemask4; +#define ACE4_READ_DATA 0x00000001 +#define ACE4_LIST_DIRECTORY 0x00000001 +#define ACE4_WRITE_DATA 0x00000002 +#define ACE4_ADD_FILE 0x00000002 +#define ACE4_APPEND_DATA 0x00000004 +#define ACE4_ADD_SUBDIRECTORY 0x00000004 +#define ACE4_READ_NAMED_ATTRS 0x00000008 +#define ACE4_WRITE_NAMED_ATTRS 0x00000010 +#define ACE4_EXECUTE 0x00000020 +#define ACE4_DELETE_CHILD 0x00000040 +#define ACE4_READ_ATTRIBUTES 0x00000080 +#define ACE4_WRITE_ATTRIBUTES 0x00000100 +#define ACE4_WRITE_RETENTION 0x00000200 +#define ACE4_WRITE_RETENTION_HOLD 0x00000400 +#define ACE4_DELETE 0x00010000 +#define ACE4_READ_ACL 0x00020000 +#define ACE4_WRITE_ACL 0x00040000 +#define ACE4_WRITE_OWNER 0x00080000 +#define ACE4_SYNCHRONIZE 0x00100000 +#define ACE4_GENERIC_READ 0x00120081 +#define ACE4_GENERIC_WRITE 0x00160106 +#define ACE4_GENERIC_EXECUTE 0x001200A0 + +struct nfsace4 { + acetype4 type; + aceflag4 flag; + acemask4 access_mask; + utf8str_mixed who; +}; +typedef struct nfsace4 nfsace4; + +typedef uint32_t aclflag4; +#define ACL4_AUTO_INHERIT 0x00000001 +#define ACL4_PROTECTED 0x00000002 +#define ACL4_DEFAULTED 0x00000004 + +struct nfsacl41 { + aclflag4 na41_flag; + struct { + u_int na41_aces_len; + nfsace4 *na41_aces_val; + } na41_aces; +}; +typedef struct nfsacl41 nfsacl41; +#define MODE4_SUID 0x800 +#define MODE4_SGID 0x400 +#define MODE4_SVTX 0x200 +#define MODE4_RUSR 0x100 +#define MODE4_WUSR 0x080 +#define MODE4_XUSR 0x040 +#define MODE4_RGRP 0x020 +#define MODE4_WGRP 0x010 +#define MODE4_XGRP 0x008 +#define MODE4_ROTH 0x004 +#define MODE4_WOTH 0x002 +#define MODE4_XOTH 0x001 + +struct mode_masked4 { + mode4 mm_value_to_set; + mode4 mm_mask_bits; +}; +typedef struct mode_masked4 mode_masked4; + +struct specdata4 { + uint32_t specdata1; + uint32_t specdata2; +}; +typedef struct specdata4 specdata4; +#define FH4_PERSISTENT 0x00000000 +#define FH4_NOEXPIRE_WITH_OPEN 0x00000001 +#define FH4_VOLATILE_ANY 0x00000002 +#define FH4_VOL_MIGRATION 0x00000004 +#define FH4_VOL_RENAME 0x00000008 + +struct netaddr4 { + char *na_r_netid; + char *na_r_addr; +}; +typedef struct netaddr4 netaddr4; + +struct nfs_impl_id4 { + utf8str_cis nii_domain; + utf8str_cs nii_name; + nfstime4 nii_date; +}; +typedef struct nfs_impl_id4 nfs_impl_id4; + +struct stateid4 { + uint32_t seqid; + char other[NFS4_OTHER_SIZE]; +}; +typedef struct stateid4 stateid4; + +enum layouttype4 { + LAYOUT4_NFSV4_1_FILES = 0x1, + LAYOUT4_OSD2_OBJECTS = 0x2, + LAYOUT4_BLOCK_VOLUME = 0x3 +}; +typedef enum layouttype4 layouttype4; + +struct layout_content4 { + layouttype4 loc_type; + struct { + u_int loc_body_len; + char *loc_body_val; + } loc_body; +}; +typedef struct layout_content4 layout_content4; +/* + * LAYOUT4_OSD2_OBJECTS loc_body description + * is in a separate .x file. + */ + +/* + * LAYOUT4_BLOCK_VOLUME loc_body description + * is in a separate .x file. + */ + +struct layouthint4 { + layouttype4 loh_type; + struct { + u_int loh_body_len; + char *loh_body_val; + } loh_body; +}; +typedef struct layouthint4 layouthint4; + +enum layoutiomode4 { + LAYOUTIOMODE4_READ = 1, + LAYOUTIOMODE4_RW = 2, + LAYOUTIOMODE4_ANY = 3 +}; +typedef enum layoutiomode4 layoutiomode4; + +struct layout4 { + offset4 lo_offset; + length4 lo_length; + layoutiomode4 lo_iomode; + layout_content4 lo_content; +}; +typedef struct layout4 layout4; +#define NFS4_DEVICEID4_SIZE 16 + +typedef char deviceid4[NFS4_DEVICEID4_SIZE]; + +struct device_addr4 { + layouttype4 da_layout_type; + struct { + u_int da_addr_body_len; + char *da_addr_body_val; + } da_addr_body; +}; +typedef struct device_addr4 device_addr4; + +struct layoutupdate4 { + layouttype4 lou_type; + struct { + u_int lou_body_len; + char *lou_body_val; + } lou_body; +}; +typedef struct layoutupdate4 layoutupdate4; + +#define LAYOUT4_RET_REC_FILE 1 +#define LAYOUT4_RET_REC_FSID 2 +#define LAYOUT4_RET_REC_ALL 3 + + +enum layoutreturn_type4 { + LAYOUTRETURN4_FILE = LAYOUT4_RET_REC_FILE, + LAYOUTRETURN4_FSID = LAYOUT4_RET_REC_FSID, + LAYOUTRETURN4_ALL = LAYOUT4_RET_REC_ALL +}; +typedef enum layoutreturn_type4 layoutreturn_type4; + /* layouttype4 specific data */ + +struct layoutreturn_file4 { + offset4 lrf_offset; + length4 lrf_length; + stateid4 lrf_stateid; + struct { + u_int lrf_body_len; + char *lrf_body_val; + } lrf_body; +}; +typedef struct layoutreturn_file4 layoutreturn_file4; + +struct layoutreturn4 { + layoutreturn_type4 lr_returntype; + union { + layoutreturn_file4 lr_layout; + } layoutreturn4_u; +}; +typedef struct layoutreturn4 layoutreturn4; + + +enum fs4_status_type { + STATUS4_FIXED = 1, + STATUS4_UPDATED = 2, + STATUS4_VERSIONED = 3, + STATUS4_WRITABLE = 4, + STATUS4_REFERRAL = 5 +}; +typedef enum fs4_status_type fs4_status_type; + +struct fs4_status { + bool_t fss_absent; + fs4_status_type fss_type; + utf8str_cs fss_source; + utf8str_cs fss_current; + int32_t fss_age; + nfstime4 fss_version; +}; +typedef struct fs4_status fs4_status; +#define TH4_READ_SIZE 0 +#define TH4_WRITE_SIZE 1 +#define TH4_READ_IOSIZE 2 +#define TH4_WRITE_IOSIZE 3 + +typedef length4 threshold4_read_size; + +typedef length4 threshold4_write_size; + +typedef length4 threshold4_read_iosize; + +typedef length4 threshold4_write_iosize; + +struct threshold_item4 { + layouttype4 thi_layout_type; + bitmap4 thi_hintset; + struct { + u_int thi_hintlist_len; + char *thi_hintlist_val; + } thi_hintlist; +}; +typedef struct threshold_item4 threshold_item4; + +struct mdsthreshold4 { + struct { + u_int mth_hints_len; + threshold_item4 *mth_hints_val; + } mth_hints; +}; +typedef struct mdsthreshold4 mdsthreshold4; +#define RET4_DURATION_INFINITE 0xffffffffffffffff + +struct retention_get4 { + uint64_t rg_duration; + struct { + u_int rg_begin_time_len; + nfstime4 *rg_begin_time_val; + } rg_begin_time; +}; +typedef struct retention_get4 retention_get4; + +struct retention_set4 { + bool_t rs_enable; + struct { + u_int rs_duration_len; + uint64_t *rs_duration_val; + } rs_duration; +}; +typedef struct retention_set4 retention_set4; +#define FSCHARSET_CAP4_CONTAINS_NON_UTF8 0x1 +#define FSCHARSET_CAP4_ALLOWS_ONLY_UTF8 0x2 + +typedef uint32_t fs_charset_cap4; + +enum netloc_type4 { + NL4_NAME = 1, + NL4_URL = 2, + NL4_NETADDR = 3 +}; +typedef enum netloc_type4 netloc_type4; + +struct netloc4 { + netloc_type4 nl_type; + union { + utf8str_cis nl_name; + utf8str_cis nl_url; + netaddr4 nl_addr; + } netloc4_u; +}; +typedef struct netloc4 netloc4; + +enum change_attr_type4 { + NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR = 0, + NFS4_CHANGE_TYPE_IS_VERSION_COUNTER = 1, + NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS = 2, + NFS4_CHANGE_TYPE_IS_TIME_METADATA = 3, + NFS4_CHANGE_TYPE_IS_UNDEFINED = 4 +}; +typedef enum change_attr_type4 change_attr_type4; + +struct labelformat_spec4 { + policy4 lfs_lfs; + policy4 lfs_pi; +}; +typedef struct labelformat_spec4 labelformat_spec4; + +struct sec_label4 { + labelformat_spec4 slai_lfs; + struct { + u_int slai_data_len; + char *slai_data_val; + } slai_data; +}; +typedef struct sec_label4 sec_label4; + +struct copy_from_auth_priv { + secret4 cfap_shared_secret; + netloc4 cfap_destination; + utf8str_mixed cfap_username; +}; +typedef struct copy_from_auth_priv copy_from_auth_priv; + +struct copy_to_auth_priv { + secret4 ctap_shared_secret; + struct { + u_int ctap_source_len; + netloc4 *ctap_source_val; + } ctap_source; + utf8str_mixed ctap_username; +}; +typedef struct copy_to_auth_priv copy_to_auth_priv; + +struct copy_confirm_auth_priv { + struct { + u_int ccap_shared_secret_mic_len; + char *ccap_shared_secret_mic_val; + } ccap_shared_secret_mic; + utf8str_mixed ccap_username; +}; +typedef struct copy_confirm_auth_priv copy_confirm_auth_priv; + +struct app_data_block4 { + offset4 adb_offset; + length4 adb_block_size; + length4 adb_block_count; + length4 adb_reloff_blocknum; + count4 adb_block_num; + length4 adb_reloff_pattern; + struct { + u_int adb_pattern_len; + char *adb_pattern_val; + } adb_pattern; +}; +typedef struct app_data_block4 app_data_block4; + +struct data4 { + offset4 d_offset; + struct { + u_int d_data_len; + char *d_data_val; + } d_data; +}; +typedef struct data4 data4; + +struct data_info4 { + offset4 di_offset; + length4 di_length; +}; +typedef struct data_info4 data_info4; + +enum data_content4 { + NFS4_CONTENT_DATA = 0, + NFS4_CONTENT_HOLE = 1 +}; +typedef enum data_content4 data_content4; + +enum stable_how4 { + UNSTABLE4 = 0, + DATA_SYNC4 = 1, + FILE_SYNC4 = 2 +}; +typedef enum stable_how4 stable_how4; + +struct write_response4 { + struct { + u_int wr_callback_id_len; + stateid4 *wr_callback_id_val; + } wr_callback_id; + length4 wr_count; + stable_how4 wr_committed; + verifier4 wr_writeverf; +}; +typedef struct write_response4 write_response4; + +typedef bitmap4 fattr4_supported_attrs; + +typedef nfs_ftype4 fattr4_type; + +typedef uint32_t fattr4_fh_expire_type; + +typedef changeid4 fattr4_change; + +typedef uint64_t fattr4_size; + +typedef bool_t fattr4_link_support; + +typedef bool_t fattr4_symlink_support; + +typedef bool_t fattr4_named_attr; + +typedef fsid4 fattr4_fsid; + +typedef bool_t fattr4_unique_handles; + +typedef nfs_lease4 fattr4_lease_time; + +typedef nfsstat4 fattr4_rdattr_error; + +typedef struct { + u_int fattr4_acl_len; + nfsace4 *fattr4_acl_val; +} fattr4_acl; + +typedef uint32_t fattr4_aclsupport; + +typedef bool_t fattr4_archive; + +typedef bool_t fattr4_cansettime; + +typedef bool_t fattr4_case_insensitive; + +typedef bool_t fattr4_case_preserving; + +typedef bool_t fattr4_chown_restricted; + +typedef uint64_t fattr4_fileid; + +typedef uint64_t fattr4_files_avail; + +typedef nfs_fh4 fattr4_filehandle; + +typedef uint64_t fattr4_files_free; + +typedef uint64_t fattr4_files_total; + +typedef fs_locations4 fattr4_fs_locations; + +typedef bool_t fattr4_hidden; + +typedef bool_t fattr4_homogeneous; + +typedef uint64_t fattr4_maxfilesize; + +typedef uint32_t fattr4_maxlink; + +typedef uint32_t fattr4_maxname; + +typedef uint64_t fattr4_maxread; + +typedef uint64_t fattr4_maxwrite; + +typedef ascii_REQUIRED4 fattr4_mimetype; + +typedef mode4 fattr4_mode; + +typedef mode_masked4 fattr4_mode_set_masked; + +typedef uint64_t fattr4_mounted_on_fileid; + +typedef bool_t fattr4_no_trunc; + +typedef uint32_t fattr4_numlinks; + +typedef utf8str_mixed fattr4_owner; + +typedef utf8str_mixed fattr4_owner_group; + +typedef uint64_t fattr4_quota_avail_hard; + +typedef uint64_t fattr4_quota_avail_soft; + +typedef uint64_t fattr4_quota_used; + +typedef specdata4 fattr4_rawdev; + +typedef uint64_t fattr4_space_avail; + +typedef length4 fattr4_space_free; + +typedef uint64_t fattr4_space_total; + +typedef uint64_t fattr4_space_used; + +typedef bool_t fattr4_system; + +typedef nfstime4 fattr4_time_access; + +typedef settime4 fattr4_time_access_set; + +typedef nfstime4 fattr4_time_backup; + +typedef nfstime4 fattr4_time_create; + +typedef nfstime4 fattr4_time_delta; + +typedef nfstime4 fattr4_time_metadata; + +typedef nfstime4 fattr4_time_modify; + +typedef settime4 fattr4_time_modify_set; + +typedef bitmap4 fattr4_suppattr_exclcreat; + +typedef nfstime4 fattr4_dir_notif_delay; + +typedef nfstime4 fattr4_dirent_notif_delay; + +typedef struct { + u_int fattr4_fs_layout_types_len; + layouttype4 *fattr4_fs_layout_types_val; +} fattr4_fs_layout_types; + +typedef fs4_status fattr4_fs_status; + +typedef fs_charset_cap4 fattr4_fs_charset_cap; + +typedef uint32_t fattr4_layout_alignment; + +typedef uint32_t fattr4_layout_blksize; + +typedef layouthint4 fattr4_layout_hint; + +typedef struct { + u_int fattr4_layout_types_len; + layouttype4 *fattr4_layout_types_val; +} fattr4_layout_types; + +typedef mdsthreshold4 fattr4_mdsthreshold; + +typedef retention_get4 fattr4_retention_get; + +typedef retention_set4 fattr4_retention_set; + +typedef retention_get4 fattr4_retentevt_get; + +typedef retention_set4 fattr4_retentevt_set; + +typedef uint64_t fattr4_retention_hold; + +typedef nfsacl41 fattr4_dacl; + +typedef nfsacl41 fattr4_sacl; + +typedef change_policy4 fattr4_change_policy; + +typedef uint64_t fattr4_space_freed; + +typedef change_attr_type4 fattr4_change_attr_type; + +typedef sec_label4 fattr4_sec_label; + +typedef uint32_t fattr4_clone_blksize; +/* + * REQUIRED attributes + */ +#define FATTR4_SUPPORTED_ATTRS 0 +#define FATTR4_TYPE 1 +#define FATTR4_FH_EXPIRE_TYPE 2 +#define FATTR4_CHANGE 3 +#define FATTR4_SIZE 4 +#define FATTR4_LINK_SUPPORT 5 +#define FATTR4_SYMLINK_SUPPORT 6 +#define FATTR4_NAMED_ATTR 7 +#define FATTR4_FSID 8 +#define FATTR4_UNIQUE_HANDLES 9 +#define FATTR4_LEASE_TIME 10 +#define FATTR4_RDATTR_ERROR 11 +#define FATTR4_FILEHANDLE 19 +/* + * New to NFSv4.1 + */ +#define FATTR4_SUPPATTR_EXCLCREAT 75 +/* + * RECOMMENDED attributes + */ +#define FATTR4_ACL 12 +#define FATTR4_ACLSUPPORT 13 +#define FATTR4_ARCHIVE 14 +#define FATTR4_CANSETTIME 15 +#define FATTR4_CASE_INSENSITIVE 16 +#define FATTR4_CASE_PRESERVING 17 +#define FATTR4_CHOWN_RESTRICTED 18 +#define FATTR4_FILEID 20 +#define FATTR4_FILES_AVAIL 21 +#define FATTR4_FILES_FREE 22 +#define FATTR4_FILES_TOTAL 23 +#define FATTR4_FS_LOCATIONS 24 +#define FATTR4_HIDDEN 25 +#define FATTR4_HOMOGENEOUS 26 +#define FATTR4_MAXFILESIZE 27 +#define FATTR4_MAXLINK 28 +#define FATTR4_MAXNAME 29 +#define FATTR4_MAXREAD 30 +#define FATTR4_MAXWRITE 31 +#define FATTR4_MIMETYPE 32 +#define FATTR4_MODE 33 +#define FATTR4_NO_TRUNC 34 +#define FATTR4_NUMLINKS 35 +#define FATTR4_OWNER 36 +#define FATTR4_OWNER_GROUP 37 +#define FATTR4_QUOTA_AVAIL_HARD 38 +#define FATTR4_QUOTA_AVAIL_SOFT 39 +#define FATTR4_QUOTA_USED 40 +#define FATTR4_RAWDEV 41 +#define FATTR4_SPACE_AVAIL 42 +#define FATTR4_SPACE_FREE 43 +#define FATTR4_SPACE_TOTAL 44 +#define FATTR4_SPACE_USED 45 +#define FATTR4_SYSTEM 46 +#define FATTR4_TIME_ACCESS 47 +#define FATTR4_TIME_ACCESS_SET 48 +#define FATTR4_TIME_BACKUP 49 +#define FATTR4_TIME_CREATE 50 +#define FATTR4_TIME_DELTA 51 +#define FATTR4_TIME_METADATA 52 +#define FATTR4_TIME_MODIFY 53 +#define FATTR4_TIME_MODIFY_SET 54 +#define FATTR4_MOUNTED_ON_FILEID 55 +/* + * New to NFSv4.1 + */ +#define FATTR4_DIR_NOTIF_DELAY 56 +#define FATTR4_DIRENT_NOTIF_DELAY 57 +#define FATTR4_DACL 58 +#define FATTR4_SACL 59 +#define FATTR4_CHANGE_POLICY 60 +#define FATTR4_FS_STATUS 61 +#define FATTR4_FS_LAYOUT_TYPES 62 +#define FATTR4_LAYOUT_HINT 63 +#define FATTR4_LAYOUT_TYPES 64 +#define FATTR4_LAYOUT_BLKSIZE 65 +#define FATTR4_LAYOUT_ALIGNMENT 66 +#define FATTR4_FS_LOCATIONS_INFO 67 +#define FATTR4_MDSTHRESHOLD 68 +#define FATTR4_RETENTION_GET 69 +#define FATTR4_RETENTION_SET 70 +#define FATTR4_RETENTEVT_GET 71 +#define FATTR4_RETENTEVT_SET 72 +#define FATTR4_RETENTION_HOLD 73 +#define FATTR4_MODE_SET_MASKED 74 +#define FATTR4_FS_CHARSET_CAP 76 +/* + * New to NFSv4.2 + */ +#define FATTR4_CLONE_BLKSIZE 77 +#define FATTR4_SPACE_FREED 78 +#define FATTR4_CHANGE_ATTR_TYPE 79 +#define FATTR4_SEC_LABEL 80 + +struct fattr4 { + bitmap4 attrmask; + attrlist4 attr_vals; +}; +typedef struct fattr4 fattr4; + +struct change_info4 { + bool_t atomic; + changeid4 before; + changeid4 after; +}; +typedef struct change_info4 change_info4; + +typedef netaddr4 clientaddr4; + +struct cb_client4 { + uint32_t cb_program; + netaddr4 cb_location; +}; +typedef struct cb_client4 cb_client4; + +struct nfs_client_id4 { + verifier4 verifier; + struct { + u_int id_len; + char *id_val; + } id; +}; +typedef struct nfs_client_id4 nfs_client_id4; + +struct client_owner4 { + verifier4 co_verifier; + struct { + u_int co_ownerid_len; + char *co_ownerid_val; + } co_ownerid; +}; +typedef struct client_owner4 client_owner4; + +struct server_owner4 { + uint64_t so_minor_id; + struct { + u_int so_major_id_len; + char *so_major_id_val; + } so_major_id; +}; +typedef struct server_owner4 server_owner4; + +struct state_owner4 { + clientid4 clientid; + struct { + u_int owner_len; + char *owner_val; + } owner; +}; +typedef struct state_owner4 state_owner4; + +typedef state_owner4 open_owner4; + +typedef state_owner4 lock_owner4; + +enum nfs_lock_type4 { + READ_LT = 1, + WRITE_LT = 2, + READW_LT = 3, + WRITEW_LT = 4 +}; +typedef enum nfs_lock_type4 nfs_lock_type4; + +/* Input for computing subkeys */ + +enum ssv_subkey4 { + SSV4_SUBKEY_MIC_I2T = 1, + SSV4_SUBKEY_MIC_T2I = 2, + SSV4_SUBKEY_SEAL_I2T = 3, + SSV4_SUBKEY_SEAL_T2I = 4 +}; +typedef enum ssv_subkey4 ssv_subkey4; + + +/* Input for computing smt_hmac */ + +struct ssv_mic_plain_tkn4 { + uint32_t smpt_ssv_seq; + struct { + u_int smpt_orig_plain_len; + char *smpt_orig_plain_val; + } smpt_orig_plain; +}; +typedef struct ssv_mic_plain_tkn4 ssv_mic_plain_tkn4; + + +/* + * Secret State Verifier Generic Security Service (SSV GSS) + * PerMsgToken token + */ + +struct ssv_mic_tkn4 { + uint32_t smt_ssv_seq; + struct { + u_int smt_hmac_len; + char *smt_hmac_val; + } smt_hmac; +}; +typedef struct ssv_mic_tkn4 ssv_mic_tkn4; + + +/* Input for computing ssct_encr_data and ssct_hmac */ + +struct ssv_seal_plain_tkn4 { + struct { + u_int sspt_confounder_len; + char *sspt_confounder_val; + } sspt_confounder; + uint32_t sspt_ssv_seq; + struct { + u_int sspt_orig_plain_len; + char *sspt_orig_plain_val; + } sspt_orig_plain; + struct { + u_int sspt_pad_len; + char *sspt_pad_val; + } sspt_pad; +}; +typedef struct ssv_seal_plain_tkn4 ssv_seal_plain_tkn4; + + +/* SSV GSS SealedMessage token */ + +struct ssv_seal_cipher_tkn4 { + uint32_t ssct_ssv_seq; + struct { + u_int ssct_iv_len; + char *ssct_iv_val; + } ssct_iv; + struct { + u_int ssct_encr_data_len; + char *ssct_encr_data_val; + } ssct_encr_data; + struct { + u_int ssct_hmac_len; + char *ssct_hmac_val; + } ssct_hmac; +}; +typedef struct ssv_seal_cipher_tkn4 ssv_seal_cipher_tkn4; + + +struct fs_locations_server4 { + int32_t fls_currency; + struct { + u_int fls_info_len; + char *fls_info_val; + } fls_info; + utf8str_cis fls_server; +}; +typedef struct fs_locations_server4 fs_locations_server4; +#define FSLI4BX_GFLAGS 0 +#define FSLI4BX_TFLAGS 1 +#define FSLI4BX_CLSIMUL 2 +#define FSLI4BX_CLHANDLE 3 +#define FSLI4BX_CLFILEID 4 +#define FSLI4BX_CLWRITEVER 5 +#define FSLI4BX_CLCHANGE 6 +#define FSLI4BX_CLREADDIR 7 +#define FSLI4BX_READRANK 8 +#define FSLI4BX_WRITERANK 9 +#define FSLI4BX_READORDER 10 +#define FSLI4BX_WRITEORDER 11 +#define FSLI4GF_WRITABLE 0x01 +#define FSLI4GF_CUR_REQ 0x02 +#define FSLI4GF_ABSENT 0x04 +#define FSLI4GF_GOING 0x08 +#define FSLI4GF_SPLIT 0x10 +#define FSLI4TF_RDMA 0x01 + +struct fs_locations_item4 { + struct { + u_int fli_entries_len; + fs_locations_server4 *fli_entries_val; + } fli_entries; + pathname4 fli_rootpath; +}; +typedef struct fs_locations_item4 fs_locations_item4; + +struct fs_locations_info4 { + uint32_t fli_flags; + int32_t fli_valid_for; + pathname4 fli_fs_root; + struct { + u_int fli_items_len; + fs_locations_item4 *fli_items_val; + } fli_items; +}; +typedef struct fs_locations_info4 fs_locations_info4; +#define FSLI4IF_VAR_SUB 0x00000001 + +typedef fs_locations_info4 fattr4_fs_locations_info; +#define NFL4_UFLG_MASK 0x0000003F +#define NFL4_UFLG_DENSE 0x00000001 +#define NFL4_UFLG_COMMIT_THRU_MDS 0x00000002 +#define NFL42_UFLG_IO_ADVISE_THRU_MDS 0x00000004 +#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0 + +typedef uint32_t nfl_util4; + + +enum filelayout_hint_care4 { + NFLH4_CARE_DENSE = NFL4_UFLG_DENSE, + NFLH4_CARE_COMMIT_THRU_MDS = NFL4_UFLG_COMMIT_THRU_MDS, + NFL42_CARE_IO_ADVISE_THRU_MDS = NFL42_UFLG_IO_ADVISE_THRU_MDS, + NFLH4_CARE_STRIPE_UNIT_SIZE = 0x00000040, + NFLH4_CARE_STRIPE_COUNT = 0x00000080 +}; +typedef enum filelayout_hint_care4 filelayout_hint_care4; + +/* + * Encoded in the loh_body field of data type layouthint4: + */ + + +struct nfsv4_1_file_layouthint4 { + uint32_t nflh_care; + nfl_util4 nflh_util; + count4 nflh_stripe_count; +}; +typedef struct nfsv4_1_file_layouthint4 nfsv4_1_file_layouthint4; + + + +typedef struct { + u_int multipath_list4_len; + netaddr4 *multipath_list4_val; +} multipath_list4; + +/* + * Encoded in the da_addr_body field of data type device_addr4: + */ + +struct nfsv4_1_file_layout_ds_addr4 { + struct { + u_int nflda_stripe_indices_len; + uint32_t *nflda_stripe_indices_val; + } nflda_stripe_indices; + struct { + u_int nflda_multipath_ds_list_len; + multipath_list4 *nflda_multipath_ds_list_val; + } nflda_multipath_ds_list; +}; +typedef struct nfsv4_1_file_layout_ds_addr4 nfsv4_1_file_layout_ds_addr4; + + +/* + * Encoded in the loc_body field of data type layout_content4: + */ + +struct nfsv4_1_file_layout4 { + deviceid4 nfl_deviceid; + nfl_util4 nfl_util; + uint32_t nfl_first_stripe_index; + offset4 nfl_pattern_offset; + struct { + u_int nfl_fh_list_len; + nfs_fh4 *nfl_fh_list_val; + } nfl_fh_list; +}; +typedef struct nfsv4_1_file_layout4 nfsv4_1_file_layout4; + + +/* New operations for NFSv4.1 */ + + +/* New operations for NFSv4.2 */ + + +enum nfs_opnum4 { + OP_ACCESS = 3, + OP_CLOSE = 4, + OP_COMMIT = 5, + OP_CREATE = 6, + OP_DELEGPURGE = 7, + OP_DELEGRETURN = 8, + OP_GETATTR = 9, + OP_GETFH = 10, + OP_LINK = 11, + OP_LOCK = 12, + OP_LOCKT = 13, + OP_LOCKU = 14, + OP_LOOKUP = 15, + OP_LOOKUPP = 16, + OP_NVERIFY = 17, + OP_OPEN = 18, + OP_OPENATTR = 19, + OP_OPEN_CONFIRM = 20, + OP_OPEN_DOWNGRADE = 21, + OP_PUTFH = 22, + OP_PUTPUBFH = 23, + OP_PUTROOTFH = 24, + OP_READ = 25, + OP_READDIR = 26, + OP_READLINK = 27, + OP_REMOVE = 28, + OP_RENAME = 29, + OP_RENEW = 30, + OP_RESTOREFH = 31, + OP_SAVEFH = 32, + OP_SECINFO = 33, + OP_SETATTR = 34, + OP_SETCLIENTID = 35, + OP_SETCLIENTID_CONFIRM = 36, + OP_VERIFY = 37, + OP_WRITE = 38, + OP_RELEASE_LOCKOWNER = 39, + OP_BACKCHANNEL_CTL = 40, + OP_BIND_CONN_TO_SESSION = 41, + OP_EXCHANGE_ID = 42, + OP_CREATE_SESSION = 43, + OP_DESTROY_SESSION = 44, + OP_FREE_STATEID = 45, + OP_GET_DIR_DELEGATION = 46, + OP_GETDEVICEINFO = 47, + OP_GETDEVICELIST = 48, + OP_LAYOUTCOMMIT = 49, + OP_LAYOUTGET = 50, + OP_LAYOUTRETURN = 51, + OP_SECINFO_NO_NAME = 52, + OP_SEQUENCE = 53, + OP_SET_SSV = 54, + OP_TEST_STATEID = 55, + OP_WANT_DELEGATION = 56, + OP_DESTROY_CLIENTID = 57, + OP_RECLAIM_COMPLETE = 58, + OP_ALLOCATE = 59, + OP_COPY = 60, + OP_COPY_NOTIFY = 61, + OP_DEALLOCATE = 62, + OP_IO_ADVISE = 63, + OP_LAYOUTERROR = 64, + OP_LAYOUTSTATS = 65, + OP_OFFLOAD_CANCEL = 66, + OP_OFFLOAD_STATUS = 67, + OP_READ_PLUS = 68, + OP_SEEK = 69, + OP_WRITE_SAME = 70, + OP_CLONE = 71, + OP_ILLEGAL = 10044 +}; +typedef enum nfs_opnum4 nfs_opnum4; +#define ACCESS4_READ 0x00000001 +#define ACCESS4_LOOKUP 0x00000002 +#define ACCESS4_MODIFY 0x00000004 +#define ACCESS4_EXTEND 0x00000008 +#define ACCESS4_DELETE 0x00000010 +#define ACCESS4_EXECUTE 0x00000020 + +struct ACCESS4args { + uint32_t access; +}; +typedef struct ACCESS4args ACCESS4args; + +struct ACCESS4resok { + uint32_t supported; + uint32_t access; +}; +typedef struct ACCESS4resok ACCESS4resok; + +struct ACCESS4res { + nfsstat4 status; + union { + ACCESS4resok resok4; + } ACCESS4res_u; +}; +typedef struct ACCESS4res ACCESS4res; + +struct CLONE4args { + stateid4 cl_src_stateid; + stateid4 cl_dst_stateid; + offset4 cl_src_offset; + offset4 cl_dst_offset; + length4 cl_count; +}; +typedef struct CLONE4args CLONE4args; + +struct CLONE4res { + nfsstat4 cl_status; +}; +typedef struct CLONE4res CLONE4res; + +struct CLOSE4args { + seqid4 seqid; + stateid4 open_stateid; +}; +typedef struct CLOSE4args CLOSE4args; + +struct CLOSE4res { + nfsstat4 status; + union { + stateid4 open_stateid; + } CLOSE4res_u; +}; +typedef struct CLOSE4res CLOSE4res; + +struct COMMIT4args { + offset4 offset; + count4 count; +}; +typedef struct COMMIT4args COMMIT4args; + +struct COMMIT4resok { + verifier4 writeverf; +}; +typedef struct COMMIT4resok COMMIT4resok; + +struct COMMIT4res { + nfsstat4 status; + union { + COMMIT4resok resok4; + } COMMIT4res_u; +}; +typedef struct COMMIT4res COMMIT4res; + +struct createtype4 { + nfs_ftype4 type; + union { + linktext4 linkdata; + specdata4 devdata; + } createtype4_u; +}; +typedef struct createtype4 createtype4; + +struct CREATE4args { + createtype4 objtype; + component4 objname; + fattr4 createattrs; +}; +typedef struct CREATE4args CREATE4args; + +struct CREATE4resok { + change_info4 cinfo; + bitmap4 attrset; +}; +typedef struct CREATE4resok CREATE4resok; + +struct CREATE4res { + nfsstat4 status; + union { + CREATE4resok resok4; + } CREATE4res_u; +}; +typedef struct CREATE4res CREATE4res; + +struct DELEGPURGE4args { + clientid4 clientid; +}; +typedef struct DELEGPURGE4args DELEGPURGE4args; + +struct DELEGPURGE4res { + nfsstat4 status; +}; +typedef struct DELEGPURGE4res DELEGPURGE4res; + +struct DELEGRETURN4args { + stateid4 deleg_stateid; +}; +typedef struct DELEGRETURN4args DELEGRETURN4args; + +struct DELEGRETURN4res { + nfsstat4 status; +}; +typedef struct DELEGRETURN4res DELEGRETURN4res; + +struct GETATTR4args { + bitmap4 attr_request; +}; +typedef struct GETATTR4args GETATTR4args; + +struct GETATTR4resok { + fattr4 obj_attributes; +}; +typedef struct GETATTR4resok GETATTR4resok; + +struct GETATTR4res { + nfsstat4 status; + union { + GETATTR4resok resok4; + } GETATTR4res_u; +}; +typedef struct GETATTR4res GETATTR4res; + +struct GETFH4resok { + nfs_fh4 object; +}; +typedef struct GETFH4resok GETFH4resok; + +struct GETFH4res { + nfsstat4 status; + union { + GETFH4resok resok4; + } GETFH4res_u; +}; +typedef struct GETFH4res GETFH4res; + +struct LINK4args { + component4 newname; +}; +typedef struct LINK4args LINK4args; + +struct LINK4resok { + change_info4 cinfo; +}; +typedef struct LINK4resok LINK4resok; + +struct LINK4res { + nfsstat4 status; + union { + LINK4resok resok4; + } LINK4res_u; +}; +typedef struct LINK4res LINK4res; + +struct open_to_lock_owner4 { + seqid4 open_seqid; + stateid4 open_stateid; + seqid4 lock_seqid; + lock_owner4 lock_owner; +}; +typedef struct open_to_lock_owner4 open_to_lock_owner4; + +struct exist_lock_owner4 { + stateid4 lock_stateid; + seqid4 lock_seqid; +}; +typedef struct exist_lock_owner4 exist_lock_owner4; + +struct locker4 { + bool_t new_lock_owner; + union { + open_to_lock_owner4 open_owner; + exist_lock_owner4 lock_owner; + } locker4_u; +}; +typedef struct locker4 locker4; + +struct LOCK4args { + nfs_lock_type4 locktype; + bool_t reclaim; + offset4 offset; + length4 length; + locker4 locker; +}; +typedef struct LOCK4args LOCK4args; + +struct LOCK4denied { + offset4 offset; + length4 length; + nfs_lock_type4 locktype; + lock_owner4 owner; +}; +typedef struct LOCK4denied LOCK4denied; + +struct LOCK4resok { + stateid4 lock_stateid; +}; +typedef struct LOCK4resok LOCK4resok; + +struct LOCK4res { + nfsstat4 status; + union { + LOCK4resok resok4; + LOCK4denied denied; + } LOCK4res_u; +}; +typedef struct LOCK4res LOCK4res; + +struct LOCKT4args { + nfs_lock_type4 locktype; + offset4 offset; + length4 length; + lock_owner4 owner; +}; +typedef struct LOCKT4args LOCKT4args; + +struct LOCKT4res { + nfsstat4 status; + union { + LOCK4denied denied; + } LOCKT4res_u; +}; +typedef struct LOCKT4res LOCKT4res; + +struct LOCKU4args { + nfs_lock_type4 locktype; + seqid4 seqid; + stateid4 lock_stateid; + offset4 offset; + length4 length; +}; +typedef struct LOCKU4args LOCKU4args; + +struct LOCKU4res { + nfsstat4 status; + union { + stateid4 lock_stateid; + } LOCKU4res_u; +}; +typedef struct LOCKU4res LOCKU4res; + +struct LOOKUP4args { + component4 objname; +}; +typedef struct LOOKUP4args LOOKUP4args; + +struct LOOKUP4res { + nfsstat4 status; +}; +typedef struct LOOKUP4res LOOKUP4res; + +struct LOOKUPP4res { + nfsstat4 status; +}; +typedef struct LOOKUPP4res LOOKUPP4res; + +struct NVERIFY4args { + fattr4 obj_attributes; +}; +typedef struct NVERIFY4args NVERIFY4args; + +struct NVERIFY4res { + nfsstat4 status; +}; +typedef struct NVERIFY4res NVERIFY4res; + +enum createmode4 { + UNCHECKED4 = 0, + GUARDED4 = 1, + EXCLUSIVE4 = 2, + EXCLUSIVE4_1 = 3 +}; +typedef enum createmode4 createmode4; + +struct creatverfattr { + verifier4 cva_verf; + fattr4 cva_attrs; +}; +typedef struct creatverfattr creatverfattr; + +struct createhow4 { + createmode4 mode; + union { + fattr4 createattrs; + verifier4 createverf; + creatverfattr ch_createboth; + } createhow4_u; +}; +typedef struct createhow4 createhow4; + +enum opentype4 { + OPEN4_NOCREATE = 0, + OPEN4_CREATE = 1 +}; +typedef enum opentype4 opentype4; + +struct openflag4 { + opentype4 opentype; + union { + createhow4 how; + } openflag4_u; +}; +typedef struct openflag4 openflag4; + +enum limit_by4 { + NFS_LIMIT_SIZE = 1, + NFS_LIMIT_BLOCKS = 2 +}; +typedef enum limit_by4 limit_by4; + +struct nfs_modified_limit4 { + uint32_t num_blocks; + uint32_t bytes_per_block; +}; +typedef struct nfs_modified_limit4 nfs_modified_limit4; + +struct nfs_space_limit4 { + limit_by4 limitby; + union { + uint64_t filesize; + nfs_modified_limit4 mod_blocks; + } nfs_space_limit4_u; +}; +typedef struct nfs_space_limit4 nfs_space_limit4; +#define OPEN4_SHARE_ACCESS_READ 0x00000001 +#define OPEN4_SHARE_ACCESS_WRITE 0x00000002 +#define OPEN4_SHARE_ACCESS_BOTH 0x00000003 +#define OPEN4_SHARE_DENY_NONE 0x00000000 +#define OPEN4_SHARE_DENY_READ 0x00000001 +#define OPEN4_SHARE_DENY_WRITE 0x00000002 +#define OPEN4_SHARE_DENY_BOTH 0x00000003 +#define OPEN4_SHARE_ACCESS_WANT_DELEG_MASK 0xFF00 +#define OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE 0x0000 +#define OPEN4_SHARE_ACCESS_WANT_READ_DELEG 0x0100 +#define OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG 0x0200 +#define OPEN4_SHARE_ACCESS_WANT_ANY_DELEG 0x0300 +#define OPEN4_SHARE_ACCESS_WANT_NO_DELEG 0x0400 +#define OPEN4_SHARE_ACCESS_WANT_CANCEL 0x0500 +#define OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL 0x10000 +#define OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED 0x20000 + +enum open_delegation_type4 { + OPEN_DELEGATE_NONE = 0, + OPEN_DELEGATE_READ = 1, + OPEN_DELEGATE_WRITE = 2, + OPEN_DELEGATE_NONE_EXT = 3 +}; +typedef enum open_delegation_type4 open_delegation_type4; + +enum open_claim_type4 { + CLAIM_NULL = 0, + CLAIM_PREVIOUS = 1, + CLAIM_DELEGATE_CUR = 2, + CLAIM_DELEGATE_PREV = 3, + CLAIM_FH = 4, + CLAIM_DELEG_CUR_FH = 5, + CLAIM_DELEG_PREV_FH = 6 +}; +typedef enum open_claim_type4 open_claim_type4; + +struct open_claim_delegate_cur4 { + stateid4 delegate_stateid; + component4 file; +}; +typedef struct open_claim_delegate_cur4 open_claim_delegate_cur4; + +struct open_claim4 { + open_claim_type4 claim; + union { + component4 file; + open_delegation_type4 delegate_type; + open_claim_delegate_cur4 delegate_cur_info; + component4 file_delegate_prev; + stateid4 oc_delegate_stateid; + } open_claim4_u; +}; +typedef struct open_claim4 open_claim4; + +struct OPEN4args { + seqid4 seqid; + uint32_t share_access; + uint32_t share_deny; + open_owner4 owner; + openflag4 openhow; + open_claim4 claim; +}; +typedef struct OPEN4args OPEN4args; + +struct open_read_delegation4 { + stateid4 stateid; + bool_t recall; + nfsace4 permissions; +}; +typedef struct open_read_delegation4 open_read_delegation4; + +struct open_write_delegation4 { + stateid4 stateid; + bool_t recall; + nfs_space_limit4 space_limit; + nfsace4 permissions; +}; +typedef struct open_write_delegation4 open_write_delegation4; + +enum why_no_delegation4 { + WND4_NOT_WANTED = 0, + WND4_CONTENTION = 1, + WND4_RESOURCE = 2, + WND4_NOT_SUPP_FTYPE = 3, + WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4, + WND4_NOT_SUPP_UPGRADE = 5, + WND4_NOT_SUPP_DOWNGRADE = 6, + WND4_CANCELLED = 7, + WND4_IS_DIR = 8 +}; +typedef enum why_no_delegation4 why_no_delegation4; + +struct open_none_delegation4 { + why_no_delegation4 ond_why; + union { + bool_t ond_server_will_push_deleg; + bool_t ond_server_will_signal_avail; + } open_none_delegation4_u; +}; +typedef struct open_none_delegation4 open_none_delegation4; + +struct open_delegation4 { + open_delegation_type4 delegation_type; + union { + open_read_delegation4 read; + open_write_delegation4 write; + open_none_delegation4 od_whynone; + } open_delegation4_u; +}; +typedef struct open_delegation4 open_delegation4; +#define OPEN4_RESULT_CONFIRM 0x00000002 +#define OPEN4_RESULT_LOCKTYPE_POSIX 0x00000004 +#define OPEN4_RESULT_PRESERVE_UNLINKED 0x00000008 +#define OPEN4_RESULT_MAY_NOTIFY_LOCK 0x00000020 + +struct OPEN4resok { + stateid4 stateid; + change_info4 cinfo; + uint32_t rflags; + bitmap4 attrset; + open_delegation4 delegation; +}; +typedef struct OPEN4resok OPEN4resok; + +struct OPEN4res { + nfsstat4 status; + union { + OPEN4resok resok4; + } OPEN4res_u; +}; +typedef struct OPEN4res OPEN4res; + +struct OPENATTR4args { + bool_t createdir; +}; +typedef struct OPENATTR4args OPENATTR4args; + +struct OPENATTR4res { + nfsstat4 status; +}; +typedef struct OPENATTR4res OPENATTR4res; + +struct OPEN_CONFIRM4args { + stateid4 open_stateid; + seqid4 seqid; +}; +typedef struct OPEN_CONFIRM4args OPEN_CONFIRM4args; + +struct OPEN_CONFIRM4resok { + stateid4 open_stateid; +}; +typedef struct OPEN_CONFIRM4resok OPEN_CONFIRM4resok; + +struct OPEN_CONFIRM4res { + nfsstat4 status; + union { + OPEN_CONFIRM4resok resok4; + } OPEN_CONFIRM4res_u; +}; +typedef struct OPEN_CONFIRM4res OPEN_CONFIRM4res; + +struct OPEN_DOWNGRADE4args { + stateid4 open_stateid; + seqid4 seqid; + uint32_t share_access; + uint32_t share_deny; +}; +typedef struct OPEN_DOWNGRADE4args OPEN_DOWNGRADE4args; + +struct OPEN_DOWNGRADE4resok { + stateid4 open_stateid; +}; +typedef struct OPEN_DOWNGRADE4resok OPEN_DOWNGRADE4resok; + +struct OPEN_DOWNGRADE4res { + nfsstat4 status; + union { + OPEN_DOWNGRADE4resok resok4; + } OPEN_DOWNGRADE4res_u; +}; +typedef struct OPEN_DOWNGRADE4res OPEN_DOWNGRADE4res; + +struct PUTFH4args { + nfs_fh4 object; +}; +typedef struct PUTFH4args PUTFH4args; + +struct PUTFH4res { + nfsstat4 status; +}; +typedef struct PUTFH4res PUTFH4res; + +struct PUTPUBFH4res { + nfsstat4 status; +}; +typedef struct PUTPUBFH4res PUTPUBFH4res; + +struct PUTROOTFH4res { + nfsstat4 status; +}; +typedef struct PUTROOTFH4res PUTROOTFH4res; + +struct READ4args { + stateid4 stateid; + offset4 offset; + count4 count; +}; +typedef struct READ4args READ4args; + +struct READ4resok { + bool_t eof; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct READ4resok READ4resok; + +struct READ4res { + nfsstat4 status; + union { + READ4resok resok4; + } READ4res_u; +}; +typedef struct READ4res READ4res; + +struct READDIR4args { + nfs_cookie4 cookie; + verifier4 cookieverf; + count4 dircount; + count4 maxcount; + bitmap4 attr_request; +}; +typedef struct READDIR4args READDIR4args; + +struct entry4 { + nfs_cookie4 cookie; + component4 name; + fattr4 attrs; + struct entry4 *nextentry; +}; +typedef struct entry4 entry4; + +struct dirlist4 { + entry4 *entries; + bool_t eof; +}; +typedef struct dirlist4 dirlist4; + +struct READDIR4resok { + verifier4 cookieverf; + dirlist4 reply; +}; +typedef struct READDIR4resok READDIR4resok; + +struct READDIR4res { + nfsstat4 status; + union { + READDIR4resok resok4; + } READDIR4res_u; +}; +typedef struct READDIR4res READDIR4res; + +struct READLINK4resok { + linktext4 link; +}; +typedef struct READLINK4resok READLINK4resok; + +struct READLINK4res { + nfsstat4 status; + union { + READLINK4resok resok4; + } READLINK4res_u; +}; +typedef struct READLINK4res READLINK4res; + +struct REMOVE4args { + component4 target; +}; +typedef struct REMOVE4args REMOVE4args; + +struct REMOVE4resok { + change_info4 cinfo; +}; +typedef struct REMOVE4resok REMOVE4resok; + +struct REMOVE4res { + nfsstat4 status; + union { + REMOVE4resok resok4; + } REMOVE4res_u; +}; +typedef struct REMOVE4res REMOVE4res; + +struct RENAME4args { + component4 oldname; + component4 newname; +}; +typedef struct RENAME4args RENAME4args; + +struct RENAME4resok { + change_info4 source_cinfo; + change_info4 target_cinfo; +}; +typedef struct RENAME4resok RENAME4resok; + +struct RENAME4res { + nfsstat4 status; + union { + RENAME4resok resok4; + } RENAME4res_u; +}; +typedef struct RENAME4res RENAME4res; + +struct RENEW4args { + clientid4 clientid; +}; +typedef struct RENEW4args RENEW4args; + +struct RENEW4res { + nfsstat4 status; +}; +typedef struct RENEW4res RENEW4res; + +struct RESTOREFH4res { + nfsstat4 status; +}; +typedef struct RESTOREFH4res RESTOREFH4res; + +struct SAVEFH4res { + nfsstat4 status; +}; +typedef struct SAVEFH4res SAVEFH4res; + +struct SECINFO4args { + component4 name; +}; +typedef struct SECINFO4args SECINFO4args; + +enum rpc_gss_svc_t { + RPC_GSS_SVC_NONE = 1, + RPC_GSS_SVC_INTEGRITY = 2, + RPC_GSS_SVC_PRIVACY = 3 +}; +typedef enum rpc_gss_svc_t rpc_gss_svc_t; + +struct rpcsec_gss_info { + sec_oid4 oid; + qop4 qop; + rpc_gss_svc_t service; +}; +typedef struct rpcsec_gss_info rpcsec_gss_info; + +struct secinfo4 { + uint32_t flavor; + union { + rpcsec_gss_info flavor_info; + } secinfo4_u; +}; +typedef struct secinfo4 secinfo4; + +typedef struct { + u_int SECINFO4resok_len; + secinfo4 *SECINFO4resok_val; +} SECINFO4resok; + +struct SECINFO4res { + nfsstat4 status; + union { + SECINFO4resok resok4; + } SECINFO4res_u; +}; +typedef struct SECINFO4res SECINFO4res; + +struct SETATTR4args { + stateid4 stateid; + fattr4 obj_attributes; +}; +typedef struct SETATTR4args SETATTR4args; + +struct SETATTR4res { + nfsstat4 status; + bitmap4 attrsset; +}; +typedef struct SETATTR4res SETATTR4res; + +struct SETCLIENTID4args { + nfs_client_id4 client; + cb_client4 callback; + uint32_t callback_ident; +}; +typedef struct SETCLIENTID4args SETCLIENTID4args; + +struct SETCLIENTID4resok { + clientid4 clientid; + verifier4 setclientid_confirm; +}; +typedef struct SETCLIENTID4resok SETCLIENTID4resok; + +struct SETCLIENTID4res { + nfsstat4 status; + union { + SETCLIENTID4resok resok4; + clientaddr4 client_using; + } SETCLIENTID4res_u; +}; +typedef struct SETCLIENTID4res SETCLIENTID4res; + +struct SETCLIENTID_CONFIRM4args { + clientid4 clientid; + verifier4 setclientid_confirm; +}; +typedef struct SETCLIENTID_CONFIRM4args SETCLIENTID_CONFIRM4args; + +struct SETCLIENTID_CONFIRM4res { + nfsstat4 status; +}; +typedef struct SETCLIENTID_CONFIRM4res SETCLIENTID_CONFIRM4res; + +struct VERIFY4args { + fattr4 obj_attributes; +}; +typedef struct VERIFY4args VERIFY4args; + +struct VERIFY4res { + nfsstat4 status; +}; +typedef struct VERIFY4res VERIFY4res; + +struct WRITE4args { + stateid4 stateid; + offset4 offset; + stable_how4 stable; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct WRITE4args WRITE4args; + +struct WRITE4resok { + count4 count; + stable_how4 committed; + verifier4 writeverf; +}; +typedef struct WRITE4resok WRITE4resok; + +struct WRITE4res { + nfsstat4 status; + union { + WRITE4resok resok4; + } WRITE4res_u; +}; +typedef struct WRITE4res WRITE4res; + +struct RELEASE_LOCKOWNER4args { + lock_owner4 lock_owner; +}; +typedef struct RELEASE_LOCKOWNER4args RELEASE_LOCKOWNER4args; + +struct RELEASE_LOCKOWNER4res { + nfsstat4 status; +}; +typedef struct RELEASE_LOCKOWNER4res RELEASE_LOCKOWNER4res; + +struct ILLEGAL4res { + nfsstat4 status; +}; +typedef struct ILLEGAL4res ILLEGAL4res; + +typedef struct { + u_int gsshandle4_t_len; + char *gsshandle4_t_val; +} gsshandle4_t; + +struct gss_cb_handles4 { + rpc_gss_svc_t gcbp_service; + gsshandle4_t gcbp_handle_from_server; + gsshandle4_t gcbp_handle_from_client; +}; +typedef struct gss_cb_handles4 gss_cb_handles4; + +struct callback_sec_parms4 { + uint32_t cb_secflavor; + union { + authsys_parms cbsp_sys_cred; + gss_cb_handles4 cbsp_gss_handles; + } callback_sec_parms4_u; +}; +typedef struct callback_sec_parms4 callback_sec_parms4; + +struct BACKCHANNEL_CTL4args { + uint32_t bca_cb_program; + struct { + u_int bca_sec_parms_len; + callback_sec_parms4 *bca_sec_parms_val; + } bca_sec_parms; +}; +typedef struct BACKCHANNEL_CTL4args BACKCHANNEL_CTL4args; + +struct BACKCHANNEL_CTL4res { + nfsstat4 bcr_status; +}; +typedef struct BACKCHANNEL_CTL4res BACKCHANNEL_CTL4res; + +enum channel_dir_from_client4 { + CDFC4_FORE = 0x1, + CDFC4_BACK = 0x2, + CDFC4_FORE_OR_BOTH = 0x3, + CDFC4_BACK_OR_BOTH = 0x7 +}; +typedef enum channel_dir_from_client4 channel_dir_from_client4; + +struct BIND_CONN_TO_SESSION4args { + sessionid4 bctsa_sessid; + channel_dir_from_client4 bctsa_dir; + bool_t bctsa_use_conn_in_rdma_mode; +}; +typedef struct BIND_CONN_TO_SESSION4args BIND_CONN_TO_SESSION4args; + +enum channel_dir_from_server4 { + CDFS4_FORE = 0x1, + CDFS4_BACK = 0x2, + CDFS4_BOTH = 0x3 +}; +typedef enum channel_dir_from_server4 channel_dir_from_server4; + +struct BIND_CONN_TO_SESSION4resok { + sessionid4 bctsr_sessid; + channel_dir_from_server4 bctsr_dir; + bool_t bctsr_use_conn_in_rdma_mode; +}; +typedef struct BIND_CONN_TO_SESSION4resok BIND_CONN_TO_SESSION4resok; + +struct BIND_CONN_TO_SESSION4res { + nfsstat4 bctsr_status; + union { + BIND_CONN_TO_SESSION4resok bctsr_resok4; + } BIND_CONN_TO_SESSION4res_u; +}; +typedef struct BIND_CONN_TO_SESSION4res BIND_CONN_TO_SESSION4res; +#define EXCHGID4_FLAG_SUPP_MOVED_REFER 0x00000001 +#define EXCHGID4_FLAG_SUPP_MOVED_MIGR 0x00000002 +#define EXCHGID4_FLAG_SUPP_FENCE_OPS 0x00000004 +#define EXCHGID4_FLAG_BIND_PRINC_STATEID 0x00000100 +#define EXCHGID4_FLAG_USE_NON_PNFS 0x00010000 +#define EXCHGID4_FLAG_USE_PNFS_MDS 0x00020000 +#define EXCHGID4_FLAG_USE_PNFS_DS 0x00040000 +#define EXCHGID4_FLAG_MASK_PNFS 0x00070000 +#define EXCHGID4_FLAG_UPD_CONFIRMED_REC_A 0x40000000 +#define EXCHGID4_FLAG_CONFIRMED_R 0x80000000 + +struct state_protect_ops4 { + bitmap4 spo_must_enforce; + bitmap4 spo_must_allow; +}; +typedef struct state_protect_ops4 state_protect_ops4; + +struct ssv_sp_parms4 { + state_protect_ops4 ssp_ops; + struct { + u_int ssp_hash_algs_len; + sec_oid4 *ssp_hash_algs_val; + } ssp_hash_algs; + struct { + u_int ssp_encr_algs_len; + sec_oid4 *ssp_encr_algs_val; + } ssp_encr_algs; + uint32_t ssp_window; + uint32_t ssp_num_gss_handles; +}; +typedef struct ssv_sp_parms4 ssv_sp_parms4; + +enum state_protect_how4 { + SP4_NONE = 0, + SP4_MACH_CRED = 1, + SP4_SSV = 2 +}; +typedef enum state_protect_how4 state_protect_how4; + +struct state_protect4_a { + state_protect_how4 spa_how; + union { + state_protect_ops4 spa_mach_ops; + ssv_sp_parms4 spa_ssv_parms; + } state_protect4_a_u; +}; +typedef struct state_protect4_a state_protect4_a; + +struct EXCHANGE_ID4args { + client_owner4 eia_clientowner; + uint32_t eia_flags; + state_protect4_a eia_state_protect; + struct { + u_int eia_client_impl_id_len; + nfs_impl_id4 *eia_client_impl_id_val; + } eia_client_impl_id; +}; +typedef struct EXCHANGE_ID4args EXCHANGE_ID4args; + +struct ssv_prot_info4 { + state_protect_ops4 spi_ops; + uint32_t spi_hash_alg; + uint32_t spi_encr_alg; + uint32_t spi_ssv_len; + uint32_t spi_window; + struct { + u_int spi_handles_len; + gsshandle4_t *spi_handles_val; + } spi_handles; +}; +typedef struct ssv_prot_info4 ssv_prot_info4; + +struct state_protect4_r { + state_protect_how4 spr_how; + union { + state_protect_ops4 spr_mach_ops; + ssv_prot_info4 spr_ssv_info; + } state_protect4_r_u; +}; +typedef struct state_protect4_r state_protect4_r; + +struct EXCHANGE_ID4resok { + clientid4 eir_clientid; + sequenceid4 eir_sequenceid; + uint32_t eir_flags; + state_protect4_r eir_state_protect; + server_owner4 eir_server_owner; + struct { + u_int eir_server_scope_len; + char *eir_server_scope_val; + } eir_server_scope; + struct { + u_int eir_server_impl_id_len; + nfs_impl_id4 *eir_server_impl_id_val; + } eir_server_impl_id; +}; +typedef struct EXCHANGE_ID4resok EXCHANGE_ID4resok; + +struct EXCHANGE_ID4res { + nfsstat4 eir_status; + union { + EXCHANGE_ID4resok eir_resok4; + } EXCHANGE_ID4res_u; +}; +typedef struct EXCHANGE_ID4res EXCHANGE_ID4res; + +struct channel_attrs4 { + count4 ca_headerpadsize; + count4 ca_maxrequestsize; + count4 ca_maxresponsesize; + count4 ca_maxresponsesize_cached; + count4 ca_maxoperations; + count4 ca_maxrequests; + struct { + u_int ca_rdma_ird_len; + uint32_t *ca_rdma_ird_val; + } ca_rdma_ird; +}; +typedef struct channel_attrs4 channel_attrs4; +#define CREATE_SESSION4_FLAG_PERSIST 0x00000001 +#define CREATE_SESSION4_FLAG_CONN_BACK_CHAN 0x00000002 +#define CREATE_SESSION4_FLAG_CONN_RDMA 0x00000004 + +struct CREATE_SESSION4args { + clientid4 csa_clientid; + sequenceid4 csa_sequence; + uint32_t csa_flags; + channel_attrs4 csa_fore_chan_attrs; + channel_attrs4 csa_back_chan_attrs; + uint32_t csa_cb_program; + struct { + u_int csa_sec_parms_len; + callback_sec_parms4 *csa_sec_parms_val; + } csa_sec_parms; +}; +typedef struct CREATE_SESSION4args CREATE_SESSION4args; + +struct CREATE_SESSION4resok { + sessionid4 csr_sessionid; + sequenceid4 csr_sequence; + uint32_t csr_flags; + channel_attrs4 csr_fore_chan_attrs; + channel_attrs4 csr_back_chan_attrs; +}; +typedef struct CREATE_SESSION4resok CREATE_SESSION4resok; + +struct CREATE_SESSION4res { + nfsstat4 csr_status; + union { + CREATE_SESSION4resok csr_resok4; + } CREATE_SESSION4res_u; +}; +typedef struct CREATE_SESSION4res CREATE_SESSION4res; + +struct DESTROY_SESSION4args { + sessionid4 dsa_sessionid; +}; +typedef struct DESTROY_SESSION4args DESTROY_SESSION4args; + +struct DESTROY_SESSION4res { + nfsstat4 dsr_status; +}; +typedef struct DESTROY_SESSION4res DESTROY_SESSION4res; + +struct FREE_STATEID4args { + stateid4 fsa_stateid; +}; +typedef struct FREE_STATEID4args FREE_STATEID4args; + +struct FREE_STATEID4res { + nfsstat4 fsr_status; +}; +typedef struct FREE_STATEID4res FREE_STATEID4res; + +typedef nfstime4 attr_notice4; + +struct GET_DIR_DELEGATION4args { + bool_t gdda_signal_deleg_avail; + bitmap4 gdda_notification_types; + attr_notice4 gdda_child_attr_delay; + attr_notice4 gdda_dir_attr_delay; + bitmap4 gdda_child_attributes; + bitmap4 gdda_dir_attributes; +}; +typedef struct GET_DIR_DELEGATION4args GET_DIR_DELEGATION4args; + +struct GET_DIR_DELEGATION4resok { + verifier4 gddr_cookieverf; + stateid4 gddr_stateid; + bitmap4 gddr_notification; + bitmap4 gddr_child_attributes; + bitmap4 gddr_dir_attributes; +}; +typedef struct GET_DIR_DELEGATION4resok GET_DIR_DELEGATION4resok; + +enum gddrnf4_status { + GDD4_OK = 0, + GDD4_UNAVAIL = 1 +}; +typedef enum gddrnf4_status gddrnf4_status; + +struct GET_DIR_DELEGATION4res_non_fatal { + gddrnf4_status gddrnf_status; + union { + GET_DIR_DELEGATION4resok gddrnf_resok4; + bool_t gddrnf_will_signal_deleg_avail; + } GET_DIR_DELEGATION4res_non_fatal_u; +}; +typedef struct GET_DIR_DELEGATION4res_non_fatal GET_DIR_DELEGATION4res_non_fatal; + +struct GET_DIR_DELEGATION4res { + nfsstat4 gddr_status; + union { + GET_DIR_DELEGATION4res_non_fatal gddr_res_non_fatal4; + } GET_DIR_DELEGATION4res_u; +}; +typedef struct GET_DIR_DELEGATION4res GET_DIR_DELEGATION4res; + +struct GETDEVICEINFO4args { + deviceid4 gdia_device_id; + layouttype4 gdia_layout_type; + count4 gdia_maxcount; + bitmap4 gdia_notify_types; +}; +typedef struct GETDEVICEINFO4args GETDEVICEINFO4args; + +struct GETDEVICEINFO4resok { + device_addr4 gdir_device_addr; + bitmap4 gdir_notification; +}; +typedef struct GETDEVICEINFO4resok GETDEVICEINFO4resok; + +struct GETDEVICEINFO4res { + nfsstat4 gdir_status; + union { + GETDEVICEINFO4resok gdir_resok4; + count4 gdir_mincount; + } GETDEVICEINFO4res_u; +}; +typedef struct GETDEVICEINFO4res GETDEVICEINFO4res; + +struct GETDEVICELIST4args { + layouttype4 gdla_layout_type; + count4 gdla_maxdevices; + nfs_cookie4 gdla_cookie; + verifier4 gdla_cookieverf; +}; +typedef struct GETDEVICELIST4args GETDEVICELIST4args; + +struct GETDEVICELIST4resok { + nfs_cookie4 gdlr_cookie; + verifier4 gdlr_cookieverf; + struct { + u_int gdlr_deviceid_list_len; + deviceid4 *gdlr_deviceid_list_val; + } gdlr_deviceid_list; + bool_t gdlr_eof; +}; +typedef struct GETDEVICELIST4resok GETDEVICELIST4resok; + +struct GETDEVICELIST4res { + nfsstat4 gdlr_status; + union { + GETDEVICELIST4resok gdlr_resok4; + } GETDEVICELIST4res_u; +}; +typedef struct GETDEVICELIST4res GETDEVICELIST4res; + +struct newtime4 { + bool_t nt_timechanged; + union { + nfstime4 nt_time; + } newtime4_u; +}; +typedef struct newtime4 newtime4; + +struct newoffset4 { + bool_t no_newoffset; + union { + offset4 no_offset; + } newoffset4_u; +}; +typedef struct newoffset4 newoffset4; + +struct LAYOUTCOMMIT4args { + offset4 loca_offset; + length4 loca_length; + bool_t loca_reclaim; + stateid4 loca_stateid; + newoffset4 loca_last_write_offset; + newtime4 loca_time_modify; + layoutupdate4 loca_layoutupdate; +}; +typedef struct LAYOUTCOMMIT4args LAYOUTCOMMIT4args; + +struct newsize4 { + bool_t ns_sizechanged; + union { + length4 ns_size; + } newsize4_u; +}; +typedef struct newsize4 newsize4; + +struct LAYOUTCOMMIT4resok { + newsize4 locr_newsize; +}; +typedef struct LAYOUTCOMMIT4resok LAYOUTCOMMIT4resok; + +struct LAYOUTCOMMIT4res { + nfsstat4 locr_status; + union { + LAYOUTCOMMIT4resok locr_resok4; + } LAYOUTCOMMIT4res_u; +}; +typedef struct LAYOUTCOMMIT4res LAYOUTCOMMIT4res; + +struct LAYOUTGET4args { + bool_t loga_signal_layout_avail; + layouttype4 loga_layout_type; + layoutiomode4 loga_iomode; + offset4 loga_offset; + length4 loga_length; + length4 loga_minlength; + stateid4 loga_stateid; + count4 loga_maxcount; +}; +typedef struct LAYOUTGET4args LAYOUTGET4args; + +struct LAYOUTGET4resok { + bool_t logr_return_on_close; + stateid4 logr_stateid; + struct { + u_int logr_layout_len; + layout4 *logr_layout_val; + } logr_layout; +}; +typedef struct LAYOUTGET4resok LAYOUTGET4resok; + +struct LAYOUTGET4res { + nfsstat4 logr_status; + union { + LAYOUTGET4resok logr_resok4; + bool_t logr_will_signal_layout_avail; + } LAYOUTGET4res_u; +}; +typedef struct LAYOUTGET4res LAYOUTGET4res; + +struct LAYOUTRETURN4args { + bool_t lora_reclaim; + layouttype4 lora_layout_type; + layoutiomode4 lora_iomode; + layoutreturn4 lora_layoutreturn; +}; +typedef struct LAYOUTRETURN4args LAYOUTRETURN4args; + +struct layoutreturn_stateid { + bool_t lrs_present; + union { + stateid4 lrs_stateid; + } layoutreturn_stateid_u; +}; +typedef struct layoutreturn_stateid layoutreturn_stateid; + +struct LAYOUTRETURN4res { + nfsstat4 lorr_status; + union { + layoutreturn_stateid lorr_stateid; + } LAYOUTRETURN4res_u; +}; +typedef struct LAYOUTRETURN4res LAYOUTRETURN4res; + +enum secinfo_style4 { + SECINFO_STYLE4_CURRENT_FH = 0, + SECINFO_STYLE4_PARENT = 1 +}; +typedef enum secinfo_style4 secinfo_style4; + +typedef secinfo_style4 SECINFO_NO_NAME4args; + +typedef SECINFO4res SECINFO_NO_NAME4res; + +struct SEQUENCE4args { + sessionid4 sa_sessionid; + sequenceid4 sa_sequenceid; + slotid4 sa_slotid; + slotid4 sa_highest_slotid; + bool_t sa_cachethis; +}; +typedef struct SEQUENCE4args SEQUENCE4args; +#define SEQ4_STATUS_CB_PATH_DOWN 0x00000001 +#define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING 0x00000002 +#define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED 0x00000004 +#define SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED 0x00000008 +#define SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED 0x00000010 +#define SEQ4_STATUS_ADMIN_STATE_REVOKED 0x00000020 +#define SEQ4_STATUS_RECALLABLE_STATE_REVOKED 0x00000040 +#define SEQ4_STATUS_LEASE_MOVED 0x00000080 +#define SEQ4_STATUS_RESTART_RECLAIM_NEEDED 0x00000100 +#define SEQ4_STATUS_CB_PATH_DOWN_SESSION 0x00000200 +#define SEQ4_STATUS_BACKCHANNEL_FAULT 0x00000400 +#define SEQ4_STATUS_DEVID_CHANGED 0x00000800 +#define SEQ4_STATUS_DEVID_DELETED 0x00001000 + +struct SEQUENCE4resok { + sessionid4 sr_sessionid; + sequenceid4 sr_sequenceid; + slotid4 sr_slotid; + slotid4 sr_highest_slotid; + slotid4 sr_target_highest_slotid; + uint32_t sr_status_flags; +}; +typedef struct SEQUENCE4resok SEQUENCE4resok; + +struct SEQUENCE4res { + nfsstat4 sr_status; + union { + SEQUENCE4resok sr_resok4; + } SEQUENCE4res_u; +}; +typedef struct SEQUENCE4res SEQUENCE4res; + +struct ssa_digest_input4 { + SEQUENCE4args sdi_seqargs; +}; +typedef struct ssa_digest_input4 ssa_digest_input4; + +struct SET_SSV4args { + struct { + u_int ssa_ssv_len; + char *ssa_ssv_val; + } ssa_ssv; + struct { + u_int ssa_digest_len; + char *ssa_digest_val; + } ssa_digest; +}; +typedef struct SET_SSV4args SET_SSV4args; + +struct ssr_digest_input4 { + SEQUENCE4res sdi_seqres; +}; +typedef struct ssr_digest_input4 ssr_digest_input4; + +struct SET_SSV4resok { + struct { + u_int ssr_digest_len; + char *ssr_digest_val; + } ssr_digest; +}; +typedef struct SET_SSV4resok SET_SSV4resok; + +struct SET_SSV4res { + nfsstat4 ssr_status; + union { + SET_SSV4resok ssr_resok4; + } SET_SSV4res_u; +}; +typedef struct SET_SSV4res SET_SSV4res; + +struct TEST_STATEID4args { + struct { + u_int ts_stateids_len; + stateid4 *ts_stateids_val; + } ts_stateids; +}; +typedef struct TEST_STATEID4args TEST_STATEID4args; + +struct TEST_STATEID4resok { + struct { + u_int tsr_status_codes_len; + nfsstat4 *tsr_status_codes_val; + } tsr_status_codes; +}; +typedef struct TEST_STATEID4resok TEST_STATEID4resok; + +struct TEST_STATEID4res { + nfsstat4 tsr_status; + union { + TEST_STATEID4resok tsr_resok4; + } TEST_STATEID4res_u; +}; +typedef struct TEST_STATEID4res TEST_STATEID4res; + +struct deleg_claim4 { + open_claim_type4 dc_claim; + union { + open_delegation_type4 dc_delegate_type; + } deleg_claim4_u; +}; +typedef struct deleg_claim4 deleg_claim4; + +struct WANT_DELEGATION4args { + uint32_t wda_want; + deleg_claim4 wda_claim; +}; +typedef struct WANT_DELEGATION4args WANT_DELEGATION4args; + +struct WANT_DELEGATION4res { + nfsstat4 wdr_status; + union { + open_delegation4 wdr_resok4; + } WANT_DELEGATION4res_u; +}; +typedef struct WANT_DELEGATION4res WANT_DELEGATION4res; + +struct DESTROY_CLIENTID4args { + clientid4 dca_clientid; +}; +typedef struct DESTROY_CLIENTID4args DESTROY_CLIENTID4args; + +struct DESTROY_CLIENTID4res { + nfsstat4 dcr_status; +}; +typedef struct DESTROY_CLIENTID4res DESTROY_CLIENTID4res; + +struct RECLAIM_COMPLETE4args { + bool_t rca_one_fs; +}; +typedef struct RECLAIM_COMPLETE4args RECLAIM_COMPLETE4args; + +struct RECLAIM_COMPLETE4res { + nfsstat4 rcr_status; +}; +typedef struct RECLAIM_COMPLETE4res RECLAIM_COMPLETE4res; + +struct COPY4args { + stateid4 ca_src_stateid; + stateid4 ca_dst_stateid; + offset4 ca_src_offset; + offset4 ca_dst_offset; + length4 ca_count; + bool_t ca_consecutive; + bool_t ca_synchronous; + struct { + u_int ca_source_server_len; + netloc4 *ca_source_server_val; + } ca_source_server; +}; +typedef struct COPY4args COPY4args; + +struct copy_requirements4 { + bool_t cr_consecutive; + bool_t cr_synchronous; +}; +typedef struct copy_requirements4 copy_requirements4; + +struct COPY4resok { + write_response4 cr_response; + copy_requirements4 cr_requirements; +}; +typedef struct COPY4resok COPY4resok; + +struct COPY4res { + nfsstat4 cr_status; + union { + COPY4resok cr_resok4; + copy_requirements4 cr_requirements; + } COPY4res_u; +}; +typedef struct COPY4res COPY4res; + +struct COPY_NOTIFY4args { + stateid4 cna_src_stateid; + netloc4 cna_destination_server; +}; +typedef struct COPY_NOTIFY4args COPY_NOTIFY4args; + +struct COPY_NOTIFY4resok { + nfstime4 cnr_lease_time; + stateid4 cnr_stateid; + struct { + u_int cnr_source_server_len; + netloc4 *cnr_source_server_val; + } cnr_source_server; +}; +typedef struct COPY_NOTIFY4resok COPY_NOTIFY4resok; + +struct COPY_NOTIFY4res { + nfsstat4 cnr_status; + union { + COPY_NOTIFY4resok resok4; + } COPY_NOTIFY4res_u; +}; +typedef struct COPY_NOTIFY4res COPY_NOTIFY4res; + +struct OFFLOAD_CANCEL4args { + stateid4 oca_stateid; +}; +typedef struct OFFLOAD_CANCEL4args OFFLOAD_CANCEL4args; + +struct OFFLOAD_CANCEL4res { + nfsstat4 ocr_status; +}; +typedef struct OFFLOAD_CANCEL4res OFFLOAD_CANCEL4res; + +struct OFFLOAD_STATUS4args { + stateid4 osa_stateid; +}; +typedef struct OFFLOAD_STATUS4args OFFLOAD_STATUS4args; + +struct OFFLOAD_STATUS4resok { + length4 osr_count; + struct { + u_int osr_complete_len; + nfsstat4 *osr_complete_val; + } osr_complete; +}; +typedef struct OFFLOAD_STATUS4resok OFFLOAD_STATUS4resok; + +struct OFFLOAD_STATUS4res { + nfsstat4 osr_status; + union { + OFFLOAD_STATUS4resok osr_resok4; + } OFFLOAD_STATUS4res_u; +}; +typedef struct OFFLOAD_STATUS4res OFFLOAD_STATUS4res; + +struct ALLOCATE4args { + stateid4 aa_stateid; + offset4 aa_offset; + length4 aa_length; +}; +typedef struct ALLOCATE4args ALLOCATE4args; + +struct ALLOCATE4res { + nfsstat4 ar_status; +}; +typedef struct ALLOCATE4res ALLOCATE4res; + +struct DEALLOCATE4args { + stateid4 da_stateid; + offset4 da_offset; + length4 da_length; +}; +typedef struct DEALLOCATE4args DEALLOCATE4args; + +struct DEALLOCATE4res { + nfsstat4 dr_status; +}; +typedef struct DEALLOCATE4res DEALLOCATE4res; + +enum IO_ADVISE_type4 { + IO_ADVISE4_NORMAL = 0, + IO_ADVISE4_SEQUENTIAL = 1, + IO_ADVISE4_SEQUENTIAL_BACKWARDS = 2, + IO_ADVISE4_RANDOM = 3, + IO_ADVISE4_WILLNEED = 4, + IO_ADVISE4_WILLNEED_OPPORTUNISTIC = 5, + IO_ADVISE4_DONTNEED = 6, + IO_ADVISE4_NOREUSE = 7, + IO_ADVISE4_READ = 8, + IO_ADVISE4_WRITE = 9, + IO_ADVISE4_INIT_PROXIMITY = 10 +}; +typedef enum IO_ADVISE_type4 IO_ADVISE_type4; + +struct IO_ADVISE4args { + stateid4 iaa_stateid; + offset4 iaa_offset; + length4 iaa_count; + bitmap4 iaa_hints; +}; +typedef struct IO_ADVISE4args IO_ADVISE4args; + +struct IO_ADVISE4resok { + bitmap4 ior_hints; +}; +typedef struct IO_ADVISE4resok IO_ADVISE4resok; + +struct IO_ADVISE4res { + nfsstat4 ior_status; + union { + IO_ADVISE4resok resok4; + } IO_ADVISE4res_u; +}; +typedef struct IO_ADVISE4res IO_ADVISE4res; + +struct device_error4 { + deviceid4 de_deviceid; + nfsstat4 de_status; + nfs_opnum4 de_opnum; +}; +typedef struct device_error4 device_error4; + +struct LAYOUTERROR4args { + offset4 lea_offset; + length4 lea_length; + stateid4 lea_stateid; + struct { + u_int lea_errors_len; + device_error4 *lea_errors_val; + } lea_errors; +}; +typedef struct LAYOUTERROR4args LAYOUTERROR4args; + +struct LAYOUTERROR4res { + nfsstat4 ler_status; +}; +typedef struct LAYOUTERROR4res LAYOUTERROR4res; + +struct io_info4 { + uint64_t ii_count; + uint64_t ii_bytes; +}; +typedef struct io_info4 io_info4; + +struct LAYOUTSTATS4args { + offset4 lsa_offset; + length4 lsa_length; + stateid4 lsa_stateid; + io_info4 lsa_read; + io_info4 lsa_write; + deviceid4 lsa_deviceid; + layoutupdate4 lsa_layoutupdate; +}; +typedef struct LAYOUTSTATS4args LAYOUTSTATS4args; + +struct LAYOUTSTATS4res { + nfsstat4 lsr_status; +}; +typedef struct LAYOUTSTATS4res LAYOUTSTATS4res; + +struct READ_PLUS4args { + stateid4 rpa_stateid; + offset4 rpa_offset; + count4 rpa_count; +}; +typedef struct READ_PLUS4args READ_PLUS4args; + +struct read_plus_content { + data_content4 rpc_content; + union { + data4 rpc_data; + data_info4 rpc_hole; + } read_plus_content_u; +}; +typedef struct read_plus_content read_plus_content; + +struct read_plus_res4 { + bool_t rpr_eof; + struct { + u_int rpr_contents_len; + read_plus_content *rpr_contents_val; + } rpr_contents; +}; +typedef struct read_plus_res4 read_plus_res4; + +struct READ_PLUS4res { + nfsstat4 rp_status; + union { + read_plus_res4 rp_resok4; + } READ_PLUS4res_u; +}; +typedef struct READ_PLUS4res READ_PLUS4res; + +struct SEEK4args { + stateid4 sa_stateid; + offset4 sa_offset; + data_content4 sa_what; +}; +typedef struct SEEK4args SEEK4args; + +struct seek_res4 { + bool_t sr_eof; + offset4 sr_offset; +}; +typedef struct seek_res4 seek_res4; + +struct SEEK4res { + nfsstat4 sa_status; + union { + seek_res4 resok4; + } SEEK4res_u; +}; +typedef struct SEEK4res SEEK4res; + +struct WRITE_SAME4args { + stateid4 wsa_stateid; + stable_how4 wsa_stable; + app_data_block4 wsa_adb; +}; +typedef struct WRITE_SAME4args WRITE_SAME4args; + +struct WRITE_SAME4res { + nfsstat4 wsr_status; + union { + write_response4 resok4; + } WRITE_SAME4res_u; +}; +typedef struct WRITE_SAME4res WRITE_SAME4res; + +struct nfs_argop4 { + nfs_opnum4 argop; + union { + ACCESS4args opaccess; + CLOSE4args opclose; + COMMIT4args opcommit; + CREATE4args opcreate; + DELEGPURGE4args opdelegpurge; + DELEGRETURN4args opdelegreturn; + GETATTR4args opgetattr; + LINK4args oplink; + LOCK4args oplock; + LOCKT4args oplockt; + LOCKU4args oplocku; + LOOKUP4args oplookup; + NVERIFY4args opnverify; + OPEN4args opopen; + OPENATTR4args opopenattr; + OPEN_CONFIRM4args opopen_confirm; + OPEN_DOWNGRADE4args opopen_downgrade; + PUTFH4args opputfh; + READ4args opread; + READDIR4args opreaddir; + REMOVE4args opremove; + RENAME4args oprename; + RENEW4args oprenew; + SECINFO4args opsecinfo; + SETATTR4args opsetattr; + SETCLIENTID4args opsetclientid; + SETCLIENTID_CONFIRM4args opsetclientid_confirm; + VERIFY4args opverify; + WRITE4args opwrite; + RELEASE_LOCKOWNER4args oprelease_lockowner; + BACKCHANNEL_CTL4args opbackchannel_ctl; + BIND_CONN_TO_SESSION4args opbind_conn_to_session; + EXCHANGE_ID4args opexchange_id; + CREATE_SESSION4args opcreate_session; + DESTROY_SESSION4args opdestroy_session; + FREE_STATEID4args opfree_stateid; + GET_DIR_DELEGATION4args opget_dir_delegation; + GETDEVICEINFO4args opgetdeviceinfo; + GETDEVICELIST4args opgetdevicelist; + LAYOUTCOMMIT4args oplayoutcommit; + LAYOUTGET4args oplayoutget; + LAYOUTRETURN4args oplayoutreturn; + SECINFO_NO_NAME4args opsecinfo_no_name; + SEQUENCE4args opsequence; + SET_SSV4args opset_ssv; + TEST_STATEID4args optest_stateid; + WANT_DELEGATION4args opwant_delegation; + DESTROY_CLIENTID4args opdestroy_clientid; + RECLAIM_COMPLETE4args opreclaim_complete; + ALLOCATE4args opallocate; + COPY4args opcopy; + COPY_NOTIFY4args opoffload_notify; + DEALLOCATE4args opdeallocate; + IO_ADVISE4args opio_advise; + LAYOUTERROR4args oplayouterror; + LAYOUTSTATS4args oplayoutstats; + OFFLOAD_CANCEL4args opoffload_cancel; + OFFLOAD_STATUS4args opoffload_status; + READ_PLUS4args opread_plus; + SEEK4args opseek; + WRITE_SAME4args opwrite_same; + CLONE4args opclone; + } nfs_argop4_u; +}; +typedef struct nfs_argop4 nfs_argop4; + +struct nfs_resop4 { + nfs_opnum4 resop; + union { + ACCESS4res opaccess; + CLOSE4res opclose; + COMMIT4res opcommit; + CREATE4res opcreate; + DELEGPURGE4res opdelegpurge; + DELEGRETURN4res opdelegreturn; + GETATTR4res opgetattr; + GETFH4res opgetfh; + LINK4res oplink; + LOCK4res oplock; + LOCKT4res oplockt; + LOCKU4res oplocku; + LOOKUP4res oplookup; + LOOKUPP4res oplookupp; + NVERIFY4res opnverify; + OPEN4res opopen; + OPENATTR4res opopenattr; + OPEN_CONFIRM4res opopen_confirm; + OPEN_DOWNGRADE4res opopen_downgrade; + PUTFH4res opputfh; + PUTPUBFH4res opputpubfh; + PUTROOTFH4res opputrootfh; + READ4res opread; + READDIR4res opreaddir; + READLINK4res opreadlink; + REMOVE4res opremove; + RENAME4res oprename; + RENEW4res oprenew; + RESTOREFH4res oprestorefh; + SAVEFH4res opsavefh; + SECINFO4res opsecinfo; + SETATTR4res opsetattr; + SETCLIENTID4res opsetclientid; + SETCLIENTID_CONFIRM4res opsetclientid_confirm; + VERIFY4res opverify; + WRITE4res opwrite; + RELEASE_LOCKOWNER4res oprelease_lockowner; + BACKCHANNEL_CTL4res opbackchannel_ctl; + BIND_CONN_TO_SESSION4res opbind_conn_to_session; + EXCHANGE_ID4res opexchange_id; + CREATE_SESSION4res opcreate_session; + DESTROY_SESSION4res opdestroy_session; + FREE_STATEID4res opfree_stateid; + GET_DIR_DELEGATION4res opget_dir_delegation; + GETDEVICEINFO4res opgetdeviceinfo; + GETDEVICELIST4res opgetdevicelist; + LAYOUTCOMMIT4res oplayoutcommit; + LAYOUTGET4res oplayoutget; + LAYOUTRETURN4res oplayoutreturn; + SECINFO_NO_NAME4res opsecinfo_no_name; + SEQUENCE4res opsequence; + SET_SSV4res opset_ssv; + TEST_STATEID4res optest_stateid; + WANT_DELEGATION4res opwant_delegation; + DESTROY_CLIENTID4res opdestroy_clientid; + RECLAIM_COMPLETE4res opreclaim_complete; + ALLOCATE4res opallocate; + COPY4res opcopy; + COPY_NOTIFY4res opcopy_notify; + DEALLOCATE4res opdeallocate; + IO_ADVISE4res opio_advise; + LAYOUTERROR4res oplayouterror; + LAYOUTSTATS4res oplayoutstats; + OFFLOAD_CANCEL4res opoffload_cancel; + OFFLOAD_STATUS4res opoffload_status; + READ_PLUS4res opread_plus; + SEEK4res opseek; + WRITE_SAME4res opwrite_same; + CLONE4res opclone; + ILLEGAL4res opillegal; + } nfs_resop4_u; +}; +typedef struct nfs_resop4 nfs_resop4; + +struct COMPOUND4args { + utf8str_cs tag; + uint32_t minorversion; + struct { + u_int argarray_len; + nfs_argop4 *argarray_val; + } argarray; +}; +typedef struct COMPOUND4args COMPOUND4args; + +struct COMPOUND4res { + nfsstat4 status; + utf8str_cs tag; + struct { + u_int resarray_len; + nfs_resop4 *resarray_val; + } resarray; +}; +typedef struct COMPOUND4res COMPOUND4res; + +struct CB_GETATTR4args { + nfs_fh4 fh; + bitmap4 attr_request; +}; +typedef struct CB_GETATTR4args CB_GETATTR4args; + +struct CB_GETATTR4resok { + fattr4 obj_attributes; +}; +typedef struct CB_GETATTR4resok CB_GETATTR4resok; + +struct CB_GETATTR4res { + nfsstat4 status; + union { + CB_GETATTR4resok resok4; + } CB_GETATTR4res_u; +}; +typedef struct CB_GETATTR4res CB_GETATTR4res; + +struct CB_RECALL4args { + stateid4 stateid; + bool_t truncate; + nfs_fh4 fh; +}; +typedef struct CB_RECALL4args CB_RECALL4args; + +struct CB_RECALL4res { + nfsstat4 status; +}; +typedef struct CB_RECALL4res CB_RECALL4res; + +struct CB_ILLEGAL4res { + nfsstat4 status; +}; +typedef struct CB_ILLEGAL4res CB_ILLEGAL4res; + +enum layoutrecall_type4 { + LAYOUTRECALL4_FILE = LAYOUT4_RET_REC_FILE, + LAYOUTRECALL4_FSID = LAYOUT4_RET_REC_FSID, + LAYOUTRECALL4_ALL = LAYOUT4_RET_REC_ALL +}; +typedef enum layoutrecall_type4 layoutrecall_type4; + +struct layoutrecall_file4 { + nfs_fh4 lor_fh; + offset4 lor_offset; + length4 lor_length; + stateid4 lor_stateid; +}; +typedef struct layoutrecall_file4 layoutrecall_file4; + +struct layoutrecall4 { + layoutrecall_type4 lor_recalltype; + union { + layoutrecall_file4 lor_layout; + fsid4 lor_fsid; + } layoutrecall4_u; +}; +typedef struct layoutrecall4 layoutrecall4; + +struct CB_LAYOUTRECALL4args { + layouttype4 clora_type; + layoutiomode4 clora_iomode; + bool_t clora_changed; + layoutrecall4 clora_recall; +}; +typedef struct CB_LAYOUTRECALL4args CB_LAYOUTRECALL4args; + +struct CB_LAYOUTRECALL4res { + nfsstat4 clorr_status; +}; +typedef struct CB_LAYOUTRECALL4res CB_LAYOUTRECALL4res; + +enum notify_type4 { + NOTIFY4_CHANGE_CHILD_ATTRS = 0, + NOTIFY4_CHANGE_DIR_ATTRS = 1, + NOTIFY4_REMOVE_ENTRY = 2, + NOTIFY4_ADD_ENTRY = 3, + NOTIFY4_RENAME_ENTRY = 4, + NOTIFY4_CHANGE_COOKIE_VERIFIER = 5 +}; +typedef enum notify_type4 notify_type4; + +struct notify_entry4 { + component4 ne_file; + fattr4 ne_attrs; +}; +typedef struct notify_entry4 notify_entry4; + +struct prev_entry4 { + notify_entry4 pe_prev_entry; + nfs_cookie4 pe_prev_entry_cookie; +}; +typedef struct prev_entry4 prev_entry4; + +struct notify_remove4 { + notify_entry4 nrm_old_entry; + nfs_cookie4 nrm_old_entry_cookie; +}; +typedef struct notify_remove4 notify_remove4; + +struct notify_add4 { + struct { + u_int nad_old_entry_len; + notify_remove4 *nad_old_entry_val; + } nad_old_entry; + notify_entry4 nad_new_entry; + struct { + u_int nad_new_entry_cookie_len; + nfs_cookie4 *nad_new_entry_cookie_val; + } nad_new_entry_cookie; + struct { + u_int nad_prev_entry_len; + prev_entry4 *nad_prev_entry_val; + } nad_prev_entry; + bool_t nad_last_entry; +}; +typedef struct notify_add4 notify_add4; + +struct notify_attr4 { + notify_entry4 na_changed_entry; +}; +typedef struct notify_attr4 notify_attr4; + +struct notify_rename4 { + notify_remove4 nrn_old_entry; + notify_add4 nrn_new_entry; +}; +typedef struct notify_rename4 notify_rename4; + +struct notify_verifier4 { + verifier4 nv_old_cookieverf; + verifier4 nv_new_cookieverf; +}; +typedef struct notify_verifier4 notify_verifier4; + +typedef struct { + u_int notifylist4_len; + char *notifylist4_val; +} notifylist4; + +struct notify4 { + bitmap4 notify_mask; + notifylist4 notify_vals; +}; +typedef struct notify4 notify4; + +struct CB_NOTIFY4args { + stateid4 cna_stateid; + nfs_fh4 cna_fh; + struct { + u_int cna_changes_len; + notify4 *cna_changes_val; + } cna_changes; +}; +typedef struct CB_NOTIFY4args CB_NOTIFY4args; + +struct CB_NOTIFY4res { + nfsstat4 cnr_status; +}; +typedef struct CB_NOTIFY4res CB_NOTIFY4res; + +struct CB_PUSH_DELEG4args { + nfs_fh4 cpda_fh; + open_delegation4 cpda_delegation; +}; +typedef struct CB_PUSH_DELEG4args CB_PUSH_DELEG4args; + +struct CB_PUSH_DELEG4res { + nfsstat4 cpdr_status; +}; +typedef struct CB_PUSH_DELEG4res CB_PUSH_DELEG4res; +#define RCA4_TYPE_MASK_RDATA_DLG 0 +#define RCA4_TYPE_MASK_WDATA_DLG 1 +#define RCA4_TYPE_MASK_DIR_DLG 2 +#define RCA4_TYPE_MASK_FILE_LAYOUT 3 +#define RCA4_TYPE_MASK_BLK_LAYOUT 4 +#define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN 8 +#define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX 9 +#define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12 +#define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15 + +struct CB_RECALL_ANY4args { + uint32_t craa_objects_to_keep; + bitmap4 craa_type_mask; +}; +typedef struct CB_RECALL_ANY4args CB_RECALL_ANY4args; + +struct CB_RECALL_ANY4res { + nfsstat4 crar_status; +}; +typedef struct CB_RECALL_ANY4res CB_RECALL_ANY4res; + +typedef CB_RECALL_ANY4args CB_RECALLABLE_OBJ_AVAIL4args; + +struct CB_RECALLABLE_OBJ_AVAIL4res { + nfsstat4 croa_status; +}; +typedef struct CB_RECALLABLE_OBJ_AVAIL4res CB_RECALLABLE_OBJ_AVAIL4res; + +struct CB_RECALL_SLOT4args { + slotid4 rsa_target_highest_slotid; +}; +typedef struct CB_RECALL_SLOT4args CB_RECALL_SLOT4args; + +struct CB_RECALL_SLOT4res { + nfsstat4 rsr_status; +}; +typedef struct CB_RECALL_SLOT4res CB_RECALL_SLOT4res; + +struct referring_call4 { + sequenceid4 rc_sequenceid; + slotid4 rc_slotid; +}; +typedef struct referring_call4 referring_call4; + +struct referring_call_list4 { + sessionid4 rcl_sessionid; + struct { + u_int rcl_referring_calls_len; + referring_call4 *rcl_referring_calls_val; + } rcl_referring_calls; +}; +typedef struct referring_call_list4 referring_call_list4; + +struct CB_SEQUENCE4args { + sessionid4 csa_sessionid; + sequenceid4 csa_sequenceid; + slotid4 csa_slotid; + slotid4 csa_highest_slotid; + bool_t csa_cachethis; + struct { + u_int csa_referring_call_lists_len; + referring_call_list4 *csa_referring_call_lists_val; + } csa_referring_call_lists; +}; +typedef struct CB_SEQUENCE4args CB_SEQUENCE4args; + +struct CB_SEQUENCE4resok { + sessionid4 csr_sessionid; + sequenceid4 csr_sequenceid; + slotid4 csr_slotid; + slotid4 csr_highest_slotid; + slotid4 csr_target_highest_slotid; +}; +typedef struct CB_SEQUENCE4resok CB_SEQUENCE4resok; + +struct CB_SEQUENCE4res { + nfsstat4 csr_status; + union { + CB_SEQUENCE4resok csr_resok4; + } CB_SEQUENCE4res_u; +}; +typedef struct CB_SEQUENCE4res CB_SEQUENCE4res; + +struct CB_WANTS_CANCELLED4args { + bool_t cwca_contended_wants_cancelled; + bool_t cwca_resourced_wants_cancelled; +}; +typedef struct CB_WANTS_CANCELLED4args CB_WANTS_CANCELLED4args; + +struct CB_WANTS_CANCELLED4res { + nfsstat4 cwcr_status; +}; +typedef struct CB_WANTS_CANCELLED4res CB_WANTS_CANCELLED4res; + +struct CB_NOTIFY_LOCK4args { + nfs_fh4 cnla_fh; + lock_owner4 cnla_lock_owner; +}; +typedef struct CB_NOTIFY_LOCK4args CB_NOTIFY_LOCK4args; + +struct CB_NOTIFY_LOCK4res { + nfsstat4 cnlr_status; +}; +typedef struct CB_NOTIFY_LOCK4res CB_NOTIFY_LOCK4res; + +enum notify_deviceid_type4 { + NOTIFY_DEVICEID4_CHANGE = 1, + NOTIFY_DEVICEID4_DELETE = 2 +}; +typedef enum notify_deviceid_type4 notify_deviceid_type4; + +struct notify_deviceid_delete4 { + layouttype4 ndd_layouttype; + deviceid4 ndd_deviceid; +}; +typedef struct notify_deviceid_delete4 notify_deviceid_delete4; + +struct notify_deviceid_change4 { + layouttype4 ndc_layouttype; + deviceid4 ndc_deviceid; + bool_t ndc_immediate; +}; +typedef struct notify_deviceid_change4 notify_deviceid_change4; + +struct CB_NOTIFY_DEVICEID4args { + struct { + u_int cnda_changes_len; + notify4 *cnda_changes_val; + } cnda_changes; +}; +typedef struct CB_NOTIFY_DEVICEID4args CB_NOTIFY_DEVICEID4args; + +struct CB_NOTIFY_DEVICEID4res { + nfsstat4 cndr_status; +}; +typedef struct CB_NOTIFY_DEVICEID4res CB_NOTIFY_DEVICEID4res; + +struct offload_info4 { + nfsstat4 coa_status; + union { + write_response4 coa_resok4; + length4 coa_bytes_copied; + } offload_info4_u; +}; +typedef struct offload_info4 offload_info4; + +struct CB_OFFLOAD4args { + nfs_fh4 coa_fh; + stateid4 coa_stateid; + offload_info4 coa_offload_info; +}; +typedef struct CB_OFFLOAD4args CB_OFFLOAD4args; + +struct CB_OFFLOAD4res { + nfsstat4 cor_status; +}; +typedef struct CB_OFFLOAD4res CB_OFFLOAD4res; + +/* Callback operations new to NFSv4.1 */ +/* Callback operations new to NFSv4.2 */ + +enum nfs_cb_opnum4 { + OP_CB_GETATTR = 3, + OP_CB_RECALL = 4, + OP_CB_LAYOUTRECALL = 5, + OP_CB_NOTIFY = 6, + OP_CB_PUSH_DELEG = 7, + OP_CB_RECALL_ANY = 8, + OP_CB_RECALLABLE_OBJ_AVAIL = 9, + OP_CB_RECALL_SLOT = 10, + OP_CB_SEQUENCE = 11, + OP_CB_WANTS_CANCELLED = 12, + OP_CB_NOTIFY_LOCK = 13, + OP_CB_NOTIFY_DEVICEID = 14, + OP_CB_OFFLOAD = 15, + OP_CB_ILLEGAL = 10044 +}; +typedef enum nfs_cb_opnum4 nfs_cb_opnum4; + +struct nfs_cb_argop4 { + nfs_cb_opnum4 argop; + union { + CB_GETATTR4args opcbgetattr; + CB_RECALL4args opcbrecall; + CB_LAYOUTRECALL4args opcblayoutrecall; + CB_NOTIFY4args opcbnotify; + CB_PUSH_DELEG4args opcbpush_deleg; + CB_RECALL_ANY4args opcbrecall_any; + CB_RECALLABLE_OBJ_AVAIL4args opcbrecallable_obj_avail; + CB_RECALL_SLOT4args opcbrecall_slot; + CB_SEQUENCE4args opcbsequence; + CB_WANTS_CANCELLED4args opcbwants_cancelled; + CB_NOTIFY_LOCK4args opcbnotify_lock; + CB_NOTIFY_DEVICEID4args opcbnotify_deviceid; + CB_OFFLOAD4args opcboffload; + } nfs_cb_argop4_u; +}; +typedef struct nfs_cb_argop4 nfs_cb_argop4; + +struct nfs_cb_resop4 { + nfs_cb_opnum4 resop; + union { + CB_GETATTR4res opcbgetattr; + CB_RECALL4res opcbrecall; + CB_LAYOUTRECALL4res opcblayoutrecall; + CB_NOTIFY4res opcbnotify; + CB_PUSH_DELEG4res opcbpush_deleg; + CB_RECALL_ANY4res opcbrecall_any; + CB_RECALLABLE_OBJ_AVAIL4res opcbrecallable_obj_avail; + CB_RECALL_SLOT4res opcbrecall_slot; + CB_SEQUENCE4res opcbsequence; + CB_WANTS_CANCELLED4res opcbwants_cancelled; + CB_NOTIFY_LOCK4res opcbnotify_lock; + CB_NOTIFY_DEVICEID4res opcbnotify_deviceid; + CB_OFFLOAD4res opcboffload; + CB_ILLEGAL4res opcbillegal; + } nfs_cb_resop4_u; +}; +typedef struct nfs_cb_resop4 nfs_cb_resop4; + +struct CB_COMPOUND4args { + utf8str_cs tag; + uint32_t minorversion; + uint32_t callback_ident; + struct { + u_int argarray_len; + nfs_cb_argop4 *argarray_val; + } argarray; +}; +typedef struct CB_COMPOUND4args CB_COMPOUND4args; + +struct CB_COMPOUND4res { + nfsstat4 status; + utf8str_cs tag; + struct { + u_int resarray_len; + nfs_cb_resop4 *resarray_val; + } resarray; +}; +typedef struct CB_COMPOUND4res CB_COMPOUND4res; + +#define NFS4_PROGRAM 100003 +#define NFS_V4 4 + +#if defined(__STDC__) || defined(__cplusplus) +#define NFSPROC4_NULL 0 +extern void * nfsproc4_null_4(void *, CLIENT *); +extern void * nfsproc4_null_4_svc(void *, struct svc_req *); +#define NFSPROC4_COMPOUND 1 +extern COMPOUND4res * nfsproc4_compound_4(COMPOUND4args *, CLIENT *); +extern COMPOUND4res * nfsproc4_compound_4_svc(COMPOUND4args *, struct svc_req *); +extern int nfs4_program_4_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define NFSPROC4_NULL 0 +extern void * nfsproc4_null_4(); +extern void * nfsproc4_null_4_svc(); +#define NFSPROC4_COMPOUND 1 +extern COMPOUND4res * nfsproc4_compound_4(); +extern COMPOUND4res * nfsproc4_compound_4_svc(); +extern int nfs4_program_4_freeresult(); +#endif /* K&R C */ + +#define NFS4_CALLBACK 0x40000000 +#define NFS_CB 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define CB_NULL 0 +extern void * cb_null_1(void *, CLIENT *); +extern void * cb_null_1_svc(void *, struct svc_req *); +#define CB_COMPOUND 1 +extern CB_COMPOUND4res * cb_compound_1(CB_COMPOUND4args *, CLIENT *); +extern CB_COMPOUND4res * cb_compound_1_svc(CB_COMPOUND4args *, struct svc_req *); +extern int nfs4_callback_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define CB_NULL 0 +extern void * cb_null_1(); +extern void * cb_null_1_svc(); +#define CB_COMPOUND 1 +extern CB_COMPOUND4res * cb_compound_1(); +extern CB_COMPOUND4res * cb_compound_1_svc(); +extern int nfs4_callback_1_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_nfs_ftype4(XDR *, nfs_ftype4*); +extern bool_t xdr_nfsstat4(XDR *, nfsstat4*); +extern bool_t xdr_attrlist4(XDR *, attrlist4*); +extern bool_t xdr_bitmap4(XDR *, bitmap4*); +extern bool_t xdr_changeid4(XDR *, changeid4*); +extern bool_t xdr_clientid4(XDR *, clientid4*); +extern bool_t xdr_count4(XDR *, count4*); +extern bool_t xdr_length4(XDR *, length4*); +extern bool_t xdr_mode4(XDR *, mode4*); +extern bool_t xdr_nfs_cookie4(XDR *, nfs_cookie4*); +extern bool_t xdr_nfs_fh4(XDR *, nfs_fh4*); +extern bool_t xdr_offset4(XDR *, offset4*); +extern bool_t xdr_qop4(XDR *, qop4*); +extern bool_t xdr_sec_oid4(XDR *, sec_oid4*); +extern bool_t xdr_sequenceid4(XDR *, sequenceid4*); +extern bool_t xdr_seqid4(XDR *, seqid4*); +extern bool_t xdr_sessionid4(XDR *, sessionid4); +extern bool_t xdr_slotid4(XDR *, slotid4*); +extern bool_t xdr_utf8string(XDR *, utf8string*); +extern bool_t xdr_utf8str_cis(XDR *, utf8str_cis*); +extern bool_t xdr_utf8str_cs(XDR *, utf8str_cs*); +extern bool_t xdr_utf8str_mixed(XDR *, utf8str_mixed*); +extern bool_t xdr_component4(XDR *, component4*); +extern bool_t xdr_linktext4(XDR *, linktext4*); +extern bool_t xdr_ascii_REQUIRED4(XDR *, ascii_REQUIRED4*); +extern bool_t xdr_pathname4(XDR *, pathname4*); +extern bool_t xdr_verifier4(XDR *, verifier4); +extern bool_t xdr_secret4(XDR *, secret4*); +extern bool_t xdr_policy4(XDR *, policy4*); +extern bool_t xdr_nfstime4(XDR *, nfstime4*); +extern bool_t xdr_time_how4(XDR *, time_how4*); +extern bool_t xdr_settime4(XDR *, settime4*); +extern bool_t xdr_nfs_lease4(XDR *, nfs_lease4*); +extern bool_t xdr_fsid4(XDR *, fsid4*); +extern bool_t xdr_change_policy4(XDR *, change_policy4*); +extern bool_t xdr_fs_location4(XDR *, fs_location4*); +extern bool_t xdr_fs_locations4(XDR *, fs_locations4*); +extern bool_t xdr_acetype4(XDR *, acetype4*); +extern bool_t xdr_aceflag4(XDR *, aceflag4*); +extern bool_t xdr_acemask4(XDR *, acemask4*); +extern bool_t xdr_nfsace4(XDR *, nfsace4*); +extern bool_t xdr_aclflag4(XDR *, aclflag4*); +extern bool_t xdr_nfsacl41(XDR *, nfsacl41*); +extern bool_t xdr_mode_masked4(XDR *, mode_masked4*); +extern bool_t xdr_specdata4(XDR *, specdata4*); +extern bool_t xdr_netaddr4(XDR *, netaddr4*); +extern bool_t xdr_nfs_impl_id4(XDR *, nfs_impl_id4*); +extern bool_t xdr_stateid4(XDR *, stateid4*); +extern bool_t xdr_layouttype4(XDR *, layouttype4*); +extern bool_t xdr_layout_content4(XDR *, layout_content4*); +extern bool_t xdr_layouthint4(XDR *, layouthint4*); +extern bool_t xdr_layoutiomode4(XDR *, layoutiomode4*); +extern bool_t xdr_layout4(XDR *, layout4*); +extern bool_t xdr_deviceid4(XDR *, deviceid4); +extern bool_t xdr_device_addr4(XDR *, device_addr4*); +extern bool_t xdr_layoutupdate4(XDR *, layoutupdate4*); +extern bool_t xdr_layoutreturn_type4(XDR *, layoutreturn_type4*); +extern bool_t xdr_layoutreturn_file4(XDR *, layoutreturn_file4*); +extern bool_t xdr_layoutreturn4(XDR *, layoutreturn4*); +extern bool_t xdr_fs4_status_type(XDR *, fs4_status_type*); +extern bool_t xdr_fs4_status(XDR *, fs4_status*); +extern bool_t xdr_threshold4_read_size(XDR *, threshold4_read_size*); +extern bool_t xdr_threshold4_write_size(XDR *, threshold4_write_size*); +extern bool_t xdr_threshold4_read_iosize(XDR *, threshold4_read_iosize*); +extern bool_t xdr_threshold4_write_iosize(XDR *, threshold4_write_iosize*); +extern bool_t xdr_threshold_item4(XDR *, threshold_item4*); +extern bool_t xdr_mdsthreshold4(XDR *, mdsthreshold4*); +extern bool_t xdr_retention_get4(XDR *, retention_get4*); +extern bool_t xdr_retention_set4(XDR *, retention_set4*); +extern bool_t xdr_fs_charset_cap4(XDR *, fs_charset_cap4*); +extern bool_t xdr_netloc_type4(XDR *, netloc_type4*); +extern bool_t xdr_netloc4(XDR *, netloc4*); +extern bool_t xdr_change_attr_type4(XDR *, change_attr_type4*); +extern bool_t xdr_labelformat_spec4(XDR *, labelformat_spec4*); +extern bool_t xdr_sec_label4(XDR *, sec_label4*); +extern bool_t xdr_copy_from_auth_priv(XDR *, copy_from_auth_priv*); +extern bool_t xdr_copy_to_auth_priv(XDR *, copy_to_auth_priv*); +extern bool_t xdr_copy_confirm_auth_priv(XDR *, copy_confirm_auth_priv*); +extern bool_t xdr_app_data_block4(XDR *, app_data_block4*); +extern bool_t xdr_data4(XDR *, data4*); +extern bool_t xdr_data_info4(XDR *, data_info4*); +extern bool_t xdr_data_content4(XDR *, data_content4*); +extern bool_t xdr_stable_how4(XDR *, stable_how4*); +extern bool_t xdr_write_response4(XDR *, write_response4*); +extern bool_t xdr_fattr4_supported_attrs(XDR *, fattr4_supported_attrs*); +extern bool_t xdr_fattr4_type(XDR *, fattr4_type*); +extern bool_t xdr_fattr4_fh_expire_type(XDR *, fattr4_fh_expire_type*); +extern bool_t xdr_fattr4_change(XDR *, fattr4_change*); +extern bool_t xdr_fattr4_size(XDR *, fattr4_size*); +extern bool_t xdr_fattr4_link_support(XDR *, fattr4_link_support*); +extern bool_t xdr_fattr4_symlink_support(XDR *, fattr4_symlink_support*); +extern bool_t xdr_fattr4_named_attr(XDR *, fattr4_named_attr*); +extern bool_t xdr_fattr4_fsid(XDR *, fattr4_fsid*); +extern bool_t xdr_fattr4_unique_handles(XDR *, fattr4_unique_handles*); +extern bool_t xdr_fattr4_lease_time(XDR *, fattr4_lease_time*); +extern bool_t xdr_fattr4_rdattr_error(XDR *, fattr4_rdattr_error*); +extern bool_t xdr_fattr4_acl(XDR *, fattr4_acl*); +extern bool_t xdr_fattr4_aclsupport(XDR *, fattr4_aclsupport*); +extern bool_t xdr_fattr4_archive(XDR *, fattr4_archive*); +extern bool_t xdr_fattr4_cansettime(XDR *, fattr4_cansettime*); +extern bool_t xdr_fattr4_case_insensitive(XDR *, fattr4_case_insensitive*); +extern bool_t xdr_fattr4_case_preserving(XDR *, fattr4_case_preserving*); +extern bool_t xdr_fattr4_chown_restricted(XDR *, fattr4_chown_restricted*); +extern bool_t xdr_fattr4_fileid(XDR *, fattr4_fileid*); +extern bool_t xdr_fattr4_files_avail(XDR *, fattr4_files_avail*); +extern bool_t xdr_fattr4_filehandle(XDR *, fattr4_filehandle*); +extern bool_t xdr_fattr4_files_free(XDR *, fattr4_files_free*); +extern bool_t xdr_fattr4_files_total(XDR *, fattr4_files_total*); +extern bool_t xdr_fattr4_fs_locations(XDR *, fattr4_fs_locations*); +extern bool_t xdr_fattr4_hidden(XDR *, fattr4_hidden*); +extern bool_t xdr_fattr4_homogeneous(XDR *, fattr4_homogeneous*); +extern bool_t xdr_fattr4_maxfilesize(XDR *, fattr4_maxfilesize*); +extern bool_t xdr_fattr4_maxlink(XDR *, fattr4_maxlink*); +extern bool_t xdr_fattr4_maxname(XDR *, fattr4_maxname*); +extern bool_t xdr_fattr4_maxread(XDR *, fattr4_maxread*); +extern bool_t xdr_fattr4_maxwrite(XDR *, fattr4_maxwrite*); +extern bool_t xdr_fattr4_mimetype(XDR *, fattr4_mimetype*); +extern bool_t xdr_fattr4_mode(XDR *, fattr4_mode*); +extern bool_t xdr_fattr4_mode_set_masked(XDR *, fattr4_mode_set_masked*); +extern bool_t xdr_fattr4_mounted_on_fileid(XDR *, fattr4_mounted_on_fileid*); +extern bool_t xdr_fattr4_no_trunc(XDR *, fattr4_no_trunc*); +extern bool_t xdr_fattr4_numlinks(XDR *, fattr4_numlinks*); +extern bool_t xdr_fattr4_owner(XDR *, fattr4_owner*); +extern bool_t xdr_fattr4_owner_group(XDR *, fattr4_owner_group*); +extern bool_t xdr_fattr4_quota_avail_hard(XDR *, fattr4_quota_avail_hard*); +extern bool_t xdr_fattr4_quota_avail_soft(XDR *, fattr4_quota_avail_soft*); +extern bool_t xdr_fattr4_quota_used(XDR *, fattr4_quota_used*); +extern bool_t xdr_fattr4_rawdev(XDR *, fattr4_rawdev*); +extern bool_t xdr_fattr4_space_avail(XDR *, fattr4_space_avail*); +extern bool_t xdr_fattr4_space_free(XDR *, fattr4_space_free*); +extern bool_t xdr_fattr4_space_total(XDR *, fattr4_space_total*); +extern bool_t xdr_fattr4_space_used(XDR *, fattr4_space_used*); +extern bool_t xdr_fattr4_system(XDR *, fattr4_system*); +extern bool_t xdr_fattr4_time_access(XDR *, fattr4_time_access*); +extern bool_t xdr_fattr4_time_access_set(XDR *, fattr4_time_access_set*); +extern bool_t xdr_fattr4_time_backup(XDR *, fattr4_time_backup*); +extern bool_t xdr_fattr4_time_create(XDR *, fattr4_time_create*); +extern bool_t xdr_fattr4_time_delta(XDR *, fattr4_time_delta*); +extern bool_t xdr_fattr4_time_metadata(XDR *, fattr4_time_metadata*); +extern bool_t xdr_fattr4_time_modify(XDR *, fattr4_time_modify*); +extern bool_t xdr_fattr4_time_modify_set(XDR *, fattr4_time_modify_set*); +extern bool_t xdr_fattr4_suppattr_exclcreat(XDR *, fattr4_suppattr_exclcreat*); +extern bool_t xdr_fattr4_dir_notif_delay(XDR *, fattr4_dir_notif_delay*); +extern bool_t xdr_fattr4_dirent_notif_delay(XDR *, fattr4_dirent_notif_delay*); +extern bool_t xdr_fattr4_fs_layout_types(XDR *, fattr4_fs_layout_types*); +extern bool_t xdr_fattr4_fs_status(XDR *, fattr4_fs_status*); +extern bool_t xdr_fattr4_fs_charset_cap(XDR *, fattr4_fs_charset_cap*); +extern bool_t xdr_fattr4_layout_alignment(XDR *, fattr4_layout_alignment*); +extern bool_t xdr_fattr4_layout_blksize(XDR *, fattr4_layout_blksize*); +extern bool_t xdr_fattr4_layout_hint(XDR *, fattr4_layout_hint*); +extern bool_t xdr_fattr4_layout_types(XDR *, fattr4_layout_types*); +extern bool_t xdr_fattr4_mdsthreshold(XDR *, fattr4_mdsthreshold*); +extern bool_t xdr_fattr4_retention_get(XDR *, fattr4_retention_get*); +extern bool_t xdr_fattr4_retention_set(XDR *, fattr4_retention_set*); +extern bool_t xdr_fattr4_retentevt_get(XDR *, fattr4_retentevt_get*); +extern bool_t xdr_fattr4_retentevt_set(XDR *, fattr4_retentevt_set*); +extern bool_t xdr_fattr4_retention_hold(XDR *, fattr4_retention_hold*); +extern bool_t xdr_fattr4_dacl(XDR *, fattr4_dacl*); +extern bool_t xdr_fattr4_sacl(XDR *, fattr4_sacl*); +extern bool_t xdr_fattr4_change_policy(XDR *, fattr4_change_policy*); +extern bool_t xdr_fattr4_space_freed(XDR *, fattr4_space_freed*); +extern bool_t xdr_fattr4_change_attr_type(XDR *, fattr4_change_attr_type*); +extern bool_t xdr_fattr4_sec_label(XDR *, fattr4_sec_label*); +extern bool_t xdr_fattr4_clone_blksize(XDR *, fattr4_clone_blksize*); +extern bool_t xdr_fattr4(XDR *, fattr4*); +extern bool_t xdr_change_info4(XDR *, change_info4*); +extern bool_t xdr_clientaddr4(XDR *, clientaddr4*); +extern bool_t xdr_cb_client4(XDR *, cb_client4*); +extern bool_t xdr_nfs_client_id4(XDR *, nfs_client_id4*); +extern bool_t xdr_client_owner4(XDR *, client_owner4*); +extern bool_t xdr_server_owner4(XDR *, server_owner4*); +extern bool_t xdr_state_owner4(XDR *, state_owner4*); +extern bool_t xdr_open_owner4(XDR *, open_owner4*); +extern bool_t xdr_lock_owner4(XDR *, lock_owner4*); +extern bool_t xdr_nfs_lock_type4(XDR *, nfs_lock_type4*); +extern bool_t xdr_ssv_subkey4(XDR *, ssv_subkey4*); +extern bool_t xdr_ssv_mic_plain_tkn4(XDR *, ssv_mic_plain_tkn4*); +extern bool_t xdr_ssv_mic_tkn4(XDR *, ssv_mic_tkn4*); +extern bool_t xdr_ssv_seal_plain_tkn4(XDR *, ssv_seal_plain_tkn4*); +extern bool_t xdr_ssv_seal_cipher_tkn4(XDR *, ssv_seal_cipher_tkn4*); +extern bool_t xdr_fs_locations_server4(XDR *, fs_locations_server4*); +extern bool_t xdr_fs_locations_item4(XDR *, fs_locations_item4*); +extern bool_t xdr_fs_locations_info4(XDR *, fs_locations_info4*); +extern bool_t xdr_fattr4_fs_locations_info(XDR *, fattr4_fs_locations_info*); +extern bool_t xdr_nfl_util4(XDR *, nfl_util4*); +extern bool_t xdr_filelayout_hint_care4(XDR *, filelayout_hint_care4*); +extern bool_t xdr_nfsv4_1_file_layouthint4(XDR *, nfsv4_1_file_layouthint4*); +extern bool_t xdr_multipath_list4(XDR *, multipath_list4*); +extern bool_t xdr_nfsv4_1_file_layout_ds_addr4(XDR *, nfsv4_1_file_layout_ds_addr4*); +extern bool_t xdr_nfsv4_1_file_layout4(XDR *, nfsv4_1_file_layout4*); +extern bool_t xdr_nfs_opnum4(XDR *, nfs_opnum4*); +extern bool_t xdr_ACCESS4args(XDR *, ACCESS4args*); +extern bool_t xdr_ACCESS4resok(XDR *, ACCESS4resok*); +extern bool_t xdr_ACCESS4res(XDR *, ACCESS4res*); +extern bool_t xdr_CLONE4args(XDR *, CLONE4args*); +extern bool_t xdr_CLONE4res(XDR *, CLONE4res*); +extern bool_t xdr_CLOSE4args(XDR *, CLOSE4args*); +extern bool_t xdr_CLOSE4res(XDR *, CLOSE4res*); +extern bool_t xdr_COMMIT4args(XDR *, COMMIT4args*); +extern bool_t xdr_COMMIT4resok(XDR *, COMMIT4resok*); +extern bool_t xdr_COMMIT4res(XDR *, COMMIT4res*); +extern bool_t xdr_createtype4(XDR *, createtype4*); +extern bool_t xdr_CREATE4args(XDR *, CREATE4args*); +extern bool_t xdr_CREATE4resok(XDR *, CREATE4resok*); +extern bool_t xdr_CREATE4res(XDR *, CREATE4res*); +extern bool_t xdr_DELEGPURGE4args(XDR *, DELEGPURGE4args*); +extern bool_t xdr_DELEGPURGE4res(XDR *, DELEGPURGE4res*); +extern bool_t xdr_DELEGRETURN4args(XDR *, DELEGRETURN4args*); +extern bool_t xdr_DELEGRETURN4res(XDR *, DELEGRETURN4res*); +extern bool_t xdr_GETATTR4args(XDR *, GETATTR4args*); +extern bool_t xdr_GETATTR4resok(XDR *, GETATTR4resok*); +extern bool_t xdr_GETATTR4res(XDR *, GETATTR4res*); +extern bool_t xdr_GETFH4resok(XDR *, GETFH4resok*); +extern bool_t xdr_GETFH4res(XDR *, GETFH4res*); +extern bool_t xdr_LINK4args(XDR *, LINK4args*); +extern bool_t xdr_LINK4resok(XDR *, LINK4resok*); +extern bool_t xdr_LINK4res(XDR *, LINK4res*); +extern bool_t xdr_open_to_lock_owner4(XDR *, open_to_lock_owner4*); +extern bool_t xdr_exist_lock_owner4(XDR *, exist_lock_owner4*); +extern bool_t xdr_locker4(XDR *, locker4*); +extern bool_t xdr_LOCK4args(XDR *, LOCK4args*); +extern bool_t xdr_LOCK4denied(XDR *, LOCK4denied*); +extern bool_t xdr_LOCK4resok(XDR *, LOCK4resok*); +extern bool_t xdr_LOCK4res(XDR *, LOCK4res*); +extern bool_t xdr_LOCKT4args(XDR *, LOCKT4args*); +extern bool_t xdr_LOCKT4res(XDR *, LOCKT4res*); +extern bool_t xdr_LOCKU4args(XDR *, LOCKU4args*); +extern bool_t xdr_LOCKU4res(XDR *, LOCKU4res*); +extern bool_t xdr_LOOKUP4args(XDR *, LOOKUP4args*); +extern bool_t xdr_LOOKUP4res(XDR *, LOOKUP4res*); +extern bool_t xdr_LOOKUPP4res(XDR *, LOOKUPP4res*); +extern bool_t xdr_NVERIFY4args(XDR *, NVERIFY4args*); +extern bool_t xdr_NVERIFY4res(XDR *, NVERIFY4res*); +extern bool_t xdr_createmode4(XDR *, createmode4*); +extern bool_t xdr_creatverfattr(XDR *, creatverfattr*); +extern bool_t xdr_createhow4(XDR *, createhow4*); +extern bool_t xdr_opentype4(XDR *, opentype4*); +extern bool_t xdr_openflag4(XDR *, openflag4*); +extern bool_t xdr_limit_by4(XDR *, limit_by4*); +extern bool_t xdr_nfs_modified_limit4(XDR *, nfs_modified_limit4*); +extern bool_t xdr_nfs_space_limit4(XDR *, nfs_space_limit4*); +extern bool_t xdr_open_delegation_type4(XDR *, open_delegation_type4*); +extern bool_t xdr_open_claim_type4(XDR *, open_claim_type4*); +extern bool_t xdr_open_claim_delegate_cur4(XDR *, open_claim_delegate_cur4*); +extern bool_t xdr_open_claim4(XDR *, open_claim4*); +extern bool_t xdr_OPEN4args(XDR *, OPEN4args*); +extern bool_t xdr_open_read_delegation4(XDR *, open_read_delegation4*); +extern bool_t xdr_open_write_delegation4(XDR *, open_write_delegation4*); +extern bool_t xdr_why_no_delegation4(XDR *, why_no_delegation4*); +extern bool_t xdr_open_none_delegation4(XDR *, open_none_delegation4*); +extern bool_t xdr_open_delegation4(XDR *, open_delegation4*); +extern bool_t xdr_OPEN4resok(XDR *, OPEN4resok*); +extern bool_t xdr_OPEN4res(XDR *, OPEN4res*); +extern bool_t xdr_OPENATTR4args(XDR *, OPENATTR4args*); +extern bool_t xdr_OPENATTR4res(XDR *, OPENATTR4res*); +extern bool_t xdr_OPEN_CONFIRM4args(XDR *, OPEN_CONFIRM4args*); +extern bool_t xdr_OPEN_CONFIRM4resok(XDR *, OPEN_CONFIRM4resok*); +extern bool_t xdr_OPEN_CONFIRM4res(XDR *, OPEN_CONFIRM4res*); +extern bool_t xdr_OPEN_DOWNGRADE4args(XDR *, OPEN_DOWNGRADE4args*); +extern bool_t xdr_OPEN_DOWNGRADE4resok(XDR *, OPEN_DOWNGRADE4resok*); +extern bool_t xdr_OPEN_DOWNGRADE4res(XDR *, OPEN_DOWNGRADE4res*); +extern bool_t xdr_PUTFH4args(XDR *, PUTFH4args*); +extern bool_t xdr_PUTFH4res(XDR *, PUTFH4res*); +extern bool_t xdr_PUTPUBFH4res(XDR *, PUTPUBFH4res*); +extern bool_t xdr_PUTROOTFH4res(XDR *, PUTROOTFH4res*); +extern bool_t xdr_READ4args(XDR *, READ4args*); +extern bool_t xdr_READ4resok(XDR *, READ4resok*); +extern bool_t xdr_READ4res(XDR *, READ4res*); +extern bool_t xdr_READDIR4args(XDR *, READDIR4args*); +extern bool_t xdr_entry4(XDR *, entry4*); +extern bool_t xdr_dirlist4(XDR *, dirlist4*); +extern bool_t xdr_READDIR4resok(XDR *, READDIR4resok*); +extern bool_t xdr_READDIR4res(XDR *, READDIR4res*); +extern bool_t xdr_READLINK4resok(XDR *, READLINK4resok*); +extern bool_t xdr_READLINK4res(XDR *, READLINK4res*); +extern bool_t xdr_REMOVE4args(XDR *, REMOVE4args*); +extern bool_t xdr_REMOVE4resok(XDR *, REMOVE4resok*); +extern bool_t xdr_REMOVE4res(XDR *, REMOVE4res*); +extern bool_t xdr_RENAME4args(XDR *, RENAME4args*); +extern bool_t xdr_RENAME4resok(XDR *, RENAME4resok*); +extern bool_t xdr_RENAME4res(XDR *, RENAME4res*); +extern bool_t xdr_RENEW4args(XDR *, RENEW4args*); +extern bool_t xdr_RENEW4res(XDR *, RENEW4res*); +extern bool_t xdr_RESTOREFH4res(XDR *, RESTOREFH4res*); +extern bool_t xdr_SAVEFH4res(XDR *, SAVEFH4res*); +extern bool_t xdr_SECINFO4args(XDR *, SECINFO4args*); +extern bool_t xdr_rpc_gss_svc_t(XDR *, rpc_gss_svc_t*); +extern bool_t xdr_rpcsec_gss_info(XDR *, rpcsec_gss_info*); +extern bool_t xdr_secinfo4(XDR *, secinfo4*); +extern bool_t xdr_SECINFO4resok(XDR *, SECINFO4resok*); +extern bool_t xdr_SECINFO4res(XDR *, SECINFO4res*); +extern bool_t xdr_SETATTR4args(XDR *, SETATTR4args*); +extern bool_t xdr_SETATTR4res(XDR *, SETATTR4res*); +extern bool_t xdr_SETCLIENTID4args(XDR *, SETCLIENTID4args*); +extern bool_t xdr_SETCLIENTID4resok(XDR *, SETCLIENTID4resok*); +extern bool_t xdr_SETCLIENTID4res(XDR *, SETCLIENTID4res*); +extern bool_t xdr_SETCLIENTID_CONFIRM4args(XDR *, SETCLIENTID_CONFIRM4args*); +extern bool_t xdr_SETCLIENTID_CONFIRM4res(XDR *, SETCLIENTID_CONFIRM4res*); +extern bool_t xdr_VERIFY4args(XDR *, VERIFY4args*); +extern bool_t xdr_VERIFY4res(XDR *, VERIFY4res*); +extern bool_t xdr_WRITE4args(XDR *, WRITE4args*); +extern bool_t xdr_WRITE4resok(XDR *, WRITE4resok*); +extern bool_t xdr_WRITE4res(XDR *, WRITE4res*); +extern bool_t xdr_RELEASE_LOCKOWNER4args(XDR *, RELEASE_LOCKOWNER4args*); +extern bool_t xdr_RELEASE_LOCKOWNER4res(XDR *, RELEASE_LOCKOWNER4res*); +extern bool_t xdr_ILLEGAL4res(XDR *, ILLEGAL4res*); +extern bool_t xdr_gsshandle4_t(XDR *, gsshandle4_t*); +extern bool_t xdr_gss_cb_handles4(XDR *, gss_cb_handles4*); +extern bool_t xdr_callback_sec_parms4(XDR *, callback_sec_parms4*); +extern bool_t xdr_BACKCHANNEL_CTL4args(XDR *, BACKCHANNEL_CTL4args*); +extern bool_t xdr_BACKCHANNEL_CTL4res(XDR *, BACKCHANNEL_CTL4res*); +extern bool_t xdr_channel_dir_from_client4(XDR *, channel_dir_from_client4*); +extern bool_t xdr_BIND_CONN_TO_SESSION4args(XDR *, BIND_CONN_TO_SESSION4args*); +extern bool_t xdr_channel_dir_from_server4(XDR *, channel_dir_from_server4*); +extern bool_t xdr_BIND_CONN_TO_SESSION4resok(XDR *, BIND_CONN_TO_SESSION4resok*); +extern bool_t xdr_BIND_CONN_TO_SESSION4res(XDR *, BIND_CONN_TO_SESSION4res*); +extern bool_t xdr_state_protect_ops4(XDR *, state_protect_ops4*); +extern bool_t xdr_ssv_sp_parms4(XDR *, ssv_sp_parms4*); +extern bool_t xdr_state_protect_how4(XDR *, state_protect_how4*); +extern bool_t xdr_state_protect4_a(XDR *, state_protect4_a*); +extern bool_t xdr_EXCHANGE_ID4args(XDR *, EXCHANGE_ID4args*); +extern bool_t xdr_ssv_prot_info4(XDR *, ssv_prot_info4*); +extern bool_t xdr_state_protect4_r(XDR *, state_protect4_r*); +extern bool_t xdr_EXCHANGE_ID4resok(XDR *, EXCHANGE_ID4resok*); +extern bool_t xdr_EXCHANGE_ID4res(XDR *, EXCHANGE_ID4res*); +extern bool_t xdr_channel_attrs4(XDR *, channel_attrs4*); +extern bool_t xdr_CREATE_SESSION4args(XDR *, CREATE_SESSION4args*); +extern bool_t xdr_CREATE_SESSION4resok(XDR *, CREATE_SESSION4resok*); +extern bool_t xdr_CREATE_SESSION4res(XDR *, CREATE_SESSION4res*); +extern bool_t xdr_DESTROY_SESSION4args(XDR *, DESTROY_SESSION4args*); +extern bool_t xdr_DESTROY_SESSION4res(XDR *, DESTROY_SESSION4res*); +extern bool_t xdr_FREE_STATEID4args(XDR *, FREE_STATEID4args*); +extern bool_t xdr_FREE_STATEID4res(XDR *, FREE_STATEID4res*); +extern bool_t xdr_attr_notice4(XDR *, attr_notice4*); +extern bool_t xdr_GET_DIR_DELEGATION4args(XDR *, GET_DIR_DELEGATION4args*); +extern bool_t xdr_GET_DIR_DELEGATION4resok(XDR *, GET_DIR_DELEGATION4resok*); +extern bool_t xdr_gddrnf4_status(XDR *, gddrnf4_status*); +extern bool_t xdr_GET_DIR_DELEGATION4res_non_fatal(XDR *, GET_DIR_DELEGATION4res_non_fatal*); +extern bool_t xdr_GET_DIR_DELEGATION4res(XDR *, GET_DIR_DELEGATION4res*); +extern bool_t xdr_GETDEVICEINFO4args(XDR *, GETDEVICEINFO4args*); +extern bool_t xdr_GETDEVICEINFO4resok(XDR *, GETDEVICEINFO4resok*); +extern bool_t xdr_GETDEVICEINFO4res(XDR *, GETDEVICEINFO4res*); +extern bool_t xdr_GETDEVICELIST4args(XDR *, GETDEVICELIST4args*); +extern bool_t xdr_GETDEVICELIST4resok(XDR *, GETDEVICELIST4resok*); +extern bool_t xdr_GETDEVICELIST4res(XDR *, GETDEVICELIST4res*); +extern bool_t xdr_newtime4(XDR *, newtime4*); +extern bool_t xdr_newoffset4(XDR *, newoffset4*); +extern bool_t xdr_LAYOUTCOMMIT4args(XDR *, LAYOUTCOMMIT4args*); +extern bool_t xdr_newsize4(XDR *, newsize4*); +extern bool_t xdr_LAYOUTCOMMIT4resok(XDR *, LAYOUTCOMMIT4resok*); +extern bool_t xdr_LAYOUTCOMMIT4res(XDR *, LAYOUTCOMMIT4res*); +extern bool_t xdr_LAYOUTGET4args(XDR *, LAYOUTGET4args*); +extern bool_t xdr_LAYOUTGET4resok(XDR *, LAYOUTGET4resok*); +extern bool_t xdr_LAYOUTGET4res(XDR *, LAYOUTGET4res*); +extern bool_t xdr_LAYOUTRETURN4args(XDR *, LAYOUTRETURN4args*); +extern bool_t xdr_layoutreturn_stateid(XDR *, layoutreturn_stateid*); +extern bool_t xdr_LAYOUTRETURN4res(XDR *, LAYOUTRETURN4res*); +extern bool_t xdr_secinfo_style4(XDR *, secinfo_style4*); +extern bool_t xdr_SECINFO_NO_NAME4args(XDR *, SECINFO_NO_NAME4args*); +extern bool_t xdr_SECINFO_NO_NAME4res(XDR *, SECINFO_NO_NAME4res*); +extern bool_t xdr_SEQUENCE4args(XDR *, SEQUENCE4args*); +extern bool_t xdr_SEQUENCE4resok(XDR *, SEQUENCE4resok*); +extern bool_t xdr_SEQUENCE4res(XDR *, SEQUENCE4res*); +extern bool_t xdr_ssa_digest_input4(XDR *, ssa_digest_input4*); +extern bool_t xdr_SET_SSV4args(XDR *, SET_SSV4args*); +extern bool_t xdr_ssr_digest_input4(XDR *, ssr_digest_input4*); +extern bool_t xdr_SET_SSV4resok(XDR *, SET_SSV4resok*); +extern bool_t xdr_SET_SSV4res(XDR *, SET_SSV4res*); +extern bool_t xdr_TEST_STATEID4args(XDR *, TEST_STATEID4args*); +extern bool_t xdr_TEST_STATEID4resok(XDR *, TEST_STATEID4resok*); +extern bool_t xdr_TEST_STATEID4res(XDR *, TEST_STATEID4res*); +extern bool_t xdr_deleg_claim4(XDR *, deleg_claim4*); +extern bool_t xdr_WANT_DELEGATION4args(XDR *, WANT_DELEGATION4args*); +extern bool_t xdr_WANT_DELEGATION4res(XDR *, WANT_DELEGATION4res*); +extern bool_t xdr_DESTROY_CLIENTID4args(XDR *, DESTROY_CLIENTID4args*); +extern bool_t xdr_DESTROY_CLIENTID4res(XDR *, DESTROY_CLIENTID4res*); +extern bool_t xdr_RECLAIM_COMPLETE4args(XDR *, RECLAIM_COMPLETE4args*); +extern bool_t xdr_RECLAIM_COMPLETE4res(XDR *, RECLAIM_COMPLETE4res*); +extern bool_t xdr_COPY4args(XDR *, COPY4args*); +extern bool_t xdr_copy_requirements4(XDR *, copy_requirements4*); +extern bool_t xdr_COPY4resok(XDR *, COPY4resok*); +extern bool_t xdr_COPY4res(XDR *, COPY4res*); +extern bool_t xdr_COPY_NOTIFY4args(XDR *, COPY_NOTIFY4args*); +extern bool_t xdr_COPY_NOTIFY4resok(XDR *, COPY_NOTIFY4resok*); +extern bool_t xdr_COPY_NOTIFY4res(XDR *, COPY_NOTIFY4res*); +extern bool_t xdr_OFFLOAD_CANCEL4args(XDR *, OFFLOAD_CANCEL4args*); +extern bool_t xdr_OFFLOAD_CANCEL4res(XDR *, OFFLOAD_CANCEL4res*); +extern bool_t xdr_OFFLOAD_STATUS4args(XDR *, OFFLOAD_STATUS4args*); +extern bool_t xdr_OFFLOAD_STATUS4resok(XDR *, OFFLOAD_STATUS4resok*); +extern bool_t xdr_OFFLOAD_STATUS4res(XDR *, OFFLOAD_STATUS4res*); +extern bool_t xdr_ALLOCATE4args(XDR *, ALLOCATE4args*); +extern bool_t xdr_ALLOCATE4res(XDR *, ALLOCATE4res*); +extern bool_t xdr_DEALLOCATE4args(XDR *, DEALLOCATE4args*); +extern bool_t xdr_DEALLOCATE4res(XDR *, DEALLOCATE4res*); +extern bool_t xdr_IO_ADVISE_type4(XDR *, IO_ADVISE_type4*); +extern bool_t xdr_IO_ADVISE4args(XDR *, IO_ADVISE4args*); +extern bool_t xdr_IO_ADVISE4resok(XDR *, IO_ADVISE4resok*); +extern bool_t xdr_IO_ADVISE4res(XDR *, IO_ADVISE4res*); +extern bool_t xdr_device_error4(XDR *, device_error4*); +extern bool_t xdr_LAYOUTERROR4args(XDR *, LAYOUTERROR4args*); +extern bool_t xdr_LAYOUTERROR4res(XDR *, LAYOUTERROR4res*); +extern bool_t xdr_io_info4(XDR *, io_info4*); +extern bool_t xdr_LAYOUTSTATS4args(XDR *, LAYOUTSTATS4args*); +extern bool_t xdr_LAYOUTSTATS4res(XDR *, LAYOUTSTATS4res*); +extern bool_t xdr_READ_PLUS4args(XDR *, READ_PLUS4args*); +extern bool_t xdr_read_plus_content(XDR *, read_plus_content*); +extern bool_t xdr_read_plus_res4(XDR *, read_plus_res4*); +extern bool_t xdr_READ_PLUS4res(XDR *, READ_PLUS4res*); +extern bool_t xdr_SEEK4args(XDR *, SEEK4args*); +extern bool_t xdr_seek_res4(XDR *, seek_res4*); +extern bool_t xdr_SEEK4res(XDR *, SEEK4res*); +extern bool_t xdr_WRITE_SAME4args(XDR *, WRITE_SAME4args*); +extern bool_t xdr_WRITE_SAME4res(XDR *, WRITE_SAME4res*); +extern bool_t xdr_nfs_argop4(XDR *, nfs_argop4*); +extern bool_t xdr_nfs_resop4(XDR *, nfs_resop4*); +extern bool_t xdr_COMPOUND4args(XDR *, COMPOUND4args*); +extern bool_t xdr_COMPOUND4res(XDR *, COMPOUND4res*); +extern bool_t xdr_CB_GETATTR4args(XDR *, CB_GETATTR4args*); +extern bool_t xdr_CB_GETATTR4resok(XDR *, CB_GETATTR4resok*); +extern bool_t xdr_CB_GETATTR4res(XDR *, CB_GETATTR4res*); +extern bool_t xdr_CB_RECALL4args(XDR *, CB_RECALL4args*); +extern bool_t xdr_CB_RECALL4res(XDR *, CB_RECALL4res*); +extern bool_t xdr_CB_ILLEGAL4res(XDR *, CB_ILLEGAL4res*); +extern bool_t xdr_layoutrecall_type4(XDR *, layoutrecall_type4*); +extern bool_t xdr_layoutrecall_file4(XDR *, layoutrecall_file4*); +extern bool_t xdr_layoutrecall4(XDR *, layoutrecall4*); +extern bool_t xdr_CB_LAYOUTRECALL4args(XDR *, CB_LAYOUTRECALL4args*); +extern bool_t xdr_CB_LAYOUTRECALL4res(XDR *, CB_LAYOUTRECALL4res*); +extern bool_t xdr_notify_type4(XDR *, notify_type4*); +extern bool_t xdr_notify_entry4(XDR *, notify_entry4*); +extern bool_t xdr_prev_entry4(XDR *, prev_entry4*); +extern bool_t xdr_notify_remove4(XDR *, notify_remove4*); +extern bool_t xdr_notify_add4(XDR *, notify_add4*); +extern bool_t xdr_notify_attr4(XDR *, notify_attr4*); +extern bool_t xdr_notify_rename4(XDR *, notify_rename4*); +extern bool_t xdr_notify_verifier4(XDR *, notify_verifier4*); +extern bool_t xdr_notifylist4(XDR *, notifylist4*); +extern bool_t xdr_notify4(XDR *, notify4*); +extern bool_t xdr_CB_NOTIFY4args(XDR *, CB_NOTIFY4args*); +extern bool_t xdr_CB_NOTIFY4res(XDR *, CB_NOTIFY4res*); +extern bool_t xdr_CB_PUSH_DELEG4args(XDR *, CB_PUSH_DELEG4args*); +extern bool_t xdr_CB_PUSH_DELEG4res(XDR *, CB_PUSH_DELEG4res*); +extern bool_t xdr_CB_RECALL_ANY4args(XDR *, CB_RECALL_ANY4args*); +extern bool_t xdr_CB_RECALL_ANY4res(XDR *, CB_RECALL_ANY4res*); +extern bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4args(XDR *, CB_RECALLABLE_OBJ_AVAIL4args*); +extern bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4res(XDR *, CB_RECALLABLE_OBJ_AVAIL4res*); +extern bool_t xdr_CB_RECALL_SLOT4args(XDR *, CB_RECALL_SLOT4args*); +extern bool_t xdr_CB_RECALL_SLOT4res(XDR *, CB_RECALL_SLOT4res*); +extern bool_t xdr_referring_call4(XDR *, referring_call4*); +extern bool_t xdr_referring_call_list4(XDR *, referring_call_list4*); +extern bool_t xdr_CB_SEQUENCE4args(XDR *, CB_SEQUENCE4args*); +extern bool_t xdr_CB_SEQUENCE4resok(XDR *, CB_SEQUENCE4resok*); +extern bool_t xdr_CB_SEQUENCE4res(XDR *, CB_SEQUENCE4res*); +extern bool_t xdr_CB_WANTS_CANCELLED4args(XDR *, CB_WANTS_CANCELLED4args*); +extern bool_t xdr_CB_WANTS_CANCELLED4res(XDR *, CB_WANTS_CANCELLED4res*); +extern bool_t xdr_CB_NOTIFY_LOCK4args(XDR *, CB_NOTIFY_LOCK4args*); +extern bool_t xdr_CB_NOTIFY_LOCK4res(XDR *, CB_NOTIFY_LOCK4res*); +extern bool_t xdr_notify_deviceid_type4(XDR *, notify_deviceid_type4*); +extern bool_t xdr_notify_deviceid_delete4(XDR *, notify_deviceid_delete4*); +extern bool_t xdr_notify_deviceid_change4(XDR *, notify_deviceid_change4*); +extern bool_t xdr_CB_NOTIFY_DEVICEID4args(XDR *, CB_NOTIFY_DEVICEID4args*); +extern bool_t xdr_CB_NOTIFY_DEVICEID4res(XDR *, CB_NOTIFY_DEVICEID4res*); +extern bool_t xdr_offload_info4(XDR *, offload_info4*); +extern bool_t xdr_CB_OFFLOAD4args(XDR *, CB_OFFLOAD4args*); +extern bool_t xdr_CB_OFFLOAD4res(XDR *, CB_OFFLOAD4res*); +extern bool_t xdr_nfs_cb_opnum4(XDR *, nfs_cb_opnum4*); +extern bool_t xdr_nfs_cb_argop4(XDR *, nfs_cb_argop4*); +extern bool_t xdr_nfs_cb_resop4(XDR *, nfs_cb_resop4*); +extern bool_t xdr_CB_COMPOUND4args(XDR *, CB_COMPOUND4args*); +extern bool_t xdr_CB_COMPOUND4res(XDR *, CB_COMPOUND4res*); + +#else /* K&R C */ +extern bool_t xdr_nfs_ftype4(); +extern bool_t xdr_nfsstat4(); +extern bool_t xdr_attrlist4(); +extern bool_t xdr_bitmap4(); +extern bool_t xdr_changeid4(); +extern bool_t xdr_clientid4(); +extern bool_t xdr_count4(); +extern bool_t xdr_length4(); +extern bool_t xdr_mode4(); +extern bool_t xdr_nfs_cookie4(); +extern bool_t xdr_nfs_fh4(); +extern bool_t xdr_offset4(); +extern bool_t xdr_qop4(); +extern bool_t xdr_sec_oid4(); +extern bool_t xdr_sequenceid4(); +extern bool_t xdr_seqid4(); +extern bool_t xdr_sessionid4(); +extern bool_t xdr_slotid4(); +extern bool_t xdr_utf8string(); +extern bool_t xdr_utf8str_cis(); +extern bool_t xdr_utf8str_cs(); +extern bool_t xdr_utf8str_mixed(); +extern bool_t xdr_component4(); +extern bool_t xdr_linktext4(); +extern bool_t xdr_ascii_REQUIRED4(); +extern bool_t xdr_pathname4(); +extern bool_t xdr_verifier4(); +extern bool_t xdr_secret4(); +extern bool_t xdr_policy4(); +extern bool_t xdr_nfstime4(); +extern bool_t xdr_time_how4(); +extern bool_t xdr_settime4(); +extern bool_t xdr_nfs_lease4(); +extern bool_t xdr_fsid4(); +extern bool_t xdr_change_policy4(); +extern bool_t xdr_fs_location4(); +extern bool_t xdr_fs_locations4(); +extern bool_t xdr_acetype4(); +extern bool_t xdr_aceflag4(); +extern bool_t xdr_acemask4(); +extern bool_t xdr_nfsace4(); +extern bool_t xdr_aclflag4(); +extern bool_t xdr_nfsacl41(); +extern bool_t xdr_mode_masked4(); +extern bool_t xdr_specdata4(); +extern bool_t xdr_netaddr4(); +extern bool_t xdr_nfs_impl_id4(); +extern bool_t xdr_stateid4(); +extern bool_t xdr_layouttype4(); +extern bool_t xdr_layout_content4(); +extern bool_t xdr_layouthint4(); +extern bool_t xdr_layoutiomode4(); +extern bool_t xdr_layout4(); +extern bool_t xdr_deviceid4(); +extern bool_t xdr_device_addr4(); +extern bool_t xdr_layoutupdate4(); +extern bool_t xdr_layoutreturn_type4(); +extern bool_t xdr_layoutreturn_file4(); +extern bool_t xdr_layoutreturn4(); +extern bool_t xdr_fs4_status_type(); +extern bool_t xdr_fs4_status(); +extern bool_t xdr_threshold4_read_size(); +extern bool_t xdr_threshold4_write_size(); +extern bool_t xdr_threshold4_read_iosize(); +extern bool_t xdr_threshold4_write_iosize(); +extern bool_t xdr_threshold_item4(); +extern bool_t xdr_mdsthreshold4(); +extern bool_t xdr_retention_get4(); +extern bool_t xdr_retention_set4(); +extern bool_t xdr_fs_charset_cap4(); +extern bool_t xdr_netloc_type4(); +extern bool_t xdr_netloc4(); +extern bool_t xdr_change_attr_type4(); +extern bool_t xdr_labelformat_spec4(); +extern bool_t xdr_sec_label4(); +extern bool_t xdr_copy_from_auth_priv(); +extern bool_t xdr_copy_to_auth_priv(); +extern bool_t xdr_copy_confirm_auth_priv(); +extern bool_t xdr_app_data_block4(); +extern bool_t xdr_data4(); +extern bool_t xdr_data_info4(); +extern bool_t xdr_data_content4(); +extern bool_t xdr_stable_how4(); +extern bool_t xdr_write_response4(); +extern bool_t xdr_fattr4_supported_attrs(); +extern bool_t xdr_fattr4_type(); +extern bool_t xdr_fattr4_fh_expire_type(); +extern bool_t xdr_fattr4_change(); +extern bool_t xdr_fattr4_size(); +extern bool_t xdr_fattr4_link_support(); +extern bool_t xdr_fattr4_symlink_support(); +extern bool_t xdr_fattr4_named_attr(); +extern bool_t xdr_fattr4_fsid(); +extern bool_t xdr_fattr4_unique_handles(); +extern bool_t xdr_fattr4_lease_time(); +extern bool_t xdr_fattr4_rdattr_error(); +extern bool_t xdr_fattr4_acl(); +extern bool_t xdr_fattr4_aclsupport(); +extern bool_t xdr_fattr4_archive(); +extern bool_t xdr_fattr4_cansettime(); +extern bool_t xdr_fattr4_case_insensitive(); +extern bool_t xdr_fattr4_case_preserving(); +extern bool_t xdr_fattr4_chown_restricted(); +extern bool_t xdr_fattr4_fileid(); +extern bool_t xdr_fattr4_files_avail(); +extern bool_t xdr_fattr4_filehandle(); +extern bool_t xdr_fattr4_files_free(); +extern bool_t xdr_fattr4_files_total(); +extern bool_t xdr_fattr4_fs_locations(); +extern bool_t xdr_fattr4_hidden(); +extern bool_t xdr_fattr4_homogeneous(); +extern bool_t xdr_fattr4_maxfilesize(); +extern bool_t xdr_fattr4_maxlink(); +extern bool_t xdr_fattr4_maxname(); +extern bool_t xdr_fattr4_maxread(); +extern bool_t xdr_fattr4_maxwrite(); +extern bool_t xdr_fattr4_mimetype(); +extern bool_t xdr_fattr4_mode(); +extern bool_t xdr_fattr4_mode_set_masked(); +extern bool_t xdr_fattr4_mounted_on_fileid(); +extern bool_t xdr_fattr4_no_trunc(); +extern bool_t xdr_fattr4_numlinks(); +extern bool_t xdr_fattr4_owner(); +extern bool_t xdr_fattr4_owner_group(); +extern bool_t xdr_fattr4_quota_avail_hard(); +extern bool_t xdr_fattr4_quota_avail_soft(); +extern bool_t xdr_fattr4_quota_used(); +extern bool_t xdr_fattr4_rawdev(); +extern bool_t xdr_fattr4_space_avail(); +extern bool_t xdr_fattr4_space_free(); +extern bool_t xdr_fattr4_space_total(); +extern bool_t xdr_fattr4_space_used(); +extern bool_t xdr_fattr4_system(); +extern bool_t xdr_fattr4_time_access(); +extern bool_t xdr_fattr4_time_access_set(); +extern bool_t xdr_fattr4_time_backup(); +extern bool_t xdr_fattr4_time_create(); +extern bool_t xdr_fattr4_time_delta(); +extern bool_t xdr_fattr4_time_metadata(); +extern bool_t xdr_fattr4_time_modify(); +extern bool_t xdr_fattr4_time_modify_set(); +extern bool_t xdr_fattr4_suppattr_exclcreat(); +extern bool_t xdr_fattr4_dir_notif_delay(); +extern bool_t xdr_fattr4_dirent_notif_delay(); +extern bool_t xdr_fattr4_fs_layout_types(); +extern bool_t xdr_fattr4_fs_status(); +extern bool_t xdr_fattr4_fs_charset_cap(); +extern bool_t xdr_fattr4_layout_alignment(); +extern bool_t xdr_fattr4_layout_blksize(); +extern bool_t xdr_fattr4_layout_hint(); +extern bool_t xdr_fattr4_layout_types(); +extern bool_t xdr_fattr4_mdsthreshold(); +extern bool_t xdr_fattr4_retention_get(); +extern bool_t xdr_fattr4_retention_set(); +extern bool_t xdr_fattr4_retentevt_get(); +extern bool_t xdr_fattr4_retentevt_set(); +extern bool_t xdr_fattr4_retention_hold(); +extern bool_t xdr_fattr4_dacl(); +extern bool_t xdr_fattr4_sacl(); +extern bool_t xdr_fattr4_change_policy(); +extern bool_t xdr_fattr4_space_freed(); +extern bool_t xdr_fattr4_change_attr_type(); +extern bool_t xdr_fattr4_sec_label(); +extern bool_t xdr_fattr4_clone_blksize(); +extern bool_t xdr_fattr4(); +extern bool_t xdr_change_info4(); +extern bool_t xdr_clientaddr4(); +extern bool_t xdr_cb_client4(); +extern bool_t xdr_nfs_client_id4(); +extern bool_t xdr_client_owner4(); +extern bool_t xdr_server_owner4(); +extern bool_t xdr_state_owner4(); +extern bool_t xdr_open_owner4(); +extern bool_t xdr_lock_owner4(); +extern bool_t xdr_nfs_lock_type4(); +extern bool_t xdr_ssv_subkey4(); +extern bool_t xdr_ssv_mic_plain_tkn4(); +extern bool_t xdr_ssv_mic_tkn4(); +extern bool_t xdr_ssv_seal_plain_tkn4(); +extern bool_t xdr_ssv_seal_cipher_tkn4(); +extern bool_t xdr_fs_locations_server4(); +extern bool_t xdr_fs_locations_item4(); +extern bool_t xdr_fs_locations_info4(); +extern bool_t xdr_fattr4_fs_locations_info(); +extern bool_t xdr_nfl_util4(); +extern bool_t xdr_filelayout_hint_care4(); +extern bool_t xdr_nfsv4_1_file_layouthint4(); +extern bool_t xdr_multipath_list4(); +extern bool_t xdr_nfsv4_1_file_layout_ds_addr4(); +extern bool_t xdr_nfsv4_1_file_layout4(); +extern bool_t xdr_nfs_opnum4(); +extern bool_t xdr_ACCESS4args(); +extern bool_t xdr_ACCESS4resok(); +extern bool_t xdr_ACCESS4res(); +extern bool_t xdr_CLONE4args(); +extern bool_t xdr_CLONE4res(); +extern bool_t xdr_CLOSE4args(); +extern bool_t xdr_CLOSE4res(); +extern bool_t xdr_COMMIT4args(); +extern bool_t xdr_COMMIT4resok(); +extern bool_t xdr_COMMIT4res(); +extern bool_t xdr_createtype4(); +extern bool_t xdr_CREATE4args(); +extern bool_t xdr_CREATE4resok(); +extern bool_t xdr_CREATE4res(); +extern bool_t xdr_DELEGPURGE4args(); +extern bool_t xdr_DELEGPURGE4res(); +extern bool_t xdr_DELEGRETURN4args(); +extern bool_t xdr_DELEGRETURN4res(); +extern bool_t xdr_GETATTR4args(); +extern bool_t xdr_GETATTR4resok(); +extern bool_t xdr_GETATTR4res(); +extern bool_t xdr_GETFH4resok(); +extern bool_t xdr_GETFH4res(); +extern bool_t xdr_LINK4args(); +extern bool_t xdr_LINK4resok(); +extern bool_t xdr_LINK4res(); +extern bool_t xdr_open_to_lock_owner4(); +extern bool_t xdr_exist_lock_owner4(); +extern bool_t xdr_locker4(); +extern bool_t xdr_LOCK4args(); +extern bool_t xdr_LOCK4denied(); +extern bool_t xdr_LOCK4resok(); +extern bool_t xdr_LOCK4res(); +extern bool_t xdr_LOCKT4args(); +extern bool_t xdr_LOCKT4res(); +extern bool_t xdr_LOCKU4args(); +extern bool_t xdr_LOCKU4res(); +extern bool_t xdr_LOOKUP4args(); +extern bool_t xdr_LOOKUP4res(); +extern bool_t xdr_LOOKUPP4res(); +extern bool_t xdr_NVERIFY4args(); +extern bool_t xdr_NVERIFY4res(); +extern bool_t xdr_createmode4(); +extern bool_t xdr_creatverfattr(); +extern bool_t xdr_createhow4(); +extern bool_t xdr_opentype4(); +extern bool_t xdr_openflag4(); +extern bool_t xdr_limit_by4(); +extern bool_t xdr_nfs_modified_limit4(); +extern bool_t xdr_nfs_space_limit4(); +extern bool_t xdr_open_delegation_type4(); +extern bool_t xdr_open_claim_type4(); +extern bool_t xdr_open_claim_delegate_cur4(); +extern bool_t xdr_open_claim4(); +extern bool_t xdr_OPEN4args(); +extern bool_t xdr_open_read_delegation4(); +extern bool_t xdr_open_write_delegation4(); +extern bool_t xdr_why_no_delegation4(); +extern bool_t xdr_open_none_delegation4(); +extern bool_t xdr_open_delegation4(); +extern bool_t xdr_OPEN4resok(); +extern bool_t xdr_OPEN4res(); +extern bool_t xdr_OPENATTR4args(); +extern bool_t xdr_OPENATTR4res(); +extern bool_t xdr_OPEN_CONFIRM4args(); +extern bool_t xdr_OPEN_CONFIRM4resok(); +extern bool_t xdr_OPEN_CONFIRM4res(); +extern bool_t xdr_OPEN_DOWNGRADE4args(); +extern bool_t xdr_OPEN_DOWNGRADE4resok(); +extern bool_t xdr_OPEN_DOWNGRADE4res(); +extern bool_t xdr_PUTFH4args(); +extern bool_t xdr_PUTFH4res(); +extern bool_t xdr_PUTPUBFH4res(); +extern bool_t xdr_PUTROOTFH4res(); +extern bool_t xdr_READ4args(); +extern bool_t xdr_READ4resok(); +extern bool_t xdr_READ4res(); +extern bool_t xdr_READDIR4args(); +extern bool_t xdr_entry4(); +extern bool_t xdr_dirlist4(); +extern bool_t xdr_READDIR4resok(); +extern bool_t xdr_READDIR4res(); +extern bool_t xdr_READLINK4resok(); +extern bool_t xdr_READLINK4res(); +extern bool_t xdr_REMOVE4args(); +extern bool_t xdr_REMOVE4resok(); +extern bool_t xdr_REMOVE4res(); +extern bool_t xdr_RENAME4args(); +extern bool_t xdr_RENAME4resok(); +extern bool_t xdr_RENAME4res(); +extern bool_t xdr_RENEW4args(); +extern bool_t xdr_RENEW4res(); +extern bool_t xdr_RESTOREFH4res(); +extern bool_t xdr_SAVEFH4res(); +extern bool_t xdr_SECINFO4args(); +extern bool_t xdr_rpc_gss_svc_t(); +extern bool_t xdr_rpcsec_gss_info(); +extern bool_t xdr_secinfo4(); +extern bool_t xdr_SECINFO4resok(); +extern bool_t xdr_SECINFO4res(); +extern bool_t xdr_SETATTR4args(); +extern bool_t xdr_SETATTR4res(); +extern bool_t xdr_SETCLIENTID4args(); +extern bool_t xdr_SETCLIENTID4resok(); +extern bool_t xdr_SETCLIENTID4res(); +extern bool_t xdr_SETCLIENTID_CONFIRM4args(); +extern bool_t xdr_SETCLIENTID_CONFIRM4res(); +extern bool_t xdr_VERIFY4args(); +extern bool_t xdr_VERIFY4res(); +extern bool_t xdr_WRITE4args(); +extern bool_t xdr_WRITE4resok(); +extern bool_t xdr_WRITE4res(); +extern bool_t xdr_RELEASE_LOCKOWNER4args(); +extern bool_t xdr_RELEASE_LOCKOWNER4res(); +extern bool_t xdr_ILLEGAL4res(); +extern bool_t xdr_gsshandle4_t(); +extern bool_t xdr_gss_cb_handles4(); +extern bool_t xdr_callback_sec_parms4(); +extern bool_t xdr_BACKCHANNEL_CTL4args(); +extern bool_t xdr_BACKCHANNEL_CTL4res(); +extern bool_t xdr_channel_dir_from_client4(); +extern bool_t xdr_BIND_CONN_TO_SESSION4args(); +extern bool_t xdr_channel_dir_from_server4(); +extern bool_t xdr_BIND_CONN_TO_SESSION4resok(); +extern bool_t xdr_BIND_CONN_TO_SESSION4res(); +extern bool_t xdr_state_protect_ops4(); +extern bool_t xdr_ssv_sp_parms4(); +extern bool_t xdr_state_protect_how4(); +extern bool_t xdr_state_protect4_a(); +extern bool_t xdr_EXCHANGE_ID4args(); +extern bool_t xdr_ssv_prot_info4(); +extern bool_t xdr_state_protect4_r(); +extern bool_t xdr_EXCHANGE_ID4resok(); +extern bool_t xdr_EXCHANGE_ID4res(); +extern bool_t xdr_channel_attrs4(); +extern bool_t xdr_CREATE_SESSION4args(); +extern bool_t xdr_CREATE_SESSION4resok(); +extern bool_t xdr_CREATE_SESSION4res(); +extern bool_t xdr_DESTROY_SESSION4args(); +extern bool_t xdr_DESTROY_SESSION4res(); +extern bool_t xdr_FREE_STATEID4args(); +extern bool_t xdr_FREE_STATEID4res(); +extern bool_t xdr_attr_notice4(); +extern bool_t xdr_GET_DIR_DELEGATION4args(); +extern bool_t xdr_GET_DIR_DELEGATION4resok(); +extern bool_t xdr_gddrnf4_status(); +extern bool_t xdr_GET_DIR_DELEGATION4res_non_fatal(); +extern bool_t xdr_GET_DIR_DELEGATION4res(); +extern bool_t xdr_GETDEVICEINFO4args(); +extern bool_t xdr_GETDEVICEINFO4resok(); +extern bool_t xdr_GETDEVICEINFO4res(); +extern bool_t xdr_GETDEVICELIST4args(); +extern bool_t xdr_GETDEVICELIST4resok(); +extern bool_t xdr_GETDEVICELIST4res(); +extern bool_t xdr_newtime4(); +extern bool_t xdr_newoffset4(); +extern bool_t xdr_LAYOUTCOMMIT4args(); +extern bool_t xdr_newsize4(); +extern bool_t xdr_LAYOUTCOMMIT4resok(); +extern bool_t xdr_LAYOUTCOMMIT4res(); +extern bool_t xdr_LAYOUTGET4args(); +extern bool_t xdr_LAYOUTGET4resok(); +extern bool_t xdr_LAYOUTGET4res(); +extern bool_t xdr_LAYOUTRETURN4args(); +extern bool_t xdr_layoutreturn_stateid(); +extern bool_t xdr_LAYOUTRETURN4res(); +extern bool_t xdr_secinfo_style4(); +extern bool_t xdr_SECINFO_NO_NAME4args(); +extern bool_t xdr_SECINFO_NO_NAME4res(); +extern bool_t xdr_SEQUENCE4args(); +extern bool_t xdr_SEQUENCE4resok(); +extern bool_t xdr_SEQUENCE4res(); +extern bool_t xdr_ssa_digest_input4(); +extern bool_t xdr_SET_SSV4args(); +extern bool_t xdr_ssr_digest_input4(); +extern bool_t xdr_SET_SSV4resok(); +extern bool_t xdr_SET_SSV4res(); +extern bool_t xdr_TEST_STATEID4args(); +extern bool_t xdr_TEST_STATEID4resok(); +extern bool_t xdr_TEST_STATEID4res(); +extern bool_t xdr_deleg_claim4(); +extern bool_t xdr_WANT_DELEGATION4args(); +extern bool_t xdr_WANT_DELEGATION4res(); +extern bool_t xdr_DESTROY_CLIENTID4args(); +extern bool_t xdr_DESTROY_CLIENTID4res(); +extern bool_t xdr_RECLAIM_COMPLETE4args(); +extern bool_t xdr_RECLAIM_COMPLETE4res(); +extern bool_t xdr_COPY4args(); +extern bool_t xdr_copy_requirements4(); +extern bool_t xdr_COPY4resok(); +extern bool_t xdr_COPY4res(); +extern bool_t xdr_COPY_NOTIFY4args(); +extern bool_t xdr_COPY_NOTIFY4resok(); +extern bool_t xdr_COPY_NOTIFY4res(); +extern bool_t xdr_OFFLOAD_CANCEL4args(); +extern bool_t xdr_OFFLOAD_CANCEL4res(); +extern bool_t xdr_OFFLOAD_STATUS4args(); +extern bool_t xdr_OFFLOAD_STATUS4resok(); +extern bool_t xdr_OFFLOAD_STATUS4res(); +extern bool_t xdr_ALLOCATE4args(); +extern bool_t xdr_ALLOCATE4res(); +extern bool_t xdr_DEALLOCATE4args(); +extern bool_t xdr_DEALLOCATE4res(); +extern bool_t xdr_IO_ADVISE_type4(); +extern bool_t xdr_IO_ADVISE4args(); +extern bool_t xdr_IO_ADVISE4resok(); +extern bool_t xdr_IO_ADVISE4res(); +extern bool_t xdr_device_error4(); +extern bool_t xdr_LAYOUTERROR4args(); +extern bool_t xdr_LAYOUTERROR4res(); +extern bool_t xdr_io_info4(); +extern bool_t xdr_LAYOUTSTATS4args(); +extern bool_t xdr_LAYOUTSTATS4res(); +extern bool_t xdr_READ_PLUS4args(); +extern bool_t xdr_read_plus_content(); +extern bool_t xdr_read_plus_res4(); +extern bool_t xdr_READ_PLUS4res(); +extern bool_t xdr_SEEK4args(); +extern bool_t xdr_seek_res4(); +extern bool_t xdr_SEEK4res(); +extern bool_t xdr_WRITE_SAME4args(); +extern bool_t xdr_WRITE_SAME4res(); +extern bool_t xdr_nfs_argop4(); +extern bool_t xdr_nfs_resop4(); +extern bool_t xdr_COMPOUND4args(); +extern bool_t xdr_COMPOUND4res(); +extern bool_t xdr_CB_GETATTR4args(); +extern bool_t xdr_CB_GETATTR4resok(); +extern bool_t xdr_CB_GETATTR4res(); +extern bool_t xdr_CB_RECALL4args(); +extern bool_t xdr_CB_RECALL4res(); +extern bool_t xdr_CB_ILLEGAL4res(); +extern bool_t xdr_layoutrecall_type4(); +extern bool_t xdr_layoutrecall_file4(); +extern bool_t xdr_layoutrecall4(); +extern bool_t xdr_CB_LAYOUTRECALL4args(); +extern bool_t xdr_CB_LAYOUTRECALL4res(); +extern bool_t xdr_notify_type4(); +extern bool_t xdr_notify_entry4(); +extern bool_t xdr_prev_entry4(); +extern bool_t xdr_notify_remove4(); +extern bool_t xdr_notify_add4(); +extern bool_t xdr_notify_attr4(); +extern bool_t xdr_notify_rename4(); +extern bool_t xdr_notify_verifier4(); +extern bool_t xdr_notifylist4(); +extern bool_t xdr_notify4(); +extern bool_t xdr_CB_NOTIFY4args(); +extern bool_t xdr_CB_NOTIFY4res(); +extern bool_t xdr_CB_PUSH_DELEG4args(); +extern bool_t xdr_CB_PUSH_DELEG4res(); +extern bool_t xdr_CB_RECALL_ANY4args(); +extern bool_t xdr_CB_RECALL_ANY4res(); +extern bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4args(); +extern bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4res(); +extern bool_t xdr_CB_RECALL_SLOT4args(); +extern bool_t xdr_CB_RECALL_SLOT4res(); +extern bool_t xdr_referring_call4(); +extern bool_t xdr_referring_call_list4(); +extern bool_t xdr_CB_SEQUENCE4args(); +extern bool_t xdr_CB_SEQUENCE4resok(); +extern bool_t xdr_CB_SEQUENCE4res(); +extern bool_t xdr_CB_WANTS_CANCELLED4args(); +extern bool_t xdr_CB_WANTS_CANCELLED4res(); +extern bool_t xdr_CB_NOTIFY_LOCK4args(); +extern bool_t xdr_CB_NOTIFY_LOCK4res(); +extern bool_t xdr_notify_deviceid_type4(); +extern bool_t xdr_notify_deviceid_delete4(); +extern bool_t xdr_notify_deviceid_change4(); +extern bool_t xdr_CB_NOTIFY_DEVICEID4args(); +extern bool_t xdr_CB_NOTIFY_DEVICEID4res(); +extern bool_t xdr_offload_info4(); +extern bool_t xdr_CB_OFFLOAD4args(); +extern bool_t xdr_CB_OFFLOAD4res(); +extern bool_t xdr_nfs_cb_opnum4(); +extern bool_t xdr_nfs_cb_argop4(); +extern bool_t xdr_nfs_cb_resop4(); +extern bool_t xdr_CB_COMPOUND4args(); +extern bool_t xdr_CB_COMPOUND4res(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_NFS4_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/nfs4_prot.x b/illumos-x86_64/usr/include/rpcsvc/nfs4_prot.x new file mode 100644 index 00000000..26181504 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nfs4_prot.x @@ -0,0 +1,3709 @@ +/* + * This file was machine generated for [RFC7862]. + * + * Last updated Sun Mar 13 10:58:40 PDT 2016 + */ + +/* + * Copyright (c) 2016 IETF Trust and the persons identified + * as the authors. All rights reserved. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * - Neither the name of Internet Society, IETF or IETF + * Trust, nor the names of specific contributors, may be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +/* + * This code was derived from RFC 7863. + */ + +/* + * nfsv42.x + */ + +%#ifndef _AUTH_SYS_DEFINE_FOR_NFSv42 +%#define _AUTH_SYS_DEFINE_FOR_NFSv42 +%#include +%typedef struct authsys_parms authsys_parms; +%#endif /* _AUTH_SYS_DEFINE_FOR_NFSv42 */ + +/* + * Basic typedefs for RFC 1832 data type definitions + */ + +/* + * typedef int int32_t; + * typedef unsigned int uint32_t; + * typedef hyper int64_t; + * typedef unsigned hyper uint64_t; + */ + +/* + * Sizes + */ +const NFS4_FHSIZE = 128; +const NFS4_VERIFIER_SIZE = 8; +const NFS4_OTHER_SIZE = 12; +const NFS4_OPAQUE_LIMIT = 1024; +const NFS4_SESSIONID_SIZE = 16; + +const NFS4_INT64_MAX = 0x7fffffffffffffff; +const NFS4_UINT64_MAX = 0xffffffffffffffff; +const NFS4_INT32_MAX = 0x7fffffff; +const NFS4_UINT32_MAX = 0xffffffff; + +const NFS4_MAXFILELEN = 0xffffffffffffffff; +const NFS4_MAXFILEOFF = 0xfffffffffffffffe; + + +/* + * File types + */ +enum nfs_ftype4 { + NF4REG = 1, /* Regular File */ + NF4DIR = 2, /* Directory */ + NF4BLK = 3, /* Special File -- block device */ + NF4CHR = 4, /* Special File -- character device */ + NF4LNK = 5, /* Symbolic Link */ + NF4SOCK = 6, /* Special File -- socket */ + NF4FIFO = 7, /* Special File -- fifo */ + NF4ATTRDIR = 8, /* Attribute Directory */ + NF4NAMEDATTR = 9 /* Named Attribute */ +}; + +/* + * Error status + */ +enum nfsstat4 { + NFS4_OK = 0, /* everything is okay */ + NFS4ERR_PERM = 1, /* caller not privileged */ + NFS4ERR_NOENT = 2, /* no such file/directory */ + NFS4ERR_IO = 5, /* hard I/O error */ + NFS4ERR_NXIO = 6, /* no such device */ + NFS4ERR_ACCESS = 13, /* access denied */ + NFS4ERR_EXIST = 17, /* file already exists */ + NFS4ERR_XDEV = 18, /* different file systems */ + +/* + * Please do not allocate value 19; it was used in NFSv3, + * and we do not want a value in NFSv3 to have a different + * meaning in NFSv4.x. + */ + + NFS4ERR_NOTDIR = 20, /* should be a directory */ + NFS4ERR_ISDIR = 21, /* should not be a directory */ + NFS4ERR_INVAL = 22, /* invalid argument */ + NFS4ERR_FBIG = 27, /* file exceeds server max */ + NFS4ERR_NOSPC = 28, /* no space on file system */ + NFS4ERR_ROFS = 30, /* read-only file system */ + NFS4ERR_MLINK = 31, /* too many hard links */ + NFS4ERR_NAMETOOLONG = 63, /* name exceeds server max */ + NFS4ERR_NOTEMPTY = 66, /* directory not empty */ + NFS4ERR_DQUOT = 69, /* hard quota limit reached */ + NFS4ERR_STALE = 70, /* file no longer exists */ + NFS4ERR_BADHANDLE = 10001, /* illegal filehandle */ + NFS4ERR_BAD_COOKIE = 10003, /* READDIR cookie is stale */ + NFS4ERR_NOTSUPP = 10004, /* operation not supported */ + NFS4ERR_TOOSMALL = 10005, /* response limit exceeded */ + NFS4ERR_SERVERFAULT = 10006, /* undefined server error */ + NFS4ERR_BADTYPE = 10007, /* type invalid for CREATE */ + NFS4ERR_DELAY = 10008, /* file "busy" -- retry */ + NFS4ERR_SAME = 10009, /* nverify says attrs same */ + NFS4ERR_DENIED = 10010, /* lock unavailable */ + NFS4ERR_EXPIRED = 10011, /* lock lease expired */ + NFS4ERR_LOCKED = 10012, /* I/O failed due to lock */ + NFS4ERR_GRACE = 10013, /* in grace period */ + NFS4ERR_FHEXPIRED = 10014, /* filehandle expired */ + NFS4ERR_SHARE_DENIED = 10015, /* share reserve denied */ + NFS4ERR_WRONGSEC = 10016, /* wrong security flavor */ + NFS4ERR_CLID_INUSE = 10017, /* client ID in use */ + + /* NFS4ERR_RESOURCE is not a valid error in NFSv4.1. */ + NFS4ERR_RESOURCE = 10018, /* resource exhaustion */ + + NFS4ERR_MOVED = 10019, /* file system relocated */ + NFS4ERR_NOFILEHANDLE = 10020, /* current FH is not set */ + NFS4ERR_MINOR_VERS_MISMATCH= 10021, /* minor vers not supp */ + NFS4ERR_STALE_CLIENTID = 10022, /* server has rebooted */ + NFS4ERR_STALE_STATEID = 10023, /* server has rebooted */ + NFS4ERR_OLD_STATEID = 10024, /* state is out of sync */ + NFS4ERR_BAD_STATEID = 10025, /* incorrect stateid */ + NFS4ERR_BAD_SEQID = 10026, /* request is out of seq. */ + NFS4ERR_NOT_SAME = 10027, /* verify -- attrs not same */ + NFS4ERR_LOCK_RANGE = 10028, /* overlapping lock range */ + NFS4ERR_SYMLINK = 10029, /* should be file/directory */ + NFS4ERR_RESTOREFH = 10030, /* no saved filehandle */ + NFS4ERR_LEASE_MOVED = 10031, /* some file system moved */ + NFS4ERR_ATTRNOTSUPP = 10032, /* recommended attr not supp */ + NFS4ERR_NO_GRACE = 10033, /* reclaim outside of grace */ + NFS4ERR_RECLAIM_BAD = 10034, /* reclaim error at server */ + NFS4ERR_RECLAIM_CONFLICT= 10035, /* conflict on reclaim */ + NFS4ERR_BADXDR = 10036, /* XDR decode failed */ + NFS4ERR_LOCKS_HELD = 10037, /* file locks held at CLOSE */ + NFS4ERR_OPENMODE = 10038, /* conflict in OPEN and I/O */ + NFS4ERR_BADOWNER = 10039, /* owner translation bad */ + NFS4ERR_BADCHAR = 10040, /* UTF-8 char not supported */ + NFS4ERR_BADNAME = 10041, /* name not supported */ + NFS4ERR_BAD_RANGE = 10042, /* lock range not supported */ + NFS4ERR_LOCK_NOTSUPP = 10043, /* no atomic up/downgrade */ + NFS4ERR_OP_ILLEGAL = 10044, /* undefined operation */ + NFS4ERR_DEADLOCK = 10045, /* file-locking deadlock */ + NFS4ERR_FILE_OPEN = 10046, /* open file blocks op */ + NFS4ERR_ADMIN_REVOKED = 10047, /* lock-owner state revoked */ + NFS4ERR_CB_PATH_DOWN = 10048, /* callback path down */ + + /* NFSv4.1 errors start here. */ + + NFS4ERR_BADIOMODE = 10049, + NFS4ERR_BADLAYOUT = 10050, + NFS4ERR_BAD_SESSION_DIGEST = 10051, + NFS4ERR_BADSESSION = 10052, + NFS4ERR_BADSLOT = 10053, + NFS4ERR_COMPLETE_ALREADY = 10054, + NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055, + NFS4ERR_DELEG_ALREADY_WANTED = 10056, + NFS4ERR_BACK_CHAN_BUSY = 10057, /* backchan reqs outstanding */ + NFS4ERR_LAYOUTTRYLATER = 10058, + NFS4ERR_LAYOUTUNAVAILABLE = 10059, + NFS4ERR_NOMATCHING_LAYOUT = 10060, + NFS4ERR_RECALLCONFLICT = 10061, + NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062, + NFS4ERR_SEQ_MISORDERED = 10063, /* unexpected seq. ID in req */ + NFS4ERR_SEQUENCE_POS = 10064, /* [CB_]SEQ. op not 1st op */ + NFS4ERR_REQ_TOO_BIG = 10065, /* request too big */ + NFS4ERR_REP_TOO_BIG = 10066, /* reply too big */ + NFS4ERR_REP_TOO_BIG_TO_CACHE =10067, /* rep. not all cached */ + NFS4ERR_RETRY_UNCACHED_REP =10068, /* retry + rep. uncached */ + NFS4ERR_UNSAFE_COMPOUND =10069, /* retry/recovery too hard */ + NFS4ERR_TOO_MANY_OPS = 10070, /* too many ops in [CB_]COMP */ + NFS4ERR_OP_NOT_IN_SESSION =10071, /* op needs [CB_]SEQ. op */ + NFS4ERR_HASH_ALG_UNSUPP = 10072, /* hash alg. not supp */ + /* Error 10073 is unused. */ + NFS4ERR_CLIENTID_BUSY = 10074, /* client ID has state */ + NFS4ERR_PNFS_IO_HOLE = 10075, /* IO to _SPARSE file hole */ + NFS4ERR_SEQ_FALSE_RETRY= 10076, /* retry != original req */ + NFS4ERR_BAD_HIGH_SLOT = 10077, /* req has bad highest_slot */ + NFS4ERR_DEADSESSION = 10078, /* new req sent to dead sess */ + NFS4ERR_ENCR_ALG_UNSUPP= 10079, /* encr alg. not supp */ + NFS4ERR_PNFS_NO_LAYOUT = 10080, /* I/O without a layout */ + NFS4ERR_NOT_ONLY_OP = 10081, /* addl ops not allowed */ + NFS4ERR_WRONG_CRED = 10082, /* op done by wrong cred */ + NFS4ERR_WRONG_TYPE = 10083, /* op on wrong type object */ + NFS4ERR_DIRDELEG_UNAVAIL=10084, /* delegation not avail. */ + NFS4ERR_REJECT_DELEG = 10085, /* cb rejected delegation */ + NFS4ERR_RETURNCONFLICT = 10086, /* layout get before return */ + NFS4ERR_DELEG_REVOKED = 10087, /* deleg./layout revoked */ + + /* NFSv4.2 errors start here. */ + + NFS4ERR_PARTNER_NOTSUPP= 10088, /* s2s not supported */ + NFS4ERR_PARTNER_NO_AUTH= 10089, /* s2s not authorized */ + NFS4ERR_UNION_NOTSUPP = 10090, /* arm of union not supp */ + NFS4ERR_OFFLOAD_DENIED = 10091, /* dest not allowing copy */ + NFS4ERR_WRONG_LFS = 10092, /* LFS not supported */ + NFS4ERR_BADLABEL = 10093, /* incorrect label */ + NFS4ERR_OFFLOAD_NO_REQS= 10094 /* dest not meeting reqs */ +}; + +/* + * Basic data types + */ +typedef opaque attrlist4<>; +typedef uint32_t bitmap4<>; +typedef uint64_t changeid4; +typedef uint64_t clientid4; +typedef uint32_t count4; +typedef uint64_t length4; +typedef uint32_t mode4; +typedef uint64_t nfs_cookie4; +typedef opaque nfs_fh4; +typedef uint64_t offset4; +typedef uint32_t qop4; +typedef opaque sec_oid4<>; +typedef uint32_t sequenceid4; +typedef uint32_t seqid4; +typedef opaque sessionid4[NFS4_SESSIONID_SIZE]; +typedef uint32_t slotid4; +typedef opaque utf8string<>; +typedef utf8string utf8str_cis; +typedef utf8string utf8str_cs; +typedef utf8string utf8str_mixed; +typedef utf8str_cs component4; +typedef opaque linktext4<>; +typedef utf8string ascii_REQUIRED4; +typedef component4 pathname4<>; +typedef opaque verifier4[NFS4_VERIFIER_SIZE]; +typedef string secret4<>; +typedef uint32_t policy4; + +/* + * Timeval + */ +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; + +enum time_how4 { + SET_TO_SERVER_TIME4 = 0, + SET_TO_CLIENT_TIME4 = 1 +}; + +union settime4 switch (time_how4 set_it) { + case SET_TO_CLIENT_TIME4: + nfstime4 time; + default: + void; +}; + + +typedef uint32_t nfs_lease4; + +/* + * File attribute definitions + */ + +/* + * File System ID (FSID) structure for major/minor + */ +struct fsid4 { + uint64_t major; + uint64_t minor; +}; + +/* + * File system locations attribute + * for relocation/migration and + * related attributes + */ +struct change_policy4 { + uint64_t cp_major; + uint64_t cp_minor; +}; + +struct fs_location4 { + utf8str_cis server<>; + pathname4 rootpath; +}; + +struct fs_locations4 { + pathname4 fs_root; + fs_location4 locations<>; +}; + +/* + * Various Access Control Entry (ACE) definitions + */ + +/* + * Mask that indicates which ACEs are supported. + * Values for the fattr4_aclsupport attribute. + */ +const ACL4_SUPPORT_ALLOW_ACL = 0x00000001; +const ACL4_SUPPORT_DENY_ACL = 0x00000002; +const ACL4_SUPPORT_AUDIT_ACL = 0x00000004; +const ACL4_SUPPORT_ALARM_ACL = 0x00000008; + + +typedef uint32_t acetype4; + + +/* + * acetype4 values. Others can be added as needed. + */ +const ACE4_ACCESS_ALLOWED_ACE_TYPE = 0x00000000; +const ACE4_ACCESS_DENIED_ACE_TYPE = 0x00000001; +const ACE4_SYSTEM_AUDIT_ACE_TYPE = 0x00000002; +const ACE4_SYSTEM_ALARM_ACE_TYPE = 0x00000003; + + + +/* + * ACE flag + */ +typedef uint32_t aceflag4; + + +/* + * ACE flag values + */ +const ACE4_FILE_INHERIT_ACE = 0x00000001; +const ACE4_DIRECTORY_INHERIT_ACE = 0x00000002; +const ACE4_NO_PROPAGATE_INHERIT_ACE = 0x00000004; +const ACE4_INHERIT_ONLY_ACE = 0x00000008; +const ACE4_SUCCESSFUL_ACCESS_ACE_FLAG = 0x00000010; +const ACE4_FAILED_ACCESS_ACE_FLAG = 0x00000020; +const ACE4_IDENTIFIER_GROUP = 0x00000040; +const ACE4_INHERITED_ACE = 0x00000080; + + + +/* + * ACE mask + */ +typedef uint32_t acemask4; + + +/* + * ACE mask values + */ +const ACE4_READ_DATA = 0x00000001; +const ACE4_LIST_DIRECTORY = 0x00000001; +const ACE4_WRITE_DATA = 0x00000002; +const ACE4_ADD_FILE = 0x00000002; +const ACE4_APPEND_DATA = 0x00000004; +const ACE4_ADD_SUBDIRECTORY = 0x00000004; +const ACE4_READ_NAMED_ATTRS = 0x00000008; +const ACE4_WRITE_NAMED_ATTRS = 0x00000010; +const ACE4_EXECUTE = 0x00000020; +const ACE4_DELETE_CHILD = 0x00000040; +const ACE4_READ_ATTRIBUTES = 0x00000080; +const ACE4_WRITE_ATTRIBUTES = 0x00000100; +const ACE4_WRITE_RETENTION = 0x00000200; +const ACE4_WRITE_RETENTION_HOLD = 0x00000400; + +const ACE4_DELETE = 0x00010000; +const ACE4_READ_ACL = 0x00020000; +const ACE4_WRITE_ACL = 0x00040000; +const ACE4_WRITE_OWNER = 0x00080000; +const ACE4_SYNCHRONIZE = 0x00100000; + + +/* + * ACE4_GENERIC_READ -- defined as a combination of + * ACE4_READ_ACL | + * ACE4_READ_DATA | + * ACE4_READ_ATTRIBUTES | + * ACE4_SYNCHRONIZE + */ + +const ACE4_GENERIC_READ = 0x00120081; + +/* + * ACE4_GENERIC_WRITE -- defined as a combination of + * ACE4_READ_ACL | + * ACE4_WRITE_DATA | + * ACE4_WRITE_ATTRIBUTES | + * ACE4_WRITE_ACL | + * ACE4_APPEND_DATA | + * ACE4_SYNCHRONIZE + */ +const ACE4_GENERIC_WRITE = 0x00160106; + + +/* + * ACE4_GENERIC_EXECUTE -- defined as a combination of + * ACE4_READ_ACL | + * ACE4_READ_ATTRIBUTES | + * ACE4_EXECUTE | + * ACE4_SYNCHRONIZE + */ +const ACE4_GENERIC_EXECUTE = 0x001200A0; + + +/* + * ACE definition + */ +struct nfsace4 { + acetype4 type; + aceflag4 flag; + acemask4 access_mask; + utf8str_mixed who; +}; + + +/* + * Access Control List (ACL) flag + */ + +typedef uint32_t aclflag4; + +/* + * ACL flag values + */ +const ACL4_AUTO_INHERIT = 0x00000001; +const ACL4_PROTECTED = 0x00000002; +const ACL4_DEFAULTED = 0x00000004; + + +/* + * Version 4.1 ACL definition + */ +struct nfsacl41 { + aclflag4 na41_flag; + nfsace4 na41_aces<>; +}; + + +/* + * Field definitions for the fattr4_mode + * and fattr4_mode_set_masked attributes + */ +const MODE4_SUID = 0x800; /* set user id on execution */ +const MODE4_SGID = 0x400; /* set group id on execution */ +const MODE4_SVTX = 0x200; /* save text even after use */ +const MODE4_RUSR = 0x100; /* read permission: owner */ +const MODE4_WUSR = 0x080; /* write permission: owner */ +const MODE4_XUSR = 0x040; /* execute permission: owner */ +const MODE4_RGRP = 0x020; /* read permission: group */ +const MODE4_WGRP = 0x010; /* write permission: group */ +const MODE4_XGRP = 0x008; /* execute permission: group */ +const MODE4_ROTH = 0x004; /* read permission: other */ +const MODE4_WOTH = 0x002; /* write permission: other */ +const MODE4_XOTH = 0x001; /* execute permission: other */ + + +/* + * Masked mode for the mode_set_masked attribute + */ +struct mode_masked4 { + mode4 mm_value_to_set; /* Values of bits + to set or reset + in mode */ + + mode4 mm_mask_bits; /* Mask of bits to + set or reset + in mode */ +}; + +/* + * Special data/attribute associated with + * file types NF4BLK and NF4CHR + */ +struct specdata4 { + uint32_t specdata1; /* Major device number */ + uint32_t specdata2; /* Minor device number */ +}; + +/* + * Values for fattr4_fh_expire_type + */ +const FH4_PERSISTENT = 0x00000000; +const FH4_NOEXPIRE_WITH_OPEN = 0x00000001; +const FH4_VOLATILE_ANY = 0x00000002; +const FH4_VOL_MIGRATION = 0x00000004; +const FH4_VOL_RENAME = 0x00000008; + + +struct netaddr4 { + /* See struct rpcb in RFC 1833. */ + string na_r_netid<>; /* Network id */ + string na_r_addr<>; /* Universal address */ +}; + + +/* + * Data structures new to NFSv4.1 + */ + +struct nfs_impl_id4 { + utf8str_cis nii_domain; + utf8str_cs nii_name; + nfstime4 nii_date; +}; + + +/* + * Stateid + */ +struct stateid4 { + uint32_t seqid; + opaque other[NFS4_OTHER_SIZE]; +}; + +enum layouttype4 { + LAYOUT4_NFSV4_1_FILES = 0x1, + LAYOUT4_OSD2_OBJECTS = 0x2, + LAYOUT4_BLOCK_VOLUME = 0x3 +}; + +struct layout_content4 { + layouttype4 loc_type; + opaque loc_body<>; +}; + + +%/* +% * LAYOUT4_OSD2_OBJECTS loc_body description +% * is in a separate .x file. +% */ +% +%/* +% * LAYOUT4_BLOCK_VOLUME loc_body description +% * is in a separate .x file. +% */ + +struct layouthint4 { + layouttype4 loh_type; + opaque loh_body<>; +}; + +enum layoutiomode4 { + LAYOUTIOMODE4_READ = 1, + LAYOUTIOMODE4_RW = 2, + LAYOUTIOMODE4_ANY = 3 +}; + +struct layout4 { + offset4 lo_offset; + length4 lo_length; + layoutiomode4 lo_iomode; + layout_content4 lo_content; +}; + +const NFS4_DEVICEID4_SIZE = 16; + +typedef opaque deviceid4[NFS4_DEVICEID4_SIZE]; + +struct device_addr4 { + layouttype4 da_layout_type; + opaque da_addr_body<>; +}; + + +struct layoutupdate4 { + layouttype4 lou_type; + opaque lou_body<>; +}; + +% +/* Constants used for LAYOUTRETURN and CB_LAYOUTRECALL */ +const LAYOUT4_RET_REC_FILE = 1; +const LAYOUT4_RET_REC_FSID = 2; +const LAYOUT4_RET_REC_ALL = 3; +% +enum layoutreturn_type4 { + LAYOUTRETURN4_FILE = LAYOUT4_RET_REC_FILE, + LAYOUTRETURN4_FSID = LAYOUT4_RET_REC_FSID, + LAYOUTRETURN4_ALL = LAYOUT4_RET_REC_ALL +}; + +struct layoutreturn_file4 { + offset4 lrf_offset; + length4 lrf_length; + stateid4 lrf_stateid; +% /* layouttype4 specific data */ + opaque lrf_body<>; +}; + +union layoutreturn4 switch (layoutreturn_type4 lr_returntype) { + case LAYOUTRETURN4_FILE: + layoutreturn_file4 lr_layout; + default: + void; +}; +% + +enum fs4_status_type { + STATUS4_FIXED = 1, + STATUS4_UPDATED = 2, + STATUS4_VERSIONED = 3, + STATUS4_WRITABLE = 4, + STATUS4_REFERRAL = 5 +}; + +struct fs4_status { + bool fss_absent; + fs4_status_type fss_type; + utf8str_cs fss_source; + utf8str_cs fss_current; + int32_t fss_age; + nfstime4 fss_version; +}; + + +const TH4_READ_SIZE = 0; +const TH4_WRITE_SIZE = 1; +const TH4_READ_IOSIZE = 2; +const TH4_WRITE_IOSIZE = 3; + +typedef length4 threshold4_read_size; +typedef length4 threshold4_write_size; +typedef length4 threshold4_read_iosize; +typedef length4 threshold4_write_iosize; + +struct threshold_item4 { + layouttype4 thi_layout_type; + bitmap4 thi_hintset; + opaque thi_hintlist<>; +}; + +struct mdsthreshold4 { + threshold_item4 mth_hints<>; +}; + +const RET4_DURATION_INFINITE = 0xffffffffffffffff; +struct retention_get4 { + uint64_t rg_duration; + nfstime4 rg_begin_time<1>; +}; + +struct retention_set4 { + bool rs_enable; + uint64_t rs_duration<1>; +}; + +const FSCHARSET_CAP4_CONTAINS_NON_UTF8 = 0x1; +const FSCHARSET_CAP4_ALLOWS_ONLY_UTF8 = 0x2; + +typedef uint32_t fs_charset_cap4; + + +/* + * Data structures new to NFSv4.2 + */ + +enum netloc_type4 { + NL4_NAME = 1, + NL4_URL = 2, + NL4_NETADDR = 3 +}; +union netloc4 switch (netloc_type4 nl_type) { + case NL4_NAME: utf8str_cis nl_name; + case NL4_URL: utf8str_cis nl_url; + case NL4_NETADDR: netaddr4 nl_addr; +}; + +enum change_attr_type4 { + NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR = 0, + NFS4_CHANGE_TYPE_IS_VERSION_COUNTER = 1, + NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS = 2, + NFS4_CHANGE_TYPE_IS_TIME_METADATA = 3, + NFS4_CHANGE_TYPE_IS_UNDEFINED = 4 +}; + +struct labelformat_spec4 { + policy4 lfs_lfs; + policy4 lfs_pi; +}; + +struct sec_label4 { + labelformat_spec4 slai_lfs; + opaque slai_data<>; +}; + + +struct copy_from_auth_priv { + secret4 cfap_shared_secret; + netloc4 cfap_destination; + /* The NFSv4 user name that the user principal maps to */ + utf8str_mixed cfap_username; +}; + +struct copy_to_auth_priv { + /* Equal to cfap_shared_secret */ + secret4 ctap_shared_secret; + netloc4 ctap_source<>; + /* The NFSv4 user name that the user principal maps to */ + utf8str_mixed ctap_username; +}; + +struct copy_confirm_auth_priv { + /* Equal to GSS_GetMIC() of cfap_shared_secret */ + opaque ccap_shared_secret_mic<>; + /* The NFSv4 user name that the user principal maps to */ + utf8str_mixed ccap_username; +}; + + +struct app_data_block4 { + offset4 adb_offset; + length4 adb_block_size; + length4 adb_block_count; + length4 adb_reloff_blocknum; + count4 adb_block_num; + length4 adb_reloff_pattern; + opaque adb_pattern<>; +}; + + +struct data4 { + offset4 d_offset; + opaque d_data<>; +}; + +struct data_info4 { + offset4 di_offset; + length4 di_length; +}; + + +enum data_content4 { + NFS4_CONTENT_DATA = 0, + NFS4_CONTENT_HOLE = 1 +}; + + + +enum stable_how4 { + UNSTABLE4 = 0, + DATA_SYNC4 = 1, + FILE_SYNC4 = 2 +}; + + + +struct write_response4 { + stateid4 wr_callback_id<1>; + length4 wr_count; + stable_how4 wr_committed; + verifier4 wr_writeverf; +}; + + +/* + * NFSv4.1 attributes + */ +typedef bitmap4 fattr4_supported_attrs; +typedef nfs_ftype4 fattr4_type; +typedef uint32_t fattr4_fh_expire_type; +typedef changeid4 fattr4_change; +typedef uint64_t fattr4_size; +typedef bool fattr4_link_support; +typedef bool fattr4_symlink_support; +typedef bool fattr4_named_attr; +typedef fsid4 fattr4_fsid; +typedef bool fattr4_unique_handles; +typedef nfs_lease4 fattr4_lease_time; +typedef nfsstat4 fattr4_rdattr_error; +typedef nfsace4 fattr4_acl<>; +typedef uint32_t fattr4_aclsupport; +typedef bool fattr4_archive; +typedef bool fattr4_cansettime; +typedef bool fattr4_case_insensitive; +typedef bool fattr4_case_preserving; +typedef bool fattr4_chown_restricted; +typedef uint64_t fattr4_fileid; +typedef uint64_t fattr4_files_avail; +typedef nfs_fh4 fattr4_filehandle; +typedef uint64_t fattr4_files_free; +typedef uint64_t fattr4_files_total; +typedef fs_locations4 fattr4_fs_locations; +typedef bool fattr4_hidden; +typedef bool fattr4_homogeneous; +typedef uint64_t fattr4_maxfilesize; +typedef uint32_t fattr4_maxlink; +typedef uint32_t fattr4_maxname; +typedef uint64_t fattr4_maxread; +typedef uint64_t fattr4_maxwrite; +typedef ascii_REQUIRED4 fattr4_mimetype; +typedef mode4 fattr4_mode; +typedef mode_masked4 fattr4_mode_set_masked; +typedef uint64_t fattr4_mounted_on_fileid; +typedef bool fattr4_no_trunc; +typedef uint32_t fattr4_numlinks; +typedef utf8str_mixed fattr4_owner; +typedef utf8str_mixed fattr4_owner_group; +typedef uint64_t fattr4_quota_avail_hard; +typedef uint64_t fattr4_quota_avail_soft; +typedef uint64_t fattr4_quota_used; +typedef specdata4 fattr4_rawdev; +typedef uint64_t fattr4_space_avail; +typedef length4 fattr4_space_free; +typedef uint64_t fattr4_space_total; +typedef uint64_t fattr4_space_used; +typedef bool fattr4_system; +typedef nfstime4 fattr4_time_access; +typedef settime4 fattr4_time_access_set; +typedef nfstime4 fattr4_time_backup; +typedef nfstime4 fattr4_time_create; +typedef nfstime4 fattr4_time_delta; +typedef nfstime4 fattr4_time_metadata; +typedef nfstime4 fattr4_time_modify; +typedef settime4 fattr4_time_modify_set; +/* + * Attributes new to NFSv4.1 + */ +typedef bitmap4 fattr4_suppattr_exclcreat; +typedef nfstime4 fattr4_dir_notif_delay; +typedef nfstime4 fattr4_dirent_notif_delay; +typedef layouttype4 fattr4_fs_layout_types<>; +typedef fs4_status fattr4_fs_status; +typedef fs_charset_cap4 fattr4_fs_charset_cap; +typedef uint32_t fattr4_layout_alignment; +typedef uint32_t fattr4_layout_blksize; +typedef layouthint4 fattr4_layout_hint; +typedef layouttype4 fattr4_layout_types<>; +typedef mdsthreshold4 fattr4_mdsthreshold; +typedef retention_get4 fattr4_retention_get; +typedef retention_set4 fattr4_retention_set; +typedef retention_get4 fattr4_retentevt_get; +typedef retention_set4 fattr4_retentevt_set; +typedef uint64_t fattr4_retention_hold; +typedef nfsacl41 fattr4_dacl; +typedef nfsacl41 fattr4_sacl; +typedef change_policy4 fattr4_change_policy; +/* + * Attributes new to NFSv4.2 + */ +typedef uint64_t fattr4_space_freed; +typedef change_attr_type4 + fattr4_change_attr_type; +typedef sec_label4 fattr4_sec_label; +typedef uint32_t fattr4_clone_blksize; + +%/* +% * REQUIRED attributes +% */ +const FATTR4_SUPPORTED_ATTRS = 0; +const FATTR4_TYPE = 1; +const FATTR4_FH_EXPIRE_TYPE = 2; +const FATTR4_CHANGE = 3; +const FATTR4_SIZE = 4; +const FATTR4_LINK_SUPPORT = 5; +const FATTR4_SYMLINK_SUPPORT = 6; +const FATTR4_NAMED_ATTR = 7; +const FATTR4_FSID = 8; +const FATTR4_UNIQUE_HANDLES = 9; +const FATTR4_LEASE_TIME = 10; +const FATTR4_RDATTR_ERROR = 11; +const FATTR4_FILEHANDLE = 19; + +%/* +% * New to NFSv4.1 +% */ +const FATTR4_SUPPATTR_EXCLCREAT = 75; + +%/* +% * RECOMMENDED attributes +% */ +const FATTR4_ACL = 12; +const FATTR4_ACLSUPPORT = 13; +const FATTR4_ARCHIVE = 14; +const FATTR4_CANSETTIME = 15; +const FATTR4_CASE_INSENSITIVE = 16; +const FATTR4_CASE_PRESERVING = 17; +const FATTR4_CHOWN_RESTRICTED = 18; +const FATTR4_FILEID = 20; +const FATTR4_FILES_AVAIL = 21; +const FATTR4_FILES_FREE = 22; +const FATTR4_FILES_TOTAL = 23; +const FATTR4_FS_LOCATIONS = 24; +const FATTR4_HIDDEN = 25; +const FATTR4_HOMOGENEOUS = 26; +const FATTR4_MAXFILESIZE = 27; +const FATTR4_MAXLINK = 28; +const FATTR4_MAXNAME = 29; +const FATTR4_MAXREAD = 30; +const FATTR4_MAXWRITE = 31; +const FATTR4_MIMETYPE = 32; +const FATTR4_MODE = 33; +const FATTR4_NO_TRUNC = 34; +const FATTR4_NUMLINKS = 35; +const FATTR4_OWNER = 36; +const FATTR4_OWNER_GROUP = 37; +const FATTR4_QUOTA_AVAIL_HARD = 38; +const FATTR4_QUOTA_AVAIL_SOFT = 39; +const FATTR4_QUOTA_USED = 40; +const FATTR4_RAWDEV = 41; +const FATTR4_SPACE_AVAIL = 42; +const FATTR4_SPACE_FREE = 43; +const FATTR4_SPACE_TOTAL = 44; +const FATTR4_SPACE_USED = 45; +const FATTR4_SYSTEM = 46; +const FATTR4_TIME_ACCESS = 47; +const FATTR4_TIME_ACCESS_SET = 48; +const FATTR4_TIME_BACKUP = 49; +const FATTR4_TIME_CREATE = 50; +const FATTR4_TIME_DELTA = 51; +const FATTR4_TIME_METADATA = 52; +const FATTR4_TIME_MODIFY = 53; +const FATTR4_TIME_MODIFY_SET = 54; +const FATTR4_MOUNTED_ON_FILEID = 55; + +%/* +% * New to NFSv4.1 +% */ +const FATTR4_DIR_NOTIF_DELAY = 56; +const FATTR4_DIRENT_NOTIF_DELAY = 57; +const FATTR4_DACL = 58; +const FATTR4_SACL = 59; +const FATTR4_CHANGE_POLICY = 60; +const FATTR4_FS_STATUS = 61; +const FATTR4_FS_LAYOUT_TYPES = 62; +const FATTR4_LAYOUT_HINT = 63; +const FATTR4_LAYOUT_TYPES = 64; +const FATTR4_LAYOUT_BLKSIZE = 65; +const FATTR4_LAYOUT_ALIGNMENT = 66; +const FATTR4_FS_LOCATIONS_INFO = 67; +const FATTR4_MDSTHRESHOLD = 68; +const FATTR4_RETENTION_GET = 69; +const FATTR4_RETENTION_SET = 70; +const FATTR4_RETENTEVT_GET = 71; +const FATTR4_RETENTEVT_SET = 72; +const FATTR4_RETENTION_HOLD = 73; +const FATTR4_MODE_SET_MASKED = 74; +const FATTR4_FS_CHARSET_CAP = 76; + +%/* +% * New to NFSv4.2 +% */ +const FATTR4_CLONE_BLKSIZE = 77; +const FATTR4_SPACE_FREED = 78; +const FATTR4_CHANGE_ATTR_TYPE = 79; +const FATTR4_SEC_LABEL = 80; + +/* + * File attribute container + */ +struct fattr4 { + bitmap4 attrmask; + attrlist4 attr_vals; +}; + +/* + * Change info for the client + */ +struct change_info4 { + bool atomic; + changeid4 before; + changeid4 after; +}; + +typedef netaddr4 clientaddr4; + +/* + * Callback program info as provided by the client + */ +struct cb_client4 { + uint32_t cb_program; + netaddr4 cb_location; +}; + +/* + * NFSv4.0 long-hand client ID + */ +struct nfs_client_id4 { + verifier4 verifier; + opaque id; +}; + +/* + * NFSv4.1 client owner (aka long-hand client ID) + */ +struct client_owner4 { + verifier4 co_verifier; + opaque co_ownerid; +}; + + +/* + * NFSv4.1 server owner + */ +struct server_owner4 { + uint64_t so_minor_id; + opaque so_major_id; +}; + + +struct state_owner4 { + clientid4 clientid; + opaque owner; +}; + +typedef state_owner4 open_owner4; +typedef state_owner4 lock_owner4; + + +enum nfs_lock_type4 { + READ_LT = 1, + WRITE_LT = 2, + READW_LT = 3, /* Blocking read */ + WRITEW_LT = 4 /* Blocking write */ +}; + + +% +%/* Input for computing subkeys */ +enum ssv_subkey4 { + SSV4_SUBKEY_MIC_I2T = 1, + SSV4_SUBKEY_MIC_T2I = 2, + SSV4_SUBKEY_SEAL_I2T = 3, + SSV4_SUBKEY_SEAL_T2I = 4 +}; +% + +% +%/* Input for computing smt_hmac */ +struct ssv_mic_plain_tkn4 { + uint32_t smpt_ssv_seq; + opaque smpt_orig_plain<>; +}; +% + +% +%/* +% * Secret State Verifier Generic Security Service (SSV GSS) +% * PerMsgToken token +% */ +struct ssv_mic_tkn4 { + uint32_t smt_ssv_seq; + opaque smt_hmac<>; +}; +% + +% +%/* Input for computing ssct_encr_data and ssct_hmac */ +struct ssv_seal_plain_tkn4 { + opaque sspt_confounder<>; + uint32_t sspt_ssv_seq; + opaque sspt_orig_plain<>; + opaque sspt_pad<>; +}; +% + +% +%/* SSV GSS SealedMessage token */ +struct ssv_seal_cipher_tkn4 { + uint32_t ssct_ssv_seq; + opaque ssct_iv<>; + opaque ssct_encr_data<>; + opaque ssct_hmac<>; +}; +% + +/* + * Defines an individual server replica + */ +struct fs_locations_server4 { + int32_t fls_currency; + opaque fls_info<>; + utf8str_cis fls_server; +}; + +/* + * Byte indices of items within + * fls_info: flag fields, class numbers, + * bytes indicating ranks and orders + */ +const FSLI4BX_GFLAGS = 0; +const FSLI4BX_TFLAGS = 1; + +const FSLI4BX_CLSIMUL = 2; +const FSLI4BX_CLHANDLE = 3; +const FSLI4BX_CLFILEID = 4; +const FSLI4BX_CLWRITEVER = 5; +const FSLI4BX_CLCHANGE = 6; +const FSLI4BX_CLREADDIR = 7; + +const FSLI4BX_READRANK = 8; +const FSLI4BX_WRITERANK = 9; +const FSLI4BX_READORDER = 10; +const FSLI4BX_WRITEORDER = 11; + +/* + * Bits defined within the general flag byte + */ +const FSLI4GF_WRITABLE = 0x01; +const FSLI4GF_CUR_REQ = 0x02; +const FSLI4GF_ABSENT = 0x04; +const FSLI4GF_GOING = 0x08; +const FSLI4GF_SPLIT = 0x10; + +/* + * Bits defined within the transport flag byte + */ +const FSLI4TF_RDMA = 0x01; + +/* + * Defines a set of replicas sharing + * a common value of the root path + * within the corresponding + * single-server namespaces + */ +struct fs_locations_item4 { + fs_locations_server4 fli_entries<>; + pathname4 fli_rootpath; +}; + +/* + * Defines the overall structure of + * the fs_locations_info attribute + */ +struct fs_locations_info4 { + uint32_t fli_flags; + int32_t fli_valid_for; + pathname4 fli_fs_root; + fs_locations_item4 fli_items<>; +}; + +/* + * Flag bits in fli_flags + */ +const FSLI4IF_VAR_SUB = 0x00000001; + +typedef fs_locations_info4 fattr4_fs_locations_info; + +const NFL4_UFLG_MASK = 0x0000003F; +const NFL4_UFLG_DENSE = 0x00000001; +const NFL4_UFLG_COMMIT_THRU_MDS = 0x00000002; +const NFL42_UFLG_IO_ADVISE_THRU_MDS = 0x00000004; +const NFL4_UFLG_STRIPE_UNIT_SIZE_MASK = 0xFFFFFFC0; + +typedef uint32_t nfl_util4; + +% + +enum filelayout_hint_care4 { + NFLH4_CARE_DENSE = NFL4_UFLG_DENSE, + + NFLH4_CARE_COMMIT_THRU_MDS + = NFL4_UFLG_COMMIT_THRU_MDS, + + NFL42_CARE_IO_ADVISE_THRU_MDS + = NFL42_UFLG_IO_ADVISE_THRU_MDS, + + NFLH4_CARE_STRIPE_UNIT_SIZE + = 0x00000040, + + NFLH4_CARE_STRIPE_COUNT = 0x00000080 +}; +% +%/* +% * Encoded in the loh_body field of data type layouthint4: +% */ +% +struct nfsv4_1_file_layouthint4 { + uint32_t nflh_care; + nfl_util4 nflh_util; + count4 nflh_stripe_count; +}; + +% + +% +typedef netaddr4 multipath_list4<>; +% +%/* +% * Encoded in the da_addr_body field of data type device_addr4: +% */ +struct nfsv4_1_file_layout_ds_addr4 { + uint32_t nflda_stripe_indices<>; + multipath_list4 nflda_multipath_ds_list<>; +}; + +% + +% +%/* +% * Encoded in the loc_body field of data type layout_content4: +% */ +struct nfsv4_1_file_layout4 { + deviceid4 nfl_deviceid; + nfl_util4 nfl_util; + uint32_t nfl_first_stripe_index; + offset4 nfl_pattern_offset; + nfs_fh4 nfl_fh_list<>; +}; + +% + + +/* + * Operation arrays (the opnum first) + */ + +enum nfs_opnum4 { + OP_ACCESS = 3, + OP_CLOSE = 4, + OP_COMMIT = 5, + OP_CREATE = 6, + OP_DELEGPURGE = 7, + OP_DELEGRETURN = 8, + OP_GETATTR = 9, + OP_GETFH = 10, + OP_LINK = 11, + OP_LOCK = 12, + OP_LOCKT = 13, + OP_LOCKU = 14, + OP_LOOKUP = 15, + OP_LOOKUPP = 16, + OP_NVERIFY = 17, + OP_OPEN = 18, + OP_OPENATTR = 19, + OP_OPEN_CONFIRM = 20, /* Mandatory not-to-implement */ + OP_OPEN_DOWNGRADE = 21, + OP_PUTFH = 22, + OP_PUTPUBFH = 23, + OP_PUTROOTFH = 24, + OP_READ = 25, + OP_READDIR = 26, + OP_READLINK = 27, + OP_REMOVE = 28, + OP_RENAME = 29, + OP_RENEW = 30, /* Mandatory not-to-implement */ + OP_RESTOREFH = 31, + OP_SAVEFH = 32, + OP_SECINFO = 33, + OP_SETATTR = 34, + OP_SETCLIENTID = 35, /* Mandatory not-to-implement */ + OP_SETCLIENTID_CONFIRM = 36, /* Mandatory not-to-implement */ + OP_VERIFY = 37, + OP_WRITE = 38, + OP_RELEASE_LOCKOWNER = 39, /* Mandatory not-to-implement */ +% +%/* New operations for NFSv4.1 */ +% + OP_BACKCHANNEL_CTL = 40, + OP_BIND_CONN_TO_SESSION = 41, + OP_EXCHANGE_ID = 42, + OP_CREATE_SESSION = 43, + OP_DESTROY_SESSION = 44, + OP_FREE_STATEID = 45, + OP_GET_DIR_DELEGATION = 46, + OP_GETDEVICEINFO = 47, + OP_GETDEVICELIST = 48, + OP_LAYOUTCOMMIT = 49, + OP_LAYOUTGET = 50, + OP_LAYOUTRETURN = 51, + OP_SECINFO_NO_NAME = 52, + OP_SEQUENCE = 53, + OP_SET_SSV = 54, + OP_TEST_STATEID = 55, + OP_WANT_DELEGATION = 56, + OP_DESTROY_CLIENTID = 57, + OP_RECLAIM_COMPLETE = 58, +% +%/* New operations for NFSv4.2 */ +% + OP_ALLOCATE = 59, + OP_COPY = 60, + OP_COPY_NOTIFY = 61, + OP_DEALLOCATE = 62, + OP_IO_ADVISE = 63, + OP_LAYOUTERROR = 64, + OP_LAYOUTSTATS = 65, + OP_OFFLOAD_CANCEL = 66, + OP_OFFLOAD_STATUS = 67, + OP_READ_PLUS = 68, + OP_SEEK = 69, + OP_WRITE_SAME = 70, + OP_CLONE = 71, + OP_ILLEGAL = 10044 +}; + + + +const ACCESS4_READ = 0x00000001; +const ACCESS4_LOOKUP = 0x00000002; +const ACCESS4_MODIFY = 0x00000004; +const ACCESS4_EXTEND = 0x00000008; +const ACCESS4_DELETE = 0x00000010; +const ACCESS4_EXECUTE = 0x00000020; + +struct ACCESS4args { + /* CURRENT_FH: object */ + uint32_t access; +}; + +struct ACCESS4resok { + uint32_t supported; + uint32_t access; +}; + +union ACCESS4res switch (nfsstat4 status) { + case NFS4_OK: + ACCESS4resok resok4; + default: + void; +}; + +struct CLONE4args { + /* SAVED_FH: source file */ + /* CURRENT_FH: destination file */ + stateid4 cl_src_stateid; + stateid4 cl_dst_stateid; + offset4 cl_src_offset; + offset4 cl_dst_offset; + length4 cl_count; +}; + +struct CLONE4res { + nfsstat4 cl_status; +}; +struct CLOSE4args { + /* CURRENT_FH: object */ + seqid4 seqid; + stateid4 open_stateid; +}; + +union CLOSE4res switch (nfsstat4 status) { + case NFS4_OK: + stateid4 open_stateid; + default: + void; +}; + +struct COMMIT4args { + /* CURRENT_FH: file */ + offset4 offset; + count4 count; +}; + +struct COMMIT4resok { + verifier4 writeverf; +}; + +union COMMIT4res switch (nfsstat4 status) { + case NFS4_OK: + COMMIT4resok resok4; + default: + void; +}; + +union createtype4 switch (nfs_ftype4 type) { + case NF4LNK: + linktext4 linkdata; + case NF4BLK: + case NF4CHR: + specdata4 devdata; + case NF4SOCK: + case NF4FIFO: + case NF4DIR: + void; + default: + void; /* Server should return NFS4ERR_BADTYPE. */ +}; + +struct CREATE4args { + /* CURRENT_FH: directory for creation */ + createtype4 objtype; + component4 objname; + fattr4 createattrs; +}; + +struct CREATE4resok { + change_info4 cinfo; + bitmap4 attrset; /* Attributes set */ +}; + +union CREATE4res switch (nfsstat4 status) { + case NFS4_OK: + /* New CURRENTFH: created object */ + CREATE4resok resok4; + default: + void; +}; + +struct DELEGPURGE4args { + clientid4 clientid; +}; + +struct DELEGPURGE4res { + nfsstat4 status; +}; + +struct DELEGRETURN4args { + /* CURRENT_FH: delegated object */ + stateid4 deleg_stateid; +}; + +struct DELEGRETURN4res { + nfsstat4 status; +}; + +struct GETATTR4args { + /* CURRENT_FH: object */ + bitmap4 attr_request; +}; + +struct GETATTR4resok { + fattr4 obj_attributes; +}; + +union GETATTR4res switch (nfsstat4 status) { + case NFS4_OK: + GETATTR4resok resok4; + default: + void; +}; + +struct GETFH4resok { + nfs_fh4 object; +}; + +union GETFH4res switch (nfsstat4 status) { + case NFS4_OK: + GETFH4resok resok4; + default: + void; +}; + +struct LINK4args { + /* SAVED_FH: source object */ + /* CURRENT_FH: target directory */ + component4 newname; +}; + +struct LINK4resok { + change_info4 cinfo; +}; + +union LINK4res switch (nfsstat4 status) { + case NFS4_OK: + LINK4resok resok4; + default: + void; +}; + +/* + * For LOCK, transition from open_stateid and lock_owner + * to a lock stateid. + */ +struct open_to_lock_owner4 { + seqid4 open_seqid; + stateid4 open_stateid; + seqid4 lock_seqid; + lock_owner4 lock_owner; +}; + +/* + * For LOCK, existing lock stateid continues to request new + * file lock for the same lock_owner and open_stateid. + */ +struct exist_lock_owner4 { + stateid4 lock_stateid; + seqid4 lock_seqid; +}; + +union locker4 switch (bool new_lock_owner) { + case TRUE: + open_to_lock_owner4 open_owner; + case FALSE: + exist_lock_owner4 lock_owner; +}; + +/* + * LOCK/LOCKT/LOCKU: Record lock management + */ +struct LOCK4args { + /* CURRENT_FH: file */ + nfs_lock_type4 locktype; + bool reclaim; + offset4 offset; + length4 length; + locker4 locker; +}; + +struct LOCK4denied { + offset4 offset; + length4 length; + nfs_lock_type4 locktype; + lock_owner4 owner; +}; + +struct LOCK4resok { + stateid4 lock_stateid; +}; + +union LOCK4res switch (nfsstat4 status) { + case NFS4_OK: + LOCK4resok resok4; + case NFS4ERR_DENIED: + LOCK4denied denied; + default: + void; +}; + +struct LOCKT4args { + /* CURRENT_FH: file */ + nfs_lock_type4 locktype; + offset4 offset; + length4 length; + lock_owner4 owner; +}; + +union LOCKT4res switch (nfsstat4 status) { + case NFS4ERR_DENIED: + LOCK4denied denied; + case NFS4_OK: + void; + default: + void; +}; + +struct LOCKU4args { + /* CURRENT_FH: file */ + nfs_lock_type4 locktype; + seqid4 seqid; + stateid4 lock_stateid; + offset4 offset; + length4 length; +}; + +union LOCKU4res switch (nfsstat4 status) { + case NFS4_OK: + stateid4 lock_stateid; + default: + void; +}; + +struct LOOKUP4args { + /* CURRENT_FH: directory */ + component4 objname; +}; + +struct LOOKUP4res { + /* New CURRENT_FH: object */ + nfsstat4 status; +}; + +struct LOOKUPP4res { + /* New CURRENT_FH: parent directory */ + nfsstat4 status; +}; + +struct NVERIFY4args { + /* CURRENT_FH: object */ + fattr4 obj_attributes; +}; + +struct NVERIFY4res { + nfsstat4 status; +}; + +/* + * Various definitions for OPEN + */ +enum createmode4 { + UNCHECKED4 = 0, + GUARDED4 = 1, + /* Deprecated in NFSv4.1 */ + EXCLUSIVE4 = 2, + /* + * New to NFSv4.1. If session is persistent, + * GUARDED4 MUST be used. Otherwise, use + * EXCLUSIVE4_1 instead of EXCLUSIVE4. + */ + EXCLUSIVE4_1 = 3 +}; + +struct creatverfattr { + verifier4 cva_verf; + fattr4 cva_attrs; +}; + +union createhow4 switch (createmode4 mode) { + case UNCHECKED4: + case GUARDED4: + fattr4 createattrs; + case EXCLUSIVE4: + verifier4 createverf; + case EXCLUSIVE4_1: + creatverfattr ch_createboth; +}; + +enum opentype4 { + OPEN4_NOCREATE = 0, + OPEN4_CREATE = 1 +}; + +union openflag4 switch (opentype4 opentype) { + case OPEN4_CREATE: + createhow4 how; + default: + void; +}; + +/* Next definitions used for OPEN delegation */ +enum limit_by4 { + NFS_LIMIT_SIZE = 1, + NFS_LIMIT_BLOCKS = 2 + /* Others as needed */ +}; + +struct nfs_modified_limit4 { + uint32_t num_blocks; + uint32_t bytes_per_block; +}; + +union nfs_space_limit4 switch (limit_by4 limitby) { + /* Limit specified as file size */ + case NFS_LIMIT_SIZE: + uint64_t filesize; + /* Limit specified by number of blocks */ + case NFS_LIMIT_BLOCKS: + nfs_modified_limit4 mod_blocks; +}; + +/* + * Share Access and Deny constants for open argument + */ +const OPEN4_SHARE_ACCESS_READ = 0x00000001; +const OPEN4_SHARE_ACCESS_WRITE = 0x00000002; +const OPEN4_SHARE_ACCESS_BOTH = 0x00000003; + +const OPEN4_SHARE_DENY_NONE = 0x00000000; +const OPEN4_SHARE_DENY_READ = 0x00000001; +const OPEN4_SHARE_DENY_WRITE = 0x00000002; +const OPEN4_SHARE_DENY_BOTH = 0x00000003; + + +/* New flags for share_access field of OPEN4args */ +const OPEN4_SHARE_ACCESS_WANT_DELEG_MASK = 0xFF00; +const OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE = 0x0000; +const OPEN4_SHARE_ACCESS_WANT_READ_DELEG = 0x0100; +const OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG = 0x0200; +const OPEN4_SHARE_ACCESS_WANT_ANY_DELEG = 0x0300; +const OPEN4_SHARE_ACCESS_WANT_NO_DELEG = 0x0400; +const OPEN4_SHARE_ACCESS_WANT_CANCEL = 0x0500; + +const + OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL + = 0x10000; + +const + OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED + = 0x20000; + +enum open_delegation_type4 { + OPEN_DELEGATE_NONE = 0, + OPEN_DELEGATE_READ = 1, + OPEN_DELEGATE_WRITE = 2, + OPEN_DELEGATE_NONE_EXT = 3 /* New to NFSv4.1 */ +}; + +enum open_claim_type4 { + /* + * Not a reclaim + */ + CLAIM_NULL = 0, + + CLAIM_PREVIOUS = 1, + CLAIM_DELEGATE_CUR = 2, + CLAIM_DELEGATE_PREV = 3, + + /* + * Not a reclaim + * + * Like CLAIM_NULL, but object identified + * by the current filehandle + */ + CLAIM_FH = 4, /* New to NFSv4.1 */ + + /* + * Like CLAIM_DELEGATE_CUR, but object identified + * by current filehandle + */ + CLAIM_DELEG_CUR_FH = 5, /* New to NFSv4.1 */ + + /* + * Like CLAIM_DELEGATE_PREV, but object identified + * by current filehandle + */ + CLAIM_DELEG_PREV_FH = 6 /* New to NFSv4.1 */ +}; + +struct open_claim_delegate_cur4 { + stateid4 delegate_stateid; + component4 file; +}; + +union open_claim4 switch (open_claim_type4 claim) { + /* + * No special rights to file. + * Ordinary OPEN of the specified file. + */ + case CLAIM_NULL: + /* CURRENT_FH: directory */ + component4 file; + /* + * Right to the file established by an + * open previous to server reboot. File + * identified by filehandle obtained at + * that time rather than by name. + */ + case CLAIM_PREVIOUS: + /* CURRENT_FH: file being reclaimed */ + open_delegation_type4 delegate_type; + + /* + * Right to file based on a delegation + * granted by the server. File is + * specified by name. + */ + case CLAIM_DELEGATE_CUR: + /* CURRENT_FH: directory */ + open_claim_delegate_cur4 delegate_cur_info; + + /* + * Right to file based on a delegation + * granted to a previous boot instance + * of the client. File is specified by name. + */ + case CLAIM_DELEGATE_PREV: + /* CURRENT_FH: directory */ + component4 file_delegate_prev; + + /* + * Like CLAIM_NULL. No special rights + * to file. Ordinary OPEN of the + * specified file by current filehandle. + */ + case CLAIM_FH: /* New to NFSv4.1 */ + /* CURRENT_FH: regular file to open */ + void; + + /* + * Like CLAIM_DELEGATE_PREV. Right to file based on a + * delegation granted to a previous boot + * instance of the client. File is identified + * by filehandle. + */ + case CLAIM_DELEG_PREV_FH: /* New to NFSv4.1 */ + /* CURRENT_FH: file being opened */ + void; + + /* + * Like CLAIM_DELEGATE_CUR. Right to file based on + * a delegation granted by the server. + * File is identified by filehandle. + */ + case CLAIM_DELEG_CUR_FH: /* New to NFSv4.1 */ + /* CURRENT_FH: file being opened */ + stateid4 oc_delegate_stateid; + +}; + +/* + * OPEN: Open a file, potentially receiving an open delegation. + */ +struct OPEN4args { + seqid4 seqid; + uint32_t share_access; + uint32_t share_deny; + open_owner4 owner; + openflag4 openhow; + open_claim4 claim; +}; + +struct open_read_delegation4 { + stateid4 stateid; /* Stateid for delegation */ + bool recall; /* Pre-recalled flag for + delegations obtained + by reclaim (CLAIM_PREVIOUS) */ + + nfsace4 permissions; /* Defines users who don't + need an ACCESS call to + open for read */ +}; + +struct open_write_delegation4 { + stateid4 stateid; /* Stateid for delegation */ + bool recall; /* Pre-recalled flag for + delegations obtained + by reclaim + (CLAIM_PREVIOUS) */ + + nfs_space_limit4 + space_limit; /* Defines condition that + the client must check to + determine whether the + file needs to be flushed + to the server on close */ + + nfsace4 permissions; /* Defines users who don't + need an ACCESS call as + part of a delegated + open */ +}; + + +enum why_no_delegation4 { /* New to NFSv4.1 */ + WND4_NOT_WANTED = 0, + WND4_CONTENTION = 1, + WND4_RESOURCE = 2, + WND4_NOT_SUPP_FTYPE = 3, + WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4, + WND4_NOT_SUPP_UPGRADE = 5, + WND4_NOT_SUPP_DOWNGRADE = 6, + WND4_CANCELLED = 7, + WND4_IS_DIR = 8 +}; + +union open_none_delegation4 /* New to NFSv4.1 */ + switch (why_no_delegation4 ond_why) { + case WND4_CONTENTION: + bool ond_server_will_push_deleg; + case WND4_RESOURCE: + bool ond_server_will_signal_avail; + default: + void; +}; + +union open_delegation4 + switch (open_delegation_type4 delegation_type) { + case OPEN_DELEGATE_NONE: + void; + case OPEN_DELEGATE_READ: + open_read_delegation4 read; + case OPEN_DELEGATE_WRITE: + open_write_delegation4 write; + case OPEN_DELEGATE_NONE_EXT: /* New to NFSv4.1 */ + open_none_delegation4 od_whynone; +}; + +/* + * Result flags + */ + +/* Client must confirm open. */ +const OPEN4_RESULT_CONFIRM = 0x00000002; +/* Type of file-locking behavior at the server */ +const OPEN4_RESULT_LOCKTYPE_POSIX = 0x00000004; +/* Server will preserve file if removed while open. */ +const OPEN4_RESULT_PRESERVE_UNLINKED = 0x00000008; + +/* + * Server may use CB_NOTIFY_LOCK on locks + * derived from this open. + */ +const OPEN4_RESULT_MAY_NOTIFY_LOCK = 0x00000020; + +struct OPEN4resok { + stateid4 stateid; /* Stateid for open */ + change_info4 cinfo; /* Directory change info */ + uint32_t rflags; /* Result flags */ + bitmap4 attrset; /* Attribute set for create */ + open_delegation4 delegation; /* Info on any open + delegation */ +}; + +union OPEN4res switch (nfsstat4 status) { + case NFS4_OK: + /* New CURRENT_FH: opened file */ + OPEN4resok resok4; + default: + void; +}; + +struct OPENATTR4args { + /* CURRENT_FH: object */ + bool createdir; +}; + +struct OPENATTR4res { + /* + * If status is NFS4_OK, + * New CURRENT_FH: named attribute + * directory + */ + nfsstat4 status; +}; + +/* Obsolete in NFSv4.1 */ +struct OPEN_CONFIRM4args { + /* CURRENT_FH: opened file */ + stateid4 open_stateid; + seqid4 seqid; +}; + +struct OPEN_CONFIRM4resok { + stateid4 open_stateid; +}; + +union OPEN_CONFIRM4res switch (nfsstat4 status) { + case NFS4_OK: + OPEN_CONFIRM4resok resok4; + default: + void; +}; + +struct OPEN_DOWNGRADE4args { + /* CURRENT_FH: opened file */ + stateid4 open_stateid; + seqid4 seqid; + uint32_t share_access; + uint32_t share_deny; +}; + +struct OPEN_DOWNGRADE4resok { + stateid4 open_stateid; +}; + +union OPEN_DOWNGRADE4res switch (nfsstat4 status) { + case NFS4_OK: + OPEN_DOWNGRADE4resok resok4; + default: + void; +}; + +struct PUTFH4args { + nfs_fh4 object; +}; + +struct PUTFH4res { + /* + * If status is NFS4_OK, + * New CURRENT_FH: argument to PUTFH + */ + nfsstat4 status; +}; + +struct PUTPUBFH4res { + /* + * If status is NFS4_OK, + * New CURRENT_FH: public fh + */ + nfsstat4 status; +}; + +struct PUTROOTFH4res { + /* + * If status is NFS4_OK, + * New CURRENT_FH: root fh + */ + nfsstat4 status; +}; + +struct READ4args { + /* CURRENT_FH: file */ + stateid4 stateid; + offset4 offset; + count4 count; +}; + +struct READ4resok { + bool eof; + opaque data<>; +}; + +union READ4res switch (nfsstat4 status) { + case NFS4_OK: + READ4resok resok4; + default: + void; +}; + +struct READDIR4args { + /* CURRENT_FH: directory */ + nfs_cookie4 cookie; + verifier4 cookieverf; + count4 dircount; + count4 maxcount; + bitmap4 attr_request; +}; + +struct entry4 { + nfs_cookie4 cookie; + component4 name; + fattr4 attrs; + entry4 *nextentry; +}; + +struct dirlist4 { + entry4 *entries; + bool eof; +}; + +struct READDIR4resok { + verifier4 cookieverf; + dirlist4 reply; +}; + + +union READDIR4res switch (nfsstat4 status) { + case NFS4_OK: + READDIR4resok resok4; + default: + void; +}; + + +struct READLINK4resok { + linktext4 link; +}; + +union READLINK4res switch (nfsstat4 status) { + case NFS4_OK: + READLINK4resok resok4; + default: + void; +}; + +struct REMOVE4args { + /* CURRENT_FH: directory */ + component4 target; +}; + +struct REMOVE4resok { + change_info4 cinfo; +}; + +union REMOVE4res switch (nfsstat4 status) { + case NFS4_OK: + REMOVE4resok resok4; + default: + void; +}; + +struct RENAME4args { + /* SAVED_FH: source directory */ + component4 oldname; + /* CURRENT_FH: target directory */ + component4 newname; +}; + +struct RENAME4resok { + change_info4 source_cinfo; + change_info4 target_cinfo; +}; + +union RENAME4res switch (nfsstat4 status) { + case NFS4_OK: + RENAME4resok resok4; + default: + void; +}; + +/* Obsolete in NFSv4.1 */ +struct RENEW4args { + clientid4 clientid; +}; + +struct RENEW4res { + nfsstat4 status; +}; + +struct RESTOREFH4res { + /* + * If status is NFS4_OK, + * New CURRENT_FH: value of saved fh + */ + nfsstat4 status; +}; + +struct SAVEFH4res { + /* + * If status is NFS4_OK, + * New SAVED_FH: value of current fh + */ + nfsstat4 status; +}; + +struct SECINFO4args { + /* CURRENT_FH: directory */ + component4 name; +}; + +/* + * From RFC 2203 + */ +enum rpc_gss_svc_t { + RPC_GSS_SVC_NONE = 1, + RPC_GSS_SVC_INTEGRITY = 2, + RPC_GSS_SVC_PRIVACY = 3 +}; + +struct rpcsec_gss_info { + sec_oid4 oid; + qop4 qop; + rpc_gss_svc_t service; +}; + +/* RPCSEC_GSS has a value of "6". See RFC 2203. */ +union secinfo4 switch (uint32_t flavor) { + case RPCSEC_GSS: + rpcsec_gss_info flavor_info; + default: + void; +}; + +typedef secinfo4 SECINFO4resok<>; + +union SECINFO4res switch (nfsstat4 status) { + case NFS4_OK: + /* CURRENTFH: consumed */ + SECINFO4resok resok4; + default: + void; +}; + +struct SETATTR4args { + /* CURRENT_FH: target object */ + stateid4 stateid; + fattr4 obj_attributes; +}; + +struct SETATTR4res { + nfsstat4 status; + bitmap4 attrsset; +}; + +/* Obsolete in NFSv4.1 */ +struct SETCLIENTID4args { + nfs_client_id4 client; + cb_client4 callback; + uint32_t callback_ident; +}; + +struct SETCLIENTID4resok { + clientid4 clientid; + verifier4 setclientid_confirm; +}; + +union SETCLIENTID4res switch (nfsstat4 status) { + case NFS4_OK: + SETCLIENTID4resok resok4; + case NFS4ERR_CLID_INUSE: + clientaddr4 client_using; + default: + void; +}; + +/* Obsolete in NFSv4.1 */ +struct SETCLIENTID_CONFIRM4args { + clientid4 clientid; + verifier4 setclientid_confirm; +}; + +struct SETCLIENTID_CONFIRM4res { + nfsstat4 status; +}; + +struct VERIFY4args { + /* CURRENT_FH: object */ + fattr4 obj_attributes; +}; + +struct VERIFY4res { + nfsstat4 status; +}; + +struct WRITE4args { + /* CURRENT_FH: file */ + stateid4 stateid; + offset4 offset; + stable_how4 stable; + opaque data<>; +}; + +struct WRITE4resok { + count4 count; + stable_how4 committed; + verifier4 writeverf; +}; + +union WRITE4res switch (nfsstat4 status) { + case NFS4_OK: + WRITE4resok resok4; + default: + void; +}; + +/* Obsolete in NFSv4.1 */ +struct RELEASE_LOCKOWNER4args { + lock_owner4 lock_owner; +}; + +struct RELEASE_LOCKOWNER4res { + nfsstat4 status; +}; + +struct ILLEGAL4res { + nfsstat4 status; +}; + +typedef opaque gsshandle4_t<>; + +struct gss_cb_handles4 { + rpc_gss_svc_t gcbp_service; /* RFC 2203 */ + gsshandle4_t gcbp_handle_from_server; + gsshandle4_t gcbp_handle_from_client; +}; + +union callback_sec_parms4 switch (uint32_t cb_secflavor) { + case AUTH_NONE: + void; + case AUTH_SYS: + authsys_parms cbsp_sys_cred; /* RFC 5531 */ + case RPCSEC_GSS: + gss_cb_handles4 cbsp_gss_handles; +}; + +struct BACKCHANNEL_CTL4args { + uint32_t bca_cb_program; + callback_sec_parms4 bca_sec_parms<>; +}; + +struct BACKCHANNEL_CTL4res { + nfsstat4 bcr_status; +}; + +enum channel_dir_from_client4 { + CDFC4_FORE = 0x1, + CDFC4_BACK = 0x2, + CDFC4_FORE_OR_BOTH = 0x3, + CDFC4_BACK_OR_BOTH = 0x7 +}; + +struct BIND_CONN_TO_SESSION4args { + sessionid4 bctsa_sessid; + + channel_dir_from_client4 + bctsa_dir; + + bool bctsa_use_conn_in_rdma_mode; +}; + +enum channel_dir_from_server4 { + CDFS4_FORE = 0x1, + CDFS4_BACK = 0x2, + CDFS4_BOTH = 0x3 +}; + +struct BIND_CONN_TO_SESSION4resok { + sessionid4 bctsr_sessid; + + channel_dir_from_server4 + bctsr_dir; + + bool bctsr_use_conn_in_rdma_mode; +}; + +union BIND_CONN_TO_SESSION4res + switch (nfsstat4 bctsr_status) { + case NFS4_OK: + BIND_CONN_TO_SESSION4resok bctsr_resok4; + default: + void; +}; + +const EXCHGID4_FLAG_SUPP_MOVED_REFER = 0x00000001; +const EXCHGID4_FLAG_SUPP_MOVED_MIGR = 0x00000002; +const EXCHGID4_FLAG_SUPP_FENCE_OPS = 0x00000004; + +const EXCHGID4_FLAG_BIND_PRINC_STATEID = 0x00000100; + +const EXCHGID4_FLAG_USE_NON_PNFS = 0x00010000; +const EXCHGID4_FLAG_USE_PNFS_MDS = 0x00020000; +const EXCHGID4_FLAG_USE_PNFS_DS = 0x00040000; + +const EXCHGID4_FLAG_MASK_PNFS = 0x00070000; + +const EXCHGID4_FLAG_UPD_CONFIRMED_REC_A = 0x40000000; +const EXCHGID4_FLAG_CONFIRMED_R = 0x80000000; + +struct state_protect_ops4 { + bitmap4 spo_must_enforce; + bitmap4 spo_must_allow; +}; + +struct ssv_sp_parms4 { + state_protect_ops4 ssp_ops; + sec_oid4 ssp_hash_algs<>; + sec_oid4 ssp_encr_algs<>; + uint32_t ssp_window; + uint32_t ssp_num_gss_handles; +}; + +enum state_protect_how4 { + SP4_NONE = 0, + SP4_MACH_CRED = 1, + SP4_SSV = 2 +}; + +union state_protect4_a switch (state_protect_how4 spa_how) { + case SP4_NONE: + void; + case SP4_MACH_CRED: + state_protect_ops4 spa_mach_ops; + case SP4_SSV: + ssv_sp_parms4 spa_ssv_parms; +}; + +struct EXCHANGE_ID4args { + client_owner4 eia_clientowner; + uint32_t eia_flags; + state_protect4_a eia_state_protect; + nfs_impl_id4 eia_client_impl_id<1>; +}; + +struct ssv_prot_info4 { + state_protect_ops4 spi_ops; + uint32_t spi_hash_alg; + uint32_t spi_encr_alg; + uint32_t spi_ssv_len; + uint32_t spi_window; + gsshandle4_t spi_handles<>; +}; + +union state_protect4_r switch (state_protect_how4 spr_how) { + case SP4_NONE: + void; + case SP4_MACH_CRED: + state_protect_ops4 spr_mach_ops; + case SP4_SSV: + ssv_prot_info4 spr_ssv_info; +}; + +struct EXCHANGE_ID4resok { + clientid4 eir_clientid; + sequenceid4 eir_sequenceid; + uint32_t eir_flags; + state_protect4_r eir_state_protect; + server_owner4 eir_server_owner; + opaque eir_server_scope; + nfs_impl_id4 eir_server_impl_id<1>; +}; + +union EXCHANGE_ID4res switch (nfsstat4 eir_status) { + case NFS4_OK: + EXCHANGE_ID4resok eir_resok4; + + default: + void; +}; + +struct channel_attrs4 { + count4 ca_headerpadsize; + count4 ca_maxrequestsize; + count4 ca_maxresponsesize; + count4 ca_maxresponsesize_cached; + count4 ca_maxoperations; + count4 ca_maxrequests; + uint32_t ca_rdma_ird<1>; +}; + +const CREATE_SESSION4_FLAG_PERSIST = 0x00000001; +const CREATE_SESSION4_FLAG_CONN_BACK_CHAN = 0x00000002; +const CREATE_SESSION4_FLAG_CONN_RDMA = 0x00000004; + +struct CREATE_SESSION4args { + clientid4 csa_clientid; + sequenceid4 csa_sequence; + + uint32_t csa_flags; + + channel_attrs4 csa_fore_chan_attrs; + channel_attrs4 csa_back_chan_attrs; + + uint32_t csa_cb_program; + callback_sec_parms4 csa_sec_parms<>; +}; + +struct CREATE_SESSION4resok { + sessionid4 csr_sessionid; + sequenceid4 csr_sequence; + + uint32_t csr_flags; + + channel_attrs4 csr_fore_chan_attrs; + channel_attrs4 csr_back_chan_attrs; +}; + +union CREATE_SESSION4res switch (nfsstat4 csr_status) { + case NFS4_OK: + CREATE_SESSION4resok csr_resok4; + default: + void; +}; + +struct DESTROY_SESSION4args { + sessionid4 dsa_sessionid; +}; + +struct DESTROY_SESSION4res { + nfsstat4 dsr_status; +}; + +struct FREE_STATEID4args { + stateid4 fsa_stateid; +}; + +struct FREE_STATEID4res { + nfsstat4 fsr_status; +}; + + +typedef nfstime4 attr_notice4; + +struct GET_DIR_DELEGATION4args { + /* CURRENT_FH: delegated directory */ + bool gdda_signal_deleg_avail; + bitmap4 gdda_notification_types; + attr_notice4 gdda_child_attr_delay; + attr_notice4 gdda_dir_attr_delay; + bitmap4 gdda_child_attributes; + bitmap4 gdda_dir_attributes; +}; +struct GET_DIR_DELEGATION4resok { + verifier4 gddr_cookieverf; + /* Stateid for get_dir_delegation */ + stateid4 gddr_stateid; + /* Which notifications can the server support? */ + bitmap4 gddr_notification; + bitmap4 gddr_child_attributes; + bitmap4 gddr_dir_attributes; +}; + +enum gddrnf4_status { + GDD4_OK = 0, + GDD4_UNAVAIL = 1 +}; + +union GET_DIR_DELEGATION4res_non_fatal + switch (gddrnf4_status gddrnf_status) { + case GDD4_OK: + GET_DIR_DELEGATION4resok gddrnf_resok4; + case GDD4_UNAVAIL: + bool gddrnf_will_signal_deleg_avail; +}; + +union GET_DIR_DELEGATION4res + switch (nfsstat4 gddr_status) { + case NFS4_OK: + GET_DIR_DELEGATION4res_non_fatal gddr_res_non_fatal4; + default: + void; +}; + +struct GETDEVICEINFO4args { + deviceid4 gdia_device_id; + layouttype4 gdia_layout_type; + count4 gdia_maxcount; + bitmap4 gdia_notify_types; +}; + +struct GETDEVICEINFO4resok { + device_addr4 gdir_device_addr; + bitmap4 gdir_notification; +}; + +union GETDEVICEINFO4res switch (nfsstat4 gdir_status) { + case NFS4_OK: + GETDEVICEINFO4resok gdir_resok4; + case NFS4ERR_TOOSMALL: + count4 gdir_mincount; + default: + void; +}; + +struct GETDEVICELIST4args { + /* CURRENT_FH: object belonging to the file system */ + layouttype4 gdla_layout_type; + + /* Number of device IDs to return */ + count4 gdla_maxdevices; + + nfs_cookie4 gdla_cookie; + verifier4 gdla_cookieverf; +}; + +struct GETDEVICELIST4resok { + nfs_cookie4 gdlr_cookie; + verifier4 gdlr_cookieverf; + deviceid4 gdlr_deviceid_list<>; + bool gdlr_eof; +}; + +union GETDEVICELIST4res switch (nfsstat4 gdlr_status) { + case NFS4_OK: + GETDEVICELIST4resok gdlr_resok4; + default: + void; +}; + +union newtime4 switch (bool nt_timechanged) { + case TRUE: + nfstime4 nt_time; + case FALSE: + void; +}; + +union newoffset4 switch (bool no_newoffset) { + case TRUE: + offset4 no_offset; + case FALSE: + void; +}; + +struct LAYOUTCOMMIT4args { + /* CURRENT_FH: file */ + offset4 loca_offset; + length4 loca_length; + bool loca_reclaim; + stateid4 loca_stateid; + newoffset4 loca_last_write_offset; + newtime4 loca_time_modify; + layoutupdate4 loca_layoutupdate; +}; +union newsize4 switch (bool ns_sizechanged) { + case TRUE: + length4 ns_size; + case FALSE: + void; +}; + +struct LAYOUTCOMMIT4resok { + newsize4 locr_newsize; +}; + +union LAYOUTCOMMIT4res switch (nfsstat4 locr_status) { + case NFS4_OK: + LAYOUTCOMMIT4resok locr_resok4; + default: + void; +}; + +struct LAYOUTGET4args { + /* CURRENT_FH: file */ + bool loga_signal_layout_avail; + layouttype4 loga_layout_type; + layoutiomode4 loga_iomode; + offset4 loga_offset; + length4 loga_length; + length4 loga_minlength; + stateid4 loga_stateid; + count4 loga_maxcount; +}; +struct LAYOUTGET4resok { + bool logr_return_on_close; + stateid4 logr_stateid; + layout4 logr_layout<>; +}; + +union LAYOUTGET4res switch (nfsstat4 logr_status) { + case NFS4_OK: + LAYOUTGET4resok logr_resok4; + case NFS4ERR_LAYOUTTRYLATER: + bool logr_will_signal_layout_avail; + default: + void; +}; + + +struct LAYOUTRETURN4args { + /* CURRENT_FH: file */ + bool lora_reclaim; + layouttype4 lora_layout_type; + layoutiomode4 lora_iomode; + layoutreturn4 lora_layoutreturn; +}; + + +union layoutreturn_stateid switch (bool lrs_present) { + case TRUE: + stateid4 lrs_stateid; + case FALSE: + void; +}; + +union LAYOUTRETURN4res switch (nfsstat4 lorr_status) { + case NFS4_OK: + layoutreturn_stateid lorr_stateid; + default: + void; +}; + +enum secinfo_style4 { + SECINFO_STYLE4_CURRENT_FH = 0, + SECINFO_STYLE4_PARENT = 1 +}; + +/* CURRENT_FH: object or child directory */ +typedef secinfo_style4 SECINFO_NO_NAME4args; + +/* CURRENTFH: consumed if status is NFS4_OK */ +typedef SECINFO4res SECINFO_NO_NAME4res; + +struct SEQUENCE4args { + sessionid4 sa_sessionid; + sequenceid4 sa_sequenceid; + slotid4 sa_slotid; + slotid4 sa_highest_slotid; + bool sa_cachethis; +}; + +const SEQ4_STATUS_CB_PATH_DOWN = 0x00000001; +const SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING = 0x00000002; +const SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED = 0x00000004; +const SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED = 0x00000008; +const SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED = 0x00000010; +const SEQ4_STATUS_ADMIN_STATE_REVOKED = 0x00000020; +const SEQ4_STATUS_RECALLABLE_STATE_REVOKED = 0x00000040; +const SEQ4_STATUS_LEASE_MOVED = 0x00000080; +const SEQ4_STATUS_RESTART_RECLAIM_NEEDED = 0x00000100; +const SEQ4_STATUS_CB_PATH_DOWN_SESSION = 0x00000200; +const SEQ4_STATUS_BACKCHANNEL_FAULT = 0x00000400; +const SEQ4_STATUS_DEVID_CHANGED = 0x00000800; +const SEQ4_STATUS_DEVID_DELETED = 0x00001000; + +struct SEQUENCE4resok { + sessionid4 sr_sessionid; + sequenceid4 sr_sequenceid; + slotid4 sr_slotid; + slotid4 sr_highest_slotid; + slotid4 sr_target_highest_slotid; + uint32_t sr_status_flags; +}; + +union SEQUENCE4res switch (nfsstat4 sr_status) { + case NFS4_OK: + SEQUENCE4resok sr_resok4; + default: + void; +}; + +struct ssa_digest_input4 { + SEQUENCE4args sdi_seqargs; +}; + +struct SET_SSV4args { + opaque ssa_ssv<>; + opaque ssa_digest<>; +}; + +struct ssr_digest_input4 { + SEQUENCE4res sdi_seqres; +}; + +struct SET_SSV4resok { + opaque ssr_digest<>; +}; + +union SET_SSV4res switch (nfsstat4 ssr_status) { + case NFS4_OK: + SET_SSV4resok ssr_resok4; + default: + void; +}; + +struct TEST_STATEID4args { + stateid4 ts_stateids<>; +}; + +struct TEST_STATEID4resok { + nfsstat4 tsr_status_codes<>; +}; + +union TEST_STATEID4res switch (nfsstat4 tsr_status) { + case NFS4_OK: + TEST_STATEID4resok tsr_resok4; + default: + void; +}; + +union deleg_claim4 switch (open_claim_type4 dc_claim) { +/* + * No special rights to object. Ordinary delegation + * request of the specified object. Object identified + * by filehandle. + */ + case CLAIM_FH: /* New to NFSv4.1 */ + /* CURRENT_FH: object being delegated */ + void; + +/* + * Right to file based on a delegation granted + * to a previous boot instance of the client. + * File is specified by filehandle. + */ + case CLAIM_DELEG_PREV_FH: /* New to NFSv4.1 */ + /* CURRENT_FH: object being delegated */ + void; + +/* + * Right to the file established by an open previous + * to server reboot. File identified by filehandle. + * Used during server reclaim grace period. + */ + case CLAIM_PREVIOUS: + /* CURRENT_FH: object being reclaimed */ + open_delegation_type4 dc_delegate_type; +}; + +struct WANT_DELEGATION4args { + uint32_t wda_want; + deleg_claim4 wda_claim; +}; + +union WANT_DELEGATION4res switch (nfsstat4 wdr_status) { + case NFS4_OK: + open_delegation4 wdr_resok4; + default: + void; +}; + +struct DESTROY_CLIENTID4args { + clientid4 dca_clientid; +}; + +struct DESTROY_CLIENTID4res { + nfsstat4 dcr_status; +}; + +struct RECLAIM_COMPLETE4args { + /* + * If rca_one_fs TRUE, + * + * CURRENT_FH: object in + * file system for which the + * reclaim is complete. + */ + bool rca_one_fs; +}; + +struct RECLAIM_COMPLETE4res { + nfsstat4 rcr_status; +}; + +struct COPY4args { + /* SAVED_FH: source file */ + /* CURRENT_FH: destination file */ + stateid4 ca_src_stateid; + stateid4 ca_dst_stateid; + offset4 ca_src_offset; + offset4 ca_dst_offset; + length4 ca_count; + bool ca_consecutive; + bool ca_synchronous; + netloc4 ca_source_server<>; +}; + + +struct copy_requirements4 { + bool cr_consecutive; + bool cr_synchronous; +}; + +struct COPY4resok { + write_response4 cr_response; + copy_requirements4 cr_requirements; +}; + +union COPY4res switch (nfsstat4 cr_status) { + case NFS4_OK: + COPY4resok cr_resok4; + case NFS4ERR_OFFLOAD_NO_REQS: + copy_requirements4 cr_requirements; + default: + void; +}; + +struct COPY_NOTIFY4args { + /* CURRENT_FH: source file */ + stateid4 cna_src_stateid; + netloc4 cna_destination_server; +}; + +struct COPY_NOTIFY4resok { + nfstime4 cnr_lease_time; + stateid4 cnr_stateid; + netloc4 cnr_source_server<>; +}; + +union COPY_NOTIFY4res switch (nfsstat4 cnr_status) { + case NFS4_OK: + COPY_NOTIFY4resok resok4; + default: + void; +}; + +struct OFFLOAD_CANCEL4args { + /* CURRENT_FH: file to cancel */ + stateid4 oca_stateid; +}; + +struct OFFLOAD_CANCEL4res { + nfsstat4 ocr_status; +}; + + +struct OFFLOAD_STATUS4args { + /* CURRENT_FH: destination file */ + stateid4 osa_stateid; +}; + +struct OFFLOAD_STATUS4resok { + length4 osr_count; + nfsstat4 osr_complete<1>; +}; + +union OFFLOAD_STATUS4res switch (nfsstat4 osr_status) { + case NFS4_OK: + OFFLOAD_STATUS4resok osr_resok4; + default: + void; +}; + +struct ALLOCATE4args { + /* CURRENT_FH: file */ + stateid4 aa_stateid; + offset4 aa_offset; + length4 aa_length; +}; +struct ALLOCATE4res { + nfsstat4 ar_status; +}; + +struct DEALLOCATE4args { + /* CURRENT_FH: file */ + stateid4 da_stateid; + offset4 da_offset; + length4 da_length; +}; + + +struct DEALLOCATE4res { + nfsstat4 dr_status; +}; +enum IO_ADVISE_type4 { + IO_ADVISE4_NORMAL = 0, + IO_ADVISE4_SEQUENTIAL = 1, + IO_ADVISE4_SEQUENTIAL_BACKWARDS = 2, + IO_ADVISE4_RANDOM = 3, + IO_ADVISE4_WILLNEED = 4, + IO_ADVISE4_WILLNEED_OPPORTUNISTIC = 5, + IO_ADVISE4_DONTNEED = 6, + IO_ADVISE4_NOREUSE = 7, + IO_ADVISE4_READ = 8, + IO_ADVISE4_WRITE = 9, + IO_ADVISE4_INIT_PROXIMITY = 10 +}; + +struct IO_ADVISE4args { + /* CURRENT_FH: file */ + stateid4 iaa_stateid; + offset4 iaa_offset; + length4 iaa_count; + bitmap4 iaa_hints; +}; + +struct IO_ADVISE4resok { + bitmap4 ior_hints; +}; + +union IO_ADVISE4res switch (nfsstat4 ior_status) { + case NFS4_OK: + IO_ADVISE4resok resok4; + default: + void; +}; + + +struct device_error4 { + deviceid4 de_deviceid; + nfsstat4 de_status; + nfs_opnum4 de_opnum; +}; + + +struct LAYOUTERROR4args { + /* CURRENT_FH: file */ + offset4 lea_offset; + length4 lea_length; + stateid4 lea_stateid; + device_error4 lea_errors<>; +}; + +struct LAYOUTERROR4res { + nfsstat4 ler_status; +}; + +struct io_info4 { + uint64_t ii_count; + uint64_t ii_bytes; +}; + +struct LAYOUTSTATS4args { + /* CURRENT_FH: file */ + offset4 lsa_offset; + length4 lsa_length; + stateid4 lsa_stateid; + io_info4 lsa_read; + io_info4 lsa_write; + deviceid4 lsa_deviceid; + layoutupdate4 lsa_layoutupdate; +}; + +struct LAYOUTSTATS4res { + nfsstat4 lsr_status; +}; + +struct READ_PLUS4args { + /* CURRENT_FH: file */ + stateid4 rpa_stateid; + offset4 rpa_offset; + count4 rpa_count; +}; +union read_plus_content switch (data_content4 rpc_content) { + case NFS4_CONTENT_DATA: + data4 rpc_data; + case NFS4_CONTENT_HOLE: + data_info4 rpc_hole; + default: + void; +}; + +/* + * Allow a return of an array of contents. + */ +struct read_plus_res4 { + bool rpr_eof; + read_plus_content rpr_contents<>; +}; + +union READ_PLUS4res switch (nfsstat4 rp_status) { + case NFS4_OK: + read_plus_res4 rp_resok4; + default: + void; +}; + +struct SEEK4args { + /* CURRENT_FH: file */ + stateid4 sa_stateid; + offset4 sa_offset; + data_content4 sa_what; +}; +struct seek_res4 { + bool sr_eof; + offset4 sr_offset; +}; +union SEEK4res switch (nfsstat4 sa_status) { + case NFS4_OK: + seek_res4 resok4; + default: + void; +}; + +struct WRITE_SAME4args { + /* CURRENT_FH: file */ + stateid4 wsa_stateid; + stable_how4 wsa_stable; + app_data_block4 wsa_adb; +}; + + +union WRITE_SAME4res switch (nfsstat4 wsr_status) { + case NFS4_OK: + write_response4 resok4; + default: + void; +}; + + +/* + * Operation arrays (the rest) + */ + +union nfs_argop4 switch (nfs_opnum4 argop) { + case OP_ACCESS: ACCESS4args opaccess; + case OP_CLOSE: CLOSE4args opclose; + case OP_COMMIT: COMMIT4args opcommit; + case OP_CREATE: CREATE4args opcreate; + case OP_DELEGPURGE: DELEGPURGE4args opdelegpurge; + case OP_DELEGRETURN: DELEGRETURN4args opdelegreturn; + case OP_GETATTR: GETATTR4args opgetattr; + case OP_GETFH: void; + case OP_LINK: LINK4args oplink; + case OP_LOCK: LOCK4args oplock; + case OP_LOCKT: LOCKT4args oplockt; + case OP_LOCKU: LOCKU4args oplocku; + case OP_LOOKUP: LOOKUP4args oplookup; + case OP_LOOKUPP: void; + case OP_NVERIFY: NVERIFY4args opnverify; + case OP_OPEN: OPEN4args opopen; + case OP_OPENATTR: OPENATTR4args opopenattr; + + /* Not for NFSv4.1 */ + case OP_OPEN_CONFIRM: OPEN_CONFIRM4args opopen_confirm; + + case OP_OPEN_DOWNGRADE: OPEN_DOWNGRADE4args opopen_downgrade; + + case OP_PUTFH: PUTFH4args opputfh; + case OP_PUTPUBFH: void; + case OP_PUTROOTFH: void; + case OP_READ: READ4args opread; + case OP_READDIR: READDIR4args opreaddir; + case OP_READLINK: void; + case OP_REMOVE: REMOVE4args opremove; + case OP_RENAME: RENAME4args oprename; + + /* Not for NFSv4.1 */ + case OP_RENEW: RENEW4args oprenew; + + case OP_RESTOREFH: void; + case OP_SAVEFH: void; + case OP_SECINFO: SECINFO4args opsecinfo; + case OP_SETATTR: SETATTR4args opsetattr; + + /* Not for NFSv4.1 */ + case OP_SETCLIENTID: SETCLIENTID4args opsetclientid; + + /* Not for NFSv4.1 */ + case OP_SETCLIENTID_CONFIRM: + SETCLIENTID_CONFIRM4args + opsetclientid_confirm; + + case OP_VERIFY: VERIFY4args opverify; + case OP_WRITE: WRITE4args opwrite; + + /* Not for NFSv4.1 */ + case OP_RELEASE_LOCKOWNER: + RELEASE_LOCKOWNER4args + oprelease_lockowner; + + /* Operations new to NFSv4.1 */ + case OP_BACKCHANNEL_CTL: + BACKCHANNEL_CTL4args opbackchannel_ctl; + + case OP_BIND_CONN_TO_SESSION: + BIND_CONN_TO_SESSION4args + opbind_conn_to_session; + + case OP_EXCHANGE_ID: EXCHANGE_ID4args opexchange_id; + + case OP_CREATE_SESSION: CREATE_SESSION4args opcreate_session; + + case OP_DESTROY_SESSION: + DESTROY_SESSION4args opdestroy_session; + + case OP_FREE_STATEID: FREE_STATEID4args opfree_stateid; + + case OP_GET_DIR_DELEGATION: + GET_DIR_DELEGATION4args + opget_dir_delegation; + + case OP_GETDEVICEINFO: GETDEVICEINFO4args opgetdeviceinfo; + case OP_GETDEVICELIST: GETDEVICELIST4args opgetdevicelist; + case OP_LAYOUTCOMMIT: LAYOUTCOMMIT4args oplayoutcommit; + case OP_LAYOUTGET: LAYOUTGET4args oplayoutget; + case OP_LAYOUTRETURN: LAYOUTRETURN4args oplayoutreturn; + + case OP_SECINFO_NO_NAME: + SECINFO_NO_NAME4args opsecinfo_no_name; + + case OP_SEQUENCE: SEQUENCE4args opsequence; + case OP_SET_SSV: SET_SSV4args opset_ssv; + case OP_TEST_STATEID: TEST_STATEID4args optest_stateid; + + case OP_WANT_DELEGATION: + WANT_DELEGATION4args opwant_delegation; + + case OP_DESTROY_CLIENTID: + DESTROY_CLIENTID4args + opdestroy_clientid; + + case OP_RECLAIM_COMPLETE: + RECLAIM_COMPLETE4args + opreclaim_complete; + + /* Operations new to NFSv4.2 */ + case OP_ALLOCATE: ALLOCATE4args opallocate; + case OP_COPY: COPY4args opcopy; + case OP_COPY_NOTIFY: COPY_NOTIFY4args opoffload_notify; + case OP_DEALLOCATE: DEALLOCATE4args opdeallocate; + case OP_IO_ADVISE: IO_ADVISE4args opio_advise; + case OP_LAYOUTERROR: LAYOUTERROR4args oplayouterror; + case OP_LAYOUTSTATS: LAYOUTSTATS4args oplayoutstats; + case OP_OFFLOAD_CANCEL: OFFLOAD_CANCEL4args opoffload_cancel; + case OP_OFFLOAD_STATUS: OFFLOAD_STATUS4args opoffload_status; + case OP_READ_PLUS: READ_PLUS4args opread_plus; + case OP_SEEK: SEEK4args opseek; + case OP_WRITE_SAME: WRITE_SAME4args opwrite_same; + case OP_CLONE: CLONE4args opclone; + + /* Operations not new to NFSv4.1 */ + case OP_ILLEGAL: void; +}; + +union nfs_resop4 switch (nfs_opnum4 resop) { + case OP_ACCESS: ACCESS4res opaccess; + case OP_CLOSE: CLOSE4res opclose; + case OP_COMMIT: COMMIT4res opcommit; + case OP_CREATE: CREATE4res opcreate; + case OP_DELEGPURGE: DELEGPURGE4res opdelegpurge; + case OP_DELEGRETURN: DELEGRETURN4res opdelegreturn; + case OP_GETATTR: GETATTR4res opgetattr; + case OP_GETFH: GETFH4res opgetfh; + case OP_LINK: LINK4res oplink; + case OP_LOCK: LOCK4res oplock; + case OP_LOCKT: LOCKT4res oplockt; + case OP_LOCKU: LOCKU4res oplocku; + case OP_LOOKUP: LOOKUP4res oplookup; + case OP_LOOKUPP: LOOKUPP4res oplookupp; + case OP_NVERIFY: NVERIFY4res opnverify; + case OP_OPEN: OPEN4res opopen; + case OP_OPENATTR: OPENATTR4res opopenattr; + /* Not for NFSv4.1 */ + case OP_OPEN_CONFIRM: OPEN_CONFIRM4res opopen_confirm; + + case OP_OPEN_DOWNGRADE: OPEN_DOWNGRADE4res opopen_downgrade; + + case OP_PUTFH: PUTFH4res opputfh; + case OP_PUTPUBFH: PUTPUBFH4res opputpubfh; + case OP_PUTROOTFH: PUTROOTFH4res opputrootfh; + case OP_READ: READ4res opread; + case OP_READDIR: READDIR4res opreaddir; + case OP_READLINK: READLINK4res opreadlink; + case OP_REMOVE: REMOVE4res opremove; + case OP_RENAME: RENAME4res oprename; + /* Not for NFSv4.1 */ + case OP_RENEW: RENEW4res oprenew; + case OP_RESTOREFH: RESTOREFH4res oprestorefh; + case OP_SAVEFH: SAVEFH4res opsavefh; + case OP_SECINFO: SECINFO4res opsecinfo; + case OP_SETATTR: SETATTR4res opsetattr; + /* Not for NFSv4.1 */ + case OP_SETCLIENTID: SETCLIENTID4res opsetclientid; + + /* Not for NFSv4.1 */ + case OP_SETCLIENTID_CONFIRM: + SETCLIENTID_CONFIRM4res + opsetclientid_confirm; + case OP_VERIFY: VERIFY4res opverify; + case OP_WRITE: WRITE4res opwrite; + + /* Not for NFSv4.1 */ + case OP_RELEASE_LOCKOWNER: + RELEASE_LOCKOWNER4res + oprelease_lockowner; + + /* Operations new to NFSv4.1 */ + case OP_BACKCHANNEL_CTL: + BACKCHANNEL_CTL4res opbackchannel_ctl; + + case OP_BIND_CONN_TO_SESSION: + BIND_CONN_TO_SESSION4res + opbind_conn_to_session; + + case OP_EXCHANGE_ID: EXCHANGE_ID4res opexchange_id; + + case OP_CREATE_SESSION: CREATE_SESSION4res opcreate_session; + + case OP_DESTROY_SESSION: + DESTROY_SESSION4res opdestroy_session; + + case OP_FREE_STATEID: FREE_STATEID4res opfree_stateid; + + case OP_GET_DIR_DELEGATION: + GET_DIR_DELEGATION4res + opget_dir_delegation; + + case OP_GETDEVICEINFO: GETDEVICEINFO4res opgetdeviceinfo; + case OP_GETDEVICELIST: GETDEVICELIST4res opgetdevicelist; + case OP_LAYOUTCOMMIT: LAYOUTCOMMIT4res oplayoutcommit; + case OP_LAYOUTGET: LAYOUTGET4res oplayoutget; + case OP_LAYOUTRETURN: LAYOUTRETURN4res oplayoutreturn; + + case OP_SECINFO_NO_NAME: + SECINFO_NO_NAME4res opsecinfo_no_name; + + case OP_SEQUENCE: SEQUENCE4res opsequence; + case OP_SET_SSV: SET_SSV4res opset_ssv; + case OP_TEST_STATEID: TEST_STATEID4res optest_stateid; + + case OP_WANT_DELEGATION: + WANT_DELEGATION4res opwant_delegation; + + case OP_DESTROY_CLIENTID: + DESTROY_CLIENTID4res + opdestroy_clientid; + + case OP_RECLAIM_COMPLETE: + RECLAIM_COMPLETE4res + opreclaim_complete; + + /* Operations new to NFSv4.2 */ + case OP_ALLOCATE: ALLOCATE4res opallocate; + case OP_COPY: COPY4res opcopy; + case OP_COPY_NOTIFY: COPY_NOTIFY4res opcopy_notify; + case OP_DEALLOCATE: DEALLOCATE4res opdeallocate; + case OP_IO_ADVISE: IO_ADVISE4res opio_advise; + case OP_LAYOUTERROR: LAYOUTERROR4res oplayouterror; + case OP_LAYOUTSTATS: LAYOUTSTATS4res oplayoutstats; + case OP_OFFLOAD_CANCEL: OFFLOAD_CANCEL4res opoffload_cancel; + case OP_OFFLOAD_STATUS: OFFLOAD_STATUS4res opoffload_status; + case OP_READ_PLUS: READ_PLUS4res opread_plus; + case OP_SEEK: SEEK4res opseek; + case OP_WRITE_SAME: WRITE_SAME4res opwrite_same; + case OP_CLONE: CLONE4res opclone; + + /* Operations not new to NFSv4.1 */ + case OP_ILLEGAL: ILLEGAL4res opillegal; +}; + +struct COMPOUND4args { + utf8str_cs tag; + uint32_t minorversion; + nfs_argop4 argarray<>; +}; + +struct COMPOUND4res { + nfsstat4 status; + utf8str_cs tag; + nfs_resop4 resarray<>; +}; + + +/* + * Remote file service routines + */ +program NFS4_PROGRAM { + version NFS_V4 { + void + NFSPROC4_NULL(void) = 0; + + COMPOUND4res + NFSPROC4_COMPOUND(COMPOUND4args) = 1; + + } = 4; +} = 100003; + +/* + * NFS4 callback procedure definitions and program + */ +struct CB_GETATTR4args { + nfs_fh4 fh; + bitmap4 attr_request; +}; + +struct CB_GETATTR4resok { + fattr4 obj_attributes; +}; + +union CB_GETATTR4res switch (nfsstat4 status) { + case NFS4_OK: + CB_GETATTR4resok resok4; + default: + void; +}; + +struct CB_RECALL4args { + stateid4 stateid; + bool truncate; + nfs_fh4 fh; +}; + +struct CB_RECALL4res { + nfsstat4 status; +}; + +/* + * CB_ILLEGAL: Response for illegal operation numbers + */ +struct CB_ILLEGAL4res { + nfsstat4 status; +}; + +/* + * NFSv4.1 callback arguments and results + */ + +enum layoutrecall_type4 { + LAYOUTRECALL4_FILE = LAYOUT4_RET_REC_FILE, + LAYOUTRECALL4_FSID = LAYOUT4_RET_REC_FSID, + LAYOUTRECALL4_ALL = LAYOUT4_RET_REC_ALL +}; + +struct layoutrecall_file4 { + nfs_fh4 lor_fh; + offset4 lor_offset; + length4 lor_length; + stateid4 lor_stateid; +}; + +union layoutrecall4 switch (layoutrecall_type4 lor_recalltype) { + case LAYOUTRECALL4_FILE: + layoutrecall_file4 lor_layout; + case LAYOUTRECALL4_FSID: + fsid4 lor_fsid; + case LAYOUTRECALL4_ALL: + void; +}; + +struct CB_LAYOUTRECALL4args { + layouttype4 clora_type; + layoutiomode4 clora_iomode; + bool clora_changed; + layoutrecall4 clora_recall; +}; +struct CB_LAYOUTRECALL4res { + nfsstat4 clorr_status; +}; + +/* + * Directory notification types + */ +enum notify_type4 { + NOTIFY4_CHANGE_CHILD_ATTRS = 0, + NOTIFY4_CHANGE_DIR_ATTRS = 1, + NOTIFY4_REMOVE_ENTRY = 2, + NOTIFY4_ADD_ENTRY = 3, + NOTIFY4_RENAME_ENTRY = 4, + NOTIFY4_CHANGE_COOKIE_VERIFIER = 5 +}; + +/* Changed entry information */ +struct notify_entry4 { + component4 ne_file; + fattr4 ne_attrs; +}; + +/* Previous entry information */ +struct prev_entry4 { + notify_entry4 pe_prev_entry; + /* What READDIR returned for this entry */ + nfs_cookie4 pe_prev_entry_cookie; +}; + +struct notify_remove4 { + notify_entry4 nrm_old_entry; + nfs_cookie4 nrm_old_entry_cookie; +}; + +struct notify_add4 { + /* + * During a rename, contains + * the object that was deleted. + */ + notify_remove4 nad_old_entry<1>; + notify_entry4 nad_new_entry; + /* What READDIR would have returned for this entry */ + nfs_cookie4 nad_new_entry_cookie<1>; + prev_entry4 nad_prev_entry<1>; + bool nad_last_entry; +}; + +struct notify_attr4 { + notify_entry4 na_changed_entry; +}; + +struct notify_rename4 { + notify_remove4 nrn_old_entry; + notify_add4 nrn_new_entry; +}; + +struct notify_verifier4 { + verifier4 nv_old_cookieverf; + verifier4 nv_new_cookieverf; +}; + +/* + * Objects of type notify_<>4 and + * notify_device_<>4 are encoded in this. + */ +typedef opaque notifylist4<>; + +struct notify4 { + /* Composed from notify_type4 or notify_deviceid_type4 */ + bitmap4 notify_mask; + notifylist4 notify_vals; +}; + +struct CB_NOTIFY4args { + stateid4 cna_stateid; + nfs_fh4 cna_fh; + notify4 cna_changes<>; +}; + +struct CB_NOTIFY4res { + nfsstat4 cnr_status; +}; + +struct CB_PUSH_DELEG4args { + nfs_fh4 cpda_fh; + open_delegation4 cpda_delegation; + +}; + +struct CB_PUSH_DELEG4res { + nfsstat4 cpdr_status; +}; + +const RCA4_TYPE_MASK_RDATA_DLG = 0; +const RCA4_TYPE_MASK_WDATA_DLG = 1; +const RCA4_TYPE_MASK_DIR_DLG = 2; +const RCA4_TYPE_MASK_FILE_LAYOUT = 3; +const RCA4_TYPE_MASK_BLK_LAYOUT = 4; +const RCA4_TYPE_MASK_OBJ_LAYOUT_MIN = 8; +const RCA4_TYPE_MASK_OBJ_LAYOUT_MAX = 9; +const RCA4_TYPE_MASK_OTHER_LAYOUT_MIN = 12; +const RCA4_TYPE_MASK_OTHER_LAYOUT_MAX = 15; + +struct CB_RECALL_ANY4args { + uint32_t craa_objects_to_keep; + bitmap4 craa_type_mask; +}; + +struct CB_RECALL_ANY4res { + nfsstat4 crar_status; +}; + +typedef CB_RECALL_ANY4args CB_RECALLABLE_OBJ_AVAIL4args; + +struct CB_RECALLABLE_OBJ_AVAIL4res { + nfsstat4 croa_status; +}; + +struct CB_RECALL_SLOT4args { + slotid4 rsa_target_highest_slotid; +}; + +struct CB_RECALL_SLOT4res { + nfsstat4 rsr_status; +}; + +struct referring_call4 { + sequenceid4 rc_sequenceid; + slotid4 rc_slotid; +}; + +struct referring_call_list4 { + sessionid4 rcl_sessionid; + referring_call4 rcl_referring_calls<>; +}; + +struct CB_SEQUENCE4args { + sessionid4 csa_sessionid; + sequenceid4 csa_sequenceid; + slotid4 csa_slotid; + slotid4 csa_highest_slotid; + bool csa_cachethis; + referring_call_list4 csa_referring_call_lists<>; +}; + +struct CB_SEQUENCE4resok { + sessionid4 csr_sessionid; + sequenceid4 csr_sequenceid; + slotid4 csr_slotid; + slotid4 csr_highest_slotid; + slotid4 csr_target_highest_slotid; +}; + +union CB_SEQUENCE4res switch (nfsstat4 csr_status) { + case NFS4_OK: + CB_SEQUENCE4resok csr_resok4; + default: + void; +}; + +struct CB_WANTS_CANCELLED4args { + bool cwca_contended_wants_cancelled; + bool cwca_resourced_wants_cancelled; +}; + +struct CB_WANTS_CANCELLED4res { + nfsstat4 cwcr_status; +}; + +struct CB_NOTIFY_LOCK4args { + nfs_fh4 cnla_fh; + lock_owner4 cnla_lock_owner; +}; + +struct CB_NOTIFY_LOCK4res { + nfsstat4 cnlr_status; +}; + +/* + * Device notification types + */ +enum notify_deviceid_type4 { + NOTIFY_DEVICEID4_CHANGE = 1, + NOTIFY_DEVICEID4_DELETE = 2 +}; + +/* For NOTIFY4_DEVICEID4_DELETE */ +struct notify_deviceid_delete4 { + layouttype4 ndd_layouttype; + deviceid4 ndd_deviceid; +}; + +/* For NOTIFY4_DEVICEID4_CHANGE */ +struct notify_deviceid_change4 { + layouttype4 ndc_layouttype; + deviceid4 ndc_deviceid; + bool ndc_immediate; +}; + +struct CB_NOTIFY_DEVICEID4args { + notify4 cnda_changes<>; +}; + +struct CB_NOTIFY_DEVICEID4res { + nfsstat4 cndr_status; +}; + +union offload_info4 switch (nfsstat4 coa_status) { + case NFS4_OK: + write_response4 coa_resok4; + default: + length4 coa_bytes_copied; +}; +struct CB_OFFLOAD4args { + nfs_fh4 coa_fh; + stateid4 coa_stateid; + offload_info4 coa_offload_info; +}; +struct CB_OFFLOAD4res { + nfsstat4 cor_status; +}; +/* + * Various definitions for CB_COMPOUND + */ +% +enum nfs_cb_opnum4 { + OP_CB_GETATTR = 3, + OP_CB_RECALL = 4, +%/* Callback operations new to NFSv4.1 */ + OP_CB_LAYOUTRECALL = 5, + OP_CB_NOTIFY = 6, + OP_CB_PUSH_DELEG = 7, + OP_CB_RECALL_ANY = 8, + OP_CB_RECALLABLE_OBJ_AVAIL = 9, + OP_CB_RECALL_SLOT = 10, + OP_CB_SEQUENCE = 11, + OP_CB_WANTS_CANCELLED = 12, + OP_CB_NOTIFY_LOCK = 13, + OP_CB_NOTIFY_DEVICEID = 14, +%/* Callback operations new to NFSv4.2 */ + OP_CB_OFFLOAD = 15, + + OP_CB_ILLEGAL = 10044 +}; + +union nfs_cb_argop4 switch (nfs_cb_opnum4 argop) { + case OP_CB_GETATTR: + CB_GETATTR4args opcbgetattr; + + /* New NFSv4.1 operations */ + case OP_CB_RECALL: + CB_RECALL4args opcbrecall; + case OP_CB_LAYOUTRECALL: + CB_LAYOUTRECALL4args opcblayoutrecall; + case OP_CB_NOTIFY: + CB_NOTIFY4args opcbnotify; + case OP_CB_PUSH_DELEG: + CB_PUSH_DELEG4args opcbpush_deleg; + case OP_CB_RECALL_ANY: + CB_RECALL_ANY4args opcbrecall_any; + case OP_CB_RECALLABLE_OBJ_AVAIL: + CB_RECALLABLE_OBJ_AVAIL4args opcbrecallable_obj_avail; + case OP_CB_RECALL_SLOT: + CB_RECALL_SLOT4args opcbrecall_slot; + case OP_CB_SEQUENCE: + CB_SEQUENCE4args opcbsequence; + case OP_CB_WANTS_CANCELLED: + CB_WANTS_CANCELLED4args opcbwants_cancelled; + case OP_CB_NOTIFY_LOCK: + CB_NOTIFY_LOCK4args opcbnotify_lock; + case OP_CB_NOTIFY_DEVICEID: + CB_NOTIFY_DEVICEID4args opcbnotify_deviceid; + + /* New NFSv4.2 operations */ + case OP_CB_OFFLOAD: + CB_OFFLOAD4args opcboffload; + + case OP_CB_ILLEGAL: void; +}; + +union nfs_cb_resop4 switch (nfs_cb_opnum4 resop) { + case OP_CB_GETATTR: CB_GETATTR4res opcbgetattr; + case OP_CB_RECALL: CB_RECALL4res opcbrecall; + + /* New NFSv4.1 operations */ + case OP_CB_LAYOUTRECALL: + CB_LAYOUTRECALL4res + opcblayoutrecall; + + case OP_CB_NOTIFY: CB_NOTIFY4res opcbnotify; + + case OP_CB_PUSH_DELEG: CB_PUSH_DELEG4res + opcbpush_deleg; + + case OP_CB_RECALL_ANY: CB_RECALL_ANY4res + opcbrecall_any; + + case OP_CB_RECALLABLE_OBJ_AVAIL: + CB_RECALLABLE_OBJ_AVAIL4res + opcbrecallable_obj_avail; + + case OP_CB_RECALL_SLOT: + CB_RECALL_SLOT4res + opcbrecall_slot; + + case OP_CB_SEQUENCE: CB_SEQUENCE4res opcbsequence; + + case OP_CB_WANTS_CANCELLED: + CB_WANTS_CANCELLED4res + opcbwants_cancelled; + + case OP_CB_NOTIFY_LOCK: + CB_NOTIFY_LOCK4res + opcbnotify_lock; + + case OP_CB_NOTIFY_DEVICEID: + CB_NOTIFY_DEVICEID4res + opcbnotify_deviceid; + + /* New NFSv4.2 operations */ + case OP_CB_OFFLOAD: CB_OFFLOAD4res opcboffload; + + /* Not new operation */ + case OP_CB_ILLEGAL: CB_ILLEGAL4res opcbillegal; +}; + + +struct CB_COMPOUND4args { + utf8str_cs tag; + uint32_t minorversion; + uint32_t callback_ident; + nfs_cb_argop4 argarray<>; +}; + +struct CB_COMPOUND4res { + nfsstat4 status; + utf8str_cs tag; + nfs_cb_resop4 resarray<>; +}; + + + +/* + * Program number is in the transient range, since the client + * will assign the exact transient program number and provide + * that to the server via the CREATE_SESSION or + * BACKCHANNEL_CTL operations. + */ +program NFS4_CALLBACK { + version NFS_CB { + void + CB_NULL(void) = 0; + CB_COMPOUND4res + CB_COMPOUND(CB_COMPOUND4args) = 1; + } = 1; +} = 0x40000000; diff --git a/illumos-x86_64/usr/include/rpcsvc/nfs_acl.h b/illumos-x86_64/usr/include/rpcsvc/nfs_acl.h new file mode 100644 index 00000000..ab2146f1 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nfs_acl.h @@ -0,0 +1,475 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _NFS_ACL_H_RPCGEN +#define _NFS_ACL_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NFS_ACL_MAX_ENTRIES 1024 + +typedef int uid; + +typedef u_short o_mode; + +struct aclent { + int type; + uid id; + o_mode perm; +}; +typedef struct aclent aclent; +#define NA_USER_OBJ 0x1 +#define NA_USER 0x2 +#define NA_GROUP_OBJ 0x4 +#define NA_GROUP 0x8 +#define NA_CLASS_OBJ 0x10 +#define NA_OTHER_OBJ 0x20 +#define NA_ACL_DEFAULT 0x1000 +#define NA_READ 0x4 +#define NA_WRITE 0x2 +#define NA_EXEC 0x1 + +struct secattr { + u_int mask; + int aclcnt; + struct { + u_int aclent_len; + aclent *aclent_val; + } aclent; + int dfaclcnt; + struct { + u_int dfaclent_len; + aclent *dfaclent_val; + } dfaclent; +}; +typedef struct secattr secattr; +#define NA_ACL 0x1 +#define NA_ACLCNT 0x2 +#define NA_DFACL 0x4 +#define NA_DFACLCNT 0x8 + +struct GETACL2args { + fhandle_t fh; + u_int mask; +}; +typedef struct GETACL2args GETACL2args; + +struct GETACL2resok { + struct nfsfattr attr; + secattr acl; +}; +typedef struct GETACL2resok GETACL2resok; + +struct GETACL2res { + nfsstat status; + union { + GETACL2resok resok; + } GETACL2res_u; +}; +typedef struct GETACL2res GETACL2res; + +struct SETACL2args { + fhandle_t fh; + secattr acl; +}; +typedef struct SETACL2args SETACL2args; + +struct SETACL2resok { + struct nfsfattr attr; +}; +typedef struct SETACL2resok SETACL2resok; + +struct SETACL2res { + nfsstat status; + union { + SETACL2resok resok; + } SETACL2res_u; +}; +typedef struct SETACL2res SETACL2res; + +struct GETATTR2args { + fhandle_t fh; +}; +typedef struct GETATTR2args GETATTR2args; + +struct GETATTR2resok { + struct nfsfattr attr; +}; +typedef struct GETATTR2resok GETATTR2resok; + +struct GETATTR2res { + nfsstat status; + union { + GETATTR2resok resok; + } GETATTR2res_u; +}; +typedef struct GETATTR2res GETATTR2res; + +struct ACCESS2args { + fhandle_t fh; + uint32 access; +}; +typedef struct ACCESS2args ACCESS2args; +#define ACCESS2_READ 0x1 +#define ACCESS2_LOOKUP 0x2 +#define ACCESS2_MODIFY 0x4 +#define ACCESS2_EXTEND 0x8 +#define ACCESS2_DELETE 0x10 +#define ACCESS2_EXECUTE 0x20 + +struct ACCESS2resok { + struct nfsfattr attr; + uint32 access; +}; +typedef struct ACCESS2resok ACCESS2resok; + +struct ACCESS2res { + nfsstat status; + union { + ACCESS2resok resok; + } ACCESS2res_u; +}; +typedef struct ACCESS2res ACCESS2res; + +struct GETXATTRDIR2args { + fhandle_t fh; + bool_t create; +}; +typedef struct GETXATTRDIR2args GETXATTRDIR2args; + +struct GETXATTRDIR2resok { + fhandle_t fh; + struct nfsfattr attr; +}; +typedef struct GETXATTRDIR2resok GETXATTRDIR2resok; + +struct GETXATTRDIR2res { + nfsstat status; + union { + GETXATTRDIR2resok resok; + } GETXATTRDIR2res_u; +}; +typedef struct GETXATTRDIR2res GETXATTRDIR2res; + +struct GETACL3args { + nfs_fh3 fh; + u_int mask; +}; +typedef struct GETACL3args GETACL3args; + +struct GETACL3resok { + post_op_attr attr; + secattr acl; +}; +typedef struct GETACL3resok GETACL3resok; + +struct GETACL3resfail { + post_op_attr attr; +}; +typedef struct GETACL3resfail GETACL3resfail; + +struct GETACL3res { + nfsstat3 status; + union { + GETACL3resok resok; + GETACL3resfail resfail; + } GETACL3res_u; +}; +typedef struct GETACL3res GETACL3res; + +struct SETACL3args { + nfs_fh3 fh; + secattr acl; +}; +typedef struct SETACL3args SETACL3args; + +struct SETACL3resok { + post_op_attr attr; +}; +typedef struct SETACL3resok SETACL3resok; + +struct SETACL3resfail { + post_op_attr attr; +}; +typedef struct SETACL3resfail SETACL3resfail; + +struct SETACL3res { + nfsstat3 status; + union { + SETACL3resok resok; + SETACL3resfail resfail; + } SETACL3res_u; +}; +typedef struct SETACL3res SETACL3res; + +struct GETXATTRDIR3args { + nfs_fh3 fh; + bool_t create; +}; +typedef struct GETXATTRDIR3args GETXATTRDIR3args; + +struct GETXATTRDIR3resok { + nfs_fh3 fh; + post_op_attr attr; +}; +typedef struct GETXATTRDIR3resok GETXATTRDIR3resok; + +struct GETXATTRDIR3res { + nfsstat3 status; + union { + GETXATTRDIR3resok resok; + } GETXATTRDIR3res_u; +}; +typedef struct GETXATTRDIR3res GETXATTRDIR3res; + +struct GETACL4args { + nfs_fh4 fh; + u_int mask; +}; +typedef struct GETACL4args GETACL4args; + +struct GETACL4resok { + post_op_attr attr; + secattr acl; +}; +typedef struct GETACL4resok GETACL4resok; + +struct GETACL4resfail { + post_op_attr attr; +}; +typedef struct GETACL4resfail GETACL4resfail; + +struct GETACL4res { + nfsstat3 status; + union { + GETACL4resok resok; + GETACL4resfail resfail; + } GETACL4res_u; +}; +typedef struct GETACL4res GETACL4res; + +struct SETACL4args { + nfs_fh4 fh; + secattr acl; +}; +typedef struct SETACL4args SETACL4args; + +struct SETACL4resok { + post_op_attr attr; +}; +typedef struct SETACL4resok SETACL4resok; + +struct SETACL4resfail { + post_op_attr attr; +}; +typedef struct SETACL4resfail SETACL4resfail; + +struct SETACL4res { + nfsstat3 status; + union { + SETACL4resok resok; + SETACL4resfail resfail; + } SETACL4res_u; +}; +typedef struct SETACL4res SETACL4res; +#define NFS_ACL_PORT 2049 + +#define NFS_ACL_PROGRAM 100227 +#define NFS_ACL_V2 2 + +#if defined(__STDC__) || defined(__cplusplus) +#define ACLPROC2_NULL 0 +extern void * aclproc2_null_2(void *, CLIENT *); +extern void * aclproc2_null_2_svc(void *, struct svc_req *); +#define ACLPROC2_GETACL 1 +extern GETACL2res * aclproc2_getacl_2(GETACL2args *, CLIENT *); +extern GETACL2res * aclproc2_getacl_2_svc(GETACL2args *, struct svc_req *); +#define ACLPROC2_SETACL 2 +extern SETACL2res * aclproc2_setacl_2(SETACL2args *, CLIENT *); +extern SETACL2res * aclproc2_setacl_2_svc(SETACL2args *, struct svc_req *); +#define ACLPROC2_GETATTR 3 +extern GETATTR2res * aclproc2_getattr_2(GETATTR2args *, CLIENT *); +extern GETATTR2res * aclproc2_getattr_2_svc(GETATTR2args *, struct svc_req *); +#define ACLPROC2_ACCESS 4 +extern ACCESS2res * aclproc2_access_2(ACCESS2args *, CLIENT *); +extern ACCESS2res * aclproc2_access_2_svc(ACCESS2args *, struct svc_req *); +#define ACLPROC2_GETXATTRDIR 5 +extern GETXATTRDIR2res * aclproc2_getxattrdir_2(GETXATTRDIR2args *, CLIENT *); +extern GETXATTRDIR2res * aclproc2_getxattrdir_2_svc(GETXATTRDIR2args *, struct svc_req *); +extern int nfs_acl_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define ACLPROC2_NULL 0 +extern void * aclproc2_null_2(); +extern void * aclproc2_null_2_svc(); +#define ACLPROC2_GETACL 1 +extern GETACL2res * aclproc2_getacl_2(); +extern GETACL2res * aclproc2_getacl_2_svc(); +#define ACLPROC2_SETACL 2 +extern SETACL2res * aclproc2_setacl_2(); +extern SETACL2res * aclproc2_setacl_2_svc(); +#define ACLPROC2_GETATTR 3 +extern GETATTR2res * aclproc2_getattr_2(); +extern GETATTR2res * aclproc2_getattr_2_svc(); +#define ACLPROC2_ACCESS 4 +extern ACCESS2res * aclproc2_access_2(); +extern ACCESS2res * aclproc2_access_2_svc(); +#define ACLPROC2_GETXATTRDIR 5 +extern GETXATTRDIR2res * aclproc2_getxattrdir_2(); +extern GETXATTRDIR2res * aclproc2_getxattrdir_2_svc(); +extern int nfs_acl_program_2_freeresult(); +#endif /* K&R C */ +#define NFS_ACL_V3 3 + +#if defined(__STDC__) || defined(__cplusplus) +#define ACLPROC3_NULL 0 +extern void * aclproc3_null_3(void *, CLIENT *); +extern void * aclproc3_null_3_svc(void *, struct svc_req *); +#define ACLPROC3_GETACL 1 +extern GETACL3res * aclproc3_getacl_3(GETACL3args *, CLIENT *); +extern GETACL3res * aclproc3_getacl_3_svc(GETACL3args *, struct svc_req *); +#define ACLPROC3_SETACL 2 +extern SETACL3res * aclproc3_setacl_3(SETACL3args *, CLIENT *); +extern SETACL3res * aclproc3_setacl_3_svc(SETACL3args *, struct svc_req *); +#define ACLPROC3_GETXATTRDIR 3 +extern GETXATTRDIR3res * aclproc3_getxattrdir_3(GETXATTRDIR3args *, CLIENT *); +extern GETXATTRDIR3res * aclproc3_getxattrdir_3_svc(GETXATTRDIR3args *, struct svc_req *); +extern int nfs_acl_program_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define ACLPROC3_NULL 0 +extern void * aclproc3_null_3(); +extern void * aclproc3_null_3_svc(); +#define ACLPROC3_GETACL 1 +extern GETACL3res * aclproc3_getacl_3(); +extern GETACL3res * aclproc3_getacl_3_svc(); +#define ACLPROC3_SETACL 2 +extern SETACL3res * aclproc3_setacl_3(); +extern SETACL3res * aclproc3_setacl_3_svc(); +#define ACLPROC3_GETXATTRDIR 3 +extern GETXATTRDIR3res * aclproc3_getxattrdir_3(); +extern GETXATTRDIR3res * aclproc3_getxattrdir_3_svc(); +extern int nfs_acl_program_3_freeresult(); +#endif /* K&R C */ +#define NFS_ACL_V4 4 + +#if defined(__STDC__) || defined(__cplusplus) +#define ACLPROC4_NULL 0 +extern void * aclproc4_null_4(void *, CLIENT *); +extern void * aclproc4_null_4_svc(void *, struct svc_req *); +#define ACLPROC4_GETACL 1 +extern GETACL4res * aclproc4_getacl_4(GETACL4args *, CLIENT *); +extern GETACL4res * aclproc4_getacl_4_svc(GETACL4args *, struct svc_req *); +#define ACLPROC4_SETACL 2 +extern SETACL4res * aclproc4_setacl_4(SETACL4args *, CLIENT *); +extern SETACL4res * aclproc4_setacl_4_svc(SETACL4args *, struct svc_req *); +extern int nfs_acl_program_4_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define ACLPROC4_NULL 0 +extern void * aclproc4_null_4(); +extern void * aclproc4_null_4_svc(); +#define ACLPROC4_GETACL 1 +extern GETACL4res * aclproc4_getacl_4(); +extern GETACL4res * aclproc4_getacl_4_svc(); +#define ACLPROC4_SETACL 2 +extern SETACL4res * aclproc4_setacl_4(); +extern SETACL4res * aclproc4_setacl_4_svc(); +extern int nfs_acl_program_4_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_uid(XDR *, uid*); +extern bool_t xdr_o_mode(XDR *, o_mode*); +extern bool_t xdr_aclent(XDR *, aclent*); +extern bool_t xdr_secattr(XDR *, secattr*); +extern bool_t xdr_GETACL2args(XDR *, GETACL2args*); +extern bool_t xdr_GETACL2resok(XDR *, GETACL2resok*); +extern bool_t xdr_GETACL2res(XDR *, GETACL2res*); +extern bool_t xdr_SETACL2args(XDR *, SETACL2args*); +extern bool_t xdr_SETACL2resok(XDR *, SETACL2resok*); +extern bool_t xdr_SETACL2res(XDR *, SETACL2res*); +extern bool_t xdr_GETATTR2args(XDR *, GETATTR2args*); +extern bool_t xdr_GETATTR2resok(XDR *, GETATTR2resok*); +extern bool_t xdr_GETATTR2res(XDR *, GETATTR2res*); +extern bool_t xdr_ACCESS2args(XDR *, ACCESS2args*); +extern bool_t xdr_ACCESS2resok(XDR *, ACCESS2resok*); +extern bool_t xdr_ACCESS2res(XDR *, ACCESS2res*); +extern bool_t xdr_GETXATTRDIR2args(XDR *, GETXATTRDIR2args*); +extern bool_t xdr_GETXATTRDIR2resok(XDR *, GETXATTRDIR2resok*); +extern bool_t xdr_GETXATTRDIR2res(XDR *, GETXATTRDIR2res*); +extern bool_t xdr_GETACL3args(XDR *, GETACL3args*); +extern bool_t xdr_GETACL3resok(XDR *, GETACL3resok*); +extern bool_t xdr_GETACL3resfail(XDR *, GETACL3resfail*); +extern bool_t xdr_GETACL3res(XDR *, GETACL3res*); +extern bool_t xdr_SETACL3args(XDR *, SETACL3args*); +extern bool_t xdr_SETACL3resok(XDR *, SETACL3resok*); +extern bool_t xdr_SETACL3resfail(XDR *, SETACL3resfail*); +extern bool_t xdr_SETACL3res(XDR *, SETACL3res*); +extern bool_t xdr_GETXATTRDIR3args(XDR *, GETXATTRDIR3args*); +extern bool_t xdr_GETXATTRDIR3resok(XDR *, GETXATTRDIR3resok*); +extern bool_t xdr_GETXATTRDIR3res(XDR *, GETXATTRDIR3res*); +extern bool_t xdr_GETACL4args(XDR *, GETACL4args*); +extern bool_t xdr_GETACL4resok(XDR *, GETACL4resok*); +extern bool_t xdr_GETACL4resfail(XDR *, GETACL4resfail*); +extern bool_t xdr_GETACL4res(XDR *, GETACL4res*); +extern bool_t xdr_SETACL4args(XDR *, SETACL4args*); +extern bool_t xdr_SETACL4resok(XDR *, SETACL4resok*); +extern bool_t xdr_SETACL4resfail(XDR *, SETACL4resfail*); +extern bool_t xdr_SETACL4res(XDR *, SETACL4res*); + +#else /* K&R C */ +extern bool_t xdr_uid(); +extern bool_t xdr_o_mode(); +extern bool_t xdr_aclent(); +extern bool_t xdr_secattr(); +extern bool_t xdr_GETACL2args(); +extern bool_t xdr_GETACL2resok(); +extern bool_t xdr_GETACL2res(); +extern bool_t xdr_SETACL2args(); +extern bool_t xdr_SETACL2resok(); +extern bool_t xdr_SETACL2res(); +extern bool_t xdr_GETATTR2args(); +extern bool_t xdr_GETATTR2resok(); +extern bool_t xdr_GETATTR2res(); +extern bool_t xdr_ACCESS2args(); +extern bool_t xdr_ACCESS2resok(); +extern bool_t xdr_ACCESS2res(); +extern bool_t xdr_GETXATTRDIR2args(); +extern bool_t xdr_GETXATTRDIR2resok(); +extern bool_t xdr_GETXATTRDIR2res(); +extern bool_t xdr_GETACL3args(); +extern bool_t xdr_GETACL3resok(); +extern bool_t xdr_GETACL3resfail(); +extern bool_t xdr_GETACL3res(); +extern bool_t xdr_SETACL3args(); +extern bool_t xdr_SETACL3resok(); +extern bool_t xdr_SETACL3resfail(); +extern bool_t xdr_SETACL3res(); +extern bool_t xdr_GETXATTRDIR3args(); +extern bool_t xdr_GETXATTRDIR3resok(); +extern bool_t xdr_GETXATTRDIR3res(); +extern bool_t xdr_GETACL4args(); +extern bool_t xdr_GETACL4resok(); +extern bool_t xdr_GETACL4resfail(); +extern bool_t xdr_GETACL4res(); +extern bool_t xdr_SETACL4args(); +extern bool_t xdr_SETACL4resok(); +extern bool_t xdr_SETACL4resfail(); +extern bool_t xdr_SETACL4res(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_NFS_ACL_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/nfs_acl.x b/illumos-x86_64/usr/include/rpcsvc/nfs_acl.x new file mode 100644 index 00000000..9ccd593e --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nfs_acl.x @@ -0,0 +1,379 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1994,2001-2003 Sun Microsystems, Inc. + * All rights reserved. + * Use is subject to license terms. + */ + +const NFS_ACL_MAX_ENTRIES = 1024; + +typedef int uid; +typedef unsigned short o_mode; + +/* + * This is the format of an ACL which is passed over the network. + */ +struct aclent { + int type; + uid id; + o_mode perm; +}; + +/* + * The values for the type element of the aclent structure. + */ +const NA_USER_OBJ = 0x1; /* object owner */ +const NA_USER = 0x2; /* additional users */ +const NA_GROUP_OBJ = 0x4; /* owning group of the object */ +const NA_GROUP = 0x8; /* additional groups */ +const NA_CLASS_OBJ = 0x10; /* file group class and mask entry */ +const NA_OTHER_OBJ = 0x20; /* other entry for the object */ +const NA_ACL_DEFAULT = 0x1000; /* default flag */ + +/* + * The bit field values for the perm element of the aclent + * structure. The three values can be combined to form any + * of the 8 combinations. + */ +const NA_READ = 0x4; /* read permission */ +const NA_WRITE = 0x2; /* write permission */ +const NA_EXEC = 0x1; /* exec permission */ + +/* + * This is the structure which contains the ACL entries for a + * particular entity. It contains the ACL entries which apply + * to this object plus any default ACL entries which are + * inherited by its children. + * + * The values for the mask field are defined below. + */ +struct secattr { + u_int mask; + int aclcnt; + aclent aclent; + int dfaclcnt; + aclent dfaclent; +}; + +/* + * The values for the mask element of the secattr struct as well + * as for the mask element in the arguments in the GETACL2 and + * GETACL3 procedures. + */ +const NA_ACL = 0x1; /* aclent contains a valid list */ +const NA_ACLCNT = 0x2; /* the number of entries in the aclent list */ +const NA_DFACL = 0x4; /* dfaclent contains a valid list */ +const NA_DFACLCNT = 0x8; /* the number of entries in the dfaclent list */ + +/* + * This the definition for the GETACL procedure which applies to + * NFS Version 2. + */ +struct GETACL2args { + fhandle_t fh; + u_int mask; +}; + +struct GETACL2resok { + struct nfsfattr attr; + secattr acl; +}; + +union GETACL2res switch (enum nfsstat status) { +case ACL2_OK: + GETACL2resok resok; +default: + void; +}; + +/* + * This is the definition for the SETACL procedure which applies + * NFS Version 2. + */ +struct SETACL2args { + fhandle_t fh; + secattr acl; +}; + +struct SETACL2resok { + struct nfsfattr attr; +}; + +union SETACL2res switch (enum nfsstat status) { +case ACL2_OK: + SETACL2resok resok; +default: + void; +}; + +/* + * This is the definition for the GETATTR procedure which can be + * used as an alternative to the GETATTR in NFS Version 2. The + * main difference between this GETATTR and the NFS GETATTR is + * that this GETATTR returns the mode of the file without it being + * changed to match the min/max permissions mapping that the NFS + * Version 2 server does. + */ +struct GETATTR2args { + fhandle_t fh; +}; + +struct GETATTR2resok { + struct nfsfattr attr; +}; + +union GETATTR2res switch (enum nfsstat status) { +case ACL2_OK: + GETATTR2resok resok; +default: + void; +}; + +/* + * This is the definition for the ACCESS procedure which applies + * to NFS Version 2. + */ +struct ACCESS2args { + fhandle_t fh; + uint32 access; +}; + +/* + * The following access permissions may be requested: + */ +const ACCESS2_READ = 0x1; /* read data or readdir a directory */ +const ACCESS2_LOOKUP = 0x2; /* lookup a name in a directory */ +const ACCESS2_MODIFY = 0x4; /* rewrite existing file data or */ + /* modify existing directory entries */ +const ACCESS2_EXTEND = 0x8; /* write new data or add directory entries */ +const ACCESS2_DELETE = 0x10; /* delete existing directory entry */ +const ACCESS2_EXECUTE = 0x20; /* execute file (no meaning for a directory) */ + +struct ACCESS2resok { + struct nfsfattr attr; + uint32 access; +}; + +union ACCESS2res switch (enum nfsstat status) { +case ACL2_OK: + ACCESS2resok resok; +default: + void; +}; + +/* + * This is the definition for the GETXATTRDIR procedure which applies + * to NFS Version 2 files. + */ +struct GETXATTRDIR2args { + fhandle_t fh; + bool create; +}; + +struct GETXATTRDIR2resok { + fhandle_t fh; + struct nfsfattr attr; +}; + +union GETXATTRDIR2res switch (enum nfsstat status) { +case ACL2_OK: + GETXATTRDIR2resok resok; +default: + void; +}; + +/* + * This is the definition for the GETACL procedure which applies + * to NFS Version 3 files. + */ +struct GETACL3args { + nfs_fh3 fh; + u_int mask; +}; + +struct GETACL3resok { + post_op_attr attr; + secattr acl; +}; + +struct GETACL3resfail { + post_op_attr attr; +}; + +union GETACL3res switch (nfsstat3 status) { +case ACL3_OK: + GETACL3resok resok; +default: + GETACL3resfail resfail; +}; + +/* + * This is the definition for the SETACL procedure which applies + * to NFS Version 3 files. + */ +struct SETACL3args { + nfs_fh3 fh; + secattr acl; +}; + +struct SETACL3resok { + post_op_attr attr; +}; + +struct SETACL3resfail { + post_op_attr attr; +}; + +union SETACL3res switch (nfsstat3 status) { +case ACL3_OK: + SETACL3resok resok; +default: + SETACL3resfail resfail; +}; + +/* + * This is the definition for the GETXATTRDIR procedure which applies + * to NFS Version 3 files. + */ +struct GETXATTRDIR3args { + nfs_fh3 fh; + bool create; +}; + +struct GETXATTRDIR3resok { + nfs_fh3 fh; + post_op_attr attr; +}; + +union GETXATTRDIR3res switch (nfsstat3 status) { +case ACL3_OK: + GETXATTRDIR3resok resok; +default: + void; +}; + +/* + * XXX { + * This is a transitional interface to enable Solaris NFSv4 + * clients to manipulate ACLs on Solaris servers until the + * spec is complete enough to implement this inside the + * NFSv4 protocol itself. NFSv4 does handle extended + * attributes in-band. + */ + +/* + * This is the definition for the GETACL procedure which applies + * to NFS Version 4 files. + */ +struct GETACL4args { + nfs_fh4 fh; + u_int mask; +}; + +struct GETACL4resok { + post_op_attr attr; + secattr acl; +}; + +struct GETACL4resfail { + post_op_attr attr; +}; + +union GETACL4res switch (nfsstat3 status) { +case ACL4_OK: + GETACL4resok resok; +default: + GETACL4resfail resfail; +}; + +/* + * This is the definition for the SETACL procedure which applies + * to NFS Version 4 files. + */ +struct SETACL4args { + nfs_fh4 fh; + secattr acl; +}; + +struct SETACL4resok { + post_op_attr attr; +}; + +struct SETACL4resfail { + post_op_attr attr; +}; + +union SETACL4res switch (nfsstat3 status) { +case ACL4_OK: + SETACL4resok resok; +default: + SETACL4resfail resfail; +}; + +/* XXX } */ + +/* + * Share the port with the NFS service. NFS has to be running + * in order for this service to be useful anyway. + */ +const NFS_ACL_PORT = 2049; + +/* + * This is the definition for the ACL network protocol which is used + * to provide support for Solaris ACLs for files which are accessed + * via NFS Version 2 and NFS Version 3. + */ +program NFS_ACL_PROGRAM { + version NFS_ACL_V2 { + void + ACLPROC2_NULL(void) = 0; + GETACL2res + ACLPROC2_GETACL(GETACL2args) = 1; + SETACL2res + ACLPROC2_SETACL(SETACL2args) = 2; + GETATTR2res + ACLPROC2_GETATTR(GETATTR2args) = 3; + ACCESS2res + ACLPROC2_ACCESS(ACCESS2args) = 4; + GETXATTRDIR2res + ACLPROC2_GETXATTRDIR(GETXATTRDIR2args) = 5; + } = 2; + version NFS_ACL_V3 { + void + ACLPROC3_NULL(void) = 0; + GETACL3res + ACLPROC3_GETACL(GETACL3args) = 1; + SETACL3res + ACLPROC3_SETACL(SETACL3args) = 2; + GETXATTRDIR3res + ACLPROC3_GETXATTRDIR(GETXATTRDIR3args) = 3; + } = 3; + version NFS_ACL_V4 { + void + ACLPROC4_NULL(void) = 0; + GETACL4res + ACLPROC4_GETACL(GETACL4args) = 1; + SETACL4res + ACLPROC4_SETACL(SETACL4args) = 2; + } = 4; +} = 100227; diff --git a/illumos-x86_64/usr/include/rpcsvc/nfs_prot.h b/illumos-x86_64/usr/include/rpcsvc/nfs_prot.h new file mode 100644 index 00000000..103a72e6 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nfs_prot.h @@ -0,0 +1,1743 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _NFS_PROT_H_RPCGEN +#define _NFS_PROT_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for uint64, int64, uint32, and int32 + */ +#include + +#define NFS_PORT 2049 +#define NFS_MAXDATA 8192 +#define NFS_MAXPATHLEN 1024 +#define NFS_MAXNAMLEN 255 +#define NFS_FHSIZE 32 +#define NFS_COOKIESIZE 4 +#define NFS_FIFO_DEV -1 +#define NFSMODE_FMT 0170000 +#define NFSMODE_DIR 0040000 +#define NFSMODE_CHR 0020000 +#define NFSMODE_BLK 0060000 +#define NFSMODE_REG 0100000 +#define NFSMODE_LNK 0120000 +#define NFSMODE_SOCK 0140000 +#define NFSMODE_FIFO 0010000 + +enum nfsstat { + NFS_OK = 0, + NFSERR_PERM = 1, + NFSERR_NOENT = 2, + NFSERR_IO = 5, + NFSERR_NXIO = 6, + NFSERR_ACCES = 13, + NFSERR_EXIST = 17, + NFSERR_XDEV = 18, + NFSERR_NODEV = 19, + NFSERR_NOTDIR = 20, + NFSERR_ISDIR = 21, + NFSERR_INVAL = 22, + NFSERR_FBIG = 27, + NFSERR_NOSPC = 28, + NFSERR_ROFS = 30, + NFSERR_OPNOTSUPP = 45, + NFSERR_NAMETOOLONG = 63, + NFSERR_NOTEMPTY = 66, + NFSERR_DQUOT = 69, + NFSERR_STALE = 70, + NFSERR_REMOTE = 71, + NFSERR_WFLUSH = 72 +}; +typedef enum nfsstat nfsstat; + +enum ftype { + NFNON = 0, + NFREG = 1, + NFDIR = 2, + NFBLK = 3, + NFCHR = 4, + NFLNK = 5, + NFSOCK = 6, + NFBAD = 7, + NFFIFO = 8 +}; +typedef enum ftype ftype; + +struct nfs_fh { + char data[NFS_FHSIZE]; +}; +typedef struct nfs_fh nfs_fh; + +struct nfstime { + u_int seconds; + u_int useconds; +}; +typedef struct nfstime nfstime; + +struct fattr { + ftype type; + u_int mode; + u_int nlink; + u_int uid; + u_int gid; + u_int size; + u_int blocksize; + u_int rdev; + u_int blocks; + u_int fsid; + u_int fileid; + nfstime atime; + nfstime mtime; + nfstime ctime; +}; +typedef struct fattr fattr; + +struct sattr { + u_int mode; + u_int uid; + u_int gid; + u_int size; + nfstime atime; + nfstime mtime; +}; +typedef struct sattr sattr; + +typedef char *filename; + +typedef char *nfspath; + +struct attrstat { + nfsstat status; + union { + fattr attributes; + } attrstat_u; +}; +typedef struct attrstat attrstat; + +struct sattrargs { + nfs_fh file; + sattr attributes; +}; +typedef struct sattrargs sattrargs; + +struct diropargs { + nfs_fh dir; + filename name; +}; +typedef struct diropargs diropargs; + +struct diropokres { + nfs_fh file; + fattr attributes; +}; +typedef struct diropokres diropokres; + +struct diropres { + nfsstat status; + union { + diropokres diropres; + } diropres_u; +}; +typedef struct diropres diropres; + +struct readlinkres { + nfsstat status; + union { + nfspath data; + } readlinkres_u; +}; +typedef struct readlinkres readlinkres; + +struct readargs { + nfs_fh file; + u_int offset; + u_int count; + u_int totalcount; +}; +typedef struct readargs readargs; + +struct readokres { + fattr attributes; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct readokres readokres; + +struct readres { + nfsstat status; + union { + readokres reply; + } readres_u; +}; +typedef struct readres readres; + +struct writeargs { + nfs_fh file; + u_int beginoffset; + u_int offset; + u_int totalcount; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct writeargs writeargs; + +struct createargs { + diropargs where; + sattr attributes; +}; +typedef struct createargs createargs; + +struct renameargs { + diropargs from; + diropargs to; +}; +typedef struct renameargs renameargs; + +struct linkargs { + nfs_fh from; + diropargs to; +}; +typedef struct linkargs linkargs; + +struct symlinkargs { + diropargs from; + nfspath to; + sattr attributes; +}; +typedef struct symlinkargs symlinkargs; + +typedef char nfscookie[NFS_COOKIESIZE]; + +struct readdirargs { + nfs_fh dir; + nfscookie cookie; + u_int count; +}; +typedef struct readdirargs readdirargs; + +struct entry { + u_int fileid; + filename name; + nfscookie cookie; + struct entry *nextentry; +}; +typedef struct entry entry; + +struct dirlist { + entry *entries; + bool_t eof; +}; +typedef struct dirlist dirlist; + +struct readdirres { + nfsstat status; + union { + dirlist reply; + } readdirres_u; +}; +typedef struct readdirres readdirres; + +struct statfsokres { + u_int tsize; + u_int bsize; + u_int blocks; + u_int bfree; + u_int bavail; +}; +typedef struct statfsokres statfsokres; + +struct statfsres { + nfsstat status; + union { + statfsokres reply; + } statfsres_u; +}; +typedef struct statfsres statfsres; +#define NFS3_FHSIZE 64 +#define NFS3_COOKIEVERFSIZE 8 +#define NFS3_CREATEVERFSIZE 8 +#define NFS3_WRITEVERFSIZE 8 + +typedef char *filename3; + +typedef char *nfspath3; + +typedef uint64 fileid3; + +typedef uint64 cookie3; + +typedef char cookieverf3[NFS3_COOKIEVERFSIZE]; + +typedef char createverf3[NFS3_CREATEVERFSIZE]; + +typedef char writeverf3[NFS3_WRITEVERFSIZE]; + +typedef uint32 uid3; + +typedef uint32 gid3; + +typedef uint64 size3; + +typedef uint64 offset3; + +typedef uint32 mode3; + +typedef uint32 count3; + +enum nfsstat3 { + NFS3_OK = 0, + NFS3ERR_PERM = 1, + NFS3ERR_NOENT = 2, + NFS3ERR_IO = 5, + NFS3ERR_NXIO = 6, + NFS3ERR_ACCES = 13, + NFS3ERR_EXIST = 17, + NFS3ERR_XDEV = 18, + NFS3ERR_NODEV = 19, + NFS3ERR_NOTDIR = 20, + NFS3ERR_ISDIR = 21, + NFS3ERR_INVAL = 22, + NFS3ERR_FBIG = 27, + NFS3ERR_NOSPC = 28, + NFS3ERR_ROFS = 30, + NFS3ERR_MLINK = 31, + NFS3ERR_NAMETOOLONG = 63, + NFS3ERR_NOTEMPTY = 66, + NFS3ERR_DQUOT = 69, + NFS3ERR_STALE = 70, + NFS3ERR_REMOTE = 71, + NFS3ERR_BADHANDLE = 10001, + NFS3ERR_NOT_SYNC = 10002, + NFS3ERR_BAD_COOKIE = 10003, + NFS3ERR_NOTSUPP = 10004, + NFS3ERR_TOOSMALL = 10005, + NFS3ERR_SERVERFAULT = 10006, + NFS3ERR_BADTYPE = 10007, + NFS3ERR_JUKEBOX = 10008 +}; +typedef enum nfsstat3 nfsstat3; + +enum ftype3 { + NF3REG = 1, + NF3DIR = 2, + NF3BLK = 3, + NF3CHR = 4, + NF3LNK = 5, + NF3SOCK = 6, + NF3FIFO = 7 +}; +typedef enum ftype3 ftype3; + +struct specdata3 { + uint32 specdata1; + uint32 specdata2; +}; +typedef struct specdata3 specdata3; + +struct nfs_fh3 { + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct nfs_fh3 nfs_fh3; + +struct nfstime3 { + uint32 seconds; + uint32 nseconds; +}; +typedef struct nfstime3 nfstime3; + +struct fattr3 { + ftype3 type; + mode3 mode; + uint32 nlink; + uid3 uid; + gid3 gid; + size3 size; + size3 used; + specdata3 rdev; + uint64 fsid; + fileid3 fileid; + nfstime3 atime; + nfstime3 mtime; + nfstime3 ctime; +}; +typedef struct fattr3 fattr3; + +struct post_op_attr { + bool_t attributes_follow; + union { + fattr3 attributes; + } post_op_attr_u; +}; +typedef struct post_op_attr post_op_attr; + +struct wcc_attr { + size3 size; + nfstime3 mtime; + nfstime3 ctime; +}; +typedef struct wcc_attr wcc_attr; + +struct pre_op_attr { + bool_t attributes_follow; + union { + wcc_attr attributes; + } pre_op_attr_u; +}; +typedef struct pre_op_attr pre_op_attr; + +struct wcc_data { + pre_op_attr before; + post_op_attr after; +}; +typedef struct wcc_data wcc_data; + +struct post_op_fh3 { + bool_t handle_follows; + union { + nfs_fh3 handle; + } post_op_fh3_u; +}; +typedef struct post_op_fh3 post_op_fh3; + +enum time_how { + DONT_CHANGE = 0, + SET_TO_SERVER_TIME = 1, + SET_TO_CLIENT_TIME = 2 +}; +typedef enum time_how time_how; + +struct set_mode3 { + bool_t set_it; + union { + mode3 mode; + } set_mode3_u; +}; +typedef struct set_mode3 set_mode3; + +struct set_uid3 { + bool_t set_it; + union { + uid3 uid; + } set_uid3_u; +}; +typedef struct set_uid3 set_uid3; + +struct set_gid3 { + bool_t set_it; + union { + gid3 gid; + } set_gid3_u; +}; +typedef struct set_gid3 set_gid3; + +struct set_size3 { + bool_t set_it; + union { + size3 size; + } set_size3_u; +}; +typedef struct set_size3 set_size3; + +struct set_atime { + time_how set_it; + union { + nfstime3 atime; + } set_atime_u; +}; +typedef struct set_atime set_atime; + +struct set_mtime { + time_how set_it; + union { + nfstime3 mtime; + } set_mtime_u; +}; +typedef struct set_mtime set_mtime; + +struct sattr3 { + set_mode3 mode; + set_uid3 uid; + set_gid3 gid; + set_size3 size; + set_atime atime; + set_mtime mtime; +}; +typedef struct sattr3 sattr3; + +struct diropargs3 { + nfs_fh3 dir; + filename3 name; +}; +typedef struct diropargs3 diropargs3; + +struct GETATTR3args { + nfs_fh3 object; +}; +typedef struct GETATTR3args GETATTR3args; + +struct GETATTR3resok { + fattr3 obj_attributes; +}; +typedef struct GETATTR3resok GETATTR3resok; + +struct GETATTR3res { + nfsstat3 status; + union { + GETATTR3resok resok; + } GETATTR3res_u; +}; +typedef struct GETATTR3res GETATTR3res; + +struct sattrguard3 { + bool_t check; + union { + nfstime3 obj_ctime; + } sattrguard3_u; +}; +typedef struct sattrguard3 sattrguard3; + +struct SETATTR3args { + nfs_fh3 object; + sattr3 new_attributes; + sattrguard3 guard; +}; +typedef struct SETATTR3args SETATTR3args; + +struct SETATTR3resok { + wcc_data obj_wcc; +}; +typedef struct SETATTR3resok SETATTR3resok; + +struct SETATTR3resfail { + wcc_data obj_wcc; +}; +typedef struct SETATTR3resfail SETATTR3resfail; + +struct SETATTR3res { + nfsstat3 status; + union { + SETATTR3resok resok; + SETATTR3resfail resfail; + } SETATTR3res_u; +}; +typedef struct SETATTR3res SETATTR3res; + +struct LOOKUP3args { + diropargs3 what; +}; +typedef struct LOOKUP3args LOOKUP3args; + +struct LOOKUP3resok { + nfs_fh3 object; + post_op_attr obj_attributes; + post_op_attr dir_attributes; +}; +typedef struct LOOKUP3resok LOOKUP3resok; + +struct LOOKUP3resfail { + post_op_attr dir_attributes; +}; +typedef struct LOOKUP3resfail LOOKUP3resfail; + +struct LOOKUP3res { + nfsstat3 status; + union { + LOOKUP3resok resok; + LOOKUP3resfail resfail; + } LOOKUP3res_u; +}; +typedef struct LOOKUP3res LOOKUP3res; +#define ACCESS3_READ 0x0001 +#define ACCESS3_LOOKUP 0x0002 +#define ACCESS3_MODIFY 0x0004 +#define ACCESS3_EXTEND 0x0008 +#define ACCESS3_DELETE 0x0010 +#define ACCESS3_EXECUTE 0x0020 + +struct ACCESS3args { + nfs_fh3 object; + uint32 access; +}; +typedef struct ACCESS3args ACCESS3args; + +struct ACCESS3resok { + post_op_attr obj_attributes; + uint32 access; +}; +typedef struct ACCESS3resok ACCESS3resok; + +struct ACCESS3resfail { + post_op_attr obj_attributes; +}; +typedef struct ACCESS3resfail ACCESS3resfail; + +struct ACCESS3res { + nfsstat3 status; + union { + ACCESS3resok resok; + ACCESS3resfail resfail; + } ACCESS3res_u; +}; +typedef struct ACCESS3res ACCESS3res; + +struct READLINK3args { + nfs_fh3 symlink; +}; +typedef struct READLINK3args READLINK3args; + +struct READLINK3resok { + post_op_attr symlink_attributes; + nfspath3 data; +}; +typedef struct READLINK3resok READLINK3resok; + +struct READLINK3resfail { + post_op_attr symlink_attributes; +}; +typedef struct READLINK3resfail READLINK3resfail; + +struct READLINK3res { + nfsstat3 status; + union { + READLINK3resok resok; + READLINK3resfail resfail; + } READLINK3res_u; +}; +typedef struct READLINK3res READLINK3res; + +struct READ3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; +typedef struct READ3args READ3args; + +struct READ3resok { + post_op_attr file_attributes; + count3 count; + bool_t eof; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct READ3resok READ3resok; + +struct READ3resfail { + post_op_attr file_attributes; +}; +typedef struct READ3resfail READ3resfail; + +struct READ3res { + nfsstat3 status; + union { + READ3resok resok; + READ3resfail resfail; + } READ3res_u; +}; +typedef struct READ3res READ3res; + +enum stable_how { + UNSTABLE = 0, + DATA_SYNC = 1, + FILE_SYNC = 2 +}; +typedef enum stable_how stable_how; + +struct WRITE3args { + nfs_fh3 file; + offset3 offset; + count3 count; + stable_how stable; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct WRITE3args WRITE3args; + +struct WRITE3resok { + wcc_data file_wcc; + count3 count; + stable_how committed; + writeverf3 verf; +}; +typedef struct WRITE3resok WRITE3resok; + +struct WRITE3resfail { + wcc_data file_wcc; +}; +typedef struct WRITE3resfail WRITE3resfail; + +struct WRITE3res { + nfsstat3 status; + union { + WRITE3resok resok; + WRITE3resfail resfail; + } WRITE3res_u; +}; +typedef struct WRITE3res WRITE3res; + +enum createmode3 { + UNCHECKED = 0, + GUARDED = 1, + EXCLUSIVE = 2 +}; +typedef enum createmode3 createmode3; + +struct createhow3 { + createmode3 mode; + union { + sattr3 obj_attributes; + createverf3 verf; + } createhow3_u; +}; +typedef struct createhow3 createhow3; + +struct CREATE3args { + diropargs3 where; + createhow3 how; +}; +typedef struct CREATE3args CREATE3args; + +struct CREATE3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; +typedef struct CREATE3resok CREATE3resok; + +struct CREATE3resfail { + wcc_data dir_wcc; +}; +typedef struct CREATE3resfail CREATE3resfail; + +struct CREATE3res { + nfsstat3 status; + union { + CREATE3resok resok; + CREATE3resfail resfail; + } CREATE3res_u; +}; +typedef struct CREATE3res CREATE3res; + +struct MKDIR3args { + diropargs3 where; + sattr3 attributes; +}; +typedef struct MKDIR3args MKDIR3args; + +struct MKDIR3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; +typedef struct MKDIR3resok MKDIR3resok; + +struct MKDIR3resfail { + wcc_data dir_wcc; +}; +typedef struct MKDIR3resfail MKDIR3resfail; + +struct MKDIR3res { + nfsstat3 status; + union { + MKDIR3resok resok; + MKDIR3resfail resfail; + } MKDIR3res_u; +}; +typedef struct MKDIR3res MKDIR3res; + +struct symlinkdata3 { + sattr3 symlink_attributes; + nfspath3 symlink_data; +}; +typedef struct symlinkdata3 symlinkdata3; + +struct SYMLINK3args { + diropargs3 where; + symlinkdata3 symlink; +}; +typedef struct SYMLINK3args SYMLINK3args; + +struct SYMLINK3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; +typedef struct SYMLINK3resok SYMLINK3resok; + +struct SYMLINK3resfail { + wcc_data dir_wcc; +}; +typedef struct SYMLINK3resfail SYMLINK3resfail; + +struct SYMLINK3res { + nfsstat3 status; + union { + SYMLINK3resok resok; + SYMLINK3resfail resfail; + } SYMLINK3res_u; +}; +typedef struct SYMLINK3res SYMLINK3res; + +struct devicedata3 { + sattr3 dev_attributes; + specdata3 spec; +}; +typedef struct devicedata3 devicedata3; + +struct mknoddata3 { + ftype3 type; + union { + devicedata3 device; + sattr3 pipe_attributes; + } mknoddata3_u; +}; +typedef struct mknoddata3 mknoddata3; + +struct MKNOD3args { + diropargs3 where; + mknoddata3 what; +}; +typedef struct MKNOD3args MKNOD3args; + +struct MKNOD3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; +typedef struct MKNOD3resok MKNOD3resok; + +struct MKNOD3resfail { + wcc_data dir_wcc; +}; +typedef struct MKNOD3resfail MKNOD3resfail; + +struct MKNOD3res { + nfsstat3 status; + union { + MKNOD3resok resok; + MKNOD3resfail resfail; + } MKNOD3res_u; +}; +typedef struct MKNOD3res MKNOD3res; + +struct REMOVE3args { + diropargs3 object; +}; +typedef struct REMOVE3args REMOVE3args; + +struct REMOVE3resok { + wcc_data dir_wcc; +}; +typedef struct REMOVE3resok REMOVE3resok; + +struct REMOVE3resfail { + wcc_data dir_wcc; +}; +typedef struct REMOVE3resfail REMOVE3resfail; + +struct REMOVE3res { + nfsstat3 status; + union { + REMOVE3resok resok; + REMOVE3resfail resfail; + } REMOVE3res_u; +}; +typedef struct REMOVE3res REMOVE3res; + +struct RMDIR3args { + diropargs3 object; +}; +typedef struct RMDIR3args RMDIR3args; + +struct RMDIR3resok { + wcc_data dir_wcc; +}; +typedef struct RMDIR3resok RMDIR3resok; + +struct RMDIR3resfail { + wcc_data dir_wcc; +}; +typedef struct RMDIR3resfail RMDIR3resfail; + +struct RMDIR3res { + nfsstat3 status; + union { + RMDIR3resok resok; + RMDIR3resfail resfail; + } RMDIR3res_u; +}; +typedef struct RMDIR3res RMDIR3res; + +struct RENAME3args { + diropargs3 from; + diropargs3 to; +}; +typedef struct RENAME3args RENAME3args; + +struct RENAME3resok { + wcc_data fromdir_wcc; + wcc_data todir_wcc; +}; +typedef struct RENAME3resok RENAME3resok; + +struct RENAME3resfail { + wcc_data fromdir_wcc; + wcc_data todir_wcc; +}; +typedef struct RENAME3resfail RENAME3resfail; + +struct RENAME3res { + nfsstat3 status; + union { + RENAME3resok resok; + RENAME3resfail resfail; + } RENAME3res_u; +}; +typedef struct RENAME3res RENAME3res; + +struct LINK3args { + nfs_fh3 file; + diropargs3 link; +}; +typedef struct LINK3args LINK3args; + +struct LINK3resok { + post_op_attr file_attributes; + wcc_data linkdir_wcc; +}; +typedef struct LINK3resok LINK3resok; + +struct LINK3resfail { + post_op_attr file_attributes; + wcc_data linkdir_wcc; +}; +typedef struct LINK3resfail LINK3resfail; + +struct LINK3res { + nfsstat3 status; + union { + LINK3resok resok; + LINK3resfail resfail; + } LINK3res_u; +}; +typedef struct LINK3res LINK3res; + +struct READDIR3args { + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 count; +}; +typedef struct READDIR3args READDIR3args; + +struct entry3 { + fileid3 fileid; + filename3 name; + cookie3 cookie; + struct entry3 *nextentry; +}; +typedef struct entry3 entry3; + +struct dirlist3 { + entry3 *entries; + bool_t eof; +}; +typedef struct dirlist3 dirlist3; + +struct READDIR3resok { + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlist3 reply; +}; +typedef struct READDIR3resok READDIR3resok; + +struct READDIR3resfail { + post_op_attr dir_attributes; +}; +typedef struct READDIR3resfail READDIR3resfail; + +struct READDIR3res { + nfsstat3 status; + union { + READDIR3resok resok; + READDIR3resfail resfail; + } READDIR3res_u; +}; +typedef struct READDIR3res READDIR3res; + +struct READDIRPLUS3args { + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 dircount; + count3 maxcount; +}; +typedef struct READDIRPLUS3args READDIRPLUS3args; + +struct entryplus3 { + fileid3 fileid; + filename3 name; + cookie3 cookie; + post_op_attr name_attributes; + post_op_fh3 name_handle; + struct entryplus3 *nextentry; +}; +typedef struct entryplus3 entryplus3; + +struct dirlistplus3 { + entryplus3 *entries; + bool_t eof; +}; +typedef struct dirlistplus3 dirlistplus3; + +struct READDIRPLUS3resok { + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlistplus3 reply; +}; +typedef struct READDIRPLUS3resok READDIRPLUS3resok; + +struct READDIRPLUS3resfail { + post_op_attr dir_attributes; +}; +typedef struct READDIRPLUS3resfail READDIRPLUS3resfail; + +struct READDIRPLUS3res { + nfsstat3 status; + union { + READDIRPLUS3resok resok; + READDIRPLUS3resfail resfail; + } READDIRPLUS3res_u; +}; +typedef struct READDIRPLUS3res READDIRPLUS3res; + +struct FSSTAT3args { + nfs_fh3 fsroot; +}; +typedef struct FSSTAT3args FSSTAT3args; + +struct FSSTAT3resok { + post_op_attr obj_attributes; + size3 tbytes; + size3 fbytes; + size3 abytes; + size3 tfiles; + size3 ffiles; + size3 afiles; + uint32 invarsec; +}; +typedef struct FSSTAT3resok FSSTAT3resok; + +struct FSSTAT3resfail { + post_op_attr obj_attributes; +}; +typedef struct FSSTAT3resfail FSSTAT3resfail; + +struct FSSTAT3res { + nfsstat3 status; + union { + FSSTAT3resok resok; + FSSTAT3resfail resfail; + } FSSTAT3res_u; +}; +typedef struct FSSTAT3res FSSTAT3res; +#define FSF3_LINK 0x0001 +#define FSF3_SYMLINK 0x0002 +#define FSF3_HOMOGENEOUS 0x0008 +#define FSF3_CANSETTIME 0x0010 + +struct FSINFO3args { + nfs_fh3 fsroot; +}; +typedef struct FSINFO3args FSINFO3args; + +struct FSINFO3resok { + post_op_attr obj_attributes; + uint32 rtmax; + uint32 rtpref; + uint32 rtmult; + uint32 wtmax; + uint32 wtpref; + uint32 wtmult; + uint32 dtpref; + size3 maxfilesize; + nfstime3 time_delta; + uint32 properties; +}; +typedef struct FSINFO3resok FSINFO3resok; + +struct FSINFO3resfail { + post_op_attr obj_attributes; +}; +typedef struct FSINFO3resfail FSINFO3resfail; + +struct FSINFO3res { + nfsstat3 status; + union { + FSINFO3resok resok; + FSINFO3resfail resfail; + } FSINFO3res_u; +}; +typedef struct FSINFO3res FSINFO3res; + +struct PATHCONF3args { + nfs_fh3 object; +}; +typedef struct PATHCONF3args PATHCONF3args; + +struct PATHCONF3resok { + post_op_attr obj_attributes; + uint32 linkmax; + uint32 name_max; + bool_t no_trunc; + bool_t chown_restricted; + bool_t case_insensitive; + bool_t case_preserving; +}; +typedef struct PATHCONF3resok PATHCONF3resok; + +struct PATHCONF3resfail { + post_op_attr obj_attributes; +}; +typedef struct PATHCONF3resfail PATHCONF3resfail; + +struct PATHCONF3res { + nfsstat3 status; + union { + PATHCONF3resok resok; + PATHCONF3resfail resfail; + } PATHCONF3res_u; +}; +typedef struct PATHCONF3res PATHCONF3res; + +struct COMMIT3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; +typedef struct COMMIT3args COMMIT3args; + +struct COMMIT3resok { + wcc_data file_wcc; + writeverf3 verf; +}; +typedef struct COMMIT3resok COMMIT3resok; + +struct COMMIT3resfail { + wcc_data file_wcc; +}; +typedef struct COMMIT3resfail COMMIT3resfail; + +struct COMMIT3res { + nfsstat3 status; + union { + COMMIT3resok resok; + COMMIT3resfail resfail; + } COMMIT3res_u; +}; +typedef struct COMMIT3res COMMIT3res; + +#define NFS_PROGRAM 100003 +#define NFS_VERSION 2 + +#if defined(__STDC__) || defined(__cplusplus) +#define NFSPROC_NULL 0 +extern void * nfsproc_null_2(void *, CLIENT *); +extern void * nfsproc_null_2_svc(void *, struct svc_req *); +#define NFSPROC_GETATTR 1 +extern attrstat * nfsproc_getattr_2(nfs_fh *, CLIENT *); +extern attrstat * nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); +#define NFSPROC_SETATTR 2 +extern attrstat * nfsproc_setattr_2(sattrargs *, CLIENT *); +extern attrstat * nfsproc_setattr_2_svc(sattrargs *, struct svc_req *); +#define NFSPROC_ROOT 3 +extern void * nfsproc_root_2(void *, CLIENT *); +extern void * nfsproc_root_2_svc(void *, struct svc_req *); +#define NFSPROC_LOOKUP 4 +extern diropres * nfsproc_lookup_2(diropargs *, CLIENT *); +extern diropres * nfsproc_lookup_2_svc(diropargs *, struct svc_req *); +#define NFSPROC_READLINK 5 +extern readlinkres * nfsproc_readlink_2(nfs_fh *, CLIENT *); +extern readlinkres * nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); +#define NFSPROC_READ 6 +extern readres * nfsproc_read_2(readargs *, CLIENT *); +extern readres * nfsproc_read_2_svc(readargs *, struct svc_req *); +#define NFSPROC_WRITECACHE 7 +extern void * nfsproc_writecache_2(void *, CLIENT *); +extern void * nfsproc_writecache_2_svc(void *, struct svc_req *); +#define NFSPROC_WRITE 8 +extern attrstat * nfsproc_write_2(writeargs *, CLIENT *); +extern attrstat * nfsproc_write_2_svc(writeargs *, struct svc_req *); +#define NFSPROC_CREATE 9 +extern diropres * nfsproc_create_2(createargs *, CLIENT *); +extern diropres * nfsproc_create_2_svc(createargs *, struct svc_req *); +#define NFSPROC_REMOVE 10 +extern nfsstat * nfsproc_remove_2(diropargs *, CLIENT *); +extern nfsstat * nfsproc_remove_2_svc(diropargs *, struct svc_req *); +#define NFSPROC_RENAME 11 +extern nfsstat * nfsproc_rename_2(renameargs *, CLIENT *); +extern nfsstat * nfsproc_rename_2_svc(renameargs *, struct svc_req *); +#define NFSPROC_LINK 12 +extern nfsstat * nfsproc_link_2(linkargs *, CLIENT *); +extern nfsstat * nfsproc_link_2_svc(linkargs *, struct svc_req *); +#define NFSPROC_SYMLINK 13 +extern nfsstat * nfsproc_symlink_2(symlinkargs *, CLIENT *); +extern nfsstat * nfsproc_symlink_2_svc(symlinkargs *, struct svc_req *); +#define NFSPROC_MKDIR 14 +extern diropres * nfsproc_mkdir_2(createargs *, CLIENT *); +extern diropres * nfsproc_mkdir_2_svc(createargs *, struct svc_req *); +#define NFSPROC_RMDIR 15 +extern nfsstat * nfsproc_rmdir_2(diropargs *, CLIENT *); +extern nfsstat * nfsproc_rmdir_2_svc(diropargs *, struct svc_req *); +#define NFSPROC_READDIR 16 +extern readdirres * nfsproc_readdir_2(readdirargs *, CLIENT *); +extern readdirres * nfsproc_readdir_2_svc(readdirargs *, struct svc_req *); +#define NFSPROC_STATFS 17 +extern statfsres * nfsproc_statfs_2(nfs_fh *, CLIENT *); +extern statfsres * nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); +extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define NFSPROC_NULL 0 +extern void * nfsproc_null_2(); +extern void * nfsproc_null_2_svc(); +#define NFSPROC_GETATTR 1 +extern attrstat * nfsproc_getattr_2(); +extern attrstat * nfsproc_getattr_2_svc(); +#define NFSPROC_SETATTR 2 +extern attrstat * nfsproc_setattr_2(); +extern attrstat * nfsproc_setattr_2_svc(); +#define NFSPROC_ROOT 3 +extern void * nfsproc_root_2(); +extern void * nfsproc_root_2_svc(); +#define NFSPROC_LOOKUP 4 +extern diropres * nfsproc_lookup_2(); +extern diropres * nfsproc_lookup_2_svc(); +#define NFSPROC_READLINK 5 +extern readlinkres * nfsproc_readlink_2(); +extern readlinkres * nfsproc_readlink_2_svc(); +#define NFSPROC_READ 6 +extern readres * nfsproc_read_2(); +extern readres * nfsproc_read_2_svc(); +#define NFSPROC_WRITECACHE 7 +extern void * nfsproc_writecache_2(); +extern void * nfsproc_writecache_2_svc(); +#define NFSPROC_WRITE 8 +extern attrstat * nfsproc_write_2(); +extern attrstat * nfsproc_write_2_svc(); +#define NFSPROC_CREATE 9 +extern diropres * nfsproc_create_2(); +extern diropres * nfsproc_create_2_svc(); +#define NFSPROC_REMOVE 10 +extern nfsstat * nfsproc_remove_2(); +extern nfsstat * nfsproc_remove_2_svc(); +#define NFSPROC_RENAME 11 +extern nfsstat * nfsproc_rename_2(); +extern nfsstat * nfsproc_rename_2_svc(); +#define NFSPROC_LINK 12 +extern nfsstat * nfsproc_link_2(); +extern nfsstat * nfsproc_link_2_svc(); +#define NFSPROC_SYMLINK 13 +extern nfsstat * nfsproc_symlink_2(); +extern nfsstat * nfsproc_symlink_2_svc(); +#define NFSPROC_MKDIR 14 +extern diropres * nfsproc_mkdir_2(); +extern diropres * nfsproc_mkdir_2_svc(); +#define NFSPROC_RMDIR 15 +extern nfsstat * nfsproc_rmdir_2(); +extern nfsstat * nfsproc_rmdir_2_svc(); +#define NFSPROC_READDIR 16 +extern readdirres * nfsproc_readdir_2(); +extern readdirres * nfsproc_readdir_2_svc(); +#define NFSPROC_STATFS 17 +extern statfsres * nfsproc_statfs_2(); +extern statfsres * nfsproc_statfs_2_svc(); +extern int nfs_program_2_freeresult(); +#endif /* K&R C */ + +#define NFS3_PROGRAM 100003 +#define NFS_V3 3 + +#if defined(__STDC__) || defined(__cplusplus) +#define NFSPROC3_NULL 0 +extern void * nfsproc3_null_3(void *, CLIENT *); +extern void * nfsproc3_null_3_svc(void *, struct svc_req *); +#define NFSPROC3_GETATTR 1 +extern GETATTR3res * nfsproc3_getattr_3(GETATTR3args *, CLIENT *); +extern GETATTR3res * nfsproc3_getattr_3_svc(GETATTR3args *, struct svc_req *); +#define NFSPROC3_SETATTR 2 +extern SETATTR3res * nfsproc3_setattr_3(SETATTR3args *, CLIENT *); +extern SETATTR3res * nfsproc3_setattr_3_svc(SETATTR3args *, struct svc_req *); +#define NFSPROC3_LOOKUP 3 +extern LOOKUP3res * nfsproc3_lookup_3(LOOKUP3args *, CLIENT *); +extern LOOKUP3res * nfsproc3_lookup_3_svc(LOOKUP3args *, struct svc_req *); +#define NFSPROC3_ACCESS 4 +extern ACCESS3res * nfsproc3_access_3(ACCESS3args *, CLIENT *); +extern ACCESS3res * nfsproc3_access_3_svc(ACCESS3args *, struct svc_req *); +#define NFSPROC3_READLINK 5 +extern READLINK3res * nfsproc3_readlink_3(READLINK3args *, CLIENT *); +extern READLINK3res * nfsproc3_readlink_3_svc(READLINK3args *, struct svc_req *); +#define NFSPROC3_READ 6 +extern READ3res * nfsproc3_read_3(READ3args *, CLIENT *); +extern READ3res * nfsproc3_read_3_svc(READ3args *, struct svc_req *); +#define NFSPROC3_WRITE 7 +extern WRITE3res * nfsproc3_write_3(WRITE3args *, CLIENT *); +extern WRITE3res * nfsproc3_write_3_svc(WRITE3args *, struct svc_req *); +#define NFSPROC3_CREATE 8 +extern CREATE3res * nfsproc3_create_3(CREATE3args *, CLIENT *); +extern CREATE3res * nfsproc3_create_3_svc(CREATE3args *, struct svc_req *); +#define NFSPROC3_MKDIR 9 +extern MKDIR3res * nfsproc3_mkdir_3(MKDIR3args *, CLIENT *); +extern MKDIR3res * nfsproc3_mkdir_3_svc(MKDIR3args *, struct svc_req *); +#define NFSPROC3_SYMLINK 10 +extern SYMLINK3res * nfsproc3_symlink_3(SYMLINK3args *, CLIENT *); +extern SYMLINK3res * nfsproc3_symlink_3_svc(SYMLINK3args *, struct svc_req *); +#define NFSPROC3_MKNOD 11 +extern MKNOD3res * nfsproc3_mknod_3(MKNOD3args *, CLIENT *); +extern MKNOD3res * nfsproc3_mknod_3_svc(MKNOD3args *, struct svc_req *); +#define NFSPROC3_REMOVE 12 +extern REMOVE3res * nfsproc3_remove_3(REMOVE3args *, CLIENT *); +extern REMOVE3res * nfsproc3_remove_3_svc(REMOVE3args *, struct svc_req *); +#define NFSPROC3_RMDIR 13 +extern RMDIR3res * nfsproc3_rmdir_3(RMDIR3args *, CLIENT *); +extern RMDIR3res * nfsproc3_rmdir_3_svc(RMDIR3args *, struct svc_req *); +#define NFSPROC3_RENAME 14 +extern RENAME3res * nfsproc3_rename_3(RENAME3args *, CLIENT *); +extern RENAME3res * nfsproc3_rename_3_svc(RENAME3args *, struct svc_req *); +#define NFSPROC3_LINK 15 +extern LINK3res * nfsproc3_link_3(LINK3args *, CLIENT *); +extern LINK3res * nfsproc3_link_3_svc(LINK3args *, struct svc_req *); +#define NFSPROC3_READDIR 16 +extern READDIR3res * nfsproc3_readdir_3(READDIR3args *, CLIENT *); +extern READDIR3res * nfsproc3_readdir_3_svc(READDIR3args *, struct svc_req *); +#define NFSPROC3_READDIRPLUS 17 +extern READDIRPLUS3res * nfsproc3_readdirplus_3(READDIRPLUS3args *, CLIENT *); +extern READDIRPLUS3res * nfsproc3_readdirplus_3_svc(READDIRPLUS3args *, struct svc_req *); +#define NFSPROC3_FSSTAT 18 +extern FSSTAT3res * nfsproc3_fsstat_3(FSSTAT3args *, CLIENT *); +extern FSSTAT3res * nfsproc3_fsstat_3_svc(FSSTAT3args *, struct svc_req *); +#define NFSPROC3_FSINFO 19 +extern FSINFO3res * nfsproc3_fsinfo_3(FSINFO3args *, CLIENT *); +extern FSINFO3res * nfsproc3_fsinfo_3_svc(FSINFO3args *, struct svc_req *); +#define NFSPROC3_PATHCONF 20 +extern PATHCONF3res * nfsproc3_pathconf_3(PATHCONF3args *, CLIENT *); +extern PATHCONF3res * nfsproc3_pathconf_3_svc(PATHCONF3args *, struct svc_req *); +#define NFSPROC3_COMMIT 21 +extern COMMIT3res * nfsproc3_commit_3(COMMIT3args *, CLIENT *); +extern COMMIT3res * nfsproc3_commit_3_svc(COMMIT3args *, struct svc_req *); +extern int nfs3_program_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define NFSPROC3_NULL 0 +extern void * nfsproc3_null_3(); +extern void * nfsproc3_null_3_svc(); +#define NFSPROC3_GETATTR 1 +extern GETATTR3res * nfsproc3_getattr_3(); +extern GETATTR3res * nfsproc3_getattr_3_svc(); +#define NFSPROC3_SETATTR 2 +extern SETATTR3res * nfsproc3_setattr_3(); +extern SETATTR3res * nfsproc3_setattr_3_svc(); +#define NFSPROC3_LOOKUP 3 +extern LOOKUP3res * nfsproc3_lookup_3(); +extern LOOKUP3res * nfsproc3_lookup_3_svc(); +#define NFSPROC3_ACCESS 4 +extern ACCESS3res * nfsproc3_access_3(); +extern ACCESS3res * nfsproc3_access_3_svc(); +#define NFSPROC3_READLINK 5 +extern READLINK3res * nfsproc3_readlink_3(); +extern READLINK3res * nfsproc3_readlink_3_svc(); +#define NFSPROC3_READ 6 +extern READ3res * nfsproc3_read_3(); +extern READ3res * nfsproc3_read_3_svc(); +#define NFSPROC3_WRITE 7 +extern WRITE3res * nfsproc3_write_3(); +extern WRITE3res * nfsproc3_write_3_svc(); +#define NFSPROC3_CREATE 8 +extern CREATE3res * nfsproc3_create_3(); +extern CREATE3res * nfsproc3_create_3_svc(); +#define NFSPROC3_MKDIR 9 +extern MKDIR3res * nfsproc3_mkdir_3(); +extern MKDIR3res * nfsproc3_mkdir_3_svc(); +#define NFSPROC3_SYMLINK 10 +extern SYMLINK3res * nfsproc3_symlink_3(); +extern SYMLINK3res * nfsproc3_symlink_3_svc(); +#define NFSPROC3_MKNOD 11 +extern MKNOD3res * nfsproc3_mknod_3(); +extern MKNOD3res * nfsproc3_mknod_3_svc(); +#define NFSPROC3_REMOVE 12 +extern REMOVE3res * nfsproc3_remove_3(); +extern REMOVE3res * nfsproc3_remove_3_svc(); +#define NFSPROC3_RMDIR 13 +extern RMDIR3res * nfsproc3_rmdir_3(); +extern RMDIR3res * nfsproc3_rmdir_3_svc(); +#define NFSPROC3_RENAME 14 +extern RENAME3res * nfsproc3_rename_3(); +extern RENAME3res * nfsproc3_rename_3_svc(); +#define NFSPROC3_LINK 15 +extern LINK3res * nfsproc3_link_3(); +extern LINK3res * nfsproc3_link_3_svc(); +#define NFSPROC3_READDIR 16 +extern READDIR3res * nfsproc3_readdir_3(); +extern READDIR3res * nfsproc3_readdir_3_svc(); +#define NFSPROC3_READDIRPLUS 17 +extern READDIRPLUS3res * nfsproc3_readdirplus_3(); +extern READDIRPLUS3res * nfsproc3_readdirplus_3_svc(); +#define NFSPROC3_FSSTAT 18 +extern FSSTAT3res * nfsproc3_fsstat_3(); +extern FSSTAT3res * nfsproc3_fsstat_3_svc(); +#define NFSPROC3_FSINFO 19 +extern FSINFO3res * nfsproc3_fsinfo_3(); +extern FSINFO3res * nfsproc3_fsinfo_3_svc(); +#define NFSPROC3_PATHCONF 20 +extern PATHCONF3res * nfsproc3_pathconf_3(); +extern PATHCONF3res * nfsproc3_pathconf_3_svc(); +#define NFSPROC3_COMMIT 21 +extern COMMIT3res * nfsproc3_commit_3(); +extern COMMIT3res * nfsproc3_commit_3_svc(); +extern int nfs3_program_3_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_nfsstat(XDR *, nfsstat*); +extern bool_t xdr_ftype(XDR *, ftype*); +extern bool_t xdr_nfs_fh(XDR *, nfs_fh*); +extern bool_t xdr_nfstime(XDR *, nfstime*); +extern bool_t xdr_fattr(XDR *, fattr*); +extern bool_t xdr_sattr(XDR *, sattr*); +extern bool_t xdr_filename(XDR *, filename*); +extern bool_t xdr_nfspath(XDR *, nfspath*); +extern bool_t xdr_attrstat(XDR *, attrstat*); +extern bool_t xdr_sattrargs(XDR *, sattrargs*); +extern bool_t xdr_diropargs(XDR *, diropargs*); +extern bool_t xdr_diropokres(XDR *, diropokres*); +extern bool_t xdr_diropres(XDR *, diropres*); +extern bool_t xdr_readlinkres(XDR *, readlinkres*); +extern bool_t xdr_readargs(XDR *, readargs*); +extern bool_t xdr_readokres(XDR *, readokres*); +extern bool_t xdr_readres(XDR *, readres*); +extern bool_t xdr_writeargs(XDR *, writeargs*); +extern bool_t xdr_createargs(XDR *, createargs*); +extern bool_t xdr_renameargs(XDR *, renameargs*); +extern bool_t xdr_linkargs(XDR *, linkargs*); +extern bool_t xdr_symlinkargs(XDR *, symlinkargs*); +extern bool_t xdr_nfscookie(XDR *, nfscookie); +extern bool_t xdr_readdirargs(XDR *, readdirargs*); +extern bool_t xdr_entry(XDR *, entry*); +extern bool_t xdr_dirlist(XDR *, dirlist*); +extern bool_t xdr_readdirres(XDR *, readdirres*); +extern bool_t xdr_statfsokres(XDR *, statfsokres*); +extern bool_t xdr_statfsres(XDR *, statfsres*); +extern bool_t xdr_filename3(XDR *, filename3*); +extern bool_t xdr_nfspath3(XDR *, nfspath3*); +extern bool_t xdr_fileid3(XDR *, fileid3*); +extern bool_t xdr_cookie3(XDR *, cookie3*); +extern bool_t xdr_cookieverf3(XDR *, cookieverf3); +extern bool_t xdr_createverf3(XDR *, createverf3); +extern bool_t xdr_writeverf3(XDR *, writeverf3); +extern bool_t xdr_uid3(XDR *, uid3*); +extern bool_t xdr_gid3(XDR *, gid3*); +extern bool_t xdr_size3(XDR *, size3*); +extern bool_t xdr_offset3(XDR *, offset3*); +extern bool_t xdr_mode3(XDR *, mode3*); +extern bool_t xdr_count3(XDR *, count3*); +extern bool_t xdr_nfsstat3(XDR *, nfsstat3*); +extern bool_t xdr_ftype3(XDR *, ftype3*); +extern bool_t xdr_specdata3(XDR *, specdata3*); +extern bool_t xdr_nfs_fh3(XDR *, nfs_fh3*); +extern bool_t xdr_nfstime3(XDR *, nfstime3*); +extern bool_t xdr_fattr3(XDR *, fattr3*); +extern bool_t xdr_post_op_attr(XDR *, post_op_attr*); +extern bool_t xdr_wcc_attr(XDR *, wcc_attr*); +extern bool_t xdr_pre_op_attr(XDR *, pre_op_attr*); +extern bool_t xdr_wcc_data(XDR *, wcc_data*); +extern bool_t xdr_post_op_fh3(XDR *, post_op_fh3*); +extern bool_t xdr_time_how(XDR *, time_how*); +extern bool_t xdr_set_mode3(XDR *, set_mode3*); +extern bool_t xdr_set_uid3(XDR *, set_uid3*); +extern bool_t xdr_set_gid3(XDR *, set_gid3*); +extern bool_t xdr_set_size3(XDR *, set_size3*); +extern bool_t xdr_set_atime(XDR *, set_atime*); +extern bool_t xdr_set_mtime(XDR *, set_mtime*); +extern bool_t xdr_sattr3(XDR *, sattr3*); +extern bool_t xdr_diropargs3(XDR *, diropargs3*); +extern bool_t xdr_GETATTR3args(XDR *, GETATTR3args*); +extern bool_t xdr_GETATTR3resok(XDR *, GETATTR3resok*); +extern bool_t xdr_GETATTR3res(XDR *, GETATTR3res*); +extern bool_t xdr_sattrguard3(XDR *, sattrguard3*); +extern bool_t xdr_SETATTR3args(XDR *, SETATTR3args*); +extern bool_t xdr_SETATTR3resok(XDR *, SETATTR3resok*); +extern bool_t xdr_SETATTR3resfail(XDR *, SETATTR3resfail*); +extern bool_t xdr_SETATTR3res(XDR *, SETATTR3res*); +extern bool_t xdr_LOOKUP3args(XDR *, LOOKUP3args*); +extern bool_t xdr_LOOKUP3resok(XDR *, LOOKUP3resok*); +extern bool_t xdr_LOOKUP3resfail(XDR *, LOOKUP3resfail*); +extern bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res*); +extern bool_t xdr_ACCESS3args(XDR *, ACCESS3args*); +extern bool_t xdr_ACCESS3resok(XDR *, ACCESS3resok*); +extern bool_t xdr_ACCESS3resfail(XDR *, ACCESS3resfail*); +extern bool_t xdr_ACCESS3res(XDR *, ACCESS3res*); +extern bool_t xdr_READLINK3args(XDR *, READLINK3args*); +extern bool_t xdr_READLINK3resok(XDR *, READLINK3resok*); +extern bool_t xdr_READLINK3resfail(XDR *, READLINK3resfail*); +extern bool_t xdr_READLINK3res(XDR *, READLINK3res*); +extern bool_t xdr_READ3args(XDR *, READ3args*); +extern bool_t xdr_READ3resok(XDR *, READ3resok*); +extern bool_t xdr_READ3resfail(XDR *, READ3resfail*); +extern bool_t xdr_READ3res(XDR *, READ3res*); +extern bool_t xdr_stable_how(XDR *, stable_how*); +extern bool_t xdr_WRITE3args(XDR *, WRITE3args*); +extern bool_t xdr_WRITE3resok(XDR *, WRITE3resok*); +extern bool_t xdr_WRITE3resfail(XDR *, WRITE3resfail*); +extern bool_t xdr_WRITE3res(XDR *, WRITE3res*); +extern bool_t xdr_createmode3(XDR *, createmode3*); +extern bool_t xdr_createhow3(XDR *, createhow3*); +extern bool_t xdr_CREATE3args(XDR *, CREATE3args*); +extern bool_t xdr_CREATE3resok(XDR *, CREATE3resok*); +extern bool_t xdr_CREATE3resfail(XDR *, CREATE3resfail*); +extern bool_t xdr_CREATE3res(XDR *, CREATE3res*); +extern bool_t xdr_MKDIR3args(XDR *, MKDIR3args*); +extern bool_t xdr_MKDIR3resok(XDR *, MKDIR3resok*); +extern bool_t xdr_MKDIR3resfail(XDR *, MKDIR3resfail*); +extern bool_t xdr_MKDIR3res(XDR *, MKDIR3res*); +extern bool_t xdr_symlinkdata3(XDR *, symlinkdata3*); +extern bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args*); +extern bool_t xdr_SYMLINK3resok(XDR *, SYMLINK3resok*); +extern bool_t xdr_SYMLINK3resfail(XDR *, SYMLINK3resfail*); +extern bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res*); +extern bool_t xdr_devicedata3(XDR *, devicedata3*); +extern bool_t xdr_mknoddata3(XDR *, mknoddata3*); +extern bool_t xdr_MKNOD3args(XDR *, MKNOD3args*); +extern bool_t xdr_MKNOD3resok(XDR *, MKNOD3resok*); +extern bool_t xdr_MKNOD3resfail(XDR *, MKNOD3resfail*); +extern bool_t xdr_MKNOD3res(XDR *, MKNOD3res*); +extern bool_t xdr_REMOVE3args(XDR *, REMOVE3args*); +extern bool_t xdr_REMOVE3resok(XDR *, REMOVE3resok*); +extern bool_t xdr_REMOVE3resfail(XDR *, REMOVE3resfail*); +extern bool_t xdr_REMOVE3res(XDR *, REMOVE3res*); +extern bool_t xdr_RMDIR3args(XDR *, RMDIR3args*); +extern bool_t xdr_RMDIR3resok(XDR *, RMDIR3resok*); +extern bool_t xdr_RMDIR3resfail(XDR *, RMDIR3resfail*); +extern bool_t xdr_RMDIR3res(XDR *, RMDIR3res*); +extern bool_t xdr_RENAME3args(XDR *, RENAME3args*); +extern bool_t xdr_RENAME3resok(XDR *, RENAME3resok*); +extern bool_t xdr_RENAME3resfail(XDR *, RENAME3resfail*); +extern bool_t xdr_RENAME3res(XDR *, RENAME3res*); +extern bool_t xdr_LINK3args(XDR *, LINK3args*); +extern bool_t xdr_LINK3resok(XDR *, LINK3resok*); +extern bool_t xdr_LINK3resfail(XDR *, LINK3resfail*); +extern bool_t xdr_LINK3res(XDR *, LINK3res*); +extern bool_t xdr_READDIR3args(XDR *, READDIR3args*); +extern bool_t xdr_entry3(XDR *, entry3*); +extern bool_t xdr_dirlist3(XDR *, dirlist3*); +extern bool_t xdr_READDIR3resok(XDR *, READDIR3resok*); +extern bool_t xdr_READDIR3resfail(XDR *, READDIR3resfail*); +extern bool_t xdr_READDIR3res(XDR *, READDIR3res*); +extern bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args*); +extern bool_t xdr_entryplus3(XDR *, entryplus3*); +extern bool_t xdr_dirlistplus3(XDR *, dirlistplus3*); +extern bool_t xdr_READDIRPLUS3resok(XDR *, READDIRPLUS3resok*); +extern bool_t xdr_READDIRPLUS3resfail(XDR *, READDIRPLUS3resfail*); +extern bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res*); +extern bool_t xdr_FSSTAT3args(XDR *, FSSTAT3args*); +extern bool_t xdr_FSSTAT3resok(XDR *, FSSTAT3resok*); +extern bool_t xdr_FSSTAT3resfail(XDR *, FSSTAT3resfail*); +extern bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res*); +extern bool_t xdr_FSINFO3args(XDR *, FSINFO3args*); +extern bool_t xdr_FSINFO3resok(XDR *, FSINFO3resok*); +extern bool_t xdr_FSINFO3resfail(XDR *, FSINFO3resfail*); +extern bool_t xdr_FSINFO3res(XDR *, FSINFO3res*); +extern bool_t xdr_PATHCONF3args(XDR *, PATHCONF3args*); +extern bool_t xdr_PATHCONF3resok(XDR *, PATHCONF3resok*); +extern bool_t xdr_PATHCONF3resfail(XDR *, PATHCONF3resfail*); +extern bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res*); +extern bool_t xdr_COMMIT3args(XDR *, COMMIT3args*); +extern bool_t xdr_COMMIT3resok(XDR *, COMMIT3resok*); +extern bool_t xdr_COMMIT3resfail(XDR *, COMMIT3resfail*); +extern bool_t xdr_COMMIT3res(XDR *, COMMIT3res*); + +#else /* K&R C */ +extern bool_t xdr_nfsstat(); +extern bool_t xdr_ftype(); +extern bool_t xdr_nfs_fh(); +extern bool_t xdr_nfstime(); +extern bool_t xdr_fattr(); +extern bool_t xdr_sattr(); +extern bool_t xdr_filename(); +extern bool_t xdr_nfspath(); +extern bool_t xdr_attrstat(); +extern bool_t xdr_sattrargs(); +extern bool_t xdr_diropargs(); +extern bool_t xdr_diropokres(); +extern bool_t xdr_diropres(); +extern bool_t xdr_readlinkres(); +extern bool_t xdr_readargs(); +extern bool_t xdr_readokres(); +extern bool_t xdr_readres(); +extern bool_t xdr_writeargs(); +extern bool_t xdr_createargs(); +extern bool_t xdr_renameargs(); +extern bool_t xdr_linkargs(); +extern bool_t xdr_symlinkargs(); +extern bool_t xdr_nfscookie(); +extern bool_t xdr_readdirargs(); +extern bool_t xdr_entry(); +extern bool_t xdr_dirlist(); +extern bool_t xdr_readdirres(); +extern bool_t xdr_statfsokres(); +extern bool_t xdr_statfsres(); +extern bool_t xdr_filename3(); +extern bool_t xdr_nfspath3(); +extern bool_t xdr_fileid3(); +extern bool_t xdr_cookie3(); +extern bool_t xdr_cookieverf3(); +extern bool_t xdr_createverf3(); +extern bool_t xdr_writeverf3(); +extern bool_t xdr_uid3(); +extern bool_t xdr_gid3(); +extern bool_t xdr_size3(); +extern bool_t xdr_offset3(); +extern bool_t xdr_mode3(); +extern bool_t xdr_count3(); +extern bool_t xdr_nfsstat3(); +extern bool_t xdr_ftype3(); +extern bool_t xdr_specdata3(); +extern bool_t xdr_nfs_fh3(); +extern bool_t xdr_nfstime3(); +extern bool_t xdr_fattr3(); +extern bool_t xdr_post_op_attr(); +extern bool_t xdr_wcc_attr(); +extern bool_t xdr_pre_op_attr(); +extern bool_t xdr_wcc_data(); +extern bool_t xdr_post_op_fh3(); +extern bool_t xdr_time_how(); +extern bool_t xdr_set_mode3(); +extern bool_t xdr_set_uid3(); +extern bool_t xdr_set_gid3(); +extern bool_t xdr_set_size3(); +extern bool_t xdr_set_atime(); +extern bool_t xdr_set_mtime(); +extern bool_t xdr_sattr3(); +extern bool_t xdr_diropargs3(); +extern bool_t xdr_GETATTR3args(); +extern bool_t xdr_GETATTR3resok(); +extern bool_t xdr_GETATTR3res(); +extern bool_t xdr_sattrguard3(); +extern bool_t xdr_SETATTR3args(); +extern bool_t xdr_SETATTR3resok(); +extern bool_t xdr_SETATTR3resfail(); +extern bool_t xdr_SETATTR3res(); +extern bool_t xdr_LOOKUP3args(); +extern bool_t xdr_LOOKUP3resok(); +extern bool_t xdr_LOOKUP3resfail(); +extern bool_t xdr_LOOKUP3res(); +extern bool_t xdr_ACCESS3args(); +extern bool_t xdr_ACCESS3resok(); +extern bool_t xdr_ACCESS3resfail(); +extern bool_t xdr_ACCESS3res(); +extern bool_t xdr_READLINK3args(); +extern bool_t xdr_READLINK3resok(); +extern bool_t xdr_READLINK3resfail(); +extern bool_t xdr_READLINK3res(); +extern bool_t xdr_READ3args(); +extern bool_t xdr_READ3resok(); +extern bool_t xdr_READ3resfail(); +extern bool_t xdr_READ3res(); +extern bool_t xdr_stable_how(); +extern bool_t xdr_WRITE3args(); +extern bool_t xdr_WRITE3resok(); +extern bool_t xdr_WRITE3resfail(); +extern bool_t xdr_WRITE3res(); +extern bool_t xdr_createmode3(); +extern bool_t xdr_createhow3(); +extern bool_t xdr_CREATE3args(); +extern bool_t xdr_CREATE3resok(); +extern bool_t xdr_CREATE3resfail(); +extern bool_t xdr_CREATE3res(); +extern bool_t xdr_MKDIR3args(); +extern bool_t xdr_MKDIR3resok(); +extern bool_t xdr_MKDIR3resfail(); +extern bool_t xdr_MKDIR3res(); +extern bool_t xdr_symlinkdata3(); +extern bool_t xdr_SYMLINK3args(); +extern bool_t xdr_SYMLINK3resok(); +extern bool_t xdr_SYMLINK3resfail(); +extern bool_t xdr_SYMLINK3res(); +extern bool_t xdr_devicedata3(); +extern bool_t xdr_mknoddata3(); +extern bool_t xdr_MKNOD3args(); +extern bool_t xdr_MKNOD3resok(); +extern bool_t xdr_MKNOD3resfail(); +extern bool_t xdr_MKNOD3res(); +extern bool_t xdr_REMOVE3args(); +extern bool_t xdr_REMOVE3resok(); +extern bool_t xdr_REMOVE3resfail(); +extern bool_t xdr_REMOVE3res(); +extern bool_t xdr_RMDIR3args(); +extern bool_t xdr_RMDIR3resok(); +extern bool_t xdr_RMDIR3resfail(); +extern bool_t xdr_RMDIR3res(); +extern bool_t xdr_RENAME3args(); +extern bool_t xdr_RENAME3resok(); +extern bool_t xdr_RENAME3resfail(); +extern bool_t xdr_RENAME3res(); +extern bool_t xdr_LINK3args(); +extern bool_t xdr_LINK3resok(); +extern bool_t xdr_LINK3resfail(); +extern bool_t xdr_LINK3res(); +extern bool_t xdr_READDIR3args(); +extern bool_t xdr_entry3(); +extern bool_t xdr_dirlist3(); +extern bool_t xdr_READDIR3resok(); +extern bool_t xdr_READDIR3resfail(); +extern bool_t xdr_READDIR3res(); +extern bool_t xdr_READDIRPLUS3args(); +extern bool_t xdr_entryplus3(); +extern bool_t xdr_dirlistplus3(); +extern bool_t xdr_READDIRPLUS3resok(); +extern bool_t xdr_READDIRPLUS3resfail(); +extern bool_t xdr_READDIRPLUS3res(); +extern bool_t xdr_FSSTAT3args(); +extern bool_t xdr_FSSTAT3resok(); +extern bool_t xdr_FSSTAT3resfail(); +extern bool_t xdr_FSSTAT3res(); +extern bool_t xdr_FSINFO3args(); +extern bool_t xdr_FSINFO3resok(); +extern bool_t xdr_FSINFO3resfail(); +extern bool_t xdr_FSINFO3res(); +extern bool_t xdr_PATHCONF3args(); +extern bool_t xdr_PATHCONF3resok(); +extern bool_t xdr_PATHCONF3resfail(); +extern bool_t xdr_PATHCONF3res(); +extern bool_t xdr_COMMIT3args(); +extern bool_t xdr_COMMIT3resok(); +extern bool_t xdr_COMMIT3resfail(); +extern bool_t xdr_COMMIT3res(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_NFS_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/nfs_prot.x b/illumos-x86_64/usr/include/rpcsvc/nfs_prot.x new file mode 100644 index 00000000..6709f1cd --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nfs_prot.x @@ -0,0 +1,1262 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifdef RPC_HDR +%/* +% * Definitions for uint64, int64, uint32, and int32 +% */ +%#include +% +#endif + +const NFS_PORT = 2049; +const NFS_MAXDATA = 8192; +const NFS_MAXPATHLEN = 1024; +const NFS_MAXNAMLEN = 255; +const NFS_FHSIZE = 32; +const NFS_COOKIESIZE = 4; +const NFS_FIFO_DEV = -1; /* size kludge for named pipes */ + +/* + * File types + */ +const NFSMODE_FMT = 0170000; /* type of file */ +const NFSMODE_DIR = 0040000; /* directory */ +const NFSMODE_CHR = 0020000; /* character special */ +const NFSMODE_BLK = 0060000; /* block special */ +const NFSMODE_REG = 0100000; /* regular */ +const NFSMODE_LNK = 0120000; /* symbolic link */ +const NFSMODE_SOCK = 0140000; /* socket */ +const NFSMODE_FIFO = 0010000; /* fifo */ + +/* + * Error status + */ +enum nfsstat { + NFS_OK= 0, /* no error */ + NFSERR_PERM=1, /* Not owner */ + NFSERR_NOENT=2, /* No such file or directory */ + NFSERR_IO=5, /* I/O error */ + NFSERR_NXIO=6, /* No such device or address */ + NFSERR_ACCES=13, /* Permission denied */ + NFSERR_EXIST=17, /* File exists */ + NFSERR_XDEV=18, /* Cross-device link */ + NFSERR_NODEV=19, /* No such device */ + NFSERR_NOTDIR=20, /* Not a directory*/ + NFSERR_ISDIR=21, /* Is a directory */ + NFSERR_INVAL=22, /* Invalid argument */ + NFSERR_FBIG=27, /* File too large */ + NFSERR_NOSPC=28, /* No space left on device */ + NFSERR_ROFS=30, /* Read-only file system */ + NFSERR_OPNOTSUPP=45, /* Operation not supported */ + NFSERR_NAMETOOLONG=63, /* File name too long */ + NFSERR_NOTEMPTY=66, /* Directory not empty */ + NFSERR_DQUOT=69, /* Disc quota exceeded */ + NFSERR_STALE=70, /* Stale NFS file handle */ + NFSERR_REMOTE=71, /* Object is remote */ + NFSERR_WFLUSH=72 /* write cache flushed */ +}; + +/* + * File types + */ +enum ftype { + NFNON = 0, /* non-file */ + NFREG = 1, /* regular file */ + NFDIR = 2, /* directory */ + NFBLK = 3, /* block special */ + NFCHR = 4, /* character special */ + NFLNK = 5, /* symbolic link */ + NFSOCK = 6, /* unix domain sockets */ + NFBAD = 7, /* unused */ + NFFIFO = 8 /* named pipe */ +}; + +/* + * File access handle + */ +struct nfs_fh { + opaque data[NFS_FHSIZE]; +}; + +/* + * Timeval + */ +struct nfstime { + unsigned seconds; + unsigned useconds; +}; + + +/* + * File attributes + */ +struct fattr { + ftype type; /* file type */ + unsigned mode; /* protection mode bits */ + unsigned nlink; /* # hard links */ + unsigned uid; /* owner user id */ + unsigned gid; /* owner group id */ + unsigned size; /* file size in bytes */ + unsigned blocksize; /* prefered block size */ + unsigned rdev; /* special device # */ + unsigned blocks; /* Kb of disk used by file */ + unsigned fsid; /* device # */ + unsigned fileid; /* inode # */ + nfstime atime; /* time of last access */ + nfstime mtime; /* time of last modification */ + nfstime ctime; /* time of last change */ +}; + +/* + * File attributes which can be set + */ +struct sattr { + unsigned mode; /* protection mode bits */ + unsigned uid; /* owner user id */ + unsigned gid; /* owner group id */ + unsigned size; /* file size in bytes */ + nfstime atime; /* time of last access */ + nfstime mtime; /* time of last modification */ +}; + + +typedef string filename; +typedef string nfspath; + +/* + * Reply status with file attributes + */ +union attrstat switch (nfsstat status) { +case NFS_OK: + fattr attributes; +default: + void; +}; + +struct sattrargs { + nfs_fh file; + sattr attributes; +}; + +/* + * Arguments for directory operations + */ +struct diropargs { + nfs_fh dir; /* directory file handle */ + filename name; /* name (up to NFS_MAXNAMLEN bytes) */ +}; + +struct diropokres { + nfs_fh file; + fattr attributes; +}; + +/* + * Results from directory operation + */ +union diropres switch (nfsstat status) { +case NFS_OK: + diropokres diropres; +default: + void; +}; + +union readlinkres switch (nfsstat status) { +case NFS_OK: + nfspath data; +default: + void; +}; + +/* + * Arguments to remote read + */ +struct readargs { + nfs_fh file; /* handle for file */ + unsigned offset; /* byte offset in file */ + unsigned count; /* immediate read count */ + unsigned totalcount; /* total read count (from this offset)*/ +}; + +/* + * Status OK portion of remote read reply + */ +struct readokres { + fattr attributes; /* attributes, need for pagin*/ + opaque data; +}; + +union readres switch (nfsstat status) { +case NFS_OK: + readokres reply; +default: + void; +}; + +/* + * Arguments to remote write + */ +struct writeargs { + nfs_fh file; /* handle for file */ + unsigned beginoffset; /* beginning byte offset in file */ + unsigned offset; /* current byte offset in file */ + unsigned totalcount; /* total write count (to this offset)*/ + opaque data; +}; + +struct createargs { + diropargs where; + sattr attributes; +}; + +struct renameargs { + diropargs from; + diropargs to; +}; + +struct linkargs { + nfs_fh from; + diropargs to; +}; + +struct symlinkargs { + diropargs from; + nfspath to; + sattr attributes; +}; + + +typedef opaque nfscookie[NFS_COOKIESIZE]; + +/* + * Arguments to readdir + */ +struct readdirargs { + nfs_fh dir; /* directory handle */ + nfscookie cookie; + unsigned count; /* number of directory bytes to read */ +}; + +struct entry { + unsigned fileid; + filename name; + nfscookie cookie; + entry *nextentry; +}; + +struct dirlist { + entry *entries; + bool eof; +}; + +union readdirres switch (nfsstat status) { +case NFS_OK: + dirlist reply; +default: + void; +}; + +struct statfsokres { + unsigned tsize; /* preferred transfer size in bytes */ + unsigned bsize; /* fundamental file system block size */ + unsigned blocks; /* total blocks in file system */ + unsigned bfree; /* free blocks in fs */ + unsigned bavail; /* free blocks avail to non-superuser */ +}; + +union statfsres switch (nfsstat status) { +case NFS_OK: + statfsokres reply; +default: + void; +}; + +/* + * Remote file service routines + */ +program NFS_PROGRAM { + version NFS_VERSION { + void + NFSPROC_NULL(void) = 0; + + attrstat + NFSPROC_GETATTR(nfs_fh) = 1; + + attrstat + NFSPROC_SETATTR(sattrargs) = 2; + + void + NFSPROC_ROOT(void) = 3; + + diropres + NFSPROC_LOOKUP(diropargs) = 4; + + readlinkres + NFSPROC_READLINK(nfs_fh) = 5; + + readres + NFSPROC_READ(readargs) = 6; + + void + NFSPROC_WRITECACHE(void) = 7; + + attrstat + NFSPROC_WRITE(writeargs) = 8; + + diropres + NFSPROC_CREATE(createargs) = 9; + + nfsstat + NFSPROC_REMOVE(diropargs) = 10; + + nfsstat + NFSPROC_RENAME(renameargs) = 11; + + nfsstat + NFSPROC_LINK(linkargs) = 12; + + nfsstat + NFSPROC_SYMLINK(symlinkargs) = 13; + + diropres + NFSPROC_MKDIR(createargs) = 14; + + nfsstat + NFSPROC_RMDIR(diropargs) = 15; + + readdirres + NFSPROC_READDIR(readdirargs) = 16; + + statfsres + NFSPROC_STATFS(nfs_fh) = 17; + } = 2; +} = 100003; + +/* + * Version 3 declarations and definitions. + */ + +/* + * Sizes + */ +const NFS3_FHSIZE = 64; +const NFS3_COOKIEVERFSIZE = 8; +const NFS3_CREATEVERFSIZE = 8; +const NFS3_WRITEVERFSIZE = 8; + +/* + * Basic data types + */ +typedef string filename3<>; +typedef string nfspath3<>; +typedef uint64 fileid3; +typedef uint64 cookie3; +typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE]; +typedef opaque createverf3[NFS3_CREATEVERFSIZE]; +typedef opaque writeverf3[NFS3_WRITEVERFSIZE]; +typedef uint32 uid3; +typedef uint32 gid3; +typedef uint64 size3; +typedef uint64 offset3; +typedef uint32 mode3; +typedef uint32 count3; + +/* + * Error status + */ +enum nfsstat3 { + NFS3_OK = 0, + NFS3ERR_PERM = 1, + NFS3ERR_NOENT = 2, + NFS3ERR_IO = 5, + NFS3ERR_NXIO = 6, + NFS3ERR_ACCES = 13, + NFS3ERR_EXIST = 17, + NFS3ERR_XDEV = 18, + NFS3ERR_NODEV = 19, + NFS3ERR_NOTDIR = 20, + NFS3ERR_ISDIR = 21, + NFS3ERR_INVAL = 22, + NFS3ERR_FBIG = 27, + NFS3ERR_NOSPC = 28, + NFS3ERR_ROFS = 30, + NFS3ERR_MLINK = 31, + NFS3ERR_NAMETOOLONG = 63, + NFS3ERR_NOTEMPTY = 66, + NFS3ERR_DQUOT = 69, + NFS3ERR_STALE = 70, + NFS3ERR_REMOTE = 71, + NFS3ERR_BADHANDLE = 10001, + NFS3ERR_NOT_SYNC = 10002, + NFS3ERR_BAD_COOKIE = 10003, + NFS3ERR_NOTSUPP = 10004, + NFS3ERR_TOOSMALL = 10005, + NFS3ERR_SERVERFAULT = 10006, + NFS3ERR_BADTYPE = 10007, + NFS3ERR_JUKEBOX = 10008 +}; + +/* + * File types + */ +enum ftype3 { + NF3REG = 1, + NF3DIR = 2, + NF3BLK = 3, + NF3CHR = 4, + NF3LNK = 5, + NF3SOCK = 6, + NF3FIFO = 7 +}; + +struct specdata3 { + uint32 specdata1; + uint32 specdata2; +}; + +/* + * File access handle + */ +struct nfs_fh3 { + opaque data; +}; + +/* + * Timeval + */ +struct nfstime3 { + uint32 seconds; + uint32 nseconds; +}; + +/* + * File attributes + */ +struct fattr3 { + ftype3 type; + mode3 mode; + uint32 nlink; + uid3 uid; + gid3 gid; + size3 size; + size3 used; + specdata3 rdev; + uint64 fsid; + fileid3 fileid; + nfstime3 atime; + nfstime3 mtime; + nfstime3 ctime; +}; + +/* + * File attributes + */ +union post_op_attr switch (bool attributes_follow) { +case TRUE: + fattr3 attributes; +case FALSE: + void; +}; + +struct wcc_attr { + size3 size; + nfstime3 mtime; + nfstime3 ctime; +}; + +union pre_op_attr switch (bool attributes_follow) { +case TRUE: + wcc_attr attributes; +case FALSE: + void; +}; + +struct wcc_data { + pre_op_attr before; + post_op_attr after; +}; + +union post_op_fh3 switch (bool handle_follows) { +case TRUE: + nfs_fh3 handle; +case FALSE: + void; +}; + +enum time_how { + DONT_CHANGE = 0, + SET_TO_SERVER_TIME = 1, + SET_TO_CLIENT_TIME = 2 +}; + +union set_mode3 switch (bool set_it) { +case TRUE: + mode3 mode; +default: + void; +}; + +union set_uid3 switch (bool set_it) { +case TRUE: + uid3 uid; +default: + void; +}; + +union set_gid3 switch (bool set_it) { +case TRUE: + gid3 gid; +default: + void; +}; + +union set_size3 switch (bool set_it) { +case TRUE: + size3 size; +default: + void; +}; + +union set_atime switch (time_how set_it) { +case SET_TO_CLIENT_TIME: + nfstime3 atime; +default: + void; +}; + +union set_mtime switch (time_how set_it) { +case SET_TO_CLIENT_TIME: + nfstime3 mtime; +default: + void; +}; + +struct sattr3 { + set_mode3 mode; + set_uid3 uid; + set_gid3 gid; + set_size3 size; + set_atime atime; + set_mtime mtime; +}; + +struct diropargs3 { + nfs_fh3 dir; + filename3 name; +}; + +/* + * GETATTR: Get file attributes + */ +struct GETATTR3args { + nfs_fh3 object; +}; + +struct GETATTR3resok { + fattr3 obj_attributes; +}; + +union GETATTR3res switch (nfsstat3 status) { +case NFS3_OK: + GETATTR3resok resok; +default: + void; +}; + +/* + * SETATTR: Set file attributes + */ +union sattrguard3 switch (bool check) { +case TRUE: + nfstime3 obj_ctime; +case FALSE: + void; +}; + +struct SETATTR3args { + nfs_fh3 object; + sattr3 new_attributes; + sattrguard3 guard; +}; + +struct SETATTR3resok { + wcc_data obj_wcc; +}; + +struct SETATTR3resfail { + wcc_data obj_wcc; +}; + +union SETATTR3res switch (nfsstat3 status) { +case NFS3_OK: + SETATTR3resok resok; +default: + SETATTR3resfail resfail; +}; + +/* + * LOOKUP: Lookup filename + */ +struct LOOKUP3args { + diropargs3 what; +}; + +struct LOOKUP3resok { + nfs_fh3 object; + post_op_attr obj_attributes; + post_op_attr dir_attributes; +}; + +struct LOOKUP3resfail { + post_op_attr dir_attributes; +}; + +union LOOKUP3res switch (nfsstat3 status) { +case NFS3_OK: + LOOKUP3resok resok; +default: + LOOKUP3resfail resfail; +}; + +/* + * ACCESS: Check access permission + */ +const ACCESS3_READ = 0x0001; +const ACCESS3_LOOKUP = 0x0002; +const ACCESS3_MODIFY = 0x0004; +const ACCESS3_EXTEND = 0x0008; +const ACCESS3_DELETE = 0x0010; +const ACCESS3_EXECUTE = 0x0020; + +struct ACCESS3args { + nfs_fh3 object; + uint32 access; +}; + +struct ACCESS3resok { + post_op_attr obj_attributes; + uint32 access; +}; + +struct ACCESS3resfail { + post_op_attr obj_attributes; +}; + +union ACCESS3res switch (nfsstat3 status) { +case NFS3_OK: + ACCESS3resok resok; +default: + ACCESS3resfail resfail; +}; + +/* + * READLINK: Read from symbolic link + */ +struct READLINK3args { + nfs_fh3 symlink; +}; + +struct READLINK3resok { + post_op_attr symlink_attributes; + nfspath3 data; +}; + +struct READLINK3resfail { + post_op_attr symlink_attributes; +}; + +union READLINK3res switch (nfsstat3 status) { +case NFS3_OK: + READLINK3resok resok; +default: + READLINK3resfail resfail; +}; + +/* + * READ: Read from file + */ +struct READ3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; + +struct READ3resok { + post_op_attr file_attributes; + count3 count; + bool eof; + opaque data<>; +}; + +struct READ3resfail { + post_op_attr file_attributes; +}; + +union READ3res switch (nfsstat3 status) { +case NFS3_OK: + READ3resok resok; +default: + READ3resfail resfail; +}; + +/* + * WRITE: Write to file + */ +enum stable_how { + UNSTABLE = 0, + DATA_SYNC = 1, + FILE_SYNC = 2 +}; + +struct WRITE3args { + nfs_fh3 file; + offset3 offset; + count3 count; + stable_how stable; + opaque data<>; +}; + +struct WRITE3resok { + wcc_data file_wcc; + count3 count; + stable_how committed; + writeverf3 verf; +}; + +struct WRITE3resfail { + wcc_data file_wcc; +}; + +union WRITE3res switch (nfsstat3 status) { +case NFS3_OK: + WRITE3resok resok; +default: + WRITE3resfail resfail; +}; + +/* + * CREATE: Create a file + */ +enum createmode3 { + UNCHECKED = 0, + GUARDED = 1, + EXCLUSIVE = 2 +}; + +union createhow3 switch (createmode3 mode) { +case UNCHECKED: +case GUARDED: + sattr3 obj_attributes; +case EXCLUSIVE: + createverf3 verf; +}; + +struct CREATE3args { + diropargs3 where; + createhow3 how; +}; + +struct CREATE3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; + +struct CREATE3resfail { + wcc_data dir_wcc; +}; + +union CREATE3res switch (nfsstat3 status) { +case NFS3_OK: + CREATE3resok resok; +default: + CREATE3resfail resfail; +}; + +/* + * MKDIR: Create a directory + */ +struct MKDIR3args { + diropargs3 where; + sattr3 attributes; +}; + +struct MKDIR3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; + +struct MKDIR3resfail { + wcc_data dir_wcc; +}; + +union MKDIR3res switch (nfsstat3 status) { +case NFS3_OK: + MKDIR3resok resok; +default: + MKDIR3resfail resfail; +}; + +/* + * SYMLINK: Create a symbolic link + */ +struct symlinkdata3 { + sattr3 symlink_attributes; + nfspath3 symlink_data; +}; + +struct SYMLINK3args { + diropargs3 where; + symlinkdata3 symlink; +}; + +struct SYMLINK3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; + +struct SYMLINK3resfail { + wcc_data dir_wcc; +}; + +union SYMLINK3res switch (nfsstat3 status) { +case NFS3_OK: + SYMLINK3resok resok; +default: + SYMLINK3resfail resfail; +}; + +/* + * MKNOD: Create a special file + */ +struct devicedata3 { + sattr3 dev_attributes; + specdata3 spec; +}; + +union mknoddata3 switch (ftype3 type) { +case NF3CHR: +case NF3BLK: + devicedata3 device; +case NF3SOCK: +case NF3FIFO: + sattr3 pipe_attributes; +default: + void; +}; + +struct MKNOD3args { + diropargs3 where; + mknoddata3 what; +}; + +struct MKNOD3resok { + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; +}; + +struct MKNOD3resfail { + wcc_data dir_wcc; +}; + +union MKNOD3res switch (nfsstat3 status) { +case NFS3_OK: + MKNOD3resok resok; +default: + MKNOD3resfail resfail; +}; + +/* + * REMOVE: Remove a file + */ +struct REMOVE3args { + diropargs3 object; +}; + +struct REMOVE3resok { + wcc_data dir_wcc; +}; + +struct REMOVE3resfail { + wcc_data dir_wcc; +}; + +union REMOVE3res switch (nfsstat3 status) { +case NFS3_OK: + REMOVE3resok resok; +default: + REMOVE3resfail resfail; +}; + +/* + * RMDIR: Remove a directory + */ +struct RMDIR3args { + diropargs3 object; +}; + +struct RMDIR3resok { + wcc_data dir_wcc; +}; + +struct RMDIR3resfail { + wcc_data dir_wcc; +}; + +union RMDIR3res switch (nfsstat3 status) { +case NFS3_OK: + RMDIR3resok resok; +default: + RMDIR3resfail resfail; +}; + +/* + * RENAME: Rename a file or directory + */ +struct RENAME3args { + diropargs3 from; + diropargs3 to; +}; + +struct RENAME3resok { + wcc_data fromdir_wcc; + wcc_data todir_wcc; +}; + +struct RENAME3resfail { + wcc_data fromdir_wcc; + wcc_data todir_wcc; +}; + +union RENAME3res switch (nfsstat3 status) { +case NFS3_OK: + RENAME3resok resok; +default: + RENAME3resfail resfail; +}; + +/* + * LINK: Create link to an object + */ +struct LINK3args { + nfs_fh3 file; + diropargs3 link; +}; + +struct LINK3resok { + post_op_attr file_attributes; + wcc_data linkdir_wcc; +}; + +struct LINK3resfail { + post_op_attr file_attributes; + wcc_data linkdir_wcc; +}; + +union LINK3res switch (nfsstat3 status) { +case NFS3_OK: + LINK3resok resok; +default: + LINK3resfail resfail; +}; + +/* + * READDIR: Read from directory + */ +struct READDIR3args { + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 count; +}; + +struct entry3 { + fileid3 fileid; + filename3 name; + cookie3 cookie; + entry3 *nextentry; +}; + +struct dirlist3 { + entry3 *entries; + bool eof; +}; + +struct READDIR3resok { + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlist3 reply; +}; + +struct READDIR3resfail { + post_op_attr dir_attributes; +}; + +union READDIR3res switch (nfsstat3 status) { +case NFS3_OK: + READDIR3resok resok; +default: + READDIR3resfail resfail; +}; + +/* + * READDIRPLUS: Extended read from a directory + */ +struct READDIRPLUS3args { + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 dircount; + count3 maxcount; +}; + +struct entryplus3 { + fileid3 fileid; + filename3 name; + cookie3 cookie; + post_op_attr name_attributes; + post_op_fh3 name_handle; + entryplus3 *nextentry; +}; + +struct dirlistplus3 { + entryplus3 *entries; + bool eof; +}; + +struct READDIRPLUS3resok { + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlistplus3 reply; +}; + +struct READDIRPLUS3resfail { + post_op_attr dir_attributes; +}; + +union READDIRPLUS3res switch (nfsstat3 status) { +case NFS3_OK: + READDIRPLUS3resok resok; +default: + READDIRPLUS3resfail resfail; +}; + +/* + * FSSTAT: Get dynamic file system information + */ +struct FSSTAT3args { + nfs_fh3 fsroot; +}; + +struct FSSTAT3resok { + post_op_attr obj_attributes; + size3 tbytes; + size3 fbytes; + size3 abytes; + size3 tfiles; + size3 ffiles; + size3 afiles; + uint32 invarsec; +}; + +struct FSSTAT3resfail { + post_op_attr obj_attributes; +}; + +union FSSTAT3res switch (nfsstat3 status) { +case NFS3_OK: + FSSTAT3resok resok; +default: + FSSTAT3resfail resfail; +}; + +/* + * FSINFO: Get static file system information + */ + +const FSF3_LINK = 0x0001; +const FSF3_SYMLINK = 0x0002; +const FSF3_HOMOGENEOUS = 0x0008; +const FSF3_CANSETTIME = 0x0010; + +struct FSINFO3args { + nfs_fh3 fsroot; +}; + +struct FSINFO3resok { + post_op_attr obj_attributes; + uint32 rtmax; + uint32 rtpref; + uint32 rtmult; + uint32 wtmax; + uint32 wtpref; + uint32 wtmult; + uint32 dtpref; + size3 maxfilesize; + nfstime3 time_delta; + uint32 properties; +}; + +struct FSINFO3resfail { + post_op_attr obj_attributes; +}; + +union FSINFO3res switch (nfsstat3 status) { +case NFS3_OK: + FSINFO3resok resok; +default: + FSINFO3resfail resfail; +}; + +/* + * PATHCONF: Retrieve POSIX information + */ +struct PATHCONF3args { + nfs_fh3 object; +}; + +struct PATHCONF3resok { + post_op_attr obj_attributes; + uint32 linkmax; + uint32 name_max; + bool no_trunc; + bool chown_restricted; + bool case_insensitive; + bool case_preserving; +}; + +struct PATHCONF3resfail { + post_op_attr obj_attributes; +}; + +union PATHCONF3res switch (nfsstat3 status) { +case NFS3_OK: + PATHCONF3resok resok; +default: + PATHCONF3resfail resfail; +}; + +/* + * COMMIT: Commit cached data on a server to stable storage + */ +struct COMMIT3args { + nfs_fh3 file; + offset3 offset; + count3 count; +}; + +struct COMMIT3resok { + wcc_data file_wcc; + writeverf3 verf; +}; + +struct COMMIT3resfail { + wcc_data file_wcc; +}; + +union COMMIT3res switch (nfsstat3 status) { +case NFS3_OK: + COMMIT3resok resok; +default: + COMMIT3resfail resfail; +}; + +/* + * Remote file service routines + */ +program NFS3_PROGRAM { + version NFS_V3 { + void + NFSPROC3_NULL(void) = 0; + + GETATTR3res + NFSPROC3_GETATTR(GETATTR3args) = 1; + + SETATTR3res + NFSPROC3_SETATTR(SETATTR3args) = 2; + + LOOKUP3res + NFSPROC3_LOOKUP(LOOKUP3args) = 3; + + ACCESS3res + NFSPROC3_ACCESS(ACCESS3args) = 4; + + READLINK3res + NFSPROC3_READLINK(READLINK3args) = 5; + + READ3res + NFSPROC3_READ(READ3args) = 6; + + WRITE3res + NFSPROC3_WRITE(WRITE3args) = 7; + + CREATE3res + NFSPROC3_CREATE(CREATE3args) = 8; + + MKDIR3res + NFSPROC3_MKDIR(MKDIR3args) = 9; + + SYMLINK3res + NFSPROC3_SYMLINK(SYMLINK3args) = 10; + + MKNOD3res + NFSPROC3_MKNOD(MKNOD3args) = 11; + + REMOVE3res + NFSPROC3_REMOVE(REMOVE3args) = 12; + + RMDIR3res + NFSPROC3_RMDIR(RMDIR3args) = 13; + + RENAME3res + NFSPROC3_RENAME(RENAME3args) = 14; + + LINK3res + NFSPROC3_LINK(LINK3args) = 15; + + READDIR3res + NFSPROC3_READDIR(READDIR3args) = 16; + + READDIRPLUS3res + NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17; + + FSSTAT3res + NFSPROC3_FSSTAT(FSSTAT3args) = 18; + + FSINFO3res + NFSPROC3_FSINFO(FSINFO3args) = 19; + + PATHCONF3res + NFSPROC3_PATHCONF(PATHCONF3args) = 20; + + COMMIT3res + NFSPROC3_COMMIT(COMMIT3args) = 21; + } = 3; +} = 100003; diff --git a/illumos-x86_64/usr/include/rpcsvc/nis.h b/illumos-x86_64/usr/include/rpcsvc/nis.h new file mode 100644 index 00000000..d351d5cd --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nis.h @@ -0,0 +1,400 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _NIS_H_RPCGEN +#define _NIS_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __nis_object_h +#define __nis_object_h + +#define NIS_MAXSTRINGLEN 255 +#define NIS_MAXNAMELEN 1024 +#define NIS_MAXATTRNAME 32 +#define NIS_MAXATTRVAL 2048 +#define NIS_MAXCOLUMNS 64 +#define NIS_MAXATTR 16 +#define NIS_MAXPATH 1024 +#define NIS_MAXREPLICAS 128 +#define NIS_MAXLINKS 16 +#define NIS_PK_NONE 0 +#define NIS_PK_DH 1 +#define NIS_PK_RSA 2 +#define NIS_PK_KERB 3 +#define NIS_PK_DHEXT 4 + +struct nis_attr { + char *zattr_ndx; + struct { + u_int zattr_val_len; + char *zattr_val_val; + } zattr_val; +}; +typedef struct nis_attr nis_attr; + +typedef char *nis_name; + +enum zotypes { + BOGUS_OBJ = 0, + NO_OBJ = 1, + DIRECTORY_OBJ = 2, + GROUP_OBJ = 3, + TABLE_OBJ = 4, + ENTRY_OBJ = 5, + LINK_OBJ = 6, + PRIVATE_OBJ = 7, + NIS_BOGUS_OBJ = 0, + NIS_NO_OBJ = 1, + NIS_DIRECTORY_OBJ = 2, + NIS_GROUP_OBJ = 3, + NIS_TABLE_OBJ = 4, + NIS_ENTRY_OBJ = 5, + NIS_LINK_OBJ = 6, + NIS_PRIVATE_OBJ = 7 +}; +typedef enum zotypes zotypes; + +enum nstype { + UNKNOWN = 0, + NIS = 1, + SUNYP = 2, + IVY = 3, + DNS = 4, + X500 = 5, + DNANS = 6, + XCHS = 7, + CDS = 8 +}; +typedef enum nstype nstype; + +struct oar_mask { + uint_t oa_rights; + zotypes oa_otype; +}; +typedef struct oar_mask oar_mask; + +struct endpoint { + char *uaddr; + char *family; + char *proto; +}; +typedef struct endpoint endpoint; + +struct nis_server { + nis_name name; + struct { + u_int ep_len; + endpoint *ep_val; + } ep; + uint_t key_type; + netobj pkey; +}; +typedef struct nis_server nis_server; + +struct directory_obj { + nis_name do_name; + nstype do_type; + struct { + u_int do_servers_len; + nis_server *do_servers_val; + } do_servers; + uint32_t do_ttl; + struct { + u_int do_armask_len; + oar_mask *do_armask_val; + } do_armask; +}; +typedef struct directory_obj directory_obj; +#define EN_BINARY 1 +#define EN_CRYPT 2 +#define EN_XDR 4 +#define EN_MODIFIED 8 +#define EN_ASN1 64 + +struct entry_col { + uint_t ec_flags; + struct { + u_int ec_value_len; + char *ec_value_val; + } ec_value; +}; +typedef struct entry_col entry_col; + +struct entry_obj { + char *en_type; + struct { + u_int en_cols_len; + entry_col *en_cols_val; + } en_cols; +}; +typedef struct entry_obj entry_obj; + +struct group_obj { + uint_t gr_flags; + struct { + u_int gr_members_len; + nis_name *gr_members_val; + } gr_members; +}; +typedef struct group_obj group_obj; + +struct link_obj { + zotypes li_rtype; + struct { + u_int li_attrs_len; + nis_attr *li_attrs_val; + } li_attrs; + nis_name li_name; +}; +typedef struct link_obj link_obj; +#define TA_BINARY 1 +#define TA_CRYPT 2 +#define TA_XDR 4 +#define TA_SEARCHABLE 8 +#define TA_CASE 16 +#define TA_MODIFIED 32 +#define TA_ASN1 64 + +struct table_col { + char *tc_name; + uint_t tc_flags; + uint_t tc_rights; +}; +typedef struct table_col table_col; + +struct table_obj { + char *ta_type; + int ta_maxcol; + u_char ta_sep; + struct { + u_int ta_cols_len; + table_col *ta_cols_val; + } ta_cols; + char *ta_path; +}; +typedef struct table_obj table_obj; + +struct objdata { + zotypes zo_type; + union { + struct directory_obj di_data; + struct group_obj gr_data; + struct table_obj ta_data; + struct entry_obj en_data; + struct link_obj li_data; + struct { + u_int po_data_len; + char *po_data_val; + } po_data; + } objdata_u; +}; +typedef struct objdata objdata; + +struct nis_oid { + uint32_t ctime; + uint32_t mtime; +}; +typedef struct nis_oid nis_oid; + +struct nis_object { + nis_oid zo_oid; + nis_name zo_name; + nis_name zo_owner; + nis_name zo_group; + nis_name zo_domain; + uint_t zo_access; + uint32_t zo_ttl; + objdata zo_data; +}; +typedef struct nis_object nis_object; + +#endif /* if __nis_object_h */ + + +enum log_entry_t { + LOG_NOP = 0, + ADD_NAME = 1, + REM_NAME = 2, + MOD_NAME_OLD = 3, + MOD_NAME_NEW = 4, + ADD_IBASE = 5, + REM_IBASE = 6, + MOD_IBASE = 7, + UPD_STAMP = 8 +}; +typedef enum log_entry_t log_entry_t; + +struct log_entry { + uint32_t le_time; + log_entry_t le_type; + nis_name le_princp; + nis_name le_name; + struct { + u_int le_attrs_len; + nis_attr *le_attrs_val; + } le_attrs; + nis_object le_object; +}; +typedef struct log_entry log_entry; + +struct nis_tag { + u_int tag_type; + char *tag_val; +}; +typedef struct nis_tag nis_tag; +/* + * Structures used for server binding. + */ + +struct nis_bound_endpoint { + endpoint ep; + int generation; + int rank; + u_int flags; + int hostnum; + int epnum; + nis_name uaddr; + endpoint cbep; +}; +typedef struct nis_bound_endpoint nis_bound_endpoint; + + +struct nis_bound_directory { + int generation; + int min_rank; + int optimal_rank; + directory_obj dobj; + struct { + u_int BEP_len; + nis_bound_endpoint *BEP_val; + } BEP; +}; +typedef struct nis_bound_directory nis_bound_directory; + +#define bep_len BEP.BEP_len +#define bep_val BEP.BEP_val + +struct nis_active_endpoint { + endpoint ep; + nis_name hostname; + int rank; + int uaddr_generation; + nis_name uaddr; + int cbep_generation; + endpoint cbep; +}; +typedef struct nis_active_endpoint nis_active_endpoint; + +/* defines for nis_bound_endpoint.flags */ +#define NIS_BOUND 0x1 +#define NIS_TRANSIENT_ERRORS 0x2 +/* + * Generic "hash" datastructures, used by all types of hashed data. + */ +struct nis_hash_data { + nis_name name; /* NIS name of hashed item */ + int keychain; /* It's hash key (for pop) */ + struct nis_hash_data *next; /* Hash collision pointer */ + struct nis_hash_data *prv_item; /* A serial, doubly linked list */ + struct nis_hash_data *nxt_item; /* of items in the hash table */ +}; +typedef struct nis_hash_data NIS_HASH_ITEM; + +struct nis_hash_table { + NIS_HASH_ITEM *keys[64]; /* A hash table of items */ + NIS_HASH_ITEM *first; /* The first "item" in serial list */ +}; +typedef struct nis_hash_table NIS_HASH_TABLE; + +/* Structure for storing dynamically allocated static data */ +struct nis_sdata { + void *buf; /* Memory allocation pointer */ + u_int size; /* Buffer size */ +}; + +/* Generic client creating flags */ +#define ZMH_VC 1 +#define ZMH_DG 2 +#define ZMH_AUTH 4 +#define ZMH_NOFALLBACK 8 + +/* Testing Access rights for objects */ + +#define NIS_READ_ACC 1 +#define NIS_MODIFY_ACC 2 +#define NIS_CREATE_ACC 4 +#define NIS_DESTROY_ACC 8 +/* Test macros. a == access rights, m == desired rights. */ +#define NIS_WORLD(a, m) (((a) & (m)) != 0) +#define NIS_GROUP(a, m) (((a) & ((m) << 8)) != 0) +#define NIS_OWNER(a, m) (((a) & ((m) << 16)) != 0) +#define NIS_NOBODY(a, m) (((a) & ((m) << 24)) != 0) +/* + * EOL Alert - The following non-prefixed test macros are + * here for backward compatability, and will be not be present + * in future releases - use the NIS_*() macros above. + */ +#define WORLD(a, m) (((a) & (m)) != 0) +#define GROUP(a, m) (((a) & ((m) << 8)) != 0) +#define OWNER(a, m) (((a) & ((m) << 16)) != 0) +#define NOBODY(a, m) (((a) & ((m) << 24)) != 0) + +#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype) +#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights) +#define WORLD_DEFAULT (NIS_READ_ACC) +#define GROUP_DEFAULT (NIS_READ_ACC << 8) +#define OWNER_DEFAULT ((NIS_READ_ACC +\ + NIS_MODIFY_ACC +\ + NIS_CREATE_ACC +\ + NIS_DESTROY_ACC) << 16) +#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT) + +/* Result manipulation defines ... */ +#define NIS_RES_NUMOBJ(x) ((x)->objects.objects_len) +#define NIS_RES_OBJECT(x) ((x)->objects.objects_val) +#define NIS_RES_COOKIE(x) ((x)->cookie) +#define NIS_RES_STATUS(x) ((x)->status) + +/* These defines make getting at the variant part of the object easier. */ +#define TA_data zo_data.objdata_u.ta_data +#define EN_data zo_data.objdata_u.en_data +#define DI_data zo_data.objdata_u.di_data +#define LI_data zo_data.objdata_u.li_data +#define GR_data zo_data.objdata_u.gr_data + +#define __type_of(o) ((o)->zo_data.zo_type) + +/* Declarations for the internal subroutines in nislib.c */ +enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME}; +typedef enum name_pos name_pos; + +/* + * Defines for getting at column data in entry objects. Because RPCGEN + * generates some rather wordy structures, we create some defines that + * collapse the needed keystrokes to access a particular value using + * these definitions they take an nis_object *, and an int and return + * a u_char * for Value, and an int for length. + */ +#define ENTRY_VAL(obj, col) \ + (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val +#define ENTRY_LEN(obj, col) \ + (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len + + + +#ifdef __cplusplus +} +#endif + +/* Prototypes, and extern declarations for the NIS library functions. */ +#include +#endif /* __NIS_RPCGEN_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/nis.x b/illumos-x86_64/usr/include/rpcsvc/nis.x new file mode 100644 index 00000000..ca1b32ff --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nis.x @@ -0,0 +1,286 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * RPC Language Protocol description file for NIS Plus + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * + * From 4.1 : @(#)nis.x 1.61 Copyright 1989 Sun Microsystems + */ + +/* This gets stuffed into the source files. */ +#if RPC_HDR +%#include +#endif +#if defined(RPC_XDR) || defined(RPC_CLNT) || defined(RPC_SVC) +%#ifndef xdr_uint32_t +%#define xdr_uint32_t xdr_u_int +%#endif +%#ifndef xdr_uint_t +%#define xdr_uint_t xdr_u_int +%#endif +#endif +#if RPC_SVC +%#include "nis_svc.h" +#endif + +/* Include the RPC Language description of NIS objects */ +#include "nis_object.x" + + + + +/* + * These are the type of entries that are stored in the transaction log, + * note that modifications will appear as two entries, for names, they have + * a "OLD" entry followed by a "NEW" entry. For entries in tables, there + * is a remove followed by an add. It is done this way so that we can read + * the log backwards to back out transactions and forwards to propogate + * updated. + */ +enum log_entry_t { + LOG_NOP = 0, + ADD_NAME = 1, /* Name Added to name space */ + REM_NAME = 2, /* Name removed from name space */ + MOD_NAME_OLD = 3, /* Name was modified in the name space */ + MOD_NAME_NEW = 4, /* Name was modified in the name space */ + ADD_IBASE = 5, /* Entry added to information base */ + REM_IBASE = 6, /* Entry removed from information base */ + MOD_IBASE = 7, /* Entry was modified in information base */ + UPD_STAMP = 8 /* Update timestamp (used as fenceposts) */ +}; + +/* + * This result is returned from the name service when it is requested to + * dump logged entries from its transaction log. Information base updates + * will have the name of the information base in the le_name field and + * a canonical set of attribute/value pairs to fully specify the entry's + * 'name'. + */ +struct log_entry { + uint32_t le_time; /* Time in seconds */ + log_entry_t le_type; /* Type of log entry */ + nis_name le_princp; /* Principal making the change */ + nis_name le_name; /* Name of table/dir involved */ + nis_attr le_attrs<>; /* List of AV pairs. */ + nis_object le_object; /* Actual object value */ +}; + + +/* + * This structure defines a generic NIS tag list. The taglist contains + * zero or tags, each of which is a type and a value. (u_int). + * These are used to report statistics (see tag definitions below) + * and to set or reset state variables. + */ +struct nis_tag { + u_int tag_type; /* Statistic tag (may vary) */ + string tag_val<>; /* Statistic value may also vary */ +}; + + +%/* +% * Structures used for server binding. +% */ +struct nis_bound_endpoint { + endpoint ep; + int generation; + int rank; + u_int flags; + int hostnum; + int epnum; + nis_name uaddr; + endpoint cbep; +}; +typedef struct nis_bound_endpoint nis_bound_endpoint; + +struct nis_bound_directory { + int generation; + int min_rank; /* minimum rank of bound endpoints */ + int optimal_rank; /* best possible rank of all endpoints */ + directory_obj dobj; + nis_bound_endpoint BEP<>; +}; +typedef struct nis_bound_directory nis_bound_directory; +%#define bep_len BEP.BEP_len +%#define bep_val BEP.BEP_val + +struct nis_active_endpoint { + endpoint ep; + nis_name hostname; + int rank; + int uaddr_generation; + nis_name uaddr; + int cbep_generation; + endpoint cbep; +}; +typedef struct nis_active_endpoint nis_active_endpoint; + +%/* defines for nis_bound_endpoint.flags */ +%#define NIS_BOUND 0x1 +%#define NIS_TRANSIENT_ERRORS 0x2 + + + +/* + * What's going on here? Well, it's like this. When the service + * is being compiled it wants to have the service definition specific + * info included, and when the client is being compiled it wants that + * info. This includes the appropriate file which was generated by + * make in the protocols directory (probably /usr/include/rpcsvc). + */ +#ifdef RPC_SVC +%#include "nis_svc.h" +#endif +#ifdef RPC_CLNT +%#include "nis_clnt.h" +#endif + + +/* + * Included below are the defines that become part of nis.h, + * they are technically not part of the protocol, but do define + * key aspects of the implementation and are therefore useful + * in building a conforming server or client. + */ +#if RPC_HDR +%/* +% * Generic "hash" datastructures, used by all types of hashed data. +% */ +%struct nis_hash_data { +% nis_name name; /* NIS name of hashed item */ +% int keychain; /* It's hash key (for pop) */ +% struct nis_hash_data *next; /* Hash collision pointer */ +% struct nis_hash_data *prv_item; /* A serial, doubly linked list */ +% struct nis_hash_data *nxt_item; /* of items in the hash table */ +%}; +%typedef struct nis_hash_data NIS_HASH_ITEM; +% +%struct nis_hash_table { +% NIS_HASH_ITEM *keys[64]; /* A hash table of items */ +% NIS_HASH_ITEM *first; /* The first "item" in serial list */ +%}; +%typedef struct nis_hash_table NIS_HASH_TABLE; +% +%/* Structure for storing dynamically allocated static data */ +%struct nis_sdata { +% void *buf; /* Memory allocation pointer */ +% u_int size; /* Buffer size */ +%}; +% +%/* Generic client creating flags */ +%#define ZMH_VC 1 +%#define ZMH_DG 2 +%#define ZMH_AUTH 4 +%#define ZMH_NOFALLBACK 8 +% +%/* Testing Access rights for objects */ +% +%#define NIS_READ_ACC 1 +%#define NIS_MODIFY_ACC 2 +%#define NIS_CREATE_ACC 4 +%#define NIS_DESTROY_ACC 8 +%/* Test macros. a == access rights, m == desired rights. */ +%#define NIS_WORLD(a, m) (((a) & (m)) != 0) +%#define NIS_GROUP(a, m) (((a) & ((m) << 8)) != 0) +%#define NIS_OWNER(a, m) (((a) & ((m) << 16)) != 0) +%#define NIS_NOBODY(a, m) (((a) & ((m) << 24)) != 0) +%/* +% * EOL Alert - The following non-prefixed test macros are +% * here for backward compatability, and will be not be present +% * in future releases - use the NIS_*() macros above. +% */ +%#define WORLD(a, m) (((a) & (m)) != 0) +%#define GROUP(a, m) (((a) & ((m) << 8)) != 0) +%#define OWNER(a, m) (((a) & ((m) << 16)) != 0) +%#define NOBODY(a, m) (((a) & ((m) << 24)) != 0) +% +%#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype) +%#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights) +%#define WORLD_DEFAULT (NIS_READ_ACC) +%#define GROUP_DEFAULT (NIS_READ_ACC << 8) +%#define OWNER_DEFAULT ((NIS_READ_ACC +\ +% NIS_MODIFY_ACC +\ +% NIS_CREATE_ACC +\ +% NIS_DESTROY_ACC) << 16) +%#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT) +% +%/* Result manipulation defines ... */ +%#define NIS_RES_NUMOBJ(x) ((x)->objects.objects_len) +%#define NIS_RES_OBJECT(x) ((x)->objects.objects_val) +%#define NIS_RES_COOKIE(x) ((x)->cookie) +%#define NIS_RES_STATUS(x) ((x)->status) +% +%/* These defines make getting at the variant part of the object easier. */ +%#define TA_data zo_data.objdata_u.ta_data +%#define EN_data zo_data.objdata_u.en_data +%#define DI_data zo_data.objdata_u.di_data +%#define LI_data zo_data.objdata_u.li_data +%#define GR_data zo_data.objdata_u.gr_data +% +%#define __type_of(o) ((o)->zo_data.zo_type) +% +%/* Declarations for the internal subroutines in nislib.c */ +%enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME}; +%typedef enum name_pos name_pos; +% +%/* +% * Defines for getting at column data in entry objects. Because RPCGEN +% * generates some rather wordy structures, we create some defines that +% * collapse the needed keystrokes to access a particular value using +% * these definitions they take an nis_object *, and an int and return +% * a u_char * for Value, and an int for length. +% */ +%#define ENTRY_VAL(obj, col) \ +% (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val +%#define ENTRY_LEN(obj, col) \ +% (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len +% +% +% +%#ifdef __cplusplus +%} +%#endif +% +%/* Prototypes, and extern declarations for the NIS library functions. */ +%#include +%#endif /* __NIS_RPCGEN_H */ +%/* EDIT_START */ +% +%/* +% * nis_3.h +% * +% * This file contains definitions that are only of interest to the actual +% * service daemon and client stubs. Normal users of NIS will not include +% * this file. +% * +% * NOTE : This include file is automatically created by a combination +% * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead +% * and then remake this file. +% */ +%#ifndef __nis_3_h +%#define __nis_3_h +%#ifdef __cplusplus +%extern "C" { +%#endif +#endif diff --git a/illumos-x86_64/usr/include/rpcsvc/nis_db.h b/illumos-x86_64/usr/include/rpcsvc/nis_db.h new file mode 100644 index 00000000..65efd4b2 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nis_db.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * This header file defines the interface to the NIS database. All + * implementations of the database must export at least these routines. + * They must also follow the conventions set herein. See the implementors + * guide for specific semantics that are required. + */ + +#ifndef _RPCSVC_NIS_DB_H +#define _RPCSVC_NIS_DB_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum db_status { + DB_SUCCESS = 0, + DB_NOTFOUND = 1, + DB_NOTUNIQUE = 2, + DB_BADTABLE = 3, + DB_BADQUERY = 4, + DB_BADOBJECT = 5, + DB_MEMORY_LIMIT = 6, + DB_STORAGE_LIMIT = 7, + DB_INTERNAL_ERROR = 8 +}; +typedef enum db_status db_status; + +enum db_action { + DB_LOOKUP = 0, + DB_REMOVE = 1, + DB_ADD = 2, + DB_FIRST = 3, + DB_NEXT = 4, + DB_ALL = 5, + DB_RESET_NEXT = 6 +}; +typedef enum db_action db_action; + +typedef entry_obj *entry_object_p; + +typedef struct { + uint_t db_next_desc_len; + char *db_next_desc_val; +} db_next_desc; + +struct db_result { + db_status status; + db_next_desc nextinfo; + struct { + uint_t objects_len; + entry_object_p *objects_val; + } objects; + long ticks; +}; +typedef struct db_result db_result; + +/* + * Prototypes for the database functions. + */ + +extern bool_t db_initialize(char *); +extern db_status db_create_table(char *, table_obj *); +extern db_status db_destroy_table(char *); +extern db_result *db_first_entry(char *, int, nis_attr *); +extern db_result *db_next_entry(char *, db_next_desc *); +extern db_result *db_reset_next_entry(char *, db_next_desc *); +extern db_result *db_list_entries(char *, int, nis_attr *); +extern db_result *db_add_entry(char *, int, nis_attr *, entry_obj *); +extern db_result *db_remove_entry(char *, int, nis_attr *); +extern db_status db_checkpoint(char *); +extern db_status db_standby(char *); +extern db_status db_table_exists(char *); +extern db_status db_unload_table(char *); +extern void db_free_result(db_result *); + +#ifdef __cplusplus +} +#endif + +#endif /* _RPCSVC_NIS_DB_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/nis_object.x b/illumos-x86_64/usr/include/rpcsvc/nis_object.x new file mode 100644 index 00000000..7ef49fda --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nis_object.x @@ -0,0 +1,329 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * nis_object.x + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if RPC_HDR +% +%#ifndef __nis_object_h +%#define __nis_object_h +% +#endif +/* + * This file defines the format for a NIS object in RPC language. + * It is included by the main .x file and the database access protocol + * file. It is common because both of them need to deal with the same + * type of object. Generating the actual code though is a bit messy because + * the nis.x file and the nis_dba.x file will generate xdr routines to + * encode/decode objects when only one set is needed. Such is life when + * one is using rpcgen. + * + * Note, the protocol doesn't specify any limits on such things as + * maximum name length, number of attributes, etc. These are enforced + * by the database backend. When you hit them you will no. Also see + * the db_getlimits() function for fetching the limit values. + * + */ + +#if defined(RPC_XDR) || defined(RPC_SVC) || defined(RPC_CLNT) +%#ifndef xdr_uint32_t +%#define xdr_uint32_t xdr_u_int +%#endif +%#ifndef xdr_uint_t +%#define xdr_uint_t xdr_u_int +%#endif +#endif + +/* Some manifest constants, chosen to maximize flexibility without + * plugging the wire full of data. + */ +const NIS_MAXSTRINGLEN = 255; +const NIS_MAXNAMELEN = 1024; +const NIS_MAXATTRNAME = 32; +const NIS_MAXATTRVAL = 2048; +const NIS_MAXCOLUMNS = 64; +const NIS_MAXATTR = 16; +const NIS_MAXPATH = 1024; +const NIS_MAXREPLICAS = 128; +const NIS_MAXLINKS = 16; + +const NIS_PK_NONE = 0; /* no public key (unix/sys auth) */ +const NIS_PK_DH = 1; /* Public key is Diffie-Hellman type */ +const NIS_PK_RSA = 2; /* Public key if RSA type */ +const NIS_PK_KERB = 3; /* Use kerberos style authentication */ +const NIS_PK_DHEXT = 4; /* Extended Diffie-Hellman for RPC-GSS */ + +/* + * The fundamental name type of NIS. The name may consist of two parts, + * the first being the fully qualified name, and the second being an + * optional set of attribute/value pairs. + */ +struct nis_attr { + string zattr_ndx<>; /* name of the index */ + opaque zattr_val<>; /* Value for the attribute. */ +}; + +typedef string nis_name<>; /* The NIS name itself. */ + +/* NIS object types are defined by the following enumeration. The numbers + * they use are based on the following scheme : + * 0 - 1023 are reserved for Sun, + * 1024 - 2047 are defined to be private to a particular tree. + * 2048 - 4095 are defined to be user defined. + * 4096 - ... are reserved for future use. + * + * EOL Alert - The non-prefixed names are present for backward + * compatability only, and will not exist in future releases. Use + * the NIS_* names for future compatability. + */ + +enum zotypes { + + BOGUS_OBJ = 0, /* Uninitialized object structure */ + NO_OBJ = 1, /* NULL object (no data) */ + DIRECTORY_OBJ = 2, /* Directory object describing domain */ + GROUP_OBJ = 3, /* Group object (a list of names) */ + TABLE_OBJ = 4, /* Table object (a database schema) */ + ENTRY_OBJ = 5, /* Entry object (a database record) */ + LINK_OBJ = 6, /* A name link. */ + PRIVATE_OBJ = 7, /* Private object (all opaque data) */ + + NIS_BOGUS_OBJ = 0, /* Uninitialized object structure */ + NIS_NO_OBJ = 1, /* NULL object (no data) */ + NIS_DIRECTORY_OBJ = 2, /* Directory object describing domain */ + NIS_GROUP_OBJ = 3, /* Group object (a list of names) */ + NIS_TABLE_OBJ = 4, /* Table object (a database schema) */ + NIS_ENTRY_OBJ = 5, /* Entry object (a database record) */ + NIS_LINK_OBJ = 6, /* A name link. */ + NIS_PRIVATE_OBJ = 7 /* Private object (all opaque data) */ +}; + +/* + * The types of Name services NIS knows about. They are enumerated + * here. The Binder code will use this type to determine if it has + * a set of library routines that will access the indicated name service. + */ +enum nstype { + UNKNOWN = 0, + NIS = 1, /* Nis Plus Service */ + SUNYP = 2, /* Old NIS Service */ + IVY = 3, /* Nis Plus Plus Service */ + DNS = 4, /* Domain Name Service */ + X500 = 5, /* ISO/CCCIT X.500 Service */ + DNANS = 6, /* Digital DECNet Name Service */ + XCHS = 7, /* Xerox ClearingHouse Service */ + CDS= 8 +}; + +/* + * DIRECTORY - The name service object. These objects identify other name + * servers that are serving some portion of the name space. Each has a + * type associated with it. The resolver library will note whether or not + * is has the needed routines to access that type of service. + * The oarmask structure defines an access rights mask on a per object + * type basis for the name spaces. The only bits currently used are + * create and destroy. By enabling or disabling these access rights for + * a specific object type for a one of the accessor entities (owner, + * group, world) the administrator can control what types of objects + * may be freely added to the name space and which require the + * administrator's approval. + */ +struct oar_mask { + uint_t oa_rights; /* Access rights mask */ + zotypes oa_otype; /* Object type */ +}; + +struct endpoint { + string uaddr<>; + string family<>; /* Transport family (INET, OSI, etc) */ + string proto<>; /* Protocol (TCP, UDP, CLNP, etc) */ +}; + +/* + * Note: pkey is a netobj which is limited to 1024 bytes which limits the + * keysize to 8192 bits. This is consider to be a reasonable limit for + * the expected lifetime of this service. + */ +struct nis_server { + nis_name name; /* Principal name of the server */ + endpoint ep<>; /* Universal addr(s) for server */ + uint_t key_type; /* Public key type */ + netobj pkey; /* server's public key */ +}; + +struct directory_obj { + nis_name do_name; /* Name of the directory being served */ + nstype do_type; /* one of NIS, DNS, IVY, YP, or X.500 */ + nis_server do_servers<>; /* <0> == Primary name server */ + uint32_t do_ttl; /* Time To Live (for caches) */ + oar_mask do_armask<>; /* Create/Destroy rights by object type */ +}; + +/* + * ENTRY - This is one row of data from an information base. + * The type value is used by the client library to convert the entry to + * it's internal structure representation. The Table name is a back pointer + * to the table where the entry is stored. This allows the client library + * to determine where to send a request if the client wishes to change this + * entry but got to it through a LINK rather than directly. + * If the entry is a "standalone" entry then this field is void. + */ +const EN_BINARY = 1; /* Indicates value is binary data */ +const EN_CRYPT = 2; /* Indicates the value is encrypted */ +const EN_XDR = 4; /* Indicates the value is XDR encoded */ +const EN_MODIFIED = 8; /* Indicates entry is modified. */ +const EN_ASN1 = 64; /* Means contents use ASN.1 encoding */ + +struct entry_col { + uint_t ec_flags; /* Flags for this value */ + opaque ec_value<>; /* It's textual value */ +}; + +struct entry_obj { + string en_type<>; /* Type of entry such as "passwd" */ + entry_col en_cols<>; /* Value for the entry */ +}; + +/* + * GROUP - The group object contains a list of NIS principal names. Groups + * are used to authorize principals. Each object has a set of access rights + * for members of its group. Principal names in groups are in the form + * name.directory and recursive groups are expressed as @groupname.directory + */ +struct group_obj { + uint_t gr_flags; /* Flags controlling group */ + nis_name gr_members<>; /* List of names in group */ +}; + +/* + * LINK - This is the LINK object. It is quite similar to a symbolic link + * in the UNIX filesystem. The attributes in the main object structure are + * relative to the LINK data and not what it points to (like the file system) + * "modify" privleges here indicate the right to modify what the link points + * at and not to modify that actual object pointed to by the link. + */ +struct link_obj { + zotypes li_rtype; /* Real type of the object */ + nis_attr li_attrs<>; /* Attribute/Values for tables */ + nis_name li_name; /* The object's real NIS name */ +}; + +/* + * TABLE - This is the table object. It implements a simple + * data base that applications and use for configuration or + * administration purposes. The role of the table is to group together + * a set of related entries. Tables are the simple database component + * of NIS. Like many databases, tables are logically divided into columns + * and rows. The columns are labeled with indexes and each ENTRY makes + * up a row. Rows may be addressed within the table by selecting one + * or more indexes, and values for those indexes. Each row which has + * a value for the given index that matches the desired value is returned. + * Within the definition of each column there is a flags variable, this + * variable contains flags which determine whether or not the column is + * searchable, contains binary data, and access rights for the entry objects + * column value. + */ + +const TA_BINARY = 1; /* Means table data is binary */ +const TA_CRYPT = 2; /* Means value should be encrypted */ +const TA_XDR = 4; /* Means value is XDR encoded */ +const TA_SEARCHABLE = 8; /* Means this column is searchable */ +const TA_CASE = 16; /* Means this column is Case Sensitive */ +const TA_MODIFIED = 32; /* Means this columns attrs are modified*/ +const TA_ASN1 = 64; /* Means contents use ASN.1 encoding */ + +struct table_col { + string tc_name<64>; /* Column Name */ + uint_t tc_flags; /* control flags */ + uint_t tc_rights; /* Access rights mask */ +}; + +struct table_obj { + string ta_type<64>; /* Table type such as "passwd" */ + int ta_maxcol; /* Total number of columns */ + u_char ta_sep; /* Separator character */ + table_col ta_cols<>; /* The number of table indexes */ + string ta_path<>; /* A search path for this table */ +}; + +/* + * This union joins together all of the currently known objects. + */ +union objdata switch (zotypes zo_type) { + case NIS_DIRECTORY_OBJ : + struct directory_obj di_data; + case NIS_GROUP_OBJ : + struct group_obj gr_data; + case NIS_TABLE_OBJ : + struct table_obj ta_data; + case NIS_ENTRY_OBJ: + struct entry_obj en_data; + case NIS_LINK_OBJ : + struct link_obj li_data; + case NIS_PRIVATE_OBJ : + opaque po_data<>; + case NIS_NO_OBJ : + void; + case NIS_BOGUS_OBJ : + void; + default : + void; +}; + +/* + * This is the basic NIS object data type. It consists of a generic part + * which all objects contain, and a specialized part which varies depending + * on the type of the object. All of the specialized sections have been + * described above. You might have wondered why they all start with an + * integer size, followed by the useful data. The answer is, when the + * server doesn't recognize the type returned it treats it as opaque data. + * And the definition for opaque data is {int size; char *data;}. In this + * way, servers and utility routines that do not understand a given type + * may still pass it around. One has to be careful in setting + * this variable accurately, it must take into account such things as + * XDR padding of structures etc. The best way to set it is to note one's + * position in the XDR encoding stream, encode the structure, look at the + * new position and calculate the size. + */ +struct nis_oid { + uint32_t ctime; /* Time of objects creation */ + uint32_t mtime; /* Time of objects modification */ +}; + +struct nis_object { + nis_oid zo_oid; /* object identity verifier. */ + nis_name zo_name; /* The NIS name for this object */ + nis_name zo_owner; /* NIS name of object owner. */ + nis_name zo_group; /* NIS name of access group. */ + nis_name zo_domain; /* The administrator for the object */ + uint_t zo_access; /* Access rights (owner, group, world) */ + uint32_t zo_ttl; /* Object's time to live in seconds. */ + objdata zo_data; /* Data structure for this type */ +}; +#if RPC_HDR +% +%#endif /* if __nis_object_h */ +% +#endif diff --git a/illumos-x86_64/usr/include/rpcsvc/nislib.h b/illumos-x86_64/usr/include/rpcsvc/nislib.h new file mode 100644 index 00000000..d1abc4ae --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nislib.h @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * nislib.h + * + * This file contains the interfaces that are visible in the SunOS 5.x + * implementation of NIS Plus. + */ + +#ifndef _RPCSVC_NISLIB_H +#define _RPCSVC_NISLIB_H + + +#ifdef __cplusplus +extern "C" { +#endif + +extern name_pos nis_dir_cmp(nis_name, nis_name); + +extern nis_name nis_domain_of(nis_name); +extern nis_name nis_leaf_of(nis_name); +extern nis_name nis_leaf_of_r(const nis_name, char *, size_t); +extern nis_name nis_name_of(nis_name); +extern nis_name nis_local_group(void); +extern nis_name nis_local_directory(void); +extern nis_name nis_local_host(void); + +extern void nis_destroy_object(nis_object *); +extern nis_object *nis_clone_object(nis_object *, nis_object *); +extern nis_object *nis_read_obj(char *); +extern int nis_write_obj(char *, nis_object *); + +extern void *nis_get_static_storage(struct nis_sdata *, uint_t, uint_t); +extern nis_name __nis_rpc_domain(void); + +CLIENT *__nis_clnt_create(int, struct netconfig *, char *, struct netbuf *, + int, int, int, int, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _RPCSVC_NISLIB_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/nlm_prot.h b/illumos-x86_64/usr/include/rpcsvc/nlm_prot.h new file mode 100644 index 00000000..93d578c4 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nlm_prot.h @@ -0,0 +1,650 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _NLM_PROT_H_RPCGEN +#define _NLM_PROT_H_RPCGEN + +#include +#ifndef _KERNEL +#include +#include +#endif /* !_KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include + +#define LM_MAXSTRLEN 1024 +#define LM_MAXNAMELEN (LM_MAXSTRLEN + 1) + +enum nlm_stats { + nlm_granted = 0, + nlm_denied = 1, + nlm_denied_nolocks = 2, + nlm_blocked = 3, + nlm_denied_grace_period = 4, + nlm_deadlck = 5 +}; +typedef enum nlm_stats nlm_stats; + +struct nlm_holder { + bool_t exclusive; + int svid; + netobj oh; + u_int l_offset; + u_int l_len; +}; +typedef struct nlm_holder nlm_holder; + +struct nlm_testrply { + nlm_stats stat; + union { + struct nlm_holder holder; + } nlm_testrply_u; +}; +typedef struct nlm_testrply nlm_testrply; + +struct nlm_stat { + nlm_stats stat; +}; +typedef struct nlm_stat nlm_stat; + +struct nlm_res { + netobj cookie; + nlm_stat stat; +}; +typedef struct nlm_res nlm_res; + +struct nlm_testres { + netobj cookie; + nlm_testrply stat; +}; +typedef struct nlm_testres nlm_testres; + +struct nlm_lock { + char *caller_name; + netobj fh; + netobj oh; + int svid; + u_int l_offset; + u_int l_len; +}; +typedef struct nlm_lock nlm_lock; + +struct nlm_lockargs { + netobj cookie; + bool_t block; + bool_t exclusive; + struct nlm_lock alock; + bool_t reclaim; + int state; +}; +typedef struct nlm_lockargs nlm_lockargs; + +struct nlm_cancargs { + netobj cookie; + bool_t block; + bool_t exclusive; + struct nlm_lock alock; +}; +typedef struct nlm_cancargs nlm_cancargs; + +struct nlm_testargs { + netobj cookie; + bool_t exclusive; + struct nlm_lock alock; +}; +typedef struct nlm_testargs nlm_testargs; + +struct nlm_unlockargs { + netobj cookie; + struct nlm_lock alock; +}; +typedef struct nlm_unlockargs nlm_unlockargs; +/* + * The following enums are actually bit encoded for efficient + * boolean algebra.... DON'T change them..... + * The mixed-case enums violate the present style guide, but we're + * stuck with 'em. + */ + +enum fsh_mode { + fsm_DN = 0, + fsm_DR = 1, + fsm_DW = 2, + fsm_DRW = 3 +}; +typedef enum fsh_mode fsh_mode; + +enum fsh_access { + fsa_NONE = 0, + fsa_R = 1, + fsa_W = 2, + fsa_RW = 3 +}; +typedef enum fsh_access fsh_access; + +struct nlm_share { + char *caller_name; + netobj fh; + netobj oh; + fsh_mode mode; + fsh_access access; +}; +typedef struct nlm_share nlm_share; + +struct nlm_shareargs { + netobj cookie; + nlm_share share; + bool_t reclaim; +}; +typedef struct nlm_shareargs nlm_shareargs; + +struct nlm_shareres { + netobj cookie; + nlm_stats stat; + int sequence; +}; +typedef struct nlm_shareres nlm_shareres; + +struct nlm_notify { + char *name; + int state; +}; +typedef struct nlm_notify nlm_notify; + +enum nlm4_stats { + nlm4_granted = 0, + nlm4_denied = 1, + nlm4_denied_nolocks = 2, + nlm4_blocked = 3, + nlm4_denied_grace_period = 4, + nlm4_deadlck = 5, + nlm4_rofs = 6, + nlm4_stale_fh = 7, + nlm4_fbig = 8, + nlm4_failed = 9 +}; +typedef enum nlm4_stats nlm4_stats; + +struct nlm4_holder { + bool_t exclusive; + int32 svid; + netobj oh; + uint64 l_offset; + uint64 l_len; +}; +typedef struct nlm4_holder nlm4_holder; + +struct nlm4_testrply { + nlm4_stats stat; + union { + struct nlm4_holder holder; + } nlm4_testrply_u; +}; +typedef struct nlm4_testrply nlm4_testrply; + +struct nlm4_stat { + nlm4_stats stat; +}; +typedef struct nlm4_stat nlm4_stat; + +struct nlm4_res { + netobj cookie; + nlm4_stat stat; +}; +typedef struct nlm4_res nlm4_res; + +struct nlm4_testres { + netobj cookie; + nlm4_testrply stat; +}; +typedef struct nlm4_testres nlm4_testres; + +struct nlm4_lock { + char *caller_name; + netobj fh; + netobj oh; + int32 svid; + uint64 l_offset; + uint64 l_len; +}; +typedef struct nlm4_lock nlm4_lock; + +struct nlm4_lockargs { + netobj cookie; + bool_t block; + bool_t exclusive; + struct nlm4_lock alock; + bool_t reclaim; + int32 state; +}; +typedef struct nlm4_lockargs nlm4_lockargs; + +struct nlm4_cancargs { + netobj cookie; + bool_t block; + bool_t exclusive; + struct nlm4_lock alock; +}; +typedef struct nlm4_cancargs nlm4_cancargs; + +struct nlm4_testargs { + netobj cookie; + bool_t exclusive; + struct nlm4_lock alock; +}; +typedef struct nlm4_testargs nlm4_testargs; + +struct nlm4_unlockargs { + netobj cookie; + struct nlm4_lock alock; +}; +typedef struct nlm4_unlockargs nlm4_unlockargs; + +struct nlm4_share { + char *caller_name; + netobj fh; + netobj oh; + fsh_mode mode; + fsh_access access; +}; +typedef struct nlm4_share nlm4_share; + +struct nlm4_shareargs { + netobj cookie; + nlm4_share share; + bool_t reclaim; +}; +typedef struct nlm4_shareargs nlm4_shareargs; + +struct nlm4_shareres { + netobj cookie; + nlm4_stats stat; + int32 sequence; +}; +typedef struct nlm4_shareres nlm4_shareres; + +struct nlm4_notify { + char *name; + int32 state; +}; +typedef struct nlm4_notify nlm4_notify; + +struct nlm_sm_status { + char *mon_name; + int32 state; + char priv[16]; +}; +typedef struct nlm_sm_status nlm_sm_status; + +#define NLM_PROG 100021 +#define NLM_VERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define NLM_NULL 0 +extern enum clnt_stat nlm_null_1(void *, void *, CLIENT *); +extern bool_t nlm_null_1_svc(void *, void *, struct svc_req *); +#define NLM_TEST 1 +extern enum clnt_stat nlm_test_1(nlm_testargs *, nlm_testres *, CLIENT *); +extern bool_t nlm_test_1_svc(nlm_testargs *, nlm_testres *, struct svc_req *); +#define NLM_LOCK 2 +extern enum clnt_stat nlm_lock_1(nlm_lockargs *, nlm_res *, CLIENT *); +extern bool_t nlm_lock_1_svc(nlm_lockargs *, nlm_res *, struct svc_req *); +#define NLM_CANCEL 3 +extern enum clnt_stat nlm_cancel_1(nlm_cancargs *, nlm_res *, CLIENT *); +extern bool_t nlm_cancel_1_svc(nlm_cancargs *, nlm_res *, struct svc_req *); +#define NLM_UNLOCK 4 +extern enum clnt_stat nlm_unlock_1(nlm_unlockargs *, nlm_res *, CLIENT *); +extern bool_t nlm_unlock_1_svc(nlm_unlockargs *, nlm_res *, struct svc_req *); +#define NLM_GRANTED 5 +extern enum clnt_stat nlm_granted_1(nlm_testargs *, nlm_res *, CLIENT *); +extern bool_t nlm_granted_1_svc(nlm_testargs *, nlm_res *, struct svc_req *); +#define NLM_TEST_MSG 6 +extern enum clnt_stat nlm_test_msg_1(nlm_testargs *, void *, CLIENT *); +extern bool_t nlm_test_msg_1_svc(nlm_testargs *, void *, struct svc_req *); +#define NLM_LOCK_MSG 7 +extern enum clnt_stat nlm_lock_msg_1(nlm_lockargs *, void *, CLIENT *); +extern bool_t nlm_lock_msg_1_svc(nlm_lockargs *, void *, struct svc_req *); +#define NLM_CANCEL_MSG 8 +extern enum clnt_stat nlm_cancel_msg_1(nlm_cancargs *, void *, CLIENT *); +extern bool_t nlm_cancel_msg_1_svc(nlm_cancargs *, void *, struct svc_req *); +#define NLM_UNLOCK_MSG 9 +extern enum clnt_stat nlm_unlock_msg_1(nlm_unlockargs *, void *, CLIENT *); +extern bool_t nlm_unlock_msg_1_svc(nlm_unlockargs *, void *, struct svc_req *); +#define NLM_GRANTED_MSG 10 +extern enum clnt_stat nlm_granted_msg_1(nlm_testargs *, void *, CLIENT *); +extern bool_t nlm_granted_msg_1_svc(nlm_testargs *, void *, struct svc_req *); +#define NLM_TEST_RES 11 +extern enum clnt_stat nlm_test_res_1(nlm_testres *, void *, CLIENT *); +extern bool_t nlm_test_res_1_svc(nlm_testres *, void *, struct svc_req *); +#define NLM_LOCK_RES 12 +extern enum clnt_stat nlm_lock_res_1(nlm_res *, void *, CLIENT *); +extern bool_t nlm_lock_res_1_svc(nlm_res *, void *, struct svc_req *); +#define NLM_CANCEL_RES 13 +extern enum clnt_stat nlm_cancel_res_1(nlm_res *, void *, CLIENT *); +extern bool_t nlm_cancel_res_1_svc(nlm_res *, void *, struct svc_req *); +#define NLM_UNLOCK_RES 14 +extern enum clnt_stat nlm_unlock_res_1(nlm_res *, void *, CLIENT *); +extern bool_t nlm_unlock_res_1_svc(nlm_res *, void *, struct svc_req *); +#define NLM_GRANTED_RES 15 +extern enum clnt_stat nlm_granted_res_1(nlm_res *, void *, CLIENT *); +extern bool_t nlm_granted_res_1_svc(nlm_res *, void *, struct svc_req *); +extern int nlm_prog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define NLM_NULL 0 +extern enum clnt_stat nlm_null_1(); +extern bool_t nlm_null_1_svc(); +#define NLM_TEST 1 +extern enum clnt_stat nlm_test_1(); +extern bool_t nlm_test_1_svc(); +#define NLM_LOCK 2 +extern enum clnt_stat nlm_lock_1(); +extern bool_t nlm_lock_1_svc(); +#define NLM_CANCEL 3 +extern enum clnt_stat nlm_cancel_1(); +extern bool_t nlm_cancel_1_svc(); +#define NLM_UNLOCK 4 +extern enum clnt_stat nlm_unlock_1(); +extern bool_t nlm_unlock_1_svc(); +#define NLM_GRANTED 5 +extern enum clnt_stat nlm_granted_1(); +extern bool_t nlm_granted_1_svc(); +#define NLM_TEST_MSG 6 +extern enum clnt_stat nlm_test_msg_1(); +extern bool_t nlm_test_msg_1_svc(); +#define NLM_LOCK_MSG 7 +extern enum clnt_stat nlm_lock_msg_1(); +extern bool_t nlm_lock_msg_1_svc(); +#define NLM_CANCEL_MSG 8 +extern enum clnt_stat nlm_cancel_msg_1(); +extern bool_t nlm_cancel_msg_1_svc(); +#define NLM_UNLOCK_MSG 9 +extern enum clnt_stat nlm_unlock_msg_1(); +extern bool_t nlm_unlock_msg_1_svc(); +#define NLM_GRANTED_MSG 10 +extern enum clnt_stat nlm_granted_msg_1(); +extern bool_t nlm_granted_msg_1_svc(); +#define NLM_TEST_RES 11 +extern enum clnt_stat nlm_test_res_1(); +extern bool_t nlm_test_res_1_svc(); +#define NLM_LOCK_RES 12 +extern enum clnt_stat nlm_lock_res_1(); +extern bool_t nlm_lock_res_1_svc(); +#define NLM_CANCEL_RES 13 +extern enum clnt_stat nlm_cancel_res_1(); +extern bool_t nlm_cancel_res_1_svc(); +#define NLM_UNLOCK_RES 14 +extern enum clnt_stat nlm_unlock_res_1(); +extern bool_t nlm_unlock_res_1_svc(); +#define NLM_GRANTED_RES 15 +extern enum clnt_stat nlm_granted_res_1(); +extern bool_t nlm_granted_res_1_svc(); +extern int nlm_prog_1_freeresult(); +#endif /* K&R C */ +#define NLM_SM 2 + +#if defined(__STDC__) || defined(__cplusplus) +#define NLM_SM_NOTIFY1 17 +extern enum clnt_stat nlm_sm_notify1_2(struct nlm_sm_status *, void *, CLIENT *); +extern bool_t nlm_sm_notify1_2_svc(struct nlm_sm_status *, void *, struct svc_req *); +#define NLM_SM_NOTIFY2 18 +extern enum clnt_stat nlm_sm_notify2_2(struct nlm_sm_status *, void *, CLIENT *); +extern bool_t nlm_sm_notify2_2_svc(struct nlm_sm_status *, void *, struct svc_req *); +extern int nlm_prog_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define NLM_SM_NOTIFY1 17 +extern enum clnt_stat nlm_sm_notify1_2(); +extern bool_t nlm_sm_notify1_2_svc(); +#define NLM_SM_NOTIFY2 18 +extern enum clnt_stat nlm_sm_notify2_2(); +extern bool_t nlm_sm_notify2_2_svc(); +extern int nlm_prog_2_freeresult(); +#endif /* K&R C */ +#define NLM_VERSX 3 + +#if defined(__STDC__) || defined(__cplusplus) +#define NLM_SHARE 20 +extern enum clnt_stat nlm_share_3(nlm_shareargs *, nlm_shareres *, CLIENT *); +extern bool_t nlm_share_3_svc(nlm_shareargs *, nlm_shareres *, struct svc_req *); +#define NLM_UNSHARE 21 +extern enum clnt_stat nlm_unshare_3(nlm_shareargs *, nlm_shareres *, CLIENT *); +extern bool_t nlm_unshare_3_svc(nlm_shareargs *, nlm_shareres *, struct svc_req *); +#define NLM_NM_LOCK 22 +extern enum clnt_stat nlm_nm_lock_3(nlm_lockargs *, nlm_res *, CLIENT *); +extern bool_t nlm_nm_lock_3_svc(nlm_lockargs *, nlm_res *, struct svc_req *); +#define NLM_FREE_ALL 23 +extern enum clnt_stat nlm_free_all_3(nlm_notify *, void *, CLIENT *); +extern bool_t nlm_free_all_3_svc(nlm_notify *, void *, struct svc_req *); +extern int nlm_prog_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define NLM_SHARE 20 +extern enum clnt_stat nlm_share_3(); +extern bool_t nlm_share_3_svc(); +#define NLM_UNSHARE 21 +extern enum clnt_stat nlm_unshare_3(); +extern bool_t nlm_unshare_3_svc(); +#define NLM_NM_LOCK 22 +extern enum clnt_stat nlm_nm_lock_3(); +extern bool_t nlm_nm_lock_3_svc(); +#define NLM_FREE_ALL 23 +extern enum clnt_stat nlm_free_all_3(); +extern bool_t nlm_free_all_3_svc(); +extern int nlm_prog_3_freeresult(); +#endif /* K&R C */ +#define NLM4_VERS 4 + +#if defined(__STDC__) || defined(__cplusplus) +#define NLM4_NULL 0 +extern enum clnt_stat nlm4_null_4(void *, void *, CLIENT *); +extern bool_t nlm4_null_4_svc(void *, void *, struct svc_req *); +#define NLM4_TEST 1 +extern enum clnt_stat nlm4_test_4(nlm4_testargs *, nlm4_testres *, CLIENT *); +extern bool_t nlm4_test_4_svc(nlm4_testargs *, nlm4_testres *, struct svc_req *); +#define NLM4_LOCK 2 +extern enum clnt_stat nlm4_lock_4(nlm4_lockargs *, nlm4_res *, CLIENT *); +extern bool_t nlm4_lock_4_svc(nlm4_lockargs *, nlm4_res *, struct svc_req *); +#define NLM4_CANCEL 3 +extern enum clnt_stat nlm4_cancel_4(nlm4_cancargs *, nlm4_res *, CLIENT *); +extern bool_t nlm4_cancel_4_svc(nlm4_cancargs *, nlm4_res *, struct svc_req *); +#define NLM4_UNLOCK 4 +extern enum clnt_stat nlm4_unlock_4(nlm4_unlockargs *, nlm4_res *, CLIENT *); +extern bool_t nlm4_unlock_4_svc(nlm4_unlockargs *, nlm4_res *, struct svc_req *); +#define NLM4_GRANTED 5 +extern enum clnt_stat nlm4_granted_4(nlm4_testargs *, nlm4_res *, CLIENT *); +extern bool_t nlm4_granted_4_svc(nlm4_testargs *, nlm4_res *, struct svc_req *); +#define NLM4_TEST_MSG 6 +extern enum clnt_stat nlm4_test_msg_4(nlm4_testargs *, void *, CLIENT *); +extern bool_t nlm4_test_msg_4_svc(nlm4_testargs *, void *, struct svc_req *); +#define NLM4_LOCK_MSG 7 +extern enum clnt_stat nlm4_lock_msg_4(nlm4_lockargs *, void *, CLIENT *); +extern bool_t nlm4_lock_msg_4_svc(nlm4_lockargs *, void *, struct svc_req *); +#define NLM4_CANCEL_MSG 8 +extern enum clnt_stat nlm4_cancel_msg_4(nlm4_cancargs *, void *, CLIENT *); +extern bool_t nlm4_cancel_msg_4_svc(nlm4_cancargs *, void *, struct svc_req *); +#define NLM4_UNLOCK_MSG 9 +extern enum clnt_stat nlm4_unlock_msg_4(nlm4_unlockargs *, void *, CLIENT *); +extern bool_t nlm4_unlock_msg_4_svc(nlm4_unlockargs *, void *, struct svc_req *); +#define NLM4_GRANTED_MSG 10 +extern enum clnt_stat nlm4_granted_msg_4(nlm4_testargs *, void *, CLIENT *); +extern bool_t nlm4_granted_msg_4_svc(nlm4_testargs *, void *, struct svc_req *); +#define NLM4_TEST_RES 11 +extern enum clnt_stat nlm4_test_res_4(nlm4_testres *, void *, CLIENT *); +extern bool_t nlm4_test_res_4_svc(nlm4_testres *, void *, struct svc_req *); +#define NLM4_LOCK_RES 12 +extern enum clnt_stat nlm4_lock_res_4(nlm4_res *, void *, CLIENT *); +extern bool_t nlm4_lock_res_4_svc(nlm4_res *, void *, struct svc_req *); +#define NLM4_CANCEL_RES 13 +extern enum clnt_stat nlm4_cancel_res_4(nlm4_res *, void *, CLIENT *); +extern bool_t nlm4_cancel_res_4_svc(nlm4_res *, void *, struct svc_req *); +#define NLM4_UNLOCK_RES 14 +extern enum clnt_stat nlm4_unlock_res_4(nlm4_res *, void *, CLIENT *); +extern bool_t nlm4_unlock_res_4_svc(nlm4_res *, void *, struct svc_req *); +#define NLM4_GRANTED_RES 15 +extern enum clnt_stat nlm4_granted_res_4(nlm4_res *, void *, CLIENT *); +extern bool_t nlm4_granted_res_4_svc(nlm4_res *, void *, struct svc_req *); +#define NLM4_SHARE 20 +extern enum clnt_stat nlm4_share_4(nlm4_shareargs *, nlm4_shareres *, CLIENT *); +extern bool_t nlm4_share_4_svc(nlm4_shareargs *, nlm4_shareres *, struct svc_req *); +#define NLM4_UNSHARE 21 +extern enum clnt_stat nlm4_unshare_4(nlm4_shareargs *, nlm4_shareres *, CLIENT *); +extern bool_t nlm4_unshare_4_svc(nlm4_shareargs *, nlm4_shareres *, struct svc_req *); +#define NLM4_NM_LOCK 22 +extern enum clnt_stat nlm4_nm_lock_4(nlm4_lockargs *, nlm4_res *, CLIENT *); +extern bool_t nlm4_nm_lock_4_svc(nlm4_lockargs *, nlm4_res *, struct svc_req *); +#define NLM4_FREE_ALL 23 +extern enum clnt_stat nlm4_free_all_4(nlm4_notify *, void *, CLIENT *); +extern bool_t nlm4_free_all_4_svc(nlm4_notify *, void *, struct svc_req *); +extern int nlm_prog_4_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define NLM4_NULL 0 +extern enum clnt_stat nlm4_null_4(); +extern bool_t nlm4_null_4_svc(); +#define NLM4_TEST 1 +extern enum clnt_stat nlm4_test_4(); +extern bool_t nlm4_test_4_svc(); +#define NLM4_LOCK 2 +extern enum clnt_stat nlm4_lock_4(); +extern bool_t nlm4_lock_4_svc(); +#define NLM4_CANCEL 3 +extern enum clnt_stat nlm4_cancel_4(); +extern bool_t nlm4_cancel_4_svc(); +#define NLM4_UNLOCK 4 +extern enum clnt_stat nlm4_unlock_4(); +extern bool_t nlm4_unlock_4_svc(); +#define NLM4_GRANTED 5 +extern enum clnt_stat nlm4_granted_4(); +extern bool_t nlm4_granted_4_svc(); +#define NLM4_TEST_MSG 6 +extern enum clnt_stat nlm4_test_msg_4(); +extern bool_t nlm4_test_msg_4_svc(); +#define NLM4_LOCK_MSG 7 +extern enum clnt_stat nlm4_lock_msg_4(); +extern bool_t nlm4_lock_msg_4_svc(); +#define NLM4_CANCEL_MSG 8 +extern enum clnt_stat nlm4_cancel_msg_4(); +extern bool_t nlm4_cancel_msg_4_svc(); +#define NLM4_UNLOCK_MSG 9 +extern enum clnt_stat nlm4_unlock_msg_4(); +extern bool_t nlm4_unlock_msg_4_svc(); +#define NLM4_GRANTED_MSG 10 +extern enum clnt_stat nlm4_granted_msg_4(); +extern bool_t nlm4_granted_msg_4_svc(); +#define NLM4_TEST_RES 11 +extern enum clnt_stat nlm4_test_res_4(); +extern bool_t nlm4_test_res_4_svc(); +#define NLM4_LOCK_RES 12 +extern enum clnt_stat nlm4_lock_res_4(); +extern bool_t nlm4_lock_res_4_svc(); +#define NLM4_CANCEL_RES 13 +extern enum clnt_stat nlm4_cancel_res_4(); +extern bool_t nlm4_cancel_res_4_svc(); +#define NLM4_UNLOCK_RES 14 +extern enum clnt_stat nlm4_unlock_res_4(); +extern bool_t nlm4_unlock_res_4_svc(); +#define NLM4_GRANTED_RES 15 +extern enum clnt_stat nlm4_granted_res_4(); +extern bool_t nlm4_granted_res_4_svc(); +#define NLM4_SHARE 20 +extern enum clnt_stat nlm4_share_4(); +extern bool_t nlm4_share_4_svc(); +#define NLM4_UNSHARE 21 +extern enum clnt_stat nlm4_unshare_4(); +extern bool_t nlm4_unshare_4_svc(); +#define NLM4_NM_LOCK 22 +extern enum clnt_stat nlm4_nm_lock_4(); +extern bool_t nlm4_nm_lock_4_svc(); +#define NLM4_FREE_ALL 23 +extern enum clnt_stat nlm4_free_all_4(); +extern bool_t nlm4_free_all_4_svc(); +extern int nlm_prog_4_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_nlm_stats(XDR *, nlm_stats*); +extern bool_t xdr_nlm_holder(XDR *, nlm_holder*); +extern bool_t xdr_nlm_testrply(XDR *, nlm_testrply*); +extern bool_t xdr_nlm_stat(XDR *, nlm_stat*); +extern bool_t xdr_nlm_res(XDR *, nlm_res*); +extern bool_t xdr_nlm_testres(XDR *, nlm_testres*); +extern bool_t xdr_nlm_lock(XDR *, nlm_lock*); +extern bool_t xdr_nlm_lockargs(XDR *, nlm_lockargs*); +extern bool_t xdr_nlm_cancargs(XDR *, nlm_cancargs*); +extern bool_t xdr_nlm_testargs(XDR *, nlm_testargs*); +extern bool_t xdr_nlm_unlockargs(XDR *, nlm_unlockargs*); +extern bool_t xdr_fsh_mode(XDR *, fsh_mode*); +extern bool_t xdr_fsh_access(XDR *, fsh_access*); +extern bool_t xdr_nlm_share(XDR *, nlm_share*); +extern bool_t xdr_nlm_shareargs(XDR *, nlm_shareargs*); +extern bool_t xdr_nlm_shareres(XDR *, nlm_shareres*); +extern bool_t xdr_nlm_notify(XDR *, nlm_notify*); +extern bool_t xdr_nlm4_stats(XDR *, nlm4_stats*); +extern bool_t xdr_nlm4_holder(XDR *, nlm4_holder*); +extern bool_t xdr_nlm4_testrply(XDR *, nlm4_testrply*); +extern bool_t xdr_nlm4_stat(XDR *, nlm4_stat*); +extern bool_t xdr_nlm4_res(XDR *, nlm4_res*); +extern bool_t xdr_nlm4_testres(XDR *, nlm4_testres*); +extern bool_t xdr_nlm4_lock(XDR *, nlm4_lock*); +extern bool_t xdr_nlm4_lockargs(XDR *, nlm4_lockargs*); +extern bool_t xdr_nlm4_cancargs(XDR *, nlm4_cancargs*); +extern bool_t xdr_nlm4_testargs(XDR *, nlm4_testargs*); +extern bool_t xdr_nlm4_unlockargs(XDR *, nlm4_unlockargs*); +extern bool_t xdr_nlm4_share(XDR *, nlm4_share*); +extern bool_t xdr_nlm4_shareargs(XDR *, nlm4_shareargs*); +extern bool_t xdr_nlm4_shareres(XDR *, nlm4_shareres*); +extern bool_t xdr_nlm4_notify(XDR *, nlm4_notify*); +extern bool_t xdr_nlm_sm_status(XDR *, nlm_sm_status*); + +#else /* K&R C */ +extern bool_t xdr_nlm_stats(); +extern bool_t xdr_nlm_holder(); +extern bool_t xdr_nlm_testrply(); +extern bool_t xdr_nlm_stat(); +extern bool_t xdr_nlm_res(); +extern bool_t xdr_nlm_testres(); +extern bool_t xdr_nlm_lock(); +extern bool_t xdr_nlm_lockargs(); +extern bool_t xdr_nlm_cancargs(); +extern bool_t xdr_nlm_testargs(); +extern bool_t xdr_nlm_unlockargs(); +extern bool_t xdr_fsh_mode(); +extern bool_t xdr_fsh_access(); +extern bool_t xdr_nlm_share(); +extern bool_t xdr_nlm_shareargs(); +extern bool_t xdr_nlm_shareres(); +extern bool_t xdr_nlm_notify(); +extern bool_t xdr_nlm4_stats(); +extern bool_t xdr_nlm4_holder(); +extern bool_t xdr_nlm4_testrply(); +extern bool_t xdr_nlm4_stat(); +extern bool_t xdr_nlm4_res(); +extern bool_t xdr_nlm4_testres(); +extern bool_t xdr_nlm4_lock(); +extern bool_t xdr_nlm4_lockargs(); +extern bool_t xdr_nlm4_cancargs(); +extern bool_t xdr_nlm4_testargs(); +extern bool_t xdr_nlm4_unlockargs(); +extern bool_t xdr_nlm4_share(); +extern bool_t xdr_nlm4_shareargs(); +extern bool_t xdr_nlm4_shareres(); +extern bool_t xdr_nlm4_notify(); +extern bool_t xdr_nlm_sm_status(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_NLM_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/nlm_prot.x b/illumos-x86_64/usr/include/rpcsvc/nlm_prot.x new file mode 100644 index 00000000..1ce59d41 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nlm_prot.x @@ -0,0 +1,458 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (C) 1986, 1992, 1993, 1997, 1999 by Sun Microsystems, Inc. + * All rights reserved. + * + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * + * Protocol used between local lock manager and remote lock manager. + * + * There are currently 3 versions of the protocol in use. Versions 1 + * and 3 are used with NFS version 2. Version 4 is used with NFS + * version 3. + * + * (Note: there is also a version 2, but it defines an orthogonal set of + * procedures that the status monitor uses to notify the lock manager of + * changes in monitored systems.) + */ + +#if RPC_HDR +% +%#include +% +#endif + +#ifdef RPC_HDR +%#define LM_MAXSTRLEN 1024 +%#define LM_MAXNAMELEN (LM_MAXSTRLEN + 1) +#endif + +/* + * Types for versions 1 and 3. + */ + +/* + * Status of a call to the lock manager. The lower case enums violate the + * current style guide, but we're stuck with 'em. + */ + +enum nlm_stats { + nlm_granted = 0, + nlm_denied = 1, + nlm_denied_nolocks = 2, + nlm_blocked = 3, + nlm_denied_grace_period = 4, + nlm_deadlck = 5 +}; + +/* + * The holder of a conflicting lock. + */ + +struct nlm_holder { + bool exclusive; + int svid; + netobj oh; + unsigned l_offset; + unsigned l_len; +}; + +union nlm_testrply switch (nlm_stats stat) { + case nlm_denied: + struct nlm_holder holder; + default: + void; +}; + +struct nlm_stat { + nlm_stats stat; +}; + +struct nlm_res { + netobj cookie; + nlm_stat stat; +}; + +struct nlm_testres { + netobj cookie; + nlm_testrply stat; +}; + +struct nlm_lock { + string caller_name; + netobj fh; /* identify a file */ + netobj oh; /* identify owner of a lock */ + int svid; /* generated from pid for svid */ + unsigned l_offset; + unsigned l_len; +}; + +struct nlm_lockargs { + netobj cookie; + bool block; + bool exclusive; + struct nlm_lock alock; + bool reclaim; /* used for recovering locks */ + int state; /* specify local status monitor state */ +}; + +struct nlm_cancargs { + netobj cookie; + bool block; + bool exclusive; + struct nlm_lock alock; +}; + +struct nlm_testargs { + netobj cookie; + bool exclusive; + struct nlm_lock alock; +}; + +struct nlm_unlockargs { + netobj cookie; + struct nlm_lock alock; +}; + +#ifdef RPC_HDR +%/* +% * The following enums are actually bit encoded for efficient +% * boolean algebra.... DON'T change them..... +% * The mixed-case enums violate the present style guide, but we're +% * stuck with 'em. +% */ +#endif + +enum fsh_mode { + fsm_DN = 0, /* deny none */ + fsm_DR = 1, /* deny read */ + fsm_DW = 2, /* deny write */ + fsm_DRW = 3 /* deny read/write */ +}; + +enum fsh_access { + fsa_NONE = 0, /* for completeness */ + fsa_R = 1, /* read only */ + fsa_W = 2, /* write only */ + fsa_RW = 3 /* read/write */ +}; + +struct nlm_share { + string caller_name; + netobj fh; + netobj oh; + fsh_mode mode; + fsh_access access; +}; + +struct nlm_shareargs { + netobj cookie; + nlm_share share; + bool reclaim; +}; + +struct nlm_shareres { + netobj cookie; + nlm_stats stat; + int sequence; +}; + +struct nlm_notify { + string name; + int state; +}; + +/* + * Types for version 4. + * + * This revision is designed to work with NFS V3. The main changes from + * NFS V2 to V3 that affect the NLM protocol are that all file offsets + * and sizes are now unsigned 64-bit ints, and file handles are now + * variable length. In NLM V1 and V3, the fixed-length V2 file handle + * was encoded as a 'netobj', which is a count followed by the data + * bytes. For NLM 4, the file handle is already a count followed by + * data bytes, so the handle is copied directly into the netobj, rather + * than being encoded with an additional byte count. + */ + +/* + * Status of a call to the lock manager. + */ + +enum nlm4_stats { + nlm4_granted = 0, /* lock was granted */ + nlm4_denied = 1, /* lock was not granted, usually */ + /* due to conflicting lock */ + nlm4_denied_nolocks = 2, /* not granted: out of resources */ + nlm4_blocked = 3, /* not granted: expect callback */ + /* when granted */ + nlm4_denied_grace_period = 4, /* not granted: server is */ + /* reestablishing old locks */ + nlm4_deadlck = 5, /* not granted: deadlock detected */ + nlm4_rofs = 6, /* not granted: read-only filesystem */ + nlm4_stale_fh = 7, /* not granted: stale file handle */ + nlm4_fbig = 8, /* not granted: offset or length */ + /* too big */ + nlm4_failed = 9 /* not granted: some other error */ +}; + +/* + * The holder of a conflicting lock. + */ + +struct nlm4_holder { + bool exclusive; + int32 svid; + netobj oh; + uint64 l_offset; + uint64 l_len; +}; + +union nlm4_testrply switch (nlm4_stats stat) { + case nlm4_denied: + struct nlm4_holder holder; + default: + void; +}; + +struct nlm4_stat { + nlm4_stats stat; +}; + +struct nlm4_res { + netobj cookie; + nlm4_stat stat; +}; + +struct nlm4_testres { + netobj cookie; + nlm4_testrply stat; +}; + +struct nlm4_lock { + string caller_name; + netobj fh; /* identify a file */ + netobj oh; /* identify owner of a lock */ + int32 svid; /* generated from pid for svid */ + uint64 l_offset; + uint64 l_len; +}; + +struct nlm4_lockargs { + netobj cookie; + bool block; + bool exclusive; + struct nlm4_lock alock; + bool reclaim; /* used for recovering locks */ + int32 state; /* specify local status monitor state */ +}; + +struct nlm4_cancargs { + netobj cookie; + bool block; + bool exclusive; + struct nlm4_lock alock; +}; + +struct nlm4_testargs { + netobj cookie; + bool exclusive; + struct nlm4_lock alock; +}; + +struct nlm4_unlockargs { + netobj cookie; + struct nlm4_lock alock; +}; + +struct nlm4_share { + string caller_name; + netobj fh; + netobj oh; + fsh_mode mode; + fsh_access access; +}; + +struct nlm4_shareargs { + netobj cookie; + nlm4_share share; + bool reclaim; +}; + +struct nlm4_shareres { + netobj cookie; + nlm4_stats stat; + int32 sequence; +}; + +struct nlm4_notify { + string name; + int32 state; +}; + +/* + * Argument for the NLM call-back procedure called by rpc.statd + * when a monitored host status changes. The statd calls the + * NLM prog,vers,proc specified in the SM_MON call. + * NB: This struct must exactly match sm_inter.x:sm_status + * and requires LM_MAXSTRLEN == SM_MAXSTRLEN + */ +struct nlm_sm_status { + string mon_name; /* name of host */ + int32 state; /* new state */ + opaque priv[16]; /* private data */ +}; + +/* + * Over-the-wire protocol used between the network lock managers + */ + +program NLM_PROG { + + version NLM_VERS { + + void + NLM_NULL(void) = 0; + + nlm_testres + NLM_TEST(nlm_testargs) = 1; + + nlm_res + NLM_LOCK(nlm_lockargs) = 2; + + nlm_res + NLM_CANCEL(nlm_cancargs) = 3; + + nlm_res + NLM_UNLOCK(nlm_unlockargs) = 4; + /* + * remote lock manager call-back to grant lock + */ + nlm_res + NLM_GRANTED(nlm_testargs) = 5; + + /* + * message passing style of requesting lock + */ + + void + NLM_TEST_MSG(nlm_testargs) = 6; + void + NLM_LOCK_MSG(nlm_lockargs) = 7; + void + NLM_CANCEL_MSG(nlm_cancargs) = 8; + void + NLM_UNLOCK_MSG(nlm_unlockargs) = 9; + void + NLM_GRANTED_MSG(nlm_testargs) = 10; + void + NLM_TEST_RES(nlm_testres) = 11; + void + NLM_LOCK_RES(nlm_res) = 12; + void + NLM_CANCEL_RES(nlm_res) = 13; + void + NLM_UNLOCK_RES(nlm_res) = 14; + void + NLM_GRANTED_RES(nlm_res) = 15; + } = 1; + + /* + * Private (loopback-only) call-backs from statd, + * used to notify that some machine has restarted. + * The meaning of these is up to the lock manager + * implemenation. (See the SM_MON calls.) + */ + version NLM_SM { + void NLM_SM_NOTIFY1(struct nlm_sm_status) = 17; + void NLM_SM_NOTIFY2(struct nlm_sm_status) = 18; + } = 2; + + version NLM_VERSX { + nlm_shareres + NLM_SHARE(nlm_shareargs) = 20; + nlm_shareres + NLM_UNSHARE(nlm_shareargs) = 21; + nlm_res + NLM_NM_LOCK(nlm_lockargs) = 22; + void + NLM_FREE_ALL(nlm_notify) = 23; + } = 3; + + version NLM4_VERS { + void + NLM4_NULL(void) = 0; + nlm4_testres + NLM4_TEST(nlm4_testargs) = 1; + nlm4_res + NLM4_LOCK(nlm4_lockargs) = 2; + nlm4_res + NLM4_CANCEL(nlm4_cancargs) = 3; + nlm4_res + NLM4_UNLOCK(nlm4_unlockargs) = 4; + /* + * remote lock manager call-back to grant lock + */ + nlm4_res + NLM4_GRANTED(nlm4_testargs) = 5; + + /* + * message passing style of requesting lock + */ + + void + NLM4_TEST_MSG(nlm4_testargs) = 6; + void + NLM4_LOCK_MSG(nlm4_lockargs) = 7; + void + NLM4_CANCEL_MSG(nlm4_cancargs) = 8; + void + NLM4_UNLOCK_MSG(nlm4_unlockargs) = 9; + void + NLM4_GRANTED_MSG(nlm4_testargs) = 10; + void + NLM4_TEST_RES(nlm4_testres) = 11; + void + NLM4_LOCK_RES(nlm4_res) = 12; + void + NLM4_CANCEL_RES(nlm4_res) = 13; + void + NLM4_UNLOCK_RES(nlm4_res) = 14; + void + NLM4_GRANTED_RES(nlm4_res) = 15; + + /* + * DOS-style file sharing + */ + + nlm4_shareres + NLM4_SHARE(nlm4_shareargs) = 20; + nlm4_shareres + NLM4_UNSHARE(nlm4_shareargs) = 21; + nlm4_res + NLM4_NM_LOCK(nlm4_lockargs) = 22; + void + NLM4_FREE_ALL(nlm4_notify) = 23; + } = 4; + +} = 100021; diff --git a/illumos-x86_64/usr/include/rpcsvc/nsm_addr.h b/illumos-x86_64/usr/include/rpcsvc/nsm_addr.h new file mode 100644 index 00000000..7af75f34 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nsm_addr.h @@ -0,0 +1,144 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _NSM_ADDR_H_RPCGEN +#define _NSM_ADDR_H_RPCGEN + +#include +#ifndef _KERNEL +#include +#include +#endif /* !_KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* from nsm_addr.x */ + +/* + * This is the definition for the REG procedure which is used + * to register name/address pairs with statd. + */ + + +enum nsm_addr_res { + nsm_addr_succ = 0, + nsm_addr_fail = 1 +}; +typedef enum nsm_addr_res nsm_addr_res; + +struct reg1args { + u_int family; + char *name; + netobj address; +}; +typedef struct reg1args reg1args; + +struct reg1res { + nsm_addr_res status; +}; +typedef struct reg1res reg1res; + +/* + * This is the definition for the UNREG procedure which is used + * to unregister an address (and its associated name, if that name + * has no other addresses registered with it) with statd. + */ + +struct unreg1args { + u_int family; + char *name; + netobj address; +}; +typedef struct unreg1args unreg1args; + +struct unreg1res { + nsm_addr_res status; +}; +typedef struct unreg1res unreg1res; + +/* + * This is the definition for the NSM address registration network + * protocol which is used to privately support address registration + * with the status daemon statd (NSM). + */ + +#define NSM_ADDR_PROGRAM 100133 +#define NSM_ADDR_V1 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define NSMADDRPROC1_NULL 0 +extern enum clnt_stat nsmaddrproc1_null_1(void *, void *, CLIENT *); +extern bool_t nsmaddrproc1_null_1_svc(void *, void *, struct svc_req *); +#define NSMADDRPROC1_REG 1 +extern enum clnt_stat nsmaddrproc1_reg_1(reg1args *, reg1res *, CLIENT *); +extern bool_t nsmaddrproc1_reg_1_svc(reg1args *, reg1res *, struct svc_req *); +#define NSMADDRPROC1_UNREG 2 +extern enum clnt_stat nsmaddrproc1_unreg_1(unreg1args *, unreg1res *, CLIENT *); +extern bool_t nsmaddrproc1_unreg_1_svc(unreg1args *, unreg1res *, struct svc_req *); +extern int nsm_addr_program_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define NSMADDRPROC1_NULL 0 +extern enum clnt_stat nsmaddrproc1_null_1(); +extern bool_t nsmaddrproc1_null_1_svc(); +#define NSMADDRPROC1_REG 1 +extern enum clnt_stat nsmaddrproc1_reg_1(); +extern bool_t nsmaddrproc1_reg_1_svc(); +#define NSMADDRPROC1_UNREG 2 +extern enum clnt_stat nsmaddrproc1_unreg_1(); +extern bool_t nsmaddrproc1_unreg_1_svc(); +extern int nsm_addr_program_1_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_nsm_addr_res(XDR *, nsm_addr_res*); +extern bool_t xdr_reg1args(XDR *, reg1args*); +extern bool_t xdr_reg1res(XDR *, reg1res*); +extern bool_t xdr_unreg1args(XDR *, unreg1args*); +extern bool_t xdr_unreg1res(XDR *, unreg1res*); + +#else /* K&R C */ +extern bool_t xdr_nsm_addr_res(); +extern bool_t xdr_reg1args(); +extern bool_t xdr_reg1res(); +extern bool_t xdr_unreg1args(); +extern bool_t xdr_unreg1res(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_NSM_ADDR_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/nsm_addr.x b/illumos-x86_64/usr/include/rpcsvc/nsm_addr.x new file mode 100644 index 00000000..556efb9a --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/nsm_addr.x @@ -0,0 +1,78 @@ +%/* +% * Copyright 2005 Sun Microsystems, Inc. All rights reserved. +% * Use is subject to license terms. +% * +% * CDDL HEADER START +% * +% * The contents of this file are subject to the terms of the +% * Common Development and Distribution License, Version 1.0 only +% * (the "License"). You may not use this file except in compliance +% * with the License. +% * +% * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +% * or http://www.opensolaris.org/os/licensing. +% * See the License for the specific language governing permissions +% * and limitations under the License. +% * +% * When distributing Covered Code, include this CDDL HEADER in each +% * file and include the License file at usr/src/OPENSOLARIS.LICENSE. +% * If applicable, add the following below this CDDL HEADER, with the +% * fields enclosed by brackets "[]" replaced with your own identifying +% * information: Portions Copyright [yyyy] [name of copyright owner] +% * +% * CDDL HEADER END +% */ +% +%/* from nsm_addr.x */ +% +%/* +% * This is the definition for the REG procedure which is used +% * to register name/address pairs with statd. +% */ +% +enum nsm_addr_res { + nsm_addr_succ = 0, /* simple success/failure result */ + nsm_addr_fail = 1 +}; + +struct reg1args { + unsigned int family; /* address families from socket.h */ + string name<1024>; /* name to register with this addr */ + netobj address; +}; + +struct reg1res { + nsm_addr_res status; +}; +% +%/* +% * This is the definition for the UNREG procedure which is used +% * to unregister an address (and its associated name, if that name +% * has no other addresses registered with it) with statd. +% */ +struct unreg1args { + unsigned int family; /* address families from socket.h */ + string name<1024>; /* name under this addr to unregister */ + netobj address; +}; + +struct unreg1res { + nsm_addr_res status; +}; + +% +%/* +% * This is the definition for the NSM address registration network +% * protocol which is used to privately support address registration +% * with the status daemon statd (NSM). +% */ +program NSM_ADDR_PROGRAM { + version NSM_ADDR_V1 { + void + NSMADDRPROC1_NULL(void) = 0; + reg1res + NSMADDRPROC1_REG(reg1args) = 1; + unreg1res + NSMADDRPROC1_UNREG(unreg1args) = 2; + } = 1; +} = 100133; diff --git a/illumos-x86_64/usr/include/rpcsvc/rpc_sztypes.h b/illumos-x86_64/usr/include/rpcsvc/rpc_sztypes.h new file mode 100644 index 00000000..234724fa --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rpc_sztypes.h @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1994, by Sun Microsystems, Inc. + */ + +#ifndef _RPCSVC_RPC_SZTYPES_H +#define _RPCSVC_RPC_SZTYPES_H + +#include + +#endif /* _RPCSVC_RPC_SZTYPES_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/rpc_sztypes.x b/illumos-x86_64/usr/include/rpcsvc/rpc_sztypes.x new file mode 100644 index 00000000..dd49739f --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rpc_sztypes.x @@ -0,0 +1,34 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Definitions for primitive types that are explicitly sized. + */ + +typedef unsigned hyper uint64; +typedef hyper int64; + +typedef unsigned int uint32; +typedef int int32; diff --git a/illumos-x86_64/usr/include/rpcsvc/rquota.h b/illumos-x86_64/usr/include/rpcsvc/rquota.h new file mode 100644 index 00000000..460ea3d2 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rquota.h @@ -0,0 +1,94 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _RQUOTA_H_RPCGEN +#define _RQUOTA_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RQ_PATHLEN 1024 + +struct getquota_args { + char *gqa_pathp; + int32_t gqa_uid; +}; +typedef struct getquota_args getquota_args; + +struct rquota { + int32_t rq_bsize; + bool_t rq_active; + uint32_t rq_bhardlimit; + uint32_t rq_bsoftlimit; + uint32_t rq_curblocks; + uint32_t rq_fhardlimit; + uint32_t rq_fsoftlimit; + uint32_t rq_curfiles; + uint32_t rq_btimeleft; + uint32_t rq_ftimeleft; +}; +typedef struct rquota rquota; + +enum gqr_status { + Q_OK = 1, + Q_NOQUOTA = 2, + Q_EPERM = 3 +}; +typedef enum gqr_status gqr_status; + +struct getquota_rslt { + gqr_status status; + union { + rquota gqr_rquota; + } getquota_rslt_u; +}; +typedef struct getquota_rslt getquota_rslt; + +#define RQUOTAPROG 100011 +#define RQUOTAVERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define RQUOTAPROC_GETQUOTA 1 +extern getquota_rslt * rquotaproc_getquota_1(getquota_args *, CLIENT *); +extern getquota_rslt * rquotaproc_getquota_1_svc(getquota_args *, struct svc_req *); +#define RQUOTAPROC_GETACTIVEQUOTA 2 +extern getquota_rslt * rquotaproc_getactivequota_1(getquota_args *, CLIENT *); +extern getquota_rslt * rquotaproc_getactivequota_1_svc(getquota_args *, struct svc_req *); +extern int rquotaprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define RQUOTAPROC_GETQUOTA 1 +extern getquota_rslt * rquotaproc_getquota_1(); +extern getquota_rslt * rquotaproc_getquota_1_svc(); +#define RQUOTAPROC_GETACTIVEQUOTA 2 +extern getquota_rslt * rquotaproc_getactivequota_1(); +extern getquota_rslt * rquotaproc_getactivequota_1_svc(); +extern int rquotaprog_1_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_getquota_args(XDR *, getquota_args*); +extern bool_t xdr_rquota(XDR *, rquota*); +extern bool_t xdr_gqr_status(XDR *, gqr_status*); +extern bool_t xdr_getquota_rslt(XDR *, getquota_rslt*); + +#else /* K&R C */ +extern bool_t xdr_getquota_args(); +extern bool_t xdr_rquota(); +extern bool_t xdr_gqr_status(); +extern bool_t xdr_getquota_rslt(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RQUOTA_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/rquota.x b/illumos-x86_64/usr/include/rpcsvc/rquota.x new file mode 100644 index 00000000..cf34b41c --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rquota.x @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1987 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Remote quota protocol + * Requires unix authentication + */ + +const RQ_PATHLEN = 1024; + +struct getquota_args { + string gqa_pathp; /* path to filesystem of interest */ + int32_t gqa_uid; /* inquire about quota for uid */ +}; + +/* + * remote quota structure + */ +struct rquota { + int32_t rq_bsize; /* block size for block counts */ + bool rq_active; /* indicates whether quota is active */ + uint32_t rq_bhardlimit; /* absolute limit on disk blks alloc */ + uint32_t rq_bsoftlimit; /* preferred limit on disk blks */ + uint32_t rq_curblocks; /* current block count */ + uint32_t rq_fhardlimit; /* absolute limit on allocated files */ + uint32_t rq_fsoftlimit; /* preferred file limit */ + uint32_t rq_curfiles; /* current # allocated files */ + uint32_t rq_btimeleft; /* time left for excessive disk use */ + uint32_t rq_ftimeleft; /* time left for excessive files */ +}; + +enum gqr_status { + Q_OK = 1, /* quota returned */ + Q_NOQUOTA = 2, /* noquota for uid */ + Q_EPERM = 3 /* no permission to access quota */ +}; + +union getquota_rslt switch (gqr_status status) { +case Q_OK: + rquota gqr_rquota; /* valid if status == Q_OK */ +case Q_NOQUOTA: + void; +case Q_EPERM: + void; +}; + +program RQUOTAPROG { + version RQUOTAVERS { + /* + * Get all quotas + */ + getquota_rslt + RQUOTAPROC_GETQUOTA(getquota_args) = 1; + + /* + * Get active quotas only + */ + getquota_rslt + RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2; + } = 1; +} = 100011; diff --git a/illumos-x86_64/usr/include/rpcsvc/rstat.h b/illumos-x86_64/usr/include/rpcsvc/rstat.h new file mode 100644 index 00000000..da4b18f1 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rstat.h @@ -0,0 +1,161 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _RSTAT_H_RPCGEN +#define _RSTAT_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (c) 1985, 1990, 1991 by Sun Microsystems, Inc. + */ +/* from rstat.x */ + +/* + * Scale factor for scaled integers used to count load averages. + */ +#ifndef FSCALE +#define FSHIFT 8 /* bits to right of fixed binary point */ +#define FSCALE (1< /* The time struct defined below is */ +#endif /* meant to match struct timeval. */ + + + + + + +#define RSTAT_CPUSTATES 4 +#define RSTAT_DK_NDRIVE 4 +#define RSTAT_CPU_USER 0 +#define RSTAT_CPU_NICE 1 +#define RSTAT_CPU_SYS 2 +#define RSTAT_CPU_IDLE 3 + +struct rstat_timeval { + int tv_sec; + int tv_usec; +}; +typedef struct rstat_timeval rstat_timeval; + +struct statsvar { + struct { + u_int cp_time_len; + int *cp_time_val; + } cp_time; + struct { + u_int dk_xfer_len; + int *dk_xfer_val; + } dk_xfer; + u_int v_pgpgin; + u_int v_pgpgout; + u_int v_pswpin; + u_int v_pswpout; + u_int v_intr; + int if_ipackets; + int if_ierrors; + int if_opackets; + int if_oerrors; + int if_collisions; + u_int v_swtch; + int avenrun[3]; + rstat_timeval boottime; + rstat_timeval curtime; +}; +typedef struct statsvar statsvar; + +struct statstime { + int cp_time[RSTAT_CPUSTATES]; + int dk_xfer[RSTAT_DK_NDRIVE]; + u_int v_pgpgin; + u_int v_pgpgout; + u_int v_pswpin; + u_int v_pswpout; + u_int v_intr; + int if_ipackets; + int if_ierrors; + int if_oerrors; + int if_collisions; + u_int v_swtch; + int avenrun[3]; + rstat_timeval boottime; + rstat_timeval curtime; + int if_opackets; +}; +typedef struct statstime statstime; + +#if defined(__STDC__) || defined(__cplusplus) +enum clnt_stat rstat(char *, struct statstime *); +int havedisk(char *); +#else +enum clnt_stat rstat(); +int havedisk(); +#endif + + +#define RSTATPROG 100001 +#define RSTATVERS_VAR 4 + +#if defined(__STDC__) || defined(__cplusplus) +#define RSTATPROC_STATS 1 +extern statsvar * rstatproc_stats_4(void *, CLIENT *); +extern statsvar * rstatproc_stats_4_svc(void *, struct svc_req *); +#define RSTATPROC_HAVEDISK 2 +extern u_int * rstatproc_havedisk_4(void *, CLIENT *); +extern u_int * rstatproc_havedisk_4_svc(void *, struct svc_req *); +extern int rstatprog_4_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define RSTATPROC_STATS 1 +extern statsvar * rstatproc_stats_4(); +extern statsvar * rstatproc_stats_4_svc(); +#define RSTATPROC_HAVEDISK 2 +extern u_int * rstatproc_havedisk_4(); +extern u_int * rstatproc_havedisk_4_svc(); +extern int rstatprog_4_freeresult(); +#endif /* K&R C */ +#define RSTATVERS_TIME 3 + +#if defined(__STDC__) || defined(__cplusplus) +extern statstime * rstatproc_stats_3(void *, CLIENT *); +extern statstime * rstatproc_stats_3_svc(void *, struct svc_req *); +extern u_int * rstatproc_havedisk_3(void *, CLIENT *); +extern u_int * rstatproc_havedisk_3_svc(void *, struct svc_req *); +extern int rstatprog_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +extern statstime * rstatproc_stats_3(); +extern statstime * rstatproc_stats_3_svc(); +extern u_int * rstatproc_havedisk_3(); +extern u_int * rstatproc_havedisk_3_svc(); +extern int rstatprog_3_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_rstat_timeval(XDR *, rstat_timeval*); +extern bool_t xdr_statsvar(XDR *, statsvar*); +extern bool_t xdr_statstime(XDR *, statstime*); + +#else /* K&R C */ +extern bool_t xdr_rstat_timeval(); +extern bool_t xdr_statsvar(); +extern bool_t xdr_statstime(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RSTAT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/rstat.x b/illumos-x86_64/usr/include/rpcsvc/rstat.x new file mode 100644 index 00000000..de1a7059 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rstat.x @@ -0,0 +1,176 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +%/* +% * Copyright (c) 1985, 1990, 1991 by Sun Microsystems, Inc. +% */ + +%/* from rstat.x */ + +/* + * Gather statistics on remote machines + */ + +#ifdef RPC_HDR +% +%/* +% * Scale factor for scaled integers used to count load averages. +% */ +%#ifndef FSCALE +%#define FSHIFT 8 /* bits to right of fixed binary point */ +%#define FSCALE (1< /* The time struct defined below is */ +%#endif /* meant to match struct timeval. */ +% +% +% +% +% +% +#elif RPC_SVC +% +%/* +% * Server side stub routines for the rstat daemon +% */ +% +#elif RPC_CLNT +% +%/* +% * Client side stub routines for the rstat daemon +% */ +% +#elif RPC_XDR +%/* +% * XDR routines for the rstat daemon, rup and perfmeter. +% */ +% +%/* +% * xdr_timeval was used in previous releases. +% */ +% +%bool_t +%#ifdef __STDC__ +%xdr_timeval(XDR *xdrs, struct timeval *tvp) +%#else /* K&R C */ +%xdr_timeval(xdrs, tvp) +% XDR *xdrs; +% struct timeval *tvp; +%#endif /* K&R C */ +%{ +% return (xdr_rstat_timeval(xdrs, (rstat_timeval *)tvp)); +%} + +% +#endif + +const RSTAT_CPUSTATES = 4; +const RSTAT_DK_NDRIVE = 4; + +/* + * the cpu stat values + */ + +const RSTAT_CPU_USER = 0; +const RSTAT_CPU_NICE = 1; +const RSTAT_CPU_SYS = 2; +const RSTAT_CPU_IDLE = 3; + +/* + * GMT since 0:00, January 1, 1970 + */ +struct rstat_timeval { + int tv_sec; /* seconds */ + int tv_usec; /* and microseconds */ +}; + +struct statsvar { /* RSTATVERS_VAR */ + int cp_time<>; /* variable number of CPU states */ + int dk_xfer<>; /* variable number of disks */ + unsigned v_pgpgin; /* these are cumulative sum */ + unsigned v_pgpgout; + unsigned v_pswpin; + unsigned v_pswpout; + unsigned v_intr; + int if_ipackets; + int if_ierrors; + int if_opackets; + int if_oerrors; + int if_collisions; + unsigned v_swtch; + int avenrun[3]; + rstat_timeval boottime; + rstat_timeval curtime; +}; + +struct statstime { /* RSTATVERS_TIME */ + int cp_time[RSTAT_CPUSTATES]; + int dk_xfer[RSTAT_DK_NDRIVE]; + unsigned int v_pgpgin; /* these are cumulative sum */ + unsigned int v_pgpgout; + unsigned int v_pswpin; + unsigned int v_pswpout; + unsigned int v_intr; + int if_ipackets; + int if_ierrors; + int if_oerrors; + int if_collisions; + unsigned int v_swtch; + int avenrun[3]; + rstat_timeval boottime; + rstat_timeval curtime; + int if_opackets; +}; + +program RSTATPROG { + /* + * Version 4 allows for variable number of disk and RSTAT_CPU states. + */ + version RSTATVERS_VAR { + statsvar + RSTATPROC_STATS (void) = 1; + unsigned int + RSTATPROC_HAVEDISK (void) = 2; + } = 4; + /* + * Newest version includes current time and context switching info + */ + version RSTATVERS_TIME { + statstime + RSTATPROC_STATS(void) = 1; + unsigned int + RSTATPROC_HAVEDISK(void) = 2; + } = 3; +} = 100001; + +#ifdef RPC_HDR +% +%#if defined(__STDC__) || defined(__cplusplus) +%enum clnt_stat rstat(char *, struct statstime *); +%int havedisk(char *); +%#else +%enum clnt_stat rstat(); +%int havedisk(); +%#endif +% +#endif diff --git a/illumos-x86_64/usr/include/rpcsvc/rusers.h b/illumos-x86_64/usr/include/rpcsvc/rusers.h new file mode 100644 index 00000000..705b8ccc --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rusers.h @@ -0,0 +1,138 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _RUSERS_H_RPCGEN +#define _RUSERS_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Find out about remote users + */ +#define RUSERS_MAXUSERLEN 32 +#define RUSERS_MAXLINELEN 32 +#define RUSERS_MAXHOSTLEN 257 + +struct rusers_utmp { + char *ut_user; + char *ut_line; + char *ut_host; + int ut_type; + int ut_time; + u_int ut_idle; +}; +typedef struct rusers_utmp rusers_utmp; + +typedef struct { + u_int utmp_array_len; + rusers_utmp *utmp_array_val; +} utmp_array; + +/* + * Values for ut_type field above. + */ +#define RUSERS_EMPTY 0 +#define RUSERS_RUN_LVL 1 +#define RUSERS_BOOT_TIME 2 +#define RUSERS_OLD_TIME 3 +#define RUSERS_NEW_TIME 4 +#define RUSERS_INIT_PROCESS 5 +#define RUSERS_LOGIN_PROCESS 6 +#define RUSERS_USER_PROCESS 7 +#define RUSERS_DEAD_PROCESS 8 +#define RUSERS_ACCOUNTING 9 + + + +/* + * The following structures are used by version 2 of the rusersd protocol. + * They were not developed with rpcgen, so they do not appear as RPCL. + */ + +#define RUSERSVERS_IDLE 2 +#define RUSERSVERS 3 /* current version */ +#define MAXUSERS 100 + +/* + * This is the structure used in version 2 of the rusersd RPC service. + * It corresponds to the utmp structure for BSD systems. + */ +struct ru_utmp { + char ut_line[8]; /* tty name */ + char ut_name[8]; /* user id */ + char ut_host[16]; /* host name, if remote */ + time_t ut_time; /* time on */ +}; + +struct utmpidle { + struct ru_utmp ui_utmp; + unsigned ui_idle; +}; + +struct utmpidlearr { + struct utmpidle **uia_arr; + int uia_cnt; +}; + +int xdr_utmpidlearr(); + +#if defined(__STDC__) || defined(__cplusplus) +enum clnt_stat rusers(char *host, struct utmpidlearr *up); +int rnusers(char *host); +#else +enum clnt_stat rusers(); +int rnusers(); +#endif + + +#define RUSERSPROG 100002 +#define RUSERSVERS_3 3 + +#if defined(__STDC__) || defined(__cplusplus) +#define RUSERSPROC_NUM 1 +extern int * rusersproc_num_3(void *, CLIENT *); +extern int * rusersproc_num_3_svc(void *, struct svc_req *); +#define RUSERSPROC_NAMES 2 +extern utmp_array * rusersproc_names_3(void *, CLIENT *); +extern utmp_array * rusersproc_names_3_svc(void *, struct svc_req *); +#define RUSERSPROC_ALLNAMES 3 +extern utmp_array * rusersproc_allnames_3(void *, CLIENT *); +extern utmp_array * rusersproc_allnames_3_svc(void *, struct svc_req *); +extern int rusersprog_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define RUSERSPROC_NUM 1 +extern int * rusersproc_num_3(); +extern int * rusersproc_num_3_svc(); +#define RUSERSPROC_NAMES 2 +extern utmp_array * rusersproc_names_3(); +extern utmp_array * rusersproc_names_3_svc(); +#define RUSERSPROC_ALLNAMES 3 +extern utmp_array * rusersproc_allnames_3(); +extern utmp_array * rusersproc_allnames_3_svc(); +extern int rusersprog_3_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_rusers_utmp(XDR *, rusers_utmp*); +extern bool_t xdr_utmp_array(XDR *, utmp_array*); + +#else /* K&R C */ +extern bool_t xdr_rusers_utmp(); +extern bool_t xdr_utmp_array(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RUSERS_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/rusers.x b/illumos-x86_64/usr/include/rpcsvc/rusers.x new file mode 100644 index 00000000..f5756eb4 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rusers.x @@ -0,0 +1,121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1991 Sun Microsystems, Inc. + */ + +%/* +% * Find out about remote users +% */ + +const RUSERS_MAXUSERLEN = 32; +const RUSERS_MAXLINELEN = 32; +const RUSERS_MAXHOSTLEN = 257; + +struct rusers_utmp { + string ut_user; /* aka ut_name */ + string ut_line; /* device */ + string ut_host; /* host user logged on from */ + int ut_type; /* type of entry */ + int ut_time; /* time entry was made */ + unsigned int ut_idle; /* minutes idle */ +}; + +typedef rusers_utmp utmp_array<>; + +#ifdef RPC_HDR +% +%/* +% * Values for ut_type field above. +% */ +#endif +const RUSERS_EMPTY = 0; +const RUSERS_RUN_LVL = 1; +const RUSERS_BOOT_TIME = 2; +const RUSERS_OLD_TIME = 3; +const RUSERS_NEW_TIME = 4; +const RUSERS_INIT_PROCESS = 5; +const RUSERS_LOGIN_PROCESS = 6; +const RUSERS_USER_PROCESS = 7; +const RUSERS_DEAD_PROCESS = 8; +const RUSERS_ACCOUNTING = 9; + +program RUSERSPROG { + + version RUSERSVERS_3 { + int + RUSERSPROC_NUM(void) = 1; + + utmp_array + RUSERSPROC_NAMES(void) = 2; + + utmp_array + RUSERSPROC_ALLNAMES(void) = 3; + } = 3; + +} = 100002; + +#ifdef RPC_HDR +% +% +% +%/* +% * The following structures are used by version 2 of the rusersd protocol. +% * They were not developed with rpcgen, so they do not appear as RPCL. +% */ +% +%#define RUSERSVERS_IDLE 2 +%#define RUSERSVERS 3 /* current version */ +%#define MAXUSERS 100 +% +%/* +% * This is the structure used in version 2 of the rusersd RPC service. +% * It corresponds to the utmp structure for BSD systems. +% */ +%struct ru_utmp { +% char ut_line[8]; /* tty name */ +% char ut_name[8]; /* user id */ +% char ut_host[16]; /* host name, if remote */ +% time_t ut_time; /* time on */ +%}; +% +%struct utmpidle { +% struct ru_utmp ui_utmp; +% unsigned ui_idle; +%}; +% +%struct utmpidlearr { +% struct utmpidle **uia_arr; +% int uia_cnt; +%}; +% +%int xdr_utmpidlearr(); +% +%#if defined(__STDC__) || defined(__cplusplus) +%enum clnt_stat rusers(char *host, struct utmpidlearr *up); +%int rnusers(char *host); +%#else +%enum clnt_stat rusers(); +%int rnusers(); +%#endif +% +#endif diff --git a/illumos-x86_64/usr/include/rpcsvc/rwall.h b/illumos-x86_64/usr/include/rpcsvc/rwall.h new file mode 100644 index 00000000..83719b02 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rwall.h @@ -0,0 +1,90 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _RWALL_H_RPCGEN +#define _RWALL_H_RPCGEN + +#include +#ifndef _KERNEL +#include +#include +#endif /* !_KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* from rwall.x */ + +/* + * Remote write-all ONC service + */ + + +typedef char *wrapstring; + + +#if defined(__STDC__) || defined(__cplusplus) +enum clnt_stat rwall(char *, char *); +#else +enum clnt_stat rwall(); +#endif + + +#define WALLPROG 100008 +#define WALLVERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define WALLPROC_WALL 2 +extern enum clnt_stat wallproc_wall_1(wrapstring *, void *, CLIENT *); +extern bool_t wallproc_wall_1_svc(wrapstring *, void *, struct svc_req *); +extern int wallprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define WALLPROC_WALL 2 +extern enum clnt_stat wallproc_wall_1(); +extern bool_t wallproc_wall_1_svc(); +extern int wallprog_1_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_wrapstring(XDR *, wrapstring*); + +#else /* K&R C */ +extern bool_t xdr_wrapstring(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RWALL_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/rwall.x b/illumos-x86_64/usr/include/rpcsvc/rwall.x new file mode 100644 index 00000000..6cc24167 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/rwall.x @@ -0,0 +1,69 @@ +%/* +% * Copyright 2005 Sun Microsystems, Inc. All rights reserved. +% * Use is subject to license terms. +% * +% * CDDL HEADER START +% * +% * The contents of this file are subject to the terms of the +% * Common Development and Distribution License, Version 1.0 only +% * (the "License"). You may not use this file except in compliance +% * with the License. +% * +% * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +% * or http://www.opensolaris.org/os/licensing. +% * See the License for the specific language governing permissions +% * and limitations under the License. +% * +% * When distributing Covered Code, include this CDDL HEADER in each +% * file and include the License file at usr/src/OPENSOLARIS.LICENSE. +% * If applicable, add the following below this CDDL HEADER, with the +% * fields enclosed by brackets "[]" replaced with your own identifying +% * information: Portions Copyright [yyyy] [name of copyright owner] +% * +% * CDDL HEADER END +% */ + +%/* from rwall.x */ +% +%/* +% * Remote write-all ONC service +% */ + +#ifdef RPC_HDR +% +#elif RPC_SVC +% +%/* +% * Server side stub routines for the rpc.rwalld daemon +% */ +% +#elif RPC_CLNT +% +%/* +% * Client side stub routines for the rwall program +% */ +% +#endif + +typedef string wrapstring<>; /* Define for RPC library's xdr_wrapstring */ + +program WALLPROG { + version WALLVERS { + /* + * There is no procedure 1 + */ + void + WALLPROC_WALL (wrapstring) = 2; + } = 1; +} = 100008; + +#ifdef RPC_HDR +% +% +%#if defined(__STDC__) || defined(__cplusplus) +%enum clnt_stat rwall(char *, char *); +%#else +%enum clnt_stat rwall(); +%#endif +% +#endif diff --git a/illumos-x86_64/usr/include/rpcsvc/sm_inter.h b/illumos-x86_64/usr/include/rpcsvc/sm_inter.h new file mode 100644 index 00000000..16da1b4a --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/sm_inter.h @@ -0,0 +1,157 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _SM_INTER_H_RPCGEN +#define _SM_INTER_H_RPCGEN + +#include +#ifndef _KERNEL +#include +#include +#endif /* !_KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (c) 1986, 1994 by Sun Microsystems, Inc. + * All rights reserved. + */ +/* from sm_inter.x */ +#define SM_MAXSTRLEN 1024 + +struct sm_name { + char *mon_name; +}; +typedef struct sm_name sm_name; + +struct my_id { + char *my_name; + int my_prog; + int my_vers; + int my_proc; +}; +typedef struct my_id my_id; + +struct mon_id { + char *mon_name; + struct my_id my_id; +}; +typedef struct mon_id mon_id; + +struct mon { + struct mon_id mon_id; + char priv[16]; +}; +typedef struct mon mon; + +struct sm_stat { + int state; +}; +typedef struct sm_stat sm_stat; + +enum sm_res { + stat_succ = 0, + stat_fail = 1 +}; +typedef enum sm_res sm_res; + +struct sm_stat_res { + sm_res res_stat; + int state; +}; +typedef struct sm_stat_res sm_stat_res; + +struct sm_status { + char *mon_name; + int state; + char priv[16]; +}; +typedef struct sm_status sm_status; + +struct stat_chge { + char *mon_name; + int state; +}; +typedef struct stat_chge stat_chge; + +#define SM_PROG 100024 +#define SM_VERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define SM_STAT 1 +extern enum clnt_stat sm_stat_1(struct sm_name *, struct sm_stat_res *, CLIENT *); +extern bool_t sm_stat_1_svc(struct sm_name *, struct sm_stat_res *, struct svc_req *); +#define SM_MON 2 +extern enum clnt_stat sm_mon_1(struct mon *, struct sm_stat_res *, CLIENT *); +extern bool_t sm_mon_1_svc(struct mon *, struct sm_stat_res *, struct svc_req *); +#define SM_UNMON 3 +extern enum clnt_stat sm_unmon_1(struct mon_id *, struct sm_stat *, CLIENT *); +extern bool_t sm_unmon_1_svc(struct mon_id *, struct sm_stat *, struct svc_req *); +#define SM_UNMON_ALL 4 +extern enum clnt_stat sm_unmon_all_1(struct my_id *, struct sm_stat *, CLIENT *); +extern bool_t sm_unmon_all_1_svc(struct my_id *, struct sm_stat *, struct svc_req *); +#define SM_SIMU_CRASH 5 +extern enum clnt_stat sm_simu_crash_1(void *, void *, CLIENT *); +extern bool_t sm_simu_crash_1_svc(void *, void *, struct svc_req *); +#define SM_NOTIFY 6 +extern enum clnt_stat sm_notify_1(struct stat_chge *, void *, CLIENT *); +extern bool_t sm_notify_1_svc(struct stat_chge *, void *, struct svc_req *); +extern int sm_prog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define SM_STAT 1 +extern enum clnt_stat sm_stat_1(); +extern bool_t sm_stat_1_svc(); +#define SM_MON 2 +extern enum clnt_stat sm_mon_1(); +extern bool_t sm_mon_1_svc(); +#define SM_UNMON 3 +extern enum clnt_stat sm_unmon_1(); +extern bool_t sm_unmon_1_svc(); +#define SM_UNMON_ALL 4 +extern enum clnt_stat sm_unmon_all_1(); +extern bool_t sm_unmon_all_1_svc(); +#define SM_SIMU_CRASH 5 +extern enum clnt_stat sm_simu_crash_1(); +extern bool_t sm_simu_crash_1_svc(); +#define SM_NOTIFY 6 +extern enum clnt_stat sm_notify_1(); +extern bool_t sm_notify_1_svc(); +extern int sm_prog_1_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_sm_name(XDR *, sm_name*); +extern bool_t xdr_my_id(XDR *, my_id*); +extern bool_t xdr_mon_id(XDR *, mon_id*); +extern bool_t xdr_mon(XDR *, mon*); +extern bool_t xdr_sm_stat(XDR *, sm_stat*); +extern bool_t xdr_sm_res(XDR *, sm_res*); +extern bool_t xdr_sm_stat_res(XDR *, sm_stat_res*); +extern bool_t xdr_sm_status(XDR *, sm_status*); +extern bool_t xdr_stat_chge(XDR *, stat_chge*); + +#else /* K&R C */ +extern bool_t xdr_sm_name(); +extern bool_t xdr_my_id(); +extern bool_t xdr_mon_id(); +extern bool_t xdr_mon(); +extern bool_t xdr_sm_stat(); +extern bool_t xdr_sm_res(); +extern bool_t xdr_sm_stat_res(); +extern bool_t xdr_sm_status(); +extern bool_t xdr_stat_chge(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_SM_INTER_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/sm_inter.x b/illumos-x86_64/usr/include/rpcsvc/sm_inter.x new file mode 100644 index 00000000..7d9f6273 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/sm_inter.x @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +%/* +% * Copyright (c) 1986, 1994 by Sun Microsystems, Inc. +% * All rights reserved. +% */ + +%/* from sm_inter.x */ + +/* + * Status monitor protocol specification + */ + +program SM_PROG { + version SM_VERS { + /* res_stat = stat_succ if status monitor agrees to monitor */ + /* res_stat = stat_fail if status monitor cannot monitor */ + /* if res_stat == stat_succ, state = state number of site */ + /* sm_name */ + struct sm_stat_res SM_STAT(struct sm_name) = 1; + + /* res_stat = stat_succ if status monitor agrees to monitor */ + /* res_stat = stat_fail if status monitor cannot monitor */ + /* stat consists of state number of local site */ + struct sm_stat_res SM_MON(struct mon) = 2; + + /* stat consists of state number of local site */ + struct sm_stat SM_UNMON(struct mon_id) = 3; + + /* stat consists of state number of local site */ + struct sm_stat SM_UNMON_ALL(struct my_id) = 4; + + void SM_SIMU_CRASH(void) = 5; + + void SM_NOTIFY(struct stat_chge) = 6; + } = 1; +} = 100024; + +const SM_MAXSTRLEN = 1024; + +struct sm_name { + string mon_name; +}; + +struct my_id { + string my_name; /* name of the site iniates the */ + /* monitoring request */ + int my_prog; /* rpc program # of the requesting process */ + int my_vers; /* rpc version # of the requesting process */ + int my_proc; /* rpc procedure # of the requesting process */ +}; + +struct mon_id { + string mon_name; /* name of the site to be monitored */ + struct my_id my_id; +}; + + +struct mon{ + struct mon_id mon_id; + opaque priv[16]; /* private information to store at monitor */ + /* for requesting process */ +}; + + +/* + * state # of status monitor monitonically increases each time + * status of the site changes: + * an even number (>= 0) indicates the site is down and + * an odd number (> 0) indicates the site is up; + */ +struct sm_stat { + int state; /* state # of status monitor */ +}; + +enum sm_res { + stat_succ = 0, /* status monitor agrees to monitor */ + stat_fail = 1 /* status monitor cannot monitor */ +}; + +struct sm_stat_res { + sm_res res_stat; + int state; +}; + +/* + * structure of the status message sent by the status monitor to the + * requesting program when a monitored site changes status. + */ +struct sm_status { + string mon_name; + int state; + opaque priv[16]; /* stored private information */ +}; + +/* + * structure sent between statd's to announce a state change (e.g., + * reboot). + */ +struct stat_chge { + string mon_name; + int state; +}; diff --git a/illumos-x86_64/usr/include/rpcsvc/spray.h b/illumos-x86_64/usr/include/rpcsvc/spray.h new file mode 100644 index 00000000..cc804131 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/spray.h @@ -0,0 +1,84 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _SPRAY_H_RPCGEN +#define _SPRAY_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (c) 1987, 1991 by Sun Microsystems, Inc. + */ +/* from spray.x */ +#define SPRAYMAX 8845 + +struct spraytimeval { + u_int sec; + u_int usec; +}; +typedef struct spraytimeval spraytimeval; + +struct spraycumul { + u_int counter; + spraytimeval clock; +}; +typedef struct spraycumul spraycumul; + +typedef struct { + u_int sprayarr_len; + char *sprayarr_val; +} sprayarr; + +#define SPRAYPROG 100012 +#define SPRAYVERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define SPRAYPROC_SPRAY 1 +extern void * sprayproc_spray_1(sprayarr *, CLIENT *); +extern void * sprayproc_spray_1_svc(sprayarr *, struct svc_req *); +#define SPRAYPROC_GET 2 +extern spraycumul * sprayproc_get_1(void *, CLIENT *); +extern spraycumul * sprayproc_get_1_svc(void *, struct svc_req *); +#define SPRAYPROC_CLEAR 3 +extern void * sprayproc_clear_1(void *, CLIENT *); +extern void * sprayproc_clear_1_svc(void *, struct svc_req *); +extern int sprayprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define SPRAYPROC_SPRAY 1 +extern void * sprayproc_spray_1(); +extern void * sprayproc_spray_1_svc(); +#define SPRAYPROC_GET 2 +extern spraycumul * sprayproc_get_1(); +extern spraycumul * sprayproc_get_1_svc(); +#define SPRAYPROC_CLEAR 3 +extern void * sprayproc_clear_1(); +extern void * sprayproc_clear_1_svc(); +extern int sprayprog_1_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_spraytimeval(XDR *, spraytimeval*); +extern bool_t xdr_spraycumul(XDR *, spraycumul*); +extern bool_t xdr_sprayarr(XDR *, sprayarr*); + +#else /* K&R C */ +extern bool_t xdr_spraytimeval(); +extern bool_t xdr_spraycumul(); +extern bool_t xdr_sprayarr(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_SPRAY_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/spray.x b/illumos-x86_64/usr/include/rpcsvc/spray.x new file mode 100644 index 00000000..a7583c7f --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/spray.x @@ -0,0 +1,79 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +%/* +% * Copyright (c) 1987, 1991 by Sun Microsystems, Inc. +% */ + +%/* from spray.x */ + +/* + * Spray a server with packets + * Useful for testing flakiness of network interfaces + */ + +const SPRAYMAX = 8845; /* max amount can spray */ + +/* + * GMT since 0:00, 1 January 1970 + */ +struct spraytimeval { + unsigned int sec; + unsigned int usec; +}; + +/* + * spray statistics + */ +struct spraycumul { + unsigned int counter; + spraytimeval clock; +}; + +/* + * spray data + */ +typedef opaque sprayarr; + +program SPRAYPROG { + version SPRAYVERS { + /* + * Just throw away the data and increment the counter + * This call never returns, so the client should always + * time it out. + */ + void + SPRAYPROC_SPRAY(sprayarr) = 1; + + /* + * Get the value of the counter and elapsed time since + * last CLEAR. + */ + spraycumul + SPRAYPROC_GET(void) = 2; + + /* + * Clear the counter and reset the elapsed time + */ + void + SPRAYPROC_CLEAR(void) = 3; + } = 1; +} = 100012; diff --git a/illumos-x86_64/usr/include/rpcsvc/ufs_prot.h b/illumos-x86_64/usr/include/rpcsvc/ufs_prot.h new file mode 100644 index 00000000..4fd28150 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/ufs_prot.h @@ -0,0 +1,220 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _UFS_PROT_H_RPCGEN +#define _UFS_PROT_H_RPCGEN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +enum ufsdrc_t { + UFSDRC_OK = 0, + UFSDRC_NOENT = ENOENT, + UFSDRC_PERM = EPERM, + UFSDRC_INVAL = EINVAL, + UFSDRC_NOEXEC = ENOEXEC, + UFSDRC_NODEV = ENODEV, + UFSDRC_NXIO = ENXIO, + UFSDRC_BUSY = EBUSY, + UFSDRC_OPNOTSUP = EOPNOTSUPP, + UFSDRC_EXECERR = 254, + UFSDRC_ERR = 255 +}; +typedef enum ufsdrc_t ufsdrc_t; + +struct fs_identity_t { + dev_t fs_dev; + char *fs_name; +}; +typedef struct fs_identity_t fs_identity_t; + +struct ufsd_repairfs_args_t { + fs_identity_t ua_fsid; + u_int ua_attempts; +}; +typedef struct ufsd_repairfs_args_t ufsd_repairfs_args_t; + +struct ufsd_repairfs_list_t { + int ual_listlen; + ufsd_repairfs_args_t *ual_list; +}; +typedef struct ufsd_repairfs_list_t ufsd_repairfs_list_t; + +enum ufsd_event_t { + UFSDEV_NONE = 0, + UFSDEV_REBOOT = 0 + 1, + UFSDEV_FSCK = 0 + 2, + UFSDEV_LOG_OP = 0 + 3 +}; +typedef enum ufsd_event_t ufsd_event_t; + +enum ufsd_boot_type_t { + UFSDB_NONE = 0, + UFSDB_CLEAN = 0 + 1, + UFSDB_POSTPANIC = 0 + 2 +}; +typedef enum ufsd_boot_type_t ufsd_boot_type_t; + +enum ufsd_log_op_t { + UFSDLO_NONE = 0, + UFSDLO_COMMIT = 0 + 1, + UFSDLO_GET = 0 + 2, + UFSDLO_PUT = 0 + 3, + UFSDLO_RESET = 0 + 4 +}; +typedef enum ufsd_log_op_t ufsd_log_op_t; + +enum ufsd_fsck_state_t { + UFSDFS_NONE = 0, + UFSDFS_DISPATCH = 0 + 1, + UFSDFS_ERREXIT = 0 + 2, + UFSDFS_SUCCESS = 0 + 3 +}; +typedef enum ufsd_fsck_state_t ufsd_fsck_state_t; +#define UFSD_VARMSGMAX 1024 +#define UFSD_SPAREMSGBYTES 4 + +struct ufsd_log_data_t { + int umld_eob; + int umld_seq; + struct { + u_int umld_buf_len; + char *umld_buf_val; + } umld_buf; +}; +typedef struct ufsd_log_data_t ufsd_log_data_t; + +struct ufsd_log_msg_t { + ufsd_log_op_t um_lop; + union { + ufsd_log_data_t um_logdata; + } ufsd_log_msg_t_u; +}; +typedef struct ufsd_log_msg_t ufsd_log_msg_t; + +struct ufsd_msg_vardata_t { + ufsd_event_t umv_ev; + union { + ufsd_boot_type_t umv_b; + ufsd_fsck_state_t umv_fs; + ufsd_log_msg_t umv_lm; + } ufsd_msg_vardata_t_u; +}; +typedef struct ufsd_msg_vardata_t ufsd_msg_vardata_t; + +struct ufsd_msg_t { + time_t um_time; + u_int um_from; + struct { + u_int um_spare_len; + char *um_spare_val; + } um_spare; + ufsd_msg_vardata_t um_var; +}; +typedef struct ufsd_msg_t ufsd_msg_t; +#define UFSD_SERVNAME "ufsd" +#define xdr_dev_t xdr_u_int +#define xdr_time_t xdr_int +/* + * Set UFSD_THISVERS to the newest version of the protocol + * This allows the preprocessor to force an error if the + * protocol changes, since the kernel xdr routines may need to be + * recoded. Note that we can't explicitly set the version to a + * symbol as rpcgen will then create erroneous routine names. + */ +#define UFSD_V1 1 +#define UFSD_ORIGVERS UFSD_V1 +#define UFSD_THISVERS 1 + +#define UFSD_PROG 100233 +#define UFSD_VERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define UFSD_NULL 0 +extern ufsdrc_t * ufsd_null_1(void *, CLIENT *); +extern ufsdrc_t * ufsd_null_1_svc(void *, struct svc_req *); +#define UFSD_REPAIRFS 1 +extern ufsdrc_t * ufsd_repairfs_1(ufsd_repairfs_args_t *, CLIENT *); +extern ufsdrc_t * ufsd_repairfs_1_svc(ufsd_repairfs_args_t *, struct svc_req *); +#define UFSD_REPAIRFSLIST 2 +extern ufsdrc_t * ufsd_repairfslist_1(ufsd_repairfs_list_t *, CLIENT *); +extern ufsdrc_t * ufsd_repairfslist_1_svc(ufsd_repairfs_list_t *, struct svc_req *); +#define UFSD_SEND 3 +extern ufsdrc_t * ufsd_send_1(ufsd_msg_t *, CLIENT *); +extern ufsdrc_t * ufsd_send_1_svc(ufsd_msg_t *, struct svc_req *); +#define UFSD_RECV 4 +extern ufsdrc_t * ufsd_recv_1(ufsd_msg_t *, CLIENT *); +extern ufsdrc_t * ufsd_recv_1_svc(ufsd_msg_t *, struct svc_req *); +#define UFSD_EXIT 5 +extern ufsdrc_t * ufsd_exit_1(void *, CLIENT *); +extern ufsdrc_t * ufsd_exit_1_svc(void *, struct svc_req *); +extern int ufsd_prog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define UFSD_NULL 0 +extern ufsdrc_t * ufsd_null_1(); +extern ufsdrc_t * ufsd_null_1_svc(); +#define UFSD_REPAIRFS 1 +extern ufsdrc_t * ufsd_repairfs_1(); +extern ufsdrc_t * ufsd_repairfs_1_svc(); +#define UFSD_REPAIRFSLIST 2 +extern ufsdrc_t * ufsd_repairfslist_1(); +extern ufsdrc_t * ufsd_repairfslist_1_svc(); +#define UFSD_SEND 3 +extern ufsdrc_t * ufsd_send_1(); +extern ufsdrc_t * ufsd_send_1_svc(); +#define UFSD_RECV 4 +extern ufsdrc_t * ufsd_recv_1(); +extern ufsdrc_t * ufsd_recv_1_svc(); +#define UFSD_EXIT 5 +extern ufsdrc_t * ufsd_exit_1(); +extern ufsdrc_t * ufsd_exit_1_svc(); +extern int ufsd_prog_1_freeresult(); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_ufsdrc_t(XDR *, ufsdrc_t*); +extern bool_t xdr_fs_identity_t(XDR *, fs_identity_t*); +extern bool_t xdr_ufsd_repairfs_args_t(XDR *, ufsd_repairfs_args_t*); +extern bool_t xdr_ufsd_repairfs_list_t(XDR *, ufsd_repairfs_list_t*); +extern bool_t xdr_ufsd_event_t(XDR *, ufsd_event_t*); +extern bool_t xdr_ufsd_boot_type_t(XDR *, ufsd_boot_type_t*); +extern bool_t xdr_ufsd_log_op_t(XDR *, ufsd_log_op_t*); +extern bool_t xdr_ufsd_fsck_state_t(XDR *, ufsd_fsck_state_t*); +extern bool_t xdr_ufsd_log_data_t(XDR *, ufsd_log_data_t*); +extern bool_t xdr_ufsd_log_msg_t(XDR *, ufsd_log_msg_t*); +extern bool_t xdr_ufsd_msg_vardata_t(XDR *, ufsd_msg_vardata_t*); +extern bool_t xdr_ufsd_msg_t(XDR *, ufsd_msg_t*); + +#else /* K&R C */ +extern bool_t xdr_ufsdrc_t(); +extern bool_t xdr_fs_identity_t(); +extern bool_t xdr_ufsd_repairfs_args_t(); +extern bool_t xdr_ufsd_repairfs_list_t(); +extern bool_t xdr_ufsd_event_t(); +extern bool_t xdr_ufsd_boot_type_t(); +extern bool_t xdr_ufsd_log_op_t(); +extern bool_t xdr_ufsd_fsck_state_t(); +extern bool_t xdr_ufsd_log_data_t(); +extern bool_t xdr_ufsd_log_msg_t(); +extern bool_t xdr_ufsd_msg_vardata_t(); +extern bool_t xdr_ufsd_msg_t(); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_UFS_PROT_H_RPCGEN */ diff --git a/illumos-x86_64/usr/include/rpcsvc/ufs_prot.x b/illumos-x86_64/usr/include/rpcsvc/ufs_prot.x new file mode 100644 index 00000000..a7846f18 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/ufs_prot.x @@ -0,0 +1,154 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1994 by Sun Microsystems, Inc. + * All Rights Reserved + */ + +%#include +%#include +%#include + +enum ufsdrc_t { + UFSDRC_OK = 0, + UFSDRC_NOENT = ENOENT, /* can't find fsck */ + UFSDRC_PERM = EPERM, /* no permissions */ + UFSDRC_INVAL = EINVAL, /* poorly formed args */ + UFSDRC_NOEXEC = ENOEXEC, /* can't exec fsck */ + UFSDRC_NODEV = ENODEV, /* invalid file system id */ + UFSDRC_NXIO = ENXIO, /* bad special device */ + UFSDRC_BUSY = EBUSY, /* another fsck in progress */ + UFSDRC_OPNOTSUP = EOPNOTSUPP, /* daemons mode makes this unfeasible */ + UFSDRC_EXECERR = 254, /* fsck/child ran but had an error */ + UFSDRC_ERR = 255 /* generic error */ +}; + +struct fs_identity_t { + dev_t fs_dev; + string fs_name; +}; + +struct ufsd_repairfs_args_t { + fs_identity_t ua_fsid; + unsigned int ua_attempts; +}; + +struct ufsd_repairfs_list_t { + int ual_listlen; + ufsd_repairfs_args_t *ual_list; +}; + +enum ufsd_event_t { + UFSDEV_NONE = 0, + UFSDEV_REBOOT, + UFSDEV_FSCK, + UFSDEV_LOG_OP +}; + +enum ufsd_boot_type_t { + UFSDB_NONE = 0, + UFSDB_CLEAN, + UFSDB_POSTPANIC +}; + +enum ufsd_log_op_t { + UFSDLO_NONE = 0, + UFSDLO_COMMIT, + UFSDLO_GET, + UFSDLO_PUT, + UFSDLO_RESET +}; + +enum ufsd_fsck_state_t { + UFSDFS_NONE = 0, + UFSDFS_DISPATCH, + UFSDFS_ERREXIT, + UFSDFS_SUCCESS +}; + +const UFSD_VARMSGMAX = 1024; +const UFSD_SPAREMSGBYTES = 4; +struct ufsd_log_data_t { + int umld_eob; + int umld_seq; + char umld_buf; + +}; + +union ufsd_log_msg_t switch (ufsd_log_op_t um_lop) { +case UFSDLO_COMMIT: + void; +case UFSDLO_GET: + void; +case UFSDLO_PUT: + ufsd_log_data_t um_logdata; +case UFSDLO_RESET: + void; +default: + void; +}; + +union ufsd_msg_vardata_t switch (ufsd_event_t umv_ev) { +case UFSDEV_NONE: + void; +case UFSDEV_REBOOT: + ufsd_boot_type_t umv_b; +case UFSDEV_FSCK: + ufsd_fsck_state_t umv_fs; +case UFSDEV_LOG_OP: + ufsd_log_msg_t umv_lm; +default: + void; +}; + +struct ufsd_msg_t { + time_t um_time; + unsigned int um_from; + char um_spare; + ufsd_msg_vardata_t um_var; +}; + +%#define UFSD_SERVNAME "ufsd" +%#define xdr_dev_t xdr_u_int +%#define xdr_time_t xdr_int + +%/* +% * Set UFSD_THISVERS to the newest version of the protocol +% * This allows the preprocessor to force an error if the +% * protocol changes, since the kernel xdr routines may need to be +% * recoded. Note that we can't explicitly set the version to a +% * symbol as rpcgen will then create erroneous routine names. +% */ +%#define UFSD_V1 1 +%#define UFSD_ORIGVERS UFSD_V1 +%#define UFSD_THISVERS 1 + +program UFSD_PROG { + version UFSD_VERS { + ufsdrc_t UFSD_NULL(void) = 0; + ufsdrc_t UFSD_REPAIRFS(ufsd_repairfs_args_t) = 1; + ufsdrc_t UFSD_REPAIRFSLIST(ufsd_repairfs_list_t) = 2; + ufsdrc_t UFSD_SEND(ufsd_msg_t) = 3; + ufsdrc_t UFSD_RECV(ufsd_msg_t) = 4; + ufsdrc_t UFSD_EXIT(void) = 5; + } = 1; +} = 100233; diff --git a/illumos-x86_64/usr/include/rpcsvc/yp.x b/illumos-x86_64/usr/include/rpcsvc/yp.x new file mode 100644 index 00000000..86d50cd3 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/yp.x @@ -0,0 +1,288 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * yp.x + * + * Copyright (c) 1988-1992 Sun Microsystems Inc + * All Rights Reserved. + */ + +/* + * Protocol description file for the Network Information Services + */ + +const YPMAXRECORD = 1024; +const YPMAXDOMAIN = 256; +const YPMAXMAP = 64; +const YPMAXPEER = 64; + + +enum ypstat { + YP_TRUE = 1, + YP_NOMORE = 2, + YP_FALSE = 0, + YP_NOMAP = -1, + YP_NODOM = -2, + YP_NOKEY = -3, + YP_BADOP = -4, + YP_BADDB = -5, + YP_YPERR = -6, + YP_BADARGS = -7, + YP_VERS = -8 +}; + + +enum ypxfrstat { + YPXFR_SUCC = 1, + YPXFR_AGE = 2, + YPXFR_NOMAP = -1, + YPXFR_NODOM = -2, + YPXFR_RSRC = -3, + YPXFR_RPC = -4, + YPXFR_MADDR = -5, + YPXFR_YPERR = -6, + YPXFR_BADARGS = -7, + YPXFR_DBM = -8, + YPXFR_FILE = -9, + YPXFR_SKEW = -10, + YPXFR_CLEAR = -11, + YPXFR_FORCE = -12, + YPXFR_XFRERR = -13, + YPXFR_REFUSED = -14 +}; + + +typedef string domainname; +typedef string mapname; +typedef string peername; +typedef opaque keydat; +typedef opaque valdat; + + +struct ypmap_parms { + domainname domain; + mapname map; + unsigned int ordernum; + peername peer; +}; + +struct ypreq_key { + domainname domain; + mapname map; + keydat key; +}; + +struct ypreq_nokey { + domainname domain; + mapname map; +}; + +struct ypreq_xfr { + ypmap_parms map_parms; + unsigned int transid; + unsigned int prog; + unsigned int port; +}; + + +struct ypresp_val { + ypstat stat; + valdat val; +}; + +struct ypresp_key_val { + ypstat stat; + valdat val; + keydat key; +}; + + +struct ypresp_master { + ypstat stat; + peername peer; +}; + +struct ypresp_order { + ypstat stat; + unsigned int ordernum; +}; + +union ypresp_all switch (bool more) { +case TRUE: + ypresp_key_val val; +case FALSE: + void; +}; + +struct ypresp_xfr { + unsigned int transid; + ypxfrstat xfrstat; +}; + +struct ypmaplist { + mapname map; + ypmaplist *next; +}; + +struct ypresp_maplist { + ypstat stat; + ypmaplist *maps; +}; + +enum yppush_status { + YPPUSH_SUCC = 1, /* Success */ + YPPUSH_AGE = 2, /* Master's version not newer */ + YPPUSH_NOMAP = -1, /* Can't find server for map */ + YPPUSH_NODOM = -2, /* Domain not supported */ + YPPUSH_RSRC = -3, /* Local resource alloc failure */ + YPPUSH_RPC = -4, /* RPC failure talking to server */ + YPPUSH_MADDR = -5, /* Can't get master address */ + YPPUSH_YPERR = -6, /* NIS server/map db error */ + YPPUSH_BADARGS = -7, /* Request arguments bad */ + YPPUSH_DBM = -8, /* Local dbm operation failed */ + YPPUSH_FILE = -9, /* Local file I/O operation failed */ + YPPUSH_SKEW = -10, /* Map version skew during transfer */ + YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ + YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ + YPPUSH_XFRERR = -13, /* ypxfr error */ + YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ +}; + +struct yppushresp_xfr { + unsigned transid; + yppush_status status; +}; + +/* + * Response structure and overall result status codes. Success and failure + * represent two separate response message types. + */ + +enum ypbind_resptype { + YPBIND_SUCC_VAL = 1, + YPBIND_FAIL_VAL = 2 +}; + +struct ypbind_binding { + opaque ypbind_binding_addr[4]; /* In network order */ + opaque ypbind_binding_port[2]; /* In network order */ +}; + +union ypbind_resp switch (ypbind_resptype ypbind_status) { +case YPBIND_FAIL_VAL: + unsigned ypbind_error; +case YPBIND_SUCC_VAL: + ypbind_binding ypbind_bindinfo; +}; + +/* Detailed failure reason codes for response field ypbind_error*/ + +const YPBIND_ERR_ERR = 1; /* Internal error */ +const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ +const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ + + +/* + * Request data structure for ypbind "Set domain" procedure. + */ +struct ypbind_setdom { + domainname ypsetdom_domain; + ypbind_binding ypsetdom_binding; + unsigned ypsetdom_vers; +}; + + +/* + * NIS access protocol + */ +program YPPROG { + version YPVERS { + void + YPPROC_NULL(void) = 0; + + bool + YPPROC_DOMAIN(domainname) = 1; + + bool + YPPROC_DOMAIN_NONACK(domainname) = 2; + + ypresp_val + YPPROC_MATCH(ypreq_key) = 3; + + ypresp_key_val + YPPROC_FIRST(ypreq_key) = 4; + + ypresp_key_val + YPPROC_NEXT(ypreq_key) = 5; + + ypresp_xfr + YPPROC_XFR(ypreq_xfr) = 6; + + void + YPPROC_CLEAR(void) = 7; + + ypresp_all + YPPROC_ALL(ypreq_nokey) = 8; + + ypresp_master + YPPROC_MASTER(ypreq_nokey) = 9; + + ypresp_order + YPPROC_ORDER(ypreq_nokey) = 10; + + ypresp_maplist + YPPROC_MAPLIST(domainname) = 11; + } = 2; +} = 100004; + + +/* + * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR + */ +program YPPUSH_XFRRESPPROG { + version YPPUSH_XFRRESPVERS { + void + YPPUSHPROC_NULL(void) = 0; + + yppushresp_xfr + YPPUSHPROC_XFRRESP(void) = 1; + } = 1; +} = 0x40000000; /* transient: could be anything up to 0x5fffffff */ + + +/* + * NIS binding protocol + */ +program YPBINDPROG { + version YPBINDVERS { + void + YPBINDPROC_NULL(void) = 0; + + ypbind_resp + YPBINDPROC_DOMAIN(domainname) = 1; + + void + YPBINDPROC_SETDOM(ypbind_setdom) = 2; + } = 2; +} = 100007; + + diff --git a/illumos-x86_64/usr/include/rpcsvc/yp_prot.h b/illumos-x86_64/usr/include/rpcsvc/yp_prot.h new file mode 100644 index 00000000..f7e5dff5 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/yp_prot.h @@ -0,0 +1,384 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _RPCSVC_YP_PROT_H +#define _RPCSVC_YP_PROT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains symbols and structures defining the rpc protocol + * between the YP clients and the YP servers. The servers are the YP + * database servers, and the YP. + */ + +/* + * The following procedures are supported by the protocol: + * + * YPPROC_NULL() returns () takes nothing, returns nothing. This indicates + * that the yp server is alive. + * + * YPPROC_DOMAIN (char *) returns (bool_t) TRUE. Indicates that the + * responding yp server does serve the named domain; FALSE indicates no + * support. + * + * YPPROC_DOMAIN_NONACK (char *) returns (TRUE) if the yp server does serve + * the named domain, otherwise does not return. Used in the broadcast case. + * + * YPPROC_MATCH (struct ypreq_key) returns (struct ypresp_val). Returns the + * right-hand value for a passed left-hand key, within a named map and + * domain. + * + * YPPROC_FIRST (struct ypreq_nokey) returns (struct ypresp_key_val). + * Returns the first key-value pair from a named domain and map. + * + * YPPROC_NEXT (struct ypreq_key) returns (struct ypresp_key_val). Returns + * the key-value pair following a passed key-value pair within a named + * domain and map. + * + * YPPROC_XFR (struct ypreq_xfr) returns nothing. Indicates to a server that + * a map should be updated. + * + * YPPROC_NEWXFR (struct ypreq_newxfr) returns nothing. Indicates to a server + * that a map should be updated. Uses protocol independent request struct. + * + * YPPROC_CLEAR takes nothing, returns nothing. Instructs a yp server to + * close the current map, so that old versions of the disk file don't get + * held open. + * + * YPPROC_ALL (struct ypreq_nokey), returns + * union switch (bool more) { + * TRUE: (struct ypresp_key_val); + * FALSE: (struct) {}; + * } + * + * YPPROC_MASTER (struct ypreq_nokey), returns (ypresp_master) + * + * YPPROC_ORDER (struct ypreq_nokey), returns (ypresp_order) + * + * YPPROC_MAPLIST (char *), returns (struct ypmaplist *) + */ + +/* 'bool' is a built-in type for g++ */ +#if !(defined(__cplusplus) && defined(_BOOL)) && !defined(__GNUG__) +#ifndef BOOL_DEFINED +typedef unsigned int bool; +#define BOOL_DEFINED +#endif +#endif + +/* Program and version symbols, magic numbers */ + +#define YPPROG ((rpcprog_t)100004) +#define YPVERS ((rpcvers_t)2) +#define YPVERS_ORIG ((rpcvers_t)1) +#define YPMAXRECORD ((uint_t)1024) +#define YPMAXDOMAIN ((uint_t)256) +#define YPMAXMAP ((uint_t)64) +#define YPMAXPEER ((uint_t)256) + +/* byte size of a large yp packet */ +#define YPMSGSZ 1600 + +struct ypmap_parms { + char *domain; /* Null string means not available */ + char *map; /* Null string means not available */ + unsigned int ordernum; /* 0 means not available */ + char *owner; /* Null string means not available */ +}; + +/* + * Request parameter structures + */ + +struct ypreq_key { + char *domain; + char *map; + datum keydat; +}; + +struct ypreq_nokey { + char *domain; + char *map; +}; + +struct ypreq_xfr { + struct ypmap_parms map_parms; + unsigned int transid; + unsigned int proto; + unsigned short port; +}; + +struct ypreq_newxfr { + struct ypmap_parms map_parms; + unsigned int transid; + unsigned int proto; + char *name; +}; + +#define ypxfr_domain map_parms.domain +#define ypxfr_map map_parms.map +#define ypxfr_ordernum map_parms.ordernum +#define ypxfr_owner map_parms.owner + +/* + * Response parameter structures + */ + +struct ypresp_val { + unsigned int status; + datum valdat; +}; + +struct ypresp_key_val { + unsigned int status; + datum valdat; + datum keydat; +}; + +struct ypresp_master { + unsigned int status; + char *master; +}; + +struct ypresp_order { + unsigned int status; + unsigned int ordernum; +}; + +struct ypmaplist { + char ypml_name[YPMAXMAP + 1]; + struct ypmaplist *ypml_next; +}; + +struct ypresp_maplist { + unsigned int status; + struct ypmaplist *list; +}; + +/* + * Procedure symbols. YPPROC_NULL, YPPROC_DOMAIN, and YPPROC_DOMAIN_NONACK + * must keep the same values (0, 1, and 2) that they had in the first version + * of the protocol. + */ + +#define YPPROC_NULL ((rpcproc_t)0) +#define YPPROC_DOMAIN ((rpcproc_t)1) +#define YPPROC_DOMAIN_NONACK ((rpcproc_t)2) +#define YPPROC_MATCH ((rpcproc_t)3) +#define YPPROC_FIRST ((rpcproc_t)4) +#define YPPROC_NEXT ((rpcproc_t)5) +#define YPPROC_XFR ((rpcproc_t)6) +#define YPPROC_NEWXFR ((rpcproc_t)12) +#define YPPROC_CLEAR ((rpcproc_t)7) +#define YPPROC_ALL ((rpcproc_t)8) +#define YPPROC_MASTER ((rpcproc_t)9) +#define YPPROC_ORDER ((rpcproc_t)10) +#define YPPROC_MAPLIST ((rpcproc_t)11) + +/* Return status values */ + +#define YP_TRUE (1) /* General purpose success code */ +#define YP_NOMORE (2) /* No more entries in map */ +#define YP_FALSE (0) /* General purpose failure code */ +#define YP_NOMAP (-1) /* No such map in domain */ +#define YP_NODOM (-2) /* Domain not supported */ +#define YP_NOKEY (-3) /* No such key in map */ +#define YP_BADOP (-4) /* Invalid operation */ +#define YP_BADDB (-5) /* Server data base is bad */ +#define YP_YPERR (-6) /* YP server error */ +#define YP_BADARGS (-7) /* Request arguments bad */ +#define YP_VERS (-8) /* YP server vers. mismatch - server */ + /* can't supply requested service. */ + +enum ypreqtype {YPREQ_KEY = 1, YPREQ_NOKEY = 2, YPREQ_MAP_PARMS = 3}; +struct yprequest { + enum ypreqtype yp_reqtype; + union { + struct ypreq_key yp_req_keytype; + struct ypreq_nokey yp_req_nokeytype; + struct ypmap_parms yp_req_map_parmstype; + }yp_reqbody; +}; + +#define YPMATCH_REQTYPE YPREQ_KEY +#define ypmatch_req_domain yp_reqbody.yp_req_keytype.domain +#define ypmatch_req_map yp_reqbody.yp_req_keytype.map +#define ypmatch_req_keydat yp_reqbody.yp_req_keytype.keydat +#define ypmatch_req_keyptr yp_reqbody.yp_req_keytype.keydat.dptr +#define ypmatch_req_keysize yp_reqbody.yp_req_keytype.keydat.dsize + +#define YPFIRST_REQTYPE YPREQ_NOKEY +#define ypfirst_req_domain yp_reqbody.yp_req_nokeytype.domain +#define ypfirst_req_map yp_reqbody.yp_req_nokeytype.map + +#define YPNEXT_REQTYPE YPREQ_KEY +#define ypnext_req_domain yp_reqbody.yp_req_keytype.domain +#define ypnext_req_map yp_reqbody.yp_req_keytype.map +#define ypnext_req_keydat yp_reqbody.yp_req_keytype.keydat +#define ypnext_req_keyptr yp_reqbody.yp_req_keytype.keydat.dptr +#define ypnext_req_keysize yp_reqbody.yp_req_keytype.keydat.dsize + +#define YPPUSH_REQTYPE YPREQ_NOKEY +#define yppush_req_domain yp_reqbody.yp_req_nokeytype.domain +#define yppush_req_map yp_reqbody.yp_req_nokeytype.map + +#define YPPULL_REQTYPE YPREQ_NOKEY +#define yppull_req_domain yp_reqbody.yp_req_nokeytype.domain +#define yppull_req_map yp_reqbody.yp_req_nokeytype.map + +#define YPPOLL_REQTYPE YPREQ_NOKEY +#define yppoll_req_domain yp_reqbody.yp_req_nokeytype.domain +#define yppoll_req_map yp_reqbody.yp_req_nokeytype.map + +#define YPGET_REQTYPE YPREQ_MAP_PARMS +#define ypget_req_domain yp_reqbody.yp_req_map_parmstype.domain +#define ypget_req_map yp_reqbody.yp_req_map_parmstype.map +#define ypget_req_ordernum yp_reqbody.yp_req_map_parmstype.ordernum +#define ypget_req_owner yp_reqbody.yp_req_map_parmstype.owner + +enum ypresptype {YPRESP_VAL = 1, YPRESP_KEY_VAL = 2, YPRESP_MAP_PARMS = 3}; +struct ypresponse { + enum ypresptype yp_resptype; + union { + struct ypresp_val yp_resp_valtype; + struct ypresp_key_val yp_resp_key_valtype; + struct ypmap_parms yp_resp_map_parmstype; + } yp_respbody; +}; + +#define YPMATCH_RESPTYPE YPRESP_VAL +#define ypmatch_resp_status yp_respbody.yp_resp_valtype.status +#define ypmatch_resp_valdat yp_respbody.yp_resp_valtype.valdat +#define ypmatch_resp_valptr yp_respbody.yp_resp_valtype.valdat.dptr +#define ypmatch_resp_valsize yp_respbody.yp_resp_valtype.valdat.dsize + +#define YPFIRST_RESPTYPE YPRESP_KEY_VAL +#define ypfirst_resp_status yp_respbody.yp_resp_key_valtype.status +#define ypfirst_resp_keydat yp_respbody.yp_resp_key_valtype.keydat +#define ypfirst_resp_keyptr yp_respbody.yp_resp_key_valtype.keydat.dptr +#define ypfirst_resp_keysize yp_respbody.yp_resp_key_valtype.keydat.dsize +#define ypfirst_resp_valdat yp_respbody.yp_resp_key_valtype.valdat +#define ypfirst_resp_valptr yp_respbody.yp_resp_key_valtype.valdat.dptr +#define ypfirst_resp_valsize yp_respbody.yp_resp_key_valtype.valdat.dsize + +#define YPNEXT_RESPTYPE YPRESP_KEY_VAL +#define ypnext_resp_status yp_respbody.yp_resp_key_valtype.status +#define ypnext_resp_keydat yp_respbody.yp_resp_key_valtype.keydat +#define ypnext_resp_keyptr yp_respbody.yp_resp_key_valtype.keydat.dptr +#define ypnext_resp_keysize yp_respbody.yp_resp_key_valtype.keydat.dsize +#define ypnext_resp_valdat yp_respbody.yp_resp_key_valtype.valdat +#define ypnext_resp_valptr yp_respbody.yp_resp_key_valtype.valdat.dptr +#define ypnext_resp_valsize yp_respbody.yp_resp_key_valtype.valdat.dsize + +#define YPPOLL_RESPTYPE YPRESP_MAP_PARMS +#define yppoll_resp_domain yp_respbody.yp_resp_map_parmstype.domain +#define yppoll_resp_map yp_respbody.yp_resp_map_parmstype.map +#define yppoll_resp_ordernum yp_respbody.yp_resp_map_parmstype.ordernum +#define yppoll_resp_owner yp_respbody.yp_resp_map_parmstype.owner + + +extern bool _xdr_yprequest(); +extern bool _xdr_ypresponse(); +/* + * Protocol between clients (ypxfr, only) and yppush + * yppush speaks a protocol in the transient range, which + * is supplied to ypxfr as a command-line parameter when it + * is activated by ypserv. + */ +#define YPPUSHVERS ((rpcvers_t)1) +#define YPPUSHVERS_ORIG ((rpcvers_t)1) + +/* Procedure symbols */ + +#define YPPUSHPROC_NULL ((rpcproc_t)0) +#define YPPUSHPROC_XFRRESP ((rpcproc_t)1) + +struct yppushresp_xfr { + unsigned int transid; + unsigned int status; +}; + +/* Status values for yppushresp_xfr.status */ + +#define YPPUSH_SUCC (1) /* Success */ +#define YPPUSH_AGE (2) /* Master's version not newer */ +#define YPPUSH_NOMAP (-1) /* Can't find server for map */ +#define YPPUSH_NODOM (-2) /* Domain not supported */ +#define YPPUSH_RSRC (-3) /* Local resouce alloc failure */ +#define YPPUSH_RPC (-4) /* RPC failure talking to server */ +#define YPPUSH_MADDR (-5) /* Can't get master address */ +#define YPPUSH_YPERR (-6) /* YP server/map db error */ +#define YPPUSH_BADARGS (-7) /* Request arguments bad */ +#define YPPUSH_DBM (-8) /* Local dbm operation failed */ +#define YPPUSH_FILE (-9) /* Local file I/O operation failed */ +#define YPPUSH_SKEW (-10) /* Map version skew during transfer */ +#define YPPUSH_CLEAR (-11) /* Can't send "Clear" req to local */ + /* ypserv */ +#define YPPUSH_FORCE (-12) /* No local order number in map - */ + /* use -f flag. */ +#define YPPUSH_XFRERR (-13) /* ypxfr error */ +#define YPPUSH_REFUSED (-14) /* Transfer request refused by ypserv */ +#define YPPUSH_NOALIAS (-15) /* Alias not found for map or domain */ + +extern bool xdr_datum(XDR *, datum *); +extern bool xdr_ypdomain_wrap_string(XDR *, char **); +extern bool xdr_ypmap_wrap_string(XDR *, char **); +extern bool xdr_ypreq_key(XDR *, struct ypreq_key *); +extern bool xdr_ypreq_nokey(XDR *, struct ypreq_nokey *); +extern bool xdr_ypreq_xfr(XDR *, struct ypreq_xfr *); +extern bool xdr_ypreq_newxfr(XDR *, struct ypreq_newxfr *); +extern bool xdr_ypresp_val(XDR *, struct ypresp_val *); +extern bool xdr_ypresp_key_val(XDR *, struct ypresp_key_val *); +extern bool xdr_ypmap_parms(XDR *, struct ypmap_parms *); +extern bool xdr_ypowner_wrap_string(XDR *, char **); +extern bool xdr_yppushresp_xfr(XDR *, struct yppushresp_xfr *); +extern bool xdr_ypresp_order(XDR *, struct ypresp_order *); +extern bool xdr_ypresp_master(XDR *, struct ypresp_master *); +extern bool xdr_ypall(XDR *, struct ypall_callback *); +extern bool xdr_ypresp_maplist(XDR *, struct ypresp_maplist *); + +#ifdef __cplusplus +} +#endif + +#endif /* _RPCSVC_YP_PROT_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/ypclnt.h b/illumos-x86_64/usr/include/rpcsvc/ypclnt.h new file mode 100644 index 00000000..9bbe3e94 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/ypclnt.h @@ -0,0 +1,124 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1989 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _RPCSVC_YPCLNT_H +#define _RPCSVC_YPCLNT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ypclnt.h + * This defines the symbols used in the c language + * interface to the yp client functions. A description of this interface + * can be read in ypclnt(3NSL). + */ + +/* + * Failure reason codes. The success condition is indicated by a functional + * value of "0". + */ +#define YPERR_BADARGS 1 /* Args to function are bad */ +#define YPERR_RPC 2 /* RPC failure */ +#define YPERR_DOMAIN 3 /* Can't bind to a server which */ + /* serves this domain. */ +#define YPERR_MAP 4 /* No such map in server's domain */ +#define YPERR_KEY 5 /* No such key in map */ +#define YPERR_YPERR 6 /* Internal yp server or client */ + /* interface error */ +#define YPERR_RESRC 7 /* Local resource allocation failure */ +#define YPERR_NOMORE 8 /* No more records in map database */ +#define YPERR_PMAP 9 /* Can't communicate with portmapper */ +#define YPERR_YPBIND 10 /* Can't communicate with ypbind */ +#define YPERR_YPSERV 11 /* Can't communicate with ypserv */ +#define YPERR_NODOM 12 /* Local domain name not set */ +#define YPERR_BADDB 13 /* yp data base is bad */ +#define YPERR_VERS 14 /* YP version mismatch */ +#define YPERR_ACCESS 15 /* Access violation */ +#define YPERR_BUSY 16 /* Database is busy */ + +/* + * Types of update operations + */ +#define YPOP_CHANGE 1 /* change, do not add */ +#define YPOP_INSERT 2 /* add, do not change */ +#define YPOP_DELETE 3 /* delete this entry */ +#define YPOP_STORE 4 /* add, or change */ + + + +/* + * Data definitions + */ + +/* + * struct ypall_callback * is the arg which must be passed to yp_all + */ + +struct ypall_callback { + int (*foreach)(); /* Return non-0 to stop getting */ + /* called */ + char *data; /* Opaque pointer for use of callback */ + /* function */ +}; + +/* + * External yp client function references. + */ + +extern int yp_bind(char *); +extern void yp_unbind(char *); +extern int yp_get_default_domain(char **); +extern int yp_match(char *, char *, char *, int, char **, int *); +extern int yp_first(char *, char *, char **, int *, char **, int *); +extern int yp_next(char *, char *, char *, int, char **, int *, char **, int *); +extern int yp_master(char *, char *, char **); +extern int yp_order(char *, char *, unsigned long *); +extern int yp_all(char *, char *, struct ypall_callback *); +extern char *yperr_string(int); +extern int ypprot_err(int); +extern int yp_update(char *, char *, unsigned, char *, int, char *, int); + +/* + * Global yp data structures + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RPCSVC_YPCLNT_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/yppasswd.h b/illumos-x86_64/usr/include/rpcsvc/yppasswd.h new file mode 100644 index 00000000..a89d1061 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/yppasswd.h @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1985 by Sun Microsystems, Inc. + * + */ + + +#ifndef _RPCSVC_YPPASSWD_H +#define _RPCSVC_YPPASSWD_H + +#ifndef _PWD_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define YPPASSWDPROG ((rpcprog_t)100009) +#define YPPASSWDVERS ((rpcvers_t)1) +#define YPPASSWDPROC_UPDATE ((rpcproc_t)1) + +struct yppasswd { + char *oldpass; /* old (unencrypted) password */ + struct passwd newpw; /* new pw structure */ +}; + +int xdr_yppasswd(); + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPCSVC_YPPASSWD_H */ diff --git a/illumos-x86_64/usr/include/rpcsvc/ypupd.h b/illumos-x86_64/usr/include/rpcsvc/ypupd.h new file mode 100644 index 00000000..8f089648 --- /dev/null +++ b/illumos-x86_64/usr/include/rpcsvc/ypupd.h @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _RPCSVC_YPUPD_H +#define _RPCSVC_YPUPD_H + +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Compiled from ypupdate_prot.x using rpcgen + * This is NOT source code! + * DO NOT EDIT THIS FILE! + */ +#define MAXMAPNAMELEN 255 +#define MAXYPDATALEN 1023 +#define MAXERRMSGLEN 255 + +#define YPU_PROG ((ulong_t)100028) +#define YPU_VERS ((ulong_t)1) +#define YPU_CHANGE ((ulong_t)1) +extern uint_t *ypu_change_1(); +#define YPU_INSERT ((ulong_t)2) +extern uint_t *ypu_insert_1(); +#define YPU_DELETE ((ulong_t)3) +extern uint_t *ypu_delete_1(); +#define YPU_STORE ((ulong_t)4) +extern uint_t *ypu_store_1(); + +typedef struct { + uint_t yp_buf_len; + char *yp_buf_val; +} yp_buf; +bool_t xdr_yp_buf(); + +struct ypupdate_args { + char *mapname; + yp_buf key; + yp_buf datum; +}; +typedef struct ypupdate_args ypupdate_args; +bool_t xdr_ypupdate_args(); + +struct ypdelete_args { + char *mapname; + yp_buf key; +}; +typedef struct ypdelete_args ypdelete_args; +bool_t xdr_ypdelete_args(); + +#ifdef __cplusplus +} +#endif + +#endif /* _RPCSVC_YPUPD_H */ diff --git a/illumos-x86_64/usr/include/rsmapi.h b/illumos-x86_64/usr/include/rsmapi.h new file mode 100644 index 00000000..b4dcfb2c --- /dev/null +++ b/illumos-x86_64/usr/include/rsmapi.h @@ -0,0 +1,295 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _RSMAPI_H +#define _RSMAPI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +typedef enum { + RSM_MAP_NONE = 0x0, + RSM_MAP_FIXED = 0x1, + RSM_MAP_RESERVED = 0x2 +}rsm_attribute_t; + +/* + * Topology data structures - The primary structure is struct rsm_topology_t + * + * The key interconnect data required for segment operations includes the + * cluster nodeids and the controllers (name, hardware address); with + * the fundamental constraint that the controller specified for a segment + * import must have a physical connection with the contorller used in the + * export of the segment. To facilitate applications in the establishment + * of proper and efficient export and import policies, a delineation of the + * interconnect topology is provided by these data structures. + * + */ + + +#define RSM_CONNECTION_ACTIVE 3 + + +typedef struct rsm_topology_hdr { + rsm_node_id_t local_nodeid; + uint_t local_cntlr_count; +} rsm_topology_hdr_t; + + +typedef struct rsm_connections_hdr { + char cntlr_name[MAXNAMELEN]; /* */ + rsm_addr_t local_hwaddr; + int remote_cntlr_count; +} rsm_connections_hdr_t; + + +/* + * The remote cntrlname element should be used for matching with the + * cntrlname of an exported segment. + * + * An application must not attempt to use a connection unless the + * the connection_state element of struct rsm_remote_cntlr_t is equal to + * RSM_CONNECTION_ACTIVE + */ +typedef struct rsm_remote_cntlr { + rsm_node_id_t remote_nodeid; + char remote_cntlrname[MAXNAMELEN]; + rsm_addr_t remote_hwaddr; + uint_t connection_state; +} rsm_remote_cntlr_t; + + +/* + * The actual size of the remote_cntlr array is equal to the remote_cntlr_count + * of the rsm_connections_hdr_t struct. + */ +typedef struct rsm_connection { + rsm_connections_hdr_t hdr; + rsm_remote_cntlr_t remote_cntlr[1]; +} rsm_connections_t; + + +/* + * A pointer to an instance of this structure type is returned by a call + * to rsm_get_interconnect_topology(). The actual size of the connections + * array is equal to the local_cntlr_count of the rsm_topology_hdr_t struct. + */ +typedef struct rsm_topology { + rsm_topology_hdr_t topology_hdr; + rsm_connections_t *connections[1]; +} rsm_topology_t; + +/* + * function templates: + */ + +int rsm_get_controller(char *name, rsmapi_controller_handle_t *controller); + +int rsm_get_controller_attr(rsmapi_controller_handle_t chdl, + rsmapi_controller_attr_t *attr); + +int rsm_release_controller(rsmapi_controller_handle_t controller); + +/* + * Export side memory segment operations + */ +int rsm_memseg_export_create(rsmapi_controller_handle_t controller, + rsm_memseg_export_handle_t *memseg, + void *vaddr, size_t size, uint_t flags); + + +int rsm_memseg_export_destroy(rsm_memseg_export_handle_t memseg); + + + +int rsm_memseg_export_rebind(rsm_memseg_export_handle_t memseg, + void *vaddr, offset_t off, size_t size); + + + +int rsm_memseg_export_publish(rsm_memseg_export_handle_t memseg, + rsm_memseg_id_t *segment_id, + rsmapi_access_entry_t access_list[], + uint_t access_list_length); + + +int rsm_memseg_export_unpublish(rsm_memseg_export_handle_t memseg); + +int rsm_memseg_export_republish(rsm_memseg_export_handle_t memseg, + rsmapi_access_entry_t access_list[], + uint_t access_list_length); + + + + + + + +/* + * import side memory segment operations: + */ + +int rsm_memseg_import_connect(rsmapi_controller_handle_t controller, + rsm_node_id_t node_id, + rsm_memseg_id_t segment_id, + rsm_permission_t perm, + rsm_memseg_import_handle_t *im_memseg); + + +int rsm_memseg_import_disconnect(rsm_memseg_import_handle_t im_memseg); + + + +/* + * import side memory segment operations (read access functions): + */ +int rsm_memseg_import_get8(rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint8_t *datap, + ulong_t rep_cnt); +int rsm_memseg_import_get16(rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint16_t *datap, + ulong_t rep_cnt); +int rsm_memseg_import_get32(rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint32_t *datap, + ulong_t rep_cnt); +int rsm_memseg_import_get64(rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint64_t *datap, + ulong_t rep_cnt); +int rsm_memseg_import_get(rsm_memseg_import_handle_t im_memseg, + off_t offset, + void *dst_addr, + size_t length); + +int rsm_memseg_import_getv(rsm_scat_gath_t *); + + + +/* + * import side memory segment operations (write access functions): + */ +int rsm_memseg_import_put8(rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint8_t *datap, + ulong_t rep_cnt); +int rsm_memseg_import_put16(rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint16_t *datap, + ulong_t rep_cnt); +int rsm_memseg_import_put32(rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint32_t *datap, + ulong_t rep_cnt); +int rsm_memseg_import_put64(rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint64_t *datap, + ulong_t rep_cnt); +int rsm_memseg_import_put(rsm_memseg_import_handle_t im_memseg, + off_t offset, + void *src_addr, + size_t length); + +int rsm_memseg_import_putv(rsm_scat_gath_t *); + + +/* + * import side memory segment operations (mapping): + */ +int rsm_memseg_import_map(rsm_memseg_import_handle_t im_memseg, + void **address, + rsm_attribute_t attr, + rsm_permission_t perm, + off_t offset, size_t length); + + + + +int rsm_memseg_import_unmap(rsm_memseg_import_handle_t im_memseg); + + + +/* + * import side memory segment operations (barriers): + */ + +int rsm_memseg_import_init_barrier(rsm_memseg_import_handle_t im_memseg, + rsm_barrier_type_t type, + rsmapi_barrier_t *barrier); + + +int rsm_memseg_import_open_barrier(rsmapi_barrier_t *barrier); + + +int rsm_memseg_import_close_barrier(rsmapi_barrier_t *barrier); + +int rsm_memseg_import_order_barrier(rsmapi_barrier_t *barrier); + +int rsm_memseg_import_destroy_barrier(rsmapi_barrier_t *barrier); + +int rsm_memseg_import_get_mode(rsm_memseg_import_handle_t im_memseg, + rsm_barrier_mode_t *mode); + +int rsm_memseg_import_set_mode(rsm_memseg_import_handle_t im_memseg, + rsm_barrier_mode_t mode); + + + + +int rsm_intr_signal_post(void * im_memseg, uint_t flags); + +int rsm_intr_signal_wait(void * im_memseg, int timeout); + +int rsm_memseg_get_pollfd(void *, struct pollfd *); +int rsm_memseg_release_pollfd(void *); + +int rsm_get_interconnect_topology(rsm_topology_t **); +void rsm_free_interconnect_topology(rsm_topology_t *); + +int rsm_create_localmemory_handle(rsmapi_controller_handle_t, + rsm_localmemory_handle_t *, + caddr_t, size_t); + +int rsm_free_localmemory_handle(rsmapi_controller_handle_t, + rsm_localmemory_handle_t); + +int rsm_get_segmentid_range(const char *, rsm_memseg_id_t *, uint32_t *); + +int rsm_intr_signal_wait_pollfd(struct pollfd [], nfds_t, int, int *); + +#ifdef __cplusplus +} +#endif + +#endif /* _RSMAPI_H */ diff --git a/illumos-x86_64/usr/include/rtld_db.h b/illumos-x86_64/usr/include/rtld_db.h new file mode 100644 index 00000000..0bfe3005 --- /dev/null +++ b/illumos-x86_64/usr/include/rtld_db.h @@ -0,0 +1,194 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _RTLD_DB_H +#define _RTLD_DB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + + +/* + * librtld_db interface versions + */ +#define RD_VERSION1 1 +#define RD_VERSION2 2 +#define RD_VERSION3 3 +#define RD_VERSION4 4 +#define RD_VERSION RD_VERSION4 + +typedef enum { + RD_ERR, /* generic */ + RD_OK, /* generic "call" succeeded */ + RD_NOCAPAB, /* capability not available */ + RD_DBERR, /* import service failed */ + RD_NOBASE, /* 5.x: aux tag AT_BASE not found */ + RD_NODYNAM, /* symbol 'DYNAMIC' not found */ + RD_NOMAPS /* link-maps are not yet available */ +} rd_err_e; + + +/* + * ways that the event notification can take place: + */ +typedef enum { + RD_NOTIFY_BPT, /* set break-point at address */ + RD_NOTIFY_AUTOBPT, /* 4.x compat. not used in 5.x */ + RD_NOTIFY_SYSCALL /* watch for syscall */ +} rd_notify_e; + +/* + * information on ways that the event notification can take place: + */ +typedef struct rd_notify { + rd_notify_e type; + union { + psaddr_t bptaddr; /* break point address */ + long syscallno; /* system call id */ + } u; +} rd_notify_t; + +/* + * information about event instance: + */ +typedef enum { + RD_NOSTATE = 0, /* no state information */ + RD_CONSISTENT, /* link-maps are stable */ + RD_ADD, /* currently adding object to link-maps */ + RD_DELETE /* currently deleteing object from link-maps */ +} rd_state_e; + +typedef struct rd_event_msg { + rd_event_e type; + union { + rd_state_e state; /* for DLACTIVITY */ + } u; +} rd_event_msg_t; + + +/* + * iteration over load objects + */ +typedef struct rd_loadobj { + psaddr_t rl_nameaddr; /* address of the name in user space */ + unsigned rl_flags; + psaddr_t rl_base; /* base of address of code */ + psaddr_t rl_data_base; /* base of address of data */ + Lmid_t rl_lmident; /* ident of link map */ + psaddr_t rl_refnameaddr; /* reference name of filter in user */ + /* space. If non null object is a */ + /* filter. */ + psaddr_t rl_plt_base; /* These fields are present for 4.x */ + unsigned rl_plt_size; /* compatibility and are not */ + /* currently used in SunOS5.x */ + psaddr_t rl_bend; /* end of image (text+data+bss) */ + psaddr_t rl_padstart; /* start of padding */ + psaddr_t rl_padend; /* end of image after padding */ + psaddr_t rl_dynamic; /* points to the DYNAMIC section */ + /* in the target process */ + unsigned long rl_tlsmodid; /* module ID for TLS references */ +} rd_loadobj_t; + +/* + * Values for rl_flags + */ +#define RD_FLG_MEM_OBJECT 0x0001 /* Identifies this object as */ + /* originating from a relocatable */ + /* module which was dynamically */ + /* loaded */ + +/* + * Commands for rd_ctl() + */ +#define RD_CTL_SET_HELPPATH 0x01 /* Set the path used to find helpers */ + +typedef struct rd_agent rd_agent_t; +typedef int rl_iter_f(const rd_loadobj_t *, void *); + + +/* + * PLT skipping + */ +typedef enum { + RD_RESOLVE_NONE, /* don't do anything special */ + RD_RESOLVE_STEP, /* step 'pi_nstep' instructions */ + RD_RESOLVE_TARGET, /* resolved target is in 'pi_target' */ + RD_RESOLVE_TARGET_STEP /* put a bpt on target, then step nstep times */ +} rd_skip_e; + + +typedef struct rd_plt_info { + rd_skip_e pi_skip_method; + long pi_nstep; + psaddr_t pi_target; + psaddr_t pi_baddr; + unsigned int pi_flags; +} rd_plt_info_t; + + +/* + * Values for pi_flags + */ +#define RD_FLG_PI_PLTBOUND 0x0001 /* Indicates that the PLT */ + /* has been bound - and that */ + /* pi_baddr will contain its */ + /* destination address */ + +struct ps_prochandle; + +/* + * librtld_db.so entry points + */ +extern void rd_delete(rd_agent_t *); +extern char *rd_errstr(rd_err_e rderr); +extern rd_err_e rd_event_addr(rd_agent_t *, rd_event_e, rd_notify_t *); +extern rd_err_e rd_event_enable(rd_agent_t *, int); +extern rd_err_e rd_event_getmsg(rd_agent_t *, rd_event_msg_t *); +extern rd_err_e rd_init(int); +extern rd_err_e rd_ctl(int, void *); +extern rd_err_e rd_loadobj_iter(rd_agent_t *, rl_iter_f *, + void *); +extern void rd_log(const int); +extern rd_agent_t *rd_new(struct ps_prochandle *); +extern rd_err_e rd_objpad_enable(struct rd_agent *, size_t); +extern rd_err_e rd_plt_resolution(rd_agent_t *, psaddr_t, lwpid_t, + psaddr_t, rd_plt_info_t *); +extern rd_err_e rd_get_dyns(rd_agent_t *, psaddr_t, void **, size_t *); +extern rd_err_e rd_reset(struct rd_agent *); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTLD_DB_H */ diff --git a/illumos-x86_64/usr/include/sac.h b/illumos-x86_64/usr/include/sac.h new file mode 100644 index 00000000..0c6b0051 --- /dev/null +++ b/illumos-x86_64/usr/include/sac.h @@ -0,0 +1,152 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SAC_H +#define _SAC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define IDLEN 4 /* length in bytes of a utmp id */ +#define SC_WILDC 0xff /* wild character for utmp ids */ +#define PMTAGSIZE 14 /* maximum length in bytes for */ + /* a port monitor tag */ + +/* + * values for rflag in doconfig() + */ + +#define NOASSIGN 0x1 /* don't allow assign operations */ +#define NORUN 0x2 /* don't allow run or runwait operations */ + + +/* + * message to SAC (header only). This header is forever fixed. The + * size field (pm_size) defines the size of the data portion of the + * message, which follows the header. The form of this optional + * data portion is defined strictly by the message type (pm_type). + */ + +struct pmmsg { + char pm_type; /* type of message */ + uchar_t pm_state; /* current state of port monitor */ + char pm_maxclass; /* max message class this PM */ + /* understands */ + char pm_tag[PMTAGSIZE + 1]; /* port monitor's tag */ + int pm_size; /* size of optional data portion */ +}; + + + +/* + * pm_type values + */ + +#define PM_STATUS 1 /* status response */ +#define PM_UNKNOWN 2 /* an unknown message was received */ + +/* + * pm_state values + */ + +/* + * Class 1 responses + */ + +#define PM_STARTING 1 /* port monitor in starting state */ +#define PM_ENABLED 2 /* port monitor in enabled state */ +#define PM_DISABLED 3 /* port monitor in disabled state */ +#define PM_STOPPING 4 /* port monitor in stopping state */ + +/* + * message to port monitor + */ + +struct sacmsg { + int sc_size; /* size of optional data portion */ + char sc_type; /* type of message */ +}; + + + +/* + * sc_type values + * These represent commands that the SAC sends to a port monitor. These + * commands are divided into "classes" for extensibility. Each subsequent + * "class" is a superset of the previous "classes" plus the new commands + * defined within that "class". The header for all commands is identical; + * however, a command may be defined such that an optional data portion may + * be sent in addition to the header. The format of this optional data piece + * is self-defining based on the command. Important note: the first message + * sent by the SAC will always be a class 1 message. The port monitor + * response will indicate the maximum class that it is able to understand. + * Another note is that port monitors should only respond to a message with + * an equivalent class response (i.e. a class 1 command causes a class 1 + * response). + */ + +/* + * Class 1 commands (currently, there are only class 1 commands) + */ + +#define SC_STATUS 1 /* status request */ +#define SC_ENABLE 2 /* enable request */ +#define SC_DISABLE 3 /* disable request */ +#define SC_READDB 4 /* read pmtab request */ + +/* + * `errno' values for Saferrno, note that Saferrno is used by + * both pmadm and sacadm and these values are shared between + * them + */ + +#define E_BADARGS 1 /* bad args or ill-formed command line */ +#define E_NOPRIV 2 /* user not privileged for operation */ +#define E_SAFERR 3 /* generic SAF error */ +#define E_SYSERR 4 /* system error */ +#define E_NOEXIST 5 /* invalid specification */ +#define E_DUP 6 /* entry already exists */ +#define E_PMRUN 7 /* port monitor is running */ +#define E_PMNOTRUN 8 /* port monitor is not running */ +#define E_RECOVER 9 /* in recovery */ +#define E_SACNOTRUN 10 /* sac daemon is not running */ + +extern int doconfig(int, char *, long); + +#ifdef __cplusplus +} +#endif + +#endif /* _SAC_H */ diff --git a/illumos-x86_64/usr/include/sasl/prop.h b/illumos-x86_64/usr/include/sasl/prop.h new file mode 100644 index 00000000..14451a71 --- /dev/null +++ b/illumos-x86_64/usr/include/sasl/prop.h @@ -0,0 +1,180 @@ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * prop.h -- property request/response management routines + * + * Author: Chris Newman + * Removal of implementation-specific details by: Rob Siemborski + * + * This is intended to be used to create a list of properties to request, + * and _then_ request values for all properties. Any change to the request + * list will discard any existing values. This assumption allows a very + * efficient and simple memory model. This was designed for SASL API auxiliary + * property support, but would be fine for other contexts where this property + * model is appropriate. + * + * The "struct propctx" is allocated by prop_new and is a fixed size structure. + * If a prop_init() call were added, it would be reasonable to embed a "struct + * propctx" in another structure. prop_new also allocates a pool of memory + * (in the vbase field) which will be used for an array of "struct propval" + * to list all the requested properties. + * + * Properties may be multi-valued. + */ + +#ifndef _SASL_PROP_H +#define _SASL_PROP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * the resulting structure for property values + */ +struct propval { + /* + * name of property; NULL = end of list + * same pointer used in request will be used here + */ + const char *name; + const char **values; + /* + * list of strings, values == NULL if property not + * found, *values == NULL if property found with + * no values + */ + unsigned nvalues; /* total number of value strings */ + unsigned valsize; /* total size in characters of all value strings */ +}; + +/* + * private internal structure + */ +#define PROP_DEFAULT 4 /* default number of propvals to assume */ +struct propctx; + +/* + * create a property context + * estimate -- an estimate of the storage needed for requests & responses + * 0 will use module default + * returns a new property context on success and NULL on any error + */ +struct propctx *prop_new(unsigned estimate); + +/* + * create new propctx which duplicates the contents of an existing propctx + * returns SASL_OK on success + * possible other return values include: SASL_NOMEM, SASL_BADPARAM + */ +int prop_dup(struct propctx *src_ctx, struct propctx **dst_ctx); + +/* + * Add property names to request + * ctx -- context from prop_new() + * names -- list of property names; must persist until context freed + * or requests cleared (This extends to other contexts that + * are dup'ed from this one, and their children, etc) + * + * NOTE: may clear values from context as side-effect + * returns SASL_OK on success + * possible other return values include: SASL_NOMEM, SASL_BADPARAM + */ +int prop_request(struct propctx *ctx, const char **names); + +/* + * return array of struct propval from the context + * return value persists until next call to + * prop_request, prop_clear or prop_dispose on context + * + * returns NULL on error + */ +const struct propval *prop_get(struct propctx *ctx); + +/* + * Fill in an array of struct propval based on a list of property names + * return value persists until next call to + * prop_request, prop_clear or prop_dispose on context + * returns number of matching properties which were found (values != NULL) + * if a name requested here was never requested by a prop_request, then + * the name field of the associated vals entry will be set to NULL + * + * The vals array MUST be atleast as long as the names array. + * + * returns # of matching properties on success + * possible other return values include: SASL_BADPARAM + */ +int prop_getnames(struct propctx *ctx, const char **names, + struct propval *vals); + +/* + * clear values and optionally requests from property context + * ctx -- property context + * requests -- 0 = don't clear requests, 1 = clear requests + */ +void prop_clear(struct propctx *ctx, int requests); + +/* + * erase the value of a property + */ +void prop_erase(struct propctx *ctx, const char *name); + +/* + * dispose of property context + * ctx -- is disposed and set to NULL; noop if ctx or *ctx is NULL + */ +void prop_dispose(struct propctx **ctx); + + +/* fetcher interfaces */ + +/* + * format the requested property names into a string + * ctx -- context from prop_new()/prop_request() + * sep -- separator between property names (unused if none requested) + * seplen -- length of separator, if < 0 then strlen(sep) will be used + * outbuf -- output buffer + * outmax -- maximum length of output buffer including NUL terminator + * outlen -- set to length of output string excluding NUL terminator + * returns SASL_OK on success + * returns SASL_BADPARAM or amount of additional space needed on failure + */ +int prop_format(struct propctx *ctx, const char *sep, int seplen, + char *outbuf, unsigned outmax, unsigned *outlen); + +/* + * add a property value to the context + * ctx -- context from prop_new()/prop_request() + * name -- name of property to which value will be added + * if NULL, add to the same name as previous prop_set/setvals call + * value -- a value for the property; will be copied into context + * if NULL, remove existing values + * vallen -- length of value, if <= 0 then strlen(value) will be used + * returns SASL_OK on success + * possible error return values include: SASL_BADPARAM, SASL_NOMEM + */ +int prop_set(struct propctx *ctx, const char *name, + const char *value, int vallen); + +/* + * set the values for a property + * ctx -- context from prop_new()/prop_request() + * name -- name of property to which value will be added + * if NULL, add to the same name as previous prop_set/setvals call + * values -- array of values, ending in NULL. Each value is a NUL terminated + * string + * returns SASL_OK on success + * possible error return values include: SASL_BADPARAM, SASL_NOMEM + */ +int prop_setvals(struct propctx *ctx, const char *name, + const char **values); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SASL_PROP_H */ diff --git a/illumos-x86_64/usr/include/sasl/sasl.h b/illumos-x86_64/usr/include/sasl/sasl.h new file mode 100644 index 00000000..1edf5742 --- /dev/null +++ b/illumos-x86_64/usr/include/sasl/sasl.h @@ -0,0 +1,1274 @@ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * *******************************IMPORTANT****************************** + * send email to chris.newman@sun.com and cyrus-bugs@andrew.cmu.edu * + * if you need to add new error codes, callback types, property values, * + * etc. It is important to keep the multiple implementations of this * + * API from diverging. * + * *******************************IMPORTANT****************************** + * + * Basic Type Summary: + * sasl_conn_t Context for a SASL connection negotiation + * sasl_ssf_t Security layer Strength Factor + * sasl_callback_t A typed client/server callback function and context + * sasl_interact_t A client interaction descriptor + * sasl_secret_t A client password + * sasl_rand_t Random data context structure + * sasl_security_properties_t An application's required security level + * + * Callbacks: + * sasl_getopt_t client/server: Get an option value + * sasl_canon_user_t client/server: Canonicalize username + * sasl_log_t client/server: Log message handler + * sasl_verifyfile_t client/server: Verify file for specified usage + * sasl_getpath_t client/server: Get sasl search path + * + * Client only Callbacks: + * sasl_getrealm_t client: Get available realms + * sasl_getsimple_t client: Get user/language list + * sasl_getsecret_t client: Get authentication secret + * sasl_chalprompt_t client: Display challenge and prompt for response + * + * Server only Callbacks: + * sasl_authorize_t user authorization policy callback + * sasl_server_userdb_checkpass_t check password and auxprops in userdb + * sasl_server_userdb_setpass_t set password in userdb + * + * Client/Server Function Summary: + * sasl_done Release all SASL global state + * sasl_dispose Connection done: Dispose of sasl_conn_t + * sasl_getprop Get property (e.g., user name, security layer info) + * sasl_setprop Set property (e.g., external ssf) + * sasl_errdetail Generate string from last error on connection + * sasl_errstring Translate sasl error code to a string + * sasl_encode Encode data to send using security layer + * sasl_decode Decode data received using security layer + * + * Utility functions: + * sasl_encode64 Encode data to send using MIME base64 encoding + * sasl_decode64 Decode data received using MIME base64 encoding + * sasl_erasebuffer Erase a buffer + * + * Client Function Summary: + * sasl_client_init Load and initialize client plug-ins (call once) + * sasl_client_new Initialize client connection context: sasl_conn_t + * sasl_client_start Select mechanism for connection + * sasl_client_step Perform one authentication step + * + * Server Function Summary + * sasl_server_init Load and initialize server plug-ins (call once) + * sasl_server_new Initialize server connection context: sasl_conn_t + * sasl_listmech Create list of available mechanisms + * sasl_server_start Begin an authentication exchange + * sasl_server_step Perform one authentication exchange step + * sasl_checkpass Check a plaintext passphrase + * sasl_checkapop Check an APOP challenge/response (uses pseudo "APOP" + * mechanism similar to CRAM-MD5 mechanism; optional) + * sasl_user_exists Check if user exists + * sasl_setpass Change a password or add a user entry + * sasl_auxprop_request Request auxiliary properties + * sasl_auxprop_getctx Get auxiliary property context for connection + * + * Basic client model: + * 1. client calls sasl_client_init() at startup to load plug-ins + * 2. when connection formed, call sasl_client_new() + * 3. once list of supported mechanisms received from server, client + * calls sasl_client_start(). goto 4a + * 4. client calls sasl_client_step() + * [4a. If SASL_INTERACT, fill in prompts and goto 4 + * -- doesn't happen if callbacks provided] + * 4b. If SASL error, goto 7 or 3 + * 4c. If SASL_OK, continue or goto 6 if last server response was success + * 5. send message to server, wait for response + * 5a. On data or success with server response, goto 4 + * 5b. On failure goto 7 or 3 + * 5c. On success with no server response continue + * 6. continue with application protocol until connection closes + * call sasl_getprop/sasl_encode/sasl_decode() if using security layer + * 7. call sasl_dispose(), may return to step 2 + * 8. call sasl_done() when program terminates + * + * Basic Server model: + * 1. call sasl_server_init() at startup to load plug-ins + * 2. On connection, call sasl_server_new() + * 3. call sasl_listmech() and send list to client] + * 4. after client AUTH command, call sasl_server_start(), goto 5a + * 5. call sasl_server_step() + * 5a. If SASL_CONTINUE, output to client, wait response, repeat 5 + * 5b. If SASL error, then goto 7 + * 5c. If SASL_OK, move on + * 6. continue with application protocol until connection closes + * call sasl_getprop to get username + * call sasl_getprop/sasl_encode/sasl_decode() if using security layer + * 7. call sasl_dispose(), may return to step 2 + * 8. call sasl_done() when program terminates + * + * *********************************************** + * IMPORTANT NOTE: server realms / username syntax + * + * If a user name contains a "@", then the rightmost "@" in the user name + * separates the account name from the realm in which this account is + * located. A single server may support multiple realms. If the + * server knows the realm at connection creation time (e.g., a server + * with multiple IP addresses tightly binds one address to a specific + * realm) then that realm must be passed in the user_realm field of + * the sasl_server_new call. If user_realm is non-empty and an + * unqualified user name is supplied, then the canon_user facility is + * expected to append "@" and user_realm to the user name. The canon_user + * facility may treat other characters such as "%" as equivalent to "@". + * + * If the server forbids the use of "@" in user names for other + * purposes, this simplifies security validation. + */ + +#ifndef _SASL_SASL_H +#define _SASL_SASL_H + +#ifndef _SASL_PROP_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define SASL_VERSION_MAJOR 2 +#define SASL_VERSION_MINOR 1 +#define SASL_VERSION_STEP 15 + +/* + * The following ifdef block is the standard way of creating macros + * which make exporting from a DLL simpler. All files within this DLL + * are compiled with the LIBSASL_EXPORTS symbol defined on the command + * line. this symbol should not be defined on any project that uses + * this DLL. This way any other project whose source files include + * this file see LIBSASL_API functions as being imported from a DLL, + * wheras this DLL sees symbols defined with this macro as being + * exported. + * + * Under Unix, life is simpler: we just need to mark library functions + * as extern. (Technically, we don't even have to do that.) + */ +#ifdef WIN32 +#ifdef LIBSASL_EXPORTS +#define LIBSASL_API __declspec(dllexport) +#else /* LIBSASL_EXPORTS */ +#define LIBSASL_API __declspec(dllimport) +#endif /* LIBSASL_EXPORTS */ +#else /* WIN32 */ +#define LIBSASL_API extern +#endif /* WIN32 */ + +/* + * Same as above, but used during a variable declaration. Only Unix definition + * is different, as we can't assign an initial value to an extern variable + */ +#ifdef WIN32 +#ifdef LIBSASL_EXPORTS +#define LIBSASL_VAR __declspec(dllexport) +#else /* LIBSASL_EXPORTS */ +#define LIBSASL_VAR __declspec(dllimport) +#endif /* LIBSASL_EXPORTS */ +#else /* WIN32 */ +#define LIBSASL_VAR +#endif /* WIN32 */ + +/* + * Basic API + */ + +/* SASL result codes: */ +#define SASL_CONTINUE 1 /* another step is needed in authentication */ +#define SASL_OK 0 /* successful result */ +#define SASL_FAIL -1 /* generic failure */ +#define SASL_NOMEM -2 /* memory shortage failure */ +#define SASL_BUFOVER -3 /* overflowed buffer */ +#define SASL_NOMECH -4 /* mechanism not supported */ +#define SASL_BADPROT -5 /* bad protocol / cancel */ +#define SASL_NOTDONE -6 /* can't request info until later in exchange */ +#define SASL_BADPARAM -7 /* invalid parameter supplied */ +#define SASL_TRYAGAIN -8 /* transient failure (e.g., weak key) */ +#define SASL_BADMAC -9 /* integrity check failed */ +#define SASL_NOTINIT -12 /* SASL library not initialized */ + +/* -- client only codes -- */ +#define SASL_INTERACT 2 /* needs user interaction */ +#define SASL_BADSERV -10 /* server failed mutual authentication step */ +#define SASL_WRONGMECH -11 /* mechanism doesn't support requested feature */ + +/* -- server only codes -- */ +#define SASL_BADAUTH -13 /* authentication failure */ +#define SASL_NOAUTHZ -14 /* authorization failure */ +#define SASL_TOOWEAK -15 /* mechanism too weak for this user */ +#define SASL_ENCRYPT -16 /* encryption needed to use mechanism */ +#define SASL_TRANS -17 /* One time use of a plaintext password will */ + /* enable requested mechanism for user */ +#define SASL_EXPIRED -18 /* passphrase expired, has to be reset */ +#define SASL_DISABLED -19 /* account disabled */ +#define SASL_NOUSER -20 /* user not found */ +#define SASL_BADVERS -23 /* version mismatch with plug-in */ +#define SASL_UNAVAIL -24 /* remote authentication server unavailable */ +#define SASL_NOVERIFY -26 /* user exists, but no verifier for user */ + +/* -- codes for password setting -- */ +#define SASL_PWLOCK -21 /* passphrase locked */ +#define SASL_NOCHANGE -22 /* requested change was not needed */ +#define SASL_WEAKPASS -27 /* passphrase is too weak for security policy */ +#define SASL_NOUSERPASS -28 /* user supplied passwords not permitted */ + +/* max size of a sasl mechanism name */ +#define SASL_MECHNAMEMAX 20 + +#ifdef _WIN32 +/* Define to have the same layout as a WSABUF */ +#ifndef STRUCT_IOVEC_DEFINED +#define STRUCT_IOVEC_DEFINED 1 +struct iovec { + long iov_len; + char *iov_base; +}; +#endif +#else +struct iovec; /* Defined in OS headers */ +#endif + + +/* per-connection SASL negotiation state for client or server */ +typedef struct sasl_conn sasl_conn_t; + +/* + * Plain text password structure. + * len is the length of the password, data is the text. + */ +typedef struct sasl_secret { + unsigned long len; + unsigned char data[1]; /* variable sized */ +} sasl_secret_t; + +/* random data context structure */ +typedef struct sasl_rand_s sasl_rand_t; + + +/* + * Configure Basic Services + */ + +/* + * the following functions are used to adjust how allocation and mutexes work + * they must be called before all other SASL functions: + */ + +/* The following function is obsolete */ +/* + * memory allocation functions which may optionally be replaced: + */ +typedef void *sasl_malloc_t(unsigned long); +typedef void *sasl_calloc_t(unsigned long, unsigned long); +typedef void *sasl_realloc_t(void *, unsigned long); +typedef void sasl_free_t(void *); + +LIBSASL_API void sasl_set_alloc(sasl_malloc_t *, + sasl_calloc_t *, + sasl_realloc_t *, + sasl_free_t *); + +/* The following function is obsolete */ +/* + * mutex functions which may optionally be replaced: + * sasl_mutex_alloc allocates a mutex structure + * sasl_mutex_lock blocks until mutex locked + * returns -1 on deadlock or parameter error + * returns 0 on success + * sasl_mutex_unlock unlocks mutex if it's locked + * returns -1 if not locked or parameter error + * returns 0 on success + * sasl_mutex_free frees a mutex structure + */ +typedef void *sasl_mutex_alloc_t(void); +typedef int sasl_mutex_lock_t(void *mutex); +typedef int sasl_mutex_unlock_t(void *mutex); +typedef void sasl_mutex_free_t(void *mutex); +LIBSASL_API void sasl_set_mutex(sasl_mutex_alloc_t *, sasl_mutex_lock_t *, + sasl_mutex_unlock_t *, sasl_mutex_free_t *); + +/* + * Security preference types + */ + +/* + * security layer strength factor -- an unsigned integer usable by the caller + * to specify approximate security layer strength desired. Roughly + * correlated to effective key length for encryption. + * 0 = no protection + * 1 = integrity protection only + * 40 = 40-bit DES or 40-bit RC2/RC4 + * 56 = DES + * 112 = triple-DES + * 128 = 128-bit RC2/RC4/BLOWFISH + * 256 = baseline AES + */ +typedef unsigned sasl_ssf_t; + +/* usage flags provided to sasl_server_new and sasl_client_new: */ +#define SASL_SUCCESS_DATA 0x0004 /* server supports data on success */ +#define SASL_NEED_PROXY 0x0008 /* require a mech that allows proxying */ + +/* + * Security Property Types + */ + +/* + * Structure specifying the client or server's security policy + * and optional additional properties. + */ + +/* These are the various security flags apps can specify. */ +/* + * NOPLAINTEXT -- don't permit mechanisms susceptible to simple + * passive attack (e.g., PLAIN, LOGIN) + * NOACTIVE -- protection from active (non-dictionary) attacks + * during authentication exchange. + * Authenticates server. + * NODICTIONARY -- don't permit mechanisms susceptible to passive + * dictionary attack + * FORWARD_SECRECY -- require forward secrecy between sessions + * (breaking one won't help break next) + * NOANONYMOUS -- don't permit mechanisms that allow anonymous login + * PASS_CREDENTIALS -- require mechanisms which pass client + * credentials, and allow mechanisms which can pass + * credentials to do so + * MUTUAL_AUTH -- require mechanisms which provide mutual + * authentication + */ +#define SASL_SEC_NOPLAINTEXT 0x0001 +#define SASL_SEC_NOACTIVE 0x0002 +#define SASL_SEC_NODICTIONARY 0x0004 +#define SASL_SEC_FORWARD_SECRECY 0x0008 +#define SASL_SEC_NOANONYMOUS 0x0010 +#define SASL_SEC_PASS_CREDENTIALS 0x0020 +#define SASL_SEC_MUTUAL_AUTH 0x0040 +#define SASL_SEC_MAXIMUM 0x00FF + +typedef struct sasl_security_properties +{ + /* + * security strength factor + * min_ssf = minimum acceptable final level + * max_ssf = maximum acceptable final level + */ + sasl_ssf_t min_ssf; + sasl_ssf_t max_ssf; + + /* + * Maximum security layer receive buffer size. + * 0=security layer not supported + */ + unsigned maxbufsize; + +/* bitfield for attacks to protect against */ + unsigned security_flags; + +/* NULL terminated array of additional property names, values */ + const char **property_names; + const char **property_values; +} sasl_security_properties_t; + +/* + * Callback types + */ + +/* + * Extensible type for a client/server callbacks + * id -- identifies callback type + * proc -- procedure call arguments vary based on id + * context -- context passed to procedure + */ +/* + * Note that any memory that is allocated by the callback needs to be + * freed by the application, be it via function call or interaction. + * + * It may be freed after sasl_*_step returns SASL_OK. if the mechanism + * requires this information to persist (for a security layer, for example) + * it must maintain a private copy. + */ +typedef struct sasl_callback { + /* + * Identifies the type of the callback function. + * Mechanisms must ignore callbacks with id's they don't recognize. + */ + unsigned long id; + int (*proc)(); /* Callback function. Types of arguments vary by 'id' */ + void *context; +} sasl_callback_t; + +/* + * callback ids & functions: + */ +#define SASL_CB_LIST_END 0 /* end of list */ + +/* + * option reading callback -- this allows a SASL configuration to be + * encapsulated in the caller's configuration system. Some implementations + * may use default config file(s) if this is omitted. Configuration items + * may be plugin-specific and are arbitrary strings. + * + * inputs: + * context -- option context from callback record + * plugin_name -- name of plugin (NULL = general SASL option) + * option -- name of option + * output: + * result -- set to result which persists until next getopt in + * same thread, unchanged if option not found + * len -- length of result (may be NULL) + * returns: + * SASL_OK -- no error + * SASL_FAIL -- error + */ +typedef int sasl_getopt_t(void *context, const char *plugin_name, + const char *option, + const char **result, unsigned *len); +#define SASL_CB_GETOPT 1 + +/* Logging levels for use with the logging callback function. */ +#define SASL_LOG_NONE 0 /* don't log anything */ +#define SASL_LOG_ERR 1 /* log unusual errors (default) */ +#define SASL_LOG_FAIL 2 /* log all authentication failures */ +#define SASL_LOG_WARN 3 /* log non-fatal warnings */ +#define SASL_LOG_NOTE 4 /* more verbose than LOG_WARN */ +#define SASL_LOG_DEBUG 5 /* more verbose than LOG_NOTE */ +#define SASL_LOG_TRACE 6 /* traces of internal protocols */ +#define SASL_LOG_PASS 7 /* traces of internal protocols, including */ + /* passwords */ + +/* + * logging callback -- this allows plugins and the middleware to + * log operations they perform. + * inputs: + * context -- logging context from the callback record + * level -- logging level; see above + * message -- message to log + * returns: + * SASL_OK -- no error + * SASL_FAIL -- error + */ +typedef int sasl_log_t(void *context, + int level, + const char *message); +#define SASL_CB_LOG 2 + +/* + * getpath callback -- this allows applications to specify the + * colon-separated path to search for plugins (by default, + * taken from an implementation-specific location). + * inputs: + * context -- getpath context from the callback record + * outputs: + * path -- colon seperated path + * returns: + * SASL_OK -- no error + * SASL_FAIL -- error + */ +typedef int sasl_getpath_t(void *context, + const char **path); + +#define SASL_CB_GETPATH 3 + +/* Callback to get the location of the sasl config */ +#define SASL_CB_GETCONF 0x5001 + +/* + * verify file callback -- this allows applications to check if they + * want SASL to use files, file by file. This is intended to allow + * applications to sanity check the environment to make sure plugins + * or the configuration file can't be written to, etc. + * inputs: + * context -- verifypath context from the callback record + * file -- full path to file to verify + * type -- type of file to verify (see below) + * + * returns: + * SASL_OK -- no error (file can safely be used) + * SASL_CONTINUE -- continue WITHOUT using this file + * SASL_FAIL -- error + */ + +/* these are the types of files libsasl will ask about */ +typedef enum { + SASL_VRFY_PLUGIN = 0, /* a DLL/shared library plug-in */ + SASL_VRFY_CONF = 1, /* a configuration file */ + SASL_VRFY_PASSWD = 2, /* a password storage file/db */ + SASL_VRFY_OTHER = 3 /* some other file */ +} sasl_verify_type_t; + +typedef int sasl_verifyfile_t(void *context, + const char *file, sasl_verify_type_t type); +#define SASL_CB_VERIFYFILE 4 + + +/* client/user interaction callbacks: */ +/* + * Simple prompt -- result must persist until next call to getsimple on + * same connection or until connection context is disposed + * inputs: + * context -- context from callback structure + * id -- callback id + * outputs: + * result -- set to NUL terminated string + * NULL = user cancel + * len -- length of result + * returns SASL_OK + */ +typedef int sasl_getsimple_t(void *context, int id, + const char **result, unsigned *len); +#define SASL_CB_USER 0x4001 /* client user identity to login as */ +#define SASL_CB_AUTHNAME 0x4002 /* client authentication name */ +#define SASL_CB_LANGUAGE 0x4003 + /* + * comma separated list of RFC 1766 + * language codes in order of preference + * to be used to localize client prompts + * or server error codes + */ +#define SASL_CB_CNONCE 0x4007 + /* caller supplies client-nonce primarily for testing purposes */ + +/* + * get a sasl_secret_t (plaintext password with length) + * inputs: + * conn -- connection context + * context -- context from callback structure + * id -- callback id + * outputs: + * psecret -- set to NULL to cancel + * set to password structure which must persist until + * next call to getsecret in same connection, but middleware + * will erase password data when it's done with it. + * returns SASL_OK + */ +typedef int sasl_getsecret_t(sasl_conn_t *conn, void *context, int id, + sasl_secret_t **psecret); +#define SASL_CB_PASS 0x4004 /* client passphrase-based secret */ + + +/* + * prompt for input in response to a challenge. + * input: + * context -- context from callback structure + * id -- callback id + * challenge -- server challenge + * output: + * result -- NUL terminated result, NULL = user cancel + * len -- length of result + * returns SASL_OK + */ +typedef int sasl_chalprompt_t(void *context, int id, + const char *challenge, + const char *prompt, const char *defresult, + const char **result, unsigned *len); +#define SASL_CB_ECHOPROMPT 0x4005 /* challenge and client enterred result */ +#define SASL_CB_NOECHOPROMPT 0x4006 /* challenge and client enterred result */ + +/* + * prompt (or autoselect) the realm to do authentication in. + * may get a list of valid realms. + * input: + * context -- context from callback structure + * id -- callback id + * availrealms -- available realms; string list; NULL terminated + * list may be empty. + * output: + * result -- NUL terminated realm; NULL is equivalent to "" + * returns SASL_OK + * result must persist until the next callback + */ +typedef int sasl_getrealm_t(void *context, int id, + const char **availrealms, + const char **result); +#define SASL_CB_GETREALM (0x4008) /* realm to attempt authentication in */ + +/* server callbacks: */ + +/* + * improved callback to verify authorization; + * canonicalization now handled elsewhere + * conn -- connection context + * requested_user -- the identity/username to authorize (NUL terminated) + * rlen -- length of requested_user + * auth_identity -- the identity associated with the secret (NUL terminated) + * alen -- length of auth_identity + * default_realm -- default user realm, as passed to sasl_server_new if + * urlen -- length of default realm + * propctx -- auxiliary properties + * returns SASL_OK on success, + * SASL_NOAUTHZ or other SASL response on failure + */ +typedef int sasl_authorize_t(sasl_conn_t *conn, + void *context, + const char *requested_user, unsigned rlen, + const char *auth_identity, unsigned alen, + const char *def_realm, unsigned urlen, + struct propctx *propctx); +#define SASL_CB_PROXY_POLICY 0x8001 + +/* + * functions for "userdb" based plugins to call to get/set passwords. + * the location for the passwords is determined by the caller or middleware. + * plug-ins may get passwords from other locations. + */ + +/* + * callback to verify a plaintext password against the caller-supplied + * user database. This is necessary to allow additional s for + * encoding of the userPassword property. + * user -- NUL terminated user name with user@realm syntax + * pass -- password to check (may not be NUL terminated) + * passlen -- length of password to check + * propctx -- auxiliary properties for user + */ +typedef int sasl_server_userdb_checkpass_t(sasl_conn_t *conn, + void *context, + const char *user, + const char *pass, + unsigned passlen, + struct propctx *propctx); +#define SASL_CB_SERVER_USERDB_CHECKPASS (0x8005) + +/* + * callback to store/change a plaintext password in the user database + * user -- NUL terminated user name with user@realm syntax + * pass -- password to store (may not be NUL terminated) + * passlen -- length of password to store + * propctx -- auxiliary properties (not stored) + * flags -- see SASL_SET_* flags below (SASL_SET_CREATE optional) + */ +typedef int sasl_server_userdb_setpass_t(sasl_conn_t *conn, + void *context, + const char *user, + const char *pass, + unsigned passlen, + struct propctx *propctx, + unsigned flags); +#define SASL_CB_SERVER_USERDB_SETPASS (0x8006) + +/* + * callback for a server-supplied user canonicalization function. + * + * This function is called directly after the mechanism has the + * authentication and authorization IDs. It is called before any + * User Canonicalization plugin is called. It has the responsibility + * of copying its output into the provided output buffers. + * + * in, inlen -- user name to canonicalize, may not be NUL terminated + * may be same buffer as out + * flags -- not currently used, supplied by auth mechanism + * user_realm -- the user realm (may be NULL in case of client) + * out -- buffer to copy user name + * out_max -- max length of user name + * out_len -- set to length of user name + * + * returns + * SASL_OK on success + * SASL_BADPROT username contains invalid character + */ + +/* User Canonicalization Function Flags */ + +#define SASL_CU_NONE 0x00 /* Not a valid flag to pass */ +/* One of the following two is required */ +#define SASL_CU_AUTHID 0x01 +#define SASL_CU_AUTHZID 0x02 + +typedef int sasl_canon_user_t(sasl_conn_t *conn, + void *context, + const char *in, unsigned inlen, + unsigned flags, + const char *user_realm, + char *out, + unsigned out_max, unsigned *out_len); + +#define SASL_CB_CANON_USER (0x8007) + +/* + * Common Client/server functions + */ + +/* + * get sasl library version information + * implementation is a vendor-defined string + * version is a vender-defined representation of the version # + */ +LIBSASL_API void sasl_version(const char **implementation, + int *version); + +/* + * dispose of all SASL plugins. Connection + * states have to be disposed of before calling this. + */ +LIBSASL_API void sasl_done(void); + +/* + * dispose connection state, sets it to NULL + * checks for pointer to NULL + */ +LIBSASL_API void sasl_dispose(sasl_conn_t **pconn); + +/* + * translate an error number into a string + * input: + * saslerr -- the error number + * langlist -- comma separated list of RFC 1766 languages (may be NULL) + * results: + * outlang -- the language actually used (may be NULL if don't care) + * returns: + * the error message in UTF-8 (only the US-ASCII subset if langlist is NULL) + */ +LIBSASL_API const char *sasl_errstring(int saslerr, + const char *langlist, + const char **outlang); + +/* + * get detail about the last error that occurred on a connection + * text is sanitized so it's suitable to send over the wire + * (e.g., no distinction between SASL_BADAUTH and SASL_NOUSER) + * input: + * conn -- mandatory connection context + * returns: + * the error message in UTF-8 (only the US-ASCII subset permitted if no + * SASL_CB_LANGUAGE callback is present) + */ +LIBSASL_API const char *sasl_errdetail(sasl_conn_t *conn); + +/* + * set the error string which will be returned by sasl_errdetail() using + * syslog()-style formatting (e.g. printf-style with %m as most recent + * errno error) + * + * primarily for use by server callbacks such as the sasl_authorize_t + * callback and internally to plug-ins + * + * This will also trigger a call to the SASL logging callback (if any) + * with a level of SASL_LOG_FAIL unless the SASL_NOLOG flag is set. + * + * Messages should be sensitive to the current language setting. If there + * is no SASL_CB_LANGUAGE callback messages MUST be US-ASCII otherwise UTF-8 + * is used and use of RFC 2482 for mixed-language text is encouraged. + * + * if conn is NULL, function does nothing + */ +LIBSASL_API void sasl_seterror(sasl_conn_t *conn, unsigned flags, + const char *fmt, ...); +#define SASL_NOLOG 0x01 + +/* + * get property from SASL connection state + * propnum -- property number + * pvalue -- pointer to value + * returns: + * SASL_OK -- no error + * SASL_NOTDONE -- property not available yet + * SASL_BADPARAM -- bad property number + */ +LIBSASL_API int sasl_getprop(sasl_conn_t *conn, int propnum, + const void **pvalue); +#define SASL_USERNAME 0 /* pointer to NUL terminated user name */ +#define SASL_SSF 1 /* security layer security strength factor, */ + /* if 0, call to sasl_encode, sasl_decode */ + /* unnecessary */ +#define SASL_MAXOUTBUF 2 /* security layer max output buf unsigned */ +#define SASL_DEFUSERREALM 3 /* default realm passed to server_new */ + /* or set with setprop */ +#define SASL_GETOPTCTX 4 /* context for getopt callback */ +#define SASL_CALLBACK 7 /* current callback function list */ +#define SASL_IPLOCALPORT 8 /* iplocalport string passed to server_new */ +#define SASL_IPREMOTEPORT 9 /* ipremoteport string passed to server_new */ +#define SASL_SERVICE 12 /* service passed to sasl_*_new */ +#define SASL_SERVERFQDN 13 /* serverFQDN passed to sasl_*_new */ +#define SASL_AUTHSOURCE 14 /* name of auth source last used, useful */ + /* for failed authentication tracking */ +#define SASL_MECHNAME 15 /* active mechanism name, if any */ +#define SASL_AUTHUSER 16 /* authentication/admin user */ + +/* + * This returns a string which is either empty or has an error message + * from sasl_seterror (e.g., from a plug-in or callback). It differs + * from the result of sasl_errdetail() which also takes into account the + * last return status code. + */ +#define SASL_PLUGERR 10 + +/* + * set property in SASL connection state + * returns: + * SASL_OK -- value set + * SASL_BADPARAM -- invalid property or value + */ +LIBSASL_API int sasl_setprop(sasl_conn_t *conn, + int propnum, + const void *value); +#define SASL_SSF_EXTERNAL 100 /* external SSF active (sasl_ssf_t *) */ +#define SASL_SEC_PROPS 101 /* sasl_security_properties_t */ +#define SASL_AUTH_EXTERNAL 102 /* external authentication ID (const char *) */ + +/* + * If the SASL_AUTH_EXTERNAL value is non-NULL, then a special version of the + * EXTERNAL mechanism is enabled (one for server-embedded EXTERNAL mechanisms). + * Otherwise, the EXTERNAL mechanism will be absent unless a plug-in + * including EXTERNAL is present. + */ + +/* + * do precalculations during an idle period or network round trip + * may pass NULL to precompute for some mechanisms prior to connect + * returns 1 if action taken, 0 if no action taken + */ +LIBSASL_API int sasl_idle(sasl_conn_t *conn); + +/* + * Client API + */ + +/* + * list of client interactions with user for caller to fill in + */ +typedef struct sasl_interact { + unsigned long id; /* same as client/user callback ID */ + const char *challenge; /* presented to user (e.g. OTP challenge) */ + const char *prompt; /* presented to user (e.g. "Username: ") */ + const char *defresult; /* default result string */ + const void *result; /* set to point to result */ + unsigned len; /* set to length of result */ +} sasl_interact_t; + +/* + * initialize the SASL client drivers + * callbacks -- base callbacks for all client connections; + * must include getopt callback + * returns: + * SASL_OK -- Success + * SASL_NOMEM -- Not enough memory + * SASL_BADVERS -- Mechanism version mismatch + * SASL_BADPARAM -- missing getopt callback or error in config file + * SASL_NOMECH -- No mechanisms available + * ... + */ +LIBSASL_API int sasl_client_init(const sasl_callback_t *callbacks); + +/* + * initialize a client exchange based on the specified mechanism + * service -- registered name of the service using SASL (e.g. "imap") + * serverFQDN -- the fully qualified domain name of the server + * iplocalport -- client IPv4/IPv6 domain literal string with port + * (if NULL, then mechanisms requiring IPaddr are disabled) + * ipremoteport -- server IPv4/IPv6 domain literal string with port + * (if NULL, then mechanisms requiring IPaddr are disabled) + * prompt_supp -- list of client interactions supported + * may also include sasl_getopt_t context & call + * NULL prompt_supp = user/pass via SASL_INTERACT only + * NULL proc = interaction supported via SASL_INTERACT + * flags -- server usage flags (see above) + * out: + * pconn -- sasl connection + * + * Returns: + * SASL_OK -- success + * SASL_NOMECH -- no mechanism meets requested properties + * SASL_NOMEM -- not enough memory + */ +LIBSASL_API int sasl_client_new(const char *service, + const char *serverFQDN, + const char *iplocalport, + const char *ipremoteport, + const sasl_callback_t *prompt_supp, + unsigned flags, + sasl_conn_t **pconn); + +/* + * select a mechanism for a connection + * mechlist -- list of mechanisms to use (punctuation ignored) + * output: + * prompt_need -- on SASL_INTERACT, list of prompts needed to continue + * may be NULL if callbacks provided + * clientout -- the initial client response to send to the server + * will be valid until next call to client_start/client_step + * NULL if mech doesn't include initial client challenge + * mech -- set to mechansm name of selected mechanism (may be NULL) + * + * Returns: + * SASL_OK -- success + * SASL_NOMEM -- not enough memory + * SASL_NOMECH -- no mechanism meets requested properties + * SASL_INTERACT -- user interaction needed to fill in prompt_need list + */ +LIBSASL_API int sasl_client_start(sasl_conn_t *conn, + const char *mechlist, + sasl_interact_t **prompt_need, + const char **clientout, + unsigned *clientoutlen, + const char **mech); + +/* + * do a single authentication step. + * serverin -- the server message received by the client, MUST have a NUL + * sentinel, not counted by serverinlen + * output: + * prompt_need -- on SASL_INTERACT, list of prompts needed to continue + * clientout -- the client response to send to the server + * will be valid until next call to client_start/client_step + * + * returns: + * SASL_OK -- success + * SASL_INTERACT -- user interaction needed to fill in prompt_need list + * SASL_BADPROT -- server protocol incorrect/cancelled + * SASL_BADSERV -- server failed mutual auth + */ +LIBSASL_API int sasl_client_step(sasl_conn_t *conn, + const char *serverin, + unsigned serverinlen, + sasl_interact_t **prompt_need, + const char **clientout, + unsigned *clientoutlen); + +/* + * Server API + */ + +/* + * initialize server drivers, done once per process + * callbacks -- callbacks for all server connections; must include + * getopt callback + * appname -- name of calling application (for lower level logging) + * results: + * state -- server state + * returns: + * SASL_OK -- success + * SASL_BADPARAM -- error in config file + * SASL_NOMEM -- memory failure + * SASL_BADVERS -- Mechanism version mismatch + */ +LIBSASL_API int sasl_server_init(const sasl_callback_t *callbacks, + const char *appname); + +/* + * IP/port syntax: + * a.b.c.d:p where a-d are 0-255 and p is 0-65535 port number. + * [e:f:g:h:i:j:k:l]:p where e-l are 0000-ffff lower-case hexidecimal + * [e:f:g:h:i:j:a.b.c.d]:p alternate syntax for previous + * + * Note that one or more "0" fields in f-k can be replaced with "::" + * Thus: [e:f:0000:0000:0000:j:k:l]:p + * can be abbreviated: [e:f::j:k:l]:p + * + * A buffer of size 52 is adequate for the longest format with NUL terminator. + */ + +/* + * create context for a single SASL connection + * service -- registered name of the service using SASL (e.g. "imap") + * serverFQDN -- Fully qualified domain name of server. NULL means use + * gethostname() or equivalent. + * Useful for multi-homed servers. + * user_realm -- permits multiple user realms on server, NULL = default + * iplocalport -- server IPv4/IPv6 domain literal string with port + * (if NULL, then mechanisms requiring IPaddr are disabled) + * ipremoteport -- client IPv4/IPv6 domain literal string with port + * (if NULL, then mechanisms requiring IPaddr are disabled) + * callbacks -- callbacks (e.g., authorization, lang, new getopt context) + * flags -- usage flags (see above) + * returns: + * pconn -- new connection context + * + * returns: + * SASL_OK -- success + * SASL_NOMEM -- not enough memory + */ +LIBSASL_API int sasl_server_new(const char *service, + const char *serverFQDN, + const char *user_realm, + const char *iplocalport, + const char *ipremoteport, + const sasl_callback_t *callbacks, + unsigned flags, + sasl_conn_t **pconn); + +/* The following function is obsolete */ +/* + * Return an array of NUL-terminated strings, terminated by a NULL pointer, + * which lists all possible mechanisms that the library can supply + * + * Returns NULL on failure. + */ +LIBSASL_API const char ** sasl_global_listmech(void); + +/* + * This returns a list of mechanisms in a NUL-terminated string + * conn -- the connection to list mechanisms for (either client + * or server) + * user -- restricts mechanisms to those available to that user + * (may be NULL, not used for client case) + * prefix -- appended to beginning of result + * sep -- appended between mechanisms + * suffix -- appended to end of result + * results: + * result -- NUL terminated result which persists until next + * call to sasl_listmech for this sasl_conn_t + * plen -- gets length of result (excluding NUL), may be NULL + * pcount -- gets number of mechanisms, may be NULL + * + * returns: + * SASL_OK -- success + * SASL_NOMEM -- not enough memory + * SASL_NOMECH -- no enabled mechanisms + */ +LIBSASL_API int sasl_listmech(sasl_conn_t *conn, + const char *user, + const char *prefix, + const char *sep, + const char *suffix, + const char **result, + unsigned *plen, + int *pcount); + +/* + * start a mechanism exchange within a connection context + * mech -- the mechanism name client requested + * clientin -- client initial response (NUL terminated), NULL if empty + * clientinlen -- length of initial response + * serverout -- initial server challenge, NULL if done + * (library handles freeing this string) + * serveroutlen -- length of initial server challenge + * output: + * pconn -- the connection negotiation state on success + * + * Same returns as sasl_server_step() or + * SASL_NOMECH if mechanism not available. + */ +LIBSASL_API int sasl_server_start(sasl_conn_t *conn, + const char *mech, + const char *clientin, + unsigned clientinlen, + const char **serverout, + unsigned *serveroutlen); + +/* + * perform one step of the SASL exchange + * inputlen & input -- client data + * NULL on first step if no optional client step + * outputlen & output -- set to the server data to transmit + * to the client in the next step + * (library handles freeing this) + * + * returns: + * SASL_OK -- exchange is complete. + * SASL_CONTINUE -- indicates another step is necessary. + * SASL_TRANS -- entry for user exists, but not for mechanism + * and transition is possible + * SASL_BADPARAM -- service name needed + * SASL_BADPROT -- invalid input from client + * ... + */ +LIBSASL_API int sasl_server_step(sasl_conn_t *conn, + const char *clientin, + unsigned clientinlen, + const char **serverout, + unsigned *serveroutlen); + +/* The following function is obsolete */ +/* + * check if an apop exchange is valid + * (note this is an optional part of the SASL API) + * if challenge is NULL, just check if APOP is enabled + * inputs: + * challenge -- challenge which was sent to client + * challen -- length of challenge, 0 = strlen(challenge) + * response -- client response, " " (RFC 1939) + * resplen -- length of response, 0 = strlen(response) + * returns + * SASL_OK -- success + * SASL_BADAUTH -- authentication failed + * SASL_BADPARAM -- missing challenge + * SASL_BADPROT -- protocol error (e.g., response in wrong format) + * SASL_NOVERIFY -- user found, but no verifier + * SASL_NOMECH -- mechanism not supported + * SASL_NOUSER -- user not found + */ +LIBSASL_API int sasl_checkapop(sasl_conn_t *conn, + const char *challenge, unsigned challen, + const char *response, unsigned resplen); + +/* + * check if a plaintext password is valid + * if user is NULL, check if plaintext passwords are enabled + * inputs: + * user -- user to query in current user_domain + * userlen -- length of username, 0 = strlen(user) + * pass -- plaintext password to check + * passlen -- length of password, 0 = strlen(pass) + * returns + * SASL_OK -- success + * SASL_NOMECH -- mechanism not supported + * SASL_NOVERIFY -- user found, but no verifier + * SASL_NOUSER -- user not found + */ +LIBSASL_API int sasl_checkpass(sasl_conn_t *conn, + const char *user, unsigned userlen, + const char *pass, unsigned passlen); + +/* + * check if a user exists on server + * conn -- connection context + * service -- registered name of the service using SASL (e.g. "imap") + * user_realm -- permits multiple user realms on server, NULL = default + * user -- NUL terminated user name + * + * returns: + * SASL_OK -- success + * SASL_DISABLED -- account disabled + * SASL_NOUSER -- user not found + * SASL_NOVERIFY -- user found, but no usable mechanism + * SASL_NOMECH -- no mechanisms enabled + */ +LIBSASL_API int sasl_user_exists(sasl_conn_t *conn, + const char *service, + const char *user_realm, + const char *user); + +/* + * set the password for a user + * conn -- SASL connection + * user -- user name + * pass -- plaintext password, may be NULL to remove user + * passlen -- length of password, 0 = strlen(pass) + * oldpass -- NULL will sometimes work + * oldpasslen -- length of password, 0 = strlen(oldpass) + * flags -- see flags below + * + * returns: + * SASL_NOCHANGE -- proper entry already exists + * SASL_NOMECH -- no authdb supports password setting as configured + * SASL_NOVERIFY -- user exists, but no settable password present + * SASL_DISABLED -- account disabled + * SASL_PWLOCK -- password locked + * SASL_WEAKPASS -- password too weak for security policy + * SASL_NOUSERPASS -- user-supplied passwords not permitted + * SASL_FAIL -- OS error + * SASL_BADPARAM -- password too long + * SASL_OK -- successful + */ +LIBSASL_API int sasl_setpass(sasl_conn_t *conn, + const char *user, + const char *pass, unsigned passlen, + const char *oldpass, unsigned oldpasslen, + unsigned flags); +#define SASL_SET_CREATE 0x01 /* create a new entry for user */ +#define SASL_SET_REMOVE SASL_SET_CREATE /* remove user if pass is NULL */ +#define SASL_SET_DISABLE 0x02 /* disable user account */ + +/* + * Auxiliary Property Support -- added by cjn 1999-09-29 + */ + +#define SASL_AUX_END NULL /* last auxiliary property */ + +/* traditional Posix items (should be implemented on Posix systems) */ +#define SASL_AUX_PASSWORD "*userPassword" /* User Password (of authid) */ +#define SASL_AUX_UIDNUM "uidNumber" /* UID number for the user */ +#define SASL_AUX_GIDNUM "gidNumber" /* GID for the user */ +#define SASL_AUX_FULLNAME "gecos" /* full name of the user, unix-style */ +#define SASL_AUX_HOMEDIR "homeDirectory" /* home directory for user */ +#define SASL_AUX_SHELL "loginShell" /* login shell for the user */ + +/* optional additional items (not necessarily implemented) */ +/* + * single preferred mail address for user canonically-quoted + * RFC821/822 syntax + */ +#define SASL_AUX_MAILADDR "mail" +/* path to unix-style mailbox for user */ +#define SASL_AUX_UNIXMBX "mailMessageStore" +/* SMTP mail channel name to use if user authenticates successfully */ +#define SASL_AUX_MAILCHAN "mailSMTPSubmitChannel" + +/* + * Request a set of auxiliary properties + * conn connection context + * propnames list of auxiliary property names to request ending with + * NULL. + * + * Subsequent calls will add items to the request list. Call with NULL + * to clear the request list. + * + * errors + * SASL_OK -- success + * SASL_BADPARAM -- bad count/conn parameter + * SASL_NOMEM -- out of memory + */ +LIBSASL_API int sasl_auxprop_request(sasl_conn_t *conn, + const char **propnames); + +/* + * Returns current auxiliary property context. + * Use functions in prop.h to access content + * + * if authentication hasn't completed, property values may be empty/NULL + * + * properties not recognized by active plug-ins will be left empty/NULL + * + * returns NULL if conn is invalid. + */ +LIBSASL_API struct propctx *sasl_auxprop_getctx(sasl_conn_t *conn); + +/* + * security layer API + */ + +/* + * encode a block of data for transmission using security layer, + * returning the input buffer if there is no security layer. + * output is only valid until next call to sasl_encode or sasl_encodev + * returns: + * SASL_OK -- success (returns input if no layer negotiated) + * SASL_NOTDONE -- security layer negotiation not finished + * SASL_BADPARAM -- inputlen is greater than the SASL_MAXOUTBUF + */ +LIBSASL_API int sasl_encode(sasl_conn_t *conn, + const char *input, unsigned inputlen, + const char **output, unsigned *outputlen); + +/* + * encode a block of data for transmission using security layer + * output is only valid until next call to sasl_encode or sasl_encodev + * returns: + * SASL_OK -- success (returns input if no layer negotiated) + * SASL_NOTDONE -- security layer negotiation not finished + * SASL_BADPARAM -- input length is greater than the SASL_MAXOUTBUF + * or no security layer + */ +LIBSASL_API int sasl_encodev(sasl_conn_t *conn, + const struct iovec *invec, unsigned numiov, + const char **output, unsigned *outputlen); + +/* + * decode a block of data received using security layer + * returning the input buffer if there is no security layer. + * output is only valid until next call to sasl_decode + * + * if outputlen is 0 on return, than the value of output is undefined. + * + * returns: + * SASL_OK -- success (returns input if no layer negotiated) + * SASL_NOTDONE -- security layer negotiation not finished + * SASL_BADMAC -- bad message integrity check + */ +LIBSASL_API int sasl_decode(sasl_conn_t *conn, + const char *input, unsigned inputlen, + const char **output, unsigned *outputlen); + +#ifdef __cplusplus +} +#endif + +#endif /* _SASL_SASL_H */ diff --git a/illumos-x86_64/usr/include/sasl/saslplug.h b/illumos-x86_64/usr/include/sasl/saslplug.h new file mode 100644 index 00000000..2b7dd6e7 --- /dev/null +++ b/illumos-x86_64/usr/include/sasl/saslplug.h @@ -0,0 +1,890 @@ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* saslplug.h -- API for SASL plug-ins */ + +#ifndef _SASL_SASLPLUG_H +#define _SASL_SASLPLUG_H + +#ifndef _SASL_SASL_H +#include +#endif + +#ifndef _MD5_H +#include +#endif /* _MD5_H */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* intermediate MD5 context */ +typedef struct HMAC_MD5_CTX_s { + MD5_CTX ictx, octx; +} HMAC_MD5_CTX; + +/* + * intermediate HMAC state + * values stored in network byte order (Big Endian) + */ +typedef struct HMAC_MD5_STATE_s { + uint32_t istate[4]; + uint32_t ostate[4]; +} HMAC_MD5_STATE; + +/* + * callback to lookup a sasl_callback_t for a connection + * input: + * conn -- the connection to lookup a callback for + * callbacknum -- the number of the callback + * output: + * pproc -- pointer to the callback function (set to NULL on failure) + * pcontext -- pointer to the callback context (set to NULL on failure) + * returns: + * SASL_OK -- no error + * SASL_FAIL -- unable to find a callback of the requested type + * SASL_INTERACT -- caller must use interaction to get data + */ +typedef int sasl_getcallback_t(sasl_conn_t *conn, + unsigned long callbackid, + int (**pproc)(), + void **pcontext); + +/* + * The sasl_utils structure will remain backwards compatible unless + * the SASL_*_PLUG_VERSION is changed incompatibly + * higher SASL_UTILS_VERSION numbers indicate more functions are available + */ +#define SASL_UTILS_VERSION 4 + +/* utility function set for plug-ins */ +typedef struct sasl_utils { + int version; + + /* contexts */ + sasl_conn_t *conn; + sasl_rand_t *rpool; + void *getopt_context; + + /* option function */ + sasl_getopt_t *getopt; + + /* allocation functions: */ + sasl_malloc_t *malloc; + sasl_calloc_t *calloc; + sasl_realloc_t *realloc; + sasl_free_t *free; + + /* mutex functions: */ + sasl_mutex_alloc_t *mutex_alloc; + sasl_mutex_lock_t *mutex_lock; + sasl_mutex_unlock_t *mutex_unlock; + sasl_mutex_free_t *mutex_free; + + /* MD5 hash and HMAC functions */ + void (*MD5Init)(MD5_CTX *); + void (*MD5Update)(MD5_CTX *, const unsigned char *text, unsigned int len); + void (*MD5Final)(unsigned char [16], MD5_CTX *); + void (*hmac_md5)(const unsigned char *text, int text_len, + const unsigned char *key, int key_len, + unsigned char [16]); + void (*hmac_md5_init)(HMAC_MD5_CTX *, const unsigned char *key, int len); + /* hmac_md5_update() is just a call to MD5Update on inner context */ + void (*hmac_md5_final)(unsigned char [16], HMAC_MD5_CTX *); + void (*hmac_md5_precalc)(HMAC_MD5_STATE *, + const unsigned char *key, int len); + void (*hmac_md5_import)(HMAC_MD5_CTX *, HMAC_MD5_STATE *); + + /* mechanism utility functions (same as above): */ + int (*mkchal)(sasl_conn_t *conn, char *buf, unsigned maxlen, + unsigned hostflag); + int (*utf8verify)(const char *str, unsigned len); + void (*rand)(sasl_rand_t *rpool, char *buf, unsigned len); + void (*churn)(sasl_rand_t *rpool, const char *data, unsigned len); + + /* + * This allows recursive calls to the sasl_checkpass() routine from + * within a SASL plug-in. This MUST NOT be used in the PLAIN mechanism + * as sasl_checkpass MAY be a front-end for the PLAIN mechanism. + * This is intended for use by the non-standard LOGIN mechanism and + * potentially by a future mechanism which uses public-key technology + * to set up a lightweight encryption layer just for sending a + * password. + */ + int (*checkpass)(sasl_conn_t *conn, + const char *user, unsigned userlen, + const char *pass, unsigned passlen); + + /* Access to base64 encode/decode routines */ + int (*decode64)(const char *in, unsigned inlen, + char *out, unsigned outmax, unsigned *outlen); + int (*encode64)(const char *in, unsigned inlen, + char *out, unsigned outmax, unsigned *outlen); + + /* erase a buffer */ + void (*erasebuffer)(char *buf, unsigned len); + + /* callback to sasl_getprop() and sasl_setprop() */ + int (*getprop)(sasl_conn_t *conn, int propnum, const void **pvalue); + int (*setprop)(sasl_conn_t *conn, int propnum, const void *value); + + /* callback function */ + sasl_getcallback_t *getcallback; + + /* + * format a message and then pass it to the SASL_CB_LOG callback + * + * use syslog()-style formatting (printf with %m as most recent errno + * error). The implementation may use a fixed size buffer not smaller + * than 512 octets if it securely truncates the message. + * + * level is a SASL_LOG_* level (see sasl.h) + */ + void (*log)(sasl_conn_t *conn, int level, const char *fmt, ...); + + /* callback to sasl_seterror() */ + void (*seterror)(sasl_conn_t *conn, unsigned flags, const char *fmt, ...); + + /* spare function pointer */ + int *(*spare_fptr)(); + + /* auxiliary property utilities */ + struct propctx *(*prop_new)(unsigned estimate); + int (*prop_dup)(struct propctx *src_ctx, struct propctx **dst_ctx); + int (*prop_request)(struct propctx *ctx, const char **names); + const struct propval *(*prop_get)(struct propctx *ctx); + int (*prop_getnames)(struct propctx *ctx, const char **names, + struct propval *vals); + void (*prop_clear)(struct propctx *ctx, int requests); + void (*prop_dispose)(struct propctx **ctx); + int (*prop_format)(struct propctx *ctx, const char *sep, int seplen, + char *outbuf, unsigned outmax, unsigned *outlen); + int (*prop_set)(struct propctx *ctx, const char *name, + const char *value, int vallen); + int (*prop_setvals)(struct propctx *ctx, const char *name, + const char **values); + void (*prop_erase)(struct propctx *ctx, const char *name); + + /* for additions which don't require a version upgrade; set to 0 */ + int (*spare_fptr1)(); + int (*spare_fptr2)(); + int (*spare_fptr3)(); +} sasl_utils_t; + +/* + * output parameters from SASL API + * + * created / destroyed by the glue code, though probably filled in + * by a combination of the plugin, the glue code, and the canon_user callback. + * + */ +typedef struct sasl_out_params { + unsigned doneflag; /* exchange complete */ + + const char *user; /* canonicalized user name */ + const char *authid; /* canonicalized authentication id */ + + unsigned ulen; /* length of canonicalized user name */ + unsigned alen; /* length of canonicalized authid */ + + /* security layer information */ + unsigned maxoutbuf; + sasl_ssf_t mech_ssf; /* Should be set non-zero if negotiation of a */ + /* security layer was *attempted*, even if */ + /* the negotiation failed */ + void *encode_context; + int (*encode)(void *context, const struct iovec *invec, unsigned numiov, + const char **output, unsigned *outputlen); + void *decode_context; + int (*decode)(void *context, const char *input, unsigned inputlen, + const char **output, unsigned *outputlen); + + /* for additions which don't require a version upgrade; set to 0 */ + void *spare_ptr1; + void *spare_ptr2; + void *spare_ptr3; + void *spare_ptr4; + int (*spare_fptr1)(); + int (*spare_fptr2)(); + int spare_int1; + int spare_int2; + int spare_int3; + int spare_int4; + + /* + * set to 0 initially, this allows a plugin with extended parameters + * to work with an older framework by updating version as parameters + * are added. + */ + int param_version; +} sasl_out_params_t; + +/* + * Client Mechanism Functions + */ + +/* + * input parameters to client SASL plugin + * + * created / destroyed by the glue code + * + */ +typedef struct sasl_client_params { + const char *service; /* service name */ + const char *serverFQDN; /* server fully qualified domain name */ + const char *clientFQDN; /* client's fully qualified domain name */ + const sasl_utils_t *utils; /* SASL API utility routines -- */ + /* for a particular sasl_conn_t, */ + /* MUST remain valid until mech_free is */ + /* called */ + const sasl_callback_t *prompt_supp; /* client callback list */ + const char *iplocalport; /* server IP domain literal & port */ + const char *ipremoteport; /* client IP domain literal & port */ + + unsigned servicelen; /* length of service */ + unsigned slen; /* length of serverFQDN */ + unsigned clen; /* length of clientFQDN */ + unsigned iploclen; /* length of iplocalport */ + unsigned ipremlen; /* length of ipremoteport */ + + /* application's security requirements & info */ + sasl_security_properties_t props; + sasl_ssf_t external_ssf; /* external SSF active */ + + /* for additions which don't require a version upgrade; set to 0 */ + void *spare_ptr1; + void *spare_ptr2; + void *spare_ptr3; + void *spare_ptr4; + + /* + * Canonicalize a user name from on-wire to internal format + * added rjs3 2001-05-23 + * Must be called once user name aquired if canon_user is non-NULL. + * conn connection context + * in user name from wire protocol (need not be NUL terminated) + * len length of user name from wire protocol (0 = strlen(user)) + * flags for SASL_CU_* flags + * oparams the user, authid, ulen, alen, fields are + * set appropriately after canonicalization/copying and + * authorization of arguments + * + * responsible for setting user, ulen, authid, and alen in the oparams + * structure + * + * default behavior is to strip leading and trailing whitespace, as + * well as allocating space for and copying the parameters. + * + * results: + * SASL_OK -- success + * SASL_NOMEM -- out of memory + * SASL_BADPARAM -- invalid conn + * SASL_BADPROT -- invalid user/authid + */ + int (*canon_user)(sasl_conn_t *conn, + const char *in, unsigned len, + unsigned flags, + sasl_out_params_t *oparams); + + int (*spare_fptr1)(); + + int spare_int1; + int spare_int2; + int spare_int3; + + /* flags field as passed to sasl_client_new */ + unsigned flags; + + /* + * set to 0 initially, this allows a plugin with extended parameters + * to work with an older framework by updating version as parameters + * are added. + */ + int param_version; +} sasl_client_params_t; + +/* features shared between client and server */ +/* These allow the glue code to handle client-first and server-last issues */ + +/* + * This indicates that the mechanism prefers to do client-send-first + * if the protocol allows it. + */ +#define SASL_FEAT_WANT_CLIENT_FIRST 0x0002 + +/* + * This feature is deprecated, instead, plugins should set *serverout to + * non-NULL and return SASL_OK intelligently to allow flexible use of + * server-last semantics + */ +/* #define SASL_FEAT_WANT_SERVER_LAST 0x0004 */ + +/* + * This feature is deprecated, instead plugins should correctly set + * SASL_FEAT_SERVER_FIRST as needed + */ +/* #define SASL_FEAT_INTERNAL_CLIENT_FIRST 0x0008 */ + +/* + * This indicates that the plugin is server-first only. + * Not defining either of SASL_FEAT_SERVER_FIRST or + * SASL_FEAT_WANT_CLIENT_FIRST indicates that the mechanism will take care + * of the client-first situation internally. + */ +#define SASL_FEAT_SERVER_FIRST 0x0010 + +/* This plugin allows proxying */ +#define SASL_FEAT_ALLOWS_PROXY 0x0020 + +/* client plug-in features */ +#define SASL_FEAT_NEEDSERVERFQDN 0x0001 + +/* a C object for a client mechanism */ +typedef struct sasl_client_plug { + /* mechanism name */ + const char *mech_name; + + /* best mech additional security layer strength factor */ + sasl_ssf_t max_ssf; + + /* best security flags, as defined in sasl_security_properties_t */ + unsigned security_flags; + + /* features of plugin */ + unsigned features; + + /* required prompt ids, NULL = user/pass only */ + const unsigned long *required_prompts; + + /* global state for mechanism */ + void *glob_context; + + /* + * create context for mechanism, using params supplied + * glob_context -- from above + * params -- params from sasl_client_new + * conn_context -- context for one connection + * returns: + * SASL_OK -- success + * SASL_NOMEM -- not enough memory + * SASL_WRONGMECH -- mech doesn't support security params + */ + int (*mech_new)(void *glob_context, + sasl_client_params_t *cparams, + void **conn_context); + + /* + * perform one step of exchange. NULL is passed for serverin on + * first step. + * returns: + * SASL_OK -- success + * SASL_INTERACT -- user interaction needed to fill in prompts + * SASL_BADPROT -- server protocol incorrect/cancelled + * SASL_BADSERV -- server failed mutual auth + */ + int (*mech_step)(void *conn_context, + sasl_client_params_t *cparams, + const char *serverin, + unsigned serverinlen, + sasl_interact_t **prompt_need, + const char **clientout, + unsigned *clientoutlen, + sasl_out_params_t *oparams); + + /* dispose of connection context from mech_new */ + void (*mech_dispose)(void *conn_context, const sasl_utils_t *utils); + + /* + * free all global space used by mechanism + * mech_dispose must be called on all mechanisms first + */ + void (*mech_free)(void *glob_context, const sasl_utils_t *utils); + + /* + * perform precalculations during a network round-trip + * or idle period. conn_context may be NULL + * returns 1 if action taken, 0 if no action taken + */ + int (*idle)(void *glob_context, + void *conn_context, + sasl_client_params_t *cparams); + + /* for additions which don't require a version upgrade; set to 0 */ + int (*spare_fptr1)(); + int (*spare_fptr2)(); +} sasl_client_plug_t; + +#define SASL_CLIENT_PLUG_VERSION 4 + +/* + * plug-in entry point: + * utils -- utility callback functions + * max_version -- highest client plug version supported + * returns: + * out_version -- client plug version of result + * pluglist -- list of mechanism plug-ins + * plugcount -- number of mechanism plug-ins + * results: + * SASL_OK -- success + * SASL_NOMEM -- failure + * SASL_BADVERS -- max_version too small + * SASL_BADPARAM -- bad config string + * ... + */ +typedef int sasl_client_plug_init_t(const sasl_utils_t *utils, + int max_version, + int *out_version, + sasl_client_plug_t **pluglist, + int *plugcount); + +/* add a client plug-in */ +LIBSASL_API int sasl_client_add_plugin(const char *plugname, + sasl_client_plug_init_t *cplugfunc); + +/* + * Server Functions + */ + +/* + * input parameters to server SASL plugin + * + * created / destroyed by the glue code + * + */ +typedef struct sasl_server_params { + const char *service; /* NULL = default service for user_exists */ + /* and setpass */ + const char *appname; /* name of calling application */ + const char *serverFQDN; /* server default fully qualified domain name */ + /* (e.g., gethostname) */ + const char *user_realm; /* realm for user (NULL = client supplied) */ + const char *iplocalport; /* server IP domain literal & port */ + const char *ipremoteport; /* client IP domain literal & port */ + + unsigned servicelen; /* length of service */ + unsigned applen; /* length of appname */ + unsigned slen; /* length of serverFQDN */ + unsigned urlen; /* length of user_realm */ + unsigned iploclen; /* length of iplocalport */ + unsigned ipremlen; /* length of ipremoteport */ + + /* + * This indicates the level of logging desired. See SASL_LOG_* + * in sasl.h + * + * Plug-ins can ignore this and just pass their desired level to + * the log callback. This is primarily used to eliminate logging which + * might be a performance problem (e.g., full protocol trace) and + * to select between SASL_LOG_TRACE and SASL_LOG_PASS alternatives + */ + int log_level; + + const sasl_utils_t *utils; /* SASL API utility routines -- */ + /* for a particular sasl_conn_t, */ + /* MUST remain valid until mech_free is */ + /* called */ + + const sasl_callback_t *callbacks; /* Callbacks from application */ + + /* application's security requirements */ + sasl_security_properties_t props; + sasl_ssf_t external_ssf; /* external SSF active */ + + /* + * server plug-in calls this when it first has access to the plaintext + * passphrase. This is used to transition users via setpass calls. + * If passlen is 0, it defaults to strlen(pass). + * returns 0 if no entry added, 1 if entry added + */ + int (*transition)(sasl_conn_t *conn, const char *pass, unsigned passlen); + + /* + * Canonicalize a user name from on-wire to internal format + * added cjn 1999-09-21 + * Must be called once user name aquired if canon_user is non-NULL. + * conn connection context + * user user name from wire protocol (need not be NUL terminated) + * ulen length of user name from wire protocol (0 = strlen(user)) + * flags for SASL_CU_* flags + * oparams the user, authid, ulen, alen, fields are + * set appropriately after canonicalization/copying and + * authorization of arguments + * + * responsible for setting user, ulen, authid, and alen in the oparams + * structure + * + * default behavior is to strip leading and trailing whitespace, as + * well as allocating space for and copying the parameters. + * + * results: + * SASL_OK -- success + * SASL_NOMEM -- out of memory + * SASL_BADPARAM -- invalid conn + * SASL_BADPROT -- invalid user/authid + */ + int (*canon_user)(sasl_conn_t *conn, + const char *user, unsigned ulen, + unsigned flags, + sasl_out_params_t *oparams); + + /* + * auxiliary property context (see definitions in prop.h) + * added cjn 2000-01-30 + * + * NOTE: these properties are the ones associated with the + * canonicalized "user" (user to login as / authorization id), not + * the "authid" (user whose credentials are used / authentication id) + * Prefix the property name with a "*" if a property associated with + * the "authid" is interesting. + */ + struct propctx *propctx; + + /* for additions which don't require a version upgrade; set to 0 */ + void *spare_ptr1; + void *spare_ptr2; + void *spare_ptr3; + void *spare_ptr4; + int (*spare_fptr1)(); + int (*spare_fptr2)(); + int spare_int1; + int spare_int2; + int spare_int3; + + /* flags field as passed to sasl_server_new */ + unsigned flags; + + /* + * set to 0 initially, this allows a plugin with extended parameters + * to work with an older framework by updating version as parameters + * are added. + */ + int param_version; +} sasl_server_params_t; + +/* features for server plug-in */ +#define SASL_FEAT_SERVICE 0x0200 /* service-specific passwords supported */ +#define SASL_FEAT_GETSECRET 0x0400 /* sasl_server_{get,put}secret_t */ + /* callbacks required by plug-in */ + +/* a C object for a server mechanism */ +typedef struct sasl_server_plug { + /* mechanism name */ + const char *mech_name; + + /* best mech additional security layer strength factor */ + sasl_ssf_t max_ssf; + + /* best security flags, as defined in sasl_security_properties_t */ + unsigned security_flags; + + /* features of plugin */ + unsigned features; + + /* global state for mechanism */ + void *glob_context; + + /* + * create a new mechanism handler + * glob_context -- global context + * sparams -- server config params + * challenge -- server challenge from previous instance or NULL + * challen -- length of challenge from previous instance or 0 + * out: + * conn_context -- connection context + * errinfo -- error information + * + * returns: + * SASL_OK -- successfully created mech instance + * SASL_* -- any other server error code + */ + int (*mech_new)(void *glob_context, + sasl_server_params_t *sparams, + const char *challenge, + unsigned challen, + void **conn_context); + + /* + * perform one step in exchange + * + * returns: + * SASL_OK -- success, all done + * SASL_CONTINUE -- success, one more round trip + * SASL_* -- any other server error code + */ + int (*mech_step)(void *conn_context, + sasl_server_params_t *sparams, + const char *clientin, + unsigned clientinlen, + const char **serverout, + unsigned *serveroutlen, + sasl_out_params_t *oparams); + + /* dispose of a connection state */ + void (*mech_dispose)(void *conn_context, const sasl_utils_t *utils); + + /* + * free global state for mechanism + * mech_dispose must be called on all mechanisms first + */ + void (*mech_free)(void *glob_context, const sasl_utils_t *utils); + + /* + * set a password (optional) + * glob_context -- global context + * sparams -- service, middleware utilities, etc. props ignored + * user -- user name + * pass -- password/passphrase (NULL = disable/remove/delete) + * passlen -- length of password/passphrase + * oldpass -- old password/passphrase (NULL = transition) + * oldpasslen -- length of password/passphrase + * flags -- see above + * + * returns: + * SASL_NOCHANGE -- no change was needed + * SASL_NOUSER -- no entry for user + * SASL_NOVERIFY -- no mechanism compatible entry for user + * SASL_PWLOCK -- password locked + * SASL_DIABLED -- account disabled + * etc. + */ + int (*setpass)(void *glob_context, + sasl_server_params_t *sparams, + const char *user, + const char *pass, unsigned passlen, + const char *oldpass, unsigned oldpasslen, + unsigned flags); + + /* + * query which mechanisms are available for user + * glob_context -- context + * sparams -- service, middleware utilities, etc. props ignored + * user -- NUL terminated user name + * maxmech -- max number of strings in mechlist (0 = no output) + * output: + * mechlist -- an array of C string pointers, filled in with + * mechanism names available to the user + * + * returns: + * SASL_OK -- success + * SASL_NOMEM -- not enough memory + * SASL_FAIL -- lower level failure + * SASL_DISABLED -- account disabled + * SASL_NOUSER -- user not found + * SASL_BUFOVER -- maxmech is too small + * SASL_NOVERIFY -- user found, but no mechanisms available + */ + int (*user_query)(void *glob_context, + sasl_server_params_t *sparams, + const char *user, + int maxmech, + const char **mechlist); + + /* + * perform precalculations during a network round-trip + * or idle period. conn_context may be NULL (optional) + * returns 1 if action taken, 0 if no action taken + */ + int (*idle)(void *glob_context, + void *conn_context, + sasl_server_params_t *sparams); + + /* + * check if mechanism is available + * TODO - Is this correct? + * optional--if NULL, mechanism is available based on ENABLE= + * in config + * + * If this routine sets conn_context to a non-NULL value, then the call + * to mech_new will be skipped. This should not be done unless + * there's a significant performance benefit, since it can cause + * additional memory allocation in SASL core code to keep track of + * contexts potentially for multiple mechanisms. + * + * This is called by the first call to sasl_listmech() for a + * given connection context, thus for a given protocol it may + * never be called. Note that if mech_avail returns SASL_NOMECH, + * then that mechanism is considered disabled for the remainder + * of the session. + * + * returns SASL_OK on success, + * SASL_NOMECH if mech disabled + */ + int (*mech_avail)(void *glob_context, + sasl_server_params_t *sparams, + void **conn_context); + + /* for additions which don't require a version upgrade; set to 0 */ + int (*spare_fptr2)(); +} sasl_server_plug_t; + +#define SASL_SERVER_PLUG_VERSION 4 + +/* + * plug-in entry point: + * utils -- utility callback functions + * plugname -- name of plug-in (may be NULL) + * max_version -- highest server plug version supported + * returns: + * out_version -- server plug-in version of result + * pluglist -- list of mechanism plug-ins + * plugcount -- number of mechanism plug-ins + * results: + * SASL_OK -- success + * SASL_NOMEM -- failure + * SASL_BADVERS -- max_version too small + * SASL_BADPARAM -- bad config string + * ... + */ +typedef int sasl_server_plug_init_t(const sasl_utils_t *utils, + int max_version, + int *out_version, + sasl_server_plug_t **pluglist, + int *plugcount); + +/* + * add a server plug-in + */ +LIBSASL_API int sasl_server_add_plugin(const char *plugname, + sasl_server_plug_init_t *splugfunc); + +/* + * user canonicalization plug-in -- added cjn 1999-09-29 + */ + +typedef struct sasl_canonuser { + /* optional features of plugin (set to 0) */ + int features; + + /* spare integer (set to 0) */ + int spare_int1; + + /* global state for plugin */ + void *glob_context; + + /* name of plugin */ + char *name; + + /* free global state for plugin */ + void (*canon_user_free)(void *glob_context, const sasl_utils_t *utils); + + /* + * canonicalize a username + * glob_context -- global context from this structure + * sparams -- server params, note user_realm&propctx elements + * user -- user to login as (may not be NUL terminated) + * len -- length of user name (0 = strlen(user)) + * flags -- for SASL_CU_* flags + * out -- buffer to copy user name + * out_max -- max length of user name + * out_len -- set to length of user name + * + * note that the output buffers MAY be the same as the input buffers. + * + * returns + * SASL_OK on success + * SASL_BADPROT username contains invalid character + */ + int (*canon_user_server)(void *glob_context, + sasl_server_params_t *sparams, + const char *user, unsigned len, + unsigned flags, + char *out, + unsigned out_umax, unsigned *out_ulen); + + int (*canon_user_client)(void *glob_context, + sasl_client_params_t *cparams, + const char *user, unsigned len, + unsigned flags, + char *out, + unsigned out_max, unsigned *out_len); + + /* for additions which don't require a version upgrade; set to 0 */ + int (*spare_fptr1)(); + int (*spare_fptr2)(); + int (*spare_fptr3)(); +} sasl_canonuser_plug_t; + +#define SASL_CANONUSER_PLUG_VERSION 5 + +/* + * default name for canonuser plug-in entry point is "sasl_canonuser_init" + * similar to sasl_server_plug_init model, except only returns one + * sasl_canonuser_plug_t structure; + */ +typedef int sasl_canonuser_init_t(const sasl_utils_t *utils, + int max_version, + int *out_version, + sasl_canonuser_plug_t **plug, + const char *plugname); + +/* add a canonuser plugin */ +LIBSASL_API int sasl_canonuser_add_plugin(const char *plugname, + sasl_canonuser_init_t *canonuserfunc); + +/* + * auxiliary property plug-in -- added cjn 1999-09-29 + */ + +typedef struct sasl_auxprop_plug { + /* optional features of plugin (none defined yet, set to 0) */ + int features; + + /* spare integer, must be set to 0 */ + int spare_int1; + + /* global state for plugin */ + void *glob_context; + + /* free global state for plugin (OPTIONAL) */ + void (*auxprop_free)(void *glob_context, const sasl_utils_t *utils); + + /* + * fill in fields of an auxiliary property context + * last element in array has id of SASL_AUX_END + * elements with non-0 len should be ignored. + */ + void (*auxprop_lookup)(void *glob_context, + sasl_server_params_t *sparams, + unsigned flags, + const char *user, unsigned ulen); + + /* name of the auxprop plugin */ + char *name; + + /* for additions which don't require a version upgrade; set to 0 */ + void (*spare_fptr1)(); +} sasl_auxprop_plug_t; + +/* auxprop lookup flags */ +#define SASL_AUXPROP_OVERRIDE 0x01 /* if clear, ignore auxiliary properties */ + /* with non-zero len field. If set, */ + /* override value of those properties */ +#define SASL_AUXPROP_AUTHZID 0x02 /* if clear, we are looking up the */ + /* authid flags (prefixed with *), */ + /* otherwise we are looking up the */ + /* authzid flags (no prefix) */ + +#define SASL_AUXPROP_PLUG_VERSION 4 + +/* + * default name for auxprop plug-in entry point is "sasl_auxprop_init" + * similar to sasl_server_plug_init model, except only returns one + * sasl_auxprop_plug_t structure; + */ +typedef int sasl_auxprop_init_t(const sasl_utils_t *utils, + int max_version, + int *out_version, + sasl_auxprop_plug_t **plug, + const char *plugname); + +/* add an auxiliary property plug-in */ +LIBSASL_API int sasl_auxprop_add_plugin(const char *plugname, + sasl_auxprop_init_t *auxpropfunc); + +#ifdef __cplusplus +} +#endif + +#endif /* _SASL_SASLPLUG_H */ diff --git a/illumos-x86_64/usr/include/sasl/saslutil.h b/illumos-x86_64/usr/include/sasl/saslutil.h new file mode 100644 index 00000000..8cffa19e --- /dev/null +++ b/illumos-x86_64/usr/include/sasl/saslutil.h @@ -0,0 +1,103 @@ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * saslutil.h -- various utility functions in SASL library + */ + +#ifndef _SASL_SASLUTIL_H +#define _SASL_SASLUTIL_H + +#ifndef _SASL_SASL_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * base64 decode + * in -- input data + * inlen -- length of input data + * out -- output data (may be same as in, must have enough space) + * outmax -- max size of output buffer + * result: + * outlen -- actual output length + * + * returns SASL_BADPROT on bad base64, + * SASL_BUFOVER if result won't fit + * SASL_OK on success + */ +LIBSASL_API int sasl_decode64(const char *in, unsigned inlen, + char *out, unsigned outmax, unsigned *outlen); + +/* + * base64 encode + * in -- input data + * inlen -- input data length + * out -- output buffer (will be NUL terminated) + * outmax -- max size of output buffer + * result: + * outlen -- gets actual length of output buffer (optional) + * + * Returns SASL_OK on success, SASL_BUFOVER if result won't fit + */ +LIBSASL_API int sasl_encode64(const char *in, unsigned inlen, + char *out, unsigned outmax, unsigned *outlen); + +#if 0 +/* + * The following is not supported: + * + * make a challenge string (NUL terminated) + * buf -- buffer for result + * maxlen -- max length of result + * hostflag -- 0 = don't include hostname, 1 = include hostname + * returns final length or 0 if not enough space + */ +LIBSASL_API int sasl_mkchal(sasl_conn_t *conn, char *buf, + unsigned maxlen, unsigned hostflag); +#endif + +/* + * verify a string is valid UTF-8 + * if len == 0, strlen(str) will be used. + * returns SASL_BADPROT on error, SASL_OK on success + */ +LIBSASL_API int sasl_utf8verify(const char *str, unsigned len); + +#if 0 +/* The following are not supported */ + +/* create random pool seeded with OS-based params */ +LIBSASL_API int sasl_randcreate(sasl_rand_t **rpool); + +/* free random pool from randcreate */ +LIBSASL_API void sasl_randfree(sasl_rand_t **rpool); + +/* seed random number generator */ +LIBSASL_API void sasl_randseed(sasl_rand_t *rpool, const char *seed, + unsigned len); + +/* generate random octets */ +LIBSASL_API void sasl_rand(sasl_rand_t *rpool, char *buf, unsigned len); + +/* churn data into random number generator */ +LIBSASL_API void sasl_churn(sasl_rand_t *rpool, const char *data, + unsigned len); +#endif + +/* + * erase a security sensitive buffer or password. + * Implementation may use recovery-resistant erase logic. + */ +LIBSASL_API void sasl_erasebuffer(char *pass, unsigned len); + +#ifdef __cplusplus +} +#endif + +#endif /* _SASL_SASLUTIL_H */ diff --git a/illumos-x86_64/usr/include/sched.h b/illumos-x86_64/usr/include/sched.h new file mode 100644 index 00000000..5eed5fb3 --- /dev/null +++ b/illumos-x86_64/usr/include/sched.h @@ -0,0 +1,72 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SCHED_H +#define _SCHED_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct sched_param { + int sched_priority; /* scheduling priority */ + int sched_pad[8]; +}; + +/* + * POSIX scheduling policies + */ +#define SCHED_OTHER 0 /* traditional time-sharing scheduling class */ +#define SCHED_FIFO 1 /* real-time class: run to completion */ +#define SCHED_RR 2 /* real-time class: round-robin */ +#define SCHED_SYS 3 /* system scheduling class */ +#define SCHED_IA 4 /* interactive time-sharing class */ +#define SCHED_FSS 5 /* fair-share scheduling class */ +#define SCHED_FX 6 /* fixed-priority scheduling class */ +#define _SCHED_NEXT 7 /* first unassigned policy number */ + +/* + * function prototypes + */ +int sched_getparam(pid_t, struct sched_param *); +int sched_setparam(pid_t, const struct sched_param *); +int sched_getscheduler(pid_t); +int sched_setscheduler(pid_t, int, const struct sched_param *); +int sched_yield(void); +int sched_get_priority_max(int); +int sched_get_priority_min(int); +int sched_rr_get_interval(pid_t, struct timespec *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SCHED_H */ diff --git a/illumos-x86_64/usr/include/schedctl.h b/illumos-x86_64/usr/include/schedctl.h new file mode 100644 index 00000000..3d734982 --- /dev/null +++ b/illumos-x86_64/usr/include/schedctl.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SCHEDCTL_H +#define _SCHEDCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef sc_public_t schedctl_t; + +extern void yield(void); + +#define schedctl_start(p) \ + (void) (((p) == NULL)? 0 : \ + ((((schedctl_t *)(p))->sc_nopreempt = 1), 0)) + +#define schedctl_stop(p) \ + (void) (((p) == NULL)? 0 : \ + ((((schedctl_t *)(p))->sc_nopreempt = 0), \ + (((schedctl_t *)(p))->sc_yield? (yield(), 0) : 0))) + +/* + * libsched API + */ +schedctl_t *schedctl_init(void); +schedctl_t *schedctl_lookup(void); +void schedctl_exit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SCHEDCTL_H */ diff --git a/illumos-x86_64/usr/include/scsi/libscsi.h b/illumos-x86_64/usr/include/scsi/libscsi.h new file mode 100644 index 00000000..5904217f --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/libscsi.h @@ -0,0 +1,182 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, Joyent, Inc. + */ + +#ifndef _LIBSCSI_H +#define _LIBSCSI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#define LIBSCSI_VERSION 1 +#define LIBSCSI_STATUS_INVALID ((sam4_status_t)-1) +#define LIBSCSI_DEFAULT_ENGINE_PATH "/usr/lib/scsi/plugins/scsi/engines" +#define LIBSCSI_DEFAULT_ENGINE "uscsi" + +/* + * Flags for action creation. Selected to avoid overlap with the uscsi + * flags with similar or identical meaning. + */ +#define LIBSCSI_AF_READ 0x80000000 +#define LIBSCSI_AF_WRITE 0x40000000 +#define LIBSCSI_AF_SILENT 0x20000000 +#define LIBSCSI_AF_DIAGNOSE 0x10000000 +#define LIBSCSI_AF_ISOLATE 0x08000000 +#define LIBSCSI_AF_RQSENSE 0x04000000 + +typedef enum libscsi_errno { + ESCSI_NONE, /* no error */ + ESCSI_NOMEM, /* no memory */ + ESCSI_ZERO_LENGTH, /* zero-length allocation requested */ + ESCSI_VERSION, /* library version mismatch */ + ESCSI_BADTARGET, /* invalid target specification */ + ESCSI_BADCMD, /* invalid SCSI command */ + ESCSI_BADENGINE, /* engine library corrupt */ + ESCSI_NOENGINE, /* engine library not found */ + ESCSI_ENGINE_INIT, /* engine initialization failed */ + ESCSI_ENGINE_VER, /* engine version mismatch */ + ESCSI_ENGINE_BADPATH, /* engine path contains no usable components */ + ESCSI_BADFLAGS, /* incorrect action flags */ + ESCSI_BOGUSFLAGS, /* unknown flag value */ + ESCSI_BADLENGTH, /* buffer length overflow */ + ESCSI_NEEDBUF, /* missing required buffer */ + ESCSI_IO, /* I/O operation failed */ + ESCSI_SYS, /* system call failed */ + ESCSI_PERM, /* insufficient permissions */ + ESCSI_RANGE, /* parameter outside valid range */ + ESCSI_NOTSUP, /* operation not supported */ + ESCSI_UNKNOWN, /* error of unknown type */ + ESCSI_INQUIRY_FAILED, /* initial inquiry command failed */ + ESCSI_MAX /* maximum libscsi errno value */ +} libscsi_errno_t; + +struct libscsi_hdl; +typedef struct libscsi_hdl libscsi_hdl_t; + +struct libscsi_target; +typedef struct libscsi_target libscsi_target_t; + +typedef struct libscsi_status { + uint64_t lss_status; /* SCSI status of this command */ + size_t lss_sense_len; /* Length in bytes of sense data */ + uint8_t *lss_sense_data; /* Pointer to sense data */ +} libscsi_status_t; + +struct libscsi_action; +typedef struct libscsi_action libscsi_action_t; + +typedef struct libscsi_engine_ops { + void *(*lseo_open)(libscsi_hdl_t *, const void *); + void (*lseo_close)(libscsi_hdl_t *, void *); + int (*lseo_exec)(libscsi_hdl_t *, void *, libscsi_action_t *); + void (*lseo_target_name)(libscsi_hdl_t *, void *, char *, size_t); + int (*lseo_max_transfer)(libscsi_hdl_t *, void *, size_t *); +} libscsi_engine_ops_t; + +typedef struct libscsi_engine { + const char *lse_name; + uint_t lse_libversion; + const libscsi_engine_ops_t *lse_ops; +} libscsi_engine_t; + +extern libscsi_hdl_t *libscsi_init(uint_t, libscsi_errno_t *); +extern void libscsi_fini(libscsi_hdl_t *); + +extern libscsi_target_t *libscsi_open(libscsi_hdl_t *, const char *, + const void *); +extern void libscsi_close(libscsi_hdl_t *, libscsi_target_t *); +extern libscsi_hdl_t *libscsi_get_handle(libscsi_target_t *); + +extern const char *libscsi_vendor(libscsi_target_t *); +extern const char *libscsi_product(libscsi_target_t *); +extern const char *libscsi_revision(libscsi_target_t *); +extern int libscsi_max_transfer(libscsi_target_t *, size_t *); + +extern libscsi_errno_t libscsi_errno(libscsi_hdl_t *); +extern const char *libscsi_errmsg(libscsi_hdl_t *); +extern const char *libscsi_strerror(libscsi_errno_t); +extern const char *libscsi_errname(libscsi_errno_t); +extern libscsi_errno_t libscsi_errcode(const char *); + +extern libscsi_action_t *libscsi_action_alloc(libscsi_hdl_t *, spc3_cmd_t, + uint_t, void *, size_t); +extern libscsi_action_t *libscsi_action_alloc_vendor(libscsi_hdl_t *, + spc3_cmd_t, size_t, uint_t, void *, size_t); +extern sam4_status_t libscsi_action_get_status(const libscsi_action_t *); +extern void libscsi_action_set_timeout(libscsi_action_t *, uint32_t); +extern size_t libscsi_action_get_cdblen(const libscsi_action_t *); +extern uint32_t libscsi_action_get_timeout(const libscsi_action_t *); +extern uint_t libscsi_action_get_flags(const libscsi_action_t *); +extern uint8_t *libscsi_action_get_cdb(const libscsi_action_t *); +extern int libscsi_action_get_buffer(const libscsi_action_t *, + uint8_t **, size_t *, size_t *); +extern int libscsi_action_get_sense(const libscsi_action_t *, + uint8_t **, size_t *, size_t *); +extern int libscsi_action_parse_sense(const libscsi_action_t *, uint64_t *, + uint64_t *, uint64_t *, diskaddr_t *); +extern void libscsi_action_set_status(libscsi_action_t *, sam4_status_t); +extern int libscsi_action_set_datalen(libscsi_action_t *, size_t); +extern int libscsi_action_set_senselen(libscsi_action_t *, size_t); +extern int libscsi_exec(libscsi_action_t *, libscsi_target_t *); +extern void libscsi_action_free(libscsi_action_t *); + +extern const char *libscsi_sense_key_name(uint64_t); +extern const char *libscsi_sense_code_name(uint64_t, uint64_t); + +/* + * Interfaces for engine providers + */ +extern void *libscsi_alloc(libscsi_hdl_t *, size_t); +extern void *libscsi_zalloc(libscsi_hdl_t *, size_t); +extern char *libscsi_strdup(libscsi_hdl_t *, const char *); +extern void libscsi_free(libscsi_hdl_t *, void *); +extern libscsi_status_t *libscsi_status_alloc(libscsi_hdl_t *, size_t); +extern int libscsi_status_fill(libscsi_hdl_t *, libscsi_status_t *, + uint16_t, size_t); +extern void libscsi_status_free(libscsi_hdl_t *, libscsi_status_t *); + +extern int libscsi_set_errno(libscsi_hdl_t *, libscsi_errno_t); +extern int libscsi_verror(libscsi_hdl_t *, libscsi_errno_t, const char *, + va_list); +extern int libscsi_error(libscsi_hdl_t *, libscsi_errno_t, const char *, ...); + +typedef const libscsi_engine_t *(*libscsi_engine_init_f)(libscsi_hdl_t *); + +/* + * Generic SCSI utility functions. + */ +extern size_t libscsi_cmd_cdblen(libscsi_hdl_t *, uint8_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSCSI_H */ diff --git a/illumos-x86_64/usr/include/scsi/libses.h b/illumos-x86_64/usr/include/scsi/libses.h new file mode 100644 index 00000000..1fcf46ae --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/libses.h @@ -0,0 +1,137 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBSES_H +#define _LIBSES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include +#include + +#include +#include +#include + +#define LIBSES_VERSION 1 + +/* + * element type prop can be created by any plugin. The ses2 plugin created + * SES-2 defined element types and SUN plugin defines vendor specific types. + */ +#define SES_PROP_ELEMENT_TYPE "ses-element-type" + +typedef enum ses_node_type { + SES_NODE_NONE = 0x0, + SES_NODE_TARGET = 0x1, + SES_NODE_ENCLOSURE = 0x2, + SES_NODE_AGGREGATE = 0x4, + SES_NODE_ELEMENT = 0x8 +} ses_node_type_t; + +typedef enum ses_errno { + ESES_NONE, /* no error */ + ESES_NOMEM, /* no memory */ + ESES_ZERO_LENGTH, /* zero-length allocation requested */ + ESES_VERSION, /* library version mismatch */ + ESES_NVL, /* nvlist manipulation error */ + ESES_BAD_NODE, /* bad node */ + ESES_INVALID_OP, /* invalid operation */ + ESES_RANGE, /* value out of range */ + ESES_INVALID_PROP, /* nonexistent or immutable property */ + ESES_BAD_TYPE, /* incorrect property type */ + ESES_BAD_PAGE, /* bad page number */ + ESES_BAD_RESPONSE, /* bad response from target */ + ESES_BUSY, /* target busy */ + ESES_TOOMUCHCHANGE, /* target configuration changing too rapidly */ + ESES_LIBSCSI, /* SCSI error */ + ESES_NOTSUP, /* operation not supported */ + ESES_UNKNOWN, /* error of unknown type */ + ESES_CHANGED, /* generation count has changed */ + ESES_PLUGIN, /* invalid or missing plugin */ + ESES_MAX /* maximum libses errno value */ +} ses_errno_t; + +struct ses_target; +typedef struct ses_target ses_target_t; + +struct ses_snap; +typedef struct ses_snap ses_snap_t; + +struct ses_node; +typedef struct ses_node ses_node_t; + +extern ses_target_t *ses_open(uint_t, const char *); +extern ses_target_t *ses_open_scsi(uint_t, libscsi_target_t *); +extern void ses_close(ses_target_t *); + +extern libscsi_target_t *ses_scsi_target(ses_target_t *); + +typedef enum ses_walk_action { + SES_WALK_ACTION_CONTINUE, + SES_WALK_ACTION_PRUNE, + SES_WALK_ACTION_TERMINATE +} ses_walk_action_t; + +typedef ses_walk_action_t (*ses_walk_f)(ses_node_t *, void *); + +extern uint64_t ses_node_id(ses_node_t *); +extern ses_node_t *ses_node_lookup(ses_snap_t *, uint64_t); + +extern ses_node_t *ses_root_node(ses_snap_t *); +extern ses_node_t *ses_node_sibling(ses_node_t *); +extern ses_node_t *ses_node_prev_sibling(ses_node_t *); +extern ses_node_t *ses_node_child(ses_node_t *); +extern ses_node_t *ses_node_parent(ses_node_t *); +extern int ses_walk(ses_snap_t *, ses_walk_f, void *); + +extern ses_snap_t *ses_snap_hold(ses_target_t *); +extern void ses_snap_rele(ses_snap_t *); +extern ses_snap_t *ses_snap_new(ses_target_t *); +extern uint32_t ses_snap_generation(ses_snap_t *); + +extern ses_node_type_t ses_node_type(ses_node_t *); +extern nvlist_t *ses_node_props(ses_node_t *); +extern int ses_node_ctl(ses_node_t *, const char *, nvlist_t *); +extern ses_snap_t *ses_node_snapshot(ses_node_t *); +extern ses_target_t *ses_node_target(ses_node_t *); + +extern ses_errno_t ses_errno(void); +extern const char *ses_errmsg(void); +extern const char *ses_strerror(ses_errno_t); +extern const char *ses_nv_error_member(void); + +extern ses_node_t *ses_snap_primary_enclosure(ses_snap_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSES_H */ diff --git a/illumos-x86_64/usr/include/scsi/libses_plugin.h b/illumos-x86_64/usr/include/scsi/libses_plugin.h new file mode 100644 index 00000000..0bae67bb --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/libses_plugin.h @@ -0,0 +1,166 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBSES_PLUGIN_H +#define _LIBSES_PLUGIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LIBSES_PLUGIN_VERSION 1 + +/* + * These are the primary APIs for plugins to interact with libses. + */ + +struct ses_plugin; +typedef struct ses_plugin ses_plugin_t; + +typedef enum { + SES_PAGE_DIAG, + SES_PAGE_CTL +} ses_pagetype_t; + +typedef enum ses_page_req { + SES_REQ_OPTIONAL, + SES_REQ_MANDATORY_ALL, + SES_REQ_MANDATORY_STANDARD, + SES_REQ_OPTIONAL_STANDARD +} ses_page_req_t; + +typedef struct ses_pagedesc { + int spd_pagenum; + size_t (*spd_ctl_len)(uint_t, int, size_t); + void *(*spd_ctl_fill)(ses_plugin_t *, void *, size_t, + ses_node_t *); + void *(*spd_index)(ses_plugin_t *, ses_node_t *, + void *, size_t, size_t *); + int spd_gcoff; + ses_page_req_t spd_req; +} ses_pagedesc_t; + +typedef struct ses_plugin_config { + ses_pagedesc_t *spc_pages; + int (*spc_node_parse)(ses_plugin_t *, ses_node_t *); + int (*spc_node_ctl)(ses_plugin_t *, ses_node_t *, + const char *, nvlist_t *); +} ses_plugin_config_t; + +extern int ses_plugin_register(ses_plugin_t *, int, ses_plugin_config_t *); + +extern void *ses_plugin_page_lookup(ses_plugin_t *, ses_snap_t *, int, + ses_node_t *, size_t *); + +extern void *ses_plugin_ctlpage_lookup(ses_plugin_t *, ses_snap_t *, int, + size_t, ses_node_t *, boolean_t); + +extern void ses_plugin_setspecific(ses_plugin_t *, void *); +extern void *ses_plugin_getspecific(ses_plugin_t *); + +/* + * The following are support functions provided by libses. + */ + +extern int ses_assert(const char *, const char *, int); + +#define VERIFY(x) ((void)((x) || ses_assert(#x, __FILE__, __LINE__))) + +#ifdef DEBUG +#define ASSERT(x) VERIFY(x) +#else +#define ASSERT(x) +#endif + +#define SES_NV_ADD(_t, _e, _l, _n, ...) \ + if (((_e) = nvlist_add_##_t((_l), (_n), __VA_ARGS__)) != 0) \ + return (ses_set_nverrno((_e), (_n))) + +#define SES_NV_ADD_OR_FREE(_t, _e, _l, _n, ...) \ + if (((_e) = nvlist_add_##_t((_l), (_n), __VA_ARGS__)) != 0) { \ + nvlist_free(_l); return (ses_set_nverrno((_e), (_n))); } + +#define SES_NV_ADD_FS(_e, _l, _name, _buf) \ + SES_NV_ADD(fixed_string, (_e), (_l), (_name), (_buf), sizeof (_buf)) + +#define SES_NV_ADD_FS_TRUNC(_e, _l, _name, _buf) \ + SES_NV_ADD(fixed_string_trunc, (_e), (_l), (_name), (_buf), \ + sizeof (_buf)) + +#define SES_NV_CTLBOOL(_l, _n, _b) \ + { \ + boolean_t v = B_FALSE; \ + (void) nvlist_lookup_boolean_value((_l), (_n), &v); \ + (_b) = v; \ + } + +#define SES_NV_CTLBOOL_INVERT(_l, _n, _b) \ + { \ + boolean_t v = B_FALSE; \ + (void) nvlist_lookup_boolean_value((_l), (_n), &v); \ + (_b) = !v; \ + } + +#define SES_NV_CTL64(_l, _n, _v) \ + { \ + uint64_t v = 0; \ + (void) nvlist_lookup_uint64((_l), (_n), &v); \ + (_v) = v; \ + } + +#define SES_NV_CTL16(_l, _n, _v) \ + { \ + uint16_t v = 0; \ + (void) nvlist_lookup_uint16((_l), (_n), &v); \ + SCSI_WRITE16(&(_v), v); \ + } + +extern void *ses_alloc(size_t); +extern void *ses_zalloc(size_t); +extern char *ses_strdup(const char *); +extern void *ses_realloc(void *, size_t); +extern void ses_free(void *); + +extern int ses_set_errno(ses_errno_t); +extern int ses_set_nverrno(int, const char *); +extern int ses_error(ses_errno_t, const char *, ...); +extern int ses_nverror(int, const char *, const char *, ...); +extern void ses_panic(const char *, ...) __NORETURN; + +extern int nvlist_add_fixed_string(nvlist_t *, const char *, + const char *, size_t); +extern int nvlist_add_fixed_string_trunc(nvlist_t *, const char *, + const char *, size_t); + +#define SES_WITHIN_PAGE(sp, size, data, len) \ + ((char *)(sp) <= (char *)(data) + (len) - (size)) +#define SES_WITHIN_PAGE_STRUCT(sp, data, len) \ + SES_WITHIN_PAGE((sp), sizeof (*(sp)), (data), (len)) + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSES_PLUGIN_H */ diff --git a/illumos-x86_64/usr/include/scsi/libsmp.h b/illumos-x86_64/usr/include/scsi/libsmp.h new file mode 100644 index 00000000..1cb59563 --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/libsmp.h @@ -0,0 +1,127 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBSMP_H +#define _LIBSMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include + +#define LIBSMP_VERSION 1 + +#define SMP_TARGET_C_LONG_RESP 0x01 /* Long response (SAS-2 10.4.3.4) */ +#define SMP_TARGET_C_ZONING 0x02 /* Zoning supported */ +#define SMP_TARGET_C_ZG_256 0x04 /* 256 zone groups supported */ + +typedef enum smp_errno { + ESMP_NONE, /* no error */ + ESMP_NOMEM, /* no memory */ + ESMP_ZERO_LENGTH, /* zero-length allocation requested */ + ESMP_VERSION, /* library version mismatch */ + ESMP_BADTARGET, /* invalid target specification */ + ESMP_BADFUNC, /* invalid SMP function */ + ESMP_BADENGINE, /* engine library corrupt */ + ESMP_NOENGINE, /* engine library not found */ + ESMP_ENGINE_INIT, /* engine initialization failed */ + ESMP_ENGINE_VER, /* engine version mismatch */ + ESMP_ENGINE_BADPATH, /* engine path contains no usable components */ + ESMP_BADLENGTH, /* buffer length overflow or size error */ + ESMP_NEEDBUF, /* missing required buffer */ + ESMP_PLUGIN, /* no plugins found */ + ESMP_IO, /* I/O operation failed */ + ESMP_SYS, /* system call failed */ + ESMP_PERM, /* insufficient permissions */ + ESMP_RANGE, /* parameter outside valid range */ + ESMP_NOTSUP, /* operation not supported */ + ESMP_UNKNOWN, /* error of unknown type */ + ESMP_REPGEN_FAILED, /* initial report general command failed */ + ESMP_MAX /* maximum libsmp errno value */ +} smp_errno_t; + +typedef struct smp_target_def { + const char *std_engine; + const void *std_def; +} smp_target_def_t; + +struct smp_target; +typedef struct smp_target smp_target_t; + +struct smp_action; +typedef struct smp_action smp_action_t; + +extern int smp_init(int); +extern void smp_fini(void); + +extern smp_target_t *smp_open(const smp_target_def_t *); +extern uint_t smp_target_getcap(const smp_target_t *); +extern uint16_t smp_target_get_change_count(const smp_target_t *); +extern void smp_target_set_change_count(smp_target_t *, uint16_t); +extern uint8_t smp_target_get_number_of_phys(const smp_target_t *); +extern uint16_t smp_target_get_exp_route_indexes(const smp_target_t *); +extern const char *smp_target_vendor(const smp_target_t *); +extern const char *smp_target_product(const smp_target_t *); +extern const char *smp_target_revision(const smp_target_t *); +extern const char *smp_target_component_vendor(const smp_target_t *); +extern uint16_t smp_target_component_id(const smp_target_t *); +extern uint8_t smp_target_component_revision(const smp_target_t *); +extern void smp_target_name(const smp_target_t *, char *, size_t); +extern uint64_t smp_target_addr(const smp_target_t *); +extern void smp_close(smp_target_t *); + +extern smp_errno_t smp_errno(void); +extern smp_errno_t smp_errcode(const char *); +extern const char *smp_errmsg(void); +extern const char *smp_strerror(smp_errno_t); +extern const char *smp_errname(smp_errno_t); + +extern char *smp_trim_strdup(const char *, size_t); + +extern smp_action_t *smp_action_alloc(smp_function_t, smp_target_t *, size_t); +extern smp_action_t *smp_action_xalloc(smp_function_t, smp_target_t *, + void *, size_t, void *, size_t); +extern uint32_t smp_action_get_timeout(const smp_action_t *); +extern void smp_action_set_timeout(smp_action_t *, uint32_t); +extern void smp_action_get_request(const smp_action_t *, void **, size_t *); +extern void smp_action_get_response(const smp_action_t *, + smp_result_t *, void **, size_t *); +extern int smp_exec(smp_action_t *, smp_target_t *); +extern void smp_action_free(smp_action_t *); + +extern nvlist_t *smp_discover(const smp_target_def_t **, size_t); +extern nvlist_t *smp_discover_targets(smp_target_t **, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSMP_H */ diff --git a/illumos-x86_64/usr/include/scsi/libsmp_plugin.h b/illumos-x86_64/usr/include/scsi/libsmp_plugin.h new file mode 100644 index 00000000..9d5cbf1b --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/libsmp_plugin.h @@ -0,0 +1,132 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBSMP_PLUGIN_H +#define _LIBSMP_PLUGIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include + +#define LIBSMP_PLUGIN_VERSION 1 +#define LIBSMP_ENGINE_VERSION 1 + +#ifndef SMP_REQ_MINLEN +#define SMP_REQ_MINLEN \ + (offsetof(smp_request_frame_t, srf_data[0]) + sizeof (smp_crc_t)) +#endif +#ifndef SMP_RESP_MINLEN +#define SMP_RESP_MINLEN \ + (offsetof(smp_response_frame_t, srf_data[0]) + sizeof (smp_crc_t)) +#endif + +#define VERIFY(x) ((void)((x) || smp_assert(#x, __FILE__, __LINE__))) + +#ifdef DEBUG +#define ASSERT(x) VERIFY(x) +#else +#define ASSERT(x) +#endif + +struct smp_engine; +typedef struct smp_engine smp_engine_t; + +struct smp_plugin; +typedef struct smp_plugin smp_plugin_t; + +typedef struct smp_engine_ops { + void *(*seo_open)(const void *); + void (*seo_close)(void *); + int (*seo_exec)(void *, smp_action_t *); + void (*seo_target_name)(void *, char *, size_t); + uint64_t (*seo_target_addr)(void *); +} smp_engine_ops_t; + +typedef struct smp_engine_config { + const char *sec_name; + const smp_engine_ops_t *sec_ops; +} smp_engine_config_t; + +#define SMP_FD_F_NEEDS_CHANGE_COUNT 0x0001 +#define SMP_FD_F_PROVIDES_CHANGE_COUNT 0x0002 +#define SMP_FD_F_READ 0x0004 +#define SMP_FD_F_WRITE 0x0008 + +typedef struct smp_function_def { + smp_function_t sfd_function; + uint_t sfd_capmask; + uint_t sfd_capset; + uint_t sfd_flags; + size_t (*sfd_rq_len)(size_t, smp_target_t *); + off_t (*sfd_rq_dataoff)(smp_action_t *, smp_target_t *); + void (*sfd_rq_setframe)(smp_action_t *, smp_target_t *); + size_t (*sfd_rs_datalen)(smp_action_t *, smp_target_t *); + off_t (*sfd_rs_dataoff)(smp_action_t *, smp_target_t *); + void (*sfd_rs_getparams)(smp_action_t *, smp_target_t *); +} smp_function_def_t; + +typedef struct smp_plugin_config { + const char *spc_name; + smp_function_def_t *spc_functions; +} smp_plugin_config_t; + +extern int smp_assert(const char *, const char *, int); + +extern void *smp_alloc(size_t); +extern void *smp_zalloc(size_t); +extern char *smp_strdup(const char *); +extern void smp_free(void *); + +extern int smp_set_errno(smp_errno_t); +extern int smp_verror(smp_errno_t, const char *, va_list); +extern int smp_error(smp_errno_t, const char *, ...); + +extern void smp_action_get_request_frame(const smp_action_t *, + void **, size_t *); +extern void smp_action_get_response_frame(const smp_action_t *, + void **, size_t *); +extern void smp_action_set_response_len(smp_action_t *, size_t); +extern void smp_action_set_result(smp_action_t *, smp_result_t); +extern const smp_function_def_t *smp_action_get_function_def( + const smp_action_t *); + +extern int smp_engine_register(smp_engine_t *, int, + const smp_engine_config_t *); + +extern int smp_plugin_register(smp_plugin_t *, int, + const smp_plugin_config_t *); +extern void smp_plugin_setspecific(smp_plugin_t *, void *); +extern void *smp_plugin_getspecific(smp_plugin_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBSMP_PLUGIN_H */ diff --git a/illumos-x86_64/usr/include/scsi/plugins/ses/framework/libses.h b/illumos-x86_64/usr/include/scsi/plugins/ses/framework/libses.h new file mode 100644 index 00000000..50d27c4e --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/plugins/ses/framework/libses.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _FRAMEWORK_LIBSES_H +#define _FRAMEWORK_LIBSES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These are properties attached to the root target node of the enclosure, and + * represent the SCSI inquiry data. + */ +#define SCSI_PROP_VENDOR "scsi-inquiry-vendor" +#define SCSI_PROP_PRODUCT "scsi-inquiry-product" +#define SCSI_PROP_REVISION "scsi-inquiry-revision" + +/* + * This property provides a human-readable name for the element type. This is + * constant, and not derived from the enclosure data. + */ +#define LIBSES_PROP_ELEMENT_TYPE_NAME "libses-element-type-name" + +/* + * The following properties can be added to any node. There is no provision in + * the specification for these properties, but they can be derived from vendor + * specific data for some enclosures. + */ +#define LIBSES_PROP_PART "libses-part-number" +#define LIBSES_PROP_SERIAL "libses-serial-number" +#define LIBSES_PROP_FRU "libses-is-fru" +#define LIBSES_PROP_PHYS_PARENT "libses-physical-parent-element-index" + +/* + * The chassis serial number is a pseudo property that doesn't exist in SES + * spec. A single physical chassis may present several logically different SES + * targets that are connected to the same or different elements. These targets + * can extract the chassis serial number in a vendor-specific way so that + * consumers know these SES targets refer to the same device. This defaults to + * to the logical-id, and is always present. + */ +#define LIBSES_EN_PROP_CSN "libses-chassis-serial" + +/* + * This boolean property identifies a chassis as internal, where the connected + * elements are part of a single system chassis and not an external enclosure. + * This is used on platforms with a disk backplane that exports a SES target. + */ +#define LIBSES_EN_PROP_INTERNAL "libses-internal" + +/* + * This property identifies the subchassis id for those systems that + * support the concept of a subchassis. + */ +#define LIBSES_EN_PROP_SUBCHASSIS_ID "libses-subchassis-id" + +/* + * Maximum allowed firmware upload chunk size. Obtained in a vendor- or + * platform-specific manner but generic in nature. + */ +#define LIBSES_EN_PROP_FIRMWARE_CHUNK_SIZE "libses-firmware-chunksize" + +#ifdef __cplusplus +} +#endif + +#endif /* _FRAMEWORK_LIBSES_H */ diff --git a/illumos-x86_64/usr/include/scsi/plugins/ses/framework/ses2.h b/illumos-x86_64/usr/include/scsi/plugins/ses/framework/ses2.h new file mode 100644 index 00000000..41229cb2 --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/plugins/ses/framework/ses2.h @@ -0,0 +1,521 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _FRAMEWORK_SES2_H +#define _FRAMEWORK_SES2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Node properties + */ +typedef enum ses2_element_type { + SES_ET_UNSPECIFIED = 0, + SES_ET_DEVICE = 0x1, + SES_ET_POWER_SUPPLY = 0x2, + SES_ET_COOLING = 0x3, + SES_ET_TEMPERATURE_SENSOR = 0x4, + SES_ET_DOOR_LOCK = 0x5, + SES_ET_AUDIBLE_ALARM = 0x6, + SES_ET_ESC_ELECTRONICS = 0x7, + SES_ET_SCC_ELECTRONICS = 0x8, + SES_ET_NONVOLATILE_CACHE = 0x9, + SES_ET_INVALID_OPERATION_REASON = 0xa, + SES_ET_UPS = 0xb, + SES_ET_DISPLAY = 0xc, + SES_ET_KEY_PAD_ENTRY = 0xd, + SES_ET_ENCLOSURE = 0xe, + SES_ET_SCSI_PORT_XCVR = 0xf, + SES_ET_LANGUAGE = 0x10, + SES_ET_COMMUNICATION_PORT = 0x11, + SES_ET_VOLTAGE_SENSOR = 0x12, + SES_ET_CURRENT_SENSOR = 0x13, + SES_ET_SCSI_TARGET_PORT = 0x14, + SES_ET_SCSI_INITIATOR_PORT = 0x15, + SES_ET_SIMPLE_SUBENCLOSURE = 0x16, + SES_ET_ARRAY_DEVICE = 0x17, + SES_ET_SAS_EXPANDER = 0x18, + SES_ET_SAS_CONNECTOR = 0x19 +} ses2_element_type_t; + +#define SES_PROP_STATUS_CODE "ses-status-code" +typedef enum ses_element_status_code { + SES_ESC_UNSUPPORTED = 0, + SES_ESC_OK = 1, + SES_ESC_CRITICAL = 2, + SES_ESC_NONCRITICAL = 3, + SES_ESC_UNRECOVERABLE = 4, + SES_ESC_NOT_INSTALLED = 5, + SES_ESC_UNKNOWN = 6, + SES_ESC_UNAVAIL = 7, + SES_ESC_NO_ACCESS = 8 +} ses_element_status_code_t; + +#define SES_PROP_ELEMENT_CLASS_INDEX "ses-element-class-index" /* U64 */ +#define SES_PROP_ELEMENT_INDEX "ses-element-index" /* U64 */ +#define SES_PROP_ELEMENT_ONLY_INDEX "ses-element-only-index" /* U64 */ +#define SES_PROP_BAY_NUMBER "ses-bay-number" /* U64 */ +#define SES_PROP_PRDFAIL "ses-failure-predicted" +#define SES_PROP_SWAP "ses-swapped" +#define SES_PROP_DISABLED "ses-disabled" +#define SES_PROP_IDENT "ses-identify" +#define SES_PROP_WARN "ses-warning" +#define SES_PROP_FAIL "ses-failed" +#define SES_PROP_WARN_REQ "ses-warning-indicator-requested" +#define SES_PROP_FAIL_REQ "ses-failure-indicator-requested" +#define SES_PROP_REPORT "ses-reported-via" +#define SES_PROP_RMV "ses-ready-to-remove" +#define SES_PROP_OFF "ses-off" +#define SES_PROP_REQUESTED_ON "ses-requested-on" +#define SES_PROP_CLASS_DESCRIPTION "ses-class-description" /* S */ +#define SES_PROP_DESCRIPTION "ses-description" /* S */ +#define SES_PROP_HOT_SWAP "ses-hot-swappable" + +#define SES_PROP_CRIT_OVER "ses-critical-over" +#define SES_PROP_CRIT_UNDER "ses-critical-under" +#define SES_PROP_WARN_OVER "ses-warning-over" +#define SES_PROP_WARN_UNDER "ses-warning-under" + +#define SES_FC_PROP_NODE_NAME "ses-fc-node-name" /* U64 */ +#define SES_FC_PROP_LOOP_POS "ses-fc-loop-position" /* U64 */ +#define SES_FC_PROP_REQ_HARDADDR "ses-fc-requested-hard-address" +#define SES_FC_PROP_N_PORT_ID "ses-fc-n_port-identifier" /* U64 */ +#define SES_FC_PROP_N_PORT_NAME "ses-fc-n_port-name" /* U64 */ +#define SES_FC_PROP_PORTS "ses-fc-ports" /* NVA */ + +#define SES_SAS_PROP_DEVICE_TYPE "ses-sas-device-type" /* U64 */ +/* + * SAS2r11 7.8.2 Table 123 + */ +typedef enum sas_device_type { + SAS_DT_END_DEVICE = 0x01, + SAS_DT_EXPANDER = 0x02, + SAS_DT_LEGACY_EXPANDER = 0x3 +} sas_device_type_t; + +#define SES_SAS_PROP_SMPI_PORT "ses-sas-smp-initiator-port" +#define SES_SAS_PROP_STPI_PORT "ses-sas-stp-initiator-port" +#define SES_SAS_PROP_SSPI_PORT "ses-sas-ssp-initiator-port" +#define SES_SAS_PROP_SATA_DEVICE "ses-sas-sata-device" +#define SES_SAS_PROP_SMPT_PORT "ses-sas-smp-target-port" +#define SES_SAS_PROP_STPT_PORT "ses-sas-stp-target-port" +#define SES_SAS_PROP_SSPT_PORT "ses-sas-ssp-target-port" +#define SES_SAS_PROP_ATT_ADDR "ses-sas-attached-address" /* U64 */ +#define SES_SAS_PROP_ADDR "ses-sas-address" /* U64 */ +#define SES_SAS_PROP_PHY_ID "ses-sas-phy-identifier" /* U64 */ +#define SES_SAS_PROP_PHYS "ses-sas-phys" /* NVA */ +#define SES_PROP_CE_IDX "ses-connector-element-index" /* U64 */ +#define SES_PROP_OE_IDX "ses-other-element-index" /* U64 */ + +#define SES_PROP_THRESH_CRIT_HI "ses-high-critical-threshold" /* U64 */ +#define SES_PROP_THRESH_WARN_HI "ses-high-warning-threshold" /* U64 */ +#define SES_PROP_THRESH_CRIT_LO "ses-low-critical-threshold" /* U64 */ +#define SES_PROP_THRESH_WARN_LO "ses-low-warning-threshold" /* U64 */ + +/* + * Audible Alarm properties + */ +#define SES_ALARM_PROP_UNRECOV "ses-indicating-unrecoverable" +#define SES_ALARM_PROP_CRIT "ses-indicating-critical" +#define SES_ALARM_PROP_NONCRIT "ses-indicating-noncritical" +#define SES_ALARM_PROP_INFO "ses-indicating-informational" +#define SES_ALARM_PROP_REMIND "ses-reminder-mode" +#define SES_ALARM_PROP_MUTED "ses-muted" +#define SES_ALARM_PROP_RQST_MUTE "ses-mute-requested" + +/* + * Nonvolatile Cache properties + */ +#define SES_CACHE_PROP_SIZE "ses-cache-size" /* U64 */ + +/* + * Cooling Element properties + */ +#define SES_COOLING_PROP_FAN_SPEED "ses-fan-speed" /* U64 */ +#define SES_COOLING_PROP_SPEED_CODE "ses-fan-speed-code" /* U64 */ +typedef enum ses_cooling_fan_speed { + SES_COOLING_FAN_SPEED_STOPPED = 0, + SES_COOLING_FAN_SPEED_LOWEST = 1, + SES_COOLING_FAN_SPEED_LOWER = 2, + SES_COOLING_FAN_SPEED_LOW = 3, + SES_COOLING_FAN_SPEED_INTERMEDIATE = 4, + SES_COOLING_FAN_SPEED_HIGH = 5, + SES_COOLING_FAN_SPEED_HIGHER = 6, + SES_COOLING_FAN_SPEED_HIGHEST = 7 +} ses_cooling_fan_speed_t; + +/* + * Device/Array Device properties + */ +#define SES_DEV_PROP_SLOT_ADDR "ses-slot-address" /* U64 */ +#define SES_DEV_PROP_PRDFAIL "ses-failure-predicted" +#define SES_DEV_PROP_READY_TO_INSERT "ses-ready-to-insert" +#define SES_DEV_PROP_ENC_BYP_A "ses-enclosure-bypassed-a" +#define SES_DEV_PROP_ENC_BYP_B "ses-enclosure-bypassed-b" +#define SES_DEV_PROP_DO_NOT_REMOVE "ses-do-not-remove" +#define SES_DEV_PROP_APP_BYP_A "ses-app-client-bypassed-a" +#define SES_DEV_PROP_APP_BYP_B "ses-app-client-bypassed-b" +#define SES_DEV_PROP_DEV_BYP_A "ses-device-bypassed-a" +#define SES_DEV_PROP_DEV_BYP_B "ses-device-bypassed-b" +#define SES_DEV_PROP_BYP_A "ses-bypassed-a" +#define SES_DEV_PROP_BYP_B "ses-bypassed-b" +#define SES_DEV_PROP_FAULT_RQSTD "ses-fault-requested" +#define SES_DEV_PROP_FAULT_SENSED "ses-fault-sensed" +#define SES_DEV_PROP_SAS_NOT_ALL_PHYS "ses-sas-not-all-phys" + +/* Control only */ +#define SES_DEV_PROP_REQ_MISSING "ses-request-missing" +#define SES_DEV_PROP_REQ_ACTIVE "ses-request-activity" + +#define SES_AD_PROP_RR_ABORT "ses-remap-rebuild-abort" +#define SES_AD_PROP_REBUILD "ses-remap-rebuild" +#define SES_AD_PROP_IN_FAILED_ARRAY "ses-in-failed-array" +#define SES_AD_PROP_IN_CRIT_ARRAY "ses-in-critical-array" +#define SES_AD_PROP_CONS_CHK "ses-consistency-check" +#define SES_AD_PROP_HOT_SPARE "ses-hot-spare" +#define SES_AD_PROP_RSVD_DEVICE "ses-reserved-device" +#define SES_AD_PROP_OK "ses-ok" + +/* + * Display Element properties + */ +#define SES_DPY_PROP_CHAR "ses-displayed-character" /* U16 */ +#define SES_DPY_PROP_MODE "ses-display-mode" /* U64 */ +/* + * SES-2r17 Table 96, 7.3.14 + */ +typedef enum ses_display_mode_ctl { + SES_DISPLAY_MC_NOCHG = 0, + SES_DISPLAY_MC_ESP = 1, + SES_DISPLAY_MC_SET = 2 +} ses_display_mode_ctl_t; + +typedef enum ses2_display_mode_status { + SES_DISPLAY_MS_NOTSUP = 0, + SES_DISPLAY_MS_ESP = 1, + SES_DISPLAY_MS_SET = 2 +} ses_display_mode_status_t; + +/* + * Current Sensor properties + */ +#define SES_CS_PROP_CURRENT_MA "ses-current" /* I64 */ + +/* + * Door Lock properties + */ +#define SES_LOCK_PROP_UNLOCKED "ses-unlocked" + +/* + * SCSI Initiator or Target Port properties + */ +#define SES_ITP_PROP_ENABLED "ses-enabled" + +/* + * Language Module properties + */ +#define SES_LANG_PROP_LANGCODE "ses-language-code" /* U64 */ + +/* + * SCSI Port/Transceiver properties + */ +#define SES_PX_PROP_XMIT_FAIL "ses-transmitter-failure" +#define SES_PX_PROP_LOL "ses-loss-of-link" + +/* + * Power Supply properties + */ +#define SES_PSU_PROP_DC_OVER_CURRENT "ses-dc-over-current" +#define SES_PSU_PROP_DC_UNDER_VOLTAGE "ses-dc-under-voltage" +#define SES_PSU_PROP_DC_OVER_VOLTAGE "ses-dc-over-voltage" +#define SES_PSU_PROP_DC_FAIL "ses-dc-fail" +#define SES_PSU_PROP_AC_FAIL "ses-ac-fail" +#define SES_PSU_PROP_TEMP_WARN "ses-temperature-warning" /* I64 */ +#define SES_PSU_PROP_OVERTEMP_FAIL "ses-overtemperature-failure" + +/* + * SAS Expander properties + */ +#define SES_EXP_PROP_SAS_ADDR "ses-expander-sas-address" /* U64 */ + +/* + * SAS Connector properties + */ +#define SES_SC_PROP_PHYSICAL_LINK "ses-sas-physical-link" /* U64 */ +#define SES_SC_PROP_CONNECTOR_TYPE "ses-sas-connector-type" /* U64 */ +/* + * SES2r17 Table 122, 7.3.26 + */ +typedef enum ses_sasconn_type { + SES_SASCONN_T_UNKNOWN = 0, + SES_SASCONN_T_SFF_8470 = 0x1, + SES_SASCONN_T_SFF_8088 = 0x2, + SES_SASCONN_T_VENDOR_EXT = 0xf, + SES_SASCONN_T_SFF_8484 = 0x10, + SES_SASCONN_T_SFF_8087 = 0x11, + SES_SASCONN_T_SFF_8482_R = 0x20, + SES_SASCONN_T_SATA_HOST = 0x21, + SES_SASCONN_T_SFF_8482_P = 0x22, + SES_SASCONN_T_SATA_DEV = 0x23, + SES_SASCONN_T_VIRTUAL = 0x2f, + SES_SASCONN_T_VENDOR_INT = 0x3f, + SES_SASCONN_T_VENDOR_70 = 0x70, + SES_SASCONN_T_VENDOR_71 = 0x71, + SES_SASCONN_T_VENDOR_72 = 0x72, + SES_SASCONN_T_VENDOR_73 = 0x73, + SES_SASCONN_T_VENDOR_74 = 0x74, + SES_SASCONN_T_VENDOR_75 = 0x75, + SES_SASCONN_T_VENDOR_76 = 0x76, + SES_SASCONN_T_VENDOR_77 = 0x77, + SES_SASCONN_T_VENDOR_78 = 0x78, + SES_SASCONN_T_VENDOR_79 = 0x79, + SES_SASCONN_T_VENDOR_7A = 0x7a, + SES_SASCONN_T_VENDOR_7B = 0x7b, + SES_SASCONN_T_VENDOR_7C = 0x7c, + SES_SASCONN_T_VENDOR_7D = 0x7d, + SES_SASCONN_T_VENDOR_7E = 0x7e, + SES_SASCONN_T_VENDOR_7F = 0x7f +} ses_sasconn_type_t; + +/* + * Simple Subenclosure properties + */ +#define SES_SS_PROP_SHORT_STATUS "ses-short-status" /* U64 */ + +/* + * Temperature Sensor properties + */ +#define SES_TEMP_PROP_TEMP "ses-temperature" /* I64 */ + +/* + * Uninterruptible Power Supply properties + */ +#define SES_UPS_PROP_TIMELEFT "ses-battery-time-remaining" /* U64 */ +#define SES_UPS_PROP_INTF_FAIL "ses-interface-failure" +#define SES_UPS_PROP_WARN "ses-low-battery-warning" +#define SES_UPS_PROP_UPS_FAIL "ses-ups-failure" +#define SES_UPS_PROP_DC_FAIL "ses-dc-failure" +#define SES_UPS_PROP_AC_FAIL "ses-ac-failure" +#define SES_UPS_PROP_AC_QUAL "ses-ac-quality-exception" +#define SES_UPS_PROP_AC_HI "ses-ac-overvoltage-exception" +#define SES_UPS_PROP_AC_LO "ses-ac-undervoltage-exception" +#define SES_UPS_PROP_BPF "ses-battery-failure-predicted" +#define SES_UPS_PROP_BATT_FAIL "ses-battery-failure" + +/* + * Voltage Sensor properties + */ +#define SES_VS_PROP_VOLTAGE_MV "ses-voltage" /* I64 */ + +/* + * Enclosure Services Controller properties (Control only) + */ +#define SES_ESC_PROP_SELECT "ses-select-element" + +/* + * Primary/Subenclosure properties + */ +#define SES_EN_PROP_EID "ses-enclosure-id" /* U64 */ +#define SES_EN_PROP_ESPID "ses-enclosure-service-proc-id" +#define SES_EN_PROP_NESP "ses-enclosure-service-proc-count" +#define SES_EN_PROP_LID "ses-logical-id" /* NV */ +#define SES_EN_PROP_VID "ses-vendor-id" /* S */ +#define SES_EN_PROP_PID "ses-product-id" /* S */ +#define SES_EN_PROP_REV "ses-product-revision" /* S */ +#define SES_EN_PROP_VS "ses-product-vendor-specific" /* BA */ + +#define SES_EN_PROP_UNRECOV "ses-status-unrecoverable" +#define SES_EN_PROP_CRIT "ses-status-critical" +#define SES_EN_PROP_NONCRIT "ses-status-noncritical" +#define SES_EN_PROP_INFO "ses-status-informational" +#define SES_EN_PROP_INVOP "ses-status-invalid-operation" +#define SES_EN_PROP_HELP "ses-help-text" /* S */ +#define SES_EN_PROP_STRING "ses-string-in-data" /* BA */ +#define SES_EN_PROP_SHORT "ses-short-status" /* U64 */ +#define SES_EN_PROP_UCODE "ses-microcode-dl-status" /* U64 */ +typedef enum ses2_dl_ucode_status { + SES2_DLUCODE_S_NOP = 0, + SES2_DLUCODE_S_INPROGRESS = 0x1, + SES2_DLUCODE_S_SAVING = 0x2, + SES2_DLUCODE_S_INTERIM_3 = 0x3, + SES2_DLUCODE_S_INTERIM_4 = 0x4, + SES2_DLUCODE_S_INTERIM_5 = 0x5, + SES2_DLUCODE_S_INTERIM_6 = 0x6, + SES2_DLUCODE_S_INTERIM_7 = 0x7, + SES2_DLUCODE_S_INTERIM_8 = 0x8, + SES2_DLUCODE_S_INTERIM_9 = 0x9, + SES2_DLUCODE_S_INTERIM_A = 0xa, + SES2_DLUCODE_S_INTERIM_B = 0xb, + SES2_DLUCODE_S_INTERIM_C = 0xc, + SES2_DLUCODE_S_INTERIM_D = 0xd, + SES2_DLUCODE_S_INTERIM_E = 0xe, + SES2_DLUCODE_S_INTERIM_F = 0xf, + SES2_DLUCODE_S_COMPLETE_NOW = 0x10, + SES2_DLUCODE_S_COMPLETE_AT_RESET = 0x11, + SES2_DLUCODE_S_COMPLETE_AT_POWERON = 0x12, + SES2_DLUCODE_S_VENDOR_70 = 0x70, + SES2_DLUCODE_S_VENDOR_71 = 0x71, + SES2_DLUCODE_S_VENDOR_72 = 0x72, + SES2_DLUCODE_S_VENDOR_73 = 0x73, + SES2_DLUCODE_S_VENDOR_74 = 0x74, + SES2_DLUCODE_S_VENDOR_75 = 0x75, + SES2_DLUCODE_S_VENDOR_76 = 0x76, + SES2_DLUCODE_S_VENDOR_77 = 0x77, + SES2_DLUCODE_S_VENDOR_78 = 0x78, + SES2_DLUCODE_S_VENDOR_79 = 0x79, + SES2_DLUCODE_S_VENDOR_7A = 0x7a, + SES2_DLUCODE_S_VENDOR_7B = 0x7b, + SES2_DLUCODE_S_VENDOR_7C = 0x7c, + SES2_DLUCODE_S_VENDOR_7D = 0x7d, + SES2_DLUCODE_S_VENDOR_7E = 0x7e, + SES2_DLUCODE_S_VENDOR_7F = 0x7f, + SES2_DLUCODE_S_PAGE_ERR = 0x80, + SES2_DLUCODE_S_IMAGE_ERR = 0x81, + SES2_DLUCODE_S_TIMEOUT = 0x82, + SES2_DLUCODE_S_INTERNAL_NEEDIMAGE = 0x83, + SES2_DLUCODE_S_INTERNAL_SAFE = 0x84, + SES2_DLUCODE_S_VENDOR_ERR_F0 = 0xf0, + SES2_DLUCODE_S_VENDOR_ERR_F1 = 0xf1, + SES2_DLUCODE_S_VENDOR_ERR_F2 = 0xf2, + SES2_DLUCODE_S_VENDOR_ERR_F3 = 0xf3, + SES2_DLUCODE_S_VENDOR_ERR_F4 = 0xf4, + SES2_DLUCODE_S_VENDOR_ERR_F5 = 0xf5, + SES2_DLUCODE_S_VENDOR_ERR_F6 = 0xf6, + SES2_DLUCODE_S_VENDOR_ERR_F7 = 0xf7, + SES2_DLUCODE_S_VENDOR_ERR_F8 = 0xf8, + SES2_DLUCODE_S_VENDOR_ERR_F9 = 0xf9, + SES2_DLUCODE_S_VENDOR_ERR_FA = 0xfa, + SES2_DLUCODE_S_VENDOR_ERR_FB = 0xfb, + SES2_DLUCODE_S_VENDOR_ERR_FC = 0xfc, + SES2_DLUCODE_S_VENDOR_ERR_FD = 0xfd, + SES2_DLUCODE_S_VENDOR_ERR_FE = 0xfe, + SES2_DLUCODE_S_VENDOR_ERR_FF = 0xff +} ses2_dl_ucode_status_t; + +typedef enum ses_dl_ucode_mode { + SES_DLUCODE_M_WITH_OFFS = 6, + SES_DLUCODE_M_WITH_OFFS_SAVE = 7 +} ses_dl_ucode_mode_t; + +#define SES_EN_PROP_UCODE_A "ses-microcode-dl-addl-status" /* U64 */ +#define SES_EN_PROP_UCODE_SZ "ses-microcode-maximum-size" /* U64 */ +#define SES_EN_PROP_UCODE_BUF "ses-microcode-buffer-id" /* U64 */ +#define SES_EN_PROP_UCODE_OFF "ses-microcode-buffer-offset" /* U64 */ + +#define SES_EN_PROP_NICK "ses-nickname" /* S */ +#define SES_EN_PROP_NICK_STATUS "ses-nickname-status" /* U64 */ +typedef enum ses_subnick_status { + SES_SNS_NO_ERROR = 0x0, + SES_SNS_ERR_PAGE = 0x80, + SES_SNS_ERR_INT_NICKLOST = 0x81, + SES_SNS_ERR_INT_PRESERVED = 0x82 +} ses_subnick_status_t; + +#define SES_EN_PROP_NICK_ADDL_STATUS "ses-nickname-additional-status" +#define SES_EN_PROP_NICK_LANG "ses-nickname-language" /* U64 */ + +#define SES_EN_PROP_POWER_DELAY "ses-power-cycle-delay" /* U64 */ +#define SES_EN_PROP_POWER_DURATION "ses-power-cycle-duration" /* U64 */ +#define SES_EN_PROP_POWER_REQUEST "ses-power-cycle-request" /* U64 */ + +typedef enum ses_power_delay { + SES_PDL_NONE = 0x0, + SES_PDL_IMMEDIATE = 0x3f +} ses_power_delay_t; + +typedef enum ses_power_duration { + SES_PDR_NONE = 0x0, + SES_PDR_MANUAL = 0x3f +} ses_power_duration_t; + +typedef enum ses_power_request { + SES_PRQ_NONE = 0x0, + SES_PRQ_SET = 0x1, + SES_PRQ_CANCEL = 0x2 +} ses_power_request_t; + +/* + * IEEE logical IDs (for SES_EN_PROP_LID) + */ +#define SPC3_NAA_INT "naa-id-integer" /* U64 */ +#define SPC3_NAA_ID_TYPE "naa-id-type" /* U64 */ +#define SPC3_NAA_COMPANY_ID "naa-company-id" /* U64 */ +#define SPC3_NAA_VS_A "naa-vendor-specific-a" /* U64 */ +#define SPC3_NAA_VS_B "naa-vendor-specific-b" /* U64 */ + +/* + * SES-2 Diagnostic page codes (Table 5, 6.1.1). The set of exported pages + * constitutes an inter-plugin interface and is therefore part of the public + * header file. + */ +typedef enum ses2_diag_page { + SES2_DIAGPAGE_SUPPORTED_PAGES = 0x00, + SES2_DIAGPAGE_CONFIG = 0x01, + SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS = 0x02, + SES2_DIAGPAGE_HELP_TEXT = 0x03, + SES2_DIAGPAGE_STRING_IO = 0x04, + SES2_DIAGPAGE_THRESHOLD_IO = 0x05, + SES2_DIAGPAGE_ELEMENT_DESC = 0x07, + SES2_DIAGPAGE_SHORT_STATUS = 0x08, + SES2_DIAGPAGE_ENCLOSURE_BUSY = 0x09, + SES2_DIAGPAGE_ADDL_ELEM_STATUS = 0x0a, + SES2_DIAGPAGE_SUBENCLOSURE_HELP_TEXT = 0x0b, + SES2_DIAGPAGE_SUBENCLOSURE_STRING_IO = 0x0c, + SES2_DIAGPAGE_SUPPORTED_SES_PAGES = 0x0d, + SES2_DIAGPAGE_DL_MICROCODE_CTL_STATUS = 0x0e, + SES2_DIAGPAGE_SUBENCLOSURE_NICKNAME_CTL_STATUS = 0x0f, + SES2_DIAGPAGE_VENDOR_0 = 0x10, + SES2_DIAGPAGE_VENDOR_1 = 0x11, + SES2_DIAGPAGE_VENDOR_2 = 0x12, + SES2_DIAGPAGE_VENDOR_3 = 0x13, + SES2_DIAGPAGE_VENDOR_4 = 0x14, + SES2_DIAGPAGE_VENDOR_5 = 0x15, + SES2_DIAGPAGE_VENDOR_6 = 0x16, + SES2_DIAGPAGE_VENDOR_7 = 0x17, + SES2_DIAGPAGE_VENDOR_8 = 0x18, + SES2_DIAGPAGE_VENDOR_9 = 0x19, + SES2_DIAGPAGE_VENDOR_A = 0x1a, + SES2_DIAGPAGE_VENDOR_B = 0x1b, + SES2_DIAGPAGE_VENDOR_C = 0x1c, + SES2_DIAGPAGE_VENDOR_D = 0x1d, + SES2_DIAGPAGE_VENDOR_E = 0x1e, + SES2_DIAGPAGE_VENDOR_F = 0x1f +} ses2_diag_page_t; + +#define SES_CTL_OP_SETPROP "ses-ctl-setprop" +#define SES_CTL_OP_DL_UCODE "ses-ctl-dl-ucode" + +#define SES_CTL_PROP_UCODE_DATA "ses-ctl-ucode-data" +#define SES_CTL_PROP_UCODE_BUFID "ses-ctl-ucode-bufid" +#define SES_CTL_PROP_UCODE_MODE "ses-ctl-ucode-mode" +#define SES_CTL_PROP_UCODE_DATA_LEN "ses-ctl-ucode-data-length" /* U64 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _FRAMEWORK_SES2_H */ diff --git a/illumos-x86_64/usr/include/scsi/plugins/ses/framework/ses2_impl.h b/illumos-x86_64/usr/include/scsi/plugins/ses/framework/ses2_impl.h new file mode 100644 index 00000000..a080c1e3 --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/plugins/ses/framework/ses2_impl.h @@ -0,0 +1,1554 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright 2019 RackTop Systems + */ + +#ifndef _PLUGIN_SES_IMPL_H +#define _PLUGIN_SES_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#pragma pack(1) + +/* + * Generic IO timeout in seconds, from . + */ +#define SES2_TIMEOUT 60 + +/* + * SES-2 Enclosure Descriptor Header (Table 8, 6.1.2.2) + */ +typedef struct ses2_ed_hdr_impl { + DECL_BITFIELD4( + sehi_n_esps :3, + _reserved1 :1, + sehi_rel_esp_id :3, + _reserved2 :1); + uint8_t sehi_subenclosure_id; + uint8_t sehi_n_etd_hdrs; + uint8_t sehi_ed_len; +} ses2_ed_hdr_impl_t; + +/* + * SES-2 Enclosure Descriptor (Table 8, 6.1.2.2) + */ +typedef struct ses2_ed_impl { + ses2_ed_hdr_impl_t st_hdr; + spc3_naa_id_8_impl_t st_logical_id; + char st_vendor_id[8]; + char st_product_id[16]; + char st_product_revision[4]; + uint8_t st_priv[1]; +} ses2_ed_impl_t; + +/* + * SES-2 Type Descriptor Header (Table 9, 6.1.2.3) + */ +typedef struct ses2_td_hdr_impl { + uint8_t sthi_element_type; + uint8_t sthi_max_elements; + uint8_t sthi_subenclosure_id; + uint8_t sthi_text_len; +} ses2_td_hdr_impl_t; + +/* + * SES-2 Configuration diagnostic page (Table 7, 6.1.2.1) + */ +typedef struct ses2_config_page_impl { + uint8_t scpi_page_code; + uint8_t scpi_n_subenclosures; + uint16_t scpi_page_length; + uint32_t scpi_generation_code; + uint8_t scpi_data[1]; +} ses2_config_page_impl_t; + +/* + * Logically we should be able to use 4 or 8 bytes for a minimum allocation; + * however, it seems at least some devices will fail the request in that case. + */ +#define SES2_MIN_DIAGPAGE_ALLOC 512 + +/* + * SES-2 Element Control and Overall Control fields (Table 59, 7.2.2) + */ +typedef struct ses2_cmn_elem_ctl_impl { + DECL_BITFIELD5( + _reserved1 :4, + seci_rst_swap :1, + seci_disable :1, + seci_prdfail :1, + seci_select :1); +} ses2_cmn_elem_ctl_impl_t; + +typedef struct ses2_elem_ctl_impl { + ses2_cmn_elem_ctl_impl_t seci_common; + uint8_t seci_data[3]; +} ses2_elem_ctl_impl_t; + +/* + * SES-2 Element Status and Overall Status fields (Table 60, 7.2.3) + */ +typedef struct ses2_cmn_elem_status_impl { + DECL_BITFIELD5( + sesi_status_code :4, + sesi_swap :1, + sesi_disabled :1, + sesi_prdfail :1, + _reserved1 :1); +} ses2_cmn_elem_status_impl_t; + +typedef struct ses2_elem_status_impl { + ses2_cmn_elem_status_impl_t sesi_common; + uint8_t sesi_data[3]; +} ses2_elem_status_impl_t; + +/* + * SES-2 Device element for the Enclosure Control diagnostic page. + */ +typedef struct ses2_device_ctl_impl { + ses2_cmn_elem_ctl_impl_t sdci_common; + uint8_t _reserved1; + DECL_BITFIELD8( + _reserved2 :1, + sdci_rqst_ident :1, + sdci_rqst_remove :1, + sdci_rqst_insert :1, + sdci_rqst_missing :1, + _reserved3 :1, + sdci_do_not_remove :1, + sdci_rqst_active :1); + DECL_BITFIELD6( + _reserved4 :2, + sdci_enable_byp_b :1, + sdci_enable_byp_a :1, + sdci_device_off :1, + sdci_rqst_fault :1, + _reserved5 :2); +} ses2_device_ctl_impl_t; + +/* + * SES-2 Device element for the Enclosure Status diagnostic page + * (Table 64, 7.3.2). + */ +typedef struct ses2_device_status_impl { + ses2_cmn_elem_status_impl_t sdsi_common; + uint8_t sdsi_slot_addr; + DECL_BITFIELD8( + sdsi_report :1, + sdsi_ident :1, + sdsi_rmv :1, + sdsi_ready_to_insert :1, + sdsi_enclosure_bypassed_b :1, + sdsi_enclosure_bypassed_a :1, + sdsi_do_not_remove :1, + sdsi_app_client_bypassed_a :1); + DECL_BITFIELD8( + sdsi_device_bypassed_b :1, + sdsi_device_bypassed_a :1, + sdsi_bypassed_b :1, + sdsi_bypassed_a :1, + sdsi_device_off :1, + sdsi_fault_reqstd :1, + sdsi_fault_sensed :1, + sdsi_app_client_bypassed_b :1); +} ses2_device_status_impl_t; + +typedef struct ses2_array_device_ctl_impl { + ses2_cmn_elem_ctl_impl_t sadci_common; + DECL_BITFIELD8( + sadci_rqst_rr_abort :1, + sadci_rqst_rebuild :1, + sadci_rqst_in_failed_array :1, + sadci_rqst_in_crit_array :1, + sadci_rqst_cons_check :1, + sadci_rqst_hot_spare :1, + sadci_rqst_rsvd_device :1, + sadci_rqst_ok :1); + DECL_BITFIELD8( + _reserved1 :1, + sadci_rqst_ident :1, + sadci_rqst_remove :1, + sadci_rqst_insert :1, + sadci_rqst_missing :1, + _reserved2 :1, + sadci_do_not_remove :1, + sadci_rqst_active :1); + DECL_BITFIELD6( + _reserved3 :2, + sadci_enable_byp_b :1, + sadci_enable_byp_a :1, + sadci_device_off :1, + sadci_rqst_fault :1, + _reserved4 :2); +} ses2_array_device_ctl_impl_t; + +/* + * SES-2 Array Device element for the Enclosure Status diagnostic page + * (Table 66, 7.3.3) + */ +typedef struct ses2_array_device_status_impl { + ses2_cmn_elem_status_impl_t sadsi_common; + DECL_BITFIELD8( + sadsi_rr_abort :1, + sadsi_rebuild :1, + sadsi_in_failed_array :1, + sadsi_in_crit_array :1, + sadsi_cons_chk :1, + sadsi_hot_spare :1, + sadsi_rsvd_device :1, + sadsi_ok :1); + DECL_BITFIELD8( + sadsi_report :1, + sadsi_ident :1, + sadsi_rmv :1, + sadsi_ready_to_insert :1, + sadsi_enclosure_bypassed_b :1, + sadsi_enclosure_bypassed_a :1, + sadsi_do_not_remove :1, + sadsi_app_client_bypassed_a :1); + DECL_BITFIELD8( + sadsi_device_bypassed_b :1, + sadsi_device_bypassed_a :1, + sadsi_bypassed_b :1, + sadsi_bypassed_a :1, + sadsi_device_off :1, + sadsi_fault_reqstd :1, + sadsi_fault_sensed :1, + sadsi_app_client_bypassed_b :1); +} ses2_array_device_status_impl_t; + +/* + * SES-2 Power Supply element for control-type diagnostic pages (T68). + */ +typedef struct ses2_psu_ctl_impl { + ses2_cmn_elem_ctl_impl_t spci_common; + DECL_BITFIELD2( + _reserved1 :7, + spci_rqst_ident :1); + uint8_t _reserved2; + DECL_BITFIELD4( + _reserved3 :5, + spci_rqst_on :1, + spci_rqst_fail :1, + _reserved4 :1); +} ses2_psu_ctl_impl_t; + +/* + * SES-2 Power Supply element for status-type diagnostic pages (Table 69, 7.3.4) + */ +typedef struct ses2_psu_status_impl { + ses2_cmn_elem_status_impl_t spsi_common; + DECL_BITFIELD2( + _reserved1 :7, + spsi_ident :1); + DECL_BITFIELD5( + _reserved2 :1, + spsi_dc_over_current :1, + spsi_dc_under_voltage :1, + spsi_dc_over_voltage :1, + _reserved3 :4); + DECL_BITFIELD8( + spsi_dc_fail :1, + spsi_ac_fail :1, + spsi_temp_warn :1, + spsi_overtmp_fail :1, + spsi_off :1, + spsi_rqsted_on :1, + spsi_fail :1, + spsi_hot_swap :1); +} ses2_psu_status_impl_t; + +/* + * SES-2 Cooling element for control-type diagnostic pages (Table 70). + */ +typedef struct ses2_cooling_ctl_impl { + ses2_cmn_elem_ctl_impl_t scci_common; + DECL_BITFIELD2( + _reserved1 :7, + scci_rqst_ident :1); + uint8_t _reserved2; + DECL_BITFIELD5( + scci_requested_speed_code :3, + _reserved3 :2, + scci_rqst_on :1, + scci_rqst_fail :1, + _reserved4 :1); +} ses2_cooling_ctl_impl_t; + +/* + * SES-2 Cooling element for status-type diagnostic pages (Table 71, 7.3.5) + */ +typedef struct ses2_cooling_status_impl { + ses2_cmn_elem_status_impl_t scsi_common; + DECL_BITFIELD3( + scsi_fan_speed_ms3 :3, + _reserved1 :4, + scsi_ident :1); + uint8_t scsi_fan_speed_lsb; + DECL_BITFIELD6( + scsi_actual_speed_code :3, + _reserved2 :1, + scsi_off :1, + scsi_requested_on :1, + scsi_fail :1, + _reserved3 :1); +} ses2_cooling_status_impl_t; + +/* + * The fan_speed fields are multiplied by this factor to obtain the actual + * number of RPMs. + */ +#define SES2_ES_COOLING_SPEED_FACTOR 10 + +#define SES2_ES_COOLING_ST_FAN_SPEED(csip) \ + (((((uint16_t)(csip)->scsi_fan_speed_ms3) << 8) | \ + ((uint16_t)(csip)->scsi_fan_speed_lsb)) * \ + (uint16_t)SES2_ES_COOLING_SPEED_FACTOR) + +/* + * SES-2 Temperature Sensor element for control-type diagnostic pages (T74). + */ +typedef struct ses2_temp_ctl_impl { + ses2_cmn_elem_ctl_impl_t stci_common; + DECL_BITFIELD3( + _reserved1 :6, + stci_rqst_fail :1, + stci_rqst_ident :1); + uint8_t _reserved2[2]; +} ses2_temp_ctl_impl_t; + +/* + * SES-2 Temperature Sensor element for status-type diagnostic pages + * (Table 74, 7.3.6) + */ +typedef struct ses2_temp_status_impl { + ses2_cmn_elem_status_impl_t stsi_common; + DECL_BITFIELD3( + _reserved1 :6, + stsi_fail :1, + stsi_ident :1); + uint8_t stsi_temperature; + DECL_BITFIELD4( + stsi_ut_warn :1, + stsi_ut_fail :1, + stsi_ot_warn :1, + stsi_ot_fail :1); +} ses2_temp_status_impl_t; + +#define SES2_ES_TEMP_OFFSET (-20) + +#define SES2_ES_TEMP_ST_TEMPERATURE(tsip) \ + ((tsip)->stsi_temperature + SES2_ES_TEMP_OFFSET) + +/* + * SES-2 Door Lock element for control-type diagnostic pages (T76). + */ +typedef struct ses2_lock_ctl_impl { + ses2_cmn_elem_ctl_impl_t slci_common; + DECL_BITFIELD3( + _reserved1 :6, + slci_rqst_fail :1, + slci_rqst_ident :1); + uint8_t _reserved2; + DECL_BITFIELD2( + slci_unlock :1, + _reserved3 :7); +} ses2_lock_ctl_impl_t; + +/* + * SES-2 Door Lock element for status-type diagnostic pages (Table 77, 7.3.7) + */ +typedef struct ses2_lock_status_impl { + ses2_cmn_elem_status_impl_t slsi_common; + DECL_BITFIELD3( + _reserved1 :6, + slsi_fail :1, + slsi_ident :1); + uint8_t _reserved2; + DECL_BITFIELD2( + slsi_unlocked :1, + _reserved3 :7); +} ses2_lock_status_impl_t; + +/* + * SES-2 Audible Alarm element for control-type diagnostic pages (T78). + */ +typedef struct ses2_alarm_ctl_impl { + ses2_cmn_elem_ctl_impl_t saci_common; + DECL_BITFIELD3( + _reserved1 :6, + saci_rqst_fail :1, + saci_rqst_ident :1); + uint8_t _reserved2; + DECL_BITFIELD8( + saci_unrecov :1, + saci_crit :1, + saci_noncrit :1, + saci_info :1, + saci_set_remind :1, + _reserved3 :1, + saci_set_mute :1, + _reserved4 :1); +} ses2_alarm_ctl_impl_t; + +/* + * SES-2 Audible Alarm element for status-type diagnostic pages + * (Table 79, 7.3.8) + */ +typedef struct ses2_alarm_status_impl { + ses2_cmn_elem_status_impl_t sasi_common; + DECL_BITFIELD3( + _reserved1 :6, + sasi_fail :1, + sasi_ident :1); + uint8_t _reserved2; + DECL_BITFIELD8( + sasi_unrecov :1, + sasi_crit :1, + sasi_noncrit :1, + sasi_info :1, + sasi_remind :1, + _reserved3 :1, + sasi_muted :1, + sasi_rqst_mute :1); +} ses2_alarm_status_impl_t; + +/* + * SES-2 Enclosure Services Controller Electronics element for control-type + * diagnostic pages (Table 80, 7.3.9). + */ +typedef struct ses2_controller_ctl_impl { + ses2_cmn_elem_ctl_impl_t scci_common; + DECL_BITFIELD3( + _reserved1 :6, + scci_rqst_fail :1, + scci_rqst_ident :1); + DECL_BITFIELD2( + scci_select_element :1, + _reserved2 :7); + uint8_t _reserved3; +} ses2_controller_ctl_impl_t; + +/* + * SES-2 Enclosure Services Controller Electronics element for status-type + * diagnostic pages (Table 81, 7.3.9), + */ +typedef struct ses2_controller_status_impl { + ses2_cmn_elem_status_impl_t scsi_common; + DECL_BITFIELD3( + _reserved1 :6, + scsi_fail :1, + scsi_ident :1); + DECL_BITFIELD2( + scsi_report :1, + _reserved2 :7); + DECL_BITFIELD2( + _reserved3 :7, + scsi_hot_swap :1); +} ses2_controller_status_impl_t; + +/* + * SES-2 SCC Controller Electronics element for control-type diagnostic pages + * (Table 82, 7.3.10). + */ +typedef struct ses2_scc_ctl_impl { + ses2_cmn_elem_ctl_impl_t ssci_common; + DECL_BITFIELD3( + _reserved1 :6, + ssci_rqst_fail :1, + ssci_rqst_ident :1); + uint8_t _reserved2[2]; +} ses2_scc_ctl_impl_t; + +/* + * SES-2 SCC Controller Electronics element for status-type diagnostic pages + * (Table 83, 7.3.10) + */ +typedef struct ses2_scc_status_impl { + ses2_cmn_elem_status_impl_t sss_common; + DECL_BITFIELD3( + _reserved1 :6, + sss_fail :1, + sss_ident :1); + DECL_BITFIELD2( + sss_report :1, + _reserved2 :7); + uint8_t _reserved3; +} ses2_scc_status_impl_t; + +/* + * SES-2 Nonvolatile Cache element for control-type diagnostic pages + * (Table 84, 7.3.11). + */ +typedef struct ses2_nvcache_ctl_impl { + ses2_cmn_elem_ctl_impl_t snci_common; + DECL_BITFIELD3( + _reserved1 :6, + snci_rqst_fail :1, + snci_rqst_ident :1); + uint8_t _reserved2[2]; +} ses2_nvcache_ctl_impl_t; + +/* + * SES-2 Nonvolatile Cache element for status-type diagnostic pages (Table 85, + * 7.3.11) + */ +typedef struct ses2_nvcache_status_impl { + ses2_cmn_elem_status_impl_t snsi_common; + DECL_BITFIELD4( + snsi_size_multiplier :2, + _reserved1 :4, + snsi_fail :1, + snsi_ident :1); + uint16_t snsi_nvcache_size; +} ses2_nvcache_status_impl_t; + +/* + * Ibid., Table 86 defines the size multipliers as follows: + * + * 00b - bytes + * 01b - 1<<10 bytes + * 10b - 1<<20 bytes + * 11b - 1<<30 bytes + * + * We will calculate the actual size in bytes by doing + * + * nvcache_size << (SES2_NVCACHE_SHIFT * multiplier) + */ +#define SES2_NVCACHE_SHIFT 10 +#define SES2_NVCACHE_SIZE(nsip) \ + ((uint64_t)SCSI_READ16(&(nsip)->snsi_nvcache_size) << \ + (SES2_NVCACHE_SHIFT * (nsip)->snsi_size_multiplier)) + +/* + * SES-2 Invalid Operation Reason element for status-type diagnostic pages + * (Table 88, 7.3.12) + */ +typedef struct ses2_invop_reason_status_impl { + ses2_cmn_elem_status_impl_t sirsi_common; + DECL_BITFIELD2( + sirsi_priv_ms6 :6, + sirsi_invop_type :2); + uint8_t sirsi_priv[2]; +} ses2_invop_reason_status_impl_t; + +/* + * Ibid., Invop Type values (Table 89) + */ +typedef enum ses2_invop_type { + SES2_INVOP_SEND_PAGE_CODE = 0x0, + SES2_INVOP_SEND_PAGE_FORMAT = 0x1, + SES2_INVOP_VENDOR_SPECIFIC = 0x3 +} ses2_invop_type_t; + +/* + * Ibid., Invalid Operation Reason element for status-type diagnostic pages + * with Invop Type of 00b (Table 90) + */ +typedef struct ses2_invop_code_status_impl { + ses2_cmn_elem_status_impl_t sicsi_common; + DECL_BITFIELD3( + sicsi_page_not_supported :1, + _reserved1 :5, + sicsi_invop_type :2); + uint8_t _reserved2[2]; +} ses2_invop_code_status_impl_t; + +/* + * Ibid., Invalid Operation Reason element for status-type diagnostic pages + * with Invop Type of 01b (Table 91) + */ +typedef struct ses2_invop_format_status_impl { + ses2_cmn_elem_status_impl_t sifsi_common; + DECL_BITFIELD3( + sifsi_bit_number :3, + _reserved1 :3, + sifsi_invop_type :2); + uint16_t sifsi_byte_offset[2]; +} ses2_invop_format_status_impl_t; + +/* + * SES-2 Uninterruptible Power Supply element for control-type diagnostic + * pages (Table 93, 7.3.13) + */ +typedef struct ses2_ups_ctl_impl { + ses2_cmn_elem_ctl_impl_t suci_common; + uint8_t _reserved1[2]; + DECL_BITFIELD3( + _reserved2 :6, + suci_rqst_fail :1, + suci_rqst_ident :1); +} ses2_ups_ctl_impl_t; + +/* + * SES-2 Uninterruptible Power Supply element for status-type diagnostic pages + * (Table 94, 7.3.13) + */ +typedef struct ses2_ups_status_impl { + ses2_cmn_elem_status_impl_t susi_common; + uint8_t susi_battery_status; /* Time remaining in minutes */ + DECL_BITFIELD8( + susi_intf_fail :1, + susi_warn :1, + susi_ups_fail :1, + susi_dc_fail :1, + susi_ac_fail :1, + susi_ac_qual :1, + susi_ac_hi :1, + susi_ac_lo :1); + DECL_BITFIELD5( + susi_bpf :1, + susi_batt_fail :1, + _reserved1 :4, + susi_fail :1, + susi_ident :1); +} ses2_ups_status_impl_t; + +/* + * SES-2 Display element for control-type diagnostic pages (Table 95, 7.3.14) + */ +typedef struct ses2_display_ctl_impl { + ses2_cmn_elem_ctl_impl_t sdci_common; + DECL_BITFIELD4( + sdci_display_mode :2, + _reserved1 :4, + sdci_rqst_fail :1, + sdci_rqst_ident :1); + uint16_t sdci_display_character; +} ses2_display_ctl_impl_t; + +/* + * SES-2 Display element for status-type diagnostic pages (Table 97, 7.3.14) + */ +typedef struct ses2_display_status_impl { + ses2_cmn_elem_status_impl_t sdsi_common; + DECL_BITFIELD4( + sdsi_display_mode_status :2, + _reserved1 :3, + sdsi_fail :1, + sdsi_ident :1); + uint16_t sdsi_display_character_status; +} ses2_display_status_impl_t; + +/* + * SES-2 Key Pad Entry element for control-type diagnostic pages (Table 99). + */ +typedef struct ses2_keypad_ctl_impl { + ses2_cmn_elem_ctl_impl_t skci_common; + DECL_BITFIELD3( + _reserved1 :6, + skci_rqst_fail :1, + skci_rqst_ident :1); + uint8_t _reserved2[2]; +} ses2_keypad_ctl_impl_t; + +/* + * SES-2 Key Pad Entry element for status-type diagnostic pages (Table 100, + * 7.3.15) + */ +typedef struct ses2_keypad_status_impl { + ses2_cmn_elem_status_impl_t sksi_common; + DECL_BITFIELD3( + _reserved1 :6, + sksi_fail :1, + sksi_ident :1); + uint8_t _reserved2[2]; +} ses2_keypad_status_impl_t; + +/* + * SES-2 Enclosure element for control-type diagnostic pages (Table 101). + */ +typedef struct ses2_enclosure_ctl_impl { + ses2_cmn_elem_ctl_impl_t seci_common; + DECL_BITFIELD2( + _reserved1 :7, + seci_rqst_ident :1); + DECL_BITFIELD2( + seci_power_cycle_delay :6, + seci_power_cycle_request :2); + DECL_BITFIELD3( + seci_request_warning :1, + seci_request_failure :1, + seci_power_off_duration :6); +} ses2_enclosure_ctl_impl_t; + +/* + * SES-2 Enclosure element for status-type diagnostic pages (Table 101, 7.3.16) + */ +typedef struct ses2_enclosure_status_impl { + ses2_cmn_elem_status_impl_t sesi_common; + DECL_BITFIELD2( + _reserved1 :7, + sesi_ident :1); + DECL_BITFIELD3( + sesi_warning_indication :1, + sesi_failure_indication :1, + sesi_power_delay :6); + DECL_BITFIELD3( + sesi_warning_requested :1, + sesi_failure_requested :1, + sesi_power_duration :6); +} ses2_enclosure_status_impl_t; + +/* + * SES-2 SCSI Port/Transceiver element for control-type diagnostic pages (T103) + */ +typedef struct ses2_port_ctl_impl { + ses2_cmn_elem_ctl_impl_t spci_common; + DECL_BITFIELD3( + _reserved1 :6, + spci_rqst_fail :1, + spci_rqst_ident :1); + uint8_t _reserved2; + DECL_BITFIELD3( + _reserved3 :4, + spci_disable :1, + _reserved4 :3); +} ses2_port_ctl_impl_t; + +/* + * SES-2 SCSI Port/Transceiver element for status-type diagnostic pages + * (Table 104, 7.3.17) + */ +typedef struct ses2_port_status_impl { + ses2_cmn_elem_status_impl_t spsi_common; + DECL_BITFIELD3( + _reserved1 :6, + spsi_fail :1, + spsi_ident :1); + DECL_BITFIELD2( + spsi_report :1, + _reserved2 :7); + DECL_BITFIELD5( + spsi_xmit_fail :1, + spsi_lol :1, + _reserved3 :2, + spsi_disabled :1, + _reserved4 :3); +} ses2_port_status_impl_t; + +/* + * SES-2 Language element for control-type diagnostic pages (T105) + */ +typedef struct ses2_lang_ctl_impl { + ses2_cmn_elem_ctl_impl_t slci_common; + DECL_BITFIELD2( + _reserved1 :7, + slci_rqst_ident :1); + uint16_t slci_language_code; +} ses2_lang_ctl_impl_t; + +/* + * SES-2 Language element for status-type diagnostic pages (Table 105, 7.3.18) + */ +typedef struct ses2_lang_status_impl { + ses2_cmn_elem_status_impl_t slsi_common; + DECL_BITFIELD2( + _reserved1 :7, + slsi_ident :1); + uint16_t slsi_language_code; +} ses2_lang_status_impl_t; + +/* + * SES-2 Communication Port element for control-type diagnostic pages + * (Table 107, 7.3.19). + */ +typedef struct ses2_comm_ctl_impl { + ses2_cmn_elem_ctl_impl_t scci_common; + DECL_BITFIELD3( + _reserved1 :6, + scci_rqst_fail :1, + scci_rqst_ident :1); + uint8_t _reserved2; + DECL_BITFIELD2( + scci_disable :1, + _reserved3 :7); +} ses2_comm_ctl_impl_t; + +/* + * SES-2 Communication Port element for status-type diagnostic pages + * (Table 108, 7.3.19) + */ +typedef struct ses2_comm_status_impl { + ses2_cmn_elem_status_impl_t scsi_common; + DECL_BITFIELD3( + _reserved1 :6, + scsi_fail :1, + scsi_ident :1); + uint8_t _reserved2; + DECL_BITFIELD2( + scsi_disabled :1, + _reserved3 :7); +} ses2_comm_status_impl_t; + +/* + * SES-2 Voltage Sensor element for control-type diagnostic pages + * (Table 109, 7.3.20). + */ +typedef struct ses2_voltage_ctl_impl { + ses2_cmn_elem_ctl_impl_t svci_common; + DECL_BITFIELD3( + _reserved1 :6, + svci_rqst_fail :1, + svci_rqst_ident :1); + uint8_t _reserved2[2]; +} ses2_voltage_ctl_impl_t; + +/* + * SES-2 Voltage Sensor element for status-type diagnostic pages + * (Table 110, 7.3.20). + */ +typedef struct ses2_voltage_status_impl { + ses2_cmn_elem_status_impl_t svsi_common; + DECL_BITFIELD7( + svsi_crit_under :1, + svsi_crit_over :1, + svsi_warn_under :1, + svsi_warn_over :1, + _reserved1 :2, + svsi_fail :1, + svsi_ident :1); + uint16_t svsi_voltage; +} ses2_voltage_status_impl_t; + +/* + * Ibid. defines the svsi_voltage field as a 16-bit signed 2's complement + * integer, represented in units of 10 mV. AC voltages are RMS. + */ +#define SES2_VOLTAGE_MULTIPLIER (0.01) +#define SES2_VOLTAGE(vsip) \ + (SCSI_READ16(&(vsip)->svsi_voltage) * SES2_VOLTAGE_MULTIPLIER) + +/* + * SES-2 Current Sensor element for control-type diagnostic pages + * (Table 111, 7.3.21). + */ +typedef struct ses2_current_ctl_impl { + ses2_cmn_elem_ctl_impl_t scci_common; + DECL_BITFIELD3( + _reserved1 :6, + scci_rqst_fail :1, + scci_rqst_ident :1); + uint8_t _reserved2[2]; +} ses2_current_ctl_impl_t; + +/* + * SES-2 Current Sensor element for status-type diagnostic pages + * (Table 112, 7.3.21) + */ +typedef struct ses2_current_status_impl { + ses2_cmn_elem_status_impl_t scsi_common; + DECL_BITFIELD7( + _reserved1 :1, + scsi_crit_over :1, + _reserved2 :1, + scsi_warn_over :1, + _reserved3 :2, + scsi_fail :1, + scsi_ident :1); + uint16_t scsi_current; +} ses2_current_status_impl_t; + +/* + * Ibid. defines the scsi_voltage field in the same way as for voltage above. + * Units here are 10 mA. AC amperages are RMS. + */ +#define SES2_CURRENT_MULTIPLIER (0.01) +#define SES2_CURRENT(csip) \ + (SCSI_READ16(&(csip)->scsi_current) * SES2_CURRENT_MULTIPLIER) + +/* + * SES-2 SCSI Target Port element for control-type diagnostic pages + * (Table 113, 7.3.22), SCSI Initiator Port element for control-type + * diagnostic pages (Table 115, 7.3.23). + */ +typedef struct ses2_itp_ctl_impl { + ses2_cmn_elem_ctl_impl_t sici_common; + DECL_BITFIELD3( + _reserved1 :6, + sici_rqst_fail :1, + sici_rqst_ident :1); + uint8_t _reserved2; + DECL_BITFIELD2( + sici_enable :1, + _reserved3 :7); +} ses2_itp_ctl_impl_t; + +/* + * SES-2 SCSI Target Port element for status-type diagnostic pages (Table 114, + * 7.3.22), SCSI Initiator Port element for status-type diagnostic pages + * (Table 116, 7.3.23) + */ +typedef struct ses2_itp_status_impl { + ses2_cmn_elem_status_impl_t sisi_common; + DECL_BITFIELD3( + _reserved1 :6, + sisi_fail :1, + sisi_ident :1); + DECL_BITFIELD2( + sisi_report :1, + _reserved2 :7); + DECL_BITFIELD2( + sisi_enabled :1, + _reserved3 :7); +} ses2_itp_status_impl_t; + +/* + * SES-2 Simple Subenclosure element for control-type diagnostic pages + * (Table 117, 7.3.24). + */ +typedef struct ses2_ss_ctl_impl { + ses2_cmn_elem_ctl_impl_t ssci_common; + DECL_BITFIELD3( + _reserved1 :6, + ssci_rqst_fail :1, + ssci_rqst_ident :1); + uint8_t _reserved2[2]; +} ses2_ss_ctl_impl_t; + +/* + * SES-2 Simple Subenclosure element for status-type diagnostic pages + * (Table 117, 7.3.24) + */ +typedef struct ses2_ss_status_impl { + ses2_cmn_elem_status_impl_t sss_common; + DECL_BITFIELD3( + _reserved1 :6, + sss_fail :1, + sss_ident :1); + uint8_t _reserved2; + uint8_t sss_short_status; +} ses2_ss_status_impl_t; + +/* + * SES-2 SAS Expander element for control-type diagnostic pages + * (Table 119, 7.3.25). + */ +typedef struct ses2_expander_ctl_impl { + ses2_cmn_elem_ctl_impl_t seci_common; + DECL_BITFIELD3( + _reserved1 :6, + seci_rqst_fail :1, + seci_rqst_ident :1); + uint8_t _reserved2[2]; +} ses2_expander_ctl_impl_t; + +/* + * SES-2 SAS Expander element for status-type diagnostic pages (Table 120, + * 7.3.25) + */ +typedef struct ses2_expander_status_impl { + ses2_cmn_elem_status_impl_t sesi_common; + DECL_BITFIELD3( + _reserved1 :6, + sesi_fail :1, + sesi_ident :1); + uint8_t _reserved2[2]; +} ses2_expander_status_impl_t; + +/* + * SES-2 SAS Connector element for control-type diagnostic pages (Table 121, + * 7.3.26). + */ +typedef struct ses2_sasconn_ctl_impl { + ses2_cmn_elem_ctl_impl_t ssci_common; + DECL_BITFIELD2( + _reserved1 :7, + ssci_rqst_ident :1); + uint8_t _reserved2; + DECL_BITFIELD3( + _reserved3 :6, + ssci_rqst_fail :1, + _reserved4 :1); +} ses2_sasconn_ctl_impl_t; + +/* + * SES-2 SAS Connector element for status-type diagnostic pages (Table 122, + * 7.3.26) + */ +typedef struct ses2_sasconn_status_impl { + ses2_cmn_elem_status_impl_t sss_common; + DECL_BITFIELD2( + sss_connector_type :7, + sss_ident :1); + uint8_t sss_connector_physical_link; + DECL_BITFIELD3( + _reserved1 :6, + sss_fail :1, + _reserved2 :1); +} ses2_sasconn_status_impl_t; + +/* + * SES-2 Enclosure Control diagnostic page (Table 10, 6.1.3) + */ +typedef struct ses2_control_page_impl { + uint8_t scpi_page_code; + DECL_BITFIELD5( + scpi_unrecov :1, + scpi_crit :1, + scpi_noncrit :1, + scpi_info :1, + _reserved1 :4); + uint16_t scpi_page_length; + uint32_t scpi_generation_code; + ses2_elem_ctl_impl_t scpi_data[1]; +} ses2_control_page_impl_t; + +/* + * SES-2 Enclosure Status (Table 11, 6.1.4) + */ +typedef struct ses2_status_page_impl { + uint8_t sspi_page_code; + DECL_BITFIELD6( + sspi_unrecov :1, + sspi_crit :1, + sspi_noncrit :1, + sspi_info :1, + sspi_invop :1, + _reserved1 :3); + uint16_t sspi_page_length; + uint32_t sspi_generation_code; + uint8_t sspi_data[1]; +} ses2_status_page_impl_t; + +/* + * SES-2 Help Text diagnostic page (Table 13, 6.1.5). + */ +typedef struct ses2_help_page_impl { + uint8_t shpi_page_code; + uint8_t _reserved1; + uint16_t shpi_page_length; + char shpi_help_text[1]; +} ses2_help_page_impl_t; + +/* + * SES-2 String Out diagnostic page (Table 14, 6.1.6). + */ +typedef struct ses2_string_out_page_impl { + uint8_t ssopi_page_code; + uint8_t _reserved1; + uint16_t ssopi_page_length; + uint8_t ssopi_data[1]; +} ses2_string_out_page_impl_t; + +/* + * SES-2 String In diagnostic page (Table 15, 6.1.7). + */ +typedef struct ses2_string_in_page_impl { + uint8_t ssipi_page_code; + uint8_t _reserved1; + uint16_t ssipi_page_length; + uint8_t ssipi_data[1]; +} ses2_string_in_page_impl_t; + +/* + * SES-2 Threshold fields - (Table 17, 6.1.8), (Table 19, 6.1.9). + */ +typedef struct ses2_threshold_impl { + uint8_t sti_high_crit; + uint8_t sti_high_warn; + uint8_t sti_low_warn; + uint8_t sti_low_crit; +} ses2_threshold_impl_t; + +/* + * SES-2 Threshold Out diagnostic page (Table 16, 6.1.8). + */ +typedef struct ses2_threshold_out_page_impl { + uint8_t stopi_page_code; + uint8_t _reserved1; + uint16_t stopi_page_length; + uint32_t stopi_generation_code; + ses2_threshold_impl_t stopi_thresholds[1]; +} ses2_threshold_out_page_impl_t; + +/* + * SES-2 Threshold In diagnostic page (Table 18, 6.1.9). + */ +typedef struct ses2_threshold_in_page_impl { + uint8_t stipi_page_code; + DECL_BITFIELD3( + _reserved1 :4, + stipi_invop :1, + _reserved2 :3); + uint16_t stipi_page_length; + uint32_t stipi_generation_code; + ses2_threshold_impl_t stipi_thresholds[1]; +} ses2_threshold_in_page_impl_t; + +/* + * SES-2 Element Descriptor diagnostic page (Table 20, 6.1.10). + */ +typedef struct ses2_elem_desc_page_impl { + uint8_t sedpi_page_code; + uint8_t _reserved1; + uint16_t sedpi_page_length; + uint32_t sedpi_generation_code; + uint8_t sedpi_data[1]; +} ses2_elem_desc_page_impl_t; + +/* + * SES-2 Overall/element descriptor format (Table 22, 6.1.10). + */ +typedef struct ses2_elem_descriptor_impl { + uint8_t _reserved1[2]; + uint16_t sedi_descriptor_length; + char sedi_descriptor[1]; +} ses2_elem_descriptor_impl_t; + +/* + * SES-2 Short Enclosure Status diagnostic page (Table 23, 6.1.11). + */ +typedef struct ses2_short_status_page_impl { + uint8_t ssspi_page_code; + uint8_t ssspi_short_status; + uint16_t ssspi_page_length; +} ses2_short_status_page_impl_t; + +/* + * SES-2 Enclosure Busy diagnostic page (Table 24, 6.1.12). + */ +typedef struct ses2_enclosure_busy_page_impl { + uint8_t sebpi_page_code; + DECL_BITFIELD2( + sebpi_busy :1, + sebpi_vs_1_1 :7); + uint16_t sebpi_page_length; +} ses2_enclosure_busy_page_impl_t; + +/* + * SES-2 Additional Element Status diagnostic page (Table 25, 6.1.13). + */ +typedef struct ses2_aes_page_impl { + uint8_t sapi_page_code; + uint8_t _reserved1; + uint16_t sapi_page_length; + uint32_t sapi_generation_code; + uint8_t sapi_data[1]; +} ses2_aes_page_impl_t; + +/* + * SES-2 Additional Element Status descriptor (EIP == 1) (Table 26, 6.1.13). + * Updated with EIIOE for Table 32 from SES-3, 6.1.13. + * Note that we think later revs of SES-3 probably widen the EIIOE to 2 bits, + * waiting for final document to be sure. + */ +typedef struct ses2_aes_descr_eip_impl { + DECL_BITFIELD4( + sadei_protocol_identifier :4, + sadei_eip :1, + _reserved1 :2, + sadei_invalid :1); + uint8_t sadei_length; + DECL_BITFIELD2( + sadei_eiioe :2, + _reserved2 :6); + uint8_t sadei_element_index; + uint8_t sadei_protocol_specific[1]; +} ses2_aes_descr_eip_impl_t; + +/* + * SES-2 Additional Element Status descriptor (EIP == 0) (Table 27, 6.1.13). + */ +typedef struct ses2_aes_descr_impl { + DECL_BITFIELD4( + sadei_protocol_identifier :4, + sadei_eip :1, + _reserved1 :2, + sadei_invalid :1); + uint8_t sadei_length; + uint8_t sadei_protocol_specific[1]; +} ses2_aes_descr_impl_t; + +/* + * SES-2 Port descriptor (Table 30, 6.1.13.2). + */ +typedef struct ses2_aes_port_descr_impl { + uint8_t sapdi_port_loop_position; + uint8_t _reserved1[3]; + uint8_t sapdi_port_requested_hard_address; + uint8_t sapdi_n_port_identifier[3]; + uint64_t sapdi_n_port_name; +} ses2_aes_port_descr_impl_t; + +/* + * SES-2 Additional Element Status descriptor for FC (Table 28, 6.1.13.2). + */ +typedef struct ses2_aes_descr_fc_eip_impl { + uint8_t sadfi_n_ports; + uint8_t _reserved1[2]; + uint8_t sadfi_bay_number; + uint64_t sadfi_node_name; + ses2_aes_port_descr_impl_t sadfi_ports[1]; +} ses2_aes_descr_fc_eip_impl_t; + +/* + * SES-2 Additional Element Status descriptor for FC (EIP == 0) + * (Table 29, 6.1.13.2). + */ +typedef struct ses2_aes_descr_fc_impl { + uint8_t sadfi_n_ports; + uint8_t _reserved1; + uint64_t sadfi_node_name; + ses2_aes_port_descr_impl_t sadfi_ports[1]; +} ses2_aes_descr_fc_impl_t; + +/* + * SES-2 Additional Element Status descriptor for SAS (Table 31, 6.1.13.3). + */ +typedef struct ses2_aes_descr_sas_impl { + uint8_t _specific1; + DECL_BITFIELD2( + _specific2 :6, + sadsi_descriptor_type :2); + uint8_t _specific3[1]; +} ses2_aes_descr_sas_impl_t; + +typedef enum ses2_aes_descr_sas_type { + SES2_AESD_SAS_DEVICE = 0, + SES2_AESD_SAS_OTHER = 1 +} ses2_aes_descr_sas_type_t; + +typedef struct ses2_aes_phy0_descr_impl { + DECL_BITFIELD3( + _reserved1 :4, + sapdi_device_type :3, + _reserved2 :1); + uint8_t _reserved3; + DECL_BITFIELD5( + _reserved4 :1, + sapdi_smp_initiator_port :1, + sapdi_stp_initiator_port :1, + sapdi_ssp_initiator_port :1, + _reserved5 :4); + DECL_BITFIELD6( + sapdi_sata_device :1, + sapdi_smp_target_port :1, + sapdi_stp_target_port :1, + sapdi_ssp_target_port :1, + _reserved6 :3, + sapdi_sata_port_selector :1); + uint64_t sapdi_attached_sas_address; + uint64_t sapdi_sas_address; + uint8_t sapdi_phy_identifier; + uint8_t _reserved7[7]; +} ses2_aes_phy0_descr_impl_t; + +typedef struct ses2_aes_descr_sas0_eip_impl { + uint8_t sadsi_n_phy_descriptors; + DECL_BITFIELD3( + sadsi_not_all_phys :1, + _reserved1 :5, + sadsi_descriptor_type :2); + uint8_t _reserved2; + uint8_t sadsi_bay_number; + ses2_aes_phy0_descr_impl_t sadsi_phys[1]; +} ses2_aes_descr_sas0_eip_impl_t; + +typedef struct ses2_aes_descr_sas0_impl { + uint8_t sadsi_n_phy_descriptors; + DECL_BITFIELD3( + sadsi_not_all_phys :1, + _reserved1 :5, + sadsi_descriptor_type :2); + ses2_aes_phy0_descr_impl_t sadsi_phys[1]; +} ses2_aes_descr_sas0_impl_t; + +/* + * SES-2 Additional Element Status for SAS Expander elements + * (Table 36, 6.1.13.3.3). + */ +typedef struct ses2_aes_exp_phy_descr_impl { + uint8_t saepdi_connector_element_index; + uint8_t saepdi_other_element_index; +} ses2_aes_exp_phy_descr_impl_t; + +typedef struct ses2_aes_descr_exp_impl { + uint8_t sadei_n_exp_phy_descriptors; + DECL_BITFIELD2( + _reserved1 :6, + sadei_descriptor_type :2); + uint8_t _reserved2[2]; + uint64_t sadei_sas_address; + ses2_aes_exp_phy_descr_impl_t sadei_phys[1]; +} ses2_aes_descr_exp_impl_t; + +/* + * SES-2 Additional Element Status for SCSI Initiator/Target Port and + * Enclosure Services Controller Electronics elements (Table 38, 6.1.13.3.4). + */ +typedef struct ses2_aes_phy1_descr_impl { + uint8_t sapdi_phy_identifier; + uint8_t _reserved1; + uint8_t sapdi_connector_element_index; + uint8_t sapdi_other_element_index; + uint64_t sapdi_sas_address; +} ses2_aes_phy1_descr_impl_t; + +typedef struct ses2_aes_descr_sas1_impl { + uint8_t sadsi_n_phy_descriptors; + DECL_BITFIELD2( + _reserved1 :6, + sadsi_descriptor_type :2); + uint8_t _reserved2[2]; + ses2_aes_phy1_descr_impl_t sadsi_phys[1]; +} ses2_aes_descr_sas1_impl_t; + +/* + * SES-2 Subenclosure Help Text diagnostic page (Table 40, 6.1.14). + */ +typedef struct ses2_subhelp_page_impl { + uint8_t sspi_page_code; + uint8_t sspi_n_subenclosures; + uint16_t sspi_page_length; + uint32_t sspi_generation_code; + uint8_t sspi_data[1]; +} ses2_subhelp_page_impl_t; + +/* + * SES-2 Subenclosure help text format (Table 41, 6.1.14). + */ +typedef struct ses2_subhelp_text_impl { + uint8_t _reserved1; + uint8_t ssti_subenclosure_identifier; + uint16_t ssti_subenclosure_help_text_length; + char ssti_subenclosure_help_text[1]; +} ses2_subhelp_text_impl_t; + +#define SES2_SUBHELP_LEN(stip) \ + (SCSI_READ16(&(stip)->ssti_subenclosure_help_text_length) + \ + offsetof(ses2_subhelp_text_impl_t, ssti_subenclosure_help_text[0])) +/* + * SES-2 Subenclosure String Out diagnostic page (Table 42, 6.1.15). + */ +typedef struct ses2_substring_out_page_impl { + uint8_t ssopi_page_code; + uint8_t ssopi_subenclosure_identifier; + uint16_t ssopi_page_length; + uint32_t ssopi_generation_code; + uint8_t ssopi_data[1]; +} ses2_substring_out_page_impl_t; + +/* + * SES-2 Subenclosure String In diagnostic page (Table 43, 6.1.16). + */ +typedef struct ses2_substring_in_page_impl { + uint8_t ssipi_page_code; + uint8_t ssipi_n_subenclosures; + uint16_t ssipi_page_length; + uint32_t ssipi_generation_code; + uint8_t ssipi_data[1]; +} ses2_substring_in_page_impl_t; + +/* + * SES-2 Subenclosure string in data format (Table 44, 6.1.16). + */ +typedef struct ses2_substring_in_data_impl { + uint8_t _reserved1; + uint8_t ssidi_subenclosure_identifier; + uint16_t ssidi_substring_data_length; + uint8_t ssidi_data[1]; +} ses2_substring_in_data_impl_t; + +#define SES2_SUBSTR_LEN(sdip) \ + (SCSI_READ16(&(sdip)->ssidi_substring_data_length) + \ + offsetof(ses2_substring_in_data_impl_t, ssidi_data[0])) + +/* + * SES-2 Supported SES Diagnostic Pages diagnostic page (Table 45, 6.1.17). + */ +typedef struct ses2_supported_ses_diag_page_impl { + uint8_t sssdpi_page_code; + uint8_t _reserved1; + uint16_t sssdpi_page_length; + uint8_t sssdpi_pages[1]; +} ses2_supported_ses_diag_page_impl_t; + +/* + * SES-2 Download Microcode Control diagnostic page (Table 46, 6.1.18). + */ +typedef struct ses2_ucode_ctl_page_impl { + uint8_t sucpi_page_code; + uint8_t sucpi_subenclosure_identifier; + uint16_t sucpi_page_length; + uint32_t sucpi_generation_code; + uint8_t sucpi_dl_ucode_mode; + uint8_t _reserved1[2]; + uint8_t sucpi_buffer_id; + uint32_t sucpi_buffer_offset; + uint32_t sucpi_ucode_image_length; + uint32_t sucpi_ucode_data_length; + uint8_t sucpi_ucode_data[1]; +} ses2_ucode_ctl_page_impl_t; + +/* + * SES-2 Download Microcode Status diagnostic page (Table 48-49, 6.1.19). + */ +typedef struct ses2_ucode_status_descr_impl { + uint8_t _reserved1; + uint8_t susdi_subenclosure_identifier; + uint8_t susdi_subenclosure_dl_status; + uint8_t susdi_subenclosure_dl_addl_status; + uint32_t susdi_subenclosure_dl_max_size; + uint8_t _reserved2[3]; + uint8_t susdi_subenclosure_dl_buffer_id; + uint32_t susdi_subenclosure_dl_buffer_offset; +} ses2_ucode_status_descr_impl_t; + +typedef struct ses2_ucode_status_page_impl { + uint8_t suspi_page_code; + uint8_t suspi_n_subenclosures; + uint16_t suspi_page_length; + uint32_t suspi_generation_code; + ses2_ucode_status_descr_impl_t suspi_descriptors[1]; +} ses2_ucode_status_page_impl_t; + +/* + * SES-2 Subenclosure Nickname Control diagnostic page (Table 51, 6.1.20). + */ +typedef struct ses2_subnick_ctl_page_impl { + uint8_t sscpi_page_code; + uint8_t sspci_subenclosure_identifier; + uint16_t sspci_page_length; + uint32_t sspci_generation_code; + char sspci_subenclosure_nickname[32]; +} ses2_subnick_ctl_page_impl_t; + +/* + * SES-2 Subenclosure Nickname Status diagnostic page (Table 52-53, 6.1.21). + */ +typedef struct ses2_subnick_descr_impl { + uint8_t _reserved1; + uint8_t ssdi_subenclosure_identifier; + uint8_t ssdi_subenclosure_nick_status; + uint8_t ssdi_subenclosure_nick_addl_status; + uint8_t _reserved2[2]; + uint16_t ssdi_subenclosure_nick_lang_code; + char ssdi_subenclosure_nickname[32]; +} ses2_subnick_descr_impl_t; + +typedef struct ses2_subnick_status_page_impl { + uint8_t sspsi_page_code; + uint8_t sspci_n_subenclosures; + uint16_t sspci_page_length; + uint32_t sspci_generation_code; + ses2_subnick_descr_impl_t sspci_subnicks[1]; +} ses2_subnick_status_page_impl_t; + +/* + * SES-2 Mode page code for enclosure services devices (Table 57, 6.3.2). + */ +typedef struct ses2_esm_mode_page_impl { + DECL_BITFIELD3( + sempi_page_code :6, + _reserved1 :1, + sempi_ps :1); + uint8_t sempi_page_length; + uint8_t _reserved2[3]; + DECL_BITFIELD2( + sempi_enbltc :1, + _reserved3 :7); + uint16_t sempi_max_task_completion_time; +} ses2_esm_mode_page_impl_t; + +#pragma pack() + +extern ses_pagedesc_t ses2_pages[]; + +extern int ses2_fill_element_node(ses_plugin_t *, ses_node_t *); +extern int ses2_fill_enclosure_node(ses_plugin_t *, ses_node_t *); + +typedef int (*ses2_setprop_f)(ses_plugin_t *, ses_node_t *, ses2_diag_page_t, + nvpair_t *); + +typedef struct ses2_ctl_prop { + const char *scp_name; + data_type_t scp_type; + ses2_diag_page_t scp_num; + ses2_setprop_f scp_setprop; +} ses2_ctl_prop_t; + +typedef int (*ses2_setdef_f)(ses_node_t *, ses2_diag_page_t, void *); + +extern int ses2_ctl_common_setprop(ses_plugin_t *sp, ses_node_t *, + ses2_diag_page_t, nvpair_t *); + +#define SES_COMMON_CTL_PROPS \ +{ \ + .scp_name = SES_PROP_SWAP, \ + .scp_type = DATA_TYPE_BOOLEAN_VALUE, \ + .scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS, \ + .scp_setprop = ses2_ctl_common_setprop \ +}, \ +{ \ + .scp_name = SES_PROP_DISABLED, \ + .scp_type = DATA_TYPE_BOOLEAN_VALUE, \ + .scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS, \ + .scp_setprop = ses2_ctl_common_setprop \ +}, \ +{ \ + .scp_name = SES_PROP_PRDFAIL, \ + .scp_type = DATA_TYPE_BOOLEAN_VALUE, \ + .scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS, \ + .scp_setprop = ses2_ctl_common_setprop \ +} + +typedef struct ses2_ctl_desc { + ses2_element_type_t scd_et; + const ses2_ctl_prop_t *scd_props; + ses2_setdef_f scd_setdef; +} ses2_ctl_desc_t; + +extern int ses2_setprop(ses_plugin_t *, ses_node_t *, const ses2_ctl_prop_t *, + nvlist_t *); + +extern int ses2_element_setdef(ses_node_t *, ses2_diag_page_t, void *); +extern int ses2_enclosure_setdef(ses_node_t *, ses2_diag_page_t, void *); + +extern int ses2_element_ctl(ses_plugin_t *, ses_node_t *, const char *, + nvlist_t *); +extern int ses2_enclosure_ctl(ses_plugin_t *, ses_node_t *, const char *, + nvlist_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _PLUGIN_SES_IMPL_H */ diff --git a/illumos-x86_64/usr/include/scsi/plugins/ses/vendor/sun.h b/illumos-x86_64/usr/include/scsi/plugins/ses/vendor/sun.h new file mode 100644 index 00000000..0517629f --- /dev/null +++ b/illumos-x86_64/usr/include/scsi/plugins/ses/vendor/sun.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _VENDOR_SUN_H +#define _VENDOR_SUN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Node properties + */ +#define SUN_DIAGPAGE_FRUID SES2_DIAGPAGE_VENDOR_0 + +typedef enum sun_element_type { + SES_ET_SUNW_FANMODULE = 0x90, + SES_ET_SUNW_POWERBOARD = 0x94, + SES_ET_SUNW_POWERMODULE = 0x95, + SES_ET_SUNW_FANBOARD = 0x96 +} sun_element_type; + +#ifdef __cplusplus +} +#endif + +#endif /* _VENDOR_SUN_H */ diff --git a/illumos-x86_64/usr/include/sdp.h b/illumos-x86_64/usr/include/sdp.h new file mode 100644 index 00000000..2bc0d2b9 --- /dev/null +++ b/illumos-x86_64/usr/include/sdp.h @@ -0,0 +1,252 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SDP_H +#define _SDP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define SDP_VERSION_FIELD 'v' +#define SDP_ORIGIN_FIELD 'o' +#define SDP_NAME_FIELD 's' +#define SDP_INFO_FIELD 'i' +#define SDP_URI_FIELD 'u' +#define SDP_EMAIL_FIELD 'e' +#define SDP_PHONE_FIELD 'p' +#define SDP_CONNECTION_FIELD 'c' +#define SDP_BANDWIDTH_FIELD 'b' +#define SDP_TIME_FIELD 't' +#define SDP_REPEAT_FIELD 'r' +#define SDP_ZONE_FIELD 'z' +#define SDP_KEY_FIELD 'k' +#define SDP_ATTRIBUTE_FIELD 'a' +#define SDP_MEDIA_FIELD 'm' + +/* SDP Parse errors */ +#define SDP_VERSION_ERROR 0x00000001 +#define SDP_ORIGIN_ERROR 0x00000002 +#define SDP_NAME_ERROR 0x00000004 +#define SDP_INFO_ERROR 0x00000008 +#define SDP_URI_ERROR 0x00000010 +#define SDP_EMAIL_ERROR 0x00000020 +#define SDP_PHONE_ERROR 0x00000040 +#define SDP_CONNECTION_ERROR 0x00000080 +#define SDP_BANDWIDTH_ERROR 0x00000100 +#define SDP_TIME_ERROR 0x00000200 +#define SDP_REPEAT_TIME_ERROR 0x00000400 +#define SDP_ZONE_ERROR 0x00000800 +#define SDP_KEY_ERROR 0x00001000 +#define SDP_ATTRIBUTE_ERROR 0x00002000 +#define SDP_MEDIA_ERROR 0x00004000 +#define SDP_FIELDS_ORDER_ERROR 0x00008000 +#define SDP_MISSING_FIELDS 0x00010000 + +#define SDP_AUDIO "audio" +#define SDP_VIDEO "video" +#define SDP_TEXT "text" +#define SDP_APPLICATION "application" +#define SDP_MESSAGE "message" +#define SDP_RTPMAP "rtpmap" + +#define SDP_SESSION_VERSION_1 1 + +typedef struct sdp_list { + void *value; + struct sdp_list *next; +} sdp_list_t; + +/* + * SDP origin field. + * o= + */ +typedef struct sdp_origin { + char *o_username; + uint64_t o_id; + uint64_t o_version; + char *o_nettype; + char *o_addrtype; + char *o_address; +} sdp_origin_t; + +/* + * SDP connection field. + * c= [/ttl]/ + */ +typedef struct sdp_conn { + char *c_nettype; + char *c_addrtype; + char *c_address; + int c_addrcount; + struct sdp_conn *c_next; + uint8_t c_ttl; +} sdp_conn_t; + +/* + * SDP repeat field. Always found in time structure. + * r= + */ +typedef struct sdp_repeat { + uint64_t r_interval; + uint64_t r_duration; + sdp_list_t *r_offset; + struct sdp_repeat *r_next; +} sdp_repeat_t; + +/* + * SDP time field. + * t= + */ +typedef struct sdp_time { + uint64_t t_start; + uint64_t t_stop; + sdp_repeat_t *t_repeat; + struct sdp_time *t_next; +} sdp_time_t; + +/* + * SDP time zone field. + * z= .... + */ +typedef struct sdp_zone { + uint64_t z_time; + char *z_offset; + struct sdp_zone *z_next; +} sdp_zone_t; + +/* + * SDP attribute field. + * a= or a=: + */ +typedef struct sdp_attr { + char *a_name; + char *a_value; + struct sdp_attr *a_next; +} sdp_attr_t; + +/* + * SDP bandwidth field. + * b=: + */ +typedef struct sdp_bandwidth { + char *b_type; + uint64_t b_value; + struct sdp_bandwidth *b_next; +} sdp_bandwidth_t; + +/* + * SDP key field to session or media section of SDP. + * k= or k=: + */ +typedef struct sdp_key { + char *k_method; + char *k_enckey; +} sdp_key_t; + +typedef struct sdp_session sdp_session_t; + +/* + * SDP media section, contains media fields and other fields within + * media section. + * m= [/portcount] ... + */ +typedef struct sdp_media { + char *m_name; + uint_t m_port; + int m_portcount; + char *m_proto; + sdp_list_t *m_format; + char *m_info; + sdp_conn_t *m_conn; + sdp_bandwidth_t *m_bw; + sdp_key_t *m_key; + sdp_attr_t *m_attr; + struct sdp_media *m_next; + sdp_session_t *m_session; +} sdp_media_t; + +struct sdp_session { + int sdp_session_version; + int s_version; + sdp_origin_t *s_origin; + char *s_name; + char *s_info; + char *s_uri; + sdp_list_t *s_email; + sdp_list_t *s_phone; + sdp_conn_t *s_conn; + sdp_bandwidth_t *s_bw; + sdp_time_t *s_time; + sdp_zone_t *s_zone; + sdp_key_t *s_key; + sdp_attr_t *s_attr; + sdp_media_t *s_media; +}; + +extern int sdp_parse(const char *, int, int, sdp_session_t **, + uint_t *); +extern sdp_media_t *sdp_find_media(sdp_media_t *, const char *); +extern sdp_attr_t *sdp_find_attribute(sdp_attr_t *, const char *); +extern sdp_attr_t *sdp_find_media_rtpmap(sdp_media_t *, const char *); +extern sdp_session_t *sdp_clone_session(const sdp_session_t *); +extern sdp_session_t *sdp_new_session(); +extern int sdp_add_origin(sdp_session_t *, const char *, uint64_t, + uint64_t, const char *, const char *, const char *); +extern int sdp_add_name(sdp_session_t *, const char *); +extern int sdp_add_information(char **, const char *); +extern int sdp_add_uri(sdp_session_t *, const char *); +extern int sdp_add_email(sdp_session_t *, const char *); +extern int sdp_add_phone(sdp_session_t *, const char *); +extern int sdp_add_connection(sdp_conn_t **, const char *, + const char *, const char *, uint8_t, int); +extern int sdp_add_bandwidth(sdp_bandwidth_t **, const char *, + uint64_t); +extern int sdp_add_repeat(sdp_time_t *, uint64_t, uint64_t, + const char *); +extern int sdp_add_time(sdp_session_t *, uint64_t, uint64_t, + sdp_time_t **); +extern int sdp_add_zone(sdp_session_t *, uint64_t, const char *); +extern int sdp_add_key(sdp_key_t **, const char *, const char *); +extern int sdp_add_attribute(sdp_attr_t **, const char *, + const char *); +extern int sdp_add_media(sdp_session_t *, const char *, uint_t, + int, const char *, const char *, sdp_media_t **); +extern int sdp_delete_all_field(sdp_session_t *, const char); +extern int sdp_delete_all_media_field(sdp_media_t *, const char); +extern int sdp_delete_media(sdp_media_t **, sdp_media_t *); +extern int sdp_delete_attribute(sdp_attr_t **, sdp_attr_t *); +extern void sdp_free_session(sdp_session_t *); +extern char *sdp_session_to_str(const sdp_session_t *, int *); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SDP_H */ diff --git a/illumos-x86_64/usr/include/search.h b/illumos-x86_64/usr/include/search.h new file mode 100644 index 00000000..2eae7ded --- /dev/null +++ b/illumos-x86_64/usr/include/search.h @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SEARCH_H +#define _SEARCH_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* HSEARCH(3C) */ +typedef enum { FIND, ENTER } ACTION; + +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) +struct qelem { + struct qelem *q_forw; + struct qelem *q_back; +}; +#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */ + +typedef struct entry { char *key, *data; } ENTRY; + +int hcreate(size_t); +void hdestroy(void); +ENTRY *hsearch(ENTRY, ACTION); +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2) +void insque(void *, void *); +void remque(void *); +#endif + + +/* TSEARCH(3C) */ +typedef enum { preorder, postorder, endorder, leaf } VISIT; + +void *tdelete(const void *_RESTRICT_KYWD, void **_RESTRICT_KYWD, + int (*)(const void *, const void *)); +void *tfind(const void *, void *const *, int (*)(const void *, const void *)); +void *tsearch(const void *, void **, int (*)(const void *, const void *)); +void twalk(const void *, void (*)(const void *, VISIT, int)); + + +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) +/* BSEARCH(3C) */ +void *bsearch(const void *, const void *, size_t, size_t, + int (*)(const void *, const void *)); +#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */ + +/* LSEARCH(3C) */ +void *lfind(const void *, const void *, size_t *, size_t, + int (*)(const void *, const void *)); +void *lsearch(const void *, void *, size_t *, size_t, + int (*)(const void *, const void *)); + +#ifdef __cplusplus +} +#endif + +#endif /* _SEARCH_H */ diff --git a/illumos-x86_64/usr/include/secdb.h b/illumos-x86_64/usr/include/secdb.h new file mode 100644 index 00000000..f5fed8e9 --- /dev/null +++ b/illumos-x86_64/usr/include/secdb.h @@ -0,0 +1,103 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SECDB_H +#define _SECDB_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#define DEFAULT_POLICY "solaris" +#define SUSER_POLICY "suser" /* fallback: old policy */ + +#define KV_ACTION "act" +#define KV_COMMAND "cmd" +#define KV_JAVA_CLASS "java_class" +#define KV_JAVA_METHOD "java_method" + +#define KV_ASSIGN "=" +#define KV_DELIMITER ";" +#define KV_EMPTY "" +#define KV_ESCAPE '\\' +#define KV_ADD_KEYS 16 /* number of key value pairs to realloc */ +#define KV_SPECIAL "=;:\\" +#define KV_TOKEN_DELIMIT ":" +#define KV_WILDCARD "*" +#define KV_WILDCHAR '*' +#define KV_ACTION_WILDCARD "*;*;*;*;*" +#define KV_SEPCHAR ',' +#define KV_SEPSTR "," +#define KV_OBJECTCHAR '/' +#define KV_OBJECT "/" +#define KV_AUDIT_DELIMIT ":" + +#define KV_FLAG_NONE 0x0000 +#define KV_FLAG_REQUIRED 0x0001 + +/* + * return status macros for all attribute databases + */ +#define ATTR_FOUND 0 /* Authoritative found */ +#define ATTR_NOT_FOUND -1 /* Authoritative not found */ +#define ATTR_NO_RECOVERY -2 /* Non-recoverable errors */ + + +typedef struct kv_s { + char *key; + char *value; +} kv_t; /* A key-value pair */ + +typedef struct kva_s { + int length; /* array length */ + kv_t *data; /* array of key value pairs */ +} kva_t; /* Key-value array */ + + +extern char *kva_match(kva_t *, char *); +extern int _auth_match(const char *, const char *); +extern char *_argv_to_csl(char **strings); +extern char **_csl_to_argv(char *csl); +extern char *_do_unescape(char *src); +extern void _free_argv(char **p_argv); +extern int _insert2kva(kva_t *, char *, char *); +extern int _kva2str(kva_t *, char *, int, char *, char *); +extern kva_t *_kva_dup(kva_t *); +extern void _kva_free(kva_t *); +extern void _kva_free_value(kva_t *, char *); +extern kva_t *_new_kva(int size); +extern kva_t *_str2kva(char *, char *, char *); +extern int _enum_auths(const char *, int (*)(const char *, void *, void *), + void *ctxt, void *pres); +extern int _enum_profs(const char *, + int (*)(const char *, kva_t *, void *, void *), void *ctxt, void *pres); +extern int _enum_attrs(const char *, + int (*)(const char *, kva_t *, void *, void *), void *ctxt, void *pres); + +#ifdef __cplusplus +} +#endif + +#endif /* _SECDB_H */ diff --git a/illumos-x86_64/usr/include/security/auditd.h b/illumos-x86_64/usr/include/security/auditd.h new file mode 100644 index 00000000..d7ca96de --- /dev/null +++ b/illumos-x86_64/usr/include/security/auditd.h @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2017 Tintri by DDN, Inc. All rights reserved. + * + * This is an unstable interface; changes may be made without + * notice. + */ + +#ifndef _AUDITD_H +#define _AUDITD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * "WARN" errors trigger calls to audit_warn + */ +enum auditd_rc { + AUDITD_SUCCESS, /* ok */ + AUDITD_RETRY, /* retry after a delay (WARN retry) */ + AUDITD_NO_MEMORY, /* can't allocate memory (WARN no_memory) */ + AUDITD_INVALID, /* bad input (WARN invalid) */ + AUDITD_COMM_FAIL, /* communications failure */ + AUDITD_FATAL, /* other error (WARN failure) */ + AUDITD_FAIL, /* other non-fatal error */ + AUDITD_DISCARD /* Discarded message */ +}; +typedef enum auditd_rc auditd_rc_t; + +/* + * auditd_plugin() + * arg 1 - input buffer, binary Solaris audit record + * arg 2 - input buffer length + * arg 3 - record sequence number + * arg 4 - optional explanation of error return (use NULL, + * not an empty string if not used.) + */ +auditd_rc_t auditd_plugin(const char *, size_t, uint64_t, char **); +/* + * auditd_plugin_open() + * arg 1 - attr/val struct, use with kva_match() + * arg 2 - attr/value pair string: attr1=value1;attr2=value2 + * arg 3 - optional explanation of error return (use NULL, + * not an empty string if not used.) + * + * make local copy of args 1 and 2; they are trashed after return. + */ +auditd_rc_t auditd_plugin_open(const kva_t *, char **, char **); + +/* + * auditd_plugin_close() + * arg 1 - optional explanation of error return (use NULL, + * not an empty string if not used.) + */ +auditd_rc_t auditd_plugin_close(char **); + +#ifdef __cplusplus +} +#endif + +#endif /* _AUDITD_H */ diff --git a/illumos-x86_64/usr/include/security/cryptoki.h b/illumos-x86_64/usr/include/security/cryptoki.h new file mode 100644 index 00000000..2486b6c0 --- /dev/null +++ b/illumos-x86_64/usr/include/security/cryptoki.h @@ -0,0 +1,144 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _CRYPTOKI_H +#define _CRYPTOKI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CK_PTR +#define CK_PTR * +#endif + +#ifndef CK_DEFINE_FUNCTION +#define CK_DEFINE_FUNCTION(returnType, name) returnType name +#endif + +#ifndef CK_DECLARE_FUNCTION +#define CK_DECLARE_FUNCTION(returnType, name) returnType name +#endif + +#ifndef CK_DECLARE_FUNCTION_POINTER +#define CK_DECLARE_FUNCTION_POINTER(returnType, name) returnType (* name) +#endif + +#ifndef CK_CALLBACK_FUNCTION +#define CK_CALLBACK_FUNCTION(returnType, name) returnType (* name) +#endif + +#ifndef NULL_PTR +#include /* For NULL */ +#define NULL_PTR NULL +#endif + +/* + * pkcs11t.h defines TRUE and FALSE in a way that upsets lint + */ +#ifndef CK_DISABLE_TRUE_FALSE +#define CK_DISABLE_TRUE_FALSE +#ifndef TRUE +#define TRUE 1 +#endif /* TRUE */ +#ifndef FALSE +#define FALSE 0 +#endif /* FALSE */ +#endif /* CK_DISABLE_TRUE_FALSE */ + +#undef CK_PKCS11_FUNCTION_INFO + +#include + +/* Default salt len to generate PKCS#5 key */ +#define CK_PKCS5_PBKD2_SALT_SIZE (16UL) + +/* Default number of iterations to generate PKCS#5 key */ +#define CK_PKCS5_PBKD2_ITERATIONS (1000UL) + +/* Solaris specific functions */ + +#include + +/* + * pkcs11_GetCriteriaSession will initialize the framework and do all + * the necessary work of calling C_GetSlotList(), C_GetMechanismInfo() + * C_OpenSession() to create a session that meets all the criteria in + * the given function pointer. + */ +CK_RV pkcs11_GetCriteriaSession( + boolean_t (*criteria)(CK_SLOT_ID slot_id, void *args, CK_RV *rv), + void *args, CK_SESSION_HANDLE_PTR hSession); + +/* + * SUNW_C_GetMechSession will initialize the framework and do all + * the necessary PKCS#11 calls to create a session capable of + * providing operations on the requested mechanism + */ +CK_RV SUNW_C_GetMechSession(CK_MECHANISM_TYPE mech, + CK_SESSION_HANDLE_PTR hSession); + +/* + * SUNW_C_KeyToObject will create a secret key object for the given + * mechanism from the rawkey data. + */ +CK_RV SUNW_C_KeyToObject(CK_SESSION_HANDLE hSession, + CK_MECHANISM_TYPE mech, const void *rawkey, size_t rawkey_len, + CK_OBJECT_HANDLE_PTR obj); + +/* + * pkcs11_PasswdToPBKD2Object will create a secret key from the given string + * (e.g. passphrase) using PKCS#5 Password-Based Key Derivation Function 2 + * (PBKD2). + */ +CK_RV +pkcs11_PasswdToPBKD2Object(CK_SESSION_HANDLE hSession, char *passphrase, + size_t passphrase_len, void *salt, size_t salt_len, CK_ULONG iterations, + CK_KEY_TYPE key_type, CK_ULONG key_len, CK_FLAGS key_flags, + CK_OBJECT_HANDLE_PTR obj); + +/* + * pkcs11_ObjectToKey gets the rawkey data from a secret key object. + * The caller is responsible to free the allocated rawkey data. + */ +CK_RV +pkcs11_ObjectToKey(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE obj, + void **rawkey, size_t *rawkey_len, boolean_t destroy_obj); + +/* + * pkcs11_PasswdToKey will create PKCS#5 PBKD2 rawkey data from the + * given passphrase. The caller is responsible to free the allocated + * rawkey data. + */ +CK_RV +pkcs11_PasswdToKey(CK_SESSION_HANDLE hSession, char *passphrase, + size_t passphrase_len, void *salt, size_t salt_len, CK_KEY_TYPE key_type, + CK_ULONG key_len, void **rawkey, size_t *rawkey_len); + +#ifdef __cplusplus +} +#endif + +#endif /* _CRYPTOKI_H */ diff --git a/illumos-x86_64/usr/include/security/pam_appl.h b/illumos-x86_64/usr/include/security/pam_appl.h new file mode 100644 index 00000000..73825fe3 --- /dev/null +++ b/illumos-x86_64/usr/include/security/pam_appl.h @@ -0,0 +1,362 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2023 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _PAM_APPL_H +#define _PAM_APPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generic PAM errors */ +#define PAM_SUCCESS 0 /* Normal function return */ +#define PAM_OPEN_ERR 1 /* Dlopen failure */ +#define PAM_SYMBOL_ERR 2 /* Symbol not found */ +#define PAM_SERVICE_ERR 3 /* Error in underlying service module */ +#define PAM_SYSTEM_ERR 4 /* System error */ +#define PAM_BUF_ERR 5 /* Memory buffer error */ +#define PAM_CONV_ERR 6 /* Conversation failure */ +#define PAM_PERM_DENIED 7 /* Permission denied */ + +/* Errors returned by pam_authenticate, pam_acct_mgmt(), and pam_setcred() */ +#define PAM_MAXTRIES 8 /* Maximum number of tries exceeded */ +#define PAM_AUTH_ERR 9 /* Authentication failure */ +#define PAM_NEW_AUTHTOK_REQD 10 /* Get new auth token from the user */ +#define PAM_CRED_INSUFFICIENT 11 /* can not access auth data b/c */ + /* of insufficient credentials */ +#define PAM_AUTHINFO_UNAVAIL 12 /* Can not retrieve auth information */ +#define PAM_USER_UNKNOWN 13 /* No account present for user */ + +/* Errors returned by pam_setcred() */ +#define PAM_CRED_UNAVAIL 14 /* can not retrieve user credentials */ +#define PAM_CRED_EXPIRED 15 /* user credentials expired */ +#define PAM_CRED_ERR 16 /* failure setting user credentials */ + +/* Errors returned by pam_acct_mgmt() */ +#define PAM_ACCT_EXPIRED 17 /* user account has expired */ +#define PAM_AUTHTOK_EXPIRED 18 /* Password expired and no longer */ + /* usable */ + +/* Errors returned by pam_open/close_session() */ +#define PAM_SESSION_ERR 19 /* can not make/remove entry for */ + /* specified session */ + +/* Errors returned by pam_chauthtok() */ +#define PAM_AUTHTOK_ERR 20 /* Authentication token */ + /* manipulation error */ +#define PAM_AUTHTOK_RECOVERY_ERR 21 /* Old authentication token */ + /* cannot be recovered */ +#define PAM_AUTHTOK_LOCK_BUSY 22 /* Authentication token */ + /* lock busy */ +#define PAM_AUTHTOK_DISABLE_AGING 23 /* Authentication token aging */ + /* is disabled */ + +/* Errors returned by pam_get_data */ +#define PAM_NO_MODULE_DATA 24 /* module data not found */ + +/* Errors returned by modules */ +#define PAM_IGNORE 25 /* ignore module */ + +#define PAM_ABORT 26 /* General PAM failure */ +#define PAM_TRY_AGAIN 27 /* Unable to update password */ + /* Try again another time */ +#define PAM_TOTAL_ERRNUM 28 + +/* + * structure pam_message is used to pass prompt, error message, + * or any text information from scheme to application/user. + */ + +struct pam_message { + int msg_style; /* Msg_style - see below */ + char *msg; /* Message string */ +}; + +/* + * msg_style defines the interaction style between the + * scheme and the application. + */ +#define PAM_PROMPT_ECHO_OFF 1 /* Echo off when getting response */ +#define PAM_PROMPT_ECHO_ON 2 /* Echo on when getting response */ +#define PAM_ERROR_MSG 3 /* Error message */ +#define PAM_TEXT_INFO 4 /* Textual information */ + +/* + * max # of messages passed to the application through the + * conversation function call + */ +#define PAM_MAX_NUM_MSG 32 + +/* + * max size (in chars) of each messages passed to the application + * through the conversation function call + */ +#define PAM_MAX_MSG_SIZE 512 + +/* + * max size (in chars) of each response passed from the application + * through the conversation function call + */ +#define PAM_MAX_RESP_SIZE 512 + +/* + * structure pam_response is used by the scheme to get the user's + * response back from the application/user. + */ + +struct pam_response { + char *resp; /* Response string */ + int resp_retcode; /* Return code - for future use */ +}; + +/* + * structure pam_conv is used by authentication applications for passing + * call back function pointers and application data pointers to the scheme + */ +struct pam_conv { +#ifdef _PAM_LEGACY_NONCONST + int (*conv)(int, struct pam_message **, +#else + int (*conv)(int, const struct pam_message **, +#endif + struct pam_response **, void *); + void *appdata_ptr; /* Application data ptr */ +}; + +/* the pam handle */ +typedef struct pam_handle pam_handle_t; + +/* + * pam_start() is called to initiate an authentication exchange + * with PAM. + */ +extern int +pam_start( + const char *service_name, /* Service Name */ + const char *user, /* User Name */ + const struct pam_conv *pam_conv, /* Conversation structure */ + pam_handle_t **pamh /* Address to store handle */ +); + +/* + * pam_end() is called to end an authentication exchange with PAM. + */ +extern int +pam_end( + pam_handle_t *pamh, /* handle from pam_start() */ + int status /* the final status value that */ + /* gets passed to cleanup functions */ +); + +/* + * pam_set_item is called to store an object in PAM handle. + */ +extern int +pam_set_item( + pam_handle_t *pamh, /* PAM handle */ + int item_type, /* Type of object - see below */ + const void *item /* Address of place to put pointer */ + /* to object */ +); + +/* + * pam_get_item is called to retrieve an object from the static data area + */ +extern int +pam_get_item( + const pam_handle_t *pamh, /* PAM handle */ + int item_type, /* Type of object - see below */ +#ifdef _PAM_LEGACY_NONCONST + void **item /* Address of place to put pointer */ +#else + const void **item /* Address of place to put pointer */ +#endif + /* to object */ +); + +/* Items supported by pam_[sg]et_item() calls */ +#define PAM_SERVICE 1 /* The program/service name */ +#define PAM_USER 2 /* The user name */ +#define PAM_TTY 3 /* The tty name */ +#define PAM_RHOST 4 /* The remote host name */ +#define PAM_CONV 5 /* The conversation structure */ +#define PAM_AUTHTOK 6 /* The authentication token */ +#define PAM_OLDAUTHTOK 7 /* Old authentication token */ +#define PAM_RUSER 8 /* The remote user name */ +#define PAM_USER_PROMPT 9 /* The user prompt */ +#define PAM_REPOSITORY 10 /* The repository to be updated */ +#define PAM_RESOURCE 11 /* Resource management info */ +#define PAM_AUSER 12 /* The authenticated user name */ + +/* pam repository structure */ + +struct pam_repository { + char *type; /* Repository type, e.g., files, nis, ldap */ + void *scope; /* Optional scope information */ + size_t scope_len; /* length of scope inforamtion */ +}; + +typedef struct pam_repository pam_repository_t; + +/* + * pam_get_user is called to retrieve the user name (PAM_USER). If PAM_USER + * is not set then this call will prompt for the user name using the + * conversation function. This function should only be used by modules, not + * applications. + */ + +extern int +pam_get_user( + pam_handle_t *pamh, /* PAM handle */ +#ifdef _PAM_LEGACY_NONCONST + char **user, /* User Name */ +#else + const char **user, /* User Name */ +#endif + const char *prompt /* Prompt */ +); + +/* + * PAM equivalent to strerror(); + */ +extern const char * +pam_strerror( + pam_handle_t *pamh, /* pam handle */ + int errnum /* error number */ +); + +/* general flag for pam_* functions */ +#define PAM_SILENT 0x80000000 + +/* + * pam_authenticate is called to authenticate the current user. + */ +extern int +pam_authenticate( + pam_handle_t *pamh, + int flags +); + +/* + * Flags for pam_authenticate + */ + +#define PAM_DISALLOW_NULL_AUTHTOK 0x1 /* The password must be non-null */ + +/* + * pam_acct_mgmt is called to perform account management processing + */ +extern int +pam_acct_mgmt( + pam_handle_t *pamh, + int flags +); + +/* + * pam_open_session is called to note the initiation of new session in the + * appropriate administrative data bases. + */ +extern int +pam_open_session( + pam_handle_t *pamh, + int flags +); + +/* + * pam_close_session records the termination of a session. + */ +extern int +pam_close_session( + pam_handle_t *pamh, + int flags +); + +/* pam_setcred is called to set the credentials of the current user */ +extern int +pam_setcred( + pam_handle_t *pamh, + int flags +); + +/* flags for pam_setcred() */ +#define PAM_ESTABLISH_CRED 0x1 /* set scheme specific user id */ +#define PAM_DELETE_CRED 0x2 /* unset scheme specific user id */ +#define PAM_REINITIALIZE_CRED 0x4 /* reinitialize user credentials */ + /* (after a password has changed */ +#define PAM_REFRESH_CRED 0x8 /* extend lifetime of credentials */ + +/* pam_chauthtok is called to change authentication token */ + +extern int +pam_chauthtok( + pam_handle_t *pamh, + int flags +); + +/* + * Be careful - there are flags defined for pam_sm_chauthtok() in + * pam_modules.h also: + * PAM_PRELIM_CHECK 0x1 + * PAM_UPDATE_AUTHTOK 0x2 + */ +#define PAM_CHANGE_EXPIRED_AUTHTOK 0x4 /* update expired passwords only */ +#define PAM_NO_AUTHTOK_CHECK 0x8 /* bypass password strength tests */ + +/* pam_putenv is called to add environment variables to the PAM handle */ + +extern int +pam_putenv( + pam_handle_t *pamh, + const char *name_value +); + +/* pam_getenv is called to retrieve an env variable from the PAM handle */ + +#ifdef _PAM_LEGACY_NONCONST +extern char * +#else +extern const char * +#endif +pam_getenv( + pam_handle_t *pamh, + const char *name +); + +/* pam_getenvlist is called to retrieve all env variables from the PAM handle */ + +extern char ** +pam_getenvlist( + pam_handle_t *pamh +); + +#ifdef __cplusplus +} +#endif + +#endif /* _PAM_APPL_H */ diff --git a/illumos-x86_64/usr/include/security/pam_modules.h b/illumos-x86_64/usr/include/security/pam_modules.h new file mode 100644 index 00000000..e31bd4b8 --- /dev/null +++ b/illumos-x86_64/usr/include/security/pam_modules.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992-1995, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _PAM_MODULES_H +#define _PAM_MODULES_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern int +pam_sm_authenticate( + pam_handle_t *pamh, + int flags, + int argc, + const char **argv); + +extern int +pam_sm_setcred( + pam_handle_t *pamh, + int flags, + int argc, + const char **argv); + +extern int +pam_sm_acct_mgmt( + pam_handle_t *pamh, + int flags, + int argc, + const char **argv); + +extern int +pam_sm_open_session( + pam_handle_t *pamh, + int flags, + int argc, + const char **argv); + +extern int +pam_sm_close_session( + pam_handle_t *pamh, + int flags, + int argc, + const char **argv); + +/* + * Be careful - there are flags defined for pam_chauthtok() in + * pam_appl.h also. + */ +#define PAM_PRELIM_CHECK 0x1 +#define PAM_UPDATE_AUTHTOK 0x2 + +extern int +pam_sm_chauthtok( + pam_handle_t *pamh, + int flags, + int argc, + const char **argv); + +/* + * pam_set_data is used to create module specific data, and + * to optionally add a cleanup handler that gets called by pam_end. + * + */ +extern int +pam_set_data( + pam_handle_t *pamh, /* PAM handle */ + const char *module_data_name, /* unique module data name */ + void *data, /* the module specific data */ + void (*cleanup)(pam_handle_t *pamh, void *data, int pam_end_status) +); + +/* + * get module specific data set by pam_set_scheme_data. + * returns PAM_NO_MODULE_DATA if specified module data was not found. + */ +extern int +pam_get_data( + const pam_handle_t *pamh, + const char *module_data_name, + const void **data +); + +#ifdef __cplusplus +} +#endif + +#endif /* _PAM_MODULES_H */ diff --git a/illumos-x86_64/usr/include/security/pkcs11.h b/illumos-x86_64/usr/include/security/pkcs11.h new file mode 100644 index 00000000..53bbbd61 --- /dev/null +++ b/illumos-x86_64/usr/include/security/pkcs11.h @@ -0,0 +1,264 @@ +/* Copyright (c) OASIS Open 2016. All Rights Reserved./ + * /Distributed under the terms of the OASIS IPR Policy, + * [http://www.oasis-open.org/policies-guidelines/ipr], AS-IS, WITHOUT ANY + * IMPLIED OR EXPRESS WARRANTY; there is no warranty of MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE or NONINFRINGEMENT of the rights of others. + */ + +/* Latest version of the specification: + * http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/pkcs11-base-v2.40.html + */ + +#ifndef _PKCS11_H_ +#define _PKCS11_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Before including this file (pkcs11.h) (or pkcs11t.h by + * itself), 5 platform-specific macros must be defined. These + * macros are described below, and typical definitions for them + * are also given. Be advised that these definitions can depend + * on both the platform and the compiler used (and possibly also + * on whether a Cryptoki library is linked statically or + * dynamically). + * + * In addition to defining these 5 macros, the packing convention + * for Cryptoki structures should be set. The Cryptoki + * convention on packing is that structures should be 1-byte + * aligned. + * + * If you're using Microsoft Developer Studio 5.0 to produce + * Win32 stuff, this might be done by using the following + * preprocessor directive before including pkcs11.h or pkcs11t.h: + * + * #pragma pack(push, cryptoki, 1) + * + * and using the following preprocessor directive after including + * pkcs11.h or pkcs11t.h: + * + * #pragma pack(pop, cryptoki) + * + * If you're using an earlier version of Microsoft Developer + * Studio to produce Win16 stuff, this might be done by using + * the following preprocessor directive before including + * pkcs11.h or pkcs11t.h: + * + * #pragma pack(1) + * + * In a UNIX environment, you're on your own for this. You might + * not need to do (or be able to do!) anything. + * + * + * Now for the macros: + * + * + * 1. CK_PTR: The indirection string for making a pointer to an + * object. It can be used like this: + * + * typedef CK_BYTE CK_PTR CK_BYTE_PTR; + * + * If you're using Microsoft Developer Studio 5.0 to produce + * Win32 stuff, it might be defined by: + * + * #define CK_PTR * + * + * If you're using an earlier version of Microsoft Developer + * Studio to produce Win16 stuff, it might be defined by: + * + * #define CK_PTR far * + * + * In a typical UNIX environment, it might be defined by: + * + * #define CK_PTR * + * + * + * 2. CK_DECLARE_FUNCTION(returnType, name): A macro which makes + * an importable Cryptoki library function declaration out of a + * return type and a function name. It should be used in the + * following fashion: + * + * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)( + * CK_VOID_PTR pReserved + * ); + * + * If you're using Microsoft Developer Studio 5.0 to declare a + * function in a Win32 Cryptoki .dll, it might be defined by: + * + * #define CK_DECLARE_FUNCTION(returnType, name) \ + * returnType __declspec(dllimport) name + * + * If you're using an earlier version of Microsoft Developer + * Studio to declare a function in a Win16 Cryptoki .dll, it + * might be defined by: + * + * #define CK_DECLARE_FUNCTION(returnType, name) \ + * returnType __export _far _pascal name + * + * In a UNIX environment, it might be defined by: + * + * #define CK_DECLARE_FUNCTION(returnType, name) \ + * returnType name + * + * + * 3. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro + * which makes a Cryptoki API function pointer declaration or + * function pointer type declaration out of a return type and a + * function name. It should be used in the following fashion: + * + * // Define funcPtr to be a pointer to a Cryptoki API function + * // taking arguments args and returning CK_RV. + * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args); + * + * or + * + * // Define funcPtrType to be the type of a pointer to a + * // Cryptoki API function taking arguments args and returning + * // CK_RV, and then define funcPtr to be a variable of type + * // funcPtrType. + * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args); + * funcPtrType funcPtr; + * + * If you're using Microsoft Developer Studio 5.0 to access + * functions in a Win32 Cryptoki .dll, in might be defined by: + * + * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ + * returnType __declspec(dllimport) (* name) + * + * If you're using an earlier version of Microsoft Developer + * Studio to access functions in a Win16 Cryptoki .dll, it might + * be defined by: + * + * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ + * returnType __export _far _pascal (* name) + * + * In a UNIX environment, it might be defined by: + * + * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ + * returnType (* name) + * + * + * 4. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes + * a function pointer type for an application callback out of + * a return type for the callback and a name for the callback. + * It should be used in the following fashion: + * + * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args); + * + * to declare a function pointer, myCallback, to a callback + * which takes arguments args and returns a CK_RV. It can also + * be used like this: + * + * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args); + * myCallbackType myCallback; + * + * If you're using Microsoft Developer Studio 5.0 to do Win32 + * Cryptoki development, it might be defined by: + * + * #define CK_CALLBACK_FUNCTION(returnType, name) \ + * returnType (* name) + * + * If you're using an earlier version of Microsoft Developer + * Studio to do Win16 development, it might be defined by: + * + * #define CK_CALLBACK_FUNCTION(returnType, name) \ + * returnType _far _pascal (* name) + * + * In a UNIX environment, it might be defined by: + * + * #define CK_CALLBACK_FUNCTION(returnType, name) \ + * returnType (* name) + * + * + * 5. NULL_PTR: This macro is the value of a NULL pointer. + * + * In any ANSI/ISO C environment (and in many others as well), + * this should best be defined by + * + * #ifndef NULL_PTR + * #define NULL_PTR 0 + * #endif + */ + + +/* All the various Cryptoki types and #define'd values are in the + * file pkcs11t.h. + */ +#include "pkcs11t.h" + +#define __PASTE(x,y) x##y + + +/* ============================================================== + * Define the "extern" form of all the entry points. + * ============================================================== + */ + +#define CK_NEED_ARG_LIST 1 +#define CK_PKCS11_FUNCTION_INFO(name) \ + extern CK_DECLARE_FUNCTION(CK_RV, name) + +/* pkcs11f.h has all the information about the Cryptoki + * function prototypes. + */ +#include "pkcs11f.h" + +#undef CK_NEED_ARG_LIST +#undef CK_PKCS11_FUNCTION_INFO + + +/* ============================================================== + * Define the typedef form of all the entry points. That is, for + * each Cryptoki function C_XXX, define a type CK_C_XXX which is + * a pointer to that kind of function. + * ============================================================== + */ + +#define CK_NEED_ARG_LIST 1 +#define CK_PKCS11_FUNCTION_INFO(name) \ + typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name)) + +/* pkcs11f.h has all the information about the Cryptoki + * function prototypes. + */ +#include "pkcs11f.h" + +#undef CK_NEED_ARG_LIST +#undef CK_PKCS11_FUNCTION_INFO + + +/* ============================================================== + * Define structed vector of entry points. A CK_FUNCTION_LIST + * contains a CK_VERSION indicating a library's Cryptoki version + * and then a whole slew of function pointers to the routines in + * the library. This type was declared, but not defined, in + * pkcs11t.h. + * ============================================================== + */ + +#define CK_PKCS11_FUNCTION_INFO(name) \ + __PASTE(CK_,name) name; + +struct CK_FUNCTION_LIST { + + CK_VERSION version; /* Cryptoki version */ + +/* Pile all the function pointers into the CK_FUNCTION_LIST. */ +/* pkcs11f.h has all the information about the Cryptoki + * function prototypes. + */ +#include "pkcs11f.h" + +}; + +#undef CK_PKCS11_FUNCTION_INFO + + +#undef __PASTE + +#ifdef __cplusplus +} +#endif + +#endif /* _PKCS11_H_ */ diff --git a/illumos-x86_64/usr/include/security/pkcs11f.h b/illumos-x86_64/usr/include/security/pkcs11f.h new file mode 100644 index 00000000..538ba9eb --- /dev/null +++ b/illumos-x86_64/usr/include/security/pkcs11f.h @@ -0,0 +1,938 @@ +/* Copyright (c) OASIS Open 2016. All Rights Reserved./ + * /Distributed under the terms of the OASIS IPR Policy, + * [http://www.oasis-open.org/policies-guidelines/ipr], AS-IS, WITHOUT ANY + * IMPLIED OR EXPRESS WARRANTY; there is no warranty of MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE or NONINFRINGEMENT of the rights of others. + */ + +/* Latest version of the specification: + * http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/pkcs11-base-v2.40.html + */ + +/* This header file contains pretty much everything about all the + * Cryptoki function prototypes. Because this information is + * used for more than just declaring function prototypes, the + * order of the functions appearing herein is important, and + * should not be altered. + */ + +/* General-purpose */ + +/* C_Initialize initializes the Cryptoki library. */ +CK_PKCS11_FUNCTION_INFO(C_Initialize) +#ifdef CK_NEED_ARG_LIST +( + CK_VOID_PTR pInitArgs /* if this is not NULL_PTR, it gets + * cast to CK_C_INITIALIZE_ARGS_PTR + * and dereferenced + */ +); +#endif + + +/* C_Finalize indicates that an application is done with the + * Cryptoki library. + */ +CK_PKCS11_FUNCTION_INFO(C_Finalize) +#ifdef CK_NEED_ARG_LIST +( + CK_VOID_PTR pReserved /* reserved. Should be NULL_PTR */ +); +#endif + + +/* C_GetInfo returns general information about Cryptoki. */ +CK_PKCS11_FUNCTION_INFO(C_GetInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_INFO_PTR pInfo /* location that receives information */ +); +#endif + + +/* C_GetFunctionList returns the function list. */ +CK_PKCS11_FUNCTION_INFO(C_GetFunctionList) +#ifdef CK_NEED_ARG_LIST +( + CK_FUNCTION_LIST_PTR_PTR ppFunctionList /* receives pointer to + * function list + */ +); +#endif + + + +/* Slot and token management */ + +/* C_GetSlotList obtains a list of slots in the system. */ +CK_PKCS11_FUNCTION_INFO(C_GetSlotList) +#ifdef CK_NEED_ARG_LIST +( + CK_BBOOL tokenPresent, /* only slots with tokens */ + CK_SLOT_ID_PTR pSlotList, /* receives array of slot IDs */ + CK_ULONG_PTR pulCount /* receives number of slots */ +); +#endif + + +/* C_GetSlotInfo obtains information about a particular slot in + * the system. + */ +CK_PKCS11_FUNCTION_INFO(C_GetSlotInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* the ID of the slot */ + CK_SLOT_INFO_PTR pInfo /* receives the slot information */ +); +#endif + + +/* C_GetTokenInfo obtains information about a particular token + * in the system. + */ +CK_PKCS11_FUNCTION_INFO(C_GetTokenInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* ID of the token's slot */ + CK_TOKEN_INFO_PTR pInfo /* receives the token information */ +); +#endif + + +/* C_GetMechanismList obtains a list of mechanism types + * supported by a token. + */ +CK_PKCS11_FUNCTION_INFO(C_GetMechanismList) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* ID of token's slot */ + CK_MECHANISM_TYPE_PTR pMechanismList, /* gets mech. array */ + CK_ULONG_PTR pulCount /* gets # of mechs. */ +); +#endif + + +/* C_GetMechanismInfo obtains information about a particular + * mechanism possibly supported by a token. + */ +CK_PKCS11_FUNCTION_INFO(C_GetMechanismInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* ID of the token's slot */ + CK_MECHANISM_TYPE type, /* type of mechanism */ + CK_MECHANISM_INFO_PTR pInfo /* receives mechanism info */ +); +#endif + + +/* C_InitToken initializes a token. */ +CK_PKCS11_FUNCTION_INFO(C_InitToken) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* ID of the token's slot */ + CK_UTF8CHAR_PTR pPin, /* the SO's initial PIN */ + CK_ULONG ulPinLen, /* length in bytes of the PIN */ + CK_UTF8CHAR_PTR pLabel /* 32-byte token label (blank padded) */ +); +#endif + + +/* C_InitPIN initializes the normal user's PIN. */ +CK_PKCS11_FUNCTION_INFO(C_InitPIN) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_UTF8CHAR_PTR pPin, /* the normal user's PIN */ + CK_ULONG ulPinLen /* length in bytes of the PIN */ +); +#endif + + +/* C_SetPIN modifies the PIN of the user who is logged in. */ +CK_PKCS11_FUNCTION_INFO(C_SetPIN) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_UTF8CHAR_PTR pOldPin, /* the old PIN */ + CK_ULONG ulOldLen, /* length of the old PIN */ + CK_UTF8CHAR_PTR pNewPin, /* the new PIN */ + CK_ULONG ulNewLen /* length of the new PIN */ +); +#endif + + + +/* Session management */ + +/* C_OpenSession opens a session between an application and a + * token. + */ +CK_PKCS11_FUNCTION_INFO(C_OpenSession) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID, /* the slot's ID */ + CK_FLAGS flags, /* from CK_SESSION_INFO */ + CK_VOID_PTR pApplication, /* passed to callback */ + CK_NOTIFY Notify, /* callback function */ + CK_SESSION_HANDLE_PTR phSession /* gets session handle */ +); +#endif + + +/* C_CloseSession closes a session between an application and a + * token. + */ +CK_PKCS11_FUNCTION_INFO(C_CloseSession) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + + +/* C_CloseAllSessions closes all sessions with a token. */ +CK_PKCS11_FUNCTION_INFO(C_CloseAllSessions) +#ifdef CK_NEED_ARG_LIST +( + CK_SLOT_ID slotID /* the token's slot */ +); +#endif + + +/* C_GetSessionInfo obtains information about the session. */ +CK_PKCS11_FUNCTION_INFO(C_GetSessionInfo) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_SESSION_INFO_PTR pInfo /* receives session info */ +); +#endif + + +/* C_GetOperationState obtains the state of the cryptographic operation + * in a session. + */ +CK_PKCS11_FUNCTION_INFO(C_GetOperationState) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pOperationState, /* gets state */ + CK_ULONG_PTR pulOperationStateLen /* gets state length */ +); +#endif + + +/* C_SetOperationState restores the state of the cryptographic + * operation in a session. + */ +CK_PKCS11_FUNCTION_INFO(C_SetOperationState) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pOperationState, /* holds state */ + CK_ULONG ulOperationStateLen, /* holds state length */ + CK_OBJECT_HANDLE hEncryptionKey, /* en/decryption key */ + CK_OBJECT_HANDLE hAuthenticationKey /* sign/verify key */ +); +#endif + + +/* C_Login logs a user into a token. */ +CK_PKCS11_FUNCTION_INFO(C_Login) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_USER_TYPE userType, /* the user type */ + CK_UTF8CHAR_PTR pPin, /* the user's PIN */ + CK_ULONG ulPinLen /* the length of the PIN */ +); +#endif + + +/* C_Logout logs a user out from a token. */ +CK_PKCS11_FUNCTION_INFO(C_Logout) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + + + +/* Object management */ + +/* C_CreateObject creates a new object. */ +CK_PKCS11_FUNCTION_INFO(C_CreateObject) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* the object's template */ + CK_ULONG ulCount, /* attributes in template */ + CK_OBJECT_HANDLE_PTR phObject /* gets new object's handle. */ +); +#endif + + +/* C_CopyObject copies an object, creating a new object for the + * copy. + */ +CK_PKCS11_FUNCTION_INFO(C_CopyObject) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject, /* the object's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* template for new object */ + CK_ULONG ulCount, /* attributes in template */ + CK_OBJECT_HANDLE_PTR phNewObject /* receives handle of copy */ +); +#endif + + +/* C_DestroyObject destroys an object. */ +CK_PKCS11_FUNCTION_INFO(C_DestroyObject) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject /* the object's handle */ +); +#endif + + +/* C_GetObjectSize gets the size of an object in bytes. */ +CK_PKCS11_FUNCTION_INFO(C_GetObjectSize) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject, /* the object's handle */ + CK_ULONG_PTR pulSize /* receives size of object */ +); +#endif + + +/* C_GetAttributeValue obtains the value of one or more object + * attributes. + */ +CK_PKCS11_FUNCTION_INFO(C_GetAttributeValue) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject, /* the object's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs; gets vals */ + CK_ULONG ulCount /* attributes in template */ +); +#endif + + +/* C_SetAttributeValue modifies the value of one or more object + * attributes. + */ +CK_PKCS11_FUNCTION_INFO(C_SetAttributeValue) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hObject, /* the object's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs and values */ + CK_ULONG ulCount /* attributes in template */ +); +#endif + + +/* C_FindObjectsInit initializes a search for token and session + * objects that match a template. + */ +CK_PKCS11_FUNCTION_INFO(C_FindObjectsInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_ATTRIBUTE_PTR pTemplate, /* attribute values to match */ + CK_ULONG ulCount /* attrs in search template */ +); +#endif + + +/* C_FindObjects continues a search for token and session + * objects that match a template, obtaining additional object + * handles. + */ +CK_PKCS11_FUNCTION_INFO(C_FindObjects) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_OBJECT_HANDLE_PTR phObject, /* gets obj. handles */ + CK_ULONG ulMaxObjectCount, /* max handles to get */ + CK_ULONG_PTR pulObjectCount /* actual # returned */ +); +#endif + + +/* C_FindObjectsFinal finishes a search for token and session + * objects. + */ +CK_PKCS11_FUNCTION_INFO(C_FindObjectsFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + + + +/* Encryption and decryption */ + +/* C_EncryptInit initializes an encryption operation. */ +CK_PKCS11_FUNCTION_INFO(C_EncryptInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the encryption mechanism */ + CK_OBJECT_HANDLE hKey /* handle of encryption key */ +); +#endif + + +/* C_Encrypt encrypts single-part data. */ +CK_PKCS11_FUNCTION_INFO(C_Encrypt) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pData, /* the plaintext data */ + CK_ULONG ulDataLen, /* bytes of plaintext */ + CK_BYTE_PTR pEncryptedData, /* gets ciphertext */ + CK_ULONG_PTR pulEncryptedDataLen /* gets c-text size */ +); +#endif + + +/* C_EncryptUpdate continues a multiple-part encryption + * operation. + */ +CK_PKCS11_FUNCTION_INFO(C_EncryptUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pPart, /* the plaintext data */ + CK_ULONG ulPartLen, /* plaintext data len */ + CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ + CK_ULONG_PTR pulEncryptedPartLen /* gets c-text size */ +); +#endif + + +/* C_EncryptFinal finishes a multiple-part encryption + * operation. + */ +CK_PKCS11_FUNCTION_INFO(C_EncryptFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session handle */ + CK_BYTE_PTR pLastEncryptedPart, /* last c-text */ + CK_ULONG_PTR pulLastEncryptedPartLen /* gets last size */ +); +#endif + + +/* C_DecryptInit initializes a decryption operation. */ +CK_PKCS11_FUNCTION_INFO(C_DecryptInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the decryption mechanism */ + CK_OBJECT_HANDLE hKey /* handle of decryption key */ +); +#endif + + +/* C_Decrypt decrypts encrypted data in a single part. */ +CK_PKCS11_FUNCTION_INFO(C_Decrypt) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pEncryptedData, /* ciphertext */ + CK_ULONG ulEncryptedDataLen, /* ciphertext length */ + CK_BYTE_PTR pData, /* gets plaintext */ + CK_ULONG_PTR pulDataLen /* gets p-text size */ +); +#endif + + +/* C_DecryptUpdate continues a multiple-part decryption + * operation. + */ +CK_PKCS11_FUNCTION_INFO(C_DecryptUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pEncryptedPart, /* encrypted data */ + CK_ULONG ulEncryptedPartLen, /* input length */ + CK_BYTE_PTR pPart, /* gets plaintext */ + CK_ULONG_PTR pulPartLen /* p-text size */ +); +#endif + + +/* C_DecryptFinal finishes a multiple-part decryption + * operation. + */ +CK_PKCS11_FUNCTION_INFO(C_DecryptFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pLastPart, /* gets plaintext */ + CK_ULONG_PTR pulLastPartLen /* p-text size */ +); +#endif + + + +/* Message digesting */ + +/* C_DigestInit initializes a message-digesting operation. */ +CK_PKCS11_FUNCTION_INFO(C_DigestInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism /* the digesting mechanism */ +); +#endif + + +/* C_Digest digests data in a single part. */ +CK_PKCS11_FUNCTION_INFO(C_Digest) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pData, /* data to be digested */ + CK_ULONG ulDataLen, /* bytes of data to digest */ + CK_BYTE_PTR pDigest, /* gets the message digest */ + CK_ULONG_PTR pulDigestLen /* gets digest length */ +); +#endif + + +/* C_DigestUpdate continues a multiple-part message-digesting + * operation. + */ +CK_PKCS11_FUNCTION_INFO(C_DigestUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pPart, /* data to be digested */ + CK_ULONG ulPartLen /* bytes of data to be digested */ +); +#endif + + +/* C_DigestKey continues a multi-part message-digesting + * operation, by digesting the value of a secret key as part of + * the data already digested. + */ +CK_PKCS11_FUNCTION_INFO(C_DigestKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_OBJECT_HANDLE hKey /* secret key to digest */ +); +#endif + + +/* C_DigestFinal finishes a multiple-part message-digesting + * operation. + */ +CK_PKCS11_FUNCTION_INFO(C_DigestFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pDigest, /* gets the message digest */ + CK_ULONG_PTR pulDigestLen /* gets byte count of digest */ +); +#endif + + + +/* Signing and MACing */ + +/* C_SignInit initializes a signature (private key encryption) + * operation, where the signature is (will be) an appendix to + * the data, and plaintext cannot be recovered from the + * signature. + */ +CK_PKCS11_FUNCTION_INFO(C_SignInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the signature mechanism */ + CK_OBJECT_HANDLE hKey /* handle of signature key */ +); +#endif + + +/* C_Sign signs (encrypts with private key) data in a single + * part, where the signature is (will be) an appendix to the + * data, and plaintext cannot be recovered from the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_Sign) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pData, /* the data to sign */ + CK_ULONG ulDataLen, /* count of bytes to sign */ + CK_BYTE_PTR pSignature, /* gets the signature */ + CK_ULONG_PTR pulSignatureLen /* gets signature length */ +); +#endif + + +/* C_SignUpdate continues a multiple-part signature operation, + * where the signature is (will be) an appendix to the data, + * and plaintext cannot be recovered from the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_SignUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pPart, /* the data to sign */ + CK_ULONG ulPartLen /* count of bytes to sign */ +); +#endif + + +/* C_SignFinal finishes a multiple-part signature operation, + * returning the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_SignFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pSignature, /* gets the signature */ + CK_ULONG_PTR pulSignatureLen /* gets signature length */ +); +#endif + + +/* C_SignRecoverInit initializes a signature operation, where + * the data can be recovered from the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_SignRecoverInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the signature mechanism */ + CK_OBJECT_HANDLE hKey /* handle of the signature key */ +); +#endif + + +/* C_SignRecover signs data in a single operation, where the + * data can be recovered from the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_SignRecover) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pData, /* the data to sign */ + CK_ULONG ulDataLen, /* count of bytes to sign */ + CK_BYTE_PTR pSignature, /* gets the signature */ + CK_ULONG_PTR pulSignatureLen /* gets signature length */ +); +#endif + + + +/* Verifying signatures and MACs */ + +/* C_VerifyInit initializes a verification operation, where the + * signature is an appendix to the data, and plaintext cannot + * cannot be recovered from the signature (e.g. DSA). + */ +CK_PKCS11_FUNCTION_INFO(C_VerifyInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the verification mechanism */ + CK_OBJECT_HANDLE hKey /* verification key */ +); +#endif + + +/* C_Verify verifies a signature in a single-part operation, + * where the signature is an appendix to the data, and plaintext + * cannot be recovered from the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_Verify) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pData, /* signed data */ + CK_ULONG ulDataLen, /* length of signed data */ + CK_BYTE_PTR pSignature, /* signature */ + CK_ULONG ulSignatureLen /* signature length*/ +); +#endif + + +/* C_VerifyUpdate continues a multiple-part verification + * operation, where the signature is an appendix to the data, + * and plaintext cannot be recovered from the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_VerifyUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pPart, /* signed data */ + CK_ULONG ulPartLen /* length of signed data */ +); +#endif + + +/* C_VerifyFinal finishes a multiple-part verification + * operation, checking the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_VerifyFinal) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pSignature, /* signature to verify */ + CK_ULONG ulSignatureLen /* signature length */ +); +#endif + + +/* C_VerifyRecoverInit initializes a signature verification + * operation, where the data is recovered from the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_VerifyRecoverInit) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the verification mechanism */ + CK_OBJECT_HANDLE hKey /* verification key */ +); +#endif + + +/* C_VerifyRecover verifies a signature in a single-part + * operation, where the data is recovered from the signature. + */ +CK_PKCS11_FUNCTION_INFO(C_VerifyRecover) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pSignature, /* signature to verify */ + CK_ULONG ulSignatureLen, /* signature length */ + CK_BYTE_PTR pData, /* gets signed data */ + CK_ULONG_PTR pulDataLen /* gets signed data len */ +); +#endif + + + +/* Dual-function cryptographic operations */ + +/* C_DigestEncryptUpdate continues a multiple-part digesting + * and encryption operation. + */ +CK_PKCS11_FUNCTION_INFO(C_DigestEncryptUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pPart, /* the plaintext data */ + CK_ULONG ulPartLen, /* plaintext length */ + CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ + CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */ +); +#endif + + +/* C_DecryptDigestUpdate continues a multiple-part decryption and + * digesting operation. + */ +CK_PKCS11_FUNCTION_INFO(C_DecryptDigestUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pEncryptedPart, /* ciphertext */ + CK_ULONG ulEncryptedPartLen, /* ciphertext length */ + CK_BYTE_PTR pPart, /* gets plaintext */ + CK_ULONG_PTR pulPartLen /* gets plaintext len */ +); +#endif + + +/* C_SignEncryptUpdate continues a multiple-part signing and + * encryption operation. + */ +CK_PKCS11_FUNCTION_INFO(C_SignEncryptUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pPart, /* the plaintext data */ + CK_ULONG ulPartLen, /* plaintext length */ + CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ + CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */ +); +#endif + + +/* C_DecryptVerifyUpdate continues a multiple-part decryption and + * verify operation. + */ +CK_PKCS11_FUNCTION_INFO(C_DecryptVerifyUpdate) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_BYTE_PTR pEncryptedPart, /* ciphertext */ + CK_ULONG ulEncryptedPartLen, /* ciphertext length */ + CK_BYTE_PTR pPart, /* gets plaintext */ + CK_ULONG_PTR pulPartLen /* gets p-text length */ +); +#endif + + + +/* Key management */ + +/* C_GenerateKey generates a secret key, creating a new key + * object. + */ +CK_PKCS11_FUNCTION_INFO(C_GenerateKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* key generation mech. */ + CK_ATTRIBUTE_PTR pTemplate, /* template for new key */ + CK_ULONG ulCount, /* # of attrs in template */ + CK_OBJECT_HANDLE_PTR phKey /* gets handle of new key */ +); +#endif + + +/* C_GenerateKeyPair generates a public-key/private-key pair, + * creating new key objects. + */ +CK_PKCS11_FUNCTION_INFO(C_GenerateKeyPair) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session handle */ + CK_MECHANISM_PTR pMechanism, /* key-gen mech. */ + CK_ATTRIBUTE_PTR pPublicKeyTemplate, /* template for pub. key */ + CK_ULONG ulPublicKeyAttributeCount, /* # pub. attrs. */ + CK_ATTRIBUTE_PTR pPrivateKeyTemplate, /* template for priv. key */ + CK_ULONG ulPrivateKeyAttributeCount, /* # priv. attrs. */ + CK_OBJECT_HANDLE_PTR phPublicKey, /* gets pub. key handle */ + CK_OBJECT_HANDLE_PTR phPrivateKey /* gets priv. key handle */ +); +#endif + + +/* C_WrapKey wraps (i.e., encrypts) a key. */ +CK_PKCS11_FUNCTION_INFO(C_WrapKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_MECHANISM_PTR pMechanism, /* the wrapping mechanism */ + CK_OBJECT_HANDLE hWrappingKey, /* wrapping key */ + CK_OBJECT_HANDLE hKey, /* key to be wrapped */ + CK_BYTE_PTR pWrappedKey, /* gets wrapped key */ + CK_ULONG_PTR pulWrappedKeyLen /* gets wrapped key size */ +); +#endif + + +/* C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new + * key object. + */ +CK_PKCS11_FUNCTION_INFO(C_UnwrapKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_MECHANISM_PTR pMechanism, /* unwrapping mech. */ + CK_OBJECT_HANDLE hUnwrappingKey, /* unwrapping key */ + CK_BYTE_PTR pWrappedKey, /* the wrapped key */ + CK_ULONG ulWrappedKeyLen, /* wrapped key len */ + CK_ATTRIBUTE_PTR pTemplate, /* new key template */ + CK_ULONG ulAttributeCount, /* template length */ + CK_OBJECT_HANDLE_PTR phKey /* gets new handle */ +); +#endif + + +/* C_DeriveKey derives a key from a base key, creating a new key + * object. + */ +CK_PKCS11_FUNCTION_INFO(C_DeriveKey) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* session's handle */ + CK_MECHANISM_PTR pMechanism, /* key deriv. mech. */ + CK_OBJECT_HANDLE hBaseKey, /* base key */ + CK_ATTRIBUTE_PTR pTemplate, /* new key template */ + CK_ULONG ulAttributeCount, /* template length */ + CK_OBJECT_HANDLE_PTR phKey /* gets new handle */ +); +#endif + + + +/* Random number generation */ + +/* C_SeedRandom mixes additional seed material into the token's + * random number generator. + */ +CK_PKCS11_FUNCTION_INFO(C_SeedRandom) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR pSeed, /* the seed material */ + CK_ULONG ulSeedLen /* length of seed material */ +); +#endif + + +/* C_GenerateRandom generates random data. */ +CK_PKCS11_FUNCTION_INFO(C_GenerateRandom) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_BYTE_PTR RandomData, /* receives the random data */ + CK_ULONG ulRandomLen /* # of bytes to generate */ +); +#endif + + + +/* Parallel function management */ + +/* C_GetFunctionStatus is a legacy function; it obtains an + * updated status of a function running in parallel with an + * application. + */ +CK_PKCS11_FUNCTION_INFO(C_GetFunctionStatus) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + + +/* C_CancelFunction is a legacy function; it cancels a function + * running in parallel. + */ +CK_PKCS11_FUNCTION_INFO(C_CancelFunction) +#ifdef CK_NEED_ARG_LIST +( + CK_SESSION_HANDLE hSession /* the session's handle */ +); +#endif + + +/* C_WaitForSlotEvent waits for a slot event (token insertion, + * removal, etc.) to occur. + */ +CK_PKCS11_FUNCTION_INFO(C_WaitForSlotEvent) +#ifdef CK_NEED_ARG_LIST +( + CK_FLAGS flags, /* blocking/nonblocking flag */ + CK_SLOT_ID_PTR pSlot, /* location that receives the slot ID */ + CK_VOID_PTR pRserved /* reserved. Should be NULL_PTR */ +); +#endif diff --git a/illumos-x86_64/usr/include/security/pkcs11t.h b/illumos-x86_64/usr/include/security/pkcs11t.h new file mode 100644 index 00000000..85387799 --- /dev/null +++ b/illumos-x86_64/usr/include/security/pkcs11t.h @@ -0,0 +1,2009 @@ +/* Copyright (c) OASIS Open 2016. All Rights Reserved./ + * /Distributed under the terms of the OASIS IPR Policy, + * [http://www.oasis-open.org/policies-guidelines/ipr], AS-IS, WITHOUT ANY + * IMPLIED OR EXPRESS WARRANTY; there is no warranty of MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE or NONINFRINGEMENT of the rights of others. + */ + +/* Latest version of the specification: + * http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/pkcs11-base-v2.40.html + */ + +/* See top of pkcs11.h for information about the macros that + * must be defined and the structure-packing conventions that + * must be set before including this file. + */ + +#ifndef _PKCS11T_H_ +#define _PKCS11T_H_ 1 + +#define CRYPTOKI_VERSION_MAJOR 2 +#define CRYPTOKI_VERSION_MINOR 40 +#define CRYPTOKI_VERSION_AMENDMENT 0 + +#define CK_TRUE 1 +#define CK_FALSE 0 + +#ifndef CK_DISABLE_TRUE_FALSE +#ifndef FALSE +#define FALSE CK_FALSE +#endif +#ifndef TRUE +#define TRUE CK_TRUE +#endif +#endif + +/* an unsigned 8-bit value */ +typedef unsigned char CK_BYTE; + +/* an unsigned 8-bit character */ +typedef CK_BYTE CK_CHAR; + +/* an 8-bit UTF-8 character */ +typedef CK_BYTE CK_UTF8CHAR; + +/* a BYTE-sized Boolean flag */ +typedef CK_BYTE CK_BBOOL; + +/* an unsigned value, at least 32 bits long */ +typedef unsigned long int CK_ULONG; + +/* a signed value, the same size as a CK_ULONG */ +typedef long int CK_LONG; + +/* at least 32 bits; each bit is a Boolean flag */ +typedef CK_ULONG CK_FLAGS; + + +/* some special values for certain CK_ULONG variables */ +#define CK_UNAVAILABLE_INFORMATION (~0UL) +#define CK_EFFECTIVELY_INFINITE 0UL + + +typedef CK_BYTE CK_PTR CK_BYTE_PTR; +typedef CK_CHAR CK_PTR CK_CHAR_PTR; +typedef CK_UTF8CHAR CK_PTR CK_UTF8CHAR_PTR; +typedef CK_ULONG CK_PTR CK_ULONG_PTR; +typedef void CK_PTR CK_VOID_PTR; + +/* Pointer to a CK_VOID_PTR-- i.e., pointer to pointer to void */ +typedef CK_VOID_PTR CK_PTR CK_VOID_PTR_PTR; + + +/* The following value is always invalid if used as a session + * handle or object handle + */ +#define CK_INVALID_HANDLE 0UL + + +typedef struct CK_VERSION { + CK_BYTE major; /* integer portion of version number */ + CK_BYTE minor; /* 1/100ths portion of version number */ +} CK_VERSION; + +typedef CK_VERSION CK_PTR CK_VERSION_PTR; + + +typedef struct CK_INFO { + CK_VERSION cryptokiVersion; /* Cryptoki interface ver */ + CK_UTF8CHAR manufacturerID[32]; /* blank padded */ + CK_FLAGS flags; /* must be zero */ + CK_UTF8CHAR libraryDescription[32]; /* blank padded */ + CK_VERSION libraryVersion; /* version of library */ +} CK_INFO; + +typedef CK_INFO CK_PTR CK_INFO_PTR; + + +/* CK_NOTIFICATION enumerates the types of notifications that + * Cryptoki provides to an application + */ +typedef CK_ULONG CK_NOTIFICATION; +#define CKN_SURRENDER 0UL +#define CKN_OTP_CHANGED 1UL + +typedef CK_ULONG CK_SLOT_ID; + +typedef CK_SLOT_ID CK_PTR CK_SLOT_ID_PTR; + + +/* CK_SLOT_INFO provides information about a slot */ +typedef struct CK_SLOT_INFO { + CK_UTF8CHAR slotDescription[64]; /* blank padded */ + CK_UTF8CHAR manufacturerID[32]; /* blank padded */ + CK_FLAGS flags; + + CK_VERSION hardwareVersion; /* version of hardware */ + CK_VERSION firmwareVersion; /* version of firmware */ +} CK_SLOT_INFO; + +/* flags: bit flags that provide capabilities of the slot + * Bit Flag Mask Meaning + */ +#define CKF_TOKEN_PRESENT 0x00000001UL /* a token is there */ +#define CKF_REMOVABLE_DEVICE 0x00000002UL /* removable devices*/ +#define CKF_HW_SLOT 0x00000004UL /* hardware slot */ + +typedef CK_SLOT_INFO CK_PTR CK_SLOT_INFO_PTR; + + +/* CK_TOKEN_INFO provides information about a token */ +typedef struct CK_TOKEN_INFO { + CK_UTF8CHAR label[32]; /* blank padded */ + CK_UTF8CHAR manufacturerID[32]; /* blank padded */ + CK_UTF8CHAR model[16]; /* blank padded */ + CK_CHAR serialNumber[16]; /* blank padded */ + CK_FLAGS flags; /* see below */ + + CK_ULONG ulMaxSessionCount; /* max open sessions */ + CK_ULONG ulSessionCount; /* sess. now open */ + CK_ULONG ulMaxRwSessionCount; /* max R/W sessions */ + CK_ULONG ulRwSessionCount; /* R/W sess. now open */ + CK_ULONG ulMaxPinLen; /* in bytes */ + CK_ULONG ulMinPinLen; /* in bytes */ + CK_ULONG ulTotalPublicMemory; /* in bytes */ + CK_ULONG ulFreePublicMemory; /* in bytes */ + CK_ULONG ulTotalPrivateMemory; /* in bytes */ + CK_ULONG ulFreePrivateMemory; /* in bytes */ + CK_VERSION hardwareVersion; /* version of hardware */ + CK_VERSION firmwareVersion; /* version of firmware */ + CK_CHAR utcTime[16]; /* time */ +} CK_TOKEN_INFO; + +/* The flags parameter is defined as follows: + * Bit Flag Mask Meaning + */ +#define CKF_RNG 0x00000001UL /* has random # generator */ +#define CKF_WRITE_PROTECTED 0x00000002UL /* token is write-protected */ +#define CKF_LOGIN_REQUIRED 0x00000004UL /* user must login */ +#define CKF_USER_PIN_INITIALIZED 0x00000008UL /* normal user's PIN is set */ + +/* CKF_RESTORE_KEY_NOT_NEEDED. If it is set, + * that means that *every* time the state of cryptographic + * operations of a session is successfully saved, all keys + * needed to continue those operations are stored in the state + */ +#define CKF_RESTORE_KEY_NOT_NEEDED 0x00000020UL + +/* CKF_CLOCK_ON_TOKEN. If it is set, that means + * that the token has some sort of clock. The time on that + * clock is returned in the token info structure + */ +#define CKF_CLOCK_ON_TOKEN 0x00000040UL + +/* CKF_PROTECTED_AUTHENTICATION_PATH. If it is + * set, that means that there is some way for the user to login + * without sending a PIN through the Cryptoki library itself + */ +#define CKF_PROTECTED_AUTHENTICATION_PATH 0x00000100UL + +/* CKF_DUAL_CRYPTO_OPERATIONS. If it is true, + * that means that a single session with the token can perform + * dual simultaneous cryptographic operations (digest and + * encrypt; decrypt and digest; sign and encrypt; and decrypt + * and sign) + */ +#define CKF_DUAL_CRYPTO_OPERATIONS 0x00000200UL + +/* CKF_TOKEN_INITIALIZED. If it is true, the + * token has been initialized using C_InitializeToken or an + * equivalent mechanism outside the scope of PKCS #11. + * Calling C_InitializeToken when this flag is set will cause + * the token to be reinitialized. + */ +#define CKF_TOKEN_INITIALIZED 0x00000400UL + +/* CKF_SECONDARY_AUTHENTICATION. If it is + * true, the token supports secondary authentication for + * private key objects. + */ +#define CKF_SECONDARY_AUTHENTICATION 0x00000800UL + +/* CKF_USER_PIN_COUNT_LOW. If it is true, an + * incorrect user login PIN has been entered at least once + * since the last successful authentication. + */ +#define CKF_USER_PIN_COUNT_LOW 0x00010000UL + +/* CKF_USER_PIN_FINAL_TRY. If it is true, + * supplying an incorrect user PIN will it to become locked. + */ +#define CKF_USER_PIN_FINAL_TRY 0x00020000UL + +/* CKF_USER_PIN_LOCKED. If it is true, the + * user PIN has been locked. User login to the token is not + * possible. + */ +#define CKF_USER_PIN_LOCKED 0x00040000UL + +/* CKF_USER_PIN_TO_BE_CHANGED. If it is true, + * the user PIN value is the default value set by token + * initialization or manufacturing, or the PIN has been + * expired by the card. + */ +#define CKF_USER_PIN_TO_BE_CHANGED 0x00080000UL + +/* CKF_SO_PIN_COUNT_LOW. If it is true, an + * incorrect SO login PIN has been entered at least once since + * the last successful authentication. + */ +#define CKF_SO_PIN_COUNT_LOW 0x00100000UL + +/* CKF_SO_PIN_FINAL_TRY. If it is true, + * supplying an incorrect SO PIN will it to become locked. + */ +#define CKF_SO_PIN_FINAL_TRY 0x00200000UL + +/* CKF_SO_PIN_LOCKED. If it is true, the SO + * PIN has been locked. SO login to the token is not possible. + */ +#define CKF_SO_PIN_LOCKED 0x00400000UL + +/* CKF_SO_PIN_TO_BE_CHANGED. If it is true, + * the SO PIN value is the default value set by token + * initialization or manufacturing, or the PIN has been + * expired by the card. + */ +#define CKF_SO_PIN_TO_BE_CHANGED 0x00800000UL + +#define CKF_ERROR_STATE 0x01000000UL + +typedef CK_TOKEN_INFO CK_PTR CK_TOKEN_INFO_PTR; + + +/* CK_SESSION_HANDLE is a Cryptoki-assigned value that + * identifies a session + */ +typedef CK_ULONG CK_SESSION_HANDLE; + +typedef CK_SESSION_HANDLE CK_PTR CK_SESSION_HANDLE_PTR; + + +/* CK_USER_TYPE enumerates the types of Cryptoki users */ +typedef CK_ULONG CK_USER_TYPE; +/* Security Officer */ +#define CKU_SO 0UL +/* Normal user */ +#define CKU_USER 1UL +/* Context specific */ +#define CKU_CONTEXT_SPECIFIC 2UL + +/* CK_STATE enumerates the session states */ +typedef CK_ULONG CK_STATE; +#define CKS_RO_PUBLIC_SESSION 0UL +#define CKS_RO_USER_FUNCTIONS 1UL +#define CKS_RW_PUBLIC_SESSION 2UL +#define CKS_RW_USER_FUNCTIONS 3UL +#define CKS_RW_SO_FUNCTIONS 4UL + +/* CK_SESSION_INFO provides information about a session */ +typedef struct CK_SESSION_INFO { + CK_SLOT_ID slotID; + CK_STATE state; + CK_FLAGS flags; /* see below */ + CK_ULONG ulDeviceError; /* device-dependent error code */ +} CK_SESSION_INFO; + +/* The flags are defined in the following table: + * Bit Flag Mask Meaning + */ +#define CKF_RW_SESSION 0x00000002UL /* session is r/w */ +#define CKF_SERIAL_SESSION 0x00000004UL /* no parallel */ + +typedef CK_SESSION_INFO CK_PTR CK_SESSION_INFO_PTR; + + +/* CK_OBJECT_HANDLE is a token-specific identifier for an + * object + */ +typedef CK_ULONG CK_OBJECT_HANDLE; + +typedef CK_OBJECT_HANDLE CK_PTR CK_OBJECT_HANDLE_PTR; + + +/* CK_OBJECT_CLASS is a value that identifies the classes (or + * types) of objects that Cryptoki recognizes. It is defined + * as follows: + */ +typedef CK_ULONG CK_OBJECT_CLASS; + +/* The following classes of objects are defined: */ +#define CKO_DATA 0x00000000UL +#define CKO_CERTIFICATE 0x00000001UL +#define CKO_PUBLIC_KEY 0x00000002UL +#define CKO_PRIVATE_KEY 0x00000003UL +#define CKO_SECRET_KEY 0x00000004UL +#define CKO_HW_FEATURE 0x00000005UL +#define CKO_DOMAIN_PARAMETERS 0x00000006UL +#define CKO_MECHANISM 0x00000007UL +#define CKO_OTP_KEY 0x00000008UL + +#define CKO_VENDOR_DEFINED 0x80000000UL + +typedef CK_OBJECT_CLASS CK_PTR CK_OBJECT_CLASS_PTR; + +/* CK_HW_FEATURE_TYPE is a value that identifies the hardware feature type + * of an object with CK_OBJECT_CLASS equal to CKO_HW_FEATURE. + */ +typedef CK_ULONG CK_HW_FEATURE_TYPE; + +/* The following hardware feature types are defined */ +#define CKH_MONOTONIC_COUNTER 0x00000001UL +#define CKH_CLOCK 0x00000002UL +#define CKH_USER_INTERFACE 0x00000003UL +#define CKH_VENDOR_DEFINED 0x80000000UL + +/* CK_KEY_TYPE is a value that identifies a key type */ +typedef CK_ULONG CK_KEY_TYPE; + +/* the following key types are defined: */ +#define CKK_RSA 0x00000000UL +#define CKK_DSA 0x00000001UL +#define CKK_DH 0x00000002UL +#define CKK_ECDSA 0x00000003UL /* Deprecated */ +#define CKK_EC 0x00000003UL +#define CKK_X9_42_DH 0x00000004UL +#define CKK_KEA 0x00000005UL +#define CKK_GENERIC_SECRET 0x00000010UL +#define CKK_RC2 0x00000011UL +#define CKK_RC4 0x00000012UL +#define CKK_DES 0x00000013UL +#define CKK_DES2 0x00000014UL +#define CKK_DES3 0x00000015UL +#define CKK_CAST 0x00000016UL +#define CKK_CAST3 0x00000017UL +#define CKK_CAST5 0x00000018UL /* Deprecated */ +#define CKK_CAST128 0x00000018UL +#define CKK_RC5 0x00000019UL +#define CKK_IDEA 0x0000001AUL +#define CKK_SKIPJACK 0x0000001BUL +#define CKK_BATON 0x0000001CUL +#define CKK_JUNIPER 0x0000001DUL +#define CKK_CDMF 0x0000001EUL +#define CKK_AES 0x0000001FUL +#define CKK_BLOWFISH 0x00000020UL +#define CKK_TWOFISH 0x00000021UL +#define CKK_SECURID 0x00000022UL +#define CKK_HOTP 0x00000023UL +#define CKK_ACTI 0x00000024UL +#define CKK_CAMELLIA 0x00000025UL +#define CKK_ARIA 0x00000026UL + +#define CKK_MD5_HMAC 0x00000027UL +#define CKK_SHA_1_HMAC 0x00000028UL +#define CKK_RIPEMD128_HMAC 0x00000029UL +#define CKK_RIPEMD160_HMAC 0x0000002AUL +#define CKK_SHA256_HMAC 0x0000002BUL +#define CKK_SHA384_HMAC 0x0000002CUL +#define CKK_SHA512_HMAC 0x0000002DUL +#define CKK_SHA224_HMAC 0x0000002EUL + +#define CKK_SEED 0x0000002FUL +#define CKK_GOSTR3410 0x00000030UL +#define CKK_GOSTR3411 0x00000031UL +#define CKK_GOST28147 0x00000032UL + + + +#define CKK_VENDOR_DEFINED 0x80000000UL + + +/* CK_CERTIFICATE_TYPE is a value that identifies a certificate + * type + */ +typedef CK_ULONG CK_CERTIFICATE_TYPE; + +#define CK_CERTIFICATE_CATEGORY_UNSPECIFIED 0UL +#define CK_CERTIFICATE_CATEGORY_TOKEN_USER 1UL +#define CK_CERTIFICATE_CATEGORY_AUTHORITY 2UL +#define CK_CERTIFICATE_CATEGORY_OTHER_ENTITY 3UL + +#define CK_SECURITY_DOMAIN_UNSPECIFIED 0UL +#define CK_SECURITY_DOMAIN_MANUFACTURER 1UL +#define CK_SECURITY_DOMAIN_OPERATOR 2UL +#define CK_SECURITY_DOMAIN_THIRD_PARTY 3UL + + +/* The following certificate types are defined: */ +#define CKC_X_509 0x00000000UL +#define CKC_X_509_ATTR_CERT 0x00000001UL +#define CKC_WTLS 0x00000002UL +#define CKC_VENDOR_DEFINED 0x80000000UL + + +/* CK_ATTRIBUTE_TYPE is a value that identifies an attribute + * type + */ +typedef CK_ULONG CK_ATTRIBUTE_TYPE; + +/* The CKF_ARRAY_ATTRIBUTE flag identifies an attribute which + * consists of an array of values. + */ +#define CKF_ARRAY_ATTRIBUTE 0x40000000UL + +/* The following OTP-related defines relate to the CKA_OTP_FORMAT attribute */ +#define CK_OTP_FORMAT_DECIMAL 0UL +#define CK_OTP_FORMAT_HEXADECIMAL 1UL +#define CK_OTP_FORMAT_ALPHANUMERIC 2UL +#define CK_OTP_FORMAT_BINARY 3UL + +/* The following OTP-related defines relate to the CKA_OTP_..._REQUIREMENT + * attributes + */ +#define CK_OTP_PARAM_IGNORED 0UL +#define CK_OTP_PARAM_OPTIONAL 1UL +#define CK_OTP_PARAM_MANDATORY 2UL + +/* The following attribute types are defined: */ +#define CKA_CLASS 0x00000000UL +#define CKA_TOKEN 0x00000001UL +#define CKA_PRIVATE 0x00000002UL +#define CKA_LABEL 0x00000003UL +#define CKA_APPLICATION 0x00000010UL +#define CKA_VALUE 0x00000011UL +#define CKA_OBJECT_ID 0x00000012UL +#define CKA_CERTIFICATE_TYPE 0x00000080UL +#define CKA_ISSUER 0x00000081UL +#define CKA_SERIAL_NUMBER 0x00000082UL +#define CKA_AC_ISSUER 0x00000083UL +#define CKA_OWNER 0x00000084UL +#define CKA_ATTR_TYPES 0x00000085UL +#define CKA_TRUSTED 0x00000086UL +#define CKA_CERTIFICATE_CATEGORY 0x00000087UL +#define CKA_JAVA_MIDP_SECURITY_DOMAIN 0x00000088UL +#define CKA_URL 0x00000089UL +#define CKA_HASH_OF_SUBJECT_PUBLIC_KEY 0x0000008AUL +#define CKA_HASH_OF_ISSUER_PUBLIC_KEY 0x0000008BUL +#define CKA_NAME_HASH_ALGORITHM 0x0000008CUL +#define CKA_CHECK_VALUE 0x00000090UL + +#define CKA_KEY_TYPE 0x00000100UL +#define CKA_SUBJECT 0x00000101UL +#define CKA_ID 0x00000102UL +#define CKA_SENSITIVE 0x00000103UL +#define CKA_ENCRYPT 0x00000104UL +#define CKA_DECRYPT 0x00000105UL +#define CKA_WRAP 0x00000106UL +#define CKA_UNWRAP 0x00000107UL +#define CKA_SIGN 0x00000108UL +#define CKA_SIGN_RECOVER 0x00000109UL +#define CKA_VERIFY 0x0000010AUL +#define CKA_VERIFY_RECOVER 0x0000010BUL +#define CKA_DERIVE 0x0000010CUL +#define CKA_START_DATE 0x00000110UL +#define CKA_END_DATE 0x00000111UL +#define CKA_MODULUS 0x00000120UL +#define CKA_MODULUS_BITS 0x00000121UL +#define CKA_PUBLIC_EXPONENT 0x00000122UL +#define CKA_PRIVATE_EXPONENT 0x00000123UL +#define CKA_PRIME_1 0x00000124UL +#define CKA_PRIME_2 0x00000125UL +#define CKA_EXPONENT_1 0x00000126UL +#define CKA_EXPONENT_2 0x00000127UL +#define CKA_COEFFICIENT 0x00000128UL +#define CKA_PUBLIC_KEY_INFO 0x00000129UL +#define CKA_PRIME 0x00000130UL +#define CKA_SUBPRIME 0x00000131UL +#define CKA_BASE 0x00000132UL + +#define CKA_PRIME_BITS 0x00000133UL +#define CKA_SUBPRIME_BITS 0x00000134UL +#define CKA_SUB_PRIME_BITS CKA_SUBPRIME_BITS + +#define CKA_VALUE_BITS 0x00000160UL +#define CKA_VALUE_LEN 0x00000161UL +#define CKA_EXTRACTABLE 0x00000162UL +#define CKA_LOCAL 0x00000163UL +#define CKA_NEVER_EXTRACTABLE 0x00000164UL +#define CKA_ALWAYS_SENSITIVE 0x00000165UL +#define CKA_KEY_GEN_MECHANISM 0x00000166UL + +#define CKA_MODIFIABLE 0x00000170UL +#define CKA_COPYABLE 0x00000171UL + +#define CKA_DESTROYABLE 0x00000172UL + +#define CKA_ECDSA_PARAMS 0x00000180UL /* Deprecated */ +#define CKA_EC_PARAMS 0x00000180UL + +#define CKA_EC_POINT 0x00000181UL + +#define CKA_SECONDARY_AUTH 0x00000200UL /* Deprecated */ +#define CKA_AUTH_PIN_FLAGS 0x00000201UL /* Deprecated */ + +#define CKA_ALWAYS_AUTHENTICATE 0x00000202UL + +#define CKA_WRAP_WITH_TRUSTED 0x00000210UL +#define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE|0x00000211UL) +#define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE|0x00000212UL) +#define CKA_DERIVE_TEMPLATE (CKF_ARRAY_ATTRIBUTE|0x00000213UL) + +#define CKA_OTP_FORMAT 0x00000220UL +#define CKA_OTP_LENGTH 0x00000221UL +#define CKA_OTP_TIME_INTERVAL 0x00000222UL +#define CKA_OTP_USER_FRIENDLY_MODE 0x00000223UL +#define CKA_OTP_CHALLENGE_REQUIREMENT 0x00000224UL +#define CKA_OTP_TIME_REQUIREMENT 0x00000225UL +#define CKA_OTP_COUNTER_REQUIREMENT 0x00000226UL +#define CKA_OTP_PIN_REQUIREMENT 0x00000227UL +#define CKA_OTP_COUNTER 0x0000022EUL +#define CKA_OTP_TIME 0x0000022FUL +#define CKA_OTP_USER_IDENTIFIER 0x0000022AUL +#define CKA_OTP_SERVICE_IDENTIFIER 0x0000022BUL +#define CKA_OTP_SERVICE_LOGO 0x0000022CUL +#define CKA_OTP_SERVICE_LOGO_TYPE 0x0000022DUL + +#define CKA_GOSTR3410_PARAMS 0x00000250UL +#define CKA_GOSTR3411_PARAMS 0x00000251UL +#define CKA_GOST28147_PARAMS 0x00000252UL + +#define CKA_HW_FEATURE_TYPE 0x00000300UL +#define CKA_RESET_ON_INIT 0x00000301UL +#define CKA_HAS_RESET 0x00000302UL + +#define CKA_PIXEL_X 0x00000400UL +#define CKA_PIXEL_Y 0x00000401UL +#define CKA_RESOLUTION 0x00000402UL +#define CKA_CHAR_ROWS 0x00000403UL +#define CKA_CHAR_COLUMNS 0x00000404UL +#define CKA_COLOR 0x00000405UL +#define CKA_BITS_PER_PIXEL 0x00000406UL +#define CKA_CHAR_SETS 0x00000480UL +#define CKA_ENCODING_METHODS 0x00000481UL +#define CKA_MIME_TYPES 0x00000482UL +#define CKA_MECHANISM_TYPE 0x00000500UL +#define CKA_REQUIRED_CMS_ATTRIBUTES 0x00000501UL +#define CKA_DEFAULT_CMS_ATTRIBUTES 0x00000502UL +#define CKA_SUPPORTED_CMS_ATTRIBUTES 0x00000503UL +#define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE|0x00000600UL) + +#define CKA_VENDOR_DEFINED 0x80000000UL + +/* CK_ATTRIBUTE is a structure that includes the type, length + * and value of an attribute + */ +typedef struct CK_ATTRIBUTE { + CK_ATTRIBUTE_TYPE type; + CK_VOID_PTR pValue; + CK_ULONG ulValueLen; /* in bytes */ +} CK_ATTRIBUTE; + +typedef CK_ATTRIBUTE CK_PTR CK_ATTRIBUTE_PTR; + +/* CK_DATE is a structure that defines a date */ +typedef struct CK_DATE{ + CK_CHAR year[4]; /* the year ("1900" - "9999") */ + CK_CHAR month[2]; /* the month ("01" - "12") */ + CK_CHAR day[2]; /* the day ("01" - "31") */ +} CK_DATE; + + +/* CK_MECHANISM_TYPE is a value that identifies a mechanism + * type + */ +typedef CK_ULONG CK_MECHANISM_TYPE; + +/* the following mechanism types are defined: */ +#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000UL +#define CKM_RSA_PKCS 0x00000001UL +#define CKM_RSA_9796 0x00000002UL +#define CKM_RSA_X_509 0x00000003UL + +#define CKM_MD2_RSA_PKCS 0x00000004UL +#define CKM_MD5_RSA_PKCS 0x00000005UL +#define CKM_SHA1_RSA_PKCS 0x00000006UL + +#define CKM_RIPEMD128_RSA_PKCS 0x00000007UL +#define CKM_RIPEMD160_RSA_PKCS 0x00000008UL +#define CKM_RSA_PKCS_OAEP 0x00000009UL + +#define CKM_RSA_X9_31_KEY_PAIR_GEN 0x0000000AUL +#define CKM_RSA_X9_31 0x0000000BUL +#define CKM_SHA1_RSA_X9_31 0x0000000CUL +#define CKM_RSA_PKCS_PSS 0x0000000DUL +#define CKM_SHA1_RSA_PKCS_PSS 0x0000000EUL + +#define CKM_DSA_KEY_PAIR_GEN 0x00000010UL +#define CKM_DSA 0x00000011UL +#define CKM_DSA_SHA1 0x00000012UL +#define CKM_DSA_SHA224 0x00000013UL +#define CKM_DSA_SHA256 0x00000014UL +#define CKM_DSA_SHA384 0x00000015UL +#define CKM_DSA_SHA512 0x00000016UL + +#define CKM_DH_PKCS_KEY_PAIR_GEN 0x00000020UL +#define CKM_DH_PKCS_DERIVE 0x00000021UL + +#define CKM_X9_42_DH_KEY_PAIR_GEN 0x00000030UL +#define CKM_X9_42_DH_DERIVE 0x00000031UL +#define CKM_X9_42_DH_HYBRID_DERIVE 0x00000032UL +#define CKM_X9_42_MQV_DERIVE 0x00000033UL + +#define CKM_SHA256_RSA_PKCS 0x00000040UL +#define CKM_SHA384_RSA_PKCS 0x00000041UL +#define CKM_SHA512_RSA_PKCS 0x00000042UL +#define CKM_SHA256_RSA_PKCS_PSS 0x00000043UL +#define CKM_SHA384_RSA_PKCS_PSS 0x00000044UL +#define CKM_SHA512_RSA_PKCS_PSS 0x00000045UL + +#define CKM_SHA224_RSA_PKCS 0x00000046UL +#define CKM_SHA224_RSA_PKCS_PSS 0x00000047UL + +#define CKM_SHA512_224 0x00000048UL +#define CKM_SHA512_224_HMAC 0x00000049UL +#define CKM_SHA512_224_HMAC_GENERAL 0x0000004AUL +#define CKM_SHA512_224_KEY_DERIVATION 0x0000004BUL +#define CKM_SHA512_256 0x0000004CUL +#define CKM_SHA512_256_HMAC 0x0000004DUL +#define CKM_SHA512_256_HMAC_GENERAL 0x0000004EUL +#define CKM_SHA512_256_KEY_DERIVATION 0x0000004FUL + +#define CKM_SHA512_T 0x00000050UL +#define CKM_SHA512_T_HMAC 0x00000051UL +#define CKM_SHA512_T_HMAC_GENERAL 0x00000052UL +#define CKM_SHA512_T_KEY_DERIVATION 0x00000053UL + +#define CKM_RC2_KEY_GEN 0x00000100UL +#define CKM_RC2_ECB 0x00000101UL +#define CKM_RC2_CBC 0x00000102UL +#define CKM_RC2_MAC 0x00000103UL + +#define CKM_RC2_MAC_GENERAL 0x00000104UL +#define CKM_RC2_CBC_PAD 0x00000105UL + +#define CKM_RC4_KEY_GEN 0x00000110UL +#define CKM_RC4 0x00000111UL +#define CKM_DES_KEY_GEN 0x00000120UL +#define CKM_DES_ECB 0x00000121UL +#define CKM_DES_CBC 0x00000122UL +#define CKM_DES_MAC 0x00000123UL + +#define CKM_DES_MAC_GENERAL 0x00000124UL +#define CKM_DES_CBC_PAD 0x00000125UL + +#define CKM_DES2_KEY_GEN 0x00000130UL +#define CKM_DES3_KEY_GEN 0x00000131UL +#define CKM_DES3_ECB 0x00000132UL +#define CKM_DES3_CBC 0x00000133UL +#define CKM_DES3_MAC 0x00000134UL + +#define CKM_DES3_MAC_GENERAL 0x00000135UL +#define CKM_DES3_CBC_PAD 0x00000136UL +#define CKM_DES3_CMAC_GENERAL 0x00000137UL +#define CKM_DES3_CMAC 0x00000138UL +#define CKM_CDMF_KEY_GEN 0x00000140UL +#define CKM_CDMF_ECB 0x00000141UL +#define CKM_CDMF_CBC 0x00000142UL +#define CKM_CDMF_MAC 0x00000143UL +#define CKM_CDMF_MAC_GENERAL 0x00000144UL +#define CKM_CDMF_CBC_PAD 0x00000145UL + +#define CKM_DES_OFB64 0x00000150UL +#define CKM_DES_OFB8 0x00000151UL +#define CKM_DES_CFB64 0x00000152UL +#define CKM_DES_CFB8 0x00000153UL + +#define CKM_MD2 0x00000200UL + +#define CKM_MD2_HMAC 0x00000201UL +#define CKM_MD2_HMAC_GENERAL 0x00000202UL + +#define CKM_MD5 0x00000210UL + +#define CKM_MD5_HMAC 0x00000211UL +#define CKM_MD5_HMAC_GENERAL 0x00000212UL + +#define CKM_SHA_1 0x00000220UL + +#define CKM_SHA_1_HMAC 0x00000221UL +#define CKM_SHA_1_HMAC_GENERAL 0x00000222UL + +#define CKM_RIPEMD128 0x00000230UL +#define CKM_RIPEMD128_HMAC 0x00000231UL +#define CKM_RIPEMD128_HMAC_GENERAL 0x00000232UL +#define CKM_RIPEMD160 0x00000240UL +#define CKM_RIPEMD160_HMAC 0x00000241UL +#define CKM_RIPEMD160_HMAC_GENERAL 0x00000242UL + +#define CKM_SHA256 0x00000250UL +#define CKM_SHA256_HMAC 0x00000251UL +#define CKM_SHA256_HMAC_GENERAL 0x00000252UL +#define CKM_SHA224 0x00000255UL +#define CKM_SHA224_HMAC 0x00000256UL +#define CKM_SHA224_HMAC_GENERAL 0x00000257UL +#define CKM_SHA384 0x00000260UL +#define CKM_SHA384_HMAC 0x00000261UL +#define CKM_SHA384_HMAC_GENERAL 0x00000262UL +#define CKM_SHA512 0x00000270UL +#define CKM_SHA512_HMAC 0x00000271UL +#define CKM_SHA512_HMAC_GENERAL 0x00000272UL +#define CKM_SECURID_KEY_GEN 0x00000280UL +#define CKM_SECURID 0x00000282UL +#define CKM_HOTP_KEY_GEN 0x00000290UL +#define CKM_HOTP 0x00000291UL +#define CKM_ACTI 0x000002A0UL +#define CKM_ACTI_KEY_GEN 0x000002A1UL + +#define CKM_CAST_KEY_GEN 0x00000300UL +#define CKM_CAST_ECB 0x00000301UL +#define CKM_CAST_CBC 0x00000302UL +#define CKM_CAST_MAC 0x00000303UL +#define CKM_CAST_MAC_GENERAL 0x00000304UL +#define CKM_CAST_CBC_PAD 0x00000305UL +#define CKM_CAST3_KEY_GEN 0x00000310UL +#define CKM_CAST3_ECB 0x00000311UL +#define CKM_CAST3_CBC 0x00000312UL +#define CKM_CAST3_MAC 0x00000313UL +#define CKM_CAST3_MAC_GENERAL 0x00000314UL +#define CKM_CAST3_CBC_PAD 0x00000315UL +/* Note that CAST128 and CAST5 are the same algorithm */ +#define CKM_CAST5_KEY_GEN 0x00000320UL +#define CKM_CAST128_KEY_GEN 0x00000320UL +#define CKM_CAST5_ECB 0x00000321UL +#define CKM_CAST128_ECB 0x00000321UL +#define CKM_CAST5_CBC 0x00000322UL /* Deprecated */ +#define CKM_CAST128_CBC 0x00000322UL +#define CKM_CAST5_MAC 0x00000323UL /* Deprecated */ +#define CKM_CAST128_MAC 0x00000323UL +#define CKM_CAST5_MAC_GENERAL 0x00000324UL /* Deprecated */ +#define CKM_CAST128_MAC_GENERAL 0x00000324UL +#define CKM_CAST5_CBC_PAD 0x00000325UL /* Deprecated */ +#define CKM_CAST128_CBC_PAD 0x00000325UL +#define CKM_RC5_KEY_GEN 0x00000330UL +#define CKM_RC5_ECB 0x00000331UL +#define CKM_RC5_CBC 0x00000332UL +#define CKM_RC5_MAC 0x00000333UL +#define CKM_RC5_MAC_GENERAL 0x00000334UL +#define CKM_RC5_CBC_PAD 0x00000335UL +#define CKM_IDEA_KEY_GEN 0x00000340UL +#define CKM_IDEA_ECB 0x00000341UL +#define CKM_IDEA_CBC 0x00000342UL +#define CKM_IDEA_MAC 0x00000343UL +#define CKM_IDEA_MAC_GENERAL 0x00000344UL +#define CKM_IDEA_CBC_PAD 0x00000345UL +#define CKM_GENERIC_SECRET_KEY_GEN 0x00000350UL +#define CKM_CONCATENATE_BASE_AND_KEY 0x00000360UL +#define CKM_CONCATENATE_BASE_AND_DATA 0x00000362UL +#define CKM_CONCATENATE_DATA_AND_BASE 0x00000363UL +#define CKM_XOR_BASE_AND_DATA 0x00000364UL +#define CKM_EXTRACT_KEY_FROM_KEY 0x00000365UL +#define CKM_SSL3_PRE_MASTER_KEY_GEN 0x00000370UL +#define CKM_SSL3_MASTER_KEY_DERIVE 0x00000371UL +#define CKM_SSL3_KEY_AND_MAC_DERIVE 0x00000372UL + +#define CKM_SSL3_MASTER_KEY_DERIVE_DH 0x00000373UL +#define CKM_TLS_PRE_MASTER_KEY_GEN 0x00000374UL +#define CKM_TLS_MASTER_KEY_DERIVE 0x00000375UL +#define CKM_TLS_KEY_AND_MAC_DERIVE 0x00000376UL +#define CKM_TLS_MASTER_KEY_DERIVE_DH 0x00000377UL + +#define CKM_TLS_PRF 0x00000378UL + +#define CKM_SSL3_MD5_MAC 0x00000380UL +#define CKM_SSL3_SHA1_MAC 0x00000381UL +#define CKM_MD5_KEY_DERIVATION 0x00000390UL +#define CKM_MD2_KEY_DERIVATION 0x00000391UL +#define CKM_SHA1_KEY_DERIVATION 0x00000392UL + +#define CKM_SHA256_KEY_DERIVATION 0x00000393UL +#define CKM_SHA384_KEY_DERIVATION 0x00000394UL +#define CKM_SHA512_KEY_DERIVATION 0x00000395UL +#define CKM_SHA224_KEY_DERIVATION 0x00000396UL + +#define CKM_PBE_MD2_DES_CBC 0x000003A0UL +#define CKM_PBE_MD5_DES_CBC 0x000003A1UL +#define CKM_PBE_MD5_CAST_CBC 0x000003A2UL +#define CKM_PBE_MD5_CAST3_CBC 0x000003A3UL +#define CKM_PBE_MD5_CAST5_CBC 0x000003A4UL /* Deprecated */ +#define CKM_PBE_MD5_CAST128_CBC 0x000003A4UL +#define CKM_PBE_SHA1_CAST5_CBC 0x000003A5UL /* Deprecated */ +#define CKM_PBE_SHA1_CAST128_CBC 0x000003A5UL +#define CKM_PBE_SHA1_RC4_128 0x000003A6UL +#define CKM_PBE_SHA1_RC4_40 0x000003A7UL +#define CKM_PBE_SHA1_DES3_EDE_CBC 0x000003A8UL +#define CKM_PBE_SHA1_DES2_EDE_CBC 0x000003A9UL +#define CKM_PBE_SHA1_RC2_128_CBC 0x000003AAUL +#define CKM_PBE_SHA1_RC2_40_CBC 0x000003ABUL + +#define CKM_PKCS5_PBKD2 0x000003B0UL + +#define CKM_PBA_SHA1_WITH_SHA1_HMAC 0x000003C0UL + +#define CKM_WTLS_PRE_MASTER_KEY_GEN 0x000003D0UL +#define CKM_WTLS_MASTER_KEY_DERIVE 0x000003D1UL +#define CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC 0x000003D2UL +#define CKM_WTLS_PRF 0x000003D3UL +#define CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE 0x000003D4UL +#define CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE 0x000003D5UL + +#define CKM_TLS10_MAC_SERVER 0x000003D6UL +#define CKM_TLS10_MAC_CLIENT 0x000003D7UL +#define CKM_TLS12_MAC 0x000003D8UL +#define CKM_TLS12_KDF 0x000003D9UL +#define CKM_TLS12_MASTER_KEY_DERIVE 0x000003E0UL +#define CKM_TLS12_KEY_AND_MAC_DERIVE 0x000003E1UL +#define CKM_TLS12_MASTER_KEY_DERIVE_DH 0x000003E2UL +#define CKM_TLS12_KEY_SAFE_DERIVE 0x000003E3UL +#define CKM_TLS_MAC 0x000003E4UL +#define CKM_TLS_KDF 0x000003E5UL + +#define CKM_KEY_WRAP_LYNKS 0x00000400UL +#define CKM_KEY_WRAP_SET_OAEP 0x00000401UL + +#define CKM_CMS_SIG 0x00000500UL +#define CKM_KIP_DERIVE 0x00000510UL +#define CKM_KIP_WRAP 0x00000511UL +#define CKM_KIP_MAC 0x00000512UL + +#define CKM_CAMELLIA_KEY_GEN 0x00000550UL +#define CKM_CAMELLIA_ECB 0x00000551UL +#define CKM_CAMELLIA_CBC 0x00000552UL +#define CKM_CAMELLIA_MAC 0x00000553UL +#define CKM_CAMELLIA_MAC_GENERAL 0x00000554UL +#define CKM_CAMELLIA_CBC_PAD 0x00000555UL +#define CKM_CAMELLIA_ECB_ENCRYPT_DATA 0x00000556UL +#define CKM_CAMELLIA_CBC_ENCRYPT_DATA 0x00000557UL +#define CKM_CAMELLIA_CTR 0x00000558UL + +#define CKM_ARIA_KEY_GEN 0x00000560UL +#define CKM_ARIA_ECB 0x00000561UL +#define CKM_ARIA_CBC 0x00000562UL +#define CKM_ARIA_MAC 0x00000563UL +#define CKM_ARIA_MAC_GENERAL 0x00000564UL +#define CKM_ARIA_CBC_PAD 0x00000565UL +#define CKM_ARIA_ECB_ENCRYPT_DATA 0x00000566UL +#define CKM_ARIA_CBC_ENCRYPT_DATA 0x00000567UL + +#define CKM_SEED_KEY_GEN 0x00000650UL +#define CKM_SEED_ECB 0x00000651UL +#define CKM_SEED_CBC 0x00000652UL +#define CKM_SEED_MAC 0x00000653UL +#define CKM_SEED_MAC_GENERAL 0x00000654UL +#define CKM_SEED_CBC_PAD 0x00000655UL +#define CKM_SEED_ECB_ENCRYPT_DATA 0x00000656UL +#define CKM_SEED_CBC_ENCRYPT_DATA 0x00000657UL + +#define CKM_SKIPJACK_KEY_GEN 0x00001000UL +#define CKM_SKIPJACK_ECB64 0x00001001UL +#define CKM_SKIPJACK_CBC64 0x00001002UL +#define CKM_SKIPJACK_OFB64 0x00001003UL +#define CKM_SKIPJACK_CFB64 0x00001004UL +#define CKM_SKIPJACK_CFB32 0x00001005UL +#define CKM_SKIPJACK_CFB16 0x00001006UL +#define CKM_SKIPJACK_CFB8 0x00001007UL +#define CKM_SKIPJACK_WRAP 0x00001008UL +#define CKM_SKIPJACK_PRIVATE_WRAP 0x00001009UL +#define CKM_SKIPJACK_RELAYX 0x0000100aUL +#define CKM_KEA_KEY_PAIR_GEN 0x00001010UL +#define CKM_KEA_KEY_DERIVE 0x00001011UL +#define CKM_KEA_DERIVE 0x00001012UL +#define CKM_FORTEZZA_TIMESTAMP 0x00001020UL +#define CKM_BATON_KEY_GEN 0x00001030UL +#define CKM_BATON_ECB128 0x00001031UL +#define CKM_BATON_ECB96 0x00001032UL +#define CKM_BATON_CBC128 0x00001033UL +#define CKM_BATON_COUNTER 0x00001034UL +#define CKM_BATON_SHUFFLE 0x00001035UL +#define CKM_BATON_WRAP 0x00001036UL + +#define CKM_ECDSA_KEY_PAIR_GEN 0x00001040UL /* Deprecated */ +#define CKM_EC_KEY_PAIR_GEN 0x00001040UL + +#define CKM_ECDSA 0x00001041UL +#define CKM_ECDSA_SHA1 0x00001042UL +#define CKM_ECDSA_SHA224 0x00001043UL +#define CKM_ECDSA_SHA256 0x00001044UL +#define CKM_ECDSA_SHA384 0x00001045UL +#define CKM_ECDSA_SHA512 0x00001046UL + +#define CKM_ECDH1_DERIVE 0x00001050UL +#define CKM_ECDH1_COFACTOR_DERIVE 0x00001051UL +#define CKM_ECMQV_DERIVE 0x00001052UL + +#define CKM_ECDH_AES_KEY_WRAP 0x00001053UL +#define CKM_RSA_AES_KEY_WRAP 0x00001054UL + +#define CKM_JUNIPER_KEY_GEN 0x00001060UL +#define CKM_JUNIPER_ECB128 0x00001061UL +#define CKM_JUNIPER_CBC128 0x00001062UL +#define CKM_JUNIPER_COUNTER 0x00001063UL +#define CKM_JUNIPER_SHUFFLE 0x00001064UL +#define CKM_JUNIPER_WRAP 0x00001065UL +#define CKM_FASTHASH 0x00001070UL + +#define CKM_AES_KEY_GEN 0x00001080UL +#define CKM_AES_ECB 0x00001081UL +#define CKM_AES_CBC 0x00001082UL +#define CKM_AES_MAC 0x00001083UL +#define CKM_AES_MAC_GENERAL 0x00001084UL +#define CKM_AES_CBC_PAD 0x00001085UL +#define CKM_AES_CTR 0x00001086UL +#define CKM_AES_GCM 0x00001087UL +#define CKM_AES_CCM 0x00001088UL +#define CKM_AES_CTS 0x00001089UL +#define CKM_AES_CMAC 0x0000108AUL +#define CKM_AES_CMAC_GENERAL 0x0000108BUL + +#define CKM_AES_XCBC_MAC 0x0000108CUL +#define CKM_AES_XCBC_MAC_96 0x0000108DUL +#define CKM_AES_GMAC 0x0000108EUL + +#define CKM_BLOWFISH_KEY_GEN 0x00001090UL +#define CKM_BLOWFISH_CBC 0x00001091UL +#define CKM_TWOFISH_KEY_GEN 0x00001092UL +#define CKM_TWOFISH_CBC 0x00001093UL +#define CKM_BLOWFISH_CBC_PAD 0x00001094UL +#define CKM_TWOFISH_CBC_PAD 0x00001095UL + +#define CKM_DES_ECB_ENCRYPT_DATA 0x00001100UL +#define CKM_DES_CBC_ENCRYPT_DATA 0x00001101UL +#define CKM_DES3_ECB_ENCRYPT_DATA 0x00001102UL +#define CKM_DES3_CBC_ENCRYPT_DATA 0x00001103UL +#define CKM_AES_ECB_ENCRYPT_DATA 0x00001104UL +#define CKM_AES_CBC_ENCRYPT_DATA 0x00001105UL + +#define CKM_GOSTR3410_KEY_PAIR_GEN 0x00001200UL +#define CKM_GOSTR3410 0x00001201UL +#define CKM_GOSTR3410_WITH_GOSTR3411 0x00001202UL +#define CKM_GOSTR3410_KEY_WRAP 0x00001203UL +#define CKM_GOSTR3410_DERIVE 0x00001204UL +#define CKM_GOSTR3411 0x00001210UL +#define CKM_GOSTR3411_HMAC 0x00001211UL +#define CKM_GOST28147_KEY_GEN 0x00001220UL +#define CKM_GOST28147_ECB 0x00001221UL +#define CKM_GOST28147 0x00001222UL +#define CKM_GOST28147_MAC 0x00001223UL +#define CKM_GOST28147_KEY_WRAP 0x00001224UL + +#define CKM_DSA_PARAMETER_GEN 0x00002000UL +#define CKM_DH_PKCS_PARAMETER_GEN 0x00002001UL +#define CKM_X9_42_DH_PARAMETER_GEN 0x00002002UL +#define CKM_DSA_PROBABLISTIC_PARAMETER_GEN 0x00002003UL +#define CKM_DSA_SHAWE_TAYLOR_PARAMETER_GEN 0x00002004UL + +#define CKM_AES_OFB 0x00002104UL +#define CKM_AES_CFB64 0x00002105UL +#define CKM_AES_CFB8 0x00002106UL +#define CKM_AES_CFB128 0x00002107UL + +#define CKM_AES_CFB1 0x00002108UL +#define CKM_AES_KEY_WRAP 0x00002109UL /* WAS: 0x00001090 */ +#define CKM_AES_KEY_WRAP_PAD 0x0000210AUL /* WAS: 0x00001091 */ + +#define CKM_RSA_PKCS_TPM_1_1 0x00004001UL +#define CKM_RSA_PKCS_OAEP_TPM_1_1 0x00004002UL + +#define CKM_VENDOR_DEFINED 0x80000000UL + +typedef CK_MECHANISM_TYPE CK_PTR CK_MECHANISM_TYPE_PTR; + + +/* CK_MECHANISM is a structure that specifies a particular + * mechanism + */ +typedef struct CK_MECHANISM { + CK_MECHANISM_TYPE mechanism; + CK_VOID_PTR pParameter; + CK_ULONG ulParameterLen; /* in bytes */ +} CK_MECHANISM; + +typedef CK_MECHANISM CK_PTR CK_MECHANISM_PTR; + + +/* CK_MECHANISM_INFO provides information about a particular + * mechanism + */ +typedef struct CK_MECHANISM_INFO { + CK_ULONG ulMinKeySize; + CK_ULONG ulMaxKeySize; + CK_FLAGS flags; +} CK_MECHANISM_INFO; + +/* The flags are defined as follows: + * Bit Flag Mask Meaning */ +#define CKF_HW 0x00000001UL /* performed by HW */ + +/* Specify whether or not a mechanism can be used for a particular task */ +#define CKF_ENCRYPT 0x00000100UL +#define CKF_DECRYPT 0x00000200UL +#define CKF_DIGEST 0x00000400UL +#define CKF_SIGN 0x00000800UL +#define CKF_SIGN_RECOVER 0x00001000UL +#define CKF_VERIFY 0x00002000UL +#define CKF_VERIFY_RECOVER 0x00004000UL +#define CKF_GENERATE 0x00008000UL +#define CKF_GENERATE_KEY_PAIR 0x00010000UL +#define CKF_WRAP 0x00020000UL +#define CKF_UNWRAP 0x00040000UL +#define CKF_DERIVE 0x00080000UL + +/* Describe a token's EC capabilities not available in mechanism + * information. + */ +#define CKF_EC_F_P 0x00100000UL +#define CKF_EC_F_2M 0x00200000UL +#define CKF_EC_ECPARAMETERS 0x00400000UL +#define CKF_EC_NAMEDCURVE 0x00800000UL +#define CKF_EC_UNCOMPRESS 0x01000000UL +#define CKF_EC_COMPRESS 0x02000000UL + +#define CKF_EXTENSION 0x80000000UL + +typedef CK_MECHANISM_INFO CK_PTR CK_MECHANISM_INFO_PTR; + +/* CK_RV is a value that identifies the return value of a + * Cryptoki function + */ +typedef CK_ULONG CK_RV; + +#define CKR_OK 0x00000000UL +#define CKR_CANCEL 0x00000001UL +#define CKR_HOST_MEMORY 0x00000002UL +#define CKR_SLOT_ID_INVALID 0x00000003UL + +#define CKR_GENERAL_ERROR 0x00000005UL +#define CKR_FUNCTION_FAILED 0x00000006UL + +#define CKR_ARGUMENTS_BAD 0x00000007UL +#define CKR_NO_EVENT 0x00000008UL +#define CKR_NEED_TO_CREATE_THREADS 0x00000009UL +#define CKR_CANT_LOCK 0x0000000AUL + +#define CKR_ATTRIBUTE_READ_ONLY 0x00000010UL +#define CKR_ATTRIBUTE_SENSITIVE 0x00000011UL +#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL +#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013UL + +#define CKR_ACTION_PROHIBITED 0x0000001BUL + +#define CKR_DATA_INVALID 0x00000020UL +#define CKR_DATA_LEN_RANGE 0x00000021UL +#define CKR_DEVICE_ERROR 0x00000030UL +#define CKR_DEVICE_MEMORY 0x00000031UL +#define CKR_DEVICE_REMOVED 0x00000032UL +#define CKR_ENCRYPTED_DATA_INVALID 0x00000040UL +#define CKR_ENCRYPTED_DATA_LEN_RANGE 0x00000041UL +#define CKR_FUNCTION_CANCELED 0x00000050UL +#define CKR_FUNCTION_NOT_PARALLEL 0x00000051UL + +#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL + +#define CKR_KEY_HANDLE_INVALID 0x00000060UL + +#define CKR_KEY_SIZE_RANGE 0x00000062UL +#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL + +#define CKR_KEY_NOT_NEEDED 0x00000064UL +#define CKR_KEY_CHANGED 0x00000065UL +#define CKR_KEY_NEEDED 0x00000066UL +#define CKR_KEY_INDIGESTIBLE 0x00000067UL +#define CKR_KEY_FUNCTION_NOT_PERMITTED 0x00000068UL +#define CKR_KEY_NOT_WRAPPABLE 0x00000069UL +#define CKR_KEY_UNEXTRACTABLE 0x0000006AUL + +#define CKR_MECHANISM_INVALID 0x00000070UL +#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL + +#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL +#define CKR_OPERATION_ACTIVE 0x00000090UL +#define CKR_OPERATION_NOT_INITIALIZED 0x00000091UL +#define CKR_PIN_INCORRECT 0x000000A0UL +#define CKR_PIN_INVALID 0x000000A1UL +#define CKR_PIN_LEN_RANGE 0x000000A2UL + +#define CKR_PIN_EXPIRED 0x000000A3UL +#define CKR_PIN_LOCKED 0x000000A4UL + +#define CKR_SESSION_CLOSED 0x000000B0UL +#define CKR_SESSION_COUNT 0x000000B1UL +#define CKR_SESSION_HANDLE_INVALID 0x000000B3UL +#define CKR_SESSION_PARALLEL_NOT_SUPPORTED 0x000000B4UL +#define CKR_SESSION_READ_ONLY 0x000000B5UL +#define CKR_SESSION_EXISTS 0x000000B6UL + +#define CKR_SESSION_READ_ONLY_EXISTS 0x000000B7UL +#define CKR_SESSION_READ_WRITE_SO_EXISTS 0x000000B8UL + +#define CKR_SIGNATURE_INVALID 0x000000C0UL +#define CKR_SIGNATURE_LEN_RANGE 0x000000C1UL +#define CKR_TEMPLATE_INCOMPLETE 0x000000D0UL +#define CKR_TEMPLATE_INCONSISTENT 0x000000D1UL +#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL +#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL +#define CKR_TOKEN_WRITE_PROTECTED 0x000000E2UL +#define CKR_UNWRAPPING_KEY_HANDLE_INVALID 0x000000F0UL +#define CKR_UNWRAPPING_KEY_SIZE_RANGE 0x000000F1UL +#define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT 0x000000F2UL +#define CKR_USER_ALREADY_LOGGED_IN 0x00000100UL +#define CKR_USER_NOT_LOGGED_IN 0x00000101UL +#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102UL +#define CKR_USER_TYPE_INVALID 0x00000103UL + +#define CKR_USER_ANOTHER_ALREADY_LOGGED_IN 0x00000104UL +#define CKR_USER_TOO_MANY_TYPES 0x00000105UL + +#define CKR_WRAPPED_KEY_INVALID 0x00000110UL +#define CKR_WRAPPED_KEY_LEN_RANGE 0x00000112UL +#define CKR_WRAPPING_KEY_HANDLE_INVALID 0x00000113UL +#define CKR_WRAPPING_KEY_SIZE_RANGE 0x00000114UL +#define CKR_WRAPPING_KEY_TYPE_INCONSISTENT 0x00000115UL +#define CKR_RANDOM_SEED_NOT_SUPPORTED 0x00000120UL + +#define CKR_RANDOM_NO_RNG 0x00000121UL + +#define CKR_DOMAIN_PARAMS_INVALID 0x00000130UL + +#define CKR_CURVE_NOT_SUPPORTED 0x00000140UL + +#define CKR_BUFFER_TOO_SMALL 0x00000150UL +#define CKR_SAVED_STATE_INVALID 0x00000160UL +#define CKR_INFORMATION_SENSITIVE 0x00000170UL +#define CKR_STATE_UNSAVEABLE 0x00000180UL + +#define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190UL +#define CKR_CRYPTOKI_ALREADY_INITIALIZED 0x00000191UL +#define CKR_MUTEX_BAD 0x000001A0UL +#define CKR_MUTEX_NOT_LOCKED 0x000001A1UL + +#define CKR_NEW_PIN_MODE 0x000001B0UL +#define CKR_NEXT_OTP 0x000001B1UL + +#define CKR_EXCEEDED_MAX_ITERATIONS 0x000001B5UL +#define CKR_FIPS_SELF_TEST_FAILED 0x000001B6UL +#define CKR_LIBRARY_LOAD_FAILED 0x000001B7UL +#define CKR_PIN_TOO_WEAK 0x000001B8UL +#define CKR_PUBLIC_KEY_INVALID 0x000001B9UL + +#define CKR_FUNCTION_REJECTED 0x00000200UL + +#define CKR_VENDOR_DEFINED 0x80000000UL + + +/* CK_NOTIFY is an application callback that processes events */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_NOTIFY)( + CK_SESSION_HANDLE hSession, /* the session's handle */ + CK_NOTIFICATION event, + CK_VOID_PTR pApplication /* passed to C_OpenSession */ +); + + +/* CK_FUNCTION_LIST is a structure holding a Cryptoki spec + * version and pointers of appropriate types to all the + * Cryptoki functions + */ +typedef struct CK_FUNCTION_LIST CK_FUNCTION_LIST; + +typedef CK_FUNCTION_LIST CK_PTR CK_FUNCTION_LIST_PTR; + +typedef CK_FUNCTION_LIST_PTR CK_PTR CK_FUNCTION_LIST_PTR_PTR; + + +/* CK_CREATEMUTEX is an application callback for creating a + * mutex object + */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_CREATEMUTEX)( + CK_VOID_PTR_PTR ppMutex /* location to receive ptr to mutex */ +); + + +/* CK_DESTROYMUTEX is an application callback for destroying a + * mutex object + */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_DESTROYMUTEX)( + CK_VOID_PTR pMutex /* pointer to mutex */ +); + + +/* CK_LOCKMUTEX is an application callback for locking a mutex */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_LOCKMUTEX)( + CK_VOID_PTR pMutex /* pointer to mutex */ +); + + +/* CK_UNLOCKMUTEX is an application callback for unlocking a + * mutex + */ +typedef CK_CALLBACK_FUNCTION(CK_RV, CK_UNLOCKMUTEX)( + CK_VOID_PTR pMutex /* pointer to mutex */ +); + + +/* CK_C_INITIALIZE_ARGS provides the optional arguments to + * C_Initialize + */ +typedef struct CK_C_INITIALIZE_ARGS { + CK_CREATEMUTEX CreateMutex; + CK_DESTROYMUTEX DestroyMutex; + CK_LOCKMUTEX LockMutex; + CK_UNLOCKMUTEX UnlockMutex; + CK_FLAGS flags; + CK_VOID_PTR pReserved; +} CK_C_INITIALIZE_ARGS; + +/* flags: bit flags that provide capabilities of the slot + * Bit Flag Mask Meaning + */ +#define CKF_LIBRARY_CANT_CREATE_OS_THREADS 0x00000001UL +#define CKF_OS_LOCKING_OK 0x00000002UL + +typedef CK_C_INITIALIZE_ARGS CK_PTR CK_C_INITIALIZE_ARGS_PTR; + + +/* additional flags for parameters to functions */ + +/* CKF_DONT_BLOCK is for the function C_WaitForSlotEvent */ +#define CKF_DONT_BLOCK 1 + +/* CK_RSA_PKCS_MGF_TYPE is used to indicate the Message + * Generation Function (MGF) applied to a message block when + * formatting a message block for the PKCS #1 OAEP encryption + * scheme. + */ +typedef CK_ULONG CK_RSA_PKCS_MGF_TYPE; + +typedef CK_RSA_PKCS_MGF_TYPE CK_PTR CK_RSA_PKCS_MGF_TYPE_PTR; + +/* The following MGFs are defined */ +#define CKG_MGF1_SHA1 0x00000001UL +#define CKG_MGF1_SHA256 0x00000002UL +#define CKG_MGF1_SHA384 0x00000003UL +#define CKG_MGF1_SHA512 0x00000004UL +#define CKG_MGF1_SHA224 0x00000005UL + +/* CK_RSA_PKCS_OAEP_SOURCE_TYPE is used to indicate the source + * of the encoding parameter when formatting a message block + * for the PKCS #1 OAEP encryption scheme. + */ +typedef CK_ULONG CK_RSA_PKCS_OAEP_SOURCE_TYPE; + +typedef CK_RSA_PKCS_OAEP_SOURCE_TYPE CK_PTR CK_RSA_PKCS_OAEP_SOURCE_TYPE_PTR; + +/* The following encoding parameter sources are defined */ +#define CKZ_DATA_SPECIFIED 0x00000001UL + +/* CK_RSA_PKCS_OAEP_PARAMS provides the parameters to the + * CKM_RSA_PKCS_OAEP mechanism. + */ +typedef struct CK_RSA_PKCS_OAEP_PARAMS { + CK_MECHANISM_TYPE hashAlg; + CK_RSA_PKCS_MGF_TYPE mgf; + CK_RSA_PKCS_OAEP_SOURCE_TYPE source; + CK_VOID_PTR pSourceData; + CK_ULONG ulSourceDataLen; +} CK_RSA_PKCS_OAEP_PARAMS; + +typedef CK_RSA_PKCS_OAEP_PARAMS CK_PTR CK_RSA_PKCS_OAEP_PARAMS_PTR; + +/* CK_RSA_PKCS_PSS_PARAMS provides the parameters to the + * CKM_RSA_PKCS_PSS mechanism(s). + */ +typedef struct CK_RSA_PKCS_PSS_PARAMS { + CK_MECHANISM_TYPE hashAlg; + CK_RSA_PKCS_MGF_TYPE mgf; + CK_ULONG sLen; +} CK_RSA_PKCS_PSS_PARAMS; + +typedef CK_RSA_PKCS_PSS_PARAMS CK_PTR CK_RSA_PKCS_PSS_PARAMS_PTR; + +typedef CK_ULONG CK_EC_KDF_TYPE; + +/* The following EC Key Derivation Functions are defined */ +#define CKD_NULL 0x00000001UL +#define CKD_SHA1_KDF 0x00000002UL + +/* The following X9.42 DH key derivation functions are defined */ +#define CKD_SHA1_KDF_ASN1 0x00000003UL +#define CKD_SHA1_KDF_CONCATENATE 0x00000004UL +#define CKD_SHA224_KDF 0x00000005UL +#define CKD_SHA256_KDF 0x00000006UL +#define CKD_SHA384_KDF 0x00000007UL +#define CKD_SHA512_KDF 0x00000008UL +#define CKD_CPDIVERSIFY_KDF 0x00000009UL + + +/* CK_ECDH1_DERIVE_PARAMS provides the parameters to the + * CKM_ECDH1_DERIVE and CKM_ECDH1_COFACTOR_DERIVE mechanisms, + * where each party contributes one key pair. + */ +typedef struct CK_ECDH1_DERIVE_PARAMS { + CK_EC_KDF_TYPE kdf; + CK_ULONG ulSharedDataLen; + CK_BYTE_PTR pSharedData; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; +} CK_ECDH1_DERIVE_PARAMS; + +typedef CK_ECDH1_DERIVE_PARAMS CK_PTR CK_ECDH1_DERIVE_PARAMS_PTR; + +/* + * CK_ECDH2_DERIVE_PARAMS provides the parameters to the + * CKM_ECMQV_DERIVE mechanism, where each party contributes two key pairs. + */ +typedef struct CK_ECDH2_DERIVE_PARAMS { + CK_EC_KDF_TYPE kdf; + CK_ULONG ulSharedDataLen; + CK_BYTE_PTR pSharedData; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPrivateDataLen; + CK_OBJECT_HANDLE hPrivateData; + CK_ULONG ulPublicDataLen2; + CK_BYTE_PTR pPublicData2; +} CK_ECDH2_DERIVE_PARAMS; + +typedef CK_ECDH2_DERIVE_PARAMS CK_PTR CK_ECDH2_DERIVE_PARAMS_PTR; + +typedef struct CK_ECMQV_DERIVE_PARAMS { + CK_EC_KDF_TYPE kdf; + CK_ULONG ulSharedDataLen; + CK_BYTE_PTR pSharedData; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPrivateDataLen; + CK_OBJECT_HANDLE hPrivateData; + CK_ULONG ulPublicDataLen2; + CK_BYTE_PTR pPublicData2; + CK_OBJECT_HANDLE publicKey; +} CK_ECMQV_DERIVE_PARAMS; + +typedef CK_ECMQV_DERIVE_PARAMS CK_PTR CK_ECMQV_DERIVE_PARAMS_PTR; + +/* Typedefs and defines for the CKM_X9_42_DH_KEY_PAIR_GEN and the + * CKM_X9_42_DH_PARAMETER_GEN mechanisms + */ +typedef CK_ULONG CK_X9_42_DH_KDF_TYPE; +typedef CK_X9_42_DH_KDF_TYPE CK_PTR CK_X9_42_DH_KDF_TYPE_PTR; + +/* CK_X9_42_DH1_DERIVE_PARAMS provides the parameters to the + * CKM_X9_42_DH_DERIVE key derivation mechanism, where each party + * contributes one key pair + */ +typedef struct CK_X9_42_DH1_DERIVE_PARAMS { + CK_X9_42_DH_KDF_TYPE kdf; + CK_ULONG ulOtherInfoLen; + CK_BYTE_PTR pOtherInfo; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; +} CK_X9_42_DH1_DERIVE_PARAMS; + +typedef struct CK_X9_42_DH1_DERIVE_PARAMS CK_PTR CK_X9_42_DH1_DERIVE_PARAMS_PTR; + +/* CK_X9_42_DH2_DERIVE_PARAMS provides the parameters to the + * CKM_X9_42_DH_HYBRID_DERIVE and CKM_X9_42_MQV_DERIVE key derivation + * mechanisms, where each party contributes two key pairs + */ +typedef struct CK_X9_42_DH2_DERIVE_PARAMS { + CK_X9_42_DH_KDF_TYPE kdf; + CK_ULONG ulOtherInfoLen; + CK_BYTE_PTR pOtherInfo; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPrivateDataLen; + CK_OBJECT_HANDLE hPrivateData; + CK_ULONG ulPublicDataLen2; + CK_BYTE_PTR pPublicData2; +} CK_X9_42_DH2_DERIVE_PARAMS; + +typedef CK_X9_42_DH2_DERIVE_PARAMS CK_PTR CK_X9_42_DH2_DERIVE_PARAMS_PTR; + +typedef struct CK_X9_42_MQV_DERIVE_PARAMS { + CK_X9_42_DH_KDF_TYPE kdf; + CK_ULONG ulOtherInfoLen; + CK_BYTE_PTR pOtherInfo; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPrivateDataLen; + CK_OBJECT_HANDLE hPrivateData; + CK_ULONG ulPublicDataLen2; + CK_BYTE_PTR pPublicData2; + CK_OBJECT_HANDLE publicKey; +} CK_X9_42_MQV_DERIVE_PARAMS; + +typedef CK_X9_42_MQV_DERIVE_PARAMS CK_PTR CK_X9_42_MQV_DERIVE_PARAMS_PTR; + +/* CK_KEA_DERIVE_PARAMS provides the parameters to the + * CKM_KEA_DERIVE mechanism + */ +typedef struct CK_KEA_DERIVE_PARAMS { + CK_BBOOL isSender; + CK_ULONG ulRandomLen; + CK_BYTE_PTR pRandomA; + CK_BYTE_PTR pRandomB; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; +} CK_KEA_DERIVE_PARAMS; + +typedef CK_KEA_DERIVE_PARAMS CK_PTR CK_KEA_DERIVE_PARAMS_PTR; + + +/* CK_RC2_PARAMS provides the parameters to the CKM_RC2_ECB and + * CKM_RC2_MAC mechanisms. An instance of CK_RC2_PARAMS just + * holds the effective keysize + */ +typedef CK_ULONG CK_RC2_PARAMS; + +typedef CK_RC2_PARAMS CK_PTR CK_RC2_PARAMS_PTR; + + +/* CK_RC2_CBC_PARAMS provides the parameters to the CKM_RC2_CBC + * mechanism + */ +typedef struct CK_RC2_CBC_PARAMS { + CK_ULONG ulEffectiveBits; /* effective bits (1-1024) */ + CK_BYTE iv[8]; /* IV for CBC mode */ +} CK_RC2_CBC_PARAMS; + +typedef CK_RC2_CBC_PARAMS CK_PTR CK_RC2_CBC_PARAMS_PTR; + + +/* CK_RC2_MAC_GENERAL_PARAMS provides the parameters for the + * CKM_RC2_MAC_GENERAL mechanism + */ +typedef struct CK_RC2_MAC_GENERAL_PARAMS { + CK_ULONG ulEffectiveBits; /* effective bits (1-1024) */ + CK_ULONG ulMacLength; /* Length of MAC in bytes */ +} CK_RC2_MAC_GENERAL_PARAMS; + +typedef CK_RC2_MAC_GENERAL_PARAMS CK_PTR \ + CK_RC2_MAC_GENERAL_PARAMS_PTR; + + +/* CK_RC5_PARAMS provides the parameters to the CKM_RC5_ECB and + * CKM_RC5_MAC mechanisms + */ +typedef struct CK_RC5_PARAMS { + CK_ULONG ulWordsize; /* wordsize in bits */ + CK_ULONG ulRounds; /* number of rounds */ +} CK_RC5_PARAMS; + +typedef CK_RC5_PARAMS CK_PTR CK_RC5_PARAMS_PTR; + + +/* CK_RC5_CBC_PARAMS provides the parameters to the CKM_RC5_CBC + * mechanism + */ +typedef struct CK_RC5_CBC_PARAMS { + CK_ULONG ulWordsize; /* wordsize in bits */ + CK_ULONG ulRounds; /* number of rounds */ + CK_BYTE_PTR pIv; /* pointer to IV */ + CK_ULONG ulIvLen; /* length of IV in bytes */ +} CK_RC5_CBC_PARAMS; + +typedef CK_RC5_CBC_PARAMS CK_PTR CK_RC5_CBC_PARAMS_PTR; + + +/* CK_RC5_MAC_GENERAL_PARAMS provides the parameters for the + * CKM_RC5_MAC_GENERAL mechanism + */ +typedef struct CK_RC5_MAC_GENERAL_PARAMS { + CK_ULONG ulWordsize; /* wordsize in bits */ + CK_ULONG ulRounds; /* number of rounds */ + CK_ULONG ulMacLength; /* Length of MAC in bytes */ +} CK_RC5_MAC_GENERAL_PARAMS; + +typedef CK_RC5_MAC_GENERAL_PARAMS CK_PTR \ + CK_RC5_MAC_GENERAL_PARAMS_PTR; + +/* CK_MAC_GENERAL_PARAMS provides the parameters to most block + * ciphers' MAC_GENERAL mechanisms. Its value is the length of + * the MAC + */ +typedef CK_ULONG CK_MAC_GENERAL_PARAMS; + +typedef CK_MAC_GENERAL_PARAMS CK_PTR CK_MAC_GENERAL_PARAMS_PTR; + +typedef struct CK_DES_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[8]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_DES_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_DES_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_DES_CBC_ENCRYPT_DATA_PARAMS_PTR; + +typedef struct CK_AES_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[16]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_AES_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_AES_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_AES_CBC_ENCRYPT_DATA_PARAMS_PTR; + +/* CK_SKIPJACK_PRIVATE_WRAP_PARAMS provides the parameters to the + * CKM_SKIPJACK_PRIVATE_WRAP mechanism + */ +typedef struct CK_SKIPJACK_PRIVATE_WRAP_PARAMS { + CK_ULONG ulPasswordLen; + CK_BYTE_PTR pPassword; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPAndGLen; + CK_ULONG ulQLen; + CK_ULONG ulRandomLen; + CK_BYTE_PTR pRandomA; + CK_BYTE_PTR pPrimeP; + CK_BYTE_PTR pBaseG; + CK_BYTE_PTR pSubprimeQ; +} CK_SKIPJACK_PRIVATE_WRAP_PARAMS; + +typedef CK_SKIPJACK_PRIVATE_WRAP_PARAMS CK_PTR \ + CK_SKIPJACK_PRIVATE_WRAP_PARAMS_PTR; + + +/* CK_SKIPJACK_RELAYX_PARAMS provides the parameters to the + * CKM_SKIPJACK_RELAYX mechanism + */ +typedef struct CK_SKIPJACK_RELAYX_PARAMS { + CK_ULONG ulOldWrappedXLen; + CK_BYTE_PTR pOldWrappedX; + CK_ULONG ulOldPasswordLen; + CK_BYTE_PTR pOldPassword; + CK_ULONG ulOldPublicDataLen; + CK_BYTE_PTR pOldPublicData; + CK_ULONG ulOldRandomLen; + CK_BYTE_PTR pOldRandomA; + CK_ULONG ulNewPasswordLen; + CK_BYTE_PTR pNewPassword; + CK_ULONG ulNewPublicDataLen; + CK_BYTE_PTR pNewPublicData; + CK_ULONG ulNewRandomLen; + CK_BYTE_PTR pNewRandomA; +} CK_SKIPJACK_RELAYX_PARAMS; + +typedef CK_SKIPJACK_RELAYX_PARAMS CK_PTR \ + CK_SKIPJACK_RELAYX_PARAMS_PTR; + + +typedef struct CK_PBE_PARAMS { + CK_BYTE_PTR pInitVector; + CK_UTF8CHAR_PTR pPassword; + CK_ULONG ulPasswordLen; + CK_BYTE_PTR pSalt; + CK_ULONG ulSaltLen; + CK_ULONG ulIteration; +} CK_PBE_PARAMS; + +typedef CK_PBE_PARAMS CK_PTR CK_PBE_PARAMS_PTR; + + +/* CK_KEY_WRAP_SET_OAEP_PARAMS provides the parameters to the + * CKM_KEY_WRAP_SET_OAEP mechanism + */ +typedef struct CK_KEY_WRAP_SET_OAEP_PARAMS { + CK_BYTE bBC; /* block contents byte */ + CK_BYTE_PTR pX; /* extra data */ + CK_ULONG ulXLen; /* length of extra data in bytes */ +} CK_KEY_WRAP_SET_OAEP_PARAMS; + +typedef CK_KEY_WRAP_SET_OAEP_PARAMS CK_PTR CK_KEY_WRAP_SET_OAEP_PARAMS_PTR; + +typedef struct CK_SSL3_RANDOM_DATA { + CK_BYTE_PTR pClientRandom; + CK_ULONG ulClientRandomLen; + CK_BYTE_PTR pServerRandom; + CK_ULONG ulServerRandomLen; +} CK_SSL3_RANDOM_DATA; + + +typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS { + CK_SSL3_RANDOM_DATA RandomInfo; + CK_VERSION_PTR pVersion; +} CK_SSL3_MASTER_KEY_DERIVE_PARAMS; + +typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS CK_PTR \ + CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR; + +typedef struct CK_SSL3_KEY_MAT_OUT { + CK_OBJECT_HANDLE hClientMacSecret; + CK_OBJECT_HANDLE hServerMacSecret; + CK_OBJECT_HANDLE hClientKey; + CK_OBJECT_HANDLE hServerKey; + CK_BYTE_PTR pIVClient; + CK_BYTE_PTR pIVServer; +} CK_SSL3_KEY_MAT_OUT; + +typedef CK_SSL3_KEY_MAT_OUT CK_PTR CK_SSL3_KEY_MAT_OUT_PTR; + + +typedef struct CK_SSL3_KEY_MAT_PARAMS { + CK_ULONG ulMacSizeInBits; + CK_ULONG ulKeySizeInBits; + CK_ULONG ulIVSizeInBits; + CK_BBOOL bIsExport; + CK_SSL3_RANDOM_DATA RandomInfo; + CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; +} CK_SSL3_KEY_MAT_PARAMS; + +typedef CK_SSL3_KEY_MAT_PARAMS CK_PTR CK_SSL3_KEY_MAT_PARAMS_PTR; + +typedef struct CK_TLS_PRF_PARAMS { + CK_BYTE_PTR pSeed; + CK_ULONG ulSeedLen; + CK_BYTE_PTR pLabel; + CK_ULONG ulLabelLen; + CK_BYTE_PTR pOutput; + CK_ULONG_PTR pulOutputLen; +} CK_TLS_PRF_PARAMS; + +typedef CK_TLS_PRF_PARAMS CK_PTR CK_TLS_PRF_PARAMS_PTR; + +typedef struct CK_WTLS_RANDOM_DATA { + CK_BYTE_PTR pClientRandom; + CK_ULONG ulClientRandomLen; + CK_BYTE_PTR pServerRandom; + CK_ULONG ulServerRandomLen; +} CK_WTLS_RANDOM_DATA; + +typedef CK_WTLS_RANDOM_DATA CK_PTR CK_WTLS_RANDOM_DATA_PTR; + +typedef struct CK_WTLS_MASTER_KEY_DERIVE_PARAMS { + CK_MECHANISM_TYPE DigestMechanism; + CK_WTLS_RANDOM_DATA RandomInfo; + CK_BYTE_PTR pVersion; +} CK_WTLS_MASTER_KEY_DERIVE_PARAMS; + +typedef CK_WTLS_MASTER_KEY_DERIVE_PARAMS CK_PTR \ + CK_WTLS_MASTER_KEY_DERIVE_PARAMS_PTR; + +typedef struct CK_WTLS_PRF_PARAMS { + CK_MECHANISM_TYPE DigestMechanism; + CK_BYTE_PTR pSeed; + CK_ULONG ulSeedLen; + CK_BYTE_PTR pLabel; + CK_ULONG ulLabelLen; + CK_BYTE_PTR pOutput; + CK_ULONG_PTR pulOutputLen; +} CK_WTLS_PRF_PARAMS; + +typedef CK_WTLS_PRF_PARAMS CK_PTR CK_WTLS_PRF_PARAMS_PTR; + +typedef struct CK_WTLS_KEY_MAT_OUT { + CK_OBJECT_HANDLE hMacSecret; + CK_OBJECT_HANDLE hKey; + CK_BYTE_PTR pIV; +} CK_WTLS_KEY_MAT_OUT; + +typedef CK_WTLS_KEY_MAT_OUT CK_PTR CK_WTLS_KEY_MAT_OUT_PTR; + +typedef struct CK_WTLS_KEY_MAT_PARAMS { + CK_MECHANISM_TYPE DigestMechanism; + CK_ULONG ulMacSizeInBits; + CK_ULONG ulKeySizeInBits; + CK_ULONG ulIVSizeInBits; + CK_ULONG ulSequenceNumber; + CK_BBOOL bIsExport; + CK_WTLS_RANDOM_DATA RandomInfo; + CK_WTLS_KEY_MAT_OUT_PTR pReturnedKeyMaterial; +} CK_WTLS_KEY_MAT_PARAMS; + +typedef CK_WTLS_KEY_MAT_PARAMS CK_PTR CK_WTLS_KEY_MAT_PARAMS_PTR; + +typedef struct CK_CMS_SIG_PARAMS { + CK_OBJECT_HANDLE certificateHandle; + CK_MECHANISM_PTR pSigningMechanism; + CK_MECHANISM_PTR pDigestMechanism; + CK_UTF8CHAR_PTR pContentType; + CK_BYTE_PTR pRequestedAttributes; + CK_ULONG ulRequestedAttributesLen; + CK_BYTE_PTR pRequiredAttributes; + CK_ULONG ulRequiredAttributesLen; +} CK_CMS_SIG_PARAMS; + +typedef CK_CMS_SIG_PARAMS CK_PTR CK_CMS_SIG_PARAMS_PTR; + +typedef struct CK_KEY_DERIVATION_STRING_DATA { + CK_BYTE_PTR pData; + CK_ULONG ulLen; +} CK_KEY_DERIVATION_STRING_DATA; + +typedef CK_KEY_DERIVATION_STRING_DATA CK_PTR \ + CK_KEY_DERIVATION_STRING_DATA_PTR; + + +/* The CK_EXTRACT_PARAMS is used for the + * CKM_EXTRACT_KEY_FROM_KEY mechanism. It specifies which bit + * of the base key should be used as the first bit of the + * derived key + */ +typedef CK_ULONG CK_EXTRACT_PARAMS; + +typedef CK_EXTRACT_PARAMS CK_PTR CK_EXTRACT_PARAMS_PTR; + +/* CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is used to + * indicate the Pseudo-Random Function (PRF) used to generate + * key bits using PKCS #5 PBKDF2. + */ +typedef CK_ULONG CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE; + +typedef CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE CK_PTR \ + CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE_PTR; + +#define CKP_PKCS5_PBKD2_HMAC_SHA1 0x00000001UL +#define CKP_PKCS5_PBKD2_HMAC_GOSTR3411 0x00000002UL +#define CKP_PKCS5_PBKD2_HMAC_SHA224 0x00000003UL +#define CKP_PKCS5_PBKD2_HMAC_SHA256 0x00000004UL +#define CKP_PKCS5_PBKD2_HMAC_SHA384 0x00000005UL +#define CKP_PKCS5_PBKD2_HMAC_SHA512 0x00000006UL +#define CKP_PKCS5_PBKD2_HMAC_SHA512_224 0x00000007UL +#define CKP_PKCS5_PBKD2_HMAC_SHA512_256 0x00000008UL + +/* CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is used to indicate the + * source of the salt value when deriving a key using PKCS #5 + * PBKDF2. + */ +typedef CK_ULONG CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE; + +typedef CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE CK_PTR \ + CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE_PTR; + +/* The following salt value sources are defined in PKCS #5 v2.0. */ +#define CKZ_SALT_SPECIFIED 0x00000001UL + +/* CK_PKCS5_PBKD2_PARAMS is a structure that provides the + * parameters to the CKM_PKCS5_PBKD2 mechanism. + */ +typedef struct CK_PKCS5_PBKD2_PARAMS { + CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE saltSource; + CK_VOID_PTR pSaltSourceData; + CK_ULONG ulSaltSourceDataLen; + CK_ULONG iterations; + CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf; + CK_VOID_PTR pPrfData; + CK_ULONG ulPrfDataLen; + CK_UTF8CHAR_PTR pPassword; + CK_ULONG_PTR ulPasswordLen; +} CK_PKCS5_PBKD2_PARAMS; + +typedef CK_PKCS5_PBKD2_PARAMS CK_PTR CK_PKCS5_PBKD2_PARAMS_PTR; + +/* CK_PKCS5_PBKD2_PARAMS2 is a corrected version of the CK_PKCS5_PBKD2_PARAMS + * structure that provides the parameters to the CKM_PKCS5_PBKD2 mechanism + * noting that the ulPasswordLen field is a CK_ULONG and not a CK_ULONG_PTR. + */ +typedef struct CK_PKCS5_PBKD2_PARAMS2 { + CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE saltSource; + CK_VOID_PTR pSaltSourceData; + CK_ULONG ulSaltSourceDataLen; + CK_ULONG iterations; + CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf; + CK_VOID_PTR pPrfData; + CK_ULONG ulPrfDataLen; + CK_UTF8CHAR_PTR pPassword; + CK_ULONG ulPasswordLen; +} CK_PKCS5_PBKD2_PARAMS2; + +typedef CK_PKCS5_PBKD2_PARAMS2 CK_PTR CK_PKCS5_PBKD2_PARAMS2_PTR; + +typedef CK_ULONG CK_OTP_PARAM_TYPE; +typedef CK_OTP_PARAM_TYPE CK_PARAM_TYPE; /* backward compatibility */ + +typedef struct CK_OTP_PARAM { + CK_OTP_PARAM_TYPE type; + CK_VOID_PTR pValue; + CK_ULONG ulValueLen; +} CK_OTP_PARAM; + +typedef CK_OTP_PARAM CK_PTR CK_OTP_PARAM_PTR; + +typedef struct CK_OTP_PARAMS { + CK_OTP_PARAM_PTR pParams; + CK_ULONG ulCount; +} CK_OTP_PARAMS; + +typedef CK_OTP_PARAMS CK_PTR CK_OTP_PARAMS_PTR; + +typedef struct CK_OTP_SIGNATURE_INFO { + CK_OTP_PARAM_PTR pParams; + CK_ULONG ulCount; +} CK_OTP_SIGNATURE_INFO; + +typedef CK_OTP_SIGNATURE_INFO CK_PTR CK_OTP_SIGNATURE_INFO_PTR; + +#define CK_OTP_VALUE 0UL +#define CK_OTP_PIN 1UL +#define CK_OTP_CHALLENGE 2UL +#define CK_OTP_TIME 3UL +#define CK_OTP_COUNTER 4UL +#define CK_OTP_FLAGS 5UL +#define CK_OTP_OUTPUT_LENGTH 6UL +#define CK_OTP_OUTPUT_FORMAT 7UL + +#define CKF_NEXT_OTP 0x00000001UL +#define CKF_EXCLUDE_TIME 0x00000002UL +#define CKF_EXCLUDE_COUNTER 0x00000004UL +#define CKF_EXCLUDE_CHALLENGE 0x00000008UL +#define CKF_EXCLUDE_PIN 0x00000010UL +#define CKF_USER_FRIENDLY_OTP 0x00000020UL + +typedef struct CK_KIP_PARAMS { + CK_MECHANISM_PTR pMechanism; + CK_OBJECT_HANDLE hKey; + CK_BYTE_PTR pSeed; + CK_ULONG ulSeedLen; +} CK_KIP_PARAMS; + +typedef CK_KIP_PARAMS CK_PTR CK_KIP_PARAMS_PTR; + +typedef struct CK_AES_CTR_PARAMS { + CK_ULONG ulCounterBits; + CK_BYTE cb[16]; +} CK_AES_CTR_PARAMS; + +typedef CK_AES_CTR_PARAMS CK_PTR CK_AES_CTR_PARAMS_PTR; + +typedef struct CK_GCM_PARAMS { + CK_BYTE_PTR pIv; + CK_ULONG ulIvLen; + CK_ULONG ulIvBits; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulTagBits; +} CK_GCM_PARAMS; + +typedef CK_GCM_PARAMS CK_PTR CK_GCM_PARAMS_PTR; + +typedef struct CK_CCM_PARAMS { + CK_ULONG ulDataLen; + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceLen; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulMACLen; +} CK_CCM_PARAMS; + +typedef CK_CCM_PARAMS CK_PTR CK_CCM_PARAMS_PTR; + +/* + * These conflict w/ definitions in usr/src/crypto/common and are deprecated, + * so we will require clients to explicitly request their use. + */ +#ifdef PKCS11_DEPRECATED_PARAMS +/* Deprecated. Use CK_GCM_PARAMS */ +typedef struct CK_AES_GCM_PARAMS { + CK_BYTE_PTR pIv; + CK_ULONG ulIvLen; + CK_ULONG ulIvBits; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulTagBits; +} CK_AES_GCM_PARAMS; + +typedef CK_AES_GCM_PARAMS CK_PTR CK_AES_GCM_PARAMS_PTR; + +/* Deprecated. Use CK_CCM_PARAMS */ +typedef struct CK_AES_CCM_PARAMS { + CK_ULONG ulDataLen; + CK_BYTE_PTR pNonce; + CK_ULONG ulNonceLen; + CK_BYTE_PTR pAAD; + CK_ULONG ulAADLen; + CK_ULONG ulMACLen; +} CK_AES_CCM_PARAMS; + +typedef CK_AES_CCM_PARAMS CK_PTR CK_AES_CCM_PARAMS_PTR; +#endif + +typedef struct CK_CAMELLIA_CTR_PARAMS { + CK_ULONG ulCounterBits; + CK_BYTE cb[16]; +} CK_CAMELLIA_CTR_PARAMS; + +typedef CK_CAMELLIA_CTR_PARAMS CK_PTR CK_CAMELLIA_CTR_PARAMS_PTR; + +typedef struct CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[16]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS CK_PTR \ + CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS_PTR; + +typedef struct CK_ARIA_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[16]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_ARIA_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_ARIA_CBC_ENCRYPT_DATA_PARAMS CK_PTR \ + CK_ARIA_CBC_ENCRYPT_DATA_PARAMS_PTR; + +typedef struct CK_DSA_PARAMETER_GEN_PARAM { + CK_MECHANISM_TYPE hash; + CK_BYTE_PTR pSeed; + CK_ULONG ulSeedLen; + CK_ULONG ulIndex; +} CK_DSA_PARAMETER_GEN_PARAM; + +typedef CK_DSA_PARAMETER_GEN_PARAM CK_PTR CK_DSA_PARAMETER_GEN_PARAM_PTR; + +typedef struct CK_ECDH_AES_KEY_WRAP_PARAMS { + CK_ULONG ulAESKeyBits; + CK_EC_KDF_TYPE kdf; + CK_ULONG ulSharedDataLen; + CK_BYTE_PTR pSharedData; +} CK_ECDH_AES_KEY_WRAP_PARAMS; + +typedef CK_ECDH_AES_KEY_WRAP_PARAMS CK_PTR CK_ECDH_AES_KEY_WRAP_PARAMS_PTR; + +typedef CK_ULONG CK_JAVA_MIDP_SECURITY_DOMAIN; + +typedef CK_ULONG CK_CERTIFICATE_CATEGORY; + +typedef struct CK_RSA_AES_KEY_WRAP_PARAMS { + CK_ULONG ulAESKeyBits; + CK_RSA_PKCS_OAEP_PARAMS_PTR pOAEPParams; +} CK_RSA_AES_KEY_WRAP_PARAMS; + +typedef CK_RSA_AES_KEY_WRAP_PARAMS CK_PTR CK_RSA_AES_KEY_WRAP_PARAMS_PTR; + +typedef struct CK_TLS12_MASTER_KEY_DERIVE_PARAMS { + CK_SSL3_RANDOM_DATA RandomInfo; + CK_VERSION_PTR pVersion; + CK_MECHANISM_TYPE prfHashMechanism; +} CK_TLS12_MASTER_KEY_DERIVE_PARAMS; + +typedef CK_TLS12_MASTER_KEY_DERIVE_PARAMS CK_PTR \ + CK_TLS12_MASTER_KEY_DERIVE_PARAMS_PTR; + +typedef struct CK_TLS12_KEY_MAT_PARAMS { + CK_ULONG ulMacSizeInBits; + CK_ULONG ulKeySizeInBits; + CK_ULONG ulIVSizeInBits; + CK_BBOOL bIsExport; + CK_SSL3_RANDOM_DATA RandomInfo; + CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; + CK_MECHANISM_TYPE prfHashMechanism; +} CK_TLS12_KEY_MAT_PARAMS; + +typedef CK_TLS12_KEY_MAT_PARAMS CK_PTR CK_TLS12_KEY_MAT_PARAMS_PTR; + +typedef struct CK_TLS_KDF_PARAMS { + CK_MECHANISM_TYPE prfMechanism; + CK_BYTE_PTR pLabel; + CK_ULONG ulLabelLength; + CK_SSL3_RANDOM_DATA RandomInfo; + CK_BYTE_PTR pContextData; + CK_ULONG ulContextDataLength; +} CK_TLS_KDF_PARAMS; + +typedef CK_TLS_KDF_PARAMS CK_PTR CK_TLS_KDF_PARAMS_PTR; + +typedef struct CK_TLS_MAC_PARAMS { + CK_MECHANISM_TYPE prfHashMechanism; + CK_ULONG ulMacLength; + CK_ULONG ulServerOrClient; +} CK_TLS_MAC_PARAMS; + +typedef CK_TLS_MAC_PARAMS CK_PTR CK_TLS_MAC_PARAMS_PTR; + +typedef struct CK_GOSTR3410_DERIVE_PARAMS { + CK_EC_KDF_TYPE kdf; + CK_BYTE_PTR pPublicData; + CK_ULONG ulPublicDataLen; + CK_BYTE_PTR pUKM; + CK_ULONG ulUKMLen; +} CK_GOSTR3410_DERIVE_PARAMS; + +typedef CK_GOSTR3410_DERIVE_PARAMS CK_PTR CK_GOSTR3410_DERIVE_PARAMS_PTR; + +typedef struct CK_GOSTR3410_KEY_WRAP_PARAMS { + CK_BYTE_PTR pWrapOID; + CK_ULONG ulWrapOIDLen; + CK_BYTE_PTR pUKM; + CK_ULONG ulUKMLen; + CK_OBJECT_HANDLE hKey; +} CK_GOSTR3410_KEY_WRAP_PARAMS; + +typedef CK_GOSTR3410_KEY_WRAP_PARAMS CK_PTR CK_GOSTR3410_KEY_WRAP_PARAMS_PTR; + +typedef struct CK_SEED_CBC_ENCRYPT_DATA_PARAMS { + CK_BYTE iv[16]; + CK_BYTE_PTR pData; + CK_ULONG length; +} CK_SEED_CBC_ENCRYPT_DATA_PARAMS; + +typedef CK_SEED_CBC_ENCRYPT_DATA_PARAMS CK_PTR \ + CK_SEED_CBC_ENCRYPT_DATA_PARAMS_PTR; + +#endif /* _PKCS11T_H_ */ + diff --git a/illumos-x86_64/usr/include/semaphore.h b/illumos-x86_64/usr/include/semaphore.h new file mode 100644 index 00000000..300de7be --- /dev/null +++ b/illumos-x86_64/usr/include/semaphore.h @@ -0,0 +1,98 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SEMAPHORE_H +#define _SEMAPHORE_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Including has an unfortunate XPG/POSIX history. In XPG6 and POSIX + * 1999, sem_timedwait() was added which required making the struct timespec + * declared in some form. In XPG7, this is permitted to make all of time.h + * visible. In XPG8, the use of the clockid_t is required from time.h. For + * better and worse, that is how the ifdef soup is here. We prefer including + * time.h so that folks can get a full definition for the time struct timespec + * rather than the forward declaration that most other OSes do here. + */ +#if !defined(_STRICT_POSIX) || defined(_XPG7) +#include +#elif defined(_XPG6) +struct timespec; +#endif + +typedef struct { + /* this structure must be the same as sema_t in */ + uint32_t sem_count; /* semaphore count */ + uint16_t sem_type; + uint16_t sem_magic; + upad64_t sem_pad1[3]; /* reserved for a mutex_t */ + upad64_t sem_pad2[2]; /* reserved for a cond_t */ +} sem_t; + +#define SEM_FAILED ((sem_t *)(-1)) + +/* + * function prototypes + */ +int sem_init(sem_t *, int, unsigned int); +int sem_destroy(sem_t *); +sem_t *sem_open(const char *, int, ...); +int sem_close(sem_t *); +int sem_unlink(const char *); +int sem_wait(sem_t *); + +#if !defined(_STRICT_POSIX) || defined(_XPG6) +int sem_timedwait(sem_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +int sem_reltimedwait_np(sem_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +#endif /* !_STRICT_POSIX || _XPG6 */ + +#if !defined(_STRICT_POSIX) || defined(_XPG8) +int sem_clockwait(sem_t *_RESTRICT_KYWD, clockid_t, + const struct timespec *_RESTRICT_KYWD); +int sem_relclockwait_np(sem_t *_RESTRICT_KYWD, clockid_t, + const struct timespec *_RESTRICT_KYWD); +#endif /* !_STRICT_POSIX || _XPG8 */ +int sem_trywait(sem_t *); +int sem_post(sem_t *); +int sem_getvalue(sem_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); + +#ifdef __cplusplus +} +#endif + +#endif /* _SEMAPHORE_H */ diff --git a/illumos-x86_64/usr/include/setjmp.h b/illumos-x86_64/usr/include/setjmp.h new file mode 100644 index 00000000..08de6b0b --- /dev/null +++ b/illumos-x86_64/usr/include/setjmp.h @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SETJMP_H +#define _SETJMP_H + +#include + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::jmp_buf; +using std::longjmp; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX) || \ + defined(__EXTENSIONS__) +/* non-ANSI standard compilation */ + +#if defined(_LP64) +typedef long sigjmp_buf[_SIGJBLEN]; +#else +typedef int sigjmp_buf[_SIGJBLEN]; +#endif + +extern int sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE; +#pragma unknown_control_flow(sigsetjmp) +extern void siglongjmp(sigjmp_buf, int) __NORETURN; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SETJMP_H */ diff --git a/illumos-x86_64/usr/include/sframe-api.h b/illumos-x86_64/usr/include/sframe-api.h new file mode 100644 index 00000000..8c26257f --- /dev/null +++ b/illumos-x86_64/usr/include/sframe-api.h @@ -0,0 +1,314 @@ +/* Public API to SFrame. + + Copyright (C) 2022-2025 Free Software Foundation, Inc. + + This file is part of libsframe. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _SFRAME_API_H +#define _SFRAME_API_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct sframe_decoder_ctx sframe_decoder_ctx; +typedef struct sframe_encoder_ctx sframe_encoder_ctx; + +#define MAX_NUM_STACK_OFFSETS 3 + +#define MAX_OFFSET_BYTES \ + ((SFRAME_FRE_OFFSET_4B * 2 * MAX_NUM_STACK_OFFSETS)) + +/* User interfacing SFrame Row Entry. + An abstraction provided by libsframe so the consumer is decoupled from + the binary format representation of the same. + + The members are best ordered such that they are aligned at their natural + boundaries. This helps avoid usage of undesirable misaligned memory + accesses. See PR libsframe/29856. */ + +typedef struct sframe_frame_row_entry +{ + uint32_t fre_start_addr; + unsigned char fre_offsets[MAX_OFFSET_BYTES]; + unsigned char fre_info; +} sframe_frame_row_entry; + +#define SFRAME_ERR ((int) -1) + +/* This macro holds information about all the available SFrame + errors. It is used to form both an enum holding all the error + constants, and also the error strings themselves. To use, define + _SFRAME_FIRST and _SFRAME_ITEM to expand as you like, then + mention the macro name. See the enum after this for an example. */ +#define _SFRAME_ERRORS \ + _SFRAME_FIRST (SFRAME_ERR_VERSION_INVAL, "SFrame version not supported.") \ + _SFRAME_ITEM (SFRAME_ERR_NOMEM, "Out of Memory.") \ + _SFRAME_ITEM (SFRAME_ERR_INVAL, "Corrupt SFrame.") \ + _SFRAME_ITEM (SFRAME_ERR_BUF_INVAL, "Buffer does not contain SFrame data.") \ + _SFRAME_ITEM (SFRAME_ERR_DCTX_INVAL, "Corrupt SFrame decoder.") \ + _SFRAME_ITEM (SFRAME_ERR_ECTX_INVAL, "Corrupt SFrame encoder.") \ + _SFRAME_ITEM (SFRAME_ERR_FDE_INVAL, "Corrput FDE.") \ + _SFRAME_ITEM (SFRAME_ERR_FRE_INVAL, "Corrupt FRE.") \ + _SFRAME_ITEM (SFRAME_ERR_FDE_NOTFOUND,"FDE not found.") \ + _SFRAME_ITEM (SFRAME_ERR_FDE_NOTSORTED, "FDEs not sorted.") \ + _SFRAME_ITEM (SFRAME_ERR_FRE_NOTFOUND,"FRE not found.") \ + _SFRAME_ITEM (SFRAME_ERR_FREOFFSET_NOPRESENT,"FRE offset not present.") + +#define SFRAME_ERR_BASE 2000 /* Base value for libsframe errnos. */ + +enum + { +#define _SFRAME_FIRST(NAME, STR) NAME = SFRAME_ERR_BASE +#define _SFRAME_ITEM(NAME, STR) , NAME +_SFRAME_ERRORS +#undef _SFRAME_ITEM +#undef _SFRAME_FIRST + }; + +/* Count of SFrame errors. */ +#define SFRAME_ERR_NERR (SFRAME_ERR_FREOFFSET_NOPRESENT - SFRAME_ERR_BASE + 1) + +/* Get the error message string. */ + +extern const char * +sframe_errmsg (int error); + +/* Create an FDE function info bye given an FRE_TYPE and an FDE_TYPE. */ + +extern unsigned char +sframe_fde_create_func_info (uint32_t fre_type, uint32_t fde_type); + +/* Gather the FRE type given the function size. */ + +extern uint32_t +sframe_calc_fre_type (size_t func_size); + +/* The SFrame Decoder. */ + +/* Decode the specified SFrame buffer CF_BUF of size CF_SIZE and return the + new SFrame decoder context. Sets ERRP for the caller if any error. */ +extern sframe_decoder_ctx * +sframe_decode (const char *cf_buf, size_t cf_size, int *errp); + +/* Free the decoder context. */ +extern void +sframe_decoder_free (sframe_decoder_ctx **dctx); + +/* Get the size of the SFrame header from the decoder context DCTX. */ +extern unsigned int +sframe_decoder_get_hdr_size (sframe_decoder_ctx *dctx); + +/* Get the SFrame's abi/arch info. */ +extern uint8_t +sframe_decoder_get_abi_arch (sframe_decoder_ctx *dctx); + +/* Get the format version from the SFrame decoder context DCTX. */ +extern uint8_t +sframe_decoder_get_version (sframe_decoder_ctx *dctx); + +/* Get the section flags from the SFrame decoder context DCTX. */ +extern uint8_t +sframe_decoder_get_flags (sframe_decoder_ctx *dctx); + +/* Get the offset of the sfde_func_start_address field (from the start of the + on-disk layout of the SFrame section) of the FDE at FUNC_IDX in the decoder + context DCTX. + + If FUNC_IDX is more than the number of SFrame FDEs in the section, sets + error code in ERRP, but returns the (hypothetical) offset. This is useful + for the linker when arranging input FDEs into the output section to be + emitted. */ +uint32_t +sframe_decoder_get_offsetof_fde_start_addr (sframe_decoder_ctx *dctx, + uint32_t func_idx, int *errp); + +/* Return the number of function descriptor entries in the SFrame decoder + DCTX. */ +extern uint32_t +sframe_decoder_get_num_fidx (sframe_decoder_ctx *dctx); + +/* Get the fixed FP offset from the decoder context DCTX. */ +extern int8_t +sframe_decoder_get_fixed_fp_offset (sframe_decoder_ctx *dctx); + +/* Get the fixed RA offset from the decoder context DCTX. */ +extern int8_t +sframe_decoder_get_fixed_ra_offset (sframe_decoder_ctx *dctx); + +/* Find the SFrame Frame Row Entry which contains the PC. Returns + SFRAME_ERR if failure. */ + +extern int +sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc, + sframe_frame_row_entry *frep); + +/* Get the FRE_IDX'th FRE of the function at FUNC_IDX'th function + index entry in the SFrame decoder CTX. Returns error code as + applicable. */ +extern int +sframe_decoder_get_fre (sframe_decoder_ctx *ctx, + unsigned int func_idx, + unsigned int fre_idx, + sframe_frame_row_entry *fre); + +/* Get the data (NUM_FRES, FUNC_START_ADDRESS) from the function + descriptor entry at index I'th in the decoder CTX. If failed, + return error code. */ +extern int +sframe_decoder_get_funcdesc (sframe_decoder_ctx *ctx, + unsigned int i, + uint32_t *num_fres, + uint32_t *func_size, + int32_t *func_start_address, + unsigned char *func_info); + +/* Get the data (NUM_FRES, FUNC_SIZE, FUNC_START_ADDRESS, FUNC_INFO, + REP_BLOCK_SIZE) from the function descriptor entry at index I'th + in the decoder CTX. If failed, return error code. + This API is only available from SFRAME_VERSION_2. */ +extern int +sframe_decoder_get_funcdesc_v2 (sframe_decoder_ctx *ctx, + unsigned int i, + uint32_t *num_fres, + uint32_t *func_size, + int32_t *func_start_address, + unsigned char *func_info, + uint8_t *rep_block_size); + +/* SFrame textual dump. */ +extern void +dump_sframe (sframe_decoder_ctx *decoder, uint64_t addr); + +/* Get the base reg id from the FRE info. Sets errp if fails. */ +extern uint8_t +sframe_fre_get_base_reg_id (sframe_frame_row_entry *fre, int *errp); + +/* Get the CFA offset from the FRE. If the offset is invalid, sets errp. */ +extern int32_t +sframe_fre_get_cfa_offset (sframe_decoder_ctx *dtcx, + sframe_frame_row_entry *fre, int *errp); + +/* Get the FP offset from the FRE. If the offset is invalid, sets errp. + + For s390x the offset may be an encoded register number, indicated by + LSB set to one, which is only valid in the topmost frame. */ +extern int32_t +sframe_fre_get_fp_offset (sframe_decoder_ctx *dctx, + sframe_frame_row_entry *fre, int *errp); + +/* Get the RA offset from the FRE. If the offset is invalid, sets errp. + + For s390x an RA offset value of SFRAME_FRE_RA_OFFSET_INVALID indicates + that the RA is not saved, which is only valid in the topmost frame. + For s390x the offset may be an encoded register number, indicated by + LSB set to one, which is only valid in the topmost frame. */ +extern int32_t +sframe_fre_get_ra_offset (sframe_decoder_ctx *dctx, + sframe_frame_row_entry *fre, int *errp); + +/* Get whether the RA is mangled. */ + +extern bool +sframe_fre_get_ra_mangled_p (sframe_decoder_ctx *dctx, + sframe_frame_row_entry *fre, int *errp); + +/* The SFrame Encoder. */ + +/* Create an encoder context with the given SFrame format version VER, FLAGS + and ABI information. Sets errp if failure. */ +extern sframe_encoder_ctx * +sframe_encode (uint8_t ver, uint8_t flags, uint8_t abi_arch, + int8_t fixed_fp_offset, int8_t fixed_ra_offset, int *errp); + +/* Free the encoder context. */ +extern void +sframe_encoder_free (sframe_encoder_ctx **encoder); + +/* Get the size of the SFrame header from the encoder ctx ENCODER. */ +extern unsigned int +sframe_encoder_get_hdr_size (sframe_encoder_ctx *encoder); + +/* Get the abi/arch info from the SFrame encoder context CTX. */ +extern uint8_t +sframe_encoder_get_abi_arch (sframe_encoder_ctx *encoder); + +/* Get the format version from the SFrame encoder context ENCODER. */ +extern uint8_t +sframe_encoder_get_version (sframe_encoder_ctx *encoder); + +/* Get the section flags from the SFrame encoder context ENCODER. */ +extern uint8_t +sframe_encoder_get_flags (sframe_encoder_ctx *encoder); + +/* Get the offset of the sfde_func_start_address field (from the start of the + on-disk layout of the SFrame section) of the FDE at FUNC_IDX in the encoder + context ENCODER. + + If FUNC_IDX is more than the number of SFrame FDEs in the section, sets + error code in ERRP, but returns the (hypothetical) offset. This is useful + for the linker when arranging input FDEs into the output section to be + emitted. */ +uint32_t +sframe_encoder_get_offsetof_fde_start_addr (sframe_encoder_ctx *encoder, + uint32_t func_idx, int *errp); + +/* Return the number of function descriptor entries in the SFrame encoder + ENCODER. */ +extern uint32_t +sframe_encoder_get_num_fidx (sframe_encoder_ctx *encoder); + +/* Add an FRE to function at FUNC_IDX'th function descriptor index entry in + the encoder context. */ +extern int +sframe_encoder_add_fre (sframe_encoder_ctx *encoder, + unsigned int func_idx, + sframe_frame_row_entry *frep); + +/* Add a new function descriptor entry with START_ADDR, FUNC_SIZE and NUM_FRES + to the encoder. */ +extern int +sframe_encoder_add_funcdesc (sframe_encoder_ctx *encoder, + int32_t start_addr, + uint32_t func_size, + unsigned char func_info, + uint32_t num_fres); + +/* Add a new function descriptor entry with START_ADDR, FUNC_SIZE, FUNC_INFO + and REP_BLOCK_SIZE to the encoder. */ +extern int +sframe_encoder_add_funcdesc_v2 (sframe_encoder_ctx *encoder, + int32_t start_addr, + uint32_t func_size, + unsigned char func_info, + uint8_t rep_block_size, + uint32_t num_fres); + +/* Serialize the contents of the encoder and return the buffer. ENCODED_SIZE + is updated to the size of the buffer. Sets ERRP if failure. */ +extern char * +sframe_encoder_write (sframe_encoder_ctx *encoder, + size_t *encoded_size, int *errp); + +#ifdef __cplusplus +} +#endif + +#endif /* _SFRAME_API_H */ diff --git a/illumos-x86_64/usr/include/sframe.h b/illumos-x86_64/usr/include/sframe.h new file mode 100644 index 00000000..7523adbe --- /dev/null +++ b/illumos-x86_64/usr/include/sframe.h @@ -0,0 +1,413 @@ +/* SFrame format description. + Copyright (C) 2022-2025 Free Software Foundation, Inc. + + This file is part of libsframe. + + libsframe is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not see + . */ + +#ifndef _SFRAME_H +#define _SFRAME_H + +#include +#include +#include + +#include "ansidecl.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* SFrame format. + + SFrame format is a simple format to represent the information needed + for generating vanilla backtraces. SFrame format keeps track of the + minimal necessary information needed for stack tracing: + - Canonical Frame Address (CFA) + - Frame Pointer (FP) + - Return Address (RA) + + The SFrame section itself has the following structure: + + +--------+------------+---------+ + | file | function | frame | + | header | descriptor | row | + | | entries | entries | + +--------+------------+---------+ + + The file header stores a magic number and version information, flags, and + the byte offset of each of the sections relative to the end of the header + itself. The file header also specifies the total number of Function + Descriptor Entries, Frame Row Entries and length of the FRE sub-section. + + Following the header is a list of Function Descriptor Entries (FDEs). + This list may be sorted if the flags in the file header indicate it to be + so. The sort order, if applicable, is the order of functions in the + .text.* sections in the resulting binary artifact. Each Function + Descriptor Entry specifies the start PC of a function, the size in bytes + of the function and an offset to its first Frame Row Entry (FRE). Each FDE + additionally also specifies the type of FRE it uses to encode the stack + trace information. + + Next, the SFrame Frame Row Entry sub-section is a list of variable size + records. Each entry represents stack trace information for a set of PCs + of the function. A singular Frame Row Entry is a self-sufficient record + which contains information on how to generate stack trace from the + applicable set of PCs. + + */ + + +/* SFrame format versions. */ +#define SFRAME_VERSION_1 1 +#define SFRAME_VERSION_2 2 +/* SFrame magic number. */ +#define SFRAME_MAGIC 0xdee2 +/* Current version of SFrame format. */ +#define SFRAME_VERSION SFRAME_VERSION_2 + +/* Various flags for SFrame. */ + +/* Function Descriptor Entries are sorted on PC. */ +#define SFRAME_F_FDE_SORTED 0x1 +/* Functions preserve frame pointer. */ +#define SFRAME_F_FRAME_POINTER 0x2 +/* Function start address in SFrame FDE is encoded as the distance from the + location of the sfde_func_start_address to the start PC of the function. + If absent, the function start address in SFrame FDE is encoded as the + distance from the start of the SFrame FDE section to the start PC of the + function. */ +#define SFRAME_F_FDE_FUNC_START_PCREL 0x4 + +/* Set of all defined flags in SFrame V2. */ +#define SFRAME_V2_F_ALL_FLAGS \ + (SFRAME_F_FDE_SORTED | SFRAME_F_FRAME_POINTER \ + | SFRAME_F_FDE_FUNC_START_PCREL) + +#define SFRAME_CFA_FIXED_FP_INVALID 0 +#define SFRAME_CFA_FIXED_RA_INVALID 0 + +/* Supported ABIs/Arch. */ +#define SFRAME_ABI_AARCH64_ENDIAN_BIG 1 /* AARCH64 big endian. */ +#define SFRAME_ABI_AARCH64_ENDIAN_LITTLE 2 /* AARCH64 little endian. */ +#define SFRAME_ABI_AMD64_ENDIAN_LITTLE 3 /* AMD64 little endian. */ +#define SFRAME_ABI_S390X_ENDIAN_BIG 4 /* s390x big endian. */ + +/* SFrame FRE types. */ +#define SFRAME_FRE_TYPE_ADDR1 0 +#define SFRAME_FRE_TYPE_ADDR2 1 +#define SFRAME_FRE_TYPE_ADDR4 2 + +/* SFrame Function Descriptor Entry types. + + The SFrame format has two possible representations for functions. The + choice of which type to use is made according to the instruction patterns + in the relevant program stub. + + An SFrame FDE of type SFRAME_FDE_TYPE_PCINC is an indication + that the PCs in the FREs should be treated as increments in bytes. This is + used for a bulk of the executable code of a program, which contains + instructions with no specific pattern. + + An SFrame FDE of type SFRAME_FDE_TYPE_PCMASK is an indication + that the PCs in the FREs should be treated as masks. This type is useful + for the cases when a small pattern of instructions in a program stub is + repeatedly to cover a specific functionality. Typical usescases are pltN + entries, trampolines etc. */ + +/* Unwinders perform a (PC >= FRE_START_ADDR) to look up a matching FRE. */ +#define SFRAME_FDE_TYPE_PCINC 0 +/* Unwinders perform a (PC % REP_BLOCK_SIZE >= FRE_START_ADDR) to look up a + matching FRE. */ +#define SFRAME_FDE_TYPE_PCMASK 1 + +typedef struct sframe_preamble +{ + uint16_t sfp_magic; /* Magic number (SFRAME_MAGIC). */ + uint8_t sfp_version; /* Data format version number (SFRAME_VERSION). */ + uint8_t sfp_flags; /* Flags. */ +} ATTRIBUTE_PACKED sframe_preamble; + +typedef struct sframe_header +{ + sframe_preamble sfh_preamble; + /* Information about the arch (endianness) and ABI. */ + uint8_t sfh_abi_arch; + /* Offset for the Frame Pointer (FP) from CFA may be fixed for some + ABIs (e.g, in AMD64 when -fno-omit-frame-pointer is used). When fixed, + this field specifies the fixed stack frame offset and the individual + FREs do not need to track it. When not fixed, it is set to + SFRAME_CFA_FIXED_FP_INVALID, and the individual FREs may provide + the applicable stack frame offset, if any. */ + int8_t sfh_cfa_fixed_fp_offset; + /* Offset for the Return Address from CFA is fixed for some ABIs + (e.g., AMD64 has it as CFA-8). When fixed, the header specifies the + fixed stack frame offset and the individual FREs do not track it. When + not fixed, it is set to SFRAME_CFA_FIXED_RA_INVALID, and individual + FREs provide the applicable stack frame offset, if any. */ + int8_t sfh_cfa_fixed_ra_offset; + /* Number of bytes making up the auxiliary header, if any. + Some ABI/arch, in the future, may use this space for extending the + information in SFrame header. Auxiliary header is contained in + bytes sequentially following the sframe_header. */ + uint8_t sfh_auxhdr_len; + /* Number of SFrame FDEs in this SFrame section. */ + uint32_t sfh_num_fdes; + /* Number of SFrame Frame Row Entries. */ + uint32_t sfh_num_fres; + /* Number of bytes in the SFrame Frame Row Entry section. */ + uint32_t sfh_fre_len; + /* Offset of SFrame Function Descriptor Entry section. */ + uint32_t sfh_fdeoff; + /* Offset of SFrame Frame Row Entry section. */ + uint32_t sfh_freoff; +} ATTRIBUTE_PACKED sframe_header; + +#define SFRAME_V1_HDR_SIZE(sframe_hdr) \ + ((sizeof (sframe_header) + (sframe_hdr).sfh_auxhdr_len)) + +/* Two possible keys for executable (instruction) pointers signing. */ +#define SFRAME_AARCH64_PAUTH_KEY_A 0 /* Key A. */ +#define SFRAME_AARCH64_PAUTH_KEY_B 1 /* Key B. */ + +typedef struct sframe_func_desc_entry +{ + /* Function start address. Encoded as a signed offset, relative to the + beginning of the current FDE. */ + int32_t sfde_func_start_address; + /* Size of the function in bytes. */ + uint32_t sfde_func_size; + /* Offset of the first SFrame Frame Row Entry of the function, relative to the + beginning of the SFrame Frame Row Entry sub-section. */ + uint32_t sfde_func_start_fre_off; + /* Number of frame row entries for the function. */ + uint32_t sfde_func_num_fres; + /* Additional information for stack tracing from the function: + - 4-bits: Identify the FRE type used for the function. + - 1-bit: Identify the FDE type of the function - mask or inc. + - 1-bit: PAC authorization A/B key (aarch64). + - 2-bits: Unused. + ------------------------------------------------------------------------ + | Unused | PAC auth A/B key (aarch64) | FDE type | FRE type | + | | Unused (amd64, s390x) | | | + ------------------------------------------------------------------------ + 8 6 5 4 0 */ + uint8_t sfde_func_info; + /* Size of the block of repeating insns. Used for SFrame FDEs of type + SFRAME_FDE_TYPE_PCMASK. */ + uint8_t sfde_func_rep_size; + uint16_t sfde_func_padding2; +} ATTRIBUTE_PACKED sframe_func_desc_entry; + +/* Macros to compose and decompose function info in FDE. */ + +/* Note: Set PAC auth key to SFRAME_AARCH64_PAUTH_KEY_A by default. */ +#define SFRAME_V1_FUNC_INFO(fde_type, fre_enc_type) \ + (((SFRAME_AARCH64_PAUTH_KEY_A & 0x1) << 5) | \ + (((fde_type) & 0x1) << 4) | ((fre_enc_type) & 0xf)) + +#define SFRAME_V1_FUNC_FRE_TYPE(data) ((data) & 0xf) +#define SFRAME_V1_FUNC_FDE_TYPE(data) (((data) >> 4) & 0x1) +#define SFRAME_V1_FUNC_PAUTH_KEY(data) (((data) >> 5) & 0x1) + +/* Set the pauth key as indicated. */ +#define SFRAME_V1_FUNC_INFO_UPDATE_PAUTH_KEY(pauth_key, fde_info) \ + ((((pauth_key) & 0x1) << 5) | ((fde_info) & 0xdf)) + +/* Size of stack frame offsets in an SFrame Frame Row Entry. A single + SFrame FRE has all offsets of the same size. Offset size may vary + across frame row entries. */ +#define SFRAME_FRE_OFFSET_1B 0 +#define SFRAME_FRE_OFFSET_2B 1 +#define SFRAME_FRE_OFFSET_4B 2 + +/* An SFrame Frame Row Entry can be SP or FP based. */ +#define SFRAME_BASE_REG_FP 0 +#define SFRAME_BASE_REG_SP 1 + +/* The index at which a specific offset is presented in the variable length + bytes of an FRE. */ +#define SFRAME_FRE_CFA_OFFSET_IDX 0 +/* The RA stack offset, if present, will always be at index 1 in the variable + length bytes of the FRE. */ +#define SFRAME_FRE_RA_OFFSET_IDX 1 +/* The FP stack offset may appear at offset 1 or 2, depending on the ABI as RA + may or may not be tracked. */ +#define SFRAME_FRE_FP_OFFSET_IDX 2 + +/* Invalid RA offset. Currently used for s390x as padding to represent FP + without RA saved. */ +#define SFRAME_FRE_RA_OFFSET_INVALID 0 + +typedef struct sframe_fre_info +{ + /* Information about + - 1 bit: base reg for CFA + - 4 bits: Number of offsets (N). A value of upto 3 is allowed to track + all three of CFA, FP and RA (fixed implicit order). + - 2 bits: information about size of the offsets (S) in bytes. + Valid values are SFRAME_FRE_OFFSET_1B, SFRAME_FRE_OFFSET_2B, + SFRAME_FRE_OFFSET_4B + - 1 bit: Mangled RA state bit (aarch64 only). + ---------------------------------------------------------------------------------- + | Mangled-RA (aarch64) | Size of offsets | Number of offsets | base_reg | + | Unused (amd64, s390x)| | | | + ---------------------------------------------------------------------------------- + 8 7 5 1 0 + + */ + uint8_t fre_info; +} sframe_fre_info; + +/* Macros to compose and decompose FRE info. */ + +/* Note: Set mangled_ra_p to zero by default. */ +#define SFRAME_V1_FRE_INFO(base_reg_id, offset_num, offset_size) \ + (((0 & 0x1) << 7) | (((offset_size) & 0x3) << 5) | \ + (((offset_num) & 0xf) << 1) | ((base_reg_id) & 0x1)) + +/* Set the mangled_ra_p bit as indicated. */ +#define SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P(mangled_ra_p, fre_info) \ + ((((mangled_ra_p) & 0x1) << 7) | ((fre_info) & 0x7f)) + +#define SFRAME_V1_FRE_CFA_BASE_REG_ID(data) ((data) & 0x1) +#define SFRAME_V1_FRE_OFFSET_COUNT(data) (((data) >> 1) & 0xf) +#define SFRAME_V1_FRE_OFFSET_SIZE(data) (((data) >> 5) & 0x3) +#define SFRAME_V1_FRE_MANGLED_RA_P(data) (((data) >> 7) & 0x1) + +/* SFrame Frame Row Entry definitions. + + Used for AMD64, AARCH64, and s390x. + + An SFrame Frame Row Entry is a self-sufficient record which contains + information on how to generate the stack trace for the specified range of + PCs. Each SFrame Frame Row Entry is followed by S*N bytes, where: + S is the size of the stack frame offset for the FRE, and + N is the number of stack frame offsets in the FRE + + The interpretation of FRE stack offsets is ABI-specific: + + AMD64: + offset1 (interpreted as CFA = BASE_REG + offset1) + if FP is being tracked + offset2 (intrepreted as FP = CFA + offset2) + fi + + AARCH64: + offset1 (interpreted as CFA = BASE_REG + offset1) + if FP is being tracked (in other words, if frame record created) + offset2 (interpreted as RA = CFA + offset2) + offset3 (intrepreted as FP = CFA + offset3) + fi + Note that in AAPCS64, a frame record, if created, will save both FP and + LR on stack. + + s390x: + offset1 (interpreted as CFA = BASE_REG + offset1) + if RA is being tracked + offset2 (interpreted as RA = CFA + offset2; an offset value of + SFRAME_FRE_RA_OFFSET_INVALID indicates a dummy padding RA offset + to represent FP without RA saved on stack) + if FP is being tracked + offset3 (intrepreted as FP = CFA + offset3) + fi + else + if FP is being tracked + offset2 (intrepreted as FP = CFA + offset2) + fi + fi + Note that in s390x, if a FP/RA offset2/offset3 value has the least- + significant bit set it represents a DWARF register number shifted to the + left by 1 to restore the FP/RA value from. +*/ + +/* Used when SFRAME_FRE_TYPE_ADDR1 is specified as FRE type. */ +typedef struct sframe_frame_row_entry_addr1 +{ + /* Start address of the frame row entry. Encoded as an 1-byte unsigned + offset, relative to the start address of the function. */ + uint8_t sfre_start_address; + sframe_fre_info sfre_info; +} ATTRIBUTE_PACKED sframe_frame_row_entry_addr1; + +/* Upper limit of start address in sframe_frame_row_entry_addr1 + is 0x100 (not inclusive). */ +#define SFRAME_FRE_TYPE_ADDR1_LIMIT \ + (1ULL << ((SFRAME_FRE_TYPE_ADDR1 + 1) * 8)) + +/* Used when SFRAME_FRE_TYPE_ADDR2 is specified as FRE type. */ +typedef struct sframe_frame_row_entry_addr2 +{ + /* Start address of the frame row entry. Encoded as an 2-byte unsigned + offset, relative to the start address of the function. */ + uint16_t sfre_start_address; + sframe_fre_info sfre_info; +} ATTRIBUTE_PACKED sframe_frame_row_entry_addr2; + +/* Upper limit of start address in sframe_frame_row_entry_addr2 + is 0x10000 (not inclusive). */ +#define SFRAME_FRE_TYPE_ADDR2_LIMIT \ + (1ULL << ((SFRAME_FRE_TYPE_ADDR2 * 2) * 8)) + +/* Used when SFRAME_FRE_TYPE_ADDR4 is specified as FRE type. */ +typedef struct sframe_frame_row_entry_addr4 +{ + /* Start address of the frame row entry. Encoded as a 4-byte unsigned + offset, relative to the start address of the function. */ + uint32_t sfre_start_address; + sframe_fre_info sfre_info; +} ATTRIBUTE_PACKED sframe_frame_row_entry_addr4; + +/* Upper limit of start address in sframe_frame_row_entry_addr2 + is 0x100000000 (not inclusive). */ +#define SFRAME_FRE_TYPE_ADDR4_LIMIT \ + (1ULL << ((SFRAME_FRE_TYPE_ADDR4 * 2) * 8)) + +/* On s390x, the CFA offset from CFA base register is by definition a minimum + of 160. Store it adjusted by -160 to enable use of 8-bit SFrame offsets. + Additionally scale by an alignment factor of 8, as the SP and thus CFA + offset on s390x is always 8-byte aligned. */ +#define SFRAME_S390X_CFA_OFFSET_ADJUSTMENT SFRAME_S390X_SP_VAL_OFFSET +#define SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR 8 +#define SFRAME_V2_S390X_CFA_OFFSET_ENCODE(offset) \ + (((offset) + SFRAME_S390X_CFA_OFFSET_ADJUSTMENT) \ + / SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR) +#define SFRAME_V2_S390X_CFA_OFFSET_DECODE(offset) \ + (((offset) * SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR) \ + - SFRAME_S390X_CFA_OFFSET_ADJUSTMENT) + +/* On s390x, the CFA is defined as SP at call site + 160. Therefore the + SP value offset from CFA is -160. */ +#define SFRAME_S390X_SP_VAL_OFFSET (-160) + +/* On s390x, the FP and RA registers can be saved either on the stack or, + in case of leaf functions, in registers. Store DWARF register numbers + encoded as offset by using the least-significant bit (LSB) as indicator: + - LSB=0: Stack offset. The s390x ELF ABI mandates that stack register + slots must be 8-byte aligned. + - LSB=1: DWARF register number shifted to the left by one. */ +#define SFRAME_V2_S390X_OFFSET_IS_REGNUM(offset) \ + ((offset) & 1) +#define SFRAME_V2_S390X_OFFSET_ENCODE_REGNUM(regnum) \ + (((regnum) << 1) | 1) +#define SFRAME_V2_S390X_OFFSET_DECODE_REGNUM(offset) \ + ((offset) >> 1) + +#ifdef __cplusplus +} +#endif + +#endif /* _SFRAME_H */ diff --git a/illumos-x86_64/usr/include/sgtty.h b/illumos-x86_64/usr/include/sgtty.h new file mode 100644 index 00000000..4456baa8 --- /dev/null +++ b/illumos-x86_64/usr/include/sgtty.h @@ -0,0 +1,135 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SGTTY_H +#define _SGTTY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Modes + */ +#define HUPCL 01 +#ifndef _SYS_IOCTL_H +#define XTABS 02 +#define LCASE 04 +#define ECHO 010 +#define CRMOD 020 +#define RAW 040 +#define ODDP 0100 +#define EVENP 0200 +#define ANYP 0300 +#define NLDELAY 001400 +#define TBDELAY 002000 +#define CRDELAY 030000 +#define VTDELAY 040000 +#define BSDELAY 0100000 +#define ALLDELAY 0177400 + +/* + * Delay algorithms + */ +#define CR0 0 +#define CR1 010000 +#define CR2 020000 +#define CR3 030000 +#define NL0 0 +#define NL1 000400 +#define NL2 001000 +#define NL3 001400 +#define TAB0 0 +#define TAB1 002000 +#endif /* _SYS_IOCTL_H */ +#define NOAL 004000 +#ifndef _SYS_IOCTL_H +#define FF0 0 +#define FF1 040000 +#define BS0 0 +#define BS1 0100000 +#endif /* _SYS_IOCTL_H */ + +#ifndef _SYS_TTOLD_H + +/* + * Structure for stty and gtty system calls. + */ +struct sgttyb { + char sg_ispeed; /* input speed */ + char sg_ospeed; /* output speed */ + char sg_erase; /* erase character */ + char sg_kill; /* kill character */ + int sg_flags; /* mode flags */ +}; + +/* BSD local special chars. Structure for TIOCSLTC/TIOCGLTC */ +struct ltchars { + char t_suspc; /* stop process signal */ + char t_dsuspc; /* delayed stop process signal */ + char t_rprntc; /* reprint line */ + char t_flushc; /* flush output (toggles) */ + char t_werasc; /* word erase */ + char t_lnextc; /* literal next character */ +}; + +/* + * Speeds + */ +#define B0 0 +#define B50 1 +#define B75 2 +#define B110 3 +#define B134 4 +#define B150 5 +#define B200 6 +#define B300 7 +#define B600 8 +#define B1200 9 +#define B1800 10 +#define B2400 11 +#define B4800 12 +#define B9600 13 +#define EXTA 14 +#define EXTB 15 + +/* + * ioctl arguments + */ +#define FIOCLEX (('f'<<8)|1) +#define FIONCLEX (('f'<<8)|2) +#define TIOCHPCL (('t'<<8)|2) +#define TIOCGETP (('t'<<8)|8) +#define TIOCSETP (('t'<<8)|9) +#define TIOCEXCL (('t'<<8)|13) +#define TIOCNXCL (('t'<<8)|14) + +#endif /* _SYS_TTOLD_H */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SGTTY_H */ diff --git a/illumos-x86_64/usr/include/sha1.h b/illumos-x86_64/usr/include/sha1.h new file mode 100644 index 00000000..00836299 --- /dev/null +++ b/illumos-x86_64/usr/include/sha1.h @@ -0,0 +1,32 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SHA1_H +#define _SHA1_H + +#include + +#endif /* _SHA1_H */ diff --git a/illumos-x86_64/usr/include/sha2.h b/illumos-x86_64/usr/include/sha2.h new file mode 100644 index 00000000..ddb2bc1c --- /dev/null +++ b/illumos-x86_64/usr/include/sha2.h @@ -0,0 +1,32 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SHA2_H +#define _SHA2_H + +#include + +#endif /* _SHA2_H */ diff --git a/illumos-x86_64/usr/include/shadow.h b/illumos-x86_64/usr/include/shadow.h new file mode 100644 index 00000000..1506e09e --- /dev/null +++ b/illumos-x86_64/usr/include/shadow.h @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SHADOW_H +#define _SHADOW_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#define PASSWD "/etc/passwd" +#define SHADOW "/etc/shadow" +#define OPASSWD "/etc/opasswd" +#define OSHADOW "/etc/oshadow" +#define PASSTEMP "/etc/ptmp" +#define SHADTEMP "/etc/stmp" + +#define DAY (24L * 60 * 60) /* 1 day in seconds */ +#define DAY_NOW (time_t)time((time_t *)0) / DAY + /* The above timezone variable is set by a call to */ + /* any ctime(3c) routine. Programs using the DAY_NOW */ + /* macro must call one of the ctime routines, */ + /* e.g. tzset(), BEFORE referencing DAY_NOW */ + +#define LOCKSTRING "*LK*" /* prefix to/string in sp_pwdp to lock acct */ +#define NOLOGINSTRING "NP" /* sp_pwdp for no-login accounts */ +#define NOPWDRTR "*NP*" /* password is not retrievable */ +/* + * The spwd structure is used in the retreval of information from + * /etc/shadow. It is used by routines in the libos library. + */ +struct spwd { + char *sp_namp; /* user name */ + char *sp_pwdp; /* user password */ + int sp_lstchg; /* password lastchanged date */ + int sp_min; /* minimum number of days between password changes */ + int sp_max; /* number of days password is valid */ + int sp_warn; /* number of days to warn user to change passwd */ + int sp_inact; /* number of days the login may be inactive */ + int sp_expire; /* date when the login is no longer valid */ + unsigned int sp_flag; /* currently low 4 bits are used */ + + /* low 4 bits of sp_flag for counting failed login attempts */ +#define FAILCOUNT_MASK 0xF +}; + +#ifndef _STDIO_H +#include +#endif + +/* Declare all shadow password functions */ + +extern struct spwd *getspnam_r(const char *, struct spwd *, char *, int); +extern struct spwd *getspent_r(struct spwd *, char *, int); +extern struct spwd *fgetspent_r(FILE *, struct spwd *, char *, int); + +extern void setspent(void); +extern void endspent(void); +extern struct spwd *getspent(void); /* MT-unsafe */ +extern struct spwd *fgetspent(FILE *); /* MT-unsafe */ +extern struct spwd *getspnam(const char *); /* MT-unsafe */ + +extern int putspent(const struct spwd *, FILE *); +extern int lckpwdf(void); +extern int ulckpwdf(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SHADOW_H */ diff --git a/illumos-x86_64/usr/include/sharefs/share.h b/illumos-x86_64/usr/include/sharefs/share.h new file mode 100644 index 00000000..7266fce5 --- /dev/null +++ b/illumos-x86_64/usr/include/sharefs/share.h @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SHAREFS_SHARE_H +#define _SHAREFS_SHARE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * struct share defines the format of an exported filesystem. + * + * It is also the interface between the userland tools and + * the kernel. + */ +typedef struct share { + char *sh_path; + char *sh_res; + char *sh_fstype; + char *sh_opts; + char *sh_descr; + size_t sh_size; + struct share *sh_next; +} share_t; + +#ifdef _SYSCALL32 +typedef struct share32 { + caddr32_t sh_path; + caddr32_t sh_res; + caddr32_t sh_fstype; + caddr32_t sh_opts; + caddr32_t sh_descr; + size32_t sh_size; + caddr32_t sh_next; +} share32_t; +#endif /* _SYSCALL32 */ + +#define SHARETAB "/etc/dfs/sharetab" +#define MAXBUFSIZE 65536 + +/* + * Flavors of the system call. + */ +enum sharefs_sys_op { SHAREFS_ADD, SHAREFS_REMOVE, SHAREFS_REPLACE }; + +#ifdef _KERNEL + +extern int sharefs(enum sharefs_sys_op opcode, struct share *sh, + uint32_t iMaxLen); + +#else + +extern int _sharefs(enum sharefs_sys_op opcode, struct share *sh); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !_SHAREFS_SHARE_H */ diff --git a/illumos-x86_64/usr/include/sharefs/sharefs.h b/illumos-x86_64/usr/include/sharefs/sharefs.h new file mode 100644 index 00000000..d222227c --- /dev/null +++ b/illumos-x86_64/usr/include/sharefs/sharefs.h @@ -0,0 +1,128 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2018 Nexenta Systems, Inc. + */ + +#ifndef _SHAREFS_SHAREFS_H +#define _SHAREFS_SHAREFS_H + +/* + * This header provides service for the sharefs module. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SHAREFS_ROOT "/etc/dfs" +#define SHAREFS_BASE "sharetab" + +/* + * Lengths of strings. + */ +typedef struct sharefs_lens { + int shl_path; + int shl_res; + int shl_fstype; + int shl_opts; + int shl_descr; +} sharefs_lens_t; + +/* + * VFS data object + */ +typedef struct sharefs_vfs { + vnode_t *sharefs_vfs_root; +} sharefs_vfs_t; + +#define SHAREFS_NAME_MAX MAXNAMELEN + +typedef struct sharetab_globals { + /* + * The lock ordering whenever sharefs_lock and sharetab_lock both + * need to be held is: sharefs_lock and then sharetab_lock. + */ + krwlock_t sharefs_lock; /* lock for the vnode ops */ + sharetab_t *sharefs_sharetab; /* The sharetab. */ + + uint_t sharetab_count; /* How many shares? */ + krwlock_t sharetab_lock; /* lock for the cached sharetab */ + size_t sharetab_size; /* How big is the sharetab file? */ + + timestruc_t sharetab_mtime; /* Last mod to sharetab */ + timestruc_t sharetab_snap_time; /* Last snap */ + uint_t sharetab_generation; /* Which copy is it? */ +} sharetab_globals_t; + +#define SHAREFS_INO_FILE 0x80 + +extern vnode_t *sharefs_create_root_file(vfs_t *); +extern sharetab_globals_t *sharetab_get_globals(zone_t *zone); + +/* + * Sharetab file + * + * Note that even though the sharetab code does not explictly + * use 'sharefs_file', it is required by GFS that the first + * field of the private data be a gfs_file_t. + */ +typedef struct shnode_t { + gfs_file_t sharefs_file; /* gfs file */ + char *sharefs_snap; /* snapshot of the share */ + size_t sharefs_size; /* size of the snapshot */ + uint_t sharefs_count; /* number of shares */ + uint_t sharefs_refs; /* reference count */ + uint_t sharefs_real_vp; /* Are we a real or snap */ + uint_t sharefs_generation; /* Which copy are we? */ + timestruc_t sharefs_snap_time; /* When were we modded? */ +} shnode_t; + +/* + * Some conversion macros: + */ +#define VTOSH(vp) ((shnode_t *)((vp)->v_data)) + +extern const fs_operation_def_t sharefs_tops_data[]; +extern vnodeops_t *sharefs_ops_data; + +extern void sharefs_data_init(void); + +extern void sharefs_sharetab_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* !_SHAREFS_SHAREFS_H */ diff --git a/illumos-x86_64/usr/include/sharefs/sharetab.h b/illumos-x86_64/usr/include/sharefs/sharetab.h new file mode 100644 index 00000000..f1a3fd62 --- /dev/null +++ b/illumos-x86_64/usr/include/sharefs/sharetab.h @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SHAREFS_SHARETAB_H +#define _SHAREFS_SHARETAB_H + +#include + +/* + * This header defines the glue to keeping a sharetab in memory. + * It is broken out from sharefs.h in the case that it will be + * reused in userland. + */ + +/* + * Note: + * Must include share/share.h before this header. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct sh_list { /* cached share list */ + struct sh_list *shl_next; + share_t *shl_sh; +} sh_list_t; + +typedef struct sharefs_hash_head { + share_t *ssh_sh; + uint_t ssh_count; +} sharefs_hash_head_t; + +#define SHARETAB_HASHES PKP_HASH_SIZE + +typedef struct sharetab { + sharefs_hash_head_t s_buckets[SHARETAB_HASHES]; + char *s_fstype; + struct sharetab *s_next; + uint_t s_count; +} sharetab_t; + +#ifdef __cplusplus +} +#endif + +#endif /* !_SHAREFS_SHARETAB_H */ diff --git a/illumos-x86_64/usr/include/siginfo.h b/illumos-x86_64/usr/include/siginfo.h new file mode 100644 index 00000000..e6d5bb1b --- /dev/null +++ b/illumos-x86_64/usr/include/siginfo.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2015 Circonus, Inc. All rights reserved. + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _SIGINFO_H +#define _SIGINFO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct siginfolist { + int nsiginfo; + char **vsiginfo; +}; + +extern const char *_sys_illlist[]; +extern const char *_sys_fpelist[]; +extern const char *_sys_segvlist[]; +extern const char *_sys_buslist[]; +extern const char *_sys_traplist[]; +extern const char *_sys_cldlist[]; +extern const struct siginfolist *_sys_siginfolistp; +#define _sys_siginfolist _sys_siginfolistp + +extern void psignal(int, const char *); +extern void psiginfo(const siginfo_t *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SIGINFO_H */ diff --git a/illumos-x86_64/usr/include/signal.h b/illumos-x86_64/usr/include/signal.h new file mode 100644 index 00000000..042372d6 --- /dev/null +++ b/illumos-x86_64/usr/include/signal.h @@ -0,0 +1,175 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SIGNAL_H +#define _SIGNAL_H + +#include + +#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \ + defined(__XOPEN_OR_POSIX) +#include /* need pid_t/uid_t/size_t/clock_t/caddr_t/pthread_t */ +#endif + +#include +#include + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::sig_atomic_t; +using std::signal; +using std::raise; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +extern const char **_sys_siglistp; /* signal descriptions */ +extern const int _sys_siglistn; /* # of signal descriptions */ + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +#define _sys_siglist _sys_siglistp +#define _sys_nsig _sys_siglistn +#endif + +#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \ + defined(__XOPEN_OR_POSIX) +extern int kill(pid_t, int); +extern int sigaction(int, const struct sigaction *_RESTRICT_KYWD, + struct sigaction *_RESTRICT_KYWD); +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) +extern int sigaddset(sigset_t *, int); +extern int sigdelset(sigset_t *, int); +extern int sigemptyset(sigset_t *); +extern int sigfillset(sigset_t *); +extern int sigismember(const sigset_t *, int); +#endif +extern int sigpending(sigset_t *); +extern int sigprocmask(int, const sigset_t *_RESTRICT_KYWD, + sigset_t *_RESTRICT_KYWD); +extern int sigsuspend(const sigset_t *); +#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC)... */ + +#if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \ + !defined(__XOPEN_OR_POSIX)) +#include +extern int gsignal(int); +extern int (*ssignal(int, int (*)(int)))(int); +extern int sigsend(idtype_t, id_t, int); +extern int sigsendset(const procset_t *, int); +extern int sig2str(int, char *); +extern int str2sig(const char *, int *); +#define SIG2STR_MAX 32 +#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC)... */ + +#if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \ + !defined(__XOPEN_OR_POSIX)) || defined(_XPG4_2) +extern void (*bsd_signal(int, void (*)(int)))(int); +extern int killpg(pid_t, int); +extern int siginterrupt(int, int); +extern int sigaltstack(const stack_t *_RESTRICT_KYWD, stack_t *_RESTRICT_KYWD); +extern int sighold(int); +extern int sigignore(int); +extern int sigpause(int); +extern int sigrelse(int); +extern void (*sigset(int, void (*)(int)))(int); +#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && ... */ + +/* Marked as LEGACY in SUSv2 and removed in SUSv3 */ +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (defined(_XPG4_2) && !defined(_XPG6)) +extern int sigstack(struct sigstack *, struct sigstack *); +#endif + +#if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \ + !defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE > 2) +#include +#include +extern int pthread_kill(pthread_t, int); +extern int pthread_sigmask(int, const sigset_t *_RESTRICT_KYWD, + sigset_t *_RESTRICT_KYWD); +extern int sigwaitinfo(const sigset_t *_RESTRICT_KYWD, + siginfo_t *_RESTRICT_KYWD); +extern int sigtimedwait(const sigset_t *_RESTRICT_KYWD, + siginfo_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD); +extern int sigqueue(pid_t, int, const union sigval); +#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && */ + +/* + * sigwait() prototype is defined here. + */ + +#if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \ + !defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE - 0 >= 199506L) || \ + defined(_POSIX_PTHREAD_SEMANTICS) + +#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname sigwait __posix_sigwait +extern int sigwait(const sigset_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +#else /* __PRAGMA_REDEFINE_EXTNAME */ + +extern int __posix_sigwait(const sigset_t *_RESTRICT_KYWD, + int *_RESTRICT_KYWD); + +#ifdef __lint +#define sigwait __posix_sigwait +#else /* !__lint */ + +static int +sigwait(const sigset_t *_RESTRICT_KYWD __setp, int *_RESTRICT_KYWD __signo) +{ + return (__posix_sigwait(__setp, __signo)); +} + +#endif /* !__lint */ +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +extern int sigwait(sigset_t *); + +#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SIGNAL_H */ diff --git a/illumos-x86_64/usr/include/sip.h b/illumos-x86_64/usr/include/sip.h new file mode 100644 index 00000000..09745bd5 --- /dev/null +++ b/illumos-x86_64/usr/include/sip.h @@ -0,0 +1,772 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SIP_H +#define _SIP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* Send a SIP message statefully */ +#define SIP_SEND_STATEFUL 0x0001 + +/* Enable multiple dialogs if a request is forked */ +#define SIP_DIALOG_ON_FORK 0x0010 + +#define SIP_CRLF "\r\n" +#define SKIP_CRLF(msg_ptr) (msg_ptr = msg_ptr + 2) +#define SIP_VERSION "SIP/2.0" +#define SIP "SIP" + +/* SIP headers */ +#define SIP_TO "TO" +#define SIP_FROM "FROM" +#define SIP_TAG "TAG=" +#define SIP_CONTENT_LENGTH "CONTENT-LENGTH" +#define SIP_CONTENT_TYPE "CONTENT-TYPE" +#define SIP_CALL_ID "CALL-ID" +#define SIP_CSEQ "CSEQ" +#define SIP_MAX_FORWARDS "MAX-FORWARDS" +#define SIP_CONTACT "CONTACT" +#define SIP_VIA "Via" +#define SIP_RECORD_ROUTE "RECORD-ROUTE" +#define SIP_ROUTE "ROUTE" +#define SIP_ACCEPT "ACCEPT" +#define SIP_ACCEPT_ENCODE "ACCEPT-ENCODING" +#define SIP_ACCEPT_LANG "ACCEPT-LANGUAGE" +#define SIP_ALERT_INFO "ALERT-INFO" +#define SIP_ALLOW "ALLOW" +#define SIP_CALL_INFO "CALL-INFO" +#define SIP_CONTENT_DIS "CONTENT-DISPOSITION" +#define SIP_CONTENT_ENCODE "CONTENT-ENCODING" +#define SIP_CONTENT_LANG "CONTENT-LANGUAGE" +#define SIP_DATE "DATE" +#define SIP_ERROR_INFO "ERROR-INFO" +#define SIP_EXPIRE "EXPIRES" +#define SIP_IN_REPLY_TO "IN-REPLY-TO" +#define SIP_MIN_EXPIRE "MIN-EXPIRES" +#define SIP_MIME_VERSION "MIME-VERSION" +#define SIP_ORGANIZATION "ORGANIZATION" +#define SIP_PRIORITY "PRIORITY" +#define SIP_REQUIRE "REQUIRE" +#define SIP_REPLYTO "REPLY-TO" +#define SIP_RETRY_AFTER "RETRY-AFTER" +#define SIP_SERVER "SERVER" +#define SIP_SUBJECT "SUBJECT" +#define SIP_SUPPORT "SUPPORTED" +#define SIP_TIMESTAMP "TIMESTAMP" +#define SIP_UNSUPPORT "UNSUPPORTED" +#define SIP_USER_AGENT "USER-AGENT" +#define SIP_WARNING "WARNING" +#define SIP_ALLOW_EVENTS "ALLOW-EVENTS" +#define SIP_EVENT "EVENT" +#define SIP_SUBSCRIPTION_STATE "SUBSCRIPTION-STATE" +#define SIP_WWW_AUTHEN "WWW-AUTHENTICATE" +#define SIP_AUTHOR "AUTHORIZATION" +#define SIP_AUTHEN_INFO "AUTHENTICATION-INFO" +#define SIP_PROXY_AUTHOR "PROXY-AUTHORIZATION" +#define SIP_PROXY_AUTHEN "PROXY-AUTHENTICATE" +#define SIP_PROXY_REQ "PROXY-REQUIRE" +#define SIP_PASSERTEDID "P-ASSERTED-IDENTITY" +#define SIP_PPREFERREDID "P-PREFERRED-IDENTITY" +#define SIP_PRIVACY "PRIVACY" +#define SIP_RACK "RACK" +#define SIP_RSEQ "RSEQ" + +/* SIP Response Codes */ + +/* 1XX - Provisional */ +#define SIP_TRYING 100 +#define SIP_RINGING 180 +#define SIP_CALL_IS_BEING_FORWARDED 181 +#define SIP_QUEUED 182 +#define SIP_SESSION_PROGRESS 183 + +/* 2XX - Success */ +#define SIP_OK 200 +#define SIP_ACCEPTED 202 + +/* 3XX - Redirection */ +#define SIP_MULTIPLE_CHOICES 300 +#define SIP_MOVED_PERMANENTLY 301 +#define SIP_MOVED_TEMPORARILY 302 +#define SIP_USE_PROXY 303 +#define SIP_ALTERNATIVE_SERVICE 304 + +/* 4XX - Request Failed */ +#define SIP_BAD_REQUEST 400 +#define SIP_UNAUTHORIZED 401 +#define SIP_PAYMENT_REQUIRED 402 +#define SIP_FORBIDDEN 403 +#define SIP_NOT_FOUND 404 +#define SIP_METHOD_NOT_ALLOWED 405 +#define SIP_NOT_ACCEPTABLE 406 +#define SIP_PROXY_AUTH_REQUIRED 407 +#define SIP_REQUEST_TIMEOUT 408 +#define SIP_GONE 410 +#define SIP_REQUEST_ENTITY_2_LARGE 413 +#define SIP_REQUEST_URI_2_LONG 414 +#define SIP_UNSUPPORTED_MEDIA_TYPE 415 +#define SIP_UNSUPPORTED_URI_SCHEME 416 +#define SIP_BAD_EXTENSION 420 +#define SIP_EXTENSION_REQUIRED 421 +#define SIP_INTERVAL_2_BRIEF 423 +#define SIP_TEMPORARILY_UNAVAIL 480 +#define SIP_CALL_NON_EXISTANT 481 +#define SIP_LOOP_DETECTED 482 +#define SIP_TOO_MANY_HOOPS 483 +#define SIP_ADDRESS_INCOMPLETE 484 +#define SIP_AMBIGUOUS 485 +#define SIP_BUSY_HERE 486 +#define SIP_REQUEST_TERMINATED 487 +#define SIP_NOT_ACCEPTABLE_HERE 488 +#define SIP_BAD_EVENT 489 +#define SIP_REQUEST_PENDING 491 +#define SIP_UNDECIPHERABLE 493 + +/* 5XX - Server Failure */ +#define SIP_SERVER_INTERNAL_ERROR 500 +#define SIP_NOT_IMPLEMENTED 501 +#define SIP_BAD_GATEWAY 502 +#define SIP_SERVICE_UNAVAILABLE 503 +#define SIP_SERVER_TIMEOUT 504 +#define SIP_VERSION_NOT_SUPPORTED 505 +#define SIP_MESSAGE_2_LARGE 513 + +/* 6XX - Global Failures */ +#define SIP_BUSY_EVERYWHERE 600 +#define SIP_DECLINE 601 +#define SIP_DOES_NOT_EXIST_ANYWHERE 604 +#define SIP_NOT_ACCEPTABLE_ANYWHERE 606 + +/* Response error types */ +#define SIP_PROVISIONAL_RESP(resp) ((resp) >= 100 && (resp) < 200) +#define SIP_FINAL_RESP(resp) ((resp) >= 200 && (resp) < 700) +#define SIP_OK_RESP(resp) ((resp) >= 200 && (resp) < 300) +#define SIP_NONOK_FINAL_RESP(resp) ((resp) >= 300 && (resp) < 700) +#define SIP_REDIRECT_RESP(resp) ((resp) >= 300 && (resp) < 400) +#define SIP_REQFAIL_RESP(resp) ((resp) >= 400 && (resp) < 500) +#define SIP_SRVFAIL_RESP(resp) ((resp) >= 500 && (resp) < 600) +#define SIP_GLOBFAIL_RESP(resp) ((resp) >= 600 && (resp) < 700) + +/* Types of transactions */ +#define SIP_CLIENT_TRANSACTION 1 +#define SIP_SERVER_TRANSACTION 2 + +/* Transaction states */ +#define SIP_NEW_TRANSACTION 0 + +/* Client Transaction States */ +#define SIP_CLNT_CALLING 1 +#define SIP_CLNT_INV_PROCEEDING 2 +#define SIP_CLNT_INV_TERMINATED 3 +#define SIP_CLNT_INV_COMPLETED 4 +#define SIP_CLNT_TRYING 5 +#define SIP_CLNT_NONINV_PROCEEDING 6 +#define SIP_CLNT_NONINV_TERMINATED 7 +#define SIP_CLNT_NONINV_COMPLETED 8 + +/* Server Transaction States */ +#define SIP_SRV_INV_PROCEEDING 9 +#define SIP_SRV_INV_COMPLETED 10 +#define SIP_SRV_CONFIRMED 11 +#define SIP_SRV_INV_TERMINATED 12 +#define SIP_SRV_TRYING 13 +#define SIP_SRV_NONINV_PROCEEDING 14 +#define SIP_SRV_NONINV_COMPLETED 15 +#define SIP_SRV_NONINV_TERMINATED 16 + +/* Dialog types */ +#define SIP_UAC_DIALOG 1 +#define SIP_UAS_DIALOG 2 + +/* Dialog state */ +typedef enum dialog_state { + SIP_DLG_NEW = 0, /* New dialog, no reply received yet */ + SIP_DLG_EARLY, /* Early dialog, provisional reply received */ + SIP_DLG_CONFIRMED, /* Confirmed dialog, 2xx reply received */ + SIP_DLG_DESTROYED /* Destroyed dialog */ +} dialog_state_t; + +/* SIP URI parse errors */ +#define SIP_URIERR_SCHEME 0x00000001 /* invalid URL SCHEME name */ +#define SIP_URIERR_USER 0x00000002 /* invalid user name */ +#define SIP_URIERR_PASS 0x00000004 /* invalid password */ +#define SIP_URIERR_HOST 0x00000008 /* invalid domain name */ +#define SIP_URIERR_PORT 0x00000010 /* invalid port number */ +#define SIP_URIERR_PARAM 0x00000020 /* parameter specific error */ +#define SIP_URIERR_HEADER 0x00000040 /* headers specific error */ +#define SIP_URIERR_OPAQUE 0x00000080 /* opaque specific error */ +#define SIP_URIERR_QUERY 0x00000100 /* query specific error */ +#define SIP_URIERR_PATH 0x00000200 /* path specific error */ +#define SIP_URIERR_REGNAME 0x00000400 /* reg-name specific error */ +#define SIP_URIERR_NOURI 0x00000800 /* No URI */ +#define SIP_URIERR_MEMORY 0x00001000 /* out of memory */ + +/* SIP traffic counters */ +typedef enum sip_traffic_counter_names { + SIP_TOTAL_BYTES_RCVD = 0, + SIP_TOTAL_BYTES_SENT, + SIP_TOTAL_REQ_RCVD, + SIP_TOTAL_REQ_SENT, + SIP_TOTAL_RESP_RCVD, + SIP_TOTAL_RESP_SENT, + SIP_ACK_REQ_RCVD, + SIP_ACK_REQ_SENT, + SIP_BYE_REQ_RCVD, + SIP_BYE_REQ_SENT, + SIP_CANCEL_REQ_RCVD, + SIP_CANCEL_REQ_SENT, + SIP_INFO_REQ_RCVD, + SIP_INFO_REQ_SENT, + SIP_INVITE_REQ_RCVD, + SIP_INVITE_REQ_SENT, + SIP_NOTIFY_REQ_RCVD, + SIP_NOTIFY_REQ_SENT, + SIP_OPTIONS_REQ_RCVD, + SIP_OPTIONS_REQ_SENT, + SIP_PRACK_REQ_RCVD, + SIP_PRACK_REQ_SENT, + SIP_REFER_REQ_RCVD, + SIP_REFER_REQ_SENT, + SIP_REGISTER_REQ_RCVD, + SIP_REGISTER_REQ_SENT, + SIP_SUBSCRIBE_REQ_RCVD, + SIP_SUBSCRIBE_REQ_SENT, + SIP_UPDATE_REQ_RCVD, + SIP_UPDATE_REQ_SENT, + SIP_1XX_RESP_RCVD, + SIP_1XX_RESP_SENT, + SIP_2XX_RESP_RCVD, + SIP_2XX_RESP_SENT, + SIP_3XX_RESP_RCVD, + SIP_3XX_RESP_SENT, + SIP_4XX_RESP_RCVD, + SIP_4XX_RESP_SENT, + SIP_5XX_RESP_RCVD, + SIP_5XX_RESP_SENT, + SIP_6XX_RESP_RCVD, + SIP_6xx_RESP_SENT, + SIP_COUNTER_START_TIME, + SIP_COUNTER_STOP_TIME +} sip_traffic_counter_names_t; + +/* SIP Traffic counter group */ +#define SIP_TRAFFIC_COUNTERS 0x0001 /* measures end to end SIP traffic */ + +/* SIP Logging Levels */ +#define SIP_DETAIL_LOGGING 0x0001 /* logs the entire sip message */ + +#ifdef __linux__ +#define B_FALSE 0 +#define B_TRUE 1 + +typedef int boolean_t; +typedef unsigned char uchar_t; +typedef unsigned int uint_t; +typedef unsigned int uint32_t; +#endif + +typedef struct sip_message *sip_msg_t; +typedef struct sip_header *sip_header_t; +typedef struct sip_value *sip_header_value_t; +typedef struct sip_dialog *sip_dialog_t; +typedef struct sip_uri *sip_uri_t; +typedef struct sip_conn_object *sip_conn_object_t; +typedef struct sip_xaction *sip_transaction_t; + +typedef struct sip_str { + char *sip_str_ptr; + int sip_str_len; +}sip_str_t; + + +/* SIP parameter */ +typedef struct sip_param { + sip_str_t param_name; + sip_str_t param_value; + struct sip_param *param_next; +}sip_param_t; + + +/* Parsed header structure */ +typedef struct sip_parsed_header { + int sip_parsed_header_version; + struct sip_value *value; + sip_header_t sip_header; +}sip_parsed_header_t; + +#define SIP_PARSED_HEADER_VERSION_1 1 + +/* Value states */ +typedef enum { + SIP_VALUE_ACTIVE = 0, + SIP_VALUE_BAD, + SIP_VALUE_DELETED +}sip_value_state_t; + +/* SIP header value */ +typedef struct sip_value { + int sip_value_version; + void *next; + sip_param_t *param_list; + sip_value_state_t value_state; /* Active/Deleted */ + sip_parsed_header_t *parsed_header; + char *value_start; + char *value_end; + sip_str_t *sip_value_uri_str; + sip_uri_t sip_value_parse_uri; +}sip_value_t; + +#define SIP_VALUE_VERSION_1 1 + +typedef struct sip_header_general { + char *sip_hdr_start; + char *sip_hdr_end; + char *sip_hdr_current; + sip_parsed_header_t *sip_hdr_parsed; +}sip_hdr_general_t; + +/* SIP methods */ +typedef enum { + UNKNOWN = 0, + INVITE, + ACK, + OPTIONS, + BYE, + CANCEL, + REGISTER, + REFER, + INFO, + SUBSCRIBE, + NOTIFY, + PRACK +}sip_method_t; + +#define MAX_SIP_METHODS 12 + +typedef struct sip_methods { + char *name; /* Name of the method */ + int len; /* Length for comparison */ +}sip_methods_t; + +extern sip_methods_t sip_methods[]; + +/* SIP header function table */ +typedef struct header_function_table { + char *header_name; + char *header_short_name; + int (*header_parse_func)(struct sip_header *, + struct sip_parsed_header **); + boolean_t (*header_check_compliance)(struct sip_parsed_header *); + boolean_t (*header_is_equal)(struct sip_parsed_header *, + struct sip_parsed_header *); + void (*header_free)(struct sip_parsed_header *); +}sip_header_function_t; + +/* Connection Manager interface */ +typedef struct sip_io_pointers_s { + int (*sip_conn_send)(const sip_conn_object_t, char *, int); + void (*sip_hold_conn_object)(sip_conn_object_t); + void (*sip_rel_conn_object)(sip_conn_object_t); + boolean_t (*sip_conn_is_stream)(sip_conn_object_t); + boolean_t (*sip_conn_is_reliable)(sip_conn_object_t); + int (*sip_conn_remote_address)(sip_conn_object_t, struct sockaddr *, + socklen_t *); + int (*sip_conn_local_address)(sip_conn_object_t, struct sockaddr *, + socklen_t *); + int (*sip_conn_transport)(sip_conn_object_t); + int (*sip_conn_timer1)(sip_conn_object_t); + int (*sip_conn_timer2)(sip_conn_object_t); + int (*sip_conn_timer4)(sip_conn_object_t); + int (*sip_conn_timerd)(sip_conn_object_t); +}sip_io_pointers_t; + +/* Upper layer registerations */ +typedef struct sip_ulp_pointers_s { + void (*sip_ulp_recv)(const sip_conn_object_t, + sip_msg_t, const sip_dialog_t); + uint_t (*sip_ulp_timeout)(void *, void (*func)(void *), + struct timeval *); + boolean_t (*sip_ulp_untimeout)(uint_t); + int (*sip_ulp_trans_error)(sip_transaction_t, int, void *); + void (*sip_ulp_dlg_del)(sip_dialog_t, sip_msg_t, void *); + void (*sip_ulp_trans_state_cb)(sip_transaction_t, + sip_msg_t, int, int); + void (*sip_ulp_dlg_state_cb)(sip_dialog_t, sip_msg_t, int, + int); +}sip_ulp_pointers_t; + +/* SIP stack initialization structure */ +typedef struct sip_stack_init_s { + int sip_version; + int sip_stack_flags; + sip_io_pointers_t *sip_io_pointers; + sip_ulp_pointers_t *sip_ulp_pointers; + sip_header_function_t *sip_function_table; +}sip_stack_init_t; + +/* SIP stack version */ +#define SIP_STACK_VERSION 1 + +/* Flags for sip_stack_flags */ +#define SIP_STACK_DIALOGS 0x0001 + +extern int sip_init_conn_object(sip_conn_object_t); +extern void sip_clear_stale_data(sip_conn_object_t); +extern void sip_conn_destroyed(sip_conn_object_t); + +extern int (*sip_stack_send)(const sip_conn_object_t, char *, int); +extern void (*sip_refhold_conn)(sip_conn_object_t); +extern void (*sip_refrele_conn)(sip_conn_object_t); +extern boolean_t (*sip_is_conn_stream)(sip_conn_object_t); +extern boolean_t (*sip_is_conn_reliable)(sip_conn_object_t); +extern int (*sip_conn_rem_addr)(sip_conn_object_t, + struct sockaddr *, socklen_t *); +extern int (*sip_conn_local_addr)(sip_conn_object_t, + struct sockaddr *, socklen_t *); +extern int (*sip_conn_transport)(sip_conn_object_t); +extern int (*sip_conn_timer1)(sip_conn_object_t); +extern int (*sip_conn_timer2)(sip_conn_object_t); +extern int (*sip_conn_timer4)(sip_conn_object_t); +extern int (*sip_conn_timerd)(sip_conn_object_t); + +extern uint_t (*sip_stack_timeout)(void *, void (*func)(void *), + struct timeval *); +extern boolean_t (*sip_stack_untimeout)(uint_t); + +extern sip_msg_t sip_new_msg(); +extern void sip_free_msg(sip_msg_t); +extern void sip_hold_msg(sip_msg_t); +extern int sip_stack_init(sip_stack_init_t *); +extern int sip_sendmsg(sip_conn_object_t, sip_msg_t, sip_dialog_t, + uint32_t); +extern void sip_process_new_packet(sip_conn_object_t, void *, + size_t); +extern char *sip_guid(); +extern char *sip_sent_by_to_str(int *); +extern int sip_register_sent_by(char *); +extern void sip_unregister_sent_by(char *); +extern void sip_unregister_all_sent_by(); +extern char *sip_branchid(sip_msg_t); +extern uint32_t sip_get_cseq(); +extern uint32_t sip_get_rseq(); +extern int sip_get_num_via(sip_msg_t, int *); + +extern int sip_add_from(sip_msg_t, char *, char *, char *, + boolean_t, char *); +extern int sip_add_to(sip_msg_t, char *, char *, char *, + boolean_t, char *); +extern int sip_add_response_line(sip_msg_t, int, char *); +extern int sip_add_request_line(sip_msg_t, sip_method_t, char *); +extern int sip_add_via(sip_msg_t, char *, char *, int, char *); +extern int sip_add_maxforward(sip_msg_t, uint_t); +extern int sip_add_callid(sip_msg_t, char *); +extern int sip_add_cseq(sip_msg_t, sip_method_t, uint32_t); +extern int sip_add_content_type(sip_msg_t, char *, char *); +extern int sip_add_content(sip_msg_t, char *); +extern int sip_add_contact(sip_msg_t, char *, char *, boolean_t, + char *); +extern int sip_add_route(sip_msg_t, char *, char *, char *); +extern int sip_add_record_route(sip_msg_t, char *, char *, char *); +extern int sip_add_branchid_to_via(sip_msg_t, char *); +extern int sip_add_accept(sip_msg_t, char *, char *, char *, + char *); +extern int sip_add_author(sip_msg_t, char *, char *); +extern int sip_add_authen_info(sip_msg_t, char *); +extern int sip_add_proxy_authen(sip_msg_t, char *, char *); +extern int sip_add_proxy_author(sip_msg_t, char *, char *); +extern int sip_add_proxy_require(sip_msg_t, char *); +extern int sip_add_www_authen(sip_msg_t, char *, char *); +extern int sip_add_accept_enc(sip_msg_t, char *, char *); +extern int sip_add_accept_lang(sip_msg_t, char *, char *); +extern int sip_add_alert_info(sip_msg_t, char *, char *); +extern int sip_add_allow(sip_msg_t, sip_method_t); +extern int sip_add_call_info(sip_msg_t, char *, char *); +extern int sip_add_content_disp(sip_msg_t, char *, char *); +extern int sip_add_content_enc(sip_msg_t, char *); +extern int sip_add_content_lang(sip_msg_t, char *); +extern int sip_add_date(sip_msg_t, char *); +extern int sip_add_error_info(sip_msg_t, char *, char *); +extern int sip_add_expires(sip_msg_t, int); +extern int sip_add_in_reply_to(sip_msg_t, char *); +extern int sip_add_mime_version(sip_msg_t, char *); +extern int sip_add_min_expires(sip_msg_t, int); +extern int sip_add_org(sip_msg_t, char *); +extern int sip_add_priority(sip_msg_t, char *); +extern int sip_add_reply_to(sip_msg_t, char *, char *, char *, + boolean_t); +extern int sip_add_require(sip_msg_t, char *); +extern int sip_add_retry_after(sip_msg_t, int, char *, char *); +extern int sip_add_server(sip_msg_t, char *); +extern int sip_add_subject(sip_msg_t, char *); +extern int sip_add_supported(sip_msg_t, char *); +extern int sip_add_tstamp(sip_msg_t, char *, char *); +extern int sip_add_unsupported(sip_msg_t, char *); +extern int sip_add_user_agent(sip_msg_t, char *); +extern int sip_add_warning(sip_msg_t, int, char *, char *); +extern int sip_add_allow_events(sip_msg_t, char *); +extern int sip_add_event(sip_msg_t, char *, char *); +extern int sip_add_substate(sip_msg_t, char *, char *); +extern int sip_add_privacy(sip_msg_t, char *); +extern int sip_add_passertedid(sip_msg_t, char *, char *, + boolean_t); +extern int sip_add_ppreferredid(sip_msg_t, char *, char *, + boolean_t); +extern int sip_add_rack(sip_msg_t, int, int, sip_method_t); +extern int sip_add_rseq(sip_msg_t, int); +extern const sip_str_t *sip_get_author_scheme(sip_msg_t, int *); +extern const sip_str_t *sip_get_author_param(sip_msg_t, char *, int *); +extern const sip_str_t *sip_get_authen_info(sip_header_value_t, int *); +extern const sip_str_t *sip_get_proxy_authen_scheme(sip_msg_t, int *); +extern const sip_str_t *sip_get_proxy_authen_param(sip_msg_t, char *, int *); +extern const sip_str_t *sip_get_proxy_author_scheme(sip_msg_t, int *); +extern const sip_str_t *sip_get_proxy_author_param(sip_msg_t, char *, int *); +extern const sip_str_t *sip_get_proxy_require(sip_header_value_t, int *); +extern const sip_str_t *sip_get_www_authen_scheme(sip_msg_t, int *); +extern const sip_str_t *sip_get_www_authen_param(sip_msg_t, char *, int *); +extern const sip_str_t *sip_get_allow_events(sip_header_value_t, int *); +extern const sip_str_t *sip_get_event(sip_msg_t, int *); +extern const sip_str_t *sip_get_substate(sip_msg_t, int *); +extern const sip_str_t *sip_get_accept_type(sip_header_value_t, int *); +extern const sip_str_t *sip_get_accept_sub_type(sip_header_value_t, int *); +extern const sip_str_t *sip_get_accept_enc(sip_header_value_t, int *); +extern const sip_str_t *sip_get_accept_lang(sip_header_value_t, int *); +extern const sip_str_t *sip_get_alert_info_uri(sip_header_value_t, int *); +extern sip_method_t sip_get_allow_method(sip_header_value_t, int *); +extern int sip_get_min_expires(sip_msg_t, int *); +extern const sip_str_t *sip_get_mime_version(sip_msg_t, int *); +extern const sip_str_t *sip_get_org(sip_msg_t, int *); +extern const sip_str_t *sip_get_priority(sip_msg_t, int *); +extern const sip_str_t *sip_get_replyto_display_name(sip_msg_t, int *); +extern const sip_str_t *sip_get_replyto_uri_str(sip_msg_t, int *); +extern const sip_str_t *sip_get_date_time(sip_msg_t, int *); +extern int sip_get_date_day(sip_msg_t, int *); +extern const sip_str_t *sip_get_date_month(sip_msg_t, int *); +extern const sip_str_t *sip_get_date_wkday(sip_msg_t, int *); +extern int sip_get_date_year(sip_msg_t, int *); +extern const sip_str_t *sip_get_date_timezone(sip_msg_t, int *); +extern const sip_str_t *sip_get_content_disp(sip_msg_t, int *); +extern const sip_str_t *sip_get_content_lang(sip_header_value_t, int *); +extern const sip_str_t *sip_get_content_enc(sip_header_value_t, int *); +extern const sip_str_t *sip_get_error_info_uri(sip_header_value_t, int *); +extern int sip_get_expires(sip_msg_t, int *); +extern const sip_str_t *sip_get_require(sip_header_value_t, int *); +extern const sip_str_t *sip_get_subject(sip_msg_t, int *); +extern const sip_str_t *sip_get_supported(sip_header_value_t, int *); +extern const sip_str_t *sip_get_tstamp_delay(sip_msg_t, int *); +extern const sip_str_t *sip_get_tstamp_value(sip_msg_t, int *); +extern const sip_str_t *sip_get_unsupported(sip_header_value_t, int *); +extern const sip_str_t *sip_get_server(sip_msg_t, int *); +extern const sip_str_t *sip_get_user_agent(sip_msg_t, int *); +extern int sip_get_warning_code(sip_header_value_t, int *); +extern const sip_str_t *sip_get_warning_agent(sip_header_value_t, int *); +extern const sip_str_t *sip_get_warning_text(sip_header_value_t, int *); +extern const sip_str_t *sip_get_call_info_uri(sip_header_value_t, int *); +extern const sip_str_t *sip_get_in_reply_to(sip_header_value_t, int *); +extern int sip_get_retry_after_time(sip_msg_t, int *); +extern const sip_str_t *sip_get_retry_after_cmts(sip_msg_t, int *); +extern const sip_str_t *sip_get_passertedid_display_name(sip_header_value_t, + int *); +extern const sip_str_t *sip_get_passertedid_uri_str(sip_header_value_t, + int *); +extern const sip_str_t *sip_get_ppreferredid_display_name(sip_header_value_t, + int *); +extern const sip_str_t *sip_get_ppreferredid_uri_str(sip_header_value_t, + int *); +extern const sip_str_t *sip_get_priv_value(sip_header_value_t, int *); +extern int sip_get_rack_resp_num(sip_msg_t, int *); +extern int sip_get_rack_cseq_num(sip_msg_t, int *); +extern sip_method_t sip_get_rack_method(sip_msg_t, int *); +extern int sip_get_rseq_resp_num(sip_msg_t, int *); + +extern int sip_copy_start_line(sip_msg_t, sip_msg_t); +extern int sip_delete_start_line(sip_msg_t sip_msg); +extern int sip_copy_header(sip_msg_t, sip_header_t, char *); +extern int sip_copy_header_by_name(sip_msg_t, sip_msg_t, char *, + char *); +extern int sip_copy_all_headers(sip_msg_t, sip_msg_t); +extern int sip_delete_header_by_name(sip_msg_t, char *); +extern int sip_add_header(sip_msg_t, char *); +extern sip_header_t sip_add_param(sip_header_t, char *, int *); +extern int sip_delete_header(sip_header_t); +extern int sip_delete_value(sip_header_t, sip_header_value_t); +extern sip_msg_t sip_clone_msg(const sip_msg_t); +extern sip_msg_t sip_create_response(const sip_msg_t, int, char *, + char *, char *); +extern int sip_create_OKack(const sip_msg_t, sip_msg_t, char *, + char *, int, char *); +extern char *sip_get_resp_desc(int); +extern char *sip_get_branchid(const sip_msg_t, int *); + +extern const struct sip_header *sip_get_header(sip_msg_t, char *, sip_header_t, + int *); +extern const struct sip_value *sip_get_header_value( + const struct sip_header *, int *); +extern const struct sip_value *sip_get_next_value(sip_header_value_t, int *); +extern const sip_str_t *sip_get_param_value(sip_header_value_t, + char *, int *); +extern const sip_param_t *sip_get_params(sip_header_value_t, int *); +extern boolean_t sip_is_param_present(const sip_param_t *, + char *, int); + +extern char *sip_msg_to_str(sip_msg_t, int *); +extern char *sip_hdr_to_str(sip_header_t, int *); +extern char *sip_reqline_to_str(sip_msg_t, int *); +extern char *sip_respline_to_str(sip_msg_t, int *); +extern boolean_t sip_msg_is_request(const sip_msg_t, int *); +extern boolean_t sip_msg_is_response(const sip_msg_t, int *); +extern sip_method_t sip_get_request_method(const sip_msg_t, int *); +extern const sip_str_t *sip_get_request_uri_str(sip_msg_t, int *); +extern int sip_get_response_code(sip_msg_t, int *); +extern const sip_str_t *sip_get_response_phrase(sip_msg_t, int *); +extern const sip_str_t *sip_get_sip_version(sip_msg_t, int *); +extern int sip_get_msg_len(sip_msg_t, int *); +extern const sip_str_t *sip_get_route_uri_str(sip_header_value_t, int *); +extern const sip_str_t *sip_get_route_display_name(sip_header_value_t, int *); +extern const sip_str_t *sip_get_contact_uri_str(sip_header_value_t, int *); +extern const sip_str_t *sip_get_contact_display_name(sip_header_value_t, + int *); +extern const sip_str_t *sip_get_from_uri_str(sip_msg_t, int *); +extern const sip_str_t *sip_get_from_display_name(sip_msg_t, int *); +extern const sip_str_t *sip_get_from_tag(sip_msg_t, int *); +extern const sip_str_t *sip_get_to_uri_str(sip_msg_t, int *); +extern const sip_str_t *sip_get_to_display_name(sip_msg_t, int *); +extern const sip_str_t *sip_get_to_tag(sip_msg_t, int *); +extern const sip_str_t *sip_get_callid(sip_msg_t, int *); +extern int sip_get_callseq_num(sip_msg_t, int *); +extern sip_method_t sip_get_callseq_method(sip_msg_t, int *); +extern const sip_str_t *sip_get_via_sent_by_host(sip_header_value_t, int *); +extern int sip_get_via_sent_by_port(sip_header_value_t, int *); +extern const sip_str_t *sip_get_via_sent_protocol_version(sip_header_value_t, + int *); +extern const sip_str_t *sip_get_via_sent_protocol_name(sip_header_value_t, + int *); +extern const sip_str_t *sip_get_via_sent_transport(sip_header_value_t, + int *); +extern int sip_get_maxforward(sip_msg_t, int *); +extern int sip_get_content_length(sip_msg_t, int *); +extern const sip_str_t *sip_get_content_type(sip_msg_t, int *); +extern const sip_str_t *sip_get_content_sub_type(sip_msg_t, int *); +extern char *sip_get_content(sip_msg_t, int *); +extern sip_msg_t sip_create_dialog_req(sip_method_t, sip_dialog_t, + char *, char *, int, char *, uint32_t, int); +extern sip_msg_t sip_create_dialog_req_nocontact(sip_method_t, + sip_dialog_t, char *, char *, int, char *, + uint32_t, int); +extern int sip_get_dialog_state(sip_dialog_t, int *); +extern int sip_get_dialog_method(sip_dialog_t, int *); +extern int sip_get_dialog_msgcnt(sip_dialog_t, int *); +extern const sip_str_t *sip_get_dialog_callid(sip_dialog_t, int *); +extern const sip_str_t *sip_get_dialog_local_tag(sip_dialog_t, int *); +extern const sip_str_t *sip_get_dialog_remote_tag(sip_dialog_t, int *); +extern const struct sip_uri *sip_get_dialog_local_uri(sip_dialog_t, int *); +extern const struct sip_uri *sip_get_dialog_remote_uri(sip_dialog_t, int *); +extern const struct sip_uri *sip_get_dialog_remote_target_uri(sip_dialog_t, + int *); +extern const struct sip_uri *sip_get_dialog_local_contact_uri(sip_dialog_t, + int *); +extern const sip_str_t *sip_get_dialog_route_set(sip_dialog_t, int *); +extern boolean_t sip_is_dialog_secure(sip_dialog_t, int *); +extern uint32_t sip_get_dialog_local_cseq(sip_dialog_t, int *); +extern uint32_t sip_get_dialog_remote_cseq(sip_dialog_t, int *); +extern int sip_get_dialog_type(sip_dialog_t dialog, int *); + +extern void sip_hold_dialog(sip_dialog_t); +extern void sip_release_dialog(sip_dialog_t); +extern void sip_delete_dialog(sip_dialog_t); + +extern sip_uri_t sip_parse_uri(sip_str_t *, int *); +extern void sip_free_parsed_uri(sip_uri_t); +extern boolean_t sip_is_sipuri(const struct sip_uri *); +extern const sip_str_t *sip_get_uri_scheme(const struct sip_uri *, + int *); +extern const sip_str_t *sip_get_uri_user(const struct sip_uri *, + int *); +extern const sip_str_t *sip_get_uri_password(const struct sip_uri *, + int *); +extern const sip_str_t *sip_get_uri_host(const struct sip_uri *, + int *); +extern int sip_get_uri_port(const struct sip_uri *, + int *error); +extern const sip_param_t *sip_get_uri_params(const struct sip_uri *, + int *); +extern const sip_str_t *sip_get_uri_headers(const struct sip_uri *, + int *); +extern const sip_str_t *sip_get_uri_opaque(const struct sip_uri *, + int *); +extern const sip_str_t *sip_get_uri_query(const struct sip_uri *, + int *); +extern const sip_str_t *sip_get_uri_path(const struct sip_uri *, + int *); +extern const sip_str_t *sip_get_uri_regname(const struct sip_uri *, + int *); +extern boolean_t sip_is_uri_teluser(const struct sip_uri *); +extern int sip_get_uri_errflags(const struct sip_uri *, + int *); +extern char *sip_uri_errflags_to_str(int); + +extern const struct sip_uri *sip_get_request_uri(sip_msg_t, int *); +extern const struct sip_uri *sip_get_uri_parsed(sip_header_value_t, int *); + +/* Transaction functions */ +extern const struct sip_xaction *sip_get_trans(sip_msg_t, int, int *); +extern char *sip_get_trans_branchid(sip_transaction_t, + int *); +extern sip_method_t sip_get_trans_method(sip_transaction_t, + int *); +extern int sip_get_trans_state(sip_transaction_t, int *); +extern const struct sip_message *sip_get_trans_resp_msg(sip_transaction_t, + int *); +extern const struct sip_message *sip_get_trans_orig_msg(sip_transaction_t, + int *); +extern void sip_hold_trans(sip_transaction_t); +extern void sip_release_trans(sip_transaction_t); +extern const struct sip_conn_object *sip_get_trans_conn_obj( + sip_transaction_t, int *); + +/* Logging functions */ +extern int sip_enable_trans_logging(FILE *, int); +extern int sip_enable_dialog_logging(FILE *, int); +extern void sip_disable_trans_logging(); +extern void sip_disable_dialog_logging(); + +/* Traffic measurement functions */ +extern int sip_get_counter_value(int, int, void *, size_t); +extern int sip_enable_counters(int); +extern int sip_disable_counters(int); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SIP_H */ diff --git a/illumos-x86_64/usr/include/skein.h b/illumos-x86_64/usr/include/skein.h new file mode 100644 index 00000000..f341b967 --- /dev/null +++ b/illumos-x86_64/usr/include/skein.h @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2013 Saso Kiselkov. All rights reserved. + */ + +#ifndef _SKEIN_H +#define _SKEIN_H + +#include + +#endif /* _SKEIN_H */ diff --git a/illumos-x86_64/usr/include/smbios.h b/illumos-x86_64/usr/include/smbios.h new file mode 100644 index 00000000..43d47760 --- /dev/null +++ b/illumos-x86_64/usr/include/smbios.h @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SMBIOS_H +#define _SMBIOS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This header file defines the interfaces available from the SMBIOS access + * library, libsmbios, and an equivalent kernel module. This API can be used + * to access DMTF SMBIOS data from a device, file, or raw memory buffer. + * This is NOT yet a public interface, although it may eventually become one in + * the fullness of time after we gain more experience with the interfaces. + * + * In the meantime, be aware that any program linked with this API in this + * release of Solaris is almost guaranteed to break in the next release. + * + * In short, do not user this header file or these routines for any purpose. + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SMBIOS_H */ diff --git a/illumos-x86_64/usr/include/spawn.h b/illumos-x86_64/usr/include/spawn.h new file mode 100644 index 00000000..a2f40851 --- /dev/null +++ b/illumos-x86_64/usr/include/spawn.h @@ -0,0 +1,217 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2011 by Delphix. All rights reserved. + */ + +#ifndef _SPAWN_H +#define _SPAWN_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * flags for posix_spawnattr_setflags() + */ +#define POSIX_SPAWN_RESETIDS 0x0001 +#define POSIX_SPAWN_SETPGROUP 0x0002 +#define POSIX_SPAWN_SETSIGDEF 0x0004 +#define POSIX_SPAWN_SETSIGMASK 0x0008 +#define POSIX_SPAWN_SETSCHEDPARAM 0x0010 +#define POSIX_SPAWN_SETSCHEDULER 0x0020 +#define POSIX_SPAWN_SETSID 0x0040 +/* + * non-portable extensions + */ +#if !defined(_STRICT_POSIX) +#define POSIX_SPAWN_SETSIGIGN_NP 0x0800 +#define POSIX_SPAWN_NOSIGCHLD_NP 0x1000 +#define POSIX_SPAWN_WAITPID_NP 0x2000 +#define POSIX_SPAWN_NOEXECERR_NP 0x4000 +#endif /* !_STRICT_POSIX */ + +typedef struct { + void *__spawn_attrp; /* implementation-private */ +} posix_spawnattr_t; + +typedef struct { + void *__file_attrp; /* implementation-private */ +} posix_spawn_file_actions_t; + +extern int posix_spawn( + pid_t *_RESTRICT_KYWD pid, + const char *_RESTRICT_KYWD path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *_RESTRICT_KYWD attrp, + char *const *_RESTRICT_KYWD argv, + char *const *_RESTRICT_KYWD envp); + +extern int posix_spawnp( + pid_t *_RESTRICT_KYWD pid, + const char *_RESTRICT_KYWD file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *_RESTRICT_KYWD attrp, + char *const *_RESTRICT_KYWD argv, + char *const *_RESTRICT_KYWD envp); + +extern int posix_spawn_file_actions_init( + posix_spawn_file_actions_t *file_actions); + +extern int posix_spawn_file_actions_destroy( + posix_spawn_file_actions_t *file_actions); + +extern int posix_spawn_file_actions_addchdir( + posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions, + const char *_RESTRICT_KYWD path); + +extern int posix_spawn_file_actions_addopen( + posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions, + int filedes, + const char *_RESTRICT_KYWD path, + int oflag, + mode_t mode); + +extern int posix_spawn_file_actions_addclose( + posix_spawn_file_actions_t *file_actions, + int filedes); + +extern int posix_spawn_file_actions_adddup2( + posix_spawn_file_actions_t *file_actions, + int filedes, + int newfiledes); + +extern int posix_spawn_file_actions_addfchdir( + posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions, + int fd); + +extern int posix_spawnattr_init( + posix_spawnattr_t *attr); + +extern int posix_spawnattr_destroy( + posix_spawnattr_t *attr); + +extern int posix_spawnattr_setflags( + posix_spawnattr_t *attr, + short flags); + +extern int posix_spawnattr_getflags( + const posix_spawnattr_t *_RESTRICT_KYWD attr, + short *_RESTRICT_KYWD flags); + +extern int posix_spawnattr_setpgroup( + posix_spawnattr_t *attr, + pid_t pgroup); + +extern int posix_spawnattr_getpgroup( + const posix_spawnattr_t *_RESTRICT_KYWD attr, + pid_t *_RESTRICT_KYWD pgroup); + +extern int posix_spawnattr_setschedparam( + posix_spawnattr_t *_RESTRICT_KYWD attr, + const struct sched_param *_RESTRICT_KYWD schedparam); + +extern int posix_spawnattr_getschedparam( + const posix_spawnattr_t *_RESTRICT_KYWD attr, + struct sched_param *_RESTRICT_KYWD schedparam); + +extern int posix_spawnattr_setschedpolicy( + posix_spawnattr_t *attr, + int schedpolicy); + +extern int posix_spawnattr_getschedpolicy( + const posix_spawnattr_t *_RESTRICT_KYWD attr, + int *_RESTRICT_KYWD schedpolicy); + +extern int posix_spawnattr_setsigdefault( + posix_spawnattr_t *_RESTRICT_KYWD attr, + const sigset_t *_RESTRICT_KYWD sigdefault); + +extern int posix_spawnattr_getsigdefault( + const posix_spawnattr_t *_RESTRICT_KYWD attr, + sigset_t *_RESTRICT_KYWD sigdefault); + +/* + * non-portable extensions + */ +#if !defined(_STRICT_POSIX) + +extern int posix_spawn_pipe_np( + pid_t *_RESTRICT_KYWD pidp, + int *_RESTRICT_KYWD fdp, + const char *_RESTRICT_KYWD cmd, + boolean_t write, + posix_spawn_file_actions_t *_RESTRICT_KYWD fact, + posix_spawnattr_t *_RESTRICT_KYWD attr); + +extern int posix_spawn_file_actions_addclosefrom_np( + posix_spawn_file_actions_t *file_actions, + int lowfiledes); + +extern int posix_spawnattr_setsigignore_np( + posix_spawnattr_t *_RESTRICT_KYWD attr, + const sigset_t *_RESTRICT_KYWD sigignore); + +extern int posix_spawnattr_getsigignore_np( + const posix_spawnattr_t *_RESTRICT_KYWD attr, + sigset_t *_RESTRICT_KYWD sigignore); + +/* + * These _np variants are not documented in the manual, but are provided for + * compatibility purposes with folks who have implemented this prior to + * standardization in POSIX 2024. + */ +extern int posix_spawn_file_actions_addchdir_np( + posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions, + const char *_RESTRICT_KYWD path); + +extern int posix_spawn_file_actions_addfchdir_np( + posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions, + int fd); + +#endif /* !_STRICT_POSIX */ + +extern int posix_spawnattr_setsigmask( + posix_spawnattr_t *_RESTRICT_KYWD attr, + const sigset_t *_RESTRICT_KYWD sigmask); + +extern int posix_spawnattr_getsigmask( + const posix_spawnattr_t *_RESTRICT_KYWD attr, + sigset_t *_RESTRICT_KYWD sigmask); + +#ifdef __cplusplus +} +#endif + +#endif /* _SPAWN_H */ diff --git a/illumos-x86_64/usr/include/sqlite3.h b/illumos-x86_64/usr/include/sqlite3.h new file mode 100644 index 00000000..c2ed7503 --- /dev/null +++ b/illumos-x86_64/usr/include/sqlite3.h @@ -0,0 +1,13775 @@ +/* +** 2001-09-15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the interface that the SQLite library +** presents to client programs. If a C-function, structure, datatype, +** or constant definition does not appear in this file, then it is +** not a published API of SQLite, is subject to change without +** notice, and should not be referenced by programs that use SQLite. +** +** Some of the definitions that are in this file are marked as +** "experimental". Experimental interfaces are normally new +** features recently added to SQLite. We do not anticipate changes +** to experimental interfaces but reserve the right to make minor changes +** if experience from use "in the wild" suggest such changes are prudent. +** +** The official C-language API documentation for SQLite is derived +** from comments in this file. This file is the authoritative source +** on how SQLite interfaces are supposed to operate. +** +** The name of this file under configuration management is "sqlite.h.in". +** The makefile makes some minor changes to this file (such as inserting +** the version number) and changes its name to "sqlite3.h" as +** part of the build process. +*/ +#ifndef SQLITE3_H +#define SQLITE3_H +#include /* Needed for the definition of va_list */ + +/* +** Make sure we can call this stuff from C++. +*/ +#ifdef __cplusplus +extern "C" { +#endif + + +/* +** Facilitate override of interface linkage and calling conventions. +** Be aware that these macros may not be used within this particular +** translation of the amalgamation and its associated header file. +** +** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the +** compiler that the target identifier should have external linkage. +** +** The SQLITE_CDECL macro is used to set the calling convention for +** public functions that accept a variable number of arguments. +** +** The SQLITE_APICALL macro is used to set the calling convention for +** public functions that accept a fixed number of arguments. +** +** The SQLITE_STDCALL macro is no longer used and is now deprecated. +** +** The SQLITE_CALLBACK macro is used to set the calling convention for +** function pointers. +** +** The SQLITE_SYSAPI macro is used to set the calling convention for +** functions provided by the operating system. +** +** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and +** SQLITE_SYSAPI macros are used only when building for environments +** that require non-default calling conventions. +*/ +#ifndef SQLITE_EXTERN +# define SQLITE_EXTERN extern +#endif +#ifndef SQLITE_API +# define SQLITE_API +#endif +#ifndef SQLITE_CDECL +# define SQLITE_CDECL +#endif +#ifndef SQLITE_APICALL +# define SQLITE_APICALL +#endif +#ifndef SQLITE_STDCALL +# define SQLITE_STDCALL SQLITE_APICALL +#endif +#ifndef SQLITE_CALLBACK +# define SQLITE_CALLBACK +#endif +#ifndef SQLITE_SYSAPI +# define SQLITE_SYSAPI +#endif + +/* +** These no-op macros are used in front of interfaces to mark those +** interfaces as either deprecated or experimental. New applications +** should not use deprecated interfaces - they are supported for backwards +** compatibility only. Application writers should be aware that +** experimental interfaces are subject to change in point releases. +** +** These macros used to resolve to various kinds of compiler magic that +** would generate warning messages when they were used. But that +** compiler magic ended up generating such a flurry of bug reports +** that we have taken it all out and gone back to using simple +** noop macros. +*/ +#define SQLITE_DEPRECATED +#define SQLITE_EXPERIMENTAL + +/* +** Ensure these symbols were not defined by some previous header file. +*/ +#ifdef SQLITE_VERSION +# undef SQLITE_VERSION +#endif +#ifdef SQLITE_VERSION_NUMBER +# undef SQLITE_VERSION_NUMBER +#endif + +/* +** CAPI3REF: Compile-Time Library Version Numbers +** +** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header +** evaluates to a string literal that is the SQLite version in the +** format "X.Y.Z" where X is the major version number (always 3 for +** SQLite3) and Y is the minor version number and Z is the release number.)^ +** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer +** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same +** numbers used in [SQLITE_VERSION].)^ +** The SQLITE_VERSION_NUMBER for any given release of SQLite will also +** be larger than the release from which it is derived. Either Y will +** be held constant and Z will be incremented or else Y will be incremented +** and Z will be reset to zero. +** +** Since [version 3.6.18] ([dateof:3.6.18]), +** SQLite source code has been stored in the +** Fossil configuration management +** system. ^The SQLITE_SOURCE_ID macro evaluates to +** a string which identifies a particular check-in of SQLite +** within its configuration management system. ^The SQLITE_SOURCE_ID +** string contains the date and time of the check-in (UTC) and a SHA1 +** or SHA3-256 hash of the entire source tree. If the source code has +** been edited in any way since it was last checked in, then the last +** four hexadecimal digits of the hash may be modified. +** +** See also: [sqlite3_libversion()], +** [sqlite3_libversion_number()], [sqlite3_sourceid()], +** [sqlite_version()] and [sqlite_source_id()]. +*/ +#define SQLITE_VERSION "3.50.4" +#define SQLITE_VERSION_NUMBER 3050004 +#define SQLITE_SOURCE_ID "2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45e20a3" + +/* +** CAPI3REF: Run-Time Library Version Numbers +** KEYWORDS: sqlite3_version sqlite3_sourceid +** +** These interfaces provide the same information as the [SQLITE_VERSION], +** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros +** but are associated with the library instead of the header file. ^(Cautious +** programmers might include assert() statements in their application to +** verify that values returned by these interfaces match the macros in +** the header, and thus ensure that the application is +** compiled with matching library and header files. +** +**
+** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
+** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
+** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
+** 
)^ +** +** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] +** macro. ^The sqlite3_libversion() function returns a pointer to the +** to the sqlite3_version[] string constant. The sqlite3_libversion() +** function is provided for use in DLLs since DLL users usually do not have +** direct access to string constants within the DLL. ^The +** sqlite3_libversion_number() function returns an integer equal to +** [SQLITE_VERSION_NUMBER]. ^(The sqlite3_sourceid() function returns +** a pointer to a string constant whose value is the same as the +** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built +** using an edited copy of [the amalgamation], then the last four characters +** of the hash might be different from [SQLITE_SOURCE_ID].)^ +** +** See also: [sqlite_version()] and [sqlite_source_id()]. +*/ +SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; +SQLITE_API const char *sqlite3_libversion(void); +SQLITE_API const char *sqlite3_sourceid(void); +SQLITE_API int sqlite3_libversion_number(void); + +/* +** CAPI3REF: Run-Time Library Compilation Options Diagnostics +** +** ^The sqlite3_compileoption_used() function returns 0 or 1 +** indicating whether the specified option was defined at +** compile time. ^The SQLITE_ prefix may be omitted from the +** option name passed to sqlite3_compileoption_used(). +** +** ^The sqlite3_compileoption_get() function allows iterating +** over the list of options that were defined at compile time by +** returning the N-th compile time option string. ^If N is out of range, +** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ +** prefix is omitted from any strings returned by +** sqlite3_compileoption_get(). +** +** ^Support for the diagnostic functions sqlite3_compileoption_used() +** and sqlite3_compileoption_get() may be omitted by specifying the +** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. +** +** See also: SQL functions [sqlite_compileoption_used()] and +** [sqlite_compileoption_get()] and the [compile_options pragma]. +*/ +#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS +SQLITE_API int sqlite3_compileoption_used(const char *zOptName); +SQLITE_API const char *sqlite3_compileoption_get(int N); +#else +# define sqlite3_compileoption_used(X) 0 +# define sqlite3_compileoption_get(X) ((void*)0) +#endif + +/* +** CAPI3REF: Test To See If The Library Is Threadsafe +** +** ^The sqlite3_threadsafe() function returns zero if and only if +** SQLite was compiled with mutexing code omitted due to the +** [SQLITE_THREADSAFE] compile-time option being set to 0. +** +** SQLite can be compiled with or without mutexes. When +** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes +** are enabled and SQLite is threadsafe. When the +** [SQLITE_THREADSAFE] macro is 0, +** the mutexes are omitted. Without the mutexes, it is not safe +** to use SQLite concurrently from more than one thread. +** +** Enabling mutexes incurs a measurable performance penalty. +** So if speed is of utmost importance, it makes sense to disable +** the mutexes. But for maximum safety, mutexes should be enabled. +** ^The default behavior is for mutexes to be enabled. +** +** This interface can be used by an application to make sure that the +** version of SQLite that it is linking against was compiled with +** the desired setting of the [SQLITE_THREADSAFE] macro. +** +** This interface only reports on the compile-time mutex setting +** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with +** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but +** can be fully or partially disabled using a call to [sqlite3_config()] +** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], +** or [SQLITE_CONFIG_SERIALIZED]. ^(The return value of the +** sqlite3_threadsafe() function shows only the compile-time setting of +** thread safety, not any run-time changes to that setting made by +** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() +** is unchanged by calls to sqlite3_config().)^ +** +** See the [threading mode] documentation for additional information. +*/ +SQLITE_API int sqlite3_threadsafe(void); + +/* +** CAPI3REF: Database Connection Handle +** KEYWORDS: {database connection} {database connections} +** +** Each open SQLite database is represented by a pointer to an instance of +** the opaque structure named "sqlite3". It is useful to think of an sqlite3 +** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and +** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] +** and [sqlite3_close_v2()] are its destructors. There are many other +** interfaces (such as +** [sqlite3_prepare_v2()], [sqlite3_create_function()], and +** [sqlite3_busy_timeout()] to name but three) that are methods on an +** sqlite3 object. +*/ +typedef struct sqlite3 sqlite3; + +/* +** CAPI3REF: 64-Bit Integer Types +** KEYWORDS: sqlite_int64 sqlite_uint64 +** +** Because there is no cross-platform way to specify 64-bit integer types +** SQLite includes typedefs for 64-bit signed and unsigned integers. +** +** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. +** The sqlite_int64 and sqlite_uint64 types are supported for backwards +** compatibility only. +** +** ^The sqlite3_int64 and sqlite_int64 types can store integer values +** between -9223372036854775808 and +9223372036854775807 inclusive. ^The +** sqlite3_uint64 and sqlite_uint64 types can store integer values +** between 0 and +18446744073709551615 inclusive. +*/ +#ifdef SQLITE_INT64_TYPE + typedef SQLITE_INT64_TYPE sqlite_int64; +# ifdef SQLITE_UINT64_TYPE + typedef SQLITE_UINT64_TYPE sqlite_uint64; +# else + typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; +# endif +#elif defined(_MSC_VER) || defined(__BORLANDC__) + typedef __int64 sqlite_int64; + typedef unsigned __int64 sqlite_uint64; +#else + typedef long long int sqlite_int64; + typedef unsigned long long int sqlite_uint64; +#endif +typedef sqlite_int64 sqlite3_int64; +typedef sqlite_uint64 sqlite3_uint64; + +/* +** If compiling for a processor that lacks floating point support, +** substitute integer for floating-point. +*/ +#ifdef SQLITE_OMIT_FLOATING_POINT +# define double sqlite3_int64 +#endif + +/* +** CAPI3REF: Closing A Database Connection +** DESTRUCTOR: sqlite3 +** +** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors +** for the [sqlite3] object. +** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if +** the [sqlite3] object is successfully destroyed and all associated +** resources are deallocated. +** +** Ideally, applications should [sqlite3_finalize | finalize] all +** [prepared statements], [sqlite3_blob_close | close] all [BLOB handles], and +** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated +** with the [sqlite3] object prior to attempting to close the object. +** ^If the database connection is associated with unfinalized prepared +** statements, BLOB handlers, and/or unfinished sqlite3_backup objects then +** sqlite3_close() will leave the database connection open and return +** [SQLITE_BUSY]. ^If sqlite3_close_v2() is called with unfinalized prepared +** statements, unclosed BLOB handlers, and/or unfinished sqlite3_backups, +** it returns [SQLITE_OK] regardless, but instead of deallocating the database +** connection immediately, it marks the database connection as an unusable +** "zombie" and makes arrangements to automatically deallocate the database +** connection after all prepared statements are finalized, all BLOB handles +** are closed, and all backups have finished. The sqlite3_close_v2() interface +** is intended for use with host languages that are garbage collected, and +** where the order in which destructors are called is arbitrary. +** +** ^If an [sqlite3] object is destroyed while a transaction is open, +** the transaction is automatically rolled back. +** +** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)] +** must be either a NULL +** pointer or an [sqlite3] object pointer obtained +** from [sqlite3_open()], [sqlite3_open16()], or +** [sqlite3_open_v2()], and not previously closed. +** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer +** argument is a harmless no-op. +*/ +SQLITE_API int sqlite3_close(sqlite3*); +SQLITE_API int sqlite3_close_v2(sqlite3*); + +/* +** The type for a callback function. +** This is legacy and deprecated. It is included for historical +** compatibility and is not documented. +*/ +typedef int (*sqlite3_callback)(void*,int,char**, char**); + +/* +** CAPI3REF: One-Step Query Execution Interface +** METHOD: sqlite3 +** +** The sqlite3_exec() interface is a convenience wrapper around +** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], +** that allows an application to run multiple statements of SQL +** without having to use a lot of C code. +** +** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, +** semicolon-separate SQL statements passed into its 2nd argument, +** in the context of the [database connection] passed in as its 1st +** argument. ^If the callback function of the 3rd argument to +** sqlite3_exec() is not NULL, then it is invoked for each result row +** coming out of the evaluated SQL statements. ^The 4th argument to +** sqlite3_exec() is relayed through to the 1st argument of each +** callback invocation. ^If the callback pointer to sqlite3_exec() +** is NULL, then no callback is ever invoked and result rows are +** ignored. +** +** ^If an error occurs while evaluating the SQL statements passed into +** sqlite3_exec(), then execution of the current statement stops and +** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() +** is not NULL then any error message is written into memory obtained +** from [sqlite3_malloc()] and passed back through the 5th parameter. +** To avoid memory leaks, the application should invoke [sqlite3_free()] +** on error message strings returned through the 5th parameter of +** sqlite3_exec() after the error message string is no longer needed. +** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors +** occur, then sqlite3_exec() sets the pointer in its 5th parameter to +** NULL before returning. +** +** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() +** routine returns SQLITE_ABORT without invoking the callback again and +** without running any subsequent SQL statements. +** +** ^The 2nd argument to the sqlite3_exec() callback function is the +** number of columns in the result. ^The 3rd argument to the sqlite3_exec() +** callback is an array of pointers to strings obtained as if from +** [sqlite3_column_text()], one for each column. ^If an element of a +** result row is NULL then the corresponding string pointer for the +** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the +** sqlite3_exec() callback is an array of pointers to strings where each +** entry represents the name of corresponding result column as obtained +** from [sqlite3_column_name()]. +** +** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer +** to an empty string, or a pointer that contains only whitespace and/or +** SQL comments, then no SQL statements are evaluated and the database +** is not changed. +** +** Restrictions: +** +**
    +**
  • The application must ensure that the 1st parameter to sqlite3_exec() +** is a valid and open [database connection]. +**
  • The application must not close the [database connection] specified by +** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. +**
  • The application must not modify the SQL statement text passed into +** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. +**
  • The application must not dereference the arrays or string pointers +** passed as the 3rd and 4th callback parameters after it returns. +**
+*/ +SQLITE_API int sqlite3_exec( + sqlite3*, /* An open database */ + const char *sql, /* SQL to be evaluated */ + int (*callback)(void*,int,char**,char**), /* Callback function */ + void *, /* 1st argument to callback */ + char **errmsg /* Error msg written here */ +); + +/* +** CAPI3REF: Result Codes +** KEYWORDS: {result code definitions} +** +** Many SQLite functions return an integer result code from the set shown +** here in order to indicate success or failure. +** +** New error codes may be added in future versions of SQLite. +** +** See also: [extended result code definitions] +*/ +#define SQLITE_OK 0 /* Successful result */ +/* beginning-of-error-codes */ +#define SQLITE_ERROR 1 /* Generic error */ +#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ +#define SQLITE_PERM 3 /* Access permission denied */ +#define SQLITE_ABORT 4 /* Callback routine requested an abort */ +#define SQLITE_BUSY 5 /* The database file is locked */ +#define SQLITE_LOCKED 6 /* A table in the database is locked */ +#define SQLITE_NOMEM 7 /* A malloc() failed */ +#define SQLITE_READONLY 8 /* Attempt to write a readonly database */ +#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ +#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ +#define SQLITE_CORRUPT 11 /* The database disk image is malformed */ +#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ +#define SQLITE_FULL 13 /* Insertion failed because database is full */ +#define SQLITE_CANTOPEN 14 /* Unable to open the database file */ +#define SQLITE_PROTOCOL 15 /* Database lock protocol error */ +#define SQLITE_EMPTY 16 /* Internal use only */ +#define SQLITE_SCHEMA 17 /* The database schema changed */ +#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ +#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ +#define SQLITE_MISMATCH 20 /* Data type mismatch */ +#define SQLITE_MISUSE 21 /* Library used incorrectly */ +#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ +#define SQLITE_AUTH 23 /* Authorization denied */ +#define SQLITE_FORMAT 24 /* Not used */ +#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ +#define SQLITE_NOTADB 26 /* File opened that is not a database file */ +#define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */ +#define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */ +#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ +#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ +/* end-of-error-codes */ + +/* +** CAPI3REF: Extended Result Codes +** KEYWORDS: {extended result code definitions} +** +** In its default configuration, SQLite API routines return one of 30 integer +** [result codes]. However, experience has shown that many of +** these result codes are too coarse-grained. They do not provide as +** much information about problems as programmers might like. In an effort to +** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8] +** and later) include +** support for additional result codes that provide more detailed information +** about errors. These [extended result codes] are enabled or disabled +** on a per database connection basis using the +** [sqlite3_extended_result_codes()] API. Or, the extended code for +** the most recent error can be obtained using +** [sqlite3_extended_errcode()]. +*/ +#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8)) +#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8)) +#define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8)) +#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) +#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) +#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) +#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) +#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) +#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) +#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) +#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) +#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) +#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) +#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) +#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) +#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) +#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) +#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) +#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) +#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) +#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) +#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) +#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) +#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) +#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) +#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) +#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) +#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) +#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) +#define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8)) +#define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8)) +#define SQLITE_IOERR_BEGIN_ATOMIC (SQLITE_IOERR | (29<<8)) +#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8)) +#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) +#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8)) +#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8)) +#define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8)) +#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) +#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8)) +#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) +#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) +#define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8)) +#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) +#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) +#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) +#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) +#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */ +#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8)) +#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) +#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8)) +#define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8)) +#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) +#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) +#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8)) +#define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8)) +#define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8)) +#define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6<<8)) +#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8)) +#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8)) +#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8)) +#define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8)) +#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8)) +#define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8)) +#define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8)) +#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) +#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) +#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) +#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) +#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8)) +#define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8)) +#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) +#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) +#define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8)) +#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) +#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) +#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) +#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */ + +/* +** CAPI3REF: Flags For File Open Operations +** +** These bit values are intended for use in the +** 3rd parameter to the [sqlite3_open_v2()] interface and +** in the 4th parameter to the [sqlite3_vfs.xOpen] method. +** +** Only those flags marked as "Ok for sqlite3_open_v2()" may be +** used as the third argument to the [sqlite3_open_v2()] interface. +** The other flags have historically been ignored by sqlite3_open_v2(), +** though future versions of SQLite might change so that an error is +** raised if any of the disallowed bits are passed into sqlite3_open_v2(). +** Applications should not depend on the historical behavior. +** +** Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into +** [sqlite3_open_v2()] does *not* cause the underlying database file +** to be opened using O_EXCL. Passing SQLITE_OPEN_EXCLUSIVE into +** [sqlite3_open_v2()] has historically be a no-op and might become an +** error in future versions of SQLite. +*/ +#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ +#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ +#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ +#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ +#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ +#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ +#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ +#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ +#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ +#define SQLITE_OPEN_SUPER_JOURNAL 0x00004000 /* VFS only */ +#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ +#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */ + +/* Reserved: 0x00F00000 */ +/* Legacy compatibility: */ +#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ + + +/* +** CAPI3REF: Device Characteristics +** +** The xDeviceCharacteristics method of the [sqlite3_io_methods] +** object returns an integer which is a vector of these +** bit values expressing I/O characteristics of the mass storage +** device that holds the file that the [sqlite3_io_methods] +** refers to. +** +** The SQLITE_IOCAP_ATOMIC property means that all writes of +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values +** mean that writes of blocks that are nnn bytes in size and +** are aligned to an address which is an integer multiple of +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means +** that when data is appended to a file, the data is appended +** first then the size of the file is extended, never the other +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that +** information is written to disk in the same order as calls +** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that +** after reboot following a crash or power loss, the only bytes in a +** file that were written at the application level might have changed +** and that adjacent bytes, even bytes within the same sector are +** guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN +** flag indicates that a file cannot be deleted when open. The +** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on +** read-only media and cannot be changed even by processes with +** elevated privileges. +** +** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying +** filesystem supports doing multiple write operations atomically when those +** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and +** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. +** +** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read +** from the database file in amounts that are not a multiple of the +** page size and that do not begin at a page boundary. Without this +** property, SQLite is careful to only do full-page reads and write +** on aligned pages, with the one exception that it will do a sub-page +** read of the first page to access the database header. +*/ +#define SQLITE_IOCAP_ATOMIC 0x00000001 +#define SQLITE_IOCAP_ATOMIC512 0x00000002 +#define SQLITE_IOCAP_ATOMIC1K 0x00000004 +#define SQLITE_IOCAP_ATOMIC2K 0x00000008 +#define SQLITE_IOCAP_ATOMIC4K 0x00000010 +#define SQLITE_IOCAP_ATOMIC8K 0x00000020 +#define SQLITE_IOCAP_ATOMIC16K 0x00000040 +#define SQLITE_IOCAP_ATOMIC32K 0x00000080 +#define SQLITE_IOCAP_ATOMIC64K 0x00000100 +#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 +#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 +#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 +#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 +#define SQLITE_IOCAP_IMMUTABLE 0x00002000 +#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 +#define SQLITE_IOCAP_SUBPAGE_READ 0x00008000 + +/* +** CAPI3REF: File Locking Levels +** +** SQLite uses one of these integer values as the second +** argument to calls it makes to the xLock() and xUnlock() methods +** of an [sqlite3_io_methods] object. These values are ordered from +** lest restrictive to most restrictive. +** +** The argument to xLock() is always SHARED or higher. The argument to +** xUnlock is either SHARED or NONE. +*/ +#define SQLITE_LOCK_NONE 0 /* xUnlock() only */ +#define SQLITE_LOCK_SHARED 1 /* xLock() or xUnlock() */ +#define SQLITE_LOCK_RESERVED 2 /* xLock() only */ +#define SQLITE_LOCK_PENDING 3 /* xLock() only */ +#define SQLITE_LOCK_EXCLUSIVE 4 /* xLock() only */ + +/* +** CAPI3REF: Synchronization Type Flags +** +** When SQLite invokes the xSync() method of an +** [sqlite3_io_methods] object it uses a combination of +** these integer values as the second argument. +** +** When the SQLITE_SYNC_DATAONLY flag is used, it means that the +** sync operation only needs to flush data to mass storage. Inode +** information need not be flushed. If the lower four bits of the flag +** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. +** If the lower four bits equal SQLITE_SYNC_FULL, that means +** to use Mac OS X style fullsync instead of fsync(). +** +** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags +** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL +** settings. The [synchronous pragma] determines when calls to the +** xSync VFS method occur and applies uniformly across all platforms. +** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how +** energetic or rigorous or forceful the sync operations are and +** only make a difference on Mac OSX for the default SQLite code. +** (Third-party VFS implementations might also make the distinction +** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the +** operating systems natively supported by SQLite, only Mac OSX +** cares about the difference.) +*/ +#define SQLITE_SYNC_NORMAL 0x00002 +#define SQLITE_SYNC_FULL 0x00003 +#define SQLITE_SYNC_DATAONLY 0x00010 + +/* +** CAPI3REF: OS Interface Open File Handle +** +** An [sqlite3_file] object represents an open file in the +** [sqlite3_vfs | OS interface layer]. Individual OS interface +** implementations will +** want to subclass this object by appending additional fields +** for their own use. The pMethods entry is a pointer to an +** [sqlite3_io_methods] object that defines methods for performing +** I/O operations on the open file. +*/ +typedef struct sqlite3_file sqlite3_file; +struct sqlite3_file { + const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ +}; + +/* +** CAPI3REF: OS Interface File Virtual Methods Object +** +** Every file opened by the [sqlite3_vfs.xOpen] method populates an +** [sqlite3_file] object (or, more commonly, a subclass of the +** [sqlite3_file] object) with a pointer to an instance of this object. +** This object defines the methods used to perform various operations +** against the open file represented by the [sqlite3_file] object. +** +** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element +** to a non-NULL pointer, then the sqlite3_io_methods.xClose method +** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The +** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen] +** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element +** to NULL. +** +** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or +** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). +** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] +** flag may be ORed in to indicate that only the data of the file +** and not its inode needs to be synced. +** +** The integer values to xLock() and xUnlock() are one of +**
    +**
  • [SQLITE_LOCK_NONE], +**
  • [SQLITE_LOCK_SHARED], +**
  • [SQLITE_LOCK_RESERVED], +**
  • [SQLITE_LOCK_PENDING], or +**
  • [SQLITE_LOCK_EXCLUSIVE]. +**
+** xLock() upgrades the database file lock. In other words, xLock() moves the +** database file lock in the direction NONE toward EXCLUSIVE. The argument to +** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never +** SQLITE_LOCK_NONE. If the database file lock is already at or above the +** requested lock, then the call to xLock() is a no-op. +** xUnlock() downgrades the database file lock to either SHARED or NONE. +** If the lock is already at or below the requested lock state, then the call +** to xUnlock() is a no-op. +** The xCheckReservedLock() method checks whether any database connection, +** either in this process or in some other process, is holding a RESERVED, +** PENDING, or EXCLUSIVE lock on the file. It returns, via its output +** pointer parameter, true if such a lock exists and false otherwise. +** +** The xFileControl() method is a generic interface that allows custom +** VFS implementations to directly control an open file using the +** [sqlite3_file_control()] interface. The second "op" argument is an +** integer opcode. The third argument is a generic pointer intended to +** point to a structure that may contain arguments or space in which to +** write return values. Potential uses for xFileControl() might be +** functions to enable blocking locks with timeouts, to change the +** locking strategy (for example to use dot-file locks), to inquire +** about the status of a lock, or to break stale locks. The SQLite +** core reserves all opcodes less than 100 for its own use. +** A [file control opcodes | list of opcodes] less than 100 is available. +** Applications that define a custom xFileControl method should use opcodes +** greater than 100 to avoid conflicts. VFS implementations should +** return [SQLITE_NOTFOUND] for file control opcodes that they do not +** recognize. +** +** The xSectorSize() method returns the sector size of the +** device that underlies the file. The sector size is the +** minimum write that can be performed without disturbing +** other bytes in the file. The xDeviceCharacteristics() +** method returns a bit vector describing behaviors of the +** underlying device: +** +**
    +**
  • [SQLITE_IOCAP_ATOMIC] +**
  • [SQLITE_IOCAP_ATOMIC512] +**
  • [SQLITE_IOCAP_ATOMIC1K] +**
  • [SQLITE_IOCAP_ATOMIC2K] +**
  • [SQLITE_IOCAP_ATOMIC4K] +**
  • [SQLITE_IOCAP_ATOMIC8K] +**
  • [SQLITE_IOCAP_ATOMIC16K] +**
  • [SQLITE_IOCAP_ATOMIC32K] +**
  • [SQLITE_IOCAP_ATOMIC64K] +**
  • [SQLITE_IOCAP_SAFE_APPEND] +**
  • [SQLITE_IOCAP_SEQUENTIAL] +**
  • [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] +**
  • [SQLITE_IOCAP_POWERSAFE_OVERWRITE] +**
  • [SQLITE_IOCAP_IMMUTABLE] +**
  • [SQLITE_IOCAP_BATCH_ATOMIC] +**
  • [SQLITE_IOCAP_SUBPAGE_READ] +**
+** +** The SQLITE_IOCAP_ATOMIC property means that all writes of +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values +** mean that writes of blocks that are nnn bytes in size and +** are aligned to an address which is an integer multiple of +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means +** that when data is appended to a file, the data is appended +** first then the size of the file is extended, never the other +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that +** information is written to disk in the same order as calls +** to xWrite(). +** +** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill +** in the unread portions of the buffer with zeros. A VFS that +** fails to zero-fill short reads might seem to work. However, +** failure to zero-fill short reads will eventually lead to +** database corruption. +*/ +typedef struct sqlite3_io_methods sqlite3_io_methods; +struct sqlite3_io_methods { + int iVersion; + int (*xClose)(sqlite3_file*); + int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); + int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); + int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); + int (*xSync)(sqlite3_file*, int flags); + int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); + int (*xLock)(sqlite3_file*, int); + int (*xUnlock)(sqlite3_file*, int); + int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); + int (*xFileControl)(sqlite3_file*, int op, void *pArg); + int (*xSectorSize)(sqlite3_file*); + int (*xDeviceCharacteristics)(sqlite3_file*); + /* Methods above are valid for version 1 */ + int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**); + int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); + void (*xShmBarrier)(sqlite3_file*); + int (*xShmUnmap)(sqlite3_file*, int deleteFlag); + /* Methods above are valid for version 2 */ + int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); + int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p); + /* Methods above are valid for version 3 */ + /* Additional methods may be added in future releases */ +}; + +/* +** CAPI3REF: Standard File Control Opcodes +** KEYWORDS: {file control opcodes} {file control opcode} +** +** These integer constants are opcodes for the xFileControl method +** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] +** interface. +** +**
    +**
  • [[SQLITE_FCNTL_LOCKSTATE]] +** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This +** opcode causes the xFileControl method to write the current state of +** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], +** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) +** into an integer that the pArg argument points to. +** This capability is only available if SQLite is compiled with [SQLITE_DEBUG]. +** +**
  • [[SQLITE_FCNTL_SIZE_HINT]] +** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS +** layer a hint of how large the database file will grow to be during the +** current transaction. This hint is not guaranteed to be accurate but it +** is often close. The underlying VFS might choose to preallocate database +** file space based on this hint in order to help writes to the database +** file run faster. +** +**
  • [[SQLITE_FCNTL_SIZE_LIMIT]] +** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that +** implements [sqlite3_deserialize()] to set an upper bound on the size +** of the in-memory database. The argument is a pointer to a [sqlite3_int64]. +** If the integer pointed to is negative, then it is filled in with the +** current limit. Otherwise the limit is set to the larger of the value +** of the integer pointed to and the current database size. The integer +** pointed to is set to the new limit. +** +**
  • [[SQLITE_FCNTL_CHUNK_SIZE]] +** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS +** extends and truncates the database file in chunks of a size specified +** by the user. The fourth argument to [sqlite3_file_control()] should +** point to an integer (type int) containing the new chunk-size to use +** for the nominated database. Allocating database file space in large +** chunks (say 1MB at a time), may reduce file-system fragmentation and +** improve performance on some systems. +** +**
  • [[SQLITE_FCNTL_FILE_POINTER]] +** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer +** to the [sqlite3_file] object associated with a particular database +** connection. See also [SQLITE_FCNTL_JOURNAL_POINTER]. +** +**
  • [[SQLITE_FCNTL_JOURNAL_POINTER]] +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer +** to the [sqlite3_file] object associated with the journal file (either +** the [rollback journal] or the [write-ahead log]) for a particular database +** connection. See also [SQLITE_FCNTL_FILE_POINTER]. +** +**
  • [[SQLITE_FCNTL_SYNC_OMITTED]] +** No longer in use. +** +**
  • [[SQLITE_FCNTL_SYNC]] +** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and +** sent to the VFS immediately before the xSync method is invoked on a +** database file descriptor. Or, if the xSync method is not invoked +** because the user has configured SQLite with +** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place +** of the xSync method. In most cases, the pointer argument passed with +** this file-control is NULL. However, if the database file is being synced +** as part of a multi-database commit, the argument points to a nul-terminated +** string containing the transactions super-journal file name. VFSes that +** do not need this signal should silently ignore this opcode. Applications +** should not call [sqlite3_file_control()] with this opcode as doing so may +** disrupt the operation of the specialized VFSes that do require it. +** +**
  • [[SQLITE_FCNTL_COMMIT_PHASETWO]] +** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite +** and sent to the VFS after a transaction has been committed immediately +** but before the database is unlocked. VFSes that do not need this signal +** should silently ignore this opcode. Applications should not call +** [sqlite3_file_control()] with this opcode as doing so may disrupt the +** operation of the specialized VFSes that do require it. +** +**
  • [[SQLITE_FCNTL_WIN32_AV_RETRY]] +** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic +** retry counts and intervals for certain disk I/O operations for the +** windows [VFS] in order to provide robustness in the presence of +** anti-virus programs. By default, the windows VFS will retry file read, +** file write, and file delete operations up to 10 times, with a delay +** of 25 milliseconds before the first retry and with the delay increasing +** by an additional 25 milliseconds with each subsequent retry. This +** opcode allows these two values (10 retries and 25 milliseconds of delay) +** to be adjusted. The values are changed for all database connections +** within the same process. The argument is a pointer to an array of two +** integers where the first integer is the new retry count and the second +** integer is the delay. If either integer is negative, then the setting +** is not changed but instead the prior value of that setting is written +** into the array entry, allowing the current retry settings to be +** interrogated. The zDbName parameter is ignored. +** +**
  • [[SQLITE_FCNTL_PERSIST_WAL]] +** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the +** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary +** write ahead log ([WAL file]) and shared memory +** files used for transaction control +** are automatically deleted when the latest connection to the database +** closes. Setting persistent WAL mode causes those files to persist after +** close. Persisting the files is useful when other processes that do not +** have write permission on the directory containing the database file want +** to read the database file, as the WAL and shared memory files must exist +** in order for the database to be readable. The fourth parameter to +** [sqlite3_file_control()] for this opcode should be a pointer to an integer. +** That integer is 0 to disable persistent WAL mode or 1 to enable persistent +** WAL mode. If the integer is -1, then it is overwritten with the current +** WAL persistence setting. +** +**
  • [[SQLITE_FCNTL_POWERSAFE_OVERWRITE]] +** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the +** persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting +** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the +** xDeviceCharacteristics methods. The fourth parameter to +** [sqlite3_file_control()] for this opcode should be a pointer to an integer. +** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage +** mode. If the integer is -1, then it is overwritten with the current +** zero-damage mode setting. +** +**
  • [[SQLITE_FCNTL_OVERWRITE]] +** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening +** a write transaction to indicate that, unless it is rolled back for some +** reason, the entire database file will be overwritten by the current +** transaction. This is used by VACUUM operations. +** +**
  • [[SQLITE_FCNTL_VFSNAME]] +** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of +** all [VFSes] in the VFS stack. The names are of all VFS shims and the +** final bottom-level VFS are written into memory obtained from +** [sqlite3_malloc()] and the result is stored in the char* variable +** that the fourth parameter of [sqlite3_file_control()] points to. +** The caller is responsible for freeing the memory when done. As with +** all file-control actions, there is no guarantee that this will actually +** do anything. Callers should initialize the char* variable to a NULL +** pointer in case this file-control is not implemented. This file-control +** is intended for diagnostic use only. +** +**
  • [[SQLITE_FCNTL_VFS_POINTER]] +** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level +** [VFSes] currently in use. ^(The argument X in +** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be +** of type "[sqlite3_vfs] **". This opcodes will set *X +** to a pointer to the top-level VFS.)^ +** ^When there are multiple VFS shims in the stack, this opcode finds the +** upper-most shim only. +** +**
  • [[SQLITE_FCNTL_PRAGMA]] +** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] +** file control is sent to the open [sqlite3_file] object corresponding +** to the database file to which the pragma statement refers. ^The argument +** to the [SQLITE_FCNTL_PRAGMA] file control is an array of +** pointers to strings (char**) in which the second element of the array +** is the name of the pragma and the third element is the argument to the +** pragma or NULL if the pragma has no argument. ^The handler for an +** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element +** of the char** argument point to a string obtained from [sqlite3_mprintf()] +** or the equivalent and that string will become the result of the pragma or +** the error message if the pragma fails. ^If the +** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal +** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] +** file control returns [SQLITE_OK], then the parser assumes that the +** VFS has handled the PRAGMA itself and the parser generates a no-op +** prepared statement if result string is NULL, or that returns a copy +** of the result string if the string is non-NULL. +** ^If the [SQLITE_FCNTL_PRAGMA] file control returns +** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means +** that the VFS encountered an error while handling the [PRAGMA] and the +** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] +** file control occurs at the beginning of pragma statement analysis and so +** it is able to override built-in [PRAGMA] statements. +** +**
  • [[SQLITE_FCNTL_BUSYHANDLER]] +** ^The [SQLITE_FCNTL_BUSYHANDLER] +** file-control may be invoked by SQLite on the database file handle +** shortly after it is opened in order to provide a custom VFS with access +** to the connection's busy-handler callback. The argument is of type (void**) +** - an array of two (void *) values. The first (void *) actually points +** to a function of type (int (*)(void *)). In order to invoke the connection's +** busy-handler, this function should be invoked with the second (void *) in +** the array as the only argument. If it returns non-zero, then the operation +** should be retried. If it returns zero, the custom VFS should abandon the +** current operation. +** +**
  • [[SQLITE_FCNTL_TEMPFILENAME]] +** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control +** to have SQLite generate a +** temporary filename using the same algorithm that is followed to generate +** temporary filenames for TEMP tables and other internal uses. The +** argument should be a char** which will be filled with the filename +** written into memory obtained from [sqlite3_malloc()]. The caller should +** invoke [sqlite3_free()] on the result to avoid a memory leak. +** +**
  • [[SQLITE_FCNTL_MMAP_SIZE]] +** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the +** maximum number of bytes that will be used for memory-mapped I/O. +** The argument is a pointer to a value of type sqlite3_int64 that +** is an advisory maximum number of bytes in the file to memory map. The +** pointer is overwritten with the old value. The limit is not changed if +** the value originally pointed to is negative, and so the current limit +** can be queried by passing in a pointer to a negative number. This +** file-control is used internally to implement [PRAGMA mmap_size]. +** +**
  • [[SQLITE_FCNTL_TRACE]] +** The [SQLITE_FCNTL_TRACE] file control provides advisory information +** to the VFS about what the higher layers of the SQLite stack are doing. +** This file control is used by some VFS activity tracing [shims]. +** The argument is a zero-terminated string. Higher layers in the +** SQLite stack may generate instances of this file control if +** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled. +** +**
  • [[SQLITE_FCNTL_HAS_MOVED]] +** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a +** pointer to an integer and it writes a boolean into that integer depending +** on whether or not the file has been renamed, moved, or deleted since it +** was first opened. +** +**
  • [[SQLITE_FCNTL_WIN32_GET_HANDLE]] +** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the +** underlying native file handle associated with a file handle. This file +** control interprets its argument as a pointer to a native file handle and +** writes the resulting value there. +** +**
  • [[SQLITE_FCNTL_WIN32_SET_HANDLE]] +** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This +** opcode causes the xFileControl method to swap the file handle with the one +** pointed to by the pArg argument. This capability is used during testing +** and only needs to be supported when SQLITE_TEST is defined. +** +**
  • [[SQLITE_FCNTL_NULL_IO]] +** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor +** or file handle for the [sqlite3_file] object such that it will no longer +** read or write to the database file. +** +**
  • [[SQLITE_FCNTL_WAL_BLOCK]] +** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might +** be advantageous to block on the next WAL lock if the lock is not immediately +** available. The WAL subsystem issues this signal during rare +** circumstances in order to fix a problem with priority inversion. +** Applications should not use this file-control. +** +**
  • [[SQLITE_FCNTL_ZIPVFS]] +** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other +** VFS should return SQLITE_NOTFOUND for this opcode. +** +**
  • [[SQLITE_FCNTL_RBU]] +** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by +** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for +** this opcode. +** +**
  • [[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]] +** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then +** the file descriptor is placed in "batch write mode", which +** means all subsequent write operations will be deferred and done +** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. Systems +** that do not support batch atomic writes will return SQLITE_NOTFOUND. +** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to +** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or +** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make +** no VFS interface calls on the same [sqlite3_file] file descriptor +** except for calls to the xWrite method and the xFileControl method +** with [SQLITE_FCNTL_SIZE_HINT]. +** +**
  • [[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]] +** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write +** operations since the previous successful call to +** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically. +** This file control returns [SQLITE_OK] if and only if the writes were +** all performed successfully and have been committed to persistent storage. +** ^Regardless of whether or not it is successful, this file control takes +** the file descriptor out of batch write mode so that all subsequent +** write operations are independent. +** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without +** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. +** +**
  • [[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]] +** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write +** operations since the previous successful call to +** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. +** ^This file control takes the file descriptor out of batch write mode +** so that all subsequent write operations are independent. +** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without +** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. +** +**
  • [[SQLITE_FCNTL_LOCK_TIMEOUT]] +** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode is used to configure a VFS +** to block for up to M milliseconds before failing when attempting to +** obtain a file lock using the xLock or xShmLock methods of the VFS. +** The parameter is a pointer to a 32-bit signed integer that contains +** the value that M is to be set to. Before returning, the 32-bit signed +** integer is overwritten with the previous value of M. +** +**
  • [[SQLITE_FCNTL_BLOCK_ON_CONNECT]] +** The [SQLITE_FCNTL_BLOCK_ON_CONNECT] opcode is used to configure the +** VFS to block when taking a SHARED lock to connect to a wal mode database. +** This is used to implement the functionality associated with +** SQLITE_SETLK_BLOCK_ON_CONNECT. +** +**
  • [[SQLITE_FCNTL_DATA_VERSION]] +** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to +** a database file. The argument is a pointer to a 32-bit unsigned integer. +** The "data version" for the pager is written into the pointer. The +** "data version" changes whenever any change occurs to the corresponding +** database file, either through SQL statements on the same database +** connection or through transactions committed by separate database +** connections possibly in other processes. The [sqlite3_total_changes()] +** interface can be used to find if any database on the connection has changed, +** but that interface responds to changes on TEMP as well as MAIN and does +** not provide a mechanism to detect changes to MAIN only. Also, the +** [sqlite3_total_changes()] interface responds to internal changes only and +** omits changes made by other database connections. The +** [PRAGMA data_version] command provides a mechanism to detect changes to +** a single attached database that occur due to other database connections, +** but omits changes implemented by the database connection on which it is +** called. This file control is the only mechanism to detect changes that +** happen either internally or externally and that are associated with +** a particular attached database. +** +**
  • [[SQLITE_FCNTL_CKPT_START]] +** The [SQLITE_FCNTL_CKPT_START] opcode is invoked from within a checkpoint +** in wal mode before the client starts to copy pages from the wal +** file to the database file. +** +**
  • [[SQLITE_FCNTL_CKPT_DONE]] +** The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint +** in wal mode after the client has finished copying pages from the wal +** file to the database file, but before the *-shm file is updated to +** record the fact that the pages have been checkpointed. +** +**
  • [[SQLITE_FCNTL_EXTERNAL_READER]] +** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect +** whether or not there is a database client in another process with a wal-mode +** transaction open on the database or not. It is only available on unix.The +** (void*) argument passed with this file-control should be a pointer to a +** value of type (int). The integer value is set to 1 if the database is a wal +** mode database and there exists at least one client in another process that +** currently has an SQL transaction open on the database. It is set to 0 if +** the database is not a wal-mode db, or if there is no such connection in any +** other process. This opcode cannot be used to detect transactions opened +** by clients within the current process, only within other processes. +** +**
  • [[SQLITE_FCNTL_CKSM_FILE]] +** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use internally by the +** [checksum VFS shim] only. +** +**
  • [[SQLITE_FCNTL_RESET_CACHE]] +** If there is currently no transaction open on the database, and the +** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control +** purges the contents of the in-memory page cache. If there is an open +** transaction, or if the db is a temp-db, this opcode is a no-op, not an error. +**
+*/ +#define SQLITE_FCNTL_LOCKSTATE 1 +#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 +#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 +#define SQLITE_FCNTL_LAST_ERRNO 4 +#define SQLITE_FCNTL_SIZE_HINT 5 +#define SQLITE_FCNTL_CHUNK_SIZE 6 +#define SQLITE_FCNTL_FILE_POINTER 7 +#define SQLITE_FCNTL_SYNC_OMITTED 8 +#define SQLITE_FCNTL_WIN32_AV_RETRY 9 +#define SQLITE_FCNTL_PERSIST_WAL 10 +#define SQLITE_FCNTL_OVERWRITE 11 +#define SQLITE_FCNTL_VFSNAME 12 +#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13 +#define SQLITE_FCNTL_PRAGMA 14 +#define SQLITE_FCNTL_BUSYHANDLER 15 +#define SQLITE_FCNTL_TEMPFILENAME 16 +#define SQLITE_FCNTL_MMAP_SIZE 18 +#define SQLITE_FCNTL_TRACE 19 +#define SQLITE_FCNTL_HAS_MOVED 20 +#define SQLITE_FCNTL_SYNC 21 +#define SQLITE_FCNTL_COMMIT_PHASETWO 22 +#define SQLITE_FCNTL_WIN32_SET_HANDLE 23 +#define SQLITE_FCNTL_WAL_BLOCK 24 +#define SQLITE_FCNTL_ZIPVFS 25 +#define SQLITE_FCNTL_RBU 26 +#define SQLITE_FCNTL_VFS_POINTER 27 +#define SQLITE_FCNTL_JOURNAL_POINTER 28 +#define SQLITE_FCNTL_WIN32_GET_HANDLE 29 +#define SQLITE_FCNTL_PDB 30 +#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 +#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 +#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 +#define SQLITE_FCNTL_LOCK_TIMEOUT 34 +#define SQLITE_FCNTL_DATA_VERSION 35 +#define SQLITE_FCNTL_SIZE_LIMIT 36 +#define SQLITE_FCNTL_CKPT_DONE 37 +#define SQLITE_FCNTL_RESERVE_BYTES 38 +#define SQLITE_FCNTL_CKPT_START 39 +#define SQLITE_FCNTL_EXTERNAL_READER 40 +#define SQLITE_FCNTL_CKSM_FILE 41 +#define SQLITE_FCNTL_RESET_CACHE 42 +#define SQLITE_FCNTL_NULL_IO 43 +#define SQLITE_FCNTL_BLOCK_ON_CONNECT 44 + +/* deprecated names */ +#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE +#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE +#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO + + +/* +** CAPI3REF: Mutex Handle +** +** The mutex module within SQLite defines [sqlite3_mutex] to be an +** abstract type for a mutex object. The SQLite core never looks +** at the internal representation of an [sqlite3_mutex]. It only +** deals with pointers to the [sqlite3_mutex] object. +** +** Mutexes are created using [sqlite3_mutex_alloc()]. +*/ +typedef struct sqlite3_mutex sqlite3_mutex; + +/* +** CAPI3REF: Loadable Extension Thunk +** +** A pointer to the opaque sqlite3_api_routines structure is passed as +** the third parameter to entry points of [loadable extensions]. This +** structure must be typedefed in order to work around compiler warnings +** on some platforms. +*/ +typedef struct sqlite3_api_routines sqlite3_api_routines; + +/* +** CAPI3REF: File Name +** +** Type [sqlite3_filename] is used by SQLite to pass filenames to the +** xOpen method of a [VFS]. It may be cast to (const char*) and treated +** as a normal, nul-terminated, UTF-8 buffer containing the filename, but +** may also be passed to special APIs such as: +** +**
    +**
  • sqlite3_filename_database() +**
  • sqlite3_filename_journal() +**
  • sqlite3_filename_wal() +**
  • sqlite3_uri_parameter() +**
  • sqlite3_uri_boolean() +**
  • sqlite3_uri_int64() +**
  • sqlite3_uri_key() +**
+*/ +typedef const char *sqlite3_filename; + +/* +** CAPI3REF: OS Interface Object +** +** An instance of the sqlite3_vfs object defines the interface between +** the SQLite core and the underlying operating system. The "vfs" +** in the name of the object stands for "virtual file system". See +** the [VFS | VFS documentation] for further information. +** +** The VFS interface is sometimes extended by adding new methods onto +** the end. Each time such an extension occurs, the iVersion field +** is incremented. The iVersion value started out as 1 in +** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2 +** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased +** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields +** may be appended to the sqlite3_vfs object and the iVersion value +** may increase again in future versions of SQLite. +** Note that due to an oversight, the structure +** of the sqlite3_vfs object changed in the transition from +** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] +** and yet the iVersion field was not increased. +** +** The szOsFile field is the size of the subclassed [sqlite3_file] +** structure used by this VFS. mxPathname is the maximum length of +** a pathname in this VFS. +** +** Registered sqlite3_vfs objects are kept on a linked list formed by +** the pNext pointer. The [sqlite3_vfs_register()] +** and [sqlite3_vfs_unregister()] interfaces manage this list +** in a thread-safe way. The [sqlite3_vfs_find()] interface +** searches the list. Neither the application code nor the VFS +** implementation should use the pNext pointer. +** +** The pNext field is the only field in the sqlite3_vfs +** structure that SQLite will ever modify. SQLite will only access +** or modify this field while holding a particular static mutex. +** The application should never modify anything within the sqlite3_vfs +** object once the object has been registered. +** +** The zName field holds the name of the VFS module. The name must +** be unique across all VFS modules. +** +** [[sqlite3_vfs.xOpen]] +** ^SQLite guarantees that the zFilename parameter to xOpen +** is either a NULL pointer or string obtained +** from xFullPathname() with an optional suffix added. +** ^If a suffix is added to the zFilename parameter, it will +** consist of a single "-" character followed by no more than +** 11 alphanumeric and/or "-" characters. +** ^SQLite further guarantees that +** the string will be valid and unchanged until xClose() is +** called. Because of the previous sentence, +** the [sqlite3_file] can safely store a pointer to the +** filename if it needs to remember the filename for some reason. +** If the zFilename parameter to xOpen is a NULL pointer then xOpen +** must invent its own temporary name for the file. ^Whenever the +** xFilename parameter is NULL it will also be the case that the +** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. +** +** The flags argument to xOpen() includes all bits set in +** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] +** or [sqlite3_open16()] is used, then flags includes at least +** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. +** If xOpen() opens a file read-only then it sets *pOutFlags to +** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. +** +** ^(SQLite will also add one of the following flags to the xOpen() +** call, depending on the object being opened: +** +**
    +**
  • [SQLITE_OPEN_MAIN_DB] +**
  • [SQLITE_OPEN_MAIN_JOURNAL] +**
  • [SQLITE_OPEN_TEMP_DB] +**
  • [SQLITE_OPEN_TEMP_JOURNAL] +**
  • [SQLITE_OPEN_TRANSIENT_DB] +**
  • [SQLITE_OPEN_SUBJOURNAL] +**
  • [SQLITE_OPEN_SUPER_JOURNAL] +**
  • [SQLITE_OPEN_WAL] +**
)^ +** +** The file I/O implementation can use the object type flags to +** change the way it deals with files. For example, an application +** that does not care about crash recovery or rollback might make +** the open of a journal file a no-op. Writes to this journal would +** also be no-ops, and any attempt to read the journal would return +** SQLITE_IOERR. Or the implementation might recognize that a database +** file will be doing page-aligned sector reads and writes in a random +** order and set up its I/O subsystem accordingly. +** +** SQLite might also add one of the following flags to the xOpen method: +** +**
    +**
  • [SQLITE_OPEN_DELETEONCLOSE] +**
  • [SQLITE_OPEN_EXCLUSIVE] +**
+** +** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be +** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] +** will be set for TEMP databases and their journals, transient +** databases, and subjournals. +** +** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction +** with the [SQLITE_OPEN_CREATE] flag, which are both directly +** analogous to the O_EXCL and O_CREAT flags of the POSIX open() +** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the +** SQLITE_OPEN_CREATE, is used to indicate that file should always +** be created, and that it is an error if it already exists. +** It is not used to indicate the file should be opened +** for exclusive access. +** +** ^At least szOsFile bytes of memory are allocated by SQLite +** to hold the [sqlite3_file] structure passed as the third +** argument to xOpen. The xOpen method does not have to +** allocate the structure; it should just fill it in. Note that +** the xOpen method must set the sqlite3_file.pMethods to either +** a valid [sqlite3_io_methods] object or to NULL. xOpen must do +** this even if the open fails. SQLite expects that the sqlite3_file.pMethods +** element will be valid after xOpen returns regardless of the success +** or failure of the xOpen call. +** +** [[sqlite3_vfs.xAccess]] +** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] +** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to +** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] +** to test whether a file is at least readable. The SQLITE_ACCESS_READ +** flag is never actually used and is not implemented in the built-in +** VFSes of SQLite. The file is named by the second argument and can be a +** directory. The xAccess method returns [SQLITE_OK] on success or some +** non-zero error code if there is an I/O error or if the name of +** the file given in the second argument is illegal. If SQLITE_OK +** is returned, then non-zero or zero is written into *pResOut to indicate +** whether or not the file is accessible. +** +** ^SQLite will always allocate at least mxPathname+1 bytes for the +** output buffer xFullPathname. The exact size of the output buffer +** is also passed as a parameter to both methods. If the output buffer +** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is +** handled as a fatal error by SQLite, vfs implementations should endeavor +** to prevent this by setting mxPathname to a sufficiently large value. +** +** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() +** interfaces are not strictly a part of the filesystem, but they are +** included in the VFS structure for completeness. +** The xRandomness() function attempts to return nBytes bytes +** of good-quality randomness into zOut. The return value is +** the actual number of bytes of randomness obtained. +** The xSleep() method causes the calling thread to sleep for at +** least the number of microseconds given. ^The xCurrentTime() +** method returns a Julian Day Number for the current date and time as +** a floating point value. +** ^The xCurrentTimeInt64() method returns, as an integer, the Julian +** Day Number multiplied by 86400000 (the number of milliseconds in +** a 24-hour day). +** ^SQLite will use the xCurrentTimeInt64() method to get the current +** date and time if that method is available (if iVersion is 2 or +** greater and the function pointer is not NULL) and will fall back +** to xCurrentTime() if xCurrentTimeInt64() is unavailable. +** +** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces +** are not used by the SQLite core. These optional interfaces are provided +** by some VFSes to facilitate testing of the VFS code. By overriding +** system calls with functions under its control, a test program can +** simulate faults and error conditions that would otherwise be difficult +** or impossible to induce. The set of system calls that can be overridden +** varies from one VFS to another, and from one version of the same VFS to the +** next. Applications that use these interfaces must be prepared for any +** or all of these interfaces to be NULL or for their behavior to change +** from one release to the next. Applications must not attempt to access +** any of these methods if the iVersion of the VFS is less than 3. +*/ +typedef struct sqlite3_vfs sqlite3_vfs; +typedef void (*sqlite3_syscall_ptr)(void); +struct sqlite3_vfs { + int iVersion; /* Structure version number (currently 3) */ + int szOsFile; /* Size of subclassed sqlite3_file */ + int mxPathname; /* Maximum file pathname length */ + sqlite3_vfs *pNext; /* Next registered VFS */ + const char *zName; /* Name of this virtual file system */ + void *pAppData; /* Pointer to application-specific data */ + int (*xOpen)(sqlite3_vfs*, sqlite3_filename zName, sqlite3_file*, + int flags, int *pOutFlags); + int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); + int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); + int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); + void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); + void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); + void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); + void (*xDlClose)(sqlite3_vfs*, void*); + int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); + int (*xSleep)(sqlite3_vfs*, int microseconds); + int (*xCurrentTime)(sqlite3_vfs*, double*); + int (*xGetLastError)(sqlite3_vfs*, int, char *); + /* + ** The methods above are in version 1 of the sqlite_vfs object + ** definition. Those that follow are added in version 2 or later + */ + int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*); + /* + ** The methods above are in versions 1 and 2 of the sqlite_vfs object. + ** Those below are for version 3 and greater. + */ + int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr); + sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName); + const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName); + /* + ** The methods above are in versions 1 through 3 of the sqlite_vfs object. + ** New fields may be appended in future versions. The iVersion + ** value will increment whenever this happens. + */ +}; + +/* +** CAPI3REF: Flags for the xAccess VFS method +** +** These integer constants can be used as the third parameter to +** the xAccess method of an [sqlite3_vfs] object. They determine +** what kind of permissions the xAccess method is looking for. +** With SQLITE_ACCESS_EXISTS, the xAccess method +** simply checks whether the file exists. +** With SQLITE_ACCESS_READWRITE, the xAccess method +** checks whether the named directory is both readable and writable +** (in other words, if files can be added, removed, and renamed within +** the directory). +** The SQLITE_ACCESS_READWRITE constant is currently used only by the +** [temp_store_directory pragma], though this could change in a future +** release of SQLite. +** With SQLITE_ACCESS_READ, the xAccess method +** checks whether the file is readable. The SQLITE_ACCESS_READ constant is +** currently unused, though it might be used in a future release of +** SQLite. +*/ +#define SQLITE_ACCESS_EXISTS 0 +#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ +#define SQLITE_ACCESS_READ 2 /* Unused */ + +/* +** CAPI3REF: Flags for the xShmLock VFS method +** +** These integer constants define the various locking operations +** allowed by the xShmLock method of [sqlite3_io_methods]. The +** following are the only legal combinations of flags to the +** xShmLock method: +** +**
    +**
  • SQLITE_SHM_LOCK | SQLITE_SHM_SHARED +**
  • SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE +**
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED +**
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE +**
+** +** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as +** was given on the corresponding lock. +** +** The xShmLock method can transition between unlocked and SHARED or +** between unlocked and EXCLUSIVE. It cannot transition between SHARED +** and EXCLUSIVE. +*/ +#define SQLITE_SHM_UNLOCK 1 +#define SQLITE_SHM_LOCK 2 +#define SQLITE_SHM_SHARED 4 +#define SQLITE_SHM_EXCLUSIVE 8 + +/* +** CAPI3REF: Maximum xShmLock index +** +** The xShmLock method on [sqlite3_io_methods] may use values +** between 0 and this upper bound as its "offset" argument. +** The SQLite core will never attempt to acquire or release a +** lock outside of this range +*/ +#define SQLITE_SHM_NLOCK 8 + + +/* +** CAPI3REF: Initialize The SQLite Library +** +** ^The sqlite3_initialize() routine initializes the +** SQLite library. ^The sqlite3_shutdown() routine +** deallocates any resources that were allocated by sqlite3_initialize(). +** These routines are designed to aid in process initialization and +** shutdown on embedded systems. Workstation applications using +** SQLite normally do not need to invoke either of these routines. +** +** A call to sqlite3_initialize() is an "effective" call if it is +** the first time sqlite3_initialize() is invoked during the lifetime of +** the process, or if it is the first time sqlite3_initialize() is invoked +** following a call to sqlite3_shutdown(). ^(Only an effective call +** of sqlite3_initialize() does any initialization. All other calls +** are harmless no-ops.)^ +** +** A call to sqlite3_shutdown() is an "effective" call if it is the first +** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only +** an effective call to sqlite3_shutdown() does any deinitialization. +** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ +** +** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() +** is not. The sqlite3_shutdown() interface must only be called from a +** single thread. All open [database connections] must be closed and all +** other SQLite resources must be deallocated prior to invoking +** sqlite3_shutdown(). +** +** Among other things, ^sqlite3_initialize() will invoke +** sqlite3_os_init(). Similarly, ^sqlite3_shutdown() +** will invoke sqlite3_os_end(). +** +** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. +** ^If for some reason, sqlite3_initialize() is unable to initialize +** the library (perhaps it is unable to allocate a needed resource such +** as a mutex) it returns an [error code] other than [SQLITE_OK]. +** +** ^The sqlite3_initialize() routine is called internally by many other +** SQLite interfaces so that an application usually does not need to +** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] +** calls sqlite3_initialize() so the SQLite library will be automatically +** initialized when [sqlite3_open()] is called if it has not be initialized +** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] +** compile-time option, then the automatic calls to sqlite3_initialize() +** are omitted and the application must call sqlite3_initialize() directly +** prior to using any other SQLite interface. For maximum portability, +** it is recommended that applications always invoke sqlite3_initialize() +** directly prior to using any other SQLite interface. Future releases +** of SQLite may require this. In other words, the behavior exhibited +** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the +** default behavior in some future release of SQLite. +** +** The sqlite3_os_init() routine does operating-system specific +** initialization of the SQLite library. The sqlite3_os_end() +** routine undoes the effect of sqlite3_os_init(). Typical tasks +** performed by these routines include allocation or deallocation +** of static resources, initialization of global variables, +** setting up a default [sqlite3_vfs] module, or setting up +** a default configuration using [sqlite3_config()]. +** +** The application should never invoke either sqlite3_os_init() +** or sqlite3_os_end() directly. The application should only invoke +** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() +** interface is called automatically by sqlite3_initialize() and +** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate +** implementations for sqlite3_os_init() and sqlite3_os_end() +** are built into SQLite when it is compiled for Unix, Windows, or OS/2. +** When [custom builds | built for other platforms] +** (using the [SQLITE_OS_OTHER=1] compile-time +** option) the application must supply a suitable implementation for +** sqlite3_os_init() and sqlite3_os_end(). An application-supplied +** implementation of sqlite3_os_init() or sqlite3_os_end() +** must return [SQLITE_OK] on success and some other [error code] upon +** failure. +*/ +SQLITE_API int sqlite3_initialize(void); +SQLITE_API int sqlite3_shutdown(void); +SQLITE_API int sqlite3_os_init(void); +SQLITE_API int sqlite3_os_end(void); + +/* +** CAPI3REF: Configuring The SQLite Library +** +** The sqlite3_config() interface is used to make global configuration +** changes to SQLite in order to tune SQLite to the specific needs of +** the application. The default configuration is recommended for most +** applications and so this routine is usually not necessary. It is +** provided to support rare applications with unusual needs. +** +** The sqlite3_config() interface is not threadsafe. The application +** must ensure that no other SQLite interfaces are invoked by other +** threads while sqlite3_config() is running. +** +** The first argument to sqlite3_config() is an integer +** [configuration option] that determines +** what property of SQLite is to be configured. Subsequent arguments +** vary depending on the [configuration option] +** in the first argument. +** +** For most configuration options, the sqlite3_config() interface +** may only be invoked prior to library initialization using +** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. +** The exceptional configuration options that may be invoked at any time +** are called "anytime configuration options". +** ^If sqlite3_config() is called after [sqlite3_initialize()] and before +** [sqlite3_shutdown()] with a first argument that is not an anytime +** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE. +** Note, however, that ^sqlite3_config() can be called as part of the +** implementation of an application-defined [sqlite3_os_init()]. +** +** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. +** ^If the option is unknown or SQLite is unable to set the option +** then this routine returns a non-zero [error code]. +*/ +SQLITE_API int sqlite3_config(int, ...); + +/* +** CAPI3REF: Configure database connections +** METHOD: sqlite3 +** +** The sqlite3_db_config() interface is used to make configuration +** changes to a [database connection]. The interface is similar to +** [sqlite3_config()] except that the changes apply to a single +** [database connection] (specified in the first argument). +** +** The second argument to sqlite3_db_config(D,V,...) is the +** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code +** that indicates what aspect of the [database connection] is being configured. +** Subsequent arguments vary depending on the configuration verb. +** +** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if +** the call is considered successful. +*/ +SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); + +/* +** CAPI3REF: Memory Allocation Routines +** +** An instance of this object defines the interface between SQLite +** and low-level memory allocation routines. +** +** This object is used in only one place in the SQLite interface. +** A pointer to an instance of this object is the argument to +** [sqlite3_config()] when the configuration option is +** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. +** By creating an instance of this object +** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) +** during configuration, an application can specify an alternative +** memory allocation subsystem for SQLite to use for all of its +** dynamic memory needs. +** +** Note that SQLite comes with several [built-in memory allocators] +** that are perfectly adequate for the overwhelming majority of applications +** and that this object is only useful to a tiny minority of applications +** with specialized memory allocation requirements. This object is +** also used during testing of SQLite in order to specify an alternative +** memory allocator that simulates memory out-of-memory conditions in +** order to verify that SQLite recovers gracefully from such +** conditions. +** +** The xMalloc, xRealloc, and xFree methods must work like the +** malloc(), realloc() and free() functions from the standard C library. +** ^SQLite guarantees that the second argument to +** xRealloc is always a value returned by a prior call to xRoundup. +** +** xSize should return the allocated size of a memory allocation +** previously obtained from xMalloc or xRealloc. The allocated size +** is always at least as big as the requested size but may be larger. +** +** The xRoundup method returns what would be the allocated size of +** a memory allocation given a particular requested size. Most memory +** allocators round up memory allocations at least to the next multiple +** of 8. Some allocators round up to a larger multiple or to a power of 2. +** Every memory allocation request coming in through [sqlite3_malloc()] +** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, +** that causes the corresponding memory allocation to fail. +** +** The xInit method initializes the memory allocator. For example, +** it might allocate any required mutexes or initialize internal data +** structures. The xShutdown method is invoked (indirectly) by +** [sqlite3_shutdown()] and should deallocate any resources acquired +** by xInit. The pAppData pointer is used as the only parameter to +** xInit and xShutdown. +** +** SQLite holds the [SQLITE_MUTEX_STATIC_MAIN] mutex when it invokes +** the xInit method, so the xInit method need not be threadsafe. The +** xShutdown method is only called from [sqlite3_shutdown()] so it does +** not need to be threadsafe either. For all other methods, SQLite +** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the +** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which +** it is by default) and so the methods are automatically serialized. +** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other +** methods must be threadsafe or else make their own arrangements for +** serialization. +** +** SQLite will never invoke xInit() more than once without an intervening +** call to xShutdown(). +*/ +typedef struct sqlite3_mem_methods sqlite3_mem_methods; +struct sqlite3_mem_methods { + void *(*xMalloc)(int); /* Memory allocation function */ + void (*xFree)(void*); /* Free a prior allocation */ + void *(*xRealloc)(void*,int); /* Resize an allocation */ + int (*xSize)(void*); /* Return the size of an allocation */ + int (*xRoundup)(int); /* Round up request size to allocation size */ + int (*xInit)(void*); /* Initialize the memory allocator */ + void (*xShutdown)(void*); /* Deinitialize the memory allocator */ + void *pAppData; /* Argument to xInit() and xShutdown() */ +}; + +/* +** CAPI3REF: Configuration Options +** KEYWORDS: {configuration option} +** +** These constants are the available integer configuration options that +** can be passed as the first argument to the [sqlite3_config()] interface. +** +** Most of the configuration options for sqlite3_config() +** will only work if invoked prior to [sqlite3_initialize()] or after +** [sqlite3_shutdown()]. The few exceptions to this rule are called +** "anytime configuration options". +** ^Calling [sqlite3_config()] with a first argument that is not an +** anytime configuration option in between calls to [sqlite3_initialize()] and +** [sqlite3_shutdown()] is a no-op that returns SQLITE_MISUSE. +** +** The set of anytime configuration options can change (by insertions +** and/or deletions) from one release of SQLite to the next. +** As of SQLite version 3.42.0, the complete set of anytime configuration +** options is: +**
    +**
  • SQLITE_CONFIG_LOG +**
  • SQLITE_CONFIG_PCACHE_HDRSZ +**
+** +** New configuration options may be added in future releases of SQLite. +** Existing configuration options might be discontinued. Applications +** should check the return code from [sqlite3_config()] to make sure that +** the call worked. The [sqlite3_config()] interface will return a +** non-zero [error code] if a discontinued or unsupported configuration option +** is invoked. +** +**
+** [[SQLITE_CONFIG_SINGLETHREAD]]
SQLITE_CONFIG_SINGLETHREAD
+**
There are no arguments to this option. ^This option sets the +** [threading mode] to Single-thread. In other words, it disables +** all mutexing and puts SQLite into a mode where it can only be used +** by a single thread. ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** it is not possible to change the [threading mode] from its default +** value of Single-thread and so [sqlite3_config()] will return +** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD +** configuration option.
+** +** [[SQLITE_CONFIG_MULTITHREAD]]
SQLITE_CONFIG_MULTITHREAD
+**
There are no arguments to this option. ^This option sets the +** [threading mode] to Multi-thread. In other words, it disables +** mutexing on [database connection] and [prepared statement] objects. +** The application is responsible for serializing access to +** [database connections] and [prepared statements]. But other mutexes +** are enabled so that SQLite will be safe to use in a multi-threaded +** environment as long as no two threads attempt to use the same +** [database connection] at the same time. ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** it is not possible to set the Multi-thread [threading mode] and +** [sqlite3_config()] will return [SQLITE_ERROR] if called with the +** SQLITE_CONFIG_MULTITHREAD configuration option.
+** +** [[SQLITE_CONFIG_SERIALIZED]]
SQLITE_CONFIG_SERIALIZED
+**
There are no arguments to this option. ^This option sets the +** [threading mode] to Serialized. In other words, this option enables +** all mutexes including the recursive +** mutexes on [database connection] and [prepared statement] objects. +** In this mode (which is the default when SQLite is compiled with +** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access +** to [database connections] and [prepared statements] so that the +** application is free to use the same [database connection] or the +** same [prepared statement] in different threads at the same time. +** ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** it is not possible to set the Serialized [threading mode] and +** [sqlite3_config()] will return [SQLITE_ERROR] if called with the +** SQLITE_CONFIG_SERIALIZED configuration option.
+** +** [[SQLITE_CONFIG_MALLOC]]
SQLITE_CONFIG_MALLOC
+**
^(The SQLITE_CONFIG_MALLOC option takes a single argument which is +** a pointer to an instance of the [sqlite3_mem_methods] structure. +** The argument specifies +** alternative low-level memory allocation routines to be used in place of +** the memory allocation routines built into SQLite.)^ ^SQLite makes +** its own private copy of the content of the [sqlite3_mem_methods] structure +** before the [sqlite3_config()] call returns.
+** +** [[SQLITE_CONFIG_GETMALLOC]]
SQLITE_CONFIG_GETMALLOC
+**
^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which +** is a pointer to an instance of the [sqlite3_mem_methods] structure. +** The [sqlite3_mem_methods] +** structure is filled with the currently defined memory allocation routines.)^ +** This option can be used to overload the default memory allocation +** routines with a wrapper that simulations memory allocation failure or +** tracks memory usage, for example.
+** +** [[SQLITE_CONFIG_SMALL_MALLOC]]
SQLITE_CONFIG_SMALL_MALLOC
+**
^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of +** type int, interpreted as a boolean, which if true provides a hint to +** SQLite that it should avoid large memory allocations if possible. +** SQLite will run faster if it is free to make large memory allocations, +** but some application might prefer to run slower in exchange for +** guarantees about memory fragmentation that are possible if large +** allocations are avoided. This hint is normally off. +**
+** +** [[SQLITE_CONFIG_MEMSTATUS]]
SQLITE_CONFIG_MEMSTATUS
+**
^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int, +** interpreted as a boolean, which enables or disables the collection of +** memory allocation statistics. ^(When memory allocation statistics are +** disabled, the following SQLite interfaces become non-operational: +**
    +**
  • [sqlite3_hard_heap_limit64()] +**
  • [sqlite3_memory_used()] +**
  • [sqlite3_memory_highwater()] +**
  • [sqlite3_soft_heap_limit64()] +**
  • [sqlite3_status64()] +**
)^ +** ^Memory allocation statistics are enabled by default unless SQLite is +** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory +** allocation statistics are disabled by default. +**
+** +** [[SQLITE_CONFIG_SCRATCH]]
SQLITE_CONFIG_SCRATCH
+**
The SQLITE_CONFIG_SCRATCH option is no longer used. +**
+** +** [[SQLITE_CONFIG_PAGECACHE]]
SQLITE_CONFIG_PAGECACHE
+**
^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool +** that SQLite can use for the database page cache with the default page +** cache implementation. +** This configuration option is a no-op if an application-defined page +** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]. +** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to +** 8-byte aligned memory (pMem), the size of each page cache line (sz), +** and the number of cache lines (N). +** The sz argument should be the size of the largest database page +** (a power of two between 512 and 65536) plus some extra bytes for each +** page header. ^The number of extra bytes needed by the page header +** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ]. +** ^It is harmless, apart from the wasted memory, +** for the sz parameter to be larger than necessary. The pMem +** argument must be either a NULL pointer or a pointer to an 8-byte +** aligned block of memory of at least sz*N bytes, otherwise +** subsequent behavior is undefined. +** ^When pMem is not NULL, SQLite will strive to use the memory provided +** to satisfy page cache needs, falling back to [sqlite3_malloc()] if +** a page cache line is larger than sz bytes or if all of the pMem buffer +** is exhausted. +** ^If pMem is NULL and N is non-zero, then each database connection +** does an initial bulk allocation for page cache memory +** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or +** of -1024*N bytes if N is negative, . ^If additional +** page cache memory is needed beyond what is provided by the initial +** allocation, then SQLite goes to [sqlite3_malloc()] separately for each +** additional cache line.
+** +** [[SQLITE_CONFIG_HEAP]]
SQLITE_CONFIG_HEAP
+**
^The SQLITE_CONFIG_HEAP option specifies a static memory buffer +** that SQLite will use for all of its dynamic memory allocation needs +** beyond those provided for by [SQLITE_CONFIG_PAGECACHE]. +** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled +** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns +** [SQLITE_ERROR] if invoked otherwise. +** ^There are three arguments to SQLITE_CONFIG_HEAP: +** An 8-byte aligned pointer to the memory, +** the number of bytes in the memory buffer, and the minimum allocation size. +** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts +** to using its default memory allocator (the system malloc() implementation), +** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the +** memory pointer is not NULL then the alternative memory +** allocator is engaged to handle all of SQLites memory allocation needs. +** The first pointer (the memory pointer) must be aligned to an 8-byte +** boundary or subsequent behavior of SQLite will be undefined. +** The minimum allocation size is capped at 2**12. Reasonable values +** for the minimum allocation size are 2**5 through 2**8.
+** +** [[SQLITE_CONFIG_MUTEX]]
SQLITE_CONFIG_MUTEX
+**
^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a +** pointer to an instance of the [sqlite3_mutex_methods] structure. +** The argument specifies alternative low-level mutex routines to be used +** in place the mutex routines built into SQLite.)^ ^SQLite makes a copy of +** the content of the [sqlite3_mutex_methods] structure before the call to +** [sqlite3_config()] returns. ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** the entire mutexing subsystem is omitted from the build and hence calls to +** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will +** return [SQLITE_ERROR].
+** +** [[SQLITE_CONFIG_GETMUTEX]]
SQLITE_CONFIG_GETMUTEX
+**
^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which +** is a pointer to an instance of the [sqlite3_mutex_methods] structure. The +** [sqlite3_mutex_methods] +** structure is filled with the currently defined mutex routines.)^ +** This option can be used to overload the default mutex allocation +** routines with a wrapper used to track mutex usage for performance +** profiling or testing, for example. ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** the entire mutexing subsystem is omitted from the build and hence calls to +** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will +** return [SQLITE_ERROR].
+** +** [[SQLITE_CONFIG_LOOKASIDE]]
SQLITE_CONFIG_LOOKASIDE
+**
^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine +** the default size of [lookaside memory] on each [database connection]. +** The first argument is the +** size of each lookaside buffer slot ("sz") and the second is the number of +** slots allocated to each database connection ("cnt").)^ +** ^(SQLITE_CONFIG_LOOKASIDE sets the default lookaside size. +** The [SQLITE_DBCONFIG_LOOKASIDE] option to [sqlite3_db_config()] can +** be used to change the lookaside configuration on individual connections.)^ +** The [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to change the +** default lookaside configuration at compile-time. +**
+** +** [[SQLITE_CONFIG_PCACHE2]]
SQLITE_CONFIG_PCACHE2
+**
^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is +** a pointer to an [sqlite3_pcache_methods2] object. This object specifies +** the interface to a custom page cache implementation.)^ +** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.
+** +** [[SQLITE_CONFIG_GETPCACHE2]]
SQLITE_CONFIG_GETPCACHE2
+**
^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which +** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies of +** the current page cache implementation into that object.)^
+** +** [[SQLITE_CONFIG_LOG]]
SQLITE_CONFIG_LOG
+**
The SQLITE_CONFIG_LOG option is used to configure the SQLite +** global [error log]. +** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a +** function with a call signature of void(*)(void*,int,const char*), +** and a pointer to void. ^If the function pointer is not NULL, it is +** invoked by [sqlite3_log()] to process each logging event. ^If the +** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. +** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is +** passed through as the first parameter to the application-defined logger +** function whenever that function is invoked. ^The second parameter to +** the logger function is a copy of the first parameter to the corresponding +** [sqlite3_log()] call and is intended to be a [result code] or an +** [extended result code]. ^The third parameter passed to the logger is +** log message after formatting via [sqlite3_snprintf()]. +** The SQLite logging interface is not reentrant; the logger function +** supplied by the application must not invoke any SQLite interface. +** In a multi-threaded application, the application-defined logger +** function must be threadsafe.
+** +** [[SQLITE_CONFIG_URI]]
SQLITE_CONFIG_URI +**
^(The SQLITE_CONFIG_URI option takes a single argument of type int. +** If non-zero, then URI handling is globally enabled. If the parameter is zero, +** then URI handling is globally disabled.)^ ^If URI handling is globally +** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()], +** [sqlite3_open16()] or +** specified as part of [ATTACH] commands are interpreted as URIs, regardless +** of whether or not the [SQLITE_OPEN_URI] flag is set when the database +** connection is opened. ^If it is globally disabled, filenames are +** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the +** database connection is opened. ^(By default, URI handling is globally +** disabled. The default value may be changed by compiling with the +** [SQLITE_USE_URI] symbol defined.)^ +** +** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]]
SQLITE_CONFIG_COVERING_INDEX_SCAN +**
^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer +** argument which is interpreted as a boolean in order to enable or disable +** the use of covering indices for full table scans in the query optimizer. +** ^The default setting is determined +** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on" +** if that compile-time option is omitted. +** The ability to disable the use of covering indices for full table scans +** is because some incorrectly coded legacy applications might malfunction +** when the optimization is enabled. Providing the ability to +** disable the optimization allows the older, buggy application code to work +** without change even with newer versions of SQLite. +** +** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]] +**
SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE +**
These options are obsolete and should not be used by new code. +** They are retained for backwards compatibility but are now no-ops. +**
+** +** [[SQLITE_CONFIG_SQLLOG]] +**
SQLITE_CONFIG_SQLLOG +**
This option is only available if sqlite is compiled with the +** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should +** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int). +** The second should be of type (void*). The callback is invoked by the library +** in three separate circumstances, identified by the value passed as the +** fourth parameter. If the fourth parameter is 0, then the database connection +** passed as the second argument has just been opened. The third argument +** points to a buffer containing the name of the main database file. If the +** fourth parameter is 1, then the SQL statement that the third parameter +** points to has just been executed. Or, if the fourth parameter is 2, then +** the connection being passed as the second parameter is being closed. The +** third parameter is passed NULL In this case. An example of using this +** configuration option can be seen in the "test_sqllog.c" source file in +** the canonical SQLite source tree.
+** +** [[SQLITE_CONFIG_MMAP_SIZE]] +**
SQLITE_CONFIG_MMAP_SIZE +**
^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values +** that are the default mmap size limit (the default setting for +** [PRAGMA mmap_size]) and the maximum allowed mmap size limit. +** ^The default setting can be overridden by each database connection using +** either the [PRAGMA mmap_size] command, or by using the +** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size +** will be silently truncated if necessary so that it does not exceed the +** compile-time maximum mmap size set by the +** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^ +** ^If either argument to this option is negative, then that argument is +** changed to its compile-time default. +** +** [[SQLITE_CONFIG_WIN32_HEAPSIZE]] +**
SQLITE_CONFIG_WIN32_HEAPSIZE +**
^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is +** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro +** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value +** that specifies the maximum size of the created heap. +** +** [[SQLITE_CONFIG_PCACHE_HDRSZ]] +**
SQLITE_CONFIG_PCACHE_HDRSZ +**
^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which +** is a pointer to an integer and writes into that integer the number of extra +** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE]. +** The amount of extra space required can change depending on the compiler, +** target platform, and SQLite version. +** +** [[SQLITE_CONFIG_PMASZ]] +**
SQLITE_CONFIG_PMASZ +**
^The SQLITE_CONFIG_PMASZ option takes a single parameter which +** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded +** sorter to that integer. The default minimum PMA Size is set by the +** [SQLITE_SORTER_PMASZ] compile-time option. New threads are launched +** to help with sort operations when multithreaded sorting +** is enabled (using the [PRAGMA threads] command) and the amount of content +** to be sorted exceeds the page size times the minimum of the +** [PRAGMA cache_size] setting and this value. +** +** [[SQLITE_CONFIG_STMTJRNL_SPILL]] +**
SQLITE_CONFIG_STMTJRNL_SPILL +**
^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which +** becomes the [statement journal] spill-to-disk threshold. +** [Statement journals] are held in memory until their size (in bytes) +** exceeds this threshold, at which point they are written to disk. +** Or if the threshold is -1, statement journals are always held +** exclusively in memory. +** Since many statement journals never become large, setting the spill +** threshold to a value such as 64KiB can greatly reduce the amount of +** I/O required to support statement rollback. +** The default value for this setting is controlled by the +** [SQLITE_STMTJRNL_SPILL] compile-time option. +** +** [[SQLITE_CONFIG_SORTERREF_SIZE]] +**
SQLITE_CONFIG_SORTERREF_SIZE +**
The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter +** of type (int) - the new value of the sorter-reference size threshold. +** Usually, when SQLite uses an external sort to order records according +** to an ORDER BY clause, all fields required by the caller are present in the +** sorted records. However, if SQLite determines based on the declared type +** of a table column that its values are likely to be very large - larger +** than the configured sorter-reference size threshold - then a reference +** is stored in each sorted record and the required column values loaded +** from the database as records are returned in sorted order. The default +** value for this option is to never use this optimization. Specifying a +** negative value for this option restores the default behavior. +** This option is only available if SQLite is compiled with the +** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. +** +** [[SQLITE_CONFIG_MEMDB_MAXSIZE]] +**
SQLITE_CONFIG_MEMDB_MAXSIZE +**
The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter +** [sqlite3_int64] parameter which is the default maximum size for an in-memory +** database created using [sqlite3_deserialize()]. This default maximum +** size can be adjusted up or down for individual databases using the +** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control]. If this +** configuration setting is never used, then the default maximum is determined +** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that +** compile-time option is not set, then the default maximum is 1073741824. +** +** [[SQLITE_CONFIG_ROWID_IN_VIEW]] +**
SQLITE_CONFIG_ROWID_IN_VIEW +**
The SQLITE_CONFIG_ROWID_IN_VIEW option enables or disables the ability +** for VIEWs to have a ROWID. The capability can only be enabled if SQLite is +** compiled with -DSQLITE_ALLOW_ROWID_IN_VIEW, in which case the capability +** defaults to on. This configuration option queries the current setting or +** changes the setting to off or on. The argument is a pointer to an integer. +** If that integer initially holds a value of 1, then the ability for VIEWs to +** have ROWIDs is activated. If the integer initially holds zero, then the +** ability is deactivated. Any other initial value for the integer leaves the +** setting unchanged. After changes, if any, the integer is written with +** a 1 or 0, if the ability for VIEWs to have ROWIDs is on or off. If SQLite +** is compiled without -DSQLITE_ALLOW_ROWID_IN_VIEW (which is the usual and +** recommended case) then the integer is always filled with zero, regardless +** if its initial value. +**
+*/ +#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ +#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ +#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ +#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ +#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ +#define SQLITE_CONFIG_SCRATCH 6 /* No longer used */ +#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ +#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ +#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ +#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ +#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ +/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ +#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ +#define SQLITE_CONFIG_PCACHE 14 /* no-op */ +#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ +#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ +#define SQLITE_CONFIG_URI 17 /* int */ +#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ +#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */ +#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */ +#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ +#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ +#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ +#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ +#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ +#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ +#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ +#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ +#define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */ +#define SQLITE_CONFIG_ROWID_IN_VIEW 30 /* int* */ + +/* +** CAPI3REF: Database Connection Configuration Options +** +** These constants are the available integer configuration options that +** can be passed as the second parameter to the [sqlite3_db_config()] interface. +** +** The [sqlite3_db_config()] interface is a var-args functions. It takes a +** variable number of parameters, though always at least two. The number of +** parameters passed into sqlite3_db_config() depends on which of these +** constants is given as the second parameter. This documentation page +** refers to parameters beyond the second as "arguments". Thus, when this +** page says "the N-th argument" it means "the N-th parameter past the +** configuration option" or "the (N+2)-th parameter to sqlite3_db_config()". +** +** New configuration options may be added in future releases of SQLite. +** Existing configuration options might be discontinued. Applications +** should check the return code from [sqlite3_db_config()] to make sure that +** the call worked. ^The [sqlite3_db_config()] interface will return a +** non-zero [error code] if a discontinued or unsupported configuration option +** is invoked. +** +**
+** [[SQLITE_DBCONFIG_LOOKASIDE]] +**
SQLITE_DBCONFIG_LOOKASIDE
+**
The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the +** configuration of the [lookaside memory allocator] within a database +** connection. +** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are not +** in the [DBCONFIG arguments|usual format]. +** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two, +** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE +** should have a total of five parameters. +**
    +**
  1. The first argument ("buf") is a +** pointer to a memory buffer to use for lookaside memory. +** The first argument may be NULL in which case SQLite will allocate the +** lookaside buffer itself using [sqlite3_malloc()]. +**

  2. The second argument ("sz") is the +** size of each lookaside buffer slot. Lookaside is disabled if "sz" +** is less than 8. The "sz" argument should be a multiple of 8 less than +** 65536. If "sz" does not meet this constraint, it is reduced in size until +** it does. +**

  3. The third argument ("cnt") is the number of slots. Lookaside is disabled +** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so +** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt" +** parameter is usually chosen so that the product of "sz" and "cnt" is less +** than 1,000,000. +**

+**

If the "buf" argument is not NULL, then it must +** point to a memory buffer with a size that is greater than +** or equal to the product of "sz" and "cnt". +** The buffer must be aligned to an 8-byte boundary. +** The lookaside memory +** configuration for a database connection can only be changed when that +** connection is not currently using lookaside memory, or in other words +** when the value returned by [SQLITE_DBSTATUS_LOOKASIDE_USED] is zero. +** Any attempt to change the lookaside memory configuration when lookaside +** memory is in use leaves the configuration unchanged and returns +** [SQLITE_BUSY]. +** If the "buf" argument is NULL and an attempt +** to allocate memory based on "sz" and "cnt" fails, then +** lookaside is silently disabled. +**

+** The [SQLITE_CONFIG_LOOKASIDE] configuration option can be used to set the +** default lookaside configuration at initialization. The +** [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to set the default lookaside +** configuration at compile-time. Typical values for lookaside are 1200 for +** "sz" and 40 to 100 for "cnt". +**

+** +** [[SQLITE_DBCONFIG_ENABLE_FKEY]] +**
SQLITE_DBCONFIG_ENABLE_FKEY
+**
^This option is used to enable or disable the enforcement of +** [foreign key constraints]. This is the same setting that is +** enabled or disabled by the [PRAGMA foreign_keys] statement. +** The first argument is an integer which is 0 to disable FK enforcement, +** positive to enable FK enforcement or negative to leave FK enforcement +** unchanged. The second parameter is a pointer to an integer into which +** is written 0 or 1 to indicate whether FK enforcement is off or on +** following this call. The second parameter may be a NULL pointer, in +** which case the FK enforcement setting is not reported back.
+** +** [[SQLITE_DBCONFIG_ENABLE_TRIGGER]] +**
SQLITE_DBCONFIG_ENABLE_TRIGGER
+**
^This option is used to enable or disable [CREATE TRIGGER | triggers]. +** There should be two additional arguments. +** The first argument is an integer which is 0 to disable triggers, +** positive to enable triggers or negative to leave the setting unchanged. +** The second parameter is a pointer to an integer into which +** is written 0 or 1 to indicate whether triggers are disabled or enabled +** following this call. The second parameter may be a NULL pointer, in +** which case the trigger setting is not reported back. +** +**

Originally this option disabled all triggers. ^(However, since +** SQLite version 3.35.0, TEMP triggers are still allowed even if +** this option is off. So, in other words, this option now only disables +** triggers in the main database schema or in the schemas of [ATTACH]-ed +** databases.)^

+** +** [[SQLITE_DBCONFIG_ENABLE_VIEW]] +**
SQLITE_DBCONFIG_ENABLE_VIEW
+**
^This option is used to enable or disable [CREATE VIEW | views]. +** There must be two additional arguments. +** The first argument is an integer which is 0 to disable views, +** positive to enable views or negative to leave the setting unchanged. +** The second parameter is a pointer to an integer into which +** is written 0 or 1 to indicate whether views are disabled or enabled +** following this call. The second parameter may be a NULL pointer, in +** which case the view setting is not reported back. +** +**

Originally this option disabled all views. ^(However, since +** SQLite version 3.35.0, TEMP views are still allowed even if +** this option is off. So, in other words, this option now only disables +** views in the main database schema or in the schemas of ATTACH-ed +** databases.)^

+** +** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]] +**
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER
+**
^This option is used to enable or disable the +** [fts3_tokenizer()] function which is part of the +** [FTS3] full-text search engine extension. +** There must be two additional arguments. +** The first argument is an integer which is 0 to disable fts3_tokenizer() or +** positive to enable fts3_tokenizer() or negative to leave the setting +** unchanged. +** The second parameter is a pointer to an integer into which +** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled +** following this call. The second parameter may be a NULL pointer, in +** which case the new setting is not reported back.
+** +** [[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION]] +**
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
+**
^This option is used to enable or disable the [sqlite3_load_extension()] +** interface independently of the [load_extension()] SQL function. +** The [sqlite3_enable_load_extension()] API enables or disables both the +** C-API [sqlite3_load_extension()] and the SQL function [load_extension()]. +** There must be two additional arguments. +** When the first argument to this interface is 1, then only the C-API is +** enabled and the SQL function remains disabled. If the first argument to +** this interface is 0, then both the C-API and the SQL function are disabled. +** If the first argument is -1, then no changes are made to state of either the +** C-API or the SQL function. +** The second parameter is a pointer to an integer into which +** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface +** is disabled or enabled following this call. The second parameter may +** be a NULL pointer, in which case the new setting is not reported back. +**
+** +** [[SQLITE_DBCONFIG_MAINDBNAME]]
SQLITE_DBCONFIG_MAINDBNAME
+**
^This option is used to change the name of the "main" database +** schema. This option does not follow the +** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format]. +** This option takes exactly one additional argument so that the +** [sqlite3_db_config()] call has a total of three parameters. The +** extra argument must be a pointer to a constant UTF8 string which +** will become the new schema name in place of "main". ^SQLite does +** not make a copy of the new main schema name string, so the application +** must ensure that the argument passed into SQLITE_DBCONFIG MAINDBNAME +** is unchanged until after the database connection closes. +**
+** +** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]] +**
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE
+**
Usually, when a database in [WAL mode] is closed or detached from a +** database handle, SQLite checks if if there are other connections to the +** same database, and if there are no other database connection (if the +** connection being closed is the last open connection to the database), +** then SQLite performs a [checkpoint] before closing the connection and +** deletes the WAL file. The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can +** be used to override that behavior. The first argument passed to this +** operation (the third parameter to [sqlite3_db_config()]) is an integer +** which is positive to disable checkpoints-on-close, or zero (the default) +** to enable them, and negative to leave the setting unchanged. +** The second argument (the fourth parameter) is a pointer to an integer +** into which is written 0 or 1 to indicate whether checkpoints-on-close +** have been disabled - 0 if they are not disabled, 1 if they are. +**
+** +** [[SQLITE_DBCONFIG_ENABLE_QPSG]]
SQLITE_DBCONFIG_ENABLE_QPSG
+**
^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates +** the [query planner stability guarantee] (QPSG). When the QPSG is active, +** a single SQL query statement will always use the same algorithm regardless +** of values of [bound parameters].)^ The QPSG disables some query optimizations +** that look at the values of bound parameters, which can make some queries +** slower. But the QPSG has the advantage of more predictable behavior. With +** the QPSG active, SQLite will always use the same query plan in the field as +** was used during testing in the lab. +** The first argument to this setting is an integer which is 0 to disable +** the QPSG, positive to enable QPSG, or negative to leave the setting +** unchanged. The second parameter is a pointer to an integer into which +** is written 0 or 1 to indicate whether the QPSG is disabled or enabled +** following this call. +**
+** +** [[SQLITE_DBCONFIG_TRIGGER_EQP]]
SQLITE_DBCONFIG_TRIGGER_EQP
+**
By default, the output of EXPLAIN QUERY PLAN commands does not +** include output for any operations performed by trigger programs. This +** option is used to set or clear (the default) a flag that governs this +** behavior. The first parameter passed to this operation is an integer - +** positive to enable output for trigger programs, or zero to disable it, +** or negative to leave the setting unchanged. +** The second parameter is a pointer to an integer into which is written +** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if +** it is not disabled, 1 if it is. +**
+** +** [[SQLITE_DBCONFIG_RESET_DATABASE]]
SQLITE_DBCONFIG_RESET_DATABASE
+**
Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run +** [VACUUM] in order to reset a database back to an empty database +** with no schema and no content. The following process works even for +** a badly corrupted database file: +**
    +**
  1. If the database connection is newly opened, make sure it has read the +** database schema by preparing then discarding some query against the +** database, or calling sqlite3_table_column_metadata(), ignoring any +** errors. This step is only necessary if the application desires to keep +** the database in WAL mode after the reset if it was in WAL mode before +** the reset. +**
  2. sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0); +**
  3. [sqlite3_exec](db, "[VACUUM]", 0, 0, 0); +**
  4. sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0); +**
+** Because resetting a database is destructive and irreversible, the +** process requires the use of this obscure API and multiple steps to +** help ensure that it does not happen by accident. Because this +** feature must be capable of resetting corrupt databases, and +** shutting down virtual tables may require access to that corrupt +** storage, the library must abandon any installed virtual tables +** without calling their xDestroy() methods. +** +** [[SQLITE_DBCONFIG_DEFENSIVE]]
SQLITE_DBCONFIG_DEFENSIVE
+**
The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the +** "defensive" flag for a database connection. When the defensive +** flag is enabled, language features that allow ordinary SQL to +** deliberately corrupt the database file are disabled. The disabled +** features include but are not limited to the following: +**
    +**
  • The [PRAGMA writable_schema=ON] statement. +**
  • The [PRAGMA journal_mode=OFF] statement. +**
  • The [PRAGMA schema_version=N] statement. +**
  • Writes to the [sqlite_dbpage] virtual table. +**
  • Direct writes to [shadow tables]. +**
+**
+** +** [[SQLITE_DBCONFIG_WRITABLE_SCHEMA]]
SQLITE_DBCONFIG_WRITABLE_SCHEMA
+**
The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the +** "writable_schema" flag. This has the same effect and is logically equivalent +** to setting [PRAGMA writable_schema=ON] or [PRAGMA writable_schema=OFF]. +** The first argument to this setting is an integer which is 0 to disable +** the writable_schema, positive to enable writable_schema, or negative to +** leave the setting unchanged. The second parameter is a pointer to an +** integer into which is written 0 or 1 to indicate whether the writable_schema +** is enabled or disabled following this call. +**
+** +** [[SQLITE_DBCONFIG_LEGACY_ALTER_TABLE]] +**
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE
+**
The SQLITE_DBCONFIG_LEGACY_ALTER_TABLE option activates or deactivates +** the legacy behavior of the [ALTER TABLE RENAME] command such it +** behaves as it did prior to [version 3.24.0] (2018-06-04). See the +** "Compatibility Notice" on the [ALTER TABLE RENAME documentation] for +** additional information. This feature can also be turned on and off +** using the [PRAGMA legacy_alter_table] statement. +**
+** +** [[SQLITE_DBCONFIG_DQS_DML]] +**
SQLITE_DBCONFIG_DQS_DML
+**
The SQLITE_DBCONFIG_DQS_DML option activates or deactivates +** the legacy [double-quoted string literal] misfeature for DML statements +** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The +** default value of this setting is determined by the [-DSQLITE_DQS] +** compile-time option. +**
+** +** [[SQLITE_DBCONFIG_DQS_DDL]] +**
SQLITE_DBCONFIG_DQS_DDL
+**
The SQLITE_DBCONFIG_DQS option activates or deactivates +** the legacy [double-quoted string literal] misfeature for DDL statements, +** such as CREATE TABLE and CREATE INDEX. The +** default value of this setting is determined by the [-DSQLITE_DQS] +** compile-time option. +**
+** +** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]] +**
SQLITE_DBCONFIG_TRUSTED_SCHEMA
+**
The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to +** assume that database schemas are untainted by malicious content. +** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite +** takes additional defensive steps to protect the application from harm +** including: +**
    +**
  • Prohibit the use of SQL functions inside triggers, views, +** CHECK constraints, DEFAULT clauses, expression indexes, +** partial indexes, or generated columns +** unless those functions are tagged with [SQLITE_INNOCUOUS]. +**
  • Prohibit the use of virtual tables inside of triggers or views +** unless those virtual tables are tagged with [SQLITE_VTAB_INNOCUOUS]. +**
+** This setting defaults to "on" for legacy compatibility, however +** all applications are advised to turn it off if possible. This setting +** can also be controlled using the [PRAGMA trusted_schema] statement. +**
+** +** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]] +**
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT
+**
The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates +** the legacy file format flag. When activated, this flag causes all newly +** created database file to have a schema format version number (the 4-byte +** integer found at offset 44 into the database header) of 1. This in turn +** means that the resulting database file will be readable and writable by +** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting, +** newly created databases are generally not understandable by SQLite versions +** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there +** is now scarcely any need to generate database files that are compatible +** all the way back to version 3.0.0, and so this setting is of little +** practical use, but is provided so that SQLite can continue to claim the +** ability to generate new database files that are compatible with version +** 3.0.0. +**

Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on, +** the [VACUUM] command will fail with an obscure error when attempting to +** process a table with generated columns and a descending index. This is +** not considered a bug since SQLite versions 3.3.0 and earlier do not support +** either generated columns or descending indexes. +**

+** +** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]] +**
SQLITE_DBCONFIG_STMT_SCANSTATUS
+**
The SQLITE_DBCONFIG_STMT_SCANSTATUS option is only useful in +** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears +** a flag that enables collection of the sqlite3_stmt_scanstatus_v2() +** statistics. For statistics to be collected, the flag must be set on +** the database handle both when the SQL statement is prepared and when it +** is stepped. The flag is set (collection of statistics is enabled) +** by default.

This option takes two arguments: an integer and a pointer to +** an integer.. The first argument is 1, 0, or -1 to enable, disable, or +** leave unchanged the statement scanstatus option. If the second argument +** is not NULL, then the value of the statement scanstatus setting after +** processing the first argument is written into the integer that the second +** argument points to. +**

+** +** [[SQLITE_DBCONFIG_REVERSE_SCANORDER]] +**
SQLITE_DBCONFIG_REVERSE_SCANORDER
+**
The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order +** in which tables and indexes are scanned so that the scans start at the end +** and work toward the beginning rather than starting at the beginning and +** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the +** same as setting [PRAGMA reverse_unordered_selects].

This option takes +** two arguments which are an integer and a pointer to an integer. The first +** argument is 1, 0, or -1 to enable, disable, or leave unchanged the +** reverse scan order flag, respectively. If the second argument is not NULL, +** then 0 or 1 is written into the integer that the second argument points to +** depending on if the reverse scan order flag is set after processing the +** first argument. +**

+** +** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]] +**
SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE
+**
The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables +** the ability of the [ATTACH DATABASE] SQL command to create a new database +** file if the database filed named in the ATTACH command does not already +** exist. This ability of ATTACH to create a new database is enabled by +** default. Applications can disable or reenable the ability for ATTACH to +** create new database files using this DBCONFIG option.

+** This option takes two arguments which are an integer and a pointer +** to an integer. The first argument is 1, 0, or -1 to enable, disable, or +** leave unchanged the attach-create flag, respectively. If the second +** argument is not NULL, then 0 or 1 is written into the integer that the +** second argument points to depending on if the attach-create flag is set +** after processing the first argument. +**

+** +** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]] +**
SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE
+**
The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the +** ability of the [ATTACH DATABASE] SQL command to open a database for writing. +** This capability is enabled by default. Applications can disable or +** reenable this capability using the current DBCONFIG option. If the +** the this capability is disabled, the [ATTACH] command will still work, +** but the database will be opened read-only. If this option is disabled, +** then the ability to create a new database using [ATTACH] is also disabled, +** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE] +** option.

+** This option takes two arguments which are an integer and a pointer +** to an integer. The first argument is 1, 0, or -1 to enable, disable, or +** leave unchanged the ability to ATTACH another database for writing, +** respectively. If the second argument is not NULL, then 0 or 1 is written +** into the integer to which the second argument points, depending on whether +** the ability to ATTACH a read/write database is enabled or disabled +** after processing the first argument. +**

+** +** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]] +**
SQLITE_DBCONFIG_ENABLE_COMMENTS
+**
The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the +** ability to include comments in SQL text. Comments are enabled by default. +** An application can disable or reenable comments in SQL text using this +** DBCONFIG option.

+** This option takes two arguments which are an integer and a pointer +** to an integer. The first argument is 1, 0, or -1 to enable, disable, or +** leave unchanged the ability to use comments in SQL text, +** respectively. If the second argument is not NULL, then 0 or 1 is written +** into the integer that the second argument points to depending on if +** comments are allowed in SQL text after processing the first argument. +**

+** +**
+** +** [[DBCONFIG arguments]]

Arguments To SQLITE_DBCONFIG Options

+** +**

Most of the SQLITE_DBCONFIG options take two arguments, so that the +** overall call to [sqlite3_db_config()] has a total of four parameters. +** The first argument (the third parameter to sqlite3_db_config()) is a integer. +** The second argument is a pointer to an integer. If the first argument is 1, +** then the option becomes enabled. If the first integer argument is 0, then the +** option is disabled. If the first argument is -1, then the option setting +** is unchanged. The second argument, the pointer to an integer, may be NULL. +** If the second argument is not NULL, then a value of 0 or 1 is written into +** the integer to which the second argument points, depending on whether the +** setting is disabled or enabled after applying any changes specified by +** the first argument. +** +**

While most SQLITE_DBCONFIG options use the argument format +** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME] +** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the +** documentation of those exceptional options for details. +*/ +#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ +#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ +#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ +#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */ +#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */ +#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */ +#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */ +#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */ +#define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */ +#define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */ +#define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */ +#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */ +#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */ +#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */ +#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */ +#define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */ + +/* +** CAPI3REF: Enable Or Disable Extended Result Codes +** METHOD: sqlite3 +** +** ^The sqlite3_extended_result_codes() routine enables or disables the +** [extended result codes] feature of SQLite. ^The extended result +** codes are disabled by default for historical compatibility. +*/ +SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); + +/* +** CAPI3REF: Last Insert Rowid +** METHOD: sqlite3 +** +** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables) +** has a unique 64-bit signed +** integer key called the [ROWID | "rowid"]. ^The rowid is always available +** as an undeclared column named ROWID, OID, or _ROWID_ as long as those +** names are not also used by explicitly declared columns. ^If +** the table has a column of type [INTEGER PRIMARY KEY] then that column +** is another alias for the rowid. +** +** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of +** the most recent successful [INSERT] into a rowid table or [virtual table] +** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not +** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred +** on the database connection D, then sqlite3_last_insert_rowid(D) returns +** zero. +** +** As well as being set automatically as rows are inserted into database +** tables, the value returned by this function may be set explicitly by +** [sqlite3_set_last_insert_rowid()] +** +** Some virtual table implementations may INSERT rows into rowid tables as +** part of committing a transaction (e.g. to flush data accumulated in memory +** to disk). In this case subsequent calls to this function return the rowid +** associated with these internal INSERT operations, which leads to +** unintuitive results. Virtual table implementations that do write to rowid +** tables in this way can avoid this problem by restoring the original +** rowid value using [sqlite3_set_last_insert_rowid()] before returning +** control to the user. +** +** ^(If an [INSERT] occurs within a trigger then this routine will +** return the [rowid] of the inserted row as long as the trigger is +** running. Once the trigger program ends, the value returned +** by this routine reverts to what it was before the trigger was fired.)^ +** +** ^An [INSERT] that fails due to a constraint violation is not a +** successful [INSERT] and does not change the value returned by this +** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, +** and INSERT OR ABORT make no changes to the return value of this +** routine when their insertion fails. ^(When INSERT OR REPLACE +** encounters a constraint violation, it does not fail. The +** INSERT continues to completion after deleting rows that caused +** the constraint problem so INSERT OR REPLACE will always change +** the return value of this interface.)^ +** +** ^For the purposes of this routine, an [INSERT] is considered to +** be successful even if it is subsequently rolled back. +** +** This function is accessible to SQL statements via the +** [last_insert_rowid() SQL function]. +** +** If a separate thread performs a new [INSERT] on the same +** database connection while the [sqlite3_last_insert_rowid()] +** function is running and thus changes the last insert [rowid], +** then the value returned by [sqlite3_last_insert_rowid()] is +** unpredictable and might not equal either the old or the new +** last insert [rowid]. +*/ +SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); + +/* +** CAPI3REF: Set the Last Insert Rowid value. +** METHOD: sqlite3 +** +** The sqlite3_set_last_insert_rowid(D, R) method allows the application to +** set the value returned by calling sqlite3_last_insert_rowid(D) to R +** without inserting a row into the database. +*/ +SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64); + +/* +** CAPI3REF: Count The Number Of Rows Modified +** METHOD: sqlite3 +** +** ^These functions return the number of rows modified, inserted or +** deleted by the most recently completed INSERT, UPDATE or DELETE +** statement on the database connection specified by the only parameter. +** The two functions are identical except for the type of the return value +** and that if the number of rows modified by the most recent INSERT, UPDATE, +** or DELETE is greater than the maximum value supported by type "int", then +** the return value of sqlite3_changes() is undefined. ^Executing any other +** type of SQL statement does not modify the value returned by these functions. +** For the purposes of this interface, a CREATE TABLE AS SELECT statement +** does not count as an INSERT, UPDATE or DELETE statement and hence the rows +** added to the new table by the CREATE TABLE AS SELECT statement are not +** counted. +** +** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are +** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], +** [foreign key actions] or [REPLACE] constraint resolution are not counted. +** +** Changes to a view that are intercepted by +** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value +** returned by sqlite3_changes() immediately after an INSERT, UPDATE or +** DELETE statement run on a view is always zero. Only changes made to real +** tables are counted. +** +** Things are more complicated if the sqlite3_changes() function is +** executed while a trigger program is running. This may happen if the +** program uses the [changes() SQL function], or if some other callback +** function invokes sqlite3_changes() directly. Essentially: +** +**

    +**
  • ^(Before entering a trigger program the value returned by +** sqlite3_changes() function is saved. After the trigger program +** has finished, the original value is restored.)^ +** +**
  • ^(Within a trigger program each INSERT, UPDATE and DELETE +** statement sets the value returned by sqlite3_changes() +** upon completion as normal. Of course, this value will not include +** any changes performed by sub-triggers, as the sqlite3_changes() +** value will be saved and restored after each sub-trigger has run.)^ +**
+** +** ^This means that if the changes() SQL function (or similar) is used +** by the first INSERT, UPDATE or DELETE statement within a trigger, it +** returns the value as set when the calling statement began executing. +** ^If it is used by the second or subsequent such statement within a trigger +** program, the value returned reflects the number of rows modified by the +** previous INSERT, UPDATE or DELETE statement within the same trigger. +** +** If a separate thread makes changes on the same database connection +** while [sqlite3_changes()] is running then the value returned +** is unpredictable and not meaningful. +** +** See also: +**
    +**
  • the [sqlite3_total_changes()] interface +**
  • the [count_changes pragma] +**
  • the [changes() SQL function] +**
  • the [data_version pragma] +**
+*/ +SQLITE_API int sqlite3_changes(sqlite3*); +SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*); + +/* +** CAPI3REF: Total Number Of Rows Modified +** METHOD: sqlite3 +** +** ^These functions return the total number of rows inserted, modified or +** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed +** since the database connection was opened, including those executed as +** part of trigger programs. The two functions are identical except for the +** type of the return value and that if the number of rows modified by the +** connection exceeds the maximum value supported by type "int", then +** the return value of sqlite3_total_changes() is undefined. ^Executing +** any other type of SQL statement does not affect the value returned by +** sqlite3_total_changes(). +** +** ^Changes made as part of [foreign key actions] are included in the +** count, but those made as part of REPLACE constraint resolution are +** not. ^Changes to a view that are intercepted by INSTEAD OF triggers +** are not counted. +** +** The [sqlite3_total_changes(D)] interface only reports the number +** of rows that changed due to SQL statement run against database +** connection D. Any changes by other database connections are ignored. +** To detect changes against a database file from other database +** connections use the [PRAGMA data_version] command or the +** [SQLITE_FCNTL_DATA_VERSION] [file control]. +** +** If a separate thread makes changes on the same database connection +** while [sqlite3_total_changes()] is running then the value +** returned is unpredictable and not meaningful. +** +** See also: +**
    +**
  • the [sqlite3_changes()] interface +**
  • the [count_changes pragma] +**
  • the [changes() SQL function] +**
  • the [data_version pragma] +**
  • the [SQLITE_FCNTL_DATA_VERSION] [file control] +**
+*/ +SQLITE_API int sqlite3_total_changes(sqlite3*); +SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*); + +/* +** CAPI3REF: Interrupt A Long-Running Query +** METHOD: sqlite3 +** +** ^This function causes any pending database operation to abort and +** return at its earliest opportunity. This routine is typically +** called in response to a user action such as pressing "Cancel" +** or Ctrl-C where the user wants a long query operation to halt +** immediately. +** +** ^It is safe to call this routine from a thread different from the +** thread that is currently running the database operation. But it +** is not safe to call this routine with a [database connection] that +** is closed or might close before sqlite3_interrupt() returns. +** +** ^If an SQL operation is very nearly finished at the time when +** sqlite3_interrupt() is called, then it might not have an opportunity +** to be interrupted and might continue to completion. +** +** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. +** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE +** that is inside an explicit transaction, then the entire transaction +** will be rolled back automatically. +** +** ^The sqlite3_interrupt(D) call is in effect until all currently running +** SQL statements on [database connection] D complete. ^Any new SQL statements +** that are started after the sqlite3_interrupt() call and before the +** running statement count reaches zero are interrupted as if they had been +** running prior to the sqlite3_interrupt() call. ^New SQL statements +** that are started after the running statement count reaches zero are +** not effected by the sqlite3_interrupt(). +** ^A call to sqlite3_interrupt(D) that occurs when there are no running +** SQL statements is a no-op and has no effect on SQL statements +** that are started after the sqlite3_interrupt() call returns. +** +** ^The [sqlite3_is_interrupted(D)] interface can be used to determine whether +** or not an interrupt is currently in effect for [database connection] D. +** It returns 1 if an interrupt is currently in effect, or 0 otherwise. +*/ +SQLITE_API void sqlite3_interrupt(sqlite3*); +SQLITE_API int sqlite3_is_interrupted(sqlite3*); + +/* +** CAPI3REF: Determine If An SQL Statement Is Complete +** +** These routines are useful during command-line input to determine if the +** currently entered text seems to form a complete SQL statement or +** if additional input is needed before sending the text into +** SQLite for parsing. ^These routines return 1 if the input string +** appears to be a complete SQL statement. ^A statement is judged to be +** complete if it ends with a semicolon token and is not a prefix of a +** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within +** string literals or quoted identifier names or comments are not +** independent tokens (they are part of the token in which they are +** embedded) and thus do not count as a statement terminator. ^Whitespace +** and comments that follow the final semicolon are ignored. +** +** ^These routines return 0 if the statement is incomplete. ^If a +** memory allocation fails, then SQLITE_NOMEM is returned. +** +** ^These routines do not parse the SQL statements thus +** will not detect syntactically incorrect SQL. +** +** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior +** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked +** automatically by sqlite3_complete16(). If that initialization fails, +** then the return value from sqlite3_complete16() will be non-zero +** regardless of whether or not the input SQL is complete.)^ +** +** The input to [sqlite3_complete()] must be a zero-terminated +** UTF-8 string. +** +** The input to [sqlite3_complete16()] must be a zero-terminated +** UTF-16 string in native byte order. +*/ +SQLITE_API int sqlite3_complete(const char *sql); +SQLITE_API int sqlite3_complete16(const void *sql); + +/* +** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors +** KEYWORDS: {busy-handler callback} {busy handler} +** METHOD: sqlite3 +** +** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X +** that might be invoked with argument P whenever +** an attempt is made to access a database table associated with +** [database connection] D when another thread +** or process has the table locked. +** The sqlite3_busy_handler() interface is used to implement +** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. +** +** ^If the busy callback is NULL, then [SQLITE_BUSY] +** is returned immediately upon encountering the lock. ^If the busy callback +** is not NULL, then the callback might be invoked with two arguments. +** +** ^The first argument to the busy handler is a copy of the void* pointer which +** is the third argument to sqlite3_busy_handler(). ^The second argument to +** the busy handler callback is the number of times that the busy handler has +** been invoked previously for the same locking event. ^If the +** busy callback returns 0, then no additional attempts are made to +** access the database and [SQLITE_BUSY] is returned +** to the application. +** ^If the callback returns non-zero, then another attempt +** is made to access the database and the cycle repeats. +** +** The presence of a busy handler does not guarantee that it will be invoked +** when there is lock contention. ^If SQLite determines that invoking the busy +** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] +** to the application instead of invoking the +** busy handler. +** Consider a scenario where one process is holding a read lock that +** it is trying to promote to a reserved lock and +** a second process is holding a reserved lock that it is trying +** to promote to an exclusive lock. The first process cannot proceed +** because it is blocked by the second and the second process cannot +** proceed because it is blocked by the first. If both processes +** invoke the busy handlers, neither will make any progress. Therefore, +** SQLite returns [SQLITE_BUSY] for the first process, hoping that this +** will induce the first process to release its read lock and allow +** the second process to proceed. +** +** ^The default busy callback is NULL. +** +** ^(There can only be a single busy handler defined for each +** [database connection]. Setting a new busy handler clears any +** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] +** or evaluating [PRAGMA busy_timeout=N] will change the +** busy handler and thus clear any previously set busy handler. +** +** The busy callback should not take any actions which modify the +** database connection that invoked the busy handler. In other words, +** the busy handler is not reentrant. Any such actions +** result in undefined behavior. +** +** A busy handler must not close the database connection +** or [prepared statement] that invoked the busy handler. +*/ +SQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*); + +/* +** CAPI3REF: Set A Busy Timeout +** METHOD: sqlite3 +** +** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps +** for a specified amount of time when a table is locked. ^The handler +** will sleep multiple times until at least "ms" milliseconds of sleeping +** have accumulated. ^After at least "ms" milliseconds of sleeping, +** the handler returns 0 which causes [sqlite3_step()] to return +** [SQLITE_BUSY]. +** +** ^Calling this routine with an argument less than or equal to zero +** turns off all busy handlers. +** +** ^(There can only be a single busy handler for a particular +** [database connection] at any given moment. If another busy handler +** was defined (using [sqlite3_busy_handler()]) prior to calling +** this routine, that other busy handler is cleared.)^ +** +** See also: [PRAGMA busy_timeout] +*/ +SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); + +/* +** CAPI3REF: Set the Setlk Timeout +** METHOD: sqlite3 +** +** This routine is only useful in SQLITE_ENABLE_SETLK_TIMEOUT builds. If +** the VFS supports blocking locks, it sets the timeout in ms used by +** eligible locks taken on wal mode databases by the specified database +** handle. In non-SQLITE_ENABLE_SETLK_TIMEOUT builds, or if the VFS does +** not support blocking locks, this function is a no-op. +** +** Passing 0 to this function disables blocking locks altogether. Passing +** -1 to this function requests that the VFS blocks for a long time - +** indefinitely if possible. The results of passing any other negative value +** are undefined. +** +** Internally, each SQLite database handle store two timeout values - the +** busy-timeout (used for rollback mode databases, or if the VFS does not +** support blocking locks) and the setlk-timeout (used for blocking locks +** on wal-mode databases). The sqlite3_busy_timeout() method sets both +** values, this function sets only the setlk-timeout value. Therefore, +** to configure separate busy-timeout and setlk-timeout values for a single +** database handle, call sqlite3_busy_timeout() followed by this function. +** +** Whenever the number of connections to a wal mode database falls from +** 1 to 0, the last connection takes an exclusive lock on the database, +** then checkpoints and deletes the wal file. While it is doing this, any +** new connection that tries to read from the database fails with an +** SQLITE_BUSY error. Or, if the SQLITE_SETLK_BLOCK_ON_CONNECT flag is +** passed to this API, the new connection blocks until the exclusive lock +** has been released. +*/ +SQLITE_API int sqlite3_setlk_timeout(sqlite3*, int ms, int flags); + +/* +** CAPI3REF: Flags for sqlite3_setlk_timeout() +*/ +#define SQLITE_SETLK_BLOCK_ON_CONNECT 0x01 + +/* +** CAPI3REF: Convenience Routines For Running Queries +** METHOD: sqlite3 +** +** This is a legacy interface that is preserved for backwards compatibility. +** Use of this interface is not recommended. +** +** Definition: A result table is memory data structure created by the +** [sqlite3_get_table()] interface. A result table records the +** complete query results from one or more queries. +** +** The table conceptually has a number of rows and columns. But +** these numbers are not part of the result table itself. These +** numbers are obtained separately. Let N be the number of rows +** and M be the number of columns. +** +** A result table is an array of pointers to zero-terminated UTF-8 strings. +** There are (N+1)*M elements in the array. The first M pointers point +** to zero-terminated strings that contain the names of the columns. +** The remaining entries all point to query results. NULL values result +** in NULL pointers. All other values are in their UTF-8 zero-terminated +** string representation as returned by [sqlite3_column_text()]. +** +** A result table might consist of one or more memory allocations. +** It is not safe to pass a result table directly to [sqlite3_free()]. +** A result table should be deallocated using [sqlite3_free_table()]. +** +** ^(As an example of the result table format, suppose a query result +** is as follows: +** +**
+**        Name        | Age
+**        -----------------------
+**        Alice       | 43
+**        Bob         | 28
+**        Cindy       | 21
+** 
+** +** There are two columns (M==2) and three rows (N==3). Thus the +** result table has 8 entries. Suppose the result table is stored +** in an array named azResult. Then azResult holds this content: +** +**
+**        azResult[0] = "Name";
+**        azResult[1] = "Age";
+**        azResult[2] = "Alice";
+**        azResult[3] = "43";
+**        azResult[4] = "Bob";
+**        azResult[5] = "28";
+**        azResult[6] = "Cindy";
+**        azResult[7] = "21";
+** 
)^ +** +** ^The sqlite3_get_table() function evaluates one or more +** semicolon-separated SQL statements in the zero-terminated UTF-8 +** string of its 2nd parameter and returns a result table to the +** pointer given in its 3rd parameter. +** +** After the application has finished with the result from sqlite3_get_table(), +** it must pass the result table pointer to sqlite3_free_table() in order to +** release the memory that was malloced. Because of the way the +** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling +** function must not try to call [sqlite3_free()] directly. Only +** [sqlite3_free_table()] is able to release the memory properly and safely. +** +** The sqlite3_get_table() interface is implemented as a wrapper around +** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access +** to any internal data structures of SQLite. It uses only the public +** interface defined here. As a consequence, errors that occur in the +** wrapper layer outside of the internal [sqlite3_exec()] call are not +** reflected in subsequent calls to [sqlite3_errcode()] or +** [sqlite3_errmsg()]. +*/ +SQLITE_API int sqlite3_get_table( + sqlite3 *db, /* An open database */ + const char *zSql, /* SQL to be evaluated */ + char ***pazResult, /* Results of the query */ + int *pnRow, /* Number of result rows written here */ + int *pnColumn, /* Number of result columns written here */ + char **pzErrmsg /* Error msg written here */ +); +SQLITE_API void sqlite3_free_table(char **result); + +/* +** CAPI3REF: Formatted String Printing Functions +** +** These routines are work-alikes of the "printf()" family of functions +** from the standard C library. +** These routines understand most of the common formatting options from +** the standard library printf() +** plus some additional non-standard formats ([%q], [%Q], [%w], and [%z]). +** See the [built-in printf()] documentation for details. +** +** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their +** results into memory obtained from [sqlite3_malloc64()]. +** The strings returned by these two routines should be +** released by [sqlite3_free()]. ^Both routines return a +** NULL pointer if [sqlite3_malloc64()] is unable to allocate enough +** memory to hold the resulting string. +** +** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from +** the standard C library. The result is written into the +** buffer supplied as the second parameter whose size is given by +** the first parameter. Note that the order of the +** first two parameters is reversed from snprintf().)^ This is an +** historical accident that cannot be fixed without breaking +** backwards compatibility. ^(Note also that sqlite3_snprintf() +** returns a pointer to its buffer instead of the number of +** characters actually written into the buffer.)^ We admit that +** the number of characters written would be a more useful return +** value but we cannot change the implementation of sqlite3_snprintf() +** now without breaking compatibility. +** +** ^As long as the buffer size is greater than zero, sqlite3_snprintf() +** guarantees that the buffer is always zero-terminated. ^The first +** parameter "n" is the total size of the buffer, including space for +** the zero terminator. So the longest string that can be completely +** written will be n-1 characters. +** +** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). +** +** See also: [built-in printf()], [printf() SQL function] +*/ +SQLITE_API char *sqlite3_mprintf(const char*,...); +SQLITE_API char *sqlite3_vmprintf(const char*, va_list); +SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); +SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); + +/* +** CAPI3REF: Memory Allocation Subsystem +** +** The SQLite core uses these three routines for all of its own +** internal memory allocation needs. "Core" in the previous sentence +** does not include operating-system specific [VFS] implementation. The +** Windows VFS uses native malloc() and free() for some operations. +** +** ^The sqlite3_malloc() routine returns a pointer to a block +** of memory at least N bytes in length, where N is the parameter. +** ^If sqlite3_malloc() is unable to obtain sufficient free +** memory, it returns a NULL pointer. ^If the parameter N to +** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns +** a NULL pointer. +** +** ^The sqlite3_malloc64(N) routine works just like +** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead +** of a signed 32-bit integer. +** +** ^Calling sqlite3_free() with a pointer previously returned +** by sqlite3_malloc() or sqlite3_realloc() releases that memory so +** that it might be reused. ^The sqlite3_free() routine is +** a no-op if is called with a NULL pointer. Passing a NULL pointer +** to sqlite3_free() is harmless. After being freed, memory +** should neither be read nor written. Even reading previously freed +** memory might result in a segmentation fault or other severe error. +** Memory corruption, a segmentation fault, or other severe error +** might result if sqlite3_free() is called with a non-NULL pointer that +** was not obtained from sqlite3_malloc() or sqlite3_realloc(). +** +** ^The sqlite3_realloc(X,N) interface attempts to resize a +** prior memory allocation X to be at least N bytes. +** ^If the X parameter to sqlite3_realloc(X,N) +** is a NULL pointer then its behavior is identical to calling +** sqlite3_malloc(N). +** ^If the N parameter to sqlite3_realloc(X,N) is zero or +** negative then the behavior is exactly the same as calling +** sqlite3_free(X). +** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation +** of at least N bytes in size or NULL if insufficient memory is available. +** ^If M is the size of the prior allocation, then min(N,M) bytes +** of the prior allocation are copied into the beginning of buffer returned +** by sqlite3_realloc(X,N) and the prior allocation is freed. +** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the +** prior allocation is not freed. +** +** ^The sqlite3_realloc64(X,N) interfaces works the same as +** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead +** of a 32-bit signed integer. +** +** ^If X is a memory allocation previously obtained from sqlite3_malloc(), +** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then +** sqlite3_msize(X) returns the size of that memory allocation in bytes. +** ^The value returned by sqlite3_msize(X) might be larger than the number +** of bytes requested when X was allocated. ^If X is a NULL pointer then +** sqlite3_msize(X) returns zero. If X points to something that is not +** the beginning of memory allocation, or if it points to a formerly +** valid memory allocation that has now been freed, then the behavior +** of sqlite3_msize(X) is undefined and possibly harmful. +** +** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(), +** sqlite3_malloc64(), and sqlite3_realloc64() +** is always aligned to at least an 8 byte boundary, or to a +** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time +** option is used. +** +** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] +** must be either NULL or else pointers obtained from a prior +** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have +** not yet been released. +** +** The application must not read or write any part of +** a block of memory after it has been released using +** [sqlite3_free()] or [sqlite3_realloc()]. +*/ +SQLITE_API void *sqlite3_malloc(int); +SQLITE_API void *sqlite3_malloc64(sqlite3_uint64); +SQLITE_API void *sqlite3_realloc(void*, int); +SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64); +SQLITE_API void sqlite3_free(void*); +SQLITE_API sqlite3_uint64 sqlite3_msize(void*); + +/* +** CAPI3REF: Memory Allocator Statistics +** +** SQLite provides these two interfaces for reporting on the status +** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] +** routines, which form the built-in memory allocation subsystem. +** +** ^The [sqlite3_memory_used()] routine returns the number of bytes +** of memory currently outstanding (malloced but not freed). +** ^The [sqlite3_memory_highwater()] routine returns the maximum +** value of [sqlite3_memory_used()] since the high-water mark +** was last reset. ^The values returned by [sqlite3_memory_used()] and +** [sqlite3_memory_highwater()] include any overhead +** added by SQLite in its implementation of [sqlite3_malloc()], +** but not overhead added by the any underlying system library +** routines that [sqlite3_malloc()] may call. +** +** ^The memory high-water mark is reset to the current value of +** [sqlite3_memory_used()] if and only if the parameter to +** [sqlite3_memory_highwater()] is true. ^The value returned +** by [sqlite3_memory_highwater(1)] is the high-water mark +** prior to the reset. +*/ +SQLITE_API sqlite3_int64 sqlite3_memory_used(void); +SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); + +/* +** CAPI3REF: Pseudo-Random Number Generator +** +** SQLite contains a high-quality pseudo-random number generator (PRNG) used to +** select random [ROWID | ROWIDs] when inserting new records into a table that +** already uses the largest possible [ROWID]. The PRNG is also used for +** the built-in random() and randomblob() SQL functions. This interface allows +** applications to access the same PRNG for other purposes. +** +** ^A call to this routine stores N bytes of randomness into buffer P. +** ^The P parameter can be a NULL pointer. +** +** ^If this routine has not been previously called or if the previous +** call had N less than one or a NULL pointer for P, then the PRNG is +** seeded using randomness obtained from the xRandomness method of +** the default [sqlite3_vfs] object. +** ^If the previous call to this routine had an N of 1 or more and a +** non-NULL P then the pseudo-randomness is generated +** internally and without recourse to the [sqlite3_vfs] xRandomness +** method. +*/ +SQLITE_API void sqlite3_randomness(int N, void *P); + +/* +** CAPI3REF: Compile-Time Authorization Callbacks +** METHOD: sqlite3 +** KEYWORDS: {authorizer callback} +** +** ^This routine registers an authorizer callback with a particular +** [database connection], supplied in the first argument. +** ^The authorizer callback is invoked as SQL statements are being compiled +** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], +** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()], +** and [sqlite3_prepare16_v3()]. ^At various +** points during the compilation process, as logic is being created +** to perform various actions, the authorizer callback is invoked to +** see if those actions are allowed. ^The authorizer callback should +** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the +** specific action but allow the SQL statement to continue to be +** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be +** rejected with an error. ^If the authorizer callback returns +** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] +** then the [sqlite3_prepare_v2()] or equivalent call that triggered +** the authorizer will fail with an error message. +** +** When the callback returns [SQLITE_OK], that means the operation +** requested is ok. ^When the callback returns [SQLITE_DENY], the +** [sqlite3_prepare_v2()] or equivalent call that triggered the +** authorizer will fail with an error message explaining that +** access is denied. +** +** ^The first parameter to the authorizer callback is a copy of the third +** parameter to the sqlite3_set_authorizer() interface. ^The second parameter +** to the callback is an integer [SQLITE_COPY | action code] that specifies +** the particular action to be authorized. ^The third through sixth parameters +** to the callback are either NULL pointers or zero-terminated strings +** that contain additional details about the action to be authorized. +** Applications must always be prepared to encounter a NULL pointer in any +** of the third through the sixth parameters of the authorization callback. +** +** ^If the action code is [SQLITE_READ] +** and the callback returns [SQLITE_IGNORE] then the +** [prepared statement] statement is constructed to substitute +** a NULL value in place of the table column that would have +** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] +** return can be used to deny an untrusted user access to individual +** columns of a table. +** ^When a table is referenced by a [SELECT] but no column values are +** extracted from that table (for example in a query like +** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback +** is invoked once for that table with a column name that is an empty string. +** ^If the action code is [SQLITE_DELETE] and the callback returns +** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the +** [truncate optimization] is disabled and all rows are deleted individually. +** +** An authorizer is used when [sqlite3_prepare | preparing] +** SQL statements from an untrusted source, to ensure that the SQL statements +** do not try to access data they are not allowed to see, or that they do not +** try to execute malicious statements that damage the database. For +** example, an application may allow a user to enter arbitrary +** SQL queries for evaluation by a database. But the application does +** not want the user to be able to make arbitrary changes to the +** database. An authorizer could then be put in place while the +** user-entered SQL is being [sqlite3_prepare | prepared] that +** disallows everything except [SELECT] statements. +** +** Applications that need to process SQL from untrusted sources +** might also consider lowering resource limits using [sqlite3_limit()] +** and limiting database size using the [max_page_count] [PRAGMA] +** in addition to using an authorizer. +** +** ^(Only a single authorizer can be in place on a database connection +** at a time. Each call to sqlite3_set_authorizer overrides the +** previous call.)^ ^Disable the authorizer by installing a NULL callback. +** The authorizer is disabled by default. +** +** The authorizer callback must not do anything that will modify +** the database connection that invoked the authorizer callback. +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their +** database connections for the meaning of "modify" in this paragraph. +** +** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the +** statement might be re-prepared during [sqlite3_step()] due to a +** schema change. Hence, the application should ensure that the +** correct authorizer callback remains in place during the [sqlite3_step()]. +** +** ^Note that the authorizer callback is invoked only during +** [sqlite3_prepare()] or its variants. Authorization is not +** performed during statement evaluation in [sqlite3_step()], unless +** as stated in the previous paragraph, sqlite3_step() invokes +** sqlite3_prepare_v2() to reprepare a statement after a schema change. +*/ +SQLITE_API int sqlite3_set_authorizer( + sqlite3*, + int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), + void *pUserData +); + +/* +** CAPI3REF: Authorizer Return Codes +** +** The [sqlite3_set_authorizer | authorizer callback function] must +** return either [SQLITE_OK] or one of these two constants in order +** to signal SQLite whether or not the action is permitted. See the +** [sqlite3_set_authorizer | authorizer documentation] for additional +** information. +** +** Note that SQLITE_IGNORE is also used as a [conflict resolution mode] +** returned from the [sqlite3_vtab_on_conflict()] interface. +*/ +#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ +#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ + +/* +** CAPI3REF: Authorizer Action Codes +** +** The [sqlite3_set_authorizer()] interface registers a callback function +** that is invoked to authorize certain SQL statement actions. The +** second parameter to the callback is an integer code that specifies +** what action is being authorized. These are the integer action codes that +** the authorizer callback may be passed. +** +** These action code values signify what kind of operation is to be +** authorized. The 3rd and 4th parameters to the authorization +** callback function will be parameters or NULL depending on which of these +** codes is used as the second parameter. ^(The 5th parameter to the +** authorizer callback is the name of the database ("main", "temp", +** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback +** is the name of the inner-most trigger or view that is responsible for +** the access attempt or NULL if this access attempt is directly from +** top-level SQL code. +*/ +/******************************************* 3rd ************ 4th ***********/ +#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ +#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ +#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ +#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ +#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ +#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ +#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ +#define SQLITE_CREATE_VIEW 8 /* View Name NULL */ +#define SQLITE_DELETE 9 /* Table Name NULL */ +#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ +#define SQLITE_DROP_TABLE 11 /* Table Name NULL */ +#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ +#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ +#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ +#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ +#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ +#define SQLITE_DROP_VIEW 17 /* View Name NULL */ +#define SQLITE_INSERT 18 /* Table Name NULL */ +#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ +#define SQLITE_READ 20 /* Table Name Column Name */ +#define SQLITE_SELECT 21 /* NULL NULL */ +#define SQLITE_TRANSACTION 22 /* Operation NULL */ +#define SQLITE_UPDATE 23 /* Table Name Column Name */ +#define SQLITE_ATTACH 24 /* Filename NULL */ +#define SQLITE_DETACH 25 /* Database Name NULL */ +#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ +#define SQLITE_REINDEX 27 /* Index Name NULL */ +#define SQLITE_ANALYZE 28 /* Table Name NULL */ +#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ +#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ +#define SQLITE_FUNCTION 31 /* NULL Function Name */ +#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ +#define SQLITE_COPY 0 /* No longer used */ +#define SQLITE_RECURSIVE 33 /* NULL NULL */ + +/* +** CAPI3REF: Deprecated Tracing And Profiling Functions +** DEPRECATED +** +** These routines are deprecated. Use the [sqlite3_trace_v2()] interface +** instead of the routines described here. +** +** These routines register callback functions that can be used for +** tracing and profiling the execution of SQL statements. +** +** ^The callback function registered by sqlite3_trace() is invoked at +** various times when an SQL statement is being run by [sqlite3_step()]. +** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the +** SQL statement text as the statement first begins executing. +** ^(Additional sqlite3_trace() callbacks might occur +** as each triggered subprogram is entered. The callbacks for triggers +** contain a UTF-8 SQL comment that identifies the trigger.)^ +** +** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit +** the length of [bound parameter] expansion in the output of sqlite3_trace(). +** +** ^The callback function registered by sqlite3_profile() is invoked +** as each SQL statement finishes. ^The profile callback contains +** the original statement text and an estimate of wall-clock time +** of how long that statement took to run. ^The profile callback +** time is in units of nanoseconds, however the current implementation +** is only capable of millisecond resolution so the six least significant +** digits in the time are meaningless. Future versions of SQLite +** might provide greater resolution on the profiler callback. Invoking +** either [sqlite3_trace()] or [sqlite3_trace_v2()] will cancel the +** profile callback. +*/ +SQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*, + void(*xTrace)(void*,const char*), void*); +SQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, + void(*xProfile)(void*,const char*,sqlite3_uint64), void*); + +/* +** CAPI3REF: SQL Trace Event Codes +** KEYWORDS: SQLITE_TRACE +** +** These constants identify classes of events that can be monitored +** using the [sqlite3_trace_v2()] tracing logic. The M argument +** to [sqlite3_trace_v2(D,M,X,P)] is an OR-ed combination of one or more of +** the following constants. ^The first argument to the trace callback +** is one of the following constants. +** +** New tracing constants may be added in future releases. +** +** ^A trace callback has four arguments: xCallback(T,C,P,X). +** ^The T argument is one of the integer type codes above. +** ^The C argument is a copy of the context pointer passed in as the +** fourth argument to [sqlite3_trace_v2()]. +** The P and X arguments are pointers whose meanings depend on T. +** +**
+** [[SQLITE_TRACE_STMT]]
SQLITE_TRACE_STMT
+**
^An SQLITE_TRACE_STMT callback is invoked when a prepared statement +** first begins running and possibly at other times during the +** execution of the prepared statement, such as at the start of each +** trigger subprogram. ^The P argument is a pointer to the +** [prepared statement]. ^The X argument is a pointer to a string which +** is the unexpanded SQL text of the prepared statement or an SQL comment +** that indicates the invocation of a trigger. ^The callback can compute +** the same text that would have been returned by the legacy [sqlite3_trace()] +** interface by using the X argument when X begins with "--" and invoking +** [sqlite3_expanded_sql(P)] otherwise. +** +** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
+**
^An SQLITE_TRACE_PROFILE callback provides approximately the same +** information as is provided by the [sqlite3_profile()] callback. +** ^The P argument is a pointer to the [prepared statement] and the +** X argument points to a 64-bit integer which is approximately +** the number of nanoseconds that the prepared statement took to run. +** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. +** +** [[SQLITE_TRACE_ROW]]
SQLITE_TRACE_ROW
+**
^An SQLITE_TRACE_ROW callback is invoked whenever a prepared +** statement generates a single row of result. +** ^The P argument is a pointer to the [prepared statement] and the +** X argument is unused. +** +** [[SQLITE_TRACE_CLOSE]]
SQLITE_TRACE_CLOSE
+**
^An SQLITE_TRACE_CLOSE callback is invoked when a database +** connection closes. +** ^The P argument is a pointer to the [database connection] object +** and the X argument is unused. +**
+*/ +#define SQLITE_TRACE_STMT 0x01 +#define SQLITE_TRACE_PROFILE 0x02 +#define SQLITE_TRACE_ROW 0x04 +#define SQLITE_TRACE_CLOSE 0x08 + +/* +** CAPI3REF: SQL Trace Hook +** METHOD: sqlite3 +** +** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback +** function X against [database connection] D, using property mask M +** and context pointer P. ^If the X callback is +** NULL or if the M mask is zero, then tracing is disabled. The +** M argument should be the bitwise OR-ed combination of +** zero or more [SQLITE_TRACE] constants. +** +** ^Each call to either sqlite3_trace(D,X,P) or sqlite3_trace_v2(D,M,X,P) +** overrides (cancels) all prior calls to sqlite3_trace(D,X,P) or +** sqlite3_trace_v2(D,M,X,P) for the [database connection] D. Each +** database connection may have at most one trace callback. +** +** ^The X callback is invoked whenever any of the events identified by +** mask M occur. ^The integer return value from the callback is currently +** ignored, though this may change in future releases. Callback +** implementations should return zero to ensure future compatibility. +** +** ^A trace callback is invoked with four arguments: callback(T,C,P,X). +** ^The T argument is one of the [SQLITE_TRACE] +** constants to indicate why the callback was invoked. +** ^The C argument is a copy of the context pointer. +** The P and X arguments are pointers whose meanings depend on T. +** +** The sqlite3_trace_v2() interface is intended to replace the legacy +** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which +** are deprecated. +*/ +SQLITE_API int sqlite3_trace_v2( + sqlite3*, + unsigned uMask, + int(*xCallback)(unsigned,void*,void*,void*), + void *pCtx +); + +/* +** CAPI3REF: Query Progress Callbacks +** METHOD: sqlite3 +** +** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback +** function X to be invoked periodically during long running calls to +** [sqlite3_step()] and [sqlite3_prepare()] and similar for +** database connection D. An example use for this +** interface is to keep a GUI updated during a large query. +** +** ^The parameter P is passed through as the only parameter to the +** callback function X. ^The parameter N is the approximate number of +** [virtual machine instructions] that are evaluated between successive +** invocations of the callback X. ^If N is less than one then the progress +** handler is disabled. +** +** ^Only a single progress handler may be defined at one time per +** [database connection]; setting a new progress handler cancels the +** old one. ^Setting parameter X to NULL disables the progress handler. +** ^The progress handler is also disabled by setting N to a value less +** than 1. +** +** ^If the progress callback returns non-zero, the operation is +** interrupted. This feature can be used to implement a +** "Cancel" button on a GUI progress dialog box. +** +** The progress handler callback must not do anything that will modify +** the database connection that invoked the progress handler. +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their +** database connections for the meaning of "modify" in this paragraph. +** +** The progress handler callback would originally only be invoked from the +** bytecode engine. It still might be invoked during [sqlite3_prepare()] +** and similar because those routines might force a reparse of the schema +** which involves running the bytecode engine. However, beginning with +** SQLite version 3.41.0, the progress handler callback might also be +** invoked directly from [sqlite3_prepare()] while analyzing and generating +** code for complex queries. +*/ +SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); + +/* +** CAPI3REF: Opening A New Database Connection +** CONSTRUCTOR: sqlite3 +** +** ^These routines open an SQLite database file as specified by the +** filename argument. ^The filename argument is interpreted as UTF-8 for +** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte +** order for sqlite3_open16(). ^(A [database connection] handle is usually +** returned in *ppDb, even if an error occurs. The only exception is that +** if SQLite is unable to allocate memory to hold the [sqlite3] object, +** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] +** object.)^ ^(If the database is opened (and/or created) successfully, then +** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The +** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain +** an English language description of the error following a failure of any +** of the sqlite3_open() routines. +** +** ^The default encoding will be UTF-8 for databases created using +** sqlite3_open() or sqlite3_open_v2(). ^The default encoding for databases +** created using sqlite3_open16() will be UTF-16 in the native byte order. +** +** Whether or not an error occurs when it is opened, resources +** associated with the [database connection] handle should be released by +** passing it to [sqlite3_close()] when it is no longer required. +** +** The sqlite3_open_v2() interface works like sqlite3_open() +** except that it accepts two additional parameters for additional control +** over the new database connection. ^(The flags parameter to +** sqlite3_open_v2() must include, at a minimum, one of the following +** three flag combinations:)^ +** +**
+** ^(
[SQLITE_OPEN_READONLY]
+**
The database is opened in read-only mode. If the database does +** not already exist, an error is returned.
)^ +** +** ^(
[SQLITE_OPEN_READWRITE]
+**
The database is opened for reading and writing if possible, or +** reading only if the file is write protected by the operating +** system. In either case the database must already exist, otherwise +** an error is returned. For historical reasons, if opening in +** read-write mode fails due to OS-level permissions, an attempt is +** made to open it in read-only mode. [sqlite3_db_readonly()] can be +** used to determine whether the database is actually +** read-write.
)^ +** +** ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
+**
The database is opened for reading and writing, and is created if +** it does not already exist. This is the behavior that is always used for +** sqlite3_open() and sqlite3_open16().
)^ +**
+** +** In addition to the required flags, the following optional flags are +** also supported: +** +**
+** ^(
[SQLITE_OPEN_URI]
+**
The filename can be interpreted as a URI if this flag is set.
)^ +** +** ^(
[SQLITE_OPEN_MEMORY]
+**
The database will be opened as an in-memory database. The database +** is named by the "filename" argument for the purposes of cache-sharing, +** if shared cache mode is enabled, but the "filename" is otherwise ignored. +**
)^ +** +** ^(
[SQLITE_OPEN_NOMUTEX]
+**
The new database connection will use the "multi-thread" +** [threading mode].)^ This means that separate threads are allowed +** to use SQLite at the same time, as long as each thread is using +** a different [database connection]. +** +** ^(
[SQLITE_OPEN_FULLMUTEX]
+**
The new database connection will use the "serialized" +** [threading mode].)^ This means the multiple threads can safely +** attempt to use the same database connection at the same time. +** (Mutexes will block any actual concurrency, but in this mode +** there is no harm in trying.) +** +** ^(
[SQLITE_OPEN_SHAREDCACHE]
+**
The database is opened [shared cache] enabled, overriding +** the default shared cache setting provided by +** [sqlite3_enable_shared_cache()].)^ +** The [use of shared cache mode is discouraged] and hence shared cache +** capabilities may be omitted from many builds of SQLite. In such cases, +** this option is a no-op. +** +** ^(
[SQLITE_OPEN_PRIVATECACHE]
+**
The database is opened [shared cache] disabled, overriding +** the default shared cache setting provided by +** [sqlite3_enable_shared_cache()].)^ +** +** [[OPEN_EXRESCODE]] ^(
[SQLITE_OPEN_EXRESCODE]
+**
The database connection comes up in "extended result code mode". +** In other words, the database behaves as if +** [sqlite3_extended_result_codes(db,1)] were called on the database +** connection as soon as the connection is created. In addition to setting +** the extended result code mode, this flag also causes [sqlite3_open_v2()] +** to return an extended result code.
+** +** [[OPEN_NOFOLLOW]] ^(
[SQLITE_OPEN_NOFOLLOW]
+**
The database filename is not allowed to contain a symbolic link
+**
)^ +** +** If the 3rd parameter to sqlite3_open_v2() is not one of the +** required combinations shown above optionally combined with other +** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] +** then the behavior is undefined. Historic versions of SQLite +** have silently ignored surplus bits in the flags parameter to +** sqlite3_open_v2(), however that behavior might not be carried through +** into future versions of SQLite and so applications should not rely +** upon it. Note in particular that the SQLITE_OPEN_EXCLUSIVE flag is a no-op +** for sqlite3_open_v2(). The SQLITE_OPEN_EXCLUSIVE does *not* cause +** the open to fail if the database already exists. The SQLITE_OPEN_EXCLUSIVE +** flag is intended for use by the [sqlite3_vfs|VFS interface] only, and not +** by sqlite3_open_v2(). +** +** ^The fourth parameter to sqlite3_open_v2() is the name of the +** [sqlite3_vfs] object that defines the operating system interface that +** the new database connection should use. ^If the fourth parameter is +** a NULL pointer then the default [sqlite3_vfs] object is used. +** +** ^If the filename is ":memory:", then a private, temporary in-memory database +** is created for the connection. ^This in-memory database will vanish when +** the database connection is closed. Future versions of SQLite might +** make use of additional special filenames that begin with the ":" character. +** It is recommended that when a database filename actually does begin with +** a ":" character you should prefix the filename with a pathname such as +** "./" to avoid ambiguity. +** +** ^If the filename is an empty string, then a private, temporary +** on-disk database will be created. ^This private database will be +** automatically deleted as soon as the database connection is closed. +** +** [[URI filenames in sqlite3_open()]]

URI Filenames

+** +** ^If [URI filename] interpretation is enabled, and the filename argument +** begins with "file:", then the filename is interpreted as a URI. ^URI +** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is +** set in the third argument to sqlite3_open_v2(), or if it has +** been enabled globally using the [SQLITE_CONFIG_URI] option with the +** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. +** URI filename interpretation is turned off +** by default, but future releases of SQLite might enable URI filename +** interpretation by default. See "[URI filenames]" for additional +** information. +** +** URI filenames are parsed according to RFC 3986. ^If the URI contains an +** authority, then it must be either an empty string or the string +** "localhost". ^If the authority is not an empty string or "localhost", an +** error is returned to the caller. ^The fragment component of a URI, if +** present, is ignored. +** +** ^SQLite uses the path component of the URI as the name of the disk file +** which contains the database. ^If the path begins with a '/' character, +** then it is interpreted as an absolute path. ^If the path does not begin +** with a '/' (meaning that the authority section is omitted from the URI) +** then the path is interpreted as a relative path. +** ^(On windows, the first component of an absolute path +** is a drive specification (e.g. "C:").)^ +** +** [[core URI query parameters]] +** The query component of a URI may contain parameters that are interpreted +** either by SQLite itself, or by a [VFS | custom VFS implementation]. +** SQLite and its built-in [VFSes] interpret the +** following query parameters: +** +**
    +**
  • vfs: ^The "vfs" parameter may be used to specify the name of +** a VFS object that provides the operating system interface that should +** be used to access the database file on disk. ^If this option is set to +** an empty string the default VFS object is used. ^Specifying an unknown +** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is +** present, then the VFS specified by the option takes precedence over +** the value passed as the fourth parameter to sqlite3_open_v2(). +** +**
  • mode: ^(The mode parameter may be set to either "ro", "rw", +** "rwc", or "memory". Attempting to set it to any other value is +** an error)^. +** ^If "ro" is specified, then the database is opened for read-only +** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the +** third argument to sqlite3_open_v2(). ^If the mode option is set to +** "rw", then the database is opened for read-write (but not create) +** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had +** been set. ^Value "rwc" is equivalent to setting both +** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is +** set to "memory" then a pure [in-memory database] that never reads +** or writes from disk is used. ^It is an error to specify a value for +** the mode parameter that is less restrictive than that specified by +** the flags passed in the third parameter to sqlite3_open_v2(). +** +**
  • cache: ^The cache parameter may be set to either "shared" or +** "private". ^Setting it to "shared" is equivalent to setting the +** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to +** sqlite3_open_v2(). ^Setting the cache parameter to "private" is +** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. +** ^If sqlite3_open_v2() is used and the "cache" parameter is present in +** a URI filename, its value overrides any behavior requested by setting +** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. +** +**
  • psow: ^The psow parameter indicates whether or not the +** [powersafe overwrite] property does or does not apply to the +** storage media on which the database file resides. +** +**
  • nolock: ^The nolock parameter is a boolean query parameter +** which if set disables file locking in rollback journal modes. This +** is useful for accessing a database on a filesystem that does not +** support locking. Caution: Database corruption might result if two +** or more processes write to the same database and any one of those +** processes uses nolock=1. +** +**
  • immutable: ^The immutable parameter is a boolean query +** parameter that indicates that the database file is stored on +** read-only media. ^When immutable is set, SQLite assumes that the +** database file cannot be changed, even by a process with higher +** privilege, and so the database is opened read-only and all locking +** and change detection is disabled. Caution: Setting the immutable +** property on a database file that does in fact change can result +** in incorrect query results and/or [SQLITE_CORRUPT] errors. +** See also: [SQLITE_IOCAP_IMMUTABLE]. +** +**
+** +** ^Specifying an unknown parameter in the query component of a URI is not an +** error. Future versions of SQLite might understand additional query +** parameters. See "[query parameters with special meaning to SQLite]" for +** additional information. +** +** [[URI filename examples]]

URI filename examples

+** +** +**
URI filenames Results +**
file:data.db +** Open the file "data.db" in the current directory. +**
file:/home/fred/data.db
+** file:///home/fred/data.db
+** file://localhost/home/fred/data.db
+** Open the database file "/home/fred/data.db". +**
file://darkstar/home/fred/data.db +** An error. "darkstar" is not a recognized authority. +**
+** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db +** Windows only: Open the file "data.db" on fred's desktop on drive +** C:. Note that the %20 escaping in this example is not strictly +** necessary - space characters can be used literally +** in URI filenames. +**
file:data.db?mode=ro&cache=private +** Open file "data.db" in the current directory for read-only access. +** Regardless of whether or not shared-cache mode is enabled by +** default, use a private cache. +**
file:/home/fred/data.db?vfs=unix-dotfile +** Open file "/home/fred/data.db". Use the special VFS "unix-dotfile" +** that uses dot-files in place of posix advisory locking. +**
file:data.db?mode=readonly +** An error. "readonly" is not a valid option for the "mode" parameter. +** Use "ro" instead: "file:data.db?mode=ro". +**
+** +** ^URI hexadecimal escape sequences (%HH) are supported within the path and +** query components of a URI. A hexadecimal escape sequence consists of a +** percent sign - "%" - followed by exactly two hexadecimal digits +** specifying an octet value. ^Before the path or query components of a +** URI filename are interpreted, they are encoded using UTF-8 and all +** hexadecimal escape sequences replaced by a single byte containing the +** corresponding octet. If this process generates an invalid UTF-8 encoding, +** the results are undefined. +** +** Note to Windows users: The encoding used for the filename argument +** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever +** codepage is currently defined. Filenames containing international +** characters must be converted to UTF-8 prior to passing them into +** sqlite3_open() or sqlite3_open_v2(). +** +** Note to Windows Runtime users: The temporary directory must be set +** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various +** features that require the use of temporary files may fail. +** +** See also: [sqlite3_temp_directory] +*/ +SQLITE_API int sqlite3_open( + const char *filename, /* Database filename (UTF-8) */ + sqlite3 **ppDb /* OUT: SQLite db handle */ +); +SQLITE_API int sqlite3_open16( + const void *filename, /* Database filename (UTF-16) */ + sqlite3 **ppDb /* OUT: SQLite db handle */ +); +SQLITE_API int sqlite3_open_v2( + const char *filename, /* Database filename (UTF-8) */ + sqlite3 **ppDb, /* OUT: SQLite db handle */ + int flags, /* Flags */ + const char *zVfs /* Name of VFS module to use */ +); + +/* +** CAPI3REF: Obtain Values For URI Parameters +** +** These are utility routines, useful to [VFS|custom VFS implementations], +** that check if a database file was a URI that contained a specific query +** parameter, and if so obtains the value of that query parameter. +** +** The first parameter to these interfaces (hereafter referred to +** as F) must be one of: +**
    +**
  • A database filename pointer created by the SQLite core and +** passed into the xOpen() method of a VFS implementation, or +**
  • A filename obtained from [sqlite3_db_filename()], or +**
  • A new filename constructed using [sqlite3_create_filename()]. +**
+** If the F parameter is not one of the above, then the behavior is +** undefined and probably undesirable. Older versions of SQLite were +** more tolerant of invalid F parameters than newer versions. +** +** If F is a suitable filename (as described in the previous paragraph) +** and if P is the name of the query parameter, then +** sqlite3_uri_parameter(F,P) returns the value of the P +** parameter if it exists or a NULL pointer if P does not appear as a +** query parameter on F. If P is a query parameter of F and it +** has no explicit value, then sqlite3_uri_parameter(F,P) returns +** a pointer to an empty string. +** +** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean +** parameter and returns true (1) or false (0) according to the value +** of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the +** value of query parameter P is one of "yes", "true", or "on" in any +** case or if the value begins with a non-zero number. The +** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of +** query parameter P is one of "no", "false", or "off" in any case or +** if the value begins with a numeric zero. If P is not a query +** parameter on F or if the value of P does not match any of the +** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). +** +** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a +** 64-bit signed integer and returns that integer, or D if P does not +** exist. If the value of P is something other than an integer, then +** zero is returned. +** +** The sqlite3_uri_key(F,N) returns a pointer to the name (not +** the value) of the N-th query parameter for filename F, or a NULL +** pointer if N is less than zero or greater than the number of query +** parameters minus 1. The N value is zero-based so N should be 0 to obtain +** the name of the first query parameter, 1 for the second parameter, and +** so forth. +** +** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and +** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and +** is not a database file pathname pointer that the SQLite core passed +** into the xOpen VFS method, then the behavior of this routine is undefined +** and probably undesirable. +** +** Beginning with SQLite [version 3.31.0] ([dateof:3.31.0]) the input F +** parameter can also be the name of a rollback journal file or WAL file +** in addition to the main database file. Prior to version 3.31.0, these +** routines would only work if F was the name of the main database file. +** When the F parameter is the name of the rollback journal or WAL file, +** it has access to all the same query parameters as were found on the +** main database file. +** +** See the [URI filename] documentation for additional information. +*/ +SQLITE_API const char *sqlite3_uri_parameter(sqlite3_filename z, const char *zParam); +SQLITE_API int sqlite3_uri_boolean(sqlite3_filename z, const char *zParam, int bDefault); +SQLITE_API sqlite3_int64 sqlite3_uri_int64(sqlite3_filename, const char*, sqlite3_int64); +SQLITE_API const char *sqlite3_uri_key(sqlite3_filename z, int N); + +/* +** CAPI3REF: Translate filenames +** +** These routines are available to [VFS|custom VFS implementations] for +** translating filenames between the main database file, the journal file, +** and the WAL file. +** +** If F is the name of an sqlite database file, journal file, or WAL file +** passed by the SQLite core into the VFS, then sqlite3_filename_database(F) +** returns the name of the corresponding database file. +** +** If F is the name of an sqlite database file, journal file, or WAL file +** passed by the SQLite core into the VFS, or if F is a database filename +** obtained from [sqlite3_db_filename()], then sqlite3_filename_journal(F) +** returns the name of the corresponding rollback journal file. +** +** If F is the name of an sqlite database file, journal file, or WAL file +** that was passed by the SQLite core into the VFS, or if F is a database +** filename obtained from [sqlite3_db_filename()], then +** sqlite3_filename_wal(F) returns the name of the corresponding +** WAL file. +** +** In all of the above, if F is not the name of a database, journal or WAL +** filename passed into the VFS from the SQLite core and F is not the +** return value from [sqlite3_db_filename()], then the result is +** undefined and is likely a memory access violation. +*/ +SQLITE_API const char *sqlite3_filename_database(sqlite3_filename); +SQLITE_API const char *sqlite3_filename_journal(sqlite3_filename); +SQLITE_API const char *sqlite3_filename_wal(sqlite3_filename); + +/* +** CAPI3REF: Database File Corresponding To A Journal +** +** ^If X is the name of a rollback or WAL-mode journal file that is +** passed into the xOpen method of [sqlite3_vfs], then +** sqlite3_database_file_object(X) returns a pointer to the [sqlite3_file] +** object that represents the main database file. +** +** This routine is intended for use in custom [VFS] implementations +** only. It is not a general-purpose interface. +** The argument sqlite3_file_object(X) must be a filename pointer that +** has been passed into [sqlite3_vfs].xOpen method where the +** flags parameter to xOpen contains one of the bits +** [SQLITE_OPEN_MAIN_JOURNAL] or [SQLITE_OPEN_WAL]. Any other use +** of this routine results in undefined and probably undesirable +** behavior. +*/ +SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*); + +/* +** CAPI3REF: Create and Destroy VFS Filenames +** +** These interfaces are provided for use by [VFS shim] implementations and +** are not useful outside of that context. +** +** The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of +** database filename D with corresponding journal file J and WAL file W and +** an array P of N URI Key/Value pairs. The result from +** sqlite3_create_filename(D,J,W,N,P) is a pointer to a database filename that +** is safe to pass to routines like: +**
    +**
  • [sqlite3_uri_parameter()], +**
  • [sqlite3_uri_boolean()], +**
  • [sqlite3_uri_int64()], +**
  • [sqlite3_uri_key()], +**
  • [sqlite3_filename_database()], +**
  • [sqlite3_filename_journal()], or +**
  • [sqlite3_filename_wal()]. +**
+** If a memory allocation error occurs, sqlite3_create_filename() might +** return a NULL pointer. The memory obtained from sqlite3_create_filename(X) +** must be released by a corresponding call to sqlite3_free_filename(Y). +** +** The P parameter in sqlite3_create_filename(D,J,W,N,P) should be an array +** of 2*N pointers to strings. Each pair of pointers in this array corresponds +** to a key and value for a query parameter. The P parameter may be a NULL +** pointer if N is zero. None of the 2*N pointers in the P array may be +** NULL pointers and key pointers should not be empty strings. +** None of the D, J, or W parameters to sqlite3_create_filename(D,J,W,N,P) may +** be NULL pointers, though they can be empty strings. +** +** The sqlite3_free_filename(Y) routine releases a memory allocation +** previously obtained from sqlite3_create_filename(). Invoking +** sqlite3_free_filename(Y) where Y is a NULL pointer is a harmless no-op. +** +** If the Y parameter to sqlite3_free_filename(Y) is anything other +** than a NULL pointer or a pointer previously acquired from +** sqlite3_create_filename(), then bad things such as heap +** corruption or segfaults may occur. The value Y should not be +** used again after sqlite3_free_filename(Y) has been called. This means +** that if the [sqlite3_vfs.xOpen()] method of a VFS has been called using Y, +** then the corresponding [sqlite3_module.xClose() method should also be +** invoked prior to calling sqlite3_free_filename(Y). +*/ +SQLITE_API sqlite3_filename sqlite3_create_filename( + const char *zDatabase, + const char *zJournal, + const char *zWal, + int nParam, + const char **azParam +); +SQLITE_API void sqlite3_free_filename(sqlite3_filename); + +/* +** CAPI3REF: Error Codes And Messages +** METHOD: sqlite3 +** +** ^If the most recent sqlite3_* API call associated with +** [database connection] D failed, then the sqlite3_errcode(D) interface +** returns the numeric [result code] or [extended result code] for that +** API call. +** ^The sqlite3_extended_errcode() +** interface is the same except that it always returns the +** [extended result code] even when extended result codes are +** disabled. +** +** The values returned by sqlite3_errcode() and/or +** sqlite3_extended_errcode() might change with each API call. +** Except, there are some interfaces that are guaranteed to never +** change the value of the error code. The error-code preserving +** interfaces include the following: +** +**
    +**
  • sqlite3_errcode() +**
  • sqlite3_extended_errcode() +**
  • sqlite3_errmsg() +**
  • sqlite3_errmsg16() +**
  • sqlite3_error_offset() +**
+** +** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language +** text that describes the error, as either UTF-8 or UTF-16 respectively, +** or NULL if no error message is available. +** (See how SQLite handles [invalid UTF] for exceptions to this rule.) +** ^(Memory to hold the error message string is managed internally. +** The application does not need to worry about freeing the result. +** However, the error string might be overwritten or deallocated by +** subsequent calls to other SQLite interface functions.)^ +** +** ^The sqlite3_errstr(E) interface returns the English-language text +** that describes the [result code] E, as UTF-8, or NULL if E is not an +** result code for which a text error message is available. +** ^(Memory to hold the error message string is managed internally +** and must not be freed by the application)^. +** +** ^If the most recent error references a specific token in the input +** SQL, the sqlite3_error_offset() interface returns the byte offset +** of the start of that token. ^The byte offset returned by +** sqlite3_error_offset() assumes that the input SQL is UTF8. +** ^If the most recent error does not reference a specific token in the input +** SQL, then the sqlite3_error_offset() function returns -1. +** +** When the serialized [threading mode] is in use, it might be the +** case that a second error occurs on a separate thread in between +** the time of the first error and the call to these interfaces. +** When that happens, the second error will be reported since these +** interfaces always report the most recent result. To avoid +** this, each thread can obtain exclusive use of the [database connection] D +** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning +** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after +** all calls to the interfaces listed here are completed. +** +** If an interface fails with SQLITE_MISUSE, that means the interface +** was invoked incorrectly by the application. In that case, the +** error code and message may or may not be set. +*/ +SQLITE_API int sqlite3_errcode(sqlite3 *db); +SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); +SQLITE_API const char *sqlite3_errmsg(sqlite3*); +SQLITE_API const void *sqlite3_errmsg16(sqlite3*); +SQLITE_API const char *sqlite3_errstr(int); +SQLITE_API int sqlite3_error_offset(sqlite3 *db); + +/* +** CAPI3REF: Prepared Statement Object +** KEYWORDS: {prepared statement} {prepared statements} +** +** An instance of this object represents a single SQL statement that +** has been compiled into binary form and is ready to be evaluated. +** +** Think of each SQL statement as a separate computer program. The +** original SQL text is source code. A prepared statement object +** is the compiled object code. All SQL must be converted into a +** prepared statement before it can be run. +** +** The life-cycle of a prepared statement object usually goes like this: +** +**
    +**
  1. Create the prepared statement object using [sqlite3_prepare_v2()]. +**
  2. Bind values to [parameters] using the sqlite3_bind_*() +** interfaces. +**
  3. Run the SQL by calling [sqlite3_step()] one or more times. +**
  4. Reset the prepared statement using [sqlite3_reset()] then go back +** to step 2. Do this zero or more times. +**
  5. Destroy the object using [sqlite3_finalize()]. +**
+*/ +typedef struct sqlite3_stmt sqlite3_stmt; + +/* +** CAPI3REF: Run-time Limits +** METHOD: sqlite3 +** +** ^(This interface allows the size of various constructs to be limited +** on a connection by connection basis. The first parameter is the +** [database connection] whose limit is to be set or queried. The +** second parameter is one of the [limit categories] that define a +** class of constructs to be size limited. The third parameter is the +** new limit for that construct.)^ +** +** ^If the new limit is a negative number, the limit is unchanged. +** ^(For each limit category SQLITE_LIMIT_NAME there is a +** [limits | hard upper bound] +** set at compile-time by a C preprocessor macro called +** [limits | SQLITE_MAX_NAME]. +** (The "_LIMIT_" in the name is changed to "_MAX_".))^ +** ^Attempts to increase a limit above its hard upper bound are +** silently truncated to the hard upper bound. +** +** ^Regardless of whether or not the limit was changed, the +** [sqlite3_limit()] interface returns the prior value of the limit. +** ^Hence, to find the current value of a limit without changing it, +** simply invoke this interface with the third parameter set to -1. +** +** Run-time limits are intended for use in applications that manage +** both their own internal database and also databases that are controlled +** by untrusted external sources. An example application might be a +** web browser that has its own databases for storing history and +** separate databases controlled by JavaScript applications downloaded +** off the Internet. The internal databases can be given the +** large, default limits. Databases managed by external sources can +** be given much smaller limits designed to prevent a denial of service +** attack. Developers might also want to use the [sqlite3_set_authorizer()] +** interface to further control untrusted SQL. The size of the database +** created by an untrusted script can be contained using the +** [max_page_count] [PRAGMA]. +** +** New run-time limit categories may be added in future releases. +*/ +SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); + +/* +** CAPI3REF: Run-Time Limit Categories +** KEYWORDS: {limit category} {*limit categories} +** +** These constants define various performance limits +** that can be lowered at run-time using [sqlite3_limit()]. +** The synopsis of the meanings of the various limits is shown below. +** Additional information is available at [limits | Limits in SQLite]. +** +**
+** [[SQLITE_LIMIT_LENGTH]] ^(
SQLITE_LIMIT_LENGTH
+**
The maximum size of any string or BLOB or table row, in bytes.
)^ +** +** [[SQLITE_LIMIT_SQL_LENGTH]] ^(
SQLITE_LIMIT_SQL_LENGTH
+**
The maximum length of an SQL statement, in bytes.
)^ +** +** [[SQLITE_LIMIT_COLUMN]] ^(
SQLITE_LIMIT_COLUMN
+**
The maximum number of columns in a table definition or in the +** result set of a [SELECT] or the maximum number of columns in an index +** or in an ORDER BY or GROUP BY clause.
)^ +** +** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(
SQLITE_LIMIT_EXPR_DEPTH
+**
The maximum depth of the parse tree on any expression.
)^ +** +** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(
SQLITE_LIMIT_COMPOUND_SELECT
+**
The maximum number of terms in a compound SELECT statement.
)^ +** +** [[SQLITE_LIMIT_VDBE_OP]] ^(
SQLITE_LIMIT_VDBE_OP
+**
The maximum number of instructions in a virtual machine program +** used to implement an SQL statement. If [sqlite3_prepare_v2()] or +** the equivalent tries to allocate space for more than this many opcodes +** in a single prepared statement, an SQLITE_NOMEM error is returned.
)^ +** +** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(
SQLITE_LIMIT_FUNCTION_ARG
+**
The maximum number of arguments on a function.
)^ +** +** [[SQLITE_LIMIT_ATTACHED]] ^(
SQLITE_LIMIT_ATTACHED
+**
The maximum number of [ATTACH | attached databases].)^
+** +** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]] +** ^(
SQLITE_LIMIT_LIKE_PATTERN_LENGTH
+**
The maximum length of the pattern argument to the [LIKE] or +** [GLOB] operators.
)^ +** +** [[SQLITE_LIMIT_VARIABLE_NUMBER]] +** ^(
SQLITE_LIMIT_VARIABLE_NUMBER
+**
The maximum index number of any [parameter] in an SQL statement.)^ +** +** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(
SQLITE_LIMIT_TRIGGER_DEPTH
+**
The maximum depth of recursion for triggers.
)^ +** +** [[SQLITE_LIMIT_WORKER_THREADS]] ^(
SQLITE_LIMIT_WORKER_THREADS
+**
The maximum number of auxiliary worker threads that a single +** [prepared statement] may start.
)^ +**
+*/ +#define SQLITE_LIMIT_LENGTH 0 +#define SQLITE_LIMIT_SQL_LENGTH 1 +#define SQLITE_LIMIT_COLUMN 2 +#define SQLITE_LIMIT_EXPR_DEPTH 3 +#define SQLITE_LIMIT_COMPOUND_SELECT 4 +#define SQLITE_LIMIT_VDBE_OP 5 +#define SQLITE_LIMIT_FUNCTION_ARG 6 +#define SQLITE_LIMIT_ATTACHED 7 +#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 +#define SQLITE_LIMIT_VARIABLE_NUMBER 9 +#define SQLITE_LIMIT_TRIGGER_DEPTH 10 +#define SQLITE_LIMIT_WORKER_THREADS 11 + +/* +** CAPI3REF: Prepare Flags +** +** These constants define various flags that can be passed into +** "prepFlags" parameter of the [sqlite3_prepare_v3()] and +** [sqlite3_prepare16_v3()] interfaces. +** +** New flags may be added in future releases of SQLite. +** +**
+** [[SQLITE_PREPARE_PERSISTENT]] ^(
SQLITE_PREPARE_PERSISTENT
+**
The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner +** that the prepared statement will be retained for a long time and +** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()] +** and [sqlite3_prepare16_v3()] assume that the prepared statement will +** be used just once or at most a few times and then destroyed using +** [sqlite3_finalize()] relatively soon. The current implementation acts +** on this hint by avoiding the use of [lookaside memory] so as not to +** deplete the limited store of lookaside memory. Future versions of +** SQLite may act on this hint differently. +** +** [[SQLITE_PREPARE_NORMALIZE]]
SQLITE_PREPARE_NORMALIZE
+**
The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used +** to be required for any prepared statement that wanted to use the +** [sqlite3_normalized_sql()] interface. However, the +** [sqlite3_normalized_sql()] interface is now available to all +** prepared statements, regardless of whether or not they use this +** flag. +** +** [[SQLITE_PREPARE_NO_VTAB]]
SQLITE_PREPARE_NO_VTAB
+**
The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler +** to return an error (error code SQLITE_ERROR) if the statement uses +** any virtual tables. +** +** [[SQLITE_PREPARE_DONT_LOG]]
SQLITE_PREPARE_DONT_LOG
+**
The SQLITE_PREPARE_DONT_LOG flag prevents SQL compiler +** errors from being sent to the error log defined by +** [SQLITE_CONFIG_LOG]. This can be used, for example, to do test +** compiles to see if some SQL syntax is well-formed, without generating +** messages on the global error log when it is not. If the test compile +** fails, the sqlite3_prepare_v3() call returns the same error indications +** with or without this flag; it just omits the call to [sqlite3_log()] that +** logs the error. +**
+*/ +#define SQLITE_PREPARE_PERSISTENT 0x01 +#define SQLITE_PREPARE_NORMALIZE 0x02 +#define SQLITE_PREPARE_NO_VTAB 0x04 +#define SQLITE_PREPARE_DONT_LOG 0x10 + +/* +** CAPI3REF: Compiling An SQL Statement +** KEYWORDS: {SQL statement compiler} +** METHOD: sqlite3 +** CONSTRUCTOR: sqlite3_stmt +** +** To execute an SQL statement, it must first be compiled into a byte-code +** program using one of these routines. Or, in other words, these routines +** are constructors for the [prepared statement] object. +** +** The preferred routine to use is [sqlite3_prepare_v2()]. The +** [sqlite3_prepare()] interface is legacy and should be avoided. +** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used +** for special purposes. +** +** The use of the UTF-8 interfaces is preferred, as SQLite currently +** does all parsing using UTF-8. The UTF-16 interfaces are provided +** as a convenience. The UTF-16 interfaces work by converting the +** input text into UTF-8, then invoking the corresponding UTF-8 interface. +** +** The first argument, "db", is a [database connection] obtained from a +** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or +** [sqlite3_open16()]. The database connection must not have been closed. +** +** The second argument, "zSql", is the statement to be compiled, encoded +** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(), +** and sqlite3_prepare_v3() +** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(), +** and sqlite3_prepare16_v3() use UTF-16. +** +** ^If the nByte argument is negative, then zSql is read up to the +** first zero terminator. ^If nByte is positive, then it is the maximum +** number of bytes read from zSql. When nByte is positive, zSql is read +** up to the first zero terminator or until the nByte bytes have been read, +** whichever comes first. ^If nByte is zero, then no prepared +** statement is generated. +** If the caller knows that the supplied string is nul-terminated, then +** there is a small performance advantage to passing an nByte parameter that +** is the number of bytes in the input string including +** the nul-terminator. +** Note that nByte measure the length of the input in bytes, not +** characters, even for the UTF-16 interfaces. +** +** ^If pzTail is not NULL then *pzTail is made to point to the first byte +** past the end of the first SQL statement in zSql. These routines only +** compile the first statement in zSql, so *pzTail is left pointing to +** what remains uncompiled. +** +** ^*ppStmt is left pointing to a compiled [prepared statement] that can be +** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set +** to NULL. ^If the input text contains no SQL (if the input is an empty +** string or a comment) then *ppStmt is set to NULL. +** The calling procedure is responsible for deleting the compiled +** SQL statement using [sqlite3_finalize()] after it has finished with it. +** ppStmt may not be NULL. +** +** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; +** otherwise an [error code] is returned. +** +** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(), +** and sqlite3_prepare16_v3() interfaces are recommended for all new programs. +** The older interfaces (sqlite3_prepare() and sqlite3_prepare16()) +** are retained for backwards compatibility, but their use is discouraged. +** ^In the "vX" interfaces, the prepared statement +** that is returned (the [sqlite3_stmt] object) contains a copy of the +** original SQL text. This causes the [sqlite3_step()] interface to +** behave differently in three ways: +** +**
    +**
  1. +** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it +** always used to do, [sqlite3_step()] will automatically recompile the SQL +** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY] +** retries will occur before sqlite3_step() gives up and returns an error. +**
  2. +** +**
  3. +** ^When an error occurs, [sqlite3_step()] will return one of the detailed +** [error codes] or [extended error codes]. ^The legacy behavior was that +** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code +** and the application would have to make a second call to [sqlite3_reset()] +** in order to find the underlying cause of the problem. With the "v2" prepare +** interfaces, the underlying reason for the error is returned immediately. +**
  4. +** +**
  5. +** ^If the specific value bound to a [parameter | host parameter] in the +** WHERE clause might influence the choice of query plan for a statement, +** then the statement will be automatically recompiled, as if there had been +** a schema change, on the first [sqlite3_step()] call following any change +** to the [sqlite3_bind_text | bindings] of that [parameter]. +** ^The specific value of a WHERE-clause [parameter] might influence the +** choice of query plan if the parameter is the left-hand side of a [LIKE] +** or [GLOB] operator or if the parameter is compared to an indexed column +** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled. +**
  6. +**
+** +**

^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having +** the extra prepFlags parameter, which is a bit array consisting of zero or +** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The +** sqlite3_prepare_v2() interface works exactly the same as +** sqlite3_prepare_v3() with a zero prepFlags parameter. +*/ +SQLITE_API int sqlite3_prepare( + sqlite3 *db, /* Database handle */ + const char *zSql, /* SQL statement, UTF-8 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const char **pzTail /* OUT: Pointer to unused portion of zSql */ +); +SQLITE_API int sqlite3_prepare_v2( + sqlite3 *db, /* Database handle */ + const char *zSql, /* SQL statement, UTF-8 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const char **pzTail /* OUT: Pointer to unused portion of zSql */ +); +SQLITE_API int sqlite3_prepare_v3( + sqlite3 *db, /* Database handle */ + const char *zSql, /* SQL statement, UTF-8 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const char **pzTail /* OUT: Pointer to unused portion of zSql */ +); +SQLITE_API int sqlite3_prepare16( + sqlite3 *db, /* Database handle */ + const void *zSql, /* SQL statement, UTF-16 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const void **pzTail /* OUT: Pointer to unused portion of zSql */ +); +SQLITE_API int sqlite3_prepare16_v2( + sqlite3 *db, /* Database handle */ + const void *zSql, /* SQL statement, UTF-16 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const void **pzTail /* OUT: Pointer to unused portion of zSql */ +); +SQLITE_API int sqlite3_prepare16_v3( + sqlite3 *db, /* Database handle */ + const void *zSql, /* SQL statement, UTF-16 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const void **pzTail /* OUT: Pointer to unused portion of zSql */ +); + +/* +** CAPI3REF: Retrieving Statement SQL +** METHOD: sqlite3_stmt +** +** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 +** SQL text used to create [prepared statement] P if P was +** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], +** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()]. +** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8 +** string containing the SQL text of prepared statement P with +** [bound parameters] expanded. +** ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8 +** string containing the normalized SQL text of prepared statement P. The +** semantics used to normalize a SQL statement are unspecified and subject +** to change. At a minimum, literal values will be replaced with suitable +** placeholders. +** +** ^(For example, if a prepared statement is created using the SQL +** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 +** and parameter :xyz is unbound, then sqlite3_sql() will return +** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() +** will return "SELECT 2345,NULL".)^ +** +** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory +** is available to hold the result, or if the result would exceed the +** the maximum string length determined by the [SQLITE_LIMIT_LENGTH]. +** +** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of +** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time +** option causes sqlite3_expanded_sql() to always return NULL. +** +** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P) +** are managed by SQLite and are automatically freed when the prepared +** statement is finalized. +** ^The string returned by sqlite3_expanded_sql(P), on the other hand, +** is obtained from [sqlite3_malloc()] and must be freed by the application +** by passing it to [sqlite3_free()]. +** +** ^The sqlite3_normalized_sql() interface is only available if +** the [SQLITE_ENABLE_NORMALIZE] compile-time option is defined. +*/ +SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); +SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt); +#ifdef SQLITE_ENABLE_NORMALIZE +SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt); +#endif + +/* +** CAPI3REF: Determine If An SQL Statement Writes The Database +** METHOD: sqlite3_stmt +** +** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if +** and only if the [prepared statement] X makes no direct changes to +** the content of the database file. +** +** Note that [application-defined SQL functions] or +** [virtual tables] might change the database indirectly as a side effect. +** ^(For example, if an application defines a function "eval()" that +** calls [sqlite3_exec()], then the following SQL statement would +** change the database file through side-effects: +** +**

+**    SELECT eval('DELETE FROM t1') FROM t2;
+** 
+** +** But because the [SELECT] statement does not change the database file +** directly, sqlite3_stmt_readonly() would still return true.)^ +** +** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], +** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, +** since the statements themselves do not actually modify the database but +** rather they control the timing of when other statements modify the +** database. ^The [ATTACH] and [DETACH] statements also cause +** sqlite3_stmt_readonly() to return true since, while those statements +** change the configuration of a database connection, they do not make +** changes to the content of the database files on disk. +** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since +** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and +** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so +** sqlite3_stmt_readonly() returns false for those commands. +** +** ^This routine returns false if there is any possibility that the +** statement might change the database file. ^A false return does +** not guarantee that the statement will change the database file. +** ^For example, an UPDATE statement might have a WHERE clause that +** makes it a no-op, but the sqlite3_stmt_readonly() result would still +** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a +** read-only no-op if the table already exists, but +** sqlite3_stmt_readonly() still returns false for such a statement. +** +** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN] +** statement, then sqlite3_stmt_readonly(X) returns the same value as +** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted. +*/ +SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement +** METHOD: sqlite3_stmt +** +** ^The sqlite3_stmt_isexplain(S) interface returns 1 if the +** prepared statement S is an EXPLAIN statement, or 2 if the +** statement S is an EXPLAIN QUERY PLAN. +** ^The sqlite3_stmt_isexplain(S) interface returns 0 if S is +** an ordinary statement or a NULL pointer. +*/ +SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Change The EXPLAIN Setting For A Prepared Statement +** METHOD: sqlite3_stmt +** +** The sqlite3_stmt_explain(S,E) interface changes the EXPLAIN +** setting for [prepared statement] S. If E is zero, then S becomes +** a normal prepared statement. If E is 1, then S behaves as if +** its SQL text began with "[EXPLAIN]". If E is 2, then S behaves as if +** its SQL text began with "[EXPLAIN QUERY PLAN]". +** +** Calling sqlite3_stmt_explain(S,E) might cause S to be reprepared. +** SQLite tries to avoid a reprepare, but a reprepare might be necessary +** on the first transition into EXPLAIN or EXPLAIN QUERY PLAN mode. +** +** Because of the potential need to reprepare, a call to +** sqlite3_stmt_explain(S,E) will fail with SQLITE_ERROR if S cannot be +** reprepared because it was created using [sqlite3_prepare()] instead of +** the newer [sqlite3_prepare_v2()] or [sqlite3_prepare_v3()] interfaces and +** hence has no saved SQL text with which to reprepare. +** +** Changing the explain setting for a prepared statement does not change +** the original SQL text for the statement. Hence, if the SQL text originally +** began with EXPLAIN or EXPLAIN QUERY PLAN, but sqlite3_stmt_explain(S,0) +** is called to convert the statement into an ordinary statement, the EXPLAIN +** or EXPLAIN QUERY PLAN keywords will still appear in the sqlite3_sql(S) +** output, even though the statement now acts like a normal SQL statement. +** +** This routine returns SQLITE_OK if the explain mode is successfully +** changed, or an error code if the explain mode could not be changed. +** The explain mode cannot be changed while a statement is active. +** Hence, it is good practice to call [sqlite3_reset(S)] +** immediately prior to calling sqlite3_stmt_explain(S,E). +*/ +SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode); + +/* +** CAPI3REF: Determine If A Prepared Statement Has Been Reset +** METHOD: sqlite3_stmt +** +** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the +** [prepared statement] S has been stepped at least once using +** [sqlite3_step(S)] but has neither run to completion (returned +** [SQLITE_DONE] from [sqlite3_step(S)]) nor +** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S) +** interface returns false if S is a NULL pointer. If S is not a +** NULL pointer and is not a pointer to a valid [prepared statement] +** object, then the behavior is undefined and probably undesirable. +** +** This interface can be used in combination [sqlite3_next_stmt()] +** to locate all prepared statements associated with a database +** connection that are in need of being reset. This can be used, +** for example, in diagnostic routines to search for prepared +** statements that are holding a transaction open. +*/ +SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*); + +/* +** CAPI3REF: Dynamically Typed Value Object +** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} +** +** SQLite uses the sqlite3_value object to represent all values +** that can be stored in a database table. SQLite uses dynamic typing +** for the values it stores. ^Values stored in sqlite3_value objects +** can be integers, floating point values, strings, BLOBs, or NULL. +** +** An sqlite3_value object may be either "protected" or "unprotected". +** Some interfaces require a protected sqlite3_value. Other interfaces +** will accept either a protected or an unprotected sqlite3_value. +** Every interface that accepts sqlite3_value arguments specifies +** whether or not it requires a protected sqlite3_value. The +** [sqlite3_value_dup()] interface can be used to construct a new +** protected sqlite3_value from an unprotected sqlite3_value. +** +** The terms "protected" and "unprotected" refer to whether or not +** a mutex is held. An internal mutex is held for a protected +** sqlite3_value object but no mutex is held for an unprotected +** sqlite3_value object. If SQLite is compiled to be single-threaded +** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) +** or if SQLite is run in one of reduced mutex modes +** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] +** then there is no distinction between protected and unprotected +** sqlite3_value objects and they can be used interchangeably. However, +** for maximum code portability it is recommended that applications +** still make the distinction between protected and unprotected +** sqlite3_value objects even when not strictly required. +** +** ^The sqlite3_value objects that are passed as parameters into the +** implementation of [application-defined SQL functions] are protected. +** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()] +** are protected. +** ^The sqlite3_value object returned by +** [sqlite3_column_value()] is unprotected. +** Unprotected sqlite3_value objects may only be used as arguments +** to [sqlite3_result_value()], [sqlite3_bind_value()], and +** [sqlite3_value_dup()]. +** The [sqlite3_value_blob | sqlite3_value_type()] family of +** interfaces require protected sqlite3_value objects. +*/ +typedef struct sqlite3_value sqlite3_value; + +/* +** CAPI3REF: SQL Function Context Object +** +** The context in which an SQL function executes is stored in an +** sqlite3_context object. ^A pointer to an sqlite3_context object +** is always first parameter to [application-defined SQL functions]. +** The application-defined SQL function implementation will pass this +** pointer through into calls to [sqlite3_result_int | sqlite3_result()], +** [sqlite3_aggregate_context()], [sqlite3_user_data()], +** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], +** and/or [sqlite3_set_auxdata()]. +*/ +typedef struct sqlite3_context sqlite3_context; + +/* +** CAPI3REF: Binding Values To Prepared Statements +** KEYWORDS: {host parameter} {host parameters} {host parameter name} +** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} +** METHOD: sqlite3_stmt +** +** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, +** literals may be replaced by a [parameter] that matches one of the following +** templates: +** +**
    +**
  • ? +**
  • ?NNN +**
  • :VVV +**
  • @VVV +**
  • $VVV +**
+** +** In the templates above, NNN represents an integer literal, +** and VVV represents an alphanumeric identifier.)^ ^The values of these +** parameters (also called "host parameter names" or "SQL parameters") +** can be set using the sqlite3_bind_*() routines defined here. +** +** ^The first argument to the sqlite3_bind_*() routines is always +** a pointer to the [sqlite3_stmt] object returned from +** [sqlite3_prepare_v2()] or its variants. +** +** ^The second argument is the index of the SQL parameter to be set. +** ^The leftmost SQL parameter has an index of 1. ^When the same named +** SQL parameter is used more than once, second and subsequent +** occurrences have the same index as the first occurrence. +** ^The index for named parameters can be looked up using the +** [sqlite3_bind_parameter_index()] API if desired. ^The index +** for "?NNN" parameters is the value of NNN. +** ^The NNN value must be between 1 and the [sqlite3_limit()] +** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 32766). +** +** ^The third argument is the value to bind to the parameter. +** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16() +** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter +** is ignored and the end result is the same as sqlite3_bind_null(). +** ^If the third parameter to sqlite3_bind_text() is not NULL, then +** it should be a pointer to well-formed UTF8 text. +** ^If the third parameter to sqlite3_bind_text16() is not NULL, then +** it should be a pointer to well-formed UTF16 text. +** ^If the third parameter to sqlite3_bind_text64() is not NULL, then +** it should be a pointer to a well-formed unicode string that is +** either UTF8 if the sixth parameter is SQLITE_UTF8, or UTF16 +** otherwise. +** +** [[byte-order determination rules]] ^The byte-order of +** UTF16 input text is determined by the byte-order mark (BOM, U+FEFF) +** found in the first character, which is removed, or in the absence of a BOM +** the byte order is the native byte order of the host +** machine for sqlite3_bind_text16() or the byte order specified in +** the 6th parameter for sqlite3_bind_text64().)^ +** ^If UTF16 input text contains invalid unicode +** characters, then SQLite might change those invalid characters +** into the unicode replacement character: U+FFFD. +** +** ^(In those routines that have a fourth argument, its value is the +** number of bytes in the parameter. To be clear: the value is the +** number of bytes in the value, not the number of characters.)^ +** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16() +** is negative, then the length of the string is +** the number of bytes up to the first zero terminator. +** If the fourth parameter to sqlite3_bind_blob() is negative, then +** the behavior is undefined. +** If a non-negative fourth parameter is provided to sqlite3_bind_text() +** or sqlite3_bind_text16() or sqlite3_bind_text64() then +** that parameter must be the byte offset +** where the NUL terminator would occur assuming the string were NUL +** terminated. If any NUL characters occur at byte offsets less than +** the value of the fourth parameter then the resulting string value will +** contain embedded NULs. The result of expressions involving strings +** with embedded NULs is undefined. +** +** ^The fifth argument to the BLOB and string binding interfaces controls +** or indicates the lifetime of the object referenced by the third parameter. +** These three options exist: +** ^ (1) A destructor to dispose of the BLOB or string after SQLite has finished +** with it may be passed. ^It is called to dispose of the BLOB or string even +** if the call to the bind API fails, except the destructor is not called if +** the third parameter is a NULL pointer or the fourth parameter is negative. +** ^ (2) The special constant, [SQLITE_STATIC], may be passed to indicate that +** the application remains responsible for disposing of the object. ^In this +** case, the object and the provided pointer to it must remain valid until +** either the prepared statement is finalized or the same SQL parameter is +** bound to something else, whichever occurs sooner. +** ^ (3) The constant, [SQLITE_TRANSIENT], may be passed to indicate that the +** object is to be copied prior to the return from sqlite3_bind_*(). ^The +** object and pointer to it must remain valid until then. ^SQLite will then +** manage the lifetime of its private copy. +** +** ^The sixth argument to sqlite3_bind_text64() must be one of +** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] +** to specify the encoding of the text in the third parameter. If +** the sixth argument to sqlite3_bind_text64() is not one of the +** allowed values shown above, or if the text encoding is different +** from the encoding specified by the sixth parameter, then the behavior +** is undefined. +** +** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that +** is filled with zeroes. ^A zeroblob uses a fixed amount of memory +** (just an integer to hold its size) while it is being processed. +** Zeroblobs are intended to serve as placeholders for BLOBs whose +** content is later written using +** [sqlite3_blob_open | incremental BLOB I/O] routines. +** ^A negative value for the zeroblob results in a zero-length BLOB. +** +** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in +** [prepared statement] S to have an SQL value of NULL, but to also be +** associated with the pointer P of type T. ^D is either a NULL pointer or +** a pointer to a destructor function for P. ^SQLite will invoke the +** destructor D with a single argument of P when it is finished using +** P. The T parameter should be a static string, preferably a string +** literal. The sqlite3_bind_pointer() routine is part of the +** [pointer passing interface] added for SQLite 3.20.0. +** +** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer +** for the [prepared statement] or with a prepared statement for which +** [sqlite3_step()] has been called more recently than [sqlite3_reset()], +** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() +** routine is passed a [prepared statement] that has been finalized, the +** result is undefined and probably harmful. +** +** ^Bindings are not cleared by the [sqlite3_reset()] routine. +** ^Unbound parameters are interpreted as NULL. +** +** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an +** [error code] if anything goes wrong. +** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB +** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or +** [SQLITE_MAX_LENGTH]. +** ^[SQLITE_RANGE] is returned if the parameter +** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. +** +** See also: [sqlite3_bind_parameter_count()], +** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. +*/ +SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); +SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, + void(*)(void*)); +SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); +SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); +SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); +SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); +SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); +SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); +SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, + void(*)(void*), unsigned char encoding); +SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); +SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*)); +SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); +SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); + +/* +** CAPI3REF: Number Of SQL Parameters +** METHOD: sqlite3_stmt +** +** ^This routine can be used to find the number of [SQL parameters] +** in a [prepared statement]. SQL parameters are tokens of the +** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as +** placeholders for values that are [sqlite3_bind_blob | bound] +** to the parameters at a later time. +** +** ^(This routine actually returns the index of the largest (rightmost) +** parameter. For all forms except ?NNN, this will correspond to the +** number of unique parameters. If parameters of the ?NNN form are used, +** there may be gaps in the list.)^ +** +** See also: [sqlite3_bind_blob|sqlite3_bind()], +** [sqlite3_bind_parameter_name()], and +** [sqlite3_bind_parameter_index()]. +*/ +SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); + +/* +** CAPI3REF: Name Of A Host Parameter +** METHOD: sqlite3_stmt +** +** ^The sqlite3_bind_parameter_name(P,N) interface returns +** the name of the N-th [SQL parameter] in the [prepared statement] P. +** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" +** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" +** respectively. +** In other words, the initial ":" or "$" or "@" or "?" +** is included as part of the name.)^ +** ^Parameters of the form "?" without a following integer have no name +** and are referred to as "nameless" or "anonymous parameters". +** +** ^The first host parameter has an index of 1, not 0. +** +** ^If the value N is out of range or if the N-th parameter is +** nameless, then NULL is returned. ^The returned string is +** always in UTF-8 encoding even if the named parameter was +** originally specified as UTF-16 in [sqlite3_prepare16()], +** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()]. +** +** See also: [sqlite3_bind_blob|sqlite3_bind()], +** [sqlite3_bind_parameter_count()], and +** [sqlite3_bind_parameter_index()]. +*/ +SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); + +/* +** CAPI3REF: Index Of A Parameter With A Given Name +** METHOD: sqlite3_stmt +** +** ^Return the index of an SQL parameter given its name. ^The +** index value returned is suitable for use as the second +** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero +** is returned if no matching parameter is found. ^The parameter +** name must be given in UTF-8 even if the original statement +** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or +** [sqlite3_prepare16_v3()]. +** +** See also: [sqlite3_bind_blob|sqlite3_bind()], +** [sqlite3_bind_parameter_count()], and +** [sqlite3_bind_parameter_name()]. +*/ +SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); + +/* +** CAPI3REF: Reset All Bindings On A Prepared Statement +** METHOD: sqlite3_stmt +** +** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset +** the [sqlite3_bind_blob | bindings] on a [prepared statement]. +** ^Use this routine to reset all host parameters to NULL. +*/ +SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); + +/* +** CAPI3REF: Number Of Columns In A Result Set +** METHOD: sqlite3_stmt +** +** ^Return the number of columns in the result set returned by the +** [prepared statement]. ^If this routine returns 0, that means the +** [prepared statement] returns no data (for example an [UPDATE]). +** ^However, just because this routine returns a positive number does not +** mean that one or more rows of data will be returned. ^A SELECT statement +** will always have a positive sqlite3_column_count() but depending on the +** WHERE clause constraints and the table content, it might return no rows. +** +** See also: [sqlite3_data_count()] +*/ +SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Column Names In A Result Set +** METHOD: sqlite3_stmt +** +** ^These routines return the name assigned to a particular column +** in the result set of a [SELECT] statement. ^The sqlite3_column_name() +** interface returns a pointer to a zero-terminated UTF-8 string +** and sqlite3_column_name16() returns a pointer to a zero-terminated +** UTF-16 string. ^The first parameter is the [prepared statement] +** that implements the [SELECT] statement. ^The second parameter is the +** column number. ^The leftmost column is number 0. +** +** ^The returned string pointer is valid until either the [prepared statement] +** is destroyed by [sqlite3_finalize()] or until the statement is automatically +** reprepared by the first call to [sqlite3_step()] for a particular run +** or until the next call to +** sqlite3_column_name() or sqlite3_column_name16() on the same column. +** +** ^If sqlite3_malloc() fails during the processing of either routine +** (for example during a conversion from UTF-8 to UTF-16) then a +** NULL pointer is returned. +** +** ^The name of a result column is the value of the "AS" clause for +** that column, if there is an AS clause. If there is no AS clause +** then the name of the column is unspecified and may change from +** one release of SQLite to the next. +*/ +SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); +SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); + +/* +** CAPI3REF: Source Of Data In A Query Result +** METHOD: sqlite3_stmt +** +** ^These routines provide a means to determine the database, table, and +** table column that is the origin of a particular result column in a +** [SELECT] statement. +** ^The name of the database or table or column can be returned as +** either a UTF-8 or UTF-16 string. ^The _database_ routines return +** the database name, the _table_ routines return the table name, and +** the origin_ routines return the column name. +** ^The returned string is valid until the [prepared statement] is destroyed +** using [sqlite3_finalize()] or until the statement is automatically +** reprepared by the first call to [sqlite3_step()] for a particular run +** or until the same information is requested +** again in a different encoding. +** +** ^The names returned are the original un-aliased names of the +** database, table, and column. +** +** ^The first argument to these interfaces is a [prepared statement]. +** ^These functions return information about the Nth result column returned by +** the statement, where N is the second function argument. +** ^The left-most column is column 0 for these routines. +** +** ^If the Nth column returned by the statement is an expression or +** subquery and is not a column value, then all of these functions return +** NULL. ^These routines might also return NULL if a memory allocation error +** occurs. ^Otherwise, they return the name of the attached database, table, +** or column that query result column was extracted from. +** +** ^As with all other SQLite APIs, those whose names end with "16" return +** UTF-16 encoded strings and the other functions return UTF-8. +** +** ^These APIs are only available if the library was compiled with the +** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. +** +** If two or more threads call one or more +** [sqlite3_column_database_name | column metadata interfaces] +** for the same [prepared statement] and result column +** at the same time then the results are undefined. +*/ +SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int); +SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); +SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int); +SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); +SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); +SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); + +/* +** CAPI3REF: Declared Datatype Of A Query Result +** METHOD: sqlite3_stmt +** +** ^(The first parameter is a [prepared statement]. +** If this statement is a [SELECT] statement and the Nth column of the +** returned result set of that [SELECT] is a table column (not an +** expression or subquery) then the declared type of the table +** column is returned.)^ ^If the Nth column of the result set is an +** expression or subquery, then a NULL pointer is returned. +** ^The returned string is always UTF-8 encoded. +** +** ^(For example, given the database schema: +** +** CREATE TABLE t1(c1 VARIANT); +** +** and the following statement to be compiled: +** +** SELECT c1 + 1, c1 FROM t1; +** +** this routine would return the string "VARIANT" for the second result +** column (i==1), and a NULL pointer for the first result column (i==0).)^ +** +** ^SQLite uses dynamic run-time typing. ^So just because a column +** is declared to contain a particular type does not mean that the +** data stored in that column is of the declared type. SQLite is +** strongly typed, but the typing is dynamic not static. ^Type +** is associated with individual values, not with the containers +** used to hold those values. +*/ +SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); +SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); + +/* +** CAPI3REF: Evaluate An SQL Statement +** METHOD: sqlite3_stmt +** +** After a [prepared statement] has been prepared using any of +** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()], +** or [sqlite3_prepare16_v3()] or one of the legacy +** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function +** must be called one or more times to evaluate the statement. +** +** The details of the behavior of the sqlite3_step() interface depend +** on whether the statement was prepared using the newer "vX" interfaces +** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()], +** [sqlite3_prepare16_v2()] or the older legacy +** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the +** new "vX" interface is recommended for new applications but the legacy +** interface will continue to be supported. +** +** ^In the legacy interface, the return value will be either [SQLITE_BUSY], +** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. +** ^With the "v2" interface, any of the other [result codes] or +** [extended result codes] might be returned as well. +** +** ^[SQLITE_BUSY] means that the database engine was unable to acquire the +** database locks it needs to do its job. ^If the statement is a [COMMIT] +** or occurs outside of an explicit transaction, then you can retry the +** statement. If the statement is not a [COMMIT] and occurs within an +** explicit transaction then you should rollback the transaction before +** continuing. +** +** ^[SQLITE_DONE] means that the statement has finished executing +** successfully. sqlite3_step() should not be called again on this virtual +** machine without first calling [sqlite3_reset()] to reset the virtual +** machine back to its initial state. +** +** ^If the SQL statement being executed returns any data, then [SQLITE_ROW] +** is returned each time a new row of data is ready for processing by the +** caller. The values may be accessed using the [column access functions]. +** sqlite3_step() is called again to retrieve the next row of data. +** +** ^[SQLITE_ERROR] means that a run-time error (such as a constraint +** violation) has occurred. sqlite3_step() should not be called again on +** the VM. More information may be found by calling [sqlite3_errmsg()]. +** ^With the legacy interface, a more specific error code (for example, +** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) +** can be obtained by calling [sqlite3_reset()] on the +** [prepared statement]. ^In the "v2" interface, +** the more specific error code is returned directly by sqlite3_step(). +** +** [SQLITE_MISUSE] means that the this routine was called inappropriately. +** Perhaps it was called on a [prepared statement] that has +** already been [sqlite3_finalize | finalized] or on one that had +** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could +** be the case that the same database connection is being used by two or +** more threads at the same moment in time. +** +** For all versions of SQLite up to and including 3.6.23.1, a call to +** [sqlite3_reset()] was required after sqlite3_step() returned anything +** other than [SQLITE_ROW] before any subsequent invocation of +** sqlite3_step(). Failure to reset the prepared statement using +** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from +** sqlite3_step(). But after [version 3.6.23.1] ([dateof:3.6.23.1]), +** sqlite3_step() began +** calling [sqlite3_reset()] automatically in this circumstance rather +** than returning [SQLITE_MISUSE]. This is not considered a compatibility +** break because any application that ever receives an SQLITE_MISUSE error +** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option +** can be used to restore the legacy behavior. +** +** Goofy Interface Alert: In the legacy interface, the sqlite3_step() +** API always returns a generic error code, [SQLITE_ERROR], following any +** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call +** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the +** specific [error codes] that better describes the error. +** We admit that this is a goofy design. The problem has been fixed +** with the "v2" interface. If you prepare all of your SQL statements +** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()] +** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead +** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, +** then the more specific [error codes] are returned directly +** by sqlite3_step(). The use of the "vX" interfaces is recommended. +*/ +SQLITE_API int sqlite3_step(sqlite3_stmt*); + +/* +** CAPI3REF: Number of columns in a result set +** METHOD: sqlite3_stmt +** +** ^The sqlite3_data_count(P) interface returns the number of columns in the +** current row of the result set of [prepared statement] P. +** ^If prepared statement P does not have results ready to return +** (via calls to the [sqlite3_column_int | sqlite3_column()] family of +** interfaces) then sqlite3_data_count(P) returns 0. +** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. +** ^The sqlite3_data_count(P) routine returns 0 if the previous call to +** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) +** will return non-zero if previous call to [sqlite3_step](P) returned +** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum] +** where it always returns zero since each step of that multi-step +** pragma returns 0 columns of data. +** +** See also: [sqlite3_column_count()] +*/ +SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Fundamental Datatypes +** KEYWORDS: SQLITE_TEXT +** +** ^(Every value in SQLite has one of five fundamental datatypes: +** +**
    +**
  • 64-bit signed integer +**
  • 64-bit IEEE floating point number +**
  • string +**
  • BLOB +**
  • NULL +**
)^ +** +** These constants are codes for each of those types. +** +** Note that the SQLITE_TEXT constant was also used in SQLite version 2 +** for a completely different meaning. Software that links against both +** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not +** SQLITE_TEXT. +*/ +#define SQLITE_INTEGER 1 +#define SQLITE_FLOAT 2 +#define SQLITE_BLOB 4 +#define SQLITE_NULL 5 +#ifdef SQLITE_TEXT +# undef SQLITE_TEXT +#else +# define SQLITE_TEXT 3 +#endif +#define SQLITE3_TEXT 3 + +/* +** CAPI3REF: Result Values From A Query +** KEYWORDS: {column access functions} +** METHOD: sqlite3_stmt +** +** Summary: +**
+**
sqlite3_column_blobBLOB result +**
sqlite3_column_doubleREAL result +**
sqlite3_column_int32-bit INTEGER result +**
sqlite3_column_int6464-bit INTEGER result +**
sqlite3_column_textUTF-8 TEXT result +**
sqlite3_column_text16UTF-16 TEXT result +**
sqlite3_column_valueThe result as an +** [sqlite3_value|unprotected sqlite3_value] object. +**
    +**
sqlite3_column_bytesSize of a BLOB +** or a UTF-8 TEXT result in bytes +**
sqlite3_column_bytes16   +** →  Size of UTF-16 +** TEXT in bytes +**
sqlite3_column_typeDefault +** datatype of the result +**
+** +** Details: +** +** ^These routines return information about a single column of the current +** result row of a query. ^In every case the first argument is a pointer +** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] +** that was returned from [sqlite3_prepare_v2()] or one of its variants) +** and the second argument is the index of the column for which information +** should be returned. ^The leftmost column of the result set has the index 0. +** ^The number of columns in the result can be determined using +** [sqlite3_column_count()]. +** +** If the SQL statement does not currently point to a valid row, or if the +** column index is out of range, the result is undefined. +** These routines may only be called when the most recent call to +** [sqlite3_step()] has returned [SQLITE_ROW] and neither +** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. +** If any of these routines are called after [sqlite3_reset()] or +** [sqlite3_finalize()] or after [sqlite3_step()] has returned +** something other than [SQLITE_ROW], the results are undefined. +** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] +** are called from a different thread while any of these routines +** are pending, then the results are undefined. +** +** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16) +** each return the value of a result column in a specific data format. If +** the result column is not initially in the requested format (for example, +** if the query returns an integer but the sqlite3_column_text() interface +** is used to extract the value) then an automatic type conversion is performed. +** +** ^The sqlite3_column_type() routine returns the +** [SQLITE_INTEGER | datatype code] for the initial data type +** of the result column. ^The returned value is one of [SQLITE_INTEGER], +** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. +** The return value of sqlite3_column_type() can be used to decide which +** of the first six interface should be used to extract the column value. +** The value returned by sqlite3_column_type() is only meaningful if no +** automatic type conversions have occurred for the value in question. +** After a type conversion, the result of calling sqlite3_column_type() +** is undefined, though harmless. Future +** versions of SQLite may change the behavior of sqlite3_column_type() +** following a type conversion. +** +** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes() +** or sqlite3_column_bytes16() interfaces can be used to determine the size +** of that BLOB or string. +** +** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() +** routine returns the number of bytes in that BLOB or string. +** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts +** the string to UTF-8 and then returns the number of bytes. +** ^If the result is a numeric value then sqlite3_column_bytes() uses +** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns +** the number of bytes in that string. +** ^If the result is NULL, then sqlite3_column_bytes() returns zero. +** +** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() +** routine returns the number of bytes in that BLOB or string. +** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts +** the string to UTF-16 and then returns the number of bytes. +** ^If the result is a numeric value then sqlite3_column_bytes16() uses +** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns +** the number of bytes in that string. +** ^If the result is NULL, then sqlite3_column_bytes16() returns zero. +** +** ^The values returned by [sqlite3_column_bytes()] and +** [sqlite3_column_bytes16()] do not include the zero terminators at the end +** of the string. ^For clarity: the values returned by +** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of +** bytes in the string, not the number of characters. +** +** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), +** even empty strings, are always zero-terminated. ^The return +** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. +** +** ^Strings returned by sqlite3_column_text16() always have the endianness +** which is native to the platform, regardless of the text encoding set +** for the database. +** +** Warning: ^The object returned by [sqlite3_column_value()] is an +** [unprotected sqlite3_value] object. In a multithreaded environment, +** an unprotected sqlite3_value object may only be used safely with +** [sqlite3_bind_value()] and [sqlite3_result_value()]. +** If the [unprotected sqlite3_value] object returned by +** [sqlite3_column_value()] is used in any other way, including calls +** to routines like [sqlite3_value_int()], [sqlite3_value_text()], +** or [sqlite3_value_bytes()], the behavior is not threadsafe. +** Hence, the sqlite3_column_value() interface +** is normally only useful within the implementation of +** [application-defined SQL functions] or [virtual tables], not within +** top-level application code. +** +** These routines may attempt to convert the datatype of the result. +** ^For example, if the internal representation is FLOAT and a text result +** is requested, [sqlite3_snprintf()] is used internally to perform the +** conversion automatically. ^(The following table details the conversions +** that are applied: +** +**
+** +**
Internal
Type
Requested
Type
Conversion +** +**
NULL INTEGER Result is 0 +**
NULL FLOAT Result is 0.0 +**
NULL TEXT Result is a NULL pointer +**
NULL BLOB Result is a NULL pointer +**
INTEGER FLOAT Convert from integer to float +**
INTEGER TEXT ASCII rendering of the integer +**
INTEGER BLOB Same as INTEGER->TEXT +**
FLOAT INTEGER [CAST] to INTEGER +**
FLOAT TEXT ASCII rendering of the float +**
FLOAT BLOB [CAST] to BLOB +**
TEXT INTEGER [CAST] to INTEGER +**
TEXT FLOAT [CAST] to REAL +**
TEXT BLOB No change +**
BLOB INTEGER [CAST] to INTEGER +**
BLOB FLOAT [CAST] to REAL +**
BLOB TEXT [CAST] to TEXT, ensure zero terminator +**
+**
)^ +** +** Note that when type conversions occur, pointers returned by prior +** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or +** sqlite3_column_text16() may be invalidated. +** Type conversions and pointer invalidations might occur +** in the following cases: +** +**
    +**
  • The initial content is a BLOB and sqlite3_column_text() or +** sqlite3_column_text16() is called. A zero-terminator might +** need to be added to the string.
  • +**
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or +** sqlite3_column_text16() is called. The content must be converted +** to UTF-16.
  • +**
  • The initial content is UTF-16 text and sqlite3_column_bytes() or +** sqlite3_column_text() is called. The content must be converted +** to UTF-8.
  • +**
+** +** ^Conversions between UTF-16be and UTF-16le are always done in place and do +** not invalidate a prior pointer, though of course the content of the buffer +** that the prior pointer references will have been modified. Other kinds +** of conversion are done in place when it is possible, but sometimes they +** are not possible and in those cases prior pointers are invalidated. +** +** The safest policy is to invoke these routines +** in one of the following ways: +** +**
    +**
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • +**
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • +**
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • +**
+** +** In other words, you should call sqlite3_column_text(), +** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result +** into the desired format, then invoke sqlite3_column_bytes() or +** sqlite3_column_bytes16() to find the size of the result. Do not mix calls +** to sqlite3_column_text() or sqlite3_column_blob() with calls to +** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() +** with calls to sqlite3_column_bytes(). +** +** ^The pointers returned are valid until a type conversion occurs as +** described above, or until [sqlite3_step()] or [sqlite3_reset()] or +** [sqlite3_finalize()] is called. ^The memory space used to hold strings +** and BLOBs is freed automatically. Do not pass the pointers returned +** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into +** [sqlite3_free()]. +** +** As long as the input parameters are correct, these routines will only +** fail if an out-of-memory error occurs during a format conversion. +** Only the following subset of interfaces are subject to out-of-memory +** errors: +** +**
    +**
  • sqlite3_column_blob() +**
  • sqlite3_column_text() +**
  • sqlite3_column_text16() +**
  • sqlite3_column_bytes() +**
  • sqlite3_column_bytes16() +**
+** +** If an out-of-memory error occurs, then the return value from these +** routines is the same as if the column had contained an SQL NULL value. +** Valid SQL NULL returns can be distinguished from out-of-memory errors +** by invoking the [sqlite3_errcode()] immediately after the suspect +** return value is obtained and before any +** other SQLite interface is called on the same [database connection]. +*/ +SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); +SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); +SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); +SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); +SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); +SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); +SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); +SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); +SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); +SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); + +/* +** CAPI3REF: Destroy A Prepared Statement Object +** DESTRUCTOR: sqlite3_stmt +** +** ^The sqlite3_finalize() function is called to delete a [prepared statement]. +** ^If the most recent evaluation of the statement encountered no errors +** or if the statement is never been evaluated, then sqlite3_finalize() returns +** SQLITE_OK. ^If the most recent evaluation of statement S failed, then +** sqlite3_finalize(S) returns the appropriate [error code] or +** [extended error code]. +** +** ^The sqlite3_finalize(S) routine can be called at any point during +** the life cycle of [prepared statement] S: +** before statement S is ever evaluated, after +** one or more calls to [sqlite3_reset()], or after any call +** to [sqlite3_step()] regardless of whether or not the statement has +** completed execution. +** +** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. +** +** The application must finalize every [prepared statement] in order to avoid +** resource leaks. It is a grievous error for the application to try to use +** a prepared statement after it has been finalized. Any use of a prepared +** statement after it has been finalized can result in undefined and +** undesirable behavior such as segfaults and heap corruption. +*/ +SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Reset A Prepared Statement Object +** METHOD: sqlite3_stmt +** +** The sqlite3_reset() function is called to reset a [prepared statement] +** object back to its initial state, ready to be re-executed. +** ^Any SQL statement variables that had values bound to them using +** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. +** Use [sqlite3_clear_bindings()] to reset the bindings. +** +** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S +** back to the beginning of its program. +** +** ^The return code from [sqlite3_reset(S)] indicates whether or not +** the previous evaluation of prepared statement S completed successfully. +** ^If [sqlite3_step(S)] has never before been called on S or if +** [sqlite3_step(S)] has not been called since the previous call +** to [sqlite3_reset(S)], then [sqlite3_reset(S)] will return +** [SQLITE_OK]. +** +** ^If the most recent call to [sqlite3_step(S)] for the +** [prepared statement] S indicated an error, then +** [sqlite3_reset(S)] returns an appropriate [error code]. +** ^The [sqlite3_reset(S)] interface might also return an [error code] +** if there were no prior errors but the process of resetting +** the prepared statement caused a new error. ^For example, if an +** [INSERT] statement with a [RETURNING] clause is only stepped one time, +** that one call to [sqlite3_step(S)] might return SQLITE_ROW but +** the overall statement might still fail and the [sqlite3_reset(S)] call +** might return SQLITE_BUSY if locking constraints prevent the +** database change from committing. Therefore, it is important that +** applications check the return code from [sqlite3_reset(S)] even if +** no prior call to [sqlite3_step(S)] indicated a problem. +** +** ^The [sqlite3_reset(S)] interface does not change the values +** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. +*/ +SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); + + +/* +** CAPI3REF: Create Or Redefine SQL Functions +** KEYWORDS: {function creation routines} +** METHOD: sqlite3 +** +** ^These functions (collectively known as "function creation routines") +** are used to add SQL functions or aggregates or to redefine the behavior +** of existing SQL functions or aggregates. The only differences between +** the three "sqlite3_create_function*" routines are the text encoding +** expected for the second parameter (the name of the function being +** created) and the presence or absence of a destructor callback for +** the application data pointer. Function sqlite3_create_window_function() +** is similar, but allows the user to supply the extra callback functions +** needed by [aggregate window functions]. +** +** ^The first parameter is the [database connection] to which the SQL +** function is to be added. ^If an application uses more than one database +** connection then application-defined SQL functions must be added +** to each database connection separately. +** +** ^The second parameter is the name of the SQL function to be created or +** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 +** representation, exclusive of the zero-terminator. ^Note that the name +** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. +** ^Any attempt to create a function with a longer name +** will result in [SQLITE_MISUSE] being returned. +** +** ^The third parameter (nArg) +** is the number of arguments that the SQL function or +** aggregate takes. ^If this parameter is -1, then the SQL function or +** aggregate may take any number of arguments between 0 and the limit +** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third +** parameter is less than -1 or greater than 127 then the behavior is +** undefined. +** +** ^The fourth parameter, eTextRep, specifies what +** [SQLITE_UTF8 | text encoding] this SQL function prefers for +** its parameters. The application should set this parameter to +** [SQLITE_UTF16LE] if the function implementation invokes +** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the +** implementation invokes [sqlite3_value_text16be()] on an input, or +** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8] +** otherwise. ^The same SQL function may be registered multiple times using +** different preferred text encodings, with different implementations for +** each encoding. +** ^When multiple implementations of the same function are available, SQLite +** will pick the one that involves the least amount of data conversion. +** +** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC] +** to signal that the function will always return the same result given +** the same inputs within a single SQL statement. Most SQL functions are +** deterministic. The built-in [random()] SQL function is an example of a +** function that is not deterministic. The SQLite query planner is able to +** perform additional optimizations on deterministic functions, so use +** of the [SQLITE_DETERMINISTIC] flag is recommended where possible. +** +** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY] +** flag, which if present prevents the function from being invoked from +** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, +** index expressions, or the WHERE clause of partial indexes. +** +** For best security, the [SQLITE_DIRECTONLY] flag is recommended for +** all application-defined SQL functions that do not need to be +** used inside of triggers, views, CHECK constraints, or other elements of +** the database schema. This flag is especially recommended for SQL +** functions that have side effects or reveal internal application state. +** Without this flag, an attacker might be able to modify the schema of +** a database file to include invocations of the function with parameters +** chosen by the attacker, which the application will then execute when +** the database file is opened and read. +** +** ^(The fifth parameter is an arbitrary pointer. The implementation of the +** function can gain access to this pointer using [sqlite3_user_data()].)^ +** +** ^The sixth, seventh and eighth parameters passed to the three +** "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are +** pointers to C-language functions that implement the SQL function or +** aggregate. ^A scalar SQL function requires an implementation of the xFunc +** callback only; NULL pointers must be passed as the xStep and xFinal +** parameters. ^An aggregate SQL function requires an implementation of xStep +** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing +** SQL function or aggregate, pass NULL pointers for all three function +** callbacks. +** +** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue +** and xInverse) passed to sqlite3_create_window_function are pointers to +** C-language callbacks that implement the new function. xStep and xFinal +** must both be non-NULL. xValue and xInverse may either both be NULL, in +** which case a regular aggregate function is created, or must both be +** non-NULL, in which case the new function may be used as either an aggregate +** or aggregate window function. More details regarding the implementation +** of aggregate window functions are +** [user-defined window functions|available here]. +** +** ^(If the final parameter to sqlite3_create_function_v2() or +** sqlite3_create_window_function() is not NULL, then it is the destructor for +** the application data pointer. The destructor is invoked when the function +** is deleted, either by being overloaded or when the database connection +** closes.)^ ^The destructor is also invoked if the call to +** sqlite3_create_function_v2() fails. ^When the destructor callback is +** invoked, it is passed a single argument which is a copy of the application +** data pointer which was the fifth parameter to sqlite3_create_function_v2(). +** +** ^It is permitted to register multiple implementations of the same +** functions with the same name but with either differing numbers of +** arguments or differing preferred text encodings. ^SQLite will use +** the implementation that most closely matches the way in which the +** SQL function is used. ^A function implementation with a non-negative +** nArg parameter is a better match than a function implementation with +** a negative nArg. ^A function where the preferred text encoding +** matches the database encoding is a better +** match than a function where the encoding is different. +** ^A function where the encoding difference is between UTF16le and UTF16be +** is a closer match than a function where the encoding difference is +** between UTF8 and UTF16. +** +** ^Built-in functions may be overloaded by new application-defined functions. +** +** ^An application-defined function is permitted to call other +** SQLite interfaces. However, such calls must not +** close the database connection nor finalize or reset the prepared +** statement in which the function is running. +*/ +SQLITE_API int sqlite3_create_function( + sqlite3 *db, + const char *zFunctionName, + int nArg, + int eTextRep, + void *pApp, + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*) +); +SQLITE_API int sqlite3_create_function16( + sqlite3 *db, + const void *zFunctionName, + int nArg, + int eTextRep, + void *pApp, + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*) +); +SQLITE_API int sqlite3_create_function_v2( + sqlite3 *db, + const char *zFunctionName, + int nArg, + int eTextRep, + void *pApp, + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*), + void(*xDestroy)(void*) +); +SQLITE_API int sqlite3_create_window_function( + sqlite3 *db, + const char *zFunctionName, + int nArg, + int eTextRep, + void *pApp, + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*), + void (*xValue)(sqlite3_context*), + void (*xInverse)(sqlite3_context*,int,sqlite3_value**), + void(*xDestroy)(void*) +); + +/* +** CAPI3REF: Text Encodings +** +** These constant define integer codes that represent the various +** text encodings supported by SQLite. +*/ +#define SQLITE_UTF8 1 /* IMP: R-37514-35566 */ +#define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */ +#define SQLITE_UTF16BE 3 /* IMP: R-51971-34154 */ +#define SQLITE_UTF16 4 /* Use native byte order */ +#define SQLITE_ANY 5 /* Deprecated */ +#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ + +/* +** CAPI3REF: Function Flags +** +** These constants may be ORed together with the +** [SQLITE_UTF8 | preferred text encoding] as the fourth argument +** to [sqlite3_create_function()], [sqlite3_create_function16()], or +** [sqlite3_create_function_v2()]. +** +**
+** [[SQLITE_DETERMINISTIC]]
SQLITE_DETERMINISTIC
+** The SQLITE_DETERMINISTIC flag means that the new function always gives +** the same output when the input parameters are the same. +** The [abs|abs() function] is deterministic, for example, but +** [randomblob|randomblob()] is not. Functions must +** be deterministic in order to be used in certain contexts such as +** with the WHERE clause of [partial indexes] or in [generated columns]. +** SQLite might also optimize deterministic functions by factoring them +** out of inner loops. +**
+** +** [[SQLITE_DIRECTONLY]]
SQLITE_DIRECTONLY
+** The SQLITE_DIRECTONLY flag means that the function may only be invoked +** from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in +** schema structures such as [CHECK constraints], [DEFAULT clauses], +** [expression indexes], [partial indexes], or [generated columns]. +**

+** The SQLITE_DIRECTONLY flag is recommended for any +** [application-defined SQL function] +** that has side-effects or that could potentially leak sensitive information. +** This will prevent attacks in which an application is tricked +** into using a database file that has had its schema surreptitiously +** modified to invoke the application-defined function in ways that are +** harmful. +**

+** Some people say it is good practice to set SQLITE_DIRECTONLY on all +** [application-defined SQL functions], regardless of whether or not they +** are security sensitive, as doing so prevents those functions from being used +** inside of the database schema, and thus ensures that the database +** can be inspected and modified using generic tools (such as the [CLI]) +** that do not have access to the application-defined functions. +**

+** +** [[SQLITE_INNOCUOUS]]
SQLITE_INNOCUOUS
+** The SQLITE_INNOCUOUS flag means that the function is unlikely +** to cause problems even if misused. An innocuous function should have +** no side effects and should not depend on any values other than its +** input parameters. The [abs|abs() function] is an example of an +** innocuous function. +** The [load_extension() SQL function] is not innocuous because of its +** side effects. +**

SQLITE_INNOCUOUS is similar to SQLITE_DETERMINISTIC, but is not +** exactly the same. The [random|random() function] is an example of a +** function that is innocuous but not deterministic. +**

Some heightened security settings +** ([SQLITE_DBCONFIG_TRUSTED_SCHEMA] and [PRAGMA trusted_schema=OFF]) +** disable the use of SQL functions inside views and triggers and in +** schema structures such as [CHECK constraints], [DEFAULT clauses], +** [expression indexes], [partial indexes], and [generated columns] unless +** the function is tagged with SQLITE_INNOCUOUS. Most built-in functions +** are innocuous. Developers are advised to avoid using the +** SQLITE_INNOCUOUS flag for application-defined functions unless the +** function has been carefully audited and found to be free of potentially +** security-adverse side-effects and information-leaks. +**

+** +** [[SQLITE_SUBTYPE]]
SQLITE_SUBTYPE
+** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call +** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. +** This flag instructs SQLite to omit some corner-case optimizations that +** might disrupt the operation of the [sqlite3_value_subtype()] function, +** causing it to return zero rather than the correct subtype(). +** All SQL functions that invoke [sqlite3_value_subtype()] should have this +** property. If the SQLITE_SUBTYPE property is omitted, then the return +** value from [sqlite3_value_subtype()] might sometimes be zero even though +** a non-zero subtype was specified by the function argument expression. +** +** [[SQLITE_RESULT_SUBTYPE]]
SQLITE_RESULT_SUBTYPE
+** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call +** [sqlite3_result_subtype()] to cause a sub-type to be associated with its +** result. +** Every function that invokes [sqlite3_result_subtype()] should have this +** property. If it does not, then the call to [sqlite3_result_subtype()] +** might become a no-op if the function is used as term in an +** [expression index]. On the other hand, SQL functions that never invoke +** [sqlite3_result_subtype()] should avoid setting this property, as the +** purpose of this property is to disable certain optimizations that are +** incompatible with subtypes. +** +** [[SQLITE_SELFORDER1]]
SQLITE_SELFORDER1
+** The SQLITE_SELFORDER1 flag indicates that the function is an aggregate +** that internally orders the values provided to the first argument. The +** ordered-set aggregate SQL notation with a single ORDER BY term can be +** used to invoke this function. If the ordered-set aggregate notation is +** used on a function that lacks this flag, then an error is raised. Note +** that the ordered-set aggregate syntax is only available if SQLite is +** built using the -DSQLITE_ENABLE_ORDERED_SET_AGGREGATES compile-time option. +**
+**
+*/ +#define SQLITE_DETERMINISTIC 0x000000800 +#define SQLITE_DIRECTONLY 0x000080000 +#define SQLITE_SUBTYPE 0x000100000 +#define SQLITE_INNOCUOUS 0x000200000 +#define SQLITE_RESULT_SUBTYPE 0x001000000 +#define SQLITE_SELFORDER1 0x002000000 + +/* +** CAPI3REF: Deprecated Functions +** DEPRECATED +** +** These functions are [deprecated]. In order to maintain +** backwards compatibility with older code, these functions continue +** to be supported. However, new applications should avoid +** the use of these functions. To encourage programmers to avoid +** these functions, we will not explain what they do. +*/ +#ifndef SQLITE_OMIT_DEPRECATED +SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); +SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); +SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); +SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); +SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); +SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), + void*,sqlite3_int64); +#endif + +/* +** CAPI3REF: Obtaining SQL Values +** METHOD: sqlite3_value +** +** Summary: +**
+**
sqlite3_value_blobBLOB value +**
sqlite3_value_doubleREAL value +**
sqlite3_value_int32-bit INTEGER value +**
sqlite3_value_int6464-bit INTEGER value +**
sqlite3_value_pointerPointer value +**
sqlite3_value_textUTF-8 TEXT value +**
sqlite3_value_text16UTF-16 TEXT value in +** the native byteorder +**
sqlite3_value_text16beUTF-16be TEXT value +**
sqlite3_value_text16leUTF-16le TEXT value +**
    +**
sqlite3_value_bytesSize of a BLOB +** or a UTF-8 TEXT in bytes +**
sqlite3_value_bytes16   +** →  Size of UTF-16 +** TEXT in bytes +**
sqlite3_value_typeDefault +** datatype of the value +**
sqlite3_value_numeric_type   +** →  Best numeric datatype of the value +**
sqlite3_value_nochange   +** →  True if the column is unchanged in an UPDATE +** against a virtual table. +**
sqlite3_value_frombind   +** →  True if value originated from a [bound parameter] +**
+** +** Details: +** +** These routines extract type, size, and content information from +** [protected sqlite3_value] objects. Protected sqlite3_value objects +** are used to pass parameter information into the functions that +** implement [application-defined SQL functions] and [virtual tables]. +** +** These routines work only with [protected sqlite3_value] objects. +** Any attempt to use these routines on an [unprotected sqlite3_value] +** is not threadsafe. +** +** ^These routines work just like the corresponding [column access functions] +** except that these routines take a single [protected sqlite3_value] object +** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. +** +** ^The sqlite3_value_text16() interface extracts a UTF-16 string +** in the native byte-order of the host machine. ^The +** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces +** extract UTF-16 strings as big-endian and little-endian respectively. +** +** ^If [sqlite3_value] object V was initialized +** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)] +** and if X and Y are strings that compare equal according to strcmp(X,Y), +** then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, +** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() +** routine is part of the [pointer passing interface] added for SQLite 3.20.0. +** +** ^(The sqlite3_value_type(V) interface returns the +** [SQLITE_INTEGER | datatype code] for the initial datatype of the +** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], +** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ +** Other interfaces might change the datatype for an sqlite3_value object. +** For example, if the datatype is initially SQLITE_INTEGER and +** sqlite3_value_text(V) is called to extract a text value for that +** integer, then subsequent calls to sqlite3_value_type(V) might return +** SQLITE_TEXT. Whether or not a persistent internal datatype conversion +** occurs is undefined and may change from one release of SQLite to the next. +** +** ^(The sqlite3_value_numeric_type() interface attempts to apply +** numeric affinity to the value. This means that an attempt is +** made to convert the value to an integer or floating point. If +** such a conversion is possible without loss of information (in other +** words, if the value is a string that looks like a number) +** then the conversion is performed. Otherwise no conversion occurs. +** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ +** +** ^Within the [xUpdate] method of a [virtual table], the +** sqlite3_value_nochange(X) interface returns true if and only if +** the column corresponding to X is unchanged by the UPDATE operation +** that the xUpdate method call was invoked to implement and if +** and the prior [xColumn] method call that was invoked to extracted +** the value for that column returned without setting a result (probably +** because it queried [sqlite3_vtab_nochange()] and found that the column +** was unchanging). ^Within an [xUpdate] method, any value for which +** sqlite3_value_nochange(X) is true will in all other respects appear +** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other +** than within an [xUpdate] method call for an UPDATE statement, then +** the return value is arbitrary and meaningless. +** +** ^The sqlite3_value_frombind(X) interface returns non-zero if the +** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] +** interfaces. ^If X comes from an SQL literal value, or a table column, +** or an expression, then sqlite3_value_frombind(X) returns zero. +** +** Please pay particular attention to the fact that the pointer returned +** from [sqlite3_value_blob()], [sqlite3_value_text()], or +** [sqlite3_value_text16()] can be invalidated by a subsequent call to +** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], +** or [sqlite3_value_text16()]. +** +** These routines must be called from the same thread as +** the SQL function that supplied the [sqlite3_value*] parameters. +** +** As long as the input parameter is correct, these routines can only +** fail if an out-of-memory error occurs during a format conversion. +** Only the following subset of interfaces are subject to out-of-memory +** errors: +** +**
    +**
  • sqlite3_value_blob() +**
  • sqlite3_value_text() +**
  • sqlite3_value_text16() +**
  • sqlite3_value_text16le() +**
  • sqlite3_value_text16be() +**
  • sqlite3_value_bytes() +**
  • sqlite3_value_bytes16() +**
+** +** If an out-of-memory error occurs, then the return value from these +** routines is the same as if the column had contained an SQL NULL value. +** Valid SQL NULL returns can be distinguished from out-of-memory errors +** by invoking the [sqlite3_errcode()] immediately after the suspect +** return value is obtained and before any +** other SQLite interface is called on the same [database connection]. +*/ +SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); +SQLITE_API double sqlite3_value_double(sqlite3_value*); +SQLITE_API int sqlite3_value_int(sqlite3_value*); +SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); +SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*); +SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); +SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); +SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); +SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); +SQLITE_API int sqlite3_value_bytes(sqlite3_value*); +SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); +SQLITE_API int sqlite3_value_type(sqlite3_value*); +SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); +SQLITE_API int sqlite3_value_nochange(sqlite3_value*); +SQLITE_API int sqlite3_value_frombind(sqlite3_value*); + +/* +** CAPI3REF: Report the internal text encoding state of an sqlite3_value object +** METHOD: sqlite3_value +** +** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8], +** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current text encoding +** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X) +** returns something other than SQLITE_TEXT, then the return value from +** sqlite3_value_encoding(X) is meaningless. ^Calls to +** [sqlite3_value_text(X)], [sqlite3_value_text16(X)], [sqlite3_value_text16be(X)], +** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or +** [sqlite3_value_bytes16(X)] might change the encoding of the value X and +** thus change the return from subsequent calls to sqlite3_value_encoding(X). +** +** This routine is intended for used by applications that test and validate +** the SQLite implementation. This routine is inquiring about the opaque +** internal state of an [sqlite3_value] object. Ordinary applications should +** not need to know what the internal state of an sqlite3_value object is and +** hence should not need to use this interface. +*/ +SQLITE_API int sqlite3_value_encoding(sqlite3_value*); + +/* +** CAPI3REF: Finding The Subtype Of SQL Values +** METHOD: sqlite3_value +** +** The sqlite3_value_subtype(V) function returns the subtype for +** an [application-defined SQL function] argument V. The subtype +** information can be used to pass a limited amount of context from +** one SQL function to another. Use the [sqlite3_result_subtype()] +** routine to set the subtype for the return value of an SQL function. +** +** Every [application-defined SQL function] that invokes this interface +** should include the [SQLITE_SUBTYPE] property in the text +** encoding argument when the function is [sqlite3_create_function|registered]. +** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype() +** might return zero instead of the upstream subtype in some corner cases. +*/ +SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*); + +/* +** CAPI3REF: Copy And Free SQL Values +** METHOD: sqlite3_value +** +** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value] +** object V and returns a pointer to that copy. ^The [sqlite3_value] returned +** is a [protected sqlite3_value] object even if the input is not. +** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a +** memory allocation fails. ^If V is a [pointer value], then the result +** of sqlite3_value_dup(V) is a NULL value. +** +** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object +** previously obtained from [sqlite3_value_dup()]. ^If V is a NULL pointer +** then sqlite3_value_free(V) is a harmless no-op. +*/ +SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value*); +SQLITE_API void sqlite3_value_free(sqlite3_value*); + +/* +** CAPI3REF: Obtain Aggregate Function Context +** METHOD: sqlite3_context +** +** Implementations of aggregate SQL functions use this +** routine to allocate memory for storing their state. +** +** ^The first time the sqlite3_aggregate_context(C,N) routine is called +** for a particular aggregate function, SQLite allocates +** N bytes of memory, zeroes out that memory, and returns a pointer +** to the new memory. ^On second and subsequent calls to +** sqlite3_aggregate_context() for the same aggregate function instance, +** the same buffer is returned. Sqlite3_aggregate_context() is normally +** called once for each invocation of the xStep callback and then one +** last time when the xFinal callback is invoked. ^(When no rows match +** an aggregate query, the xStep() callback of the aggregate function +** implementation is never called and xFinal() is called exactly once. +** In those cases, sqlite3_aggregate_context() might be called for the +** first time from within xFinal().)^ +** +** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer +** when first called if N is less than or equal to zero or if a memory +** allocation error occurs. +** +** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is +** determined by the N parameter on the first successful call. Changing the +** value of N in any subsequent call to sqlite3_aggregate_context() within +** the same aggregate function instance will not resize the memory +** allocation.)^ Within the xFinal callback, it is customary to set +** N=0 in calls to sqlite3_aggregate_context(C,N) so that no +** pointless memory allocations occur. +** +** ^SQLite automatically frees the memory allocated by +** sqlite3_aggregate_context() when the aggregate query concludes. +** +** The first parameter must be a copy of the +** [sqlite3_context | SQL function context] that is the first parameter +** to the xStep or xFinal callback routine that implements the aggregate +** function. +** +** This routine must be called from the same thread in which +** the aggregate SQL function is running. +*/ +SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); + +/* +** CAPI3REF: User Data For Functions +** METHOD: sqlite3_context +** +** ^The sqlite3_user_data() interface returns a copy of +** the pointer that was the pUserData parameter (the 5th parameter) +** of the [sqlite3_create_function()] +** and [sqlite3_create_function16()] routines that originally +** registered the application defined function. +** +** This routine must be called from the same thread in which +** the application-defined function is running. +*/ +SQLITE_API void *sqlite3_user_data(sqlite3_context*); + +/* +** CAPI3REF: Database Connection For Functions +** METHOD: sqlite3_context +** +** ^The sqlite3_context_db_handle() interface returns a copy of +** the pointer to the [database connection] (the 1st parameter) +** of the [sqlite3_create_function()] +** and [sqlite3_create_function16()] routines that originally +** registered the application defined function. +*/ +SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); + +/* +** CAPI3REF: Function Auxiliary Data +** METHOD: sqlite3_context +** +** These functions may be used by (non-aggregate) SQL functions to +** associate auxiliary data with argument values. If the same argument +** value is passed to multiple invocations of the same SQL function during +** query execution, under some circumstances the associated auxiliary data +** might be preserved. An example of where this might be useful is in a +** regular-expression matching function. The compiled version of the regular +** expression can be stored as auxiliary data associated with the pattern string. +** Then as long as the pattern string remains the same, +** the compiled regular expression can be reused on multiple +** invocations of the same function. +** +** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data +** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument +** value to the application-defined function. ^N is zero for the left-most +** function argument. ^If there is no auxiliary data +** associated with the function argument, the sqlite3_get_auxdata(C,N) interface +** returns a NULL pointer. +** +** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the +** N-th argument of the application-defined function. ^Subsequent +** calls to sqlite3_get_auxdata(C,N) return P from the most recent +** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or +** NULL if the auxiliary data has been discarded. +** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, +** SQLite will invoke the destructor function X with parameter P exactly +** once, when the auxiliary data is discarded. +** SQLite is free to discard the auxiliary data at any time, including:
    +**
  • ^(when the corresponding function parameter changes)^, or +**
  • ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the +** SQL statement)^, or +**
  • ^(when sqlite3_set_auxdata() is invoked again on the same +** parameter)^, or +**
  • ^(during the original sqlite3_set_auxdata() call when a memory +** allocation error occurs.)^ +**
  • ^(during the original sqlite3_set_auxdata() call if the function +** is evaluated during query planning instead of during query execution, +** as sometimes happens with [SQLITE_ENABLE_STAT4].)^
+** +** Note the last two bullets in particular. The destructor X in +** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the +** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() +** should be called near the end of the function implementation and the +** function implementation should not make any use of P after +** sqlite3_set_auxdata() has been called. Furthermore, a call to +** sqlite3_get_auxdata() that occurs immediately after a corresponding call +** to sqlite3_set_auxdata() might still return NULL if an out-of-memory +** condition occurred during the sqlite3_set_auxdata() call or if the +** function is being evaluated during query planning rather than during +** query execution. +** +** ^(In practice, auxiliary data is preserved between function calls for +** function parameters that are compile-time constants, including literal +** values and [parameters] and expressions composed from the same.)^ +** +** The value of the N parameter to these interfaces should be non-negative. +** Future enhancements may make use of negative N values to define new +** kinds of function caching behavior. +** +** These routines must be called from the same thread in which +** the SQL function is running. +** +** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()]. +*/ +SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); +SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); + +/* +** CAPI3REF: Database Connection Client Data +** METHOD: sqlite3 +** +** These functions are used to associate one or more named pointers +** with a [database connection]. +** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P +** to be attached to [database connection] D using name N. Subsequent +** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P +** or a NULL pointer if there were no prior calls to +** sqlite3_set_clientdata() with the same values of D and N. +** Names are compared using strcmp() and are thus case sensitive. +** +** If P and X are both non-NULL, then the destructor X is invoked with +** argument P on the first of the following occurrences: +**
    +**
  • An out-of-memory error occurs during the call to +** sqlite3_set_clientdata() which attempts to register pointer P. +**
  • A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made +** with the same D and N parameters. +**
  • The database connection closes. SQLite does not make any guarantees +** about the order in which destructors are called, only that all +** destructors will be called exactly once at some point during the +** database connection closing process. +**
+** +** SQLite does not do anything with client data other than invoke +** destructors on the client data at the appropriate time. The intended +** use for client data is to provide a mechanism for wrapper libraries +** to store additional information about an SQLite database connection. +** +** There is no limit (other than available memory) on the number of different +** client data pointers (with different names) that can be attached to a +** single database connection. However, the implementation is optimized +** for the case of having only one or two different client data names. +** Applications and wrapper libraries are discouraged from using more than +** one client data name each. +** +** There is no way to enumerate the client data pointers +** associated with a database connection. The N parameter can be thought +** of as a secret key such that only code that knows the secret key is able +** to access the associated data. +** +** Security Warning: These interfaces should not be exposed in scripting +** languages or in other circumstances where it might be possible for an +** attacker to invoke them. Any agent that can invoke these interfaces +** can probably also take control of the process. +** +** Database connection client data is only available for SQLite +** version 3.44.0 ([dateof:3.44.0]) and later. +** +** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()]. +*/ +SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*); +SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*)); + +/* +** CAPI3REF: Constants Defining Special Destructor Behavior +** +** These are special values for the destructor that is passed in as the +** final argument to routines like [sqlite3_result_blob()]. ^If the destructor +** argument is SQLITE_STATIC, it means that the content pointer is constant +** and will never change. It does not need to be destroyed. ^The +** SQLITE_TRANSIENT value means that the content will likely change in +** the near future and that SQLite should make its own private copy of +** the content before returning. +** +** The typedef is necessary to work around problems in certain +** C++ compilers. +*/ +typedef void (*sqlite3_destructor_type)(void*); +#define SQLITE_STATIC ((sqlite3_destructor_type)0) +#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) + +/* +** CAPI3REF: Setting The Result Of An SQL Function +** METHOD: sqlite3_context +** +** These routines are used by the xFunc or xFinal callbacks that +** implement SQL functions and aggregates. See +** [sqlite3_create_function()] and [sqlite3_create_function16()] +** for additional information. +** +** These functions work very much like the [parameter binding] family of +** functions used to bind values to host parameters in prepared statements. +** Refer to the [SQL parameter] documentation for additional information. +** +** ^The sqlite3_result_blob() interface sets the result from +** an application-defined function to be the BLOB whose content is pointed +** to by the second parameter and which is N bytes long where N is the +** third parameter. +** +** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N) +** interfaces set the result of the application-defined function to be +** a BLOB containing all zero bytes and N bytes in size. +** +** ^The sqlite3_result_double() interface sets the result from +** an application-defined function to be a floating point value specified +** by its 2nd argument. +** +** ^The sqlite3_result_error() and sqlite3_result_error16() functions +** cause the implemented SQL function to throw an exception. +** ^SQLite uses the string pointed to by the +** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() +** as the text of an error message. ^SQLite interprets the error +** message string from sqlite3_result_error() as UTF-8. ^SQLite +** interprets the string from sqlite3_result_error16() as UTF-16 using +** the same [byte-order determination rules] as [sqlite3_bind_text16()]. +** ^If the third parameter to sqlite3_result_error() +** or sqlite3_result_error16() is negative then SQLite takes as the error +** message all text up through the first zero character. +** ^If the third parameter to sqlite3_result_error() or +** sqlite3_result_error16() is non-negative then SQLite takes that many +** bytes (not characters) from the 2nd parameter as the error message. +** ^The sqlite3_result_error() and sqlite3_result_error16() +** routines make a private copy of the error message text before +** they return. Hence, the calling function can deallocate or +** modify the text after they return without harm. +** ^The sqlite3_result_error_code() function changes the error code +** returned by SQLite as a result of an error in a function. ^By default, +** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() +** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. +** +** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an +** error indicating that a string or BLOB is too long to represent. +** +** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an +** error indicating that a memory allocation failed. +** +** ^The sqlite3_result_int() interface sets the return value +** of the application-defined function to be the 32-bit signed integer +** value given in the 2nd argument. +** ^The sqlite3_result_int64() interface sets the return value +** of the application-defined function to be the 64-bit signed integer +** value given in the 2nd argument. +** +** ^The sqlite3_result_null() interface sets the return value +** of the application-defined function to be NULL. +** +** ^The sqlite3_result_text(), sqlite3_result_text16(), +** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces +** set the return value of the application-defined function to be +** a text string which is represented as UTF-8, UTF-16 native byte order, +** UTF-16 little endian, or UTF-16 big endian, respectively. +** ^The sqlite3_result_text64() interface sets the return value of an +** application-defined function to be a text string in an encoding +** specified by the fifth (and last) parameter, which must be one +** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]. +** ^SQLite takes the text result from the application from +** the 2nd parameter of the sqlite3_result_text* interfaces. +** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces +** other than sqlite3_result_text64() is negative, then SQLite computes +** the string length itself by searching the 2nd parameter for the first +** zero character. +** ^If the 3rd parameter to the sqlite3_result_text* interfaces +** is non-negative, then as many bytes (not characters) of the text +** pointed to by the 2nd parameter are taken as the application-defined +** function result. If the 3rd parameter is non-negative, then it +** must be the byte offset into the string where the NUL terminator would +** appear if the string were NUL terminated. If any NUL characters occur +** in the string at a byte offset that is less than the value of the 3rd +** parameter, then the resulting string will contain embedded NULs and the +** result of expressions operating on strings with embedded NULs is undefined. +** ^If the 4th parameter to the sqlite3_result_text* interfaces +** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that +** function as the destructor on the text or BLOB result when it has +** finished using that result. +** ^If the 4th parameter to the sqlite3_result_text* interfaces or to +** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite +** assumes that the text or BLOB result is in constant space and does not +** copy the content of the parameter nor call a destructor on the content +** when it has finished using that result. +** ^If the 4th parameter to the sqlite3_result_text* interfaces +** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT +** then SQLite makes a copy of the result into space obtained +** from [sqlite3_malloc()] before it returns. +** +** ^For the sqlite3_result_text16(), sqlite3_result_text16le(), and +** sqlite3_result_text16be() routines, and for sqlite3_result_text64() +** when the encoding is not UTF8, if the input UTF16 begins with a +** byte-order mark (BOM, U+FEFF) then the BOM is removed from the +** string and the rest of the string is interpreted according to the +** byte-order specified by the BOM. ^The byte-order specified by +** the BOM at the beginning of the text overrides the byte-order +** specified by the interface procedure. ^So, for example, if +** sqlite3_result_text16le() is invoked with text that begins +** with bytes 0xfe, 0xff (a big-endian byte-order mark) then the +** first two bytes of input are skipped and the remaining input +** is interpreted as UTF16BE text. +** +** ^For UTF16 input text to the sqlite3_result_text16(), +** sqlite3_result_text16be(), sqlite3_result_text16le(), and +** sqlite3_result_text64() routines, if the text contains invalid +** UTF16 characters, the invalid characters might be converted +** into the unicode replacement character, U+FFFD. +** +** ^The sqlite3_result_value() interface sets the result of +** the application-defined function to be a copy of the +** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The +** sqlite3_result_value() interface makes a copy of the [sqlite3_value] +** so that the [sqlite3_value] specified in the parameter may change or +** be deallocated after sqlite3_result_value() returns without harm. +** ^A [protected sqlite3_value] object may always be used where an +** [unprotected sqlite3_value] object is required, so either +** kind of [sqlite3_value] object can be used with this interface. +** +** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an +** SQL NULL value, just like [sqlite3_result_null(C)], except that it +** also associates the host-language pointer P or type T with that +** NULL value such that the pointer can be retrieved within an +** [application-defined SQL function] using [sqlite3_value_pointer()]. +** ^If the D parameter is not NULL, then it is a pointer to a destructor +** for the P parameter. ^SQLite invokes D with P as its only argument +** when SQLite is finished with P. The T parameter should be a static +** string and preferably a string literal. The sqlite3_result_pointer() +** routine is part of the [pointer passing interface] added for SQLite 3.20.0. +** +** If these routines are called from within a different thread +** than the one containing the application-defined function that received +** the [sqlite3_context] pointer, the results are undefined. +*/ +SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); +SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*, + sqlite3_uint64,void(*)(void*)); +SQLITE_API void sqlite3_result_double(sqlite3_context*, double); +SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); +SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); +SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); +SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); +SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); +SQLITE_API void sqlite3_result_int(sqlite3_context*, int); +SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); +SQLITE_API void sqlite3_result_null(sqlite3_context*); +SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); +SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64, + void(*)(void*), unsigned char encoding); +SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); +SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); +SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); +SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); +SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*)); +SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); +SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); + + +/* +** CAPI3REF: Setting The Subtype Of An SQL Function +** METHOD: sqlite3_context +** +** The sqlite3_result_subtype(C,T) function causes the subtype of +** the result from the [application-defined SQL function] with +** [sqlite3_context] C to be the value T. Only the lower 8 bits +** of the subtype T are preserved in current versions of SQLite; +** higher order bits are discarded. +** The number of subtype bytes preserved by SQLite might increase +** in future releases of SQLite. +** +** Every [application-defined SQL function] that invokes this interface +** should include the [SQLITE_RESULT_SUBTYPE] property in its +** text encoding argument when the SQL function is +** [sqlite3_create_function|registered]. If the [SQLITE_RESULT_SUBTYPE] +** property is omitted from the function that invokes sqlite3_result_subtype(), +** then in some cases the sqlite3_result_subtype() might fail to set +** the result subtype. +** +** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any +** SQL function that invokes the sqlite3_result_subtype() interface +** and that does not have the SQLITE_RESULT_SUBTYPE property will raise +** an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1 +** by default. +*/ +SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); + +/* +** CAPI3REF: Define New Collating Sequences +** METHOD: sqlite3 +** +** ^These functions add, remove, or modify a [collation] associated +** with the [database connection] specified as the first argument. +** +** ^The name of the collation is a UTF-8 string +** for sqlite3_create_collation() and sqlite3_create_collation_v2() +** and a UTF-16 string in native byte order for sqlite3_create_collation16(). +** ^Collation names that compare equal according to [sqlite3_strnicmp()] are +** considered to be the same name. +** +** ^(The third argument (eTextRep) must be one of the constants: +**
    +**
  • [SQLITE_UTF8], +**
  • [SQLITE_UTF16LE], +**
  • [SQLITE_UTF16BE], +**
  • [SQLITE_UTF16], or +**
  • [SQLITE_UTF16_ALIGNED]. +**
)^ +** ^The eTextRep argument determines the encoding of strings passed +** to the collating function callback, xCompare. +** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep +** force strings to be UTF16 with native byte order. +** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin +** on an even byte address. +** +** ^The fourth argument, pArg, is an application data pointer that is passed +** through as the first argument to the collating function callback. +** +** ^The fifth argument, xCompare, is a pointer to the collating function. +** ^Multiple collating functions can be registered using the same name but +** with different eTextRep parameters and SQLite will use whichever +** function requires the least amount of data transformation. +** ^If the xCompare argument is NULL then the collating function is +** deleted. ^When all collating functions having the same name are deleted, +** that collation is no longer usable. +** +** ^The collating function callback is invoked with a copy of the pArg +** application data pointer and with two strings in the encoding specified +** by the eTextRep argument. The two integer parameters to the collating +** function callback are the length of the two strings, in bytes. The collating +** function must return an integer that is negative, zero, or positive +** if the first string is less than, equal to, or greater than the second, +** respectively. A collating function must always return the same answer +** given the same inputs. If two or more collating functions are registered +** to the same collation name (using different eTextRep values) then all +** must give an equivalent answer when invoked with equivalent strings. +** The collating function must obey the following properties for all +** strings A, B, and C: +** +**
    +**
  1. If A==B then B==A. +**
  2. If A==B and B==C then A==C. +**
  3. If A<B THEN B>A. +**
  4. If A<B and B<C then A<C. +**
+** +** If a collating function fails any of the above constraints and that +** collating function is registered and used, then the behavior of SQLite +** is undefined. +** +** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() +** with the addition that the xDestroy callback is invoked on pArg when +** the collating function is deleted. +** ^Collating functions are deleted when they are overridden by later +** calls to the collation creation functions or when the +** [database connection] is closed using [sqlite3_close()]. +** +** ^The xDestroy callback is not called if the +** sqlite3_create_collation_v2() function fails. Applications that invoke +** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should +** check the return code and dispose of the application data pointer +** themselves rather than expecting SQLite to deal with it for them. +** This is different from every other SQLite interface. The inconsistency +** is unfortunate but cannot be changed without breaking backwards +** compatibility. +** +** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. +*/ +SQLITE_API int sqlite3_create_collation( + sqlite3*, + const char *zName, + int eTextRep, + void *pArg, + int(*xCompare)(void*,int,const void*,int,const void*) +); +SQLITE_API int sqlite3_create_collation_v2( + sqlite3*, + const char *zName, + int eTextRep, + void *pArg, + int(*xCompare)(void*,int,const void*,int,const void*), + void(*xDestroy)(void*) +); +SQLITE_API int sqlite3_create_collation16( + sqlite3*, + const void *zName, + int eTextRep, + void *pArg, + int(*xCompare)(void*,int,const void*,int,const void*) +); + +/* +** CAPI3REF: Collation Needed Callbacks +** METHOD: sqlite3 +** +** ^To avoid having to register all collation sequences before a database +** can be used, a single callback function may be registered with the +** [database connection] to be invoked whenever an undefined collation +** sequence is required. +** +** ^If the function is registered using the sqlite3_collation_needed() API, +** then it is passed the names of undefined collation sequences as strings +** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, +** the names are passed as UTF-16 in machine native byte order. +** ^A call to either function replaces the existing collation-needed callback. +** +** ^(When the callback is invoked, the first argument passed is a copy +** of the second argument to sqlite3_collation_needed() or +** sqlite3_collation_needed16(). The second argument is the database +** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], +** or [SQLITE_UTF16LE], indicating the most desirable form of the collation +** sequence function required. The fourth parameter is the name of the +** required collation sequence.)^ +** +** The callback function should register the desired collation using +** [sqlite3_create_collation()], [sqlite3_create_collation16()], or +** [sqlite3_create_collation_v2()]. +*/ +SQLITE_API int sqlite3_collation_needed( + sqlite3*, + void*, + void(*)(void*,sqlite3*,int eTextRep,const char*) +); +SQLITE_API int sqlite3_collation_needed16( + sqlite3*, + void*, + void(*)(void*,sqlite3*,int eTextRep,const void*) +); + +#ifdef SQLITE_ENABLE_CEROD +/* +** Specify the activation key for a CEROD database. Unless +** activated, none of the CEROD routines will work. +*/ +SQLITE_API void sqlite3_activate_cerod( + const char *zPassPhrase /* Activation phrase */ +); +#endif + +/* +** CAPI3REF: Suspend Execution For A Short Time +** +** The sqlite3_sleep() function causes the current thread to suspend execution +** for at least a number of milliseconds specified in its parameter. +** +** If the operating system does not support sleep requests with +** millisecond time resolution, then the time will be rounded up to +** the nearest second. The number of milliseconds of sleep actually +** requested from the operating system is returned. +** +** ^SQLite implements this interface by calling the xSleep() +** method of the default [sqlite3_vfs] object. If the xSleep() method +** of the default VFS is not implemented correctly, or not implemented at +** all, then the behavior of sqlite3_sleep() may deviate from the description +** in the previous paragraphs. +** +** If a negative argument is passed to sqlite3_sleep() the results vary by +** VFS and operating system. Some system treat a negative argument as an +** instruction to sleep forever. Others understand it to mean do not sleep +** at all. ^In SQLite version 3.42.0 and later, a negative +** argument passed into sqlite3_sleep() is changed to zero before it is relayed +** down into the xSleep method of the VFS. +*/ +SQLITE_API int sqlite3_sleep(int); + +/* +** CAPI3REF: Name Of The Folder Holding Temporary Files +** +** ^(If this global variable is made to point to a string which is +** the name of a folder (a.k.a. directory), then all temporary files +** created by SQLite when using a built-in [sqlite3_vfs | VFS] +** will be placed in that directory.)^ ^If this variable +** is a NULL pointer, then SQLite performs a search for an appropriate +** temporary file directory. +** +** Applications are strongly discouraged from using this global variable. +** It is required to set a temporary folder on Windows Runtime (WinRT). +** But for all other platforms, it is highly recommended that applications +** neither read nor write this variable. This global variable is a relic +** that exists for backwards compatibility of legacy applications and should +** be avoided in new projects. +** +** It is not safe to read or modify this variable in more than one +** thread at a time. It is not safe to read or modify this variable +** if a [database connection] is being used at the same time in a separate +** thread. +** It is intended that this variable be set once +** as part of process initialization and before any SQLite interface +** routines have been called and that this variable remain unchanged +** thereafter. +** +** ^The [temp_store_directory pragma] may modify this variable and cause +** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, +** the [temp_store_directory pragma] always assumes that any string +** that this variable points to is held in memory obtained from +** [sqlite3_malloc] and the pragma may attempt to free that memory +** using [sqlite3_free]. +** Hence, if this variable is modified directly, either it should be +** made NULL or made to point to memory obtained from [sqlite3_malloc] +** or else the use of the [temp_store_directory pragma] should be avoided. +** Except when requested by the [temp_store_directory pragma], SQLite +** does not free the memory that sqlite3_temp_directory points to. If +** the application wants that memory to be freed, it must do +** so itself, taking care to only do so after all [database connection] +** objects have been destroyed. +** +** Note to Windows Runtime users: The temporary directory must be set +** prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various +** features that require the use of temporary files may fail. Here is an +** example of how to do this using C++ with the Windows Runtime: +** +**
+** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
+**       TemporaryFolder->Path->Data();
+** char zPathBuf[MAX_PATH + 1];
+** memset(zPathBuf, 0, sizeof(zPathBuf));
+** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
+**       NULL, NULL);
+** sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
+** 
+*/ +SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; + +/* +** CAPI3REF: Name Of The Folder Holding Database Files +** +** ^(If this global variable is made to point to a string which is +** the name of a folder (a.k.a. directory), then all database files +** specified with a relative pathname and created or accessed by +** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed +** to be relative to that directory.)^ ^If this variable is a NULL +** pointer, then SQLite assumes that all database files specified +** with a relative pathname are relative to the current directory +** for the process. Only the windows VFS makes use of this global +** variable; it is ignored by the unix VFS. +** +** Changing the value of this variable while a database connection is +** open can result in a corrupt database. +** +** It is not safe to read or modify this variable in more than one +** thread at a time. It is not safe to read or modify this variable +** if a [database connection] is being used at the same time in a separate +** thread. +** It is intended that this variable be set once +** as part of process initialization and before any SQLite interface +** routines have been called and that this variable remain unchanged +** thereafter. +** +** ^The [data_store_directory pragma] may modify this variable and cause +** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, +** the [data_store_directory pragma] always assumes that any string +** that this variable points to is held in memory obtained from +** [sqlite3_malloc] and the pragma may attempt to free that memory +** using [sqlite3_free]. +** Hence, if this variable is modified directly, either it should be +** made NULL or made to point to memory obtained from [sqlite3_malloc] +** or else the use of the [data_store_directory pragma] should be avoided. +*/ +SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory; + +/* +** CAPI3REF: Win32 Specific Interface +** +** These interfaces are available only on Windows. The +** [sqlite3_win32_set_directory] interface is used to set the value associated +** with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to +** zValue, depending on the value of the type parameter. The zValue parameter +** should be NULL to cause the previous value to be freed via [sqlite3_free]; +** a non-NULL value will be copied into memory obtained from [sqlite3_malloc] +** prior to being used. The [sqlite3_win32_set_directory] interface returns +** [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported, +** or [SQLITE_NOMEM] if memory could not be allocated. The value of the +** [sqlite3_data_directory] variable is intended to act as a replacement for +** the current directory on the sub-platforms of Win32 where that concept is +** not present, e.g. WinRT and UWP. The [sqlite3_win32_set_directory8] and +** [sqlite3_win32_set_directory16] interfaces behave exactly the same as the +** sqlite3_win32_set_directory interface except the string parameter must be +** UTF-8 or UTF-16, respectively. +*/ +SQLITE_API int sqlite3_win32_set_directory( + unsigned long type, /* Identifier for directory being set or reset */ + void *zValue /* New value for directory being set or reset */ +); +SQLITE_API int sqlite3_win32_set_directory8(unsigned long type, const char *zValue); +SQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zValue); + +/* +** CAPI3REF: Win32 Directory Types +** +** These macros are only available on Windows. They define the allowed values +** for the type argument to the [sqlite3_win32_set_directory] interface. +*/ +#define SQLITE_WIN32_DATA_DIRECTORY_TYPE 1 +#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE 2 + +/* +** CAPI3REF: Test For Auto-Commit Mode +** KEYWORDS: {autocommit mode} +** METHOD: sqlite3 +** +** ^The sqlite3_get_autocommit() interface returns non-zero or +** zero if the given database connection is or is not in autocommit mode, +** respectively. ^Autocommit mode is on by default. +** ^Autocommit mode is disabled by a [BEGIN] statement. +** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. +** +** If certain kinds of errors occur on a statement within a multi-statement +** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], +** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the +** transaction might be rolled back automatically. The only way to +** find out whether SQLite automatically rolled back the transaction after +** an error is to use this function. +** +** If another thread changes the autocommit status of the database +** connection while this routine is running, then the return value +** is undefined. +*/ +SQLITE_API int sqlite3_get_autocommit(sqlite3*); + +/* +** CAPI3REF: Find The Database Handle Of A Prepared Statement +** METHOD: sqlite3_stmt +** +** ^The sqlite3_db_handle interface returns the [database connection] handle +** to which a [prepared statement] belongs. ^The [database connection] +** returned by sqlite3_db_handle is the same [database connection] +** that was the first argument +** to the [sqlite3_prepare_v2()] call (or its variants) that was used to +** create the statement in the first place. +*/ +SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); + +/* +** CAPI3REF: Return The Schema Name For A Database Connection +** METHOD: sqlite3 +** +** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name +** for the N-th database on database connection D, or a NULL pointer if N is +** out of range. An N value of 0 means the main database file. An N of 1 is +** the "temp" schema. Larger values of N correspond to various ATTACH-ed +** databases. +** +** Space to hold the string that is returned by sqlite3_db_name() is managed +** by SQLite itself. The string might be deallocated by any operation that +** changes the schema, including [ATTACH] or [DETACH] or calls to +** [sqlite3_serialize()] or [sqlite3_deserialize()], even operations that +** occur on a different thread. Applications that need to +** remember the string long-term should make their own copy. Applications that +** are accessing the same database connection simultaneously on multiple +** threads should mutex-protect calls to this API and should make their own +** private copy of the result prior to releasing the mutex. +*/ +SQLITE_API const char *sqlite3_db_name(sqlite3 *db, int N); + +/* +** CAPI3REF: Return The Filename For A Database Connection +** METHOD: sqlite3 +** +** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename +** associated with database N of connection D. +** ^If there is no attached database N on the database +** connection D, or if database N is a temporary or in-memory database, then +** this function will return either a NULL pointer or an empty string. +** +** ^The string value returned by this routine is owned and managed by +** the database connection. ^The value will be valid until the database N +** is [DETACH]-ed or until the database connection closes. +** +** ^The filename returned by this function is the output of the +** xFullPathname method of the [VFS]. ^In other words, the filename +** will be an absolute pathname, even if the filename used +** to open the database originally was a URI or relative pathname. +** +** If the filename pointer returned by this routine is not NULL, then it +** can be used as the filename input parameter to these routines: +**
    +**
  • [sqlite3_uri_parameter()] +**
  • [sqlite3_uri_boolean()] +**
  • [sqlite3_uri_int64()] +**
  • [sqlite3_filename_database()] +**
  • [sqlite3_filename_journal()] +**
  • [sqlite3_filename_wal()] +**
+*/ +SQLITE_API sqlite3_filename sqlite3_db_filename(sqlite3 *db, const char *zDbName); + +/* +** CAPI3REF: Determine if a database is read-only +** METHOD: sqlite3 +** +** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N +** of connection D is read-only, 0 if it is read/write, or -1 if N is not +** the name of a database on connection D. +*/ +SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); + +/* +** CAPI3REF: Determine the transaction state of a database +** METHOD: sqlite3 +** +** ^The sqlite3_txn_state(D,S) interface returns the current +** [transaction state] of schema S in database connection D. ^If S is NULL, +** then the highest transaction state of any schema on database connection D +** is returned. Transaction states are (in order of lowest to highest): +**
    +**
  1. SQLITE_TXN_NONE +**
  2. SQLITE_TXN_READ +**
  3. SQLITE_TXN_WRITE +**
+** ^If the S argument to sqlite3_txn_state(D,S) is not the name of +** a valid schema, then -1 is returned. +*/ +SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema); + +/* +** CAPI3REF: Allowed return values from sqlite3_txn_state() +** KEYWORDS: {transaction state} +** +** These constants define the current transaction state of a database file. +** ^The [sqlite3_txn_state(D,S)] interface returns one of these +** constants in order to describe the transaction state of schema S +** in [database connection] D. +** +**
+** [[SQLITE_TXN_NONE]]
SQLITE_TXN_NONE
+**
The SQLITE_TXN_NONE state means that no transaction is currently +** pending.
+** +** [[SQLITE_TXN_READ]]
SQLITE_TXN_READ
+**
The SQLITE_TXN_READ state means that the database is currently +** in a read transaction. Content has been read from the database file +** but nothing in the database file has changed. The transaction state +** will be advanced to SQLITE_TXN_WRITE if any changes occur and there are +** no other conflicting concurrent write transactions. The transaction +** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or +** [COMMIT].
+** +** [[SQLITE_TXN_WRITE]]
SQLITE_TXN_WRITE
+**
The SQLITE_TXN_WRITE state means that the database is currently +** in a write transaction. Content has been written to the database file +** but has not yet committed. The transaction state will change to +** SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].
+*/ +#define SQLITE_TXN_NONE 0 +#define SQLITE_TXN_READ 1 +#define SQLITE_TXN_WRITE 2 + +/* +** CAPI3REF: Find the next prepared statement +** METHOD: sqlite3 +** +** ^This interface returns a pointer to the next [prepared statement] after +** pStmt associated with the [database connection] pDb. ^If pStmt is NULL +** then this interface returns a pointer to the first prepared statement +** associated with the database connection pDb. ^If no prepared statement +** satisfies the conditions of this routine, it returns NULL. +** +** The [database connection] pointer D in a call to +** [sqlite3_next_stmt(D,S)] must refer to an open database +** connection and in particular must not be a NULL pointer. +*/ +SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Commit And Rollback Notification Callbacks +** METHOD: sqlite3 +** +** ^The sqlite3_commit_hook() interface registers a callback +** function to be invoked whenever a transaction is [COMMIT | committed]. +** ^Any callback set by a previous call to sqlite3_commit_hook() +** for the same database connection is overridden. +** ^The sqlite3_rollback_hook() interface registers a callback +** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. +** ^Any callback set by a previous call to sqlite3_rollback_hook() +** for the same database connection is overridden. +** ^The pArg argument is passed through to the callback. +** ^If the callback on a commit hook function returns non-zero, +** then the commit is converted into a rollback. +** +** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions +** return the P argument from the previous call of the same function +** on the same [database connection] D, or NULL for +** the first call for each function on D. +** +** The commit and rollback hook callbacks are not reentrant. +** The callback implementation must not do anything that will modify +** the database connection that invoked the callback. Any actions +** to modify the database connection must be deferred until after the +** completion of the [sqlite3_step()] call that triggered the commit +** or rollback hook in the first place. +** Note that running any other SQL statements, including SELECT statements, +** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify +** the database connections for the meaning of "modify" in this paragraph. +** +** ^Registering a NULL function disables the callback. +** +** ^When the commit hook callback routine returns zero, the [COMMIT] +** operation is allowed to continue normally. ^If the commit hook +** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. +** ^The rollback hook is invoked on a rollback that results from a commit +** hook returning non-zero, just as it would be with any other rollback. +** +** ^For the purposes of this API, a transaction is said to have been +** rolled back if an explicit "ROLLBACK" statement is executed, or +** an error or constraint causes an implicit rollback to occur. +** ^The rollback callback is not invoked if a transaction is +** automatically rolled back because the database connection is closed. +** +** See also the [sqlite3_update_hook()] interface. +*/ +SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); +SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); + +/* +** CAPI3REF: Autovacuum Compaction Amount Callback +** METHOD: sqlite3 +** +** ^The sqlite3_autovacuum_pages(D,C,P,X) interface registers a callback +** function C that is invoked prior to each autovacuum of the database +** file. ^The callback is passed a copy of the generic data pointer (P), +** the schema-name of the attached database that is being autovacuumed, +** the size of the database file in pages, the number of free pages, +** and the number of bytes per page, respectively. The callback should +** return the number of free pages that should be removed by the +** autovacuum. ^If the callback returns zero, then no autovacuum happens. +** ^If the value returned is greater than or equal to the number of +** free pages, then a complete autovacuum happens. +** +**

^If there are multiple ATTACH-ed database files that are being +** modified as part of a transaction commit, then the autovacuum pages +** callback is invoked separately for each file. +** +**

The callback is not reentrant. The callback function should +** not attempt to invoke any other SQLite interface. If it does, bad +** things may happen, including segmentation faults and corrupt database +** files. The callback function should be a simple function that +** does some arithmetic on its input parameters and returns a result. +** +** ^The X parameter to sqlite3_autovacuum_pages(D,C,P,X) is an optional +** destructor for the P parameter. ^If X is not NULL, then X(P) is +** invoked whenever the database connection closes or when the callback +** is overwritten by another invocation of sqlite3_autovacuum_pages(). +** +**

^There is only one autovacuum pages callback per database connection. +** ^Each call to the sqlite3_autovacuum_pages() interface overrides all +** previous invocations for that database connection. ^If the callback +** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, +** then the autovacuum steps callback is canceled. The return value +** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might +** be some other error code if something goes wrong. The current +** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other +** return codes might be added in future releases. +** +**

If no autovacuum pages callback is specified (the usual case) or +** a NULL pointer is provided for the callback, +** then the default behavior is to vacuum all free pages. So, in other +** words, the default behavior is the same as if the callback function +** were something like this: +** +**

+**     unsigned int demonstration_autovac_pages_callback(
+**       void *pClientData,
+**       const char *zSchema,
+**       unsigned int nDbPage,
+**       unsigned int nFreePage,
+**       unsigned int nBytePerPage
+**     ){
+**       return nFreePage;
+**     }
+** 
+*/ +SQLITE_API int sqlite3_autovacuum_pages( + sqlite3 *db, + unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), + void*, + void(*)(void*) +); + + +/* +** CAPI3REF: Data Change Notification Callbacks +** METHOD: sqlite3 +** +** ^The sqlite3_update_hook() interface registers a callback function +** with the [database connection] identified by the first argument +** to be invoked whenever a row is updated, inserted or deleted in +** a [rowid table]. +** ^Any callback set by a previous call to this function +** for the same database connection is overridden. +** +** ^The second argument is a pointer to the function to invoke when a +** row is updated, inserted or deleted in a rowid table. +** ^The update hook is disabled by invoking sqlite3_update_hook() +** with a NULL pointer as the second parameter. +** ^The first argument to the callback is a copy of the third argument +** to sqlite3_update_hook(). +** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], +** or [SQLITE_UPDATE], depending on the operation that caused the callback +** to be invoked. +** ^The third and fourth arguments to the callback contain pointers to the +** database and table name containing the affected row. +** ^The final callback parameter is the [rowid] of the row. +** ^In the case of an update, this is the [rowid] after the update takes place. +** +** ^(The update hook is not invoked when internal system tables are +** modified (i.e. sqlite_sequence).)^ +** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified. +** +** ^In the current implementation, the update hook +** is not invoked when conflicting rows are deleted because of an +** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook +** invoked when rows are deleted using the [truncate optimization]. +** The exceptions defined in this paragraph might change in a future +** release of SQLite. +** +** Whether the update hook is invoked before or after the +** corresponding change is currently unspecified and may differ +** depending on the type of change. Do not rely on the order of the +** hook call with regards to the final result of the operation which +** triggers the hook. +** +** The update hook implementation must not do anything that will modify +** the database connection that invoked the update hook. Any actions +** to modify the database connection must be deferred until after the +** completion of the [sqlite3_step()] call that triggered the update hook. +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their +** database connections for the meaning of "modify" in this paragraph. +** +** ^The sqlite3_update_hook(D,C,P) function +** returns the P argument from the previous call +** on the same [database connection] D, or NULL for +** the first call on D. +** +** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()], +** and [sqlite3_preupdate_hook()] interfaces. +*/ +SQLITE_API void *sqlite3_update_hook( + sqlite3*, + void(*)(void *,int ,char const *,char const *,sqlite3_int64), + void* +); + +/* +** CAPI3REF: Enable Or Disable Shared Pager Cache +** +** ^(This routine enables or disables the sharing of the database cache +** and schema data structures between [database connection | connections] +** to the same database. Sharing is enabled if the argument is true +** and disabled if the argument is false.)^ +** +** This interface is omitted if SQLite is compiled with +** [-DSQLITE_OMIT_SHARED_CACHE]. The [-DSQLITE_OMIT_SHARED_CACHE] +** compile-time option is recommended because the +** [use of shared cache mode is discouraged]. +** +** ^Cache sharing is enabled and disabled for an entire process. +** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). +** In prior versions of SQLite, +** sharing was enabled or disabled for each thread separately. +** +** ^(The cache sharing mode set by this interface effects all subsequent +** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. +** Existing database connections continue to use the sharing mode +** that was in effect at the time they were opened.)^ +** +** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled +** successfully. An [error code] is returned otherwise.)^ +** +** ^Shared cache is disabled by default. It is recommended that it stay +** that way. In other words, do not use this routine. This interface +** continues to be provided for historical compatibility, but its use is +** discouraged. Any use of shared cache is discouraged. If shared cache +** must be used, it is recommended that shared cache only be enabled for +** individual database connections using the [sqlite3_open_v2()] interface +** with the [SQLITE_OPEN_SHAREDCACHE] flag. +** +** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 +** and will always return SQLITE_MISUSE. On those systems, +** shared cache mode should be enabled per-database connection via +** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE]. +** +** This interface is threadsafe on processors where writing a +** 32-bit integer is atomic. +** +** See Also: [SQLite Shared-Cache Mode] +*/ +SQLITE_API int sqlite3_enable_shared_cache(int); + +/* +** CAPI3REF: Attempt To Free Heap Memory +** +** ^The sqlite3_release_memory() interface attempts to free N bytes +** of heap memory by deallocating non-essential memory allocations +** held by the database library. Memory used to cache database +** pages to improve performance is an example of non-essential memory. +** ^sqlite3_release_memory() returns the number of bytes actually freed, +** which might be more or less than the amount requested. +** ^The sqlite3_release_memory() routine is a no-op returning zero +** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. +** +** See also: [sqlite3_db_release_memory()] +*/ +SQLITE_API int sqlite3_release_memory(int); + +/* +** CAPI3REF: Free Memory Used By A Database Connection +** METHOD: sqlite3 +** +** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap +** memory as possible from database connection D. Unlike the +** [sqlite3_release_memory()] interface, this interface is in effect even +** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is +** omitted. +** +** See also: [sqlite3_release_memory()] +*/ +SQLITE_API int sqlite3_db_release_memory(sqlite3*); + +/* +** CAPI3REF: Impose A Limit On Heap Size +** +** These interfaces impose limits on the amount of heap memory that will be +** used by all database connections within a single process. +** +** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the +** soft limit on the amount of heap memory that may be allocated by SQLite. +** ^SQLite strives to keep heap memory utilization below the soft heap +** limit by reducing the number of pages held in the page cache +** as heap memory usages approaches the limit. +** ^The soft heap limit is "soft" because even though SQLite strives to stay +** below the limit, it will exceed the limit rather than generate +** an [SQLITE_NOMEM] error. In other words, the soft heap limit +** is advisory only. +** +** ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of +** N bytes on the amount of memory that will be allocated. ^The +** sqlite3_hard_heap_limit64(N) interface is similar to +** sqlite3_soft_heap_limit64(N) except that memory allocations will fail +** when the hard heap limit is reached. +** +** ^The return value from both sqlite3_soft_heap_limit64() and +** sqlite3_hard_heap_limit64() is the size of +** the heap limit prior to the call, or negative in the case of an +** error. ^If the argument N is negative +** then no change is made to the heap limit. Hence, the current +** size of heap limits can be determined by invoking +** sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1). +** +** ^Setting the heap limits to zero disables the heap limiter mechanism. +** +** ^The soft heap limit may not be greater than the hard heap limit. +** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N) +** is invoked with a value of N that is greater than the hard heap limit, +** the soft heap limit is set to the value of the hard heap limit. +** ^The soft heap limit is automatically enabled whenever the hard heap +** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and +** the soft heap limit is outside the range of 1..N, then the soft heap +** limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the +** hard heap limit is enabled makes the soft heap limit equal to the +** hard heap limit. +** +** The memory allocation limits can also be adjusted using +** [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit]. +** +** ^(The heap limits are not enforced in the current implementation +** if one or more of following conditions are true: +** +**
    +**
  • The limit value is set to zero. +**
  • Memory accounting is disabled using a combination of the +** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and +** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. +**
  • An alternative page cache implementation is specified using +** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...). +**
  • The page cache allocates from its own memory pool supplied +** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than +** from the heap. +**
)^ +** +** The circumstances under which SQLite will enforce the heap limits may +** change in future releases of SQLite. +*/ +SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); +SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N); + +/* +** CAPI3REF: Deprecated Soft Heap Limit Interface +** DEPRECATED +** +** This is a deprecated version of the [sqlite3_soft_heap_limit64()] +** interface. This routine is provided for historical compatibility +** only. All new applications should use the +** [sqlite3_soft_heap_limit64()] interface rather than this one. +*/ +SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); + + +/* +** CAPI3REF: Extract Metadata About A Column Of A Table +** METHOD: sqlite3 +** +** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns +** information about column C of table T in database D +** on [database connection] X.)^ ^The sqlite3_table_column_metadata() +** interface returns SQLITE_OK and fills in the non-NULL pointers in +** the final five arguments with appropriate values if the specified +** column exists. ^The sqlite3_table_column_metadata() interface returns +** SQLITE_ERROR if the specified column does not exist. +** ^If the column-name parameter to sqlite3_table_column_metadata() is a +** NULL pointer, then this routine simply checks for the existence of the +** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it +** does not. If the table name parameter T in a call to +** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is +** undefined behavior. +** +** ^The column is identified by the second, third and fourth parameters to +** this function. ^(The second parameter is either the name of the database +** (i.e. "main", "temp", or an attached database) containing the specified +** table or NULL.)^ ^If it is NULL, then all attached databases are searched +** for the table using the same algorithm used by the database engine to +** resolve unqualified table references. +** +** ^The third and fourth parameters to this function are the table and column +** name of the desired column, respectively. +** +** ^Metadata is returned by writing to the memory locations passed as the 5th +** and subsequent parameters to this function. ^Any of these arguments may be +** NULL, in which case the corresponding element of metadata is omitted. +** +** ^(
+** +**
Parameter Output
Type
Description +** +**
5th const char* Data type +**
6th const char* Name of default collation sequence +**
7th int True if column has a NOT NULL constraint +**
8th int True if column is part of the PRIMARY KEY +**
9th int True if column is [AUTOINCREMENT] +**
+**
)^ +** +** ^The memory pointed to by the character pointers returned for the +** declaration type and collation sequence is valid until the next +** call to any SQLite API function. +** +** ^If the specified table is actually a view, an [error code] is returned. +** +** ^If the specified column is "rowid", "oid" or "_rowid_" and the table +** is not a [WITHOUT ROWID] table and an +** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output +** parameters are set for the explicitly declared column. ^(If there is no +** [INTEGER PRIMARY KEY] column, then the outputs +** for the [rowid] are set as follows: +** +**
+**     data type: "INTEGER"
+**     collation sequence: "BINARY"
+**     not null: 0
+**     primary key: 1
+**     auto increment: 0
+** 
)^ +** +** ^This function causes all database schemas to be read from disk and +** parsed, if that has not already been done, and returns an error if +** any errors are encountered while loading the schema. +*/ +SQLITE_API int sqlite3_table_column_metadata( + sqlite3 *db, /* Connection handle */ + const char *zDbName, /* Database name or NULL */ + const char *zTableName, /* Table name */ + const char *zColumnName, /* Column name */ + char const **pzDataType, /* OUTPUT: Declared data type */ + char const **pzCollSeq, /* OUTPUT: Collation sequence name */ + int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ + int *pPrimaryKey, /* OUTPUT: True if column part of PK */ + int *pAutoinc /* OUTPUT: True if column is auto-increment */ +); + +/* +** CAPI3REF: Load An Extension +** METHOD: sqlite3 +** +** ^This interface loads an SQLite extension library from the named file. +** +** ^The sqlite3_load_extension() interface attempts to load an +** [SQLite extension] library contained in the file zFile. If +** the file cannot be loaded directly, attempts are made to load +** with various operating-system specific extensions added. +** So for example, if "samplelib" cannot be loaded, then names like +** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might +** be tried also. +** +** ^The entry point is zProc. +** ^(zProc may be 0, in which case SQLite will try to come up with an +** entry point name on its own. It first tries "sqlite3_extension_init". +** If that does not work, it constructs a name "sqlite3_X_init" where +** X consists of the lower-case equivalent of all ASCII alphabetic +** characters in the filename from the last "/" to the first following +** "." and omitting any initial "lib".)^ +** ^The sqlite3_load_extension() interface returns +** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. +** ^If an error occurs and pzErrMsg is not 0, then the +** [sqlite3_load_extension()] interface shall attempt to +** fill *pzErrMsg with error message text stored in memory +** obtained from [sqlite3_malloc()]. The calling function +** should free this memory by calling [sqlite3_free()]. +** +** ^Extension loading must be enabled using +** [sqlite3_enable_load_extension()] or +** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL) +** prior to calling this API, +** otherwise an error will be returned. +** +** Security warning: It is recommended that the +** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this +** interface. The use of the [sqlite3_enable_load_extension()] interface +** should be avoided. This will keep the SQL function [load_extension()] +** disabled and prevent SQL injections from giving attackers +** access to extension loading capabilities. +** +** See also the [load_extension() SQL function]. +*/ +SQLITE_API int sqlite3_load_extension( + sqlite3 *db, /* Load the extension into this database connection */ + const char *zFile, /* Name of the shared library containing extension */ + const char *zProc, /* Entry point. Derived from zFile if 0 */ + char **pzErrMsg /* Put error message here if not 0 */ +); + +/* +** CAPI3REF: Enable Or Disable Extension Loading +** METHOD: sqlite3 +** +** ^So as not to open security holes in older applications that are +** unprepared to deal with [extension loading], and as a means of disabling +** [extension loading] while evaluating user-entered SQL, the following API +** is provided to turn the [sqlite3_load_extension()] mechanism on and off. +** +** ^Extension loading is off by default. +** ^Call the sqlite3_enable_load_extension() routine with onoff==1 +** to turn extension loading on and call it with onoff==0 to turn +** it back off again. +** +** ^This interface enables or disables both the C-API +** [sqlite3_load_extension()] and the SQL function [load_extension()]. +** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) +** to enable or disable only the C-API.)^ +** +** Security warning: It is recommended that extension loading +** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method +** rather than this interface, so the [load_extension()] SQL function +** remains disabled. This will prevent SQL injections from giving attackers +** access to extension loading capabilities. +*/ +SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); + +/* +** CAPI3REF: Automatically Load Statically Linked Extensions +** +** ^This interface causes the xEntryPoint() function to be invoked for +** each new [database connection] that is created. The idea here is that +** xEntryPoint() is the entry point for a statically linked [SQLite extension] +** that is to be automatically loaded into all new database connections. +** +** ^(Even though the function prototype shows that xEntryPoint() takes +** no arguments and returns void, SQLite invokes xEntryPoint() with three +** arguments and expects an integer result as if the signature of the +** entry point were as follows: +** +**
+**    int xEntryPoint(
+**      sqlite3 *db,
+**      const char **pzErrMsg,
+**      const struct sqlite3_api_routines *pThunk
+**    );
+** 
)^ +** +** If the xEntryPoint routine encounters an error, it should make *pzErrMsg +** point to an appropriate error message (obtained from [sqlite3_mprintf()]) +** and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg +** is NULL before calling the xEntryPoint(). ^SQLite will invoke +** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any +** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], +** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. +** +** ^Calling sqlite3_auto_extension(X) with an entry point X that is already +** on the list of automatic extensions is a harmless no-op. ^No entry point +** will be called more than once for each database connection that is opened. +** +** See also: [sqlite3_reset_auto_extension()] +** and [sqlite3_cancel_auto_extension()] +*/ +SQLITE_API int sqlite3_auto_extension(void(*xEntryPoint)(void)); + +/* +** CAPI3REF: Cancel Automatic Extension Loading +** +** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the +** initialization routine X that was registered using a prior call to +** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)] +** routine returns 1 if initialization routine X was successfully +** unregistered and it returns 0 if X was not on the list of initialization +** routines. +*/ +SQLITE_API int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void)); + +/* +** CAPI3REF: Reset Automatic Extension Loading +** +** ^This interface disables all automatic extensions previously +** registered using [sqlite3_auto_extension()]. +*/ +SQLITE_API void sqlite3_reset_auto_extension(void); + +/* +** Structures used by the virtual table interface +*/ +typedef struct sqlite3_vtab sqlite3_vtab; +typedef struct sqlite3_index_info sqlite3_index_info; +typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; +typedef struct sqlite3_module sqlite3_module; + +/* +** CAPI3REF: Virtual Table Object +** KEYWORDS: sqlite3_module {virtual table module} +** +** This structure, sometimes called a "virtual table module", +** defines the implementation of a [virtual table]. +** This structure consists mostly of methods for the module. +** +** ^A virtual table module is created by filling in a persistent +** instance of this structure and passing a pointer to that instance +** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. +** ^The registration remains valid until it is replaced by a different +** module or until the [database connection] closes. The content +** of this structure must not change while it is registered with +** any database connection. +*/ +struct sqlite3_module { + int iVersion; + int (*xCreate)(sqlite3*, void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVTab, char**); + int (*xConnect)(sqlite3*, void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVTab, char**); + int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); + int (*xDisconnect)(sqlite3_vtab *pVTab); + int (*xDestroy)(sqlite3_vtab *pVTab); + int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); + int (*xClose)(sqlite3_vtab_cursor*); + int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, + int argc, sqlite3_value **argv); + int (*xNext)(sqlite3_vtab_cursor*); + int (*xEof)(sqlite3_vtab_cursor*); + int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); + int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); + int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); + int (*xBegin)(sqlite3_vtab *pVTab); + int (*xSync)(sqlite3_vtab *pVTab); + int (*xCommit)(sqlite3_vtab *pVTab); + int (*xRollback)(sqlite3_vtab *pVTab); + int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, + void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), + void **ppArg); + int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); + /* The methods above are in version 1 of the sqlite_module object. Those + ** below are for version 2 and greater. */ + int (*xSavepoint)(sqlite3_vtab *pVTab, int); + int (*xRelease)(sqlite3_vtab *pVTab, int); + int (*xRollbackTo)(sqlite3_vtab *pVTab, int); + /* The methods above are in versions 1 and 2 of the sqlite_module object. + ** Those below are for version 3 and greater. */ + int (*xShadowName)(const char*); + /* The methods above are in versions 1 through 3 of the sqlite_module object. + ** Those below are for version 4 and greater. */ + int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema, + const char *zTabName, int mFlags, char **pzErr); +}; + +/* +** CAPI3REF: Virtual Table Indexing Information +** KEYWORDS: sqlite3_index_info +** +** The sqlite3_index_info structure and its substructures is used as part +** of the [virtual table] interface to +** pass information into and receive the reply from the [xBestIndex] +** method of a [virtual table module]. The fields under **Inputs** are the +** inputs to xBestIndex and are read-only. xBestIndex inserts its +** results into the **Outputs** fields. +** +** ^(The aConstraint[] array records WHERE clause constraints of the form: +** +**
column OP expr
+** +** where OP is =, <, <=, >, or >=.)^ ^(The particular operator is +** stored in aConstraint[].op using one of the +** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ +** ^(The index of the column is stored in +** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the +** expr on the right-hand side can be evaluated (and thus the constraint +** is usable) and false if it cannot.)^ +** +** ^The optimizer automatically inverts terms of the form "expr OP column" +** and makes other simplifications to the WHERE clause in an attempt to +** get as many WHERE clause terms into the form shown above as possible. +** ^The aConstraint[] array only reports WHERE clause terms that are +** relevant to the particular virtual table being queried. +** +** ^Information about the ORDER BY clause is stored in aOrderBy[]. +** ^Each term of aOrderBy records a column of the ORDER BY clause. +** +** The colUsed field indicates which columns of the virtual table may be +** required by the current scan. Virtual table columns are numbered from +** zero in the order in which they appear within the CREATE TABLE statement +** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), +** the corresponding bit is set within the colUsed mask if the column may be +** required by SQLite. If the table has at least 64 columns and any column +** to the right of the first 63 is required, then bit 63 of colUsed is also +** set. In other words, column iCol may be required if the expression +** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to +** non-zero. +** +** The [xBestIndex] method must fill aConstraintUsage[] with information +** about what parameters to pass to xFilter. ^If argvIndex>0 then +** the right-hand side of the corresponding aConstraint[] is evaluated +** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit +** is true, then the constraint is assumed to be fully handled by the +** virtual table and might not be checked again by the byte code.)^ ^(The +** aConstraintUsage[].omit flag is an optimization hint. When the omit flag +** is left in its default setting of false, the constraint will always be +** checked separately in byte code. If the omit flag is changed to true, then +** the constraint may or may not be checked in byte code. In other words, +** when the omit flag is true there is no guarantee that the constraint will +** not be checked again using byte code.)^ +** +** ^The idxNum and idxStr values are recorded and passed into the +** [xFilter] method. +** ^[sqlite3_free()] is used to free idxStr if and only if +** needToFreeIdxStr is true. +** +** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in +** the correct order to satisfy the ORDER BY clause so that no separate +** sorting step is required. +** +** ^The estimatedCost value is an estimate of the cost of a particular +** strategy. A cost of N indicates that the cost of the strategy is similar +** to a linear scan of an SQLite table with N rows. A cost of log(N) +** indicates that the expense of the operation is similar to that of a +** binary search on a unique indexed field of an SQLite table with N rows. +** +** ^The estimatedRows value is an estimate of the number of rows that +** will be returned by the strategy. +** +** The xBestIndex method may optionally populate the idxFlags field with a +** mask of SQLITE_INDEX_SCAN_* flags. One such flag is +** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN] +** output to show the idxNum as hex instead of as decimal. Another flag is +** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will +** return at most one row. +** +** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then +** SQLite also assumes that if a call to the xUpdate() method is made as +** part of the same statement to delete or update a virtual table row and the +** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback +** any database changes. In other words, if the xUpdate() returns +** SQLITE_CONSTRAINT, the database contents must be exactly as they were +** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not +** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by +** the xUpdate method are automatically rolled back by SQLite. +** +** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info +** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). +** If a virtual table extension is +** used with an SQLite version earlier than 3.8.2, the results of attempting +** to read or write the estimatedRows field are undefined (but are likely +** to include crashing the application). The estimatedRows field should +** therefore only be used if [sqlite3_libversion_number()] returns a +** value greater than or equal to 3008002. Similarly, the idxFlags field +** was added for [version 3.9.0] ([dateof:3.9.0]). +** It may therefore only be used if +** sqlite3_libversion_number() returns a value greater than or equal to +** 3009000. +*/ +struct sqlite3_index_info { + /* Inputs */ + int nConstraint; /* Number of entries in aConstraint */ + struct sqlite3_index_constraint { + int iColumn; /* Column constrained. -1 for ROWID */ + unsigned char op; /* Constraint operator */ + unsigned char usable; /* True if this constraint is usable */ + int iTermOffset; /* Used internally - xBestIndex should ignore */ + } *aConstraint; /* Table of WHERE clause constraints */ + int nOrderBy; /* Number of terms in the ORDER BY clause */ + struct sqlite3_index_orderby { + int iColumn; /* Column number */ + unsigned char desc; /* True for DESC. False for ASC. */ + } *aOrderBy; /* The ORDER BY clause */ + /* Outputs */ + struct sqlite3_index_constraint_usage { + int argvIndex; /* if >0, constraint is part of argv to xFilter */ + unsigned char omit; /* Do not code a test for this constraint */ + } *aConstraintUsage; + int idxNum; /* Number used to identify the index */ + char *idxStr; /* String, possibly obtained from sqlite3_malloc */ + int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ + int orderByConsumed; /* True if output is already ordered */ + double estimatedCost; /* Estimated cost of using this index */ + /* Fields below are only available in SQLite 3.8.2 and later */ + sqlite3_int64 estimatedRows; /* Estimated number of rows returned */ + /* Fields below are only available in SQLite 3.9.0 and later */ + int idxFlags; /* Mask of SQLITE_INDEX_SCAN_* flags */ + /* Fields below are only available in SQLite 3.10.0 and later */ + sqlite3_uint64 colUsed; /* Input: Mask of columns used by statement */ +}; + +/* +** CAPI3REF: Virtual Table Scan Flags +** +** Virtual table implementations are allowed to set the +** [sqlite3_index_info].idxFlags field to some combination of +** these bits. +*/ +#define SQLITE_INDEX_SCAN_UNIQUE 0x00000001 /* Scan visits at most 1 row */ +#define SQLITE_INDEX_SCAN_HEX 0x00000002 /* Display idxNum as hex */ + /* in EXPLAIN QUERY PLAN */ + +/* +** CAPI3REF: Virtual Table Constraint Operator Codes +** +** These macros define the allowed values for the +** [sqlite3_index_info].aConstraint[].op field. Each value represents +** an operator that is part of a constraint term in the WHERE clause of +** a query that uses a [virtual table]. +** +** ^The left-hand operand of the operator is given by the corresponding +** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand +** operand is the rowid. +** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET +** operators have no left-hand operand, and so for those operators the +** corresponding aConstraint[].iColumn is meaningless and should not be +** used. +** +** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through +** value 255 are reserved to represent functions that are overloaded +** by the [xFindFunction|xFindFunction method] of the virtual table +** implementation. +** +** The right-hand operands for each constraint might be accessible using +** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand +** operand is only available if it appears as a single constant literal +** in the input SQL. If the right-hand operand is another column or an +** expression (even a constant expression) or a parameter, then the +** sqlite3_vtab_rhs_value() probably will not be able to extract it. +** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and +** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand +** and hence calls to sqlite3_vtab_rhs_value() for those operators will +** always return SQLITE_NOTFOUND. +** +** The collating sequence to be used for comparison can be found using +** the [sqlite3_vtab_collation()] interface. For most real-world virtual +** tables, the collating sequence of constraints does not matter (for example +** because the constraints are numeric) and so the sqlite3_vtab_collation() +** interface is not commonly needed. +*/ +#define SQLITE_INDEX_CONSTRAINT_EQ 2 +#define SQLITE_INDEX_CONSTRAINT_GT 4 +#define SQLITE_INDEX_CONSTRAINT_LE 8 +#define SQLITE_INDEX_CONSTRAINT_LT 16 +#define SQLITE_INDEX_CONSTRAINT_GE 32 +#define SQLITE_INDEX_CONSTRAINT_MATCH 64 +#define SQLITE_INDEX_CONSTRAINT_LIKE 65 +#define SQLITE_INDEX_CONSTRAINT_GLOB 66 +#define SQLITE_INDEX_CONSTRAINT_REGEXP 67 +#define SQLITE_INDEX_CONSTRAINT_NE 68 +#define SQLITE_INDEX_CONSTRAINT_ISNOT 69 +#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70 +#define SQLITE_INDEX_CONSTRAINT_ISNULL 71 +#define SQLITE_INDEX_CONSTRAINT_IS 72 +#define SQLITE_INDEX_CONSTRAINT_LIMIT 73 +#define SQLITE_INDEX_CONSTRAINT_OFFSET 74 +#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150 + +/* +** CAPI3REF: Register A Virtual Table Implementation +** METHOD: sqlite3 +** +** ^These routines are used to register a new [virtual table module] name. +** ^Module names must be registered before +** creating a new [virtual table] using the module and before using a +** preexisting [virtual table] for the module. +** +** ^The module name is registered on the [database connection] specified +** by the first parameter. ^The name of the module is given by the +** second parameter. ^The third parameter is a pointer to +** the implementation of the [virtual table module]. ^The fourth +** parameter is an arbitrary client data pointer that is passed through +** into the [xCreate] and [xConnect] methods of the virtual table module +** when a new virtual table is being created or reinitialized. +** +** ^The sqlite3_create_module_v2() interface has a fifth parameter which +** is a pointer to a destructor for the pClientData. ^SQLite will +** invoke the destructor function (if it is not NULL) when SQLite +** no longer needs the pClientData pointer. ^The destructor will also +** be invoked if the call to sqlite3_create_module_v2() fails. +** ^The sqlite3_create_module() +** interface is equivalent to sqlite3_create_module_v2() with a NULL +** destructor. +** +** ^If the third parameter (the pointer to the sqlite3_module object) is +** NULL then no new module is created and any existing modules with the +** same name are dropped. +** +** See also: [sqlite3_drop_modules()] +*/ +SQLITE_API int sqlite3_create_module( + sqlite3 *db, /* SQLite connection to register module with */ + const char *zName, /* Name of the module */ + const sqlite3_module *p, /* Methods for the module */ + void *pClientData /* Client data for xCreate/xConnect */ +); +SQLITE_API int sqlite3_create_module_v2( + sqlite3 *db, /* SQLite connection to register module with */ + const char *zName, /* Name of the module */ + const sqlite3_module *p, /* Methods for the module */ + void *pClientData, /* Client data for xCreate/xConnect */ + void(*xDestroy)(void*) /* Module destructor function */ +); + +/* +** CAPI3REF: Remove Unnecessary Virtual Table Implementations +** METHOD: sqlite3 +** +** ^The sqlite3_drop_modules(D,L) interface removes all virtual +** table modules from database connection D except those named on list L. +** The L parameter must be either NULL or a pointer to an array of pointers +** to strings where the array is terminated by a single NULL pointer. +** ^If the L parameter is NULL, then all virtual table modules are removed. +** +** See also: [sqlite3_create_module()] +*/ +SQLITE_API int sqlite3_drop_modules( + sqlite3 *db, /* Remove modules from this connection */ + const char **azKeep /* Except, do not remove the ones named here */ +); + +/* +** CAPI3REF: Virtual Table Instance Object +** KEYWORDS: sqlite3_vtab +** +** Every [virtual table module] implementation uses a subclass +** of this object to describe a particular instance +** of the [virtual table]. Each subclass will +** be tailored to the specific needs of the module implementation. +** The purpose of this superclass is to define certain fields that are +** common to all module implementations. +** +** ^Virtual tables methods can set an error message by assigning a +** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should +** take care that any prior string is freed by a call to [sqlite3_free()] +** prior to assigning a new string to zErrMsg. ^After the error message +** is delivered up to the client application, the string will be automatically +** freed by sqlite3_free() and the zErrMsg field will be zeroed. +*/ +struct sqlite3_vtab { + const sqlite3_module *pModule; /* The module for this virtual table */ + int nRef; /* Number of open cursors */ + char *zErrMsg; /* Error message from sqlite3_mprintf() */ + /* Virtual table implementations will typically add additional fields */ +}; + +/* +** CAPI3REF: Virtual Table Cursor Object +** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} +** +** Every [virtual table module] implementation uses a subclass of the +** following structure to describe cursors that point into the +** [virtual table] and are used +** to loop through the virtual table. Cursors are created using the +** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed +** by the [sqlite3_module.xClose | xClose] method. Cursors are used +** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods +** of the module. Each module implementation will define +** the content of a cursor structure to suit its own needs. +** +** This superclass exists in order to define fields of the cursor that +** are common to all implementations. +*/ +struct sqlite3_vtab_cursor { + sqlite3_vtab *pVtab; /* Virtual table of this cursor */ + /* Virtual table implementations will typically add additional fields */ +}; + +/* +** CAPI3REF: Declare The Schema Of A Virtual Table +** +** ^The [xCreate] and [xConnect] methods of a +** [virtual table module] call this interface +** to declare the format (the names and datatypes of the columns) of +** the virtual tables they implement. +*/ +SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL); + +/* +** CAPI3REF: Overload A Function For A Virtual Table +** METHOD: sqlite3 +** +** ^(Virtual tables can provide alternative implementations of functions +** using the [xFindFunction] method of the [virtual table module]. +** But global versions of those functions +** must exist in order to be overloaded.)^ +** +** ^(This API makes sure a global version of a function with a particular +** name and number of parameters exists. If no such function exists +** before this API is called, a new function is created.)^ ^The implementation +** of the new function always causes an exception to be thrown. So +** the new function is not good for anything by itself. Its only +** purpose is to be a placeholder function that can be overloaded +** by a [virtual table]. +*/ +SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); + +/* +** CAPI3REF: A Handle To An Open BLOB +** KEYWORDS: {BLOB handle} {BLOB handles} +** +** An instance of this object represents an open BLOB on which +** [sqlite3_blob_open | incremental BLOB I/O] can be performed. +** ^Objects of this type are created by [sqlite3_blob_open()] +** and destroyed by [sqlite3_blob_close()]. +** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces +** can be used to read or write small subsections of the BLOB. +** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. +*/ +typedef struct sqlite3_blob sqlite3_blob; + +/* +** CAPI3REF: Open A BLOB For Incremental I/O +** METHOD: sqlite3 +** CONSTRUCTOR: sqlite3_blob +** +** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located +** in row iRow, column zColumn, table zTable in database zDb; +** in other words, the same BLOB that would be selected by: +** +**
+**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
+** 
)^ +** +** ^(Parameter zDb is not the filename that contains the database, but +** rather the symbolic name of the database. For attached databases, this is +** the name that appears after the AS keyword in the [ATTACH] statement. +** For the main database file, the database name is "main". For TEMP +** tables, the database name is "temp".)^ +** +** ^If the flags parameter is non-zero, then the BLOB is opened for read +** and write access. ^If the flags parameter is zero, the BLOB is opened for +** read-only access. +** +** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored +** in *ppBlob. Otherwise an [error code] is returned and, unless the error +** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided +** the API is not misused, it is always safe to call [sqlite3_blob_close()] +** on *ppBlob after this function returns. +** +** This function fails with SQLITE_ERROR if any of the following are true: +**
    +**
  • ^(Database zDb does not exist)^, +**
  • ^(Table zTable does not exist within database zDb)^, +**
  • ^(Table zTable is a WITHOUT ROWID table)^, +**
  • ^(Column zColumn does not exist)^, +**
  • ^(Row iRow is not present in the table)^, +**
  • ^(The specified column of row iRow contains a value that is not +** a TEXT or BLOB value)^, +**
  • ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE +** constraint and the blob is being opened for read/write access)^, +**
  • ^([foreign key constraints | Foreign key constraints] are enabled, +** column zColumn is part of a [child key] definition and the blob is +** being opened for read/write access)^. +**
+** +** ^Unless it returns SQLITE_MISUSE, this function sets the +** [database connection] error code and message accessible via +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. +** +** A BLOB referenced by sqlite3_blob_open() may be read using the +** [sqlite3_blob_read()] interface and modified by using +** [sqlite3_blob_write()]. The [BLOB handle] can be moved to a +** different row of the same table using the [sqlite3_blob_reopen()] +** interface. However, the column, table, or database of a [BLOB handle] +** cannot be changed after the [BLOB handle] is opened. +** +** ^(If the row that a BLOB handle points to is modified by an +** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects +** then the BLOB handle is marked as "expired". +** This is true if any column of the row is changed, even a column +** other than the one the BLOB handle is open on.)^ +** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for +** an expired BLOB handle fail with a return code of [SQLITE_ABORT]. +** ^(Changes written into a BLOB prior to the BLOB expiring are not +** rolled back by the expiration of the BLOB. Such changes will eventually +** commit if the transaction continues to completion.)^ +** +** ^Use the [sqlite3_blob_bytes()] interface to determine the size of +** the opened blob. ^The size of a blob may not be changed by this +** interface. Use the [UPDATE] SQL command to change the size of a +** blob. +** +** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces +** and the built-in [zeroblob] SQL function may be used to create a +** zero-filled blob to read or write using the incremental-blob interface. +** +** To avoid a resource leak, every open [BLOB handle] should eventually +** be released by a call to [sqlite3_blob_close()]. +** +** See also: [sqlite3_blob_close()], +** [sqlite3_blob_reopen()], [sqlite3_blob_read()], +** [sqlite3_blob_bytes()], [sqlite3_blob_write()]. +*/ +SQLITE_API int sqlite3_blob_open( + sqlite3*, + const char *zDb, + const char *zTable, + const char *zColumn, + sqlite3_int64 iRow, + int flags, + sqlite3_blob **ppBlob +); + +/* +** CAPI3REF: Move a BLOB Handle to a New Row +** METHOD: sqlite3_blob +** +** ^This function is used to move an existing [BLOB handle] so that it points +** to a different row of the same database table. ^The new row is identified +** by the rowid value passed as the second argument. Only the row can be +** changed. ^The database, table and column on which the blob handle is open +** remain the same. Moving an existing [BLOB handle] to a new row is +** faster than closing the existing handle and opening a new one. +** +** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - +** it must exist and there must be either a blob or text value stored in +** the nominated column.)^ ^If the new row is not present in the table, or if +** it does not contain a blob or text value, or if another error occurs, an +** SQLite error code is returned and the blob handle is considered aborted. +** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or +** [sqlite3_blob_reopen()] on an aborted blob handle immediately return +** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle +** always returns zero. +** +** ^This function sets the database handle error code and message. +*/ +SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); + +/* +** CAPI3REF: Close A BLOB Handle +** DESTRUCTOR: sqlite3_blob +** +** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed +** unconditionally. Even if this routine returns an error code, the +** handle is still closed.)^ +** +** ^If the blob handle being closed was opened for read-write access, and if +** the database is in auto-commit mode and there are no other open read-write +** blob handles or active write statements, the current transaction is +** committed. ^If an error occurs while committing the transaction, an error +** code is returned and the transaction rolled back. +** +** Calling this function with an argument that is not a NULL pointer or an +** open blob handle results in undefined behavior. ^Calling this routine +** with a null pointer (such as would be returned by a failed call to +** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function +** is passed a valid open blob handle, the values returned by the +** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning. +*/ +SQLITE_API int sqlite3_blob_close(sqlite3_blob *); + +/* +** CAPI3REF: Return The Size Of An Open BLOB +** METHOD: sqlite3_blob +** +** ^Returns the size in bytes of the BLOB accessible via the +** successfully opened [BLOB handle] in its only argument. ^The +** incremental blob I/O routines can only read or overwrite existing +** blob content; they cannot change the size of a blob. +** +** This routine only works on a [BLOB handle] which has been created +** by a prior successful call to [sqlite3_blob_open()] and which has not +** been closed by [sqlite3_blob_close()]. Passing any other pointer in +** to this routine results in undefined and probably undesirable behavior. +*/ +SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); + +/* +** CAPI3REF: Read Data From A BLOB Incrementally +** METHOD: sqlite3_blob +** +** ^(This function is used to read data from an open [BLOB handle] into a +** caller-supplied buffer. N bytes of data are copied into buffer Z +** from the open BLOB, starting at offset iOffset.)^ +** +** ^If offset iOffset is less than N bytes from the end of the BLOB, +** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is +** less than zero, [SQLITE_ERROR] is returned and no data is read. +** ^The size of the blob (and hence the maximum value of N+iOffset) +** can be determined using the [sqlite3_blob_bytes()] interface. +** +** ^An attempt to read from an expired [BLOB handle] fails with an +** error code of [SQLITE_ABORT]. +** +** ^(On success, sqlite3_blob_read() returns SQLITE_OK. +** Otherwise, an [error code] or an [extended error code] is returned.)^ +** +** This routine only works on a [BLOB handle] which has been created +** by a prior successful call to [sqlite3_blob_open()] and which has not +** been closed by [sqlite3_blob_close()]. Passing any other pointer in +** to this routine results in undefined and probably undesirable behavior. +** +** See also: [sqlite3_blob_write()]. +*/ +SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); + +/* +** CAPI3REF: Write Data Into A BLOB Incrementally +** METHOD: sqlite3_blob +** +** ^(This function is used to write data into an open [BLOB handle] from a +** caller-supplied buffer. N bytes of data are copied from the buffer Z +** into the open BLOB, starting at offset iOffset.)^ +** +** ^(On success, sqlite3_blob_write() returns SQLITE_OK. +** Otherwise, an [error code] or an [extended error code] is returned.)^ +** ^Unless SQLITE_MISUSE is returned, this function sets the +** [database connection] error code and message accessible via +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. +** +** ^If the [BLOB handle] passed as the first argument was not opened for +** writing (the flags parameter to [sqlite3_blob_open()] was zero), +** this function returns [SQLITE_READONLY]. +** +** This function may only modify the contents of the BLOB; it is +** not possible to increase the size of a BLOB using this API. +** ^If offset iOffset is less than N bytes from the end of the BLOB, +** [SQLITE_ERROR] is returned and no data is written. The size of the +** BLOB (and hence the maximum value of N+iOffset) can be determined +** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less +** than zero [SQLITE_ERROR] is returned and no data is written. +** +** ^An attempt to write to an expired [BLOB handle] fails with an +** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred +** before the [BLOB handle] expired are not rolled back by the +** expiration of the handle, though of course those changes might +** have been overwritten by the statement that expired the BLOB handle +** or by other independent statements. +** +** This routine only works on a [BLOB handle] which has been created +** by a prior successful call to [sqlite3_blob_open()] and which has not +** been closed by [sqlite3_blob_close()]. Passing any other pointer in +** to this routine results in undefined and probably undesirable behavior. +** +** See also: [sqlite3_blob_read()]. +*/ +SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); + +/* +** CAPI3REF: Virtual File System Objects +** +** A virtual filesystem (VFS) is an [sqlite3_vfs] object +** that SQLite uses to interact +** with the underlying operating system. Most SQLite builds come with a +** single default VFS that is appropriate for the host computer. +** New VFSes can be registered and existing VFSes can be unregistered. +** The following interfaces are provided. +** +** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. +** ^Names are case sensitive. +** ^Names are zero-terminated UTF-8 strings. +** ^If there is no match, a NULL pointer is returned. +** ^If zVfsName is NULL then the default VFS is returned. +** +** ^New VFSes are registered with sqlite3_vfs_register(). +** ^Each new VFS becomes the default VFS if the makeDflt flag is set. +** ^The same VFS can be registered multiple times without injury. +** ^To make an existing VFS into the default VFS, register it again +** with the makeDflt flag set. If two different VFSes with the +** same name are registered, the behavior is undefined. If a +** VFS is registered with a name that is NULL or an empty string, +** then the behavior is undefined. +** +** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. +** ^(If the default VFS is unregistered, another VFS is chosen as +** the default. The choice for the new VFS is arbitrary.)^ +*/ +SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); +SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); +SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); + +/* +** CAPI3REF: Mutexes +** +** The SQLite core uses these routines for thread +** synchronization. Though they are intended for internal +** use by SQLite, code that links against SQLite is +** permitted to use any of these routines. +** +** The SQLite source code contains multiple implementations +** of these mutex routines. An appropriate implementation +** is selected automatically at compile-time. The following +** implementations are available in the SQLite core: +** +**
    +**
  • SQLITE_MUTEX_PTHREADS +**
  • SQLITE_MUTEX_W32 +**
  • SQLITE_MUTEX_NOOP +**
+** +** The SQLITE_MUTEX_NOOP implementation is a set of routines +** that does no real locking and is appropriate for use in +** a single-threaded application. The SQLITE_MUTEX_PTHREADS and +** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix +** and Windows. +** +** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor +** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex +** implementation is included with the library. In this case the +** application must supply a custom mutex implementation using the +** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function +** before calling sqlite3_initialize() or any other public sqlite3_ +** function that calls sqlite3_initialize(). +** +** ^The sqlite3_mutex_alloc() routine allocates a new +** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc() +** routine returns NULL if it is unable to allocate the requested +** mutex. The argument to sqlite3_mutex_alloc() must be one of these +** integer constants: +** +**
    +**
  • SQLITE_MUTEX_FAST +**
  • SQLITE_MUTEX_RECURSIVE +**
  • SQLITE_MUTEX_STATIC_MAIN +**
  • SQLITE_MUTEX_STATIC_MEM +**
  • SQLITE_MUTEX_STATIC_OPEN +**
  • SQLITE_MUTEX_STATIC_PRNG +**
  • SQLITE_MUTEX_STATIC_LRU +**
  • SQLITE_MUTEX_STATIC_PMEM +**
  • SQLITE_MUTEX_STATIC_APP1 +**
  • SQLITE_MUTEX_STATIC_APP2 +**
  • SQLITE_MUTEX_STATIC_APP3 +**
  • SQLITE_MUTEX_STATIC_VFS1 +**
  • SQLITE_MUTEX_STATIC_VFS2 +**
  • SQLITE_MUTEX_STATIC_VFS3 +**
+** +** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) +** cause sqlite3_mutex_alloc() to create +** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE +** is used but not necessarily so when SQLITE_MUTEX_FAST is used. +** The mutex implementation does not need to make a distinction +** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does +** not want to. SQLite will only request a recursive mutex in +** cases where it really needs one. If a faster non-recursive mutex +** implementation is available on the host platform, the mutex subsystem +** might return such a mutex in response to SQLITE_MUTEX_FAST. +** +** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other +** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return +** a pointer to a static preexisting mutex. ^Nine static mutexes are +** used by the current version of SQLite. Future versions of SQLite +** may add additional static mutexes. Static mutexes are for internal +** use by SQLite only. Applications that use SQLite mutexes should +** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or +** SQLITE_MUTEX_RECURSIVE. +** +** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST +** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() +** returns a different mutex on every call. ^For the static +** mutex types, the same mutex is returned on every call that has +** the same type number. +** +** ^The sqlite3_mutex_free() routine deallocates a previously +** allocated dynamic mutex. Attempting to deallocate a static +** mutex results in undefined behavior. +** +** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt +** to enter a mutex. ^If another thread is already within the mutex, +** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return +** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] +** upon successful entry. ^(Mutexes created using +** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. +** In such cases, the +** mutex must be exited an equal number of times before another thread +** can enter.)^ If the same thread tries to enter any mutex other +** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined. +** +** ^(Some systems (for example, Windows 95) do not support the operation +** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() +** will always return SQLITE_BUSY. In most cases the SQLite core only uses +** sqlite3_mutex_try() as an optimization, so this is acceptable +** behavior. The exceptions are unix builds that set the +** SQLITE_ENABLE_SETLK_TIMEOUT build option. In that case a working +** sqlite3_mutex_try() is required.)^ +** +** ^The sqlite3_mutex_leave() routine exits a mutex that was +** previously entered by the same thread. The behavior +** is undefined if the mutex is not currently entered by the +** calling thread or is not currently allocated. +** +** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), +** sqlite3_mutex_leave(), or sqlite3_mutex_free() is a NULL pointer, +** then any of the four routines behaves as a no-op. +** +** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. +*/ +SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); +SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); +SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); +SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); +SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); + +/* +** CAPI3REF: Mutex Methods Object +** +** An instance of this structure defines the low-level routines +** used to allocate and use mutexes. +** +** Usually, the default mutex implementations provided by SQLite are +** sufficient, however the application has the option of substituting a custom +** implementation for specialized deployments or systems for which SQLite +** does not provide a suitable implementation. In this case, the application +** creates and populates an instance of this structure to pass +** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. +** Additionally, an instance of this structure can be used as an +** output variable when querying the system for the current mutex +** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. +** +** ^The xMutexInit method defined by this structure is invoked as +** part of system initialization by the sqlite3_initialize() function. +** ^The xMutexInit routine is called by SQLite exactly once for each +** effective call to [sqlite3_initialize()]. +** +** ^The xMutexEnd method defined by this structure is invoked as +** part of system shutdown by the sqlite3_shutdown() function. The +** implementation of this method is expected to release all outstanding +** resources obtained by the mutex methods implementation, especially +** those obtained by the xMutexInit method. ^The xMutexEnd() +** interface is invoked exactly once for each call to [sqlite3_shutdown()]. +** +** ^(The remaining seven methods defined by this structure (xMutexAlloc, +** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and +** xMutexNotheld) implement the following interfaces (respectively): +** +**
    +**
  • [sqlite3_mutex_alloc()]
  • +**
  • [sqlite3_mutex_free()]
  • +**
  • [sqlite3_mutex_enter()]
  • +**
  • [sqlite3_mutex_try()]
  • +**
  • [sqlite3_mutex_leave()]
  • +**
  • [sqlite3_mutex_held()]
  • +**
  • [sqlite3_mutex_notheld()]
  • +**
)^ +** +** The only difference is that the public sqlite3_XXX functions enumerated +** above silently ignore any invocations that pass a NULL pointer instead +** of a valid mutex handle. The implementations of the methods defined +** by this structure are not required to handle this case. The results +** of passing a NULL pointer instead of a valid mutex handle are undefined +** (i.e. it is acceptable to provide an implementation that segfaults if +** it is passed a NULL pointer). +** +** The xMutexInit() method must be threadsafe. It must be harmless to +** invoke xMutexInit() multiple times within the same process and without +** intervening calls to xMutexEnd(). Second and subsequent calls to +** xMutexInit() must be no-ops. +** +** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] +** and its associates). Similarly, xMutexAlloc() must not use SQLite memory +** allocation for a static mutex. ^However xMutexAlloc() may use SQLite +** memory allocation for a fast or recursive mutex. +** +** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is +** called, but only if the prior call to xMutexInit returned SQLITE_OK. +** If xMutexInit fails in any way, it is expected to clean up after itself +** prior to returning. +*/ +typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; +struct sqlite3_mutex_methods { + int (*xMutexInit)(void); + int (*xMutexEnd)(void); + sqlite3_mutex *(*xMutexAlloc)(int); + void (*xMutexFree)(sqlite3_mutex *); + void (*xMutexEnter)(sqlite3_mutex *); + int (*xMutexTry)(sqlite3_mutex *); + void (*xMutexLeave)(sqlite3_mutex *); + int (*xMutexHeld)(sqlite3_mutex *); + int (*xMutexNotheld)(sqlite3_mutex *); +}; + +/* +** CAPI3REF: Mutex Verification Routines +** +** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines +** are intended for use inside assert() statements. The SQLite core +** never uses these routines except inside an assert() and applications +** are advised to follow the lead of the core. The SQLite core only +** provides implementations for these routines when it is compiled +** with the SQLITE_DEBUG flag. External mutex implementations +** are only required to provide these routines if SQLITE_DEBUG is +** defined and if NDEBUG is not defined. +** +** These routines should return true if the mutex in their argument +** is held or not held, respectively, by the calling thread. +** +** The implementation is not required to provide versions of these +** routines that actually work. If the implementation does not provide working +** versions of these routines, it should at least provide stubs that always +** return true so that one does not get spurious assertion failures. +** +** If the argument to sqlite3_mutex_held() is a NULL pointer then +** the routine should return 1. This seems counter-intuitive since +** clearly the mutex cannot be held if it does not exist. But +** the reason the mutex does not exist is because the build is not +** using mutexes. And we do not want the assert() containing the +** call to sqlite3_mutex_held() to fail, so a non-zero return is +** the appropriate thing to do. The sqlite3_mutex_notheld() +** interface should also return 1 when given a NULL pointer. +*/ +#ifndef NDEBUG +SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); +SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); +#endif + +/* +** CAPI3REF: Mutex Types +** +** The [sqlite3_mutex_alloc()] interface takes a single argument +** which is one of these integer constants. +** +** The set of static mutexes may change from one SQLite release to the +** next. Applications that override the built-in mutex logic must be +** prepared to accommodate additional static mutexes. +*/ +#define SQLITE_MUTEX_FAST 0 +#define SQLITE_MUTEX_RECURSIVE 1 +#define SQLITE_MUTEX_STATIC_MAIN 2 +#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ +#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ +#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ +#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_randomness() */ +#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ +#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ +#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ +#define SQLITE_MUTEX_STATIC_APP1 8 /* For use by application */ +#define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */ +#define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */ +#define SQLITE_MUTEX_STATIC_VFS1 11 /* For use by built-in VFS */ +#define SQLITE_MUTEX_STATIC_VFS2 12 /* For use by extension VFS */ +#define SQLITE_MUTEX_STATIC_VFS3 13 /* For use by application VFS */ + +/* Legacy compatibility: */ +#define SQLITE_MUTEX_STATIC_MASTER 2 + + +/* +** CAPI3REF: Retrieve the mutex for a database connection +** METHOD: sqlite3 +** +** ^This interface returns a pointer to the [sqlite3_mutex] object that +** serializes access to the [database connection] given in the argument +** when the [threading mode] is Serialized. +** ^If the [threading mode] is Single-thread or Multi-thread then this +** routine returns a NULL pointer. +*/ +SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); + +/* +** CAPI3REF: Low-Level Control Of Database Files +** METHOD: sqlite3 +** KEYWORDS: {file control} +** +** ^The [sqlite3_file_control()] interface makes a direct call to the +** xFileControl method for the [sqlite3_io_methods] object associated +** with a particular database identified by the second argument. ^The +** name of the database is "main" for the main database or "temp" for the +** TEMP database, or the name that appears after the AS keyword for +** databases that are added using the [ATTACH] SQL command. +** ^A NULL pointer can be used in place of "main" to refer to the +** main database file. +** ^The third and fourth parameters to this routine +** are passed directly through to the second and third parameters of +** the xFileControl method. ^The return value of the xFileControl +** method becomes the return value of this routine. +** +** A few opcodes for [sqlite3_file_control()] are handled directly +** by the SQLite core and never invoke the +** sqlite3_io_methods.xFileControl method. +** ^The [SQLITE_FCNTL_FILE_POINTER] value for the op parameter causes +** a pointer to the underlying [sqlite3_file] object to be written into +** the space pointed to by the 4th parameter. The +** [SQLITE_FCNTL_JOURNAL_POINTER] works similarly except that it returns +** the [sqlite3_file] object associated with the journal file instead of +** the main database. The [SQLITE_FCNTL_VFS_POINTER] opcode returns +** a pointer to the underlying [sqlite3_vfs] object for the file. +** The [SQLITE_FCNTL_DATA_VERSION] returns the data version counter +** from the pager. +** +** ^If the second parameter (zDbName) does not match the name of any +** open database file, then SQLITE_ERROR is returned. ^This error +** code is not remembered and will not be recalled by [sqlite3_errcode()] +** or [sqlite3_errmsg()]. The underlying xFileControl method might +** also return SQLITE_ERROR. There is no way to distinguish between +** an incorrect zDbName and an SQLITE_ERROR return from the underlying +** xFileControl method. +** +** See also: [file control opcodes] +*/ +SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); + +/* +** CAPI3REF: Testing Interface +** +** ^The sqlite3_test_control() interface is used to read out internal +** state of SQLite and to inject faults into SQLite for testing +** purposes. ^The first parameter is an operation code that determines +** the number, meaning, and operation of all subsequent parameters. +** +** This interface is not for use by applications. It exists solely +** for verifying the correct operation of the SQLite library. Depending +** on how the SQLite library is compiled, this interface might not exist. +** +** The details of the operation codes, their meanings, the parameters +** they take, and what they do are all subject to change without notice. +** Unlike most of the SQLite API, this function is not guaranteed to +** operate consistently from one release to the next. +*/ +SQLITE_API int sqlite3_test_control(int op, ...); + +/* +** CAPI3REF: Testing Interface Operation Codes +** +** These constants are the valid operation code parameters used +** as the first argument to [sqlite3_test_control()]. +** +** These parameters and their meanings are subject to change +** without notice. These values are for testing purposes only. +** Applications should not use any of these parameters or the +** [sqlite3_test_control()] interface. +*/ +#define SQLITE_TESTCTRL_FIRST 5 +#define SQLITE_TESTCTRL_PRNG_SAVE 5 +#define SQLITE_TESTCTRL_PRNG_RESTORE 6 +#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ +#define SQLITE_TESTCTRL_FK_NO_ACTION 7 +#define SQLITE_TESTCTRL_BITVEC_TEST 8 +#define SQLITE_TESTCTRL_FAULT_INSTALL 9 +#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 +#define SQLITE_TESTCTRL_PENDING_BYTE 11 +#define SQLITE_TESTCTRL_ASSERT 12 +#define SQLITE_TESTCTRL_ALWAYS 13 +#define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */ +#define SQLITE_TESTCTRL_JSON_SELFCHECK 14 +#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 +#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ +#define SQLITE_TESTCTRL_GETOPT 16 +#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ +#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17 +#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 +#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */ +#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 19 +#define SQLITE_TESTCTRL_NEVER_CORRUPT 20 +#define SQLITE_TESTCTRL_VDBE_COVERAGE 21 +#define SQLITE_TESTCTRL_BYTEORDER 22 +#define SQLITE_TESTCTRL_ISINIT 23 +#define SQLITE_TESTCTRL_SORTER_MMAP 24 +#define SQLITE_TESTCTRL_IMPOSTER 25 +#define SQLITE_TESTCTRL_PARSER_COVERAGE 26 +#define SQLITE_TESTCTRL_RESULT_INTREAL 27 +#define SQLITE_TESTCTRL_PRNG_SEED 28 +#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 +#define SQLITE_TESTCTRL_SEEK_COUNT 30 +#define SQLITE_TESTCTRL_TRACEFLAGS 31 +#define SQLITE_TESTCTRL_TUNE 32 +#define SQLITE_TESTCTRL_LOGEST 33 +#define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */ +#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */ + +/* +** CAPI3REF: SQL Keyword Checking +** +** These routines provide access to the set of SQL language keywords +** recognized by SQLite. Applications can use these routines to determine +** whether or not a specific identifier needs to be escaped (for example, +** by enclosing in double-quotes) so as not to confuse the parser. +** +** The sqlite3_keyword_count() interface returns the number of distinct +** keywords understood by SQLite. +** +** The sqlite3_keyword_name(N,Z,L) interface finds the 0-based N-th keyword and +** makes *Z point to that keyword expressed as UTF8 and writes the number +** of bytes in the keyword into *L. The string that *Z points to is not +** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns +** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z +** or L are NULL or invalid pointers then calls to +** sqlite3_keyword_name(N,Z,L) result in undefined behavior. +** +** The sqlite3_keyword_check(Z,L) interface checks to see whether or not +** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero +** if it is and zero if not. +** +** The parser used by SQLite is forgiving. It is often possible to use +** a keyword as an identifier as long as such use does not result in a +** parsing ambiguity. For example, the statement +** "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and +** creates a new table named "BEGIN" with three columns named +** "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid +** using keywords as identifiers. Common techniques used to avoid keyword +** name collisions include: +**
    +**
  • Put all identifier names inside double-quotes. This is the official +** SQL way to escape identifier names. +**
  • Put identifier names inside [...]. This is not standard SQL, +** but it is what SQL Server does and so lots of programmers use this +** technique. +**
  • Begin every identifier with the letter "Z" as no SQL keywords start +** with "Z". +**
  • Include a digit somewhere in every identifier name. +**
+** +** Note that the number of keywords understood by SQLite can depend on +** compile-time options. For example, "VACUUM" is not a keyword if +** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option. Also, +** new keywords may be added to future releases of SQLite. +*/ +SQLITE_API int sqlite3_keyword_count(void); +SQLITE_API int sqlite3_keyword_name(int,const char**,int*); +SQLITE_API int sqlite3_keyword_check(const char*,int); + +/* +** CAPI3REF: Dynamic String Object +** KEYWORDS: {dynamic string} +** +** An instance of the sqlite3_str object contains a dynamically-sized +** string under construction. +** +** The lifecycle of an sqlite3_str object is as follows: +**
    +**
  1. ^The sqlite3_str object is created using [sqlite3_str_new()]. +**
  2. ^Text is appended to the sqlite3_str object using various +** methods, such as [sqlite3_str_appendf()]. +**
  3. ^The sqlite3_str object is destroyed and the string it created +** is returned using the [sqlite3_str_finish()] interface. +**
+*/ +typedef struct sqlite3_str sqlite3_str; + +/* +** CAPI3REF: Create A New Dynamic String Object +** CONSTRUCTOR: sqlite3_str +** +** ^The [sqlite3_str_new(D)] interface allocates and initializes +** a new [sqlite3_str] object. To avoid memory leaks, the object returned by +** [sqlite3_str_new()] must be freed by a subsequent call to +** [sqlite3_str_finish(X)]. +** +** ^The [sqlite3_str_new(D)] interface always returns a pointer to a +** valid [sqlite3_str] object, though in the event of an out-of-memory +** error the returned object might be a special singleton that will +** silently reject new text, always return SQLITE_NOMEM from +** [sqlite3_str_errcode()], always return 0 for +** [sqlite3_str_length()], and always return NULL from +** [sqlite3_str_finish(X)]. It is always safe to use the value +** returned by [sqlite3_str_new(D)] as the sqlite3_str parameter +** to any of the other [sqlite3_str] methods. +** +** The D parameter to [sqlite3_str_new(D)] may be NULL. If the +** D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum +** length of the string contained in the [sqlite3_str] object will be +** the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead +** of [SQLITE_MAX_LENGTH]. +*/ +SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*); + +/* +** CAPI3REF: Finalize A Dynamic String +** DESTRUCTOR: sqlite3_str +** +** ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X +** and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()] +** that contains the constructed string. The calling application should +** pass the returned value to [sqlite3_free()] to avoid a memory leak. +** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any +** errors were encountered during construction of the string. ^The +** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the +** string in [sqlite3_str] object X is zero bytes long. +*/ +SQLITE_API char *sqlite3_str_finish(sqlite3_str*); + +/* +** CAPI3REF: Add Content To A Dynamic String +** METHOD: sqlite3_str +** +** These interfaces add content to an sqlite3_str object previously obtained +** from [sqlite3_str_new()]. +** +** ^The [sqlite3_str_appendf(X,F,...)] and +** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf] +** functionality of SQLite to append formatted text onto the end of +** [sqlite3_str] object X. +** +** ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S +** onto the end of the [sqlite3_str] object X. N must be non-negative. +** S must contain at least N non-zero bytes of content. To append a +** zero-terminated string in its entirety, use the [sqlite3_str_appendall()] +** method instead. +** +** ^The [sqlite3_str_appendall(X,S)] method appends the complete content of +** zero-terminated string S onto the end of [sqlite3_str] object X. +** +** ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the +** single-byte character C onto the end of [sqlite3_str] object X. +** ^This method can be used, for example, to add whitespace indentation. +** +** ^The [sqlite3_str_reset(X)] method resets the string under construction +** inside [sqlite3_str] object X back to zero bytes in length. +** +** These methods do not return a result code. ^If an error occurs, that fact +** is recorded in the [sqlite3_str] object and can be recovered by a +** subsequent call to [sqlite3_str_errcode(X)]. +*/ +SQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...); +SQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list); +SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N); +SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn); +SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C); +SQLITE_API void sqlite3_str_reset(sqlite3_str*); + +/* +** CAPI3REF: Status Of A Dynamic String +** METHOD: sqlite3_str +** +** These interfaces return the current status of an [sqlite3_str] object. +** +** ^If any prior errors have occurred while constructing the dynamic string +** in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return +** an appropriate error code. ^The [sqlite3_str_errcode(X)] method returns +** [SQLITE_NOMEM] following any out-of-memory error, or +** [SQLITE_TOOBIG] if the size of the dynamic string exceeds +** [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors. +** +** ^The [sqlite3_str_length(X)] method returns the current length, in bytes, +** of the dynamic string under construction in [sqlite3_str] object X. +** ^The length returned by [sqlite3_str_length(X)] does not include the +** zero-termination byte. +** +** ^The [sqlite3_str_value(X)] method returns a pointer to the current +** content of the dynamic string under construction in X. The value +** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X +** and might be freed or altered by any subsequent method on the same +** [sqlite3_str] object. Applications must not use the pointer returned by +** [sqlite3_str_value(X)] after any subsequent method call on the same +** object. ^Applications may change the content of the string returned +** by [sqlite3_str_value(X)] as long as they do not write into any bytes +** outside the range of 0 to [sqlite3_str_length(X)] and do not read or +** write any byte after any subsequent sqlite3_str method call. +*/ +SQLITE_API int sqlite3_str_errcode(sqlite3_str*); +SQLITE_API int sqlite3_str_length(sqlite3_str*); +SQLITE_API char *sqlite3_str_value(sqlite3_str*); + +/* +** CAPI3REF: SQLite Runtime Status +** +** ^These interfaces are used to retrieve runtime status information +** about the performance of SQLite, and optionally to reset various +** highwater marks. ^The first argument is an integer code for +** the specific parameter to measure. ^(Recognized integer codes +** are of the form [status parameters | SQLITE_STATUS_...].)^ +** ^The current value of the parameter is returned into *pCurrent. +** ^The highest recorded value is returned in *pHighwater. ^If the +** resetFlag is true, then the highest record value is reset after +** *pHighwater is written. ^(Some parameters do not record the highest +** value. For those parameters +** nothing is written into *pHighwater and the resetFlag is ignored.)^ +** ^(Other parameters record only the highwater mark and not the current +** value. For these latter parameters nothing is written into *pCurrent.)^ +** +** ^The sqlite3_status() and sqlite3_status64() routines return +** SQLITE_OK on success and a non-zero [error code] on failure. +** +** If either the current value or the highwater mark is too large to +** be represented by a 32-bit integer, then the values returned by +** sqlite3_status() are undefined. +** +** See also: [sqlite3_db_status()] +*/ +SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); +SQLITE_API int sqlite3_status64( + int op, + sqlite3_int64 *pCurrent, + sqlite3_int64 *pHighwater, + int resetFlag +); + + +/* +** CAPI3REF: Status Parameters +** KEYWORDS: {status parameters} +** +** These integer constants designate various run-time status parameters +** that can be returned by [sqlite3_status()]. +** +**
+** [[SQLITE_STATUS_MEMORY_USED]] ^(
SQLITE_STATUS_MEMORY_USED
+**
This parameter is the current amount of memory checked out +** using [sqlite3_malloc()], either directly or indirectly. The +** figure includes calls made to [sqlite3_malloc()] by the application +** and internal memory usage by the SQLite library. Auxiliary page-cache +** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in +** this parameter. The amount returned is the sum of the allocation +** sizes as reported by the xSize method in [sqlite3_mem_methods].
)^ +** +** [[SQLITE_STATUS_MALLOC_SIZE]] ^(
SQLITE_STATUS_MALLOC_SIZE
+**
This parameter records the largest memory allocation request +** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their +** internal equivalents). Only the value returned in the +** *pHighwater parameter to [sqlite3_status()] is of interest. +** The value written into the *pCurrent parameter is undefined.
)^ +** +** [[SQLITE_STATUS_MALLOC_COUNT]] ^(
SQLITE_STATUS_MALLOC_COUNT
+**
This parameter records the number of separate memory allocations +** currently checked out.
)^ +** +** [[SQLITE_STATUS_PAGECACHE_USED]] ^(
SQLITE_STATUS_PAGECACHE_USED
+**
This parameter returns the number of pages used out of the +** [pagecache memory allocator] that was configured using +** [SQLITE_CONFIG_PAGECACHE]. The +** value returned is in pages, not in bytes.
)^ +** +** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] +** ^(
SQLITE_STATUS_PAGECACHE_OVERFLOW
+**
This parameter returns the number of bytes of page cache +** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] +** buffer and where forced to overflow to [sqlite3_malloc()]. The +** returned value includes allocations that overflowed because they +** were too large (they were larger than the "sz" parameter to +** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because +** no space was left in the page cache.
)^ +** +** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
SQLITE_STATUS_PAGECACHE_SIZE
+**
This parameter records the largest memory allocation request +** handed to the [pagecache memory allocator]. Only the value returned in the +** *pHighwater parameter to [sqlite3_status()] is of interest. +** The value written into the *pCurrent parameter is undefined.
)^ +** +** [[SQLITE_STATUS_SCRATCH_USED]]
SQLITE_STATUS_SCRATCH_USED
+**
No longer used.
+** +** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(
SQLITE_STATUS_SCRATCH_OVERFLOW
+**
No longer used.
+** +** [[SQLITE_STATUS_SCRATCH_SIZE]]
SQLITE_STATUS_SCRATCH_SIZE
+**
No longer used.
+** +** [[SQLITE_STATUS_PARSER_STACK]] ^(
SQLITE_STATUS_PARSER_STACK
+**
The *pHighwater parameter records the deepest parser stack. +** The *pCurrent value is undefined. The *pHighwater value is only +** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
)^ +**
+** +** New status parameters may be added from time to time. +*/ +#define SQLITE_STATUS_MEMORY_USED 0 +#define SQLITE_STATUS_PAGECACHE_USED 1 +#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 +#define SQLITE_STATUS_SCRATCH_USED 3 /* NOT USED */ +#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 /* NOT USED */ +#define SQLITE_STATUS_MALLOC_SIZE 5 +#define SQLITE_STATUS_PARSER_STACK 6 +#define SQLITE_STATUS_PAGECACHE_SIZE 7 +#define SQLITE_STATUS_SCRATCH_SIZE 8 /* NOT USED */ +#define SQLITE_STATUS_MALLOC_COUNT 9 + +/* +** CAPI3REF: Database Connection Status +** METHOD: sqlite3 +** +** ^This interface is used to retrieve runtime status information +** about a single [database connection]. ^The first argument is the +** database connection object to be interrogated. ^The second argument +** is an integer constant, taken from the set of +** [SQLITE_DBSTATUS options], that +** determines the parameter to interrogate. The set of +** [SQLITE_DBSTATUS options] is likely +** to grow in future releases of SQLite. +** +** ^The current value of the requested parameter is written into *pCur +** and the highest instantaneous value is written into *pHiwtr. ^If +** the resetFlg is true, then the highest instantaneous value is +** reset back down to the current value. +** +** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a +** non-zero [error code] on failure. +** +** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. +*/ +SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); + +/* +** CAPI3REF: Status Parameters for database connections +** KEYWORDS: {SQLITE_DBSTATUS options} +** +** These constants are the available integer "verbs" that can be passed as +** the second argument to the [sqlite3_db_status()] interface. +** +** New verbs may be added in future releases of SQLite. Existing verbs +** might be discontinued. Applications should check the return code from +** [sqlite3_db_status()] to make sure that the call worked. +** The [sqlite3_db_status()] interface will return a non-zero error code +** if a discontinued or unsupported verb is invoked. +** +**
+** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(
SQLITE_DBSTATUS_LOOKASIDE_USED
+**
This parameter returns the number of lookaside memory slots currently +** checked out.
)^ +** +** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
SQLITE_DBSTATUS_LOOKASIDE_HIT
+**
This parameter returns the number of malloc attempts that were +** satisfied using lookaside memory. Only the high-water value is meaningful; +** the current value is always zero.
)^ +** +** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] +** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
+**
This parameter returns the number of malloc attempts that might have +** been satisfied using lookaside memory but failed due to the amount of +** memory requested being larger than the lookaside slot size. +** Only the high-water value is meaningful; +** the current value is always zero.
)^ +** +** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] +** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
+**
This parameter returns the number of malloc attempts that might have +** been satisfied using lookaside memory but failed due to all lookaside +** memory already being in use. +** Only the high-water value is meaningful; +** the current value is always zero.
)^ +** +** [[SQLITE_DBSTATUS_CACHE_USED]] ^(
SQLITE_DBSTATUS_CACHE_USED
+**
This parameter returns the approximate number of bytes of heap +** memory used by all pager caches associated with the database connection.)^ +** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. +**
+** +** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] +** ^(
SQLITE_DBSTATUS_CACHE_USED_SHARED
+**
This parameter is similar to DBSTATUS_CACHE_USED, except that if a +** pager cache is shared between two or more connections the bytes of heap +** memory used by that pager cache is divided evenly between the attached +** connections.)^ In other words, if none of the pager caches associated +** with the database connection are shared, this request returns the same +** value as DBSTATUS_CACHE_USED. Or, if one or more of the pager caches are +** shared, the value returned by this call will be smaller than that returned +** by DBSTATUS_CACHE_USED. ^The highwater mark associated with +** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
+** +** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
SQLITE_DBSTATUS_SCHEMA_USED
+**
This parameter returns the approximate number of bytes of heap +** memory used to store the schema for all databases associated +** with the connection - main, temp, and any [ATTACH]-ed databases.)^ +** ^The full amount of memory used by the schemas is reported, even if the +** schema memory is shared with other database connections due to +** [shared cache mode] being enabled. +** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. +**
+** +** [[SQLITE_DBSTATUS_STMT_USED]] ^(
SQLITE_DBSTATUS_STMT_USED
+**
This parameter returns the approximate number of bytes of heap +** and lookaside memory used by all prepared statements associated with +** the database connection.)^ +** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. +**
+** +** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(
SQLITE_DBSTATUS_CACHE_HIT
+**
This parameter returns the number of pager cache hits that have +** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT +** is always 0. +**
+** +** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(
SQLITE_DBSTATUS_CACHE_MISS
+**
This parameter returns the number of pager cache misses that have +** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS +** is always 0. +**
+** +** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(
SQLITE_DBSTATUS_CACHE_WRITE
+**
This parameter returns the number of dirty cache entries that have +** been written to disk. Specifically, the number of pages written to the +** wal file in wal mode databases, or the number of pages written to the +** database file in rollback mode databases. Any pages written as part of +** transaction rollback or database recovery operations are not included. +** If an IO or other error occurs while writing a page to disk, the effect +** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The +** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0. +**
+** +** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(
SQLITE_DBSTATUS_CACHE_SPILL
+**
This parameter returns the number of dirty cache entries that have +** been written to disk in the middle of a transaction due to the page +** cache overflowing. Transactions are more efficient if they are written +** to disk all at once. When pages spill mid-transaction, that introduces +** additional overhead. This parameter can be used to help identify +** inefficiencies that can be resolved by increasing the cache size. +**
+** +** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(
SQLITE_DBSTATUS_DEFERRED_FKS
+**
This parameter returns zero for the current value if and only if +** all foreign key constraints (deferred or immediate) have been +** resolved.)^ ^The highwater mark is always 0. +**
+**
+*/ +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 +#define SQLITE_DBSTATUS_CACHE_USED 1 +#define SQLITE_DBSTATUS_SCHEMA_USED 2 +#define SQLITE_DBSTATUS_STMT_USED 3 +#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 +#define SQLITE_DBSTATUS_CACHE_HIT 7 +#define SQLITE_DBSTATUS_CACHE_MISS 8 +#define SQLITE_DBSTATUS_CACHE_WRITE 9 +#define SQLITE_DBSTATUS_DEFERRED_FKS 10 +#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11 +#define SQLITE_DBSTATUS_CACHE_SPILL 12 +#define SQLITE_DBSTATUS_MAX 12 /* Largest defined DBSTATUS */ + + +/* +** CAPI3REF: Prepared Statement Status +** METHOD: sqlite3_stmt +** +** ^(Each prepared statement maintains various +** [SQLITE_STMTSTATUS counters] that measure the number +** of times it has performed specific operations.)^ These counters can +** be used to monitor the performance characteristics of the prepared +** statements. For example, if the number of table steps greatly exceeds +** the number of table searches or result rows, that would tend to indicate +** that the prepared statement is using a full table scan rather than +** an index. +** +** ^(This interface is used to retrieve and reset counter values from +** a [prepared statement]. The first argument is the prepared statement +** object to be interrogated. The second argument +** is an integer code for a specific [SQLITE_STMTSTATUS counter] +** to be interrogated.)^ +** ^The current value of the requested counter is returned. +** ^If the resetFlg is true, then the counter is reset to zero after this +** interface call returns. +** +** See also: [sqlite3_status()] and [sqlite3_db_status()]. +*/ +SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); + +/* +** CAPI3REF: Status Parameters for prepared statements +** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} +** +** These preprocessor macros define integer codes that name counter +** values associated with the [sqlite3_stmt_status()] interface. +** The meanings of the various counters are as follows: +** +**
+** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]]
SQLITE_STMTSTATUS_FULLSCAN_STEP
+**
^This is the number of times that SQLite has stepped forward in +** a table as part of a full table scan. Large numbers for this counter +** may indicate opportunities for performance improvement through +** careful use of indices.
+** +** [[SQLITE_STMTSTATUS_SORT]]
SQLITE_STMTSTATUS_SORT
+**
^This is the number of sort operations that have occurred. +** A non-zero value in this counter may indicate an opportunity to +** improve performance through careful use of indices.
+** +** [[SQLITE_STMTSTATUS_AUTOINDEX]]
SQLITE_STMTSTATUS_AUTOINDEX
+**
^This is the number of rows inserted into transient indices that +** were created automatically in order to help joins run faster. +** A non-zero value in this counter may indicate an opportunity to +** improve performance by adding permanent indices that do not +** need to be reinitialized each time the statement is run.
+** +** [[SQLITE_STMTSTATUS_VM_STEP]]
SQLITE_STMTSTATUS_VM_STEP
+**
^This is the number of virtual machine operations executed +** by the prepared statement if that number is less than or equal +** to 2147483647. The number of virtual machine operations can be +** used as a proxy for the total work done by the prepared statement. +** If the number of virtual machine operations exceeds 2147483647 +** then the value returned by this statement status code is undefined.
+** +** [[SQLITE_STMTSTATUS_REPREPARE]]
SQLITE_STMTSTATUS_REPREPARE
+**
^This is the number of times that the prepare statement has been +** automatically regenerated due to schema changes or changes to +** [bound parameters] that might affect the query plan.
+** +** [[SQLITE_STMTSTATUS_RUN]]
SQLITE_STMTSTATUS_RUN
+**
^This is the number of times that the prepared statement has +** been run. A single "run" for the purposes of this counter is one +** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. +** The counter is incremented on the first [sqlite3_step()] call of each +** cycle.
+** +** [[SQLITE_STMTSTATUS_FILTER_MISS]] +** [[SQLITE_STMTSTATUS_FILTER HIT]] +**
SQLITE_STMTSTATUS_FILTER_HIT
+** SQLITE_STMTSTATUS_FILTER_MISS
+**
^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join +** step was bypassed because a Bloom filter returned not-found. The +** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of +** times that the Bloom filter returned a find, and thus the join step +** had to be processed as normal.
+** +** [[SQLITE_STMTSTATUS_MEMUSED]]
SQLITE_STMTSTATUS_MEMUSED
+**
^This is the approximate number of bytes of heap memory +** used to store the prepared statement. ^This value is not actually +** a counter, and so the resetFlg parameter to sqlite3_stmt_status() +** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED. +**
+**
+*/ +#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 +#define SQLITE_STMTSTATUS_SORT 2 +#define SQLITE_STMTSTATUS_AUTOINDEX 3 +#define SQLITE_STMTSTATUS_VM_STEP 4 +#define SQLITE_STMTSTATUS_REPREPARE 5 +#define SQLITE_STMTSTATUS_RUN 6 +#define SQLITE_STMTSTATUS_FILTER_MISS 7 +#define SQLITE_STMTSTATUS_FILTER_HIT 8 +#define SQLITE_STMTSTATUS_MEMUSED 99 + +/* +** CAPI3REF: Custom Page Cache Object +** +** The sqlite3_pcache type is opaque. It is implemented by +** the pluggable module. The SQLite core has no knowledge of +** its size or internal structure and never deals with the +** sqlite3_pcache object except by holding and passing pointers +** to the object. +** +** See [sqlite3_pcache_methods2] for additional information. +*/ +typedef struct sqlite3_pcache sqlite3_pcache; + +/* +** CAPI3REF: Custom Page Cache Object +** +** The sqlite3_pcache_page object represents a single page in the +** page cache. The page cache will allocate instances of this +** object. Various methods of the page cache use pointers to instances +** of this object as parameters or as their return value. +** +** See [sqlite3_pcache_methods2] for additional information. +*/ +typedef struct sqlite3_pcache_page sqlite3_pcache_page; +struct sqlite3_pcache_page { + void *pBuf; /* The content of the page */ + void *pExtra; /* Extra information associated with the page */ +}; + +/* +** CAPI3REF: Application Defined Page Cache. +** KEYWORDS: {page cache} +** +** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can +** register an alternative page cache implementation by passing in an +** instance of the sqlite3_pcache_methods2 structure.)^ +** In many applications, most of the heap memory allocated by +** SQLite is used for the page cache. +** By implementing a +** custom page cache using this API, an application can better control +** the amount of memory consumed by SQLite, the way in which +** that memory is allocated and released, and the policies used to +** determine exactly which parts of a database file are cached and for +** how long. +** +** The alternative page cache mechanism is an +** extreme measure that is only needed by the most demanding applications. +** The built-in page cache is recommended for most uses. +** +** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an +** internal buffer by SQLite within the call to [sqlite3_config]. Hence +** the application may discard the parameter after the call to +** [sqlite3_config()] returns.)^ +** +** [[the xInit() page cache method]] +** ^(The xInit() method is called once for each effective +** call to [sqlite3_initialize()])^ +** (usually only once during the lifetime of the process). ^(The xInit() +** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ +** The intent of the xInit() method is to set up global data structures +** required by the custom page cache implementation. +** ^(If the xInit() method is NULL, then the +** built-in default page cache is used instead of the application defined +** page cache.)^ +** +** [[the xShutdown() page cache method]] +** ^The xShutdown() method is called by [sqlite3_shutdown()]. +** It can be used to clean up +** any outstanding resources before process shutdown, if required. +** ^The xShutdown() method may be NULL. +** +** ^SQLite automatically serializes calls to the xInit method, +** so the xInit method need not be threadsafe. ^The +** xShutdown method is only called from [sqlite3_shutdown()] so it does +** not need to be threadsafe either. All other methods must be threadsafe +** in multithreaded applications. +** +** ^SQLite will never invoke xInit() more than once without an intervening +** call to xShutdown(). +** +** [[the xCreate() page cache methods]] +** ^SQLite invokes the xCreate() method to construct a new cache instance. +** SQLite will typically create one cache instance for each open database file, +** though this is not guaranteed. ^The +** first parameter, szPage, is the size in bytes of the pages that must +** be allocated by the cache. ^szPage will always be a power of two. ^The +** second parameter szExtra is a number of bytes of extra storage +** associated with each page cache entry. ^The szExtra parameter will be +** a number less than 250. SQLite will use the +** extra szExtra bytes on each page to store metadata about the underlying +** database page on disk. The value passed into szExtra depends +** on the SQLite version, the target platform, and how SQLite was compiled. +** ^The third argument to xCreate(), bPurgeable, is true if the cache being +** created will be used to cache database pages of a file stored on disk, or +** false if it is used for an in-memory database. The cache implementation +** does not have to do anything special based upon the value of bPurgeable; +** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will +** never invoke xUnpin() except to deliberately delete a page. +** ^In other words, calls to xUnpin() on a cache with bPurgeable set to +** false will always have the "discard" flag set to true. +** ^Hence, a cache created with bPurgeable set to false will +** never contain any unpinned pages. +** +** [[the xCachesize() page cache method]] +** ^(The xCachesize() method may be called at any time by SQLite to set the +** suggested maximum cache-size (number of pages stored) for the cache +** instance passed as the first argument. This is the value configured using +** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable +** parameter, the implementation is not required to do anything with this +** value; it is advisory only. +** +** [[the xPagecount() page cache methods]] +** The xPagecount() method must return the number of pages currently +** stored in the cache, both pinned and unpinned. +** +** [[the xFetch() page cache methods]] +** The xFetch() method locates a page in the cache and returns a pointer to +** an sqlite3_pcache_page object associated with that page, or a NULL pointer. +** The pBuf element of the returned sqlite3_pcache_page object will be a +** pointer to a buffer of szPage bytes used to store the content of a +** single database page. The pExtra element of sqlite3_pcache_page will be +** a pointer to the szExtra bytes of extra storage that SQLite has requested +** for each entry in the page cache. +** +** The page to be fetched is determined by the key. ^The minimum key value +** is 1. After it has been retrieved using xFetch, the page is considered +** to be "pinned". +** +** If the requested page is already in the page cache, then the page cache +** implementation must return a pointer to the page buffer with its content +** intact. If the requested page is not already in the cache, then the +** cache implementation should use the value of the createFlag +** parameter to help it determine what action to take: +** +** +**
createFlag Behavior when page is not already in cache +**
0 Do not allocate a new page. Return NULL. +**
1 Allocate a new page if it is easy and convenient to do so. +** Otherwise return NULL. +**
2 Make every effort to allocate a new page. Only return +** NULL if allocating a new page is effectively impossible. +**
+** +** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite +** will only use a createFlag of 2 after a prior call with a createFlag of 1 +** failed.)^ In between the xFetch() calls, SQLite may +** attempt to unpin one or more cache pages by spilling the content of +** pinned pages to disk and synching the operating system disk cache. +** +** [[the xUnpin() page cache method]] +** ^xUnpin() is called by SQLite with a pointer to a currently pinned page +** as its second argument. If the third parameter, discard, is non-zero, +** then the page must be evicted from the cache. +** ^If the discard parameter is +** zero, then the page may be discarded or retained at the discretion of the +** page cache implementation. ^The page cache implementation +** may choose to evict unpinned pages at any time. +** +** The cache must not perform any reference counting. A single +** call to xUnpin() unpins the page regardless of the number of prior calls +** to xFetch(). +** +** [[the xRekey() page cache methods]] +** The xRekey() method is used to change the key value associated with the +** page passed as the second argument. If the cache +** previously contains an entry associated with newKey, it must be +** discarded. ^Any prior cache entry associated with newKey is guaranteed not +** to be pinned. +** +** When SQLite calls the xTruncate() method, the cache must discard all +** existing cache entries with page numbers (keys) greater than or equal +** to the value of the iLimit parameter passed to xTruncate(). If any +** of these pages are pinned, they become implicitly unpinned, meaning that +** they can be safely discarded. +** +** [[the xDestroy() page cache method]] +** ^The xDestroy() method is used to delete a cache allocated by xCreate(). +** All resources associated with the specified cache should be freed. ^After +** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] +** handle invalid, and will not use it with any other sqlite3_pcache_methods2 +** functions. +** +** [[the xShrink() page cache method]] +** ^SQLite invokes the xShrink() method when it wants the page cache to +** free up as much of heap memory as possible. The page cache implementation +** is not obligated to free any memory, but well-behaved implementations should +** do their best. +*/ +typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2; +struct sqlite3_pcache_methods2 { + int iVersion; + void *pArg; + int (*xInit)(void*); + void (*xShutdown)(void*); + sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable); + void (*xCachesize)(sqlite3_pcache*, int nCachesize); + int (*xPagecount)(sqlite3_pcache*); + sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard); + void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, + unsigned oldKey, unsigned newKey); + void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + void (*xDestroy)(sqlite3_pcache*); + void (*xShrink)(sqlite3_pcache*); +}; + +/* +** This is the obsolete pcache_methods object that has now been replaced +** by sqlite3_pcache_methods2. This object is not used by SQLite. It is +** retained in the header file for backwards compatibility only. +*/ +typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; +struct sqlite3_pcache_methods { + void *pArg; + int (*xInit)(void*); + void (*xShutdown)(void*); + sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); + void (*xCachesize)(sqlite3_pcache*, int nCachesize); + int (*xPagecount)(sqlite3_pcache*); + void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + void (*xUnpin)(sqlite3_pcache*, void*, int discard); + void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); + void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + void (*xDestroy)(sqlite3_pcache*); +}; + + +/* +** CAPI3REF: Online Backup Object +** +** The sqlite3_backup object records state information about an ongoing +** online backup operation. ^The sqlite3_backup object is created by +** a call to [sqlite3_backup_init()] and is destroyed by a call to +** [sqlite3_backup_finish()]. +** +** See Also: [Using the SQLite Online Backup API] +*/ +typedef struct sqlite3_backup sqlite3_backup; + +/* +** CAPI3REF: Online Backup API. +** +** The backup API copies the content of one database into another. +** It is useful either for creating backups of databases or +** for copying in-memory databases to or from persistent files. +** +** See Also: [Using the SQLite Online Backup API] +** +** ^SQLite holds a write transaction open on the destination database file +** for the duration of the backup operation. +** ^The source database is read-locked only while it is being read; +** it is not locked continuously for the entire backup operation. +** ^Thus, the backup may be performed on a live source database without +** preventing other database connections from +** reading or writing to the source database while the backup is underway. +** +** ^(To perform a backup operation: +**
    +**
  1. sqlite3_backup_init() is called once to initialize the +** backup, +**
  2. sqlite3_backup_step() is called one or more times to transfer +** the data between the two databases, and finally +**
  3. sqlite3_backup_finish() is called to release all resources +** associated with the backup operation. +**
)^ +** There should be exactly one call to sqlite3_backup_finish() for each +** successful call to sqlite3_backup_init(). +** +** [[sqlite3_backup_init()]] sqlite3_backup_init() +** +** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the +** [database connection] associated with the destination database +** and the database name, respectively. +** ^The database name is "main" for the main database, "temp" for the +** temporary database, or the name specified after the AS keyword in +** an [ATTACH] statement for an attached database. +** ^The S and M arguments passed to +** sqlite3_backup_init(D,N,S,M) identify the [database connection] +** and database name of the source database, respectively. +** ^The source and destination [database connections] (parameters S and D) +** must be different or else sqlite3_backup_init(D,N,S,M) will fail with +** an error. +** +** ^A call to sqlite3_backup_init() will fail, returning NULL, if +** there is already a read or read-write transaction open on the +** destination database. +** +** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is +** returned and an error code and error message are stored in the +** destination [database connection] D. +** ^The error code and message for the failed call to sqlite3_backup_init() +** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or +** [sqlite3_errmsg16()] functions. +** ^A successful call to sqlite3_backup_init() returns a pointer to an +** [sqlite3_backup] object. +** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and +** sqlite3_backup_finish() functions to perform the specified backup +** operation. +** +** [[sqlite3_backup_step()]] sqlite3_backup_step() +** +** ^Function sqlite3_backup_step(B,N) will copy up to N pages between +** the source and destination databases specified by [sqlite3_backup] object B. +** ^If N is negative, all remaining source pages are copied. +** ^If sqlite3_backup_step(B,N) successfully copies N pages and there +** are still more pages to be copied, then the function returns [SQLITE_OK]. +** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages +** from source to destination, then it returns [SQLITE_DONE]. +** ^If an error occurs while running sqlite3_backup_step(B,N), +** then an [error code] is returned. ^As well as [SQLITE_OK] and +** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], +** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an +** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. +** +** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if +**
    +**
  1. the destination database was opened read-only, or +**
  2. the destination database is using write-ahead-log journaling +** and the destination and source page sizes differ, or +**
  3. the destination database is an in-memory database and the +** destination and source page sizes differ. +**
)^ +** +** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then +** the [sqlite3_busy_handler | busy-handler function] +** is invoked (if one is specified). ^If the +** busy-handler returns non-zero before the lock is available, then +** [SQLITE_BUSY] is returned to the caller. ^In this case the call to +** sqlite3_backup_step() can be retried later. ^If the source +** [database connection] +** is being used to write to the source database when sqlite3_backup_step() +** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this +** case the call to sqlite3_backup_step() can be retried later on. ^(If +** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or +** [SQLITE_READONLY] is returned, then +** there is no point in retrying the call to sqlite3_backup_step(). These +** errors are considered fatal.)^ The application must accept +** that the backup operation has failed and pass the backup operation handle +** to the sqlite3_backup_finish() to release associated resources. +** +** ^The first call to sqlite3_backup_step() obtains an exclusive lock +** on the destination file. ^The exclusive lock is not released until either +** sqlite3_backup_finish() is called or the backup operation is complete +** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to +** sqlite3_backup_step() obtains a [shared lock] on the source database that +** lasts for the duration of the sqlite3_backup_step() call. +** ^Because the source database is not locked between calls to +** sqlite3_backup_step(), the source database may be modified mid-way +** through the backup process. ^If the source database is modified by an +** external process or via a database connection other than the one being +** used by the backup operation, then the backup will be automatically +** restarted by the next call to sqlite3_backup_step(). ^If the source +** database is modified by using the same database connection as is used +** by the backup operation, then the backup database is automatically +** updated at the same time. +** +** [[sqlite3_backup_finish()]] sqlite3_backup_finish() +** +** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the +** application wishes to abandon the backup operation, the application +** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). +** ^The sqlite3_backup_finish() interfaces releases all +** resources associated with the [sqlite3_backup] object. +** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any +** active write-transaction on the destination database is rolled back. +** The [sqlite3_backup] object is invalid +** and may not be used following a call to sqlite3_backup_finish(). +** +** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no +** sqlite3_backup_step() errors occurred, regardless of whether or not +** sqlite3_backup_step() completed. +** ^If an out-of-memory condition or IO error occurred during any prior +** sqlite3_backup_step() call on the same [sqlite3_backup] object, then +** sqlite3_backup_finish() returns the corresponding [error code]. +** +** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() +** is not a permanent error and does not affect the return value of +** sqlite3_backup_finish(). +** +** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]] +** sqlite3_backup_remaining() and sqlite3_backup_pagecount() +** +** ^The sqlite3_backup_remaining() routine returns the number of pages still +** to be backed up at the conclusion of the most recent sqlite3_backup_step(). +** ^The sqlite3_backup_pagecount() routine returns the total number of pages +** in the source database at the conclusion of the most recent +** sqlite3_backup_step(). +** ^(The values returned by these functions are only updated by +** sqlite3_backup_step(). If the source database is modified in a way that +** changes the size of the source database or the number of pages remaining, +** those changes are not reflected in the output of sqlite3_backup_pagecount() +** and sqlite3_backup_remaining() until after the next +** sqlite3_backup_step().)^ +** +** Concurrent Usage of Database Handles +** +** ^The source [database connection] may be used by the application for other +** purposes while a backup operation is underway or being initialized. +** ^If SQLite is compiled and configured to support threadsafe database +** connections, then the source database connection may be used concurrently +** from within other threads. +** +** However, the application must guarantee that the destination +** [database connection] is not passed to any other API (by any thread) after +** sqlite3_backup_init() is called and before the corresponding call to +** sqlite3_backup_finish(). SQLite does not currently check to see +** if the application incorrectly accesses the destination [database connection] +** and so no error code is reported, but the operations may malfunction +** nevertheless. Use of the destination database connection while a +** backup is in progress might also cause a mutex deadlock. +** +** If running in [shared cache mode], the application must +** guarantee that the shared cache used by the destination database +** is not accessed while the backup is running. In practice this means +** that the application must guarantee that the disk file being +** backed up to is not accessed by any connection within the process, +** not just the specific connection that was passed to sqlite3_backup_init(). +** +** The [sqlite3_backup] object itself is partially threadsafe. Multiple +** threads may safely make multiple concurrent calls to sqlite3_backup_step(). +** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() +** APIs are not strictly speaking threadsafe. If they are invoked at the +** same time as another thread is invoking sqlite3_backup_step() it is +** possible that they return invalid values. +** +** Alternatives To Using The Backup API +** +** Other techniques for safely creating a consistent backup of an SQLite +** database include: +** +**
    +**
  • The [VACUUM INTO] command. +**
  • The [sqlite3_rsync] utility program. +**
+*/ +SQLITE_API sqlite3_backup *sqlite3_backup_init( + sqlite3 *pDest, /* Destination database handle */ + const char *zDestName, /* Destination database name */ + sqlite3 *pSource, /* Source database handle */ + const char *zSourceName /* Source database name */ +); +SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); +SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); +SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); +SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); + +/* +** CAPI3REF: Unlock Notification +** METHOD: sqlite3 +** +** ^When running in shared-cache mode, a database operation may fail with +** an [SQLITE_LOCKED] error if the required locks on the shared-cache or +** individual tables within the shared-cache cannot be obtained. See +** [SQLite Shared-Cache Mode] for a description of shared-cache locking. +** ^This API may be used to register a callback that SQLite will invoke +** when the connection currently holding the required lock relinquishes it. +** ^This API is only available if the library was compiled with the +** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. +** +** See Also: [Using the SQLite Unlock Notification Feature]. +** +** ^Shared-cache locks are released when a database connection concludes +** its current transaction, either by committing it or rolling it back. +** +** ^When a connection (known as the blocked connection) fails to obtain a +** shared-cache lock and SQLITE_LOCKED is returned to the caller, the +** identity of the database connection (the blocking connection) that +** has locked the required resource is stored internally. ^After an +** application receives an SQLITE_LOCKED error, it may call the +** sqlite3_unlock_notify() method with the blocked connection handle as +** the first argument to register for a callback that will be invoked +** when the blocking connection's current transaction is concluded. ^The +** callback is invoked from within the [sqlite3_step] or [sqlite3_close] +** call that concludes the blocking connection's transaction. +** +** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, +** there is a chance that the blocking connection will have already +** concluded its transaction by the time sqlite3_unlock_notify() is invoked. +** If this happens, then the specified callback is invoked immediately, +** from within the call to sqlite3_unlock_notify().)^ +** +** ^If the blocked connection is attempting to obtain a write-lock on a +** shared-cache table, and more than one other connection currently holds +** a read-lock on the same table, then SQLite arbitrarily selects one of +** the other connections to use as the blocking connection. +** +** ^(There may be at most one unlock-notify callback registered by a +** blocked connection. If sqlite3_unlock_notify() is called when the +** blocked connection already has a registered unlock-notify callback, +** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is +** called with a NULL pointer as its second argument, then any existing +** unlock-notify callback is canceled. ^The blocked connection's +** unlock-notify callback may also be canceled by closing the blocked +** connection using [sqlite3_close()]. +** +** The unlock-notify callback is not reentrant. If an application invokes +** any sqlite3_xxx API functions from within an unlock-notify callback, a +** crash or deadlock may be the result. +** +** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always +** returns SQLITE_OK. +** +** Callback Invocation Details +** +** When an unlock-notify callback is registered, the application provides a +** single void* pointer that is passed to the callback when it is invoked. +** However, the signature of the callback function allows SQLite to pass +** it an array of void* context pointers. The first argument passed to +** an unlock-notify callback is a pointer to an array of void* pointers, +** and the second is the number of entries in the array. +** +** When a blocking connection's transaction is concluded, there may be +** more than one blocked connection that has registered for an unlock-notify +** callback. ^If two or more such blocked connections have specified the +** same callback function, then instead of invoking the callback function +** multiple times, it is invoked once with the set of void* context pointers +** specified by the blocked connections bundled together into an array. +** This gives the application an opportunity to prioritize any actions +** related to the set of unblocked database connections. +** +** Deadlock Detection +** +** Assuming that after registering for an unlock-notify callback a +** database waits for the callback to be issued before taking any further +** action (a reasonable assumption), then using this API may cause the +** application to deadlock. For example, if connection X is waiting for +** connection Y's transaction to be concluded, and similarly connection +** Y is waiting on connection X's transaction, then neither connection +** will proceed and the system may remain deadlocked indefinitely. +** +** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock +** detection. ^If a given call to sqlite3_unlock_notify() would put the +** system in a deadlocked state, then SQLITE_LOCKED is returned and no +** unlock-notify callback is registered. The system is said to be in +** a deadlocked state if connection A has registered for an unlock-notify +** callback on the conclusion of connection B's transaction, and connection +** B has itself registered for an unlock-notify callback when connection +** A's transaction is concluded. ^Indirect deadlock is also detected, so +** the system is also considered to be deadlocked if connection B has +** registered for an unlock-notify callback on the conclusion of connection +** C's transaction, where connection C is waiting on connection A. ^Any +** number of levels of indirection are allowed. +** +** The "DROP TABLE" Exception +** +** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost +** always appropriate to call sqlite3_unlock_notify(). There is however, +** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, +** SQLite checks if there are any currently executing SELECT statements +** that belong to the same connection. If there are, SQLITE_LOCKED is +** returned. In this case there is no "blocking connection", so invoking +** sqlite3_unlock_notify() results in the unlock-notify callback being +** invoked immediately. If the application then re-attempts the "DROP TABLE" +** or "DROP INDEX" query, an infinite loop might be the result. +** +** One way around this problem is to check the extended error code returned +** by an sqlite3_step() call. ^(If there is a blocking connection, then the +** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in +** the special "DROP TABLE/INDEX" case, the extended error code is just +** SQLITE_LOCKED.)^ +*/ +SQLITE_API int sqlite3_unlock_notify( + sqlite3 *pBlocked, /* Waiting connection */ + void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ + void *pNotifyArg /* Argument to pass to xNotify */ +); + + +/* +** CAPI3REF: String Comparison +** +** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications +** and extensions to compare the contents of two buffers containing UTF-8 +** strings in a case-independent fashion, using the same definition of "case +** independence" that SQLite uses internally when comparing identifiers. +*/ +SQLITE_API int sqlite3_stricmp(const char *, const char *); +SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); + +/* +** CAPI3REF: String Globbing +* +** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if +** string X matches the [GLOB] pattern P. +** ^The definition of [GLOB] pattern matching used in +** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the +** SQL dialect understood by SQLite. ^The [sqlite3_strglob(P,X)] function +** is case sensitive. +** +** Note that this routine returns zero on a match and non-zero if the strings +** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. +** +** See also: [sqlite3_strlike()]. +*/ +SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr); + +/* +** CAPI3REF: String LIKE Matching +* +** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if +** string X matches the [LIKE] pattern P with escape character E. +** ^The definition of [LIKE] pattern matching used in +** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E" +** operator in the SQL dialect understood by SQLite. ^For "X LIKE P" without +** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0. +** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case +** insensitive - equivalent upper and lower case ASCII characters match +** one another. +** +** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though +** only ASCII characters are case folded. +** +** Note that this routine returns zero on a match and non-zero if the strings +** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. +** +** See also: [sqlite3_strglob()]. +*/ +SQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc); + +/* +** CAPI3REF: Error Logging Interface +** +** ^The [sqlite3_log()] interface writes a message into the [error log] +** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. +** ^If logging is enabled, the zFormat string and subsequent arguments are +** used with [sqlite3_snprintf()] to generate the final output string. +** +** The sqlite3_log() interface is intended for use by extensions such as +** virtual tables, collating functions, and SQL functions. While there is +** nothing to prevent an application from calling sqlite3_log(), doing so +** is considered bad form. +** +** The zFormat string must not be NULL. +** +** To avoid deadlocks and other threading problems, the sqlite3_log() routine +** will not use dynamically allocated memory. The log message is stored in +** a fixed-length buffer on the stack. If the log message is longer than +** a few hundred characters, it will be truncated to the length of the +** buffer. +*/ +SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...); + +/* +** CAPI3REF: Write-Ahead Log Commit Hook +** METHOD: sqlite3 +** +** ^The [sqlite3_wal_hook()] function is used to register a callback that +** is invoked each time data is committed to a database in wal mode. +** +** ^(The callback is invoked by SQLite after the commit has taken place and +** the associated write-lock on the database released)^, so the implementation +** may read, write or [checkpoint] the database as required. +** +** ^The first parameter passed to the callback function when it is invoked +** is a copy of the third parameter passed to sqlite3_wal_hook() when +** registering the callback. ^The second is a copy of the database handle. +** ^The third parameter is the name of the database that was written to - +** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter +** is the number of pages currently in the write-ahead log file, +** including those that were just committed. +** +** The callback function should normally return [SQLITE_OK]. ^If an error +** code is returned, that error will propagate back up through the +** SQLite code base to cause the statement that provoked the callback +** to report an error, though the commit will have still occurred. If the +** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value +** that does not correspond to any valid SQLite error code, the results +** are undefined. +** +** A single database handle may have at most a single write-ahead log callback +** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any +** previously registered write-ahead log callback. ^The return value is +** a copy of the third parameter from the previous call, if any, or 0. +** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the +** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will +** overwrite any prior [sqlite3_wal_hook()] settings. +*/ +SQLITE_API void *sqlite3_wal_hook( + sqlite3*, + int(*)(void *,sqlite3*,const char*,int), + void* +); + +/* +** CAPI3REF: Configure an auto-checkpoint +** METHOD: sqlite3 +** +** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around +** [sqlite3_wal_hook()] that causes any database on [database connection] D +** to automatically [checkpoint] +** after committing a transaction if there are N or +** more frames in the [write-ahead log] file. ^Passing zero or +** a negative value as the nFrame parameter disables automatic +** checkpoints entirely. +** +** ^The callback registered by this function replaces any existing callback +** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback +** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism +** configured by this function. +** +** ^The [wal_autocheckpoint pragma] can be used to invoke this interface +** from SQL. +** +** ^Checkpoints initiated by this mechanism are +** [sqlite3_wal_checkpoint_v2|PASSIVE]. +** +** ^Every new [database connection] defaults to having the auto-checkpoint +** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] +** pages. The use of this interface +** is only necessary if the default setting is found to be suboptimal +** for a particular application. +*/ +SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); + +/* +** CAPI3REF: Checkpoint a database +** METHOD: sqlite3 +** +** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to +** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^ +** +** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the +** [write-ahead log] for database X on [database connection] D to be +** transferred into the database file and for the write-ahead log to +** be reset. See the [checkpointing] documentation for addition +** information. +** +** This interface used to be the only way to cause a checkpoint to +** occur. But then the newer and more powerful [sqlite3_wal_checkpoint_v2()] +** interface was added. This interface is retained for backwards +** compatibility and as a convenience for applications that need to manually +** start a callback but which do not need the full power (and corresponding +** complication) of [sqlite3_wal_checkpoint_v2()]. +*/ +SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); + +/* +** CAPI3REF: Checkpoint a database +** METHOD: sqlite3 +** +** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint +** operation on database X of [database connection] D in mode M. Status +** information is written back into integers pointed to by L and C.)^ +** ^(The M parameter must be a valid [checkpoint mode]:)^ +** +**
+**
SQLITE_CHECKPOINT_PASSIVE
+** ^Checkpoint as many frames as possible without waiting for any database +** readers or writers to finish, then sync the database file if all frames +** in the log were checkpointed. ^The [busy-handler callback] +** is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode. +** ^On the other hand, passive mode might leave the checkpoint unfinished +** if there are concurrent readers or writers. +** +**
SQLITE_CHECKPOINT_FULL
+** ^This mode blocks (it invokes the +** [sqlite3_busy_handler|busy-handler callback]) until there is no +** database writer and all readers are reading from the most recent database +** snapshot. ^It then checkpoints all frames in the log file and syncs the +** database file. ^This mode blocks new database writers while it is pending, +** but new database readers are allowed to continue unimpeded. +** +**
SQLITE_CHECKPOINT_RESTART
+** ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition +** that after checkpointing the log file it blocks (calls the +** [busy-handler callback]) +** until all readers are reading from the database file only. ^This ensures +** that the next writer will restart the log file from the beginning. +** ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new +** database writer attempts while it is pending, but does not impede readers. +** +**
SQLITE_CHECKPOINT_TRUNCATE
+** ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the +** addition that it also truncates the log file to zero bytes just prior +** to a successful return. +**
+** +** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in +** the log file or to -1 if the checkpoint could not run because +** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not +** NULL,then *pnCkpt is set to the total number of checkpointed frames in the +** log file (including any that were already checkpointed before the function +** was called) or to -1 if the checkpoint could not run due to an error or +** because the database is not in WAL mode. ^Note that upon successful +** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been +** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero. +** +** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If +** any other process is running a checkpoint operation at the same time, the +** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a +** busy-handler configured, it will not be invoked in this case. +** +** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the +** exclusive "writer" lock on the database file. ^If the writer lock cannot be +** obtained immediately, and a busy-handler is configured, it is invoked and +** the writer lock retried until either the busy-handler returns 0 or the lock +** is successfully obtained. ^The busy-handler is also invoked while waiting for +** database readers as described above. ^If the busy-handler returns 0 before +** the writer lock is obtained or while waiting for database readers, the +** checkpoint operation proceeds from that point in the same way as +** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible +** without blocking any further. ^SQLITE_BUSY is returned in this case. +** +** ^If parameter zDb is NULL or points to a zero length string, then the +** specified operation is attempted on all WAL databases [attached] to +** [database connection] db. In this case the +** values written to output parameters *pnLog and *pnCkpt are undefined. ^If +** an SQLITE_BUSY error is encountered when processing one or more of the +** attached WAL databases, the operation is still attempted on any remaining +** attached databases and SQLITE_BUSY is returned at the end. ^If any other +** error occurs while processing an attached database, processing is abandoned +** and the error code is returned to the caller immediately. ^If no error +** (SQLITE_BUSY or otherwise) is encountered while processing the attached +** databases, SQLITE_OK is returned. +** +** ^If database zDb is the name of an attached database that is not in WAL +** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If +** zDb is not NULL (or a zero length string) and is not the name of any +** attached database, SQLITE_ERROR is returned to the caller. +** +** ^Unless it returns SQLITE_MISUSE, +** the sqlite3_wal_checkpoint_v2() interface +** sets the error information that is queried by +** [sqlite3_errcode()] and [sqlite3_errmsg()]. +** +** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface +** from SQL. +*/ +SQLITE_API int sqlite3_wal_checkpoint_v2( + sqlite3 *db, /* Database handle */ + const char *zDb, /* Name of attached database (or NULL) */ + int eMode, /* SQLITE_CHECKPOINT_* value */ + int *pnLog, /* OUT: Size of WAL log in frames */ + int *pnCkpt /* OUT: Total number of frames checkpointed */ +); + +/* +** CAPI3REF: Checkpoint Mode Values +** KEYWORDS: {checkpoint mode} +** +** These constants define all valid values for the "checkpoint mode" passed +** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface. +** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the +** meaning of each of these checkpoint modes. +*/ +#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */ +#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */ +#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for readers */ +#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */ + +/* +** CAPI3REF: Virtual Table Interface Configuration +** +** This function may be called by either the [xConnect] or [xCreate] method +** of a [virtual table] implementation to configure +** various facets of the virtual table interface. +** +** If this interface is invoked outside the context of an xConnect or +** xCreate virtual table method then the behavior is undefined. +** +** In the call sqlite3_vtab_config(D,C,...) the D parameter is the +** [database connection] in which the virtual table is being created and +** which is passed in as the first argument to the [xConnect] or [xCreate] +** method that is invoking sqlite3_vtab_config(). The C parameter is one +** of the [virtual table configuration options]. The presence and meaning +** of parameters after C depend on which [virtual table configuration option] +** is used. +*/ +SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); + +/* +** CAPI3REF: Virtual Table Configuration Options +** KEYWORDS: {virtual table configuration options} +** KEYWORDS: {virtual table configuration option} +** +** These macros define the various options to the +** [sqlite3_vtab_config()] interface that [virtual table] implementations +** can use to customize and optimize their behavior. +** +**
+** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]] +**
SQLITE_VTAB_CONSTRAINT_SUPPORT
+**
Calls of the form +** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, +** where X is an integer. If X is zero, then the [virtual table] whose +** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not +** support constraints. In this configuration (which is the default) if +** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire +** statement is rolled back as if [ON CONFLICT | OR ABORT] had been +** specified as part of the user's SQL statement, regardless of the actual +** ON CONFLICT mode specified. +** +** If X is non-zero, then the virtual table implementation guarantees +** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before +** any modifications to internal or persistent data structures have been made. +** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite +** is able to roll back a statement or database transaction, and abandon +** or continue processing the current SQL statement as appropriate. +** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns +** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode +** had been ABORT. +** +** Virtual table implementations that are required to handle OR REPLACE +** must do so within the [xUpdate] method. If a call to the +** [sqlite3_vtab_on_conflict()] function indicates that the current ON +** CONFLICT policy is REPLACE, the virtual table implementation should +** silently replace the appropriate rows within the xUpdate callback and +** return SQLITE_OK. Or, if this is not possible, it may return +** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT +** constraint handling. +**
+** +** [[SQLITE_VTAB_DIRECTONLY]]
SQLITE_VTAB_DIRECTONLY
+**
Calls of the form +** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the +** the [xConnect] or [xCreate] methods of a [virtual table] implementation +** prohibits that virtual table from being used from within triggers and +** views. +**
+** +** [[SQLITE_VTAB_INNOCUOUS]]
SQLITE_VTAB_INNOCUOUS
+**
Calls of the form +** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the +** [xConnect] or [xCreate] methods of a [virtual table] implementation +** identify that virtual table as being safe to use from within triggers +** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the +** virtual table can do no serious harm even if it is controlled by a +** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS +** flag unless absolutely necessary. +**
+** +** [[SQLITE_VTAB_USES_ALL_SCHEMAS]]
SQLITE_VTAB_USES_ALL_SCHEMAS
+**
Calls of the form +** [sqlite3_vtab_config](db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the +** the [xConnect] or [xCreate] methods of a [virtual table] implementation +** instruct the query planner to begin at least a read transaction on +** all schemas ("main", "temp", and any ATTACH-ed databases) whenever the +** virtual table is used. +**
+**
+*/ +#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 +#define SQLITE_VTAB_INNOCUOUS 2 +#define SQLITE_VTAB_DIRECTONLY 3 +#define SQLITE_VTAB_USES_ALL_SCHEMAS 4 + +/* +** CAPI3REF: Determine The Virtual Table Conflict Policy +** +** This function may only be called from within a call to the [xUpdate] method +** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The +** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], +** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode +** of the SQL statement that triggered the call to the [xUpdate] method of the +** [virtual table]. +*/ +SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *); + +/* +** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE +** +** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn] +** method of a [virtual table], then it might return true if the +** column is being fetched as part of an UPDATE operation during which the +** column value will not change. The virtual table implementation can use +** this hint as permission to substitute a return value that is less +** expensive to compute and that the corresponding +** [xUpdate] method understands as a "no-change" value. +** +** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that +** the column is not changed by the UPDATE statement, then the xColumn +** method can optionally return without setting a result, without calling +** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces]. +** In that case, [sqlite3_value_nochange(X)] will return true for the +** same column in the [xUpdate] method. +** +** The sqlite3_vtab_nochange() routine is an optimization. Virtual table +** implementations should continue to give a correct answer even if the +** sqlite3_vtab_nochange() interface were to always return false. In the +** current implementation, the sqlite3_vtab_nochange() interface does always +** returns false for the enhanced [UPDATE FROM] statement. +*/ +SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*); + +/* +** CAPI3REF: Determine The Collation For a Virtual Table Constraint +** METHOD: sqlite3_index_info +** +** This function may only be called from within a call to the [xBestIndex] +** method of a [virtual table]. This function returns a pointer to a string +** that is the name of the appropriate collation sequence to use for text +** comparisons on the constraint identified by its arguments. +** +** The first argument must be the pointer to the [sqlite3_index_info] object +** that is the first parameter to the xBestIndex() method. The second argument +** must be an index into the aConstraint[] array belonging to the +** sqlite3_index_info structure passed to xBestIndex. +** +** Important: +** The first parameter must be the same pointer that is passed into the +** xBestMethod() method. The first parameter may not be a pointer to a +** different [sqlite3_index_info] object, even an exact copy. +** +** The return value is computed as follows: +** +**
    +**
  1. If the constraint comes from a WHERE clause expression that contains +** a [COLLATE operator], then the name of the collation specified by +** that COLLATE operator is returned. +**

  2. If there is no COLLATE operator, but the column that is the subject +** of the constraint specifies an alternative collating sequence via +** a [COLLATE clause] on the column definition within the CREATE TABLE +** statement that was passed into [sqlite3_declare_vtab()], then the +** name of that alternative collating sequence is returned. +**

  3. Otherwise, "BINARY" is returned. +**

+*/ +SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int); + +/* +** CAPI3REF: Determine if a virtual table query is DISTINCT +** METHOD: sqlite3_index_info +** +** This API may only be used from within an [xBestIndex|xBestIndex method] +** of a [virtual table] implementation. The result of calling this +** interface from outside of xBestIndex() is undefined and probably harmful. +** +** ^The sqlite3_vtab_distinct() interface returns an integer between 0 and +** 3. The integer returned by sqlite3_vtab_distinct() +** gives the virtual table additional information about how the query +** planner wants the output to be ordered. As long as the virtual table +** can meet the ordering requirements of the query planner, it may set +** the "orderByConsumed" flag. +** +**
  1. +** ^If the sqlite3_vtab_distinct() interface returns 0, that means +** that the query planner needs the virtual table to return all rows in the +** sort order defined by the "nOrderBy" and "aOrderBy" fields of the +** [sqlite3_index_info] object. This is the default expectation. If the +** virtual table outputs all rows in sorted order, then it is always safe for +** the xBestIndex method to set the "orderByConsumed" flag, regardless of +** the return value from sqlite3_vtab_distinct(). +**

  2. +** ^(If the sqlite3_vtab_distinct() interface returns 1, that means +** that the query planner does not need the rows to be returned in sorted order +** as long as all rows with the same values in all columns identified by the +** "aOrderBy" field are adjacent.)^ This mode is used when the query planner +** is doing a GROUP BY. +**

  3. +** ^(If the sqlite3_vtab_distinct() interface returns 2, that means +** that the query planner does not need the rows returned in any particular +** order, as long as rows with the same values in all columns identified +** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows +** contain the same values for all columns identified by "colUsed", all but +** one such row may optionally be omitted from the result.)^ +** The virtual table is not required to omit rows that are duplicates +** over the "colUsed" columns, but if the virtual table can do that without +** too much extra effort, it could potentially help the query to run faster. +** This mode is used for a DISTINCT query. +**

  4. +** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the +** virtual table must return rows in the order defined by "aOrderBy" as +** if the sqlite3_vtab_distinct() interface had returned 0. However if +** two or more rows in the result have the same values for all columns +** identified by "colUsed", then all but one such row may optionally be +** omitted.)^ Like when the return value is 2, the virtual table +** is not required to omit rows that are duplicates over the "colUsed" +** columns, but if the virtual table can do that without +** too much extra effort, it could potentially help the query to run faster. +** This mode is used for queries +** that have both DISTINCT and ORDER BY clauses. +**

+** +**

The following table summarizes the conditions under which the +** virtual table is allowed to set the "orderByConsumed" flag based on +** the value returned by sqlite3_vtab_distinct(). This table is a +** restatement of the previous four paragraphs: +** +** +** +**
sqlite3_vtab_distinct() return value +** Rows are returned in aOrderBy order +** Rows with the same value in all aOrderBy columns are adjacent +** Duplicates over all colUsed columns may be omitted +**
0yesyesno +**
1noyesno +**
2noyesyes +**
3yesyesyes +**
+** +** ^For the purposes of comparing virtual table output values to see if the +** values are the same value for sorting purposes, two NULL values are considered +** to be the same. In other words, the comparison operator is "IS" +** (or "IS NOT DISTINCT FROM") and not "==". +** +** If a virtual table implementation is unable to meet the requirements +** specified above, then it must not set the "orderByConsumed" flag in the +** [sqlite3_index_info] object or an incorrect answer may result. +** +** ^A virtual table implementation is always free to return rows in any order +** it wants, as long as the "orderByConsumed" flag is not set. ^When the +** "orderByConsumed" flag is unset, the query planner will add extra +** [bytecode] to ensure that the final results returned by the SQL query are +** ordered correctly. The use of the "orderByConsumed" flag and the +** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful +** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed" +** flag might help queries against a virtual table to run faster. Being +** overly aggressive and setting the "orderByConsumed" flag when it is not +** valid to do so, on the other hand, might cause SQLite to return incorrect +** results. +*/ +SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*); + +/* +** CAPI3REF: Identify and handle IN constraints in xBestIndex +** +** This interface may only be used from within an +** [xBestIndex|xBestIndex() method] of a [virtual table] implementation. +** The result of invoking this interface from any other context is +** undefined and probably harmful. +** +** ^(A constraint on a virtual table of the form +** "[IN operator|column IN (...)]" is +** communicated to the xBestIndex method as a +** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use +** this constraint, it must set the corresponding +** aConstraintUsage[].argvIndex to a positive integer. ^(Then, under +** the usual mode of handling IN operators, SQLite generates [bytecode] +** that invokes the [xFilter|xFilter() method] once for each value +** on the right-hand side of the IN operator.)^ Thus the virtual table +** only sees a single value from the right-hand side of the IN operator +** at a time. +** +** In some cases, however, it would be advantageous for the virtual +** table to see all values on the right-hand of the IN operator all at +** once. The sqlite3_vtab_in() interfaces facilitates this in two ways: +** +**

    +**
  1. +** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero) +** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint +** is an [IN operator] that can be processed all at once. ^In other words, +** sqlite3_vtab_in() with -1 in the third argument is a mechanism +** by which the virtual table can ask SQLite if all-at-once processing +** of the IN operator is even possible. +** +**

  2. +** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates +** to SQLite that the virtual table does or does not want to process +** the IN operator all-at-once, respectively. ^Thus when the third +** parameter (F) is non-negative, this interface is the mechanism by +** which the virtual table tells SQLite how it wants to process the +** IN operator. +**

+** +** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times +** within the same xBestIndex method call. ^For any given P,N pair, +** the return value from sqlite3_vtab_in(P,N,F) will always be the same +** within the same xBestIndex call. ^If the interface returns true +** (non-zero), that means that the constraint is an IN operator +** that can be processed all-at-once. ^If the constraint is not an IN +** operator or cannot be processed all-at-once, then the interface returns +** false. +** +** ^(All-at-once processing of the IN operator is selected if both of the +** following conditions are met: +** +**
    +**
  1. The P->aConstraintUsage[N].argvIndex value is set to a positive +** integer. This is how the virtual table tells SQLite that it wants to +** use the N-th constraint. +** +**

  2. The last call to sqlite3_vtab_in(P,N,F) for which F was +** non-negative had F>=1. +**

)^ +** +** ^If either or both of the conditions above are false, then SQLite uses +** the traditional one-at-a-time processing strategy for the IN constraint. +** ^If both conditions are true, then the argvIndex-th parameter to the +** xFilter method will be an [sqlite3_value] that appears to be NULL, +** but which can be passed to [sqlite3_vtab_in_first()] and +** [sqlite3_vtab_in_next()] to find all values on the right-hand side +** of the IN constraint. +*/ +SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle); + +/* +** CAPI3REF: Find all elements on the right-hand side of an IN constraint. +** +** These interfaces are only useful from within the +** [xFilter|xFilter() method] of a [virtual table] implementation. +** The result of invoking these interfaces from any other context +** is undefined and probably harmful. +** +** The X parameter in a call to sqlite3_vtab_in_first(X,P) or +** sqlite3_vtab_in_next(X,P) should be one of the parameters to the +** xFilter method which invokes these routines, and specifically +** a parameter that was previously selected for all-at-once IN constraint +** processing using the [sqlite3_vtab_in()] interface in the +** [xBestIndex|xBestIndex method]. ^(If the X parameter is not +** an xFilter argument that was selected for all-at-once IN constraint +** processing, then these routines return [SQLITE_ERROR].)^ +** +** ^(Use these routines to access all values on the right-hand side +** of the IN constraint using code like the following: +** +**
+**    for(rc=sqlite3_vtab_in_first(pList, &pVal);
+**        rc==SQLITE_OK && pVal;
+**        rc=sqlite3_vtab_in_next(pList, &pVal)
+**    ){
+**      // do something with pVal
+**    }
+**    if( rc!=SQLITE_OK ){
+**      // an error has occurred
+**    }
+** 
)^ +** +** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P) +** routines return SQLITE_OK and set *P to point to the first or next value +** on the RHS of the IN constraint. ^If there are no more values on the +** right hand side of the IN constraint, then *P is set to NULL and these +** routines return [SQLITE_DONE]. ^The return value might be +** some other value, such as SQLITE_NOMEM, in the event of a malfunction. +** +** The *ppOut values returned by these routines are only valid until the +** next call to either of these routines or until the end of the xFilter +** method from which these routines were called. If the virtual table +** implementation needs to retain the *ppOut values for longer, it must make +** copies. The *ppOut values are [protected sqlite3_value|protected]. +*/ +SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut); +SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut); + +/* +** CAPI3REF: Constraint values in xBestIndex() +** METHOD: sqlite3_index_info +** +** This API may only be used from within the [xBestIndex|xBestIndex method] +** of a [virtual table] implementation. The result of calling this interface +** from outside of an xBestIndex method are undefined and probably harmful. +** +** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within +** the [xBestIndex] method of a [virtual table] implementation, with P being +** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and +** J being a 0-based index into P->aConstraint[], then this routine +** attempts to set *V to the value of the right-hand operand of +** that constraint if the right-hand operand is known. ^If the +** right-hand operand is not known, then *V is set to a NULL pointer. +** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if +** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V) +** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th +** constraint is not available. ^The sqlite3_vtab_rhs_value() interface +** can return a result code other than SQLITE_OK or SQLITE_NOTFOUND if +** something goes wrong. +** +** The sqlite3_vtab_rhs_value() interface is usually only successful if +** the right-hand operand of a constraint is a literal value in the original +** SQL statement. If the right-hand operand is an expression or a reference +** to some other column or a [host parameter], then sqlite3_vtab_rhs_value() +** will probably return [SQLITE_NOTFOUND]. +** +** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and +** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such +** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^ +** +** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value +** and remains valid for the duration of the xBestIndex method call. +** ^When xBestIndex returns, the sqlite3_value object returned by +** sqlite3_vtab_rhs_value() is automatically deallocated. +** +** The "_rhs_" in the name of this routine is an abbreviation for +** "Right-Hand Side". +*/ +SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal); + +/* +** CAPI3REF: Conflict resolution modes +** KEYWORDS: {conflict resolution mode} +** +** These constants are returned by [sqlite3_vtab_on_conflict()] to +** inform a [virtual table] implementation of the [ON CONFLICT] mode +** for the SQL statement being evaluated. +** +** Note that the [SQLITE_IGNORE] constant is also used as a potential +** return value from the [sqlite3_set_authorizer()] callback and that +** [SQLITE_ABORT] is also a [result code]. +*/ +#define SQLITE_ROLLBACK 1 +/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */ +#define SQLITE_FAIL 3 +/* #define SQLITE_ABORT 4 // Also an error code */ +#define SQLITE_REPLACE 5 + +/* +** CAPI3REF: Prepared Statement Scan Status Opcodes +** KEYWORDS: {scanstatus options} +** +** The following constants can be used for the T parameter to the +** [sqlite3_stmt_scanstatus(S,X,T,V)] interface. Each constant designates a +** different metric for sqlite3_stmt_scanstatus() to return. +** +** When the value returned to V is a string, space to hold that string is +** managed by the prepared statement S and will be automatically freed when +** S is finalized. +** +** Not all values are available for all query elements. When a value is +** not available, the output variable is set to -1 if the value is numeric, +** or to NULL if it is a string (SQLITE_SCANSTAT_NAME). +** +**
+** [[SQLITE_SCANSTAT_NLOOP]]
SQLITE_SCANSTAT_NLOOP
+**
^The [sqlite3_int64] variable pointed to by the V parameter will be +** set to the total number of times that the X-th loop has run.
+** +** [[SQLITE_SCANSTAT_NVISIT]]
SQLITE_SCANSTAT_NVISIT
+**
^The [sqlite3_int64] variable pointed to by the V parameter will be set +** to the total number of rows examined by all iterations of the X-th loop.
+** +** [[SQLITE_SCANSTAT_EST]]
SQLITE_SCANSTAT_EST
+**
^The "double" variable pointed to by the V parameter will be set to the +** query planner's estimate for the average number of rows output from each +** iteration of the X-th loop. If the query planner's estimate was accurate, +** then this value will approximate the quotient NVISIT/NLOOP and the +** product of this value for all prior loops with the same SELECTID will +** be the NLOOP value for the current loop.
+** +** [[SQLITE_SCANSTAT_NAME]]
SQLITE_SCANSTAT_NAME
+**
^The "const char *" variable pointed to by the V parameter will be set +** to a zero-terminated UTF-8 string containing the name of the index or table +** used for the X-th loop.
+** +** [[SQLITE_SCANSTAT_EXPLAIN]]
SQLITE_SCANSTAT_EXPLAIN
+**
^The "const char *" variable pointed to by the V parameter will be set +** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN] +** description for the X-th loop.
+** +** [[SQLITE_SCANSTAT_SELECTID]]
SQLITE_SCANSTAT_SELECTID
+**
^The "int" variable pointed to by the V parameter will be set to the +** id for the X-th query plan element. The id value is unique within the +** statement. The select-id is the same value as is output in the first +** column of an [EXPLAIN QUERY PLAN] query.
+** +** [[SQLITE_SCANSTAT_PARENTID]]
SQLITE_SCANSTAT_PARENTID
+**
The "int" variable pointed to by the V parameter will be set to the +** id of the parent of the current query element, if applicable, or +** to zero if the query element has no parent. This is the same value as +** returned in the second column of an [EXPLAIN QUERY PLAN] query.
+** +** [[SQLITE_SCANSTAT_NCYCLE]]
SQLITE_SCANSTAT_NCYCLE
+**
The sqlite3_int64 output value is set to the number of cycles, +** according to the processor time-stamp counter, that elapsed while the +** query element was being processed. This value is not available for +** all query elements - if it is unavailable the output variable is +** set to -1.
+**
+*/ +#define SQLITE_SCANSTAT_NLOOP 0 +#define SQLITE_SCANSTAT_NVISIT 1 +#define SQLITE_SCANSTAT_EST 2 +#define SQLITE_SCANSTAT_NAME 3 +#define SQLITE_SCANSTAT_EXPLAIN 4 +#define SQLITE_SCANSTAT_SELECTID 5 +#define SQLITE_SCANSTAT_PARENTID 6 +#define SQLITE_SCANSTAT_NCYCLE 7 + +/* +** CAPI3REF: Prepared Statement Scan Status +** METHOD: sqlite3_stmt +** +** These interfaces return information about the predicted and measured +** performance for pStmt. Advanced applications can use this +** interface to compare the predicted and the measured performance and +** issue warnings and/or rerun [ANALYZE] if discrepancies are found. +** +** Since this interface is expected to be rarely used, it is only +** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS] +** compile-time option. +** +** The "iScanStatusOp" parameter determines which status information to return. +** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior +** of this interface is undefined. ^The requested measurement is written into +** a variable pointed to by the "pOut" parameter. +** +** The "flags" parameter must be passed a mask of flags. At present only +** one flag is defined - SQLITE_SCANSTAT_COMPLEX. If SQLITE_SCANSTAT_COMPLEX +** is specified, then status information is available for all elements +** of a query plan that are reported by "EXPLAIN QUERY PLAN" output. If +** SQLITE_SCANSTAT_COMPLEX is not specified, then only query plan elements +** that correspond to query loops (the "SCAN..." and "SEARCH..." elements of +** the EXPLAIN QUERY PLAN output) are available. Invoking API +** sqlite3_stmt_scanstatus() is equivalent to calling +** sqlite3_stmt_scanstatus_v2() with a zeroed flags parameter. +** +** Parameter "idx" identifies the specific query element to retrieve statistics +** for. Query elements are numbered starting from zero. A value of -1 may +** retrieve statistics for the entire query. ^If idx is out of range +** - less than -1 or greater than or equal to the total number of query +** elements used to implement the statement - a non-zero value is returned and +** the variable that pOut points to is unchanged. +** +** See also: [sqlite3_stmt_scanstatus_reset()] +*/ +SQLITE_API int sqlite3_stmt_scanstatus( + sqlite3_stmt *pStmt, /* Prepared statement for which info desired */ + int idx, /* Index of loop to report on */ + int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */ + void *pOut /* Result written here */ +); +SQLITE_API int sqlite3_stmt_scanstatus_v2( + sqlite3_stmt *pStmt, /* Prepared statement for which info desired */ + int idx, /* Index of loop to report on */ + int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */ + int flags, /* Mask of flags defined below */ + void *pOut /* Result written here */ +); + +/* +** CAPI3REF: Prepared Statement Scan Status +** KEYWORDS: {scan status flags} +*/ +#define SQLITE_SCANSTAT_COMPLEX 0x0001 + +/* +** CAPI3REF: Zero Scan-Status Counters +** METHOD: sqlite3_stmt +** +** ^Zero all [sqlite3_stmt_scanstatus()] related event counters. +** +** This API is only available if the library is built with pre-processor +** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined. +*/ +SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*); + +/* +** CAPI3REF: Flush caches to disk mid-transaction +** METHOD: sqlite3 +** +** ^If a write-transaction is open on [database connection] D when the +** [sqlite3_db_cacheflush(D)] interface is invoked, any dirty +** pages in the pager-cache that are not currently in use are written out +** to disk. A dirty page may be in use if a database cursor created by an +** active SQL statement is reading from it, or if it is page 1 of a database +** file (page 1 is always "in use"). ^The [sqlite3_db_cacheflush(D)] +** interface flushes caches for all schemas - "main", "temp", and +** any [attached] databases. +** +** ^If this function needs to obtain extra database locks before dirty pages +** can be flushed to disk, it does so. ^If those locks cannot be obtained +** immediately and there is a busy-handler callback configured, it is invoked +** in the usual manner. ^If the required lock still cannot be obtained, then +** the database is skipped and an attempt made to flush any dirty pages +** belonging to the next (if any) database. ^If any databases are skipped +** because locks cannot be obtained, but no other error occurs, this +** function returns SQLITE_BUSY. +** +** ^If any other error occurs while flushing dirty pages to disk (for +** example an IO error or out-of-memory condition), then processing is +** abandoned and an SQLite [error code] is returned to the caller immediately. +** +** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK. +** +** ^This function does not set the database handle error code or message +** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions. +*/ +SQLITE_API int sqlite3_db_cacheflush(sqlite3*); + +/* +** CAPI3REF: The pre-update hook. +** METHOD: sqlite3 +** +** ^These interfaces are only available if SQLite is compiled using the +** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option. +** +** ^The [sqlite3_preupdate_hook()] interface registers a callback function +** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation +** on a database table. +** ^At most one preupdate hook may be registered at a time on a single +** [database connection]; each call to [sqlite3_preupdate_hook()] overrides +** the previous setting. +** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()] +** with a NULL pointer as the second parameter. +** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as +** the first parameter to callbacks. +** +** ^The preupdate hook only fires for changes to real database tables; the +** preupdate hook is not invoked for changes to [virtual tables] or to +** system tables like sqlite_sequence or sqlite_stat1. +** +** ^The second parameter to the preupdate callback is a pointer to +** the [database connection] that registered the preupdate hook. +** ^The third parameter to the preupdate callback is one of the constants +** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the +** kind of update operation that is about to occur. +** ^(The fourth parameter to the preupdate callback is the name of the +** database within the database connection that is being modified. This +** will be "main" for the main database or "temp" for TEMP tables or +** the name given after the AS keyword in the [ATTACH] statement for attached +** databases.)^ +** ^The fifth parameter to the preupdate callback is the name of the +** table that is being modified. +** +** For an UPDATE or DELETE operation on a [rowid table], the sixth +** parameter passed to the preupdate callback is the initial [rowid] of the +** row being modified or deleted. For an INSERT operation on a rowid table, +** or any operation on a WITHOUT ROWID table, the value of the sixth +** parameter is undefined. For an INSERT or UPDATE on a rowid table the +** seventh parameter is the final rowid value of the row being inserted +** or updated. The value of the seventh parameter passed to the callback +** function is not defined for operations on WITHOUT ROWID tables, or for +** DELETE operations on rowid tables. +** +** ^The sqlite3_preupdate_hook(D,C,P) function returns the P argument from +** the previous call on the same [database connection] D, or NULL for +** the first call on D. +** +** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()], +** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces +** provide additional information about a preupdate event. These routines +** may only be called from within a preupdate callback. Invoking any of +** these routines from outside of a preupdate callback or with a +** [database connection] pointer that is different from the one supplied +** to the preupdate callback results in undefined and probably undesirable +** behavior. +** +** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns +** in the row that is being inserted, updated, or deleted. +** +** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to +** a [protected sqlite3_value] that contains the value of the Nth column of +** the table row before it is updated. The N parameter must be between 0 +** and one less than the number of columns or the behavior will be +** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE +** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the +** behavior is undefined. The [sqlite3_value] that P points to +** will be destroyed when the preupdate callback returns. +** +** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to +** a [protected sqlite3_value] that contains the value of the Nth column of +** the table row after it is updated. The N parameter must be between 0 +** and one less than the number of columns or the behavior will be +** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE +** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the +** behavior is undefined. The [sqlite3_value] that P points to +** will be destroyed when the preupdate callback returns. +** +** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate +** callback was invoked as a result of a direct insert, update, or delete +** operation; or 1 for inserts, updates, or deletes invoked by top-level +** triggers; or 2 for changes resulting from triggers called by top-level +** triggers; and so forth. +** +** When the [sqlite3_blob_write()] API is used to update a blob column, +** the pre-update hook is invoked with SQLITE_DELETE, because +** the new values are not yet available. In this case, when a +** callback made with op==SQLITE_DELETE is actually a write using the +** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns +** the index of the column being written. In other cases, where the +** pre-update hook is being invoked for some other reason, including a +** regular DELETE, sqlite3_preupdate_blobwrite() returns -1. +** +** See also: [sqlite3_update_hook()] +*/ +#if defined(SQLITE_ENABLE_PREUPDATE_HOOK) +SQLITE_API void *sqlite3_preupdate_hook( + sqlite3 *db, + void(*xPreUpdate)( + void *pCtx, /* Copy of third arg to preupdate_hook() */ + sqlite3 *db, /* Database handle */ + int op, /* SQLITE_UPDATE, DELETE or INSERT */ + char const *zDb, /* Database name */ + char const *zName, /* Table name */ + sqlite3_int64 iKey1, /* Rowid of row about to be deleted/updated */ + sqlite3_int64 iKey2 /* New rowid value (for a rowid UPDATE) */ + ), + void* +); +SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **); +SQLITE_API int sqlite3_preupdate_count(sqlite3 *); +SQLITE_API int sqlite3_preupdate_depth(sqlite3 *); +SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **); +SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *); +#endif + +/* +** CAPI3REF: Low-level system error code +** METHOD: sqlite3 +** +** ^Attempt to return the underlying operating system error code or error +** number that caused the most recent I/O error or failure to open a file. +** The return value is OS-dependent. For example, on unix systems, after +** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be +** called to get back the underlying "errno" that caused the problem, such +** as ENOSPC, EAUTH, EISDIR, and so forth. +*/ +SQLITE_API int sqlite3_system_errno(sqlite3*); + +/* +** CAPI3REF: Database Snapshot +** KEYWORDS: {snapshot} {sqlite3_snapshot} +** +** An instance of the snapshot object records the state of a [WAL mode] +** database for some specific point in history. +** +** In [WAL mode], multiple [database connections] that are open on the +** same database file can each be reading a different historical version +** of the database file. When a [database connection] begins a read +** transaction, that connection sees an unchanging copy of the database +** as it existed for the point in time when the transaction first started. +** Subsequent changes to the database from other connections are not seen +** by the reader until a new read transaction is started. +** +** The sqlite3_snapshot object records state information about an historical +** version of the database file so that it is possible to later open a new read +** transaction that sees that historical version of the database rather than +** the most recent version. +*/ +typedef struct sqlite3_snapshot { + unsigned char hidden[48]; +} sqlite3_snapshot; + +/* +** CAPI3REF: Record A Database Snapshot +** CONSTRUCTOR: sqlite3_snapshot +** +** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a +** new [sqlite3_snapshot] object that records the current state of +** schema S in database connection D. ^On success, the +** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly +** created [sqlite3_snapshot] object into *P and returns SQLITE_OK. +** If there is not already a read-transaction open on schema S when +** this function is called, one is opened automatically. +** +** If a read-transaction is opened by this function, then it is guaranteed +** that the returned snapshot object may not be invalidated by a database +** writer or checkpointer until after the read-transaction is closed. This +** is not guaranteed if a read-transaction is already open when this +** function is called. In that case, any subsequent write or checkpoint +** operation on the database may invalidate the returned snapshot handle, +** even while the read-transaction remains open. +** +** The following must be true for this function to succeed. If any of +** the following statements are false when sqlite3_snapshot_get() is +** called, SQLITE_ERROR is returned. The final value of *P is undefined +** in this case. +** +**
    +**
  • The database handle must not be in [autocommit mode]. +** +**
  • Schema S of [database connection] D must be a [WAL mode] database. +** +**
  • There must not be a write transaction open on schema S of database +** connection D. +** +**
  • One or more transactions must have been written to the current wal +** file since it was created on disk (by any connection). This means +** that a snapshot cannot be taken on a wal mode database with no wal +** file immediately after it is first opened. At least one transaction +** must be written to it first. +**
+** +** This function may also return SQLITE_NOMEM. If it is called with the +** database handle in autocommit mode but fails for some other reason, +** whether or not a read transaction is opened on schema S is undefined. +** +** The [sqlite3_snapshot] object returned from a successful call to +** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()] +** to avoid a memory leak. +** +** The [sqlite3_snapshot_get()] interface is only available when the +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get( + sqlite3 *db, + const char *zSchema, + sqlite3_snapshot **ppSnapshot +); + +/* +** CAPI3REF: Start a read transaction on an historical snapshot +** METHOD: sqlite3_snapshot +** +** ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read +** transaction or upgrades an existing one for schema S of +** [database connection] D such that the read transaction refers to +** historical [snapshot] P, rather than the most recent change to the +** database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK +** on success or an appropriate [error code] if it fails. +** +** ^In order to succeed, the database connection must not be in +** [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there +** is already a read transaction open on schema S, then the database handle +** must have no active statements (SELECT statements that have been passed +** to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). +** SQLITE_ERROR is returned if either of these conditions is violated, or +** if schema S does not exist, or if the snapshot object is invalid. +** +** ^A call to sqlite3_snapshot_open() will fail to open if the specified +** snapshot has been overwritten by a [checkpoint]. In this case +** SQLITE_ERROR_SNAPSHOT is returned. +** +** If there is already a read transaction open when this function is +** invoked, then the same read transaction remains open (on the same +** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT +** is returned. If another error code - for example SQLITE_PROTOCOL or an +** SQLITE_IOERR error code - is returned, then the final state of the +** read transaction is undefined. If SQLITE_OK is returned, then the +** read transaction is now open on database snapshot P. +** +** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the +** database connection D does not know that the database file for +** schema S is in [WAL mode]. A database connection might not know +** that the database file is in [WAL mode] if there has been no prior +** I/O on that database connection, or if the database entered [WAL mode] +** after the most recent I/O on the database connection.)^ +** (Hint: Run "[PRAGMA application_id]" against a newly opened +** database connection in order to make it ready to use snapshots.) +** +** The [sqlite3_snapshot_open()] interface is only available when the +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open( + sqlite3 *db, + const char *zSchema, + sqlite3_snapshot *pSnapshot +); + +/* +** CAPI3REF: Destroy a snapshot +** DESTRUCTOR: sqlite3_snapshot +** +** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P. +** The application must eventually free every [sqlite3_snapshot] object +** using this routine to avoid a memory leak. +** +** The [sqlite3_snapshot_free()] interface is only available when the +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. +*/ +SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*); + +/* +** CAPI3REF: Compare the ages of two snapshot handles. +** METHOD: sqlite3_snapshot +** +** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages +** of two valid snapshot handles. +** +** If the two snapshot handles are not associated with the same database +** file, the result of the comparison is undefined. +** +** Additionally, the result of the comparison is only valid if both of the +** snapshot handles were obtained by calling sqlite3_snapshot_get() since the +** last time the wal file was deleted. The wal file is deleted when the +** database is changed back to rollback mode or when the number of database +** clients drops to zero. If either snapshot handle was obtained before the +** wal file was last deleted, the value returned by this function +** is undefined. +** +** Otherwise, this API returns a negative value if P1 refers to an older +** snapshot than P2, zero if the two handles refer to the same database +** snapshot, and a positive value if P1 is a newer snapshot than P2. +** +** This interface is only available if SQLite is compiled with the +** [SQLITE_ENABLE_SNAPSHOT] option. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp( + sqlite3_snapshot *p1, + sqlite3_snapshot *p2 +); + +/* +** CAPI3REF: Recover snapshots from a wal file +** METHOD: sqlite3_snapshot +** +** If a [WAL file] remains on disk after all database connections close +** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control] +** or because the last process to have the database opened exited without +** calling [sqlite3_close()]) and a new connection is subsequently opened +** on that database and [WAL file], the [sqlite3_snapshot_open()] interface +** will only be able to open the last transaction added to the WAL file +** even though the WAL file contains other valid transactions. +** +** This function attempts to scan the WAL file associated with database zDb +** of database handle db and make all valid snapshots available to +** sqlite3_snapshot_open(). It is an error if there is already a read +** transaction open on the database, or if the database is not a WAL mode +** database. +** +** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +** +** This interface is only available if SQLite is compiled with the +** [SQLITE_ENABLE_SNAPSHOT] option. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb); + +/* +** CAPI3REF: Serialize a database +** +** The sqlite3_serialize(D,S,P,F) interface returns a pointer to +** memory that is a serialization of the S database on +** [database connection] D. If S is a NULL pointer, the main database is used. +** If P is not a NULL pointer, then the size of the database in bytes +** is written into *P. +** +** For an ordinary on-disk database file, the serialization is just a +** copy of the disk file. For an in-memory database or a "TEMP" database, +** the serialization is the same sequence of bytes which would be written +** to disk if that database were backed up to disk. +** +** The usual case is that sqlite3_serialize() copies the serialization of +** the database into memory obtained from [sqlite3_malloc64()] and returns +** a pointer to that memory. The caller is responsible for freeing the +** returned value to avoid a memory leak. However, if the F argument +** contains the SQLITE_SERIALIZE_NOCOPY bit, then no memory allocations +** are made, and the sqlite3_serialize() function will return a pointer +** to the contiguous memory representation of the database that SQLite +** is currently using for that database, or NULL if no such contiguous +** memory representation of the database exists. A contiguous memory +** representation of the database will usually only exist if there has +** been a prior call to [sqlite3_deserialize(D,S,...)] with the same +** values of D and S. +** The size of the database is written into *P even if the +** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy +** of the database exists. +** +** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set, +** the returned buffer content will remain accessible and unchanged +** until either the next write operation on the connection or when +** the connection is closed, and applications must not modify the +** buffer. If the bit had been clear, the returned buffer will not +** be accessed by SQLite after the call. +** +** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the +** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory +** allocation error occurs. +** +** This interface is omitted if SQLite is compiled with the +** [SQLITE_OMIT_DESERIALIZE] option. +*/ +SQLITE_API unsigned char *sqlite3_serialize( + sqlite3 *db, /* The database connection */ + const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */ + sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */ + unsigned int mFlags /* Zero or more SQLITE_SERIALIZE_* flags */ +); + +/* +** CAPI3REF: Flags for sqlite3_serialize +** +** Zero or more of the following constants can be OR-ed together for +** the F argument to [sqlite3_serialize(D,S,P,F)]. +** +** SQLITE_SERIALIZE_NOCOPY means that [sqlite3_serialize()] will return +** a pointer to contiguous in-memory database that it is currently using, +** without making a copy of the database. If SQLite is not currently using +** a contiguous in-memory database, then this option causes +** [sqlite3_serialize()] to return a NULL pointer. SQLite will only be +** using a contiguous in-memory database if it has been initialized by a +** prior call to [sqlite3_deserialize()]. +*/ +#define SQLITE_SERIALIZE_NOCOPY 0x001 /* Do no memory allocations */ + +/* +** CAPI3REF: Deserialize a database +** +** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the +** [database connection] D to disconnect from database S and then +** reopen S as an in-memory database based on the serialization contained +** in P. The serialized database P is N bytes in size. M is the size of +** the buffer P, which might be larger than N. If M is larger than N, and +** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is +** permitted to add content to the in-memory database as long as the total +** size does not exceed M bytes. +** +** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will +** invoke sqlite3_free() on the serialization buffer when the database +** connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then +** SQLite will try to increase the buffer size using sqlite3_realloc64() +** if writes on the database cause it to grow larger than M bytes. +** +** Applications must not modify the buffer P or invalidate it before +** the database connection D is closed. +** +** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the +** database is currently in a read transaction or is involved in a backup +** operation. +** +** It is not possible to deserialize into the TEMP database. If the +** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the +** function returns SQLITE_ERROR. +** +** The deserialized database should not be in [WAL mode]. If the database +** is in WAL mode, then any attempt to use the database file will result +** in an [SQLITE_CANTOPEN] error. The application can set the +** [file format version numbers] (bytes 18 and 19) of the input database P +** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the +** database file into rollback mode and work around this limitation. +** +** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the +** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then +** [sqlite3_free()] is invoked on argument P prior to returning. +** +** This interface is omitted if SQLite is compiled with the +** [SQLITE_OMIT_DESERIALIZE] option. +*/ +SQLITE_API int sqlite3_deserialize( + sqlite3 *db, /* The database connection */ + const char *zSchema, /* Which DB to reopen with the deserialization */ + unsigned char *pData, /* The serialized database content */ + sqlite3_int64 szDb, /* Number of bytes in the deserialization */ + sqlite3_int64 szBuf, /* Total size of buffer pData[] */ + unsigned mFlags /* Zero or more SQLITE_DESERIALIZE_* flags */ +); + +/* +** CAPI3REF: Flags for sqlite3_deserialize() +** +** The following are allowed values for the 6th argument (the F argument) to +** the [sqlite3_deserialize(D,S,P,N,M,F)] interface. +** +** The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization +** in the P argument is held in memory obtained from [sqlite3_malloc64()] +** and that SQLite should take ownership of this memory and automatically +** free it when it has finished using it. Without this flag, the caller +** is responsible for freeing any dynamically allocated memory. +** +** The SQLITE_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to +** grow the size of the database using calls to [sqlite3_realloc64()]. This +** flag should only be used if SQLITE_DESERIALIZE_FREEONCLOSE is also used. +** Without this flag, the deserialized database cannot increase in size beyond +** the number of bytes specified by the M parameter. +** +** The SQLITE_DESERIALIZE_READONLY flag means that the deserialized database +** should be treated as read-only. +*/ +#define SQLITE_DESERIALIZE_FREEONCLOSE 1 /* Call sqlite3_free() on close */ +#define SQLITE_DESERIALIZE_RESIZEABLE 2 /* Resize using sqlite3_realloc64() */ +#define SQLITE_DESERIALIZE_READONLY 4 /* Database is read-only */ + +/* +** Undo the hack that converts floating point types to integer for +** builds on processors without floating point support. +*/ +#ifdef SQLITE_OMIT_FLOATING_POINT +# undef double +#endif + +#if defined(__wasi__) +# undef SQLITE_WASI +# define SQLITE_WASI 1 +# ifndef SQLITE_OMIT_LOAD_EXTENSION +# define SQLITE_OMIT_LOAD_EXTENSION +# endif +# ifndef SQLITE_THREADSAFE +# define SQLITE_THREADSAFE 0 +# endif +#endif + +#ifdef __cplusplus +} /* End of the 'extern "C"' block */ +#endif +/* #endif for SQLITE3_H will be added by mksqlite3.tcl */ + +/******** Begin file sqlite3rtree.h *********/ +/* +** 2010 August 30 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +*/ + +#ifndef _SQLITE3RTREE_H_ +#define _SQLITE3RTREE_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; +typedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info; + +/* The double-precision datatype used by RTree depends on the +** SQLITE_RTREE_INT_ONLY compile-time option. +*/ +#ifdef SQLITE_RTREE_INT_ONLY + typedef sqlite3_int64 sqlite3_rtree_dbl; +#else + typedef double sqlite3_rtree_dbl; +#endif + +/* +** Register a geometry callback named zGeom that can be used as part of an +** R-Tree geometry query as follows: +** +** SELECT ... FROM WHERE MATCH $zGeom(... params ...) +*/ +SQLITE_API int sqlite3_rtree_geometry_callback( + sqlite3 *db, + const char *zGeom, + int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*), + void *pContext +); + + +/* +** A pointer to a structure of the following type is passed as the first +** argument to callbacks registered using rtree_geometry_callback(). +*/ +struct sqlite3_rtree_geometry { + void *pContext; /* Copy of pContext passed to s_r_g_c() */ + int nParam; /* Size of array aParam[] */ + sqlite3_rtree_dbl *aParam; /* Parameters passed to SQL geom function */ + void *pUser; /* Callback implementation user data */ + void (*xDelUser)(void *); /* Called by SQLite to clean up pUser */ +}; + +/* +** Register a 2nd-generation geometry callback named zScore that can be +** used as part of an R-Tree geometry query as follows: +** +** SELECT ... FROM WHERE MATCH $zQueryFunc(... params ...) +*/ +SQLITE_API int sqlite3_rtree_query_callback( + sqlite3 *db, + const char *zQueryFunc, + int (*xQueryFunc)(sqlite3_rtree_query_info*), + void *pContext, + void (*xDestructor)(void*) +); + + +/* +** A pointer to a structure of the following type is passed as the +** argument to scored geometry callback registered using +** sqlite3_rtree_query_callback(). +** +** Note that the first 5 fields of this structure are identical to +** sqlite3_rtree_geometry. This structure is a subclass of +** sqlite3_rtree_geometry. +*/ +struct sqlite3_rtree_query_info { + void *pContext; /* pContext from when function registered */ + int nParam; /* Number of function parameters */ + sqlite3_rtree_dbl *aParam; /* value of function parameters */ + void *pUser; /* callback can use this, if desired */ + void (*xDelUser)(void*); /* function to free pUser */ + sqlite3_rtree_dbl *aCoord; /* Coordinates of node or entry to check */ + unsigned int *anQueue; /* Number of pending entries in the queue */ + int nCoord; /* Number of coordinates */ + int iLevel; /* Level of current node or entry */ + int mxLevel; /* The largest iLevel value in the tree */ + sqlite3_int64 iRowid; /* Rowid for current entry */ + sqlite3_rtree_dbl rParentScore; /* Score of parent node */ + int eParentWithin; /* Visibility of parent node */ + int eWithin; /* OUT: Visibility */ + sqlite3_rtree_dbl rScore; /* OUT: Write the score here */ + /* The following fields are only available in 3.8.11 and later */ + sqlite3_value **apSqlParam; /* Original SQL values of parameters */ +}; + +/* +** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin. +*/ +#define NOT_WITHIN 0 /* Object completely outside of query region */ +#define PARTLY_WITHIN 1 /* Object partially overlaps query region */ +#define FULLY_WITHIN 2 /* Object fully contained within query region */ + + +#ifdef __cplusplus +} /* end of the 'extern "C"' block */ +#endif + +#endif /* ifndef _SQLITE3RTREE_H_ */ + +/******** End of sqlite3rtree.h *********/ +/******** Begin file sqlite3session.h *********/ + +#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) +#define __SQLITESESSION_H_ 1 + +/* +** Make sure we can call this stuff from C++. +*/ +#ifdef __cplusplus +extern "C" { +#endif + + +/* +** CAPI3REF: Session Object Handle +** +** An instance of this object is a [session] that can be used to +** record changes to a database. +*/ +typedef struct sqlite3_session sqlite3_session; + +/* +** CAPI3REF: Changeset Iterator Handle +** +** An instance of this object acts as a cursor for iterating +** over the elements of a [changeset] or [patchset]. +*/ +typedef struct sqlite3_changeset_iter sqlite3_changeset_iter; + +/* +** CAPI3REF: Create A New Session Object +** CONSTRUCTOR: sqlite3_session +** +** Create a new session object attached to database handle db. If successful, +** a pointer to the new object is written to *ppSession and SQLITE_OK is +** returned. If an error occurs, *ppSession is set to NULL and an SQLite +** error code (e.g. SQLITE_NOMEM) is returned. +** +** It is possible to create multiple session objects attached to a single +** database handle. +** +** Session objects created using this function should be deleted using the +** [sqlite3session_delete()] function before the database handle that they +** are attached to is itself closed. If the database handle is closed before +** the session object is deleted, then the results of calling any session +** module function, including [sqlite3session_delete()] on the session object +** are undefined. +** +** Because the session module uses the [sqlite3_preupdate_hook()] API, it +** is not possible for an application to register a pre-update hook on a +** database handle that has one or more session objects attached. Nor is +** it possible to create a session object attached to a database handle for +** which a pre-update hook is already defined. The results of attempting +** either of these things are undefined. +** +** The session object will be used to create changesets for tables in +** database zDb, where zDb is either "main", or "temp", or the name of an +** attached database. It is not an error if database zDb is not attached +** to the database when the session object is created. +*/ +SQLITE_API int sqlite3session_create( + sqlite3 *db, /* Database handle */ + const char *zDb, /* Name of db (e.g. "main") */ + sqlite3_session **ppSession /* OUT: New session object */ +); + +/* +** CAPI3REF: Delete A Session Object +** DESTRUCTOR: sqlite3_session +** +** Delete a session object previously allocated using +** [sqlite3session_create()]. Once a session object has been deleted, the +** results of attempting to use pSession with any other session module +** function are undefined. +** +** Session objects must be deleted before the database handle to which they +** are attached is closed. Refer to the documentation for +** [sqlite3session_create()] for details. +*/ +SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); + +/* +** CAPI3REF: Configure a Session Object +** METHOD: sqlite3_session +** +** This method is used to configure a session object after it has been +** created. At present the only valid values for the second parameter are +** [SQLITE_SESSION_OBJCONFIG_SIZE] and [SQLITE_SESSION_OBJCONFIG_ROWID]. +** +*/ +SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg); + +/* +** CAPI3REF: Options for sqlite3session_object_config +** +** The following values may passed as the the 2nd parameter to +** sqlite3session_object_config(). +** +**
SQLITE_SESSION_OBJCONFIG_SIZE
+** This option is used to set, clear or query the flag that enables +** the [sqlite3session_changeset_size()] API. Because it imposes some +** computational overhead, this API is disabled by default. Argument +** pArg must point to a value of type (int). If the value is initially +** 0, then the sqlite3session_changeset_size() API is disabled. If it +** is greater than 0, then the same API is enabled. Or, if the initial +** value is less than zero, no change is made. In all cases the (int) +** variable is set to 1 if the sqlite3session_changeset_size() API is +** enabled following the current call, or 0 otherwise. +** +** It is an error (SQLITE_MISUSE) to attempt to modify this setting after +** the first table has been attached to the session object. +** +**
SQLITE_SESSION_OBJCONFIG_ROWID
+** This option is used to set, clear or query the flag that enables +** collection of data for tables with no explicit PRIMARY KEY. +** +** Normally, tables with no explicit PRIMARY KEY are simply ignored +** by the sessions module. However, if this flag is set, it behaves +** as if such tables have a column "_rowid_ INTEGER PRIMARY KEY" inserted +** as their leftmost columns. +** +** It is an error (SQLITE_MISUSE) to attempt to modify this setting after +** the first table has been attached to the session object. +*/ +#define SQLITE_SESSION_OBJCONFIG_SIZE 1 +#define SQLITE_SESSION_OBJCONFIG_ROWID 2 + +/* +** CAPI3REF: Enable Or Disable A Session Object +** METHOD: sqlite3_session +** +** Enable or disable the recording of changes by a session object. When +** enabled, a session object records changes made to the database. When +** disabled - it does not. A newly created session object is enabled. +** Refer to the documentation for [sqlite3session_changeset()] for further +** details regarding how enabling and disabling a session object affects +** the eventual changesets. +** +** Passing zero to this function disables the session. Passing a value +** greater than zero enables it. Passing a value less than zero is a +** no-op, and may be used to query the current state of the session. +** +** The return value indicates the final state of the session object: 0 if +** the session is disabled, or 1 if it is enabled. +*/ +SQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable); + +/* +** CAPI3REF: Set Or Clear the Indirect Change Flag +** METHOD: sqlite3_session +** +** Each change recorded by a session object is marked as either direct or +** indirect. A change is marked as indirect if either: +** +**
    +**
  • The session object "indirect" flag is set when the change is +** made, or +**
  • The change is made by an SQL trigger or foreign key action +** instead of directly as a result of a users SQL statement. +**
+** +** If a single row is affected by more than one operation within a session, +** then the change is considered indirect if all operations meet the criteria +** for an indirect change above, or direct otherwise. +** +** This function is used to set, clear or query the session object indirect +** flag. If the second argument passed to this function is zero, then the +** indirect flag is cleared. If it is greater than zero, the indirect flag +** is set. Passing a value less than zero does not modify the current value +** of the indirect flag, and may be used to query the current state of the +** indirect flag for the specified session object. +** +** The return value indicates the final state of the indirect flag: 0 if +** it is clear, or 1 if it is set. +*/ +SQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect); + +/* +** CAPI3REF: Attach A Table To A Session Object +** METHOD: sqlite3_session +** +** If argument zTab is not NULL, then it is the name of a table to attach +** to the session object passed as the first argument. All subsequent changes +** made to the table while the session object is enabled will be recorded. See +** documentation for [sqlite3session_changeset()] for further details. +** +** Or, if argument zTab is NULL, then changes are recorded for all tables +** in the database. If additional tables are added to the database (by +** executing "CREATE TABLE" statements) after this call is made, changes for +** the new tables are also recorded. +** +** Changes can only be recorded for tables that have a PRIMARY KEY explicitly +** defined as part of their CREATE TABLE statement. It does not matter if the +** PRIMARY KEY is an "INTEGER PRIMARY KEY" (rowid alias) or not. The PRIMARY +** KEY may consist of a single column, or may be a composite key. +** +** It is not an error if the named table does not exist in the database. Nor +** is it an error if the named table does not have a PRIMARY KEY. However, +** no changes will be recorded in either of these scenarios. +** +** Changes are not recorded for individual rows that have NULL values stored +** in one or more of their PRIMARY KEY columns. +** +** SQLITE_OK is returned if the call completes without error. Or, if an error +** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned. +** +**

Special sqlite_stat1 Handling

+** +** As of SQLite version 3.22.0, the "sqlite_stat1" table is an exception to +** some of the rules above. In SQLite, the schema of sqlite_stat1 is: +**
+**        CREATE TABLE sqlite_stat1(tbl,idx,stat)
+**  
+** +** Even though sqlite_stat1 does not have a PRIMARY KEY, changes are +** recorded for it as if the PRIMARY KEY is (tbl,idx). Additionally, changes +** are recorded for rows for which (idx IS NULL) is true. However, for such +** rows a zero-length blob (SQL value X'') is stored in the changeset or +** patchset instead of a NULL value. This allows such changesets to be +** manipulated by legacy implementations of sqlite3changeset_invert(), +** concat() and similar. +** +** The sqlite3changeset_apply() function automatically converts the +** zero-length blob back to a NULL value when updating the sqlite_stat1 +** table. However, if the application calls sqlite3changeset_new(), +** sqlite3changeset_old() or sqlite3changeset_conflict on a changeset +** iterator directly (including on a changeset iterator passed to a +** conflict-handler callback) then the X'' value is returned. The application +** must translate X'' to NULL itself if required. +** +** Legacy (older than 3.22.0) versions of the sessions module cannot capture +** changes made to the sqlite_stat1 table. Legacy versions of the +** sqlite3changeset_apply() function silently ignore any modifications to the +** sqlite_stat1 table that are part of a changeset or patchset. +*/ +SQLITE_API int sqlite3session_attach( + sqlite3_session *pSession, /* Session object */ + const char *zTab /* Table name */ +); + +/* +** CAPI3REF: Set a table filter on a Session Object. +** METHOD: sqlite3_session +** +** The second argument (xFilter) is the "filter callback". For changes to rows +** in tables that are not attached to the Session object, the filter is called +** to determine whether changes to the table's rows should be tracked or not. +** If xFilter returns 0, changes are not tracked. Note that once a table is +** attached, xFilter will not be called again. +*/ +SQLITE_API void sqlite3session_table_filter( + sqlite3_session *pSession, /* Session object */ + int(*xFilter)( + void *pCtx, /* Copy of third arg to _filter_table() */ + const char *zTab /* Table name */ + ), + void *pCtx /* First argument passed to xFilter */ +); + +/* +** CAPI3REF: Generate A Changeset From A Session Object +** METHOD: sqlite3_session +** +** Obtain a changeset containing changes to the tables attached to the +** session object passed as the first argument. If successful, +** set *ppChangeset to point to a buffer containing the changeset +** and *pnChangeset to the size of the changeset in bytes before returning +** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to +** zero and return an SQLite error code. +** +** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes, +** each representing a change to a single row of an attached table. An INSERT +** change contains the values of each field of a new database row. A DELETE +** contains the original values of each field of a deleted database row. An +** UPDATE change contains the original values of each field of an updated +** database row along with the updated values for each updated non-primary-key +** column. It is not possible for an UPDATE change to represent a change that +** modifies the values of primary key columns. If such a change is made, it +** is represented in a changeset as a DELETE followed by an INSERT. +** +** Changes are not recorded for rows that have NULL values stored in one or +** more of their PRIMARY KEY columns. If such a row is inserted or deleted, +** no corresponding change is present in the changesets returned by this +** function. If an existing row with one or more NULL values stored in +** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL, +** only an INSERT is appears in the changeset. Similarly, if an existing row +** with non-NULL PRIMARY KEY values is updated so that one or more of its +** PRIMARY KEY columns are set to NULL, the resulting changeset contains a +** DELETE change only. +** +** The contents of a changeset may be traversed using an iterator created +** using the [sqlite3changeset_start()] API. A changeset may be applied to +** a database with a compatible schema using the [sqlite3changeset_apply()] +** API. +** +** Within a changeset generated by this function, all changes related to a +** single table are grouped together. In other words, when iterating through +** a changeset or when applying a changeset to a database, all changes related +** to a single table are processed before moving on to the next table. Tables +** are sorted in the same order in which they were attached (or auto-attached) +** to the sqlite3_session object. The order in which the changes related to +** a single table are stored is undefined. +** +** Following a successful call to this function, it is the responsibility of +** the caller to eventually free the buffer that *ppChangeset points to using +** [sqlite3_free()]. +** +**

Changeset Generation

+** +** Once a table has been attached to a session object, the session object +** records the primary key values of all new rows inserted into the table. +** It also records the original primary key and other column values of any +** deleted or updated rows. For each unique primary key value, data is only +** recorded once - the first time a row with said primary key is inserted, +** updated or deleted in the lifetime of the session. +** +** There is one exception to the previous paragraph: when a row is inserted, +** updated or deleted, if one or more of its primary key columns contain a +** NULL value, no record of the change is made. +** +** The session object therefore accumulates two types of records - those +** that consist of primary key values only (created when the user inserts +** a new record) and those that consist of the primary key values and the +** original values of other table columns (created when the users deletes +** or updates a record). +** +** When this function is called, the requested changeset is created using +** both the accumulated records and the current contents of the database +** file. Specifically: +** +**
    +**
  • For each record generated by an insert, the database is queried +** for a row with a matching primary key. If one is found, an INSERT +** change is added to the changeset. If no such row is found, no change +** is added to the changeset. +** +**
  • For each record generated by an update or delete, the database is +** queried for a row with a matching primary key. If such a row is +** found and one or more of the non-primary key fields have been +** modified from their original values, an UPDATE change is added to +** the changeset. Or, if no such row is found in the table, a DELETE +** change is added to the changeset. If there is a row with a matching +** primary key in the database, but all fields contain their original +** values, no change is added to the changeset. +**
+** +** This means, amongst other things, that if a row is inserted and then later +** deleted while a session object is active, neither the insert nor the delete +** will be present in the changeset. Or if a row is deleted and then later a +** row with the same primary key values inserted while a session object is +** active, the resulting changeset will contain an UPDATE change instead of +** a DELETE and an INSERT. +** +** When a session object is disabled (see the [sqlite3session_enable()] API), +** it does not accumulate records when rows are inserted, updated or deleted. +** This may appear to have some counter-intuitive effects if a single row +** is written to more than once during a session. For example, if a row +** is inserted while a session object is enabled, then later deleted while +** the same session object is disabled, no INSERT record will appear in the +** changeset, even though the delete took place while the session was disabled. +** Or, if one field of a row is updated while a session is enabled, and +** then another field of the same row is updated while the session is disabled, +** the resulting changeset will contain an UPDATE change that updates both +** fields. +*/ +SQLITE_API int sqlite3session_changeset( + sqlite3_session *pSession, /* Session object */ + int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ + void **ppChangeset /* OUT: Buffer containing changeset */ +); + +/* +** CAPI3REF: Return An Upper-limit For The Size Of The Changeset +** METHOD: sqlite3_session +** +** By default, this function always returns 0. For it to return +** a useful result, the sqlite3_session object must have been configured +** to enable this API using sqlite3session_object_config() with the +** SQLITE_SESSION_OBJCONFIG_SIZE verb. +** +** When enabled, this function returns an upper limit, in bytes, for the size +** of the changeset that might be produced if sqlite3session_changeset() were +** called. The final changeset size might be equal to or smaller than the +** size in bytes returned by this function. +*/ +SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession); + +/* +** CAPI3REF: Load The Difference Between Tables Into A Session +** METHOD: sqlite3_session +** +** If it is not already attached to the session object passed as the first +** argument, this function attaches table zTbl in the same manner as the +** [sqlite3session_attach()] function. If zTbl does not exist, or if it +** does not have a primary key, this function is a no-op (but does not return +** an error). +** +** Argument zFromDb must be the name of a database ("main", "temp" etc.) +** attached to the same database handle as the session object that contains +** a table compatible with the table attached to the session by this function. +** A table is considered compatible if it: +** +**
    +**
  • Has the same name, +**
  • Has the same set of columns declared in the same order, and +**
  • Has the same PRIMARY KEY definition. +**
+** +** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables +** are compatible but do not have any PRIMARY KEY columns, it is not an error +** but no changes are added to the session object. As with other session +** APIs, tables without PRIMARY KEYs are simply ignored. +** +** This function adds a set of changes to the session object that could be +** used to update the table in database zFrom (call this the "from-table") +** so that its content is the same as the table attached to the session +** object (call this the "to-table"). Specifically: +** +**
    +**
  • For each row (primary key) that exists in the to-table but not in +** the from-table, an INSERT record is added to the session object. +** +**
  • For each row (primary key) that exists in the to-table but not in +** the from-table, a DELETE record is added to the session object. +** +**
  • For each row (primary key) that exists in both tables, but features +** different non-PK values in each, an UPDATE record is added to the +** session. +**
+** +** To clarify, if this function is called and then a changeset constructed +** using [sqlite3session_changeset()], then after applying that changeset to +** database zFrom the contents of the two compatible tables would be +** identical. +** +** Unless the call to this function is a no-op as described above, it is an +** error if database zFrom does not exist or does not contain the required +** compatible table. +** +** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite +** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg +** may be set to point to a buffer containing an English language error +** message. It is the responsibility of the caller to free this buffer using +** sqlite3_free(). +*/ +SQLITE_API int sqlite3session_diff( + sqlite3_session *pSession, + const char *zFromDb, + const char *zTbl, + char **pzErrMsg +); + + +/* +** CAPI3REF: Generate A Patchset From A Session Object +** METHOD: sqlite3_session +** +** The differences between a patchset and a changeset are that: +** +**
    +**
  • DELETE records consist of the primary key fields only. The +** original values of other fields are omitted. +**
  • The original values of any modified fields are omitted from +** UPDATE records. +**
+** +** A patchset blob may be used with up to date versions of all +** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), +** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly, +** attempting to use a patchset blob with old versions of the +** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. +** +** Because the non-primary key "old.*" fields are omitted, no +** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset +** is passed to the sqlite3changeset_apply() API. Other conflict types work +** in the same way as for changesets. +** +** Changes within a patchset are ordered in the same way as for changesets +** generated by the sqlite3session_changeset() function (i.e. all changes for +** a single table are grouped together, tables appear in the order in which +** they were attached to the session object). +*/ +SQLITE_API int sqlite3session_patchset( + sqlite3_session *pSession, /* Session object */ + int *pnPatchset, /* OUT: Size of buffer at *ppPatchset */ + void **ppPatchset /* OUT: Buffer containing patchset */ +); + +/* +** CAPI3REF: Test if a changeset has recorded any changes. +** +** Return non-zero if no changes to attached tables have been recorded by +** the session object passed as the first argument. Otherwise, if one or +** more changes have been recorded, return zero. +** +** Even if this function returns zero, it is possible that calling +** [sqlite3session_changeset()] on the session handle may still return a +** changeset that contains no changes. This can happen when a row in +** an attached table is modified and then later on the original values +** are restored. However, if this function returns non-zero, then it is +** guaranteed that a call to sqlite3session_changeset() will return a +** changeset containing zero changes. +*/ +SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); + +/* +** CAPI3REF: Query for the amount of heap memory used by a session object. +** +** This API returns the total amount of heap memory in bytes currently +** used by the session object passed as the only argument. +*/ +SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession); + +/* +** CAPI3REF: Create An Iterator To Traverse A Changeset +** CONSTRUCTOR: sqlite3_changeset_iter +** +** Create an iterator used to iterate through the contents of a changeset. +** If successful, *pp is set to point to the iterator handle and SQLITE_OK +** is returned. Otherwise, if an error occurs, *pp is set to zero and an +** SQLite error code is returned. +** +** The following functions can be used to advance and query a changeset +** iterator created by this function: +** +**
    +**
  • [sqlite3changeset_next()] +**
  • [sqlite3changeset_op()] +**
  • [sqlite3changeset_new()] +**
  • [sqlite3changeset_old()] +**
+** +** It is the responsibility of the caller to eventually destroy the iterator +** by passing it to [sqlite3changeset_finalize()]. The buffer containing the +** changeset (pChangeset) must remain valid until after the iterator is +** destroyed. +** +** Assuming the changeset blob was created by one of the +** [sqlite3session_changeset()], [sqlite3changeset_concat()] or +** [sqlite3changeset_invert()] functions, all changes within the changeset +** that apply to a single table are grouped together. This means that when +** an application iterates through a changeset using an iterator created by +** this function, all changes that relate to a single table are visited +** consecutively. There is no chance that the iterator will visit a change +** the applies to table X, then one for table Y, and then later on visit +** another change for table X. +** +** The behavior of sqlite3changeset_start_v2() and its streaming equivalent +** may be modified by passing a combination of +** [SQLITE_CHANGESETSTART_INVERT | supported flags] as the 4th parameter. +** +** Note that the sqlite3changeset_start_v2() API is still experimental +** and therefore subject to change. +*/ +SQLITE_API int sqlite3changeset_start( + sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */ + int nChangeset, /* Size of changeset blob in bytes */ + void *pChangeset /* Pointer to blob containing changeset */ +); +SQLITE_API int sqlite3changeset_start_v2( + sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */ + int nChangeset, /* Size of changeset blob in bytes */ + void *pChangeset, /* Pointer to blob containing changeset */ + int flags /* SESSION_CHANGESETSTART_* flags */ +); + +/* +** CAPI3REF: Flags for sqlite3changeset_start_v2 +** +** The following flags may passed via the 4th parameter to +** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]: +** +**
SQLITE_CHANGESETSTART_INVERT
+** Invert the changeset while iterating through it. This is equivalent to +** inverting a changeset using sqlite3changeset_invert() before applying it. +** It is an error to specify this flag with a patchset. +*/ +#define SQLITE_CHANGESETSTART_INVERT 0x0002 + + +/* +** CAPI3REF: Advance A Changeset Iterator +** METHOD: sqlite3_changeset_iter +** +** This function may only be used with iterators created by the function +** [sqlite3changeset_start()]. If it is called on an iterator passed to +** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE +** is returned and the call has no effect. +** +** Immediately after an iterator is created by sqlite3changeset_start(), it +** does not point to any change in the changeset. Assuming the changeset +** is not empty, the first call to this function advances the iterator to +** point to the first change in the changeset. Each subsequent call advances +** the iterator to point to the next change in the changeset (if any). If +** no error occurs and the iterator points to a valid change after a call +** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. +** Otherwise, if all changes in the changeset have already been visited, +** SQLITE_DONE is returned. +** +** If an error occurs, an SQLite error code is returned. Possible error +** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or +** SQLITE_NOMEM. +*/ +SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter); + +/* +** CAPI3REF: Obtain The Current Operation From A Changeset Iterator +** METHOD: sqlite3_changeset_iter +** +** The pIter argument passed to this function may either be an iterator +** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator +** created by [sqlite3changeset_start()]. In the latter case, the most recent +** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this +** is not the case, this function returns [SQLITE_MISUSE]. +** +** Arguments pOp, pnCol and pzTab may not be NULL. Upon return, three +** outputs are set through these pointers: +** +** *pOp is set to one of [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], +** depending on the type of change that the iterator currently points to; +** +** *pnCol is set to the number of columns in the table affected by the change; and +** +** *pzTab is set to point to a nul-terminated utf-8 encoded string containing +** the name of the table affected by the current change. The buffer remains +** valid until either sqlite3changeset_next() is called on the iterator +** or until the conflict-handler function returns. +** +** If pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change +** is an indirect change, or false (0) otherwise. See the documentation for +** [sqlite3session_indirect()] for a description of direct and indirect +** changes. +** +** If no error occurs, SQLITE_OK is returned. If an error does occur, an +** SQLite error code is returned. The values of the output variables may not +** be trusted in this case. +*/ +SQLITE_API int sqlite3changeset_op( + sqlite3_changeset_iter *pIter, /* Iterator object */ + const char **pzTab, /* OUT: Pointer to table name */ + int *pnCol, /* OUT: Number of columns in table */ + int *pOp, /* OUT: SQLITE_INSERT, DELETE or UPDATE */ + int *pbIndirect /* OUT: True for an 'indirect' change */ +); + +/* +** CAPI3REF: Obtain The Primary Key Definition Of A Table +** METHOD: sqlite3_changeset_iter +** +** For each modified table, a changeset includes the following: +** +**
    +**
  • The number of columns in the table, and +**
  • Which of those columns make up the tables PRIMARY KEY. +**
+** +** This function is used to find which columns comprise the PRIMARY KEY of +** the table modified by the change that iterator pIter currently points to. +** If successful, *pabPK is set to point to an array of nCol entries, where +** nCol is the number of columns in the table. Elements of *pabPK are set to +** 0x01 if the corresponding column is part of the tables primary key, or +** 0x00 if it is not. +** +** If argument pnCol is not NULL, then *pnCol is set to the number of columns +** in the table. +** +** If this function is called when the iterator does not point to a valid +** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise, +** SQLITE_OK is returned and the output variables populated as described +** above. +*/ +SQLITE_API int sqlite3changeset_pk( + sqlite3_changeset_iter *pIter, /* Iterator object */ + unsigned char **pabPK, /* OUT: Array of boolean - true for PK cols */ + int *pnCol /* OUT: Number of entries in output array */ +); + +/* +** CAPI3REF: Obtain old.* Values From A Changeset Iterator +** METHOD: sqlite3_changeset_iter +** +** The pIter argument passed to this function may either be an iterator +** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator +** created by [sqlite3changeset_start()]. In the latter case, the most recent +** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. +** Furthermore, it may only be called if the type of change that the iterator +** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise, +** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL. +** +** Argument iVal must be greater than or equal to 0, and less than the number +** of columns in the table affected by the current change. Otherwise, +** [SQLITE_RANGE] is returned and *ppValue is set to NULL. +** +** If successful, this function sets *ppValue to point to a protected +** sqlite3_value object containing the iVal'th value from the vector of +** original row values stored as part of the UPDATE or DELETE change and +** returns SQLITE_OK. The name of the function comes from the fact that this +** is similar to the "old.*" columns available to update or delete triggers. +** +** If some other error occurs (e.g. an OOM condition), an SQLite error code +** is returned and *ppValue is set to NULL. +*/ +SQLITE_API int sqlite3changeset_old( + sqlite3_changeset_iter *pIter, /* Changeset iterator */ + int iVal, /* Column number */ + sqlite3_value **ppValue /* OUT: Old value (or NULL pointer) */ +); + +/* +** CAPI3REF: Obtain new.* Values From A Changeset Iterator +** METHOD: sqlite3_changeset_iter +** +** The pIter argument passed to this function may either be an iterator +** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator +** created by [sqlite3changeset_start()]. In the latter case, the most recent +** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. +** Furthermore, it may only be called if the type of change that the iterator +** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise, +** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL. +** +** Argument iVal must be greater than or equal to 0, and less than the number +** of columns in the table affected by the current change. Otherwise, +** [SQLITE_RANGE] is returned and *ppValue is set to NULL. +** +** If successful, this function sets *ppValue to point to a protected +** sqlite3_value object containing the iVal'th value from the vector of +** new row values stored as part of the UPDATE or INSERT change and +** returns SQLITE_OK. If the change is an UPDATE and does not include +** a new value for the requested column, *ppValue is set to NULL and +** SQLITE_OK returned. The name of the function comes from the fact that +** this is similar to the "new.*" columns available to update or delete +** triggers. +** +** If some other error occurs (e.g. an OOM condition), an SQLite error code +** is returned and *ppValue is set to NULL. +*/ +SQLITE_API int sqlite3changeset_new( + sqlite3_changeset_iter *pIter, /* Changeset iterator */ + int iVal, /* Column number */ + sqlite3_value **ppValue /* OUT: New value (or NULL pointer) */ +); + +/* +** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator +** METHOD: sqlite3_changeset_iter +** +** This function should only be used with iterator objects passed to a +** conflict-handler callback by [sqlite3changeset_apply()] with either +** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function +** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue +** is set to NULL. +** +** Argument iVal must be greater than or equal to 0, and less than the number +** of columns in the table affected by the current change. Otherwise, +** [SQLITE_RANGE] is returned and *ppValue is set to NULL. +** +** If successful, this function sets *ppValue to point to a protected +** sqlite3_value object containing the iVal'th value from the +** "conflicting row" associated with the current conflict-handler callback +** and returns SQLITE_OK. +** +** If some other error occurs (e.g. an OOM condition), an SQLite error code +** is returned and *ppValue is set to NULL. +*/ +SQLITE_API int sqlite3changeset_conflict( + sqlite3_changeset_iter *pIter, /* Changeset iterator */ + int iVal, /* Column number */ + sqlite3_value **ppValue /* OUT: Value from conflicting row */ +); + +/* +** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations +** METHOD: sqlite3_changeset_iter +** +** This function may only be called with an iterator passed to an +** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case +** it sets the output variable to the total number of known foreign key +** violations in the destination database and returns SQLITE_OK. +** +** In all other cases this function returns SQLITE_MISUSE. +*/ +SQLITE_API int sqlite3changeset_fk_conflicts( + sqlite3_changeset_iter *pIter, /* Changeset iterator */ + int *pnOut /* OUT: Number of FK violations */ +); + + +/* +** CAPI3REF: Finalize A Changeset Iterator +** METHOD: sqlite3_changeset_iter +** +** This function is used to finalize an iterator allocated with +** [sqlite3changeset_start()]. +** +** This function should only be called on iterators created using the +** [sqlite3changeset_start()] function. If an application calls this +** function with an iterator passed to a conflict-handler by +** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the +** call has no effect. +** +** If an error was encountered within a call to an sqlite3changeset_xxx() +** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an +** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding +** to that error is returned by this function. Otherwise, SQLITE_OK is +** returned. This is to allow the following pattern (pseudo-code): +** +**
+**   sqlite3changeset_start();
+**   while( SQLITE_ROW==sqlite3changeset_next() ){
+**     // Do something with change.
+**   }
+**   rc = sqlite3changeset_finalize();
+**   if( rc!=SQLITE_OK ){
+**     // An error has occurred
+**   }
+** 
+*/ +SQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter); + +/* +** CAPI3REF: Invert A Changeset +** +** This function is used to "invert" a changeset object. Applying an inverted +** changeset to a database reverses the effects of applying the uninverted +** changeset. Specifically: +** +**
    +**
  • Each DELETE change is changed to an INSERT, and +**
  • Each INSERT change is changed to a DELETE, and +**
  • For each UPDATE change, the old.* and new.* values are exchanged. +**
+** +** This function does not change the order in which changes appear within +** the changeset. It merely reverses the sense of each individual change. +** +** If successful, a pointer to a buffer containing the inverted changeset +** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and +** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are +** zeroed and an SQLite error code returned. +** +** It is the responsibility of the caller to eventually call sqlite3_free() +** on the *ppOut pointer to free the buffer allocation following a successful +** call to this function. +** +** WARNING/TODO: This function currently assumes that the input is a valid +** changeset. If it is not, the results are undefined. +*/ +SQLITE_API int sqlite3changeset_invert( + int nIn, const void *pIn, /* Input changeset */ + int *pnOut, void **ppOut /* OUT: Inverse of input */ +); + +/* +** CAPI3REF: Concatenate Two Changeset Objects +** +** This function is used to concatenate two changesets, A and B, into a +** single changeset. The result is a changeset equivalent to applying +** changeset A followed by changeset B. +** +** This function combines the two input changesets using an +** sqlite3_changegroup object. Calling it produces similar results as the +** following code fragment: +** +**
+**   sqlite3_changegroup *pGrp;
+**   rc = sqlite3_changegroup_new(&pGrp);
+**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);
+**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);
+**   if( rc==SQLITE_OK ){
+**     rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);
+**   }else{
+**     *ppOut = 0;
+**     *pnOut = 0;
+**   }
+** 
+** +** Refer to the sqlite3_changegroup documentation below for details. +*/ +SQLITE_API int sqlite3changeset_concat( + int nA, /* Number of bytes in buffer pA */ + void *pA, /* Pointer to buffer containing changeset A */ + int nB, /* Number of bytes in buffer pB */ + void *pB, /* Pointer to buffer containing changeset B */ + int *pnOut, /* OUT: Number of bytes in output changeset */ + void **ppOut /* OUT: Buffer containing output changeset */ +); + +/* +** CAPI3REF: Changegroup Handle +** +** A changegroup is an object used to combine two or more +** [changesets] or [patchsets] +*/ +typedef struct sqlite3_changegroup sqlite3_changegroup; + +/* +** CAPI3REF: Create A New Changegroup Object +** CONSTRUCTOR: sqlite3_changegroup +** +** An sqlite3_changegroup object is used to combine two or more changesets +** (or patchsets) into a single changeset (or patchset). A single changegroup +** object may combine changesets or patchsets, but not both. The output is +** always in the same format as the input. +** +** If successful, this function returns SQLITE_OK and populates (*pp) with +** a pointer to a new sqlite3_changegroup object before returning. The caller +** should eventually free the returned object using a call to +** sqlite3changegroup_delete(). If an error occurs, an SQLite error code +** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL. +** +** The usual usage pattern for an sqlite3_changegroup object is as follows: +** +**
    +**
  • It is created using a call to sqlite3changegroup_new(). +** +**
  • Zero or more changesets (or patchsets) are added to the object +** by calling sqlite3changegroup_add(). +** +**
  • The result of combining all input changesets together is obtained +** by the application via a call to sqlite3changegroup_output(). +** +**
  • The object is deleted using a call to sqlite3changegroup_delete(). +**
+** +** Any number of calls to add() and output() may be made between the calls to +** new() and delete(), and in any order. +** +** As well as the regular sqlite3changegroup_add() and +** sqlite3changegroup_output() functions, also available are the streaming +** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). +*/ +SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); + +/* +** CAPI3REF: Add a Schema to a Changegroup +** METHOD: sqlite3_changegroup_schema +** +** This method may be used to optionally enforce the rule that the changesets +** added to the changegroup handle must match the schema of database zDb +** ("main", "temp", or the name of an attached database). If +** sqlite3changegroup_add() is called to add a changeset that is not compatible +** with the configured schema, SQLITE_SCHEMA is returned and the changegroup +** object is left in an undefined state. +** +** A changeset schema is considered compatible with the database schema in +** the same way as for sqlite3changeset_apply(). Specifically, for each +** table in the changeset, there exists a database table with: +** +**
    +**
  • The name identified by the changeset, and +**
  • at least as many columns as recorded in the changeset, and +**
  • the primary key columns in the same position as recorded in +** the changeset. +**
+** +** The output of the changegroup object always has the same schema as the +** database nominated using this function. In cases where changesets passed +** to sqlite3changegroup_add() have fewer columns than the corresponding table +** in the database schema, these are filled in using the default column +** values from the database schema. This makes it possible to combined +** changesets that have different numbers of columns for a single table +** within a changegroup, provided that they are otherwise compatible. +*/ +SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); + +/* +** CAPI3REF: Add A Changeset To A Changegroup +** METHOD: sqlite3_changegroup +** +** Add all changes within the changeset (or patchset) in buffer pData (size +** nData bytes) to the changegroup. +** +** If the buffer contains a patchset, then all prior calls to this function +** on the same changegroup object must also have specified patchsets. Or, if +** the buffer contains a changeset, so must have the earlier calls to this +** function. Otherwise, SQLITE_ERROR is returned and no changes are added +** to the changegroup. +** +** Rows within the changeset and changegroup are identified by the values in +** their PRIMARY KEY columns. A change in the changeset is considered to +** apply to the same row as a change already present in the changegroup if +** the two rows have the same primary key. +** +** Changes to rows that do not already appear in the changegroup are +** simply copied into it. Or, if both the new changeset and the changegroup +** contain changes that apply to a single row, the final contents of the +** changegroup depends on the type of each change, as follows: +** +** +** +** +**
Existing Change New Change Output Change +**
INSERT INSERT +** The new change is ignored. This case does not occur if the new +** changeset was recorded immediately after the changesets already +** added to the changegroup. +**
INSERT UPDATE +** The INSERT change remains in the changegroup. The values in the +** INSERT change are modified as if the row was inserted by the +** existing change and then updated according to the new change. +**
INSERT DELETE +** The existing INSERT is removed from the changegroup. The DELETE is +** not added. +**
UPDATE INSERT +** The new change is ignored. This case does not occur if the new +** changeset was recorded immediately after the changesets already +** added to the changegroup. +**
UPDATE UPDATE +** The existing UPDATE remains within the changegroup. It is amended +** so that the accompanying values are as if the row was updated once +** by the existing change and then again by the new change. +**
UPDATE DELETE +** The existing UPDATE is replaced by the new DELETE within the +** changegroup. +**
DELETE INSERT +** If one or more of the column values in the row inserted by the +** new change differ from those in the row deleted by the existing +** change, the existing DELETE is replaced by an UPDATE within the +** changegroup. Otherwise, if the inserted row is exactly the same +** as the deleted row, the existing DELETE is simply discarded. +**
DELETE UPDATE +** The new change is ignored. This case does not occur if the new +** changeset was recorded immediately after the changesets already +** added to the changegroup. +**
DELETE DELETE +** The new change is ignored. This case does not occur if the new +** changeset was recorded immediately after the changesets already +** added to the changegroup. +**
+** +** If the new changeset contains changes to a table that is already present +** in the changegroup, then the number of columns and the position of the +** primary key columns for the table must be consistent. If this is not the +** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup +** object has been configured with a database schema using the +** sqlite3changegroup_schema() API, then it is possible to combine changesets +** with different numbers of columns for a single table, provided that +** they are otherwise compatible. +** +** If the input changeset appears to be corrupt and the corruption is +** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition +** occurs during processing, this function returns SQLITE_NOMEM. +** +** In all cases, if an error occurs the state of the final contents of the +** changegroup is undefined. If no error occurs, SQLITE_OK is returned. +*/ +SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); + +/* +** CAPI3REF: Add A Single Change To A Changegroup +** METHOD: sqlite3_changegroup +** +** This function adds the single change currently indicated by the iterator +** passed as the second argument to the changegroup object. The rules for +** adding the change are just as described for [sqlite3changegroup_add()]. +** +** If the change is successfully added to the changegroup, SQLITE_OK is +** returned. Otherwise, an SQLite error code is returned. +** +** The iterator must point to a valid entry when this function is called. +** If it does not, SQLITE_ERROR is returned and no change is added to the +** changegroup. Additionally, the iterator must not have been opened with +** the SQLITE_CHANGESETAPPLY_INVERT flag. In this case SQLITE_ERROR is also +** returned. +*/ +SQLITE_API int sqlite3changegroup_add_change( + sqlite3_changegroup*, + sqlite3_changeset_iter* +); + + + +/* +** CAPI3REF: Obtain A Composite Changeset From A Changegroup +** METHOD: sqlite3_changegroup +** +** Obtain a buffer containing a changeset (or patchset) representing the +** current contents of the changegroup. If the inputs to the changegroup +** were themselves changesets, the output is a changeset. Or, if the +** inputs were patchsets, the output is also a patchset. +** +** As with the output of the sqlite3session_changeset() and +** sqlite3session_patchset() functions, all changes related to a single +** table are grouped together in the output of this function. Tables appear +** in the same order as for the very first changeset added to the changegroup. +** If the second or subsequent changesets added to the changegroup contain +** changes for tables that do not appear in the first changeset, they are +** appended onto the end of the output changeset, again in the order in +** which they are first encountered. +** +** If an error occurs, an SQLite error code is returned and the output +** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK +** is returned and the output variables are set to the size of and a +** pointer to the output buffer, respectively. In this case it is the +** responsibility of the caller to eventually free the buffer using a +** call to sqlite3_free(). +*/ +SQLITE_API int sqlite3changegroup_output( + sqlite3_changegroup*, + int *pnData, /* OUT: Size of output buffer in bytes */ + void **ppData /* OUT: Pointer to output buffer */ +); + +/* +** CAPI3REF: Delete A Changegroup Object +** DESTRUCTOR: sqlite3_changegroup +*/ +SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); + +/* +** CAPI3REF: Apply A Changeset To A Database +** +** Apply a changeset or patchset to a database. These functions attempt to +** update the "main" database attached to handle db with the changes found in +** the changeset passed via the second and third arguments. +** +** The fourth argument (xFilter) passed to these functions is the "filter +** callback". If it is not NULL, then for each table affected by at least one +** change in the changeset, the filter callback is invoked with +** the table name as the second argument, and a copy of the context pointer +** passed as the sixth argument as the first. If the "filter callback" +** returns zero, then no attempt is made to apply any changes to the table. +** Otherwise, if the return value is non-zero or the xFilter argument to +** is NULL, all changes related to the table are attempted. +** +** For each table that is not excluded by the filter callback, this function +** tests that the target database contains a compatible table. A table is +** considered compatible if all of the following are true: +** +**
    +**
  • The table has the same name as the name recorded in the +** changeset, and +**
  • The table has at least as many columns as recorded in the +** changeset, and +**
  • The table has primary key columns in the same position as +** recorded in the changeset. +**
+** +** If there is no compatible table, it is not an error, but none of the +** changes associated with the table are applied. A warning message is issued +** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most +** one such warning is issued for each table in the changeset. +** +** For each change for which there is a compatible table, an attempt is made +** to modify the table contents according to the UPDATE, INSERT or DELETE +** change. If a change cannot be applied cleanly, the conflict handler +** function passed as the fifth argument to sqlite3changeset_apply() may be +** invoked. A description of exactly when the conflict handler is invoked for +** each type of change is below. +** +** Unlike the xFilter argument, xConflict may not be passed NULL. The results +** of passing anything other than a valid function pointer as the xConflict +** argument are undefined. +** +** Each time the conflict handler function is invoked, it must return one +** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or +** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned +** if the second argument passed to the conflict handler is either +** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler +** returns an illegal value, any changes already made are rolled back and +** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different +** actions are taken by sqlite3changeset_apply() depending on the value +** returned by each invocation of the conflict-handler function. Refer to +** the documentation for the three +** [SQLITE_CHANGESET_OMIT|available return values] for details. +** +**
+**
DELETE Changes
+** For each DELETE change, the function checks if the target database +** contains a row with the same primary key value (or values) as the +** original row values stored in the changeset. If it does, and the values +** stored in all non-primary key columns also match the values stored in +** the changeset the row is deleted from the target database. +** +** If a row with matching primary key values is found, but one or more of +** the non-primary key fields contains a value different from the original +** row value stored in the changeset, the conflict-handler function is +** invoked with [SQLITE_CHANGESET_DATA] as the second argument. If the +** database table has more columns than are recorded in the changeset, +** only the values of those non-primary key fields are compared against +** the current database contents - any trailing database table columns +** are ignored. +** +** If no row with matching primary key values is found in the database, +** the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND] +** passed as the second argument. +** +** If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT +** (which can only happen if a foreign key constraint is violated), the +** conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT] +** passed as the second argument. This includes the case where the DELETE +** operation is attempted because an earlier call to the conflict handler +** function returned [SQLITE_CHANGESET_REPLACE]. +** +**
INSERT Changes
+** For each INSERT change, an attempt is made to insert the new row into +** the database. If the changeset row contains fewer fields than the +** database table, the trailing fields are populated with their default +** values. +** +** If the attempt to insert the row fails because the database already +** contains a row with the same primary key values, the conflict handler +** function is invoked with the second argument set to +** [SQLITE_CHANGESET_CONFLICT]. +** +** If the attempt to insert the row fails because of some other constraint +** violation (e.g. NOT NULL or UNIQUE), the conflict handler function is +** invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT]. +** This includes the case where the INSERT operation is re-attempted because +** an earlier call to the conflict handler function returned +** [SQLITE_CHANGESET_REPLACE]. +** +**
UPDATE Changes
+** For each UPDATE change, the function checks if the target database +** contains a row with the same primary key value (or values) as the +** original row values stored in the changeset. If it does, and the values +** stored in all modified non-primary key columns also match the values +** stored in the changeset the row is updated within the target database. +** +** If a row with matching primary key values is found, but one or more of +** the modified non-primary key fields contains a value different from an +** original row value stored in the changeset, the conflict-handler function +** is invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since +** UPDATE changes only contain values for non-primary key fields that are +** to be modified, only those fields need to match the original values to +** avoid the SQLITE_CHANGESET_DATA conflict-handler callback. +** +** If no row with matching primary key values is found in the database, +** the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND] +** passed as the second argument. +** +** If the UPDATE operation is attempted, but SQLite returns +** SQLITE_CONSTRAINT, the conflict-handler function is invoked with +** [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument. +** This includes the case where the UPDATE operation is attempted after +** an earlier call to the conflict handler function returned +** [SQLITE_CHANGESET_REPLACE]. +**
+** +** It is safe to execute SQL statements, including those that write to the +** table that the callback related to, from within the xConflict callback. +** This can be used to further customize the application's conflict +** resolution strategy. +** +** All changes made by these functions are enclosed in a savepoint transaction. +** If any other error (aside from a constraint failure when attempting to +** write to the target database) occurs, then the savepoint transaction is +** rolled back, restoring the target database to its original state, and an +** SQLite error code returned. +** +** If the output parameters (ppRebase) and (pnRebase) are non-NULL and +** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2() +** may set (*ppRebase) to point to a "rebase" that may be used with the +** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase) +** is set to the size of the buffer in bytes. It is the responsibility of the +** caller to eventually free any such buffer using sqlite3_free(). The buffer +** is only allocated and populated if one or more conflicts were encountered +** while applying the patchset. See comments surrounding the sqlite3_rebaser +** APIs for further details. +** +** The behavior of sqlite3changeset_apply_v2() and its streaming equivalent +** may be modified by passing a combination of +** [SQLITE_CHANGESETAPPLY_NOSAVEPOINT | supported flags] as the 9th parameter. +** +** Note that the sqlite3changeset_apply_v2() API is still experimental +** and therefore subject to change. +*/ +SQLITE_API int sqlite3changeset_apply( + sqlite3 *db, /* Apply change to "main" db of this handle */ + int nChangeset, /* Size of changeset in bytes */ + void *pChangeset, /* Changeset blob */ + int(*xFilter)( + void *pCtx, /* Copy of sixth arg to _apply() */ + const char *zTab /* Table name */ + ), + int(*xConflict)( + void *pCtx, /* Copy of sixth arg to _apply() */ + int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ + sqlite3_changeset_iter *p /* Handle describing change and conflict */ + ), + void *pCtx /* First argument passed to xConflict */ +); +SQLITE_API int sqlite3changeset_apply_v2( + sqlite3 *db, /* Apply change to "main" db of this handle */ + int nChangeset, /* Size of changeset in bytes */ + void *pChangeset, /* Changeset blob */ + int(*xFilter)( + void *pCtx, /* Copy of sixth arg to _apply() */ + const char *zTab /* Table name */ + ), + int(*xConflict)( + void *pCtx, /* Copy of sixth arg to _apply() */ + int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ + sqlite3_changeset_iter *p /* Handle describing change and conflict */ + ), + void *pCtx, /* First argument passed to xConflict */ + void **ppRebase, int *pnRebase, /* OUT: Rebase data */ + int flags /* SESSION_CHANGESETAPPLY_* flags */ +); + +/* +** CAPI3REF: Flags for sqlite3changeset_apply_v2 +** +** The following flags may passed via the 9th parameter to +** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]: +** +**
+**
SQLITE_CHANGESETAPPLY_NOSAVEPOINT
+** Usually, the sessions module encloses all operations performed by +** a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The +** SAVEPOINT is committed if the changeset or patchset is successfully +** applied, or rolled back if an error occurs. Specifying this flag +** causes the sessions module to omit this savepoint. In this case, if the +** caller has an open transaction or savepoint when apply_v2() is called, +** it may revert the partially applied changeset by rolling it back. +** +**
SQLITE_CHANGESETAPPLY_INVERT
+** Invert the changeset before applying it. This is equivalent to inverting +** a changeset using sqlite3changeset_invert() before applying it. It is +** an error to specify this flag with a patchset. +** +**
SQLITE_CHANGESETAPPLY_IGNORENOOP
+** Do not invoke the conflict handler callback for any changes that +** would not actually modify the database even if they were applied. +** Specifically, this means that the conflict handler is not invoked +** for: +**
    +**
  • a delete change if the row being deleted cannot be found, +**
  • an update change if the modified fields are already set to +** their new values in the conflicting row, or +**
  • an insert change if all fields of the conflicting row match +** the row being inserted. +**
+** +**
SQLITE_CHANGESETAPPLY_FKNOACTION
+** If this flag it set, then all foreign key constraints in the target +** database behave as if they were declared with "ON UPDATE NO ACTION ON +** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL +** or SET DEFAULT. +*/ +#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 +#define SQLITE_CHANGESETAPPLY_INVERT 0x0002 +#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 +#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008 + +/* +** CAPI3REF: Constants Passed To The Conflict Handler +** +** Values that may be passed as the second argument to a conflict-handler. +** +**
+**
SQLITE_CHANGESET_DATA
+** The conflict handler is invoked with CHANGESET_DATA as the second argument +** when processing a DELETE or UPDATE change if a row with the required +** PRIMARY KEY fields is present in the database, but one or more other +** (non primary-key) fields modified by the update do not contain the +** expected "before" values. +** +** The conflicting row, in this case, is the database row with the matching +** primary key. +** +**
SQLITE_CHANGESET_NOTFOUND
+** The conflict handler is invoked with CHANGESET_NOTFOUND as the second +** argument when processing a DELETE or UPDATE change if a row with the +** required PRIMARY KEY fields is not present in the database. +** +** There is no conflicting row in this case. The results of invoking the +** sqlite3changeset_conflict() API are undefined. +** +**
SQLITE_CHANGESET_CONFLICT
+** CHANGESET_CONFLICT is passed as the second argument to the conflict +** handler while processing an INSERT change if the operation would result +** in duplicate primary key values. +** +** The conflicting row in this case is the database row with the matching +** primary key. +** +**
SQLITE_CHANGESET_FOREIGN_KEY
+** If foreign key handling is enabled, and applying a changeset leaves the +** database in a state containing foreign key violations, the conflict +** handler is invoked with CHANGESET_FOREIGN_KEY as the second argument +** exactly once before the changeset is committed. If the conflict handler +** returns CHANGESET_OMIT, the changes, including those that caused the +** foreign key constraint violation, are committed. Or, if it returns +** CHANGESET_ABORT, the changeset is rolled back. +** +** No current or conflicting row information is provided. The only function +** it is possible to call on the supplied sqlite3_changeset_iter handle +** is sqlite3changeset_fk_conflicts(). +** +**
SQLITE_CHANGESET_CONSTRAINT
+** If any other constraint violation occurs while applying a change (i.e. +** a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is +** invoked with CHANGESET_CONSTRAINT as the second argument. +** +** There is no conflicting row in this case. The results of invoking the +** sqlite3changeset_conflict() API are undefined. +** +**
+*/ +#define SQLITE_CHANGESET_DATA 1 +#define SQLITE_CHANGESET_NOTFOUND 2 +#define SQLITE_CHANGESET_CONFLICT 3 +#define SQLITE_CHANGESET_CONSTRAINT 4 +#define SQLITE_CHANGESET_FOREIGN_KEY 5 + +/* +** CAPI3REF: Constants Returned By The Conflict Handler +** +** A conflict handler callback must return one of the following three values. +** +**
+**
SQLITE_CHANGESET_OMIT
+** If a conflict handler returns this value no special action is taken. The +** change that caused the conflict is not applied. The session module +** continues to the next change in the changeset. +** +**
SQLITE_CHANGESET_REPLACE
+** This value may only be returned if the second argument to the conflict +** handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this +** is not the case, any changes applied so far are rolled back and the +** call to sqlite3changeset_apply() returns SQLITE_MISUSE. +** +** If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict +** handler, then the conflicting row is either updated or deleted, depending +** on the type of change. +** +** If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict +** handler, then the conflicting row is removed from the database and a +** second attempt to apply the change is made. If this second attempt fails, +** the original row is restored to the database before continuing. +** +**
SQLITE_CHANGESET_ABORT
+** If this value is returned, any changes applied so far are rolled back +** and the call to sqlite3changeset_apply() returns SQLITE_ABORT. +**
+*/ +#define SQLITE_CHANGESET_OMIT 0 +#define SQLITE_CHANGESET_REPLACE 1 +#define SQLITE_CHANGESET_ABORT 2 + +/* +** CAPI3REF: Rebasing changesets +** EXPERIMENTAL +** +** Suppose there is a site hosting a database in state S0. And that +** modifications are made that move that database to state S1 and a +** changeset recorded (the "local" changeset). Then, a changeset based +** on S0 is received from another site (the "remote" changeset) and +** applied to the database. The database is then in state +** (S1+"remote"), where the exact state depends on any conflict +** resolution decisions (OMIT or REPLACE) made while applying "remote". +** Rebasing a changeset is to update it to take those conflict +** resolution decisions into account, so that the same conflicts +** do not have to be resolved elsewhere in the network. +** +** For example, if both the local and remote changesets contain an +** INSERT of the same key on "CREATE TABLE t1(a PRIMARY KEY, b)": +** +** local: INSERT INTO t1 VALUES(1, 'v1'); +** remote: INSERT INTO t1 VALUES(1, 'v2'); +** +** and the conflict resolution is REPLACE, then the INSERT change is +** removed from the local changeset (it was overridden). Or, if the +** conflict resolution was "OMIT", then the local changeset is modified +** to instead contain: +** +** UPDATE t1 SET b = 'v2' WHERE a=1; +** +** Changes within the local changeset are rebased as follows: +** +**
+**
Local INSERT
+** This may only conflict with a remote INSERT. If the conflict +** resolution was OMIT, then add an UPDATE change to the rebased +** changeset. Or, if the conflict resolution was REPLACE, add +** nothing to the rebased changeset. +** +**
Local DELETE
+** This may conflict with a remote UPDATE or DELETE. In both cases the +** only possible resolution is OMIT. If the remote operation was a +** DELETE, then add no change to the rebased changeset. If the remote +** operation was an UPDATE, then the old.* fields of change are updated +** to reflect the new.* values in the UPDATE. +** +**
Local UPDATE
+** This may conflict with a remote UPDATE or DELETE. If it conflicts +** with a DELETE, and the conflict resolution was OMIT, then the update +** is changed into an INSERT. Any undefined values in the new.* record +** from the update change are filled in using the old.* values from +** the conflicting DELETE. Or, if the conflict resolution was REPLACE, +** the UPDATE change is simply omitted from the rebased changeset. +** +** If conflict is with a remote UPDATE and the resolution is OMIT, then +** the old.* values are rebased using the new.* values in the remote +** change. Or, if the resolution is REPLACE, then the change is copied +** into the rebased changeset with updates to columns also updated by +** the conflicting remote UPDATE removed. If this means no columns would +** be updated, the change is omitted. +**
+** +** A local change may be rebased against multiple remote changes +** simultaneously. If a single key is modified by multiple remote +** changesets, they are combined as follows before the local changeset +** is rebased: +** +**
    +**
  • If there has been one or more REPLACE resolutions on a +** key, it is rebased according to a REPLACE. +** +**
  • If there have been no REPLACE resolutions on a key, then +** the local changeset is rebased according to the most recent +** of the OMIT resolutions. +**
+** +** Note that conflict resolutions from multiple remote changesets are +** combined on a per-field basis, not per-row. This means that in the +** case of multiple remote UPDATE operations, some fields of a single +** local change may be rebased for REPLACE while others are rebased for +** OMIT. +** +** In order to rebase a local changeset, the remote changeset must first +** be applied to the local database using sqlite3changeset_apply_v2() and +** the buffer of rebase information captured. Then: +** +**
    +**
  1. An sqlite3_rebaser object is created by calling +** sqlite3rebaser_create(). +**
  2. The new object is configured with the rebase buffer obtained from +** sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure(). +** If the local changeset is to be rebased against multiple remote +** changesets, then sqlite3rebaser_configure() should be called +** multiple times, in the same order that the multiple +** sqlite3changeset_apply_v2() calls were made. +**
  3. Each local changeset is rebased by calling sqlite3rebaser_rebase(). +**
  4. The sqlite3_rebaser object is deleted by calling +** sqlite3rebaser_delete(). +**
+*/ +typedef struct sqlite3_rebaser sqlite3_rebaser; + +/* +** CAPI3REF: Create a changeset rebaser object. +** EXPERIMENTAL +** +** Allocate a new changeset rebaser object. If successful, set (*ppNew) to +** point to the new object and return SQLITE_OK. Otherwise, if an error +** occurs, return an SQLite error code (e.g. SQLITE_NOMEM) and set (*ppNew) +** to NULL. +*/ +SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew); + +/* +** CAPI3REF: Configure a changeset rebaser object. +** EXPERIMENTAL +** +** Configure the changeset rebaser object to rebase changesets according +** to the conflict resolutions described by buffer pRebase (size nRebase +** bytes), which must have been obtained from a previous call to +** sqlite3changeset_apply_v2(). +*/ +SQLITE_API int sqlite3rebaser_configure( + sqlite3_rebaser*, + int nRebase, const void *pRebase +); + +/* +** CAPI3REF: Rebase a changeset +** EXPERIMENTAL +** +** Argument pIn must point to a buffer containing a changeset nIn bytes +** in size. This function allocates and populates a buffer with a copy +** of the changeset rebased according to the configuration of the +** rebaser object passed as the first argument. If successful, (*ppOut) +** is set to point to the new buffer containing the rebased changeset and +** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the +** responsibility of the caller to eventually free the new buffer using +** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut) +** are set to zero and an SQLite error code returned. +*/ +SQLITE_API int sqlite3rebaser_rebase( + sqlite3_rebaser*, + int nIn, const void *pIn, + int *pnOut, void **ppOut +); + +/* +** CAPI3REF: Delete a changeset rebaser object. +** EXPERIMENTAL +** +** Delete the changeset rebaser object and all associated resources. There +** should be one call to this function for each successful invocation +** of sqlite3rebaser_create(). +*/ +SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p); + +/* +** CAPI3REF: Streaming Versions of API functions. +** +** The six streaming API xxx_strm() functions serve similar purposes to the +** corresponding non-streaming API functions: +** +** +** +**
Streaming functionNon-streaming equivalent
sqlite3changeset_apply_strm[sqlite3changeset_apply] +**
sqlite3changeset_apply_strm_v2[sqlite3changeset_apply_v2] +**
sqlite3changeset_concat_strm[sqlite3changeset_concat] +**
sqlite3changeset_invert_strm[sqlite3changeset_invert] +**
sqlite3changeset_start_strm[sqlite3changeset_start] +**
sqlite3session_changeset_strm[sqlite3session_changeset] +**
sqlite3session_patchset_strm[sqlite3session_patchset] +**
+** +** Non-streaming functions that accept changesets (or patchsets) as input +** require that the entire changeset be stored in a single buffer in memory. +** Similarly, those that return a changeset or patchset do so by returning +** a pointer to a single large buffer allocated using sqlite3_malloc(). +** Normally this is convenient. However, if an application running in a +** low-memory environment is required to handle very large changesets, the +** large contiguous memory allocations required can become onerous. +** +** In order to avoid this problem, instead of a single large buffer, input +** is passed to a streaming API functions by way of a callback function that +** the sessions module invokes to incrementally request input data as it is +** required. In all cases, a pair of API function parameters such as +** +**
+**        int nChangeset,
+**        void *pChangeset,
+**  
+** +** Is replaced by: +** +**
+**        int (*xInput)(void *pIn, void *pData, int *pnData),
+**        void *pIn,
+**  
+** +** Each time the xInput callback is invoked by the sessions module, the first +** argument passed is a copy of the supplied pIn context pointer. The second +** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no +** error occurs the xInput method should copy up to (*pnData) bytes of data +** into the buffer and set (*pnData) to the actual number of bytes copied +** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) +** should be set to zero to indicate this. Or, if an error occurs, an SQLite +** error code should be returned. In all cases, if an xInput callback returns +** an error, all processing is abandoned and the streaming API function +** returns a copy of the error code to the caller. +** +** In the case of sqlite3changeset_start_strm(), the xInput callback may be +** invoked by the sessions module at any point during the lifetime of the +** iterator. If such an xInput callback returns an error, the iterator enters +** an error state, whereby all subsequent calls to iterator functions +** immediately fail with the same error code as returned by xInput. +** +** Similarly, streaming API functions that return changesets (or patchsets) +** return them in chunks by way of a callback function instead of via a +** pointer to a single large buffer. In this case, a pair of parameters such +** as: +** +**
+**        int *pnChangeset,
+**        void **ppChangeset,
+**  
+** +** Is replaced by: +** +**
+**        int (*xOutput)(void *pOut, const void *pData, int nData),
+**        void *pOut
+**  
+** +** The xOutput callback is invoked zero or more times to return data to +** the application. The first parameter passed to each call is a copy of the +** pOut pointer supplied by the application. The second parameter, pData, +** points to a buffer nData bytes in size containing the chunk of output +** data being returned. If the xOutput callback successfully processes the +** supplied data, it should return SQLITE_OK to indicate success. Otherwise, +** it should return some other SQLite error code. In this case processing +** is immediately abandoned and the streaming API function returns a copy +** of the xOutput error code to the application. +** +** The sessions module never invokes an xOutput callback with the third +** parameter set to a value less than or equal to zero. Other than this, +** no guarantees are made as to the size of the chunks of data returned. +*/ +SQLITE_API int sqlite3changeset_apply_strm( + sqlite3 *db, /* Apply change to "main" db of this handle */ + int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ + void *pIn, /* First arg for xInput */ + int(*xFilter)( + void *pCtx, /* Copy of sixth arg to _apply() */ + const char *zTab /* Table name */ + ), + int(*xConflict)( + void *pCtx, /* Copy of sixth arg to _apply() */ + int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ + sqlite3_changeset_iter *p /* Handle describing change and conflict */ + ), + void *pCtx /* First argument passed to xConflict */ +); +SQLITE_API int sqlite3changeset_apply_v2_strm( + sqlite3 *db, /* Apply change to "main" db of this handle */ + int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ + void *pIn, /* First arg for xInput */ + int(*xFilter)( + void *pCtx, /* Copy of sixth arg to _apply() */ + const char *zTab /* Table name */ + ), + int(*xConflict)( + void *pCtx, /* Copy of sixth arg to _apply() */ + int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ + sqlite3_changeset_iter *p /* Handle describing change and conflict */ + ), + void *pCtx, /* First argument passed to xConflict */ + void **ppRebase, int *pnRebase, + int flags +); +SQLITE_API int sqlite3changeset_concat_strm( + int (*xInputA)(void *pIn, void *pData, int *pnData), + void *pInA, + int (*xInputB)(void *pIn, void *pData, int *pnData), + void *pInB, + int (*xOutput)(void *pOut, const void *pData, int nData), + void *pOut +); +SQLITE_API int sqlite3changeset_invert_strm( + int (*xInput)(void *pIn, void *pData, int *pnData), + void *pIn, + int (*xOutput)(void *pOut, const void *pData, int nData), + void *pOut +); +SQLITE_API int sqlite3changeset_start_strm( + sqlite3_changeset_iter **pp, + int (*xInput)(void *pIn, void *pData, int *pnData), + void *pIn +); +SQLITE_API int sqlite3changeset_start_v2_strm( + sqlite3_changeset_iter **pp, + int (*xInput)(void *pIn, void *pData, int *pnData), + void *pIn, + int flags +); +SQLITE_API int sqlite3session_changeset_strm( + sqlite3_session *pSession, + int (*xOutput)(void *pOut, const void *pData, int nData), + void *pOut +); +SQLITE_API int sqlite3session_patchset_strm( + sqlite3_session *pSession, + int (*xOutput)(void *pOut, const void *pData, int nData), + void *pOut +); +SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, + int (*xInput)(void *pIn, void *pData, int *pnData), + void *pIn +); +SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*, + int (*xOutput)(void *pOut, const void *pData, int nData), + void *pOut +); +SQLITE_API int sqlite3rebaser_rebase_strm( + sqlite3_rebaser *pRebaser, + int (*xInput)(void *pIn, void *pData, int *pnData), + void *pIn, + int (*xOutput)(void *pOut, const void *pData, int nData), + void *pOut +); + +/* +** CAPI3REF: Configure global parameters +** +** The sqlite3session_config() interface is used to make global configuration +** changes to the sessions module in order to tune it to the specific needs +** of the application. +** +** The sqlite3session_config() interface is not threadsafe. If it is invoked +** while any other thread is inside any other sessions method then the +** results are undefined. Furthermore, if it is invoked after any sessions +** related objects have been created, the results are also undefined. +** +** The first argument to the sqlite3session_config() function must be one +** of the SQLITE_SESSION_CONFIG_XXX constants defined below. The +** interpretation of the (void*) value passed as the second parameter and +** the effect of calling this function depends on the value of the first +** parameter. +** +**
+**
SQLITE_SESSION_CONFIG_STRMSIZE
+** By default, the sessions module streaming interfaces attempt to input +** and output data in approximately 1 KiB chunks. This operand may be used +** to set and query the value of this configuration setting. The pointer +** passed as the second argument must point to a value of type (int). +** If this value is greater than 0, it is used as the new streaming data +** chunk size for both input and output. Before returning, the (int) value +** pointed to by pArg is set to the final value of the streaming interface +** chunk size. +**
+** +** This function returns SQLITE_OK if successful, or an SQLite error code +** otherwise. +*/ +SQLITE_API int sqlite3session_config(int op, void *pArg); + +/* +** CAPI3REF: Values for sqlite3session_config(). +*/ +#define SQLITE_SESSION_CONFIG_STRMSIZE 1 + +/* +** Make sure we can call this stuff from C++. +*/ +#ifdef __cplusplus +} +#endif + +#endif /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */ + +/******** End of sqlite3session.h *********/ +/******** Begin file fts5.h *********/ +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Interfaces to extend FTS5. Using the interfaces defined in this file, +** FTS5 may be extended with: +** +** * custom tokenizers, and +** * custom auxiliary functions. +*/ + + +#ifndef _FTS5_H +#define _FTS5_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************* +** CUSTOM AUXILIARY FUNCTIONS +** +** Virtual table implementations may overload SQL functions by implementing +** the sqlite3_module.xFindFunction() method. +*/ + +typedef struct Fts5ExtensionApi Fts5ExtensionApi; +typedef struct Fts5Context Fts5Context; +typedef struct Fts5PhraseIter Fts5PhraseIter; + +typedef void (*fts5_extension_function)( + const Fts5ExtensionApi *pApi, /* API offered by current FTS version */ + Fts5Context *pFts, /* First arg to pass to pApi functions */ + sqlite3_context *pCtx, /* Context for returning result/error */ + int nVal, /* Number of values in apVal[] array */ + sqlite3_value **apVal /* Array of trailing arguments */ +); + +struct Fts5PhraseIter { + const unsigned char *a; + const unsigned char *b; +}; + +/* +** EXTENSION API FUNCTIONS +** +** xUserData(pFts): +** Return a copy of the pUserData pointer passed to the xCreateFunction() +** API when the extension function was registered. +** +** xColumnTotalSize(pFts, iCol, pnToken): +** If parameter iCol is less than zero, set output variable *pnToken +** to the total number of tokens in the FTS5 table. Or, if iCol is +** non-negative but less than the number of columns in the table, return +** the total number of tokens in column iCol, considering all rows in +** the FTS5 table. +** +** If parameter iCol is greater than or equal to the number of columns +** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g. +** an OOM condition or IO error), an appropriate SQLite error code is +** returned. +** +** xColumnCount(pFts): +** Return the number of columns in the table. +** +** xColumnSize(pFts, iCol, pnToken): +** If parameter iCol is less than zero, set output variable *pnToken +** to the total number of tokens in the current row. Or, if iCol is +** non-negative but less than the number of columns in the table, set +** *pnToken to the number of tokens in column iCol of the current row. +** +** If parameter iCol is greater than or equal to the number of columns +** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g. +** an OOM condition or IO error), an appropriate SQLite error code is +** returned. +** +** This function may be quite inefficient if used with an FTS5 table +** created with the "columnsize=0" option. +** +** xColumnText: +** If parameter iCol is less than zero, or greater than or equal to the +** number of columns in the table, SQLITE_RANGE is returned. +** +** Otherwise, this function attempts to retrieve the text of column iCol of +** the current document. If successful, (*pz) is set to point to a buffer +** containing the text in utf-8 encoding, (*pn) is set to the size in bytes +** (not characters) of the buffer and SQLITE_OK is returned. Otherwise, +** if an error occurs, an SQLite error code is returned and the final values +** of (*pz) and (*pn) are undefined. +** +** xPhraseCount: +** Returns the number of phrases in the current query expression. +** +** xPhraseSize: +** If parameter iCol is less than zero, or greater than or equal to the +** number of phrases in the current query, as returned by xPhraseCount, +** 0 is returned. Otherwise, this function returns the number of tokens in +** phrase iPhrase of the query. Phrases are numbered starting from zero. +** +** xInstCount: +** Set *pnInst to the total number of occurrences of all phrases within +** the query within the current row. Return SQLITE_OK if successful, or +** an error code (i.e. SQLITE_NOMEM) if an error occurs. +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. If the FTS5 table is created +** with either "detail=none" or "detail=column" and "content=" option +** (i.e. if it is a contentless table), then this API always returns 0. +** +** xInst: +** Query for the details of phrase match iIdx within the current row. +** Phrase matches are numbered starting from zero, so the iIdx argument +** should be greater than or equal to zero and smaller than the value +** output by xInstCount(). If iIdx is less than zero or greater than +** or equal to the value returned by xInstCount(), SQLITE_RANGE is returned. +** +** Otherwise, output parameter *piPhrase is set to the phrase number, *piCol +** to the column in which it occurs and *piOff the token offset of the +** first token of the phrase. SQLITE_OK is returned if successful, or an +** error code (i.e. SQLITE_NOMEM) if an error occurs. +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. +** +** xRowid: +** Returns the rowid of the current row. +** +** xTokenize: +** Tokenize text using the tokenizer belonging to the FTS5 table. +** +** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback): +** This API function is used to query the FTS table for phrase iPhrase +** of the current query. Specifically, a query equivalent to: +** +** ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid +** +** with $p set to a phrase equivalent to the phrase iPhrase of the +** current query is executed. Any column filter that applies to +** phrase iPhrase of the current query is included in $p. For each +** row visited, the callback function passed as the fourth argument +** is invoked. The context and API objects passed to the callback +** function may be used to access the properties of each matched row. +** Invoking Api.xUserData() returns a copy of the pointer passed as +** the third argument to pUserData. +** +** If parameter iPhrase is less than zero, or greater than or equal to +** the number of phrases in the query, as returned by xPhraseCount(), +** this function returns SQLITE_RANGE. +** +** If the callback function returns any value other than SQLITE_OK, the +** query is abandoned and the xQueryPhrase function returns immediately. +** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. +** Otherwise, the error code is propagated upwards. +** +** If the query runs to completion without incident, SQLITE_OK is returned. +** Or, if some error occurs before the query completes or is aborted by +** the callback, an SQLite error code is returned. +** +** +** xSetAuxdata(pFts5, pAux, xDelete) +** +** Save the pointer passed as the second argument as the extension function's +** "auxiliary data". The pointer may then be retrieved by the current or any +** future invocation of the same fts5 extension function made as part of +** the same MATCH query using the xGetAuxdata() API. +** +** Each extension function is allocated a single auxiliary data slot for +** each FTS query (MATCH expression). If the extension function is invoked +** more than once for a single FTS query, then all invocations share a +** single auxiliary data context. +** +** If there is already an auxiliary data pointer when this function is +** invoked, then it is replaced by the new pointer. If an xDelete callback +** was specified along with the original pointer, it is invoked at this +** point. +** +** The xDelete callback, if one is specified, is also invoked on the +** auxiliary data pointer after the FTS5 query has finished. +** +** If an error (e.g. an OOM condition) occurs within this function, +** the auxiliary data is set to NULL and an error code returned. If the +** xDelete parameter was not NULL, it is invoked on the auxiliary data +** pointer before returning. +** +** +** xGetAuxdata(pFts5, bClear) +** +** Returns the current auxiliary data pointer for the fts5 extension +** function. See the xSetAuxdata() method for details. +** +** If the bClear argument is non-zero, then the auxiliary data is cleared +** (set to NULL) before this function returns. In this case the xDelete, +** if any, is not invoked. +** +** +** xRowCount(pFts5, pnRow) +** +** This function is used to retrieve the total number of rows in the table. +** In other words, the same value that would be returned by: +** +** SELECT count(*) FROM ftstable; +** +** xPhraseFirst() +** This function is used, along with type Fts5PhraseIter and the xPhraseNext +** method, to iterate through all instances of a single query phrase within +** the current row. This is the same information as is accessible via the +** xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient +** to use, this API may be faster under some circumstances. To iterate +** through instances of phrase iPhrase, use the following code: +** +** Fts5PhraseIter iter; +** int iCol, iOff; +** for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff); +** iCol>=0; +** pApi->xPhraseNext(pFts, &iter, &iCol, &iOff) +** ){ +** // An instance of phrase iPhrase at offset iOff of column iCol +** } +** +** The Fts5PhraseIter structure is defined above. Applications should not +** modify this structure directly - it should only be used as shown above +** with the xPhraseFirst() and xPhraseNext() API methods (and by +** xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below). +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. If the FTS5 table is created +** with either "detail=none" or "detail=column" and "content=" option +** (i.e. if it is a contentless table), then this API always iterates +** through an empty set (all calls to xPhraseFirst() set iCol to -1). +** +** In all cases, matches are visited in (column ASC, offset ASC) order. +** i.e. all those in column 0, sorted by offset, followed by those in +** column 1, etc. +** +** xPhraseNext() +** See xPhraseFirst above. +** +** xPhraseFirstColumn() +** This function and xPhraseNextColumn() are similar to the xPhraseFirst() +** and xPhraseNext() APIs described above. The difference is that instead +** of iterating through all instances of a phrase in the current row, these +** APIs are used to iterate through the set of columns in the current row +** that contain one or more instances of a specified phrase. For example: +** +** Fts5PhraseIter iter; +** int iCol; +** for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol); +** iCol>=0; +** pApi->xPhraseNextColumn(pFts, &iter, &iCol) +** ){ +** // Column iCol contains at least one instance of phrase iPhrase +** } +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" option. If the FTS5 table is created with either +** "detail=none" "content=" option (i.e. if it is a contentless table), +** then this API always iterates through an empty set (all calls to +** xPhraseFirstColumn() set iCol to -1). +** +** The information accessed using this API and its companion +** xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext +** (or xInst/xInstCount). The chief advantage of this API is that it is +** significantly more efficient than those alternatives when used with +** "detail=column" tables. +** +** xPhraseNextColumn() +** See xPhraseFirstColumn above. +** +** xQueryToken(pFts5, iPhrase, iToken, ppToken, pnToken) +** This is used to access token iToken of phrase iPhrase of the current +** query. Before returning, output parameter *ppToken is set to point +** to a buffer containing the requested token, and *pnToken to the +** size of this buffer in bytes. +** +** If iPhrase or iToken are less than zero, or if iPhrase is greater than +** or equal to the number of phrases in the query as reported by +** xPhraseCount(), or if iToken is equal to or greater than the number of +** tokens in the phrase, SQLITE_RANGE is returned and *ppToken and *pnToken + are both zeroed. +** +** The output text is not a copy of the query text that specified the +** token. It is the output of the tokenizer module. For tokendata=1 +** tables, this includes any embedded 0x00 and trailing data. +** +** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken) +** This is used to access token iToken of phrase hit iIdx within the +** current row. If iIdx is less than zero or greater than or equal to the +** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, +** output variable (*ppToken) is set to point to a buffer containing the +** matching document token, and (*pnToken) to the size of that buffer in +** bytes. +** +** The output text is not a copy of the document text that was tokenized. +** It is the output of the tokenizer module. For tokendata=1 tables, this +** includes any embedded 0x00 and trailing data. +** +** This API may be slow in some cases if the token identified by parameters +** iIdx and iToken matched a prefix token in the query. In most cases, the +** first call to this API for each prefix token in the query is forced +** to scan the portion of the full-text index that matches the prefix +** token to collect the extra data required by this API. If the prefix +** token matches a large number of token instances in the document set, +** this may be a performance problem. +** +** If the user knows in advance that a query may use this API for a +** prefix token, FTS5 may be configured to collect all required data as part +** of the initial querying of the full-text index, avoiding the second scan +** entirely. This also causes prefix queries that do not use this API to +** run more slowly and use more memory. FTS5 may be configured in this way +** either on a per-table basis using the [FTS5 insttoken | 'insttoken'] +** option, or on a per-query basis using the +** [fts5_insttoken | fts5_insttoken()] user function. +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. +** +** xColumnLocale(pFts5, iIdx, pzLocale, pnLocale) +** If parameter iCol is less than zero, or greater than or equal to the +** number of columns in the table, SQLITE_RANGE is returned. +** +** Otherwise, this function attempts to retrieve the locale associated +** with column iCol of the current row. Usually, there is no associated +** locale, and output parameters (*pzLocale) and (*pnLocale) are set +** to NULL and 0, respectively. However, if the fts5_locale() function +** was used to associate a locale with the value when it was inserted +** into the fts5 table, then (*pzLocale) is set to point to a nul-terminated +** buffer containing the name of the locale in utf-8 encoding. (*pnLocale) +** is set to the size in bytes of the buffer, not including the +** nul-terminator. +** +** If successful, SQLITE_OK is returned. Or, if an error occurs, an +** SQLite error code is returned. The final value of the output parameters +** is undefined in this case. +** +** xTokenize_v2: +** Tokenize text using the tokenizer belonging to the FTS5 table. This +** API is the same as the xTokenize() API, except that it allows a tokenizer +** locale to be specified. +*/ +struct Fts5ExtensionApi { + int iVersion; /* Currently always set to 4 */ + + void *(*xUserData)(Fts5Context*); + + int (*xColumnCount)(Fts5Context*); + int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow); + int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken); + + int (*xTokenize)(Fts5Context*, + const char *pText, int nText, /* Text to tokenize */ + void *pCtx, /* Context passed to xToken() */ + int (*xToken)(void*, int, const char*, int, int, int) /* Callback */ + ); + + int (*xPhraseCount)(Fts5Context*); + int (*xPhraseSize)(Fts5Context*, int iPhrase); + + int (*xInstCount)(Fts5Context*, int *pnInst); + int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff); + + sqlite3_int64 (*xRowid)(Fts5Context*); + int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn); + int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken); + + int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData, + int(*)(const Fts5ExtensionApi*,Fts5Context*,void*) + ); + int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*)); + void *(*xGetAuxdata)(Fts5Context*, int bClear); + + int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*); + void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff); + + int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); + void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); + + /* Below this point are iVersion>=3 only */ + int (*xQueryToken)(Fts5Context*, + int iPhrase, int iToken, + const char **ppToken, int *pnToken + ); + int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*); + + /* Below this point are iVersion>=4 only */ + int (*xColumnLocale)(Fts5Context*, int iCol, const char **pz, int *pn); + int (*xTokenize_v2)(Fts5Context*, + const char *pText, int nText, /* Text to tokenize */ + const char *pLocale, int nLocale, /* Locale to pass to tokenizer */ + void *pCtx, /* Context passed to xToken() */ + int (*xToken)(void*, int, const char*, int, int, int) /* Callback */ + ); +}; + +/* +** CUSTOM AUXILIARY FUNCTIONS +*************************************************************************/ + +/************************************************************************* +** CUSTOM TOKENIZERS +** +** Applications may also register custom tokenizer types. A tokenizer +** is registered by providing fts5 with a populated instance of the +** following structure. All structure methods must be defined, setting +** any member of the fts5_tokenizer struct to NULL leads to undefined +** behaviour. The structure methods are expected to function as follows: +** +** xCreate: +** This function is used to allocate and initialize a tokenizer instance. +** A tokenizer instance is required to actually tokenize text. +** +** The first argument passed to this function is a copy of the (void*) +** pointer provided by the application when the fts5_tokenizer_v2 object +** was registered with FTS5 (the third argument to xCreateTokenizer()). +** The second and third arguments are an array of nul-terminated strings +** containing the tokenizer arguments, if any, specified following the +** tokenizer name as part of the CREATE VIRTUAL TABLE statement used +** to create the FTS5 table. +** +** The final argument is an output variable. If successful, (*ppOut) +** should be set to point to the new tokenizer handle and SQLITE_OK +** returned. If an error occurs, some value other than SQLITE_OK should +** be returned. In this case, fts5 assumes that the final value of *ppOut +** is undefined. +** +** xDelete: +** This function is invoked to delete a tokenizer handle previously +** allocated using xCreate(). Fts5 guarantees that this function will +** be invoked exactly once for each successful call to xCreate(). +** +** xTokenize: +** This function is expected to tokenize the nText byte string indicated +** by argument pText. pText may or may not be nul-terminated. The first +** argument passed to this function is a pointer to an Fts5Tokenizer object +** returned by an earlier call to xCreate(). +** +** The third argument indicates the reason that FTS5 is requesting +** tokenization of the supplied text. This is always one of the following +** four values: +** +**
  • FTS5_TOKENIZE_DOCUMENT - A document is being inserted into +** or removed from the FTS table. The tokenizer is being invoked to +** determine the set of tokens to add to (or delete from) the +** FTS index. +** +**
  • FTS5_TOKENIZE_QUERY - A MATCH query is being executed +** against the FTS index. The tokenizer is being called to tokenize +** a bareword or quoted string specified as part of the query. +** +**
  • (FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX) - Same as +** FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is +** followed by a "*" character, indicating that the last token +** returned by the tokenizer will be treated as a token prefix. +** +**
  • FTS5_TOKENIZE_AUX - The tokenizer is being invoked to +** satisfy an fts5_api.xTokenize() request made by an auxiliary +** function. Or an fts5_api.xColumnSize() request made by the same +** on a columnsize=0 database. +**
+** +** The sixth and seventh arguments passed to xTokenize() - pLocale and +** nLocale - are a pointer to a buffer containing the locale to use for +** tokenization (e.g. "en_US") and its size in bytes, respectively. The +** pLocale buffer is not nul-terminated. pLocale may be passed NULL (in +** which case nLocale is always 0) to indicate that the tokenizer should +** use its default locale. +** +** For each token in the input string, the supplied callback xToken() must +** be invoked. The first argument to it should be a copy of the pointer +** passed as the second argument to xTokenize(). The third and fourth +** arguments are a pointer to a buffer containing the token text, and the +** size of the token in bytes. The 4th and 5th arguments are the byte offsets +** of the first byte of and first byte immediately following the text from +** which the token is derived within the input. +** +** The second argument passed to the xToken() callback ("tflags") should +** normally be set to 0. The exception is if the tokenizer supports +** synonyms. In this case see the discussion below for details. +** +** FTS5 assumes the xToken() callback is invoked for each token in the +** order that they occur within the input text. +** +** If an xToken() callback returns any value other than SQLITE_OK, then +** the tokenization should be abandoned and the xTokenize() method should +** immediately return a copy of the xToken() return value. Or, if the +** input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally, +** if an error occurs with the xTokenize() implementation itself, it +** may abandon the tokenization and return any error code other than +** SQLITE_OK or SQLITE_DONE. +** +** If the tokenizer is registered using an fts5_tokenizer_v2 object, +** then the xTokenize() method has two additional arguments - pLocale +** and nLocale. These specify the locale that the tokenizer should use +** for the current request. If pLocale and nLocale are both 0, then the +** tokenizer should use its default locale. Otherwise, pLocale points to +** an nLocale byte buffer containing the name of the locale to use as utf-8 +** text. pLocale is not nul-terminated. +** +** FTS5_TOKENIZER +** +** There is also an fts5_tokenizer object. This is an older, deprecated, +** version of fts5_tokenizer_v2. It is similar except that: +** +**
    +**
  • There is no "iVersion" field, and +**
  • The xTokenize() method does not take a locale argument. +**
+** +** Legacy fts5_tokenizer tokenizers must be registered using the +** legacy xCreateTokenizer() function, instead of xCreateTokenizer_v2(). +** +** Tokenizer implementations registered using either API may be retrieved +** using both xFindTokenizer() and xFindTokenizer_v2(). +** +** SYNONYM SUPPORT +** +** Custom tokenizers may also support synonyms. Consider a case in which a +** user wishes to query for a phrase such as "first place". Using the +** built-in tokenizers, the FTS5 query 'first + place' will match instances +** of "first place" within the document set, but not alternative forms +** such as "1st place". In some applications, it would be better to match +** all instances of "first place" or "1st place" regardless of which form +** the user specified in the MATCH query text. +** +** There are several ways to approach this in FTS5: +** +**
  1. By mapping all synonyms to a single token. In this case, using +** the above example, this means that the tokenizer returns the +** same token for inputs "first" and "1st". Say that token is in +** fact "first", so that when the user inserts the document "I won +** 1st place" entries are added to the index for tokens "i", "won", +** "first" and "place". If the user then queries for '1st + place', +** the tokenizer substitutes "first" for "1st" and the query works +** as expected. +** +**
  2. By querying the index for all synonyms of each query term +** separately. In this case, when tokenizing query text, the +** tokenizer may provide multiple synonyms for a single term +** within the document. FTS5 then queries the index for each +** synonym individually. For example, faced with the query: +** +** +** ... MATCH 'first place' +** +** the tokenizer offers both "1st" and "first" as synonyms for the +** first token in the MATCH query and FTS5 effectively runs a query +** similar to: +** +** +** ... MATCH '(first OR 1st) place' +** +** except that, for the purposes of auxiliary functions, the query +** still appears to contain just two phrases - "(first OR 1st)" +** being treated as a single phrase. +** +**
  3. By adding multiple synonyms for a single term to the FTS index. +** Using this method, when tokenizing document text, the tokenizer +** provides multiple synonyms for each token. So that when a +** document such as "I won first place" is tokenized, entries are +** added to the FTS index for "i", "won", "first", "1st" and +** "place". +** +** This way, even if the tokenizer does not provide synonyms +** when tokenizing query text (it should not - to do so would be +** inefficient), it doesn't matter if the user queries for +** 'first + place' or '1st + place', as there are entries in the +** FTS index corresponding to both forms of the first token. +**
+** +** Whether it is parsing document or query text, any call to xToken that +** specifies a tflags argument with the FTS5_TOKEN_COLOCATED bit +** is considered to supply a synonym for the previous token. For example, +** when parsing the document "I won first place", a tokenizer that supports +** synonyms would call xToken() 5 times, as follows: +** +** +** xToken(pCtx, 0, "i", 1, 0, 1); +** xToken(pCtx, 0, "won", 3, 2, 5); +** xToken(pCtx, 0, "first", 5, 6, 11); +** xToken(pCtx, FTS5_TOKEN_COLOCATED, "1st", 3, 6, 11); +** xToken(pCtx, 0, "place", 5, 12, 17); +** +** +** It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time +** xToken() is called. Multiple synonyms may be specified for a single token +** by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. +** There is no limit to the number of synonyms that may be provided for a +** single token. +** +** In many cases, method (1) above is the best approach. It does not add +** extra data to the FTS index or require FTS5 to query for multiple terms, +** so it is efficient in terms of disk space and query speed. However, it +** does not support prefix queries very well. If, as suggested above, the +** token "first" is substituted for "1st" by the tokenizer, then the query: +** +** +** ... MATCH '1s*' +** +** will not match documents that contain the token "1st" (as the tokenizer +** will probably not map "1s" to any prefix of "first"). +** +** For full prefix support, method (3) may be preferred. In this case, +** because the index contains entries for both "first" and "1st", prefix +** queries such as 'fi*' or '1s*' will match correctly. However, because +** extra entries are added to the FTS index, this method uses more space +** within the database. +** +** Method (2) offers a midpoint between (1) and (3). Using this method, +** a query such as '1s*' will match documents that contain the literal +** token "1st", but not "first" (assuming the tokenizer is not able to +** provide synonyms for prefixes). However, a non-prefix query like '1st' +** will match against "1st" and "first". This method does not require +** extra disk space, as no extra entries are added to the FTS index. +** On the other hand, it may require more CPU cycles to run MATCH queries, +** as separate queries of the FTS index are required for each synonym. +** +** When using methods (2) or (3), it is important that the tokenizer only +** provide synonyms when tokenizing document text (method (3)) or query +** text (method (2)), not both. Doing so will not cause any errors, but is +** inefficient. +*/ +typedef struct Fts5Tokenizer Fts5Tokenizer; +typedef struct fts5_tokenizer_v2 fts5_tokenizer_v2; +struct fts5_tokenizer_v2 { + int iVersion; /* Currently always 2 */ + + int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); + void (*xDelete)(Fts5Tokenizer*); + int (*xTokenize)(Fts5Tokenizer*, + void *pCtx, + int flags, /* Mask of FTS5_TOKENIZE_* flags */ + const char *pText, int nText, + const char *pLocale, int nLocale, + int (*xToken)( + void *pCtx, /* Copy of 2nd argument to xTokenize() */ + int tflags, /* Mask of FTS5_TOKEN_* flags */ + const char *pToken, /* Pointer to buffer containing token */ + int nToken, /* Size of token in bytes */ + int iStart, /* Byte offset of token within input text */ + int iEnd /* Byte offset of end of token within input text */ + ) + ); +}; + +/* +** New code should use the fts5_tokenizer_v2 type to define tokenizer +** implementations. The following type is included for legacy applications +** that still use it. +*/ +typedef struct fts5_tokenizer fts5_tokenizer; +struct fts5_tokenizer { + int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); + void (*xDelete)(Fts5Tokenizer*); + int (*xTokenize)(Fts5Tokenizer*, + void *pCtx, + int flags, /* Mask of FTS5_TOKENIZE_* flags */ + const char *pText, int nText, + int (*xToken)( + void *pCtx, /* Copy of 2nd argument to xTokenize() */ + int tflags, /* Mask of FTS5_TOKEN_* flags */ + const char *pToken, /* Pointer to buffer containing token */ + int nToken, /* Size of token in bytes */ + int iStart, /* Byte offset of token within input text */ + int iEnd /* Byte offset of end of token within input text */ + ) + ); +}; + + +/* Flags that may be passed as the third argument to xTokenize() */ +#define FTS5_TOKENIZE_QUERY 0x0001 +#define FTS5_TOKENIZE_PREFIX 0x0002 +#define FTS5_TOKENIZE_DOCUMENT 0x0004 +#define FTS5_TOKENIZE_AUX 0x0008 + +/* Flags that may be passed by the tokenizer implementation back to FTS5 +** as the third argument to the supplied xToken callback. */ +#define FTS5_TOKEN_COLOCATED 0x0001 /* Same position as prev. token */ + +/* +** END OF CUSTOM TOKENIZERS +*************************************************************************/ + +/************************************************************************* +** FTS5 EXTENSION REGISTRATION API +*/ +typedef struct fts5_api fts5_api; +struct fts5_api { + int iVersion; /* Currently always set to 3 */ + + /* Create a new tokenizer */ + int (*xCreateTokenizer)( + fts5_api *pApi, + const char *zName, + void *pUserData, + fts5_tokenizer *pTokenizer, + void (*xDestroy)(void*) + ); + + /* Find an existing tokenizer */ + int (*xFindTokenizer)( + fts5_api *pApi, + const char *zName, + void **ppUserData, + fts5_tokenizer *pTokenizer + ); + + /* Create a new auxiliary function */ + int (*xCreateFunction)( + fts5_api *pApi, + const char *zName, + void *pUserData, + fts5_extension_function xFunction, + void (*xDestroy)(void*) + ); + + /* APIs below this point are only available if iVersion>=3 */ + + /* Create a new tokenizer */ + int (*xCreateTokenizer_v2)( + fts5_api *pApi, + const char *zName, + void *pUserData, + fts5_tokenizer_v2 *pTokenizer, + void (*xDestroy)(void*) + ); + + /* Find an existing tokenizer */ + int (*xFindTokenizer_v2)( + fts5_api *pApi, + const char *zName, + void **ppUserData, + fts5_tokenizer_v2 **ppTokenizer + ); +}; + +/* +** END OF REGISTRATION API +*************************************************************************/ + +#ifdef __cplusplus +} /* end of the 'extern "C"' block */ +#endif + +#endif /* _FTS5_H */ + +/******** End of fts5.h *********/ +#endif /* SQLITE3_H */ diff --git a/illumos-x86_64/usr/include/sqlite3ext.h b/illumos-x86_64/usr/include/sqlite3ext.h new file mode 100644 index 00000000..cf775dfb --- /dev/null +++ b/illumos-x86_64/usr/include/sqlite3ext.h @@ -0,0 +1,723 @@ +/* +** 2006 June 7 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the SQLite interface for use by +** shared libraries that want to be imported as extensions into +** an SQLite instance. Shared libraries that intend to be loaded +** as extensions by SQLite should #include this file instead of +** sqlite3.h. +*/ +#ifndef SQLITE3EXT_H +#define SQLITE3EXT_H +#include "sqlite3.h" + +/* +** The following structure holds pointers to all of the SQLite API +** routines. +** +** WARNING: In order to maintain backwards compatibility, add new +** interfaces to the end of this structure only. If you insert new +** interfaces in the middle of this structure, then older different +** versions of SQLite will not be able to load each other's shared +** libraries! +*/ +struct sqlite3_api_routines { + void * (*aggregate_context)(sqlite3_context*,int nBytes); + int (*aggregate_count)(sqlite3_context*); + int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); + int (*bind_double)(sqlite3_stmt*,int,double); + int (*bind_int)(sqlite3_stmt*,int,int); + int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64); + int (*bind_null)(sqlite3_stmt*,int); + int (*bind_parameter_count)(sqlite3_stmt*); + int (*bind_parameter_index)(sqlite3_stmt*,const char*zName); + const char * (*bind_parameter_name)(sqlite3_stmt*,int); + int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*)); + int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*)); + int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*); + int (*busy_handler)(sqlite3*,int(*)(void*,int),void*); + int (*busy_timeout)(sqlite3*,int ms); + int (*changes)(sqlite3*); + int (*close)(sqlite3*); + int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*, + int eTextRep,const char*)); + int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*, + int eTextRep,const void*)); + const void * (*column_blob)(sqlite3_stmt*,int iCol); + int (*column_bytes)(sqlite3_stmt*,int iCol); + int (*column_bytes16)(sqlite3_stmt*,int iCol); + int (*column_count)(sqlite3_stmt*pStmt); + const char * (*column_database_name)(sqlite3_stmt*,int); + const void * (*column_database_name16)(sqlite3_stmt*,int); + const char * (*column_decltype)(sqlite3_stmt*,int i); + const void * (*column_decltype16)(sqlite3_stmt*,int); + double (*column_double)(sqlite3_stmt*,int iCol); + int (*column_int)(sqlite3_stmt*,int iCol); + sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol); + const char * (*column_name)(sqlite3_stmt*,int); + const void * (*column_name16)(sqlite3_stmt*,int); + const char * (*column_origin_name)(sqlite3_stmt*,int); + const void * (*column_origin_name16)(sqlite3_stmt*,int); + const char * (*column_table_name)(sqlite3_stmt*,int); + const void * (*column_table_name16)(sqlite3_stmt*,int); + const unsigned char * (*column_text)(sqlite3_stmt*,int iCol); + const void * (*column_text16)(sqlite3_stmt*,int iCol); + int (*column_type)(sqlite3_stmt*,int iCol); + sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol); + void * (*commit_hook)(sqlite3*,int(*)(void*),void*); + int (*complete)(const char*sql); + int (*complete16)(const void*sql); + int (*create_collation)(sqlite3*,const char*,int,void*, + int(*)(void*,int,const void*,int,const void*)); + int (*create_collation16)(sqlite3*,const void*,int,void*, + int(*)(void*,int,const void*,int,const void*)); + int (*create_function)(sqlite3*,const char*,int,int,void*, + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*)); + int (*create_function16)(sqlite3*,const void*,int,int,void*, + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*)); + int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); + int (*data_count)(sqlite3_stmt*pStmt); + sqlite3 * (*db_handle)(sqlite3_stmt*); + int (*declare_vtab)(sqlite3*,const char*); + int (*enable_shared_cache)(int); + int (*errcode)(sqlite3*db); + const char * (*errmsg)(sqlite3*); + const void * (*errmsg16)(sqlite3*); + int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**); + int (*expired)(sqlite3_stmt*); + int (*finalize)(sqlite3_stmt*pStmt); + void (*free)(void*); + void (*free_table)(char**result); + int (*get_autocommit)(sqlite3*); + void * (*get_auxdata)(sqlite3_context*,int); + int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**); + int (*global_recover)(void); + void (*interruptx)(sqlite3*); + sqlite_int64 (*last_insert_rowid)(sqlite3*); + const char * (*libversion)(void); + int (*libversion_number)(void); + void *(*malloc)(int); + char * (*mprintf)(const char*,...); + int (*open)(const char*,sqlite3**); + int (*open16)(const void*,sqlite3**); + int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); + int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); + void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*); + void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); + void *(*realloc)(void*,int); + int (*reset)(sqlite3_stmt*pStmt); + void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*)); + void (*result_double)(sqlite3_context*,double); + void (*result_error)(sqlite3_context*,const char*,int); + void (*result_error16)(sqlite3_context*,const void*,int); + void (*result_int)(sqlite3_context*,int); + void (*result_int64)(sqlite3_context*,sqlite_int64); + void (*result_null)(sqlite3_context*); + void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*)); + void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*)); + void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*)); + void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*)); + void (*result_value)(sqlite3_context*,sqlite3_value*); + void * (*rollback_hook)(sqlite3*,void(*)(void*),void*); + int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*, + const char*,const char*),void*); + void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*)); + char * (*xsnprintf)(int,char*,const char*,...); + int (*step)(sqlite3_stmt*); + int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*, + char const**,char const**,int*,int*,int*); + void (*thread_cleanup)(void); + int (*total_changes)(sqlite3*); + void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*); + int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*); + void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*, + sqlite_int64),void*); + void * (*user_data)(sqlite3_context*); + const void * (*value_blob)(sqlite3_value*); + int (*value_bytes)(sqlite3_value*); + int (*value_bytes16)(sqlite3_value*); + double (*value_double)(sqlite3_value*); + int (*value_int)(sqlite3_value*); + sqlite_int64 (*value_int64)(sqlite3_value*); + int (*value_numeric_type)(sqlite3_value*); + const unsigned char * (*value_text)(sqlite3_value*); + const void * (*value_text16)(sqlite3_value*); + const void * (*value_text16be)(sqlite3_value*); + const void * (*value_text16le)(sqlite3_value*); + int (*value_type)(sqlite3_value*); + char *(*vmprintf)(const char*,va_list); + /* Added ??? */ + int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); + /* Added by 3.3.13 */ + int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); + int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); + int (*clear_bindings)(sqlite3_stmt*); + /* Added by 3.4.1 */ + int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*, + void (*xDestroy)(void *)); + /* Added by 3.5.0 */ + int (*bind_zeroblob)(sqlite3_stmt*,int,int); + int (*blob_bytes)(sqlite3_blob*); + int (*blob_close)(sqlite3_blob*); + int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64, + int,sqlite3_blob**); + int (*blob_read)(sqlite3_blob*,void*,int,int); + int (*blob_write)(sqlite3_blob*,const void*,int,int); + int (*create_collation_v2)(sqlite3*,const char*,int,void*, + int(*)(void*,int,const void*,int,const void*), + void(*)(void*)); + int (*file_control)(sqlite3*,const char*,int,void*); + sqlite3_int64 (*memory_highwater)(int); + sqlite3_int64 (*memory_used)(void); + sqlite3_mutex *(*mutex_alloc)(int); + void (*mutex_enter)(sqlite3_mutex*); + void (*mutex_free)(sqlite3_mutex*); + void (*mutex_leave)(sqlite3_mutex*); + int (*mutex_try)(sqlite3_mutex*); + int (*open_v2)(const char*,sqlite3**,int,const char*); + int (*release_memory)(int); + void (*result_error_nomem)(sqlite3_context*); + void (*result_error_toobig)(sqlite3_context*); + int (*sleep)(int); + void (*soft_heap_limit)(int); + sqlite3_vfs *(*vfs_find)(const char*); + int (*vfs_register)(sqlite3_vfs*,int); + int (*vfs_unregister)(sqlite3_vfs*); + int (*xthreadsafe)(void); + void (*result_zeroblob)(sqlite3_context*,int); + void (*result_error_code)(sqlite3_context*,int); + int (*test_control)(int, ...); + void (*randomness)(int,void*); + sqlite3 *(*context_db_handle)(sqlite3_context*); + int (*extended_result_codes)(sqlite3*,int); + int (*limit)(sqlite3*,int,int); + sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*); + const char *(*sql)(sqlite3_stmt*); + int (*status)(int,int*,int*,int); + int (*backup_finish)(sqlite3_backup*); + sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*); + int (*backup_pagecount)(sqlite3_backup*); + int (*backup_remaining)(sqlite3_backup*); + int (*backup_step)(sqlite3_backup*,int); + const char *(*compileoption_get)(int); + int (*compileoption_used)(const char*); + int (*create_function_v2)(sqlite3*,const char*,int,int,void*, + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*), + void(*xDestroy)(void*)); + int (*db_config)(sqlite3*,int,...); + sqlite3_mutex *(*db_mutex)(sqlite3*); + int (*db_status)(sqlite3*,int,int*,int*,int); + int (*extended_errcode)(sqlite3*); + void (*log)(int,const char*,...); + sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64); + const char *(*sourceid)(void); + int (*stmt_status)(sqlite3_stmt*,int,int); + int (*strnicmp)(const char*,const char*,int); + int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*); + int (*wal_autocheckpoint)(sqlite3*,int); + int (*wal_checkpoint)(sqlite3*,const char*); + void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*); + int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); + int (*vtab_config)(sqlite3*,int op,...); + int (*vtab_on_conflict)(sqlite3*); + /* Version 3.7.16 and later */ + int (*close_v2)(sqlite3*); + const char *(*db_filename)(sqlite3*,const char*); + int (*db_readonly)(sqlite3*,const char*); + int (*db_release_memory)(sqlite3*); + const char *(*errstr)(int); + int (*stmt_busy)(sqlite3_stmt*); + int (*stmt_readonly)(sqlite3_stmt*); + int (*stricmp)(const char*,const char*); + int (*uri_boolean)(const char*,const char*,int); + sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64); + const char *(*uri_parameter)(const char*,const char*); + char *(*xvsnprintf)(int,char*,const char*,va_list); + int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); + /* Version 3.8.7 and later */ + int (*auto_extension)(void(*)(void)); + int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64, + void(*)(void*)); + int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64, + void(*)(void*),unsigned char); + int (*cancel_auto_extension)(void(*)(void)); + int (*load_extension)(sqlite3*,const char*,const char*,char**); + void *(*malloc64)(sqlite3_uint64); + sqlite3_uint64 (*msize)(void*); + void *(*realloc64)(void*,sqlite3_uint64); + void (*reset_auto_extension)(void); + void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64, + void(*)(void*)); + void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64, + void(*)(void*), unsigned char); + int (*strglob)(const char*,const char*); + /* Version 3.8.11 and later */ + sqlite3_value *(*value_dup)(const sqlite3_value*); + void (*value_free)(sqlite3_value*); + int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64); + int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64); + /* Version 3.9.0 and later */ + unsigned int (*value_subtype)(sqlite3_value*); + void (*result_subtype)(sqlite3_context*,unsigned int); + /* Version 3.10.0 and later */ + int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int); + int (*strlike)(const char*,const char*,unsigned int); + int (*db_cacheflush)(sqlite3*); + /* Version 3.12.0 and later */ + int (*system_errno)(sqlite3*); + /* Version 3.14.0 and later */ + int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*); + char *(*expanded_sql)(sqlite3_stmt*); + /* Version 3.18.0 and later */ + void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64); + /* Version 3.20.0 and later */ + int (*prepare_v3)(sqlite3*,const char*,int,unsigned int, + sqlite3_stmt**,const char**); + int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int, + sqlite3_stmt**,const void**); + int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*)); + void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*)); + void *(*value_pointer)(sqlite3_value*,const char*); + int (*vtab_nochange)(sqlite3_context*); + int (*value_nochange)(sqlite3_value*); + const char *(*vtab_collation)(sqlite3_index_info*,int); + /* Version 3.24.0 and later */ + int (*keyword_count)(void); + int (*keyword_name)(int,const char**,int*); + int (*keyword_check)(const char*,int); + sqlite3_str *(*str_new)(sqlite3*); + char *(*str_finish)(sqlite3_str*); + void (*str_appendf)(sqlite3_str*, const char *zFormat, ...); + void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list); + void (*str_append)(sqlite3_str*, const char *zIn, int N); + void (*str_appendall)(sqlite3_str*, const char *zIn); + void (*str_appendchar)(sqlite3_str*, int N, char C); + void (*str_reset)(sqlite3_str*); + int (*str_errcode)(sqlite3_str*); + int (*str_length)(sqlite3_str*); + char *(*str_value)(sqlite3_str*); + /* Version 3.25.0 and later */ + int (*create_window_function)(sqlite3*,const char*,int,int,void*, + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*), + void (*xValue)(sqlite3_context*), + void (*xInv)(sqlite3_context*,int,sqlite3_value**), + void(*xDestroy)(void*)); + /* Version 3.26.0 and later */ + const char *(*normalized_sql)(sqlite3_stmt*); + /* Version 3.28.0 and later */ + int (*stmt_isexplain)(sqlite3_stmt*); + int (*value_frombind)(sqlite3_value*); + /* Version 3.30.0 and later */ + int (*drop_modules)(sqlite3*,const char**); + /* Version 3.31.0 and later */ + sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64); + const char *(*uri_key)(const char*,int); + const char *(*filename_database)(const char*); + const char *(*filename_journal)(const char*); + const char *(*filename_wal)(const char*); + /* Version 3.32.0 and later */ + const char *(*create_filename)(const char*,const char*,const char*, + int,const char**); + void (*free_filename)(const char*); + sqlite3_file *(*database_file_object)(const char*); + /* Version 3.34.0 and later */ + int (*txn_state)(sqlite3*,const char*); + /* Version 3.36.1 and later */ + sqlite3_int64 (*changes64)(sqlite3*); + sqlite3_int64 (*total_changes64)(sqlite3*); + /* Version 3.37.0 and later */ + int (*autovacuum_pages)(sqlite3*, + unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), + void*, void(*)(void*)); + /* Version 3.38.0 and later */ + int (*error_offset)(sqlite3*); + int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**); + int (*vtab_distinct)(sqlite3_index_info*); + int (*vtab_in)(sqlite3_index_info*,int,int); + int (*vtab_in_first)(sqlite3_value*,sqlite3_value**); + int (*vtab_in_next)(sqlite3_value*,sqlite3_value**); + /* Version 3.39.0 and later */ + int (*deserialize)(sqlite3*,const char*,unsigned char*, + sqlite3_int64,sqlite3_int64,unsigned); + unsigned char *(*serialize)(sqlite3*,const char *,sqlite3_int64*, + unsigned int); + const char *(*db_name)(sqlite3*,int); + /* Version 3.40.0 and later */ + int (*value_encoding)(sqlite3_value*); + /* Version 3.41.0 and later */ + int (*is_interrupted)(sqlite3*); + /* Version 3.43.0 and later */ + int (*stmt_explain)(sqlite3_stmt*,int); + /* Version 3.44.0 and later */ + void *(*get_clientdata)(sqlite3*,const char*); + int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*)); + /* Version 3.50.0 and later */ + int (*setlk_timeout)(sqlite3*,int,int); +}; + +/* +** This is the function signature used for all extension entry points. It +** is also defined in the file "loadext.c". +*/ +typedef int (*sqlite3_loadext_entry)( + sqlite3 *db, /* Handle to the database. */ + char **pzErrMsg, /* Used to set error string on failure. */ + const sqlite3_api_routines *pThunk /* Extension API function pointers. */ +); + +/* +** The following macros redefine the API routines so that they are +** redirected through the global sqlite3_api structure. +** +** This header file is also used by the loadext.c source file +** (part of the main SQLite library - not an extension) so that +** it can get access to the sqlite3_api_routines structure +** definition. But the main library does not want to redefine +** the API. So the redefinition macros are only valid if the +** SQLITE_CORE macros is undefined. +*/ +#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) +#define sqlite3_aggregate_context sqlite3_api->aggregate_context +#ifndef SQLITE_OMIT_DEPRECATED +#define sqlite3_aggregate_count sqlite3_api->aggregate_count +#endif +#define sqlite3_bind_blob sqlite3_api->bind_blob +#define sqlite3_bind_double sqlite3_api->bind_double +#define sqlite3_bind_int sqlite3_api->bind_int +#define sqlite3_bind_int64 sqlite3_api->bind_int64 +#define sqlite3_bind_null sqlite3_api->bind_null +#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count +#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index +#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name +#define sqlite3_bind_text sqlite3_api->bind_text +#define sqlite3_bind_text16 sqlite3_api->bind_text16 +#define sqlite3_bind_value sqlite3_api->bind_value +#define sqlite3_busy_handler sqlite3_api->busy_handler +#define sqlite3_busy_timeout sqlite3_api->busy_timeout +#define sqlite3_changes sqlite3_api->changes +#define sqlite3_close sqlite3_api->close +#define sqlite3_collation_needed sqlite3_api->collation_needed +#define sqlite3_collation_needed16 sqlite3_api->collation_needed16 +#define sqlite3_column_blob sqlite3_api->column_blob +#define sqlite3_column_bytes sqlite3_api->column_bytes +#define sqlite3_column_bytes16 sqlite3_api->column_bytes16 +#define sqlite3_column_count sqlite3_api->column_count +#define sqlite3_column_database_name sqlite3_api->column_database_name +#define sqlite3_column_database_name16 sqlite3_api->column_database_name16 +#define sqlite3_column_decltype sqlite3_api->column_decltype +#define sqlite3_column_decltype16 sqlite3_api->column_decltype16 +#define sqlite3_column_double sqlite3_api->column_double +#define sqlite3_column_int sqlite3_api->column_int +#define sqlite3_column_int64 sqlite3_api->column_int64 +#define sqlite3_column_name sqlite3_api->column_name +#define sqlite3_column_name16 sqlite3_api->column_name16 +#define sqlite3_column_origin_name sqlite3_api->column_origin_name +#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16 +#define sqlite3_column_table_name sqlite3_api->column_table_name +#define sqlite3_column_table_name16 sqlite3_api->column_table_name16 +#define sqlite3_column_text sqlite3_api->column_text +#define sqlite3_column_text16 sqlite3_api->column_text16 +#define sqlite3_column_type sqlite3_api->column_type +#define sqlite3_column_value sqlite3_api->column_value +#define sqlite3_commit_hook sqlite3_api->commit_hook +#define sqlite3_complete sqlite3_api->complete +#define sqlite3_complete16 sqlite3_api->complete16 +#define sqlite3_create_collation sqlite3_api->create_collation +#define sqlite3_create_collation16 sqlite3_api->create_collation16 +#define sqlite3_create_function sqlite3_api->create_function +#define sqlite3_create_function16 sqlite3_api->create_function16 +#define sqlite3_create_module sqlite3_api->create_module +#define sqlite3_create_module_v2 sqlite3_api->create_module_v2 +#define sqlite3_data_count sqlite3_api->data_count +#define sqlite3_db_handle sqlite3_api->db_handle +#define sqlite3_declare_vtab sqlite3_api->declare_vtab +#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache +#define sqlite3_errcode sqlite3_api->errcode +#define sqlite3_errmsg sqlite3_api->errmsg +#define sqlite3_errmsg16 sqlite3_api->errmsg16 +#define sqlite3_exec sqlite3_api->exec +#ifndef SQLITE_OMIT_DEPRECATED +#define sqlite3_expired sqlite3_api->expired +#endif +#define sqlite3_finalize sqlite3_api->finalize +#define sqlite3_free sqlite3_api->free +#define sqlite3_free_table sqlite3_api->free_table +#define sqlite3_get_autocommit sqlite3_api->get_autocommit +#define sqlite3_get_auxdata sqlite3_api->get_auxdata +#define sqlite3_get_table sqlite3_api->get_table +#ifndef SQLITE_OMIT_DEPRECATED +#define sqlite3_global_recover sqlite3_api->global_recover +#endif +#define sqlite3_interrupt sqlite3_api->interruptx +#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid +#define sqlite3_libversion sqlite3_api->libversion +#define sqlite3_libversion_number sqlite3_api->libversion_number +#define sqlite3_malloc sqlite3_api->malloc +#define sqlite3_mprintf sqlite3_api->mprintf +#define sqlite3_open sqlite3_api->open +#define sqlite3_open16 sqlite3_api->open16 +#define sqlite3_prepare sqlite3_api->prepare +#define sqlite3_prepare16 sqlite3_api->prepare16 +#define sqlite3_prepare_v2 sqlite3_api->prepare_v2 +#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 +#define sqlite3_profile sqlite3_api->profile +#define sqlite3_progress_handler sqlite3_api->progress_handler +#define sqlite3_realloc sqlite3_api->realloc +#define sqlite3_reset sqlite3_api->reset +#define sqlite3_result_blob sqlite3_api->result_blob +#define sqlite3_result_double sqlite3_api->result_double +#define sqlite3_result_error sqlite3_api->result_error +#define sqlite3_result_error16 sqlite3_api->result_error16 +#define sqlite3_result_int sqlite3_api->result_int +#define sqlite3_result_int64 sqlite3_api->result_int64 +#define sqlite3_result_null sqlite3_api->result_null +#define sqlite3_result_text sqlite3_api->result_text +#define sqlite3_result_text16 sqlite3_api->result_text16 +#define sqlite3_result_text16be sqlite3_api->result_text16be +#define sqlite3_result_text16le sqlite3_api->result_text16le +#define sqlite3_result_value sqlite3_api->result_value +#define sqlite3_rollback_hook sqlite3_api->rollback_hook +#define sqlite3_set_authorizer sqlite3_api->set_authorizer +#define sqlite3_set_auxdata sqlite3_api->set_auxdata +#define sqlite3_snprintf sqlite3_api->xsnprintf +#define sqlite3_step sqlite3_api->step +#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata +#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup +#define sqlite3_total_changes sqlite3_api->total_changes +#define sqlite3_trace sqlite3_api->trace +#ifndef SQLITE_OMIT_DEPRECATED +#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings +#endif +#define sqlite3_update_hook sqlite3_api->update_hook +#define sqlite3_user_data sqlite3_api->user_data +#define sqlite3_value_blob sqlite3_api->value_blob +#define sqlite3_value_bytes sqlite3_api->value_bytes +#define sqlite3_value_bytes16 sqlite3_api->value_bytes16 +#define sqlite3_value_double sqlite3_api->value_double +#define sqlite3_value_int sqlite3_api->value_int +#define sqlite3_value_int64 sqlite3_api->value_int64 +#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type +#define sqlite3_value_text sqlite3_api->value_text +#define sqlite3_value_text16 sqlite3_api->value_text16 +#define sqlite3_value_text16be sqlite3_api->value_text16be +#define sqlite3_value_text16le sqlite3_api->value_text16le +#define sqlite3_value_type sqlite3_api->value_type +#define sqlite3_vmprintf sqlite3_api->vmprintf +#define sqlite3_vsnprintf sqlite3_api->xvsnprintf +#define sqlite3_overload_function sqlite3_api->overload_function +#define sqlite3_prepare_v2 sqlite3_api->prepare_v2 +#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 +#define sqlite3_clear_bindings sqlite3_api->clear_bindings +#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob +#define sqlite3_blob_bytes sqlite3_api->blob_bytes +#define sqlite3_blob_close sqlite3_api->blob_close +#define sqlite3_blob_open sqlite3_api->blob_open +#define sqlite3_blob_read sqlite3_api->blob_read +#define sqlite3_blob_write sqlite3_api->blob_write +#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2 +#define sqlite3_file_control sqlite3_api->file_control +#define sqlite3_memory_highwater sqlite3_api->memory_highwater +#define sqlite3_memory_used sqlite3_api->memory_used +#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc +#define sqlite3_mutex_enter sqlite3_api->mutex_enter +#define sqlite3_mutex_free sqlite3_api->mutex_free +#define sqlite3_mutex_leave sqlite3_api->mutex_leave +#define sqlite3_mutex_try sqlite3_api->mutex_try +#define sqlite3_open_v2 sqlite3_api->open_v2 +#define sqlite3_release_memory sqlite3_api->release_memory +#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem +#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig +#define sqlite3_sleep sqlite3_api->sleep +#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit +#define sqlite3_vfs_find sqlite3_api->vfs_find +#define sqlite3_vfs_register sqlite3_api->vfs_register +#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister +#define sqlite3_threadsafe sqlite3_api->xthreadsafe +#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob +#define sqlite3_result_error_code sqlite3_api->result_error_code +#define sqlite3_test_control sqlite3_api->test_control +#define sqlite3_randomness sqlite3_api->randomness +#define sqlite3_context_db_handle sqlite3_api->context_db_handle +#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes +#define sqlite3_limit sqlite3_api->limit +#define sqlite3_next_stmt sqlite3_api->next_stmt +#define sqlite3_sql sqlite3_api->sql +#define sqlite3_status sqlite3_api->status +#define sqlite3_backup_finish sqlite3_api->backup_finish +#define sqlite3_backup_init sqlite3_api->backup_init +#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount +#define sqlite3_backup_remaining sqlite3_api->backup_remaining +#define sqlite3_backup_step sqlite3_api->backup_step +#define sqlite3_compileoption_get sqlite3_api->compileoption_get +#define sqlite3_compileoption_used sqlite3_api->compileoption_used +#define sqlite3_create_function_v2 sqlite3_api->create_function_v2 +#define sqlite3_db_config sqlite3_api->db_config +#define sqlite3_db_mutex sqlite3_api->db_mutex +#define sqlite3_db_status sqlite3_api->db_status +#define sqlite3_extended_errcode sqlite3_api->extended_errcode +#define sqlite3_log sqlite3_api->log +#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64 +#define sqlite3_sourceid sqlite3_api->sourceid +#define sqlite3_stmt_status sqlite3_api->stmt_status +#define sqlite3_strnicmp sqlite3_api->strnicmp +#define sqlite3_unlock_notify sqlite3_api->unlock_notify +#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint +#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint +#define sqlite3_wal_hook sqlite3_api->wal_hook +#define sqlite3_blob_reopen sqlite3_api->blob_reopen +#define sqlite3_vtab_config sqlite3_api->vtab_config +#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict +/* Version 3.7.16 and later */ +#define sqlite3_close_v2 sqlite3_api->close_v2 +#define sqlite3_db_filename sqlite3_api->db_filename +#define sqlite3_db_readonly sqlite3_api->db_readonly +#define sqlite3_db_release_memory sqlite3_api->db_release_memory +#define sqlite3_errstr sqlite3_api->errstr +#define sqlite3_stmt_busy sqlite3_api->stmt_busy +#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly +#define sqlite3_stricmp sqlite3_api->stricmp +#define sqlite3_uri_boolean sqlite3_api->uri_boolean +#define sqlite3_uri_int64 sqlite3_api->uri_int64 +#define sqlite3_uri_parameter sqlite3_api->uri_parameter +#define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf +#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2 +/* Version 3.8.7 and later */ +#define sqlite3_auto_extension sqlite3_api->auto_extension +#define sqlite3_bind_blob64 sqlite3_api->bind_blob64 +#define sqlite3_bind_text64 sqlite3_api->bind_text64 +#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension +#define sqlite3_load_extension sqlite3_api->load_extension +#define sqlite3_malloc64 sqlite3_api->malloc64 +#define sqlite3_msize sqlite3_api->msize +#define sqlite3_realloc64 sqlite3_api->realloc64 +#define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension +#define sqlite3_result_blob64 sqlite3_api->result_blob64 +#define sqlite3_result_text64 sqlite3_api->result_text64 +#define sqlite3_strglob sqlite3_api->strglob +/* Version 3.8.11 and later */ +#define sqlite3_value_dup sqlite3_api->value_dup +#define sqlite3_value_free sqlite3_api->value_free +#define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64 +#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64 +/* Version 3.9.0 and later */ +#define sqlite3_value_subtype sqlite3_api->value_subtype +#define sqlite3_result_subtype sqlite3_api->result_subtype +/* Version 3.10.0 and later */ +#define sqlite3_status64 sqlite3_api->status64 +#define sqlite3_strlike sqlite3_api->strlike +#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush +/* Version 3.12.0 and later */ +#define sqlite3_system_errno sqlite3_api->system_errno +/* Version 3.14.0 and later */ +#define sqlite3_trace_v2 sqlite3_api->trace_v2 +#define sqlite3_expanded_sql sqlite3_api->expanded_sql +/* Version 3.18.0 and later */ +#define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid +/* Version 3.20.0 and later */ +#define sqlite3_prepare_v3 sqlite3_api->prepare_v3 +#define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3 +#define sqlite3_bind_pointer sqlite3_api->bind_pointer +#define sqlite3_result_pointer sqlite3_api->result_pointer +#define sqlite3_value_pointer sqlite3_api->value_pointer +/* Version 3.22.0 and later */ +#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange +#define sqlite3_value_nochange sqlite3_api->value_nochange +#define sqlite3_vtab_collation sqlite3_api->vtab_collation +/* Version 3.24.0 and later */ +#define sqlite3_keyword_count sqlite3_api->keyword_count +#define sqlite3_keyword_name sqlite3_api->keyword_name +#define sqlite3_keyword_check sqlite3_api->keyword_check +#define sqlite3_str_new sqlite3_api->str_new +#define sqlite3_str_finish sqlite3_api->str_finish +#define sqlite3_str_appendf sqlite3_api->str_appendf +#define sqlite3_str_vappendf sqlite3_api->str_vappendf +#define sqlite3_str_append sqlite3_api->str_append +#define sqlite3_str_appendall sqlite3_api->str_appendall +#define sqlite3_str_appendchar sqlite3_api->str_appendchar +#define sqlite3_str_reset sqlite3_api->str_reset +#define sqlite3_str_errcode sqlite3_api->str_errcode +#define sqlite3_str_length sqlite3_api->str_length +#define sqlite3_str_value sqlite3_api->str_value +/* Version 3.25.0 and later */ +#define sqlite3_create_window_function sqlite3_api->create_window_function +/* Version 3.26.0 and later */ +#define sqlite3_normalized_sql sqlite3_api->normalized_sql +/* Version 3.28.0 and later */ +#define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain +#define sqlite3_value_frombind sqlite3_api->value_frombind +/* Version 3.30.0 and later */ +#define sqlite3_drop_modules sqlite3_api->drop_modules +/* Version 3.31.0 and later */ +#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64 +#define sqlite3_uri_key sqlite3_api->uri_key +#define sqlite3_filename_database sqlite3_api->filename_database +#define sqlite3_filename_journal sqlite3_api->filename_journal +#define sqlite3_filename_wal sqlite3_api->filename_wal +/* Version 3.32.0 and later */ +#define sqlite3_create_filename sqlite3_api->create_filename +#define sqlite3_free_filename sqlite3_api->free_filename +#define sqlite3_database_file_object sqlite3_api->database_file_object +/* Version 3.34.0 and later */ +#define sqlite3_txn_state sqlite3_api->txn_state +/* Version 3.36.1 and later */ +#define sqlite3_changes64 sqlite3_api->changes64 +#define sqlite3_total_changes64 sqlite3_api->total_changes64 +/* Version 3.37.0 and later */ +#define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages +/* Version 3.38.0 and later */ +#define sqlite3_error_offset sqlite3_api->error_offset +#define sqlite3_vtab_rhs_value sqlite3_api->vtab_rhs_value +#define sqlite3_vtab_distinct sqlite3_api->vtab_distinct +#define sqlite3_vtab_in sqlite3_api->vtab_in +#define sqlite3_vtab_in_first sqlite3_api->vtab_in_first +#define sqlite3_vtab_in_next sqlite3_api->vtab_in_next +/* Version 3.39.0 and later */ +#ifndef SQLITE_OMIT_DESERIALIZE +#define sqlite3_deserialize sqlite3_api->deserialize +#define sqlite3_serialize sqlite3_api->serialize +#endif +#define sqlite3_db_name sqlite3_api->db_name +/* Version 3.40.0 and later */ +#define sqlite3_value_encoding sqlite3_api->value_encoding +/* Version 3.41.0 and later */ +#define sqlite3_is_interrupted sqlite3_api->is_interrupted +/* Version 3.43.0 and later */ +#define sqlite3_stmt_explain sqlite3_api->stmt_explain +/* Version 3.44.0 and later */ +#define sqlite3_get_clientdata sqlite3_api->get_clientdata +#define sqlite3_set_clientdata sqlite3_api->set_clientdata +/* Version 3.50.0 and later */ +#define sqlite3_setlk_timeout sqlite3_api->setlk_timeout +#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ + +#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) + /* This case when the file really is being compiled as a loadable + ** extension */ +# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; +# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; +# define SQLITE_EXTENSION_INIT3 \ + extern const sqlite3_api_routines *sqlite3_api; +#else + /* This case when the file is being statically linked into the + ** application */ +# define SQLITE_EXTENSION_INIT1 /*no-op*/ +# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */ +# define SQLITE_EXTENSION_INIT3 /*no-op*/ +#endif + +#endif /* SQLITE3EXT_H */ diff --git a/illumos-x86_64/usr/include/stack_unwind.h b/illumos-x86_64/usr/include/stack_unwind.h new file mode 100644 index 00000000..eeead4c6 --- /dev/null +++ b/illumos-x86_64/usr/include/stack_unwind.h @@ -0,0 +1,296 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Public interfaces for AMD64 Unwind routines + */ + +#ifndef _STACK_UNWIND_H +#define _STACK_UNWIND_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__amd64) /* none of this is valid except for AMD64 */ + +typedef enum { + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8 +} _Unwind_Reason_Code; + +typedef int _Unwind_Action; +extern const _Unwind_Action _UA_SEARCH_PHASE; +extern const _Unwind_Action _UA_CLEANUP_PHASE; +extern const _Unwind_Action _UA_HANDLER_FRAME; +extern const _Unwind_Action _UA_FORCE_UNWIND; + +struct _Unwind_Exception; +struct _Unwind_Context; + + +/* + * Signature of language specific call back for deleting exception object + */ +typedef void (*_Unwind_Exception_Cleanup_Fn)( + _Unwind_Reason_Code reason, + struct _Unwind_Exception *exc); + +/* + * Header preceding language specific exception object + * For Sun C++ these fields are the beginning of the + * language specific structure. + */ +struct _Unwind_Exception { + uint64_t exception_class; + _Unwind_Exception_Cleanup_Fn exception_cleanup; + uint64_t private_1; + uint64_t private_2; +}; + +/* + * Signature for language specific routine - address is in eh_frame CIE. + * During phase one it predicts whether exception would be caught at this + * frame and during phase two selects a handler as predicted. An action + * of _UA_FORCE_UNWIND will prevent any catch block from being selected. + * + * The personality function is the only call back used when + * _Unwind_RaiseException() is called. + */ +typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)( + int version, + _Unwind_Action actions, + uint64_t exceptionClass, + struct _Unwind_Exception *exceptionObject, + struct _Unwind_Context *context); + +/* + * Signature of callback function that is used when _Unwind_ForcedUnwind() + * is called. It is called at every step of walkback and that can control + * the execution of the personality routine at each frame. + */ +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)( + int version, + _Unwind_Action actions, + uint64_t exceptionClass, + struct _Unwind_Exception *exceptionObject, + struct _Unwind_Context *context, + void *stop_parameter); + +/* + * Here begins the external functional interface + */ + +/* + * Used to implement C++ throw - starts walkback with caller's caller. + * The routine in the middle must use %rbp as a frame pointer + */ +_Unwind_Reason_Code _Unwind_RaiseException( + struct _Unwind_Exception *exception_object); + +/* + * Used (with different stop functions) for POSIX thread cancellation + * and stack walking - starts walkback with caller's caller. + * + * Note: must be called by a routine which has a real FP and doesn't use + * callee saves registers. + */ +_Unwind_Reason_Code _Unwind_ForcedUnwind( + struct _Unwind_Exception *exception_object, + _Unwind_Stop_Fn stop, + void *stop_parameter); + +/* + * Used to resume unwinding at end of cleanup (not catch) code + * Assumes that caller is language specific cleanup code and + * pops the stack one level before resuming walk. + */ +void _Unwind_Resume(struct _Unwind_Exception *exception_object); + +/* + * Calls destructor function for exception object + */ +void _Unwind_DeleteException(struct _Unwind_Exception *exception_object); +/* + * { + * (*(exception_object->exception_cleanup))(_URC_NO_REASON, + * exception_object); + * } + */ + + +#if 0 + +extern "C" _Unwind_Reason_Code +__example_stop_fn(int version, int actions, uint64_t exclass, + struct _Unwind_Exception *exception_object, + struct _Unwind_Context *ctx, void *_Sa) +{ + _Unwind_Reason_Code res; + + uint64_t fp = _Unwind_GetCFA(ctx); + + if (fp == 0 || _Unwind_GetGR(ctx, RET_ADD) == 0) { + if (no_return) + die; + res = _URC_END_OF_STACK; + } else { + /* + * Your logic here: + * res = ........ + */ + } + switch (res) { + case _URC_NO_REASON: + /* + * framework will call personality routine for current context + * then then move one frame back the stack and call here with + * updated context. POSIX thread cancellation uses this pattern. + * + * If this path is taken the exception object passed must have + * been constructed by the same language system supplying the + * personality routines. i.e. foreign exceptions are not + * implemented. + * + * The Sun Microsystems C++ runtime contains the routine + * + * _ex_unwind(_Unwind_Stop_fn sfunc, void *sfunc_arg) + * + * which is a wrapper around _Unwind_ForcedUnwind that + * sets up a C++ exception object. + * + * Once this path is taken, the stack frame from which + * _Unwind_ForcedUnwind was called is not guaranteed to + * still exist. Thus the return codes listed below which + * result in that call returning are rendered bogus. + * + * A thread reaching the end of the stack during cancellation + * must die instead of returning _URC_END_OF_STACK. + */ + break; + case _URC_CONTINUE_UNWIND: + /* + * framework will move one frame back the stack and + * call here with updated context + * + * The exception record supplied to _Unwind_ForcedUnwind + * need only contain the header and may be stack allocated + * if this function will never allow the personality + * function to run (as in a trace generator). + */ + break; + case _URC_INSTALL_CONTEXT: + /* + * framework will resume execution of user code at location + * specified by (altered) context + */ + _Unwind_Delete_Exception(res, exception_object); + break; + case _URC_NORMAL_STOP: + /* + * call to _Unwind_ForcedUnwind will return _URC_NORMAL_STOP + */ + _Unwind_Delete_Exception(res, exception_object); + break; + case _URC_END_OF_STACK: + /* + * call to _Unwind_ForcedUnwind will return _URC_END_OF_STACK + */ + _Unwind_Delete_Exception(res, exception_object); + break; + case _URC_FOREIGN_EXCEPTION_CAUGHT: + case _URC_FATAL_PHASE2_ERROR: + case _URC_FATAL_PHASE1_ERROR: + case _URC_HANDLER_FOUND: + /* + * call to _Unwind_ForcedUnwind will return + * _URC_FATAL_PHASE2_ERROR + */ + _Unwind_Delete_Exception(res, exception_object); + break; + } + return (res); +} + +#endif + +/* + * Stack frame context accessors defined in ABI + * (despite all the dire text in the ABI these are reliable Get/Set routines) + * Note: RA is handled as a GR value + */ + +/* + * Valid Index values for _Unwind_GetGR + */ +#define GPR_RBX 3 /* callee saves */ +#define FP_RBP 6 /* callee saves (optional frame pointer) */ +#define SP_RSP 7 /* callee saves */ +#define EIR_R12 12 /* callee saves */ +#define EIR_R13 13 /* callee saves */ +#define EIR_R14 14 /* callee saves */ +#define EIR_R15 15 /* callee saves */ +#define RET_ADD 16 /* virtual register - really caller's PC */ + +/* + * Valid Index values for _Unwind_SetGR + */ +#define GPR_RDX 1 /* landing pad parameter */ +#define GPR_RCX 2 /* landing pad parameter */ +#define GPR_RSI 4 /* landing pad parameter */ +#define GPR_RDI 5 /* landing pad parameter */ + +uint64_t _Unwind_GetGR(struct _Unwind_Context *context, int index); + +void _Unwind_SetGR(struct _Unwind_Context *context, int index, + uint64_t new_value); + +uint64_t _Unwind_GetCFA(struct _Unwind_Context *context); + +uint64_t _Unwind_GetIP(struct _Unwind_Context *context); + +void _Unwind_SetIP(struct _Unwind_Context *context, uint64_t new_value); + +void *_Unwind_GetLanguageSpecificData(struct _Unwind_Context *context); + +uint64_t _Unwind_GetRegionStart(struct _Unwind_Context *context); + +#endif /* __amd64 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STACK_UNWIND_H */ diff --git a/illumos-x86_64/usr/include/stdalign.h b/illumos-x86_64/usr/include/stdalign.h new file mode 100644 index 00000000..54edd168 --- /dev/null +++ b/illumos-x86_64/usr/include/stdalign.h @@ -0,0 +1,21 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _STDALIGN_H +#define _STDALIGN_H + +#include + +#endif /* _STDALIGN_H */ diff --git a/illumos-x86_64/usr/include/stdarg.h b/illumos-x86_64/usr/include/stdarg.h new file mode 100644 index 00000000..86d5734f --- /dev/null +++ b/illumos-x86_64/usr/include/stdarg.h @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _STDARG_H +#define _STDARG_H + +/* + * This header defines the ISO C 1989, ISO C++ 1998, and ISO C 1999 + * variable argument definitions. For legacy support, it also defines + * the pre-standard variable argument definitions. + * + * The varargs definitions within this header are defined in terms of + * implementation definitions. These implementation definitions reside + * in . This organization enables protected use of + * the implementation by other standard headers without introducing + * names into the users' namespace. + */ + +#include +#include + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::va_list; +#endif + +#endif /* _STDARG_H */ diff --git a/illumos-x86_64/usr/include/stdbit.h b/illumos-x86_64/usr/include/stdbit.h new file mode 100644 index 00000000..e431ad7e --- /dev/null +++ b/illumos-x86_64/usr/include/stdbit.h @@ -0,0 +1,27 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _STDBIT_H +#define _STDBIT_H + +/* + * This header was introduced in C23 and is the standard's expected interface + * for this functionality. We provide these routines to both userland and the + * kernel and all of the related declarations are in . + */ + +#include + +#endif /* _STDBIT_H */ diff --git a/illumos-x86_64/usr/include/stdbool.h b/illumos-x86_64/usr/include/stdbool.h new file mode 100644 index 00000000..f199b819 --- /dev/null +++ b/illumos-x86_64/usr/include/stdbool.h @@ -0,0 +1,32 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _STDBOOL_H +#define _STDBOOL_H + +#include + +#endif /* _STDBOOL_H */ diff --git a/illumos-x86_64/usr/include/stddef.h b/illumos-x86_64/usr/include/stddef.h new file mode 100644 index 00000000..ff822147 --- /dev/null +++ b/illumos-x86_64/usr/include/stddef.h @@ -0,0 +1,79 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _STDDEF_H +#define _STDDEF_H + +#include +#include +#include + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::ptrdiff_t; +using std::size_t; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * wchar_t is a built-in type in standard C++ and as such is not + * defined here when using standard C++. However, the GNU compiler + * fixincludes utility nonetheless creates its own version of this + * header for use by gcc and g++. In that version it adds a redundant + * guard for __cplusplus. To avoid the creation of a gcc/g++ specific + * header we need to include the following magic comment: + * + * we must use the C++ compiler's type + * + * The above comment should not be removed or changed until GNU + * gcc/fixinc/inclhack.def is updated to bypass this header. + */ +#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__)) +#ifndef _WCHAR_T +#define _WCHAR_T +#if defined(_LP64) +typedef int wchar_t; +#else +typedef long wchar_t; +#endif +#endif /* !_WCHAR_T */ +#endif /* !defined(__cplusplus) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STDDEF_H */ diff --git a/illumos-x86_64/usr/include/stdint.h b/illumos-x86_64/usr/include/stdint.h new file mode 100644 index 00000000..cb1bc885 --- /dev/null +++ b/illumos-x86_64/usr/include/stdint.h @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _STDINT_H +#define _STDINT_H + +/* + * This header was introduced by the ISO C Standard, ISO/IEC + * 9899:1999 Programming language - C. It is a subset of the + * header. + */ + +#include + +#if __EXT1_VISIBLE +/* ISO/IEC 9899:2011 K.3.4.4 */ +#ifndef RSIZE_MAX +#define RSIZE_MAX (SIZE_MAX >> 1) +#endif +#endif /* __EXT1_VISIBLE */ + +#endif /* _STDINT_H */ diff --git a/illumos-x86_64/usr/include/stdio.h b/illumos-x86_64/usr/include/stdio.h new file mode 100644 index 00000000..bc6627e1 --- /dev/null +++ b/illumos-x86_64/usr/include/stdio.h @@ -0,0 +1,391 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2025 Hans Rosenfeld + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * User-visible pieces of the ANSI C standard I/O package. + */ + +#ifndef _STDIO_H +#define _STDIO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Do all of our 'redefine_extname' processing before + * declarations of the associated functions are seen. + * This is necessary to keep gcc happy. + */ +#if defined(__PRAGMA_REDEFINE_EXTNAME) + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#pragma redefine_extname fopen fopen64 +#pragma redefine_extname freopen freopen64 +#pragma redefine_extname tmpfile tmpfile64 +#pragma redefine_extname fgetpos fgetpos64 +#pragma redefine_extname fsetpos fsetpos64 +#if defined(_LARGEFILE_SOURCE) +#pragma redefine_extname fseeko fseeko64 +#pragma redefine_extname ftello ftello64 +#endif /* _LARGEFILE_SOURCE */ +#endif /* !defined(_LP64) && _FILE_OFFSET_BITS == 64 */ + +/* In the LP64 compilation environment, all APIs are already large file */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#pragma redefine_extname fopen64 fopen +#pragma redefine_extname freopen64 freopen +#pragma redefine_extname tmpfile64 tmpfile +#pragma redefine_extname fgetpos64 fgetpos +#pragma redefine_extname fsetpos64 fsetpos +#if defined(_LARGEFILE_SOURCE) +#pragma redefine_extname fseeko64 fseeko +#pragma redefine_extname ftello64 ftello +#endif /* _LARGEFILE_SOURCE */ +#endif /* defined(_LP64) && defined(_LARGEFILE64_SOURCE) */ + +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#ifdef __cplusplus +} +#endif + +#include + +/* + * If feature test macros are set that enable interfaces that use types + * defined in , get those types by doing the include. + * + * Note that in asking for the interfaces associated with this feature test + * macro one also asks for definitions of the POSIX types. + */ + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::FILE; +using std::size_t; +using std::fpos_t; +using std::remove; +using std::rename; +using std::tmpfile; +using std::tmpnam; +using std::fclose; +using std::fflush; +using std::fopen; +using std::freopen; +using std::setbuf; +using std::setvbuf; +using std::fprintf; +using std::fscanf; +using std::printf; +using std::scanf; +using std::sprintf; +using std::sscanf; +using std::vfprintf; +using std::vprintf; +using std::vsprintf; +using std::fgetc; +using std::fgets; +using std::fputc; +using std::fputs; +using std::getc; +using std::getchar; +using std::gets; +using std::putc; +using std::putchar; +using std::puts; +using std::ungetc; +using std::fread; +using std::fwrite; +using std::fgetpos; +using std::fseek; +using std::fsetpos; +using std::ftell; +using std::rewind; +using std::clearerr; +using std::feof; +using std::ferror; +using std::perror; +#ifndef _LP64 +using std::__filbuf; +using std::__flsbuf; +#endif /* _LP64 */ +#endif /* __cplusplus >= 199711L */ + +/* + * This header needs to be included here because it relies on the global + * visibility of FILE and size_t in the C++ environment. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) +#ifndef _OFF_T +#define _OFF_T +#if defined(_LP64) || _FILE_OFFSET_BITS == 32 +typedef long off_t; +#else +typedef __longlong_t off_t; +#endif +#ifdef _LARGEFILE64_SOURCE +#ifdef _LP64 +typedef off_t off64_t; +#else +typedef __longlong_t off64_t; +#endif +#endif /* _LARGEFILE64_SOURCE */ +#endif /* _OFF_T */ +#endif /* _LARGEFILE_SOURCE */ + +#ifdef _LARGEFILE64_SOURCE +#ifdef _LP64 +typedef fpos_t fpos64_t; +#else +typedef __longlong_t fpos64_t; +#endif +#endif /* _LARGEFILE64_SOURCE */ + +/* + * XPG4 requires that va_list be defined in "as described in + * ". ANSI-C and POSIX require that the namespace of + * not be polluted with this name. + */ +#if defined(_XPG4) && !defined(_VA_LIST) +#define _VA_LIST +typedef __va_list va_list; +#endif /* defined(_XPG4 && !defined(_VA_LIST) */ + +#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \ + defined(__XOPEN_OR_POSIX) + +#define L_ctermid 9 + +/* Marked LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +#define L_cuserid 9 +#endif + +#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \ + defined(_XOPEN_SOURCE) + +#define P_tmpdir "/var/tmp/" +#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */ + +#ifndef _STDIO_ALLOCATE +extern unsigned char _sibuf[], _sobuf[]; +#endif + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#if !defined(__PRAGMA_REDEFINE_EXTNAME) +extern FILE *fopen64(const char *, const char *); +extern FILE *freopen64(const char *, const char *, FILE *); +extern FILE *tmpfile64(void); +extern int fgetpos64(FILE *, fpos_t *); +extern int fsetpos64(FILE *, const fpos_t *); +#define fopen fopen64 +#define freopen freopen64 +#define tmpfile tmpfile64 +#define fgetpos fgetpos64 +#define fsetpos fsetpos64 +#ifdef _LARGEFILE_SOURCE +#define fseeko fseeko64 +#define ftello ftello64 +#endif +#endif /* !__PRAGMA_REDEFINE_EXTNAME */ +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +#ifndef _LP64 +extern unsigned char *_bufendtab[]; +extern FILE *_lastbuf; +#endif + +/* In the LP64 compilation environment, all APIs are already large file */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#if !defined(__PRAGMA_REDEFINE_EXTNAME) +#define fopen64 fopen +#define freopen64 freopen +#define tmpfile64 tmpfile +#define fgetpos64 fgetpos +#define fsetpos64 fsetpos +#ifdef _LARGEFILE_SOURCE +#define fseeko64 fseeko +#define ftello64 ftello +#endif +#endif /* !__PRAGMA_REDEFINE_EXTNAME */ +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +#ifndef _SSIZE_T +#define _SSIZE_T +#if defined(_LP64) +typedef long ssize_t; /* size of something in bytes or -1 */ +#else +typedef int ssize_t; /* (historical version) */ +#endif +#endif /* !_SSIZE_T */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_REENTRANT) +extern char *tmpnam_r(char *); +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +extern int fdclose(FILE *, int *); +extern int fcloseall(void); +extern void setbuffer(FILE *, char *, size_t); +extern int setlinebuf(FILE *); +/* PRINTFLIKE2 */ +extern int asprintf(char **, const char *, ...); +/* PRINTFLIKE2 */ +extern int vasprintf(char **, const char *, __va_list); +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD, + int, FILE *_RESTRICT_KYWD); +extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD, + FILE *_RESTRICT_KYWD); +#endif /* __EXTENSIONS__ ... */ + +/* + * The following are known to POSIX and XOPEN, but not to ANSI-C. + */ +#if defined(__EXTENSIONS__) || \ + !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX) + +extern FILE *fdopen(int, const char *); +extern char *ctermid(char *); +extern int fileno(FILE *); + +#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */ + +/* + * The following are known to POSIX.1c, but not to ANSI-C or XOPEN. + */ +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ + (_POSIX_C_SOURCE - 0 >= 199506L) +extern void flockfile(FILE *); +extern int ftrylockfile(FILE *); +extern void funlockfile(FILE *); +extern int getc_unlocked(FILE *); +extern int getchar_unlocked(void); +extern int putc_unlocked(int, FILE *); +extern int putchar_unlocked(int); + +#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT).. */ + +/* + * The following are known to XOPEN, but not to ANSI-C or POSIX. + */ +#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \ + defined(_XOPEN_SOURCE) +extern FILE *popen(const char *, const char *); +extern char *tempnam(const char *, const char *); +extern int pclose(FILE *); +#if !defined(_XOPEN_SOURCE) +extern int getsubopt(char **, char *const *, char **); +#endif /* !defined(_XOPEN_SOURCE) */ + +/* Marked LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +extern char *cuserid(char *); +extern int getopt(int, char *const *, const char *); +extern char *optarg; +extern int optind, opterr, optopt; +extern int getw(FILE *); +extern int putw(int, FILE *); +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ + +#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */ + +/* + * The following are defined as part of the Large File Summit interfaces. + */ +#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) +extern int fseeko(FILE *, off_t, int); +extern off_t ftello(FILE *); +#endif + +/* + * The following are defined as part of the transitional Large File Summit + * interfaces. + */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern FILE *fopen64(const char *, const char *); +extern FILE *freopen64(const char *, const char *, FILE *); +extern FILE *tmpfile64(void); +extern int fgetpos64(FILE *, fpos64_t *); +extern int fsetpos64(FILE *, const fpos64_t *); +extern int fseeko64(FILE *, off64_t, int); +extern off64_t ftello64(FILE *); +#endif + +/* + * XPG7 symbols + */ +#if !defined(_STRICT_SYMBOLS) || defined(_XPG7) +extern FILE *fmemopen(void *_RESTRICT_KYWD, size_t, + const char *_RESTRICT_KYWD); +extern FILE *open_memstream(char **, size_t *); + +extern int dprintf(int, const char *_RESTRICT_KYWD, ...) + __PRINTFLIKE(2); +extern int vdprintf(int, const char *_RESTRICT_KYWD, __va_list) + __VPRINTFLIKE(2); +#endif /* !_STRICT_SYMBOLS || _XPG7 */ + +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ + (_POSIX_C_SOURCE - 0 >= 199506L) +#define getchar_unlocked() getc_unlocked(stdin) +#define putchar_unlocked(x) putc_unlocked((x), stdout) +#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT).. */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STDIO_H */ diff --git a/illumos-x86_64/usr/include/stdio_ext.h b/illumos-x86_64/usr/include/stdio_ext.h new file mode 100644 index 00000000..4360739b --- /dev/null +++ b/illumos-x86_64/usr/include/stdio_ext.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Extensions to the stdio package + */ + +#ifndef _STDIO_EXT_H +#define _STDIO_EXT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Even though the contents of the stdio FILE structure have always been + * private to the stdio implementation, over the years some programs have + * needed to get information about a stdio stream that was not accessible + * through a supported interface. These programs have resorted to accessing + * fields of the FILE structure directly, rendering them possibly non-portable + * to new implementations of stdio, or more likely, preventing enhancements + * to stdio because those programs will break. + * + * In the 64-bit world, the FILE structure is opaque. The routines here + * are provided as a way to get the information that used to be retrieved + * directly from the FILE structure. They are based on the needs of + * existing programs (such as 'mh' and 'emacs'), so they may be extended + * as other programs are ported. Though they may still be non-portable to + * other operating systems, they will work from each Solaris release to + * the next. More portable interfaces are being developed. + */ + +#define FSETLOCKING_QUERY 0 +#define FSETLOCKING_INTERNAL 1 +#define FSETLOCKING_BYCALLER 2 + +extern size_t __fbufsize(FILE *stream); +extern int __freading(FILE *stream); +extern int __fwriting(FILE *stream); +extern int __freadable(FILE *stream); +extern int __fwritable(FILE *stream); +extern int __flbf(FILE *stream); +extern void __fpurge(FILE *stream); +extern size_t __fpending(FILE *stream); +extern void _flushlbf(void); +extern int __fsetlocking(FILE *stream, int type); + +/* + * Extended FILE enabling function. + */ +#if defined(_LP64) && !defined(__lint) +#define enable_extended_FILE_stdio(fd, act) (0) +#else +extern int enable_extended_FILE_stdio(int, int); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _STDIO_EXT_H */ diff --git a/illumos-x86_64/usr/include/stdio_impl.h b/illumos-x86_64/usr/include/stdio_impl.h new file mode 100644 index 00000000..734ef267 --- /dev/null +++ b/illumos-x86_64/usr/include/stdio_impl.h @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _STDIO_IMPL_H +#define _STDIO_IMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _LP64 + +#ifndef _FILE64_H + +struct __FILE_TAG { + long __pad[16]; +}; + +#endif /* _FILE64_H */ + +#else + +struct __FILE_TAG /* needs to be binary-compatible with old versions */ +{ +#ifdef _STDIO_REVERSE + unsigned char *_ptr; /* next character from/to here in buffer */ + int _cnt; /* number of available characters in buffer */ +#else + int _cnt; /* number of available characters in buffer */ + unsigned char *_ptr; /* next character from/to here in buffer */ +#endif + unsigned char *_base; /* the buffer */ + unsigned char _flag; /* the state of the stream */ + unsigned char _magic; /* Old home of the file descriptor */ + /* Only fileno(3C) can retrieve the value now */ + unsigned __orientation:2; /* the orientation of the stream */ + unsigned __ionolock:1; /* turn off implicit locking */ + unsigned __seekable:1; /* is file seekable? */ + unsigned __extendedfd:1; /* enable extended FILE */ + unsigned __xf_nocheck:1; /* no extended FILE runtime check */ + unsigned __filler:10; +}; + +#endif /* _LP64 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STDIO_IMPL_H */ diff --git a/illumos-x86_64/usr/include/stdio_tag.h b/illumos-x86_64/usr/include/stdio_tag.h new file mode 100644 index 00000000..53777199 --- /dev/null +++ b/illumos-x86_64/usr/include/stdio_tag.h @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _STDIO_TAG_H +#define _STDIO_TAG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __FILE_TAG +#if defined(__cplusplus) && !defined(__GNUC__) && (__cplusplus < 54321L) +#define __FILE_TAG FILE +#else +#define __FILE_TAG __FILE +#endif +typedef struct __FILE_TAG __FILE; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _STDIO_TAG_H */ diff --git a/illumos-x86_64/usr/include/stdlib.h b/illumos-x86_64/usr/include/stdlib.h new file mode 100644 index 00000000..0b9c12fc --- /dev/null +++ b/illumos-x86_64/usr/include/stdlib.h @@ -0,0 +1,361 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 2013 Gary Mills + * + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2025 Oxide Computer Company + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _STDLIB_H +#define _STDLIB_H + +#include +#include +#include + +#if defined(__EXTENSIONS__) || defined(_XPG4) +#include +#endif + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::div_t; +using std::ldiv_t; +using std::size_t; +using std::abort; +using std::abs; +using std::atexit; +using std::atof; +using std::atoi; +using std::atol; +using std::bsearch; +using std::calloc; +using std::div; +using std::exit; +using std::free; +using std::getenv; +using std::labs; +using std::ldiv; +using std::malloc; +using std::mblen; +using std::mbstowcs; +using std::mbtowc; +using std::qsort; +using std::rand; +using std::realloc; +using std::srand; +using std::strtod; +using std::strtol; +using std::strtoul; +using std::system; +using std::wcstombs; +using std::wctomb; +#endif + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 201103L +using std::at_quick_exit; +using std::quick_exit; +#endif +#if __cplusplus >= 201703L +using std::aligned_alloc; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _UID_T +#define _UID_T +typedef unsigned int uid_t; /* UID type */ +#endif /* !_UID_T */ + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname mkstemp mkstemp64 +#pragma redefine_extname mkstemps mkstemps64 +#pragma redefine_extname mkostemp mkostemp64 +#pragma redefine_extname mkostemps mkostemps64 +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define mkstemp mkstemp64 +#define mkstemps mkstemps64 +#define mkostemp mkostemp64 +#define mkostemps mkostemps64 +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#endif /* _FILE_OFFSET_BITS == 64 */ + +/* In the LP64 compilation environment, all APIs are already large file */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname mkstemp64 mkstemp +#pragma redefine_extname mkstemps64 mkstemps +#pragma redefine_extname mkostemp64 mkostemp +#pragma redefine_extname mkostemps64 mkostemps +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define mkstemp64 mkstemp +#define mkstemps64 mkstemps +#define mkostemp64 mkostemp +#define mkostemps64 mkostemps +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT) +extern int rand_r(unsigned int *); +#endif + +extern void _exithandle(void); + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \ + defined(_XPG4) +extern double drand48(void); +extern double erand48(unsigned short *); +extern long jrand48(unsigned short *); +extern void lcong48(unsigned short *); +extern long lrand48(void); +extern long mrand48(void); +extern long nrand48(unsigned short *); +extern unsigned short *seed48(unsigned short *); +extern void srand48(long); +extern int putenv(char *); +extern void setkey(const char *); +#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */ + +/* + * swab() has historically been in as delivered from AT&T + * and continues to be visible in the default compilation environment. + * As of Issue 4 of the X/Open Portability Guides, swab() was declared + * in . As a result, with respect to X/Open namespace the + * swab() declaration in this header is only visible for the XPG3 + * environment. + */ +#if (defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC__) && !defined(_POSIX_C_SOURCE))) && \ + (!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4))) +#ifndef _SSIZE_T +#define _SSIZE_T +#if defined(_LP64) +typedef long ssize_t; /* size of something in bytes or -1 */ +#else +typedef int ssize_t; /* (historical version) */ +#endif +#endif /* !_SSIZE_T */ + +extern void swab(const char *, char *, ssize_t); +#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */ + +#if defined(__EXTENSIONS__) || \ + !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ + (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) +extern int mkstemp(char *); +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int mkstemps(char *, int); +#endif +#endif /* defined(__EXTENSIONS__) ... */ + +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int mkstemp64(char *); +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int mkstemps64(char *, int); +#endif +#endif /* _LARGEFILE64_SOURCE... */ + +#if !defined(_STRICT_SYMBOLS) || defined(_XPG7) +extern char *mkdtemp(char *); +#endif /* !_STRICT_SYMBOLS || _XPG7 */ + +#if !defined(_STRICT_SYMBOLS) || defined(_XPG8) +extern int mkostemp(char *, int); +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int mkostemp64(char *, int); +#endif /* _LARGEFILE64_SOURCE || !((_FILE_OFFSET_BITS == 64) ... */ +#endif /* !_STRICT_SYMBOLS || _XPG8 */ + +#if !defined(_STRICT_SYMBOLS) +extern int mkostemps(char *, int, int); +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int mkostemps64(char *, int, int); +#endif /* _LARGEFILE64_SOURCE || !((_FILE_OFFSET_BITS == 64) ... */ +#endif /* !_STRICT_SYMBOLS */ + + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG4_2) +extern long a64l(const char *); +extern char *ecvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern char *fcvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern char *gcvt(double, int, char *); +extern int getsubopt(char **, char *const *, char **); +extern int grantpt(int); +extern char *initstate(unsigned, char *, size_t); +extern char *l64a(long); +extern char *mktemp(char *); +extern char *ptsname(int); +extern long random(void); +extern char *realpath(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD); +extern char *setstate(const char *); +extern void srandom(unsigned); +extern int unlockpt(int); +/* Marked LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +extern int ttyslot(void); +extern void *valloc(size_t); +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ +#endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG6) +extern int posix_memalign(void **, size_t, size_t); +extern int posix_openpt(int); +extern int setenv(const char *, const char *, int); +extern int unsetenv(const char *); +#endif + +/* + * In strict XPG4v2 mode, slave pseudo terminal devices behave differently. + * See the block comment in usr/src/lib/libc/port/gen/pt.c + */ +#if defined(_STRICT_SYMBOLS) && defined(_XPG4_2) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname unlockpt __unlockpt_xpg4 +#else +extern int __unlockpt_xpg4(int); +#define unlockpt __unlockpt_xpg4 +#endif +#endif /* defined(_STRICT_SYMBOLS) && defined(_XPG4_2) */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +extern char *canonicalize_file_name(const char *); +extern int clearenv(void); +extern void closefrom(int); +extern int daemon(int, int); +extern int dup2(int, int); +extern int dup3(int, int, int); +extern int fdwalk(int (*)(void *, int), void *); +extern char *qecvt(long double, int, int *, int *); +extern char *qfcvt(long double, int, int *, int *); +extern char *qgcvt(long double, int, char *); +extern char *getcwd(char *, size_t); +extern const char *getexecname(void); + +#ifndef __GETLOGIN_DEFINED /* Avoid duplicate in unistd.h */ +#define __GETLOGIN_DEFINED +#ifndef __USE_LEGACY_LOGNAME__ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getlogin getloginx +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern char *getloginx(void); +#define getlogin getloginx +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* __USE_LEGACY_LOGNAME__ */ +extern char *getlogin(void); +#endif /* __GETLOGIN_DEFINED */ + +extern int getopt(int, char *const *, const char *); +extern char *optarg; +extern int optind, opterr, optopt; +extern char *getpass(const char *); +extern char *getpassphrase(const char *); +extern int getpw(uid_t, char *); +extern int isatty(int); +extern void *memalign(size_t, size_t); +extern char *ttyname(int); +extern char *mkdtemp(char *); +extern const char *getprogname(void); +extern void setprogname(const char *); + +#if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) +extern char *lltostr(long long, char *); +extern char *ulltostr(unsigned long long, char *); +#endif /* !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) */ + +#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */ + +/* OpenBSD and misc. compatibility functions */ +#if !defined(_STRICT_SYMBOLS) + +#include +extern uint32_t arc4random(void); +extern void arc4random_buf(void *, size_t); +extern uint32_t arc4random_uniform(uint32_t); +extern void freezero(void *, size_t); +extern void *recallocarray(void *, size_t, size_t, size_t); +extern long long strtonum(const char *, long long, long long, const char **); +extern long long strtonumx(const char *, long long, long long, const char **, + int); +extern void *reallocf(void *, size_t); + +/* these three are also in xlocale.h */ +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif +extern float strtof_l(const char *, char **, locale_t); +extern double strtod_l(const char *, char **, locale_t); +extern long double strtold_l(const char *, char **, locale_t); +#endif /* !_STRICT_SYBMOLS */ + +/* + * POSIX 2024 functions. + */ +#if !defined(_STRICT_SYMBOLS) || defined(_XPG8) +extern int ptsname_r(int, char *, size_t); +extern void qsort_r(void *, size_t, size_t, + int (*)(const void *, const void *, void *), void *); +extern void *reallocarray(void *, size_t, size_t); +extern char *secure_getenv(const char *); +#endif /* !_STRICT_SYMBOLS || _XPG8 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STDLIB_H */ diff --git a/illumos-x86_64/usr/include/stdnoreturn.h b/illumos-x86_64/usr/include/stdnoreturn.h new file mode 100644 index 00000000..429cb0f0 --- /dev/null +++ b/illumos-x86_64/usr/include/stdnoreturn.h @@ -0,0 +1,38 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _STDNORETURN_H +#define _STDNORETURN_H + +/* + * ISO/IEC C11 stdnoreturn.h + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11) + +#define noreturn _Noreturn + +#endif /* !_STRICT_SYMBOLS || _STDC_C11 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STDNORETURN_H */ diff --git a/illumos-x86_64/usr/include/storclass.h b/illumos-x86_64/usr/include/storclass.h new file mode 100644 index 00000000..09561dbc --- /dev/null +++ b/illumos-x86_64/usr/include/storclass.h @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _STORCLASS_H +#define _STORCLASS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * STORAGE CLASSES + */ + +#define C_EFCN -1 /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ + +/* + * The following storage class is a "dummy" used only by STS + * for line number entries reformatted as symbol table entries + */ + +#define C_LINE 104 +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* special storage class for external */ + /* symbols in dmert public libraries */ +#define C_SHADOW 107 /* shadow symbol */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STORCLASS_H */ diff --git a/illumos-x86_64/usr/include/string.h b/illumos-x86_64/usr/include/string.h new file mode 100644 index 00000000..b3596292 --- /dev/null +++ b/illumos-x86_64/usr/include/string.h @@ -0,0 +1,199 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 Joyent, Inc. + * Copyright 2024 Oxide Computer company + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _STRING_H +#define _STRING_H + +#include + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::size_t; +using std::memchr; +using std::memcmp; +using std::memcpy; +using std::memmove; +using std::memset; +using std::strcat; +using std::strchr; +using std::strcmp; +using std::strcoll; +using std::strcpy; +using std::strcspn; +using std::strerror; +using std::strlen; +using std::strncat; +using std::strncmp; +using std::strncpy; +using std::strpbrk; +using std::strrchr; +using std::strspn; +using std::strstr; +using std::strtok; +using std::strxfrm; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG6) || defined(_REENTRANT) +extern int strerror_r(int, char *, size_t); +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT) +extern char *strtok_r(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + char **_RESTRICT_KYWD); +#endif + +#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \ + defined(__XOPEN_OR_POSIX) +extern void *memccpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, + int, size_t); +#endif + +#if !defined(_STRICT_SYMBOLS) || defined(_XPG7) + +extern char *stpcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); +extern char *stpncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t); +extern char *strndup(const char *, size_t); +extern size_t strnlen(const char *, size_t); +extern char *strsignal(int); + +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +extern int strcoll_l(const char *, const char *, locale_t); +extern size_t strxfrm_l(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + size_t, locale_t); +extern int strcasecmp_l(const char *, const char *, locale_t); +extern int strncasecmp_l(const char *, const char *, size_t, locale_t); +extern char *strerror_l(int, locale_t); + +#endif /* defined(_STRICT_SYMBOLS) || defined(_XPG7) */ + +#if !defined(_STRICT_SYMBOLS) + +/* Note that some of these are also declared in strings.h for XPG4_2+ */ +extern void explicit_bzero(void *, size_t); +extern int uucopy(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t); +extern int uucopystr(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t); +extern int ffs(int); +extern int ffsl(long); +extern int ffsll(long long); +extern int fls(int); +extern int flsl(long); +extern int flsll(long long); +extern void *memmem(const void *, size_t, const void *, size_t); +extern void *memrchr(const void *, int, size_t); +extern char *strcasestr(const char *, const char *); +extern char *strnstr(const char *, const char *, size_t); +extern size_t strlcpy(char *, const char *, size_t); +extern size_t strlcat(char *, const char *, size_t); +extern char *strsep(char **stringp, const char *delim); +extern char *strchrnul(const char *, int); +extern char *strcasestr_l(const char *, const char *, locale_t); +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, size_t); +extern const char *strerrorname_np(int); +extern const char *strerrordesc_np(int); +#endif /* !defined(__STRICT_SYMBOLS) */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG4_2) +extern char *strdup(const char *); +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + +#if defined(__GNUC__) + +#define strdupa(s) \ + (__extension__( \ + { \ + char *__str = (char *)(s); \ + (__str = strcpy((char *)__builtin_alloca(strlen(__str) + 1), \ + __str), __str); \ + })) + +#define strndupa(s, n) \ + (__extension__( \ + { \ + char *__str = (char *)(s); \ + size_t __len = strnlen(__str, (n)); \ + (__str = strncpy((char *)__builtin_alloca(__len + 1), \ + __str, __len), \ + __str[__len] = '\0', __str); \ + })) + +#else /* __GNUC__ */ + +#if defined(unix) /* excludes c99 */ +/* + * Studio C currently can't do the gcc-style inlining, + * so we use thread-local storage instead. + */ +extern void *__builtin_alloca(size_t); +extern __thread char *__strdupa_str; +extern __thread size_t __strdupa_len; + +#define strdupa(s) \ + (__strdupa_str = (char *)(s), \ + strcpy((char *)__builtin_alloca(strlen(__strdupa_str) + 1), \ + __strdupa_str)) + +#define strndupa(s, n) \ + (__strdupa_str = (char *)(s), \ + __strdupa_len = strnlen(__strdupa_str, (n)), \ + __strdupa_str = strncpy((char *)__builtin_alloca(__strdupa_len + 1), \ + __strdupa_str, __strdupa_len), \ + __strdupa_str[__strdupa_len] = '\0', __strdupa_str) +#endif /* unix */ + +#endif /* __GNUC__ */ +#endif /* __EXTENSIONS__ ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STRING_H */ diff --git a/illumos-x86_64/usr/include/stringprep.h b/illumos-x86_64/usr/include/stringprep.h new file mode 100644 index 00000000..9ef15d4d --- /dev/null +++ b/illumos-x86_64/usr/include/stringprep.h @@ -0,0 +1,298 @@ +/* stringprep.h --- Header file for stringprep functions. + Copyright (C) 2002-2025 Simon Josefsson + + This file is part of GNU Libidn. + + GNU Libidn is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version. + + or both in parallel, as here. + + GNU Libidn is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see . */ + +#ifndef STRINGPREP_H +# define STRINGPREP_H + +/** + * SECTION:stringprep + * @title: stringprep.h + * @short_description: Stringprep-related functions + * + * Stringprep-related functions. + */ + +# ifndef IDNAPI +# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY +# define IDNAPI __attribute__((__visibility__("default"))) +# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllexport) +# elif defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllimport) +# else +# define IDNAPI +# endif +# endif + +# include /* size_t */ +# include /* ssize_t */ +# include /* uint32_t */ + +# ifdef __cplusplus +extern "C" +{ +# endif + +# define STRINGPREP_VERSION "1.43" + +/* Error codes. */ + typedef enum + { + STRINGPREP_OK = 0, + /* Stringprep errors. */ + STRINGPREP_CONTAINS_UNASSIGNED = 1, + STRINGPREP_CONTAINS_PROHIBITED = 2, + STRINGPREP_BIDI_BOTH_L_AND_RAL = 3, + STRINGPREP_BIDI_LEADTRAIL_NOT_RAL = 4, + STRINGPREP_BIDI_CONTAINS_PROHIBITED = 5, + /* Error in calling application. */ + STRINGPREP_TOO_SMALL_BUFFER = 100, + STRINGPREP_PROFILE_ERROR = 101, + STRINGPREP_FLAG_ERROR = 102, + STRINGPREP_UNKNOWN_PROFILE = 103, + STRINGPREP_ICONV_ERROR = 104, + /* Internal errors. */ + STRINGPREP_NFKC_FAILED = 200, + STRINGPREP_MALLOC_ERROR = 201 + } Stringprep_rc; + +/* Flags used when calling stringprep(). */ + typedef enum + { + STRINGPREP_NO_NFKC = 1, + STRINGPREP_NO_BIDI = 2, + STRINGPREP_NO_UNASSIGNED = 4 + } Stringprep_profile_flags; + +/* Steps in a stringprep profile. */ + typedef enum + { + STRINGPREP_NFKC = 1, + STRINGPREP_BIDI = 2, + STRINGPREP_MAP_TABLE = 3, + STRINGPREP_UNASSIGNED_TABLE = 4, + STRINGPREP_PROHIBIT_TABLE = 5, + STRINGPREP_BIDI_PROHIBIT_TABLE = 6, + STRINGPREP_BIDI_RAL_TABLE = 7, + STRINGPREP_BIDI_L_TABLE = 8 + } Stringprep_profile_steps; + +# define STRINGPREP_MAX_MAP_CHARS 4 + + /* *INDENT-OFF* */ + + /* Why INDENT-OFF? GTK-DOC has a bug + * which causes + * parsing of structs to fail unless the terminating } is at the + * beginning of the line. We hard-code the header file to be like + * that, and add the INDENT-OFF markers so that indent won't restore + * them. When that bug is fixed, remove the INDENT-* marker, run + * 'make indent', and make sure that + * doc/reference/libidn-decl-list.txt stay the same. + * + * Of course, exposing these struct's in the public header file in + * the first place was a mistake. + */ + + /** + * Stringprep_table_element: + * @start: starting codepoint. + * @end: ending codepoint, 0 if only one character. + * @map: codepoints to map @start into, NULL if end is not 0. + * + * Stringprep profile table element. + */ + struct Stringprep_table_element + { + uint32_t start; + uint32_t end; + uint32_t map[STRINGPREP_MAX_MAP_CHARS]; +}; + typedef struct Stringprep_table_element Stringprep_table_element; + + /** + * Stringprep_table: + * @operation: a #Stringprep_profile_steps value + * @flags: a #Stringprep_profile_flags value + * @table: zero-terminated array of %Stringprep_table_element elements. + * @table_size: size of @table, to speed up searching. + * + * Stringprep profile table. + */ + struct Stringprep_table + { + Stringprep_profile_steps operation; + Stringprep_profile_flags flags; + const Stringprep_table_element *table; + size_t table_size; +}; + /** + * Stringprep_profile: + * + * Stringprep profile table. + */ + typedef struct Stringprep_table Stringprep_profile; + + /** + * Stringprep_profiles: + * @name: name of stringprep profile. + * @tables: zero-terminated array of %Stringprep_profile elements. + * + * Element structure + */ + struct Stringprep_profiles + { + const char *name; + const Stringprep_profile *tables; +}; + typedef struct Stringprep_profiles Stringprep_profiles; + /* *INDENT-ON* */ + + extern IDNAPI const Stringprep_profiles stringprep_profiles[]; + +/* Profiles */ + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_A_1[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_B_1[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_B_2[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_B_3[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_1_1[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_1_2[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_2_1[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_2_2[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_3[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_4[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_5[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_6[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_7[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_8[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_C_9[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_D_1[]; + extern IDNAPI const Stringprep_table_element stringprep_rfc3454_D_2[]; + + /* Nameprep */ + + extern IDNAPI const Stringprep_profile stringprep_nameprep[]; + +# define stringprep_nameprep(in, maxlen) \ + stringprep(in, maxlen, 0, stringprep_nameprep) + +# define stringprep_nameprep_no_unassigned(in, maxlen) \ + stringprep(in, maxlen, STRINGPREP_NO_UNASSIGNED, stringprep_nameprep) + + /* SASL */ + + extern IDNAPI const Stringprep_profile stringprep_saslprep[]; + extern IDNAPI const Stringprep_table_element + stringprep_saslprep_space_map[]; + extern IDNAPI const Stringprep_profile stringprep_plain[]; + extern IDNAPI const Stringprep_profile stringprep_trace[]; + +# define stringprep_plain(in, maxlen) \ + stringprep(in, maxlen, 0, stringprep_plain) + + /* Kerberos */ + + extern IDNAPI const Stringprep_profile stringprep_kerberos5[]; + +# define stringprep_kerberos5(in, maxlen) \ + stringprep(in, maxlen, 0, stringprep_kerberos5) + + /* XMPP */ + + extern IDNAPI const Stringprep_profile stringprep_xmpp_nodeprep[]; + extern IDNAPI const Stringprep_profile stringprep_xmpp_resourceprep[]; + extern IDNAPI const Stringprep_table_element + stringprep_xmpp_nodeprep_prohibit[]; + +# define stringprep_xmpp_nodeprep(in, maxlen) \ + stringprep(in, maxlen, 0, stringprep_xmpp_nodeprep) +# define stringprep_xmpp_resourceprep(in, maxlen) \ + stringprep(in, maxlen, 0, stringprep_xmpp_resourceprep) + + /* iSCSI */ + + extern IDNAPI const Stringprep_profile stringprep_iscsi[]; + extern IDNAPI const Stringprep_table_element stringprep_iscsi_prohibit[]; + +# define stringprep_iscsi(in, maxlen) \ + stringprep(in, maxlen, 0, stringprep_iscsi) + + /* API */ + + extern IDNAPI int stringprep_4i (uint32_t * ucs4, size_t *len, + size_t maxucs4len, + Stringprep_profile_flags flags, + const Stringprep_profile * profile); + extern IDNAPI int stringprep_4zi (uint32_t * ucs4, size_t maxucs4len, + Stringprep_profile_flags flags, + const Stringprep_profile * profile); + extern IDNAPI int stringprep (char *in, size_t maxlen, + Stringprep_profile_flags flags, + const Stringprep_profile * profile); + + extern IDNAPI int stringprep_profile (const char *in, + char **out, + const char *profile, + Stringprep_profile_flags flags); + + extern IDNAPI const char *stringprep_strerror (Stringprep_rc rc); + + extern IDNAPI const char *stringprep_check_version (const char + *req_version); + +/* Utility */ + + extern IDNAPI int stringprep_unichar_to_utf8 (uint32_t c, char *outbuf); + extern IDNAPI uint32_t stringprep_utf8_to_unichar (const char *p); + + extern IDNAPI uint32_t *stringprep_utf8_to_ucs4 (const char *str, + ssize_t len, + size_t *items_written); + extern IDNAPI char *stringprep_ucs4_to_utf8 (const uint32_t * str, + ssize_t len, + size_t *items_read, + size_t *items_written); + + extern IDNAPI char *stringprep_utf8_nfkc_normalize (const char *str, + ssize_t len); + extern IDNAPI uint32_t *stringprep_ucs4_nfkc_normalize (const uint32_t * + str, ssize_t len); + + extern IDNAPI const char *stringprep_locale_charset (void); + extern IDNAPI char *stringprep_convert (const char *str, + const char *to_codeset, + const char *from_codeset); + extern IDNAPI char *stringprep_locale_to_utf8 (const char *str); + extern IDNAPI char *stringprep_utf8_to_locale (const char *str); + +# ifdef __cplusplus +} +# endif + +#endif /* STRINGPREP_H */ diff --git a/illumos-x86_64/usr/include/strings.h b/illumos-x86_64/usr/include/strings.h new file mode 100644 index 00000000..2d3cd9b2 --- /dev/null +++ b/illumos-x86_64/usr/include/strings.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1995, 1996, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _STRINGS_H +#define _STRINGS_H + +#include +#include + +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern int bcmp(const void *, const void *, size_t); +extern void bcopy(const void *, void *, size_t); +extern void bzero(void *, size_t); + +extern char *index(const char *, int); +extern char *rindex(const char *, int); + +/* + * X/Open System Interfaces and Headers, Issue 4, Version 2, defines + * both and . The namespace requirements + * do not permit the visibility of anything other than what is + * specifically defined for each of these headers. As a result, + * inclusion of would result in declarations not allowed + * in , and making the following prototypes visible for + * anything other than X/Open UNIX Extension would result in + * conflicts with what is now in . + */ +#if defined(_XPG4_2) && !defined(__EXTENSIONS__) +extern int ffs(int); +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, size_t); +#if defined(_XPG7) +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif +extern int strcasecmp_l(const char *, const char *, locale_t); +extern int strncasecmp_l(const char *, const char *, size_t, locale_t); +#endif /* defined(_XPG7) */ +#endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STRINGS_H */ diff --git a/illumos-x86_64/usr/include/stropts.h b/illumos-x86_64/usr/include/stropts.h new file mode 100644 index 00000000..9d3e6e6a --- /dev/null +++ b/illumos-x86_64/usr/include/stropts.h @@ -0,0 +1,70 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _STROPTS_H +#define _STROPTS_H + +/* + * Streams user options definitions. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int isastream(int); + +extern int getmsg(int, struct strbuf *_RESTRICT_KYWD, + struct strbuf *_RESTRICT_KYWD, int *_RESTRICT_KYWD); +extern int putmsg(int, const struct strbuf *, const struct strbuf *, int); + +extern int getpmsg(int, struct strbuf *_RESTRICT_KYWD, + struct strbuf *_RESTRICT_KYWD, int *_RESTRICT_KYWD, + int *_RESTRICT_KYWD); +extern int putpmsg(int, const struct strbuf *, const struct strbuf *, int, int); + +/* + * These three routines are duplicated in unistd.h; duplication necessitated + * by XPG4.2 compliance/namespace issues. ioctl() is also duplicated in + * for broader portability aid. + */ +extern int ioctl(int, int, ...); +extern int fattach(int, const char *); +extern int fdetach(const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _STROPTS_H */ diff --git a/illumos-x86_64/usr/include/sudo_plugin.h b/illumos-x86_64/usr/include/sudo_plugin.h new file mode 100644 index 00000000..24a20d19 --- /dev/null +++ b/illumos-x86_64/usr/include/sudo_plugin.h @@ -0,0 +1,292 @@ +/* + * SPDX-License-Identifier: ISC + * + * Copyright (c) 2009-2023 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef SUDO_PLUGIN_H +#define SUDO_PLUGIN_H + +/* API version major/minor */ +#define SUDO_API_VERSION_MAJOR 1 +#define SUDO_API_VERSION_MINOR 22 +#define SUDO_API_MKVERSION(x, y) (((x) << 16) | (y)) +#define SUDO_API_VERSION SUDO_API_MKVERSION(SUDO_API_VERSION_MAJOR, SUDO_API_VERSION_MINOR) + +/* Getters and setters for plugin API versions */ +#define SUDO_API_VERSION_GET_MAJOR(v) ((v) >> 16) +#define SUDO_API_VERSION_GET_MINOR(v) ((v) & 0xffffU) +#define SUDO_API_VERSION_SET_MAJOR(vp, n) do { \ + *(vp) = (*(vp) & 0x0000ffffU) | ((n) << 16); \ +} while(0) +#define SUDO_API_VERSION_SET_MINOR(vp, n) do { \ + *(vp) = (*(vp) & 0xffff0000U) | (n); \ +} while(0) + +/* "plugin type" for the sudo front end, as passed to an audit plugin */ +#define SUDO_FRONT_END 0 + +/* Conversation function types and defines */ +struct sudo_conv_message { +#define SUDO_CONV_PROMPT_ECHO_OFF 0x0001 /* do not echo user input */ +#define SUDO_CONV_PROMPT_ECHO_ON 0x0002 /* echo user input */ +#define SUDO_CONV_ERROR_MSG 0x0003 /* error message */ +#define SUDO_CONV_INFO_MSG 0x0004 /* informational message */ +#define SUDO_CONV_PROMPT_MASK 0x0005 /* mask user input */ +#define SUDO_CONV_PROMPT_ECHO_OK 0x1000 /* flag: allow echo if no tty */ +#define SUDO_CONV_PREFER_TTY 0x2000 /* flag: use tty if possible */ + int msg_type; + int timeout; + const char *msg; +}; + +/* + * Maximum length of a reply (not including the trailing NUL) when + * conversing with the user. In practical terms, this is the longest + * password sudo will support. This means that a buffer of size + * SUDO_CONV_REPL_MAX+1 is guaranteed to be able to hold any reply + * from the conversation function. + */ +#define SUDO_CONV_REPL_MAX 1023 + +struct sudo_conv_reply { + char *reply; +}; + +/* Conversation callback API version major/minor */ +#define SUDO_CONV_CALLBACK_VERSION_MAJOR 1 +#define SUDO_CONV_CALLBACK_VERSION_MINOR 0 +#define SUDO_CONV_CALLBACK_VERSION SUDO_API_MKVERSION(SUDO_CONV_CALLBACK_VERSION_MAJOR, SUDO_CONV_CALLBACK_VERSION_MINOR) + +/* + * Callback struct to be passed to the conversation function. + * Can be used to perform operations on suspend/resume such + * as dropping/acquiring locks. + */ +typedef int (*sudo_conv_callback_fn_t)(int signo, void *closure); +struct sudo_conv_callback { + unsigned int version; + void *closure; + sudo_conv_callback_fn_t on_suspend; + sudo_conv_callback_fn_t on_resume; +}; + +typedef int (*sudo_conv_t)(int num_msgs, const struct sudo_conv_message msgs[], + struct sudo_conv_reply replies[], struct sudo_conv_callback *callback); +typedef int (*sudo_printf_t)(int msg_type, const char * restrict fmt, ...); + +/* + * Hooks allow a plugin to hook into specific sudo and/or libc functions. + */ + +#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || __GNUC__ > 4) +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif + +/* Hook functions typedefs. */ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +typedef int (*sudo_hook_fn_t)(...); +#else +typedef int (*sudo_hook_fn_t)(); +#endif +typedef int (*sudo_hook_fn_setenv_t)(const char *name, const char *value, int overwrite, void *closure); +typedef int (*sudo_hook_fn_putenv_t)(char *string, void *closure); +typedef int (*sudo_hook_fn_getenv_t)(const char *name, char **value, void *closure); +typedef int (*sudo_hook_fn_unsetenv_t)(const char *name, void *closure); + +/* Hook structure definition. */ +struct sudo_hook { + unsigned int hook_version; + unsigned int hook_type; + sudo_hook_fn_t hook_fn; + void *closure; +}; + +/* Hook API version major/minor */ +#define SUDO_HOOK_VERSION_MAJOR 1 +#define SUDO_HOOK_VERSION_MINOR 0 +#define SUDO_HOOK_VERSION SUDO_API_MKVERSION(SUDO_HOOK_VERSION_MAJOR, SUDO_HOOK_VERSION_MINOR) + +/* + * Hook function return values. + */ +#define SUDO_HOOK_RET_ERROR -1 /* error */ +#define SUDO_HOOK_RET_NEXT 0 /* go to the next hook in the list */ +#define SUDO_HOOK_RET_STOP 1 /* stop hook processing for this type */ + +/* + * Hooks for setenv/unsetenv/putenv/getenv. + * This allows the plugin to be notified when a PAM module modifies + * the environment so it can update the copy of the environment that + * is passed to execve(). + */ +#define SUDO_HOOK_SETENV 1 +#define SUDO_HOOK_UNSETENV 2 +#define SUDO_HOOK_PUTENV 3 +#define SUDO_HOOK_GETENV 4 + +/* + * Plugin interface to sudo's main event loop. + */ +typedef void (*sudo_plugin_ev_callback_t)(int fd, int what, void *closure); + +struct timespec; +struct sudo_plugin_event { + int (*set)(struct sudo_plugin_event *pev, int fd, int events, sudo_plugin_ev_callback_t callback, void *closure); + int (*add)(struct sudo_plugin_event *pev, struct timespec *timeout); + int (*del)(struct sudo_plugin_event *pev); + int (*pending)(struct sudo_plugin_event *pev, int events, struct timespec *ts); + int (*fd)(struct sudo_plugin_event *pev); + void (*setbase)(struct sudo_plugin_event *pev, void *base); + void (*loopbreak)(struct sudo_plugin_event *pev); + void (*free)(struct sudo_plugin_event *pev); + /* actually larger... */ +}; + +/* Sudo plugin Event types */ +#define SUDO_PLUGIN_EV_TIMEOUT 0x01 /* fire after timeout */ +#define SUDO_PLUGIN_EV_READ 0x02 /* fire when readable */ +#define SUDO_PLUGIN_EV_WRITE 0x04 /* fire when writable */ +#define SUDO_PLUGIN_EV_PERSIST 0x08 /* persist until deleted */ +#define SUDO_PLUGIN_EV_SIGNAL 0x10 /* fire on signal receipt */ + +/* Policy plugin type and defines. */ +struct passwd; +struct policy_plugin { +#define SUDO_POLICY_PLUGIN 1 + unsigned int type; /* always SUDO_POLICY_PLUGIN */ + unsigned int version; /* always SUDO_API_VERSION */ + int (*open)(unsigned int version, sudo_conv_t conversation, + sudo_printf_t sudo_plugin_printf, char * const settings[], + char * const user_info[], char * const user_env[], + char * const plugin_options[], const char **errstr); + void (*close)(int exit_status, int error); /* wait status or error */ + int (*show_version)(int verbose); + int (*check_policy)(int argc, char * const argv[], + char *env_add[], char **command_info[], + char **argv_out[], char **user_env_out[], const char **errstr); + int (*list)(int argc, char * const argv[], int verbose, + const char *user, const char **errstr); + int (*validate)(const char **errstr); + void (*invalidate)(int rmcred); + int (*init_session)(struct passwd *pwd, char **user_env_out[], + const char **errstr); + void (*register_hooks)(int version, int (*register_hook)(struct sudo_hook *hook)); + void (*deregister_hooks)(int version, int (*deregister_hook)(struct sudo_hook *hook)); + struct sudo_plugin_event * (*event_alloc)(void); +}; + +/* I/O plugin type and defines. */ +struct io_plugin { +#define SUDO_IO_PLUGIN 2 + unsigned int type; /* always SUDO_IO_PLUGIN */ + unsigned int version; /* always SUDO_API_VERSION */ + int (*open)(unsigned int version, sudo_conv_t conversation, + sudo_printf_t sudo_plugin_printf, char * const settings[], + char * const user_info[], char * const command_info[], + int argc, char * const argv[], char * const user_env[], + char * const plugin_options[], const char **errstr); + void (*close)(int exit_status, int error); /* wait status or error */ + int (*show_version)(int verbose); + int (*log_ttyin)(const char *buf, unsigned int len, const char **errstr); + int (*log_ttyout)(const char *buf, unsigned int len, const char **errstr); + int (*log_stdin)(const char *buf, unsigned int len, const char **errstr); + int (*log_stdout)(const char *buf, unsigned int len, const char **errstr); + int (*log_stderr)(const char *buf, unsigned int len, const char **errstr); + void (*register_hooks)(int version, + int (*register_hook)(struct sudo_hook *hook)); + void (*deregister_hooks)(int version, + int (*deregister_hook)(struct sudo_hook *hook)); + int (*change_winsize)(unsigned int line, unsigned int cols, + const char **errstr); + int (*log_suspend)(int signo, const char **errstr); + struct sudo_plugin_event * (*event_alloc)(void); +}; + +/* Differ audit plugin close status types. */ +#define SUDO_PLUGIN_NO_STATUS 0 +#define SUDO_PLUGIN_WAIT_STATUS 1 +#define SUDO_PLUGIN_EXEC_ERROR 2 +#define SUDO_PLUGIN_SUDO_ERROR 3 + +/* Audit plugin type and defines */ +struct audit_plugin { +#define SUDO_AUDIT_PLUGIN 3 + unsigned int type; /* always SUDO_AUDIT_PLUGIN */ + unsigned int version; /* always SUDO_API_VERSION */ + int (*open)(unsigned int version, sudo_conv_t conversation, + sudo_printf_t sudo_plugin_printf, char * const settings[], + char * const user_info[], int submit_optind, + char * const submit_argv[], char * const submit_envp[], + char * const plugin_options[], const char **errstr); + void (*close)(int status_type, int status); + int (*accept)(const char *plugin_name, unsigned int plugin_type, + char * const command_info[], char * const run_argv[], + char * const run_envp[], const char **errstr); + int (*reject)(const char *plugin_name, unsigned int plugin_type, + const char *audit_msg, char * const command_info[], + const char **errstr); + int (*error)(const char *plugin_name, unsigned int plugin_type, + const char *audit_msg, char * const command_info[], + const char **errstr); + int (*show_version)(int verbose); + void (*register_hooks)(int version, int (*register_hook)(struct sudo_hook *hook)); + void (*deregister_hooks)(int version, int (*deregister_hook)(struct sudo_hook *hook)); + struct sudo_plugin_event * (*event_alloc)(void); +}; + +/* Approval plugin type and defines */ +struct approval_plugin { +#define SUDO_APPROVAL_PLUGIN 4 + unsigned int type; /* always SUDO_APPROVAL_PLUGIN */ + unsigned int version; /* always SUDO_API_VERSION */ + int (*open)(unsigned int version, sudo_conv_t conversation, + sudo_printf_t sudo_plugin_printf, char * const settings[], + char * const user_info[], int submit_optind, + char * const submit_argv[], char * const submit_envp[], + char * const plugin_options[], const char **errstr); + void (*close)(void); + int (*check)(char * const command_info[], char * const run_argv[], + char * const run_envp[], const char **errstr); + int (*show_version)(int verbose); +}; + +/* Sudoers group plugin version major/minor */ +#define GROUP_API_VERSION_MAJOR 1 +#define GROUP_API_VERSION_MINOR 0 +#define GROUP_API_VERSION SUDO_API_MKVERSION(GROUP_API_VERSION_MAJOR, GROUP_API_VERSION_MINOR) + +/* Getters and setters for group version (for source compat only) */ +#define GROUP_API_VERSION_GET_MAJOR(v) SUDO_API_VERSION_GET_MAJOR(v) +#define GROUP_API_VERSION_GET_MINOR(v) SUDO_API_VERSION_GET_MINOR(v) +#define GROUP_API_VERSION_SET_MAJOR(vp, n) SUDO_API_VERSION_SET_MAJOR(vp, n) +#define GROUP_API_VERSION_SET_MINOR(vp, n) SUDO_API_VERSION_SET_MINOR(vp, n) + +/* + * version: for compatibility checking + * group_init: return 1 on success, 0 if unconfigured, -1 on error. + * group_cleanup: called to clean up resources used by provider + * user_in_group: returns 1 if user is in group, 0 if not. + * note that pwd may be NULL if the user is not in passwd. + */ +struct sudoers_group_plugin { + unsigned int version; + int (*init)(int version, sudo_printf_t sudo_plugin_printf, + char *const argv[]); + void (*cleanup)(void); + int (*query)(const char *user, const char *group, const struct passwd *pwd); +}; + +#endif /* SUDO_PLUGIN_H */ diff --git a/illumos-x86_64/usr/include/symcat.h b/illumos-x86_64/usr/include/symcat.h new file mode 100644 index 00000000..c0dd11b8 --- /dev/null +++ b/illumos-x86_64/usr/include/symcat.h @@ -0,0 +1,55 @@ +/* Symbol concatenation utilities. + + Copyright (C) 1998-2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef SYM_CAT_H +#define SYM_CAT_H + +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define CONCAT2(a,b) a##b +#define CONCAT3(a,b,c) a##b##c +#define CONCAT4(a,b,c,d) a##b##c##d +#define CONCAT5(a,b,c,d,e) a##b##c##d##e +#define CONCAT6(a,b,c,d,e,f) a##b##c##d##e##f +#define STRINGX(s) #s +#else +/* Note one should never pass extra whitespace to the CONCATn macros, + e.g. CONCAT2(foo, bar) because traditonal C will keep the space between + the two labels instead of concatenating them. Instead, make sure to + write CONCAT2(foo,bar). */ +#define CONCAT2(a,b) a/**/b +#define CONCAT3(a,b,c) a/**/b/**/c +#define CONCAT4(a,b,c,d) a/**/b/**/c/**/d +#define CONCAT5(a,b,c,d,e) a/**/b/**/c/**/d/**/e +#define CONCAT6(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f +#define STRINGX(s) "s" +#endif + +#define XCONCAT2(a,b) CONCAT2(a,b) +#define XCONCAT3(a,b,c) CONCAT3(a,b,c) +#define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d) +#define XCONCAT5(a,b,c,d,e) CONCAT5(a,b,c,d,e) +#define XCONCAT6(a,b,c,d,e,f) CONCAT6(a,b,c,d,e,f) + +/* Note the layer of indirection here is typically used to allow + stringification of the expansion of macros. I.e. "#define foo + bar", "XSTRING(foo)", to yield "bar". Be aware that this only + works for __STDC__, not for traditional C which will still resolve + to "foo". */ +#define XSTRING(s) STRINGX(s) + +#endif /* SYM_CAT_H */ diff --git a/illumos-x86_64/usr/include/syms.h b/illumos-x86_64/usr/include/syms.h new file mode 100644 index 00000000..ae1336ad --- /dev/null +++ b/illumos-x86_64/usr/include/syms.h @@ -0,0 +1,228 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYMS_H +#define _SYMS_H + +/* Storage Classes are defined in storclass.h */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Number of characters in a symbol name */ +#define SYMNMLEN 8 +/* Number of characters in a file name */ +#define FILNMLEN 14 +/* Number of array dimensions in auxiliary entry */ +#define DIMNUM 4 + +struct syment +{ + union + { + char _n_name[SYMNMLEN]; /* old COFF version */ + struct + { + long _n_zeroes; /* new == 0 */ + long _n_offset; /* offset into string table */ + } _n_n; + char *_n_nptr[2]; /* allows for overlaying */ + } _n; + unsigned long n_value; /* value of symbol */ + short n_scnum; /* section number */ + unsigned short n_type; /* type and derived type */ + char n_sclass; /* storage class */ + char n_numaux; /* number of aux. entries */ +}; + +#define n_name _n._n_name +#define n_nptr _n._n_nptr[1] +#define n_zeroes _n._n_n._n_zeroes +#define n_offset _n._n_n._n_offset + +/* + * Relocatable symbols have a section number of the + * section in which they are defined. Otherwise, section + * numbers have the following meanings: + */ + /* undefined symbol */ +#define N_UNDEF 0 + /* value of symbol is absolute */ +#define N_ABS -1 + /* special debugging symbol -- value of symbol is meaningless */ +#define N_DEBUG -2 + /* indicates symbol needs transfer vector (preload) */ +#define N_TV (unsigned short)-3 + + /* indicates symbol needs transfer vector (postload) */ + +#define P_TV (unsigned short)-4 + +/* + * The fundamental type of a symbol packed into the low + * 4 bits of the word. + */ + +#define _EF ".ef" + +#define T_NULL 0 +#define T_ARG 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration */ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ + +/* + * derived types are: + */ + +#define DT_NON 0 /* no derived type */ +#define DT_PTR 1 /* pointer */ +#define DT_FCN 2 /* function */ +#define DT_ARY 3 /* array */ + +/* + * type packing constants + */ + +#define N_BTMASK 017 +#define N_TMASK 060 +#define N_TMASK1 0300 +#define N_TMASK2 0360 +#define N_BTSHFT 4 +#define N_TSHIFT 2 + +/* + * MACROS + */ + + /* Basic Type of x */ + +#define BTYPE(x) ((x) & N_BTMASK) + + /* Is x a pointer ? */ + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) + + /* Is x a function ? */ + +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) + + /* Is x an array ? */ + +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) + + /* Is x a structure, union, or enumeration TAG? */ + +#define ISTAG(x) ((x) == C_STRTAG || (x) == C_UNTAG || (x) == C_ENTAG) + +#define INCREF(x) ((((x)&~N_BTMASK)<>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +/* + * AUXILIARY ENTRY FORMAT + */ + +union auxent +{ + struct + { + long x_tagndx; /* str, un, or enum tag indx */ + union + { + struct + { + unsigned short x_lnno; /* declaration line */ + /* number */ + unsigned short x_size; /* str, union, array */ + /* size */ + } x_lnsz; + long x_fsize; /* size of function */ + } x_misc; + union + { + struct /* if ISFCN, tag, or .bb */ + { + long x_lnnoptr; /* ptr to fcn line # */ + long x_endndx; /* entry ndx past */ + /* block end */ + } x_fcn; + struct /* if ISARY, up to 4 dimen. */ + { + unsigned short x_dimen[DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; /* tv index */ + } x_sym; + struct + { + char x_fname[FILNMLEN]; + } x_file; + struct + { + long x_scnlen; /* section length */ + unsigned short x_nreloc; /* number of reloc entries */ + unsigned short x_nlinno; /* number of line numbers */ + } x_scn; + + struct + { + long x_tvfill; /* tv fill value */ + unsigned short x_tvlen; /* length of .tv */ + unsigned short x_tvran[2]; /* tv range */ + } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ +}; + +#define SYMENT struct syment +#define SYMESZ 18 /* sizeof(SYMENT) */ + +#define AUXENT union auxent +#define AUXESZ 18 /* sizeof(AUXENT) */ + +/* Defines for "special" symbols */ + +#define _ETEXT "etext" +#define _EDATA "edata" +#define _END "end" +#define _START "_start" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYMS_H */ diff --git a/illumos-x86_64/usr/include/synch.h b/illumos-x86_64/usr/include/synch.h new file mode 100644 index 00000000..d7afffd5 --- /dev/null +++ b/illumos-x86_64/usr/include/synch.h @@ -0,0 +1,224 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYNCH_H +#define _SYNCH_H + +/* + * synch.h: + * definitions needed to use the thread synchronization interface + */ + +#ifndef _ASM +#include +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* + * Semaphores + */ +typedef struct _sema { + /* this structure must be the same as sem_t in */ + uint32_t count; /* semaphore count */ + uint16_t type; + uint16_t magic; + upad64_t pad1[3]; /* reserved for a mutex_t */ + upad64_t pad2[2]; /* reserved for a cond_t */ +} sema_t; + +/* + * POSIX.1c Note: + * POSIX.1c requires that define the structures pthread_mutex_t + * and pthread_cond_t. These structures are identical to mutex_t (lwp_mutex_t) + * and cond_t (lwp_cond_t) which are defined in . A nested included + * of (to allow a "#typedef mutex_t pthread_mutex_t") would pull in + * non-posix symbols/constants violating the namespace restrictions. Hence, + * pthread_mutex_t/pthread_cond_t have been redefined in (actually + * in ). Any modifications done to mutex_t/lwp_mutex_t or + * cond_t/lwp_cond_t should also be done to pthread_mutex_t/pthread_cond_t. + */ +typedef lwp_mutex_t mutex_t; +typedef lwp_cond_t cond_t; + +/* + * Readers/writer locks + * + * NOTE: The layout of this structure should be kept in sync with the layout + * of the correponding structure of pthread_rwlock_t in sys/types.h. + * Also, there is an identical structure for lwp_rwlock_t in . + * Because we have to deal with C++, we cannot redefine this one as that one. + */ +typedef struct _rwlock { + int32_t readers; /* rwstate word */ + uint16_t type; + uint16_t magic; + mutex_t mutex; /* used with process-shared rwlocks */ + cond_t readercv; /* used only to indicate ownership */ + cond_t writercv; /* used only to indicate ownership */ +} rwlock_t; + +int _lwp_mutex_lock(lwp_mutex_t *); +int _lwp_mutex_unlock(lwp_mutex_t *); +int _lwp_mutex_trylock(lwp_mutex_t *); +int _lwp_cond_wait(lwp_cond_t *, lwp_mutex_t *); +int _lwp_cond_timedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *); +int _lwp_cond_reltimedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *); +int _lwp_cond_signal(lwp_cond_t *); +int _lwp_cond_broadcast(lwp_cond_t *); +int _lwp_sema_init(lwp_sema_t *, int); +int _lwp_sema_wait(lwp_sema_t *); +int _lwp_sema_trywait(lwp_sema_t *); +int _lwp_sema_post(lwp_sema_t *); +int cond_init(cond_t *, int, void *); +int cond_destroy(cond_t *); +int cond_wait(cond_t *, mutex_t *); +int cond_timedwait(cond_t *, mutex_t *, const timespec_t *); +int cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *); +int cond_signal(cond_t *); +int cond_broadcast(cond_t *); +int mutex_init(mutex_t *, int, void *); +int mutex_destroy(mutex_t *); +int mutex_consistent(mutex_t *); +int mutex_lock(mutex_t *); +int mutex_trylock(mutex_t *); +int mutex_unlock(mutex_t *); +int rwlock_init(rwlock_t *, int, void *); +int rwlock_destroy(rwlock_t *); +int rw_rdlock(rwlock_t *); +int rw_wrlock(rwlock_t *); +int rw_unlock(rwlock_t *); +int rw_tryrdlock(rwlock_t *); +int rw_trywrlock(rwlock_t *); +int sema_init(sema_t *, unsigned int, int, void *); +int sema_destroy(sema_t *); +int sema_wait(sema_t *); +int sema_timedwait(sema_t *, const timespec_t *); +int sema_reltimedwait(sema_t *, const timespec_t *); +int sema_post(sema_t *); +int sema_trywait(sema_t *); + +#endif /* _ASM */ + +/* "Magic numbers" tagging synchronization object types */ +#define MUTEX_MAGIC _MUTEX_MAGIC +#define SEMA_MAGIC _SEMA_MAGIC +#define COND_MAGIC _COND_MAGIC +#define RWL_MAGIC _RWL_MAGIC + +/* + * POSIX.1c Note: + * DEFAULTMUTEX is defined same as PTHREAD_MUTEX_INITIALIZER in . + * DEFAULTCV is defined same as PTHREAD_COND_INITIALIZER in . + * DEFAULTRWLOCK is defined same as PTHREAD_RWLOCK_INITIALIZER in . + * Any changes to these macros should be reflected in + */ +#define DEFAULTMUTEX \ + {{0, 0, 0, {USYNC_THREAD}, MUTEX_MAGIC}, \ + {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0} +#define SHAREDMUTEX \ + {{0, 0, 0, {USYNC_PROCESS}, MUTEX_MAGIC}, \ + {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0} +#define RECURSIVEMUTEX \ + {{0, 0, 0, {USYNC_THREAD|LOCK_RECURSIVE}, MUTEX_MAGIC}, \ + {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0} +#define ERRORCHECKMUTEX \ + {{0, 0, 0, {USYNC_THREAD|LOCK_ERRORCHECK}, MUTEX_MAGIC}, \ + {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0} +#define RECURSIVE_ERRORCHECKMUTEX \ + {{0, 0, 0, {USYNC_THREAD|LOCK_RECURSIVE|LOCK_ERRORCHECK}, \ + MUTEX_MAGIC}, {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0} +#define DEFAULTCV \ + {{{0, 0, 0, 0}, USYNC_THREAD, COND_MAGIC}, 0} +#define SHAREDCV \ + {{{0, 0, 0, 0}, USYNC_PROCESS, COND_MAGIC}, 0} +#define DEFAULTSEMA \ + {0, USYNC_THREAD, SEMA_MAGIC, {0, 0, 0}, {0, 0}} +#define SHAREDSEMA \ + {0, USYNC_PROCESS, SEMA_MAGIC, {0, 0, 0}, {0, 0}} +#define DEFAULTRWLOCK \ + {0, USYNC_THREAD, RWL_MAGIC, DEFAULTMUTEX, DEFAULTCV, DEFAULTCV} +#define SHAREDRWLOCK \ + {0, USYNC_PROCESS, RWL_MAGIC, SHAREDMUTEX, SHAREDCV, SHAREDCV} + +/* + * Tests on lock states. + */ +#define SEMA_HELD(x) _sema_held(x) +#define RW_READ_HELD(x) _rw_read_held(x) +#define RW_WRITE_HELD(x) _rw_write_held(x) +#define RW_LOCK_HELD(x) (RW_READ_HELD(x) || RW_WRITE_HELD(x)) +#define MUTEX_HELD(x) _mutex_held(x) + +/* + * The following definitions are for assertions which can be checked + * statically by tools like lock_lint. You can also define your own + * run-time test for each. If you don't, we define them to 1 so that + * such assertions simply pass. + */ +#ifndef NO_LOCKS_HELD +#define NO_LOCKS_HELD 1 +#endif +#ifndef NO_COMPETING_THREADS +#define NO_COMPETING_THREADS 1 +#endif + +#ifndef _ASM + +/* + * The *_held() functions apply equally well to Solaris threads + * and to Posix threads synchronization objects, but the formal + * type declarations are different, so we just declare the argument + * to each *_held() function to be a void *, expecting that they will + * be called with the proper type of argument in each case. + */ +int _sema_held(void *); /* sema_t or sem_t */ +int _rw_read_held(void *); /* rwlock_t or pthread_rwlock_t */ +int _rw_write_held(void *); /* rwlock_t or pthread_rwlock_t */ +int _mutex_held(void *); /* mutex_t or pthread_mutex_t */ + +/* Pause API */ +void smt_pause(void); + +#endif /* _ASM */ + +/* + * Panicking versions of our favorite friends. + */ +void mutex_enter(mutex_t *); +void mutex_exit(mutex_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYNCH_H */ diff --git a/illumos-x86_64/usr/include/sys/acct.h b/illumos-x86_64/usr/include/sys/acct.h new file mode 100644 index 00000000..e01ad610 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/acct.h @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_ACCT_H +#define _SYS_ACCT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Accounting structures + */ + +typedef ushort_t comp_t; /* "floating point" */ + /* 13-bit fraction, 3-bit exponent */ + +/* SVR4 acct structure */ +struct acct { + char ac_flag; /* Accounting flag */ + char ac_stat; /* Exit status */ + uid32_t ac_uid; /* Accounting user ID */ + gid32_t ac_gid; /* Accounting group ID */ + dev32_t ac_tty; /* control typewriter */ + time32_t ac_btime; /* Beginning time */ + comp_t ac_utime; /* acctng user time in clock ticks */ + comp_t ac_stime; /* acctng system time in clock ticks */ + comp_t ac_etime; /* acctng elapsed time in clock ticks */ + comp_t ac_mem; /* memory usage */ + comp_t ac_io; /* chars transferred */ + comp_t ac_rw; /* blocks read or written */ + char ac_comm[8]; /* command name */ +}; + +/* + * Account commands will use this header to read SVR3 + * accounting data files. + */ + +struct o_acct { + char ac_flag; /* Accounting flag */ + char ac_stat; /* Exit status */ + o_uid_t ac_uid; /* Accounting user ID */ + o_gid_t ac_gid; /* Accounting group ID */ + o_dev_t ac_tty; /* control typewriter */ + time32_t ac_btime; /* Beginning time */ + comp_t ac_utime; /* acctng user time in clock ticks */ + comp_t ac_stime; /* acctng system time in clock ticks */ + comp_t ac_etime; /* acctng elapsed time in clock ticks */ + comp_t ac_mem; /* memory usage */ + comp_t ac_io; /* chars transferred */ + comp_t ac_rw; /* blocks read or written */ + char ac_comm[8]; /* command name */ +}; + +#if !defined(_KERNEL) +extern int acct(const char *); +#endif /* !defined(_KERNEL) */ + +#if defined(_KERNEL) + +void acct(int); +int sysacct(char *); + +struct vnode; +int acct_fs_in_use(struct vnode *); +#endif + +#define AFORK 0001 /* has executed fork, but no exec */ +#define ASU 0002 /* used super-user privileges */ +#define AEXPND 0040 /* expanded acct structure */ +#define ACCTF 0300 /* record type: 00 = acct */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ACCT_H */ diff --git a/illumos-x86_64/usr/include/sys/acctctl.h b/illumos-x86_64/usr/include/sys/acctctl.h new file mode 100644 index 00000000..1dfa8e85 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/acctctl.h @@ -0,0 +1,207 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ACCTCTL_H +#define _SYS_ACCTCTL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for acctctl() system call + */ + +/* + * modes + */ +#define AC_PROC (0x1 << 24) /* change process accounting settings */ +#define AC_TASK (0x2 << 24) /* change task accounting settings */ +#define AC_FLOW (0x4 << 24) /* change flow accounting settings */ +#define AC_NET (0x8 << 24) /* change network accounting settings */ +#define AC_MODE(x) ((x) & 0xff000000) + +/* + * options + */ +#define AC_FILE_SET (0x01) /* set accounting file name */ +#define AC_FILE_GET (0x02) /* get accounting file name */ +#define AC_RES_SET (0x04) /* set (enable/disable) resources */ +#define AC_RES_GET (0x08) /* get a list of enabled resources */ +#define AC_STATE_SET (0x10) /* set accounting mode state (on/off) */ +#define AC_STATE_GET (0x20) /* get accounting mode state */ +#define AC_OPTION(x) ((x) & 0x00ffffff) + +/* + * Process accounting resource IDs + */ +#define AC_NONE 0 /* special end-of-list identifier */ +#define AC_PROC_PID 1 /* process ID */ +#define AC_PROC_UID 2 /* user ID */ +#define AC_PROC_GID 3 /* group ID */ +#define AC_PROC_PROJID 4 /* project ID */ +#define AC_PROC_TASKID 5 /* task ID */ +#define AC_PROC_CPU 6 /* user/system cpu time */ +#define AC_PROC_TIME 7 /* start/finish time */ +#define AC_PROC_COMMAND 8 /* command name */ +#define AC_PROC_TTY 9 /* control tty */ +#define AC_PROC_HOSTNAME 10 /* hostname */ +#define AC_PROC_MICROSTATE 11 /* microstate accounting */ +#define AC_PROC_FLAG 12 /* accounting flags */ +#define AC_PROC_ANCPID 13 /* ancestor process's ID */ +#define AC_PROC_WAIT_STATUS 14 /* process wait status */ +#define AC_PROC_ZONENAME 15 /* zone name */ +#define AC_PROC_MEM 16 /* memory usage */ +#define AC_PROC_MAX_RES 16 /* must be equal to the number above */ + +/* + * Task accounting resource IDs + */ +#define AC_TASK_TASKID 1 /* task ID */ +#define AC_TASK_PROJID 2 /* project ID */ +#define AC_TASK_CPU 3 /* user/system cpu time */ +#define AC_TASK_TIME 4 /* start/finish time */ +#define AC_TASK_HOSTNAME 5 /* hostname */ +#define AC_TASK_MICROSTATE 6 /* microstate accounting */ +#define AC_TASK_ANCTASKID 7 /* ancestor task's taskid */ +#define AC_TASK_ZONENAME 8 /* zone name */ +#define AC_TASK_MAX_RES 8 /* must be equal to the number above */ + +/* + * Flow accounting resource IDs + */ +#define AC_FLOW_SADDR 1 /* source address */ +#define AC_FLOW_DADDR 2 /* destination address */ +#define AC_FLOW_SPORT 3 /* source port */ +#define AC_FLOW_DPORT 4 /* destination port */ +#define AC_FLOW_PROTOCOL 5 /* protocol */ +#define AC_FLOW_DSFIELD 6 /* dsfield */ +#define AC_FLOW_CTIME 7 /* creation time for this flow */ +#define AC_FLOW_LSEEN 8 /* pkt last seen for this flow */ +#define AC_FLOW_NBYTES 9 /* no. of bytes in this flow */ +#define AC_FLOW_NPKTS 10 /* no. of packets for this flow */ +#define AC_FLOW_PROJID 11 /* project id */ +#define AC_FLOW_UID 12 /* user id */ +#define AC_FLOW_ANAME 13 /* action instance name */ +#define AC_FLOW_MAX_RES 13 /* must be equal to the number above */ + +/* + * Network accounting resource IDs + */ +#define AC_NET_NAME 1 /* flow name */ +#define AC_NET_EHOST 2 /* ethernet source address */ +#define AC_NET_EDEST 3 /* ethernet destination address */ +#define AC_NET_VLAN_TPID 4 /* VLAN protocol ID */ +#define AC_NET_VLAN_TCI 5 /* VLAN tag control info. */ +#define AC_NET_SAP 6 /* SAP */ +#define AC_NET_PRIORITY 7 /* Priority */ +#define AC_NET_BWLIMIT 8 /* Bandwidth limit */ +#define AC_NET_DEVNAME 9 /* Device name */ +#define AC_NET_SADDR 10 /* Source IP address */ +#define AC_NET_DADDR 11 /* Dest IP address */ +#define AC_NET_SPORT 12 /* Source Port */ +#define AC_NET_DPORT 13 /* Dest Port */ +#define AC_NET_PROTOCOL 14 /* Protocol */ +#define AC_NET_DSFIELD 15 /* DiffServ field */ +#define AC_NET_CURTIME 16 /* Current Time */ +#define AC_NET_IBYTES 17 /* Inbound Bytes */ +#define AC_NET_OBYTES 18 /* Outbound Bytes */ +#define AC_NET_IPKTS 19 /* Inbound Packets */ +#define AC_NET_OPKTS 20 /* Outbound Packets */ +#define AC_NET_IERRPKTS 21 /* Inbound Error Packets */ +#define AC_NET_OERRPKTS 22 /* Outbound Error Packets */ +#define AC_NET_MAX_RES 22 /* must be equal to the number above */ + +#define AC_MAX_RES \ + MAX(MAX(MAX(AC_PROC_MAX_RES, AC_TASK_MAX_RES), AC_FLOW_MAX_RES), \ + AC_NET_MAX_RES) +#define AC_MASK_SZ BT_BITOUL(AC_MAX_RES + 1) + +/* + * resource states + */ +#define AC_ON 1 /* enabled resource */ +#define AC_OFF 0 /* disabled resource */ + +typedef struct ac_res { + int ar_id; /* resource ID */ + int ar_state; /* resource state; see above */ +} ac_res_t; + +#ifdef _KERNEL + +#include +#include +#include + +typedef struct ac_info { + kmutex_t ac_lock; /* protects the structure */ + vnode_t *ac_vnode; /* exacct file vnode pointer */ + char *ac_file; /* exacct file name */ + int ac_state; /* accounting state */ + ulong_t ac_mask[AC_MASK_SZ]; /* bitmask of resources */ +} ac_info_t; + +/* + * Key used for retrieving per-zone exacct settings. This remains + * uninitialized (ZONE_KEY_UNINITIALIZED) until the acctctl module is loaded. + */ +extern zone_key_t exacct_zone_key; + +/* + * Per-zone exacct settings. Each zone may have its own settings for + * process, task, flow, and network accounting. + * + * Per-zone flow accounting has not yet been implemented, so this + * provides zones with the view that flow accounting in the zone hasn't + * been initialized (which is true). The various system calls will fail + * to set flow accounting parameters from within a zone. + * + * The global list of accounting settings is used when we check to see + * if the accounting file is already in use by any zone. + */ +struct exacct_globals { + ac_info_t ac_task; + ac_info_t ac_proc; + ac_info_t ac_flow; + ac_info_t ac_net; + list_node_t ac_link; +}; + +#else + +extern int acctctl(int cmd, void *buf, size_t bufsz); + +#endif /* ifdef _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ACCTCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/acl.h b/illumos-x86_64/usr/include/sys/acl.h new file mode 100644 index 00000000..eec11886 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/acl.h @@ -0,0 +1,321 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. + */ + +#ifndef _SYS_ACL_H +#define _SYS_ACL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_ACL_ENTRIES (1024) /* max entries of each type */ +typedef struct acl { + int a_type; /* the type of ACL entry */ + uid_t a_id; /* the entry in -uid or gid */ + o_mode_t a_perm; /* the permission field */ +} aclent_t; + +typedef struct ace { + uid_t a_who; /* uid or gid */ + uint32_t a_access_mask; /* read,write,... */ + uint16_t a_flags; /* see below */ + uint16_t a_type; /* allow or deny */ +} ace_t; + +typedef struct acl_info acl_t; + +/* + * The following are Defined types for an aclent_t. + */ +#define USER_OBJ (0x01) /* object owner */ +#define USER (0x02) /* additional users */ +#define GROUP_OBJ (0x04) /* owning group of the object */ +#define GROUP (0x08) /* additional groups */ +#define CLASS_OBJ (0x10) /* file group class and mask entry */ +#define OTHER_OBJ (0x20) /* other entry for the object */ +#define ACL_DEFAULT (0x1000) /* default flag */ +/* default object owner */ +#define DEF_USER_OBJ (ACL_DEFAULT | USER_OBJ) +/* default additional users */ +#define DEF_USER (ACL_DEFAULT | USER) +/* default owning group */ +#define DEF_GROUP_OBJ (ACL_DEFAULT | GROUP_OBJ) +/* default additional groups */ +#define DEF_GROUP (ACL_DEFAULT | GROUP) +/* default mask entry */ +#define DEF_CLASS_OBJ (ACL_DEFAULT | CLASS_OBJ) +/* default other entry */ +#define DEF_OTHER_OBJ (ACL_DEFAULT | OTHER_OBJ) + +/* + * The following are defined for ace_t. + * + * Note, these are intentionally the same as the Windows + * "File Access Rights Constants" you can find on MSDN. + * (See also: "Standard Access Rights" on MSDN). + * + * The equivalent Windows names for these are just like + * those show below, with FILE_ in place of ACE_, except + * as noted below. Also note that Windows uses a special + * privilege: BYPASS_TRAVERSE_CHECKING, normally granted + * to everyone, that causes the absence of ACE_TRAVERSE + * to be ignored. + */ +#define ACE_READ_DATA 0x00000001 /* file: read data */ +#define ACE_LIST_DIRECTORY 0x00000001 /* dir: list files */ +#define ACE_WRITE_DATA 0x00000002 /* file: write data */ +#define ACE_ADD_FILE 0x00000002 /* dir: create file */ +#define ACE_APPEND_DATA 0x00000004 /* file: append data */ +#define ACE_ADD_SUBDIRECTORY 0x00000004 /* dir: create subdir */ +#define ACE_READ_NAMED_ATTRS 0x00000008 /* FILE_READ_EA */ +#define ACE_WRITE_NAMED_ATTRS 0x00000010 /* FILE_WRITE_EA */ +#define ACE_EXECUTE 0x00000020 /* file: execute */ +#define ACE_TRAVERSE 0x00000020 /* dir: lookup name */ +#define ACE_DELETE_CHILD 0x00000040 /* dir: unlink child */ +#define ACE_READ_ATTRIBUTES 0x00000080 /* (all) stat, etc. */ +#define ACE_WRITE_ATTRIBUTES 0x00000100 /* (all) utimes, etc. */ +#define ACE_DELETE 0x00010000 /* (all) unlink self */ +#define ACE_READ_ACL 0x00020000 /* (all) getsecattr */ +#define ACE_WRITE_ACL 0x00040000 /* (all) setsecattr */ +#define ACE_WRITE_OWNER 0x00080000 /* (all) chown */ +#define ACE_SYNCHRONIZE 0x00100000 /* (all) see MSDN */ + +/* + * Some of the following are the same as Windows uses. (but NOT ALL!) + * See the "ACE_HEADER" structure description on MSDN for details. + * Comments show relations to the MSDN names. + */ +#define ACE_FILE_INHERIT_ACE 0x0001 /* = OBJECT_INHERIT_ACE */ +#define ACE_DIRECTORY_INHERIT_ACE 0x0002 /* = CONTAINER_INHERIT_ACE */ +#define ACE_NO_PROPAGATE_INHERIT_ACE 0x0004 /* = NO_PROPAGATE_INHERIT_ACE */ +#define ACE_INHERIT_ONLY_ACE 0x0008 /* = INHERIT_ONLY_ACE */ +#define ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x0010 +#define ACE_FAILED_ACCESS_ACE_FLAG 0x0020 +#define ACE_IDENTIFIER_GROUP 0x0040 +#define ACE_INHERITED_ACE 0x0080 /* INHERITED_ACE, 0x10 on NT */ +#define ACE_OWNER 0x1000 +#define ACE_GROUP 0x2000 +#define ACE_EVERYONE 0x4000 + +/* These four are the same as Windows, but with an ACE_ prefix added. */ +#define ACE_ACCESS_ALLOWED_ACE_TYPE 0x0000 +#define ACE_ACCESS_DENIED_ACE_TYPE 0x0001 +#define ACE_SYSTEM_AUDIT_ACE_TYPE 0x0002 +#define ACE_SYSTEM_ALARM_ACE_TYPE 0x0003 + +#define ACL_AUTO_INHERIT 0x0001 +#define ACL_PROTECTED 0x0002 +#define ACL_DEFAULTED 0x0004 +#define ACL_FLAGS_ALL (ACL_AUTO_INHERIT|ACL_PROTECTED| \ + ACL_DEFAULTED) + +/* + * These are only applicable in a CIFS context. + * Here again, same as Windows, but with an ACE_ prefix added. + */ +#define ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x04 +#define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05 +#define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06 +#define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07 +#define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08 +#define ACE_ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x09 +#define ACE_ACCESS_DENIED_CALLBACK_ACE_TYPE 0x0A +#define ACE_ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0x0B +#define ACE_ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0x0C +#define ACE_SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0x0D +#define ACE_SYSTEM_ALARM_CALLBACK_ACE_TYPE 0x0E +#define ACE_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0x0F +#define ACE_SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10 + +#define ACE_ALL_TYPES 0x001F + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +typedef struct ace_object { + uid_t a_who; /* uid or gid */ + uint32_t a_access_mask; /* read,write,... */ + uint16_t a_flags; /* see below */ + uint16_t a_type; /* allow or deny */ + uint8_t a_obj_type[16]; /* obj type */ + uint8_t a_inherit_obj_type[16]; /* inherit obj */ +} ace_object_t; + +#endif + +#define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \ + ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \ + ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \ + ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \ + ACE_WRITE_OWNER|ACE_SYNCHRONIZE) + +#define ACE_ALL_WRITE_PERMS (ACE_WRITE_DATA|ACE_APPEND_DATA| \ + ACE_WRITE_ATTRIBUTES|ACE_WRITE_NAMED_ATTRS|ACE_WRITE_ACL| \ + ACE_WRITE_OWNER|ACE_DELETE|ACE_DELETE_CHILD) + +#define ACE_READ_PERMS (ACE_READ_DATA|ACE_READ_ACL|ACE_READ_ATTRIBUTES| \ + ACE_READ_NAMED_ATTRS) + +#define ACE_WRITE_PERMS (ACE_WRITE_DATA|ACE_APPEND_DATA|ACE_WRITE_ATTRIBUTES| \ + ACE_WRITE_NAMED_ATTRS) + +#define ACE_MODIFY_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \ + ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \ + ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \ + ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_SYNCHRONIZE) +/* + * The following flags are supported by both NFSv4 ACLs and ace_t. + */ +#define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \ + ACE_DIRECTORY_INHERIT_ACE | \ + ACE_NO_PROPAGATE_INHERIT_ACE | \ + ACE_INHERIT_ONLY_ACE | \ + ACE_IDENTIFIER_GROUP) + +#define ACE_TYPE_FLAGS (ACE_OWNER|ACE_GROUP|ACE_EVERYONE| \ + ACE_IDENTIFIER_GROUP) +#define ACE_INHERIT_FLAGS (ACE_FILE_INHERIT_ACE| \ + ACE_DIRECTORY_INHERIT_ACE|ACE_NO_PROPAGATE_INHERIT_ACE|ACE_INHERIT_ONLY_ACE) + +/* cmd args to acl(2) for aclent_t */ +#define GETACL 1 +#define SETACL 2 +#define GETACLCNT 3 + +/* cmd's to manipulate ace acls. */ +#define ACE_GETACL 4 +#define ACE_SETACL 5 +#define ACE_GETACLCNT 6 + +/* minimal acl entries from GETACLCNT */ +#define MIN_ACL_ENTRIES 4 + +#if !defined(_KERNEL) + +/* acl check errors */ +#define GRP_ERROR 1 +#define USER_ERROR 2 +#define OTHER_ERROR 3 +#define CLASS_ERROR 4 +#define DUPLICATE_ERROR 5 +#define MISS_ERROR 6 +#define MEM_ERROR 7 +#define ENTRY_ERROR 8 + + +/* + * similar to ufs_acl.h: changed to char type for user commands (tar, cpio) + * Attribute types + */ +#define UFSD_FREE ('0') /* Free entry */ +#define UFSD_ACL ('1') /* Access Control Lists */ +#define UFSD_DFACL ('2') /* reserved for future use */ +#define ACE_ACL ('3') /* ace_t style acls */ + +/* + * flag to [f]acl_get() + * controls whether a trivial acl should be returned. + */ +#define ACL_NO_TRIVIAL 0x2 + + +/* + * Flags to control acl_totext() + */ + +#define ACL_APPEND_ID 0x1 /* append uid/gid to user/group entries */ +#define ACL_COMPACT_FMT 0x2 /* build ACL in ls -V format */ +#define ACL_NORESOLVE 0x4 /* don't do name service lookups */ +#define ACL_SID_FMT 0x8 /* use usersid/groupsid when appropriate */ + +/* + * Legacy aclcheck errors for aclent_t ACLs + */ +#define EACL_GRP_ERROR GRP_ERROR +#define EACL_USER_ERROR USER_ERROR +#define EACL_OTHER_ERROR OTHER_ERROR +#define EACL_CLASS_ERROR CLASS_ERROR +#define EACL_DUPLICATE_ERROR DUPLICATE_ERROR +#define EACL_MISS_ERROR MISS_ERROR +#define EACL_MEM_ERROR MEM_ERROR +#define EACL_ENTRY_ERROR ENTRY_ERROR + +#define EACL_INHERIT_ERROR 9 /* invalid inherit flags */ +#define EACL_FLAGS_ERROR 10 /* unknown flag value */ +#define EACL_PERM_MASK_ERROR 11 /* unknown permission */ +#define EACL_COUNT_ERROR 12 /* invalid acl count */ + +#define EACL_INVALID_SLOT 13 /* invalid acl slot */ +#define EACL_NO_ACL_ENTRY 14 /* Entry doesn't exist */ +#define EACL_DIFF_TYPE 15 /* acls aren't same type */ + +#define EACL_INVALID_USER_GROUP 16 /* need user/group name */ +#define EACL_INVALID_STR 17 /* invalid acl string */ +#define EACL_FIELD_NOT_BLANK 18 /* can't have blank field */ +#define EACL_INVALID_ACCESS_TYPE 19 /* invalid access type */ +#define EACL_UNKNOWN_DATA 20 /* Unrecognized data in ACL */ +#define EACL_MISSING_FIELDS 21 /* missing fields in acl */ + +#define EACL_INHERIT_NOTDIR 22 /* Need dir for inheritance */ + +extern int aclcheck(aclent_t *, int, int *); +extern int acltomode(aclent_t *, int, mode_t *); +extern int aclfrommode(aclent_t *, int, mode_t *); +extern int aclsort(int, int, aclent_t *); +extern char *acltotext(aclent_t *, int); +extern aclent_t *aclfromtext(char *, int *); +extern void acl_free(acl_t *); +extern int acl_get(const char *, int, acl_t **); +extern int facl_get(int, int, acl_t **); +extern int acl_set(const char *, acl_t *acl); +extern int facl_set(int, acl_t *acl); +extern int acl_strip(const char *, uid_t, gid_t, mode_t); +extern int acl_trivial(const char *); +extern char *acl_totext(acl_t *, int); +extern int acl_fromtext(const char *, acl_t **); +extern int acl_check(acl_t *, int); + +#else /* !defined(_KERNEL) */ + +extern void ksort(caddr_t, int, int, int (*)(void *, void *)); +extern int cmp2acls(void *, void *); + +#endif /* !defined(_KERNEL) */ + +extern int acl(const char *path, int cmd, int cnt, void *buf); +extern int facl(int fd, int cmd, int cnt, void *buf); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ACL_H */ diff --git a/illumos-x86_64/usr/include/sys/acl_impl.h b/illumos-x86_64/usr/include/sys/acl_impl.h new file mode 100644 index 00000000..71733490 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/acl_impl.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ACL_IMPL_H +#define _SYS_ACL_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * acl flags + * + * ACL_AUTO_INHERIT, ACL_PROTECTED and ACL_DEFAULTED + * flags can also be stored in this field. + */ +#define ACL_IS_TRIVIAL 0x10000 +#define ACL_IS_DIR 0x20000 + +typedef enum acl_type { + ACLENT_T = 0, + ACE_T = 1 +} acl_type_t; + +struct acl_info { + acl_type_t acl_type; /* style of acl */ + int acl_cnt; /* number of acl entries */ + int acl_entry_size; /* sizeof acl entry */ + int acl_flags; /* special flags about acl */ + void *acl_aclp; /* the acl */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ACL_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/acpi_drv.h b/illumos-x86_64/usr/include/sys/acpi_drv.h new file mode 100644 index 00000000..185e8385 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/acpi_drv.h @@ -0,0 +1,259 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2015 Hans Rosenfeld + */ + +#ifndef _ACPI_DRV_H +#define _ACPI_DRV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +enum acpi_drv_ioctl { + ACPI_DRV_IOC_BAY, + ACPI_DRV_IOC_INFO, + ACPI_DRV_IOC_STATUS, + ACPI_DRV_IOC_AC_COUNT, + ACPI_DRV_IOC_POWER_STATUS, + ACPI_DRV_IOC_SET_WARNING, + ACPI_DRV_IOC_GET_WARNING, + ACPI_DRV_IOC_LID_STATUS, + ACPI_DRV_IOC_LID_UPDATE, + ACPI_DRV_IOC_LEVELS, + ACPI_DRV_IOC_SET_BRIGHTNESS +}; + +#define ACPI_DRV_BST_CHARGING 2 +#define ACPI_DRV_BST_DISCHARGING 1 + +typedef struct batt_bay { + /* Total number of bays in the system */ + int bay_number; + + /* + * Bitmap for each bay and its battery. + * battery_map bit i: + * 1 -- battery inserted to bay i + * 0 -- bay i empty + */ + uint64_t battery_map; +} batt_bay_t; + +typedef struct acpi_bif { + uint32_t bif_unit; + + /* + * 0x00000000 - 0x7fffffff + * 0xffffffff - Unknown design capacity in [mWh] or [mAh] + */ + uint32_t bif_design_cap; + + /* + * 0x00000000 - 0x7fffffff + * 0xffffffff - Unknown last full charge capacity in [mWh] or [mAh] + */ + uint32_t bif_last_cap; + + uint32_t bif_tech; + + /* + * 0x00000000 - 0x7fffffff + * 0xffffffff - Unknown design voltage in [mV] + */ + uint32_t bif_voltage; + + /* + * 0x00000000 - 0x7fffffff in [mWh] or [mAh] + */ + uint32_t bif_warn_cap; + + /* + * 0x00000000 - 0x7fffffff in [mWh] or [mAh] + */ + uint32_t bif_low_cap; + + uint32_t bif_gran1_cap; + uint32_t bif_gran2_cap; + char bif_model[MAXNAMELEN]; + char bif_serial[MAXNAMELEN]; + char bif_type[MAXNAMELEN]; + char bif_oem_info[MAXNAMELEN]; +} acpi_bif_t; + +typedef struct acpi_bst { + uint32_t bst_state; + + /* + * 0x00000000 - 0x7fffffff in [mW] or [mA] + * 0xffffffff - Unknown rate + */ + uint32_t bst_rate; + + /* + * 0x00000000 - 0x7fffffff in [mWh] or [mAh] + * 0xffffffff - Unknown capacity + */ + uint32_t bst_rem_cap; + + /* + * 0x00000000 - 0x7fffffff in [mV] + * 0xffffffff - Unknown voltage + */ + uint32_t bst_voltage; +} acpi_bst_t; + +/* Battery warnning levels in percentage */ +typedef struct acpi_drv_warn { + uint32_t bw_enabled; /* Enabled */ + uint32_t bw_charge_warn; /* charge warn threshold */ + uint32_t bw_charge_low; /* charge low threshold */ +} acpi_drv_warn_t; + +#define ACPI_DRV_NAME "acpi_drv" +#define ACPI_DRV_POWER_KSTAT_NAME "power" +#define ACPI_DRV_BTWARN_KSTAT_NAME "battery warning" +#define ACPI_DRV_BIF_KSTAT_NAME "battery BIF" +#define ACPI_DRV_BST_KSTAT_NAME "battery BST" + +#define AC "AC" +#define BATTERY "battery" +#define SYSTEM_POWER "system power" +#define SUPPORTED_BATTERY_COUNT "supported_battery_count" + +#define BW_ENABLED "enabled" +#define BW_POWEROFF_THRESHOLD "warn capacity threshold" +#define BW_SHUTDOWN_THRESHOLD "low capacity threshold" + +#define BIF_UNIT "bif_unit" +#define BIF_DESIGN_CAP "bif_design_cap" +#define BIF_LAST_CAP "bif_last_cap" +#define BIF_TECH "bif_tech" +#define BIF_VOLTAGE "bif_voltage" +#define BIF_WARN_CAP "bif_warn_cap" +#define BIF_LOW_CAP "bif_low_cap" +#define BIF_GRAN1_CAP "bif_gran1_cap" +#define BIF_GRAN2_CAP "bif_gran2_cap" +#define BIF_MODEL "bif_model" +#define BIF_SERIAL "bif_serial" +#define BIF_TYPE "bif_type" +#define BIF_OEM_INFO "bif_oem_info" + +#define BST_STATE "bst_state" +#define BST_RATE "bst_rate" +#define BST_REM_CAP "bst_rem_cap" +#define BST_VOLTAGE "bst_voltage" + +#define PSR_AC_PRESENT "psr_ac_present" + +typedef struct acpi_drv_power_kstat_s { + struct kstat_named acpi_drv_power; + struct kstat_named acpi_drv_supported_battery_count; +} acpi_drv_power_kstat_t; + +typedef struct acpi_drv_warn_kstat_s { + struct kstat_named acpi_drv_bw_enabled; + struct kstat_named acpi_drv_bw_charge_warn; + struct kstat_named acpi_drv_bw_charge_low; +} acpi_drv_warn_kstat_t; + +/* BIF kstat */ +typedef struct acpi_drv_bif_kstat_s { + struct kstat_named acpi_drv_bif_unit; + struct kstat_named acpi_drv_bif_design_cap; + struct kstat_named acpi_drv_bif_last_cap; + struct kstat_named acpi_drv_bif_tech; + struct kstat_named acpi_drv_bif_voltage; + struct kstat_named acpi_drv_bif_warn_cap; + struct kstat_named acpi_drv_bif_low_cap; + struct kstat_named acpi_drv_bif_gran1_cap; + struct kstat_named acpi_drv_bif_gran2_cap; + struct kstat_named acpi_drv_bif_model; + struct kstat_named acpi_drv_bif_serial; + struct kstat_named acpi_drv_bif_type; + struct kstat_named acpi_drv_bif_oem_info; +} acpi_drv_bif_kstat_t; + +/* BST kstat */ +typedef struct acpi_drv_bst_kstat_s { + struct kstat_named acpi_drv_bst_state; + struct kstat_named acpi_drv_bst_rate; + struct kstat_named acpi_drv_bst_rem_cap; + struct kstat_named acpi_drv_bst_voltage; +} acpi_drv_bst_kstat_t; + +/* acpi device types */ +enum acpi_drv_type { + ACPI_DRV_TYPE_UNKNOWN, + ACPI_DRV_TYPE_CBAT, + ACPI_DRV_TYPE_AC, + ACPI_DRV_TYPE_LID, + ACPI_DRV_TYPE_DISPLAY, + ACPI_DRV_TYPE_HOTKEY +}; + +struct acpi_drv_output_info { + uint32_t adr; /* unique ID for this output device */ + int nlev; /* number of brightness levels */ +}; + +struct acpi_drv_output_status { + int state; + int num_levels; + int cur_level; + int cur_level_index; +}; + +#define ACPI_DRV_OK 0 +#define ACPI_DRV_ERR -1 + +#ifdef _KERNEL + +#define MINOR_SHIFT 8 +#define IDX_MASK ((1 << MINOR_SHIFT) - 1) +#define MINOR_BATT(idx) (ACPI_DRV_TYPE_CBAT << MINOR_SHIFT | \ + (idx)) +#define MINOR_AC(idx) (ACPI_DRV_TYPE_AC << MINOR_SHIFT | \ + (idx)) +#define MINOR_LID(idx) (ACPI_DRV_TYPE_LID << MINOR_SHIFT | \ + (idx)) +#define MINOR_HOTKEY(idx) (ACPI_DRV_TYPE_HOTKEY << MINOR_SHIFT \ + | (idx)) +#define MINOR2IDX(minor) ((minor) & IDX_MASK) +#define MINOR2TYPE(minor) ((minor) >> MINOR_SHIFT) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ACPI_DRV_H */ diff --git a/illumos-x86_64/usr/include/sys/aio.h b/illumos-x86_64/usr/include/sys/aio.h new file mode 100644 index 00000000..1ddede34 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/aio.h @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_AIO_H +#define _SYS_AIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct aio_result_t { + ssize_t aio_return; /* return value of read or write */ + int aio_errno; /* errno generated by the IO */ +} aio_result_t; + +#ifdef _SYSCALL32 +typedef struct aio_result32_t { + int aio_return; /* return value of read or write */ + int aio_errno; /* errno generated by the IO */ +} aio_result32_t; +#endif /* _SYSCALL32 */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define AIOREAD 0 /* opcodes for aio calls */ +#define AIOWRITE 1 +#define AIOWAIT 2 +#define AIOCANCEL 3 +#define AIONOTIFY 4 +#define AIOINIT 5 +#define AIOSTART 6 +#define AIOLIO 7 +#define AIOSUSPEND 8 +#define AIOERROR 9 +#define AIOLIOWAIT 10 +#define AIOAREAD 11 +#define AIOAWRITE 12 +#define AIOFSYNC 20 +#define AIOWAITN 21 +#define AIORESERVED1 23 /* reserved for the aio implementation */ +#define AIORESERVED2 24 +#define AIORESERVED3 25 +#ifdef _LARGEFILE64_SOURCE +#if defined(_LP64) && !defined(_KERNEL) +#define AIOLIO64 AIOLIO +#define AIOSUSPEND64 AIOSUSPEND +#define AIOERROR64 AIOERROR +#define AIOLIOWAIT64 AIOLIOWAIT +#define AIOAREAD64 AIOAREAD +#define AIOAWRITE64 AIOAWRITE +#define AIOCANCEL64 AIOCANCEL +#define AIOFSYNC64 AIOFSYNC +#else +#define AIOLIO64 13 +#define AIOSUSPEND64 14 +#define AIOERROR64 15 +#define AIOLIOWAIT64 16 +#define AIOAREAD64 17 +#define AIOAWRITE64 18 +#define AIOCANCEL64 19 +#define AIOFSYNC64 22 +#endif /* defined(_LP64) && !defined(_KERNEL) */ +#endif /* _LARGEFILE64_SOURCE */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#define AIO_POLL_BIT 0x20 /* opcode filter for AIO_INPROGRESS */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_AIO_H */ diff --git a/illumos-x86_64/usr/include/sys/aio_impl.h b/illumos-x86_64/usr/include/sys/aio_impl.h new file mode 100644 index 00000000..337397c2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/aio_impl.h @@ -0,0 +1,193 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_AIO_IMPL_H +#define _SYS_AIO_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#define AIO_HASHSZ 8192L /* power of 2 */ +#define AIO_HASH(cookie) (((uintptr_t)(cookie) >> 3) & (AIO_HASHSZ-1)) +#define DUPLICATE 1 + +/* + * an aio_list_t is the head of a list. a group of requests are in + * the same list if their aio_req_list field point to the same list + * head. + * + * a list head is used for notification. a group of requests that + * should only notify a process when they are done will have a + * list head. notification is sent when the group of requests are + * done. + */ +typedef struct aio_lio { + int lio_nent; /* number of requests in list */ + int lio_refcnt; /* number of requests active */ + struct aio_lio *lio_next; /* free list pointer */ + kcondvar_t lio_notify; /* list notification */ + sigqueue_t *lio_sigqp; /* sigqueue_t pointer */ + int lio_port; /* port number notification */ + port_kevent_t *lio_portkev; /* port event structure */ +} aio_lio_t; + +/* + * async I/O request struct - one per I/O request. + */ + +/* + * Clustering: The aio_req_t structure is used by the PXFS module + * as a contract private interface. + */ + +typedef struct aio_req_t { + struct aio_req aio_req; + int aio_req_fd; /* aio's file descriptor */ + int aio_req_flags; /* flags */ + aio_result_t *aio_req_resultp; /* pointer to user's results */ + int (*aio_req_cancel)(); /* driver's cancel cb. */ + struct aio_req_t *aio_req_next; /* doneq and pollq pointers */ + struct aio_req_t *aio_req_prev; /* doubly linked list */ + struct aio_req_t *aio_hash_next; /* next in a hash bucket */ + aio_lio_t *aio_req_lio; /* head of list IO chain */ + struct uio aio_req_uio; /* uio struct */ + struct iovec aio_req_iov; /* iovec struct */ + struct buf aio_req_buf; /* buf struct */ + sigqueue_t *aio_req_sigqp; /* sigqueue_t pointer */ + union { + caddr_t iocb; /* ptr to aiocb: 32-32, 64-64 */ + caddr32_t iocb32; /* ptr to aiocb: 32-64 */ + } aio_req_iocb; + port_kevent_t *aio_req_portkev; /* port event structure */ + int aio_req_port; /* port id */ +} aio_req_t; + +/* + * Struct for asynchronous I/O (aio) information per process. + * Each proc stucture has a field pointing to this struct. + * The field will be null if no aio is used. + */ +typedef struct aio { + int aio_pending; /* # uncompleted requests */ + int aio_outstanding; /* total # of requests */ + int aio_ok; /* everything ok when set */ + int aio_flags; /* flags */ + int aio_rqclnup; /* cleanup request used by DR */ + int aio_portpendcnt; /* # pending req. per port */ + aio_req_t *aio_portq; /* port queue head */ + aio_req_t *aio_portcleanupq; /* port cleanup queue head */ + aio_req_t *aio_portpending; /* list of pending requests */ + aio_req_t *aio_free; /* freelist of aio requests */ + aio_lio_t *aio_lio_free; /* freelist of lio heads */ + aio_req_t *aio_doneq; /* done queue head */ + aio_req_t *aio_pollq; /* poll queue head */ + aio_req_t *aio_notifyq; /* notify queue head */ + aio_req_t *aio_cleanupq; /* cleanup queue head */ + kmutex_t aio_mutex; /* mutex for aio struct */ + kmutex_t aio_cleanupq_mutex; /* cleanupq processing */ + kcondvar_t aio_waitcv; /* cv for aiowait()'ers */ + kcondvar_t aio_cleanupcv; /* notify cleanup, aio_done */ + kcondvar_t aio_waitncv; /* cv for further aiowaitn() */ + kcondvar_t aio_portcv; /* cv for port events */ + aiocb_t **aio_iocb; /* list of 32 & 64 bit ptrs */ + size_t aio_iocbsz; /* reserved space for iocbs */ + uint_t aio_waitncnt; /* # requests for aiowaitn */ + int aio_notifycnt; /* # user-level notifications */ + kmutex_t aio_portq_mutex; /* mutex for aio_portq */ + aio_req_t *aio_hash[AIO_HASHSZ]; /* hash list of requests */ +} aio_t; + +/* + * aio_flags for an aio_t. + */ +#define AIO_CLEANUP 0x0001 /* do aio cleanup processing */ +#define AIO_WAITN 0x0002 /* aiowaitn in progress */ +#define AIO_WAITN_PENDING 0x0004 /* aiowaitn requests pending */ +#define AIO_REQ_BLOCK 0x0008 /* block new requests */ +#define AIO_CLEANUP_PORT 0x0010 +#define AIO_DONE_ACTIVE 0x0020 /* aio_done call in progress */ +#define AIO_SOLARIS_REQ 0x0040 /* an old solaris aio req was issued */ + +/* + * aio_req_flags for an aio_req_t + */ +#define AIO_POLL 0x0001 /* AIO_INPROGRESS is set */ +#define AIO_PENDING 0x0002 /* aio is in progress */ +#define AIO_PHYSIODONE 0x0004 /* unlocked phys pages */ +#define AIO_COPYOUTDONE 0x0008 /* result copied to userland */ +#define AIO_NOTIFYQ 0x0010 /* aio req is on the notifyq */ +#define AIO_CLEANUPQ 0x0020 /* aio req is on the cleanupq */ +#define AIO_POLLQ 0x0040 /* aio req is on the pollq */ +#define AIO_DONEQ 0x0080 /* aio req is on the doneq */ +#define AIO_ZEROLEN 0x0100 /* aio req is zero length */ +#define AIO_PAGELOCKDONE 0x0200 /* aio called as_pagelock() */ +#define AIO_CLOSE_PORT 0x0400 /* port is being closed */ +#define AIO_SIGNALLED 0x0800 /* process signalled by this req */ +#define AIO_SOLARIS 0x1000 /* this is an old solaris aio req */ + +/* flag argument of aio_cleanup() */ + +#define AIO_CLEANUP_POLL 0 /* check kaio poll queue */ +#define AIO_CLEANUP_EXIT 1 /* aio_cleanup_exit() */ +#define AIO_CLEANUP_THREAD 2 /* aio_cleanup_thread() */ + +/* functions exported by common/os/aio_subr.c */ + +extern int aphysio(int (*)(), int (*)(), dev_t, int, void (*)(), + struct aio_req *); +extern void aphysio_unlock(aio_req_t *); +extern void aio_cleanup(int); +extern void aio_cleanup_exit(void); +extern void aio_zerolen(aio_req_t *); +extern void aio_req_free(aio_t *, aio_req_t *); +extern void aio_cleanupq_concat(aio_t *, aio_req_t *, int); +extern void aio_copyout_result(aio_req_t *); +extern void aio_copyout_result_port(struct iovec *, struct buf *, void *); +extern void aio_req_remove_portq(aio_t *, aio_req_t *); +extern void aio_enq(aio_req_t **, aio_req_t *, int); +extern void aio_deq(aio_req_t **, aio_req_t *); +/* Clustering: PXFS module uses this interface */ +extern int aio_done(struct buf *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_AIO_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/aio_req.h b/illumos-x86_64/usr/include/sys/aio_req.h new file mode 100644 index 00000000..9619b72d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/aio_req.h @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993, by Sun Microsystems, Inc. + */ + +#ifndef _SYS_AIO_REQ_H +#define _SYS_AIO_REQ_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * async I/O request struct exposed to drivers. + */ +struct aio_req { + struct uio *aio_uio; /* UIO for this request */ + void *aio_private; +}; + +extern int aphysio(int (*)(), int (*)(), dev_t, int, void (*)(), + struct aio_req *); +extern int anocancel(struct buf *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_AIO_REQ_H */ diff --git a/illumos-x86_64/usr/include/sys/aiocb.h b/illumos-x86_64/usr/include/sys/aiocb.h new file mode 100644 index 00000000..5b2fbaa9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/aiocb.h @@ -0,0 +1,142 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_AIOCB_H +#define _SYS_AIOCB_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct aiocb { + int aio_fildes; + volatile void *aio_buf; /* buffer location */ + size_t aio_nbytes; /* length of transfer */ + off_t aio_offset; /* file offset */ + int aio_reqprio; /* request priority offset */ + struct sigevent aio_sigevent; /* notification type */ + int aio_lio_opcode; /* listio operation */ + aio_result_t aio_resultp; /* results */ + int aio_state; /* state flag for List I/O */ + int aio__pad[1]; /* extension padding */ +} aiocb_t; + +#ifdef _LARGEFILE64_SOURCE +#if !defined(_KERNEL) +typedef struct aiocb64 { + int aio_fildes; + volatile void *aio_buf; /* buffer location */ + size_t aio_nbytes; /* length of transfer */ + off64_t aio_offset; /* file offset */ + int aio_reqprio; /* request priority offset */ + struct sigevent aio_sigevent; /* notification type */ + int aio_lio_opcode; /* listio operation */ + aio_result_t aio_resultp; /* results */ + int aio_state; /* state flag for List I/O */ + int aio__pad[1]; /* extension padding */ +} aiocb64_t; +#else + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct aiocb64_32 { + int aio_fildes; + caddr32_t aio_buf; /* buffer location */ + uint32_t aio_nbytes; /* length of transfer */ + off64_t aio_offset; /* file offset */ + int aio_reqprio; /* request priority offset */ + struct sigevent32 aio_sigevent; /* notification type */ + int aio_lio_opcode; /* listio operation */ + aio_result32_t aio_resultp; /* results */ + int aio_state; /* state flag for List I/O */ + int aio__pad[1]; /* extension padding */ +} aiocb64_32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* !defined(_KERNEL) */ +#endif /* _LARGEFILE64_SOURCE */ + +#ifdef _SYSCALL32 +typedef struct aiocb32 { + int aio_fildes; + caddr32_t aio_buf; /* buffer location */ + uint32_t aio_nbytes; /* length of transfer */ + uint32_t aio_offset; /* file offset */ + int aio_reqprio; /* request priority offset */ + struct sigevent32 aio_sigevent; /* notification type */ + int aio_lio_opcode; /* listio operation */ + aio_result32_t aio_resultp; /* results */ + int aio_state; /* state flag for List I/O */ + int aio__pad[1]; /* extension padding */ +} aiocb32_t; + +#endif /* _SYSCALL32 */ +/* + * return values for aiocancel() + */ +#define AIO_CANCELED 0 +#define AIO_ALLDONE 1 +#define AIO_NOTCANCELED 2 + +/* + * mode values for lio_listio() + */ +#define LIO_NOWAIT 0 +#define LIO_WAIT 1 + + +/* + * listio operation codes + * + * LIO_READ and LIO_WRITE were previously defined as FREAD and FWRITE as + * defined in . However, inclusion of results + * in X/Open namespace pollution and as such is no longer included in + * this header. The values of LIO_READ and LIO_WRITE must be identical + * to the values of FREAD and FWRITE in . Any change to one + * will require a change to the other. + */ + +#define LIO_NOP 0 +#define LIO_READ 0x01 /* Must match value of FREAD in sys/file.h */ +#define LIO_WRITE 0x02 /* Must match value of FWRITE in sys/file.h */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_AIOCB_H */ diff --git a/illumos-x86_64/usr/include/sys/archsystm.h b/illumos-x86_64/usr/include/sys/archsystm.h new file mode 100644 index 00000000..6c43f2fe --- /dev/null +++ b/illumos-x86_64/usr/include/sys/archsystm.h @@ -0,0 +1,230 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_ARCHSYSTM_H +#define _SYS_ARCHSYSTM_H + +/* + * A selection of ISA-dependent interfaces + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +extern greg_t getfp(void); +extern int getpil(void); + +extern ulong_t getcr0(void); +extern void setcr0(ulong_t); +extern ulong_t getcr8(void); +extern void setcr8(ulong_t); +extern ulong_t getcr2(void); +extern void clflush_insn(caddr_t addr); +extern void mfence_insn(void); + +#if defined(__i386) +extern uint16_t getgs(void); +extern void setgs(uint16_t); + +#endif + +extern kmem_cache_t *fpsave_cachep; + +extern void cli(void); +extern void sti(void); + +extern void tenmicrosec(void); + +extern void restore_int_flag(ulong_t); +extern void intr_restore(ulong_t); +extern ulong_t clear_int_flag(void); +extern ulong_t intr_clear(void); +extern ulong_t getflags(void); +extern int interrupts_enabled(void); + +extern void int3(void); +extern void int18(void); +extern void int20(void); +extern void int_cmci(void); + +#if defined(__amd64) +extern void sys_syscall(), tr_sys_syscall(); +extern void sys_syscall32(), tr_sys_syscall32(); +extern void sys_lcall32(); +extern void sys_syscall_int(); +extern void tr_sys_syscall_int(); +extern void brand_sys_syscall(), tr_brand_sys_syscall(); +extern void brand_sys_syscall32(), tr_brand_sys_syscall32(); +extern void brand_sys_syscall_int(), tr_brand_sys_syscall_int(); +extern int update_sregs(); +extern void reset_sregs(); +#elif defined(__i386) +extern void sys_call(); +extern void tr_sys_call(); +extern void brand_sys_call(); +#endif +extern void sys_sysenter(); +extern void tr_sys_sysenter(); +extern void brand_sys_sysenter(); +extern void tr_brand_sys_sysenter(); + +extern void dosyscall(void); + +extern void bind_hwcap(void); + +extern uint16_t inw(int port); +extern uint32_t inl(int port); +extern void outw(int port, uint16_t value); +extern void outl(int port, uint32_t value); + +extern void pc_reset(void) __NORETURN; +extern void efi_reset(void) __NORETURN; +extern void reset(void) __NORETURN; +extern int goany(void); + +extern void setgregs(klwp_t *, gregset_t); +extern void getgregs(klwp_t *, gregset_t); +extern void setfpregs(klwp_t *, fpregset_t *); +extern void getfpregs(klwp_t *, fpregset_t *); + +#if defined(_SYSCALL32_IMPL) +extern void getgregs32(klwp_t *, gregset32_t); +extern void setfpregs32(klwp_t *, fpregset32_t *); +extern void getfpregs32(klwp_t *, fpregset32_t *); +#endif + +struct fpu_ctx; + +extern void fp_free(struct fpu_ctx *); +extern void fp_save(struct fpu_ctx *); +extern void fp_restore(struct fpu_ctx *); + +extern int fpu_pentium_fdivbug; + +extern void sep_save(void *); +extern void sep_restore(void *); + +extern void brand_interpositioning_enable(void *); +extern void brand_interpositioning_disable(void *); + +struct regs; + +extern int instr_size(struct regs *, caddr_t *, enum seg_rw); + +extern int enable_cbcp; /* patchable in /etc/system */ + +extern uint_t cpu_hwcap_flags; +extern uint_t cpu_freq; +extern uint64_t cpu_freq_hz; + +extern int use_sse_pagecopy; +extern int use_sse_pagezero; +extern int use_sse_copy; + +extern caddr_t i86devmap(pfn_t, pgcnt_t, uint_t); +extern page_t *page_numtopp_alloc(pfn_t pfnum); + +extern void hwblkclr(void *, size_t); +extern void hwblkpagecopy(const void *, void *); +extern void page_copy_no_xmm(void *dst, void *src); +extern void block_zero_no_xmm(void *dst, int len); +#define BLOCKZEROALIGN (4 * sizeof (void *)) + +extern void (*kcpc_hw_enable_cpc_intr)(void); + +extern void init_desctbls(void); + +extern user_desc_t *cpu_get_gdt(void); + +extern void switch_sp_and_call(void *, void (*)(uint_t, uint_t), uint_t, + uint_t); +extern hrtime_t (*gethrtimef)(void); +extern hrtime_t (*gethrtimeunscaledf)(void); +extern void (*scalehrtimef)(hrtime_t *); +extern uint64_t (*unscalehrtimef)(hrtime_t); +extern void (*gethrestimef)(timestruc_t *); + +extern void av_dispatch_softvect(uint_t); +extern void av_dispatch_autovect(uint_t); +extern uint_t atomic_btr32(uint32_t *, uint_t); +extern uint_t bsrw_insn(uint16_t); +extern int sys_rtt_common(struct regs *); +extern void fakesoftint(void); + +extern void *plat_traceback(void *); + +/* + * The following two macros are the four byte instruction sequence of stac, nop + * and clac, nop. These are used in startup_smap() and hotinline_smap() as a + * part of properly setting up the valid instructions. For more information on + * SMAP, see uts/intel/ml/copy.s, uts/i86pc/os/machdep.c and + * uts/common/os/modctl.c. + * + * Note that smap_disable and smap_enable are resolved to stubs at compile time, + * but inlined at runtime by do_hotinlines() in uts/i86pc/os/machdep.c. + */ +#define SMAP_CLAC_INSTR 0x90ca010f +#define SMAP_STAC_INSTR 0x90cb010f +extern void smap_disable(void); +extern void smap_enable(void); + +#if defined(__xpv) +extern void xen_init_callbacks(void); +extern void xen_set_callback(void (*)(void), uint_t, uint_t); +extern void xen_printf(const char *, ...); +#define cpr_dprintf xen_printf +extern int xpv_panicking; +#define IN_XPV_PANIC() (xpv_panicking > 0) +#else +extern void setup_mca(void); +extern void pat_sync(void); +extern void patch_tsc_read(int); +#if defined(__amd64) && !defined(__xpv) +extern void patch_memops(uint_t); +#endif /* defined(__amd64) && !defined(__xpv) */ +extern void setup_xfem(void); +#define cpr_dprintf prom_printf +#define IN_XPV_PANIC() (__lintzero) +#endif + +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_BOOT) +extern uint8_t inb(int port); +extern void outb(int port, uint8_t value); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ARCHSYSTM_H */ diff --git a/illumos-x86_64/usr/include/sys/ascii.h b/illumos-x86_64/usr/include/sys/ascii.h new file mode 100644 index 00000000..df44d5ea --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ascii.h @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_ASCII_H +#define _SYS_ASCII_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define A_NUL 0 +#define A_SOH 1 +#define A_STX 2 +#define A_ETX 3 +#define A_EOT 4 +#define A_ENQ 5 +#define A_ACK 6 +#define A_BEL 7 +#define A_BS 8 +#define A_HT 9 +#define A_NL 10 +#define A_LF 10 +#define A_VT 11 +#define A_FF 12 +#define A_NP 12 +#define A_CR 13 +#define A_SO 14 +#define A_SI 15 +#define A_DLE 16 +#define A_DC1 17 +#define A_DC2 18 +#define A_DC3 19 +#define A_DC4 20 +#define A_NAK 21 +#define A_SYN 22 +#define A_ETB 23 +#define A_CAN 24 +#define A_EM 25 +#define A_SUB 26 +#define A_ESC 27 +#define A_FS 28 +#define A_GS 29 +#define A_RS 30 +#define A_US 31 +#define A_DEL 127 +#define A_CSI 0x9b + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ASCII_H */ diff --git a/illumos-x86_64/usr/include/sys/asm_linkage.h b/illumos-x86_64/usr/include/sys/asm_linkage.h new file mode 100644 index 00000000..f04a1752 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/asm_linkage.h @@ -0,0 +1,330 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_ASM_LINKAGE_H +#define _SYS_ASM_LINKAGE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _ASM /* The remainder of this file is only for assembly files */ + +/* + * make annoying differences in assembler syntax go away + */ + +/* + * Why not use the 'data16' and 'addr16' prefixes .. well, the + * assembler doesn't quite believe in real mode, and thus argues with + * us about what we're trying to do. + */ +#define D16 .byte 0x66; +#define A16 .byte 0x67; + +#define _CONST(const) (const) +#define _BITNOT(const) ~_CONST(const) +#define _MUL(a, b) _CONST(a * b) + +/* + * C pointers are different sizes between i386 and amd64. + * These constants can be used to compute offsets into pointer arrays. + */ +#if defined(__amd64) +#define CLONGSHIFT 3 +#define CLONGSIZE 8 +#define CLONGMASK 7 +#elif defined(__i386) +#define CLONGSHIFT 2 +#define CLONGSIZE 4 +#define CLONGMASK 3 +#endif + +/* + * Since we know we're either ILP32 or LP64 .. + */ +#define CPTRSHIFT CLONGSHIFT +#define CPTRSIZE CLONGSIZE +#define CPTRMASK CLONGMASK + +#if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT) +#error "inconsistent shift constants" +#endif + +#if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1) +#error "inconsistent mask constants" +#endif + +#define ASM_ENTRY_ALIGN 16 + +/* + * SSE register alignment and save areas + */ + +#define XMM_SIZE 16 +#define XMM_ALIGN 16 + +#if defined(__amd64) + +#define SAVE_XMM_PROLOG(sreg, nreg) \ + subq $_CONST(_MUL(XMM_SIZE, nreg)), %rsp; \ + movq %rsp, sreg + +#define RSTOR_XMM_EPILOG(sreg, nreg) \ + addq $_CONST(_MUL(XMM_SIZE, nreg)), %rsp + +#elif defined(__i386) + +#define SAVE_XMM_PROLOG(sreg, nreg) \ + subl $_CONST(_MUL(XMM_SIZE, nreg) + XMM_ALIGN), %esp; \ + movl %esp, sreg; \ + addl $XMM_ALIGN, sreg; \ + andl $_BITNOT(XMM_ALIGN-1), sreg + +#define RSTOR_XMM_EPILOG(sreg, nreg) \ + addl $_CONST(_MUL(XMM_SIZE, nreg) + XMM_ALIGN), %esp; + +#endif /* __i386 */ + +/* + * profiling causes definitions of the MCOUNT and RTMCOUNT + * particular to the type + */ +#ifdef GPROF + +#define MCOUNT(x) \ + pushl %ebp; \ + movl %esp, %ebp; \ + call _mcount; \ + popl %ebp + +#endif /* GPROF */ + +#ifdef PROF + +#define MCOUNT(x) \ +/* CSTYLED */ \ + .lcomm .L_##x##1, 4, 4; \ + pushl %ebp; \ + movl %esp, %ebp; \ +/* CSTYLED */ \ + movl $.L_##x##1, %edx; \ + call _mcount; \ + popl %ebp + +#endif /* PROF */ + +/* + * if we are not profiling, MCOUNT should be defined to nothing + */ +#if !defined(PROF) && !defined(GPROF) +#define MCOUNT(x) +#endif /* !defined(PROF) && !defined(GPROF) */ + +#define RTMCOUNT(x) MCOUNT(x) + +/* + * Macro to define weak symbol aliases. These are similar to the ANSI-C + * #pragma weak _name = name + * except a compiler can determine type. The assembler must be told. Hence, + * the second parameter must be the type of the symbol (i.e.: function,...) + */ +#define ANSI_PRAGMA_WEAK(sym, stype) \ +/* CSTYLED */ \ + .weak _##sym; \ +/* CSTYLED */ \ + .type _##sym, @stype; \ +/* CSTYLED */ \ +_##sym = sym + +/* + * Like ANSI_PRAGMA_WEAK(), but for unrelated names, as in: + * #pragma weak sym1 = sym2 + */ +#define ANSI_PRAGMA_WEAK2(sym1, sym2, stype) \ + .weak sym1; \ + .type sym1, @stype; \ +sym1 = sym2 + +/* + * ENTRY provides the standard procedure entry code and an easy way to + * insert the calls to mcount for profiling. ENTRY_NP is identical, but + * never calls mcount. + */ +#define ENTRY(x) \ + .text; \ + .align ASM_ENTRY_ALIGN; \ + .globl x; \ + .type x, @function; \ +x: MCOUNT(x) + +#define ENTRY_NP(x) \ + .text; \ + .align ASM_ENTRY_ALIGN; \ + .globl x; \ + .type x, @function; \ +x: + +#define RTENTRY(x) \ + .text; \ + .align ASM_ENTRY_ALIGN; \ + .globl x; \ + .type x, @function; \ +x: RTMCOUNT(x) + +/* + * ENTRY2 is identical to ENTRY but provides two labels for the entry point. + */ +#define ENTRY2(x, y) \ + .text; \ + .align ASM_ENTRY_ALIGN; \ + .globl x, y; \ + .type x, @function; \ + .type y, @function; \ +/* CSTYLED */ \ +x: ; \ +y: MCOUNT(x) + +#define ENTRY_NP2(x, y) \ + .text; \ + .align ASM_ENTRY_ALIGN; \ + .globl x, y; \ + .type x, @function; \ + .type y, @function; \ +/* CSTYLED */ \ +x: ; \ +y: + + +/* + * ALTENTRY provides for additional entry points. + */ +#define ALTENTRY(x) \ + .globl x; \ + .type x, @function; \ +x: + +/* + * DGDEF and DGDEF2 provide global data declarations. + * + * DGDEF provides a word aligned word of storage. + * + * DGDEF2 allocates "sz" bytes of storage with **NO** alignment. This + * implies this macro is best used for byte arrays. + * + * DGDEF3 allocates "sz" bytes of storage with "algn" alignment. + */ +#define DGDEF2(name, sz) \ + .data; \ + .globl name; \ + .type name, @object; \ + .size name, sz; \ +name: + +#define DGDEF3(name, sz, algn) \ + .data; \ + .align algn; \ + .globl name; \ + .type name, @object; \ + .size name, sz; \ +name: + +#define DGDEF(name) DGDEF3(name, 4, 4) + +/* + * SET_SIZE trails a function and set the size for the ELF symbol table. + */ +#define SET_SIZE(x) \ + .size x, [.-x] + +/* + * NWORD provides native word value. + */ +#if defined(__amd64) + +/*CSTYLED*/ +#define NWORD quad + +#elif defined(__i386) + +#define NWORD long + +#endif /* __i386 */ + +/* + * These macros should be used when making indirect calls in the kernel. They + * will perform a jump or call to the corresponding register in a way that knows + * about retpolines and handles whether such mitigations are enabled or not. + * + * INDIRECT_JMP_REG will jump to named register. INDIRECT_CALL_REG will instead + * do a call. These macros cannot be used to dereference a register. For + * example, if you need to do something that looks like the following: + * + * call *24(%rdi) + * jmp *(%r15) + * + * You must instead first do a movq into the corresponding location. You need to + * be careful to make sure that the register that its loaded into is safe to + * use. Often that register may be saved or used elsewhere so it may not be safe + * to clobber the value. Usually, loading into %rax would be safe. These would + * turn into something like: + * + * movq 24(%rdi), %rdi; INDIRECT_CALL_REG(rdi) + * movq (%r15), %r15; INDIRECT_JMP_REG(r15) + * + * If you are trying to call a global function, then use the following pattern + * (substituting the register in question): + * + * leaq my_favorite_function(%rip), %rax + * INDIRECT_CALL_REG(rax) + * + * If you instead have a function pointer (say gethrtimef for example), then you + * need to do: + * + * movq my_favorite_function_pointer(%rip), %rax + * INDIRECT_CALL_REG(rax) + */ + +/* CSTYLED */ +#define INDIRECT_JMP_REG(reg) jmp __x86_indirect_thunk_##reg; + +/* CSTYLED */ +#define INDIRECT_CALL_REG(reg) call __x86_indirect_thunk_##reg; + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ASM_LINKAGE_H */ diff --git a/illumos-x86_64/usr/include/sys/asynch.h b/illumos-x86_64/usr/include/sys/asynch.h new file mode 100644 index 00000000..928737e7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/asynch.h @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991 by Sun Microsystems, Inc. + */ + +#ifndef _SYS_ASYNCH_H +#define _SYS_ASYNCH_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define AIO_INPROGRESS -2 /* values not set by the system */ + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname aioread aioread64 +#pragma redefine_extname aiowrite aiowrite64 +#else +#define aioread aioread64 +#define aiowrite aiowrite64 +#endif +#endif /* _FILE_OFFSET_BITS */ + +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname aioread64 aioread +#pragma redefine_extname aiowrite64 aiowrite +#else +#define aioread64 aioread +#define aiowrite64 aiowrite +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ +extern int aioread(int, caddr_t, int, off_t, int, aio_result_t *); +extern int aiowrite(int, caddr_t, int, off_t, int, aio_result_t *); +extern int aiocancel(aio_result_t *); +extern aio_result_t *aiowait(struct timeval *); + +/* transitional large file interfaces */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int aioread64(int, caddr_t, int, off64_t, int, aio_result_t *); +extern int aiowrite64(int, caddr_t, int, off64_t, int, aio_result_t *); +#endif /* _LARGEFILE64_SOURCE... */ + +#define MAXASYNCHIO 200 /* maxi.number of outstanding i/o's */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ASYNCH_H */ diff --git a/illumos-x86_64/usr/include/sys/atomic.h b/illumos-x86_64/usr/include/sys/atomic.h new file mode 100644 index 00000000..a2cb51c6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/atomic.h @@ -0,0 +1,281 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ATOMIC_H +#define _SYS_ATOMIC_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) && defined(__GNUC__) && defined(_ASM_INLINES) && \ + (defined(__i386) || defined(__amd64)) +#include +#endif + +/* + * Increment target. + */ +extern void atomic_inc_8(volatile uint8_t *); +extern void atomic_inc_uchar(volatile uchar_t *); +extern void atomic_inc_16(volatile uint16_t *); +extern void atomic_inc_ushort(volatile ushort_t *); +extern void atomic_inc_32(volatile uint32_t *); +extern void atomic_inc_uint(volatile uint_t *); +extern void atomic_inc_ulong(volatile ulong_t *); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern void atomic_inc_64(volatile uint64_t *); +#endif + +/* + * Decrement target + */ +extern void atomic_dec_8(volatile uint8_t *); +extern void atomic_dec_uchar(volatile uchar_t *); +extern void atomic_dec_16(volatile uint16_t *); +extern void atomic_dec_ushort(volatile ushort_t *); +extern void atomic_dec_32(volatile uint32_t *); +extern void atomic_dec_uint(volatile uint_t *); +extern void atomic_dec_ulong(volatile ulong_t *); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern void atomic_dec_64(volatile uint64_t *); +#endif + +/* + * Add delta to target + */ +extern void atomic_add_8(volatile uint8_t *, int8_t); +extern void atomic_add_char(volatile uchar_t *, signed char); +extern void atomic_add_16(volatile uint16_t *, int16_t); +extern void atomic_add_short(volatile ushort_t *, short); +extern void atomic_add_32(volatile uint32_t *, int32_t); +extern void atomic_add_int(volatile uint_t *, int); +extern void atomic_add_ptr(volatile void *, ssize_t); +extern void atomic_add_long(volatile ulong_t *, long); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern void atomic_add_64(volatile uint64_t *, int64_t); +#endif + +/* + * logical OR bits with target + */ +extern void atomic_or_8(volatile uint8_t *, uint8_t); +extern void atomic_or_uchar(volatile uchar_t *, uchar_t); +extern void atomic_or_16(volatile uint16_t *, uint16_t); +extern void atomic_or_ushort(volatile ushort_t *, ushort_t); +extern void atomic_or_32(volatile uint32_t *, uint32_t); +extern void atomic_or_uint(volatile uint_t *, uint_t); +extern void atomic_or_ulong(volatile ulong_t *, ulong_t); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern void atomic_or_64(volatile uint64_t *, uint64_t); +#endif + +/* + * logical AND bits with target + */ +extern void atomic_and_8(volatile uint8_t *, uint8_t); +extern void atomic_and_uchar(volatile uchar_t *, uchar_t); +extern void atomic_and_16(volatile uint16_t *, uint16_t); +extern void atomic_and_ushort(volatile ushort_t *, ushort_t); +extern void atomic_and_32(volatile uint32_t *, uint32_t); +extern void atomic_and_uint(volatile uint_t *, uint_t); +extern void atomic_and_ulong(volatile ulong_t *, ulong_t); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern void atomic_and_64(volatile uint64_t *, uint64_t); +#endif + +/* + * As above, but return the new value. Note that these _nv() variants are + * substantially more expensive on some platforms than the no-return-value + * versions above, so don't use them unless you really need to know the + * new value *atomically* (e.g. when decrementing a reference count and + * checking whether it went to zero). + */ + +/* + * Increment target and return new value. + */ +extern uint8_t atomic_inc_8_nv(volatile uint8_t *); +extern uchar_t atomic_inc_uchar_nv(volatile uchar_t *); +extern uint16_t atomic_inc_16_nv(volatile uint16_t *); +extern ushort_t atomic_inc_ushort_nv(volatile ushort_t *); +extern uint32_t atomic_inc_32_nv(volatile uint32_t *); +extern uint_t atomic_inc_uint_nv(volatile uint_t *); +extern ulong_t atomic_inc_ulong_nv(volatile ulong_t *); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern uint64_t atomic_inc_64_nv(volatile uint64_t *); +#endif + +/* + * Decrement target and return new value. + */ +extern uint8_t atomic_dec_8_nv(volatile uint8_t *); +extern uchar_t atomic_dec_uchar_nv(volatile uchar_t *); +extern uint16_t atomic_dec_16_nv(volatile uint16_t *); +extern ushort_t atomic_dec_ushort_nv(volatile ushort_t *); +extern uint32_t atomic_dec_32_nv(volatile uint32_t *); +extern uint_t atomic_dec_uint_nv(volatile uint_t *); +extern ulong_t atomic_dec_ulong_nv(volatile ulong_t *); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern uint64_t atomic_dec_64_nv(volatile uint64_t *); +#endif + +/* + * Add delta to target + */ +extern uint8_t atomic_add_8_nv(volatile uint8_t *, int8_t); +extern uchar_t atomic_add_char_nv(volatile uchar_t *, signed char); +extern uint16_t atomic_add_16_nv(volatile uint16_t *, int16_t); +extern ushort_t atomic_add_short_nv(volatile ushort_t *, short); +extern uint32_t atomic_add_32_nv(volatile uint32_t *, int32_t); +extern uint_t atomic_add_int_nv(volatile uint_t *, int); +extern void *atomic_add_ptr_nv(volatile void *, ssize_t); +extern ulong_t atomic_add_long_nv(volatile ulong_t *, long); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern uint64_t atomic_add_64_nv(volatile uint64_t *, int64_t); +#endif + +/* + * logical OR bits with target and return new value. + */ +extern uint8_t atomic_or_8_nv(volatile uint8_t *, uint8_t); +extern uchar_t atomic_or_uchar_nv(volatile uchar_t *, uchar_t); +extern uint16_t atomic_or_16_nv(volatile uint16_t *, uint16_t); +extern ushort_t atomic_or_ushort_nv(volatile ushort_t *, ushort_t); +extern uint32_t atomic_or_32_nv(volatile uint32_t *, uint32_t); +extern uint_t atomic_or_uint_nv(volatile uint_t *, uint_t); +extern ulong_t atomic_or_ulong_nv(volatile ulong_t *, ulong_t); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern uint64_t atomic_or_64_nv(volatile uint64_t *, uint64_t); +#endif + +/* + * logical AND bits with target and return new value. + */ +extern uint8_t atomic_and_8_nv(volatile uint8_t *, uint8_t); +extern uchar_t atomic_and_uchar_nv(volatile uchar_t *, uchar_t); +extern uint16_t atomic_and_16_nv(volatile uint16_t *, uint16_t); +extern ushort_t atomic_and_ushort_nv(volatile ushort_t *, ushort_t); +extern uint32_t atomic_and_32_nv(volatile uint32_t *, uint32_t); +extern uint_t atomic_and_uint_nv(volatile uint_t *, uint_t); +extern ulong_t atomic_and_ulong_nv(volatile ulong_t *, ulong_t); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern uint64_t atomic_and_64_nv(volatile uint64_t *, uint64_t); +#endif + +/* + * If *arg1 == arg2, set *arg1 = arg3; return old value + */ +extern uint8_t atomic_cas_8(volatile uint8_t *, uint8_t, uint8_t); +extern uchar_t atomic_cas_uchar(volatile uchar_t *, uchar_t, uchar_t); +extern uint16_t atomic_cas_16(volatile uint16_t *, uint16_t, uint16_t); +extern ushort_t atomic_cas_ushort(volatile ushort_t *, ushort_t, ushort_t); +extern uint32_t atomic_cas_32(volatile uint32_t *, uint32_t, uint32_t); +extern uint_t atomic_cas_uint(volatile uint_t *, uint_t, uint_t); +extern void *atomic_cas_ptr(volatile void *, void *, void *); +extern ulong_t atomic_cas_ulong(volatile ulong_t *, ulong_t, ulong_t); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern uint64_t atomic_cas_64(volatile uint64_t *, uint64_t, uint64_t); +#endif + +/* + * Swap target and return old value + */ +extern uint8_t atomic_swap_8(volatile uint8_t *, uint8_t); +extern uchar_t atomic_swap_uchar(volatile uchar_t *, uchar_t); +extern uint16_t atomic_swap_16(volatile uint16_t *, uint16_t); +extern ushort_t atomic_swap_ushort(volatile ushort_t *, ushort_t); +extern uint32_t atomic_swap_32(volatile uint32_t *, uint32_t); +extern uint_t atomic_swap_uint(volatile uint_t *, uint_t); +extern void *atomic_swap_ptr(volatile void *, void *); +extern ulong_t atomic_swap_ulong(volatile ulong_t *, ulong_t); +#if defined(_KERNEL) || defined(_INT64_TYPE) +extern uint64_t atomic_swap_64(volatile uint64_t *, uint64_t); +#endif + +/* + * Perform an exclusive atomic bit set/clear on a target. + * Returns 0 if bit was sucessfully set/cleared, or -1 + * if the bit was already set/cleared. + */ +extern int atomic_set_long_excl(volatile ulong_t *, uint_t); +extern int atomic_clear_long_excl(volatile ulong_t *, uint_t); + +/* + * Generic memory barrier used during lock entry, placed after the + * memory operation that acquires the lock to guarantee that the lock + * protects its data. No stores from after the memory barrier will + * reach visibility, and no loads from after the barrier will be + * resolved, before the lock acquisition reaches global visibility. + */ +extern void membar_enter(void); + +/* + * Generic memory barrier used during lock exit, placed before the + * memory operation that releases the lock to guarantee that the lock + * protects its data. All loads and stores issued before the barrier + * will be resolved before the subsequent lock update reaches visibility. + */ +extern void membar_exit(void); + +/* + * Arrange that all stores issued before this point in the code reach + * global visibility before any stores that follow; useful in producer + * modules that update a data item, then set a flag that it is available. + * The memory barrier guarantees that the available flag is not visible + * earlier than the updated data, i.e. it imposes store ordering. + */ +extern void membar_producer(void); + +/* + * Arrange that all loads issued before this point in the code are + * completed before any subsequent loads; useful in consumer modules + * that check to see if data is available and read the data. + * The memory barrier guarantees that the data is not sampled until + * after the available flag has been seen, i.e. it imposes load ordering. + */ +extern void membar_consumer(void); + +#if defined(_KERNEL) + +#if defined(_LP64) || defined(_ILP32) +#define atomic_add_ip atomic_add_long +#define atomic_add_ip_nv atomic_add_long_nv +#define casip atomic_cas_ulong +#endif + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ATOMIC_H */ diff --git a/illumos-x86_64/usr/include/sys/attr.h b/illumos-x86_64/usr/include/sys/attr.h new file mode 100644 index 00000000..57c579bc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/attr.h @@ -0,0 +1,155 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_ATTR_H +#define _SYS_ATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +#include +#include +#include +#endif +#include + +/* Attribute names for nvlist's */ +#define A_CRTIME "crtime" +#define A_HIDDEN "hidden" +#define A_SYSTEM "system" +#define A_READONLY "readonly" +#define A_ARCHIVE "archive" +#define A_NOUNLINK "nounlink" +#define A_IMMUTABLE "immutable" +#define A_APPENDONLY "appendonly" +#define A_NODUMP "nodump" +#define A_OPAQUE "opaque" +#define A_AV_QUARANTINED "av_quarantined" +#define A_AV_MODIFIED "av_modified" +#define A_FSID "fsid" +#define A_AV_SCANSTAMP "av_scanstamp" +#define A_OWNERSID "ownersid" +#define A_GROUPSID "groupsid" +#define A_REPARSE_POINT "reparse" +#define A_GEN "generation" +#define A_OFFLINE "offline" +#define A_SPARSE "sparse" + +/* Attribute option for utilities */ +#define O_HIDDEN "H" +#define O_SYSTEM "S" +#define O_READONLY "R" +#define O_ARCHIVE "A" +#define O_NOUNLINK "u" +#define O_IMMUTABLE "i" +#define O_APPENDONLY "a" +#define O_NODUMP "d" +#define O_AV_QUARANTINED "q" +#define O_AV_MODIFIED "m" +#define O_REPARSE_POINT "r" +#define O_OFFLINE "O" +#define O_SPARSE "s" +#define O_NONE "" + +/* ownersid and groupsid are composed of two nvpairs */ +#define SID_DOMAIN "domain" +#define SID_RID "rid" + +typedef enum { + F_ATTR_INVAL = -1, + F_ARCHIVE, + F_HIDDEN, + F_READONLY, + F_SYSTEM, + F_APPENDONLY, + F_NODUMP, + F_IMMUTABLE, + F_AV_MODIFIED, + F_OPAQUE, + F_AV_SCANSTAMP, + F_AV_QUARANTINED, + F_NOUNLINK, + F_CRTIME, + F_OWNERSID, + F_GROUPSID, + F_FSID, + F_REPARSE, + F_GEN, + F_OFFLINE, + F_SPARSE, + F_ATTR_ALL +} f_attr_t; + +#define VIEW_READONLY "SUNWattr_ro" +#define VIEW_READWRITE "SUNWattr_rw" + +/* + * These are the supported views into the virtual sysattr directory. + * Additional views should be added before XATTR_VIEW_LAST. + */ +typedef enum { + XATTR_VIEW_INVALID = -1, + XATTR_VIEW_READONLY, + XATTR_VIEW_READWRITE, + XATTR_VIEW_LAST +} xattr_view_t; + +typedef struct { + char *x_name; + char *x_option; + xattr_view_t x_xattr_view; + data_type_t x_data_type; +} xattr_entry_t; + +#ifdef _KERNEL +#define XATTR_MAXFIDSZ NFS_FHMAXDATA + +typedef struct { + uint16_t len; + char parent_fid[XATTR_MAXFIDSZ]; + uint16_t parent_len; + uint16_t dir_offset; +} xattr_fid_t; + +#define XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t)) + +int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *); +int xattr_sysattr_casechk(char *name); +#endif + +int attr_count(void); +const char *attr_to_name(f_attr_t); +const char *attr_to_option(f_attr_t); +f_attr_t name_to_attr(const char *name); +f_attr_t option_to_attr(const char *option); +xattr_view_t attr_to_xattr_view(f_attr_t attr); +data_type_t attr_to_data_type(f_attr_t attr); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ATTR_H */ diff --git a/illumos-x86_64/usr/include/sys/autoconf.h b/illumos-x86_64/usr/include/sys/autoconf.h new file mode 100644 index 00000000..2bde2a7b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/autoconf.h @@ -0,0 +1,312 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_AUTOCONF_H +#define _SYS_AUTOCONF_H + +/* Derived from autoconf.h, SunOS 4.1.1 1.15 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This defines a parallel structure to the devops list. + */ + +#include +#include +#include +#include +#include +#include +#include + +struct devnames { + char *dn_name; /* Name of this driver */ + int dn_flags; /* per-driver flags, see below */ + struct par_list *dn_pl; /* parent list, for making devinfos */ + kmutex_t dn_lock; /* Per driver lock (see below) */ + dev_info_t *dn_head; /* Head of instance list */ + int dn_instance; /* Next instance no. to assign */ + void *dn_inlist; /* instance # nodes for this driver */ + ddi_prop_list_t *dn_global_prop_ptr; /* per-driver global properties */ + kcondvar_t dn_wait; /* for ddi_hold_installed_driver */ + kthread_id_t dn_busy_thread; /* for debugging only */ + struct mperm *dn_mperm; /* minor permissions */ + struct mperm *dn_mperm_wild; /* default minor permission */ + struct mperm *dn_mperm_clone; /* minor permission, clone use */ + int dn_pinstance; /* Preassign instance boundary */ +}; + +/* + * dn_lock is used to protect the driver initialization/loading + * from fini/unloading. It also protects each drivers devops + * reference count, the dn_flags, and the dn_head linked list of + * driver instances. The busy_changing bit is used to avoid + * recursive calls to ddi_hold_installed_driver to hold the + * same driver. + */ + +/* + * Defines for dn_flags. + */ +#define DN_CONF_PARSED 0x0001 +#define DN_DRIVER_BUSY 0x0002 /* for ddi_hold_installed_driver */ +#define DN_DRIVER_INACTIVE 0x0004 /* driver not active */ +#define DN_DRIVER_HELD 0x0020 /* held via ddi_hold_installed_driver */ +#define DN_TAKEN_GETUDEV 0x0040 /* getudev() used this entry */ +#define DN_DRIVER_REMOVED 0x0080 /* driver entry removed */ + +#define DN_FORCE_ATTACH 0x0100 /* DDI_FORCEATTACH prop */ +#define DN_LEAF_DRIVER 0x0200 /* this is a leaf driver */ +#define DN_NETWORK_DRIVER 0x0400 /* network interface driver */ +#define DN_NO_AUTODETACH 0x0800 /* no autodetach */ +#define DN_GLDV3_DRIVER 0x1000 /* gldv3 (Nemo) driver */ +#define DN_PHCI_DRIVER 0x2000 /* pHCI driver */ +#define DN_OPEN_RETURNS_EINTR 0x4000 /* DDI_OPEN_RETURNS_EINTR prop */ +#define DN_SCSI_SIZE_CLEAN 0x8000 /* driver is scsi_size_clean() */ +#define DN_NETWORK_PHYSDRIVER 0x10000 /* physical network driver */ +#define DN_DEVID_REGISTRANT 0x20000 /* ddi-devid-registrant prop */ + +#ifdef _KERNEL + +/* + * Debugging flags and macros + */ +#define DDI_AUDIT 0x0001 +#define DDI_DEBUG 0x0002 +#define DDI_MTCONFIG 0x0004 +#define DDI_DEBUG_BOOTMOD 0x0008 /* module loading to mount root */ +#define DDI_DEBUG_COMPAT 0x0010 /* ddi_hold_install_driver */ +#define LDI_DBG_OPENCLOSE 0x0020 /* ldi open/close info */ +#define LDI_DBG_ALLOCFREE 0x0040 /* ldi ident alloc/free info */ +#define LDI_DBG_STREAMS 0x0080 /* ldi streams link/unlink */ +#define LDI_DBG_EVENTCB 0x0100 /* ldi event callback info */ +#define DDI_INTR_API 0x0200 /* interrupt interface messages */ +#define DDI_INTR_IMPL 0x0400 /* interrupt implementation msgs */ +#define DDI_INTR_NEXUS 0x0800 /* interrupt messages from nexuses */ +#define DDI_DBG_RETIRE 0x1000 /* Retire related messages */ +#define DDI_DBG_RTR_VRBOSE 0x2000 /* Verbose Retire messages */ +#define DDI_DBG_RTR_TRACE 0x4000 /* Trace Retire messages */ +#define LDI_EV_DEBUG 0x8000 /* LDI events debug messages */ +#define LDI_EV_TRACE 0x10000 /* LDI events trace messages */ +#define DDI_INTR_IRM 0x20000 /* interrupt resource management */ +#define DDI_HP_API 0x40000 /* Hotplug interface messages */ +#define DDI_HP_IMPL 0x80000 /* Hotplug implementation msgs */ +#define DDI_HP_NEXUS 0x100000 /* Hotplug messages from nexuses */ +#define DDI_MP_DEBUG 0x200000 /* ddi-mp translations */ + +extern int ddidebug; + +#ifdef DEBUG +#define NDI_CONFIG_DEBUG(args) if (ddidebug & DDI_DEBUG) cmn_err args +#define BMDPRINTF(args) if (ddidebug & DDI_DEBUG_BOOTMOD) printf args +#define DCOMPATPRINTF(args) if (ddidebug & DDI_DEBUG_COMPAT) cmn_err args +#define LDI_OPENCLOSE(args) if (ddidebug & LDI_DBG_OPENCLOSE) cmn_err args +#define LDI_ALLOCFREE(args) if (ddidebug & LDI_DBG_ALLOCFREE) cmn_err args +#define LDI_STREAMS_LNK(args) if (ddidebug & LDI_DBG_STREAMS) cmn_err args +#define LDI_EVENTCB(args) if (ddidebug & LDI_DBG_EVENTCB) cmn_err args +#define DDI_INTR_APIDBG(args) if (ddidebug & DDI_INTR_API) cmn_err args +#define DDI_INTR_IMPLDBG(args) if (ddidebug & DDI_INTR_IMPL) cmn_err args +#define DDI_INTR_NEXDBG(args) if (ddidebug & DDI_INTR_NEXUS) cmn_err args +#define RIO_DEBUG(args) if (ddidebug & DDI_DBG_RETIRE) cmn_err args +#define RIO_VERBOSE(args) if (ddidebug & DDI_DBG_RTR_VRBOSE) cmn_err args +#define RIO_TRACE(args) if (ddidebug & DDI_DBG_RTR_TRACE) cmn_err args +#define LDI_EVDBG(args) if (ddidebug & LDI_EV_DEBUG) cmn_err args +#define LDI_EVTRC(args) if (ddidebug & LDI_EV_TRACE) cmn_err args +#define DDI_INTR_IRMDBG(args) if (ddidebug & DDI_INTR_IRM) cmn_err args +#define DDI_HP_APIDBG(args) if (ddidebug & DDI_HP_API) cmn_err args +#define DDI_HP_IMPLDBG(args) if (ddidebug & DDI_HP_IMPL) cmn_err args +#define DDI_HP_NEXDBG(args) if (ddidebug & DDI_HP_NEXUS) cmn_err args +#else +#define NDI_CONFIG_DEBUG(args) +#define BMDPRINTF(args) +#define DCOMPATPRINTF(args) +#define LDI_OPENCLOSE(args) +#define LDI_ALLOCFREE(args) +#define LDI_STREAMS_LNK(args) +#define LDI_EVENTCB(args) +#define DDI_INTR_APIDBG(args) +#define DDI_INTR_IMPLDBG(args) +#define DDI_INTR_NEXDBG(args) +#define RIO_DEBUG(args) if (ddidebug & DDI_DBG_RETIRE) cmn_err args +#define RIO_VERBOSE(args) if (ddidebug & DDI_DBG_RTR_VRBOSE) cmn_err args +#define RIO_TRACE(args) if (ddidebug & DDI_DBG_RTR_TRACE) cmn_err args +#define LDI_EVDBG(args) if (ddidebug & LDI_EV_DEBUG) cmn_err args +#define LDI_EVTRC(args) if (ddidebug & LDI_EV_TRACE) cmn_err args +#define DDI_INTR_IRMDBG(args) +#define DDI_HP_APIDBG(args) +#define DDI_HP_IMPLDBG(args) +#define DDI_HP_NEXDBG(args) +#endif +#define DDI_MP_DBG(args) if (ddidebug & DDI_MP_DEBUG) cmn_err args + + +/* + * DDI configuration logs + */ +#define DDI_STACK_DEPTH 14 + +typedef struct devinfo_audit { + dev_info_t *da_devinfo; /* address of devinfo node */ + hrtime_t da_timestamp; /* audit time */ + kthread_id_t da_thread; /* thread of transaction */ + struct devinfo_audit *da_lastlog; /* last log of state change */ + ddi_node_state_t da_node_state; /* devinfo state at log time */ + int da_device_state; /* device state */ + int da_depth; + pc_t da_stack[DDI_STACK_DEPTH]; +} devinfo_audit_t; + +typedef struct { + kmutex_t dh_lock; + int dh_max; + int dh_curr; + int dh_hits; + devinfo_audit_t dh_entry[1]; +} devinfo_log_header_t; + +struct di_cache { + uint32_t cache_valid; /* no lock needed - field atomic updt */ + kmutex_t cache_lock; /* protects fields below */ + void *cache_data; + size_t cache_size; +}; + +extern struct di_cache di_cache; +extern int di_cache_debug; +extern volatile ulong_t devtree_gen; + +/* + * Special dev_info nodes + */ +#define PSEUDO_PATH "/"DEVI_PSEUDO_NEXNAME +#define CLONE_PATH PSEUDO_PATH"/clone@0" + +#define DI_CACHE_FILE "/etc/devices/snapshot_cache" +#define DI_CACHE_TEMP DI_CACHE_FILE".tmp" + +extern dev_info_t *options_dip; +extern dev_info_t *pseudo_dip; +extern dev_info_t *clone_dip; +extern major_t clone_major; +extern major_t mm_major; +extern major_t nulldriver_major; + +extern struct devnames *devnamesp; +extern struct devnames orphanlist; + +extern struct dev_ops nodev_ops, mod_nodev_ops; + +/* + * Obsolete interface, no longer used, to be removed. + * Retained only for driver compatibility. + */ +extern krwlock_t devinfo_tree_lock; /* obsolete */ + +/* + * Acquires dn_lock, as above. + */ +#define LOCK_DEV_OPS(lp) mutex_enter((lp)) +#define UNLOCK_DEV_OPS(lp) mutex_exit((lp)) + +/* + * Not to be used without obtaining the per-driver lock. + */ +#define INCR_DEV_OPS_REF(opsp) (opsp)->devo_refcnt++ +#define DECR_DEV_OPS_REF(opsp) (opsp)->devo_refcnt-- +#define CB_DRV_INSTALLED(opsp) ((opsp) != &nodev_ops && \ + (opsp) != &mod_nodev_ops) +#define DRV_UNLOADABLE(opsp) ((opsp)->devo_refcnt == 0) +#define DEV_OPS_HELD(opsp) ((opsp)->devo_refcnt > 0) +#define NEXUS_DRV(opsp) ((opsp)->devo_bus_ops != NULL) +#define NETWORK_DRV(maj) (devnamesp[(maj)].dn_flags & DN_NETWORK_DRIVER) +#define GLDV3_DRV(maj) (devnamesp[(maj)].dn_flags & DN_GLDV3_DRIVER) +#define NETWORK_PHYSDRV(maj) \ + (devnamesp[(maj)].dn_flags & DN_NETWORK_PHYSDRIVER) + +extern void impl_rem_dev_props(dev_info_t *); +extern void add_class(char *, char *); + +extern int make_mbind(char *, int, char *, struct bind **); +extern void delete_mbind(const char *, struct bind **); +extern void purge_mbind(int, struct bind **); + +extern void configure(void); +#if defined(__sparc) +extern void setcputype(void); +#endif +extern void devtree_freeze(void); +extern void reset_leaves(void); +extern void quiesce_devices(dev_info_t *, void *); + +extern void setup_ddi(void); +extern void setup_ddi_poststartup(void); +extern void impl_ddi_callback_init(void); +extern void impl_fix_props(dev_info_t *, dev_info_t *, char *, int, caddr_t); +extern int impl_check_cpu(dev_info_t *); +extern int check_status(int, char *, dev_info_t *); + +extern int exclude_settrap(int); +extern int exclude_level(int); + +extern major_t path_to_major(char *); +extern void i_ddi_node_cache_init(void); +extern dev_info_t *i_ddi_alloc_node(dev_info_t *, const char *, pnode_t, int, + ddi_prop_t *, int); +extern void i_ddi_forceattach_drivers(void); +extern int i_ddi_io_initialized(void); +extern dev_info_t *i_ddi_create_branch(dev_info_t *, int); +extern void i_ddi_add_devimap(dev_info_t *dip); +extern void i_ddi_di_cache_invalidate(void); +extern void i_ddi_di_cache_free(struct di_cache *cache); + +/* devname_state - for /dev to denote reconfig and system available */ +#define DS_RECONFIG 0x01 /* reconfig boot */ +#define DS_SYSAVAIL 0x02 /* implicit reconfig enabled */ + +extern int i_ddi_sysavail(void); +extern int i_ddi_reconfig(void); +extern void i_ddi_set_sysavail(void); +extern void i_ddi_set_reconfig(void); + +/* I/O retire related */ +extern int e_ddi_retire_device(char *path, char **cons_array); +extern int e_ddi_unretire_device(char *path); +extern int e_ddi_mark_retiring(dev_info_t *dip, void *arg); +extern int e_ddi_retire_notify(dev_info_t *dip, void *arg); +extern int e_ddi_retire_finalize(dev_info_t *dip, void *arg); +extern void e_ddi_degrade_finalize(dev_info_t *dip); +extern void e_ddi_undegrade_finalize(dev_info_t *dip); + +extern int check_driver_quiesce(dev_info_t *dip, void *arg); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_AUTOCONF_H */ diff --git a/illumos-x86_64/usr/include/sys/auxv.h b/illumos-x86_64/usr/include/sys/auxv.h new file mode 100644 index 00000000..203b884c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/auxv.h @@ -0,0 +1,252 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2022 Oxide Computer Company + */ + +#ifndef _SYS_AUXV_H +#define _SYS_AUXV_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_ASM) +typedef struct +{ + int a_type; + union { + long a_val; + void *a_ptr; + void (*a_fcn)(); + } a_un; +} auxv_t; + +#if defined(_SYSCALL32) + +typedef struct { + int32_t a_type; + union { + int32_t a_val; + caddr32_t a_ptr; + caddr32_t a_fcn; + } a_un; +} auxv32_t; + +#endif /* _SYSCALL32 */ + +#endif /* _ASM */ + +#define AT_NULL 0 +#define AT_IGNORE 1 +#define AT_EXECFD 2 +#define AT_PHDR 3 /* &phdr[0] */ +#define AT_PHENT 4 /* sizeof(phdr[0]) */ +#define AT_PHNUM 5 /* # phdr entries */ +#define AT_PAGESZ 6 /* getpagesize(2) */ +#define AT_BASE 7 /* ld.so base addr */ +#define AT_FLAGS 8 /* processor flags */ +#define AT_ENTRY 9 /* a.out entry point */ + +/* First introduced on Linux */ +#define AT_RANDOM 25 /* address of 16 random bytes */ + +/* + * These relate to the original PPC ABI document; Linux reused + * the values for other things (see below), so disambiguation of + * these values may require additional context in PPC binaries. + * + * AT_DCACHEBSIZE 10 smallest data cache block size + * AT_ICACHEBSIZE 11 smallest instruction cache block size + * AT_UCACHEBSIZE 12 smallest unified cache block size + * + * These are the values from LSB 1.3, the first five are also described + * in the draft amd64 ABI. + * + * At the time of writing, illumos doesn't place any of these values into the + * aux vector, except where noted. We do similar things via AT_SUN_ values. + * + * AT_NOTELF 10 program is not ELF? + * AT_UID 11 real user id (provided in LX) + * AT_EUID 12 effective user id (provided in LX) + * AT_GID 13 real group id (provided in LX) + * AT_EGID 14 effective group id (provided in LX) + * + * AT_PLATFORM 15 + * AT_HWCAP 16 + * AT_CLKTCK 17 c.f. _SC_CLK_TCK (provided in LX) + * AT_FPUCW 18 + * + * AT_DCACHEBSIZE 19 (moved from 10) + * AT_ICACHEBSIZE 20 (moved from 11) + * AT_UCACHEBSIZE 21 (moved from 12) + * + * AT_IGNOREPPC 22 + * + * On Linux: + * AT_* values 18 through 22 are reserved + * AT_SECURE 23 secure mode boolean (provided in LX) + * AT_BASE_PLATFORM 24 string identifying real platform, may + * differ from AT_PLATFORM. + * AT_HWCAP2 26 extension of AT_HWCAP + * AT_EXECFN 31 filename of program + * AT_SYSINFO 32 + * AT_SYSINFO_EHDR 33 The vDSO location + */ + +/* + * Sun extensions begin here + */ +#define AT_SUN_UID 2000 /* effective user id */ +#define AT_SUN_RUID 2001 /* real user id */ +#define AT_SUN_GID 2002 /* effective group id */ +#define AT_SUN_RGID 2003 /* real group id */ + +/* + * The following attributes are specific to the + * kernel implementation of the linker/loader. + */ +#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ +#define AT_SUN_LDSHDR 2005 /* dynamic linker's section headers */ +#define AT_SUN_LDNAME 2006 /* name of dynamic linker */ +#define AT_SUN_LPAGESZ 2007 /* large pagesize */ +/* + * The following aux vector provides a null-terminated platform + * identification string. This information is the same as provided + * by sysinfo(2) when invoked with the command SI_PLATFORM. + */ +#define AT_SUN_PLATFORM 2008 /* platform name */ + +/* + * These attributes communicate performance -hints- about processor + * hardware capabilities that might be useful to library implementations. + */ +#define AT_SUN_HWCAP 2009 +#define AT_SUN_HWCAP2 2023 +#define AT_SUN_HWCAP3 2029 + +#if defined(_KERNEL) +/* + * User info regarding machine attributes, respectively reported to native and + * non-native user apps. + */ +extern uint_t auxv_hwcap; +extern uint_t auxv_hwcap_2; +extern uint_t auxv_hwcap_3; +#if defined(_SYSCALL32) +extern uint_t auxv_hwcap32; +extern uint_t auxv_hwcap32_2; +extern uint_t auxv_hwcap32_3; +#endif /* _SYSCALL32 */ +#else +extern uint_t getisax(uint32_t *, uint_t); +#endif /* _KERNEL */ + +#define AT_SUN_IFLUSH 2010 /* flush icache? */ +#define AT_SUN_CPU 2011 /* cpu name */ + +/* + * The following aux vector provides a pointer to a null-terminated + * path name, a copy of the path name passed to the exec() system + * call but that has had all symlinks resolved (see resolvepath(2)). + */ +#define AT_SUN_EXECNAME 2014 /* exec() path name */ + +#define AT_SUN_MMU 2015 /* mmu module name */ +#define AT_SUN_LDDATA 2016 /* dynamic linkers data segment */ + +#define AT_SUN_AUXFLAGS 2017 /* AF_SUN_ flags passed from the kernel */ + +/* + * Used to indicate to the runtime linker the name of the emulation binary, + * if one is being used. For brands, this is the name of the brand library. + */ +#define AT_SUN_EMULATOR 2018 + +#define AT_SUN_BRANDNAME 2019 + +/* + * Aux vectors available for brand modules. + */ +#define AT_SUN_BRAND_AUX1 2020 +#define AT_SUN_BRAND_AUX2 2021 +#define AT_SUN_BRAND_AUX3 2022 +#define AT_SUN_BRAND_AUX4 2025 +#define AT_SUN_BRAND_NROOT 2024 + +/* + * Aux vector for comm page + */ +#define AT_SUN_COMMPAGE 2026 + +/* + * These two AUX vectors are generally used to define information about the FPU. + * These values are currently only used on the x86 platform. + */ +#define AT_SUN_FPTYPE 2027 +#define AT_SUN_FPSIZE 2028 + +/* + * The kernel is in a better position to determine whether a process needs to + * ignore dangerous LD environment variables. If set, this flags tells + * ld.so.1 to run "secure" and ignore the the environment. + */ +#define AF_SUN_SETUGID 0x00000001 + +/* + * If set, this flag indicates that hardware capabilites can be verified + * against the AT_SUN_HWCAP value. + */ +#define AF_SUN_HWCAPVERIFY 0x00000002 + +/* + * If set, this flag indicates that the the linker should not initialize + * any of its link maps as primary link wrt the unified libc threading + * interfaces. + */ +#define AF_SUN_NOPLM 0x00000004 + +#ifdef __cplusplus +} +#endif + +#if defined(_AUXV_TARGET_ALL) || defined(_AUXV_TARGET_SPARC) || defined(__sparc) +#include +#endif + +#if defined(_AUXV_TARGET_ALL) || defined(_AUXV_TARGET_386) || defined(__x86) +#include +#endif + +#endif /* _SYS_AUXV_H */ diff --git a/illumos-x86_64/usr/include/sys/auxv_386.h b/illumos-x86_64/usr/include/sys/auxv_386.h new file mode 100644 index 00000000..d8e6938b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/auxv_386.h @@ -0,0 +1,158 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2019, Joyent, Inc. + * Copyright 2022 Oxide Computer Company + */ + +#ifndef _SYS_AUXV_386_H +#define _SYS_AUXV_386_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flags used in AT_SUN_HWCAP elements to describe various userland + * instruction set extensions available on different processors. + * The basic assumption is that of the i386 ABI; that is, i386 plus i387 + * floating point. + * + * Note that if a given bit is set; the implication is that the kernel + * provides all the underlying architectural support for the correct + * functioning of the extended instruction(s). + */ +#define AV_386_FPU 0x00001 /* x87-style floating point */ +#define AV_386_TSC 0x00002 /* rdtsc insn */ +#define AV_386_CX8 0x00004 /* cmpxchg8b insn */ +#define AV_386_SEP 0x00008 /* sysenter and sysexit */ +#define AV_386_AMD_SYSC 0x00010 /* AMD's syscall and sysret */ +#define AV_386_CMOV 0x00020 /* conditional move insns */ +#define AV_386_MMX 0x00040 /* MMX insns */ +#define AV_386_AMD_MMX 0x00080 /* AMD's MMX insns */ +#define AV_386_AMD_3DNow 0x00100 /* AMD's 3Dnow! insns */ +#define AV_386_AMD_3DNowx 0x00200 /* AMD's 3Dnow! extended insns */ +#define AV_386_FXSR 0x00400 /* fxsave and fxrstor */ +#define AV_386_SSE 0x00800 /* SSE insns and regs */ +#define AV_386_SSE2 0x01000 /* SSE2 insns and regs */ + /* 0x02000 withdrawn - do not assign */ +#define AV_386_SSE3 0x04000 /* SSE3 insns and regs */ + /* 0x08000 withdrawn - do not assign */ +#define AV_386_CX16 0x10000 /* cmpxchg16b insn */ +#define AV_386_AHF 0x20000 /* lahf/sahf insns */ +#define AV_386_TSCP 0x40000 /* rdtscp instruction */ +#define AV_386_AMD_SSE4A 0x80000 /* AMD's SSE4A insns */ +#define AV_386_POPCNT 0x100000 /* POPCNT insn */ +#define AV_386_AMD_LZCNT 0x200000 /* AMD's LZCNT insn */ +#define AV_386_SSSE3 0x400000 /* Intel SSSE3 insns */ +#define AV_386_SSE4_1 0x800000 /* Intel SSE4.1 insns */ +#define AV_386_SSE4_2 0x1000000 /* Intel SSE4.2 insns */ +#define AV_386_MOVBE 0x2000000 /* Intel MOVBE insns */ +#define AV_386_AES 0x4000000 /* Intel AES insns */ +#define AV_386_PCLMULQDQ 0x8000000 /* Intel PCLMULQDQ insn */ +#define AV_386_XSAVE 0x10000000 /* Intel XSAVE/XRSTOR insns */ +#define AV_386_AVX 0x20000000 /* Intel AVX insns */ +#define AV_386_VMX 0x40000000 /* Intel VMX support */ +#define AV_386_AMD_SVM 0x80000000 /* AMD SVM support */ + +#define FMT_AV_386 \ + "\020" \ + "\040svm\037vmx\036avx\035xsave" \ + "\034pclmulqdq\033aes" \ + "\032movbe\031sse4.2" \ + "\030sse4.1\027ssse3\026amd_lzcnt\025popcnt" \ + "\024amd_sse4a\023tscp\022ahf\021cx16" \ + "\017sse3\015sse2\014sse\013fxsr\012amd3dx\011amd3d" \ + "\010amdmmx\07mmx\06cmov\05amdsysc\04sep\03cx8\02tsc\01fpu" + +/* + * Flags used in AT_SUN_HWCAP2 elements + */ +#define AV_386_2_F16C 0x00000001 /* F16C half percision extensions */ +#define AV_386_2_RDRAND 0x00000002 /* RDRAND insn */ +#define AV_386_2_BMI1 0x00000004 /* BMI1 insns */ +#define AV_386_2_BMI2 0x00000008 /* BMI2 insns */ +#define AV_386_2_FMA 0x00000010 /* FMA insns */ +#define AV_386_2_AVX2 0x00000020 /* AVX2 insns */ +#define AV_386_2_ADX 0x00000040 /* ADX insns */ +#define AV_386_2_RDSEED 0x00000080 /* RDSEED insn */ +#define AV_386_2_AVX512F 0x00000100 /* AVX512 foundation insns */ +#define AV_386_2_AVX512DQ 0x00000200 /* AVX512DQ insns */ +#define AV_386_2_AVX512IFMA 0x00000400 /* AVX512IFMA insns */ +#define AV_386_2_AVX512PF 0x00000800 /* AVX512PF insns */ +#define AV_386_2_AVX512ER 0x00001000 /* AVX512ER insns */ +#define AV_386_2_AVX512CD 0x00002000 /* AVX512CD insns */ +#define AV_386_2_AVX512BW 0x00004000 /* AVX512BW insns */ +#define AV_386_2_AVX512VL 0x00008000 /* AVX512VL insns */ +#define AV_386_2_AVX512VBMI 0x00010000 /* AVX512VBMI insns */ +#define AV_386_2_AVX512VPOPCDQ 0x00020000 /* AVX512VPOPCNTDQ insns */ +#define AV_386_2_AVX512_4NNIW 0x00040000 /* AVX512 4NNIW insns */ +#define AV_386_2_AVX512_4FMAPS 0x00080000 /* AVX512 4FMAPS insns */ +#define AV_386_2_SHA 0x00100000 /* SHA insns */ +#define AV_386_2_FSGSBASE 0x00200000 /* FSBASE/GSBASE */ +#define AV_386_2_CLFLUSHOPT 0x00400000 /* CLFLUSHOPT instr */ +#define AV_386_2_CLWB 0x00800000 /* CLWB insn */ +#define AV_386_2_MONITORX 0x01000000 /* MONITORX insns */ +#define AV_386_2_CLZERO 0x02000000 /* CLZERO */ +#define AV_386_2_AVX512_VNNI 0x04000000 /* AVX512_VNNI */ +#define AV_386_2_VPCLMULQDQ 0x08000000 /* VPCLMULQDQ */ +#define AV_386_2_VAES 0x10000000 /* VAES */ +#define AV_386_2_GFNI 0x20000000 /* GFNI */ +#define AV_386_2_AVX512_VP2INT 0x40000000 /* AVX512 VP2INTERESECT */ +#define AV_386_2_AVX512_BITALG 0x80000000 /* AVX512 BITALG */ + +#define FMT_AV_386_2 \ + "\040avx512_vbmi2\037avx512_vp2intersect" \ + "\036gfni\035vaes\034vpclmulqdq\033avx512_vnni" \ + "\032clzero\031monitorx\030clwb\027clflushopt\026fsgsbase" \ + "\025sha\024avx512_4fmaps\023avx512_4nniw\022avx512vpopcntdq" \ + "\021avx512vbmi\020avx512vl\017avx512bw\016avx512cd" \ + "\015avx512er\014avx512pf\013avx512ifma\012avx512dq\011avx512f" \ + "\010rdseed\07adx\06avx2\05fma\04bmi2\03bmi1\02rdrand\01f16c" + +/* + * Flags used in AT_SUN_HWCAP3 elements + */ +#define AV_386_3_AVX512_VBMI2 0x00000001 /* AVX512_VBMI2 */ +#define AV_386_3_AVX512_BF16 0x00000002 /* AVX512_BF16 */ + +#define FMT_AV_386_3 \ + "\02avx512_bf16\01avx512_vbmi2" + +/* + * Flags used in AT_SUN_FPTYPE on x86. + * + * We don't currently support xsavec in illumos. However, when we do, then we + * should add this to the type list and extend our primary consumer (rtld) to + * use it. xsaveopt is not in this list because it is not appropriate for the + * stack based storage. + */ +#define AT_386_FPINFO_NONE 0 +#define AT_386_FPINFO_FXSAVE 1 +#define AT_386_FPINFO_XSAVE 2 +#define AT_386_FPINFO_XSAVE_AMD 3 + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_AUXV_386_H */ diff --git a/illumos-x86_64/usr/include/sys/auxv_SPARC.h b/illumos-x86_64/usr/include/sys/auxv_SPARC.h new file mode 100644 index 00000000..fd6d7c63 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/auxv_SPARC.h @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_AUXV_SPARC_H +#define _SYS_AUXV_SPARC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flags used to describe various instruction set extensions available + * on different SPARC processors. + * + * [The first four are legacy descriptions.] + */ +#define AV_SPARC_MUL32 0x0001 /* 32x32-bit smul/umul is efficient */ +#define AV_SPARC_DIV32 0x0002 /* 32x32-bit sdiv/udiv is efficient */ +#define AV_SPARC_FSMULD 0x0004 /* fsmuld is efficient */ +#define AV_SPARC_V8PLUS 0x0008 /* V9 instructions available to 32-bit apps */ +#define AV_SPARC_POPC 0x0010 /* popc is efficient */ +#define AV_SPARC_VIS 0x0020 /* VIS instruction set supported */ +#define AV_SPARC_VIS2 0x0040 /* VIS2 instruction set supported */ +#define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */ +#define AV_SPARC_FMAF 0x0100 /* Fused Multiply-Add */ +/* Bit 9 is not in use */ +#define AV_SPARC_VIS3 0x0400 /* VIS3 instruction set extensions */ +#define AV_SPARC_HPC 0x0800 /* High Performance Computing insns */ +#define AV_SPARC_RANDOM 0x1000 /* random instruction */ +#define AV_SPARC_TRANS 0x2000 /* transactions supported */ +#define AV_SPARC_FJFMAU 0x4000 /* Fujitsu Unfused Multiply-Add */ +#define AV_SPARC_IMA 0x8000 /* Integer Multiply-add */ +#define AV_SPARC_ASI_CACHE_SPARING 0x10000 +#define AV_SPARC_PAUSE 0x20000 /* pause instruction */ +#define AV_SPARC_CBCOND 0x40000 /* compare and branch instructions */ +#define AV_SPARC_AES 0x80000 /* AES instructions */ +#define AV_SPARC_DES 0x100000 /* DES instructions */ +#define AV_SPARC_KASUMI 0x200000 /* Kasumi instructions */ +#define AV_SPARC_CAMELLIA 0x400000 /* Camellia instructions */ +#define AV_SPARC_MD5 0x800000 /* MD5 instructions */ +#define AV_SPARC_SHA1 0x1000000 /* SHA1 instructions */ +#define AV_SPARC_SHA256 0x2000000 /* SHA256 instructions */ +#define AV_SPARC_SHA512 0x4000000 /* SHA512 instructions */ +#define AV_SPARC_MPMUL 0x8000000 /* multiple precision multiply */ +#define AV_SPARC_MONT 0x10000000 /* Montgomery mult/sqr instructions */ +#define AV_SPARC_CRC32C 0x20000000 /* CRC32C instructions */ + +#define FMT_AV_SPARC \ + "\20" \ + "\36crc32c\35mont\34mpmul\33sha512\32sha256\31sha1" \ + "\30md5\27camellia\26kasumi\25des\24aes\23cbcond\22pause\21cspare" \ + "\20ima\17fjfmau\16trans\15random\14hpc\13vis3\12-\11fmaf" \ + "\10ASIBlkInit\7vis2\6vis\5popc\4v8plus\3fsmuld\2div32\1mul32" + +/* + * compatibility defines: Obsolete + */ +#define AV_SPARC_HWMUL_32x32 AV_SPARC_MUL32 +#define AV_SPARC_HWDIV_32x32 AV_SPARC_DIV32 +#define AV_SPARC_HWFSMULD AV_SPARC_FSMULD + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_AUXV_SPARC_H */ diff --git a/illumos-x86_64/usr/include/sys/av/iec61883.h b/illumos-x86_64/usr/include/sys/av/iec61883.h new file mode 100644 index 00000000..2792d50e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/av/iec61883.h @@ -0,0 +1,287 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_AV_IEC61883_H +#define _SYS_AV_IEC61883_H + +/* + * IEC 61883 interfaces + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* current interface version */ +#define IEC61883_IMPL_MKVER(major, minor) (((major) << 8) | (minor)) +#define IEC61883_IMPL_VER_MAJOR(ver) (((ver) >> 8) & 0xff) +#define IEC61883_IMPL_VER_MINOR(ver) ((ver) & 0xff) +#define IEC61883_V1_0 IEC61883_IMPL_MKVER(1, 0) + +/* + * asyncronous request (ARQ) + */ +typedef struct iec61883_arq { + int arq_type; /* type */ + int arq_len; /* length */ + union { + uint32_t quadlet; + uint64_t octlet; + uint8_t buf[8]; + } arq_data; /* data */ +} iec61883_arq_t; + +/* ARQ types (arq_type) */ +enum { + IEC61883_ARQ_FCP_CMD, + IEC61883_ARQ_FCP_RESP, + IEC61883_ARQ_BUS_RESET +}; + +/* + * IEC61883_ISOCH_INIT argument + */ +typedef struct iec61883_isoch_init { + int ii_version; /* interface version */ + int ii_pkt_size; /* packet size */ + int ii_frame_size; /* packets/frame */ + int ii_frame_cnt; /* # of frames */ + int ii_direction; /* xfer direction */ + int ii_bus_speed; /* bus speed */ + uint64_t ii_channel; /* channel mask */ + int ii_dbs; /* DBS */ + int ii_fn; /* FN */ + int ii_rate_n; /* rate numerator */ + int ii_rate_d; /* rate denominator */ + int ii_ts_mode; /* timestamp mode */ + int ii_flags; /* flags */ + int ii_handle; /* isoch handle */ + int ii_frame_rcnt; /* # of frames */ + off_t ii_mmap_off; /* mmap offset */ + int ii_rchannel; /* channel */ + int ii_error; /* error code */ +} iec61883_isoch_init_t; + +/* xfer directions (ii_direction) */ +enum { + IEC61883_DIR_RECV, + IEC61883_DIR_XMIT +}; + +/* bus speeds (ii_bus_speed) */ +enum { + IEC61883_S100, + IEC61883_S200, + IEC61883_S400 +}; + +/* special rate coefficients (ii_rate_n, ii_rate_d) */ +#define IEC61883_RATE_N_DV_NTSC 1 +#define IEC61883_RATE_D_DV_NTSC 0 +#define IEC61883_RATE_N_DV_PAL 2 +#define IEC61883_RATE_D_DV_PAL 0 + +/* timestamp modes (ii_ts_mode) */ +enum { + IEC61883_TS_NONE = 0, + IEC61883_TS_SYT = 0x0206 +}; + +/* error codes (ii_error) */ +enum { + IEC61883_ERR_NOMEM = 1, + IEC61883_ERR_NOCHANNEL, + IEC61883_ERR_PKT_SIZE, + IEC61883_ERR_VERSION, + IEC61883_ERR_INVAL, + IEC61883_ERR_OTHER +}; + +/* + * data transfer strusture + */ +typedef struct iec61883_xfer { + int xf_empty_idx; /* first empty frame */ + int xf_empty_cnt; /* empty frame count */ + int xf_full_idx; /* first full frame */ + int xf_full_cnt; /* full frame count */ + int xf_error; /* error */ +} iec61883_xfer_t; + +/* + * IEC61883_RECV argument + */ +typedef struct iec61883_recv { + int rx_handle; /* isoch handle */ + int rx_flags; /* flags */ + iec61883_xfer_t rx_xfer; /* xfer params */ +} iec61883_recv_t; + +/* + * IEC61883_XMIT argument + */ +typedef struct iec61883_xmit { + int tx_handle; /* isoch handle */ + int tx_flags; /* flags */ + iec61883_xfer_t tx_xfer; /* xfer params */ + int tx_miss_cnt; /* missed cycles */ +} iec61883_xmit_t; + +/* + * IEC61883_PLUG_INIT argument + */ +typedef struct iec61883_plug_init { + int pi_ver; /* interface version */ + int pi_loc; /* plug location */ + int pi_type; /* plug type */ + int pi_num; /* plug number */ + int pi_flags; /* flags */ + int pi_handle; /* plug handle */ + int pi_rnum; /* plug number */ +} iec61883_plug_init_t; + +/* plug locations (pi_loc) */ +enum { + IEC61883_LOC_LOCAL, + IEC61883_LOC_REMOTE +}; + +/* plug types (pi_type) */ +enum { + IEC61883_PLUG_IN, + IEC61883_PLUG_OUT, + IEC61883_PLUG_MASTER_IN, + IEC61883_PLUG_MASTER_OUT +}; + +/* special plug number (pi_num) */ +enum { + IEC61883_PLUG_ANY = -1 +}; + +/* + * IEC61883_PLUG_REG_READ argument + */ +typedef struct iec61883_plug_reg_val { + int pr_handle; /* plug handle */ + uint32_t pr_val; /* register value */ +} iec61883_plug_reg_val_t; + +/* + * IEC61883_PLUG_REG_CAS argument + */ +typedef struct iec61883_plug_reg_lock { + int pl_handle; /* plug handle */ + uint32_t pl_arg; /* compare arg */ + uint32_t pl_data; /* write value */ + uint32_t pl_old; /* original value */ +} iec61883_plug_reg_lock_t; + +/* + * IEC61883_NODE_GET_TEXT_LEAF argument + */ +typedef struct iec61883_node_text_leaf { + int tl_parent; /* ROM parent */ + int tl_num; /* leaf number */ + int tl_len; /* buffer length */ + uint32_t *tl_data; /* data buffer */ + int tl_cnt; /* leaf count */ + int tl_rlen; /* real length */ + uint32_t tl_spec; /* specifier */ + uint32_t tl_lang_id; /* language id */ + uint32_t tl_desc_entry; /* entry described by this leaf */ +} iec61883_node_text_leaf_t; + +/* ROM parent types (tl_parent) */ +enum { + IEC61883_ROM_ROOT, /* leaf in the root directory */ + IEC61883_ROM_UNIT /* leaf in the unit directory */ +}; + +/* ioctl codes */ +#define IEC61883_IMPL_IOC ('i' << 8) +#define IEC61883_IMPL_MKIOC(c) (c | IEC61883_IMPL_IOC) + +#define IEC61883_ISOCH_INIT IEC61883_IMPL_MKIOC(0x01) +#define IEC61883_ISOCH_FINI IEC61883_IMPL_MKIOC(0x02) +#define IEC61883_START IEC61883_IMPL_MKIOC(0x03) +#define IEC61883_STOP IEC61883_IMPL_MKIOC(0x04) +#define IEC61883_RECV IEC61883_IMPL_MKIOC(0x05) +#define IEC61883_XMIT IEC61883_IMPL_MKIOC(0x06) +#define IEC61883_PLUG_INIT IEC61883_IMPL_MKIOC(0x07) +#define IEC61883_PLUG_FINI IEC61883_IMPL_MKIOC(0x08) +#define IEC61883_PLUG_REG_READ IEC61883_IMPL_MKIOC(0x09) +#define IEC61883_PLUG_REG_CAS IEC61883_IMPL_MKIOC(0x0A) +#define IEC61883_ARQ_GET_IBUF_SIZE IEC61883_IMPL_MKIOC(0x0B) +#define IEC61883_ARQ_SET_IBUF_SIZE IEC61883_IMPL_MKIOC(0x0C) +#define IEC61883_NODE_GET_BUS_NAME IEC61883_IMPL_MKIOC(0x0D) +#define IEC61883_NODE_GET_UID IEC61883_IMPL_MKIOC(0x0E) +#define IEC61883_NODE_GET_TEXT_LEAF IEC61883_IMPL_MKIOC(0x0F) + + +/* 32-bit structures for the drivers */ +#ifdef _KERNEL +typedef struct iec61883_isoch_init32 { + int ii_version; /* interface version */ + int ii_pkt_size; /* packet size */ + int ii_frame_size; /* packets/frame */ + int ii_frame_cnt; /* # of frames */ + int ii_direction; /* xfer direction */ + int ii_bus_speed; /* bus speed */ + uint64_t ii_channel; /* channel mask */ + int ii_dbs; /* DBS */ + int ii_fn; /* FN */ + int ii_rate_n; /* rate numerator */ + int ii_rate_d; /* rate denominator */ + int ii_ts_mode; /* timestamp mode */ + int ii_flags; /* flags */ + int ii_handle; /* isoch handle */ + int ii_frame_rcnt; /* # of frames */ + int32_t ii_mmap_off; /* mmap offset */ + int ii_rchannel; /* channel */ + int ii_error; /* error code */ +} iec61883_isoch_init32_t; + +typedef struct iec61883_node_text_leaf32 { + int tl_parent; /* ROM parent */ + int tl_num; /* leaf number */ + int tl_len; /* buffer length */ + caddr32_t tl_data; /* data buffer */ + int tl_cnt; /* leaf count */ + int tl_rlen; /* real length */ + uint32_t tl_spec; /* specifier */ + uint32_t tl_lang_id; /* language id */ + uint32_t tl_desc_entry; /* entry described by this leaf */ +} iec61883_node_text_leaf32_t; +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_AV_IEC61883_H */ diff --git a/illumos-x86_64/usr/include/sys/avintr.h b/illumos-x86_64/usr/include/sys/avintr.h new file mode 100644 index 00000000..974d08cf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/avintr.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_AVINTR_H +#define _SYS_AVINTR_H + + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Period of autovector structures (add this in to get the next level). + */ +#define MAXIPL 16 +#define INT_IPL(x) (x) +#define AV_INT_SPURIOUS -1 + +typedef uint_t (*avfunc)(caddr_t, caddr_t); + +struct autovec { + + /* + * Interrupt handler and argument to pass to it. + */ + + struct autovec *av_link; /* pointer to next on in chain */ + uint_t (*av_vector)(); + caddr_t av_intarg1; + caddr_t av_intarg2; + uint64_t *av_ticksp; + uint_t av_prilevel; /* priority level */ + + /* + * Interrupt handle/id (like intrspec structure pointer) used to + * identify a specific instance of interrupt handler in case we + * have to remove the interrupt handler later. + * + */ + void *av_intr_id; + dev_info_t *av_dip; + ushort_t av_flags; /* pending flags */ + struct autovec *av_ipl_link; /* pointer to next on ipl chain */ +}; + +#define AV_PENTRY_VECTMASK 0xff /* low 8 bit used for irqno */ +#define AV_PENTRY_PEND 0x100 /* pending hardware interrupt */ +#define AV_PENTRY_ONPROC 0x200 /* being serviced by CPU */ +#define AV_PENTRY_LEVEL 0x8000 /* level-triggered interrupt */ + +struct av_head { + struct autovec *avh_link; + ushort_t avh_hi_pri; + ushort_t avh_lo_pri; +}; + +/* softing contains a bit field of software interrupts which are pending */ +struct softint { + int st_pending; +}; + +#ifdef _KERNEL + +extern kmutex_t av_lock; +extern ddi_softint_hdl_impl_t softlevel_hdl[]; +extern ddi_softint_hdl_impl_t softlevel1_hdl; +extern int add_avintr(void *intr_id, int lvl, avfunc xxintr, char *name, + int vect, caddr_t arg1, caddr_t arg2, uint64_t *, dev_info_t *); +extern int add_nmintr(int lvl, avfunc nmintr, char *name, caddr_t arg); +extern int add_avsoftintr(void *intr_id, int lvl, avfunc xxintr, + char *name, caddr_t arg1, caddr_t arg2); +extern int rem_avsoftintr(void *intr_id, int lvl, avfunc xxintr); +extern int av_softint_movepri(void *intr_id, int old_lvl); +extern void update_avsoftintr_args(void *intr_id, int lvl, caddr_t arg2); +extern void rem_avintr(void *intr_id, int lvl, avfunc xxintr, int vect); +extern void wait_till_seen(int ipl); +extern uint_t softlevel1(caddr_t, caddr_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_AVINTR_H */ diff --git a/illumos-x86_64/usr/include/sys/avl.h b/illumos-x86_64/usr/include/sys/avl.h new file mode 100644 index 00000000..ec2647a8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/avl.h @@ -0,0 +1,320 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2014 by Delphix. All rights reserved. + */ + +#ifndef _AVL_H +#define _AVL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * This is a generic implementation of AVL trees for use in the illumos. The + * interfaces provide an efficient way of implementing an ordered set of data + * structures. + * + * AVL trees provide an alternative to using an ordered linked list. Using AVL + * trees will usually be faster, however they requires more storage. An ordered + * linked list in general requires 2 pointers in each data structure. The + * AVL tree implementation uses 3 pointers. The following chart gives the + * approximate performance of operations with the different approaches: + * + * Operation Link List AVL tree + * --------- -------- -------- + * lookup O(n) O(log(n)) + * + * insert 1 node constant O(log(n)) + * + * delete 1 node constant between constant and O(log(n)) + * + * delete all nodes O(n) O(n) + * + * visit the next + * or prev node constant between constant and O(log(n)) + * + * + * The data structure nodes are anchored at an "avl_tree_t" (the equivalent + * of a list header) and the individual nodes will have a field of + * type "avl_node_t" (corresponding to list pointers). + * + * The type "avl_index_t" is used to indicate a position in the list for + * certain calls. + * + * The usage scenario is generally: + * + * 1. Create the list/tree with: avl_create() + * + * followed by any mixture of: + * + * 2a. Insert nodes with: avl_add(), or avl_find() and avl_insert() + * + * 2b. Visited elements with: + * avl_first() - returns the lowest valued node + * avl_last() - returns the highest valued node + * AVL_NEXT() - given a node go to next higher one + * AVL_PREV() - given a node go to previous lower one + * + * 2c. Find the node with the closest value either less than or greater + * than a given value with avl_nearest(). + * + * 2d. Remove individual nodes from the list/tree with avl_remove(). + * + * and finally when the list is being destroyed + * + * 3. Use avl_destroy_nodes() to quickly process/free up any remaining nodes. + * Note that once you use avl_destroy_nodes(), you can no longer + * use any routine except avl_destroy_nodes() and avl_destoy(). + * + * 4. Use avl_destroy() to destroy the AVL tree itself. + * + * Any locking for multiple thread access is up to the user to provide, just + * as is needed for any linked list implementation. + */ + +/* + * AVL comparator helpers + */ +#define AVL_ISIGN(a) (((a) > 0) - ((a) < 0)) +#define AVL_CMP(a, b) (((a) > (b)) - ((a) < (b))) +#define AVL_PCMP(a, b) \ + (((uintptr_t)(a) > (uintptr_t)(b)) - ((uintptr_t)(a) < (uintptr_t)(b))) + +/* + * Type used for the root of the AVL tree. + */ +typedef struct avl_tree avl_tree_t; + +/* + * The data nodes in the AVL tree must have a field of this type. + */ +typedef struct avl_node avl_node_t; + +/* + * An opaque type used to locate a position in the tree where a node + * would be inserted. + */ +typedef uintptr_t avl_index_t; + + +/* + * Direction constants used for avl_nearest(). + */ +#define AVL_BEFORE (0) +#define AVL_AFTER (1) + + +/* + * Prototypes + * + * Where not otherwise mentioned, "void *" arguments are a pointer to the + * user data structure which must contain a field of type avl_node_t. + * + * Also assume the user data structures looks like: + * stuct my_type { + * ... + * avl_node_t my_link; + * ... + * }; + */ + +/* + * Initialize an AVL tree. Arguments are: + * + * tree - the tree to be initialized + * compar - function to compare two nodes, it must return exactly: -1, 0, or +1 + * -1 for <, 0 for ==, and +1 for > + * size - the value of sizeof(struct my_type) + * offset - the value of OFFSETOF(struct my_type, my_link) + */ +extern void avl_create(avl_tree_t *tree, + int (*compar) (const void *, const void *), size_t size, size_t offset); + + +/* + * Find a node with a matching value in the tree. Returns the matching node + * found. If not found, it returns NULL and then if "where" is not NULL it sets + * "where" for use with avl_insert() or avl_nearest(). + * + * node - node that has the value being looked for + * where - position for use with avl_nearest() or avl_insert(), may be NULL + */ +extern void *avl_find(avl_tree_t *tree, const void *node, avl_index_t *where); + +/* + * Insert a node into the tree. + * + * node - the node to insert + * where - position as returned from avl_find() + */ +extern void avl_insert(avl_tree_t *tree, void *node, avl_index_t where); + +/* + * Insert "new_data" in "tree" in the given "direction" either after + * or before the data "here". + * + * This might be useful for avl clients caching recently accessed + * data to avoid doing avl_find() again for insertion. + * + * new_data - new data to insert + * here - existing node in "tree" + * direction - either AVL_AFTER or AVL_BEFORE the data "here". + */ +extern void avl_insert_here(avl_tree_t *tree, void *new_data, void *here, + int direction); + + +/* + * Return the first or last valued node in the tree. Will return NULL + * if the tree is empty. + * + */ +extern void *avl_first(avl_tree_t *tree); +extern void *avl_last(avl_tree_t *tree); + + +/* + * Return the next or previous valued node in the tree. + * AVL_NEXT() will return NULL if at the last node. + * AVL_PREV() will return NULL if at the first node. + * + * node - the node from which the next or previous node is found + */ +#define AVL_NEXT(tree, node) avl_walk(tree, node, AVL_AFTER) +#define AVL_PREV(tree, node) avl_walk(tree, node, AVL_BEFORE) + + +/* + * Find the node with the nearest value either greater or less than + * the value from a previous avl_find(). Returns the node or NULL if + * there isn't a matching one. + * + * where - position as returned from avl_find() + * direction - either AVL_BEFORE or AVL_AFTER + * + * EXAMPLE get the greatest node that is less than a given value: + * + * avl_tree_t *tree; + * struct my_data look_for_value = {....}; + * struct my_data *node; + * struct my_data *less; + * avl_index_t where; + * + * node = avl_find(tree, &look_for_value, &where); + * if (node != NULL) + * less = AVL_PREV(tree, node); + * else + * less = avl_nearest(tree, where, AVL_BEFORE); + */ +extern void *avl_nearest(avl_tree_t *tree, avl_index_t where, int direction); + + +/* + * Add a single node to the tree. + * The node must not be in the tree, and it must not + * compare equal to any other node already in the tree. + * + * node - the node to add + */ +extern void avl_add(avl_tree_t *tree, void *node); + + +/* + * Remove a single node from the tree. The node must be in the tree. + * + * node - the node to remove + */ +extern void avl_remove(avl_tree_t *tree, void *node); + +/* + * Reinsert a node only if its order has changed relative to its nearest + * neighbors. To optimize performance avl_update_lt() checks only the previous + * node and avl_update_gt() checks only the next node. Use avl_update_lt() and + * avl_update_gt() only if you know the direction in which the order of the + * node may change. + */ +extern boolean_t avl_update(avl_tree_t *, void *); +extern boolean_t avl_update_lt(avl_tree_t *, void *); +extern boolean_t avl_update_gt(avl_tree_t *, void *); + +/* + * Swaps the contents of the two trees. + */ +extern void avl_swap(avl_tree_t *tree1, avl_tree_t *tree2); + +/* + * Return the number of nodes in the tree + */ +extern ulong_t avl_numnodes(avl_tree_t *tree); + +/* + * Return B_TRUE if there are zero nodes in the tree, B_FALSE otherwise. + */ +extern boolean_t avl_is_empty(avl_tree_t *tree); + +/* + * Used to destroy any remaining nodes in a tree. The cookie argument should + * be initialized to NULL before the first call. Returns a node that has been + * removed from the tree and may be free()'d. Returns NULL when the tree is + * empty. + * + * Once you call avl_destroy_nodes(), you can only continuing calling it and + * finally avl_destroy(). No other AVL routines will be valid. + * + * cookie - a "void *" used to save state between calls to avl_destroy_nodes() + * + * EXAMPLE: + * avl_tree_t *tree; + * struct my_data *node; + * void *cookie; + * + * cookie = NULL; + * while ((node = avl_destroy_nodes(tree, &cookie)) != NULL) + * free(node); + * avl_destroy(tree); + */ +extern void *avl_destroy_nodes(avl_tree_t *tree, void **cookie); + + +/* + * Final destroy of an AVL tree. Arguments are: + * + * tree - the empty tree to destroy + */ +extern void avl_destroy(avl_tree_t *tree); + + + +#ifdef __cplusplus +} +#endif + +#endif /* _AVL_H */ diff --git a/illumos-x86_64/usr/include/sys/avl_impl.h b/illumos-x86_64/usr/include/sys/avl_impl.h new file mode 100644 index 00000000..4522895c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/avl_impl.h @@ -0,0 +1,162 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _AVL_IMPL_H +#define _AVL_IMPL_H + +/* + * This is a private header file. Applications should not directly include + * this file. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * generic AVL tree implementation for kernel use + * + * There are 5 pieces of information stored for each node in an AVL tree + * + * pointer to less than child + * pointer to greater than child + * a pointer to the parent of this node + * an indication [0/1] of which child I am of my parent + * a "balance" (-1, 0, +1) indicating which child tree is taller + * + * Since they only need 3 bits, the last two fields are packed into the + * bottom bits of the parent pointer on 64 bit machines to save on space. + */ + +#ifndef _LP64 + +struct avl_node { + struct avl_node *avl_child[2]; /* left/right children */ + struct avl_node *avl_parent; /* this node's parent */ + unsigned short avl_child_index; /* my index in parent's avl_child[] */ + short avl_balance; /* balance value: -1, 0, +1 */ +}; + +#define AVL_XPARENT(n) ((n)->avl_parent) +#define AVL_SETPARENT(n, p) ((n)->avl_parent = (p)) + +#define AVL_XCHILD(n) ((n)->avl_child_index) +#define AVL_SETCHILD(n, c) ((n)->avl_child_index = (unsigned short)(c)) + +#define AVL_XBALANCE(n) ((n)->avl_balance) +#define AVL_SETBALANCE(n, b) ((n)->avl_balance = (short)(b)) + +#else /* _LP64 */ + +/* + * for 64 bit machines, avl_pcb contains parent pointer, balance and child_index + * values packed in the following manner: + * + * |63 3| 2 |1 0 | + * |-------------------------------------|-----------------|-------------| + * | avl_parent hi order bits | avl_child_index | avl_balance | + * | | | + 1 | + * |-------------------------------------|-----------------|-------------| + * + */ +struct avl_node { + struct avl_node *avl_child[2]; /* left/right children nodes */ + uintptr_t avl_pcb; /* parent, child_index, balance */ +}; + +/* + * macros to extract/set fields in avl_pcb + * + * pointer to the parent of the current node is the high order bits + */ +#define AVL_XPARENT(n) ((struct avl_node *)((n)->avl_pcb & ~7)) +#define AVL_SETPARENT(n, p) \ + ((n)->avl_pcb = (((n)->avl_pcb & 7) | (uintptr_t)(p))) + +/* + * index of this node in its parent's avl_child[]: bit #2 + */ +#define AVL_XCHILD(n) (((n)->avl_pcb >> 2) & 1) +#define AVL_SETCHILD(n, c) \ + ((n)->avl_pcb = (uintptr_t)(((n)->avl_pcb & ~4) | ((c) << 2))) + +/* + * balance indication for a node, lowest 2 bits. A valid balance is + * -1, 0, or +1, and is encoded by adding 1 to the value to get the + * unsigned values of 0, 1, 2. + */ +#define AVL_XBALANCE(n) ((int)(((n)->avl_pcb & 3) - 1)) +#define AVL_SETBALANCE(n, b) \ + ((n)->avl_pcb = (uintptr_t)((((n)->avl_pcb & ~3) | ((b) + 1)))) + +#endif /* _LP64 */ + + + +/* + * switch between a node and data pointer for a given tree + * the value of "o" is tree->avl_offset + */ +#define AVL_NODE2DATA(n, o) ((void *)((uintptr_t)(n) - (o))) +#define AVL_DATA2NODE(d, o) ((struct avl_node *)((uintptr_t)(d) + (o))) + + + +/* + * macros used to create/access an avl_index_t + */ +#define AVL_INDEX2NODE(x) ((avl_node_t *)((x) & ~1)) +#define AVL_INDEX2CHILD(x) ((x) & 1) +#define AVL_MKINDEX(n, c) ((avl_index_t)(n) | (c)) + + +/* + * The tree structure. The fields avl_root, avl_compar, and avl_offset come + * first since they are needed for avl_find(). We want them to fit into + * a single 64 byte cache line to make avl_find() as fast as possible. + */ +struct avl_tree { + struct avl_node *avl_root; /* root node in tree */ + int (*avl_compar)(const void *, const void *); + size_t avl_offset; /* offsetof(type, avl_link_t field) */ + ulong_t avl_numnodes; /* number of nodes in the tree */ + size_t avl_size; /* sizeof user type struct */ +}; + + +/* + * This will only by used via AVL_NEXT() or AVL_PREV() + */ +extern void *avl_walk(struct avl_tree *, void *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _AVL_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/bitext.h b/illumos-x86_64/usr/include/sys/bitext.h new file mode 100644 index 00000000..9baa6b59 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bitext.h @@ -0,0 +1,48 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2022 Oxide Computer Company + */ + +#ifndef _SYS_BITEXT_H +#define _SYS_BITEXT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A bunch of routines to make working with bits and registers easier. This is + * designed to be a replacement for the BITX macro and provide additional error + * handling. See bitx64(9F), bitdel64(9F), and bitset64(9F) for more + * information. + */ + +extern uint8_t bitx8(uint8_t, uint_t, uint_t); +extern uint16_t bitx16(uint16_t, uint_t, uint_t); +extern uint32_t bitx32(uint32_t, uint_t, uint_t); +extern uint64_t bitx64(uint64_t, uint_t, uint_t); + +extern uint8_t bitset8(uint8_t, uint_t, uint_t, uint8_t); +extern uint16_t bitset16(uint16_t, uint_t, uint_t, uint16_t); +extern uint32_t bitset32(uint32_t, uint_t, uint_t, uint32_t); +extern uint64_t bitset64(uint64_t, uint_t, uint_t, uint64_t); + +extern uint64_t bitdel64(uint64_t, uint_t, uint_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BITEXT_H */ diff --git a/illumos-x86_64/usr/include/sys/bitmap.h b/illumos-x86_64/usr/include/sys/bitmap.h new file mode 100644 index 00000000..4282dca0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bitmap.h @@ -0,0 +1,199 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2014 by Delphix. All rights reserved. + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. + * Copyright 2022 Oxide Computer Company + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_BITMAP_H +#define _SYS_BITMAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#if defined(__GNUC__) && defined(_ASM_INLINES) && \ + (defined(__i386) || defined(__amd64)) +#include +#endif + +/* + * Operations on bitmaps of arbitrary size + * A bitmap is a vector of 1 or more ulong_t's. + * The user of the package is responsible for range checks and keeping + * track of sizes. + */ + +#ifdef _LP64 +#define BT_ULSHIFT 6 /* log base 2 of BT_NBIPUL, to extract word index */ +#define BT_ULSHIFT32 5 /* log base 2 of BT_NBIPUL, to extract word index */ +#else +#define BT_ULSHIFT 5 /* log base 2 of BT_NBIPUL, to extract word index */ +#endif + +#define BT_NBIPUL (1 << BT_ULSHIFT) /* n bits per ulong_t */ +#define BT_ULMASK (BT_NBIPUL - 1) /* to extract bit index */ + +#ifdef _LP64 +#define BT_NBIPUL32 (1 << BT_ULSHIFT32) /* n bits per ulong_t */ +#define BT_ULMASK32 (BT_NBIPUL32 - 1) /* to extract bit index */ +#define BT_ULMAXMASK 0xffffffffffffffff /* used by bt_getlowbit */ +#else +#define BT_ULMAXMASK 0xffffffff +#endif + +/* + * bitmap is a ulong_t *, bitindex an index_t + * + * The macros BT_WIM and BT_BIW internal; there is no need + * for users of this package to use them. + */ + +/* + * word in map + */ +#define BT_WIM(bitmap, bitindex) \ + ((bitmap)[(bitindex) >> BT_ULSHIFT]) +/* + * bit in word + */ +#define BT_BIW(bitindex) \ + (1UL << ((bitindex) & BT_ULMASK)) + +#ifdef _LP64 +#define BT_WIM32(bitmap, bitindex) \ + ((bitmap)[(bitindex) >> BT_ULSHIFT32]) + +#define BT_BIW32(bitindex) \ + (1UL << ((bitindex) & BT_ULMASK32)) +#endif + +/* + * These are public macros + * + * BT_BITOUL == n bits to n ulong_t's + */ +#define BT_BITOUL(nbits) \ + (((nbits) + BT_NBIPUL - 1l) / BT_NBIPUL) +#define BT_SIZEOFMAP(nbits) \ + (BT_BITOUL(nbits) * sizeof (ulong_t)) +#define BT_TEST(bitmap, bitindex) \ + ((BT_WIM((bitmap), (bitindex)) & BT_BIW(bitindex)) ? 1 : 0) +#define BT_SET(bitmap, bitindex) \ + { BT_WIM((bitmap), (bitindex)) |= BT_BIW(bitindex); } +#define BT_CLEAR(bitmap, bitindex) \ + { BT_WIM((bitmap), (bitindex)) &= ~BT_BIW(bitindex); } + +#ifdef _LP64 +#define BT_BITOUL32(nbits) \ + (((nbits) + BT_NBIPUL32 - 1l) / BT_NBIPUL32) +#define BT_SIZEOFMAP32(nbits) \ + (BT_BITOUL32(nbits) * sizeof (uint_t)) +#define BT_TEST32(bitmap, bitindex) \ + ((BT_WIM32((bitmap), (bitindex)) & BT_BIW32(bitindex)) ? 1 : 0) +#define BT_SET32(bitmap, bitindex) \ + { BT_WIM32((bitmap), (bitindex)) |= BT_BIW32(bitindex); } +#define BT_CLEAR32(bitmap, bitindex) \ + { BT_WIM32((bitmap), (bitindex)) &= ~BT_BIW32(bitindex); } +#endif /* _LP64 */ + + +/* + * BIT_ONLYONESET is a private macro not designed for bitmaps of + * arbitrary size. u must be an unsigned integer/long. It returns + * true if one and only one bit is set in u. + */ +#define BIT_ONLYONESET(u) \ + ((((u) == 0) ? 0 : ((u) & ((u) - 1)) == 0)) + +#if (defined(_KERNEL) || defined(_FAKE_KERNEL)) && !defined(_ASM) +#include + +/* + * return next available bit index from map with specified number of bits + */ +extern index_t bt_availbit(const ulong_t *, size_t); +/* + * find the highest order bit that is on, and is within or below + * the word specified by wx + */ +extern int bt_gethighbit(const ulong_t *, int wx); +extern int bt_range(const ulong_t *, size_t *, size_t *, size_t); +/* + * Find highest and lowest one bit set. + * Returns bit number + 1 of bit that is set, otherwise returns 0. + * Low order bit is 0, high order bit is 31. + */ +extern int highbit(ulong_t); +extern int highbit64(uint64_t); +extern int lowbit(ulong_t); +extern int bt_getlowbit(const ulong_t *, size_t, size_t); +extern void bt_copy(const ulong_t *, ulong_t *, ulong_t); + +/* + * find the parity + */ +extern int odd_parity(ulong_t); + +/* + * Atomically set/clear bits + * Atomic exclusive operations will set "result" to "-1" + * if the bit is already set/cleared. "result" will be set + * to 0 otherwise. + */ +#define BT_ATOMIC_SET(bitmap, bitindex) \ + { atomic_or_ulong(&(BT_WIM(bitmap, bitindex)), BT_BIW(bitindex)); } +#define BT_ATOMIC_CLEAR(bitmap, bitindex) \ + { atomic_and_ulong(&(BT_WIM(bitmap, bitindex)), ~BT_BIW(bitindex)); } + +#define BT_ATOMIC_SET_EXCL(bitmap, bitindex, result) \ + { result = atomic_set_long_excl(&(BT_WIM(bitmap, bitindex)), \ + (bitindex) % BT_NBIPUL); } +#define BT_ATOMIC_CLEAR_EXCL(bitmap, bitindex, result) \ + { result = atomic_clear_long_excl(&(BT_WIM(bitmap, bitindex)), \ + (bitindex) % BT_NBIPUL); } + +/* + * Extracts bits between index h (high, inclusive) and l (low, exclusive) from + * u, which must be an unsigned integer. + */ +#define BITX(u, h, l) (((u) >> (l)) & ((1LU << ((h) - (l) + 1LU)) - 1LU)) + +#endif /* (_KERNEL || _FAKE_KERNEL) && !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BITMAP_H */ diff --git a/illumos-x86_64/usr/include/sys/bitset.h b/illumos-x86_64/usr/include/sys/bitset.h new file mode 100644 index 00000000..c1e369bf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bitset.h @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 RackTop Systems. + */ + +#ifndef _BITSET_H +#define _BITSET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) || defined(_KMEMUSER) +#include +#include + +typedef struct bitset { + ulong_t *bs_set; + uint_t bs_words; + uint_t bs_fanout; +} bitset_t; + +/* + * Bitset initialiation / teardown + */ +void bitset_init(bitset_t *); +void bitset_init_fanout(bitset_t *, uint_t); +void bitset_fini(bitset_t *); + +/* + * Resize / query a bitset's holding capacity + */ +void bitset_resize(bitset_t *, uint_t); +uint_t bitset_capacity(bitset_t *); + +/* + * Set / clear a bit in the set + */ +void bitset_add(bitset_t *, uint_t); +void bitset_del(bitset_t *, uint_t); + +/* + * Atomic operations + */ +void bitset_atomic_add(bitset_t *, uint_t); +void bitset_atomic_del(bitset_t *, uint_t); +int bitset_atomic_test_and_add(bitset_t *, uint_t); +int bitset_atomic_test_and_del(bitset_t *, uint_t); + +/* + * Bitset queries + */ +int bitset_in_set(bitset_t *, uint_t); +int bitset_is_null(bitset_t *); +uint_t bitset_find(bitset_t *); + +/* + * Bitset computations + */ +int bitset_and(bitset_t *, bitset_t *, bitset_t *); +int bitset_or(bitset_t *, bitset_t *, bitset_t *); +int bitset_xor(bitset_t *, bitset_t *, bitset_t *); + +/* + * Miscellaneous bitset operations + */ +void bitset_zero(bitset_t *); +void bitset_copy(bitset_t *, bitset_t *); +int bitset_match(bitset_t *, bitset_t *); + +#endif /* _KERNEL || _FAKE_KERNEL || _KMEMUSER */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BITSET_H */ diff --git a/illumos-x86_64/usr/include/sys/bl.h b/illumos-x86_64/usr/include/sys/bl.h new file mode 100644 index 00000000..a2fba9e5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bl.h @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_BL_H +#define _SYS_BL_H + +/* + * The interfaces described below are private to FMA. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define BLIOC_INSERT (('B' << 8) | 0x01) +#define BLIOC_DELETE (('B' << 8) | 0x02) + +typedef struct bl_req { + caddr_t bl_fmri; /* buffer containing packed FMRI */ + size_t bl_fmrisz; /* size of packed FMRI */ + caddr_t bl_class; /* event class reason for blacklist */ +} bl_req_t; + +#if defined(_SYSCALL32) +typedef struct bl_req32 { + caddr32_t bl_fmri; + size32_t bl_fmrisz; + caddr32_t bl_class; +} bl_req32_t; +#endif /* _SYSCALL32 */ + +#define BL_FMRI_MAX_BUFSIZE 8192 /* maximum allowed packed FMRI size */ + +#ifdef _KERNEL + +extern int blacklist(int, const char *, nvlist_t *, const char *); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BL_H */ diff --git a/illumos-x86_64/usr/include/sys/blkdev.h b/illumos-x86_64/usr/include/sys/blkdev.h new file mode 100644 index 00000000..90fa1a15 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/blkdev.h @@ -0,0 +1,255 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2012 DEY Storage Systems, Inc. All rights reserved. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 Joyent, Inc. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. + */ + +#ifndef _SYS_BLKDEV_H +#define _SYS_BLKDEV_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This describes a fairly simple block device. The idea here is that + * these things want to take advantage of the common labelling support, + * but do not need all the capabilities of SCSA. So we make quite a few + * simplifications: + * + * 1) Device block size is a power of 2 greater or equal to 512 bytes. + * An optional physical block size can be reported if the underlying + * device uses larger block sizes internally, so that writes can be + * aligned properly. + * + * 2) Non-rotating media. We assume a simple linear layout. + * + * 3) Fixed queue depth, for each device. The adapter driver reports + * the queue depth at registration. We don't have any form of + * dynamic flow control. + * + * 4) Negligible power management support. The framework does not support + * fine grained power management. If the adapter driver wants to use + * such, it will need to manage power on its own. + * + * 5) Suspend/resume support managed by the adapter driver. We don't + * support suspend/resume directly. The adapter device driver will + * need to manage this on its own behalf. + * + * 6) No request priorities. Transfers are assumed to execute in + * roughly FIFO order. The adapter driver may reorder them, but the + * submitter has no control over that. + * + * 7) No request cancellation. Once submitted, the job completes or + * fails. It cannot be canceled. + * + * 8) Limited support for removable media. There is no support for + * locking bay doors or mechanised media bays. This could be + * added, but at present the only such interesting devices are + * covered by the SCSI disk driver. + */ + +typedef struct bd_handle *bd_handle_t; +typedef struct bd_xfer bd_xfer_t; +typedef struct bd_drive bd_drive_t; +typedef struct bd_media bd_media_t; +typedef struct bd_free_info bd_free_info_t; +typedef struct bd_ops bd_ops_t; + +struct dkioc_free_list_s; + +struct bd_xfer { + /* + * NB: If using DMA the br_ndmac will be non-zero. Otherwise + * the br_kaddr will be non-NULL. + */ + diskaddr_t x_blkno; + size_t x_nblks; + ddi_dma_handle_t x_dmah; + ddi_dma_cookie_t x_dmac; + unsigned x_ndmac; + caddr_t x_kaddr; + unsigned x_flags; + unsigned x_qnum; + const struct dkioc_free_list_s *x_dfl; +}; + +#define BD_XFER_POLL (1U << 0) /* no interrupts (dump) */ + +struct bd_drive { + uint32_t d_qsize; + uint32_t d_maxxfer; + boolean_t d_removable; + boolean_t d_hotpluggable; + int d_target; + int d_lun; + size_t d_vendor_len; + char *d_vendor; + size_t d_product_len; + char *d_product; + size_t d_model_len; + char *d_model; + size_t d_serial_len; + char *d_serial; + size_t d_revision_len; + char *d_revision; + + uint8_t d_eui64[8]; + uint8_t d_guid[16]; + + uint32_t d_qcount; + + /* + * Required starting alignment for free_space requests (in logical + * blocks). Must be >= 1. + */ + uint64_t d_free_align; + + /* + * Maximum number of segments supported in a free space request. + * 0 implies no limit. + */ + uint64_t d_max_free_seg; + + /* + * Maximum number of logical blocks allowed in a free space request. + * 0 implies no limit. + */ + uint64_t d_max_free_blks; + + /* + * Maximum number of logical blocks to free in a single segment. + * 0 implies no limit. If no limit, d_max_free_blks must also be 0. + * If > 0, d_max_free_seg_blks must be <= d_max_free_blks (basically + * you can't set a bigger value of d_max_free_seg_blks than + * d_max_free_blks). + */ + uint64_t d_max_free_seg_blks; +}; + +struct bd_media { + /* + * NB: The block size must be a power of two not less than + * DEV_BSIZE (512). Other values of the block size will + * simply not function and the media will be rejected. + * + * The block size must also divide evenly into the device's + * d_maxxfer field. If the maxxfer is a power of two larger + * than the block size, then this will automatically be + * satisfied. + * + * The physical block size (m_pblksize) must be 0 or a power + * of two not less than the block size. + */ + uint64_t m_nblks; + uint32_t m_blksize; + boolean_t m_readonly; + boolean_t m_solidstate; + uint32_t m_pblksize; +}; + +#define BD_INFO_FLAG_REMOVABLE (1U << 0) +#define BD_INFO_FLAG_HOTPLUGGABLE (1U << 1) +#define BD_INFO_FLAG_READ_ONLY (1U << 2) + +/* + * When adding a new version of the bd_ops_t struct, be sure to update + * BD_OPS_CURRENT_VERSION + */ +typedef enum { + BD_OPS_VERSION_0 = 0, + BD_OPS_VERSION_1 = 1, + BD_OPS_VERSION_2 = 2, +} bd_version_t; +#define BD_OPS_CURRENT_VERSION BD_OPS_VERSION_2 + +struct bd_ops { + bd_version_t o_version; + void (*o_drive_info)(void *, bd_drive_t *); + int (*o_media_info)(void *, bd_media_t *); + int (*o_devid_init)(void *, dev_info_t *, ddi_devid_t *); + int (*o_sync_cache)(void *, bd_xfer_t *); + int (*o_read)(void *, bd_xfer_t *); + int (*o_write)(void *, bd_xfer_t *); + int (*o_free_space)(void *, bd_xfer_t *); +}; + +struct bd_errstats { + /* these are managed by blkdev itself */ + kstat_named_t bd_softerrs; + kstat_named_t bd_harderrs; + kstat_named_t bd_transerrs; + kstat_named_t bd_model; + kstat_named_t bd_vid; + kstat_named_t bd_pid; + kstat_named_t bd_revision; + kstat_named_t bd_serial; + kstat_named_t bd_capacity; + + /* the following are updated on behalf of the HW driver */ + kstat_named_t bd_rq_media_err; + kstat_named_t bd_rq_ntrdy_err; + kstat_named_t bd_rq_nodev_err; + kstat_named_t bd_rq_recov_err; + kstat_named_t bd_rq_illrq_err; + kstat_named_t bd_rq_pfa_err; +}; + +#define BD_ERR_MEDIA 0 +#define BD_ERR_NTRDY 1 +#define BD_ERR_NODEV 2 +#define BD_ERR_RECOV 3 +#define BD_ERR_ILLRQ 4 +#define BD_ERR_PFA 5 + +/* + * Note, one handler *per* address. Drivers with multiple targets at + * different addresses must use separate handles. + */ +bd_handle_t bd_alloc_handle(void *, bd_ops_t *, ddi_dma_attr_t *, int); +void bd_free_handle(bd_handle_t); +const char *bd_address(bd_handle_t); +void bd_xfer_done(bd_xfer_t *, int); +void bd_error(bd_xfer_t *, int); +void bd_mod_init(struct dev_ops *); +void bd_mod_fini(struct dev_ops *); + +/* + * The following functions will cause the various bd_ops entries that were + * registered to be called. Locks should not be held across any calls to these. + */ +int bd_attach_handle(dev_info_t *, bd_handle_t); +int bd_detach_handle(bd_handle_t); +void bd_state_change(bd_handle_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BLKDEV_H */ diff --git a/illumos-x86_64/usr/include/sys/bofi.h b/illumos-x86_64/usr/include/sys/bofi.h new file mode 100644 index 00000000..4df4611f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bofi.h @@ -0,0 +1,266 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_BOFI_H +#define _SYS_BOFI_H + +/* + * header file for bus_ops fault injector + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * ioctl command values + */ +#define BOFI_ADD_DEF 0 +#define BOFI_DEL_DEF 1 +#define BOFI_START 2 +#define BOFI_STOP 3 +#define BOFI_CHK_STATE 8 +#define BOFI_CHK_STATE_W 9 +#define BOFI_BROADCAST 10 +#define BOFI_CLEAR_ACC_CHK 11 +#define BOFI_CLEAR_ERRORS 12 +#define BOFI_CLEAR_ERRDEFS 13 +#define BOFI_GET_HANDLES 16 +#define BOFI_GET_HANDLE_INFO 17 + +#define NAMESIZE 256 +#define ERRMSGSIZE 256 + +struct acc_log_elem { + hrtime_t access_time; /* timestamp */ + uint_t access_type; /* the type of access */ + uint_t _pad; /* pad struct to multiple of 8 bytes for x86 */ + offset_t offset; /* the offset into handle */ + uint64_t value; /* the value being read or written */ + uint32_t size; /* the size (in bytes) of the transaction */ + uint32_t repcount; /* repcount parameter of a ddi_repX routine */ +}; + +/* Access logging flags */ +#define BOFI_LOG_REPIO 0x1 /* log ddi_repX as multiple accesses */ +#define BOFI_LOG_WRAP 0x2 /* do continuous logging of accesses */ +#define BOFI_LOG_FULL 0x4 /* lets callers know if the log has wrapped */ +#define BOFI_LOG_TIMESTAMP 0x8 /* timestamp each log entry */ + +struct acc_log { + uint32_t logsize; /* length of the logbase array */ + uint32_t entries; /* number of valid log elements */ + uint_t flags; /* access logging flags */ + uint_t wrapcnt; /* wrap cnt */ + hrtime_t start_time; /* activation time */ + hrtime_t stop_time; /* deactivation time (or time when full) */ + caddr_t logbase; /* pointer to acc_log_elem struct */ +}; +#if defined(_SYSCALL32) + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +struct acc_log32 { + uint32_t logsize; /* length of the logbase array */ + uint32_t entries; /* number of valid log elements */ + uint_t flags; /* access logging flags */ + uint_t wrapcnt; /* wrap cnt */ + hrtime_t start_time; /* activation time */ + hrtime_t stop_time; /* deactivation time (or time when full) */ + caddr32_t logbase; /* pointer to acc_log_elem struct */ +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ + +struct bofi_errdef { + uint_t namesize; + char name[NAMESIZE]; /* as returned by ddi_get_name() */ + /* pointer to char */ + int instance; /* as returned by ddi_get_instance() */ + int rnumber; /* as used by ddi_regs_map_setup() */ + offset_t offset; /* as used by ddi_regs_map_setup() */ + offset_t len; /* as used by ddi_regs_map_setup() */ + uint_t access_type; + uint_t access_count; + uint_t fail_count; + uint_t acc_chk; + uint_t optype; + uint64_t operand; + struct acc_log log; + uint64_t errdef_handle; /* pointer to void */ +}; +#if defined(_SYSCALL32) + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +struct bofi_errdef32 { + uint_t namesize; + char name[NAMESIZE]; /* as returned by ddi_get_name() */ + /* pointer to char */ + int instance; /* as returned by ddi_get_instance() */ + int rnumber; /* as used by ddi_regs_map_setup() */ + offset_t offset; /* as used by ddi_regs_map_setup() */ + offset_t len; /* as used by ddi_regs_map_setup() */ + uint_t access_type; + uint_t access_count; + uint_t fail_count; + uint_t acc_chk; + uint_t optype; + uint64_t operand; + struct acc_log32 log; + uint64_t errdef_handle; /* pointer to void */ +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ + +struct bofi_errctl { + uint_t namesize; + char name[NAMESIZE]; /* as returned by ddi_get_name() */ + int instance; /* as returned by ddi_get_instance() */ +}; + +struct bofi_get_handles { + uint_t namesize; + char name[NAMESIZE]; /* as returned by ddi_get_name() */ + int instance; /* as returned by ddi_get_instance() */ + int count; + caddr_t buffer; +}; +#if defined(_SYSCALL32) +struct bofi_get_handles32 { + uint_t namesize; + char name[NAMESIZE]; /* as returned by ddi_get_name() */ + int instance; /* as returned by ddi_get_instance() */ + int count; + caddr32_t buffer; +}; +#endif /* _SYSCALL32 */ + +struct handle_info { + int instance; + uint_t access_type; + int rnumber; + int _pad; /* pad to 8 bytes for x86 */ + offset_t len; + offset_t offset; + uint64_t addr_cookie; +}; + +struct bofi_get_hdl_info { + uint_t namesize; + char name[NAMESIZE]; /* as returned by ddi_get_name() */ + int count; /* number of handle_info structures */ + caddr_t hdli; /* pointer to struct handle_info */ +}; +#if defined(_SYSCALL32) +struct bofi_get_hdl_info32 { + uint_t namesize; + char name[NAMESIZE]; /* as returned by ddi_get_name() */ + int count; /* number of handle_info structures */ + caddr32_t hdli; /* pointer to struct handle_info */ +}; +#endif /* _SYSCALL32 */ + +/* + * values for optype + */ +#define BOFI_EQUAL 0 +#define BOFI_AND 1 +#define BOFI_OR 2 +#define BOFI_XOR 3 +#define BOFI_NO_TRANSFER 4 +#define BOFI_DELAY_INTR 5 +#define BOFI_LOSE_INTR 6 +#define BOFI_EXTRA_INTR 7 +#define BOFI_NOP 16 +/* + * values for access_type + */ +#define BOFI_PIO_R 1 +#define BOFI_PIO_W 2 +#define BOFI_PIO_RW (BOFI_PIO_R|BOFI_PIO_W) +#define BOFI_DMA_R 4 +#define BOFI_DMA_W 8 +#define BOFI_DMA_RW (BOFI_DMA_R|BOFI_DMA_W) +#define BOFI_INTR 64 +#define BOFI_LOG 128 + +struct bofi_errstate { + hrtime_t fail_time; /* time that count went to zero */ + hrtime_t msg_time; /* time that ddi_report_error was called */ + uint_t access_count; + uint_t fail_count; + uint_t acc_chk; + uint_t errmsg_count; + char buffer[ERRMSGSIZE]; + ddi_fault_impact_t severity; + struct acc_log log; + uint64_t errdef_handle; +}; +#if defined(_SYSCALL32) + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +struct bofi_errstate32 { + hrtime_t fail_time; /* time that count went to zero */ + hrtime_t msg_time; /* time that ddi_report_error was called */ + uint_t access_count; + uint_t fail_count; + uint_t acc_chk; + uint_t errmsg_count; + char buffer[ERRMSGSIZE]; + ddi_fault_impact_t severity; + struct acc_log32 log; + uint64_t errdef_handle; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BOFI_H */ diff --git a/illumos-x86_64/usr/include/sys/bofi_impl.h b/illumos-x86_64/usr/include/sys/bofi_impl.h new file mode 100644 index 00000000..653ea34a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bofi_impl.h @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_BOFI_IMPL_H +#define _SYS_BOFI_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct bofi_errent { + struct bofi_errent *next; /* next on in-use chain */ + struct bofi_errent *cnext; /* next on clone chain */ + struct bofi_errent *cprev; /* prev on clone chain */ + struct bofi_errdef errdef; + struct bofi_errstate errstate; + caddr_t name; + struct acc_log_elem *logbase; + uint_t state; + kcondvar_t cv; + ddi_softintr_t softintr_id; +}; + +/* + * values for state + */ +#define BOFI_DEV_ACTIVE 1 +#define BOFI_NEW_MESSAGE 2 +#define BOFI_MESSAGE_WAIT 4 +#define BOFI_DEBUG 8 + +#define BOFI_NLINKS 8192 + +struct bofi_link { + struct bofi_link *link; /* next on shadow handle chain */ + struct bofi_errent *errentp; /* pointer to corresponding errent */ +}; + +struct bofi_shadow { + union { +#ifdef __sparc + struct dvma_ops dvma_ops; +#endif + ddi_acc_impl_t acc; + struct { + uint_t (*int_handler)(caddr_t, caddr_t); + caddr_t int_handler_arg1; + caddr_t int_handler_arg2; + } intr; + } save; + struct bofi_shadow *next; /* next on inuse chain */ + struct bofi_shadow *prev; /* prev on inuse chain */ + struct bofi_shadow *hnext; /* next on hhash chain */ + struct bofi_shadow *hprev; /* prev on hhash chain */ + struct bofi_shadow *dnext; /* next on dhash chain */ + struct bofi_shadow *dprev; /* prev on dhash chain */ + struct bofi_link *link; /* errdef chain */ + uint_t type; + union { + ddi_dma_handle_t dma_handle; + ddi_acc_handle_t acc_handle; + } hdl; + uint32_t bofi_inum; + dev_info_t *dip; + char name[NAMESIZE]; /* as returned by ddi_get_name() */ + int instance; /* as returned by ddi_get_instance() */ + int rnumber; + offset_t offset; + offset_t len; + caddr_t addr; + caddr_t mapaddr; + caddr_t origaddr; + caddr_t allocaddr; + uint_t flags; + int map_flags; + page_t *map_pp; + page_t **map_pplist; + struct bofi_shadow **hparrayp; + int hilevel; + ddi_umem_cookie_t umem_cookie; +}; + +/* + * values for type + */ +#define BOFI_ACC_HDL 1 +#define BOFI_DMA_HDL 2 +#define BOFI_INT_HDL 3 +#define BOFI_NULL 4 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BOFI_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/bootconf.h b/illumos-x86_64/usr/include/sys/bootconf.h new file mode 100644 index 00000000..311fd40e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bootconf.h @@ -0,0 +1,267 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2016 Nexenta Systems, Inc. + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_BOOTCONF_H +#define _SYS_BOOTCONF_H + + +/* + * Boot time configuration information objects + */ + +#include +#include /* for struct bop_regs */ +#include +#include /* for struct dirent */ +#include +#include +#include +#include /* for IFNAMSIZ */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define BP_MAX_STRLEN 32 + +/* + * Boot property names + */ +#define BP_CPU_APICID_ARRAY "cpu_apicid_array" +#define BP_LGRP_SLIT_ENABLE "lgrp_slit_enable" +#define BP_LGRP_SRAT_ENABLE "lgrp_srat_enable" +#define BP_LGRP_MSCT_ENABLE "lgrp_msct_enable" +#define BP_LGRP_TOPO_LEVELS "lgrp_topo_levels" + +/* + * masks to hand to bsys_alloc memory allocator + * XXX These names shouldn't really be srmmu derived. + */ +#define BO_NO_ALIGN 0x00001000 + +/* flags for BOP_EALLOC */ +#define BOPF_X86_ALLOC_CLIENT 0x001 +#define BOPF_X86_ALLOC_REAL 0x002 +#define BOPF_X86_ALLOC_IDMAP 0x003 +#define BOPF_X86_ALLOC_PHYS 0x004 + +/* return values for the newer bootops */ +#define BOOT_SUCCESS 0 +#define BOOT_FAILURE (-1) + +/* top of boot scratch memory: 15 MB; multiboot loads at 16 MB */ +#define MAGIC_PHYS 0xF00000 + +/* + * We pass a ptr to the space that boot has been using + * for its memory lists. + */ +struct bsys_mem { + struct memlist *physinstalled; /* amt of physmem installed */ + struct memlist *rsvdmem; /* amt of bios reserved mem */ + struct memlist *physavail; /* amt of physmem avail for use */ + struct memlist *virtavail; /* amt of virtmem avail for use */ + struct memlist *pcimem; /* amt of pcimem avail for use */ + uint_t extent; /* number of bytes in the space */ +}; + +/* + * Warning: Changing BO_VERSION blows compatibility between booters + * and older kernels. If you want to change the struct bootops, + * please consider adding new stuff to the end and using the + * "bootops-extensions" mechanism described below. + */ +#define BO_VERSION 10 /* bootops interface revision # */ + +typedef struct bootops { + /* + * the ubiquitous version number + */ + uint_t bsys_version; + + /* + * the area containing boot's memlists + */ + struct bsys_mem *boot_mem; + + /* + * have boot allocate size bytes at virthint + */ + caddr_t (*bsys_alloc)(struct bootops *, caddr_t virthint, size_t size, + int align); + + /* + * free size bytes allocated at virt - put the + * address range back onto the avail lists. + */ + void (*bsys_free)(struct bootops *, caddr_t virt, size_t size); + + /* + * to find the size of the buffer to allocate + */ + int (*bsys_getproplen)(struct bootops *, const char *); + + /* + * get the value associated with this name + */ + int (*bsys_getprop)(struct bootops *, const char *, void *); + + /* + * get the name of the next property in succession + * from the standalone + */ + char *(*bsys_nextprop)(struct bootops *, char *prevprop); + + /* + * print formatted output + */ + void (*bsys_printf)(void *, const char *, ...); + + /* + * Do a real mode interrupt + */ + void (*bsys_doint)(struct bootops *, int, struct bop_regs *); + + /* + * Enhanced version of bsys_alloc(). + */ + caddr_t (*bsys_ealloc)(struct bootops *, caddr_t virthint, size_t size, + int align, int flags); + + /* end of bootops which exist if (bootops-extensions >= 1) */ +} bootops_t; + +#define BOP_GETVERSION(bop) ((bop)->bsys_version) +#define BOP_ALLOC(bop, virthint, size, align) \ + ((bop)->bsys_alloc)(bop, virthint, size, align) +#define BOP_FREE(bop, virt, size) ((bop)->bsys_free)(bop, virt, size) +#define BOP_GETPROPLEN(bop, name) ((bop)->bsys_getproplen)(bop, name) +#define BOP_GETPROP(bop, name, buf) ((bop)->bsys_getprop)(bop, name, buf) +#define BOP_NEXTPROP(bop, prev) ((bop)->bsys_nextprop)(bop, prev) +#define BOP_DOINT(bop, intnum, rp) ((bop)->bsys_doint)(bop, intnum, rp) +#define BOP_EALLOC(bop, virthint, size, align, flags)\ + ((bop)->bsys_ealloc)(bop, virthint, size, align, flags) + +#define BOP_PUTSARG(bop, msg, arg) ((bop)->bsys_printf)(bop, msg, arg) + +#if defined(_KERNEL) && !defined(_BOOT) + +/* + * Boot configuration information + */ + +#define BO_MAXFSNAME 16 +#define BO_MAXOBJNAME 256 + +struct bootobj { + char bo_fstype[BO_MAXFSNAME]; /* vfs type name (e.g. nfs) */ + char bo_name[BO_MAXOBJNAME]; /* name of object */ + int bo_flags; /* flags, see below */ + int bo_size; /* number of blocks */ + struct vnode *bo_vp; /* vnode of object */ + char bo_devname[BO_MAXOBJNAME]; + char bo_ifname[BO_MAXOBJNAME]; + int bo_ppa; +}; + +/* + * flags + */ +#define BO_VALID 0x01 /* all information in object is valid */ +#define BO_BUSY 0x02 /* object is busy */ + +extern struct bootobj rootfs; +extern struct bootobj swapfile; + +extern char obp_bootpath[BO_MAXOBJNAME]; + +extern void *gfx_devinfo_list; + +extern dev_t getrootdev(void); +extern void getfsname(char *, char *, size_t); +extern int loadrootmodules(void); + +extern int strplumb(void); +extern int strplumb_load(void); +extern char *strplumb_get_netdev_path(void); + +extern void consconfig(void); +extern void release_bootstrap(void); + +extern void param_check(void); +extern int octet_to_hexascii(const void *, uint_t, char *, uint_t *); + +extern int dhcpinit(void); + +extern struct bootops *bootops; +extern int netboot; +extern int swaploaded; +extern int modrootloaded; +extern char kern_bootargs[]; +extern char kern_bootfile[]; +extern char *kobj_module_path; +extern char *default_path; +extern char *dhcack; +extern int dhcacklen; +extern char dhcifname[IFNAMSIZ]; +extern char *netdev_path; + +extern void bop_no_more_mem(void); + +/*PRINTFLIKE2*/ +extern void bop_printf(void *, const char *, ...) + __KPRINTFLIKE(2); +extern void vbop_printf(void *, const char *, va_list); + +/*PRINTFLIKE1*/ +extern void bop_panic(const char *, ...) + __KPRINTFLIKE(1) __NORETURN; +#pragma rarely_called(bop_panic) + +extern void read_bootenvrc(void); + +extern int bootprop_getval(const char *, u_longlong_t *); +extern int bootprop_getstr(const char *, char *, size_t); + +/* + * Back door to fakebop.c to get physical memory allocated. + * 64 bit data types are fixed for 32 bit PAE use. + */ +extern paddr_t do_bop_phys_alloc(uint64_t, uint64_t); + +extern int do_bsys_getproplen(bootops_t *, const char *); +extern int do_bsys_getprop(bootops_t *, const char *, void *); +extern int do_bsys_getproptype(bootops_t *, const char *); + +#endif /* _KERNEL && !_BOOT */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BOOTCONF_H */ diff --git a/illumos-x86_64/usr/include/sys/bootregs.h b/illumos-x86_64/usr/include/sys/bootregs.h new file mode 100644 index 00000000..dffac520 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bootregs.h @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_BOOTREGS_H +#define _SYS_BOOTREGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_BOOT) + +/* + * This structure is used by bootops to save/restore registers when + * transferring between protected and realmode code. + * + * NOTE: The following macros require an ANSI compiler! + */ + +#define i8080reg(r) union { /* 8080-like "general purpose" registers */\ + uint32_t e ## r ## x; \ + struct { uint16_t r ## x; } word; \ + struct { uint8_t r ## l, r ## h; } byte; \ +} + +#define i8086reg(r) union { /* 16/32-bit "special purpose" registers */\ + uint32_t e ## r; \ + struct { uint16_t r; } word; \ +} + +struct bop_regs { + /* + * Machine state structure for realmode <-> protected mode callout + * operations: + */ + + i8080reg(a) eax; /* The so-called "general purpose" registers */ + i8080reg(d) edx; + i8080reg(c) ecx; + i8080reg(b) ebx; + + i8086reg(bp) ebp; /* 16/32-bit "pointer" registers */ + i8086reg(si) esi; + i8086reg(di) edi; + + uint16_t ds; /* Segment registers */ + uint16_t es; + uint16_t fs; + uint16_t gs; + + uint32_t eflags; +}; + +#undef i8080reg +#undef i8086reg +#endif /* _KERNEL || _BOOT */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BOOTREGS_H */ diff --git a/illumos-x86_64/usr/include/sys/bootstat.h b/illumos-x86_64/usr/include/sys/bootstat.h new file mode 100644 index 00000000..572a529b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bootstat.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_BOOTSTAT_H +#define _SYS_BOOTSTAT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * 32/64-bit neutral stat and time structure to allow booters to be shared + * among ILP32 and LP64 kernels. + */ +typedef struct boottime { + int64_t tv_sec; + int64_t tv_nsec; +} boottime_t; + +/* + * Current booters only support mode and size, with the exception of + * nfs booter also uses ino. + */ +struct bootstat { + uint64_t st_dev; + uint64_t st_ino; + uint32_t st_mode; + uint32_t st_nlink; + int32_t st_uid; + int32_t st_gid; + uint64_t st_rdev; + uint64_t st_size; + boottime_t st_atim; + boottime_t st_mtim; + boottime_t st_ctim; + int32_t st_blksize; + int64_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; +}; + +/* + * Special struct for compressed files. + * Only used by kobj to decompress files before + * root is mounted. Afterwards, dcfs will take + * over decompression. + */ +struct compinfo { + int iscmp; + size_t fsize; + size_t blksize; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BOOTSTAT_H */ diff --git a/illumos-x86_64/usr/include/sys/bootsvcs.h b/illumos-x86_64/usr/include/sys/bootsvcs.h new file mode 100644 index 00000000..11d57172 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bootsvcs.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_BOOTSVCS_H +#define _SYS_BOOTSVCS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Boot time configuration information objects + * + * The BS_VERSION version number should be incremented when adding + * new boot_syscalls entry points. The kernel can check the boot_syscalls + * version number by looking up the BS_VERSION_PROP property in the + * device tree. This version number allows the kernel to detect if the + * version of boot.bin that loaded it supports newer boot_syscalls entry + * points. This in turn allows the kernel to potentially support + * backward compatibility with older versions of boot.bin that don't + * support newer entry points. + * + * (Before we get too carried away with extending this interface, + * realize how broken it is. Even with a cleaner namespace than + * we used to have prior to S10, it is -extremely- difficult to + * interpose upon because the method pointer is NOT passed to the + * methods. We would do well to extend the bootops and EOL this + * interface as fast as possible, rather than to add more to it.) + */ +#define BS_VERSION 4 +#define BS_VERSION_PROP "bs-version" + +typedef struct boot_syscalls { /* offset */ + int (*bsvc_getchar)(); /* 7 - getchar */ + void (*bsvc_putchar)(int); /* 8 - putchar */ + int (*bsvc_ischar)(); /* 9 - ischar */ +} boot_syscalls_t; + +#ifdef _KMDB +extern boot_syscalls_t *kmdb_sysp; +#define SYSP kmdb_sysp +#else /* !_KMDB */ +extern boot_syscalls_t *sysp; +#define SYSP sysp +#endif + +#define BSVC_GETCHAR(sysp) (((sysp)->bsvc_getchar)()) +#define BSVC_PUTCHAR(sysp, c) (((sysp)->bsvc_putchar)(c)) +#define BSVC_ISCHAR(sysp) (((sysp)->bsvc_ischar)()) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BOOTSVCS_H */ diff --git a/illumos-x86_64/usr/include/sys/bpp_io.h b/illumos-x86_64/usr/include/sys/bpp_io.h new file mode 100644 index 00000000..bca9d636 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bpp_io.h @@ -0,0 +1,189 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1990,1991,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_BPP_IO_H +#define _SYS_BPP_IO_H + +/* + * I/O header file for the bidirectional parallel port + * driver (bpp) for the Zebra SBus card. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* #defines (not struct elements) below */ + +/* + * Minor device number encoding (should not be here): + */ +#define BPP_UNIT(dev) getminor(*dev) + +/* + * ioctl defines for cmd argument + */ + /* set contents of transfer parms structure */ +#define BPPIOC_SETPARMS _IOW('b', 1, struct bpp_transfer_parms) + /* read contents of transfer parms structure */ +#define BPPIOC_GETPARMS _IOR('b', 2, struct bpp_transfer_parms) + /* set contents of output pins structure */ +#define BPPIOC_SETOUTPINS _IOW('b', 3, struct bpp_pins) + /* read contents of output pins structure */ +#define BPPIOC_GETOUTPINS _IOR('b', 4, struct bpp_pins) + /* read contents of snapshot error status structure */ +#define BPPIOC_GETERR _IOR('b', 5, struct bpp_error_status) + /* pretend to attempt a data transfer */ +#define BPPIOC_TESTIO _IO('b', 6) +/* ioctl values 7-12 are test-only and are reserved */ + + +/* Structure definitions and locals #defines below */ + +#define MAX_TIMEOUT 1800000 /* maximum read/write timeout */ + /* 30 minutes */ +/* + * #defines and enum variables, and general comments for the + * bpp_transfer_parms structure. + */ + +/* Values for read_handshake and write_handshake fields */ +enum handshake_t { + BPP_NO_HS = 1, /* no handshake pins */ + BPP_ACK_HS = 2, /* handshake controlled by ACK line */ + BPP_BUSY_HS = 3, /* handshake controlled by BSY line */ + BPP_ACK_BUSY_HS = 4, /* handshake controlled by ACK and BSY lines */ + /* read_handshake only! */ + BPP_XSCAN_HS = 5, /* xerox scanner mode, read_handshake only! */ + BPP_HSCAN_HS = 6, /* HP scanjet scanner mode */ + /* read_handshake only! */ + BPP_CLEAR_MEM = 7, /* write 0's to memory, read_handshake only! */ + BPP_SET_MEM = 8, /* write 1's to memory, read_handshake only! */ + /* The following handshakes are RESERVED. Do not use. */ + BPP_VPRINT_HS = 9, /* valid only in read/write mode */ + BPP_VPLOT_HS = 10 /* valid only in read/write mode */ +}; + +/* + * The read_setup_time field indicates + * dstrb- to bsy+ in BPP_HS_NOHS or BPP_HS_ACKHS + * dstrb- to ack+ in BPP_HS_ACKHS or BPP_HS_ACKBUSYHS + * ack- to dstrb+ in BPP_HS_XSCANHS + * + * The read_strobe_width field indicates + * ack+ to ack- in BPP_HS_ACKHS or BPP_HS_ACKBUSYHS + * dstrb+ to dstrb- in BPP_HS_XSCANHS + */ + +/* Values allowed for write_handshake field */ +/* + * these are duplicates of the definitions above + * BPP_HS_NOHS + * BPP_HS_ACKHS + * BPP_HS_BUSYHS + */ + +/* + * The write_setup_time field indicates + * data valid to dstrb+ in all handshakes + * + * The write_strobe_width field indicates + * dstrb+ to dstrb- in non-reserved handshakes + * minimum dstrb+ to dstrb- in BPP_HS_VPRINTHS or BPP_HS_VPLOTHS + */ + + +/* + * This structure is used to configure the hardware handshake and + * timing modes. + */ +struct bpp_transfer_parms { + enum handshake_t + read_handshake; /* parallel port read handshake mode */ + int read_setup_time; /* DSS register - in nanoseconds */ + int read_strobe_width; /* DSW register - in nanoseconds */ + int read_timeout; /* wait this many microseconds */ + /* before aborting a transfer */ + enum handshake_t + write_handshake; /* parallel port write handshake mode */ + int write_setup_time; /* DSS register - in nanoseconds */ + int write_strobe_width; /* DSW register - in nanoseconds */ + int write_timeout; /* wait this many microseconds */ + /* before aborting a transfer */ +}; + +struct bpp_pins { + uchar_t output_reg_pins; /* pins in P_OR register */ + uchar_t input_reg_pins; /* pins in P_IR register */ +}; + + +/* + * #defines and general comments for + * the bpp_pins structure. + */ +/* Values for output_reg_pins field */ +#define BPP_SLCTIN_PIN 0x01 /* Select in pin */ +#define BPP_AFX_PIN 0x02 /* Auto feed pin */ +#define BPP_INIT_PIN 0x04 /* Initialize pin */ +#define BPP_V1_PIN 0x08 /* reserved pin 1 */ +#define BPP_V2_PIN 0x10 /* reserved pin 2 */ +#define BPP_V3_PIN 0x20 /* reserved pin 3 */ + +#define BPP_ALL_OUT_PINS (BPP_SLCTIN_PIN | BPP_AFX_PIN | BPP_INIT_PIN |\ + BPP_V1_PIN | BPP_V2_PIN | BPP_V3_PIN) + +/* Values for input_reg_pins field */ +#define BPP_ERR_PIN 0x01 /* Error pin */ +#define BPP_SLCT_PIN 0x02 /* Select pin */ +#define BPP_PE_PIN 0x04 /* Paper empty pin */ + +#define BPP_ALL_IN_PINS (BPP_ERR_PIN | BPP_SLCT_PIN | BPP_PE_PIN) + +struct bpp_error_status { + char timeout_occurred; /* 1 if a timeout occurred */ + char bus_error; /* 1 if an SBus bus error */ + uchar_t pin_status; /* status of pins which could */ + /* cause an error */ +}; + +/* + * #defines for the bpp_error_status structure + */ +/* Values for pin_status field */ +#define BPP_ERR_ERR 0x01 /* Error pin active */ +#define BPP_SLCT_ERR 0x02 /* Select pin active */ +#define BPP_PE_ERR 0x04 /* Paper empty pin active */ +#define BPP_SLCTIN_ERR 0x10 /* Select in pin active */ +#define BPP_BUSY_ERR 0x40 /* Busy pin active */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_BPP_IO_H */ diff --git a/illumos-x86_64/usr/include/sys/brand.h b/illumos-x86_64/usr/include/sys/brand.h new file mode 100644 index 00000000..118d65a1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/brand.h @@ -0,0 +1,307 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_BRAND_H +#define _SYS_BRAND_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +/* + * All Brands supported by this kernel must use BRAND_VER_1. + */ +#define BRAND_VER_1 1 + +/* + * sub-commands to brandsys. + * 1 - 128 are for common commands + * 128+ are available for brand-specific commands. + */ +#define B_REGISTER 1 +#define B_TTYMODES 2 +#define B_ELFDATA 3 +#define B_EXEC_NATIVE 4 +#define B_EXEC_BRAND 5 +#define B_TRUSS_POINT 6 + +/* + * Structure used by zoneadmd to communicate the name of a brand and the + * supporting brand module into the kernel. + */ +struct brand_attr { + char ba_brandname[MAXNAMELEN]; + char ba_modname[MAXPATHLEN]; +}; + +/* What we call the native brand. */ +#define NATIVE_BRAND_NAME "native" + +/* What we call the labeled brand. */ +#define LABELED_BRAND_NAME "labeled" + +/* + * Aux vector containing lddata pointer of brand library linkmap. + * Used by common {brand}_librtld_db. + */ +#define AT_SUN_BRAND_COMMON_LDDATA AT_SUN_BRAND_AUX1 + +/* + * Information needed by the brand library to launch an executable. + */ +typedef struct brand_elf_data { + ulong_t sed_phdr; + ulong_t sed_phent; + ulong_t sed_phnum; + ulong_t sed_entry; + ulong_t sed_base; + ulong_t sed_ldentry; + ulong_t sed_lddata; +} brand_elf_data_t; + +/* + * Common structure used to register a branded processes + */ +typedef struct brand_proc_reg { + uint_t sbr_version; /* version number */ + caddr_t sbr_handler; /* base address of handler */ +} brand_proc_reg_t; + +#ifdef _KERNEL + +struct proc; +struct uarg; +struct brand_mach_ops; +struct intpdata; +struct execa; + +/* + * Common structure to define hooks for brand operation. + * + * Required Fields: + * b_init_brand_data - Setup zone brand data during zone_setbrand + * b_free_brand_data - Free zone brand data during zone_destroy + * b_brandsys - Syscall handler for brandsys + * b_setbrand - Initialize process brand data + * b_getattr - Get brand-custom zone attribute + * b_setattr - Set brand-custom zone attribute + * b_copy_procdata - Copy process brand data during fork + * b_proc_exit - Perform process brand exit processing + * b_exec - Reset branded process state on exec + * b_lwp_setrval - Set return code for forked child + * b_initlwp - Initialize lwp brand data (cannot drop p->p_lock) + * b_forklwp - Copy lwp brand data during fork + * b_freelwp - Free lwp brand data + * b_lwpexit - Perform lwp-specific brand exit processing + * b_elfexec - Load and execute ELF binary + * b_sigset_native_to_brand - Convert sigset native->brand + * b_sigset_brand_to_native - Convert sigset brand->native + * b_nsig - Maxiumum signal number + * b_sendsig - Update process state after sendsig + * + * Optional Fields: + * b_lwpdata_alloc - Speculatively allocate data for use in b_initlwp + * b_lwpdata_free - Free data from allocated by b_lwpdata_alloc if errors occur + * during lwp creation before b_initlwp could be called. + * b_initlwp_post - Complete lwp branding (can temporarily drop p->p_lock) + * b_exit_with_sig - Instead of sending SIGCLD, exit with custom behavior + * b_psig_to_proc - Custom additional behavior during psig + * b_wait_filter - Filter processes from being matched by waitid + * b_native_exec - Provide interpreter path prefix for executables + * b_ptrace_exectrap - Custom behavior for legacy ptrace traps + * b_map32limit - Specify alternate limit for MAP_32BIT mappings + * b_stop_notify - Hook process stop events + * b_waitid_helper - Generate synthetic results for waitid + * b_sigcld_repost - Post synthetic SIGCLD signals + * b_issig_stop - Alter/suppress signal delivery during issig + * b_sig_ignorable - Disallow discarding of signals + * b_savecontext - Alter context during savecontext + * b_restorecontext - Alter context during restorecontext + * b_sendsig_stack - Override stack used for signal delivery + * b_setid_clear - Override setid_clear behavior + * b_pagefault - Trap pagefault events + * b_intp_parse_arg - Controls interpreter argument handling (allow 1 or all) + * b_clearbrand - Perform any actions necessary when clearing the brand. + * b_rpc_statd - Upcall to rpc.statd running within the zone + * b_acct_out - Output properly formatted accounting record + */ +struct brand_ops { + void (*b_init_brand_data)(zone_t *, kmutex_t *); + void (*b_free_brand_data)(zone_t *); + int (*b_brandsys)(int, int64_t *, uintptr_t, uintptr_t, uintptr_t, + uintptr_t); + void (*b_setbrand)(struct proc *); + int (*b_getattr)(zone_t *, int, void *, size_t *); + int (*b_setattr)(zone_t *, int, void *, size_t); + void (*b_copy_procdata)(struct proc *, struct proc *); + void (*b_proc_exit)(struct proc *); + void (*b_exec)(); + void (*b_lwp_setrval)(klwp_t *, int, int); + void *(*b_lwpdata_alloc)(struct proc *); + void (*b_lwpdata_free)(void *); + void (*b_initlwp)(klwp_t *, void *); + void (*b_initlwp_post)(klwp_t *); + void (*b_forklwp)(klwp_t *, klwp_t *); + void (*b_freelwp)(klwp_t *); + void (*b_lwpexit)(klwp_t *); + int (*b_elfexec)(struct vnode *, struct execa *, struct uarg *, + struct intpdata *, int, size_t *, int, caddr_t, struct cred *, + int *); + void (*b_sigset_native_to_brand)(sigset_t *); + void (*b_sigset_brand_to_native)(sigset_t *); + void (*b_sigfd_translate)(k_siginfo_t *); + int b_nsig; + void (*b_exit_with_sig)(proc_t *, sigqueue_t *); + boolean_t (*b_wait_filter)(proc_t *, proc_t *); + boolean_t (*b_native_exec)(uint8_t, const char **); + uint32_t (*b_map32limit)(proc_t *); + void (*b_stop_notify)(proc_t *, klwp_t *, ushort_t, ushort_t); + int (*b_waitid_helper)(idtype_t, id_t, k_siginfo_t *, int, + boolean_t *, int *); + int (*b_sigcld_repost)(proc_t *, sigqueue_t *); + int (*b_issig_stop)(proc_t *, klwp_t *); + boolean_t (*b_sig_ignorable)(proc_t *, klwp_t *, int); + void (*b_savecontext)(ucontext_t *); +#if defined(_SYSCALL32_IMPL) + void (*b_savecontext32)(ucontext32_t *); +#endif + void (*b_restorecontext)(ucontext_t *); + caddr_t (*b_sendsig_stack)(int); + void (*b_sendsig)(int); + int (*b_setid_clear)(vattr_t *vap, cred_t *cr); + int (*b_pagefault)(proc_t *, klwp_t *, caddr_t, enum fault_type, + enum seg_rw); + boolean_t b_intp_parse_arg; + void (*b_clearbrand)(proc_t *, boolean_t); + void (*b_rpc_statd)(int, void *, void *); + void (*b_acct_out)(struct vnode *, int); +}; + +/* + * The b_version field must always be the first entry in this struct. + */ +typedef struct brand { + int b_version; + char *b_name; + struct brand_ops *b_ops; + struct brand_mach_ops *b_machops; + size_t b_data_size; +} brand_t; + +extern brand_t native_brand; + +/* + * Convenience macros + */ +#define lwptolwpbrand(l) ((l)->lwp_brand) +#define ttolwpbrand(t) (lwptolwpbrand(ttolwp(t))) +#define PROC_IS_BRANDED(p) ((p)->p_brand != &native_brand) +#define ZONE_IS_BRANDED(z) ((z)->zone_brand != &native_brand) +#define BROP(p) ((p)->p_brand->b_ops) +#define ZBROP(z) ((z)->zone_brand->b_ops) +#define BRMOP(p) ((p)->p_brand->b_machops) +#define SIGSET_NATIVE_TO_BRAND(sigset) \ + if (PROC_IS_BRANDED(curproc) && \ + BROP(curproc)->b_sigset_native_to_brand) \ + BROP(curproc)->b_sigset_native_to_brand(sigset) +#define SIGSET_BRAND_TO_NATIVE(sigset) \ + if (PROC_IS_BRANDED(curproc) && \ + BROP(curproc)->b_sigset_brand_to_native) \ + BROP(curproc)->b_sigset_brand_to_native(sigset) + +extern void brand_init(); +extern int brand_register(brand_t *); +extern int brand_unregister(brand_t *); +extern brand_t *brand_register_zone(struct brand_attr *); +extern brand_t *brand_find_name(char *); +extern void brand_unregister_zone(brand_t *); +extern int brand_zone_count(brand_t *); +extern int brand_setbrand(proc_t *, boolean_t); +extern void brand_clearbrand(proc_t *, boolean_t); + +/* + * The following functions can be shared among kernel brand modules which + * implement Solaris-derived brands, all of which need to do similar tasks to + * manage the brand. + */ +extern int brand_solaris_cmd(int, uintptr_t, uintptr_t, uintptr_t, + struct brand *, int); +extern void brand_solaris_copy_procdata(proc_t *, proc_t *, + struct brand *); +extern int brand_solaris_elfexec(vnode_t *, execa_t *, uarg_t *, + intpdata_t *, int, size_t *, int, caddr_t, cred_t *, int *, + struct brand *, char *, char *, char *); +extern void brand_solaris_exec(struct brand *); +extern int brand_solaris_fini(char **, struct modlinkage *, + struct brand *); +extern void brand_solaris_forklwp(klwp_t *, klwp_t *, struct brand *); +extern void brand_solaris_freelwp(klwp_t *, struct brand *); +extern void brand_solaris_initlwp(klwp_t *, struct brand *); +extern void brand_solaris_lwpexit(klwp_t *, struct brand *); +extern void brand_solaris_proc_exit(struct proc *, struct brand *); +extern void brand_solaris_setbrand(proc_t *, struct brand *); + +#if defined(_SYSCALL32) +typedef struct brand_elf_data32 { + uint32_t sed_phdr; + uint32_t sed_phent; + uint32_t sed_phnum; + uint32_t sed_entry; + uint32_t sed_base; + uint32_t sed_ldentry; + uint32_t sed_lddata; +} brand_elf_data32_t; + +typedef struct brand_common_reg32 { + uint32_t sbr_version; /* version number */ + caddr32_t sbr_handler; /* base address of handler */ +} brand_common_reg32_t; +#endif /* _SYSCALL32 */ + +/* + * Common information associated with all branded processes + */ +typedef struct brand_proc_data { + caddr_t spd_handler; /* address of user-space handler */ + brand_elf_data_t spd_elf_data; /* common ELF data for branded app. */ +} brand_proc_data_t; + +#define BRAND_NATIVE_DIR "/.SUNWnative/" +#define BRAND_NATIVE_LINKER32 BRAND_NATIVE_DIR "lib/ld.so.1" +#define BRAND_NATIVE_LINKER64 BRAND_NATIVE_DIR "lib/64/ld.so.1" + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BRAND_H */ diff --git a/illumos-x86_64/usr/include/sys/buf.h b/illumos-x86_64/usr/include/sys/buf.h new file mode 100644 index 00000000..3f72dca1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/buf.h @@ -0,0 +1,415 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2012 Joyent, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_BUF_H +#define _SYS_BUF_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Each buffer in the pool is usually doubly linked into 2 lists: + * the device with which it is currently associated (always) + * and also on a list of blocks available for allocation + * for other use (usually). + * The latter list is kept in last-used order, and the two + * lists are doubly linked to make it easy to remove + * a buffer from one list when it was found by + * looking through the other. + * A buffer is on the available list, and is liable + * to be reassigned to another disk block, if and only + * if it is not marked BUSY. When a buffer is busy, the + * available-list pointers can be used for other purposes. + * Most drivers use the forward ptr as a link in their I/O active queue. + * A buffer header contains all the information required to perform I/O. + * Most of the routines which manipulate these things are in bio.c. + * + * There are a number of locks associated with the buffer management + * system. + * hbuf.b_lock: protects hash chains, buffer hdr freelists + * and delayed write freelist + * bfree_lock; protects the bfreelist structure + * bhdr_lock: protects the free header list + * blist_lock: protects b_list fields + * buf.b_sem: protects all remaining members in the buf struct + * buf.b_io: I/O synchronization variable + * + * A buffer header is never "locked" (b_sem) when it is on + * a "freelist" (bhdrlist or bfreelist avail lists). + */ +typedef struct buf { + int b_flags; /* see defines below */ + struct buf *b_forw; /* headed by d_tab of conf.c */ + struct buf *b_back; /* " */ + struct buf *av_forw; /* position on free list, */ + struct buf *av_back; /* if not BUSY */ + o_dev_t b_dev; /* OLD major+minor device name */ + size_t b_bcount; /* transfer count */ + union { + caddr_t b_addr; /* low order core address */ + struct fs *b_fs; /* superblocks */ + struct cg *b_cg; /* UFS cylinder group block */ + struct dinode *b_dino; /* UFS ilist */ + daddr32_t *b_daddr; /* disk blocks */ + } b_un; + + lldaddr_t _b_blkno; /* block # on device (union) */ +#define b_lblkno _b_blkno._f +#ifdef _LP64 +#define b_blkno _b_blkno._f +#else +#define b_blkno _b_blkno._p._l +#endif /* _LP64 */ + + char b_obs1; /* obsolete */ + size_t b_resid; /* words not transferred after error */ + clock_t b_start; /* request start time */ + struct proc *b_proc; /* process doing physical or swap I/O */ + struct page *b_pages; /* page list for PAGEIO */ + clock_t b_obs2; /* obsolete */ + /* Begin new stuff */ +#define b_actf av_forw +#define b_actl av_back +#define b_active b_bcount +#define b_errcnt b_resid + size_t b_bufsize; /* size of allocated buffer */ + int (*b_iodone)(struct buf *); /* function called by iodone */ + struct vnode *b_vp; /* vnode associated with block */ + struct buf *b_chain; /* chain together all buffers here */ + int b_obs3; /* obsolete */ + int b_error; /* expanded error field */ + void *b_private; /* "opaque" driver private area */ + dev_t b_edev; /* expanded dev field */ + ksema_t b_sem; /* Exclusive access to buf */ + ksema_t b_io; /* I/O Synchronization */ + struct buf *b_list; /* List of potential B_DELWRI bufs */ + struct page **b_shadow; /* shadow page list */ + void *b_dip; /* device info pointer */ + struct vnode *b_file; /* file associated with this buffer */ + offset_t b_offset; /* offset in file assoc. with buffer */ +} buf_t; + +/* + * Bufhd structures used at the head of the hashed buffer queues. + * We only need seven words for this, so this abbreviated + * definition saves some space. + */ +struct diskhd { + int b_flags; /* not used, needed for consistency */ + struct buf *b_forw, *b_back; /* queue of unit queues */ + struct buf *av_forw, *av_back; /* queue of bufs for this unit */ + o_dev_t b_dev; /* OLD major+minor device name */ + size_t b_bcount; /* transfer count */ +}; + + +/* + * Statistics on the buffer cache + */ +struct biostats { + kstat_named_t bio_lookup; /* requests to assign buffer */ + kstat_named_t bio_hit; /* buffer already associated with blk */ + kstat_named_t bio_bufwant; /* kmem_allocs NOSLEEP failed new buf */ + kstat_named_t bio_bufwait; /* kmem_allocs with KM_SLEEP for buf */ + kstat_named_t bio_bufbusy; /* buffer locked by someone else */ + kstat_named_t bio_bufdup; /* duplicate buffer found for block */ +}; + +/* + * These flags are kept in b_flags. + * The first group is part of the DDI + */ +#define B_BUSY 0x0001 /* not on av_forw/back list */ +#define B_DONE 0x0002 /* transaction finished */ +#define B_ERROR 0x0004 /* transaction aborted */ +#define B_PAGEIO 0x0010 /* do I/O to pages on bp->p_pages */ +#define B_PHYS 0x0020 /* Physical IO potentially using UNIBUS map */ +#define B_READ 0x0040 /* read when I/O occurs */ +#define B_WRITE 0x0100 /* non-read pseudo-flag */ + +/* Not part of the DDI */ +#define B_WANTED 0x0080 /* issue wakeup when BUSY goes off */ +#define B_AGE 0x000200 /* delayed write for correct aging */ +#define B_ASYNC 0x000400 /* don't wait for I/O completion */ +#define B_DELWRI 0x000800 /* delayed write-wait til buf needed */ +#define B_STALE 0x001000 /* on av_* list; invalid contents */ +#define B_DONTNEED 0x002000 /* after write, need not be cached */ +#define B_REMAPPED 0x004000 /* buffer is kernel addressable */ +#define B_FREE 0x008000 /* free page when done */ +#define B_INVAL 0x010000 /* destroy page when done */ +#define B_FORCE 0x020000 /* semi-permanent removal from cache */ +#define B_NOCACHE 0x080000 /* don't cache block when released */ +#define B_TRUNC 0x100000 /* truncate page without I/O */ +#define B_SHADOW 0x200000 /* is b_shadow field valid? */ +#define B_RETRYWRI 0x400000 /* retry write til works or bfinval */ +#define B_FAILFAST 0x1000000 /* Fail promptly if device goes away */ +#define B_STARTED 0x2000000 /* io:::start probe called for buf */ +#define B_ABRWRITE 0x4000000 /* Application based recovery active */ +#define B_PAGE_NOWAIT 0x8000000 /* Skip the page if it is locked */ +#define B_INVALCURONLY 0x10000000 /* invalidate only for curproc */ + +/* + * There is some confusion over the meaning of B_FREE and B_INVAL and what + * the use of one over the other implies. + * + * In both cases, when we are done with the page (buffer) we want to free + * up the page. In the case of B_FREE, the page will go to the cachelist. + * In the case of B_INVAL, the page will be destroyed (hashed out of it's + * vnode) and placed on the freelist. Beyond this, there is no difference + * between the sole use of these two flags. In both cases, IO will be done + * if the page is not yet committed to storage. + * + * The B_INVALCURONLY flag modifies the behavior of the B_INVAL flag and is + * intended to be used in conjunction with B_INVAL. B_INVALCURONLY has no + * meaning on its own. When both B_INVALCURONLY and B_INVAL are set, then + * the mapping for the page is only invalidated for the current process. + * In this case, the page is not destroyed unless this was the final mapping. + * + * In order to discard pages without writing them back, (B_INVAL | B_TRUNC) + * should be used. + * + * Use (B_INVAL | B_FORCE) to force the page to be destroyed even if we + * could not successfuly write out the page. + */ + +/* + * Insq/Remq for the buffer hash lists. + */ +#define bremhash(bp) { \ + ASSERT((bp)->b_forw != NULL); \ + ASSERT((bp)->b_back != NULL); \ + (bp)->b_back->b_forw = (bp)->b_forw; \ + (bp)->b_forw->b_back = (bp)->b_back; \ + (bp)->b_forw = (bp)->b_back = NULL; \ +} +#define binshash(bp, dp) { \ + ASSERT((bp)->b_forw == NULL); \ + ASSERT((bp)->b_back == NULL); \ + ASSERT((dp)->b_forw != NULL); \ + ASSERT((dp)->b_back != NULL); \ + (bp)->b_forw = (dp)->b_forw; \ + (bp)->b_back = (dp); \ + (dp)->b_forw->b_back = (bp); \ + (dp)->b_forw = (bp); \ +} + + +/* + * The hash structure maintains two lists: + * + * 1) The hash list of buffers (b_forw & b_back) + * 2) The LRU free list of buffers on this hash bucket (av_forw & av_back) + * + * The dwbuf structure keeps a list of delayed write buffers per hash bucket + * hence there are exactly the same number of dwbuf structures as there are + * the hash buckets (hbuf structures) in the system. + * + * The number of buffers on the freelist may not be equal to the number of + * buffers on the hash list. That is because when buffers are busy they are + * taken off the freelist but not off the hash list. "b_length" field keeps + * track of the number of free buffers (including delayed writes ones) on + * the hash bucket. The "b_lock" mutex protects the free list as well as + * the hash list. It also protects the counter "b_length". + * + * Enties b_forw, b_back, av_forw & av_back must be at the same offset + * as the ones in buf structure. + */ +struct hbuf { + int b_flags; + + struct buf *b_forw; /* hash list forw pointer */ + struct buf *b_back; /* hash list back pointer */ + + struct buf *av_forw; /* free list forw pointer */ + struct buf *av_back; /* free list back pointer */ + + int b_length; /* # of entries on free list */ + kmutex_t b_lock; /* lock to protect this structure */ +}; + + +/* + * The delayed list pointer entries should match with the buf strcuture. + */ +struct dwbuf { + int b_flags; /* not used */ + + struct buf *b_forw; /* not used */ + struct buf *b_back; /* not used */ + + struct buf *av_forw; /* delayed write forw pointer */ + struct buf *av_back; /* delayed write back pointer */ +}; + + +/* + * Unlink a buffer from the available (free or delayed write) list and mark + * it busy (internal interface). + */ +#define notavail(bp) \ +{\ + ASSERT(SEMA_HELD(&bp->b_sem)); \ + ASSERT((bp)->av_forw != NULL); \ + ASSERT((bp)->av_back != NULL); \ + ASSERT((bp)->av_forw != (bp)); \ + ASSERT((bp)->av_back != (bp)); \ + (bp)->av_back->av_forw = (bp)->av_forw; \ + (bp)->av_forw->av_back = (bp)->av_back; \ + (bp)->b_flags |= B_BUSY; \ + (bp)->av_forw = (bp)->av_back = NULL; \ +} + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +/* + * Macros to avoid the extra function call needed for binary compat. + * + * B_RETRYWRI is not included in clear_flags for BWRITE(), BWRITE2(), + * or brwrite() so that the retry operation is persistent until the + * write either succeeds or the buffer is bfinval()'d. + * + */ +#define BREAD(dev, blkno, bsize) \ + bread_common(/* ufsvfsp */ NULL, dev, blkno, bsize) + +#define BWRITE(bp) \ + bwrite_common(/* ufsvfsp */ NULL, bp, /* force_wait */ 0, \ + /* do_relse */ 1, \ + /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)) + +#define BWRITE2(bp) \ + bwrite_common(/* ufsvfsp */ NULL, bp, /* force_wait */ 1, \ + /* do_relse */ 0, \ + /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)) + +#define GETBLK(dev, blkno, bsize) \ + getblk_common(/* ufsvfsp */ NULL, dev, blkno, bsize, /* errflg */ 0) + + +/* + * Macros for new retry write interfaces. + */ + +/* + * Same as bdwrite() except write failures are retried. + */ +#define bdrwrite(bp) { \ + (bp)->b_flags |= B_RETRYWRI; \ + bdwrite((bp)); \ +} + +/* + * Same as bwrite() except write failures are retried. + */ +#define brwrite(bp) { \ + (bp)->b_flags |= B_RETRYWRI; \ + bwrite_common((bp), /* force_wait */ 0, /* do_relse */ 1, \ + /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)); \ +} + +extern struct hbuf *hbuf; /* Hash table */ +extern struct dwbuf *dwbuf; /* delayed write hash table */ +extern struct buf *buf; /* The buffer pool itself */ +extern struct buf bfreelist; /* head of available list */ + +extern void (*bio_lufs_strategy)(void *, buf_t *); /* UFS Logging */ +extern void (*bio_snapshot_strategy)(void *, buf_t *); /* UFS snapshots */ + +int bcheck(dev_t, struct buf *); +int iowait(struct buf *); +int hash2ints(int x, int y); +int bio_busy(int); +int biowait(struct buf *); +int biomodified(struct buf *); +int geterror(struct buf *); +void minphys(struct buf *); +/* + * ufsvfsp is declared as a void * to avoid having everyone that uses + * this header file include sys/fs/ufs_inode.h. + */ +void bwrite_common(void *ufsvfsp, struct buf *, int force_wait, + int do_relse, int clear_flags); +void bwrite(struct buf *); +void bwrite2(struct buf *); +void bdwrite(struct buf *); +void bawrite(struct buf *); +void brelse(struct buf *); +void iodone(struct buf *); +void clrbuf(struct buf *); +void bflush(dev_t); +void blkflush(dev_t, daddr_t); +void binval(dev_t); +int bfinval(dev_t, int); +void binit(void); +void biodone(struct buf *); +void bioinit(struct buf *); +void biofini(struct buf *); +void bp_mapin(struct buf *); +void *bp_mapin_common(struct buf *, int); +void bp_mapout(struct buf *); +int bp_copyin(struct buf *, void *, offset_t, size_t); +int bp_copyout(void *, struct buf *, offset_t, size_t); +void bp_init(size_t, uint_t); +int bp_color(struct buf *); +void pageio_done(struct buf *); +struct buf *bread(dev_t, daddr_t, long); +struct buf *bread_common(void *, dev_t, daddr_t, long); +struct buf *breada(dev_t, daddr_t, daddr_t, long); +struct buf *getblk(dev_t, daddr_t, long); +struct buf *getblk_common(void *, dev_t, daddr_t, long, int); +struct buf *ngeteblk(long); +struct buf *geteblk(void); +struct buf *pageio_setup(struct page *, size_t, struct vnode *, int); +void bioerror(struct buf *bp, int error); +void bioreset(struct buf *bp); +struct buf *bioclone(struct buf *, off_t, size_t, dev_t, daddr_t, + int (*)(struct buf *), struct buf *, int); +size_t biosize(void); +#endif /* defined(_KERNEL) || defined(_FAKE_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BUF_H */ diff --git a/illumos-x86_64/usr/include/sys/bufmod.h b/illumos-x86_64/usr/include/sys/bufmod.h new file mode 100644 index 00000000..efe99cbf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bufmod.h @@ -0,0 +1,135 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_BUFMOD_H +#define _SYS_BUFMOD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for the STREAMS Buffering module. + * + * The module gathers incoming (read-side) messages together into + * "chunks" and passes completed chunks up to the next module in + * line. The gathering process is controlled by two ioctl-settable + * parameters: + * + * timeout The maximum delay after passing the previous chunk + * upward before passing the current one up, even if the + * chunk isn't full. If the timeout value passed in is + * a null pointer, the timeout is infinite (as in the + * select system call); this is the default. + * chunksize The maximum size of a chunk of accumulated messages, + * unless a single message exceeds the chunksize, in + * which case it's passed up in a chunk containing only + * that message. Note that a given message's size includes + * the length of any leading M_PROTO blocks it may have. + * + * There is one important side-effect: setting the timeout to zero + * (polling) will force the chunksize to zero, regardless of its + * previous setting. + */ + +/* + * Ioctls. + */ +#define SBIOC ('B' << 8) +#define SBIOCSTIME (SBIOC|1) /* set timeout info */ +#define SBIOCGTIME (SBIOC|2) /* get timeout info */ +#define SBIOCCTIME (SBIOC|3) /* clear timeout */ +#define SBIOCSCHUNK (SBIOC|4) /* set chunksize */ +#define SBIOCGCHUNK (SBIOC|5) /* get chunksize */ +#define SBIOCSSNAP (SBIOC|6) /* set snapshot length */ +#define SBIOCGSNAP (SBIOC|7) /* get snapshot length */ +#define SBIOCSFLAGS (SBIOC|8) /* set buffering modes */ +#define SBIOCGFLAGS (SBIOC|9) /* get buffering modes */ + +/* + * Default chunk size. + */ +#define SB_DFLT_CHUNK 8192 /* arbitrary */ + +/* + * buffering flags + */ + +#define SB_SEND_ON_WRITE 1 /* return buffered read data on write */ +#define SB_NO_HEADER 2 /* don't add header structure to data */ +#define SB_NO_PROTO_CVT 4 /* don't convert proto to data */ +#define SB_DEFER_CHUNK 8 /* fast response time buffering */ +#define SB_NO_DROPS 16 /* Don't drop messages */ + +/* + * buffering state + */ +#define SB_FRCVD 1 /* first message in time window received */ + +/* + * When adding a given message to an accumulating chunk, the module + * first converts any leading M_PROTO data block to M_DATA. + * It then constructs an sb_hdr (defined below), prepends it to + * the message, and pads the result out to force its length to a + * multiple of a machine-dependent alignment size guaranteed to be + * at least sizeof (ulong_t). It then adds the padded message to the + * chunk. + * + * sb_origlen is the original length of the message after the M_PROTO => M_DATA + * conversion, but before truncating or adding the header. + * + * sb_msglen is the length of the message after truncation, but before + * adding the header. + * + * sb_totlen is the length of the message after truncation, and including + * both the header itself and the trailing padding bytes. + * + * sb_drops is the cumulative number of messages dropped by the module + * due to stream read-side flow control or resource exhaustion. + * + * sb_timestamp is the packet arrival time expressed as a 'struct timeval'. + */ + +struct sb_hdr { + uint_t sbh_origlen; + uint_t sbh_msglen; + uint_t sbh_totlen; + uint_t sbh_drops; +#if defined(_LP64) + struct timeval32 sbh_timestamp; +#else + struct timeval sbh_timestamp; +#endif /* !_LP64 */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BUFMOD_H */ diff --git a/illumos-x86_64/usr/include/sys/bustypes.h b/illumos-x86_64/usr/include/sys/bustypes.h new file mode 100644 index 00000000..226b9e2e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/bustypes.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1989-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_BUSTYPES_H +#define _SYS_BUSTYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Defines for bus types. These are magic cookies passed between drivers + * and their parents to describe their address space. Configuration mechanisms + * use this as well. Root nexus drivers on implementations using + * "generic-addressing" also use these to describe register properties. + * Generally, this will be non-self configuring architectures. + * + * + * On machines supporting "generic-addressing" in the root nexus, + * the generic cookies described in the bootom of the file are used + * to distinguish the spaces described by device regsiters. + * + * Sun machines generally support OBMEM and OBIO spaces. + */ + +#define SP_VIRTUAL 0x0100 /* virtual address */ +#define SP_OBMEM 0x0200 /* on board memory */ +#define SP_OBIO 0x0210 /* on board i/o */ + +/* + * The following are some Cookie name/value suggestions... + * and are not necessarily supported at all (nexi for these devices + * must handle and convert any requests for these spaces.) + */ + +#define SP_SBUS 0x0400 /* SBus device bus */ +#define SB_XBOX 0x0500 /* XBox device bus */ + +#define SP_MBMEM 0x1000 /* MultiBus memory */ +#define SP_MBIO 0x1100 /* MultiBus IO */ + +#define SP_ATMEM 0x2000 /* AT Bus Memory */ +#define SP_ATIO 0x2100 /* AT IO */ + +#define SP_FBMEM 0x3000 /* FutureBus Memory */ +#define SP_FBIO 0x3100 /* FutureBus IO */ + +#define SP_UBMEM 0x4000 /* Arbitrary user bus memory space */ +#define SP_UBIO 0x4100 /* Arbitrary user bus IO space */ + +#define SP_INVALID ((unsigned)-1) /* This value reserved */ + +/* + * Anything in the range 0x4000 - 0x4FFF reserved for arbitrary 3rd party use. + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BUSTYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/byteorder.h b/illumos-x86_64/usr/include/sys/byteorder.h new file mode 100644 index 00000000..03333701 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/byteorder.h @@ -0,0 +1,248 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_BYTEORDER_H +#define _SYS_BYTEORDER_H + +#include +#include + +#if defined(__GNUC__) && defined(_ASM_INLINES) && \ + (defined(__i386) || defined(__amd64)) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * macros for conversion between host and (internet) network byte order + */ + +#if defined(_BIG_ENDIAN) && !defined(ntohl) && !defined(__lint) +/* big-endian */ +#define ntohl(x) (x) +#define ntohs(x) (x) +#define htonl(x) (x) +#define htons(x) (x) +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define ntohll(x) (x) +#define htonll(x) (x) +#endif /* !_XPG4_2 || __EXTENSIONS__ */ + +#elif !defined(ntohl) /* little-endian */ + +#ifndef _IN_PORT_T +#define _IN_PORT_T +typedef uint16_t in_port_t; +#endif + +#ifndef _IN_ADDR_T +#define _IN_ADDR_T +typedef uint32_t in_addr_t; +#endif + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) || defined(_XPG5) +extern uint32_t htonl(uint32_t); +extern uint16_t htons(uint16_t); +extern uint32_t ntohl(uint32_t); +extern uint16_t ntohs(uint16_t); +#else +extern in_addr_t htonl(in_addr_t); +extern in_port_t htons(in_port_t); +extern in_addr_t ntohl(in_addr_t); +extern in_port_t ntohs(in_port_t); +#endif /* !_XPG4_2 || __EXTENSIONS__ || _XPG5 */ + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +extern uint64_t htonll(uint64_t); +extern uint64_t ntohll(uint64_t); +#endif /* !_XPG4_2 || __EXTENSIONS__ */ +#endif /* _LP64 || _LONGLONG_TYPE */ +#endif + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + +/* + * Macros to reverse byte order + */ +#define BSWAP_8(x) ((x) & 0xff) +#if !defined(__i386) && !defined(__amd64) +#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8)) +#define BSWAP_32(x) (((uint32_t)(x) << 24) | \ + (((uint32_t)(x) << 8) & 0xff0000) | \ + (((uint32_t)(x) >> 8) & 0xff00) | \ + ((uint32_t)(x) >> 24)) +#else /* x86 */ +#define BSWAP_16(x) htons(x) +#define BSWAP_32(x) htonl(x) +#endif /* !__i386 && !__amd64 */ + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +#if (!defined(__i386) && !defined(__amd64)) +#define BSWAP_64(x) (((uint64_t)(x) << 56) | \ + (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \ + (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \ + (((uint64_t)(x) << 8) & 0xff00000000ULL) | \ + (((uint64_t)(x) >> 8) & 0xff000000ULL) | \ + (((uint64_t)(x) >> 24) & 0xff0000ULL) | \ + (((uint64_t)(x) >> 40) & 0xff00ULL) | \ + ((uint64_t)(x) >> 56)) +#else /* x86 */ +#define BSWAP_64(x) htonll(x) +#endif /* !__i386 && !__amd64 */ +#else /* no uint64_t */ +#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32)) +#endif /* _LP64 || _LONGLONG_TYPE */ + +#define BMASK_8(x) ((x) & 0xff) +#define BMASK_16(x) ((x) & 0xffff) +#define BMASK_32(x) ((x) & 0xffffffff) +#define BMASK_64(x) (x) + +/* + * Macros to convert from a specific byte order to/from native byte order + */ +#ifdef _BIG_ENDIAN +#define BE_8(x) BMASK_8(x) +#define BE_16(x) BMASK_16(x) +#define BE_32(x) BMASK_32(x) +#define BE_64(x) BMASK_64(x) +#define LE_8(x) BSWAP_8(x) +#define LE_16(x) BSWAP_16(x) +#define LE_32(x) BSWAP_32(x) +#define LE_64(x) BSWAP_64(x) +#else +#define LE_8(x) BMASK_8(x) +#define LE_16(x) BMASK_16(x) +#define LE_32(x) BMASK_32(x) +#define LE_64(x) BMASK_64(x) +#define BE_8(x) BSWAP_8(x) +#define BE_16(x) BSWAP_16(x) +#define BE_32(x) BSWAP_32(x) +#define BE_64(x) BSWAP_64(x) +#endif + +/* + * Macros to read unaligned values from a specific byte order to + * native byte order + */ + +#define BE_IN8(xa) \ + *((uint8_t *)(xa)) + +#if !defined(__i386) && !defined(__amd64) +#define BE_IN16(xa) \ + (((uint16_t)BE_IN8(xa) << 8) | BE_IN8((uint8_t *)(xa) + 1)) + +#define BE_IN32(xa) \ + (((uint32_t)BE_IN16(xa) << 16) | BE_IN16((uint8_t *)(xa) + 2)) + +#else /* x86 */ +#define BE_IN16(xa) htons(*((uint16_t *)(void *)(xa))) +#define BE_IN32(xa) htonl(*((uint32_t *)(void *)(xa))) +#endif /* !__i386 && !__amd64 */ + +#if (!defined(__i386) && !defined(__amd64)) || \ + (!defined(_LP64) && !defined(_LONGLONG_TYPE)) +#define BE_IN64(xa) \ + (((uint64_t)BE_IN32(xa) << 32) | BE_IN32((uint8_t *)(xa) + 4)) +#else /* x86 */ +#define BE_IN64(xa) htonll(*((uint64_t *)(void *)(xa))) +#endif /* (!__i386 && !__amd64) || (!_LP64 && !_LONGLONG_TYPE) */ + +#define LE_IN8(xa) \ + *((uint8_t *)(xa)) + +#define LE_IN16(xa) \ + (((uint16_t)LE_IN8((uint8_t *)(xa) + 1) << 8) | LE_IN8(xa)) + +#define LE_IN32(xa) \ + (((uint32_t)LE_IN16((uint8_t *)(xa) + 2) << 16) | LE_IN16(xa)) + +#define LE_IN64(xa) \ + (((uint64_t)LE_IN32((uint8_t *)(xa) + 4) << 32) | LE_IN32(xa)) + +/* + * Macros to write unaligned values from native byte order to a specific byte + * order. + */ + +#define BE_OUT8(xa, yv) *((uint8_t *)(xa)) = (uint8_t)(yv); + +#define BE_OUT16(xa, yv) \ + BE_OUT8((uint8_t *)(xa) + 1, yv); \ + BE_OUT8((uint8_t *)(xa), (yv) >> 8); + +#define BE_OUT32(xa, yv) \ + BE_OUT16((uint8_t *)(xa) + 2, yv); \ + BE_OUT16((uint8_t *)(xa), (yv) >> 16); + +#if (!defined(__i386) && !defined(__amd64)) || \ + (!defined(_LP64) && !defined(_LONGLONG_TYPE)) +#define BE_OUT64(xa, yv) \ + BE_OUT32((uint8_t *)(xa) + 4, yv); \ + BE_OUT32((uint8_t *)(xa), (yv) >> 32); +#else /* x86 with uint64_t */ +#define BE_OUT64(xa, yv) *((uint64_t *)(void *)(xa)) = htonll((uint64_t)(yv)); +#endif /* (!__i386 && !__amd64) || (!_LP64 && !_LONGLONG_TYPE) */ + +#define LE_OUT8(xa, yv) *((uint8_t *)(xa)) = (uint8_t)(yv); + +#define LE_OUT16(xa, yv) \ + LE_OUT8((uint8_t *)(xa), yv); \ + LE_OUT8((uint8_t *)(xa) + 1, (yv) >> 8); + +#define LE_OUT32(xa, yv) \ + LE_OUT16((uint8_t *)(xa), yv); \ + LE_OUT16((uint8_t *)(xa) + 2, (yv) >> 16); + +#define LE_OUT64(xa, yv) \ + LE_OUT32((uint8_t *)(xa), yv); \ + LE_OUT32((uint8_t *)(xa) + 4, (yv) >> 32); + +#endif /* !_XPG4_2 || __EXTENSIONS__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_BYTEORDER_H */ diff --git a/illumos-x86_64/usr/include/sys/callb.h b/illumos-x86_64/usr/include/sys/callb.h new file mode 100644 index 00000000..31e5aff5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/callb.h @@ -0,0 +1,216 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CALLB_H +#define _SYS_CALLB_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * definitions of callback classes (c_class) + * + * Callbacks belong in the same class if (1) their callback routines + * do the same kind of processing (ideally, using the same callback function) + * and (2) they can/should be executed at the same time in a cpr + * suspend/resume operation. + * + * Note: The DAEMON class, in particular, is for stopping kernel threads + * and nothing else. The CALLB_* macros below should be used to deal + * with kernel threads, and the callback function should be callb_generic_cpr. + * Another idiosyncrasy of the DAEMON class is that if a suspend operation + * fails, some of the callback functions may be called with the RESUME + * code which were never called with SUSPEND. Not a problem currently, + * but see bug 4201851. + */ +#define CB_CL_CPR_DAEMON 0 +#define CB_CL_CPR_VM 1 +#define CB_CL_CPR_CALLOUT 2 +#define CB_CL_CPR_OBP 3 +#define CB_CL_CPR_FB 4 +#define CB_CL_PANIC 5 +#define CB_CL_CPR_RPC 6 +#define CB_CL_CPR_PROMPRINTF 7 +#define CB_CL_UADMIN 8 +#define CB_CL_CPR_PM 9 +#define CB_CL_HALT 10 +#define CB_CL_CPR_DMA 11 +#define CB_CL_CPR_POST_USER 12 +#define CB_CL_UADMIN_PRE_VFS 13 +#define CB_CL_MDBOOT CB_CL_UADMIN +#define CB_CL_ENTER_DEBUGGER 14 +#define CB_CL_CPR_POST_KERNEL 15 +#define CB_CL_CPU_DEEP_IDLE 16 +#define NCBCLASS 17 /* CHANGE ME if classes are added/removed */ + +#define CB_MAXNAME TASKQ_NAMELEN + +/* + * CB_CL_CPR_DAEMON class specific definitions are given below: + */ + +/* + * code for CPR callb_execute_class + */ +#define CB_CODE_CPR_CHKPT 0 +#define CB_CODE_CPR_RESUME 1 + +typedef void * callb_id_t; +/* + * Per kernel thread structure for CPR daemon callbacks. + * Must be protected by either a existing lock in the daemon or + * a new lock created for such a purpose. + */ +typedef struct callb_cpr { + kmutex_t *cc_lockp; /* lock to protect this struct */ + char cc_events; /* various events for CPR */ + callb_id_t cc_id; /* callb id address */ + kcondvar_t cc_callb_cv; /* cv for callback waiting */ + kcondvar_t cc_stop_cv; /* cv to checkpoint block */ +} callb_cpr_t; + +/* + * cc_events definitions + */ +#define CALLB_CPR_START 1 /* a checkpoint request's started */ +#define CALLB_CPR_SAFE 2 /* thread is safe for CPR */ +#define CALLB_CPR_ALWAYS_SAFE 4 /* thread is ALWAYS safe for CPR */ + +/* + * Used when checking that all kernel threads are stopped. + */ +#define CALLB_MAX_RETRY 3 /* when waiting for kthread to sleep */ +#define CALLB_THREAD_DELAY 10 /* ticks allowed to reach sleep */ +#define CPR_KTHREAD_TIMEOUT_SEC 90 /* secs before callback times out -- */ + /* due to pwr mgmt of disks, make -- */ + /* big enough for worst spinup time */ + +#ifdef _KERNEL +/* + * + * CALLB_CPR_INIT macro is used by kernel threads to add their entry to + * the callback table and perform other initialization. It automatically + * adds the thread as being in the callback class CB_CL_CPR_DAEMON. + * + * cp - ptr to the callb_cpr_t structure for this kernel thread + * + * lockp - pointer to mutex protecting the callb_cpr_t stuct + * + * func - pointer to the callback function for this kernel thread. + * It has the prototype boolean_t (void *arg, int code) + * where: arg - ptr to the callb_cpr_t structure + * code - not used for this type of callback + * returns: B_TRUE if successful; B_FALSE if unsuccessful. + * + * name - a string giving the name of the kernel thread + * + * Note: lockp is the lock to protect the callb_cpr_t (cp) structure + * later on. No lock held is needed for this initialization. + */ +#define CALLB_CPR_INIT(cp, lockp, func, name) { \ + bzero((caddr_t)(cp), sizeof (callb_cpr_t)); \ + (cp)->cc_lockp = lockp; \ + (cp)->cc_id = callb_add(func, (void *)(cp), \ + CB_CL_CPR_DAEMON, name); \ + } + +#ifndef __lock_lint +#define CALLB_CPR_ASSERT(cp) ASSERT(MUTEX_HELD((cp)->cc_lockp)); +#else +#define CALLB_CPR_ASSERT(cp) +#endif +/* + * Some threads (like the idle threads) do not adhere to the callback + * protocol and are always considered safe. Such threads must never exit. + * They register their presence by calling this macro during their + * initialization. + * + * Args: + * t - thread pointer of the client kernel thread + * name - a string giving the name of the kernel thread + */ +#define CALLB_CPR_INIT_SAFE(t, name) { \ + (void) callb_add_thread(callb_generic_cpr_safe, \ + (void *) &callb_cprinfo_safe, CB_CL_CPR_DAEMON, \ + name, t); \ + } +/* + * The lock to protect cp's content must be held before + * calling the following two macros. + * + * Any code region between CALLB_CPR_SAFE_BEGIN and CALLB_CPR_SAFE_END + * is safe for checkpoint/resume. + */ +#define CALLB_CPR_SAFE_BEGIN(cp) { \ + CALLB_CPR_ASSERT(cp) \ + (cp)->cc_events |= CALLB_CPR_SAFE; \ + if ((cp)->cc_events & CALLB_CPR_START) \ + cv_signal(&(cp)->cc_callb_cv); \ + } +#define CALLB_CPR_SAFE_END(cp, lockp) { \ + CALLB_CPR_ASSERT(cp) \ + while ((cp)->cc_events & CALLB_CPR_START) \ + cv_wait(&(cp)->cc_stop_cv, lockp); \ + (cp)->cc_events &= ~CALLB_CPR_SAFE; \ + } +/* + * cv_destroy is nop right now but may be needed in the future. + */ +#define CALLB_CPR_EXIT(cp) { \ + CALLB_CPR_ASSERT(cp) \ + (cp)->cc_events |= CALLB_CPR_SAFE; \ + if ((cp)->cc_events & CALLB_CPR_START) \ + cv_signal(&(cp)->cc_callb_cv); \ + mutex_exit((cp)->cc_lockp); \ + (void) callb_delete((cp)->cc_id); \ + cv_destroy(&(cp)->cc_callb_cv); \ + cv_destroy(&(cp)->cc_stop_cv); \ + } + +extern callb_cpr_t callb_cprinfo_safe; +extern void callb_init(void); +extern callb_id_t callb_add(boolean_t (*)(void *, int), void *, int, char *); +extern callb_id_t callb_add_thread(boolean_t (*)(void *, int), + void *, int, char *, kthread_id_t); +extern int callb_delete(callb_id_t); +extern void callb_execute(callb_id_t, int); +extern void *callb_execute_class(int, int); +extern boolean_t callb_generic_cpr(void *, int); +extern boolean_t callb_generic_cpr_safe(void *, int); +extern boolean_t callb_is_stopped(kthread_id_t, caddr_t *); +extern void callb_lock_table(void); +extern void callb_unlock_table(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CALLB_H */ diff --git a/illumos-x86_64/usr/include/sys/callo.h b/illumos-x86_64/usr/include/sys/callo.h new file mode 100644 index 00000000..1cbf4643 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/callo.h @@ -0,0 +1,454 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CALLO_H +#define _SYS_CALLO_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +typedef struct callout_list callout_list_t; + +/* + * The callout mechanism provides general-purpose event scheduling: + * an arbitrary function is called in a specified amount of time. + * The expiration time for a callout is kept in its callout list + * structure. + */ +typedef struct callout { + struct callout *c_idnext; /* next in ID hash, or on freelist */ + struct callout *c_idprev; /* prev in ID hash */ + struct callout *c_clnext; /* next in callout list */ + struct callout *c_clprev; /* prev in callout list */ + callout_id_t c_xid; /* extended callout ID; see below */ + callout_list_t *c_list; /* callout list */ + void (*c_func)(void *); /* function to call */ + void *c_arg; /* argument to function */ + kthread_t *c_executor; /* executing thread */ + kcondvar_t c_done; /* signal callout completion */ + ushort_t c_waiting; /* untimeout waiting flag */ +} callout_t; + +/* + * The callout ID (callout_id_t) uniquely identifies a callout. The callout + * ID is always 64 bits internally. The lower 32 bits contain an ID value. + * The upper 32 bits contain a generation number and flags. When the ID value + * wraps the generation number is incremented during ID generation. This + * protects callers from ID collisions that can happen as a result of the wrap. + * + * The kernel internal interface, timeout_generic(), always returns a + * callout_id_t. But the legacy interfaces, timeout() and realtime_timeout() + * return a timeout_id_t. On a 64-bit system, timeout_id_t is also 64 bits. + * So, the full 64-bit ID (sans the flags) can be returned. However, on 32-bit + * systems, timeout_id_t is 32 bits. So, only the lower 32 bits can be + * returned. In such cases, a default generation number of 0 is assigned to + * the legacy IDs. + * + * The lower 32-bit ID space is partitioned into two spaces - one for + * short-term callouts and one for long-term. + * + * Here is the bit layout for the callout ID: + * + * 63 62 61 ... 32 31 30 29 .. X+1 X ... 1 0 + * ----------------------------------------------------------------------- + * | Free | Exec | Generation | Long | Counter | ID bits | Table | Type | + * | | | number | term | High | | number | | + * ----------------------------------------------------------------------- + * + * Free: + * This bit indicates that this callout has been freed. This is for + * debugging purposes. + * + * Exec(uting): + * This is the executing bit which is only set in the extended callout + * ID. This bit indicates that the callout handler is currently being + * executed. + * + * Generation number: + * This is the generation part of the ID. + * + * Long term: + * This bit indicates whether this is a short-term or a long-term callout. + * The long-term bit exists to address the problem of callout ID collision + * on 32-bit systems. This is an issue because the system typically + * generates a large number of timeout() requests, which means that callout + * IDs eventually get recycled. Most timeouts are very short-lived, so that + * ID recycling isn't a problem; but there are a handful of timeouts which + * are sufficiently long-lived to see their own IDs reused. We use the + * long-term bit to partition the ID namespace into pieces; the short-term + * space gets all the heavy traffic and can wrap frequently (i.e., on the + * order of a day) with no ill effects; the long-term space gets very little + * traffic and thus never wraps. That said, we need to future proof callouts + * in case 32-bit systems grow in size and are able to consume callout IDs + * at faster rates. So, we should make all the kernel clients that use + * callouts to use the internal interface so that they can use IDs outside + * of the legacy space with a proper generation number. + * + * Counter High + ID counter bits: + * These bits represent the actual ID bits in the callout ID. + * The highest bit of the running counter is always set; this ensures that + * the callout ID is always non-zero, thus eliminating the need for an + * explicit wrap-around test during ID generation. + * + * Table number: + * These bits carry the table number for the callout table where the callout + * is queued. Each CPU has its own callout table. So, the callout tables are + * numbered from 0 - (max_ncpus - 1). Because max_ncpus is different on + * different systems, the actual number of table number bits will vary + * accordingly. And so will the ID counter bits. + * + * Type: + * This bit represents the callout (table) type. Each CPU has one realtime + * and one normal callout table. + */ +#define CALLOUT_ID_FREE 0x8000000000000000ULL +#define CALLOUT_EXECUTING 0x4000000000000000ULL +#define CALLOUT_ID_FLAGS (CALLOUT_ID_FREE | CALLOUT_EXECUTING) +#define CALLOUT_ID_MASK ~CALLOUT_ID_FLAGS +#define CALLOUT_GENERATION_LOW 0x100000000ULL +#define CALLOUT_LONGTERM 0x80000000 +#define CALLOUT_COUNTER_HIGH 0x40000000 +#define CALLOUT_TYPE_BITS 1 +#define CALLOUT_NTYPES (1 << CALLOUT_TYPE_BITS) +#define CALLOUT_TYPE_MASK (CALLOUT_NTYPES - 1) +#define CALLOUT_COUNTER_SHIFT callout_table_bits +#define CALLOUT_TABLE(t, f) (((f) << CALLOUT_TYPE_BITS) | (t)) +#define CALLOUT_TABLE_NUM(ct) ((ct) - callout_table) +#define CALLOUT_TABLE_SEQID(ct) (CALLOUT_TABLE_NUM(ct) >> CALLOUT_TYPE_BITS) + +/* + * We assume that during any period of CALLOUT_LONGTERM_TICKS ticks, at most + * (CALLOUT_COUNTER_HIGH / callout_counter_low) callouts will be generated. + */ +#define CALLOUT_LONGTERM_TICKS 0x4000UL +#define CALLOUT_BUCKET_SHIFT 9 +#define CALLOUT_BUCKETS (1 << CALLOUT_BUCKET_SHIFT) +#define CALLOUT_BUCKET_MASK (CALLOUT_BUCKETS - 1) +#define CALLOUT_HASH(x) ((x) & CALLOUT_BUCKET_MASK) +#define CALLOUT_IDHASH(x) CALLOUT_HASH((x) >> CALLOUT_COUNTER_SHIFT) +/* + * The multiply by 0 and 1 below are cosmetic. Just to align things better + * and make it more readable. The multiplications will be done at compile + * time. + */ +#define CALLOUT_CLHASH(x) \ + CALLOUT_HASH( \ + ((x)>>(CALLOUT_BUCKET_SHIFT*0)) ^ \ + ((x)>>(CALLOUT_BUCKET_SHIFT*1)) ^ \ + ((x)>>(CALLOUT_BUCKET_SHIFT*2)) ^ \ + ((x)>>(CALLOUT_BUCKET_SHIFT*3))) + +#define CALLOUT_ID_TO_TABLE(id) ((id) & callout_table_mask) + +#define CALLOUT_SHORT_ID(table) \ + ((callout_id_t)(table) | CALLOUT_COUNTER_HIGH) +#define CALLOUT_LONG_ID(table) \ + (CALLOUT_SHORT_ID(table) | CALLOUT_LONGTERM) + +#define CALLOUT_THREADS 2 + +#define CALLOUT_REALTIME 0 /* realtime callout type */ +#define CALLOUT_NORMAL 1 /* normal callout type */ + +/* + * callout_t's are cache-aligned structures allocated from kmem caches. One kmem + * cache is created per lgrp and is shared by all CPUs in that lgrp. Benefits: + * - cache pages are mapped only in the TLBs of the CPUs of the lgrp + * - data in cache pages is present only in those CPU caches + * - memory access performance improves with locality-awareness in kmem + * + * The following structure is used to manage per-lgroup kmem caches. + * + * NOTE: Free callout_t's go to a callout table's freelist. CPUs map to callout + * tables via their sequence IDs, not CPU IDs. DR operations can cause a + * free list to have callouts from multiple lgrp caches. This takes away some + * performance, but is no worse than if we did not use lgrp caches at all. + */ +typedef struct callout_cache { + struct callout_cache *cc_next; /* link in the global list */ + lgrp_handle_t cc_hand; /* lgroup handle */ + kmem_cache_t *cc_cache; /* kmem cache pointer */ + kmem_cache_t *cc_lcache; /* kmem cache pointer */ +} callout_cache_t; + +/* + * The callout hash structure is used for queueing both callouts and + * callout lists. That is why the fields are declared as void *. + */ +typedef struct callout_hash { + void *ch_head; + void *ch_tail; +} callout_hash_t; + +/* + * CALLOUT_LIST_FLAG_FREE + * Callout list is free. + * CALLOUT_LIST_FLAG_ABSOLUTE + * Callout list contains absolute timers. + * CALLOUT_LIST_FLAG_HRESTIME + * Callout list contains hrestime timers. + * CALLOUT_LIST_FLAG_NANO + * Callout list contains 1-nanosecond resolution callouts. + * CALLOUT_LIST_FLAG_HEAPED + * Callout list is present in the callout heap. + * CALLOUT_LIST_FLAG_QUEUED + * Callout list is present in the callout queue. + */ +#define CALLOUT_LIST_FLAG_FREE 0x1 +#define CALLOUT_LIST_FLAG_ABSOLUTE 0x2 +#define CALLOUT_LIST_FLAG_HRESTIME 0x4 +#define CALLOUT_LIST_FLAG_NANO 0x8 +#define CALLOUT_LIST_FLAG_HEAPED 0x10 +#define CALLOUT_LIST_FLAG_QUEUED 0x20 + +struct callout_list { + callout_list_t *cl_next; /* next in clhash */ + callout_list_t *cl_prev; /* prev in clhash */ + hrtime_t cl_expiration; /* expiration for callouts in list */ + callout_hash_t cl_callouts; /* list of callouts */ + int cl_flags; /* callout flags */ +}; + +/* + * Callout heap element. Each element in the heap stores the expiration + * as well as the corresponding callout list. This is to avoid a lookup + * of the callout list when the heap is processed. Because we store the + * callout list pointer in the heap element, we have to always remove + * a heap element and its callout list together. We cannot remove one + * without the other. + * + * This structure's size must be a power of two because we want an + * integral number of these to fit into a page. + */ +typedef struct callout_heap { + hrtime_t ch_expiration; + callout_list_t *ch_list; +#ifndef _LP64 + char ch_pad[4]; /* pad to power of 2 */ +#endif +} callout_heap_t; + +/* + * When the heap contains too many empty callout lists, it needs to be + * cleaned up. The decision to clean up the heap is a function of the + * number of empty entries and the heap size. Also, we don't want to + * clean up small heaps. + */ +#define CALLOUT_MIN_REAP (CALLOUT_BUCKETS >> 3) +#define CALLOUT_CLEANUP(ct) ((ct->ct_nreap >= callout_min_reap) && \ + (ct->ct_nreap >= (ct->ct_heap_num >> 1))) + +/* + * Per-callout table kstats. + * + * CALLOUT_TIMEOUTS + * Callouts created since boot. + * CALLOUT_TIMEOUTS_PENDING + * Number of outstanding callouts. + * CALLOUT_UNTIMEOUTS_UNEXPIRED + * Number of cancelled callouts that have not expired. + * CALLOUT_UNTIMEOUTS_EXECUTING + * Number of cancelled callouts that were executing at the time of + * cancellation. + * CALLOUT_UNTIMEOUTS_EXPIRED + * Number of cancelled callouts that had already expired at the time + * of cancellations. + * CALLOUT_EXPIRATIONS + * Number of callouts that expired. + * CALLOUT_ALLOCATIONS + * Number of callout structures allocated. + * CALLOUT_CLEANUPS + * Number of times a callout table is cleaned up. + */ +typedef enum callout_stat_type { + CALLOUT_TIMEOUTS, + CALLOUT_TIMEOUTS_PENDING, + CALLOUT_UNTIMEOUTS_UNEXPIRED, + CALLOUT_UNTIMEOUTS_EXECUTING, + CALLOUT_UNTIMEOUTS_EXPIRED, + CALLOUT_EXPIRATIONS, + CALLOUT_ALLOCATIONS, + CALLOUT_CLEANUPS, + CALLOUT_NUM_STATS +} callout_stat_type_t; + +/* + * Callout flags: + * + * CALLOUT_FLAG_ROUNDUP + * Roundup the expiration time to the next resolution boundary. + * If this flag is not specified, the expiration time is rounded down. + * CALLOUT_FLAG_ABSOLUTE + * Normally, the expiration passed to the timeout API functions is an + * expiration interval. If this flag is specified, then it is + * interpreted as the expiration time itself. + * CALLOUT_FLAG_HRESTIME + * Normally, callouts are not affected by changes to system time + * (hrestime). This flag is used to create a callout that is affected + * by system time. If system time changes, these timers must be + * handled in a special way (see callout.c). These are used by condition + * variables and LWP timers that need this behavior. + * CALLOUT_FLAG_32BIT + * Legacy interfaces timeout() and realtime_timeout() pass this flag + * to timeout_generic() to indicate that a 32-bit ID should be allocated. + */ +#define CALLOUT_FLAG_ROUNDUP 0x1 +#define CALLOUT_FLAG_ABSOLUTE 0x2 +#define CALLOUT_FLAG_HRESTIME 0x4 +#define CALLOUT_FLAG_32BIT 0x8 + +/* + * On 32-bit systems, the legacy interfaces, timeout() and realtime_timeout(), + * must pass CALLOUT_FLAG_32BIT to timeout_generic() so that a 32-bit ID + * can be generated. + */ +#ifdef _LP64 +#define CALLOUT_LEGACY 0 +#else +#define CALLOUT_LEGACY CALLOUT_FLAG_32BIT +#endif + +/* + * All of the state information associated with a callout table. + * The fields are ordered with cache performance in mind. + */ +typedef struct callout_table { + kmutex_t ct_mutex; /* protects all callout state */ + callout_t *ct_free; /* free callout structures */ + callout_list_t *ct_lfree; /* free callout list structures */ + callout_id_t ct_short_id; /* most recently issued short-term ID */ + callout_id_t ct_long_id; /* most recently issued long-term ID */ + callout_hash_t *ct_idhash; /* ID hash chains */ + callout_hash_t *ct_clhash; /* callout list hash */ + kstat_named_t *ct_kstat_data; /* callout kstat data */ + + uint_t ct_type; /* callout table type */ + uint_t ct_suspend; /* suspend count */ + cyclic_id_t ct_cyclic; /* cyclic for this table */ + callout_heap_t *ct_heap; /* callout expiration heap */ + ulong_t ct_heap_num; /* occupied slots in the heap */ + ulong_t ct_heap_max; /* end of the heap */ + kmem_cache_t *ct_cache; /* callout kmem cache */ + kmem_cache_t *ct_lcache; /* callout list kmem cache */ + callout_id_t ct_gen_id; /* generation based ID */ + + callout_hash_t ct_expired; /* list of expired callout lists */ + taskq_t *ct_taskq; /* taskq to execute normal callouts */ + kstat_t *ct_kstats; /* callout kstats */ + int ct_nreap; /* # heap entries that need reaping */ + cyclic_id_t ct_qcyclic; /* cyclic for the callout queue */ + callout_hash_t ct_queue; /* overflow queue of callouts */ +#ifndef _LP64 + char ct_pad[12]; /* cache alignment */ +#endif + /* + * This structure should be aligned to a 64-byte (cache-line) + * boundary. Make sure the padding is right for 32-bit as well + * as 64-bit kernels. + */ +} callout_table_t; + +/* + * Short hand definitions for the callout kstats. + */ +#define ct_timeouts \ + ct_kstat_data[CALLOUT_TIMEOUTS].value.ui64 +#define ct_timeouts_pending \ + ct_kstat_data[CALLOUT_TIMEOUTS_PENDING].value.ui64 +#define ct_untimeouts_unexpired \ + ct_kstat_data[CALLOUT_UNTIMEOUTS_UNEXPIRED].value.ui64 +#define ct_untimeouts_executing \ + ct_kstat_data[CALLOUT_UNTIMEOUTS_EXECUTING].value.ui64 +#define ct_untimeouts_expired \ + ct_kstat_data[CALLOUT_UNTIMEOUTS_EXPIRED].value.ui64 +#define ct_expirations \ + ct_kstat_data[CALLOUT_EXPIRATIONS].value.ui64 +#define ct_allocations \ + ct_kstat_data[CALLOUT_ALLOCATIONS].value.ui64 +#define ct_cleanups \ + ct_kstat_data[CALLOUT_CLEANUPS].value.ui64 + +/* + * CALLOUT_CHUNK is the minimum initial size of each heap, and the amount + * by which a full heap is expanded to make room for new entries. + */ +#define CALLOUT_CHUNK (PAGESIZE / sizeof (callout_heap_t)) + +/* + * CALLOUT_MIN_HEAP_SIZE defines the minimum size for the callout heap for + * the whole system. + */ +#define CALLOUT_MIN_HEAP_SIZE (64 * 1024 * sizeof (callout_heap_t)) + +/* + * CALLOUT_MEM_FRACTION defines the fraction of available physical memory that + * can be allocated towards the callout heap for the whole system. + */ +#define CALLOUT_MEM_FRACTION 4096 + +#define CALLOUT_HEAP_PARENT(index) (((index) - 1) >> 1) +#define CALLOUT_HEAP_RIGHT(index) (((index) + 1) << 1) +#define CALLOUT_HEAP_LEFT(index) ((((index) + 1) << 1) - 1) + +#define CALLOUT_TCP_RESOLUTION 10000000ULL + +#define CALLOUT_ALIGN 64 /* cache line size */ + +#ifdef _LP64 +#define CALLOUT_MAX_TICKS NSEC_TO_TICK(CY_INFINITY); +#else +#define CALLOUT_MAX_TICKS LONG_MAX +#endif + +#define CALLOUT_TOLERANCE 200000 /* nanoseconds */ + +extern void callout_init(void); +extern void membar_sync(void); +extern void callout_cpu_online(cpu_t *); +extern void callout_cpu_offline(cpu_t *); +extern void callout_hrestime(void); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CALLO_H */ diff --git a/illumos-x86_64/usr/include/sys/cap_util.h b/illumos-x86_64/usr/include/sys/cap_util.h new file mode 100644 index 00000000..7e25ba66 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cap_util.h @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CAP_UTIL_H +#define _SYS_CAP_UTIL_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +#ifdef _KERNEL + +/* + * Capacity and utilization flags for each CPU + */ +#define CU_CPU_CNTRS_ON 1 /* CPU performance counters are on */ +#define CU_CPU_CNTRS_OFF_ON 2 /* Off -> on transition */ + +/* + * Macro that returns whether CPU performance counters turned on for given CPU + */ +#define CU_CPC_ON(cp) \ + ((cp) != NULL && (cp)->cpu_cu_info != NULL && \ + ((cp)->cpu_cu_info->cu_flag & CU_CPU_CNTRS_ON)) + + +/* + * Per counter statistics + */ +typedef struct cu_cntr_stats { + hrtime_t cs_time_running; /* running total of time counting */ + hrtime_t cs_time_stopped; /* ... time not counting */ + hrtime_t cs_time_start; /* start time of current sample */ + uint64_t cs_value_start; /* starting value for next sample */ + uint64_t cs_value_last; /* last value */ + uint64_t cs_value_total; /* running total */ + uint64_t cs_rate; /* observed rate since last */ + uint64_t cs_rate_max; /* maximum rate */ + kcpc_request_t *cs_cpc_req; /* corresponding CPC request */ + struct cpu *cs_cpu_start; /* CPU where starting value gotten */ +} cu_cntr_stats_t; + + +/* + * Counter info for a PG hardware sharing relationship + */ +typedef struct cu_cntr_info { + cpu_t *ci_cpu; /* CPU being measured */ + pghw_t *ci_pg; /* hardware PG being measured */ + kstat_t *ci_kstat; /* kstats being exported */ + cu_cntr_stats_t *ci_stats; /* counter statistics */ + uint_t ci_nstats; /* number of statistics */ +} cu_cntr_info_t; + + +/* + * Each CPU can have one or more CPC contexts for measuring capacity and + * utilization + * + * One CPC context is needed per CPU if the counter events needed to measure + * capacity and utilization on each CPU can be programmed onto all the counters + * on a CPU at the same time and there are fewer or same number of desired + * counter events as counters on each CPU. Otherwise, the desired counter + * events are assigned across multiple CPC contexts, so the contexts and their + * counter events can be multiplexed onto the counters over time to get the + * data for all of the counter events. + */ +typedef struct cu_cpc_ctx { + int cur_index; /* index for current context */ + int nctx; /* number of CPC contexts */ + kcpc_ctx_t **ctx_ptr_array; /* array of context pointers */ + size_t ctx_ptr_array_sz; /* size of array */ +} cu_cpc_ctx_t; + +/* + * Per CPU capacity and utilization info + */ +typedef struct cu_cpu_info { + struct cpu *cu_cpu; /* CPU for the statistics */ + uint_t cu_flag; /* capacity & utilization flag */ + hrtime_t cu_sample_time; /* when last sample taken */ + cu_cpc_ctx_t cu_cpc_ctx; /* performance counter contexts */ + cu_cntr_stats_t *cu_cntr_stats; /* counter statistics array */ + uint_t cu_ncntr_stats; /* number of counter statistics */ + uint_t cu_disabled; /* count of disable requests */ + /* + * Per PG hardware sharing relationship counter info + */ + cu_cntr_info_t *cu_cntr_info[PGHW_NUM_COMPONENTS]; +} cu_cpu_info_t; + +/* + * COMMON INTERFACE ROUTINES + */ + +/* + * Setup capacity and utilization support + */ +extern void cu_init(void); + +/* + * Tear down capacity and utilization support + */ +extern int cu_fini(void); + +/* + * Program CPC for capacity and utilization on given CPU + */ +extern void cu_cpc_program(struct cpu *, int *); + +/* + * Unprogram CPC for capacity and utilization on given CPU + */ +extern void cu_cpc_unprogram(struct cpu *, int *); + +/* + * Update counter statistics on a given CPU + */ +extern int cu_cpu_update(struct cpu *, boolean_t); + +/* + * Update utilization and capacity data for CMT PG + */ +extern void cu_pg_update(pghw_t *); + +/* + * Disable or enable capacity and utilization on all CPUs + */ +extern void cu_disable(void); +extern void cu_enable(void); + +/* + * PLATFORM SPECIFIC INTERFACE ROUTINES + */ +extern int cu_plat_cpc_init(cpu_t *, kcpc_request_list_t *, int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CAP_UTIL_H */ diff --git a/illumos-x86_64/usr/include/sys/ccompile.h b/illumos-x86_64/usr/include/sys/ccompile.h new file mode 100644 index 00000000..3c986716 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ccompile.h @@ -0,0 +1,180 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2015 EveryCity Ltd. All rights reserved. + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_CCOMPILE_H +#define _SYS_CCOMPILE_H + +/* + * This file contains definitions designed to enable different compilers + * to be used harmoniously on Solaris systems. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Allow for version tests for compiler bugs and features. + */ +#if defined(__GNUC__) +#define __GNUC_VERSION \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#else +#define __GNUC_VERSION 0 +#endif + +#if defined(__ATTRIBUTE_IMPLEMENTED) || defined(__GNUC__) + +/* + * analogous to lint's PRINTFLIKEn + */ +#define __sun_attr___PRINTFLIKE__(__n) \ + __attribute__((__format__(printf, __n, (__n)+1))) +#define __sun_attr___VPRINTFLIKE__(__n) \ + __attribute__((__format__(printf, __n, 0))) + +/* + * Handle the kernel printf routines that can take '%b' too + */ +#if __GNUC_VERSION < 30402 +/* + * XX64 at least this doesn't work correctly yet with 3.4.1 anyway! + */ +#define __sun_attr___KPRINTFLIKE__ __sun_attr___PRINTFLIKE__ +#define __sun_attr___KVPRINTFLIKE__ __sun_attr___VPRINTFLIKE__ +#else +#define __sun_attr___KPRINTFLIKE__(__n) \ + __attribute__((__format__(cmn_err, __n, (__n)+1))) +#define __sun_attr___KVPRINTFLIKE__(__n) \ + __attribute__((__format__(cmn_err, __n, 0))) +#endif + +/* + * This one's pretty obvious -- the function never returns + */ +#define __sun_attr___noreturn__ __attribute__((__noreturn__)) + +/* + * The function is 'extern inline' and expects GNU C89 behaviour, not C99 + * behaviour. + * + * Should only be used on 'extern inline' definitions for GCC. + */ +#if __GNUC_VERSION >= 40200 +#define __sun_attr___gnu_inline__ __attribute__((__gnu_inline__)) +#else +#define __sun_attr___gnu_inline__ +#endif + +/* + * The function has control flow such that it may return multiple times (in + * the manner of setjmp or vfork) + */ +#if __GNUC_VERSION >= 40100 +#define __sun_attr___returns_twice__ __attribute__((__returns_twice__)) +#else +#define __sun_attr___returns_twice__ +#endif + +/* + * This is an appropriate label for functions that do not + * modify their arguments, e.g. strlen() + */ +#define __sun_attr___pure__ __attribute__((__pure__)) + +/* + * This is a stronger form of __pure__. Can be used for functions + * that do not modify their arguments and don't depend on global + * memory. + */ +#define __sun_attr___const__ __attribute__((__const__)) + +#if __GNUC_VERSION >= 20700 +#define __aligned(x) __attribute__((__aligned__(x))) +/* + * This attribute, attached to a variable, means that the variable is meant to + * be possibly unused. GCC will not produce a warning for this variable. + */ +#define __sun_attr___unused__ __attribute__((__unused__)) +#endif + +#define ___sun_attr_inner(__a) __sun_attr_##__a +#define __sun_attr__(__a) ___sun_attr_inner __a + +#else /* __ATTRIBUTE_IMPLEMENTED || __GNUC__ */ + +#define __aligned(x) +#define __sun_attr__(__a) +#define __sun_attr___unused__ + +#endif /* __ATTRIBUTE_IMPLEMENTED || __GNUC__ */ + +#if __GNUC_VERSION >= 40100 +#define __sentinel(__n) __attribute__((__sentinel__(__n))) +#else +#define __sentinel(__n) +#endif + +/* + * Shorthand versions for readability + */ + +#define __PRINTFLIKE(__n) __sun_attr__((__PRINTFLIKE__(__n))) +#define __VPRINTFLIKE(__n) __sun_attr__((__VPRINTFLIKE__(__n))) +#define __KPRINTFLIKE(__n) __sun_attr__((__KPRINTFLIKE__(__n))) +#define __KVPRINTFLIKE(__n) __sun_attr__((__KVPRINTFLIKE__(__n))) +#define __NORETURN __sun_attr__((__noreturn__)) +#define __GNU_INLINE __inline__ __sun_attr__((__gnu_inline__)) +#define __RETURNS_TWICE __sun_attr__((__returns_twice__)) +#define __CONST __sun_attr__((__const__)) +#define __PURE __sun_attr__((__pure__)) +#define __packed __attribute__((__packed__)) +#define __section(x) __attribute__((__section__(x))) +#define __unused __sun_attr__((__unused__)) +#ifdef DEBUG +/* We want to discover unused variables in DEBUG build. */ +#define __maybe_unused +#else +/* + * In release build, disable warnings about variables + * which are used only for debugging. + */ +#define __maybe_unused __sun_attr__((__unused__)) +#endif +#define __used __attribute__((__used__)) +#define __weak_symbol __attribute__((__weak__)) +#define __HIDDEN __attribute__((visibility("hidden"))) +#define __cacheline_aligned __aligned(_CACHE_LINE_SIZE) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CCOMPILE_H */ diff --git a/illumos-x86_64/usr/include/sys/cdio.h b/illumos-x86_64/usr/include/sys/cdio.h new file mode 100644 index 00000000..e2ae981a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cdio.h @@ -0,0 +1,409 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CDIO_H +#define _SYS_CDIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * CDROM io controls type definitions + */ +struct cdrom_msf { + unsigned char cdmsf_min0; /* starting minute */ + unsigned char cdmsf_sec0; /* starting second */ + unsigned char cdmsf_frame0; /* starting frame */ + unsigned char cdmsf_min1; /* ending minute */ + unsigned char cdmsf_sec1; /* ending second */ + unsigned char cdmsf_frame1; /* ending frame */ +}; + +struct cdrom_ti { + unsigned char cdti_trk0; /* starting track */ + unsigned char cdti_ind0; /* starting index */ + unsigned char cdti_trk1; /* ending track */ + unsigned char cdti_ind1; /* ending index */ +}; + +struct cdrom_tochdr { + unsigned char cdth_trk0; /* starting track */ + unsigned char cdth_trk1; /* ending track */ +}; + +struct cdrom_tocentry { + unsigned char cdte_track; + unsigned cdte_adr :4; + unsigned cdte_ctrl :4; + unsigned char cdte_format; + union { + struct { + unsigned char minute; + unsigned char second; + unsigned char frame; + } msf; + int lba; + } cdte_addr; + unsigned char cdte_datamode; +}; + +/* + * CDROM address format definition, for use with struct cdrom_tocentry + */ +#define CDROM_LBA 0x01 +#define CDROM_MSF 0x02 + +/* + * Bitmask for CD-ROM data track in the cdte_ctrl field + * A track is either data or audio. + */ +#define CDROM_DATA_TRACK 0x04 + +/* + * For CDROMREADTOCENTRY, set the cdte_track to CDROM_LEADOUT to get + * the information for the leadout track. + */ +#define CDROM_LEADOUT 0xAA + +struct cdrom_subchnl { + unsigned char cdsc_format; + unsigned char cdsc_audiostatus; + unsigned cdsc_adr: 4; + unsigned cdsc_ctrl: 4; + unsigned char cdsc_trk; + unsigned char cdsc_ind; + union { + struct { + unsigned char minute; + unsigned char second; + unsigned char frame; + } msf; + int lba; + } cdsc_absaddr; + union { + struct { + unsigned char minute; + unsigned char second; + unsigned char frame; + } msf; + int lba; + } cdsc_reladdr; +}; + +/* + * Definition for audio status returned from Read Sub-channel + */ +#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ +#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ +#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ +#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ +#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ +#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ + +/* + * definition of audio volume control structure + */ +struct cdrom_volctrl { + unsigned char channel0; + unsigned char channel1; + unsigned char channel2; + unsigned char channel3; +}; + +struct cdrom_read { + int cdread_lba; + caddr_t cdread_bufaddr; + int cdread_buflen; +}; + +#if defined(_SYSCALL32) + +struct cdrom_read32 { + int cdread_lba; + caddr32_t cdread_bufaddr; + int cdread_buflen; +}; + +#define cdrom_read32tocdrom_read(cdrd32, cdrd) \ + cdrd->cdread_lba = cdrd32->cdread_lba; \ + cdrd->cdread_bufaddr = (caddr_t)(uintptr_t)cdrd32->cdread_bufaddr; \ + cdrd->cdread_buflen = cdrd32->cdread_buflen + +#define cdrom_readtocdrom_read32(cdrd, cdrd32) \ + cdrd32->cdread_lba = cdrd->cdread_lba; \ + cdrd32->cdread_bufaddr = (caddr32_t)(uintptr_t)cdrd->cdread_bufaddr; \ + cdrd32->cdread_buflen = cdrd->cdread_buflen + +#endif /* _SYSCALL32 */ + +/* + * Definition of CD/DA structure + */ +struct cdrom_cdda { + unsigned int cdda_addr; + unsigned int cdda_length; + caddr_t cdda_data; + unsigned char cdda_subcode; +}; + +#if defined(_SYSCALL32) +struct cdrom_cdda32 { + unsigned int cdda_addr; + unsigned int cdda_length; + caddr32_t cdda_data; + unsigned char cdda_subcode; +}; + +#define cdrom_cdda32tocdrom_cdda(cdda32, cdda) \ + cdda->cdda_addr = cdda32->cdda_addr; \ + cdda->cdda_length = cdda32->cdda_length; \ + cdda->cdda_data = (caddr_t)(uintptr_t)cdda32->cdda_data; \ + cdda->cdda_subcode = cdda32->cdda_subcode + +#define cdrom_cddatocdrom_cdda32(cdda, cdda32) \ + cdda32->cdda_addr = cdda->cdda_addr; \ + cdda32->cdda_length = cdda->cdda_length; \ + cdda32->cdda_data = (caddr32_t)(uintptr_t)cdda->cdda_data; \ + cdda32->cdda_subcode = cdda->cdda_subcode + +#endif /* _SYSCALL32 */ + +/* + * Definitions for cdda_subcode field + */ +#define CDROM_DA_NO_SUBCODE 0x00 /* CD/DA data with no subcode */ +#define CDROM_DA_SUBQ 0x01 /* CD/DA data with sub Q code */ +#define CDROM_DA_ALL_SUBCODE 0x02 /* CD/DA data with all subcode */ +#define CDROM_DA_SUBCODE_ONLY 0x03 /* All subcode only */ + +/* + * Definition of CD/XA structure + */ +struct cdrom_cdxa { + unsigned int cdxa_addr; + unsigned int cdxa_length; + caddr_t cdxa_data; + unsigned char cdxa_format; +}; + +#if defined(_SYSCALL32) + +struct cdrom_cdxa32 { + unsigned int cdxa_addr; + unsigned int cdxa_length; + caddr32_t cdxa_data; + unsigned char cdxa_format; +}; + +#define cdrom_cdxa32tocdrom_cdxa(cdxa32, cdxa) \ + cdxa->cdxa_addr = cdxa32->cdxa_addr; \ + cdxa->cdxa_length = cdxa32->cdxa_length; \ + cdxa->cdxa_data = (caddr_t)(uintptr_t)cdxa32->cdxa_data; \ + cdxa->cdxa_format = cdxa32->cdxa_format + +#define cdrom_cdxatocdrom_cdxa32(cdxa, cdxa32) \ + cdxa32->cdxa_addr = cdxa->cdxa_addr; \ + cdxa32->cdxa_length = cdxa->cdxa_length; \ + cdxa32->cdxa_data = (caddr32_t)(uintptr_t)cdxa->cdxa_data; \ + cdxa32->cdxa_format = cdxa->cdxa_format + +#endif /* _SYSCALL32 */ + +/* + * Definitions for cdxa_format field + */ +#define CDROM_XA_DATA 0x00 /* CD/XA data only */ +#define CDROM_XA_SECTOR_DATA 0x01 /* CD/XA all sector data */ +#define CDROM_XA_DATA_W_ERROR 0x02 /* CD/XA data with error flags data */ + +/* + * Definition of subcode structure + */ +struct cdrom_subcode { + unsigned int cdsc_length; + caddr_t cdsc_addr; +}; + +#if defined(_SYSCALL32) + +struct cdrom_subcode32 { + unsigned int cdsc_length; + caddr32_t cdsc_addr; +}; + +#define cdrom_subcode32tocdrom_subcode(cdsc32, cdsc) \ + cdsc->cdsc_length = cdsc32->cdsc_length; \ + cdsc->cdsc_addr = (caddr_t)(uintptr_t)cdsc32->cdsc_addr + +#define cdrom_subcodetocdrom_subcode32(cdsc, cdsc32) \ + cdsc32->cdsc_length = cdsc->cdsc_length; \ + cdsc32->cdsc_addr = (caddr32_t)(uintptr_t)cdsc->cdsc_addr + +#endif /* _SYSCALL32 */ + +/* + * Definitions for block size supported + */ +#define CDROM_BLK_512 512 +#define CDROM_BLK_1024 1024 +#define CDROM_BLK_2048 2048 +#define CDROM_BLK_2056 2056 +#define CDROM_BLK_2324 2324 +#define CDROM_BLK_2336 2336 +#define CDROM_BLK_2340 2340 +#define CDROM_BLK_2352 2352 +#define CDROM_BLK_2368 2368 +#define CDROM_BLK_2448 2448 +#define CDROM_BLK_2646 2646 +#define CDROM_BLK_2647 2647 +#define CDROM_BLK_SUBCODE 96 + +/* + * Definitions for drive speed supported + */ +#define CDROM_NORMAL_SPEED 0x00 +#define CDROM_DOUBLE_SPEED 0x01 +#define CDROM_QUAD_SPEED 0x03 +#define CDROM_TWELVE_SPEED 0x0C +#define CDROM_MAXIMUM_SPEED 0xff + +/* + * CDROM io control commands + */ +#define CDIOC (0x04 << 8) +#define CDROMPAUSE (CDIOC|151) /* Pause Audio Operation */ +#define CDROMRESUME (CDIOC|152) /* Resume paused Audio Operation */ +#define CDROMPLAYMSF (CDIOC|153) /* Play Audio MSF */ +#define CDROMPLAYTRKIND (CDIOC|154) /* Play Audio Track/index */ +#define CDROMREADTOCHDR (CDIOC|155) /* Read TOC header */ +#define CDROMREADTOCENTRY (CDIOC|156) /* Read a TOC entry */ +#define CDROMSTOP (CDIOC|157) /* Stop the cdrom drive */ +#define CDROMSTART (CDIOC|158) /* Start the cdrom drive */ +#define CDROMEJECT (CDIOC|159) /* Ejects the cdrom caddy */ +#define CDROMVOLCTRL (CDIOC|160) /* control output volume */ +#define CDROMSUBCHNL (CDIOC|161) /* read the subchannel data */ +#define CDROMREADMODE2 (CDIOC|162) /* read CDROM mode 2 data */ +#define CDROMREADMODE1 (CDIOC|163) /* read CDROM mode 1 data */ + +#define CDROMREADOFFSET (CDIOC|164) /* read multi-session offset */ + +#define CDROMGBLKMODE (CDIOC|165) /* get current block mode */ +#define CDROMSBLKMODE (CDIOC|166) /* set current block mode */ +#define CDROMCDDA (CDIOC|167) /* read CD/DA data */ +#define CDROMCDXA (CDIOC|168) /* read CD/XA data */ +#define CDROMSUBCODE (CDIOC|169) /* read subcode */ +#define CDROMGDRVSPEED (CDIOC|170) /* get current drive speed */ +#define CDROMSDRVSPEED (CDIOC|171) /* set current drive speed */ + +#define CDROMCLOSETRAY (CDIOC|172) /* close cd tray,load media */ + +/* + * Additional commands for CD-ROM + */ +/* + * + * Group 2 Commands + * + */ +#define SCMD_READ_SUBCHANNEL 0x42 /* optional SCSI command */ +#define SCMD_READ_TOC 0x43 /* optional SCSI command */ +#define SCMD_READ_HEADER 0x44 /* optional SCSI command */ +#define SCMD_PLAYAUDIO10 0x45 /* optional SCSI command */ +#define SCMD_PLAYAUDIO_MSF 0x47 /* optional SCSI command */ +#define SCMD_PLAYAUDIO_TI 0x48 /* optional SCSI command */ +#define SCMD_PLAYTRACK_REL10 0x49 /* optional SCSI command */ +#define SCMD_PAUSE_RESUME 0x4B /* optional SCSI command */ + +/* + * + * Group 5 Commands + * + */ +#define SCMD_PLAYAUDIO12 0xA5 /* optional SCSI command */ +#define SCMD_PLAYTRACK_REL12 0xA9 /* optional SCSI command */ +#define SCMD_SET_CDROM_SPEED 0xBB /* optional SCSI command */ +#define SCMD_READ_CD 0xBE /* Universal way of accessing CD data */ + +/* + * These defines are for SCMD_READ_CD command. + * See Expected Sector Type Field Definition (SCSI MMC-2 Spec section 6.1.15) + * This information is used to figure out which block size to use. + */ +#define READ_CD_EST_ALLTYPE 0x0 /* All Types */ +#define READ_CD_EST_CDDA 0x1 /* Only CD-DA */ +#define READ_CD_EST_MODE1 0x2 /* Only Yellow Book 2048 bytes */ +#define READ_CD_EST_MODE2 0x3 /* Only Yellow Book 2336 byte sectors */ +#define READ_CD_EST_MODE2FORM1 0x4 /* Only sectors with 2048 bytes */ +#define READ_CD_EST_MODE2FORM2 0x5 /* Only sectors with 2324 bytes */ +#define READ_CD_EST_RSVD1 0x6 /* reserved */ +#define READ_CD_EST_RSVD2 0x7 /* reserved */ + + +/* + * + * Group 6 Commands + * + */ +#define SCMD_CD_PLAYBACK_CONTROL 0xC9 /* SONY unique SCSI command */ +#define SCMD_CD_PLAYBACK_STATUS 0xC4 /* SONY unique SCSI command */ +#define SCMD_READ_CDDA 0xD8 /* Vendor unique SCSI command */ +#define SCMD_READ_CDXA 0xDB /* Vendor unique SCSI command */ +#define SCMD_READ_ALL_SUBCODES 0xDF /* Vendor unique SCSI command */ + +#define CDROM_MODE2_SIZE 2336 + +/* + * scsi_key_strings for CDROM cdio SCMD_ definitions + */ +#define SCSI_CMDS_KEY_STRINGS_CDIO \ +/* 0x42 */ SCMD_READ_SUBCHANNEL, "read_subchannel", \ +/* 0x43 */ SCMD_READ_TOC, "read_toc", \ +/* 0x44 */ SCMD_REPORT_DENSITIES | \ + SCMD_READ_HEADER, "report_densities/read_header", \ +/* 0x45 */ SCMD_PLAYAUDIO10, "playaudio", \ +/* 0x46 */ SCMD_GET_CONFIGURATION, "get_configuration", \ +/* 0x47 */ SCMD_PLAYAUDIO_MSF, "playaudio_msf", \ +/* 0x48 */ SCMD_PLAYAUDIO_TI, "playaudio_ti", \ +/* 0x49 */ SCMD_PLAYTRACK_REL10, "playaudio_rel", \ +/* 0x4b */ SCMD_PAUSE_RESUME, "pause_resume", \ + \ +/* 0xa5 */ SCMD_PLAYAUDIO12, "playaudio(12)", \ +/* 0xa9 */ SCMD_PLAYTRACK_REL12, "playtrack_rel", \ +/* 0xbb */ SCMD_SET_CDROM_SPEED, "set_cd_speed", \ +/* 0xbe */ SCMD_READ_CD, "read_cd", \ + \ +/* 0xc4 */ SCMD_CD_PLAYBACK_STATUS, "cd_playback_status", \ +/* 0xc9 */ SCMD_CD_PLAYBACK_CONTROL, "cd_playback_control", \ +/* 0xd8 */ SCMD_READ_CDDA, "read_cdda", \ +/* 0xdb */ SCMD_READ_CDXA, "read_cdxa", \ +/* 0xdf */ SCMD_READ_ALL_SUBCODES, "read_all_subcodes" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CDIO_H */ diff --git a/illumos-x86_64/usr/include/sys/cis.h b/illumos-x86_64/usr/include/sys/cis.h new file mode 100644 index 00000000..d1a42630 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cis.h @@ -0,0 +1,369 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _CIS_H +#define _CIS_H + +/* + * This is the Card Services Card Information Structure (CIS) interpreter + * header file. CIS information in this file is based on the + * Release 2.01 PCMCIA standard. + */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if defined(DEBUG) +#define CIS_DEBUG +#endif + + +/* + * The CIS interpreter has a single entry point with a bunch of function + * id numbers. + */ +#define CISP_CIS_SETUP 0x01 /* setup CS address in CIS */ +#define CISP_CIS_LIST_CREATE 0x02 /* create the CIS linked list */ +#define CISP_CIS_LIST_DESTROY 0x03 /* destroy the CIS linked list */ +#define CISP_CIS_GET_LTUPLE 0x04 /* get a tuple */ +#define CISP_CIS_PARSE_TUPLE 0x05 /* parse a tuple */ +#define CISP_CIS_CONV_DEVSPEED 0x06 /* convert devspeed to nS and back */ +#define CISP_CIS_CONV_DEVSIZE 0x07 /* convert device size */ + +/* + * Make the calls to CardServices look like function calls. + */ +#define CIS_CARD_SERVICES (*cis_card_services) + +/* + * define the tuples that we recognize + * + * Layer 1 - Basic Compatability TUples + */ +#define CISTPL_NULL 0x000 /* null tuple - ignore */ +#define CISTPL_DEVICE 0x001 /* device information */ +#define CISTPL_LONGLINK_CB 0x002 /* longlink to next tuple chain */ +#define CISTPL_CONFIG_CB 0x004 /* configuration tuple */ +#define CISTPL_CFTABLE_ENTRY_CB 0x005 /* configuration table entry */ +#define CISTPL_LONGLINK_MFC 0x006 /* multi-function tuple */ +#define CISTPL_BAR 0x007 /* Base Address Register definition */ +#define CISTPL_CHECKSUM 0x010 /* checksum control */ +#define CISTPL_LONGLINK_A 0x011 /* long-link to AM */ +#define CISTPL_LONGLINK_C 0x012 /* long-link to CM */ +#define CISTPL_LINKTARGET 0x013 /* link-target control */ +#define CISTPL_NO_LINK 0x014 /* no-link control */ +#define CISTPL_VERS_1 0x015 /* level 1 version information */ +#define CISTPL_ALTSTR 0x016 /* alternate language string */ +#define CISTPL_DEVICE_A 0x017 /* AM device information */ +#define CISTPL_JEDEC_C 0x018 /* JEDEC programming info for CM */ +#define CISTPL_JEDEC_A 0x019 /* JEDEC programming info for AM */ +#define CISTPL_CONFIG 0x01a /* configuration */ +#define CISTPL_CFTABLE_ENTRY 0x01b /* configuration-table-entry */ +#define CISTPL_DEVICE_OC 0x01c /* other op conditions CM device info */ +#define CISTPL_DEVICE_OA 0x01d /* other op conditions AM device info */ +#define CISTPL_DEVICEGEO 0x01e /* Common Memory device geometry */ +#define CISTPL_DEVICEGEO_A 0x01f /* Attribute Memory device geometry */ +#define CISTPL_MANFID 0x020 /* manufacturer identification */ +#define CISTPL_FUNCID 0x021 /* function identification */ +#define CISTPL_FUNCE 0x022 /* function extension */ + +/* + * Layer 2 - Data Recording Format Tuples + */ +#define CISTPL_SWIL 0x023 /* software interleave */ +#define CISTPL_VERS_2 0x040 /* level 2 version information */ +#define CISTPL_FORMAT 0x041 /* Common Memory recording format */ +#define CISTPL_GEOMETRY 0x042 /* geometry */ +#define CISTPL_BYTEORDER 0x043 /* byte order */ +#define CISTPL_DATE 0x044 /* card initialization date */ +#define CISTPL_BATTERY 0x045 /* battery replacement date */ +#define CISTPL_FORMAT_A 0x047 /* Attribute Memory recording format */ + +/* + * Layer 3 - Data Organization Tuples + */ +#define CISTPL_ORG 0x046 /* organization */ + +/* + * Layer 4 - System Specific Standard Tuples + */ +#define CISTPL_VEND_SPEC_80 0x080 /* vendor-specific 0x80 */ +#define CISTPL_VEND_SPEC_81 0x081 /* vendor-specific 0x81 */ +#define CISTPL_VEND_SPEC_82 0x082 /* vendor-specific 0x82 */ +#define CISTPL_VEND_SPEC_83 0x083 /* vendor-specific 0x83 */ +#define CISTPL_VEND_SPEC_84 0x084 /* vendor-specific 0x84 */ +#define CISTPL_VEND_SPEC_85 0x085 /* vendor-specific 0x85 */ +#define CISTPL_VEND_SPEC_86 0x086 /* vendor-specific 0x86 */ +#define CISTPL_VEND_SPEC_87 0x087 /* vendor-specific 0x87 */ +#define CISTPL_VEND_SPEC_88 0x088 /* vendor-specific 0x88 */ +#define CISTPL_VEND_SPEC_89 0x089 /* vendor-specific 0x89 */ +#define CISTPL_VEND_SPEC_8a 0x08a /* vendor-specific 0x8a */ +#define CISTPL_VEND_SPEC_8b 0x08b /* vendor-specific 0x8b */ +#define CISTPL_VEND_SPEC_8c 0x08c /* vendor-specific 0x8c */ +#define CISTPL_VEND_SPEC_8d 0x08d /* vendor-specific 0x8d */ +#define CISTPL_VEND_SPEC_8e 0x08e /* vendor-specific 0x8e */ +#define CISTPL_VEND_SPEC_8f 0x08f /* vendor-specific 0x8f */ +#define CISTPL_SPCL 0x090 /* special-purpose tuple */ +#define CISTPL_END 0x0ff /* end-of-list tuple */ + +/* + * Macro to check if tuple is a vendor-specific tuple. + */ +#define CISTPL_VENDSPEC_START CISTPL_VEND_SPEC_80 +#define CISTPL_VENDSPEC_END CISTPL_VEND_SPEC_8f +#define CISTPL_IS_VENDOR_SPECIFIC(td) (((td) >= CISTPL_VENDSPEC_START) && \ + ((td) <= CISTPL_VENDSPEC_END)) + +/* + * The GetFirstTuple and GetNextTuple Card Services function calls use + * the DesiredTuple member of the tuple_t structure to determine + * while tuple type to return; since the CIS parser doesn't ever + * return CISTPL_END tuples, we can never ask for those tuples, + * so we overload this tuple code to mean that we want the + * first (or next) tuple in the chain. + * XXX - If we ever do return CISTPL_END tuples, we'll have to + * re-think this. + */ +#define RETURN_FIRST_TUPLE 0x0ff /* return first/next tuple */ +#define RETURN_NEXT_TUPLE 0x0ff /* return first/next tuple */ + +/* + * types for data in CIS and pointers into PC card's CIS space + * + * The "size" member is used by the NEXT_CIS_ADDR macro so that + * we don't run past the end of the mapped CIS address space. + */ +typedef uchar_t cisdata_t; + +typedef struct cisptr_t { + acc_handle_t handle; /* access handle of CIS space */ + uint32_t size; /* size of mapped area */ + uint32_t offset; /* byte offset into CIS space */ + /* see flag definitions for cistpl_t structure */ + uint32_t flags; +} cisptr_t; + +/* + * This is the maximum length that the data portion of a tuple can be. + * We have to use this since the brain-damaged 2.01 PCMCIA spec + * specifies that you can end a CIS chain by putting a CISTPL_END + * in the link field of the last VALID tuple. + */ +#define CIS_MAX_TUPLE_DATA_LEN 254 + +/* + * This is the maximum size of the string used to describe the name + * of the tuple. + */ +#define CIS_MAX_TUPLE_NAME_LEN 40 + +/* + * CIS_MAX_FUNCTIONS defines the maximum number of functions that can + * exist on a card. + */ +#define CIS_MAX_FUNCTIONS 8 /* max number of functions per card */ + +/* + * Macros to manipulate addresses and data in various CIS spaces + * + * NEXT_CIS_ADDR(cisptr_t *) increments the offset to point to the + * next data element in the CIS, based on what space the CIS + * we are reading resides in. If the resulting address would + * be past the end of the mapped-in area, we return NULL, + * otherwise the adjusted offset value is returned. Note that + * this only works if the "size" member specifies the maximum + * mapped in window size and an "offset" member value of zero + * refers to the first byte of the window. + * + * GET_CIS_DATA(ptr) returns the data byte at the current CIS location. + * + * GET_CIS_ADDR(tp,ptr) returns the virtual address that was saved by a + * call to STORE_CIS_ADDR. + * + * BAD_CIS_ADDR is a flag that should be returned by callers of NEXT_CIS_ADDR + * if that macro returns NULL. Note that this flag shares the same bit + * field definitions as the tuple handler flags defined in cis_handlers.h + * so check that file if you make any changes to these flags. + * XXX - not the best distribution of flags, I'm afraid + */ +#define NEXT_CIS_ADDR(ptr) \ + (((ptr->flags&CISTPLF_AM_SPACE)?(ptr->offset += 2): \ + (ptr->offset++)), \ + ((ptr->offset > ptr->size)?(0):ptr->offset)) +#define GET_CIS_DATA(ptr) csx_Get8(ptr->handle, ptr->offset) +#define GET_CIS_ADDR(tp) ((cisdata_t *)(uintptr_t)(tp)->offset) +#define BAD_CIS_ADDR 0x080000000 /* read past end of mapped CIS error */ + +/* + * CIS_MEM_ALLOC(len) is used to allocate memory for our local linked + * CIS list; we use a macro so that the same code can be used in + * the kernel as well as in user space + * + * CIS_MEM_FREE(ptr) - same comment as CIS_MEM_ALLOC + */ +#if !defined(_KERNEL) +#ifdef CISMALLOC_DEBUG +#define CIS_MEM_ALLOC(len) cis_malloc((uint32_t)len) +#define CIS_MEM_FREE(ptr) cis_free(ptr) +#else +#define CIS_MEM_ALLOC(len) malloc((uint32_t)len) +#define CIS_MEM_FREE(ptr) free(ptr) +#endif /* CISMALLOC_DEBUG */ +#else +#define CIS_MEM_ALLOC(len) cis_malloc((uint32_t)len) +#define CIS_MEM_FREE(ptr) cis_free(ptr) +#endif + +typedef struct cis_u_malloc_tag_t { + caddr_t addr; + uint32_t len; +} cis_u_malloc_tag_t; + +/* + * We keep the tuples in a locally-maintained linked list. This allows + * us to return the tuple information at any time to a client for + * those cards that make their CIS inaccessible once the card is + * configured. + */ +typedef struct cistpl_t { + cisdata_t type; /* type of tuple */ + cisdata_t len; /* length of tuple data */ + cisdata_t *data; /* data in tuple */ + union { + cisdata_t *byte; /* read pointer for GET_BYTE macros */ + uint16_t *sword; + } read; + uint32_t flags; /* misc flags */ + uint32_t offset; /* CIS address offset of start of tuple */ + struct cistpl_t *prev; /* back pointer */ + struct cistpl_t *next; /* forward pointer */ +} cistpl_t; + +/* + * Flags that are used in the cistpl_t and cisptr_t linked lists + */ +#define CISTPLF_NOERROR 0x000000000 /* no error return from handler */ +#define CISTPLF_UNKNOWN 0x000000001 /* unknown tuple */ +#define CISTPLF_REGS 0x000000002 /* tuple contains registers */ +#define CISTPLF_COPYOK 0x000000004 /* OK to copy tuple data */ +#define CISTPLF_VALID 0x000000008 /* tuple is valid */ +#define CISTPLF_GLOBAL_CIS 0x000000010 /* tuple from global CIS */ +#define CISTPLF_MF_CIS 0x000000020 /* tuple from MF CIS chain */ +#define CISTPLF_FROM_AM 0x000000040 /* tuple read from AM space */ +#define CISTPLF_FROM_CM 0x000000080 /* tuple read from CM space */ +#define CISTPLF_IGNORE_TUPLE 0x000000100 /* ignore this tuple */ +#define CISTPLF_VENDOR_SPECIFIC 0x000000200 /* vnedor-specific tuple */ +#define CISTPLF_LINK_INVALID 0x001000000 /* tuple link is invalid */ +#define CISTPLF_PARAMS_INVALID 0x002000000 /* tuple body is invalid */ +#define CISTPLF_AM_SPACE 0x010000000 /* this tuple is in AM space */ +#define CISTPLF_CM_SPACE 0x020000000 /* this tuple is in CM space */ +#define CISTPLF_LM_SPACE 0x040000000 /* this tuple is in local memory */ +#define CISTPLF_MEM_ERR 0x080000000 /* GET_BYTE macros memory error */ + +/* + * Some convienience macros + */ +#define CISTPLF_SPACE_MASK (CISTPLF_AM_SPACE | CISTPLF_CM_SPACE | \ + CISTPLF_LM_SPACE) +#define CISTPLF_FROM_MASK (CISTPLF_FROM_AM | CISTPLF_FROM_CM) + +/* + * Values used internally on calls to cis_get_ltuple. + * + * The GET_XXX_LTUPLEF and FIND_XXX_XXX values are mutually exclusive, + * i.e. cis_get_ltuple can only do one of these operations per call. + * + * The other flags are bit flags and they share the flags parameter. + * + * CIS_GET_LTUPLE_IGNORE - return tuples with CISTPLF_IGNORE_TUPLE + * set in cistpl_t->flags + */ +#define GET_FIRST_LTUPLEF 0x000000001 /* return first tuple in list */ +#define GET_LAST_LTUPLEF 0x000000002 /* return last tuple in list */ +#define FIND_LTUPLE_FWDF 0x000000003 /* find tuple, fwd search from tp */ +#define FIND_LTUPLE_BACKF 0x000000004 /* find tuple, backward from tp */ +#define FIND_NEXT_LTUPLEF 0x000000005 /* find tuple, fwd from tp+1 */ +#define FIND_PREV_LTUPLEF 0x000000006 /* find tuple, backward from tp-1 */ +#define GET_NEXT_LTUPLEF 0x000000007 /* return next tuple in list */ +#define GET_PREV_LTUPLEF 0x000000008 /* return prev tuple in list */ +#define CIS_GET_LTUPLE_OPMASK 0x00000ffff /* mask for operation values */ +#define CIS_GET_LTUPLE_IGNORE 0x000010000 /* return ignored tuples */ + +/* + * macros for getting various data types out of a tuple + * Note that due to the modem tuple using a few big-endian values, + * we have to support both big and little endian macros + * + * Common Memory Specific macros - these will also work for tuples in + * local memory + */ +#define GET_CM_BYTE(tp) (((size_t)(tp)->len >= \ + ((uintptr_t)(tp)->read.byte - \ + (uintptr_t)(tp)->data)) ? \ + *(tp)->read.byte++ : ((tp)->flags |= CISTPLF_MEM_ERR)) +#define GET_CM_LEN(tp) ((size_t)(tp)->len - \ + ((uintptr_t)(tp)->read.byte - \ + (uintptr_t)(tp)->data)) + +/* Attribute Memory Specific macros */ +#define GET_AM_BYTE(tp) (((size_t)(tp)->len >= \ + (((uintptr_t)(tp)->read.byte - \ + (uintptr_t)(tp)->data))>>1) ? \ + *(cisdata_t *)(tp)->read.sword++ : \ + ((tp)->flags |= CISTPLF_MEM_ERR)) +#define GET_AM_LEN(tp) ((size_t)(tp)->len - (((uintptr_t)(tp)->read.byte - \ + (uintptr_t)(tp)->data) >> 1)) + +/* generic macros */ +#define RESET_TP(tp) (tp)->read.byte = (tp)->data +#define LOOK_BYTE(tp) *(tp)->read.byte +#define GET_BYTE_ADDR(tp) (tp)->read.byte + +#define GET_BYTE(tp) (((tp)->flags & CISTPLF_AM_SPACE) ? \ + GET_AM_BYTE(tp) : GET_CM_BYTE(tp)) +#define GET_SHORT(tp) cis_get_short(tp) +#define GET_BE_SHORT(tp) cis_get_be_short(tp) +#define GET_INT24(tp) cis_get_int24(tp) +#define GET_LONG(tp) cis_get_long(tp) +#define GET_LEN(tp) (((tp)->flags & CISTPLF_AM_SPACE) ? \ + GET_AM_LEN(tp) : GET_CM_LEN(tp)) + +/* + * cistpl_ignore_list_t - this structure describes tuples in the global + * CIS list that we want to ignore if they + * also show up in a function-specific CIS. + */ +typedef struct cistpl_ignore_list_t { + cisdata_t type; +} cistpl_ignore_list_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _CIS_H */ diff --git a/illumos-x86_64/usr/include/sys/cis_handlers.h b/illumos-x86_64/usr/include/sys/cis_handlers.h new file mode 100644 index 00000000..f17bdcd2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cis_handlers.h @@ -0,0 +1,1135 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _CIS_HANDLERS_H +#define _CIS_HANDLERS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This is the CIS tuple handler header file. + * + * Each tuple that we recognize and are prepared to handle is assigned a + * cistpl_callout_t structure. This lets us specify a handler for + * this tuple, as well as flags that describe this tuple and which + * are used by the CIS interpreter and tuple parser. + */ +typedef struct cistpl_callout_t { + cisdata_t type; /* type of tuple */ + cisdata_t subtype; /* only used for CISTPL_FUNCE */ + uint32_t flags; /* misc flags */ + uint32_t (*handler)(); /* tuple handler */ + char *text; /* name of tuple */ +} cistpl_callout_t; + +/* + * Flags that are used by a tuple handler to specify what action it + * should perform. + */ +#define HANDTPL_NOERROR 0x000000000 /* no error */ +#define HANDTPL_SET_FLAGS 0x000000001 /* set tuple flags */ +#define HANDTPL_COPY_DONE 0x000000002 /* tuple data copy is done */ +#define HANDTPL_PARSE_LTUPLE 0x000000004 /* parse tuple, return opt data */ +#define HANDTPL_RETURN_NAME 0x000000008 /* return tuple name string */ + +/* + * This flag is returned by tuple handlers if they encounter an error. It + * is returned by cis_list_lcreate if any of the tuple handlers have + * return an error while processing the CIS. + * + * Note that the following bit is reserved: + * #define BAD_CIS_ADDR 0x080000000 + * It appears in cis.h and is used to indicate that cis_list_create + * tried to read past the end of the mapped in CIS space. + */ +#define HANDTPL_ERROR 0x001000000 /* handler returned an error */ + +/* + * General-use constants and macros that aren't specific to a tuple. + */ +#define CISTPL_EXT_BIT 0x080 /* additional extension bytes follow */ + +/* + * Constants, macros and structures used by cistpl_devspeed and + * cis_convert_devspeed functions. + */ +#define CISTPL_DEVSPEED_TABLE 0x000000001 /* use the device speed table */ +#define CISTPL_DEVSPEED_EXT 0x000000002 /* use the extended speed table */ +#define CISTPL_DEVSPEED_MAX_TBL 8 /* max devspeed table entries */ +#define CISTPL_DEVSPEED_MAX_EXP 8 /* max exponent entries */ +#define CISTPL_DEVSPEED_MAX_MAN 16 /* max mantissa entries */ +#define CISTPL_DEVSPEED_TBL(t) cistpl_devspeed_struct.table[(t) & \ + (CISTPL_DEVSPEED_MAX_TBL - 1)] +#define CISTPL_DEVSPEED_MAN(m) cistpl_devspeed_struct.mantissa[(m) & \ + (CISTPL_DEVSPEED_MAX_MAN - 1)] +#define CISTPL_DEVSPEED_EXP(e) cistpl_devspeed_struct.exponent[(e) & \ + (CISTPL_DEVSPEED_MAX_EXP - 1)] +typedef struct cistpl_devspeed_struct_t { + uint32_t *table; + uint32_t *tenfac; + uint32_t *mantissa; + uint32_t *exponent; +} cistpl_devspeed_struct_t; + +/* + * Constants, flags and structure typedefs that are used by specific tuples. + * + * CISTPL_DEVICE, CISTPL_DEVICE_A, CISTPL_DEVICE_OC and CISTPL_DEVICE_OA + */ +#define CISTPL_DEVICE_DTYPE_NULL 0x00 /* a NULL device (hole) */ +#define CISTPL_DEVICE_DTYPE_ROM 0x01 /* device is of type ROM */ +#define CISTPL_DEVICE_DTYPE_OTPROM 0x02 /* device is of type OTPROM */ +#define CISTPL_DEVICE_DTYPE_EPROM 0x03 /* device is of type EPROM */ +#define CISTPL_DEVICE_DTYPE_EEPROM 0x04 /* device is of type EEPROM */ +#define CISTPL_DEVICE_DTYPE_FLASH 0x05 /* device is of type FLASH */ +#define CISTPL_DEVICE_DTYPE_SRAM 0x06 /* device is of type SRAM */ +#define CISTPL_DEVICE_DTYPE_DRAM 0x07 /* device is of type DRAM */ +#define CISTPL_DEVICE_DTYPE_RSVD_8 0x08 /* reserved */ +#define CISTPL_DEVICE_DTYPE_RSVD_9 0x09 /* reserved */ +#define CISTPL_DEVICE_DTYPE_RSVD_a 0x0a /* reserved */ +#define CISTPL_DEVICE_DTYPE_RSVD_b 0x0b /* reserved */ +#define CISTPL_DEVICE_DTYPE_RSVD_c 0x0c /* reserved */ +#define CISTPL_DEVICE_DTYPE_FUNCSPEC 0x0d /* device is of type FUNCSPEC */ +#define CISTPL_DEVICE_DTYPE_EXTEND 0x0e /* device is of type extended */ +#define CISTPL_DEVICE_DTYPE_RSVD_f 0x0f /* reserved */ + +/* + * Flags for cistpl_device_node_t->flags member for CISTPL_DEVICE + * and CISTPL_DEVICE_A tuples + */ +#define CISTPL_DEVICE_WPS 0x00000001 /* WPS bit is set */ +/* + * Flags and values for cistpl_device_node_t->flags member for + * CISTPL_DEVICE_OC and CISTPL_DEVICE_OA tuples + */ +#define CISTPL_DEVICE_OC_MWAIT 0x00010000 /* use MWAIT */ +#define CISTPL_DEVICE_OC_Vcc_MASK 0x00060000 /* mask for Vcc value */ +#define CISTPL_DEVICE_OC_Vcc5 0x00000000 /* 5.0 volt operation */ +#define CISTPL_DEVICE_OC_Vcc33 0x00020000 /* 3.3 volt operation */ +#define CISTPL_DEVICE_OC_VccXX 0x00040000 /* X.X volt operation */ +#define CISTPL_DEVICE_OC_VccYY 0x00060000 /* Y.Y volt operation */ +/* + * CISTPL_DEVICE_MAX_DEVICES defines the maximum number of devices that + * we can parse in a CISTPL_DEVICE{...} tuple + */ +#define CISTPL_DEVICE_MAX_DEVICES 10 + +/* + * CISTPL_DEVICE_SPEED_SIZE_IGNORE if the device speed is set to this, then + * ignore the speed and size values + */ +#define CISTPL_DEVICE_SPEED_SIZE_IGNORE 0x0ff /* ignore size and speed info */ + +typedef struct cistpl_device_node_t { + uint32_t flags; /* flags specific to this device */ + uint32_t speed; /* device speed in device speed code format */ + uint32_t nS_speed; /* device speed in nS */ + uint32_t type; /* device type */ + uint32_t size; /* device size */ + uint32_t size_in_bytes; /* device size in bytes */ +} cistpl_device_node_t; + +typedef struct cistpl_device_t { + uint32_t num_devices; /* number of devices found */ + cistpl_device_node_t devnode[CISTPL_DEVICE_MAX_DEVICES]; +} cistpl_device_t; + +/* + * CISTPL_CONFIG + */ +#define MAKE_CONFIG_REG_ADDR(base, reg) (base + (reg * 2)) +#define CISTPL_CONFIG_MAX_CONFIG_REGS 128 /* max num config regs */ +typedef struct cistpl_config_t { + uint32_t present; /* register present flags */ + uint32_t nr; /* number of config registers found */ + uint32_t hr; /* highest config register index found */ + uint32_t regs[CISTPL_CONFIG_MAX_CONFIG_REGS]; /* reg offsets */ + uint32_t base; /* base offset of config registers */ + uint32_t last; /* last config index */ +} cistpl_config_t; + +/* + * CISTPL_VERS_1 + */ +#define CISTPL_VERS_1_MAX_PROD_STRINGS 4 /* max number product strings */ +typedef struct cistpl_vers_1_t { + uint32_t major; /* major version number */ + uint32_t minor; /* minor version number */ + uint32_t ns; /* number of information strings */ + /* pointers to product information strings */ + char pi[CISTPL_VERS_1_MAX_PROD_STRINGS][CIS_MAX_TUPLE_DATA_LEN]; +} cistpl_vers_1_t; + +/* + * CISTPL_VERS_2 + */ +typedef struct cistpl_vers_2_t { + uint32_t vers; /* version number */ + uint32_t comply; /* level of compliance */ + uint32_t dindex; /* byte address of first data byte in card */ + uint32_t reserved; /* two reserved bytes */ + uint32_t vspec8; /* vendor specific (byte 8) */ + uint32_t vspec9; /* vendor specific (byte 9) */ + uint32_t nhdr; /* number of copies of CIS present on device */ + char oem[CIS_MAX_TUPLE_DATA_LEN]; /* Vendor of software that */ + /* formatted card */ + char info[CIS_MAX_TUPLE_DATA_LEN]; /* Informational message */ + /* about card */ +} cistpl_vers_2_t; + +/* + * CISTPL_JEDEC_A and CISTPL_JEDEC_C + */ +#define CISTPL_JEDEC_MAX_IDENTIFIERS 4 +typedef struct jedec_ident_t { + uint32_t id; /* manufacturer id */ + uint32_t info; /* manufacturer specific info */ +} jedec_ident_t; + +typedef struct cistpl_jedec_t { + uint32_t nid; /* # of JEDEC identifiers present */ + jedec_ident_t jid[CISTPL_JEDEC_MAX_IDENTIFIERS]; +} cistpl_jedec_t; + +/* + * CISTPL_FORMAT and CISTPL_FORMAT_A + * + * These tuples describe the data recording format for a region. + */ +typedef struct cistpl_format_t { + uint32_t type; /* format type code */ + uint32_t edc_length; /* error detection code length */ + uint32_t edc_type; /* error detection code type */ + uint32_t offset; /* offset of first byte of data in this part */ + uint32_t nbytes; /* number of bytes of data in this partition */ + union { + struct disk { + uint32_t bksize; /* block size */ + uint32_t nblocks; /* nblocks data for disk-like device */ + uint32_t edcloc; /* location of error detection code */ + } disk; + struct mem { + uint32_t flags; /* various flags */ + uint32_t reserved; /* reserved byte */ + caddr_t address; /* physical addr for mem-like device */ + uint32_t edcloc; /* location of error detection code */ + } mem; + } dev; +} cistpl_format_t; + +/* + * device format types + */ +#define TPLFMTTYPE_DISK 0x00 /* disk-like format */ +#define TPLFMTTYPE_MEM 0x01 /* memory-like format */ +#define TPLFMTTYPE_VS 0x80 /* vendor specific format */ + +/* + * error detection code types + */ +#define TPLFMTEDC_NONE 0x00 /* no error detection code */ +#define TPLFMTEDC_CKSUM 0x01 /* arithmetic checksum is used */ +#define TPLFMTEDC_CRC 0x02 /* 16-bit CRC */ +#define TPLFMTEDC_PCC 0x03 /* whole-partition arithmetic checksum */ +#define TPLFMTEDC_VS 0x80 /* vendor specific error checking */ + +#define EDC_LENGTH_MASK 0x07 +#define EDC_TYPE_MASK 0x0f +#define EDC_TYPE_SHIFT 3 + +/* + * flags for memory-like devices + */ +#define TPLFMTFLAGS_ADDR 0x01 /* address is valid */ +#define TPLFMTFLAGS_AUTO 0x02 /* automatically map memory region */ + +/* + * CISTPL_GEOMETRY + */ +typedef struct cistpl_geometry_t { + uint32_t spt; + uint32_t tpc; + uint32_t ncyl; +} cistpl_geometry_t; + +/* + * CISTPL_BYTEORDER + */ +typedef struct cistpl_byteorder_t { + uint32_t order; /* byte order code */ + uint32_t map; /* byte mapping code */ +} cistpl_byteorder_t; + +/* + * byte order and mapping codes + */ +#define TPLBYTEORD_LOW 0x00 /* specifies little endian order */ +#define TPLBYTEORD_HIGH 0x01 /* specifies big endian order */ +#define TPLBYTEORD_VS 0x80 /* vendor specific order 0x80-0xFF */ + +#define TPLBYTEMAP_LOW 0x00 /* byte zero is least significant byte */ +#define TPLBYTEMAP_HIGH 0x01 /* byte zero is most significant byte */ +#define TPLBYTEMAP_VS 0x80 /* vendor specific mapping */ + +/* + * CISTPL_DATE + */ +typedef struct cistpl_date_t { + uint32_t time; + uint32_t day; +} cistpl_date_t; + +/* + * CISTPL_BATTERY + */ +typedef struct cistpl_battery_t { + uint32_t rday; /* replacement date */ + uint32_t xday; /* expiration date */ +} cistpl_battery_t; + +/* + * CISTPL_ORG + */ +typedef struct cistpl_org_t { + uint32_t type; /* data organization code */ + char desc[CIS_MAX_TUPLE_DATA_LEN]; /* text description of */ + /* this organization */ +} cistpl_org_t; + +/* + * CISTPL_MANFID + */ +typedef struct cistpl_manfid_t { + uint32_t manf; /* PCMCIA PC Card manufacturer code */ + uint32_t card; /* manufacturer information */ +} cistpl_manfid_t; + +/* + * CISTPL_FUNCID + */ +typedef struct cistpl_funcid_t { + uint32_t function; /* PC Card function code */ + uint32_t sysinit; /* system initialization mask */ +} cistpl_funcid_t; + +/* + * Function types for CISTPL_FUNCID; note that the TPLFUNC_UNKNOWN is + * not defined by the PCMCIA standard. + * + * Definitions for cistpl_funcid_t->function + */ +#define TPLFUNC_MULTI 0x000 /* vendor-specific multifunction card */ +#define TPLFUNC_MEMORY 0x001 /* memory card */ +#define TPLFUNC_SERIAL 0x002 /* serial I/O port */ +#define TPLFUNC_PARALLEL 0x003 /* parallel printer port */ +#define TPLFUNC_FIXED 0x004 /* fixed disk, silicon or removeable */ +#define TPLFUNC_VIDEO 0x005 /* video interface */ +#define TPLFUNC_LAN 0x006 /* Local Area Network adapter */ +#define TPLFUNC_AIMS 0x007 /* Auto Incrementing Mass Storage */ +#define TPLFUNC_SCSI 0x008 /* SCSI bridge */ +#define TPLFUNC_SECURITY 0x009 /* Security Cards */ +#define TPLFUNC_VENDOR_SPECIFIC 0x0fe /* Vendor Specific */ +#define TPLFUNC_UNKNOWN 0x0ff /* unknown function(s) */ +/* + * Definitions for cistpl_funcid_t->sysinit + */ +#define TPLINIT_POST 0x01 /* POST should attempt configure */ +#define TPLINIT_ROM 0x02 /* map ROM during sys init */ + +/* + * CISTPL_FUNCE + */ +typedef struct cistpl_funce_t { + uint32_t function; /* type of extended data */ + uint32_t subfunction; + union { + struct serial { + uint32_t ua; /* UART in use */ + uint32_t uc; /* UART capabilities */ + } serial; + struct modem { + uint32_t fc; /* supported flow control methods */ + uint32_t cb; /* size of DCE command buffer */ + uint32_t eb; /* size of DCE to DCE buffer */ + uint32_t tb; /* size of DTE to DCE buffer */ + } modem; + struct data_modem { + uint32_t ud; /* highest data rate */ + uint32_t ms; /* modulation standards */ + /* err correct proto and non-CCITT modulation */ + uint32_t em; + uint32_t dc; /* data compression protocols */ + uint32_t cm; /* command protocols */ + uint32_t ex; /* escape mechanisms */ + uint32_t dy; /* standardized data encryption */ + uint32_t ef; /* misc. end user features */ + uint32_t ncd; /* number of country codes */ + uchar_t cd[16]; /* CCITT country code */ + } data_modem; + struct fax { + uint32_t uf; /* highest data rate in DTE/UART */ + uint32_t fm; /* CCITT modulation standards */ + uint32_t fy; /* standardized data encryption */ + uint32_t fs; /* feature selection */ + uint32_t ncf; /* number of country codes */ + uchar_t cf[16]; /* CCITT country codes */ + } fax; + struct voice { + uint32_t uv; /* highest data rate */ + uint32_t nsr; + uint32_t sr[16]; /* voice sampling rates (*100) */ + uint32_t nss; + uint32_t ss[16]; /* voice sample sizes (*10) */ + uint32_t nsc; + uint32_t sc[16]; /* voice compression methods */ + } voice; + struct lan { + uint32_t tech; /* network technology */ + uint32_t speed; /* media bit or baud rate */ + uint32_t media; /* network media supported */ + uint32_t con; /* open/closed connector standard */ + uint32_t id_sz; /* length of lan station id */ + uchar_t id[16]; /* station ID */ + } lan; + } data; +} cistpl_funce_t; + +/* serial port subfunctions */ +#define TPLFE_SUB_SERIAL 0 /* serial port */ +#define TPLFE_SUB_MODEM_COMMON 1 /* common modem interface */ +#define TPLFE_SUB_MODEM_DATA 2 /* data modem services */ +#define TPLFE_SUB_MODEM_FAX 3 /* fax modem services */ +#define TPLFE_SUB_VOICE 4 /* voice services */ +/* modem subfunctions for description of capabilities */ +#define TPLFE_CAP_MODEM_DATA 5 /* data modem capabilities */ +#define TPLFE_CAP_MODEM_FAX 6 /* fax modem capabilities */ +#define TPLFE_CAP_MODEM_VOICE 7 /* voice modem capabilities */ +/* serial port subfunctions for description of capabilities */ +#define TPLFE_CAP_SERIAL_DATA 8 /* serial port capabilities - data modem */ +#define TPLFE_CAP_SERIAL_FAX 9 /* serial port capabilities - fax modem */ +#define TPLFE_CAP_SERIAL_VOICE 10 /* serial port capabilities - voice */ + +/* serial port UART definitions */ +#define TPLFE_UA_8250 0 /* Intel 8250 */ +#define TPLFE_UA_16450 1 /* NS 16450 */ +#define TPLFE_UA_16550 2 /* NS 16550 */ + +/* serial port capabilities definitions */ +#define TPLFE_UC_PARITY_SPACE 0x0001 /* space parity supported */ +#define TPLFE_UC_PARITY_MARK 0x0002 /* mark parity supported */ +#define TPLFE_UC_PARITY_ODD 0x0004 /* odd parity supported */ +#define TPLFE_UC_PARITY_EVEN 0x0008 /* even parity supported */ +#define TPLFE_UC_CS5 0x0100 /* 5 bit characters supported */ +#define TPLFE_UC_CS6 0x0200 /* 6 bit characters supported */ +#define TPLFE_UC_CS7 0x0400 /* 7 bit characters supported */ +#define TPLFE_UC_CS8 0x0800 /* 8 bit characters supported */ +#define TPLFE_UC_STOP_1 0x1000 /* 1 stop bit supported */ +#define TPLFE_UC_STOP_15 0x2000 /* 1.5 stop bits supported */ +#define TPLFE_UC_STOP_2 0x4000 /* 2 stop bits supported */ + +/* modem flow control methods */ +#define TPLFE_FC_TX_XONOFF 0x01 /* transmit XON/XOFF */ +#define TPLFE_FC_RX_XONOFF 0x02 /* receiver XON/XOFF */ +#define TPLFE_FC_TX_HW 0x04 /* transmit hardware flow control (CTS) */ +#define TPLFE_FC_RX_HW 0x08 /* receiver hardware flow control (RTS) */ +#define TPLFE_FC_TRANS 0x10 /* tranparent flow control */ + +/* modem modulation standards */ +#define TPLFE_MS_BELL103 0x0001 /* 300bps */ +#define TPLFE_MS_V21 0x0002 /* 300bps (V.21) */ +#define TPLFE_MS_V23 0x0004 /* 600/1200bps (V.23) */ +#define TPLFE_MS_V22AB 0x0008 /* 1200bps (V.22A V.22B) */ +#define TPLFE_MS_BELL212 0x0010 /* 2400bsp (US Bell 212) */ +#define TPLFE_MS_V22BIS 0x0020 /* 2400bps (V.22bis) */ +#define TPLFE_MS_V26 0x0040 /* 2400bps leased line (V.26) */ +#define TPLFE_MS_V26BIS 0x0080 /* 2400bps (V.26bis) */ +#define TPLFE_MS_V27BIS 0x0100 /* 4800/2400bps leased line (V.27bis) */ +#define TPLFE_MS_V29 0x0200 /* 9600/7200/4800 leased line (V.29) */ +#define TPLFE_MS_V32 0x0400 /* up to 9600bps (V.32) */ +#define TPLFE_MS_V32BIS 0x0800 /* up to 14400bps (V.32bis) */ +#define TPLFE_MS_VFAST 0x1000 /* up to 28800 V.FAST */ + +/* modem error correction/detection protocols */ +#define TPLFE_EM_MNP 0x01 /* MNP levels 2-4 */ +#define TPLFE_EM_V42 0x02 /* CCITT LAPM (V.42) */ + +/* modem data compression protocols */ +#define TPLFE_DC_V42BIS 0x01 /* CCITT compression V.42 */ +#define TPLFE_DC_MNP5 0x02 /* MNP compression (uses MNP 2, 3 or 4) */ + +/* modem command protocols */ +#define TPLFE_CM_AT1 0x01 /* ANSI/EIA/TIA 602 "Action" commands */ +#define TPLFE_CM_AT2 0x02 /* ANSI/EIA/TIA 602 "ACE/DCE IF Params" */ +#define TPLFE_CM_AT3 0x04 /* ANSI/EIA/TIA 602 "Ace Parameters" */ +#define TPLFE_CM_MNP_AT 0x08 /* MNP specificat AT commands */ +#define TPLFE_CM_V25BIS 0x10 /* V.25bis calling commands */ +#define TPLFE_CM_V25A 0x20 /* V.25bis test procedures */ +#define TPLFE_CM_DMCL 0x40 /* DMCL command mode */ + +/* modem escape mechanism */ +#define TPLFE_EX_BREAK 0x01 /* BREAK support standardized */ +#define TPLFE_EX_PLUS 0x02 /* +++ returns to command mode */ +#define TPLFE_EX_UD 0x04 /* user defined escape character */ + +/* modem miscellaneous features */ +#define TPLFE_EF_CALLERID 0x01 /* Caller ID is supported */ + +/* fax modulation standards */ +#define TPLFE_FM_V21C2 0x01 /* 300bps (V.21-C2) */ +#define TPLFE_FM_V27TER 0x02 /* 4800/2400bps (V.27ter) */ +#define TPLFE_FM_V29 0x04 /* 9600/7200/4800 leased line (V.29) */ +#define TPLFE_FM_V17 0x08 /* 14.4K/12K/9600/7200bps (V.17) */ +#define TPLFE_FM_V33 0x10 /* 14.4K/12K/9600/7200 lease line (V.33) */ + +/* fax feature selection */ +#define TPLFE_FS_T3 0x01 /* Group 2 (T.3) service class */ +#define TPLFE_FS_T4 0x02 /* Group 3 (T.4) service class */ +#define TPLFE_FS_T6 0x04 /* Group 4 (T.6) service class */ +#define TPLFE_FS_ECM 0x08 /* Error Correction Modeer */ +#define TPLFE_FS_VOICEREQ 0x10 /* voice requests allowed */ +#define TPLFE_FS_POLLING 0x20 /* polling support */ +#define TPLFE_FS_FTP 0x40 /* file transfer support */ +#define TPLFE_FS_PASSWORD 0x80 /* password support */ + +/* LAN tuple definitions */ +#define TPLFE_NETWORK_INFO 0x00 + +/* LAN technology types */ +#define TPLFE_LAN_TECH_ARCNET 1 +#define TPLFE_LAN_TECH_ETHERNET 2 +#define TPLFE_LAN_TECH_TOKENRING 3 +#define TPLFE_LAN_TECH_LOCALTALK 4 +#define TPLFE_LAN_TECH_FDDI 5 +#define TPLFE_LAN_TECH_ATM 6 +#define TPLFE_LAN_TECH_WIRELESS 7 + +/* LAN media types */ +#define TPLFE_LAN_MEDIA_INHERENT 0 +#define TPLFE_LAN_MEDIA_UTP 1 +#define TPLFE_LAN_MEDIA_STP 2 +#define TPLFE_LAN_MEDIA_THIN_COAX 3 +#define TPLFE_LAN_MEDIA_THICK_COAX 4 +#define TPLFE_LAN_MEDIA_FIBER 5 +#define TPLFE_LAN_MEDIA_SSR_902 6 +#define TPLFE_LAN_MEDIA_SSR_2_4 7 +#define TPLFE_LAN_MEDIA_SSR_5_4 8 +#define TPLFE_LAN_MEDIA_DIFFUSE_IR 9 +#define TPLFE_LAN_MEDIA_PTP_IR 10 + +/* + * CISTPL_CFTABLE_ENTRY + * + * These flags and macros are used internally to the handler. + */ + /* mask to get the config entry number from TPCE_INDX */ +#define CISTPL_CFTABLE_TPCE_CFGENTRYM 0x03f + /* default config bit in TPCE_INDX */ +#define CISTPL_CFTABLE_TPCE_DEFAULTM 0x040 + /* interface config byte follows */ +#define CISTPL_CFTABLE_TPCE_IFM 0x080 + + /* power bit mask for tpce_fs */ +#define CISTPL_CFTABLE_TPCE_FS_PWRM 0x003 + /* Vcc, Vpp1 and Vpp2 descriptions */ +#define CISTPL_CFTABLE_TPCE_FS_PWR_VPP2M 0x003 + /* Vcc and Vpp1=Vpp2 descriptions */ +#define CISTPL_CFTABLE_TPCE_FS_PWR_VPP1M 0x002 + /* Vcc description only */ +#define CISTPL_CFTABLE_TPCE_FS_PWR_VCCM 0x001 + /* no connection on sleep/power down */ +#define CISTPL_CFTABLE_PD_NC_SLEEPM 0x07d + /* zero value required */ +#define CISTPL_CFTABLE_PD_ZEROM 0x07e + /* no connection ever */ +#define CISTPL_CFTABLE_PD_NCM 0x07f + + /* timing data exists */ +#define CISTPL_CFTABLE_TPCE_FS_TDM 0x004 + /* WAIT scale mask */ +#define CISTPL_CFTABLE_TPCE_FS_TD_WAITM 0x003 +#define GET_TPCE_FS_TD_WAITS(sf) ((sf)& \ + CISTPL_CFTABLE_TPCE_FS_TD_WAITM) + /* RDY/BSY scale mask */ +#define CISTPL_CFTABLE_TPCE_FS_TD_RDYM 0x01c +#define GET_TPCE_FS_TD_RDYS(sf) (((sf)>>2)& \ + CISTPL_CFTABLE_TPCE_FS_TD_RDYM) + /* RSVD scale mask */ +#define CISTPL_CFTABLE_TPCE_FS_TD_RSVDM 0x0e0 +#define GET_TPCE_FS_TD_RSVDS(sf) (((sf)>>5)& \ + CISTPL_CFTABLE_TPCE_FS_TD_RSVDM) + +#define CISTPL_CFTABLE_TPCE_FS_IOM 0x008 /* I/O data exists */ + /* I/O addr lines mask */ +#define CISTPL_CFTABLE_TPCE_FS_IO_ALM 0x01f + /* RANGE bit in TPCE_IO */ +#define CISTPL_CFTABLE_TPCE_FS_IO_RANGEM 0x080 + /* max of 16 I/O ranges */ +#define CISTPL_CFTABLE_ENTRY_MAX_IO_RANGES 16 + +#define CISTPL_CFTABLE_TPCE_FS_IRQM 0x010 /* IRQ data exists */ + /* extended IRQ mask exists */ +#define CISTPL_CFTABLE_TPCE_FS_IRQ_MASKM 0x010 + +#define CISTPL_CFTABLE_TPCE_FS_MEMM 0x060 /* mem space mask */ + /* space selection byte ... */ +#define CISTPL_CFTABLE_TPCE_FS_MEM3M 0x060 + /* length (2 bytes) and card address (2 bytes) */ +#define CISTPL_CFTABLE_TPCE_FS_MEM2M 0x040 + /* single 2-byte length */ +#define CISTPL_CFTABLE_TPCE_FS_MEM1M 0x020 + /* max of 8 mem space descriptors */ +#define CISTPL_CFTABLE_ENTRY_MAX_MEM_WINDOWS 8 + /* number of bytes/page description */ +#define CISTPL_CFTABLE_TPCE_FS_MEM_PGSIZE 256 + /* host addr info present */ +#define CISTPL_CFTABLE_TPCE_FS_MEM_HOSTM 0x080 + +#define CISTPL_CFTABLE_TPCE_FS_MISCM 0x080 /* misc fields mask */ + +/* + * Constants, macros, structures and flags used by cistpl_pd_parse() + * cistpl_expd_parse() and the CISTPL_CFTABLE_ENTRY tuple handler. + */ +#define CISTPL_PD_MAN(m) cistpl_pd_struct.mantissa[m&15] +#define CISTPL_PD_EXP(e) cistpl_pd_struct.exponent[e&7] +typedef struct cistpl_pd_struct_t { + uint32_t *mantissa; + uint32_t *exponent; +} cistpl_pd_struct_t; + +/* + * These flags are passed to the caller in the cistpl_cftable_entry_t->flags + * field and indicate what interface information is available. The low + * order byte of this field is reserved and no flags should be defined + * to exist there. + */ +#define CISTPL_CFTABLE_TPCE_DEFAULT 0x000000100 /* this is a default conf */ + +/* interface config description present flags */ +#define CISTPL_CFTABLE_TPCE_IF 0x000000200 /* if config byte exists */ +/* + * When the CISTPL_CFTABLE_TPCE_IF flag is set, the following flags + * are available in the ifc member of the cistpl_cftable_entry_t + * structure. + */ +#define CISTPL_CFTABLE_TPCE_IF_MEMORY 0x00 /* memory interface */ +#define CISTPL_CFTABLE_TPCE_IF_IO_MEM 0x01 /* IO and memory */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_2 0x02 /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_3 0x03 /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_CUSTOM_0 0x04 /* custom interface 0 */ +#define CISTPL_CFTABLE_TPCE_IF_CUSTOM_1 0x05 /* custom interface 1 */ +#define CISTPL_CFTABLE_TPCE_IF_CUSTOM_2 0x06 /* custom interface 2 */ +#define CISTPL_CFTABLE_TPCE_IF_CUSTOM_3 0x07 /* custom interface 3 */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_8 0x08 /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_9 0x09 /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_a 0x0a /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_b 0x0b /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_c 0x0c /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_d 0x0d /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_e 0x0e /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_RSVD_f 0x0f /* reserved */ +#define CISTPL_CFTABLE_TPCE_IF_MASK 0x0f /* interface type mask */ +#define CISTPL_CFTABLE_TPCE_IF_BVD 0x10 /* BVD active in PRR */ +#define CISTPL_CFTABLE_TPCE_IF_WP 0x20 /* WP active in PRR */ +#define CISTPL_CFTABLE_TPCE_IF_RDY 0x40 /* RDY active in PRR */ +#define CISTPL_CFTABLE_TPCE_IF_MWAIT 0x80 /* WAIT - mem cycles */ + +/* power description present flags */ +#define CISTPL_CFTABLE_TPCE_FS_PWR 0x000001000 /* power info exists */ + +/* timing description present flags */ +#define CISTPL_CFTABLE_TPCE_FS_TD 0x000010000 /* timing info exists */ + +/* I/O description present flags */ +#define CISTPL_CFTABLE_TPCE_FS_IO 0x000100000 /* I/O information exists */ + +/* IRQ description present flags */ +#define CISTPL_CFTABLE_TPCE_FS_IRQ 0x000200000 /* IRQ information exists */ + +/* memory space description present flags */ +#define CISTPL_CFTABLE_TPCE_FS_MEM 0x001000000 /* MEM space info exists */ + +/* misc description present flags */ +#define CISTPL_CFTABLE_TPCE_FS_MISC 0x002000000 /* MISC info exists */ + +/* additional information tuples present flags */ +#define CISTPL_CFTABLE_TPCE_FS_STCE_EV 0x004000000 /* STCE_EV exists */ +#define CISTPL_CFTABLE_TPCE_FS_STCE_PD 0x008000000 /* STCE_PD exists */ + +/* + * Power description flags and structures. + * + * The following eight values represent what the power description structure + * parameter selection byte tells us is present. A copy of this byte + * is in the low order byte of each parameter's flag field. + */ +#define CISTPL_CFTABLE_PD_NOMV 0x001 /* nominal supply voltage */ +#define CISTPL_CFTABLE_PD_MINV 0x002 /* minimum supply voltage */ +#define CISTPL_CFTABLE_PD_MAXV 0x004 /* maximum supply voltage */ +#define CISTPL_CFTABLE_PD_STATICI 0x008 /* continuous supply current */ + /* max current required averaged over 1 second */ +#define CISTPL_CFTABLE_PD_AVGI 0x010 + /* maximum current required averaged over 10mS */ +#define CISTPL_CFTABLE_PD_PEAKI 0x020 + /* power down supply curent required */ +#define CISTPL_CFTABLE_PD_PDOWNI 0x040 + /* power supply is about to blow up */ +#define CISTPL_CFTABLE_PD_RFU 0x080 + +/* + * For each voltage/current parameter, there is an associated flags field. + * The following flags are in this field. The low order byte of each + * of these flags fields also contains a copy of the power description + * structure parameter selection byte as read from the tuple, that's why + * we start the flag values at 0x0100 and go up from there. + */ + /* this parameter exists */ +#define CISTPL_CFTABLE_PD_EXISTS 0x000000100 + /* multiply return value by 10 */ +#define CISTPL_CFTABLE_PD_MUL10 0x000000200 + /* no connection on sleep/power down */ +#define CISTPL_CFTABLE_PD_NC_SLEEP 0x000001000 + /* zero value required */ +#define CISTPL_CFTABLE_PD_ZERO 0x000002000 + /* no connection ever */ +#define CISTPL_CFTABLE_PD_NC 0x000004000 + +typedef struct cistpl_cftable_entry_pwr_t { + uint32_t nomV; /* nominal supply voltage */ + uint32_t nomV_flags; + uint32_t minV; /* minimum supply voltage */ + uint32_t minV_flags; + uint32_t maxV; /* maximum supply voltage */ + uint32_t maxV_flags; + uint32_t staticI; /* continuous supply current */ + uint32_t staticI_flags; + uint32_t avgI; /* max current required */ + /* averaged over 1 sec. */ + uint32_t avgI_flags; + uint32_t peakI; /* max current required */ + /* averaged over 10mS */ + uint32_t peakI_flags; + uint32_t pdownI; /* power down supply curent required */ + uint32_t pdownI_flags; +} cistpl_cftable_entry_pwr_t; + +/* + * Flags for the global power description structure. These show up in + * the flags field of the structure. + */ +#define CISTPL_CFTABLE_TPCE_FS_PWR_VCC 0x000000001 /* Vcc description valid */ +#define CISTPL_CFTABLE_TPCE_FS_PWR_VPP1 0x000000002 /* vpp1 description valid */ +#define CISTPL_CFTABLE_TPCE_FS_PWR_VPP2 0x000000004 /* Vpp2 description valid */ + +typedef struct cistpl_cftable_entry_pd_t { + uint32_t flags; /* which descriptions are valid */ + struct cistpl_cftable_entry_pwr_t pd_vcc; /* VCC power description */ + struct cistpl_cftable_entry_pwr_t pd_vpp1; /* Vpp1 power description */ + struct cistpl_cftable_entry_pwr_t pd_vpp2; /* Vpp2 power description */ +} cistpl_cftable_entry_pd_t; + +/* + * Device speed structure. Each field is only valid if the + * CISTPL_CFTABLE_TPCE_FS_TD flag is set. + * + * The following flags describe which timing information is available. + * They appear in the flags field of the device speed structure. + */ + /* WAIT timing exists */ +#define CISTPL_CFTABLE_TPCE_FS_TD_WAIT 0x000000001 + /* RDY/BSY timing exists */ +#define CISTPL_CFTABLE_TPCE_FS_TD_RDY 0x000000002 + /* RSVD timing exists */ +#define CISTPL_CFTABLE_TPCE_FS_TD_RSVD 0x000000004 + +typedef struct cistpl_cftable_entry_speed_t { + uint32_t flags; /* which timing information is present */ + uint32_t wait; /* max WAIT time in device speed format */ + uint32_t nS_wait; /* max WAIT time in nS */ + uint32_t rdybsy; /* max RDY/BSY time in device speed format */ + uint32_t nS_rdybsy; /* max RDY/BSY time in nS */ + uint32_t rsvd; /* max RSVD time in device speed format */ + uint32_t nS_rsvd; /* max RSVD time in nS */ +} cistpl_cftable_entry_speed_t; + +/* + * Device I/O range description structures. Only valid if the + * CISTPL_CFTABLE_TPCE_FS_IO flag is set. + * + * The following flags describe the IO description information. They + * appear in the flags field of the IO space description structure. + */ +#define CISTPL_CFTABLE_TPCE_FS_IO_BUS 0x060 /* bus width mask */ +#define CISTPL_CFTABLE_TPCE_FS_IO_BUS8 0x020 /* 8-bit flag */ +#define CISTPL_CFTABLE_TPCE_FS_IO_BUS16 0x040 /* 16-bit flag */ +#define CISTPL_CFTABLE_TPCE_FS_IO_RANGE 0x080 /* IO address ranges exist */ + +typedef struct cistpl_cftable_entry_io_range_t { + uint32_t addr; /* I/O start address */ + uint32_t length; /* I/O register length */ +} cistpl_cftable_entry_io_range_t; +typedef struct cistpl_cftable_entry_io_t { + uint32_t flags; /* direct copy of TPCE_IO byte in tuple */ + uint32_t addr_lines; /* number of decoded I/O address lines */ + uint32_t ranges; /* number of I/O ranges */ + struct cistpl_cftable_entry_io_range_t + range[CISTPL_CFTABLE_ENTRY_MAX_IO_RANGES]; +} cistpl_cftable_entry_io_t; + +/* + * Device IRQ description structure. Only valid if the + * CISTPL_CFTABLE_TPCE_FS_IRQ flag is set. + */ +typedef struct cistpl_cftable_entry_irq_t { + uint32_t flags; /* direct copy of TPCE_IR byte in tuple */ + uint32_t irqs; /* bit mask for each allowed IRQ */ +} cistpl_cftable_entry_irq_t; + +/* + * Device memory space description structure. Only valid if the + * CISTPL_CFTABLE_TPCE_FS_MEM flag is set. + * + * The following flags describe the memory description information. They + * appear in the flags field of the memory space description structure. + */ + /* space descriptors */ +#define CISTPL_CFTABLE_TPCE_FS_MEM3 0x000000001 + /* host_addr=card_addr */ +#define CISTPL_CFTABLE_TPCE_FS_MEM2 0x000000002 + /* card address=0, any host address */ +#define CISTPL_CFTABLE_TPCE_FS_MEM1 0x000000004 + /* if host address is present in MEM3 */ +#define CISTPL_CFTABLE_TPCE_FS_MEM_HOST 0x000000008 + +typedef struct cistpl_cftable_entry_mem_window_t { + uint32_t length; /* length of this window */ + uint32_t card_addr; /* card address */ + uint32_t host_addr; /* host address */ +} cistpl_cftable_entry_mem_window_t; +typedef struct cistpl_cftable_entry_mem_t { + uint32_t flags; /* memory desc type and host addr info */ + uint32_t windows; /* number of memory space descriptors */ + cistpl_cftable_entry_mem_window_t + window[CISTPL_CFTABLE_ENTRY_MAX_MEM_WINDOWS]; +} cistpl_cftable_entry_mem_t; + +/* + * Devices misc description structure. Only valid if the + * CISTPL_CFTABLE_TPCE_FS_MISC flag is set. + */ +#define CISTPL_CFTABLE_TPCE_FS_MISC_MAX 2 /* # bytes we understand */ +#define CISTPL_CFTABLE_TPCE_MI_MTC_MASK 0x00000007 /* max twin cards mask */ +#define CISTPL_CFTABLE_TPCE_MI_AUDIO 0x00000008 /* audio on BVD2 */ +#define CISTPL_CFTABLE_TPCE_MI_READONLY 0x00000010 /* R/O storage */ +#define CISTPL_CFTABLE_TPCE_MI_PWRDOWN 0x00000020 /* powerdown capable */ +#define CISTPL_CFTABLE_TPCE_MI_DRQ_MASK 0x00000c00 /* DMAREQ mask */ +#define CISTPL_CFTABLE_TPCE_MI_DRQ_SPK 0x00000400 /* DMAREQ on SPKR */ +#define CISTPL_CFTABLE_TPCE_MI_DRQ_IOIS 0x00000800 /* DMAREQ on IOIS16 */ +#define CISTPL_CFTABLE_TPCE_MI_DRQ_INP 0x00000c00 /* DMAREQ on INPACK */ +#define CISTPL_CFTABLE_TPCE_MI_DMA_8 0x00000000 /* DMA width 8 bits */ +#define CISTPL_CFTABLE_TPCE_MI_DMA_16 0x00001000 /* DMA width 16 bits */ + +typedef struct cistpl_cftable_entry_misc_t { + uint32_t flags; /* misc features flags */ +} cistpl_cftable_entry_misc_t; + +/* + * Additional information sub-tuples defines and structure + */ +#define STCE_EV 0x0c0 /* Environment Descriptor Subtuple */ +#define STCE_PD 0x0c1 /* Physical Device Name Subtuple */ +typedef struct cistpl_cftable_entry_stce_ev_t { + char stev_strs[CIS_MAX_TUPLE_DATA_LEN]; +} cistpl_cftable_entry_stce_ev_t; + +typedef struct cistpl_cftable_entry_stce_pd_t { + char stpd_strs[CIS_MAX_TUPLE_DATA_LEN]; +} cistpl_cftable_entry_stce_pd_t; + +/* + * cistpl_cftable_entry_t - this is the struct that the caller passes + * to the CISTPL_CFTABLE_ENTRY handler + */ +typedef struct cistpl_cftable_entry_t { + uint32_t flags; /* which descriptions are valid */ + uint32_t ifc; /* interface description info */ + uint32_t pin; /* values for PRR */ + uint32_t index; /* configuration index number */ + struct cistpl_cftable_entry_pd_t pd; /* power requirements description */ + struct cistpl_cftable_entry_speed_t speed; /* device speed description */ + struct cistpl_cftable_entry_io_t io; /* device I/O map */ + struct cistpl_cftable_entry_irq_t irq; /* device IRQ utilization */ + struct cistpl_cftable_entry_mem_t mem; /* device memory space */ + struct cistpl_cftable_entry_misc_t misc; /* misc device features */ +} cistpl_cftable_entry_t; + +/* + * CISTPL_LINKTARGET + * + * This tuple is used to verify that tuple chains other than the primary + * chain which starts at offset 0 in Attribute Memory are valid. All + * secondary tuple chains are required to contain this tuple as the + * first tuple of the chain. + * This tuple must have a link field of at least MIN_LINKTARGET_LENGTH and + * must contain the byte pattern CISTPL_LINKTARGET_MAGIC. + * LINKTARGET_AC_HEADER_LENGTH is the number of bytes contained in a + * valid CISTPL_LINKTARGET tuple header. + */ +#define MIN_LINKTARGET_LENGTH 3 +#define CISTPL_LINKTARGET_MAGIC "CIS" +#define LINKTARGET_AC_HEADER_LENGTH 2 + +typedef struct cistpl_linktarget_t { + uint32_t length; /* number of bytes in tpltg_tag */ + char tpltg_tag[CIS_MAX_TUPLE_DATA_LEN]; +} cistpl_linktarget_t; + +/* + * CISTPL_LONGLINK_A and CISTPL_LONGLINK_C + * + * Both of these tuples are processed the same way. The target address is + * really an offset from the beginning of the specified address space + * and is not a virtual address. + * This tuple must have a link field of at least MIN_LONGLINK_AC_LENGTH. + */ +#define MIN_LONGLINK_AC_LENGTH 4 + +typedef struct cistpl_longlink_ac_t { + uint32_t flags; /* space flags */ + uint32_t tpll_addr; /* target address, normalized */ +} cistpl_longlink_ac_t; +/* + * Flags for cistpl_longlink_ac_t->flags + */ +#define CISTPL_LONGLINK_AC_AM 0x0001 /* longlink to AM */ +#define CISTPL_LONGLINK_AC_CM 0x0002 /* longlink to CM */ + +/* + * CISTPL_LONGLINK_MFC + * + * This tuple describes the start of the function-specific CIS for each + * function on a multi-function card. + * + * This tuple must have a link field of at least MIN_LONGLINK_AC_LENGTH. + */ +#define MIN_LONGLINK_MFC_LENGTH 6 +#define MIN_LONGLINK_MFC_NREGS 1 + +typedef struct cis_function_t { + uint32_t tas; /* target address space of function */ + uint32_t addr; /* target address offset */ +} cis_function_t; + +typedef struct cistpl_longlink_mfc_t { + uint32_t nfuncs; /* number of functions */ + uint32_t nregs; /* number of config register sets */ + cis_function_t function[CIS_MAX_FUNCTIONS]; +} cistpl_longlink_mfc_t; +/* + * Flags for cistpl_longlink_mfc_t->function[n]->tas + */ +#define CISTPL_LONGLINK_MFC_TAS_AM 0x00 /* CIS in attribute memory */ +#define CISTPL_LONGLINK_MFC_TAS_CM 0x01 /* CIS in common memory */ + +/* + * CISTPL_LONGLINK_CB + * + * This tuple describes the start of a function's CIS chain + * for CardBus cards + */ +typedef struct cistpl_longlink_cb_t { + uint32_t flags; /* address space flags */ + uint32_t addr; /* raw (unproessed) address value */ + union { + /* device-dependant config space info */ + struct { + uint32_t offset; /* offset within config space */ + } cfg; + /* memory space info */ + struct { + uint32_t asi; /* BAR */ + uint32_t offset; /* offset within BAR space */ + } mem; + /* expansion ROM space info */ + struct { + uint32_t image; /* image number */ + uint32_t offset; /* offset from iamge base */ + } rom; + } space; +} cistpl_longlink_cb_t; +/* + * Flags for cistpl_longlink_cb_t->flags + */ +#define CISTPL_LONGLINK_CB_CFG 0x0001 /* config space info valid */ +#define CISTPL_LONGLINK_CB_MEM 0x0002 /* memory space info valid */ +#define CISTPL_LONGLINK_CB_ROM 0x0004 /* expansion ROM space info valid */ + +/* + * CISTPL_SPCL + * + * This tuple is the Special Purpose tuple and it's contents are dependant + * on the meaning of the header information in this tuple. + */ +typedef struct cistpl_spcl_t { + uint32_t id; /* tuple contents identification */ + uint32_t seq; /* data sequence number */ + uint32_t bytes; /* number of bytes following */ + uchar_t data[CIS_MAX_TUPLE_DATA_LEN]; +} cistpl_spcl_t; +/* + * Flags for cistpl_spcl_t->seq + */ +#define CISTPL_SPCL_SEQ_END 0x080 /* last tuple in sequence */ + +/* + * CISTPL_SWIL + * + * This tuple describes the software interleaving of data within a + * partition on the card. + */ +typedef struct cistpl_swil_t { + uint32_t intrlv; /* interleave */ +} cistpl_swil_t; + +/* + * CISTPL_BAR + * + * This tuple describes the CardBus Base Address Registers + */ +typedef struct cistpl_bar_t { + uint32_t attributes; /* attributes */ + uint32_t size; /* BAR size */ +} cistpl_bar_t; +/* + * Flags for cistpl_bar_t->attributes + */ +#define CISTPL_BAR_ASI_MASK 0x007 /* Base Address Register mask */ +#define CISTPL_BAR_ASI_BAR_1 0x001 /* Base Address Register 1 */ +#define CISTPL_BAR_ASI_BAR_2 0x002 /* Base Address Register 2 */ +#define CISTPL_BAR_ASI_BAR_3 0x003 /* Base Address Register 3 */ +#define CISTPL_BAR_ASI_BAR_4 0x004 /* Base Address Register 4 */ +#define CISTPL_BAR_ASI_BAR_5 0x005 /* Base Address Register 5 */ +#define CISTPL_BAR_ASI_BAR_6 0x006 /* Base Address Register 6 */ +#define CISTPL_BAR_ASI_BAR_7 0x007 /* Base Address Register 7 */ +#define CISTPL_BAR_ASI_EXP_ROM 0x007 /* Expansion ROM BAR */ + +#define CISTPL_BAR_AS_MEM 0x000 /* BAR is of type memory */ +#define CISTPL_BAR_AS_IO 0x008 /* BAR is of type IO */ + +#define CISTPL_BAR_PREFETCH_CACHE_MASK 0x060 /* prefetch/cache mask */ +#define CISTPL_BAR_PREFETCH 0x020 /* prefetchable not cacheable */ +#define CISTPL_BAR_PREFETCH_CACHE 0x040 /* prefetchable and cacheable */ + +#define CISTPL_BAR_BELOW_1MB 0x080 /* must locate within first MB */ + +/* + * CISTPL_DEVICEGEO and CISTPL_DEVICEGEO_A + * + * These tuples describe the device geometry of memory partitions. + */ +#define CISTPL_DEVICEGEO_MAX_PARTITIONS 42 +typedef struct cistpl_devicegeo_info_t { + uint32_t bus; /* card interface width in bytes */ + uint32_t ebs; /* minimum erase block size */ + uint32_t rbs; /* minimum read block size */ + uint32_t wbs; /* minimum write bock size */ + uint32_t part; /* segment partition subdivisions */ + uint32_t hwil; /* hardware interleave */ +} cistpl_devicegeo_info_t; +typedef struct cistpl_devicegeo_t { + cistpl_devicegeo_info_t info[CISTPL_DEVICEGEO_MAX_PARTITIONS]; +} cistpl_devicegeo_t; + +/* + * The cistpl_get_tuple_name_t used to support the HANDTPL_RETURN_NAME + * operation of the CIS parser. + */ +typedef struct cistpl_get_tuple_name_t { + char name[CIS_MAX_TUPLE_NAME_LEN]; +} cistpl_get_tuple_name_t; + +/* + * cisparse_t - the structure that unifies all tuple parsing structures + */ +typedef union cisparse_t { + cistpl_config_t cistpl_config; + cistpl_device_t cistpl_device; + cistpl_vers_1_t cistpl_vers_1; + cistpl_vers_2_t cistpl_vers_2; + cistpl_jedec_t cistpl_jedec; + cistpl_format_t cistpl_format; + cistpl_geometry_t cistpl_geometry; + cistpl_byteorder_t cistpl_byteorder; + cistpl_date_t cistpl_date; + cistpl_battery_t cistpl_battery; + cistpl_org_t cistpl_org; + cistpl_manfid_t cistpl_manfid; + cistpl_funcid_t cistpl_funcid; + cistpl_funce_t cistpl_funce; + cistpl_cftable_entry_t cistpl_cftable_entry; + cistpl_linktarget_t cistpl_linktarget; + cistpl_longlink_ac_t cistpl_longlink_ac; + cistpl_longlink_mfc_t cistpl_longlink_mfc; + cistpl_spcl_t cistpl_spcl; + cistpl_swil_t cistpl_swil; + cistpl_bar_t cistpl_bar; + cistpl_devicegeo_t cistpl_devicegeo; + cistpl_longlink_cb_t cistpl_longlink_cb; + cistpl_get_tuple_name_t cistpl_get_tuple_name; + /* members below are for legacy support - REMOVE THEM BEFORE FCS!! */ + cistpl_config_t config; + cistpl_device_t device; + cistpl_vers_1_t version_1; + cistpl_vers_2_t version_2; + cistpl_jedec_t jedec; + cistpl_format_t format; + cistpl_geometry_t geometry; + cistpl_byteorder_t byteorder; + cistpl_date_t date; + cistpl_battery_t battery; + cistpl_org_t org; + cistpl_manfid_t manfid; + cistpl_funcid_t funcid; + cistpl_funce_t funce; + cistpl_cftable_entry_t cftable; + cistpl_linktarget_t linktarget; + cistpl_longlink_ac_t longlink_ac; + cistpl_longlink_mfc_t longlink_mfc; + cistpl_spcl_t spcl; + cistpl_swil_t swil; + cistpl_bar_t bar; + cistpl_devicegeo_t devgeo; + cistpl_longlink_cb_t longlink_cb; + cistpl_get_tuple_name_t tuple_name; +} cisparse_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _CIS_HANDLERS_H */ diff --git a/illumos-x86_64/usr/include/sys/cis_protos.h b/illumos-x86_64/usr/include/sys/cis_protos.h new file mode 100644 index 00000000..95374cb2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cis_protos.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999,2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _CIS_PROTOS_H +#define _CIS_PROTOS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains all of the function prototypes for functions + * used by the CIS interpreter. + * + * Prototypes for general functions + */ +uint32_t cis_list_create(cistpl_callout_t *, cs_socket_t *); +uint32_t cis_list_destroy(cs_socket_t *); +uint32_t cis_list_lcreate(cistpl_callout_t *, cisptr_t *, + cis_info_t *, cisparse_t *, cs_socket_t *); +uint32_t cis_list_ldestroy(cistpl_t **); +cistpl_t *cis_get_ltuple(cistpl_t *, cisdata_t, uint32_t); +uint32_t cistpl_devspeed(cistpl_t *, cisdata_t, uint32_t); +uint32_t cistpl_expd_parse(cistpl_t *, uint32_t *); +uint32_t cis_convert_devspeed(convert_speed_t *); +uint32_t cis_convert_devsize(convert_size_t *); +uint32_t cis_validate_longlink_acm(cisptr_t *); + +/* + * Prototypes for the tuple handlers + */ +uint32_t cis_tuple_handler(cistpl_callout_t *, cistpl_t *, uint32_t, + void *, cisdata_t); +uint32_t cis_no_tuple_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cis_unknown_tuple_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_vers_1_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_config_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_device_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_cftable_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_jedec_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_vers_2_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_format_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_geometry_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_byteorder_handler(cistpl_callout_t *, + cistpl_t *, uint32_t, void *); +uint32_t cistpl_date_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_battery_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_org_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_funcid_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_funce_serial_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_funce_lan_handler(cistpl_callout_t *, + cistpl_t *, uint32_t, void *); +uint32_t cistpl_manfid_handler(cistpl_callout_t *, cistpl_t *, + uint32_t, void *); +uint32_t cistpl_linktarget_handler(cistpl_callout_t *, + cistpl_t *, uint32_t, void *); +uint32_t cistpl_longlink_ac_handler(cistpl_callout_t *, + cistpl_t *, uint32_t, void *); +uint32_t cistpl_longlink_mfc_handler(cistpl_callout_t *, + cistpl_t *, uint32_t, void *); + +char *cis_getstr(cistpl_t *); + +#ifdef _KERNEL +caddr_t cis_malloc(size_t); +void cis_free(caddr_t); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _CIS_PROTOS_H */ diff --git a/illumos-x86_64/usr/include/sys/cladm.h b/illumos-x86_64/usr/include/sys/cladm.h new file mode 100644 index 00000000..a131089f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cladm.h @@ -0,0 +1,154 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CLADM_H +#define _SYS_CLADM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + + +/* + * This file defines interfaces which are private to Sun Clustering. + * Others should not depend on this in any way as it may change or be + * removed completely. + */ + +/* + * cladm() facilities; see below for definitions pertinent to each of these + * facilities. + */ +#define CL_INITIALIZE 0 /* bootstrapping information */ +#define CL_CONFIG 1 /* configuration information */ + + +/* + * Command definitions for each of the facilities. + * The type of the data pointer and the direction of the data transfer + * is listed for each command. + */ + +/* + * CL_INITIALIZE facility commands. + */ +#define CL_GET_BOOTFLAG 0 /* Return cluster config/boot status */ + +/* + * Definitions for the flag bits returned by CL_GET_BOOTFLAG. + */ +#define CLUSTER_CONFIGURED 0x0001 /* system is configured as a cluster */ +#define CLUSTER_BOOTED 0x0002 /* system is booted as a cluster */ + +#ifdef _KERNEL +#define CLUSTER_INSTALLING 0x0004 /* cluster is being installed */ +#define CLUSTER_DCS_ENABLED 0x0008 /* cluster device framework enabled */ +#endif /* _KERNEL */ + +/* + * CL_CONFIG facility commands. + * The CL_GET_NETADDRS and CL_GET_NUM_NETADDRS are contract private interfaces + * per PSARC/2001/579-01. + */ +#define CL_NODEID 0 /* Return nodeid of this node. */ +#define CL_HIGHEST_NODEID 1 /* Return highest configured nodeid. */ +#define CL_GDEV_PREFIX 2 /* Return path to global namespace. */ +#define CL_GET_NETADDRS 3 /* Get array of network addresses */ + /* controlled by Sun Cluster. */ +#define CL_GET_NUM_NETADDRS 4 /* Get the number of data structure */ + /* entries in the array that will be */ + /* returned using CL_GET_NETADDRS. */ + +/* + * The cladm system call can provide an array of cluster controlled + * network addresses and associated netmasks. The cladm arguments + * must be as follows: the argument fac is specified as CL_CONFIG, + * the argument cmd is specified as CL_GET_NETADDRS, and argument arg + * is the location of a structure of type cladm_netaddrs_t. The + * cladm_num_netaddrs is used as input for the requested number + * of array entries, and is used as ouput for the number of valid array + * entries available. + * + * The caller must allocate sufficient memory for the array of + * structures of type cladm_netaddr_entry_t and specify the starting + * location as cladm_netaddrs_array. The number of entries included + * in the array is determined using cladm with argument fac specified + * as CL_CONFIG, argument cmd specified as CL_GET_NUM_NETADDRS, and + * argument arg is the location of a structure of type cladm_netaddrs_t. + * The determined number of array entries is returned in + * cladm_num_netaddrs. + * + * These commands support the yielding of DR operation control (by the + * RCM Framework) to Sun Cluster for cluster controlled adapters. + * + * These data structures are contract private per PSARC/2001/579-01. + */ +typedef struct { + int32_t cl_ipversion; /* IPV4_VERSION or IPV6_VERSION */ + union { + struct { + ipaddr_t ipv4_netaddr; + ipaddr_t ipv4_netmask; + } cl_ipv4; + struct { + uint32_t ipv6_netaddr[4]; + uint32_t ipv6_netmask[4]; + } cl_ipv6; + } cl_ipv_un; +} cladm_netaddr_entry_t; + +typedef struct { + uint32_t cladm_num_netaddrs; + cladm_netaddr_entry_t *cladm_netaddrs_array; +} cladm_netaddrs_t; + +#if defined(_SYSCALL32) +typedef struct { + uint32_t cladm_num_netaddrs; + caddr32_t cladm_netaddrs_array; +} cladm_netaddrs32_t; +#endif /* defined(_SYSCALL32) */ + + +#ifdef _KERNEL +extern int cladmin(int fac, int cmd, void *data); +extern int cluster_bootflags; +#else +extern int _cladm(int fac, int cmd, void *data); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + + +#endif /* _SYS_CLADM_H */ diff --git a/illumos-x86_64/usr/include/sys/class.h b/illumos-x86_64/usr/include/sys/class.h new file mode 100644 index 00000000..c795f85e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/class.h @@ -0,0 +1,233 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_CLASS_H +#define _SYS_CLASS_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NOTE: Developers making use of the scheduler class switch mechanism + * to develop scheduling class modules should be aware that the + * architecture is not frozen and the kernel interface for scheduling + * class modules may change in future releases of System V. Support + * for the current interface is not guaranteed and class modules + * developed to this interface may require changes in order to work + * with future releases of the system. + */ + +/* + * three different ops vectors are bundled together, here. + * one is for each of the fundamental objects acted upon + * by these operators: procs, threads, and the class manager itself. + */ + +typedef struct class_ops { + int (*cl_admin)(caddr_t, cred_t *); + int (*cl_getclinfo)(void *); + int (*cl_parmsin)(void *); + int (*cl_parmsout)(void *, pc_vaparms_t *); + int (*cl_vaparmsin)(void *, pc_vaparms_t *); + int (*cl_vaparmsout)(void *, pc_vaparms_t *); + int (*cl_getclpri)(pcpri_t *); + int (*cl_alloc)(void **, int); + void (*cl_free)(void *); +} class_ops_t; + +typedef struct thread_ops { + int (*cl_enterclass)(kthread_t *, id_t, void *, cred_t *, void *); + void (*cl_exitclass)(void *); + int (*cl_canexit)(kthread_t *, cred_t *); + int (*cl_fork)(kthread_t *, kthread_t *, void *); + void (*cl_forkret)(kthread_t *, kthread_t *); + void (*cl_parmsget)(kthread_t *, void *); + int (*cl_parmsset)(kthread_t *, void *, id_t, cred_t *); + void (*cl_stop)(kthread_t *, int, int); + void (*cl_exit)(kthread_t *); + void (*cl_active)(kthread_t *); + void (*cl_inactive)(kthread_t *); + pri_t (*cl_swapin)(kthread_t *, int); + pri_t (*cl_swapout)(kthread_t *, int); + void (*cl_trapret)(kthread_t *); + void (*cl_preempt)(kthread_t *); + void (*cl_setrun)(kthread_t *); + void (*cl_sleep)(kthread_t *); + void (*cl_tick)(kthread_t *); + void (*cl_wakeup)(kthread_t *); + int (*cl_donice)(kthread_t *, cred_t *, int, int *); + pri_t (*cl_globpri)(kthread_t *); + void (*cl_set_process_group)(pid_t, pid_t, pid_t); + void (*cl_yield)(kthread_t *); + int (*cl_doprio)(kthread_t *, cred_t *, int, int *); +} thread_ops_t; + +typedef struct classfuncs { + class_ops_t sclass; + thread_ops_t thread; +} classfuncs_t; + +typedef struct sclass { + char *cl_name; /* class name */ + /* class specific initialization function */ + pri_t (*cl_init)(id_t, int, classfuncs_t **); + classfuncs_t *cl_funcs; /* pointer to classfuncs structure */ + krwlock_t *cl_lock; /* class structure read/write lock */ + int cl_count; /* # of threads trying to load class */ +} sclass_t; + +#define STATIC_SCHED (krwlock_t *)0xffffffff +#define LOADABLE_SCHED(s) ((s)->cl_lock != STATIC_SCHED) +#define SCHED_INSTALLED(s) ((s)->cl_funcs != NULL) +#define ALLOCATED_SCHED(s) ((s)->cl_lock != NULL) + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +#define CLASS_KERNEL(cid) ((cid) == syscid || (cid) == sysdccid) + +extern int nclass; /* number of configured scheduling classes */ +extern char *defaultclass; /* default class for newproc'd processes */ +extern struct sclass sclass[]; /* the class table */ +extern kmutex_t class_lock; /* lock protecting class table */ +extern int loaded_classes; /* number of classes loaded */ + +extern pri_t minclsyspri; +extern id_t syscid; /* system scheduling class ID */ +extern id_t sysdccid; /* system duty-cycle scheduling class ID */ +extern id_t defaultcid; /* "default" class id; see dispadmin(8) */ + +extern int alloc_cid(char *, id_t *); +extern int scheduler_load(char *, sclass_t *); +extern int getcid(char *, id_t *); +extern int getcidbyname(char *, id_t *); +extern int parmsin(pcparms_t *, pc_vaparms_t *); +extern int parmsout(pcparms_t *, pc_vaparms_t *); +extern int parmsset(pcparms_t *, kthread_t *); +extern void parmsget(kthread_t *, pcparms_t *); +extern int vaparmsout(char *, pcparms_t *, pc_vaparms_t *, uio_seg_t); + +#endif + +#define CL_ADMIN(clp, uaddr, reqpcredp) \ + (*(clp)->cl_funcs->sclass.cl_admin)(uaddr, reqpcredp) + +#define CL_ENTERCLASS(t, cid, clparmsp, credp, bufp) \ + (sclass[cid].cl_funcs->thread.cl_enterclass) (t, cid, \ + (void *)clparmsp, credp, bufp) + +#define CL_EXITCLASS(cid, clprocp)\ + (sclass[cid].cl_funcs->thread.cl_exitclass) ((void *)clprocp) + +#define CL_CANEXIT(t, cr) (*(t)->t_clfuncs->cl_canexit)(t, cr) + +#define CL_FORK(tp, ct, bufp) (*(tp)->t_clfuncs->cl_fork)(tp, ct, bufp) + +#define CL_FORKRET(t, ct) (*(t)->t_clfuncs->cl_forkret)(t, ct) + +#define CL_GETCLINFO(clp, clinfop) \ + (*(clp)->cl_funcs->sclass.cl_getclinfo)((void *)clinfop) + +#define CL_GETCLPRI(clp, clprip) \ + (*(clp)->cl_funcs->sclass.cl_getclpri)(clprip) + +#define CL_PARMSGET(t, clparmsp) \ + (*(t)->t_clfuncs->cl_parmsget)(t, (void *)clparmsp) + +#define CL_PARMSIN(clp, clparmsp) \ + (clp)->cl_funcs->sclass.cl_parmsin((void *)clparmsp) + +#define CL_PARMSOUT(clp, clparmsp, vaparmsp) \ + (clp)->cl_funcs->sclass.cl_parmsout((void *)clparmsp, vaparmsp) + +#define CL_VAPARMSIN(clp, clparmsp, vaparmsp) \ + (clp)->cl_funcs->sclass.cl_vaparmsin((void *)clparmsp, vaparmsp) + +#define CL_VAPARMSOUT(clp, clparmsp, vaparmsp) \ + (clp)->cl_funcs->sclass.cl_vaparmsout((void *)clparmsp, vaparmsp) + +#define CL_PARMSSET(t, clparmsp, cid, curpcredp) \ + (*(t)->t_clfuncs->cl_parmsset)(t, (void *)clparmsp, cid, curpcredp) + +#define CL_PREEMPT(tp) (*(tp)->t_clfuncs->cl_preempt)(tp) + +#define CL_SETRUN(tp) (*(tp)->t_clfuncs->cl_setrun)(tp) + +#define CL_SLEEP(tp) (*(tp)->t_clfuncs->cl_sleep)(tp) + +#define CL_STOP(t, why, what) (*(t)->t_clfuncs->cl_stop)(t, why, what) + +#define CL_EXIT(t) (*(t)->t_clfuncs->cl_exit)(t) + +#define CL_ACTIVE(t) (*(t)->t_clfuncs->cl_active)(t) + +#define CL_INACTIVE(t) (*(t)->t_clfuncs->cl_inactive)(t) + +#define CL_SWAPIN(t, flags) (*(t)->t_clfuncs->cl_swapin)(t, flags) + +#define CL_SWAPOUT(t, flags) (*(t)->t_clfuncs->cl_swapout)(t, flags) + +#define CL_TICK(t) (*(t)->t_clfuncs->cl_tick)(t) + +#define CL_TRAPRET(t) (*(t)->t_clfuncs->cl_trapret)(t) + +#define CL_WAKEUP(t) (*(t)->t_clfuncs->cl_wakeup)(t) + +#define CL_DONICE(t, cr, inc, ret) \ + (*(t)->t_clfuncs->cl_donice)(t, cr, inc, ret) + +#define CL_DOPRIO(t, cr, inc, ret) \ + (*(t)->t_clfuncs->cl_doprio)(t, cr, inc, ret) + +#define CL_GLOBPRI(t) (*(t)->t_clfuncs->cl_globpri)(t) + +#define CL_SET_PROCESS_GROUP(t, s, b, f) \ + (*(t)->t_clfuncs->cl_set_process_group)(s, b, f) + +#define CL_YIELD(tp) (*(tp)->t_clfuncs->cl_yield)(tp) + +#define CL_ALLOC(pp, cid, flag) \ + (sclass[cid].cl_funcs->sclass.cl_alloc) (pp, flag) + +#define CL_FREE(cid, bufp) (sclass[cid].cl_funcs->sclass.cl_free) (bufp) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CLASS_H */ diff --git a/illumos-x86_64/usr/include/sys/clconf.h b/illumos-x86_64/usr/include/sys/clconf.h new file mode 100644 index 00000000..428ce679 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/clconf.h @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_CLCONF_H +#define _SYS_CLCONF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This header file specifies the interface to access the + * configuration data needed in order to boot and form a cluster. + */ + +/* + * Node identifiers are numbered 1 to clconf_maximum_nodeid(). + * The nodeid zero is used to mean unknown. + */ +#define NODEID_UNKNOWN 0 + +typedef unsigned int nodeid_t; + +#if defined(_KERNEL) + +extern void clconf_init(void); +extern nodeid_t clconf_get_nodeid(void); +extern nodeid_t clconf_maximum_nodeid(void); +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CLCONF_H */ diff --git a/illumos-x86_64/usr/include/sys/cmlb.h b/illumos-x86_64/usr/include/sys/cmlb.h new file mode 100644 index 00000000..23ef49ef --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cmlb.h @@ -0,0 +1,595 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2016 Toomas Soome + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CMLB_H +#define _SYS_CMLB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * structure used for getting phygeom and virtgeom from target driver + */ +typedef struct cmlb_geom { + unsigned int g_ncyl; + unsigned short g_acyl; + unsigned short g_nhead; + unsigned short g_nsect; + unsigned short g_secsize; + diskaddr_t g_capacity; + unsigned short g_intrlv; + unsigned short g_rpm; +} cmlb_geom_t; + + +typedef struct tg_attribute { + int media_is_writable; + int media_is_solid_state; + int media_is_rotational; +} tg_attribute_t; + + + +/* bit definitions for alter_behavior passed to cmlb_attach */ + +#define CMLB_CREATE_ALTSLICE_VTOC_16_DTYPE_DIRECT 0x00000001 +#define CMLB_FAKE_GEOM_LABEL_IOCTLS_VTOC8 0x00000002 +#define CMLB_OFF_BY_ONE 0x00000004 +#define CMLB_FAKE_LABEL_ONE_PARTITION 0x00000008 +#define CMLB_INTERNAL_MINOR_NODES 0x00000010 +#define CMLB_CREATE_P0_MINOR_NODE 0x00000020 + +/* bit definitions of flag passed to cmlb_validate */ +#define CMLB_SILENT 0x00000001 + +/* version for tg_ops */ +#define TG_DK_OPS_VERSION_0 0 +#define TG_DK_OPS_VERSION_1 1 + +/* definitions for cmd passed to tg_rdwr */ +#define TG_READ 0 +#define TG_WRITE 1 + +/* definitions for cmd passed to tg_getinfo */ +#define TG_GETPHYGEOM 1 +#define TG_GETVIRTGEOM 2 +#define TG_GETCAPACITY 3 +#define TG_GETBLOCKSIZE 4 +#define TG_GETATTR 5 + +#if defined(_SUNOS_VTOC_8) + +#define CMLBUNIT_DFT_SHIFT 3 +/* This will support p0 node on sparc */ +#define CMLBUNIT_FORCE_P0_SHIFT (CMLBUNIT_DFT_SHIFT + 1) + +#elif defined(_SUNOS_VTOC_16) + +#define CMLBUNIT_DFT_SHIFT 6 +#define CMLBUNIT_FORCE_P0_SHIFT (CMLBUNIT_DFT_SHIFT) + +#else /* defined(_SUNOS_VTOC_16) */ + +#error "No VTOC format defined." + +#endif /* defined(_SUNOS_VTOC_8) */ + +/* + * Ops vector including utility functions into target driver that cmlb uses. + */ +typedef struct cmlb_tg_ops { + int tg_version; + + /* + * tg_rdwr: + * perform read/write on target device associated with devi. + * + * Arguments: + * + * devi: pointer to device's dev_info structure. + * + * cmd: operation to perform. + * Possible values: TG_READ, TG_WRITE + * + * bufp: pointer to allocated buffer for transfer + * + * start_block: starting block number to read/write (based on + * system blocksize, DEV_BSIZE) + * + * reqlength: requested transfer length (in bytes) + * + * tg_cookie cookie from target driver to be passed back to + * target driver when we call back to it through + * tg_ops. + * + * Note: It is the responsibility of caller to make sure + * length of buffer pointed to by bufp is at least equal to + * requested transfer length + * + * Return values: + * 0 success + * ENOMEM can not allocate memory + * EACCESS reservation conflict + * EIO I/O error + * EFAULT copyin/copyout error + * ENXIO internal error/ invalid devi + * EINVAL invalid command value. + */ + int (*tg_rdwr)(dev_info_t *devi, uchar_t cmd, void *bufp, + diskaddr_t start_block, size_t reqlength, void *tg_cookie); + + /* + * tg_getinfo: + * Report the information requested on device/media and + * store the requested info in area pointed to by arg. + * + * Arguments: + * devi: pointer to device's dev_info structure. + * + * cmd: operation to perform + * + * arg: arg for the operation for result. + * + * tg_cookie cookie from target driver to be passed back to + * target driver when we call back to it through + * tg_ops. + * + * Possible commands and the interpretation of arg: + * + * cmd: + * TG_GETPHYGEOM + * Obtain raw physical geometry from target, + * and store in structure pointed to by arg, + * a cmlb_geom_t structure. + * + * TG_GETVIRTGEOM: + * Obtain HBA geometry for the target and + * store in struct pointed to by arg, + * a cmlb_geom_t structure. + * + * TG_GETCAPACITY: + * Report the capacity of the target (in system + * blocksize (DEV_BSIZE) and store in the + * space pointed to by arg, a diskaddr_t. + * + * TG_GETBLOCKSIZE: + * Report the block size of the target + * in the space pointed to by arg, a uint32_t. + * + * TG_GETATTR: + * Report the information requested on + * device/media and store in area pointed to by + * arg, a tg_attribute_t structure. + * Return values: + * + * Return values: + * 0 success + * + * EACCESS reservation conflict + * + * ENXIO internal error/invalid devi + * + * EINVAL When command is TG_GETPHYGEOM or + * TG_GETVIRTGEOM, or TG_GETATTR, this return code + * indicates the operation is not applicable to + * target. + * In case of TG_GETCAP, this return code + * indicates no media in the drive. + * + * EIO An error occurred during obtaining info + * from device/media. + * + * ENOTSUP In case of TG_GETCAP, target does not + * support getting capacity info. + * + * ENOTTY Unknown command. + * + * + */ + int (*tg_getinfo)(dev_info_t *devi, int cmd, void *arg, + void *tg_cookie); + +} cmlb_tg_ops_t; + + +typedef struct __cmlb_handle *cmlb_handle_t; + +/* + * + * Functions exported from cmlb + * + * Note: Most these functions can callback to target driver through the + * tg_ops functions. Target driver should consider this for synchronization. + * Any functions that may adjust minor nodes should be called when + * the target driver ensures it is safe to do so. + */ + +/* + * cmlb_alloc_handle: + * + * Allocates a handle. + * + * Arguments: + * cmlbhandlep pointer to handle + * + * Notes: + * Allocates a handle and stores the allocated handle in the area + * pointed to by cmlbhandlep + * + * Context: + * Kernel thread only (can sleep). + */ +void +cmlb_alloc_handle(cmlb_handle_t *cmlbhandlep); + + +/* + * cmlb_attach: + * + * Attach handle to device, create minor nodes for device. + * + * + * Arguments: + * devi pointer to device's dev_info structure. + * tgopsp pointer to array of functions cmlb can use to callback + * to target driver. + * + * device_type Peripheral device type as defined in + * scsi/generic/inquiry.h + * + * is_removable whether or not device is removable. + * + * is_hotpluggable whether or not device is hotpluggable. + * + * node_type minor node type (as used by ddi_create_minor_node) + * + * alter_behavior + * bit flags: + * + * CMLB_CREATE_ALTSLICE_VTOC_16_DTYPE_DIRECT: create + * an alternate slice for the default label, if + * device type is DTYPE_DIRECT an architectures default + * label type is VTOC16. + * Otherwise alternate slice will no be created. + * + * + * CMLB_FAKE_GEOM_LABEL_IOCTLS_VTOC8: report a default + * geometry and label for DKIOCGGEOM and DKIOCGVTOC + * on architecture with VTOC 8 label types. + * + * CMLB_OFF_BY_ONE: do the workaround for legacy off-by- + * one bug in obtaining capacity (used for sd). + * + * + * cmlbhandle cmlb handle associated with device + * + * tg_cookie cookie from target driver to be passed back to target + * driver when we call back to it through tg_ops. + * + * cmlb does not interpret the values. It is currently + * used for sd to indicate whether retries are allowed + * on commands or not. e.g when cmlb entries are called + * from interrupt context on removable media, sd rather + * not have retries done. + * + * + * + * Notes: + * Assumes a default label based on capacity for non-removable devices. + * If capacity > 1TB, EFI is assumed otherwise VTOC (default VTOC + * for the architecture). + * For removable devices, default label type is assumed to be VTOC + * type. Create minor nodes based on a default label type. + * Label on the media is not validated. + * minor number consists of: + * if _SUNOS_VTOC_8 is defined + * lowest 3 bits is taken as partition number + * the rest is instance number + * if _SUNOS_VTOC_16 is defined + * lowest 6 bits is taken as partition number + * the rest is instance number + * + * + * Return values: + * 0 Success + * ENXIO creating minor nodes failed. + * EINVAL invalid arg, unsupported tg_ops version + * + */ +int +cmlb_attach(dev_info_t *devi, cmlb_tg_ops_t *tgopsp, int device_type, + boolean_t is_removable, boolean_t is_hotpluggable, char *node_type, + int alter_behavior, cmlb_handle_t cmlbhandle, void *tg_cookie); + + +/* + * cmlb_validate: + * + * Validates label. + * + * Arguments + * cmlbhandle cmlb handle associated with device. + * + * int flags + * currently used for verbosity control. + * CMLB_SILENT is the only current definition for it + * tg_cookie cookie from target driver to be passed back to target + * driver when we call back to it through tg_ops. + * Notes: + * If new label type is different from the current, adjust minor nodes + * accordingly. + * + * Return values: + * 0 success + * Note: having fdisk but no solaris partition is assumed + * success. + * + * ENOMEM memory allocation failed + * EIO i/o errors during read or get capacity + * EACCESS reservation conflicts + * EINVAL label was corrupt, or no default label was assumed + * ENXIO invalid handle + * + */ +int +cmlb_validate(cmlb_handle_t cmlbhandle, int flags, void *tg_cookie); + +/* + * cmlb_invalidate: + * Invalidate in core label data + * + * Arguments: + * cmlbhandle cmlb handle associated with device. + * tg_cookie cookie from target driver to be passed back to target + * driver when we call back to it through tg_ops. + */ +void +cmlb_invalidate(cmlb_handle_t cmlbhandle, void *tg_cookie); + + + +/* + * cmlb_is_valid + * Get status on whether the incore label/geom data is valid + * + * Arguments: + * cmlbhandle cmlb handle associated with device. + * + * Return values: + * TRUE if valid + * FALSE otherwise. + * + */ +boolean_t +cmlb_is_valid(cmlb_handle_t cmlbhandle); + +/* + * cmlb_partinfo: + * Get partition info for specified partition number. + * + * Arguments: + * cmlbhandle cmlb handle associated with device. + * part partition number + * driver when we call back to it through tg_ops. + * nblocksp pointer to number of blocks + * startblockp pointer to starting block + * partnamep pointer to name of partition + * tagp pointer to tag info + * tg_cookie cookie from target driver to be passed back to target + * + * Notes: + * If in-core label is not valid, this functions tries to revalidate + * the label. If label is valid, it stores the total number of blocks + * in this partition in the area pointed to by nblocksp, starting + * block number in area pointed to by startblockp, pointer to partition + * name in area pointed to by partnamep, and tag value in area + * pointed by tagp. + * For EFI labels, tag value will be set to 0. + * + * For all nblocksp, startblockp and partnamep, tagp, a value of NULL + * indicates the corresponding info is not requested. + * + * + * Return values: + * 0 success + * EINVAL no valid label or requested partition number is invalid. + * + */ +int +cmlb_partinfo(cmlb_handle_t cmlbhandle, int part, diskaddr_t *nblocksp, + diskaddr_t *startblockp, char **partnamep, uint16_t *tagp, void *tg_cookie); + +/* + * cmlb_efi_label_capacity: + * Get capacity stored in EFI disk label. + * + * Arguments: + * cmlbhandle cmlb handle associated with device. + * capacity pointer to capacity stored in EFI disk label. + * tg_cookie cookie from target driver to be passed back to target + * driver when we call back to it through tg_ops. + * + * + * Notes: + * If in-core label is not valid, this functions tries to revalidate + * the label. If label is valid and is an EFI label, it stores the capacity + * in disk label in the area pointed to by capacity. + * + * + * Return values: + * 0 success + * EINVAL no valid EFI label or capacity is NULL. + * + */ +int +cmlb_efi_label_capacity(cmlb_handle_t cmlbhandle, diskaddr_t *capacity, + void *tg_cookie); + +/* + * cmlb_ioctl: + * Ioctls for label handling will be handled by this function. + * These are: + * DKIOCGGEOM + * DKIOCSGEOM + * DKIOCGAPART + * DKIOCSAPART + * DKIOCGVTOC + * DKIOCGETEFI + * DKIOCPARTITION + * DKIOCSVTOC + * DKIOCSETEFI + * DKIOCGMBOOT + * DKIOCSMBOOT + * DKIOCG_PHYGEOM + * DKIOCG_VIRTGEOM + * DKIOCPARTINFO + * + * + * Arguments: + * cmlbhandle handle associated with device. + * cmd ioctl operation to be performed + * arg user argument, contains data to be set or reference + * parameter for get + * flag bit flag, indicating open settings, 32/64 bit type + * cred_p user credential pointer (not currently used) + * rval_p not currently used + * tg_cookie cookie from target driver to be passed back to target + * driver when we call back to it through tg_ops. + * + * + * + * Return values: + * 0 + * EINVAL + * ENOTTY + * ENXIO + * EIO + * EFAULT + * ENOTSUP + * EPERM + */ +int +cmlb_ioctl(cmlb_handle_t cmlbhandle, dev_t dev, int cmd, + intptr_t arg, int flag, cred_t *cred_p, int *rval_p, void *tg_cookie); + +/* + * cmlb_prop_op: + * provide common label prop_op(9E) implementation that understands the + * size(9p) properties. + * + * Arguments: + * cmlbhandle cmlb handle associated with device. + * dev See prop_op(9E) + * dip " + * prop_op " + * mod_flags " + * name " + * valuep " + * lengthp " + * part partition number + * tg_cookie cookie from target driver to be passed back to target + */ +int +cmlb_prop_op(cmlb_handle_t cmlbhandle, + dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags, + char *name, caddr_t valuep, int *lengthp, int part, void *tg_cookie); + +/* + * cmlb_get_devid_block: + * get the block number where device id is stored. + * + * Arguments: + * cmlbhandle cmlb handle associated with device. + * devidblockp pointer to block number. + * tg_cookie cookie from target driver to be passed back to target + * driver when we call back to it through tg_ops. + * + * Notes: + * It stores the block number of device id in the area pointed to + * by devidblockp. + * + * Return values: + * 0 success + * EINVAL device id does not apply to current label type. + */ +int +cmlb_get_devid_block(cmlb_handle_t cmlbhandle, diskaddr_t *devidblockp, + void *tg_cookie); + + +/* + * cmlb_close: + * + * Close the device, revert to a default label minor node for the device, + * if it is removable. + * + * Arguments: + * cmlbhandle cmlb handle associated with device. + * + * tg_cookie cookie from target driver to be passed back to target + * driver when we call back to it through tg_ops. + * Return values: + * 0 Success + * ENXIO Re-creating minor node failed. + */ +int +cmlb_close(cmlb_handle_t cmlbhandle, void *tg_cookie); + +/* + * cmlb_detach: + * + * Invalidate in-core labeling data and remove all minor nodes for + * the device associate with handle. + * + * Arguments: + * cmlbhandle cmlb handle associated with device. + * tg_cookie cookie from target driver to be passed back to target + * driver when we call back to it through tg_ops. + * + */ +void +cmlb_detach(cmlb_handle_t cmlbhandle, void *tg_cookie); + +/* + * cmlb_free_handle + * + * Frees handle. + * + * Arguments: + * cmlbhandlep pointer to handle + * + */ +void +cmlb_free_handle(cmlb_handle_t *cmlbhandlep); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CMLB_H */ diff --git a/illumos-x86_64/usr/include/sys/cmn_err.h b/illumos-x86_64/usr/include/sys/cmn_err.h new file mode 100644 index 00000000..9ecde567 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cmn_err.h @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _SYS_CMN_ERR_H +#define _SYS_CMN_ERR_H + +#if !defined(_ASM) && (defined(_KERNEL) || defined(_FAKE_KERNEL)) +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Common error handling severity levels */ + +#define CE_CONT 0 /* continuation */ +#define CE_NOTE 1 /* notice */ +#define CE_WARN 2 /* warning */ +#define CE_PANIC 3 /* panic */ +#define CE_IGNORE 4 /* print nothing */ + +#if !defined(_ASM) && (defined(_KERNEL) || defined(_FAKE_KERNEL)) + +/*PRINTFLIKE2*/ +extern void cmn_err(int, const char *, ...) + __KPRINTFLIKE(2); + +extern void vzcmn_err(zoneid_t, int, const char *, __va_list) + __KVPRINTFLIKE(3); + +extern void dev_err(dev_info_t *, int, char *, ...) + __KPRINTFLIKE(3); + +extern void vdev_err(dev_info_t *, int, const char *, __va_list) + __KVPRINTFLIKE(3); + +extern void vcmn_err(int, const char *, __va_list) + __KVPRINTFLIKE(2); + +/*PRINTFLIKE3*/ +extern void zcmn_err(zoneid_t, int, const char *, ...) + __KPRINTFLIKE(3); + +/*PRINTFLIKE1*/ +extern void printf(const char *, ...) + __KPRINTFLIKE(1); + +extern void vzprintf(zoneid_t, const char *, __va_list) + __KVPRINTFLIKE(2); + +/*PRINTFLIKE2*/ +extern void zprintf(zoneid_t, const char *, ...) + __KPRINTFLIKE(2); + +extern void vprintf(const char *, __va_list) + __KVPRINTFLIKE(1); + +/*PRINTFLIKE1*/ +extern void uprintf(const char *, ...) + __KPRINTFLIKE(1); + +extern void vuprintf(const char *, __va_list) + __KVPRINTFLIKE(1); + +/*PRINTFLIKE3*/ +extern size_t snprintf(char *, size_t, const char *, ...) + __KPRINTFLIKE(3); +extern size_t vsnprintf(char *, size_t, const char *, __va_list) + __KVPRINTFLIKE(3); +/*PRINTFLIKE2*/ +extern char *sprintf(char *, const char *, ...) + __KPRINTFLIKE(2); +extern char *vsprintf(char *, const char *, __va_list) + __KVPRINTFLIKE(2); + +/*PRINTFLIKE1*/ +extern void panic(const char *, ...) + __KPRINTFLIKE(1) __NORETURN; + +extern void vpanic(const char *, __va_list) + __KVPRINTFLIKE(1) __NORETURN; + +#endif /* !_ASM && _KERNEL ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CMN_ERR_H */ diff --git a/illumos-x86_64/usr/include/sys/compress.h b/illumos-x86_64/usr/include/sys/compress.h new file mode 100644 index 00000000..6ffedeb7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/compress.h @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_COMPRESS_H +#define _SYS_COMPRESS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern size_t compress(void *, void *, size_t); +extern size_t decompress(void *, void *, size_t, size_t); +extern uint32_t checksum32(void *, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_COMPRESS_H */ diff --git a/illumos-x86_64/usr/include/sys/condvar.h b/illumos-x86_64/usr/include/sys/condvar.h new file mode 100644 index 00000000..ef72c3c5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/condvar.h @@ -0,0 +1,119 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +/* + * condvar.h: + * + * definitions for thread synchronization primitives: condition variables + * This is the public part of the interface to condition variables. The + * private (implementation-specific) part is in /sys/condvar_impl.h. + */ + +#ifndef _SYS_CONDVAR_H +#define _SYS_CONDVAR_H + +#ifndef _ASM +#include +#include +#ifdef _KERNEL +#include +#endif /* _KERNEL */ +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* + * Condtion variables. + */ + +typedef struct _kcondvar { + ushort_t _opaque; +} kcondvar_t; + +typedef enum { + CV_DEFAULT, + CV_DRIVER +} kcv_type_t; + +#if defined(_KERNEL) + +/* + * Time resolution values used in cv_reltimedwait() and cv_reltimedwait_sig() + * to specify how accurately a relative timeout must expire - if it can be + * anticipated or deferred. + */ +typedef enum { + TR_NANOSEC, + TR_MICROSEC, + TR_MILLISEC, + TR_SEC, + TR_CLOCK_TICK, + TR_COUNT +} time_res_t; + +extern time_res_t time_res[]; + +#define TIME_RES_VALID(tr) (tr >= TR_NANOSEC && tr < TR_COUNT) + +/* + * condition variable function prototypes + */ + +extern void cv_init(kcondvar_t *, char *, kcv_type_t, void *); +extern void cv_destroy(kcondvar_t *); +extern void cv_wait(kcondvar_t *, kmutex_t *); +extern void cv_wait_stop(kcondvar_t *, kmutex_t *, int); +extern clock_t cv_timedwait(kcondvar_t *, kmutex_t *, clock_t); +extern clock_t cv_timedwait_hires(kcondvar_t *, kmutex_t *, hrtime_t, hrtime_t, + int); +extern clock_t cv_reltimedwait(kcondvar_t *, kmutex_t *, clock_t, time_res_t); +extern int cv_wait_sig(kcondvar_t *, kmutex_t *); +extern clock_t cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t); +extern int cv_timedwait_sig_hrtime(kcondvar_t *, kmutex_t *, hrtime_t); +extern clock_t cv_reltimedwait_sig(kcondvar_t *, kmutex_t *, clock_t, + time_res_t); +extern int cv_wait_sig_swap(kcondvar_t *, kmutex_t *); +extern int cv_wait_sig_swap_core(kcondvar_t *, kmutex_t *, int *); +extern void cv_signal(kcondvar_t *); +extern void cv_broadcast(kcondvar_t *); +extern int cv_waituntil_sig(kcondvar_t *, kmutex_t *, timestruc_t *, int); + +#endif /* defined(_KERNEL) */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONDVAR_H */ diff --git a/illumos-x86_64/usr/include/sys/condvar_impl.h b/illumos-x86_64/usr/include/sys/condvar_impl.h new file mode 100644 index 00000000..a5b8038b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/condvar_impl.h @@ -0,0 +1,131 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONDVAR_IMPL_H +#define _SYS_CONDVAR_IMPL_H + +/* + * Implementation-private definitions for condition variables + */ + +#ifndef _ASM +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* + * Condtion variables. + */ + +typedef struct _condvar_impl { + ushort_t cv_waiters; +} condvar_impl_t; + +#define CV_HAS_WAITERS(cvp) (((condvar_impl_t *)(cvp))->cv_waiters != 0) + +#endif /* _ASM */ + + +/* + * The cvwaitlock_t structure and associated macros provide an implementation + * of a locking mechanism that allows recursion on the reader lock without + * danger of a pending write lock elsewhere being able to cause a deadlock. + * The provision for supporting recursion is necessary for use with the + * netinfo (neti) kernel module when processing network data. + * + * Support for recursion (giving precedence to readers and allowing them + * to enter even when a write is blocked) can result in write starvation. + * There is no priority inheritence for this locking interface. + */ +typedef struct cvwaitlock_s { + kmutex_t cvw_lock; + kcondvar_t cvw_waiter; + int cvw_refcnt; +} cvwaitlock_t; + + +#define CVW_INIT(_c) { \ + mutex_init(&(_c)->cvw_lock, NULL, MUTEX_DRIVER, NULL); \ + cv_init(&(_c)->cvw_waiter, NULL, CV_DRIVER, NULL); \ + (_c)->cvw_refcnt = 0; \ +} + +#define CVW_ENTER_READ(_c) { \ + mutex_enter(&(_c)->cvw_lock); \ + while ((_c)->cvw_refcnt < 0) \ + cv_wait(&((_c)->cvw_waiter), &(_c)->cvw_lock); \ + (_c)->cvw_refcnt++; \ + mutex_exit(&(_c)->cvw_lock); \ +} + +#define CVW_ENTER_WRITE(_c) { \ + mutex_enter(&(_c)->cvw_lock); \ + while ((_c)->cvw_refcnt != 0) \ + cv_wait(&((_c)->cvw_waiter), &(_c)->cvw_lock); \ + (_c)->cvw_refcnt = -1; \ + mutex_exit(&(_c)->cvw_lock); \ +} + +#define CVW_EXIT_READ(_c) { \ + mutex_enter(&(_c)->cvw_lock); \ + ASSERT((_c)->cvw_refcnt > 0); \ + if ((--((_c)->cvw_refcnt)) == 0) \ + cv_broadcast(&(_c)->cvw_waiter); \ + mutex_exit(&(_c)->cvw_lock); \ +} + +#define CVW_EXIT_WRITE(_c) { \ + mutex_enter(&(_c)->cvw_lock); \ + ASSERT((_c)->cvw_refcnt == -1); \ + (_c)->cvw_refcnt = 0; \ + cv_broadcast(&(_c)->cvw_waiter); \ + mutex_exit(&(_c)->cvw_lock); \ +} + +#define CVW_WRITE_TO_READ(_c) { \ + mutex_enter(&(_c)->cvw_lock); \ + ASSERT((_c)->cvw_refcnt == -1); \ + (_c)->cvw_refcnt = 1; \ + cv_broadcast(&(_c)->cvw_waiter); \ + mutex_exit(&(_c)->cvw_lock); \ +} + +#define CVW_DESTROY(_c) { \ + mutex_destroy(&(_c)->cvw_lock); \ + cv_destroy(&(_c)->cvw_waiter); \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONDVAR_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/conf.h b/illumos-x86_64/usr/include/sys/conf.h new file mode 100644 index 00000000..148104f8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/conf.h @@ -0,0 +1,237 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _SYS_CONF_H +#define _SYS_CONF_H + + +#include + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define FMNAMESZ 8 /* used by struct fmodsw */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * XXX Given that drivers need to include this file, + * probably shouldn't be here, as + * it legitimizes (aka provides prototypes for) + * all sorts of functions that aren't in the DKI/SunDDI + */ +#include +#include + +#endif /* _KERNEL || _FAKE_KERNEL */ +#ifdef _KERNEL + +#include +#include +#include +#include +#include +#include +#include + +typedef struct fmodsw { + char f_name[FMNAMESZ + 1]; + struct streamtab *f_str; + int f_flag; +} fmodsw_t; + +extern struct dev_ops **devopsp; +extern int devcnt; + +/* + * Return streams information for the driver specified by major number or + * NULL if device cb_ops structure is not present. + */ +#define STREAMSTAB(maj) (devopsp[(maj)] == NULL ? NULL : \ + (devopsp[(maj)]->devo_cb_ops == NULL ? \ + NULL : \ + devopsp[(maj)]->devo_cb_ops->cb_str)) +#define CBFLAG(maj) (devopsp[(maj)]->devo_cb_ops->cb_flag) + +extern int devi_identify(dev_info_t *); +extern int devi_probe(dev_info_t *); +extern int devi_attach(dev_info_t *, ddi_attach_cmd_t); +extern int devi_detach(dev_info_t *, ddi_detach_cmd_t); +extern int devi_reset(dev_info_t *, ddi_reset_cmd_t); +extern int devi_quiesce(dev_info_t *); + +/* + * The following [cb]dev_* functions are not part of the DDI, use + * defined interfaces instead. + */ +extern int dev_open(dev_t *, int, int, cred_t *); +extern int dev_lopen(dev_t *, int, int, cred_t *); +extern int dev_close(dev_t, int, int, cred_t *); +extern int dev_lclose(dev_t, int, int, cred_t *); + +extern int dev_to_instance(dev_t); + +extern int bdev_strategy(struct buf *); +extern int bdev_print(dev_t, caddr_t); +extern int bdev_dump(dev_t, caddr_t, daddr_t, int); +extern int bdev_size(dev_t); +extern uint64_t bdev_Size(dev_t); + +extern int cdev_read(dev_t, struct uio *, cred_t *); +extern int cdev_write(dev_t, struct uio *, cred_t *); +extern int cdev_size(dev_t); +extern uint64_t cdev_Size(dev_t); +extern int cdev_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); +extern int cdev_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, + size_t len, size_t *maplen, uint_t model); +extern int cdev_mmap(int (*)(dev_t, off_t, int), + dev_t, off_t, int); +extern int cdev_segmap(dev_t, off_t, struct as *, caddr_t *, + off_t, uint_t, uint_t, uint_t, cred_t *); +extern int cdev_poll(dev_t, short, int, short *, struct pollhead **); +extern int cdev_prop_op(dev_t, dev_info_t *, ddi_prop_op_t, + int, char *, caddr_t, int *); + +#endif /* _KERNEL */ + + +/* + * Device flags. + * + * Bit 0 to bit 15 are reserved for kernel. + * Bit 16 to bit 31 are reserved for different machines. + */ + +#define D_NEW 0x00 /* new-style driver */ +#define _D_OLD 0x01 /* old-style driver (obsolete) */ +#define D_TAPE 0x08 /* Magtape device (no bdwrite when cooked) */ + +/* + * MT-safety level (in DDI portion of flags). + * + * All drivers must be MT-safe, and must advertise this by specifying D_MP. + * + * The remainder of the flags apply only to STREAMS modules and drivers. + * + * A STREAMS driver or module can optionally select inner and outer perimeters. + * The four mutually exclusive options that define the presence and scope + * of the inner perimeter are: + * D_MTPERMOD - per module single threaded. + * D_MTQPAIR - per queue-pair single threaded. + * D_MTPERQ - per queue instance single threaded. + * (none of the above) - no inner perimeter restricting concurrency + * + * The presence of the outer perimeter is declared with: + * D_MTOUTPERIM - a per-module outer perimeter. Can be combined with + * D_MTPERQ, D_MTQPAIR, and D_MP. + * + * The concurrency when entering the different STREAMS entry points can be + * modified with: + * D_MTPUTSHARED - modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD + * specifying that the put procedures should not be + * single-threaded at the inner perimeter. + * _D_MTOCSHARED - EXPERIMENTAL - will be removed in a future release. + * Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD + * specifying that the open and close procedures should not be + * single-threaded at the inner perimeter. + * _D_MTCBSHARED - EXPERIMENTAL - will be removed in a future release. + * Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD + * specifying that the callback i.e qtimeout() procedures should + * not be single-threaded at the inner perimeter. + * _D_MTSVCSHARED - EXPERIMENTAL - will be removed in a future release. + * Modifier for D_MTPERMOD only. Specifies that the service + * procedure should not be single-threaded at the inner perimeter. + * However only a single instance of the service thread can run on + * any given queue. + * D_MTOCEXCL - modifier for D_MTOUTPERIM specifying that the open and + * close procedures should be single-threaded at the outer + * perimeter. + */ +#define D_MTSAFE 0x0020 /* multi-threaded module or driver */ +#define _D_QNEXTLESS 0x0040 /* Unused, retained for source compatibility */ +#define _D_MTOCSHARED 0x0080 /* modify: open/close procedures are hot */ +/* 0x100 - see below */ +/* 0x200 - see below */ +/* 0x400 - see below */ +#define D_MTOCEXCL 0x0800 /* modify: open/close are exclusive at outer */ +#define D_MTPUTSHARED 0x1000 /* modify: put procedures are hot */ +#define D_MTPERQ 0x2000 /* per queue instance single-threaded */ +#define D_MTQPAIR 0x4000 /* per queue-pair instance single-threaded */ +#define D_MTPERMOD 0x6000 /* per module single-threaded */ +#define D_MTOUTPERIM 0x8000 /* r/w outer perimeter around whole modules */ +#define _D_MTCBSHARED 0x10000 /* modify : callback procedures are hot */ +#define _D_MTSVCSHARED 0x20000 /* modify : service procedures are hot */ + +/* The inner perimeter scope bits */ +#define D_MTINNER_MASK (D_MP|D_MTPERQ|D_MTQPAIR|D_MTPERMOD) + +/* Inner perimeter modification bits */ +#define D_MTINNER_MOD (D_MTPUTSHARED|_D_MTOCSHARED|_D_MTCBSHARED| \ + _D_MTSVCSHARED) + +/* Outer perimeter modification bits */ +#define D_MTOUTER_MOD (D_MTOCEXCL) + +/* All the MT flags */ +#define D_MTSAFETY_MASK (D_MTINNER_MASK|D_MTOUTPERIM|D_MTPUTSHARED|\ + D_MTINNER_MOD|D_MTOUTER_MOD) + +#define D_MP D_MTSAFE /* ddi/dki approved flag */ + +#define D_64BIT 0x200 /* Driver supports 64-bit offsets, blk nos. */ + +#define D_SYNCSTR 0x400 /* Module or driver has Synchronous STREAMS */ + /* extended qinit structure */ + +#define D_DEVMAP 0x100 /* Use devmap framework to mmap device */ + +#define D_HOTPLUG 0x4 /* Driver is hotplug capable */ + +#define D_U64BIT 0x40000 /* Driver supports unsigned 64-bit uio offset */ + +#define _D_DIRECT 0x80000 /* Private flag for transport modules */ + +#define D_OPEN_RETURNS_EINTR 0x100000 /* EINTR expected from open(9E) */ + +#define _D_SINGLE_INSTANCE 0x200000 /* Module may only be pushed once */ + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONF_H */ diff --git a/illumos-x86_64/usr/include/sys/consdev.h b/illumos-x86_64/usr/include/sys/consdev.h new file mode 100644 index 00000000..ee145a16 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/consdev.h @@ -0,0 +1,232 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONSDEV_H +#define _SYS_CONSDEV_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#if defined(_KERNEL) || defined(_KMDB) + +/* + * Paths to console devices + */ +#define CONSKBD_PATH "/pseudo/conskbd@0:conskbd" +#define CONSMS_PATH "/pseudo/consms@0:mouse" +#define WC_PATH "/pseudo/wc@0:wscons" +#define IWSCN_PATH "/pseudo/iwscn@0:iwscn" +#define CVC_PATH "/pseudo/cvc@0:cvc" + +/* + * Console redirection. + */ +extern dev_t rconsdev; /* real (underlying) console */ +extern struct vnode *rconsvp; /* pointer to vnode for that device */ + +/* + * Virtual Serial Console redirection. + */ +extern struct vnode *vsconsvp; /* pointer to vnode for virtual console */ + +/* + * Mouse, keyboard, and frame buffer configuration information. + * + * XXX: Assumes a single mouse/keyboard/frame buffer triple. + */ +extern dev_t mousedev; /* default mouse device */ +extern dev_t kbddev; /* default (actual) keyboard device */ +extern dev_t stdindev; /* default standard input device */ +extern dev_t fbdev; /* default framebuffer device */ +extern struct vnode *fbvp; /* pointer to vnode for that device */ +extern dev_info_t *fbdip; /* pointer to dev_info for fbdev (optional) */ +extern dev_t diagdev; /* default diag device (optional) */ + +extern int consmode; /* CONS_FW or CONS_KFB */ +extern int cons_tem_disable; +#define CONS_FW 0 +#define CONS_KFB 1 + +/* + * Workstation console redirection. + * + * The workstation console device is the multiplexor that hooks keyboard and + * frame buffer together into a single tty-like device. Access to it is + * through the redirecting driver, so that frame buffer output can be + * redirected to other devices. wsconsvp names the redirecting access point, + * and rwsconsvp names the workstation console itself. + * + * XXX: Assumes a single workstation console. + */ +extern struct vnode *wsconsvp; /* vnode for redirecting ws cons access */ +extern struct vnode *rwsconsvp; /* vnode for underlying workstation console */ + +/* + * Generic console ioctls. + * + * On systems without OBP, all potential console devices should implement these. + * + * On systems with OBP, all potential console devices should implement + * the ABORTENABLE ioctls. All potential console devices that cannot share + * their hardware with OBP should implement the POLLEDIO ioctls. + */ +#define _CONSIOC (('C'<<24)|('O'<<16)|('N'<<8)) + +/* + * Get the structure of function pointers to be used for polled I/O + * + * struct cons_polledio *polledio; + * struct strioctl str; + * + * str.ic_cmd = CONS_OPENPOLLEDIO; + * str.ic_timout = INFTIM; + * str.ic_len = sizeof (polledio); + * str.ic_dp = (char *)&polledio; + * ioctl(fd, I_STR, &str); + */ +#define CONSOPENPOLLEDIO (_CONSIOC|0) + +/* + * Get the current state of abort enable + * enable = ioctl(fd, CONSGETABORTENABLE, 0) + */ +#define CONSGETABORTENABLE (_CONSIOC|1) + +/* + * Set the current state of abort enable + * ioctl(fd, CONSSETABORTENABLE, boolean_t) + */ +#define CONSSETABORTENABLE (_CONSIOC|2) + +/* + * Undo anything that was done with CONSOPENPOLLEDIO + * ioctl(fd, CONSCLOSEPOLLEDIO, 0) + */ +#define CONSCLOSEPOLLEDIO (_CONSIOC|3) + +/* + * Set the type simulated by hardwares + * ioctl(fd, CONSSETKBDTYPE, kbdtype) + * kbdtype: + * KB_PC or KB_USB + */ +#define CONSSETKBDTYPE (_CONSIOC|4) + +#define CONSPOLLEDIO_V0 0 +#define CONSPOLLEDIO_V1 1 + +typedef int kbtrans_key_t; + +enum keystate { KEY_PRESSED = 0, KEY_RELEASED = 1 }; + + +/* + * Opaque state structure for driver state. Each driver has its own + * implementation (with different names!), and casts to/from this. + * This allows better type-checking than "void *", helping to ensure + * that the structure passed in is the structure used in the callback. + */ +typedef struct __cons_polledio_arg *cons_polledio_arg_t; + +/* + * This is the structure that is used to handle polled I/O. It is filled + * in by a lower driver, passed up, and eventually registered with the + * debugger that needs to do polled I/O. + */ +typedef struct cons_polledio { + + /* + * version of this structure + */ + unsigned cons_polledio_version; + + /* + * Argument that is passed to the following routines. + */ + cons_polledio_arg_t cons_polledio_argument; + + /* + * Pointer to the routine and its argument that handles putting + * characters out to the polled device. + */ + void (*cons_polledio_putchar)(cons_polledio_arg_t, + uchar_t); + + /* + * Pointer to the routine and its argument that handles getting + * characters from the polled device. This routine is blocking. + */ + int (*cons_polledio_getchar)(cons_polledio_arg_t); + + /* + * Pointer to the routine and its argument that checks to see + * if a character is pending input. This routine is non-blocking. + */ + boolean_t (*cons_polledio_ischar)(cons_polledio_arg_t); + + /* + * Initialize the polled subsystem. This routine is called once + * per mode change from non-polled to polled mode. + */ + void (*cons_polledio_enter)(cons_polledio_arg_t); + + /* + * Restore the non-polled subsystem. This routine is called once + * per mode change from non-polled to polled mode. + */ + void (*cons_polledio_exit)(cons_polledio_arg_t); + + + /* Routine to set the LED's in polled mode */ + void (*cons_polledio_setled)(cons_polledio_arg_t, int); + + /* Routine to indicate that a scande is available in polled mode */ + boolean_t (*cons_polledio_keycheck)( + cons_polledio_arg_t, + kbtrans_key_t *, enum keystate *); +} cons_polledio_t; + +extern cons_polledio_t *cons_polledio; + +/* + * Workstation Console + */ +#define _WCIOC (('W'<<24)|('C'<<16)) +#define WC_OPEN_FB (_WCIOC | 0) +#define WC_CLOSE_FB (_WCIOC | 1) + +#endif /* _KERNEL || _KMDB */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONSDEV_H */ diff --git a/illumos-x86_64/usr/include/sys/console.h b/illumos-x86_64/usr/include/sys/console.h new file mode 100644 index 00000000..892f7e5b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/console.h @@ -0,0 +1,93 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONSOLE_H +#define _SYS_CONSOLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Sun private interface for cn driver + */ +#define _CNIOC (('C'<<24)|('N'<<16)) +#define _CNIOC_MASK (~0xffff) +#define CONS_GETTERM (_CNIOC | 0) +#define CONS_GETDEV (_CNIOC | 1) + +#define MAX_TERM_TYPE_LEN 10 + +struct cons_getterm { + uint_t cn_term_len; + char *cn_term_type; +}; + +struct cons_getdev { + dev_t cnd_rconsdev; +}; + +#ifdef _KERNEL + +#include +#include +#include + +#ifdef _SYSCALL32 +struct cons_getterm32 { + uint32_t cn_term_len; + caddr32_t cn_term_type; +}; + +struct cons_getdev32 { + dev32_t cnd_rconsdev; +}; +#endif /* _SYSCALL32 */ + +extern void console_get_size(ushort_t *r, ushort_t *c, + ushort_t *x, ushort_t *y); +/*PRINTFLIKE1*/ +extern void console_printf(const char *, ...) __KPRINTFLIKE(1); +extern void console_vprintf(const char *, va_list) __KVPRINTFLIKE(1); + +extern void console_puts(const char *, size_t); + +extern void console_gets(char *, size_t); +extern int console_getc(void); + +extern int console_enter(int); +extern void console_exit(int, int); + +extern vnode_t *console_vnode; +extern taskq_t *console_taskq; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONSOLE_H */ diff --git a/illumos-x86_64/usr/include/sys/consplat.h b/illumos-x86_64/usr/include/sys/consplat.h new file mode 100644 index 00000000..d602c087 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/consplat.h @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONSPLAT_H +#define _SYS_CONSPLAT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int plat_use_polled_debug(void); +extern int plat_support_serial_kbd_and_ms(void); +extern char *plat_kbdpath(void); +extern char *plat_fbpath(void); +extern char *plat_mousepath(void); +extern char *plat_stdinpath(void); +extern char *plat_stdoutpath(void); +extern char *plat_diagpath(void); +extern int plat_stdin_is_keyboard(void); +extern int plat_stdout_is_framebuffer(void); +extern void plat_tem_get_colors(uint8_t *, uint8_t *); +extern void plat_tem_get_inverses(int *, int *); +extern void plat_tem_get_prom_font_size(int *, int *); +extern void plat_tem_get_prom_size(size_t *, size_t *); +extern void plat_tem_hide_prom_cursor(void); +extern void plat_tem_get_prom_pos(uint32_t *, uint32_t *); +extern int plat_virtual_console_path(char **); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONSPLAT_H */ diff --git a/illumos-x86_64/usr/include/sys/containerof.h b/illumos-x86_64/usr/include/sys/containerof.h new file mode 100644 index 00000000..89fddd39 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/containerof.h @@ -0,0 +1,59 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 Toomas Soome + */ + +#ifndef _SYS_CONTAINEROF_H +#define _SYS_CONTAINEROF_H + +/* + * __containerof macro for private use in illumos. + * + * __containerof(ptr, type, member) will return pointer to the data + * structure of given type, calculated based on the offset of 'member' + * in the structure 'type'. + * + * For this macro to work, we should be certain of the pointer type. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__containerof) + +/* + * The extension to support statements and declarations in expressions, + * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html, is available + * in gcc >= 3.1. + * We perform the assignment below to try and provide additional type safety. + */ +#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#define __containerof(m, s, name) ( \ +{ \ + const volatile __typeof(((s *)0)->name) *__m = (m); \ + (void *)((uintptr_t)__m - (uintptr_t)offsetof(s, name)); \ +}) +#else +#define __containerof(m, s, name) \ + (void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name)) +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONTAINEROF_H */ diff --git a/illumos-x86_64/usr/include/sys/contract.h b/illumos-x86_64/usr/include/sys/contract.h new file mode 100644 index 00000000..0e81f8ff --- /dev/null +++ b/illumos-x86_64/usr/include/sys/contract.h @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONTRACT_H +#define _SYS_CONTRACT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint64_t ctevid_t; + +/* + * Contract parameter maximum size, in bytes + */ +#define CT_PARAM_MAX_SIZE 8192 + +/* + * Common event types + */ +#define CT_EV_NEGEND 0 + +/* + * Level of status detail requested + */ +#define CTD_COMMON 0 /* No additional detail */ +#define CTD_FIXED 1 /* O(1) info */ +#define CTD_ALL 2 /* O(n) info */ + +/* + * Values for ctev_flags. + */ +#define CTE_ACK 0x1 +#define CTE_INFO 0x2 +#define CTE_NEG 0x4 + +#define CTP_EV_CRITICAL 100 +#define CTP_EV_INFO 101 +#define CTP_COOKIE 102 + +#define CTS_NEWCT "cts_newct" +#define CTS_NEVID "cts_nevid" + +typedef enum ctstate { + CTS_OWNED, /* contract is owned by a process */ + CTS_INHERITED, /* contract has been inherited by its parent */ + CTS_ORPHAN, /* contract has no parent */ + CTS_DEAD /* contract has been destroyed */ +} ctstate_t; + +typedef enum ct_typeid { + CTT_PROCESS, /* process contract */ + CTT_DEVICE, /* device contract */ + CTT_MAXTYPE +} ct_typeid_t; + +typedef struct ct_event { + ctid_t ctev_id; + uint32_t ctev_pad1; + ctevid_t ctev_evid; + ct_typeid_t ctev_cttype; + uint32_t ctev_flags; + uint32_t ctev_type; + uint32_t ctev_nbytes; + uint32_t ctev_goffset; + uint32_t ctev_pad2; + char *ctev_buffer; +} ct_event_t; + +typedef struct ct_status { + ctid_t ctst_id; + zoneid_t ctst_zoneid; + ct_typeid_t ctst_type; + pid_t ctst_holder; + ctstate_t ctst_state; + int ctst_nevents; + int ctst_ntime; + int ctst_qtime; + uint64_t ctst_nevid; + uint_t ctst_detail; + size_t ctst_nbytes; + uint_t ctst_critical; + uint_t ctst_informative; + uint64_t ctst_cookie; + char *ctst_buffer; +} ct_status_t; + +typedef struct ct_param { + uint32_t ctpm_id; + uint32_t ctpm_size; + void *ctpm_value; +} ct_param_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONTRACT_H */ diff --git a/illumos-x86_64/usr/include/sys/contract/device.h b/illumos-x86_64/usr/include/sys/contract/device.h new file mode 100644 index 00000000..aaa702c3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/contract/device.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONTRACT_DEVICE_H +#define _SYS_CONTRACT_DEVICE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ctmpl_device ctmpl_device_t; +typedef struct cont_device cont_device_t; + +/* + * ct_ev_* flags + */ +#define CT_DEV_EV_ONLINE 0x1 /* device is moving to online state */ +#define CT_DEV_EV_DEGRADED 0x2 /* device is moving to degraded state */ +#define CT_DEV_EV_OFFLINE 0x4 /* device is moving to offline state */ +#define CT_DEV_ALLEVENT 0x7 + +/* + * ctp_id values + */ +#define CTDP_ACCEPT 0x1 /* the acceptable set term */ +#define CTDP_NONEG 0x2 /* the non-negotiable term */ +#define CTDP_MINOR 0x4 /* the minor path term */ +#define CTDP_ALLPARAMS 0x7 + +#define CTDP_NONEG_CLEAR 0x0 /* clear the noneg flag */ +#define CTDP_NONEG_SET 0x1 /* set noneg */ + +/* + * Status fields + */ +#define CTDS_STATE "ctds_state" +#define CTDS_ASET "ctds_aset" +#define CTDS_NONEG "ctds_noneg" +#define CTDS_MINOR "ctds_minor" + +/* + * Max Time allowed for synchronous acknowledgement of a negotiation event + */ +#define CT_DEV_ACKTIME 60 /* 60 seconds */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONTRACT_DEVICE_H */ diff --git a/illumos-x86_64/usr/include/sys/contract/device_impl.h b/illumos-x86_64/usr/include/sys/contract/device_impl.h new file mode 100644 index 00000000..cfc45c4a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/contract/device_impl.h @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONTRACT_DEVICE_IMPL_H +#define _SYS_CONTRACT_DEVICE_IMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Result of negotiation end: event successfully occurred or not + */ +#define CT_EV_SUCCESS 150 +#define CT_EV_FAILURE 151 + +struct ctmpl_device { + ct_template_t ctd_ctmpl; + uint_t ctd_aset; + uint_t ctd_noneg; + char *ctd_minor; +}; + +struct cont_device { + contract_t cond_contract; /* common contract data */ + char *cond_minor; /* minor node resource in contract */ + dev_info_t *cond_dip; /* dip for minor node */ + dev_t cond_devt; /* dev_t of minor node */ + uint_t cond_spec; /* spec type of minor node */ + uint_t cond_aset; /* acceptable state set */ + uint_t cond_noneg; /* no negotiation if set */ + uint_t cond_state; /* current state of device */ + uint_t cond_neg; /* contract undergoing negotiation */ + uint64_t cond_currev_id; /* id of event being negotiated */ + uint_t cond_currev_type; /* type of event being negotiated */ + uint_t cond_currev_ack; /* ack/nack status of ev negotiation */ + list_node_t cond_next; /* linkage - devinfo's contracts */ +}; + +/* + * Kernel APIs + */ +extern ct_type_t *device_type; +/* + * struct proc; + */ +void contract_device_init(void); +ct_ack_t contract_device_offline(dev_info_t *dip, dev_t dev, int spec_type); +void contract_device_degrade(dev_info_t *dip, dev_t dev, int spec_type); +void contract_device_undegrade(dev_info_t *dip, dev_t dev, int spec_type); +int contract_device_open(dev_t dev, int spec_type, contract_t **ctpp); +void contract_device_remove_dip(dev_info_t *dip); +ct_ack_t contract_device_negotiate(dev_info_t *dip, dev_t dev, int spec_type, + uint_t evtype); +void contract_device_finalize(dev_info_t *dip, dev_t dev, int spec_type, + uint_t evtype, int ct_result); +void contract_device_negend(dev_info_t *dip, dev_t dev, int spec_type, + int result); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONTRACT_DEVICE_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/contract/process.h b/illumos-x86_64/usr/include/sys/contract/process.h new file mode 100644 index 00000000..2c70d7c9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/contract/process.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. + */ + +#ifndef _SYS_CONTRACT_PROCESS_H +#define _SYS_CONTRACT_PROCESS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ctmpl_process ctmpl_process_t; +typedef struct cont_process cont_process_t; + +/* + * Default value for FMRI terms + */ +#define CT_PR_SVC_DEFAULT "inherit:" + +/* + * zone_enter() pseudo-FMRI + */ +#define CT_PR_SVC_FMRI_ZONE_ENTER "svc:/system/zone_enter:default" + +/* + * ctr_params flags + */ +#define CT_PR_INHERIT 0x1 /* give contract to parent */ +#define CT_PR_NOORPHAN 0x2 /* kill when contract is abandoned */ +#define CT_PR_PGRPONLY 0x4 /* only kill process group on fatal errors */ +#define CT_PR_REGENT 0x8 /* automatically detach inherited contracts */ +#define CT_PR_KEEP_EXEC 0x10 /* preserve template accross exec */ +#define CT_PR_ALLPARAM 0x1f + +/* + * ctr_ev_* flags + */ +#define CT_PR_EV_EMPTY 0x1 /* contract is empty */ +#define CT_PR_EV_FORK 0x2 /* process was forked (and was added) */ +#define CT_PR_EV_EXIT 0x4 /* process exited (and left contract) */ +#define CT_PR_EV_CORE 0x8 /* process dumps core */ +#define CT_PR_EV_SIGNAL 0x10 /* process received fatal signal */ +#define CT_PR_EV_HWERR 0x20 /* process experienced uncorrectable error */ +#define CT_PR_ALLEVENT 0x3f +#define CT_PR_ALLFATAL (CT_PR_EV_CORE | CT_PR_EV_SIGNAL | CT_PR_EV_HWERR) + +/* + * ctp_id values + */ +#define CTPP_EV_FATAL 0 +#define CTPP_PARAMS 1 +#define CTPP_SUBSUME 2 +#define CTPP_SVC_FMRI 3 +#define CTPP_SVC_CTID 4 +#define CTPP_SVC_CREATOR 5 +#define CTPP_CREATOR_AUX 6 + +/* + * Status fields + */ +#define CTPS_PARAMS "ctps_params" +#define CTPS_EV_FATAL "ctps_ev_fatal" +#define CTPS_MEMBERS "ctps_members" +#define CTPS_CONTRACTS "ctps_contracts" +#define CTPS_SVC_FMRI "ctps_svc_fmri" +#define CTPS_SVC_CTID "ctps_svc_ctid" +#define CTPS_SVC_CREATOR "ctps_svc_creator" +#define CTPS_CREATOR_AUX "ctps_creator_aux" + +/* + * Event fields + */ +#define CTPE_PID "ctpe_pid" +#define CTPE_PPID "ctpe_ppid" +#define CTPE_ZCOREFILE "ctpe_zcorefile" +#define CTPE_GCOREFILE "ctpe_gcorefile" +#define CTPE_PCOREFILE "ctpe_pcorefile" +#define CTPE_SIGNAL "ctpe_signal" +#define CTPE_SENDER "ctpe_sender" +#define CTPE_SENDCT "ctpe_sendct" +#define CTPE_EXITSTATUS "ctpe_exitstatus" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONTRACT_PROCESS_H */ diff --git a/illumos-x86_64/usr/include/sys/contract/process_impl.h b/illumos-x86_64/usr/include/sys/contract/process_impl.h new file mode 100644 index 00000000..a0843b2d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/contract/process_impl.h @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONTRACT_PROCESS_IMPL_H +#define _SYS_CONTRACT_PROCESS_IMPL_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PRCTID(pp) \ + ((pp)->p_ct_process ? (pp)->p_ct_process->conp_contract.ct_id : 0) + +struct ctmpl_process { + ct_template_t ctp_ctmpl; + contract_t *ctp_subsume; + uint_t ctp_params; + uint_t ctp_ev_fatal; + refstr_t *ctp_svc_fmri; /* Service FMRI */ + refstr_t *ctp_svc_aux; /* Creator Auxiliary field */ +}; + +struct cont_process { + contract_t conp_contract; /* common contract data */ + cred_t *conp_cred; + list_t conp_members; /* member processes */ + list_t conp_inherited; /* unclaimed child contracts */ + uint_t conp_params; /* contract parameters */ + uint_t conp_ev_fatal; /* events to kill on */ + uint_t conp_nmembers; + uint_t conp_ninherited; + refstr_t *conp_svc_fmri; /* Service FMRI */ + ctid_t conp_svc_ctid; /* Service FMRI creator ctid */ + refstr_t *conp_svc_creator; /* contract creator */ + refstr_t *conp_svc_aux; /* Creator Auxiliary field */ + ctid_t conp_svc_zone_enter; /* zone_enter flag */ + /* requires ct_lock for */ + /* access */ +}; + +/* + * Kernel APIs + */ +extern ctmpl_process_t *sys_process_tmpl; +extern ct_type_t *process_type; + +struct proc; +void contract_process_init(void); +cont_process_t *contract_process_fork(ctmpl_process_t *, struct proc *, + struct proc *, int); +void contract_process_exit(cont_process_t *, struct proc *, int); +void contract_process_core(cont_process_t *, struct proc *, int, + const char *, const char *, const char *); +void contract_process_hwerr(cont_process_t *, struct proc *); +void contract_process_sig(cont_process_t *, struct proc *, int, pid_t, ctid_t, + zoneid_t); +void contract_process_take(contract_t *, contract_t *); +int contract_process_accept(contract_t *); +void contract_process_adopt(contract_t *, proc_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONTRACT_PROCESS_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/contract_impl.h b/illumos-x86_64/usr/include/sys/contract_impl.h new file mode 100644 index 00000000..704ff126 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/contract_impl.h @@ -0,0 +1,410 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CONTRACT_IMPL_H +#define _SYS_CONTRACT_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int ct_debug; + +#define CT_DEBUG(args) if (ct_debug) cmn_err args + +#ifdef _SYSCALL32 + +/* + * 32-bit versions of the event, status and parameter structures, for use + * (only) by the 64-bit kernel. See sys/contract.h for the normal versions. + * Use pack(4) to get offsets and structure size correct on amd64. + */ + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct ct_event32 { + ctid_t ctev_id; + uint32_t ctev_pad1; + ctevid_t ctev_evid; + ct_typeid_t ctev_cttype; + uint32_t ctev_flags; + uint32_t ctev_type; + uint32_t ctev_nbytes; + uint32_t ctev_goffset; + uint32_t ctev_pad2; + caddr32_t ctev_buffer; +} ct_event32_t; + +typedef struct ct_status32 { + ctid_t ctst_id; + zoneid_t ctst_zoneid; + ct_typeid_t ctst_type; + pid_t ctst_holder; + ctstate_t ctst_state; + int ctst_nevents; + int ctst_ntime; + int ctst_qtime; + uint64_t ctst_nevid; + uint_t ctst_detail; + uint_t ctst_nbytes; + uint_t ctst_critical; + uint_t ctst_informative; + uint64_t ctst_cookie; + caddr32_t ctst_buffer; +} ct_status32_t; + +typedef struct ct_param32 { + uint32_t ctpm_id; + uint32_t ctpm_size; + caddr32_t ctpm_value; +} ct_param32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ + +/* + * in kernel version of parameter structure. + */ +typedef struct ct_kparam { + ct_param_t param; /* copy of user ct_param_t */ + void *ctpm_kbuf; /* kernel buffer for parameter value */ + uint32_t ret_size; /* parameter value size for copyout */ +} ct_kparam_t; + +struct proc; + +/* + * Contract template ops vector + */ +typedef struct ctmplops { + struct ct_template *(*ctop_dup)(struct ct_template *); + void (*ctop_free)(struct ct_template *); + int (*ctop_set)(struct ct_template *, ct_kparam_t *, + const cred_t *); + int (*ctop_get)(struct ct_template *, ct_kparam_t *); + int (*ctop_create)(struct ct_template *, ctid_t *); + uint_t allevents; +} ctmplops_t; + +/* + * Contract template + */ +typedef struct ct_template { + kmutex_t ctmpl_lock; + ctmplops_t *ctmpl_ops; + struct ct_type *ctmpl_type; + void *ctmpl_data; + uint64_t ctmpl_cookie; /* term: contract cookie */ + uint_t ctmpl_ev_crit; /* term: critical events */ + uint_t ctmpl_ev_info; /* term: informative events */ +} ct_template_t; + + +typedef enum ct_listnum { + CTEL_CONTRACT, /* ../contracts/type//events */ + CTEL_BUNDLE, /* ../contracts/type/bundle */ + CTEL_PBUNDLE, /* ../contracts/type/pbundle */ + CTEL_MAX +} ct_listnum_t; + +typedef enum ctqflags { + CTQ_DEAD = 1, /* contract explicitly cancelled */ + CTQ_REFFED = 2 /* queue is reference counted */ +} ctqflags_t; + +typedef enum ct_ack { + CT_ACK = 1, /* accept break */ + CT_NACK, /* disallow break */ + CT_NONE /* no matching contracts */ +} ct_ack_t; + +/* + * Contract event queue + */ +typedef struct ct_equeue { + kmutex_t ctq_lock; + timespec_t ctq_atime; /* access time */ + ct_listnum_t ctq_listno; /* which list node */ + list_t ctq_events; /* list of events */ + list_t ctq_listeners; /* list of all listeners */ + list_t ctq_tail; /* list of tail listeners */ + int ctq_nlisteners; /* number of listeners */ + int ctq_nreliable; /* number of reliable listeners */ + int ctq_ninf; /* number of informative events */ + int ctq_max; /* max informative events */ + ctqflags_t ctq_flags; /* queue flags */ +} ct_equeue_t; + +typedef struct ct_member { + list_node_t ctm_node; /* list membership */ + int ctm_refs; /* number of references per list */ + int ctm_trimmed; /* membership has been trimmed */ + int ctm_nreliable; /* reliable listeners */ +} ct_member_t; + +typedef struct ct_kevent { + kmutex_t cte_lock; + uint64_t cte_id; /* event id */ + uint_t cte_type; /* event type */ + int cte_refs; + ct_member_t cte_nodes[CTEL_MAX]; /* event queue membership */ + int cte_flags; /* see above */ + nvlist_t *cte_data; /* event data */ + nvlist_t *cte_gdata; /* global-zone only data */ + + struct contract *cte_contract; /* contract */ +} ct_kevent_t; + +/* + * Contract vnode linkage. + * Avoid having too much knowledge about the FS. + */ +typedef struct contract_vnode { + list_node_t ctv_node; + vnode_t *ctv_vnode; +} contract_vnode_t; + +/* + * Contract ops vector + * free - when reference count drops to zero + * abandon - when holding process dies or relinquishes interest + * destroy - when contract is to be completely destroyed + * status - when contractfs needs to return detailed status information + */ +typedef struct contops { + void (*contop_free)(struct contract *); + void (*contop_abandon)(struct contract *); + void (*contop_destroy)(struct contract *); + void (*contop_status)(struct contract *, zone_t *, int, nvlist_t *, + void *, model_t); + int (*contop_ack)(struct contract *, uint_t evtype, + uint64_t evid); + int (*contop_nack)(struct contract *, uint_t evtype, + uint64_t evid); + int (*contop_qack)(struct contract *, uint_t, uint64_t); + int (*contop_newct)(struct contract *); +} contops_t; + +typedef ct_template_t *(ct_f_default_t)(void); + +/* + * Contract type information. + */ +typedef struct ct_type { + uint64_t ct_type_evid; /* last event id */ + ct_typeid_t ct_type_index; /* index in ct_types array */ + const char *ct_type_name; /* type as a string */ + kmutex_t ct_type_lock; /* protects ct_type_avl */ + avl_tree_t ct_type_avl; /* ordered list of type contracts */ + timestruc_t ct_type_timestruc; /* time last contract was written */ + ct_equeue_t ct_type_events; /* bundle queue */ + contops_t *ct_type_ops; + ct_f_default_t *ct_type_default; /* creates a fresh template */ +} ct_type_t; + +typedef enum ctflags { + CTF_INHERIT = 0x1 +} ctflags_t; + +typedef struct ct_time { + long ctm_total; /* Total time allowed for event */ + clock_t ctm_start; /* starting lbolt for event */ +} ct_time_t; + +/* + * Contract + */ +typedef struct contract { + uint64_t ct_ref; /* reference count */ + kmutex_t ct_reflock; /* reference count lock */ + kmutex_t ct_evtlock; /* event dispatch lock */ + + /* Static data */ + kproject_t *ct_proj; /* project of creator */ + uid_t ct_cuid; /* uid of contract author */ + zoneid_t ct_zoneid; /* zoneid of creator */ + uint64_t ct_czuniqid; /* unique id of creator's zone */ + timespec_t ct_ctime; /* creation time */ + ct_type_t *ct_type; /* contract type information */ + void *ct_data; /* contract type data */ + ctid_t ct_id; /* contract ID */ + uint64_t ct_cookie; /* term: contract cookie */ + uint_t ct_ev_crit; /* term: critical events */ + uint_t ct_ev_info; /* term: informative events */ + + /* Protected by other locks */ + uint64_t ct_mzuniqid; /* unique id of members' zone */ + avl_node_t ct_ctavl; /* avl membership */ + avl_node_t ct_cttavl; /* type avl membership */ + avl_node_t ct_ctlist; /* position in holder's list */ + + kmutex_t ct_lock; /* lock for everything below */ + ctstate_t ct_state; /* contract's state */ + list_t ct_vnodes; /* vnodes list */ + ctflags_t ct_flags; /* contract flags */ + ct_equeue_t ct_events; /* contract event queue */ + struct proc *ct_owner; /* contract owner (if owned) */ + struct contract *ct_regent; /* [prospective] regent contract */ + int ct_evcnt; /* number of critical events */ + ct_kevent_t *ct_nevent; /* negotiation event */ + ct_time_t ct_ntime; /* negotiation time tracker */ + ct_time_t ct_qtime; /* quantum time tracker */ +} contract_t; + +#define CTLF_COPYOUT 0x1 /* performing copyout */ +#define CTLF_RESET 0x2 /* event pointer reset or moved */ +#define CTLF_DEAD 0x4 /* dead listener */ +#define CTLF_RELIABLE 0x8 /* reliable listener */ +#define CTLF_CRITICAL 0x10 /* waiting for critical event */ + +typedef struct ct_listener { + list_node_t ctl_allnode; /* entry in list of all listeners */ + list_node_t ctl_tailnode; /* entry in list of tail listeners */ + ct_equeue_t *ctl_equeue; /* queue */ + ct_kevent_t *ctl_position; /* position in queue */ + int ctl_flags; /* state flags */ + kcondvar_t ctl_cv; /* for waiting for an event */ + pollhead_t ctl_pollhead; /* so we can poll(2) */ +} ct_listener_t; + +/* + * Contract template interfaces + */ +void ctmpl_free(ct_template_t *); +int ctmpl_set(ct_template_t *, ct_kparam_t *, const cred_t *); +int ctmpl_get(ct_template_t *, ct_kparam_t *); +ct_template_t *ctmpl_dup(ct_template_t *); +void ctmpl_activate(ct_template_t *); +void ctmpl_clear(ct_template_t *); +int ctmpl_create(ct_template_t *, ctid_t *); + +/* + * Contract parameter functions + */ +int ctparam_copyin(const void *, ct_kparam_t *, int, int); +int ctparam_copyout(ct_kparam_t *, void *, int); + +/* + * Contract functions + */ +void contract_init(void); +int contract_abandon(contract_t *, struct proc *, int); +int contract_adopt(contract_t *, struct proc *); +void contract_destroy(contract_t *); +void contract_exit(struct proc *); +int contract_ack(contract_t *ct, uint64_t evid, int cmd); +int contract_qack(contract_t *ct, uint64_t evid); +int contract_newct(contract_t *ct); + +/* + * Event interfaces + */ +uint64_t cte_publish_all(contract_t *, ct_kevent_t *, nvlist_t *, nvlist_t *); +void cte_add_listener(ct_equeue_t *, ct_listener_t *); +void cte_remove_listener(ct_listener_t *); +void cte_reset_listener(ct_listener_t *); +int cte_get_event(ct_listener_t *, int, void *, const cred_t *, uint64_t, int); +int cte_next_event(ct_listener_t *, uint64_t); +int cte_set_reliable(ct_listener_t *, const cred_t *); + +/* + * Contract implementation interfaces + */ +int contract_compar(const void *, const void *); +void ctmpl_init(ct_template_t *, ctmplops_t *, ct_type_t *, void *); +void ctmpl_copy(ct_template_t *, ct_template_t *); +int ctmpl_create_inval(ct_template_t *, ctid_t *); +int contract_ctor(contract_t *, ct_type_t *, ct_template_t *, void *, ctflags_t, + struct proc *, int); +void contract_hold(contract_t *); +void contract_rele(contract_t *); +uint64_t contract_getzuniqid(contract_t *); +void contract_setzuniqid(contract_t *, uint64_t); +void contract_rele_unlocked(contract_t *); +void contract_status_common(contract_t *, zone_t *, void *, model_t); +void contract_orphan(contract_t *); +ctid_t contract_lookup(uint64_t, ctid_t); +ctid_t contract_plookup(struct proc *, ctid_t, uint64_t); +contract_t *contract_ptr(id_t, uint64_t); +ctid_t contract_max(void); +int contract_owned(contract_t *, const cred_t *, int); + +/* + * Type interfaces + */ +extern int ct_ntypes; +extern ct_type_t **ct_types; + +ct_type_t *contract_type_init(ct_typeid_t, const char *, contops_t *, + ct_f_default_t *); +int contract_type_count(ct_type_t *); +ctid_t contract_type_max(ct_type_t *); +ctid_t contract_type_lookup(ct_type_t *, uint64_t, ctid_t); +contract_t *contract_type_ptr(ct_type_t *, ctid_t, uint64_t); +void contract_type_time(ct_type_t *, timestruc_t *); +ct_equeue_t *contract_type_bundle(ct_type_t *); +ct_equeue_t *contract_type_pbundle(ct_type_t *, struct proc *); + +/* + * FS interfaces + */ +vnode_t *contract_vnode_get(contract_t *, vfs_t *); +void contract_vnode_set(contract_t *, contract_vnode_t *, vnode_t *); +int contract_vnode_clear(contract_t *, contract_vnode_t *); + +/* + * Negotiation stubs + */ +int contract_ack_inval(contract_t *, uint_t, uint64_t); +int contract_qack_inval(contract_t *, uint_t, uint64_t); +int contract_qack_notsup(contract_t *, uint_t, uint64_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CONTRACT_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/controlregs.h b/illumos-x86_64/usr/include/sys/controlregs.h new file mode 100644 index 00000000..2a40b921 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/controlregs.h @@ -0,0 +1,275 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018, Joyent, Inc. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_CONTROLREGS_H +#define _SYS_CONTROLREGS_H + +#ifndef _ASM +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file describes the x86 architecture control registers which + * are part of the privileged architecture. + * + * Many of these definitions are shared between IA-32-style and + * AMD64-style processors. + */ + +/* CR0 Register */ + +#define CR0_PG 0x80000000 /* paging enabled */ +#define CR0_CD 0x40000000 /* cache disable */ +#define CR0_NW 0x20000000 /* not writethrough */ +#define CR0_AM 0x00040000 /* alignment mask */ +#define CR0_WP 0x00010000 /* write protect */ +#define CR0_NE 0x00000020 /* numeric error */ +#define CR0_ET 0x00000010 /* extension type */ +#define CR0_TS 0x00000008 /* task switch */ +#define CR0_EM 0x00000004 /* emulation */ +#define CR0_MP 0x00000002 /* monitor coprocessor */ +#define CR0_PE 0x00000001 /* protection enabled */ + +/* XX64 eliminate these compatibility defines */ + +#define CR0_CE CR0_CD +#define CR0_WT CR0_NW + +#define FMT_CR0 \ + "\20\40pg\37cd\36nw\35am\21wp\6ne\5et\4ts\3em\2mp\1pe" + +/* + * Set the FPU-related control bits to explain to the processor that + * we're managing FPU state: + * - set monitor coprocessor (allow TS bit to control FPU) + * - set numeric exception (disable IGNNE# mechanism) + * - set task switch (#nm on first fp instruction) + * - clear emulate math bit (cause we're not emulating!) + */ +#define CR0_ENABLE_FPU_FLAGS(cr) \ + (((cr) | CR0_MP | CR0_NE | CR0_TS) & (uint32_t)~CR0_EM) + +/* + * Set the FPU-related control bits to explain to the processor that + * we're -not- managing FPU state: + * - set emulate (all fp instructions cause #nm) + * - clear monitor coprocessor (so fwait/wait doesn't #nm) + */ +#define CR0_DISABLE_FPU_FLAGS(cr) \ + (((cr) | CR0_EM) & (uint32_t)~CR0_MP) + +/* CR3 Register */ + +#define CR3_PCD 0x00000010 /* cache disable */ +#define CR3_PWT 0x00000008 /* write through */ +#if defined(_ASM) +#define CR3_NOINVL_BIT 0x8000000000000000 +#else +#define CR3_NOINVL_BIT 0x8000000000000000ULL /* no invalidation */ +#endif +#define PCID_NONE 0x000 /* generic PCID */ +#define PCID_KERNEL 0x000 /* kernel's PCID */ +#define PCID_USER 0x001 /* user-space PCID */ + +/* CR4 Register */ + +#define CR4_VME 0x0001 /* virtual-8086 mode extensions */ +#define CR4_PVI 0x0002 /* protected-mode virtual interrupts */ +#define CR4_TSD 0x0004 /* time stamp disable */ +#define CR4_DE 0x0008 /* debugging extensions */ +#define CR4_PSE 0x0010 /* page size extensions */ +#define CR4_PAE 0x0020 /* physical address extension */ +#define CR4_MCE 0x0040 /* machine check enable */ +#define CR4_PGE 0x0080 /* page global enable */ +#define CR4_PCE 0x0100 /* perf-monitoring counter enable */ +#define CR4_OSFXSR 0x0200 /* OS fxsave/fxrstor support */ +#define CR4_OSXMMEXCPT 0x0400 /* OS unmasked exception support */ +#define CR4_UMIP 0x0800 /* user-mode instruction prevention */ +#define CR4_LA57 0x1000 /* enable 57 bit Logical addressing */ +#define CR4_VMXE 0x2000 /* VMX enable */ +#define CR4_SMXE 0x4000 /* SMX enable */ + /* 0x8000 reserved */ +#define CR4_FSGSBASE 0x10000 /* FSGSBASE enable */ +#define CR4_PCIDE 0x20000 /* PCID enable */ +#define CR4_OSXSAVE 0x40000 /* OS xsave/xrestore support */ +#define CR4_SMEP 0x100000 /* NX for user pages in kernel */ +#define CR4_SMAP 0x200000 /* kernel can't access user pages */ +#define CR4_PKE 0x400000 /* protection key enable */ + +#define FMT_CR4 \ + "\20\27pke\26smap\25smep\23osxsav" \ + "\22pcide\21fsgsbase\17smxe\16vmxe" \ + "\15la57\14umip\13xmme\12fxsr\11pce\10pge" \ + "\7mce\6pae\5pse\4de\3tsd\2pvi\1vme" + +/* + * Enable the SSE-related control bits to explain to the processor that + * we're managing XMM state and exceptions + */ +#define CR4_ENABLE_SSE_FLAGS(cr) \ + ((cr) | CR4_OSFXSR | CR4_OSXMMEXCPT) + +/* + * Disable the SSE-related control bits to explain to the processor + * that we're NOT managing XMM state + */ +#define CR4_DISABLE_SSE_FLAGS(cr) \ + ((cr) & ~(uint32_t)(CR4_OSFXSR | CR4_OSXMMEXCPT)) + +/* Intel's SYSENTER configuration registers */ + +#define MSR_INTC_SEP_CS 0x174 /* kernel code selector MSR */ +#define MSR_INTC_SEP_ESP 0x175 /* kernel esp MSR */ +#define MSR_INTC_SEP_EIP 0x176 /* kernel eip MSR */ + +/* Intel's microcode registers */ +#define MSR_INTC_UCODE_WRITE 0x79 /* microcode write */ +#define MSR_INTC_UCODE_REV 0x8b /* microcode revision */ +#define INTC_UCODE_REV_SHIFT 32 /* Bits 63:32 */ + +/* Intel's platform identification */ +#define MSR_INTC_PLATFORM_ID 0x17 +#define INTC_PLATFORM_ID_SHIFT 50 /* Bit 52:50 */ +#define INTC_PLATFORM_ID_MASK 0x7 + +/* AMD's EFER register */ + +#define MSR_AMD_EFER 0xc0000080 /* extended feature enable MSR */ + +#define AMD_EFER_AIBRSE 0x200000 /* Automatic IBRS Enable */ +#define AMD_EFER_UAIE 0x100000 /* upper address ignore enable */ +#define AMD_EFER_INTWB 0x040000 /* interruptible wbinvd / wbnoinvd */ +#define AMD_EFER_MCOMMIT 0x020000 /* enable mcommit instr */ +#define AMD_EFER_TCE 0x008000 /* translation cache extension */ +#define AMD_EFER_FFXSR 0x004000 /* fast fxsave/fxrstor */ +#define AMD_EFER_LMSLE 0x002000 /* long mode segment limit enable */ +#define AMD_EFER_SVME 0x001000 /* svm enable */ +#define AMD_EFER_NXE 0x000800 /* no-execute enable */ +#define AMD_EFER_LMA 0x000400 /* long mode active (read-only) */ +#define AMD_EFER_LME 0x000100 /* long mode enable */ +#define AMD_EFER_SCE 0x000001 /* system call extensions */ + +/* AMD's SYSCFG register */ + +#define MSR_AMD_SYSCFG 0xc0000010 /* system configuration MSR */ + +#define AMD_SYSCFG_TOM2 0x200000 /* MtrrTom2En */ +#define AMD_SYSCFG_MVDM 0x100000 /* MtrrVarDramEn */ +#define AMD_SYSCFG_MFDM 0x080000 /* MtrrFixDramModEn */ +#define AMD_SYSCFG_MFDE 0x040000 /* MtrrFixDramEn */ + +#define FMT_AMD_SYSCFG \ + "\20\26tom2\25mvdm\24mfdm\23mfde" + +/* AMD's syscall/sysret MSRs */ + +#define MSR_AMD_STAR 0xc0000081 /* %cs:%ss:%cs:%ss:%eip for syscall */ +#define MSR_AMD_LSTAR 0xc0000082 /* target %rip of 64-bit syscall */ +#define MSR_AMD_CSTAR 0xc0000083 /* target %rip of 32-bit syscall */ +#define MSR_AMD_SFMASK 0xc0000084 /* syscall flag mask */ + +/* AMD's FS.base and GS.base MSRs */ + +#define MSR_AMD_FSBASE 0xc0000100 /* 64-bit base address for %fs */ +#define MSR_AMD_GSBASE 0xc0000101 /* 64-bit base address for %gs */ +#define MSR_AMD_KGSBASE 0xc0000102 /* swapgs swaps this with gsbase */ +#define MSR_AMD_TSCAUX 0xc0000103 /* %ecx value on rdtscp insn */ + + +/* AMD's SVM MSRs */ + +#define MSR_AMD_VM_CR 0xc0010114 /* SVM global control */ +#define MSR_AMD_VM_HSAVE_PA 0xc0010117 /* SVM host save area address */ + +#define AMD_VM_CR_DPD (1 << 0) +#define AMD_VM_CR_R_INIT (1 << 1) +#define AMD_VM_CR_DIS_A20M (1 << 2) +#define AMD_VM_CR_LOCK (1 << 3) +#define AMD_VM_CR_SVMDIS (1 << 4) + +/* AMD's configuration MSRs, weakly documented in the revision guide */ + +#define MSR_AMD_DC_CFG 0xc0011022 + +#define AMD_DC_CFG_DIS_CNV_WC_SSO (UINT64_C(1) << 3) +#define AMD_DC_CFG_DIS_SMC_CHK_BUF (UINT64_C(1) << 10) + +/* AMD's HWCR MSR */ + +#define MSR_AMD_HWCR 0xc0010015 + +#define AMD_HWCR_TLBCACHEDIS (UINT64_C(1) << 3) +#define AMD_HWCR_FFDIS 0x00040 /* disable TLB Flush Filter */ +#define AMD_HWCR_MCI_STATUS_WREN 0x40000 /* enable write of MCi_STATUS */ + +/* AMD's NorthBridge Config MSR, SHOULD ONLY BE WRITTEN TO BY BIOS */ + +#define MSR_AMD_NB_CFG 0xc001001f + +#define AMD_NB_CFG_SRQ_HEARTBEAT (UINT64_C(1) << 20) +#define AMD_NB_CFG_SRQ_SPR (UINT64_C(1) << 32) + +#define MSR_AMD_BU_CFG 0xc0011023 + +#define AMD_BU_CFG_E298 (UINT64_C(1) << 1) + +/* + * This MSR exists on families, 10h, 12h+ for AMD. This controls instruction + * decoding. Most notably, for the AMD variant of retpolines, we must improve + * the serializability of lfence for the lfence based method to work. + */ +#define MSR_AMD_DE_CFG 0xc0011029 + +#define AMD_DE_CFG_E721 (1UL << 0) +#define AMD_DE_CFG_LFENCE_DISPATCH (1UL << 1) + +/* AMD's osvw MSRs */ +#define MSR_AMD_OSVW_ID_LEN 0xc0010140 +#define MSR_AMD_OSVW_STATUS 0xc0010141 + + +#define OSVW_ID_LEN_MASK 0xffffULL +#define OSVW_ID_CNT_PER_MSR 64 + +/* + * Enable PCI Extended Configuration Space (ECS) on Greyhound + */ +#define AMD_GH_NB_CFG_EN_ECS (UINT64_C(1) << 46) + +/* AMD microcode patch loader */ +#define MSR_AMD_PATCHLEVEL 0x8b +#define MSR_AMD_PATCHLOADER 0xc0010020 + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_CONTROLREGS_H */ diff --git a/illumos-x86_64/usr/include/sys/copyops.h b/illumos-x86_64/usr/include/sys/copyops.h new file mode 100644 index 00000000..54b754ea --- /dev/null +++ b/illumos-x86_64/usr/include/sys/copyops.h @@ -0,0 +1,107 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_COPYOPS_H +#define _SYS_COPYOPS_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Copy in/out vector operations. This structure is used to interpose + * on the kernel copyin/copyout/etc. operations for various purposes + * such as handling watchpoints in the affected user memory. When one of the + * copy operations causes a fault, the corresponding function in this vector is + * called to handle it. + * + * The 64-bit operations in the structure fetch and store extended + * words and are only used on platforms with 64 bit general + * registers e.g. sun4u. + * + * Since the only users of these interfaces (watchpoints and pxfs) perform the + * default action unless there is a page fault, we can save the overhead of + * having to go through this indirection unless there is a page fault. This + * improves performance both in general and when watchpoints are enabled. If, + * in the future, a consumer relies on being able to interpose on all actions, + * then this assumption will have to be undone. + * + * No consumers should call these functions directly. They are automatically + * handled by the generic versions. + */ +typedef struct copyops { + /* + * unstructured byte copyin/out functions + */ + int (*cp_copyin)(const void *, void *, size_t); + int (*cp_xcopyin)(const void *, void *, size_t); + int (*cp_copyout)(const void *, void *, size_t); + int (*cp_xcopyout)(const void *, void *, size_t); + int (*cp_copyinstr)(const char *, char *, size_t, size_t *); + int (*cp_copyoutstr)(const char *, char *, size_t, size_t *); + + /* + * fetch/store byte/halfword/word/extended word + */ + int (*cp_fuword8)(const void *, uint8_t *); + int (*cp_fuword16)(const void *, uint16_t *); + int (*cp_fuword32)(const void *, uint32_t *); + int (*cp_fuword64)(const void *, uint64_t *); + + int (*cp_suword8)(void *, uint8_t); + int (*cp_suword16)(void *, uint16_t); + int (*cp_suword32)(void *, uint32_t); + int (*cp_suword64)(void *, uint64_t); + + int (*cp_physio)(int (*)(struct buf *), struct buf *, dev_t, + int, void (*)(struct buf *), struct uio *); +} copyops_t; + +extern int default_physio(int (*)(struct buf *), struct buf *, + dev_t, int, void (*)(struct buf *), struct uio *); + +/* + * Interfaces for installing and removing copyops. + */ +extern void install_copyops(kthread_id_t tp, copyops_t *cp); +extern void remove_copyops(kthread_id_t tp); +extern int copyops_installed(kthread_id_t tp); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_COPYOPS_H */ diff --git a/illumos-x86_64/usr/include/sys/core.h b/illumos-x86_64/usr/include/sys/core.h new file mode 100644 index 00000000..543ed5fa --- /dev/null +++ b/illumos-x86_64/usr/include/sys/core.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CORE_H +#define _SYS_CORE_H + +#ifndef _KERNEL +#include +#endif /* _KERNEL */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CORE_MAGIC 0x080456 +#define CORE_NAMELEN 16 + +#if !defined(_LP64) && !defined(_KERNEL) +/* + * This structure describes the header of the old 32-bit SunOS 4.x aout exec + * module's core files. Following the header, copies of the data and stack + * segments and a copy of the user struct were recorded in the core file. + * These core files have not been produced since SunOS 5.5; new debuggers + * should not make use of this structure. The structure is not suitable for + * 64-bit consumers and will be removed altogether in a future Solaris release. + */ +struct core { + int c_magic; /* Corefile magic number */ + int c_len; /* Sizeof (struct core) */ + struct regs c_regs; /* General purpose registers */ + struct exdata c_exdata; /* Executable header */ + int c_signo; /* Killing signal, if any */ + int c_tsize; /* Text size (bytes) */ + int c_dsize; /* Data size (bytes) */ + int c_ssize; /* Stack size (bytes) */ + char c_cmdname[CORE_NAMELEN + 1]; /* Command name */ + struct _fpu c_fpu; /* external FPU state */ +#if defined(__sparc) + struct _fq c_fpu_q[_MAXFPQ]; /* fpu exception queue */ +#endif + int c_ucode; /* Exception no. from u_code */ +}; +#endif /* !_LP64 && !_KERNEL */ + +#ifdef _KERNEL + +extern int core(int, int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CORE_H */ diff --git a/illumos-x86_64/usr/include/sys/corectl.h b/illumos-x86_64/usr/include/sys/corectl.h new file mode 100644 index 00000000..058d583d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/corectl.h @@ -0,0 +1,163 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CORECTL_H +#define _SYS_CORECTL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for corectl() system call. + */ + +/* subcodes */ +#define CC_SET_OPTIONS 1 +#define CC_GET_OPTIONS 2 +#define CC_SET_GLOBAL_PATH 3 +#define CC_GET_GLOBAL_PATH 4 +#define CC_SET_PROCESS_PATH 5 +#define CC_GET_PROCESS_PATH 6 +#define CC_SET_GLOBAL_CONTENT 7 +#define CC_GET_GLOBAL_CONTENT 8 +#define CC_SET_PROCESS_CONTENT 9 +#define CC_GET_PROCESS_CONTENT 10 +#define CC_SET_DEFAULT_PATH 11 +#define CC_GET_DEFAULT_PATH 12 +#define CC_SET_DEFAULT_CONTENT 13 +#define CC_GET_DEFAULT_CONTENT 14 + +/* options */ +#define CC_GLOBAL_PATH 0x01 /* enable global core files */ +#define CC_PROCESS_PATH 0x02 /* enable per-process core files */ +#define CC_GLOBAL_SETID 0x04 /* allow global setid core files */ +#define CC_PROCESS_SETID 0x08 /* allow per-process setid core files */ +#define CC_GLOBAL_LOG 0x10 /* log global core dumps to syslog */ + +/* all of the above */ +#define CC_OPTIONS \ + (CC_GLOBAL_PATH | CC_PROCESS_PATH | \ + CC_GLOBAL_SETID | CC_PROCESS_SETID | CC_GLOBAL_LOG) + +/* contents */ +#define CC_CONTENT_STACK 0x0001ULL /* process stack */ +#define CC_CONTENT_HEAP 0x0002ULL /* process heap */ + +/* MAP_SHARED file mappings */ +#define CC_CONTENT_SHFILE 0x0004ULL /* file-backed shared mapping */ +#define CC_CONTENT_SHANON 0x0008ULL /* anonymous shared mapping */ + +/* MAP_PRIVATE file mappings */ +#define CC_CONTENT_TEXT 0x0010ULL /* read/exec file mappings */ +#define CC_CONTENT_DATA 0x0020ULL /* writable file mappings */ +#define CC_CONTENT_RODATA 0x0040ULL /* read-only file mappings */ +#define CC_CONTENT_ANON 0x0080ULL /* anonymous mappings (MAP_ANON) */ + +#define CC_CONTENT_SHM 0x0100ULL /* System V shared memory */ +#define CC_CONTENT_ISM 0x0200ULL /* intimate shared memory */ +#define CC_CONTENT_DISM 0x0400ULL /* dynamic intimate shared memory */ + +#define CC_CONTENT_CTF 0x0800ULL /* CTF data */ +#define CC_CONTENT_SYMTAB 0x1000ULL /* symbol table */ +#define CC_CONTENT_DEBUG 0x2000ULL /* debug information */ + +#define CC_CONTENT_ALL 0x3fffULL +#define CC_CONTENT_NONE 0ULL +#define CC_CONTENT_DEFAULT (CC_CONTENT_STACK | CC_CONTENT_HEAP | \ + CC_CONTENT_ISM | CC_CONTENT_DISM | CC_CONTENT_SHM | \ + CC_CONTENT_SHANON | CC_CONTENT_TEXT | CC_CONTENT_DATA | \ + CC_CONTENT_RODATA | CC_CONTENT_ANON | CC_CONTENT_CTF | \ + CC_CONTENT_SYMTAB) +#define CC_CONTENT_INVALID (-1ULL) + +typedef u_longlong_t core_content_t; + +typedef struct corectl_content { + core_content_t ccc_content; + kmutex_t ccc_mtx; + uint32_t ccc_refcnt; +} corectl_content_t; + +typedef struct corectl_path { + refstr_t *ccp_path; + kmutex_t ccp_mtx; + uint32_t ccp_refcnt; +} corectl_path_t; + +#ifdef _KERNEL + +struct core_globals { + kmutex_t core_lock; + refstr_t *core_file; + uint32_t core_options; + core_content_t core_content; + rlim64_t core_rlimit; + corectl_path_t *core_default_path; + corectl_content_t *core_default_content; +}; + +extern zone_key_t core_zone_key; + +extern void init_core(void); +extern void set_core_defaults(void); + +extern core_content_t corectl_content_value(corectl_content_t *); +extern void corectl_content_hold(corectl_content_t *); +extern void corectl_content_rele(corectl_content_t *); + +extern refstr_t *corectl_path_value(corectl_path_t *); +extern void corectl_path_hold(corectl_path_t *); +extern void corectl_path_rele(corectl_path_t *); + +#else /* _KERNEL */ + +extern int core_set_options(int); +extern int core_get_options(void); +extern int core_set_global_path(const char *, size_t); +extern int core_get_global_path(char *, size_t); +extern int core_set_default_path(const char *, size_t); +extern int core_get_default_path(char *, size_t); +extern int core_set_process_path(const char *, size_t, pid_t); +extern int core_get_process_path(char *, size_t, pid_t); +extern int core_set_global_content(const core_content_t *); +extern int core_get_global_content(core_content_t *); +extern int core_set_default_content(const core_content_t *); +extern int core_get_default_content(core_content_t *); +extern int core_set_process_content(const core_content_t *, pid_t); +extern int core_get_process_content(core_content_t *, pid_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CORECTL_H */ diff --git a/illumos-x86_64/usr/include/sys/cpc_impl.h b/illumos-x86_64/usr/include/sys/cpc_impl.h new file mode 100644 index 00000000..bc89006e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpc_impl.h @@ -0,0 +1,255 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CPC_IMPL_H +#define _SYS_CPC_IMPL_H + +#include +#include +#include + +#if defined(_KERNEL) && defined(_MULTI_DATAMODEL) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + char *ca_name; + uint64_t ca_val; +} cpc_attr_t; + +/* + * Flag arguments to cpc_bind_event and cpc_ctx_bind_event + */ +#define CPC_BIND_LWP_INHERIT (0x1) +#define CPC_BIND_EMT_OVF (0x2) + +#define CPC_MAX_IMPL_NAME 512 /* Max len of PCBE's description str */ +#define CPC_MAX_CPUREF 1024 /* Max len of PCBE's CPU ref string */ + +#define CPC_OVF_NOTIFY_EMT 0x1 +#define CPC_COUNT_USER 0x2 +#define CPC_COUNT_SYSTEM 0x4 +#define CPC_COUNT_HV 0x8 +#define CPC_COUNT_SAMPLE_MODE 0x10 + +#define KCPC_REQ_ALL_FLAGS (CPC_OVF_NOTIFY_EMT | CPC_COUNT_USER | \ + CPC_COUNT_SYSTEM | CPC_COUNT_HV | CPC_COUNT_SAMPLE_MODE) +#define KCPC_REQ_VALID_FLAGS(flags) \ + (((flags) | KCPC_REQ_ALL_FLAGS) == KCPC_REQ_ALL_FLAGS) + +/* + * CPC Capabilities + */ +#define CPC_CAP_OVERFLOW_INTERRUPT 0x1 +#define CPC_CAP_OVERFLOW_PRECISE 0x2 + +/* + * The only valid per-set flag is CPC_BIND_LWP_INHERIT, which must remain in + * cpc_event.h for backwards compatibility. + */ +#define CPC_SET_ALL_FLAGS 0x1 +#define CPC_SET_VALID_FLAGS(flags) \ + (((flags) | CPC_SET_ALL_FLAGS) == CPC_SET_ALL_FLAGS) + +/* + * These system call subcodes and ioctls allow the implementation of the + * libcpc library to store and retrieve performance counter data. Subject + * to arbitrary change without notice at any time. Do not invoke them + * directly! + */ +#define CPC_BIND 0 +#define CPC_SAMPLE 1 +#define CPC_INVALIDATE 2 +#define CPC_RELE 3 +#define CPC_EVLIST_SIZE 4 +#define CPC_LIST_EVENTS 5 +#define CPC_ATTRLIST_SIZE 6 +#define CPC_LIST_ATTRS 7 +#define CPC_IMPL_NAME 8 +#define CPC_CPUREF 9 +#define CPC_USR_EVENTS 10 +#define CPC_SYS_EVENTS 11 +#define CPC_NPIC 12 +#define CPC_CAPS 13 +#define CPC_ENABLE 14 +#define CPC_DISABLE 15 +#define CPC_PRESET 16 +#define CPC_RESTART 17 + +#define _CPCIO_IOC ((((('c'<<8)|'p')<<8)|'c')<<8) + +#define CPCIO_BIND (_CPCIO_IOC | 0x1) +#define CPCIO_SAMPLE (_CPCIO_IOC | 0x2) +#define CPCIO_RELE (_CPCIO_IOC | 0x3) + +/* + * Forward declarations. + */ +struct _kthread; +struct _kcpc_set; + +#define CPC_MAX_EVENT_LEN 512 +#define CPC_MAX_ATTR_LEN 32 + +typedef struct _kcpc_attr { + char ka_name[CPC_MAX_ATTR_LEN]; + uint64_t ka_val; +} kcpc_attr_t; + +typedef struct _kcpc_pic { + uint_t kp_flags; + struct _kcpc_request *kp_req; /* request this PIC counts for */ +} kcpc_pic_t; + +typedef struct _kcpc_ctx kcpc_ctx_t; + +struct _kcpc_ctx { + struct _kcpc_set *kc_set; /* linked list of all bound sets */ + volatile uint_t kc_flags; + kcpc_pic_t *kc_pics; /* pointer to array of per-pic data */ + hrtime_t kc_hrtime; /* gethrtime() at last sample */ + uint64_t kc_vtick; /* virtualized %tick */ + uint64_t kc_rawtick; /* last snapshot of tick/tsc */ + struct _kthread *kc_thread; /* thread this context is measuring */ + int kc_cpuid; /* CPU this context is measuring */ + kcpc_ctx_t *kc_next; /* Global list of all contexts */ + kmutex_t kc_lock; /* protects kc_flags */ + kcondvar_t kc_condv; /* wait for kcpc_restore completion */ +}; + +typedef struct __cpc_args { + void *udata1; + void *udata2; + void *udata3; +} __cpc_args_t; + +#ifdef _KERNEL + +#ifdef _MULTI_DATAMODEL +typedef struct __cpc_args32 { + caddr32_t udata1; + caddr32_t udata2; + caddr32_t udata3; +} __cpc_args32_t; +#endif /* _MULTI_DATAMODEL */ + +#define KCPC_LOG2_HASH_BUCKETS 6 /* => 64 buckets for now */ +#define CPC_HASH_BUCKETS (1l << KCPC_LOG2_HASH_BUCKETS) +#define CPC_HASH_CTX(ctx) ((((long)(ctx)) >> 7) & \ + (CPC_HASH_BUCKETS - 1)) + +/* + * Context flags. + */ +#define KCPC_CTX_FREEZE 0x1 /* => no sampling */ +#define KCPC_CTX_SIGOVF 0x2 /* => send signal on overflow */ +#define KCPC_CTX_NONPRIV 0x4 /* => non-priv access to counters */ +#define KCPC_CTX_LWPINHERIT 0x8 /* => lwp_create inherits ctx */ +#define KCPC_CTX_INVALID 0x100 /* => context stolen; discard */ +#define KCPC_CTX_INVALID_STOPPED 0x200 /* => invalid ctx has been stopped */ +#define KCPC_CTX_RESTORE 0x400 /* => kcpc_restore in progress */ + +/* + * PIC flags. + */ +#define KCPC_PIC_OVERFLOWED 0x1 /* pic overflowed & requested notify */ + +/* + * The following flags are used by the DTrace CPU performance counter provider + * and the overflow handler. The 'DCPC_INTR_*' flags are used to synchronize + * performance counter configuration events performed by the cpc provider and + * interrupt processing carried out by the overflow handler. The 'DCPC_?MASK' + * flags are used by the dcpc provider to indicate which type of mask attribute + * a platform supports. + */ + +enum dcpc_intr_state { + DCPC_INTR_INACTIVE, /* The dcpc provider is currently not in use */ + DCPC_INTR_FREE, /* No config events or ovf ints in progress */ + DCPC_INTR_PROCESSING, /* An overflow interrupt is being processed */ + DCPC_INTR_CONFIG /* cpc subsystem being configured by dcpc */ +}; + +enum dcpc_mask_attr { + DCPC_UMASK = 0x1, /* The platform supports a "umask" attribute */ + DCPC_EMASK = 0x2 /* The platform supports an "emask" attribute */ +}; + +#ifdef __sparc +extern uint64_t ultra_gettick(void); +#define KCPC_GET_TICK ultra_gettick +#else +extern hrtime_t tsc_read(void); +#define KCPC_GET_TICK tsc_read +#endif /* __sparc */ + +#define PCBE_NAMELEN 30 /* Enough room for "pcbe." plus full PCBE name spec */ + +struct cpu; + +extern uint_t cpc_ncounters; +extern krwlock_t kcpc_cpuctx_lock; /* lock for 'kcpc_cpuctx' below */ +extern int kcpc_cpuctx; /* number of cpu-specific contexts */ + +extern void kcpc_invalidate_all(void); + +extern void kcpc_passivate(void); +extern void kcpc_cpu_stop(struct cpu *, boolean_t); +extern int kcpc_pcbe_tryload(const char *, uint_t, uint_t, uint_t); +extern void kcpc_cpu_program(struct cpu *, kcpc_ctx_t *); +extern void kcpc_register_dcpc(void (*func)(uint64_t)); +extern void kcpc_unregister_dcpc(void); +extern kcpc_ctx_t *kcpc_ctx_alloc(int); +extern int kcpc_assign_reqs(struct _kcpc_set *, kcpc_ctx_t *); +extern void kcpc_ctx_free(kcpc_ctx_t *); +extern int kcpc_configure_reqs(kcpc_ctx_t *, struct _kcpc_set *, int *); +extern void kcpc_free_configs(struct _kcpc_set *); + +#endif /* _KERNEL */ + +/* + * Error subcodes. + */ +#define CPC_INVALID_EVENT 1 /* Unknown event */ +#define CPC_INVALID_PICNUM 2 /* Requested PIC out of range */ +#define CPC_INVALID_ATTRIBUTE 3 /* Unknown attribute */ +#define CPC_ATTRIBUTE_OUT_OF_RANGE 4 /* Attribute val out of range */ +#define CPC_RESOURCE_UNAVAIL 5 /* Can't get needed resource */ +#define CPC_PIC_NOT_CAPABLE 6 /* PIC can't count this event */ +#define CPC_REQ_INVALID_FLAGS 7 /* Invalid flags in req(s) */ +#define CPC_CONFLICTING_REQS 8 /* Reqs in the set conflict */ +#define CPC_ATTR_REQUIRES_PRIVILEGE 9 /* Insufficient privs for atr */ +#define CPC_PBIND_FAILED 10 /* Couldn't bind to processor */ +#define CPC_HV_NO_ACCESS 11 /* No perm for HV events */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPC_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/cpc_pcbe.h b/illumos-x86_64/usr/include/sys/cpc_pcbe.h new file mode 100644 index 00000000..eb168fcf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpc_pcbe.h @@ -0,0 +1,162 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * CPC Performance Counter Backend + * + * To utilize the performance counters on a given CPU, a pcbe (Performance + * Counter Backend) must be implemented for that CPU. + * + * This file defines the API which the kernel CPC implementation will call into. + * + */ + +#ifndef _SYS_CPC_PCBE_H +#define _SYS_CPC_PCBE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * All PCBEs must use PCBE_VER_1. + */ +#define PCBE_VER_1 1 + +#define PCBE_IMPL_NAME_P4HT "Pentium 4 with HyperThreading" + +typedef struct __pcbe_ops { + uint_t pcbe_ver; + uint_t pcbe_caps; + uint_t (*pcbe_ncounters)(void); + const char *(*pcbe_impl_name)(void); + const char *(*pcbe_cpuref)(void); + char *(*pcbe_list_events)(uint_t picnum); + char *(*pcbe_list_attrs)(void); + uint64_t (*pcbe_event_coverage)(char *event); + uint64_t (*pcbe_overflow_bitmap)(void); + int (*pcbe_configure)(uint_t, char *, uint64_t, uint_t, + uint_t, kcpc_attr_t *, void **, void *); + void (*pcbe_program)(void *); + void (*pcbe_allstop)(void); + void (*pcbe_sample)(void *); + void (*pcbe_free)(void *); +} pcbe_ops_t; + +extern pcbe_ops_t *pcbe_ops; + +/* + * uint_t pcbe_ver; + * + * Must always be set to PCBE_VER_1. + * + * uint_t pcbe_caps; + * + * Bitmask of capability flags which define the processor's capabilities: + * CPC_CAP_OVERFLOW_INTERRUPT: + * This processor can generate an interrupt when a counter + * overflows. + * + * CPC_CAP_OVERFLOW_PRECISE: + * When an overflow interrupt occurs, the backend can + * determine programmatically exactly which counter + * overflowed. + * + * uint_t (*pcbe_ncounters)(void); + * + * Returns the number of counters on the processor. + * + * const char *(*pcbe_impl_name)(void); + * + * Returns a pointer to a string which uniquely identifies the CPC + * capabilities of the processor. + * + * const char *(*pcbe_cpuref)(void); + * + * Returns a pointer to a string which points to a reference manual of + * some sort which should be consulted to understand the performance + * counters. + * + * char *(*pcbe_list_events)(uint_t picnum); + * + * Returns a pointer to a comma-separated list of events which the given + * counter number is capable of counting. picnum starts at 0 and goes as + * high as (ncounters - 1). + * + * char *(*pcbe_list_attrs)(void); + * + * Returns a pointer to a comma-separated list of attribute names which + * the PCBE supports. + * + * uint64_t (*pcbe_event_coverage)(char *event); + * + * Returns a bitmask indicating which counters are capable of counting the + * named event. Counter n is deemed capable if bit (1 << n) is turned on, + * where counters range from 0 to (ncounters - 1). + * + * uint64_t (*pcbe_overflow_bitmap)(void); + * + * Called by the kernel when a performance counter interrupt is received. + * This routine must return a bitmap of counters indicating which ones have + * overflowed. If the platform cannot determine this, it must act as if + * _all_ of its counters have overflowed. + * + * int (*pcbe_configure)(uint_t picnum, char *event, uint64_t preset, + * uint_t flags, uint_t nattrs, kcpc_attr_t *attrp, + * void **configp, void *token); + * + * Returns a pointer to a PCBE-private data structure which can later be + * used to program the indicated picnum according to the arguments. + * token may be passed to kcpc_next_config() in order to walk the list of + * configurations which will be programmed together. + * + * void (*pcbe_program)(void *token); + * + * Collects all configurations which will be programmed together, via + * kcpc_next_config(), programs them onto the hardware, and starts the + * performance counters. + * + * void (*pcbe_allstop)(void); + * + * Stops all hardware performance counters. + * + * void (*pcbe_sample)(void *token); + * + * Samples the values in the performance couters and updates the locations + * returned by kcpc_next_config() with the delta since the last sample. + * + * void (*pcbe_free)(void *config); + * + * Frees the given configuration. + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPC_PCBE_H */ diff --git a/illumos-x86_64/usr/include/sys/cpr.h b/illumos-x86_64/usr/include/sys/cpr.h new file mode 100644 index 00000000..e88f7119 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpr.h @@ -0,0 +1,672 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CPR_H +#define _SYS_CPR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include + +/* + * definitions for kernel, cprboot, pmconfig + */ +#define CPR_VERSION 6 +#define CPR_CONFIG "/etc/.cpr_config" + + +/* + * magic numbers for cpr files + */ +#define CPR_CONFIG_MAGIC 0x436E4667 /* 'CnFg' */ +#define CPR_DEFAULT_MAGIC 0x44664C74 /* 'DfLt' */ + +/* + * max(strlen("true"), strlen("false")) + 1 + */ +#define PROP_BOOL_LEN 6 +#define PROP_MOD 'Y' +#define PROP_NOMOD 'N' + +/* + * max property name length used + * max property count + */ +#define CPR_MAXPLEN 15 +#define CPR_MAXPROP 5 + +/* + * name/value of nvram properties + */ +struct cpr_prop_info { + char mod; + char name[CPR_MAXPLEN]; + char value[OBP_MAXPATHLEN]; +}; +typedef struct cpr_prop_info cprop_t; + +struct cpr_default_mini { + int magic; /* magic word for booter */ + int reusable; /* true if resuable statefile */ +}; +typedef struct cpr_default_mini cmini_t; + +struct cpr_default_info { + cmini_t mini; + cprop_t props[CPR_MAXPROP]; /* nvram property info */ +}; +typedef struct cpr_default_info cdef_t; + + +/* + * Configuration info provided by user via pmconfig. + * + * The first part (cf_type, cf_path, cf_fs, cf_devfs, cf_dev_prom) + * is used by both the cpr kernel module and cpr booter program + * to locate the statefile. + * + * cf_type CFT_UFS + * cf_path (path within file system) ".CPR" + * cf_fs (mount point for the statefile's filesystem) "/export/home" + * cf_devfs (devfs path of disk parition mounted there) "/dev/dsk/c0t0d0s7" + * cf_dev_prom (prom device path of the above disk partition) + * "/sbus/espdma/dma/sd@0:h" + * + * If the statefile were on a character special device (/dev//rdsk/c0t1d0s7), + * the fields would have the typical values shown below: + * + * cf_type CFT_SPEC + * cf_path ignored + * cf_fs ignored + * cf_devfs /dev/rdsk/c1t0d0s7 + * cf_dev_prom (prom device path of the above special file) + * "/sbus/espdma/dma/sd@1:h" + * + * If the statefile is on a zvol, the fields would have these values: + * + * cf_type CFT_ZVOL + * cf_path ignored + * cf_fs (the zvol name e.g. "dump" portion of rootpool/dump) + * cf_devfs (devfs path) "/dev/zvol/dsk//" + * cf_dev_prom (prom device path of the above special file) + * e.g. "/sbus/espdma/dma/sd@1:h" + * + * The rest of the fields are autoshutdown and autopm configuration related. + * They are updated by pmconfig and consumed by both powerd and dtpower. + */ + +struct cprconfig { + int cf_magic; /* magic word for */ + /* booter to verify */ + int cf_type; /* CFT_UFS or CFT_SPEC */ + char cf_path[MAXNAMELEN]; /* fs-relative path */ + /* for the state file */ + char cf_fs[MAXNAMELEN]; /* mount point for fs */ + /* holding state file */ + char cf_devfs[MAXNAMELEN]; /* path to device node */ + /* for above mount pt. */ + char cf_dev_prom[OBP_MAXPATHLEN]; /* full device path of */ + /* above filesystem */ + /* + * autoshutdown configuration fields + */ + int is_cpr_capable; /* 0 - False, 1 - True */ + int is_cpr_default; /* 0 - False, 1 - True */ + int is_autowakeup_capable; /* 0 - False, 1 - True */ + int as_idle; /* idle time in min */ + int as_sh; /* Start_time hour */ + int as_sm; /* Start_time minutes */ + int as_fh; /* Finish_time hour */ + int as_fm; /* Finish_time minute */ + char as_behavior[64]; /* "default","unconfigured", */ + /* "shutdown", "autowakeup" */ + /* or "noshutdown" */ + int ttychars_thold; /* default = 0 */ + float loadaverage_thold; /* default = 0.04 */ + int diskreads_thold; /* default = 0 */ + int nfsreqs_thold; /* default = 0 */ + char idlecheck_path[MAXPATHLEN]; /* default = "" */ + + /* + * autopm behavior field + */ + int is_autopm_default; /* 0 - False, 1 - True */ + char apm_behavior[64]; /* "enable","disable" or */ + /* "default" */ +}; + + +/* + * values for cf_type + */ +#define CFT_UFS 1 /* statefile is ufs file */ +#define CFT_SPEC 2 /* statefile is special file */ +#define CFT_ZVOL 3 /* statefile is a zvol */ + + +/* + * definitions for kernel, cprboot + */ +#ifdef _KERNEL + +#include +#include +#include +#include +#include + +extern int cpr_debug; + +#define errp prom_printf +#define DPRINT + +/* + * CPR_DEBUG1 displays the main flow of CPR. Use it to identify which + * sub-module of CPR causes problems. + * CPR_DEBUG2 displays minor stuff that normally won't matter. + * CPR_DEBUG3 displays some big loops (cpr_dump); requires much longer runtime. + * CPR_DEBUG4 displays lots of cprboot output, cpr_read and page handling. + * CPR_DEBUG5 various, mostly unique stuff + * CPR_DEBUG9 displays statistical data for CPR on console (by using printf), + * such as num page invalidated, etc. + */ +#define CPR_DEBUG1 0x1 +#define CPR_DEBUG2 0x2 +#define CPR_DEBUG3 0x4 +#define CPR_DEBUG4 0x8 +#define CPR_DEBUG5 0x10 +#define CPR_DEBUG6 0x20 +#define CPR_DEBUG7 0x40 +#define CPR_DEBUG8 0x80 +#define CPR_DEBUG9 CPR_DEBUG6 + +#define CPR_DEBUG(level, ...) if (cpr_debug & level) cpr_dprintf(__VA_ARGS__) + +#define CPR_DEBUG_BIT(dval) (1 << (dval - AD_CPR_DEBUG0 - 1)) +#define DBG_DONTSHOWRANGE 0 +#define DBG_SHOWRANGE 1 + +/* + * CPR FILE FORMAT: + * + * Dump Header: general dump data: + * cpr_dump_desc + * + * Machdep descriptor: cpr_machdep_desc + * Machdep data: sun4m/sun4u machine dependent info: + * cpr_sun4m_machdep + * cpr_sun4u_machdep, var length prom words + * + * Page Map: bitmap record consisting of a descriptor and data: + * cpr_bitmap_desc + * (char) bitmap[cpr_bitmap_desc.cbd_size] + * + * Page data: Contains one or more physical page records, + * each record consists of a descriptor and data: + * cpr_page_desc + * (char) page_data[cpr_page_desc.cpd_offset] + * + * Terminator: end marker + * cpr_terminator + * + * NOTE: cprboot now supports both ILP32 and LP64 kernels; + * the size of these structures written to a cpr statefile + * must be the same for ILP32 and LP64. For details, see + * sun4u/sys/cpr_impl.h + */ + +#define CPR_DUMP_MAGIC 0x44754d70 /* 'DuMp' */ +#define CPR_BITMAP_MAGIC 0x42744d70 /* 'BtMp' */ +#define CPR_PAGE_MAGIC 0x50614765 /* 'PaGe' */ +#define CPR_MACHDEP_MAGIC 0x4d614470 /* 'MaDp' */ +#define CPR_TERM_MAGIC 0x5465526d /* 'TeRm' */ + +/* + * header at the begining of the dump data section + */ +struct cpr_dump_desc { + uint_t cdd_magic; /* paranoia check */ + ushort_t cdd_version; /* version number */ + ushort_t cdd_machine; /* sun4m, sun4u */ + int cdd_bitmaprec; /* number of bitmap records */ + int cdd_dumppgsize; /* total # of frames dumped, in pages */ + int cdd_test_mode; /* true if called by uadmin test mode */ + int cdd_debug; /* turn on debug in cprboot */ + cpr_ext cdd_filesize; /* statefile size in bytes */ +}; +typedef struct cpr_dump_desc cdd_t; + +/* + * physical memory bitmap descriptor, preceeds the actual bitmap. + */ +struct cpr_bitmap_desc { + uint_t cbd_magic; /* so we can spot it better */ + pfn_t cbd_spfn; /* starting pfn */ + pfn_t cbd_epfn; /* ending pfn */ + size_t cbd_size; /* size of this bitmap, in bytes */ + cpr_ptr cbd_reg_bitmap; /* regular bitmap */ + cpr_ptr cbd_vlt_bitmap; /* volatile bitmap */ + cpr_ptr cbd_auxmap; /* aux bitmap used during thaw */ +}; +typedef struct cpr_bitmap_desc cbd_t; + +/* + * Maximum supported bitmap descriptors; 1-2 + null-terminator is common + */ +#define CPR_MAX_BMDESC (16 + 1) + +/* + * Describes the contiguous pages saved in the storage area. + * To save space data will be compressed before saved. + * However some data end up bigger after compression. + * In that case, we save the raw data and make a note + * of it in the csd_clean_compress field. + */ +struct cpr_storage_desc { + pfn_t csd_dirty_spfn; /* starting dirty pfn */ + pgcnt_t csd_dirty_npages; + cpr_ptr csd_clean_sva; /* starting clean va */ + size_t csd_clean_sz; + int csd_clean_compressed; +#ifdef DEBUG + uint_t csd_usum; + uint_t csd_csum; +#endif +}; +typedef struct cpr_storage_desc csd_t; + +/* + * Describes saved pages, preceeds page data; + * cpd_lenth len is important when pages are compressed. + */ +struct cpr_page_desc { + uint_t cpd_magic; /* so we can spot it better */ + pfn_t cpd_pfn; /* kern physical address page # */ + pgcnt_t cpd_pages; /* number of contiguous pages */ + size_t cpd_length; /* data segment size in bytes */ + uint_t cpd_flag; /* see below */ + uint_t cpd_csum; /* "after compression" checksum */ + uint_t cpd_usum; /* "before compression" checksum */ +}; +typedef struct cpr_page_desc cpd_t; + +/* + * cpd_flag values + */ +#define CPD_COMPRESS 0x0001 /* set if compressed */ +#define CPD_CSUM 0x0002 /* set if "after compression" checsum valid */ +#define CPD_USUM 0x0004 /* set if "before compression" checsum valid */ + +/* + * machdep header stores the length of the platform specific information + * that are used by resume. + * + * Note: the md_size field is the total length of the machine dependent + * information. This always includes a fixed length section and may + * include a variable length section following it on some platforms. + */ +struct cpr_machdep_desc { + uint_t md_magic; /* paranoia check */ + uint_t md_size; /* the size of the "opaque" data following */ +}; +typedef struct cpr_machdep_desc cmd_t; + +typedef struct timespec32 cpr_time_t; + +struct cpr_terminator { + uint_t magic; /* paranoia check */ + size_t real_statef_size; /* ...in bytes */ + cpr_ptr va; /* virtual addr of this struct */ + cpr_ext pfn; /* phys addr of this struct */ + cpr_time_t tm_shutdown; /* time in milisec when shutdown */ + cpr_time_t tm_cprboot_start; /* time when cprboot starts to run */ + cpr_time_t tm_cprboot_end; /* time before jumping to kernel */ +}; +typedef struct cpr_terminator ctrm_t; + + +#define REGULAR_BITMAP 1 +#define VOLATILE_BITMAP 0 + +/* + * reference the right bitmap based on the arg descriptor and flag + */ +#define DESC_TO_MAP(desc, flag) (flag == REGULAR_BITMAP) ? \ + (char *)desc->cbd_reg_bitmap : (char *)desc->cbd_vlt_bitmap +/* + * checks if a phys page is within the range covered by a bitmap + */ +#define PPN_IN_RANGE(ppn, desc) \ + (ppn <= desc->cbd_epfn && ppn >= desc->cbd_spfn) + +#define WRITE_TO_STATEFILE 0 +#define SAVE_TO_STORAGE 1 +#define STORAGE_DESC_ALLOC 2 + + +/* + * prom_read() max is 32k + * for sun4m, page size is 4k, CPR_MAXCONTIG is 8 + * for sun4u, page size is 8k, CPR_MAXCONTIG is 4 + */ +#define PROM_MAX_READ 0x8000 +#define CPR_MAX_BLOCK 0x8000 +#define CPR_MAXCONTIG (CPR_MAX_BLOCK / MMU_PAGESIZE) + +#define PAGE_ROUNDUP(val) (((val) + MMU_PAGEOFFSET) & MMU_PAGEMASK) + +/* + * converts byte size to bitmap size; 1 bit represents one phys page + */ +#define BITMAP_BYTES(size) ((size) >> (MMU_PAGESHIFT + 3)) + + +/* + * redefinitions of uadmin subcommands for A_FREEZE + */ +#define AD_CPR_COMPRESS AD_COMPRESS /* store state file compressed */ +#define AD_CPR_FORCE AD_FORCE /* force to do AD_CPR_COMPRESS */ +#define AD_CPR_CHECK AD_CHECK /* test if CPR module is there */ +#define AD_CPR_REUSEINIT AD_REUSEINIT /* write cprinfo file */ +#define AD_CPR_REUSABLE AD_REUSABLE /* create reusable statefile */ +#define AD_CPR_REUSEFINI AD_REUSEFINI /* revert to non-reusable CPR */ +#define AD_CPR_TESTHALT 6 /* test mode, halt */ +#define AD_CPR_TESTNOZ 7 /* test mode, auto-restart uncompress */ +#define AD_CPR_TESTZ 8 /* test mode, auto-restart compress */ +#define AD_CPR_PRINT 9 /* print out stats */ +#define AD_CPR_NOCOMPRESS 10 /* store state file uncompressed */ +#define AD_CPR_SUSP_DEVICES 11 /* Only suspend resume devices */ +#define AD_CPR_DEBUG0 100 /* clear debug flag */ +#define AD_CPR_DEBUG1 101 /* display CPR main flow via prom */ +#define AD_CPR_DEBUG2 102 /* misc small/mid size loops */ +#define AD_CPR_DEBUG3 103 /* exhaustive big loops */ +#define AD_CPR_DEBUG4 104 /* debug cprboot */ +#define AD_CPR_DEBUG5 105 /* debug machdep part of resume */ +#define AD_CPR_DEBUG7 107 /* debug bitmap code */ +#define AD_CPR_DEBUG8 108 +#define AD_CPR_DEBUG9 109 /* display stat data on console */ + +/* + * Suspend to RAM test points. + * Probably belong above, but are placed here for now. + */ +/* S3 leave hardware on and return success */ +#define AD_LOOPBACK_SUSPEND_TO_RAM_PASS 22 + +/* S3 leave hardware on and return failure */ +#define AD_LOOPBACK_SUSPEND_TO_RAM_FAIL 23 + +/* S3 ignored devices that fail to suspend */ +#define AD_FORCE_SUSPEND_TO_RAM 24 + +/* S3 on a specified device */ +#define AD_DEVICE_SUSPEND_TO_RAM 25 + + + +/* + * Temporary definition of the Suspend to RAM development subcommands + * so that non-ON apps will work after initial integration. + */ +#define DEV_SUSPEND_TO_RAM 200 +#define DEV_CHECK_SUSPEND_TO_RAM 201 + +/* + * cprboot related information and definitions. + * The statefile names are hardcoded for now. + */ +#define CPR_DEFAULT "/.cpr_default" +#define CPR_STATE_FILE "/.CPR" + + +/* + * definitions for CPR statistics + */ +#define CPR_E_NAMELEN 64 +#define CPR_E_MAX_EVENTNUM 64 + +struct cpr_tdata { + time_t mtime; /* mean time on this event */ + time_t stime; /* start time on this event */ + time_t etime; /* end time on this event */ + time_t ltime; /* time duration of the last event */ +}; +typedef struct cpr_tdata ctd_t; + +struct cpr_event { + struct cpr_event *ce_next; /* next event in the list */ + long ce_ntests; /* num of the events since loaded */ + ctd_t ce_sec; /* cpr time in sec on this event */ + ctd_t ce_msec; /* cpr time in 100*millisec */ + char ce_name[CPR_E_NAMELEN]; +}; + +struct cpr_stat { + int cs_ntests; /* num of cpr's since loaded */ + int cs_mclustsz; /* average cluster size: all in bytes */ + int cs_upage2statef; /* actual # of upages gone to statef */ + int cs_min_comprate; /* minimum compression ratio * 100 */ + pgcnt_t cs_nosw_pages; /* # of pages of no backing store */ + size_t cs_nocomp_statefsz; /* statefile size without compression */ + size_t cs_est_statefsz; /* estimated statefile size */ + size_t cs_real_statefsz; /* real statefile size */ + size_t cs_dumped_statefsz; /* how much has been dumped out */ + struct cpr_event *cs_event_head; /* The 1st one in stat event list */ + struct cpr_event *cs_event_tail; /* The last one in stat event list */ +}; + +/* + * macros for CPR statistics evaluation + */ +#define CPR_STAT_EVENT_START(s) cpr_stat_event_start(s, 0) +#define CPR_STAT_EVENT_END(s) cpr_stat_event_end(s, 0) +/* + * use the following is other time zone is required + */ +#define CPR_STAT_EVENT_START_TMZ(s, t) cpr_stat_event_start(s, t) +#define CPR_STAT_EVENT_END_TMZ(s, t) cpr_stat_event_end(s, t) + +#define CPR_STAT_EVENT_PRINT cpr_stat_event_print + + +/* + * State Structure for CPR + */ +typedef struct cpr { + uint_t c_cprboot_magic; + uint_t c_flags; + int c_substate; /* tracking suspend progress */ + int c_fcn; /* uadmin subcommand */ + vnode_t *c_vp; /* vnode for statefile */ + cbd_t *c_bmda; /* bitmap descriptor array */ + caddr_t c_mapping_area; /* reserve for dumping kas phys pages */ + struct cpr_stat c_stat; + char c_alloc_cnt; /* # of statefile alloc retries */ +} cpr_t; + +/* + * c_flags definitions + */ +#define C_SUSPENDING 0x01 +#define C_RESUMING 0x02 +#define C_COMPRESSING 0x04 +#define C_REUSABLE 0x08 +#define C_ERROR 0x10 + +extern cpr_t cpr_state; +#define CPR (&cpr_state) +#define STAT (&cpr_state.c_stat) + +/* + * definitions for c_substate. It works together w/ c_flags to determine which + * stages the CPR is at. + */ +#define C_ST_SUSPEND_BEGIN 0 +#define C_ST_MP_OFFLINE 1 +#define C_ST_STOP_USER_THREADS 2 +#define C_ST_PM_REATTACH_NOINVOL 3 +#define C_ST_DISABLE_UFS_LOGGING 4 +#define C_ST_STATEF_ALLOC 5 +#define C_ST_SUSPEND_DEVICES 6 +#define C_ST_STOP_KERNEL_THREADS 7 +#define C_ST_SETPROPS_1 8 +#define C_ST_DUMP 9 +#define C_ST_SETPROPS_0 10 +#define C_ST_DUMP_NOSPC 11 +#define C_ST_REUSABLE 12 +#define C_ST_NODUMP 13 +#define C_ST_MP_PAUSED 14 + +#define cpr_set_substate(a) (CPR->c_substate = (a)) + +#define C_VP (CPR->c_vp) + +#define C_MAX_ALLOC_RETRY 4 + +#define CPR_PROM_SAVE 0 +#define CPR_PROM_RESTORE 1 +#define CPR_PROM_FREE 2 + +/* + * default/historic size for cpr write buffer + */ +#define CPRBUFSZ 0x20000 + +/* + * cpr statefile I/O on a block device begins after the disk label + * and bootblock (primarily for disk slices that start at cyl 0); + * the offset should be at least (label size + bootblock size = 8k) + */ +#define CPR_SPEC_OFFSET 16384 + +typedef int (*bitfunc_t)(pfn_t, int); + +/* + * arena scan info + */ +struct cpr_walkinfo { + int mapflag; + bitfunc_t bitfunc; + pgcnt_t pages; + size_t size; + int ranges; +}; + +/* + * Value used by cpr, found in devi_cpr_flags + */ +#define DCF_CPR_SUSPENDED 0x1 /* device went through cpr_suspend */ + +/* + * Values used to differentiate between suspend to disk and suspend to ram + * in cpr_suspend and cpr_resume + */ + +#define CPR_TORAM 3 +#define CPR_TODISK 4 + +#ifndef _ASM + +extern char *cpr_build_statefile_path(void); +extern char *cpr_enumerate_promprops(char **, size_t *); +extern char *cpr_get_statefile_prom_path(void); +extern int cpr_contig_pages(vnode_t *, int); +extern int cpr_default_setup(int); +extern int cpr_dump(vnode_t *); +extern int cpr_get_reusable_mode(void); +extern int cpr_isset(pfn_t, int); +extern int cpr_main(int); +extern int cpr_mp_offline(void); +extern int cpr_mp_online(void); +extern int cpr_nobit(pfn_t, int); +extern int cpr_open_deffile(int, vnode_t **); +extern int cpr_read_cdump(int, cdd_t *, ushort_t); +extern int cpr_read_cprinfo(int, char *, char *); +extern int cpr_read_machdep(int, caddr_t, size_t); +extern int cpr_read_phys_page(int, uint_t, int *); +extern int cpr_read_terminator(int, ctrm_t *, caddr_t); +extern int cpr_resume_devices(dev_info_t *, int); +extern int cpr_set_properties(int); +extern int cpr_statefile_is_spec(void); +extern int cpr_statefile_offset(void); +extern int cpr_stop_kernel_threads(void); +extern int cpr_threads_are_stopped(void); +extern int cpr_stop_user_threads(void); +extern int cpr_suspend_devices(dev_info_t *); +extern int cpr_validate_definfo(int); +extern int cpr_write(vnode_t *, caddr_t, size_t); +extern int cpr_update_nvram(cprop_t *); +extern int cpr_write_deffile(cdef_t *); +extern int i_cpr_alloc_bitmaps(void); +extern int i_cpr_dump_sensitive_kpages(vnode_t *); +extern int i_cpr_save_sensitive_kpages(void); +extern pgcnt_t cpr_count_kpages(int, bitfunc_t); +extern pgcnt_t cpr_count_pages(caddr_t, size_t, int, bitfunc_t, int); +extern pgcnt_t cpr_count_volatile_pages(int, bitfunc_t); +extern pgcnt_t i_cpr_count_sensitive_kpages(int, bitfunc_t); +extern pgcnt_t i_cpr_count_special_kpages(int, bitfunc_t); +extern pgcnt_t i_cpr_count_storage_pages(int, bitfunc_t); +extern ssize_t cpr_get_machdep_len(int); +extern void cpr_clear_definfo(void); +extern void cpr_restore_time(void); +extern void cpr_save_time(void); +extern void cpr_show_range(char *, size_t, int, bitfunc_t, pgcnt_t); +extern void cpr_signal_user(int sig); +extern void cpr_spinning_bar(void); +extern void cpr_start_user_threads(void); +extern void cpr_stat_cleanup(void); +extern void cpr_stat_event_end(char *, cpr_time_t *); +extern void cpr_stat_event_print(void); +extern void cpr_stat_event_start(char *, cpr_time_t *); +extern void cpr_stat_record_events(void); +extern void cpr_tod_get(cpr_time_t *ctp); +extern void cpr_tod_status_set(int); +extern void i_cpr_bitmap_cleanup(void); +extern void i_cpr_stop_other_cpus(void); +extern void i_cpr_alloc_cpus(void); +extern void i_cpr_free_cpus(void); + +/*PRINTFLIKE2*/ +extern void cpr_err(int, const char *, ...) __KPRINTFLIKE(2); + +extern cpr_time_t wholecycle_tv; +extern int cpr_reusable_mode; + +#endif /* _ASM */ +#endif /* _KERNEL */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPR_H */ diff --git a/illumos-x86_64/usr/include/sys/cpu.h b/illumos-x86_64/usr/include/sys/cpu.h new file mode 100644 index 00000000..20f9e029 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpu.h @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CPU_H +#define _SYS_CPU_H + +/* + * WARNING: + * This header file is Obsolete and may be deleted in a + * future release of Solaris. + */ + +/* + * Include generic bustype cookies. + */ +#include +#include + +#if defined(_KERNEL) +#if defined(__xpv) +#include +#endif +#if defined(__GNUC__) && defined(_ASM_INLINES) +#include +#endif +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) +extern void ht_pause(void); +extern void cli(void); +extern void sti(void); +extern void i86_halt(void); +extern void i86_monitor(volatile uint32_t *addr, uint32_t extensions, + uint32_t hints); +extern void i86_mwait(uint32_t data, uint32_t extensions); + +/* + * Used to insert cpu-dependent instructions into spin loops + */ +#define SMT_PAUSE() ht_pause() + +/* + * + * C-state defines for the idle_state_transition DTrace probe + * + * The probe fires when the CPU undergoes an idle state change (e.g. C-state) + * The argument passed is the C-state to which the CPU is transitioning. + * + * These states will be shared by cpupm subsystem, so they should be kept in + * consistence with ACPI defined C states. + */ +#define IDLE_STATE_C0 0 +#define IDLE_STATE_C1 1 +#define IDLE_STATE_C2 2 +#define IDLE_STATE_C3 3 + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPU_H */ diff --git a/illumos-x86_64/usr/include/sys/cpu_uarray.h b/illumos-x86_64/usr/include/sys/cpu_uarray.h new file mode 100644 index 00000000..9cad7725 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpu_uarray.h @@ -0,0 +1,81 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2018, Joyent, Inc. + */ + +/* + * Use a cpu_uarray_t for an array of uint64_t values that are written on a + * per-CPU basis. We align each CPU on a 128-byte boundary (so two cachelines). + * It's not clear why, but this can have a significant effect in multi-socket + * systems running certain benchmarks on a relatively current Intel system. + * + * So the layout is like this, for example: + * + * 0: STAT1 for CPU 0 + * 8: STAT2 for CPU 0 + * 16: STAT3 for CPU 0 + * 24: padding + * 128: STAT1 for CPU 1 + * 136: STAT2 for CPU 1 + * ... + * + * At collection time, cpu_uarray_sum() can be used to sum the given value index + * across all CPUs, or cpu_uarray_sum_all() sums all stats across all CPUs. + * The summation is done such that it saturates at UINT64_MAX. + */ + +#ifndef _SYS_CPU_UARRAY_H +#define _SYS_CPU_UARRAY_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Trying to include sysmacros.h for P2ROUNDUP() here is just too painful. + */ +#define CUA_ROUNDUP(x, align) (-(-(x) & -(align))) +#define CUA_ALIGN (128) +#define CUA_CPU_STRIDE(nr_items) \ + CUA_ROUNDUP((nr_items), CUA_ALIGN / sizeof (uint64_t)) +#define CUA_INDEX(nr_items, c, i) (((c) * CUA_CPU_STRIDE(nr_items)) + (i)) + +#define CPU_UARRAY_VAL(cua, cpu_index, stat_index) \ + ((cua)->cu_vals[CUA_INDEX((cua)->cu_nr_items, cpu_index, stat_index)]) + +typedef struct { + uint64_t cu_nr_items; + char cu_pad[CUA_ALIGN - sizeof (uint64_t)]; +#ifdef __lint + volatile uint64_t cu_vals[1]; +#else + volatile uint64_t cu_vals[]; +#endif +} cpu_uarray_t __aligned(CUA_ALIGN); + +extern cpu_uarray_t *cpu_uarray_zalloc(size_t, int); +extern void cpu_uarray_free(cpu_uarray_t *); +extern uint64_t cpu_uarray_sum(cpu_uarray_t *, size_t); +extern uint64_t cpu_uarray_sum_all(cpu_uarray_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPU_UARRAY_H */ diff --git a/illumos-x86_64/usr/include/sys/cpucaps.h b/illumos-x86_64/usr/include/sys/cpucaps.h new file mode 100644 index 00000000..18e92381 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpucaps.h @@ -0,0 +1,155 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CPUCAPS_H +#define _SYS_CPUCAPS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +/* + * CPU caps provide an absolute hard CPU usage limit which is enforced even if + * some CPUs are idle. It can be enforced at project or zone level. + */ + +#ifdef _KERNEL + +/* + * Valid caps values go from 1 to MAXCAP - 1. Specifying the MAXCAP as the cap + * value is equivalent to disabling the cap. + */ +#define MAXCAP UINT_MAX + +/* + * cpucaps_enabled is used to quickly check whether any CPU caps specific code + * should be invoked. Users outside CPU Caps framework should use CPUCAPS_ON() + * and CPUCAPS_OFF() macros. + */ +extern boolean_t cpucaps_enabled; + +#define CPUCAPS_ON() cpucaps_enabled +#define CPUCAPS_OFF() (!cpucaps_enabled) + +/* + * Initialize the CPU caps framework. + */ +extern void cpucaps_init(void); + +/* + * Notify caps framework of a new project coming in or existing project + * going away + */ +extern void cpucaps_project_add(kproject_t *); +extern void cpucaps_project_remove(kproject_t *); + +/* + * Notify caps framework when a zone is going away. + */ +extern void cpucaps_zone_remove(zone_t *); + +/* + * Set project/zone cap to specified value. Value of MAXCAP should disable caps. + */ +extern int cpucaps_project_set(kproject_t *, rctl_qty_t); +extern int cpucaps_zone_set(zone_t *, rctl_qty_t); + +/* + * Get current CPU usage for a project/zone. + */ +extern rctl_qty_t cpucaps_project_get(kproject_t *); +extern rctl_qty_t cpucaps_zone_get(zone_t *); + +/* + * Scheduling class hooks into CPU caps framework. + */ + +/* + * CPU caps specific data for each scheduling class. + * + * There is a small amount of accounting data that should be kept by each + * scheduling class for each thread which is only used by CPU caps code. This + * data is kept in the caps_sc structure which is transparent for all scheduling + * classes. The fields in the structure are: + * + * csc_cputime - Total time spent on CPU during thread lifetime, obtained + * as the sum of user, system and trap time, reported by + * microstate accounting. + */ +typedef struct caps_sc { + hrtime_t csc_cputime; +} caps_sc_t; + +/* + * Initialize per-thread cpu-caps specific data. + */ +extern void cpucaps_sc_init(caps_sc_t *); + +/* + * Modus operandi for cpucaps_charge() function. + * + * CPUCAPS_CHARGE_ENFORCE - charge a thread for its CPU time and + * flag it to be placed on wait queue. + * + * CPUCAPS_CHARGE_ONLY - charge a thread for its CPU time. + */ +typedef enum { + CPUCAPS_CHARGE_ENFORCE, + CPUCAPS_CHARGE_ONLY +} cpucaps_charge_t; + +/* + * Add accumulated CPU usage of a thread to its cap. + * Return True if thread should be placed on waitq. + */ +extern boolean_t cpucaps_charge(kthread_t *, caps_sc_t *, cpucaps_charge_t); +#define CPUCAPS_CHARGE(t, scp, flag) \ + (CPUCAPS_ON() && cpucaps_charge(t, scp, flag)) + +/* + * Request a thread to be placed on a wait queue because the cap is exceeded + */ +extern boolean_t cpucaps_enforce(kthread_t *); +#define CPUCAPS_ENFORCE(t) (CPUCAPS_ON() && cpucaps_enforce(t)) + +/* + * CPU Caps hook into clock(). + */ +extern void (*cpucaps_clock_callout)(void); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPUCAPS_H */ diff --git a/illumos-x86_64/usr/include/sys/cpucaps_impl.h b/illumos-x86_64/usr/include/sys/cpucaps_impl.h new file mode 100644 index 00000000..95afd218 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpucaps_impl.h @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CPUCAPS_IMPL_H +#define _SYS_CPUCAPS_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include +#include +#include +#include +#include + +/* + * When resource control framework sets the cap to NOCAP value the cap + * is disabled. + */ +#define NOCAP MAXCAP + +/* + * Maximum value for the cap usage. Should be the maximum value for hrtime_t + */ +#if defined(_LP64) +#define MAX_USAGE LONG_MAX +#else +#define MAX_USAGE 9223372036854775807LL +#endif + + +/* + * Most of the per-project or per-zone state related to CPU caps is kept in the + * cpucap_t structure. + */ +typedef struct cpucap { + list_node_t cap_link; /* next/prev capped entity */ + struct kproject *cap_project; /* project for the cap */ + struct zone *cap_zone; /* zone for the cap */ + waitq_t cap_waitq; /* waitq for capped threads */ + kstat_t *cap_kstat; /* cpucaps specific kstat */ + int64_t cap_gen; /* zone cap specific */ + hrtime_t cap_value; /* scaled CPU usage cap */ + hrtime_t cap_usage; /* current CPU usage */ + disp_lock_t cap_usagelock; /* protects cap_usage above */ + /* + * Per cap statistics. + */ + hrtime_t cap_maxusage; /* maximum cap usage */ + u_longlong_t cap_below; /* # of ticks spend below the cap */ + u_longlong_t cap_above; /* # of ticks spend above the cap */ +} cpucap_t; + +/* + * Wrapper macros for checking cap state. + */ +#define CAP_ENABLED(cap) ((cap)->cap_value != 0) +#define CAP_DISABLED(cap) (!CAP_ENABLED(cap)) + +#define PROJECT_IS_CAPPED(project) \ + (((project)->kpj_cpucap != NULL) && \ + CAP_ENABLED((project)->kpj_cpucap)) + +#define ZONE_IS_CAPPED(zone) \ + (((zone)->zone_cpucap != NULL) && \ + CAP_ENABLED((zone)->zone_cpucap)) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPUCAPS_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/cpupart.h b/illumos-x86_64/usr/include/sys/cpupart.h new file mode 100644 index 00000000..a91c989b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpupart.h @@ -0,0 +1,158 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 RackTop Systems. + */ + +#ifndef _SYS_CPUPART_H +#define _SYS_CPUPART_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +typedef int cpupartid_t; + +/* + * Special partition id. + */ +#define CP_DEFAULT 0 + +/* + * Flags for cpupart_list() + */ +#define CP_ALL 0 /* return all cpu partitions */ +#define CP_NONEMPTY 1 /* return only non-empty ones */ + +typedef struct cpupart { + disp_t cp_kp_queue; /* partition-wide kpreempt queue */ + cpupartid_t cp_id; /* partition ID */ + int cp_ncpus; /* number of online processors */ + struct cpupart *cp_next; /* next partition in list */ + struct cpupart *cp_prev; /* previous partition in list */ + struct cpu *cp_cpulist; /* processor list */ + struct kstat *cp_kstat; /* per-partition statistics */ + + /* + * cp_nrunnable and cp_nrunning are used to calculate load average. + */ + uint_t cp_nrunnable; /* current # of runnable threads */ + uint_t cp_nrunning; /* current # of running threads */ + + /* + * cp_updates, cp_nrunnable_cum, cp_nwaiting_cum, and cp_hp_avenrun + * are used to generate kstat information on an as-needed basis. + */ + uint64_t cp_updates; /* number of statistics updates */ + uint64_t cp_nrunnable_cum; /* cum. # of runnable threads */ + uint64_t cp_nwaiting_cum; /* cum. # of waiting threads */ + + struct loadavg_s cp_loadavg; /* cpupart loadavg */ + + klgrpset_t cp_lgrpset; /* set of lgroups on which this */ + /* partition has cpus */ + lpl_t *cp_lgrploads; /* table of load averages for this */ + /* partition, indexed by lgrp ID */ + int cp_nlgrploads; /* size of cp_lgrploads table */ + uint64_t cp_hp_avenrun[3]; /* high-precision load average */ + uint_t cp_attr; /* bitmask of attributes */ + lgrp_gen_t cp_gen; /* generation number */ + lgrp_id_t cp_lgrp_hint; /* last home lgroup chosen */ + bitset_t cp_cmt_pgs; /* CMT PGs represented */ + bitset_t cp_haltset; /* halted CPUs */ +} cpupart_t; + +typedef struct cpupart_kstat { + kstat_named_t cpk_updates; /* number of updates */ + kstat_named_t cpk_runnable; /* cum # of runnable threads */ + kstat_named_t cpk_waiting; /* cum # waiting for I/O */ + kstat_named_t cpk_ncpus; /* current # of CPUs */ + kstat_named_t cpk_avenrun_1min; /* 1-minute load average */ + kstat_named_t cpk_avenrun_5min; /* 5-minute load average */ + kstat_named_t cpk_avenrun_15min; /* 15-minute load average */ +} cpupart_kstat_t; + +/* + * Macro to obtain the maximum run priority for the global queue associated + * with given cpu partition. + */ +#define CP_MAXRUNPRI(cp) ((cp)->cp_kp_queue.disp_maxrunpri) + +/* + * This macro is used to determine if the given thread must surrender + * CPU to higher priority runnable threads on one of its dispatch queues. + * This should really be defined in but it is not because + * including there would cause recursive includes. + */ +#define DISP_MUST_SURRENDER(t) \ + ((DISP_MAXRUNPRI(t) > DISP_PRIO(t)) || \ + (CP_MAXRUNPRI(t->t_cpupart) > DISP_PRIO(t))) + +extern cpupart_t cp_default; +extern cpupart_t *cp_list_head; +extern uint_t cp_numparts; +extern uint_t cp_numparts_nonempty; + +/* + * Each partition contains a bitset that indicates which CPUs are halted and + * which ones are running. Given the growing number of CPUs in current and + * future platforms, it's important to fanout each CPU within its partition's + * haltset to prevent contention due to false sharing. The fanout factor + * is platform specific, and declared accordingly. + */ +extern uint_t cp_haltset_fanout; + +extern void cpupart_initialize_default(); +extern cpupart_t *cpupart_find(psetid_t); +extern int cpupart_create(psetid_t *); +extern int cpupart_destroy(psetid_t); +extern psetid_t cpupart_query_cpu(cpu_t *); +extern int cpupart_attach_cpu(psetid_t, cpu_t *, int); +extern int cpupart_get_cpus(psetid_t *, processorid_t *, uint_t *); +extern int cpupart_bind_thread(kthread_id_t, psetid_t, int, void *, + void *); +extern void cpupart_kpqalloc(pri_t); +extern int cpupart_get_loadavg(psetid_t, int *, int); +extern uint_t cpupart_list(psetid_t *, uint_t, int); +extern int cpupart_setattr(psetid_t, uint_t); +extern int cpupart_getattr(psetid_t, uint_t *); + +#endif /* _KERNEL || _FAKE_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPUPART_H */ diff --git a/illumos-x86_64/usr/include/sys/cpuvar.h b/illumos-x86_64/usr/include/sys/cpuvar.h new file mode 100644 index 00000000..24adbb74 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cpuvar.h @@ -0,0 +1,808 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright 2014 Igor Kozhukhov . + * Copyright 2017 RackTop Systems. + * Copyright 2019 Joyent, Inc. + * Copyright 2021 Oxide Computer Company + */ + +#ifndef _SYS_CPUVAR_H +#define _SYS_CPUVAR_H + +#include +#include /* has cpu_stat_t definition */ +#include +#include +#include /* has kcpc_ctx_t definition */ + +#include +#if (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP) +#include +#endif + +#include +#include +#include +#include +#include +#if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL) && \ + (defined(__i386) || defined(__amd64)) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct squeue_set_s; + +#define CPU_CACHE_COHERENCE_SIZE 64 + +/* + * For fast event tracing. + */ +struct ftrace_record; +typedef struct ftrace_data { + int ftd_state; /* ftrace flags */ + kmutex_t ftd_unused; /* ftrace buffer lock, unused */ + struct ftrace_record *ftd_cur; /* current record */ + struct ftrace_record *ftd_first; /* first record */ + struct ftrace_record *ftd_last; /* last record */ +} ftrace_data_t; + +struct cyc_cpu; +struct nvlist; + +/* + * Per-CPU data. + * + * Be careful adding new members: if they are not the same in all modules (e.g. + * change size depending on a #define), CTF uniquification can fail to work + * properly. Furthermore, this is transitive in that it applies recursively to + * all types pointed to by cpu_t. + */ +typedef struct cpu { + processorid_t cpu_id; /* CPU number */ + processorid_t cpu_seqid; /* sequential CPU id (0..ncpus-1) */ + volatile cpu_flag_t cpu_flags; /* flags indicating CPU state */ + struct cpu *cpu_self; /* pointer to itself */ + kthread_t *cpu_thread; /* current thread */ + kthread_t *cpu_idle_thread; /* idle thread for this CPU */ + kthread_t *cpu_pause_thread; /* pause thread for this CPU */ + klwp_id_t cpu_lwp; /* current lwp (if any) */ + klwp_id_t cpu_fpowner; /* currently loaded fpu owner */ + struct cpupart *cpu_part; /* partition with this CPU */ + struct lgrp_ld *cpu_lpl; /* pointer to this cpu's load */ + int cpu_cache_offset; /* see kmem.c for details */ + + /* + * Links to other CPUs. It is safe to walk these lists if + * one of the following is true: + * - cpu_lock held + * - preemption disabled via kpreempt_disable + * - PIL >= DISP_LEVEL + * - acting thread is an interrupt thread + * - all other CPUs are paused + */ + struct cpu *cpu_next; /* next existing CPU */ + struct cpu *cpu_prev; /* prev existing CPU */ + struct cpu *cpu_next_onln; /* next online (enabled) CPU */ + struct cpu *cpu_prev_onln; /* prev online (enabled) CPU */ + struct cpu *cpu_next_part; /* next CPU in partition */ + struct cpu *cpu_prev_part; /* prev CPU in partition */ + struct cpu *cpu_next_lgrp; /* next CPU in latency group */ + struct cpu *cpu_prev_lgrp; /* prev CPU in latency group */ + struct cpu *cpu_next_lpl; /* next CPU in lgrp partition */ + struct cpu *cpu_prev_lpl; + + struct cpu_pg *cpu_pg; /* cpu's processor groups */ + + void *cpu_reserved[4]; /* reserved for future use */ + + /* + * Scheduling variables. + */ + disp_t *cpu_disp; /* dispatch queue data */ + /* + * Note that cpu_disp is set before the CPU is added to the system + * and is never modified. Hence, no additional locking is needed + * beyond what's necessary to access the cpu_t structure. + */ + char cpu_runrun; /* scheduling flag - set to preempt */ + char cpu_kprunrun; /* force kernel preemption */ + pri_t cpu_chosen_level; /* priority at which cpu */ + /* was chosen for scheduling */ + kthread_t *cpu_dispthread; /* thread selected for dispatch */ + disp_lock_t cpu_thread_lock; /* dispatcher lock on current thread */ + uint8_t cpu_disp_flags; /* flags used by dispatcher */ + /* + * The following field is updated when ever the cpu_dispthread + * changes. Also in places, where the current thread(cpu_dispthread) + * priority changes. This is used in disp_lowpri_cpu() + */ + pri_t cpu_dispatch_pri; /* priority of cpu_dispthread */ + clock_t cpu_last_swtch; /* last time switched to new thread */ + + /* + * Interrupt data. + */ + caddr_t cpu_intr_stack; /* interrupt stack */ + kthread_t *cpu_intr_thread; /* interrupt thread list */ + uint_t cpu_intr_actv; /* interrupt levels active (bitmask) */ + int cpu_base_spl; /* priority for highest rupt active */ + + /* + * Statistics. + */ + cpu_stats_t cpu_stats; /* per-CPU statistics */ + struct kstat *cpu_info_kstat; /* kstat for cpu info */ + + uintptr_t cpu_profile_pc; /* kernel PC in profile interrupt */ + uintptr_t cpu_profile_upc; /* user PC in profile interrupt */ + uintptr_t cpu_profile_pil; /* PIL when profile interrupted */ + + ftrace_data_t cpu_ftrace; /* per cpu ftrace data */ + + clock_t cpu_deadman_counter; /* used by deadman() */ + uint_t cpu_deadman_countdown; /* used by deadman() */ + + kmutex_t cpu_cpc_ctxlock; /* protects context for idle thread */ + kcpc_ctx_t *cpu_cpc_ctx; /* performance counter context */ + + /* + * Configuration information for the processor_info system call. + */ + processor_info_t cpu_type_info; /* config info */ + time_t cpu_state_begin; /* when CPU entered current state */ + char cpu_cpr_flags; /* CPR related info */ + struct cyc_cpu *cpu_cyclic; /* per cpu cyclic subsystem data */ + struct squeue_set_s *cpu_squeue_set; /* per cpu squeue set */ + struct nvlist *cpu_props; /* pool-related properties */ + + krwlock_t cpu_ft_lock; /* DTrace: fasttrap lock */ + uintptr_t cpu_dtrace_caller; /* DTrace: caller, if any */ + hrtime_t cpu_dtrace_chillmark; /* DTrace: chill mark time */ + hrtime_t cpu_dtrace_chilled; /* DTrace: total chill time */ + uint64_t cpu_dtrace_probes; /* DTrace: total probes fired */ + hrtime_t cpu_dtrace_nsec; /* DTrace: ns in dtrace_probe */ + + volatile uint16_t cpu_mstate; /* cpu microstate */ + volatile uint16_t cpu_mstate_gen; /* generation counter */ + volatile hrtime_t cpu_mstate_start; /* cpu microstate start time */ + volatile hrtime_t cpu_acct[NCMSTATES]; /* cpu microstate data */ + hrtime_t cpu_intracct[NCMSTATES]; /* interrupt mstate data */ + hrtime_t cpu_waitrq; /* cpu run-queue wait time */ + struct loadavg_s cpu_loadavg; /* loadavg info for this cpu */ + + char *cpu_idstr; /* for printing and debugging */ + char *cpu_brandstr; /* for printing */ + + /* + * Sum of all device interrupt weights that are currently directed at + * this cpu. Cleared at start of interrupt redistribution. + */ + int32_t cpu_intr_weight; + void *cpu_vm_data; + + struct cpu_physid *cpu_physid; /* physical associations */ + + uint64_t cpu_curr_clock; /* current clock freq in Hz */ + char *cpu_supp_freqs; /* supported freqs in Hz */ + + uintptr_t cpu_cpcprofile_pc; /* kernel PC in cpc interrupt */ + uintptr_t cpu_cpcprofile_upc; /* user PC in cpc interrupt */ + + /* + * Interrupt load factor used by dispatcher & softcall + */ + hrtime_t cpu_intrlast; /* total interrupt time (nsec) */ + int cpu_intrload; /* interrupt load factor (0-99%) */ + + uint_t cpu_rotor; /* for cheap pseudo-random numbers */ + + struct cu_cpu_info *cpu_cu_info; /* capacity & util. info */ + + /* + * cpu_generation is updated whenever CPU goes on-line or off-line. + * Updates to cpu_generation are protected by cpu_lock. + * + * See CPU_NEW_GENERATION() macro below. + */ + volatile uint_t cpu_generation; /* tracking on/off-line */ + + /* + * New members must be added /before/ this member, as the CTF tools + * rely on this being the last field before cpu_m, so they can + * correctly calculate the offset when synthetically adding the cpu_m + * member in objects that do not have it. This fixup is required for + * uniquification to work correctly. + */ + uintptr_t cpu_m_pad; + +#if (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP) + struct machcpu cpu_m; /* per architecture info */ +#endif +} cpu_t; + +/* + * The cpu_core structure consists of per-CPU state available in any context. + * On some architectures, this may mean that the page(s) containing the + * NCPU-sized array of cpu_core structures must be locked in the TLB -- it + * is up to the platform to assure that this is performed properly. Note that + * the structure is sized to avoid false sharing. + */ +#define CPUC_SIZE (sizeof (uint16_t) + sizeof (uint8_t) + \ + sizeof (uintptr_t) + sizeof (kmutex_t)) +#define CPUC_PADSIZE CPU_CACHE_COHERENCE_SIZE - CPUC_SIZE + +typedef struct cpu_core { + uint16_t cpuc_dtrace_flags; /* DTrace flags */ + uint8_t cpuc_dcpc_intr_state; /* DCPC provider intr state */ + uint8_t cpuc_pad[CPUC_PADSIZE]; /* padding */ + uintptr_t cpuc_dtrace_illval; /* DTrace illegal value */ + kmutex_t cpuc_pid_lock; /* DTrace pid provider lock */ +} cpu_core_t; + +#ifdef _KERNEL +extern cpu_core_t cpu_core[]; +#endif /* _KERNEL */ + +/* + * CPU_ON_INTR() macro. Returns non-zero if currently on interrupt stack. + * Note that this isn't a test for a high PIL. For example, cpu_intr_actv + * does not get updated when we go through sys_trap from TL>0 at high PIL. + * getpil() should be used instead to check for PIL levels. + */ +#define CPU_ON_INTR(cpup) ((cpup)->cpu_intr_actv >> (LOCK_LEVEL + 1)) + +/* + * Check to see if an interrupt thread might be active at a given ipl. + * If so return true. + * We must be conservative--it is ok to give a false yes, but a false no + * will cause disaster. (But if the situation changes after we check it is + * ok--the caller is trying to ensure that an interrupt routine has been + * exited). + * This is used when trying to remove an interrupt handler from an autovector + * list in avintr.c. + */ +#define INTR_ACTIVE(cpup, level) \ + ((level) <= LOCK_LEVEL ? \ + ((cpup)->cpu_intr_actv & (1 << (level))) : (CPU_ON_INTR(cpup))) + +/* + * CPU_PSEUDO_RANDOM() returns a per CPU value that changes each time one + * looks at it. It's meant as a cheap mechanism to be incorporated in routines + * wanting to avoid biasing, but where true randomness isn't needed (just + * something that changes). + */ +#define CPU_PSEUDO_RANDOM() (CPU->cpu_rotor++) + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT) + +#define INTR_STACK_SIZE MAX(DEFAULTSTKSZ, PAGESIZE) + +/* MEMBERS PROTECTED BY "atomicity": cpu_flags */ + +/* + * Flags in the CPU structure. + * + * These are protected by cpu_lock (except during creation). + * + * Offlined-CPUs have three stages of being offline: + * + * CPU_ENABLE indicates that the CPU is participating in I/O interrupts + * that can be directed at a number of different CPUs. If CPU_ENABLE + * is off, the CPU will not be given interrupts that can be sent elsewhere, + * but will still get interrupts from devices associated with that CPU only, + * and from other CPUs. + * + * CPU_OFFLINE indicates that the dispatcher should not allow any threads + * other than interrupt threads to run on that CPU. A CPU will not have + * CPU_OFFLINE set if there are any bound threads (besides interrupts). + * + * CPU_QUIESCED is set if p_offline was able to completely turn idle the + * CPU and it will not have to run interrupt threads. In this case it'll + * stay in the idle loop until CPU_QUIESCED is turned off. + * + * CPU_FROZEN is used only by CPR to mark CPUs that have been successfully + * suspended (in the suspend path), or have yet to be resumed (in the resume + * case). + * + * CPU_DISABLED is used for disabling SMT. It is similar to CPU_OFFLINE, but + * cannot be onlined without being forced. + * + * On some platforms CPUs can be individually powered off. + * The following flags are set for powered off CPUs: CPU_QUIESCED, + * CPU_OFFLINE, and CPU_POWEROFF. The following flags are cleared: + * CPU_RUNNING, CPU_READY, CPU_EXISTS, CPU_DISABLED and CPU_ENABLE. + */ +#define CPU_RUNNING 0x001 /* CPU running */ +#define CPU_READY 0x002 /* CPU ready for cross-calls */ +#define CPU_QUIESCED 0x004 /* CPU will stay in idle */ +#define CPU_EXISTS 0x008 /* CPU is configured */ +#define CPU_ENABLE 0x010 /* CPU enabled for interrupts */ +#define CPU_OFFLINE 0x020 /* CPU offline via p_online */ +#define CPU_POWEROFF 0x040 /* CPU is powered off */ +#define CPU_FROZEN 0x080 /* CPU is frozen via CPR suspend */ +#define CPU_SPARE 0x100 /* CPU offline available for use */ +#define CPU_FAULTED 0x200 /* CPU offline diagnosed faulty */ +#define CPU_DISABLED 0x400 /* CPU explicitly disabled (HT) */ + +#define CPU_ACTIVE(cpu) (((cpu)->cpu_flags & CPU_OFFLINE) == 0) + +/* + * Flags for cpu_offline(), cpu_faulted(), and cpu_spare(). + */ +#define CPU_FORCED 0x0001 /* Force CPU offline */ + +/* + * DTrace flags. + */ +#define CPU_DTRACE_NOFAULT 0x0001 /* Don't fault */ +#define CPU_DTRACE_DROP 0x0002 /* Drop this ECB */ +#define CPU_DTRACE_BADADDR 0x0004 /* DTrace fault: bad address */ +#define CPU_DTRACE_BADALIGN 0x0008 /* DTrace fault: bad alignment */ +#define CPU_DTRACE_DIVZERO 0x0010 /* DTrace fault: divide by zero */ +#define CPU_DTRACE_ILLOP 0x0020 /* DTrace fault: illegal operation */ +#define CPU_DTRACE_NOSCRATCH 0x0040 /* DTrace fault: out of scratch */ +#define CPU_DTRACE_KPRIV 0x0080 /* DTrace fault: bad kernel access */ +#define CPU_DTRACE_UPRIV 0x0100 /* DTrace fault: bad user access */ +#define CPU_DTRACE_TUPOFLOW 0x0200 /* DTrace fault: tuple stack overflow */ +#if defined(__sparc) +#define CPU_DTRACE_FAKERESTORE 0x0400 /* pid provider hint to getreg */ +#endif +#define CPU_DTRACE_ENTRY 0x0800 /* pid provider hint to ustack() */ +#define CPU_DTRACE_BADSTACK 0x1000 /* DTrace fault: bad stack */ + +#define CPU_DTRACE_FAULT (CPU_DTRACE_BADADDR | CPU_DTRACE_BADALIGN | \ + CPU_DTRACE_DIVZERO | CPU_DTRACE_ILLOP | \ + CPU_DTRACE_NOSCRATCH | CPU_DTRACE_KPRIV | \ + CPU_DTRACE_UPRIV | CPU_DTRACE_TUPOFLOW | \ + CPU_DTRACE_BADSTACK) +#define CPU_DTRACE_ERROR (CPU_DTRACE_FAULT | CPU_DTRACE_DROP) + +/* + * Dispatcher flags + * These flags must be changed only by the current CPU. + */ +#define CPU_DISP_DONTSTEAL 0x01 /* CPU undergoing context swtch */ +#define CPU_DISP_HALTED 0x02 /* CPU halted waiting for interrupt */ + +/* Note: inside ifdef: _KERNEL || _KMEMUSER || _BOOT */ + +/* + * Macros for manipulating sets of CPUs as a bitmap. Note that this + * bitmap may vary in size depending on the maximum CPU id a specific + * platform supports. This may be different than the number of CPUs + * the platform supports, since CPU ids can be sparse. We define two + * sets of macros; one for platforms where the maximum CPU id is less + * than the number of bits in a single word (32 in a 32-bit kernel, + * 64 in a 64-bit kernel), and one for platforms that require bitmaps + * of more than one word. + */ + +#define CPUSET_WORDS BT_BITOUL(NCPU) +#define CPUSET_NOTINSET ((uint_t)-1) + +#if defined(_MACHDEP) +struct cpuset { + ulong_t cpub[CPUSET_WORDS]; +}; +#else +struct cpuset; +#endif + +typedef struct cpuset cpuset_t; + +extern cpuset_t *cpuset_alloc(int); +extern void cpuset_free(cpuset_t *); + +/* + * Functions for manipulating cpusets. These were previously considered + * private when some cpuset_t handling was performed in the CPUSET_* macros. + * They are now acceptable to use in non-_MACHDEP code. + */ +extern void cpuset_all(cpuset_t *); +extern void cpuset_all_but(cpuset_t *, const uint_t); +extern int cpuset_isnull(const cpuset_t *); +extern int cpuset_isequal(const cpuset_t *, const cpuset_t *); +extern void cpuset_only(cpuset_t *, const uint_t); +extern long cpu_in_set(const cpuset_t *, const uint_t); +extern void cpuset_add(cpuset_t *, const uint_t); +extern void cpuset_del(cpuset_t *, const uint_t); +extern uint_t cpuset_find(const cpuset_t *); +extern void cpuset_bounds(const cpuset_t *, uint_t *, uint_t *); +extern void cpuset_atomic_del(cpuset_t *, const uint_t); +extern void cpuset_atomic_add(cpuset_t *, const uint_t); +extern long cpuset_atomic_xadd(cpuset_t *, const uint_t); +extern long cpuset_atomic_xdel(cpuset_t *, const uint_t); +extern void cpuset_or(cpuset_t *, const cpuset_t *); +extern void cpuset_xor(cpuset_t *, const cpuset_t *); +extern void cpuset_and(cpuset_t *, const cpuset_t *); +extern void cpuset_zero(cpuset_t *); + + +#if defined(_MACHDEP) + +/* + * Prior to the cpuset_t restructuring, the CPUSET_* macros contained + * significant logic, rather than directly invoking the backend functions. + * They are maintained here so that existing _MACHDEP code can use them. + */ + +#define CPUSET_ALL(set) cpuset_all(&(set)) +#define CPUSET_ALL_BUT(set, cpu) cpuset_all_but(&(set), cpu) +#define CPUSET_ONLY(set, cpu) cpuset_only(&(set), cpu) +#define CPU_IN_SET(set, cpu) cpu_in_set(&(set), cpu) +#define CPUSET_ADD(set, cpu) cpuset_add(&(set), cpu) +#define CPUSET_DEL(set, cpu) cpuset_del(&(set), cpu) +#define CPUSET_ISNULL(set) cpuset_isnull(&(set)) +#define CPUSET_ISEQUAL(set1, set2) cpuset_isequal(&(set1), &(set2)) + +/* + * Find one CPU in the cpuset. + * Sets "cpu" to the id of the found CPU, or CPUSET_NOTINSET if no cpu + * could be found. (i.e. empty set) + */ +#define CPUSET_FIND(set, cpu) { \ + cpu = cpuset_find(&(set)); \ +} + +/* + * Determine the smallest and largest CPU id in the set. Returns + * CPUSET_NOTINSET in smallest and largest when set is empty. + */ +#define CPUSET_BOUNDS(set, smallest, largest) { \ + cpuset_bounds(&(set), &(smallest), &(largest)); \ +} + +/* + * Atomic cpuset operations + * These are safe to use for concurrent cpuset manipulations. + * "xdel" and "xadd" are exclusive operations, that set "result" to "0" + * if the add or del was successful, or "-1" if not successful. + * (e.g. attempting to add a cpu to a cpuset that's already there, or + * deleting a cpu that's not in the cpuset) + */ + +#define CPUSET_ATOMIC_DEL(set, cpu) cpuset_atomic_del(&(set), cpu) +#define CPUSET_ATOMIC_ADD(set, cpu) cpuset_atomic_add(&(set), cpu) + +#define CPUSET_ATOMIC_XADD(set, cpu, result) \ + (result) = cpuset_atomic_xadd(&(set), cpu) + +#define CPUSET_ATOMIC_XDEL(set, cpu, result) \ + (result) = cpuset_atomic_xdel(&(set), cpu) + +#define CPUSET_OR(set1, set2) cpuset_or(&(set1), &(set2)) + +#define CPUSET_XOR(set1, set2) cpuset_xor(&(set1), &(set2)) + +#define CPUSET_AND(set1, set2) cpuset_and(&(set1), &(set2)) + +#define CPUSET_ZERO(set) cpuset_zero(&(set)) + +#endif /* defined(_MACHDEP) */ + + +extern cpuset_t cpu_seqid_inuse; + +extern struct cpu *cpu[]; /* indexed by CPU number */ +extern struct cpu **cpu_seq; /* indexed by sequential CPU id */ +extern cpu_t *cpu_list; /* list of CPUs */ +extern cpu_t *cpu_active; /* list of active CPUs */ +extern cpuset_t cpu_active_set; /* cached set of active CPUs */ +extern cpuset_t cpu_available; /* cached set of available CPUs */ +extern int ncpus; /* number of CPUs present */ +extern int ncpus_online; /* number of CPUs not quiesced */ +extern int ncpus_intr_enabled; /* nr of CPUs taking I/O intrs */ +extern int max_ncpus; /* max present before ncpus is known */ +extern int boot_max_ncpus; /* like max_ncpus but for real */ +extern int boot_ncpus; /* # cpus present @ boot */ +extern processorid_t max_cpuid; /* maximum CPU number */ +extern struct cpu *cpu_inmotion; /* offline or partition move target */ +extern cpu_t *clock_cpu_list; +extern processorid_t max_cpu_seqid_ever; /* maximum seqid ever given */ + +#if defined(__i386) || defined(__amd64) +extern struct cpu *curcpup(void); +#define CPU (curcpup()) /* Pointer to current CPU */ +#else +#define CPU (curthread->t_cpu) /* Pointer to current CPU */ +#endif + +/* + * CPU_CURRENT indicates to thread_affinity_set() to use whatever curthread's + * current CPU is; holding cpu_lock is not required. + */ +#define CPU_CURRENT -3 + +/* + * CPU_BEST can be used by thread_affinity_set() callers to set affinity to a + * good CPU (in particular, an ht_acquire()-friendly choice); holding cpu_lock + * is not required. + */ +#define CPU_BEST -4 + +/* + * Per-CPU statistics + * + * cpu_stats_t contains numerous system and VM-related statistics, in the form + * of gauges or monotonically-increasing event occurrence counts. + */ + +#define CPU_STATS_ENTER_K() kpreempt_disable() +#define CPU_STATS_EXIT_K() kpreempt_enable() + +#define CPU_STATS_ADD_K(class, stat, amount) \ + { kpreempt_disable(); /* keep from switching CPUs */\ + CPU_STATS_ADDQ(CPU, class, stat, amount); \ + kpreempt_enable(); \ + } + +#define CPU_STATS_ADDQ(cp, class, stat, amount) { \ + extern void __dtrace_probe___cpu_##class##info_##stat(uint_t, \ + uint64_t *, cpu_t *); \ + uint64_t *stataddr = &((cp)->cpu_stats.class.stat); \ + __dtrace_probe___cpu_##class##info_##stat((amount), \ + stataddr, cp); \ + *(stataddr) += (amount); \ +} + +#define CPU_STATS(cp, stat) \ + ((cp)->cpu_stats.stat) + +/* + * Increment CPU generation value. + * This macro should be called whenever CPU goes on-line or off-line. + * Updates to cpu_generation should be protected by cpu_lock. + */ +#define CPU_NEW_GENERATION(cp) ((cp)->cpu_generation++) + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +#define CPU_CPR_OFFLINE 0x0 +#define CPU_CPR_ONLINE 0x1 +#define CPU_CPR_IS_OFFLINE(cpu) (((cpu)->cpu_cpr_flags & CPU_CPR_ONLINE) == 0) +#define CPU_CPR_IS_ONLINE(cpu) ((cpu)->cpu_cpr_flags & CPU_CPR_ONLINE) +#define CPU_SET_CPR_FLAGS(cpu, flag) ((cpu)->cpu_cpr_flags |= flag) + +/* + * CPU support routines (not for genassym.c) + */ +#if (defined(_KERNEL) || defined(_FAKE_KERNEL)) && defined(__STDC__) + +struct zone; + +void cpu_list_init(cpu_t *); +void cpu_add_unit(cpu_t *); +void cpu_del_unit(int cpuid); +void cpu_add_active(cpu_t *); +void cpu_kstat_init(cpu_t *); +void cpu_visibility_add(cpu_t *, struct zone *); +void cpu_visibility_remove(cpu_t *, struct zone *); +void cpu_visibility_configure(cpu_t *, struct zone *); +void cpu_visibility_unconfigure(cpu_t *, struct zone *); +void cpu_visibility_online(cpu_t *, struct zone *); +void cpu_visibility_offline(cpu_t *, struct zone *); +void cpu_create_intrstat(cpu_t *); +void cpu_delete_intrstat(cpu_t *); +int cpu_kstat_intrstat_update(kstat_t *, int); +void cpu_intr_swtch_enter(kthread_t *); +void cpu_intr_swtch_exit(kthread_t *); + +void mbox_lock_init(void); /* initialize cross-call locks */ +void mbox_init(int cpun); /* initialize cross-calls */ +void poke_cpu(int cpun); /* interrupt another CPU (to preempt) */ + +/* + * values for safe_list. Pause state that CPUs are in. + */ +#define PAUSE_IDLE 0 /* normal state */ +#define PAUSE_READY 1 /* paused thread ready to spl */ +#define PAUSE_WAIT 2 /* paused thread is spl-ed high */ +#define PAUSE_DIE 3 /* tell pause thread to leave */ +#define PAUSE_DEAD 4 /* pause thread has left */ + +void mach_cpu_pause(volatile char *); + +void pause_cpus(cpu_t *off_cp, void *(*func)(void *)); +void start_cpus(void); +int cpus_paused(void); + +void cpu_pause_init(void); +cpu_t *cpu_get(processorid_t cpun); /* get the CPU struct associated */ + +int cpu_online(cpu_t *, int); /* take cpu online */ +int cpu_offline(cpu_t *, int); /* take cpu offline */ +int cpu_spare(cpu_t *, int); /* take cpu to spare */ +int cpu_faulted(cpu_t *, int); /* take cpu to faulted */ +int cpu_poweron(cpu_t *); /* take powered-off cpu to offline */ +int cpu_poweroff(cpu_t *); /* take offline cpu to powered-off */ + +cpu_t *cpu_intr_next(cpu_t *cp); /* get next online CPU taking intrs */ +int cpu_intr_count(cpu_t *cp); /* count # of CPUs handling intrs */ +int cpu_intr_on(cpu_t *cp); /* CPU taking I/O interrupts? */ +void cpu_intr_enable(cpu_t *cp); /* enable I/O interrupts */ +int cpu_intr_disable(cpu_t *cp); /* disable I/O interrupts */ +void cpu_intr_alloc(cpu_t *cp, int n); /* allocate interrupt threads */ + +/* + * Routines for checking CPU states. + */ +int cpu_is_online(cpu_t *); /* check if CPU is online */ +int cpu_is_nointr(cpu_t *); /* check if CPU can service intrs */ +int cpu_is_active(cpu_t *); /* check if CPU can run threads */ +int cpu_is_offline(cpu_t *); /* check if CPU is offline */ +int cpu_is_poweredoff(cpu_t *); /* check if CPU is powered off */ + +int cpu_flagged_online(cpu_flag_t); /* flags show CPU is online */ +int cpu_flagged_nointr(cpu_flag_t); /* flags show CPU not handling intrs */ +int cpu_flagged_active(cpu_flag_t); /* flags show CPU scheduling threads */ +int cpu_flagged_offline(cpu_flag_t); /* flags show CPU is offline */ +int cpu_flagged_poweredoff(cpu_flag_t); /* flags show CPU is powered off */ + +/* + * The processor_info(2) state of a CPU is a simplified representation suitable + * for use by an application program. Kernel subsystems should utilize the + * internal per-CPU state as given by the cpu_flags member of the cpu structure, + * as this information may include platform- or architecture-specific state + * critical to a subsystem's disposition of a particular CPU. + */ +void cpu_set_state(cpu_t *); /* record/timestamp current state */ +int cpu_get_state(cpu_t *); /* get current cpu state */ +const char *cpu_get_state_str(cpu_flag_t); + + +void cpu_set_curr_clock(uint64_t); /* indicate the current CPU's freq */ +void cpu_set_supp_freqs(cpu_t *, const char *); /* set the CPU supported */ + /* frequencies */ + +int cpu_configure(int); +int cpu_unconfigure(int); +void cpu_destroy_bound_threads(cpu_t *cp); + +extern int cpu_bind_thread(kthread_t *tp, processorid_t bind, + processorid_t *obind, int *error); +extern int cpu_unbind(processorid_t cpu_id, boolean_t force); +extern void thread_affinity_set(kthread_t *t, int cpu_id); +extern void thread_affinity_clear(kthread_t *t); +extern void affinity_set(int cpu_id); +extern void affinity_clear(void); +extern void init_cpu_mstate(struct cpu *, int); +extern void term_cpu_mstate(struct cpu *); +extern void new_cpu_mstate(int, hrtime_t); +extern void get_cpu_mstate(struct cpu *, hrtime_t *); +extern void thread_nomigrate(void); +extern void thread_allowmigrate(void); +extern void weakbinding_stop(void); +extern void weakbinding_start(void); + +/* + * The following routines affect the CPUs participation in interrupt processing, + * if that is applicable on the architecture. This only affects interrupts + * which aren't directed at the processor (not cross calls). + * + * cpu_disable_intr returns non-zero if interrupts were previously enabled. + */ +int cpu_disable_intr(struct cpu *cp); /* stop issuing interrupts to cpu */ +void cpu_enable_intr(struct cpu *cp); /* start issuing interrupts to cpu */ + +/* + * The mutex cpu_lock protects cpu_flags for all CPUs, as well as the ncpus + * and ncpus_online counts. + */ +extern kmutex_t cpu_lock; /* lock protecting CPU data */ + +/* + * CPU state change events + * + * Various subsystems need to know when CPUs change their state. They get this + * information by registering CPU state change callbacks using + * register_cpu_setup_func(). Whenever any CPU changes its state, the callback + * function is called. The callback function is passed three arguments: + * + * Event, described by cpu_setup_t + * CPU ID + * Transparent pointer passed when registering the callback + * + * The callback function is called with cpu_lock held. The return value from the + * callback function is usually ignored, except for CPU_CONFIG and CPU_UNCONFIG + * events. For these two events, non-zero return value indicates a failure and + * prevents successful completion of the operation. + * + * New events may be added in the future. Callback functions should ignore any + * events that they do not understand. + * + * The following events provide notification callbacks: + * + * CPU_INIT A new CPU is started and added to the list of active CPUs + * This event is only used during boot + * + * CPU_CONFIG A newly inserted CPU is prepared for starting running code + * This event is called by DR code + * + * CPU_UNCONFIG CPU has been powered off and needs cleanup + * This event is called by DR code + * + * CPU_ON CPU is enabled but does not run anything yet + * + * CPU_INTR_ON CPU is enabled and has interrupts enabled + * + * CPU_OFF CPU is going offline but can still run threads + * + * CPU_CPUPART_OUT CPU is going to move out of its partition + * + * CPU_CPUPART_IN CPU is going to move to a new partition + * + * CPU_SETUP CPU is set up during boot and can run threads + */ +typedef enum { + CPU_INIT, + CPU_CONFIG, + CPU_UNCONFIG, + CPU_ON, + CPU_OFF, + CPU_CPUPART_IN, + CPU_CPUPART_OUT, + CPU_SETUP, + CPU_INTR_ON +} cpu_setup_t; + +typedef int cpu_setup_func_t(cpu_setup_t, int, void *); + +/* + * Routines used to register interest in cpu's being added to or removed + * from the system. + */ +extern void register_cpu_setup_func(cpu_setup_func_t *, void *); +extern void unregister_cpu_setup_func(cpu_setup_func_t *, void *); +extern void cpu_state_change_notify(int, cpu_setup_t); + +/* + * Call specified function on the given CPU + */ +typedef void (*cpu_call_func_t)(uintptr_t, uintptr_t); +extern void cpu_call(cpu_t *, cpu_call_func_t, uintptr_t, uintptr_t); + + +/* + * Create various strings that describe the given CPU for the + * processor_info system call and configuration-related kstats. + */ +#define CPU_IDSTRLEN 100 + +extern void init_cpu_info(struct cpu *); +extern void populate_idstr(struct cpu *); +extern void cpu_vm_data_init(struct cpu *); +extern void cpu_vm_data_destroy(struct cpu *); + +#endif /* _KERNEL || _FAKE_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CPUVAR_H */ diff --git a/illumos-x86_64/usr/include/sys/crc32.h b/illumos-x86_64/usr/include/sys/crc32.h new file mode 100644 index 00000000..92bbd1c6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/crc32.h @@ -0,0 +1,230 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CRC32_H +#define _SYS_CRC32_H + +/* + * CRC32, the 32-bit Cyclic Redundancy Check, is a well-known way to + * generate checksums or hashes. Extensive literature on the theory + * behind CRC is available on the web; we won't recapitulate it here. + * We must, however, cover a few basics to explain the services we're + * providing. + * + * A CRC function is defined by two parameters: an initial value and a + * 32-bit integer that encodes its generating polynomial (explained later). + * Given these values, the CRC of any bitstream is defined as follows: + * + * crc = CRC32_INITIAL; + * foreach (bit of data) + * if (bit == (crc & 1)) + * crc = (crc >> 1); + * else + * crc = (crc >> 1) ^ CRC32_POLY; + * + * That's it. The algorithm is both simple and surprisingly powerful: + * CRC32 has been proven to detect all single-bit errors, all double-bit + * errors, and all burst errors up to 32 bits long. + * + * The most common values for the CRC parameters are: + * + * CRC32_INITIAL: 0 or -1 + * CRC32_POLY 0xEDB88320 + * + * There is no particular constraint on the initial value; any will yield a + * valid CRC. (OK, then why not always use zero? Because CRC was originally + * designed for serial transmission, in which one common form of error + * was a burst of zeroes. Note that if crc == 0, and we fold in a zero bit, + * we still have crc == 0. Therefore, if the CRC's initial value is zero, + * an arbitrarily long run of zeroes can be prepended to a packet without + * being detected.) + * + * The constraint on the polynomial is that it must be of degree 32 + * and must be primitive in the Galois field of polynomials modulo 2. + * Any such polynomial will yield a valid CRC. There's no particular + * advantage to one such polynomial over another, so the world has + * largely standardized on a particular one, 0xEDB88320. [The nth bit + * of this integer is the coefficient of x^n; the coefficient of x^32 + * is implicitly 1.] + * + * Of course, we rarely process data bitwise in software. When processing + * data bytewise, the following calculation is equivalent to the bitwise one: + * + * crc = CRC32_INITIAL; + * foreach (byte of data) + * for (crc ^= byte, i = 8; i > 0; i--) + * crc = (crc >> 1) ^ (-(crc & 1) & CRC32_POLY); + * + * Note that we still have a bitwise loop in there. We can avoid this + * by precomputing the CRC of each possible byte [i.e. 0-255] using the + * algorithm above and storing the results in a lookup table. Given + * such a table, the CRC can be computed quite efficiently as follows: + * + * crc = CRC32_INITIAL; + * foreach (byte of data) + * crc = (crc >> 8) ^ crc32_table[(crc ^ byte) & 0xFF]; + * + * The macros below support this form of CRC computation. + * + * We also define a pre-computed crc32_table[] for the polynomial 0xEDB88320. + * This is the only CRC polynomial we actually use in Solaris. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Initialize a CRC table [256 uint32_t's] with the given polynomial. + */ +#define CRC32_INIT(table, poly) \ +{ \ + uint32_t Xi, Xj, *Xt; \ + for (Xi = 0; Xi < 256; Xi++) \ + for (Xt = (table) + Xi, *Xt = Xi, Xj = 8; Xj > 0; Xj--) \ + *Xt = (*Xt >> 1) ^ (-(*Xt & 1) & (poly)); \ +} + +/* + * Compute a 32-bit CRC using the specified starting value and table. + * Typical usage: CRC32(crc, buf, size, -1U, crc32_table). + */ +#define CRC32(crc, buf, size, start, table) \ +{ \ + uint32_t Xcrc = start; \ + const uint8_t *Xcp = (const uint8_t *)(buf); \ + const uint8_t *Xcpend = Xcp + (size); \ + while (Xcp < Xcpend) \ + Xcrc = (Xcrc >> 8) ^ (table)[(Xcrc ^ *Xcp++) & 0xFF]; \ + crc = Xcrc; \ +} + +/* + * As above, but operate on a null-terminated string instead of an + * array of known size. Computes both the crc and the string length. + * Typical usage: CRC32_STRING(crc, len, str, -1U, crc32_table). + */ +#define CRC32_STRING(crc, len, str, start, table) \ +{ \ + uint32_t Xcrc = start; \ + const uint8_t *Xcp; \ + uint8_t Xc; \ + for (Xcp = (const uint8_t *)(str); (Xc = *Xcp) != 0; Xcp++) \ + Xcrc = (Xcrc >> 8) ^ (table)[(Xcrc ^ Xc) & 0xFF]; \ + (crc) = Xcrc; \ + (len) = Xcp - (const uint8_t *)(str); \ +} + +/* + * The polynomial we generally use in Solaris. + */ +#define CRC32_POLY 0xEDB88320U + +/* + * The pre-computed table values for CRC32_POLY. + */ +#define CRC32_TABLE \ + 0x00000000U, 0x77073096U, 0xEE0E612CU, 0x990951BAU, \ + 0x076DC419U, 0x706AF48FU, 0xE963A535U, 0x9E6495A3U, \ + 0x0EDB8832U, 0x79DCB8A4U, 0xE0D5E91EU, 0x97D2D988U, \ + 0x09B64C2BU, 0x7EB17CBDU, 0xE7B82D07U, 0x90BF1D91U, \ + 0x1DB71064U, 0x6AB020F2U, 0xF3B97148U, 0x84BE41DEU, \ + 0x1ADAD47DU, 0x6DDDE4EBU, 0xF4D4B551U, 0x83D385C7U, \ + 0x136C9856U, 0x646BA8C0U, 0xFD62F97AU, 0x8A65C9ECU, \ + 0x14015C4FU, 0x63066CD9U, 0xFA0F3D63U, 0x8D080DF5U, \ + 0x3B6E20C8U, 0x4C69105EU, 0xD56041E4U, 0xA2677172U, \ + 0x3C03E4D1U, 0x4B04D447U, 0xD20D85FDU, 0xA50AB56BU, \ + 0x35B5A8FAU, 0x42B2986CU, 0xDBBBC9D6U, 0xACBCF940U, \ + 0x32D86CE3U, 0x45DF5C75U, 0xDCD60DCFU, 0xABD13D59U, \ + 0x26D930ACU, 0x51DE003AU, 0xC8D75180U, 0xBFD06116U, \ + 0x21B4F4B5U, 0x56B3C423U, 0xCFBA9599U, 0xB8BDA50FU, \ + 0x2802B89EU, 0x5F058808U, 0xC60CD9B2U, 0xB10BE924U, \ + 0x2F6F7C87U, 0x58684C11U, 0xC1611DABU, 0xB6662D3DU, \ + 0x76DC4190U, 0x01DB7106U, 0x98D220BCU, 0xEFD5102AU, \ + 0x71B18589U, 0x06B6B51FU, 0x9FBFE4A5U, 0xE8B8D433U, \ + 0x7807C9A2U, 0x0F00F934U, 0x9609A88EU, 0xE10E9818U, \ + 0x7F6A0DBBU, 0x086D3D2DU, 0x91646C97U, 0xE6635C01U, \ + 0x6B6B51F4U, 0x1C6C6162U, 0x856530D8U, 0xF262004EU, \ + 0x6C0695EDU, 0x1B01A57BU, 0x8208F4C1U, 0xF50FC457U, \ + 0x65B0D9C6U, 0x12B7E950U, 0x8BBEB8EAU, 0xFCB9887CU, \ + 0x62DD1DDFU, 0x15DA2D49U, 0x8CD37CF3U, 0xFBD44C65U, \ + 0x4DB26158U, 0x3AB551CEU, 0xA3BC0074U, 0xD4BB30E2U, \ + 0x4ADFA541U, 0x3DD895D7U, 0xA4D1C46DU, 0xD3D6F4FBU, \ + 0x4369E96AU, 0x346ED9FCU, 0xAD678846U, 0xDA60B8D0U, \ + 0x44042D73U, 0x33031DE5U, 0xAA0A4C5FU, 0xDD0D7CC9U, \ + 0x5005713CU, 0x270241AAU, 0xBE0B1010U, 0xC90C2086U, \ + 0x5768B525U, 0x206F85B3U, 0xB966D409U, 0xCE61E49FU, \ + 0x5EDEF90EU, 0x29D9C998U, 0xB0D09822U, 0xC7D7A8B4U, \ + 0x59B33D17U, 0x2EB40D81U, 0xB7BD5C3BU, 0xC0BA6CADU, \ + 0xEDB88320U, 0x9ABFB3B6U, 0x03B6E20CU, 0x74B1D29AU, \ + 0xEAD54739U, 0x9DD277AFU, 0x04DB2615U, 0x73DC1683U, \ + 0xE3630B12U, 0x94643B84U, 0x0D6D6A3EU, 0x7A6A5AA8U, \ + 0xE40ECF0BU, 0x9309FF9DU, 0x0A00AE27U, 0x7D079EB1U, \ + 0xF00F9344U, 0x8708A3D2U, 0x1E01F268U, 0x6906C2FEU, \ + 0xF762575DU, 0x806567CBU, 0x196C3671U, 0x6E6B06E7U, \ + 0xFED41B76U, 0x89D32BE0U, 0x10DA7A5AU, 0x67DD4ACCU, \ + 0xF9B9DF6FU, 0x8EBEEFF9U, 0x17B7BE43U, 0x60B08ED5U, \ + 0xD6D6A3E8U, 0xA1D1937EU, 0x38D8C2C4U, 0x4FDFF252U, \ + 0xD1BB67F1U, 0xA6BC5767U, 0x3FB506DDU, 0x48B2364BU, \ + 0xD80D2BDAU, 0xAF0A1B4CU, 0x36034AF6U, 0x41047A60U, \ + 0xDF60EFC3U, 0xA867DF55U, 0x316E8EEFU, 0x4669BE79U, \ + 0xCB61B38CU, 0xBC66831AU, 0x256FD2A0U, 0x5268E236U, \ + 0xCC0C7795U, 0xBB0B4703U, 0x220216B9U, 0x5505262FU, \ + 0xC5BA3BBEU, 0xB2BD0B28U, 0x2BB45A92U, 0x5CB36A04U, \ + 0xC2D7FFA7U, 0xB5D0CF31U, 0x2CD99E8BU, 0x5BDEAE1DU, \ + 0x9B64C2B0U, 0xEC63F226U, 0x756AA39CU, 0x026D930AU, \ + 0x9C0906A9U, 0xEB0E363FU, 0x72076785U, 0x05005713U, \ + 0x95BF4A82U, 0xE2B87A14U, 0x7BB12BAEU, 0x0CB61B38U, \ + 0x92D28E9BU, 0xE5D5BE0DU, 0x7CDCEFB7U, 0x0BDBDF21U, \ + 0x86D3D2D4U, 0xF1D4E242U, 0x68DDB3F8U, 0x1FDA836EU, \ + 0x81BE16CDU, 0xF6B9265BU, 0x6FB077E1U, 0x18B74777U, \ + 0x88085AE6U, 0xFF0F6A70U, 0x66063BCAU, 0x11010B5CU, \ + 0x8F659EFFU, 0xF862AE69U, 0x616BFFD3U, 0x166CCF45U, \ + 0xA00AE278U, 0xD70DD2EEU, 0x4E048354U, 0x3903B3C2U, \ + 0xA7672661U, 0xD06016F7U, 0x4969474DU, 0x3E6E77DBU, \ + 0xAED16A4AU, 0xD9D65ADCU, 0x40DF0B66U, 0x37D83BF0U, \ + 0xA9BCAE53U, 0xDEBB9EC5U, 0x47B2CF7FU, 0x30B5FFE9U, \ + 0xBDBDF21CU, 0xCABAC28AU, 0x53B39330U, 0x24B4A3A6U, \ + 0xBAD03605U, 0xCDD70693U, 0x54DE5729U, 0x23D967BFU, \ + 0xB3667A2EU, 0xC4614AB8U, 0x5D681B02U, 0x2A6F2B94U, \ + 0xB40BBE37U, 0xC30C8EA1U, 0x5A05DF1BU, 0x2D02EF8DU + +#ifdef _KERNEL + +/* + * The kernel's pre-computed table for CRC32_POLY. + */ +extern const uint32_t crc32_table[256]; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRC32_H */ diff --git a/illumos-x86_64/usr/include/sys/cred.h b/illumos-x86_64/usr/include/sys/cred.h new file mode 100644 index 00000000..fb79dfec --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cred.h @@ -0,0 +1,193 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_CRED_H +#define _SYS_CRED_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The credential is an opaque kernel private data structure defined in + * . + */ + +typedef struct cred cred_t; + +#ifdef _KERNEL + +#define CRED() curthread->t_cred + +struct proc; /* cred.h is included in proc.h */ +struct prcred; +struct ksid; +struct ksidlist; +struct credklpd; +struct credgrp; + +struct auditinfo_addr; /* cred.h is included in audit.h */ + +extern int ngroups_max; +/* + * kcred is used when you need all privileges. + */ +extern struct cred *kcred; + +extern void cred_init(void); +extern void crhold(cred_t *); +extern void crfree(cred_t *); +extern cred_t *cralloc(void); /* all but ref uninitialized */ +extern cred_t *cralloc_ksid(void); /* cralloc() + ksid alloc'ed */ +extern cred_t *crget(void); /* initialized */ +extern cred_t *crcopy(cred_t *); +extern void crcopy_to(cred_t *, cred_t *); +extern cred_t *crdup(cred_t *); +extern void crdup_to(cred_t *, cred_t *); +extern cred_t *crgetcred(void); +extern void crset(struct proc *, cred_t *); +extern void crset_zone_privall(cred_t *); +extern int groupmember(gid_t, const cred_t *); +extern int supgroupmember(gid_t, const cred_t *); +extern int hasprocperm(const cred_t *, const cred_t *); +extern int prochasprocperm(struct proc *, struct proc *, const cred_t *); +extern int crcmp(const cred_t *, const cred_t *); +extern cred_t *zone_kcred(void); + +extern uid_t crgetuid(const cred_t *); +extern uid_t crgetruid(const cred_t *); +extern uid_t crgetsuid(const cred_t *); +extern gid_t crgetgid(const cred_t *); +extern gid_t crgetrgid(const cred_t *); +extern gid_t crgetsgid(const cred_t *); +extern zoneid_t crgetzoneid(const cred_t *); +extern projid_t crgetprojid(const cred_t *); + +extern cred_t *crgetmapped(const cred_t *); + + +extern const struct auditinfo_addr *crgetauinfo(const cred_t *); +extern struct auditinfo_addr *crgetauinfo_modifiable(cred_t *); + +extern uint_t crgetref(const cred_t *); + +extern const gid_t *crgetgroups(const cred_t *); +extern const gid_t *crgetggroups(const struct credgrp *); + +extern int crgetngroups(const cred_t *); + +/* + * Sets real, effective and/or saved uid/gid; + * -1 argument accepted as "no change". + */ +extern int crsetresuid(cred_t *, uid_t, uid_t, uid_t); +extern int crsetresgid(cred_t *, gid_t, gid_t, gid_t); + +/* + * Sets real, effective and saved uids/gids all to the same + * values. Both values must be non-negative and <= MAXUID + */ +extern int crsetugid(cred_t *, uid_t, gid_t); + +/* + * Functions to handle the supplemental group list. + */ +extern int crsetgroups(cred_t *, int, gid_t *); +extern struct credgrp *crgrpcopyin(int, gid_t *); +extern void crgrprele(struct credgrp *); +extern void crsetcredgrp(cred_t *, struct credgrp *); + +/* + * Private interface for setting zone association of credential. + */ +struct zone; +extern void crsetzone(cred_t *, struct zone *); +extern struct zone *crgetzone(const cred_t *); + +/* + * Private interface for setting project id in credential. + */ +extern void crsetprojid(cred_t *, projid_t); + +/* + * Private interface for nfs. + */ +extern cred_t *crnetadjust(cred_t *); + +/* + * Private interface for procfs. + */ +extern void cred2prcred(const cred_t *, struct prcred *); + +/* + * Private interfaces for Rampart Trusted Solaris. + */ +struct ts_label_s; +extern struct ts_label_s *crgetlabel(const cred_t *); +extern boolean_t crisremote(const cred_t *); + +/* + * Private interfaces for ephemeral uids. + */ +#define VALID_UID(id, zn) \ + ((id) <= MAXUID || valid_ephemeral_uid((zn), (id))) + +#define VALID_GID(id, zn) \ + ((id) <= MAXUID || valid_ephemeral_gid((zn), (id))) + +extern boolean_t valid_ephemeral_uid(struct zone *, uid_t); +extern boolean_t valid_ephemeral_gid(struct zone *, gid_t); + +extern int eph_uid_alloc(struct zone *, int, uid_t *, int); +extern int eph_gid_alloc(struct zone *, int, gid_t *, int); + +extern void crsetsid(cred_t *, struct ksid *, int); +extern void crsetsidlist(cred_t *, struct ksidlist *); + +extern struct ksid *crgetsid(const cred_t *, int); +extern struct ksidlist *crgetsidlist(const cred_t *); + +extern int crsetpriv(cred_t *, ...); + +extern struct credklpd *crgetcrklpd(const cred_t *); +extern void crsetcrklpd(cred_t *, struct credklpd *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRED_H */ diff --git a/illumos-x86_64/usr/include/sys/cred_impl.h b/illumos-x86_64/usr/include/sys/cred_impl.h new file mode 100644 index 00000000..e102f60e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cred_impl.h @@ -0,0 +1,106 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CRED_IMPL_H +#define _SYS_CRED_IMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The user credential implementation. + * + * This is is not a public interface. This file must not be included + * except by those routines in Solaris proper that implement credential + * manipulation and kernel policy. + * + * Credentials are shared, and therefor read-only, data structure. + * After finalization, on the cr_ref field is changed through crhold/crfree. + * + * Kernel modules that need access to fields of cred_t should use the + * accessor functions defined in + * + * The size of the cr_groups[] array is configurable but is the same + * (ngroups_max) for all cred_impl structures; cr_ngroups records the number + * of elements currently in use, not the array size. + * + * Changes in the implementation will move cr_groups[] around. + * + * Properly sized cred_t structures are only returned by crget()/crdup() + * crcopy(). It is not possible to declare one. + */ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +struct zone; /* forward reference */ +struct ts_label_s; /* forward reference */ +struct credklpd; /* forward reference */ + +/* Supplemental groups list. */ +typedef struct credgrp { + uint_t crg_ref; + uint_t crg_ngroups; + gid_t crg_groups[1]; +} credgrp_t; + +struct cred { + uint_t cr_ref; /* reference count */ + uid_t cr_uid; /* effective user id */ + gid_t cr_gid; /* effective group id */ + uid_t cr_ruid; /* real user id */ + gid_t cr_rgid; /* real group id */ + uid_t cr_suid; /* "saved" user id (from exec) */ + gid_t cr_sgid; /* "saved" group id (from exec) */ + cred_priv_t cr_priv; /* privileges */ + projid_t cr_projid; /* project */ + struct zone *cr_zone; /* pointer to per-zone structure */ + struct ts_label_s *cr_label; /* pointer to the effective label */ + struct credklpd *cr_klpd; /* pointer to the cred's klpd */ + credsid_t *cr_ksid; /* pointer to SIDs */ + credgrp_t *cr_grps; /* supplemental groups */ + /* audit info is defined dynamically */ + /* and valid only when audit enabled */ + /* auditinfo_addr_t cr_auinfo; audit info */ +}; + +extern int ngroups_max; + +#define CR_PRIVS(c) (&(c)->cr_priv) +#define CR_PRIVSETS(c) (((c)->cr_priv.crprivs)) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRED_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/crtctl.h b/illumos-x86_64/usr/include/sys/crtctl.h new file mode 100644 index 00000000..6c2d133e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/crtctl.h @@ -0,0 +1,93 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_CRTCTL_H +#define _SYS_CRTCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Define the cursor control codes + */ +#define ESC 033 /* Escape for command */ + +/* Commands */ +#define CUP 0101 /* Cursor up */ +#define CDN 0102 /* Cursor down */ +#define CRI 0103 /* Cursor right */ +#define CLE 0104 /* Cursor left */ +#define NL 0134 /* Terminal newline function */ +#define HOME 0105 /* Cursor home */ +#define VHOME 0106 /* cursor home to variable portion */ +#define LCA 0107 /* Load cursor, followed by (x,y) in (col,row) */ +#define CRTN 0133 /* Return cursor to beginning of line */ + +#define STB 0110 /* Start blink */ +#define SPB 0111 /* Stop blink */ +#define CS 0112 /* Clear Screen */ +#define CM 0135 /* Clear Memory */ +#define EEOL 0113 /* Erase to end of line */ +#define EEOP 0114 /* Erase to end of page */ +#define DC 0115 /* Delete character */ +#define DL 0116 /* Delete line */ +#define IC 0117 /* Insert character */ +#define IL 0120 /* Insert line */ +#define KBL 0121 /* keyboard lock */ +#define KBU 0122 /* keyboard unlock */ +#define ATAB 0123 /* Set column of tabs */ +#define STAB 0124 /* Set single tab */ +#define CTAB 0125 /* Clear Tabs */ +#define USCRL 0126 /* Scroll up one line */ +#define DSCRL 0127 /* Scroll down one line */ +#define ASEG 0130 /* Advance segment */ +#define BPRT 0131 /* Begin protect */ +#define EPRT 0132 /* End protect */ + +#define SVSCN 0136 /* Define variable portion of screen (OS only) */ +#define UVSCN 0137 /* Scroll Up variable portion of screen */ +#define DVSCN 0140 /* Scroll Down variable portion of screen */ + +#define SVID 0141 /* Set Video Attributes */ +#define CVID 0142 /* Clear Video Attributes */ +#define DVID 0143 /* Define Video Attributes */ +/* Video Attribute Definitions */ +#define VID_NORM 000 /* normal */ +#define VID_UL 001 /* underline */ +#define VID_BLNK 002 /* blink */ +#define VID_REV 004 /* reverse video */ +#define VID_DIM 010 /* dim intensity */ +#define VID_BOLD 020 /* bright intensity */ +#define VID_OFF 040 /* blank out field */ + +#define BRK 000 /* transmit break */ +#define HIQ 001 /* Put remainder of write on high priority queue. */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRTCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/crypto/api.h b/illumos-x86_64/usr/include/sys/crypto/api.h new file mode 100644 index 00000000..4f27bbaf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/crypto/api.h @@ -0,0 +1,423 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_CRYPTO_API_H +#define _SYS_CRYPTO_API_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef long crypto_req_id_t; +typedef void *crypto_bc_t; +typedef void *crypto_context_t; +typedef void *crypto_ctx_template_t; + +typedef uint32_t crypto_call_flag_t; + +/* crypto_call_flag's values */ +#define CRYPTO_ALWAYS_QUEUE 0x00000001 /* ALWAYS queue the req. */ +#define CRYPTO_NOTIFY_OPDONE 0x00000002 /* Notify intermediate steps */ +#define CRYPTO_SKIP_REQID 0x00000004 /* Skip request ID generation */ + +typedef struct { + crypto_call_flag_t cr_flag; + void (*cr_callback_func)(void *, int); + void *cr_callback_arg; + crypto_req_id_t cr_reqid; +} crypto_call_req_t; + +/* + * Returns the mechanism type corresponding to a mechanism name. + */ + +#define CRYPTO_MECH_INVALID ((uint64_t)-1) +extern crypto_mech_type_t crypto_mech2id(const char *name); + +/* + * Create and destroy context templates. + */ +extern int crypto_create_ctx_template(crypto_mechanism_t *mech, + crypto_key_t *key, crypto_ctx_template_t *tmpl, int kmflag); +extern void crypto_destroy_ctx_template(crypto_ctx_template_t tmpl); + +/* + * Single and multi-part digest operations. + */ +extern int crypto_digest(crypto_mechanism_t *mech, crypto_data_t *data, + crypto_data_t *digest, crypto_call_req_t *cr); +extern int crypto_digest_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_data_t *, crypto_data_t *, + crypto_call_req_t *); +extern int crypto_digest_init(crypto_mechanism_t *mech, crypto_context_t *ctxp, + crypto_call_req_t *cr); +extern int crypto_digest_init_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_context_t *, crypto_call_req_t *); +extern int crypto_digest_update(crypto_context_t ctx, crypto_data_t *data, + crypto_call_req_t *cr); +extern int crypto_digest_final(crypto_context_t ctx, crypto_data_t *digest, + crypto_call_req_t *cr); + +/* + * Single and multi-part MAC operations. + */ +extern int crypto_mac(crypto_mechanism_t *mech, crypto_data_t *data, + crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac, + crypto_call_req_t *cr); +extern int crypto_mac_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_data_t *, crypto_key_t *, + crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); +extern int crypto_mac_verify(crypto_mechanism_t *mech, crypto_data_t *data, + crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac, + crypto_call_req_t *cr); +extern int crypto_mac_verify_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_data_t *, crypto_key_t *, + crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); +extern int crypto_mac_init(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr); +extern int crypto_mac_init_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, + crypto_context_t *, crypto_call_req_t *); +extern int crypto_mac_update(crypto_context_t ctx, crypto_data_t *data, + crypto_call_req_t *cr); +extern int crypto_mac_final(crypto_context_t ctx, crypto_data_t *data, + crypto_call_req_t *cr); + +/* + * Single and multi-part sign with private key operations. + */ +extern int crypto_sign(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_data_t *data, crypto_ctx_template_t tmpl, + crypto_data_t *signature, crypto_call_req_t *cr); +extern int crypto_sign_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); +extern int crypto_sign_init(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr); +extern int crypto_sign_init_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, + crypto_context_t *, crypto_call_req_t *); +extern int crypto_sign_update(crypto_context_t ctx, crypto_data_t *data, + crypto_call_req_t *cr); +extern int crypto_sign_final(crypto_context_t ctx, crypto_data_t *signature, + crypto_call_req_t *cr); +extern int crypto_sign_recover_init_prov(crypto_provider_t, + crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, + crypto_ctx_template_t tmpl, crypto_context_t *, crypto_call_req_t *); +extern int crypto_sign_recover(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_data_t *data, crypto_ctx_template_t tmpl, crypto_data_t *signature, + crypto_call_req_t *cr); +extern int crypto_sign_recover_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); + +/* + * Single and multi-part verify with public key operations. + */ +extern int crypto_verify(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_data_t *data, crypto_ctx_template_t tmpl, crypto_data_t *signature, + crypto_call_req_t *cr); +extern int crypto_verify_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); +extern int crypto_verify_init(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr); +extern int crypto_verify_init_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, + crypto_context_t *, crypto_call_req_t *); +extern int crypto_verify_update(crypto_context_t ctx, crypto_data_t *data, + crypto_call_req_t *cr); +extern int crypto_verify_final(crypto_context_t ctx, crypto_data_t *signature, + crypto_call_req_t *cr); +extern int crypto_verify_recover_init_prov(crypto_provider_t, + crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, + crypto_ctx_template_t tmpl, crypto_context_t *, crypto_call_req_t *); +extern int crypto_verify_recover(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_data_t *signature, crypto_ctx_template_t tmpl, crypto_data_t *data, + crypto_call_req_t *cr); +extern int crypto_verify_recover_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); + +/* + * Single and multi-part encryption operations. + */ +extern int crypto_encrypt(crypto_mechanism_t *mech, crypto_data_t *plaintext, + crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *ciphertext, + crypto_call_req_t *cr); +extern int crypto_encrypt_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_data_t *, crypto_key_t *, + crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); +extern int crypto_encrypt_init(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr); +extern int crypto_encrypt_init_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, + crypto_context_t *, crypto_call_req_t *); +extern int crypto_encrypt_update(crypto_context_t ctx, + crypto_data_t *plaintext, crypto_data_t *ciphertext, + crypto_call_req_t *cr); +extern int crypto_encrypt_final(crypto_context_t ctx, + crypto_data_t *ciphertext, crypto_call_req_t *cr); + +/* + * Single and multi-part decryption operations. + */ +extern int crypto_decrypt(crypto_mechanism_t *mech, crypto_data_t *ciphertext, + crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *plaintext, + crypto_call_req_t *cr); +extern int crypto_decrypt_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_data_t *, crypto_key_t *, + crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); +extern int crypto_decrypt_init(crypto_mechanism_t *mech, crypto_key_t *key, + crypto_ctx_template_t tmpl, crypto_context_t *ctxp, + crypto_call_req_t *cr); +extern int crypto_decrypt_init_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, + crypto_context_t *, crypto_call_req_t *); +extern int crypto_decrypt_update(crypto_context_t ctx, + crypto_data_t *ciphertext, crypto_data_t *plaintext, + crypto_call_req_t *cr); +extern int crypto_decrypt_final(crypto_context_t ctx, crypto_data_t *plaintext, + crypto_call_req_t *cr); + +/* + * Single and multi-part encrypt/MAC dual operations. + */ +extern int crypto_encrypt_mac(crypto_mechanism_t *encr_mech, + crypto_mechanism_t *mac_mech, crypto_data_t *pt, + crypto_key_t *encr_key, crypto_key_t *mac_key, + crypto_ctx_template_t encr_tmpl, crypto_ctx_template_t mac_tmpl, + crypto_dual_data_t *ct, crypto_data_t *mac, crypto_call_req_t *cr); +extern int crypto_encrypt_mac_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_mechanism_t *, crypto_data_t *, + crypto_key_t *, crypto_key_t *, crypto_ctx_template_t, + crypto_ctx_template_t, crypto_dual_data_t *, crypto_data_t *, + crypto_call_req_t *); +extern int crypto_encrypt_mac_init(crypto_mechanism_t *encr_mech, + crypto_mechanism_t *mac_mech, crypto_key_t *encr_key, + crypto_key_t *mac_key, crypto_ctx_template_t encr_tmpl, + crypto_ctx_template_t mac_tmpl, crypto_context_t *ctxp, + crypto_call_req_t *cr); +extern int crypto_encrypt_mac_init_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_mechanism_t *, crypto_key_t *, crypto_key_t *, + crypto_ctx_template_t, crypto_ctx_template_t, crypto_context_t *, + crypto_call_req_t *); +extern int crypto_encrypt_mac_update(crypto_context_t ctx, + crypto_data_t *pt, crypto_dual_data_t *ct, crypto_call_req_t *cr); +extern int crypto_encrypt_mac_final(crypto_context_t ctx, + crypto_dual_data_t *ct, crypto_data_t *mac, crypto_call_req_t *cr); + +/* + * Single and multi-part MAC/decrypt dual operations. + */ +extern int crypto_mac_decrypt(crypto_mechanism_t *mac_mech, + crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct, + crypto_key_t *mac_key, crypto_key_t *decr_key, + crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl, + crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr); +extern int crypto_mac_decrypt_prov(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *mac_mech, crypto_mechanism_t *decr_mech, + crypto_dual_data_t *ct, crypto_key_t *mac_key, crypto_key_t *decr_key, + crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl, + crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr); +extern int crypto_mac_verify_decrypt(crypto_mechanism_t *mac_mech, + crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct, + crypto_key_t *mac_key, crypto_key_t *decr_key, + crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl, + crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr); +extern int crypto_mac_verify_decrypt_prov(crypto_provider_t, + crypto_session_id_t, crypto_mechanism_t *mac_mech, + crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct, + crypto_key_t *mac_key, crypto_key_t *decr_key, + crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl, + crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr); +extern int crypto_mac_decrypt_init(crypto_mechanism_t *mac_mech, + crypto_mechanism_t *decr_mech, crypto_key_t *mac_key, + crypto_key_t *decr_key, crypto_ctx_template_t mac_tmpl, + crypto_ctx_template_t decr_tmpl, crypto_context_t *ctxp, + crypto_call_req_t *cr); +extern int crypto_mac_decrypt_init_prov(crypto_provider_t, + crypto_session_id_t, crypto_mechanism_t *mac_mech, + crypto_mechanism_t *decr_mech, crypto_key_t *mac_key, + crypto_key_t *decr_key, crypto_ctx_template_t mac_tmpl, + crypto_ctx_template_t decr_tmpl, crypto_context_t *ctxp, + crypto_call_req_t *cr); +extern int crypto_mac_decrypt_update(crypto_context_t ctx, + crypto_dual_data_t *ct, crypto_data_t *pt, crypto_call_req_t *cr); +extern int crypto_mac_decrypt_final(crypto_context_t ctx, crypto_data_t *mac, + crypto_data_t *pt, crypto_call_req_t *cr); + +/* Session Management */ +extern int crypto_session_open(crypto_provider_t, crypto_session_id_t *, + crypto_call_req_t *); +extern int crypto_session_close(crypto_provider_t, crypto_session_id_t, + crypto_call_req_t *); +extern int crypto_session_login(crypto_provider_t, crypto_session_id_t, + crypto_user_type_t, char *, size_t, crypto_call_req_t *); +extern int crypto_session_logout(crypto_provider_t, crypto_session_id_t, + crypto_call_req_t *); + +/* Object Management */ +extern int crypto_object_copy(crypto_provider_t, crypto_session_id_t, + crypto_object_id_t, crypto_object_attribute_t *, uint_t, + crypto_object_id_t *, crypto_call_req_t *); +extern int crypto_object_create(crypto_provider_t, crypto_session_id_t, + crypto_object_attribute_t *, uint_t, crypto_object_id_t *, + crypto_call_req_t *); +extern int crypto_object_destroy(crypto_provider_t, crypto_session_id_t, + crypto_object_id_t, crypto_call_req_t *); +extern int crypto_object_get_attribute_value(crypto_provider_t, + crypto_session_id_t, crypto_object_id_t, crypto_object_attribute_t *, + uint_t, crypto_call_req_t *); +extern int crypto_object_get_size(crypto_provider_t, crypto_session_id_t, + crypto_object_id_t, size_t *, crypto_call_req_t *); +extern int crypto_object_find_final(crypto_provider_t, void *, + crypto_call_req_t *); +extern int crypto_object_find_init(crypto_provider_t, crypto_session_id_t, + crypto_object_attribute_t *, uint_t, void **, crypto_call_req_t *); +extern int crypto_object_find(crypto_provider_t, void *, crypto_object_id_t *, + uint_t *, uint_t, crypto_call_req_t *); +extern int crypto_object_set_attribute_value(crypto_provider_t, + crypto_session_id_t, crypto_object_id_t, crypto_object_attribute_t *, + uint_t, crypto_call_req_t *); + +/* Key Management */ +extern int crypto_key_derive(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *, + uint_t, crypto_object_id_t *, crypto_call_req_t *); +extern int crypto_key_generate(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_object_attribute_t *, uint_t, + crypto_object_id_t *, crypto_call_req_t *); +extern int crypto_key_generate_pair(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_object_attribute_t *, uint_t, + crypto_object_attribute_t *, uint_t, crypto_object_id_t *, + crypto_object_id_t *, crypto_call_req_t *); +extern int crypto_key_unwrap(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, uchar_t *, size_t *, + crypto_object_attribute_t *, uint_t, crypto_object_id_t *, + crypto_call_req_t *); +extern int crypto_key_wrap(crypto_provider_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_object_id_t *, uchar_t *, + size_t *, crypto_call_req_t *); +extern int crypto_key_check_prov(crypto_provider_t, crypto_mechanism_t *mech, + crypto_key_t *key); +extern int crypto_key_check(crypto_mechanism_t *mech, crypto_key_t *key); + + +/* + * Routines to cancel a single asynchronous request or all asynchronous + * requests associated with a particular context. + */ +extern void crypto_cancel_req(crypto_req_id_t req); +extern void crypto_cancel_ctx(crypto_context_t ctx); + +/* + * crypto_get_mech_list(9F) allocates and returns the list of currently + * supported cryptographic mechanisms. + */ +extern crypto_mech_name_t *crypto_get_mech_list(uint_t *count, int kmflag); +extern void crypto_free_mech_list(crypto_mech_name_t *mech_names, + uint_t count); + +extern crypto_provider_t crypto_get_provider(char *, char *, char *); +extern int crypto_get_provinfo(crypto_provider_t, crypto_provider_ext_info_t *); +extern void crypto_release_provider(crypto_provider_t); + +/* + * A kernel consumer can request to be notified when some particular event + * occurs. The valid events, callback function type, and functions to + * be called to register or unregister for notification are defined below. + */ + +#define CRYPTO_EVENT_MECHS_CHANGED 0x00000001 +#define CRYPTO_EVENT_PROVIDER_REGISTERED 0x00000002 +#define CRYPTO_EVENT_PROVIDER_UNREGISTERED 0x00000004 + +typedef enum { + CRYPTO_MECH_ADDED = 1, + CRYPTO_MECH_REMOVED +} crypto_event_change_t; + +/* The event_arg argument structure for CRYPTO_EVENT_PROVIDERS_CHANGE event */ +typedef struct crypto_notify_event_change { + crypto_mech_name_t ec_mech_name; + crypto_provider_type_t ec_provider_type; + crypto_event_change_t ec_change; +} crypto_notify_event_change_t; + +typedef void *crypto_notify_handle_t; +typedef void (*crypto_notify_callback_t)(uint32_t event_mask, void *event_arg); + +extern crypto_notify_handle_t crypto_notify_events( + crypto_notify_callback_t nf, uint32_t event_mask); +extern void crypto_unnotify_events(crypto_notify_handle_t); + +/* + * crypto_bufcall(9F) group of routines. + */ +extern crypto_bc_t crypto_bufcall_alloc(void); +extern int crypto_bufcall_free(crypto_bc_t bc); +extern int crypto_bufcall(crypto_bc_t bc, void (*func)(void *arg), void *arg); +extern int crypto_unbufcall(crypto_bc_t bc); + +/* + * To obtain the list of key size ranges supported by a mechanism. + */ + +#define CRYPTO_MECH_USAGE_ENCRYPT 0x00000001 +#define CRYPTO_MECH_USAGE_DECRYPT 0x00000002 +#define CRYPTO_MECH_USAGE_MAC 0x00000004 + +typedef uint32_t crypto_mech_usage_t; + +typedef struct crypto_mechanism_info { + size_t mi_min_key_size; + size_t mi_max_key_size; + crypto_keysize_unit_t mi_keysize_unit; /* for mi_xxx_key_size */ + crypto_mech_usage_t mi_usage; +} crypto_mechanism_info_t; + +#ifdef _SYSCALL32 + +typedef struct crypto_mechanism_info32 { + size32_t mi_min_key_size; + size32_t mi_max_key_size; + crypto_keysize_unit_t mi_keysize_unit; /* for mi_xxx_key_size */ + crypto_mech_usage_t mi_usage; +} crypto_mechanism_info32_t; + +#endif /* _SYSCALL32 */ + +extern int crypto_get_all_mech_info(crypto_mech_type_t, + crypto_mechanism_info_t **, uint_t *, int); +extern void crypto_free_all_mech_info(crypto_mechanism_info_t *, uint_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRYPTO_API_H */ diff --git a/illumos-x86_64/usr/include/sys/crypto/common.h b/illumos-x86_64/usr/include/sys/crypto/common.h new file mode 100644 index 00000000..c20ff823 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/crypto/common.h @@ -0,0 +1,599 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright 2013 Saso Kiselkov. All rights reserved. + */ + +#ifndef _SYS_CRYPTO_COMMON_H +#define _SYS_CRYPTO_COMMON_H + +/* + * Header file for the common data structures of the cryptographic framework + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + + +/* Cryptographic Mechanisms */ + +#define CRYPTO_MAX_MECH_NAME 32 +typedef char crypto_mech_name_t[CRYPTO_MAX_MECH_NAME]; + +typedef uint64_t crypto_mech_type_t; + +typedef struct crypto_mechanism { + crypto_mech_type_t cm_type; /* mechanism type */ + caddr_t cm_param; /* mech. parameter */ + size_t cm_param_len; /* mech. parameter len */ +} crypto_mechanism_t; + +#ifdef _SYSCALL32 + +typedef struct crypto_mechanism32 { + crypto_mech_type_t cm_type; /* mechanism type */ + caddr32_t cm_param; /* mech. parameter */ + size32_t cm_param_len; /* mech. parameter len */ +} crypto_mechanism32_t; + +#endif /* _SYSCALL32 */ + +#ifdef _KERNEL +/* CK_AES_CTR_PARAMS provides parameters to the CKM_AES_CTR mechanism */ +typedef struct CK_AES_CTR_PARAMS { + ulong_t ulCounterBits; + uint8_t cb[16]; +} CK_AES_CTR_PARAMS; +#endif + +/* CK_AES_CCM_PARAMS provides parameters to the CKM_AES_CCM mechanism */ +typedef struct CK_AES_CCM_PARAMS { + ulong_t ulMACSize; + ulong_t ulNonceSize; + ulong_t ulAuthDataSize; + ulong_t ulDataSize; /* used for plaintext or ciphertext */ + uchar_t *nonce; + uchar_t *authData; +} CK_AES_CCM_PARAMS; + +/* CK_AES_GCM_PARAMS provides parameters to the CKM_AES_GCM mechanism */ +typedef struct CK_AES_GCM_PARAMS { + uchar_t *pIv; + ulong_t ulIvLen; + ulong_t ulIvBits; + uchar_t *pAAD; + ulong_t ulAADLen; + ulong_t ulTagBits; +} CK_AES_GCM_PARAMS; + +/* CK_AES_GMAC_PARAMS provides parameters to the CKM_AES_GMAC mechanism */ +typedef struct CK_AES_GMAC_PARAMS { + uchar_t *pIv; + uchar_t *pAAD; + ulong_t ulAADLen; +} CK_AES_GMAC_PARAMS; + +#ifdef _KERNEL +/* + * CK_ECDH1_DERIVE_PARAMS provides the parameters to the + * CKM_ECDH1_KEY_DERIVE mechanism + */ +typedef struct CK_ECDH1_DERIVE_PARAMS { + ulong_t kdf; + ulong_t ulSharedDataLen; + uchar_t *pSharedData; + ulong_t ulPublicDataLen; + uchar_t *pPublicData; +} CK_ECDH1_DERIVE_PARAMS; +#endif + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +/* needed for 32-bit applications running on 64-bit kernels */ +typedef struct CK_AES_CTR_PARAMS32 { + uint32_t ulCounterBits; + uint8_t cb[16]; +} CK_AES_CTR_PARAMS32; + +/* needed for 32-bit applications running on 64-bit kernels */ +typedef struct CK_AES_CCM_PARAMS32 { + uint32_t ulMACSize; + uint32_t ulNonceSize; + uint32_t ulAuthDataSize; + uint32_t ulDataSize; + caddr32_t nonce; + caddr32_t authData; +} CK_AES_CCM_PARAMS32; + +/* needed for 32-bit applications running on 64-bit kernels */ +typedef struct CK_AES_GCM_PARAMS32 { + caddr32_t pIv; + uint32_t ulIvLen; + uint32_t ulIvBits; + caddr32_t pAAD; + uint32_t ulAADLen; + uint32_t ulTagBits; +} CK_AES_GCM_PARAMS32; + +/* needed for 32-bit applications running on 64-bit kernels */ +typedef struct CK_AES_GMAC_PARAMS32 { + caddr32_t pIv; + caddr32_t pAAD; + uint32_t ulAADLen; +} CK_AES_GMAC_PARAMS32; + +typedef struct CK_ECDH1_DERIVE_PARAMS32 { + uint32_t kdf; + uint32_t ulSharedDataLen; + caddr32_t pSharedData; + uint32_t ulPublicDataLen; + caddr32_t pPublicData; +} CK_ECDH1_DERIVE_PARAMS32; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +/* + * The measurement unit bit flag for a mechanism's minimum or maximum key size. + * The unit are mechanism dependent. It can be in bits or in bytes. + */ +typedef uint32_t crypto_keysize_unit_t; + +/* + * The following bit flags are valid in cm_mech_flags field in + * the crypto_mech_info_t structure of the SPI. + * + * Only the first two bit flags are valid in mi_keysize_unit + * field in the crypto_mechanism_info_t structure of the API. + */ +#define CRYPTO_KEYSIZE_UNIT_IN_BITS 0x00000001 +#define CRYPTO_KEYSIZE_UNIT_IN_BYTES 0x00000002 +#define CRYPTO_CAN_SHARE_OPSTATE 0x00000004 /* supports sharing */ + + +/* Mechanisms supported out-of-the-box */ +#define SUN_CKM_MD4 "CKM_MD4" +#define SUN_CKM_MD5 "CKM_MD5" +#define SUN_CKM_MD5_HMAC "CKM_MD5_HMAC" +#define SUN_CKM_MD5_HMAC_GENERAL "CKM_MD5_HMAC_GENERAL" +#define SUN_CKM_SHA1 "CKM_SHA_1" +#define SUN_CKM_SHA1_HMAC "CKM_SHA_1_HMAC" +#define SUN_CKM_SHA1_HMAC_GENERAL "CKM_SHA_1_HMAC_GENERAL" +#define SUN_CKM_SHA256 "CKM_SHA256" +#define SUN_CKM_SHA256_HMAC "CKM_SHA256_HMAC" +#define SUN_CKM_SHA256_HMAC_GENERAL "CKM_SHA256_HMAC_GENERAL" +#define SUN_CKM_SHA384 "CKM_SHA384" +#define SUN_CKM_SHA384_HMAC "CKM_SHA384_HMAC" +#define SUN_CKM_SHA384_HMAC_GENERAL "CKM_SHA384_HMAC_GENERAL" +#define SUN_CKM_SHA512 "CKM_SHA512" +#define SUN_CKM_SHA512_HMAC "CKM_SHA512_HMAC" +#define SUN_CKM_SHA512_HMAC_GENERAL "CKM_SHA512_HMAC_GENERAL" +#define SUN_CKM_SHA512_224 "CKM_SHA512_224" +#define SUN_CKM_SHA512_256 "CKM_SHA512_256" +#define SUN_CKM_DES_CBC "CKM_DES_CBC" +#define SUN_CKM_DES3_CBC "CKM_DES3_CBC" +#define SUN_CKM_DES_ECB "CKM_DES_ECB" +#define SUN_CKM_DES3_ECB "CKM_DES3_ECB" +#define SUN_CKM_BLOWFISH_CBC "CKM_BLOWFISH_CBC" +#define SUN_CKM_BLOWFISH_ECB "CKM_BLOWFISH_ECB" +#define SUN_CKM_AES_CBC "CKM_AES_CBC" +#define SUN_CKM_AES_CMAC "CKM_AES_CMAC" +#define SUN_CKM_AES_ECB "CKM_AES_ECB" +#define SUN_CKM_AES_CTR "CKM_AES_CTR" +#define SUN_CKM_AES_CCM "CKM_AES_CCM" +#define SUN_CKM_AES_GCM "CKM_AES_GCM" +#define SUN_CKM_AES_GMAC "CKM_AES_GMAC" +#define SUN_CKM_AES_CFB128 "CKM_AES_CFB128" +#define SUN_CKM_RC4 "CKM_RC4" +#define SUN_CKM_RSA_PKCS "CKM_RSA_PKCS" +#define SUN_CKM_RSA_X_509 "CKM_RSA_X_509" +#define SUN_CKM_MD5_RSA_PKCS "CKM_MD5_RSA_PKCS" +#define SUN_CKM_SHA1_RSA_PKCS "CKM_SHA1_RSA_PKCS" +#define SUN_CKM_SHA256_RSA_PKCS "CKM_SHA256_RSA_PKCS" +#define SUN_CKM_SHA384_RSA_PKCS "CKM_SHA384_RSA_PKCS" +#define SUN_CKM_SHA512_RSA_PKCS "CKM_SHA512_RSA_PKCS" +#define SUN_CKM_EC_KEY_PAIR_GEN "CKM_EC_KEY_PAIR_GEN" +#define SUN_CKM_ECDH1_DERIVE "CKM_ECDH1_DERIVE" +#define SUN_CKM_ECDSA_SHA1 "CKM_ECDSA_SHA1" +#define SUN_CKM_ECDSA "CKM_ECDSA" + +/* Shared operation context format for CKM_RC4 */ +typedef struct { +#if defined(__amd64) + uint32_t i, j; + uint32_t arr[256]; + uint32_t flag; +#else + uchar_t arr[256]; + uchar_t i, j; +#endif /* __amd64 */ + uint64_t pad; /* For 64-bit alignment */ +} arcfour_state_t; + +/* Data arguments of cryptographic operations */ + +typedef enum crypto_data_format { + CRYPTO_DATA_RAW = 1, + CRYPTO_DATA_UIO, + CRYPTO_DATA_MBLK +} crypto_data_format_t; + +typedef struct crypto_data { + crypto_data_format_t cd_format; /* Format identifier */ + off_t cd_offset; /* Offset from the beginning */ + size_t cd_length; /* # of bytes in use */ + caddr_t cd_miscdata; /* ancillary data */ + union { + /* Raw format */ + iovec_t cdu_raw; /* Pointer and length */ + + /* uio scatter-gather format */ + uio_t *cdu_uio; + + /* mblk scatter-gather format */ + mblk_t *cdu_mp; /* The mblk chain */ + + } cdu; /* Crypto Data Union */ +} crypto_data_t; + +#define cd_raw cdu.cdu_raw +#define cd_uio cdu.cdu_uio +#define cd_mp cdu.cdu_mp + +typedef struct crypto_dual_data { + crypto_data_t dd_data; /* The data */ + off_t dd_offset2; /* Used by dual operation */ + size_t dd_len2; /* # of bytes to take */ +} crypto_dual_data_t; + +#define dd_format dd_data.cd_format +#define dd_offset1 dd_data.cd_offset +#define dd_len1 dd_data.cd_length +#define dd_miscdata dd_data.cd_miscdata +#define dd_raw dd_data.cd_raw +#define dd_uio dd_data.cd_uio +#define dd_mp dd_data.cd_mp + +/* The keys, and their contents */ + +typedef enum { + CRYPTO_KEY_RAW = 1, /* ck_data is a cleartext key */ + CRYPTO_KEY_REFERENCE, /* ck_obj_id is an opaque reference */ + CRYPTO_KEY_ATTR_LIST /* ck_attrs is a list of object attributes */ +} crypto_key_format_t; + +typedef uint64_t crypto_attr_type_t; + +/* Attribute types to use for passing a RSA public key or a private key. */ +#define SUN_CKA_MODULUS 0x00000120 +#define SUN_CKA_MODULUS_BITS 0x00000121 +#define SUN_CKA_PUBLIC_EXPONENT 0x00000122 +#define SUN_CKA_PRIVATE_EXPONENT 0x00000123 +#define SUN_CKA_PRIME_1 0x00000124 +#define SUN_CKA_PRIME_2 0x00000125 +#define SUN_CKA_EXPONENT_1 0x00000126 +#define SUN_CKA_EXPONENT_2 0x00000127 +#define SUN_CKA_COEFFICIENT 0x00000128 +#define SUN_CKA_PRIME 0x00000130 +#define SUN_CKA_SUBPRIME 0x00000131 +#define SUN_CKA_BASE 0x00000132 + +#define CKK_EC 0x00000003UL +#define CKK_GENERIC_SECRET 0x00000010UL +#define CKK_RC4 0x00000012UL +#define CKK_AES 0x0000001FUL +#define CKK_DES 0x00000013UL +#define CKK_DES2 0x00000014UL +#define CKK_DES3 0x00000015UL + +#define CKO_PUBLIC_KEY 0x00000002UL +#define CKO_PRIVATE_KEY 0x00000003UL +#define CKA_CLASS 0x00000000UL +#define CKA_VALUE 0x00000011UL +#define CKA_KEY_TYPE 0x00000100UL +#define CKA_VALUE_LEN 0x00000161UL +#define CKA_EC_PARAMS 0x00000180UL +#define CKA_EC_POINT 0x00000181UL + +typedef uint32_t crypto_object_id_t; + +typedef struct crypto_object_attribute { + crypto_attr_type_t oa_type; /* attribute type */ + caddr_t oa_value; /* attribute value */ + ssize_t oa_value_len; /* length of attribute value */ +} crypto_object_attribute_t; + +typedef struct crypto_key { + crypto_key_format_t ck_format; /* format identifier */ + union { + /* for CRYPTO_KEY_RAW ck_format */ + struct { + uint_t cku_v_length; /* # of bits in ck_data */ + void *cku_v_data; /* ptr to key value */ + } cku_key_value; + + /* for CRYPTO_KEY_REFERENCE ck_format */ + crypto_object_id_t cku_key_id; /* reference to object key */ + + /* for CRYPTO_KEY_ATTR_LIST ck_format */ + struct { + uint_t cku_a_count; /* number of attributes */ + crypto_object_attribute_t *cku_a_oattr; + } cku_key_attrs; + } cku_data; /* Crypto Key union */ +} crypto_key_t; + +#ifdef _SYSCALL32 + +typedef struct crypto_object_attribute32 { + uint64_t oa_type; /* attribute type */ + caddr32_t oa_value; /* attribute value */ + ssize32_t oa_value_len; /* length of attribute value */ +} crypto_object_attribute32_t; + +typedef struct crypto_key32 { + crypto_key_format_t ck_format; /* format identifier */ + union { + /* for CRYPTO_KEY_RAW ck_format */ + struct { + uint32_t cku_v_length; /* # of bytes in ck_data */ + caddr32_t cku_v_data; /* ptr to key value */ + } cku_key_value; + + /* for CRYPTO_KEY_REFERENCE ck_format */ + crypto_object_id_t cku_key_id; /* reference to object key */ + + /* for CRYPTO_KEY_ATTR_LIST ck_format */ + struct { + uint32_t cku_a_count; /* number of attributes */ + caddr32_t cku_a_oattr; + } cku_key_attrs; + } cku_data; /* Crypto Key union */ +} crypto_key32_t; + +#endif /* _SYSCALL32 */ + +#define ck_data cku_data.cku_key_value.cku_v_data +#define ck_length cku_data.cku_key_value.cku_v_length +#define ck_obj_id cku_data.cku_key_id +#define ck_count cku_data.cku_key_attrs.cku_a_count +#define ck_attrs cku_data.cku_key_attrs.cku_a_oattr + +/* + * Raw key lengths are expressed in number of bits. + * The following macro returns the minimum number of + * bytes that can contain the specified number of bits. + * Round up without overflowing the integer type. + */ +#define CRYPTO_BITS2BYTES(n) ((n) == 0 ? 0 : (((n) - 1) >> 3) + 1) +#define CRYPTO_BYTES2BITS(n) ((n) << 3) + +/* Providers */ + +typedef enum { + CRYPTO_HW_PROVIDER = 0, + CRYPTO_SW_PROVIDER, + CRYPTO_LOGICAL_PROVIDER +} crypto_provider_type_t; + +typedef uint32_t crypto_provider_id_t; +#define KCF_PROVID_INVALID ((uint32_t)-1) + +typedef struct crypto_provider_entry { + crypto_provider_id_t pe_provider_id; + uint_t pe_mechanism_count; +} crypto_provider_entry_t; + +typedef struct crypto_dev_list_entry { + char le_dev_name[MAXNAMELEN]; + uint_t le_dev_instance; + uint_t le_mechanism_count; +} crypto_dev_list_entry_t; + +/* User type for authentication ioctls and SPI entry points */ + +typedef enum crypto_user_type { + CRYPTO_SO = 0, + CRYPTO_USER +} crypto_user_type_t; + +/* Version for provider management ioctls and SPI entry points */ + +typedef struct crypto_version { + uchar_t cv_major; + uchar_t cv_minor; +} crypto_version_t; + +/* session data structure opaque to the consumer */ +typedef void *crypto_session_t; + +/* provider data structure opaque to the consumer */ +typedef void *crypto_provider_t; + +/* Limits used by both consumers and providers */ +#define CRYPTO_EXT_SIZE_LABEL 32 +#define CRYPTO_EXT_SIZE_MANUF 32 +#define CRYPTO_EXT_SIZE_MODEL 16 +#define CRYPTO_EXT_SIZE_SERIAL 16 +#define CRYPTO_EXT_SIZE_TIME 16 + +typedef struct crypto_provider_ext_info { + uchar_t ei_label[CRYPTO_EXT_SIZE_LABEL]; + uchar_t ei_manufacturerID[CRYPTO_EXT_SIZE_MANUF]; + uchar_t ei_model[CRYPTO_EXT_SIZE_MODEL]; + uchar_t ei_serial_number[CRYPTO_EXT_SIZE_SERIAL]; + ulong_t ei_flags; + ulong_t ei_max_session_count; + ulong_t ei_max_pin_len; + ulong_t ei_min_pin_len; + ulong_t ei_total_public_memory; + ulong_t ei_free_public_memory; + ulong_t ei_total_private_memory; + ulong_t ei_free_private_memory; + crypto_version_t ei_hardware_version; + crypto_version_t ei_firmware_version; + uchar_t ei_time[CRYPTO_EXT_SIZE_TIME]; + int ei_hash_max_input_len; + int ei_hmac_max_input_len; +} crypto_provider_ext_info_t; + +typedef uint_t crypto_session_id_t; + +typedef enum cmd_type { + COPY_FROM_DATA, + COPY_TO_DATA, + COMPARE_TO_DATA, + MD5_DIGEST_DATA, + SHA1_DIGEST_DATA, + SHA2_DIGEST_DATA, + GHASH_DATA +} cmd_type_t; + +#define CRYPTO_DO_UPDATE 0x01 +#define CRYPTO_DO_FINAL 0x02 +#define CRYPTO_DO_MD5 0x04 +#define CRYPTO_DO_SHA1 0x08 +#define CRYPTO_DO_SIGN 0x10 +#define CRYPTO_DO_VERIFY 0x20 +#define CRYPTO_DO_SHA2 0x40 + +#define PROVIDER_OWNS_KEY_SCHEDULE 0x00000001 + +/* + * Common cryptographic status and error codes. + */ +#define CRYPTO_SUCCESS 0x00000000 +#define CRYPTO_CANCEL 0x00000001 +#define CRYPTO_HOST_MEMORY 0x00000002 +#define CRYPTO_GENERAL_ERROR 0x00000003 +#define CRYPTO_FAILED 0x00000004 +#define CRYPTO_ARGUMENTS_BAD 0x00000005 +#define CRYPTO_ATTRIBUTE_READ_ONLY 0x00000006 +#define CRYPTO_ATTRIBUTE_SENSITIVE 0x00000007 +#define CRYPTO_ATTRIBUTE_TYPE_INVALID 0x00000008 +#define CRYPTO_ATTRIBUTE_VALUE_INVALID 0x00000009 +#define CRYPTO_CANCELED 0x0000000A +#define CRYPTO_DATA_INVALID 0x0000000B +#define CRYPTO_DATA_LEN_RANGE 0x0000000C +#define CRYPTO_DEVICE_ERROR 0x0000000D +#define CRYPTO_DEVICE_MEMORY 0x0000000E +#define CRYPTO_DEVICE_REMOVED 0x0000000F +#define CRYPTO_ENCRYPTED_DATA_INVALID 0x00000010 +#define CRYPTO_ENCRYPTED_DATA_LEN_RANGE 0x00000011 +#define CRYPTO_KEY_HANDLE_INVALID 0x00000012 +#define CRYPTO_KEY_SIZE_RANGE 0x00000013 +#define CRYPTO_KEY_TYPE_INCONSISTENT 0x00000014 +#define CRYPTO_KEY_NOT_NEEDED 0x00000015 +#define CRYPTO_KEY_CHANGED 0x00000016 +#define CRYPTO_KEY_NEEDED 0x00000017 +#define CRYPTO_KEY_INDIGESTIBLE 0x00000018 +#define CRYPTO_KEY_FUNCTION_NOT_PERMITTED 0x00000019 +#define CRYPTO_KEY_NOT_WRAPPABLE 0x0000001A +#define CRYPTO_KEY_UNEXTRACTABLE 0x0000001B +#define CRYPTO_MECHANISM_INVALID 0x0000001C +#define CRYPTO_MECHANISM_PARAM_INVALID 0x0000001D +#define CRYPTO_OBJECT_HANDLE_INVALID 0x0000001E +#define CRYPTO_OPERATION_IS_ACTIVE 0x0000001F +#define CRYPTO_OPERATION_NOT_INITIALIZED 0x00000020 +#define CRYPTO_PIN_INCORRECT 0x00000021 +#define CRYPTO_PIN_INVALID 0x00000022 +#define CRYPTO_PIN_LEN_RANGE 0x00000023 +#define CRYPTO_PIN_EXPIRED 0x00000024 +#define CRYPTO_PIN_LOCKED 0x00000025 +#define CRYPTO_SESSION_CLOSED 0x00000026 +#define CRYPTO_SESSION_COUNT 0x00000027 +#define CRYPTO_SESSION_HANDLE_INVALID 0x00000028 +#define CRYPTO_SESSION_READ_ONLY 0x00000029 +#define CRYPTO_SESSION_EXISTS 0x0000002A +#define CRYPTO_SESSION_READ_ONLY_EXISTS 0x0000002B +#define CRYPTO_SESSION_READ_WRITE_SO_EXISTS 0x0000002C +#define CRYPTO_SIGNATURE_INVALID 0x0000002D +#define CRYPTO_SIGNATURE_LEN_RANGE 0x0000002E +#define CRYPTO_TEMPLATE_INCOMPLETE 0x0000002F +#define CRYPTO_TEMPLATE_INCONSISTENT 0x00000030 +#define CRYPTO_UNWRAPPING_KEY_HANDLE_INVALID 0x00000031 +#define CRYPTO_UNWRAPPING_KEY_SIZE_RANGE 0x00000032 +#define CRYPTO_UNWRAPPING_KEY_TYPE_INCONSISTENT 0x00000033 +#define CRYPTO_USER_ALREADY_LOGGED_IN 0x00000034 +#define CRYPTO_USER_NOT_LOGGED_IN 0x00000035 +#define CRYPTO_USER_PIN_NOT_INITIALIZED 0x00000036 +#define CRYPTO_USER_TYPE_INVALID 0x00000037 +#define CRYPTO_USER_ANOTHER_ALREADY_LOGGED_IN 0x00000038 +#define CRYPTO_USER_TOO_MANY_TYPES 0x00000039 +#define CRYPTO_WRAPPED_KEY_INVALID 0x0000003A +#define CRYPTO_WRAPPED_KEY_LEN_RANGE 0x0000003B +#define CRYPTO_WRAPPING_KEY_HANDLE_INVALID 0x0000003C +#define CRYPTO_WRAPPING_KEY_SIZE_RANGE 0x0000003D +#define CRYPTO_WRAPPING_KEY_TYPE_INCONSISTENT 0x0000003E +#define CRYPTO_RANDOM_SEED_NOT_SUPPORTED 0x0000003F +#define CRYPTO_RANDOM_NO_RNG 0x00000040 +#define CRYPTO_DOMAIN_PARAMS_INVALID 0x00000041 +#define CRYPTO_BUFFER_TOO_SMALL 0x00000042 +#define CRYPTO_INFORMATION_SENSITIVE 0x00000043 +#define CRYPTO_NOT_SUPPORTED 0x00000044 + +#define CRYPTO_QUEUED 0x00000045 +#define CRYPTO_BUFFER_TOO_BIG 0x00000046 +#define CRYPTO_INVALID_CONTEXT 0x00000047 +#define CRYPTO_INVALID_MAC 0x00000048 +#define CRYPTO_MECH_NOT_SUPPORTED 0x00000049 +#define CRYPTO_INCONSISTENT_ATTRIBUTE 0x0000004A +#define CRYPTO_NO_PERMISSION 0x0000004B +#define CRYPTO_INVALID_PROVIDER_ID 0x0000004C +#define CRYPTO_VERSION_MISMATCH 0x0000004D +#define CRYPTO_BUSY 0x0000004E +#define CRYPTO_UNKNOWN_PROVIDER 0x0000004F +#define CRYPTO_MODVERIFICATION_FAILED 0x00000050 +#define CRYPTO_OLD_CTX_TEMPLATE 0x00000051 +#define CRYPTO_WEAK_KEY 0x00000052 +#define CRYPTO_FIPS140_ERROR 0x00000053 +/* + * Don't forget to update CRYPTO_LAST_ERROR and the error_number_table[] + * in kernelUtil.c when new error code is added. + */ +#define CRYPTO_LAST_ERROR 0x00000053 + +/* + * Special values that can be used to indicate that information is unavailable + * or that there is not practical limit. These values can be used + * by fields of the SPI crypto_provider_ext_info(9S) structure. + * The value of CRYPTO_UNAVAILABLE_INFO should be the same as + * CK_UNAVAILABLE_INFO in the PKCS#11 spec. + */ +#define CRYPTO_UNAVAILABLE_INFO ((ulong_t)(-1)) +#define CRYPTO_EFFECTIVELY_INFINITE 0x0 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRYPTO_COMMON_H */ diff --git a/illumos-x86_64/usr/include/sys/crypto/ioctl.h b/illumos-x86_64/usr/include/sys/crypto/ioctl.h new file mode 100644 index 00000000..b7b51176 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/crypto/ioctl.h @@ -0,0 +1,1501 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CRYPTO_IOCTL_H +#define _SYS_CRYPTO_IOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#define CRYPTO_MAX_ATTRIBUTE_COUNT 128 + +#define CRYPTO_IOFLAGS_RW_SESSION 0x00000001 + +#define CRYPTO(x) (('y' << 8) | (x)) + +#define MAX_NUM_THRESHOLD 7 + +/* the PKCS11 Mechanisms */ +#define CKM_RC4 0x00000111UL +#define CKM_DES3_ECB 0x00000132UL +#define CKM_DES3_CBC 0x00000133UL +#define CKM_MD5 0x00000210UL +#define CKM_SHA_1 0x00000220UL +#define CKM_AES_ECB 0x00001081UL +#define CKM_AES_CBC 0x00001082UL + +/* + * General Purpose Ioctls + */ + +typedef struct fl_mechs_threshold { + int mech_type; + uint32_t mech_threshold; +} fl_mechs_threshold_t; + +typedef struct crypto_function_list { + boolean_t fl_digest_init; + boolean_t fl_digest; + boolean_t fl_digest_update; + boolean_t fl_digest_key; + boolean_t fl_digest_final; + + boolean_t fl_encrypt_init; + boolean_t fl_encrypt; + boolean_t fl_encrypt_update; + boolean_t fl_encrypt_final; + + boolean_t fl_decrypt_init; + boolean_t fl_decrypt; + boolean_t fl_decrypt_update; + boolean_t fl_decrypt_final; + + boolean_t fl_mac_init; + boolean_t fl_mac; + boolean_t fl_mac_update; + boolean_t fl_mac_final; + + boolean_t fl_sign_init; + boolean_t fl_sign; + boolean_t fl_sign_update; + boolean_t fl_sign_final; + boolean_t fl_sign_recover_init; + boolean_t fl_sign_recover; + + boolean_t fl_verify_init; + boolean_t fl_verify; + boolean_t fl_verify_update; + boolean_t fl_verify_final; + boolean_t fl_verify_recover_init; + boolean_t fl_verify_recover; + + boolean_t fl_digest_encrypt_update; + boolean_t fl_decrypt_digest_update; + boolean_t fl_sign_encrypt_update; + boolean_t fl_decrypt_verify_update; + + boolean_t fl_seed_random; + boolean_t fl_generate_random; + + boolean_t fl_session_open; + boolean_t fl_session_close; + boolean_t fl_session_login; + boolean_t fl_session_logout; + + boolean_t fl_object_create; + boolean_t fl_object_copy; + boolean_t fl_object_destroy; + boolean_t fl_object_get_size; + boolean_t fl_object_get_attribute_value; + boolean_t fl_object_set_attribute_value; + boolean_t fl_object_find_init; + boolean_t fl_object_find; + boolean_t fl_object_find_final; + + boolean_t fl_key_generate; + boolean_t fl_key_generate_pair; + boolean_t fl_key_wrap; + boolean_t fl_key_unwrap; + boolean_t fl_key_derive; + + boolean_t fl_init_token; + boolean_t fl_init_pin; + boolean_t fl_set_pin; + + boolean_t prov_is_hash_limited; + uint32_t prov_hash_threshold; + uint32_t prov_hash_limit; + + boolean_t prov_is_hmac_limited; + uint32_t prov_hmac_limit; + + int total_threshold_count; + fl_mechs_threshold_t fl_threshold[MAX_NUM_THRESHOLD]; +} crypto_function_list_t; + +typedef struct crypto_get_function_list { + uint_t fl_return_value; + crypto_provider_id_t fl_provider_id; + crypto_function_list_t fl_list; +} crypto_get_function_list_t; + +typedef struct crypto_get_mechanism_number { + uint_t pn_return_value; + caddr_t pn_mechanism_string; + size_t pn_mechanism_len; + crypto_mech_type_t pn_internal_number; +} crypto_get_mechanism_number_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_get_mechanism_number32 { + uint32_t pn_return_value; + caddr32_t pn_mechanism_string; + size32_t pn_mechanism_len; + crypto_mech_type_t pn_internal_number; +} crypto_get_mechanism_number32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_GET_FUNCTION_LIST CRYPTO(20) +#define CRYPTO_GET_MECHANISM_NUMBER CRYPTO(21) + +/* + * Session Ioctls + */ + +typedef uint32_t crypto_flags_t; + +typedef struct crypto_open_session { + uint_t os_return_value; + crypto_session_id_t os_session; + crypto_flags_t os_flags; + crypto_provider_id_t os_provider_id; +} crypto_open_session_t; + +typedef struct crypto_close_session { + uint_t cs_return_value; + crypto_session_id_t cs_session; +} crypto_close_session_t; + +typedef struct crypto_close_all_sessions { + uint_t as_return_value; + crypto_provider_id_t as_provider_id; +} crypto_close_all_sessions_t; + +#define CRYPTO_OPEN_SESSION CRYPTO(30) +#define CRYPTO_CLOSE_SESSION CRYPTO(31) +#define CRYPTO_CLOSE_ALL_SESSIONS CRYPTO(32) + +/* + * Login Ioctls + */ +typedef struct crypto_login { + uint_t co_return_value; + crypto_session_id_t co_session; + uint_t co_user_type; + uint_t co_pin_len; + caddr_t co_pin; +} crypto_login_t; + +typedef struct crypto_logout { + uint_t cl_return_value; + crypto_session_id_t cl_session; +} crypto_logout_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +typedef struct crypto_login32 { + uint32_t co_return_value; + crypto_session_id_t co_session; + uint32_t co_user_type; + uint32_t co_pin_len; + caddr32_t co_pin; +} crypto_login32_t; + +typedef struct crypto_logout32 { + uint32_t cl_return_value; + crypto_session_id_t cl_session; +} crypto_logout32_t; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_LOGIN CRYPTO(40) +#define CRYPTO_LOGOUT CRYPTO(41) + +/* flag for encrypt and decrypt operations */ +#define CRYPTO_INPLACE_OPERATION 0x00000001 + +/* + * Cryptographic Ioctls + */ +typedef struct crypto_encrypt { + uint_t ce_return_value; + crypto_session_id_t ce_session; + size_t ce_datalen; + caddr_t ce_databuf; + size_t ce_encrlen; + caddr_t ce_encrbuf; + uint_t ce_flags; +} crypto_encrypt_t; + +typedef struct crypto_encrypt_init { + uint_t ei_return_value; + crypto_session_id_t ei_session; + crypto_mechanism_t ei_mech; + crypto_key_t ei_key; +} crypto_encrypt_init_t; + +typedef struct crypto_encrypt_update { + uint_t eu_return_value; + crypto_session_id_t eu_session; + size_t eu_datalen; + caddr_t eu_databuf; + size_t eu_encrlen; + caddr_t eu_encrbuf; + uint_t eu_flags; +} crypto_encrypt_update_t; + +typedef struct crypto_encrypt_final { + uint_t ef_return_value; + crypto_session_id_t ef_session; + size_t ef_encrlen; + caddr_t ef_encrbuf; +} crypto_encrypt_final_t; + +typedef struct crypto_decrypt { + uint_t cd_return_value; + crypto_session_id_t cd_session; + size_t cd_encrlen; + caddr_t cd_encrbuf; + size_t cd_datalen; + caddr_t cd_databuf; + uint_t cd_flags; +} crypto_decrypt_t; + +typedef struct crypto_decrypt_init { + uint_t di_return_value; + crypto_session_id_t di_session; + crypto_mechanism_t di_mech; + crypto_key_t di_key; +} crypto_decrypt_init_t; + +typedef struct crypto_decrypt_update { + uint_t du_return_value; + crypto_session_id_t du_session; + size_t du_encrlen; + caddr_t du_encrbuf; + size_t du_datalen; + caddr_t du_databuf; + uint_t du_flags; +} crypto_decrypt_update_t; + +typedef struct crypto_decrypt_final { + uint_t df_return_value; + crypto_session_id_t df_session; + size_t df_datalen; + caddr_t df_databuf; +} crypto_decrypt_final_t; + +typedef struct crypto_digest { + uint_t cd_return_value; + crypto_session_id_t cd_session; + size_t cd_datalen; + caddr_t cd_databuf; + size_t cd_digestlen; + caddr_t cd_digestbuf; +} crypto_digest_t; + +typedef struct crypto_digest_init { + uint_t di_return_value; + crypto_session_id_t di_session; + crypto_mechanism_t di_mech; +} crypto_digest_init_t; + +typedef struct crypto_digest_update { + uint_t du_return_value; + crypto_session_id_t du_session; + size_t du_datalen; + caddr_t du_databuf; +} crypto_digest_update_t; + +typedef struct crypto_digest_key { + uint_t dk_return_value; + crypto_session_id_t dk_session; + crypto_key_t dk_key; +} crypto_digest_key_t; + +typedef struct crypto_digest_final { + uint_t df_return_value; + crypto_session_id_t df_session; + size_t df_digestlen; + caddr_t df_digestbuf; +} crypto_digest_final_t; + +typedef struct crypto_mac { + uint_t cm_return_value; + crypto_session_id_t cm_session; + size_t cm_datalen; + caddr_t cm_databuf; + size_t cm_maclen; + caddr_t cm_macbuf; +} crypto_mac_t; + +typedef struct crypto_mac_init { + uint_t mi_return_value; + crypto_session_id_t mi_session; + crypto_mechanism_t mi_mech; + crypto_key_t mi_key; +} crypto_mac_init_t; + +typedef struct crypto_mac_update { + uint_t mu_return_value; + crypto_session_id_t mu_session; + size_t mu_datalen; + caddr_t mu_databuf; +} crypto_mac_update_t; + +typedef struct crypto_mac_final { + uint_t mf_return_value; + crypto_session_id_t mf_session; + size_t mf_maclen; + caddr_t mf_macbuf; +} crypto_mac_final_t; + +typedef struct crypto_sign { + uint_t cs_return_value; + crypto_session_id_t cs_session; + size_t cs_datalen; + caddr_t cs_databuf; + size_t cs_signlen; + caddr_t cs_signbuf; +} crypto_sign_t; + +typedef struct crypto_sign_init { + uint_t si_return_value; + crypto_session_id_t si_session; + crypto_mechanism_t si_mech; + crypto_key_t si_key; +} crypto_sign_init_t; + +typedef struct crypto_sign_update { + uint_t su_return_value; + crypto_session_id_t su_session; + size_t su_datalen; + caddr_t su_databuf; +} crypto_sign_update_t; + +typedef struct crypto_sign_final { + uint_t sf_return_value; + crypto_session_id_t sf_session; + size_t sf_signlen; + caddr_t sf_signbuf; +} crypto_sign_final_t; + +typedef struct crypto_sign_recover_init { + uint_t ri_return_value; + crypto_session_id_t ri_session; + crypto_mechanism_t ri_mech; + crypto_key_t ri_key; +} crypto_sign_recover_init_t; + +typedef struct crypto_sign_recover { + uint_t sr_return_value; + crypto_session_id_t sr_session; + size_t sr_datalen; + caddr_t sr_databuf; + size_t sr_signlen; + caddr_t sr_signbuf; +} crypto_sign_recover_t; + +typedef struct crypto_verify { + uint_t cv_return_value; + crypto_session_id_t cv_session; + size_t cv_datalen; + caddr_t cv_databuf; + size_t cv_signlen; + caddr_t cv_signbuf; +} crypto_verify_t; + +typedef struct crypto_verify_init { + uint_t vi_return_value; + crypto_session_id_t vi_session; + crypto_mechanism_t vi_mech; + crypto_key_t vi_key; +} crypto_verify_init_t; + +typedef struct crypto_verify_update { + uint_t vu_return_value; + crypto_session_id_t vu_session; + size_t vu_datalen; + caddr_t vu_databuf; +} crypto_verify_update_t; + +typedef struct crypto_verify_final { + uint_t vf_return_value; + crypto_session_id_t vf_session; + size_t vf_signlen; + caddr_t vf_signbuf; +} crypto_verify_final_t; + +typedef struct crypto_verify_recover_init { + uint_t ri_return_value; + crypto_session_id_t ri_session; + crypto_mechanism_t ri_mech; + crypto_key_t ri_key; +} crypto_verify_recover_init_t; + +typedef struct crypto_verify_recover { + uint_t vr_return_value; + crypto_session_id_t vr_session; + size_t vr_signlen; + caddr_t vr_signbuf; + size_t vr_datalen; + caddr_t vr_databuf; +} crypto_verify_recover_t; + +typedef struct crypto_digest_encrypt_update { + uint_t eu_return_value; + crypto_session_id_t eu_session; + size_t eu_datalen; + caddr_t eu_databuf; + size_t eu_encrlen; + caddr_t eu_encrbuf; +} crypto_digest_encrypt_update_t; + +typedef struct crypto_decrypt_digest_update { + uint_t du_return_value; + crypto_session_id_t du_session; + size_t du_encrlen; + caddr_t du_encrbuf; + size_t du_datalen; + caddr_t du_databuf; +} crypto_decrypt_digest_update_t; + +typedef struct crypto_sign_encrypt_update { + uint_t eu_return_value; + crypto_session_id_t eu_session; + size_t eu_datalen; + caddr_t eu_databuf; + size_t eu_encrlen; + caddr_t eu_encrbuf; +} crypto_sign_encrypt_update_t; + +typedef struct crypto_decrypt_verify_update { + uint_t vu_return_value; + crypto_session_id_t vu_session; + size_t vu_encrlen; + caddr_t vu_encrbuf; + size_t vu_datalen; + caddr_t vu_databuf; +} crypto_decrypt_verify_update_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +typedef struct crypto_encrypt32 { + uint32_t ce_return_value; + crypto_session_id_t ce_session; + size32_t ce_datalen; + caddr32_t ce_databuf; + size32_t ce_encrlen; + caddr32_t ce_encrbuf; + uint32_t ce_flags; +} crypto_encrypt32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_encrypt_init32 { + uint32_t ei_return_value; + crypto_session_id_t ei_session; + crypto_mechanism32_t ei_mech; + crypto_key32_t ei_key; +} crypto_encrypt_init32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct crypto_encrypt_update32 { + uint32_t eu_return_value; + crypto_session_id_t eu_session; + size32_t eu_datalen; + caddr32_t eu_databuf; + size32_t eu_encrlen; + caddr32_t eu_encrbuf; + uint_t eu_flags; +} crypto_encrypt_update32_t; + +typedef struct crypto_encrypt_final32 { + uint32_t ef_return_value; + crypto_session_id_t ef_session; + size32_t ef_encrlen; + caddr32_t ef_encrbuf; +} crypto_encrypt_final32_t; + +typedef struct crypto_decrypt32 { + uint32_t cd_return_value; + crypto_session_id_t cd_session; + size32_t cd_encrlen; + caddr32_t cd_encrbuf; + size32_t cd_datalen; + caddr32_t cd_databuf; + uint32_t cd_flags; +} crypto_decrypt32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_decrypt_init32 { + uint32_t di_return_value; + crypto_session_id_t di_session; + crypto_mechanism32_t di_mech; + crypto_key32_t di_key; +} crypto_decrypt_init32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct crypto_decrypt_update32 { + uint32_t du_return_value; + crypto_session_id_t du_session; + size32_t du_encrlen; + caddr32_t du_encrbuf; + size32_t du_datalen; + caddr32_t du_databuf; + uint_t du_flags; +} crypto_decrypt_update32_t; + +typedef struct crypto_decrypt_final32 { + uint32_t df_return_value; + crypto_session_id_t df_session; + size32_t df_datalen; + caddr32_t df_databuf; +} crypto_decrypt_final32_t; + +typedef struct crypto_digest32 { + uint32_t cd_return_value; + crypto_session_id_t cd_session; + size32_t cd_datalen; + caddr32_t cd_databuf; + size32_t cd_digestlen; + caddr32_t cd_digestbuf; +} crypto_digest32_t; + +typedef struct crypto_digest_init32 { + uint32_t di_return_value; + crypto_session_id_t di_session; + crypto_mechanism32_t di_mech; +} crypto_digest_init32_t; + +typedef struct crypto_digest_update32 { + uint32_t du_return_value; + crypto_session_id_t du_session; + size32_t du_datalen; + caddr32_t du_databuf; +} crypto_digest_update32_t; + +typedef struct crypto_digest_key32 { + uint32_t dk_return_value; + crypto_session_id_t dk_session; + crypto_key32_t dk_key; +} crypto_digest_key32_t; + +typedef struct crypto_digest_final32 { + uint32_t df_return_value; + crypto_session_id_t df_session; + size32_t df_digestlen; + caddr32_t df_digestbuf; +} crypto_digest_final32_t; + +typedef struct crypto_mac32 { + uint32_t cm_return_value; + crypto_session_id_t cm_session; + size32_t cm_datalen; + caddr32_t cm_databuf; + size32_t cm_maclen; + caddr32_t cm_macbuf; +} crypto_mac32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_mac_init32 { + uint32_t mi_return_value; + crypto_session_id_t mi_session; + crypto_mechanism32_t mi_mech; + crypto_key32_t mi_key; +} crypto_mac_init32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct crypto_mac_update32 { + uint32_t mu_return_value; + crypto_session_id_t mu_session; + size32_t mu_datalen; + caddr32_t mu_databuf; +} crypto_mac_update32_t; + +typedef struct crypto_mac_final32 { + uint32_t mf_return_value; + crypto_session_id_t mf_session; + size32_t mf_maclen; + caddr32_t mf_macbuf; +} crypto_mac_final32_t; + +typedef struct crypto_sign32 { + uint32_t cs_return_value; + crypto_session_id_t cs_session; + size32_t cs_datalen; + caddr32_t cs_databuf; + size32_t cs_signlen; + caddr32_t cs_signbuf; +} crypto_sign32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_sign_init32 { + uint32_t si_return_value; + crypto_session_id_t si_session; + crypto_mechanism32_t si_mech; + crypto_key32_t si_key; +} crypto_sign_init32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct crypto_sign_update32 { + uint32_t su_return_value; + crypto_session_id_t su_session; + size32_t su_datalen; + caddr32_t su_databuf; +} crypto_sign_update32_t; + +typedef struct crypto_sign_final32 { + uint32_t sf_return_value; + crypto_session_id_t sf_session; + size32_t sf_signlen; + caddr32_t sf_signbuf; +} crypto_sign_final32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_sign_recover_init32 { + uint32_t ri_return_value; + crypto_session_id_t ri_session; + crypto_mechanism32_t ri_mech; + crypto_key32_t ri_key; +} crypto_sign_recover_init32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct crypto_sign_recover32 { + uint32_t sr_return_value; + crypto_session_id_t sr_session; + size32_t sr_datalen; + caddr32_t sr_databuf; + size32_t sr_signlen; + caddr32_t sr_signbuf; +} crypto_sign_recover32_t; + +typedef struct crypto_verify32 { + uint32_t cv_return_value; + crypto_session_id_t cv_session; + size32_t cv_datalen; + caddr32_t cv_databuf; + size32_t cv_signlen; + caddr32_t cv_signbuf; +} crypto_verify32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_verify_init32 { + uint32_t vi_return_value; + crypto_session_id_t vi_session; + crypto_mechanism32_t vi_mech; + crypto_key32_t vi_key; +} crypto_verify_init32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct crypto_verify_update32 { + uint32_t vu_return_value; + crypto_session_id_t vu_session; + size32_t vu_datalen; + caddr32_t vu_databuf; +} crypto_verify_update32_t; + +typedef struct crypto_verify_final32 { + uint32_t vf_return_value; + crypto_session_id_t vf_session; + size32_t vf_signlen; + caddr32_t vf_signbuf; +} crypto_verify_final32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_verify_recover_init32 { + uint32_t ri_return_value; + crypto_session_id_t ri_session; + crypto_mechanism32_t ri_mech; + crypto_key32_t ri_key; +} crypto_verify_recover_init32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct crypto_verify_recover32 { + uint32_t vr_return_value; + crypto_session_id_t vr_session; + size32_t vr_signlen; + caddr32_t vr_signbuf; + size32_t vr_datalen; + caddr32_t vr_databuf; +} crypto_verify_recover32_t; + +typedef struct crypto_digest_encrypt_update32 { + uint32_t eu_return_value; + crypto_session_id_t eu_session; + size32_t eu_datalen; + caddr32_t eu_databuf; + size32_t eu_encrlen; + caddr32_t eu_encrbuf; +} crypto_digest_encrypt_update32_t; + +typedef struct crypto_decrypt_digest_update32 { + uint32_t du_return_value; + crypto_session_id_t du_session; + size32_t du_encrlen; + caddr32_t du_encrbuf; + size32_t du_datalen; + caddr32_t du_databuf; +} crypto_decrypt_digest_update32_t; + +typedef struct crypto_sign_encrypt_update32 { + uint32_t eu_return_value; + crypto_session_id_t eu_session; + size32_t eu_datalen; + caddr32_t eu_databuf; + size32_t eu_encrlen; + caddr32_t eu_encrbuf; +} crypto_sign_encrypt_update32_t; + +typedef struct crypto_decrypt_verify_update32 { + uint32_t vu_return_value; + crypto_session_id_t vu_session; + size32_t vu_encrlen; + caddr32_t vu_encrbuf; + size32_t vu_datalen; + caddr32_t vu_databuf; +} crypto_decrypt_verify_update32_t; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_ENCRYPT CRYPTO(50) +#define CRYPTO_ENCRYPT_INIT CRYPTO(51) +#define CRYPTO_ENCRYPT_UPDATE CRYPTO(52) +#define CRYPTO_ENCRYPT_FINAL CRYPTO(53) +#define CRYPTO_DECRYPT CRYPTO(54) +#define CRYPTO_DECRYPT_INIT CRYPTO(55) +#define CRYPTO_DECRYPT_UPDATE CRYPTO(56) +#define CRYPTO_DECRYPT_FINAL CRYPTO(57) + +#define CRYPTO_DIGEST CRYPTO(58) +#define CRYPTO_DIGEST_INIT CRYPTO(59) +#define CRYPTO_DIGEST_UPDATE CRYPTO(60) +#define CRYPTO_DIGEST_KEY CRYPTO(61) +#define CRYPTO_DIGEST_FINAL CRYPTO(62) +#define CRYPTO_MAC CRYPTO(63) +#define CRYPTO_MAC_INIT CRYPTO(64) +#define CRYPTO_MAC_UPDATE CRYPTO(65) +#define CRYPTO_MAC_FINAL CRYPTO(66) + +#define CRYPTO_SIGN CRYPTO(67) +#define CRYPTO_SIGN_INIT CRYPTO(68) +#define CRYPTO_SIGN_UPDATE CRYPTO(69) +#define CRYPTO_SIGN_FINAL CRYPTO(70) +#define CRYPTO_SIGN_RECOVER_INIT CRYPTO(71) +#define CRYPTO_SIGN_RECOVER CRYPTO(72) +#define CRYPTO_VERIFY CRYPTO(73) +#define CRYPTO_VERIFY_INIT CRYPTO(74) +#define CRYPTO_VERIFY_UPDATE CRYPTO(75) +#define CRYPTO_VERIFY_FINAL CRYPTO(76) +#define CRYPTO_VERIFY_RECOVER_INIT CRYPTO(77) +#define CRYPTO_VERIFY_RECOVER CRYPTO(78) + +#define CRYPTO_DIGEST_ENCRYPT_UPDATE CRYPTO(79) +#define CRYPTO_DECRYPT_DIGEST_UPDATE CRYPTO(80) +#define CRYPTO_SIGN_ENCRYPT_UPDATE CRYPTO(81) +#define CRYPTO_DECRYPT_VERIFY_UPDATE CRYPTO(82) + +/* + * Random Number Ioctls + */ +typedef struct crypto_seed_random { + uint_t sr_return_value; + crypto_session_id_t sr_session; + size_t sr_seedlen; + caddr_t sr_seedbuf; +} crypto_seed_random_t; + +typedef struct crypto_generate_random { + uint_t gr_return_value; + crypto_session_id_t gr_session; + caddr_t gr_buf; + size_t gr_buflen; +} crypto_generate_random_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +typedef struct crypto_seed_random32 { + uint32_t sr_return_value; + crypto_session_id_t sr_session; + size32_t sr_seedlen; + caddr32_t sr_seedbuf; +} crypto_seed_random32_t; + +typedef struct crypto_generate_random32 { + uint32_t gr_return_value; + crypto_session_id_t gr_session; + caddr32_t gr_buf; + size32_t gr_buflen; +} crypto_generate_random32_t; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_SEED_RANDOM CRYPTO(90) +#define CRYPTO_GENERATE_RANDOM CRYPTO(91) + +/* + * Object Management Ioctls + */ +typedef struct crypto_object_create { + uint_t oc_return_value; + crypto_session_id_t oc_session; + crypto_object_id_t oc_handle; + uint_t oc_count; + caddr_t oc_attributes; +} crypto_object_create_t; + +typedef struct crypto_object_copy { + uint_t oc_return_value; + crypto_session_id_t oc_session; + crypto_object_id_t oc_handle; + crypto_object_id_t oc_new_handle; + uint_t oc_count; + caddr_t oc_new_attributes; +} crypto_object_copy_t; + +typedef struct crypto_object_destroy { + uint_t od_return_value; + crypto_session_id_t od_session; + crypto_object_id_t od_handle; +} crypto_object_destroy_t; + +typedef struct crypto_object_get_attribute_value { + uint_t og_return_value; + crypto_session_id_t og_session; + crypto_object_id_t og_handle; + uint_t og_count; + caddr_t og_attributes; +} crypto_object_get_attribute_value_t; + +typedef struct crypto_object_get_size { + uint_t gs_return_value; + crypto_session_id_t gs_session; + crypto_object_id_t gs_handle; + size_t gs_size; +} crypto_object_get_size_t; + +typedef struct crypto_object_set_attribute_value { + uint_t sa_return_value; + crypto_session_id_t sa_session; + crypto_object_id_t sa_handle; + uint_t sa_count; + caddr_t sa_attributes; +} crypto_object_set_attribute_value_t; + +typedef struct crypto_object_find_init { + uint_t fi_return_value; + crypto_session_id_t fi_session; + uint_t fi_count; + caddr_t fi_attributes; +} crypto_object_find_init_t; + +typedef struct crypto_object_find_update { + uint_t fu_return_value; + crypto_session_id_t fu_session; + uint_t fu_max_count; + uint_t fu_count; + caddr_t fu_handles; +} crypto_object_find_update_t; + +typedef struct crypto_object_find_final { + uint_t ff_return_value; + crypto_session_id_t ff_session; +} crypto_object_find_final_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +typedef struct crypto_object_create32 { + uint32_t oc_return_value; + crypto_session_id_t oc_session; + crypto_object_id_t oc_handle; + uint32_t oc_count; + caddr32_t oc_attributes; +} crypto_object_create32_t; + +typedef struct crypto_object_copy32 { + uint32_t oc_return_value; + crypto_session_id_t oc_session; + crypto_object_id_t oc_handle; + crypto_object_id_t oc_new_handle; + uint32_t oc_count; + caddr32_t oc_new_attributes; +} crypto_object_copy32_t; + +typedef struct crypto_object_destroy32 { + uint32_t od_return_value; + crypto_session_id_t od_session; + crypto_object_id_t od_handle; +} crypto_object_destroy32_t; + +typedef struct crypto_object_get_attribute_value32 { + uint32_t og_return_value; + crypto_session_id_t og_session; + crypto_object_id_t og_handle; + uint32_t og_count; + caddr32_t og_attributes; +} crypto_object_get_attribute_value32_t; + +typedef struct crypto_object_get_size32 { + uint32_t gs_return_value; + crypto_session_id_t gs_session; + crypto_object_id_t gs_handle; + size32_t gs_size; +} crypto_object_get_size32_t; + +typedef struct crypto_object_set_attribute_value32 { + uint32_t sa_return_value; + crypto_session_id_t sa_session; + crypto_object_id_t sa_handle; + uint32_t sa_count; + caddr32_t sa_attributes; +} crypto_object_set_attribute_value32_t; + +typedef struct crypto_object_find_init32 { + uint32_t fi_return_value; + crypto_session_id_t fi_session; + uint32_t fi_count; + caddr32_t fi_attributes; +} crypto_object_find_init32_t; + +typedef struct crypto_object_find_update32 { + uint32_t fu_return_value; + crypto_session_id_t fu_session; + uint32_t fu_max_count; + uint32_t fu_count; + caddr32_t fu_handles; +} crypto_object_find_update32_t; + +typedef struct crypto_object_find_final32 { + uint32_t ff_return_value; + crypto_session_id_t ff_session; +} crypto_object_find_final32_t; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_OBJECT_CREATE CRYPTO(100) +#define CRYPTO_OBJECT_COPY CRYPTO(101) +#define CRYPTO_OBJECT_DESTROY CRYPTO(102) +#define CRYPTO_OBJECT_GET_ATTRIBUTE_VALUE CRYPTO(103) +#define CRYPTO_OBJECT_GET_SIZE CRYPTO(104) +#define CRYPTO_OBJECT_SET_ATTRIBUTE_VALUE CRYPTO(105) +#define CRYPTO_OBJECT_FIND_INIT CRYPTO(106) +#define CRYPTO_OBJECT_FIND_UPDATE CRYPTO(107) +#define CRYPTO_OBJECT_FIND_FINAL CRYPTO(108) + +/* + * Key Generation Ioctls + */ +typedef struct crypto_object_generate_key { + uint_t gk_return_value; + crypto_session_id_t gk_session; + crypto_object_id_t gk_handle; + crypto_mechanism_t gk_mechanism; + uint_t gk_count; + caddr_t gk_attributes; +} crypto_object_generate_key_t; + +typedef struct crypto_object_generate_key_pair { + uint_t kp_return_value; + crypto_session_id_t kp_session; + crypto_object_id_t kp_public_handle; + crypto_object_id_t kp_private_handle; + uint_t kp_public_count; + uint_t kp_private_count; + caddr_t kp_public_attributes; + caddr_t kp_private_attributes; + crypto_mechanism_t kp_mechanism; +} crypto_object_generate_key_pair_t; + +typedef struct crypto_object_wrap_key { + uint_t wk_return_value; + crypto_session_id_t wk_session; + crypto_mechanism_t wk_mechanism; + crypto_key_t wk_wrapping_key; + crypto_object_id_t wk_object_handle; + size_t wk_wrapped_key_len; + caddr_t wk_wrapped_key; +} crypto_object_wrap_key_t; + +typedef struct crypto_object_unwrap_key { + uint_t uk_return_value; + crypto_session_id_t uk_session; + crypto_mechanism_t uk_mechanism; + crypto_key_t uk_unwrapping_key; + crypto_object_id_t uk_object_handle; + size_t uk_wrapped_key_len; + caddr_t uk_wrapped_key; + uint_t uk_count; + caddr_t uk_attributes; +} crypto_object_unwrap_key_t; + +typedef struct crypto_derive_key { + uint_t dk_return_value; + crypto_session_id_t dk_session; + crypto_mechanism_t dk_mechanism; + crypto_key_t dk_base_key; + crypto_object_id_t dk_object_handle; + uint_t dk_count; + caddr_t dk_attributes; +} crypto_derive_key_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_object_generate_key32 { + uint32_t gk_return_value; + crypto_session_id_t gk_session; + crypto_object_id_t gk_handle; + crypto_mechanism32_t gk_mechanism; + uint32_t gk_count; + caddr32_t gk_attributes; +} crypto_object_generate_key32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct crypto_object_generate_key_pair32 { + uint32_t kp_return_value; + crypto_session_id_t kp_session; + crypto_object_id_t kp_public_handle; + crypto_object_id_t kp_private_handle; + uint32_t kp_public_count; + uint32_t kp_private_count; + caddr32_t kp_public_attributes; + caddr32_t kp_private_attributes; + crypto_mechanism32_t kp_mechanism; +} crypto_object_generate_key_pair32_t; + +typedef struct crypto_object_wrap_key32 { + uint32_t wk_return_value; + crypto_session_id_t wk_session; + crypto_mechanism32_t wk_mechanism; + crypto_key32_t wk_wrapping_key; + crypto_object_id_t wk_object_handle; + size32_t wk_wrapped_key_len; + caddr32_t wk_wrapped_key; +} crypto_object_wrap_key32_t; + +typedef struct crypto_object_unwrap_key32 { + uint32_t uk_return_value; + crypto_session_id_t uk_session; + crypto_mechanism32_t uk_mechanism; + crypto_key32_t uk_unwrapping_key; + crypto_object_id_t uk_object_handle; + size32_t uk_wrapped_key_len; + caddr32_t uk_wrapped_key; + uint32_t uk_count; + caddr32_t uk_attributes; +} crypto_object_unwrap_key32_t; + +typedef struct crypto_derive_key32 { + uint32_t dk_return_value; + crypto_session_id_t dk_session; + crypto_mechanism32_t dk_mechanism; + crypto_key32_t dk_base_key; + crypto_object_id_t dk_object_handle; + uint32_t dk_count; + caddr32_t dk_attributes; +} crypto_derive_key32_t; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_GENERATE_KEY CRYPTO(110) +#define CRYPTO_GENERATE_KEY_PAIR CRYPTO(111) +#define CRYPTO_WRAP_KEY CRYPTO(112) +#define CRYPTO_UNWRAP_KEY CRYPTO(113) +#define CRYPTO_DERIVE_KEY CRYPTO(114) + +/* + * Provider Management Ioctls + */ + +typedef struct crypto_get_provider_list { + uint_t pl_return_value; + uint_t pl_count; + crypto_provider_entry_t pl_list[1]; +} crypto_get_provider_list_t; + +typedef struct crypto_provider_data { + uchar_t pd_prov_desc[CRYPTO_PROVIDER_DESCR_MAX_LEN]; + uchar_t pd_label[CRYPTO_EXT_SIZE_LABEL]; + uchar_t pd_manufacturerID[CRYPTO_EXT_SIZE_MANUF]; + uchar_t pd_model[CRYPTO_EXT_SIZE_MODEL]; + uchar_t pd_serial_number[CRYPTO_EXT_SIZE_SERIAL]; + ulong_t pd_flags; + ulong_t pd_max_session_count; + ulong_t pd_session_count; + ulong_t pd_max_rw_session_count; + ulong_t pd_rw_session_count; + ulong_t pd_max_pin_len; + ulong_t pd_min_pin_len; + ulong_t pd_total_public_memory; + ulong_t pd_free_public_memory; + ulong_t pd_total_private_memory; + ulong_t pd_free_private_memory; + crypto_version_t pd_hardware_version; + crypto_version_t pd_firmware_version; + uchar_t pd_time[CRYPTO_EXT_SIZE_TIME]; +} crypto_provider_data_t; + +typedef struct crypto_get_provider_info { + uint_t gi_return_value; + crypto_provider_id_t gi_provider_id; + crypto_provider_data_t gi_provider_data; +} crypto_get_provider_info_t; + +typedef struct crypto_get_provider_mechanisms { + uint_t pm_return_value; + crypto_provider_id_t pm_provider_id; + uint_t pm_count; + crypto_mech_name_t pm_list[1]; +} crypto_get_provider_mechanisms_t; + +typedef struct crypto_get_provider_mechanism_info { + uint_t mi_return_value; + crypto_provider_id_t mi_provider_id; + crypto_mech_name_t mi_mechanism_name; + uint32_t mi_min_key_size; + uint32_t mi_max_key_size; + uint32_t mi_flags; +} crypto_get_provider_mechanism_info_t; + +typedef struct crypto_init_token { + uint_t it_return_value; + crypto_provider_id_t it_provider_id; + caddr_t it_pin; + size_t it_pin_len; + caddr_t it_label; +} crypto_init_token_t; + +typedef struct crypto_init_pin { + uint_t ip_return_value; + crypto_session_id_t ip_session; + caddr_t ip_pin; + size_t ip_pin_len; +} crypto_init_pin_t; + +typedef struct crypto_set_pin { + uint_t sp_return_value; + crypto_session_id_t sp_session; + caddr_t sp_old_pin; + size_t sp_old_len; + caddr_t sp_new_pin; + size_t sp_new_len; +} crypto_set_pin_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +typedef struct crypto_get_provider_list32 { + uint32_t pl_return_value; + uint32_t pl_count; + crypto_provider_entry_t pl_list[1]; +} crypto_get_provider_list32_t; + +typedef struct crypto_version32 { + uchar_t cv_major; + uchar_t cv_minor; +} crypto_version32_t; + +typedef struct crypto_provider_data32 { + uchar_t pd_prov_desc[CRYPTO_PROVIDER_DESCR_MAX_LEN]; + uchar_t pd_label[CRYPTO_EXT_SIZE_LABEL]; + uchar_t pd_manufacturerID[CRYPTO_EXT_SIZE_MANUF]; + uchar_t pd_model[CRYPTO_EXT_SIZE_MODEL]; + uchar_t pd_serial_number[CRYPTO_EXT_SIZE_SERIAL]; + uint32_t pd_flags; + uint32_t pd_max_session_count; + uint32_t pd_session_count; + uint32_t pd_max_rw_session_count; + uint32_t pd_rw_session_count; + uint32_t pd_max_pin_len; + uint32_t pd_min_pin_len; + uint32_t pd_total_public_memory; + uint32_t pd_free_public_memory; + uint32_t pd_total_private_memory; + uint32_t pd_free_private_memory; + crypto_version32_t pd_hardware_version; + crypto_version32_t pd_firmware_version; + uchar_t pd_time[CRYPTO_EXT_SIZE_TIME]; +} crypto_provider_data32_t; + +typedef struct crypto_get_provider_info32 { + uint32_t gi_return_value; + crypto_provider_id_t gi_provider_id; + crypto_provider_data32_t gi_provider_data; +} crypto_get_provider_info32_t; + +typedef struct crypto_get_provider_mechanisms32 { + uint32_t pm_return_value; + crypto_provider_id_t pm_provider_id; + uint32_t pm_count; + crypto_mech_name_t pm_list[1]; +} crypto_get_provider_mechanisms32_t; + +typedef struct crypto_init_token32 { + uint32_t it_return_value; + crypto_provider_id_t it_provider_id; + caddr32_t it_pin; + size32_t it_pin_len; + caddr32_t it_label; +} crypto_init_token32_t; + +typedef struct crypto_init_pin32 { + uint32_t ip_return_value; + crypto_session_id_t ip_session; + caddr32_t ip_pin; + size32_t ip_pin_len; +} crypto_init_pin32_t; + +typedef struct crypto_set_pin32 { + uint32_t sp_return_value; + crypto_session_id_t sp_session; + caddr32_t sp_old_pin; + size32_t sp_old_len; + caddr32_t sp_new_pin; + size32_t sp_new_len; +} crypto_set_pin32_t; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_GET_PROVIDER_LIST CRYPTO(120) +#define CRYPTO_GET_PROVIDER_INFO CRYPTO(121) +#define CRYPTO_GET_PROVIDER_MECHANISMS CRYPTO(122) +#define CRYPTO_GET_PROVIDER_MECHANISM_INFO CRYPTO(123) +#define CRYPTO_INIT_TOKEN CRYPTO(124) +#define CRYPTO_INIT_PIN CRYPTO(125) +#define CRYPTO_SET_PIN CRYPTO(126) + +/* + * No (Key) Store Key Generation Ioctls + */ +typedef struct crypto_nostore_generate_key { + uint_t ngk_return_value; + crypto_session_id_t ngk_session; + crypto_mechanism_t ngk_mechanism; + uint_t ngk_in_count; + uint_t ngk_out_count; + caddr_t ngk_in_attributes; + caddr_t ngk_out_attributes; +} crypto_nostore_generate_key_t; + +typedef struct crypto_nostore_generate_key_pair { + uint_t nkp_return_value; + crypto_session_id_t nkp_session; + uint_t nkp_in_public_count; + uint_t nkp_in_private_count; + uint_t nkp_out_public_count; + uint_t nkp_out_private_count; + caddr_t nkp_in_public_attributes; + caddr_t nkp_in_private_attributes; + caddr_t nkp_out_public_attributes; + caddr_t nkp_out_private_attributes; + crypto_mechanism_t nkp_mechanism; +} crypto_nostore_generate_key_pair_t; + +typedef struct crypto_nostore_derive_key { + uint_t ndk_return_value; + crypto_session_id_t ndk_session; + crypto_mechanism_t ndk_mechanism; + crypto_key_t ndk_base_key; + uint_t ndk_in_count; + uint_t ndk_out_count; + caddr_t ndk_in_attributes; + caddr_t ndk_out_attributes; +} crypto_nostore_derive_key_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +typedef struct crypto_nostore_generate_key32 { + uint32_t ngk_return_value; + crypto_session_id_t ngk_session; + crypto_mechanism32_t ngk_mechanism; + uint32_t ngk_in_count; + uint32_t ngk_out_count; + caddr32_t ngk_in_attributes; + caddr32_t ngk_out_attributes; +} crypto_nostore_generate_key32_t; + +typedef struct crypto_nostore_generate_key_pair32 { + uint32_t nkp_return_value; + crypto_session_id_t nkp_session; + uint32_t nkp_in_public_count; + uint32_t nkp_in_private_count; + uint32_t nkp_out_public_count; + uint32_t nkp_out_private_count; + caddr32_t nkp_in_public_attributes; + caddr32_t nkp_in_private_attributes; + caddr32_t nkp_out_public_attributes; + caddr32_t nkp_out_private_attributes; + crypto_mechanism32_t nkp_mechanism; +} crypto_nostore_generate_key_pair32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct crypto_nostore_derive_key32 { + uint32_t ndk_return_value; + crypto_session_id_t ndk_session; + crypto_mechanism32_t ndk_mechanism; + crypto_key32_t ndk_base_key; + uint32_t ndk_in_count; + uint32_t ndk_out_count; + caddr32_t ndk_in_attributes; + caddr32_t ndk_out_attributes; +} crypto_nostore_derive_key32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_NOSTORE_GENERATE_KEY CRYPTO(127) +#define CRYPTO_NOSTORE_GENERATE_KEY_PAIR CRYPTO(128) +#define CRYPTO_NOSTORE_DERIVE_KEY CRYPTO(129) + +/* + * Mechanism Ioctls + */ + +typedef struct crypto_get_mechanism_list { + uint_t ml_return_value; + uint_t ml_count; + crypto_mech_name_t ml_list[1]; +} crypto_get_mechanism_list_t; + +typedef struct crypto_get_all_mechanism_info { + uint_t mi_return_value; + crypto_mech_name_t mi_mechanism_name; + uint_t mi_count; + crypto_mechanism_info_t mi_list[1]; +} crypto_get_all_mechanism_info_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +typedef struct crypto_get_mechanism_list32 { + uint32_t ml_return_value; + uint32_t ml_count; + crypto_mech_name_t ml_list[1]; +} crypto_get_mechanism_list32_t; + +typedef struct crypto_get_all_mechanism_info32 { + uint32_t mi_return_value; + crypto_mech_name_t mi_mechanism_name; + uint32_t mi_count; + crypto_mechanism_info32_t mi_list[1]; +} crypto_get_all_mechanism_info32_t; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define CRYPTO_GET_MECHANISM_LIST CRYPTO(140) +#define CRYPTO_GET_ALL_MECHANISM_INFO CRYPTO(141) + +#define CRYPTO_GET_PROVIDER_BY_MECH CRYPTO(142) + +typedef struct crypto_by_mech { + int rv; + int res; + crypto_mech_type_t mech_type; + uint_t mech_keylen; + crypto_func_group_t mech_fg; + crypto_session_id_t session_id; +} crypto_by_mech_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRYPTO_IOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/crypto/ioctladmin.h b/illumos-x86_64/usr/include/sys/crypto/ioctladmin.h new file mode 100644 index 00000000..17dd12ad --- /dev/null +++ b/illumos-x86_64/usr/include/sys/crypto/ioctladmin.h @@ -0,0 +1,165 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CRYPTO_IOCTLADMIN_H +#define _SYS_CRYPTO_IOCTLADMIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define ADMIN_IOCTL_DEVICE "/dev/cryptoadm" + +#define CRYPTOADMIN(x) (('y' << 8) | (x)) + +/* + * Administrative IOCTLs + */ + +typedef struct crypto_get_dev_list { + uint_t dl_return_value; + uint_t dl_dev_count; + crypto_dev_list_entry_t dl_devs[1]; +} crypto_get_dev_list_t; + +typedef struct crypto_get_soft_list { + uint_t sl_return_value; + uint_t sl_soft_count; + size_t sl_soft_len; + caddr_t sl_soft_names; +} crypto_get_soft_list_t; + +typedef struct crypto_get_dev_info { + uint_t di_return_value; + char di_dev_name[MAXNAMELEN]; + uint_t di_dev_instance; + uint_t di_count; + crypto_mech_name_t di_list[1]; +} crypto_get_dev_info_t; + +typedef struct crypto_get_soft_info { + uint_t si_return_value; + char si_name[MAXNAMELEN]; + uint_t si_count; + crypto_mech_name_t si_list[1]; +} crypto_get_soft_info_t; + +typedef struct crypto_load_dev_disabled { + uint_t dd_return_value; + char dd_dev_name[MAXNAMELEN]; + uint_t dd_dev_instance; + uint_t dd_count; + crypto_mech_name_t dd_list[1]; +} crypto_load_dev_disabled_t; + +typedef struct crypto_load_soft_disabled { + uint_t sd_return_value; + char sd_name[MAXNAMELEN]; + uint_t sd_count; + crypto_mech_name_t sd_list[1]; +} crypto_load_soft_disabled_t; + +typedef struct crypto_unload_soft_module { + uint_t sm_return_value; + char sm_name[MAXNAMELEN]; +} crypto_unload_soft_module_t; + +typedef struct crypto_load_soft_config { + uint_t sc_return_value; + char sc_name[MAXNAMELEN]; + uint_t sc_count; + crypto_mech_name_t sc_list[1]; +} crypto_load_soft_config_t; + +typedef struct crypto_load_door { + uint_t ld_return_value; + uint_t ld_did; +} crypto_load_door_t; + +typedef struct crypto_fips140 { + uint_t fips140_return_value; + uint_t fips140_op; + uint_t fips140_status; +} crypto_fips140_t; + +#ifdef _KERNEL +#ifdef _SYSCALL32 + +typedef struct crypto_get_soft_list32 { + uint32_t sl_return_value; + uint32_t sl_soft_count; + size32_t sl_soft_len; + caddr32_t sl_soft_names; +} crypto_get_soft_list32_t; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +/* + * FIPS140 ioctl operations + */ +enum { + FIPS140_STATUS, /* get current fips140 mode */ + FIPS140_ENABLE, /* enable fips140 mode */ + FIPS140_DISABLE /* disable fips140 mode */ + + +}; + +/* + * FIPS140 Mode Status + */ +enum { + FIPS140_MODE_UNSET, /* userland has not told us the mode */ + FIPS140_MODE_VALIDATING, /* In the process of validation to enable */ + FIPS140_MODE_SHUTDOWN, /* Failure has occurred, shutdown framework */ + FIPS140_MODE_ENABLED, /* Validation is complete and we are running */ + FIPS140_MODE_DISABLED /* Not running in FIPS 140 mode */ +}; + +#define CRYPTO_GET_VERSION CRYPTOADMIN(1) +#define CRYPTO_GET_DEV_LIST CRYPTOADMIN(2) +#define CRYPTO_GET_SOFT_LIST CRYPTOADMIN(3) +#define CRYPTO_GET_DEV_INFO CRYPTOADMIN(4) +#define CRYPTO_GET_SOFT_INFO CRYPTOADMIN(5) +#define CRYPTO_LOAD_DEV_DISABLED CRYPTOADMIN(8) +#define CRYPTO_LOAD_SOFT_DISABLED CRYPTOADMIN(9) +#define CRYPTO_UNLOAD_SOFT_MODULE CRYPTOADMIN(10) +#define CRYPTO_LOAD_SOFT_CONFIG CRYPTOADMIN(11) +#define CRYPTO_POOL_CREATE CRYPTOADMIN(12) +#define CRYPTO_POOL_WAIT CRYPTOADMIN(13) +#define CRYPTO_POOL_RUN CRYPTOADMIN(14) +#define CRYPTO_LOAD_DOOR CRYPTOADMIN(15) +#define CRYPTO_FIPS140_STATUS CRYPTOADMIN(16) +#define CRYPTO_FIPS140_SET CRYPTOADMIN(17) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRYPTO_IOCTLADMIN_H */ diff --git a/illumos-x86_64/usr/include/sys/crypto/spi.h b/illumos-x86_64/usr/include/sys/crypto/spi.h new file mode 100644 index 00000000..e9df8e21 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/crypto/spi.h @@ -0,0 +1,772 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CRYPTO_SPI_H +#define _SYS_CRYPTO_SPI_H + +/* + * CSPI: Cryptographic Service Provider Interface. + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#define CRYPTO_SPI_VERSION_1 1 +#define CRYPTO_SPI_VERSION_2 2 +#define CRYPTO_SPI_VERSION_3 3 +#define CRYPTO_SPI_VERSION_4 4 + +/* + * Provider-private handle. This handle is specified by a provider + * when it registers by means of the pi_provider_handle field of + * the crypto_provider_info structure, and passed to the provider + * when its entry points are invoked. + */ +typedef void *crypto_provider_handle_t; + +/* + * Context templates can be used to by software providers to pre-process + * keying material, such as key schedules. They are allocated by + * a software provider create_ctx_template(9E) entry point, and passed + * as argument to initialization and atomic provider entry points. + */ +typedef void *crypto_spi_ctx_template_t; + +/* + * Request handles are used by the kernel to identify an asynchronous + * request being processed by a provider. It is passed by the kernel + * to a hardware provider when submitting a request, and must be + * specified by a provider when calling crypto_op_notification(9F) + */ +typedef void *crypto_req_handle_t; + +/* Values for cc_flags field */ +#define CRYPTO_INIT_OPSTATE 0x00000001 /* allocate and init cc_opstate */ +#define CRYPTO_USE_OPSTATE 0x00000002 /* .. start using it as context */ + +/* + * The context structure is passed from the kernel to a provider. + * It contains the information needed to process a multi-part or + * single part operation. The context structure is not used + * by atomic operations. + * + * Parameters needed to perform a cryptographic operation, such + * as keys, mechanisms, input and output buffers, are passed + * as separate arguments to Provider routines. + */ +typedef struct crypto_ctx { + crypto_provider_handle_t cc_provider; + crypto_session_id_t cc_session; + void *cc_provider_private; /* owned by provider */ + void *cc_framework_private; /* owned by framework */ + uint32_t cc_flags; /* flags */ + void *cc_opstate; /* state */ +} crypto_ctx_t; + +/* + * Extended provider information. + */ + +/* + * valid values for ei_flags field of extended info structure + * They match the RSA Security, Inc PKCS#11 tokenInfo flags. + */ +#define CRYPTO_EXTF_RNG 0x00000001 +#define CRYPTO_EXTF_WRITE_PROTECTED 0x00000002 +#define CRYPTO_EXTF_LOGIN_REQUIRED 0x00000004 +#define CRYPTO_EXTF_USER_PIN_INITIALIZED 0x00000008 +#define CRYPTO_EXTF_CLOCK_ON_TOKEN 0x00000040 +#define CRYPTO_EXTF_PROTECTED_AUTHENTICATION_PATH 0x00000100 +#define CRYPTO_EXTF_DUAL_CRYPTO_OPERATIONS 0x00000200 +#define CRYPTO_EXTF_TOKEN_INITIALIZED 0x00000400 +#define CRYPTO_EXTF_USER_PIN_COUNT_LOW 0x00010000 +#define CRYPTO_EXTF_USER_PIN_FINAL_TRY 0x00020000 +#define CRYPTO_EXTF_USER_PIN_LOCKED 0x00040000 +#define CRYPTO_EXTF_USER_PIN_TO_BE_CHANGED 0x00080000 +#define CRYPTO_EXTF_SO_PIN_COUNT_LOW 0x00100000 +#define CRYPTO_EXTF_SO_PIN_FINAL_TRY 0x00200000 +#define CRYPTO_EXTF_SO_PIN_LOCKED 0x00400000 +#define CRYPTO_EXTF_SO_PIN_TO_BE_CHANGED 0x00800000 + +/* + * The crypto_control_ops structure contains pointers to control + * operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_control_ops { + void (*provider_status)(crypto_provider_handle_t, uint_t *); +} crypto_control_ops_t; + +/* + * The crypto_ctx_ops structure contains points to context and context + * templates management operations for cryptographic providers. It is + * passed through the crypto_ops(9S) structure when providers register + * with the kernel using crypto_register_provider(9F). + */ +typedef struct crypto_ctx_ops { + int (*create_ctx_template)(crypto_provider_handle_t, + crypto_mechanism_t *, crypto_key_t *, + crypto_spi_ctx_template_t *, size_t *, crypto_req_handle_t); + int (*free_context)(crypto_ctx_t *); +} crypto_ctx_ops_t; + +/* + * The crypto_digest_ops structure contains pointers to digest + * operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_digest_ops { + int (*digest_init)(crypto_ctx_t *, crypto_mechanism_t *, + crypto_req_handle_t); + int (*digest)(crypto_ctx_t *, crypto_data_t *, crypto_data_t *, + crypto_req_handle_t); + int (*digest_update)(crypto_ctx_t *, crypto_data_t *, + crypto_req_handle_t); + int (*digest_key)(crypto_ctx_t *, crypto_key_t *, crypto_req_handle_t); + int (*digest_final)(crypto_ctx_t *, crypto_data_t *, + crypto_req_handle_t); + int (*digest_atomic)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_data_t *, + crypto_data_t *, crypto_req_handle_t); +} crypto_digest_ops_t; + +/* + * The crypto_cipher_ops structure contains pointers to encryption + * and decryption operations for cryptographic providers. It is + * passed through the crypto_ops(9S) structure when providers register + * with the kernel using crypto_register_provider(9F). + */ +typedef struct crypto_cipher_ops { + int (*encrypt_init)(crypto_ctx_t *, + crypto_mechanism_t *, crypto_key_t *, + crypto_spi_ctx_template_t, crypto_req_handle_t); + int (*encrypt)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*encrypt_update)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*encrypt_final)(crypto_ctx_t *, + crypto_data_t *, crypto_req_handle_t); + int (*encrypt_atomic)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_data_t *, crypto_spi_ctx_template_t, crypto_req_handle_t); + + int (*decrypt_init)(crypto_ctx_t *, + crypto_mechanism_t *, crypto_key_t *, + crypto_spi_ctx_template_t, crypto_req_handle_t); + int (*decrypt)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*decrypt_update)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*decrypt_final)(crypto_ctx_t *, + crypto_data_t *, crypto_req_handle_t); + int (*decrypt_atomic)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_data_t *, crypto_spi_ctx_template_t, crypto_req_handle_t); +} crypto_cipher_ops_t; + +/* + * The crypto_mac_ops structure contains pointers to MAC + * operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_mac_ops { + int (*mac_init)(crypto_ctx_t *, + crypto_mechanism_t *, crypto_key_t *, + crypto_spi_ctx_template_t, crypto_req_handle_t); + int (*mac)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*mac_update)(crypto_ctx_t *, + crypto_data_t *, crypto_req_handle_t); + int (*mac_final)(crypto_ctx_t *, + crypto_data_t *, crypto_req_handle_t); + int (*mac_atomic)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_data_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); + int (*mac_verify_atomic)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_data_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); +} crypto_mac_ops_t; + +/* + * The crypto_sign_ops structure contains pointers to signing + * operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_sign_ops { + int (*sign_init)(crypto_ctx_t *, + crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); + int (*sign)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*sign_update)(crypto_ctx_t *, + crypto_data_t *, crypto_req_handle_t); + int (*sign_final)(crypto_ctx_t *, + crypto_data_t *, crypto_req_handle_t); + int (*sign_atomic)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_data_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); + int (*sign_recover_init)(crypto_ctx_t *, crypto_mechanism_t *, + crypto_key_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); + int (*sign_recover)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*sign_recover_atomic)(crypto_provider_handle_t, + crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, + crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); +} crypto_sign_ops_t; + +/* + * The crypto_verify_ops structure contains pointers to verify + * operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_verify_ops { + int (*verify_init)(crypto_ctx_t *, + crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); + int (*verify)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*verify_update)(crypto_ctx_t *, + crypto_data_t *, crypto_req_handle_t); + int (*verify_final)(crypto_ctx_t *, + crypto_data_t *, crypto_req_handle_t); + int (*verify_atomic)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, + crypto_data_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); + int (*verify_recover_init)(crypto_ctx_t *, crypto_mechanism_t *, + crypto_key_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); + int (*verify_recover)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*verify_recover_atomic)(crypto_provider_handle_t, + crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, + crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t, + crypto_req_handle_t); +} crypto_verify_ops_t; + +/* + * The crypto_dual_ops structure contains pointers to dual + * cipher and sign/verify operations for cryptographic providers. + * It is passed through the crypto_ops(9S) structure when + * providers register with the kernel using + * crypto_register_provider(9F). + */ +typedef struct crypto_dual_ops { + int (*digest_encrypt_update)( + crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *, + crypto_data_t *, crypto_req_handle_t); + int (*decrypt_digest_update)( + crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *, + crypto_data_t *, crypto_req_handle_t); + int (*sign_encrypt_update)( + crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *, + crypto_data_t *, crypto_req_handle_t); + int (*decrypt_verify_update)( + crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *, + crypto_data_t *, crypto_req_handle_t); +} crypto_dual_ops_t; + +/* + * The crypto_dual_cipher_mac_ops structure contains pointers to dual + * cipher and MAC operations for cryptographic providers. + * It is passed through the crypto_ops(9S) structure when + * providers register with the kernel using + * crypto_register_provider(9F). + */ +typedef struct crypto_dual_cipher_mac_ops { + int (*encrypt_mac_init)(crypto_ctx_t *, + crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *, + crypto_key_t *, crypto_spi_ctx_template_t, + crypto_spi_ctx_template_t, crypto_req_handle_t); + int (*encrypt_mac)(crypto_ctx_t *, + crypto_data_t *, crypto_dual_data_t *, crypto_data_t *, + crypto_req_handle_t); + int (*encrypt_mac_update)(crypto_ctx_t *, + crypto_data_t *, crypto_dual_data_t *, crypto_req_handle_t); + int (*encrypt_mac_final)(crypto_ctx_t *, + crypto_dual_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*encrypt_mac_atomic)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *, + crypto_key_t *, crypto_data_t *, crypto_dual_data_t *, + crypto_data_t *, crypto_spi_ctx_template_t, + crypto_spi_ctx_template_t, crypto_req_handle_t); + + int (*mac_decrypt_init)(crypto_ctx_t *, + crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *, + crypto_key_t *, crypto_spi_ctx_template_t, + crypto_spi_ctx_template_t, crypto_req_handle_t); + int (*mac_decrypt)(crypto_ctx_t *, + crypto_dual_data_t *, crypto_data_t *, crypto_data_t *, + crypto_req_handle_t); + int (*mac_decrypt_update)(crypto_ctx_t *, + crypto_dual_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*mac_decrypt_final)(crypto_ctx_t *, + crypto_data_t *, crypto_data_t *, crypto_req_handle_t); + int (*mac_decrypt_atomic)(crypto_provider_handle_t, + crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, + crypto_mechanism_t *, crypto_key_t *, crypto_dual_data_t *, + crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t, + crypto_spi_ctx_template_t, crypto_req_handle_t); + int (*mac_verify_decrypt_atomic)(crypto_provider_handle_t, + crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, + crypto_mechanism_t *, crypto_key_t *, crypto_dual_data_t *, + crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t, + crypto_spi_ctx_template_t, crypto_req_handle_t); +} crypto_dual_cipher_mac_ops_t; + +/* + * The crypto_random_number_ops structure contains pointers to random + * number operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_random_number_ops { + int (*seed_random)(crypto_provider_handle_t, crypto_session_id_t, + uchar_t *, size_t, uint_t, uint32_t, crypto_req_handle_t); + int (*generate_random)(crypto_provider_handle_t, crypto_session_id_t, + uchar_t *, size_t, crypto_req_handle_t); +} crypto_random_number_ops_t; + +/* + * Flag values for seed_random. + */ +#define CRYPTO_SEED_NOW 0x00000001 + +/* + * The crypto_session_ops structure contains pointers to session + * operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_session_ops { + int (*session_open)(crypto_provider_handle_t, crypto_session_id_t *, + crypto_req_handle_t); + int (*session_close)(crypto_provider_handle_t, crypto_session_id_t, + crypto_req_handle_t); + int (*session_login)(crypto_provider_handle_t, crypto_session_id_t, + crypto_user_type_t, char *, size_t, crypto_req_handle_t); + int (*session_logout)(crypto_provider_handle_t, crypto_session_id_t, + crypto_req_handle_t); +} crypto_session_ops_t; + +/* + * The crypto_object_ops structure contains pointers to object + * operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_object_ops { + int (*object_create)(crypto_provider_handle_t, crypto_session_id_t, + crypto_object_attribute_t *, uint_t, crypto_object_id_t *, + crypto_req_handle_t); + int (*object_copy)(crypto_provider_handle_t, crypto_session_id_t, + crypto_object_id_t, crypto_object_attribute_t *, uint_t, + crypto_object_id_t *, crypto_req_handle_t); + int (*object_destroy)(crypto_provider_handle_t, crypto_session_id_t, + crypto_object_id_t, crypto_req_handle_t); + int (*object_get_size)(crypto_provider_handle_t, crypto_session_id_t, + crypto_object_id_t, size_t *, crypto_req_handle_t); + int (*object_get_attribute_value)(crypto_provider_handle_t, + crypto_session_id_t, crypto_object_id_t, + crypto_object_attribute_t *, uint_t, crypto_req_handle_t); + int (*object_set_attribute_value)(crypto_provider_handle_t, + crypto_session_id_t, crypto_object_id_t, + crypto_object_attribute_t *, uint_t, crypto_req_handle_t); + int (*object_find_init)(crypto_provider_handle_t, crypto_session_id_t, + crypto_object_attribute_t *, uint_t, void **, + crypto_req_handle_t); + int (*object_find)(crypto_provider_handle_t, void *, + crypto_object_id_t *, uint_t, uint_t *, crypto_req_handle_t); + int (*object_find_final)(crypto_provider_handle_t, void *, + crypto_req_handle_t); +} crypto_object_ops_t; + +/* + * The crypto_key_ops structure contains pointers to key + * operations for cryptographic providers. It is passed through + * the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_key_ops { + int (*key_generate)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_object_attribute_t *, uint_t, + crypto_object_id_t *, crypto_req_handle_t); + int (*key_generate_pair)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_object_attribute_t *, uint_t, + crypto_object_attribute_t *, uint_t, crypto_object_id_t *, + crypto_object_id_t *, crypto_req_handle_t); + int (*key_wrap)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_object_id_t *, + uchar_t *, size_t *, crypto_req_handle_t); + int (*key_unwrap)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, uchar_t *, size_t *, + crypto_object_attribute_t *, uint_t, + crypto_object_id_t *, crypto_req_handle_t); + int (*key_derive)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *, + uint_t, crypto_object_id_t *, crypto_req_handle_t); + int (*key_check)(crypto_provider_handle_t, crypto_mechanism_t *, + crypto_key_t *); +} crypto_key_ops_t; + +/* + * The crypto_provider_management_ops structure contains pointers + * to management operations for cryptographic providers. It is passed + * through the crypto_ops(9S) structure when providers register with the + * kernel using crypto_register_provider(9F). + */ +typedef struct crypto_provider_management_ops { + int (*ext_info)(crypto_provider_handle_t, + crypto_provider_ext_info_t *, crypto_req_handle_t); + int (*init_token)(crypto_provider_handle_t, char *, size_t, + char *, crypto_req_handle_t); + int (*init_pin)(crypto_provider_handle_t, crypto_session_id_t, + char *, size_t, crypto_req_handle_t); + int (*set_pin)(crypto_provider_handle_t, crypto_session_id_t, + char *, size_t, char *, size_t, crypto_req_handle_t); +} crypto_provider_management_ops_t; + +typedef struct crypto_mech_ops { + int (*copyin_mechanism)(crypto_provider_handle_t, + crypto_mechanism_t *, crypto_mechanism_t *, int *, int); + int (*copyout_mechanism)(crypto_provider_handle_t, + crypto_mechanism_t *, crypto_mechanism_t *, int *, int); + int (*free_mechanism)(crypto_provider_handle_t, crypto_mechanism_t *); +} crypto_mech_ops_t; + +typedef struct crypto_nostore_key_ops { + int (*nostore_key_generate)(crypto_provider_handle_t, + crypto_session_id_t, crypto_mechanism_t *, + crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *, + uint_t, crypto_req_handle_t); + int (*nostore_key_generate_pair)(crypto_provider_handle_t, + crypto_session_id_t, crypto_mechanism_t *, + crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *, + uint_t, crypto_object_attribute_t *, uint_t, + crypto_object_attribute_t *, uint_t, crypto_req_handle_t); + int (*nostore_key_derive)(crypto_provider_handle_t, crypto_session_id_t, + crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *, + uint_t, crypto_object_attribute_t *, uint_t, crypto_req_handle_t); +} crypto_nostore_key_ops_t; + +/* + * crypto_fips140_ops provides a function for FIPS 140 Power-On Self Test for + * those providers that are part of the Cryptographic Framework bounday. See + * crypto_fips140_ops(9s) for details. + */ +typedef struct crypto_fips140_ops { + void (*fips140_post)(int *); +} crypto_fips140_ops_t; + +/* + * The crypto_ops(9S) structure contains the structures containing + * the pointers to functions implemented by cryptographic providers. + * It is specified as part of the crypto_provider_info(9S) + * supplied by a provider when it registers with the kernel + * by calling crypto_register_provider(9F). + */ +typedef struct crypto_ops_v1 { + crypto_control_ops_t *co_control_ops; + crypto_digest_ops_t *co_digest_ops; + crypto_cipher_ops_t *co_cipher_ops; + crypto_mac_ops_t *co_mac_ops; + crypto_sign_ops_t *co_sign_ops; + crypto_verify_ops_t *co_verify_ops; + crypto_dual_ops_t *co_dual_ops; + crypto_dual_cipher_mac_ops_t *co_dual_cipher_mac_ops; + crypto_random_number_ops_t *co_random_ops; + crypto_session_ops_t *co_session_ops; + crypto_object_ops_t *co_object_ops; + crypto_key_ops_t *co_key_ops; + crypto_provider_management_ops_t *co_provider_ops; + crypto_ctx_ops_t *co_ctx_ops; +} crypto_ops_v1_t; + +typedef struct crypto_ops_v2 { + crypto_ops_v1_t v1_ops; + crypto_mech_ops_t *co_mech_ops; +} crypto_ops_v2_t; + +typedef struct crypto_ops_v3 { + crypto_ops_v2_t v2_ops; + crypto_nostore_key_ops_t *co_nostore_key_ops; +} crypto_ops_v3_t; + +typedef struct crypto_ops_v4 { + crypto_ops_v3_t v3_ops; + crypto_fips140_ops_t *co_fips140_ops; +} crypto_ops_v4_t; + +typedef struct crypto_ops { + union { + crypto_ops_v4_t cou_v4; + crypto_ops_v3_t cou_v3; + crypto_ops_v2_t cou_v2; + crypto_ops_v1_t cou_v1; + } cou; +} crypto_ops_t; + +#define co_control_ops cou.cou_v1.co_control_ops +#define co_digest_ops cou.cou_v1.co_digest_ops +#define co_cipher_ops cou.cou_v1.co_cipher_ops +#define co_mac_ops cou.cou_v1.co_mac_ops +#define co_sign_ops cou.cou_v1.co_sign_ops +#define co_verify_ops cou.cou_v1.co_verify_ops +#define co_dual_ops cou.cou_v1.co_dual_ops +#define co_dual_cipher_mac_ops cou.cou_v1.co_dual_cipher_mac_ops +#define co_random_ops cou.cou_v1.co_random_ops +#define co_session_ops cou.cou_v1.co_session_ops +#define co_object_ops cou.cou_v1.co_object_ops +#define co_key_ops cou.cou_v1.co_key_ops +#define co_provider_ops cou.cou_v1.co_provider_ops +#define co_ctx_ops cou.cou_v1.co_ctx_ops +#define co_mech_ops cou.cou_v2.co_mech_ops +#define co_nostore_key_ops cou.cou_v3.co_nostore_key_ops +#define co_fips140_ops cou.cou_v4.co_fips140_ops + +/* + * Provider device specification passed during registration. + * + * Software providers set the pi_provider_type field of provider_info_t + * to CRYPTO_SW_PROVIDER, and set the pd_sw field of + * crypto_provider_dev_t to the address of their modlinkage. + * + * Hardware providers set the pi_provider_type field of provider_info_t + * to CRYPTO_HW_PROVIDER, and set the pd_hw field of + * crypto_provider_dev_t to the dev_info structure corresponding + * to the device instance being registered. + * + * Logical providers set the pi_provider_type field of provider_info_t + * to CRYPTO_LOGICAL_PROVIDER, and set the pd_hw field of + * crypto_provider_dev_t to the dev_info structure corresponding + * to the device instance being registered. + */ + +typedef union crypto_provider_dev { + struct modlinkage *pd_sw; /* for CRYPTO_SW_PROVIDER */ + dev_info_t *pd_hw; /* for CRYPTO_HW_PROVIDER */ +} crypto_provider_dev_t; + +#endif /* _KERNEL */ + +/* + * The mechanism info structure crypto_mech_info_t contains a function group + * bit mask cm_func_group_mask. This field, of type crypto_func_group_t, + * specifies the provider entry point that can be used a particular + * mechanism. The function group mask is a combination of the following values. + */ + +typedef uint32_t crypto_func_group_t; + +#define CRYPTO_FG_ENCRYPT 0x00000001 /* encrypt_init() */ +#define CRYPTO_FG_DECRYPT 0x00000002 /* decrypt_init() */ +#define CRYPTO_FG_DIGEST 0x00000004 /* digest_init() */ +#define CRYPTO_FG_SIGN 0x00000008 /* sign_init() */ +#define CRYPTO_FG_SIGN_RECOVER 0x00000010 /* sign_recover_init() */ +#define CRYPTO_FG_VERIFY 0x00000020 /* verify_init() */ +#define CRYPTO_FG_VERIFY_RECOVER 0x00000040 /* verify_recover_init() */ +#define CRYPTO_FG_GENERATE 0x00000080 /* key_generate() */ +#define CRYPTO_FG_GENERATE_KEY_PAIR 0x00000100 /* key_generate_pair() */ +#define CRYPTO_FG_WRAP 0x00000200 /* key_wrap() */ +#define CRYPTO_FG_UNWRAP 0x00000400 /* key_unwrap() */ +#define CRYPTO_FG_DERIVE 0x00000800 /* key_derive() */ +#define CRYPTO_FG_MAC 0x00001000 /* mac_init() */ +#define CRYPTO_FG_ENCRYPT_MAC 0x00002000 /* encrypt_mac_init() */ +#define CRYPTO_FG_MAC_DECRYPT 0x00004000 /* decrypt_mac_init() */ +#define CRYPTO_FG_ENCRYPT_ATOMIC 0x00008000 /* encrypt_atomic() */ +#define CRYPTO_FG_DECRYPT_ATOMIC 0x00010000 /* decrypt_atomic() */ +#define CRYPTO_FG_MAC_ATOMIC 0x00020000 /* mac_atomic() */ +#define CRYPTO_FG_DIGEST_ATOMIC 0x00040000 /* digest_atomic() */ +#define CRYPTO_FG_SIGN_ATOMIC 0x00080000 /* sign_atomic() */ +#define CRYPTO_FG_SIGN_RECOVER_ATOMIC 0x00100000 /* sign_recover_atomic() */ +#define CRYPTO_FG_VERIFY_ATOMIC 0x00200000 /* verify_atomic() */ +#define CRYPTO_FG_VERIFY_RECOVER_ATOMIC 0x00400000 /* verify_recover_atomic() */ +#define CRYPTO_FG_ENCRYPT_MAC_ATOMIC 0x00800000 /* encrypt_mac_atomic() */ +#define CRYPTO_FG_MAC_DECRYPT_ATOMIC 0x01000000 /* mac_decrypt_atomic() */ +#define CRYPTO_FG_RESERVED 0x80000000 + +/* + * Maximum length of the pi_provider_description field of the + * crypto_provider_info structure. + */ +#define CRYPTO_PROVIDER_DESCR_MAX_LEN 64 + +#ifdef _KERNEL + +/* Bit mask for all the simple operations */ +#define CRYPTO_FG_SIMPLEOP_MASK (CRYPTO_FG_ENCRYPT | CRYPTO_FG_DECRYPT | \ + CRYPTO_FG_DIGEST | CRYPTO_FG_SIGN | CRYPTO_FG_VERIFY | CRYPTO_FG_MAC | \ + CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_DECRYPT_ATOMIC | \ + CRYPTO_FG_MAC_ATOMIC | CRYPTO_FG_DIGEST_ATOMIC | CRYPTO_FG_SIGN_ATOMIC | \ + CRYPTO_FG_VERIFY_ATOMIC) + +/* Bit mask for all the dual operations */ +#define CRYPTO_FG_MAC_CIPHER_MASK (CRYPTO_FG_ENCRYPT_MAC | \ + CRYPTO_FG_MAC_DECRYPT | CRYPTO_FG_ENCRYPT_MAC_ATOMIC | \ + CRYPTO_FG_MAC_DECRYPT_ATOMIC) + +/* Add other combos to CRYPTO_FG_DUAL_MASK */ +#define CRYPTO_FG_DUAL_MASK CRYPTO_FG_MAC_CIPHER_MASK + +/* + * The crypto_mech_info structure specifies one of the mechanisms + * supported by a cryptographic provider. The pi_mechanisms field of + * the crypto_provider_info structure contains a pointer to an array + * of crypto_mech_info's. + */ +typedef struct crypto_mech_info { + crypto_mech_name_t cm_mech_name; + crypto_mech_type_t cm_mech_number; + crypto_func_group_t cm_func_group_mask; + ssize_t cm_min_key_length; + ssize_t cm_max_key_length; + uint32_t cm_mech_flags; +} crypto_mech_info_t; + +/* Alias the old name to the new name for compatibility. */ +#define cm_keysize_unit cm_mech_flags + +/* + * crypto_kcf_provider_handle_t is a handle allocated by the kernel. + * It is returned after the provider registers with + * crypto_register_provider(), and must be specified by the provider + * when calling crypto_unregister_provider(), and + * crypto_provider_notification(). + */ +typedef uint_t crypto_kcf_provider_handle_t; + +/* + * Provider information. Passed as argument to crypto_register_provider(9F). + * Describes the provider and its capabilities. Multiple providers can + * register for the same device instance. In this case, the same + * pi_provider_dev must be specified with a different pi_provider_handle. + */ +typedef struct crypto_provider_info_v1 { + uint_t pi_interface_version; + char *pi_provider_description; + crypto_provider_type_t pi_provider_type; + crypto_provider_dev_t pi_provider_dev; + crypto_provider_handle_t pi_provider_handle; + crypto_ops_t *pi_ops_vector; + uint_t pi_mech_list_count; + crypto_mech_info_t *pi_mechanisms; + uint_t pi_logical_provider_count; + crypto_kcf_provider_handle_t *pi_logical_providers; +} crypto_provider_info_v1_t; + +typedef struct crypto_provider_info_v2 { + crypto_provider_info_v1_t v1_info; + uint_t pi_flags; +} crypto_provider_info_v2_t; + +typedef struct crypto_provider_info { + union { + crypto_provider_info_v2_t piu_v2; + crypto_provider_info_v1_t piu_v1; + } piu; +} crypto_provider_info_t; + +#define pi_interface_version piu.piu_v1.pi_interface_version +#define pi_provider_description piu.piu_v1.pi_provider_description +#define pi_provider_type piu.piu_v1.pi_provider_type +#define pi_provider_dev piu.piu_v1.pi_provider_dev +#define pi_provider_handle piu.piu_v1.pi_provider_handle +#define pi_ops_vector piu.piu_v1.pi_ops_vector +#define pi_mech_list_count piu.piu_v1.pi_mech_list_count +#define pi_mechanisms piu.piu_v1.pi_mechanisms +#define pi_logical_provider_count piu.piu_v1.pi_logical_provider_count +#define pi_logical_providers piu.piu_v1.pi_logical_providers +#define pi_flags piu.piu_v2.pi_flags + +/* hidden providers can only be accessed via a logical provider */ +#define CRYPTO_HIDE_PROVIDER 0x00000001 +/* + * provider can not do multi-part digest (updates) and has a limit + * on maximum input data that it can digest. The provider sets + * this value in crypto_provider_ext_info_t by implementing + * the ext_info entry point in the co_provider_ops vector. + */ +#define CRYPTO_HASH_NO_UPDATE 0x00000002 +/* + * provider can not do multi-part HMAC (updates) and has a limit + * on maximum input data that it can hmac. The provider sets + * this value in crypto_provider_ext_info_t by implementing + * the ext_info entry point in the co_provider_ops vector. + */ +#define CRYPTO_HMAC_NO_UPDATE 0x00000008 + +/* provider can handle the request without returning a CRYPTO_QUEUED */ +#define CRYPTO_SYNCHRONOUS 0x00000004 + +#define CRYPTO_PIFLAGS_RESERVED2 0x40000000 +#define CRYPTO_PIFLAGS_RESERVED1 0x80000000 + +/* + * Provider status passed by a provider to crypto_provider_notification(9F) + * and returned by the provider_status(9E) entry point. + */ +#define CRYPTO_PROVIDER_READY 0 +#define CRYPTO_PROVIDER_BUSY 1 +#define CRYPTO_PROVIDER_FAILED 2 + +/* + * Functions exported by Solaris to cryptographic providers. Providers + * call these functions to register and unregister, notify the kernel + * of state changes, and notify the kernel when a asynchronous request + * completed. + */ +extern int crypto_register_provider(crypto_provider_info_t *, + crypto_kcf_provider_handle_t *); +extern int crypto_unregister_provider(crypto_kcf_provider_handle_t); +extern void crypto_provider_notification(crypto_kcf_provider_handle_t, uint_t); +extern void crypto_op_notification(crypto_req_handle_t, int); +extern int crypto_kmflag(crypto_req_handle_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CRYPTO_SPI_H */ diff --git a/illumos-x86_64/usr/include/sys/cs.h b/illumos-x86_64/usr/include/sys/cs.h new file mode 100644 index 00000000..c44deb9a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cs.h @@ -0,0 +1,1228 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _CS_H +#define _CS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * PCMCIA Card Services header file + */ + +/* + * XXX - This define really should be in a global header file + * somewhere; we do this stunt here since a lot of + * people include this header file but not necessarily + * the header file in which this is defined. + */ +#ifndef _VERSION +#define _VERSION(major, minor) ((major)<<16|(minor)) +#endif + +/* + * Define this version of CS - this should correspond to the PCMCIA + * version number specified in the PCMCIA standard. + */ +#define CS_VERSION _VERSION(5, 2) + +/* + * CS_INTERNAL_REVISION_LEVEL is our internal revision level value returned + * via GetCardServicesInfo in get_cardservices_info_t->Revision + */ +#define CS_INTERNAL_REVISION_LEVEL _VERSION(2, 0) + +#define CS_GET_CARDSERVICES_INFO_VENDOR_STRING "Solaris UNIX Card Services\n" \ + "Copyright 2008 Sun Microsystems, Inc. All rights reserved.\n" \ + "Use is subject to license terms.\n" \ + "@(#)cs.h 1.69 08/10/17 SMI\n" \ + "Based on the PC Card Standard, February 1995\n" + +/* + * typedef for function pointers to quiet lint and cc -v + */ +typedef int32_t (csfunction_t)(int32_t, ...); /* for lint - cc -v quieting */ + +/* + * CS_SUN_VENDOR_DESCRIPTION - can be returned by clients handling + * the CS_EVENT_CLIENT_INFO event in the + * client_info_t->VendorName member. + */ +#define CS_SUN_VENDOR_DESCRIPTION "Sun Microsystems, Inc. (c) 1996" + +/* + * Return codes from Card Services - these correspond to the PCMCIA + * standard and also include some implementation-specific return + * codes. + */ +#define CS_SUCCESS 0x00 /* Request succeeded */ +#define CS_BAD_ADAPTER 0x01 /* Specified adapter is invalid */ +#define CS_BAD_ATTRIBUTE 0x02 /* Bad attribute value */ +#define CS_BAD_BASE 0x03 /* System base address invalid */ +#define CS_BAD_EDC 0x04 /* EDC generator is invalid */ + /* RESERVED - 0x05 */ +#define CS_BAD_IRQ 0x06 /* Invalid IRQ */ +#define CS_BAD_OFFSET 0x07 /* Card offset invalid */ +#define CS_BAD_PAGE 0x08 /* Card page invalid */ +#define CS_READ_FAILURE 0x09 /* Unable to complete read request */ +#define CS_BAD_SIZE 0x0a /* Size is invalid */ +#define CS_BAD_SOCKET 0x0b /* Specified socket is invalid */ + /* RESERVED - 0x0c */ +#define CS_BAD_TYPE 0x0d /* Window/interface type invalid */ +#define CS_BAD_VCC 0x0e /* Vcc value/index invalid */ +#define CS_BAD_VPP 0x0f /* Vpp value/index invalid */ +#define CS_BAD_WINDOW 0x11 /* Specified window is invalid */ +#define CS_WRITE_FAILURE 0x12 /* Unable to complete write request */ + /* RESERVED - 0x13 */ +#define CS_NO_CARD 0x14 /* No PC card in socket */ +#define CS_UNSUPPORTED_FUNCTION 0x15 /* Unsupported function */ +#define CS_UNSUPPORTED_MODE 0x16 /* Unsupported processor mode */ +#define CS_BAD_SPEED 0x17 /* Specified speed is unavailable */ +#define CS_BUSY 0x18 /* CS is busy - try again later */ +#define CS_GENERAL_FAILURE 0x19 /* Undefined error */ +#define CS_WRITE_PROTECTED 0x1a /* Media is write protected */ +#define CS_BAD_ARG_LENGTH 0x1b /* Arg length invalid */ +#define CS_BAD_ARGS 0x1c /* Arg values invalid */ +#define CS_CONFIGURATION_LOCKED 0x1d /* This configuration is locked */ +#define CS_IN_USE 0x1e /* Requested resource in use */ +#define CS_NO_MORE_ITEMS 0x1f /* No more of requested item */ +#define CS_OUT_OF_RESOURCE 0x20 /* Internal CS resources exhausted */ +#define CS_BAD_HANDLE 0x21 /* client or window handle invalid */ + +/* + * The following are Solaris-specific extended return codes + */ +#define CS_NO_CIS 0x80 /* No CIS on card */ +#define CS_BAD_CIS 0x81 /* Bad CIS on card */ +#define CS_UNKNOWN_TUPLE 0x82 /* unknown tuple */ +#define CS_BAD_VERSION 0x83 /* bad CS version */ +#define CS_UNSUPPORTED_EVENT 0x84 /* Unsupported event in client */ +#define CS_CSI_ERROR 0x85 /* error in csi driver protocol */ +#define CS_CSI_NOT_INIT 0x86 /* csi library/driver not initialized */ +#define CS_NO_TUPLE_PARSER 0x87 /* no tuple parser for this tuple */ +#define CS_CARD_NOT_READY 0x88 /* card not ready */ +#define CS_ERRORLIST_END 0x8000 /* end of error list */ + +/* + * Card Services event codes - these do NOT correspond to the PCMCIA + * standard event codes for CS since these events are encoded as + * bit flags, while the PCMCIA standard event codes are encoded + * as numerical values. In practice, this shouldn't be a problem + * since no one should be looking at the absolute value of the + * event codes; these defines should be used. + * + * The numerical value of an event code determines in what order a client + * will receive the event if other events are also pending for that + * client. XXX - need to make event_t a 64-bit field. + * + * Card Services receives these events from Socket Services or by reading + * the card's Pin Replacement Register. In either case, the client + * always gets the same type of notification. + */ +#define CS_EVENT_REGISTRATION_COMPLETE 0x00000001 /* 0x82 */ +#define CS_EVENT_PM_RESUME 0x00000002 /* 0x05 */ +#define CS_EVENT_CARD_INSERTION 0x00000004 /* 0x0c */ +#define CS_EVENT_CARD_READY 0x00000008 /* 0x01 */ +#define CS_EVENT_BATTERY_LOW 0x00000010 /* 0x02 is also BVD2 */ +#define CS_EVENT_BATTERY_DEAD 0x00000020 /* 0x40 is also BVD1 */ +#define CS_EVENT_CARD_LOCK 0x00000040 /* 0x03 */ +#define CS_EVENT_PM_SUSPEND 0x00000080 /* 0x04 */ +#define CS_EVENT_CARD_RESET 0x00000100 /* 0x11 */ +#define CS_EVENT_CARD_UNLOCK 0x00000200 /* 0x06 */ +#define CS_EVENT_EJECTION_COMPLETE 0x00000400 /* 0x07 */ +#define CS_EVENT_EJECTION_REQUEST 0x00000800 /* 0x08 */ +#define CS_EVENT_ERASE_COMPLETE 0x00001000 /* 0x81 */ +#define CS_EVENT_EXCLUSIVE_COMPLETE 0x00002000 /* 0x0d */ +#define CS_EVENT_EXCLUSIVE_REQUEST 0x00004000 /* 0x0e */ +#define CS_EVENT_INSERTION_COMPLETE 0x00008000 /* 0x09 */ +#define CS_EVENT_INSERTION_REQUEST 0x00010000 /* 0x0a */ +#define CS_EVENT_RESET_COMPLETE 0x00020000 /* 0x80 */ +#define CS_EVENT_RESET_PHYSICAL 0x00040000 /* 0x0f */ +#define CS_EVENT_RESET_REQUEST 0x00080000 /* 0x10 */ +#define CS_EVENT_MTD_REQUEST 0x00100000 /* 0x12 */ +#define CS_EVENT_CLIENT_INFO 0x00200000 /* 0x14 */ +#define CS_EVENT_TIMER_EXPIRED 0x00400000 /* 0x15 */ +#define CS_EVENT_WRITE_PROTECT 0x01000000 /* 0x17 */ + +/* + * The CS_EVENT_SS_UPDATED event is generated when Socket Services + * has completed parsing the CIS and has done any necessary + * work to get the client driver loaded and attached. + */ +#define CS_EVENT_SS_UPDATED 0x00800000 /* 0x16 */ + +/* + * The CS_EVENT_STATUS_CHANGE event is generated by a Socket Services + * PCE_CARD_STATUS_CHANGE event; this event gets converted to + * the appropriate Card Services events when Card Services + * reads the PRR. + */ +#define CS_EVENT_STATUS_CHANGE 0x02000000 /* ?? */ + +/* + * The CS_EVENT_CARD_REMOVAL is the last "real" CS event and must + * have the highest value of all "real" CS events so that this + * event is handed to the client after all other queued events + * have been processed. + * If the client has set the CS_EVENT_CARD_REMOVAL_LOWP flag in + * either of their event masks, then they will also receive + * a CS_EVENT_CARD_REMOVAL at low (cs_event_thread) priority; + * in this low priority removal event, the client can call + * many CS functions that they can't call when they recieve + * the high priority removal event. + */ +#define CS_EVENT_CARD_REMOVAL 0x10000000 /* 0x0b */ +#define CS_EVENT_CARD_REMOVAL_LOWP 0x20000000 /* ?? */ +/* + * The following are not events but they share the event flags field + * and are used internally by CS. These bit patterns will never + * be seen by clients. + * CS_EVENT_ALL_CLIENTS can only be set by the super-client and by + * the CSI clients; setting this bit causes the driver to + * receive any events specified in their event masks whenever + * any such events occur on the socket. + * CS_EVENT_READY_TIMEOUT is a CS-private flag and should never be + * set by clients. + */ +#define CS_EVENT_ALL_CLIENTS 0x40000000 /* ?? */ +#define CS_EVENT_READY_TIMEOUT 0x80000000 /* ?? */ + +/* + * CS_EVENT_CLIENT_EVENTS_MASK is a msk of events that only the framework + * is allowed to manipulate. + */ +#define CS_EVENT_CLIENT_EVENTS_MASK ~(CS_EVENT_SS_UPDATED | \ + CS_EVENT_ALL_CLIENTS | \ + CS_EVENT_CARD_REMOVAL_LOWP) + +/* + * client_info_t structure used by clients for a CS_EVENT_CLIENT_INFO + * event and for the GetClientInfo function. + */ +#define CS_CLIENT_INFO_MAX_NAME_LEN 80 +typedef struct client_info_t { + uint32_t Attributes; + uint32_t Revision; /* BCD value of client revision */ + uint32_t CSLevel; /* BCD value of CS release */ + uint32_t RevDate; /* revision date */ + char ClientName[CS_CLIENT_INFO_MAX_NAME_LEN]; + char VendorName[CS_CLIENT_INFO_MAX_NAME_LEN]; + char DriverName[MODMAXNAMELEN]; +} client_info_t; + +/* + * Flags for client_info_t->Attributes + * + * The low order byte bit values are used to return the data passed + * in to RegisterClient in the client_reg_t->Attributes member. + */ +#define CS_CLIENT_INFO_SOCKET_SERVICES INFO_SOCKET_SERVICES +#define CS_CLIENT_INFO_IO_CLIENT INFO_IO_CLIENT +#define CS_CLIENT_INFO_MTD_CLIENT INFO_MTD_CLIENT +#define CS_CLIENT_INFO_MEM_CLIENT INFO_MEM_CLIENT +#define CS_CLIENT_INFO_CSI_CLIENT INFO_CSI_CLIENT +#define CS_CLIENT_INFO_CARD_SHARE INFO_CARD_SHARE +#define CS_CLIENT_INFO_CARD_EXCL INFO_CARD_EXCL +#define CS_CLIENT_INFO_CLIENT_MASK 0x000000ff +/* + * Control and status flags. + */ +#define CS_CLIENT_INFO_VALID 0x00010000 /* client info valid */ +#define CS_CLIENT_INFO_CLIENT_ACTIVE 0x00020000 /* client is for card */ +#define CS_CLIENT_INFO_FLAGS_MASK 0xffff0000 +/* + * Client Info subservice flags and types. + */ +#define CS_CLIENT_INFO_SUBSVC_CS 0x00000000 /* CS client data */ +#define CS_CLIENT_INFO_SUBSVC_MASK 0x0000ff00 /* sub-service mask */ +#define GET_CLIENT_INFO_SUBSVC(s) (((s) & CS_CLIENT_INFO_SUBSVC_MASK)>>8) +#define SET_CLIENT_INFO_SUBSVC(s) (((s)<<8) & CS_CLIENT_INFO_SUBSVC_MASK) + +/* + * CS_CLIENT_INFO_MAKE_DATE - Macro to make constructing the + * client_info_t->RevDate member easier. Parameters are: + * + * day - from 1 to 31 + * month - from 1 to 12 + * year - year relative to 1980 + * 00 - 1980 + * 06 - 1986 + * 12 = 1992 + * 16 - 1996, etc... + */ +#define CS_CLIENT_INFO_MAKE_DATE(d, m, y) (((d) & 0x01f) | \ + (((m) & 0x0f) << 5) | \ + (((y) & 0x7f) << 9)) +#define CS_CLIENT_INFO_GET_DAY(d) ((d) & 0x1f) +#define CS_CLIENT_INFO_GET_MONTH(m) (((m) >> 5) & 0x0f) +#define CS_CLIENT_INFO_GET_YEAR(y) ((((y) >> 9) & 0x7f) + 1980) +#define CS_CLIENT_INFO_GET_YEAR_OFFSET(y) (((y) >> 9) & 0x7f) + +/* + * get_firstnext_client_t_t structure used for GetFirstClient and GetNextClient + */ +typedef struct get_firstnext_client_t { + uint32_t Socket; + uint32_t Attributes; + client_handle_t client_handle; /* returned client handle */ + uint32_t num_clients; +} get_firstnext_client_t; + +/* + * Flags for get_firstnext_client_t->Attributes + */ +#define CS_GET_FIRSTNEXT_CLIENT_ALL_CLIENTS 0x00000001 +#define CS_GET_FIRSTNEXT_CLIENT_SOCKET_ONLY 0x00000002 + +/* + * The client event callback argument structure - this is passed in to + * the client event handler. Most of these arguments are identical + * to the PCMCIA-specified arguments. + */ +typedef struct event_callback_args_t { + client_handle_t client_handle; + void *info; + void *mtdrequest; + void *buffer; + void *misc; + void *client_data; + client_info_t client_info; +} event_callback_args_t; + +/* + * Event priority flag passed to the client's event handler; the client + * uses this priority to determine which mutex to use. + */ +#define CS_EVENT_PRI_LOW 0x0001 +#define CS_EVENT_PRI_HIGH 0x0002 +#define CS_EVENT_PRI_NONE 0x0004 + +/* + * Event-specific event_callback_args_t->info values + * + * CS_EVENT_WRITE_PROTECT + * CS_EVENT_WRITE_PROTECT_WPOFF - card is not write protected + * CS_EVENT_WRITE_PROTECT_WPON - card is write protected + */ +#define CS_EVENT_WRITE_PROTECT_WPOFF 0x0000 +#define CS_EVENT_WRITE_PROTECT_WPON 0xffff + +/* + * Endinanness and data ordering Attribute bits common to both R2 and + * CardBus windows and common to RequestIO, RequestWindow and + * DupHandle. + */ +#define WIN_ACC_ENDIAN_MASK 0x00300000 /* endian mask */ +#define WIN_ACC_NEVER_SWAP 0x00000000 /* i/o access: no swap */ +#define WIN_ACC_BIG_ENDIAN 0x00100000 /* big endian */ +#define WIN_ACC_LITTLE_ENDIAN 0x00200000 /* little endian */ + +#define WIN_ACC_ORDER_MASK 0x00700000 /* order mask */ +#define WIN_ACC_STRICT_ORDER 0x00000000 /* strict order */ +#define WIN_ACC_UNORDERED_OK 0x00100000 /* may be re-ordered */ +#define WIN_ACC_MERGING_OK 0x00200000 /* may merge i/o */ +#define WIN_ACC_LOADCACHING_OK 0x00300000 /* may cache reads */ +#define WIN_ACC_STORECACHING_OK 0x00400000 /* may cache all i/o */ + +/* + * io_req_t structure used for RequestIO and ReleaseIO + */ +typedef struct io_req_t { + uint32_t Socket; + baseaddru_t BasePort1; + uint32_t NumPorts1; /* 1st IO range no. contiguous ports */ + uint32_t Attributes1; /* 1st IO range attributes */ + baseaddru_t BasePort2; + uint32_t NumPorts2; /* 2nd IO range no. contiguous ports */ + uint32_t Attributes2; /* 2nd IO range attributes */ + uint32_t IOAddrLines; /* number of IO address lines decoded */ +} io_req_t; + +/* + * Flags for RequestIO and ReleaseIO + */ +#define IO_DATA_WIDTH_MASK 0x00000001 /* data path width mask */ +#define IO_DATA_WIDTH_8 0x00000000 /* 8 bit data path */ +#define IO_DATA_WIDTH_16 0x00000001 /* 16 bit data path */ + +/* + * The following flags are included for compatability with other versions of + * Card Services, but they are not implemented in this version. They + * are assigned values as placeholders only. If any of these flags + * are set on a call to RequestIO, CS_BAD_ATTRIBUTE is returned. + */ +#define IO_SHARED 0x00010000 /* for compatability only */ +#define IO_FIRST_SHARED 0x00020000 /* for compatability only */ +#define IO_FORCE_ALIAS_ACCESS 0x00040000 /* for compatability only */ + +/* + * The following flags are private to Card Services and should never be set + * by a client. Doing so will cause the system to take a supervisor + * trap at level twenty-nine. + */ +#define IO_DEALLOCATE_WINDOW 0x10000000 /* CS private */ +#define IO_DISABLE_WINDOW 0x20000000 /* CS private */ + +/* + * win_req_t structure used for RequestWindow + * + * Note that the ReqOffset member is not defined in the current PCMCIA + * spec but is included here to aid clients in determining the + * optimum offset to give to MapMemPage. + */ +typedef struct win_req_t { + uint32_t Socket; + uint32_t Attributes; /* window flags */ + union { + uint32_t base; /* requested window base address */ + acc_handle_t handle; /* access handle for base of window */ + } Base; + uint32_t Size; /* window size requested/granted */ + union { + uint32_t AccessSpeed; /* window access speed */ + uint32_t IOAddrLines; /* for I/O windows only */ + } win_params; + uint32_t ReqOffset; /* required window offest */ +} win_req_t; + +/* + * modify_win_t structure used for ModifyWindow + */ +typedef struct modify_win_t { + uint32_t Attributes; /* window flags */ + uint32_t AccessSpeed; /* window access speed */ +} modify_win_t; + +/* + * Flags for RequestWindow and ModifyWindow + */ +#define WIN_MEMORY_TYPE_MASK 0x00000021 /* window type mask */ +#define WIN_MEMORY_TYPE_CM 0x00000000 /* window points to CM */ +#define WIN_MEMORY_TYPE_AM 0x00000001 /* window points to AM */ +#define WIN_MEMORY_TYPE_IO 0x00000020 /* window points to IO */ + +#define WIN_DATA_WIDTH_MASK 0x00000042 /* data path width mask */ +#define WIN_DATA_WIDTH_8 0x00000000 /* 8-bit data path */ +#define WIN_DATA_WIDTH_16 0x00000002 /* 16-bit data path */ +#define WIN_DATA_WIDTH_32 0x00000040 /* 32-bit data path */ + +#define WIN_ENABLE 0x00000004 /* enable/disable window */ +#define WIN_OFFSET_SIZE 0x00000008 /* card offsets window sized */ +#define WIN_ACCESS_SPEED_VALID 0x00000010 /* speed valid (ModifyWindow) */ + +#define WIN_PREFETCH_CACHE_MASK 0x00000300 /* prefetch/cache mask */ +#define WIN_PREFETCH 0x00000100 /* prefetchable not cacheable */ +#define WIN_PREFETCH_CACHE 0x00000200 /* prefetchable and cacheable */ + +#define WIN_BAR_MASK 0x00007000 /* Base Address Register mask */ +#define WIN_BAR_1 0x00001000 /* Base Address Register 1 */ +#define WIN_BAR_2 0x00002000 /* Base Address Register 2 */ +#define WIN_BAR_3 0x00003000 /* Base Address Register 3 */ +#define WIN_BAR_4 0x00004000 /* Base Address Register 4 */ +#define WIN_BAR_5 0x00005000 /* Base Address Register 5 */ +#define WIN_BAR_6 0x00006000 /* Base Address Register 6 */ +#define WIN_BAR_7 0x00007000 /* Base Address Register 7 */ + +/* + * The following flag is used internally by Card Services and should never + * be set by the caller. + */ +#define WIN_DATA_WIDTH_VALID 0x00008000 /* CS internal */ + +/* + * The following flags are included for compatability with other versions of + * Card Services, but they are not implemented in this version. They + * are assigned values as placeholders only. If any of these flags + * are set on a call to RequestWindow, CS_BAD_ATTRIBUTE is returned. + */ +#define WIN_PAGED 0x00010000 /* for compatability only */ +#define WIN_SHARED 0x00020000 /* for compatability only */ +#define WIN_FIRST_SHARED 0x00040000 /* for compatability only */ +#define WIN_BINDING_SPECIFIC 0x00080000 /* for compatability only */ + +/* + * The following flag is actually part of the AccessSpeed member + */ +#define WIN_USE_WAIT 0x80 /* use window that supports WAIT */ + +/* + * client_reg_t structure for RegisterClient + */ +typedef struct client_reg_t { + uint32_t Attributes; + uint32_t EventMask; + event_callback_args_t event_callback_args; + uint32_t Version; /* CS version to expect */ + csfunction_t *event_handler; + /* DDI support */ + ddi_iblock_cookie_t *iblk_cookie; /* event iblk cookie */ + ddi_idevice_cookie_t *idev_cookie; /* event idev cookie */ + dev_info_t *dip; /* client's dip */ + char driver_name[MODMAXNAMELEN]; + /* CS private */ + void *priv; /* CS private data */ +} client_reg_t; + +/* + * Flags for RegisterClient - some of these flags are also used internally + * by CS to sequence the order of event callbacks and to allow Socket + * Services to register as a "super" client. + * + * The client_reg_t->Attributes structure member uses these flags. + * + * The client_info_t->Attributes, client_types_t->type and client_t->flags + * tructure members use these flags as well. + * + * Client types - mutually exclusive. + */ +#define INFO_SOCKET_SERVICES 0x00000001 +#define INFO_IO_CLIENT 0x00000002 +#define INFO_MTD_CLIENT 0x00000004 +#define INFO_MEM_CLIENT 0x00000008 +#define INFO_CSI_CLIENT 0x00000010 +#define INFO_CLIENT_TYPE_MASK (INFO_SOCKET_SERVICES | \ + INFO_IO_CLIENT | \ + INFO_MTD_CLIENT | \ + INFO_MEM_CLIENT | \ + INFO_CSI_CLIENT) +#define MAX_CLIENT_TYPES 3 /* doesn't include SS or CSI clients */ + +/* + * The following two are for backwards-compatability with the PCMCIA spec. + * We will give the client CARD_INSERTION and REGISTRATION_COMPLETE + * if either of these two bits are set. Normally, all IO and MEM + * clients should set both of these bits. + */ +#define INFO_CARD_SHARE 0x00000020 +#define INFO_CARD_EXCL 0x00000040 +#define INFO_CARD_FLAGS_MASK (INFO_CARD_SHARE | INFO_CARD_EXCL) + +/* + * tuple_t struct used for GetFirstTuple, GetNextTuple, GetTupleData + * and ParseTuple + * + * Note that the values for DesiredTuple are defined in the cis.h header + * file. + */ +typedef struct tuple_t { + uint32_t Socket; /* socket number to get tuple from */ + uint32_t Attributes; /* tuple return attributes */ + cisdata_t DesiredTuple; /* tuple to search for or flags */ + cisdata_t TupleOffset; /* offset in tuple data body */ + uint32_t Flags; /* CS private */ + cistpl_t *LinkOffset; /* CS private */ + cistpl_t *CISOffset; /* CS private */ + cisdata_t TupleDataMax; /* max size of tuple data area */ + cisdata_t TupleDataLen; /* actual size of tuple data area */ + /* tuple body data buffer */ + cisdata_t TupleData[CIS_MAX_TUPLE_DATA_LEN]; + cisdata_t TupleCode; /* tuple type code */ + cisdata_t TupleLink; /* tuple data body size */ +} tuple_t; + +/* + * Attribute flags definitions for CS tuple functions. + * + */ +#define TUPLE_RETURN_LINK 0x00000002 /* return link tuples */ +#define TUPLE_RETURN_IGNORED_TUPLES 0x00010000 /* return ignored tuples */ +#define TUPLE_RETURN_NAME 0x00020000 /* return tuple name */ + +/* + * cisinfo_t structure used for ValidateCIS + */ +typedef struct cisinfo_t { + uint32_t Socket; /* socket number to validate CIS on */ + uint32_t Chains; /* number of tuple chains in CIS */ + uint32_t Tuples; /* total number of tuples in CIS */ +} cisinfo_t; + +/* + * map_mem_page_t structure used for MapMemPage + */ +typedef struct map_mem_page_t { + uint32_t CardOffset; /* card offset */ + uint32_t Page; /* page number */ +} map_mem_page_t; + +/* + * sockevent_t structure used for GetEventMask and SetEventMask + */ +typedef struct sockevent_t { + uint32_t Attributes; /* attribute flags for call */ + uint32_t EventMask; /* event mask to set or return */ + uint32_t Socket; /* socket number if necessary */ +} sockevent_t; + +/* + * request_socket_mask_t structure used for RequestSocketMask + */ +typedef struct request_socket_mask_t { + uint32_t Socket; /* socket number if necessary */ + uint32_t EventMask; /* event mask to set or return */ +} request_socket_mask_t; + +/* + * release_socket_mask_t structure used for ReleaseSocketMask + */ +typedef struct release_socket_mask_t { + uint32_t Socket; +} release_socket_mask_t; + +/* + * Flags for GetEventMask and SetEventMask + */ +#define CONF_EVENT_MASK_GLOBAL 0x00000000 /* global event mask */ +#define CONF_EVENT_MASK_CLIENT 0x00000001 /* client event mask */ +#define CONF_EVENT_MASK_VALID 0x00000001 /* client event mask */ + +/* + * convert_speed_t structure used for ConvertSpeed + */ +typedef struct convert_speed_t { + uint32_t Attributes; + uint32_t nS; + uint32_t devspeed; +} convert_speed_t; + +/* + * Flags for ConvertSpeed + */ +#define CONVERT_NS_TO_DEVSPEED 0x00000001 +#define CONVERT_DEVSPEED_TO_NS 0x00000002 + +/* + * convert_size_t structure used for ConvertSize + */ +typedef struct convert_size_t { + uint32_t Attributes; + uint32_t bytes; + uint32_t devsize; +} convert_size_t; + +/* + * Flags for ConvertSize + */ +#define CONVERT_BYTES_TO_DEVSIZE 0x00000001 +#define CONVERT_DEVSIZE_TO_BYTES 0x00000002 + +#define MAX_CS_EVENT_BUFSIZE 64 /* single event */ +#define MAX_MULTI_EVENT_BUFSIZE 512 /* all events */ + +#define CS_EVENT_MAX_BUFSIZE MAX_MULTI_EVENT_BUFSIZE +#define CS_ERROR_MAX_BUFSIZE MAX_CS_EVENT_BUFSIZE + +/* + * event2text_t structure used for Event2Text + */ +typedef struct event2text_t { + event_t event; /* events */ + /* buffer to return text strings */ + char text[CS_EVENT_MAX_BUFSIZE]; +} event2text_t; + +/* + * error2text_t structure used for Error2Text + */ +typedef struct error2text_t { + uint32_t item; + char text[CS_ERROR_MAX_BUFSIZE]; +} error2text_t; + +/* + * get_status_t structure used for GetStatus + * + * The values in the status members are the same as the CS_EVENT_XXX values. + */ +typedef struct get_status_t { + uint32_t Socket; + uint32_t CardState; /* "live" card status for this client */ + uint32_t SocketState; /* latched socket values */ + uint32_t raw_CardState; /* raw live card status */ +} get_status_t; + +/* + * GetStatus returns card state using the same bit definitions + * as the CS_EVENT_XXX bits. Some of the CS_EVENT_XXX bits + * are not meaningful for GetStatus and are reused here for + * status definitions. + * + * get_status_t->CardState and get_status_t->raw_CardState bits + */ +#define CS_STATUS_WRITE_PROTECTED CS_EVENT_WRITE_PROTECT +#define CS_STATUS_CARD_LOCKED CS_EVENT_CARD_LOCK +#define CS_STATUS_EJECTION_REQUEST CS_EVENT_EJECTION_REQUEST +#define CS_STATUS_INSERTION_REQUEST CS_EVENT_INSERTION_REQUEST +#define CS_STATUS_BATTERY_DEAD CS_EVENT_BATTERY_DEAD +#define CS_STATUS_BATTERY_LOW CS_EVENT_BATTERY_LOW +#define CS_STATUS_CARD_READY CS_EVENT_CARD_READY +#define CS_STATUS_CARD_INSERTED CS_EVENT_CARD_INSERTION +#define CS_STATUS_RES_EVT1 0x00100000 +#define CS_STATUS_RES_EVT2 0x00200000 +#define CS_STATUS_RES_EVT3 0x00400000 +#define CS_STATUS_VCC_50 0x10000000 +#define CS_STATUS_VCC_33 0x20000000 +#define CS_STATUS_VCC_XX 0x40000000 +#define CS_STATUS_REQ_ATTN 0x80000000 +/* + * get_status_t->SocketState bits + */ +#define CS_SOCK_STATUS_WRITE_PROTECT_CHANGE CS_EVENT_WRITE_PROTECT +#define CS_SOCK_STATUS_CARD_LOCK_CHNAGE CS_EVENT_CARD_LOCK +#define CS_SOCK_STATUS_EJECTION_PENDING CS_EVENT_EJECTION_REQUEST +#define CS_SOCK_STATUS_INSERTION_PENDING CS_EVENT_INSERTION_REQUEST +#define CS_SOCK_STATUS_BATTERY_DEAD_CHNAGE CS_EVENT_BATTERY_DEAD +#define CS_SOCK_STATUS_BATTERY_LOW_CHNAGE CS_EVENT_BATTERY_LOW +#define CS_SOCK_STATUS_CARD_READY_CHANGE CS_EVENT_CARD_READY +#define CS_SOCK_STATUS_CARD_DETECT_CHNAGE CS_EVENT_CARD_INSERTION + +/* + * map_log_socket_t structure used for MapLogSocket + */ +typedef struct map_log_socket_t { + uint32_t LogSocket; /* logical socket */ + uint32_t PhyAdapter; /* physical adapter */ + uint32_t PhySocket; /* physical socket */ +} map_log_socket_t; + +/* + * get_physical_adapter_info_t structure used for GetPhysicalAdapterInfo + */ +typedef struct get_physical_adapter_info_t { + uint32_t LogSocket; /* logical socket */ + uint32_t PhySocket; /* physical socket */ + uint32_t flags; /* adapter flags */ + char name[MODMAXNAMELEN]; /* adapter module name */ + uint32_t major; /* adapter major number */ + uint32_t minor; /* adapter minor number */ + uint32_t instance; /* instance number of this adapter */ + uint32_t number; /* canonical adapter number */ + uint32_t num_sockets; /* # sockets on this adapter */ + uint32_t first_socket; /* first socket # on this adapter */ +} get_physical_adapter_info_t; + +/* + * irq_req_t structure used for RequestIRQ and ReleaseIRQ + */ +typedef struct irq_req_t { + uint32_t Socket; + uint32_t Attributes; /* IRQ attribute flags */ + csfunction_t *irq_handler; + void *irq_handler_arg; + ddi_iblock_cookie_t *iblk_cookie; /* IRQ iblk cookie */ + ddi_idevice_cookie_t *idev_cookie; /* IRQ idev cookie */ +} irq_req_t; + +/* + * Flags for RequestIRQ and ReleaseIRQ + */ +#define IRQ_TYPE_EXCLUSIVE 0x00000002 +/* + * The following flags are included for compatability with other versions of + * Card Services, but they are not implemented in this version. They + * are assigned values as placeholders only. If any of these flags + * are set on a call to RequestIRQ, CS_BAD_ATTRIBUTE is returned. + */ +#define IRQ_FORCED_PULSE 0x00010000 +#define IRQ_TYPE_TIME 0x00020000 +#define IRQ_TYPE_DYNAMIC_SHARING 0x00040000 +#define IRQ_FIRST_SHARED 0x00080000 +#define IRQ_PULSE_ALLOCATED 0x00100000 + +/* + * release_config_t structure used for ReleaseConfiguration + */ +typedef struct release_config_t { + uint32_t Socket; +} release_config_t; + +/* + * config_req_t structure used for RequestConfiguration + */ +typedef struct config_req_t { + uint32_t Socket; + uint32_t Attributes; /* configuration attributes */ + uint32_t Vcc; /* Vcc value */ + uint32_t Vpp1; /* Vpp1 value */ + uint32_t Vpp2; /* Vpp2 value */ + uint32_t IntType; /* socket interface type - mem or IO */ + uint32_t ConfigBase; /* offset from start of AM space */ + uint32_t Status; /* value to write to STATUS register */ + uint32_t Pin; /* value to write to PRR */ + uint32_t Copy; /* value to write to COPY register */ + uint32_t ConfigIndex; /* value to write to COR */ + uint32_t Present; /* which config registers present */ + uint32_t ExtendedStatus; /* value to write to EXSTAT register */ +} config_req_t; + +/* + * Flags for RequestConfiguration - note that the CONF_ENABLE_IRQ_STEERING + * flag shares the same bit field as the Attributes flags for + * ModifyConfiguration. + */ +#define CONF_ENABLE_IRQ_STEERING 0x00010000 +/* + * The following flags are used for the IntType member to specify which + * type of socket interface the client wants. + */ +#define SOCKET_INTERFACE_MEMORY 0x00000001 +#define SOCKET_INTERFACE_MEMORY_AND_IO 0x00000002 +/* + * The following flags are used for the Present member to specify which + * configuration registers are present. They may also be used by + * clients for their internal state. + */ +#define CONFIG_OPTION_REG_PRESENT 0x00000001 /* COR present */ +#define CONFIG_STATUS_REG_PRESENT 0x00000002 /* STAT reg present */ +#define CONFIG_PINREPL_REG_PRESENT 0x00000004 /* PRR present */ +#define CONFIG_COPY_REG_PRESENT 0x00000008 /* COPY reg present */ +#define CONFIG_EXSTAT_REG_PRESENT 0x00000010 /* EXSTAT reg present */ +#define CONFIG_IOBASE0_REG_PRESENT 0x00000020 /* IOBASE0 reg present */ +#define CONFIG_IOBASE1_REG_PRESENT 0x00000040 /* IOBASE1 reg present */ +#define CONFIG_IOBASE2_REG_PRESENT 0x00000080 /* IOBASE2 reg present */ +#define CONFIG_IOBASE3_REG_PRESENT 0x00000100 /* IOBASE3 reg present */ +#define CONFIG_IOLIMIT_REG_PRESENT 0x00000200 /* IOLIMIT reg present */ + +/* + * CONFIG_IOBASE_REG_MASK - mask of IO Base Port register present bits + * CONFIG_IOBASE_REG_SHIFT - shifts IO Base Port register present bits + */ +#define CONFIG_IOBASE_REG_MASK 0x000001e0 /* IOBASEn present mask */ +#define CONFIG_IOBASE_REG_SHIFT 5 + +/* + * Bit definitions for configuration registers. + * + * Pin Replacement Register (PRR) bits - these are used for calls to + * RequestConfiguration, AccessConfigurationRegister and + * GetConfigurationInfo, as well as internally by clients + * and Card Services. + * To inform Card Services that a particular bit in the PRR is valid on + * a call to RequestConfiguration, both the XXX_STATUS and the + * XXX_EVENT bits must be set. + */ +#define PRR_WP_STATUS 0x01 /* R-WP state W-write WP Cbit */ +#define PRR_READY_STATUS 0x02 /* R-READY state W-write READY Cbit */ +#define PRR_BVD2_STATUS 0x04 /* R-BVD2 state W-write BVD2 Cbit */ +#define PRR_BVD1_STATUS 0x08 /* R-BVD1 state W-write BVD1 Cbit */ +#define PRR_WP_EVENT 0x10 /* WP changed */ +#define PRR_READY_EVENT 0x20 /* READY changed */ +#define PRR_BVD2_EVENT 0x40 /* BVD2 changed */ +#define PRR_BVD1_EVENT 0x80 /* BVD1 changed */ +/* + * Configuration Option Register (COR) bits + */ +#define COR_ENABLE_FUNCTION 0x01 /* enable function */ +#define COR_ENABLE_BASE_LIMIT 0x02 /* enable base and limit registers */ +#define COR_ENABLE_IREQ_ROUTING 0x04 /* enable IREQ routing */ +#define COR_STATUS_CHANGE_MODE 0x08 /* status change mode */ +#define COR_LEVEL_IRQ 0x40 /* set to enable level interrupts */ +#define COR_SOFT_RESET 0x80 /* soft reset bit */ +/* + * Card Configuration Status Register (CCSR) + */ +#define CCSR_INTR_ACK 0x01 /* interrupt acknowledge */ +#define CCSR_INTR 0x02 /* interrupt pending */ +#define CCSR_POWER_DOWN 0x04 /* power down card */ +#define CCSR_AUDIO 0x08 /* enable Audio signal */ +#define CCSR_IO_IS_8 0x20 /* only 8-bit IO data path */ +#define CCSR_SIG_CHG 0x40 /* enable status changes */ +#define CCSR_CHANGED 0x80 /* one of the PRR bits has changed */ +/* + * Macros to manipulate the Socket and Copy Register (SCR) values + */ +#define SCR_GET_SOCKET(r) ((r)&0x0f) +#define SCR_GET_COPY(r) (((r)>>4)&7) +#define SCR_SET_SOCKET(s) ((s)&0x0f) +#define SCR_SET_COPY(c) (((c)&7)<<4) +#define SCR_SET_SOCKET_COPY(s, c) (((s)&0x0f) | (((c)&7)<<4)) + +/* + * modify_config_t structure used for ModifyConfiguration + */ +typedef struct modify_config_t { + uint32_t Socket; + uint32_t Attributes; /* attributes to modify */ + uint32_t Vpp1; /* Vpp1 value */ + uint32_t Vpp2; /* Vpp2 value */ +} modify_config_t; + +/* + * Flags for ModifyConfiguration - note that the CONF_ENABLE_IRQ_STEERING + * flag used with RequestConfiguration shares this bit field. + */ +#define CONF_VPP1_CHANGE_VALID 0x00000002 /* Vpp1 is valid */ +#define CONF_VPP2_CHANGE_VALID 0x00000004 /* Vpp2 is valid */ +#define CONF_IRQ_CHANGE_VALID 0x00000008 /* IRQ is valid */ + +/* + * access_config_reg_t structure used for AccessConfigurationRegister + */ +typedef struct access_config_reg_t { + uint32_t Socket; + uint32_t Action; /* register access operation */ + uint32_t Offset; /* config register offset */ + uint32_t Value; /* value read or written */ +} access_config_reg_t; +/* + * Flags for AccessConfigurationRegister + */ +#define CONFIG_REG_READ 0x00000001 /* read config register */ +#define CONFIG_REG_WRITE 0x00000002 /* write config register */ +/* + * The following offsets are used to specify the configuration register + * offset to AccessConfigurationRegister + */ +#define CONFIG_OPTION_REG_OFFSET 0x00 /* COR offset */ +#define CONFIG_STATUS_REG_OFFSET 0x02 /* STAT reg offset */ +#define CONFIG_PINREPL_REG_OFFSET 0x04 /* PRR offset */ +#define CONFIG_COPY_REG_OFFSET 0x06 /* COPY reg offset */ +#define CONFIG_EXSTAT_REG_OFFSET 0x08 /* EXSTAT reg offset */ +#define CONFIG_IOBASE0_REG_OFFSET 0x0a /* IOBASE0 reg offset */ +#define CONFIG_IOBASE1_REG_OFFSET 0x0c /* IOBASE1 reg offset */ +#define CONFIG_IOBASE2_REG_OFFSET 0x0e /* IOBASE2 reg offset */ +#define CONFIG_IOBASE3_REG_OFFSET 0x10 /* IOBASE3 reg offset */ +#define CONFIG_IOLIMIT_REG_OFFSET 0x12 /* IOLIMIT reg offset */ + +/* + * reset_function_t structure used for ResetFunction + */ +typedef struct reset_function_t { + uint32_t Socket; + uint32_t Attributes; +} reset_function_t; + +/* + * get_cardservices_info_t structure used for GetCardServicesInfo + */ +#define CS_GET_CARDSERVICES_INFO_MAX_VS_LEN 512 +typedef struct get_cardservices_info_t { + char Signature[2]; /* CS signature bytes */ + uint32_t NumSockets; /* number of sockets */ + uint32_t Revision; /* BCD value of CS revision */ + uint32_t CSLevel; /* BCD value of CS release */ + uint32_t FuncsPerSocket; /* max number of functions per socket */ + char VendorString[CS_GET_CARDSERVICES_INFO_MAX_VS_LEN]; +} get_cardservices_info_t; + +/* + * get_configuration_info_t structure used by GetConfigurationInfo + */ +typedef struct get_configuration_info_t { + uint32_t Socket; /* Socket/function to get info for */ + uint32_t Attributes; /* configuration attributes */ + uint32_t Vcc; /* Vcc value */ + uint32_t Vpp1; /* Vpp1 value */ + uint32_t Vpp2; /* Vpp2 value */ + uint32_t IntType; /* memory only or memory and IO ifc */ + uint32_t ConfigBase; /* offset from start of AM space */ + uint32_t Status; /* value written to STATUS register */ + uint32_t Pin; /* value written to PRR */ + uint32_t Copy; /* value to written COPY register */ + uint32_t Option; /* which written to COR */ + uint32_t Present; /* which config registers present */ + uint32_t FirstDevType; /* from CISTPL_DEVICE */ + uint32_t FuncCode; /* from CISTPL_FUNCID */ + uint32_t SysInitMask; /* from CISTPL_FUNCID */ + uint32_t ManufCode; /* from CISTPL_MANFID */ + uint32_t ManufInfo; /* from CISTPL_MANFID */ + uint32_t CardValues; /* which config registers written */ + uint32_t AssignedIRQ; /* IRQ assigned to card */ + uint32_t IRQ_Attributes; /* IRQ attributes */ + uint32_t BasePort1; /* address of 1st IO range */ + uint32_t NumPorts1; /* 1st IO range no. contiguous ports */ + uint32_t Attributes1; /* 1st IO range attributes */ + uint32_t BasePort2; /* address of 2nd IO range */ + uint32_t NumPorts2; /* 2nd IO range no. contiguous ports */ + uint32_t Attributes2; /* 2nd IO range attributes */ + uint32_t IOAddrLines; /* number of IO address lines decoded */ + uint32_t ExStat; /* value written to EXSTAT register */ + uint32_t DMA_Attributes; /* signals used for DMA */ + uint32_t DMA_Assign_Chan; /* assigned DMA channel */ + uint32_t NumIOWindows; /* number of IO windows in use */ + uint32_t NumMemWindows; /* number of memory windows in use */ +} get_configuration_info_t; + +/* + * devnode_desc_t structure used in make_device_node_t and remove_device_node_t + * for MakeDeviceNode and RemoveDeviceNode + */ +typedef struct devnode_desc_t { + char *name; /* device node path and name */ + int32_t spec_type; /* dev special type (block or char) */ + int32_t minor_num; /* device node minor number */ + char *node_type; /* device node type */ +} devnode_desc_t; + +/* + * make_device_node_t structure used for MakeDeviceNode + */ +typedef struct make_device_node_t { + uint32_t Action; /* device operation */ + uint32_t NumDevNodes; /* number of nodes to create */ + devnode_desc_t *devnode_desc; /* description of device nodes */ +} make_device_node_t; +/* + * Action values for MakeDeviceNode + */ +#define CREATE_DEVICE_NODE 0x01 /* create device node */ + +/* + * remove_device_node_t structure used for RemoveDeviceNode + */ +typedef struct remove_device_node_t { + uint32_t Action; /* device operation */ + uint32_t NumDevNodes; /* number of nodes to remove */ + devnode_desc_t *devnode_desc; /* description of device nodes */ +} remove_device_node_t; +/* + * Action values for RemoveDeviceNode + * + * Note: The "Action" member for make_device_node_t and remove_device_node_t + * share the same set of values. + */ +#define REMOVE_DEVICE_NODE 0x02 /* remove device node */ +#define REMOVE_ALL_DEVICE_NODES 0x03 /* remove all device nodes */ + +/* + * cs_ddi_info_t for CS_DDI_Info + */ +typedef struct cs_ddi_info_t { + uint32_t Socket; /* socket number */ + char *driver_name; /* unique driver name */ + dev_info_t *dip; /* dip */ + int32_t instance; /* instance */ +} cs_ddi_info_t; + +/* + * cs_sys_ctl_t for CS_Sys_Ctl + */ +typedef struct cs_sys_ctl_t { + uint32_t Socket; + uint32_t Action; + uint32_t Flags; + uint32_t Events; + client_handle_t client_handle; +} cs_sys_ctl_t; +/* + * cs_sys_ctl_t->Action defines + * + * CS_SYS_CTL_SEND_EVENT - send events in cs_sys_ctl_t->Events to clients + */ +#define CS_SYS_CTL_SEND_EVENT 0x0001 /* simulate events */ +/* + * cs_sys_ctl_t->Flags defines + * + * CS_SYS_CTL_WAIT_SYNC - wait for operation to complete, otherwise + * return immediately + * CS_SYS_CTL_EVENT_SOCKET - send events to all clients on specified + * socket + * CS_SYS_CTL_EVENT_CLIENT - send events to client specified by + * cs_sys_ctl_t->client_handle + */ +#define CS_SYS_CTL_WAIT_SYNC 0x00000001 /* synchornize with thread */ +#define CS_SYS_CTL_EVENT_SOCKET 0x00000002 /* to all clients on socket */ +#define CS_SYS_CTL_EVENT_CLIENT 0x00000004 /* to client specified */ + +/* + * Autoincrement control flags for RepPut8, RepPut16, RepPut32, RepPut32, + * RepGet8, RepGet16, RepGet32, RepGet64 + */ +#define CS_DEV_AUTOINCR DDI_DEV_AUTOINCR +#define CS_DEV_NO_AUTOINCR DDI_DEV_NO_AUTOINCR + +/* + * Card Services function prototypes + */ +int32_t csx_RegisterClient(client_handle_t *, client_reg_t *); +int32_t csx_DeregisterClient(client_handle_t); +int32_t csx_GetStatus(client_handle_t, get_status_t *); +int32_t csx_SetEventMask(client_handle_t, sockevent_t *); +int32_t csx_GetEventMask(client_handle_t, sockevent_t *); +int32_t csx_RequestIO(client_handle_t, io_req_t *); +int32_t csx_ReleaseIO(client_handle_t, io_req_t *); +int32_t csx_RequestIRQ(client_handle_t, irq_req_t *); +int32_t csx_ReleaseIRQ(client_handle_t, irq_req_t *); +int32_t csx_RequestWindow(client_handle_t, window_handle_t *, win_req_t *); +int32_t csx_ReleaseWindow(window_handle_t); +int32_t csx_ModifyWindow(window_handle_t, modify_win_t *); +int32_t csx_MapMemPage(window_handle_t, map_mem_page_t *); +int32_t csx_RequestSocketMask(client_handle_t, request_socket_mask_t *); +int32_t csx_ReleaseSocketMask(client_handle_t, release_socket_mask_t *); +int32_t csx_RequestConfiguration(client_handle_t, config_req_t *); +int32_t csx_ModifyConfiguration(client_handle_t, modify_config_t *); +int32_t csx_ReleaseConfiguration(client_handle_t, release_config_t *); +int32_t csx_AccessConfigurationRegister(client_handle_t, access_config_reg_t *); +int32_t csx_GetFirstTuple(client_handle_t, tuple_t *); +int32_t csx_GetNextTuple(client_handle_t, tuple_t *); +int32_t csx_GetTupleData(client_handle_t, tuple_t *); +int32_t csx_MapLogSocket(client_handle_t, map_log_socket_t *); +int32_t csx_ValidateCIS(client_handle_t, cisinfo_t *); +int32_t csx_MakeDeviceNode(client_handle_t, make_device_node_t *); +int32_t csx_RemoveDeviceNode(client_handle_t, remove_device_node_t *); +int32_t csx_ConvertSpeed(convert_speed_t *); +int32_t csx_ConvertSize(convert_size_t *); +int32_t csx_Event2Text(event2text_t *); +int32_t csx_Error2Text(error2text_t *); +int32_t csx_CS_DDI_Info(cs_ddi_info_t *); +int32_t csx_CS_Sys_Ctl(cs_sys_ctl_t *); +int32_t csx_ResetFunction(client_handle_t, reset_function_t *); +int32_t csx_GetFirstClient(get_firstnext_client_t *); +int32_t csx_GetNextClient(get_firstnext_client_t *); +int32_t csx_GetClientInfo(client_handle_t, client_info_t *); +int32_t csx_GetCardServicesInfo(client_handle_t, get_cardservices_info_t *); +int32_t csx_GetConfigurationInfo(client_handle_t *, get_configuration_info_t *); +int32_t csx_GetPhysicalAdapterInfo(client_handle_t, + get_physical_adapter_info_t *); + +/* + * CIS tuple parsing functions + */ +int32_t csx_Parse_CISTPL_CONFIG(client_handle_t, tuple_t *, cistpl_config_t *); +int32_t csx_Parse_CISTPL_DEVICE(client_handle_t, tuple_t *, cistpl_device_t *); +int32_t csx_Parse_CISTPL_DEVICE_A(client_handle_t, tuple_t *, + cistpl_device_t *); +int32_t csx_Parse_CISTPL_DEVICE_OA(client_handle_t, tuple_t *, + cistpl_device_t *); +int32_t csx_Parse_CISTPL_DEVICE_OC(client_handle_t, tuple_t *, + cistpl_device_t *); +int32_t csx_Parse_CISTPL_VERS_1(client_handle_t, tuple_t *, cistpl_vers_1_t *); +int32_t csx_Parse_CISTPL_VERS_2(client_handle_t, tuple_t *, cistpl_vers_2_t *); +int32_t csx_Parse_CISTPL_JEDEC_A(client_handle_t, tuple_t *, cistpl_jedec_t *); +int32_t csx_Parse_CISTPL_JEDEC_C(client_handle_t, tuple_t *, cistpl_jedec_t *); +int32_t csx_Parse_CISTPL_FORMAT(client_handle_t, tuple_t *, cistpl_format_t *); +int32_t csx_Parse_CISTPL_FORMAT_A(client_handle_t, tuple_t *, + cistpl_format_t *); +int32_t csx_Parse_CISTPL_GEOMETRY(client_handle_t, tuple_t *, + cistpl_geometry_t *); +int32_t csx_Parse_CISTPL_BYTEORDER(client_handle_t, tuple_t *, + cistpl_byteorder_t *); +int32_t csx_Parse_CISTPL_DATE(client_handle_t, tuple_t *, cistpl_date_t *); +int32_t csx_Parse_CISTPL_BATTERY(client_handle_t, tuple_t *, + cistpl_battery_t *); +int32_t csx_Parse_CISTPL_ORG(client_handle_t, tuple_t *, cistpl_org_t *); +int32_t csx_Parse_CISTPL_MANFID(client_handle_t, tuple_t *, cistpl_manfid_t *); +int32_t csx_Parse_CISTPL_FUNCID(client_handle_t, tuple_t *, cistpl_funcid_t *); +int32_t csx_Parse_CISTPL_FUNCE(client_handle_t, tuple_t *, cistpl_funce_t *, + uint32_t); +int32_t csx_Parse_CISTPL_CFTABLE_ENTRY(client_handle_t, tuple_t *, + cistpl_cftable_entry_t *); +int32_t csx_Parse_CISTPL_LINKTARGET(client_handle_t, tuple_t *, + cistpl_linktarget_t *); +int32_t csx_Parse_CISTPL_LONGLINK_A(client_handle_t, tuple_t *, + cistpl_longlink_ac_t *); +int32_t csx_Parse_CISTPL_LONGLINK_C(client_handle_t, tuple_t *, + cistpl_longlink_ac_t *); +int32_t csx_Parse_CISTPL_LONGLINK_MFC(client_handle_t, tuple_t *, + cistpl_longlink_mfc_t *); +int32_t csx_Parse_CISTPL_SPCL(client_handle_t, tuple_t *, + cistpl_spcl_t *); +int32_t csx_Parse_CISTPL_SWIL(client_handle_t, tuple_t *, + cistpl_swil_t *); +int32_t csx_Parse_CISTPL_BAR(client_handle_t, tuple_t *, + cistpl_bar_t *); +int32_t csx_Parse_CISTPL_DEVICEGEO(client_handle_t, tuple_t *, + cistpl_devicegeo_t *); +int32_t csx_Parse_CISTPL_DEVICEGEO_A(client_handle_t, tuple_t *, + cistpl_devicegeo_t *); +int32_t csx_Parse_CISTPL_LONGLINK_CB(client_handle_t, tuple_t *, + cistpl_longlink_cb_t *); +int32_t csx_ParseTuple(client_handle_t, tuple_t *, cisparse_t *, uint32_t); + +/* + * Data access functions + */ +void csx_Put8(acc_handle_t, uint32_t, uint8_t); +void csx_Put16(acc_handle_t, uint32_t, uint16_t); +void csx_Put32(acc_handle_t, uint32_t, uint32_t); +void csx_Put64(acc_handle_t, uint32_t, uint64_t); +uint8_t csx_Get8(acc_handle_t, uint32_t); +uint16_t csx_Get16(acc_handle_t, uint32_t); +uint32_t csx_Get32(acc_handle_t, uint32_t); +uint64_t csx_Get64(acc_handle_t, uint32_t); +void csx_RepPut8(acc_handle_t, uint8_t *, uint32_t, uint32_t, uint32_t); +void csx_RepPut16(acc_handle_t, uint16_t *, uint32_t, uint32_t, uint32_t); +void csx_RepPut32(acc_handle_t, uint32_t *, uint32_t, uint32_t, uint32_t); +void csx_RepPut64(acc_handle_t, uint64_t *, uint32_t, uint32_t, uint32_t); +void csx_RepGet8(acc_handle_t, uint8_t *, uint32_t, uint32_t, uint32_t); +void csx_RepGet16(acc_handle_t, uint16_t *, uint32_t, uint32_t, uint32_t); +void csx_RepGet32(acc_handle_t, uint32_t *, uint32_t, uint32_t, uint32_t); +void csx_RepGet64(acc_handle_t, uint64_t *, uint32_t, uint32_t, uint32_t); + +/* + * Data access handle manipulation functions + */ +int32_t csx_GetMappedAddr(acc_handle_t, void **); +int32_t csx_GetPhysAddr(acc_handle_t, void **); +int32_t csx_DupHandle(acc_handle_t, acc_handle_t *, uint32_t); +int32_t csx_FreeHandle(acc_handle_t *); +int32_t csx_GetHandleOffset(acc_handle_t, uint32_t *); +int32_t csx_SetHandleOffset(acc_handle_t, uint32_t); + +/* + * XXX - PCMCIA Shady Meadows Retirement Community + * + * The defines in this section should be retired once the PS drivers + * get updated. + * + * XXX This is an old version of WIN_DATA_WIDTH_MASK and should be + * retired soon. RETIRE + */ +#define WIN_DATA_WIDTH 0x00000002 /* 16-bit data path */ +/* + * XXX The following are old versions of the IO_DATA_WIDTH_XXX names and + * should be retured soon. RETIRE + */ +#define IO_DATA_PATH_WIDTH 0x00000001 /* 16 bit data path */ +#define IO_DATA_PATH_WIDTH_8 0x00000000 /* 8 bit data path */ +#define IO_DATA_PATH_WIDTH_16 0x00000001 /* 16 bit data path */ +/* + * XXX - REMOVAL_ALL_DEVICE_NODES typo, remove soon. RETIRE + */ +#define REMOVAL_ALL_DEVICE_NODES 0x03 /* remove all device nodes */ + +/* + * The old name of the csx_RequestSocketMask structure was + * sockmask_t for some bizzare reason. This typedef + * keeps that old name around until we can fix + * the drivers. + */ +typedef struct request_socket_mask_t sockmask_t; /* RETIRE */ + +/* XXX - RETIRE and change to a typedef XXX */ +struct devnode_desc { + char *name; /* device node path and name */ + int32_t spec_type; /* dev special type (block or char) */ + int32_t minor_num; /* device node minor number */ + char *node_type; /* device node type */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _CS_H */ diff --git a/illumos-x86_64/usr/include/sys/cs_priv.h b/illumos-x86_64/usr/include/sys/cs_priv.h new file mode 100644 index 00000000..8af8b343 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cs_priv.h @@ -0,0 +1,772 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _CS_PRIV_H +#define _CS_PRIV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * PCMCIA Card Services private header file + */ + +/* + * typedef for function pointers to quiet lint and cc -v + */ +typedef int32_t (f_t)(int32_t, ...); /* for lint - cc -v quieting */ + +/* + * Magic number we use when talking with Socket Services + */ +#define CS_MAGIC PCCS_MAGIC + +/* + * Make the calls to SocketServices and the CIS Parser look like + * function calls. + */ +#define SocketServices (*cs_socket_services) +#define CIS_PARSER (*cis_parser) + +/* + * CIS_DEFAULT_SPEED is the default speed to use to read the CIS + * in AM space. It is expressed in nS. + */ +#define CIS_DEFAULT_SPEED 250 + +/* + * This is the IO window speed. + */ +#define IO_WIN_SPEED 250 + +/* + * Flags to support various internal first/next functions. All of + * these must be within CIS_GET_LTUPLE_OPMASK which is defined + * in the cis.h file. Values outside this mask range are used + * internally by the CIS parser. + */ +#define CS_GET_FIRST_FLAG 0x0001 +#define CS_GET_NEXT_FLAG 0x0002 + +/* + * Macros to manipulate bits - only does up to uint32_t size + */ +#define CS_BIT_WORDSIZE (sizeof (uint32_t)) + +#define CS_BIT_GET(val, bit) \ + ((uint32_t)(val) & (uint32_t)(1<<(uint32_t)(bit))) + +#define CS_BIT_CLEAR(val, bit) ((val) &= (uint32_t)~(1<<(uint32_t)(bit))) + +#define CS_BIT_SET(val, bit) \ + ((uint32_t)(val) |= (uint32_t)(1<<(uint32_t)(bit))) + +/* + * Minimum time to wait after socket reset before we are allowed to + * access the card. The PCMCIA specification says at least 20mS + * must elapse from the time that the card is reset until the + * first access of any kind can be made to the card. This time + * value is expressed in mS. + */ +#define RESET_TIMEOUT_TIME 180 + +/* + * Maximum time to wait for card ready after resetting the socket. + * We wait for card ready a maximum of 20 seconds after card + * reset before considering that we have an error condition. + * XXX - what does PCMCIA specify as the max time here?? + */ +#define READY_TIMEOUT_TIME (drv_usectohz(20000000)) + +/* + * Time between periodically kicking the soft interrupt handler. + */ +#define SOFTINT_TIMEOUT_TIME (drv_usectohz(2000000)) + +/* + * Various delays are necessary when switching the card and socket + * between IO and memory modes. All delays are in mS. + * + * cs_request_configuration parameters: + * CS_RC1_DELAY - delay between writing COR and switching socket + * to IO mode + * CS_RC2_DELAY - delay after switching socket to IO mode + * + * cs_release_configuration parameters: + * CS_RQ_DELAY - amount of time that the RESET bit in the COR is + * held asserted + */ +#define CS_RC1_DELAY 20 /* COR->IO delay in mS */ +#define CS_RC2_DELAY 300 /* post-COR delay in mS */ +#define CS_RQ_DELAY 100 /* COR(RESET) delay in mS */ + +/* + * Handy macro to do untimeout. + */ +#define UNTIMEOUT(id) \ + if ((id)) { \ + (void) untimeout((id)); \ + (id) = 0; \ + } + +/* + * Macros to enter/exit event thread mutex + */ +#define EVENT_THREAD_MUTEX_ENTER(acq, sp) \ + acq = !MUTEX_HELD(&sp->client_lock); \ + if (acq) \ + mutex_enter(&sp->client_lock); +#define EVENT_THREAD_MUTEX_EXIT(acq, sp) \ + if (acq) \ + mutex_exit(&sp->client_lock); + +/* + * cisregister_t structure is used to support the CISRegister + * and the CISUnregister function calls + */ +typedef struct cisregister_t { + uint32_t cis_magic; + uint32_t cis_version; + void * (*cis_parser)(int32_t function, ...); + cistpl_callout_t *cistpl_std_callout; /* standard callout list */ +} cisregister_t; + +/* + * These two defines are to support CISRegister and CISUnregister + */ +#define CIS_MAGIC 0x20434953 +#define CIS_VERSION _VERSION(0, 1) + +/* + * CS_MAX_CIS defines the number of CIS chains that we hang off the per-socket + * structure. + * + * CS_GLOBAL_CIS defines the index where the CIS parser puts the first CIS list + * for a single-function card or the global CIS list for a multi-function + * card. + * + * CS_MAX_CIS is one greater than CIS_MAX_FUNCTIONS since the CIS parser + * puts the global CIS chain on the CS_GLOBAL_CIS function index as + * follows: + * + * For single-function cards: + * sp->cis[0] - CIS chain + * sp->cis[1..(CIS_MAX_FUNCTIONS - 1)] - not used + * sp->cis[CS_GLOBAL_CIS] - not used + * + * For multi-function cards: + * sp->cis[0..(CIS_MAX_FUNCTIONS - 1)] - global CIS chain followed + * by per-function CIS chain + * sp->cis[CS_GLOBAL_CIS] - global CIS chain + */ +#define CS_MAX_CIS (CIS_MAX_FUNCTIONS + 1) +#define CS_GLOBAL_CIS CIS_MAX_FUNCTIONS + +/* + * CS_SS_CLIENT_HANDLE is a special client handle that Socket Services gets + * when it registers with RegisterClient. + */ +#define CS_SS_CLIENT_HANDLE 0x00000000 + +/* + * Client handle, socket number, function number and socket pointer + * macros. The client handle encoding is private to Card Services, + * and external modules should not use these macros to manipulate + * client handles. + * + * The encoding of the client handle is: + * + * xxxxxfff | xsssssss | cccccccc | cccccccc + * + * f - function number bit + * s - socket number bit + * c - client number bit + * x - don't care bits + */ +#define CLIENT_HANDLE_IS_SS(ch) (!GET_CLIENT_MINOR((ch))) +#define CS_MAX_SOCKETS_MASK (PCMCIA_MAX_SOCKETS - 1) +#define CS_MAX_FUNCTIONS_MASK (CIS_MAX_FUNCTIONS - 1) +#define CS_MAX_CLIENTS_MASK 0x0ffff +#define CS_MAX_CLIENTS (CS_MAX_CLIENTS_MASK - 2) +#define MAKE_CLIENT_HANDLE(s, f, c) ((((f)&CS_MAX_FUNCTIONS_MASK)<<24) | \ + (((s)&CS_MAX_SOCKETS_MASK)<<16) | \ + ((c)&CS_MAX_CLIENTS_MASK)) +#define GET_CLIENT_SOCKET(ch) (((ch)>>16)&CS_MAX_SOCKETS_MASK) +#define GET_CLIENT_FUNCTION(ch) (((ch)>>24)&CS_MAX_FUNCTIONS_MASK) +#define GET_CLIENT_MINOR(ch) ((ch)&CS_MAX_CLIENTS_MASK) + +/* + * Socket number macros. These are used by Socket Services, CSI + * drivers and the "super-client" driver to specify which + * socket and function number on that socket they wish to + * manipulate. This socket number encoding is typically passed + * to various Card Services functions by these drivers. + * + * The encoding of the socket number is: + * + * xxxxxxxx | xxxxgfff | xxxxxxxx | xsssssss + * + * g - global CIS bit + * f - function number bit + * s - socket number bit + * x - don't care bits + */ +#define CS_GET_SOCKET_NUMBER(s) ((s)&CS_MAX_SOCKETS_MASK) +#define CS_GET_FUNCTION_NUMBER(s) (((s)>>16)&(CS_MAX_FUNCTIONS_MASK | \ + CIS_MAX_FUNCTIONS)) +#define CS_SET_SOCKET_NUMBER(s) ((s)&CS_MAX_SOCKETS_MASK) +#define CS_SET_FUNCTION_NUMBER(f) (((f)&(CS_MAX_FUNCTIONS_MASK | \ + CIS_MAX_FUNCTIONS))<<16) +#define CS_MAKE_SOCKET_NUMBER(s, f) (CS_SET_SOCKET_NUMBER(s) | \ + CS_SET_FUNCTION_NUMBER(f)) + +/* + * DIP2SOCKET_NUM(dip) - this macro gets the PCM_DEV_SOCKET property from + * the passed dip. If the property can't be found, then the default + * value of cs_globals.max_socket_num is returned. + */ +#define DIP2SOCKET_NUM(dip) ddi_getprop(DDI_DEV_T_NONE, dip,\ + (DDI_PROP_CANSLEEP | \ + DDI_PROP_NOTPROM), \ + PCM_DEV_SOCKET, \ + cs_globals.max_socket_num) + +/* + * Range checking macros + * + * CHECK_SOCKET_NUM(socket_number, max_sockets) returns 1 if + * socket_number is in range + */ +#define CHECK_SOCKET_NUM(sn, ms) (((sn) >= (ms))?0:1) + +/* + * window macros + * + * These all expect that the window has been validated as a valid + * window (i.e. CW_WINDOW_VALID is set in window state) + * + * Note that WINDOW_FOR_SOCKET expects a socket mask for the wsm + * parameter (this is a socket_enum_t type, and NOT just a + * plain old uint32_t) + */ +#define WINDOW_FOR_SOCKET(wsm, sn) ((wsm)[sn/PR_WORDSIZE] & \ + (1 << ((sn) & PR_MASK))) +#define WINDOW_AVAILABLE_FOR_MEM(cwp) (!(cwp->state & CW_WIN_IN_USE)) +#define WINDOW_AVAILABLE_FOR_IO(cwp) \ + (!(cwp->state & (CW_CIS | CW_MEM | CW_ALLOCATED))) + +/* + * IO Base and NumPorts address frobnitz macros + */ +#define IOADDR_FROBNITZ(Base, IOAddrLines) (Base&((1<event_callback_handler(event, pri, \ + &(cp)->event_callback_args) + +/* + * Macro to return event in PRR - this also clears the changed bit if + * the event occured. + */ +#define PRR_EVENT(prrx, pe, ps, ce, re) \ + if (prrx & pe) { \ + if (prrx & ps) \ + (re) |= ce; \ + prrx &= ~pe; \ + prrx |= ps; \ + } + +/* + * io_alloc_t struct used to keep track of a client's IO window allocation + */ +typedef struct io_alloc_t { + uint32_t Window1; /* allocated IO window no. for set #1 */ + baseaddru_t BasePort1; /* 1st IO range base address or port */ + uint32_t NumPorts1; /* 1st IO range no. contiguous ports */ + uint32_t Attributes1; /* 1st IO range attributes */ + uint32_t Window2; /* allocated IO window no. for set #2 */ + baseaddru_t BasePort2; /* s2nd IO range base address or port */ + uint32_t NumPorts2; /* 2nd IO range no. contiguous ports */ + uint32_t Attributes2; /* second IO range attributes */ + uint32_t IOAddrLines; /* number of IO address lines decoded */ +} io_alloc_t; + +/* + * irq_alloc_t structure used to keep track of a client's IRQ allocation + */ +typedef struct irq_alloc_t { + uint32_t Attributes; /* IRQ attribute flags */ + uint32_t irq; /* assigned IRQ number */ + uint32_t handler_id; /* IRQ handler ID for this IRQ */ + f_t *irq_handler; + void *irq_handler_arg1; + void *irq_handler_arg2; +} irq_alloc_t; + +/* + * The client data structure + */ +typedef struct client_t { + client_handle_t client_handle; /* this client's client handle */ + unsigned flags; /* client flags */ + /* resource control */ + uint32_t memwin_count; /* number of mem windows allocated */ + io_alloc_t io_alloc; /* IO resource allocations */ + irq_alloc_t irq_alloc; /* IRQ resource allocations */ + /* event support */ + uint32_t event_mask; /* client event mask */ + uint32_t global_mask; /* client global event mask */ + uint32_t events; /* current events pending */ + uint32_t pending_events; /* events pending in RegisterClient */ + csfunction_t *event_callback_handler; + event_callback_args_t event_callback_args; + /* config registers support */ + config_regs_t config_regs; /* pointers to config registers */ + uint32_t config_regs_offset; /* offset from start of AM */ + unsigned pin; /* valid bits in PRR */ + uint32_t present; /* which config registers present */ + /* DDI support */ + dev_info_t *dip; /* this client's dip */ + char *driver_name; /* client's driver name */ + int32_t instance; /* client's driver instance */ + /* list control */ + struct client_t *next; /* next client pointer */ + struct client_t *prev; /* previous client pointer */ +} client_t; + +/* + * Flags for client structure - note that we share the client_t->flags + * member with the definitions in cs.h that are used by the + * RegisterClient function. + * + * We can start our flags from 0x00001000 and on up. + */ +#define REQ_CONFIGURATION_DONE 0x00001000 /* RequestConfiguration done */ +#define REQ_SOCKET_MASK_DONE 0x00002000 /* RequestSocketMask done */ +#define REQ_IO_DONE 0x00004000 /* RequestIO done */ +#define REQ_IRQ_DONE 0x00008000 /* RequestIRQ done */ +#define CLIENT_SUPER_CLIENT 0x00010000 /* "super-client" client */ +#define CLIENT_CSI_CLIENT 0x00020000 /* CSI client */ +#define CLIENT_CARD_INSERTED 0x00100000 /* current card for client */ +#define CLIENT_SENT_INSERTION 0x00200000 /* send CARD_INSERTION */ +#define CLIENT_MTD_IN_PROGRESS 0x01000000 /* MTD op in progress */ +#define CLIENT_IO_ALLOCATED 0x02000000 /* IO resources allocated */ +#define CLIENT_IRQ_ALLOCATED 0x04000000 /* IRQ resources allocated */ +#define CLIENT_WIN_ALLOCATED 0x08000000 /* window resources allocated */ + +#ifdef USE_IOMMAP_WINDOW +/* + * io_mmap_window_t structure that describes the memory-mapped IO + * window on this socket + */ +typedef struct io_mmap_window_t { + uint32_t flags; /* window flags */ + uint32_t number; /* IO window number */ + uint32_t size; /* size of mapped IO window */ + ddi_acc_handle_t handle; /* window mapped base address */ + uint32_t count; /* referance count */ +} io_mmap_window_t; +#endif /* USE_IOMMAP_WINDOW */ + +/* + * cis_info_t structure used to hold per-socket CIS information + */ +typedef struct cis_info_t { + uint32_t flags; /* CIS-specific flags */ + cistpl_t *cis; /* CIS linked lists */ + uint32_t nchains; /* number of tuple chains in CIS */ + uint32_t ntuples; /* number of tuples in CIS */ +} cis_info_t; + +/* + * cs_adapter_t structure used to hold per-socket + * adapter-specific info + */ +typedef struct cs_adapter_t { + uint32_t flags; /* adapter flags */ + char name[MODMAXNAMELEN]; /* adapter module name */ + uint32_t major; /* adapter major number */ + uint32_t minor; /* adapter minor number */ + uint32_t instance; /* instance number of this adapter */ + uint32_t number; /* canonical adapter number */ + uint32_t num_sockets; /* # sockets on this adapter */ + uint32_t first_socket; /* first socket # on this adapter */ +} cs_adapter_t; + +/* + * The per-socket structure. + */ +typedef struct cs_socket_t { + unsigned socket_num; /* socket number */ + uint32_t flags; /* socket flags */ + uint32_t init_state; /* cs_init state */ + cs_adapter_t adapter; /* adapter info */ + /* socket thread control and status */ + kthread_t *event_thread; /* per-socket work thread */ + uint32_t thread_state; /* socket thread state flags */ + kmutex_t lock; /* protects events and clients */ + kcondvar_t thread_cv; /* event handling synchronization */ + kcondvar_t caller_cv; /* event handling synchronization */ + kcondvar_t reset_cv; /* for use after card RESET */ + uint32_t events; /* socket events */ + uint32_t event_mask; /* socket event mask */ + ddi_softintr_t softint_id; /* soft interrupt handler ID */ + timeout_id_t rdybsy_tmo_id; /* timer ID for READY/BUSY timer */ + ddi_iblock_cookie_t *iblk; /* event iblk cookie */ + ddi_idevice_cookie_t *idev; /* event idev cookie */ + callb_cpr_t cprinfo_cs; /* CPR cookie for cs_event_thread */ + callb_cpr_t cprinfo_ss; /* CPR cookie for cs_ss_thread */ + /* client management */ + client_t *client_list; /* clients on this socket */ + unsigned next_cl_minor; /* next available client minor num */ + kmutex_t client_lock; /* protects client list */ + uint32_t num_clients; /* number of clients on this socket */ + /* CIS support */ + uint32_t cis_win_num; /* CIS window number */ + unsigned cis_win_size; /* CIS window size */ + uint32_t cis_flags; + uint32_t nfuncs; /* number of functions */ + cis_info_t cis[CS_MAX_CIS]; /* CIS information */ + kmutex_t cis_lock; /* protects CIS */ +#ifdef USE_IOMMAP_WINDOW + /* memory mapped IO window support */ + io_mmap_window_t *io_mmap_window; +#endif /* USE_IOMMAP_WINDOW */ + /* Socket Services work thread control and status */ + kthread_t *ss_thread; /* SS work thread */ + uint32_t ss_thread_state; /* SS work thread state */ + kcondvar_t ss_thread_cv; /* SS work thread synchronization */ + kcondvar_t ss_caller_cv; /* SS work thread synchronization */ + kmutex_t ss_thread_lock; /* protects SS work thread state */ + struct cs_socket_t *next; /* next socket in list */ +} cs_socket_t; + +/* + * cs_socket_t->flags flags + */ +#define SOCKET_CARD_INSERTED 0x00000001 /* card is inserted */ +#define SOCKET_IS_IO 0x00000002 /* socket in IO mode */ +#define SOCKET_UNLOAD_MODULE 0x00000004 /* want to unload CS */ +#define SOCKET_NEEDS_THREAD 0x00000008 /* wake event thread */ +#define SOCKET_IS_VALID 0x00000020 /* socket OK to use */ + +/* + * cs_socket_t->thread_state and cs_socket_t->ss_thread_state flags + */ + +/* generic for all threads */ +#define SOCKET_THREAD_EXIT 0x00000001 /* exit event thread */ + +/* only used for per-socket event thread */ +#define SOCKET_WAIT_FOR_READY 0x00001000 /* waiting for READY */ +#define SOCKET_RESET_TIMER 0x00002000 /* RESET timer */ +#define SOCKET_WAIT_SYNC 0x00004000 /* SYNC */ + +/* only used for Socket Services work thread */ +#define SOCKET_THREAD_CSCISInit 0x00100000 /* call CSCISInit */ + +/* + * cs_socket_t->cis_flags and cs_socket_t->cis_info_t->flags flags + */ +#define CW_VALID_CIS 0x00000001 /* valid CIS */ +#define CW_MULTI_FUNCTION_CIS 0x00000002 /* multifunction card */ +#define CW_LONGLINK_A_FOUND 0x00000004 /* CISTPL_LONGLINK_A */ +#define CW_LONGLINK_C_FOUND 0x00000008 /* CISTP_LONGLINK_C */ +#define CW_LONGLINK_MFC_FOUND 0x00000010 /* LONGLINK_MFC */ +#define CW_CHECK_LINKTARGET 0x00000020 /* check linktarget */ +#define CW_RET_ON_LINKTARGET_ERROR 0x00000040 /* linktarget invalid */ +#define CW_CHECK_PRIMARY_CHAIN 0x00000080 /* check for primary */ + /* chain tuples */ + +/* + * CW_LONGLINK_FOUND - a combination of the various CW_LONGLINK_XXX_FOUND + * flags used to make the code less dense. + */ +#define CW_LONGLINK_FOUND (CW_LONGLINK_A_FOUND | \ + CW_LONGLINK_C_FOUND | \ + CW_LONGLINK_MFC_FOUND) + +/* + * macro to test for a valid CIS window on a socket + */ +#define SOCKET_HAS_CIS_WINDOW(sp) (sp->cis_win_num != PCMCIA_MAX_WINDOWS) + +/* + * cs_socket_t->init_state flags - these flags are used to keep track of what + * was allocated in cs_init so that things can be deallocated properly + * in cs_deinit. + */ +#define SOCKET_INIT_STATE_MUTEX 0x00000001 /* mutexii are OK */ +#define SOCKET_INIT_STATE_CV 0x00000002 /* cvii are OK */ +#define SOCKET_INIT_STATE_THREAD 0x00000004 /* thread OK */ +#define SOCKET_INIT_STATE_READY 0x00000008 /* socket OK */ +#define SOCKET_INIT_STATE_SS_THREAD 0x00000010 /* SS thread OK */ +/* + * While this next flag doesn't really describe a per-socket resource, + * we still set it for each socket. When the soft interrupt handler + * finally gets removed in cs_deinit, this flag will get cleared. + * The value of this flag should follow the previous SOCKET_INIT + * flag values. + */ +#define SOCKET_INIT_STATE_SOFTINTR 0x00000020 /* softintr handler */ + +/* + * Macro to create a socket event thread. + */ +#define CS_THREAD_PRIORITY (v.v_maxsyspri - 4) +#define CREATE_SOCKET_EVENT_THREAD(eh, csp) \ + thread_create(NULL, 0, eh, (void *)csp, \ + 0, &p0, TS_RUN, CS_THREAD_PRIORITY) + +/* + * The per-window structure. + */ +typedef struct cs_window_t { + uint32_t window_num; /* window number */ + window_handle_t window_handle; /* unique window handle */ + client_handle_t client_handle; /* owner of this window */ + unsigned socket_num; /* socket number */ + unsigned state; /* window state flags */ + struct cs_window_t *next; /* next window in list */ +} cs_window_t; + +/* + * Window structure state flags - if none of the bits in the + * CW_WIN_IN_USE mask are set AND if CW_WINDOW_VALID is set, + * it means that this window is available and not being used + * by anyone. + * Setting the CW_ALLOCATED will prevent the window from being found + * as an available window for memory or IO; since memory windows + * are not shared between clients, RequestWindow will always set + * the CW_ALLOCATED flag when it has assigned a memory window to + * a client. Since we can sometimes share IO windows, RequestIO + * will only set the CW_ALLOCATED flag if it doesn't want the IO + * window to be used by other calls to RequestIO. + * When CW_WINDOW_VALID is set, it means that this is a valid window + * that has been added by the framework and can be used. If this + * bit is not set, this window can not be used at all. + */ +#define CW_ALLOCATED 0x00000001 /* window is allocated */ +#define CW_CIS 0x00000002 /* window being used as CIS window */ +#define CW_MEM 0x00000004 /* window being used as mem window */ +#define CW_IO 0x00000008 /* window being used as IO window */ +#define CW_WIN_IN_USE 0x0000ffff /* window in use mask */ +#define CW_WINDOW_VALID 0x00010000 /* window is valid */ + +/* + * window handle defines - the WINDOW_HANDLE_MASK implies the maximum number + * of windows allowed + */ +#define WINDOW_HANDLE_MAGIC 0x574d0000 +#define WINDOW_HANDLE_MASK 0x0000ffff +#define GET_WINDOW_NUMBER(wh) ((wh) & WINDOW_HANDLE_MASK) +#define GET_WINDOW_MAGIC(wh) ((wh) & ~WINDOW_HANDLE_MASK) + +/* + * The client type structures, used to sequence events to clients on a + * socket. The "type" flags are the same as are used for the + * RegisterClient function. + */ +typedef struct client_types_t { + uint32_t type; + uint32_t order; + struct client_types_t *next; +} client_types_t; + +/* + * Flags that specify the order of client event notifications for the + * client_types_t structure. + */ +#define CLIENT_EVENTS_LIFO 0x00000001 +#define CLIENT_EVENTS_FIFO 0x00000002 + +/* + * This is a structure that CS uses to keep track of items that are global + * to all functions in the module. + */ +typedef struct cs_globals_t { + cs_socket_t *sp; /* head of socket list */ + cs_window_t *cw; /* head of window list */ + kmutex_t global_lock; /* protects this struct */ + kmutex_t window_lock; /* protects cs_windows */ + ddi_softintr_t softint_id; /* soft interrupt handler id */ + timeout_id_t sotfint_tmo; /* soft interrupt handler timeout id */ + uint32_t init_state; /* flags set in cs_init */ + uint32_t flags; /* general global flags */ + uint32_t max_socket_num; /* highest socket number plus one */ + uint32_t num_sockets; /* total number of sockets */ + uint32_t num_windows; /* total number of windows */ + struct sclient_list_t *sclient_list; +} cs_globals_t; + +/* + * Flags for cs_globals_t->init_state + */ +#define GLOBAL_INIT_STATE_SOFTINTR 0x00010000 /* softintr handler */ +#define GLOBAL_INIT_STATE_MUTEX 0x00020000 /* global mutex init */ +#define GLOBAL_INIT_STATE_NO_CLIENTS 0x00040000 /* no new clients */ +#define GLOBAL_INIT_STATE_UNLOADING 0x00080000 /* cs_deinit running */ +#define GLOBAL_INIT_STATE_SS_READY 0x00100000 /* SS ready for */ + /* callbacks */ +/* + * Flags for cs_globals_t->flags + */ +#define GLOBAL_SUPER_CLIENT_REGISTERED 0x00000001 /* "super-client" reg */ +#define GLOBAL_IN_SOFTINTR 0x00000002 /* in soft int code */ + +/* + * sclient_reg_t struct for RegisterClient when a "super-client" is + * registering. + * This structure is actually hung off of the client_reg_t.private + * structure member. Since we don't make public how to write + * a "super-client", the actual structure that the client uses + * is defined in this private header file. + */ +typedef struct sclient_reg_t { + uint32_t max_socket_num; + uint32_t num_sockets; + uint32_t num_windows; + uint32_t num_clients; + struct sclient_list_t { + client_handle_t client_handle; + uint32_t error; + } **sclient_list; +} sclient_reg_t; + +/* + * structure for event text used for cs_ss_event_text + */ +typedef struct cs_ss_event_text_t { + event_t ss_event; /* SS event code */ + event_t cs_event; /* CS event code */ + char *text; +} cs_ss_event_text_t; + +/* + * Flags for cs_read_event_status + */ +#define CS_RES_IGNORE_NO_CARD 0x0001 /* don't check for card */ + +/* + * cs_csfunc2text_strings_t structure used internally in Error2Text + */ +typedef struct cs_csfunc2text_strings_t { + uint32_t item; + char *text; +} cs_csfunc2text_strings_t; + +/* + * Flags for Error2Text - not used by clients; the struct is defined + * in the cs.h header file. + */ +#define CSFUN2TEXT_FUNCTION 0x0001 /* return text of CS function code */ +#define CSFUN2TEXT_RETURN 0x0002 /* return text of CS return code */ + +/* + * Macros to walk the local linked CIS list. + * + * These macros can take any valid local list tuple pointer. They return + * another tuple pointer or NULL if they fail. + */ +#define GET_NEXT_TUPLE(tp, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ + NULL, GET_NEXT_LTUPLEF | \ + (f & ~CIS_GET_LTUPLE_OPMASK)) +#define GET_PREV_TUPLE(tp, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ + NULL, GET_PREV_LTUPLEF | \ + (f & ~CIS_GET_LTUPLE_OPMASK)) +#define GET_FIRST_LTUPLE(tp, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ + NULL, GET_FIRST_LTUPLEF | \ + (f & ~CIS_GET_LTUPLE_OPMASK)) +#define GET_LAST_LTUPLE(tp, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ + NULL, GET_LAST_LTUPLEF | \ + (f & ~CIS_GET_LTUPLE_OPMASK)) +#define FIND_LTUPLE_FWD(tp, tu, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ + tu, FIND_LTUPLE_FWDF | \ + (f & ~CIS_GET_LTUPLE_OPMASK)) +#define FIND_LTUPLE_BACK(tp, tu, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ + tu, FIND_LTUPLE_BACKF | \ + (f & ~CIS_GET_LTUPLE_OPMASK)) +#define FIND_NEXT_LTUPLE(tp, tu, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ + tu, FIND_NEXT_LTUPLEF | \ + (f & ~CIS_GET_LTUPLE_OPMASK)) +#define FIND_PREV_LTUPLE(tp, tu, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ + tu, FIND_PREV_LTUPLEF | \ + (f & ~CIS_GET_LTUPLE_OPMASK)) +#define FIND_FIRST_LTUPLE(tp, tu, f) FIND_LTUPLE_FWD(GET_FIRST_LTUPLE(tp, \ + f), tu, f) + + +/* + * Card Services hooks and general nexus prototypes + */ +int cs_init(void); +uint32_t cs_event(event_t, uint32_t, uint32_t); +int pcmcia_set_em_handler(int (*handler)(), caddr_t events, + int elen, uint32_t id, void **cs, void **ss); + +extern csfunction_t *cs_socket_services; + + +#ifdef __cplusplus +} +#endif + +#endif /* _CS_PRIV_H */ diff --git a/illumos-x86_64/usr/include/sys/cs_strings.h b/illumos-x86_64/usr/include/sys/cs_strings.h new file mode 100644 index 00000000..8fd36398 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cs_strings.h @@ -0,0 +1,199 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995-1996 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _CS_STRINGS_H +#define _CS_STRINGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These values depend on the size of the cs_ss_event_text_t array + * and on the number of CS events that we want the client to + * be able to display. + * XXX - this should be determined automatically + */ +#define MAX_SS_EVENTS 9 /* maximum SS events */ +#define MAX_CS_EVENTS 28 /* maximum CS events */ + +/* + * The cs_ss_event_text_t structure is used to support the Event2Text + * and cs_event2text function. MAX_SS_EVENTS and MAX_CS_EVENTS + * are defined in the cs_priv.h header file. If the size of this + * array or strctures changes, the MAX_CS_EVENT_BUFSIZE define + * which is in cs.h might need to be changed as well. + */ +cs_ss_event_text_t cs_ss_event_text[MAX_CS_EVENTS+1] = { + { PCE_CARD_REMOVAL, CS_EVENT_CARD_REMOVAL, "CARD_REMOVAL" }, + { PCE_CARD_INSERT, CS_EVENT_CARD_INSERTION, "CARD_INSERTION" }, + { PCE_CARD_READY, CS_EVENT_CARD_READY, "CARD_READY" }, + { PCE_CARD_BATTERY_WARN, CS_EVENT_BATTERY_LOW, "BATTERY_WARN" }, + { PCE_CARD_BATTERY_DEAD, CS_EVENT_BATTERY_DEAD, "BATTERY_DEAD" }, + { PCE_CARD_STATUS_CHANGE, 0, "STATUS_CHANGE" }, + { PCE_CARD_WRITE_PROTECT, CS_EVENT_WRITE_PROTECT, "WRITE_PROTECT" }, + { PCE_PM_RESUME, CS_EVENT_PM_RESUME, "PM_RESUME" }, + { PCE_PM_SUSPEND, CS_EVENT_PM_SUSPEND, "PM_SUSPEND" }, + { 0, CS_EVENT_REGISTRATION_COMPLETE, "REGISTRATION_COMPLETE" }, + { 0, CS_EVENT_CARD_LOCK, "CARD_LOCK" }, + { 0, CS_EVENT_CARD_RESET, "CARD_RESET" }, + { 0, CS_EVENT_CARD_UNLOCK, "CARD_UNLOCK" }, + { 0, CS_EVENT_EJECTION_COMPLETE, "EJECTION_COMPLETE" }, + { 0, CS_EVENT_EJECTION_REQUEST, "EJECTION_REQUEST" }, + { 0, CS_EVENT_ERASE_COMPLETE, "ERASE_COMPLETE" }, + { 0, CS_EVENT_EXCLUSIVE_COMPLETE, "EXCLUSIVE_COMPLETE" }, + { 0, CS_EVENT_EXCLUSIVE_REQUEST, "EXCLUSIVE_REQUEST" }, + { 0, CS_EVENT_INSERTION_COMPLETE, "INSERTION_COMPLETE" }, + { 0, CS_EVENT_INSERTION_REQUEST, "INSERTION_REQUEST" }, + { 0, CS_EVENT_RESET_COMPLETE, "RESET_COMPLETE" }, + { 0, CS_EVENT_RESET_PHYSICAL, "RESET_PHYSICAL" }, + { 0, CS_EVENT_RESET_REQUEST, "RESET_REQUEST" }, + { 0, CS_EVENT_MTD_REQUEST, "MTD_REQUEST" }, + { 0, CS_EVENT_CLIENT_INFO, "CLIENT_INFO" }, + { 0, CS_EVENT_TIMER_EXPIRED, "TIMER_EXPIRED" }, + { 0, CS_EVENT_SS_UPDATED, "SS_UPDATED" }, + { 0, CS_EVENT_CARD_REMOVAL_LOWP, "CARD_REMOVAL_LOWP" }, + { MAX_SS_EVENTS, 0, "{undefined}" }, +}; + +cs_csfunc2text_strings_t cs_csfunc2text_funcstrings[] = { + { CISRegister, "CISRegister" }, + { CISUnregister, "CISUnregister" }, + { InitCISWindow, "InitCISWindow" }, + { GetCardServicesInfo, "GetCardServicesInfo" }, + { RegisterClient, "RegisterClient" }, + { DeregisterClient, "DeregisterClient" }, + { GetStatus, "GetStatus" }, + { ResetFunction, "ResetFunction" }, + { SetEventMask, "SetEventMask" }, + { GetEventMask, "GetEventMask" }, + { RequestIO, "RequestIO" }, + { ReleaseIO, "ReleaseIO" }, + { RequestIRQ, "RequestIRQ" }, + { ReleaseIRQ, "ReleaseIRQ" }, + { RequestWindow, "RequestWindow" }, + { ReleaseWindow, "ReleaseWindow" }, + { ModifyWindow, "ModifyWindow" }, + { MapMemPage, "MapMemPage" }, + { RequestSocketMask, "RequestSocketMask" }, + { ReleaseSocketMask, "ReleaseSocketMask" }, + { RequestConfiguration, "RequestConfiguration" }, + { GetConfigurationInfo, "GetConfigurationInfo" }, + { ModifyConfiguration, "ModifyConfiguration" }, + { ReleaseConfiguration, "ReleaseConfiguration" }, + { OpenMemory, "OpenMemory" }, + { ReadMemory, "ReadMemory" }, + { WriteMemory, "WriteMemory" }, + { CopyMemory, "CopyMemory" }, + { RegisterEraseQueue, "RegisterEraseQueue" }, + { CheckEraseQueue, "CheckEraseQueue" }, + { DeregisterEraseQueue, "DeregisterEraseQueue" }, + { CloseMemory, "CloseMemory" }, + { GetFirstRegion, "GetFirstRegion" }, + { GetNextRegion, "GetNextRegion" }, + { GetFirstPartition, "GetFirstPartition" }, + { GetNextPartition, "GetNextPartition" }, + { ReturnSSEntry, "ReturnSSEntry" }, + { MapLogSocket, "MapLogSocket" }, + { MapPhySocket, "MapPhySocket" }, + { MapLogWindow, "MapLogWindow" }, + { MapPhyWindow, "MapPhyWindow" }, + { RegisterMTD, "RegisterMTD" }, + { RegisterTimer, "RegisterTimer" }, + { SetRegion, "SetRegion" }, + { RequestExclusive, "RequestExclusive" }, + { ReleaseExclusive, "ReleaseExclusive" }, + { GetFirstClient, "GetFirstClient" }, + { GetNextClient, "GetNextClient" }, + { GetClientInfo, "GetClientInfo" }, + { AddSocketServices, "AddSocketServices" }, + { ReplaceSocketServices, "ReplaceSocketServices" }, + { VendorSpecific, "VendorSpecific" }, + { AdjustResourceInfo, "AdjustResourceInfo" }, + { ValidateCIS, "ValidateCIS" }, + { GetFirstTuple, "GetFirstTuple" }, + { GetNextTuple, "GetNextTuple" }, + { GetTupleData, "GetTupleData" }, + { ParseTuple, "ParseTuple" }, + { MakeDeviceNode, "MakeDeviceNode" }, + { RemoveDeviceNode, "RemoveDeviceNode" }, + { ConvertSpeed, "ConvertSpeed" }, + { ConvertSize, "ConvertSize" }, + { Event2Text, "Event2Text" }, + { Error2Text, "Error2Text" }, + { AccessConfigurationRegister, "AccessConfigurationRegister" }, + { CS_DDI_Info, "CS_DDI_Info" }, + { CS_Sys_Ctl, "CS_Sys_Ctl" }, + { CSFuncListEnd, "{unknown Card Services function}" }, +}; + +cs_csfunc2text_strings_t cs_csfunc2text_returnstrings[] = { + { CS_SUCCESS, "CS_SUCCESS" }, + { CS_BAD_ADAPTER, "CS_BAD_ADAPTER" }, + { CS_BAD_ATTRIBUTE, "CS_BAD_ATTRIBUTE" }, + { CS_BAD_BASE, "CS_BAD_BASE" }, + { CS_BAD_EDC, "CS_BAD_EDC" }, + { CS_BAD_IRQ, "CS_BAD_IRQ" }, + { CS_BAD_OFFSET, "CS_BAD_OFFSET" }, + { CS_BAD_PAGE, "CS_BAD_PAGE" }, + { CS_READ_FAILURE, "CS_READ_FAILURE" }, + { CS_BAD_SIZE, "CS_BAD_SIZE" }, + { CS_BAD_SOCKET, "CS_BAD_SOCKET" }, + { CS_BAD_TYPE, "CS_BAD_TYPE" }, + { CS_BAD_VCC, "CS_BAD_VCC" }, + { CS_BAD_VPP, "CS_BAD_VPP" }, + { CS_BAD_WINDOW, "CS_BAD_WINDOW" }, + { CS_WRITE_FAILURE, "CS_WRITE_FAILURE" }, + { CS_NO_CARD, "CS_NO_CARD" }, + { CS_UNSUPPORTED_FUNCTION, "CS_UNSUPPORTED_FUNCTION" }, + { CS_UNSUPPORTED_MODE, "CS_UNSUPPORTED_MODE" }, + { CS_BAD_SPEED, "CS_BAD_SPEED" }, + { CS_BUSY, "CS_BUSY" }, + { CS_GENERAL_FAILURE, "CS_GENERAL_FAILURE" }, + { CS_WRITE_PROTECTED, "CS_WRITE_PROTECTED" }, + { CS_BAD_ARG_LENGTH, "CS_BAD_ARG_LENGTH" }, + { CS_BAD_ARGS, "CS_BAD_ARGS" }, + { CS_CONFIGURATION_LOCKED, "CS_CONFIGURATION_LOCKED" }, + { CS_IN_USE, "CS_IN_USE" }, + { CS_NO_MORE_ITEMS, "CS_NO_MORE_ITEMS" }, + { CS_OUT_OF_RESOURCE, "CS_OUT_OF_RESOURCE" }, + { CS_BAD_HANDLE, "CS_BAD_HANDLE" }, + { CS_NO_CIS, "CS_NO_CIS" }, + { CS_BAD_CIS, "CS_BAD_CIS" }, + { CS_UNKNOWN_TUPLE, "CS_UNKNOWN_TUPLE" }, + { CS_BAD_VERSION, "CS_BAD_VERSION" }, + { CS_UNSUPPORTED_EVENT, "CS_UNSUPPORTED_EVENT" }, + { CS_CSI_ERROR, "CS_CSI_ERROR" }, + { CS_CSI_NOT_INIT, "CS_CSI_NOT_INIT" }, + { CS_NO_TUPLE_PARSER, "CS_NO_TUPLE_PARSER" }, + { CS_ERRORLIST_END, "{unknown Card Services return code}" }, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _CS_STRINGS_H */ diff --git a/illumos-x86_64/usr/include/sys/cs_stubs.h b/illumos-x86_64/usr/include/sys/cs_stubs.h new file mode 100644 index 00000000..289f8763 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cs_stubs.h @@ -0,0 +1,164 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _CS_STUBS_H +#define _CS_STUBS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Magic number for Card Services to use when registering it's entry + * point with the Card Services stubs module. + */ +#define CS_STUBS_MAGIC 0x19960300 + +/* + * Card Services function identifiers - these correspond to the PCMCIA + * standard function codes for CS with the exception of a few + * private and implementation-specific function identifiers. + * + * client services functions + */ +#define GetCardServicesInfo 0x000b +#define RegisterClient 0x0010 +#define DeregisterClient 0x0002 +#define GetStatus 0x000c +#define ResetFunction 0x0011 +#define SetEventMask 0x0031 +#define GetEventMask 0x002e +/* + * reource management functions + */ +#define RequestIO 0x001f +#define ReleaseIO 0x001b +#define RequestIRQ 0x0020 +#define ReleaseIRQ 0x001c +#define RequestWindow 0x0021 +#define ReleaseWindow 0x001d +#define ModifyWindow 0x0017 +#define MapMemPage 0x0014 +#define RequestSocketMask 0x0022 +#define ReleaseSocketMask 0x002f +#define RequestConfiguration 0x0030 +#define GetConfigurationInfo 0x0004 +#define ModifyConfiguration 0x0027 +#define ReleaseConfiguration 0x001e +#define AccessConfigurationRegister 0x0036 +/* + * bulk memory service functions + */ +#define OpenMemory 0x0018 +#define ReadMemory 0x0019 +#define WriteMemory 0x0024 +#define CopyMemory 0x0001 +#define RegisterEraseQueue 0x000f +#define CheckEraseQueue 0x0026 +#define DeregisterEraseQueue 0x0025 +#define CloseMemory 0x0000 +/* + * client utility functions + */ +#define GetFirstTuple 0x0007 +#define GetNextTuple 0x000a +#define GetTupleData 0x000d +#define GetFirstRegion 0x0006 +#define GetNextRegion 0x0009 +#define GetFirstPartition 0x0005 +#define GetNextPartition 0x0008 +/* + * advanced client services functions + */ +#define ReturnSSEntry 0x0023 +#define MapLogSocket 0x0012 +#define MapPhySocket 0x0015 +#define MapLogWindow 0x0013 +#define MapPhyWindow 0x0016 +#define RegisterMTD 0x001a +#define RegisterTimer 0x0028 +#define SetRegion 0x0029 +#define ValidateCIS 0x002b +#define RequestExclusive 0x002c +#define ReleaseExclusive 0x002d +#define GetFirstClient 0x000e +#define GetNextClient 0x002a +#define GetClientInfo 0x0003 +#define AddSocketServices 0x0032 +#define ReplaceSocketServices 0x0033 +#define VendorSpecific 0x0034 +#define AdjustResourceInfo 0x0035 +/* + * private functions - clients should never call these; if they do, + * the system will esplode. + */ +#define CISRegister 0x1000 +#define CISUnregister 0x1001 +#define InitCISWindow 0x1002 +/* + * Card Services functions specific to this implementation + */ +#define ParseTuple 0x2000 /* parses contents of tuples */ +#define MakeDeviceNode 0x2001 /* makes device nodes in fs */ +#define ConvertSpeed 0x2002 /* converts device speeds */ +#define ConvertSize 0x2003 /* converts device sizes */ +#define Event2Text 0x2004 /* return string of event type */ +#define Error2Text 0x2005 /* function or ret code string */ +#define CS_DDI_Info 0x2006 /* set/get DDI info */ +#define CS_Sys_Ctl 0x2007 /* CS system control */ +#define RemoveDeviceNode 0x2008 /* removes device nodes in fs */ +#define GetPhysicalAdapterInfo 0x2009 /* returns physical adapter info */ +#define CSFuncListEnd 0x8000 /* end of CS function list */ + +/* + * Structure used when Card Services registers it's entry point with + * the Card Services stubs module + */ +typedef struct cs_register_cardservices_t { + uint32_t function; + uint32_t magic; + csfunction_t *cardservices; + csfunction_t *socketservices; +} cs_register_cardservices_t; + +/* + * Functions for cs_register_cardservices_t + */ +#define CS_ENTRY_REGISTER 0x0001 +#define CS_ENTRY_DEREGISTER 0x0002 +#define CS_ENTRY_INQUIRE 0x0003 + +/* + * Function prototypes + */ +int32_t csx_register_cardservices(cs_register_cardservices_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _CS_STUBS_H */ diff --git a/illumos-x86_64/usr/include/sys/cs_types.h b/illumos-x86_64/usr/include/sys/cs_types.h new file mode 100644 index 00000000..58cddccf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cs_types.h @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995-1996 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _CS_TYPES_H +#define _CS_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * PCMCIA Card Services types header file + */ + +typedef uint32_t client_handle_t; +typedef uint32_t window_handle_t; +typedef uint32_t event_t; +typedef uint8_t cfg_regs_t; + +typedef struct baseaddru_t { + uint32_t base; + ddi_acc_handle_t handle; +} baseaddru_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _CS_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/csiioctl.h b/illumos-x86_64/usr/include/sys/csiioctl.h new file mode 100644 index 00000000..6a6debfa --- /dev/null +++ b/illumos-x86_64/usr/include/sys/csiioctl.h @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_CSIIOCTL_H +#define _SYS_CSIIOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * csiioctl.h + * + * CodeSet Independent codeset width communication between stty(1) and + * ldterm(4M). + * + * CSDATA_SET This call takes a pointer to a ldterm_cs_data_t data + * structure, and uses it to set the line discipline definition + * and also for a possible switch of the internal methods and + * data for the current locale's codeset. + * + * When this message is reached, the ldterm(4M) will check + * the validity of the message and if the message contains + * a valid data, it will accumulate the data and switch + * the internal methods if necessary to support the requested + * codeset. + * + * CSDATA_GET This call takes a pointer to a ldterm_cs_data_t structure + * and returns in it the codeset data info currently in use by + * the ldterm(4M) module. + */ + +#define CSI_IOC (('C' | 128) << 8) +#define CSDATA_SET (CSI_IOC | 1) +#define CSDATA_GET (CSI_IOC | 2) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CSIIOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/ctf.h b/illumos-x86_64/usr/include/sys/ctf.h new file mode 100644 index 00000000..2e41cf9a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ctf.h @@ -0,0 +1,360 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _CTF_H +#define _CTF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * CTF - Compact ANSI-C Type Format + * + * This file format can be used to compactly represent the information needed + * by a debugger to interpret the ANSI-C types used by a given program. + * Traditionally, this kind of information is generated by the compiler when + * invoked with the -g flag and is stored in "stabs" strings or in the more + * modern DWARF format. CTF provides a representation of only the information + * that is relevant to debugging a complex, optimized C program such as the + * operating system kernel in a form that is significantly more compact than + * the equivalent stabs or DWARF representation. The format is data-model + * independent, so consumers do not need different code depending on whether + * they are 32-bit or 64-bit programs. CTF assumes that a standard ELF symbol + * table is available for use in the debugger, and uses the structure and data + * of the symbol table to avoid storing redundant information. The CTF data + * may be compressed on disk or in memory, indicated by a bit in the header. + * CTF may be interpreted in a raw disk file, or it may be stored in an ELF + * section, typically named .SUNW_ctf. Data structures are aligned so that + * a raw CTF file or CTF ELF section may be manipulated using mmap(2). + * + * The CTF file or section itself has the following structure: + * + * +--------+--------+---------+----------+-------+--------+ + * | file | type | data | function | data | string | + * | header | labels | objects | info | types | table | + * +--------+--------+---------+----------+-------+--------+ + * + * The file header stores a magic number and version information, encoding + * flags, and the byte offset of each of the sections relative to the end of the + * header itself. If the CTF data has been uniquified against another set of + * CTF data, a reference to that data also appears in the the header. This + * reference is the name of the label corresponding to the types uniquified + * against. + * + * Following the header is a list of labels, used to group the types included in + * the data types section. Each label is accompanied by a type ID i. A given + * label refers to the group of types whose IDs are in the range [0, i]. + * + * Data object and function records are stored in the same order as they appear + * in the corresponding symbol table, except that symbols marked SHN_UNDEF are + * not stored and symbols that have no type data are padded out with zeroes. + * For each data object, the type ID (a small integer) is recorded. For each + * function, the type ID of the return type and argument types is recorded. + * + * The data types section is a list of variable size records that represent each + * type, in order by their ID. The types themselves form a directed graph, + * where each node may contain one or more outgoing edges to other type nodes, + * denoted by their ID. + * + * Strings are recorded as a string table ID (0 or 1) and a byte offset into the + * string table. String table 0 is the internal CTF string table. String table + * 1 is the external string table, which is the string table associated with the + * ELF symbol table for this object. CTF does not record any strings that are + * already in the symbol table, and the CTF string table does not contain any + * duplicated strings. + * + * If the CTF data has been merged with another parent CTF object, some outgoing + * edges may refer to type nodes that exist in another CTF object. The debugger + * and libctf library are responsible for connecting the appropriate objects + * together so that the full set of types can be explored and manipulated. + */ + +#define CTF_MAX_TYPE 0xffff /* max type identifier value */ +#define CTF_MAX_NAME 0x7fffffff /* max offset into a string table */ +#define CTF_MAX_VLEN 0x3ff /* max struct, union, enum members or args */ +#define CTF_MAX_INTOFF 0xff /* max offset of intrinsic value in bits */ +#define CTF_MAX_INTBITS 0xffff /* max size of an intrinsic in bits */ + +/* See ctf_type_t */ +#define CTF_MAX_SIZE 0xfffe /* max size of a type in bytes */ +#define CTF_LSIZE_SENT 0xffff /* sentinel for ctt_size */ +#define CTF_MAX_LSIZE UINT64_MAX + +typedef struct ctf_preamble { + ushort_t ctp_magic; /* magic number (CTF_MAGIC) */ + uchar_t ctp_version; /* data format version number (CTF_VERSION) */ + uchar_t ctp_flags; /* flags (see below) */ +} ctf_preamble_t; + +typedef struct ctf_header { + ctf_preamble_t cth_preamble; + uint_t cth_parlabel; /* ref to name of parent lbl uniq'd against */ + uint_t cth_parname; /* ref to basename of parent */ + uint_t cth_lbloff; /* offset of label section */ + uint_t cth_objtoff; /* offset of object section */ + uint_t cth_funcoff; /* offset of function section */ + uint_t cth_typeoff; /* offset of type section */ + uint_t cth_stroff; /* offset of string section */ + uint_t cth_strlen; /* length of string section in bytes */ +} ctf_header_t; + +#define cth_magic cth_preamble.ctp_magic +#define cth_version cth_preamble.ctp_version +#define cth_flags cth_preamble.ctp_flags + +#ifdef CTF_OLD_VERSIONS + +typedef struct ctf_header_v1 { + ctf_preamble_t cth_preamble; + uint_t cth_objtoff; + uint_t cth_funcoff; + uint_t cth_typeoff; + uint_t cth_stroff; + uint_t cth_strlen; +} ctf_header_v1_t; + +#endif /* CTF_OLD_VERSIONS */ + +#define CTF_MAGIC 0xcff1 /* magic number identifying header */ + +/* data format version number */ +#define CTF_VERSION_1 1 +#define CTF_VERSION_2 2 +#define CTF_VERSION CTF_VERSION_2 /* current version */ + +#define CTF_F_COMPRESS 0x1 /* data buffer is compressed */ + +typedef struct ctf_lblent { + uint_t ctl_label; /* ref to name of label */ + uint_t ctl_typeidx; /* last type associated with this label */ +} ctf_lblent_t; + +typedef struct ctf_stype { + uint_t ctt_name; /* reference to name in string table */ + ushort_t ctt_info; /* encoded kind, variant length (see below) */ + union { + ushort_t _size; /* size of entire type in bytes */ + ushort_t _type; /* reference to another type */ + } _u; +} ctf_stype_t; + +/* + * type sizes, measured in bytes, come in two flavors. 99% of them fit within + * (USHRT_MAX - 1), and thus can be stored in the ctt_size member of a + * ctf_stype_t. The maximum value for these sizes is CTF_MAX_SIZE. The sizes + * larger than CTF_MAX_SIZE must be stored in the ctt_lsize member of a + * ctf_type_t. Use of this member is indicated by the presence of + * CTF_LSIZE_SENT in ctt_size. + */ +typedef struct ctf_type { + uint_t ctt_name; /* reference to name in string table */ + ushort_t ctt_info; /* encoded kind, variant length (see below) */ + union { + ushort_t _size; /* always CTF_LSIZE_SENT */ + ushort_t _type; /* do not use */ + } _u; + uint_t ctt_lsizehi; /* high 32 bits of type size in bytes */ + uint_t ctt_lsizelo; /* low 32 bits of type size in bytes */ +} ctf_type_t; + +#define ctt_size _u._size /* for fundamental types that have a size */ +#define ctt_type _u._type /* for types that reference another type */ + +/* + * The following macros compose and decompose values for ctt_info and + * ctt_name, as well as other structures that contain name references. + * + * ------------------------ + * ctt_info: | kind | isroot | vlen | + * ------------------------ + * 15 11 10 9 0 + * + * kind = CTF_INFO_KIND(c.ctt_info); <-- CTF_K_* value (see below) + * vlen = CTF_INFO_VLEN(c.ctt_info); <-- length of variable data list + * + * stid = CTF_NAME_STID(c.ctt_name); <-- string table id number (0 or 1) + * offset = CTF_NAME_OFFSET(c.ctt_name); <-- string table byte offset + * + * c.ctt_info = CTF_TYPE_INFO(kind, vlen); + * c.ctt_name = CTF_TYPE_NAME(stid, offset); + */ + +#define CTF_INFO_KIND(info) (((info) & 0xf800) >> 11) +#define CTF_INFO_ISROOT(info) (((info) & 0x0400) >> 10) +#define CTF_INFO_VLEN(info) (((info) & CTF_MAX_VLEN)) + +#define CTF_NAME_STID(name) ((name) >> 31) +#define CTF_NAME_OFFSET(name) ((name) & 0x7fffffff) + +#define CTF_TYPE_INFO(kind, isroot, vlen) \ + (((kind) << 11) | (((isroot) ? 1 : 0) << 10) | ((vlen) & CTF_MAX_VLEN)) + +#define CTF_TYPE_NAME(stid, offset) \ + (((stid) << 31) | ((offset) & 0x7fffffff)) + +#define CTF_CHILD_START (0x8000) +#define CTF_TYPE_ISPARENT(id) ((id) < CTF_CHILD_START) +#define CTF_TYPE_ISCHILD(id) ((id) >= CTF_CHILD_START) + +#define CTF_TYPE_TO_INDEX(id) ((id) & (CTF_CHILD_START - 1)) +#define CTF_INDEX_TO_TYPE(id, child) \ + ((child) ? ((id) | CTF_CHILD_START) : (id)) +#define CTF_PARENT_SHIFT 15 + +#define CTF_STRTAB_0 0 /* symbolic define for string table id 0 */ +#define CTF_STRTAB_1 1 /* symbolic define for string table id 1 */ + +#define CTF_TYPE_LSIZE(cttp) \ + (((uint64_t)(cttp)->ctt_lsizehi) << 32 | (cttp)->ctt_lsizelo) +#define CTF_SIZE_TO_LSIZE_HI(size) ((uint32_t)((uint64_t)(size) >> 32)) +#define CTF_SIZE_TO_LSIZE_LO(size) ((uint32_t)(size)) + +#ifdef CTF_OLD_VERSIONS + +#define CTF_INFO_KIND_V1(info) (((info) & 0xf000) >> 12) +#define CTF_INFO_ISROOT_V1(info) (((info) & 0x0800) >> 11) +#define CTF_INFO_VLEN_V1(info) (((info) & 0x07ff)) + +#define CTF_TYPE_INFO_V1(kind, isroot, vlen) \ + (((kind) << 12) | (((isroot) ? 1 : 0) << 11) | ((vlen) & 0x07ff)) + +#endif /* CTF_OLD_VERSIONS */ + +/* + * Values for CTF_TYPE_KIND(). If the kind has an associated data list, + * CTF_INFO_VLEN() will extract the number of elements in the list, and + * the type of each element is shown in the comments below. + */ +#define CTF_K_UNKNOWN 0 /* unknown type (used for padding) */ +#define CTF_K_INTEGER 1 /* variant data is CTF_INT_DATA() (see below) */ +#define CTF_K_FLOAT 2 /* variant data is CTF_FP_DATA() (see below) */ +#define CTF_K_POINTER 3 /* ctt_type is referenced type */ +#define CTF_K_ARRAY 4 /* variant data is single ctf_array_t */ +#define CTF_K_FUNCTION 5 /* ctt_type is return type, variant data is */ + /* list of argument types (ushort_t's) */ +#define CTF_K_STRUCT 6 /* variant data is list of ctf_member_t's */ +#define CTF_K_UNION 7 /* variant data is list of ctf_member_t's */ +#define CTF_K_ENUM 8 /* variant data is list of ctf_enum_t's */ +#define CTF_K_FORWARD 9 /* no additional data; ctt_name is tag */ +#define CTF_K_TYPEDEF 10 /* ctt_type is referenced type */ +#define CTF_K_VOLATILE 11 /* ctt_type is base type */ +#define CTF_K_CONST 12 /* ctt_type is base type */ +#define CTF_K_RESTRICT 13 /* ctt_type is base type */ + +#define CTF_K_MAX 31 /* Maximum possible CTF_K_* value */ + +/* + * Values for ctt_type when kind is CTF_K_INTEGER. The flags, offset in bits, + * and size in bits are encoded as a single word using the following macros. + */ +#define CTF_INT_ENCODING(data) (((data) & 0xff000000) >> 24) +#define CTF_INT_OFFSET(data) (((data) & 0x00ff0000) >> 16) +#define CTF_INT_BITS(data) (((data) & 0x0000ffff)) + +#define CTF_INT_DATA(encoding, offset, bits) \ + (((encoding) << 24) | ((offset) << 16) | (bits)) + +#define CTF_INT_SIGNED 0x01 /* integer is signed (otherwise unsigned) */ +#define CTF_INT_CHAR 0x02 /* character display format */ +#define CTF_INT_BOOL 0x04 /* boolean display format */ +#define CTF_INT_VARARGS 0x08 /* varargs display format */ + +/* + * Values for ctt_type when kind is CTF_K_FLOAT. The encoding, offset in bits, + * and size in bits are encoded as a single word using the following macros. + */ +#define CTF_FP_ENCODING(data) (((data) & 0xff000000) >> 24) +#define CTF_FP_OFFSET(data) (((data) & 0x00ff0000) >> 16) +#define CTF_FP_BITS(data) (((data) & 0x0000ffff)) + +#define CTF_FP_DATA(encoding, offset, bits) \ + (((encoding) << 24) | ((offset) << 16) | (bits)) + +#define CTF_FP_SINGLE 1 /* IEEE 32-bit float encoding */ +#define CTF_FP_DOUBLE 2 /* IEEE 64-bit float encoding */ +#define CTF_FP_CPLX 3 /* Complex encoding */ +#define CTF_FP_DCPLX 4 /* Double complex encoding */ +#define CTF_FP_LDCPLX 5 /* Long double complex encoding */ +#define CTF_FP_LDOUBLE 6 /* Long double encoding */ +#define CTF_FP_INTRVL 7 /* Interval (2x32-bit) encoding */ +#define CTF_FP_DINTRVL 8 /* Double interval (2x64-bit) encoding */ +#define CTF_FP_LDINTRVL 9 /* Long double interval (2x128-bit) encoding */ +#define CTF_FP_IMAGRY 10 /* Imaginary (32-bit) encoding */ +#define CTF_FP_DIMAGRY 11 /* Long imaginary (64-bit) encoding */ +#define CTF_FP_LDIMAGRY 12 /* Long double imaginary (128-bit) encoding */ + +#define CTF_FP_MAX 12 /* Maximum possible CTF_FP_* value */ + +typedef struct ctf_array { + ushort_t cta_contents; /* reference to type of array contents */ + ushort_t cta_index; /* reference to type of array index */ + uint_t cta_nelems; /* number of elements */ +} ctf_array_t; + +/* + * Most structure members have bit offsets that can be expressed using a + * short. Some don't. ctf_member_t is used for structs which cannot + * contain any of these large offsets, whereas ctf_lmember_t is used in the + * latter case. If ctt_size for a given struct is >= 8192 bytes, all members + * will be stored as type ctf_lmember_t. + */ + +#define CTF_LSTRUCT_THRESH 8192 + +typedef struct ctf_member { + uint_t ctm_name; /* reference to name in string table */ + ushort_t ctm_type; /* reference to type of member */ + ushort_t ctm_offset; /* offset of this member in bits */ +} ctf_member_t; + +typedef struct ctf_lmember { + uint_t ctlm_name; /* reference to name in string table */ + ushort_t ctlm_type; /* reference to type of member */ + ushort_t ctlm_pad; /* padding */ + uint_t ctlm_offsethi; /* high 32 bits of member offset in bits */ + uint_t ctlm_offsetlo; /* low 32 bits of member offset in bits */ +} ctf_lmember_t; + +#define CTF_LMEM_OFFSET(ctlmp) \ + (((uint64_t)(ctlmp)->ctlm_offsethi) << 32 | (ctlmp)->ctlm_offsetlo) +#define CTF_OFFSET_TO_LMEMHI(offset) ((uint32_t)((uint64_t)(offset) >> 32)) +#define CTF_OFFSET_TO_LMEMLO(offset) ((uint32_t)(offset)) + +typedef struct ctf_enum { + uint_t cte_name; /* reference to name in string table */ + int cte_value; /* value associated with this name */ +} ctf_enum_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _CTF_H */ diff --git a/illumos-x86_64/usr/include/sys/ctf_api.h b/illumos-x86_64/usr/include/sys/ctf_api.h new file mode 100644 index 00000000..a04b4032 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ctf_api.h @@ -0,0 +1,335 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2020 Joyent, Inc. + */ + +/* + * This header file defines the interfaces available from the CTF debugger + * library, libctf, and an equivalent kernel module. This API can be used by + * a debugger to operate on data in the Compact ANSI-C Type Format (CTF). + * This is NOT a public interface, although it may eventually become one in + * the fullness of time after we gain more experience with the interfaces. + * + * In the meantime, be aware that any program linked with this API in this + * release of Solaris is almost guaranteed to break in the next release. + * + * In short, do not user this header file or the CTF routines for any purpose. + */ + +#ifndef _CTF_API_H +#define _CTF_API_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Clients can open one or more CTF containers and obtain a pointer to an + * opaque ctf_file_t. Types are identified by an opaque ctf_id_t token. + * These opaque definitions allow libctf to evolve without breaking clients. + */ +typedef struct ctf_file ctf_file_t; +typedef long ctf_id_t; + +#define ECTF_BASE 1000 /* base value for libctf errnos */ + +enum { + ECTF_FMT = ECTF_BASE, /* file is not in CTF or ELF format */ + ECTF_ELFVERS, /* ELF version is more recent than libctf */ + ECTF_CTFVERS, /* CTF version is more recent than libctf */ + ECTF_ENDIAN, /* data is different endian-ness than lib */ + ECTF_SYMTAB, /* symbol table uses invalid entry size */ + ECTF_SYMBAD, /* symbol table data buffer invalid */ + ECTF_STRBAD, /* string table data buffer invalid */ + ECTF_CORRUPT, /* file data corruption detected */ + ECTF_NOCTFDATA, /* ELF file does not contain CTF data */ + ECTF_NOCTFBUF, /* buffer does not contain CTF data */ + ECTF_NOSYMTAB, /* symbol table data is not available */ + ECTF_NOPARENT, /* parent CTF container is not available */ + ECTF_DMODEL, /* data model mismatch */ + ECTF_MMAP, /* failed to mmap a data section */ + ECTF_ZMISSING, /* decompression library not installed */ + ECTF_ZINIT, /* failed to initialize decompression library */ + ECTF_ZALLOC, /* failed to allocate decompression buffer */ + ECTF_DECOMPRESS, /* failed to decompress CTF data */ + ECTF_STRTAB, /* string table for this string is missing */ + ECTF_BADNAME, /* string offset is corrupt w.r.t. strtab */ + ECTF_BADID, /* invalid type ID number */ + ECTF_NOTSOU, /* type is not a struct or union */ + ECTF_NOTENUM, /* type is not an enum */ + ECTF_NOTSUE, /* type is not a struct, union, or enum */ + ECTF_NOTINTFP, /* type is not an integer or float */ + ECTF_NOTARRAY, /* type is not an array */ + ECTF_NOTREF, /* type does not reference another type */ + ECTF_NAMELEN, /* buffer is too small to hold type name */ + ECTF_NOTYPE, /* no type found corresponding to name */ + ECTF_SYNTAX, /* syntax error in type name */ + ECTF_NOTFUNC, /* symtab entry does not refer to a function */ + ECTF_NOFUNCDAT, /* no func info available for function */ + ECTF_NOTDATA, /* symtab entry does not refer to a data obj */ + ECTF_NOTYPEDAT, /* no type info available for object */ + ECTF_NOLABEL, /* no label found corresponding to name */ + ECTF_NOLABELDATA, /* file does not contain any labels */ + ECTF_NOTSUP, /* feature not supported */ + ECTF_NOENUMNAM, /* enum element name not found */ + ECTF_NOMEMBNAM, /* member name not found */ + ECTF_RDONLY, /* CTF container is read-only */ + ECTF_DTFULL, /* CTF type is full (no more members allowed) */ + ECTF_FULL, /* CTF container is full */ + ECTF_DUPMEMBER, /* duplicate member name definition */ + ECTF_CONFLICT, /* conflicting type definition present */ + ECTF_REFERENCED, /* type has outstanding references */ + ECTF_NOTDYN, /* type is not a dynamic type */ + ECTF_ELF, /* elf library failure */ + ECTF_MCHILD, /* cannot merge child container */ + ECTF_LABELEXISTS, /* label already exists */ + ECTF_LCONFLICT, /* merged labels conflict */ + ECTF_ZLIB, /* zlib library failure */ + ECTF_CONVBKERR, /* CTF conversion backend error */ + ECTF_CONVNOCSRC, /* No C source to convert from */ + ECTF_CONVNODEBUG /* No debug info to convert into CTF */ +}; + +/* + * If the debugger needs to provide the CTF library with a set of raw buffers + * for use as the CTF data, symbol table, and string table, it can do so by + * filling in ctf_sect_t structures and passing them to ctf_bufopen(): + */ +typedef struct ctf_sect { + const char *cts_name; /* section name (if any) */ + ulong_t cts_type; /* section type (ELF SHT_... value) */ + ulong_t cts_flags; /* section flags (ELF SHF_... value) */ + const void *cts_data; /* pointer to section data */ + size_t cts_size; /* size of data in bytes */ + size_t cts_entsize; /* size of each section entry (symtab only) */ + off64_t cts_offset; /* file offset of this section (if any) */ +} ctf_sect_t; + +/* + * Encoding information for integers, floating-point values, and certain other + * intrinsics can be obtained by calling ctf_type_encoding(), below. The flags + * field will contain values appropriate for the type defined in . + */ +typedef struct ctf_encoding { + uint_t cte_format; /* data format (CTF_INT_* or CTF_FP_* flags) */ + uint_t cte_offset; /* offset of value in bits */ + uint_t cte_bits; /* size of storage in bits */ +} ctf_encoding_t; + +typedef struct ctf_membinfo { + ctf_id_t ctm_type; /* type of struct or union member */ + ulong_t ctm_offset; /* offset of member in bits */ +} ctf_membinfo_t; + +typedef struct ctf_arinfo { + ctf_id_t ctr_contents; /* type of array contents */ + ctf_id_t ctr_index; /* type of array index */ + uint_t ctr_nelems; /* number of elements */ +} ctf_arinfo_t; + +typedef struct ctf_funcinfo { + ctf_id_t ctc_return; /* function return type */ + uint_t ctc_argc; /* number of typed arguments to function */ + uint_t ctc_flags; /* function attributes (see below) */ +} ctf_funcinfo_t; + +typedef struct ctf_lblinfo { + ctf_id_t ctb_typeidx; /* last type associated with the label */ +} ctf_lblinfo_t; + +#define CTF_FUNC_VARARG 0x1 /* function arguments end with varargs */ + +/* + * Functions that return integer status or a ctf_id_t use the following value + * to indicate failure. ctf_errno() can be used to obtain an error code. + */ +#define CTF_ERR (-1L) + +/* + * The CTF data model is inferred to be the caller's data model or the data + * model of the given object, unless ctf_setmodel() is explicitly called. + */ +#define CTF_MODEL_ILP32 1 /* object data model is ILP32 */ +#define CTF_MODEL_LP64 2 /* object data model is LP64 */ +#ifdef _LP64 +#define CTF_MODEL_NATIVE CTF_MODEL_LP64 +#else +#define CTF_MODEL_NATIVE CTF_MODEL_ILP32 +#endif + +/* + * Dynamic CTF containers can be created using ctf_create(). The ctf_add_* + * routines can be used to add new definitions to the dynamic container. + * New types are labeled as root or non-root to determine whether they are + * visible at the top-level program scope when subsequently doing a lookup. + */ +#define CTF_ADD_NONROOT 0 /* type only visible in nested scope */ +#define CTF_ADD_ROOT 1 /* type visible at top-level scope */ + +/* + * These typedefs are used to define the signature for callback functions + * that can be used with the iteration and visit functions below: + */ +typedef int ctf_visit_f(const char *, ctf_id_t, ulong_t, int, void *); +typedef int ctf_member_f(const char *, ctf_id_t, ulong_t, void *); +typedef int ctf_enum_f(const char *, int, void *); +typedef int ctf_type_f(ctf_id_t, boolean_t, void *); +typedef int ctf_label_f(const char *, const ctf_lblinfo_t *, void *); +typedef int ctf_function_f(const char *, ulong_t, ctf_funcinfo_t *, void *); +typedef int ctf_object_f(const char *, ctf_id_t, ulong_t, void *); +typedef int ctf_string_f(const char *, void *); + +extern ctf_file_t *ctf_bufopen(const ctf_sect_t *, const ctf_sect_t *, + const ctf_sect_t *, int *); +extern ctf_file_t *ctf_fdopen(int, int *); +extern ctf_file_t *ctf_open(const char *, int *); +extern ctf_file_t *ctf_create(int *); +extern ctf_file_t *ctf_fdcreate(int, int *); +extern ctf_file_t *ctf_dup(ctf_file_t *); +extern void ctf_close(ctf_file_t *); + +extern ctf_file_t *ctf_parent_file(ctf_file_t *); +extern const char *ctf_parent_name(ctf_file_t *); +extern const char *ctf_parent_label(ctf_file_t *); + +extern int ctf_import(ctf_file_t *, ctf_file_t *); +extern int ctf_setmodel(ctf_file_t *, int); +extern int ctf_getmodel(ctf_file_t *); + +extern void ctf_setspecific(ctf_file_t *, void *); +extern void *ctf_getspecific(ctf_file_t *); + +extern int ctf_errno(ctf_file_t *); +extern uint_t ctf_flags(ctf_file_t *); +extern const char *ctf_errmsg(int); +extern int ctf_version(int); + +extern ctf_id_t ctf_max_id(ctf_file_t *); +extern ulong_t ctf_nr_syms(ctf_file_t *); + +extern int ctf_func_info(ctf_file_t *, ulong_t, ctf_funcinfo_t *); +extern int ctf_func_info_by_id(ctf_file_t *, ctf_id_t, ctf_funcinfo_t *); +extern int ctf_func_args(ctf_file_t *, ulong_t, uint_t, ctf_id_t *); +extern int ctf_func_args_by_id(ctf_file_t *, ctf_id_t, uint_t, ctf_id_t *); + +extern ctf_id_t ctf_lookup_by_name(ctf_file_t *, const char *); +extern ctf_id_t ctf_lookup_by_symbol(ctf_file_t *, ulong_t); + +extern char *ctf_symbol_name(ctf_file_t *, ulong_t, char *, size_t); + +extern ctf_id_t ctf_type_resolve(ctf_file_t *, ctf_id_t); +extern ssize_t ctf_type_lname(ctf_file_t *, ctf_id_t, char *, size_t); +extern char *ctf_type_name(ctf_file_t *, ctf_id_t, char *, size_t); +extern char *ctf_type_qname(ctf_file_t *, ctf_id_t, char *, size_t, + const char *); +extern char *ctf_type_cname(ctf_file_t *, ctf_id_t, char *, size_t, + const char *); +extern ssize_t ctf_type_size(ctf_file_t *, ctf_id_t); +extern ssize_t ctf_type_align(ctf_file_t *, ctf_id_t); +extern int ctf_type_kind(ctf_file_t *, ctf_id_t); +extern const char *ctf_kind_name(ctf_file_t *, int); +extern ctf_id_t ctf_type_reference(ctf_file_t *, ctf_id_t); +extern ctf_id_t ctf_type_pointer(ctf_file_t *, ctf_id_t); +extern int ctf_type_encoding(ctf_file_t *, ctf_id_t, ctf_encoding_t *); +extern int ctf_type_visit(ctf_file_t *, ctf_id_t, ctf_visit_f *, void *); +extern int ctf_type_cmp(ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t); +extern int ctf_type_compat(ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t); + +extern int ctf_member_info(ctf_file_t *, ctf_id_t, const char *, + ctf_membinfo_t *); +extern int ctf_array_info(ctf_file_t *, ctf_id_t, ctf_arinfo_t *); + +extern const char *ctf_enum_name(ctf_file_t *, ctf_id_t, int); +extern int ctf_enum_value(ctf_file_t *, ctf_id_t, const char *, int *); + +extern const char *ctf_label_topmost(ctf_file_t *); +extern int ctf_label_info(ctf_file_t *, const char *, ctf_lblinfo_t *); + +extern int ctf_member_iter(ctf_file_t *, ctf_id_t, ctf_member_f *, void *); +extern int ctf_enum_iter(ctf_file_t *, ctf_id_t, ctf_enum_f *, void *); +extern int ctf_type_iter(ctf_file_t *, boolean_t, ctf_type_f *, void *); +extern int ctf_label_iter(ctf_file_t *, ctf_label_f *, void *); +extern int ctf_function_iter(ctf_file_t *, ctf_function_f *, void *); +extern int ctf_object_iter(ctf_file_t *, ctf_object_f *, void *); +extern int ctf_string_iter(ctf_file_t *, ctf_string_f *, void *); + +extern ctf_id_t ctf_add_array(ctf_file_t *, uint_t, const ctf_arinfo_t *); +extern ctf_id_t ctf_add_const(ctf_file_t *, uint_t, const char *, ctf_id_t); +extern ctf_id_t ctf_add_enum(ctf_file_t *, uint_t, const char *, size_t); +extern ctf_id_t ctf_add_float(ctf_file_t *, uint_t, + const char *, const ctf_encoding_t *); +extern ctf_id_t ctf_add_forward(ctf_file_t *, uint_t, const char *, uint_t); +extern ctf_id_t ctf_add_funcptr(ctf_file_t *, uint_t, const ctf_funcinfo_t *, + const ctf_id_t *); +extern ctf_id_t ctf_add_integer(ctf_file_t *, uint_t, + const char *, const ctf_encoding_t *); +extern ctf_id_t ctf_add_pointer(ctf_file_t *, uint_t, const char *, ctf_id_t); +extern ctf_id_t ctf_add_type(ctf_file_t *, ctf_file_t *, ctf_id_t); +extern ctf_id_t ctf_add_typedef(ctf_file_t *, uint_t, const char *, ctf_id_t); +extern ctf_id_t ctf_add_restrict(ctf_file_t *, uint_t, const char *, ctf_id_t); +extern ctf_id_t ctf_add_struct(ctf_file_t *, uint_t, const char *); +extern ctf_id_t ctf_add_union(ctf_file_t *, uint_t, const char *); +extern ctf_id_t ctf_add_volatile(ctf_file_t *, uint_t, const char *, ctf_id_t); + +extern int ctf_add_enumerator(ctf_file_t *, ctf_id_t, const char *, int); +extern int ctf_add_member(ctf_file_t *, ctf_id_t, const char *, ctf_id_t, + ulong_t); + + +extern int ctf_add_function(ctf_file_t *, ulong_t, const ctf_funcinfo_t *, + const ctf_id_t *); +extern int ctf_add_object(ctf_file_t *, ulong_t, ctf_id_t); +extern int ctf_add_label(ctf_file_t *, const char *, ctf_id_t, uint_t); + +extern int ctf_set_array(ctf_file_t *, ctf_id_t, const ctf_arinfo_t *); +extern int ctf_set_root(ctf_file_t *, ctf_id_t, const boolean_t); +extern int ctf_set_size(ctf_file_t *, ctf_id_t, const ulong_t); + +extern int ctf_delete_type(ctf_file_t *, ctf_id_t); + +extern int ctf_update(ctf_file_t *); +extern int ctf_discard(ctf_file_t *); +extern int ctf_write(ctf_file_t *, int); +extern void ctf_dataptr(ctf_file_t *, const void **, size_t *); + +#ifdef _KERNEL + +struct module; +extern ctf_file_t *ctf_modopen(struct module *, int *); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _CTF_API_H */ diff --git a/illumos-x86_64/usr/include/sys/ctfs.h b/illumos-x86_64/usr/include/sys/ctfs.h new file mode 100644 index 00000000..d124c039 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ctfs.h @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CTFS_H +#define _SYS_CTFS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Location of the contract filesystem. + */ +#define CTFS_ROOT "/system/contract" + +/* + * CTFS ioctl constants + */ +#define CTFS_PREFIX ('c' << 24 | 't' << 16) +#define CTFS_IOC(x, y) (CTFS_PREFIX | (x) << 8 | (y)) + +/* + * Control codes for messages written to template files. + */ +#define CTFS_TMPL(x) CTFS_IOC('t', x) +#define CT_TACTIVATE CTFS_TMPL(0) /* Activate template */ +#define CT_TCLEAR CTFS_TMPL(1) /* Clear active template */ +#define CT_TCREATE CTFS_TMPL(2) /* Create contract from template */ +#define CT_TSET CTFS_TMPL(3) /* Set parameter */ +#define CT_TGET CTFS_TMPL(4) /* Get parameter */ + +/* + * Control codes for messages written to ctl files. + */ +#define CTFS_CTL(x) CTFS_IOC('c', x) +#define CT_CABANDON CTFS_CTL(0) /* Abandon contract */ +#define CT_CACK CTFS_CTL(1) /* Ack a message */ +#define CT_CQREQ CTFS_CTL(2) /* Request an additional quantum */ +#define CT_CADOPT CTFS_CTL(3) /* Adopt a contract */ +#define CT_CNEWCT CTFS_CTL(4) /* Define new contract */ +#define CT_CNACK CTFS_CTL(5) /* nack a negotiation */ + +/* + * Control codes for messages written to status files. + */ +#define CTFS_STAT(x) CTFS_IOC('s', x) +#define CT_SSTATUS CTFS_STAT(0) /* Obtain contract status */ + +/* + * Control codes for messages written to event endpoints. + */ +#define CTFS_EVT(x) CTFS_IOC('e', x) +#define CT_ERESET CTFS_EVT(0) /* Reset event queue pointer */ +#define CT_ERECV CTFS_EVT(1) /* Read next event */ +#define CT_ECRECV CTFS_EVT(2) /* Read next critical event */ +#define CT_ENEXT CTFS_EVT(3) /* Skip current event */ +#define CT_ERELIABLE CTFS_EVT(4) /* Request reliable event receipt */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CTFS_H */ diff --git a/illumos-x86_64/usr/include/sys/ctfs_impl.h b/illumos-x86_64/usr/include/sys/ctfs_impl.h new file mode 100644 index 00000000..51d53285 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ctfs_impl.h @@ -0,0 +1,237 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CTFS_IMPL_H +#define _SYS_CTFS_IMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Inode numbers + */ + +/* + * Root inode: + * --------------------------------------------------- + * | 0 | + * --------------------------------------------------- + * 63 0 + */ + +#define CTFS_INO_ROOT 0 + +/* + * Contract-specific file: + * --------------------------------------------------- + * |1| file (62:32) | contract id (31:0) | + * --------------------------------------------------- + * 63 0 + * file = 0 : directory + * file = 1 : "all" directory symlink + * file > 1 : special files ("ctl", "status", etc.) + */ + +#define CTFS_INO_CT_SHIFT 32 +#define CTFS_INO_CT(ctid, file) \ + ((1ULL << 63) | \ + ((unsigned long long)(file) << CTFS_INO_CT_SHIFT) | \ + (ctid)) +#define CTFS_INO_CT_DIR(ctid) CTFS_INO_CT((ctid), 0) +#define CTFS_INO_CT_LINK(ctid) CTFS_INO_CT((ctid), 1) +#define CTFS_INO_CT_FILE(ctid, file) CTFS_INO_CT((ctid), (file) + 2) + +/* + * Type-specific file: + * --------------------------------------------------- + * | 0 | type (31:16) | file (15:0) | + * --------------------------------------------------- + * 63 0 + * type = 0 : invalid + * type > 0 : contract type index + 1 ("all" is #types + 1) + * file = 0 : directory + * file > 0 : special files ("template", "latest", etc.) + */ + +#define CTFS_INO_TYPE_SHIFT 16 +#define CTFS_INO_TYPE(type, file) \ + (((type) + 1) << CTFS_INO_TYPE_SHIFT | (file)) +#define CTFS_INO_TYPE_DIR(type) CTFS_INO_TYPE((type), 0) +#define CTFS_INO_TYPE_FILE(type, file) CTFS_INO_TYPE((type), (file) + 1) + +/* + * Other constants + */ +#define CTFS_NAME_MAX 32 + +/* + * Possible values for ctfs_endpt_flags, below. + */ +#define CTFS_ENDPT_SETUP 0x1 +#define CTFS_ENDPT_NBLOCK 0x2 + +/* + * Common endpoint object. + */ +typedef struct ctfs_endpoint { + kmutex_t ctfs_endpt_lock; + ct_listener_t ctfs_endpt_listener; + uint_t ctfs_endpt_flags; +} ctfs_endpoint_t; + +/* + * root directory data + */ +typedef gfs_dir_t ctfs_rootnode_t; + +/* + * /all directory data + */ +typedef gfs_dir_t ctfs_adirnode_t; + +/* + * /all symlink data + */ +typedef struct ctfs_symnode { + gfs_file_t ctfs_sn_file; /* gfs file */ + contract_t *ctfs_sn_contract; /* target contract */ + char *ctfs_sn_string; /* target path */ + size_t ctfs_sn_size; /* length of target path */ +} ctfs_symnode_t; + +/* + * contract type directory data + */ +typedef gfs_dir_t ctfs_tdirnode_t; + +/* + * contract directory data + */ +typedef struct ctfs_cdirnode { + gfs_dir_t ctfs_cn_dir; /* directory contents */ + contract_t *ctfs_cn_contract; /* contract pointer */ + contract_vnode_t ctfs_cn_linkage; /* contract vnode list node */ +} ctfs_cdirnode_t; + +/* + * template file data + */ +typedef struct ctfs_tmplnode { + gfs_file_t ctfs_tmn_file; /* gfs file */ + ct_template_t *ctfs_tmn_tmpl; /* template pointer */ +} ctfs_tmplnode_t; + +/* + * ctl and status file data + */ +typedef struct ctfs_ctlnode { + gfs_file_t ctfs_ctl_file; /* gfs file */ + contract_t *ctfs_ctl_contract; /* contract pointer */ +} ctfs_ctlnode_t; + +/* + * latest file data + */ +typedef gfs_dir_t ctfs_latenode_t; + +/* + * events file data + */ +typedef struct ctfs_evnode { + gfs_file_t ctfs_ev_file; /* gfs file */ + contract_t *ctfs_ev_contract; /* contract we're watching */ + ctfs_endpoint_t ctfs_ev_listener; /* common endpoint data */ +} ctfs_evnode_t; + +/* + * bundle and pbundle file data + */ +typedef struct ctfs_bunode { + gfs_file_t ctfs_bu_file; /* gfs file */ + ct_equeue_t *ctfs_bu_queue; /* queue we're watching */ + ctfs_endpoint_t ctfs_bu_listener; /* common endpoint data */ +} ctfs_bunode_t; + +/* + * VFS data object + */ +typedef struct ctfs_vfs { + vnode_t *ctvfs_root; /* root vnode pointer */ +} ctfs_vfs_t; + +/* + * vnode creation routines + */ +extern vnode_t *ctfs_create_tdirnode(vnode_t *); +extern vnode_t *ctfs_create_tmplnode(vnode_t *); +extern vnode_t *ctfs_create_latenode(vnode_t *); +extern vnode_t *ctfs_create_pbundle(vnode_t *); +extern vnode_t *ctfs_create_bundle(vnode_t *); +extern vnode_t *ctfs_create_ctlnode(vnode_t *); +extern vnode_t *ctfs_create_statnode(vnode_t *); +extern vnode_t *ctfs_create_evnode(vnode_t *); +extern vnode_t *ctfs_create_adirnode(vnode_t *); +extern vnode_t *ctfs_create_cdirnode(vnode_t *, contract_t *); +extern vnode_t *ctfs_create_symnode(vnode_t *, contract_t *); + +/* + * common ctfs routines + */ +extern void ctfs_common_getattr(vnode_t *, vattr_t *); +extern int ctfs_close(vnode_t *, int, int, offset_t, cred_t *, + caller_context_t *); +extern int ctfs_access_dir(vnode_t *, int, int, cred_t *, + caller_context_t *); +extern int ctfs_access_readonly(vnode_t *, int, int, cred_t *, + caller_context_t *); +extern int ctfs_access_readwrite(vnode_t *, int, int, cred_t *, + caller_context_t *); +extern int ctfs_open(vnode_t **, int, cred_t *, + caller_context_t *); + +/* + * vnode ops vector templates + */ +extern vnodeops_t *ctfs_ops_root; +extern vnodeops_t *ctfs_ops_adir; +extern vnodeops_t *ctfs_ops_sym; +extern vnodeops_t *ctfs_ops_tdir; +extern vnodeops_t *ctfs_ops_tmpl; +extern vnodeops_t *ctfs_ops_cdir; +extern vnodeops_t *ctfs_ops_ctl; +extern vnodeops_t *ctfs_ops_stat; +extern vnodeops_t *ctfs_ops_event; +extern vnodeops_t *ctfs_ops_bundle; +extern vnodeops_t *ctfs_ops_latest; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CTFS_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/ctype.h b/illumos-x86_64/usr/include/sys/ctype.h new file mode 100644 index 00000000..51ea781c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ctype.h @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2015 PALO, Richard. All rights reserved. + */ + +#ifndef _SYS_CTYPE_H +#define _SYS_CTYPE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define ISDIGIT(_c) \ + ((_c) >= '0' && (_c) <= '9') + +#define ISXDIGIT(_c) \ + (ISDIGIT(_c) || \ + ((_c) >= 'a' && (_c) <= 'f') || \ + ((_c) >= 'A' && (_c) <= 'F')) + +#define ISLOWER(_c) \ + ((_c) >= 'a' && (_c) <= 'z') + +#define ISUPPER(_c) \ + ((_c) >= 'A' && (_c) <= 'Z') + +#define ISALPHA(_c) \ + (ISUPPER(_c) || \ + ISLOWER(_c)) + +#define ISALNUM(_c) \ + (ISALPHA(_c) || \ + ISDIGIT(_c)) + +#define ISPRINT(_c) \ + ((_c) >= ' ' && (_c) <= '~') + +#define ISSPACE(_c) \ + ((_c) == ' ' || \ + (_c) == '\t' || \ + (_c) == '\r' || \ + (_c) == '\n') + +static __GNU_INLINE boolean_t /* LINTED E_STATIC_UNUSED */ +isdigit(char c) +{ + return (ISDIGIT(c)); +} +#pragma inline(isdigit) + +static __GNU_INLINE boolean_t /* LINTED E_STATIC_UNUSED */ +isxdigit(char c) +{ + return (ISXDIGIT(c)); +} +#pragma inline(isxdigit) + +static __GNU_INLINE boolean_t /* LINTED E_STATIC_UNUSED */ +islower(char c) +{ + return (ISLOWER(c)); +} +#pragma inline(islower) + +static __GNU_INLINE boolean_t /* LINTED E_STATIC_UNUSED */ +isupper(char c) +{ + return (ISUPPER(c)); +} +#pragma inline(isupper) + +static __GNU_INLINE boolean_t /* LINTED E_STATIC_UNUSED */ +isalpha(char c) +{ + return (ISALPHA(c)); +} +#pragma inline(isalpha) + +static __GNU_INLINE boolean_t /* LINTED E_STATIC_UNUSED */ +isalnum(char c) +{ + return (ISALNUM(c)); +} +#pragma inline(isalnum) + +static __GNU_INLINE boolean_t /* LINTED E_STATIC_UNUSED */ +isprint(char c) +{ + return (ISPRINT(c)); +} +#pragma inline(isprint) + +static __GNU_INLINE boolean_t /* LINTED E_STATIC_UNUSED */ +isspace(char c) +{ + return (ISSPACE(c)); +} +#pragma inline(isspace) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CTYPE_H */ diff --git a/illumos-x86_64/usr/include/sys/cyclic.h b/illumos-x86_64/usr/include/sys/cyclic.h new file mode 100644 index 00000000..270a0944 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cyclic.h @@ -0,0 +1,107 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2017 RackTop Systems. + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _SYS_CYCLIC_H +#define _SYS_CYCLIC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM +#include +#include +#include +#endif /* !_ASM */ + +#define CY_LOW_LEVEL 0 +#define CY_LOCK_LEVEL 1 +#define CY_HIGH_LEVEL 2 +#define CY_SOFT_LEVELS 2 +#define CY_LEVELS 3 + +#ifndef _ASM + +typedef uintptr_t cyclic_id_t; +typedef int cyc_index_t; +typedef int cyc_cookie_t; +typedef uint16_t cyc_level_t; +typedef void (*cyc_func_t)(void *); +typedef void *cyb_arg_t; + +#define CYCLIC_NONE ((cyclic_id_t)0) + +typedef struct cyc_handler { + cyc_func_t cyh_func; + void *cyh_arg; + cyc_level_t cyh_level; +} cyc_handler_t; + +typedef struct cyc_time { + hrtime_t cyt_when; + hrtime_t cyt_interval; +} cyc_time_t; + +typedef struct cyc_omni_handler { + void (*cyo_online)(void *, cpu_t *, cyc_handler_t *, cyc_time_t *); + void (*cyo_offline)(void *, cpu_t *, void *); + void *cyo_arg; +} cyc_omni_handler_t; + +#define CY_INFINITY INT64_MAX + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *); +extern cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *); +extern void cyclic_remove(cyclic_id_t); +extern void cyclic_bind(cyclic_id_t, cpu_t *, cpupart_t *); +extern int cyclic_reprogram(cyclic_id_t, hrtime_t); +extern void cyclic_move_here(cyclic_id_t); +extern hrtime_t cyclic_getres(); + +extern int cyclic_offline(cpu_t *cpu); +extern void cyclic_online(cpu_t *cpu); +extern int cyclic_juggle(cpu_t *cpu); +extern void cyclic_move_in(cpu_t *); +extern int cyclic_move_out(cpu_t *); +extern void cyclic_suspend(); +extern void cyclic_resume(); + +extern void cyclic_fire(cpu_t *cpu); +extern void cyclic_softint(cpu_t *cpu, cyc_level_t level); + +#endif /* _KERNEL || _FAKE_KERNEL */ + +#endif /* !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CYCLIC_H */ diff --git a/illumos-x86_64/usr/include/sys/cyclic_impl.h b/illumos-x86_64/usr/include/sys/cyclic_impl.h new file mode 100644 index 00000000..b29119bc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/cyclic_impl.h @@ -0,0 +1,551 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_CYCLIC_IMPL_H +#define _SYS_CYCLIC_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Cyclic Subsystem Backend-supplied Interfaces + * -------------------------------------------- + * + * 0 Background + * + * The design, implementation and interfaces of the cyclic subsystem are + * covered in detail in block comments in the implementation. This + * comment covers the interface from the cyclic subsystem into the cyclic + * backend. The backend is specified by a structure of function pointers + * defined below. + * + * 1 Overview + * + * cyb_configure() <-- Configures the backend on the specified CPU + * cyb_unconfigure() <-- Unconfigures the backend + * cyb_enable() <-- Enables the CY_HIGH_LEVEL interrupt source + * cyb_disable() <-- Disables the CY_HIGH_LEVEL interrupt source + * cyb_reprogram() <-- Reprograms the CY_HIGH_LEVEL interrupt source + * cyb_softint() <-- Generates a soft interrupt + * cyb_set_level() <-- Sets the programmable interrupt level + * cyb_restore_level() <-- Restores the programmable interrupt level + * cyb_xcall() <-- Cross calls to the specified CPU + * cyb_suspend() <-- Suspends the backend + * cyb_resume() <-- Resumes the backend + * + * 2 cyb_arg_t cyb_configure(cpu_t *) + * + * 2.1 Overview + * + * cyb_configure() should configure the specified CPU for cyclic operation. + * + * 2.2 Arguments and notes + * + * cyb_configure() should initialize any backend-specific per-CPU + * structures for the specified CPU. cyb_configure() will be called for + * each CPU (including the boot CPU) during boot. If the platform + * supports dynamic reconfiguration, cyb_configure() will be called for + * new CPUs as they are configured into the system. + * + * 2.3 Return value + * + * cyb_configure() is expected to return a cookie (a cyb_arg_t, which is + * of type void *) which will be used as the first argument for all future + * cyclic calls into the backend on the specified CPU. + * + * 2.4 Caller's context + * + * cpu_lock will be held. The caller's CPU is unspecified, and may or + * may not be the CPU specified to cyb_configure(). + * + * 3 void cyb_unconfigure(cyb_arg_t arg) + * + * 3.1 Overview + * + * cyb_unconfigure() should unconfigure the specified backend. + * + * 3.2 Arguments and notes + * + * The only argument to cyb_unconfigure() is a cookie as returned from + * cyb_configure(). + * + * cyb_unconfigure() should free any backend-specific per-CPU structures + * for the specified backend. cyb_unconfigure() will _only_ be called on + * platforms which support dynamic reconfiguration. If the platform does + * not support dynamic reconfiguration, cyb_unconfigure() may panic. + * + * After cyb_unconfigure() returns, the backend must not call cyclic_fire() + * on the corresponding CPU; doing so will result in a bad trap. + * + * 3.3 Return value + * + * None. + * + * 3.4 Caller's context + * + * cpu_lock will be held. The caller's CPU is unspecified, and may or + * may not be the CPU specified to cyb_unconfigure(). The specified + * CPU is guaranteed to exist at the time cyb_unconfigure() is called. + * The cyclic subsystem is guaranteed to be suspended when cyb_unconfigure() + * is called, and interrupts are guaranteed to be disabled. + * + * 4 void cyb_enable(cyb_arg_t arg) + * + * 4.1 Overview + * + * cyb_enable() should enable the CY_HIGH_LEVEL interrupt source on + * the specified backend. + * + * 4.2 Arguments and notes + * + * The only argument to cyb_enable() is a backend cookie as returned from + * cyb_configure(). + * + * cyb_enable() will only be called if a) the specified backend has never + * been enabled or b) the specified backend has been explicitly disabled with + * cyb_disable(). In either case, cyb_enable() will only be called if + * the cyclic subsystem wishes to add a cyclic to the CPU corresponding + * to the specified backend. cyb_enable() will be called before + * cyb_reprogram() for a given backend. + * + * cyclic_fire() should not be called on a CPU which has not had its backend + * explicitly cyb_enable()'d, but to do so does not constitute fatal error. + * + * 4.3 Return value + * + * None. + * + * 4.4 Caller's context + * + * cyb_enable() will only be called from CY_HIGH_LEVEL context on the CPU + * corresponding to the specified backend. + * + * 5 void cyb_disable(cyb_arg_t arg) + * + * 5.1 Overview + * + * cyb_disable() should disable the CY_HIGH_LEVEL interrupt source on + * the specified backend. + * + * 5.2 Arguments and notes + * + * The only argument to cyb_disable() is a backend cookie as returned from + * cyb_configure(). + * + * cyb_disable() will only be called on backends which have been previously + * been cyb_enable()'d. cyb_disable() will be called when all cyclics have + * been juggled away or removed from a cyb_enable()'d CPU. + * + * cyclic_fire() should not be called on a CPU which has had its backend + * explicitly cyb_disable()'d, but to do so does not constitute fatal + * error. cyb_disable() is thus not required to check for a pending + * CY_HIGH_LEVEL interrupt. + * + * 5.3 Return value + * + * None. + * + * 5.4 Caller's context + * + * cyb_disable() will only be called from CY_HIGH_LEVEL context on the CPU + * corresponding to the specified backend. + * + * 6 void cyb_reprogram(cyb_arg_t arg, hrtime_t time) + * + * 6.1 Overview + * + * cyb_reprogram() should reprogram the CY_HIGH_LEVEL interrupt source + * to fire at the absolute time specified. + * + * 6.2 Arguments and notes + * + * The first argument to cyb_reprogram() is a backend cookie as returned from + * cyb_configure(). + * + * The second argument is an absolute time at which the CY_HIGH_LEVEL + * interrupt should fire. The specified time _may_ be in the past (albeit + * the very recent past). If this is the case, the backend should generate + * a CY_HIGH_LEVEL interrupt as soon as possible. + * + * The platform should not assume that cyb_reprogram() will be called with + * monotonically increasing values. + * + * If the platform does not allow for interrupts at arbitrary times in the + * future, cyb_reprogram() may do nothing -- as long as cyclic_fire() is + * called periodically at CY_HIGH_LEVEL. While this is clearly suboptimal + * (cyclic granularity will be bounded by the length of the period between + * cyclic_fire()'s), it allows the cyclic subsystem to be implemented on + * inferior hardware. + * + * 6.3 Return value + * + * None. + * + * 6.4 Caller's context + * + * cyb_reprogram() will only be called from CY_HIGH_LEVEL context on the CPU + * corresponding to the specified backend. + * + * 7 void cyb_softint(cyb_arg_t arg, cyc_level_t level) + * + * 7.1 Overview + * + * cyb_softint() should generate a software interrupt on the specified + * backend at the specified level. + * + * 7.2 Arguments and notes + * + * The first argument to cyb_softint() is a backend cookie as returned from + * cyb_configure(). The second argument is the interrupt level at which + * the software interrupt should be generated; it will be either + * CY_LOCK_LEVEL or CY_LOW_LEVEL. + * + * The software interrupt _must_ be generated on the CPU corresponding + * to the specified backend; platforms are _required_ to have a per-CPU + * notion of a software interrupt. + * + * Unless a software interrupt is already pending at the specified level, + * the software interrupt _must_ be generated. Once cyclic_softint() + * has been called at a given level, the software interrupt at that level + * should no longer be considered pending; an intervening CY_HIGH_LEVEL + * interrupt and subsequent cyb_softint() must generate another software + * interrupt. + * + * 7.3 Return value + * + * None. + * + * 7.4 Caller's context + * + * cyb_softint() will only be called at a level higher than the one + * specified: if CY_LOCK_LEVEL is specified, the caller will be at + * CY_HIGH_LEVEL; if CY_LOW_LEVEL is specified, the caller will be at + * either CY_HIGH_LEVEL or CY_LOCK_LEVEL. cyb_softint() will only be + * called on the CPU corresponding to the specified backend. + * + * 8 cyb_set_level(cyb_arg_t arg, cyc_level_t level) + * + * 8.1 Overview + * + * cyb_set_level() should set the programmable interrupt level to the + * level specified. + * + * 8.2 Arguments and notes + * + * The first argument to cyb_set_level() is a backend cookie as returned + * from cyb_configure(). The second argument is the level to which + * the programmable interrupt level should be set; it will be one of + * CY_HIGH_LEVEL, CY_LOCK_LEVEL or CY_LOW_LEVEL. + * + * After cyb_set_level() returns, the CPU associated with the specified + * backend should accept no interrupt at a level greater than or equal to + * the specified level. This will generally be a wrapper around splx(). + * + * The cyclic subsystem will never call cyb_set_level() twice consecutively + * on the same backend; there will always be an intervening + * cyb_restore_level(); + * + * 8.3 Return value + * + * cyb_set_level() should return a cookie to be passed back to + * cyb_restore_level(). On most implementations, this cookie will be + * the spl at the time of cyb_set_level(). + * + * 8.4 Caller's context + * + * cyb_set_level() is unique in that it is the only backend-provided + * interface which may be called in cross call context (see cyb_xcall(), + * below). cyb_set_level() may also be called from any of the cyclic + * + * 9 cyb_restore_level(cyb_arg_t arg, cyc_cookie_t cookie) + * + * 9.1 Overview + * + * cyb_restore_level() should restore the programmable interrupt level + * based upon the specified cookie. + * + * 9.2 Arguments and notes + * + * The first argument to cyb_restore_level() is a backend cookie as returned + * from cyb_configure(). The second argument is a cookie as returned from + * cyb_set_level(). + * + * cyb_restore_level() should restore the programmable interrupt level + * to its value when cyb_set_level() was called; the cookie is used + * to provide a hint to the backend. cyb_restore_level() will not be + * called without a proceeding call to cyb_set_level(), and + * cyb_restore_level() will never be called twice consecutively on the + * same backend. + * + * 9.3 Return value + * + * None. + * + * 9.4 Caller's context + * + * The constraints outlined in 5.9.2 imply that cyb_restore_level() can + * only be called from CY_HIGH_LEVEL, CY_LOCK_LEVEL or CY_LOW_LEVEL context. + * cyb_restore_level() is always called on the CPU associated with the + * specified backend. + * + * 10 cyb_xcall(cyb_arg_t arg, cpu_t *, void(*func)(void *), void *farg) + * + * 10.1 Overview + * + * cyb_xcall() should execute the specified function on the specified CPU. + * + * 10.2 Arguments and notes + * + * The first argument to cyb_restore_level() is a backend cookie as returned + * from cyb_configure(). The second argument is a CPU on which the third + * argument, a function pointer, should be executed. The fourth argument, + * a void *, should be passed as the argument to the specified function. + * + * cyb_xcall() must provide exactly-once semantics. If the specified + * function is called more than once, or not at all, the cyclic subsystem + * will become internally inconsistent. The specified function must be + * be executed on the specified CPU, but may be executed in any context + * (any interrupt context or kernel context). + * + * cyb_xcall() cannot block. Any resources which cyb_xcall() needs to + * acquire must thus be protected by synchronization primitives which + * never require the caller to block. + * + * 10.3 Return value + * + * None. + * + * 10.4 Caller's context + * + * cpu_lock will be held and kernel preemption may be disabled. The caller + * may be unable to block, giving rise to the constraint outlined in + * 10.2, above. + * + * 11 cyb_suspend(cyb_arg_t arg) + * + * 11.1 Overview + * + * cyb_suspend() should suspend the specified backend. + * + * 11.2 Arguments and notes + * + * The only argument to cyb_suspend() is a backend cookie as returned from + * cyb_configure(). + * + * cyb_suspend() will never be called on enabled backends. The backend + * should assume that the machine may be subsequently powered off; any + * volatile hardware state should be preserved and restored in cyb_resume(). + * However, the backend should not _assume_ that the machine will be + * powered off; cyb_suspend() may also be called as part of dynamic + * reconfiguration. + * + * cyb_suspend() will be called on the corresponding backend of each + * CPU in the system in succession, regardless of CPU state (P_ONLINE, + * P_OFFLINE, P_NOINTR). The cyclic subsystem will not suspend only a + * fraction of the CPUs. + * + * 11.3 Return value + * + * None. + * + * 11.4 Caller's context + * + * cyb_suspend() will be called in cross call context on the CPU associated + * with the specified backend. + * + * 12 cyb_resume(cyb_arg_t arg) + * + * 12.1 Overview + * + * cyb_resume() should resume the specified backend. + * + * 12.2 Arguments and notes + * + * The only argument to cyb_resume() is a backend cookie as returned from + * cyb_resume(). + * + * Calls to cyb_resume() will always have been proceeded by corresponding + * calls to cyb_suspend(). The machine may have been powered off between + * cyb_suspend() and the call to cyb_resume(). cyb_resume() may decide + * to restore hardware to its state at the time cyb_suspend() was called. + * + * The cyclic subsystem will make no calls into the backend between + * cyb_suspend() and cyb_resume(). + * + * 12.3 Return value + * + * None. + * + * 12.4 Caller's context + * + * cyb_resume() will be called in cross call context on the CPU associated + * with the specified backend. + */ +typedef struct cyc_backend { + cyb_arg_t (*cyb_configure)(cpu_t *); + void (*cyb_unconfigure)(cyb_arg_t); + void (*cyb_enable)(cyb_arg_t); + void (*cyb_disable)(cyb_arg_t); + void (*cyb_reprogram)(cyb_arg_t, hrtime_t); + void (*cyb_softint)(cyb_arg_t, cyc_level_t); + cyc_cookie_t (*cyb_set_level)(cyb_arg_t, cyc_level_t); + void (*cyb_restore_level)(cyb_arg_t, cyc_cookie_t); + void (*cyb_xcall)(cyb_arg_t, cpu_t *, cyc_func_t, void *); + void (*cyb_suspend)(cyb_arg_t); + void (*cyb_resume)(cyb_arg_t); + cyb_arg_t cyb_arg; +} cyc_backend_t; + +extern void cyclic_init(cyc_backend_t *be, hrtime_t resolution); +extern void cyclic_mp_init(); + +#ifdef DEBUG +#define CYCLIC_TRACE +#endif + +typedef enum { + CYS_ONLINE, + CYS_OFFLINE, + CYS_EXPANDING, + CYS_REMOVING, + CYS_SUSPENDED +} cyc_state_t; + +#define CYF_FREE 0x0001 +#define CYF_CPU_BOUND 0x0002 +#define CYF_PART_BOUND 0x0004 + +typedef struct cyclic { + hrtime_t cy_expire; + hrtime_t cy_interval; + void (*cy_handler)(void *); + void *cy_arg; + uint32_t cy_pend; + uint16_t cy_flags; + cyc_level_t cy_level; +} cyclic_t; + +typedef struct cyc_pcbuffer { + cyc_index_t *cypc_buf; + int cypc_prodndx; + int cypc_consndx; + int cypc_sizemask; +} cyc_pcbuffer_t; + +typedef struct cyc_softbuf { + uchar_t cys_hard; /* Can only be zero or one */ + uchar_t cys_soft; /* Can only be zero or one */ + cyc_pcbuffer_t cys_buf[2]; +} cyc_softbuf_t; + +#define CY_NTRACEREC 512 + +typedef struct cyc_tracerec { + hrtime_t cyt_tstamp; + char *cyt_why; + uint64_t cyt_arg0; + uint64_t cyt_arg1; +} cyc_tracerec_t; + +typedef struct cyc_tracebuf { + int cyt_ndx; + cyc_tracerec_t cyt_buf[CY_NTRACEREC]; +} cyc_tracebuf_t; + +#define CY_NCOVERAGE 127 + +typedef struct cyc_coverage { + char *cyv_why; + int cyv_passive_count; + int cyv_count[CY_LEVELS]; + uint64_t cyv_arg0; + uint64_t cyv_arg1; +} cyc_coverage_t; + +typedef struct cyc_cpu { + cpu_t *cyp_cpu; + cyc_index_t *cyp_heap; + cyclic_t *cyp_cyclics; + cyc_index_t cyp_nelems; + cyc_index_t cyp_size; + cyc_state_t cyp_state; + cyc_softbuf_t cyp_softbuf[CY_SOFT_LEVELS]; + cyc_backend_t *cyp_backend; + ksema_t cyp_modify_wait; + uint32_t cyp_modify_levels; + uint32_t cyp_rpend; +#ifdef CYCLIC_TRACE + cyc_tracebuf_t cyp_trace[CY_LEVELS]; +#endif +} cyc_cpu_t; + +typedef struct cyc_omni_cpu { + cyc_cpu_t *cyo_cpu; + cyc_index_t cyo_ndx; + void *cyo_arg; + struct cyc_omni_cpu *cyo_next; +} cyc_omni_cpu_t; + +typedef struct cyc_id { + krwlock_t cyi_lock; + cyc_cpu_t *cyi_cpu; + cyc_index_t cyi_ndx; + struct cyc_id *cyi_prev; + struct cyc_id *cyi_next; + cyc_omni_handler_t cyi_omni_hdlr; + cyc_omni_cpu_t *cyi_omni_list; +} cyc_id_t; + +typedef struct cyc_xcallarg { + cyc_cpu_t *cyx_cpu; + cyc_handler_t *cyx_hdlr; + cyc_time_t *cyx_when; + cyc_index_t cyx_ndx; + cyc_index_t *cyx_heap; + cyclic_t *cyx_cyclics; + cyc_index_t cyx_size; + uint16_t cyx_flags; + int cyx_wait; +} cyc_xcallarg_t; + +#define CY_DEFAULT_PERCPU 1 +#define CY_PASSIVE_LEVEL -1 + +#define CY_WAIT 0 +#define CY_NOWAIT 1 + +#define CYC_HEAP_PARENT(ndx) (((ndx) - 1) >> 1) +#define CYC_HEAP_RIGHT(ndx) (((ndx) + 1) << 1) +#define CYC_HEAP_LEFT(ndx) ((((ndx) + 1) << 1) - 1) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CYCLIC_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/dacf.h b/illumos-x86_64/usr/include/sys/dacf.h new file mode 100644 index 00000000..80cc30a9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dacf.h @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DACF_H +#define _DACF_H + +/* + * Device autoconfiguration framework (dacf) + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define DACF_MODREV_1 1 /* interface version # */ + +typedef void* dacf_arghdl_t; +typedef void* dacf_infohdl_t; + +typedef enum { + DACF_OPID_ERROR = -1, + DACF_OPID_END = 0, /* mark end of array of dacf_op's */ + DACF_OPID_POSTATTACH = 1, /* operate after a driver attaches */ + DACF_OPID_PREDETACH = 2 /* operate before a driver detaches */ +} dacf_opid_t; + +#define DACF_NUM_OPIDS 2 + +typedef struct dacf_op { + dacf_opid_t op_id; /* operation id */ + int (*op_func)(dacf_infohdl_t, dacf_arghdl_t, int); +} dacf_op_t; + +typedef struct dacf_opset { + char *opset_name; /* name of this op-set */ + dacf_op_t *opset_ops; /* null-terminated array of ops */ +} dacf_opset_t; + +struct dacfsw { + int dacf_rev; /* dacf interface revision # */ + dacf_opset_t *dacf_opsets; /* op-sets in this module */ +}; + +extern struct dacfsw kmod_dacfsw; /* kernel provided module */ + +/* + * DACF client interface + */ + +const char *dacf_minor_name(dacf_infohdl_t); +minor_t dacf_minor_number(dacf_infohdl_t); +dev_t dacf_get_dev(dacf_infohdl_t); +const char *dacf_driver_name(dacf_infohdl_t); +dev_info_t *dacf_devinfo_node(dacf_infohdl_t); +const char *dacf_get_arg(dacf_arghdl_t, char *); + +void dacf_store_info(dacf_infohdl_t, void *); +void *dacf_retrieve_info(dacf_infohdl_t); + +struct vnode *dacf_makevp(dacf_infohdl_t); + +/* + * Error codes for configuration operations + */ +#define DACF_SUCCESS 0 +#define DACF_FAILURE -1 + +#ifdef __cplusplus +} +#endif + +#endif /* _DACF_H */ diff --git a/illumos-x86_64/usr/include/sys/dacf_impl.h b/illumos-x86_64/usr/include/sys/dacf_impl.h new file mode 100644 index 00000000..094e764c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dacf_impl.h @@ -0,0 +1,162 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DACF_IMPL_H +#define _DACF_IMPL_H + +/* + * Implementation-Private definitions for Device autoconfiguration (dacf) + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef struct dacf_module { + char *dm_name; /* module name */ + krwlock_t dm_lock; /* module lock */ + int dm_loaded; /* whether dm_opsets is valid */ + dacf_opset_t *dm_opsets; /* null-terminated array of op-sets */ +} dacf_module_t; + + +#define DACF_RULE_HASHSIZE 8 +#define DACF_MODULE_HASHSIZE 8 +#define DACF_INFO_HASHSIZE 16 + +/* + * Flags to dacf_process_rsrvs + */ +#define DACF_PROC_INVOKE 0x0001 +#define DACF_PROC_RELE 0x0002 + +typedef enum dacf_devspec { + DACF_DS_ERROR = -1, /* error state */ + DACF_DS_MIN_NT = 1, /* match minor node-type */ + DACF_DS_DRV_MNAME = 2, /* match driver minor name */ + DACF_DS_DEV_PATH = 3 /* match device path */ +} dacf_devspec_t; + +#define DACF_NUM_DEVSPECS 3 + +typedef struct dacf_arg { + char *arg_name; /* operation argument name */ + char *arg_val; /* operation argument value */ + struct dacf_arg *arg_next; /* next arg in chain */ +} dacf_arg_t; + +typedef struct dacf_rule { + char *r_devspec_data; /* the dev-spec data to match against */ + char *r_module; /* module implementing the operation */ + char *r_opset; /* opset in module that impls. op */ + dacf_opid_t r_opid; /* operation id for this rule */ + uint_t r_opts; /* reserved for options */ + uint_t r_refs; /* reference count */ + dacf_arg_t *r_args; /* linked list of operation arguments */ +} dacf_rule_t; + +typedef struct dacf_rsrvlist { + dacf_rule_t *rsrv_rule; /* the rule being reserved for later */ + dacf_infohdl_t rsrv_ihdl; + int rsrv_result; /* retval of the last invoke */ + struct dacf_rsrvlist *rsrv_next; +} dacf_rsrvlist_t; + +#ifdef _KERNEL + +extern kmutex_t dacf_lock; + +int dacf_module_register(char *, struct dacfsw *); +int dacf_module_unregister(char *); + +int dacf_arg_insert(dacf_arg_t **, char *, char *); +void dacf_arglist_delete(dacf_arg_t **); + +void dacf_init(void); +int read_dacf_binding_file(char *); +void dacf_clear_rules(void); + +dacf_devspec_t dacf_get_devspec(char *); +const char *dacf_devspec_to_str(dacf_devspec_t); + +dacf_opid_t dacf_get_op(char *); +const char *dacf_opid_to_str(dacf_opid_t); + +int dacf_getopt(char *, uint_t *); + +int dacf_rule_insert(dacf_devspec_t, char *, char *, char *, + dacf_opid_t, uint_t, dacf_arg_t *); +void dacf_rule_hold(dacf_rule_t *); +void dacf_rule_rele(dacf_rule_t *); + +struct ddi_minor_data; +void dacf_rsrv_make(dacf_rsrvlist_t *, dacf_rule_t *, void *, + dacf_rsrvlist_t **); +void dacf_process_rsrvs(dacf_rsrvlist_t **, dacf_opid_t, int); +void dacf_clr_rsrvs(dev_info_t *, dacf_opid_t); + +dacf_rule_t *dacf_match(dacf_opid_t, dacf_devspec_t, const void *); + +/* + * Failure codes from dacf_op_invoke, assigned to dacf_rsrvlist_t.rsrv_result + */ +#define DACF_ERR_MOD_NOTFOUND -1 +#define DACF_ERR_OPSET_NOTFOUND -2 +#define DACF_ERR_OP_NOTFOUND -3 +#define DACF_ERR_OP_FAILED -4 + +int dacf_op_invoke(dacf_rule_t *, dacf_infohdl_t, int); + +/* + * Debugging support + */ +#define DACF_DBG_MSGS 0x00000001 +#define DACF_DBG_DEVI 0x00000002 + +extern int dacfdebug; + + +/* + * dacf client support: definitions pertaining to the various kernel hooks + * that utilize the dacf framework + */ + +void dacfc_match_create_minor(const char *, const char *, dev_info_t *, + struct ddi_minor_data *, int); + +int dacfc_postattach(dev_info_t *); +int dacfc_predetach(dev_info_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DACF_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/damap.h b/illumos-x86_64/usr/include/sys/damap.h new file mode 100644 index 00000000..68e5b8de --- /dev/null +++ b/illumos-x86_64/usr/include/sys/damap.h @@ -0,0 +1,181 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_DAMAP_H +#define _SYS_DAMAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Delta (device) Address Map Interfaces + * + * These interfaces provide time-stablized sets of 'addresses', + * where addresses are string representations of device + * or bus-specific address. The mechanisms include interfaces to + * report and remove address from a map, time stabilization, callouts + * to higher-level configuration and unconfiguration actions, and + * address lookup functions. + * + * Per Address Reports + * With per-address reporting, the caller reports the addition and removal + * each address visible to it. Each report is independently time stabilized; + * Once a report has stabilized, the reported address is either + * activated & configured, or unconfigured & released. + * + * Full Set Reports + * When using fullset reporting, the report provider enumerates the entire + * set of addresses visible to the provider at a given point in time. + * The entire set is then stabilized. + * Upon stabilizing, any newly reported addresses are activated & configured + * and any previously active addresses which are no longer visible are + * automatically unconfigured and released, freeing the provider from + * the need to explicitly unconfigure addresses no longer present. + * + * Stabilization + * Once an address has been reported (or reported as removed), the report + * is time stabilized before the framework initiates a configuration + * or unconfiguration action. If the address is re-reported while undergoing + * stabilization, the timer is reset for either the address or the full + * set of addresses reported to the map. + * + * Activation/Release + * Once a reported address has passed its stabilization, the address is + * 'activated' by the framework. Once activated, the address is passed + * to a configuration callout to perform whatever actions are necessary. + * If a reported address is deleted or fails to stabilize, the address + * is released by the map. + * A report provider may register callback functions to be invoked + * as part of the address activation & release process. In addition to + * the callbacks, a provider can also supply a handle to provider-private + * data at the time an address is reported. This handle is returned to + * provider as an argument to the activation & release callbacks. + * + * Lookup/Access + * The set of stable addresses contained in a map can be obtained by + * calling interfaces to lookup either a single address or the full + * list of stable addresses. + */ + +/* + * damap_t: Handle to a delta address map + * damap_id_t: Handle to an entry of damap_t + */ +typedef struct __damap_dm *damap_t; +typedef id_t damap_id_t; + +/* + * damap_id_list_t: List of damap_id_handles + * NB. Not Used + */ +typedef struct __damap_id_list *damap_id_list_t; + +#define NODAM (damap_id_t)0 + +/* + * activate_cb: Provider callback when reported address is activated + * deactivate_cb: Provider callback when address has been released + * + * configure_cb: Class callout to configure newly activated addresses + * unconfig_cb: Class callout to unconfigure deactivated addresses + */ +typedef enum { + DAMAP_DEACT_RSN_GONE = 0, + DAMAP_DEACT_RSN_CFG_FAIL, + DAMAP_DEACT_RSN_UNSTBL +} damap_deact_rsn_t; + +typedef void (*damap_activate_cb_t)(void *, char *, int, void **); +typedef void (*damap_deactivate_cb_t)(void *, char *, int, void *, + damap_deact_rsn_t); + +typedef int (*damap_configure_cb_t)(void *, damap_t *, damap_id_t); +typedef int (*damap_unconfig_cb_t)(void *, damap_t *, damap_id_t); + +/* + * Map reporting mode + */ +typedef enum {DAMAP_REPORT_PERADDR, DAMAP_REPORT_FULLSET} damap_rptmode_t; + +/* + * Map create options flags + * DAMAP_SERIALCONFIG - serialize activate/deactivate operations + * DAMAP_MTCONFIG - multithread config/unconfg operations + */ +#define DAMAP_SERIALCONFIG 0 +#define DAMAP_MTCONFIG 1 + +int damap_create(char *, damap_rptmode_t, int, int, + void *, damap_activate_cb_t, damap_deactivate_cb_t, + void *, damap_configure_cb_t, damap_unconfig_cb_t, + damap_t **); +void damap_destroy(damap_t *); + +char *damap_name(damap_t *); +int damap_size(damap_t *); +int damap_is_empty(damap_t *); +int damap_sync(damap_t *, int); + +int damap_addr_add(damap_t *, char *, damap_id_t *, nvlist_t *, void *); +int damap_addr_del(damap_t *, char *); +int damap_addrid_del(damap_t *, int); + +/* + * modifiers to damap_addrset_end() + */ +#define DAMAP_END_RESET 1 +#define DAMAP_END_ABORT 2 + +int damap_addrset_begin(damap_t *); +int damap_addrset_add(damap_t *, char *, damap_id_t *, + nvlist_t *, void *); +int damap_addrset_end(damap_t *, int); +int damap_addrset_flush(damap_t *); +int damap_addrset_reset(damap_t *, int); +damap_id_t damap_id_next(damap_t *, damap_id_list_t, damap_id_t); +char *damap_id2addr(damap_t *, damap_id_t); +nvlist_t *damap_id2nvlist(damap_t *, damap_id_t); +int damap_id_hold(damap_t *, damap_id_t); +void damap_id_rele(damap_t *, damap_id_t); +int damap_id_ref(damap_t *, damap_id_t); +void damap_id_list_rele(damap_t *, damap_id_list_t); +void *damap_id_priv_get(damap_t *, damap_id_t); +void damap_id_priv_set(damap_t *, damap_id_t, void *); +damap_id_t damap_lookup(damap_t *, char *); +int damap_lookup_all(damap_t *, damap_id_list_t *); + +#define DAM_SUCCESS 0 +#define DAM_EEXIST 1 +#define DAM_MAPFULL 2 +#define DAM_EINVAL 3 +#define DAM_FAILURE 4 +#define DAM_SHAME 5 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DAMAP_H */ diff --git a/illumos-x86_64/usr/include/sys/damap_impl.h b/illumos-x86_64/usr/include/sys/damap_impl.h new file mode 100644 index 00000000..2b1b09c0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/damap_impl.h @@ -0,0 +1,152 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2023 Racktop Systems, Inc. + */ + +#ifndef _SYS_DAMAP_IMPL_H +#define _SYS_DAMAP_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct dam dam_t; + +/* + * activate_cb: Provider callback when reported address is activated + * deactivate_cb: Provider callback when address has been released + * + * configure_cb: Class callout to configure newly activated addresses + * unconfig_cb: Class callout to unconfigure deactivated addresses + */ +typedef void (*activate_cb_t)(void *, char *addr, int idx, void **privp); +typedef void (*deactivate_cb_t)(void *, char *addr, int idx, void *priv, + damap_deact_rsn_t deact_rsn); + +typedef int (*configure_cb_t)(void *, dam_t *mapp, id_t map_id); +typedef int (*unconfig_cb_t)(void *, dam_t *mapp, id_t map_id); + + +struct dam { + char *dam_name; + int dam_flags; /* map state and cv flags */ + int dam_options; /* map options */ + int dam_rptmode; /* report mode */ + clock_t dam_stable_ticks; /* stabilization */ + uint_t dam_size; /* max index for addr hash */ + id_t dam_high; /* highest index allocated */ + timeout_id_t dam_tid; /* timeout(9F) ID */ + + void *dam_activate_arg; /* activation private */ + activate_cb_t dam_activate_cb; /* activation callback */ + deactivate_cb_t dam_deactivate_cb; /* deactivation callback */ + + void *dam_config_arg; /* config-private */ + configure_cb_t dam_configure_cb; /* configure callout */ + unconfig_cb_t dam_unconfig_cb; /* unconfigure callout */ + + ddi_strid *dam_addr_hash; /* addresss to ID hash */ + bitset_t dam_active_set; /* activated address set */ + bitset_t dam_stable_set; /* stable address set */ + bitset_t dam_report_set; /* reported address set */ + void *dam_da; /* per-address soft state */ + hrtime_t dam_last_update; /* last map update */ + hrtime_t dam_last_stable; /* last map stable */ + int dam_stable_cnt; /* # of times map stabilized */ + int dam_stable_overrun; + kcondvar_t dam_sync_cv; + kmutex_t dam_lock; + kstat_t *dam_kstatsp; + int dam_sync_to_cnt; +}; + +#define DAM_SPEND 0x10 /* stable pending */ +#define DAM_DESTROYPEND 0x20 /* in process of being destroyed */ +#define DAM_SETADD 0x100 /* fullset update pending */ + +/* + * per address softstate stucture + */ +typedef struct { + uint_t da_flags; /* flags */ + int da_jitter; /* address re-report count */ + int da_ref; /* refcount on address */ + void *da_ppriv; /* stable provider private */ + void *da_cfg_priv; /* config/unconfig private */ + nvlist_t *da_nvl; /* stable nvlist */ + nvlist_t *da_nvl_rpt; /* reported nvlist */ + int64_t da_deadline; /* ddi_get_lbolt64 value when stable */ + hrtime_t da_last_report; /* timestamp of last report */ + int da_report_cnt; /* # of times address reported */ + hrtime_t da_last_stable; /* timestamp of last stable address */ + int da_stable_cnt; /* # of times address has stabilized */ + char *da_addr; /* string in dam_addr_hash (for mdb) */ +} dam_da_t; + +/* + * dam_da_t.da_flags + */ +#define DA_INIT 0x1 /* address initizized */ +#define DA_FAILED_CONFIG 0x2 /* address failed configure */ +#define DA_RELE 0x4 /* adddress released */ + + +/* + * report type + */ +#define RPT_ADDR_ADD 0 +#define RPT_ADDR_DEL 1 + +#define DAM_IN_REPORT(m, i) (bitset_in_set(&(m)->dam_report_set, (i))) +#define DAM_IS_STABLE(m, i) (bitset_in_set(&(m)->dam_active_set, (i))) + +/* + * DAM statistics + */ +struct dam_kstats { + struct kstat_named dam_cycles; + struct kstat_named dam_overrun; + struct kstat_named dam_jitter; + struct kstat_named dam_active; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DAMAP_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/dc_ki.h b/illumos-x86_64/usr/include/sys/dc_ki.h new file mode 100644 index 00000000..1f7fb872 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dc_ki.h @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998, 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DC_KI_H +#define _DC_KI_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The routine is used for all drivers that are loaded into + * memory before root is mounted. They are implemented in + * misc/cl_bootstrap module in SunCluster consolidation. + */ + +extern void cluster(void); +extern int clboot_modload(struct modctl *mp); +extern int clboot_loadrootmodules(); +extern int clboot_rootconf(); +extern void clboot_mountroot(); + +#ifdef __cplusplus +} +#endif + +#endif /* _DC_KI_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi.h b/illumos-x86_64/usr/include/sys/ddi.h new file mode 100644 index 00000000..86ba4b1a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi.h @@ -0,0 +1,179 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_DDI_H +#define _SYS_DDI_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ddi.h -- the flag and function definitions needed by DDI-conforming + * drivers. This header file contains #undefs to undefine macros that + * drivers would otherwise pick up in order that function definitions + * may be used. Programmers should place the include of "sys/ddi.h" + * after any header files that define the macros #undef'ed or the code + * may compile incorrectly. + */ + +/* + * define min() and max() as macros so that drivers will not pick up the + * min() and max() kernel functions since they do signed comparison only. + */ +#ifdef min +#undef min +#endif /* min */ +#define min(a, b) ((a) < (b) ? (a) : (b)) + +#ifdef max +#undef max +#endif /* max */ +#define max(a, b) ((a) < (b) ? (b) : (a)) + +#define TIME 1 +#define UPROCP 2 +#define PPGRP 3 +#define LBOLT 4 +#define SYSRINT 5 +#define SYSXINT 6 +#define SYSMINT 7 +#define SYSRAWC 8 +#define SYSCANC 9 +#define SYSOUTC 10 +#define PPID 11 +#define PSID 12 +#define UCRED 13 + +extern int drv_getparm(uint_t, void *); +extern int drv_setparm(uint_t, ulong_t); +extern void drv_usecwait(clock_t); +extern clock_t drv_hztousec(clock_t); +extern clock_t drv_usectohz(clock_t); +extern void delay(clock_t); +extern void time_to_wait(clock_t *, clock_t); + +/* XXX -- should be changed to major_t */ +/* convert external to internal major number */ + +extern int etoimajor(major_t); +/* convert internal to extern major number */ +extern int itoemajor(major_t, int); +extern int drv_priv(struct cred *); + +/* + * The following declarations take the place of macros in + * sysmacros.h The undefs are for any case where a driver includes + * sysmacros.h, even though DDI conforming drivers must not. + */ +#undef getemajor +#undef geteminor +#undef getmajor +#undef getminor +#undef makedevice +#undef cmpdev +#undef expdev + + +extern major_t getemajor(dev_t); +extern minor_t geteminor(dev_t); +extern major_t getmajor(dev_t); +extern minor_t getminor(dev_t); +extern dev_t makedevice(major_t, minor_t); +extern o_dev_t cmpdev(dev_t); +extern dev_t expdev(dev_t); + +/* + * The following macros from param.h are also being converted to + * functions and #undefs must be done here as well since param.h + * will be included by most if not every driver + */ + +#undef btop +#undef btopr +#undef ptob + +extern unsigned long btop(unsigned long); +extern unsigned long btopr(unsigned long); +extern unsigned long ptob(unsigned long); + + +/* STREAMS drivers and modules must include stream.h to pick up the */ +/* needed structure and flag definitions. As was the case with map.h, */ +/* macros used by both the kernel and drivers in times past now have */ +/* a macro definition for the kernel and a function definition for */ +/* drivers. The following #undefs allow drivers to include stream.h */ +/* but call the functions rather than macros. */ + +#undef OTHERQ +#undef RD +#undef WR +#undef SAMESTR +#undef datamsg + +extern struct queue *OTHERQ(queue_t *); /* stream.h */ +extern struct queue *RD(queue_t *); +extern struct queue *WR(queue_t *); +extern int SAMESTR(queue_t *); +extern int datamsg(unsigned char); + +/* declarations of functions for allocating and deallocating the space */ +/* for a buffer header (just a header, not the associated buffer) */ + +extern struct buf *getrbuf(int); +extern void freerbuf(struct buf *); + +#ifdef _KERNEL +/* + * SVR4MP replacement for hat_getkpfnum() + */ +#define NOPAGE (-1) /* value returned for invalid addresses */ + +typedef pfn_t ppid_t; /* a 'physical page identifier' - no math allowed! */ + +extern ppid_t kvtoppid(caddr_t); + +extern int qassociate(queue_t *, int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_hp.h b/illumos-x86_64/usr/include/sys/ddi_hp.h new file mode 100644 index 00000000..b88762a9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_hp.h @@ -0,0 +1,132 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_DDI_HP_H +#define _SYS_DDI_HP_H + +/* + * Sun DDI hotplug support definitions + * + * See the big theory statement in uts/common/os/ddi_hp_impl.c for more + * information. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ddi_hp_cn_state_t + * + * Typedef of generic hotplug state machine for Hotplug Connection (CN) + */ +typedef enum { + DDI_HP_CN_STATE_EMPTY = 0x1000, /* Empty */ + DDI_HP_CN_STATE_PRESENT = 0x2000, /* A Device Present */ + DDI_HP_CN_STATE_POWERED = 0x3000, /* Powered */ + DDI_HP_CN_STATE_ENABLED = 0x4000, /* Enabled */ + DDI_HP_CN_STATE_PORT_EMPTY = 0x5000, /* PORT Empty */ + DDI_HP_CN_STATE_PORT_PRESENT = 0x6000, /* A Device Node Present */ + DDI_HP_CN_STATE_OFFLINE = 0x7000, /* Driver not attached */ + DDI_HP_CN_STATE_ATTACHED = 0x8000, /* Device driver attached */ + DDI_HP_CN_STATE_MAINTENANCE = 0x9000, /* Device in maintenance */ + DDI_HP_CN_STATE_ONLINE = 0xa000 /* Device is ready */ +} ddi_hp_cn_state_t; + +/* + * ddi_hp_cn_type_t + * + * Typedef for Hotplug Connection (CN) types. + */ +typedef enum { + DDI_HP_CN_TYPE_VIRTUAL_PORT = 0x1, /* Virtual Hotplug Port */ + DDI_HP_CN_TYPE_PCI = 0x2, /* PCI bus slot */ + DDI_HP_CN_TYPE_PCIE = 0x3 /* PCI Express slot */ +} ddi_hp_cn_type_t; + +#define DDI_HP_CN_TYPE_STR_PORT "Virtual-Port" +/* + * The value set to ddi_hp_cn_info_t->cn_num_dpd_on in the case of the + * connection does not depend on any other connections. + */ +#define DDI_HP_CN_NUM_NONE -1 + +/* + * ddi_hp_cn_info_t + * + * Hotplug Connection (CN) information structure. + * A Connection is either a Connector or a Port. + */ +typedef struct ddi_hp_cn_info { + char *cn_name; /* Name of the Connection */ + /* + * Connection number. + */ + int cn_num; + /* + * Depend-on connection number; + * The connection number on which this connection is depending on. + * If this connection does not depend on any other connections + * under the same parent node, then it's cn_num_dpd_on is set to + * DDI_HP_CN_NUM_NONE. + */ + int cn_num_dpd_on; + + ddi_hp_cn_type_t cn_type; /* Type: Port, PCI, PCIE, ... */ + + /* + * Description string for types of Connection. Set by bus software + * and read by users only. + */ + char *cn_type_str; + /* + * The child device of this Port. + * It is NULL if this is a Connector. + */ + dev_info_t *cn_child; + + ddi_hp_cn_state_t cn_state; /* Hotplug Connection state */ + time32_t cn_last_change; /* Last time state changed. */ +} ddi_hp_cn_info_t; + +typedef struct ddi_hp_property { + char *nvlist_buf; + size_t buf_size; +} ddi_hp_property_t; + +#if defined(_SYSCALL32) +typedef struct ddi_hp_property32 { + caddr32_t nvlist_buf; + uint32_t buf_size; +} ddi_hp_property32_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_HP_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_hp_impl.h b/illumos-x86_64/usr/include/sys/ddi_hp_impl.h new file mode 100644 index 00000000..b52df77c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_hp_impl.h @@ -0,0 +1,157 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2019 Joyent, Inc. + */ + +/* + * See the big theory statement in uts/common/os/ddi_hp_impl.c for more + * information about the structures and functions defined here. + */ + +#ifndef _SYS_DDI_HP_IMPL_H +#define _SYS_DDI_HP_IMPL_H + +/* + * Sun DDI hotplug implementation specific definitions + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* Flags for sync request and async hotplug request */ +#define DDI_HP_REQ_SYNC 0x0001 +#define DDI_HP_REQ_ASYNC 0x0002 + +/* Check if a handle represents a port or a connector */ +#define DDI_HP_IS_VIRTUAL_PORT(hdlp) \ + (hdlp->cn_info.cn_type == DDI_HP_CN_TYPE_VIRTUAL_PORT) + +/* + * ddi_hp_cn_handle_t + * + * DDI handle for a registered Hotplug Connection (CN) + */ +typedef struct ddi_hp_cn_handle { + dev_info_t *cn_dip; /* The dip that the handle is linked */ + ddi_hp_cn_info_t cn_info; /* Connection info */ + struct ddi_hp_cn_handle *next; /* Next Connector/Port. */ +} ddi_hp_cn_handle_t; + +typedef struct ddi_hp_cn_async_event_entry { + dev_info_t *dip; + char *cn_name; + ddi_hp_cn_state_t target_state; +} ddi_hp_cn_async_event_entry_t; + +/* + * ddi_hp_op_t + * + * Typedef for Hotplug OPS commands used with bus_hp_op() + */ +typedef enum { + DDI_HPOP_CN_GET_STATE = 1, /* Get Connection state */ + DDI_HPOP_CN_CHANGE_STATE, /* Change Connection state */ + DDI_HPOP_CN_PROBE, /* Probe Connection */ + DDI_HPOP_CN_UNPROBE, /* Unprobe Connection */ + DDI_HPOP_CN_GET_PROPERTY, /* Get bus specific property */ + DDI_HPOP_CN_SET_PROPERTY, /* Set bus specific property */ + DDI_HPOP_CN_CREATE_PORT, /* Create a port for virtual hotplug */ + DDI_HPOP_CN_REMOVE_PORT /* Remove an empty port */ +} ddi_hp_op_t; + +#define DDIHP_CN_OPS(hdlp, op, arg, result, ret) \ + if (DDI_HP_IS_VIRTUAL_PORT(hdlp)) \ + ret = ddihp_port_ops(hdlp, op, arg, result); \ + else \ + ret = ddihp_connector_ops(hdlp, op, arg, result); + +#define NEXUS_HAS_HP_OP(dip) \ + ((DEVI(dip)->devi_ops->devo_bus_ops) && \ + (DEVI(dip)->devi_ops->devo_bus_ops->busops_rev >= BUSO_REV_10) && \ + (DEVI(dip)->devi_ops->devo_bus_ops->bus_hp_op)) + +/* + * ddi_hp_cn_sysevent_t + * + * The following correspond to sysevent defined subclasses + */ +typedef enum { + DDI_HP_CN_STATE_CHANGE, + DDI_HP_CN_REQ +} ddi_hp_cn_sysevent_t; + +/* + * Misc + */ + +/* Append a node to list */ +#define DDIHP_LIST_APPEND(type, head, node) \ +if (node) { \ + type *curr, *prev = NULL; \ + (node)->next = NULL; \ + for (curr = (head); curr; prev = curr, curr = curr->next); \ + if (prev == NULL) \ + (head) = (node); \ + else \ + prev->next = (node); \ +} + +/* Remove a node from a list */ +#define DDIHP_LIST_REMOVE(type, head, node) \ +if (node) { \ + type *curr, *prev = NULL; \ + for (curr = (head); curr; prev = curr, curr = curr->next) { \ + if (curr == (node)) \ + break; \ + } \ + if (curr) { \ + if (prev == NULL) \ + (head) = (head)->next; \ + else \ + prev->next = curr->next; \ + } \ +} + +int ddihp_modctl(int hp_op, char *path, char *cn_name, uintptr_t arg, + uintptr_t rval); +ddi_hp_cn_handle_t *ddihp_cn_name_to_handle(dev_info_t *dip, char *cn_name); +int ddihp_cn_getstate(ddi_hp_cn_handle_t *hdlp); +int ddihp_port_ops(ddi_hp_cn_handle_t *hdlp, ddi_hp_op_t op, + void *arg, void *result); +int ddihp_connector_ops(ddi_hp_cn_handle_t *hdlp, + ddi_hp_op_t op, void *arg, void *result); +void ddihp_cn_gen_sysevent(ddi_hp_cn_handle_t *hdlp, + ddi_hp_cn_sysevent_t event_sub_class, int hint, int kmflag); +int ddihp_cn_unregister(ddi_hp_cn_handle_t *hdlp); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_HP_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_impldefs.h b/illumos-x86_64/usr/include/sys/ddi_impldefs.h new file mode 100644 index 00000000..2570fe87 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_impldefs.h @@ -0,0 +1,1278 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore . All rights reserved. + * Copyright 2016 Joyent, Inc. + * Copyright (c) 2016 by Delphix. All rights reserved. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. + */ + +#ifndef _SYS_DDI_IMPLDEFS_H +#define _SYS_DDI_IMPLDEFS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The device id implementation has been switched to be based on properties. + * For compatibility with di_devid libdevinfo interface the following + * must be defined: + */ +#define DEVID_COMPATIBILITY ((ddi_devid_t)-1) + +/* + * Definitions for node class. + * DDI_NC_PROM: a node with a nodeid that may be used in a promif call. + * DDI_NC_PSEUDO: a software created node with a software assigned nodeid. + */ +typedef enum { + DDI_NC_PROM = 0, + DDI_NC_PSEUDO +} ddi_node_class_t; + +/* + * Definitions for generic callback mechanism. + */ +typedef enum { + DDI_CB_INTR_ADD, /* More available interrupts */ + DDI_CB_INTR_REMOVE /* Fewer available interrupts */ +} ddi_cb_action_t; + +typedef enum { + DDI_CB_FLAG_INTR = 0x1 /* Driver is IRM aware */ +} ddi_cb_flags_t; + +#define DDI_CB_FLAG_VALID(f) ((f) & DDI_CB_FLAG_INTR) + +typedef int (*ddi_cb_func_t)(dev_info_t *dip, ddi_cb_action_t action, + void *cbarg, void *arg1, void *arg2); + +typedef struct ddi_cb { + uint64_t cb_flags; + dev_info_t *cb_dip; + ddi_cb_func_t cb_func; + void *cb_arg1; + void *cb_arg2; +} ddi_cb_t; + +/* + * dev_info: The main device information structure this is intended to be + * opaque to drivers and drivers should use ddi functions to + * access *all* driver accessible fields. + * + * devi_parent_data includes property lists (interrupts, registers, etc.) + * devi_driver_data includes whatever the driver wants to place there. + */ +struct devinfo_audit; + +typedef struct devi_port { + union { + struct { + uint32_t type; + uint32_t pad; + } port; + uint64_t type64; + } info; + void *priv_p; +} devi_port_t; + +typedef struct devi_bus_priv { + devi_port_t port_up; + devi_port_t port_down; +} devi_bus_priv_t; + +#if defined(__x86) +struct iommulib_unit; +typedef struct iommulib_unit *iommulib_handle_t; +struct iommulib_nex; +typedef struct iommulib_nex *iommulib_nexhandle_t; +#endif + +typedef uint8_t ndi_flavor_t; +struct ddi_hp_cn_handle; + +struct in_node; + +struct dev_info { + + struct dev_info *devi_parent; /* my parent node in tree */ + struct dev_info *devi_child; /* my child list head */ + struct dev_info *devi_sibling; /* next element on my level */ + + char *devi_binding_name; /* name used to bind driver: */ + /* shared storage, points to */ + /* devi_node_name, devi_compat_names */ + /* or devi_rebinding_name */ + + char *devi_addr; /* address part of name */ + + int devi_nodeid; /* device nodeid */ + int devi_instance; /* device instance number */ + + struct dev_ops *devi_ops; /* driver operations */ + + void *devi_parent_data; /* parent private data */ + void *devi_driver_data; /* driver private data */ + + ddi_prop_t *devi_drv_prop_ptr; /* head of driver prop list */ + ddi_prop_t *devi_sys_prop_ptr; /* head of system prop list */ + + struct ddi_minor_data *devi_minor; /* head of minor list */ + struct dev_info *devi_next; /* Next instance of this device */ + kmutex_t devi_lock; /* Protects per-devinfo data */ + + /* logical parents for busop primitives */ + + struct dev_info *devi_bus_map_fault; /* bus_map_fault parent */ + void *devi_obsolete; /* obsolete placeholder */ + struct dev_info *devi_bus_dma_allochdl; /* bus_dma_newhdl parent */ + struct dev_info *devi_bus_dma_freehdl; /* bus_dma_freehdl parent */ + struct dev_info *devi_bus_dma_bindhdl; /* bus_dma_bindhdl parent */ + struct dev_info *devi_bus_dma_unbindhdl; /* bus_dma_unbindhdl parent */ + struct dev_info *devi_bus_dma_flush; /* bus_dma_flush parent */ + struct dev_info *devi_bus_dma_win; /* bus_dma_win parent */ + struct dev_info *devi_bus_dma_ctl; /* bus_dma_ctl parent */ + struct dev_info *devi_bus_ctl; /* bus_ctl parent */ + + ddi_prop_t *devi_hw_prop_ptr; /* head of hw prop list */ + + char *devi_node_name; /* The 'name' of the node */ + char *devi_compat_names; /* A list of driver names */ + size_t devi_compat_length; /* Size of compat_names */ + + int (*devi_bus_dma_bindfunc)(dev_info_t *, dev_info_t *, + ddi_dma_handle_t, struct ddi_dma_req *, ddi_dma_cookie_t *, + uint_t *); + int (*devi_bus_dma_unbindfunc)(dev_info_t *, dev_info_t *, + ddi_dma_handle_t); + + char *devi_devid_str; /* registered device id */ + + /* + * power management entries + * components exist even if the device is not currently power managed + */ + struct pm_info *devi_pm_info; /* 0 => dev not power managed */ + uint_t devi_pm_flags; /* pm flags */ + int devi_pm_num_components; /* number of components */ + size_t devi_pm_comp_size; /* size of devi_components */ + struct pm_component *devi_pm_components; /* array of pm components */ + struct dev_info *devi_pm_ppm; /* ppm attached to this one */ + void *devi_pm_ppm_private; /* for use by ppm driver */ + int devi_pm_dev_thresh; /* "device" threshold */ + uint_t devi_pm_kidsupcnt; /* # of kids powered up */ + struct pm_scan *devi_pm_scan; /* pm scan info */ + uint_t devi_pm_noinvolpm; /* # of descendents no-invol */ + uint_t devi_pm_volpmd; /* # of voluntarily pm'ed */ + kmutex_t devi_pm_lock; /* pm lock for state */ + kmutex_t devi_pm_busy_lock; /* for component busy count */ + + uint_t devi_state; /* device/bus state flags */ + /* see below for definitions */ + kcondvar_t devi_cv; /* cv */ + int devi_ref; /* reference count */ + + dacf_rsrvlist_t *devi_dacf_tasks; /* dacf reservation queue */ + + ddi_node_class_t devi_node_class; /* Node class */ + int devi_node_attributes; /* Node attributes: See below */ + + char *devi_device_class; + + /* + * New mpxio kernel hooks entries + */ + int devi_mdi_component; /* mpxio component type */ + void *devi_mdi_client; /* mpxio client information */ + void *devi_mdi_xhci; /* vhci/phci info */ + + ddi_prop_list_t *devi_global_prop_list; /* driver global properties */ + major_t devi_major; /* driver major number */ + ddi_node_state_t devi_node_state; /* state of node */ + uint_t devi_flags; /* configuration flags */ + int devi_circular; /* for recursive operations */ + void *devi_busy_thread; /* thread operating on node */ + void *devi_taskq; /* hotplug taskq */ + + /* device driver statistical and audit info */ + struct devinfo_audit *devi_audit; /* last state change */ + + /* + * FMA support for resource caches and error handlers + */ + struct i_ddi_fmhdl *devi_fmhdl; + + uint_t devi_cpr_flags; + + /* Owned by DDI interrupt framework */ + devinfo_intr_t *devi_intr_p; + + void *devi_nex_pm; /* nexus PM private */ + + char *devi_addr_buf; /* buffer for devi_addr */ + + char *devi_rebinding_name; /* binding_name of rebind */ + + /* For device contracts that have this dip's minor node as resource */ + kmutex_t devi_ct_lock; /* contract lock */ + kcondvar_t devi_ct_cv; /* contract cv */ + int devi_ct_count; /* # of outstanding responses */ + int devi_ct_neg; /* neg. occurred on dip */ + list_t devi_ct; + + /* owned by bus framework */ + devi_bus_priv_t devi_bus; /* bus private data */ + + /* Declarations of the pure dynamic properties to snapshot */ + struct i_ddi_prop_dyn *devi_prop_dyn_driver; /* prop_op */ + struct i_ddi_prop_dyn *devi_prop_dyn_parent; /* bus_prop_op */ + +#if defined(__x86) + /* For x86 (Intel and AMD) IOMMU support */ + void *devi_iommu; + iommulib_handle_t devi_iommulib_handle; + iommulib_nexhandle_t devi_iommulib_nex_handle; +#endif + + /* Generic callback mechanism */ + ddi_cb_t *devi_cb_p; + + /* ndi 'flavors' */ + ndi_flavor_t devi_flavor; /* flavor assigned by parent */ + ndi_flavor_t devi_flavorv_n; /* number of child-flavors */ + void **devi_flavorv; /* child-flavor specific data */ + + /* Owned by hotplug framework */ + struct ddi_hp_cn_handle *devi_hp_hdlp; /* hotplug handle list */ + + struct in_node *devi_in_node; /* pointer to devinfo node's in_node_t */ + + /* detach event data */ + char *devi_ev_path; + int devi_ev_instance; + + /* + * Unbind callback data. + */ + kmutex_t devi_unbind_lock; + list_t devi_unbind_cbs; +}; + +#define DEVI(dev_info_type) ((struct dev_info *)(dev_info_type)) + +/* + * NB: The 'name' field, for compatibility with old code (both existing + * device drivers and userland code), is now defined as the name used + * to bind the node to a device driver, and not the device node name. + * If the device node name does not define a binding to a device driver, + * and the framework uses a different algorithm to create the binding to + * the driver, the node name and binding name will be different. + * + * Note that this implies that the node name plus instance number does + * NOT create a unique driver id; only the binding name plus instance + * number creates a unique driver id. + * + * New code should not use 'devi_name'; use 'devi_binding_name' or + * 'devi_node_name' and/or the routines that access those fields. + */ + +#define devi_name devi_binding_name + +/* + * DDI_CF1, DDI_CF2 and DDI_DRV_UNLOADED are obsolete. They are kept + * around to allow legacy drivers to to compile. + */ +#define DDI_CF1(devi) (DEVI(devi)->devi_addr != NULL) +#define DDI_CF2(devi) (DEVI(devi)->devi_ops != NULL) +#define DDI_DRV_UNLOADED(devi) (DEVI(devi)->devi_ops == &mod_nodev_ops) + +/* + * The device state flags (devi_state) contains information regarding + * the state of the device (Online/Offline/Down). For bus nexus + * devices, the device state also contains state information regarding + * the state of the bus represented by this nexus node. + * + * Device state information is stored in bits [0-7], bus state in bits + * [8-15]. + * + * NOTE: all devi_state updates should be protected by devi_lock. + */ +#define DEVI_DEVICE_OFFLINE 0x00000001 +#define DEVI_DEVICE_DOWN 0x00000002 +#define DEVI_DEVICE_DEGRADED 0x00000004 +#define DEVI_DEVICE_REMOVED 0x00000008 /* hardware removed */ + +#define DEVI_BUS_QUIESCED 0x00000100 +#define DEVI_BUS_DOWN 0x00000200 +#define DEVI_NDI_CONFIG 0x00000400 /* perform config when attaching */ + +#define DEVI_S_ATTACHING 0x00010000 +#define DEVI_S_DETACHING 0x00020000 +#define DEVI_S_ONLINING 0x00040000 +#define DEVI_S_OFFLINING 0x00080000 + +#define DEVI_S_INVOKING_DACF 0x00100000 /* busy invoking a dacf task */ + +#define DEVI_S_UNBOUND 0x00200000 +#define DEVI_S_REPORT 0x08000000 /* report status change */ + +#define DEVI_S_EVADD 0x10000000 /* state of devfs event */ +#define DEVI_S_EVREMOVE 0x20000000 /* state of devfs event */ +#define DEVI_S_NEED_RESET 0x40000000 /* devo_reset should be called */ + +/* + * Device state macros. + * o All SET/CLR/DONE users must protect context with devi_lock. + * o DEVI_SET_DEVICE_ONLINE users must do their own DEVI_SET_REPORT. + * o DEVI_SET_DEVICE_{DOWN|DEGRADED|UP} should only be used when !OFFLINE. + * o DEVI_SET_DEVICE_UP clears DOWN and DEGRADED. + */ +#define DEVI_IS_DEVICE_OFFLINE(dip) \ + ((DEVI(dip)->devi_state & DEVI_DEVICE_OFFLINE) == DEVI_DEVICE_OFFLINE) + +#define DEVI_SET_DEVICE_ONLINE(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + if (DEVI(dip)->devi_state & DEVI_DEVICE_DEGRADED) { \ + mutex_exit(&DEVI(dip)->devi_lock); \ + e_ddi_undegrade_finalize(dip); \ + mutex_enter(&DEVI(dip)->devi_lock); \ + } \ + /* setting ONLINE clears DOWN, DEGRADED, OFFLINE */ \ + DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DOWN | \ + DEVI_DEVICE_DEGRADED | DEVI_DEVICE_OFFLINE); \ + } + +#define DEVI_SET_DEVICE_OFFLINE(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= (DEVI_DEVICE_OFFLINE | DEVI_S_REPORT); \ + } + +#define DEVI_IS_DEVICE_DOWN(dip) \ + ((DEVI(dip)->devi_state & DEVI_DEVICE_DOWN) == DEVI_DEVICE_DOWN) + +#define DEVI_SET_DEVICE_DOWN(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \ + DEVI(dip)->devi_state |= (DEVI_DEVICE_DOWN | DEVI_S_REPORT); \ + } + +#define DEVI_IS_DEVICE_DEGRADED(dip) \ + ((DEVI(dip)->devi_state & \ + (DEVI_DEVICE_DEGRADED|DEVI_DEVICE_DOWN)) == DEVI_DEVICE_DEGRADED) + +#define DEVI_SET_DEVICE_DEGRADED(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \ + mutex_exit(&DEVI(dip)->devi_lock); \ + e_ddi_degrade_finalize(dip); \ + mutex_enter(&DEVI(dip)->devi_lock); \ + DEVI(dip)->devi_state |= (DEVI_DEVICE_DEGRADED | DEVI_S_REPORT); \ + } + +#define DEVI_SET_DEVICE_UP(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \ + if (DEVI(dip)->devi_state & DEVI_DEVICE_DEGRADED) { \ + mutex_exit(&DEVI(dip)->devi_lock); \ + e_ddi_undegrade_finalize(dip); \ + mutex_enter(&DEVI(dip)->devi_lock); \ + } \ + DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DEGRADED | DEVI_DEVICE_DOWN); \ + DEVI(dip)->devi_state |= DEVI_S_REPORT; \ + } + +/* Device removal and insertion */ +#define DEVI_IS_DEVICE_REMOVED(dip) \ + ((DEVI(dip)->devi_state & DEVI_DEVICE_REMOVED) == DEVI_DEVICE_REMOVED) + +#define DEVI_SET_DEVICE_REMOVED(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_DEVICE_REMOVED | DEVI_S_REPORT; \ + } + +#define DEVI_SET_DEVICE_REINSERTED(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_DEVICE_REMOVED; \ + DEVI(dip)->devi_state |= DEVI_S_REPORT; \ + } + +/* Bus state change macros */ +#define DEVI_IS_BUS_QUIESCED(dip) \ + ((DEVI(dip)->devi_state & DEVI_BUS_QUIESCED) == DEVI_BUS_QUIESCED) + +#define DEVI_SET_BUS_ACTIVE(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_BUS_QUIESCED; \ + DEVI(dip)->devi_state |= DEVI_S_REPORT; \ + } + +#define DEVI_SET_BUS_QUIESCE(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= (DEVI_BUS_QUIESCED | DEVI_S_REPORT); \ + } + +#define DEVI_IS_BUS_DOWN(dip) \ + ((DEVI(dip)->devi_state & DEVI_BUS_DOWN) == DEVI_BUS_DOWN) + +#define DEVI_SET_BUS_UP(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_BUS_DOWN; \ + DEVI(dip)->devi_state |= DEVI_S_REPORT; \ + } + +#define DEVI_SET_BUS_DOWN(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= (DEVI_BUS_DOWN | DEVI_S_REPORT); \ + } + +/* Status change report needed */ +#define DEVI_NEED_REPORT(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_REPORT) == DEVI_S_REPORT) + +#define DEVI_SET_REPORT(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_S_REPORT; \ + } + +#define DEVI_REPORT_DONE(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_REPORT; \ + } + +/* Do an NDI_CONFIG for its children */ +#define DEVI_NEED_NDI_CONFIG(dip) \ + ((DEVI(dip)->devi_state & DEVI_NDI_CONFIG) == DEVI_NDI_CONFIG) + +#define DEVI_SET_NDI_CONFIG(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_NDI_CONFIG; \ + } + +#define DEVI_CLR_NDI_CONFIG(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_NDI_CONFIG; \ + } + +/* Attaching or detaching state */ +#define DEVI_IS_ATTACHING(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_ATTACHING) == DEVI_S_ATTACHING) + +#define DEVI_SET_ATTACHING(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_S_ATTACHING; \ + } + +#define DEVI_CLR_ATTACHING(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_ATTACHING; \ + } + +#define DEVI_IS_DETACHING(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_DETACHING) == DEVI_S_DETACHING) + +#define DEVI_SET_DETACHING(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_S_DETACHING; \ + } + +#define DEVI_CLR_DETACHING(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_DETACHING; \ + } + +/* Onlining or offlining state */ +#define DEVI_IS_ONLINING(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_ONLINING) == DEVI_S_ONLINING) + +#define DEVI_SET_ONLINING(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_S_ONLINING; \ + } + +#define DEVI_CLR_ONLINING(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_ONLINING; \ + } + +#define DEVI_IS_OFFLINING(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_OFFLINING) == DEVI_S_OFFLINING) + +#define DEVI_SET_OFFLINING(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_S_OFFLINING; \ + } + +#define DEVI_CLR_OFFLINING(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_OFFLINING; \ + } + +#define DEVI_IS_IN_RECONFIG(dip) \ + (DEVI(dip)->devi_state & (DEVI_S_OFFLINING | DEVI_S_ONLINING)) + +/* Busy invoking a dacf task against this node */ +#define DEVI_IS_INVOKING_DACF(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_INVOKING_DACF) == DEVI_S_INVOKING_DACF) + +#define DEVI_SET_INVOKING_DACF(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_S_INVOKING_DACF; \ + } + +#define DEVI_CLR_INVOKING_DACF(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_INVOKING_DACF; \ + } + +/* Events for add/remove */ +#define DEVI_EVADD(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_EVADD) == DEVI_S_EVADD) + +#define DEVI_SET_EVADD(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_EVREMOVE; \ + DEVI(dip)->devi_state |= DEVI_S_EVADD; \ + } + +#define DEVI_EVREMOVE(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_EVREMOVE) == DEVI_S_EVREMOVE) + +#define DEVI_SET_EVREMOVE(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_EVADD; \ + DEVI(dip)->devi_state |= DEVI_S_EVREMOVE; \ + } + +#define DEVI_SET_EVUNINIT(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~(DEVI_S_EVADD | DEVI_S_EVREMOVE); \ + } + +/* Need to call the devo_reset entry point for this device at shutdown */ +#define DEVI_NEED_RESET(dip) \ + ((DEVI(dip)->devi_state & DEVI_S_NEED_RESET) == DEVI_S_NEED_RESET) + +#define DEVI_SET_NEED_RESET(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state |= DEVI_S_NEED_RESET; \ + } + +#define DEVI_CLR_NEED_RESET(dip) { \ + ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ + DEVI(dip)->devi_state &= ~DEVI_S_NEED_RESET; \ + } + +/* + * devi_flags bits + * + * NOTE: all devi_state updates should be protected by devi_lock. + */ +#define DEVI_BUSY 0x00000001 /* busy configuring children */ +#define DEVI_MADE_CHILDREN 0x00000002 /* children made from specs */ +#define DEVI_ATTACHED_CHILDREN 0x00000004 /* attached all existing children */ +#define DEVI_BRANCH_HELD 0x00000008 /* branch rooted at this dip held */ +#define DEVI_NO_BIND 0x00000010 /* prevent driver binding */ +#define DEVI_CACHED_DEVID 0x00000020 /* devid cached in devid cache */ +#define DEVI_PHCI_SIGNALS_VHCI 0x00000040 /* pHCI ndi_devi_exit signals vHCI */ +#define DEVI_REBIND 0x00000080 /* post initchild driver rebind */ +#define DEVI_RETIRED 0x00000100 /* device is retired */ +#define DEVI_RETIRING 0x00000200 /* being evaluated for retire */ +#define DEVI_R_CONSTRAINT 0x00000400 /* constraints have been applied */ +#define DEVI_R_BLOCKED 0x00000800 /* constraints block retire */ +#define DEVI_CT_NOP 0x00001000 /* NOP contract event occurred */ +#define DEVI_PCI_DEVICE 0x00002000 /* dip is PCI */ + +#define DEVI_BUSY_CHANGING(dip) (DEVI(dip)->devi_flags & DEVI_BUSY) +#define DEVI_BUSY_OWNED(dip) (DEVI_BUSY_CHANGING(dip) && \ + ((DEVI(dip))->devi_busy_thread == curthread)) + +#define DEVI_IS_PCI(dip) (DEVI(dip)->devi_flags & DEVI_PCI_DEVICE) +#define DEVI_SET_PCI(dip) (DEVI(dip)->devi_flags |= (DEVI_PCI_DEVICE)) + +char *i_ddi_devi_class(dev_info_t *); +int i_ddi_set_devi_class(dev_info_t *, const char *, int); + +/* + * This structure represents one piece of bus space occupied by a given + * device. It is used in an array for devices with multiple address windows. + */ +struct regspec { + uint_t regspec_bustype; /* cookie for bus type it's on */ + uint_t regspec_addr; /* address of reg relative to bus */ + uint_t regspec_size; /* size of this register set */ +}; + +/* + * This is a version of the above structure that works for 64-bit mappings and + * doesn't rely on overloading of fields as is done on SPARC. Eventually the + * struct regspec should be replaced with this. + */ +struct regspec64 { + uint64_t regspec_bustype; /* cookie for bus type it's on */ + uint64_t regspec_addr; /* address of reg relative to bus */ + uint64_t regspec_size; /* size of this register set */ +}; + +/* + * This structure represents one piece of nexus bus space. + * It is used in an array for nexi with multiple bus spaces + * to define the childs offsets in the parents bus space. + */ +struct rangespec { + uint_t rng_cbustype; /* Child's address, hi order */ + uint_t rng_coffset; /* Child's address, lo order */ + uint_t rng_bustype; /* Parent's address, hi order */ + uint_t rng_offset; /* Parent's address, lo order */ + uint_t rng_size; /* size of space for this entry */ +}; + +#ifdef _KERNEL + +typedef enum { + DDI_PRE = 0, + DDI_POST = 1 +} ddi_pre_post_t; + +/* + * This structure represents notification of a child attach event + * These could both be the same if attach/detach commands were in the + * same name space. + * Note that the target dip is passed as an arg already. + */ +struct attachspec { + ddi_attach_cmd_t cmd; /* type of event */ + ddi_pre_post_t when; /* one of DDI_PRE or DDI_POST */ + dev_info_t *pdip; /* parent of attaching node */ + int result; /* result of attach op (post command only) */ +}; + +/* + * This structure represents notification of a child detach event + * Note that the target dip is passed as an arg already. + */ +struct detachspec { + ddi_detach_cmd_t cmd; /* type of event */ + ddi_pre_post_t when; /* one of DDI_PRE or DDI_POST */ + dev_info_t *pdip; /* parent of detaching node */ + int result; /* result of detach op (post command only) */ +}; + +#endif /* _KERNEL */ + +typedef enum { + DDM_MINOR = 0, + DDM_ALIAS, + DDM_DEFAULT, + DDM_INTERNAL_PATH +} ddi_minor_type; + +/* implementation flags for driver specified device access control */ +#define DM_NO_FSPERM 0x1 + +struct devplcy; + +struct ddi_minor { + char *name; /* name of node */ + dev_t dev; /* device number */ + int spec_type; /* block or char */ + int flags; /* access flags */ + const char *node_type; /* block, byte, serial, network */ + struct devplcy *node_priv; /* privilege for this minor */ + mode_t priv_mode; /* default apparent privilege mode */ +}; + +/* + * devi_node_attributes contains node attributes private to the + * ddi implementation. As a consumer, do not use these bit definitions + * directly, use the ndi functions that check for the existence of the + * specific node attributes. + * + * DDI_PERSISTENT indicates a 'persistent' node; one that is not + * automatically freed by the framework if the driver is unloaded + * or the driver fails to attach to this node. + * + * DDI_AUTO_ASSIGNED_NODEID indicates that the nodeid was auto-assigned + * by the framework and should be auto-freed if the node is removed. + * + * DDI_VHCI_NODE indicates that the node type is VHCI. This flag + * must be set by ndi_devi_config_vhci() routine only. + * + * DDI_HIDDEN_NODE indicates that the node should not show up in snapshots + * or in /devices. + * + * DDI_HOTPLUG_NODE indicates that the node created by nexus hotplug. + */ +#define DDI_PERSISTENT 0x01 +#define DDI_AUTO_ASSIGNED_NODEID 0x02 +#define DDI_VHCI_NODE 0x04 +#define DDI_HIDDEN_NODE 0x08 +#define DDI_HOTPLUG_NODE 0x10 + +#define DEVI_VHCI_NODE(dip) \ + (DEVI(dip)->devi_node_attributes & DDI_VHCI_NODE) + +/* + * The ddi_minor_data structure gets filled in by ddi_create_minor_node. + * It then gets attached to the devinfo node as a property. + */ +struct ddi_minor_data { + struct ddi_minor_data *next; /* next one in the chain */ + dev_info_t *dip; /* pointer to devinfo node */ + ddi_minor_type type; /* Following data type */ + struct ddi_minor d_minor; /* Actual minor node data */ +}; + +#define ddm_name d_minor.name +#define ddm_dev d_minor.dev +#define ddm_flags d_minor.flags +#define ddm_spec_type d_minor.spec_type +#define ddm_node_type d_minor.node_type +#define ddm_node_priv d_minor.node_priv +#define ddm_priv_mode d_minor.priv_mode + +/* + * parent private data structure contains register, interrupt, property + * and range information. + */ +struct ddi_parent_private_data { + int par_nreg; /* number of regs */ + struct regspec *par_reg; /* array of regs */ + int par_nintr; /* number of interrupts */ + struct intrspec *par_intr; /* array of possible interrupts */ + int par_nrng; /* number of ranges */ + struct rangespec *par_rng; /* array of ranges */ +}; +#define DEVI_PD(d) \ + ((struct ddi_parent_private_data *)DEVI((d))->devi_parent_data) + +#define sparc_pd_getnreg(dev) (DEVI_PD(dev)->par_nreg) +#define sparc_pd_getnintr(dev) (DEVI_PD(dev)->par_nintr) +#define sparc_pd_getnrng(dev) (DEVI_PD(dev)->par_nrng) +#define sparc_pd_getreg(dev, n) (&DEVI_PD(dev)->par_reg[(n)]) +#define sparc_pd_getintr(dev, n) (&DEVI_PD(dev)->par_intr[(n)]) +#define sparc_pd_getrng(dev, n) (&DEVI_PD(dev)->par_rng[(n)]) + +#ifdef _KERNEL +/* + * This data structure is private to the indexed soft state allocator. + */ +typedef struct i_ddi_soft_state { + void **array; /* the array of pointers */ + kmutex_t lock; /* serialize access to this struct */ + size_t size; /* how many bytes per state struct */ + size_t n_items; /* how many structs herein */ + struct i_ddi_soft_state *next; /* 'dirty' elements */ +} i_ddi_soft_state; + +/* + * This data structure is private to the stringhashed soft state allocator. + */ +typedef struct i_ddi_soft_state_bystr { + size_t ss_size; /* how many bytes per state struct */ + mod_hash_t *ss_mod_hash; /* hash implementation */ +} i_ddi_soft_state_bystr; + +/* + * This data structure is private to the ddi_strid_* implementation + */ +typedef struct i_ddi_strid { + size_t strid_chunksz; + size_t strid_spacesz; + id_space_t *strid_space; + mod_hash_t *strid_byid; + mod_hash_t *strid_bystr; +} i_ddi_strid; +#endif /* _KERNEL */ + +/* + * Solaris DDI DMA implementation structure and function definitions. + * + * Note: no callers of DDI functions must depend upon data structures + * declared below. They are not guaranteed to remain constant. + */ + +/* + * Implementation DMA mapping structure. + * + * The publicly visible ddi_dma_req structure is filled + * in by a caller that wishes to map a memory object + * for DMA. Internal to this implementation of the public + * DDI DMA functions this request structure is put together + * with bus nexus specific functions that have additional + * information and constraints as to how to go about doing + * the requested mapping function + * + * In this implementation, some of the information from the + * original requester is retained throughout the lifetime + * of the I/O mapping being active. + */ + +/* + * This is the implementation specific description + * of how we've mapped an object for DMA. + */ +#if defined(__sparc) +typedef struct ddi_dma_impl { + /* + * DMA mapping information + */ + ulong_t dmai_mapping; /* mapping cookie */ + + /* + * Size of the current mapping, in bytes. + * + * Note that this is distinct from the size of the object being mapped + * for DVMA. We might have only a portion of the object mapped at any + * given point in time. + */ + uint_t dmai_size; + + /* + * Offset, in bytes, into object that is currently mapped. + */ + off_t dmai_offset; + + /* + * Information gathered from the original DMA mapping + * request and saved for the lifetime of the mapping. + */ + uint_t dmai_minxfer; + uint_t dmai_burstsizes; + uint_t dmai_ndvmapages; + uint_t dmai_pool; /* cached DVMA space */ + uint_t dmai_rflags; /* requester's flags + ours */ + uint_t dmai_inuse; /* active handle? */ + uint_t dmai_nwin; + uint_t dmai_winsize; + uint_t dmai_ncookies; + uint_t dmai_curcookie; + caddr_t dmai_nexus_private; + void *dmai_iopte; + uint_t *dmai_sbi; + void *dmai_minfo; /* random mapping information */ + dev_info_t *dmai_rdip; /* original requester's dev_info_t */ + ddi_dma_obj_t dmai_object; /* requester's object */ + ddi_dma_attr_t dmai_attr; /* DMA attributes */ + ddi_dma_cookie_t *dmai_cookie; /* pointer to first DMA cookie */ + + int (*dmai_fault_check)(struct ddi_dma_impl *handle); + void (*dmai_fault_notify)(struct ddi_dma_impl *handle); + int dmai_fault; + ndi_err_t dmai_error; + +} ddi_dma_impl_t; + +#elif defined(__x86) + +/* + * ddi_dma_impl portion that genunix (sunddi.c) depends on. x86 rootnex + * implementation specific state is in dmai_private. + */ +typedef struct ddi_dma_impl { + ddi_dma_cookie_t *dmai_cookie; /* array of DMA cookies */ + uint_t dmai_ncookies; + uint_t dmai_curcookie; + void *dmai_private; + + /* + * Information gathered from the original dma mapping + * request and saved for the lifetime of the mapping. + */ + uint_t dmai_minxfer; + uint_t dmai_burstsizes; + uint_t dmai_rflags; /* requester's flags + ours */ + int dmai_nwin; + dev_info_t *dmai_rdip; /* original requester's dev_info_t */ + + ddi_dma_attr_t dmai_attr; /* DMA attributes */ + + int (*dmai_fault_check)(struct ddi_dma_impl *handle); + void (*dmai_fault_notify)(struct ddi_dma_impl *handle); + int dmai_fault; + ndi_err_t dmai_error; +} ddi_dma_impl_t; + +#else +#error "struct ddi_dma_impl not defined for this architecture" +#endif /* defined(__sparc) */ + +/* + * For now DMA segments share state with the DMA handle + */ +typedef ddi_dma_impl_t ddi_dma_seg_impl_t; + +/* + * These flags use reserved bits from the dma request flags. + * + * A note about the DMP_NOSYNC flags: the root nexus will + * set these as it sees best. If an intermediate nexus + * actually needs these operations, then during the unwind + * from the call to ddi_dma_bind, the nexus driver *must* + * clear the appropriate flag(s). This is because, as an + * optimization, ddi_dma_sync(9F) looks at these flags before + * deciding to spend the time going back up the tree. + */ + +#define _DMCM1 DDI_DMA_RDWR|DDI_DMA_REDZONE|DDI_DMA_PARTIAL +#define _DMCM2 DDI_DMA_CONSISTENT|DMP_VMEREQ +#define DMP_DDIFLAGS (_DMCM1|_DMCM2) +#define DMP_SHADOW 0x20 +#define DMP_LKIOPB 0x40 +#define DMP_LKSYSV 0x80 +#define DMP_IOCACHE 0x100 +#define DMP_USEHAT 0x200 +#define DMP_PHYSADDR 0x400 +#define DMP_INVALID 0x800 +#define DMP_NOLIMIT 0x1000 +#define DMP_VMEREQ 0x10000000 +#define DMP_BYPASSNEXUS 0x20000000 +#define DMP_NODEVSYNC 0x40000000 +#define DMP_NOCPUSYNC 0x80000000 +#define DMP_NOSYNC (DMP_NODEVSYNC|DMP_NOCPUSYNC) + +/* + * In order to complete a device to device mapping that + * has percolated as high as an IU nexus (gone that high + * because the DMA request is a VADDR type), we define + * structure to use with the DDI_CTLOPS_DMAPMAPC request + * that re-traverses the request tree to finish the + * DMA 'mapping' for a device. + */ +struct dma_phys_mapc { + struct ddi_dma_req *dma_req; /* original request */ + ddi_dma_impl_t *mp; /* current handle, or none */ + int nptes; /* number of ptes */ + void *ptes; /* ptes already read */ +}; + +#define MAXCALLBACK 20 + +/* + * Callback definitions + */ +struct ddi_callback { + struct ddi_callback *c_nfree; + struct ddi_callback *c_nlist; + int (*c_call)(); + int c_count; + caddr_t c_arg; + size_t c_size; +}; + +/* + * Pure dynamic property declaration. A pure dynamic property is a property + * for which a driver's prop_op(9E) implementation will return a value on + * demand, but the property name does not exist on a property list (global, + * driver, system, or hardware) - the person asking for the value must know + * the name and type information. + * + * For a pure dynamic property to show up in a di_init() devinfo shapshot, the + * devinfo driver must know name and type. The i_ddi_prop_dyn_t mechanism + * allows a driver to define an array of the name/type information of its + * dynamic properties. When a driver declares its dynamic properties in a + * i_ddi_prop_dyn_t array, and registers that array using + * i_ddi_prop_dyn_driver_set() the devinfo driver has sufficient information + * to represent the properties in a snapshot - calling the driver's + * prop_op(9E) to obtain values. + * + * The last element of a i_ddi_prop_dyn_t is detected via a NULL dp_name value. + * + * A pure dynamic property name associated with a minor_node/dev_t should be + * defined with a dp_spec_type of S_IFCHR or S_IFBLK, as appropriate. The + * driver's prop_op(9E) entry point will be called for all + * ddi_create_minor_node(9F) nodes of the specified spec_type. For a driver + * where not all minor_node/dev_t combinations support the same named + * properties, it is the responsibility of the prop_op(9E) implementation to + * sort out what combinations are appropriate. + * + * A pure dynamic property of a devinfo node should be defined with a + * dp_spec_type of 0. + * + * NB: Public DDI property interfaces no longer support pure dynamic + * properties, but they are still still used. A prime example is the cmlb + * implementation of size(9P) properties. Using pure dynamic properties + * reduces the space required to maintain per-partition information. Since + * there are no public interfaces to create pure dynamic properties, + * the i_ddi_prop_dyn_t mechanism should remain private. + */ +typedef struct i_ddi_prop_dyn { + char *dp_name; /* name of dynamic property */ + int dp_type; /* DDI_PROP_TYPE_ of property */ + int dp_spec_type; /* 0, S_IFCHR, S_IFBLK */ +} i_ddi_prop_dyn_t; +void i_ddi_prop_dyn_driver_set(dev_info_t *, + i_ddi_prop_dyn_t *); +i_ddi_prop_dyn_t *i_ddi_prop_dyn_driver_get(dev_info_t *); +void i_ddi_prop_dyn_parent_set(dev_info_t *, + i_ddi_prop_dyn_t *); +i_ddi_prop_dyn_t *i_ddi_prop_dyn_parent_get(dev_info_t *); +void i_ddi_prop_dyn_cache_invalidate(dev_info_t *, + i_ddi_prop_dyn_t *); + +/* + * Device id - Internal definition. + */ +#define DEVID_MAGIC_MSB 0x69 +#define DEVID_MAGIC_LSB 0x64 +#define DEVID_REV_MSB 0x00 +#define DEVID_REV_LSB 0x01 +#define DEVID_HINT_SIZE 4 + +typedef struct impl_devid { + uchar_t did_magic_hi; /* device id magic # (msb) */ + uchar_t did_magic_lo; /* device id magic # (lsb) */ + uchar_t did_rev_hi; /* device id revision # (msb) */ + uchar_t did_rev_lo; /* device id revision # (lsb) */ + uchar_t did_type_hi; /* device id type (msb) */ + uchar_t did_type_lo; /* device id type (lsb) */ + uchar_t did_len_hi; /* length of devid data (msb) */ + uchar_t did_len_lo; /* length of devid data (lsb) */ + char did_driver[DEVID_HINT_SIZE]; /* driver name - HINT */ + char did_id[1]; /* start of device id data */ +} impl_devid_t; + +#define DEVID_GETTYPE(devid) ((ushort_t) \ + (((devid)->did_type_hi << NBBY) + \ + (devid)->did_type_lo)) + +#define DEVID_FORMTYPE(devid, type) (devid)->did_type_hi = hibyte((type)); \ + (devid)->did_type_lo = lobyte((type)); + +#define DEVID_GETLEN(devid) ((ushort_t) \ + (((devid)->did_len_hi << NBBY) + \ + (devid)->did_len_lo)) + +#define DEVID_FORMLEN(devid, len) (devid)->did_len_hi = hibyte((len)); \ + (devid)->did_len_lo = lobyte((len)); + +/* + * Per PSARC/1995/352, a binary devid contains fields for , + * , , , , and the itself. + * This proposal would encode the binary devid into a string consisting + * of ",@" as indicated below + * ( is rederived from the length of the string + * representation of the ): + * + * ->"id" + * + * ->"%d" // "0" -> type of DEVID_NONE "id0" + * // NOTE: PSARC/1995/352 is "1". + * // NOTE: support limited to 10 revisions + * // in current implementation + * + * ->"%s" // "sd"/"ssd" + * // NOTE: driver names limited to 4 + * // characters for "1" + * + * ->'w' | // DEVID_SCSI3_WWN + * 'W' | // DEVID_SCSI3_WWN + * 't' | // DEVID_SCSI3_VPD_T10 + * 'T' | // DEVID_SCSI3_VPD_T10 + * 'x' | // DEVID_SCSI3_VPD_EUI + * 'X' | // DEVID_SCSI3_VPD_EUI + * 'n' | // DEVID_SCSI3_VPD_NAA + * 'N' | // DEVID_SCSI3_VPD_NAA + * 's' | // DEVID_SCSI_SERIAL + * 'S' | // DEVID_SCSI_SERIAL + * 'f' | // DEVID_FAB + * 'F' | // DEVID_FAB + * 'e' | // DEVID_ENCAP + * 'E' | // DEVID_ENCAP + * 'a' | // DEVID_ATA_SERIAL + * 'A' | // DEVID_ATA_SERIAL + * 'd' | // DEVID_NVME_NSID + * 'D' | // DEVID_NVME_NSID + * 'i' | // DEVID_NVME_EUI64 + * 'I' | // DEVID_NVME_EUI64 + * 'g' | // DEVID_NVME_NGUID + * 'G' | // DEVID_NVME_NGUID + * 'u' | // unknown + * 'U' // unknown + * // NOTE:lower case -> + * // upper case -> + * // NOTE:this covers all types currently + * // defined for 1. + * // NOTE:a can be added + * // without changing the . + * + * -> | // is upper case + * // is lower case + * + * // only if all bytes of binary field + * // are in the set: + * // [A-Z][a-z][0-9]+-.= and space and 0x00 + * // the encoded form is: + * // [A-Z][a-z][0-9]+-.= and _ and ~ + * // NOTE: ' ' <=> '_', 0x00 <=> '~' + * // these sets are chosen to avoid shell + * // and conflicts with DDI node names. + * + * // if not ; each byte of binary + * // maps a to 2 digit ascii hex + * // representation in the string. + * + * This encoding provides a meaningful correlation between the /devices + * path and the devid string where possible. + * + * Fibre: + * sbus@6,0/SUNW,socal@d,10000/sf@1,0/ssd@w21000020370bb488,0:c,raw + * id1,ssd@w20000020370bb488:c,raw + * + * Copper: + * sbus@7,0/SUNW,fas@3,8800000/sd@a,0:c + * id1,sd@SIBM_____1XY210__________:c + */ +/* determine if a byte of an id meets ASCII representation requirements */ +#define DEVID_IDBYTE_ISASCII(b) ( \ + (((b) >= 'a') && ((b) <= 'z')) || \ + (((b) >= 'A') && ((b) <= 'Z')) || \ + (((b) >= '0') && ((b) <= '9')) || \ + (b == '+') || (b == '-') || (b == '.') || (b == '=') || \ + (b == ' ') || (b == 0x00)) + +/* set type to lower case to indicate that the did_id field is ascii */ +#define DEVID_TYPE_SETASCII(c) (c - 0x20) /* 'a' -> 'A' */ + +/* determine from type if did_id field is binary or ascii */ +#define DEVID_TYPE_ISASCII(c) (((c) >= 'A') && ((c) <= 'Z')) + +/* convert type field from binary to ascii */ +#define DEVID_TYPE_BINTOASCII(b) ( \ + ((b) == DEVID_SCSI3_WWN) ? 'w' : \ + ((b) == DEVID_SCSI3_VPD_T10) ? 't' : \ + ((b) == DEVID_SCSI3_VPD_EUI) ? 'x' : \ + ((b) == DEVID_SCSI3_VPD_NAA) ? 'n' : \ + ((b) == DEVID_SCSI_SERIAL) ? 's' : \ + ((b) == DEVID_FAB) ? 'f' : \ + ((b) == DEVID_ENCAP) ? 'e' : \ + ((b) == DEVID_ATA_SERIAL) ? 'a' : \ + ((b) == DEVID_NVME_NSID) ? 'd' : \ + ((b) == DEVID_NVME_EUI64) ? 'i' : \ + ((b) == DEVID_NVME_NGUID) ? 'g' : \ + 'u') /* unknown */ + +/* convert type field from ascii to binary */ +#define DEVID_TYPE_ASCIITOBIN(c) ( \ + (((c) == 'w') || ((c) == 'W')) ? DEVID_SCSI3_WWN : \ + (((c) == 't') || ((c) == 'T')) ? DEVID_SCSI3_VPD_T10 : \ + (((c) == 'x') || ((c) == 'X')) ? DEVID_SCSI3_VPD_EUI : \ + (((c) == 'n') || ((c) == 'N')) ? DEVID_SCSI3_VPD_NAA : \ + (((c) == 's') || ((c) == 'S')) ? DEVID_SCSI_SERIAL : \ + (((c) == 'f') || ((c) == 'F')) ? DEVID_FAB : \ + (((c) == 'e') || ((c) == 'E')) ? DEVID_ENCAP : \ + (((c) == 'a') || ((c) == 'A')) ? DEVID_ATA_SERIAL : \ + (((c) == 'd') || ((c) == 'D')) ? DEVID_NVME_NSID : \ + (((c) == 'i') || ((c) == 'I')) ? DEVID_NVME_EUI64 : \ + (((c) == 'g') || ((c) == 'G')) ? DEVID_NVME_NGUID : \ + DEVID_MAXTYPE +1) /* unknown */ + +/* determine if the type should be forced to hex encoding (non-ascii) */ +#define DEVID_TYPE_BIN_FORCEHEX(b) ( \ + ((b) == DEVID_SCSI3_WWN) || \ + ((b) == DEVID_SCSI3_VPD_EUI) || \ + ((b) == DEVID_SCSI3_VPD_NAA) || \ + ((b) == DEVID_NVME_EUI64) || \ + ((b) == DEVID_NVME_NGUID) || \ + ((b) == DEVID_FAB)) + +/* determine if the type is from a scsi3 vpd */ +#define IS_DEVID_SCSI3_VPD_TYPE(b) ( \ + ((b) == DEVID_SCSI3_VPD_T10) || \ + ((b) == DEVID_SCSI3_VPD_EUI) || \ + ((b) == DEVID_SCSI3_VPD_NAA)) + +/* convert rev field from binary to ascii (only supports 10 revs) */ +#define DEVID_REV_BINTOASCII(b) (b + '0') + +/* convert rev field from ascii to binary (only supports 10 revs) */ +#define DEVID_REV_ASCIITOBIN(c) (c - '0') + +/* name of devid property */ +#define DEVID_PROP_NAME "devid" + +/* + * prop_name used by pci_{save,restore}_config_regs() + */ +#define SAVED_CONFIG_REGS "pci-config-regs" +#define SAVED_CONFIG_REGS_MASK "pcie-config-regs-mask" +#define SAVED_CONFIG_REGS_CAPINFO "pci-cap-info" + +typedef struct pci_config_header_state { + uint16_t chs_command; + uint8_t chs_cache_line_size; + uint8_t chs_latency_timer; + uint8_t chs_header_type; + uint8_t chs_sec_latency_timer; + uint8_t chs_bridge_control; + uint32_t chs_base0; + uint32_t chs_base1; + uint32_t chs_base2; + uint32_t chs_base3; + uint32_t chs_base4; + uint32_t chs_base5; +} pci_config_header_state_t; + +#ifdef _KERNEL + +typedef struct pci_cap_save_desc { + uint16_t cap_offset; + uint16_t cap_id; + uint32_t cap_nregs; +} pci_cap_save_desc_t; + +typedef struct pci_cap_entry { + uint16_t cap_id; + uint16_t cap_reg; + uint16_t cap_mask; + uint32_t cap_ndwords; + uint32_t (*cap_save_func)(ddi_acc_handle_t confhdl, uint16_t cap_ptr, + uint32_t *regbuf, uint32_t ndwords); +} pci_cap_entry_t; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_IMPLDEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_implfuncs.h b/illumos-x86_64/usr/include/sys/ddi_implfuncs.h new file mode 100644 index 00000000..cb1b8510 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_implfuncs.h @@ -0,0 +1,253 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2012 Garrett D'Amore . All rights reserved. + * Copyright 2020 Joshua M. Clulow + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_DDI_IMPLFUNCS_H +#define _SYS_DDI_IMPLFUNCS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +#ifdef _KERNEL + +/* + * Declare implementation functions that sunddi functions can call in order to + * perform their required task. Each kernel architecture must provide them. + */ +extern int i_ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, + off_t offset, off_t len, caddr_t *vaddrp); +extern int i_ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, + struct regspec *rp); +extern struct regspec *i_ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber); +extern int i_ddi_map_fault(dev_info_t *dip, dev_info_t *rdip, + struct hat *hat, struct seg *seg, caddr_t addr, + struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock); + +/* + * Implementation-specific memory allocation and de-allocation routines + */ +extern int i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attributes, + size_t length, int cansleep, int streaming, + const ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, + size_t *real_length, ddi_acc_hdl_t *handlep); +extern void i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap); + +extern int i_ddi_devi_get_ppa(dev_info_t *); +extern void i_ddi_devi_set_ppa(dev_info_t *, int); + +extern void i_ddi_devacc_to_hatacc(const ddi_device_acc_attr_t *devaccp, + uint_t *hataccp); +extern void i_ddi_cacheattr_to_hatacc(uint_t flags, uint_t *hataccp); +extern boolean_t i_ddi_check_cache_attr(uint_t flags); + +/* + * Access and DMA handle fault set/clear routines + */ +extern void i_ddi_acc_set_fault(ddi_acc_handle_t handle); +extern void i_ddi_acc_clr_fault(ddi_acc_handle_t handle); +extern void i_ddi_dma_set_fault(ddi_dma_handle_t handle); +extern void i_ddi_dma_clr_fault(ddi_dma_handle_t handle); + +/* + * Event-handling functions for rootnex. + * These provide the standard implementation of fault handling. + */ +extern void i_ddi_rootnex_init_events(dev_info_t *); +extern int i_ddi_rootnex_get_eventcookie(dev_info_t *, dev_info_t *, char *, + ddi_eventcookie_t *); +extern int i_ddi_rootnex_add_eventcall(dev_info_t *, dev_info_t *, + ddi_eventcookie_t, ddi_event_cb_f, void *, ddi_callback_id_t *); +extern int i_ddi_rootnex_remove_eventcall(dev_info_t *, ddi_callback_id_t); +extern int i_ddi_rootnex_post_event(dev_info_t *, dev_info_t *, + ddi_eventcookie_t, void *); + +/* + * Search and return properties from the PROM + */ +extern int impl_ddi_bus_prop_op(dev_t, dev_info_t *, dev_info_t *, + ddi_prop_op_t, int, char *, caddr_t, int *); + +/* + * Copy an integer from PROM to native machine representation + */ +extern int impl_ddi_prop_int_from_prom(uchar_t *intp, int n); + +extern int impl_ddi_sunbus_initchild(dev_info_t *); +extern void impl_ddi_sunbus_removechild(dev_info_t *); + +/* + * Implementation-specific access handle allocator and init. routines + */ +extern ddi_acc_handle_t impl_acc_hdl_alloc(int (*waitfp)(caddr_t), + caddr_t arg); +extern void impl_acc_hdl_free(ddi_acc_handle_t handle); +extern ddi_acc_hdl_t *impl_acc_hdl_get(ddi_acc_handle_t handle); +extern void impl_acc_hdl_init(ddi_acc_hdl_t *hp); + +/* + * Access error handling support + */ +extern void impl_acc_err_init(ddi_acc_hdl_t *); +extern int impl_dma_check(dev_info_t *, const void *, const void *, + const void *); +extern int i_ddi_ontrap(ddi_acc_handle_t); +extern void i_ddi_notrap(ddi_acc_handle_t); +extern int i_ddi_prot_trampoline(void); +extern int i_ddi_caut_trampoline(void); + +/* + * misc/bootdev entry points - these are private routines and subject + * to change + */ +extern int i_devname_to_promname(char *dev_name, char *ret_buf, size_t); +extern int i_promname_to_devname(char *prom_name, char *ret_buf); +extern char *i_convert_boot_device_name(char *, char *, size_t *); + +/* + * Nodeid management + */ +extern void impl_ddi_init_nodeid(void); +extern int impl_ddi_alloc_nodeid(int *); +extern int impl_ddi_take_nodeid(int, int); +extern void impl_ddi_free_nodeid(int); + +/* + * minorname/devtspectype conversions + */ +extern char *i_ddi_devtspectype_to_minorname(dev_info_t *, dev_t, int); +extern int i_ddi_minorname_to_devtspectype(dev_info_t *, const char *, dev_t *, + int *); + +/* + * Routines in ddi_v9_asm.s + */ +extern int do_peek(size_t, void *, void *); +extern int do_poke(size_t, void *, void *); +extern void peek_fault(void); +extern void poke_fault(void); +extern int peekpoke_mem(ddi_ctl_enum_t, peekpoke_ctlops_t *); + +/* + * Helper functions + */ +extern char *i_ddi_strdup(const char *, uint_t); +extern void i_ddi_prop_list_delete(ddi_prop_t *); +extern ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t); +extern int i_ddi_load_drvconf(major_t); +extern int i_ddi_unload_drvconf(major_t); +extern ddi_node_state_t i_ddi_node_state(dev_info_t *); +extern int i_ddi_devi_attached(dev_info_t *); +extern void i_ddi_parse_name(char *, char **, char **, char **); +extern void i_ddi_set_node_state(dev_info_t *, ddi_node_state_t); +extern int i_ddi_detach_installed_driver(major_t, int); +extern void i_ddi_set_binding_name(dev_info_t *, char *); +extern void i_ddi_bind_devs(void); +extern int i_ddi_unbind_devs_by_alias(major_t, char *); +extern void i_ddi_unbind_devs(major_t); +extern ddi_prop_list_t *i_ddi_prop_list_create(ddi_prop_t *); +struct devnames; +extern void i_ddi_prop_list_hold(ddi_prop_list_t *, struct devnames *); +extern void i_ddi_prop_list_rele(ddi_prop_list_t *, struct devnames *); +extern ddi_prop_t *i_ddi_prop_search(dev_t, char *, uint_t, ddi_prop_t **); +extern int resolve_pathname(const char *, dev_info_t **, dev_t *, int *); +extern int i_ddi_prompath_to_devfspath(char *, char *); +extern int i_ddi_attach_node_hierarchy(dev_info_t *); +extern dev_info_t *i_ddi_attach_pseudo_node(char *); +extern int i_ddi_attach_hw_nodes(char *); +extern int i_ddi_devs_attached(major_t); +extern int i_ddi_minor_node_count(dev_info_t *, const char *); +extern int ddi_is_pci_dip(dev_info_t *dip); + +/* + * Non-DDI functions: wrapper around mod_hold/rele_dev_by_major() + */ +extern struct dev_ops *ddi_hold_driver(major_t); +extern void ddi_rele_driver(major_t); + +/* + * /etc/devices cache files management + */ +extern void i_ddi_devices_init(void); +extern void i_ddi_read_devices_files(void); +extern void i_ddi_clean_devices_files(void); + +/* + * devid cache + */ +extern void devid_cache_init(void); +extern void devid_cache_read(void); +extern void devid_cache_cleanup(void); +extern int i_ddi_devi_get_devid(dev_t, dev_info_t *, ddi_devid_t *); +extern int e_ddi_devid_discovery(ddi_devid_t); +extern int e_devid_cache_register(dev_info_t *, ddi_devid_t); +extern void e_devid_cache_unregister(dev_info_t *); +extern int e_devid_cache_to_devt_list(ddi_devid_t, const char *, int *, + dev_t **); +extern void e_devid_cache_free_devt_list(int, dev_t *); + +/* + * I/O retire persistent store + */ +extern void retire_store_init(void); +extern void retire_store_read(void); +extern int e_ddi_retire_persist(char *); +extern int e_ddi_retire_unpersist(char *); +extern int e_ddi_device_retired(char *); + +/* + * Resource control functions to lock down device memory + */ +extern int i_ddi_incr_locked_memory(proc_t *, rctl_qty_t); +extern void i_ddi_decr_locked_memory(proc_t *, rctl_qty_t); + +/* + * Support routine for file systems that need to scan block devices searching + * for a label as part of mounting the root file system. + */ +extern void preroot_walk_block_devices(int (*)(const char *, void *), void *); + +#define PREROOT_WALK_BLOCK_DEVICES_NEXT 1 +#define PREROOT_WALK_BLOCK_DEVICES_CANCEL 2 + + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_IMPLFUNCS_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_intr.h b/illumos-x86_64/usr/include/sys/ddi_intr.h new file mode 100644 index 00000000..8a71a2d7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_intr.h @@ -0,0 +1,332 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_DDI_INTR_H +#define _SYS_DDI_INTR_H + +/* + * Sun DDI interrupt support definitions + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Interrupt related definitions. + */ + +/* + * Returned by ddi_add_intr or ddi_add_fastintr in order to signal + * the the caller requested interrupt number to be added does not + * exist. + */ +#define DDI_INTR_NOTFOUND 1 /* interrupt not found error */ + +/* + * For use by driver interrupt service routines to return to the + * system whether an interrupt was for the driver or not. + */ +#define DDI_INTR_CLAIMED 1 /* returned when driver claims intr */ +#define DDI_INTR_UNCLAIMED 0 /* returned when driver does not */ + +/* Hardware interrupt types */ +#define DDI_INTR_TYPE_FIXED 0x1 +#define DDI_INTR_TYPE_MSI 0x2 +#define DDI_INTR_TYPE_MSIX 0x4 + +/* Hardware interrupt priority must be a number within these min/max values */ +#define DDI_INTR_PRI_MIN 1 +#define DDI_INTR_PRI_MAX 12 + +/* Soft priority must be a number within these min/max values */ +#define DDI_INTR_SOFTPRI_MIN 1 +#define DDI_INTR_SOFTPRI_MAX 9 + +/* Used in calls to allocate soft interrupt priority. */ +#define DDI_INTR_SOFTPRI_DEFAULT DDI_INTR_SOFTPRI_MIN + +/* + * Interrupt flags specify certain capabilities for a given + * interrupt (by type and inum). + * RO/RW refer to use by ddi_intr_set_cap(9f) + * + * DDI_INTR_FLAG_MSI64 is an internal flag not exposed to leaf drivers. + */ +#define DDI_INTR_FLAG_LEVEL 0x0001 /* (RW) level trigger */ +#define DDI_INTR_FLAG_EDGE 0x0002 /* (RW) edge triggered */ +#define DDI_INTR_FLAG_MASKABLE 0x0010 /* (RO) maskable */ +#define DDI_INTR_FLAG_PENDING 0x0020 /* (RO) int pending supported */ +#define DDI_INTR_FLAG_BLOCK 0x0100 /* (RO) requires block enable */ +#define DDI_INTR_FLAG_MSI64 0x0200 /* (RO) MSI/X supports 64 bit addr */ + +/* + * Macro to be used while passing interrupt priority + * for lock initialization. + */ +#define DDI_INTR_PRI(pri) (void *)((uintptr_t)(pri)) + +/* + * Typedef for interrupt handles + */ +typedef struct __ddi_intr_handle *ddi_intr_handle_t; +typedef struct __ddi_softint_handle *ddi_softint_handle_t; + +/* + * Definition for behavior flag which is used with ddi_intr_alloc(9f). + */ +#define DDI_INTR_ALLOC_NORMAL 0 /* Non-strict alloc */ +#define DDI_INTR_ALLOC_STRICT 1 /* Strict allocation */ + +/* + * Typedef for driver's interrupt handler + */ +typedef uint_t (ddi_intr_handler_t)(caddr_t arg1, caddr_t arg2); + +#endif /* _KERNEL */ +#include +#ifdef _KERNEL + +/* + * DDI interrupt function prototypes. + * + * New DDI interrupt interfaces. + */ + +/* + * ddi_intr_get_supported_types: + * + * Return, as a bit mask, the hardware interrupt types supported by + * both the device and by the host in the integer pointed + * to be the 'typesp' argument. + */ +int ddi_intr_get_supported_types(dev_info_t *dip, int *typesp); + +/* + * ddi_intr_get_nintrs: + * + * Return as an integer in the integer pointed to by the argument + * *nintrsp*, the number of interrupts the device supports for the + * given interrupt type. + */ +int ddi_intr_get_nintrs(dev_info_t *dip, int type, int *nintrsp); + +/* + * ddi_intr_get_navail: + * + * Return as an integer in the integer pointed to by the argument + * *navailp*, the number of interrupts currently available for the + * given interrupt type. + */ +int ddi_intr_get_navail(dev_info_t *dip, int type, int *navailp); + +/* + * Interrupt resource allocate/free functions + */ +int ddi_intr_alloc(dev_info_t *dip, ddi_intr_handle_t *h_array, + int type, int inum, int count, int *actualp, int behavior); +int ddi_intr_free(ddi_intr_handle_t h); + +/* + * Interrupt get/set capacity functions + */ +int ddi_intr_get_cap(ddi_intr_handle_t h, int *flagsp); +int ddi_intr_set_cap(ddi_intr_handle_t h, int flags); + +/* + * Interrupt priority management functions + */ +uint_t ddi_intr_get_hilevel_pri(void); +int ddi_intr_get_pri(ddi_intr_handle_t h, uint_t *prip); +int ddi_intr_set_pri(ddi_intr_handle_t h, uint_t pri); + +/* + * Interrupt add/duplicate/remove functions + */ +int ddi_intr_add_handler(ddi_intr_handle_t h, + ddi_intr_handler_t inthandler, void *arg1, void *arg2); +int ddi_intr_dup_handler(ddi_intr_handle_t org, int vector, + ddi_intr_handle_t *dup); +int ddi_intr_remove_handler(ddi_intr_handle_t h); + + +/* + * Interrupt enable/disable/block_enable/block_disable functions + */ +int ddi_intr_enable(ddi_intr_handle_t h); +int ddi_intr_disable(ddi_intr_handle_t h); +int ddi_intr_block_enable(ddi_intr_handle_t *h_array, int count); +int ddi_intr_block_disable(ddi_intr_handle_t *h_array, int count); + +/* + * Interrupt set/clr mask functions + */ +int ddi_intr_set_mask(ddi_intr_handle_t h); +int ddi_intr_clr_mask(ddi_intr_handle_t h); + +/* + * Interrupt get pending function + */ +int ddi_intr_get_pending(ddi_intr_handle_t h, int *pendingp); + +/* + * Interrupt resource management function + */ +int ddi_intr_set_nreq(dev_info_t *dip, int nreq); + +/* + * Soft interrupt functions + */ +int ddi_intr_add_softint(dev_info_t *dip, ddi_softint_handle_t *h, + int soft_pri, ddi_intr_handler_t handler, void *arg1); +int ddi_intr_remove_softint(ddi_softint_handle_t h); +int ddi_intr_trigger_softint(ddi_softint_handle_t h, void *arg2); +int ddi_intr_get_softint_pri(ddi_softint_handle_t h, uint_t *soft_prip); +int ddi_intr_set_softint_pri(ddi_softint_handle_t h, uint_t soft_pri); + +/* + * Old DDI interrupt interfaces. + * + * The following DDI interrupt interfaces are obsolete. + * Use the above new DDI interrupt interfaces instead. + */ + +/* + * Return non-zero if the specified interrupt exists and the handler + * will be restricted to using only certain functions because the + * interrupt level is not blocked by the scheduler. I.e., it cannot + * signal other threads. + */ +int ddi_intr_hilevel(dev_info_t *dip, uint_t inumber); + +int ddi_get_iblock_cookie(dev_info_t *dip, uint_t inumber, + ddi_iblock_cookie_t *iblock_cookiep); + +/* + * ddi_dev_nintrs + * + * If the device has h/w interrupt(s), report + * how many of them that there are into resultp. + * Return DDI_FAILURE if the device has no interrupts. + */ +int ddi_dev_nintrs(dev_info_t *dev, int *resultp); + +/* + * ddi_add_intr: Add an interrupt to the system. + * + * The interrupt number "inumber" determines which interrupt will + * be added. The interrupt number is associated with interrupt + * information provided from self identifying devices or configuration + * information for non-self identifying devices. If only one interrupt + * is associated with the device then the interrupt number should be 0. + * + * If successful, "*iblock_cookiep" will contain information necessary + * for initializing locks (mutex_init, cv_init, etc.) as well as for + * possible later removal of the interrupt from the system. + * + * If successful, "*idevice_cookiep" will contain the correct programmable + * device interrupt value (see in the form of the + * type ddi_idevice_cookie_t). + * + * Either cookie pointer may be specified as a NULL pointer + * in which case no value will be returned. + * + * The interrupt handler "int_handler" is the address of the routine + * to be called upon receipt of an appropriate interrupt. The + * interrupt handler should return DDI_INTR_CLAIMED if the + * interrupt was claimed, else DDI_INTR_UNCLAIMED. The argument + * "int_handler_arg" will be passed to the "int_handler" + * upon receipt of an appropriate interrupt. + * + * If successful ddi_add_intr will return DDI_SUCCESS. + * If the interrupt information cannot be found it will + * return DDI_INTR_NOTFOUND. + * + */ +int ddi_add_intr(dev_info_t *dip, uint_t inumber, + ddi_iblock_cookie_t *iblock_cookiep, + ddi_idevice_cookie_t *idevice_cookiep, + uint_t (*int_handler)(caddr_t int_handler_arg), + caddr_t int_handler_arg); + +/* + * The following function is for Sun's internal use only at present + */ +int ddi_add_fastintr(dev_info_t *dip, uint_t inumber, + ddi_iblock_cookie_t *iblock_cookiep, + ddi_idevice_cookie_t *idevice_cookiep, + uint_t (*hi_int_handler)(void)); + +/* + * ddi_remove_intr: Remove interrupt set up by ddi_add_intr. + * + * This routine is intended to be used by drivers that are + * preparing to unload themselves "detach" from the system. + */ +void ddi_remove_intr(dev_info_t *dip, uint_t inum, + ddi_iblock_cookie_t iblock_cookie); + +/* + * For use by ddi_add_softintr in order to specify a priority preference. + */ +#define DDI_SOFTINT_FIXED 0 /* Fixed priority soft interrupt */ +#define DDI_SOFTINT_LOW 8 /* Low priority soft interrupt */ +#define DDI_SOFTINT_MED 128 /* Medium priority soft interrupt */ +#define DDI_SOFTINT_HIGH 256 /* High priority soft interrupt */ + + +int ddi_get_soft_iblock_cookie(dev_info_t *dip, int preference, + ddi_iblock_cookie_t *iblock_cookiep); + +/* + * ddi_add_softintr: Add a "soft" interrupt to the system. + * + * Like ddi_add_intr, only for system interrupts that you can trigger + * yourself. You specify a preference (see above) for the level you + * want. You get an identifier back which you can use to either trigger + * a soft interrupt or, later, remove it. + */ +int ddi_add_softintr(dev_info_t *dip, int preference, ddi_softintr_t *idp, + ddi_iblock_cookie_t *iblock_cookiep, + ddi_idevice_cookie_t *idevice_cookiep, + uint_t (*int_handler)(caddr_t int_handler_arg), + caddr_t int_handler_arg); + +void ddi_remove_softintr(ddi_softintr_t id); + +void ddi_trigger_softintr(ddi_softintr_t id); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_INTR_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_intr_impl.h b/illumos-x86_64/usr/include/sys/ddi_intr_impl.h new file mode 100644 index 00000000..db7cda16 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_intr_impl.h @@ -0,0 +1,452 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_DDI_INTR_IMPL_H +#define _SYS_DDI_INTR_IMPL_H + +/* + * Sun DDI interrupt implementation specific definitions + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Typedef for interrupt ops + */ +typedef enum { + DDI_INTROP_SUPPORTED_TYPES = 1, /* 1 get supported interrupts types */ + DDI_INTROP_NINTRS, /* 2 get num of interrupts supported */ + DDI_INTROP_ALLOC, /* 3 allocate interrupt handle */ + DDI_INTROP_GETPRI, /* 4 get priority */ + DDI_INTROP_SETPRI, /* 5 set priority */ + DDI_INTROP_ADDISR, /* 6 add interrupt handler */ + DDI_INTROP_DUPVEC, /* 7 duplicate interrupt handler */ + DDI_INTROP_ENABLE, /* 8 enable interrupt */ + DDI_INTROP_BLOCKENABLE, /* 9 block enable interrupts */ + DDI_INTROP_BLOCKDISABLE, /* 10 block disable interrupts */ + DDI_INTROP_DISABLE, /* 11 disable interrupt */ + DDI_INTROP_REMISR, /* 12 remove interrupt handler */ + DDI_INTROP_FREE, /* 13 free interrupt handle */ + DDI_INTROP_GETCAP, /* 14 get capabilities */ + DDI_INTROP_SETCAP, /* 15 set capabilities */ + DDI_INTROP_SETMASK, /* 16 set mask */ + DDI_INTROP_CLRMASK, /* 17 clear mask */ + DDI_INTROP_GETPENDING, /* 18 get pending interrupt */ + DDI_INTROP_NAVAIL, /* 19 get num of available interrupts */ + DDI_INTROP_GETPOOL, /* 20 get resource management pool */ + DDI_INTROP_GETTARGET, /* 21 get target for a given intr(s) */ + DDI_INTROP_SETTARGET /* 22 set target for a given intr(s) */ +} ddi_intr_op_t; + +/* Version number used in the handles */ +#define DDI_INTR_VERSION_1 1 +#define DDI_INTR_VERSION DDI_INTR_VERSION_1 + +/* + * One such data structure is allocated per ddi_intr_handle_t + * This is the incore copy of the regular interrupt info. + */ +typedef struct ddi_intr_handle_impl { + dev_info_t *ih_dip; /* dip associated with handle */ + uint16_t ih_type; /* interrupt type being used */ + ushort_t ih_inum; /* interrupt number */ + uint32_t ih_vector; /* vector number */ + uint16_t ih_ver; /* Version */ + uint_t ih_state; /* interrupt handle state */ + uint_t ih_cap; /* interrupt capabilities */ + uint_t ih_pri; /* priority - bus dependent */ + krwlock_t ih_rwlock; /* read/write lock per handle */ + + uint_t (*ih_cb_func)(caddr_t, caddr_t); + void *ih_cb_arg1; + void *ih_cb_arg2; + + /* + * The following 3 members are used to support MSI-X specific features + */ + uint_t ih_flags; /* Misc flags */ + uint_t ih_dup_cnt; /* # of dupped msi-x vectors */ + struct ddi_intr_handle_impl *ih_main; + /* pntr to the main vector */ + /* + * The next set of members are for 'scratch' purpose only. + * The DDI interrupt framework uses them internally and their + * interpretation is left to the framework. For now, + * scratch1 - used to send NINTRs information + * to various nexus drivers. + * scratch2 - used to send 'behavior' flag + * information to the nexus drivers + * from ddi_intr_alloc(). It is also + * used to send 'h_array' to the nexus drivers + * for ddi_intr_block_enable/disable() on x86. + * private - On X86 it usually carries a pointer to + * ihdl_plat_t. Not used on SPARC platforms. + */ + void *ih_private; /* Platform specific data */ + uint_t ih_scratch1; /* Scratch1: #interrupts */ + void *ih_scratch2; /* Scratch2: flag/h_array */ + + /* + * The ih_target field may not reflect the actual target that is + * currently being used for the given interrupt. This field is just a + * snapshot taken either during ddi_intr_add_handler() or + * get/set_intr_affinity() calls. + */ + processorid_t ih_target; /* Target ID */ +} ddi_intr_handle_impl_t; + +/* values for ih_state (strictly for interrupt handle) */ +#define DDI_IHDL_STATE_ALLOC 0x01 /* Allocated. ddi_intr_alloc() called */ +#define DDI_IHDL_STATE_ADDED 0x02 /* Added interrupt handler */ + /* ddi_intr_add_handler() called */ +#define DDI_IHDL_STATE_ENABLE 0x04 /* Enabled. ddi_intr_enable() called */ + +#define DDI_INTR_IS_MSI_OR_MSIX(type) \ + ((type) == DDI_INTR_TYPE_MSI || (type) == DDI_INTR_TYPE_MSIX) + +#define DDI_INTR_BEHAVIOR_FLAG_VALID(f) \ + (((f) == DDI_INTR_ALLOC_NORMAL) || ((f) == DDI_INTR_ALLOC_STRICT)) + +#define DDI_INTR_TYPE_FLAG_VALID(t) \ + (((t) == DDI_INTR_TYPE_FIXED) || \ + ((t) == DDI_INTR_TYPE_MSI) || \ + ((t) == DDI_INTR_TYPE_MSIX)) + +/* values for ih_flags */ +#define DDI_INTR_MSIX_DUP 0x01 /* MSI-X vector which has been dupped */ + +/* Maximum number of MSI resources to allocate */ +#define DDI_MAX_MSI_ALLOC 2 + +/* Default number of MSI-X resources to allocate */ +#define DDI_DEFAULT_MSIX_ALLOC 2 + +#define DDI_MSIX_ALLOC_DIVIDER 32 +#define DDI_MIN_MSIX_ALLOC 8 +#define DDI_MAX_MSIX_ALLOC 2048 + +struct av_softinfo; + +/* + * One such data structure is allocated per ddi_soft_intr_handle + * This is the incore copy of the softint info. + */ +typedef struct ddi_softint_hdl_impl { + dev_info_t *ih_dip; /* dip associated with handle */ + uint_t ih_pri; /* priority - bus dependent */ + krwlock_t ih_rwlock; /* read/write lock per handle */ + struct av_softinfo *ih_pending; /* whether softint is pending */ + + uint_t (*ih_cb_func)(caddr_t, caddr_t); + /* cb function for soft ints */ + void *ih_cb_arg1; /* arg1 of callback function */ + void *ih_cb_arg2; /* arg2 passed to "trigger" */ + + /* + * The next member is for 'scratch' purpose only. + * The DDI interrupt framework uses it internally and its + * interpretation is left to the framework. + * private - used by the DDI framework to pass back + * and forth 'softid' information on SPARC + * side only. Not used on X86 platform. + */ + void *ih_private; /* Platform specific data */ +} ddi_softint_hdl_impl_t; + +/* Softint internal implementation defines */ +#define DDI_SOFT_INTR_PRI_M 4 +#define DDI_SOFT_INTR_PRI_H 6 + +/* + * One such data structure is allocated for MSI-X enabled + * device. If no MSI-X is enabled then it is NULL + */ +typedef struct ddi_intr_msix { + /* MSI-X Table related information */ + ddi_acc_handle_t msix_tbl_hdl; /* MSI-X table handle */ + uint32_t *msix_tbl_addr; /* MSI-X table addr */ + uint32_t msix_tbl_offset; /* MSI-X table offset */ + + /* MSI-X PBA Table related information */ + ddi_acc_handle_t msix_pba_hdl; /* MSI-X PBA handle */ + uint32_t *msix_pba_addr; /* MSI-X PBA addr */ + uint32_t msix_pba_offset; /* MSI-X PBA offset */ + + ddi_device_acc_attr_t msix_dev_attr; /* MSI-X device attr */ +} ddi_intr_msix_t; + +/* + * Interrupt Resource Management (IRM). + */ + +#define DDI_IRM_POLICY_LARGE 1 +#define DDI_IRM_POLICY_EVEN 2 + +#define DDI_IRM_POLICY_VALID(p) (((p) == DDI_IRM_POLICY_LARGE) || \ + ((p) == DDI_IRM_POLICY_EVEN)) + +#define DDI_IRM_FLAG_ACTIVE 0x1 /* Pool is active */ +#define DDI_IRM_FLAG_QUEUED 0x2 /* Pool is queued */ +#define DDI_IRM_FLAG_WAITERS 0x4 /* Pool has waiters */ +#define DDI_IRM_FLAG_EXIT 0x8 /* Balance thread must exit */ +#define DDI_IRM_FLAG_NEW 0x10 /* Request is new */ +#define DDI_IRM_FLAG_CALLBACK 0x20 /* Request has callback */ + +/* + * One such data structure for each supply of interrupt vectors. + * Contains information about the size and policies defining the + * supply, and a list of associated device-specific requests. + */ +typedef struct ddi_irm_pool { + int ipool_flags; /* Status flags of the pool */ + int ipool_types; /* Types of interrupts */ + int ipool_policy; /* Rebalancing policy */ + uint_t ipool_totsz; /* Total size of the pool */ + uint_t ipool_defsz; /* Default allocation size */ + uint_t ipool_minno; /* Minimum number consumed */ + uint_t ipool_reqno; /* Total number requested */ + uint_t ipool_resno; /* Total number reserved */ + kmutex_t ipool_lock; /* Protects all pool usage */ + kmutex_t ipool_navail_lock; /* Protects 'navail' of reqs */ + kcondvar_t ipool_cv; /* Condition variable */ + kthread_t *ipool_thread; /* Balancing thread */ + dev_info_t *ipool_owner; /* Device that created pool */ + list_t ipool_req_list; /* All requests in pool */ + list_t ipool_scratch_list; /* Requests being reduced */ + list_node_t ipool_link; /* Links in global pool list */ +} ddi_irm_pool_t; + +/* + * One such data structure for each dip's devinfo_intr_t. + * Contains information about vectors requested from IRM. + */ +typedef struct ddi_irm_req { + int ireq_flags; /* Flags for request */ + int ireq_type; /* Type requested */ + uint_t ireq_nreq; /* Number requested */ + uint_t ireq_navail; /* Number available */ + uint_t ireq_scratch; /* Scratch value */ + dev_info_t *ireq_dip; /* Requesting device */ + ddi_irm_pool_t *ireq_pool_p; /* Supplying pool */ + list_node_t ireq_link; /* Request list link */ + list_node_t ireq_scratch_link; /* Scratch list link */ +} ddi_irm_req_t; + +/* + * This structure is used to pass parameters to ndi_create_irm(), + * and describes the operating parameters of an IRM pool. + */ +typedef struct ddi_irm_params { + int iparams_types; /* Types of interrupts in pool */ + uint_t iparams_total; /* Total size of the pool */ +} ddi_irm_params_t; + +/* + * One such data structure is allocated for each dip. + * It has interrupt related information that can be + * stored/retrieved for convenience. + */ +typedef struct devinfo_intr { + /* These three fields show what the device is capable of */ + uint_t devi_intr_sup_types; /* Intrs supported by device */ + + ddi_intr_msix_t *devi_msix_p; /* MSI-X info, if supported */ + + /* Next three fields show current status for the device */ + uint_t devi_intr_curr_type; /* Interrupt type being used */ + uint_t devi_intr_sup_nintrs; /* #intr supported */ + uint_t devi_intr_curr_nintrs; /* #intr currently being used */ + /* + * #intr currently being enabled + * (for MSI block enable, the valuse is either 1 or 0.) + */ + uint_t devi_intr_curr_nenables; + + ddi_intr_handle_t *devi_intr_handle_p; /* Hdl for legacy intr APIs */ + +#if defined(__i386) || defined(__amd64) + /* Save the PCI config space handle */ + ddi_acc_handle_t devi_cfg_handle; + int devi_cap_ptr; /* MSI or MSI-X cap pointer */ +#endif + + ddi_irm_req_t *devi_irm_req_p; /* IRM request information */ +} devinfo_intr_t; + +#define NEXUS_HAS_INTR_OP(dip) \ + ((DEVI(dip)->devi_ops->devo_bus_ops) && \ + (DEVI(dip)->devi_ops->devo_bus_ops->busops_rev >= BUSO_REV_9) && \ + (DEVI(dip)->devi_ops->devo_bus_ops->bus_intr_op)) + +int i_ddi_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t op, + ddi_intr_handle_impl_t *hdlp, void *result); + +int i_ddi_add_softint(ddi_softint_hdl_impl_t *); +void i_ddi_remove_softint(ddi_softint_hdl_impl_t *); +int i_ddi_trigger_softint(ddi_softint_hdl_impl_t *, void *); +int i_ddi_set_softint_pri(ddi_softint_hdl_impl_t *, uint_t); + +void i_ddi_intr_devi_init(dev_info_t *dip); +void i_ddi_intr_devi_fini(dev_info_t *dip); + +uint_t i_ddi_intr_get_supported_types(dev_info_t *dip); +void i_ddi_intr_set_supported_types(dev_info_t *dip, int sup_type); +uint_t i_ddi_intr_get_current_type(dev_info_t *dip); +void i_ddi_intr_set_current_type(dev_info_t *dip, int intr_type); +uint_t i_ddi_intr_get_supported_nintrs(dev_info_t *dip, int intr_type); +void i_ddi_intr_set_supported_nintrs(dev_info_t *dip, int nintrs); +uint_t i_ddi_intr_get_current_nintrs(dev_info_t *dip); +void i_ddi_intr_set_current_nintrs(dev_info_t *dip, int nintrs); +uint_t i_ddi_intr_get_current_nenables(dev_info_t *dip); +void i_ddi_intr_set_current_nenables(dev_info_t *dip, int nintrs); +uint_t i_ddi_intr_get_current_navail(dev_info_t *dip, int intr_type); +uint_t i_ddi_intr_get_limit(dev_info_t *dip, int intr_type, + ddi_irm_pool_t *pool_p); + +ddi_irm_pool_t *i_ddi_intr_get_pool(dev_info_t *dip, int intr_type); + +void irm_init(void); +int i_ddi_irm_insert(dev_info_t *dip, int intr_type, int count); +int i_ddi_irm_modify(dev_info_t *dip, int nreq); +int i_ddi_irm_remove(dev_info_t *dip); +void i_ddi_irm_set_cb(dev_info_t *dip, boolean_t cb_flag); +int i_ddi_irm_supported(dev_info_t *dip, int type); + +ddi_intr_handle_t i_ddi_get_intr_handle(dev_info_t *dip, int inum); +void i_ddi_set_intr_handle(dev_info_t *dip, int inum, ddi_intr_handle_t hdl); + +ddi_intr_msix_t *i_ddi_get_msix(dev_info_t *dip); +void i_ddi_set_msix(dev_info_t *dip, ddi_intr_msix_t *msix_p); + +#if defined(__i386) || defined(__amd64) +ddi_acc_handle_t i_ddi_get_pci_config_handle(dev_info_t *dip); +void i_ddi_set_pci_config_handle(dev_info_t *dip, ddi_acc_handle_t handle); +int i_ddi_get_msi_msix_cap_ptr(dev_info_t *dip); +void i_ddi_set_msi_msix_cap_ptr(dev_info_t *dip, int cap_ptr); +#endif + +int32_t i_ddi_get_intr_weight(dev_info_t *); +int32_t i_ddi_set_intr_weight(dev_info_t *, int32_t); + +void i_ddi_alloc_intr_phdl(ddi_intr_handle_impl_t *); +void i_ddi_free_intr_phdl(ddi_intr_handle_impl_t *); + +extern int irm_enable; /* global flag for IRM */ + +#define DDI_INTR_ASSIGN_HDLR_N_ARGS(hdlp, func, arg1, arg2) \ + hdlp->ih_cb_func = func; \ + hdlp->ih_cb_arg1 = arg1; \ + hdlp->ih_cb_arg2 = arg2; + +#ifdef DEBUG +#define I_DDI_VERIFY_MSIX_HANDLE(hdlp) \ + if ((hdlp->ih_type == DDI_INTR_TYPE_MSIX) && \ + (hdlp->ih_flags & DDI_INTR_MSIX_DUP)) { \ + ASSERT(hdlp->ih_dip == hdlp->ih_main->ih_dip); \ + ASSERT(hdlp->ih_type == hdlp->ih_main->ih_type); \ + ASSERT(hdlp->ih_vector == hdlp->ih_main->ih_vector); \ + ASSERT(hdlp->ih_ver == hdlp->ih_main->ih_ver); \ + ASSERT(hdlp->ih_cap == hdlp->ih_main->ih_cap); \ + ASSERT(hdlp->ih_pri == hdlp->ih_main->ih_pri); \ + } +#else +#define I_DDI_VERIFY_MSIX_HANDLE(hdlp) +#endif + +#else /* _KERNEL */ + +typedef struct devinfo_intr devinfo_intr_t; + +#endif /* _KERNEL */ + +/* + * Used only by old DDI interrupt interfaces. + */ + +/* + * This structure represents one interrupt possible from the given + * device. It is used in an array for devices with multiple interrupts. + */ +struct intrspec { + uint_t intrspec_pri; /* interrupt priority */ + uint_t intrspec_vec; /* vector # (0 if none) */ + uint_t (*intrspec_func)(); /* function to call for interrupt, */ + /* If (uint_t (*)()) 0, none. */ + /* If (uint_t (*)()) 1, then */ +}; + +#ifdef _KERNEL + +/* + * Figure out how many FIXED nintrs are supported + */ +int i_ddi_get_intx_nintrs(dev_info_t *dip); + +/* + * NOTE: + * The following 4 busops entry points are obsoleted with version + * 9 or greater. Use i_ddi_intr_op interface in place of these + * obsolete interfaces. + * + * Remove these busops entry points and all related data structures + * in future minor/major solaris release. + */ +typedef enum {DDI_INTR_CTLOPS_NONE} ddi_intr_ctlop_t; + +/* + * Interrupt get/set affinity functions + */ +int get_intr_affinity(ddi_intr_handle_t h, processorid_t *tgt_p); +int set_intr_affinity(ddi_intr_handle_t h, processorid_t tgt); + +/* The following are obsolete interfaces */ +ddi_intrspec_t i_ddi_get_intrspec(dev_info_t *dip, dev_info_t *rdip, + uint_t inumber); + +int i_ddi_add_intrspec(dev_info_t *dip, dev_info_t *rdip, + ddi_intrspec_t intrspec, ddi_iblock_cookie_t *iblock_cookiep, + ddi_idevice_cookie_t *idevice_cookiep, + uint_t (*int_handler)(caddr_t int_handler_arg), + caddr_t int_handler_arg, int kind); + +void i_ddi_remove_intrspec(dev_info_t *dip, dev_info_t *rdip, + ddi_intrspec_t intrspec, ddi_iblock_cookie_t iblock_cookie); + +int i_ddi_intr_ctlops(dev_info_t *dip, dev_info_t *rdip, + ddi_intr_ctlop_t op, void *arg, void *val); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_INTR_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_isa.h b/illumos-x86_64/usr/include/sys/ddi_isa.h new file mode 100644 index 00000000..7590c411 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_isa.h @@ -0,0 +1,590 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DDI_ISA_H +#define _SYS_DDI_ISA_H + +#include +#include +#include +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * These are the data access functions which the platform + * can choose to define as functions or macro's. + */ + +/* + * DDI interfaces defined as macro's + */ + +/* + * DDI interfaces defined as functions + */ + +#ifdef __STDC__ + +/* + * ahi_acc_attr flags + */ +#define DDI_ACCATTR_CONFIG_SPACE 0x1 +#define DDI_ACCATTR_IO_SPACE 0x2 +#define DDI_ACCATTR_CPU_VADDR 0x4 +#define DDI_ACCATTR_DIRECT 0x8 + +typedef struct ddi_acc_impl { + ddi_acc_hdl_t ahi_common; + uint_t ahi_acc_attr; + ulong_t ahi_io_port_base; + + uint8_t + (*ahi_get8)(struct ddi_acc_impl *handle, uint8_t *addr); + uint16_t + (*ahi_get16)(struct ddi_acc_impl *handle, uint16_t *addr); + uint32_t + (*ahi_get32)(struct ddi_acc_impl *handle, uint32_t *addr); + uint64_t + (*ahi_get64)(struct ddi_acc_impl *handle, uint64_t *addr); + + void (*ahi_put8)(struct ddi_acc_impl *handle, uint8_t *addr, + uint8_t value); + void (*ahi_put16)(struct ddi_acc_impl *handle, uint16_t *addr, + uint16_t value); + void (*ahi_put32)(struct ddi_acc_impl *handle, uint32_t *addr, + uint32_t value); + void (*ahi_put64)(struct ddi_acc_impl *handle, uint64_t *addr, + uint64_t value); + + void (*ahi_rep_get8)(struct ddi_acc_impl *handle, + uint8_t *host_addr, uint8_t *dev_addr, + size_t repcount, uint_t flags); + void (*ahi_rep_get16)(struct ddi_acc_impl *handle, + uint16_t *host_addr, uint16_t *dev_addr, + size_t repcount, uint_t flags); + void (*ahi_rep_get32)(struct ddi_acc_impl *handle, + uint32_t *host_addr, uint32_t *dev_addr, + size_t repcount, uint_t flags); + void (*ahi_rep_get64)(struct ddi_acc_impl *handle, + uint64_t *host_addr, uint64_t *dev_addr, + size_t repcount, uint_t flags); + + void (*ahi_rep_put8)(struct ddi_acc_impl *handle, + uint8_t *host_addr, uint8_t *dev_addr, + size_t repcount, uint_t flags); + void (*ahi_rep_put16)(struct ddi_acc_impl *handle, + uint16_t *host_addr, uint16_t *dev_addr, + size_t repcount, uint_t flags); + void (*ahi_rep_put32)(struct ddi_acc_impl *handle, + uint32_t *host_addr, uint32_t *dev_addr, + size_t repcount, uint_t flags); + void (*ahi_rep_put64)(struct ddi_acc_impl *handle, + uint64_t *host_addr, uint64_t *dev_addr, + size_t repcount, uint_t flags); + + int (*ahi_fault_check)(struct ddi_acc_impl *handle); + void (*ahi_fault_notify)(struct ddi_acc_impl *handle); + uint32_t ahi_fault; + ndi_err_t *ahi_err; + kmutex_t *ahi_peekpoke_mutexp; + kmutex_t *ahi_err_mutexp; + void (*ahi_scan)(dev_info_t *, ddi_fm_error_t *); + dev_info_t *ahi_scan_dip; +} ddi_acc_impl_t; + + +/* + * Input functions to memory mapped IO + */ +uint8_t +i_ddi_vaddr_get8(ddi_acc_impl_t *hdlp, uint8_t *addr); + +uint16_t +i_ddi_vaddr_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); + +uint32_t +i_ddi_vaddr_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); + +uint64_t +i_ddi_vaddr_get64(ddi_acc_impl_t *hdlp, uint64_t *addr); + +uint16_t +i_ddi_vaddr_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); + +uint32_t +i_ddi_vaddr_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); + +uint64_t +i_ddi_vaddr_swap_get64(ddi_acc_impl_t *hdlp, uint64_t *addr); + +/* + * Output functions to memory mapped IO + */ +void +i_ddi_vaddr_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value); + +void +i_ddi_vaddr_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value); + +void +i_ddi_vaddr_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value); + +void +i_ddi_vaddr_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value); + +void +i_ddi_vaddr_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value); + +void +i_ddi_vaddr_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value); + +void +i_ddi_vaddr_swap_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value); + +/* + * Repeated input functions for memory mapped IO + */ +void +i_ddi_vaddr_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_swap_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +/* + * Repeated output functions for memory mapped IO + */ +void +i_ddi_vaddr_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_swap_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_vaddr_swap_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +/* + * Input functions to IO space + */ +uint8_t +i_ddi_io_get8(ddi_acc_impl_t *hdlp, uint8_t *addr); + +uint16_t +i_ddi_io_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); + +uint32_t +i_ddi_io_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); + +uint64_t +i_ddi_io_get64(ddi_acc_impl_t *hdlp, uint64_t *addr); + +uint16_t +i_ddi_io_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); + +uint32_t +i_ddi_io_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); + +/* + * Output functions to IO space + */ +void +i_ddi_io_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value); + +void +i_ddi_io_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value); + +void +i_ddi_io_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value); + +void +i_ddi_io_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value); + +void +i_ddi_io_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value); + +void +i_ddi_io_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value); + +/* + * Repeated input functions for IO space + */ +void +i_ddi_io_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr, + size_t repcount, uint_t flags); + +void +i_ddi_io_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_io_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_io_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_io_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_io_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +/* + * Repeated output functions for IO space + */ +void +i_ddi_io_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr, + size_t repcount, uint_t flags); + +void +i_ddi_io_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_io_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, uint32_t *dev_addr, + size_t repcount, uint_t flags); + +void +i_ddi_io_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, uint64_t *dev_addr, + size_t repcount, uint_t flags); +void +i_ddi_io_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_io_swap_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +/* + * repeat for protected mode accesses + */ + +/* + * Input functions to memory mapped IO + */ +uint8_t +i_ddi_prot_vaddr_get8(ddi_acc_impl_t *hdlp, uint8_t *addr); + +uint16_t +i_ddi_prot_vaddr_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); + +uint32_t +i_ddi_prot_vaddr_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); + +uint64_t +i_ddi_prot_vaddr_get64(ddi_acc_impl_t *hdlp, uint64_t *addr); + +uint16_t +i_ddi_prot_vaddr_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); + +uint32_t +i_ddi_prot_vaddr_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); + +uint64_t +i_ddi_prot_vaddr_swap_get64(ddi_acc_impl_t *hdlp, uint64_t *addr); + +/* + * Output functions to memory mapped IO + */ +void +i_ddi_prot_vaddr_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value); + +void +i_ddi_prot_vaddr_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value); + +void +i_ddi_prot_vaddr_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value); + +void +i_ddi_prot_vaddr_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value); + +void +i_ddi_prot_vaddr_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, + uint16_t value); + +void +i_ddi_prot_vaddr_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, + uint32_t value); + +void +i_ddi_prot_vaddr_swap_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, + uint64_t value); + +/* + * Repeated input functions for memory mapped IO + */ +void +i_ddi_prot_vaddr_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_swap_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +/* + * Repeated output functions for memory mapped IO + */ +void +i_ddi_prot_vaddr_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_swap_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_vaddr_swap_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +/* + * Input functions to IO space + */ +uint8_t +i_ddi_prot_io_get8(ddi_acc_impl_t *hdlp, uint8_t *addr); + +uint16_t +i_ddi_prot_io_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); + +uint32_t +i_ddi_prot_io_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); + +uint16_t +i_ddi_prot_io_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); + +uint32_t +i_ddi_prot_io_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); + +/* + * Output functions to IO space + */ +void +i_ddi_prot_io_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value); + +void +i_ddi_prot_io_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value); + +void +i_ddi_prot_io_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value); + +void +i_ddi_prot_io_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value); + +void +i_ddi_prot_io_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value); + +void +i_ddi_prot_io_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value); + +/* + * Repeated input functions for IO space + */ +void +i_ddi_prot_io_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_io_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_io_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_io_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_io_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +/* + * Repeated output functions for IO space + */ +void +i_ddi_prot_io_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_io_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_io_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_io_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); +void +i_ddi_prot_io_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); + +void +i_ddi_prot_io_swap_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); + +/* + * Default fault-checking and notification functions + */ +int +i_ddi_acc_fault_check(ddi_acc_impl_t *hdlp); + +void +i_ddi_acc_fault_notify(ddi_acc_impl_t *hdlp); + +/* DDI Fault Services functions */ +void i_ddi_caut_get(size_t size, void *addr, void *val); + +uint8_t i_ddi_caut_get8(ddi_acc_impl_t *hdlp, uint8_t *addr); +uint16_t i_ddi_caut_get16(ddi_acc_impl_t *hdlp, uint16_t *addr); +uint32_t i_ddi_caut_get32(ddi_acc_impl_t *hdlp, uint32_t *addr); +uint64_t i_ddi_caut_get64(ddi_acc_impl_t *hdlp, uint64_t *addr); + +void i_ddi_caut_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value); +void i_ddi_caut_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value); +void i_ddi_caut_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value); +void i_ddi_caut_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value); + +void i_ddi_caut_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); +void i_ddi_caut_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); +void i_ddi_caut_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); +void i_ddi_caut_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +void i_ddi_caut_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); +void i_ddi_caut_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); +void i_ddi_caut_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); +void i_ddi_caut_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +boolean_t i_ddi_copybuf_required(ddi_dma_attr_t *attrp); +size_t i_ddi_copybuf_size(); +uint32_t i_ddi_dma_max(dev_info_t *dip, ddi_dma_attr_t *attrp); + +/* handles case of running on top of hypervisor */ +pfn_t i_ddi_paddr_to_pfn(paddr_t paddr); + +#endif /* __STDC__ */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_ISA_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_obsolete.h b/illumos-x86_64/usr/include/sys/ddi_obsolete.h new file mode 100644 index 00000000..39ee6db8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_obsolete.h @@ -0,0 +1,92 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2014 Garrett D'Amore + */ + +#ifndef _SYS_DDI_OBSOLETE_H +#define _SYS_DDI_OBSOLETE_H + +/* + * Obsoleted DDI Interfaces + */ + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef _DDI_STRICT + +extern long strtol(const char *, char **, int); +extern unsigned long strtoul(const char *, char **, int); + +uint8_t ddi_mem_get8(ddi_acc_handle_t handle, uint8_t *host_addr); +uint16_t ddi_mem_get16(ddi_acc_handle_t handle, uint16_t *host_addr); +uint32_t ddi_mem_get32(ddi_acc_handle_t handle, uint32_t *host_addr); +uint64_t ddi_mem_get64(ddi_acc_handle_t handle, uint64_t *host_addr); +void ddi_mem_put8(ddi_acc_handle_t handle, uint8_t *dev_addr, uint8_t value); +void ddi_mem_put16(ddi_acc_handle_t handle, uint16_t *dev_addr, uint16_t value); +void ddi_mem_put32(ddi_acc_handle_t handle, uint32_t *dev_addr, uint32_t value); +void ddi_mem_put64(ddi_acc_handle_t handle, uint64_t *dev_addr, uint64_t value); + +void ddi_mem_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); +void ddi_mem_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); +void ddi_mem_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); +void ddi_mem_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); +void ddi_mem_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, + uint8_t *dev_addr, size_t repcount, uint_t flags); +void ddi_mem_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, + uint16_t *dev_addr, size_t repcount, uint_t flags); +void ddi_mem_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, + uint32_t *dev_addr, size_t repcount, uint_t flags); +void ddi_mem_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, + uint64_t *dev_addr, size_t repcount, uint_t flags); + +uint8_t ddi_io_get8(ddi_acc_handle_t handle, uint8_t *dev_addr); +uint16_t ddi_io_get16(ddi_acc_handle_t handle, uint16_t *dev_addr); +uint32_t ddi_io_get32(ddi_acc_handle_t handle, uint32_t *dev_addr); +void ddi_io_put8(ddi_acc_handle_t handle, uint8_t *dev_addr, uint8_t value); +void ddi_io_put16(ddi_acc_handle_t handle, uint16_t *dev_addr, uint16_t value); +void ddi_io_put32(ddi_acc_handle_t handle, uint32_t *dev_addr, uint32_t value); + +void ddi_io_rep_get8(ddi_acc_handle_t handle, + uint8_t *host_addr, uint8_t *dev_addr, size_t repcount); +void ddi_io_rep_get16(ddi_acc_handle_t handle, + uint16_t *host_addr, uint16_t *dev_addr, size_t repcount); +void ddi_io_rep_get32(ddi_acc_handle_t handle, + uint32_t *host_addr, uint32_t *dev_addr, size_t repcount); +void ddi_io_rep_put8(ddi_acc_handle_t handle, + uint8_t *host_addr, uint8_t *dev_addr, size_t repcount); +void ddi_io_rep_put16(ddi_acc_handle_t handle, + uint16_t *host_addr, uint16_t *dev_addr, size_t repcount); +void ddi_io_rep_put32(ddi_acc_handle_t handle, + uint32_t *host_addr, uint32_t *dev_addr, size_t repcount); + +/* Obsolete LDI event interfaces */ +extern int ldi_get_eventcookie(ldi_handle_t, char *, + ddi_eventcookie_t *); +extern int ldi_add_event_handler(ldi_handle_t, ddi_eventcookie_t, + void (*handler)(ldi_handle_t, ddi_eventcookie_t, void *, void *), + void *, ldi_callback_id_t *); +extern int ldi_remove_event_handler(ldi_handle_t, ldi_callback_id_t); + + +#endif /* not _DDI_STRICT */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_OBSOLETE_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_periodic.h b/illumos-x86_64/usr/include/sys/ddi_periodic.h new file mode 100644 index 00000000..0af46e5c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_periodic.h @@ -0,0 +1,78 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_DDI_PERIODIC_H +#define _SYS_DDI_PERIODIC_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Opaque handle type for i_timeout() and i_untimeout(). + */ +typedef struct __timeout *timeout_t; + +typedef enum ddi_periodic_flags { + DPF_DISPATCHED = 0x01, + DPF_EXECUTING = 0x02, + DPF_CANCELLED = 0x04 +} ddi_periodic_flags_t; + +/* + * Each instance of this structure represents a single periodic handler + * registered through ddi_periodic_add(9F). + */ +typedef struct ddi_periodic_impl { + struct list_node dpr_link; /* protected by periodics_lock */ + struct list_node dpr_softint_link; /* only used when DPF_DISPATCHED */ + id_t dpr_id; + hrtime_t dpr_interval; + + kmutex_t dpr_lock; + kcondvar_t dpr_cv; + ddi_periodic_flags_t dpr_flags; + uint_t dpr_level; /* 0 <= dpr_level <= 10 */ + taskq_ent_t dpr_taskq_ent; /* only used for level of 0 */ + uint64_t dpr_fire_count; + kthread_t *dpr_thread; + + cyclic_id_t dpr_cyclic_id; + + void (*dpr_handler)(void *); + void *dpr_arg; +} ddi_periodic_impl_t; + +/* + * Internal implementation functions for the DDI periodic interface. + */ +void ddi_periodic_init(void); +void ddi_periodic_fini(void); +void ddi_periodic_softintr(int level); +timeout_t i_timeout(void (*)(void *), void *, hrtime_t, int); +void i_untimeout(timeout_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_PERIODIC_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_ufm.h b/illumos-x86_64/usr/include/sys/ddi_ufm.h new file mode 100644 index 00000000..9f2474f2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_ufm.h @@ -0,0 +1,264 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2020 Joyent, Inc. + * Copyright 2020 Oxide Computer Company + */ + +#ifndef _SYS_DDI_UFM_H +#define _SYS_DDI_UFM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +#include +#include +#include +#include +#else +#include +#include +#include +#endif /* _KERNEL */ + +#define DDI_UFM_DEV "/dev/ufm" +#define DDI_UFM_CURRENT_VERSION 1 +#define DDI_UFM_VERSION_ONE 1 + +#define UFM_IOC ('u' << 24) | ('f' << 16) | ('m' << 8) +#define UFM_IOC_GETCAPS (UFM_IOC | 1) +#define UFM_IOC_REPORTSZ (UFM_IOC | 2) +#define UFM_IOC_REPORT (UFM_IOC | 3) +#define UFM_IOC_READIMG (UFM_IOC | 4) +#define UFM_IOC_MAX UFM_IOC_REPORT + +/* + * Bitfield enumerating the DDI UFM capabilities supported by this device + * instance. Currently there is only a single capability of being able to + * report UFM information. When support for new capabilties are added to the + * DDI UFM subsystem, it should be reflected in this enum and the implementation + * of the UFM_IOC_GETCAPS should be extended appropriately. + */ +typedef enum { + DDI_UFM_CAP_REPORT = 1 << 0, + DDI_UFM_CAP_READIMG = 1 << 1 +} ddi_ufm_cap_t; + +/* + * This struct defines the input/output data for the UFM_IOC_GETCAPS ioctl. + * Callers should specify the ufmg_version and ufmg_devpath fields. On success + * the ufmg_caps field will be filled in with a value indicating the supported + * UFM capabilities of the device specified in ufmg_devpath. + */ +typedef struct ufm_ioc_getcaps { + uint_t ufmg_version; /* DDI_UFM_VERSION */ + uint_t ufmg_caps; /* UFM Caps */ + char ufmg_devpath[MAXPATHLEN]; +} ufm_ioc_getcaps_t; + +/* + * This struct defines the input/output data for the UFM_IOC_REPORTSZ ioctl. + * Callers should specify the ufbz_version and ufbz_devpath fields. On success + * the ufmg_size field will be filled in with the amount of space (in bytes) + * required to hold the UFM data for this device instance. This should be used + * to allocate a sufficiently size buffer for the UFM_IOC_REPORT ioctl. + */ +typedef struct ufm_ioc_bufsz { + uint_t ufbz_version; /* DDI_UFM_VERSION */ + size_t ufbz_size; /* sz of buf to be returned by ioctl */ + char ufbz_devpath[MAXPATHLEN]; +} ufm_ioc_bufsz_t; + +#ifdef _KERNEL +typedef struct ufm_ioc_bufsz32 { + uint_t ufbz_version; + size32_t ufbz_size; + char ufbz_devpath[MAXPATHLEN]; +} ufm_ioc_bufsz32_t; +#endif /* _KERNEL */ + +/* + * This struct defines the input/output data for the UFM_IOC_REPORT ioctl. + * Callers should specify the ufmr_version, ufmr_bufsz and ufmr_devpath fields. + * On success, the ufmr_buf field will point to a packed nvlist containing the + * UFM data for the specified device instance. The value of ufmr_bufsz will be + * updated to reflect the actual size of data copied out. + */ +typedef struct ufm_ioc_report { + uint_t ufmr_version; /* DDI_UFM_VERSION */ + size_t ufmr_bufsz; /* size of caller-supplied buffer */ + caddr_t ufmr_buf; /* buf to hold packed output nvl */ + char ufmr_devpath[MAXPATHLEN]; +} ufm_ioc_report_t; + +#ifdef _KERNEL +typedef struct ufm_ioc_report32 { + uint_t ufmr_version; + size32_t ufmr_bufsz; + caddr32_t ufmr_buf; + char ufmr_devpath[MAXPATHLEN]; +} ufm_ioc_report32_t; +#endif /* _KERNEL */ + +/* + * This struct defines the input/output data for the UFM_IOC_READ ioctl, which + * reads the firmware image from a given slot. + */ +typedef struct ufm_ioc_readimg { + uint_t ufri_version; + uint_t ufri_imageno; + uint_t ufri_slotno; + uint64_t ufri_offset; + uint64_t ufri_len; + uint64_t ufri_nread; + void *ufri_buf; + char ufri_devpath[MAXPATHLEN]; +} ufm_ioc_readimg_t; + +#ifdef _KERNEL +#pragma pack(4) +typedef struct ufm_ioc_readimg32 { + uint_t ufri_version; + uint_t ufri_imageno; + uint_t ufri_slotno; + uint64_t ufri_offset; + uint64_t ufri_len; + uint64_t ufri_nread; + caddr32_t ufri_buf; + char ufri_devpath[MAXPATHLEN]; +} ufm_ioc_readimg32_t; +#pragma pack() +#endif /* _KERNEL */ + +/* + * The UFM_IOC_REPORT ioctl return UFM image and slot data in the form of a + * packed nvlist. The nvlist contains and array of nvlists (one-per-image). + * Each image nvlist contains will contain a string nvpair containing a + * description of the image and an optional nvlist nvpair containing + * miscellaneous image information. + */ +#define DDI_UFM_NV_IMAGES "ufm-images" +#define DDI_UFM_NV_IMAGE_DESC "ufm-image-description" +#define DDI_UFM_NV_IMAGE_MISC "ufm-image-misc" + +/* + * Each image nvlist also contains an array of nvlists representing the slots. + */ +#define DDI_UFM_NV_IMAGE_SLOTS "ufm-image-slots" + +/* + * Each slot nvlist has the following: + * + * o A string nvpair describing the firmware image version + * o A uint32 nvpair describing the slot attributes (see ddi_ufm_attr_t + * below). + * o An optional nvlist nvpar may be present containing additional + * miscellaneous slot data. + * o An optional uint64 slot length that indicates the size of the image in + * that slot. Note htis is the size of the image, not the size of the slot. + */ +#define DDI_UFM_NV_SLOT_VERSION "ufm-slot-version" +#define DDI_UFM_NV_SLOT_IMGSIZE "ufm-slot-imgsize" + +typedef enum { + DDI_UFM_ATTR_READABLE = 1 << 0, + DDI_UFM_ATTR_WRITEABLE = 1 << 1, + DDI_UFM_ATTR_ACTIVE = 1 << 2, + DDI_UFM_ATTR_EMPTY = 1 << 3 +} ddi_ufm_attr_t; + +#define DDI_UFM_ATTR_MAX DDI_UFM_ATTR_READABLE | \ + DDI_UFM_ATTR_WRITEABLE | \ + DDI_UFM_ATTR_ACTIVE | \ + DDI_UFM_ATTR_EMPTY + +#define DDI_UFM_NV_SLOT_ATTR "ufm-slot-attributes" + +#define DDI_UFM_NV_SLOT_MISC "ufm-slot-misc" + +#ifdef _KERNEL +/* opaque structures */ +typedef struct ddi_ufm_handle ddi_ufm_handle_t; +typedef struct ddi_ufm_image ddi_ufm_image_t; +typedef struct ddi_ufm_slot ddi_ufm_slot_t; + +/* + * DDI UFM Operations vector + */ +typedef struct ddi_ufm_ops { + int (*ddi_ufm_op_nimages)(ddi_ufm_handle_t *, void *, uint_t *); + int (*ddi_ufm_op_fill_image)(ddi_ufm_handle_t *, void *, uint_t, + ddi_ufm_image_t *); + int (*ddi_ufm_op_fill_slot)(ddi_ufm_handle_t *, void *, uint_t, uint_t, + ddi_ufm_slot_t *); + int (*ddi_ufm_op_getcaps)(ddi_ufm_handle_t *, void *, ddi_ufm_cap_t *); + int (*ddi_ufm_op_readimg)(ddi_ufm_handle_t *, void *, uint_t, uint_t, + uint64_t, uint64_t, void *, uint64_t *); +} ddi_ufm_ops_t; + +/* + * During a device driver's attach(9E) entry point, a device driver should + * register with the UFM subsystem by filling out a UFM operations vector + * (see above) and then calling ddi_ufm_init(9F). The driver may pass in a + * value, usually a pointer to its soft state pointer, which it will then + * receive when its subsequent entry points are called. + */ +int ddi_ufm_init(dev_info_t *, uint_t version, ddi_ufm_ops_t *, + ddi_ufm_handle_t **, void *); + +/* + * Device drivers should call ddi_ufm_update(9F) after driver initialization is + * complete and after calling ddi_ufm_init(9F), in order to indicate to the + * UFM subsystem that the driver is in a state where it is ready to receive + * calls to its UFM entry points. + * + * Additionally, whenever the driver detects a change in the state of a UFM, it + * should call ddi_ufm_update(9F). This will cause the UFM subsystem to + * invalidate any cached state regarding this driver's UFM(s) + */ +void ddi_ufm_update(ddi_ufm_handle_t *); + +/* + * A device driver should call ddi_ufm_fini(9F) during its detach(9E) entry + * point. Upon return, the driver is gaurunteed that no further DDI UFM entry + * points will be called and thus any related state can be safely torn down. + * + * After return, the UFM handle is no longer valid and should not be used in + * any future ddi_ufm_* calls. + */ +void ddi_ufm_fini(ddi_ufm_handle_t *); + +/* + * These interfaces should only be called within the context of a + * ddi_ufm_op_fill_image callback. + */ +void ddi_ufm_image_set_desc(ddi_ufm_image_t *, const char *); +void ddi_ufm_image_set_nslots(ddi_ufm_image_t *, uint_t); +void ddi_ufm_image_set_misc(ddi_ufm_image_t *, nvlist_t *); + +/* + * These interfaces should only be called within the context of a + * ddi_ufm_op_fill_slot callback. + */ +void ddi_ufm_slot_set_version(ddi_ufm_slot_t *, const char *); +void ddi_ufm_slot_set_attrs(ddi_ufm_slot_t *, ddi_ufm_attr_t); +void ddi_ufm_slot_set_misc(ddi_ufm_slot_t *, nvlist_t *); +void ddi_ufm_slot_set_imgsize(ddi_ufm_slot_t *, uint64_t); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_UFM_H */ diff --git a/illumos-x86_64/usr/include/sys/ddi_ufm_impl.h b/illumos-x86_64/usr/include/sys/ddi_ufm_impl.h new file mode 100644 index 00000000..08711eb8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddi_ufm_impl.h @@ -0,0 +1,91 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2019 Joyent, Inc. + * Copyright 2020 Oxide Computer Company + */ + +#ifndef _SYS_DDI_UFM_IMPL_H +#define _SYS_DDI_UFM_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +typedef enum { + DDI_UFM_STATE_INIT = 1 << 0, + DDI_UFM_STATE_READY = 1 << 1, + DDI_UFM_STATE_SHUTTING_DOWN = 1 << 2 +} ddi_ufm_state_t; + +/* private interface for startup_ddi() */ +void ufm_init(); + +/* private interfaces for ufm driver */ +struct ddi_ufm_handle *ufm_find(const char *); +int ufm_cache_fill(struct ddi_ufm_handle *ufmh); +int ufm_read_img(ddi_ufm_handle_t *, uint_t, uint_t, uint64_t, uint64_t, + uintptr_t, uint64_t *, int); + +struct ddi_ufm_slot { + uint_t ufms_slotno; + char *ufms_version; + ddi_ufm_attr_t ufms_attrs; + uint64_t ufms_imgsize; + nvlist_t *ufms_misc; +}; + +struct ddi_ufm_image { + uint_t ufmi_imageno; + char *ufmi_desc; + nvlist_t *ufmi_misc; + struct ddi_ufm_slot *ufmi_slots; + uint_t ufmi_nslots; +}; + +struct ddi_ufm_handle { + /* + * The following fields get filled in when a UFM-aware driver calls + * ddi_ufm_init(9F). They remain valid until the driver calls + * ddi_ufm_fini(9F). You can test for validity of these fields by + * checking if the DDI_UFM_STATE_INIT flag is set in ufmh_state. + */ + kmutex_t ufmh_lock; + char ufmh_devpath[MAXPATHLEN]; + ddi_ufm_ops_t *ufmh_ops; + void *ufmh_arg; + uint_t ufmh_state; + uint_t ufmh_version; + /* + * The following four fields represent lazily cached UFM data + * retrieved from a UFM-aware driver. If ufmh_report is non-NULL + * then all four of these fields will contain valid data. + */ + struct ddi_ufm_image *ufmh_images; + uint_t ufmh_nimages; + ddi_ufm_cap_t ufmh_caps; + nvlist_t *ufmh_report; + + avl_node_t ufmh_link; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDI_UFM_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/ddidevmap.h b/illumos-x86_64/usr/include/sys/ddidevmap.h new file mode 100644 index 00000000..b0794a6b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddidevmap.h @@ -0,0 +1,294 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_DDIDEVMAP_H +#define _SYS_DDIDEVMAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include + +struct devmap_info { + size_t length; /* and this length */ + size_t page_size; /* pte page size selected by framework */ + size_t offset; /* optimal page size based on this offset */ + ushort_t valid_flag; /* flag to indicate the validity of data */ + uchar_t byte_order; /* the endian characteristics of the mapping */ + + /* + * describes order in which the CPU will reference data. + */ + uchar_t data_order; +}; + +typedef void * ddi_umem_cookie_t; + +/* + * umem callback function vector for drivers + * + * NOTE: IMPORTANT! When umem_lockmemory is called with a valid + * umem_callback_ops and DDI_UMEMLOCK_LONGTERM set, the 'cleanup' + * callback function may be called AFTER a call to ddi_umem_lock. + * It is the users responsibility to make sure that ddi_umem_lock is + * called ONLY once for each ddi_umem_lock/umem_lockmemory cookie. + */ +#define UMEM_CALLBACK_VERSION 1 +struct umem_callback_ops { + int cbo_umem_callback_version; /* version number */ + void (*cbo_umem_lock_cleanup)(ddi_umem_cookie_t *); +}; + +struct ddi_umem_cookie { + size_t size; /* size of allocation */ + caddr_t cvaddr; /* cookie virtual address. */ + /* KMEM - kvaddr returned from ddi_umem_alloc() */ + /* For LOCKEDUMEM - user address of backing store */ + /* For TRASH_UMEM - unused */ + kmutex_t lock; + uint_t type; /* see below for umem_cookie types */ + /* + * Following 4 members are used for UMEM_LOCKED cookie type + */ + page_t **pparray; /* shadow list from as_pagelock */ + void *procp; /* user process owning backing store */ + struct as *asp; /* as ptr for use by ddi_umem_unlock */ + enum seg_rw s_flags; /* flags used during pagelock/fault */ + /* + * locked indicates underlying memory locked for KMEM_PAGEABLE + * locked is a count of for how many pages this has been locked + */ + uint_t locked; + struct umem_callback_ops callbacks; + /* + * cook_refcnt used in UMEM_LOCKED type + */ + ulong_t cook_refcnt; /* cookie reference count */ + struct ddi_umem_cookie *unl_forw; /* list ptr for unlock cookies */ + ulong_t upd_max_lock_rctl; /* track max-locked mem rctl? */ +}; + +typedef struct as *ddi_as_handle_t; + + +/* + * type of umem_cookie: + * pageable memory allocated from segkp segment driver + * non-pageable memory allocated from kmem_getpages() + * locked umem allocated from ddi_umem_lock + * trash umem maps all user virtual addresses to a common trash page + */ +#define KMEM_PAGEABLE 0x100 /* un-locked kernel memory */ +#define KMEM_NON_PAGEABLE 0x200 /* locked kernel memeory */ +#define UMEM_LOCKED 0x400 /* locked user process memeory */ +#define UMEM_TRASH 0x800 /* trash page mapping */ + +typedef struct __devmap_pmem_cookie *devmap_pmem_cookie_t; + +typedef void *devmap_cookie_t; + +struct devmap_callback_ctl { + int devmap_rev; /* devmap_callback_ctl version number */ + int (*devmap_map)(devmap_cookie_t dhp, dev_t dev, uint_t flags, + offset_t off, size_t len, void **pvtp); + int (*devmap_access)(devmap_cookie_t dhp, void *pvtp, offset_t off, + size_t len, uint_t type, uint_t rw); + int (*devmap_dup)(devmap_cookie_t dhp, void *pvtp, + devmap_cookie_t new_dhp, void **new_pvtp); + void (*devmap_unmap)(devmap_cookie_t dhp, void *pvtp, offset_t off, + size_t len, devmap_cookie_t new_dhp1, + void **new_pvtp1, devmap_cookie_t new_dhp2, + void **new_pvtp2); +}; + +struct devmap_softlock { + ulong_t id; /* handle grouping id */ + dev_t dev; /* Device to which we are mapping */ + struct devmap_softlock *next; + kmutex_t lock; + kcondvar_t cv; + int refcnt; /* Number of threads with mappings */ + ssize_t softlocked; +}; + +struct devmap_ctx { + ulong_t id; /* handle grouping id */ + dev_info_t *dip; /* Device info struct for tracing context */ + struct devmap_ctx *next; + kmutex_t lock; + kcondvar_t cv; + int refcnt; /* Number of threads with mappings */ + uint_t oncpu; /* this context is running on a cpu */ + timeout_id_t timeout; /* Timeout ID */ +}; + +/* + * Fault information passed to the driver fault handling routine. + * The DEVMAP_LOCK and DEVMAP_UNLOCK are used by software + * to lock and unlock pages for physical I/O. + */ +enum devmap_fault_type { + DEVMAP_ACCESS, /* invalid page */ + DEVMAP_PROT, /* protection fault */ + DEVMAP_LOCK, /* software requested locking */ + DEVMAP_UNLOCK /* software requested unlocking */ +}; + +/* + * seg_rw gives the access type for a fault operation + */ +enum devmap_rw { + DEVMAP_OTHER, /* unknown or not touched */ + DEVMAP_READ, /* read access attempted */ + DEVMAP_WRITE, /* write access attempted */ + DEVMAP_EXEC, /* execution access attempted */ + DEVMAP_CREATE /* create if page doesn't exist */ +}; + +typedef struct devmap_handle { + + /* + * physical offset at the beginning of mapping. + */ + offset_t dh_roff; + + /* + * user offset at the beginning of mapping. + */ + offset_t dh_uoff; + size_t dh_len; /* length of mapping */ + dev_t dh_dev; /* dev_t for this mapping */ + caddr_t dh_cvaddr; /* cookie virtual address */ + caddr_t dh_uvaddr; /* user address within dh_seg */ + + /* + * Lock protects fields that can change during remap + * dh_roff, dh_cookie, dh_flags, dh_mmulevel, dh_maxprot, + * dh_pfn, dh_hat_attr + */ + kmutex_t dh_lock; + + /* + * to sync. faults for remap and unlocked kvaddr. + */ + struct seg *dh_seg; /* segment created for this mapping */ + void *dh_pvtp; /* device mapping private data */ + struct devmap_handle *dh_next; + struct devmap_softlock *dh_softlock; + struct devmap_ctx *dh_ctx; + ddi_umem_cookie_t dh_cookie; /* kmem cookie */ + devmap_pmem_cookie_t dh_pcookie; /* pmem cookie */ + + /* + * protection flag possible for attempted mapping. + */ + uint_t dh_prot; + + /* + * Current maximum protection flag for attempted mapping. + * This controls how dh_prot can be changed in segdev_setprot + * See dh_orig_maxprot below also + */ + uint_t dh_maxprot; + + /* + * mmu level corresponds to the Max page size can be use for + * the mapping. + */ + uint_t dh_mmulevel; + uint_t dh_flags; /* see defines below */ + pfn_t dh_pfn; /* pfn corresponds to dh_reg_off */ + uint_t dh_hat_attr; + clock_t dh_timeout_length; + struct devmap_callback_ctl dh_callbackops; + + /* + * orig_maxprot is what the original mmap set maxprot to. + * This is never modified once it is setup during mmap(2) + * This is different from the current dh_maxprot which can + * be changed in devmap_*_setup/remap + */ + uint_t dh_orig_maxprot; +} devmap_handle_t; + +#endif /* _KERNEL */ + +/* + * define for devmap_rev + */ +#define DEVMAP_OPS_REV 1 + +/* + * defines for devmap_*_setup flag, called by drivers + */ +#define DEVMAP_DEFAULTS 0x00 +#define DEVMAP_MAPPING_INVALID 0x01 /* mapping is invalid */ +#define DEVMAP_ALLOW_REMAP 0x02 /* allow remap */ +#define DEVMAP_USE_PAGESIZE 0x04 /* use pagesize for mmu load */ + +/* flags used by drivers */ +#define DEVMAP_SETUP_FLAGS \ + (DEVMAP_MAPPING_INVALID | DEVMAP_ALLOW_REMAP | DEVMAP_USE_PAGESIZE) + +/* + * defines for dh_flags, these are used internally in devmap + */ +#define DEVMAP_SETUP_DONE 0x100 /* mapping setup is done */ +#define DEVMAP_LOCK_INITED 0x200 /* locks are initailized */ +#define DEVMAP_LOCKED 0x800 /* dhp is locked. */ +#define DEVMAP_FLAG_LARGE 0x1000 /* cal. optimal pgsize */ + +/* + * Flags to pass to ddi_umem_alloc and ddi_umem_iosetup + */ +#define DDI_UMEM_SLEEP 0x0 +#define DDI_UMEM_NOSLEEP 0x01 +#define DDI_UMEM_PAGEABLE 0x02 +#define DDI_UMEM_TRASH 0x04 + +/* + * Flags to pass to ddi_umem_lock to indicate expected access pattern + * DDI_UMEMLOCK_READ implies the memory being locked will be read + * (e.g., data read from memory is written out to the disk or network) + * DDI_UMEMLOCK_WRITE implies the memory being locked will be written + * (e.g., data from the disk or network is written to memory) + * Both flags may be set in the call to ddi_umem_lock, + * Note that this corresponds to the VM subsystem definition of read/write + * and also correspond to the prots set in devmap + * When doing I/O, B_READ/B_WRITE are used which have exactly the opposite + * meaning. Be careful when using it both for I/O and devmap + * + * + */ +#define DDI_UMEMLOCK_READ 0x01 +#define DDI_UMEMLOCK_WRITE 0x02 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDIDEVMAP_H */ diff --git a/illumos-x86_64/usr/include/sys/ddidmareq.h b/illumos-x86_64/usr/include/sys/ddidmareq.h new file mode 100644 index 00000000..ec6ca3b2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddidmareq.h @@ -0,0 +1,799 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_DDIDMAREQ_H +#define _SYS_DDIDMAREQ_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Memory Objects + * + * Definitions of structures that can describe + * an object that can be mapped for DMA. + */ + +/* + * Structure describing a virtual address + */ +struct v_address { + caddr_t v_addr; /* base virtual address */ + struct as *v_as; /* pointer to address space */ + void *v_priv; /* priv data for shadow I/O */ +}; + +/* + * Structure describing a page-based address + */ +struct pp_address { + /* + * A pointer to a circularly linked list of page structures. + */ + struct page *pp_pp; + uint_t pp_offset; /* offset within first page */ +}; + +/* + * Structure to describe a physical memory address. + */ +struct phy_address { + ulong_t p_addr; /* base physical address */ + ulong_t p_memtype; /* memory type */ +}; + +/* + * Structure to describe an array DVMA addresses. + * Under normal circumstances, dv_nseg will be 1. + * dvs_start is always page aligned. + */ +struct dvma_address { + size_t dv_off; + size_t dv_nseg; + struct dvmaseg { + uint64_t dvs_start; + size_t dvs_len; + } *dv_seg; +}; + +/* + * A union of all of the above structures. + * + * This union describes the relationship between + * the kind of an address description and an object. + */ +typedef union { + struct v_address virt_obj; /* Some virtual address */ + struct pp_address pp_obj; /* Some page-based address */ + struct phy_address phys_obj; /* Some physical address */ + struct dvma_address dvma_obj; +} ddi_dma_aobj_t; + +/* + * DMA object types - used to select how the object + * being mapped is being addressed by the IU. + */ +typedef enum { + DMA_OTYP_VADDR = 0, /* enforce starting value of zero */ + DMA_OTYP_PAGES, + DMA_OTYP_PADDR, + DMA_OTYP_BUFVADDR, + DMA_OTYP_DVADDR +} ddi_dma_atyp_t; + +/* + * A compact package to describe an object that is to be mapped for DMA. + */ +typedef struct { + uint_t dmao_size; /* size, in bytes, of the object */ + ddi_dma_atyp_t dmao_type; /* type of object */ + ddi_dma_aobj_t dmao_obj; /* the object described */ +} ddi_dma_obj_t; + +/* + * DMA addressing limits. + * + * This structure describes the constraints that a particular device's + * DMA engine has to its parent so that the parent may correctly set + * things up for a DMA mapping. Each parent may in turn modify the + * constraints listed in a DMA request structure in order to describe + * to its parent any changed or additional constraints. The rules + * are that each parent may modify a constraint in order to further + * constrain things (e.g., picking a more limited address range than + * that permitted by the child), but that the parent may not ignore + * a child's constraints. + * + * A particular constraint that we do *not* address is whether or not + * a requested mapping is too large for a DMA engine's counter to + * correctly track. It is still up to each driver to explicitly handle + * transfers that are too large for its own hardware to deal with directly. + * + * The mapping routines that are cognizant of this structure will + * copy any user defined limits structure if they need to modify + * the fields (as alluded to above). + * + * A note as to how to define constraints: + * + * How you define the constraints for your device depends on how you + * define your device. For example, you may have an SBus card with a + * device on it that address only the bottom 16mb of virtual DMA space. + * However, if the card also has ancillary circuitry that pulls the high 8 + * bits of address lines high, the more correct expression for your device + * is that it address [0xff000000..0xffffffff] rather than [0..0x00ffffff]. + */ +#if defined(__sparc) +typedef struct ddi_dma_lim { + + /* + * Low range of 32 bit addressing capability. + */ + uint_t dlim_addr_lo; + + /* + * Upper inclusive bound of addressing capability. It is an + * inclusive boundary limit to allow for the addressing range + * [0..0xffffffff] to be specified in preference to [0..0]. + */ + uint_t dlim_addr_hi; + + /* + * Inclusive upper bound with which The DMA engine's counter acts as + * a register. + * + * This handles the case where an upper portion of a DMA address + * register is a latch instead of being a full 32 bit register + * (e.g., the upper 8 bits may remain constant while the lower + * 24 bits are the real address register). + * + * This essentially gives a hint about segment limitations + * to the mapping routines. + */ + uint_t dlim_cntr_max; + + /* + * DMA burst sizes. + * + * At the time of a mapping request, this tag defines the possible + * DMA burst cycle sizes that the requestor's DMA engine can + * emit. The format of the data is binary encoding of burst sizes + * assumed to be powers of two. That is, if a DMA engine is capable + * of doing 1, 2, 4 and 16 byte transfers, the encoding would be 0x17. + * + * As the mapping request is handled by intervening nexi, the + * burstsizes value may be modified. Prior to enabling DMA for + * the specific device, the driver that owns the DMA engine should + * check (via ddi_dma_burstsizes(9F)) what the allowed burstsizes + * have become and program their DMA engine appropriately. + */ + uint_t dlim_burstsizes; + + /* + * Minimum effective DMA transfer size, in units of bytes. + * + * This value specifies the minimum effective granularity of the + * DMA engine. It is distinct from dlim_burtsizes in that it + * describes the minimum amount of access a DMA transfer will + * effect. dlim_burtsizes describes in what electrical fashion + * the DMA engine might perform its accesses, while dlim_minxfer + * describes the minimum amount of memory that can be touched by + * the DMA transfer. + * + * As the mapping request is handled by intervening nexi, the + * dlim_minxfer value may be modifed contingent upon the presence + * (and use) of I/O caches and DMA write buffers in between the + * DMA engine and the object that DMA is being performed on. + * + */ + uint_t dlim_minxfer; + + /* + * Expected average data rate for this DMA engine + * while transferring data. + * + * This is used as a hint for a number of operations that might + * want to know the possible optimal latency requirements of this + * device. A value of zero will be interpreted as a 'do not care'. + */ + uint_t dlim_dmaspeed; + +} ddi_dma_lim_t; + +#elif defined(__x86) + +/* + * values for dlim_minxfer + */ +#define DMA_UNIT_8 1 +#define DMA_UNIT_16 2 +#define DMA_UNIT_32 4 + +/* + * Version number + */ +#define DMALIM_VER0 ((0x86000000) + 0) + +typedef struct ddi_dma_lim { + + /* + * Low range of 32 bit addressing capability. + */ + uint_t dlim_addr_lo; + + /* + * Upper Inclusive bound of 32 bit addressing capability. + * + * The ISA nexus restricts this to 0x00ffffff, since this bus has + * only 24 address lines. This enforces the 16 Mb address limitation. + * The EISA nexus restricts this to 0xffffffff. + */ + uint_t dlim_addr_hi; + + /* + * DMA engine counter not used; set to 0 + */ + uint_t dlim_cntr_max; + + /* + * DMA burst sizes not used; set to 1 + */ + uint_t dlim_burstsizes; + + /* + * Minimum effective DMA transfer size. + * + * This value specifies the minimum effective granularity of the + * DMA engine. It is distinct from dlim_burstsizes in that it + * describes the minimum amount of access a DMA transfer will + * effect. dlim_burstsizes describes in what electrical fashion + * the DMA engine might perform its accesses, while dlim_minxfer + * describes the minimum amount of memory that can be touched by + * the DMA transfer. + * + * This value also implies the required address alignment. + * The number of bytes transferred is assumed to be + * dlim_minxfer * (DMA engine count) + * + * It should be set to DMA_UNIT_8, DMA_UNIT_16, or DMA_UNIT_32. + */ + uint_t dlim_minxfer; + + /* + * Expected average data rate for this DMA engine + * while transferring data. + * + * This is used as a hint for a number of operations that might + * want to know the possible optimal latency requirements of this + * device. A value of zero will be interpreted as a 'do not care'. + */ + uint_t dlim_dmaspeed; + + + /* + * Version number of this structure + */ + uint_t dlim_version; /* = 0x86 << 24 + 0 */ + + /* + * Inclusive upper bound with which the DMA engine's Address acts as + * a register. + * This handles the case where an upper portion of a DMA address + * register is a latch instead of being a full 32 bit register + * (e.g., the upper 16 bits remain constant while the lower 16 bits + * are incremented for each DMA transfer). + * + * The ISA nexus restricts only 3rd-party DMA requests to 0x0000ffff, + * since the ISA DMA engine has a 16-bit register for low address and + * an 8-bit latch for high address. This enforces the first 64 Kb + * limitation (address boundary). + * The EISA nexus restricts only 3rd-party DMA requests to 0xffffffff. + */ + uint_t dlim_adreg_max; + + /* + * Maximum transfer count that the DMA engine can handle. + * + * The ISA nexus restricts only 3rd-party DMA requests to 0x0000ffff, + * since the ISA DMA engine has a 16-bit register for counting. + * This enforces the other 64 Kb limitation (count size). + * The EISA nexus restricts only 3rd-party DMA requests to 0x00ffffff, + * since the EISA DMA engine has a 24-bit register for counting. + * + * This transfer count limitation is a per segment limitation. + * It can also be used to restrict the size of segments. + * + * This is used as a bit mask, so it must be a power of 2, minus 1. + */ + uint_t dlim_ctreg_max; + + /* + * Granularity of DMA transfer, in units of bytes. + * + * Breakup sizes must be multiples of this value. + * If no scatter/gather capabilty is specified, then the size of + * each DMA transfer must be a multiple of this value. + * + * If there is scatter/gather capability, then a single cookie cannot + * be smaller in size than the minimum xfer value, and may be less + * than the granularity value. The total transfer length of the + * scatter/gather list should be a multiple of the granularity value; + * use dlim_sgllen to specify the length of the scatter/gather list. + * + * This value should be equal to the sector size of the device. + */ + uint_t dlim_granular; + + /* + * Length of scatter/gather list + * + * This value specifies the number of segments or cookies that a DMA + * engine can consume in one i/o request to the device. For 3rd-party + * DMA that uses the bus nexus this should be set to 1. Devices with + * 1st-party DMA capability should specify the number of entries in + * its scatter/gather list. The breakup routine will ensure that each + * group of dlim_sgllen cookies (within a DMA window) will have a + * total transfer length that is a multiple of dlim_granular. + * + * < 0 : tbd + * = 0 : breakup is for PIO. + * = 1 : breakup is for DMA engine with no scatter/gather + * capability. + * >= 2 : breakup is for DMA engine with scatter/gather + * capability; value is max number of entries in list. + * + * Note that this list length is not dependent on the DMA window + * size. The size of the DMA window is based on resources consumed, + * such as intermediate buffers. Several s/g lists may exist within + * a window. But the end of a window does imply the end of the s/g + * list. + */ + short dlim_sgllen; + + /* + * Size of device i/o request + * + * This value indicates the maximum number of bytes the device + * can transmit/receive for one i/o command. This limitation is + * significant ony if it is less than (dlim_ctreg_max * dlim_sgllen). + */ + uint_t dlim_reqsize; + +} ddi_dma_lim_t; + +#else +#error "struct ddi_dma_lim not defined for this architecture" +#endif /* defined(__sparc) */ + +/* + * Flags definition for dma_attr_flags + */ + +/* + * return physical DMA address on platforms + * which support DVMA + */ +#define DDI_DMA_FORCE_PHYSICAL 0x0100 + +/* + * An error will be flagged for DMA data path errors + */ +#define DDI_DMA_FLAGERR 0x200 + +/* + * Enable relaxed ordering + */ +#define DDI_DMA_RELAXED_ORDERING 0x400 + + +/* + * Consolidation private x86 only flag which will cause a bounce buffer + * (paddr < dma_attr_seg) to be used if the buffer passed to the bind + * operation contains pages both above and below dma_attr_seg. If this flag + * is set, dma_attr_seg must be <= dma_attr_addr_hi. + */ +#define _DDI_DMA_BOUNCE_ON_SEG 0x8000 + +#define DMA_ATTR_V0 0 +#define DMA_ATTR_VERSION DMA_ATTR_V0 + +typedef struct ddi_dma_attr { + uint_t dma_attr_version; /* version number */ + uint64_t dma_attr_addr_lo; /* low DMA address range */ + uint64_t dma_attr_addr_hi; /* high DMA address range */ + uint64_t dma_attr_count_max; /* DMA counter register */ + uint64_t dma_attr_align; /* DMA address alignment */ + uint_t dma_attr_burstsizes; /* DMA burstsizes */ + uint32_t dma_attr_minxfer; /* min effective DMA size */ + uint64_t dma_attr_maxxfer; /* max DMA xfer size */ + uint64_t dma_attr_seg; /* segment boundary */ + int dma_attr_sgllen; /* s/g length */ + uint32_t dma_attr_granular; /* granularity of device */ + uint_t dma_attr_flags; /* Bus specific DMA flags */ +} ddi_dma_attr_t; + +/* + * Handy macro to set a maximum bit value (should be elsewhere) + * + * Clear off all bits lower then 'mybit' in val; if there are no + * bits higher than or equal to mybit in val then set mybit. Assumes + * mybit equals some power of 2 and is not zero. + */ +#define maxbit(val, mybit) \ + ((val) & ~((mybit)-1)) | ((((val) & ~((mybit)-1)) == 0) ? (mybit) : 0) + +/* + * Handy macro to set a minimum bit value (should be elsewhere) + * + * Clear off all bits higher then 'mybit' in val; if there are no + * bits lower than or equal to mybit in val then set mybit. Assumes + * mybit equals some pow2 and is not zero. + */ +#define minbit(val, mybit) \ + (((val)&((mybit)|((mybit)-1))) | \ + ((((val) & ((mybit)-1)) == 0) ? (mybit) : 0)) + +/* + * Structure of a request to map an object for DMA. + */ +typedef struct ddi_dma_req { + /* + * Caller's DMA engine constraints. + * + * If there are no particular constraints to the caller's DMA + * engine, this field may be set to NULL. The implementation DMA + * setup functions will then select a set of standard beginning + * constraints. + * + * In either case, as the mapping proceeds, the initial DMA + * constraints may become more restrictive as each intervening + * nexus might add further restrictions. + */ + ddi_dma_lim_t *dmar_limits; + + /* + * Contains the information passed to the DMA mapping allocation + * routine(s). + */ + uint_t dmar_flags; + + /* + * Callback function. A caller of the DMA mapping functions must + * specify by filling in this field whether the allocation routines + * can sleep awaiting mapping resources, must *not* sleep awaiting + * resources, or may *not* sleep awaiting any resources and must + * call the function specified by dmar_fp with the the argument + * dmar_arg when resources might have become available at a future + * time. + */ + int (*dmar_fp)(); + + caddr_t dmar_arg; /* Callback function argument */ + + /* + * Description of the object to be mapped for DMA. + * Must be last in this structure in case that the + * union ddi_dma_obj_t changes in the future. + */ + ddi_dma_obj_t dmar_object; + +} ddi_dma_req_t; + +/* + * Defines for the DMA mapping allocation functions + * + * If a DMA callback funtion is set to anything other than the following + * defines then it is assumed that one wishes a callback and is providing + * a function address. + */ +#define DDI_DMA_DONTWAIT ((int (*)(caddr_t))0) +#define DDI_DMA_SLEEP ((int (*)(caddr_t))1) + +/* + * Return values from callback functions. + */ +#define DDI_DMA_CALLBACK_RUNOUT 0 +#define DDI_DMA_CALLBACK_DONE 1 + +/* + * Flag definitions for the allocation functions. + */ +#define DDI_DMA_WRITE 0x0001 /* Direction memory --> IO */ +#define DDI_DMA_READ 0x0002 /* Direction IO --> memory */ +#define DDI_DMA_RDWR (DDI_DMA_READ | DDI_DMA_WRITE) + +/* + * If possible, establish a MMU redzone after the mapping (to protect + * against cheap DMA hardware that might get out of control). + */ +#define DDI_DMA_REDZONE 0x0004 + +/* + * A partial allocation is allowed. That is, if the size of the object + * exceeds the mapping resources available, only map a portion of the + * object and return status indicating that this took place. The caller + * can use the functions ddi_dma_numwin(9F) and ddi_dma_getwin(9F) to + * change, at a later point, the actual mapped portion of the object. + * + * The mapped portion begins at offset 0 of the object. + * + */ +#define DDI_DMA_PARTIAL 0x0008 + +/* + * Map the object for byte consistent access. Note that explicit + * synchronization (via ddi_dma_sync(9F)) will still be required. + * Consider this flag to be a hint to the mapping routines as to + * the intended use of the mapping. + * + * Normal data transfers can be usually consider to use 'streaming' + * modes of operations. They start at a specific point, transfer a + * fairly large amount of data sequentially, and then stop (usually + * on a well aligned boundary). + * + * Control mode data transfers (for memory resident device control blocks, + * e.g., ethernet message descriptors) do not access memory in such + * a streaming sequential fashion. Instead, they tend to modify a few + * words or bytes, move around and maybe modify a few more. + * + * There are many machine implementations that make this difficult to + * control in a generic and seamless fashion. Therefore, explicit synch- + * ronization steps (via ddi_dma_sync(9F)) are still required (even if you + * ask for a byte-consistent mapping) in order to make the view of the + * memory object shared between a CPU and a DMA master in consistent. + * However, judicious use of this flag can give sufficient hints to + * the mapping routines to attempt to pick the most efficacious mapping + * such that the synchronization steps are as efficient as possible. + * + */ +#define DDI_DMA_CONSISTENT 0x0010 + +/* + * Some DMA mappings have to be 'exclusive' access. + */ +#define DDI_DMA_EXCLUSIVE 0x0020 + +/* + * Sequential, unidirectional, block-sized and block aligned transfers + */ +#define DDI_DMA_STREAMING 0x0040 + +/* + * Support for 64-bit SBus devices + */ +#define DDI_DMA_SBUS_64BIT 0x2000 + +/* + * Return values from the mapping allocation functions. + */ + +/* + * succeeded in satisfying request + */ +#define DDI_DMA_MAPPED 0 + +/* + * Mapping is legitimate (for advisory calls). + */ +#define DDI_DMA_MAPOK 0 + +/* + * Succeeded in mapping a portion of the request. + */ +#define DDI_DMA_PARTIAL_MAP 1 + +/* + * indicates end of window/segment list + */ +#define DDI_DMA_DONE 2 + +/* + * No resources to map request. + */ +#define DDI_DMA_NORESOURCES -1 + +/* + * Can't establish a mapping to the specified object + * (no specific reason). + */ +#define DDI_DMA_NOMAPPING -2 + +/* + * The request is too big to be mapped. + */ +#define DDI_DMA_TOOBIG -3 + +/* + * The request is too small to be mapped. + */ +#define DDI_DMA_TOOSMALL -4 + +/* + * The request cannot be mapped because the object + * is locked against mapping by another DMA master. + */ +#define DDI_DMA_LOCKED -5 + +/* + * The request cannot be mapped because the limits + * structure has bogus values. + */ +#define DDI_DMA_BADLIMITS -6 + +/* + * the segment/window pointer is stale + */ +#define DDI_DMA_STALE -7 + +/* + * The system can't allocate DMA resources using + * the given DMA attributes + */ +#define DDI_DMA_BADATTR -8 + +/* + * A DMA handle is already used for a DMA + */ +#define DDI_DMA_INUSE -9 + + +/* + * DVMA disabled or not supported. use physical DMA + */ +#define DDI_DMA_USE_PHYSICAL -10 + + +/* + * In order for the access to a memory object to be consistent + * between a device and a CPU, the function ddi_dma_sync(9F) + * must be called upon the DMA handle. The following flags + * define whose view of the object should be made consistent. + * There are different flags here because on different machines + * there are definite performance implications of how long + * such synchronization takes. + * + * DDI_DMA_SYNC_FORDEV makes all device references to the object + * mapped by the DMA handle up to date. It should be used by a + * driver after a cpu modifies the memory object (over the range + * specified by the other arguments to the ddi_dma_sync(9F) call). + * + * DDI_DMA_SYNC_FORCPU makes all cpu references to the object + * mapped by the DMA handle up to date. It should be used + * by a driver after the receipt of data from the device to + * the memory object is done (over the range specified by + * the other arguments to the ddi_dma_sync(9F) call). + * + * If the only mapping that concerns the driver is one for the + * kernel (such as memory allocated by ddi_iopb_alloc(9F)), the + * flag DDI_DMA_SYNC_FORKERNEL can be used. This is a hint to the + * system that if it can synchronize the kernel's view faster + * that the CPU's view, it can do so, otherwise it acts the + * same as DDI_DMA_SYNC_FORCPU. DDI_DMA_SYNC_FORKERNEL might + * speed up the synchronization of kernel mappings in case of + * non IO-coherent CPU caches. + */ +#define DDI_DMA_SYNC_FORDEV 0x0 +#define DDI_DMA_SYNC_FORCPU 0x1 +#define DDI_DMA_SYNC_FORKERNEL 0x2 + +/* + * Bus nexus control functions for DMA + */ + +/* + * Control operations, defined here so that devops.h can be included + * by drivers without having to include a specific SYSDDI implementation + * header file. + */ + +enum ddi_dma_ctlops { + DDI_DMA_FREE, /* obsolete - do not use */ + DDI_DMA_SYNC, /* obsolete - do not use */ + DDI_DMA_HTOC, /* obsolete - do not use */ + DDI_DMA_KVADDR, /* obsolete - do not use */ + DDI_DMA_MOVWIN, /* obsolete - do not use */ + DDI_DMA_REPWIN, /* obsolete - do not use */ + DDI_DMA_GETERR, /* obsolete - do not use */ + DDI_DMA_COFF, /* obsolete - do not use */ + DDI_DMA_NEXTWIN, /* obsolete - do not use */ + DDI_DMA_NEXTSEG, /* obsolete - do not use */ + DDI_DMA_SEGTOC, /* obsolete - do not use */ + DDI_DMA_RESERVE, /* reserve some DVMA range */ + DDI_DMA_RELEASE, /* free preallocated DVMA range */ + DDI_DMA_RESETH, /* obsolete - do not use */ + DDI_DMA_CKSYNC, /* obsolete - do not use */ + DDI_DMA_IOPB_ALLOC, /* obsolete - do not use */ + DDI_DMA_IOPB_FREE, /* obsolete - do not use */ + DDI_DMA_SMEM_ALLOC, /* obsolete - do not use */ + DDI_DMA_SMEM_FREE, /* obsolete - do not use */ + DDI_DMA_SET_SBUS64, /* 64 bit SBus support */ + DDI_DMA_REMAP, /* remap DVMA buffers after relocation */ + + /* + * control ops for DMA engine on motherboard + */ + DDI_DMA_E_ACQUIRE, /* get channel for exclusive use */ + DDI_DMA_E_FREE, /* release channel */ + DDI_DMA_E_1STPTY, /* setup channel for 1st party DMA */ + DDI_DMA_E_GETCB, /* get control block for DMA engine */ + DDI_DMA_E_FREECB, /* free control blk for DMA engine */ + DDI_DMA_E_PROG, /* program channel of DMA engine */ + DDI_DMA_E_SWSETUP, /* setup channel for software control */ + DDI_DMA_E_SWSTART, /* software operation of DMA channel */ + DDI_DMA_E_ENABLE, /* enable channel of DMA engine */ + DDI_DMA_E_STOP, /* stop a channel of DMA engine */ + DDI_DMA_E_DISABLE, /* disable channel of DMA engine */ + DDI_DMA_E_GETCNT, /* get remaining xfer count */ + DDI_DMA_E_GETLIM, /* obsolete - do not use */ + DDI_DMA_E_GETATTR /* get DMA engine attributes */ +}; + +/* + * Cache attribute flags: + * + * IOMEM_DATA_CACHED + * The CPU can cache the data it fetches and push it to memory at a later + * time. This is the default attribute and used if no cache attributes is + * specified. + * + * IOMEM_DATA_UC_WR_COMBINE + * The CPU never caches the data but writes may occur out of order or be + * combined. It implies re-ordering. + * + * IOMEM_DATA_UNCACHED + * The CPU never caches the data and has uncacheable access to memory. + * It also implies strict ordering. + * + * The cache attributes are mutually exclusive, and any combination of the + * values leads to a failure. On the sparc architecture, only IOMEM_DATA_CACHED + * is meaningful, but others lead to a failure. + */ +#define IOMEM_DATA_CACHED 0x10000 /* data is cached */ +#define IOMEM_DATA_UC_WR_COMBINE 0x20000 /* data is not cached, but */ + /* writes might be combined */ +#define IOMEM_DATA_UNCACHED 0x40000 /* data is not cached. */ +#define IOMEM_DATA_MASK 0xF0000 /* cache attrs mask */ + +/* + * Check if either uncacheable or write-combining specified. (those flags are + * mutually exclusive) This macro is used to override hat attributes if either + * one is set. + */ +#define OVERRIDE_CACHE_ATTR(attr) \ + (attr & (IOMEM_DATA_UNCACHED | IOMEM_DATA_UC_WR_COMBINE)) + +/* + * Get the cache attribute from flags. If there is no attributes, + * return IOMEM_DATA_CACHED (default attribute). + */ +#define IOMEM_CACHE_ATTR(flags) \ + ((flags & IOMEM_DATA_MASK) ? (flags & IOMEM_DATA_MASK) : \ + IOMEM_DATA_CACHED) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDIDMAREQ_H */ diff --git a/illumos-x86_64/usr/include/sys/ddifm.h b/illumos-x86_64/usr/include/sys/ddifm.h new file mode 100644 index 00000000..ef2dc453 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddifm.h @@ -0,0 +1,128 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DDIFM_H +#define _DDIFM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +extern int ddi_system_fmcap; + +/* Fault Management error handling */ + +/* Error handling return status */ +#define DDI_FM_OK 0 +#define DDI_FM_FATAL -1 +#define DDI_FM_NONFATAL -2 +#define DDI_FM_UNKNOWN -3 + +/* Driver fault management capabilities */ +#define DDI_FM_NOT_CAPABLE 0x00000000 +#define DDI_FM_EREPORT_CAPABLE 0x00000001 +#define DDI_FM_ACCCHK_CAPABLE 0x00000002 +#define DDI_FM_DMACHK_CAPABLE 0x00000004 +#define DDI_FM_ERRCB_CAPABLE 0x00000008 + +#define DDI_FM_DEFAULT_CAP(cap) (cap == DDI_FM_NOT_CAPABLE) +#define DDI_FM_EREPORT_CAP(cap) (cap & DDI_FM_EREPORT_CAPABLE) +#define DDI_FM_ACC_ERR_CAP(cap) (cap & DDI_FM_ACCCHK_CAPABLE) +#define DDI_FM_DMA_ERR_CAP(cap) (cap & DDI_FM_DMACHK_CAPABLE) +#define DDI_FM_ERRCB_CAP(cap) (cap & DDI_FM_ERRCB_CAPABLE) + +/* error expectation values */ +#define DDI_FM_ERR_UNEXPECTED 0 +#define DDI_FM_ERR_EXPECTED 1 +#define DDI_FM_ERR_POKE 2 +#define DDI_FM_ERR_PEEK 3 + +#ifdef _KERNEL + +typedef struct ddi_fm_error { + int fme_version; /* version of this structure */ + int fme_status; /* status for this error */ + int fme_flag; /* error expectation flag */ + uint64_t fme_ena; /* ENA for this error */ + ddi_acc_handle_t fme_acc_handle; /* optional acc handle */ + ddi_dma_handle_t fme_dma_handle; /* optional dma handle */ + void *fme_bus_specific; /* optional bus specific err */ + int fme_bus_type; /* optional bus type */ +} ddi_fm_error_t; + +#define DDI_FME_VER0 0 +#define DDI_FME_VER1 1 +#define DDI_FME_VERSION DDI_FME_VER1 + +#define DDI_FME_BUS_TYPE_DFLT 0 /* bus type = default */ +#define DDI_FME_BUS_TYPE_PCI 1 /* bus type = pci/pcix/pcie */ + +typedef int (*ddi_err_func_t)(dev_info_t *, ddi_fm_error_t *, const void *); + +/* + * DDI for error handling and ereport generation + */ + +/* + * ereport generation: [ddi|ndi]_fm_ereport_post + */ +extern void ddi_fm_ereport_post(dev_info_t *, const char *, uint64_t, int, ...); +extern void ndi_fm_ereport_post(dev_info_t *, const char *, uint64_t, int, ...); + +/* + * service changes: + * + * After a hardened driver raises an ereport (or after pci_ereport_post() has + * raised an ereport for an event which implecated one of a driver's access or + * dma handles), the driver should always determine the service impact and + * report it. + */ +extern void ddi_fm_service_impact(dev_info_t *, int); + +/* error handling */ +extern void ddi_fm_handler_register(dev_info_t *, ddi_err_func_t, void *); +extern void ddi_fm_handler_unregister(dev_info_t *); + +/* fault management initialization and clean-up */ +extern void ddi_fm_init(dev_info_t *, int *, ddi_iblock_cookie_t *); +extern void ddi_fm_fini(dev_info_t *); +extern int ddi_fm_capable(dev_info_t *dip); + +/* access and dma handle error protection */ +extern void ddi_fm_dma_err_get(ddi_dma_handle_t, ddi_fm_error_t *, int); +extern void ddi_fm_acc_err_get(ddi_acc_handle_t, ddi_fm_error_t *, int); +extern void ddi_fm_dma_err_clear(ddi_dma_handle_t, int); +extern void ddi_fm_acc_err_clear(ddi_acc_handle_t, int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DDIFM_H */ diff --git a/illumos-x86_64/usr/include/sys/ddifm_impl.h b/illumos-x86_64/usr/include/sys/ddifm_impl.h new file mode 100644 index 00000000..05535f57 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddifm_impl.h @@ -0,0 +1,138 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _DDIFM_IMPL_H +#define _DDIFM_IMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct i_ddi_fmkstat { + kstat_named_t fek_erpt_dropped; /* total ereports dropped */ + kstat_named_t fek_fmc_miss; /* total fmc misses */ + kstat_named_t fek_fmc_full; /* total fmc allocs fail */ + kstat_named_t fek_acc_err; /* total access errors */ + kstat_named_t fek_dma_err; /* total dma errors */ +}; + +/* Fault management error handler support */ + +#define DDI_MAX_ERPT_CLASS 64 +#define DDI_FM_STKDEPTH 20 +#define DDI_FM_SYM_SZ 64 + +struct i_ddi_errhdl { + int (*eh_func)(); /* error handler callback */ + void *eh_impl; /* callback arg */ +}; + +/* Fault management resource cache support */ + +struct i_ddi_fmc_entry { + struct i_ddi_fmc_entry *fce_prev; + struct i_ddi_fmc_entry *fce_next; + void *fce_resource; /* acc or DMA handle cached */ + void *fce_bus_specific; /* Bus-specific handle data */ +}; + +struct i_ddi_fmc { + kmutex_t fc_lock; /* cache active access */ + struct i_ddi_fmc_entry *fc_head; /* active handle list */ + struct i_ddi_fmc_entry *fc_tail; /* tail of active handle list */ +}; + +/* Error handler targets */ +struct i_ddi_fmtgt { + struct i_ddi_fmtgt *ft_next; /* next fm child target */ + dev_info_t *ft_dip; /* fm target error handler dip */ + struct i_ddi_errhdl *ft_errhdl; /* error handler */ +}; + +struct i_ddi_fmhdl { + kmutex_t fh_lock; /* error handler lock */ + kthread_t *fh_lock_owner; + struct i_ddi_fmc *fh_dma_cache; /* fm dma handle cache */ + struct i_ddi_fmc *fh_acc_cache; /* fm access handle cache */ + dev_info_t *fh_dip; + kstat_t *fh_ksp; /* pointer to installed kstat */ + int fh_cap; /* fm level for this instance */ + struct i_ddi_fmkstat fh_kstat; /* fm kstats for this inst */ + errorq_t *fh_errorq; /* errorq for this instance */ + nvlist_t *fh_fmri; /* optional fmri */ + ddi_iblock_cookie_t fh_ibc; /* ibc for error handling */ + struct i_ddi_fmtgt *fh_tgts; /* registered fm tgts */ + void *fh_bus_specific; /* Bus specific FM info */ +}; + +typedef struct pci_fm_err { + char *err_class; + uint32_t reg_bit; + char *terr_class; + int flags; +} pci_fm_err_t; + +extern pci_fm_err_t pci_err_tbl[]; + +#ifdef _KERNEL +typedef int (*ddi_fmcompare_t)(dev_info_t *, const void *, const void *, + const void *); + +extern void ndi_fm_init(void); + +/* driver defect error reporting */ +extern void i_ddi_drv_ereport_post(dev_info_t *, const char *, nvlist_t *, int); + +/* target error handler add/remove/dispatch */ +extern void i_ddi_fm_handler_enter(dev_info_t *); +extern void i_ddi_fm_handler_exit(dev_info_t *); +extern boolean_t i_ddi_fm_handler_owned(dev_info_t *); + +/* access and dma handle protection support */ +extern void i_ddi_fm_acc_err_set(ddi_acc_handle_t, uint64_t, int, int); +extern void i_ddi_fm_dma_err_set(ddi_dma_handle_t, uint64_t, int, int); +extern ddi_fmcompare_t i_ddi_fm_acc_err_cf_get(ddi_acc_handle_t); +extern ddi_fmcompare_t i_ddi_fm_dma_err_cf_get(ddi_dma_handle_t); + +/* fm busop support */ +extern void i_ndi_busop_access_enter(dev_info_t *, ddi_acc_handle_t); +extern void i_ndi_busop_access_exit(dev_info_t *, ddi_acc_handle_t); +extern int i_ndi_busop_fm_init(dev_info_t *, int, ddi_iblock_cookie_t *); +extern void i_ndi_busop_fm_fini(dev_info_t *); + +/* fm cache support */ +void i_ndi_fmc_create(struct i_ddi_fmc **, int, ddi_iblock_cookie_t); +void i_ndi_fmc_destroy(struct i_ddi_fmc *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DDIFM_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/ddimapreq.h b/illumos-x86_64/usr/include/sys/ddimapreq.h new file mode 100644 index 00000000..90dd9576 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddimapreq.h @@ -0,0 +1,135 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991-1994 Sun Microsystems, Inc. + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _SYS_DDIMAPREQ_H +#define _SYS_DDIMAPREQ_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Mapping requests are for an rnumber or for a regspec. + * + * A regspec is a generic triple, usually representing + * type, offset, length + * + * And is interpreted privately between the child and parent. + * The triple should be sufficient for representing byte addressable devices. + */ + +typedef union { + int rnumber; + struct regspec *rp; +} ddi_map_obj_t; + +typedef enum { + DDI_MT_RNUMBER = 0, + DDI_MT_REGSPEC +} ddi_map_type_t; + +/* + * Mapping operators: + */ +typedef enum { + DDI_MO_MAP_UNLOCKED = 0, /* Create mapping, do not lock down */ + DDI_MO_MAP_LOCKED, /* Create locked down mapping */ + DDI_MO_MAP_HANDLE, /* Create handle, do not map */ + DDI_MO_UNMAP, /* Unmap (implies unlock, if locked) */ + DDI_MO_UNLOCK /* Unlock mapping, do *not* unmap */ +} ddi_map_op_t; + +/* + * Mapping request structure... + */ + +typedef struct { + ddi_map_op_t map_op; + ddi_map_type_t map_type; + ddi_map_obj_t map_obj; + uint_t map_flags; /* See below... */ + int map_prot; /* Prot bits (see sys/mman.h) */ + ddi_acc_hdl_t *map_handlep; + int map_vers; +} ddi_map_req_t; + +/* + * version number + */ +#define DDI_MAP_VERSION 0x0001 + +/* + * Mappings subject to the following flags: + */ + + /* + * Make mapping suitable for user program use. + */ +#define DDI_MF_USER_MAPPING 0x1 + + /* + * Make mapping suitable for kernel mapping. + */ +#define DDI_MF_KERNEL_MAPPING 0x2 +#define DDI_MF_DEVICE_MAPPING 0x4 + +/* + * The upper bits of map_flags are reserved for platform-specific flags. These + * start with the highest bit and then work their way down. Currently only one + * bit is used, and only on x86. + */ + /* + * Indicates that there is an extended register + * specification (fully 64-bit aware) being used. This + * should only be used by children of the x86 root nexus + * driver. + */ +#define DDI_MF_EXT_REGSPEC 0x80000000 + +#endif /* _KERNEL */ + +/* + * Error (non-zero) return codes from DDI mapping functions... + */ + +#define DDI_ME_GENERIC (-1) /* Generic un-enumerated error */ +#define DDI_ME_UNIMPLEMENTED (-2) /* Unimplemented operator */ +#define DDI_ME_NORESOURCES (-3) /* No resources, try later? */ +#define DDI_ME_UNSUPPORTED (-4) /* Op is not supported in impl. */ +#define DDI_ME_REGSPEC_RANGE (-5) /* Addressing range error */ +#define DDI_ME_RNUMBER_RANGE (-6) /* Addressing range error */ +#define DDI_ME_INVAL (-7) /* Invalid input parameter */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDIMAPREQ_H */ diff --git a/illumos-x86_64/usr/include/sys/ddipropdefs.h b/illumos-x86_64/usr/include/sys/ddipropdefs.h new file mode 100644 index 00000000..5e7427d4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ddipropdefs.h @@ -0,0 +1,340 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DDIPROPDEFS_H +#define _SYS_DDIPROPDEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ddiprops.h: All definitions related to DDI properties. + * Structure definitions are private to the DDI + * implementation. See also, ddipropfuncs.h + */ + +/* + * ddi_prop_op_t: Enum for prop_op functions + */ + +typedef enum { + PROP_LEN = 0, /* Get prop len only */ + PROP_LEN_AND_VAL_BUF, /* Get len+val into callers buffer */ + PROP_LEN_AND_VAL_ALLOC, /* Get len+val into alloc-ed buffer */ + PROP_EXISTS /* Does the property exist? */ +} ddi_prop_op_t; + +/* + * ddi_prop_t: The basic item used to store software defined propeties. + * Note that properties are always stored by reference. + */ + +typedef struct ddi_prop { + struct ddi_prop *prop_next; + dev_t prop_dev; /* specific match/wildcard */ + char *prop_name; /* Property name */ + int prop_flags; /* See flags below */ + int prop_len; /* Prop length (0 == Bool. prop) */ + caddr_t prop_val; /* ptr to property value */ +} ddi_prop_t; + +/* + * A referenced property list, used for sharing properties among + * multiple driver instances + */ +typedef struct ddi_prop_list { + ddi_prop_t *prop_list; + int prop_ref; +} ddi_prop_list_t; + +/* + * Handle passed around to encode/decode a property value. + */ +typedef struct ddi_prop_handle { + void *ph_data; /* Encoded data */ + void *ph_cur_pos; /* encode/decode position */ + void *ph_save_pos; /* Save/restore position */ + uint_t ph_size; /* Size of encoded data */ + uint_t ph_flags; /* See below */ + struct prop_handle_ops *ph_ops; /* Encode/decode routines */ +} prop_handle_t; + +/* + * Property handle encode/decode ops + */ +typedef struct prop_handle_ops { + int (*op_prop_int)(prop_handle_t *ph, uint_t cmd, int *data); + int (*op_prop_str)(prop_handle_t *ph, uint_t cmd, char *data); + int (*op_prop_bytes)(prop_handle_t *ph, uint_t cmd, + uchar_t *data, uint_t size); + int (*op_prop_int64)(prop_handle_t *ph, uint_t cmd, int64_t *data); +} prop_handle_ops_t; + +/* + * Data passed back to driver. The driver gets a pointer to driver_data. + * When we get it back we do negative indexing to find the size and free + * routine to call + */ +struct prop_driver_data { + size_t pdd_size; + void (*pdd_prop_free)(struct prop_driver_data *); +}; + + +/* + * Macros to call the integer/string/byte OBP 1275 operators + */ +#define DDI_PROP_INT(ph, cmd, data) \ + (*(ph)->ph_ops->op_prop_int)((ph), (cmd), (data)) +#define DDI_PROP_STR(ph, cmd, data) \ + (*(ph)->ph_ops->op_prop_str)((ph), (cmd), (data)) +#define DDI_PROP_BYTES(ph, cmd, data, size) \ + (*(ph)->ph_ops->op_prop_bytes)((ph), (cmd), (data), (size)) + +/* + * Macro to call the 64 bit integer operator + */ +#define DDI_PROP_INT64(ph, cmd, data) \ + (*(ph)->ph_ops->op_prop_int64)((ph), (cmd), (data)) + +/* + * Property handle commands + */ +typedef enum { + DDI_PROP_CMD_GET_ESIZE, /* Get encoded size of data */ + DDI_PROP_CMD_GET_DSIZE, /* Get decoded size of data */ + DDI_PROP_CMD_DECODE, /* Decode the current data */ + DDI_PROP_CMD_ENCODE, /* Encode the current data */ + DDI_PROP_CMD_SKIP /* Skip the current data */ +} ddi_prop_cmd_t; + +/* + * Return values from property handle encode/decode ops + * Positive numbers are used to return the encoded or + * decode size of the object, so an ok return must be positive, + * and all error returns negative. + */ +typedef enum { + DDI_PROP_RESULT_ERROR = -2, /* error in encoding/decoding data */ + DDI_PROP_RESULT_EOF, /* end of data reached */ + DDI_PROP_RESULT_OK /* if >= to DDI_PROP_RESULT_OK, */ + /* operation was successful */ +} ddi_prop_result_t; + +/* 1275 property cell */ +typedef uint32_t prop_1275_cell_t; + +/* Length of a 1275 property cell */ +#define PROP_1275_CELL_SIZE sizeof (prop_1275_cell_t) +#define CELLS_1275_TO_BYTES(n) ((n) * PROP_1275_CELL_SIZE) +#define BYTES_TO_1275_CELLS(n) ((n) / PROP_1275_CELL_SIZE) + +/* + * Property handle flags + */ +#define PH_FROM_PROM 0x01 /* Property came from the prom */ + +/* + * Return values from property functions: + */ + +#define DDI_PROP_SUCCESS 0 +#define DDI_PROP_NOT_FOUND 1 /* Prop not defined */ +#define DDI_PROP_UNDEFINED 2 /* Overriden to undefine a prop */ +#define DDI_PROP_NO_MEMORY 3 /* Unable to allocate/no sleep */ +#define DDI_PROP_INVAL_ARG 4 /* Invalid calling argument */ +#define DDI_PROP_BUF_TOO_SMALL 5 /* Callers buf too small */ +#define DDI_PROP_CANNOT_DECODE 6 /* Could not decode prop */ +#define DDI_PROP_CANNOT_ENCODE 7 /* Could not encode prop */ +#define DDI_PROP_END_OF_DATA 8 /* Prop found in an encoded format */ + +/* + * used internally in the framework only + */ +#define DDI_PROP_FOUND_1275 255 /* Prop found in OPB 1275 format */ + +/* + * Size of a 1275 int in bytes + */ +#define PROP_1275_INT_SIZE 4 + +/* + * Property flags: + */ + +#define DDI_PROP_DONTPASS 0x0001 /* Don't pass request to parent */ +#define DDI_PROP_CANSLEEP 0x0002 /* Memory allocation may sleep */ + +/* + * Used internally by the DDI property rountines and masked in DDI(9F) + * interfaces... + */ + +#define DDI_PROP_SYSTEM_DEF 0x0004 /* System defined property */ + +/* + * Used in framework only, to inhibit certain pre-defined s/w property + * names from coming from the prom. + */ +#define DDI_PROP_NOTPROM 0x0008 /* Don't look at prom properties */ + +/* + * Used interally by the DDI property routines to implement the old + * depricated functions with the new functions + */ +#define DDI_PROP_DONTSLEEP 0x0010 /* Memory allocation may not sleep */ +#define DDI_PROP_STACK_CREATE 0x0020 /* Do a LIFO stack of properties */ +#define DDI_PROP_UNDEF_IT 0x0040 /* Undefine a property */ +#define DDI_PROP_HW_DEF 0x0080 /* Hardware defined property */ + +/* + * Type of data property contains + */ +#define DDI_PROP_TYPE_INT 0x0100 +#define DDI_PROP_TYPE_STRING 0x0200 +#define DDI_PROP_TYPE_BYTE 0x0400 +#define DDI_PROP_TYPE_COMPOSITE 0x0800 +#define DDI_PROP_TYPE_INT64 0x1000 + +#define DDI_PROP_TYPE_ANY (DDI_PROP_TYPE_INT | \ + DDI_PROP_TYPE_STRING | \ + DDI_PROP_TYPE_BYTE | \ + DDI_PROP_TYPE_COMPOSITE) + +#define DDI_PROP_TYPE_MASK (DDI_PROP_TYPE_INT | \ + DDI_PROP_TYPE_STRING | \ + DDI_PROP_TYPE_BYTE | \ + DDI_PROP_TYPE_COMPOSITE | \ + DDI_PROP_TYPE_INT64) + +/* + * This flag indicates that the LDI lookup routine + * should match the request regardless of the actual + * dev_t with which the property was created. In other + * words, any dev_t value found on the property list + * is an acceptable part of the match criteria. + */ +#define LDI_DEV_T_ANY 0x2000 + +/* + * Private flag that should ONLY be used by the LDI Framework + * to indicate a property search of an unbound dlpi2 dip. + * The LDI property lookup interfaces will set this flag if + * it is determined that the dip representing a dlpi-style2 + * driver is currently unbound (dip == NULL) at the time of + * the property lookup request. + */ +#define DDI_UNBND_DLPI2 0x4000 + +/* + * Private flag that indicates that a typed interface that predates typed + * properties is being used - the framework should set additional typed flags + * (DDI_PROP_TYPE_INT64) when expanding search to DDI_PROP_TYPE_ANY. + */ +#define DDI_PROP_CONSUMER_TYPED 0x8000 + +/* + * Private flag that indicates that the ldi is doing a driver prop_op + * call to check for driver dynamic properties. This request should + * not be passed onto the common property lookup framework since all + * the ldi property interface are typed and driver prop_op lookups are + * not. + */ +#define DDI_PROP_DYNAMIC 0x10000 + +/* + * Private flag used to lookup global properties specified in rootnex.conf file + */ +#define DDI_PROP_ROOTNEX_GLOBAL 0x20000 + + +/* + * DDI_DEV_T_NONE: When creating, property is not associated with + * particular dev_t. + * DDI_DEV_T_ANY: Wildcard dev_t when searching properties. + */ +#define DDI_DEV_T_NONE ((dev_t)-1) +#define DDI_DEV_T_ANY ((dev_t)-2) +/* + * DDI_MAJOR_T_UNKNOWN Used when a driver does not know its dev_t during + * a property create. + * DDI_MAJOR_T_NONE Used when a driver does not have a major number. + */ +#define DDI_MAJOR_T_UNKNOWN ((major_t)0) +#define DDI_MAJOR_T_NONE ((major_t)-1) + +/* + * Some DDI property names... + */ + +/* + * One of the following boolean properties shall be defined in the + * root node, and defines the addressing mode understood by the root + * node of the implementation.... + */ + +#define DDI_RELATIVE_ADDRESSING "relative-addressing" +#define DDI_GENERIC_ADDRESSING "generic-addressing" + +/* + * Common property encoded data search routine. Returns the encoded data + * in valuep. Match is done on dip, dev, data type (in flags), and name. + */ +int ddi_prop_search_common(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, + uint_t flags, char *name, void *valuep, uint_t *lengthp); + + +/* + * Property debugging support in kernel... + */ + +/* + * Property debugging support... Be careful about enabling this when + * you are tipping in to the console. Undefine PROP_DEBUG to remove + * all support from the code. (c.f. autoconf.c and zs_common.c) + * + * It does no good to enable this if the rest of the kernel was built with + * this disabled (specifically, the core kernel module.) + * + * #define DDI_PROP_DEBUG 1 + */ + +#ifdef DDI_PROP_DEBUG +#define ddi_prop_printf if (ddi_prop_debug_flag != 0) printf + +/* + * Returns prev value of debugging flag, non-zero enables debug printf's + */ + +int ddi_prop_debug(int enable); + +#endif /* DDI_PROP_DEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDIPROPDEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/dditypes.h b/illumos-x86_64/usr/include/sys/dditypes.h new file mode 100644 index 00000000..bdb2a393 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dditypes.h @@ -0,0 +1,326 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_DDITYPES_H +#define _SYS_DDITYPES_H + +#include +#ifndef _ASM +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM +/* + * DMA types + * + * A DMA handle represent a "DMA object". A DMA object is an abstraction + * that represents the potential source or destination of DMA transfers to + * or from a device. The DMA object is the highest level description of + * the source or destination and is not suitable for the actual transfer. + * + * Note, that we avoid the specific references to "mapping". The fact that + * a transfer requires mapping is an artifact of the specific architectural + * implementation. + */ +typedef struct __ddi_dma_handle *ddi_dma_handle_t; + +/* + * A dma window type represents a "DMA window". A DMA window is a portion + * of a dma object or might be the entire object. A DMA window has had system + * resources allocated to it and is prepared to be transferred into or + * out of. Examples of system resources are DVMA mapping resources and + * intermediate transfer buffer resources. + * + */ +typedef struct __ddi_dma_win *ddi_dma_win_t; + + +/* + * A dma segment type represents a "DMA segment". A dma segment is a + * contiguous portion of a DMA window which is entirely addressable by the + * device for a transfer operation. One example where DMA segments are + * required is where the system does not contain DVMA capability and + * the object or window may be non-contiguous. In this example the + * object or window will be broken into smaller contiguous segments. + * Another example is where a device or some intermediary bus adapter has + * some upper limit on its transfer size (i.e. an 8-bit address register). + * In this example the object or window will be broken into smaller + * addressable segments. + */ +typedef struct __ddi_dma_seg *ddi_dma_seg_t; + +/* + * A DMA cookie contains DMA address information required to + * program a DMA engine + */ +typedef struct { + union { + uint64_t _dmac_ll; /* 64 bit DMA address */ + uint32_t _dmac_la[2]; /* 2 x 32 bit address */ + } _dmu; + size_t dmac_size; /* DMA cookie size */ + uint_t dmac_type; /* bus specific type bits */ +} ddi_dma_cookie_t; + +#define dmac_laddress _dmu._dmac_ll +#ifdef _LONG_LONG_HTOL +#define dmac_notused _dmu._dmac_la[0] +#define dmac_address _dmu._dmac_la[1] +#else +#define dmac_address _dmu._dmac_la[0] +#define dmac_notused _dmu._dmac_la[1] +#endif + +/* + * Interrupt types + */ + +/* + * Both ddi_iblock_cookie_t and ddi_idevice_cookie_t are + * obsolete data structures. + * + * lock initialization type + */ +typedef struct __ddi_iblock_cookie *ddi_iblock_cookie_t; +typedef union { + struct { + ushort_t _idev_vector; /* vector - bus dependent */ + ushort_t _idev_priority; /* priority - bus dependent */ + } idu; + uint_t idev_softint; /* Soft interrupt register bit(s) */ +} ddi_idevice_cookie_t; +#define idev_vector idu._idev_vector +#define idev_priority idu._idev_priority + +/* + * register specification + */ +typedef struct __ddi_regspec *ddi_regspec_t; + +/* + * interrupt specification + */ +typedef struct __ddi_intrspec *ddi_intrspec_t; + +/* + * ddi_softintr_t is an obsolete data structure. + * + * soft interrupt id + */ +typedef struct __ddi_softintr *ddi_softintr_t; + +/* + * opaque device info handle + */ +typedef struct __dev_info *dev_info_t; + +/* + * Mapping cookie for devmap(9E) + */ +typedef struct __ddi_devmap_data *ddi_devmap_data_t; + +/* + * Opaque Device id + */ +typedef struct __ddi_devid *ddi_devid_t; + +/* + * Device id types + */ +#define DEVID_NONE 0 +#define DEVID_SCSI3_WWN 1 +#define DEVID_SCSI_SERIAL 2 +#define DEVID_FAB 3 +#define DEVID_ENCAP 4 +#define DEVID_ATA_SERIAL 5 +#define DEVID_SCSI3_VPD_T10 6 +#define DEVID_SCSI3_VPD_EUI 7 +#define DEVID_SCSI3_VPD_NAA 8 +#define DEVID_NVME_NSID 9 +#define DEVID_NVME_EUI64 10 +#define DEVID_NVME_NGUID 11 +#define DEVID_MAXTYPE 11 + +/* + * Device id scsi encode versions (version of encode interface, not devid) + */ +#define DEVID_SCSI_ENCODE_VERSION1 0 +#define DEVID_SCSI_ENCODE_VERSION2 1 +#define DEVID_SCSI_ENCODE_VERSION_LATEST DEVID_SCSI_ENCODE_VERSION2 + +/* + * Device id smp encode versions (version of encode interface, not devid) + */ +#define DEVID_SMP_ENCODE_VERSION1 0 +#define DEVID_SMP_ENCODE_VERSION_LATEST DEVID_SMP_ENCODE_VERSION1 + +/* minor name values for devid lookup interfaces */ +#define DEVID_MINOR_NAME_ALL ((char *)0) +#define DEVID_MINOR_NAME_ALL_CHR ((char *)1) +#define DEVID_MINOR_NAME_ALL_BLK ((char *)2) + +/* + * Define ddi_devmap_cmd types. This should probably be elsewhere. + */ +typedef enum { + DDI_DEVMAP_VALIDATE = 0 /* Check mapping, but do nothing */ +} ddi_devmap_cmd_t; + +/* + * Definitions for node state. + * + * NOTE: DS_ATTACHED and DS_READY should only be used by the devcfg.c state + * model code itself, other code should use i_ddi_devi_attached() to avoid + * logic errors associated with transient DS_READY->DS_ATTACHED->DS_READY + * state changes while the node is attached. + */ +typedef enum { + DS_INVAL = -1, + DS_PROTO = 0, + DS_LINKED, /* in orphan list */ + DS_BOUND, /* in per-driver list */ + DS_INITIALIZED, /* bus address assigned */ + DS_PROBED, /* device known to exist */ + DS_ATTACHED, /* don't use, see NOTE above: driver attached */ + DS_READY /* don't use, see NOTE above: post attach complete */ +} ddi_node_state_t; + +/* + * NDI Event Service + */ +typedef enum {EPL_KERNEL, EPL_INTERRUPT, EPL_HIGHLEVEL} ddi_plevel_t; +typedef struct ddi_event_cookie *ddi_eventcookie_t; +typedef struct ddi_event_callbacks *ddi_callback_id_t; +typedef void (*ddi_event_cb_f)(dev_info_t *, ddi_eventcookie_t, + void *arg, void *impldata); + +#endif /* !_ASM */ + +#ifdef _KERNEL +#ifndef _ASM + +/* + * Device Access Attributes + */ + +typedef struct ddi_device_acc_attr { + ushort_t devacc_attr_version; + uchar_t devacc_attr_endian_flags; + uchar_t devacc_attr_dataorder; + uchar_t devacc_attr_access; /* access error protection */ +} ddi_device_acc_attr_t; + +#define DDI_DEVICE_ATTR_V0 0x0001 +#define DDI_DEVICE_ATTR_V1 0x0002 + +/* + * endian-ness flags + */ +#define DDI_NEVERSWAP_ACC 0x00 +#define DDI_STRUCTURE_LE_ACC 0x01 +#define DDI_STRUCTURE_BE_ACC 0x02 + +/* + * Data ordering values + */ +#define DDI_STRICTORDER_ACC 0x00 +#define DDI_UNORDERED_OK_ACC 0x01 +#define DDI_MERGING_OK_ACC 0x02 +#define DDI_LOADCACHING_OK_ACC 0x03 +#define DDI_STORECACHING_OK_ACC 0x04 + +/* + * Data size + */ +#define DDI_DATA_SZ01_ACC 1 +#define DDI_DATA_SZ02_ACC 2 +#define DDI_DATA_SZ04_ACC 4 +#define DDI_DATA_SZ08_ACC 8 + +/* + * Data Access Handle + */ +#define VERS_ACCHDL 0x0001 + +typedef struct __ddi_acc_handle *ddi_acc_handle_t; + +typedef struct ddi_acc_hdl { + int ah_vers; /* version number */ + void *ah_bus_private; /* bus private pointer */ + void *ah_platform_private; /* platform private pointer */ + dev_info_t *ah_dip; /* requesting device */ + + uint_t ah_rnumber; /* register number */ + caddr_t ah_addr; /* address of mapping */ + + off_t ah_offset; /* offset of mapping */ + off_t ah_len; /* length of mapping */ + uint_t ah_hat_flags; /* hat flags used to map object */ + pfn_t ah_pfn; /* physical page frame number */ + uint_t ah_pnum; /* number of contiguous pages */ + ulong_t ah_xfermodes; /* data transfer modes, etc */ + ddi_device_acc_attr_t ah_acc; /* device access attributes */ +} ddi_acc_hdl_t; + +/* + * Used by DDI_CTLOPS_POKE and DDI_CTLOPS_PEEK for peek/poke and cautious acc + */ +typedef struct { + size_t size; + uintptr_t dev_addr; + uintptr_t host_addr; + ddi_acc_handle_t handle; + size_t repcount; + uint_t flags; +} peekpoke_ctlops_t; + +/* + * Used by the high resolution timeout functions + */ +typedef struct __ddi_periodic *ddi_periodic_t; + +#endif /* !_ASM */ + +/* + * devacc_attr_access error protection types + */ +#define DDI_DEFAULT_ACC 0x01 /* take default action */ +#define DDI_FLAGERR_ACC 0x02 /* protected against access faults */ +#define DDI_CAUTIOUS_ACC 0x03 /* high protection against faults */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DDITYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/debug.h b/illumos-x86_64/usr/include/sys/debug.h new file mode 100644 index 00000000..e6ac8747 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/debug.h @@ -0,0 +1,158 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2012, 2017 by Delphix. All rights reserved. + * Copyright 2013 Saso Kiselkov. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_DEBUG_H +#define _SYS_DEBUG_H + +#if !defined(_STANDALONE) +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ASSERT(ex) causes a panic or debugger entry if expression ex is not + * true. ASSERT() is included only for debugging, and is a no-op in + * production kernels. VERIFY(ex), on the other hand, behaves like + * ASSERT and is evaluated on both debug and non-debug kernels. + */ + +extern void assfail(const char *, const char *, int); +#define VERIFY(EX) ((void)((EX) || (assfail(#EX, __FILE__, __LINE__), 0))) +#if DEBUG +#define ASSERT(EX) ((void)((EX) || (assfail(#EX, __FILE__, __LINE__), 0))) +#else +#define ASSERT(x) ((void)0) +#endif + +/* + * Assertion variants sensitive to the compilation data model + */ +#if defined(_LP64) +#define ASSERT64(x) ASSERT(x) +#define ASSERT32(x) +#else +#define ASSERT64(x) +#define ASSERT32(x) ASSERT(x) +#endif + +/* + * IMPLY and EQUIV are assertions of the form: + * + * if (a) then (b) + * and + * if (a) then (b) *AND* if (b) then (a) + */ +#if DEBUG +#define IMPLY(A, B) \ + ((void)(((!(A)) || (B)) || \ + (assfail("(" #A ") implies (" #B ")", __FILE__, __LINE__), 0))) +#define EQUIV(A, B) \ + ((void)((!!(A) == !!(B)) || \ + (assfail("(" #A ") is equivalent to (" #B ")", \ + __FILE__, __LINE__), 0))) +#else +#define IMPLY(A, B) ((void)0) +#define EQUIV(A, B) ((void)0) +#endif + +/* + * ASSERT3() behaves like ASSERT() except that it is an explicit conditional, + * and prints out the values of the left and right hand expressions as part of + * the panic message to ease debugging. The three variants imply the type + * of their arguments. ASSERT3S() is for signed data types, ASSERT3U() is + * for unsigned, and ASSERT3P() is for pointers. The VERIFY3*() macros + * have the same relationship as above. + */ +extern void assfail3(const char *, uintmax_t, const char *, uintmax_t, + const char *, int); +#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \ + const TYPE __left = (TYPE)(LEFT); \ + const TYPE __right = (TYPE)(RIGHT); \ + if (!(__left OP __right)) \ + assfail3(#LEFT " " #OP " " #RIGHT, \ + (uintmax_t)__left, #OP, (uintmax_t)__right, \ + __FILE__, __LINE__); \ +_NOTE(CONSTCOND) } while (0) + +#define VERIFY3B(x, y, z) VERIFY3_IMPL(x, y, z, boolean_t) +#define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t) +#define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t) +#define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t) +#define VERIFY0(x) VERIFY3_IMPL(x, ==, 0, uintmax_t) + +#if DEBUG +#define ASSERT3B(x, y, z) VERIFY3_IMPL(x, y, z, boolean_t) +#define ASSERT3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t) +#define ASSERT3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t) +#define ASSERT3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t) +#define ASSERT0(x) VERIFY3_IMPL(x, ==, 0, uintmax_t) +#else +#define ASSERT3B(x, y, z) ((void)0) +#define ASSERT3S(x, y, z) ((void)0) +#define ASSERT3U(x, y, z) ((void)0) +#define ASSERT3P(x, y, z) ((void)0) +#define ASSERT0(x) ((void)0) +#endif + +/* + * Compile-time assertion. The condition 'x' must be constant. + */ +#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed") + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern void abort_sequence_enter(char *); +extern void debug_enter(char *); + +#endif /* _KERNEL || _FAKE_KERNEL */ + +#if defined(DEBUG) && !defined(__sun) +/* CSTYLED */ +#define STATIC +#else +/* CSTYLED */ +#define STATIC static +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEBUG_H */ diff --git a/illumos-x86_64/usr/include/sys/debugreg.h b/illumos-x86_64/usr/include/sys/debugreg.h new file mode 100644 index 00000000..8528a293 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/debugreg.h @@ -0,0 +1,110 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ +/* + * Copyright (c) 2018, Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_DEBUGREG_H +#define _SYS_DEBUGREG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Specify masks for accessing the i386 debug registers. + */ + +/* + * The debug registers are found in an array (debugreg) in the u block. + * On the i386, there are 4 registers to specify linear addresses. + * dr4 and dr5 are reserved. + */ +#define DR_FIRSTADDR 0 /* u.u_debugreg[DR_FIRSTADDR] */ +#define DR_LASTADDR 3 /* u.u_debugreg[DR_LASTADDR] */ + +/* + * The debug status is found in dr6 after a debug trap. + */ +#define DR_STATUS 6 /* u.u_debugreg[DR_STATUS] */ +#define DR_TRAP0 0x1 /* Trap from debug register #0 */ +#define DR_TRAP1 0x2 /* Trap from debug register #1 */ +#define DR_TRAP2 0x4 /* Trap from debug register #2 */ +#define DR_TRAP3 0x8 /* Trap from debug register #3 */ +#define DR_ICEALSO 0x2000 /* Flag bit reserved for in-circuit-emulator */ +#define DR_SINGLESTEP 0x4000 /* Trap resulting from the single-step flag */ +#define DR_TASKSWITCH 0x8000 /* Trap resulting from a task-switch */ +#define DR_IN_RTM 0x10000 /* Trap inside an RTM region */ + +/* + * dr7 controls the rest of the debug registers. + * use shifts and masks because arrays of fields tend to get aligned. + * For example, + * dr7 & DR_LOCAL_ENABLE_MASK + * dr7 >> (DR_LOCAL_ENABLE_SHIFT + r# * DR_ENABLE_SIZE) & 0x1 + * dr7 >> (DR_CONTROL_SHIFT + r# * DR_CONTROL_SIZE) & DR_RW_MASK + * Note that the GLOBAL bits below and always turned off by the kernel. + */ +#define DR_CONTROL 7 /* u.u_debugreg[DR_CONTROL] */ +#define DR_LOCAL_ENABLE_MASK 0x55 /* Enable all 4 regs for ldt addrs */ +#define DR_GLOBAL_ENABLE_MASK 0xAA /* Enable all 4 regs for gdt addrs */ +#define DR_CONTROL_RESERVED 0xFC00 /* Bits reserved by Intel */ +#define DR_LOCAL_SLOWDOWN 0x100 /* Slow the pipeline for ldt addrs */ +#define DR_GLOBAL_SLOWDOWN 0x200 /* Slow the pipeline for gdt addrs */ +#define DR_RTM 0x800 /* Restricted Transactional Memory */ +#define DR_GENERAL_DETECT 0x2000 /* General Detect Enable */ + +#define DR_LOCAL_ENABLE_SHIFT 0 /* Additional shift: local enable */ +#define DR_GLOBAL_ENABLE_SHIFT 1 /* Additional shift: global enable */ +#define DR_ENABLE_SIZE 2 /* 2 enable bits per register */ + +#define DR_TRAPS (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3) +#define DR_ENABLE0 0x03 /* Local or Global enable of trap 0 */ +#define DR_ENABLE1 0x0C /* Local or Global enable of trap 1 */ +#define DR_ENABLE2 0x30 /* Local or Global enable of trap 2 */ +#define DR_ENABLE3 0xC0 /* Local or Global enable of trap 3 */ + +#define DR_CONTROL_SHIFT 16 /* Shift to register control bits */ +#define DR_CONTROL_SIZE 4 /* 4 control bits per register */ +#define DR_RW_MASK 0x3 /* Two bits specify r/w access */ +#define DR_RW_EXECUTE 0x0 /* Settings for the read/write mask */ +#define DR_RW_WRITE 0x1 +#define DR_RW_IO_RW 0x2 /* I/O space on Pentium and beyond */ +#define DR_RW_READ 0x3 +#define DR_LEN_MASK 0xC /* Two bits specify data length */ +#define DR_LEN_1 0x0 /* Settings for data length */ +#define DR_LEN_2 0x4 +#define DR_LEN_4 0xC +#define DR_LEN_8 0x8 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEBUGREG_H */ diff --git a/illumos-x86_64/usr/include/sys/des.h b/illumos-x86_64/usr/include/sys/des.h new file mode 100644 index 00000000..20a16c2c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/des.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983-1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_DES_H +#define _SYS_DES_H + +/* + * Generic DES driver interface + * Keep this file hardware independent! + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ +#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ + +enum desdir { ENCRYPT, DECRYPT }; +enum desmode { CBC, ECB }; + +/* + * parameters to ioctl call + */ +struct desparams { + uchar_t des_key[8]; /* key (with low bit parity) */ + enum desdir des_dir; /* direction */ + enum desmode des_mode; /* mode */ + uchar_t des_ivec[8]; /* input vector */ + unsigned des_len; /* number of bytes to crypt */ + union { + uchar_t UDES_data[DES_QUICKLEN]; + uchar_t *UDES_buf; + } UDES; +#define des_data UDES.UDES_data /* direct data here if quick */ +#define des_buf UDES.UDES_buf /* otherwise, pointer to data */ +}; + +/* + * Encrypt an arbitrary sized buffer + */ +#define DESIOCBLOCK _IOWR('d', 6, struct desparams) + +/* + * Encrypt of small amount of data, quickly + */ +#define DESIOCQUICK _IOWR('d', 7, struct desparams) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DES_H */ diff --git a/illumos-x86_64/usr/include/sys/devcache.h b/illumos-x86_64/usr/include/sys/devcache.h new file mode 100644 index 00000000..04b5207a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devcache.h @@ -0,0 +1,79 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DEVCACHE_H +#define _SYS_DEVCACHE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef _KERNEL + +/* + * Handle reference to a registered file + */ +typedef struct __nvf_handle *nvf_handle_t; + +/* + * Registration descriptor for a cache file within /etc/devices + * + * path - cache file path path + * unpack_list - when reading, called to unpack nvlist + * pack_list - when writing, called to pack nvlist + * list_free - free data contained within list + * write_complete - called when write is completed + */ +typedef struct nvf_ops { + char *nvfr_cache_path; + int (*nvfr_unpack_nvlist)(nvf_handle_t, nvlist_t *, char *); + int (*nvfr_pack_list)(nvf_handle_t, nvlist_t **); + void (*nvfr_list_free)(nvf_handle_t); + void (*nvfr_write_complete)(nvf_handle_t); +} nvf_ops_t; + +/* + * Client interfaces + */ + +nvf_handle_t nvf_register_file(nvf_ops_t *); +int nvf_read_file(nvf_handle_t); +void nvf_wake_daemon(void); +void nvf_error(const char *, ...); +char *nvf_cache_name(nvf_handle_t); +krwlock_t *nvf_lock(nvf_handle_t); +list_t *nvf_list(nvf_handle_t); +void nvf_mark_dirty(nvf_handle_t); +int nvf_is_dirty(nvf_handle_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVCACHE_H */ diff --git a/illumos-x86_64/usr/include/sys/devcache_impl.h b/illumos-x86_64/usr/include/sys/devcache_impl.h new file mode 100644 index 00000000..0ad80104 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devcache_impl.h @@ -0,0 +1,164 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DEVCACHE_IMPL_H +#define _SYS_DEVCACHE_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * /etc/devices cache files format + * Leave some padding for easy extension in the future + */ + +#define NVPF_HDR_MAGIC 0xdeb1dcac +#define NVPF_HDR_VERSION 1 +#define NVPF_HDR_SIZE 128 + +typedef struct nvpacked_file_hdr { + union { + struct nvfp_hdr { + uint32_t magic; + int32_t version; + int64_t size; + uint16_t hdr_chksum; + uint16_t chksum; + } nvpf; + uchar_t nvpf_pad[NVPF_HDR_SIZE]; + } un; +} nvpf_hdr_t; + +#define nvpf_magic un.nvpf.magic +#define nvpf_version un.nvpf.version +#define nvpf_size un.nvpf.size +#define nvpf_hdr_chksum un.nvpf.hdr_chksum +#define nvpf_chksum un.nvpf.chksum + + +#ifdef _KERNEL + +/* + * Descriptor used for kernel-level file i/o + */ +typedef struct kfile { + struct vnode *kf_vp; + int kf_vnflags; + char *kf_fname; + offset_t kf_fpos; + int kf_state; +} kfile_t; + +/* + * File descriptor for files in the nvlist format + */ +typedef struct nvfiledesc nvfd_t; + +/* + * Descriptor for a file managed as a backing store for some + * kernel-generated device state such as device devids, + * vhci-to-phci mapping, etc. + * Each client can manage the data in any form convenient. + * providing functions to unpack (read) and pack (write) + * the data as an nvlist. + * + * Clients should not reference this structure directly + * but through the handle returned when registering. + */ +struct nvfiledesc { + nvf_ops_t *nvf_ops; /* client ops vectors */ + int nvf_flags; /* flags */ + list_t nvf_data_list; /* data list */ + krwlock_t nvf_lock; /* lock for data list */ + list_node_t nvf_link; /* link to next file desc */ +}; + +/* + * nvf_flags + */ +#define NVF_F_DIRTY 0x01 /* needs to be flushed */ +#define NVF_F_FLUSHING 0x02 /* in process of being flushed */ +#define NVF_F_ERROR 0x04 /* most recent flush failed */ +#define NVF_F_READONLY 0x10 /* file is read-only */ +#define NVF_F_CREATE_MSG 0x20 /* file not found on boot, emit msg */ +#define NVF_F_REBUILD_MSG 0x40 /* file was found corrupted, emit msg */ + +#define NVF_IS_DIRTY(nvfd) ((nvfd)->nvf_flags & NVF_F_DIRTY) +#define NVF_MARK_DIRTY(nvfd) ((nvfd)->nvf_flags |= NVF_F_DIRTY) +#define NVF_CLEAR_DIRTY(nvfd) ((nvfd)->nvf_flags &= ~NVF_F_DIRTY) + +#define NVF_IS_READONLY(nvfd) ((nvfd)->nvf_flags & NVF_F_READONLY) +#define NVF_MARK_READONLY(nvfd) ((nvfd)->nvf_flags |= NVF_F_READONLY) + +/* shorthand to client ops */ +#define nvf_cache_path nvf_ops->nvfr_cache_path +#define nvf_unpack_nvlist nvf_ops->nvfr_unpack_nvlist +#define nvf_pack_list nvf_ops->nvfr_pack_list +#define nvf_list_free nvf_ops->nvfr_list_free +#define nvf_write_complete nvf_ops->nvfr_write_complete + + +/* + * More thorough error reporting available both debug & + * non-debug kernels, but turned off by default. + */ +extern int kfio_report_error; /* kernel file i/o operations */ + +/* + * Suffix of temporary file for updates + */ +#define MAX_SUFFIX_LEN 4 +#define NEW_FILENAME_SUFFIX "new" + + +#ifdef DEBUG + +#define NVPDAEMON_DEBUG(args) { if (nvpdaemon_debug) cmn_err args; } +#define KFDEBUG(args) { if (kfio_debug) cmn_err args; } +#define KFDEBUG1(args) { if (kfio_debug > 1) cmn_err args; } +#define KFDEBUG2(args) { if (kfio_debug > 2) cmn_err args; } +#define KFDUMP(args) { if (kfio_debug > 2) args; } + +#else + +#define NVPDAEMON_DEBUG(args) +#define KFDEBUG(args) +#define KFDEBUG1(args) +#define KFDEBUG2(args) +#define KFDUMP(args) + +#endif /* DEBUG */ + + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVCACHE_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/devctl.h b/illumos-x86_64/usr/include/sys/devctl.h new file mode 100644 index 00000000..5dce50c7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devctl.h @@ -0,0 +1,269 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DEVCTL_H +#define _SYS_DEVCTL_H + +/* + * Device control interfaces + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * structure used to pass IOCTL data between the libdevice interfaces + * and nexus driver devctl IOCTL interface. + * + * Applications and nexus drivers may not access the contents of this + * structure directly. Instead, drivers must use the ndi_dc_*(9n) + * interfaces, while applications must use the interfaces provided by + * libdevice.so.1. + */ +struct devctl_iocdata { + uint_t cmd; /* ioctl cmd */ + uint_t flags; /* command-specific flags */ + void *cpyout_buf; /* copyout vector */ + nvlist_t *nvl_user; /* application defined attributes */ + size_t nvl_usersz; + char *c_nodename; /* child device nodename */ + char *c_unitaddr; /* child device unit address */ +}; + +#if defined(_SYSCALL32) +/* + * Structure to pass/return data from 32-bit program's. + */ +struct devctl_iocdata32 { + uint32_t cmd; + uint32_t flags; + caddr32_t cpyout_buf; + caddr32_t nvl_user; + uint32_t nvl_usersz; + caddr32_t c_nodename; + caddr32_t c_unitaddr; +}; +#endif + +/* + * Limit size of packed application defined attributes (nvl_user) to prevent + * user application from requesting excessive kernel memory allocation. + */ +#define DEVCTL_MAX_NVL_USERSZ 0x10000 + +/* + * State of receptacle for an Attachment Point. + */ +typedef enum { + AP_RSTATE_EMPTY, + AP_RSTATE_DISCONNECTED, + AP_RSTATE_CONNECTED +} ap_rstate_t; + +/* + * State of occupant for an Attachment Point. + */ +typedef enum { + AP_OSTATE_UNCONFIGURED, + AP_OSTATE_CONFIGURED +} ap_ostate_t; + +/* + * condition of an Attachment Point. + */ +typedef enum { + AP_COND_UNKNOWN, + AP_COND_OK, + AP_COND_FAILING, + AP_COND_FAILED, + AP_COND_UNUSABLE +} ap_condition_t; + +/* + * structure used to return the state of Attachment Point (AP) thru + * devctl_ap_getstate() interface. + */ + +typedef struct devctl_ap_state { + ap_rstate_t ap_rstate; /* receptacle state */ + ap_ostate_t ap_ostate; /* occupant state */ + ap_condition_t ap_condition; /* condition of AP */ + time_t ap_last_change; + uint32_t ap_error_code; /* error code */ + uint8_t ap_in_transition; +} devctl_ap_state_t; + +#if defined(_SYSCALL32) +/* + * Structure to pass/return data from 32-bit program's. + */ +typedef struct devctl_ap_state32 { + ap_rstate_t ap_rstate; /* receptacle state */ + ap_ostate_t ap_ostate; /* occupant state */ + ap_condition_t ap_condition; /* condition of AP */ + time32_t ap_last_change; + uint32_t ap_error_code; /* error code */ + uint8_t ap_in_transition; +} devctl_ap_state32_t; +#endif + +#define DEVCTL_IOC (0xDC << 16) +#define DEVCTL_IOC_MAX (DEVCTL_IOC | 0xFFFF) +#define DEVCTL_BUS_QUIESCE (DEVCTL_IOC | 1) +#define DEVCTL_BUS_UNQUIESCE (DEVCTL_IOC | 2) +#define DEVCTL_BUS_RESETALL (DEVCTL_IOC | 3) +#define DEVCTL_BUS_RESET (DEVCTL_IOC | 4) +#define DEVCTL_BUS_GETSTATE (DEVCTL_IOC | 5) +#define DEVCTL_DEVICE_ONLINE (DEVCTL_IOC | 6) +#define DEVCTL_DEVICE_OFFLINE (DEVCTL_IOC | 7) +#define DEVCTL_DEVICE_GETSTATE (DEVCTL_IOC | 9) +#define DEVCTL_DEVICE_RESET (DEVCTL_IOC | 10) +#define DEVCTL_BUS_CONFIGURE (DEVCTL_IOC | 11) +#define DEVCTL_BUS_UNCONFIGURE (DEVCTL_IOC | 12) +#define DEVCTL_DEVICE_REMOVE (DEVCTL_IOC | 13) +#define DEVCTL_AP_CONNECT (DEVCTL_IOC | 14) +#define DEVCTL_AP_DISCONNECT (DEVCTL_IOC | 15) +#define DEVCTL_AP_INSERT (DEVCTL_IOC | 16) +#define DEVCTL_AP_REMOVE (DEVCTL_IOC | 17) +#define DEVCTL_AP_CONFIGURE (DEVCTL_IOC | 18) +#define DEVCTL_AP_UNCONFIGURE (DEVCTL_IOC | 19) +#define DEVCTL_AP_GETSTATE (DEVCTL_IOC | 20) +#define DEVCTL_AP_CONTROL (DEVCTL_IOC | 21) +#define DEVCTL_BUS_DEV_CREATE (DEVCTL_IOC | 22) +#define DEVCTL_PM_BUSY_COMP (DEVCTL_IOC | 23) +#define DEVCTL_PM_IDLE_COMP (DEVCTL_IOC | 24) +#define DEVCTL_PM_RAISE_PWR (DEVCTL_IOC | 25) +#define DEVCTL_PM_LOWER_PWR (DEVCTL_IOC | 26) +#define DEVCTL_PM_CHANGE_PWR_LOW (DEVCTL_IOC | 27) +#define DEVCTL_PM_CHANGE_PWR_HIGH (DEVCTL_IOC | 28) +#define DEVCTL_PM_POWER (DEVCTL_IOC | 29) +#define DEVCTL_PM_PROM_PRINTF (DEVCTL_IOC | 30) +#define DEVCTL_PM_FAIL_SUSPEND (DEVCTL_IOC | 31) +#define DEVCTL_PM_PWR_HAS_CHANGED_ON_RESUME (DEVCTL_IOC | 32) +#define DEVCTL_PM_PUP_WITH_PWR_HAS_CHANGED (DEVCTL_IOC | 34) +#define DEVCTL_PM_BUSY_COMP_TEST (DEVCTL_IOC | 35) +#define DEVCTL_PM_BUS_STRICT_TEST (DEVCTL_IOC | 36) +#define DEVCTL_PM_NO_LOWER_POWER (DEVCTL_IOC | 37) +#define DEVCTL_PM_BUS_NO_INVOL (DEVCTL_IOC | 38) +#define DEVCTL_SET_LED (DEVCTL_IOC | 39) +#define DEVCTL_GET_LED (DEVCTL_IOC | 40) +#define DEVCTL_NUM_LEDS (DEVCTL_IOC | 41) + + +/* + * is (c) in the range of possible devctl IOCTL commands? + */ +#define IS_DEVCTL(c) (((c) >= DEVCTL_IOC) && ((c) <= DEVCTL_IOC_MAX)) + +/* + * Device and Bus State definitions + * + * Device state is returned as a set of bit-flags that indicate the current + * operational state of a device node. + * + * Device nodes for leaf devices only contain state information for the + * device itself. Nexus device nodes contain both Bus and Device state + * information. + * + * DEVICE_ONLINE - Device is available for use by the system. Mutually + * exclusive with DEVICE_OFFLINE. + * + * DEVICE_OFFLINE - Device is unavailable for use by the system. + * Mutually exclusive with DEVICE_ONLINE and DEVICE_BUSY. + * + * DEVICE_DOWN - Device has been placed in the "DOWN" state by + * its controlling driver. + * + * DEVICE_BUSY - Device has open instances or nexus has INITALIZED + * children (nexi). A device in this state is by + * definition Online. + * + * Bus state is returned as a set of bit-flags which indicates the + * operational state of a bus associated with the nexus dev_info node. + * + * BUS_ACTIVE - The bus associated with the device node is Active. + * I/O requests from child devices attached to the + * are initiated (or queued for initiation) as they + * are received. + * + * BUS_QUIESCED - The bus associated with the device node has been + * Quieced. I/O requests from child devices attached + * to the bus are held pending until the bus nexus is + * Unquiesced. + * + * BUS_SHUTDOWN - The bus associated with the device node has been + * shutdown by the nexus driver. I/O requests from + * child devices are returned with an error indicating + * the requested operation failed. + */ +#define DEVICE_ONLINE 0x1 +#define DEVICE_BUSY 0x2 +#define DEVICE_OFFLINE 0x4 +#define DEVICE_DOWN 0x8 + +#define BUS_ACTIVE 0x10 +#define BUS_QUIESCED 0x20 +#define BUS_SHUTDOWN 0x40 + +#define DEVICE_STATES_ASCII "Dev_Online", "Dev_Busy", "Dev_Offline", \ + "Dev_Down", "Bus_Active", "Bus_Quiesced", "Bus_Shutdown" + +#define DC_DEVI_NODENAME "ndi_dc.devi_nodename" + +#define DEVCTL_CONSTRUCT 0x1 +#define DEVCTL_OFFLINE 0x2 + +/* + * Drive status LED control + */ +struct dc_led_ctl { + uint32_t led_number : 16; /* LED/device number */ + uint32_t led_ctl_active : 1; /* Control active */ + uint32_t led_type : 9; /* LED type */ + uint32_t led_state : 6; /* LED ON/OFF/Blink state */ +}; + +/* Control active field */ +#define DCL_CNTRL_OFF 0 /* Control inactive */ +#define DCL_CNTRL_ON 1 /* Control active */ + +/* LED type field */ +#define DCL_TYPE_DEVICE_FAIL 1 /* Device FAIL LED type */ +#define DCL_TYPE_DEVICE_OK2RM 2 /* Device OK2RM LED type */ + +/* LED state field */ +#define DCL_STATE_OFF 0 /* LED state OFF */ +#define DCL_STATE_ON 1 /* LED state ON */ +#define DCL_STATE_SLOW_BLNK 2 /* LED slow blink */ +#define DCL_STATE_FAST_BLNK 3 /* LED fast blink */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/devfm.h b/illumos-x86_64/usr/include/sys/devfm.h new file mode 100644 index 00000000..11a85519 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devfm.h @@ -0,0 +1,177 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_DEVFM_H +#define _SYS_DEVFM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define FM_IOC_MAXBUFSZ 32768 /* 32 KiB */ +#define FM_IOC_OUT_BUFSZ 32768 /* 32 KiB */ +#define FM_IOC_OUT_MAXBUFSZ 1048576 /* 1 MiB */ +#define FM_DRV_VERSION 1 + +#define FM_VERSIONS_VERSION "fm-versions-version" +#define FM_PAGE_OP_VERSION "page-operation-version" +#define FM_CPU_OP_VERSION "cpu-operation-version" +#define FM_CPU_INFO_VERSION "cpu-info-version" +#define FM_TOPO_LEGACY_VERSION "topo-legacy-version" +#define FM_CACHE_INFO_VERSION "cache-info-version" + +/* + * FMA driver ioctl interfaces + */ +#define FM_IOC (0xFA << 16) +#define FM_IOC_VERSIONS (FM_IOC | 1) +#define FM_IOC_PAGE_RETIRE (FM_IOC | 2) +#define FM_IOC_PAGE_STATUS (FM_IOC | 3) +#define FM_IOC_PAGE_UNRETIRE (FM_IOC | 4) + +#if defined(__x86) +#define FM_IOC_PHYSCPU_INFO (FM_IOC | 5) +#define FM_IOC_CPU_RETIRE (FM_IOC | 6) +#define FM_IOC_CPU_STATUS (FM_IOC | 7) +#define FM_IOC_CPU_UNRETIRE (FM_IOC | 8) +#define FM_IOC_GENTOPO_LEGACY (FM_IOC | 9) +#endif /* __x86 */ + +/* + * Information about caches. Each CPU that is in the physical CPU information + * will be in here in the same ID order allowing one to map them directly. + */ +#define FM_IOC_CACHE_INFO (FM_IOC | 10) + +/* + * Types + */ +typedef struct fm_ioc_data { + uint32_t fid_version; /* interface version */ + size_t fid_insz; /* size of packed input nvlist */ + caddr_t fid_inbuf; /* buf containing packed input nvl */ + size_t fid_outsz; /* size of packed output nvlist */ + caddr_t fid_outbuf; /* buf containing packed output nvl */ +} fm_ioc_data_t; + +#ifdef _KERNEL +typedef struct fm_ioc_data32 { + uint32_t fid_version; /* interface version */ + size32_t fid_insz; /* size of packed input nvlist */ + caddr32_t fid_inbuf; /* buf containing packed input nvl */ + size32_t fid_outsz; /* size of packed output nvlist */ + caddr32_t fid_outbuf; /* buf containing packed output nvl */ +} fm_ioc_data32_t; +#endif /* _KERNEL */ + +/* + * Constants + */ +#define FM_PAGE_RETIRE_FMRI "fmri" +#define FM_PHYSCPU_INFO_CPUS "cpus" +#define FM_CPU_RETIRE_CHIP_ID "chip_id" +#define FM_PHYSCPU_INFO_NPROCNODES "procnodes_per_pkg" +#define FM_PHYSCPU_INFO_PROCNODE_ID "procnodeid" +#define FM_CPU_RETIRE_CORE_ID "core_id" +#define FM_CPU_RETIRE_STRAND_ID "strand_id" +#define FM_CPU_RETIRE_OLDSTATUS "oldstatus" +#define FM_GENTOPO_LEGACY "gentopolegacy" +#define FM_CACHE_INFO_NCPUS "ncpus" + +/* + * Properties set by FM_PHYSCPU_INFO + */ +#define FM_PHYSCPU_INFO_VENDOR_ID "vendor_id" +#define FM_PHYSCPU_INFO_FAMILY "family" +#define FM_PHYSCPU_INFO_MODEL "model" +#define FM_PHYSCPU_INFO_STEPPING "stepping" + +/* + * When Multi-Chip-Module(MCM) support is added + * chip_id should map to the processor package + * and not the die in the processor package. + * This is for FMA; kernel's perception of + * chip_id could differ for MCM. + */ +#define FM_PHYSCPU_INFO_CHIP_ID "chip_id" + +#define FM_PHYSCPU_INFO_CORE_ID "core_id" +#define FM_PHYSCPU_INFO_STRAND_ID "strand_id" +#define FM_PHYSCPU_INFO_STRAND_APICID "strand_initial_apicid" +#define FM_PHYSCPU_INFO_SMBIOS_ID "smbios_id" +#define FM_PHYSCPU_INFO_CHIP_ROOTS "chip_roots" +#define FM_PHYSCPU_INFO_CHIP_REV "chip_rev" +#define FM_PHYSCPU_INFO_SOCKET_TYPE "socket_type" +#define FM_PHYSCPU_INFO_CPU_ID "cpuid" +#define FM_PHYSCPU_INFO_CHIP_IDENTSTR "chip_identstr" + +/* + * Information exposed by the cache information structure. This is currently + * organized by the given caches available to a CPU. There is a given nvlist_t + * array for each cache level. The majority of these entries are meant to be + * generic across all platforms and derived from the underlying architecture's + * metadata (CPUID, CLIDR_EL1, etc.). + * + * The FM_CACHE_INFO_ID value is manufactured by the kernel. CPU architectures + * generally present cache information as specific to a logical CPU. This allows + * systems to determine what level caches are shared between different CPUs by + * comparing these entries across CPUs. Items prefixed with a given architecture + * are specific to it and will not show up on other platforms. These exist so + * topology modules can have more information than just the cache-id. While it's + * helpful, it doesn't tell us what level of the CPU (or whether it's internal + * or external) it exists at. This is going to be architecture and potentially + * platform specific given that ARMv8-A/ARMv9-A doesn't define a way to get this + * for example. + * + * It is expected that callers will always fill out the sets and ways + * appropriately. If a cache is fully-associative, we expects the number of sets + * to be populated and set to 1 that way consumers can attempt to have a uniform + * experience here. + */ +#define FM_CACHE_INFO_LEVEL "cache-level" /* uint32_t */ +#define FM_CACHE_INFO_TYPE "cache-type" /* uint32_t */ +typedef enum { + FM_CACHE_INFO_T_DATA = 1 << 0, + FM_CACHE_INFO_T_INSTR = 1 << 1, + FM_CACHE_INFO_T_UNIFIED = 1 << 2 +} fm_cache_info_type_t; +#define FM_CACHE_INFO_NSETS "cache-sets" /* uint64_t */ +#define FM_CACHE_INFO_NWAYS "cache-ways" /* uint32_t */ +#define FM_CACHE_INFO_LINE_SIZE "line-size" /* uint32_t */ +#define FM_CACHE_INFO_TOTAL_SIZE "total-size" /* uint64_t */ +#define FM_CACHE_INFO_FULLY_ASSOC "fully-associative" /* boolean (key) */ +#define FM_CACHE_INFO_ID "cache-id" /* uint64_t */ +#define FM_CACHE_INFO_X86_APIC_SHIFT "x86-apic-shift" /* uint32_t */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVFM_H */ diff --git a/illumos-x86_64/usr/include/sys/devid_cache.h b/illumos-x86_64/usr/include/sys/devid_cache.h new file mode 100644 index 00000000..3ae23284 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devid_cache.h @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DEVID_CACHE_H +#define _SYS_DEVID_CACHE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * The top-level nvpair identifiers in the + * /etc/devices/devid_cache nvlist format + */ +#define DP_DEVID_ID "devid" + +#ifdef _KERNEL + +/* devid-specific list element */ +typedef struct nvp_devid { + int nvp_flags; + char *nvp_devpath; + dev_info_t *nvp_dip; + ddi_devid_t nvp_devid; + list_node_t nvp_link; /* link to next element */ +} nvp_devid_t; + + +/* + * nvp_flags - devid + */ +#define NVP_DEVID_REGISTERED 0x01 /* devid registered on this boot */ +#define NVP_DEVID_DIP 0x02 /* devinfo valid for this devid */ + +/* + * tunables - see devid_cache.c for more details + */ +extern int devid_discovery_boot; +extern int devid_discovery_postboot; +extern int devid_discovery_postboot_always; +extern int devid_discovery_secs; + +extern int devid_cache_read_disable; +extern int devid_cache_write_disable; + +/* + * More thorough error reporting available both debug & + * non-debug kernels, but turned off by default. + */ +extern int devid_report_error; /* devid cache operations */ + + +/* + * function prototypes + */ +static int devid_cache_pack_list(nvf_handle_t, nvlist_t **); +static int devid_cache_unpack_nvlist(nvf_handle_t, nvlist_t *, char *); +static void devid_list_free(nvf_handle_t); + + +#ifdef DEBUG + +#define DEVID_DEBUG(args) { if (devid_debug) cmn_err args; } +#define DEVID_DEBUG1(args) { if (devid_debug > 1) cmn_err args; } +#define DEVID_DEBUG2(args) { if (devid_debug > 2) cmn_err args; } +#define DEVID_DUMP(args) { if (devid_debug > 2) args; } +#define DEVID_LOG_REG(args) { if (devid_log_registers) devid_log args; } +#define DEVID_LOG_FIND(args) { if (devid_log_finds) devid_log args; } +#define DEVID_LOG_LOOKUP(args) { if (devid_log_lookups) cmn_err args; } +#define DEVID_LOG_MATCH(args) { if (devid_log_matches) devid_log args; } +#define DEVID_LOG_PATHS(args) { if (devid_log_paths) cmn_err args; } +#define DEVID_LOG_ERR(args) { if (devid_log_failures) devid_log args; } +#define DEVID_LOG_DISC(args) { if (devid_log_discovery) cmn_err args; } +#define DEVID_LOG_HOLD(args) { if (devid_log_hold) cmn_err args; } +#define DEVID_LOG_UNREG(args) { if (devid_log_unregisters) cmn_err args; } +#define DEVID_LOG_REMOVE(args) { if (devid_log_removes) cmn_err args; } +#define DEVID_LOG_STALE(args) { if (devid_log_stale) devid_log args; } +#define DEVID_LOG_DETACH(args) { if (devid_log_detaches) cmn_err args; } + + +#define NVP_DEVID_DEBUG_PATH(arg) { \ + if (nvp_devid_debug) \ + cmn_err(CE_CONT, "%s\n", arg); \ + } + +#define NVP_DEVID_DEBUG_DEVID(arg) { \ + if (nvp_devid_debug) { \ + char *ds = ddi_devid_str_encode(arg, NULL); \ + cmn_err(CE_CONT, "devid: %s\n", ds); \ + ddi_devid_str_free(ds); \ + } \ + } + +static void devid_log(char *, ddi_devid_t, char *); + +#else + +#define DEVID_DEBUG(args) +#define DEVID_DEBUG1(args) +#define DEVID_DEBUG2(args) +#define DEVID_DUMP(args) +#define DEVID_LOG_REG(args) +#define DEVID_LOG_FIND(args) +#define DEVID_LOG_LOOKUP(args) +#define DEVID_LOG_MATCH(args) +#define DEVID_LOG_PATHS(args) +#define DEVID_LOG_ERR(args) +#define DEVID_LOG_DISC(args) +#define DEVID_LOG_HOLD(args) +#define DEVID_LOG_UNREG(args) +#define DEVID_LOG_REMOVE(args) +#define DEVID_LOG_STALE(args) +#define DEVID_LOG_DETACH(args) +#define NVP_DEVID_DEBUG_PATH(arg) +#define NVP_DEVID_DEBUG_DEVID(arg) + +#endif /* DEBUG */ + +#define DEVIDERR(args) { if (devid_report_error) cmn_err args; } + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVID_CACHE_H */ diff --git a/illumos-x86_64/usr/include/sys/devinfo_impl.h b/illumos-x86_64/usr/include/sys/devinfo_impl.h new file mode 100644 index 00000000..22ef3c3f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devinfo_impl.h @@ -0,0 +1,438 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_DEVINFO_IMPL_H +#define _SYS_DEVINFO_IMPL_H + +#include + +/* + * This file is separate from libdevinfo.h because the devinfo driver + * needs to know about the stuff. Library consumer should not care + * about stuff defined here. + * + * The only exception is di_priv_data (consolidation private) and + * DINFO* ioctls. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ioctl commands for devinfo driver */ + +#define DIIOC (0xdf<<8) +#define DIIOC_MASK (0xffff00ff) + +/* + * Any combination of the following ORed together will take a snapshot + * of the device configuration data. + */ +#define DINFOSUBTREE (DIIOC | 0x01) /* include subtree */ +#define DINFOMINOR (DIIOC | 0x02) /* include minor data */ +#define DINFOPROP (DIIOC | 0x04) /* include properties */ +#define DINFOPATH (DIIOC | 0x08) /* include i/o pathing information */ + +/* private bits */ +#define DINFOPRIVDATA (DIIOC | 0x10) /* include private data */ +#define DINFOFORCE (DIIOC | 0x20) /* force load all drivers */ +#define DINFOCACHE (DIIOC | 0x100000) /* use cached data */ +#define DINFOCLEANUP (DIIOC | 0x200000) /* cleanup /etc/devices files */ + +/* new public flag for the layered drivers framework */ +#define DINFOLYR (DIIOC | 0x40) /* get device layering information */ + +/* new public flag for the hotplug framework */ +#define DINFOHP (DIIOC | 0x400000) /* include hotplug information */ + +/* + * Straight ioctl commands, not bitwise operation + */ +#define DINFOUSRLD (DIIOC | 0x80) /* copy snapshot to usrland */ +#define DINFOLODRV (DIIOC | 0x81) /* force load a driver */ +#define DINFOIDENT (DIIOC | 0x82) /* identify the driver */ + +/* + * ioctl for taking a snapshot a single node and all nodes + */ +#define DINFOCPYONE DIIOC +#define DINFOCPYALL (DINFOSUBTREE | DINFOPROP | DINFOMINOR) + +#define DI_MAGIC 0xdfdf /* magic number returned by DINFOIDENT */ + +/* driver ops encoding */ + +#define DI_BUS_OPS 0x1 +#define DI_CB_OPS 0x2 +#define DI_STREAM_OPS 0x4 + +/* property list enumeration */ + +#define DI_PROP_DRV_LIST 0 +#define DI_PROP_SYS_LIST 1 +#define DI_PROP_GLB_LIST 2 +#define DI_PROP_HW_LIST 3 + +/* misc parameters */ + +#define MAX_TREE_DEPTH 64 +#define MAX_PTR_IN_PRV 5 +#define DI_SNAPSHOT_VERSION_0 0 /* reserved */ +#define DI_SNAPSHOT_VERSION_1 1 /* reserved */ +#define DI_SNAPSHOT_VERSION_2 2 /* reserved */ +#define DI_SNAPSHOT_VERSION DI_SNAPSHOT_VERSION_2 /* current version */ +#define DI_PRIVDATA_VERSION_0 10 /* Start from 10 so caller must set */ +#define DI_BIG_ENDIAN 0 /* reserved */ +#define DI_LITTLE_ENDIAN 1 /* reserved */ + +#define DI_CACHE_MAGIC 0xdfcac6ed /* magic # for cache */ +#define DI_CACHE_PERMS (0444) +#define DI_CACHE_SNAPSHOT_FLAGS \ + (DINFOFORCE|DINFOSUBTREE|DINFOMINOR|DINFOPROP|DINFOPATH) + +#define DI_NODE(addr) ((struct di_node *)((void *)(addr))) +#define DI_MINOR(addr) ((struct di_minor *)((void *)(addr))) +#define DI_PROP(addr) ((struct di_prop *)((void *)(addr))) +#define DI_PATH(addr) ((struct di_path *)((void *)(addr))) +#define DI_PATHPROP(addr) ((struct di_path_prop *)((void *)(addr))) +#define DI_ALL(addr) ((struct di_all *)((void *)(addr))) +#define DI_DEVNM(addr) ((struct di_devnm *)((void *)(addr))) +#define DI_LINK(addr) ((struct di_link *)((void *)(addr))) +#define DI_LNODE(addr) ((struct di_lnode *)((void *)(addr))) +#define DI_PRIV_FORMAT(addr) ((struct di_priv_format *)((void *)(addr))) +#define DI_HP(addr) ((struct di_hp *)((void *)(addr))) +#define DI_ALIAS(addr) ((struct di_alias *)((void *)(addr))) + +/* + * multipath component definitions: Follows the registered component of + * the mpxio system. + */ +#define MULTIPATH_COMPONENT_NONE 0 +#define MULTIPATH_COMPONENT_VHCI 0x1 +#define MULTIPATH_COMPONENT_PHCI 0x2 +#define MULTIPATH_COMPONENT_CLIENT 0x4 + +typedef int32_t di_off_t; + +/* + * devinfo driver snapshot data structure + */ +struct di_all { + int version; /* snapshot version, reserved */ + int cache_magic; /* magic number for cached snapshot */ + int pd_version; /* private data format version */ + int endianness; /* reserved for future use */ + int generation; /* reserved for future use */ + uint32_t cache_checksum; /* snapshot checksum */ + uint64_t snapshot_time; /* snapshot timestamp */ + di_off_t top_devinfo; /* actual top devinfo in snapshot */ + di_off_t top_vhci_devinfo; + di_off_t devnames; + di_off_t ppdata_format; /* parent priv data format array */ + di_off_t dpdata_format; /* driver priv data format array */ + di_off_t aliases; /* offset to alias tree */ + int n_ppdata; /* size of ppdata_format array */ + int n_dpdata; /* size of pddata_format array */ + int devcnt; /* size of devnames array */ + uint_t command; /* same as in di_init() */ + uint_t map_size; /* size of the snapshot */ + char req_path[MAXPATHLEN]; /* path to requested root */ + char root_path[1]; /* path to actual snapshot root */ +}; + +struct di_devnm { + di_off_t name; + di_off_t global_prop; + di_off_t head; /* head of per instance list */ + int flags; /* driver attachment info */ + int instance; /* next instance to assign */ + uint_t ops; /* bit-encoded driver ops */ +}; + + +struct di_lnode; + +struct di_link { + di_off_t self; + int count; + int spec_type; /* block or char access type */ + di_off_t src_lnode; /* src di_lnode */ + di_off_t tgt_lnode; /* tgt di_lnode */ + di_off_t src_link_next; /* next src di_link /w same di_lnode */ + di_off_t tgt_link_next; /* next tgt di_link /w same di_lnode */ + di_off_t src_node_next; /* next src di_link /w same di_node */ + di_off_t tgt_node_next; /* next tgt di_link /w same di_node */ + uint64_t user_private_data; +}; + +struct di_lnode { + di_off_t self; + + /* + * public information describing a link endpoint + */ + major_t dev_major; /* dev_t can be 64-bit */ + minor_t dev_minor; /* dev_t can be 64-bit */ + di_off_t node; /* offset of di_node */ + + /* + * di_link ptr to links comming into this node + * (this lnode is the target of these di_links) + */ + di_off_t link_in; + + /* + * di_link ptr to links going out of this node + * (this lnode is the source of these di_links) + */ + di_off_t link_out; + + /* + * di_lnode pointer to the next lnode associated with the + * same di_node + */ + di_off_t node_next; + + uint64_t user_private_data; +}; + +struct di_node { /* useful info to export for each tree node */ + /* + * offset to di_node structures + */ + di_off_t self; /* make it self addressable */ + di_off_t parent; /* offset of parent node */ + di_off_t child; /* offset of child node */ + di_off_t sibling; /* offset of sibling */ + di_off_t next; /* next node on per-instance list */ + /* + * offset to char strings of current node + */ + di_off_t node_name; /* offset of device node name */ + di_off_t address; /* offset of address part of name */ + di_off_t bind_name; /* offset of binding name */ + di_off_t compat_names; /* offset of compatible names */ + /* + * offset to property lists, private data, etc. + */ + di_off_t minor_data; + di_off_t drv_prop; + di_off_t sys_prop; + di_off_t glob_prop; + di_off_t hw_prop; + di_off_t parent_data; + di_off_t driver_data; + di_off_t multipath_client; + di_off_t multipath_phci; + di_off_t devid; /* registered device id */ + di_off_t pm_info; /* RESERVED FOR FUTURE USE */ + /* + * misc values + */ + int compat_length; /* size of compatible name list */ + int drv_major; /* for indexing into devnames array */ + /* + * value attributes of current node + */ + int instance; /* instance number */ + int nodeid; /* node id */ + ddi_node_class_t node_class; /* node class */ + int attributes; /* node attributes */ + uint_t state; /* hotplugging device state */ + ddi_node_state_t node_state; /* devinfo state */ + + di_off_t lnodes; /* lnodes associated with this di_node */ + di_off_t tgt_links; + di_off_t src_links; + + uint32_t di_pad1; /* 4 byte padding for 32bit x86 app. */ + uint64_t user_private_data; + /* + * offset to link vhci/phci nodes. + */ + di_off_t next_vhci; + di_off_t top_phci; + di_off_t next_phci; + uint32_t multipath_component; /* stores MDI_COMPONENT_* value. */ + /* + * devi_flags field + */ + uint32_t flags; + uint32_t di_pad2; /* 4 byte padding for 32bit x86 app. */ + /* + * offset to hotplug nodes. + */ + di_off_t hp_data; +}; + +/* + * chain of ddi_minor_data structure + */ +struct di_minor { + di_off_t self; /* make it self addressable */ + di_off_t next; /* next one in the chain */ + di_off_t name; /* name of node */ + di_off_t node_type; /* block, byte, serial, network */ + ddi_minor_type type; /* data type */ + major_t dev_major; /* dev_t can be 64-bit */ + minor_t dev_minor; + int spec_type; /* block or char */ + unsigned int mdclass; /* no longer used, may be removed */ + di_off_t node; /* address of di_node */ + uint64_t user_private_data; +}; + +typedef enum { + DI_PATH_STATE_UNKNOWN, + DI_PATH_STATE_OFFLINE, + DI_PATH_STATE_STANDBY, + DI_PATH_STATE_ONLINE, + DI_PATH_STATE_FAULT +} di_path_state_t; + +/* + * multipathing information structures + */ +struct di_path { + di_off_t self; /* make it self addressable */ + di_off_t path_c_link; /* next pathinfo via client linkage */ + di_off_t path_p_link; /* next pathinfo via phci linkage */ + di_off_t path_client; /* reference to client node */ + di_off_t path_phci; /* reference to phci node */ + di_off_t path_prop; /* property list */ + di_off_t path_addr; /* path addressing information */ + di_path_state_t path_state; /* path state */ + uint_t path_snap_state; /* describes valid fields */ + int path_instance; /* path instance */ + uint64_t user_private_data; + uint_t path_flags; /* path flags */ +}; + +/* + * chain of hotplug information structures + */ +struct di_hp { + di_off_t self; /* make it self addressable */ + di_off_t next; /* next one in chain */ + di_off_t hp_name; /* name of hotplug connection */ + int hp_connection; /* connection number */ + int hp_depends_on; /* connection number depended upon */ + int hp_state; /* current hotplug state */ + int hp_type; /* connection type: PCI, ... */ + di_off_t hp_type_str; /* description of connection type */ + uint32_t hp_last_change; /* timestamp of last change */ + di_off_t hp_child; /* child device node */ +}; + +/* + * Flags for snap_state + */ +#define DI_PATH_SNAP_NOCLIENT 0x01 /* client endpt not in snapshot */ +#define DI_PATH_SNAP_NOPHCI 0x02 /* phci endpt not in snapshot */ +#define DI_PATH_SNAP_ENDPTS 0x04 /* Endpoints have been postprocessed */ + +#define DI_PATH_SNAP_NOCLINK 0x10 /* client linkage not in snapshot */ +#define DI_PATH_SNAP_NOPLINK 0x20 /* phci linkage not in snapshot */ +#define DI_PATH_SNAP_LINKS 0x40 /* linkages have been postprocessed */ + +/* + * Flags for path_flags + */ +#define DI_PATH_FLAGS_DEVICE_REMOVED 0x01 /* peer of DI_DEVICE_REMOVED */ + +/* + * path properties + */ +struct di_path_prop { + di_off_t self; /* make it self addressable */ + di_off_t prop_next; /* next property linkage */ + di_off_t prop_name; /* property name */ + di_off_t prop_data; /* property data */ + int prop_type; /* property data type */ + int prop_len; /* prop length in bytes */ +}; + +/* + * Now the properties. + */ +struct di_prop { + di_off_t self; /* make it self addressable */ + di_off_t next; + di_off_t prop_name; /* Property name */ + di_off_t prop_data; /* property data */ + major_t dev_major; /* dev_t can be 64 bit */ + minor_t dev_minor; + int prop_flags; /* mark prop value types & more */ + int prop_len; /* prop len in bytes (boolean if 0) */ + int prop_list; /* which list (DI_PROP_SYS_LIST), etc */ +}; + +/* + * Private data stuff for supporting prtconf. + * Allows one level of indirection of fixed sized obj or obj array. + * The array size may be an int member of the array. + */ + +struct di_priv_format { + char drv_name[MAXPATHLEN]; /* name of parent drv for ppdata */ + size_t bytes; /* size in bytes of this struct */ + struct { /* ptrs to dereference */ + int size; /* size of object assoc. this ptr */ + int offset; /* location of pointer within struct */ + int len_offset; /* offset to var. containing the len */ + } ptr[MAX_PTR_IN_PRV]; +}; + +struct di_priv_data { + int version; + int n_parent; + int n_driver; + struct di_priv_format *parent; + struct di_priv_format *driver; +}; + + +/* + * structure for saving alias information + */ +struct di_alias { + di_off_t self; /* make it self addressable */ + di_off_t curroff; /* offset to curr dip's snapshot */ + di_off_t next; /* next alias */ + char alias[1]; /* alias path */ +}; + +/* + * structure passed in from ioctl + */ +struct dinfo_io { + char root_path[MAXPATHLEN]; + struct di_priv_data priv; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVINFO_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/devops.h b/illumos-x86_64/usr/include/sys/devops.h new file mode 100644 index 00000000..9e2bf1f7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devops.h @@ -0,0 +1,496 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2012 Garrett D'Amore . All rights reserved. + */ + +#ifndef _SYS_DEVOPS_H +#define _SYS_DEVOPS_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * cb_ops: Leaf device drivers or bus nexus drivers supporting + * direct user process access (open/close/etc). + * + * This is an OR of cdevsw and bdevsw fields for drivers that + * support both character and block entry points. + * + * For streams stuff, see also sys/stream.h. + * + * The following DDI/DKI or DKI only or DDI only functions are + * provided in the character/block driver operations structure. + * + * block/char Function description + * b/c XXopen DDI/DKI + * b/c XXclose DDI/DKI + * b XXstrategy DDI/DKI + * b XXprint DDI/DKI + * b XXdump DDI(Sun) + * c XXread DDI/DKI + * c XXwrite DDI/DKI + * c XXioctl DDI/DKI + * c XXdevmap DDI(Sun) + * c XXmmap DKI(Obsolete) + * c XXsegmap DKI + * c XXchpoll DDI/DKI + * c XXprop_op DDI(Sun) + * c XXaread DDI(Sun) + * c XXawrite DDI(Sun) + */ + +struct cb_ops { + int (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp); + int (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp); + int (*cb_strategy)(struct buf *bp); + int (*cb_print)(dev_t dev, char *str); + int (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk); + int (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp); + int (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp); + int (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode, + cred_t *credp, int *rvalp); + int (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off, + size_t len, size_t *maplen, uint_t model); + int (*cb_mmap)(dev_t dev, off_t off, int prot); + int (*cb_segmap)(dev_t dev, off_t off, struct as *asp, + caddr_t *addrp, off_t len, unsigned int prot, + unsigned int maxprot, unsigned int flags, cred_t *credp); + int (*cb_chpoll)(dev_t dev, short events, int anyyet, + short *reventsp, struct pollhead **phpp); + int (*cb_prop_op)(dev_t dev, dev_info_t *dip, + ddi_prop_op_t prop_op, int mod_flags, + char *name, caddr_t valuep, int *length); + + struct streamtab *cb_str; /* streams information */ + + /* + * The cb_flag fields are here to tell the system a + * bit about the device. The bit definitions are + * in . + */ + int cb_flag; /* driver compatibility flag */ + int cb_rev; /* cb_ops version number */ + int (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp); + int (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp); +}; + +/* + * bus_ops: bus nexus drivers only. + * + * These functions are used to implement the Sun DDI functions + * described elsewhere. + * + * Only nexus drivers support these entry points. + * + * The following bus nexus functions are provided in the bus nexus + * driver operations structure. Note that all functions take both + * their dip and the requesters dip except for the child functions since + * they will be called from outside the ddi. + * + * bus_map - Map/unmap/control IU -> device mappings. + * bus_get_intrspec - obsolete, not called + * bus_add_intrspec - obsolete, not called + * bus_remove_intrspec - obsolete, not called + * bus_map_fault - bus fault handler + * bus_dma_map - obsolete, not called + * bus_dma_allochdl - allocate a DMA handle + * bus_dma_freehdl - free a DMA handle + * bus_dma_bindhdl - bind a DMA handle to physical mapping + * bus_dma_unbindhdl - unbind a DMA handle to physical mapping + * bus_dma_flush - flush DMA caches + * bus_dma_win - access DMA windows + * bus_dma_ctl - control dma mapping (legacy use only) + * bus_ctl - generic control operations + * bus_prop_op - request for property + * bus_get_eventcookie - get an event cookie + * bus_add_eventcall - event call management + * bus_remove_eventcall - event call management + * bus_post_event - post an event + * bus_config - child node configuration + * bus_unconfig - child node unconfiguration + * bus_fm_init - FMA support + * bus_fm_fini - FMA support + * bus_fm_access_enter - FMA support + * bus_fm_access_exit - FMA support + * bus_power - power management + * bus_intr_op - control interrupt mappings + * bus_hp_op - hotplug support + */ + +#define BUSO_REV_3 3 +#define BUSO_REV_4 4 +#define BUSO_REV_5 5 +#define BUSO_REV_6 6 +#define BUSO_REV_7 7 +#define BUSO_REV_8 8 +#define BUSO_REV_9 9 +#define BUSO_REV_10 10 +#define BUSO_REV BUSO_REV_10 + + +struct bus_ops { + int busops_rev; /* rev of this structure */ + int (*bus_map)(dev_info_t *dip, dev_info_t *rdip, + ddi_map_req_t *mp, off_t offset, off_t len, + caddr_t *vaddrp); + + /* + * NOTE: the following 3 busops entrypoints are obsoleted with + * version 9 or greater. Use bus_intr_op interface in place of + * these obsolete interfaces. + */ + ddi_intrspec_t (*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip, + uint_t inumber); + int (*bus_add_intrspec)(dev_info_t *dip, + dev_info_t *rdip, ddi_intrspec_t intrspec, + ddi_iblock_cookie_t *ibcp, + ddi_idevice_cookie_t *idcp, + uint_t (*int_handler)(caddr_t intr_handler_arg), + caddr_t intr_handler_arg, int kind); + void (*bus_remove_intrspec)(dev_info_t *dip, + dev_info_t *rdip, ddi_intrspec_t intrspec, + ddi_iblock_cookie_t iblock_cookie); + + int (*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip, + struct hat *hat, struct seg *seg, caddr_t addr, + struct devpage *dp, pfn_t pfn, uint_t prot, + uint_t lock); + int (*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip, + struct ddi_dma_req *dmareq, + ddi_dma_handle_t *handlep); + int (*bus_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), + caddr_t arg, ddi_dma_handle_t *handlep); + int (*bus_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + int (*bus_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, struct ddi_dma_req *dmareq, + ddi_dma_cookie_t *, uint_t *); + int (*bus_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + int (*bus_dma_flush)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, off_t off, + size_t len, uint_t cache_flags); + int (*bus_dma_win)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, uint_t win, off_t *offp, + size_t *lenp, ddi_dma_cookie_t *cookiep, + uint_t *ccountp); + int (*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, + enum ddi_dma_ctlops request, off_t *offp, + size_t *lenp, caddr_t *objp, uint_t flags); + int (*bus_ctl)(dev_info_t *dip, dev_info_t *rdip, + ddi_ctl_enum_t ctlop, void *arg, void *result); + int (*bus_prop_op)(dev_t dev, dev_info_t *dip, + dev_info_t *child_dip, ddi_prop_op_t prop_op, + int mod_flags, char *name, caddr_t valuep, + int *length); + /* + * NOTE: the following 4 busops entrypoints are only available + * with version 3 or greater. Due to interface modifications, these + * entrypoints can only be used with version 6 or greater. + */ + + int (*bus_get_eventcookie)(dev_info_t *dip, + dev_info_t *rdip, char *eventname, + ddi_eventcookie_t *cookiep); + int (*bus_add_eventcall)(dev_info_t *dip, dev_info_t *rdip, + ddi_eventcookie_t eventid, + void (*event_hdlr)(dev_info_t *dip, + ddi_eventcookie_t event, void *arg, + void *bus_impldata), void *arg, + ddi_callback_id_t *cb_id); + int (*bus_remove_eventcall)(dev_info_t *devi, + ddi_callback_id_t cb_id); + int (*bus_post_event)(dev_info_t *dip, dev_info_t *rdip, + ddi_eventcookie_t event, void *impl_data); + + /* + * NOTE: the following bus_intr_ctl entrypoint is obsoleted with + * version 9 or greater. Use bus_intr_op interface in place of + * this obsolete interface. + */ + int (*bus_intr_ctl)(dev_info_t *dip, dev_info_t *rdip, + ddi_intr_ctlop_t ctlop, void * arg, void * result); + /* + * NOTE: the following busop entrypoints are available with version + * 5 or greater. + */ + int (*bus_config)(dev_info_t *parent, uint_t flags, + ddi_bus_config_op_t op, void *arg, + dev_info_t **childp); + int (*bus_unconfig)(dev_info_t *parent, uint_t flags, + ddi_bus_config_op_t op, void *arg); + + /* + * NOTE: the following busop entrypoints are available with version + * 6 or greater. + */ + int (*bus_fm_init)(dev_info_t *dip, dev_info_t *tdip, + int cap, ddi_iblock_cookie_t *ibc); + void (*bus_fm_fini)(dev_info_t *dip, dev_info_t *tdip); + void (*bus_fm_access_enter)(dev_info_t *dip, + ddi_acc_handle_t handle); + void (*bus_fm_access_exit)(dev_info_t *dip, + ddi_acc_handle_t handle); + + /* + * NOTE: the following busop entrypoint is available with version + * 7 or greater. + */ + int (*bus_power)(dev_info_t *dip, void *impl_arg, + pm_bus_power_op_t op, void *arg, void *result); + + /* + * NOTE: the following busop entrypoint is available with version + * 9 or greater. + */ + int (*bus_intr_op)(dev_info_t *dip, dev_info_t *rdip, + ddi_intr_op_t op, ddi_intr_handle_impl_t *hdlp, + void *result); + + /* + * NOTE: the following busop entrypoint is available with version + * 10 or greater. + */ + int (*bus_hp_op)(dev_info_t *dip, char *cn_name, + ddi_hp_op_t op, void *arg, void *result); +}; + +/* + * REV 1 bus ops structure + */ + +struct bus_ops_rev1 { + int (*bus_map)(dev_info_t *dip, dev_info_t *rdip, + ddi_map_req_t *mp, off_t offset, off_t len, + caddr_t *vaddrp); + ddi_intrspec_t (*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip, + uint_t inumber); + int (*bus_add_intrspec)(dev_info_t *dip, + dev_info_t *rdip, ddi_intrspec_t intrspec, + ddi_iblock_cookie_t *ibcp, + ddi_idevice_cookie_t *idcp, + uint_t (*int_handler)(caddr_t intr_handler_arg), + caddr_t intr_handler_arg, int kind); + void (*bus_remove_intrspec)(dev_info_t *dip, + dev_info_t *rdip, ddi_intrspec_t intrspec, + ddi_iblock_cookie_t iblock_cookie); + int (*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip, + struct hat *hat, struct seg *seg, caddr_t addr, + struct devpage *dp, pfn_t pfn, uint_t prot, + uint_t lock); + int (*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip, + struct ddi_dma_req *dmareq, + ddi_dma_handle_t *handlep); + int (*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, + enum ddi_dma_ctlops request, off_t *offp, + uint_t *lenp, caddr_t *objp, uint_t flags); + int (*bus_ctl)(dev_info_t *dip, dev_info_t *rdip, + ddi_ctl_enum_t ctlop, void *arg, void *result); + int (*bus_prop_op)(dev_t dev, dev_info_t *dip, + dev_info_t *child_dip, ddi_prop_op_t prop_op, + int mod_flags, char *name, caddr_t valuep, + int *length); +}; + +/* + * dev_ops: Contains driver common fields and pointers + * to the bus_ops and/or cb_ops parts. + * + * Drivers should set devo_rev to DEVO_REV at compile time. + * All drivers should support these entry points. + * + * the following device functions are provided in the device operations + * structure. + * + * devo_getinfo - Device handle conversion + * devo_identify - Obsolete, set to nulldev + * devo_probe - Probe for device's existence + * devo_attach - Attach driver to dev_info + * devo_detach - Detach/prepare driver to unload + * devo_reset - Reset device + * devo_quiesce - Quiesce device + */ + +#define DEVO_REV 4 +#define CB_REV 1 + +/* + * Return from driver's devo_probe function: + */ + +#define DDI_PROBE_FAILURE ENXIO /* matches nodev return */ +#define DDI_PROBE_DONTCARE 0 /* matches nulldev return */ +#define DDI_PROBE_PARTIAL 1 +#define DDI_PROBE_SUCCESS 2 + +/* + * Typedefs for the info, attach, detach and reset routines. + * These are mostly placeholders for now. + * + * NOTE: DDI_INFO_DEVT2DEVINFO is deprecated + */ +typedef enum { + DDI_INFO_DEVT2DEVINFO = 0, /* Convert a dev_t to a dev_info_t */ + DDI_INFO_DEVT2INSTANCE = 1 /* Convert a dev_t to an instance # */ +} ddi_info_cmd_t; + +typedef enum { + DDI_ATTACH = 0, + DDI_RESUME = 1, + DDI_PM_RESUME = 2 +} ddi_attach_cmd_t; + +typedef enum { + DDI_DETACH = 0, + DDI_SUSPEND = 1, + DDI_PM_SUSPEND = 2, + DDI_HOTPLUG_DETACH = 3 /* detach, don't try to auto-unconfig */ +} ddi_detach_cmd_t; + +typedef enum { + DDI_RESET_FORCE = 0 +} ddi_reset_cmd_t; + +struct dev_ops { + int devo_rev; /* Driver build version */ + int devo_refcnt; /* device reference count */ + + int (*devo_getinfo)(dev_info_t *dip, + ddi_info_cmd_t infocmd, void *arg, void **result); + int (*devo_identify)(dev_info_t *dip); + int (*devo_probe)(dev_info_t *dip); + int (*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd); + int (*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd); + int (*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd); + + struct cb_ops *devo_cb_ops; /* cb_ops pointer for leaf drivers */ + struct bus_ops *devo_bus_ops; /* bus_ops pointer for nexus drivers */ + int (*devo_power)(dev_info_t *dip, int component, + int level); + int (*devo_quiesce)(dev_info_t *dip); +}; + +/* + * Create a dev_ops suitable for a streams driver: + * + * XXX: Note: Since this is a macro, it is NOT supported as + * XXX: part of the Sun DDI. It is not a documented Sun DDI interface. + * + * STR_OPS(name, identify, probe, attach, detach, reset, + * info, flag, stream_tab); + * + * XXname is the name of the dev_ops structure. + * XXidentify must be set to nulldev + * XXprobe is the name of the probe routine, or nulldev + * XXattach is the name of the attach routine + * XXdetach is the name of the detach routine, or nodev + * XXreset is the name of the reset routine, or nodev + * XXinfo is the name of the info routine + * XXflag is driver flag (cb_flag) in cb_ops, + * XXstream_tab is the obvious. + * XXquiesce is the name of the quiesce routine. It must be implemented + * for fast reboot to succeed. + * cb_##XXname is the name of the internally defined cb_ops struct. + * + * uses cb_XXname as name of static cb_ops structure. + */ + +/* + * This file is included by genassym.c now and I couldn't get it to take the + * next line if it was broken into two lines joined by a '\'. So, don't try + * to reformat it to satisfy Cstyle because genassym.c won't compile. + */ +/* CSTYLED */ +#define DDI_DEFINE_STREAM_OPS(XXname, XXidentify, XXprobe, XXattach, XXdetach, XXreset, XXgetinfo, XXflag, XXstream_tab, XXquiesce) \ +static struct cb_ops cb_##XXname = { \ + nulldev, /* cb_open */ \ + nulldev, /* cb_close */ \ + nodev, /* cb_strategy */ \ + nodev, /* cb_print */ \ + nodev, /* cb_dump */ \ + nodev, /* cb_read */ \ + nodev, /* cb_write */ \ + nodev, /* cb_ioctl */ \ + nodev, /* cb_devmap */ \ + nodev, /* cb_mmap */ \ + nodev, /* cb_segmap */ \ + nochpoll, /* cb_chpoll */ \ + ddi_prop_op, /* cb_prop_op */ \ + (XXstream_tab), /* cb_stream */ \ + (int)(XXflag), /* cb_flag */ \ + CB_REV, /* cb_rev */ \ + nodev, /* cb_aread */ \ + nodev, /* cb_awrite */ \ +}; \ + \ +static struct dev_ops XXname = { \ + DEVO_REV, /* devo_rev */ \ + 0, /* devo_refcnt */ \ + (XXgetinfo), /* devo_getinfo */ \ + (XXidentify), /* devo_identify */ \ + (XXprobe), /* devo_probe */ \ + (XXattach), /* devo_attach */ \ + (XXdetach), /* devo_detach */ \ + (XXreset), /* devo_reset */ \ + &(cb_##XXname), /* devo_cb_ops */ \ + (struct bus_ops *)NULL, /* devo_bus_ops */ \ + NULL, /* devo_power */ \ + (XXquiesce) /* devo_quiesce */ \ +} + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVOPS_H */ diff --git a/illumos-x86_64/usr/include/sys/devpolicy.h b/illumos-x86_64/usr/include/sys/devpolicy.h new file mode 100644 index 00000000..653f04c0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devpolicy.h @@ -0,0 +1,120 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DEVPOLICY_H +#define _SYS_DEVPOLICY_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Device policy system call interface data structure. + * + * Inside the kernel we only make the structure definition available when the + * privilege set definition is complete, i.e., something included + * before including this file. + */ + +typedef struct devplcysys devplcysys_t; + +#if defined(__PRIV_CONST_IMPL) || !defined(_KERNEL) + +struct devplcysys { + major_t dps_maj; /* major number */ + minor_t dps_lomin; /* low minor number, if known */ + minor_t dps_himin; /* high minor number, if known */ + char dps_minornm[MAXNAMELEN]; /* minor name/pattern */ + boolean_t dps_isblock; /* expanded device is a block dev */ +#ifdef _KERNEL + priv_set_t dps_rdp; /* privileges required for reading */ + priv_set_t dps_wrp; /* privileges required for writing */ +#else + priv_chunk_t dps_sets[1]; /* read/write privilege sets */ +#endif +}; + +#ifdef _KERNEL +/* + * The actual device policy structure. This is returned on table + * lookups. + */ +struct devplcy { + uint32_t dp_ref; /* Reference count */ + uint32_t dp_gen; /* Generation count */ + priv_set_t dp_rdp; /* Privileges required for reading */ + priv_set_t dp_wrp; /* Privileges required for writing */ +}; +#endif /* _KERNEL */ + +#endif /* __PRIV_CONST_IMPL || !_KERNEL */ + +#ifdef _KERNEL + +typedef struct devplcy devplcy_t; + +extern devplcy_t *nullpolicy; /* The null policy */ + +extern volatile uint32_t devplcy_gen; /* The current generation count */ + +extern devplcy_t *dpget(void); +extern void dphold(devplcy_t *); +extern void dpfree(devplcy_t *); +extern devplcy_t *devpolicy_find(vnode_t *); + +extern void devpolicy_init(void); +extern int devpolicy_load(int, size_t, devplcysys_t *); +extern int devpolicy_get(int *, size_t, devplcysys_t *); +extern int devpolicy_getbyname(size_t, devplcysys_t *, char *); + +extern devplcy_t *devpolicy_priv_by_name(const char *, const char *); + +#else /* _KERNEL */ +#define DEVPLCYSYS_SZ(ip) (sizeof (devplcysys_t) + \ + ((ip)->priv_setsize * 2 - 1) * \ + sizeof (priv_chunk_t)) +#define DEVPLCYSYS_RDP(dp, ip) ((priv_set_t *)(&(dp)->dps_sets[0])) +#define DEVPLCYSYS_WRP(dp, ip) \ + ((priv_set_t *)(&(dp)->dps_sets[(ip)->priv_setsize])) + +#define DEVPLCY_TKN_RDP "read_priv_set" +#define DEVPLCY_TKN_WRP "write_priv_set" + +#endif /* _KERNEL */ + +#define MAXDEVPOLICY 1000 +#define DEVPOLICY_DFLT_MAJ ((major_t)~0) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVPOLICY_H */ diff --git a/illumos-x86_64/usr/include/sys/devpoll.h b/illumos-x86_64/usr/include/sys/devpoll.h new file mode 100644 index 00000000..3b6bd159 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/devpoll.h @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright 2015, Joyent, Inc. + */ + +#ifndef _SYS_DEVPOLL_H +#define _SYS_DEVPOLL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* /dev/poll ioctl */ +#define DPIOC (0xD0 << 8) +#define DP_POLL (DPIOC | 1) /* poll on fds cached via /dev/poll */ +#define DP_ISPOLLED (DPIOC | 2) /* is this fd cached in /dev/poll */ +#define DP_PPOLL (DPIOC | 3) /* ppoll on fds cached via /dev/poll */ +#define DP_EPOLLCOMPAT (DPIOC | 4) /* turn on epoll compatibility */ + +#define DEVPOLLSIZE 1000 /* /dev/poll table size increment */ + +/* + * /dev/poll DP_POLL ioctl format + */ +typedef struct dvpoll { + pollfd_t *dp_fds; /* pollfd array */ + nfds_t dp_nfds; /* num of pollfd's in dp_fds[] */ + int dp_timeout; /* time out in milisec */ + sigset_t *dp_setp; /* sigset, if any */ +} dvpoll_t; + +typedef struct dvpoll32 { + caddr32_t dp_fds; /* pollfd array */ + uint32_t dp_nfds; /* num of pollfd's in dp_fds[] */ + int32_t dp_timeout; /* time out in milisec */ + caddr32_t dp_setp; /* sigset, if any */ +} dvpoll32_t; + +typedef struct dvpoll_epollfd { + pollfd_t dpep_pollfd; /* must be first member */ + uint64_t dpep_data; /* data payload */ +} dvpoll_epollfd_t; + +#ifdef _KERNEL + +typedef struct dp_entry { + kmutex_t dpe_lock; /* protect a devpoll entry */ + pollcache_t *dpe_pcache; /* a ptr to pollcache */ + int dpe_refcnt; /* no. of ioctl lwp on the dpe */ + int dpe_writerwait; /* no. of waits on write */ + int dpe_flag; /* see below */ + kcondvar_t dpe_cv; +} dp_entry_t; + +#define DP_WRITER_PRESENT 0x1 /* a write is in progress */ +#define DP_ISEPOLLCOMPAT 0x2 /* epoll compatibility mode */ + +#define DP_REFRELE(dpep) { \ + mutex_enter(&(dpep)->dpe_lock); \ + ASSERT((dpep)->dpe_refcnt > 0); \ + (dpep)->dpe_refcnt--; \ + mutex_exit(&(dpep)->dpe_lock); \ +} +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DEVPOLL_H */ diff --git a/illumos-x86_64/usr/include/sys/dirent.h b/illumos-x86_64/usr/include/sys/dirent.h new file mode 100644 index 00000000..c079fb98 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dirent.h @@ -0,0 +1,135 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DIRENT_H +#define _SYS_DIRENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * File-system independent directory entry. + */ +typedef struct dirent { + ino_t d_ino; /* "inode number" of entry */ + off_t d_off; /* offset of disk directory entry */ + unsigned short d_reclen; /* length of this record */ + char d_name[1]; /* name of file */ +} dirent_t; + +#if defined(_SYSCALL32) + +/* kernel's view of user ILP32 dirent */ + +typedef struct dirent32 { + ino32_t d_ino; /* "inode number" of entry */ + off32_t d_off; /* offset of disk directory entry */ + uint16_t d_reclen; /* length of this record */ + char d_name[1]; /* name of file */ +} dirent32_t; + +#endif /* _SYSCALL32 */ + +#ifdef _LARGEFILE64_SOURCE + +/* + * transitional large file interface version AND kernel internal version + */ +typedef struct dirent64 { + ino64_t d_ino; /* "inode number" of entry */ + off64_t d_off; /* offset of disk directory entry */ + unsigned short d_reclen; /* length of this record */ + char d_name[1]; /* name of file */ +} dirent64_t; + +#endif /* _LARGEFILE64_SOURCE */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#define DIRENT64_RECLEN(namelen) \ + ((offsetof(dirent64_t, d_name[0]) + 1 + (namelen) + 7) & ~ 7) +#define DIRENT64_NAMELEN(reclen) \ + ((reclen) - (offsetof(dirent64_t, d_name[0]))) +#define DIRENT32_RECLEN(namelen) \ + ((offsetof(dirent32_t, d_name[0]) + 1 + (namelen) + 3) & ~ 3) +#define DIRENT32_NAMELEN(reclen) \ + ((reclen) - (offsetof(dirent32_t, d_name[0]))) +#endif + +/* + * This is the maximum number of bytes that getdents(2) will store in + * user-supplied dirent buffers. + */ +#define MAXGETDENTS_SIZE (64 * 1024) + +#if !defined(_KERNEL) + +/* + * large file compilation environment setup + * + * In the LP64 compilation environment, map large file interfaces + * back to native versions where possible. (This only works because + * a 'struct dirent' == 'struct dirent64'). + */ + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getdents getdents64 +#else +#define getdents getdents64 +#endif +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getdents64 getdents +#else +#define getdents64 getdents +#define dirent64 dirent +#define dirent64_t dirent_t +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern int getdents(int, struct dirent *, size_t); + +/* N.B.: transitional large file interface version deliberately not provided */ + +#endif /* !defined(_KERNEL) */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DIRENT_H */ diff --git a/illumos-x86_64/usr/include/sys/disp.h b/illumos-x86_64/usr/include/sys/disp.h new file mode 100644 index 00000000..cb3711ed --- /dev/null +++ b/illumos-x86_64/usr/include/sys/disp.h @@ -0,0 +1,195 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * + * Copyright 2018 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_DISP_H +#define _SYS_DISP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following is the format of a dispatcher queue entry. + */ +typedef struct dispq { + kthread_t *dq_first; /* first thread on queue or NULL */ + kthread_t *dq_last; /* last thread on queue or NULL */ + int dq_sruncnt; /* number of loaded, runnable */ + /* threads on queue */ +} dispq_t; + +/* + * Dispatch queue structure. + */ +typedef struct _disp { + disp_lock_t disp_lock; /* protects dispatching fields */ + pri_t disp_npri; /* # of priority levels in queue */ + dispq_t *disp_q; /* the dispatch queue */ + dispq_t *disp_q_limit; /* ptr past end of dispatch queue */ + ulong_t *disp_qactmap; /* bitmap of active dispatch queues */ + + /* + * Priorities: + * disp_maxrunpri is the maximum run priority of runnable threads + * on this queue. It is -1 if nothing is runnable. + * + * disp_max_unbound_pri is the maximum run priority of threads on + * this dispatch queue but runnable by any CPU. This may be left + * artificially high, then corrected when some CPU tries to take + * an unbound thread. It is -1 if nothing is runnable. + */ + pri_t disp_maxrunpri; /* maximum run priority */ + pri_t disp_max_unbound_pri; /* max pri of unbound threads */ + + volatile int disp_nrunnable; /* runnable threads in cpu dispq */ + + struct cpu *disp_cpu; /* cpu owning this queue or NULL */ + hrtime_t disp_steal; /* time when threads become stealable */ +} disp_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +#define MAXCLSYSPRI 99 +#define MINCLSYSPRI 60 + + +/* + * Global scheduling variables. + * - See sys/cpuvar.h for CPU-local variables. + */ +extern int nswapped; /* number of swapped threads */ + /* nswapped protected by swap_lock */ + +extern pri_t minclsyspri; /* minimum level of any system class */ +extern pri_t maxclsyspri; /* maximum level of any system class */ +extern pri_t intr_pri; /* interrupt thread priority base level */ + +#endif /* _KERNEL || _FAKE_KERNEL */ +#if defined(_KERNEL) + +/* + * Minimum amount of time that a thread can remain runnable before it can + * be stolen by another CPU (in nanoseconds). + */ +extern hrtime_t nosteal_nsec; + +/* + * Kernel preemption occurs if a higher-priority thread is runnable with + * a priority at or above kpreemptpri. + * + * So that other processors can watch for such threads, a separate + * dispatch queue with unbound work above kpreemptpri is maintained. + * This is part of the CPU partition structure (cpupart_t). + */ +extern pri_t kpreemptpri; /* level above which preemption takes place */ + +extern void disp_kp_alloc(disp_t *, pri_t); /* allocate kp queue */ +extern void disp_kp_free(disp_t *); /* free kp queue */ + +/* + * Macro for use by scheduling classes to decide whether the thread is about + * to be scheduled or not. This returns the maximum run priority. + */ +#define DISP_MAXRUNPRI(t) ((t)->t_disp_queue->disp_maxrunpri) + +/* + * Platform callbacks for various dispatcher operations + * + * idle_cpu() is invoked when a cpu goes idle, and has nothing to do. + * disp_enq_thread() is invoked when a thread is placed on a run queue. + */ +extern void (*idle_cpu)(); +extern void (*disp_enq_thread)(struct cpu *, int); + + +extern int dispdeq(kthread_t *); +extern void dispinit(void); +extern void disp_add(sclass_t *); +extern int intr_active(struct cpu *, int); +extern int servicing_interrupt(void); +extern void preempt(void); +extern void setbackdq(kthread_t *); +extern void setfrontdq(kthread_t *); +extern void swtch(void); +extern void swtch_to(kthread_t *); +extern void swtch_from_zombie(void) + __NORETURN; +extern void dq_sruninc(kthread_t *); +extern void dq_srundec(kthread_t *); +extern void cpu_rechoose(kthread_t *); +extern void cpu_surrender(kthread_t *); +extern void kpreempt(int); +extern struct cpu *disp_lowpri_cpu(struct cpu *, kthread_t *, pri_t); +extern int disp_bound_threads(struct cpu *, int); +extern int disp_bound_anythreads(struct cpu *, int); +extern int disp_bound_partition(struct cpu *, int); +extern void disp_cpu_init(struct cpu *); +extern void disp_cpu_fini(struct cpu *); +extern void disp_cpu_inactive(struct cpu *); +extern void disp_adjust_unbound_pri(kthread_t *); +extern void resume(kthread_t *); +extern void resume_from_intr(kthread_t *); +extern void resume_from_zombie(kthread_t *) + __NORETURN; +extern void disp_swapped_enq(kthread_t *); +extern int disp_anywork(void); + +extern struct cpu *disp_choose_best_cpu(void); + +#define KPREEMPT_SYNC (-1) +#define kpreempt_disable() \ + { \ + curthread->t_preempt++; \ + ASSERT(curthread->t_preempt >= 1); \ + } +#define kpreempt_enable() \ + { \ + ASSERT(curthread->t_preempt >= 1); \ + if (--curthread->t_preempt == 0 && \ + CPU->cpu_kprunrun) \ + kpreempt(KPREEMPT_SYNC); \ + } + +#endif /* _KERNEL */ + +#define CPU_IDLE_PRI (-1) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DISP_H */ diff --git a/illumos-x86_64/usr/include/sys/dkbad.h b/illumos-x86_64/usr/include/sys/dkbad.h new file mode 100644 index 00000000..84c7b8f1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dkbad.h @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_DKBAD_H +#define _SYS_DKBAD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions needed to perform bad sector + * revectoring ala DEC STD 144. + * + * The bad sector information is located in the + * first 5 even numbered sectors of the last + * track of the disk pack. There are five + * identical copies of the information, described + * by the dkbad structure. + * + * Replacement sectors are allocated starting with + * the first sector before the bad sector information + * and working backwards towards the beginning of + * the disk. A maximum of 126 bad sectors are supported. + * The position of the bad sector in the bad sector table + * determines which replacement sector it corresponds to. + * + * The bad sector information and replacement sectors + * are conventionally only accessible through the + * 'c' file system partition of the disk. If that + * partition is used for a file system, the user is + * responsible for making sure that it does not overlap + * the bad sector information or any replacement sector.s + */ + +#define NDKBAD 126 /* # of entries maximum */ + +struct dkbad { + long bt_csn; /* cartridge serial number */ + ushort_t bt_mbz; /* unused; should be 0 */ + ushort_t bt_flag; /* -1 => alignment cartridge */ + struct bt_bad { + short bt_cyl; /* cylinder number of bad sector */ + short bt_trksec; /* track and sector number */ + } bt_bad[NDKBAD]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DKBAD_H */ diff --git a/illumos-x86_64/usr/include/sys/dkio.h b/illumos-x86_64/usr/include/sys/dkio.h new file mode 100644 index 00000000..6996837b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dkio.h @@ -0,0 +1,575 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1982, 2010, Oracle and/or its affiliates. All rights reserved. + * + * Copyright 2017 Nexenta Systems, Inc. All rights reserved. + * Copyright 2012 DEY Storage Systems, Inc. All rights reserved. + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_DKIO_H +#define _SYS_DKIO_H + +#include /* Needed for NDKMAP define */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structures and definitions for disk io control commands + */ + +/* + * Structures used as data by ioctl calls. + */ + +#define DK_DEVLEN 16 /* device name max length, including */ + /* unit # & NULL (ie - "xyc1") */ + +/* + * Used for controller info + */ +struct dk_cinfo { + char dki_cname[DK_DEVLEN]; /* controller name (no unit #) */ + ushort_t dki_ctype; /* controller type */ + ushort_t dki_flags; /* flags */ + ushort_t dki_cnum; /* controller number */ + uint_t dki_addr; /* controller address */ + uint_t dki_space; /* controller bus type */ + uint_t dki_prio; /* interrupt priority */ + uint_t dki_vec; /* interrupt vector */ + char dki_dname[DK_DEVLEN]; /* drive name (no unit #) */ + uint_t dki_unit; /* unit number */ + uint_t dki_slave; /* slave number */ + ushort_t dki_partition; /* partition number */ + ushort_t dki_maxtransfer; /* max. transfer size in DEV_BSIZE */ +}; + +/* + * Controller types + */ +#define DKC_UNKNOWN 0 +#define DKC_CDROM 1 /* CD-ROM, SCSI or otherwise */ +#define DKC_WDC2880 2 +#define DKC_XXX_0 3 /* unassigned */ +#define DKC_XXX_1 4 /* unassigned */ +#define DKC_DSD5215 5 +#define DKC_ACB4000 7 +#define DKC_MD21 8 +#define DKC_XXX_2 9 /* unassigned */ +#define DKC_NCRFLOPPY 10 +#define DKC_SMSFLOPPY 12 +#define DKC_SCSI_CCS 13 /* SCSI CCS compatible */ +#define DKC_INTEL82072 14 /* native floppy chip */ +#define DKC_MD 16 /* meta-disk (virtual-disk) driver (obsolete) */ +#define DKC_INTEL82077 19 /* 82077 floppy disk controller */ +#define DKC_DIRECT 20 /* Intel direct attached device i.e. IDE */ +#define DKC_PCMCIA_MEM 21 /* PCMCIA memory disk-like type (Obsolete) */ +#define DKC_PCMCIA_ATA 22 /* PCMCIA AT Attached type */ +#define DKC_VBD 23 /* virtual block device */ +#define DKC_BLKDEV 24 /* generic block device (see blkdev(4D)) */ + +/* + * Sun reserves up through 1023 + */ + +#define DKC_CUSTOMER_BASE 1024 + +/* + * Flags + */ +#define DKI_BAD144 0x01 /* use DEC std 144 bad sector fwding */ +#define DKI_MAPTRK 0x02 /* controller does track mapping */ +#define DKI_FMTTRK 0x04 /* formats only full track at a time */ +#define DKI_FMTVOL 0x08 /* formats only full volume at a time */ +#define DKI_FMTCYL 0x10 /* formats only full cylinders at a time */ +#define DKI_HEXUNIT 0x20 /* unit number is printed as 3 hex digits */ +#define DKI_PCMCIA_PFD 0x40 /* PCMCIA pseudo-floppy memory card */ + +/* + * Used for all partitions + */ +struct dk_allmap { + struct dk_map dka_map[NDKMAP]; +}; + +#if defined(_SYSCALL32) +struct dk_allmap32 { + struct dk_map32 dka_map[NDKMAP]; +}; +#endif /* _SYSCALL32 */ + +/* + * Definition of a disk's geometry + */ +struct dk_geom { + unsigned short dkg_ncyl; /* # of data cylinders */ + unsigned short dkg_acyl; /* # of alternate cylinders */ + unsigned short dkg_bcyl; /* cyl offset (for fixed head area) */ + unsigned short dkg_nhead; /* # of heads */ + unsigned short dkg_obs1; /* obsolete */ + unsigned short dkg_nsect; /* # of data sectors per track */ + unsigned short dkg_intrlv; /* interleave factor */ + unsigned short dkg_obs2; /* obsolete */ + unsigned short dkg_obs3; /* obsolete */ + unsigned short dkg_apc; /* alternates per cyl (SCSI only) */ + unsigned short dkg_rpm; /* revolutions per minute */ + unsigned short dkg_pcyl; /* # of physical cylinders */ + unsigned short dkg_write_reinstruct; /* # sectors to skip, writes */ + unsigned short dkg_read_reinstruct; /* # sectors to skip, reads */ + unsigned short dkg_extra[7]; /* for compatible expansion */ +}; + +/* + * These defines are for historic compatibility with old drivers. + */ +#define dkg_bhead dkg_obs1 /* used to be head offset */ +#define dkg_gap1 dkg_obs2 /* used to be gap1 */ +#define dkg_gap2 dkg_obs3 /* used to be gap2 */ + +/* + * Disk io control commands + * Warning: some other ioctls with the DIOC prefix exist elsewhere. + * The Generic DKIOC numbers are from 0 - 50. + * The Floppy Driver uses 51 - 100. + * The Hard Disk (except SCSI) 101 - 106. (these are obsolete) + * The CDROM Driver 151 - 200. + * The USCSI ioctl 201 - 250. + */ +#define DKIOC (0x04 << 8) + +/* + * The following ioctls are generic in nature and need to be + * suported as appropriate by all disk drivers + */ +#define DKIOCGGEOM (DKIOC|1) /* Get geometry */ +#define DKIOCINFO (DKIOC|3) /* Get info */ +#define DKIOCEJECT (DKIOC|6) /* Generic 'eject' */ +#define DKIOCGVTOC (DKIOC|11) /* Get VTOC */ +#define DKIOCSVTOC (DKIOC|12) /* Set VTOC & Write to Disk */ + +#define DKIOCGEXTVTOC (DKIOC|23) /* Get extended VTOC */ +#define DKIOCSEXTVTOC (DKIOC|24) /* Set extended VTOC, Write to Disk */ + +/* + * Disk Cache Controls. These ioctls should be supported by + * all disk drivers. + * + * DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl + * argument, but it should be passed as NULL to allow for future + * reinterpretation. From user-mode, this ioctl request is synchronous. + * + * When invoked from within the kernel, the arg can be NULL to indicate + * a synchronous request or can be the address of a struct dk_callback + * to request an asynchronous callback when the flush request is complete. + * In this case, the flag to the ioctl must include FKIOCTL and the + * dkc_callback field of the pointed to struct must be non-null or the + * request is made synchronously. + * + * In the callback case: if the ioctl returns 0, a callback WILL be performed. + * If the ioctl returns non-zero, a callback will NOT be performed. + * NOTE: In some cases, the callback may be done BEFORE the ioctl call + * returns. The caller's locking strategy should be prepared for this case. + */ +#define DKIOCFLUSHWRITECACHE (DKIOC|34) /* flush cache to phys medium */ + +struct dk_callback { + void (*dkc_callback)(void *dkc_cookie, int error); + void *dkc_cookie; + int dkc_flag; +}; + +/* bit flag definitions for dkc_flag */ +#define FLUSH_VOLATILE 0x1 /* Bit 0: if set, only flush */ + /* volatile cache; otherwise, flush */ + /* volatile and non-volatile cache */ + +#define DKIOCGETWCE (DKIOC|36) /* Get current write cache */ + /* enablement status */ +#define DKIOCSETWCE (DKIOC|37) /* Enable/Disable write cache */ + +/* + * The following ioctls are used by Sun drivers to communicate + * with their associated format routines. Support of these ioctls + * is not required of foreign drivers + */ +#define DKIOCSGEOM (DKIOC|2) /* Set geometry */ +#define DKIOCSAPART (DKIOC|4) /* Set all partitions */ +#define DKIOCGAPART (DKIOC|5) /* Get all partitions */ +#define DKIOCG_PHYGEOM (DKIOC|32) /* get physical geometry */ +#define DKIOCG_VIRTGEOM (DKIOC|33) /* get virtual geometry */ + +/* + * The following ioctl's are removable media support + */ +#define DKIOCLOCK (DKIOC|7) /* Generic 'lock' */ +#define DKIOCUNLOCK (DKIOC|8) /* Generic 'unlock' */ +#define DKIOCSTATE (DKIOC|13) /* Inquire insert/eject state */ +#define DKIOCREMOVABLE (DKIOC|16) /* is media removable */ + + +/* + * ioctl for hotpluggable devices + */ +#define DKIOCHOTPLUGGABLE (DKIOC|35) /* is hotpluggable */ + +#if defined(__i386) || defined(__amd64) +/* ioctl to write extended partition structure into the disk */ +#define DKIOCSETEXTPART (DKIOC|46) +#endif + +/* ioctl to report whether the disk is solid state or not - used for ZFS */ +#define DKIOCSOLIDSTATE (DKIOC|38) + +/* + * Ioctl to force driver to re-read the alternate partition and rebuild + * the internal defect map. + */ +#define DKIOCADDBAD (DKIOC|20) /* Re-read the alternate map (IDE) */ +#define DKIOCGETDEF (DKIOC|21) /* read defect list (IDE) */ + +/* + * Used by applications to get disk defect information from IDE + * drives. + */ +#ifdef _SYSCALL32 +struct defect_header32 { + int head; + caddr32_t buffer; +}; +#endif /* _SYSCALL32 */ + +struct defect_header { + int head; + caddr_t buffer; +}; + +#define DKIOCPARTINFO (DKIOC|22) /* Get partition or slice parameters */ +#define DKIOCEXTPARTINFO (DKIOC|19) /* Get extended partition or slice */ + /* parameters */ + + +/* + * Used by applications to get partition or slice information + */ +#ifdef _SYSCALL32 +struct part_info32 { + daddr32_t p_start; + int p_length; +}; +#endif /* _SYSCALL32 */ + +struct part_info { + daddr_t p_start; + int p_length; +}; + +struct extpart_info { + diskaddr_t p_start; + diskaddr_t p_length; +}; + +/* The following ioctls are for Optical Memory Device */ +#define DKIOC_EBP_ENABLE (DKIOC|40) /* enable by pass erase on write */ +#define DKIOC_EBP_DISABLE (DKIOC|41) /* disable by pass erase on write */ + +/* + * This state enum is the argument passed to the DKIOCSTATE ioctl. + */ +enum dkio_state { DKIO_NONE, DKIO_EJECTED, DKIO_INSERTED, DKIO_DEV_GONE }; + +#define DKIOCGMEDIAINFO (DKIOC|42) /* get information about the media */ + +/* + * ioctls to read/write mboot info. + */ +#define DKIOCGMBOOT (DKIOC|43) /* get mboot info */ +#define DKIOCSMBOOT (DKIOC|44) /* set mboot info */ + +/* + * ioctl to get the device temperature. + */ +#define DKIOCGTEMPERATURE (DKIOC|45) /* get temperature */ + +/* + * ioctl to get the media info including physical block size + */ +#define DKIOCGMEDIAINFOEXT (DKIOC|48) + +/* + * ioctl to determine whether media is write-protected + */ +#define DKIOCREADONLY (DKIOC|49) + +/* + * Used for providing the temperature. + */ + +struct dk_temperature { + uint_t dkt_flags; /* Flags */ + short dkt_cur_temp; /* Current disk temperature */ + short dkt_ref_temp; /* reference disk temperature */ +}; + +#define DKT_BYPASS_PM 0x1 +#define DKT_INVALID_TEMP 0xFFFF + + +/* + * Used for Media info or the current profile info + */ +struct dk_minfo { + uint_t dki_media_type; /* Media type or profile info */ + uint_t dki_lbsize; /* Logical blocksize of media */ + diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */ +}; + +/* + * Used for Media info or the current profile info + * including physical block size if supported. + */ +struct dk_minfo_ext { + uint_t dki_media_type; /* Media type or profile info */ + uint_t dki_lbsize; /* Logical blocksize of media */ + diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */ + uint_t dki_pbsize; /* Physical blocksize of media */ +}; + +#ifdef _KERNEL + +/* + * The 32-bit version of the media info API did not end up with a consistent + * size in an ILP32 and LP64 interface. While the actual offsets of the members + * are the same, the resulting structure size is not. + */ +#pragma pack(4) +struct dk_minfo_ext32 { + uint_t dki_media_type; /* Media type or profile info */ + uint_t dki_lbsize; /* Logical blocksize of media */ + diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */ + uint_t dki_pbsize; /* Physical blocksize of media */ +}; +#pragma pack() +#endif + +/* + * Media types or profiles known + */ +#define DK_UNKNOWN 0x00 /* Media inserted - type unknown */ + + +/* + * SFF 8090 Specification Version 3, media types 0x01 - 0xfffe are retained to + * maintain compatibility with SFF8090. The following define the + * optical media type. + */ +#define DK_REMOVABLE_DISK 0x02 /* Removable Disk */ +#define DK_MO_ERASABLE 0x03 /* MO Erasable */ +#define DK_MO_WRITEONCE 0x04 /* MO Write once */ +#define DK_AS_MO 0x05 /* AS MO */ +#define DK_CDROM 0x08 /* CDROM */ +#define DK_CDR 0x09 /* CD-R */ +#define DK_CDRW 0x0A /* CD-RW */ +#define DK_DVDROM 0x10 /* DVD-ROM */ +#define DK_DVDR 0x11 /* DVD-R */ +#define DK_DVDRAM 0x12 /* DVD_RAM or DVD-RW */ + +/* + * Media types for other rewritable magnetic media + */ +#define DK_FIXED_DISK 0x10001 /* Fixed disk SCSI or otherwise */ +#define DK_FLOPPY 0x10002 /* Floppy media */ +#define DK_ZIP 0x10003 /* IOMEGA ZIP media */ +#define DK_JAZ 0x10004 /* IOMEGA JAZ media */ + +#define DKIOCSETEFI (DKIOC|17) /* Set EFI info */ +#define DKIOCGETEFI (DKIOC|18) /* Get EFI info */ + +#define DKIOCPARTITION (DKIOC|9) /* Get partition info */ + +/* + * Ioctls to get/set volume capabilities related to Logical Volume Managers. + * They include the ability to get/set capabilities and to issue a read to a + * specific underlying device of a replicated device. + */ + +#define DKIOCGETVOLCAP (DKIOC | 25) /* Get volume capabilities */ +#define DKIOCSETVOLCAP (DKIOC | 26) /* Set volume capabilities */ +#define DKIOCDMR (DKIOC | 27) /* Issue a directed read */ + +#define DKIOCDUMPINIT (DKIOC | 28) /* Dumpify a zvol */ +#define DKIOCDUMPFINI (DKIOC | 29) /* Un-Dumpify a zvol */ + +typedef uint_t volcapinfo_t; + +typedef uint_t volcapset_t; + +#define DKV_ABR_CAP 0x00000001 /* Support Appl.Based Recovery */ +#define DKV_DMR_CAP 0x00000002 /* Support Directed Mirror Read */ + +typedef struct volcap { + volcapinfo_t vc_info; /* Capabilities available */ + volcapset_t vc_set; /* Capabilities set */ +} volcap_t; + +#define VOL_SIDENAME 256 + +typedef struct vol_directed_rd { + int vdr_flags; + offset_t vdr_offset; + size_t vdr_nbytes; + size_t vdr_bytesread; + void *vdr_data; + int vdr_side; + char vdr_side_name[VOL_SIDENAME]; +} vol_directed_rd_t; + +#define DKV_SIDE_INIT (-1) +#define DKV_DMR_NEXT_SIDE 0x00000001 +#define DKV_DMR_DONE 0x00000002 +#define DKV_DMR_ERROR 0x00000004 +#define DKV_DMR_SUCCESS 0x00000008 +#define DKV_DMR_SHORT 0x00000010 + +#ifdef _MULTI_DATAMODEL +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif +typedef struct vol_directed_rd32 { + int32_t vdr_flags; + offset_t vdr_offset; /* 64-bit element on 32-bit alignment */ + size32_t vdr_nbytes; + size32_t vdr_bytesread; + caddr32_t vdr_data; + int32_t vdr_side; + char vdr_side_name[VOL_SIDENAME]; +} vol_directed_rd32_t; +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif +#endif /* _MULTI_DATAMODEL */ + +/* + * The ioctl is used to fetch disk's device type, vendor ID, + * model number/product ID, firmware revision and serial number together. + * + * Currently there are two device types - DKD_ATA_TYPE which means the + * disk is driven by cmdk/ata or dad/uata driver, and DKD_SCSI_TYPE + * which means the disk is driven by sd/scsi hba driver. + */ +#define DKIOC_GETDISKID (DKIOC|46) + +/* These two labels are for dkd_dtype of dk_disk_id_t */ +#define DKD_ATA_TYPE 0x01 /* ATA disk or legacy mode SATA disk */ +#define DKD_SCSI_TYPE 0x02 /* SCSI disk or native mode SATA disk */ + +#define DKD_ATA_MODEL 40 /* model number length */ +#define DKD_ATA_FWVER 8 /* firmware revision length */ +#define DKD_ATA_SERIAL 20 /* serial number length */ + +#define DKD_SCSI_VENDOR 8 /* vendor ID length */ +#define DKD_SCSI_PRODUCT 16 /* product ID length */ +#define DKD_SCSI_REVLEVEL 4 /* revision level length */ +#define DKD_SCSI_SERIAL 12 /* serial number length */ + +/* + * The argument type for DKIOC_GETDISKID ioctl. + */ +typedef struct dk_disk_id { + uint_t dkd_dtype; + union { + struct { + char dkd_amodel[DKD_ATA_MODEL]; /* 40 bytes */ + char dkd_afwver[DKD_ATA_FWVER]; /* 8 bytes */ + char dkd_aserial[DKD_ATA_SERIAL]; /* 20 bytes */ + } ata_disk_id; + struct { + char dkd_svendor[DKD_SCSI_VENDOR]; /* 8 bytes */ + char dkd_sproduct[DKD_SCSI_PRODUCT]; /* 16 bytes */ + char dkd_sfwver[DKD_SCSI_REVLEVEL]; /* 4 bytes */ + char dkd_sserial[DKD_SCSI_SERIAL]; /* 12 bytes */ + } scsi_disk_id; + } disk_id; +} dk_disk_id_t; + +/* + * The ioctl is used to update the firmware of device. + */ +#define DKIOC_UPDATEFW (DKIOC|47) + +/* The argument type for DKIOC_UPDATEFW ioctl */ +typedef struct dk_updatefw { + caddr_t dku_ptrbuf; /* pointer to firmware buf */ + uint_t dku_size; /* firmware buf length */ + uint8_t dku_type; /* firmware update type */ +} dk_updatefw_t; + +#ifdef _SYSCALL32 +typedef struct dk_updatefw_32 { + caddr32_t dku_ptrbuf; /* pointer to firmware buf */ + uint_t dku_size; /* firmware buf length */ + uint8_t dku_type; /* firmware update type */ +} dk_updatefw_32_t; +#endif /* _SYSCALL32 */ + +/* + * firmware update type - temporary or permanent use + */ +#define FW_TYPE_TEMP 0x0 /* temporary use */ +#define FW_TYPE_PERM 0x1 /* permanent use */ + +/* + * ioctl to free space (e.g. SCSI UNMAP) off a disk. + * Pass a dkioc_free_list_t containing a list of extents to be freed. + */ +#define DKIOCFREE (DKIOC|50) + +#define DF_WAIT_SYNC 0x00000001 /* Wait for full write-out of free. */ +typedef struct dkioc_free_list_ext_s { + uint64_t dfle_start; + uint64_t dfle_length; +} dkioc_free_list_ext_t; + +typedef struct dkioc_free_list_s { + uint64_t dfl_flags; + uint64_t dfl_num_exts; + uint64_t dfl_offset; + dkioc_free_list_ext_t dfl_exts[1]; +} dkioc_free_list_t; +#define DFL_SZ(num_exts) \ + (sizeof (dkioc_free_list_t) + \ + (num_exts - 1) * sizeof (dkioc_free_list_ext_t)) + +/* + * ioctl to determine if free (e.g. SCSI UNMAP) is supported. + * See FDIOC ioctls for why we're not using '51' here. + */ +#define DKIOC_CANFREE (DKIOC|60) + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DKIO_H */ diff --git a/illumos-x86_64/usr/include/sys/dkioc_free_util.h b/illumos-x86_64/usr/include/sys/dkioc_free_util.h new file mode 100644 index 00000000..f6163039 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dkioc_free_util.h @@ -0,0 +1,77 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 Nexenta Inc. All rights reserved. + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_DKIOC_FREE_UTIL_H +#define _SYS_DKIOC_FREE_UTIL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DFL_COPYIN_MAX_EXTS (1024 * 1024) + +#define DFL_ISSYNC(dfl) (((dfl)->dfl_flags & DF_WAIT_SYNC) ? B_TRUE : B_FALSE) + +/* + * Since dkioc_free_list_t and in general DKIOCFREE use bytes to express + * values instead of blocks, dkioc_free_info_t uses bytes as well for + * consistency. + */ +typedef struct dkioc_free_info { + /* log2(block size) */ + uint64_t dfi_bshift; + + /* Maximum number of extents in a single request. 0 == no limit */ + uint64_t dfi_max_ext; + + /* + * Maximum total number of bytes in a single request. 0 == no limit. + * Must by a multiple of 1U << dfi_bshift (e.g. dfi_bshift == 9, + * dfk_max_bytes must be a multiple of 512). + */ + uint64_t dfi_max_bytes; + + /* + * Maximum length of an extent. 0 == same as dfi_max_bytes. If > 0, + * must be a multiple of 1U << dfi_shift (the block size) and + * <= dfi_max_bytes. + */ + uint64_t dfi_max_ext_bytes; + + /* + * Minimum alignment for starting extent offsets in bytes + * Must be > 0, and a multiple of 1U << dfi_shift. + * + * A possible future extention might be to also express a preferred + * alignment when splitting extents. + */ + uint64_t dfi_align; +} dkioc_free_info_t; + +typedef int (*dfl_iter_fn_t)(dkioc_free_list_t *dfl, void *arg, int kmflag); + +int dfl_copyin(void *arg, dkioc_free_list_t **out, int ddi_flags, int kmflags); +void dfl_free(dkioc_free_list_t *dfl); +int dfl_iter(dkioc_free_list_t *dfl, const dkioc_free_info_t *dfi, uint64_t len, + dfl_iter_fn_t fn, void *arg, int kmflag); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DKIOC_FREE_UTIL_H */ diff --git a/illumos-x86_64/usr/include/sys/dklabel.h b/illumos-x86_64/usr/include/sys/dklabel.h new file mode 100644 index 00000000..25b52c01 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dklabel.h @@ -0,0 +1,277 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DKLABEL_H +#define _SYS_DKLABEL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Miscellaneous defines + */ +#define DKL_MAGIC 0xDABE /* magic number */ +#define FKL_MAGIC 0xff /* magic number for DOS floppies */ + +#if defined(_SUNOS_VTOC_16) +#define NDKMAP 16 /* # of logical partitions */ +#define DK_LABEL_LOC 1 /* location of disk label */ +#elif defined(_SUNOS_VTOC_8) +#define NDKMAP 8 /* # of logical partitions */ +#define DK_LABEL_LOC 0 /* location of disk label */ +#else +#error "No VTOC format defined." +#endif + +#define LEN_DKL_ASCII 128 /* length of dkl_asciilabel */ +#define LEN_DKL_VVOL 8 /* length of v_volume */ +#define DK_LABEL_SIZE 512 /* size of disk label */ +#define DK_MAX_BLOCKS 0x7fffffff /* max # of blocks handled */ + +/* + * Reserve two cylinders on SCSI disks. + * One is for the backup disk label and the other is for the deviceid. + * + * IPI disks only reserve one cylinder, but they will go away soon. + * CDROMs do not reserve any cylinders. + */ +#define DK_ACYL 2 + +/* + * Format of a Sun disk label. + * Resides in cylinder 0, head 0, sector 0. + * + * sizeof (struct dk_label) should be 512 (the current sector size), + * but should the sector size increase, this structure should remain + * at the beginning of the sector. + */ + +#if !defined(BLKADDR_TYPE) +#define BLKADDR_TYPE +#if defined(_EXTVTOC) +typedef unsigned long blkaddr_t; +typedef unsigned int blkaddr32_t; +#else +typedef daddr_t blkaddr_t; +typedef daddr32_t blkaddr32_t; +#endif +#endif + +/* + * partition headers: section 1 + * Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(4I)) + */ +struct dk_map { + blkaddr_t dkl_cylno; /* starting cylinder */ + blkaddr_t dkl_nblk; /* number of blocks; if == 0, */ + /* partition is undefined */ +}; + +/* + * partition headers: section 1 + * Fixed size for on-disk dk_label + */ +struct dk_map32 { + blkaddr32_t dkl_cylno; /* starting cylinder */ + blkaddr32_t dkl_nblk; /* number of blocks; if == 0, */ + /* partition is undefined */ +}; + +/* + * partition headers: section 2, + * brought over from AT&T SVr4 vtoc structure. + */ +struct dk_map2 { + uint16_t p_tag; /* ID tag of partition */ + uint16_t p_flag; /* permission flag */ +}; + +struct dkl_partition { + uint16_t p_tag; /* ID tag of partition */ + uint16_t p_flag; /* permision flags */ + blkaddr32_t p_start; /* start sector no of partition */ + blkaddr32_t p_size; /* # of blocks in partition */ +}; + + +/* + * VTOC inclusions from AT&T SVr4 + * Fixed sized types for on-disk VTOC + */ + +struct dk_vtoc { +#if defined(_SUNOS_VTOC_16) + uint32_t v_bootinfo[3]; /* info for mboot (unsupported) */ + uint32_t v_sanity; /* to verify vtoc sanity */ + uint32_t v_version; /* layout version */ + char v_volume[LEN_DKL_VVOL]; /* volume name */ + uint16_t v_sectorsz; /* sector size in bytes */ + uint16_t v_nparts; /* number of partitions */ + uint32_t v_reserved[10]; /* free space */ + struct dkl_partition v_part[NDKMAP]; /* partition headers */ + time32_t timestamp[NDKMAP]; /* partition timestamp (unsupported) */ + char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ +#elif defined(_SUNOS_VTOC_8) + uint32_t v_version; /* layout version */ + char v_volume[LEN_DKL_VVOL]; /* volume name */ + uint16_t v_nparts; /* number of partitions */ + struct dk_map2 v_part[NDKMAP]; /* partition hdrs, sec 2 */ + uint32_t v_bootinfo[3]; /* info needed by mboot */ + uint32_t v_sanity; /* to verify vtoc sanity */ + uint32_t v_reserved[10]; /* free space */ + time32_t v_timestamp[NDKMAP]; /* partition timestamp */ +#else +#error "No VTOC format defined." +#endif +}; + +/* + * define the amount of disk label padding needed to make + * the entire structure occupy 512 bytes. + */ +#if defined(_SUNOS_VTOC_16) +#define LEN_DKL_PAD (DK_LABEL_SIZE - \ + ((sizeof (struct dk_vtoc) + \ + (4 * sizeof (uint32_t)) + \ + (12 * sizeof (uint16_t)) + \ + (2 * (sizeof (uint16_t)))))) +#elif defined(_SUNOS_VTOC_8) +#define LEN_DKL_PAD (DK_LABEL_SIZE \ + - ((LEN_DKL_ASCII) + \ + (sizeof (struct dk_vtoc)) + \ + (sizeof (struct dk_map32) * NDKMAP) + \ + (14 * (sizeof (uint16_t))) + \ + (2 * (sizeof (uint16_t))))) +#else +#error "No VTOC format defined." +#endif + + +struct dk_label { +#if defined(_SUNOS_VTOC_16) + struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */ + uint32_t dkl_pcyl; /* # of physical cylinders */ + uint32_t dkl_ncyl; /* # of data cylinders */ + uint16_t dkl_acyl; /* # of alternate cylinders */ + uint16_t dkl_bcyl; /* cyl offset (for fixed head area) */ + uint32_t dkl_nhead; /* # of heads */ + uint32_t dkl_nsect; /* # of data sectors per track */ + uint16_t dkl_intrlv; /* interleave factor */ + uint16_t dkl_skew; /* skew factor */ + uint16_t dkl_apc; /* alternates per cyl (SCSI only) */ + uint16_t dkl_rpm; /* revolutions per minute */ + uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */ + uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */ + uint16_t dkl_extra[4]; /* for compatible expansion */ + char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */ +#elif defined(_SUNOS_VTOC_8) + char dkl_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ + struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */ + uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */ + uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */ + char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */ + uint16_t dkl_rpm; /* rotations per minute */ + uint16_t dkl_pcyl; /* # physical cylinders */ + uint16_t dkl_apc; /* alternates per cylinder */ + uint16_t dkl_obs1; /* obsolete */ + uint16_t dkl_obs2; /* obsolete */ + uint16_t dkl_intrlv; /* interleave factor */ + uint16_t dkl_ncyl; /* # of data cylinders */ + uint16_t dkl_acyl; /* # of alternate cylinders */ + uint16_t dkl_nhead; /* # of heads in this partition */ + uint16_t dkl_nsect; /* # of sectors per track */ + uint16_t dkl_obs3; /* obsolete */ + uint16_t dkl_obs4; /* obsolete */ + struct dk_map32 dkl_map[NDKMAP]; /* logical partition headers */ +#else +#error "No VTOC format defined." +#endif + uint16_t dkl_magic; /* identifies this label format */ + uint16_t dkl_cksum; /* xor checksum of sector */ +}; + +#if defined(_SUNOS_VTOC_16) +#define dkl_asciilabel dkl_vtoc.v_asciilabel +#define v_timestamp timestamp + +#elif defined(_SUNOS_VTOC_8) + +/* + * These defines are for historic compatibility with old drivers. + */ +#define dkl_gap1 dkl_obs1 /* used to be gap1 */ +#define dkl_gap2 dkl_obs2 /* used to be gap2 */ +#define dkl_bhead dkl_obs3 /* used to be label head offset */ +#define dkl_ppart dkl_obs4 /* used to by physical partition */ +#else +#error "No VTOC format defined." +#endif + +struct fk_label { /* DOS floppy label */ + uchar_t fkl_type; + uchar_t fkl_magich; + uchar_t fkl_magicl; + uchar_t filler; +}; + +/* + * Layout of stored fabricated device id (on-disk) + */ +#define DK_DEVID_BLKSIZE (512) +#define DK_DEVID_SIZE (DK_DEVID_BLKSIZE - ((sizeof (uchar_t) * 7))) +#define DK_DEVID_REV_MSB (0) +#define DK_DEVID_REV_LSB (1) + +struct dk_devid { + uchar_t dkd_rev_hi; /* revision (MSB) */ + uchar_t dkd_rev_lo; /* revision (LSB) */ + uchar_t dkd_flags; /* flags (not used yet) */ + uchar_t dkd_devid[DK_DEVID_SIZE]; /* devid stored here */ + uchar_t dkd_checksum3; /* checksum (MSB) */ + uchar_t dkd_checksum2; + uchar_t dkd_checksum1; + uchar_t dkd_checksum0; /* checksum (LSB) */ +}; + +#define DKD_GETCHKSUM(dkd) ((dkd)->dkd_checksum3 << 24) + \ + ((dkd)->dkd_checksum2 << 16) + \ + ((dkd)->dkd_checksum1 << 8) + \ + ((dkd)->dkd_checksum0) + +#define DKD_FORMCHKSUM(c, dkd) (dkd)->dkd_checksum3 = hibyte(hiword((c))); \ + (dkd)->dkd_checksum2 = lobyte(hiword((c))); \ + (dkd)->dkd_checksum1 = hibyte(loword((c))); \ + (dkd)->dkd_checksum0 = lobyte(loword((c))); +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DKLABEL_H */ diff --git a/illumos-x86_64/usr/include/sys/dktp/altsctr.h b/illumos-x86_64/usr/include/sys/dktp/altsctr.h new file mode 100644 index 00000000..7d8fc0b4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dktp/altsctr.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +/* + * (c) Copyright INTERACTIVE Systems Corporation 1986, 1988, 1990 + * All rights reserved. + */ + +#ifndef _SYS_DKTP_ALTSCTR_H +#define _SYS_DKTP_ALTSCTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* alternate sector partition information table */ +struct alts_parttbl { + uint32_t alts_sanity; /* to validate correctness */ + uint32_t alts_version; /* version number */ + uint32_t alts_map_base; /* disk offset of alts_partmap */ + uint32_t alts_map_len; /* byte length of alts_partmap */ + uint32_t alts_ent_base; /* disk offset of alts_entry */ + uint32_t alts_ent_used; /* number of alternate entries used */ + uint32_t alts_ent_end; /* disk offset of top of alts_entry */ + uint32_t alts_resv_base; /* disk offset of alts_reserved */ + uint32_t alts_pad[5]; /* reserved fields */ +}; + +/* alternate sector remap entry table */ +struct alts_ent { + uint32_t bad_start; /* starting bad sector number */ + uint32_t bad_end; /* ending bad sector number */ + uint32_t good_start; /* starting alternate sector to use */ +}; + +/* size of alternate partition table structure */ +#define ALTS_PARTTBL_SIZE sizeof (struct alts_parttbl) +/* size of alternate entry table structure */ +#define ALTS_ENT_SIZE sizeof (struct alts_ent) + +/* definition for alternate sector partition sector map */ +#define ALTS_GOOD 0 /* good alternate sectors */ +#define ALTS_BAD 1 /* bad alternate sectors */ + +/* definition for alternate sector partition id */ +#define ALTS_SANITY 0xaabbccdd /* magic number to validate alts_part */ +#define ALTS_VERSION1 0x01 /* version of alts_parttbl */ + +#define ALTS_ENT_EMPTY -1 /* empty alternate entry */ +#define ALTS_MAP_UP 1 /* search forward with increasing sect# */ +#define ALTS_MAP_DOWN -1 /* search backward with decreasing sect# */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DKTP_ALTSCTR_H */ diff --git a/illumos-x86_64/usr/include/sys/dktp/cmpkt.h b/illumos-x86_64/usr/include/sys/dktp/cmpkt.h new file mode 100644 index 00000000..5302e395 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dktp/cmpkt.h @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_DKTP_CMPKT_H +#define _SYS_DKTP_CMPKT_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct cmpkt { + opaque_t cp_objp; /* ptr to generic ctlr object */ + opaque_t cp_ctl_private; /* ptr to controller private */ + opaque_t cp_dev_private; /* ptr to device driver private */ + + int cp_scblen; /* len of status control blk */ + opaque_t cp_scbp; /* status control blk */ + int cp_cdblen; /* len of cmd description blk */ + opaque_t cp_cdbp; /* command description blk */ + long cp_reason; /* error status */ + void (*cp_callback)(); /* callback function */ + long cp_time; /* timeout values */ + long cp_flags; + + struct buf *cp_bp; /* link to buf structure */ + long cp_resid; /* data bytes not transferred */ + long cp_byteleft; /* remaining bytes to do */ + + /* for a particular disk section */ + long cp_bytexfer; /* bytes xfer in this operation */ + + daddr_t cp_srtsec; /* starting sector number */ + long cp_secleft; /* # of sectors remains */ + + ushort_t cp_retry; /* retry count */ + ushort_t cp_resv; + + void (*cp_iodone)(); /* target driver iodone() */ + struct cmpkt *cp_fltpktp; /* fault recovery pkt pointer */ + opaque_t cp_private; + opaque_t cp_passthru; /* pass through command ptr */ +}; + +/* reason code for completion status */ +#define CPS_SUCCESS 0 /* command completes with no err */ +#define CPS_FAILURE 1 /* command fails */ +#define CPS_CHKERR 2 /* command fails with status */ +#define CPS_ABORTED 3 /* command aborted */ + +/* flags definitions */ +#define CPF_NOINTR 0x0001 /* polling mode */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DKTP_CMPKT_H */ diff --git a/illumos-x86_64/usr/include/sys/dktp/dadkio.h b/illumos-x86_64/usr/include/sys/dktp/dadkio.h new file mode 100644 index 00000000..5b35fbda --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dktp/dadkio.h @@ -0,0 +1,236 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DKTP_DADKIO_H +#define _SYS_DKTP_DADKIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* direct coupled disk driver ioctl command */ +#define DIOCTL_GETGEOM 1 /* get logical disk geometry */ +#define DIOCTL_GETPHYGEOM 2 /* get physical disk geometry */ +#define DIOCTL_GETMODEL 3 /* get model number */ +#define DIOCTL_GETSERIAL 4 /* get serial number */ +#define DIOCTL_RWCMD 5 /* read/write a disk */ +#define DIOCTL_GETWCE 6 /* get write cache enabled state */ + +#if !defined(BLKADDR_TYPE) +#define BLKADDR_TYPE +#if defined(_EXTVTOC) +typedef unsigned long blkaddr_t; +typedef unsigned int blkaddr32_t; +#else +typedef daddr_t blkaddr_t; +typedef daddr32_t blkaddr32_t; +#endif +#endif + +/* + * arg structure for DIOCTL_GETMODEL and DIOCTL_GETSERIAL + * On input to the ioctl, is_size contains the size of the buffer + * pointed to by is_buf; + * On return, is_size contains the number of characters needed to + * represent the string. This may be more than the input value, in + * which case the caller can choose to + * 1. Use the truncated string as is + * 2. Allocate a buffer of is_size+1 bytes to hold the string + */ +#ifdef _SYSCALL32 +typedef struct dadk_ioc_string32 +{ + caddr32_t is_buf; /* pointer to character array */ + int is_size; /* string length */ +} dadk_ioc_string32_t; +#endif /* _SYSCALL32 */ + +typedef struct dadk_ioc_string +{ + caddr_t is_buf; /* pointer to character array */ + int is_size; /* string length */ +} dadk_ioc_string_t; + +/* direct coupled disk driver command */ +#define DCMD_READ 1 /* Read Sectors/Blocks */ +#define DCMD_WRITE 2 /* Write Sectors/Blocks */ +#define DCMD_FMTTRK 3 /* Format Tracks */ +#define DCMD_FMTDRV 4 /* Format entire drive */ +#define DCMD_RECAL 5 /* Recalibrate */ +#define DCMD_SEEK 6 /* Seek to Cylinder */ +#define DCMD_RDVER 7 /* Read Verify sectors on disk */ +#define DCMD_GETDEF 8 /* Read manufacturers defect list */ +/* cd-rom commands */ +#define DCMD_LOCK 9 /* Lock door */ +#define DCMD_UNLOCK 10 /* Unlock door */ +#define DCMD_START_MOTOR 11 /* Start motor */ +#define DCMD_STOP_MOTOR 12 /* Stop motor */ +#define DCMD_EJECT 13 /* Eject medium */ +#define DCMD_UPDATE_GEOM 14 /* Update geometry */ +#define DCMD_GET_STATE 15 /* Get removable disk status */ +#define DCMD_PAUSE 16 /* cdrom pause */ +#define DCMD_RESUME 17 /* cdrom resume */ +#define DCMD_PLAYTRKIND 18 /* cdrom play by track and index */ +#define DCMD_PLAYMSF 19 /* cdrom play msf */ +#define DCMD_SUBCHNL 20 /* cdrom sub channel */ +#define DCMD_READMODE1 21 /* cdrom read mode 1 */ +#define DCMD_READTOCHDR 22 /* cdrom read table of contents header */ +#define DCMD_READTOCENT 23 /* cdrom read table of contents entry */ +#define DCMD_READOFFSET 24 /* cdrom read offset */ +#define DCMD_READMODE2 25 /* cdrom mode 2 */ +#define DCMD_VOLCTRL 26 /* cdrom volume control */ +/* additional disk commands */ +#define DCMD_FLUSH_CACHE 27 /* flush write cache to physical medium */ + +/* driver error code */ +#define DERR_SUCCESS 0 /* success */ +#define DERR_AMNF 1 /* address mark not found */ +#define DERR_TKONF 2 /* track 0 not found */ +#define DERR_ABORT 3 /* aborted command */ +#define DERR_DWF 4 /* write fault */ +#define DERR_IDNF 5 /* ID not found */ +#define DERR_BUSY 6 /* drive busy */ +#define DERR_UNC 7 /* uncorrectable data error */ +#define DERR_BBK 8 /* bad block detected */ +#define DERR_INVCDB 9 /* invalid cdb */ +#define DERR_HARD 10 /* hard device error - no retry */ +/* + * atapi additional error codes + */ +#define DERR_ILI 11 /* Illegal length indication */ +#define DERR_EOM 12 /* End of media detected */ +#define DERR_MCR 13 /* Media change requested */ +/* + * atapi (SCSI) sense key errors + */ +#define DERR_RECOVER 14 /* Recovered from error */ +#define DERR_NOTREADY 15 /* Device not ready */ +#define DERR_MEDIUM 16 /* Medium error */ +#define DERR_HW 17 /* Hardware error */ +#define DERR_ILL 18 /* Illegal request */ +#define DERR_UNIT_ATTN 19 /* Unit attention */ +#define DERR_DATA_PROT 20 /* Data protection */ +#define DERR_MISCOMP 21 /* Miscompare */ +#define DERR_ICRC 22 /* Interface CRC error -- new driver */ + /* error code in ATA-4 and newer */ +#define DERR_RESV 23 /* Reserved */ + +struct dadkio_derr { + int d_action; + int d_severity; +}; + +/* + * dadkio_rwcmd cmd + */ + +#define DADKIO_RWCMD_READ 1 /* read command */ +#define DADKIO_RWCMD_WRITE 2 /* write command */ + +/* + * dadkio_rwcmd flags + */ +#define DADKIO_FLAG_SILENT 0x01 /* driver should not */ + /* generate any warning */ + /* or error console msgs */ +#define DADKIO_FLAG_RESERVED 0x02 /* reserved/not used */ + + +#define DADKIO_ERROR_INFO_LEN 128 + +/* + * dadkio_status status value. + */ +struct dadkio_status { + int status; + ulong_t resid; + int failed_blk_is_valid; + blkaddr_t failed_blk; + int fru_code_is_valid; + int fru_code; + char add_error_info[DADKIO_ERROR_INFO_LEN]; +}; + +#ifdef _SYSCALL32 +struct dadkio_status32 { + int status; + uint32_t resid; + int failed_blk_is_valid; + blkaddr32_t failed_blk; + int fru_code_is_valid; + int fru_code; + char add_error_info[DADKIO_ERROR_INFO_LEN]; +}; +#endif /* _SYSCALL32 */ + +/* + * Used by read/write ioctl (DKIOCTL_RWCMD) + */ +struct dadkio_rwcmd { + int cmd; + int flags; + blkaddr_t blkaddr; + uint_t buflen; + caddr_t bufaddr; + struct dadkio_status status; +}; + +#ifdef _SYSCALL32 +struct dadkio_rwcmd32 { + int cmd; + int flags; + blkaddr32_t blkaddr; + uint_t buflen; + caddr32_t bufaddr; + struct dadkio_status32 status; +}; +#endif /* _SYSCALL32 */ + +/* + * dadkio_status status values + */ +#define DADKIO_STAT_NO_ERROR 0 /* cmd was successful */ +#define DADKIO_STAT_NOT_READY 1 /* device not ready */ +#define DADKIO_STAT_MEDIUM_ERROR 2 /* error on medium */ +#define DADKIO_STAT_HARDWARE_ERROR 3 /* other hardware error */ +#define DADKIO_STAT_ILLEGAL_REQUEST 4 /* illegal request */ +#define DADKIO_STAT_ILLEGAL_ADDRESS 5 /* illegal block address */ +#define DADKIO_STAT_WRITE_PROTECTED 6 /* device write-protected */ +#define DADKIO_STAT_TIMED_OUT 7 /* no response from device */ +#define DADKIO_STAT_PARITY 8 /* parity error in data */ +#define DADKIO_STAT_BUS_ERROR 9 /* error on bus */ +#define DADKIO_STAT_SOFT_ERROR 10 /* data recovered via ECC */ +#define DADKIO_STAT_NO_RESOURCES 11 /* no resources for cmd */ +#define DADKIO_STAT_NOT_FORMATTED 12 /* device is not formatted */ +#define DADKIO_STAT_RESERVED 13 /* device is reserved */ +#define DADKIO_STAT_NOT_SUPPORTED 14 /* feature not supported */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DKTP_DADKIO_H */ diff --git a/illumos-x86_64/usr/include/sys/dktp/fdisk.h b/illumos-x86_64/usr/include/sys/dktp/fdisk.h new file mode 100644 index 00000000..e90135f3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dktp/fdisk.h @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1984, 1986, 1987, 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_DKTP_FDISK_H +#define _SYS_DKTP_FDISK_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * fdisk.h + * This file defines the structure of physical disk sector 0 for use on + * AT386 systems. The format of this sector is constrained by the ROM + * BIOS and MS-DOS conventions. + * Note that this block does not define the partitions used by the unix + * driver. The unix partitions are obtained from the VTOC. + */ + +/* + * the MAX values are the maximum usable values for BIOS chs values + * The MAX_CYL value of 1022 is the maximum usable value + * the value of 1023 is a fence value, + * indicating no CHS geometry exists for the corresponding LBA value. + * HEAD range [ 0 .. MAX_HEAD ], so number of heads is (MAX_HEAD + 1) + * SECT range [ 1 .. MAX_SECT ], so number of sectors is (MAX_SECT) + */ +#define MAX_SECT (63) +#define MAX_CYL (1022) +#define MAX_HEAD (254) + +/* + * BOOTSZ was reduced from 446 to 440 bytes to NOT overwrite the Windows + * Vista DISKID. Otherwise Vista won't boot from Solaris GRUB in a dual-boot + * setup. + * The actual size of mboot code is 425 bytes while that of GRUB stage1 is + * 423 bytes. So this changes does not harm them. + */ +#define BOOTSZ 440 /* size of boot code in master boot block */ +#define FD_NUMPART 4 /* number of 'partitions' in fdisk table */ +#define MBB_MAGIC 0xAA55 /* magic number for mboot.signature */ +#define DEFAULT_INTLV 4 /* default interleave for testing tracks */ +#define MINPSIZE 4 /* minimum number of cylinders in a partition */ +#define TSTPAT 0xE5 /* test pattern for verifying disk */ + +/* + * structure to hold the fdisk partition table + */ +struct ipart { + unsigned char bootid; /* bootable or not */ + unsigned char beghead; /* beginning head, sector, cylinder */ + unsigned char begsect; /* begcyl is a 10-bit number. High 2 bits */ + unsigned char begcyl; /* are in begsect. */ + unsigned char systid; /* OS type */ + unsigned char endhead; /* ending head, sector, cylinder */ + unsigned char endsect; /* endcyl is a 10-bit number. High 2 bits */ + unsigned char endcyl; /* are in endsect. */ + uint32_t relsect; /* first sector relative to start of disk */ + uint32_t numsect; /* number of sectors in partition */ +}; +/* + * Values for bootid. + */ +#define NOTACTIVE 0 +#define ACTIVE 128 +/* + * Values for systid. + */ +#define UNUSED 0 /* Empty Partition */ +#define DOSOS12 1 /* DOS partition, 12-bit FAT */ +#define PCIXOS 2 /* PC/IX partition */ +#define DOSOS16 4 /* DOS partition, 16-bit FAT */ +#define EXTDOS 5 /* EXT-DOS partition */ +#define DOSHUGE 6 /* Huge DOS partition > 32MB */ +#define FDISK_IFS 7 /* Installable File System (IFS): HPFS & NTFS */ +#define FDISK_AIXBOOT 8 /* AIX Boot */ +#define FDISK_AIXDATA 9 /* AIX Data */ +#define FDISK_OS2BOOT 10 /* OS/2 Boot Manager */ +#define FDISK_WINDOWS 11 /* Windows 95 FAT32 (up to 2047GB) */ +#define FDISK_EXT_WIN 12 /* Windows 95 FAT32 (extended-INT13) */ +#define FDISK_FAT95 14 /* DOS 16-bit FAT, LBA-mapped */ +#define FDISK_EXTLBA 15 /* Extended partition, LBA-mapped */ +#define DIAGPART 18 /* Diagnostic boot partition (OS independent) */ +#define FDISK_LINUX 65 /* Linux */ +#define FDISK_LINUXDSWAP 66 /* Linux swap (sharing disk w/ DRDOS) */ +#define FDISK_LINUXDNAT 67 /* Linux native (sharing disk with DRDOS) */ +#define FDISK_CPM 82 /* CP/M */ +#define DOSDATA 86 /* DOS data partition */ +#define OTHEROS 98 /* part. type for appl. (DB?) needs */ + /* raw partition. ID was 0 but conflicted */ + /* with DOS 3.3 fdisk */ +#define UNIXOS 99 /* UNIX V.x partition */ +#define FDISK_NOVELL2 100 /* Novell Netware 286 */ +#define FDISK_NOVELL3 101 /* Novell Netware 3.x and later */ +#define FDISK_QNX4 119 /* QNX 4.x */ +#define FDISK_QNX42 120 /* QNX 4.x 2nd part */ +#define FDISK_QNX43 121 /* QNX 4.x 3rd part */ +#define SUNIXOS 130 /* Solaris UNIX partition */ +#define FDISK_LINUXNAT 131 /* Linux native */ +#define FDISK_NTFSVOL1 134 /* NTFS volume set 1 */ +#define FDISK_NTFSVOL2 135 /* NTFS volume set 2 */ +#define FDISK_BSD 165 /* BSD/386, 386BSD, NetBSD, FreeBSD, OpenBSD */ +#define FDISK_NEXTSTEP 167 /* NeXTSTEP */ +#define FDISK_BSDIFS 183 /* BSDI file system */ +#define FDISK_BSDISWAP 184 /* BSDI swap */ +#define X86BOOT 190 /* x86 Solaris boot partition */ +#define SUNIXOS2 191 /* Solaris UNIX partition */ +#define EFI_PMBR 238 /* EFI PMBR */ +#define EFI_FS 239 /* EFI File System (System Partition) */ +#define MAXDOS 65535L /* max size (sectors) for DOS partition */ + +/* + * structure to hold master boot block in physical sector 0 of the disk. + * Note that partitions stuff can't be directly included in the structure + * because of lameo '386 compiler alignment design. + * Alignment issues also force us to have 2 16bit entities for a single + * 32bit win_volserno. It is not used anywhere anyway. + */ + +struct mboot { /* master boot block */ + char bootinst[BOOTSZ]; + uint16_t win_volserno_lo; + uint16_t win_volserno_hi; + uint16_t reserved; + char parts[FD_NUMPART * sizeof (struct ipart)]; + ushort_t signature; +}; + +#if defined(__i386) || defined(__amd64) + +/* Byte offset of the start of the partition table within the sector */ +#define FDISK_PART_TABLE_START 446 + +/* Maximum number of valid partitions assumed as 32 */ +#define MAX_EXT_PARTS 32 + +#else + +#define MAX_EXT_PARTS 0 + +#endif /* if defined(__i386) || defined(__amd64) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DKTP_FDISK_H */ diff --git a/illumos-x86_64/usr/include/sys/dl.h b/illumos-x86_64/usr/include/sys/dl.h new file mode 100644 index 00000000..c6099b8c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dl.h @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_DL_H +#define _SYS_DL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct dl { +#ifdef _LONG_LONG_LTOH + uint_t dl_lop; + int dl_hop; +#else + int dl_hop; + uint_t dl_lop; +#endif +} dl_t; + +extern dl_t ladd(dl_t, dl_t); +extern dl_t lsub(dl_t, dl_t); +extern dl_t lmul(dl_t, dl_t); +extern dl_t ldivide(dl_t, dl_t); +extern dl_t lshiftl(dl_t, int); +extern dl_t llog10(dl_t); +extern dl_t lexp10(dl_t); + +extern dl_t lzero; +extern dl_t lone; +extern dl_t lten; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DL_H */ diff --git a/illumos-x86_64/usr/include/sys/dld.h b/illumos-x86_64/usr/include/sys/dld.h new file mode 100644 index 00000000..de7ac46d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dld.h @@ -0,0 +1,466 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2017, Joyent, Inc. + */ + +#ifndef _SYS_DLD_H +#define _SYS_DLD_H + +/* + * Data-Link Driver ioctl interfaces. + * + * Note that the data structures defined here define an ioctl interface + * that is shared betwen user and kernel space. The dld driver thus + * assumes that the structures have identical layout and size when + * compiled in either IPL32 or LP64. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Data-Link Driver Information (text emitted by modinfo(8)) + */ +#define DLD_INFO "Data-Link Driver" + +/* + * Options: To enable an option set the property name to a non-zero value + * in kernel/drv/dld.conf. + */ + +/* + * Prevent use of the IP fast-path (direct M_DATA transmit). + */ +#define DLD_PROP_NO_FASTPATH "no-fastpath" + +/* + * Prevent advertising of the DL_CAPAB_POLL capability. + */ +#define DLD_PROP_NO_POLL "no-poll" + +/* + * Prevent advertising of the DL_CAPAB_ZEROCOPY capability. + */ +#define DLD_PROP_NO_ZEROCOPY "no-zerocopy" + +/* + * Prevent advertising of the DL_CAPAB_SOFTRING capability. + */ +#define DLD_PROP_NO_SOFTRING "no-softring" + +/* + * The name of the driver. + */ +#define DLD_DRIVER_NAME "dld" + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* + * IOCTL codes and data structures. + */ +#define DLDIOC_ATTR DLDIOC(0x03) + +typedef struct dld_ioc_attr { + datalink_id_t dia_linkid; + uint_t dia_max_sdu; +} dld_ioc_attr_t; + +#define DLDIOC_VLAN_ATTR DLDIOC(0x04) +typedef struct dld_ioc_vlan_attr { + datalink_id_t div_vlanid; + uint16_t div_vid; + datalink_id_t div_linkid; + boolean_t div_force; +} dld_ioc_vlan_attr_t; + +#define DLDIOC_PHYS_ATTR DLDIOC(0x05) +#define DLPI_LINKNAME_MAX 32 + +typedef struct dld_ioc_phys_attr { + datalink_id_t dip_linkid; + /* + * Whether this physical link supports vanity naming. Note that + * physical links whose media type is not supported by GLDv3 + * can not support vanity naming. + */ + boolean_t dip_novanity; + char dip_dev[MAXLINKNAMELEN]; +} dld_ioc_phys_attr_t; + +/* + * Secure objects ioctls + */ +typedef enum { + DLD_SECOBJ_CLASS_WEP = 1, + DLD_SECOBJ_CLASS_WPA +} dld_secobj_class_t; + +#define DLD_SECOBJ_OPT_CREATE 0x00000001 +#define DLD_SECOBJ_NAME_MAX 32 +#define DLD_SECOBJ_VAL_MAX 256 +typedef struct dld_secobj { + char so_name[DLD_SECOBJ_NAME_MAX]; + dld_secobj_class_t so_class; + uint8_t so_val[DLD_SECOBJ_VAL_MAX]; + uint_t so_len; +} dld_secobj_t; + +#define DLDIOC_SECOBJ_SET DLDIOC(0x06) +typedef struct dld_ioc_secobj_set { + dld_secobj_t ss_obj; + uint_t ss_flags; +} dld_ioc_secobj_set_t; + +#define DLDIOC_SECOBJ_GET DLDIOC(0x07) +typedef struct dld_ioc_secobj_get { + dld_secobj_t sg_obj; + uint_t sg_count; + uint_t sg_size; +} dld_ioc_secobj_get_t; + +/* + * The following two slots were used outside of ON, so don't reuse them. + * + * #define DLDIOCHOLDVLAN DLDIOC(0x08) + * #define DLDIOCRELEVLAN DLDIOC(0x09) + */ + +#define DLDIOC_SECOBJ_UNSET DLDIOC(0x0a) +typedef struct dld_ioc_secobj_unset { + char su_name[DLD_SECOBJ_NAME_MAX]; +} dld_ioc_secobj_unset_t; + +#define DLDIOC_CREATE_VLAN DLDIOC(0x0b) +typedef struct dld_ioc_create_vlan { + datalink_id_t dic_vlanid; + datalink_id_t dic_linkid; + uint16_t dic_vid; + boolean_t dic_force; +} dld_ioc_create_vlan_t; + +#define DLDIOC_DELETE_VLAN DLDIOC(0x0c) +typedef struct dld_ioc_delete_vlan { + datalink_id_t did_linkid; +} dld_ioc_delete_vlan_t; + +/* + * The following constants have been removed, and the slots are open: + * + * #define DLDIOC_SETAUTOPUSH DLDIOC(0x0d) + * #define DLDIOC_GETAUTOPUSH DLDIOC(0x0e) + * #define DLDIOC_CLRAUTOPUSH DLDIOC(0x0f) + */ + +#define DLDIOC_DOORSERVER DLDIOC(0x10) +typedef struct dld_ioc_door { + boolean_t did_start_door; +} dld_ioc_door_t; + +#define DLDIOC_RENAME DLDIOC(0x11) +typedef struct dld_ioc_rename { + datalink_id_t dir_linkid1; + datalink_id_t dir_linkid2; + char dir_link[MAXLINKNAMELEN]; +} dld_ioc_rename_t; + +/* + * The following constants have been removed, and the slots are open: + * + * #define DLDIOC_SETZID DLDIOC(0x12) + * #define DLDIOC_GETZID DLDIOC(0x13) + */ + +typedef struct dld_ioc_zid { + zoneid_t diz_zid; + datalink_id_t diz_linkid; +} dld_ioc_zid_t; + +/* + * data-link autopush configuration. + */ +struct dlautopush { + uint_t dap_anchor; + uint_t dap_npush; + char dap_aplist[MAXAPUSH][FMNAMESZ+1]; +}; + +#define DLDIOC_MACADDRGET DLDIOC(0x15) +typedef struct dld_ioc_macaddrget { + datalink_id_t dig_linkid; + uint_t dig_count; + uint_t dig_size; +} dld_ioc_macaddrget_t; + +/* possible flags for dmi_flags below */ +#define DLDIOCMACADDR_USED 0x1 /* address slot used */ + +typedef struct dld_macaddrinfo { + uint_t dmi_slot; + uint_t dmi_flags; + uint_t dmi_addrlen; + uchar_t dmi_addr[MAXMACADDRLEN]; + char dmi_client_name[MAXNAMELEN]; + datalink_id_t dma_client_linkid; +} dld_macaddrinfo_t; + +/* + * IOCTL codes and data structures for flowadm. + */ +#define DLDIOC_ADDFLOW DLDIOC(0x16) +typedef struct dld_ioc_addflow { + datalink_id_t af_linkid; + flow_desc_t af_flow_desc; + mac_resource_props_t af_resource_props; + char af_name[MAXFLOWNAMELEN]; +} dld_ioc_addflow_t; + +#define DLDIOC_REMOVEFLOW DLDIOC(0x17) +typedef struct dld_ioc_removeflow { + char rf_name[MAXFLOWNAMELEN]; +} dld_ioc_removeflow_t; + +#define DLDIOC_MODIFYFLOW DLDIOC(0x18) +typedef struct dld_ioc_modifyflow { + char mf_name[MAXFLOWNAMELEN]; + mac_resource_props_t mf_resource_props; +} dld_ioc_modifyflow_t; + +#define DLDIOC_WALKFLOW DLDIOC(0x19) +typedef struct dld_ioc_walkflow { + datalink_id_t wf_linkid; + char wf_name[MAXFLOWNAMELEN]; + uint32_t wf_nflows; + uint_t wf_len; +} dld_ioc_walkflow_t; + +typedef struct dld_flowinfo { + datalink_id_t fi_linkid; + flow_desc_t fi_flow_desc; + mac_resource_props_t fi_resource_props; + char fi_flowname[MAXFLOWNAMELEN]; + uint32_t fi_pad; +} dld_flowinfo_t; + +#define DLDIOC_USAGELOG DLDIOC(0x1a) +typedef struct dld_ioc_usagelog { + mac_logtype_t ul_type; + boolean_t ul_onoff; + uint_t ul_interval; +} dld_ioc_usagelog_t; + +#define DLDIOC_SETMACPROP DLDIOC(0x1b) +#define DLDIOC_GETMACPROP DLDIOC(0x1c) + +/* pr_flags can be set to a combination of the following flags */ +#define DLD_PROP_DEFAULT 0x0001 +#define DLD_PROP_POSSIBLE 0x0002 + +typedef struct dld_ioc_macprop_s { + uint_t pr_flags; + datalink_id_t pr_linkid; + mac_prop_id_t pr_num; + uint_t pr_perm_flags; + char pr_name[MAXLINKPROPNAME]; + uint_t pr_valsize; /* sizeof pr_val */ + char pr_val[1]; +} dld_ioc_macprop_t; + +#define DLDIOC_GETHWGRP DLDIOC(0x1d) + +typedef struct dld_ioc_hwgrpget { + datalink_id_t dih_linkid; + uint_t dih_n_groups; /* number of groups included in ioc */ + uint_t dih_size; +} dld_ioc_hwgrpget_t; + +#define MAXCLIENTNAMELEN 1024 +typedef struct dld_hwgrpinfo { + char dhi_link_name[MAXLINKNAMELEN]; + uint_t dhi_grp_num; + uint_t dhi_grp_type; + uint_t dhi_n_rings; + uint_t dhi_n_clnts; + uint_t dhi_rings[MAX_RINGS_PER_GROUP]; + char dhi_clnts[MAXCLIENTNAMELEN]; +} dld_hwgrpinfo_t; + +#define DLDIOC_GETTRAN DLDIOC(0x1e) + +#define DLDIOC_GETTRAN_GETNTRAN UINT32_MAX + +typedef struct dld_ioc_gettran { + datalink_id_t dgt_linkid; + uint_t dgt_tran_id; + boolean_t dgt_present; + boolean_t dgt_usable; +} dld_ioc_gettran_t; + +#define DLDIOC_READTRAN DLDIOC(0x1f) +typedef struct dld_ioc_tranio { + datalink_id_t dti_linkid; + uint_t dti_tran_id; + uint_t dti_page; + uint_t dti_nbytes; + uint_t dti_off; + uint64_t dti_buf; +} dld_ioc_tranio_t; + +#define DLDIOC_GETLED DLDIOC(0x20) +#define DLDIOC_SETLED DLDIOC(0x21) + +typedef struct dld_ioc_led { + datalink_id_t dil_linkid; + mac_led_mode_t dil_supported; + mac_led_mode_t dil_active; + uint_t dil_pad; +} dld_ioc_led_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#ifdef _KERNEL + +#define DLD_CAPAB_DIRECT 0x00000001 +#define DLD_CAPAB_POLL 0x00000002 +#define DLD_CAPAB_PERIM 0x00000003 +#define DLD_CAPAB_LSO 0x00000004 + +#define DLD_ENABLE 0x00000001 +#define DLD_DISABLE 0x00000002 +#define DLD_QUERY 0x00000003 + +/* + * GLDv3 entry point for negotiating capabilities. + * This is exposed to IP after negotiation of DL_CAPAB_DLD. + * + * This function takes the following arguments: + * handle: used for identifying the interface to operate on (provided by dld). + * type: capability type. + * arg: points to a capability-specific structure. + * flags: used for indicating whether to enable or disable a capability. + * + * With this function, capability negotiation is reduced from a multi-step + * process to just one single function call. + * e.g. the following code would pass 'x' from IP to dld and obtain + * arg.output_arg from dld: + * + * arg.input_arg = x; + * rc = (*dld_capab)(handle, DLD_CAPAB_XXX, &arg, DLD_ENABLE); + * ill->info1 = arg.output_arg; + */ +typedef int (*dld_capab_func_t)(void *, uint_t, void *, uint_t); + +/* + * Direct Tx/Rx capability. + */ +typedef struct dld_capab_direct_s { + /* + * Rx entry point and handle, owned by IP. + */ + uintptr_t di_rx_cf; + void *di_rx_ch; + + /* + * Tx entry points and handle, owned by DLD. + */ + /* Entry point for transmitting packets */ + uintptr_t di_tx_df; + void *di_tx_dh; + + /* flow control notification callback */ + uintptr_t di_tx_cb_df; /* callback registration/de-registration */ + void *di_tx_cb_dh; + + /* flow control "can I put on a ring" callback */ + uintptr_t di_tx_fctl_df; /* canput-like callback */ + void *di_tx_fctl_dh; +} dld_capab_direct_t; + +/* + * Polling/softring capability. + */ +#define POLL_SOFTRING 0x00000001 +typedef struct dld_capab_poll_s { + uintptr_t poll_ring_add_cf; + uintptr_t poll_ring_remove_cf; + uintptr_t poll_ring_quiesce_cf; + uintptr_t poll_ring_restart_cf; + uintptr_t poll_ring_bind_cf; + void *poll_ring_ch; + uintptr_t poll_mac_accept_df; + void *poll_mac_dh; +} dld_capab_poll_t; + +/* + * LSO capability + */ +/* + * Currently supported flags for LSO. + */ +#define DLD_LSO_BASIC_TCP_IPV4 0x01 /* TCP LSO over IPv4 capability */ +#define DLD_LSO_BASIC_TCP_IPV6 0x02 /* TCP LSO over IPv6 capability */ + +typedef struct dld_capab_lso_s { + uint_t lso_flags; /* capability flags */ + uint_t lso_max_tcpv4; /* maximum TCPv4 payload */ + uint_t lso_max_tcpv6; /* maximum TCPv6 payload */ +} dld_capab_lso_t; + +int dld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); +int dld_devt_to_instance(dev_t); +int dld_open(queue_t *, dev_t *, int, int, cred_t *); +int dld_close(queue_t *, int, cred_t *); +int dld_wput(queue_t *, mblk_t *); +int dld_wsrv(queue_t *); +int dld_str_open(queue_t *, dev_t *, void *); +int dld_str_close(queue_t *); +void *dld_str_private(queue_t *); +void dld_init_ops(struct dev_ops *, const char *); +void dld_fini_ops(struct dev_ops *); +int dld_autopush(dev_t *, struct dlautopush *); + +int dld_add_flow(datalink_id_t, char *, flow_desc_t *, + mac_resource_props_t *); +int dld_remove_flow(char *); +int dld_modify_flow(char *, mac_resource_props_t *); +int dld_walk_flow(dld_ioc_walkflow_t *, intptr_t, cred_t *); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DLD_H */ diff --git a/illumos-x86_64/usr/include/sys/dlpi.h b/illumos-x86_64/usr/include/sys/dlpi.h new file mode 100644 index 00000000..97b64370 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dlpi.h @@ -0,0 +1,1623 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018 Joyent, Inc. + * Copyright 2022 Garrett D'Amore + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Data Link Provider Interface, Version 2.0 + * Refer to document: "STREAMS DLPI Spec", 800-6915-01. + */ + +#ifndef _SYS_DLPI_H +#define _SYS_DLPI_H + +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Sun additions. + */ +#define DLIOC ('D' << 8) +#define DLIOCRAW (DLIOC|1) /* M_DATA "raw" mode */ +#define DLIOCNATIVE (DLIOC|2) /* Native traffic mode */ +#define DLIOCMARGININFO (DLIOC|3) /* margin size info */ +#define DLIOCIPNETINFO (DLIOC|4) /* ipnet header */ +#define DLIOCLOWLINK (DLIOC|5) /* low-level link up/down */ +#define DLIOCHDRINFO (DLIOC|10) /* IP fast-path */ +#define DL_IOC_HDR_INFO DLIOCHDRINFO + +#define DL_IPNETINFO_VERSION 0x1 + +typedef struct dl_ipnetinfo { + uint8_t dli_version; /* DL_IPNETINFO_* version */ + uint8_t dli_family; /* packet IP header version */ + uint16_t dli_htype; + uint32_t dli_pktlen; /* length of dl_ipnetinfo_t */ + uint32_t dli_ifindex; + uint32_t dli_grifindex; + uint32_t dli_zsrc; /* packet source zone ID (if any) */ + uint32_t dli_zdst; /* packet dest zone ID (if any) */ +} dl_ipnetinfo_t; + +/* + * DLPI revision definition history + */ +#define DL_CURRENT_VERSION 0x02 /* current version of dlpi */ +#define DL_VERSION_2 0x02 /* version of dlpi March 12, 1991 */ + +/* + * Primitives for Local Management Services + */ +#define DL_INFO_REQ 0x00 /* Information Req */ +#define DL_INFO_ACK 0x03 /* Information Ack */ +#define DL_ATTACH_REQ 0x0b /* Attach a PPA */ +#define DL_DETACH_REQ 0x0c /* Detach a PPA */ +#define DL_BIND_REQ 0x01 /* Bind DLSAP address */ +#define DL_BIND_ACK 0x04 /* DLSAP address bound */ +#define DL_UNBIND_REQ 0x02 /* Unbind DLSAP address */ +#define DL_OK_ACK 0x06 /* Success acknowledgment */ +#define DL_ERROR_ACK 0x05 /* Error acknowledgment */ +#define DL_SUBS_BIND_REQ 0x1b /* Bind Subsequent DLSAP address */ +#define DL_SUBS_BIND_ACK 0x1c /* Subsequent DLSAP address bound */ +#define DL_SUBS_UNBIND_REQ 0x15 /* Subsequent unbind */ +#define DL_ENABMULTI_REQ 0x1d /* Enable multicast addresses */ +#define DL_DISABMULTI_REQ 0x1e /* Disable multicast addresses */ +#define DL_PROMISCON_REQ 0x1f /* Turn on promiscuous mode */ +#define DL_PROMISCOFF_REQ 0x20 /* Turn off promiscuous mode */ + +/* + * Solaris specific local management + */ +#define DL_NOTIFY_REQ 0x100 /* Enable notifications */ +#define DL_NOTIFY_ACK 0x101 /* Supported notifications */ +#define DL_NOTIFY_IND 0x102 /* Notification from provider */ +#define DL_AGGR_REQ 0x103 /* Enable link aggregation */ +#define DL_AGGR_IND 0x104 /* Result from link aggregation */ +#define DL_UNAGGR_REQ 0x105 /* Disable link aggregation */ +#define DL_CAPABILITY_REQ 0x110 /* Capability request */ +#define DL_CAPABILITY_ACK 0x111 /* Capability ack */ +#define DL_CONTROL_REQ 0x112 /* Device specific control request */ +#define DL_CONTROL_ACK 0x113 /* Device specific control ack */ +#define DL_PASSIVE_REQ 0x114 /* Allow access to aggregated link */ +#define DL_INTR_MODE_REQ 0x115 /* Request Rx processing in INTR mode */ +#define DL_NOTIFY_CONF 0x116 /* Notification from upstream */ + +/* + * Primitives used for Connectionless Service + */ +#define DL_UNITDATA_REQ 0x07 /* datagram send request */ +#define DL_UNITDATA_IND 0x08 /* datagram receive indication */ +#define DL_UDERROR_IND 0x09 /* datagram error indication */ +#define DL_UDQOS_REQ 0x0a /* set QOS for subsequent datagrams */ + +/* + * Primitives used for Connection-Oriented Service + */ +#define DL_CONNECT_REQ 0x0d /* Connect request */ +#define DL_CONNECT_IND 0x0e /* Incoming connect indication */ +#define DL_CONNECT_RES 0x0f /* Accept previous connect indication */ +#define DL_CONNECT_CON 0x10 /* Connection established */ + +#define DL_TOKEN_REQ 0x11 /* Passoff token request */ +#define DL_TOKEN_ACK 0x12 /* Passoff token ack */ + +#define DL_DISCONNECT_REQ 0x13 /* Disconnect request */ +#define DL_DISCONNECT_IND 0x14 /* Disconnect indication */ + +#define DL_RESET_REQ 0x17 /* Reset service request */ +#define DL_RESET_IND 0x18 /* Incoming reset indication */ +#define DL_RESET_RES 0x19 /* Complete reset processing */ +#define DL_RESET_CON 0x1a /* Reset processing complete */ + +/* + * Primitives used for Acknowledged Connectionless Service + */ + +#define DL_DATA_ACK_REQ 0x21 /* data unit transmission request */ +#define DL_DATA_ACK_IND 0x22 /* Arrival of a command PDU */ +#define DL_DATA_ACK_STATUS_IND 0x23 /* Status indication of DATA_ACK_REQ */ +#define DL_REPLY_REQ 0x24 /* Request a DLSDU from the remote */ +#define DL_REPLY_IND 0x25 /* Arrival of a command PDU */ +#define DL_REPLY_STATUS_IND 0x26 /* Status indication of REPLY_REQ */ +#define DL_REPLY_UPDATE_REQ 0x27 /* Hold a DLSDU for transmission */ +#define DL_REPLY_UPDATE_STATUS_IND 0x28 /* Status of REPLY_UPDATE req */ + +/* + * Primitives used for XID and TEST operations + */ + +#define DL_XID_REQ 0x29 /* Request to send an XID PDU */ +#define DL_XID_IND 0x2a /* Arrival of an XID PDU */ +#define DL_XID_RES 0x2b /* request to send a response XID PDU */ +#define DL_XID_CON 0x2c /* Arrival of a response XID PDU */ +#define DL_TEST_REQ 0x2d /* TEST command request */ +#define DL_TEST_IND 0x2e /* TEST response indication */ +#define DL_TEST_RES 0x2f /* TEST response */ +#define DL_TEST_CON 0x30 /* TEST Confirmation */ + +/* + * Primitives to get and set the physical address, and to get + * Statistics + */ + +#define DL_PHYS_ADDR_REQ 0x31 /* Request to get physical addr */ +#define DL_PHYS_ADDR_ACK 0x32 /* Return physical addr */ +#define DL_SET_PHYS_ADDR_REQ 0x33 /* set physical addr */ +#define DL_GET_STATISTICS_REQ 0x34 /* Request to get statistics */ +#define DL_GET_STATISTICS_ACK 0x35 /* Return statistics */ + +/* + * Invalid primitive + */ + +#define DL_PRIM_INVAL 0xffff /* Invalid DL primitive value */ + +/* + * DLPI interface states + */ +#define DL_UNATTACHED 0x04 /* PPA not attached */ +#define DL_ATTACH_PENDING 0x05 /* Waiting ack of DL_ATTACH_REQ */ +#define DL_DETACH_PENDING 0x06 /* Waiting ack of DL_DETACH_REQ */ +#define DL_UNBOUND 0x00 /* PPA attached */ +#define DL_BIND_PENDING 0x01 /* Waiting ack of DL_BIND_REQ */ +#define DL_UNBIND_PENDING 0x02 /* Waiting ack of DL_UNBIND_REQ */ +#define DL_IDLE 0x03 /* DLSAP bound, awaiting use */ +#define DL_UDQOS_PENDING 0x07 /* Waiting ack of DL_UDQOS_REQ */ +#define DL_OUTCON_PENDING 0x08 /* awaiting DL_CONN_CON */ +#define DL_INCON_PENDING 0x09 /* awaiting DL_CONN_RES */ +#define DL_CONN_RES_PENDING 0x0a /* Waiting ack of DL_CONNECT_RES */ +#define DL_DATAXFER 0x0b /* connection-oriented data transfer */ +#define DL_USER_RESET_PENDING 0x0c /* awaiting DL_RESET_CON */ +#define DL_PROV_RESET_PENDING 0x0d /* awaiting DL_RESET_RES */ +#define DL_RESET_RES_PENDING 0x0e /* Waiting ack of DL_RESET_RES */ +#define DL_DISCON8_PENDING 0x0f /* Waiting ack of DL_DISC_REQ */ +#define DL_DISCON9_PENDING 0x10 /* Waiting ack of DL_DISC_REQ */ +#define DL_DISCON11_PENDING 0x11 /* Waiting ack of DL_DISC_REQ */ +#define DL_DISCON12_PENDING 0x12 /* Waiting ack of DL_DISC_REQ */ +#define DL_DISCON13_PENDING 0x13 /* Waiting ack of DL_DISC_REQ */ +#define DL_SUBS_BIND_PND 0x14 /* Waiting ack of DL_SUBS_BIND_REQ */ +#define DL_SUBS_UNBIND_PND 0x15 /* Waiting ack of DL_SUBS_UNBIND_REQ */ + + +/* + * DL_ERROR_ACK error return values + */ +#define DL_ACCESS 0x02 /* Improper permissions for request */ +#define DL_BADADDR 0x01 /* DLSAP addr in improper format or invalid */ +#define DL_BADCORR 0x05 /* Seq number not from outstand DL_CONN_IND */ +#define DL_BADDATA 0x06 /* User data exceeded provider limit */ +#define DL_BADPPA 0x08 /* Specified PPA was invalid */ +#define DL_BADPRIM 0x09 /* Primitive received not known by provider */ +#define DL_BADQOSPARAM 0x0a /* QOS parameters contained invalid values */ +#define DL_BADQOSTYPE 0x0b /* QOS structure type is unknown/unsupported */ +#define DL_BADSAP 0x00 /* Bad LSAP selector */ +#define DL_BADTOKEN 0x0c /* Token used not an active stream */ +#define DL_BOUND 0x0d /* Attempted second bind with dl_max_conind */ +#define DL_INITFAILED 0x0e /* Physical Link initialization failed */ +#define DL_NOADDR 0x0f /* Provider couldn't allocate alt. address */ +#define DL_NOTINIT 0x10 /* Physical Link not initialized */ +#define DL_OUTSTATE 0x03 /* Primitive issued in improper state */ +#define DL_SYSERR 0x04 /* UNIX system error occurred */ +#define DL_UNSUPPORTED 0x07 /* Requested serv. not supplied by provider */ +#define DL_UNDELIVERABLE 0x11 /* Previous data unit could not be delivered */ +#define DL_NOTSUPPORTED 0x12 /* Primitive is known but not supported */ +#define DL_TOOMANY 0x13 /* limit exceeded */ +#define DL_NOTENAB 0x14 /* Promiscuous mode not enabled */ +#define DL_BUSY 0x15 /* Other streams for PPA in post-attached */ + +#define DL_NOAUTO 0x16 /* Automatic handling XID&TEST not supported */ +#define DL_NOXIDAUTO 0x17 /* Automatic handling of XID not supported */ +#define DL_NOTESTAUTO 0x18 /* Automatic handling of TEST not supported */ +#define DL_XIDAUTO 0x19 /* Automatic handling of XID response */ +#define DL_TESTAUTO 0x1a /* Automatic handling of TEST response */ +#define DL_PENDING 0x1b /* pending outstanding connect indications */ + +/* + * DLPI media types supported + */ +#define DL_CSMACD 0x0 /* IEEE 802.3 CSMA/CD network */ +#define DL_TPB 0x1 /* IEEE 802.4 Token Passing Bus */ +#define DL_TPR 0x2 /* IEEE 802.5 Token Passing Ring */ +#define DL_METRO 0x3 /* IEEE 802.6 Metro Net */ +#define DL_ETHER 0x4 /* Ethernet Bus */ +#define DL_HDLC 0x05 /* ISO HDLC protocol support */ +#define DL_CHAR 0x06 /* Character Synchronous protocol support */ +#define DL_CTCA 0x07 /* IBM Channel-to-Channel Adapter */ +#define DL_FDDI 0x08 /* Fiber Distributed data interface */ +#define DL_FC 0x10 /* Fibre Channel interface */ +#define DL_ATM 0x11 /* ATM */ +#define DL_IPATM 0x12 /* ATM Classical IP interface */ +#define DL_X25 0x13 /* X.25 LAPB interface */ +#define DL_ISDN 0x14 /* ISDN interface */ +#define DL_HIPPI 0x15 /* HIPPI interface */ +#define DL_100VG 0x16 /* 100 Based VG Ethernet */ +#define DL_100VGTPR 0x17 /* 100 Based VG Token Ring */ +#define DL_ETH_CSMA 0x18 /* ISO 8802/3 and Ethernet */ +#define DL_100BT 0x19 /* 100 Base T */ +#define DL_IB 0x1a /* Infiniband */ +#define DL_FRAME 0x0a /* Frame Relay LAPF */ +#define DL_MPFRAME 0x0b /* Multi-protocol over Frame Relay */ +#define DL_ASYNC 0x0c /* Character Asynchronous Protocol */ +#define DL_IPX25 0x0d /* X.25 Classical IP interface */ +#define DL_LOOP 0x0e /* software loopback */ +#define DL_OTHER 0x09 /* Any other medium not listed above */ +/* + * Private media types. These must be above the value 0x80000000 as + * stated in the DLPI specification. NOTE: The SUNW_ prefix is used + * to denote synthetic DLPI types that are internal to the stack. + */ +#define DL_IPV4 0x80000001ul /* IPv4 Tunnel Link */ +#define DL_IPV6 0x80000002ul /* IPv6 Tunnel Link */ +#define SUNW_DL_VNI 0x80000003ul /* Virtual network interface */ +#define DL_WIFI 0x80000004ul /* IEEE 802.11 */ +#define DL_IPNET 0x80000005ul /* ipnet(4D) link */ +#define SUNW_DL_IPMP 0x80000006ul /* IPMP stub interface */ +#define DL_6TO4 0x80000007ul /* 6to4 Tunnel Link */ + +/* + * DLPI provider service supported. + * These must be allowed to be bitwise-OR for dl_service_mode in + * DL_INFO_ACK. + */ +#define DL_CODLS 0x01 /* support connection-oriented service */ +#define DL_CLDLS 0x02 /* support connectionless data link service */ +#define DL_ACLDLS 0x04 /* support acknowledged connectionless serv. */ + + +/* + * DLPI provider style. + * The DLPI provider style which determines whether a provider + * requires a DL_ATTACH_REQ to inform the provider which PPA + * user messages should be sent/received on. + */ +#define DL_STYLE1 0x0500 /* PPA is implicitly bound by open(2) */ +#define DL_STYLE2 0x0501 /* PPA must be expl. bound via DL_ATTACH_REQ */ + + +/* + * DLPI Originator for Disconnect and Resets + */ +#define DL_PROVIDER 0x0700 +#define DL_USER 0x0701 + +/* + * DLPI Disconnect Reasons + */ +#define DL_CONREJ_DEST_UNKNOWN 0x0800 +#define DL_CONREJ_DEST_UNREACH_PERMANENT 0x0801 +#define DL_CONREJ_DEST_UNREACH_TRANSIENT 0x0802 +#define DL_CONREJ_QOS_UNAVAIL_PERMANENT 0x0803 +#define DL_CONREJ_QOS_UNAVAIL_TRANSIENT 0x0804 +#define DL_CONREJ_PERMANENT_COND 0x0805 +#define DL_CONREJ_TRANSIENT_COND 0x0806 +#define DL_DISC_ABNORMAL_CONDITION 0x0807 +#define DL_DISC_NORMAL_CONDITION 0x0808 +#define DL_DISC_PERMANENT_CONDITION 0x0809 +#define DL_DISC_TRANSIENT_CONDITION 0x080a +#define DL_DISC_UNSPECIFIED 0x080b + +/* + * DLPI Reset Reasons + */ +#define DL_RESET_FLOW_CONTROL 0x0900 +#define DL_RESET_LINK_ERROR 0x0901 +#define DL_RESET_RESYNCH 0x0902 + +/* + * DLPI status values for acknowledged connectionless data transfer + */ +#define DL_CMD_MASK 0x0f /* mask for command portion of status */ +#define DL_CMD_OK 0x00 /* Command Accepted */ +#define DL_CMD_RS 0x01 /* Unimplemented or inactivated service */ +#define DL_CMD_UE 0x05 /* Data Link User interface error */ +#define DL_CMD_PE 0x06 /* Protocol error */ +#define DL_CMD_IP 0x07 /* Permanent implementation dependent error */ +#define DL_CMD_UN 0x09 /* Resources temporarily unavailable */ +#define DL_CMD_IT 0x0f /* Temporary implementation dependent error */ +#define DL_RSP_MASK 0xf0 /* mask for response portion of status */ +#define DL_RSP_OK 0x00 /* Response DLSDU present */ +#define DL_RSP_RS 0x10 /* Unimplemented or inactivated service */ +#define DL_RSP_NE 0x30 /* Response DLSDU never submitted */ +#define DL_RSP_NR 0x40 /* Response DLSDU not requested */ +#define DL_RSP_UE 0x50 /* Data Link User interface error */ +#define DL_RSP_IP 0x70 /* Permanent implementation dependent error */ +#define DL_RSP_UN 0x90 /* Resources temporarily unavailable */ +#define DL_RSP_IT 0xf0 /* Temporary implementation dependent error */ + +/* + * Service Class values for acknowledged connectionless data transfer + */ +#define DL_RQST_RSP 0x01 /* Use acknowledge capability in MAC sublayer */ +#define DL_RQST_NORSP 0x02 /* No acknowledgement service requested */ + +/* + * DLPI address type definition + */ +#define DL_FACT_PHYS_ADDR 0x01 /* factory physical address */ +#define DL_CURR_PHYS_ADDR 0x02 /* current physical address */ +#define DL_IPV6_TOKEN 0x03 /* IPv6 interface token */ +#define DL_IPV6_LINK_LAYER_ADDR 0x04 /* Neighbor Discovery format */ +#define DL_CURR_DEST_ADDR 0x05 /* current destination address */ + +/* + * DLPI flag definitions + */ +#define DL_POLL_FINAL 0x01 /* indicates poll/final bit set */ + +/* + * XID and TEST responses supported by the provider + */ +#define DL_AUTO_XID 0x01 /* provider will respond to XID */ +#define DL_AUTO_TEST 0x02 /* provider will respond to TEST */ + +/* + * Subsequent bind type + */ +#define DL_PEER_BIND 0x01 /* subsequent bind on a peer addr */ +#define DL_HIERARCHICAL_BIND 0x02 /* subs_bind on a hierarchical addr */ + +/* + * DLPI promiscuous mode definitions + */ +#define DL_PROMISC_PHYS 0x01 /* promiscuous mode at phys level */ +#define DL_PROMISC_SAP 0x02 /* promiscuous mode at sap level */ +#define DL_PROMISC_MULTI 0x03 /* promiscuous mode for multicast */ +#define DL_PROMISC_RX_ONLY 0x04 /* above only enabled for rx */ +#define DL_PROMISC_FIXUPS 0x05 /* above will be fixed up */ + +/* + * DLPI notification codes for DL_NOTIFY_REQ primitives. + * Bit-wise distinct since DL_NOTIFY_REQ and DL_NOTIFY_ACK carry multiple + * notification codes. + */ +#define DL_NOTE_PHYS_ADDR 0x0001 /* Physical address change */ +#define DL_NOTE_PROMISC_ON_PHYS 0x0002 /* DL_PROMISC_PHYS set on ppa */ +#define DL_NOTE_PROMISC_OFF_PHYS 0x0004 /* DL_PROMISC_PHYS cleared on ppa */ +#define DL_NOTE_LINK_DOWN 0x0008 /* Link down */ +#define DL_NOTE_LINK_UP 0x0010 /* Link up */ +#define DL_NOTE_AGGR_AVAIL 0x0020 /* Link aggregation is available */ +#define DL_NOTE_AGGR_UNAVAIL 0x0040 /* Link aggregation is not available */ +#define DL_NOTE_SDU_SIZE 0x0080 /* New SDU size, global or per addr */ +#define DL_NOTE_SPEED 0x0100 /* Approximate link speed */ +#define DL_NOTE_FASTPATH_FLUSH 0x0200 /* Fast Path info changes */ +#define DL_NOTE_CAPAB_RENEG 0x0400 /* Initiate capability renegotiation */ +#define DL_NOTE_REPLUMB 0x0800 /* Inform the link to replumb */ +#define DL_NOTE_ALLOWED_IPS 0x1000 /* "allowed-ips" notification */ +#define DL_NOTE_SDU_SIZE2 0x2000 /* New unicast and multicast size */ + +/* + * DLPI notification codes for DL_NOTIFY_CONF primitives. + */ +#define DL_NOTE_REPLUMB_DONE 0x0001 /* Indicate replumb has done */ + +/* + * DLPI Quality Of Service definition for use in QOS structure definitions. + * The QOS structures are used in connection establishment, DL_INFO_ACK, + * and setting connectionless QOS values. + */ + +/* + * Throughput + * + * This parameter is specified for both directions. + */ +typedef struct { + t_scalar_t dl_target_value; /* bits/second desired */ + t_scalar_t dl_accept_value; /* min. ok bits/second */ +} dl_through_t; + +/* + * transit delay specification + * + * This parameter is specified for both directions. + * expressed in milliseconds assuming a DLSDU size of 128 octets. + * The scaling of the value to the current DLSDU size is provider dependent. + */ +typedef struct { + t_scalar_t dl_target_value; /* desired value of service */ + t_scalar_t dl_accept_value; /* min. ok value of service */ +} dl_transdelay_t; + +/* + * priority specification + * priority range is 0-100, with 0 being highest value. + */ +typedef struct { + t_scalar_t dl_min; + t_scalar_t dl_max; +} dl_priority_t; + + +/* + * protection specification + * + */ +#define DL_NONE 0x0B01 /* no protection supplied */ +#define DL_MONITOR 0x0B02 /* prot. from passive monit. */ +#define DL_MAXIMUM 0x0B03 /* prot. from modification, replay, */ + /* addition, or deletion */ + +typedef struct { + t_scalar_t dl_min; + t_scalar_t dl_max; +} dl_protect_t; + + +/* + * Resilience specification + * probabilities are scaled by a factor of 10,000 with a time interval + * of 10,000 seconds. + */ +typedef struct { + t_scalar_t dl_disc_prob; /* prob. of provider init DISC */ + t_scalar_t dl_reset_prob; /* prob. of provider init RESET */ +} dl_resilience_t; + + +/* + * QOS type definition to be used for negotiation with the + * remote end of a connection, or a connectionless unitdata request. + * There are two type definitions to handle the negotiation + * process at connection establishment. The typedef dl_qos_range_t + * is used to present a range for parameters. This is used + * in the DL_CONNECT_REQ and DL_CONNECT_IND messages. The typedef + * dl_qos_sel_t is used to select a specific value for the QOS + * parameters. This is used in the DL_CONNECT_RES, DL_CONNECT_CON, + * and DL_INFO_ACK messages to define the selected QOS parameters + * for a connection. + * + * NOTE + * A DataLink provider which has unknown values for any of the fields + * will use a value of DL_UNKNOWN for all values in the fields. + * + * NOTE + * A QOS parameter value of DL_QOS_DONT_CARE informs the DLS + * provider the user requesting this value doesn't care + * what the QOS parameter is set to. This value becomes the + * least possible value in the range of QOS parameters. + * The order of the QOS parameter range is then: + * + * DL_QOS_DONT_CARE < 0 < MAXIMUM QOS VALUE + */ +#define DL_UNKNOWN -1 +#define DL_QOS_DONT_CARE -2 + +/* + * Every QOS structure has the first 4 bytes containing a type + * field, denoting the definition of the rest of the structure. + * This is used in the same manner has the dl_primitive variable + * is in messages. + * + * The following list is the defined QOS structure type values and structures. + */ +#define DL_QOS_CO_RANGE1 0x0101 /* CO QOS range struct. */ +#define DL_QOS_CO_SEL1 0x0102 /* CO QOS selection structure */ +#define DL_QOS_CL_RANGE1 0x0103 /* CL QOS range struct. */ +#define DL_QOS_CL_SEL1 0x0104 /* CL QOS selection */ + +typedef struct { + t_uscalar_t dl_qos_type; + dl_through_t dl_rcv_throughput; /* desired and accep. */ + dl_transdelay_t dl_rcv_trans_delay; /* desired and accep. */ + dl_through_t dl_xmt_throughput; + dl_transdelay_t dl_xmt_trans_delay; + dl_priority_t dl_priority; /* min and max values */ + dl_protect_t dl_protection; /* min and max values */ + t_scalar_t dl_residual_error; + dl_resilience_t dl_resilience; +} dl_qos_co_range1_t; + +typedef struct { + t_uscalar_t dl_qos_type; + t_scalar_t dl_rcv_throughput; + t_scalar_t dl_rcv_trans_delay; + t_scalar_t dl_xmt_throughput; + t_scalar_t dl_xmt_trans_delay; + t_scalar_t dl_priority; + t_scalar_t dl_protection; + t_scalar_t dl_residual_error; + dl_resilience_t dl_resilience; +} dl_qos_co_sel1_t; + +typedef struct { + t_uscalar_t dl_qos_type; + dl_transdelay_t dl_trans_delay; + dl_priority_t dl_priority; + dl_protect_t dl_protection; + t_scalar_t dl_residual_error; +} dl_qos_cl_range1_t; + +typedef struct { + t_uscalar_t dl_qos_type; + t_scalar_t dl_trans_delay; + t_scalar_t dl_priority; + t_scalar_t dl_protection; + t_scalar_t dl_residual_error; +} dl_qos_cl_sel1_t; + +union DL_qos_types { + t_uscalar_t dl_qos_type; + dl_qos_co_range1_t qos_co_range1; + dl_qos_co_sel1_t qos_co_sel1; + dl_qos_cl_range1_t qos_cl_range1; + dl_qos_cl_sel1_t qos_cl_sel1; +}; + +/* + * Solaris specific structures and definitions. + */ + +/* + * The following are the capability types and structures used by the + * the DL_CAPABILITY_REQ and DL_CAPABILITY_ACK primitives. + * + * These primitives are used both to determine the set of capabilities in + * the DLS provider and also to turn on and off specific capabilities. + * The response is a DL_CAPABILITY_ACK or DL_ERROR_ACK. + * + * DL_CAPABILITY_REQ can either be empty (i.e. dl_sub_length is zero) which + * is a request for the driver to return all capabilities. Otherwise, the + * DL_CAPABILITY_REQ contains the capabilities the DLS user wants to use and + * their settings. + * + * DL_CAPABILITY_ACK contains the capabilities that the DLS provider can + * support modified based on what was listed in the request. If a + * capability was included in the request then the information returned + * in the ack might be modified based on the information in the request. + */ + +#define DL_CAPAB_ID_WRAPPER 0x00 /* Module ID wrapper structure */ + /* dl_data is dl_capab_id_t */ +#define DL_CAPAB_HCKSUM 0x01 /* Checksum offload */ + /* dl_data is dl_capab_hcksum_t */ +#define DL_CAPAB_MDT 0x04 /* OBSOLETE, DO NOT USE */ +#define DL_CAPAB_ZEROCOPY 0x05 /* Zero-copy capability */ + /* dl_data is dl_capab_zerocopy_t */ +#define DL_CAPAB_DLD 0x06 /* dld capability */ + /* dl_data is dl_capab_dld_t */ +#define DL_CAPAB_VRRP 0x07 /* vrrp capability */ + /* dl_data is dl_capab_vrrp_t */ + +typedef struct { + t_uscalar_t dl_cap; /* capability type */ + t_uscalar_t dl_length; /* length of data following */ + /* Followed by zero or more bytes of dl_data */ +} dl_capability_sub_t; + +/* + * Module ID token to be included in new sub-capability structures. + * Access to this structure must be done through + * dlcapab{set,check}qid(). + */ +typedef struct { + t_uscalar_t mid[4]; /* private fields */ +} dl_mid_t; + +/* + * Module ID wrapper (follows dl_capability_sub_t) + */ +typedef struct { + dl_mid_t id_mid; /* module ID token */ + dl_capability_sub_t id_subcap; /* sub-capability */ +} dl_capab_id_t; + +/* + * DL_CAPAB_HCKSUM + * Used for negotiating different flavors of checksum offload + * capabilities. + */ +typedef struct { + t_uscalar_t hcksum_version; /* version of data following */ + t_uscalar_t hcksum_txflags; /* capabilities on transmit */ + dl_mid_t hcksum_mid; /* module ID */ +} dl_capab_hcksum_t; + +/* + * DL_CAPAB_HCKSUM revision definition history + */ +#define HCKSUM_CURRENT_VERSION 0x01 +#define HCKSUM_VERSION_1 0x01 + +/* + * Values for dl_txflags + */ +#define HCKSUM_ENABLE 0x01 /* Set to enable hardware checksum */ + /* capability */ +#define HCKSUM_INET_PARTIAL 0x02 /* Partial 1's complement checksum */ + /* ability for TCP/UDP packets. */ +#define HCKSUM_INET_FULL_V4 0x04 /* Full 1's complement checksum */ + /* ability for IPv4 TCP/UDP packets. */ +#define HCKSUM_INET_FULL_V6 0x08 /* Full 1's complement checksum */ + /* ability for IPv6 TCP/UDP packets. */ +#define HCKSUM_IPHDRCKSUM 0x10 /* IPv4 Header checksum offload */ + /* capability */ +#ifdef _KERNEL + +/* + * VRRP sub-capability (follows dl_capability_sub_t) + */ +typedef struct { + int vrrp_af; /* IPv4 or IPv6 */ +} dl_capab_vrrp_t; + +/* + * The DL_CAPAB_DLD capability enables the capabilities of gldv3-based drivers + * to be negotiated using a function call (dld_capab) instead of using streams. + */ +typedef struct dl_capab_dld_s { + t_uscalar_t dld_version; + t_uscalar_t dld_flags; + + /* DLD provided information */ + uintptr_t dld_capab; + uintptr_t dld_capab_handle; + dl_mid_t dld_mid; /* module ID */ +} dl_capab_dld_t; + +#define DL_CAPAB_DLD_ENABLE 0x00000001 +#define DLD_VERSION_1 1 +#define DLD_CURRENT_VERSION DLD_VERSION_1 + +#endif /* _KERNEL */ + +/* + * Zero-copy sub-capability (follows dl_capability_sub_t) + */ +typedef struct { + t_uscalar_t zerocopy_version; /* interface version */ + t_uscalar_t zerocopy_flags; /* capability flags */ + t_uscalar_t reserved[9]; /* reserved fields */ + dl_mid_t zerocopy_mid; /* module ID */ +} dl_capab_zerocopy_t; + +/* + * Zero-copy revision definition history + */ +#define ZEROCOPY_CURRENT_VERSION 0x01 +#define ZEROCOPY_VERSION_1 0x01 + +/* + * Currently supported values of zerocopy_flags + */ +#define DL_CAPAB_VMSAFE_MEM 0x01 /* Driver is zero-copy safe */ + /* wrt VM named buffers on */ + /* transmit */ + +/* + * DLPI interface primitive definitions. + * + * Each primitive is sent as a stream message. It is possible that + * the messages may be viewed as a sequence of bytes that have the + * following form without any padding. The structure definition + * of the following messages may have to change depending on the + * underlying hardware architecture and crossing of a hardware + * boundary with a different hardware architecture. + * + * Fields in the primitives having a name of the form + * dl_reserved cannot be used and have the value of + * binary zero, no bits turned on. + * + * Each message has the name defined followed by the + * stream message type (M_PROTO, M_PCPROTO, M_DATA) + */ + +/* + * LOCAL MANAGEMENT SERVICE PRIMITIVES + */ + +/* + * DL_INFO_REQ, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_INFO_REQ */ +} dl_info_req_t; + +/* + * DL_INFO_ACK, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_INFO_ACK */ + t_uscalar_t dl_max_sdu; /* Max bytes in a DLSDU */ + t_uscalar_t dl_min_sdu; /* Min bytes in a DLSDU */ + t_uscalar_t dl_addr_length; /* length of DLSAP address */ + t_uscalar_t dl_mac_type; /* type of medium supported */ + t_uscalar_t dl_reserved; /* value set to zero */ + t_uscalar_t dl_current_state; /* state of DLPI interface */ + t_scalar_t dl_sap_length; /* length of DLSAP SAP part */ + t_uscalar_t dl_service_mode; /* CO, CL or ACL */ + t_uscalar_t dl_qos_length; /* length of qos values */ + t_uscalar_t dl_qos_offset; /* offset from start of block */ + t_uscalar_t dl_qos_range_length; /* available range of qos */ + t_uscalar_t dl_qos_range_offset; /* offset from start of block */ + t_uscalar_t dl_provider_style; /* style1 or style2 */ + t_uscalar_t dl_addr_offset; /* offset of the DLSAP addr */ + t_uscalar_t dl_version; /* version number */ + t_uscalar_t dl_brdcst_addr_length; /* length of broadcast addr */ + t_uscalar_t dl_brdcst_addr_offset; /* offset from start of block */ + t_uscalar_t dl_growth; /* set to zero */ +} dl_info_ack_t; + +/* + * DL_ATTACH_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_ATTACH_REQ */ + t_uscalar_t dl_ppa; /* id of the PPA */ +} dl_attach_req_t; + +/* + * DL_DETACH_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_DETACH_REQ */ +} dl_detach_req_t; + +/* + * DL_BIND_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_BIND_REQ */ + t_uscalar_t dl_sap; /* info to identify DLSAP addr */ + t_uscalar_t dl_max_conind; /* max # of outstanding con_ind */ + uint16_t dl_service_mode; /* CO, CL or ACL */ + uint16_t dl_conn_mgmt; /* if non-zero, is con-mgmt stream */ + t_uscalar_t dl_xidtest_flg; /* auto init. of test and xid */ +} dl_bind_req_t; + +/* + * DL_BIND_ACK, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_BIND_ACK */ + t_uscalar_t dl_sap; /* DLSAP addr info */ + t_uscalar_t dl_addr_length; /* length of complete DLSAP addr */ + t_uscalar_t dl_addr_offset; /* offset from start of M_PCPROTO */ + t_uscalar_t dl_max_conind; /* allowed max. # of con-ind */ + t_uscalar_t dl_xidtest_flg; /* responses supported by provider */ +} dl_bind_ack_t; + +/* + * DL_SUBS_BIND_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_SUBS_BIND_REQ */ + t_uscalar_t dl_subs_sap_offset; /* offset of subs_sap */ + t_uscalar_t dl_subs_sap_length; /* length of subs_sap */ + t_uscalar_t dl_subs_bind_class; /* peer or hierarchical */ +} dl_subs_bind_req_t; + +/* + * DL_SUBS_BIND_ACK, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_SUBS_BIND_ACK */ + t_uscalar_t dl_subs_sap_offset; /* offset of subs_sap */ + t_uscalar_t dl_subs_sap_length; /* length of subs_sap */ +} dl_subs_bind_ack_t; + +/* + * DL_UNBIND_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_UNBIND_REQ */ +} dl_unbind_req_t; + +/* + * DL_SUBS_UNBIND_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_SUBS_UNBIND_REQ */ + t_uscalar_t dl_subs_sap_offset; /* offset of subs_sap */ + t_uscalar_t dl_subs_sap_length; /* length of subs_sap */ +} dl_subs_unbind_req_t; + +/* + * DL_OK_ACK, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_OK_ACK */ + t_uscalar_t dl_correct_primitive; /* primitive acknowledged */ +} dl_ok_ack_t; + +/* + * DL_ERROR_ACK, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_ERROR_ACK */ + t_uscalar_t dl_error_primitive; /* primitive in error */ + t_uscalar_t dl_errno; /* DLPI error code */ + t_uscalar_t dl_unix_errno; /* UNIX system error code */ +} dl_error_ack_t; + +/* + * DL_ENABMULTI_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_ENABMULTI_REQ */ + t_uscalar_t dl_addr_length; /* length of multicast address */ + t_uscalar_t dl_addr_offset; /* offset from start of M_PROTO block */ +} dl_enabmulti_req_t; + +/* + * DL_DISABMULTI_REQ, M_PROTO type + */ + +typedef struct { + t_uscalar_t dl_primitive; /* DL_DISABMULTI_REQ */ + t_uscalar_t dl_addr_length; /* length of multicast address */ + t_uscalar_t dl_addr_offset; /* offset from start of M_PROTO block */ +} dl_disabmulti_req_t; + +/* + * DL_PROMISCON_REQ, M_PROTO type + */ + +typedef struct { + t_uscalar_t dl_primitive; /* DL_PROMISCON_REQ */ + t_uscalar_t dl_level; /* physical,SAP, or ALL multicast */ +} dl_promiscon_req_t; + +/* + * DL_PROMISCOFF_REQ, M_PROTO type + */ + +typedef struct { + t_uscalar_t dl_primitive; /* DL_PROMISCOFF_REQ */ + t_uscalar_t dl_level; /* Physical,SAP, or ALL multicast */ +} dl_promiscoff_req_t; + +/* + * Primitives to get and set the Physical address + */ + +/* + * DL_PHYS_ADDR_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_PHYS_ADDR_REQ */ + t_uscalar_t dl_addr_type; /* factory or current physical addr */ +} dl_phys_addr_req_t; + +/* + * DL_PHYS_ADDR_ACK, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_PHYS_ADDR_ACK */ + t_uscalar_t dl_addr_length; /* length of the physical addr */ + t_uscalar_t dl_addr_offset; /* offset from start of block */ +} dl_phys_addr_ack_t; + +/* + * DL_SET_PHYS_ADDR_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_SET_PHYS_ADDR_REQ */ + t_uscalar_t dl_addr_length; /* length of physical addr */ + t_uscalar_t dl_addr_offset; /* offset from start of block */ +} dl_set_phys_addr_req_t; + +/* + * Primitives to get statistics + */ + +/* + * DL_GET_STATISTICS_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_GET_STATISTICS_REQ */ +} dl_get_statistics_req_t; + +/* + * DL_GET_STATISTICS_ACK, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_GET_STATISTICS_ACK */ + t_uscalar_t dl_stat_length; /* length of statistics structure */ + t_uscalar_t dl_stat_offset; /* offset from start of block */ +} dl_get_statistics_ack_t; + +/* + * Solaris specific local management service primitives + */ + +/* + * DL_NOTIFY_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_NOTIFY_REQ */ + uint32_t dl_notifications; /* Requested set of notifications */ + uint32_t dl_timelimit; /* In milliseconds */ +} dl_notify_req_t; + +/* + * DL_NOTIFY_ACK, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_NOTIFY_ACK */ + uint32_t dl_notifications; /* Supported set of notifications */ +} dl_notify_ack_t; + +/* + * DL_NOTIFY_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_NOTIFY_IND */ + uint32_t dl_notification; /* Which notification? */ + union { + uint32_t dlu_data32; /* notification specific */ + uint16_t dlu_data16[2]; /* For DL_NOTE_SDU_SIZE2 */ + } dl_dlu; +#define dl_data dl_dlu.dlu_data32 +#define dl_data1 dl_dlu.dlu_data16[0] /* Unicast MTU */ +#define dl_data2 dl_dlu.dlu_data16[1] /* Multicast MTU */ + t_uscalar_t dl_addr_length; /* length of complete DLSAP addr */ + t_uscalar_t dl_addr_offset; /* offset from start of M_PROTO */ +} dl_notify_ind_t; + +/* + * DL_NOTIFY_CONF, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_NOTIFY_CONF */ + uint32_t dl_notification; /* Which notification? */ +} dl_notify_conf_t; + +/* + * DL_AGGR_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_AGGR_REQ */ + uint32_t dl_key; /* Key identifying the group */ + uint32_t dl_port; /* Identifying the NIC */ + t_uscalar_t dl_addr_length; /* length of PHYS addr addr */ + t_uscalar_t dl_addr_offset; /* offset from start of M_PROTO */ +} dl_aggr_req_t; + +/* + * DL_AGGR_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_AGGR_IND */ + uint32_t dl_key; /* Key identifying the group */ + uint32_t dl_port; /* Identifying the NIC */ + t_uscalar_t dl_addr_length; /* length of PHYS addr */ + t_uscalar_t dl_addr_offset; /* offset from start of M_PROTO */ +} dl_aggr_ind_t; + +/* + * DL_UNAGGR_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* set to DL_UNAGGR_REQ */ + uint32_t dl_key; /* Key identifying the group */ + uint32_t dl_port; /* Identifying the NIC */ + t_uscalar_t dl_addr_length; /* length of PHYS addr */ + t_uscalar_t dl_addr_offset; /* offset from start of M_PROTO */ +} dl_unaggr_req_t; + +/* + * DL_CAPABILITY_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_CAPABILITY_REQ */ + t_uscalar_t dl_sub_offset; /* options offset */ + t_uscalar_t dl_sub_length; /* options length */ + /* Followed by a list of zero or more dl_capability_sub_t */ +} dl_capability_req_t; + +/* + * DL_CAPABILITY_ACK, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_CAPABILITY_ACK */ + t_uscalar_t dl_sub_offset; /* options offset */ + t_uscalar_t dl_sub_length; /* options length */ + /* Followed by a list of zero or more dl_capability_sub_t */ +} dl_capability_ack_t; + +/* + * DL_CONTROL_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_CONTROL_REQ */ + t_uscalar_t dl_operation; /* add/delete/purge */ + t_uscalar_t dl_type; /* e.g. AH/ESP/ ... */ + t_uscalar_t dl_key_offset; /* offset of key */ + t_uscalar_t dl_key_length; /* length of key */ + t_uscalar_t dl_data_offset; /* offset of data */ + t_uscalar_t dl_data_length; /* length of data */ +} dl_control_req_t; + +/* + * DL_CONTROL_ACK, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_CONTROL_ACK */ + t_uscalar_t dl_operation; /* add/delete/purge */ + t_uscalar_t dl_type; /* e.g. AH/ESP/ ... */ + t_uscalar_t dl_key_offset; /* offset of key */ + t_uscalar_t dl_key_length; /* length of key */ + t_uscalar_t dl_data_offset; /* offset of data */ + t_uscalar_t dl_data_length; /* length of data */ +} dl_control_ack_t; + +/* + * DL_PASSIVE_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; +} dl_passive_req_t; + +/* + * DL_INTR_MODE_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; + t_uscalar_t dl_sap; + t_uscalar_t dl_imode; /* intr mode: 0 off 1 on */ +} dl_intr_mode_req_t; + +/* + * CONNECTION-ORIENTED SERVICE PRIMITIVES + */ + +/* + * DL_CONNECT_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_CONNECT_REQ */ + t_uscalar_t dl_dest_addr_length; /* len. of DLSAP addr */ + t_uscalar_t dl_dest_addr_offset; /* offset */ + t_uscalar_t dl_qos_length; /* len. of QOS parm val */ + t_uscalar_t dl_qos_offset; /* offset */ + t_uscalar_t dl_growth; /* set to zero */ +} dl_connect_req_t; + +/* + * DL_CONNECT_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_CONNECT_IND */ + t_uscalar_t dl_correlation; /* provider's correl. token */ + t_uscalar_t dl_called_addr_length; /* length of called address */ + t_uscalar_t dl_called_addr_offset; /* offset from start of block */ + t_uscalar_t dl_calling_addr_length; /* length of calling address */ + t_uscalar_t dl_calling_addr_offset; /* offset from start of block */ + t_uscalar_t dl_qos_length; /* length of qos structure */ + t_uscalar_t dl_qos_offset; /* offset from start of block */ + t_uscalar_t dl_growth; /* set to zero */ +} dl_connect_ind_t; + +/* + * DL_CONNECT_RES, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_CONNECT_RES */ + t_uscalar_t dl_correlation; /* provider's correlation token */ + t_uscalar_t dl_resp_token; /* token of responding stream */ + t_uscalar_t dl_qos_length; /* length of qos structure */ + t_uscalar_t dl_qos_offset; /* offset from start of block */ + t_uscalar_t dl_growth; /* set to zero */ +} dl_connect_res_t; + +/* + * DL_CONNECT_CON, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_CONNECT_CON */ + t_uscalar_t dl_resp_addr_length; /* responder's address len */ + t_uscalar_t dl_resp_addr_offset; /* offset from start of block */ + t_uscalar_t dl_qos_length; /* length of qos structure */ + t_uscalar_t dl_qos_offset; /* offset from start of block */ + t_uscalar_t dl_growth; /* set to zero */ +} dl_connect_con_t; + +/* + * DL_TOKEN_REQ, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_TOKEN_REQ */ +} dl_token_req_t; + +/* + * DL_TOKEN_ACK, M_PCPROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_TOKEN_ACK */ + t_uscalar_t dl_token; /* Connection response token */ +}dl_token_ack_t; + +/* + * DL_DISCONNECT_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_DISCONNECT_REQ */ + t_uscalar_t dl_reason; /* norm., abnorm., perm. or trans. */ + t_uscalar_t dl_correlation; /* association with connect_ind */ +} dl_disconnect_req_t; + +/* + * DL_DISCONNECT_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_DISCONNECT_IND */ + t_uscalar_t dl_originator; /* USER or PROVIDER */ + t_uscalar_t dl_reason; /* permanent or transient */ + t_uscalar_t dl_correlation; /* association with connect_ind */ +} dl_disconnect_ind_t; + +/* + * DL_RESET_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_RESET_REQ */ +} dl_reset_req_t; + +/* + * DL_RESET_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_RESET_IND */ + t_uscalar_t dl_originator; /* Provider or User */ + t_uscalar_t dl_reason; /* flow control, link error, resync */ +} dl_reset_ind_t; + +/* + * DL_RESET_RES, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_RESET_RES */ +} dl_reset_res_t; + +/* + * DL_RESET_CON, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_RESET_CON */ +} dl_reset_con_t; + + +/* + * CONNECTIONLESS SERVICE PRIMITIVES + */ + +/* + * DL_UNITDATA_REQ, M_PROTO type, with M_DATA block(s) + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_UNITDATA_REQ */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + dl_priority_t dl_priority; /* priority value */ +} dl_unitdata_req_t; + +/* + * DL_UNITDATA_IND, M_PROTO type, with M_DATA block(s) + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_UNITDATA_IND */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* DLSAP addr length sender */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ + t_uscalar_t dl_group_address; /* one if multicast/broadcast */ +} dl_unitdata_ind_t; + +/* + * DL_UDERROR_IND, M_PROTO type + * (or M_PCPROTO type if LLI-based provider) + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_UDERROR_IND */ + t_uscalar_t dl_dest_addr_length; /* Destination DLSAP */ + t_uscalar_t dl_dest_addr_offset; /* Offset from start of block */ + t_uscalar_t dl_unix_errno; /* unix system error code */ + t_uscalar_t dl_errno; /* DLPI error code */ +} dl_uderror_ind_t; + +/* + * DL_UDQOS_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_UDQOS_REQ */ + t_uscalar_t dl_qos_length; /* requested qos byte length */ + t_uscalar_t dl_qos_offset; /* offset from start of block */ +} dl_udqos_req_t; + +/* + * Primitives to handle XID and TEST operations + */ + +/* + * DL_TEST_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_TEST_REQ */ + t_uscalar_t dl_flag; /* poll/final */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ +} dl_test_req_t; + +/* + * DL_TEST_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_TEST_IND */ + t_uscalar_t dl_flag; /* poll/final */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* DLSAP length of source */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ +} dl_test_ind_t; + +/* + * DL_TEST_RES, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_TEST_RES */ + t_uscalar_t dl_flag; /* poll/final */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ +} dl_test_res_t; + +/* + * DL_TEST_CON, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_TEST_CON */ + t_uscalar_t dl_flag; /* poll/final */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* DLSAP length of source */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ +} dl_test_con_t; + +/* + * DL_XID_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_XID_REQ */ + t_uscalar_t dl_flag; /* poll/final */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ +} dl_xid_req_t; + +/* + * DL_XID_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_XID_IND */ + t_uscalar_t dl_flag; /* poll/final */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* DLSAP length of source */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ +} dl_xid_ind_t; + +/* + * DL_XID_RES, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_XID_RES */ + t_uscalar_t dl_flag; /* poll/final */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ +} dl_xid_res_t; + +/* + * DL_XID_CON, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_XID_CON */ + t_uscalar_t dl_flag; /* poll/final */ + t_uscalar_t dl_dest_addr_length; /* DLSAP length of dest. user */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* DLSAP length of source */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ +} dl_xid_con_t; + +/* + * ACKNOWLEDGED CONNECTIONLESS SERVICE PRIMITIVES + */ + +/* + * DL_DATA_ACK_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_DATA_ACK_REQ */ + t_uscalar_t dl_correlation; /* User's correlation token */ + t_uscalar_t dl_dest_addr_length; /* length of destination addr */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* length of source address */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ + t_uscalar_t dl_priority; /* priority */ + t_uscalar_t dl_service_class; /* DL_RQST_RSP|DL_RQST_NORSP */ +} dl_data_ack_req_t; + +/* + * DL_DATA_ACK_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_DATA_ACK_IND */ + t_uscalar_t dl_dest_addr_length; /* length of destination addr */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* length of source address */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ + t_uscalar_t dl_priority; /* pri. for data unit transm. */ + t_uscalar_t dl_service_class; /* DL_RQST_RSP|DL_RQST_NORSP */ +} dl_data_ack_ind_t; + +/* + * DL_DATA_ACK_STATUS_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_DATA_ACK_STATUS_IND */ + t_uscalar_t dl_correlation; /* User's correlation token */ + t_uscalar_t dl_status; /* success or failure of previous req */ +} dl_data_ack_status_ind_t; + +/* + * DL_REPLY_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_REPLY_REQ */ + t_uscalar_t dl_correlation; /* User's correlation token */ + t_uscalar_t dl_dest_addr_length; /* destination address length */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* source address length */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ + t_uscalar_t dl_priority; /* pri for data unit trans. */ + t_uscalar_t dl_service_class; +} dl_reply_req_t; + +/* + * DL_REPLY_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_REPLY_IND */ + t_uscalar_t dl_dest_addr_length; /* destination address length */ + t_uscalar_t dl_dest_addr_offset; /* offset from start of block */ + t_uscalar_t dl_src_addr_length; /* length of source address */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ + t_uscalar_t dl_priority; /* pri for data unit trans. */ + t_uscalar_t dl_service_class; /* DL_RQST_RSP|DL_RQST_NORSP */ +} dl_reply_ind_t; + +/* + * DL_REPLY_STATUS_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_REPLY_STATUS_IND */ + t_uscalar_t dl_correlation; /* User's correlation token */ + t_uscalar_t dl_status; /* success or failure of previous req */ +} dl_reply_status_ind_t; + +/* + * DL_REPLY_UPDATE_REQ, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_REPLY_UPDATE_REQ */ + t_uscalar_t dl_correlation; /* user's correlation token */ + t_uscalar_t dl_src_addr_length; /* length of source address */ + t_uscalar_t dl_src_addr_offset; /* offset from start of block */ +} dl_reply_update_req_t; + +/* + * DL_REPLY_UPDATE_STATUS_IND, M_PROTO type + */ +typedef struct { + t_uscalar_t dl_primitive; /* DL_REPLY_UPDATE_STATUS_IND */ + t_uscalar_t dl_correlation; /* User's correlation token */ + t_uscalar_t dl_status; /* success or failure of previous req */ +} dl_reply_update_status_ind_t; + +union DL_primitives { + t_uscalar_t dl_primitive; + dl_info_req_t info_req; + dl_info_ack_t info_ack; + dl_attach_req_t attach_req; + dl_detach_req_t detach_req; + dl_bind_req_t bind_req; + dl_bind_ack_t bind_ack; + dl_unbind_req_t unbind_req; + dl_subs_bind_req_t subs_bind_req; + dl_subs_bind_ack_t subs_bind_ack; + dl_subs_unbind_req_t subs_unbind_req; + dl_ok_ack_t ok_ack; + dl_error_ack_t error_ack; + dl_connect_req_t connect_req; + dl_connect_ind_t connect_ind; + dl_connect_res_t connect_res; + dl_connect_con_t connect_con; + dl_token_req_t token_req; + dl_token_ack_t token_ack; + dl_disconnect_req_t disconnect_req; + dl_disconnect_ind_t disconnect_ind; + dl_reset_req_t reset_req; + dl_reset_ind_t reset_ind; + dl_reset_res_t reset_res; + dl_reset_con_t reset_con; + dl_unitdata_req_t unitdata_req; + dl_unitdata_ind_t unitdata_ind; + dl_uderror_ind_t uderror_ind; + dl_udqos_req_t udqos_req; + dl_enabmulti_req_t enabmulti_req; + dl_disabmulti_req_t disabmulti_req; + dl_promiscon_req_t promiscon_req; + dl_promiscoff_req_t promiscoff_req; + dl_phys_addr_req_t physaddr_req; + dl_phys_addr_ack_t physaddr_ack; + dl_set_phys_addr_req_t set_physaddr_req; + dl_get_statistics_req_t get_statistics_req; + dl_get_statistics_ack_t get_statistics_ack; + dl_notify_req_t notify_req; + dl_notify_ack_t notify_ack; + dl_notify_ind_t notify_ind; + dl_notify_conf_t notify_conf; + dl_aggr_req_t aggr_req; + dl_aggr_ind_t aggr_ind; + dl_unaggr_req_t unaggr_req; + dl_test_req_t test_req; + dl_test_ind_t test_ind; + dl_test_res_t test_res; + dl_test_con_t test_con; + dl_xid_req_t xid_req; + dl_xid_ind_t xid_ind; + dl_xid_res_t xid_res; + dl_xid_con_t xid_con; + dl_data_ack_req_t data_ack_req; + dl_data_ack_ind_t data_ack_ind; + dl_data_ack_status_ind_t data_ack_status_ind; + dl_reply_req_t reply_req; + dl_reply_ind_t reply_ind; + dl_reply_status_ind_t reply_status_ind; + dl_reply_update_req_t reply_update_req; + dl_reply_update_status_ind_t reply_update_status_ind; + dl_capability_req_t capability_req; + dl_capability_ack_t capability_ack; + dl_control_req_t control_req; + dl_control_ack_t control_ack; + dl_passive_req_t passive_req; + dl_intr_mode_req_t intr_mode_req; +}; + +#define DL_INFO_REQ_SIZE sizeof (dl_info_req_t) +#define DL_INFO_ACK_SIZE sizeof (dl_info_ack_t) +#define DL_ATTACH_REQ_SIZE sizeof (dl_attach_req_t) +#define DL_DETACH_REQ_SIZE sizeof (dl_detach_req_t) +#define DL_BIND_REQ_SIZE sizeof (dl_bind_req_t) +#define DL_BIND_ACK_SIZE sizeof (dl_bind_ack_t) +#define DL_UNBIND_REQ_SIZE sizeof (dl_unbind_req_t) +#define DL_SUBS_BIND_REQ_SIZE sizeof (dl_subs_bind_req_t) +#define DL_SUBS_BIND_ACK_SIZE sizeof (dl_subs_bind_ack_t) +#define DL_SUBS_UNBIND_REQ_SIZE sizeof (dl_subs_unbind_req_t) +#define DL_OK_ACK_SIZE sizeof (dl_ok_ack_t) +#define DL_ERROR_ACK_SIZE sizeof (dl_error_ack_t) +#define DL_CONNECT_REQ_SIZE sizeof (dl_connect_req_t) +#define DL_CONNECT_IND_SIZE sizeof (dl_connect_ind_t) +#define DL_CONNECT_RES_SIZE sizeof (dl_connect_res_t) +#define DL_CONNECT_CON_SIZE sizeof (dl_connect_con_t) +#define DL_TOKEN_REQ_SIZE sizeof (dl_token_req_t) +#define DL_TOKEN_ACK_SIZE sizeof (dl_token_ack_t) +#define DL_DISCONNECT_REQ_SIZE sizeof (dl_disconnect_req_t) +#define DL_DISCONNECT_IND_SIZE sizeof (dl_disconnect_ind_t) +#define DL_RESET_REQ_SIZE sizeof (dl_reset_req_t) +#define DL_RESET_IND_SIZE sizeof (dl_reset_ind_t) +#define DL_RESET_RES_SIZE sizeof (dl_reset_res_t) +#define DL_RESET_CON_SIZE sizeof (dl_reset_con_t) +#define DL_UNITDATA_REQ_SIZE sizeof (dl_unitdata_req_t) +#define DL_UNITDATA_IND_SIZE sizeof (dl_unitdata_ind_t) +#define DL_UDERROR_IND_SIZE sizeof (dl_uderror_ind_t) +#define DL_UDQOS_REQ_SIZE sizeof (dl_udqos_req_t) +#define DL_ENABMULTI_REQ_SIZE sizeof (dl_enabmulti_req_t) +#define DL_DISABMULTI_REQ_SIZE sizeof (dl_disabmulti_req_t) +#define DL_PROMISCON_REQ_SIZE sizeof (dl_promiscon_req_t) +#define DL_PROMISCOFF_REQ_SIZE sizeof (dl_promiscoff_req_t) +#define DL_PHYS_ADDR_REQ_SIZE sizeof (dl_phys_addr_req_t) +#define DL_PHYS_ADDR_ACK_SIZE sizeof (dl_phys_addr_ack_t) +#define DL_SET_PHYS_ADDR_REQ_SIZE sizeof (dl_set_phys_addr_req_t) +#define DL_GET_STATISTICS_REQ_SIZE sizeof (dl_get_statistics_req_t) +#define DL_GET_STATISTICS_ACK_SIZE sizeof (dl_get_statistics_ack_t) +#define DL_NOTIFY_REQ_SIZE sizeof (dl_notify_req_t) +#define DL_NOTIFY_ACK_SIZE sizeof (dl_notify_ack_t) +#define DL_NOTIFY_IND_SIZE sizeof (dl_notify_ind_t) +#define DL_NOTIFY_CONF_SIZE sizeof (dl_notify_conf_t) +#define DL_AGGR_REQ_SIZE sizeof (dl_aggr_req_t) +#define DL_AGGR_IND_SIZE sizeof (dl_aggr_ind_t) +#define DL_UNAGGR_REQ_SIZE sizeof (dl_unaggr_req_t) +#define DL_XID_REQ_SIZE sizeof (dl_xid_req_t) +#define DL_XID_IND_SIZE sizeof (dl_xid_ind_t) +#define DL_XID_RES_SIZE sizeof (dl_xid_res_t) +#define DL_XID_CON_SIZE sizeof (dl_xid_con_t) +#define DL_TEST_REQ_SIZE sizeof (dl_test_req_t) +#define DL_TEST_IND_SIZE sizeof (dl_test_ind_t) +#define DL_TEST_RES_SIZE sizeof (dl_test_res_t) +#define DL_TEST_CON_SIZE sizeof (dl_test_con_t) +#define DL_DATA_ACK_REQ_SIZE sizeof (dl_data_ack_req_t) +#define DL_DATA_ACK_IND_SIZE sizeof (dl_data_ack_ind_t) +#define DL_DATA_ACK_STATUS_IND_SIZE sizeof (dl_data_ack_status_ind_t) +#define DL_REPLY_REQ_SIZE sizeof (dl_reply_req_t) +#define DL_REPLY_IND_SIZE sizeof (dl_reply_ind_t) +#define DL_REPLY_STATUS_IND_SIZE sizeof (dl_reply_status_ind_t) +#define DL_REPLY_UPDATE_REQ_SIZE sizeof (dl_reply_update_req_t) +#define DL_REPLY_UPDATE_STATUS_IND_SIZE sizeof (dl_reply_update_status_ind_t) +#define DL_CAPABILITY_REQ_SIZE sizeof (dl_capability_req_t) +#define DL_CAPABILITY_ACK_SIZE sizeof (dl_capability_ack_t) +#define DL_CONTROL_REQ_SIZE sizeof (dl_control_req_t) +#define DL_CONTROL_ACK_SIZE sizeof (dl_control_ack_t) +#define DL_PASSIVE_REQ_SIZE sizeof (dl_passive_req_t) +#define DL_INTR_MODE_REQ_SIZE sizeof (dl_intr_mode_req_t) + +#ifdef _KERNEL +/* + * DDI DLPI routines; see the appropriate manpage for details. + */ +extern void dlbindack(queue_t *, mblk_t *, t_scalar_t, const void *, + t_uscalar_t, t_uscalar_t, t_uscalar_t); +extern void dlokack(queue_t *, mblk_t *, t_uscalar_t); +extern void dlerrorack(queue_t *, mblk_t *, t_uscalar_t, t_uscalar_t, + t_uscalar_t); +extern void dluderrorind(queue_t *, mblk_t *, const void *, t_uscalar_t, + t_uscalar_t, t_uscalar_t); +extern void dlphysaddrack(queue_t *, mblk_t *, const void *, t_uscalar_t); + +/* + * All routines that follow are unstable and subject to change. + */ +extern void dlcapabsetqid(dl_mid_t *, const queue_t *); +extern boolean_t dlcapabcheckqid(const dl_mid_t *, const queue_t *); +extern void dlnotifyack(queue_t *, mblk_t *, uint32_t); +/* + * The ldi_handle_t typedef is in , which in turn requires + * , which pulls in , which declares kernel + * versions of the printf() functions that conflict with the libc ones. + * This causes conflicts when building MDB modules like ARP that #define + * _KERNEL. So we use `struct __ldi_handle *' instead. + */ +struct __ldi_handle; +extern int dl_attach(struct __ldi_handle *, int, dl_error_ack_t *); +extern int dl_bind(struct __ldi_handle *, uint_t, dl_error_ack_t *); +extern int dl_phys_addr(struct __ldi_handle *, uchar_t *, size_t *, + dl_error_ack_t *); +extern int dl_info(struct __ldi_handle *, dl_info_ack_t *, uchar_t *, size_t *, + dl_error_ack_t *); +extern int dl_notify(struct __ldi_handle *, uint32_t *, dl_error_ack_t *); +extern const char *dl_errstr(t_uscalar_t); +extern const char *dl_primstr(t_uscalar_t); +extern const char *dl_mactypestr(t_uscalar_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DLPI_H */ diff --git a/illumos-x86_64/usr/include/sys/dls_mgmt.h b/illumos-x86_64/usr/include/sys/dls_mgmt.h new file mode 100644 index 00000000..a0d8cac9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dls_mgmt.h @@ -0,0 +1,242 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Joyent, Inc. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _DLS_MGMT_H +#define _DLS_MGMT_H + +#include +#include +#include + +/* + * Data-Link Services Module + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + DATALINK_CLASS_PHYS = 0x01, + DATALINK_CLASS_VLAN = 0x02, + DATALINK_CLASS_AGGR = 0x04, + DATALINK_CLASS_VNIC = 0x08, + DATALINK_CLASS_ETHERSTUB = 0x10, + DATALINK_CLASS_SIMNET = 0x20, + DATALINK_CLASS_BRIDGE = 0x40, + DATALINK_CLASS_IPTUN = 0x80, + DATALINK_CLASS_PART = 0x100, + DATALINK_CLASS_OVERLAY = 0x200, + DATALINK_CLASS_MISC = 0x400 +} datalink_class_t; + +#define DATALINK_CLASS_ALL (DATALINK_CLASS_PHYS | \ + DATALINK_CLASS_VLAN | DATALINK_CLASS_AGGR | DATALINK_CLASS_VNIC | \ + DATALINK_CLASS_ETHERSTUB | DATALINK_CLASS_SIMNET | \ + DATALINK_CLASS_BRIDGE | DATALINK_CLASS_IPTUN | DATALINK_CLASS_PART | \ + DATALINK_CLASS_OVERLAY | DATALINK_CLASS_MISC) + +/* + * A combination of flags and media. + * flags is the higher 32 bits, and if it is 0x01, it indicates all media + * types can be accepted; otherwise, only the given media type (specified + * in the lower 32 bits) is accepted. + */ +typedef uint64_t datalink_media_t; + +#define DATALINK_ANY_MEDIATYPE \ + ((datalink_media_t)(((datalink_media_t)0x01) << 32)) + +#define DATALINK_MEDIA_ACCEPTED(dmedia, media) \ + (((uint32_t)(((dmedia) >> 32) & 0xfffffffful) & 0x01) ? \ + B_TRUE : ((uint32_t)((dmedia) & 0xfffffffful) == (media))) + +#define MAXLINKATTRLEN 32 +#define MAXLINKATTRVALLEN 1024 + +/* + * Link attributes used by the kernel. + */ +/* + * The major number and instance number of the underlying physical device + * are kept as FPHYMAJ and FPHYINST (major, instance + 1). + * + * Set for physical links only. + */ +#define FPHYMAJ "phymaj" /* uint64_t */ +#define FPHYINST "phyinst" /* uint64_t */ + +/* + * The devname of the physical link. For example, bge0, ce1. Set for physical + * links only. + */ +#define FDEVNAME "devname" /* string */ + +/* + * The door file for the dlmgmtd (data-link management) daemon. + */ +#define DLMGMT_TMPFS_DIR "/etc/svc/volatile/dladm" +#define DLMGMT_DOOR DLMGMT_TMPFS_DIR "/dlmgmt_door" + +/* + * Door upcall commands. + */ +#define DLMGMT_CMD_DLS_CREATE 1 +#define DLMGMT_CMD_DLS_GETATTR 2 +#define DLMGMT_CMD_DLS_DESTROY 3 +#define DLMGMT_CMD_GETNAME 4 +#define DLMGMT_CMD_GETLINKID 5 +#define DLMGMT_CMD_GETNEXT 6 +#define DLMGMT_CMD_DLS_UPDATE 7 +#define DLMGMT_CMD_LINKPROP_INIT 8 +#define DLMGMT_CMD_SETZONEID 9 +#define DLMGMT_CMD_BASE 128 + +/* + * Indicate if the link mapping is active, persistent, or transient. A + * transient link is an active link with a twist -- it is an active + * link which is destroyed along with the zone rather than reassigned + * to the GZ. + */ +#define DLMGMT_ACTIVE 0x01 +#define DLMGMT_PERSIST 0x02 +#define DLMGMT_TRANSIENT 0x04 + +/* upcall argument */ +typedef struct dlmgmt_door_arg { + uint_t ld_cmd; +} dlmgmt_door_arg_t; + +typedef struct dlmgmt_upcall_arg_create { + int ld_cmd; + datalink_class_t ld_class; + uint32_t ld_media; + boolean_t ld_persist; + uint64_t ld_phymaj; + uint64_t ld_phyinst; + char ld_devname[MAXNAMELEN]; +} dlmgmt_upcall_arg_create_t; + +/* + * Note: ld_padding is necessary to keep the size of the structure the + * same on amd64 and i386. The same note applies to other ld_padding + * and lr_paddding fields in structures throughout this file. + */ +typedef struct dlmgmt_upcall_arg_destroy { + int ld_cmd; + datalink_id_t ld_linkid; + boolean_t ld_persist; + int ld_padding; +} dlmgmt_upcall_arg_destroy_t; + +typedef struct dlmgmt_upcall_arg_update { + int ld_cmd; + boolean_t ld_novanity; + uint32_t ld_media; + uint32_t ld_padding; + char ld_devname[MAXNAMELEN]; +} dlmgmt_upcall_arg_update_t; + +typedef struct dlmgmt_upcall_arg_getattr { + int ld_cmd; + datalink_id_t ld_linkid; + char ld_attr[MAXLINKATTRLEN]; +} dlmgmt_upcall_arg_getattr_t; + +typedef struct dlmgmt_door_getname { + int ld_cmd; + datalink_id_t ld_linkid; +} dlmgmt_door_getname_t; + +typedef struct dlmgmt_door_getlinkid { + int ld_cmd; + char ld_link[MAXLINKNAMELEN]; +} dlmgmt_door_getlinkid_t; + +typedef struct dlmgmt_door_getnext_s { + int ld_cmd; + datalink_id_t ld_linkid; + datalink_class_t ld_class; + uint32_t ld_flags; + datalink_media_t ld_dmedia; +} dlmgmt_door_getnext_t; + +typedef struct dlmgmt_door_linkprop_init { + int ld_cmd; + datalink_id_t ld_linkid; +} dlmgmt_door_linkprop_init_t; + +typedef struct dlmgmt_door_setzoneid { + int ld_cmd; + datalink_id_t ld_linkid; + zoneid_t ld_zoneid; +} dlmgmt_door_setzoneid_t; + +/* upcall return value */ +typedef struct dlmgmt_retval_s { + uint_t lr_err; /* return error code */ +} dlmgmt_retval_t; + +typedef dlmgmt_retval_t dlmgmt_destroy_retval_t, + dlmgmt_linkprop_init_retval_t, + dlmgmt_setzoneid_retval_t; + +struct dlmgmt_linkid_retval_s { + uint_t lr_err; + datalink_id_t lr_linkid; + uint32_t lr_flags; + datalink_class_t lr_class; + uint32_t lr_media; + uint32_t lr_padding; +}; + +typedef struct dlmgmt_linkid_retval_s dlmgmt_create_retval_t, + dlmgmt_update_retval_t, + dlmgmt_getlinkid_retval_t, + dlmgmt_getnext_retval_t; + +typedef struct dlmgmt_getname_retval_s { + uint_t lr_err; + char lr_link[MAXLINKNAMELEN]; + datalink_class_t lr_class; + uint32_t lr_media; + uint32_t lr_flags; +} dlmgmt_getname_retval_t; + +typedef struct dlmgmt_getattr_retval_s { + uint_t lr_err; + uint_t lr_type; + uint_t lr_attrsz; + uint_t lr_padding; + char lr_attrval[MAXLINKATTRVALLEN]; +} dlmgmt_getattr_retval_t; + + +#ifdef __cplusplus +} +#endif + +#endif /* _DLS_MGMT_H */ diff --git a/illumos-x86_64/usr/include/sys/dma_engine.h b/illumos-x86_64/usr/include/sys/dma_engine.h new file mode 100644 index 00000000..ad3094d2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dma_engine.h @@ -0,0 +1,278 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + */ + +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +/* Copyright (c) 1988, 1989 Intel Corp. */ +/* All Rights Reserved */ + +#ifndef _SYS_DMA_ENGINE_H +#define _SYS_DMA_ENGINE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NCHANS 8 + +/* + * the DMA Engine Request structure + */ +struct ddi_dmae_req { + dev_info_t *der_rdip; /* original requester's dev_info_t */ + uchar_t der_command; /* Read/Write/Translate/Verify */ + uchar_t der_bufprocess; /* NoAuto_init/Chain/Auto_init */ + uchar_t der_step; /* Inc / Dec / Hold */ + uchar_t der_trans; /* Single/Demand/Block/Cascade */ + uchar_t der_path; /* 8/16/32 */ + uchar_t der_cycles; /* 1 or 2 */ + uchar_t der_dest; /* Memory / IO */ + uchar_t der_arbus; /* MicroChannel arbitration reg */ + ushort_t der_ioadr; /* MicroChannel i/o address reg */ + ddi_dma_cookie_t *(*proc)(); /* address of application call routine */ + void *procparms; /* parameter buffer for appl call */ +}; + +#define DMAE_CMD_VRFY 0 +#define DMAE_CMD_WRITE 1 /* from memory to device */ +#define DMAE_CMD_READ 2 /* from device to memory */ +#define DMAE_CMD_TRAN 3 + +#define DMAE_BUF_NOAUTO 0 /* default */ +#define DMAE_BUF_CHAIN 0x1 +#define DMAE_BUF_AUTO 0x2 + +#define DMAE_STEP_INC 0 /* default */ +#define DMAE_STEP_DEC 1 +#define DMAE_STEP_HOLD 2 + +#define DMAE_TRANS_SNGL 0 /* default */ +#define DMAE_TRANS_BLCK 1 +#define DMAE_TRANS_DMND 2 +#define DMAE_TRANS_CSCD 3 + + +/* + * For the EISA bus + */ +#define DMAE_PATH_DEF 0 /* default to ISA xfer width */ +#define DMAE_PATH_8 1 /* ISA default for chnl 0..3 */ +#define DMAE_PATH_16 2 /* ISA default for chnl 5..7 */ +#define DMAE_PATH_32 3 +#define DMAE_PATH_64 4 +#define DMAE_PATH_16B 5 /* 16-bit path but byte count */ + +#define DMAE_CYCLES_1 0 /* Compatible timing */ +#define DMAE_CYCLES_2 1 /* Type "A" timing */ +#define DMAE_CYCLES_3 2 /* Type "B" timing */ +#define DMAE_CYCLES_4 3 /* Burst timing */ + +#define DMAE_DEST_IO 0 /* default */ +#define DMAE_DEST_MEM 1 + + + +/* public function routines */ +extern int i_dmae_init(dev_info_t *); +extern ddi_dma_cookie_t *_dmae_nxcookie(int); +extern int i_dmae_acquire(dev_info_t *, int, int (*)(), caddr_t); +extern int i_dmae_free(dev_info_t *, int); +extern int i_dmae_prog(dev_info_t *, struct ddi_dmae_req *, + ddi_dma_cookie_t *, int); +extern int i_dmae_swsetup(dev_info_t *, struct ddi_dmae_req *, + ddi_dma_cookie_t *, int); +extern void i_dmae_swstart(dev_info_t *, int); +extern void i_dmae_stop(dev_info_t *, int); +extern void i_dmae_enable(dev_info_t *, int); +extern void i_dmae_disable(dev_info_t *, int); +extern void i_dmae_get_chan_stat(dev_info_t *dip, int chnl, + ulong_t *addressp, int *countp); + +/* + * the DMA Channel Block structure + */ +struct dmae_chnl { + ksema_t dch_lock; /* semaphore for this channel */ + ddi_dma_cookie_t *dch_cookiep; /* current dma mapping cookie */ + ddi_dma_cookie_t *(*proc)(); /* address of application call */ + /* routine */ + void *procparms; /* parameter buffer for appl call */ +}; + + +/* + * DMA Engine DDI functions + */ + +/* + * Get DMA engine attributes + * + * The attributes of the DMA engine of the parent bus-nexus are copied into + * the provided structure. This should be called at driver attach time, + * rather than for each DMA bind. + */ + +int ddi_dmae_getattr(dev_info_t *dip, ddi_dma_attr_t *attrp); + +/* + * DMA channel allocation + * + * The allocation function must be called prior to any other DMA engine + * function on a channel. The channel should be freed after completion of the + * DMA / device operation if the channel is to be shared. + * + * Specifics of arguments to ddi_dmae_alloc: + * + * dip - dev_info pointer, which identifies the base device that wishes + * to use the DMA channel. + * + * chnl - a DMA channel number. + * + * dmae_waitfp - wait/callback_function pointer, which operates in the same + * manner as in ddi_dma_setup(). The value DDI_DMA_DONTWAIT will cause an + * immediate return if the channel cannot be acquired. The value + * DDI_DMA_SLEEP will will cause the thread to sleep and not return until + * the channel has been acquired. Any other value is assumed to be a + * callback function address. + * + * When resources might be available, the callback function is called + * (with the argument specified in arg) from interrupt context. + * + * When the callback function dmae_waitfp() is called, it should attempt to + * allocate the DMA channel again. If it succeeds or does not need the + * channel any more, it must return the value DDI_DMA_CALLBACK_DONE. + * If it does not want to allocate the channel, but instead wishes to be + * called back again later, it must return the value DDI_DMA_CALLBACK_LATER. + * If it tries to allocate the channel, but fails to do so, it must return the + * value DDI_DMA_CALLBACK_RUNOUT. + * + * Failure to observe this protocol will have unpredictable results. + * + * The callback function must provide its own data structure integrity + * when it is invoked. + */ + +int ddi_dmae_alloc(dev_info_t *dip, int chnl, int (*dmae_waitfp)(), + caddr_t arg); + +/* + * DMA channel deallocation + * + * The deallocation function should be called after completion of the + * DMA / device operation if the channel is to be shared. + */ + +int ddi_dmae_release(dev_info_t *dip, int chnl); + +/* + * DMA channel used in 1st party DMA scheme + * + * The specified channel will be configured to operate in a "slave" mode + * to a first_party DMA engine that also uses the channel. + */ + +int ddi_dmae_1stparty(dev_info_t *dip, int chnl); + +/* + * Program DMA channel + * + * The DMA channel is setup for an operation using ddi_dmae_prog(). + * This function is implemented to access all capabilities of the DMA engine + * hardware. This function disables the channel prior to setup, and enables + * the channel before returning. + * + * Specifics of arguments to ddi_dmae_prog: + * + * dmaereqp - pointer to a DMA engine request structure. This structure + * is implementation specific and contains all the info necessary to + * setup the channel, except for the memory address and count. + * This structure is implemented with default values equal to zero, + * so that normally only der_command has to be set with a read or write + * command value. Once the channel has been setup, subsequent calls to + * ddi_dmae_prog() can have dmaereqp set to NULL if only the address and + * count have to be updated. + * + * cookiep - pointer to a ddi_dma_cookie object which contains address, + * count and intermediate memory mapping information. + */ + +int ddi_dmae_prog(dev_info_t *dip, struct ddi_dmae_req *dmaereqp, + ddi_dma_cookie_t *cookiep, int chnl); + +int ddi_dmae_swsetup(dev_info_t *dip, struct ddi_dmae_req *dmaereqp, + ddi_dma_cookie_t *cookiep, int chnl); + +int ddi_dmae_swstart(dev_info_t *dip, int chnl); + +/* + * Stop DMA channel + * + * The DMA channel is disabled and any active operation is terminated. + */ + +int ddi_dmae_stop(dev_info_t *dip, int chnl); + +/* + * Enable DMA channel + * + * The DMA channel is enabled for operation. The channel is also enabled + * after successful setup in ddi_dmae_prog(). + */ + +int ddi_dmae_enable(dev_info_t *dip, int chnl); + +/* + * Disable DMA channel + * + * The DMA channel is disabled so that transfers cannot continue. + */ + +int ddi_dmae_disable(dev_info_t *dip, int chnl); + +/* + * Get remaining xfer count + * + * The count register of the DMA channel is read. The channel is assumed + * to be stopped. + */ + +int ddi_dmae_getcnt(dev_info_t *dip, int chnl, int *count); + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_DMA_ENGINE_H */ diff --git a/illumos-x86_64/usr/include/sys/dma_i8237A.h b/illumos-x86_64/usr/include/sys/dma_i8237A.h new file mode 100644 index 00000000..654c5963 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dma_i8237A.h @@ -0,0 +1,302 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DMA_I8237A_H +#define _SYS_DMA_I8237A_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#define D37A_MAX_CHAN 8 +#define D37A_DFR_ALIGN 0xf +#define D37A_MIN_CHAN 0x0 + +/* + * Defines for PC AT DMA controllers. + */ + +/* + * The PC/AT has two Intel 8237A-5 DMA controllers that provide 8 channels + */ +#define DMA_0WCNT 0x01 /* Channel word count */ +#define DMA_1WCNT 0x03 /* Channel word count */ +#define DMA_2WCNT 0x05 /* Channel word count */ +#define DMA_3WCNT 0x07 /* Channel word count */ +#define DMA_4WCNT 0xC2 /* (RESERVED) Channel word count */ +#define DMA_5WCNT 0xC6 /* Channel word count */ +#define DMA_6WCNT 0xCA /* Channel word count */ +#define DMA_7WCNT 0xCE /* Channel word count */ + +#define DMA_0ADR 0x00 /* Channel address register */ +#define DMA_1ADR 0x02 /* Channel address register */ +#define DMA_2ADR 0x04 /* Channel address register */ +#define DMA_3ADR 0x06 /* Channel address register */ +#define DMA_4ADR 0xC0 /* (RESERVED) Channel address register */ +#define DMA_5ADR 0xC4 /* Channel address register */ +#define DMA_6ADR 0xC8 /* Channel address register */ +#define DMA_7ADR 0xCC /* Channel address register */ + +/* + * The Intel DMA controllers are augmented with 8-bit page registers + * for each channel, allowing access to a 16MB address space. + */ +#define DMA_0PAGE 0x87 /* Channel 0 address extension reg */ +#define DMA_1PAGE 0x83 /* Channel 1 address extension reg */ +#define DMA_2PAGE 0x81 /* Channel 2 address extension reg */ +#define DMA_3PAGE 0x82 /* Channel 3 address extension reg */ +#define DMA_4PAGE 0 /* dummy address for dma chan. 4 page reg. */ +#define DMA_5PAGE 0x8B /* Channel 5 address extension reg */ +#define DMA_6PAGE 0x89 /* Channel 6 address extension reg */ +#define DMA_7PAGE 0x8A /* Channel 7 address extension reg */ + +/* + * The EISA has an 8-bit high-page register for each channel + * for access to a 32-bit address space. + */ +#define DMA_0HPG 0x487 /* port address for dma channel 0 */ + /* high page reg */ +#define DMA_1HPG 0x483 /* port address for dma channel 1 */ + /* high page reg */ +#define DMA_2HPG 0x481 /* port address for dma channel 2 */ + /* high page reg */ +#define DMA_3HPG 0x482 /* port address for dma channel 3 */ + /* high page reg */ +#define DMA_4HPG 0 /* dummy address for dma channel 4 */ + /* high page reg */ +#define DMA_5HPG 0x48B /* port address for dma channel 5 */ + /* high page reg */ +#define DMA_6HPG 0x489 /* port address for dma channel 6 */ + /* high page reg */ +#define DMA_7HPG 0x48A /* port address for dma channel 7 */ + /* high page reg */ + +/* + * The EISA has an 8-bit high-count register for each channel + * for xfer sizes up to 16MB. + */ +#define DMA_0XCNT 0x401 /* chan. 0 base and current count high */ +#define DMA_1XCNT 0x403 /* chan. 1 base and current count high */ +#define DMA_2XCNT 0x405 /* chan. 2 base and current count high */ +#define DMA_3XCNT 0x407 /* chan. 3 base and current count high */ +#define DMA_4XCNT 0 /* dummy chan. 4 base and current count high */ +#define DMA_5XCNT 0x4C6 /* chan. 5 base and current count high */ +#define DMA_6XCNT 0x4CA /* chan. 6 base and current count high */ +#define DMA_7XCNT 0x4CE /* chan. 7 base and current count high */ + +/* + * I/O port addresses for controller 1 + */ +#define DMAC1_CMD 0x08 /* Command reg */ +#define DMAC1_REQ 0x09 /* request reg */ +#define DMAC1_STAT 0x08 /* Status reg */ +#define DMAC1_MASK 0x0A /* Mask set/reset register */ +#define DMAC1_MODE 0x0B /* Mode reg */ +#define DMAC1_CLFF 0x0C /* Clear byte pointer first/last flip-flop */ +#define DMA1RTRWMC 0x0D /* read temp reg/write master clear */ +#define DMA1CMR 0x0E /* clear mask register */ +#define DMAC1_ALLMASK 0x0F /* Mask all registers */ +#define DMAC1_SCM 0x40A /* set chain mode */ +#define DMAC1_EWM 0x40B /* extended write mode */ + +/* + * I/O port addresses for controller 2 + */ +#define DMAC2_CMD 0xD0 /* Command reg */ +#define DMAC2_STAT 0xD0 /* Status reg */ +#define DMAC2_REQ 0xD2 /* request reg */ +#define DMAC2_MASK 0xD4 /* Mask set/reset register */ +#define DMAC2_MODE 0xD6 /* Mode reg */ +#define DMAC2_CLFF 0xD8 /* Clear byte pointer first/last flip-flop */ +#define DMA2RTRWMC 0xDA /* read temp reg/write master clear */ +#define DMA2CMR 0xDC /* clear mask register */ +#define DMAC2_ALLMASK 0xDE /* Mask all registers */ +#define DMAC2_SCM 0x4D4 /* set chain mode */ +#define DMAC2_EWM 0x4D6 /* extended write mode */ + +/* + * Write-only Command register definitions. + */ +#define DMACMD_MEM_TO_MEM 0x01 /* memory-to-memory copy (1=enable) */ +#define DMACMD_CHAN_HOLD 0x02 /* Channel 0 address hold (1=enable) */ +#define DMACMD_CTLR_ENABLE 0x04 /* Controller disable (0=enabled) */ +#define DMACMD_TIMING 0x08 /* normal/compressed timing (0=nrml) */ +#define DMACMD_FIX_PRIO 0x10 /* fixed/rotating priority (0=fixed) */ +#define DMACMD_WRT_SELECT 0x20 /* late/ext write selection (1=ext) */ +#define DMACMD_DREQ_LEVEL 0x40 /* DREQ sense active (0=actv. high) */ +#define DMACMD_DACK_LEVEL 0x80 /* DACK sense active (0=actv. low) */ + +/* + * Initialization value for DMA controller. + */ +#define DMA_CTLR_INIT ~(DMACMD_MEM_TO_MEM | DMACMD_CHAN_HOLD | \ + DMACMD_CTLR_ENABLE | DMACMD_TIMING | \ + DMACMD_FIX_PRIO | DMACMD_WRT_SELECT | \ + DMACMD_DREQ_LEVEL | DMACMD_DACK_LEVEL) + +/* + * Write-only Mode register. There is actually a 6-bit Mode register + * associated with each channel. These are written one at a time, with + * the channel number indicated by the low-order 2 bits. + */ + +#define DMAMODE_CHAN 0x03 /* Mask for the "channel select" bits. */ + /* These indicate channel 0-3 */ +#define DMAMODE_VERF 0x00 /* Verify Transfer */ +#define DMAMODE_READ 0x04 /* Read Transfer */ +#define DMAMODE_WRITE 0x08 /* Write Transfer */ + /* Note: Above settings for bits 2-3 are */ + /* "don't care" if bits 6-7 indicate */ + /* cascade mode */ +#define DMAMODE_AUTO 0x10 /* enable Autoinitialization on completion */ +#define DMAMODE_DECR 0x20 /* Address Decrement. If 0, address incr */ +#define DMAMODE_DEMAND 0x00 /* Select Demand mode */ + /* Each DREQ causes transfers at full speed */ + /* until DREQ goes inactive (after which it */ + /* can be resumed) or either terminal-count */ + /* happens or EOP is asserted */ +#define DMAMODE_SINGLE 0x40 /* Select Single mode */ + /* Each DREQ causes a single byte/word xfer */ +#define DMAMODE_BLOCK 0x80 /* Select Block mode */ + /* Each DREQ causes transfers at full speed */ + /* until terminal count or EOP */ +#define DMAMODE_CASC 0xC0 /* Select Cascade mode. On the PC-AT, this */ + /* should be set for DMA 2 channel 0 ONLY */ + + +#define EISA_DMAIS 0x40a /* interrupt status register */ + +#define DMA_MSK 0x0A /* Mask, enable disk, disable others */ +#define DMA_CLEAR 0x1A /* Master clear */ +#define IOCR 0x56 /* IO controller */ + +/* + * DMA Channels. d_chan field of dmareq. + */ + +/* 8 bit channels */ +#define DMAE_CH0 0 /* Channel 0 */ +#define DMAE_CH1 1 /* Channel 1 */ +#define DMAE_CH2 2 /* Channel 2 */ +#define DMAE_CH3 3 /* Channel 3 */ +#define DMAE_CH4 4 /* Channel 4 */ +/* 16 bit channels */ +#define DMAE_CH5 5 /* Channel 5 */ +#define DMAE_CH6 6 /* Channel 6 */ +#define DMAE_CH7 7 /* Channel 7 */ + +/* + * DMA Masks. + */ +#define DMA_SETMSK 4 /* Set mask bit */ +#define DMA_CLRMSK 0 /* Clear mask bit */ + +/* dma_alloc modes */ +#define DMA_BLOCK 0 /* blocking task time allocation */ +#define DMA_NBLOCK 1 /* non-blocking task time allocation */ + +#define EISA_DMA_8 0 /* 8-bit data path */ +#define EISA_DMA_16 1<<2 /* 16-bit data path, word count */ +#define EISA_DMA_32 2<<2 /* 32-bit data path */ +#define EISA_DMA_16B 3<<2 /* 16-bit data path, byte count */ + +#define EISA_ENCM 4 /* enable chaining mode */ +#define EISA_CMOK 8 /* chaining mode completed (OK) */ + + +/* + * Channel Address Array - makes life much easier + */ +struct d37A_chan_reg_addr { + uchar_t addr_reg; /* address register */ + uchar_t cnt_reg; /* count register */ + uchar_t page_reg; /* page register */ + uchar_t ff_reg; /* first-last flipflop */ + uchar_t cmd_reg; /* command register */ + uchar_t mode_reg; /* mode register */ + uchar_t mask_reg; /* mask register */ + uchar_t stat_reg; /* status register */ + uchar_t reqt_reg; /* request register */ + ushort_t hpage_reg; /* high page register */ + ushort_t hcnt_reg; /* high count register */ + ushort_t emode_reg; /* extended mode register */ + ushort_t scm_reg; /* set chaining mode register */ +}; + +/* + * macro to initialize array of d37A_chan_reg_addr structures + */ +#define D37A_BASE_REGS_VALUES \ + {DMA_0ADR, DMA_0WCNT, DMA_0PAGE, DMAC1_CLFF, \ + DMAC1_CMD, DMAC1_MODE, DMAC1_MASK, DMAC1_STAT, DMAC1_REQ, \ + DMA_0HPG, DMA_0XCNT, DMAC1_EWM, DMAC1_SCM}, \ + {DMA_1ADR, DMA_1WCNT, DMA_1PAGE, DMAC1_CLFF, \ + DMAC1_CMD, DMAC1_MODE, DMAC1_MASK, DMAC1_STAT, DMAC1_REQ, \ + DMA_1HPG, DMA_1XCNT, DMAC1_EWM, DMAC1_SCM}, \ + {DMA_2ADR, DMA_2WCNT, DMA_2PAGE, DMAC1_CLFF, \ + DMAC1_CMD, DMAC1_MODE, DMAC1_MASK, DMAC1_STAT, DMAC1_REQ, \ + DMA_2HPG, DMA_2XCNT, DMAC1_EWM, DMAC1_SCM}, \ + {DMA_3ADR, DMA_3WCNT, DMA_3PAGE, DMAC1_CLFF, \ + DMAC1_CMD, DMAC1_MODE, DMAC1_MASK, DMAC1_STAT, DMAC1_REQ, \ + DMA_3HPG, DMA_3XCNT, DMAC1_EWM, DMAC1_SCM}, \ + {DMA_4ADR, DMA_4WCNT, DMA_4PAGE, DMAC2_CLFF, \ + DMAC2_CMD, DMAC2_MODE, DMAC2_MASK, DMAC2_STAT, DMAC2_REQ, \ + DMA_4HPG, DMA_4XCNT, DMAC2_EWM, DMAC2_SCM}, \ + {DMA_5ADR, DMA_5WCNT, DMA_5PAGE, DMAC2_CLFF, \ + DMAC2_CMD, DMAC2_MODE, DMAC2_MASK, DMAC2_STAT, DMAC2_REQ, \ + DMA_5HPG, DMA_5XCNT, DMAC2_EWM, DMAC2_SCM}, \ + {DMA_6ADR, DMA_6WCNT, DMA_6PAGE, DMAC2_CLFF, \ + DMAC2_CMD, DMAC2_MODE, DMAC2_MASK, DMAC2_STAT, DMAC2_REQ, \ + DMA_6HPG, DMA_6XCNT, DMAC2_EWM, DMAC2_SCM}, \ + {DMA_7ADR, DMA_7WCNT, DMA_7PAGE, DMAC2_CLFF, \ + DMAC2_CMD, DMAC2_MODE, DMAC2_MASK, DMAC2_STAT, DMAC2_REQ, \ + DMA_7HPG, DMA_7XCNT, DMAC2_EWM, DMAC2_SCM} + +extern int d37A_init(dev_info_t *); +extern void d37A_dma_disable(int); +extern void d37A_dma_enable(int); +extern void d37A_dma_swstart(int); +extern void d37A_dma_stop(int); +extern void d37A_get_chan_stat(int, ulong_t *, int *); +extern int d37A_dma_valid(int); +extern void d37A_dma_release(int); + +/* The following 3 routines are intel specific : man page ddi_dmae_req(9S) */ +#if defined(__i386) || defined(__amd64) +extern uchar_t d37A_get_best_mode(struct ddi_dmae_req *); +extern int d37A_prog_chan(struct ddi_dmae_req *, ddi_dma_cookie_t *, int); +extern int d37A_dma_swsetup(struct ddi_dmae_req *, ddi_dma_cookie_t *, int); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DMA_I8237A_H */ diff --git a/illumos-x86_64/usr/include/sys/dnlc.h b/illumos-x86_64/usr/include/sys/dnlc.h new file mode 100644 index 00000000..1a6be2be --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dnlc.h @@ -0,0 +1,383 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_DNLC_H +#define _SYS_DNLC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * DNLC - Directory name lookup cache. + * There are now two sorts of name caching: + * + * Standard dnlc: This original cache holds recent mappings + * of to vnode mappings. + * + * Directory caches: Entire large directories can be cached, subject to + * memory availability and tunables. A directory cache + * anchor point must be provided in the xxnode for + * a directory. + */ + + +/* + * Standard dnlc + * ============= + */ + +/* + * This structure describes the elements in the cache of recent + * names looked up. + * + * Note namlen is a uchar_t to conserve space + * and alignment padding. The max length of any + * pathname component is defined as MAXNAMELEN + * which is 256 (including the terminating null). + * So provided this doesn't change, we don't include the null, + * we always use bcmp to compare strings, and we don't start + * storing full names, then we are ok. The space savings are worth it. + */ +typedef struct ncache { + struct ncache *hash_next; /* hash chain, MUST BE FIRST */ + struct ncache *hash_prev; + struct vnode *vp; /* vnode the name refers to */ + struct vnode *dp; /* vnode of parent of name */ + int hash; /* hash signature */ + uchar_t namlen; /* length of name */ + char name[]; /* segment name */ +} ncache_t; + +/* + * Produce size of struct ncache with space allocated in name string. + */ +#define NCACHE_SIZE(namelen) offsetof(ncache_t, name) + (namelen) + +/* + * Hash table bucket structure of name cache entries for fast lookup. + */ +typedef struct nc_hash { + ncache_t *hash_next; + ncache_t *hash_prev; + kmutex_t hash_lock; +} nc_hash_t; + +/* + * Statistics on name cache + * Not protected by locks + */ +/* + * ncstats has been deprecated, due to the integer size of the counters + * which can easily overflow in the dnlc. + * It is maintained (at some expense) for compatability. + * The preferred interface is the kstat accessible nc_stats below, ehich + * is actually shared with directory caching. + */ +struct ncstats { + int hits; /* hits that we can really use */ + int misses; /* cache misses */ + int enters; /* number of enters done */ + int dbl_enters; /* number of enters tried when already cached */ + int long_enter; /* deprecated, no longer accounted */ + int long_look; /* deprecated, no longer accounted */ + int move_to_front; /* entry moved to front of hash chain */ + int purges; /* number of purges of cache */ +}; + +struct nc_stats { + kstat_named_t ncs_hits; /* cache hits */ + kstat_named_t ncs_misses; /* cache misses */ + kstat_named_t ncs_neg_hits; /* negative cache hits */ + kstat_named_t ncs_enters; /* enters */ + kstat_named_t ncs_dbl_enters; /* enters when entry already cached */ + kstat_named_t ncs_purge_total; /* total entries prurged */ + kstat_named_t ncs_purge_all; /* dnlc_purge() calls */ + kstat_named_t ncs_purge_vp; /* dnlc_purge_vp() calls */ + kstat_named_t ncs_purge_vfs; /* dnlc_purge_vfs() calls */ + kstat_named_t ncs_purge_fs1; /* dnlc_purge_fs1() calls */ + kstat_named_t ncs_pick_free; /* found a free ncache */ + kstat_named_t ncs_pick_heur; /* found ncache w/ NULL vpages */ + kstat_named_t ncs_pick_last; /* found last ncache on chain */ + + /* directory caching stats */ + + kstat_named_t ncs_dir_hits; /* dir cache hits */ + kstat_named_t ncs_dir_misses; /* dir cache misses */ + kstat_named_t ncs_cur_dirs; /* current # directories cached */ + kstat_named_t ncs_dir_num_ents; /* current # entries cached */ + kstat_named_t ncs_dirs_cached; /* total # directories cached */ + kstat_named_t ncs_dir_start_nm; /* dir start no memory */ + kstat_named_t ncs_dir_add_nm; /* add entry/space - no memory */ + kstat_named_t ncs_dir_addabort; /* add entry/space - abort */ + kstat_named_t ncs_dir_add_max; /* add entry/space - max exceeded */ + kstat_named_t ncs_dir_reme_fai; /* remove entry fail */ + kstat_named_t ncs_dir_rems_fai; /* remove space fail */ + kstat_named_t ncs_dir_upd_fail; /* update space fail */ + kstat_named_t ncs_dir_finipurg; /* fini purges */ + kstat_named_t ncs_dir_rec_last; /* reclaim last */ + kstat_named_t ncs_dir_recl_any; /* reclaim any */ +}; + +/* + * The dnlc hashing function. + * Although really a kernel macro we export it to allow validation + * of ncache_t entries by mdb. Note, mdb can handle the ASSERT. + * + * 'hash' and 'namlen' must be l-values. A check is made to ensure + * the name length fits into an unsigned char (see ncache_t). + */ +#define DNLCHASH(name, dvp, hash, namlen) \ + { \ + char Xc; \ + const char *Xcp; \ + hash = (int)((uintptr_t)(dvp)) >> 8; \ + for (Xcp = (name); (Xc = *Xcp) != 0; Xcp++) \ + (hash) = ((hash) << 4) + (hash) + Xc; \ + ASSERT((Xcp - (name)) <= ((1 << NBBY) - 1)); \ + (namlen) = Xcp - (name); \ + } + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +#include +#include + +extern int ncsize; /* set in param_init() # of dnlc entries */ +extern vnode_t negative_cache_vnode; +#define DNLC_NO_VNODE &negative_cache_vnode + +void dnlc_init(void); +void dnlc_enter(vnode_t *, const char *, vnode_t *); +void dnlc_update(vnode_t *, const char *, vnode_t *); +vnode_t *dnlc_lookup(vnode_t *, const char *); +void dnlc_purge(void); +void dnlc_purge_vp(vnode_t *); +int dnlc_purge_vfsp(vfs_t *, int); +void dnlc_remove(vnode_t *, const char *); +int dnlc_fs_purge1(struct vnodeops *); +void dnlc_reduce_cache(void *); + +#endif /* defined(_KERNEL) */ + + +/* + * Directory caching interfaces + * ============================ + */ + +/* + * Typically for large directories, the file names will be the same or + * at least similar lengths. So there's no point in anything more elaborate + * than a simple unordered linked list of free space entries. + * For small directories the name length distribution doesn't really matter. + */ +typedef struct dcfree { + uint64_t df_handle; /* fs supplied handle */ + struct dcfree *df_next; /* link to next free entry in bucket */ + uint_t df_len; /* length of free entry */ +} dcfree_t; + +typedef struct dcentry { + uint64_t de_handle; /* fs supplied and returned data */ + struct dcentry *de_next; /* link to next name entry in bucket */ + int de_hash; /* hash signature */ + uchar_t de_namelen; /* length of name excluding null */ + char de_name[]; /* name */ +} dcentry_t; + +/* + * Produce size of struct dcentry with space allocated in name string. + */ +#define DCENTTRY_SIZE(namelen) offsetof(dcentry_t, de_name) + (namelen) + +typedef struct dircache { + struct dircache *dc_next; /* chain - for purge purposes */ + struct dircache *dc_prev; /* chain - for purge purposes */ + int64_t dc_actime; /* dir access time, from lbolt64 */ + dcentry_t **dc_namehash; /* entry hash table pointer */ + dcfree_t **dc_freehash; /* free entry hash table pointer */ + uint_t dc_num_entries; /* no of named entries */ + uint_t dc_num_free; /* no of free space entries */ + uint_t dc_nhash_mask; /* name hash table size - 1 */ + uint_t dc_fhash_mask; /* free space hash table size - 1 */ + struct dcanchor *dc_anchor; /* back ptr to anchor */ + boolean_t dc_complete; /* cache complete boolean */ +} dircache_t; + +typedef struct dcanchor { + void *dca_dircache; /* pointer to directory cache */ + kmutex_t dca_lock; /* protects the directory cache */ +} dcanchor_t; + +/* + * Head struct for doubly linked chain of dircache_t + * The next and prev fields must match those of a dircache_t + */ +typedef struct { + dircache_t *dch_next; /* next in chain */ + dircache_t *dch_prev; /* prev in chain */ + kmutex_t dch_lock; /* lock for the chain */ +} dchead_t; + + +#if defined(_KERNEL) + +/* + * Status returns from the directory cache interfaces + */ +typedef enum { + DOK, /* operation sucessful */ + DNOCACHE, /* there is no cache */ + DFOUND, /* entry found */ + DNOENT, /* no entry found */ + DTOOBIG, /* exceeds tunable dnlc_max_dir_cache */ + DNOMEM /* no memory */ +} dcret_t; + +/* + * dnlc_dir_start() requests that a directory be cached. + * This must be called initially to enable caching on a directory. + * After a successful call, directory entries and free space can be + * added (see below) until the directory is marked complete. + * "num_entries" is an estimate of the current number of + * directory entries. The request is rejected with DNOCACHE + * if num_entries falls below the tunable dnlc_dir_min_size (see + * below), and rejected with DTOOBIG if it's above dnlc_dir_max_size. + * Returns DOK, DNOCACHE, DTOOBIG, DNOMEM. + * + * Due to memory shortages, directory caches can be purged at + * any time. If the last directory cache is purged due to memory + * shortage, then the directory cache is marked internally + * as "no memory". Future returns will all be DNOCACHE until + * the next dnlc_start_dir() which will return DNOMEM once. + * This memory shortage may only be transient. It's up to the + * file system as to what to do about this condition, but an + * attempt to immediately re-build the cache will very likely + * lead to the same shortage of memory and a thrashing situation. + * + * It's file system policy as to when and what size directories to cache. + */ +dcret_t dnlc_dir_start(dcanchor_t *dcap, uint_t num_entries); + +/* + * dnlc_dir_add_entry() adds an entry (name and handle) into a + * partial or complete cache. "handle" is a file system specific + * quantity that is returned on calls to dnlc_dir_lookup() - see below. + * For example, "handle" for ufs holds the inumber and a directory + * entry offset. Returns DOK, DNOCACHE, DTOOBIG. + */ +dcret_t dnlc_dir_add_entry(dcanchor_t *dcap, const char *name, uint64_t handle); + +/* + * dnlc_dir_add_space adds free space (length and file system specific + * handle) into a partial or complete cache. "handle" is a file + * system specific quantity that is returned on calls to + * dnlc_dir_rem_space_by_len(). For example, "handle" for ufs holds + * the directory entry offset. Returns DOK, DNOCACHE, DTOOBIG. + */ +dcret_t dnlc_dir_add_space(dcanchor_t *dcap, uint_t len, uint64_t handle); + +/* + * dnlc_dir_complete() indicates the previously partial cache is now complete. + */ +void dnlc_dir_complete(dcanchor_t *dcap); + +/* + * dnlc_dir_purge() deletes a partial or complete directory cache + */ +void dnlc_dir_purge(dcanchor_t *dcap); + +/* + * dnlc_dir_lookup() lookups a file name in a directory cache + * and returns the file system handle specified on dnlc_dir_add_entry() + * in "handlep". Returns DFOUND, DNOENT, DNOCACHE. + */ +dcret_t dnlc_dir_lookup(dcanchor_t *dcap, const char *name, uint64_t *handlep); + +/* + * dnlc_dir_update() amends the handle for an entry in a directory cache + * "handle" is the new file system specific handle for the file "name". + * Returns DFOUND, DNOENT, DNOCACHE. + */ +dcret_t dnlc_dir_update(dcanchor_t *dcap, const char *name, uint64_t handle); + +/* + * dnlc_dir_rem_entry() removes an entry form a directory cache. + * Returns the handle if "handlep" non null. + * Returns DFOUND, DNOENT, DNOCACHE. + */ +dcret_t dnlc_dir_rem_entry(dcanchor_t *dcap, const char *name, + uint64_t *handlep); + +/* + * dnlc_dir_rem_space_by_len() looks up and returns free space in a + * directory cache of at least the given "len". Returns in "handlep" + * the handle supplied when adding the free space in dnlc_dir_add_space(). + * Returns DFOUND, DNOENT, DNOCACHE. + */ +dcret_t dnlc_dir_rem_space_by_len(dcanchor_t *dcap, uint_t len, + uint64_t *handlep); + +/* + * dnlc_dir_rem_space_by_handle() looks up and removes the free space in + * a directory cache with the given handle. Returns DFOUND, DNOENT, DNOCACHE. + */ +dcret_t dnlc_dir_rem_space_by_handle(dcanchor_t *dcap, uint64_t handle); + +/* + * dnlc_dir_init() initialises a directory anchor + */ +#define dnlc_dir_init(dcap) { \ + (dcap)->dca_dircache = NULL; \ + mutex_init(&(dcap)->dca_lock, NULL, MUTEX_DEFAULT, NULL); } + +/* + * dnlc_dir_fini() is called to indicate the anchor is no longer used. + * It ensures there's no directory cache and mutex_destroys the lock + */ +void dnlc_dir_fini(dcanchor_t *dcap); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DNLC_H */ diff --git a/illumos-x86_64/usr/include/sys/door.h b/illumos-x86_64/usr/include/sys/door.h new file mode 100644 index 00000000..7d048478 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/door.h @@ -0,0 +1,333 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * The door lightweight RPC I/F. + */ + +#ifndef _SYS_DOOR_H +#define _SYS_DOOR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Attributes associated with doors. + */ + +/* Attributes originally obtained from door_create operation */ +#define DOOR_UNREF 0x01 /* Deliver an unref notification with door */ +#define DOOR_PRIVATE 0x02 /* Use a private pool of server threads */ +#define DOOR_UNREF_MULTI 0x10 /* Deliver unref notification more than once */ +#define DOOR_REFUSE_DESC 0x40 /* Do not accept descriptors from callers */ +#define DOOR_NO_CANCEL 0x80 /* No server thread cancel on client abort */ +#define DOOR_NO_DEPLETION_CB 0x100 /* No thread create callbacks on depletion */ + +/* Attributes (additional) returned with door_info and door_desc_t data */ +#define DOOR_LOCAL 0x04 /* Descriptor is local to current process */ +#define DOOR_REVOKED 0x08 /* Door has been revoked */ +#define DOOR_IS_UNREF 0x20 /* Door is currently unreferenced */ +#define DOOR_PRIVCREATE 0x200 /* Door has a private thread creation func */ +#define DOOR_DEPLETION_CB 0x400 /* Set only during depletion callbacks */ + +#if !defined(_ASM) + +#include + +#if defined(_KERNEL) +#include +#include +#include +#endif /* defined(_KERNEL) */ + +/* Basic door type information */ +typedef unsigned long long door_ptr_t; /* Handle 64 bit pointers */ +typedef unsigned long long door_id_t; /* Unique door identifier */ +typedef unsigned int door_attr_t; /* Door attributes */ + +#ifdef _KERNEL +struct __door_handle; +typedef struct __door_handle *door_handle_t; /* opaque kernel door handle */ +#endif + +#define DOOR_INVAL -1 /* An invalid door descriptor */ +#define DOOR_UNREF_DATA ((void *)1) /* Unreferenced invocation address */ + +/* Door descriptor passed to door_info to get current thread's binding */ +#define DOOR_QUERY -2 + +/* Masks of applicable flags */ +#define DOOR_CREATE_MASK (DOOR_UNREF | DOOR_PRIVATE | \ + DOOR_UNREF_MULTI | DOOR_REFUSE_DESC | DOOR_NO_CANCEL | \ + DOOR_NO_DEPLETION_CB | DOOR_PRIVCREATE) +#define DOOR_KI_CREATE_MASK (DOOR_UNREF | DOOR_UNREF_MULTI) + +/* Mask of above attributes */ +#define DOOR_ATTR_MASK (DOOR_CREATE_MASK | \ + DOOR_LOCAL | DOOR_REVOKED | DOOR_IS_UNREF) + +/* Attributes used to describe door_desc_t data */ +#define DOOR_DESCRIPTOR 0x10000 /* A file descriptor is being passed */ +#ifdef _KERNEL +#define DOOR_HANDLE 0x20000 /* A kernel door handle is being passed */ +#endif +#define DOOR_RELEASE 0x40000 /* Passed references are also released */ + +/* Misc attributes used internally */ +#define DOOR_DELAY 0x80000 /* Delayed unref delivery */ +#define DOOR_UNREF_ACTIVE 0x100000 /* Unreferenced call is active */ + +/* door parameters */ +#define DOOR_PARAM_DESC_MAX 1 /* max number of request descriptors */ +#define DOOR_PARAM_DATA_MAX 2 /* max bytes of request data */ +#define DOOR_PARAM_DATA_MIN 3 /* min bytes of request data */ + +/* + * On AMD64, 32-bit pack door_desc and door_info to avoid needing special + * copyin/copyout conversions due to differing alignment rules between + * 32-bit x86 and 64-bit amd64. + */ + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* + * Structure used to pass descriptors/objects in door invocations + */ + +typedef struct door_desc { + door_attr_t d_attributes; /* Tag for union */ + union { + /* File descriptor is passed */ + struct { + int d_descriptor; + door_id_t d_id; /* unique id */ + } d_desc; +#ifdef _KERNEL + /* Kernel passes handles referring to doors */ + door_handle_t d_handle; +#endif + /* Reserved space */ + int d_resv[5]; + } d_data; +} door_desc_t; + +/* + * Structure used to return info from door_info + */ +typedef struct door_info { + pid_t di_target; /* Server process */ + door_ptr_t di_proc; /* Server procedure */ + door_ptr_t di_data; /* Data cookie */ + door_attr_t di_attributes; /* Attributes associated with door */ + door_id_t di_uniquifier; /* Unique number */ + int di_resv[4]; /* Future use */ +} door_info_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * Structure used to return info from door_cred + */ +typedef struct door_cred { + uid_t dc_euid; /* Effective uid of client */ + gid_t dc_egid; /* Effective gid of client */ + uid_t dc_ruid; /* Real uid of client */ + gid_t dc_rgid; /* Real gid of client */ + pid_t dc_pid; /* pid of client */ + int dc_resv[4]; /* Future use */ +} door_cred_t; + +/* + * Structure used to pass/return data from door_call + * + * All fields are in/out paramters. Upon return these fields + * are updated to reflect the true location and size of the results. + */ +typedef struct door_arg { + char *data_ptr; /* Argument/result data */ + size_t data_size; /* Argument/result data size */ + door_desc_t *desc_ptr; /* Argument/result descriptors */ + uint_t desc_num; /* Argument/result num discriptors */ + char *rbuf; /* Result area */ + size_t rsize; /* Result size */ +} door_arg_t; + +#if defined(_SYSCALL32) +/* + * Structure to pass/return data from 32-bit program's door_call. + */ +typedef struct door_arg32 { + caddr32_t data_ptr; /* Argument/result data */ + size32_t data_size; /* Argument/result data size */ + caddr32_t desc_ptr; /* Argument/result descriptors */ + uint32_t desc_num; /* Argument/result num descriptors */ + caddr32_t rbuf; /* Result area */ + size32_t rsize; /* Result size */ +} door_arg32_t; +#endif + +/* + * Structure used to pass door invocation information. + */ +struct door_results { + void *cookie; + char *data_ptr; + size_t data_size; + door_desc_t *desc_ptr; + size_t desc_num; + void (*pc)(); + int nservers; /* zero if thread pool is empty */ + door_info_t *door_info; +}; + +#if defined(_SYSCALL32) +/* + * Structure used to pass door invocation information to 32-bit processes. + */ +struct door_results32 { + caddr32_t cookie; + caddr32_t data_ptr; + size32_t data_size; + caddr32_t desc_ptr; + size32_t desc_num; + caddr32_t pc; + int nservers; + caddr32_t door_info; +}; +#endif + +/* + * Structure used to pass a descriptor list to door_return. + */ +typedef struct door_return_desc { + door_desc_t *desc_ptr; + uint_t desc_num; +} door_return_desc_t; + +#if defined(_SYSCALL32) +typedef struct door_return_desc32 { + caddr32_t desc_ptr; + uint_t desc_num; +} door_return_desc32_t; +#endif + +#if defined(_KERNEL) + +/* + * Errors used for doors. Negative numbers to avoid conflicts with errnos + */ +#define DOOR_WAIT -1 /* Waiting for response */ +#define DOOR_EXIT -2 /* Server thread has exited */ + +#define VTOD(v) ((struct door_node *)(v->v_data)) +#define DTOV(d) ((d)->door_vnode) + +/* + * Underlying 'filesystem' object definition + */ +typedef struct door_node { + vnode_t *door_vnode; + struct proc *door_target; /* Proc handling this doors invoc's. */ + struct door_node *door_list; /* List of active doors in proc */ + struct door_node *door_ulist; /* Unref list */ + void (*door_pc)(); /* Door server entry point */ + void *door_data; /* Cookie passed during invocations */ + door_id_t door_index; /* Used as a uniquifier */ + door_attr_t door_flags; /* State associated with door */ + uint_t door_active; /* Number of active invocations */ + door_pool_t door_servers; /* Private pool of server threads */ + size_t door_data_max; /* param: max request data size */ + size_t door_data_min; /* param: min request data size */ + uint_t door_desc_max; /* param: max request descriptors */ + uint_t door_bound_threads; /* number of bound threads */ +} door_node_t; + +/* Test if a door has been revoked */ +#define DOOR_INVALID(dp) ((dp)->door_flags & DOOR_REVOKED) + +struct file; +int door_insert(struct file *, door_desc_t *); +int door_finish_dispatch(caddr_t); +uintptr_t door_final_sp(uintptr_t, size_t, int); +int door_upcall(vnode_t *, door_arg_t *, struct cred *, size_t, uint_t); +void door_slam(void); +void door_exit(void); +void door_revoke_all(void); +void door_deliver_unref(door_node_t *); +void door_list_delete(door_node_t *); +void door_fork(kthread_t *, kthread_t *); +void door_bind_thread(door_node_t *); +void door_unbind_thread(door_node_t *); + +extern kmutex_t door_knob; +extern kcondvar_t door_cv; +extern size_t door_max_arg; + +/* + * In-kernel doors interface. These functions are considered Sun Private + * and may change incompatibly in a minor release of Solaris. + */ +int door_ki_upcall(door_handle_t, door_arg_t *); +int door_ki_upcall_limited(door_handle_t, door_arg_t *, struct cred *, + size_t, uint_t); +int door_ki_create(void (*)(void *, door_arg_t *, + void (**)(void *, void *), void **, int *), void *, door_attr_t, + door_handle_t *); +void door_ki_hold(door_handle_t); +void door_ki_rele(door_handle_t); +int door_ki_open(char *, door_handle_t *); +int door_ki_info(door_handle_t, door_info_t *); +int door_ki_getparam(door_handle_t, int, size_t *); +int door_ki_setparam(door_handle_t, int, size_t); +door_handle_t door_ki_lookup(int did); + +#endif /* defined(_KERNEL) */ +#endif /* !defined(_ASM) */ + +/* + * System call subcodes + */ +#define DOOR_CREATE 0 +#define DOOR_REVOKE 1 +#define DOOR_INFO 2 +#define DOOR_CALL 3 +#define DOOR_BIND 6 +#define DOOR_UNBIND 7 +#define DOOR_UNREFSYS 8 +#define DOOR_UCRED 9 +#define DOOR_RETURN 10 +#define DOOR_GETPARAM 11 +#define DOOR_SETPARAM 12 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DOOR_H */ diff --git a/illumos-x86_64/usr/include/sys/door_data.h b/illumos-x86_64/usr/include/sys/door_data.h new file mode 100644 index 00000000..e394e4a5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/door_data.h @@ -0,0 +1,126 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DOOR_DATA_H +#define _SYS_DOOR_DATA_H + +#include +#include + +#if defined(_KERNEL) +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) +/* door_return() stack layout */ +typedef struct door_layout { + caddr_t dl_descp; /* start of descriptors (or 0) */ + caddr_t dl_datap; /* start of data (or 0) */ + caddr_t dl_infop; /* start of door_info_t (or 0) */ + caddr_t dl_resultsp; /* start of door_results{32}_t */ + caddr_t dl_sp; /* final stack pointer (non-biased) */ +} door_layout_t; + +/* upcall invocation information */ +typedef struct door_upcall_data { + cred_t *du_cred; /* Credential associated w/ upcall */ + size_t du_max_data; /* Maximum amount of reply data */ + uint_t du_max_descs; /* Maximum number of reply descs */ +} door_upcall_t; + +/* + * Per-thread data associated with door invocations. Each door invocation + * effects the client structure of one thread and the server structure of + * another. This way, the server thread for one door_call() can make door + * calls of its own without interference. + */ +typedef struct door_client { + door_arg_t d_args; /* Door arg/results */ + door_upcall_t *d_upcall; /* upcall information */ + caddr_t d_buf; /* Temp buffer for data transfer */ + int d_bufsize; /* Size of temp buffer */ + int d_fpp_size; /* Number of File ptrs */ + struct file **d_fpp; /* File ptrs */ + int d_error; /* Error (if any) */ + kcondvar_t d_cv; + uchar_t d_args_done; /* server has processed client's args */ + uchar_t d_hold; /* Thread needs to stick around */ + uchar_t d_noresults; /* No results allowed */ + uchar_t d_overflow; /* Result overflow occurred */ + uchar_t d_kernel; /* Kernel door server */ +} door_client_t; + +typedef struct door_server { + struct _kthread *d_caller; /* Door caller */ + struct _kthread *d_servers; /* List of door servers */ + struct door_node *d_active; /* Active door */ + struct door_node *d_pool; /* our server thread pool */ + door_layout_t d_layout; + caddr_t d_sp; /* Saved thread stack base */ + size_t d_ssize; /* Saved thread stack size */ + kcondvar_t d_cv; + uchar_t d_hold; /* Thread needs to stick around */ + uchar_t d_invbound; /* Thread is bound to invalid door */ + uchar_t d_layout_done; /* d_layout has been filled */ +} door_server_t; + +typedef struct door_data { + door_client_t d_client; + door_server_t d_server; +} door_data_t; + +#define DOOR_CLIENT(dp) (&(dp)->d_client) +#define DOOR_SERVER(dp) (&(dp)->d_server) + +/* + * Macros for holding a thread in place. Takes a door_server_t or + * door_client_t pointer as an argument. + */ +#define DOOR_T_HELD(cst) ((cst)->d_hold) + +#define DOOR_T_HOLD(cst) \ + (ASSERT(!DOOR_T_HELD(cst)), ((cst)->d_hold = 1)) +#define DOOR_T_RELEASE(cst) \ + (ASSERT(DOOR_T_HELD(cst)), ((cst)->d_hold = 0), \ + cv_broadcast(&(cst)->d_cv)) + +/* + * Roundup buffer size when passing/returning data via kernel buffer. + * This cuts down on the number of overflows that occur on return + */ +#define DOOR_ROUND 128 + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DOOR_DATA_H */ diff --git a/illumos-x86_64/usr/include/sys/door_impl.h b/illumos-x86_64/usr/include/sys/door_impl.h new file mode 100644 index 00000000..1210f8a1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/door_impl.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DOOR_IMPL_H +#define _SYS_DOOR_IMPL_H + +/* + * Common definitions for and . + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct door_pool { + struct _kthread *dp_threads; + kcondvar_t dp_cv; +} door_pool_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DOOR_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/dtrace.h b/illumos-x86_64/usr/include/sys/dtrace.h new file mode 100644 index 00000000..51ed34f2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dtrace.h @@ -0,0 +1,2349 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2018 Joyent, Inc. + * Copyright (c) 2013 by Delphix. All rights reserved. + */ + +#ifndef _SYS_DTRACE_H +#define _SYS_DTRACE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DTrace Dynamic Tracing Software: Kernel Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and DTrace subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose except those expressly outlined in dtrace(4D) and libdtrace(3LIB). + * Please refer to the "Solaris Dynamic Tracing Guide" for more information. + */ + +#ifndef _ASM + +#include +#include +#include +#include +#include +#include +#include + +/* + * DTrace Universal Constants and Typedefs + */ +#define DTRACE_CPUALL -1 /* all CPUs */ +#define DTRACE_IDNONE 0 /* invalid probe identifier */ +#define DTRACE_EPIDNONE 0 /* invalid enabled probe identifier */ +#define DTRACE_AGGIDNONE 0 /* invalid aggregation identifier */ +#define DTRACE_AGGVARIDNONE 0 /* invalid aggregation variable ID */ +#define DTRACE_CACHEIDNONE 0 /* invalid predicate cache */ +#define DTRACE_PROVNONE 0 /* invalid provider identifier */ +#define DTRACE_METAPROVNONE 0 /* invalid meta-provider identifier */ +#define DTRACE_ARGNONE -1 /* invalid argument index */ + +#define DTRACE_PROVNAMELEN 64 +#define DTRACE_MODNAMELEN 64 +#define DTRACE_FUNCNAMELEN 128 +#define DTRACE_NAMELEN 64 +#define DTRACE_FULLNAMELEN (DTRACE_PROVNAMELEN + DTRACE_MODNAMELEN + \ + DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 4) +#define DTRACE_ARGTYPELEN 128 + +typedef uint32_t dtrace_id_t; /* probe identifier */ +typedef uint32_t dtrace_epid_t; /* enabled probe identifier */ +typedef uint32_t dtrace_aggid_t; /* aggregation identifier */ +typedef int64_t dtrace_aggvarid_t; /* aggregation variable identifier */ +typedef uint16_t dtrace_actkind_t; /* action kind */ +typedef int64_t dtrace_optval_t; /* option value */ +typedef uint32_t dtrace_cacheid_t; /* predicate cache identifier */ + +typedef enum dtrace_probespec { + DTRACE_PROBESPEC_NONE = -1, + DTRACE_PROBESPEC_PROVIDER = 0, + DTRACE_PROBESPEC_MOD, + DTRACE_PROBESPEC_FUNC, + DTRACE_PROBESPEC_NAME +} dtrace_probespec_t; + +/* + * DTrace Intermediate Format (DIF) + * + * The following definitions describe the DTrace Intermediate Format (DIF), a + * a RISC-like instruction set and program encoding used to represent + * predicates and actions that can be bound to DTrace probes. The constants + * below defining the number of available registers are suggested minimums; the + * compiler should use DTRACEIOC_CONF to dynamically obtain the number of + * registers provided by the current DTrace implementation. + */ +#define DIF_VERSION_1 1 /* DIF version 1: Solaris 10 Beta */ +#define DIF_VERSION_2 2 /* DIF version 2: Solaris 10 FCS */ +#define DIF_VERSION DIF_VERSION_2 /* latest DIF instruction set version */ +#define DIF_DIR_NREGS 8 /* number of DIF integer registers */ +#define DIF_DTR_NREGS 8 /* number of DIF tuple registers */ + +#define DIF_OP_OR 1 /* or r1, r2, rd */ +#define DIF_OP_XOR 2 /* xor r1, r2, rd */ +#define DIF_OP_AND 3 /* and r1, r2, rd */ +#define DIF_OP_SLL 4 /* sll r1, r2, rd */ +#define DIF_OP_SRL 5 /* srl r1, r2, rd */ +#define DIF_OP_SUB 6 /* sub r1, r2, rd */ +#define DIF_OP_ADD 7 /* add r1, r2, rd */ +#define DIF_OP_MUL 8 /* mul r1, r2, rd */ +#define DIF_OP_SDIV 9 /* sdiv r1, r2, rd */ +#define DIF_OP_UDIV 10 /* udiv r1, r2, rd */ +#define DIF_OP_SREM 11 /* srem r1, r2, rd */ +#define DIF_OP_UREM 12 /* urem r1, r2, rd */ +#define DIF_OP_NOT 13 /* not r1, rd */ +#define DIF_OP_MOV 14 /* mov r1, rd */ +#define DIF_OP_CMP 15 /* cmp r1, r2 */ +#define DIF_OP_TST 16 /* tst r1 */ +#define DIF_OP_BA 17 /* ba label */ +#define DIF_OP_BE 18 /* be label */ +#define DIF_OP_BNE 19 /* bne label */ +#define DIF_OP_BG 20 /* bg label */ +#define DIF_OP_BGU 21 /* bgu label */ +#define DIF_OP_BGE 22 /* bge label */ +#define DIF_OP_BGEU 23 /* bgeu label */ +#define DIF_OP_BL 24 /* bl label */ +#define DIF_OP_BLU 25 /* blu label */ +#define DIF_OP_BLE 26 /* ble label */ +#define DIF_OP_BLEU 27 /* bleu label */ +#define DIF_OP_LDSB 28 /* ldsb [r1], rd */ +#define DIF_OP_LDSH 29 /* ldsh [r1], rd */ +#define DIF_OP_LDSW 30 /* ldsw [r1], rd */ +#define DIF_OP_LDUB 31 /* ldub [r1], rd */ +#define DIF_OP_LDUH 32 /* lduh [r1], rd */ +#define DIF_OP_LDUW 33 /* lduw [r1], rd */ +#define DIF_OP_LDX 34 /* ldx [r1], rd */ +#define DIF_OP_RET 35 /* ret rd */ +#define DIF_OP_NOP 36 /* nop */ +#define DIF_OP_SETX 37 /* setx intindex, rd */ +#define DIF_OP_SETS 38 /* sets strindex, rd */ +#define DIF_OP_SCMP 39 /* scmp r1, r2 */ +#define DIF_OP_LDGA 40 /* ldga var, ri, rd */ +#define DIF_OP_LDGS 41 /* ldgs var, rd */ +#define DIF_OP_STGS 42 /* stgs var, rs */ +#define DIF_OP_LDTA 43 /* ldta var, ri, rd */ +#define DIF_OP_LDTS 44 /* ldts var, rd */ +#define DIF_OP_STTS 45 /* stts var, rs */ +#define DIF_OP_SRA 46 /* sra r1, r2, rd */ +#define DIF_OP_CALL 47 /* call subr, rd */ +#define DIF_OP_PUSHTR 48 /* pushtr type, rs, rr */ +#define DIF_OP_PUSHTV 49 /* pushtv type, rs, rv */ +#define DIF_OP_POPTS 50 /* popts */ +#define DIF_OP_FLUSHTS 51 /* flushts */ +#define DIF_OP_LDGAA 52 /* ldgaa var, rd */ +#define DIF_OP_LDTAA 53 /* ldtaa var, rd */ +#define DIF_OP_STGAA 54 /* stgaa var, rs */ +#define DIF_OP_STTAA 55 /* sttaa var, rs */ +#define DIF_OP_LDLS 56 /* ldls var, rd */ +#define DIF_OP_STLS 57 /* stls var, rs */ +#define DIF_OP_ALLOCS 58 /* allocs r1, rd */ +#define DIF_OP_COPYS 59 /* copys r1, r2, rd */ +#define DIF_OP_STB 60 /* stb r1, [rd] */ +#define DIF_OP_STH 61 /* sth r1, [rd] */ +#define DIF_OP_STW 62 /* stw r1, [rd] */ +#define DIF_OP_STX 63 /* stx r1, [rd] */ +#define DIF_OP_ULDSB 64 /* uldsb [r1], rd */ +#define DIF_OP_ULDSH 65 /* uldsh [r1], rd */ +#define DIF_OP_ULDSW 66 /* uldsw [r1], rd */ +#define DIF_OP_ULDUB 67 /* uldub [r1], rd */ +#define DIF_OP_ULDUH 68 /* ulduh [r1], rd */ +#define DIF_OP_ULDUW 69 /* ulduw [r1], rd */ +#define DIF_OP_ULDX 70 /* uldx [r1], rd */ +#define DIF_OP_RLDSB 71 /* rldsb [r1], rd */ +#define DIF_OP_RLDSH 72 /* rldsh [r1], rd */ +#define DIF_OP_RLDSW 73 /* rldsw [r1], rd */ +#define DIF_OP_RLDUB 74 /* rldub [r1], rd */ +#define DIF_OP_RLDUH 75 /* rlduh [r1], rd */ +#define DIF_OP_RLDUW 76 /* rlduw [r1], rd */ +#define DIF_OP_RLDX 77 /* rldx [r1], rd */ +#define DIF_OP_XLATE 78 /* xlate xlrindex, rd */ +#define DIF_OP_XLARG 79 /* xlarg xlrindex, rd */ +#define DIF_OP_STGA 80 /* stga var, ri, rd */ + +#define DIF_INTOFF_MAX 0xffff /* highest integer table offset */ +#define DIF_STROFF_MAX 0xffff /* highest string table offset */ +#define DIF_REGISTER_MAX 0xff /* highest register number */ +#define DIF_VARIABLE_MAX 0xffff /* highest variable identifier */ +#define DIF_SUBROUTINE_MAX 0xffff /* highest subroutine code */ + +#define DIF_VAR_ARRAY_MIN 0x0000 /* lowest numbered array variable */ +#define DIF_VAR_ARRAY_UBASE 0x0080 /* lowest user-defined array */ +#define DIF_VAR_ARRAY_MAX 0x00ff /* highest numbered array variable */ + +#define DIF_VAR_OTHER_MIN 0x0100 /* lowest numbered scalar or assc */ +#define DIF_VAR_OTHER_UBASE 0x0500 /* lowest user-defined scalar or assc */ +#define DIF_VAR_OTHER_MAX 0xffff /* highest numbered scalar or assc */ + +#define DIF_VAR_ARGS 0x0000 /* arguments array */ +#define DIF_VAR_REGS 0x0001 /* registers array */ +#define DIF_VAR_UREGS 0x0002 /* user registers array */ +#define DIF_VAR_VMREGS 0x0003 /* virtual machine registers array */ +#define DIF_VAR_CURTHREAD 0x0100 /* thread pointer */ +#define DIF_VAR_TIMESTAMP 0x0101 /* timestamp */ +#define DIF_VAR_VTIMESTAMP 0x0102 /* virtual timestamp */ +#define DIF_VAR_IPL 0x0103 /* interrupt priority level */ +#define DIF_VAR_EPID 0x0104 /* enabled probe ID */ +#define DIF_VAR_ID 0x0105 /* probe ID */ +#define DIF_VAR_ARG0 0x0106 /* first argument */ +#define DIF_VAR_ARG1 0x0107 /* second argument */ +#define DIF_VAR_ARG2 0x0108 /* third argument */ +#define DIF_VAR_ARG3 0x0109 /* fourth argument */ +#define DIF_VAR_ARG4 0x010a /* fifth argument */ +#define DIF_VAR_ARG5 0x010b /* sixth argument */ +#define DIF_VAR_ARG6 0x010c /* seventh argument */ +#define DIF_VAR_ARG7 0x010d /* eighth argument */ +#define DIF_VAR_ARG8 0x010e /* ninth argument */ +#define DIF_VAR_ARG9 0x010f /* tenth argument */ +#define DIF_VAR_STACKDEPTH 0x0110 /* stack depth */ +#define DIF_VAR_CALLER 0x0111 /* caller */ +#define DIF_VAR_PROBEPROV 0x0112 /* probe provider */ +#define DIF_VAR_PROBEMOD 0x0113 /* probe module */ +#define DIF_VAR_PROBEFUNC 0x0114 /* probe function */ +#define DIF_VAR_PROBENAME 0x0115 /* probe name */ +#define DIF_VAR_PID 0x0116 /* process ID */ +#define DIF_VAR_TID 0x0117 /* (per-process) thread ID */ +#define DIF_VAR_EXECNAME 0x0118 /* name of executable */ +#define DIF_VAR_ZONENAME 0x0119 /* zone name associated with process */ +#define DIF_VAR_WALLTIMESTAMP 0x011a /* wall-clock timestamp */ +#define DIF_VAR_USTACKDEPTH 0x011b /* user-land stack depth */ +#define DIF_VAR_UCALLER 0x011c /* user-level caller */ +#define DIF_VAR_PPID 0x011d /* parent process ID */ +#define DIF_VAR_UID 0x011e /* process user ID */ +#define DIF_VAR_GID 0x011f /* process group ID */ +#define DIF_VAR_ERRNO 0x0120 /* thread errno */ +#define DIF_VAR_THREADNAME 0x0121 /* thread name */ + +#define DIF_SUBR_RAND 0 +#define DIF_SUBR_MUTEX_OWNED 1 +#define DIF_SUBR_MUTEX_OWNER 2 +#define DIF_SUBR_MUTEX_TYPE_ADAPTIVE 3 +#define DIF_SUBR_MUTEX_TYPE_SPIN 4 +#define DIF_SUBR_RW_READ_HELD 5 +#define DIF_SUBR_RW_WRITE_HELD 6 +#define DIF_SUBR_RW_ISWRITER 7 +#define DIF_SUBR_COPYIN 8 +#define DIF_SUBR_COPYINSTR 9 +#define DIF_SUBR_SPECULATION 10 +#define DIF_SUBR_PROGENYOF 11 +#define DIF_SUBR_STRLEN 12 +#define DIF_SUBR_COPYOUT 13 +#define DIF_SUBR_COPYOUTSTR 14 +#define DIF_SUBR_ALLOCA 15 +#define DIF_SUBR_BCOPY 16 +#define DIF_SUBR_COPYINTO 17 +#define DIF_SUBR_MSGDSIZE 18 +#define DIF_SUBR_MSGSIZE 19 +#define DIF_SUBR_GETMAJOR 20 +#define DIF_SUBR_GETMINOR 21 +#define DIF_SUBR_DDI_PATHNAME 22 +#define DIF_SUBR_STRJOIN 23 +#define DIF_SUBR_LLTOSTR 24 +#define DIF_SUBR_BASENAME 25 +#define DIF_SUBR_DIRNAME 26 +#define DIF_SUBR_CLEANPATH 27 +#define DIF_SUBR_STRCHR 28 +#define DIF_SUBR_STRRCHR 29 +#define DIF_SUBR_STRSTR 30 +#define DIF_SUBR_STRTOK 31 +#define DIF_SUBR_SUBSTR 32 +#define DIF_SUBR_INDEX 33 +#define DIF_SUBR_RINDEX 34 +#define DIF_SUBR_HTONS 35 +#define DIF_SUBR_HTONL 36 +#define DIF_SUBR_HTONLL 37 +#define DIF_SUBR_NTOHS 38 +#define DIF_SUBR_NTOHL 39 +#define DIF_SUBR_NTOHLL 40 +#define DIF_SUBR_INET_NTOP 41 +#define DIF_SUBR_INET_NTOA 42 +#define DIF_SUBR_INET_NTOA6 43 +#define DIF_SUBR_TOUPPER 44 +#define DIF_SUBR_TOLOWER 45 +#define DIF_SUBR_GETF 46 +#define DIF_SUBR_JSON 47 +#define DIF_SUBR_STRTOLL 48 + +#define DIF_SUBR_MAX 48 /* max subroutine value */ + +typedef uint32_t dif_instr_t; + +#define DIF_INSTR_OP(i) (((i) >> 24) & 0xff) +#define DIF_INSTR_R1(i) (((i) >> 16) & 0xff) +#define DIF_INSTR_R2(i) (((i) >> 8) & 0xff) +#define DIF_INSTR_RD(i) ((i) & 0xff) +#define DIF_INSTR_RS(i) ((i) & 0xff) +#define DIF_INSTR_LABEL(i) ((i) & 0xffffff) +#define DIF_INSTR_VAR(i) (((i) >> 8) & 0xffff) +#define DIF_INSTR_INTEGER(i) (((i) >> 8) & 0xffff) +#define DIF_INSTR_STRING(i) (((i) >> 8) & 0xffff) +#define DIF_INSTR_SUBR(i) (((i) >> 8) & 0xffff) +#define DIF_INSTR_TYPE(i) (((i) >> 16) & 0xff) +#define DIF_INSTR_XLREF(i) (((i) >> 8) & 0xffff) + +#define DIF_INSTR_FMT(op, r1, r2, d) \ + (((op) << 24) | ((r1) << 16) | ((r2) << 8) | (d)) + +#define DIF_INSTR_NOT(r1, d) (DIF_INSTR_FMT(DIF_OP_NOT, r1, 0, d)) +#define DIF_INSTR_MOV(r1, d) (DIF_INSTR_FMT(DIF_OP_MOV, r1, 0, d)) +#define DIF_INSTR_CMP(op, r1, r2) (DIF_INSTR_FMT(op, r1, r2, 0)) +#define DIF_INSTR_TST(r1) (DIF_INSTR_FMT(DIF_OP_TST, r1, 0, 0)) +#define DIF_INSTR_BRANCH(op, label) (((op) << 24) | (label)) +#define DIF_INSTR_LOAD(op, r1, d) (DIF_INSTR_FMT(op, r1, 0, d)) +#define DIF_INSTR_STORE(op, r1, d) (DIF_INSTR_FMT(op, r1, 0, d)) +#define DIF_INSTR_SETX(i, d) ((DIF_OP_SETX << 24) | ((i) << 8) | (d)) +#define DIF_INSTR_SETS(s, d) ((DIF_OP_SETS << 24) | ((s) << 8) | (d)) +#define DIF_INSTR_RET(d) (DIF_INSTR_FMT(DIF_OP_RET, 0, 0, d)) +#define DIF_INSTR_NOP (DIF_OP_NOP << 24) +#define DIF_INSTR_LDA(op, v, r, d) (DIF_INSTR_FMT(op, v, r, d)) +#define DIF_INSTR_LDV(op, v, d) (((op) << 24) | ((v) << 8) | (d)) +#define DIF_INSTR_STV(op, v, rs) (((op) << 24) | ((v) << 8) | (rs)) +#define DIF_INSTR_CALL(s, d) ((DIF_OP_CALL << 24) | ((s) << 8) | (d)) +#define DIF_INSTR_PUSHTS(op, t, r2, rs) (DIF_INSTR_FMT(op, t, r2, rs)) +#define DIF_INSTR_POPTS (DIF_OP_POPTS << 24) +#define DIF_INSTR_FLUSHTS (DIF_OP_FLUSHTS << 24) +#define DIF_INSTR_ALLOCS(r1, d) (DIF_INSTR_FMT(DIF_OP_ALLOCS, r1, 0, d)) +#define DIF_INSTR_COPYS(r1, r2, d) (DIF_INSTR_FMT(DIF_OP_COPYS, r1, r2, d)) +#define DIF_INSTR_XLATE(op, r, d) (((op) << 24) | ((r) << 8) | (d)) + +#define DIF_REG_R0 0 /* %r0 is always set to zero */ + +/* + * A DTrace Intermediate Format Type (DIF Type) is used to represent the types + * of variables, function and associative array arguments, and the return type + * for each DIF object (shown below). It contains a description of the type, + * its size in bytes, and a module identifier. + */ +typedef struct dtrace_diftype { + uint8_t dtdt_kind; /* type kind (see below) */ + uint8_t dtdt_ckind; /* type kind in CTF */ + uint8_t dtdt_flags; /* type flags (see below) */ + uint8_t dtdt_pad; /* reserved for future use */ + uint32_t dtdt_size; /* type size in bytes (unless string) */ +} dtrace_diftype_t; + +#define DIF_TYPE_CTF 0 /* type is a CTF type */ +#define DIF_TYPE_STRING 1 /* type is a D string */ + +#define DIF_TF_BYREF 0x1 /* type is passed by reference */ +#define DIF_TF_BYUREF 0x2 /* user type is passed by reference */ + +/* + * A DTrace Intermediate Format variable record is used to describe each of the + * variables referenced by a given DIF object. It contains an integer variable + * identifier along with variable scope and properties, as shown below. The + * size of this structure must be sizeof (int) aligned. + */ +typedef struct dtrace_difv { + uint32_t dtdv_name; /* variable name index in dtdo_strtab */ + uint32_t dtdv_id; /* variable reference identifier */ + uint8_t dtdv_kind; /* variable kind (see below) */ + uint8_t dtdv_scope; /* variable scope (see below) */ + uint16_t dtdv_flags; /* variable flags (see below) */ + dtrace_diftype_t dtdv_type; /* variable type (see above) */ +} dtrace_difv_t; + +#define DIFV_KIND_ARRAY 0 /* variable is an array of quantities */ +#define DIFV_KIND_SCALAR 1 /* variable is a scalar quantity */ + +#define DIFV_SCOPE_GLOBAL 0 /* variable has global scope */ +#define DIFV_SCOPE_THREAD 1 /* variable has thread scope */ +#define DIFV_SCOPE_LOCAL 2 /* variable has local scope */ + +#define DIFV_F_REF 0x1 /* variable is referenced by DIFO */ +#define DIFV_F_MOD 0x2 /* variable is written by DIFO */ + +/* + * DTrace Actions + * + * The upper byte determines the class of the action; the low bytes determines + * the specific action within that class. The classes of actions are as + * follows: + * + * [ no class ] <= May record process- or kernel-related data + * DTRACEACT_PROC <= Only records process-related data + * DTRACEACT_PROC_DESTRUCTIVE <= Potentially destructive to processes + * DTRACEACT_KERNEL <= Only records kernel-related data + * DTRACEACT_KERNEL_DESTRUCTIVE <= Potentially destructive to the kernel + * DTRACEACT_SPECULATIVE <= Speculation-related action + * DTRACEACT_AGGREGATION <= Aggregating action + */ +#define DTRACEACT_NONE 0 /* no action */ +#define DTRACEACT_DIFEXPR 1 /* action is DIF expression */ +#define DTRACEACT_EXIT 2 /* exit() action */ +#define DTRACEACT_PRINTF 3 /* printf() action */ +#define DTRACEACT_PRINTA 4 /* printa() action */ +#define DTRACEACT_LIBACT 5 /* library-controlled action */ +#define DTRACEACT_TRACEMEM 6 /* tracemem() action */ +#define DTRACEACT_TRACEMEM_DYNSIZE 7 /* dynamic tracemem() size */ + +#define DTRACEACT_PROC 0x0100 +#define DTRACEACT_USTACK (DTRACEACT_PROC + 1) +#define DTRACEACT_JSTACK (DTRACEACT_PROC + 2) +#define DTRACEACT_USYM (DTRACEACT_PROC + 3) +#define DTRACEACT_UMOD (DTRACEACT_PROC + 4) +#define DTRACEACT_UADDR (DTRACEACT_PROC + 5) + +#define DTRACEACT_PROC_DESTRUCTIVE 0x0200 +#define DTRACEACT_STOP (DTRACEACT_PROC_DESTRUCTIVE + 1) +#define DTRACEACT_RAISE (DTRACEACT_PROC_DESTRUCTIVE + 2) +#define DTRACEACT_SYSTEM (DTRACEACT_PROC_DESTRUCTIVE + 3) +#define DTRACEACT_FREOPEN (DTRACEACT_PROC_DESTRUCTIVE + 4) + +#define DTRACEACT_PROC_CONTROL 0x0300 + +#define DTRACEACT_KERNEL 0x0400 +#define DTRACEACT_STACK (DTRACEACT_KERNEL + 1) +#define DTRACEACT_SYM (DTRACEACT_KERNEL + 2) +#define DTRACEACT_MOD (DTRACEACT_KERNEL + 3) + +#define DTRACEACT_KERNEL_DESTRUCTIVE 0x0500 +#define DTRACEACT_BREAKPOINT (DTRACEACT_KERNEL_DESTRUCTIVE + 1) +#define DTRACEACT_PANIC (DTRACEACT_KERNEL_DESTRUCTIVE + 2) +#define DTRACEACT_CHILL (DTRACEACT_KERNEL_DESTRUCTIVE + 3) + +#define DTRACEACT_SPECULATIVE 0x0600 +#define DTRACEACT_SPECULATE (DTRACEACT_SPECULATIVE + 1) +#define DTRACEACT_COMMIT (DTRACEACT_SPECULATIVE + 2) +#define DTRACEACT_DISCARD (DTRACEACT_SPECULATIVE + 3) + +#define DTRACEACT_CLASS(x) ((x) & 0xff00) + +#define DTRACEACT_ISDESTRUCTIVE(x) \ + (DTRACEACT_CLASS(x) == DTRACEACT_PROC_DESTRUCTIVE || \ + DTRACEACT_CLASS(x) == DTRACEACT_KERNEL_DESTRUCTIVE) + +#define DTRACEACT_ISSPECULATIVE(x) \ + (DTRACEACT_CLASS(x) == DTRACEACT_SPECULATIVE) + +#define DTRACEACT_ISPRINTFLIKE(x) \ + ((x) == DTRACEACT_PRINTF || (x) == DTRACEACT_PRINTA || \ + (x) == DTRACEACT_SYSTEM || (x) == DTRACEACT_FREOPEN) + +/* + * DTrace Aggregating Actions + * + * These are functions f(x) for which the following is true: + * + * f(f(x_0) U f(x_1) U ... U f(x_n)) = f(x_0 U x_1 U ... U x_n) + * + * where x_n is a set of arbitrary data. Aggregating actions are in their own + * DTrace action class, DTTRACEACT_AGGREGATION. The macros provided here allow + * for easier processing of the aggregation argument and data payload for a few + * aggregating actions (notably: quantize(), lquantize(), and ustack()). + */ +#define DTRACEACT_AGGREGATION 0x0700 +#define DTRACEAGG_COUNT (DTRACEACT_AGGREGATION + 1) +#define DTRACEAGG_MIN (DTRACEACT_AGGREGATION + 2) +#define DTRACEAGG_MAX (DTRACEACT_AGGREGATION + 3) +#define DTRACEAGG_AVG (DTRACEACT_AGGREGATION + 4) +#define DTRACEAGG_SUM (DTRACEACT_AGGREGATION + 5) +#define DTRACEAGG_STDDEV (DTRACEACT_AGGREGATION + 6) +#define DTRACEAGG_QUANTIZE (DTRACEACT_AGGREGATION + 7) +#define DTRACEAGG_LQUANTIZE (DTRACEACT_AGGREGATION + 8) +#define DTRACEAGG_LLQUANTIZE (DTRACEACT_AGGREGATION + 9) + +#define DTRACEACT_ISAGG(x) \ + (DTRACEACT_CLASS(x) == DTRACEACT_AGGREGATION) + +#define DTRACE_QUANTIZE_NBUCKETS \ + (((sizeof (uint64_t) * NBBY) - 1) * 2 + 1) + +#define DTRACE_QUANTIZE_ZEROBUCKET ((sizeof (uint64_t) * NBBY) - 1) + +#define DTRACE_QUANTIZE_BUCKETVAL(buck) \ + (int64_t)((buck) < DTRACE_QUANTIZE_ZEROBUCKET ? \ + -(1LL << (DTRACE_QUANTIZE_ZEROBUCKET - 1 - (buck))) : \ + (buck) == DTRACE_QUANTIZE_ZEROBUCKET ? 0 : \ + 1LL << ((buck) - DTRACE_QUANTIZE_ZEROBUCKET - 1)) + +#define DTRACE_LQUANTIZE_STEPSHIFT 48 +#define DTRACE_LQUANTIZE_STEPMASK ((uint64_t)UINT16_MAX << 48) +#define DTRACE_LQUANTIZE_LEVELSHIFT 32 +#define DTRACE_LQUANTIZE_LEVELMASK ((uint64_t)UINT16_MAX << 32) +#define DTRACE_LQUANTIZE_BASESHIFT 0 +#define DTRACE_LQUANTIZE_BASEMASK UINT32_MAX + +#define DTRACE_LQUANTIZE_STEP(x) \ + (uint16_t)(((x) & DTRACE_LQUANTIZE_STEPMASK) >> \ + DTRACE_LQUANTIZE_STEPSHIFT) + +#define DTRACE_LQUANTIZE_LEVELS(x) \ + (uint16_t)(((x) & DTRACE_LQUANTIZE_LEVELMASK) >> \ + DTRACE_LQUANTIZE_LEVELSHIFT) + +#define DTRACE_LQUANTIZE_BASE(x) \ + (int32_t)(((x) & DTRACE_LQUANTIZE_BASEMASK) >> \ + DTRACE_LQUANTIZE_BASESHIFT) + +#define DTRACE_LLQUANTIZE_FACTORSHIFT 48 +#define DTRACE_LLQUANTIZE_FACTORMASK ((uint64_t)UINT16_MAX << 48) +#define DTRACE_LLQUANTIZE_LOWSHIFT 32 +#define DTRACE_LLQUANTIZE_LOWMASK ((uint64_t)UINT16_MAX << 32) +#define DTRACE_LLQUANTIZE_HIGHSHIFT 16 +#define DTRACE_LLQUANTIZE_HIGHMASK ((uint64_t)UINT16_MAX << 16) +#define DTRACE_LLQUANTIZE_NSTEPSHIFT 0 +#define DTRACE_LLQUANTIZE_NSTEPMASK UINT16_MAX + +#define DTRACE_LLQUANTIZE_FACTOR(x) \ + (uint16_t)(((x) & DTRACE_LLQUANTIZE_FACTORMASK) >> \ + DTRACE_LLQUANTIZE_FACTORSHIFT) + +#define DTRACE_LLQUANTIZE_LOW(x) \ + (uint16_t)(((x) & DTRACE_LLQUANTIZE_LOWMASK) >> \ + DTRACE_LLQUANTIZE_LOWSHIFT) + +#define DTRACE_LLQUANTIZE_HIGH(x) \ + (uint16_t)(((x) & DTRACE_LLQUANTIZE_HIGHMASK) >> \ + DTRACE_LLQUANTIZE_HIGHSHIFT) + +#define DTRACE_LLQUANTIZE_NSTEP(x) \ + (uint16_t)(((x) & DTRACE_LLQUANTIZE_NSTEPMASK) >> \ + DTRACE_LLQUANTIZE_NSTEPSHIFT) + +#define DTRACE_USTACK_NFRAMES(x) (uint32_t)((x) & UINT32_MAX) +#define DTRACE_USTACK_STRSIZE(x) (uint32_t)((x) >> 32) +#define DTRACE_USTACK_ARG(x, y) \ + ((((uint64_t)(y)) << 32) | ((x) & UINT32_MAX)) + +#ifndef _LP64 +#ifndef _LITTLE_ENDIAN +#define DTRACE_PTR(type, name) uint32_t name##pad; type *name +#else +#define DTRACE_PTR(type, name) type *name; uint32_t name##pad +#endif +#else +#define DTRACE_PTR(type, name) type *name +#endif + +/* + * DTrace Object Format (DOF) + * + * DTrace programs can be persistently encoded in the DOF format so that they + * may be embedded in other programs (for example, in an ELF file) or in the + * dtrace driver configuration file for use in anonymous tracing. The DOF + * format is versioned and extensible so that it can be revised and so that + * internal data structures can be modified or extended compatibly. All DOF + * structures use fixed-size types, so the 32-bit and 64-bit representations + * are identical and consumers can use either data model transparently. + * + * The file layout is structured as follows: + * + * +---------------+-------------------+----- ... ----+---- ... ------+ + * | dof_hdr_t | dof_sec_t[ ... ] | loadable | non-loadable | + * | (file header) | (section headers) | section data | section data | + * +---------------+-------------------+----- ... ----+---- ... ------+ + * |<------------ dof_hdr.dofh_loadsz --------------->| | + * |<------------ dof_hdr.dofh_filesz ------------------------------->| + * + * The file header stores meta-data including a magic number, data model for + * the instrumentation, data encoding, and properties of the DIF code within. + * The header describes its own size and the size of the section headers. By + * convention, an array of section headers follows the file header, and then + * the data for all loadable sections and unloadable sections. This permits + * consumer code to easily download the headers and all loadable data into the + * DTrace driver in one contiguous chunk, omitting other extraneous sections. + * + * The section headers describe the size, offset, alignment, and section type + * for each section. Sections are described using a set of #defines that tell + * the consumer what kind of data is expected. Sections can contain links to + * other sections by storing a dof_secidx_t, an index into the section header + * array, inside of the section data structures. The section header includes + * an entry size so that sections with data arrays can grow their structures. + * + * The DOF data itself can contain many snippets of DIF (i.e. >1 DIFOs), which + * are represented themselves as a collection of related DOF sections. This + * permits us to change the set of sections associated with a DIFO over time, + * and also permits us to encode DIFOs that contain different sets of sections. + * When a DOF section wants to refer to a DIFO, it stores the dof_secidx_t of a + * section of type DOF_SECT_DIFOHDR. This section's data is then an array of + * dof_secidx_t's which in turn denote the sections associated with this DIFO. + * + * This loose coupling of the file structure (header and sections) to the + * structure of the DTrace program itself (ECB descriptions, action + * descriptions, and DIFOs) permits activities such as relocation processing + * to occur in a single pass without having to understand D program structure. + * + * Finally, strings are always stored in ELF-style string tables along with a + * string table section index and string table offset. Therefore strings in + * DOF are always arbitrary-length and not bound to the current implementation. + */ + +#define DOF_ID_SIZE 16 /* total size of dofh_ident[] in bytes */ + +typedef struct dof_hdr { + uint8_t dofh_ident[DOF_ID_SIZE]; /* identification bytes (see below) */ + uint32_t dofh_flags; /* file attribute flags (if any) */ + uint32_t dofh_hdrsize; /* size of file header in bytes */ + uint32_t dofh_secsize; /* size of section header in bytes */ + uint32_t dofh_secnum; /* number of section headers */ + uint64_t dofh_secoff; /* file offset of section headers */ + uint64_t dofh_loadsz; /* file size of loadable portion */ + uint64_t dofh_filesz; /* file size of entire DOF file */ + uint64_t dofh_pad; /* reserved for future use */ +} dof_hdr_t; + +#define DOF_ID_MAG0 0 /* first byte of magic number */ +#define DOF_ID_MAG1 1 /* second byte of magic number */ +#define DOF_ID_MAG2 2 /* third byte of magic number */ +#define DOF_ID_MAG3 3 /* fourth byte of magic number */ +#define DOF_ID_MODEL 4 /* DOF data model (see below) */ +#define DOF_ID_ENCODING 5 /* DOF data encoding (see below) */ +#define DOF_ID_VERSION 6 /* DOF file format major version (see below) */ +#define DOF_ID_DIFVERS 7 /* DIF instruction set version */ +#define DOF_ID_DIFIREG 8 /* DIF integer registers used by compiler */ +#define DOF_ID_DIFTREG 9 /* DIF tuple registers used by compiler */ +#define DOF_ID_PAD 10 /* start of padding bytes (all zeroes) */ + +#define DOF_MAG_MAG0 0x7F /* DOF_ID_MAG[0-3] */ +#define DOF_MAG_MAG1 'D' +#define DOF_MAG_MAG2 'O' +#define DOF_MAG_MAG3 'F' + +#define DOF_MAG_STRING "\177DOF" +#define DOF_MAG_STRLEN 4 + +#define DOF_MODEL_NONE 0 /* DOF_ID_MODEL */ +#define DOF_MODEL_ILP32 1 +#define DOF_MODEL_LP64 2 + +#ifdef _LP64 +#define DOF_MODEL_NATIVE DOF_MODEL_LP64 +#else +#define DOF_MODEL_NATIVE DOF_MODEL_ILP32 +#endif + +#define DOF_ENCODE_NONE 0 /* DOF_ID_ENCODING */ +#define DOF_ENCODE_LSB 1 +#define DOF_ENCODE_MSB 2 + +#ifdef _BIG_ENDIAN +#define DOF_ENCODE_NATIVE DOF_ENCODE_MSB +#else +#define DOF_ENCODE_NATIVE DOF_ENCODE_LSB +#endif + +#define DOF_VERSION_1 1 /* DOF version 1: Solaris 10 FCS */ +#define DOF_VERSION_2 2 /* DOF version 2: Solaris Express 6/06 */ +#define DOF_VERSION DOF_VERSION_2 /* Latest DOF version */ + +#define DOF_FL_VALID 0 /* mask of all valid dofh_flags bits */ + +typedef uint32_t dof_secidx_t; /* section header table index type */ +typedef uint32_t dof_stridx_t; /* string table index type */ + +#define DOF_SECIDX_NONE (-1U) /* null value for section indices */ +#define DOF_STRIDX_NONE (-1U) /* null value for string indices */ + +typedef struct dof_sec { + uint32_t dofs_type; /* section type (see below) */ + uint32_t dofs_align; /* section data memory alignment */ + uint32_t dofs_flags; /* section flags (if any) */ + uint32_t dofs_entsize; /* size of section entry (if table) */ + uint64_t dofs_offset; /* offset of section data within file */ + uint64_t dofs_size; /* size of section data in bytes */ +} dof_sec_t; + +#define DOF_SECT_NONE 0 /* null section */ +#define DOF_SECT_COMMENTS 1 /* compiler comments */ +#define DOF_SECT_SOURCE 2 /* D program source code */ +#define DOF_SECT_ECBDESC 3 /* dof_ecbdesc_t */ +#define DOF_SECT_PROBEDESC 4 /* dof_probedesc_t */ +#define DOF_SECT_ACTDESC 5 /* dof_actdesc_t array */ +#define DOF_SECT_DIFOHDR 6 /* dof_difohdr_t (variable length) */ +#define DOF_SECT_DIF 7 /* uint32_t array of byte code */ +#define DOF_SECT_STRTAB 8 /* string table */ +#define DOF_SECT_VARTAB 9 /* dtrace_difv_t array */ +#define DOF_SECT_RELTAB 10 /* dof_relodesc_t array */ +#define DOF_SECT_TYPTAB 11 /* dtrace_diftype_t array */ +#define DOF_SECT_URELHDR 12 /* dof_relohdr_t (user relocations) */ +#define DOF_SECT_KRELHDR 13 /* dof_relohdr_t (kernel relocations) */ +#define DOF_SECT_OPTDESC 14 /* dof_optdesc_t array */ +#define DOF_SECT_PROVIDER 15 /* dof_provider_t */ +#define DOF_SECT_PROBES 16 /* dof_probe_t array */ +#define DOF_SECT_PRARGS 17 /* uint8_t array (probe arg mappings) */ +#define DOF_SECT_PROFFS 18 /* uint32_t array (probe arg offsets) */ +#define DOF_SECT_INTTAB 19 /* uint64_t array */ +#define DOF_SECT_UTSNAME 20 /* struct utsname */ +#define DOF_SECT_XLTAB 21 /* dof_xlref_t array */ +#define DOF_SECT_XLMEMBERS 22 /* dof_xlmember_t array */ +#define DOF_SECT_XLIMPORT 23 /* dof_xlator_t */ +#define DOF_SECT_XLEXPORT 24 /* dof_xlator_t */ +#define DOF_SECT_PREXPORT 25 /* dof_secidx_t array (exported objs) */ +#define DOF_SECT_PRENOFFS 26 /* uint32_t array (enabled offsets) */ + +#define DOF_SECF_LOAD 1 /* section should be loaded */ + +#define DOF_SEC_ISLOADABLE(x) \ + (((x) == DOF_SECT_ECBDESC) || ((x) == DOF_SECT_PROBEDESC) || \ + ((x) == DOF_SECT_ACTDESC) || ((x) == DOF_SECT_DIFOHDR) || \ + ((x) == DOF_SECT_DIF) || ((x) == DOF_SECT_STRTAB) || \ + ((x) == DOF_SECT_VARTAB) || ((x) == DOF_SECT_RELTAB) || \ + ((x) == DOF_SECT_TYPTAB) || ((x) == DOF_SECT_URELHDR) || \ + ((x) == DOF_SECT_KRELHDR) || ((x) == DOF_SECT_OPTDESC) || \ + ((x) == DOF_SECT_PROVIDER) || ((x) == DOF_SECT_PROBES) || \ + ((x) == DOF_SECT_PRARGS) || ((x) == DOF_SECT_PROFFS) || \ + ((x) == DOF_SECT_INTTAB) || ((x) == DOF_SECT_XLTAB) || \ + ((x) == DOF_SECT_XLMEMBERS) || ((x) == DOF_SECT_XLIMPORT) || \ + ((x) == DOF_SECT_XLIMPORT) || ((x) == DOF_SECT_XLEXPORT) || \ + ((x) == DOF_SECT_PREXPORT) || ((x) == DOF_SECT_PRENOFFS)) + +typedef struct dof_ecbdesc { + dof_secidx_t dofe_probes; /* link to DOF_SECT_PROBEDESC */ + dof_secidx_t dofe_pred; /* link to DOF_SECT_DIFOHDR */ + dof_secidx_t dofe_actions; /* link to DOF_SECT_ACTDESC */ + uint32_t dofe_pad; /* reserved for future use */ + uint64_t dofe_uarg; /* user-supplied library argument */ +} dof_ecbdesc_t; + +typedef struct dof_probedesc { + dof_secidx_t dofp_strtab; /* link to DOF_SECT_STRTAB section */ + dof_stridx_t dofp_provider; /* provider string */ + dof_stridx_t dofp_mod; /* module string */ + dof_stridx_t dofp_func; /* function string */ + dof_stridx_t dofp_name; /* name string */ + uint32_t dofp_id; /* probe identifier (or zero) */ +} dof_probedesc_t; + +typedef struct dof_actdesc { + dof_secidx_t dofa_difo; /* link to DOF_SECT_DIFOHDR */ + dof_secidx_t dofa_strtab; /* link to DOF_SECT_STRTAB section */ + uint32_t dofa_kind; /* action kind (DTRACEACT_* constant) */ + uint32_t dofa_ntuple; /* number of subsequent tuple actions */ + uint64_t dofa_arg; /* kind-specific argument */ + uint64_t dofa_uarg; /* user-supplied argument */ +} dof_actdesc_t; + +typedef struct dof_difohdr { + dtrace_diftype_t dofd_rtype; /* return type for this fragment */ + dof_secidx_t dofd_links[1]; /* variable length array of indices */ +} dof_difohdr_t; + +typedef struct dof_relohdr { + dof_secidx_t dofr_strtab; /* link to DOF_SECT_STRTAB for names */ + dof_secidx_t dofr_relsec; /* link to DOF_SECT_RELTAB for relos */ + dof_secidx_t dofr_tgtsec; /* link to section we are relocating */ +} dof_relohdr_t; + +typedef struct dof_relodesc { + dof_stridx_t dofr_name; /* string name of relocation symbol */ + uint32_t dofr_type; /* relo type (DOF_RELO_* constant) */ + uint64_t dofr_offset; /* byte offset for relocation */ + uint64_t dofr_data; /* additional type-specific data */ +} dof_relodesc_t; + +#define DOF_RELO_NONE 0 /* empty relocation entry */ +#define DOF_RELO_SETX 1 /* relocate setx value */ + +typedef struct dof_optdesc { + uint32_t dofo_option; /* option identifier */ + dof_secidx_t dofo_strtab; /* string table, if string option */ + uint64_t dofo_value; /* option value or string index */ +} dof_optdesc_t; + +typedef uint32_t dof_attr_t; /* encoded stability attributes */ + +#define DOF_ATTR(n, d, c) (((n) << 24) | ((d) << 16) | ((c) << 8)) +#define DOF_ATTR_NAME(a) (((a) >> 24) & 0xff) +#define DOF_ATTR_DATA(a) (((a) >> 16) & 0xff) +#define DOF_ATTR_CLASS(a) (((a) >> 8) & 0xff) + +typedef struct dof_provider { + dof_secidx_t dofpv_strtab; /* link to DOF_SECT_STRTAB section */ + dof_secidx_t dofpv_probes; /* link to DOF_SECT_PROBES section */ + dof_secidx_t dofpv_prargs; /* link to DOF_SECT_PRARGS section */ + dof_secidx_t dofpv_proffs; /* link to DOF_SECT_PROFFS section */ + dof_stridx_t dofpv_name; /* provider name string */ + dof_attr_t dofpv_provattr; /* provider attributes */ + dof_attr_t dofpv_modattr; /* module attributes */ + dof_attr_t dofpv_funcattr; /* function attributes */ + dof_attr_t dofpv_nameattr; /* name attributes */ + dof_attr_t dofpv_argsattr; /* args attributes */ + dof_secidx_t dofpv_prenoffs; /* link to DOF_SECT_PRENOFFS section */ +} dof_provider_t; + +typedef struct dof_probe { + uint64_t dofpr_addr; /* probe base address or offset */ + dof_stridx_t dofpr_func; /* probe function string */ + dof_stridx_t dofpr_name; /* probe name string */ + dof_stridx_t dofpr_nargv; /* native argument type strings */ + dof_stridx_t dofpr_xargv; /* translated argument type strings */ + uint32_t dofpr_argidx; /* index of first argument mapping */ + uint32_t dofpr_offidx; /* index of first offset entry */ + uint8_t dofpr_nargc; /* native argument count */ + uint8_t dofpr_xargc; /* translated argument count */ + uint16_t dofpr_noffs; /* number of offset entries for probe */ + uint32_t dofpr_enoffidx; /* index of first is-enabled offset */ + uint16_t dofpr_nenoffs; /* number of is-enabled offsets */ + uint16_t dofpr_pad1; /* reserved for future use */ + uint32_t dofpr_pad2; /* reserved for future use */ +} dof_probe_t; + +typedef struct dof_xlator { + dof_secidx_t dofxl_members; /* link to DOF_SECT_XLMEMBERS section */ + dof_secidx_t dofxl_strtab; /* link to DOF_SECT_STRTAB section */ + dof_stridx_t dofxl_argv; /* input parameter type strings */ + uint32_t dofxl_argc; /* input parameter list length */ + dof_stridx_t dofxl_type; /* output type string name */ + dof_attr_t dofxl_attr; /* output stability attributes */ +} dof_xlator_t; + +typedef struct dof_xlmember { + dof_secidx_t dofxm_difo; /* member link to DOF_SECT_DIFOHDR */ + dof_stridx_t dofxm_name; /* member name */ + dtrace_diftype_t dofxm_type; /* member type */ +} dof_xlmember_t; + +typedef struct dof_xlref { + dof_secidx_t dofxr_xlator; /* link to DOF_SECT_XLATORS section */ + uint32_t dofxr_member; /* index of referenced dof_xlmember */ + uint32_t dofxr_argn; /* index of argument for DIF_OP_XLARG */ +} dof_xlref_t; + +/* + * DTrace Intermediate Format Object (DIFO) + * + * A DIFO is used to store the compiled DIF for a D expression, its return + * type, and its string and variable tables. The string table is a single + * buffer of character data into which sets instructions and variable + * references can reference strings using a byte offset. The variable table + * is an array of dtrace_difv_t structures that describe the name and type of + * each variable and the id used in the DIF code. This structure is described + * above in the DIF section of this header file. The DIFO is used at both + * user-level (in the library) and in the kernel, but the structure is never + * passed between the two: the DOF structures form the only interface. As a + * result, the definition can change depending on the presence of _KERNEL. + */ +typedef struct dtrace_difo { + dif_instr_t *dtdo_buf; /* instruction buffer */ + uint64_t *dtdo_inttab; /* integer table (optional) */ + char *dtdo_strtab; /* string table (optional) */ + dtrace_difv_t *dtdo_vartab; /* variable table (optional) */ + uint_t dtdo_len; /* length of instruction buffer */ + uint_t dtdo_intlen; /* length of integer table */ + uint_t dtdo_strlen; /* length of string table */ + uint_t dtdo_varlen; /* length of variable table */ + dtrace_diftype_t dtdo_rtype; /* return type */ + uint_t dtdo_refcnt; /* owner reference count */ + uint_t dtdo_destructive; /* invokes destructive subroutines */ +#ifndef _KERNEL + dof_relodesc_t *dtdo_kreltab; /* kernel relocations */ + dof_relodesc_t *dtdo_ureltab; /* user relocations */ + struct dt_node **dtdo_xlmtab; /* translator references */ + uint_t dtdo_krelen; /* length of krelo table */ + uint_t dtdo_urelen; /* length of urelo table */ + uint_t dtdo_xlmlen; /* length of translator table */ +#endif +} dtrace_difo_t; + +/* + * DTrace Enabling Description Structures + * + * When DTrace is tracking the description of a DTrace enabling entity (probe, + * predicate, action, ECB, record, etc.), it does so in a description + * structure. These structures all end in "desc", and are used at both + * user-level and in the kernel -- but (with the exception of + * dtrace_probedesc_t) they are never passed between them. Typically, + * user-level will use the description structures when assembling an enabling. + * It will then distill those description structures into a DOF object (see + * above), and send it into the kernel. The kernel will again use the + * description structures to create a description of the enabling as it reads + * the DOF. When the description is complete, the enabling will be actually + * created -- turning it into the structures that represent the enabling + * instead of merely describing it. Not surprisingly, the description + * structures bear a strong resemblance to the DOF structures that act as their + * conduit. + */ +struct dtrace_predicate; + +typedef struct dtrace_probedesc { + dtrace_id_t dtpd_id; /* probe identifier */ + char dtpd_provider[DTRACE_PROVNAMELEN]; /* probe provider name */ + char dtpd_mod[DTRACE_MODNAMELEN]; /* probe module name */ + char dtpd_func[DTRACE_FUNCNAMELEN]; /* probe function name */ + char dtpd_name[DTRACE_NAMELEN]; /* probe name */ +} dtrace_probedesc_t; + +typedef struct dtrace_repldesc { + dtrace_probedesc_t dtrpd_match; /* probe descr. to match */ + dtrace_probedesc_t dtrpd_create; /* probe descr. to create */ +} dtrace_repldesc_t; + +typedef struct dtrace_preddesc { + dtrace_difo_t *dtpdd_difo; /* pointer to DIF object */ + struct dtrace_predicate *dtpdd_predicate; /* pointer to predicate */ +} dtrace_preddesc_t; + +typedef struct dtrace_actdesc { + dtrace_difo_t *dtad_difo; /* pointer to DIF object */ + struct dtrace_actdesc *dtad_next; /* next action */ + dtrace_actkind_t dtad_kind; /* kind of action */ + uint32_t dtad_ntuple; /* number in tuple */ + uint64_t dtad_arg; /* action argument */ + uint64_t dtad_uarg; /* user argument */ + int dtad_refcnt; /* reference count */ +} dtrace_actdesc_t; + +typedef struct dtrace_ecbdesc { + dtrace_actdesc_t *dted_action; /* action description(s) */ + dtrace_preddesc_t dted_pred; /* predicate description */ + dtrace_probedesc_t dted_probe; /* probe description */ + uint64_t dted_uarg; /* library argument */ + int dted_refcnt; /* reference count */ +} dtrace_ecbdesc_t; + +/* + * DTrace Metadata Description Structures + * + * DTrace separates the trace data stream from the metadata stream. The only + * metadata tokens placed in the data stream are the dtrace_rechdr_t (EPID + + * timestamp) or (in the case of aggregations) aggregation identifiers. To + * determine the structure of the data, DTrace consumers pass the token to the + * kernel, and receive in return a corresponding description of the enabled + * probe (via the dtrace_eprobedesc structure) or the aggregation (via the + * dtrace_aggdesc structure). Both of these structures are expressed in terms + * of record descriptions (via the dtrace_recdesc structure) that describe the + * exact structure of the data. Some record descriptions may also contain a + * format identifier; this additional bit of metadata can be retrieved from the + * kernel, for which a format description is returned via the dtrace_fmtdesc + * structure. Note that all four of these structures must be bitness-neutral + * to allow for a 32-bit DTrace consumer on a 64-bit kernel. + */ +typedef struct dtrace_recdesc { + dtrace_actkind_t dtrd_action; /* kind of action */ + uint32_t dtrd_size; /* size of record */ + uint32_t dtrd_offset; /* offset in ECB's data */ + uint16_t dtrd_alignment; /* required alignment */ + uint16_t dtrd_format; /* format, if any */ + uint64_t dtrd_arg; /* action argument */ + uint64_t dtrd_uarg; /* user argument */ +} dtrace_recdesc_t; + +typedef struct dtrace_eprobedesc { + dtrace_epid_t dtepd_epid; /* enabled probe ID */ + dtrace_id_t dtepd_probeid; /* probe ID */ + uint64_t dtepd_uarg; /* library argument */ + uint32_t dtepd_size; /* total size */ + int dtepd_nrecs; /* number of records */ + dtrace_recdesc_t dtepd_rec[1]; /* records themselves */ +} dtrace_eprobedesc_t; + +typedef struct dtrace_aggdesc { + DTRACE_PTR(char, dtagd_name); /* not filled in by kernel */ + dtrace_aggvarid_t dtagd_varid; /* not filled in by kernel */ + int dtagd_flags; /* not filled in by kernel */ + dtrace_aggid_t dtagd_id; /* aggregation ID */ + dtrace_epid_t dtagd_epid; /* enabled probe ID */ + uint32_t dtagd_size; /* size in bytes */ + int dtagd_nrecs; /* number of records */ + uint32_t dtagd_pad; /* explicit padding */ + dtrace_recdesc_t dtagd_rec[1]; /* record descriptions */ +} dtrace_aggdesc_t; + +typedef struct dtrace_fmtdesc { + DTRACE_PTR(char, dtfd_string); /* format string */ + int dtfd_length; /* length of format string */ + uint16_t dtfd_format; /* format identifier */ +} dtrace_fmtdesc_t; + +#define DTRACE_SIZEOF_EPROBEDESC(desc) \ + (sizeof (dtrace_eprobedesc_t) + ((desc)->dtepd_nrecs ? \ + (((desc)->dtepd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0)) + +#define DTRACE_SIZEOF_AGGDESC(desc) \ + (sizeof (dtrace_aggdesc_t) + ((desc)->dtagd_nrecs ? \ + (((desc)->dtagd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0)) + +/* + * DTrace Option Interface + * + * Run-time DTrace options are set and retrieved via DOF_SECT_OPTDESC sections + * in a DOF image. The dof_optdesc structure contains an option identifier and + * an option value. The valid option identifiers are found below; the mapping + * between option identifiers and option identifying strings is maintained at + * user-level. Note that the value of DTRACEOPT_UNSET is such that all of the + * following are potentially valid option values: all positive integers, zero + * and negative one. Some options (notably "bufpolicy" and "bufresize") take + * predefined tokens as their values; these are defined with + * DTRACEOPT_{option}_{token}. + */ +#define DTRACEOPT_BUFSIZE 0 /* buffer size */ +#define DTRACEOPT_BUFPOLICY 1 /* buffer policy */ +#define DTRACEOPT_DYNVARSIZE 2 /* dynamic variable size */ +#define DTRACEOPT_AGGSIZE 3 /* aggregation size */ +#define DTRACEOPT_SPECSIZE 4 /* speculation size */ +#define DTRACEOPT_NSPEC 5 /* number of speculations */ +#define DTRACEOPT_STRSIZE 6 /* string size */ +#define DTRACEOPT_CLEANRATE 7 /* dynvar cleaning rate */ +#define DTRACEOPT_CPU 8 /* CPU to trace */ +#define DTRACEOPT_BUFRESIZE 9 /* buffer resizing policy */ +#define DTRACEOPT_GRABANON 10 /* grab anonymous state, if any */ +#define DTRACEOPT_FLOWINDENT 11 /* indent function entry/return */ +#define DTRACEOPT_QUIET 12 /* only output explicitly traced data */ +#define DTRACEOPT_STACKFRAMES 13 /* number of stack frames */ +#define DTRACEOPT_USTACKFRAMES 14 /* number of user stack frames */ +#define DTRACEOPT_AGGRATE 15 /* aggregation snapshot rate */ +#define DTRACEOPT_SWITCHRATE 16 /* buffer switching rate */ +#define DTRACEOPT_STATUSRATE 17 /* status rate */ +#define DTRACEOPT_DESTRUCTIVE 18 /* destructive actions allowed */ +#define DTRACEOPT_STACKINDENT 19 /* output indent for stack traces */ +#define DTRACEOPT_RAWBYTES 20 /* always print bytes in raw form */ +#define DTRACEOPT_JSTACKFRAMES 21 /* number of jstack() frames */ +#define DTRACEOPT_JSTACKSTRSIZE 22 /* size of jstack() string table */ +#define DTRACEOPT_AGGSORTKEY 23 /* sort aggregations by key */ +#define DTRACEOPT_AGGSORTREV 24 /* reverse-sort aggregations */ +#define DTRACEOPT_AGGSORTPOS 25 /* agg. position to sort on */ +#define DTRACEOPT_AGGSORTKEYPOS 26 /* agg. key position to sort on */ +#define DTRACEOPT_TEMPORAL 27 /* temporally ordered output */ +#define DTRACEOPT_AGGHIST 28 /* histogram aggregation output */ +#define DTRACEOPT_AGGPACK 29 /* packed aggregation output */ +#define DTRACEOPT_AGGZOOM 30 /* zoomed aggregation scaling */ +#define DTRACEOPT_ZONE 31 /* zone in which to enable probes */ +#define DTRACEOPT_MAX 32 /* number of options */ + +#define DTRACEOPT_UNSET (dtrace_optval_t)-2 /* unset option */ + +#define DTRACEOPT_BUFPOLICY_RING 0 /* ring buffer */ +#define DTRACEOPT_BUFPOLICY_FILL 1 /* fill buffer, then stop */ +#define DTRACEOPT_BUFPOLICY_SWITCH 2 /* switch buffers */ + +#define DTRACEOPT_BUFRESIZE_AUTO 0 /* automatic resizing */ +#define DTRACEOPT_BUFRESIZE_MANUAL 1 /* manual resizing */ + +/* + * DTrace Buffer Interface + * + * In order to get a snapshot of the principal or aggregation buffer, + * user-level passes a buffer description to the kernel with the dtrace_bufdesc + * structure. This describes which CPU user-level is interested in, and + * where user-level wishes the kernel to snapshot the buffer to (the + * dtbd_data field). The kernel uses the same structure to pass back some + * information regarding the buffer: the size of data actually copied out, the + * number of drops, the number of errors, the offset of the oldest record, + * and the time of the snapshot. + * + * If the buffer policy is a "switch" policy, taking a snapshot of the + * principal buffer has the additional effect of switching the active and + * inactive buffers. Taking a snapshot of the aggregation buffer _always_ has + * the additional effect of switching the active and inactive buffers. + */ +typedef struct dtrace_bufdesc { + uint64_t dtbd_size; /* size of buffer */ + uint32_t dtbd_cpu; /* CPU or DTRACE_CPUALL */ + uint32_t dtbd_errors; /* number of errors */ + uint64_t dtbd_drops; /* number of drops */ + DTRACE_PTR(char, dtbd_data); /* data */ + uint64_t dtbd_oldest; /* offset of oldest record */ + uint64_t dtbd_timestamp; /* hrtime of snapshot */ +} dtrace_bufdesc_t; + +/* + * Each record in the buffer (dtbd_data) begins with a header that includes + * the epid and a timestamp. The timestamp is split into two 4-byte parts + * so that we do not require 8-byte alignment. + */ +typedef struct dtrace_rechdr { + dtrace_epid_t dtrh_epid; /* enabled probe id */ + uint32_t dtrh_timestamp_hi; /* high bits of hrtime_t */ + uint32_t dtrh_timestamp_lo; /* low bits of hrtime_t */ +} dtrace_rechdr_t; + +#define DTRACE_RECORD_LOAD_TIMESTAMP(dtrh) \ + ((dtrh)->dtrh_timestamp_lo + \ + ((uint64_t)(dtrh)->dtrh_timestamp_hi << 32)) + +#define DTRACE_RECORD_STORE_TIMESTAMP(dtrh, hrtime) { \ + (dtrh)->dtrh_timestamp_lo = (uint32_t)hrtime; \ + (dtrh)->dtrh_timestamp_hi = hrtime >> 32; \ +} + +/* + * DTrace Status + * + * The status of DTrace is relayed via the dtrace_status structure. This + * structure contains members to count drops other than the capacity drops + * available via the buffer interface (see above). This consists of dynamic + * drops (including capacity dynamic drops, rinsing drops and dirty drops), and + * speculative drops (including capacity speculative drops, drops due to busy + * speculative buffers and drops due to unavailable speculative buffers). + * Additionally, the status structure contains a field to indicate the number + * of "fill"-policy buffers have been filled and a boolean field to indicate + * that exit() has been called. If the dtst_exiting field is non-zero, no + * further data will be generated until tracing is stopped (at which time any + * enablings of the END action will be processed); if user-level sees that + * this field is non-zero, tracing should be stopped as soon as possible. + */ +typedef struct dtrace_status { + uint64_t dtst_dyndrops; /* dynamic drops */ + uint64_t dtst_dyndrops_rinsing; /* dyn drops due to rinsing */ + uint64_t dtst_dyndrops_dirty; /* dyn drops due to dirty */ + uint64_t dtst_specdrops; /* speculative drops */ + uint64_t dtst_specdrops_busy; /* spec drops due to busy */ + uint64_t dtst_specdrops_unavail; /* spec drops due to unavail */ + uint64_t dtst_errors; /* total errors */ + uint64_t dtst_filled; /* number of filled bufs */ + uint64_t dtst_stkstroverflows; /* stack string tab overflows */ + uint64_t dtst_dblerrors; /* errors in ERROR probes */ + char dtst_killed; /* non-zero if killed */ + char dtst_exiting; /* non-zero if exit() called */ + char dtst_pad[6]; /* pad out to 64-bit align */ +} dtrace_status_t; + +/* + * DTrace Configuration + * + * User-level may need to understand some elements of the kernel DTrace + * configuration in order to generate correct DIF. This information is + * conveyed via the dtrace_conf structure. + */ +typedef struct dtrace_conf { + uint_t dtc_difversion; /* supported DIF version */ + uint_t dtc_difintregs; /* # of DIF integer registers */ + uint_t dtc_diftupregs; /* # of DIF tuple registers */ + uint_t dtc_ctfmodel; /* CTF data model */ + uint_t dtc_pad[8]; /* reserved for future use */ +} dtrace_conf_t; + +/* + * DTrace Faults + * + * The constants below DTRACEFLT_LIBRARY indicate probe processing faults; + * constants at or above DTRACEFLT_LIBRARY indicate faults in probe + * postprocessing at user-level. Probe processing faults induce an ERROR + * probe and are replicated in unistd.d to allow users' ERROR probes to decode + * the error condition using thse symbolic labels. + */ +#define DTRACEFLT_UNKNOWN 0 /* Unknown fault */ +#define DTRACEFLT_BADADDR 1 /* Bad address */ +#define DTRACEFLT_BADALIGN 2 /* Bad alignment */ +#define DTRACEFLT_ILLOP 3 /* Illegal operation */ +#define DTRACEFLT_DIVZERO 4 /* Divide-by-zero */ +#define DTRACEFLT_NOSCRATCH 5 /* Out of scratch space */ +#define DTRACEFLT_KPRIV 6 /* Illegal kernel access */ +#define DTRACEFLT_UPRIV 7 /* Illegal user access */ +#define DTRACEFLT_TUPOFLOW 8 /* Tuple stack overflow */ +#define DTRACEFLT_BADSTACK 9 /* Bad stack */ + +#define DTRACEFLT_LIBRARY 1000 /* Library-level fault */ + +/* + * DTrace Argument Types + * + * Because it would waste both space and time, argument types do not reside + * with the probe. In order to determine argument types for args[X] + * variables, the D compiler queries for argument types on a probe-by-probe + * basis. (This optimizes for the common case that arguments are either not + * used or used in an untyped fashion.) Typed arguments are specified with a + * string of the type name in the dtragd_native member of the argument + * description structure. Typed arguments may be further translated to types + * of greater stability; the provider indicates such a translated argument by + * filling in the dtargd_xlate member with the string of the translated type. + * Finally, the provider may indicate which argument value a given argument + * maps to by setting the dtargd_mapping member -- allowing a single argument + * to map to multiple args[X] variables. + */ +typedef struct dtrace_argdesc { + dtrace_id_t dtargd_id; /* probe identifier */ + int dtargd_ndx; /* arg number (-1 iff none) */ + int dtargd_mapping; /* value mapping */ + char dtargd_native[DTRACE_ARGTYPELEN]; /* native type name */ + char dtargd_xlate[DTRACE_ARGTYPELEN]; /* translated type name */ +} dtrace_argdesc_t; + +/* + * DTrace Stability Attributes + * + * Each DTrace provider advertises the name and data stability of each of its + * probe description components, as well as its architectural dependencies. + * The D compiler can query the provider attributes (dtrace_pattr_t below) in + * order to compute the properties of an input program and report them. + */ +typedef uint8_t dtrace_stability_t; /* stability code (see attributes(7)) */ +typedef uint8_t dtrace_class_t; /* architectural dependency class */ + +#define DTRACE_STABILITY_INTERNAL 0 /* private to DTrace itself */ +#define DTRACE_STABILITY_PRIVATE 1 /* private to Sun (see docs) */ +#define DTRACE_STABILITY_OBSOLETE 2 /* scheduled for removal */ +#define DTRACE_STABILITY_EXTERNAL 3 /* not controlled by Sun */ +#define DTRACE_STABILITY_UNSTABLE 4 /* new or rapidly changing */ +#define DTRACE_STABILITY_EVOLVING 5 /* less rapidly changing */ +#define DTRACE_STABILITY_STABLE 6 /* mature interface from Sun */ +#define DTRACE_STABILITY_STANDARD 7 /* industry standard */ +#define DTRACE_STABILITY_MAX 7 /* maximum valid stability */ + +#define DTRACE_CLASS_UNKNOWN 0 /* unknown architectural dependency */ +#define DTRACE_CLASS_CPU 1 /* CPU-module-specific */ +#define DTRACE_CLASS_PLATFORM 2 /* platform-specific (uname -i) */ +#define DTRACE_CLASS_GROUP 3 /* hardware-group-specific (uname -m) */ +#define DTRACE_CLASS_ISA 4 /* ISA-specific (uname -p) */ +#define DTRACE_CLASS_COMMON 5 /* common to all systems */ +#define DTRACE_CLASS_MAX 5 /* maximum valid class */ + +#define DTRACE_PRIV_NONE 0x0000 +#define DTRACE_PRIV_KERNEL 0x0001 +#define DTRACE_PRIV_USER 0x0002 +#define DTRACE_PRIV_PROC 0x0004 +#define DTRACE_PRIV_OWNER 0x0008 +#define DTRACE_PRIV_ZONEOWNER 0x0010 + +#define DTRACE_PRIV_ALL \ + (DTRACE_PRIV_KERNEL | DTRACE_PRIV_USER | \ + DTRACE_PRIV_PROC | DTRACE_PRIV_OWNER | DTRACE_PRIV_ZONEOWNER) + +typedef struct dtrace_ppriv { + uint32_t dtpp_flags; /* privilege flags */ + uid_t dtpp_uid; /* user ID */ + zoneid_t dtpp_zoneid; /* zone ID */ +} dtrace_ppriv_t; + +typedef struct dtrace_attribute { + dtrace_stability_t dtat_name; /* entity name stability */ + dtrace_stability_t dtat_data; /* entity data stability */ + dtrace_class_t dtat_class; /* entity data dependency */ +} dtrace_attribute_t; + +typedef struct dtrace_pattr { + dtrace_attribute_t dtpa_provider; /* provider attributes */ + dtrace_attribute_t dtpa_mod; /* module attributes */ + dtrace_attribute_t dtpa_func; /* function attributes */ + dtrace_attribute_t dtpa_name; /* name attributes */ + dtrace_attribute_t dtpa_args; /* args[] attributes */ +} dtrace_pattr_t; + +typedef struct dtrace_providerdesc { + char dtvd_name[DTRACE_PROVNAMELEN]; /* provider name */ + dtrace_pattr_t dtvd_attr; /* stability attributes */ + dtrace_ppriv_t dtvd_priv; /* privileges required */ +} dtrace_providerdesc_t; + +/* + * DTrace Pseudodevice Interface + * + * DTrace is controlled through ioctl(2)'s to the in-kernel dtrace:dtrace + * pseudodevice driver. These ioctls comprise the user-kernel interface to + * DTrace. + */ +#define DTRACEIOC (('d' << 24) | ('t' << 16) | ('r' << 8)) +#define DTRACEIOC_PROVIDER (DTRACEIOC | 1) /* provider query */ +#define DTRACEIOC_PROBES (DTRACEIOC | 2) /* probe query */ +#define DTRACEIOC_BUFSNAP (DTRACEIOC | 4) /* snapshot buffer */ +#define DTRACEIOC_PROBEMATCH (DTRACEIOC | 5) /* match probes */ +#define DTRACEIOC_ENABLE (DTRACEIOC | 6) /* enable probes */ +#define DTRACEIOC_AGGSNAP (DTRACEIOC | 7) /* snapshot agg. */ +#define DTRACEIOC_EPROBE (DTRACEIOC | 8) /* get eprobe desc. */ +#define DTRACEIOC_PROBEARG (DTRACEIOC | 9) /* get probe arg */ +#define DTRACEIOC_CONF (DTRACEIOC | 10) /* get config. */ +#define DTRACEIOC_STATUS (DTRACEIOC | 11) /* get status */ +#define DTRACEIOC_GO (DTRACEIOC | 12) /* start tracing */ +#define DTRACEIOC_STOP (DTRACEIOC | 13) /* stop tracing */ +#define DTRACEIOC_AGGDESC (DTRACEIOC | 15) /* get agg. desc. */ +#define DTRACEIOC_FORMAT (DTRACEIOC | 16) /* get format str */ +#define DTRACEIOC_DOFGET (DTRACEIOC | 17) /* get DOF */ +#define DTRACEIOC_REPLICATE (DTRACEIOC | 18) /* replicate enab */ + +/* + * DTrace Helpers + * + * In general, DTrace establishes probes in processes and takes actions on + * processes without knowing their specific user-level structures. Instead of + * existing in the framework, process-specific knowledge is contained by the + * enabling D program -- which can apply process-specific knowledge by making + * appropriate use of DTrace primitives like copyin() and copyinstr() to + * operate on user-level data. However, there may exist some specific probes + * of particular semantic relevance that the application developer may wish to + * explicitly export. For example, an application may wish to export a probe + * at the point that it begins and ends certain well-defined transactions. In + * addition to providing probes, programs may wish to offer assistance for + * certain actions. For example, in highly dynamic environments (e.g., Java), + * it may be difficult to obtain a stack trace in terms of meaningful symbol + * names (the translation from instruction addresses to corresponding symbol + * names may only be possible in situ); these environments may wish to define + * a series of actions to be applied in situ to obtain a meaningful stack + * trace. + * + * These two mechanisms -- user-level statically defined tracing and assisting + * DTrace actions -- are provided via DTrace _helpers_. Helpers are specified + * via DOF, but unlike enabling DOF, helper DOF may contain definitions of + * providers, probes and their arguments. If a helper wishes to provide + * action assistance, probe descriptions and corresponding DIF actions may be + * specified in the helper DOF. For such helper actions, however, the probe + * description describes the specific helper: all DTrace helpers have the + * provider name "dtrace" and the module name "helper", and the name of the + * helper is contained in the function name (for example, the ustack() helper + * is named "ustack"). Any helper-specific name may be contained in the name + * (for example, if a helper were to have a constructor, it might be named + * "dtrace:helper::init"). Helper actions are only called when the + * action that they are helping is taken. Helper actions may only return DIF + * expressions, and may only call the following subroutines: + * + * alloca() <= Allocates memory out of the consumer's scratch space + * bcopy() <= Copies memory to scratch space + * copyin() <= Copies memory from user-level into consumer's scratch + * copyinto() <= Copies memory into a specific location in scratch + * copyinstr() <= Copies a string into a specific location in scratch + * + * Helper actions may only access the following built-in variables: + * + * curthread <= Current kthread_t pointer + * tid <= Current thread identifier + * pid <= Current process identifier + * ppid <= Parent process identifier + * uid <= Current user ID + * gid <= Current group ID + * execname <= Current executable name + * zonename <= Current zone name + * + * Helper actions may not manipulate or allocate dynamic variables, but they + * may have clause-local and statically-allocated global variables. The + * helper action variable state is specific to the helper action -- variables + * used by the helper action may not be accessed outside of the helper + * action, and the helper action may not access variables that like outside + * of it. Helper actions may not load from kernel memory at-large; they are + * restricting to loading current user state (via copyin() and variants) and + * scratch space. As with probe enablings, helper actions are executed in + * program order. The result of the helper action is the result of the last + * executing helper expression. + * + * Helpers -- composed of either providers/probes or probes/actions (or both) + * -- are added by opening the "helper" minor node, and issuing an ioctl(2) + * (DTRACEHIOC_ADDDOF) that specifies the dof_helper_t structure. This + * encapsulates the name and base address of the user-level library or + * executable publishing the helpers and probes as well as the DOF that + * contains the definitions of those helpers and probes. + * + * The DTRACEHIOC_ADD and DTRACEHIOC_REMOVE are left in place for legacy + * helpers and should no longer be used. No other ioctls are valid on the + * helper minor node. + */ +#define DTRACEHIOC (('d' << 24) | ('t' << 16) | ('h' << 8)) +#define DTRACEHIOC_ADD (DTRACEHIOC | 1) /* add helper */ +#define DTRACEHIOC_REMOVE (DTRACEHIOC | 2) /* remove helper */ +#define DTRACEHIOC_ADDDOF (DTRACEHIOC | 3) /* add helper DOF */ + +typedef struct dof_helper { + char dofhp_mod[DTRACE_MODNAMELEN]; /* executable or library name */ + uint64_t dofhp_addr; /* base address of object */ + uint64_t dofhp_dof; /* address of helper DOF */ +} dof_helper_t; + +#define DTRACEMNR_DTRACE "dtrace" /* node for DTrace ops */ +#define DTRACEMNR_HELPER "helper" /* node for helpers */ +#define DTRACEMNRN_DTRACE 0 /* minor for DTrace ops */ +#define DTRACEMNRN_HELPER 1 /* minor for helpers */ +#define DTRACEMNRN_CLONE 2 /* first clone minor */ + +#ifdef _KERNEL + +/* + * DTrace Provider API + * + * The following functions are implemented by the DTrace framework and are + * used to implement separate in-kernel DTrace providers. Common functions + * are provided in uts/common/os/dtrace.c. ISA-dependent subroutines are + * defined in uts//dtrace/dtrace_asm.s or uts//dtrace/dtrace_isa.c. + * + * The provider API has two halves: the API that the providers consume from + * DTrace, and the API that providers make available to DTrace. + * + * 1 Framework-to-Provider API + * + * 1.1 Overview + * + * The Framework-to-Provider API is represented by the dtrace_pops structure + * that the provider passes to the framework when registering itself. This + * structure consists of the following members: + * + * dtps_provide() <-- Provide all probes, all modules + * dtps_provide_module() <-- Provide all probes in specified module + * dtps_enable() <-- Enable specified probe + * dtps_disable() <-- Disable specified probe + * dtps_suspend() <-- Suspend specified probe + * dtps_resume() <-- Resume specified probe + * dtps_getargdesc() <-- Get the argument description for args[X] + * dtps_getargval() <-- Get the value for an argX or args[X] variable + * dtps_mode() <-- Return the mode of the fired probe + * dtps_destroy() <-- Destroy all state associated with this probe + * + * 1.2 void dtps_provide(void *arg, const dtrace_probedesc_t *spec) + * + * 1.2.1 Overview + * + * Called to indicate that the provider should provide all probes. If the + * specified description is non-NULL, dtps_provide() is being called because + * no probe matched a specified probe -- if the provider has the ability to + * create custom probes, it may wish to create a probe that matches the + * specified description. + * + * 1.2.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is a pointer to a probe description that the provider may + * wish to consider when creating custom probes. The provider is expected to + * call back into the DTrace framework via dtrace_probe_create() to create + * any necessary probes. dtps_provide() may be called even if the provider + * has made available all probes; the provider should check the return value + * of dtrace_probe_create() to handle this case. Note that the provider need + * not implement both dtps_provide() and dtps_provide_module(); see + * "Arguments and Notes" for dtrace_register(), below. + * + * 1.2.3 Return value + * + * None. + * + * 1.2.4 Caller's context + * + * dtps_provide() is typically called from open() or ioctl() context, but may + * be called from other contexts as well. The DTrace framework is locked in + * such a way that providers may not register or unregister. This means that + * the provider may not call any DTrace API that affects its registration with + * the framework, including dtrace_register(), dtrace_unregister(), + * dtrace_invalidate(), and dtrace_condense(). However, the context is such + * that the provider may (and indeed, is expected to) call probe-related + * DTrace routines, including dtrace_probe_create(), dtrace_probe_lookup(), + * and dtrace_probe_arg(). + * + * 1.3 void dtps_provide_module(void *arg, struct modctl *mp) + * + * 1.3.1 Overview + * + * Called to indicate that the provider should provide all probes in the + * specified module. + * + * 1.3.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is a pointer to a modctl structure that indicates the + * module for which probes should be created. + * + * 1.3.3 Return value + * + * None. + * + * 1.3.4 Caller's context + * + * dtps_provide_module() may be called from open() or ioctl() context, but + * may also be called from a module loading context. mod_lock is held, and + * the DTrace framework is locked in such a way that providers may not + * register or unregister. This means that the provider may not call any + * DTrace API that affects its registration with the framework, including + * dtrace_register(), dtrace_unregister(), dtrace_invalidate(), and + * dtrace_condense(). However, the context is such that the provider may (and + * indeed, is expected to) call probe-related DTrace routines, including + * dtrace_probe_create(), dtrace_probe_lookup(), and dtrace_probe_arg(). Note + * that the provider need not implement both dtps_provide() and + * dtps_provide_module(); see "Arguments and Notes" for dtrace_register(), + * below. + * + * 1.4 int dtps_enable(void *arg, dtrace_id_t id, void *parg) + * + * 1.4.1 Overview + * + * Called to enable the specified probe. + * + * 1.4.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is the identifier of the probe to be enabled. The third + * argument is the probe argument as passed to dtrace_probe_create(). + * dtps_enable() will be called when a probe transitions from not being + * enabled at all to having one or more ECB. The number of ECBs associated + * with the probe may change without subsequent calls into the provider. + * When the number of ECBs drops to zero, the provider will be explicitly + * told to disable the probe via dtps_disable(). dtrace_probe() should never + * be called for a probe identifier that hasn't been explicitly enabled via + * dtps_enable(). + * + * 1.4.3 Return value + * + * On success, dtps_enable() should return 0. On failure, -1 should be + * returned. + * + * 1.4.4 Caller's context + * + * The DTrace framework is locked in such a way that it may not be called + * back into at all. cpu_lock is held. mod_lock is not held and may not + * be acquired. + * + * 1.5 void dtps_disable(void *arg, dtrace_id_t id, void *parg) + * + * 1.5.1 Overview + * + * Called to disable the specified probe. + * + * 1.5.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is the identifier of the probe to be disabled. The third + * argument is the probe argument as passed to dtrace_probe_create(). + * dtps_disable() will be called when a probe transitions from being enabled + * to having zero ECBs. dtrace_probe() should never be called for a probe + * identifier that has been explicitly disabled via dtps_disable(). + * + * 1.5.3 Return value + * + * None. + * + * 1.5.4 Caller's context + * + * The DTrace framework is locked in such a way that it may not be called + * back into at all. cpu_lock is held. mod_lock is not held and may not + * be acquired. + * + * 1.6 void dtps_suspend(void *arg, dtrace_id_t id, void *parg) + * + * 1.6.1 Overview + * + * Called to suspend the specified enabled probe. This entry point is for + * providers that may need to suspend some or all of their probes when CPUs + * are being powered on or when the boot monitor is being entered for a + * prolonged period of time. + * + * 1.6.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is the identifier of the probe to be suspended. The + * third argument is the probe argument as passed to dtrace_probe_create(). + * dtps_suspend will only be called on an enabled probe. Providers that + * provide a dtps_suspend entry point will want to take roughly the action + * that it takes for dtps_disable. + * + * 1.6.3 Return value + * + * None. + * + * 1.6.4 Caller's context + * + * Interrupts are disabled. The DTrace framework is in a state such that the + * specified probe cannot be disabled or destroyed for the duration of + * dtps_suspend(). As interrupts are disabled, the provider is afforded + * little latitude; the provider is expected to do no more than a store to + * memory. + * + * 1.7 void dtps_resume(void *arg, dtrace_id_t id, void *parg) + * + * 1.7.1 Overview + * + * Called to resume the specified enabled probe. This entry point is for + * providers that may need to resume some or all of their probes after the + * completion of an event that induced a call to dtps_suspend(). + * + * 1.7.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is the identifier of the probe to be resumed. The + * third argument is the probe argument as passed to dtrace_probe_create(). + * dtps_resume will only be called on an enabled probe. Providers that + * provide a dtps_resume entry point will want to take roughly the action + * that it takes for dtps_enable. + * + * 1.7.3 Return value + * + * None. + * + * 1.7.4 Caller's context + * + * Interrupts are disabled. The DTrace framework is in a state such that the + * specified probe cannot be disabled or destroyed for the duration of + * dtps_resume(). As interrupts are disabled, the provider is afforded + * little latitude; the provider is expected to do no more than a store to + * memory. + * + * 1.8 void dtps_getargdesc(void *arg, dtrace_id_t id, void *parg, + * dtrace_argdesc_t *desc) + * + * 1.8.1 Overview + * + * Called to retrieve the argument description for an args[X] variable. + * + * 1.8.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is the identifier of the current probe. The third + * argument is the probe argument as passed to dtrace_probe_create(). The + * fourth argument is a pointer to the argument description. This + * description is both an input and output parameter: it contains the + * index of the desired argument in the dtargd_ndx field, and expects + * the other fields to be filled in upon return. If there is no argument + * corresponding to the specified index, the dtargd_ndx field should be set + * to DTRACE_ARGNONE. + * + * 1.8.3 Return value + * + * None. The dtargd_ndx, dtargd_native, dtargd_xlate and dtargd_mapping + * members of the dtrace_argdesc_t structure are all output values. + * + * 1.8.4 Caller's context + * + * dtps_getargdesc() is called from ioctl() context. mod_lock is held, and + * the DTrace framework is locked in such a way that providers may not + * register or unregister. This means that the provider may not call any + * DTrace API that affects its registration with the framework, including + * dtrace_register(), dtrace_unregister(), dtrace_invalidate(), and + * dtrace_condense(). + * + * 1.9 uint64_t dtps_getargval(void *arg, dtrace_id_t id, void *parg, + * int argno, int aframes) + * + * 1.9.1 Overview + * + * Called to retrieve a value for an argX or args[X] variable. + * + * 1.9.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is the identifier of the current probe. The third + * argument is the probe argument as passed to dtrace_probe_create(). The + * fourth argument is the number of the argument (the X in the example in + * 1.9.1). The fifth argument is the number of stack frames that were used + * to get from the actual place in the code that fired the probe to + * dtrace_probe() itself, the so-called artificial frames. This argument may + * be used to descend an appropriate number of frames to find the correct + * values. If this entry point is left NULL, the dtrace_getarg() built-in + * function is used. + * + * 1.9.3 Return value + * + * The value of the argument. + * + * 1.9.4 Caller's context + * + * This is called from within dtrace_probe() meaning that interrupts + * are disabled. No locks should be taken within this entry point. + * + * 1.10 int dtps_mode(void *arg, dtrace_id_t id, void *parg) + * + * 1.10.1 Overview + * + * Called to determine the mode of a fired probe. + * + * 1.10.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is the identifier of the current probe. The third + * argument is the probe argument as passed to dtrace_probe_create(). This + * entry point must not be left NULL for providers whose probes allow for + * mixed mode tracing, that is to say those unanchored probes that can fire + * during kernel- or user-mode execution. + * + * 1.10.3 Return value + * + * A bitwise OR that encapsulates both the mode (either DTRACE_MODE_KERNEL + * or DTRACE_MODE_USER) and the policy when the privilege of the enabling + * is insufficient for that mode (a combination of DTRACE_MODE_NOPRIV_DROP, + * DTRACE_MODE_NOPRIV_RESTRICT, and DTRACE_MODE_LIMITEDPRIV_RESTRICT). If + * DTRACE_MODE_NOPRIV_DROP bit is set, insufficient privilege will result + * in the probe firing being silently ignored for the enabling; if the + * DTRACE_NODE_NOPRIV_RESTRICT bit is set, insufficient privilege will not + * prevent probe processing for the enabling, but restrictions will be in + * place that induce a UPRIV fault upon attempt to examine probe arguments + * or current process state. If the DTRACE_MODE_LIMITEDPRIV_RESTRICT bit + * is set, similar restrictions will be placed upon operation if the + * privilege is sufficient to process the enabling, but does not otherwise + * entitle the enabling to all zones. The DTRACE_MODE_NOPRIV_DROP and + * DTRACE_MODE_NOPRIV_RESTRICT are mutually exclusive (and one of these + * two policies must be specified), but either may be combined (or not) + * with DTRACE_MODE_LIMITEDPRIV_RESTRICT. + * + * 1.10.4 Caller's context + * + * This is called from within dtrace_probe() meaning that interrupts + * are disabled. No locks should be taken within this entry point. + * + * 1.11 void dtps_destroy(void *arg, dtrace_id_t id, void *parg) + * + * 1.11.1 Overview + * + * Called to destroy the specified probe. + * + * 1.11.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_register(). The + * second argument is the identifier of the probe to be destroyed. The third + * argument is the probe argument as passed to dtrace_probe_create(). The + * provider should free all state associated with the probe. The framework + * guarantees that dtps_destroy() is only called for probes that have either + * been disabled via dtps_disable() or were never enabled via dtps_enable(). + * Once dtps_disable() has been called for a probe, no further call will be + * made specifying the probe. + * + * 1.11.3 Return value + * + * None. + * + * 1.11.4 Caller's context + * + * The DTrace framework is locked in such a way that it may not be called + * back into at all. mod_lock is held. cpu_lock is not held, and may not be + * acquired. + * + * + * 2 Provider-to-Framework API + * + * 2.1 Overview + * + * The Provider-to-Framework API provides the mechanism for the provider to + * register itself with the DTrace framework, to create probes, to lookup + * probes and (most importantly) to fire probes. The Provider-to-Framework + * consists of: + * + * dtrace_register() <-- Register a provider with the DTrace framework + * dtrace_unregister() <-- Remove a provider's DTrace registration + * dtrace_invalidate() <-- Invalidate the specified provider + * dtrace_condense() <-- Remove a provider's unenabled probes + * dtrace_attached() <-- Indicates whether or not DTrace has attached + * dtrace_probe_create() <-- Create a DTrace probe + * dtrace_probe_lookup() <-- Lookup a DTrace probe based on its name + * dtrace_probe_arg() <-- Return the probe argument for a specific probe + * dtrace_probe() <-- Fire the specified probe + * + * 2.2 int dtrace_register(const char *name, const dtrace_pattr_t *pap, + * uint32_t priv, cred_t *cr, const dtrace_pops_t *pops, void *arg, + * dtrace_provider_id_t *idp) + * + * 2.2.1 Overview + * + * dtrace_register() registers the calling provider with the DTrace + * framework. It should generally be called by DTrace providers in their + * attach(9E) entry point. + * + * 2.2.2 Arguments and Notes + * + * The first argument is the name of the provider. The second argument is a + * pointer to the stability attributes for the provider. The third argument + * is the privilege flags for the provider, and must be some combination of: + * + * DTRACE_PRIV_NONE <= All users may enable probes from this provider + * + * DTRACE_PRIV_PROC <= Any user with privilege of PRIV_DTRACE_PROC may + * enable probes from this provider + * + * DTRACE_PRIV_USER <= Any user with privilege of PRIV_DTRACE_USER may + * enable probes from this provider + * + * DTRACE_PRIV_KERNEL <= Any user with privilege of PRIV_DTRACE_KERNEL + * may enable probes from this provider + * + * DTRACE_PRIV_OWNER <= This flag places an additional constraint on + * the privilege requirements above. These probes + * require either (a) a user ID matching the user + * ID of the cred passed in the fourth argument + * or (b) the PRIV_PROC_OWNER privilege. + * + * DTRACE_PRIV_ZONEOWNER<= This flag places an additional constraint on + * the privilege requirements above. These probes + * require either (a) a zone ID matching the zone + * ID of the cred passed in the fourth argument + * or (b) the PRIV_PROC_ZONE privilege. + * + * Note that these flags designate the _visibility_ of the probes, not + * the conditions under which they may or may not fire. + * + * The fourth argument is the credential that is associated with the + * provider. This argument should be NULL if the privilege flags don't + * include DTRACE_PRIV_OWNER or DTRACE_PRIV_ZONEOWNER. If non-NULL, the + * framework stashes the uid and zoneid represented by this credential + * for use at probe-time, in implicit predicates. These limit visibility + * of the probes to users and/or zones which have sufficient privilege to + * access them. + * + * The fifth argument is a DTrace provider operations vector, which provides + * the implementation for the Framework-to-Provider API. (See Section 1, + * above.) This must be non-NULL, and each member must be non-NULL. The + * exceptions to this are (1) the dtps_provide() and dtps_provide_module() + * members (if the provider so desires, _one_ of these members may be left + * NULL -- denoting that the provider only implements the other) and (2) + * the dtps_suspend() and dtps_resume() members, which must either both be + * NULL or both be non-NULL. + * + * The sixth argument is a cookie to be specified as the first argument for + * each function in the Framework-to-Provider API. This argument may have + * any value. + * + * The final argument is a pointer to dtrace_provider_id_t. If + * dtrace_register() successfully completes, the provider identifier will be + * stored in the memory pointed to be this argument. This argument must be + * non-NULL. + * + * 2.2.3 Return value + * + * On success, dtrace_register() returns 0 and stores the new provider's + * identifier into the memory pointed to by the idp argument. On failure, + * dtrace_register() returns an errno: + * + * EINVAL The arguments passed to dtrace_register() were somehow invalid. + * This may because a parameter that must be non-NULL was NULL, + * because the name was invalid (either empty or an illegal + * provider name) or because the attributes were invalid. + * + * No other failure code is returned. + * + * 2.2.4 Caller's context + * + * dtrace_register() may induce calls to dtrace_provide(); the provider must + * hold no locks across dtrace_register() that may also be acquired by + * dtrace_provide(). cpu_lock and mod_lock must not be held. + * + * 2.3 int dtrace_unregister(dtrace_provider_t id) + * + * 2.3.1 Overview + * + * Unregisters the specified provider from the DTrace framework. It should + * generally be called by DTrace providers in their detach(9E) entry point. + * + * 2.3.2 Arguments and Notes + * + * The only argument is the provider identifier, as returned from a + * successful call to dtrace_register(). As a result of calling + * dtrace_unregister(), the DTrace framework will call back into the provider + * via the dtps_destroy() entry point. Once dtrace_unregister() successfully + * completes, however, the DTrace framework will no longer make calls through + * the Framework-to-Provider API. + * + * 2.3.3 Return value + * + * On success, dtrace_unregister returns 0. On failure, dtrace_unregister() + * returns an errno: + * + * EBUSY There are currently processes that have the DTrace pseudodevice + * open, or there exists an anonymous enabling that hasn't yet + * been claimed. + * + * No other failure code is returned. + * + * 2.3.4 Caller's context + * + * Because a call to dtrace_unregister() may induce calls through the + * Framework-to-Provider API, the caller may not hold any lock across + * dtrace_register() that is also acquired in any of the Framework-to- + * Provider API functions. Additionally, mod_lock may not be held. + * + * 2.4 void dtrace_invalidate(dtrace_provider_id_t id) + * + * 2.4.1 Overview + * + * Invalidates the specified provider. All subsequent probe lookups for the + * specified provider will fail, but its probes will not be removed. + * + * 2.4.2 Arguments and note + * + * The only argument is the provider identifier, as returned from a + * successful call to dtrace_register(). In general, a provider's probes + * always remain valid; dtrace_invalidate() is a mechanism for invalidating + * an entire provider, regardless of whether or not probes are enabled or + * not. Note that dtrace_invalidate() will _not_ prevent already enabled + * probes from firing -- it will merely prevent any new enablings of the + * provider's probes. + * + * 2.5 int dtrace_condense(dtrace_provider_id_t id) + * + * 2.5.1 Overview + * + * Removes all the unenabled probes for the given provider. This function is + * not unlike dtrace_unregister(), except that it doesn't remove the + * provider just as many of its associated probes as it can. + * + * 2.5.2 Arguments and Notes + * + * As with dtrace_unregister(), the sole argument is the provider identifier + * as returned from a successful call to dtrace_register(). As a result of + * calling dtrace_condense(), the DTrace framework will call back into the + * given provider's dtps_destroy() entry point for each of the provider's + * unenabled probes. + * + * 2.5.3 Return value + * + * Currently, dtrace_condense() always returns 0. However, consumers of this + * function should check the return value as appropriate; its behavior may + * change in the future. + * + * 2.5.4 Caller's context + * + * As with dtrace_unregister(), the caller may not hold any lock across + * dtrace_condense() that is also acquired in the provider's entry points. + * Also, mod_lock may not be held. + * + * 2.6 int dtrace_attached() + * + * 2.6.1 Overview + * + * Indicates whether or not DTrace has attached. + * + * 2.6.2 Arguments and Notes + * + * For most providers, DTrace makes initial contact beyond registration. + * That is, once a provider has registered with DTrace, it waits to hear + * from DTrace to create probes. However, some providers may wish to + * proactively create probes without first being told by DTrace to do so. + * If providers wish to do this, they must first call dtrace_attached() to + * determine if DTrace itself has attached. If dtrace_attached() returns 0, + * the provider must not make any other Provider-to-Framework API call. + * + * 2.6.3 Return value + * + * dtrace_attached() returns 1 if DTrace has attached, 0 otherwise. + * + * 2.7 int dtrace_probe_create(dtrace_provider_t id, const char *mod, + * const char *func, const char *name, int aframes, void *arg) + * + * 2.7.1 Overview + * + * Creates a probe with specified module name, function name, and name. + * + * 2.7.2 Arguments and Notes + * + * The first argument is the provider identifier, as returned from a + * successful call to dtrace_register(). The second, third, and fourth + * arguments are the module name, function name, and probe name, + * respectively. Of these, module name and function name may both be NULL + * (in which case the probe is considered to be unanchored), or they may both + * be non-NULL. The name must be non-NULL, and must point to a non-empty + * string. + * + * The fifth argument is the number of artificial stack frames that will be + * found on the stack when dtrace_probe() is called for the new probe. These + * artificial frames will be automatically be pruned should the stack() or + * stackdepth() functions be called as part of one of the probe's ECBs. If + * the parameter doesn't add an artificial frame, this parameter should be + * zero. + * + * The final argument is a probe argument that will be passed back to the + * provider when a probe-specific operation is called. (e.g., via + * dtps_enable(), dtps_disable(), etc.) + * + * Note that it is up to the provider to be sure that the probe that it + * creates does not already exist -- if the provider is unsure of the probe's + * existence, it should assure its absence with dtrace_probe_lookup() before + * calling dtrace_probe_create(). + * + * 2.7.3 Return value + * + * dtrace_probe_create() always succeeds, and always returns the identifier + * of the newly-created probe. + * + * 2.7.4 Caller's context + * + * While dtrace_probe_create() is generally expected to be called from + * dtps_provide() and/or dtps_provide_module(), it may be called from other + * non-DTrace contexts. Neither cpu_lock nor mod_lock may be held. + * + * 2.8 dtrace_id_t dtrace_probe_lookup(dtrace_provider_t id, const char *mod, + * const char *func, const char *name) + * + * 2.8.1 Overview + * + * Looks up a probe based on provdider and one or more of module name, + * function name and probe name. + * + * 2.8.2 Arguments and Notes + * + * The first argument is the provider identifier, as returned from a + * successful call to dtrace_register(). The second, third, and fourth + * arguments are the module name, function name, and probe name, + * respectively. Any of these may be NULL; dtrace_probe_lookup() will return + * the identifier of the first probe that is provided by the specified + * provider and matches all of the non-NULL matching criteria. + * dtrace_probe_lookup() is generally used by a provider to be check the + * existence of a probe before creating it with dtrace_probe_create(). + * + * 2.8.3 Return value + * + * If the probe exists, returns its identifier. If the probe does not exist, + * return DTRACE_IDNONE. + * + * 2.8.4 Caller's context + * + * While dtrace_probe_lookup() is generally expected to be called from + * dtps_provide() and/or dtps_provide_module(), it may also be called from + * other non-DTrace contexts. Neither cpu_lock nor mod_lock may be held. + * + * 2.9 void *dtrace_probe_arg(dtrace_provider_t id, dtrace_id_t probe) + * + * 2.9.1 Overview + * + * Returns the probe argument associated with the specified probe. + * + * 2.9.2 Arguments and Notes + * + * The first argument is the provider identifier, as returned from a + * successful call to dtrace_register(). The second argument is a probe + * identifier, as returned from dtrace_probe_lookup() or + * dtrace_probe_create(). This is useful if a probe has multiple + * provider-specific components to it: the provider can create the probe + * once with provider-specific state, and then add to the state by looking + * up the probe based on probe identifier. + * + * 2.9.3 Return value + * + * Returns the argument associated with the specified probe. If the + * specified probe does not exist, or if the specified probe is not provided + * by the specified provider, NULL is returned. + * + * 2.9.4 Caller's context + * + * While dtrace_probe_arg() is generally expected to be called from + * dtps_provide() and/or dtps_provide_module(), it may also be called from + * other non-DTrace contexts. Neither cpu_lock nor mod_lock may be held. + * + * 2.10 void dtrace_probe(dtrace_id_t probe, uintptr_t arg0, uintptr_t arg1, + * uintptr_t arg2, uintptr_t arg3, uintptr_t arg4) + * + * 2.10.1 Overview + * + * The epicenter of DTrace: fires the specified probes with the specified + * arguments. + * + * 2.10.2 Arguments and Notes + * + * The first argument is a probe identifier as returned by + * dtrace_probe_create() or dtrace_probe_lookup(). The second through sixth + * arguments are the values to which the D variables "arg0" through "arg4" + * will be mapped. + * + * dtrace_probe() should be called whenever the specified probe has fired -- + * however the provider defines it. + * + * 2.10.3 Return value + * + * None. + * + * 2.10.4 Caller's context + * + * dtrace_probe() may be called in virtually any context: kernel, user, + * interrupt, high-level interrupt, with arbitrary adaptive locks held, with + * dispatcher locks held, with interrupts disabled, etc. The only latitude + * that must be afforded to DTrace is the ability to make calls within + * itself (and to its in-kernel subroutines) and the ability to access + * arbitrary (but mapped) memory. On some platforms, this constrains + * context. For example, on UltraSPARC, dtrace_probe() cannot be called + * from any context in which TL is greater than zero. dtrace_probe() may + * also not be called from any routine which may be called by dtrace_probe() + * -- which includes functions in the DTrace framework and some in-kernel + * DTrace subroutines. All such functions "dtrace_"; providers that + * instrument the kernel arbitrarily should be sure to not instrument these + * routines. + */ +typedef struct dtrace_pops { + void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec); + void (*dtps_provide_module)(void *arg, struct modctl *mp); + int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg); + void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg); + void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg); + void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg); + void (*dtps_getargdesc)(void *arg, dtrace_id_t id, void *parg, + dtrace_argdesc_t *desc); + uint64_t (*dtps_getargval)(void *arg, dtrace_id_t id, void *parg, + int argno, int aframes); + int (*dtps_mode)(void *arg, dtrace_id_t id, void *parg); + void (*dtps_destroy)(void *arg, dtrace_id_t id, void *parg); +} dtrace_pops_t; + +#define DTRACE_MODE_KERNEL 0x01 +#define DTRACE_MODE_USER 0x02 +#define DTRACE_MODE_NOPRIV_DROP 0x10 +#define DTRACE_MODE_NOPRIV_RESTRICT 0x20 +#define DTRACE_MODE_LIMITEDPRIV_RESTRICT 0x40 + +typedef uintptr_t dtrace_provider_id_t; + +extern int dtrace_register(const char *, const dtrace_pattr_t *, uint32_t, + cred_t *, const dtrace_pops_t *, void *, dtrace_provider_id_t *); +extern int dtrace_unregister(dtrace_provider_id_t); +extern int dtrace_condense(dtrace_provider_id_t); +extern void dtrace_invalidate(dtrace_provider_id_t); +extern dtrace_id_t dtrace_probe_lookup(dtrace_provider_id_t, const char *, + const char *, const char *); +extern dtrace_id_t dtrace_probe_create(dtrace_provider_id_t, const char *, + const char *, const char *, int, void *); +extern void *dtrace_probe_arg(dtrace_provider_id_t, dtrace_id_t); +extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1, + uintptr_t arg2, uintptr_t arg3, uintptr_t arg4); + +/* + * DTrace Meta Provider API + * + * The following functions are implemented by the DTrace framework and are + * used to implement meta providers. Meta providers plug into the DTrace + * framework and are used to instantiate new providers on the fly. At + * present, there is only one type of meta provider and only one meta + * provider may be registered with the DTrace framework at a time. The + * sole meta provider type provides user-land static tracing facilities + * by taking meta probe descriptions and adding a corresponding provider + * into the DTrace framework. + * + * 1 Framework-to-Provider + * + * 1.1 Overview + * + * The Framework-to-Provider API is represented by the dtrace_mops structure + * that the meta provider passes to the framework when registering itself as + * a meta provider. This structure consists of the following members: + * + * dtms_create_probe() <-- Add a new probe to a created provider + * dtms_provide_pid() <-- Create a new provider for a given process + * dtms_remove_pid() <-- Remove a previously created provider + * + * 1.2 void dtms_create_probe(void *arg, void *parg, + * dtrace_helper_probedesc_t *probedesc); + * + * 1.2.1 Overview + * + * Called by the DTrace framework to create a new probe in a provider + * created by this meta provider. + * + * 1.2.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_meta_register(). + * The second argument is the provider cookie for the associated provider; + * this is obtained from the return value of dtms_provide_pid(). The third + * argument is the helper probe description. + * + * 1.2.3 Return value + * + * None + * + * 1.2.4 Caller's context + * + * dtms_create_probe() is called from either ioctl() or module load context + * in the context of a newly-created provider (that is, a provider that + * is a result of a call to dtms_provide_pid()). The DTrace framework is + * locked in such a way that meta providers may not register or unregister, + * such that no other thread can call into a meta provider operation and that + * atomicity is assured with respect to meta provider operations across + * dtms_provide_pid() and subsequent calls to dtms_create_probe(). + * The context is thus effectively single-threaded with respect to the meta + * provider, and that the meta provider cannot call dtrace_meta_register() + * or dtrace_meta_unregister(). However, the context is such that the + * provider may (and is expected to) call provider-related DTrace provider + * APIs including dtrace_probe_create(). + * + * 1.3 void *dtms_provide_pid(void *arg, dtrace_meta_provider_t *mprov, + * pid_t pid) + * + * 1.3.1 Overview + * + * Called by the DTrace framework to instantiate a new provider given the + * description of the provider and probes in the mprov argument. The + * meta provider should call dtrace_register() to insert the new provider + * into the DTrace framework. + * + * 1.3.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_meta_register(). + * The second argument is a pointer to a structure describing the new + * helper provider. The third argument is the process identifier for + * process associated with this new provider. Note that the name of the + * provider as passed to dtrace_register() should be the contatenation of + * the dtmpb_provname member of the mprov argument and the processs + * identifier as a string. + * + * 1.3.3 Return value + * + * The cookie for the provider that the meta provider creates. This is + * the same value that it passed to dtrace_register(). + * + * 1.3.4 Caller's context + * + * dtms_provide_pid() is called from either ioctl() or module load context. + * The DTrace framework is locked in such a way that meta providers may not + * register or unregister. This means that the meta provider cannot call + * dtrace_meta_register() or dtrace_meta_unregister(). However, the context + * is such that the provider may -- and is expected to -- call + * provider-related DTrace provider APIs including dtrace_register(). + * + * 1.4 void dtms_remove_pid(void *arg, dtrace_meta_provider_t *mprov, + * pid_t pid) + * + * 1.4.1 Overview + * + * Called by the DTrace framework to remove a provider that had previously + * been instantiated via the dtms_provide_pid() entry point. The meta + * provider need not remove the provider immediately, but this entry + * point indicates that the provider should be removed as soon as possible + * using the dtrace_unregister() API. + * + * 1.4.2 Arguments and notes + * + * The first argument is the cookie as passed to dtrace_meta_register(). + * The second argument is a pointer to a structure describing the helper + * provider. The third argument is the process identifier for process + * associated with this new provider. + * + * 1.4.3 Return value + * + * None + * + * 1.4.4 Caller's context + * + * dtms_remove_pid() is called from either ioctl() or exit() context. + * The DTrace framework is locked in such a way that meta providers may not + * register or unregister. This means that the meta provider cannot call + * dtrace_meta_register() or dtrace_meta_unregister(). However, the context + * is such that the provider may -- and is expected to -- call + * provider-related DTrace provider APIs including dtrace_unregister(). + */ +typedef struct dtrace_helper_probedesc { + char *dthpb_mod; /* probe module */ + char *dthpb_func; /* probe function */ + char *dthpb_name; /* probe name */ + uint64_t dthpb_base; /* base address */ + uint32_t *dthpb_offs; /* offsets array */ + uint32_t *dthpb_enoffs; /* is-enabled offsets array */ + uint32_t dthpb_noffs; /* offsets count */ + uint32_t dthpb_nenoffs; /* is-enabled offsets count */ + uint8_t *dthpb_args; /* argument mapping array */ + uint8_t dthpb_xargc; /* translated argument count */ + uint8_t dthpb_nargc; /* native argument count */ + char *dthpb_xtypes; /* translated types strings */ + char *dthpb_ntypes; /* native types strings */ +} dtrace_helper_probedesc_t; + +typedef struct dtrace_helper_provdesc { + char *dthpv_provname; /* provider name */ + dtrace_pattr_t dthpv_pattr; /* stability attributes */ +} dtrace_helper_provdesc_t; + +typedef struct dtrace_mops { + void (*dtms_create_probe)(void *, void *, dtrace_helper_probedesc_t *); + void *(*dtms_provide_pid)(void *, dtrace_helper_provdesc_t *, pid_t); + void (*dtms_remove_pid)(void *, dtrace_helper_provdesc_t *, pid_t); +} dtrace_mops_t; + +typedef uintptr_t dtrace_meta_provider_id_t; + +extern int dtrace_meta_register(const char *, const dtrace_mops_t *, void *, + dtrace_meta_provider_id_t *); +extern int dtrace_meta_unregister(dtrace_meta_provider_id_t); + +/* + * DTrace Kernel Hooks + * + * The following functions are implemented by the base kernel and form a set of + * hooks used by the DTrace framework. DTrace hooks are implemented in either + * uts/common/os/dtrace_subr.c, an ISA-specific assembly file, or in a + * uts//os/dtrace_subr.c corresponding to each hardware platform. + */ + +typedef enum dtrace_vtime_state { + DTRACE_VTIME_INACTIVE = 0, /* No DTrace */ + DTRACE_VTIME_ACTIVE, /* DTrace virtual time */ +} dtrace_vtime_state_t; + +extern dtrace_vtime_state_t dtrace_vtime_active; +extern void dtrace_vtime_switch(kthread_t *next); +extern void dtrace_vtime_enable(void); +extern void dtrace_vtime_disable(void); + +struct regs; + +extern int (*dtrace_pid_probe_ptr)(struct regs *); +extern int (*dtrace_return_probe_ptr)(struct regs *); +extern void (*dtrace_fasttrap_fork_ptr)(proc_t *, proc_t *); +extern void (*dtrace_fasttrap_exec_ptr)(proc_t *); +extern void (*dtrace_fasttrap_exit_ptr)(proc_t *); +extern void dtrace_fasttrap_fork(proc_t *, proc_t *); + +typedef uintptr_t dtrace_icookie_t; +typedef void (*dtrace_xcall_t)(void *); + +extern dtrace_icookie_t dtrace_interrupt_disable(void); +extern void dtrace_interrupt_enable(dtrace_icookie_t); + +extern void dtrace_membar_producer(void); +extern void dtrace_membar_consumer(void); + +extern void (*dtrace_cpu_init)(processorid_t); +extern void (*dtrace_modload)(struct modctl *); +extern void (*dtrace_modunload)(struct modctl *); +extern void (*dtrace_helpers_cleanup)(proc_t *); +extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child); +extern void (*dtrace_cpustart_init)(); +extern void (*dtrace_cpustart_fini)(); +extern void (*dtrace_closef)(); + +extern void (*dtrace_debugger_init)(); +extern void (*dtrace_debugger_fini)(); +extern dtrace_cacheid_t dtrace_predcache_id; + +extern hrtime_t dtrace_gethrtime(void); +extern void dtrace_sync(void); +extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t)); +extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *); +extern void dtrace_vpanic(const char *, __va_list); +extern void dtrace_panic(const char *, ...); + +extern int dtrace_safe_defer_signal(void); +extern void dtrace_safe_synchronous_signal(void); + +extern int dtrace_mach_aframes(void); + +#if defined(__i386) || defined(__amd64) +extern int dtrace_instr_size(uchar_t *instr); +extern int dtrace_instr_size_isa(uchar_t *, model_t, int *); +extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t)); +extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t)); +extern void dtrace_invop_callsite(void); +#endif + +#ifdef __sparc +extern int dtrace_blksuword32(uintptr_t, uint32_t *, int); +extern void dtrace_getfsr(uint64_t *); +#endif + +#define DTRACE_CPUFLAG_ISSET(flag) \ + (cpu_core[CPU->cpu_id].cpuc_dtrace_flags & (flag)) + +#define DTRACE_CPUFLAG_SET(flag) \ + (cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= (flag)) + +#define DTRACE_CPUFLAG_CLEAR(flag) \ + (cpu_core[CPU->cpu_id].cpuc_dtrace_flags &= ~(flag)) + +#endif /* _KERNEL */ + +#endif /* _ASM */ + +#if defined(__i386) || defined(__amd64) + +#define DTRACE_INVOP_PUSHL_EBP 1 +#define DTRACE_INVOP_POPL_EBP 2 +#define DTRACE_INVOP_LEAVE 3 +#define DTRACE_INVOP_NOP 4 +#define DTRACE_INVOP_RET 5 + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DTRACE_H */ diff --git a/illumos-x86_64/usr/include/sys/dtrace_impl.h b/illumos-x86_64/usr/include/sys/dtrace_impl.h new file mode 100644 index 00000000..fe8666e1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dtrace_impl.h @@ -0,0 +1,1319 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2017 Joyent, Inc. + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +#ifndef _SYS_DTRACE_IMPL_H +#define _SYS_DTRACE_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DTrace Dynamic Tracing Software: Kernel Implementation Interfaces + * + * Note: The contents of this file are private to the implementation of the + * Solaris system and DTrace subsystem and are subject to change at any time + * without notice. Applications and drivers using these interfaces will fail + * to run on future releases. These interfaces should not be used for any + * purpose except those expressly outlined in dtrace(4D) and libdtrace(3LIB). + * Please refer to the "Solaris Dynamic Tracing Guide" for more information. + */ + +#include + +/* + * DTrace Implementation Constants and Typedefs + */ +#define DTRACE_MAXPROPLEN 128 +#define DTRACE_DYNVAR_CHUNKSIZE 256 + +struct dtrace_probe; +struct dtrace_ecb; +struct dtrace_predicate; +struct dtrace_action; +struct dtrace_provider; +struct dtrace_state; + +typedef struct dtrace_probe dtrace_probe_t; +typedef struct dtrace_ecb dtrace_ecb_t; +typedef struct dtrace_predicate dtrace_predicate_t; +typedef struct dtrace_action dtrace_action_t; +typedef struct dtrace_provider dtrace_provider_t; +typedef struct dtrace_meta dtrace_meta_t; +typedef struct dtrace_state dtrace_state_t; +typedef uint32_t dtrace_optid_t; +typedef uint32_t dtrace_specid_t; +typedef uint64_t dtrace_genid_t; + +/* + * DTrace Probes + * + * The probe is the fundamental unit of the DTrace architecture. Probes are + * created by DTrace providers, and managed by the DTrace framework. A probe + * is identified by a unique tuple, and has + * a unique probe identifier assigned to it. (Some probes are not associated + * with a specific point in text; these are called _unanchored probes_ and have + * no module or function associated with them.) Probes are represented as a + * dtrace_probe structure. To allow quick lookups based on each element of the + * probe tuple, probes are hashed by each of provider, module, function and + * name. (If a lookup is performed based on a regular expression, a + * dtrace_probekey is prepared, and a linear search is performed.) Each probe + * is additionally pointed to by a linear array indexed by its identifier. The + * identifier is the provider's mechanism for indicating to the DTrace + * framework that a probe has fired: the identifier is passed as the first + * argument to dtrace_probe(), where it is then mapped into the corresponding + * dtrace_probe structure. From the dtrace_probe structure, dtrace_probe() can + * iterate over the probe's list of enabling control blocks; see "DTrace + * Enabling Control Blocks", below.) + */ +struct dtrace_probe { + dtrace_id_t dtpr_id; /* probe identifier */ + dtrace_ecb_t *dtpr_ecb; /* ECB list; see below */ + dtrace_ecb_t *dtpr_ecb_last; /* last ECB in list */ + void *dtpr_arg; /* provider argument */ + dtrace_cacheid_t dtpr_predcache; /* predicate cache ID */ + int dtpr_aframes; /* artificial frames */ + dtrace_provider_t *dtpr_provider; /* pointer to provider */ + char *dtpr_mod; /* probe's module name */ + char *dtpr_func; /* probe's function name */ + char *dtpr_name; /* probe's name */ + dtrace_probe_t *dtpr_nextmod; /* next in module hash */ + dtrace_probe_t *dtpr_prevmod; /* previous in module hash */ + dtrace_probe_t *dtpr_nextfunc; /* next in function hash */ + dtrace_probe_t *dtpr_prevfunc; /* previous in function hash */ + dtrace_probe_t *dtpr_nextname; /* next in name hash */ + dtrace_probe_t *dtpr_prevname; /* previous in name hash */ + dtrace_genid_t dtpr_gen; /* probe generation ID */ +}; + +typedef int dtrace_probekey_f(const char *, const char *, int); + +typedef struct dtrace_probekey { + const char *dtpk_prov; /* provider name to match */ + dtrace_probekey_f *dtpk_pmatch; /* provider matching function */ + const char *dtpk_mod; /* module name to match */ + dtrace_probekey_f *dtpk_mmatch; /* module matching function */ + const char *dtpk_func; /* func name to match */ + dtrace_probekey_f *dtpk_fmatch; /* func matching function */ + const char *dtpk_name; /* name to match */ + dtrace_probekey_f *dtpk_nmatch; /* name matching function */ + dtrace_id_t dtpk_id; /* identifier to match */ +} dtrace_probekey_t; + +typedef struct dtrace_hashbucket { + struct dtrace_hashbucket *dthb_next; /* next on hash chain */ + dtrace_probe_t *dthb_chain; /* chain of probes */ + int dthb_len; /* number of probes here */ +} dtrace_hashbucket_t; + +typedef struct dtrace_hash { + dtrace_hashbucket_t **dth_tab; /* hash table */ + int dth_size; /* size of hash table */ + int dth_mask; /* mask to index into table */ + int dth_nbuckets; /* total number of buckets */ + uintptr_t dth_nextoffs; /* offset of next in probe */ + uintptr_t dth_prevoffs; /* offset of prev in probe */ + uintptr_t dth_stroffs; /* offset of str in probe */ +} dtrace_hash_t; + +/* + * DTrace Enabling Control Blocks + * + * When a provider wishes to fire a probe, it calls into dtrace_probe(), + * passing the probe identifier as the first argument. As described above, + * dtrace_probe() maps the identifier into a pointer to a dtrace_probe_t + * structure. This structure contains information about the probe, and a + * pointer to the list of Enabling Control Blocks (ECBs). Each ECB points to + * DTrace consumer state, and contains an optional predicate, and a list of + * actions. (Shown schematically below.) The ECB abstraction allows a single + * probe to be multiplexed across disjoint consumers, or across disjoint + * enablings of a single probe within one consumer. + * + * Enabling Control Block + * dtrace_ecb_t + * +------------------------+ + * | dtrace_epid_t ---------+--------------> Enabled Probe ID (EPID) + * | dtrace_state_t * ------+--------------> State associated with this ECB + * | dtrace_predicate_t * --+---------+ + * | dtrace_action_t * -----+----+ | + * | dtrace_ecb_t * ---+ | | | Predicate (if any) + * +-------------------+----+ | | dtrace_predicate_t + * | | +---> +--------------------+ + * | | | dtrace_difo_t * ---+----> DIFO + * | | +--------------------+ + * | | + * Next ECB | | Action + * (if any) | | dtrace_action_t + * : +--> +-------------------+ + * : | dtrace_actkind_t -+------> kind + * v | dtrace_difo_t * --+------> DIFO (if any) + * | dtrace_recdesc_t -+------> record descr. + * | dtrace_action_t * +------+ + * +-------------------+ | + * | Next action + * +-------------------------------+ (if any) + * | + * | Action + * | dtrace_action_t + * +--> +-------------------+ + * | dtrace_actkind_t -+------> kind + * | dtrace_difo_t * --+------> DIFO (if any) + * | dtrace_action_t * +------+ + * +-------------------+ | + * | Next action + * +-------------------------------+ (if any) + * | + * : + * v + * + * + * dtrace_probe() iterates over the ECB list. If the ECB needs less space + * than is available in the principal buffer, the ECB is processed: if the + * predicate is non-NULL, the DIF object is executed. If the result is + * non-zero, the action list is processed, with each action being executed + * accordingly. When the action list has been completely executed, processing + * advances to the next ECB. The ECB abstraction allows disjoint consumers + * to multiplex on single probes. + * + * Execution of the ECB results in consuming dte_size bytes in the buffer + * to record data. During execution, dte_needed bytes must be available in + * the buffer. This space is used for both recorded data and tuple data. + */ +struct dtrace_ecb { + dtrace_epid_t dte_epid; /* enabled probe ID */ + uint32_t dte_alignment; /* required alignment */ + size_t dte_needed; /* space needed for execution */ + size_t dte_size; /* size of recorded payload */ + dtrace_predicate_t *dte_predicate; /* predicate, if any */ + dtrace_action_t *dte_action; /* actions, if any */ + dtrace_ecb_t *dte_next; /* next ECB on probe */ + dtrace_state_t *dte_state; /* pointer to state */ + uint32_t dte_cond; /* security condition */ + dtrace_probe_t *dte_probe; /* pointer to probe */ + dtrace_action_t *dte_action_last; /* last action on ECB */ + uint64_t dte_uarg; /* library argument */ +}; + +struct dtrace_predicate { + dtrace_difo_t *dtp_difo; /* DIF object */ + dtrace_cacheid_t dtp_cacheid; /* cache identifier */ + int dtp_refcnt; /* reference count */ +}; + +struct dtrace_action { + dtrace_actkind_t dta_kind; /* kind of action */ + uint16_t dta_intuple; /* boolean: in aggregation */ + uint32_t dta_refcnt; /* reference count */ + dtrace_difo_t *dta_difo; /* pointer to DIFO */ + dtrace_recdesc_t dta_rec; /* record description */ + dtrace_action_t *dta_prev; /* previous action */ + dtrace_action_t *dta_next; /* next action */ +}; + +typedef struct dtrace_aggregation { + dtrace_action_t dtag_action; /* action; must be first */ + dtrace_aggid_t dtag_id; /* identifier */ + dtrace_ecb_t *dtag_ecb; /* corresponding ECB */ + dtrace_action_t *dtag_first; /* first action in tuple */ + uint32_t dtag_base; /* base of aggregation */ + uint8_t dtag_hasarg; /* boolean: has argument */ + uint64_t dtag_initial; /* initial value */ + void (*dtag_aggregate)(uint64_t *, uint64_t, uint64_t); +} dtrace_aggregation_t; + +/* + * DTrace Buffers + * + * Principal buffers, aggregation buffers, and speculative buffers are all + * managed with the dtrace_buffer structure. By default, this structure + * includes twin data buffers -- dtb_tomax and dtb_xamot -- that serve as the + * active and passive buffers, respectively. For speculative buffers, + * dtb_xamot will be NULL; for "ring" and "fill" buffers, dtb_xamot will point + * to a scratch buffer. For all buffer types, the dtrace_buffer structure is + * always allocated on a per-CPU basis; a single dtrace_buffer structure is + * never shared among CPUs. (That is, there is never true sharing of the + * dtrace_buffer structure; to prevent false sharing of the structure, it must + * always be aligned to the coherence granularity -- generally 64 bytes.) + * + * One of the critical design decisions of DTrace is that a given ECB always + * stores the same quantity and type of data. This is done to assure that the + * only metadata required for an ECB's traced data is the EPID. That is, from + * the EPID, the consumer can determine the data layout. (The data buffer + * layout is shown schematically below.) By assuring that one can determine + * data layout from the EPID, the metadata stream can be separated from the + * data stream -- simplifying the data stream enormously. The ECB always + * proceeds the recorded data as part of the dtrace_rechdr_t structure that + * includes the EPID and a high-resolution timestamp used for output ordering + * consistency. + * + * base of data buffer ---> +--------+--------------------+--------+ + * | rechdr | data | rechdr | + * +--------+------+--------+----+--------+ + * | data | rechdr | data | + * +---------------+--------+-------------+ + * | data, cont. | + * +--------+--------------------+--------+ + * | rechdr | data | | + * +--------+--------------------+ | + * | || | + * | || | + * | \/ | + * : : + * . . + * . . + * . . + * : : + * | | + * limit of data buffer ---> +--------------------------------------+ + * + * When evaluating an ECB, dtrace_probe() determines if the ECB's needs of the + * principal buffer (both scratch and payload) exceed the available space. If + * the ECB's needs exceed available space (and if the principal buffer policy + * is the default "switch" policy), the ECB is dropped, the buffer's drop count + * is incremented, and processing advances to the next ECB. If the ECB's needs + * can be met with the available space, the ECB is processed, but the offset in + * the principal buffer is only advanced if the ECB completes processing + * without error. + * + * When a buffer is to be switched (either because the buffer is the principal + * buffer with a "switch" policy or because it is an aggregation buffer), a + * cross call is issued to the CPU associated with the buffer. In the cross + * call context, interrupts are disabled, and the active and the inactive + * buffers are atomically switched. This involves switching the data pointers, + * copying the various state fields (offset, drops, errors, etc.) into their + * inactive equivalents, and clearing the state fields. Because interrupts are + * disabled during this procedure, the switch is guaranteed to appear atomic to + * dtrace_probe(). + * + * DTrace Ring Buffering + * + * To process a ring buffer correctly, one must know the oldest valid record. + * Processing starts at the oldest record in the buffer and continues until + * the end of the buffer is reached. Processing then resumes starting with + * the record stored at offset 0 in the buffer, and continues until the + * youngest record is processed. If trace records are of a fixed-length, + * determining the oldest record is trivial: + * + * - If the ring buffer has not wrapped, the oldest record is the record + * stored at offset 0. + * + * - If the ring buffer has wrapped, the oldest record is the record stored + * at the current offset. + * + * With variable length records, however, just knowing the current offset + * doesn't suffice for determining the oldest valid record: assuming that one + * allows for arbitrary data, one has no way of searching forward from the + * current offset to find the oldest valid record. (That is, one has no way + * of separating data from metadata.) It would be possible to simply refuse to + * process any data in the ring buffer between the current offset and the + * limit, but this leaves (potentially) an enormous amount of otherwise valid + * data unprocessed. + * + * To effect ring buffering, we track two offsets in the buffer: the current + * offset and the _wrapped_ offset. If a request is made to reserve some + * amount of data, and the buffer has wrapped, the wrapped offset is + * incremented until the wrapped offset minus the current offset is greater + * than or equal to the reserve request. This is done by repeatedly looking + * up the ECB corresponding to the EPID at the current wrapped offset, and + * incrementing the wrapped offset by the size of the data payload + * corresponding to that ECB. If this offset is greater than or equal to the + * limit of the data buffer, the wrapped offset is set to 0. Thus, the + * current offset effectively "chases" the wrapped offset around the buffer. + * Schematically: + * + * base of data buffer ---> +------+--------------------+------+ + * | EPID | data | EPID | + * +------+--------+------+----+------+ + * | data | EPID | data | + * +---------------+------+-----------+ + * | data, cont. | + * +------+---------------------------+ + * | EPID | data | + * current offset ---> +------+---------------------------+ + * | invalid data | + * wrapped offset ---> +------+--------------------+------+ + * | EPID | data | EPID | + * +------+--------+------+----+------+ + * | data | EPID | data | + * +---------------+------+-----------+ + * : : + * . . + * . ... valid data ... . + * . . + * : : + * +------+-------------+------+------+ + * | EPID | data | EPID | data | + * +------+------------++------+------+ + * | data, cont. | leftover | + * limit of data buffer ---> +-------------------+--------------+ + * + * If the amount of requested buffer space exceeds the amount of space + * available between the current offset and the end of the buffer: + * + * (1) all words in the data buffer between the current offset and the limit + * of the data buffer (marked "leftover", above) are set to + * DTRACE_EPIDNONE + * + * (2) the wrapped offset is set to zero + * + * (3) the iteration process described above occurs until the wrapped offset + * is greater than the amount of desired space. + * + * The wrapped offset is implemented by (re-)using the inactive offset. + * In a "switch" buffer policy, the inactive offset stores the offset in + * the inactive buffer; in a "ring" buffer policy, it stores the wrapped + * offset. + * + * DTrace Scratch Buffering + * + * Some ECBs may wish to allocate dynamically-sized temporary scratch memory. + * To accommodate such requests easily, scratch memory may be allocated in + * the buffer beyond the current offset plus the needed memory of the current + * ECB. If there isn't sufficient room in the buffer for the requested amount + * of scratch space, the allocation fails and an error is generated. Scratch + * memory is tracked in the dtrace_mstate_t and is automatically freed when + * the ECB ceases processing. Note that ring buffers cannot allocate their + * scratch from the principal buffer -- lest they needlessly overwrite older, + * valid data. Ring buffers therefore have their own dedicated scratch buffer + * from which scratch is allocated. + */ +#define DTRACEBUF_RING 0x0001 /* bufpolicy set to "ring" */ +#define DTRACEBUF_FILL 0x0002 /* bufpolicy set to "fill" */ +#define DTRACEBUF_NOSWITCH 0x0004 /* do not switch buffer */ +#define DTRACEBUF_WRAPPED 0x0008 /* ring buffer has wrapped */ +#define DTRACEBUF_DROPPED 0x0010 /* drops occurred */ +#define DTRACEBUF_ERROR 0x0020 /* errors occurred */ +#define DTRACEBUF_FULL 0x0040 /* "fill" buffer is full */ +#define DTRACEBUF_CONSUMED 0x0080 /* buffer has been consumed */ +#define DTRACEBUF_INACTIVE 0x0100 /* buffer is not yet active */ + +typedef struct dtrace_buffer { + uint64_t dtb_offset; /* current offset in buffer */ + uint64_t dtb_size; /* size of buffer */ + uint32_t dtb_flags; /* flags */ + uint32_t dtb_drops; /* number of drops */ + caddr_t dtb_tomax; /* active buffer */ + caddr_t dtb_xamot; /* inactive buffer */ + uint32_t dtb_xamot_flags; /* inactive flags */ + uint32_t dtb_xamot_drops; /* drops in inactive buffer */ + uint64_t dtb_xamot_offset; /* offset in inactive buffer */ + uint32_t dtb_errors; /* number of errors */ + uint32_t dtb_xamot_errors; /* errors in inactive buffer */ +#ifndef _LP64 + uint64_t dtb_pad1; /* pad out to 64 bytes */ +#endif + uint64_t dtb_switched; /* time of last switch */ + uint64_t dtb_interval; /* observed switch interval */ + uint64_t dtb_pad2[6]; /* pad to avoid false sharing */ +} dtrace_buffer_t; + +/* + * DTrace Aggregation Buffers + * + * Aggregation buffers use much of the same mechanism as described above + * ("DTrace Buffers"). However, because an aggregation is fundamentally a + * hash, there exists dynamic metadata associated with an aggregation buffer + * that is not associated with other kinds of buffers. This aggregation + * metadata is _only_ relevant for the in-kernel implementation of + * aggregations; it is not actually relevant to user-level consumers. To do + * this, we allocate dynamic aggregation data (hash keys and hash buckets) + * starting below the _limit_ of the buffer, and we allocate data from the + * _base_ of the buffer. When the aggregation buffer is copied out, _only_ the + * data is copied out; the metadata is simply discarded. Schematically, + * aggregation buffers look like: + * + * base of data buffer ---> +-------+------+-----------+-------+ + * | aggid | key | value | aggid | + * +-------+------+-----------+-------+ + * | key | + * +-------+-------+-----+------------+ + * | value | aggid | key | value | + * +-------+------++-----+------+-----+ + * | aggid | key | value | | + * +-------+------+-------------+ | + * | || | + * | || | + * | \/ | + * : : + * . . + * . . + * . . + * : : + * | /\ | + * | || +------------+ + * | || | | + * +---------------------+ | + * | hash keys | + * | (dtrace_aggkey structures) | + * | | + * +----------------------------------+ + * | hash buckets | + * | (dtrace_aggbuffer structure) | + * | | + * limit of data buffer ---> +----------------------------------+ + * + * + * As implied above, just as we assure that ECBs always store a constant + * amount of data, we assure that a given aggregation -- identified by its + * aggregation ID -- always stores data of a constant quantity and type. + * As with EPIDs, this allows the aggregation ID to serve as the metadata for a + * given record. + * + * Note that the size of the dtrace_aggkey structure must be sizeof (uintptr_t) + * aligned. (If this the structure changes such that this becomes false, an + * assertion will fail in dtrace_aggregate().) + */ +typedef struct dtrace_aggkey { + uint32_t dtak_hashval; /* hash value */ + uint32_t dtak_action:4; /* action -- 4 bits */ + uint32_t dtak_size:28; /* size -- 28 bits */ + caddr_t dtak_data; /* data pointer */ + struct dtrace_aggkey *dtak_next; /* next in hash chain */ +} dtrace_aggkey_t; + +typedef struct dtrace_aggbuffer { + uintptr_t dtagb_hashsize; /* number of buckets */ + uintptr_t dtagb_free; /* free list of keys */ + dtrace_aggkey_t **dtagb_hash; /* hash table */ +} dtrace_aggbuffer_t; + +/* + * DTrace Speculations + * + * Speculations have a per-CPU buffer and a global state. Once a speculation + * buffer has been comitted or discarded, it cannot be reused until all CPUs + * have taken the same action (commit or discard) on their respective + * speculative buffer. However, because DTrace probes may execute in arbitrary + * context, other CPUs cannot simply be cross-called at probe firing time to + * perform the necessary commit or discard. The speculation states thus + * optimize for the case that a speculative buffer is only active on one CPU at + * the time of a commit() or discard() -- for if this is the case, other CPUs + * need not take action, and the speculation is immediately available for + * reuse. If the speculation is active on multiple CPUs, it must be + * asynchronously cleaned -- potentially leading to a higher rate of dirty + * speculative drops. The speculation states are as follows: + * + * DTRACESPEC_INACTIVE <= Initial state; inactive speculation + * DTRACESPEC_ACTIVE <= Allocated, but not yet speculatively traced to + * DTRACESPEC_ACTIVEONE <= Speculatively traced to on one CPU + * DTRACESPEC_ACTIVEMANY <= Speculatively traced to on more than one CPU + * DTRACESPEC_COMMITTING <= Currently being commited on one CPU + * DTRACESPEC_COMMITTINGMANY <= Currently being commited on many CPUs + * DTRACESPEC_DISCARDING <= Currently being discarded on many CPUs + * + * The state transition diagram is as follows: + * + * +----------------------------------------------------------+ + * | | + * | +------------+ | + * | +-------------------| COMMITTING |<-----------------+ | + * | | +------------+ | | + * | | copied spec. ^ commit() on | | discard() on + * | | into principal | active CPU | | active CPU + * | | | commit() | | + * V V | | | + * +----------+ +--------+ +-----------+ + * | INACTIVE |---------------->| ACTIVE |--------------->| ACTIVEONE | + * +----------+ speculation() +--------+ speculate() +-----------+ + * ^ ^ | | | + * | | | discard() | | + * | | asynchronously | discard() on | | speculate() + * | | cleaned V inactive CPU | | on inactive + * | | +------------+ | | CPU + * | +-------------------| DISCARDING |<-----------------+ | + * | +------------+ | + * | asynchronously ^ | + * | copied spec. | discard() | + * | into principal +------------------------+ | + * | | V + * +----------------+ commit() +------------+ + * | COMMITTINGMANY |<----------------------------------| ACTIVEMANY | + * +----------------+ +------------+ + */ +typedef enum dtrace_speculation_state { + DTRACESPEC_INACTIVE = 0, + DTRACESPEC_ACTIVE, + DTRACESPEC_ACTIVEONE, + DTRACESPEC_ACTIVEMANY, + DTRACESPEC_COMMITTING, + DTRACESPEC_COMMITTINGMANY, + DTRACESPEC_DISCARDING +} dtrace_speculation_state_t; + +typedef struct dtrace_speculation { + dtrace_speculation_state_t dtsp_state; /* current speculation state */ + int dtsp_cleaning; /* non-zero if being cleaned */ + dtrace_buffer_t *dtsp_buffer; /* speculative buffer */ +} dtrace_speculation_t; + +/* + * DTrace Dynamic Variables + * + * The dynamic variable problem is obviously decomposed into two subproblems: + * allocating new dynamic storage, and freeing old dynamic storage. The + * presence of the second problem makes the first much more complicated -- or + * rather, the absence of the second renders the first trivial. This is the + * case with aggregations, for which there is effectively no deallocation of + * dynamic storage. (Or more accurately, all dynamic storage is deallocated + * when a snapshot is taken of the aggregation.) As DTrace dynamic variables + * allow for both dynamic allocation and dynamic deallocation, the + * implementation of dynamic variables is quite a bit more complicated than + * that of their aggregation kin. + * + * We observe that allocating new dynamic storage is tricky only because the + * size can vary -- the allocation problem is much easier if allocation sizes + * are uniform. We further observe that in D, the size of dynamic variables is + * actually _not_ dynamic -- dynamic variable sizes may be determined by static + * analysis of DIF text. (This is true even of putatively dynamically-sized + * objects like strings and stacks, the sizes of which are dictated by the + * "stringsize" and "stackframes" variables, respectively.) We exploit this by + * performing this analysis on all DIF before enabling any probes. For each + * dynamic load or store, we calculate the dynamically-allocated size plus the + * size of the dtrace_dynvar structure plus the storage required to key the + * data. For all DIF, we take the largest value and dub it the _chunksize_. + * We then divide dynamic memory into two parts: a hash table that is wide + * enough to have every chunk in its own bucket, and a larger region of equal + * chunksize units. Whenever we wish to dynamically allocate a variable, we + * always allocate a single chunk of memory. Depending on the uniformity of + * allocation, this will waste some amount of memory -- but it eliminates the + * non-determinism inherent in traditional heap fragmentation. + * + * Dynamic objects are allocated by storing a non-zero value to them; they are + * deallocated by storing a zero value to them. Dynamic variables are + * complicated enormously by being shared between CPUs. In particular, + * consider the following scenario: + * + * CPU A CPU B + * +---------------------------------+ +---------------------------------+ + * | | | | + * | allocates dynamic object a[123] | | | + * | by storing the value 345 to it | | | + * | ---------> | + * | | | wishing to load from object | + * | | | a[123], performs lookup in | + * | | | dynamic variable space | + * | <--------- | + * | deallocates object a[123] by | | | + * | storing 0 to it | | | + * | | | | + * | allocates dynamic object b[567] | | performs load from a[123] | + * | by storing the value 789 to it | | | + * : : : : + * . . . . + * + * This is obviously a race in the D program, but there are nonetheless only + * two valid values for CPU B's load from a[123]: 345 or 0. Most importantly, + * CPU B may _not_ see the value 789 for a[123]. + * + * There are essentially two ways to deal with this: + * + * (1) Explicitly spin-lock variables. That is, if CPU B wishes to load + * from a[123], it needs to lock a[123] and hold the lock for the + * duration that it wishes to manipulate it. + * + * (2) Avoid reusing freed chunks until it is known that no CPU is referring + * to them. + * + * The implementation of (1) is rife with complexity, because it requires the + * user of a dynamic variable to explicitly decree when they are done using it. + * Were all variables by value, this perhaps wouldn't be debilitating -- but + * dynamic variables of non-scalar types are tracked by reference. That is, if + * a dynamic variable is, say, a string, and that variable is to be traced to, + * say, the principal buffer, the DIF emulation code returns to the main + * dtrace_probe() loop a pointer to the underlying storage, not the contents of + * the storage. Further, code calling on DIF emulation would have to be aware + * that the DIF emulation has returned a reference to a dynamic variable that + * has been potentially locked. The variable would have to be unlocked after + * the main dtrace_probe() loop is finished with the variable, and the main + * dtrace_probe() loop would have to be careful to not call any further DIF + * emulation while the variable is locked to avoid deadlock. More generally, + * if one were to implement (1), DIF emulation code dealing with dynamic + * variables could only deal with one dynamic variable at a time (lest deadlock + * result). To sum, (1) exports too much subtlety to the users of dynamic + * variables -- increasing maintenance burden and imposing serious constraints + * on future DTrace development. + * + * The implementation of (2) is also complex, but the complexity is more + * manageable. We need to be sure that when a variable is deallocated, it is + * not placed on a traditional free list, but rather on a _dirty_ list. Once a + * variable is on a dirty list, it cannot be found by CPUs performing a + * subsequent lookup of the variable -- but it may still be in use by other + * CPUs. To assure that all CPUs that may be seeing the old variable have + * cleared out of probe context, a dtrace_sync() can be issued. Once the + * dtrace_sync() has completed, it can be known that all CPUs are done + * manipulating the dynamic variable -- the dirty list can be atomically + * appended to the free list. Unfortunately, there's a slight hiccup in this + * mechanism: dtrace_sync() may not be issued from probe context. The + * dtrace_sync() must be therefore issued asynchronously from non-probe + * context. For this we rely on the DTrace cleaner, a cyclic that runs at the + * "cleanrate" frequency. To ease this implementation, we define several chunk + * lists: + * + * - Dirty. Deallocated chunks, not yet cleaned. Not available. + * + * - Rinsing. Formerly dirty chunks that are currently being asynchronously + * cleaned. Not available, but will be shortly. Dynamic variable + * allocation may not spin or block for availability, however. + * + * - Clean. Clean chunks, ready for allocation -- but not on the free list. + * + * - Free. Available for allocation. + * + * Moreover, to avoid absurd contention, _each_ of these lists is implemented + * on a per-CPU basis. This is only for performance, not correctness; chunks + * may be allocated from another CPU's free list. The algorithm for allocation + * then is this: + * + * (1) Attempt to atomically allocate from current CPU's free list. If list + * is non-empty and allocation is successful, allocation is complete. + * + * (2) If the clean list is non-empty, atomically move it to the free list, + * and reattempt (1). + * + * (3) If the dynamic variable space is in the CLEAN state, look for free + * and clean lists on other CPUs by setting the current CPU to the next + * CPU, and reattempting (1). If the next CPU is the current CPU (that + * is, if all CPUs have been checked), atomically switch the state of + * the dynamic variable space based on the following: + * + * - If no free chunks were found and no dirty chunks were found, + * atomically set the state to EMPTY. + * + * - If dirty chunks were found, atomically set the state to DIRTY. + * + * - If rinsing chunks were found, atomically set the state to RINSING. + * + * (4) Based on state of dynamic variable space state, increment appropriate + * counter to indicate dynamic drops (if in EMPTY state) vs. dynamic + * dirty drops (if in DIRTY state) vs. dynamic rinsing drops (if in + * RINSING state). Fail the allocation. + * + * The cleaning cyclic operates with the following algorithm: for all CPUs + * with a non-empty dirty list, atomically move the dirty list to the rinsing + * list. Perform a dtrace_sync(). For all CPUs with a non-empty rinsing list, + * atomically move the rinsing list to the clean list. Perform another + * dtrace_sync(). By this point, all CPUs have seen the new clean list; the + * state of the dynamic variable space can be restored to CLEAN. + * + * There exist two final races that merit explanation. The first is a simple + * allocation race: + * + * CPU A CPU B + * +---------------------------------+ +---------------------------------+ + * | | | | + * | allocates dynamic object a[123] | | allocates dynamic object a[123] | + * | by storing the value 345 to it | | by storing the value 567 to it | + * | | | | + * : : : : + * . . . . + * + * Again, this is a race in the D program. It can be resolved by having a[123] + * hold the value 345 or a[123] hold the value 567 -- but it must be true that + * a[123] have only _one_ of these values. (That is, the racing CPUs may not + * put the same element twice on the same hash chain.) This is resolved + * simply: before the allocation is undertaken, the start of the new chunk's + * hash chain is noted. Later, after the allocation is complete, the hash + * chain is atomically switched to point to the new element. If this fails + * (because of either concurrent allocations or an allocation concurrent with a + * deletion), the newly allocated chunk is deallocated to the dirty list, and + * the whole process of looking up (and potentially allocating) the dynamic + * variable is reattempted. + * + * The final race is a simple deallocation race: + * + * CPU A CPU B + * +---------------------------------+ +---------------------------------+ + * | | | | + * | deallocates dynamic object | | deallocates dynamic object | + * | a[123] by storing the value 0 | | a[123] by storing the value 0 | + * | to it | | to it | + * | | | | + * : : : : + * . . . . + * + * Once again, this is a race in the D program, but it is one that we must + * handle without corrupting the underlying data structures. Because + * deallocations require the deletion of a chunk from the middle of a hash + * chain, we cannot use a single-word atomic operation to remove it. For this, + * we add a spin lock to the hash buckets that is _only_ used for deallocations + * (allocation races are handled as above). Further, this spin lock is _only_ + * held for the duration of the delete; before control is returned to the DIF + * emulation code, the hash bucket is unlocked. + */ +typedef struct dtrace_key { + uint64_t dttk_value; /* data value or data pointer */ + uint64_t dttk_size; /* 0 if by-val, >0 if by-ref */ +} dtrace_key_t; + +typedef struct dtrace_tuple { + uint32_t dtt_nkeys; /* number of keys in tuple */ + uint32_t dtt_pad; /* padding */ + dtrace_key_t dtt_key[1]; /* array of tuple keys */ +} dtrace_tuple_t; + +typedef struct dtrace_dynvar { + uint64_t dtdv_hashval; /* hash value -- 0 if free */ + struct dtrace_dynvar *dtdv_next; /* next on list or hash chain */ + void *dtdv_data; /* pointer to data */ + dtrace_tuple_t dtdv_tuple; /* tuple key */ +} dtrace_dynvar_t; + +typedef enum dtrace_dynvar_op { + DTRACE_DYNVAR_ALLOC, + DTRACE_DYNVAR_NOALLOC, + DTRACE_DYNVAR_DEALLOC +} dtrace_dynvar_op_t; + +typedef struct dtrace_dynhash { + dtrace_dynvar_t *dtdh_chain; /* hash chain for this bucket */ + uintptr_t dtdh_lock; /* deallocation lock */ +#ifdef _LP64 + uintptr_t dtdh_pad[6]; /* pad to avoid false sharing */ +#else + uintptr_t dtdh_pad[14]; /* pad to avoid false sharing */ +#endif +} dtrace_dynhash_t; + +typedef struct dtrace_dstate_percpu { + dtrace_dynvar_t *dtdsc_free; /* free list for this CPU */ + dtrace_dynvar_t *dtdsc_dirty; /* dirty list for this CPU */ + dtrace_dynvar_t *dtdsc_rinsing; /* rinsing list for this CPU */ + dtrace_dynvar_t *dtdsc_clean; /* clean list for this CPU */ + uint64_t dtdsc_drops; /* number of capacity drops */ + uint64_t dtdsc_dirty_drops; /* number of dirty drops */ + uint64_t dtdsc_rinsing_drops; /* number of rinsing drops */ +#ifdef _LP64 + uint64_t dtdsc_pad; /* pad to avoid false sharing */ +#else + uint64_t dtdsc_pad[2]; /* pad to avoid false sharing */ +#endif +} dtrace_dstate_percpu_t; + +typedef enum dtrace_dstate_state { + DTRACE_DSTATE_CLEAN = 0, + DTRACE_DSTATE_EMPTY, + DTRACE_DSTATE_DIRTY, + DTRACE_DSTATE_RINSING +} dtrace_dstate_state_t; + +typedef struct dtrace_dstate { + void *dtds_base; /* base of dynamic var. space */ + size_t dtds_size; /* size of dynamic var. space */ + size_t dtds_hashsize; /* number of buckets in hash */ + size_t dtds_chunksize; /* size of each chunk */ + dtrace_dynhash_t *dtds_hash; /* pointer to hash table */ + dtrace_dstate_state_t dtds_state; /* current dynamic var. state */ + dtrace_dstate_percpu_t *dtds_percpu; /* per-CPU dyn. var. state */ +} dtrace_dstate_t; + +/* + * DTrace Variable State + * + * The DTrace variable state tracks user-defined variables in its dtrace_vstate + * structure. Each DTrace consumer has exactly one dtrace_vstate structure, + * but some dtrace_vstate structures may exist without a corresponding DTrace + * consumer (see "DTrace Helpers", below). As described in , + * user-defined variables can have one of three scopes: + * + * DIFV_SCOPE_GLOBAL => global scope + * DIFV_SCOPE_THREAD => thread-local scope (i.e. "self->" variables) + * DIFV_SCOPE_LOCAL => clause-local scope (i.e. "this->" variables) + * + * The variable state tracks variables by both their scope and their allocation + * type: + * + * - The dtvs_globals and dtvs_locals members each point to an array of + * dtrace_statvar structures. These structures contain both the variable + * metadata (dtrace_difv structures) and the underlying storage for all + * statically allocated variables, including statically allocated + * DIFV_SCOPE_GLOBAL variables and all DIFV_SCOPE_LOCAL variables. + * + * - The dtvs_tlocals member points to an array of dtrace_difv structures for + * DIFV_SCOPE_THREAD variables. As such, this array tracks _only_ the + * variable metadata for DIFV_SCOPE_THREAD variables; the underlying storage + * is allocated out of the dynamic variable space. + * + * - The dtvs_dynvars member is the dynamic variable state associated with the + * variable state. The dynamic variable state (described in "DTrace Dynamic + * Variables", above) tracks all DIFV_SCOPE_THREAD variables and all + * dynamically-allocated DIFV_SCOPE_GLOBAL variables. + */ +typedef struct dtrace_statvar { + uint64_t dtsv_data; /* data or pointer to it */ + size_t dtsv_size; /* size of pointed-to data */ + int dtsv_refcnt; /* reference count */ + dtrace_difv_t dtsv_var; /* variable metadata */ +} dtrace_statvar_t; + +typedef struct dtrace_vstate { + dtrace_state_t *dtvs_state; /* back pointer to state */ + dtrace_statvar_t **dtvs_globals; /* statically-allocated glbls */ + int dtvs_nglobals; /* number of globals */ + dtrace_difv_t *dtvs_tlocals; /* thread-local metadata */ + int dtvs_ntlocals; /* number of thread-locals */ + dtrace_statvar_t **dtvs_locals; /* clause-local data */ + int dtvs_nlocals; /* number of clause-locals */ + dtrace_dstate_t dtvs_dynvars; /* dynamic variable state */ +} dtrace_vstate_t; + +/* + * DTrace Machine State + * + * In the process of processing a fired probe, DTrace needs to track and/or + * cache some per-CPU state associated with that particular firing. This is + * state that is always discarded after the probe firing has completed, and + * much of it is not specific to any DTrace consumer, remaining valid across + * all ECBs. This state is tracked in the dtrace_mstate structure. + */ +#define DTRACE_MSTATE_ARGS 0x00000001 +#define DTRACE_MSTATE_PROBE 0x00000002 +#define DTRACE_MSTATE_EPID 0x00000004 +#define DTRACE_MSTATE_TIMESTAMP 0x00000008 +#define DTRACE_MSTATE_STACKDEPTH 0x00000010 +#define DTRACE_MSTATE_CALLER 0x00000020 +#define DTRACE_MSTATE_IPL 0x00000040 +#define DTRACE_MSTATE_FLTOFFS 0x00000080 +#define DTRACE_MSTATE_WALLTIMESTAMP 0x00000100 +#define DTRACE_MSTATE_USTACKDEPTH 0x00000200 +#define DTRACE_MSTATE_UCALLER 0x00000400 + +typedef struct dtrace_mstate { + uintptr_t dtms_scratch_base; /* base of scratch space */ + uintptr_t dtms_scratch_ptr; /* current scratch pointer */ + size_t dtms_scratch_size; /* scratch size */ + uint32_t dtms_present; /* variables that are present */ + uint64_t dtms_arg[5]; /* cached arguments */ + dtrace_epid_t dtms_epid; /* current EPID */ + uint64_t dtms_timestamp; /* cached timestamp */ + hrtime_t dtms_walltimestamp; /* cached wall timestamp */ + int dtms_stackdepth; /* cached stackdepth */ + int dtms_ustackdepth; /* cached ustackdepth */ + struct dtrace_probe *dtms_probe; /* current probe */ + uintptr_t dtms_caller; /* cached caller */ + uint64_t dtms_ucaller; /* cached user-level caller */ + int dtms_ipl; /* cached interrupt pri lev */ + int dtms_fltoffs; /* faulting DIFO offset */ + uintptr_t dtms_strtok; /* saved strtok() pointer */ + uintptr_t dtms_strtok_limit; /* upper bound of strtok ptr */ + uint32_t dtms_access; /* memory access rights */ + dtrace_difo_t *dtms_difo; /* current dif object */ + file_t *dtms_getf; /* cached rval of getf() */ +} dtrace_mstate_t; + +#define DTRACE_COND_OWNER 0x1 +#define DTRACE_COND_USERMODE 0x2 +#define DTRACE_COND_ZONEOWNER 0x4 + +#define DTRACE_PROBEKEY_MAXDEPTH 8 /* max glob recursion depth */ + +/* + * Access flag used by dtrace_mstate.dtms_access. + */ +#define DTRACE_ACCESS_KERNEL 0x1 /* the priv to read kmem */ +#define DTRACE_ACCESS_PROC 0x2 /* the priv for proc state */ +#define DTRACE_ACCESS_ARGS 0x4 /* the priv to examine args */ + +/* + * DTrace Activity + * + * Each DTrace consumer is in one of several states, which (for purposes of + * avoiding yet-another overloading of the noun "state") we call the current + * _activity_. The activity transitions on dtrace_go() (from DTRACIOCGO), on + * dtrace_stop() (from DTRACIOCSTOP) and on the exit() action. Activities may + * only transition in one direction; the activity transition diagram is a + * directed acyclic graph. The activity transition diagram is as follows: + * + * + * +----------+ +--------+ +--------+ + * | INACTIVE |------------------>| WARMUP |------------------>| ACTIVE | + * +----------+ dtrace_go(), +--------+ dtrace_go(), +--------+ + * before BEGIN | after BEGIN | | | + * | | | | + * exit() action | | | | + * from BEGIN ECB | | | | + * | | | | + * v | | | + * +----------+ exit() action | | | + * +-----------------------------| DRAINING |<-------------------+ | | + * | +----------+ | | + * | | | | + * | dtrace_stop(), | | | + * | before END | | | + * | | | | + * | v | | + * | +---------+ +----------+ | | + * | | STOPPED |<----------------| COOLDOWN |<----------------------+ | + * | +---------+ dtrace_stop(), +----------+ dtrace_stop(), | + * | after END before END | + * | | + * | +--------+ | + * +----------------------------->| KILLED |<--------------------------+ + * deadman timeout or +--------+ deadman timeout or + * killed consumer killed consumer + * + * Note that once a DTrace consumer has stopped tracing, there is no way to + * restart it; if a DTrace consumer wishes to restart tracing, it must reopen + * the DTrace pseudodevice. + */ +typedef enum dtrace_activity { + DTRACE_ACTIVITY_INACTIVE = 0, /* not yet running */ + DTRACE_ACTIVITY_WARMUP, /* while starting */ + DTRACE_ACTIVITY_ACTIVE, /* running */ + DTRACE_ACTIVITY_DRAINING, /* before stopping */ + DTRACE_ACTIVITY_COOLDOWN, /* while stopping */ + DTRACE_ACTIVITY_STOPPED, /* after stopping */ + DTRACE_ACTIVITY_KILLED /* killed */ +} dtrace_activity_t; + +/* + * DTrace Helper Implementation + * + * A description of the helper architecture may be found in . + * Each process contains a pointer to its helpers in its p_dtrace_helpers + * member. This is a pointer to a dtrace_helpers structure, which contains an + * array of pointers to dtrace_helper structures, helper variable state (shared + * among a process's helpers) and a generation count. (The generation count is + * used to provide an identifier when a helper is added so that it may be + * subsequently removed.) The dtrace_helper structure is self-explanatory, + * containing pointers to the objects needed to execute the helper. Note that + * helpers are _duplicated_ across fork(2), and destroyed on exec(2). No more + * than dtrace_helpers_max are allowed per-process. + */ +#define DTRACE_HELPER_ACTION_USTACK 0 +#define DTRACE_NHELPER_ACTIONS 1 + +typedef struct dtrace_helper_action { + int dtha_generation; /* helper action generation */ + int dtha_nactions; /* number of actions */ + dtrace_difo_t *dtha_predicate; /* helper action predicate */ + dtrace_difo_t **dtha_actions; /* array of actions */ + struct dtrace_helper_action *dtha_next; /* next helper action */ +} dtrace_helper_action_t; + +typedef struct dtrace_helper_provider { + int dthp_generation; /* helper provider generation */ + uint32_t dthp_ref; /* reference count */ + dof_helper_t dthp_prov; /* DOF w/ provider and probes */ +} dtrace_helper_provider_t; + +typedef struct dtrace_helpers { + dtrace_helper_action_t **dthps_actions; /* array of helper actions */ + dtrace_vstate_t dthps_vstate; /* helper action var. state */ + dtrace_helper_provider_t **dthps_provs; /* array of providers */ + uint_t dthps_nprovs; /* count of providers */ + uint_t dthps_maxprovs; /* provider array size */ + int dthps_generation; /* current generation */ + pid_t dthps_pid; /* pid of associated proc */ + int dthps_deferred; /* helper in deferred list */ + struct dtrace_helpers *dthps_next; /* next pointer */ + struct dtrace_helpers *dthps_prev; /* prev pointer */ +} dtrace_helpers_t; + +/* + * DTrace Helper Action Tracing + * + * Debugging helper actions can be arduous. To ease the development and + * debugging of helpers, DTrace contains a tracing-framework-within-a-tracing- + * framework: helper tracing. If dtrace_helptrace_enabled is non-zero (which + * it is by default on DEBUG kernels), all helper activity will be traced to a + * global, in-kernel ring buffer. Each entry includes a pointer to the specific + * helper, the location within the helper, and a trace of all local variables. + * The ring buffer may be displayed in a human-readable format with the + * ::dtrace_helptrace mdb(1) dcmd. + */ +#define DTRACE_HELPTRACE_NEXT (-1) +#define DTRACE_HELPTRACE_DONE (-2) +#define DTRACE_HELPTRACE_ERR (-3) + +typedef struct dtrace_helptrace { + dtrace_helper_action_t *dtht_helper; /* helper action */ + int dtht_where; /* where in helper action */ + int dtht_nlocals; /* number of locals */ + int dtht_fault; /* type of fault (if any) */ + int dtht_fltoffs; /* DIF offset */ + uint64_t dtht_illval; /* faulting value */ + uint64_t dtht_locals[1]; /* local variables */ +} dtrace_helptrace_t; + +/* + * DTrace Credentials + * + * In probe context, we have limited flexibility to examine the credentials + * of the DTrace consumer that created a particular enabling. We use + * the Least Privilege interfaces to cache the consumer's cred pointer and + * some facts about that credential in a dtrace_cred_t structure. These + * can limit the consumer's breadth of visibility and what actions the + * consumer may take. + */ +#define DTRACE_CRV_ALLPROC 0x01 +#define DTRACE_CRV_KERNEL 0x02 +#define DTRACE_CRV_ALLZONE 0x04 + +#define DTRACE_CRV_ALL (DTRACE_CRV_ALLPROC | DTRACE_CRV_KERNEL | \ + DTRACE_CRV_ALLZONE) + +#define DTRACE_CRA_PROC 0x0001 +#define DTRACE_CRA_PROC_CONTROL 0x0002 +#define DTRACE_CRA_PROC_DESTRUCTIVE_ALLUSER 0x0004 +#define DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE 0x0008 +#define DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG 0x0010 +#define DTRACE_CRA_KERNEL 0x0020 +#define DTRACE_CRA_KERNEL_DESTRUCTIVE 0x0040 + +#define DTRACE_CRA_ALL (DTRACE_CRA_PROC | \ + DTRACE_CRA_PROC_CONTROL | \ + DTRACE_CRA_PROC_DESTRUCTIVE_ALLUSER | \ + DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE | \ + DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG | \ + DTRACE_CRA_KERNEL | \ + DTRACE_CRA_KERNEL_DESTRUCTIVE) + +typedef struct dtrace_cred { + cred_t *dcr_cred; + uint8_t dcr_destructive; + uint8_t dcr_visible; + uint16_t dcr_action; +} dtrace_cred_t; + +/* + * DTrace Consumer State + * + * Each DTrace consumer has an associated dtrace_state structure that contains + * its in-kernel DTrace state -- including options, credentials, statistics and + * pointers to ECBs, buffers, speculations and formats. A dtrace_state + * structure is also allocated for anonymous enablings. When anonymous state + * is grabbed, the grabbing consumers dts_anon pointer is set to the grabbed + * dtrace_state structure. + */ +struct dtrace_state { + dev_t dts_dev; /* device */ + int dts_necbs; /* total number of ECBs */ + dtrace_ecb_t **dts_ecbs; /* array of ECBs */ + dtrace_epid_t dts_epid; /* next EPID to allocate */ + size_t dts_needed; /* greatest needed space */ + struct dtrace_state *dts_anon; /* anon. state, if grabbed */ + dtrace_activity_t dts_activity; /* current activity */ + dtrace_vstate_t dts_vstate; /* variable state */ + dtrace_buffer_t *dts_buffer; /* principal buffer */ + dtrace_buffer_t *dts_aggbuffer; /* aggregation buffer */ + dtrace_speculation_t *dts_speculations; /* speculation array */ + int dts_nspeculations; /* number of speculations */ + int dts_naggregations; /* number of aggregations */ + dtrace_aggregation_t **dts_aggregations; /* aggregation array */ + vmem_t *dts_aggid_arena; /* arena for aggregation IDs */ + uint64_t dts_errors; /* total number of errors */ + uint32_t dts_speculations_busy; /* number of spec. busy */ + uint32_t dts_speculations_unavail; /* number of spec unavail */ + uint32_t dts_stkstroverflows; /* stack string tab overflows */ + uint32_t dts_dblerrors; /* errors in ERROR probes */ + uint32_t dts_reserve; /* space reserved for END */ + hrtime_t dts_laststatus; /* time of last status */ + cyclic_id_t dts_cleaner; /* cleaning cyclic */ + cyclic_id_t dts_deadman; /* deadman cyclic */ + hrtime_t dts_alive; /* time last alive */ + char dts_speculates; /* boolean: has speculations */ + char dts_destructive; /* boolean: has dest. actions */ + int dts_nformats; /* number of formats */ + char **dts_formats; /* format string array */ + dtrace_optval_t dts_options[DTRACEOPT_MAX]; /* options */ + dtrace_cred_t dts_cred; /* credentials */ + size_t dts_nretained; /* number of retained enabs */ + int dts_getf; /* number of getf() calls */ +}; + +struct dtrace_provider { + dtrace_pattr_t dtpv_attr; /* provider attributes */ + dtrace_ppriv_t dtpv_priv; /* provider privileges */ + dtrace_pops_t dtpv_pops; /* provider operations */ + char *dtpv_name; /* provider name */ + void *dtpv_arg; /* provider argument */ + hrtime_t dtpv_defunct; /* when made defunct */ + struct dtrace_provider *dtpv_next; /* next provider */ +}; + +struct dtrace_meta { + dtrace_mops_t dtm_mops; /* meta provider operations */ + char *dtm_name; /* meta provider name */ + void *dtm_arg; /* meta provider user arg */ + uint64_t dtm_count; /* no. of associated provs. */ +}; + +/* + * DTrace Enablings + * + * A dtrace_enabling structure is used to track a collection of ECB + * descriptions -- before they have been turned into actual ECBs. This is + * created as a result of DOF processing, and is generally used to generate + * ECBs immediately thereafter. However, enablings are also generally + * retained should the probes they describe be created at a later time; as + * each new module or provider registers with the framework, the retained + * enablings are reevaluated, with any new match resulting in new ECBs. To + * prevent probes from being matched more than once, the enabling tracks the + * last probe generation matched, and only matches probes from subsequent + * generations. + */ +typedef struct dtrace_enabling { + dtrace_ecbdesc_t **dten_desc; /* all ECB descriptions */ + int dten_ndesc; /* number of ECB descriptions */ + int dten_maxdesc; /* size of ECB array */ + dtrace_vstate_t *dten_vstate; /* associated variable state */ + dtrace_genid_t dten_probegen; /* matched probe generation */ + dtrace_ecbdesc_t *dten_current; /* current ECB description */ + int dten_error; /* current error value */ + int dten_primed; /* boolean: set if primed */ + struct dtrace_enabling *dten_prev; /* previous enabling */ + struct dtrace_enabling *dten_next; /* next enabling */ +} dtrace_enabling_t; + +/* + * DTrace Anonymous Enablings + * + * Anonymous enablings are DTrace enablings that are not associated with a + * controlling process, but rather derive their enabling from DOF stored as + * properties in the dtrace.conf file. If there is an anonymous enabling, a + * DTrace consumer state and enabling are created on attach. The state may be + * subsequently grabbed by the first consumer specifying the "grabanon" + * option. As long as an anonymous DTrace enabling exists, dtrace(4D) will + * refuse to unload. + */ +typedef struct dtrace_anon { + dtrace_state_t *dta_state; /* DTrace consumer state */ + dtrace_enabling_t *dta_enabling; /* pointer to enabling */ + processorid_t dta_beganon; /* which CPU BEGIN ran on */ +} dtrace_anon_t; + +/* + * DTrace Error Debugging + */ +#ifdef DEBUG +#define DTRACE_ERRDEBUG +#endif + +#ifdef DTRACE_ERRDEBUG + +typedef struct dtrace_errhash { + const char *dter_msg; /* error message */ + int dter_count; /* number of times seen */ +} dtrace_errhash_t; + +#define DTRACE_ERRHASHSZ 256 /* must be > number of err msgs */ + +#endif /* DTRACE_ERRDEBUG */ + +/* + * DTrace Toxic Ranges + * + * DTrace supports safe loads from probe context; if the address turns out to + * be invalid, a bit will be set by the kernel indicating that DTrace + * encountered a memory error, and DTrace will propagate the error to the user + * accordingly. However, there may exist some regions of memory in which an + * arbitrary load can change system state, and from which it is impossible to + * recover from such a load after it has been attempted. Examples of this may + * include memory in which programmable I/O registers are mapped (for which a + * read may have some implications for the device) or (in the specific case of + * UltraSPARC-I and -II) the virtual address hole. The platform is required + * to make DTrace aware of these toxic ranges; DTrace will then check that + * target addresses are not in a toxic range before attempting to issue a + * safe load. + */ +typedef struct dtrace_toxrange { + uintptr_t dtt_base; /* base of toxic range */ + uintptr_t dtt_limit; /* limit of toxic range */ +} dtrace_toxrange_t; + +extern uint64_t dtrace_getarg(int, int); +extern greg_t dtrace_getfp(void); +extern int dtrace_getipl(void); +extern uintptr_t dtrace_caller(int); +extern uint32_t dtrace_cas32(uint32_t *, uint32_t, uint32_t); +extern void *dtrace_casptr(void *, void *, void *); +extern void dtrace_copyin(uintptr_t, uintptr_t, size_t, volatile uint16_t *); +extern void dtrace_copyinstr(uintptr_t, uintptr_t, size_t, volatile uint16_t *); +extern void dtrace_copyout(uintptr_t, uintptr_t, size_t, volatile uint16_t *); +extern void dtrace_copyoutstr(uintptr_t, uintptr_t, size_t, + volatile uint16_t *); +extern void dtrace_getpcstack(pc_t *, int, int, uint32_t *); +extern ulong_t dtrace_getreg(struct regs *, uint_t); +extern void dtrace_setreg(struct regs *, uint_t, ulong_t); +extern uint64_t dtrace_getvmreg(uint_t, volatile uint16_t *); +extern int dtrace_getstackdepth(int); +extern void dtrace_getupcstack(uint64_t *, int); +extern void dtrace_getufpstack(uint64_t *, uint64_t *, int); +extern int dtrace_getustackdepth(void); +extern uintptr_t dtrace_fulword(void *); +extern uint8_t dtrace_fuword8(void *); +extern uint16_t dtrace_fuword16(void *); +extern uint32_t dtrace_fuword32(void *); +extern uint64_t dtrace_fuword64(void *); +extern void dtrace_probe_error(dtrace_state_t *, dtrace_epid_t, int, int, + int, uintptr_t); +extern int dtrace_assfail(const char *, const char *, int); +extern int dtrace_attached(void); +extern hrtime_t dtrace_gethrestime(); + +#ifdef __sparc +extern void dtrace_flush_windows(void); +extern void dtrace_flush_user_windows(void); +extern uint_t dtrace_getotherwin(void); +extern uint_t dtrace_getfprs(void); +#else +extern void dtrace_copy(uintptr_t, uintptr_t, size_t); +extern void dtrace_copystr(uintptr_t, uintptr_t, size_t, volatile uint16_t *); +#endif + +/* + * DTrace Assertions + * + * DTrace calls ASSERT and VERIFY from probe context. To assure that a failed + * ASSERT or VERIFY does not induce a markedly more catastrophic failure (e.g., + * one from which a dump cannot be gleaned), DTrace must define its own ASSERT + * and VERIFY macros to be ones that may safely be called from probe context. + * This header file must thus be included by any DTrace component that calls + * ASSERT and/or VERIFY from probe context, and _only_ by those components. + * (The only exception to this is kernel debugging infrastructure at user-level + * that doesn't depend on calling ASSERT.) + */ +#undef ASSERT +#undef VERIFY +#define VERIFY(EX) ((void)((EX) || \ + dtrace_assfail(#EX, __FILE__, __LINE__))) +#ifdef DEBUG +#define ASSERT(EX) ((void)((EX) || \ + dtrace_assfail(#EX, __FILE__, __LINE__))) +#else +#define ASSERT(X) ((void)0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DTRACE_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/dumphdr.h b/illumos-x86_64/usr/include/sys/dumphdr.h new file mode 100644 index 00000000..2019f60a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/dumphdr.h @@ -0,0 +1,235 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016 by Delphix. All rights reserved. + */ + +#ifndef _SYS_DUMPHDR_H +#define _SYS_DUMPHDR_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The dump header describes the contents of a crash dump. Two headers + * are written out: one at the beginning of the dump, and the other at + * the very end of the dump device. The terminal header is at a known + * location (end of device) so we can always find it. The initial header + * is redundant, but helps savecore(8) determine whether the dump has been + * overwritten by swap activity. See dumpadm(8) for dump configuration. + */ +#define DUMP_MAGIC 0xdefec8edU /* dump magic number */ +#define DUMP_VERSION 10 /* version of this dumphdr */ +#define DUMP_WORDSIZE (sizeof (long) * NBBY) /* word size (32 or 64) */ +#define DUMP_PANICSIZE 200 /* Max panic string copied */ +#define DUMP_COMPRESS_RATIO 2 /* conservative; usually 2.5+ */ +#define DUMP_OFFSET 65536 /* pad at start/end of dev */ +#define DUMP_LOGSIZE (2 * LOG_HIWAT) /* /dev/log message save area */ +#define DUMP_ERPTSIZE (P2ROUNDUP( \ + (ERPT_DATA_SZ / 2) * \ + (ERPT_EVCH_MAX + \ + ERPT_MAX_ERRS * ERPT_HIWAT), \ + DUMP_OFFSET)) /* ereport save area */ +#define DUMP_SUMMARYSIZE (P2ROUNDUP( \ + (STACK_BUF_SIZE + \ + sizeof (summary_dump_t) + 1024), \ + DUMP_OFFSET)) /* summary save area */ + +typedef struct dumphdr { + uint32_t dump_magic; /* magic number */ + uint32_t dump_version; /* version number */ + uint32_t dump_flags; /* flags; see below */ + uint32_t dump_wordsize; /* 32 or 64 */ + offset_t dump_start; /* starting offset on dump device */ + offset_t dump_ksyms; /* offset of compressed symbol table */ + offset_t dump_pfn; /* offset of pfn table for all pages */ + offset_t dump_map; /* offset of page translation map */ + offset_t dump_data; /* offset of actual dump data */ + struct utsname dump_utsname; /* copy of utsname structure */ + char dump_platform[SYS_NMLN]; /* platform name (uname -i) */ + char dump_panicstring[DUMP_PANICSIZE]; /* copy of panicstr */ + time_t dump_crashtime; /* time of crash */ + long dump_pageshift; /* log2(pagesize) */ + long dump_pagesize; /* pagesize */ + long dump_hashmask; /* page translation hash mask */ + long dump_nvtop; /* number of vtop table entries */ + pgcnt_t dump_npages; /* number of data pages */ + size_t dump_ksyms_size; /* kernel symbol table size */ + size_t dump_ksyms_csize; /* compressed symbol table size */ + uint32_t dump_fm_panic; /* initiated from fm subsystems */ + char dump_uuid[36 + 1]; /* os image uuid */ +} dumphdr_t; + +/* + * Values for dump_flags + */ +#define DF_VALID 0x00000001 /* Dump is valid (savecore clears) */ +#define DF_COMPLETE 0x00000002 /* All pages present as configured */ +#define DF_LIVE 0x00000004 /* Dump was taken on a live system */ +#define DF_COMPRESSED 0x00000008 /* Dump is compressed */ +#define DF_KERNEL 0x00010000 /* Contains kernel pages only */ +#define DF_ALL 0x00020000 /* Contains all pages */ +#define DF_CURPROC 0x00040000 /* Contains kernel + cur proc pages */ +#define DF_CONTENT 0xffff0000 /* The set of all dump content flags */ + +/* + * Dump translation map hash table entry. + */ +typedef struct dump_map { + offset_t dm_first; + offset_t dm_next; + offset_t dm_data; + struct as *dm_as; + uintptr_t dm_va; +} dump_map_t; + +/* + * Dump translation map hash function. + */ +#define DUMP_HASH(dhp, as, va) \ + ((((uintptr_t)(as) >> 3) + ((va) >> (dhp)->dump_pageshift)) & \ + (dhp)->dump_hashmask) + +/* + * Encoding of the csize word used to provide meta information + * between dumpsys and savecore. + * + * tag size + * 1-4095 1..dump_maxcsize stream block + * 0 1..pagesize one lzjb page + * 0 0 marks end of data + */ +typedef uint32_t dumpcsize_t; + +#define DUMP_MAX_TAG (0xfffU) +#define DUMP_MAX_CSIZE (0xfffffU) +#define DUMP_SET_TAG(w, v) (((w) & DUMP_MAX_CSIZE) | ((v) << 20)) +#define DUMP_GET_TAG(w) (((w) >> 20) & DUMP_MAX_TAG) +#define DUMP_SET_CSIZE(w, v) \ + (((w) & (DUMP_MAX_TAG << 20)) | ((v) & DUMP_MAX_CSIZE)) +#define DUMP_GET_CSIZE(w) ((w) & DUMP_MAX_CSIZE) + +typedef struct dumpstreamhdr { + char stream_magic[8]; /* "StrmHdr" */ + pgcnt_t stream_pagenum; /* starting pfn */ + pgcnt_t stream_npages; /* uncompressed size */ +} dumpstreamhdr_t; + +#define DUMP_STREAM_MAGIC "StrmHdr" + +/* The number of helpers is limited by the number of stream tags. */ +#define DUMP_MAX_NHELPER DUMP_MAX_TAG + +/* + * The dump data header is placed after the dumphdr in the compressed + * image. It is not needed after savecore runs and the data pages have + * been decompressed. + */ +typedef struct dumpdatahdr { + uint32_t dump_datahdr_magic; /* data header presence */ + uint32_t dump_datahdr_version; /* data header version */ + uint64_t dump_data_csize; /* compressed data size */ + uint32_t dump_maxcsize; /* compressed data max block size */ + uint32_t dump_maxrange; /* max number of pages per range */ + uint16_t dump_nstreams; /* number of compression streams */ + uint16_t dump_clevel; /* compression level (0-9) */ + uint32_t dump_metrics; /* size of metrics data */ +} dumpdatahdr_t; + +#define DUMP_DATAHDR_MAGIC ('d' << 24 | 'h' << 16 | 'd' << 8 | 'r') + +#define DUMP_DATAHDR_VERSION 1 +#define DUMP_CLEVEL_LZJB 1 /* parallel lzjb compression */ +#define DUMP_CLEVEL_BZIP2 2 /* parallel bzip2 level 1 */ + +#ifdef _KERNEL + +extern kmutex_t dump_lock; +extern struct vnode *dumpvp; +extern u_offset_t dumpvp_size; +extern struct dumphdr *dumphdr; +extern int dump_conflags; +extern char *dumppath; + +extern int dump_timeout; +extern int dump_timeleft; +extern int dump_ioerr; + +extern int dumpinit(struct vnode *, char *, int); +extern void dumpfini(void); +extern void dump_resize(void); +extern void dump_page(pfn_t); +extern void dump_addpage(struct as *, void *, pfn_t); +extern void dumpsys(void); +extern void dumpsys_helper(void); +extern void dumpsys_helper_nw(void); +extern void dump_messages(void); +extern void dump_ereports(void); +extern void dumpvp_write(const void *, size_t); +extern int dumpvp_resize(void); +extern int dump_plat_addr(void); +extern void dump_plat_pfn(void); +extern int dump_plat_data(void *); +extern int dump_set_uuid(const char *); +extern const char *dump_get_uuid(void); + +/* + * Define a CPU count threshold that determines when to employ + * bzip2. This value is defined per-platform. + */ +extern uint_t dump_plat_mincpu_default; + +#define DUMP_PLAT_SUN4U_MINCPU 0 +#define DUMP_PLAT_SUN4U_OPL_MINCPU 0 +#define DUMP_PLAT_SUN4V_MINCPU 0 +#define DUMP_PLAT_X86_64_MINCPU 0 +#define DUMP_PLAT_X86_32_MINCPU 0 + +/* + * Override the per-platform default by setting this variable with + * /etc/system. The value 0 disables parallelism, and the old format + * dump is produced. + */ +extern uint_t dump_plat_mincpu; + +/* + * Pages may be stolen at dump time. Prevent the pages from ever being + * allocated while dump is running. + */ +#define IS_DUMP_PAGE(pp) (dump_check_used && dump_test_used((pp)->p_pagenum)) + +extern int dump_test_used(pfn_t); +extern int dump_check_used; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DUMPHDR_H */ diff --git a/illumos-x86_64/usr/include/sys/ecppio.h b/illumos-x86_64/usr/include/sys/ecppio.h new file mode 100644 index 00000000..4c56bc10 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ecppio.h @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992-1995,1997-2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_ECPPIO_H +#define _SYS_ECPPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define ECPPIOC_SETREGS _IOW('p', 73, struct ecpp_regs) +#define ECPPIOC_GETREGS _IOR('p', 74, struct ecpp_regs) +#define ECPPIOC_SETPORT _IOW('p', 77, uchar_t) +#define ECPPIOC_GETPORT _IOR('p', 78, uchar_t) +#define ECPPIOC_SETDATA _IOW('p', 79, uchar_t) +#define ECPPIOC_GETDATA _IOR('p', 80, uchar_t) + +#define ECPP_MAX_TIMEOUT 604800 /* one week */ +#define ECPP_W_TIMEOUT_DEFAULT 60 /* 60 seconds */ + +struct ecpp_regs { + uint8_t dsr; /* status reg */ + uint8_t dcr; /* control reg */ +}; + +_NOTE(SCHEME_PROTECTS_DATA("unique per call", ecpp_regs)) + +/* Values for dsr field */ +#define ECPP_EPP_TMOUT 0x01 +#define ECPP_DSR_reserved1 0x02 +#define ECPP_IRQ_ST 0x04 +#define ECPP_nERR 0x08 +#define ECPP_SLCT 0x10 +#define ECPP_PE 0x20 +#define ECPP_nACK 0x40 +#define ECPP_nBUSY 0x80 + +/* Values for the dcr field */ +#define ECPP_STB 0x01 +#define ECPP_AFX 0x02 +#define ECPP_nINIT 0x04 +#define ECPP_SLCTIN 0x08 +#define ECPP_INTR_EN 0x10 /* 1=enable */ +#define ECPP_REV_DIR 0x20 /* 1=reverse dir */ +#define ECPP_DCR_reserved6 0x40 +#define ECPP_DCR_reserved7 0x80 +#define ECPP_DCR_SET (ECPP_DCR_reserved6 | ECPP_DCR_reserved7) + +/* port types */ +#define ECPP_PORT_DMA 0x1 /* default */ +#define ECPP_PORT_PIO 0x2 +#define ECPP_PORT_TDMA 0x3 /* test fifo */ + +/* these bits are not modified by ECPPIOC_SETREGS/GETREGS */ +#define ECPP_SETREGS_DSR_MASK \ + (ECPP_EPP_TMOUT | ECPP_DSR_reserved1 | ECPP_IRQ_ST) +#define ECPP_SETREGS_DCR_MASK \ + (ECPP_INTR_EN | ECPP_REV_DIR | ECPP_DCR_SET) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ECPPIO_H */ diff --git a/illumos-x86_64/usr/include/sys/ecppreg.h b/illumos-x86_64/usr/include/sys/ecppreg.h new file mode 100644 index 00000000..f6976b7f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ecppreg.h @@ -0,0 +1,241 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1992-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ECPPREG_H +#define _SYS_ECPPREG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Register definitions for the National Semiconductor PC87332VLJ + * SuperI/O chip. + */ + +/* + * configuration registers + */ +struct config_reg { + uint8_t index; + uint8_t data; +}; + +/* index values for the configuration registers */ +#define FER 0x0 /* Function Enable Register */ +#define FAR 0x1 /* Function Address Register */ +#define PTR 0x2 /* Power and Test Register */ +#define FCR 0x3 /* Function Control Register */ +#define PCR 0x4 /* Printer Control Register */ +#define KRR 0x5 /* Keyboard and RTC control Register */ +#define PMC 0x6 /* Power Management Control register */ +#define TUP 0x7 /* Tape, UART, and Parallel port register */ +#define SID 0x8 /* Super I/O Identification register */ + +#define SIO_LITE 0x40 +#define SIO_LITE_B 0x90 +#define SIO_REVA 0x1a +#define SIO_REVB 0x1b + +/* bit definitions for the FCR register */ +#define PC87332_FCR_MSD_SEL 0x01 +#define PC87332_FCR_RESERVED 0x02 +#define PC87332_FCR_PPM_EN 0x04 +#define PC87332_FCR_PPM_FLOAT_CTL 0x08 +#define PC87332_FCR_LDX 0x10 +#define PC87332_FCR_ZWS_EN 0x20 +#define PC87332_FCR_ZWS_SEL 0x40 +#define PC87332_FCR_IOCHRDY_SEL 0x80 + +/* bit definitions for the PCR register */ +#define PC87332_PCR_EPP_EN 0x01 +#define PC87332_PCR_EPP_VER 0x02 +#define PC87332_PCR_ECP_EN 0x04 +#define PC87332_PCR_ECP_CLK_FZ 0x08 +#define PC87332_PCR_INTR_LEVL 0x10 +#define PC87332_PCR_INTR_POL 0x20 +#define PC87332_PCR_INTR_DRAIN 0x40 +#define PC87332_PCR_RESERVED 0x80 + +/* bit definitions for the PMC register */ +#define PC87332_PMC_IDE_TRISTATE 0x01 +#define PC87332_PMC_FDC_TRISTATE 0x02 +#define PC87332_PMC_UART_TRISTATE 0x04 +#define PC87332_PMC_ECP_DMA_CONFIG 0x08 +#define PC87332_PMC_FDC_PD 0x10 +#define PC87332_PMC_SLB 0x20 +#define PC87332_PMC_PP_TRISTATE 0x40 +#define PC87332_PMC_RESERVED 0x80 + +/* + * National 97317 superio registers + */ +#define PC97317_CONFIG_DEV_NO 0x07 +#define PC97317_CONFIG_ACTIVATE 0x30 +#define PC97317_CONFIG_IO_RANGE 0x31 +#define PC97317_CONFIG_BASE_ADDR_MSB 0x60 +#define PC97317_CONFIG_BASE_ADDR_LSB 0x61 +#define PC97317_CONFIG_INTR_SEL 0x70 +#define PC97317_CONFIG_INTR_TYPE 0x71 +#define PC97317_CONFIG_DMA0_CHAN 0x74 +#define PC97317_CONFIG_DMA1_CHAN 0x75 +#define PC97317_CONFIG_PP_CONFIG 0xF0 + +/* + * Plug N Play configuration superio registers + * used in PC97317 & M1553 + */ +#define PnP_CONFIG_DEV_NO 0x07 +#define PnP_CONFIG_ACTIVATE 0x30 +#define PnP_CONFIG_IO_RANGE 0x31 +#define PnP_CONFIG_BASE_ADDR_MSB 0x60 +#define PnP_CONFIG_BASE_ADDR_LSB 0x61 +#define PnP_CONFIG_INTR_SEL 0x70 +#define PnP_CONFIG_INTR_TYPE 0x71 +#define PnP_CONFIG_DMA0_CHAN 0x74 +#define PnP_CONFIG_DMA1_CHAN 0x75 +#define PnP_CONFIG_PP_CONFIG0 0xF0 +#define PnP_CONFIG_PP_CONFIG1 0xF1 + + +/* + * parallel port interface registers - same for all 1284 modes. + */ +struct info_reg { + union { + uint8_t datar; + uint8_t afifo; + } ir; + uint8_t dsr; + uint8_t dcr; + uint8_t epp_addr; + uint8_t epp_data; + uint8_t epp_data32[3]; +}; + +/* + * additional ECP mode registers. + */ +struct fifo_reg { + union { + uint8_t cfifo; + uint8_t dfifo; + uint8_t tfifo; + uint8_t config_a; + } fr; + uint8_t config_b; + uint8_t ecr; +}; + +/* + * Values for the ECR field + * + * The ECR has 3 read-only bits - bits 0,1,2. Bits 3,4,5,6,7 are read/write. + * While writing to this register (ECPPIOC_SETREGS), bits 0,1,2 must be 0. + * If not, ECPPIOC_SETREGS will return EINVAL. + */ + +#define ECPP_FIFO_EMPTY 0x01 /* 1 when FIFO empty */ +#define ECPP_FIFO_FULL 0x02 /* 1 when FIFO full */ +#define ECPP_INTR_SRV 0x04 + +/* + * When bit is 0, bit will be set to 1 + * and interrupt will be generated if + * any of the three events occur: + * (a) TC is reached while DMA enabled + * (b) If DMA disabled & DCR5 = 0, 8 or more bytes free in FIFO, + * (c) IF DMA disable & DCR5 = 1, 8 or more bytes to be read in FIFO. + * + * When this bit is 1, DMA & (a), (b), (c) + * interrupts are disabled. + */ + +#define ECPP_DMA_ENABLE 0x08 /* DMA enable =1 */ +#define ECPP_INTR_MASK 0x10 /* intr-enable nErr mask=1 */ +#define ECR_mode_000 0x00 /* PIO CENTRONICS */ +#define ECR_mode_001 0x20 /* PIO NIBBLE */ +#define ECR_mode_010 0x40 /* DMA CENTRONICS */ +#define ECR_mode_011 0x60 /* DMA ECP */ +#define ECR_mode_100 0x80 /* PIO EPP */ +#define ECR_mode_110 0xc0 /* TDMA (TFIFO) */ +#define ECR_mode_111 0xe0 /* Config Mode */ + +/* + * 97317 second level configuration registers + */ +struct config2_reg { + uint8_t eir; /* Extended Index Register */ + uint8_t edr; /* Extended Data Register */ +}; + +/* + * Second level offset + */ +#define PC97317_CONFIG2_CONTROL0 0x00 +#define PC97317_CONFIG2_CONTROL2 0x02 +#define PC97317_CONFIG2_CONTROL4 0x04 +#define PC97317_CONFIG2_PPCONFG0 0x05 + +/* Cheerio Ebus DMAC */ + +struct cheerio_dma_reg { + uint32_t csr; /* Data Control Status Register */ + uint32_t acr; /* DMA Address Count Registers */ + uint32_t bcr; /* DMA Byte Count Register */ +}; + +/* + * DMA Control and Status Register(DCSR) definitions. See Cheerio spec + * for more details + */ +#define DCSR_INT_PEND 0x00000001 /* 1= pport or dma interrupts */ +#define DCSR_ERR_PEND 0x00000002 /* 1= host bus error detected */ +#define DCSR_INT_EN 0x00000010 /* 1= enable sidewinder/ebus intr */ +#define DCSR_RESET 0x00000080 /* 1= resets the DCSR */ +#define DCSR_WRITE 0x00000100 /* DMA direction; 1 = memory */ +#define DCSR_EN_DMA 0x00000200 /* 1= enable DMA */ +#define DCSR_CYC_PEND 0x00000400 /* 1 = DMA pending */ +#define DCSR_EN_CNT 0x00002000 /* 1= enables byte counter */ +#define DCSR_TC 0x00004000 /* 1= Terminal Count occurred */ +#define DCSR_CSR_DRAIN 0x00000000 /* 1= disable draining */ +#define DCSR_BURST_0 0x00040000 /* Burst Size bit 0 */ +#define DCSR_BURST_1 0x00080000 /* Burst Size bit 1 */ +#define DCSR_DIAG 0x00000000 /* 1= diag enable */ +#define DCSR_TCI_DIS 0x00800000 /* 1= TC won't cause interrupt */ + + +/* Southbridge support */ +struct isaspace { + uchar_t isa_reg[0x500]; /* 0x500 regs from isa config space */ +}; + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ECPPREG_H */ diff --git a/illumos-x86_64/usr/include/sys/ecppsys.h b/illumos-x86_64/usr/include/sys/ecppsys.h new file mode 100644 index 00000000..e871e42a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ecppsys.h @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1990-2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_ECPPSYS_H +#define _SYS_ECPPSYS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define ECPPIOC_SETPARMS _IOW('p', 70, struct ecpp_transfer_parms) +#define ECPPIOC_GETPARMS _IOR('p', 71, struct ecpp_transfer_parms) +#define ECPPIOC_GETDEVID _IOWR('p', 73, struct ecpp_device_id) + +/* current_mode values */ +#define ECPP_CENTRONICS 0x01 /* non-1284 */ +#define ECPP_COMPAT_MODE 0x02 +#define ECPP_BYTE_MODE 0x03 +#define ECPP_NIBBLE_MODE 0x04 +#define ECPP_ECP_MODE 0x05 +#define ECPP_FAILURE_MODE 0x06 +#define ECPP_DIAG_MODE 0x07 +#define ECPP_INIT_MODE 0x08 +#define ECPP_EPP_MODE 0x09 + +typedef struct p1284_ioctl_st { + int array[10]; + char *cptr; + char *name; +} P1284Ioctl; + +struct ecpp_transfer_parms { + int write_timeout; + int mode; +}; + +/* + * Structure for retrieving IEEE 1284 Device ID + */ +struct ecpp_device_id { + int mode; /* mode to use for reading device id */ + int len; /* length of buffer */ + int rlen; /* actual length of device id string */ + char *addr; /* buffer address */ +#ifndef _LP64 + int filler[2]; +#endif +}; + +#ifdef _KERNEL +/* + * 32bit support for ioctl + */ +struct ecpp_device_id32 { + int mode; /* mode to use for reading device id */ + int len; /* length of buffer */ + int rlen; /* actual length of device id string */ + caddr32_t addr; /* buffer address */ + int filler[2]; +}; +#endif /* _KERNEL */ +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ECPPSYS_H */ diff --git a/illumos-x86_64/usr/include/sys/ecppvar.h b/illumos-x86_64/usr/include/sys/ecppvar.h new file mode 100644 index 00000000..c5159d4b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ecppvar.h @@ -0,0 +1,522 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ECPPVAR_H +#define _SYS_ECPPVAR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ecppunit; + +/* + * Hardware-abstraction structure + */ +struct ecpp_hw { + int (*map_regs)(struct ecppunit *); /* map registers */ + void (*unmap_regs)(struct ecppunit *); /* unmap registers */ + int (*config_chip)(struct ecppunit *); /* configure SuperIO */ + void (*config_mode)(struct ecppunit *); /* config new mode */ + void (*mask_intr)(struct ecppunit *); /* mask interrupts */ + void (*unmask_intr)(struct ecppunit *); /* unmask interrupts */ + int (*dma_start)(struct ecppunit *); /* start DMA transfer */ + int (*dma_stop)(struct ecppunit *, size_t *); /* stop DMA xfer */ + size_t (*dma_getcnt)(struct ecppunit *); /* get DMA counter */ + ddi_dma_attr_t *attr; /* DMA attributes */ +}; + +#define ECPP_MAP_REGS(pp) (pp)->hw->map_regs(pp) +#define ECPP_UNMAP_REGS(pp) (pp)->hw->unmap_regs(pp) +#define ECPP_CONFIG_CHIP(pp) (pp)->hw->config_chip(pp) +#define ECPP_CONFIG_MODE(pp) (pp)->hw->config_mode(pp) +#define ECPP_MASK_INTR(pp) (pp)->hw->mask_intr(pp) +#define ECPP_UNMASK_INTR(pp) (pp)->hw->unmask_intr(pp) +#define ECPP_DMA_START(pp) (pp)->hw->dma_start(pp) +#define ECPP_DMA_STOP(pp, cnt) (pp)->hw->dma_stop(pp, cnt) +#define ECPP_DMA_GETCNT(pp) (pp)->hw->dma_getcnt(pp) + +/* NSC 87332/97317 and EBus DMAC */ +struct ecpp_ebus { + struct config_reg *c_reg; /* configuration registers */ + ddi_acc_handle_t c_handle; /* handle for conf regs */ + struct cheerio_dma_reg *dmac; /* ebus dmac registers */ + ddi_acc_handle_t d_handle; /* handle for dmac registers */ + struct config2_reg *c2_reg; /* 97317 2nd level conf regs */ + ddi_acc_handle_t c2_handle; /* handle for c2_reg */ +}; + +/* Southbridge SuperIO and 8237 DMAC */ +struct ecpp_m1553 { + struct isaspace *isa_space; /* all of isa space */ + ddi_acc_handle_t d_handle; /* handle for isa space */ + uint8_t chn; /* 8237 dma channel */ + int isadma_entered; /* Southbridge DMA workaround */ +}; + +#if defined(__x86) +struct ecpp_x86 { + uint8_t chn; +}; +#endif + +/* + * Hardware binding structure + */ +struct ecpp_hw_bind { + char *name; /* binding name */ + struct ecpp_hw *hw; /* hw description */ + char *info; /* info string */ +}; + +/* ecpp e_busy states */ +typedef enum { + ECPP_IDLE = 1, /* No ongoing transfers */ + ECPP_BUSY = 2, /* Ongoing transfers on the cable */ + ECPP_DATA = 3, /* Not used */ + ECPP_ERR = 4, /* Bad status in Centronics mode */ + ECPP_FLUSH = 5 /* Currently flushing the q */ +} ecpp_busy_t; + +/* + * ecpp soft state structure + */ +struct ecppunit { + kmutex_t umutex; /* lock for this structure */ + int instance; /* instance number */ + dev_info_t *dip; /* device information */ + ddi_iblock_cookie_t ecpp_trap_cookie; /* interrupt cookie */ + ecpp_busy_t e_busy; /* ecpp busy flag */ + kcondvar_t pport_cv; /* cv to signal idle state */ + /* + * common SuperIO registers + */ + struct info_reg *i_reg; /* info registers */ + struct fifo_reg *f_reg; /* fifo register */ + ddi_acc_handle_t i_handle; + ddi_acc_handle_t f_handle; + /* + * DMA support + */ + ddi_dma_handle_t dma_handle; /* DMA handle */ + ddi_dma_cookie_t dma_cookie; /* current cookie */ + uint_t dma_cookie_count; /* # of cookies */ + uint_t dma_nwin; /* # of DMA windows */ + uint_t dma_curwin; /* current window number */ + uint_t dma_dir; /* transfer direction */ + /* + * hardware-dependent stuff + */ + struct ecpp_hw *hw; /* operations/attributes */ + union { /* hw-dependent data */ + struct ecpp_ebus ebus; + struct ecpp_m1553 m1553; +#if defined(__x86) + struct ecpp_x86 x86; +#endif + } uh; + /* + * DDI/STREAMS stuff + */ + boolean_t oflag; /* instance open flag */ + queue_t *readq; /* pointer to readq */ + queue_t *writeq; /* pointer to writeq */ + mblk_t *msg; /* current message block */ + boolean_t suspended; /* driver suspended status */ + /* + * Modes of operation + */ + int current_mode; /* 1284 mode */ + uchar_t current_phase; /* 1284 phase */ + uchar_t backchannel; /* backchannel mode supported */ + uchar_t io_mode; /* transfer mode: PIO/DMA */ + /* + * Ioctls support + */ + struct ecpp_transfer_parms xfer_parms; /* transfer parameters */ + struct ecpp_regs regs; /* control/status registers */ + uint8_t saved_dsr; /* store the dsr returned from TESTIO */ + boolean_t timeout_error; /* store the timeout for GETERR */ + uchar_t port; /* xfer type: dma/pio/tfifo */ + struct prn_timeouts prn_timeouts; /* prnio timeouts */ + /* + * ecpp.conf parameters + */ + uchar_t init_seq; /* centronics init seq */ + uint32_t wsrv_retry; /* delay (ms) before next wsrv */ + uint32_t wait_for_busy; /* wait for BUSY to deassert */ + uint32_t data_setup_time; /* pio centronics handshake */ + uint32_t strobe_pulse_width; /* pio centronics handshake */ + uint8_t fast_centronics; /* DMA/PIO centronics */ + uint8_t fast_compat; /* DMA/PIO 1284 compatible mode */ + uint32_t ecp_rev_speed; /* rev xfer speed in ECP, bytes/sec */ + uint32_t rev_watchdog; /* rev xfer watchdog period, ms */ + /* + * Timeouts + */ + timeout_id_t timeout_id; /* io transfers timer */ + timeout_id_t fifo_timer_id; /* drain SuperIO FIFO */ + timeout_id_t wsrv_timer_id; /* wsrv timeout */ + /* + * Softintr data + */ + ddi_softintr_t softintr_id; + int softintr_flags; /* flags indicating softintr task */ + uint8_t softintr_pending; + /* + * Misc stuff + */ + caddr_t ioblock; /* transfer buffer block */ + size_t xfercnt; /* # of bytes to transfer */ + size_t resid; /* # of bytes not transferred */ + caddr_t next_byte; /* next byte for PIO transfer */ + caddr_t last_byte; /* last byte for PIO transfer */ + uint32_t ecpp_drain_counter; /* allows fifo to drain */ + uchar_t dma_cancelled; /* flushed while dma'ing */ + uint8_t tfifo_intr; /* TFIFO switch interrupt workaround */ + size_t nread; /* requested read */ + size_t last_dmacnt; /* DMA counter value for rev watchdog */ + uint32_t rev_timeout_cnt; /* number of watchdog invocations */ + /* + * Spurious interrupt detection + */ + hrtime_t lastspur; /* last time spurious intrs started */ + long nspur; /* spurious intrs counter */ + /* + * Statistics + */ + kstat_t *ksp; /* kstat pointer */ + kstat_t *intrstats; /* kstat interrupt counter */ + /* + * number of bytes, transferred in and out in each mode + */ + uint32_t ctxpio_obytes; + uint32_t obytes[ECPP_EPP_MODE+1]; + uint32_t ibytes[ECPP_EPP_MODE+1]; + /* + * other stats + */ + uint32_t to_mode[ECPP_EPP_MODE+1]; /* # transitions to mode */ + uint32_t xfer_tout; /* # transfer timeouts */ + uint32_t ctx_cf; /* # periph check failures */ + uint32_t joblen; /* of bytes xfer'd since open */ + uint32_t isr_reattempt_high; /* max times isr has looped */ + /* + * interrupt stats + */ + uint_t intr_hard; + uint_t intr_spurious; + uint_t intr_soft; + /* + * identify second register set for ecp mode on Sx86 + */ + int noecpregs; +}; + +_NOTE(MUTEX_PROTECTS_DATA(ecppunit::umutex, ecppunit)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::dip)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::instance)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::i_reg)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::f_reg)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::i_handle)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::f_handle)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::ecpp_trap_cookie)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::readq)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::writeq)) + +/* + * current_phase values + */ +#define ECPP_PHASE_INIT 0x00 /* initialization */ +#define ECPP_PHASE_NEGO 0x01 /* negotiation */ +#define ECPP_PHASE_TERM 0x02 /* termination */ +#define ECPP_PHASE_PO 0x03 /* power-on */ + +#define ECPP_PHASE_C_FWD_DMA 0x10 /* cntrx/compat fwd dma xfer */ +#define ECPP_PHASE_C_FWD_PIO 0x11 /* cntrx/compat fwd PIO xfer */ +#define ECPP_PHASE_C_IDLE 0x12 /* cntrx/compat idle */ + +#define ECPP_PHASE_NIBT_REVDATA 0x20 /* nibble/byte reverse data */ +#define ECPP_PHASE_NIBT_AVAIL 0x21 /* nibble/byte reverse data available */ +#define ECPP_PHASE_NIBT_NAVAIL 0x22 /* nibble/byte reverse data not avail */ +#define ECPP_PHASE_NIBT_REVIDLE 0x22 /* nibble/byte reverse idle */ +#define ECPP_PHASE_NIBT_REVINTR 0x23 /* nibble/byte reverse interrupt */ + +#define ECPP_PHASE_ECP_SETUP 0x30 /* ecp setup */ +#define ECPP_PHASE_ECP_FWD_XFER 0x31 /* ecp forward transfer */ +#define ECPP_PHASE_ECP_FWD_IDLE 0x32 /* ecp forward idle */ +#define ECPP_PHASE_ECP_FWD_REV 0x33 /* ecp forward to reverse */ +#define ECPP_PHASE_ECP_REV_XFER 0x34 /* ecp reverse transfer */ +#define ECPP_PHASE_ECP_REV_IDLE 0x35 /* ecp reverse idle */ +#define ECPP_PHASE_ECP_REV_FWD 0x36 /* ecp reverse to forward */ + +#define ECPP_PHASE_EPP_INIT_IDLE 0x40 /* epp init phase */ +#define ECPP_PHASE_EPP_IDLE 0x41 /* epp all-round phase */ + +#define FAILURE_PHASE 0x80 +#define UNDEFINED_PHASE 0x81 + +/* ecpp return values */ +#define SUCCESS 1 +#define FAILURE 2 + +#define TRUE 1 +#define FALSE 0 + +/* message type */ +#define ECPP_BACKCHANNEL 0x45 + +/* transfer modes */ +#define ECPP_DMA 0x1 +#define ECPP_PIO 0x2 + +/* tuneable timing defaults */ +#define CENTRONICS_RETRY 750 /* 750 milliseconds */ +#define WAIT_FOR_BUSY 1000 /* 1000 microseconds */ +#define SUSPEND_TOUT 10 /* # seconds before suspend fails */ + +/* Centronics hanshaking defaults */ +#define DATA_SETUP_TIME 2 /* 2 uSec Data Setup Time (2x min) */ +#define STROBE_PULSE_WIDTH 2 /* 2 uSec Strobe Pulse (2x min) */ + +/* 1284 Extensibility Request values */ +#define ECPP_XREQ_NIBBLE 0x00 /* Nibble Mode Rev Channel Transfer */ +#define ECPP_XREQ_BYTE 0x01 /* Byte Mode Rev Channel Transfer */ +#define ECPP_XREQ_ID 0x04 /* Request Device ID */ +#define ECPP_XREQ_ECP 0x10 /* Request ECP Mode */ +#define ECPP_XREQ_ECPRLE 0x30 /* Request ECP Mode with RLE */ +#define ECPP_XREQ_EPP 0x40 /* Request EPP Mode */ +#define ECPP_XREQ_XLINK 0x80 /* Request Extensibility Link */ + +/* softintr flags */ +#define ECPP_SOFTINTR_PIONEXT 0x1 /* write next byte in PIO mode */ + +/* Stream defaults */ +#define IO_BLOCK_SZ 1024 * 128 /* transfer buffer size */ +#define ECPPHIWAT 32 * 1024 * 6 +#define ECPPLOWAT 32 * 1024 * 4 + +/* Loop timers */ +#define ECPP_REG_WRITE_MAX_LOOP 100 /* cpu is faster than superio */ +#define ECPP_ISR_MAX_DELAY 30 /* DMAC slow PENDING status */ + +/* misc constants */ +#define ECPP_FIFO_SZ 16 /* FIFO size */ +#define FIFO_DRAIN_PERIOD 250000 /* max FIFO drain period in usec */ +#define NIBBLE_REV_BLKSZ 1024 /* send up to # bytes at a time */ +#define FWD_TIMEOUT_DEFAULT 90 /* forward xfer timeout in seconds */ +#define REV_TIMEOUT_DEFAULT 0 /* reverse xfer timeout in seconds */ + +/* ECP mode constants */ +#define ECP_REV_BLKSZ 1024 /* send up to # bytes at a time */ +#define ECP_REV_BLKSZ_MAX (4 * 1024) /* maximum of # bytes */ +#define ECP_REV_SPEED (1 * 1024 * 1024) /* bytes/sec */ +#define ECP_REV_MINTOUT 5 /* min ECP rev xfer timeout in ms */ +#define REV_WATCHDOG 100 /* poll DMA counter every # ms */ + +/* spurious interrupt detection */ +#define SPUR_CRITICAL 100 /* number of interrupts... */ +#define SPUR_PERIOD 1000000000 /* in # ns */ + +/* + * Copyin/copyout states + */ +#define ECPP_STRUCTIN 0 +#define ECPP_STRUCTOUT 1 +#define ECPP_ADDRIN 2 +#define ECPP_ADDROUT 3 + +/* + * As other ioctls require the same structure, put inner struct's into union + */ +struct ecpp_copystate { + int state; /* see above */ + void *uaddr; /* user address of the following structure */ + union { + struct ecpp_device_id devid; + struct prn_1284_device_id prn_devid; + struct prn_interface_info prn_if; + } un; +}; + +/* + * The structure is dynamically created for each M_IOCTL and is bound to mblk + */ +_NOTE(SCHEME_PROTECTS_DATA("unique per call", ecpp_copystate)) + +/* kstat structure */ +struct ecppkstat { + /* + * number of bytes, transferred in and out in each mode + */ + struct kstat_named ek_ctx_obytes; + struct kstat_named ek_ctxpio_obytes; + struct kstat_named ek_nib_ibytes; + struct kstat_named ek_ecp_obytes; + struct kstat_named ek_ecp_ibytes; + struct kstat_named ek_epp_obytes; + struct kstat_named ek_epp_ibytes; + struct kstat_named ek_diag_obytes; + /* + * number of transitions to particular mode + */ + struct kstat_named ek_to_ctx; + struct kstat_named ek_to_nib; + struct kstat_named ek_to_ecp; + struct kstat_named ek_to_epp; + struct kstat_named ek_to_diag; + /* + * other stats + */ + struct kstat_named ek_xfer_tout; /* # transfer timeouts */ + struct kstat_named ek_ctx_cf; /* # periph check failures */ + struct kstat_named ek_joblen; /* # bytes xfer'd since open */ + struct kstat_named ek_isr_reattempt_high; /* max # times */ + /* isr has looped */ + struct kstat_named ek_mode; /* 1284 mode */ + struct kstat_named ek_phase; /* 1284 ECP phase */ + struct kstat_named ek_backchan; /* backchannel mode supported */ + struct kstat_named ek_iomode; /* transfer mode: pio/dma */ + struct kstat_named ek_state; /* ecpp busy flag */ +}; + +/* Macros for superio programming */ +#define PP_PUTB(x, y, z) ddi_put8(x, y, z) +#define PP_GETB(x, y) ddi_get8(x, y) + +#define DSR_READ(pp) PP_GETB((pp)->i_handle, &(pp)->i_reg->dsr) +#define DCR_READ(pp) PP_GETB((pp)->i_handle, &(pp)->i_reg->dcr) +#define ECR_READ(pp) \ + (pp->noecpregs) ? 0xff : PP_GETB((pp)->f_handle, &(pp)->f_reg->ecr) +#define DATAR_READ(pp) PP_GETB((pp)->i_handle, &(pp)->i_reg->ir.datar) +#define DFIFO_READ(pp) \ + (pp->noecpregs) ? 0xff : PP_GETB((pp)->f_handle, &(pp)->f_reg->fr.dfifo) +#define TFIFO_READ(pp) \ + (pp->noecpregs) ? 0xff : PP_GETB((pp)->f_handle, &(pp)->f_reg->fr.tfifo) + +#define DCR_WRITE(pp, val) PP_PUTB((pp)->i_handle, &(pp)->i_reg->dcr, val) +#define ECR_WRITE(pp, val) \ + if (!pp->noecpregs) PP_PUTB((pp)->f_handle, &(pp)->f_reg->ecr, val) +#define DATAR_WRITE(pp, val) \ + PP_PUTB((pp)->i_handle, &(pp)->i_reg->ir.datar, val) +#define DFIFO_WRITE(pp, val) \ + if (!pp->noecpregs) PP_PUTB((pp)->f_handle, &(pp)->f_reg->fr.dfifo, val) +#define TFIFO_WRITE(pp, val) \ + if (!pp->noecpregs) PP_PUTB((pp)->f_handle, &(pp)->f_reg->fr.tfifo, val) + +/* + * Macros to manipulate register bits + */ +#define OR_SET_BYTE_R(handle, addr, val) \ +{ \ + uint8_t tmpval; \ + tmpval = ddi_get8(handle, (uint8_t *)addr); \ + tmpval |= val; \ + ddi_put8(handle, (uint8_t *)addr, tmpval); \ +} + +#define OR_SET_LONG_R(handle, addr, val) \ +{ \ + uint32_t tmpval; \ + tmpval = ddi_get32(handle, (uint32_t *)addr); \ + tmpval |= val; \ + ddi_put32(handle, (uint32_t *)addr, tmpval); \ +} + +#define AND_SET_BYTE_R(handle, addr, val) \ +{ \ + uint8_t tmpval; \ + tmpval = ddi_get8(handle, (uint8_t *)addr); \ + tmpval &= val; \ + ddi_put8(handle, (uint8_t *)addr, tmpval); \ +} + +#define AND_SET_LONG_R(handle, addr, val) \ +{ \ + uint32_t tmpval; \ + tmpval = ddi_get32(handle, (uint32_t *)addr); \ + tmpval &= val; \ + ddi_put32(handle, (uint32_t *)addr, tmpval); \ +} + +#define NOR_SET_LONG_R(handle, addr, val, mask) \ +{ \ + uint32_t tmpval; \ + tmpval = ddi_get32(handle, (uint32_t *)addr); \ + tmpval &= ~(mask); \ + tmpval |= val; \ + ddi_put32(handle, (uint32_t *)addr, tmpval); \ +} + +/* + * Macros for Cheerio/RIO DMAC programming + */ +#define SET_DMAC_CSR(pp, val) ddi_put32(pp->uh.ebus.d_handle, \ + ((uint32_t *)&pp->uh.ebus.dmac->csr), \ + ((uint32_t)val)) +#define GET_DMAC_CSR(pp) ddi_get32(pp->uh.ebus.d_handle, \ + (uint32_t *)&(pp->uh.ebus.dmac->csr)) + +#define SET_DMAC_ACR(pp, val) ddi_put32(pp->uh.ebus.d_handle, \ + ((uint32_t *)&pp->uh.ebus.dmac->acr), \ + ((uint32_t)val)) + +#define GET_DMAC_ACR(pp) ddi_get32(pp->uh.ebus.d_handle, \ + (uint32_t *)&pp->uh.ebus.dmac->acr) + +#define SET_DMAC_BCR(pp, val) ddi_put32(pp->uh.ebus.d_handle, \ + ((uint32_t *)&pp->uh.ebus.dmac->bcr), \ + ((uint32_t)val)) + +#define GET_DMAC_BCR(pp) ddi_get32(pp->uh.ebus.d_handle, \ + ((uint32_t *)&pp->uh.ebus.dmac->bcr)) + +#define DMAC_RESET_TIMEOUT 10000 /* in usec */ + +/* + * Macros to distinguish between PIO and DMA Compatibility mode + */ +#define COMPAT_PIO(pp) (((pp)->io_mode == ECPP_PIO) && \ + ((pp)->current_mode == ECPP_CENTRONICS || \ + (pp)->current_mode == ECPP_COMPAT_MODE)) + +#define COMPAT_DMA(pp) (((pp)->io_mode == ECPP_DMA) && \ + ((pp)->current_mode == ECPP_CENTRONICS || \ + (pp)->current_mode == ECPP_COMPAT_MODE)) + +/* + * Other useful macros + */ +#define NELEM(a) (sizeof (a) / sizeof (*(a))) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ECPPVAR_H */ diff --git a/illumos-x86_64/usr/include/sys/edonr.h b/illumos-x86_64/usr/include/sys/edonr.h new file mode 100644 index 00000000..e65118dc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/edonr.h @@ -0,0 +1,93 @@ +/* + * IDI,NTNU + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright (C) 2009, 2010, Jorn Amundsen + * + * Tweaked Edon-R implementation for SUPERCOP, based on NIST API. + * + * $Id: edonr.h 517 2013-02-17 20:34:39Z joern $ + */ +/* + * Portions copyright (c) 2013, Saso Kiselkov, All rights reserved + */ + +#ifndef _SYS_EDONR_H_ +#define _SYS_EDONR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * EdonR allows to call EdonRUpdate() consecutively only if the total length + * of stored unprocessed data and the new supplied data is less than or equal + * to the BLOCK_SIZE on which the compression functions operates. + * Otherwise an assertion failure is invoked. + */ + +/* Specific algorithm definitions */ +#define EdonR224_DIGEST_SIZE 28 +#define EdonR224_BLOCK_SIZE 64 +#define EdonR256_DIGEST_SIZE 32 +#define EdonR256_BLOCK_SIZE 64 +#define EdonR384_DIGEST_SIZE 48 +#define EdonR384_BLOCK_SIZE 128 +#define EdonR512_DIGEST_SIZE 64 +#define EdonR512_BLOCK_SIZE 128 + +#define EdonR256_BLOCK_BITSIZE 512 +#define EdonR512_BLOCK_BITSIZE 1024 + +typedef struct { + uint32_t DoublePipe[16]; + uint8_t LastPart[EdonR256_BLOCK_SIZE * 2]; +} EdonRData256; +typedef struct { + uint64_t DoublePipe[16]; + uint8_t LastPart[EdonR512_BLOCK_SIZE * 2]; +} EdonRData512; + +typedef struct { + size_t hashbitlen; + + /* + algorithm specific parameters */ + int unprocessed_bits; + uint64_t bits_processed; + union { + EdonRData256 p256[1]; + EdonRData512 p512[1]; + } pipe[1]; +} EdonRState; + +void EdonRInit(EdonRState *state, size_t hashbitlen); +void EdonRUpdate(EdonRState *state, const uint8_t *data, size_t databitlen); +void EdonRFinal(EdonRState *state, uint8_t *hashval); +void EdonRHash(size_t hashbitlen, const uint8_t *data, size_t databitlen, + uint8_t *hashval); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EDONR_H_ */ diff --git a/illumos-x86_64/usr/include/sys/efi_partition.h b/illumos-x86_64/usr/include/sys/efi_partition.h new file mode 100644 index 00000000..4061cb4c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/efi_partition.h @@ -0,0 +1,273 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * Copyright 2014 Toomas Soome + * Copyright (c) 2019, Joyent, Inc. + */ + +#ifndef _SYS_EFI_PARTITION_H +#define _SYS_EFI_PARTITION_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * GUID Partition Table Header + */ + +#define EFI_LABEL_SIZE 512 +#define LEN_EFI_PAD (EFI_LABEL_SIZE - \ + ((5 * sizeof (diskaddr_t)) + \ + (7 * sizeof (uint_t)) + \ + (8 * sizeof (char)) + \ + (1 * (sizeof (struct uuid))))) + +#define EFI_SIGNATURE 0x5452415020494645ULL + +/* + * Although the EFI spec is clear that sizeof (efi_gpt_t) is a valid value + * (512), at least one EFI system (AMI v4.6.4.1) incorrectly expects this to be + * exactly the size of the structure defined in the spec, that is, 92. + * + * As the reserved section is never used, the modified value works fine + * everywhere else. + */ +#define EFI_HEADER_SIZE (offsetof(efi_gpt_t, efi_gpt_Reserved2)) + +/* EFI Guid Partition Table Header -- little endian on-disk format */ +typedef struct efi_gpt { + uint64_t efi_gpt_Signature; + uint_t efi_gpt_Revision; + uint_t efi_gpt_HeaderSize; + uint_t efi_gpt_HeaderCRC32; + uint_t efi_gpt_Reserved1; + diskaddr_t efi_gpt_MyLBA; + diskaddr_t efi_gpt_AlternateLBA; + diskaddr_t efi_gpt_FirstUsableLBA; + diskaddr_t efi_gpt_LastUsableLBA; + struct uuid efi_gpt_DiskGUID; + diskaddr_t efi_gpt_PartitionEntryLBA; + uint_t efi_gpt_NumberOfPartitionEntries; + uint_t efi_gpt_SizeOfPartitionEntry; + uint_t efi_gpt_PartitionEntryArrayCRC32; + char efi_gpt_Reserved2[LEN_EFI_PAD]; +} efi_gpt_t; + +/* EFI Guid Partition Entry Attributes -- little endian format */ +typedef struct efi_gpe_Attrs { + uint32_t PartitionAttrs :16, + Reserved2 :16; + uint32_t Reserved1 :31, + RequiredPartition :1; +} efi_gpe_Attrs_t; + +/* + * 6a96237f-1dd2-11b2-99a6-080020736631 V_UNASSIGNED (not used as such) + * 6a82cb45-1dd2-11b2-99a6-080020736631 V_BOOT + * 6a85cf4d-1dd2-11b2-99a6-080020736631 V_ROOT + * 6a87c46f-1dd2-11b2-99a6-080020736631 V_SWAP + * 6a898cc3-1dd2-11b2-99a6-080020736631 V_USR + * 6a8b642b-1dd2-11b2-99a6-080020736631 V_BACKUP + * 6a8d2ac7-1dd2-11b2-99a6-080020736631 V_STAND (not used) + * 6a8ef2e9-1dd2-11b2-99a6-080020736631 V_VAR + * 6a90ba39-1dd2-11b2-99a6-080020736631 V_HOME + * 6a9283a5-1dd2-11b2-99a6-080020736631 V_ALTSCTR + * 6a945a3b-1dd2-11b2-99a6-080020736631 V_CACHE + */ + +#define EFI_UNUSED { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, \ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } +#define EFI_RESV1 { 0x6a96237f, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_BOOT { 0x6a82cb45, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_ROOT { 0x6a85cf4d, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_SWAP { 0x6a87c46f, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_USR { 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_BACKUP { 0x6a8b642b, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_RESV2 { 0x6a8d2ac7, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_VAR { 0x6a8ef2e9, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_HOME { 0x6a90ba39, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_ALTSCTR { 0x6a9283a5, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_RESERVED { 0x6a945a3b, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_SYSTEM { 0xC12A7328, 0xF81F, 0x11d2, 0xBA, 0x4B, \ + { 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } } +#define EFI_LEGACY_MBR { 0x024DEE41, 0x33E7, 0x11d3, 0x9D, 0x69, \ + { 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F } } +#define EFI_SYMC_PUB { 0x6a9630d1, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_SYMC_CDS { 0x6a980767, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_MSFT_RESV { 0xE3C9E316, 0x0B5C, 0x4DB8, 0x81, 0x7D, \ + { 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } } +#define EFI_DELL_BASIC { 0xebd0a0a2, 0xb9e5, 0x4433, 0x87, 0xc0, \ + { 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } } +#define EFI_DELL_RAID { 0xa19d880f, 0x05fc, 0x4d3b, 0xa0, 0x06, \ + { 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e } } +#define EFI_DELL_SWAP { 0x0657fd6d, 0xa4ab, 0x43c4, 0x84, 0xe5, \ + { 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f } } +#define EFI_DELL_LVM { 0xe6d6d379, 0xf507, 0x44c2, 0xa2, 0x3c, \ + { 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28 } } +#define EFI_DELL_RESV { 0x8da63339, 0x0007, 0x60c0, 0xc4, 0x36, \ + { 0x08, 0x3a, 0xc8, 0x23, 0x09, 0x08 } } +#define EFI_AAPL_BOOT { 0x426F6F74, 0x0000, 0x11aa, 0xaa, 0x11, \ + { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } +#define EFI_AAPL_HFS { 0x48465300, 0x0000, 0x11aa, 0xaa, 0x11, \ + { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } +#define EFI_AAPL_UFS { 0x55465300, 0x0000, 0x11aa, 0xaa, 0x11, \ + { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } +#define EFI_AAPL_ZFS { 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \ + { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } +#define EFI_AAPL_APFS { 0x7c3457ef, 0x0000, 0x11aa, 0xaa, 0x11, \ + { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } +#define EFI_FREEBSD_BOOT { 0x83bd6b9d, 0x7f41, 0x11dc, 0xbe, 0x0b, \ + { 0x00, 0x15, 0x60, 0xb8, 0x4f, 0x0f } } +#define EFI_FREEBSD_NANDFS { 0x74ba7dd9, 0xa689, 0x11e1, 0xbd, 0x04, \ + { 0x00, 0xe0, 0x81, 0x28, 0x6a, 0xcf } } +#define EFI_FREEBSD_SWAP { 0x516e7cb5, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ + { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } +#define EFI_FREEBSD_UFS { 0x516e7cb6, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ + { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } +#define EFI_FREEBSD_VINUM { 0x516e7cb8, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ + { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } +#define EFI_FREEBSD_ZFS { 0x516e7cba, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ + { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } +#define EFI_BIOS_BOOT { 0x21686148, 0x6449, 0x6e6f, 0x74, 0x4e, \ + { 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } } + +/* minimum # of bytes for partition table entires, per EFI spec */ +#define EFI_MIN_ARRAY_SIZE (16 * 1024) + +#define EFI_PART_NAME_LEN 36 + +/* size of the "reserved" partition, in blocks */ +#define EFI_MIN_RESV_SIZE (16 * 1024) + +/* EFI Guid Partition Entry */ +typedef struct efi_gpe { + struct uuid efi_gpe_PartitionTypeGUID; + struct uuid efi_gpe_UniquePartitionGUID; + diskaddr_t efi_gpe_StartingLBA; + diskaddr_t efi_gpe_EndingLBA; + efi_gpe_Attrs_t efi_gpe_Attributes; + ushort_t efi_gpe_PartitionName[EFI_PART_NAME_LEN]; +} efi_gpe_t; + +/* + * passed to the useful (we hope) routines (efi_alloc_and_read and + * efi_write) that take this VTOC-like struct. These routines handle + * converting this struct into the EFI struct, generate UUIDs and + * checksums, and perform any necessary byte-swapping to the on-disk + * format. + */ +/* Solaris library abstraction for EFI partitons */ +typedef struct dk_part { + diskaddr_t p_start; /* starting LBA */ + diskaddr_t p_size; /* size in blocks */ + struct uuid p_guid; /* partion type GUID */ + ushort_t p_tag; /* converted to part'n type GUID */ + ushort_t p_flag; /* attributes */ + char p_name[EFI_PART_NAME_LEN]; /* partition name */ + struct uuid p_uguid; /* unique partition GUID */ + uint_t p_resv[8]; /* future use - set to zero */ +} dk_part_t; + +/* Solaris library abstraction for an EFI GPT */ +#define EFI_VERSION102 0x00010002 +#define EFI_VERSION100 0x00010000 +#define EFI_VERSION_CURRENT EFI_VERSION100 +typedef struct dk_gpt { + uint_t efi_version; /* set to EFI_VERSION_CURRENT */ + uint_t efi_nparts; /* number of partitions below */ + uint_t efi_part_size; /* size of each partition entry */ + /* efi_part_size is unused */ + uint_t efi_lbasize; /* size of block in bytes */ + diskaddr_t efi_last_lba; /* last block on the disk */ + diskaddr_t efi_first_u_lba; /* first block after labels */ + diskaddr_t efi_last_u_lba; /* last block before backup labels */ + struct uuid efi_disk_uguid; /* unique disk GUID */ + uint_t efi_flags; + uint_t efi_reserved1; /* future use - set to zero */ + diskaddr_t efi_altern_lba; /* lba of alternate GPT header */ + uint_t efi_reserved[12]; /* future use - set to zero */ + struct dk_part efi_parts[1]; /* array of partitions */ +} dk_gpt_t; + +/* possible values for "efi_flags" */ +#define EFI_GPT_PRIMARY_CORRUPT 0x1 /* primary label corrupt */ + +/* the private ioctl between libefi and the driver */ +typedef struct dk_efi { + diskaddr_t dki_lba; /* starting block */ + len_t dki_length; /* length in bytes */ + union { + efi_gpt_t *_dki_data; + uint64_t _dki_data_64; + } dki_un; +#define dki_data dki_un._dki_data +#define dki_data_64 dki_un._dki_data_64 +} dk_efi_t; + +struct partition64 { + struct uuid p_type; + uint_t p_partno; + uint_t p_resv1; + diskaddr_t p_start; + diskaddr_t p_size; +}; + +/* + * Number of EFI partitions + */ +#define EFI_NUMPAR 9 + +#ifndef _KERNEL +extern uint_t efi_reserved_sectors(struct dk_gpt *); +extern int efi_alloc_and_init(int, uint32_t, struct dk_gpt **); +extern int efi_alloc_and_read(int, struct dk_gpt **); +extern int efi_write(int, struct dk_gpt *); +extern void efi_free(struct dk_gpt *); +extern int efi_type(int); +extern void efi_err_check(struct dk_gpt *); +extern int efi_auto_sense(int fd, struct dk_gpt **); +extern int efi_use_whole_disk(int fd); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EFI_PARTITION_H */ diff --git a/illumos-x86_64/usr/include/sys/elf.h b/illumos-x86_64/usr/include/sys/elf.h new file mode 100644 index 00000000..bfd8a39a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/elf.h @@ -0,0 +1,1055 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2012 DEY Storage Systems, Inc. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2024 Oxide Computer Company + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_ELF_H +#define _SYS_ELF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define ELF32_FSZ_ADDR 4 +#define ELF32_FSZ_HALF 2 +#define ELF32_FSZ_OFF 4 +#define ELF32_FSZ_SWORD 4 +#define ELF32_FSZ_WORD 4 + +#define ELF64_FSZ_ADDR 8 +#define ELF64_FSZ_HALF 2 +#define ELF64_FSZ_OFF 8 +#define ELF64_FSZ_SWORD 4 +#define ELF64_FSZ_WORD 4 +#define ELF64_FSZ_SXWORD 8 +#define ELF64_FSZ_XWORD 8 + +/* + * "Enumerations" below use ...NUM as the number of + * values in the list. It should be 1 greater than the + * highest "real" value. + */ + +/* + * ELF header + */ + +#define EI_NIDENT 16 + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* ident bytes */ + Elf32_Half e_type; /* file type */ + Elf32_Half e_machine; /* target machine */ + Elf32_Word e_version; /* file version */ + Elf32_Addr e_entry; /* start address */ + Elf32_Off e_phoff; /* phdr file offset */ + Elf32_Off e_shoff; /* shdr file offset */ + Elf32_Word e_flags; /* file flags */ + Elf32_Half e_ehsize; /* sizeof ehdr */ + Elf32_Half e_phentsize; /* sizeof phdr */ + Elf32_Half e_phnum; /* number phdrs */ + Elf32_Half e_shentsize; /* sizeof shdr */ + Elf32_Half e_shnum; /* number shdrs */ + Elf32_Half e_shstrndx; /* shdr string index */ +} Elf32_Ehdr; + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* ident bytes */ + Elf64_Half e_type; /* file type */ + Elf64_Half e_machine; /* target machine */ + Elf64_Word e_version; /* file version */ + Elf64_Addr e_entry; /* start address */ + Elf64_Off e_phoff; /* phdr file offset */ + Elf64_Off e_shoff; /* shdr file offset */ + Elf64_Word e_flags; /* file flags */ + Elf64_Half e_ehsize; /* sizeof ehdr */ + Elf64_Half e_phentsize; /* sizeof phdr */ + Elf64_Half e_phnum; /* number phdrs */ + Elf64_Half e_shentsize; /* sizeof shdr */ + Elf64_Half e_shnum; /* number shdrs */ + Elf64_Half e_shstrndx; /* shdr string index */ +} Elf64_Ehdr; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ + + +#define EI_MAG0 0 /* e_ident[] indexes */ +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 /* File class */ +#define EI_DATA 5 /* Data encoding */ +#define EI_VERSION 6 /* File version */ +#define EI_OSABI 7 /* Operating system/ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define EI_PAD 9 /* Start of padding bytes */ + +#define ELFMAG0 0x7f /* EI_MAG */ +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define ELFCLASSNONE 0 /* EI_CLASS */ +#define ELFCLASS32 1 +#define ELFCLASS64 2 +#define ELFCLASSNUM 3 + +#define ELFDATANONE 0 /* EI_DATA */ +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 +#define ELFDATANUM 3 + +#define ET_NONE 0 /* e_type */ +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_NUM 5 +#define ET_LOOS 0xfe00 /* OS specific range */ +#define ET_LOSUNW 0xfeff +#define ET_SUNWPSEUDO 0xfeff +#define ET_HISUNW 0xfeff +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 /* processor specific range */ +#define ET_HIPROC 0xffff + +#define ET_LOPROC 0xff00 /* processor specific range */ +#define ET_HIPROC 0xffff + +#define EM_NONE 0 /* e_machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* Sun SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel 80486 */ +#define EM_860 7 /* Intel i860 */ +#define EM_MIPS 8 /* MIPS RS3000 Big-Endian */ +#define EM_S370 9 /* IBM System/370 Processor */ +#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-Endian */ +#define EM_RS6000 11 /* RS6000 */ +#define EM_UNKNOWN12 12 +#define EM_UNKNOWN13 13 +#define EM_UNKNOWN14 14 +#define EM_PA_RISC 15 /* PA-RISC */ +#define EM_PARISC EM_PA_RISC /* Alias: GNU compatibility */ +#define EM_nCUBE 16 /* nCUBE */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Sun SPARC 32+ */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* 64-bit PowerPC */ +#define EM_S390 22 /* IBM System/390 Processor */ +#define EM_UNKNOWN22 EM_S390 /* Alias: Older published name */ +#define EM_UNKNOWN23 23 +#define EM_UNKNOWN24 24 +#define EM_UNKNOWN25 25 +#define EM_UNKNOWN26 26 +#define EM_UNKNOWN27 27 +#define EM_UNKNOWN28 28 +#define EM_UNKNOWN29 29 +#define EM_UNKNOWN30 30 +#define EM_UNKNOWN31 31 +#define EM_UNKNOWN32 32 +#define EM_UNKNOWN33 33 +#define EM_UNKNOWN34 34 +#define EM_UNKNOWN35 35 +#define EM_V800 36 /* NEX V800 */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* Advanced RISC Marchines ARM */ +#define EM_ALPHA 41 /* Digital Alpha */ +#define EM_SH 42 /* Hitachi SH */ +#define EM_SPARCV9 43 /* Sun SPARC V9 (64-bit) */ +#define EM_TRICORE 44 /* Siemens Tricore embedded processor */ +#define EM_ARC 45 /* Argonaut RISC Core, */ + /* Argonaut Technologies Inc. */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel IA64 */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola ColdFire */ +#define EM_68HC12 53 /* Motorola M68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Mulimedia Accelerator */ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Star*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ */ + /* embedded processor family */ +#define EM_AMD64 62 /* AMDs x86-64 architecture */ +#define EM_X86_64 EM_AMD64 /* (compatibility) */ + +#define EM_PDSP 63 /* Sony DSP Processor */ +#define EM_UNKNOWN64 64 +#define EM_UNKNOWN65 65 +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+8/16 bit */ + /* microcontroller */ +#define EM_ST7 68 /* STMicroelectronics ST7 8-bit */ + /* microcontroller */ +#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8-bit */ + /* microcontroller */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit */ + /* embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit */ + /* embedded processor */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /* Donald Knuth's educational */ + /* 64-bit processor */ +#define EM_HUANY 81 /* Harvard University */ + /* machine-independent */ + /* object files */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa architecture */ + +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose */ + /* Processor */ +#define EM_NS32K 97 /* National Semiconductor 32000 series */ +#define EM_TPC 98 /* Tenor Network TPC processor */ +#define EM_SNP1K 99 /* Trebia SNP 1000 processor */ +#define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200 */ + /* microcontroller */ +#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */ +#define EM_MAX 102 /* MAX Processor */ +#define EM_CR 103 /* National Semiconductor CompactRISC */ + /* microprocessor */ +#define EM_F2MC16 104 /* Fujitsu F2MC16 */ +#define EM_MSP430 105 /* Texas Instruments embedded microcontroller */ + /* msp430 */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */ +#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */ +#define EM_SEP 108 /* Sharp embedded microprocessor */ +#define EM_ARCA 109 /* Arca RISC Microprocessor */ +#define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. */ + /* and MPRC of Peking University */ +#define EM_EXCESS 111 /* eXcess: 16/32/64-bit configurable embedded */ + /* CPU */ +#define EM_DXP 112 /* Icera Semiconductor Inc. Deep Execution */ + /* Processor */ +#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ +#define EM_CRX 114 /* National Semiconductor CompactRISC CRX */ + /* microprocessor */ +#define EM_XGATE 115 /* Motorola XGATE embedded processor */ +#define EM_C166 116 /* Infineon C16x/XC16x processor */ +#define EM_M16C 117 /* Renesas M16C series microprocessors */ +#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F Digital */ + /* Signal Controller */ +#define EM_CE 119 /* Freescale Communication Engine RISC core */ +#define EM_M32C 120 /* Renesas M32C series microprocessors */ + +#define EM_TSK3000 131 /* Altium TSK3000 core */ +#define EM_RS08 132 /* Freescale RS08 embedded processor */ +#define EM_SHARC 133 /* Analog Devices SHARC family of 32-bit DSP */ + /* processors */ +#define EM_ECOG2 134 /* Cyan Technology eCOG2 microprocessor */ +#define EM_SCORE7 135 /* Sunplus S+core7 RISC processor */ +#define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP Processor */ +#define EM_VIDEOCORE3 137 /* Broadcom VideoCore III processor */ +#define EM_LATTICEMICO32 138 /* RISC processor for Lattice FPGA */ + /* architecture */ +#define EM_SE_C17 139 /* Seiko Epson C17 family */ +#define EM_TI_C6000 140 /* The Texas Instruments TMS320C6000 DSP */ + /* family */ +#define EM_TI_C2000 141 /* The Texas Instruments TMS320C2000 DSP */ + /* family */ +#define EM_TI_C5500 142 /* The Texas Instruments TMS320C55x DSP */ + /* family */ +#define EM_TI_ARP32 143 /* Texas Instruments Application Specific */ + /* RISC Processor, 32bit fetch */ +#define EM_TI_PRU 144 /* Texas Instruments Programmable Realtime */ + /* Unit */ + +#define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW Data Signal */ + /* Processor */ +#define EM_CYPRESS_M8C 161 /* Cypress M8C microprocessor */ +#define EM_R32C 162 /* Renesas R32C series microprocessors */ +#define EM_TRIMEDIA 163 /* NXP Semiconductors TriMedia architecture */ + /* family */ +#define EM_QDSP6 164 /* QUALCOMM DSP6 Processor */ +#define EM_8051 165 /* Intel 8051 and variants */ +#define EM_STXP7X 166 /* STMicroelectronics STxP7x family of */ + /* configurable and extensible RISC */ + /* processors */ +#define EM_NDS32 167 /* Andes Technology compact code size */ + /* embedded RISC processor family */ +#define EM_ECOG1 168 /* Cyan Technology eCOG1X family */ +#define EM_ECOG1X EM_EC0G1X /* Cyan Technology eCOG1X family */ +#define EM_MAXQ30 169 /* Dallas Semiconductor MAXQ30 Core */ + /* Micro-controllers */ +#define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP Processor */ +#define EM_MANIK 171 /* M2000 Reconfigurable RISC Microprocessor */ +#define EM_CRAYNV2 172 /* Cray Inc. NV2 vector architecture */ +#define EM_RX 173 /* Renesas RX family */ +#define EM_METAG 174 /* Imagination Technologies META processor */ + /* architecture */ +#define EM_MCST_ELBRUS 175 /* MCST Elbrus general purpose hardware */ + /* architecture */ +#define EM_ECOG16 176 /* Cyan Technology eCOG16 family */ +#define EM_CR16 177 /* National Semiconductor CompactRISC */ + /* CR16 16-bit microprocessor */ +#define EM_ETPU 178 /* Freescale Extended Time Processing Unit */ +#define EM_SLE9X 179 /* Infineon Technologies SLE9X core */ +#define EM_L10M 180 /* Intel L10M */ +#define EM_K10M 181 /* Intel K10M */ + +#define EM_AARCH64 183 /* ARM 64-bit architecture (AARCH64) */ + +#define EM_AVR32 185 /* Atmel Corporation 32-bit microprocessor */ + /* family */ +#define EM_STM8 186 /* STMicroeletronics STM8 8-bit */ + /* microcontroller */ +#define EM_TILE64 187 /* Tilera TILE64 multicore architecture */ + /* family */ +#define EM_TILEPRO 188 /* Tilera TILEPro multicore architecture */ + /* family */ +#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze 32-bit RISC soft */ + /* processor core */ +#define EM_CUDA 190 /* NVIDIA CUDA architecture */ +#define EM_TILEGX 191 /* Tilera TILE-Gx multicore architecture */ + /* family */ +#define EM_CLOUDSHIELD 192 /* CloudShield architecture family */ +#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st generation processor */ + /* family */ +#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd generation processor */ + /* family */ +#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */ +#define EM_OPEN8 196 /* Open8 8-bit RISC soft processor core */ +#define EM_RL78 197 /* Renesas RL78 family */ +#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V processor */ +#define EM_78KOR 199 /* Renesas 78KOR family */ +#define EM_56800EX 200 /* Freescale 56800EX Digital Signal */ + /* Controller (DSC) */ +#define EM_BA1 201 /* Beyond BA1 CPU architecture */ +#define EM_BA2 202 /* Beyond BA2 CPU architecture */ +#define EM_XCORE 203 /* XMOS xCORE processor family */ +#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) family */ +#define EM_INTEL205 205 /* Reserved by Intel */ +#define EM_INTEL206 206 /* Reserved by Intel */ +#define EM_INTEL207 207 /* Reserved by Intel */ +#define EM_INTEL208 208 /* Reserved by Intel */ +#define EM_INTEL209 209 /* Reserved by Intel */ +#define EM_KM32 210 /* KM211 KM32 32-bit processor */ +#define EM_KMX32 211 /* KM211 KMX32 32-bit processor */ +#define EM_KMX16 212 /* KM211 KMX16 16-bit processor */ +#define EM_KMX8 213 /* KM211 KMX8 8-bit processor */ +#define EM_KVARC 214 /* KM211 KVARC processor */ +#define EM_CDP 215 /* Paneve CDP architecture family */ +#define EM_COGE 216 /* Cognitive Smart Memory Processor */ +#define EM_COOL 217 /* Bluechip Systems CoolEngine */ +#define EM_NORC 218 /* Nanoradio Optimized RISC */ +#define EM_CSR_KALIMBA 219 /* CSR Kalimba architecture family */ +#define EM_Z80 220 /* Zilog Z80 */ +#define EM_VISIUM 221 /* Controls and Data Services VISIUMcore */ + /* processor */ +#define EM_FT32 222 /* FTDI Chip FT32 high performance 32-bit */ + /* RISC architecture */ +#define EM_MOXIE 223 /* Moxie processor family */ +#define EM_AMDGPU 224 /* AMD GPU architecture */ + +/* 225-242 reserved */ + +#define EM_RISCV 243 /* RISC-V */ +#define EM_LANAI 244 /* Lanai processor */ +#define EM_CEVA 245 /* CEVA Processor Architecture Family */ +#define EM_CEVA_X2 246 /* CEVA X2 Processor Family */ +#define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */ +#define EM_GRAPHCORE_IPU 248 /* Graphcore Intelligent Processing Unit */ +#define EM_IMG1 249 /* Imagination Technologies */ +#define EM_NFP 250 /* Netronome Flow Processor */ +#define EM_VE 251 /* NEC Vector Engine */ +#define EM_CSKY 252 /* C-SKY processor family */ +#define EM_ARC_COMPACT3_64 253 /* Synopsys ARCv2.3 64-bit */ +#define EM_MCS6502 254 /* MOS Technology MCS 6502 processor */ +#define EM_ARC_COMPACT3 255 /* Synopsys ARCv2.3 32-bit */ +#define EM_KVX 256 /* Kalray VLIW core of the MPPA family */ +#define EM_65816 257 /* WDC 65816/65C816 */ +#define EM_LOONGARCH 258 /* Loongson Loongarch */ +#define EM_KF32 259 /* ChipON KungFu32 */ +#define EM_U16_U8CORE 260 /* LAPIS nX-U16/U8 */ +#define EM_TACHYUM 261 /* Reserved for Tachyum processor */ +#define EM_56800EF 262 /* NXP 56800EF Digital Signal Controller */ +#define EM_SBF 263 /* Solana Bytecode Format */ +#define EM_AIENGINE 264 /* AMD/Xilinx AIEngine architecture */ +#define EM_SIMA_MLA 265 /* SiMa MLA */ +#define EM_BANG 266 /* Cambricon BANG */ +#define EM_LOONGGPU 267 /* Loongson LoongGPU */ +#define EM_SW64 268 /* Wuxi Institute Of Advanced Technology SW64 */ +#define EM_AIECTRLCODE 269 /* AMD/Xilinx AIEngine ctrlcode */ + +#define EM_NUM EM_AIECTRLCODE + 1 + +#define EV_NONE 0 /* e_version, EI_VERSION */ +#define EV_CURRENT 1 +#define EV_NUM 2 + + +#define ELFOSABI_NONE 0 /* No extensions or unspecified */ +#define ELFOSABI_SYSV ELFOSABI_NONE +#define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_GNU 3 /* GNU */ +#define ELFOSABI_LINUX ELFOSABI_GNU /* historical alias for GNU */ +#define ELFOSABI_UNKNOWN4 4 +#define ELFOSABI_UNKNOWN5 5 +#define ELFOSABI_SOLARIS 6 /* Sun Solaris */ +#define ELFOSABI_AIX 7 /* AIX */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* Open BSD */ +#define ELFOSABI_OPENVMS 13 /* Open VMS */ +#define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ +#define ELFOSABI_FENIXOS 16 /* The FenixOS highly scalable */ + /* multi-core OS */ +#define ELFOSABI_CLOUDABI 17 /* Nuxi CloudABI */ +#define ELFOSABI_OPENVOS 18 /* Stratus Technologies OpenVOS */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* standalone (embedded) application */ + +#define EAV_SUNW_NONE 0 /* EI_ABIVERSION */ +#define EAV_SUNW_CURRENT 1 +#define EAV_SUNW_NUM 2 + + +/* + * Program header + */ + +typedef struct { + Elf32_Word p_type; /* entry type */ + Elf32_Off p_offset; /* file offset */ + Elf32_Addr p_vaddr; /* virtual address */ + Elf32_Addr p_paddr; /* physical address */ + Elf32_Word p_filesz; /* file size */ + Elf32_Word p_memsz; /* memory size */ + Elf32_Word p_flags; /* entry flags */ + Elf32_Word p_align; /* memory/file alignment */ +} Elf32_Phdr; + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Word p_type; /* entry type */ + Elf64_Word p_flags; /* entry flags */ + Elf64_Off p_offset; /* file offset */ + Elf64_Addr p_vaddr; /* virtual address */ + Elf64_Addr p_paddr; /* physical address */ + Elf64_Xword p_filesz; /* file size */ + Elf64_Xword p_memsz; /* memory size */ + Elf64_Xword p_align; /* memory/file alignment */ +} Elf64_Phdr; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ + + +#define PT_NULL 0 /* p_type */ +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_TLS 7 +#define PT_NUM 8 + +#define PT_LOOS 0x60000000 /* OS specific range */ + +/* + * PT_SUNW_UNWIND and PT_SUNW_EH_FRAME perform the same function, + * providing access to the .eh_frame_hdr section of the object. + * PT_SUNW_UNWIND is the original value, while PT_SUNW_EH_FRAME is + * required by the amd64 psABI. The Solaris link-editor (ld) tags output + * objects with PT_SUNW_UNWIND, but the Solaris runtime linker (ld.so.1) + * will accept and use either value. + */ +#define PT_SUNW_UNWIND 0x6464e550 +#define PT_SUNW_EH_FRAME 0x6474e550 +#define PT_GNU_EH_FRAME PT_SUNW_EH_FRAME + +/* + * Linux specific program headers not currently used by Solaris + */ +#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ +#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ + +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment (unused) */ +#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ +#define PT_SUNWDTRACE 0x6ffffffc /* private */ +#define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */ +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff + +#define PT_LOPROC 0x70000000 /* processor specific range */ +#define PT_HIPROC 0x7fffffff + +#define PF_R 0x4 /* p_flags */ +#define PF_W 0x2 +#define PF_X 0x1 + +#define PF_MASKOS 0x0ff00000 /* OS specific values */ +#define PF_MASKPROC 0xf0000000 /* processor specific values */ + +#define PF_SUNW_FAILURE 0x00100000 /* mapping absent due to failure */ +#define PF_SUNW_KILLED 0x00200000 /* signal received during dump */ +#define PF_SUNW_SIGINFO 0x00400000 /* segment has killing sig's siginfo */ + +#define PN_XNUM 0xffff /* extended program header index */ + +/* + * Section header + */ + +typedef struct { + Elf32_Word sh_name; /* section name */ + Elf32_Word sh_type; /* SHT_... */ + Elf32_Word sh_flags; /* SHF_... */ + Elf32_Addr sh_addr; /* virtual address */ + Elf32_Off sh_offset; /* file offset */ + Elf32_Word sh_size; /* section size */ + Elf32_Word sh_link; /* misc info */ + Elf32_Word sh_info; /* misc info */ + Elf32_Word sh_addralign; /* memory alignment */ + Elf32_Word sh_entsize; /* entry size if table */ +} Elf32_Shdr; + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Word sh_name; /* section name */ + Elf64_Word sh_type; /* SHT_... */ + Elf64_Xword sh_flags; /* SHF_... */ + Elf64_Addr sh_addr; /* virtual address */ + Elf64_Off sh_offset; /* file offset */ + Elf64_Xword sh_size; /* section size */ + Elf64_Word sh_link; /* misc info */ + Elf64_Word sh_info; /* misc info */ + Elf64_Xword sh_addralign; /* memory alignment */ + Elf64_Xword sh_entsize; /* entry size if table */ +} Elf64_Shdr; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ + +#define SHT_NULL 0 /* sh_type */ +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_UNKNOWN12 12 +#define SHT_UNKNOWN13 13 +#define SHT_INIT_ARRAY 14 +#define SHT_FINI_ARRAY 15 +#define SHT_PREINIT_ARRAY 16 +#define SHT_GROUP 17 +#define SHT_SYMTAB_SHNDX 18 +#define SHT_NUM 19 + +/* Solaris ABI specific values */ +#define SHT_LOOS 0x60000000 /* OS specific range */ +#define SHT_LOSUNW 0x6fffffef +#define SHT_SUNW_capchain 0x6fffffef +#define SHT_SUNW_capinfo 0x6ffffff0 +#define SHT_SUNW_symsort 0x6ffffff1 +#define SHT_SUNW_tlssort 0x6ffffff2 +#define SHT_SUNW_LDYNSYM 0x6ffffff3 +#define SHT_SUNW_dof 0x6ffffff4 +#define SHT_SUNW_cap 0x6ffffff5 +#define SHT_SUNW_SIGNATURE 0x6ffffff6 +#define SHT_SUNW_ANNOTATE 0x6ffffff7 +#define SHT_SUNW_DEBUGSTR 0x6ffffff8 +#define SHT_SUNW_DEBUG 0x6ffffff9 +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_SUNW_verdef 0x6ffffffd +#define SHT_GNU_verdef SHT_SUNW_verdef +#define SHT_SUNW_verneed 0x6ffffffe +#define SHT_GNU_verneed SHT_SUNW_verneed +#define SHT_SUNW_versym 0x6fffffff +#define SHT_GNU_versym SHT_SUNW_versym +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff + +/* + * GNU/Linux OSABI specific values with different meanings than under Solaris. + * Due to the overlap in assigned values with the Solaris OSABI, correct + * interpretation of these values requires knowledge of the OSABI used by + * the object. + */ +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */ +#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ +#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content */ + +/* + * LLVM-specific section types, actually independent of any (ELF) OS. + * See: https://llvm.org/docs/Extensions.html + */ +#define SHT_LLVM_ODRTAB 0x6fff4c00 /* ODR Table */ +#define SHT_LLVM_LINKER_OPTIONS 0x6fff4c01 /* Linker options */ +#define SHT_LLVM_UNKNOWN1 0x6fff4c02 /* previously call graph profile */ +#define SHT_LLVM_ADDRSIG 0x6fff4c03 /* significant address table */ +#define SHT_LLVM_DEPENDENT_LIBRARIES 0x6fff4c04 /* dependent libraries. */ +#define SHT_LLVM_SYMPART 0x6fff4c05 /* symbol partition specs. */ +#define SHT_LLVM_PART_EHDR 0x6fff4c06 /* ehdr for loadable part. */ +#define SHT_LLVM_PART_PHDR 0x6fff4c07 /* phdrs for loadable part. */ +#define SHT_LLVM_BB_ADDR_MAP 0x6fff4c08 /* basic block addr map */ +#define SHT_LLVM_CALL_GRAPH_PROFILE 0x6fff4c09 /* call graph profile */ + +#define SHT_LOPROC 0x70000000 /* processor specific range */ +#define SHT_HIPROC 0x7fffffff + +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0xffffffff + +#define SHF_WRITE 0x01 /* sh_flags */ +#define SHF_ALLOC 0x02 +#define SHF_EXECINSTR 0x04 +#define SHF_MERGE 0x10 +#define SHF_STRINGS 0x20 +#define SHF_INFO_LINK 0x40 +#define SHF_LINK_ORDER 0x80 +#define SHF_OS_NONCONFORMING 0x100 +#define SHF_GROUP 0x200 +#define SHF_TLS 0x400 + +#define SHF_MASKOS 0x0ff00000 /* OS specific values */ + + +#define SHF_MASKPROC 0xf0000000 /* processor specific values */ + +#define SHN_UNDEF 0 /* special section numbers */ +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 /* processor specific range */ +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 /* OS specific range */ +#define SHN_LOSUNW 0xff3f +#define SHN_SUNW_IGNORE 0xff3f +#define SHN_HISUNW 0xff3f +#define SHN_HIOS 0xff3f +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_XINDEX 0xffff /* extended sect index */ +#define SHN_HIRESERVE 0xffff + + + +/* + * Symbol table + */ + +typedef struct { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; /* bind, type: ELF_32_ST_... */ + unsigned char st_other; + Elf32_Half st_shndx; /* SHN_... */ +} Elf32_Sym; + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Word st_name; + unsigned char st_info; /* bind, type: ELF_64_ST_... */ + unsigned char st_other; + Elf64_Half st_shndx; /* SHN_... */ + Elf64_Addr st_value; + Elf64_Xword st_size; +} Elf64_Sym; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ + +#define STN_UNDEF 0 + +/* + * Macros to compose and decompose values for S.st_info + * + * bind = ELF32_ST_BIND(S.st_info) + * type = ELF32_ST_TYPE(S.st_info) + * S.st_info = ELF32_ST_INFO(bind, type) + */ + +#define ELF32_ST_BIND(info) ((info) >> 4) +#define ELF32_ST_TYPE(info) ((info) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind)<<4)+((type)&0xf)) + +#define ELF64_ST_BIND(info) ((info) >> 4) +#define ELF64_ST_TYPE(info) ((info) & 0xf) +#define ELF64_ST_INFO(bind, type) (((bind)<<4)+((type)&0xf)) + + +#define STB_LOCAL 0 /* BIND */ +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_NUM 3 + +#define STB_LOOS 10 /* operating system specific range */ +#define STB_HIOS 12 + +#define STB_LOPROC 13 /* processor specific range */ +#define STB_HIPROC 15 + +#define STT_NOTYPE 0 /* symbol type is unspecified */ +#define STT_OBJECT 1 /* data object */ +#define STT_FUNC 2 /* code object */ +#define STT_SECTION 3 /* symbol identifies an ELF section */ +#define STT_FILE 4 /* symbol's name is file name */ +#define STT_COMMON 5 /* common data object */ +#define STT_TLS 6 /* thread-local data object */ +#define STT_NUM 7 /* # defined types in generic range */ +#define STT_LOOS 10 /* OS specific range */ +#define STT_HIOS 12 +#define STT_LOPROC 13 /* processor specific range */ +#define STT_HIPROC 15 + +/* + * Macros to decompose values for S.st_other + * + * visibility = ELF32_ST_VISIBILITY(S.st_other) + */ +#define ELF32_ST_VISIBILITY(other) ((other)&0x7) +#define ELF64_ST_VISIBILITY(other) ((other)&0x7) + +#define STV_DEFAULT 0 +#define STV_INTERNAL 1 +#define STV_HIDDEN 2 +#define STV_PROTECTED 3 +#define STV_EXPORTED 4 +#define STV_SINGLETON 5 +#define STV_ELIMINATE 6 + +#define STV_NUM 7 + +/* + * Relocation + */ + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; /* sym, type: ELF32_R_... */ +} Elf32_Rel; + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; /* sym, type: ELF32_R_... */ + Elf32_Sword r_addend; +} Elf32_Rela; + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; /* sym, type: ELF64_R_... */ +} Elf64_Rel; + +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; /* sym, type: ELF64_R_... */ + Elf64_Sxword r_addend; +} Elf64_Rela; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ + + +/* + * Macros to compose and decompose values for Rel.r_info, Rela.f_info + * + * sym = ELF32_R_SYM(R.r_info) + * type = ELF32_R_TYPE(R.r_info) + * R.r_info = ELF32_R_INFO(sym, type) + */ + +#define ELF32_R_SYM(info) ((info)>>8) +#define ELF32_R_TYPE(info) ((unsigned char)(info)) +#define ELF32_R_INFO(sym, type) (((sym)<<8)+(unsigned char)(type)) + +#define ELF64_R_SYM(info) ((info)>>32) +#define ELF64_R_TYPE(info) ((Elf64_Word)(info)) +#define ELF64_R_INFO(sym, type) (((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type)) + + +/* + * The r_info field is composed of two 32-bit components: the symbol + * table index and the relocation type. The relocation type for SPARC V9 + * is further decomposed into an 8-bit type identifier and a 24-bit type + * dependent data field. For the existing Elf32 relocation types, + * that data field is zero. + */ +#define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40) +#define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56) +#define ELF64_R_TYPE_INFO(data, type) \ + (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type)) + + +/* + * Section Group Flags (SHT_GROUP) + */ +#define GRP_COMDAT 0x01 + + +/* + * Note entry header + */ + +typedef struct { + Elf32_Word n_namesz; /* length of note's name */ + Elf32_Word n_descsz; /* length of note's "desc" */ + Elf32_Word n_type; /* type of note */ +} Elf32_Nhdr; + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Word n_namesz; /* length of note's name */ + Elf64_Word n_descsz; /* length of note's "desc" */ + Elf64_Word n_type; /* type of note */ +} Elf64_Nhdr; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ + +/* + * Move entry + */ +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf32_Lword m_value; /* symbol value */ + Elf32_Word m_info; /* size + index */ + Elf32_Word m_poffset; /* symbol offset */ + Elf32_Half m_repeat; /* repeat count */ + Elf32_Half m_stride; /* stride info */ +} Elf32_Move; + +/* + * Macros to compose and decompose values for Move.r_info + * + * sym = ELF32_M_SYM(M.m_info) + * size = ELF32_M_SIZE(M.m_info) + * M.m_info = ELF32_M_INFO(sym, size) + */ +#define ELF32_M_SYM(info) ((info)>>8) +#define ELF32_M_SIZE(info) ((unsigned char)(info)) +#define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) + +typedef struct { + Elf64_Lword m_value; /* symbol value */ + Elf64_Xword m_info; /* size + index */ + Elf64_Xword m_poffset; /* symbol offset */ + Elf64_Half m_repeat; /* repeat count */ + Elf64_Half m_stride; /* stride info */ +} Elf64_Move; +#define ELF64_M_SYM(info) ((info)>>8) +#define ELF64_M_SIZE(info) ((unsigned char)(info)) +#define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) + +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ + + +/* + * Capabilities entry, Capabilities info and Capabilities chain. + */ +#ifndef _ASM +typedef struct { + Elf32_Word c_tag; /* how to interpret value */ + union { + Elf32_Word c_val; + Elf32_Addr c_ptr; + } c_un; +} Elf32_Cap; + +typedef Elf32_Word Elf32_Capinfo; +typedef Elf32_Word Elf32_Capchain; + +/* + * Macros to compose and decompose values for capabilities info. + * + * sym = ELF32_C_SYM(info) + * grp = ELF32_C_GROUP(info) + * info = ELF32_C_INFO(sym, grp) + */ +#define ELF32_C_SYM(info) ((info)>>8) +#define ELF32_C_GROUP(info) ((unsigned char)(info)) +#define ELF32_C_INFO(sym, grp) (((sym)<<8)+(unsigned char)(grp)) + + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Xword c_tag; /* how to interpret value */ + union { + Elf64_Xword c_val; + Elf64_Addr c_ptr; + } c_un; +} Elf64_Cap; + +typedef Elf64_Xword Elf64_Capinfo; +typedef Elf64_Word Elf64_Capchain; + +/* + * Macros to compose and decompose values for capabilities info. + * + * sym = ELF64_C_SYM(info) + * grp = ELF64_C_GROUP(info) + * info = ELF64_C_INFO(sym, grp) + */ +#define ELF64_C_SYM(info) ((info)>>32) +#define ELF64_C_GROUP(info) ((Elf64_Word)(info)) +#define ELF64_C_INFO(sym, grp) (((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(grp)) + +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ +#endif + +/* + * Version numbers for SHT_SUNW_capinfo and SHT_SUNW_capchain. + */ +#define CAPINFO_NONE 0 +#define CAPINFO_CURRENT 1 +#define CAPINFO_NUM 2 + +#define CAPCHAIN_NONE 0 +#define CAPCHAIN_CURRENT 1 +#define CAPCHAIN_NUM 2 + +/* + * A SHT_SUNW_capinfo table mirrors a symbol table. A capabilities symbol has + * a SHT_SUNW_capinfo table entry that provides an index into the associated + * SHT_SUNW_cap capabilities group, and the symbol index of the associated lead + * symbol. A capabilities symbol is a local symbol. A global lead capabilities + * symbol is tagged with a group CAPINFO_SUNW_GLOB. + */ +#define CAPINFO_SUNW_GLOB 0xff + +/* + * Capabilities values. + */ +#define CA_SUNW_NULL 0 +#define CA_SUNW_HW_1 1 /* first hardware capabilities entry */ +#define CA_SUNW_SF_1 2 /* first software capabilities entry */ +#define CA_SUNW_HW_2 3 /* second hardware capabilities entry */ +#define CA_SUNW_PLAT 4 /* platform capability entry */ +#define CA_SUNW_MACH 5 /* machine capability entry */ +#define CA_SUNW_ID 6 /* capability identifier */ +#define CA_SUNW_HW_3 7 /* third hardware capabilities entry */ +#define CA_SUNW_NUM 8 + +/* + * Define software capabilities (CA_SUNW_SF_1 values). Note, hardware + * capabilities (CA_SUNW_HW_1 values) are taken directly from sys/auxv_$MACH.h. + */ +#define SF1_SUNW_FPKNWN 0x001 /* frame pointer usage is known */ +#define SF1_SUNW_FPUSED 0x002 /* frame pointer is in use */ +#define SF1_SUNW_ADDR32 0x004 /* 32-bit address space requirement */ +#define SF1_SUNW_MASK 0x007 /* known software capabilities mask */ + +/* + * Known values for note entry types (e_type == ET_CORE) + */ +#define NT_PRSTATUS 1 /* prstatus_t */ +#define NT_PRFPREG 2 /* prfpregset_t */ +#define NT_PRPSINFO 3 /* prpsinfo_t */ +#define NT_PRXREG 4 /* prxregset_t */ +#define NT_PLATFORM 5 /* string from sysinfo(SI_PLATFORM) */ +#define NT_AUXV 6 /* auxv_t array */ +#define NT_GWINDOWS 7 /* gwindows_t SPARC only */ +#define NT_ASRS 8 /* asrset_t SPARC V9 only */ +#define NT_LDT 9 /* ssd array IA32 only */ +#define NT_PSTATUS 10 /* pstatus_t */ +#define NT_PSINFO 13 /* psinfo_t */ +#define NT_PRCRED 14 /* prcred_t */ +#define NT_UTSNAME 15 /* struct utsname */ +#define NT_LWPSTATUS 16 /* lwpstatus_t */ +#define NT_LWPSINFO 17 /* lwpsinfo_t */ +#define NT_PRPRIV 18 /* prpriv_t */ +#define NT_PRPRIVINFO 19 /* priv_impl_info_t */ +#define NT_CONTENT 20 /* core_content_t */ +#define NT_ZONENAME 21 /* string from getzonenamebyid(3C) */ +#define NT_FDINFO 22 /* open fd info */ +#define NT_SPYMASTER 23 /* psinfo_t for agent LWP spymaster */ +#define NT_SECFLAGS 24 /* process security-flags */ +#define NT_LWPNAME 25 /* prlwpname_t */ +#define NT_UPANIC 26 /* prupanic_t */ +#define NT_CWD 27 /* prcwd_t */ +#define NT_NUM 27 + + +#ifdef _KERNEL +/* + * The following routine checks the processor-specific + * fields of an ELF header. + */ +int elfheadcheck(unsigned char, Elf32_Half, Elf32_Word); +#endif + +#ifdef __cplusplus +} +#endif + +#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_SPARC) +#include +#endif + +#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_386) +#include +#endif + +#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_AMD64) +#include +#endif + +#endif /* _SYS_ELF_H */ diff --git a/illumos-x86_64/usr/include/sys/elf_386.h b/illumos-x86_64/usr/include/sys/elf_386.h new file mode 100644 index 00000000..06e38d3c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/elf_386.h @@ -0,0 +1,141 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ELF_386_H +#define _SYS_ELF_386_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define R_386_NONE 0 /* relocation type */ +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_32PLT 11 +#define R_386_TLS_GD_PLT 12 +#define R_386_TLS_LDM_PLT 13 +#define R_386_TLS_TPOFF 14 +#define R_386_TLS_IE 15 +#define R_386_TLS_GOTIE 16 +#define R_386_TLS_LE 17 +#define R_386_TLS_GD 18 +#define R_386_TLS_LDM 19 +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 +#define R_386_TLS_GD_PUSH 25 +#define R_386_TLS_GD_CALL 26 +#define R_386_TLS_GD_POP 27 +#define R_386_TLS_LDM_32 28 +#define R_386_TLS_LDM_PUSH 29 +#define R_386_TLS_LDM_CALL 30 +#define R_386_TLS_LDM_POP 31 +#define R_386_TLS_LDO_32 32 +#define R_386_TLS_IE_32 33 +#define R_386_TLS_LE_32 34 +#define R_386_TLS_DTPMOD32 35 +#define R_386_TLS_DTPOFF32 36 +#define R_386_TLS_TPOFF32 37 +#define R_386_SIZE32 38 +#define R_386_TLS_GOTDESC 39 +#define R_386_TLS_DESC_CALL 40 +#define R_386_TLS_DESC 41 +#define R_386_IRELATIVE 42 +#define R_386_GOT32X 43 +#define R_386_NUM 44 + +#define ELF_386_MAXPGSZ 0x10000 /* maximum page size */ + +#define SHF_ORDERED 0x40000000 +#define SHF_EXCLUDE 0x80000000 + +#define SHN_BEFORE 0xff00 +#define SHN_AFTER 0xff01 + +/* + * There are consumers of this file that want to include elf defines for + * all architectures. This is a problem for the defines below, because + * while they are architecture specific they have common names. Hence to + * prevent attempts to redefine these variables we'll check if any of + * the other elf architecture header files have been included. If + * they have then we'll just stick with the existing definitions. + */ +#if !defined(_SYS_ELF_MACH_COMMON) +#define _SYS_ELF_MACH_COMMON +#define _SYS_ELF_MACH_386 + +/* + * Plt and Got information; the first few .got and .plt entries are reserved + * PLT[0] jump to dynamic linker + * GOT[0] address of _DYNAMIC + */ +#define M_PLT_INSSIZE 6 /* single plt instruction size */ +#define M_PLT_XNumber 1 /* PLT[0] reserved */ +#define M_GOT_XDYNAMIC 0 /* got index for _DYNAMIC */ +#define M_GOT_XLINKMAP 1 /* got index for link map */ +#define M_GOT_XRTLD 2 /* got index for rtbinder */ +#define M_GOT_XNumber 3 /* reserved no. of got entries */ + +#define M32_WORD_ALIGN 4 +#define M32_PLT_ENTSIZE 16 /* plt entry size in bytes */ +#define M32_PLT_ALIGN M32_WORD_ALIGN /* alignment of .plt section */ +#define M32_GOT_ENTSIZE 4 /* got entry size in bytes */ +#define M32_PLT_RESERVSZ (M_PLT_XNumber * \ + M32_PLT_ENTSIZE) /* first plt reserved */ + + +/* + * Make common alias for the 32/64 bit specific defines based on _ELF64 + */ +#if !defined(_ELF64) +/* architecture common defines */ +#define M_WORD_ALIGN M32_WORD_ALIGN +#define M_PLT_ENTSIZE M32_PLT_ENTSIZE +#define M_PLT_ALIGN M32_PLT_ALIGN +#define M_PLT_RESERVSZ M32_PLT_RESERVSZ +#define M_GOT_ENTSIZE M32_GOT_ENTSIZE +#endif /* !_ELF64 */ + +#endif /* !_SYS_ELF_MACH_COMMON */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ELF_386_H */ diff --git a/illumos-x86_64/usr/include/sys/elf_SPARC.h b/illumos-x86_64/usr/include/sys/elf_SPARC.h new file mode 100644 index 00000000..976242e9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/elf_SPARC.h @@ -0,0 +1,258 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ELF_SPARC_H +#define _SYS_ELF_SPARC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define EF_SPARC_32PLUS_MASK 0xffff00 /* bits indicating V8+ type */ +#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ +#define EF_SPARC_EXT_MASK 0xffff00 /* bits for vendor extensions */ +#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ +#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ +#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARC3 extensions */ + +#define EF_SPARCV9_MM 0x3 /* mask for memory model */ +#define EF_SPARCV9_TSO 0x0 /* total store ordering */ +#define EF_SPARCV9_PSO 0x1 /* partial store ordering */ +#define EF_SPARCV9_RMO 0x2 /* relaxed memory ordering */ + +#define R_SPARC_NONE 0 /* relocation type */ +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +#define R_SPARC_GOTDATA_HIX22 80 +#define R_SPARC_GOTDATA_LOX10 81 +#define R_SPARC_GOTDATA_OP_HIX22 82 +#define R_SPARC_GOTDATA_OP_LOX10 83 +#define R_SPARC_GOTDATA_OP 84 +#define R_SPARC_H34 85 +#define R_SPARC_SIZE32 86 +#define R_SPARC_SIZE64 87 +#define R_SPARC_NUM 88 + +/* + * Relocation aliases + */ +#define R_SPARC_L34 R_SPARC_L44 /* associated with R_SPARC_H34 */ + /* same calc as R_SPARC_L44 */ + +#define ELF_SPARC_MAXPGSZ 0x10000 /* maximum page size */ +#define ELF_SPARCV9_MAXPGSZ 0x100000 + +/* + * Processor specific section types + */ +#define SHT_SPARC_GOTDATA 0x70000000 + +#define SHF_ORDERED 0x40000000 +#define SHF_EXCLUDE 0x80000000 + +#define SHN_BEFORE 0xff00 +#define SHN_AFTER 0xff01 + +#define STT_SPARC_REGISTER 13 /* register symbol type */ + +#define DT_SPARC_REGISTER 0x70000001 /* identifies register */ + /* symbols */ + + +/* + * Register symbol numbers - to be used in the st_value field + * of register symbols. + */ +#define STO_SPARC_REGISTER_G1 0x1 /* register %g1 */ +#define STO_SPARC_REGISTER_G2 0x2 /* register %g2 */ +#define STO_SPARC_REGISTER_G3 0x3 /* register %g3 */ +#define STO_SPARC_REGISTER_G4 0x4 /* register %g4 */ +#define STO_SPARC_REGISTER_G5 0x5 /* register %g5 */ +#define STO_SPARC_REGISTER_G6 0x6 /* register %g6 */ +#define STO_SPARC_REGISTER_G7 0x7 /* register %g7 */ + +/* + * There are consumers of this file that want to include elf defines for + * all architectures. This is a problem for the defines below, because + * while they are architecture specific they have common names. Hence to + * prevent attempts to redefine these variables we'll check if any of + * the other elf architecture header files have been included. If + * they have then we'll just stick with the existing definitions. + */ +#if !defined(_SYS_ELF_MACH_COMMON) +#define _SYS_ELF_MACH_COMMON + +/* + * Plt and Got information; the first few .got and .plt entries are reserved + * PLT[0] jump to dynamic linker + * GOT[0] address of _DYNAMIC + */ +#define M_PLT_INSSIZE 4 /* single plt instruction size */ +#define M_PLT_XNumber 4 /* reserved no. of plt entries */ +#define M_GOT_XDYNAMIC 0 /* got index for _DYNAMIC */ +#define M_GOT_XNumber 1 /* reserved no. of got entries */ + +/* + * ELF32 bit PLT constants + */ +#define M32_WORD_ALIGN 4 +#define M32_PLT_ENTSIZE 12 /* plt entry size in bytes */ +#define M32_PLT_ALIGN M_WORD_ALIGN /* alignment of .plt section */ +#define M32_GOT_ENTSIZE 4 /* got entry size in bytes */ +#define M32_GOT_MAXSMALL 2048 /* maximum no. of small gots */ +#define M32_PLT_RESERVSZ (M_PLT_XNumber * \ + M32_PLT_ENTSIZE) /* first 4 plt's reserved */ + +/* + * ELF64 bit PLT constants + */ +#define M64_WORD_ALIGN 8 +#define M64_PLT_ENTSIZE 32 /* plt entry size in bytes */ +#define M64_PLT_ALIGN 256 /* alignment of .plt section */ +#define M64_GOT_ENTSIZE 8 /* got entry size in bytes */ +#define M64_GOT_MAXSMALL 1024 /* maximum no. of small gots */ +#define M64_PLT_RESERVSZ (M_PLT_XNumber * \ + M64_PLT_ENTSIZE) /* first 4 plt's reserved */ + +#define M64_PLT_NEARPLTS 0x8000 /* # of NEAR PLTS we can have */ +#define M64_PLT_FENTSIZE 24 /* size of far plt is 6 instructions */ + /* x 4bytes */ +#define M64_PLT_PSIZE 8 /* size of PLTP pointer */ +#define M64_PLT_FBLKCNTS 160 /* # of plts in far PLT blocks */ +#define M64_PLT_FBLOCKSZ (M64_PLT_FBLKCNTS *\ + M64_PLT_ENTSIZE) /* size of far PLT block */ + + +/* + * Make common alias for the 32/64 bit specific defines based on _ELF64 + */ +#ifdef _ELF64 +/* architecture common defines */ +#define M_WORD_ALIGN M64_WORD_ALIGN +#define M_PLT_ENTSIZE M64_PLT_ENTSIZE +#define M_PLT_ALIGN M64_PLT_ALIGN +#define M_PLT_RESERVSZ M64_PLT_RESERVSZ +#define M_GOT_ENTSIZE M64_GOT_ENTSIZE +/* sparc specific defines */ +#define M_GOT_MAXSMALL M64_GOT_MAXSMALL +#else /* !_ELF64 */ +/* architecture common defines */ +#define M_WORD_ALIGN M32_WORD_ALIGN +#define M_PLT_ENTSIZE M32_PLT_ENTSIZE +#define M_PLT_ALIGN M32_PLT_ALIGN +#define M_PLT_RESERVSZ M32_PLT_RESERVSZ +#define M_GOT_ENTSIZE M32_GOT_ENTSIZE +/* sparc specific defines */ +#define M_GOT_MAXSMALL M32_GOT_MAXSMALL +#endif /* !_ELF64 */ + +#endif /* !_SYS_ELF_MACH_COMMON */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ELF_SPARC_H */ diff --git a/illumos-x86_64/usr/include/sys/elf_amd64.h b/illumos-x86_64/usr/include/sys/elf_amd64.h new file mode 100644 index 00000000..3386dc95 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/elf_amd64.h @@ -0,0 +1,187 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ELF_AMD64_H +#define _SYS_ELF_AMD64_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define R_AMD64_NONE 0 /* relocation types */ +#define R_AMD64_64 1 +#define R_AMD64_PC32 2 +#define R_AMD64_GOT32 3 +#define R_AMD64_PLT32 4 +#define R_AMD64_COPY 5 +#define R_AMD64_GLOB_DAT 6 +#define R_AMD64_JUMP_SLOT 7 +#define R_AMD64_RELATIVE 8 +#define R_AMD64_GOTPCREL 9 +#define R_AMD64_32 10 +#define R_AMD64_32S 11 +#define R_AMD64_16 12 +#define R_AMD64_PC16 13 +#define R_AMD64_8 14 +#define R_AMD64_PC8 15 +#define R_AMD64_DTPMOD64 16 +#define R_AMD64_DTPOFF64 17 +#define R_AMD64_TPOFF64 18 +#define R_AMD64_TLSGD 19 +#define R_AMD64_TLSLD 20 +#define R_AMD64_DTPOFF32 21 +#define R_AMD64_GOTTPOFF 22 +#define R_AMD64_TPOFF32 23 +#define R_AMD64_PC64 24 +#define R_AMD64_GOTOFF64 25 +#define R_AMD64_GOTPC32 26 +#define R_AMD64_GOT64 27 /* reserved for future expansion */ +#define R_AMD64_GOTPCREL64 28 /* reserved for future expansion */ +#define R_AMD64_GOTPC64 29 /* reserved for future expansion */ +#define R_AMD64_GOTPLT64 30 /* reserved for future expansion */ +#define R_AMD64_PLTOFF64 31 /* reserved for future expansion */ +#define R_AMD64_SIZE32 32 +#define R_AMD64_SIZE64 33 +#define R_AMD64_GOTPC32_TLSDESC 34 +#define R_AMD64_TLSDESC_CALL 35 +#define R_AMD64_TLSDESC 36 +#define R_AMD64_IRELATIVE 37 +#define R_AMD64_RELATIVE64 38 +#define R_AMD64_UNKNOWN39 39 /* deprecated */ +#define R_AMD64_UNKNOWN40 40 /* deprecated */ +#define R_AMD64_GOTPCRELX 41 +#define R_AMD64_REX_GOTPCRELX 42 +#define R_AMD64_NUM 43 + +/* + * The "System V Application Binary Interface, AMD64 Architecture Processor + * Supplement", defines relocations in terms of R_X86_64_ rather than R_AMD64_. + * Maintain both relocation naming conventions for compatibility. + */ +#define R_X86_64_NONE R_AMD64_NONE +#define R_X86_64_64 R_AMD64_64 +#define R_X86_64_PC32 R_AMD64_PC32 +#define R_X86_64_GOT32 R_AMD64_GOT32 +#define R_X86_64_PLT32 R_AMD64_PLT32 +#define R_X86_64_COPY R_AMD64_COPY +#define R_X86_64_GLOB_DAT R_AMD64_GLOB_DAT +#define R_X86_64_JUMP_SLOT R_AMD64_JUMP_SLOT +#define R_X86_64_RELATIVE R_AMD64_RELATIVE +#define R_X86_64_GOTPCREL R_AMD64_GOTPCREL +#define R_X86_64_32 R_AMD64_32 +#define R_X86_64_32S R_AMD64_32S +#define R_X86_64_16 R_AMD64_16 +#define R_X86_64_PC16 R_AMD64_PC16 +#define R_X86_64_8 R_AMD64_8 +#define R_X86_64_PC8 R_AMD64_PC8 +#define R_X86_64_DTPMOD64 R_AMD64_DTPMOD64 +#define R_X86_64_DTPOFF64 R_AMD64_DTPOFF64 +#define R_X86_64_TPOFF64 R_AMD64_TPOFF64 +#define R_X86_64_TLSGD R_AMD64_TLSGD +#define R_X86_64_TLSLD R_AMD64_TLSLD +#define R_X86_64_DTPOFF32 R_AMD64_DTPOFF32 +#define R_X86_64_GOTTPOFF R_AMD64_GOTTPOFF +#define R_X86_64_TPOFF32 R_AMD64_TPOFF32 +#define R_X86_64_PC64 R_AMD64_PC64 +#define R_X86_64_GOTPC32 R_AMD64_GOTPC32 +#define R_X86_64_GOTOFF64 R_AMD64_GOTOFF64 +#define R_X86_64_GOT64 R_AMD64_GOT64 +#define R_X86_64_GOTPCREL64 R_AMD64_GOTPCREL64 +#define R_X86_64_GOTPC64 R_AMD64_GOTPC64 +#define R_X86_64_GOTPLT64 R_AMD64_GOTPLT64 +#define R_X86_64_PLTOFF64 R_AMD64_PLTOFF64 +#define R_X86_64_SIZE32 R_AMD64_SIZE32 +#define R_X86_64_SIZE64 R_AMD64_SIZE64 +#define R_X86_64_GOTPC32_TLSDESC R_AMD64_GOTPC32_TLSDESC +#define R_X86_64_TLSDESC_CALL R_AMD64_TLSDESC_CALL +#define R_X86_64_TLSDESC R_AMD64_TLSDESC +#define R_X86_64_IRELATIVE R_AMD64_IRELATIVE +#define R_X86_64_RELATIVE64 R_AMD64_RELATIVE64 +#define R_X86_64_GOTPCRELX R_AMD64_GOTPCRELX +#define R_X86_64_REX_GOTPCRELX R_AMD64_REX_GOTPCRELX +#define R_X86_64_NUM R_AMD64_NUM + +#define ELF_AMD64_MAXPGSZ 0x100000 /* maximum page size */ + +/* + * processor specific section types + */ +#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ +#define SHT_X86_64_UNWIND SHT_AMD64_UNWIND + +/* + * NOTE: PT_SUNW_UNWIND is defined in the OS specific range + * to conform with the amd64 psABI. + */ + +#define SHF_AMD64_LARGE 0x10000000 +#define SHF_X86_64_LARGE SHF_AMD64_LARGE + +#define SHN_AMD64_LCOMMON 0xff02 +#define SHN_X86_64_LCOMMON SHN_AMD64_LCOMMON + +/* + * There are consumers of this file that want to include elf defines for + * all architectures. This is a problem for the defines below, because + * while they are architecture specific they have common names. Hence to + * prevent attempts to redefine these variables we'll check if any of + * the other elf architecture header files have been included. If + * they have then we'll just stick with the existing definitions. + */ +#if defined(_SYS_ELF_MACH_386) + +/* + * Plt and Got information; the first few .got and .plt entries are reserved + * PLT[0] jump to dynamic linker + * GOT[0] address of _DYNAMIC + */ +#define M64_WORD_ALIGN 8 +#define M64_PLT_ENTSIZE M32_PLT_ENTSIZE +#define M64_PLT_ALIGN M64_WORD_ALIGN /* alignment of .plt section */ +#define M64_GOT_ENTSIZE 8 /* got entry size in bytes */ +#define M64_PLT_RESERVSZ M32_PLT_RESERVSZ + +/* + * Make common alias for the 32/64 bit specific defines based on _ELF64 + */ +#if defined(_ELF64) +/* architecture common defines */ +#define M_WORD_ALIGN M64_WORD_ALIGN +#define M_PLT_ENTSIZE M64_PLT_ENTSIZE +#define M_PLT_ALIGN M64_PLT_ALIGN +#define M_PLT_RESERVSZ M64_PLT_RESERVSZ +#define M_GOT_ENTSIZE M64_GOT_ENTSIZE +#endif /* _ELF64 */ + +#endif /* _SYS_ELF_MACH_386 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ELF_AMD64_H */ diff --git a/illumos-x86_64/usr/include/sys/elf_notes.h b/illumos-x86_64/usr/include/sys/elf_notes.h new file mode 100644 index 00000000..22e90557 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/elf_notes.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993 by Sun Microsystems, Inc. + */ + +#ifndef _SYS_ELF_NOTES_H +#define _SYS_ELF_NOTES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Sun defined names for elf note sections. + */ +#define ELF_NOTE_SOLARIS "SUNW Solaris" + +/* + * Describes the desired pagesize of elf PT_LOAD segments. + * Descriptor is 1 word in length, and contains the desired pagesize. + */ +#define ELF_NOTE_PAGESIZE_HINT 1 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ELF_NOTES_H */ diff --git a/illumos-x86_64/usr/include/sys/elftypes.h b/illumos-x86_64/usr/include/sys/elftypes.h new file mode 100644 index 00000000..bb346a11 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/elftypes.h @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ELFTYPES_H +#define _SYS_ELFTYPES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_LP64) +typedef unsigned int Elf32_Addr; +typedef unsigned short Elf32_Half; +typedef unsigned int Elf32_Off; +typedef int Elf32_Sword; +typedef unsigned int Elf32_Word; +#else +typedef unsigned long Elf32_Addr; +typedef unsigned short Elf32_Half; +typedef unsigned long Elf32_Off; +typedef long Elf32_Sword; +typedef unsigned long Elf32_Word; +#endif + +#if defined(_LP64) +typedef unsigned long Elf64_Addr; +typedef unsigned short Elf64_Half; +typedef unsigned long Elf64_Off; +typedef int Elf64_Sword; +typedef long Elf64_Sxword; +typedef unsigned int Elf64_Word; +typedef unsigned long Elf64_Xword; +typedef unsigned long Elf64_Lword; +typedef unsigned long Elf32_Lword; +#elif defined(_LONGLONG_TYPE) +typedef unsigned long long Elf64_Addr; +typedef unsigned short Elf64_Half; +typedef unsigned long long Elf64_Off; +typedef int Elf64_Sword; +typedef long long Elf64_Sxword; +typedef unsigned int Elf64_Word; +typedef unsigned long long Elf64_Xword; +typedef unsigned long long Elf64_Lword; +typedef unsigned long long Elf32_Lword; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ELFTYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/epm.h b/illumos-x86_64/usr/include/sys/epm.h new file mode 100644 index 00000000..cc340957 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/epm.h @@ -0,0 +1,1017 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_EPM_H +#define _SYS_EPM_H + +#include +#include +#include +#include +#include +#include + +/* + * XXXX + * Do we really need this include? It may be leftover from early CPUPM code. + * #include + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * epm.h: Function prototypes and data structs for kernel pm functions. + */ + +void e_pm_props(dev_info_t *); +int e_new_pm_props(dev_info_t *); + +#define PM_LEVEL_UPONLY (-2) /* only raise power level */ +#define PM_LEVEL_DOWNONLY (-3) /* only lower power level */ +#define PM_LEVEL_EXACT (-4) /* wants exact power level */ + +/* + * Values used by e_pm_props and friends, found in devi_pm_flags + */ +#define PMC_NEEDS_SR 0x00001 /* do suspend/resume despite no "reg" */ +#define PMC_NO_SR 0x00002 /* don't suspend/resume despite "reg" */ +#define PMC_PARENTAL_SR 0x00004 /* call up tree to suspend/resume */ +#define PMC_WANTS_NOTIFY 0x00008 /* notify if child pwr level changes */ +#define PMC_BC 0x00010 /* no pm-components, backwards compat */ +#define PMC_COMPONENTS_DONE 0x00020 /* parsed pm-components */ +#define PMC_COMPONENTS_FAILED 0x00040 /* failed parsing pm-components */ +#define PMC_SUSPENDED 0x00080 /* device has been suspended */ +#define PMC_DEF_THRESH 0x00100 /* thresholds are default */ +#define PMC_DEV_THRESH 0x00200 /* SET_THRESHOLD ioctl seen */ +#define PMC_COMP_THRESH 0x00400 /* relative threshold set */ +#define PMC_NEXDEF_THRESH 0x00800 /* relative threshold set for nexus */ +#define PMC_NOPMKID 0x01000 /* non-pm'd child of pm'd parent */ +#define PMC_NO_INVOL 0x02000 /* no pm without driver's consent */ +#define PMC_VOLPMD 0x04000 /* went down voluntarily */ +#define PMC_SKIP_BRINGUP 0x08000 /* Skipped a dependency bringup */ + +/* + * A node which is the console frame buffer, and should not be powered down + * automatically because the OBP driver doesn't know how to power it back up + * before using it (can remove this when prom calls back into kernel to do + * io to console). + */ +#define PMC_CONSOLE_FB 0x10000 /* console framebuffer */ +#define PMC_NOINVOL_DONE 0x20000 /* processed by pm_noinvol_specd() */ +#define PMC_DRIVER_REMOVED 0x40000 /* driver is removed */ +#define PMC_CPU_DEVICE 0x80000 /* device is a power manageable CPU */ +#define PMC_CPU_THRESH 0x100000 /* cpu threshold set */ + +#define PMC_THRESH_ALL (PMC_DEF_THRESH | PMC_DEV_THRESH | \ + PMC_COMP_THRESH | PMC_NEXDEF_THRESH | PMC_CPU_THRESH) +#define PMC_THRESH_NONE ~(PMC_THRESH_ALL) + +/* Flags for the component */ +#define PM_POWER_OP 0x00001 /* set power in process */ +#define PM_PHC_WHILE_SET_POWER 0x00002 /* phc and set power deadlock */ + +/* + * One of these is attached to each devinfo that is autopm'd. + */ +typedef struct pm_scan { + int ps_idle_down; /* PMID_XXX flags */ + int ps_scan_flags; /* scan flags, defined below */ + timeout_id_t ps_scan_id; /* per dip scan timeout id */ +} pm_scan_t; + +/* + * ps_scan_flags may take the following values, plus possibly + * more defined. + */ +#define PM_SCANNING 0x100 /* scanning: pm_scan_dev is active */ +#define PM_SCAN_AGAIN 0x200 +#define PM_SCAN_STOP 0x400 +#define PM_SCAN_DISPATCHED 0x800 + +#define PM_DEFAULT_MIN_SCAN ((clock_t)15) /* Minimum scan interval in sec */ +#define PM_CPU_MIN_SCAN ((clock_t)1) /* Minimum interval for CPUs */ + +/* + * Power management component definitions, used for tracking idleness of + * devices. An array of these hangs off the devi_pm_components member of the + * dev_info struct (if initialized by driver and/or auto-pm) + * The array of these structs is followed in the same kmem_zalloc'd chunk by + * the names pointed to by the structs. + */ + +/* + * This (sub-)struct contains all the info extracted from the pm-components + * property for each component (name of component, names and values of power + * levels supported). It is in a separate structure to allow it to be handled + * as a struct assignment. + */ +typedef struct pm_comp { + char *pmc_name; /* name of component */ + int pmc_numlevels; /* number of power levels supported */ + int *pmc_lvals; /* numerical values of levels */ + int *pmc_thresh; /* thresholds in secs, last INT_MAX */ + char **pmc_lnames; /* human readable names of levels */ + /* + * This part is just bookkeeping for the storage space involved above + * used for copying and freeing the struct members. This because C + * is really an assembler at heart. + */ + size_t pmc_name_sz; /* size of name string */ + char *pmc_lname_buf; /* buffer holding *pmc_lnames */ + size_t pmc_lnames_sz; /* total size of pmc_lname_buf */ +} pm_comp_t; + +/* + * Here we have the rest of what we need to know about a component. + */ +typedef struct pm_component { + uint_t pmc_flags; /* flags this component */ + uint_t pmc_busycount; /* for nesting busy calls */ + time_t pmc_timestamp; /* timestamp */ + uint_t pmc_norm_pwr; /* normal power index (or value) */ + int pmc_cur_pwr; /* current power index (or value) */ + int pmc_phc_pwr; /* prev. value of curpwr (deadlock) */ + pm_comp_t pmc_comp; /* component description */ +} pm_component_t; + +/* + * All members of this struct are protected by PM_LOCK_DIP(dip). + * + * kidsupcnt counts (the number of components of new-style children at non-zero + * level (unknown counts as non-zero)) + (the number of old-style children with + * component 0 at non-zero level) for parents that have not asked for + * notification. When kidsupcnt is 0 for a nexus node, then pm scans it, + * otherwise it leaves it alone. + * Parents that ask for notification always get get scanned, + * so we keep their kidsupcnt at zero. + */ +typedef struct pm_info { + uint_t pmi_dev_pm_state; /* PM state of a device */ + int pmi_clone; /* owner for direct pm'd devs */ + int pmi_levels[2]; /* storage space for 2 levels */ + int *pmi_lp; /* storage space for >2 levels */ + kcondvar_t pmi_cv; /* condvar for direct PM access */ +} pm_info_t; + +/* + * Work request structure for the dependency processing thread. + */ +typedef struct pm_dep_wk { + int pdw_type; /* Type of request */ + int pdw_wait; /* caller waits for result */ + int pdw_done; /* set when req is done */ + int pdw_ret; /* return value to caller */ + int pdw_pwr; /* pwr level of keeper */ + kcondvar_t pdw_cv; /* cv to wake up caller */ + struct pm_dep_wk *pdw_next; /* next element */ + char *pdw_keeper; + char *pdw_kept; +} pm_dep_wk_t; + +/* + * Types of work, depends on when it gets called: + */ +#define PM_DEP_WK_POWER_ON 1 /* power on */ +#define PM_DEP_WK_POWER_OFF 2 /* power off */ +#define PM_DEP_WK_DETACH 3 /* detach */ +#define PM_DEP_WK_REMOVE_DEP 4 /* dependency removed */ +#define PM_DEP_WK_BRINGUP_SELF 5 /* released from direct PM */ +#define PM_DEP_WK_RECORD_KEEPER 6 /* PM_ADD_DEPENDENT */ +#define PM_DEP_WK_RECORD_KEEPER_PROP 7 /* PM_ADD_DEPENDENT_PROP */ +#define PM_DEP_WK_KEPT 8 /* dep. work as a kept */ +#define PM_DEP_WK_KEEPER 9 /* dep. work as a keeper */ +#define PM_DEP_WK_ATTACH 10 /* when dip is attached */ +#define PM_DEP_WK_CHECK_KEPT 11 /* check if this is a kept */ +#define PM_DEP_WK_CPR_SUSPEND 12 /* Suspend dep. during CPR */ +#define PM_DEP_WK_CPR_RESUME 13 /* Resume dep. after CPR */ + +/* + * Wait for dependency work to finish or not. + */ +#define PM_DEP_WAIT 1 +#define PM_DEP_NOWAIT 0 + +typedef enum pm_canblock +{ + PM_CANBLOCK_BLOCK, /* wait for controlling process action */ + PM_CANBLOCK_FAIL, /* don't wait, fail request */ + PM_CANBLOCK_BYPASS /* don't wait, ignore controlling process */ +} pm_canblock_t; + +typedef enum pm_cpupm +{ + PM_CPUPM_NOTSET, /* no specific treatment of CPU devices */ + PM_CPUPM_POLLING, /* CPUPM enabled: polling mode */ + PM_CPUPM_EVENT, /* CPUPM enabled: event driven mode */ + PM_CPUPM_DISABLE /* do not power manage CPU devices */ +} pm_cpupm_t; + +#define PPM(dip) ((dev_info_t *)DEVI(dip)->devi_pm_ppm) + +/* + * The power request struct uses for the DDI_CTLOPS_POWER busctl. + * + * Note: When changing this enum it is necessary to maintain binary + * compatibility with older versions. To insure that, add new values only + * at the end and refrain from deleting any existing values. + */ +typedef enum { + PMR_SET_POWER = 1, /* called ddi_power (obsolete) */ + PMR_SUSPEND, /* parental suspend */ + PMR_RESUME, /* parental resume */ + PMR_PRE_SET_POWER, /* parent's "pre" notification */ + PMR_POST_SET_POWER, /* parent's "post" notification */ + PMR_PPM_SET_POWER, /* platform pm set power */ + PMR_PPM_ATTACH, /* ppm attach notify - unused */ + PMR_PPM_DETACH, /* ppm detach notify - unused */ + PMR_PPM_POWER_CHANGE_NOTIFY, /* ppm level change notify */ + PMR_REPORT_PMCAP, /* report pm capability */ + PMR_CHANGED_POWER, /* parent's power_has_changed notif. */ + PMR_PPM_PRE_PROBE, /* ppm pre probe notify */ + PMR_PPM_POST_PROBE, /* ppm post probe notify */ + PMR_PPM_PRE_ATTACH, /* ppm pre attach notify */ + PMR_PPM_POST_ATTACH, /* ppm post pm attach notify */ + PMR_PPM_PRE_DETACH, /* ppm pre pm detach notify */ + PMR_PPM_POST_DETACH, /* ppm post pm detach notify */ + PMR_PPM_UNMANAGE, /* device being unmanaged */ + PMR_PPM_PRE_RESUME, /* ppm resume notify */ + PMR_PPM_ALL_LOWEST, /* ppm all lowest power notify */ + PMR_PPM_LOCK_POWER, /* ppm lock power */ + PMR_PPM_UNLOCK_POWER, /* ppm unlock power */ + PMR_PPM_TRY_LOCK_POWER, /* ppm try lock power */ + PMR_PPM_INIT_CHILD, /* ppm init child notify */ + PMR_PPM_UNINIT_CHILD, /* ppm uninit child notify */ + PMR_PPM_POWER_LOCK_OWNER, /* ppm power lock owner's address */ + PMR_PPM_ENTER_SX, /* ppm: enter ACPI S[2-4] state */ + PMR_PPM_EXIT_SX, /* ppm: enter ACPI S[2-4] state */ + PMR_PPM_SEARCH_LIST /* ppm: search tuple list */ +} pm_request_type; + +/* + * When changing the elements of the union below it is necessary to + * maintain binary compatibility with older versions. Refrain from + * deleting existing elements of the union or modifying their contents. + * Avoid increasing the total size of this structure if new elements + * must be added. + */ +typedef struct power_req { + pm_request_type request_type; + union req { + /* + * PMR_SET_POWER (obsolete) + */ + struct set_power_req { + dev_info_t *who; + int cmpt; + int level; + } set_power_req; + /* + * PMR_SUSPEND + */ + struct suspend_req { + dev_info_t *who; + ddi_detach_cmd_t cmd; + } suspend_req; + /* + * PMR_PPM_PRE_RESUME or PMR_RESUME + */ + struct resume_req { + dev_info_t *who; + ddi_attach_cmd_t cmd; + } resume_req; + /* + * PMR_PRE_SET_POWER + */ + struct pre_set_power_req { + dev_info_t *who; + int cmpt; + int old_level; + int new_level; + } pre_set_power_req; + /* + * PMR_POST_SET_POWER + */ + struct post_set_power_req { + dev_info_t *who; + int cmpt; + int old_level; + int new_level; + int result; /* driver's return */ + } post_set_power_req; + /* + * PMR_PPM_SET_POWER + */ + struct ppm_set_power_req { + dev_info_t *who; + int cmpt; + int old_level; + int new_level; + pm_canblock_t canblock; + void *cookie; + } ppm_set_power_req; + /* + * PMR_PPM_POWER_CHANGE_NOTIFY + */ + struct ppm_notify_level_req { + dev_info_t *who; + int cmpt; + int old_level; + int new_level; + } ppm_notify_level_req; + /* + * PMR_REPORT_PMCAP + */ + struct report_pmcap_req { + dev_info_t *who; + int cap; + void *arg; + } report_pmcap_req; + /* + * PMR_CHANGED_POWER + */ + struct changed_power_req { + dev_info_t *who; + int cmpt; + int old_level; + int new_level; + int result; + } changed_power_req; + /* + * PMR_PPM_PRE_PROBE, PMR_PPM_POST_PROBE, PMR_PPM_PRE_ATTACH, + * PMR_PPM_POST_ATTACH, PMR_PPM_PRE_DETACH, PMR_PPM_POST_DETACH + * PMR_PPM_INIT_CHILD, PMR_PPM_UNINIT_CHILD, or PMR_PPM_UNMANAGE + */ + struct ppm_config_req { + dev_info_t *who; + int result; /* post only */ + } ppm_config_req; + /* + * PMR_PPM_ALL_LOWEST + */ + struct ppm_all_lowest_req { + int mode; + } ppm_all_lowest_req; + /* + * PMR_PPM_LOCK_POWER, PMR_PPM_TRY_LOCK_POWER + */ + struct ppm_lock_power_req { + dev_info_t *who; + } ppm_lock_power_req; + /* + * PMR_PPM_UNLOCK_POWER + */ + struct ppm_unlock_power_req { + dev_info_t *who; + } ppm_unlock_power_req; + /* + * PMR_PPM_POWER_LOCK_OWNER + */ + struct ppm_power_lock_owner_req { + dev_info_t *who; + kthread_t *owner; + } ppm_power_lock_owner_req; + /* + * PMR_PPM_POWER_ENTER_SX + */ + struct ppm_power_enter_sx_req { + int sx_state; /* S3, S4 */ + int test_point; /* test point */ + uint64_t wakephys; /* restart vector phys addr */ + void *psr; /* PSM (apic) state buffer */ + } ppm_power_enter_sx_req; + /* + * PMR_PPM_SEARCH_LIST + */ + struct ppm_search_list { + pm_searchargs_t *searchlist; + int result; + } ppm_search_list_req; + } req; +} power_req_t; + +#define S3 3 +#define S4 4 + +extern int cpr_test_point; +extern major_t cpr_device; + +#define LOOP_BACK_NONE 0 +#define LOOP_BACK_PASS 1 +#define LOOP_BACK_FAIL 2 +#define FORCE_SUSPEND_TO_RAM 3 +#define DEVICE_SUSPEND_TO_RAM 4 + +/* + * Struct passed as arg to appm_ioctl + */ +typedef struct s3_args { + int s3a_state; /* S3, S4 */ + int s3a_test_point; /* test point */ + uint64_t s3a_wakephys; /* restart vector physical addr */ + void *s3a_psr; /* apic state save buffer */ +} s3a_t; + +/* + * Structure used by the following bus_power operations: + * + * BUS_POWER_PRE_NOTIFICATION + * BUS_POWER_POST_NOTIFICATION + * BUS_POWER_CHILD_PWRCHG + */ +typedef struct pm_bp_child_pwrchg { + dev_info_t *bpc_dip; /* dip of the target device */ + char *bpc_path; /* path to the target device */ + int bpc_comp; /* component changing power */ + int bpc_olevel; /* old power level */ + int bpc_nlevel; /* new power level */ + void *bpc_private; /* PM framework private */ +} pm_bp_child_pwrchg_t; + +/* + * Structure used by the BUS_POWER_NEXUS_PWRUP operation + */ +typedef struct pm_bp_nexus_pwrup { + dev_info_t *bpn_dip; /* dip of the nexus device */ + int bpn_comp; /* component powering up */ + int bpn_level; /* new power level */ + void *bpn_private; /* PM framework private */ +} pm_bp_nexus_pwrup_t; + +/* + * Structure used by the BUS_POWER_HAS_CHANGED operation + */ +typedef struct pm_bp_has_changed { + dev_info_t *bphc_dip; /* dip of the target device */ + char *bphc_path; /* path to the target device */ + int bphc_comp; /* component changing power */ + int bphc_olevel; /* old power level */ + int bphc_nlevel; /* new power level */ + void *bphc_private; /* PM framework private */ +} pm_bp_has_changed_t; + +/* + * Commands indicating which activity is requiring an + * update to the noinvol counters. + */ +#define PM_BP_NOINVOL_ATTACH 1 +#define PM_BP_NOINVOL_DETACH 2 +#define PM_BP_NOINVOL_REMDRV 3 +#define PM_BP_NOINVOL_CFB 4 +#define PM_BP_NOINVOL_POWER 5 + +/* + * Structure used by the BUS_POWER_NOINVOL operation. + */ +typedef struct pm_bp_noinvol { + dev_info_t *bpni_dip; /* dip of the target device */ + char *bpni_path; /* path to the target device */ + int bpni_cmd; /* how to update the counters */ + int bpni_volpmd; /* volpmd of target device */ + int bpni_wasvolpmd; /* whether to update volpmd */ + void *bpni_private; /* PM framework private */ +} pm_bp_noinvol_t; + +/* + * This struct is used by the code that makes a PMR_PPM_SET_POWER request + * to ppm. Devices that changed power other than the primary device (which + * was requested) are passed back to the pm framework through this + * structure. + */ +typedef struct pm_ppm_devlist { + dev_info_t *ppd_who; + int ppd_cmpt; + int ppd_old_level; + int ppd_new_level; + struct pm_ppm_devlist *ppd_next; +} pm_ppm_devlist_t; + +/* + * This struct is used by the code that brings up parents and notifies + * ppm drivers across probe/attach/detach (pm_pre/post_probe/attach/detach()) + */ +typedef struct pm_ppm_cookie { + dev_info_t *ppc_dip; /* dip of target node */ + dev_info_t *ppc_pdip; /* parent's dip */ + dev_info_t *ppc_ppm; /* interested ppm driver */ + int ppc_cmd; /* attach/detach cmd */ +} pm_ppm_cookie_t; + +/* + * This struct records one dependency (a device keeps another or others up) + * pdr_size includes size of strings. + */ +typedef struct pm_dep_rec { + char *pdr_keeper; /* physpath of device keeping up */ + char *pdr_kept; /* physpath or property name */ + char **pdr_kept_paths; /* array of kept devices' paths */ + struct pm_dep_rec *pdr_next; /* next dependency device */ + size_t pdr_size; /* size to kmem_free */ + major_t pdr_major; /* major of kept driver (not props) */ + int pdr_isprop; /* true if kept is property name */ + int pdr_kept_count; /* how many kept altogether */ + int pdr_satisfied; /* true if in force (not properties) */ +} pm_pdr_t; + + +/* + * This struct records threshold information about a single component + */ +typedef struct pm_thresh_entry { + int pte_numthresh; + int *pte_thresh; +} pm_pte_t; + +/* + * Note that this header and its array of entry structs with their arrays + * of thresholds and string storage for physpath are all kmem_alloced in one + * chunk for easy freeing ptr_size is the size of that chunk + */ +typedef struct pm_thresh_rec { + char *ptr_physpath; /* identifies node */ + struct pm_thresh_rec *ptr_next; + int ptr_numcomps; /* number of components */ + size_t ptr_size; /* total size for kmem_free */ + pm_pte_t *ptr_entries; +} pm_thresh_rec_t; + +/* + * pmi_dev_pm_state state bits: + */ + +/* + * a direct-pm device, not scanned, but controlled by a process + */ +#define PM_DIRECT 0x1 +/* + * autopm is suspended while waiting to see if detach succeeds + */ +#define PM_DETACHING 0x2 + +/* + * An all_to_normal operation for an autopm device that is detaching, is + * deferred in case the detach fails. + */ +#define PM_ALLNORM_DEFERRED 0x4 + +#define PM_GET_PM_INFO(dip) (DEVI(dip)->devi_pm_info) +#define PM_GET_PM_SCAN(dip) (DEVI(dip)->devi_pm_scan) + +#define PM_NUMCMPTS(dip) (DEVI(dip)->devi_pm_num_components) +#define PM_CP(dip, comp) (&DEVI(dip)->devi_pm_components[comp]) + +/* + * Returns true if the device specified by dip is directly power managed + */ +#define PM_ISDIRECT(dip) \ + (((pm_info_t *)PM_GET_PM_INFO(dip))->pmi_dev_pm_state & PM_DIRECT) + +/* + * Returns true if the device specified by dip is an old node for which we + * provide backwards compatible behavior (e.g. no pm-components property). + */ +#define PM_ISBC(dip) (DEVI(dip)->devi_pm_flags & PMC_BC) + +/* + * Returns true if we have skipped a dependency bringup on this dip. + */ +#define PM_SKBU(dip) (DEVI(dip)->devi_pm_flags & PMC_SKIP_BRINGUP) + +/* + * Returns true if device specified by dip is a power manageable CPU. + */ +#define PM_ISCPU(dip) (DEVI(dip)->devi_pm_flags & PMC_CPU_DEVICE) + +/* + * Returns true if cpupm is enabled in event driven mode. + */ +#define PM_EVENT_CPUPM (cpupm == PM_CPUPM_EVENT) + +/* + * Returns true if cpupm is enabled in polling mode. + */ +#define PM_POLLING_CPUPM (cpupm == PM_CPUPM_POLLING) + +/* + * Returns true if cpupm operating using the default mode. + */ +#define PM_DEFAULT_CPUPM (cpupm == cpupm_default_mode) + +/* + * Returns true if is disabled. + */ +#define PM_CPUPM_DISABLED (cpupm == PM_CPUPM_DISABLE) + +/* + * If ((autopm is enabled and + * (CPUPM is not disabled and we're not in event mode, or it isn't a cpu)) + * OR + * (CPUPM are enabled and it is one)) + */ +#define PM_SCANABLE(dip) ((autopm_enabled && \ + ((!PM_CPUPM_DISABLED && !PM_EVENT_CPUPM) || !PM_ISCPU(dip))) || \ + (PM_POLLING_CPUPM && PM_ISCPU(dip))) + +#define PM_NOT_ALL_LOWEST 0x0 /* not all components are at lowest */ +#define PM_ALL_LOWEST 0x1 /* all components are at lowest lvl */ + +#define PM_ADDR(dip) (ddi_get_name_addr(dip) ? ddi_get_name_addr(dip) : "") +#define PM_NAME(dip) (ddi_binding_name(dip)) +#define PM_NODE(dip) (ddi_node_name(dip)) +#define PM_INST(dip) (ddi_get_instance(dip)) +#define PM_DEVICE(dip) PM_NAME(dip), PM_ADDR(dip), PM_NODE(dip), PM_INST(dip) + +#ifdef DEBUG +/* + * Flags passed to PMD to enable debug printfs. If the same flag is set in + * pm_debug below then the message is printed. The most generally useful + * ones are the first 3 or 4. + */ +#define PMD_ERROR 0x0000001 +#define PMD_FAIL 0x0000002 +#define PMD_IOCTL 0x0000004 +#define PMD_SCAN 0x0000008 +#define PMD_RESCAN 0x0000010 +#define PMD_REMINFO 0x0000020 +#define PMD_NAMETODIP 0x0000040 +#define PMD_CLOSE 0x0000080 +#define PMD_DIN 0x0000100 /* Dev Is Needed */ +#define PMD_PMC 0x0000200 /* for testing with sun4m pmc driver */ +#define PMD_PPM 0x0000400 +#define PMD_DEP 0x0000800 /* dependency processing */ +#define PMD_IDLEDOWN 0x0001000 +#define PMD_SET 0x0002000 +#define PMD_BRING 0x0004000 +#define PMD_ALLNORM 0x0008000 +#define PMD_REMDEV 0x0010000 +#define PMD_LEVEL 0x0020000 +#define PMD_THRESH 0x0040000 +#define PMD_DPM 0x0080000 /* Direct Power Management */ +#define PMD_NORM 0x0100000 +#define PMD_STATS 0x0200000 +#define PMD_DEREG 0x0400000 +#define PMD_KEEPS 0x0800000 +#define PMD_KIDSUP 0x1000000 +#define PMD_TCHECK 0x2000000 +#define PMD_NOINVOL 0x4000000 +#define PMD_CFB 0x8000000 /* console fb pm */ +#define PMD_DHR 0x10000000 /* driver hold/rele changes */ +#define PMD_PIL 0x20000000 /* print out PIL when calling power */ +#define PMD_PHC 0x40000000 /* pm_power_has_changed messages */ +#define PMD_LOCK 0x80000000 +#define PMD_SX 0x80000000 /* ACPI S[1234] states */ +#define PMD_PROTO PMD_SX /* and other Prototype stuff */ + +extern uint_t pm_debug; +extern uint_t pm_divertdebug; +/*PRINTFLIKE1*/ +extern void pm_log(const char *fmt, ...) __KPRINTFLIKE(1); + +#if !defined(__sparc) +/* + * On non-sparc machines, PMDDEBUG isn't as big a deal as Sparc, so we + * define PMDDEUG here for use on non-sparc platforms. + */ +#define PMDDEBUG +#endif /* !__sparc */ + +#ifdef PMDDEBUG +#define PMD(level, arglist) { \ + if (pm_debug & (level)) { \ + pm_log arglist; \ + } \ +} +#else /* !PMDDEBUG */ +#define PMD(level, arglist) ((void)0); +#endif /* PMDDEBUG */ +#ifndef sparc +extern clock_t pt_sleep; +/* code is char hex number to display on POST LED */ +#define PT(code) {outb(0x80, (char)code); drv_usecwait(pt_sleep); } +#else +#define PT(code) +#endif +#else +#define PMD(level, arglist) +#define PT(code) +#endif +/* + * Code Value Indication + * + */ +#define PT_SPL7 0x01 /* pm_suspend spl7 */ +#define PT_PMSRET 0x02 /* pm_suspend returns */ +#define PT_PPMCTLOP 0x03 /* invoking ppm_ctlops */ +#define PT_ACPISDEV 0x04 /* acpi suspend devices */ +#define PT_IC 0x05 /* acpi intr_clear */ +#define PT_1to1 0x06 /* 1:1 mapping */ +#define PT_SC 0x07 /* save context */ +#define PT_SWV 0x08 /* set waking vector */ +#define PT_SWV_FAIL 0x09 /* set waking vector failed */ +#define PT_EWE 0x0a /* enable wake events */ +#define PT_EWE_FAIL 0x0b /* enable wake events failed */ +#define PT_RTCW 0x0c /* setting rtc wakeup */ +#define PT_RTCW_FAIL 0x0d /* setting rtc wakeup failed */ +#define PT_TOD 0x0e /* setting tod */ +#define PT_SXP 0x0f /* sx prep */ +#define PT_SXE 0x10 /* sx enter */ +#define PT_SXE_FAIL 0x11 /* sx enter failed */ +#define PT_INSOM 0x12 /* insomnia label */ +#define PT_WOKE 0x20 /* woke up */ +#define PT_UNDO1to1 0x21 /* Undo 1:1 mapping */ +#define PT_LSS 0x22 /* leave sleep state */ +#define PT_LSS_FAIL 0x23 /* leave sleep state failed */ +#define PT_CPB 0x24 /* clear power button event */ +#define PT_CPB_FAIL 0x25 /* clear power button event failed */ +#define PT_DRTC_FAIL 0x26 /* disable rtc fails */ +#define PT_ACPIREINIT 0x27 /* reinit apic */ +#define PT_ACPIRESTORE 0x28 /* restore apic */ +#define PT_INTRRESTORE 0x28 /* restore interrupts */ +#define PT_RESDEV 0x2a /* ressume acpi devices */ +#define PT_CPU 0x2b /* init_cpu_syscall */ +#define PT_PRESUME 0x30 /* pm_resume entered */ +#define PT_RSUS 0x31 /* pm_resume "suspended" */ +#define PT_RKERN 0x32 /* pm_resume "kernel" */ +#define PT_RDRV 0x33 /* pm_resume "driver" */ +#define PT_RDRV_FAIL 0x34 /* pm_resume "driver" failed */ +#define PT_RRNOINVOL 0x35 /* pm_resume "reattach_noinvol" */ +#define PT_RUSER 0x36 /* pm_resume "user" */ +#define PT_RAPMSIG 0x37 /* pm_resume APM/SRN signal */ +#define PT_RMPO 0x38 /* pm_resume "mp_online" */ +#define PT_RDONE 0x39 /* pm_resume done */ + +extern void pm_detaching(dev_info_t *); +extern void pm_detach_failed(dev_info_t *); +extern int pm_power(dev_info_t *, int, int); +extern int pm_unmanage(dev_info_t *); +extern void pm_rem_info(dev_info_t *); +extern int pm_get_norm_pwrs(dev_info_t *, int **, size_t *); +extern dev_info_t *pm_name_to_dip(char *, int); +extern int pm_power_up(dev_info_t *, int, int, int, pm_info_t *); +extern int pm_default_idle_threshold; +extern void pm_set_device_threshold(dev_info_t *, int, int); +extern int pm_valid_power(dev_info_t *, int, int); +extern void pm_lock_power(dev_info_t *); +extern void pm_unlock_power(dev_info_t *); +extern int pm_try_locking_power(dev_info_t *); +extern void pm_lock_power_single(dev_info_t *); +extern void pm_unlock_power_single(dev_info_t *); +extern int pm_try_locking_power_single(dev_info_t *); +extern int pm_isbc(dev_info_t *dip); +extern int pm_isdirect(dev_info_t *dip); +extern int pm_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, + void *a, void *v); +extern int pm_noinvol_detached(char *); +extern int pm_init_child(dev_info_t *); +extern int pm_uninit_child(dev_info_t *); + +extern int pm_all_to_normal(dev_info_t *, pm_canblock_t); +extern int pm_set_power(dev_info_t *, int, int, int, pm_canblock_t, int, + int *); +extern void pm_scan_init(dev_info_t *dip); +extern void pm_scan_fini(dev_info_t *dip); +extern void pm_scan_stop(dev_info_t *dip); +extern int pm_scan_stop_walk(dev_info_t *dip, void *); +extern void pm_scan(void *); +extern time_t pm_scan_dev(dev_info_t *dip); +extern void pm_rescan(void *); +extern int pm_rescan_walk(dev_info_t *, void *); +extern void pm_forget_power_level(dev_info_t *); +extern int pm_pre_config(dev_info_t *, char *); +extern int pm_pre_unconfig(dev_info_t *, int, int *, char *); +extern void pm_post_config(dev_info_t *, char *); +extern void pm_post_unconfig(dev_info_t *, int, char *); +extern void pm_pre_probe(dev_info_t *, pm_ppm_cookie_t *); +extern void pm_post_probe(pm_ppm_cookie_t *, int, int); +extern void pm_post_attach(pm_ppm_cookie_t *, int); +extern void pm_pre_attach(dev_info_t *, pm_ppm_cookie_t *, + ddi_attach_cmd_t); +extern void pm_pre_detach(dev_info_t *, ddi_detach_cmd_t, + pm_ppm_cookie_t *); +extern void pm_post_detach(pm_ppm_cookie_t *, int); +extern int pm_powerup(dev_info_t *); +extern int pm_all_at_normal(dev_info_t *); +extern int pm_busop_bus_power(dev_info_t *, void *, + pm_bus_power_op_t, void *, void *); +extern void pm_hold_power(dev_info_t *); +extern void pm_rele_power(dev_info_t *); +extern void pm_driver_removed(major_t); +extern void pm_borrow_lock(kthread_t *); +extern void pm_return_lock(void); +extern int pm_reattach_noinvol(void); +extern void pm_reattach_noinvol_fini(); +extern void pm_restore_direct_levels(void); +extern void pm_save_direct_levels(void); +extern void pm_cfb_setup(const char *); +extern void pm_proceed(dev_info_t *, int, int, int); +extern void pm_get_timestamps(dev_info_t *, time_t *); +extern void pm_deregister_watcher(int, dev_info_t *); +extern void pm_dispatch_to_dep_thread(int, char *, char *, int, int *, int); +extern int e_pm_valid_comp(dev_info_t *, int, pm_component_t **); +extern int e_pm_valid_info(dev_info_t *, pm_info_t **); +extern int e_pm_valid_power(dev_info_t *, int, int); +extern void pm_init_locks(void); +extern int pm_register_ppm(int (*)(dev_info_t *), dev_info_t *); +extern int pm_is_cfb(dev_info_t *); +#ifdef DEBUG +extern int pm_cfb_is_up(void); +#endif + +#ifdef DIPLOCKDEBUG +#define PM_LOCK_DIP(dip) { PMD(PMD_LOCK, ("dip lock %s@%s(%s#%d) " \ + "%s %d\n", PM_DEVICE(dip), \ + __FILE__, __LINE__)) \ + mutex_enter(&DEVI(dip)->devi_pm_lock); } +#define PM_UNLOCK_DIP(dip) { PMD(PMD_LOCK, ("dip unlock %s@%s(%s#%d) " \ + "%s %d\n", PM_DEVICE(dip), \ + __FILE__, __LINE__)) \ + mutex_exit(&DEVI(dip)->devi_pm_lock); } +#else +#define PM_LOCK_DIP(dip) mutex_enter(&DEVI(dip)->devi_pm_lock) +#define PM_UNLOCK_DIP(dip) mutex_exit(&DEVI(dip)->devi_pm_lock) +#endif + +/* + * These are the same DEBUG or not + */ +#define PM_LOCK_BUSY(dip) mutex_enter(&DEVI(dip)->devi_pm_busy_lock) +#define PM_UNLOCK_BUSY(dip) mutex_exit(&DEVI(dip)->devi_pm_busy_lock) +#define PM_LOCK_POWER(dip) pm_lock_power(dip) +#define PM_UNLOCK_POWER(dip) pm_unlock_power(dip) +#define PM_TRY_LOCK_POWER(dip) pm_try_locking_power(dip) +#define PM_IAM_LOCKING_DIP(dip) (mutex_owned(&DEVI(dip)->devi_pm_lock)) + +#define PM_DEFAULT_SYS_IDLENESS 1800 /* 30 minutes */ + +/* + * Codes put into the pr_retval field of pm_rsvp_t that tell pm_block() + * how to proceed + */ +#define PMP_SUCCEED 0x1 /* return success, the process did it */ +#define PMP_FAIL 0x2 /* return fail, process did something else */ +#define PMP_RELEASE 0x3 /* let it go, the process has lost interest */ + /* also arg to pm_proceed to signal this */ +/* + * Values of "style" for e_pm_manage and pm_premanage + */ +#define PM_STYLE_NEW 0 +#define PM_STYLE_UNKNOWN 1 + +/* + * Arg passed to pm_proceed that results in PMP_SUCCEED or PMP_FAIL being set + * in pr_retval depending on what is pending + */ +#define PMP_SETPOWER 0x4 + +#define PM_MAX_CLONE 256 + +typedef struct pm_rsvp { + dev_info_t *pr_dip; + int pr_comp; + int pr_newlevel; + int pr_oldlevel; + kcondvar_t pr_cv; /* a place to sleep */ + int pr_retval; /* what to do when you wake up */ + struct pm_rsvp *pr_next; + struct pm_rsvp *pr_prev; +} pm_rsvp_t; + +typedef struct psce { /* pm_state_change_entries */ + struct pm_state_change *psce_first; + struct pm_state_change *psce_in; + struct pm_state_change *psce_out; + struct pm_state_change *psce_last; + int psce_overruns; + int psce_references; + kmutex_t psce_lock; +} psce_t; + +typedef struct pscc { /* pm_state_change_control */ + int pscc_clone; + dev_info_t *pscc_dip; + psce_t *pscc_entries; + struct pscc *pscc_next; + struct pscc *pscc_prev; +} pscc_t; + +#define PSCCOUNT 128 /* number of state change entries kept per process */ + +/* + * Struct used to track the existence of devices exporting the + * no-involuntary-power-cycles property, and remember things from their + * devinfo node for later attach. + */ +typedef struct pm_noinvol { + struct pm_noinvol *ni_next; + char *ni_path; + major_t ni_major; /* for attaching at cpr time */ + uint_t ni_flags; /* selected PMC_* values */ + uint_t ni_noinvolpm; /* saved noinvolpm count */ + uint_t ni_volpmd; /* saved volpmd count */ + uint_t ni_wasvolpmd; /* was vol pm'd at detach */ + size_t ni_size; + int ni_persistent; /* still around */ +} pm_noinvol_t; + +#define PMID_IOCTIMER 0x1 /* pm_ioctl sets during timer */ +#define PMID_CFBTIMER 0x2 /* cfb sets during timer */ +#define PMID_IOCSCAN 0x4 /* pm_ioctl sets during scan */ +#define PMID_CFBSCAN 0x8 /* cfb sets during scan */ + +#define PMID_IOC (PMID_IOCTIMER | PMID_IOCSCAN) +#define PMID_CFB (PMID_CFBTIMER | PMID_CFBSCAN) +#define PMID_TIMERS (PMID_IOCTIMER | PMID_CFBTIMER) +#define PMID_SCANS (PMID_IOCSCAN | PMID_CFBSCAN) +#define PMID_SCANS_SHIFT 2 +#define PMID_SET_SCANS(pmid) (pmid) |= (((pmid) & PMID_TIMERS) << \ + PMID_SCANS_SHIFT); +#define PMID_IS_IOC(pmid) ((pmid) & PMID_IOC) +#define PMID_IS_CFB(pmid, dip) (((pmid) & PMID_CFB) && \ + (DEVI(dip)->devi_pm_flags & \ + (PMC_DEF_THRESH | PMC_NEXDEF_THRESH))) +#define PM_IS_PID(dip) (PMID_IS_IOC(PM_GET_PM_SCAN(dip)->ps_idle_down) || \ + PMID_IS_CFB(PM_GET_PM_SCAN(dip)->ps_idle_down, dip)) +#define PM_IS_CFB(dip) (DEVI(dip)->devi_pm_flags & PMC_CONSOLE_FB) +#define PM_KUC(dip) (DEVI(dip)->devi_pm_kidsupcnt) +#define PM_CURPOWER(dip, comp) cur_power(PM_CP(dip, comp)) + +#define PM_WANTS_NOTIFICATION(dip) \ + (DEVI(dip)->devi_pm_flags & PMC_WANTS_NOTIFY) + +#define PM_HAS_BUS_POWER(dip) \ + ((DEVI(dip)->devi_ops->devo_bus_ops != NULL) && \ + (DEVI(dip)->devi_ops->devo_bus_ops->busops_rev >= BUSO_REV_7) &&\ + (DEVI(dip)->devi_ops->devo_bus_ops->bus_power != NULL)) + +#define PM_BUS_POWER_FUNC(dip) \ + DEVI(dip)->devi_ops->devo_bus_ops->bus_power + +/* + * Structure used to pass down sunpm's private data variables + * through the bus_power bus_op calls + */ +typedef struct pm_sp_misc { + pm_canblock_t pspm_canblock; + int pspm_scan; + int *pspm_errnop; + int pspm_direction; +} pm_sp_misc_t; + +/* + * This structure is used in validating that the power level + * of the descendents are off, while a device is powered off. + */ +typedef struct pm_desc_pwrchk { + dev_info_t *pdpc_dip; + int pdpc_par_involved; +} pm_desc_pwrchk_t; + + +/* + * These defines are used by pm_trans_check() to calculate time. + * Mostly copied from "tzfile.h". + */ +#define DC_SPY (SECSPERDAY * DAYSPERNYEAR) +#define DC_SPW (SECSPERDAY * DAYSPERWEEK) +#define DC_SPD SECSPERDAY + +#define DC_SCSI_YEAR_LEN 4 /* YYYY */ +#define DC_SCSI_WEEK_LEN 2 /* WW */ +#define DC_SCSI_NPY 5 /* # power-cycle years */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EPM_H */ diff --git a/illumos-x86_64/usr/include/sys/epoll.h b/illumos-x86_64/usr/include/sys/epoll.h new file mode 100644 index 00000000..480bfdf9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/epoll.h @@ -0,0 +1,91 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2014, Joyent, Inc. All rights reserved. + * Copyright 2020 Oxide Computer Company + */ + +#ifndef _SYS_EPOLL_H +#define _SYS_EPOLL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union epoll_data { + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct epoll_event { + uint32_t events; /* events */ + epoll_data_t data; /* user-specified data */ +} epoll_event_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * Define the EPOLL* constants in terms of their poll(2)/poll(4D) equivalents. + * Note that the values match the equivalents in Linux to allow for any binary + * compatibility layers to not need to translate them. + */ +#define EPOLLIN 0x0001 +#define EPOLLPRI 0x0002 +#define EPOLLOUT 0x0004 +#define EPOLLRDNORM 0x0040 +#define EPOLLRDBAND 0x0080 +#define EPOLLWRNORM 0x0100 +#define EPOLLWRBAND 0x0200 +#define EPOLLMSG 0x0400 /* not used */ +#define EPOLLERR 0x0008 +#define EPOLLHUP 0x0010 +#define EPOLLRDHUP 0x2000 + +#define EPOLLEXCLUSIVE (1UL << 28) /* sets exclusive wake-up mode */ +#define EPOLLWAKEUP (1UL << 29) /* no meaning; silently ignored */ +#define EPOLLONESHOT (1UL << 30) /* translated to POLLONESHOT */ +#define EPOLLET (1UL << 31) /* translated to POLLET */ + +#define EPOLL_CTL_ADD 1 +#define EPOLL_CTL_DEL 2 +#define EPOLL_CTL_MOD 3 + +#define EPOLL_CLOEXEC 02000000 + +#if !defined(_KERNEL) + +extern int epoll_create(int size); +extern int epoll_create1(int flags); +extern int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); +extern int epoll_wait(int epfd, struct epoll_event *events, + int maxevents, int timeout); +extern int epoll_pwait(int epfd, struct epoll_event *events, + int maxevents, int timeout, const sigset_t *sigmask); + +#endif /* !_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EPOLL_H */ diff --git a/illumos-x86_64/usr/include/sys/errno.h b/illumos-x86_64/usr/include/sys/errno.h new file mode 100644 index 00000000..9f3c46b3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/errno.h @@ -0,0 +1,204 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2000 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_ERRNO_H +#define _SYS_ERRNO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Error codes + */ + +#define EPERM 1 /* Not super-user */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No children */ +#define EAGAIN 11 /* Resource temporarily unavailable */ +#define ENOMEM 12 /* Not enough core */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Mount device busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Inappropriate ioctl for device */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math arg out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define ENOMSG 35 /* No message of desired type */ +#define EIDRM 36 /* Identifier removed */ +#define ECHRNG 37 /* Channel number out of range */ +#define EL2NSYNC 38 /* Level 2 not synchronized */ +#define EL3HLT 39 /* Level 3 halted */ +#define EL3RST 40 /* Level 3 reset */ +#define ELNRNG 41 /* Link number out of range */ +#define EUNATCH 42 /* Protocol driver not attached */ +#define ENOCSI 43 /* No CSI structure available */ +#define EL2HLT 44 /* Level 2 halted */ +#define EDEADLK 45 /* Deadlock condition. */ +#define ENOLCK 46 /* No record locks available. */ +#define ECANCELED 47 /* Operation canceled */ +#define ENOTSUP 48 /* Operation not supported */ + +/* Filesystem Quotas */ +#define EDQUOT 49 /* Disc quota exceeded */ + +/* Convergent Error Returns */ +#define EBADE 50 /* invalid exchange */ +#define EBADR 51 /* invalid request descriptor */ +#define EXFULL 52 /* exchange full */ +#define ENOANO 53 /* no anode */ +#define EBADRQC 54 /* invalid request code */ +#define EBADSLT 55 /* invalid slot */ +#define EDEADLOCK 56 /* file locking deadlock error */ + +#define EBFONT 57 /* bad font file fmt */ + +/* Interprocess Robust Locks */ +#define EOWNERDEAD 58 /* process died with the lock */ +#define ENOTRECOVERABLE 59 /* lock is not recoverable */ + +/* stream problems */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* no data (for no delay io) */ +#define ETIME 62 /* timer expired */ +#define ENOSR 63 /* out of streams resources */ + +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* The object is remote */ +#define ENOLINK 67 /* the link has been severed */ +#define EADV 68 /* advertise error */ +#define ESRMNT 69 /* srmount error */ + +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ + +/* Interprocess Robust Locks */ +#define ELOCKUNMAPPED 72 /* locked lock was unmapped */ + +#define ENOTACTIVE 73 /* Facility is not active */ +#define EMULTIHOP 74 /* multihop attempted */ +#define EBADMSG 77 /* trying to read unreadable message */ +#define ENAMETOOLONG 78 /* path name is too long */ +#define EOVERFLOW 79 /* value too large to be stored in data type */ +#define ENOTUNIQ 80 /* given log. name not unique */ +#define EBADFD 81 /* f.d. invalid for this operation */ +#define EREMCHG 82 /* Remote address changed */ + +/* shared library problems */ +#define ELIBACC 83 /* Can't access a needed shared lib. */ +#define ELIBBAD 84 /* Accessing a corrupted shared lib. */ +#define ELIBSCN 85 /* .lib section in a.out corrupted. */ +#define ELIBMAX 86 /* Attempting to link in too many libs. */ +#define ELIBEXEC 87 /* Attempting to exec a shared library. */ +#define EILSEQ 88 /* Illegal byte sequence. */ +#define ENOSYS 89 /* Unsupported file system operation */ +#define ELOOP 90 /* Symbolic link loop */ +#define ERESTART 91 /* Restartable system call */ +#define ESTRPIPE 92 /* if pipe/FIFO, don't sleep in stream head */ +#define ENOTEMPTY 93 /* directory not empty */ +#define EUSERS 94 /* Too many users (for UFS) */ + +/* BSD Networking Software */ + /* argument errors */ +#define ENOTSOCK 95 /* Socket operation on non-socket */ +#define EDESTADDRREQ 96 /* Destination address required */ +#define EMSGSIZE 97 /* Message too long */ +#define EPROTOTYPE 98 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 99 /* Protocol not available */ +#define EPROTONOSUPPORT 120 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 121 /* Socket type not supported */ +#define EOPNOTSUPP 122 /* Operation not supported on socket */ +#define EPFNOSUPPORT 123 /* Protocol family not supported */ +#define EAFNOSUPPORT 124 /* Address family not supported by */ + /* protocol family */ +#define EADDRINUSE 125 /* Address already in use */ +#define EADDRNOTAVAIL 126 /* Can't assign requested address */ + /* operational errors */ +#define ENETDOWN 127 /* Network is down */ +#define ENETUNREACH 128 /* Network is unreachable */ +#define ENETRESET 129 /* Network dropped connection because */ + /* of reset */ +#define ECONNABORTED 130 /* Software caused connection abort */ +#define ECONNRESET 131 /* Connection reset by peer */ +#define ENOBUFS 132 /* No buffer space available */ +#define EISCONN 133 /* Socket is already connected */ +#define ENOTCONN 134 /* Socket is not connected */ +/* XENIX has 135 - 142 */ +#define ESHUTDOWN 143 /* Can't send after socket shutdown */ +#define ETOOMANYREFS 144 /* Too many references: can't splice */ +#define ETIMEDOUT 145 /* Connection timed out */ +#define ECONNREFUSED 146 /* Connection refused */ +#define EHOSTDOWN 147 /* Host is down */ +#define EHOSTUNREACH 148 /* No route to host */ +#define EWOULDBLOCK EAGAIN +#define EALREADY 149 /* operation already in progress */ +#define EINPROGRESS 150 /* operation now in progress */ + +/* SUN Network File System */ +#define ESTALE 151 /* Stale NFS file handle */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ERRNO_H */ diff --git a/illumos-x86_64/usr/include/sys/errorq.h b/illumos-x86_64/usr/include/sys/errorq.h new file mode 100644 index 00000000..5ae6f9e9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/errorq.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ERRORQ_H +#define _ERRORQ_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct errorq errorq_t; +typedef struct errorq_elem errorq_elem_t; +typedef void (*errorq_func_t)(void *, const void *, const errorq_elem_t *); + +/* + * Public flags for errorq_create(): bit range 0-15 + */ +#define ERRORQ_VITAL 0x0001 /* drain queue automatically on system reset */ + +/* + * Public flags for errorq_dispatch(): + */ +#define ERRORQ_ASYNC 0 /* schedule async queue drain for caller */ +#define ERRORQ_SYNC 1 /* do not schedule drain; caller will drain */ + +#ifdef _KERNEL + +extern errorq_t *errorq_create(const char *, errorq_func_t, void *, + ulong_t, size_t, uint_t, uint_t); + +extern errorq_t *errorq_nvcreate(const char *, errorq_func_t, void *, + ulong_t, size_t, uint_t, uint_t); + +extern void errorq_destroy(errorq_t *); +extern void errorq_dispatch(errorq_t *, const void *, size_t, uint_t); +extern void errorq_drain(errorq_t *); +extern void errorq_init(void); +extern void errorq_panic(void); +extern errorq_elem_t *errorq_reserve(errorq_t *); +extern void errorq_commit(errorq_t *, errorq_elem_t *, uint_t); +extern void errorq_cancel(errorq_t *, errorq_elem_t *); +extern nvlist_t *errorq_elem_nvl(errorq_t *, const errorq_elem_t *); +extern nv_alloc_t *errorq_elem_nva(errorq_t *, const errorq_elem_t *); +extern void *errorq_elem_dup(errorq_t *, const errorq_elem_t *, + errorq_elem_t **); +extern void errorq_dump(); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ERRORQ_H */ diff --git a/illumos-x86_64/usr/include/sys/errorq_impl.h b/illumos-x86_64/usr/include/sys/errorq_impl.h new file mode 100644 index 00000000..a2584b95 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/errorq_impl.h @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ERRORQ_IMPL_H +#define _ERRORQ_IMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct errorq_nvelem { + void *eqn_buf; /* data buf for this nv element */ + nvlist_t *eqn_nvl; /* nvlist */ + nv_alloc_t *eqn_nva; /* fixed nv allocator */ +} errorq_nvelem_t; + +struct errorq_elem { + struct errorq_elem *eqe_next; /* next on processing list */ + struct errorq_elem *eqe_prev; /* prev on free or pend list */ + struct errorq_elem *eqe_dump; /* next on crash dump list */ + void *eqe_data; /* data for this element */ +}; + +typedef struct errorq_kstat { + kstat_named_t eqk_dispatched; /* total errors dispatched */ + kstat_named_t eqk_dropped; /* total errors dropped */ + kstat_named_t eqk_logged; /* total errors logged */ + kstat_named_t eqk_reserved; /* total errors reserved */ + kstat_named_t eqk_reserve_fail; /* total reservation failures */ + kstat_named_t eqk_committed; /* total errors committed */ + kstat_named_t eqk_commit_fail; /* total commit failures */ + kstat_named_t eqk_cancelled; /* total reserves cancelled */ +} errorq_kstat_t; + +/* + * errorq implementation flags: bit range 16-31 + */ +#define ERRORQ_ACTIVE 0x00010000 /* queue is enabled */ +#define ERRORQ_NVLIST 0x00020000 /* nvlist queue */ + +#define ERRORQ_NAMELEN 31 /* length of queue name */ + +struct errorq { + char eq_name[ERRORQ_NAMELEN + 1]; /* string name for debugging */ + errorq_kstat_t eq_kstat; /* kstat data (see above) */ + kstat_t *eq_ksp; /* pointer to installed kstat */ + errorq_func_t eq_func; /* drain callback */ + void *eq_private; /* drain callback data */ + void *eq_data; /* buffer of queue data */ + ulong_t eq_qlen; /* maximum queue length */ + size_t eq_size; /* size of element data */ + uint_t eq_ipl; /* soft interrupt priority */ + uint_t eq_flags; /* flags (see above) */ + ddi_softintr_t eq_id; /* soft interrupt identifier */ + kmutex_t eq_lock; /* consumer lock */ + errorq_elem_t *eq_elems; /* array of all elements */ + errorq_elem_t *eq_phead; /* head of processing list */ + errorq_elem_t *eq_ptail; /* tail of processing list */ + errorq_elem_t *eq_pend; /* list of pending errors */ + ulong_t *eq_bitmap; /* bitmap of free elements */ + errorq_elem_t *eq_dump; /* list of crash dump elem's */ + struct errorq *eq_next; /* next errorq on global list */ + index_t eq_rotor; /* best efforts bitmap rotor */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _ERRORQ_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/esunddi.h b/illumos-x86_64/usr/include/sys/esunddi.h new file mode 100644 index 00000000..92a61a06 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/esunddi.h @@ -0,0 +1,273 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2016 by Delphix. All rights reserved. + * Copyright 2020 Oxide Computer Company + */ + +#ifndef _SYS_ESUNDDI_H +#define _SYS_ESUNDDI_H +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * esunddi.h: Function prototypes for kernel ddi functions. + * Note that drivers calling these functions are not + * portable. + */ + +int +e_ddi_prop_create(dev_t dev, dev_info_t *dip, int flag, + char *name, caddr_t value, int length); + +int +e_ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag, + char *name, caddr_t value, int length); + +int +e_ddi_prop_update_int(dev_t match_dev, dev_info_t *dip, + char *name, int data); + +int +e_ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip, + char *name, int64_t data); + +int +e_ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, + char *name, int *data, uint_t nelements); + +int +e_ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, + char *name, int64_t *data, uint_t nelements); + +int +e_ddi_prop_update_string(dev_t match_dev, dev_info_t *dip, + char *name, char *data); + +int +e_ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip, + char *name, char **data, uint_t nelements); + +int +e_ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip, + char *name, uchar_t *data, uint_t nelements); + +int +e_ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name); + +void +e_ddi_prop_remove_all(dev_info_t *dip); + +int +e_ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name); + +int +e_ddi_getprop(dev_t dev, vtype_t type, char *name, int flags, int defaultval); + +int64_t +e_ddi_getprop_int64(dev_t dev, vtype_t type, char *name, + int flags, int64_t defvalue); + +int +e_ddi_getproplen(dev_t dev, vtype_t type, char *name, int flags, int *lengthp); + +int +e_ddi_getlongprop(dev_t dev, vtype_t type, char *name, int flags, + caddr_t valuep, int *lengthp); + +int +e_ddi_getlongprop_buf(dev_t dev, vtype_t type, char *name, int flags, + caddr_t valuep, int *lengthp); + +int +e_ddi_parental_suspend_resume(dev_info_t *dip); + +int +e_ddi_resume(dev_info_t *dip, ddi_attach_cmd_t); + +int +e_ddi_suspend(dev_info_t *dip, ddi_detach_cmd_t cmd); + +void +pm_init(void); + +void +e_ddi_prop_list_delete(ddi_prop_t *proplist); + +int +e_ddi_copyfromdev(dev_info_t *, off_t, const void *, void *, size_t); + +int +e_ddi_copytodev(dev_info_t *, off_t, const void *, void *, size_t); + +/* + * return codes for devi_stillreferenced() + * + * DEVI_REFERENCED - specfs has open minor device(s) for the devinfo + * DEVI_NOT_REFERENCED - specfs has no open minor device for the devinfo + */ +#define DEVI_REFERENCED 1 +#define DEVI_NOT_REFERENCED 0 + +int +devi_stillreferenced(dev_info_t *dip); + +extern int (*pm_platform_power)(power_req_t *); + +/* + * A consolidation private function which is essentially equivalent to + * ddi_umem_lock but with the addition of arguments ops_vector and procp. + * The procp argument can be eliminated eventually as part of proper + * dynamic reconfiguration callback implementation. + * + * The valid flag values are those used for ddi_umem_lock plus an + * additional flag (DDI_UMEMLOCK_LONGTERM) which must be set when the + * locking will be maintained for an indefinitely long period (essentially + * permanent), rather than for what would be required for a typical I/O + * completion. When DDI_UMEMLOCK_LONGTERM is set, umem_lockmemory will + * return EFAULT if the memory pertains to a regular file which is + * mapped MAP_SHARED. This is to prevent a deadlock in the pvn routines + * if a file truncation is attempted after the locking is done. + */ +int +umem_lockmemory(caddr_t addr, size_t size, int flags, + ddi_umem_cookie_t *cookie, struct umem_callback_ops *ops_vector, + proc_t *procp); + +#define DDI_UMEMLOCK_LONGTERM 0x04 + +/* + * These are evolving forms of the ddi function ddi_hold_devi_by_instance. + * Like ddi_hold_devi_by_instance, the hold should be released with + * ddi_release_devi. + */ +dev_info_t * +e_ddi_hold_devi_by_dev(dev_t dev, int flags); + +dev_info_t * +e_ddi_hold_devi_by_path(char *path, int flags); + +/* {e_}ddi_hold_devi{_by{instance|dev|path}} flags */ +#define E_DDI_HOLD_DEVI_NOATTACH 0x01 + +void +e_ddi_hold_devi(dev_info_t *); + +/* + * Return the reference count on a devinfo node. The caller can determine, + * with knowledge of its own holds, if the devinfo node is still in use. + */ +int +e_ddi_devi_holdcnt(dev_info_t *dip); + +/* + * Perform path reconstruction given a major and instance. Does not + * drive attach of the path. + */ +int +e_ddi_majorinstance_to_path(major_t major, int instance, char *name); + +/* + * walk all devinfo nodes linked on the driver list + */ +void +e_ddi_walk_driver(char *, int (*f)(dev_info_t *, void *), void *); + +/* + * Given the nodeid for a persistent node, find the corresponding + * devinfo node. + * NOTE: .conf nodeids are not valid arguments to this function. + */ +dev_info_t * +e_ddi_nodeid_to_dip(pnode_t nodeid); + +/* + * Defines for DR interfaces + */ +#define DEVI_BRANCH_CHILD 0x01 /* Walk immediate children of root */ +#define DEVI_BRANCH_CONFIGURE 0x02 /* Configure branch after create */ +#define DEVI_BRANCH_DESTROY 0x04 /* Destroy branch after unconfigure */ +#define DEVI_BRANCH_EVENT 0x08 /* Post NDI event */ +#define DEVI_BRANCH_PROM 0x10 /* Branches derived from PROM nodes */ +#define DEVI_BRANCH_SID 0x20 /* SID node branches */ +#define DEVI_BRANCH_ROOT 0x40 /* Node is the root of a branch */ + +typedef struct devi_branch { + void *arg; + void (*devi_branch_callback)(dev_info_t *, void *, uint_t); + int type; + union { + int (*prom_branch_select)(pnode_t, void *, uint_t); + int (*sid_branch_create)(dev_info_t *, void *, uint_t); + } create; +} devi_branch_t; + +extern int e_ddi_branch_create(dev_info_t *pdip, devi_branch_t *bp, + dev_info_t **dipp, uint_t flags); +extern int e_ddi_branch_configure(dev_info_t *rdip, dev_info_t **dipp, + uint_t flags); +extern int e_ddi_branch_unconfigure(dev_info_t *rdip, dev_info_t **dipp, + uint_t flags); +extern int e_ddi_branch_destroy(dev_info_t *rdip, dev_info_t **dipp, + uint_t flags); +extern void e_ddi_branch_hold(dev_info_t *rdip); +extern void e_ddi_branch_rele(dev_info_t *rdip); +extern int e_ddi_branch_held(dev_info_t *rdip); +extern int e_ddi_branch_referenced(dev_info_t *rdip, + int (*cb)(dev_info_t *dip, void *, uint_t), void *arg); + +/* + * Obsolete interfaces, no longer used, to be removed. + * Retained only for driver compatibility. + */ +void e_ddi_enter_driver_list(struct devnames *, int *); /* obsolete */ + +int e_ddi_tryenter_driver_list(struct devnames *, int *); /* obsolete */ + +void e_ddi_exit_driver_list(struct devnames *, int); /* obsolete */ + +typedef struct ddi_unbind_callback { + list_node_t ddiub_next; + void (*ddiub_cb)(void *, dev_info_t *); + void *ddiub_arg; +} ddi_unbind_callback_t; + +extern void e_ddi_register_unbind_callback(dev_info_t *, + ddi_unbind_callback_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ESUNDDI_H */ diff --git a/illumos-x86_64/usr/include/sys/ethernet.h b/illumos-x86_64/usr/include/sys/ethernet.h new file mode 100644 index 00000000..4febb891 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ethernet.h @@ -0,0 +1,163 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2021 Oxide Computer Company + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ethernet.h header for common Ethernet declarations. + */ + +#ifndef _SYS_ETHERNET_H +#define _SYS_ETHERNET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define ETHERADDRL (6) /* ethernet address length in octets */ +#define ETHERFCSL (4) /* ethernet FCS length in octets */ +#define ETHERADDRSTRL (18) /* char size of ETHERADDRL with null */ + +/* + * Ethernet address - 6 octets + */ +typedef uchar_t ether_addr_t[ETHERADDRL]; + +/* + * Ethernet address - 6 octets + */ +struct ether_addr { + ether_addr_t ether_addr_octet; +}; + +/* + * Structure of a 10Mb/s Ethernet header. + */ +struct ether_header { + struct ether_addr ether_dhost; + struct ether_addr ether_shost; + ushort_t ether_type; +}; + +#define ETHER_CFI 0 + +struct ether_vlan_header { + struct ether_addr ether_dhost; + struct ether_addr ether_shost; + ushort_t ether_tpid; + ushort_t ether_tci; + ushort_t ether_type; +}; + +/* + * The VLAN tag. Available for applications that cannot make use of struct + * ether_vlan_header because they assume Ethernet encapsulation. + */ +struct ether_vlan_extinfo { + ushort_t ether_tci; + ushort_t ether_type; +}; + +#define ETHERTYPE_PUP (0x0200) /* PUP protocol */ +#define ETHERTYPE_802_MIN (0x0600) /* Min valid ethernet type */ + /* under IEEE 802.3 rules */ +#define ETHERTYPE_IP (0x0800) /* IP protocol */ +#define ETHERTYPE_ARP (0x0806) /* Addr. resolution protocol */ +#define ETHERTYPE_REVARP (0x8035) /* Reverse ARP */ +#define ETHERTYPE_AT (0x809b) /* AppleTalk protocol */ +#define ETHERTYPE_AARP (0x80f3) /* AppleTalk ARP */ +#define ETHERTYPE_VLAN (0x8100) /* 802.1Q VLAN */ +#define ETHERTYPE_IPV6 (0x86dd) /* IPv6 */ +#define ETHERTYPE_SLOW (0x8809) /* Slow Protocol */ +#define ETHERTYPE_PPPOED (0x8863) /* PPPoE Discovery Stage */ +#define ETHERTYPE_PPPOES (0x8864) /* PPPoE Session Stage */ +#define ETHERTYPE_EAPOL (0x888e) /* EAPOL protocol */ +#define ETHERTYPE_RSN_PREAUTH (0x88c7) /* RSN PRE-Authentication */ +#define ETHERTYPE_TRILL (0x88c8) /* TBD. TRILL frame */ +#define ETHERTYPE_FCOE (0x8906) /* FCoE */ +#define ETHERTYPE_MAX (0xffff) /* Max valid ethernet type */ + +/* + * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have + * (type-ETHERTYPE_TRAIL)*512 bytes of data followed + * by an ETHER type (as given above) and then the (variable-length) header. + */ +#define ETHERTYPE_TRAIL (0x1000) /* Trailer packet */ +#define ETHERTYPE_NTRAILER (16) + +#define ETHERMTU (1500) /* max frame w/o header or fcs */ +#define ETHERMIN (60) /* min frame w/header w/o fcs */ +#define ETHERMAX (1514) /* max frame w/header w/o fcs */ + +/* + * Compare two Ethernet addresses - assumes that the two given + * pointers can be referenced as shorts. On architectures + * where this is not the case, use bcmp instead. Note that like + * bcmp, we return zero if they are the SAME. + */ + +#if defined(__sparc) || defined(__i386) || defined(__amd64) +#define ether_cmp(a, b) (((short *)b)[2] != ((short *)a)[2] || \ + ((short *)b)[1] != ((short *)a)[1] || \ + ((short *)b)[0] != ((short *)a)[0]) +#else +#define ether_cmp(a, b) (bcmp((caddr_t)a, (caddr_t)b, 6)) +#endif + +/* + * Copy Ethernet addresses from a to b - assumes that the two given + * pointers can be referenced as shorts. On architectures + * where this is not the case, use bcopy instead. + */ + +#if defined(__sparc) || defined(__i386) || defined(__amd64) +#define ether_copy(a, b) { ((short *)b)[0] = ((short *)a)[0]; \ + ((short *)b)[1] = ((short *)a)[1]; ((short *)b)[2] = ((short *)a)[2]; } +#else +#define ether_copy(a, b) (bcopy((caddr_t)a, (caddr_t)b, 6)) +#endif + +#ifdef _KERNEL +#define ETHER_IS_MULTICAST(addr) (((addr)[0] & 0x01) != 0) + +extern int localetheraddr(struct ether_addr *, struct ether_addr *); +extern char *ether_sprintf(struct ether_addr *); +extern int ether_aton(char *, uchar_t *); +#else /* _KERNEL */ +extern char *ether_ntoa(const struct ether_addr *); +extern char *ether_ntoa_r(const struct ether_addr *, char *); +extern struct ether_addr *ether_aton(const char *); +extern struct ether_addr *ether_aton_r(const char *, struct ether_addr *); +extern int ether_ntohost(char *, const struct ether_addr *); +extern int ether_hostton(const char *, struct ether_addr *); +extern int ether_line(const char *, struct ether_addr *, char *); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ETHERNET_H */ diff --git a/illumos-x86_64/usr/include/sys/euc.h b/illumos-x86_64/usr/include/sys/euc.h new file mode 100644 index 00000000..6d45ab0e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/euc.h @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_EUC_H +#define _SYS_EUC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NOTASCII +#define SS2 0x008e +#define SS3 0x008f + + /* NOTE: c of following macros must be the 1st byte of characters */ +#define ISASCII(c) (!((c) & ~0177)) +#define NOTASCII(c) ((c) & ~0177) +#define ISSET2(c) (((c) & 0x00ff) == SS2) +#define ISSET3(c) (((c) & 0x00ff) == SS3) +#define ISPRINT(c, wp) (wp._multibyte && !ISASCII(c) || isprint(c)) + /* eucwidth_t wp; */ + +#ifndef _EUCWIDTH_T +#define _EUCWIDTH_T +typedef struct { + short int _eucw1, _eucw2, _eucw3; /* EUC width */ + short int _scrw1, _scrw2, _scrw3; /* screen width */ + short int _pcw; /* WIDE_CHAR width */ + char _multibyte; /* 1=multi-byte, 0=single-byte */ +} eucwidth_t; +#endif /* ! _EUCWIDTH_T */ +#endif /* ! NOTASCII */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EUC_H */ diff --git a/illumos-x86_64/usr/include/sys/eucioctl.h b/illumos-x86_64/usr/include/sys/eucioctl.h new file mode 100644 index 00000000..9122b523 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/eucioctl.h @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_EUCIOCTL_H +#define _SYS_EUCIOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * /usr/include/sys/eucioctl.h: + * + * Header for EUC width information to LD modules. + */ + +#ifndef EUC_IOC +#define EUC_IOC (('E' | 128) << 8) +#endif +#define EUC_WSET (EUC_IOC | 1) +#define EUC_WGET (EUC_IOC | 2) +#define EUC_MSAVE (EUC_IOC | 3) +#define EUC_MREST (EUC_IOC | 4) +#define EUC_IXLOFF (EUC_IOC | 5) +#define EUC_IXLON (EUC_IOC | 6) +#define EUC_OXLOFF (EUC_IOC | 7) +#define EUC_OXLON (EUC_IOC | 8) + +/* + * This structure should really be the same one as defined in "euc.h", + * but we want to minimize the number of bytes sent downstream to each + * module -- this should make it 8 bytes -- therefore, we take only the + * info we need. The major assumptions here are that no EUC character + * set has a character width greater than 255 bytes, and that no EUC + * character consumes more than 255 screen columns. Let me know if this + * is an unsafe assumption... + */ + +struct eucioc { + unsigned char eucw[4]; + unsigned char scrw[4]; +}; +typedef struct eucioc eucioc_t; + +/* + * The following defines are for LD modules to broadcast the state of + * their "icanon" bit. + * + * The message type is M_CTL; message block 1 has a data block containing + * an "iocblk"; EUC_BCAST is put into the "ioc_cmd" field. The "b_cont" + * of the first message block points to a second message block. The second + * message block is type M_DATA; it contains 1 byte that is either EUC_B_RAW + * or EUC_B_CANON depending on the state of the "icanon" bit. EUC line + * disciplines should take care to broadcast this information when they are + * in multibyte character mode. + */ + +#define EUC_BCAST EUC_IOC|16 + +#define EUC_B_CANON '\177' +#define EUC_B_RAW '\001' /* MUST be non-zero! */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EUCIOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/eventfd.h b/illumos-x86_64/usr/include/sys/eventfd.h new file mode 100644 index 00000000..b64a1013 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/eventfd.h @@ -0,0 +1,76 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2017, Joyent, Inc. + */ + +/* + * Header file to support for the eventfd facility. Note that this facility + * is designed to be binary compatible with the Linux eventfd facility; values + * for constants here should therefore exactly match those found in Linux, and + * this facility shouldn't be extended independently of Linux. + */ + +#ifndef _SYS_EVENTFD_H +#define _SYS_EVENTFD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint64_t eventfd_t; + +/* + * To assure binary compatibility with Linux, these values are fixed at their + * Linux equivalents, not their native ones. + */ +#define EFD_CLOEXEC 02000000 /* LX_O_CLOEXEC */ +#define EFD_NONBLOCK 04000 /* LX_O_NONBLOCK */ +#define EFD_SEMAPHORE 1 + +/* + * These ioctl values are specific to the native implementation; applications + * shouldn't be using them directly, and they should therefore be safe to + * change without breaking apps. + */ +#define EVENTFDIOC (('e' << 24) | ('f' << 16) | ('d' << 8)) +#define EVENTFDIOC_SEMAPHORE (EVENTFDIOC | 1) /* toggle sem state */ + +/* + * Kernel-internal method to write to eventfd while bypassing overflow limits, + * therefore avoiding potential to block as well. This is used to fulfill AIO + * behavior in LX related to eventfd notification. + */ +#define EVENTFDIOC_POST (EVENTFDIOC | 2) + +#ifndef _KERNEL + +extern int eventfd(unsigned int, int); +extern int eventfd_read(int, eventfd_t *); +extern int eventfd_write(int, eventfd_t); + +#else + +#define EVENTFDMNRN_EVENTFD 0 +#define EVENTFDMNRN_CLONE 1 +#define EVENTFD_VALMAX (ULLONG_MAX - 1ULL) +#define EVENTFD_VALOVERFLOW ULLONG_MAX + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EVENTFD_H */ diff --git a/illumos-x86_64/usr/include/sys/exacct.h b/illumos-x86_64/usr/include/sys/exacct.h new file mode 100644 index 00000000..a9c394bb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/exacct.h @@ -0,0 +1,205 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_EXACCT_H +#define _SYS_EXACCT_H + +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define EXACCT_VERSION 1 + +/* + * unpack and free allocation options: the behaviour of the ea_free_object() + * function is coordinated with whether an unpack used EUP_ALLOC or EUP_NOALLOC, + * such that unpacked object hierarchies can be later freed successfully. + */ +#define EUP_ALLOC 0x0 /* allocate new memory for vbl length objects */ +#define EUP_NOALLOC 0x1 /* use existing buffer for vbl length objects */ +#define EUP_ALLOC_MASK 0x1 + +/* + * wracct and putacct record type options: the properties of the partial and + * interval records differ slightly: a partial record is a snapshot of the + * resource usage for the given process or task, while an interval record + * reports the current usage since the last interval record or creation. + * Interval records are supported only for tasks. + */ +#define EW_PARTIAL (0x01) /* partial record */ +#define EW_INTERVAL (0x02) /* interval record */ +#define EW_FINAL (0x04) /* final record: used only in kernel */ + +/* + * putacct contents option: the contents of the buffer passed to putacct may be + * identified either as raw data or as a packed exacct record. + */ +#define EP_RAW 0 +#define EP_EXACCT_OBJECT 1 + +#define EXACCT_MAX_BUFSIZE (64 * 1024) + +#ifndef _KERNEL +extern size_t getacct(idtype_t, id_t, void *, size_t); +extern int putacct(idtype_t, id_t, void *, size_t, int); +extern int wracct(idtype_t, id_t, int); +#endif /* ! _KERNEL */ + +/* + * Error codes. libexacct reports these errors through the ea_error() function; + * in the case of EXR_SYSCALL_FAIL, errno will contain the error code + * encountered by the underlying system call. + */ +#define EXR_OK 0 +#define EXR_SYSCALL_FAIL 1 +#define EXR_CORRUPT_FILE 2 +#define EXR_EOF 3 +#define EXR_NO_CREATOR 4 +#define EXR_INVALID_BUF 5 +#define EXR_NOTSUPP 6 +#define EXR_UNKN_VERSION 7 +#define EXR_INVALID_OBJ 8 + +typedef uint64_t ea_size_t; +typedef uint32_t ea_catalog_t; + +typedef enum {EO_ERROR = -1, EO_NONE = 0, EO_GROUP, EO_ITEM} ea_object_type_t; + +typedef struct ea_item { + /* + * The ei_u union is discriminated via the type field of the enclosing + * object's catalog tag. + */ + union { + uint8_t ei_u_uint8; + uint16_t ei_u_uint16; + uint32_t ei_u_uint32; + uint64_t ei_u_uint64; + double ei_u_double; + char *ei_u_string; + void *ei_u_object; /* for embedded packed object */ + void *ei_u_raw; + } ei_u; + ea_size_t ei_size; +} ea_item_t; +#define ei_uint8 ei_u.ei_u_uint8 +#define ei_uint16 ei_u.ei_u_uint16 +#define ei_uint32 ei_u.ei_u_uint32 +#define ei_uint64 ei_u.ei_u_uint64 +#define ei_double ei_u.ei_u_double +#define ei_string ei_u.ei_u_string +#define ei_object ei_u.ei_u_object +#define ei_raw ei_u.ei_u_raw + +typedef struct ea_group { + uint32_t eg_nobjs; + struct ea_object *eg_objs; +} ea_group_t; + +typedef struct ea_object { + ea_object_type_t eo_type; + union { + ea_group_t eo_u_group; + ea_item_t eo_u_item; + } eo_u; + struct ea_object *eo_next; + ea_catalog_t eo_catalog; +} ea_object_t; +#define eo_group eo_u.eo_u_group +#define eo_item eo_u.eo_u_item + +extern int ea_set_item(ea_object_t *, ea_catalog_t, const void *, size_t); +extern int ea_set_group(ea_object_t *, ea_catalog_t); + +/* + * In prior releases, the following three functions had the type void, and so + * could not return a status code. In SunOS 5.9, the return type has been + * changed to int, so that if errors are detected the invoking application + * can be notified appropriately. + */ +extern int ea_attach_to_object(ea_object_t *, ea_object_t *); +extern int ea_attach_to_group(ea_object_t *, ea_object_t *); +extern int ea_free_item(ea_object_t *, int); + +extern void ea_free_object(ea_object_t *, int); +extern size_t ea_pack_object(ea_object_t *, void *, size_t); +extern void *ea_alloc(size_t); +extern void ea_free(void *, size_t); +extern char *ea_strdup(const char *); +extern void ea_strfree(char *); + +#ifdef _KERNEL +extern ea_object_t *ea_alloc_item(ea_catalog_t, void *, size_t); +extern ea_object_t *ea_alloc_group(ea_catalog_t); +extern ea_object_t *ea_attach_item(ea_object_t *, void *, size_t, ea_catalog_t); +extern void exacct_commit_task(void *); +extern void exacct_commit_proc(proc_t *, int); +extern void exacct_update_task_mstate(proc_t *); +extern int exacct_tag_task(ac_info_t *, task_t *, void *, size_t, int); +extern int exacct_tag_proc(ac_info_t *, pid_t, taskid_t, void *, size_t, int, + const char *); +extern void exacct_commit_flow(void *); +extern int exacct_commit_netinfo(void *, int); +extern void exacct_init(void); +extern void *exacct_create_header(size_t *); +extern int exacct_write_header(ac_info_t *, void *, size_t); +extern void exacct_calculate_proc_usage(proc_t *, proc_usage_t *, + ulong_t *, int, int); +extern int exacct_commit_callback(ac_info_t *, void *, size_t, void *, + size_t, size_t *); +extern int exacct_assemble_proc_usage(ac_info_t *, proc_usage_t *, + int (*)(ac_info_t *, void *, size_t, void *, size_t, size_t *), + void *, size_t, size_t *, int); +extern int exacct_assemble_task_usage(ac_info_t *, task_t *, + int (*)(ac_info_t *, void *, size_t, void *, size_t, size_t *), + void *, size_t, size_t *, int); +extern int exacct_assemble_flow_usage(ac_info_t *, flow_usage_t *, + int (*)(ac_info_t *, void *, size_t, void *, size_t, size_t *), + void *, size_t, size_t *); +extern void exacct_move_mstate(proc_t *, task_t *, task_t *); +extern int exacct_assemble_net_usage(ac_info_t *, void *, + int (*)(ac_info_t *, void *, size_t, void *, size_t, size_t *), + void *, size_t, size_t *, int); +extern taskq_t *exacct_queue; +extern kmem_cache_t *exacct_object_cache; +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EXACCT_H */ diff --git a/illumos-x86_64/usr/include/sys/exacct_catalog.h b/illumos-x86_64/usr/include/sys/exacct_catalog.h new file mode 100644 index 00000000..f6d9c09e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/exacct_catalog.h @@ -0,0 +1,242 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_EXACCT_CATALOG_H +#define _SYS_EXACCT_CATALOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * exacct_catalog.h contains the default catalog for SunOS resource values + * reported via the extended accounting facility. Each recorded value written + * to an exacct file is identified via its catalog tag, which is the first four + * bytes of each object. The exacct catalog tag is a 32-bit integer partitioned + * into three fields, as illustrated by the following diagram. + * + * 31 27 23 0 + * +-------+-------+----------------------------------------------+ + * |type |catalog|id | + * +-------+-------+----------------------------------------------+ + * + * Each of the fields is described in more detail below. + */ + +/* + * Data type field. These should correspond to the values of an ea_item_type_t, + * shifted left 28 bits, plus the special value for a record group. All + * unspecified values of this field are reserved for future use. + */ +#define EXT_TYPE_MASK ((uint_t)0xf << 28) + +#define EXT_NONE ((uint_t)0x0 << 28) +#define EXT_UINT8 ((uint_t)0x1 << 28) +#define EXT_UINT16 ((uint_t)0x2 << 28) +#define EXT_UINT32 ((uint_t)0x3 << 28) +#define EXT_UINT64 ((uint_t)0x4 << 28) +#define EXT_DOUBLE ((uint_t)0x5 << 28) +#define EXT_STRING ((uint_t)0x6 << 28) +#define EXT_EXACCT_OBJECT ((uint_t)0x7 << 28) +#define EXT_RAW ((uint_t)0x8 << 28) +#define EXT_GROUP ((uint_t)0xf << 28) + +/* + * The catalog type field is the second four bits of the catalog tag. All + * unspecified values of this field are reserved for future use. + */ +#define EXC_CATALOG_MASK ((uint_t)0xf << 24) + +#define EXC_NONE (0x0 << 24) +#define EXC_LOCAL (0x1 << 24) +#define EXC_DEFAULT EXC_NONE + +/* + * The data id field comprises the final 24 bits of an ea_catalog_t. The + * current Solaris data ids defined in this version of the exacct format follow. + * All values of this field are reserved if the catalog type is EXC_DEFAULT. If + * the catalog type is EXC_LOCAL, this field is application defined. + */ +#define EXD_DATA_MASK 0xffffff + +#define EXD_NONE 0x000000 + +#define EXD_VERSION 0x000001 +#define EXD_FILETYPE 0x000002 +#define EXD_CREATOR 0x000003 +#define EXD_HOSTNAME 0x000004 + +#define EXD_GROUP_HEADER 0x0000ff +#define EXD_GROUP_PROC 0x000100 +#define EXD_GROUP_TASK 0x000101 +#define EXD_GROUP_LWP 0x000102 +#define EXD_GROUP_PROC_TAG 0x000103 +#define EXD_GROUP_TASK_TAG 0x000104 +#define EXD_GROUP_LWP_TAG 0x000105 +#define EXD_GROUP_PROC_PARTIAL 0x000106 +#define EXD_GROUP_TASK_PARTIAL 0x000107 +#define EXD_GROUP_TASK_INTERVAL 0x000108 +#define EXD_GROUP_FLOW 0x000109 +#define EXD_GROUP_RFMA 0x00010a +#define EXD_GROUP_FMA 0x00010b +#define EXD_GROUP_NET_LINK_DESC 0X00010c +#define EXD_GROUP_NET_FLOW_DESC 0X00010d +#define EXD_GROUP_NET_LINK_STATS 0X00010e +#define EXD_GROUP_NET_FLOW_STATS 0X00010f + +#define EXD_PROC_PID 0x001000 +#define EXD_PROC_UID 0x001001 +#define EXD_PROC_GID 0x001002 +#define EXD_PROC_TASKID 0x001003 +#define EXD_PROC_PROJID 0x001004 +#define EXD_PROC_HOSTNAME 0x001005 +#define EXD_PROC_COMMAND 0x001006 +#define EXD_PROC_START_SEC 0x001007 +#define EXD_PROC_START_NSEC 0x001008 +#define EXD_PROC_FINISH_SEC 0x001009 +#define EXD_PROC_FINISH_NSEC 0x00100a +#define EXD_PROC_CPU_USER_SEC 0x00100b +#define EXD_PROC_CPU_USER_NSEC 0x00100c +#define EXD_PROC_CPU_SYS_SEC 0x00100d +#define EXD_PROC_CPU_SYS_NSEC 0x00100e +#define EXD_PROC_TTY_MAJOR 0x00100f +#define EXD_PROC_TTY_MINOR 0x001010 +#define EXD_PROC_FAULTS_MAJOR 0x001011 +#define EXD_PROC_FAULTS_MINOR 0x001012 +#define EXD_PROC_MESSAGES_RCV 0x001013 +#define EXD_PROC_MESSAGES_SND 0x001014 +#define EXD_PROC_BLOCKS_IN 0x001015 +#define EXD_PROC_BLOCKS_OUT 0x001016 +#define EXD_PROC_CHARS_RDWR 0x001017 +#define EXD_PROC_CONTEXT_VOL 0x001018 +#define EXD_PROC_CONTEXT_INV 0x001019 +#define EXD_PROC_SIGNALS 0x00101a +#define EXD_PROC_SWAPS 0x00101b +#define EXD_PROC_SYSCALLS 0x00101c +#define EXD_PROC_ACCT_FLAGS 0x00101d +#define EXD_PROC_TAG 0x00101e +#define EXD_PROC_ANCPID 0x00101f +#define EXD_PROC_WAIT_STATUS 0x001020 +#define EXD_PROC_ZONENAME 0x001021 +/* + * Physical memory usage estimates, in kilobytes. Counts usage due to + * both memory used exclusively by the process, and memory shared with + * other processes. + */ +#define EXD_PROC_MEM_RSS_AVG_K 0x001022 +#define EXD_PROC_MEM_RSS_MAX_K 0x001023 + +#define EXD_TASK_TASKID 0x002000 +#define EXD_TASK_PROJID 0x002001 +#define EXD_TASK_HOSTNAME 0x002002 +#define EXD_TASK_START_SEC 0x002003 +#define EXD_TASK_START_NSEC 0x002004 +#define EXD_TASK_FINISH_SEC 0x002005 +#define EXD_TASK_FINISH_NSEC 0x002006 +#define EXD_TASK_CPU_USER_SEC 0x002007 +#define EXD_TASK_CPU_USER_NSEC 0x002008 +#define EXD_TASK_CPU_SYS_SEC 0x002009 +#define EXD_TASK_CPU_SYS_NSEC 0x00200a +#define EXD_TASK_FAULTS_MAJOR 0x00200b +#define EXD_TASK_FAULTS_MINOR 0x00200c +#define EXD_TASK_MESSAGES_RCV 0x00200d +#define EXD_TASK_MESSAGES_SND 0x00200e +#define EXD_TASK_BLOCKS_IN 0x00200f +#define EXD_TASK_BLOCKS_OUT 0x002010 +#define EXD_TASK_CHARS_RDWR 0x002011 +#define EXD_TASK_CONTEXT_VOL 0x002012 +#define EXD_TASK_CONTEXT_INV 0x002013 +#define EXD_TASK_SIGNALS 0x002014 +#define EXD_TASK_SWAPS 0x002015 +#define EXD_TASK_SYSCALLS 0x002016 +#define EXD_TASK_TAG 0x002017 +#define EXD_TASK_ANCTASKID 0x002018 +#define EXD_TASK_ZONENAME 0x002019 + +#define EXD_FLOW_V4SADDR 0x003000 +#define EXD_FLOW_V4DADDR 0x003001 +#define EXD_FLOW_V6SADDR 0x003002 +#define EXD_FLOW_V6DADDR 0x003003 +#define EXD_FLOW_SPORT 0x003004 +#define EXD_FLOW_DPORT 0x003005 +#define EXD_FLOW_PROTOCOL 0x003006 +#define EXD_FLOW_DSFIELD 0x003007 +#define EXD_FLOW_NBYTES 0x003008 +#define EXD_FLOW_NPKTS 0x003009 +#define EXD_FLOW_CTIME 0x00300a +#define EXD_FLOW_LSEEN 0x00300b +#define EXD_FLOW_PROJID 0x00300c +#define EXD_FLOW_UID 0x00300d +#define EXD_FLOW_ANAME 0x00300e + +#define EXD_FMA_LABEL 0x004000 +#define EXD_FMA_VERSION 0x004001 +#define EXD_FMA_OSREL 0x004002 +#define EXD_FMA_OSVER 0x004003 +#define EXD_FMA_PLAT 0x004004 +#define EXD_FMA_TODSEC 0x004005 +#define EXD_FMA_TODNSEC 0x004006 +#define EXD_FMA_NVLIST 0x004007 +#define EXD_FMA_MAJOR 0x004008 +#define EXD_FMA_MINOR 0x004009 +#define EXD_FMA_INODE 0x00400A +#define EXD_FMA_OFFSET 0x00400B +#define EXD_FMA_UUID 0x00400C + +/* For EXD_GROUP_FLDESC and EXD_GROUP_LNDESC */ +#define EXD_NET_DESC_NAME 0x005001 +#define EXD_NET_DESC_EHOST 0x005002 +#define EXD_NET_DESC_EDEST 0x005003 +#define EXD_NET_DESC_VLAN_TPID 0x005004 +#define EXD_NET_DESC_VLAN_TCI 0x005005 +#define EXD_NET_DESC_SAP 0x005006 +#define EXD_NET_DESC_PRIORITY 0x005007 +#define EXD_NET_DESC_BWLIMIT 0x005008 +/* For EXD_GROUP_FLDESC only */ +#define EXD_NET_DESC_DEVNAME 0x005009 +#define EXD_NET_DESC_V4SADDR 0x00500a +#define EXD_NET_DESC_V4DADDR 0x00500b +#define EXD_NET_DESC_V6SADDR 0x00500c +#define EXD_NET_DESC_V6DADDR 0x00500d +#define EXD_NET_DESC_SPORT 0x00500e +#define EXD_NET_DESC_DPORT 0x00500f +#define EXD_NET_DESC_PROTOCOL 0x005010 +#define EXD_NET_DESC_DSFIELD 0x005011 + +/* For EXD_NET_STATS */ +#define EXD_NET_STATS_NAME 0x006000 +#define EXD_NET_STATS_CURTIME 0x006001 +#define EXD_NET_STATS_IBYTES 0x006002 +#define EXD_NET_STATS_OBYTES 0x006003 +#define EXD_NET_STATS_IPKTS 0x006004 +#define EXD_NET_STATS_OPKTS 0x006005 +#define EXD_NET_STATS_IERRPKTS 0x006006 +#define EXD_NET_STATS_OERRPKTS 0x006007 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EXACCT_CATALOG_H */ diff --git a/illumos-x86_64/usr/include/sys/exacct_impl.h b/illumos-x86_64/usr/include/sys/exacct_impl.h new file mode 100644 index 00000000..6f25f02e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/exacct_impl.h @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_EXACCT_IMPL_H +#define _SYS_EXACCT_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * Setting the exacct error code. libexacct provides more detailed codes for + * identifying causes of operational failure; the kernel doesn't use this + * facility, since the kernel operations can't fail. (KM_SLEEP allocations, + * for instance.) + */ +#ifdef _KERNEL +#define EXACCT_SET_ERR(x) +#else /* _KERNEL */ +extern void exacct_seterr(int); +#define EXACCT_SET_ERR(x) exacct_seterr(x) +#endif /* _KERNEL */ + +typedef struct task_usage { + hrtime_t tu_utime; /* user time */ + hrtime_t tu_stime; /* system time */ + + uint64_t tu_minflt; /* minor faults */ + uint64_t tu_majflt; /* major faults */ + uint64_t tu_sndmsg; /* messages sent */ + uint64_t tu_rcvmsg; /* messages received */ + uint64_t tu_ioch; /* characters read and written */ + uint64_t tu_iblk; /* input blocks */ + uint64_t tu_oblk; /* output blocks */ + uint64_t tu_vcsw; /* voluntary context switches */ + uint64_t tu_icsw; /* involuntary context switches */ + uint64_t tu_nsig; /* signals received */ + uint64_t tu_nswp; /* swaps */ + uint64_t tu_nscl; /* system calls */ + uint64_t tu_startsec; /* start time (seconds) */ + uint64_t tu_startnsec; /* start time (nanoseconds) */ + uint64_t tu_finishsec; /* finish time (seconds) */ + uint64_t tu_finishnsec; /* finish time (nanoseconds) */ + taskid_t tu_anctaskid; /* ancestor task's ID */ +} task_usage_t; + +typedef struct proc_usage { + uint64_t pu_minflt; /* minor faults */ + uint64_t pu_majflt; /* major faults */ + uint64_t pu_sndmsg; /* messages sent */ + uint64_t pu_rcvmsg; /* messages received */ + uint64_t pu_ioch; /* characters read and written */ + uint64_t pu_iblk; /* input blocks */ + uint64_t pu_oblk; /* output blocks */ + uint64_t pu_vcsw; /* voluntary context switches */ + uint64_t pu_icsw; /* involuntary context switches */ + uint64_t pu_nsig; /* signals received */ + uint64_t pu_nswp; /* swaps */ + uint64_t pu_nscl; /* system calls */ + uint64_t pu_utimesec; /* user time (seconds) */ + uint64_t pu_utimensec; /* user time (nanoseconds) */ + uint64_t pu_stimesec; /* system time (seconds) */ + uint64_t pu_stimensec; /* system time (nanoseconds) */ + uint64_t pu_startsec; /* start time (seconds) */ + uint64_t pu_startnsec; /* start time (nanoseconds) */ + uint64_t pu_finishsec; /* finish time (seconds) */ + uint64_t pu_finishnsec; /* finish time (nanoseconds) */ + uint64_t pu_mem_rss_avg; /* average RSS (K) */ + uint64_t pu_mem_rss_max; /* peak RSS (K) */ + + pid_t pu_pid; /* process ID */ + uid_t pu_ruid; /* user ID */ + gid_t pu_rgid; /* group ID */ + projid_t pu_projid; /* project ID */ + taskid_t pu_taskid; /* task ID */ + uint32_t pu_acflag; /* accounting flags */ + char *pu_command; /* command string */ + uint32_t pu_major; /* major number of controlling tty */ + uint32_t pu_minor; /* minor number of controlling tty */ + int pu_wstat; /* wait() status */ + pid_t pu_ancpid; /* ancestor process's ID */ + char pu_zonename[ZONENAME_MAX]; /* Zone name */ + char pu_nodename[_SYS_NMLN]; +} proc_usage_t; + +typedef struct flow_usage { + uint32_t fu_saddr[4]; /* source address */ + uint32_t fu_daddr[4]; /* remote address */ + uint8_t fu_protocol; /* protocol type */ + uint16_t fu_sport; /* source port */ + uint16_t fu_dport; /* remote port */ + uint8_t fu_dsfield; /* DS field */ + uint32_t fu_nbytes; /* number of bytes (incl. IP header) */ + uint32_t fu_npackets; /* number of packets */ + uint64_t fu_ctime; /* creation time for this item */ + uint64_t fu_lseen; /* when the last item of this desc. was seen */ + projid_t fu_projid; /* project ID */ + uid_t fu_userid; /* user ID */ + boolean_t fu_isv4; /* to extract the correct l/r-addr */ + char *fu_aname; /* action instance name */ +} flow_usage_t; + +#define EX_NET_LNDESC_REC 1 +#define EX_NET_FLDESC_REC 2 +#define EX_NET_LNSTAT_REC 3 +#define EX_NET_FLSTAT_REC 4 + +typedef struct net_stat_s { + char *ns_name; + uint64_t ns_ibytes; + uint64_t ns_obytes; + uint64_t ns_ipackets; + uint64_t ns_opackets; + uint64_t ns_ierrors; + uint64_t ns_oerrors; + boolean_t ns_isref; +} net_stat_t; + +typedef struct net_desc_s { + char *nd_name; + char *nd_devname; + uchar_t nd_ehost[6]; + uchar_t nd_edest[6]; + ushort_t nd_vlan_tpid; + ushort_t nd_vlan_tci; + ushort_t nd_sap; + ushort_t nd_priority; + uint64_t nd_bw_limit; + uint32_t nd_saddr[4]; + uint32_t nd_daddr[4]; + boolean_t nd_isv4; + uint16_t nd_sport; + uint16_t nd_dport; + uint8_t nd_protocol; + uint8_t nd_dsfield; + int nd_type; +} net_desc_t; + +extern void exacct_order16(uint16_t *); +extern void exacct_order32(uint32_t *); +extern void exacct_order64(uint64_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EXACCT_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/exec.h b/illumos-x86_64/usr/include/sys/exec.h new file mode 100644 index 00000000..9d1e0d23 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/exec.h @@ -0,0 +1,274 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2022 Garrett D'Amore + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_EXEC_H +#define _SYS_EXEC_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Number of bytes to read for magic string + */ +#define MAGIC_BYTES 8 + +#define getexmag(x) (((x)[0] << 8) + (x)[1]) + +typedef struct execa { + const char *fname; + const char **argp; + const char **envp; +} execa_t; + +typedef struct execenv { + caddr_t ex_bssbase; + caddr_t ex_brkbase; + size_t ex_brksize; + vnode_t *ex_vp; + short ex_magic; +} execenv_t; + +#ifdef _KERNEL + +#define LOADABLE_EXEC(e) ((e)->exec_lock) +#define LOADED_EXEC(e) ((e)->exec_func) + + +/* + * User argument structure for passing exec information around between the + * common and machine-dependent portions of exec and the exec modules. + */ +typedef struct uarg { + ssize_t na; + ssize_t ne; + ssize_t nc; + size_t argstrlen; + size_t envstrlen; + char *fname; + char *pathname; + size_t auxsize; + caddr_t stackend; + size_t stk_align; + size_t stk_size; + char *stk_base; + char *stk_strp; + int *stk_offp; + size_t usrstack_size; + uint_t stk_prot; + uint_t dat_prot; + int traceinval; + int addr32; + model_t to_model; + model_t from_model; + size_t to_ptrsize; + size_t from_ptrsize; + size_t ncargs; + struct execsw *execswp; + uintptr_t entry; + uintptr_t thrptr; + vnode_t *ex_vp; + char *emulator; + char *brandname; + const char *brand_nroot; + char *auxp_auxflags; /* addr of auxflags auxv on the user stack */ + char *auxp_brand; /* address of first brand auxv on user stack */ + cred_t *pfcred; + boolean_t scrubenv; + uintptr_t maxstack; + boolean_t stk_prot_override; + uintptr_t commpage; +} uarg_t; + +/* + * Possible brand actions for exec. + */ +#define EBA_NONE 0 +#define EBA_NATIVE 1 +#define EBA_BRAND 2 + +/* + * The following macro is a machine dependent encapsulation of + * postfix processing to hide the stack direction from elf.c + * thereby making the elf.c code machine independent. + */ +#define execpoststack(ARGS, ARRAYADDR, BYTESIZE) \ + (copyout((caddr_t)(ARRAYADDR), (ARGS)->stackend, (BYTESIZE)) ? EFAULT \ + : (((ARGS)->stackend += (BYTESIZE)), 0)) + +/* + * This provides the current user stack address for an object of size BYTESIZE. + * Used to determine the stack address just before applying execpoststack(). + */ +#define stackaddress(ARGS, BYTESIZE) ((ARGS)->stackend) + +/* + * Macro to add attribute/values the aux vector under construction. + */ +/* BEGIN CSTYLED */ +#if ((_LONG_ALIGNMENT == (2 * _INT_ALIGNMENT)) || \ + (_POINTER_ALIGNMENT == (2 * _INT_ALIGNMENT))) +/* END CSTYLED */ +/* + * This convoluted stuff is necessitated by the fact that there is + * potential padding in the aux vector, but not necessarily and + * without clearing the padding there is a small, but potential + * security hole. + */ +#define ADDAUX(p, a, v) { \ + (&(p)->a_type)[1] = 0; \ + (p)->a_type = (a); \ + (p)->a_un.a_val = (v); \ + ++(p); \ + } +#else +#define ADDAUX(p, a, v) { \ + (p)->a_type = (a); \ + ((p)++)->a_un.a_val = (v); \ + } +#endif + +#define INTPSZ MAXPATHLEN +#define INTP_MAXDEPTH 5 /* Nested interpreter depth matches Linux */ +typedef struct intpdata { + char *intp; + char *intp_name[INTP_MAXDEPTH]; + char *intp_arg[INTP_MAXDEPTH]; +} intpdata_t; + +#define EXECSETID_SETID 0x1 /* setid exec */ +#define EXECSETID_UGIDS 0x2 /* [ug]ids mismatch */ +#define EXECSETID_PRIVS 0x4 /* more privs than before */ + +struct execsw { + char *exec_magic; + int exec_magoff; + int exec_maglen; + int (*exec_func)(struct vnode *vp, struct execa *uap, + struct uarg *args, struct intpdata *idata, int level, + size_t *execsz, int setid, caddr_t exec_file, + struct cred *cred, int *brand_action); + int (*exec_core)(struct vnode *vp, struct proc *p, + struct cred *cred, rlim64_t rlimit, int sig, + core_content_t content); + krwlock_t *exec_lock; +}; + +extern int nexectype; /* number of elements in execsw */ +extern struct execsw execsw[]; +extern kmutex_t execsw_lock; + +extern short elfmagic; +extern short intpmagic; +extern short javamagic; +extern short nomagic; + +extern char elf32magicstr[]; +extern char elf64magicstr[]; +extern char intpmagicstr[]; +extern char javamagicstr[]; +extern char nomagicstr[]; + +extern int exec_args(execa_t *, uarg_t *, intpdata_t *, void **); +extern int exece(uintptr_t, const char **, const char **, int); +extern int exec_common(const char *, const char **, const char **, vnode_t *, + int); +extern int gexec(vnode_t **vp, struct execa *uap, struct uarg *args, + struct intpdata *idata, int level, size_t *execsz, caddr_t exec_file, + struct cred *cred, int *brand_action); +extern struct execsw *allocate_execsw(char *name, char *magic, + size_t magic_size); +extern struct execsw *findexecsw(char *magic); +extern struct execsw *findexec_by_hdr(char *header); +extern struct execsw *findexec_by_magic(char *magic); +extern int execpermissions(struct vnode *vp, struct vattr *vattrp, + struct uarg *args); +extern int execmap(vnode_t *vp, caddr_t addr, size_t len, size_t zfodlen, + off_t offset, int prot, int page, uint_t); +extern void setexecenv(struct execenv *ep); +extern int execopen(struct vnode **vpp, int *fdp); +extern int execclose(int fd); +extern void setregs(uarg_t *); +extern void exec_set_sp(size_t); + +/* + * Utility functions for branded process executing + */ +#if !defined(_ELF32_COMPAT) +/* + * When compiling 64-bit kernels we don't want these definitions included + * when compiling the 32-bit compatability elf code in the elfexec module. + */ +extern int elfexec(vnode_t *, execa_t *, uarg_t *, intpdata_t *, int, + size_t *, int, caddr_t, cred_t *, int *); +extern int mapexec_brand(vnode_t *, uarg_t *, Ehdr *, Addr *, + intptr_t *, caddr_t, char **, caddr_t *, caddr_t *, size_t *, + uintptr_t *, uintptr_t *); +extern int elfreadhdr(vnode_t *, cred_t *, Ehdr *, uint_t *, caddr_t *, + size_t *); +#endif /* !_ELF32_COMPAT */ + +#if defined(_LP64) +extern int elf32exec(vnode_t *, execa_t *, uarg_t *, intpdata_t *, int, + size_t *, int, caddr_t, cred_t *, int *); +extern int mapexec32_brand(vnode_t *, uarg_t *, Elf32_Ehdr *, Elf32_Addr *, + intptr_t *, caddr_t, char **, caddr_t *, caddr_t *, size_t *, + uintptr_t *, uintptr_t *); +extern int elf32readhdr(vnode_t *, cred_t *, Elf32_Ehdr *, uint_t *, caddr_t *, + size_t *); +#endif /* _LP64 */ + +/* + * Utility functions for exec module core routines: + */ +extern int core_seg(proc_t *, vnode_t *, u_offset_t, caddr_t, size_t, + rlim64_t, cred_t *); + +extern int core_write(vnode_t *, enum uio_seg, u_offset_t, const void *, + size_t, rlim64_t, cred_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EXEC_H */ diff --git a/illumos-x86_64/usr/include/sys/exechdr.h b/illumos-x86_64/usr/include/sys/exechdr.h new file mode 100644 index 00000000..d63595b9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/exechdr.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1995-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_EXECHDR_H +#define _SYS_EXECHDR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * format of the exec header + * known by kernel and by user programs + */ +struct exec { + unsigned a_dynamic:1; /* has a __DYNAMIC */ + unsigned a_toolversion:7; /* version of toolset used to */ + /* create this file */ + unsigned char a_machtype; /* machine type */ + uint16_t a_magic; /* magic number */ + uint32_t a_text; /* size of text segment */ + uint32_t a_data; /* size of initialized data */ + uint32_t a_bss; /* size of uninitialized data */ + uint32_t a_syms; /* size of symbol table */ + uint32_t a_entry; /* entry point */ + uint32_t a_trsize; /* size of text relocation */ + uint32_t a_drsize; /* size of data relocation */ +}; + +#define OMAGIC 0407 /* old impure format */ +#define NMAGIC 0410 /* read-only text */ +#define ZMAGIC 0413 /* demand load format */ + +/* machine types */ + +#define M_OLDSUN2 0 /* old sun-2 executable files */ +#define M_68010 1 /* runs on either 68010 or 68020 */ +#define M_68020 2 /* runs only on 68020 */ +#define M_SPARC 3 /* runs only on SPARC */ + +#define TV_SUN2_SUN3 0 +#define TV_SUN4 1 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EXECHDR_H */ diff --git a/illumos-x86_64/usr/include/sys/execx.h b/illumos-x86_64/usr/include/sys/execx.h new file mode 100644 index 00000000..2f9ea5f9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/execx.h @@ -0,0 +1,38 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_EXECX_H +#define _SYS_EXECX_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * If this flag is set then the first argument to execvex() is interpreted as + * a file descriptor that is open in the calling process rather than the name + * of a program to be executed. + */ +#define EXEC_DESCRIPTOR 0x1 + +#ifndef _KERNEL +extern int execvex(uintptr_t, char *const *, char *const *, int); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EXECX_H */ diff --git a/illumos-x86_64/usr/include/sys/fasttrap.h b/illumos-x86_64/usr/include/sys/fasttrap.h new file mode 100644 index 00000000..71eb846c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fasttrap.h @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FASTTRAP_H +#define _SYS_FASTTRAP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define FASTTRAPIOC (('m' << 24) | ('r' << 16) | ('f' << 8)) +#define FASTTRAPIOC_MAKEPROBE (FASTTRAPIOC | 1) +#define FASTTRAPIOC_GETINSTR (FASTTRAPIOC | 2) + +typedef enum fasttrap_probe_type { + DTFTP_NONE = 0, + DTFTP_ENTRY, + DTFTP_RETURN, + DTFTP_OFFSETS, + DTFTP_POST_OFFSETS, + DTFTP_IS_ENABLED +} fasttrap_probe_type_t; + +typedef struct fasttrap_probe_spec { + pid_t ftps_pid; + fasttrap_probe_type_t ftps_type; + + char ftps_func[DTRACE_FUNCNAMELEN]; + char ftps_mod[DTRACE_MODNAMELEN]; + + uint64_t ftps_pc; + uint64_t ftps_size; + uint64_t ftps_noffs; + uint64_t ftps_offs[1]; +} fasttrap_probe_spec_t; + +typedef struct fasttrap_instr_query { + uint64_t ftiq_pc; + pid_t ftiq_pid; + fasttrap_instr_t ftiq_instr; +} fasttrap_instr_query_t; + +/* + * To support the fasttrap provider from very early in a process's life, + * the run-time linker, ld.so.1, has a program header of type PT_SUNWDTRACE + * which points to a data object which must be PT_SUNWDTRACE_SIZE bytes. + * This structure mimics the fasttrap provider section of the ulwp_t structure. + * When the fasttrap provider is changed to require new or different + * instructions, the data object in ld.so.1 and the thread initializers in libc + * (libc_init() and _thrp_create()) need to be updated to include the new + * instructions, and PT_SUNWDTRACE needs to be changed to a new unique number + * (while the old value gets assigned something like PT_SUNWDTRACE_1). Since the + * linker must be backward compatible with old Solaris releases, it must have + * program headers for each of the PT_SUNWDTRACE versions. The kernel's + * elfexec() function only has to look for the latest version of the + * PT_SUNWDTRACE program header. + */ +#define PT_SUNWDTRACE_SIZE FASTTRAP_SUNWDTRACE_SIZE + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FASTTRAP_H */ diff --git a/illumos-x86_64/usr/include/sys/fasttrap_impl.h b/illumos-x86_64/usr/include/sys/fasttrap_impl.h new file mode 100644 index 00000000..6c44897e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fasttrap_impl.h @@ -0,0 +1,190 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FASTTRAP_IMPL_H +#define _FASTTRAP_IMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fasttrap Providers, Probes and Tracepoints + * + * Each Solaris process can have multiple providers -- the pid provider as + * well as any number of user-level statically defined tracing (USDT) + * providers. Those providers are each represented by a fasttrap_provider_t. + * All providers for a given process have a pointer to a shared + * fasttrap_proc_t. The fasttrap_proc_t has two states: active or defunct. + * When the count of active providers goes to zero it becomes defunct; a + * provider drops its active count when it is removed individually or as part + * of a mass removal when a process exits or performs an exec. + * + * Each probe is represented by a fasttrap_probe_t which has a pointer to + * its associated provider as well as a list of fasttrap_id_tp_t structures + * which are tuples combining a fasttrap_id_t and a fasttrap_tracepoint_t. + * A fasttrap_tracepoint_t represents the actual point of instrumentation + * and it contains two lists of fasttrap_id_t structures (to be fired pre- + * and post-instruction emulation) that identify the probes attached to the + * tracepoint. Tracepoints also have a pointer to the fasttrap_proc_t for the + * process they trace which is used when looking up a tracepoint both when a + * probe fires and when enabling and disabling probes. + * + * It's important to note that probes are preallocated with the necessary + * number of tracepoints, but that tracepoints can be shared by probes and + * swapped between probes. If a probe's preallocated tracepoint is enabled + * (and, therefore, the associated probe is enabled), and that probe is + * then disabled, ownership of that tracepoint may be exchanged for an + * unused tracepoint belonging to another probe that was attached to the + * enabled tracepoint. + */ + +typedef struct fasttrap_proc { + pid_t ftpc_pid; /* process ID for this proc */ + uint64_t ftpc_acount; /* count of active providers */ + uint64_t ftpc_rcount; /* count of extant providers */ + kmutex_t ftpc_mtx; /* lock on all but acount */ + struct fasttrap_proc *ftpc_next; /* next proc in hash chain */ +} fasttrap_proc_t; + +typedef struct fasttrap_provider { + pid_t ftp_pid; /* process ID for this prov */ + char ftp_name[DTRACE_PROVNAMELEN]; /* prov name (w/o the pid) */ + dtrace_provider_id_t ftp_provid; /* DTrace provider handle */ + uint_t ftp_marked; /* mark for possible removal */ + uint_t ftp_retired; /* mark when retired */ + kmutex_t ftp_mtx; /* provider lock */ + kmutex_t ftp_cmtx; /* lock on creating probes */ + uint64_t ftp_rcount; /* enabled probes ref count */ + uint64_t ftp_ccount; /* consumers creating probes */ + uint64_t ftp_mcount; /* meta provider count */ + fasttrap_proc_t *ftp_proc; /* shared proc for all provs */ + struct fasttrap_provider *ftp_next; /* next prov in hash chain */ +} fasttrap_provider_t; + +typedef struct fasttrap_id fasttrap_id_t; +typedef struct fasttrap_probe fasttrap_probe_t; +typedef struct fasttrap_tracepoint fasttrap_tracepoint_t; + +struct fasttrap_id { + fasttrap_probe_t *fti_probe; /* referrring probe */ + fasttrap_id_t *fti_next; /* enabled probe list on tp */ + fasttrap_probe_type_t fti_ptype; /* probe type */ +}; + +typedef struct fasttrap_id_tp { + fasttrap_id_t fit_id; + fasttrap_tracepoint_t *fit_tp; +} fasttrap_id_tp_t; + +struct fasttrap_probe { + dtrace_id_t ftp_id; /* DTrace probe identifier */ + pid_t ftp_pid; /* pid for this probe */ + fasttrap_provider_t *ftp_prov; /* this probe's provider */ + uintptr_t ftp_faddr; /* associated function's addr */ + size_t ftp_fsize; /* associated function's size */ + uint64_t ftp_gen; /* modification generation */ + uint64_t ftp_ntps; /* number of tracepoints */ + uint8_t *ftp_argmap; /* native to translated args */ + uint8_t ftp_nargs; /* translated argument count */ + uint8_t ftp_enabled; /* is this probe enabled */ + char *ftp_xtypes; /* translated types index */ + char *ftp_ntypes; /* native types index */ + fasttrap_id_tp_t ftp_tps[1]; /* flexible array */ +}; + +#define FASTTRAP_ID_INDEX(id) \ +((fasttrap_id_tp_t *)(((char *)(id) - offsetof(fasttrap_id_tp_t, fit_id))) - \ +&(id)->fti_probe->ftp_tps[0]) + +struct fasttrap_tracepoint { + fasttrap_proc_t *ftt_proc; /* associated process struct */ + uintptr_t ftt_pc; /* address of tracepoint */ + pid_t ftt_pid; /* pid of tracepoint */ + fasttrap_machtp_t ftt_mtp; /* ISA-specific portion */ + fasttrap_id_t *ftt_ids; /* NULL-terminated list */ + fasttrap_id_t *ftt_retids; /* NULL-terminated list */ + fasttrap_tracepoint_t *ftt_next; /* link in global hash */ +}; + +typedef struct fasttrap_bucket { + kmutex_t ftb_mtx; /* bucket lock */ + void *ftb_data; /* data payload */ + + uint8_t ftb_pad[64 - sizeof (kmutex_t) - sizeof (void *)]; +} fasttrap_bucket_t; + +typedef struct fasttrap_hash { + ulong_t fth_nent; /* power-of-2 num. of entries */ + ulong_t fth_mask; /* fth_nent - 1 */ + fasttrap_bucket_t *fth_table; /* array of buckets */ +} fasttrap_hash_t; + +/* + * If at some future point these assembly functions become observable by + * DTrace, then these defines should become separate functions so that the + * fasttrap provider doesn't trigger probes during internal operations. + */ +#define fasttrap_copyout copyout +#define fasttrap_fuword32 fuword32 +#define fasttrap_suword32 suword32 + +#define fasttrap_fulword fulword +#define fasttrap_sulword sulword + +extern void fasttrap_sigtrap(proc_t *, kthread_t *, uintptr_t); + +extern dtrace_id_t fasttrap_probe_id; +extern fasttrap_hash_t fasttrap_tpoints; + +#define FASTTRAP_TPOINTS_INDEX(pid, pc) \ + (((pc) / sizeof (fasttrap_instr_t) + (pid)) & fasttrap_tpoints.fth_mask) + +/* + * Must be implemented by fasttrap_isa.c + */ +extern int fasttrap_tracepoint_init(proc_t *, fasttrap_tracepoint_t *, + uintptr_t, fasttrap_probe_type_t); +extern int fasttrap_tracepoint_install(proc_t *, fasttrap_tracepoint_t *); +extern int fasttrap_tracepoint_remove(proc_t *, fasttrap_tracepoint_t *); + +extern int fasttrap_pid_probe(struct regs *); +extern int fasttrap_return_probe(struct regs *); + +extern uint64_t fasttrap_pid_getarg(void *, dtrace_id_t, void *, int, int); +extern uint64_t fasttrap_usdt_getarg(void *, dtrace_id_t, void *, int, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _FASTTRAP_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/fasttrap_isa.h b/illumos-x86_64/usr/include/sys/fasttrap_isa.h new file mode 100644 index 00000000..ea9526c6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fasttrap_isa.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FASTTRAP_ISA_H +#define _FASTTRAP_ISA_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define FASTTRAP_MAX_INSTR_SIZE 15 + +#define FASTTRAP_INSTR 0xcc + +#define FASTTRAP_SUNWDTRACE_SIZE 64 + +typedef uint8_t fasttrap_instr_t; + +typedef struct fasttrap_machtp { + uint8_t ftmt_instr[FASTTRAP_MAX_INSTR_SIZE]; /* orig. instr. */ + uint8_t ftmt_size; /* instruction size */ +#ifdef __amd64 + uint8_t ftmt_ripmode; /* %rip-relative handling mode */ + uint8_t ftmt_modrm; /* saved modrm byte */ +#endif + uint8_t ftmt_type; /* emulation type */ + uint8_t ftmt_code; /* branch condition */ + uint8_t ftmt_base; /* branch base */ + uint8_t ftmt_index; /* branch index */ + uint8_t ftmt_scale; /* branch scale */ + uint8_t ftmt_segment; /* segment for memory accesses */ + uintptr_t ftmt_dest; /* destination of control flow */ +} fasttrap_machtp_t; + +#define ftt_instr ftt_mtp.ftmt_instr +#ifdef __amd64 +#define ftt_ripmode ftt_mtp.ftmt_ripmode +#define ftt_modrm ftt_mtp.ftmt_modrm +#endif +#define ftt_size ftt_mtp.ftmt_size +#define ftt_type ftt_mtp.ftmt_type +#define ftt_code ftt_mtp.ftmt_code +#define ftt_base ftt_mtp.ftmt_base +#define ftt_index ftt_mtp.ftmt_index +#define ftt_scale ftt_mtp.ftmt_scale +#define ftt_segment ftt_mtp.ftmt_segment +#define ftt_dest ftt_mtp.ftmt_dest + +#define FASTTRAP_T_COMMON 0x00 /* common case -- no emulation */ +#define FASTTRAP_T_JCC 0x01 /* near and far conditional jumps */ +#define FASTTRAP_T_LOOP 0x02 /* loop instructions */ +#define FASTTRAP_T_JCXZ 0x03 /* jump if %ecx/%rcx is zero */ +#define FASTTRAP_T_JMP 0x04 /* relative jump */ +#define FASTTRAP_T_CALL 0x05 /* near call (and link) */ +#define FASTTRAP_T_RET 0x06 /* ret */ +#define FASTTRAP_T_RET16 0x07 /* ret */ + +/* + * For performance rather than correctness. + */ +#define FASTTRAP_T_PUSHL_EBP 0x10 /* pushl %ebp (for function entry) */ +#define FASTTRAP_T_NOP 0x11 /* nop */ + +#define FASTTRAP_RIP_1 0x1 +#define FASTTRAP_RIP_2 0x2 +#define FASTTRAP_RIP_X 0x4 + +/* + * Segment values. + */ +#define FASTTRAP_SEG_NONE 0 +#define FASTTRAP_SEG_CS 1 +#define FASTTRAP_SEG_DS 2 +#define FASTTRAP_SEG_ES 3 +#define FASTTRAP_SEG_FS 4 +#define FASTTRAP_SEG_GS 5 +#define FASTTRAP_SEG_SS 6 + +#define FASTTRAP_AFRAMES 3 +#define FASTTRAP_RETURN_AFRAMES 4 +#define FASTTRAP_ENTRY_AFRAMES 3 +#define FASTTRAP_OFFSET_AFRAMES 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _FASTTRAP_ISA_H */ diff --git a/illumos-x86_64/usr/include/sys/fault.h b/illumos-x86_64/usr/include/sys/fault.h new file mode 100644 index 00000000..139216b5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fault.h @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_FAULT_H +#define _SYS_FAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fault numbers, analagous to signals. These correspond to + * hardware faults. Setting the appropriate flags in a process's + * set of traced faults via /proc causes the process to stop each + * time one of the designated faults occurs so that a debugger can + * take action. See proc(5) for details. + */ + + /* fault enumeration must begin with 1 */ +#define FLTILL 1 /* Illegal instruction */ +#define FLTPRIV 2 /* Privileged instruction */ +#define FLTBPT 3 /* Breakpoint instruction */ +#define FLTTRACE 4 /* Trace trap (single-step) */ +#define FLTACCESS 5 /* Memory access (e.g., alignment) */ +#define FLTBOUNDS 6 /* Memory bounds (invalid address) */ +#define FLTIOVF 7 /* Integer overflow */ +#define FLTIZDIV 8 /* Integer zero divide */ +#define FLTFPE 9 /* Floating-point exception */ +#define FLTSTACK 10 /* Irrecoverable stack fault */ +#define FLTPAGE 11 /* Recoverable page fault (no associated sig) */ +#define FLTWATCH 12 /* Watchpoint trap */ +#define FLTCPCOVF 13 /* CPU performance counter overflow */ + +typedef struct { /* fault set type */ + unsigned int word[4]; +} fltset_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FAULT_H */ diff --git a/illumos-x86_64/usr/include/sys/fbio.h b/illumos-x86_64/usr/include/sys/fbio.h new file mode 100644 index 00000000..11debf4c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fbio.h @@ -0,0 +1,467 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1986,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FBIO_H +#define _SYS_FBIO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ASM +/* + * Frame buffer descriptor. + * Returned by FBIOGTYPE ioctl on frame buffer devices. + */ +struct fbtype { + int fb_type; /* as defined below */ + int fb_height; /* in pixels */ + int fb_width; /* in pixels */ + int fb_depth; /* bits per pixel */ + int fb_cmsize; /* size of color map (entries) */ + int fb_size; /* total size in bytes */ +}; + +#define FIOC ('F'<<8) +#define FBIOGTYPE (FIOC|0) + +#ifdef _KERNEL +struct fbpixrect { + struct pixrect *fbpr_pixrect; /* Pixrect of dev returned here */ +}; + +#define FBIOGPIXRECT (FIOC|1) +#endif /* _KERNEL */ + +/* + * General purpose structure for passing info in and out of frame buffers + * (used for gp1) + */ +struct fbinfo { + int fb_physaddr; /* physical frame buffer address */ + int fb_hwwidth; /* fb board width */ + int fb_hwheight; /* fb board height */ + int fb_addrdelta; /* phys addr diff between boards */ + unsigned char *fb_ropaddr; /* fb va thru kernelmap */ + int fb_unit; /* minor devnum of fb */ +}; + +#define FBIOGINFO (FIOC|2) + +/* + * Color map I/O. See also fbcmap_i below. + */ +struct fbcmap { + int index; /* first element (0 origin) */ + int count; /* number of elements */ + unsigned char *red; /* red color map elements */ + unsigned char *green; /* green color map elements */ + unsigned char *blue; /* blue color map elements */ +}; + +#ifdef _SYSCALL32 + +struct fbcmap32 { + int32_t index; /* first element (0 origin) */ + int32_t count; /* number of elements */ + caddr32_t red; /* red color map elements */ + caddr32_t green; /* green color map elements */ + caddr32_t blue; /* blue color map elements */ +}; + +#endif /* _SYSCALL32 */ + +#define FBIOPUTCMAP (FIOC|3) +#define FBIOGETCMAP (FIOC|4) + +/* + * Set/Get attributes + */ +#define FB_ATTR_NDEVSPECIFIC 8 /* no. of device specific values */ +#define FB_ATTR_NEMUTYPES 4 /* no. of emulation types */ + +struct fbsattr { + int flags; /* misc flags */ +#define FB_ATTR_AUTOINIT 1 /* emulation auto init flag */ +#define FB_ATTR_DEVSPECIFIC 2 /* dev. specific stuff valid flag */ + int emu_type; /* emulation type (-1 if unused) */ + int dev_specific[FB_ATTR_NDEVSPECIFIC]; /* catchall */ +}; + +struct fbgattr { + int real_type; /* real device type */ + int owner; /* PID of owner, 0 if myself */ + struct fbtype fbtype; /* fbtype info for real device */ + struct fbsattr sattr; /* see above */ + int emu_types[FB_ATTR_NEMUTYPES]; /* possible emulations */ + /* (-1 if unused) */ +}; + +#define FBIOSATTR (FIOC|5) +#define FBIOGATTR (FIOC|6) + + +/* + * Video control + * (the unused bits are reserved for future use) + */ +#define FBVIDEO_OFF 0 +#define FBVIDEO_ON 1 + +#define FBIOSVIDEO (FIOC|7) +#define FBIOGVIDEO (FIOC|8) + +/* Vertical retrace support. */ +#define FBIOVERTICAL (FIOC|9) +#define GRABPAGEALLOC (FIOC|10) +#define GRABPAGEFREE (FIOC|11) +#define GRABATTACH (FIOC|12) + +#define FBIOGPLNGRP (FIOC|13) +#define FBIOGCMSIZE (FIOC|14) +#define FBIOSCMSIZE (FIOC|15) +#define FBIOSCMS (FIOC|16) +#define FBIOAVAILPLNGRP (FIOC|17) + + +/* + * Structure to pass double buffering state back and forth the device. + */ + +/* used in devstate */ +#define FBDBL_AVAIL 0x80000000 +#define FBDBL_DONT_BLOCK 0x40000000 +#define FBDBL_AVAIL_PG 0x20000000 + +/* used in read/write/display */ +#define FBDBL_A 0x1 +#define FBDBL_B 0x2 +#define FBDBL_BOTH (FBDBL_A | FBDBL_B) +#define FBDBL_NONE 0x4 + +struct fbdblinfo { + unsigned int dbl_devstate; + unsigned int dbl_read; + unsigned int dbl_write; + unsigned int dbl_display; + int dbl_depth; + char dbl_wid; +}; + +#define FBIODBLGINFO (FIOC|18) +#define FBIODBLSINFO (FIOC|19) + +/* 8-bit emulation in 24-bit ioctls */ + +#define FBIOSWINFD (FIOC|20) +#define FBIOSAVWINFD (FIOC|21) +#define FBIORESWINFD (FIOC|22) +#define FBIOSRWINFD (FIOC|23) + +/* + * hardware cursor control + */ + +struct fbcurpos { + short x, y; +}; + +struct fbcursor { + short set; /* what to set */ +#define FB_CUR_SETCUR 0x01 +#define FB_CUR_SETPOS 0x02 +#define FB_CUR_SETHOT 0x04 +#define FB_CUR_SETCMAP 0x08 +#define FB_CUR_SETSHAPE 0x10 +#define FB_CUR_SETALL 0x1F + short enable; /* cursor on/off */ + struct fbcurpos pos; /* cursor position */ + struct fbcurpos hot; /* cursor hot spot */ + struct fbcmap cmap; /* color map info */ + struct fbcurpos size; /* cursor bit map size */ + char *image; /* cursor image bits */ + char *mask; /* cursor mask bits */ +}; + +#ifdef _SYSCALL32 +struct fbcursor32 { + short set; /* what to set */ + short enable; /* cursor on/off */ + struct fbcurpos pos; /* cursor position */ + struct fbcurpos hot; /* cursor hot spot */ + struct fbcmap32 cmap; /* color map info */ + struct fbcurpos size; /* cursor bit map size */ + caddr32_t image; /* cursor image bits */ + caddr32_t mask; /* cursor mask bits */ +}; +#endif /* _SYSCALL32 */ + +/* set/get cursor attributes/shape */ +#define FBIOSCURSOR (FIOC|24) +#define FBIOGCURSOR (FIOC|25) + +/* set/get cursor position */ +#define FBIOSCURPOS (FIOC|26) +#define FBIOGCURPOS (FIOC|27) + +/* get max cursor size */ +#define FBIOGCURMAX (FIOC|28) + +/* Window Grabber info ioctl */ +#define GRABLOCKINFO (FIOC|29) + +/* + * Window Identification (wid) defines, structures, and ioctls. + * + * Some wids need to be unique when used for things such as double + * buffering or rendering clipping. Some wids can be shared when + * used for display attributes only. What can be shared and how + * may be device dependent. The fb_wid_alloc.wa_type and fb_wid_item + * structure members will be left to device specific interpretation. + */ + +#define FB_WID_SHARED_8 0 +#define FB_WID_SHARED_24 1 +#define FB_WID_DBL_8 2 +#define FB_WID_DBL_24 3 + +struct fb_wid_alloc { + unsigned int wa_type; /* special attributes */ + int wa_index; /* base wid returned */ + unsigned int wa_count; /* how many contiguous wids */ +}; + +struct fb_wid_item { + unsigned int wi_type; /* special attributes */ + int wi_index; /* which lut */ + unsigned int wi_attrs; /* which attributes */ + unsigned int wi_values[NBBY*sizeof (int)]; /* the attr values */ +}; + +struct fb_wid_list { + unsigned int wl_flags; + unsigned int wl_count; + struct fb_wid_item *wl_list; +}; + +#ifdef _SYSCALL32 + +struct fb_wid_list32 { + uint32_t wl_flags; + uint32_t wl_count; + caddr32_t wl_list; +}; + +#endif /* _SYSCALL32 */ + +struct fb_wid_dbl_info { + struct fb_wid_alloc dbl_wid; + char dbl_fore; + char dbl_back; + char dbl_read_state; + char dbl_write_state; +}; + +#define FBIO_WID_ALLOC (FIOC|30) +#define FBIO_WID_FREE (FIOC|31) +#define FBIO_WID_PUT (FIOC|32) +#define FBIO_WID_GET (FIOC|33) + +#define FBIO_DEVID (FIOC|34) +#define FBIO_U_RST (FIOC|35) +#define FBIO_FULLSCREEN_ELIMINATION_GROUPS (FIOC|36) +#define FBIO_WID_DBL_SET (FIOC|37) +#define FBIOVRTOFFSET (FIOC|38) + +struct gfxfb_info { + uint16_t terminal_origin_x; + uint16_t terminal_origin_y; + uint32_t pitch; + uint16_t font_width; + uint16_t font_height; + uint8_t red_mask_size; + uint8_t red_field_position; + uint8_t green_mask_size; + uint8_t green_field_position; + uint8_t blue_mask_size; + uint8_t blue_field_position; +}; + +struct cg6_info { + ushort_t accessible_width; /* accessible bytes in scanline */ + ushort_t accessible_height; /* number of accessible scanlines */ + ushort_t line_bytes; /* number of bytes/scanline */ + ushort_t hdb_capable; /* can this thing hardware db? */ + ushort_t vmsize; /* this is Mb of video memory */ + uchar_t boardrev; /* board revision # */ + uchar_t slot; /* sbus slot # */ + uint_t pad1; /* expansion */ +}; + +struct s3_info { + ushort_t accessible_width; /* accessible bytes in scanline */ + ushort_t accessible_height; /* number of accessible scanlines */ + ushort_t line_bytes; /* number of bytes/scanline */ + ushort_t hdb_capable; /* can this thing hardware db? */ + ushort_t vmsize; /* this is Mb of video memory */ + uchar_t boardrev; /* board revision # */ + uchar_t slot; /* sbus slot # */ + uint_t pad1; /* expansion */ +}; + +struct p9000_info { + ushort_t accessible_width; /* accessible bytes in scanline */ + ushort_t accessible_height; /* number of accessible scanlines */ + ushort_t line_bytes; /* number of bytes/scanline */ + ushort_t hdb_capable; /* can this thing hardware db? */ + ushort_t vmsize; /* this is Mb of video memory */ + uchar_t boardrev; /* board revision # */ + uchar_t slot; /* sbus slot # */ + uint_t pad1; /* expansion */ +}; + +struct p9100_info { + ushort_t accessible_width; /* accessible bytes in scanline */ + ushort_t accessible_height; /* number of accessible scanlines */ + ushort_t line_bytes; /* number of bytes/scanline */ + ushort_t hdb_capable; /* can this thing hardware db? */ + ushort_t vmsize; /* this is Mb of video memory */ + uchar_t boardrev; /* board revision # */ + uchar_t slot; /* sbus slot # */ + uint_t pad1; /* expansion */ +}; + +struct wd90c24a2_info { + ushort_t accessible_width; /* accessible bytes in scanline */ + ushort_t accessible_height; /* number of accessible scanlines */ + ushort_t line_bytes; /* number of bytes/scanline */ + ushort_t hdb_capable; /* can this thing hardware db? */ + ushort_t vmsize; /* this is Mb of video memory */ + uchar_t boardrev; /* board revision # */ + uchar_t slot; /* sbus slot # */ + uint_t pad1; /* expansion */ +}; + +#define MON_TYPE_STEREO 0x8 /* stereo display */ +#define MON_TYPE_0_OFFSET 0x4 /* black level 0 ire instead of 7.5 */ +#define MON_TYPE_OVERSCAN 0x2 /* overscan */ +#define MON_TYPE_GRAY 0x1 /* greyscale monitor */ + +struct mon_info { + uint_t mon_type; /* bit array: defined above */ + uint_t pixfreq; /* pixel frequency in Hz */ + uint_t hfreq; /* horizontal freq in Hz */ + uint_t vfreq; /* vertical freq in Hz */ + uint_t vsync; /* vertical sync in scanlines */ + uint_t hsync; /* horizontal sync in pixels */ + /* these are in pixel units */ + ushort_t hfporch; /* horizontal front porch */ + ushort_t hbporch; /* horizontal back porch */ + ushort_t vfporch; /* vertical front porch */ + ushort_t vbporch; /* vertical back porch */ +}; + + +#define FBIOGXINFO (FIOC|39) +#define FBIOMONINFO (FIOC|40) + +/* + * Color map I/O. + */ +struct fbcmap_i { + unsigned int flags; /* see below */ + int id; /* colormap id for multiple cmaps */ + int index; /* first element (0 origin) */ + int count; /* number of elements */ + unsigned char *red; /* red color map elements */ + unsigned char *green; /* green color map elements */ + unsigned char *blue; /* blue color map elements */ +}; + +#ifdef _SYSCALL32 + +struct fbcmap_i32 { + uint32_t flags; /* see below */ + int32_t id; /* colormap id for multiple cmaps */ + int32_t index; /* first element (0 origin) */ + int32_t count; /* number of elements */ + caddr32_t red; /* red color map elements */ + caddr32_t green; /* green color map elements */ + caddr32_t blue; /* blue color map elements */ +}; + +#endif /* _SYSCALL32 */ + +#define FB_CMAP_BLOCK 0x1 /* wait for vrt before returning */ +#define FB_CMAP_KERNEL 0x2 /* called within kernel */ + +#define FBIOPUTCMAPI (FIOC|41) +#define FBIOGETCMAPI (FIOC|42) + +/* assigning a given window id to a pixrect - special for PHIGS */ +#define FBIO_ASSIGNWID (FIOC|43) + +/* assigning a given window to be stereo */ +#define FBIO_STEREO (FIOC|44) +#define FB_WIN_STEREO 0x2 + +#endif /* !ASM */ + +/* frame buffer type codes */ +#define FBTYPE_NOTYPE (-1) /* for backwards compatibility */ +#define FBTYPE_SUN1BW 0 /* Multibus mono */ +#define FBTYPE_SUN1COLOR 1 /* Multibus color */ +#define FBTYPE_SUN2BW 2 /* memory mono */ +#define FBTYPE_SUN2COLOR 3 /* color w/rasterop chips */ +#define FBTYPE_SUN2GP 4 /* GP1/GP2 */ +#define FBTYPE_SUN5COLOR 5 /* RoadRunner accelerator */ +#define FBTYPE_SUN3COLOR 6 /* memory color */ +#define FBTYPE_MEMCOLOR 7 /* memory 24-bit */ +#define FBTYPE_SUN4COLOR 8 /* memory color w/overlay */ + +#define FBTYPE_NOTSUN1 9 /* reserved for customer */ +#define FBTYPE_NOTSUN2 10 /* reserved for customer */ +#define FBTYPE_NOTSUN3 11 /* reserved for customer */ + +#define FBTYPE_SUNFAST_COLOR 12 /* accelerated 8bit */ +#define FBTYPE_SUNROP_COLOR 13 /* MEMCOLOR with rop h/w */ +#define FBTYPE_SUNFB_VIDEO 14 /* Simple video mixing */ +#define FBTYPE_SUNGIFB 15 /* medical image */ +#define FBTYPE_SUNGPLAS 16 /* plasma panel */ +#define FBTYPE_SUNGP3 17 /* cg12 running gpsi microcode */ +#define FBTYPE_SUNGT 18 /* gt graphics accelerator */ +#define FBTYPE_SUNLEO 19 /* zx graphics accelerator */ +#define FBTYPE_MDICOLOR 20 /* cgfourteen framebuffer */ + +#define FBTYPE_LASTPLUSONE 21 /* max number of fbs (change as add) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FBIO_H */ diff --git a/illumos-x86_64/usr/include/sys/fbuf.h b/illumos-x86_64/usr/include/sys/fbuf.h new file mode 100644 index 00000000..3446337b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fbuf.h @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_FBUF_H +#define _SYS_FBUF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A struct fbuf is used to get a mapping to part of a file using the + * segkmap facilities. After you get a mapping, you can fbrelse() it + * (giving a seg code to pass back to segmap_release), you can fbwrite() + * it (causes a synchronous write back using the file mapping information), + * or you can fbiwrite it (causing indirect synchronous write back to + * the block number given without using the file mapping information). + */ + +struct fbuf { + caddr_t fb_addr; + uint_t fb_count; +}; + +extern int fbread(struct vnode *, offset_t, uint_t, enum seg_rw, + struct fbuf **); +extern void fbzero(struct vnode *, offset_t, uint_t, struct fbuf **); +extern int fbwrite(struct fbuf *); +extern int fbdwrite(struct fbuf *); +extern int fbiwrite(struct fbuf *, struct vnode *, daddr_t bn, int bsize); +extern void fbrelse(struct fbuf *, enum seg_rw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FBUF_H */ diff --git a/illumos-x86_64/usr/include/sys/fc4/fc.h b/illumos-x86_64/usr/include/sys/fc4/fc.h new file mode 100644 index 00000000..0802462e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fc4/fc.h @@ -0,0 +1,303 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FC4_FC_H +#define _SYS_FC4_FC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fibre Channel Physical and Signaling Interface (FC-PH) definitions. + * + * NOTE: modifications of this file affect drivers, mpsas models, PLUTO + * firmware, SOC assembly code. Please be communicative. + */ + +#define FC_PH_VERSION 0x06 /* 0x06 means 4.0 ! */ +#define MAX_FRAME_SIZE 2112 /* maximum size of frame payload */ + +/* + * This is the standard frame header for FC-PH frames. + */ + +typedef struct FC2_FRAME_HDR { + uint_t r_ctl:8, d_id:24; + uint_t reserved1:8, s_id:24; + uint_t type:8, f_ctl:24; + uint_t seq_id:8, df_ctl:8, seq_cnt:16; + ushort_t ox_id, rx_id; + uint_t ro; +}aFC2_FRAME_HDR, *FC2_FRAME_HDRptr, fc_frame_header_t; + +#define WE_ARE_ORIGINATOR(fh) (fh->f_ctl & F_CTL_XCHG_CONTEXT) +#define UNSOLICITED_FRAME(fh) (fh->rx_id == 0xffff) +#define FIRST_SEQUENCE(fh) (fh->f_ctl & F_CTL_FIRST_SEQ) +#define LAST_FRAME_OF_SEQUENCE(fh) (fh->f_ctl & F_CTL_END_SEQ) +#define LAST_SEQUENCE_OF_EXCHANGE(fh) (fh->f_ctl & F_CTL_LAST_SEQ) +#define TRANSFER_INITIATIVE(fh) (fh->f_ctl & F_CTL_SEQ_INITIATIVE) + + +/* legal values for r_ctl */ +#define R_CTL_ROUTING 0xf0 /* mask for routing bits */ +#define R_CTL_INFO 0x0f /* mask for information bits */ + +#define R_CTL_DEVICE_DATA 0x00 /* all I/O related frames */ +#define R_CTL_EXTENDED_SVC 0x20 /* extended link services (PLOGI) */ +#define R_CTL_FC4_SVC 0x30 /* FC-4 link services (FCP_LOGI) */ +#define R_CTL_VIDEO_BUFF 0x40 /* not yet defined */ +#define R_CTL_BASIC_SVC 0x80 /* basic link services (NOP) */ +#define R_CTL_LINK_CTL 0xc0 /* ACKs, etc. */ + +/* legal values for r_ctl: Device Data */ +#define R_CTL_UNCATEGORIZED 0x00 +#define R_CTL_SOLICITED_DATA 0x01 +#define R_CTL_UNSOL_CONTROL 0x02 +#define R_CTL_SOLICITED_CONTROL 0x03 +#define R_CTL_UNSOL_DATA 0x04 +#define R_CTL_XFER_RDY 0x05 +#define R_CTL_COMMAND 0x06 +#define R_CTL_STATUS 0x07 + +/* legal values for r_ctl: Basic Link Services, type 0 */ +#define R_CTL_LS_NOP 0x80 +#define R_CTL_LS_ABTS 0x81 +#define R_CTL_LS_RMC 0x82 +#define R_CTL_LS_BA_ACC 0x84 +#define R_CTL_LS_BA_RJT 0x85 + +/* legal values for r_ctl: Extended Link Services, type 1 */ +#define R_CTL_ELS_REQ 0x22 +#define R_CTL_ELS_RSP 0x23 + +/* Extended Link Service command codes, type 1 */ +#define LS_RJT 0x01000000 +#define LS_ACC 0x02000000 +#define LS_PLOGI 0x03000000 +#define LS_FLOGI 0x04000000 +#define LS_LOGO 0x05000000 +#define LS_ABTX 0x06000000 +#define LS_RCS 0x07000000 +#define LS_RES 0x08000000 +#define LS_RSS 0x09000000 +#define LS_RSI 0x0a000000 +#define LS_ESTS 0x0b000000 +#define LS_ESTC 0x0c000000 +#define LS_ADVC 0x0d000000 +#define LS_RTV 0x0e000000 +#define LS_RLS 0x0f000000 +#define LS_ECHO 0x10000000 +#define LS_TEST 0x11000000 +#define LS_RRQ 0x12000000 +#define LS_IDENT 0x20000000 /* vendor unique */ +#define LS_DISPLAY 0x21000000 /* vendor unique */ + +/* legal values for r_ctl: Link Control */ +#define R_CTL_ACK_1 0xc0 +#define R_CTL_ACK_N 0xc1 +#define R_CTL_P_RJT 0xc2 +#define R_CTL_F_RJT 0xc3 +#define R_CTL_P_BSY 0xc4 +#define R_CTL_F_BSY_DF 0xc5 +#define R_CTL_F_BSY_LC 0xc6 +#define R_CTL_LCR 0xc7 + +/* type field definitions for Link Data frames: */ +#define TYPE_BASIC_LS 0x00 +#define TYPE_EXTENDED_LS 0x01 + +/* type field definitions for Device Data frames (from FC-PH 4.1): */ +#define TYPE_IS8802 0x04 +#define TYPE_IS8802_SNAP 0x05 +#define TYPE_SCSI_FCP 0x08 /* we use this one */ +#define TYPE_SCSI_GPP 0x09 +#define TYPE_HIPP_FP 0x0a +#define TYPE_IPI3_MASTER 0x11 +#define TYPE_IPI3_SLAVE 0x12 +#define TYPE_IPI3_PEER 0x13 + +#define F_CTL_XCHG_CONTEXT 0x800000 /* 0 if SID is XCHG originator */ +#define F_CTL_SEQ_CONTEXT 0x400000 /* 0 if SID is SEQ initiator */ +#define F_CTL_FIRST_SEQ 0x200000 /* 1 if first sequence of XCHG */ +#define F_CTL_LAST_SEQ 0x100000 /* 1 if last SEQ of XCHG */ +#define F_CTL_END_SEQ 0x080000 /* 1 if last frame of a SEQ */ +#define F_CTL_END_CONNECT 0x040000 /* always 0 */ +#define F_CTL_CHAINED_SEQ 0x020000 /* always 0 */ +#define F_CTL_SEQ_INITIATIVE 0x010000 /* when 1 xfrs SEQ initiative */ +#define F_CTL_XID_REASSIGNED 0x008000 /* always 0 */ +#define F_CTL_INVALIDATE_XID 0x004000 /* always 0 */ +#define F_CTL_CONTINUE_SEQ 0x0000C0 /* always 0 */ +#define F_CTL_ABORT_SEQ 0x000030 /* always 0 */ +#define F_CTL_RO_PRESENT 0x000008 /* 1 if param field == RO */ +#define F_CTL_XCHG_REASSEMBLE 0x000004 /* always 0 */ +#define F_CTL_FILL_BYTES 0x000003 /* # of fill bytes in this frame */ +#define F_CTL_RESERVED 0x003F00 +#define F_CTL_ALWAYS_ZERO (F_CTL_RESERVED | F_CTL_XCHG_REASSEMBLE | \ + F_CTL_ABORT_SEQ | F_CTL_CONTINUE_SEQ| F_CTL_INVALIDATE_XID | \ + F_CTL_XID_REASSIGNED | F_CTL_CHAINED_SEQ | F_CTL_END_CONNECT) + +/* Well known addresses ... */ +#define FS_GENERAL_MULTICAST 0xfffff7 +#define FS_WELL_KNOWN_MULTICAST 0xfffff8 +#define FS_HUNT_GROUP 0xfffff9 +#define FS_MANAGEMENT_SERVER 0xfffffa +#define FS_TIME_SERVER 0xfffffb +#define FS_NAME_SERVER 0xfffffc +#define FS_FABRIC_CONTROLLER 0xfffffd +#define FS_FABRIC_F_PORT 0xfffffe +#define FS_BROADCAST 0xffffff + +/* Fabric Busy Reason Codes */ +#define FABRIC_BUSY 0x01 +#define NPORT_BUSY 0x03 + +/* NPort Busy Reason Codes */ +#define PHYSICAL_BUSY 0x01 +#define RESOURSE_BUSY 0x03 + +/* Reject Reason Codes */ + +typedef struct FC2_RJT_PARAM { + uchar_t rjt_action; + uchar_t rjt_reason; + uchar_t reserved[2]; +} aFC2_RJT_PARAM; + +#define INVALID_D_ID 0x01 +#define INVALID_S_ID 0x02 +#define NPORT_NOT_AVAIL_TEMP 0x03 +#define NPORT_NOT_AVAIL_PERM 0x04 +#define CLASS_NOT_SUPPORTED 0x05 +#define DELIMITER_ERROR 0x06 +#define TYPE_NOT_SUPPORTED 0x07 +#define INVALID_LINK_CONTROL 0x08 +#define INVALID_R_CTL 0x09 +#define INVALID_F_CTL 0x0a +#define INVALID_OX_ID 0x0b +#define INVALID_RX_ID 0x0c +#define INVALID_SEQ_ID 0x0d +#define INVALID_DF_CTL 0x0e +#define INVALID_SEQ_CNT 0x0f +#define INVALID_PARAMETER 0x10 +#define EXCHANGE_ERROR 0x11 +#define PROTOCOL_ERROR 0x12 +#define INCORRECT_LENGTH 0x13 +#define UNEXPECTED_ACK 0x14 +#define UNEXPECTED_LINK_RESP 0x15 +#define LOGIN_REQUIRED 0x16 +#define EXCESSIVE_SEQUENCES 0x17 +#define CANT_ESTABLISH_EXCHANGE 0x18 +#define SECURITY_NOT_SUPPORTED 0x19 + +/* BA_RJT and LS_RJT reason codes */ +#define RJT_INVALID_CMD_CODE 0x01 +#define RJT_LOGICAL_ERROR 0x03 +#define RJT_LOGICAL_BUSY 0x05 +#define RJT_PROTOCOL_ERR 0x07 +#define RJT_CANT_PERFORM_RQST 0x09 +#define RJT_CMD_NOT_SUPPORTED 0x0b + + +/* + * Frame Payloads that the SOC understands + * Transfer Ready: + */ + +typedef struct Xfer_Rdy { + int seq_ro; + int burst_len; + int reserved; +} aXFER_RDY, *XFER_RDYptr; + +/* + * Link Error Status Block + */ + +typedef struct LA_RLS_reply { + int code; + int link_failure; + int loss_of_sync; + int loss_of_signal; + int primitive_error; + int code_violations; + int invalid_crc; +} aLA_RLS_reply, *LA_RLS_replyptr; + + +/* + * Login + */ + +typedef struct LOGI_PAYLOAD { + uint_t code; + uchar_t common_service_params[16]; + uchar_t port_name[8]; + uchar_t node_name[8]; + uchar_t class1_service_params[16]; + uchar_t class2_service_params[16]; + uchar_t class3_service_params[16]; +} aLOGI_PAYLOAD, *LOGI_PAYLOADptr; + +#define SP_F_PORT_LOGIN 0x10 + + +/* + * Extended Link Service Payload + */ + +/* Arbitrary upper limit for now... */ +#define FC_MAX_ELS (60-4) + +typedef struct ELS_payload { + union els_cmd_u { + struct { + uchar_t ls_command; + uchar_t reserved[3]; + } c; + uint_t i; + } els_cmd; + uchar_t els_data[FC_MAX_ELS]; +} els_payload_t; + +/* + * NOTE: This dataseg definition makes this file unique + * from the Pluto fc_ph file. + */ + +/* + * Data segment definition + */ +typedef struct fc_dataseg { + uint32_t fc_base; /* Address of buffer. */ + uint32_t fc_count; /* Length of buffer. */ +} fc_dataseg_t; + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_FC4_FC_H */ diff --git a/illumos-x86_64/usr/include/sys/fc4/fc_transport.h b/illumos-x86_64/usr/include/sys/fc4/fc_transport.h new file mode 100644 index 00000000..9064fda8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fc4/fc_transport.h @@ -0,0 +1,309 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FC4_FC_TRANSPORT_H +#define _SYS_FC4_FC_TRANSPORT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * fc_devdata_t definitions + * + * See fc.h for TYPE field definitions + */ +typedef int fc_devdata_t; + +/* + * fc_ioclass_t definitions. + */ +typedef enum { + FC_CLASS_OUTBOUND, + FC_CLASS_INBOUND, + FC_CLASS_SIMPLE, + FC_CLASS_IO_WRITE, + FC_CLASS_IO_READ, + FC_CLASS_OFFLINE, + FC_CLASS_UNSOLICITED +} fc_ioclass_t; + +/* + * This data structure is used by a Fiber Channel Adaptor driver client to + * request a Fiber Channel transaction. + */ + +typedef struct fc_packet { + /* + * identifies which FC device + * + * In our case it is a pointer to the + * port_status structure. This structure + * contains the physical port (0 or 1). + */ + void *fc_pkt_cookie; /* identifies which FC device */ + + void (*fc_pkt_comp)(struct fc_packet *); + void *fc_pkt_private; + int32_t fc_pkt_flags; /* flags */ + int32_t fc_pkt_timeout; /* Max time to complete */ + fc_ioclass_t fc_pkt_io_class; /* fc io class */ + fc_devdata_t fc_pkt_io_devdata; /* FC IO Device Data. */ + fc_dataseg_t *fc_pkt_cmd; /* Outbound packet */ + fc_dataseg_t *fc_pkt_rsp; /* Inbound Packet */ + fc_dataseg_t **fc_pkt_datap; /* List of Data Packets */ + + /* + * SOC status from soc status field in Response que. + */ + unsigned int fc_pkt_status; /* SOC Status when complete */ + int fc_pkt_statistics; /* not used */ + + fc_frame_header_t *fc_frame_cmd, /* used for command */ + *fc_frame_resp; /* used for response */ + + struct fc_packet *fc_pkt_next, /* Chain of FC packet reqs. */ + *fc_pkt_prev; +} fc_packet_t; + +/* + * Fibre channel packet flags + */ +#define FCFLAG_NOINTR 1 /* run this command without intr */ +#define FCFLAG_COMPLETE 2 /* command has completed */ + +/* + * fc_transport() return values + */ +enum { + FC_TRANSPORT_SUCCESS, /* success */ + FC_TRANSPORT_FAILURE, /* failure */ + FC_TRANSPORT_TIMEOUT, /* timeout while polling */ + FC_TRANSPORT_QFULL, /* queue full */ + FC_TRANSPORT_UNAVAIL /* temp. unavailable, e.g., offline */ +}; + + +/* + * pkt_status return values + */ +#define FC_STATUS_OK 0 +#define FC_STATUS_P_RJT 2 +#define FC_STATUS_F_RJT 3 +#define FC_STATUS_P_BSY 4 +#define FC_STATUS_F_BSY 5 +#define FC_STATUS_ERR_OFFLINE 0x11 +#define FC_STATUS_TIMEOUT 0x12 +#define FC_STATUS_ERR_OVERRUN 0x13 +#define FC_STATUS_UNKNOWN_CQ_TYPE 0x20 +#define FC_STATUS_BAD_SEG_CNT 0x21 +#define FC_STATUS_MAX_XCHG_EXCEEDED 0x22 +#define FC_STATUS_BAD_XID 0x23 +#define FC_STATUS_XCHG_BUSY 0x24 +#define FC_STATUS_BAD_POOL_ID 0x25 +#define FC_STATUS_INSUFFICIENT_CQES 0x26 +#define FC_STATUS_ALLOC_FAIL 0x27 +#define FC_STATUS_BAD_SID 0x28 +#define FC_STATUS_NO_SEQ_INIT 0x29 +#define FC_STATUS_ERROR 0x80 +#define FC_STATUS_ONLINE_TIMEOUT 0x81 +/* + * additional pseudo-status codes for login + */ +#define FC_STATUS_LOGIN_TIMEOUT 0x80000001u +#define FC_STATUS_CQFULL 0x80000002u +#define FC_STATUS_TRANSFAIL 0x80000003u +#define FC_STATUS_RESETFAIL 0x80000004u + +/* + * fc_uc_register() return values + */ +typedef void * fc_uc_cookie_t; + +/* + * fc_transport() iotype parameter + */ +typedef enum { + FC_TYPE_UNCATEGORIZED, + FC_TYPE_DATA, + FC_TYPE_UNSOL_CONTROL, + FC_TYPE_SOLICITED_CONTROL, + FC_TYPE_UNSOL_DATA, + FC_TYPE_XFER_RDY, + FC_TYPE_COMMAND, + FC_TYPE_RESPONSE +} fc_iotype_t; + + +/* + * fc_transport() sleep parameter + */ +typedef enum { + FC_SLEEP, /* sleep on queue full */ + FC_NOSLEEP /* do not sleep on queue full */ +} fc_sleep_t; + + +/* + * State changes related to the N-port interface communicated from below + */ +typedef enum { + FC_STATE_ONLINE, /* port has gone online */ + FC_STATE_OFFLINE, /* port has gone offline */ + FC_STATE_RESET /* port reset, all cmds lost */ +} fc_statec_t; + +typedef void * fc_statec_cookie_t; + +/* + * This structure is allocated by Fiber Channel Adaptor at INITCHILD time, + * and is communicated to the child by ddi_set_driver_private(). + * It defines the vectors by which the child obtains soc + * driver services, and all other information the child + * may need about its parent. + */ + +typedef struct fc_transport { + void *fc_cookie; /* Which FC dev. */ + ddi_dma_lim_t *fc_dmalimp; /* FC ddi_dma_lim_t ptr. */ + ddi_dma_attr_t *fc_dma_attrp; /* FC ddi_dma_attr_t ptr. */ + ddi_iblock_cookie_t fc_iblock; /* iblock for mutexes */ + kmutex_t fc_mtx; /* Locks for transport */ + kcondvar_t fc_cv; + + /* + * Transport a command across the interface. + */ + int (*fc_transport)( + struct fc_packet *fc, + fc_sleep_t sleep); + + /* + * Reset the transport. + */ + int (*fc_reset)( + struct fc_packet *fc); + + /* + * Allocate an fc_packet structure. + */ + fc_packet_t *(*fc_pkt_alloc)( + void *cookie, + fc_sleep_t sleep); + + /* + * Free an fc_packet structure. + */ + void (*fc_pkt_free)( + void *cookie, + struct fc_packet *pkt); + + /* + * Register a routine to handle state changes on the interface + * + * The arg parameter, along with an fc_statec_t parameter, will + * be passed to the callback routine on all state changes + * after initialization. + */ + fc_statec_cookie_t + (*fc_statec_register)( + void *cookie, + void (*callback)(void *, fc_statec_t), + void *arg); + + /* + * Unregister a routine to handle state changes + */ + void (*fc_statec_unregister)( + void *cookie, + fc_statec_cookie_t statec_cookie); + + /* + * Run the interface in polling mode. This allows interface + * state changes, etc. to be processed when system interrupts + * are disabled. This is used mostly for error recovery. + * Too bad Fibre Channel doesn't have a common error policy for + * all protocols so that we could do error recovery at + * the lowest level instead of having kludges like this... + */ + void (*fc_interface_poll)( + void *cookie); + + /* + * Unsolicited Command Interface + * + * This interface operates with the presumption that the + * higher level driver (child) will process unsolicited + * commands that pertain to its protocol such as FCP or FCIP. + */ + + /* + * Register a callback to be called in the event of an + * unsolicited command received by the soc for this child. + * No information is passed regarding the event, just that + * one occurred. The arg parameter to passed to the + * callback function as its parameter. + */ + fc_uc_cookie_t + (*fc_uc_register)( + void *cookie, + fc_devdata_t devdata, + void (*callback)(void *), + void *arg); + + /* + * Unregister a callback routine + */ + void (*fc_uc_unregister)( + void *cookie, + fc_uc_cookie_t uc_cookie); + + /* + * Return information about the unsolicited command + * event in pkt. The pkt must be a fully allocated + * fc_packet structure, with a valid cmd dataseg + * pointer, in which the received cmd payload will + * be placed. The length of the allocated dataseg should + * be greater than or equal to the length of the received + * command payload, otherwise the entire command cannot + * be copied into the data segment. This function + * returns -1 in the event of an error, or the + * actual length of the received command payload. + */ + int (*fc_uc_get_pkt)( + void *cookie, + struct fc_packet *pkt); + +} fc_transport_t; + + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_FC4_FC_TRANSPORT_H */ diff --git a/illumos-x86_64/usr/include/sys/fc4/fcal.h b/illumos-x86_64/usr/include/sys/fc4/fcal.h new file mode 100644 index 00000000..f8aff6be --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fc4/fcal.h @@ -0,0 +1,245 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FC4_FCAL_H +#define _SYS_FC4_FCAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fibre Channel Physical and Signaling Interface (FC-PH) definitions. + * + * NOTE: modifications of this file affect drivers, mpsas models, PLUTO + * firmware, SOC assembly code. Please be communicative. + */ + +#define FC_PH_VERSION 0x06 /* 0x06 means 4.0 ! */ +#define MAX_FRAME_SIZE 2112 /* maximum size of frame payload */ + +/* + * This is the standard frame header for FC-PH frames. + */ + +typedef struct FC2_FRAME_HDR { + uint_t r_ctl:8, d_id:24; + uint_t reserved1:8, s_id:24; + uint_t type:8, f_ctl:24; + uint_t seq_id:8, df_ctl:8, seq_cnt:16; + uint16_t ox_id, rx_id; + uint32_t ro; +}aFC2_FRAME_HDR, *FC2_FRAME_HDRptr, fc_frame_header_t; + +#define WE_ARE_ORIGINATOR(fh) (fh->f_ctl & F_CTL_XCHG_CONTEXT) +#define UNSOLICITED_FRAME(fh) (fh->rx_id == 0xffff) +#define FIRST_SEQUENCE(fh) (fh->f_ctl & F_CTL_FIRST_SEQ) +#define LAST_FRAME_OF_SEQUENCE(fh) (fh->f_ctl & F_CTL_END_SEQ) +#define LAST_SEQUENCE_OF_EXCHANGE(fh) (fh->f_ctl & F_CTL_LAST_SEQ) +#define TRANSFER_INITIATIVE(fh) (fh->f_ctl & F_CTL_SEQ_INITIATIVE) + + +/* legal values for r_ctl */ +#define R_CTL_ROUTING 0xf0 /* mask for routing bits */ +#define R_CTL_INFO 0x0f /* mask for information bits */ + +#define R_CTL_DEVICE_DATA 0x00 /* all I/O related frames */ +#define R_CTL_EXTENDED_SVC 0x20 /* extended link services (PLOGI) */ +#define R_CTL_FC4_SVC 0x30 /* FC-4 link services (FCP_LOGI) */ +#define R_CTL_VIDEO_BUFF 0x40 /* not yet defined */ +#define R_CTL_BASIC_SVC 0x80 /* basic link services (NOP) */ +#define R_CTL_LINK_CTL 0xc0 /* ACKs, etc. */ + +/* legal values for r_ctl: Device Data */ +#define R_CTL_UNCATEGORIZED 0x00 +#define R_CTL_SOLICITED_DATA 0x01 +#define R_CTL_UNSOL_CONTROL 0x02 +#define R_CTL_SOLICITED_CONTROL 0x03 +#define R_CTL_UNSOL_DATA 0x04 +#define R_CTL_XFER_RDY 0x05 +#define R_CTL_COMMAND 0x06 +#define R_CTL_STATUS 0x07 + +/* legal values for r_ctl: Basic Link Services, type 0 */ +#define R_CTL_LS_NOP 0x80 +#define R_CTL_LS_ABTS 0x81 +#define R_CTL_LS_RMC 0x82 +#define R_CTL_LS_BA_ACC 0x84 +#define R_CTL_LS_BA_RJT 0x85 + +/* legal values for r_ctl: Extended Link Services, type 1 */ +#define R_CTL_ELS_REQ 0x22 +#define R_CTL_ELS_RSP 0x23 + +/* legal values for r_ctl: Link Control */ +#define R_CTL_ACK_1 0xc0 +#define R_CTL_ACK_N 0xc1 +#define R_CTL_P_RJT 0xc2 +#define R_CTL_F_RJT 0xc3 +#define R_CTL_P_BSY 0xc4 +#define R_CTL_F_BSY_DF 0xc5 +#define R_CTL_F_BSY_LC 0xc6 +#define R_CTL_LCR 0xc7 + +/* type field definitions for Link Data frames: */ +#define TYPE_BASIC_LS 0x00 +#define TYPE_EXTENDED_LS 0x01 + +/* type field definitions for Device Data frames (from FC-PH 4.1): */ +#define TYPE_IS8802 0x04 +#define TYPE_IS8802_SNAP 0x05 +#define TYPE_SCSI_FCP 0x08 /* we use this one */ +#define TYPE_SCSI_GPP 0x09 +#define TYPE_HIPP_FP 0x0a +#define TYPE_IPI3_MASTER 0x11 +#define TYPE_IPI3_SLAVE 0x12 +#define TYPE_IPI3_PEER 0x13 + +#define F_CTL_XCHG_CONTEXT 0x800000 /* 0 if SID is XCHG originator */ +#define F_CTL_SEQ_CONTEXT 0x400000 /* 0 if SID is SEQ initiator */ +#define F_CTL_FIRST_SEQ 0x200000 /* 1 if first sequence of XCHG */ +#define F_CTL_LAST_SEQ 0x100000 /* 1 if last SEQ of XCHG */ +#define F_CTL_END_SEQ 0x080000 /* 1 if last frame of a SEQ */ +#define F_CTL_END_CONNECT 0x040000 /* always 0 */ +#define F_CTL_CHAINED_SEQ 0x020000 /* always 0 */ +#define F_CTL_SEQ_INITIATIVE 0x010000 /* when 1 xfrs SEQ initiative */ +#define F_CTL_XID_REASSIGNED 0x008000 /* always 0 */ +#define F_CTL_INVALIDATE_XID 0x004000 /* always 0 */ +#define F_CTL_CONTINUE_SEQ 0x0000C0 /* always 0 */ +#define F_CTL_ABORT_SEQ 0x000030 /* always 0 */ +#define F_CTL_RO_PRESENT 0x000008 /* 1 if param field == RO */ +#define F_CTL_XCHG_REASSEMBLE 0x000004 /* always 0 */ +#define F_CTL_FILL_BYTES 0x000003 /* # of fill bytes in this frame */ +#define F_CTL_RESERVED 0x003F00 +#define F_CTL_ALWAYS_ZERO (F_CTL_RESERVED | F_CTL_XCHG_REASSEMBLE | \ + F_CTL_ABORT_SEQ | F_CTL_CONTINUE_SEQ| F_CTL_INVALIDATE_XID | \ + F_CTL_XID_REASSIGNED | F_CTL_CHAINED_SEQ | F_CTL_END_CONNECT) + +/* Well known addresses ... */ +#define FS_GENERAL_MULTICAST 0xfffff7 +#define FS_WELL_KNOWN_MULTICAST 0xfffff8 +#define FS_HUNT_GROUP 0xfffff9 +#define FS_MANAGEMENT_SERVER 0xfffffa +#define FS_TIME_SERVER 0xfffffb +#define FS_NAME_SERVER 0xfffffc +#define FS_FABRIC_CONTROLLER 0xfffffd +#define FS_FABRIC_F_PORT 0xfffffe +#define FS_BROADCAST 0xffffff + +/* Fabric Busy Reason Codes */ +#define FABRIC_BUSY 0x01 +#define NPORT_BUSY 0x03 + +/* NPort Busy Reason Codes */ +#define PHYSICAL_BUSY 0x01 +#define RESOURSE_BUSY 0x03 + +/* Reject Reason Codes */ + +typedef struct FC2_RJT_PARAM { + uchar_t rjt_action; + uchar_t rjt_reason; + uchar_t reserved[2]; +} aFC2_RJT_PARAM; + +#define INVALID_D_ID 0x01 +#define INVALID_S_ID 0x02 +#define NPORT_NOT_AVAIL_TEMP 0x03 +#define NPORT_NOT_AVAIL_PERM 0x04 +#define CLASS_NOT_SUPPORTED 0x05 +#define DELIMITER_ERROR 0x06 +#define TYPE_NOT_SUPPORTED 0x07 +#define INVALID_LINK_CONTROL 0x08 +#define INVALID_R_CTL 0x09 +#define INVALID_F_CTL 0x0a +#define INVALID_OX_ID 0x0b +#define INVALID_RX_ID 0x0c +#define INVALID_SEQ_ID 0x0d +#define INVALID_DF_CTL 0x0e +#define INVALID_SEQ_CNT 0x0f +#define INVALID_PARAMETER 0x10 +#define EXCHANGE_ERROR 0x11 +#define PROTOCOL_ERROR 0x12 +#define INCORRECT_LENGTH 0x13 +#define UNEXPECTED_ACK 0x14 +#define UNEXPECTED_LINK_RESP 0x15 +#define LOGIN_REQUIRED 0x16 +#define EXCESSIVE_SEQUENCES 0x17 +#define CANT_ESTABLISH_EXCHANGE 0x18 +#define SECURITY_NOT_SUPPORTED 0x19 + +/* BA_RJT and LS_RJT reason codes */ +#define RJT_INVALID_CMD_CODE 0x01 +#define RJT_LOGICAL_ERROR 0x03 +#define RJT_LOGICAL_BUSY 0x05 +#define RJT_PROTOCOL_ERR 0x07 +#define RJT_CANT_PERFORM_RQST 0x09 +#define RJT_CMD_NOT_SUPPORTED 0x0b + + +/* + * Frame Payloads that the SOC understands + * Transfer Ready: + */ + +typedef struct Xfer_Rdy { + int32_t seq_ro; + int32_t burst_len; + int32_t reserved; +} aXFER_RDY, *XFER_RDYptr; + +/* + * Extended Link Service Payload + */ + +/* Arbitrary upper limit for now... */ +#define FC_MAX_ELS (60-4) + +typedef struct ELS_payload { + union els_cmd_u { + struct { + uchar_t ls_command; + uchar_t reserved[3]; + } c; + uint32_t i; + } els_cmd; + uchar_t els_data[FC_MAX_ELS]; +} els_payload_t; + + +/* + * Data segment definition + */ +typedef struct fc_dataseg { + uint32_t fc_base; /* Address of buffer. */ + uint32_t fc_count; /* Length of buffer. */ +} fc_dataseg_t; + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_FC4_FCAL_H */ diff --git a/illumos-x86_64/usr/include/sys/fc4/fcal_linkapp.h b/illumos-x86_64/usr/include/sys/fc4/fcal_linkapp.h new file mode 100644 index 00000000..81ef73fc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fc4/fcal_linkapp.h @@ -0,0 +1,344 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FC4_FCAL_LINKAPP_H +#define _SYS_FC4_FCAL_LINKAPP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * linkapp.h + * + * This file contains the definitions for structures and macros + * for fiber channel link application payloads and data. + */ + +/* + * Well Known Fiber Chaneel Addresses to reach the fabric for + * various services. + */ + +#define MAX_FCODE_SIZE 0x2000 +#define FS_GENERAL_MULTICAST 0xfffff7 +#define FS_WELL_KNOWN_MULTICAST 0xfffff8 +#define FS_HUNT_GROUP 0xfffff9 +#define FS_MANAGEMENT_SERVER 0xfffffa +#define FS_TIME_SERVER 0xfffffb +#define FS_NAME_SERVER 0xfffffc +#define FS_FABRIC_CONTROLLER 0xfffffd +#define FS_FABRIC_F_PORT 0xfffffe +#define FS_BROADCAST 0xffffff + +/* + * Link Application Opcodes. + */ + +#define LA_ELS_RJT 0x01 +#define LA_ELS_ACC 0x02 +#define LA_ELS_PLOGI 0x03 +#define LA_ELS_FLOGI 0x04 +#define LA_ELS_LOGO 0x05 +#define LA_ELS_ABTX 0x06 +#define LA_ELS_RCS 0x07 +#define LA_ELS_RES 0x08 +#define LA_ELS_RSS 0x09 +#define LA_ELS_RSI 0x0a +#define LA_ELS_ESTS 0x0b +#define LA_ELS_ESTC 0x0c +#define LA_ELS_ADVC 0x0d +#define LA_ELS_RTV 0x0e +#define LA_ELS_RLS 0x0f +#define LA_ELS_ECHO 0x10 +#define LA_ELS_RRQ 0x12 +#define LA_ELS_PRLI 0x20 +#define LA_ELS_PRLO 0x21 +#define LA_ELS_SCN 0x22 +#define LA_ELS_TPLS 0x23 +#define LA_ELS_GPRLO 0x24 +#define LA_ELS_GAID 0x30 +#define LA_ELS_FACT 0x31 +#define LA_ELS_FDACT 0x32 +#define LA_ELS_NACT 0x33 +#define LA_ELS_NDACT 0x34 +#define LA_ELS_QoSR 0x40 +#define LA_ELS_RVCS 0x41 +#define LA_ELS_PDISC 0x50 +#define LA_ELS_FDISC 0x51 +#define LA_ELS_ADISC 0x52 +#define LA_ELS_NEW_IDENT 0xf0 /* SMCC specific */ +#define LA_ELS_DISPLAY 0xf1 /* SMCC specific */ +#define LA_ELS_IDENT 0x20 /* SMCC specifi, SSA compat. */ + +/* + * Events supported by soc+ HBA driver + */ +#define FCAL_INSERT_EVENT "SUNW,sf:DEVICE-INSERTION.1" +#define FCAL_REMOVE_EVENT "SUNW,sf:DEVICE-REMOVAL.1" + +/* Basic Accept Payload. */ +typedef struct la_ba_acc { + uchar_t seq_id:8; + uchar_t org_s_id[3]; + ushort_t ox_id; + ushort_t rx_id; +} la_ba_acc_t; + +/* Basic Reject. */ +typedef struct la_ba_rjt { + uchar_t reserved; + uchar_t reason_code; + uchar_t explanation; + uchar_t vendor; +} la_ba_rjt_t; + +/* + * Basic Reject Reason Codes. + */ +#define RJT_INVALID_CMD 0x01 +#define RJT_LOGICAL_ERR 0x03 +#define RJT_LOGICAL_BUSY 0x05 +#define RJT_PROTOCOL_ERR 0x07 +#define RJT_UNABLE 0x09 +#define RJT_UNSUPPORTED 0x0B +#define RJT_VENDOR 0xFF + +/* + * Basic Reject Explanation Codes + */ +#define RJT_NOEXPLANATION 0x00 +#define RJT_INVALID_OSID 0x01 +#define RJT_INVALID_OXID_RXID 0x03 +#define RJT_INVALID_SEQID 0x05 +#define RJT_ABORT_INACTIVE_SEQ 0x07 +#define RJT_UNABLE_TO_SUPPLY 0x09 + +/* + * Service parameters. + */ +typedef struct common_service { + uint_t fcph; + uint_t btob_crdt; + uint_t cmn_features; + uint_t reserved; +} common_svc_t; + +typedef struct service_param { + uchar_t data[16]; +} svc_param_t; + +/* World Wide Name formats */ +typedef union la_wwn { + uchar_t raw_wwn[8]; + struct { + uint_t naa_id : 4; + uint_t nport_id : 12; + uint_t wwn_hi : 16; + uint_t wwn_lo; + } w; +} la_wwn_t; + +#define FC_WWN_SIZE 8 + +/* + * Values for naa_id + */ +#define NAA_ID_IEEE 1 +#define NAA_ID_IEEE_EXTENDED 2 + +/* Login Payload. */ +typedef struct la_els_logi { + uchar_t ls_code; + uchar_t mbz[3]; + common_svc_t common_service; + + la_wwn_t nport_ww_name; + la_wwn_t node_ww_name; + + svc_param_t class_1; + svc_param_t class_2; + svc_param_t class_3; + uchar_t reserved[16]; + uchar_t vendor_version_level[16]; +} la_els_logi_t; + +typedef la_els_logi_t la_els_logi_reply_t; +#define la_logi_t la_els_logi_t + +#define SP_F_PORT_LOGIN 0x10 + +/* Read Link Error Status */ +typedef struct la_els_rls { + uchar_t ls_code; + uchar_t mbz[3]; + uchar_t reserved; + uchar_t nport_id[3]; +} la_els_rls_t; + +/* Read Link Error Status Reply */ +typedef struct la_els_rls_reply { + uchar_t ls_code; + uchar_t mbz[3]; + uint_t link_failure; + uint_t loss_of_sync; + uint_t loss_of_signal; + uint_t primitive; + uint_t invalid_transmission; + uint_t invalid_crc; +} la_els_rls_reply_t; + +/* Logout payload. */ +typedef struct la_els_logo { + uchar_t ls_code; + uchar_t mbz[3]; + uchar_t reserved; + uchar_t nport_id[3]; + la_wwn_t nport_ww_name; +} la_els_logo_t; + +/* Logout reply payload. */ +typedef la_els_logo_t la_els_logo_reply_t; + +/* Reinstate recovery qualifier */ +typedef struct la_els_rrq { + uchar_t ls_code; + uchar_t mbz[3]; + uchar_t reserved; + uchar_t source_id[3]; + ushort_t ox_id; + ushort_t rx_id; + uchar_t assoc_header[32]; +} la_els_rrq_t; + +/* Reinstate recovery qualifier reply */ +typedef la_els_logo_t la_els_rrq_reply_t; + +/* Process login */ +typedef struct la_els_prli { + uchar_t ls_code; + uchar_t page_length; + ushort_t payload_length; + uchar_t service_params[16]; +} la_els_prli_t; + +/* Process login reply */ +typedef la_els_prli_t la_els_prli_reply_t; + +/* Process logout */ +typedef la_els_prli_t la_els_prlo_t; + +/* process logout reply */ +typedef la_els_prli_t la_els_prlo_reply_t; + +/* Port discovery */ +typedef la_els_logi_t la_els_pdisc_t; + +/* Port discovery reply */ +typedef la_els_logi_reply_t la_els_pdisc_reply_t; + +/* Address discovery */ +typedef struct la_els_adisc { + uchar_t ls_code; + uchar_t mbz[3]; + uint_t hard_address; + uchar_t port_wwn[8]; + uchar_t node_wwn[8]; + uint_t nport_id; +} la_els_adisc_t; + +/* Address discovery reply */ +typedef la_els_adisc_t la_els_adisc_reply_t; + +/* Identify */ +typedef struct la_els_identify { + uint_t ls_code; + uint_t byte_count; +} la_els_identify_t; + +/* Identify reply */ +typedef struct la_els_identify_reply { + uint_t ls_code; + uchar_t fcode[MAX_FCODE_SIZE]; +} la_els_identify_reply; + +/* Link Application Reject */ +typedef struct la_els_rjt { + uchar_t ls_code; + uchar_t mbz[3]; + uchar_t reserved; + uchar_t reason_code; + uchar_t explanation; + uchar_t vendor; +} la_els_rjt_t; + +/* + * LA_RJT Reason Codes. + */ +#define LA_RJT_INVALID 0x01 +#define LA_RJT_LOGICAL_ERR 0x03 +#define LA_RJT_LOGICAL_BUSY 0x05 +#define LA_RJT_PROTOCOL_ERR 0x07 +#define LA_RJT_UNABLE_TO_PERFORM 0x09 +#define LA_RJT_NOT_SUPPORTED 0x0b +#define LA_RJT_VENDOR 0xff + +/* + * LA_RJT explanations + */ +#define LA_RJT_NOEXPLANATION 0x00 +#define LA_RJT_OPTIONS 0x01 +#define LA_RJT_INITIATOR 0x03 +#define LA_RJT_RECIPIENT 0x05 +#define LA_RJT_DATA_FIELD_SIZE 0x07 +#define LA_RJT_CONCURRENT 0x09 +#define LA_RJT_CREDIT 0x0b + +#define LA_RJT_INVALID_PORT_WWNAME 0x0d +#define LA_RJT_INVALID_NODE_WWNAME 0x0e +#define LA_RJT_INVALID_COMMON_SVC 0x0f + +#define LA_RJT_INVALID_ASSOC_HEADER 0x11 +#define LA_RJT_ASSOC_HDR_REQD 0x13 +#define LA_RJT_INVALID_ORIG_SID 0x15 +#define LA_RJT_INVALID_FQXID 0x17 +#define LA_RJT_REQUEST_IN_PROGRESS 0x19 +#define LA_RJT_INVALID_NPORT_ID 0x1f + +#define LA_RJT_ INVALID_SEQ_ID 0x21 +#define LA_RJT_ABT_INVALID_XID 0x23 +#define LA_RJT_ABT_INACTIVE_XID 0x25 +#define LA_RJT_RRQ_REQUIRED 0x27 +#define LA_RJT_INSUFFICENT 0x29 + +#define LA_RJT_REQUESTED_DATA 0x2a +#define LA_RJT_REQUEST_NOT_SUPPORTED 0x2c + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_FC4_FCAL_LINKAPP_H */ diff --git a/illumos-x86_64/usr/include/sys/fc4/fcal_transport.h b/illumos-x86_64/usr/include/sys/fc4/fcal_transport.h new file mode 100644 index 00000000..d3d0f1ed --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fc4/fcal_transport.h @@ -0,0 +1,238 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FC4_FCAL_TRANSPORT_H +#define _SYS_FC4_FCAL_TRANSPORT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * fc_devdata_t definitions + * + * See fc.h for TYPE field definitions + */ +typedef int fc_devdata_t; + +/* + * fc_ioclass_t definitions. + */ +typedef enum { + FC_CLASS_OUTBOUND, + FC_CLASS_INBOUND, + FC_CLASS_SIMPLE, + FC_CLASS_IO_WRITE, + FC_CLASS_IO_READ, + FC_CLASS_OFFLINE, + FC_CLASS_UNSOLICITED +} fc_ioclass_t; + +/* + * fc_transport() sleep parameter + */ +typedef enum { + FCAL_SLEEP, /* sleep on queue full */ + FCAL_NOSLEEP /* do not sleep on queue full */ +} fcal_sleep_t; + +typedef struct fcal_packet { + void *fcal_pkt_cookie; /* identifies which FC device */ + struct fcal_packet *fcal_pkt_next; + void (*fcal_pkt_comp)(struct fcal_packet *); + void *fcal_pkt_private; + uint_t fcal_pkt_flags; /* flags */ + uint_t fcal_cmd_state; + uint_t fcal_pkt_status; /* SOC Status when complete */ + uint_t fcal_diag_status; /* used only for diagnostics */ + union { + soc_request_t req; + longlong_t l; + } w; + +#define fcal_socal_request w.req + + fc_frame_header_t fcal_resp_hdr; + uint_t fcal_magic; + ushort_t fcal_ncmds; +} fcal_packet_t; + +/* + * Fibre channel packet flags + */ +#define FCFLAG_NOINTR 1 /* run this command without intr */ +#define FCFLAG_COMPLETE 2 /* command has completed */ +#define FCFLAG_RESP_HEADER 4 /* valid response frame header */ +#define FCFLAG_ABORTING 8 /* this packet is being aborted */ +#define FCFLAG_ABORTED 0x10 /* the abort completed */ + +/* + * definitions for the cmd_state + */ +#define FCAL_CMD_IN_TRANSPORT 0x1 /* command in transport */ +#define FCAL_CMD_COMPLETE 0x4 /* command complete */ +#define FCAL_CMPLT_CALLED 0x10 /* Completion routine called */ + +#define FCALP_MAGIC 0x4750703 + +typedef struct fcal_transport { + void *fcal_handle; /* identifies which FC dev */ + ddi_dma_lim_t *fcal_dmalimp; + ddi_iblock_cookie_t fcal_iblock; + ddi_dma_attr_t *fcal_dmaattr; + ddi_device_acc_attr_t *fcal_accattr; + caddr_t fcal_loginparms; /* from soc+ xram */ + la_wwn_t fcal_n_wwn; /* node Worldwide name */ + la_wwn_t fcal_p_wwn; /* port Worldwide name */ + uint_t fcal_portno; /* which port */ + uint_t fcal_cmdmax; /* max number of exchanges */ + kmutex_t fcal_mtx; + kcondvar_t fcal_cv; + struct fcal_transport_ops *fcal_ops; +} fcal_transport_t; + +typedef struct fcal_transport_ops { + uint_t (*fcal_transport)(fcal_packet_t *fcalpkt, + fcal_sleep_t sleep, int + req_q_no); + uint_t (*fcal_transport_poll)(fcal_packet_t *fcalpkt, + uint_t timeout, + int req_q_no); + uint_t (*fcal_lilp_map)(void *fcal_handle, + uint_t port, + uint32_t bufid, + uint_t poll); + uint_t (*fcal_force_lip)(void *fcal_handle, + uint_t port, + uint_t poll, + uint_t lip_req); + uint_t (*fcal_abort_cmd)(void *fcal_handle, + uint_t port, + fcal_packet_t *fcalpkt, + uint_t poll); + uint_t (*fcal_els)(void *fcal_handle, + uint_t port, + uint_t els_code, + uint_t dest, + void (*callback)(), + void *arg, + caddr_t reqpayload, + caddr_t *rsppayload, + uint_t poll); + uint_t (*fcal_bypass_dev)(void *fcal_handle, + uint_t port, + uint_t dest); + void (*fcal_force_reset)(void *fcal_handle, + uint_t port, + uint_t reset); + void (*fcal_add_ulp)(void *fcal_handle, + uint_t port, + uchar_t type, + void (*ulp_statec_callback)(), + void (*ulp_els_callback)(), + void (*ulp_data_callback)(), + void *arg); + void (*fcal_remove_ulp)(void *fcal_handle, + uint_t port, + uchar_t type, + void *arg); + void (*fcal_take_core)(void *fcal_handle); +} fcal_transport_ops_t; + +/* + * additional pseudo-status codes for login + */ +#define FCAL_STATUS_LOGIN_TIMEOUT 0x80000001 +#define FCAL_STATUS_CQFULL 0x80000002 +#define FCAL_STATUS_TRANSFAIL 0x80000003 +#define FCAL_STATUS_RESETFAIL 0x80000004 + +/* + * interface and transport function return values + */ +#define FCAL_SUCCESS 0x000 +#define FCAL_TIMEOUT 0x001 +#define FCAL_ALLOC_FAILED 0x002 +#define FCAL_OLD_PORT 0x003 +#define FCAL_LINK_ERROR 0x004 +#define FCAL_OFFLINE 0x005 +#define FCAL_ABORTED 0x006 +#define FCAL_ABORT_FAILED 0x007 +#define FCAL_BAD_ABORT 0x008 +#define FCAL_BAD_PARAMS 0x009 +#define FCAL_OVERRUN 0x00a +#define FCAL_NO_TRANSPORT 0x00b +#define FCAL_TRANSPORT_SUCCESS 0x000 +#define FCAL_TRANSPORT_FAILURE 0x101 +#define FCAL_BAD_PACKET 0x102 +#define FCAL_TRANSPORT_UNAVAIL 0x103 +#define FCAL_TRANSPORT_QFULL 0x104 +#define FCAL_TRANSPORT_TIMEOUT 0x105 + +#define FCAL_FAILURE 0xffffffff +/* + * fc_uc_register() return values + */ +typedef void * fc_uc_cookie_t; + +/* + * fc_transport() iotype parameter + */ +typedef enum { + FC_TYPE_UNCATEGORIZED, + FC_TYPE_DATA, + FC_TYPE_UNSOL_CONTROL, + FC_TYPE_SOLICITED_CONTROL, + FC_TYPE_UNSOL_DATA, + FC_TYPE_XFER_RDY, + FC_TYPE_COMMAND, + FC_TYPE_RESPONSE +} fc_iotype_t; + +/* + * State changes related to the N-port interface communicated from below + */ +#define FCAL_STATE_RESET ((int)0xffffffffu) + /* port reset, all cmds lost */ + +#define FCAL_LILP_MAGIC 0x1107 +#define FCAL_BADLILP_MAGIC 0x1105 +#define FCAL_NO_LIP 0x0 +#define FCAL_FORCE_LIP 0x1 + +typedef struct fcal_lilp_map { + ushort_t lilp_magic; + ushort_t lilp_myalpa; + uchar_t lilp_length; + uchar_t lilp_alpalist[127]; +} fcal_lilp_map_t; +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_FC4_FCAL_TRANSPORT_H */ diff --git a/illumos-x86_64/usr/include/sys/fc4/fcio.h b/illumos-x86_64/usr/include/sys/fc4/fcio.h new file mode 100644 index 00000000..07619121 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fc4/fcio.h @@ -0,0 +1,277 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1998-1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FC4_FCIO_H +#define _SYS_FC4_FCIO_H + +/* + * Include any headers you depend on. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * ioctl definitions + */ +#define FIOC ('F'<<8) +#define SF_IOC (0xda << 8) +#define SFIOCGMAP (SF_IOC|1) /* Get device map */ +#define SF_NUM_ENTRIES_IN_MAP 127 + +#define FCIO_GETMAP (FIOC|175) /* Get limited map */ +#define FCIO_FORCE_LIP (FIOC|177) /* Force LIP */ +#define FCIO_LINKSTATUS (FIOC|183) /* Get link status */ +#define FCIO_FCODE_MCODE_VERSION (FIOC|202) /* Get code versions */ + +#define IFPIOCGMAP SFIOCGMAP +#define IFP_NUM_ENTRIES_IN_MAP SF_NUM_ENTRIES_IN_MAP +#define IFPIO_FORCE_LIP FCIO_FORCE_LIP +#define IFPIO_LINKSTATUS FCIO_LINKSTATUS + +typedef struct sf_al_addr_pair { + uchar_t sf_al_pa; + uchar_t sf_hard_address; + uchar_t sf_inq_dtype; + uchar_t sf_node_wwn[FC_WWN_SIZE]; + uchar_t sf_port_wwn[FC_WWN_SIZE]; +} sf_al_addr_pair_t; + +typedef struct sf_al_map { + short sf_count; + sf_al_addr_pair_t sf_addr_pair[SF_NUM_ENTRIES_IN_MAP]; + sf_al_addr_pair_t sf_hba_addr; +} sf_al_map_t; + + + +struct rls_payload { + uint_t rls_portno; + uint_t rls_linkfail; + uint_t rls_syncfail; + uint_t rls_sigfail; + uint_t rls_primitiverr; + uint_t rls_invalidword; + uint_t rls_invalidcrc; +}; + +struct lilpmap { + ushort_t lilp_magic; + ushort_t lilp_myalpa; + uchar_t lilp_length; + uchar_t lilp_list[127]; +}; + + +struct socal_fm_version { + uint_t fcode_ver_len; + uint_t mcode_ver_len; + uint_t prom_ver_len; + char *fcode_ver; + char *mcode_ver; + char *prom_ver; +}; + +/* + * kstat structures + */ +typedef struct sf_target_stats { + uint_t els_failures; /* failures on PLOGI, PRLI, ADISC etc */ + uint_t timeouts; + /* + * sf detected command timeouts, + * implies an ABTS + */ + uint_t abts_failures; /* ABTS failures */ + uint_t task_mgmt_failures; + /* + * SF task management(aborts, + * resets etc) failures + */ + uint_t data_ro_mismatches; /* SF_DATA RO mismatches */ + uint_t dl_len_mismatches; + /* + * SF_DATA length different from + * BURST_LEN + */ + uint_t logouts_recvd; + /* + * unsolicited LOGOs recvd from + * target + */ +} sf_target_stats_t; + +typedef struct sf_stats { + uint_t version; /* version of this struct, >1 */ + uint_t lip_count; /* lips forced by sf */ + uint_t lip_failures; + /* + * lip failures, ie, no ONLINE response + * after forcing lip + */ + uint_t cralloc_failures; + /* + * command/response block allocation + * failures + */ + uint_t ncmds; /* outstanding commands */ + uint_t throttle_limit; /* current throttle limit */ + uint_t cr_pool_size; + /* + * num of chunks in command/response + * pool, each chunk allows 128 packets + */ + struct sf_target_stats tstats[127]; /* per target stats */ + char drvr_name[MAXNAMELEN]; /* Name of driver, NULL term. */ +} sf_stats_t; + + +/* SOCAL Host Adapter kstat structures. */ +#define FC_STATUS_ENTRIES 256 +struct fc_pstats { + uint_t port; /* which port 0 or 1 */ + uint_t requests; /* requests issued by this soc+ */ + uint_t sol_resps; /* solicited responses received */ + uint_t unsol_resps; /* unsolicited responses received */ + uint_t lips; /* forced loop initialization */ + uint_t els_sent; /* extended link service commands issued */ + uint_t els_rcvd; /* extended link service commands received */ + uint_t abts; /* aborts attempted */ + uint_t abts_ok; /* aborts successful */ + uint_t offlines; /* changes to offline state */ + uint_t onlines; /* changes to online state */ + uint_t online_loops; /* changes to online-loop state */ + uint_t resp_status[FC_STATUS_ENTRIES]; /* response status */ +}; + +/* + * Fibre Channel Response codes + */ +#define FCAL_STATUS_OK 0 +#define FCAL_STATUS_P_RJT 2 +#define FCAL_STATUS_F_RJT 3 +#define FCAL_STATUS_P_BSY 4 +#define FCAL_STATUS_F_BSY 5 +#define FCAL_STATUS_ONLINE 0x10 +#define FCAL_STATUS_OLDPORT_ONLINE FCAL_STATUS_ONLINE +#define FCAL_STATUS_ERR_OFFLINE 0x11 +#define FCAL_STATUS_TIMEOUT 0x12 +#define FCAL_STATUS_ERR_OVERRUN 0x13 +#define FCAL_STATUS_LOOP_ONLINE 0x14 +#define FCAL_STATUS_OLD_PORT 0x15 +#define FCAL_STATUS_AL_PORT 0x16 +#define FCAL_STATUS_UNKNOWN_CQ_TYPE 0x20 /* unknown request type */ +#define FCAL_STATUS_BAD_SEG_CNT 0x21 /* insufficient # of segments */ +#define FCAL_STATUS_MAX_XCHG_EXCEEDED 0x22 +#define FCAL_STATUS_BAD_XID 0x23 +#define FCAL_STATUS_XCHG_BUSY 0x24 +#define FCAL_STATUS_BAD_POOL_ID 0x25 +#define FCAL_STATUS_INSUFFICIENT_CQES 0x26 +#define FCAL_STATUS_ALLOC_FAIL 0x27 +#define FCAL_STATUS_BAD_SID 0x28 +#define FCAL_STATUS_NO_SEQ_INIT 0x29 +#define FCAL_STATUS_BAD_DID 0x2a +#define FCAL_STATUS_ABORTED 0x30 +#define FCAL_STATUS_ABORT_FAILED 0x31 +#define FCAL_STATUS_DIAG_BUSY 0x32 +#define FCAL_STATUS_DIAG_INVALID 0x33 +#define FCAL_STATUS_INCOMPLETE_DMA_ERR 0x34 +#define FCAL_STATUS_CRC_ERR 0x35 +#define FCAL_STATUS_OPEN_FAIL 0x36 +#define FCAL_STATUS_ERROR 0x80 +#define FCAL_STATUS_ONLINE_TIMEOUT 0x81 +#define FCAL_STATUS_MAX_STATUS FCAL_STATUS_CRC_ERR + +typedef struct socal_stats { + uint_t version; /* version of this struct, >1 */ + uint_t resets; /* chip resets */ + uint_t reqq_intrs; /* request queue interrupts */ + uint_t qfulls; /* request queue full encountered */ + struct fc_pstats pstats[2]; /* per port kstats */ + char drvr_name[MAXNAMELEN]; /* Name of driver, NULL term. */ + char fw_revision[MAXNAMELEN]; /* Firmware date string.\0 */ + char node_wwn[17]; /* Node WWN */ + char port_wwn[2][17]; /* Port WWN \0 */ + uint_t parity_chk_enabled; /* != 0 if HBA checks parity. */ +} socal_stats_t; + + +struct ifp_target_stats { + int logouts_recvd; + /* + * unsolicited LOGOs recvd from + * target + */ + int task_mgmt_failures; + int data_ro_mismatches; + int dl_len_mismatches; +}; +typedef struct ifp_target_stats ifp_target_stats_t; + +struct ifp_stats { + int version; /* version of this struct, >1 */ + int lip_count; /* lips forced by ifp */ + int ncmds; /* outstanding commands */ + ifp_target_stats_t tstats[127]; /* per target stats */ + char drvr_name[MAXNAMELEN]; /* Name of driver, NULL term. */ + char fw_revision[MAXNAMELEN]; /* Firmware date string.\0 */ + char node_wwn[17]; /* Node WWN */ + char port_wwn[17]; /* Port WWN \0 */ + uint_t parity_chk_enabled; /* != 0 if HBA checks parity. */ + uint_t resp_status[FC_STATUS_ENTRIES]; /* response status */ +}; +typedef struct ifp_stats ifp_stats_t; + +/* + * Defines for the QLA21xx resp_status -- this is the command completion status + */ +#define IFP_CMD_CMPLT 0x00 /* no transport errors */ +#define IFP_CMD_INCOMPLETE 0x01 /* abnormal transport state */ +#define IFP_CMD_DMA_DERR 0x02 /* DMA direction error */ +#define IFP_CMD_TRAN_ERR 0x03 /* unspecified transport error */ +#define IFP_CMD_RESET 0x04 /* reset aborted transport */ +#define IFP_CMD_ABORTED 0x05 /* aborted on request */ +#define IFP_CMD_TIMEOUT 0x06 /* command timed out */ +#define IFP_CMD_DATA_OVR 0x07 /* data overrun--discard extra */ +#define IFP_CMD_ABORT_REJECTED 0x0e /* target rejected abort msg */ +#define IFP_CMD_RESET_REJECTED 0x12 /* target rejected reset msg */ +#define IFP_CMD_DATA_UNDER 0x15 /* data underrun */ +#define IFP_CMD_QUEUE_FULL 0x1c /* queue full SCSI status */ +#define IFP_CMD_PORT_UNAVAIL 0x28 /* port unavailable */ +#define IFP_CMD_PORT_LOGGED_OUT 0x29 /* port loged out */ +#define IFP_CMD_PORT_CONFIG_CHANGED 0x2a /* port name changed */ + + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FC4_FCIO_H */ diff --git a/illumos-x86_64/usr/include/sys/fc4/fcp.h b/illumos-x86_64/usr/include/sys/fc4/fcp.h new file mode 100644 index 00000000..523ab5bd --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fc4/fcp.h @@ -0,0 +1,235 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FC4_FCP_H +#define _SYS_FC4_FCP_H + +/* + * Frame format and protocol definitions for transferring + * commands and data between a SCSI initiator and target + * using an FC4 serial link interface. + */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * FCP Device Data Frame Information Categories + */ +#define FCP_SCSI_DATA 0x01 /* frame contains SCSI data */ +#define FCP_SCSI_CMD 0x02 /* frame contains SCSI command */ +#define FCP_SCSI_RSP 0x03 /* frame contains SCSI response */ +#define FCP_SCSI_XFER_RDY 0x05 /* frame contains xfer rdy block */ + + +/* + * FCP SCSI Control structure + */ +typedef struct fcp_cntl { + uchar_t cntl_reserved_0; /* reserved */ + uchar_t cntl_reserved_1 : 5, /* reserved */ + cntl_qtype : 3; /* tagged queueing type */ + uchar_t cntl_kill_tsk : 1, /* terminate task */ + cntl_clr_aca : 1, /* clear aca */ + cntl_reset : 1, /* reset */ + cntl_reserved_2 : 2, /* reserved */ + cntl_clr_tsk : 1, /* clear task set */ + cntl_abort_tsk : 1, /* abort task set */ + cntl_reserved_3 : 1; /* reserved */ + uchar_t cntl_reserved_4 : 6, /* reserved */ + cntl_read_data : 1, /* initiator read */ + cntl_write_data : 1; /* initiator write */ +} fcp_cntl_t; + +/* + * FCP SCSI Control Tagged Queueing types - cntl_qtype + */ +#define FCP_QTYPE_SIMPLE 0 /* simple queueing */ +#define FCP_QTYPE_HEAD_OF_Q 1 /* head of queue */ +#define FCP_QTYPE_ORDERED 2 /* ordered queueing */ +#define FCP_QTYPE_ACA_Q_TAG 4 /* ACA queueing */ +#define FCP_QTYPE_UNTAGGED 5 /* Untagged */ + + +/* + * FCP SCSI Entity Address + * + * ent_addr_0 is always the first and highest layer of + * the hierarchy. The depth of the hierarchy of addressing, + * up to a maximum of four layers, is arbitrary and + * device-dependent. + */ +typedef struct fcp_ent_addr { + ushort_t ent_addr_0; /* entity address 0 */ + ushort_t ent_addr_1; /* entity address 1 */ + ushort_t ent_addr_2; /* entity address 2 */ + ushort_t ent_addr_3; /* entity address 3 */ +} fcp_ent_addr_t; + + +/* + * Maximum size of SCSI cdb in FCP SCSI command + */ +#define FCP_CDB_SIZE 16 +#define FCP_LUN_SIZE 8 + +/* + * FCP SCSI command payload + */ +typedef struct fcp_cmd { + fcp_ent_addr_t fcp_ent_addr; /* entity address */ + fcp_cntl_t fcp_cntl; /* SCSI options */ + uchar_t fcp_cdb[FCP_CDB_SIZE]; /* SCSI cdb */ + int fcp_data_len; /* data length */ +} fcp_cmd_t; + + +/* + * FCP SCSI status + */ +typedef struct fcp_status { + ushort_t reserved_0; /* reserved */ + uchar_t reserved_1 : 4, /* reserved */ + resid_under : 1, /* resid non-zero */ + resid_over : 1, /* resid non-zero */ + sense_len_set : 1, /* sense_len non-zero */ + rsp_len_set : 1; /* response_len non-zero */ + uchar_t scsi_status; /* status of cmd */ +} fcp_status_t; + +#define resid_len_set resid_over /* for pln */ + + +/* + * FCP SCSI Response Payload + */ +typedef struct fcp_rsp { + uint_t reserved_0; /* reserved */ + uint_t reserved_1; /* reserved */ + union { + fcp_status_t fcp_status; /* command status */ + uint_t i_fcp_status; + }fcp_u; + uint_t fcp_resid; /* resid of operation */ + uint_t fcp_sense_len; /* sense data length */ + uint_t fcp_response_len; /* response data length */ + /* + * 'm' bytes of scsi response info follow + * 'n' bytes of scsi sense info follow + */ +} fcp_rsp_t; + +#define FCP_MAX_RSP_IU_SIZE 256 + +/* + * FCP RSP_INFO field format + */ + +struct fcp_rsp_info { + uchar_t resvd1; + uchar_t resvd2; + uchar_t resvd3; + uchar_t rsp_code; + uchar_t resvd4; + uchar_t resvd5; + uchar_t resvd6; + uchar_t resvd7; +}; + +/* RSP_CODE definitions */ + +#define FCP_NO_FAILURE 0x0 +#define FCP_DL_LEN_MISMATCH 0x1 +#define FCP_CMND_INVALID 0x2 +#define FCP_DATA_RO_MISMATCH 0x3 +#define FCP_TASK_MGMT_NOT_SUPPTD 0x4 +#define FCP_TASK_MGMT_FAILED 0x5 + + +/* + * FCP SCSI_ XFER_RDY Payload + */ +typedef struct fcp_xfer_rdy { + ulong_t fcp_seq_offset; /* relative offset */ + ulong_t fcp_burst_len; /* buffer space */ + ulong_t reserved; /* reserved */ +} fcp_xfer_rdy_t; + +/* + * FCP PRLI Payload + */ + +struct fcp_prli { + uchar_t type; + uchar_t resvd1; + uint_t orig_process_assoc_valid:1; + uint_t resp_process_assoc_valid:1; + uint_t establish_image_pair:1; + uint_t resvd2:13; + uint_t orig_process_associator; + uint_t resp_process_associator; + uint_t resvd3:25; + uint_t data_overlay_allowed:1; + uint_t initiator_fn:1; + uint_t target_fn:1; + uint_t cmd_data_mixed:1; + uint_t data_resp_mixed:1; + uint_t read_xfer_rdy_disabled:1; + uint_t write_xfer_rdy_disabled:1; +}; + +/* + * FCP PRLI ACC Payload + */ + +struct fcp_prli_acc { + uchar_t type; + uchar_t resvd1; + uint_t orig_process_assoc_valid:1; + uint_t resp_process_assoc_valid:1; + uint_t image_pair_establsihed:1; + uint_t resvd2:1; + uint_t accept_response_code:4; + uint_t resvd3:8; + uint_t orig_process_associator; + uint_t resp_process_associator; + uint_t resvd4:26; + uint_t initiator_fn:1; + uint_t target_fn:1; + uint_t cmd_data_mixed:1; + uint_t data_resp_mixed:1; + uint_t read_xfer_rdy_disabled:1; + uint_t write_xfer_rdy_disabled:1; +}; + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FC4_FCP_H */ diff --git a/illumos-x86_64/usr/include/sys/fc4/linkapp.h b/illumos-x86_64/usr/include/sys/fc4/linkapp.h new file mode 100644 index 00000000..4253814b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fc4/linkapp.h @@ -0,0 +1,217 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FC4_LINKAPP_H +#define _SYS_FC4_LINKAPP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * linkapp.h + * + * This file contains the definitions for structures and macros + * for fiber channel link application payloads and data. + */ + +/* + * Well Known Fiber Chaneel Addresses to reach the fabric for + * various services. + */ + +#define FS_GENERAL_MULTICAST 0xfffff7 +#define FS_WELL_KNOWN_MULTICAST 0xfffff8 +#define FS_HUNT_GROUP 0xfffff9 +#define FS_MANAGEMENT_SERVER 0xfffffa +#define FS_TIME_SERVER 0xfffffb +#define FS_NAME_SERVER 0xfffffc +#define FS_FABRIC_CONTROLLER 0xfffffd +#define FS_FABRIC_F_PORT 0xfffffe +#define FS_BROADCAST 0xffffff + +/* + * Link Application Opcodes. + */ + +#define LA_RJT 0x01000000 +#define LA_ACC 0x02000000 +#define LA_LOGI 0x03000000 +#define LA_LOGO 0x04000000 +#define LA_RLS 0x0d000000 +#define LA_IDENT 0x20000000 + +/* Basic Accept Payload. */ +typedef struct ba_acc { + uchar_t seq_id:8; + uchar_t org_s_id[3]; + ushort_t ox_id; + ushort_t rx_id; +} ba_acc_t; + +/* Basic Reject. */ +typedef struct ba_rjt { + uchar_t reseved; + uchar_t reason_code; + uchar_t explanation; + uchar_t vendor; +} ba_rjt_t; + +/* + * Basic Reject Reason Codes. + */ +#define RJT_INVALID_CMD 0x01 +#define RJT_LOGICAL_ERR 0x03 +#define RJT_LOGICAL_BUSY 0x05 +#define RJT_PROTOCOL_ERR 0x07 +#define RJT_UNABLE 0x09 +#define RJT_UNSUPPORTED 0x0B +#define RJT_VENDOR 0xFF + +/* + * Basic Reject Explanation Codes + */ +#define RJT_NOEXPLANATION 0x00 +#define RJT_INVALID_OSID 0x01 +#define RJT_INVALID_OXID_RXID 0x03 +#define RJT_INVALID_SEQID 0x05 +#define RJT_ABORT_INACTIVE_SEQ 0x07 +#define RJT_UNABLE_TO_SUPPLY 0x09 + +/* + * Service parameters. + */ +typedef struct common_service { + uint_t fcph; + uint_t btob_crdt; + uint_t cmn_features; + uint_t reserved; +} common_svc_t; + +typedef struct service_param { + uchar_t data[16]; +} svc_param_t; + +/* World Wide Name formats */ +typedef union la_wwn { + uchar_t raw_wwn[8]; + struct { + uint_t naa_id : 4; + uint_t nport_id : 12; + uint_t wwn_hi : 16; + uint_t wwn_lo; + } w; +} la_wwn_t; + +/* + * Values for naa_id + */ +#define NAA_ID_IEEE 1 +#define NAA_ID_IEEE_EXTENDED 2 + +/* Login Payload. */ +typedef struct la_logi { + unsigned code; + common_svc_t common_service; + + la_wwn_t nport_ww_name; + la_wwn_t node_ww_name; + + svc_param_t class_1; + svc_param_t class_2; + svc_param_t class_3; +} la_logi_t; + +#define SP_F_PORT_LOGIN 0x10 + +/* Read Link Error Status */ +typedef struct la_rls { + unsigned code; + uchar_t reserved; + uchar_t nport_id[3]; +} la_rls_t; + +/* Read Link Error Status Reply */ +typedef struct la_rls_reply { + unsigned code; + unsigned link_failure; + unsigned loss_of_sync; + unsigned loss_of_signal; + unsigned primitive; + unsigned invalid_transmission; + unsigned invalid_crc; +} la_rls_reply_t; + +/* Logout payload. */ +typedef struct la_logo { + unsigned cmd; +} la_logo_t; + +/* Logout reply payload. */ +typedef la_logo_t la_logo_reply_t; + +/* Link Application Reject */ +typedef struct la_rjt { + int code; + uchar_t reserved; + uchar_t reason_code; + uchar_t explanation; + uchar_t vendor; +} la_rjt_t; + +/* + * LA_RJT Reason Codes. + */ +#define LA_RJT_INVALID 0x01 +#define LA_RJT_LOGICAL_ERR 0x03 +#define LA_RJT_LOGICAL_BUSY 0x05 +#define LA_RJT_PROTOCOL_ERR 0x07 +#define LA_RJT_UNABLE_TO_PERFORM 0x09 +#define LA_RJT_NOT_SUPPORTED 0x0b +#define LA_RJT_VENDOR 0xff + +/* + * LA_RJT explanations + */ +#define LA_RJT_NOEXPLANATION 0x00 +#define LA_RJT_OPTIONS 0x01 +#define LA_RJT_INITIATOR 0x03 +#define LA_RJT_RECIPIENT 0x05 +#define LA_RJT_DATA_FIELD_SIZE 0x07 +#define LA_RJT_CONCURRENT 0x09 +#define LA_RJT_CREDIT 0x0b + +#define LA_RJT_INVALID_PORT_WWNAME 0x0d +#define LA_RJT_INVALID_NODE_WWNAME 0x0e +#define LA_RJT_INVALID_COMMON_SVC 0x0f + +#define LA_RJT_INSUFFICENT 0x29 + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_FC4_LINKAPP_H */ diff --git a/illumos-x86_64/usr/include/sys/fcntl.h b/illumos-x86_64/usr/include/sys/fcntl.h new file mode 100644 index 00000000..6f227a89 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fcntl.h @@ -0,0 +1,419 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +/* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ +/* Copyright 2020 Joyent, Inc. */ + +#ifndef _SYS_FCNTL_H +#define _SYS_FCNTL_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flag values accessible to open(2) and fcntl(2) + * The first five can only be set (exclusively) by open(2). + */ +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 +#define O_SEARCH 0x200000 +#define O_EXEC 0x400000 +#if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) +#define O_NDELAY 0x04 /* non-blocking I/O */ +#endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) */ +#define O_APPEND 0x08 /* append (writes guaranteed at the end) */ +#if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \ + (_POSIX_C_SOURCE > 2) || defined(_XOPEN_SOURCE) +#define O_SYNC 0x10 /* synchronized file update option */ +#define O_DSYNC 0x40 /* synchronized data update option */ +#define O_RSYNC 0x8000 /* synchronized file update option */ + /* defines read/write file integrity */ +#endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */ +#define O_NONBLOCK 0x80 /* non-blocking I/O (POSIX) */ +#ifdef _LARGEFILE_SOURCE +#define O_LARGEFILE 0x2000 +#endif + +/* + * Flag values accessible only to open(2). + */ +#define O_CREAT 0x100 /* open with file create (uses third arg) */ +#define O_TRUNC 0x200 /* open with truncation */ +#define O_EXCL 0x400 /* exclusive open */ +#define O_NOCTTY 0x800 /* don't allocate controlling tty (POSIX) */ +#define O_XATTR 0x4000 /* extended attribute */ +#define O_NOFOLLOW 0x20000 /* don't follow symlinks */ +#define O_NOLINKS 0x40000 /* don't allow multiple hard links */ +#define O_CLOEXEC 0x800000 /* set the close-on-exec flag */ +#if !defined(_STRICT_SYMBOLS) || defined(_XPG7) +#define O_DIRECTORY 0x1000000 /* fail if not a directory */ +#endif +#if !defined(_STRICT_SYMBOLS) +#define O_DIRECT 0x2000000 /* direct disk access hint */ +#endif +#if !defined(_STRICT_SYMBOLS) || defined(_XPG8) +#define O_CLOFORK 0x4000000 /* set the close-on-fork flag */ +#endif + +/* + * fcntl(2) requests + * + * N.B.: values are not necessarily assigned sequentially below. + */ +#define F_DUPFD 0 /* Duplicate fildes */ +#define F_GETFD 1 /* Get fildes flags */ +#define F_SETFD 2 /* Set fildes flags */ +#define F_GETFL 3 /* Get file flags */ +#define F_GETXFL 45 /* Get file flags including open-only flags */ +#define F_SETFL 4 /* Set file flags */ + +/* + * Applications that read /dev/mem must be built like the kernel. A + * new symbol "_KMEMUSER" is defined for this purpose. + */ +#if defined(_KERNEL) || defined(_KMEMUSER) +#define F_O_GETLK 5 /* SVR3 Get file lock (need for rfs, across */ + /* the wire compatibility */ +/* clustering: lock id contains both per-node sysid and node id */ +#define SYSIDMASK 0x0000ffff +#define GETSYSID(id) (id & SYSIDMASK) +#define NODEIDMASK 0xffff0000 +#define BITS_IN_SYSID 16 +#define GETNLMID(sysid) ((int)(((uint_t)(sysid) & NODEIDMASK) >> \ + BITS_IN_SYSID)) + +/* Clustering: Macro used for PXFS locks */ +#define GETPXFSID(sysid) ((int)(((uint_t)(sysid) & NODEIDMASK) >> \ + BITS_IN_SYSID)) +#endif /* defined(_KERNEL) */ + +#define F_CHKFL 8 /* Unused */ +#define F_DUP2FD 9 /* Duplicate fildes at third arg */ +#define F_DUP2FD_CLOEXEC 36 /* Like F_DUP2FD with O_CLOEXEC set */ + /* EINVAL is fildes matches arg1 */ +#define F_DUPFD_CLOEXEC 37 /* Like F_DUPFD with O_CLOEXEC set */ +#define F_DUP2FD_CLOFORK 57 /* This time with FD_CLOFORK */ +#define F_DUPFD_CLOFORK 58 /* Again, but with FD_CLOFORK */ +#define F_DUP3FD 59 /* Duplicate fildes, with flags */ + +#define F_ISSTREAM 13 /* Is the file desc. a stream ? */ +#define F_PRIV 15 /* Turn on private access to file */ +#define F_NPRIV 16 /* Turn off private access to file */ +#define F_QUOTACTL 17 /* UFS quota call */ +#define F_BLOCKS 18 /* Get number of BLKSIZE blocks allocated */ +#define F_BLKSIZE 19 /* Get optimal I/O block size */ +/* + * Numbers 20-22 have been removed and should not be reused. + */ +#define F_GETOWN 23 /* Get owner (socket emulation) */ +#define F_SETOWN 24 /* Set owner (socket emulation) */ +#define F_REVOKE 25 /* Object reuse revoke access to file desc. */ + +#define F_HASREMOTELOCKS 26 /* Does vp have NFS locks; private to lock */ + /* manager */ + +/* + * Commands that refer to flock structures. The argument types differ between + * the large and small file environments; therefore, the #defined values must + * as well. + * The NBMAND forms are private and should not be used. + * The FLOCK forms are also private and should not be used. + */ + +#if defined(_LP64) || _FILE_OFFSET_BITS == 32 +/* "Native" application compilation environment */ +#define F_SETLK 6 /* Set file lock */ +#define F_SETLKW 7 /* Set file lock and wait */ +#define F_ALLOCSP 10 /* Allocate file space */ +#define F_FREESP 11 /* Free file space */ +#define F_GETLK 14 /* Get file lock */ +#define F_SETLK_NBMAND 42 /* private */ +#if !defined(_STRICT_SYMBOLS) +#define F_OFD_GETLK 47 /* Get file lock owned by file */ +#define F_OFD_SETLK 48 /* Set file lock owned by file */ +#define F_OFD_SETLKW 49 /* Set file lock owned by file and wait */ +#define F_FLOCK 53 /* private - set flock owned by file */ +#define F_FLOCKW 54 /* private - set flock owned by file and wait */ +#endif /* _STRICT_SYMBOLS */ +#else +/* ILP32 large file application compilation environment version */ +#define F_SETLK 34 /* Set file lock */ +#define F_SETLKW 35 /* Set file lock and wait */ +#define F_ALLOCSP 28 /* Alllocate file space */ +#define F_FREESP 27 /* Free file space */ +#define F_GETLK 33 /* Get file lock */ +#define F_SETLK_NBMAND 44 /* private */ +#if !defined(_STRICT_SYMBOLS) +#define F_OFD_GETLK 50 /* Get file lock owned by file */ +#define F_OFD_SETLK 51 /* Set file lock owned by file */ +#define F_OFD_SETLKW 52 /* Set file lock owned by file and wait */ +#define F_FLOCK 55 /* private - set flock owned by file */ +#define F_FLOCKW 56 /* private - set flock owned by file and wait */ +#endif /* _STRICT_SYMBOLS */ +#endif /* _LP64 || _FILE_OFFSET_BITS == 32 */ + +#if defined(_LARGEFILE64_SOURCE) + +#if !defined(_LP64) || defined(_KERNEL) +/* + * transitional large file interface version + * These are only valid in a 32 bit application compiled with large files + * option, for source compatibility, the 64-bit versions are mapped back + * to the native versions. + */ +#define F_SETLK64 34 /* Set file lock */ +#define F_SETLKW64 35 /* Set file lock and wait */ +#define F_ALLOCSP64 28 /* Allocate file space */ +#define F_FREESP64 27 /* Free file space */ +#define F_GETLK64 33 /* Get file lock */ +#define F_SETLK64_NBMAND 44 /* private */ +#if !defined(_STRICT_SYMBOLS) +#define F_OFD_GETLK64 50 /* Get file lock owned by file */ +#define F_OFD_SETLK64 51 /* Set file lock owned by file */ +#define F_OFD_SETLKW64 52 /* Set file lock owned by file and wait */ +#define F_FLOCK64 55 /* private - set flock owned by file */ +#define F_FLOCKW64 56 /* private - set flock owned by file and wait */ +#endif /* _STRICT_SYMBOLS */ +#else +#define F_SETLK64 6 /* Set file lock */ +#define F_SETLKW64 7 /* Set file lock and wait */ +#define F_ALLOCSP64 10 /* Allocate file space */ +#define F_FREESP64 11 /* Free file space */ +#define F_GETLK64 14 /* Get file lock */ +#define F_SETLK64_NBMAND 42 /* private */ +#if !defined(_STRICT_SYMBOLS) +#define F_OFD_GETLK64 47 /* Get file lock owned by file */ +#define F_OFD_SETLK64 48 /* Set file lock owned by file */ +#define F_OFD_SETLKW64 49 /* Set file lock owned by file and wait */ +#define F_FLOCK64 53 /* private - set flock owned by file */ +#define F_FLOCKW64 54 /* private - set flock owned by file and wait */ +#endif /* _STRICT_SYMBOLS */ +#endif /* !_LP64 || _KERNEL */ + +#endif /* _LARGEFILE64_SOURCE */ + +#define F_SHARE 40 /* Set a file share reservation */ +#define F_UNSHARE 41 /* Remove a file share reservation */ +#define F_SHARE_NBMAND 43 /* private */ + +#define F_BADFD 46 /* Create Poison FD */ + +/* + * File segment locking set data type - information passed to system by user. + */ + +/* regular version, for both small and large file compilation environment */ +typedef struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; /* len == 0 means until end of file */ + int l_sysid; + pid_t l_pid; + long l_pad[4]; /* reserve area */ +} flock_t; + +#if defined(_SYSCALL32) + +/* Kernel's view of ILP32 flock structure */ + +typedef struct flock32 { + int16_t l_type; + int16_t l_whence; + off32_t l_start; + off32_t l_len; /* len == 0 means until end of file */ + int32_t l_sysid; + pid32_t l_pid; + int32_t l_pad[4]; /* reserve area */ +} flock32_t; + +#endif /* _SYSCALL32 */ + +/* transitional large file interface version */ + +#if defined(_LARGEFILE64_SOURCE) + +typedef struct flock64 { + short l_type; + short l_whence; + off64_t l_start; + off64_t l_len; /* len == 0 means until end of file */ + int l_sysid; + pid_t l_pid; + long l_pad[4]; /* reserve area */ +} flock64_t; + +#if defined(_SYSCALL32) + +/* Kernel's view of ILP32 flock64 */ + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct flock64_32 { + int16_t l_type; + int16_t l_whence; + off64_t l_start; + off64_t l_len; /* len == 0 means until end of file */ + int32_t l_sysid; + pid32_t l_pid; + int32_t l_pad[4]; /* reserve area */ +} flock64_32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* Kernel's view of LP64 flock64 */ + +typedef struct flock64_64 { + int16_t l_type; + int16_t l_whence; + off64_t l_start; + off64_t l_len; /* len == 0 means until end of file */ + int32_t l_sysid; + pid32_t l_pid; + int64_t l_pad[4]; /* reserve area */ +} flock64_64_t; + +#endif /* _SYSCALL32 */ + +#endif /* _LARGEFILE64_SOURCE */ + +#if defined(_KERNEL) || defined(_KMEMUSER) +/* SVr3 flock type; needed for rfs across the wire compatibility */ +typedef struct o_flock { + int16_t l_type; + int16_t l_whence; + int32_t l_start; + int32_t l_len; /* len == 0 means until end of file */ + int16_t l_sysid; + int16_t l_pid; +} o_flock_t; +#endif /* defined(_KERNEL) */ + +/* + * File segment locking types. + */ +#define F_RDLCK 01 /* Read lock */ +#define F_WRLCK 02 /* Write lock */ +#define F_UNLCK 03 /* Remove lock(s) */ +#define F_UNLKSYS 04 /* remove remote locks for a given system */ + +/* + * POSIX constants + */ + +/* Mask for file access modes */ +#define O_ACCMODE (O_SEARCH | O_EXEC | 0x3) +#define FD_CLOEXEC 1 /* close-on-exec flag */ +#define FD_CLOFORK 2 /* close-on-fork flag */ + +/* + * DIRECTIO + */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +#define DIRECTIO_OFF (0) +#define DIRECTIO_ON (1) + +/* + * File share reservation type + */ +typedef struct fshare { + short f_access; + short f_deny; + int f_id; +} fshare_t; + +/* + * f_access values + */ +#define F_RDACC 0x1 /* Read-only share access */ +#define F_WRACC 0x2 /* Write-only share access */ +#define F_RWACC 0x3 /* Read-Write share access */ +#define F_RMACC 0x4 /* private flag: Delete share access */ +#define F_MDACC 0x20 /* private flag: Metadata share access */ + +/* + * f_deny values + */ +#define F_NODNY 0x0 /* Don't deny others access */ +#define F_RDDNY 0x1 /* Deny others read share access */ +#define F_WRDNY 0x2 /* Deny others write share access */ +#define F_RWDNY 0x3 /* Deny others read or write share access */ +#define F_RMDNY 0x4 /* private flag: Deny delete share access */ +#define F_COMPAT 0x8 /* Set share to old DOS compatibility mode */ +#define F_MANDDNY 0x10 /* private flag: mandatory enforcement */ +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */ + +/* + * Special flags for functions such as openat(), fstatat().... + */ +#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ + defined(__EXTENSIONS__) + /* || defined(_XPG7) */ +#define AT_FDCWD 0xffd19553 +#define AT_SYMLINK_NOFOLLOW 0x1000 +#define AT_SYMLINK_FOLLOW 0x2000 /* only for linkat() */ +#define AT_REMOVEDIR 0x1 +#define _AT_TRIGGER 0x2 +#define AT_EACCESS 0x4 /* use EUID/EGID for access */ +#endif + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +/* advice for posix_fadvise */ +#define POSIX_FADV_NORMAL 0 +#define POSIX_FADV_RANDOM 1 +#define POSIX_FADV_SEQUENTIAL 2 +#define POSIX_FADV_WILLNEED 3 +#define POSIX_FADV_DONTNEED 4 +#define POSIX_FADV_NOREUSE 5 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FCNTL_H */ diff --git a/illumos-x86_64/usr/include/sys/fct.h b/illumos-x86_64/usr/include/sys/fct.h new file mode 100644 index 00000000..0960bbfb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fct.h @@ -0,0 +1,426 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. + * Copyright 2020 RackTop Systems, Inc. + */ +#ifndef _FCT_H +#define _FCT_H + +/* + * Definitions for common FC Target. + */ +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum fct_struct_id { + FCT_STRUCT_LOCAL_PORT = 1, + FCT_STRUCT_REMOTE_PORT, + FCT_STRUCT_CMD_RCVD_ELS, + FCT_STRUCT_CMD_SOL_ELS, + FCT_STRUCT_CMD_SOL_CT, + FCT_STRUCT_CMD_RCVD_ABTS, + FCT_STRUCT_CMD_FCP_XCHG, + FCT_STRUCT_DBUF_STORE, + + FCT_MAX_STRUCT_IDS +} fct_struct_id_t; + +typedef struct fct_remote_port { + void *rp_fct_private; + void *rp_fca_private; + + struct fct_local_port *rp_port; + char rp_nwwn_str[FC_WWN_BUFLEN]; + char rp_pwwn_str[FC_WWN_BUFLEN]; + uint8_t rp_nwwn[FC_WWN_LEN]; + uint8_t rp_pwwn[FC_WWN_LEN]; + uint32_t rp_id; /* 8 or 24 bit */ + uint32_t rp_hard_address; + uint16_t rp_handle; +} fct_remote_port_t; + +#define FCT_HANDLE_NONE 0xffff + +typedef struct fct_cmd { + void *cmd_fct_private; + void *cmd_fca_private; + void *cmd_specific; + + struct fct_local_port *cmd_port; + + /* During cmd porting this can be set to NULL */ + struct fct_remote_port *cmd_rp; + + /* To link cmds together for handling things like ABTS. */ + struct fct_cmd *cmd_link; + uint8_t cmd_type; + uint8_t cmd_rsvd1; + + /* During cmd posting this can be set to FCT_HANDLE_NONE */ + uint16_t cmd_rp_handle; + uint32_t cmd_handle; + uint32_t cmd_rportid; + uint32_t cmd_lportid; + uint32_t cmd_rsvd2; + uint16_t cmd_oxid; + uint16_t cmd_rxid; + fct_status_t cmd_comp_status; +} fct_cmd_t; + +/* + * fcmd_cmd_handle: Bit definitions. + * 31 23 15 7 0 + * +--------------+------------+------------+------------+ + * | V |uniq_cntr |fca specific| cmd slot index | + * +--------------+------------+------------+------------+ + * V = handle valid. + */ +#define CMD_HANDLE_SLOT_INDEX(x) ((x) & 0xffff) +#define CMD_HANDLE_VALID(x) ((x) & 0x80000000) + +enum fct_cmd_types { + FCT_CMD_FCP_XCHG = 0x0001, + FCT_CMD_RCVD_ELS = 0x0002, + FCT_CMD_SOL_ELS = 0x0004, + FCT_CMD_RCVD_ABTS = 0x0008, + FCT_CMD_SOL_CT = 0x0010, + + FCT_CMD_TYPE_ALL = 0xffff +}; + +typedef struct fct_els { + uint16_t els_req_size; + uint16_t els_resp_size; + uint16_t els_req_alloc_size; + uint16_t els_resp_alloc_size; + uint8_t *els_req_payload; + uint8_t *els_resp_payload; +} fct_els_t; + +typedef struct fct_sol_ct { + uint16_t ct_req_size; + uint16_t ct_resp_size; + uint16_t ct_req_alloc_size; + uint16_t ct_resp_alloc_size; + uint8_t *ct_req_payload; + uint8_t *ct_resp_payload; +} fct_sol_ct_t; + +typedef struct fct_rcvd_abts { + uint8_t abts_resp_rctl; /* Can be BA_ACC or BA_RJT */ + uint8_t abts_state; + uint16_t rsvd; + uint8_t abts_resp_payload[12]; +} fct_rcvd_abts_t; + +/* + * abts state + */ +#define ABTS_STATE_RECEIVED 0 +#define ABTS_STATE_RESPONDED 1 +#define ABTS_STATE_COMPLETED 2 +#define ABTS_STATE_ABORT_REQUESTED 3 +#define ABTS_STATE_ABORT_COMPLETED 4 + +#define FCHBA_MANUFACTURER_LEN 64 +#define FCHBA_SERIAL_NUMBER_LEN 64 +#define FCHBA_MODEL_LEN 256 +#define FCHBA_MODEL_DESCRIPTION_LEN 256 +#define FCHBA_HARDWARE_VERSION_LEN 256 +#define FCHBA_DRIVER_VERSION_LEN 256 +#define FCHBA_OPTION_ROM_VERSION_LEN 256 +#define FCHBA_FIRMWARE_VERSION_LEN 256 +#define FCHBA_DRIVER_NAME_LEN 256 +#define FCHBA_SYMB_NAME_LEN 255 + +#define FCT_INFO_LEN 160 +#define FCT_TASKQ_NAME_LEN 24 + +#define FC_TGT_PORT_INFO_CMD (((uint32_t)'I') << 24) +#define FC_TGT_PORT_RLS FC_TGT_PORT_INFO_CMD + 0x1 + +typedef struct fct_port_attrs { + char manufacturer[FCHBA_MANUFACTURER_LEN]; + char serial_number[FCHBA_SERIAL_NUMBER_LEN]; + char model[FCHBA_MODEL_LEN]; + char model_description[FCHBA_MODEL_DESCRIPTION_LEN]; + char hardware_version[FCHBA_HARDWARE_VERSION_LEN]; + char driver_version[FCHBA_DRIVER_VERSION_LEN]; + char option_rom_version[FCHBA_OPTION_ROM_VERSION_LEN]; + char firmware_version[FCHBA_FIRMWARE_VERSION_LEN]; + char driver_name[FCHBA_DRIVER_NAME_LEN]; + uint32_t vendor_specific_id; + uint32_t supported_cos; + uint32_t supported_speed; + uint32_t max_frame_size; +} fct_port_attrs_t; + +typedef struct fct_port_link_status { + uint32_t LinkFailureCount; + uint32_t LossOfSyncCount; + uint32_t LossOfSignalsCount; + uint32_t PrimitiveSeqProtocolErrorCount; + uint32_t InvalidTransmissionWordCount; + uint32_t InvalidCRCCount; +} fct_port_link_status_t; + +typedef struct fct_dbuf_store { + void *fds_fct_private; + void *fds_fca_private; + struct stmf_dbuf_store *fds_ds; + + stmf_data_buf_t *(*fds_alloc_data_buf)(struct fct_local_port *port, + uint32_t size, uint32_t *pminsize, uint32_t flags); + void (*fds_free_data_buf)(struct fct_dbuf_store *fds, + stmf_data_buf_t *dbuf); + stmf_status_t (*fds_setup_dbuf)(struct fct_local_port *port, + stmf_data_buf_t *dbuf, uint32_t flags); + void (*fds_teardown_dbuf)(struct fct_dbuf_store *fds, + stmf_data_buf_t *dbuf); + + uint32_t fds_max_sgl_xfer_len; + uint32_t fds_copy_threshold; +} fct_dbuf_store_t; + +#define FCT_FCA_MODREV_1 1 + +typedef struct fct_local_port { + void *port_fct_private; + void *port_fca_private; + stmf_local_port_t *port_lport; + + char port_nwwn_str[FC_WWN_BUFLEN]; + char port_pwwn_str[FC_WWN_BUFLEN]; + uint8_t port_nwwn[FC_WWN_LEN]; + uint8_t port_pwwn[FC_WWN_LEN]; + char *port_default_alias; + char *port_sym_node_name; + char *port_sym_port_name; + + stmf_port_provider_t *port_pp; + + uint32_t port_hard_address; + uint16_t port_max_logins; + uint16_t port_max_xchges; + uint32_t port_fca_fcp_cmd_size; + uint32_t port_fca_rp_private_size; + uint32_t port_fca_sol_els_private_size; + uint32_t port_fca_sol_ct_private_size; + + /* in milliseconds */ + uint32_t port_fca_abort_timeout; + + fct_dbuf_store_t *port_fds; + fct_status_t (*port_get_link_info)( + struct fct_local_port *port, struct fct_link_info *li); + fct_status_t (*port_register_remote_port)( + struct fct_local_port *port, struct fct_remote_port *rp, + struct fct_cmd *login_els); + fct_status_t (*port_deregister_remote_port)( + struct fct_local_port *port, struct fct_remote_port *rp); + fct_status_t (*port_send_cmd)(fct_cmd_t *cmd); + fct_status_t (*port_xfer_scsi_data)(fct_cmd_t *cmd, + stmf_data_buf_t *dbuf, uint32_t flags); + fct_status_t (*port_send_cmd_response)(fct_cmd_t *cmd, + uint32_t ioflags); + fct_status_t (*port_abort_cmd)(struct fct_local_port *port, + fct_cmd_t *cmd, uint32_t flags); + void (*port_ctl)(struct fct_local_port *port, + int cmd, void *arg); + fct_status_t (*port_flogi_xchg)(struct fct_local_port *port, + struct fct_flogi_xchg *fx); + void (*port_populate_hba_details)( + struct fct_local_port *port, struct fct_port_attrs *port_attrs); + fct_status_t (*port_info)(uint32_t cmd, + struct fct_local_port *port, void *arg, uint8_t *buf, + uint32_t *bufsizep); + int port_fca_version; +} fct_local_port_t; + +/* + * Common struct used during FLOGI exchange. + */ +typedef struct fct_flogi_xchg { + uint8_t fx_op; /* ELS_OP_FLOGI or ELS_OP_ACC/RJT */ + uint8_t fx_rjt_reason; + uint8_t fx_rjt_expl; + uint8_t fx_sec_timeout; /* Timeout in seconds */ + uint32_t fx_fport:1, /* 0=N_port, 1=F_port */ + rsvd2:31; + uint32_t fx_sid; /* 24 bit SID to use */ + uint32_t fx_did; /* 24 bit DID to use */ + uint8_t fx_pwwn[8]; + uint8_t fx_nwwn[8]; +} fct_flogi_xchg_t; + +typedef struct fct_link_info { + uint32_t portid; + uint8_t port_topology; + uint8_t port_speed; + + uint8_t rsvd:5, + + /* + * FCA sets this bit to indicate that fct does not need to do FLOGI + * because either FCA did the FLOGI or it determined that its a private + * loop. Setting this bit by FCA is optional. + */ + port_no_fct_flogi:1, + + /* FCA sets this bit to indicate that it did FLOGI */ + port_fca_flogi_done:1, + + /* FCT sets this bit to indicate that it did FLOGI */ + port_fct_flogi_done:1; + + uint8_t rsvd1; + + /* The fields below are only valid if someone did a successful flogi */ + uint8_t port_rnwwn[8]; + uint8_t port_rpwwn[8]; +} fct_link_info_t; + +typedef struct fct_port_stat { + kstat_named_t link_failure_cnt; + kstat_named_t loss_of_sync_cnt; + kstat_named_t loss_of_signals_cnt; + kstat_named_t prim_seq_protocol_err_cnt; + kstat_named_t invalid_tx_word_cnt; + kstat_named_t invalid_crc_cnt; +} fct_port_stat_t; + +/* + * port topology + */ +#define PORT_TOPOLOGY_UNKNOWN 0 +#define PORT_TOPOLOGY_PT_TO_PT 1 +#define PORT_TOPOLOGY_PRIVATE_LOOP 2 +#define PORT_TOPOLOGY_PUBLIC_LOOP 6 +#define PORT_TOPOLOGY_FABRIC_PT_TO_PT 5 +#define PORT_TOPOLOGY_FABRIC_BIT 4 + +#define PORT_FLOGI_DONE(li) (((li)->port_fca_flogi_done) || \ + ((li)->port_fct_flogi_done)) + +/* + * port speed + */ +#define PORT_SPEED_UNKNOWN 0 +#define PORT_SPEED_1G 1 +#define PORT_SPEED_2G 2 +#define PORT_SPEED_4G 4 +#define PORT_SPEED_8G 8 +#define PORT_SPEED_10G 16 +#define PORT_SPEED_16G 32 +#define PORT_SPEED_32G 64 + +/* + * Abort commands + */ +#define FCT_TERMINATE_CMD 1 + +/* + * FCT port states. + */ +#define FCT_STATE_OFFLINE 0 +#define FCT_STATE_ONLINING 1 +#define FCT_STATE_ONLINE 2 +#define FCT_STATE_OFFLINING 3 + +/* + * fct ctl commands. These should not conflict with stmf ctl commands + */ +#define FCT_CMD_PORT_ONLINE (STMF_LPORT_CTL_CMDS | 0x01) +#define FCT_CMD_PORT_ONLINE_COMPLETE (STMF_LPORT_CTL_CMDS | 0x02) +#define FCT_CMD_PORT_OFFLINE (STMF_LPORT_CTL_CMDS | 0x03) +#define FCT_CMD_PORT_OFFLINE_COMPLETE (STMF_LPORT_CTL_CMDS | 0x04) +#define FCT_ACK_PORT_ONLINE_COMPLETE (STMF_LPORT_CTL_CMDS | 0x05) +#define FCT_ACK_PORT_OFFLINE_COMPLETE (STMF_LPORT_CTL_CMDS | 0x06) +#define FCT_CMD_FORCE_LIP (STMF_LPORT_CTL_CMDS | 0x07) + +/* + * IO flags for cmd flow. + */ +#define FCT_IOF_FCA_DONE 0x10000 +#define FCT_IOF_FORCE_FCA_DONE 0x20000 + +/* + * Fill CTIU preamble + */ +#ifdef lint +#define FCT_FILL_CTIU_PREAMBLE(x_payload, x_ctop) _NOTE(EMPTY) +#else +#define FCT_FILL_CTIU_PREAMBLE(x_payload, x_ctop) \ + do { \ + x_payload[0] = 0x01; \ + x_payload[4] = 0xFC; \ + x_payload[5] = 0x02; \ + x_payload[8] = 0xFF & (x_ctop >> 8); \ + x_payload[9] = 0xFF & (x_ctop); \ + } while (0) +#endif + +uint64_t fct_netbuf_to_value(uint8_t *buf, uint8_t nbytes); +void fct_value_to_netbuf(uint64_t value, uint8_t *buf, uint8_t nbytes); +void *fct_alloc(fct_struct_id_t struct_id, int additional_size, int flags); +void fct_free(void *ptr); +fct_cmd_t *fct_scsi_task_alloc(struct fct_local_port *port, + uint16_t rp_handle, uint32_t rportid, uint8_t *lun, + uint16_t cdb_length, uint16_t task_ext); +fct_status_t fct_register_local_port(fct_local_port_t *port); +fct_status_t fct_deregister_local_port(fct_local_port_t *port); +void fct_handle_event(fct_local_port_t *port, int event_id, + uint32_t event_flags, caddr_t arg); +void fct_post_rcvd_cmd(fct_cmd_t *cmd, stmf_data_buf_t *dbuf); +void fct_queue_cmd_for_termination(fct_cmd_t *cmd, fct_status_t s); +void fct_queue_scsi_task_for_termination(fct_cmd_t *cmd, fct_status_t s); +fct_cmd_t *fct_handle_to_cmd(fct_local_port_t *port, uint32_t fct_handle); +void fct_ctl(struct stmf_local_port *lport, int cmd, void *arg); +void fct_cmd_fca_aborted(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags); +uint16_t fct_get_rp_handle(fct_local_port_t *port, uint32_t rportid); +void fct_send_response_done(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags); +void fct_send_cmd_done(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags); +void fct_scsi_data_xfer_done(fct_cmd_t *cmd, stmf_data_buf_t *dbuf, + uint32_t ioflags); +fct_status_t fct_port_initialize(fct_local_port_t *port, uint32_t rflags, + char *additional_info); +fct_status_t fct_port_shutdown(fct_local_port_t *port, uint32_t rflags, + char *additional_info); +fct_status_t fct_handle_rcvd_flogi(fct_local_port_t *port, + fct_flogi_xchg_t *fx); +void fct_log_local_port_event(fct_local_port_t *port, char *subclass); +void fct_log_remote_port_event(fct_local_port_t *port, char *subclass, + uint8_t *rp_pwwn, uint32_t rp_id); +void fct_wwn_to_str(char *to_ptr, const uint8_t *from_ptr); + +#ifdef __cplusplus +} +#endif + +#endif /* _FCT_H */ diff --git a/illumos-x86_64/usr/include/sys/fct_defines.h b/illumos-x86_64/usr/include/sys/fct_defines.h new file mode 100644 index 00000000..79db9f12 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fct_defines.h @@ -0,0 +1,227 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +#ifndef _FCT_DEFINES_H +#define _FCT_DEFINES_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef stmf_status_t fct_status_t; +/* + * Error codes + */ +#define FCT_SUCCESS STMF_SUCCESS +#define FCT_FAILURE STMF_TARGET_FAILURE +#define FCT_FCA_FAILURE (FCT_FAILURE | (uint64_t)0x0100000000000000) +#define FCT_BUSY STMF_BUSY +#define FCT_ABORT_SUCCESS STMF_ABORT_SUCCESS +#define FCT_ABORTED STMF_ABORTED +#define FCT_NOT_FOUND STMF_NOT_FOUND +#define FCT_TIMEOUT STMF_TIMEOUT + +#define FCT_WORKER_STUCK (FCT_FAILURE | STMF_FSC(1)) +#define FCT_ALLOC_FAILURE (FCT_FAILURE | STMF_FSC(2)) +#define FCT_LOCAL_PORT_OFFLINE (FCT_FAILURE | STMF_FSC(3)) +#define FCT_NO_XCHG_RESOURCE (FCT_FAILURE | STMF_FSC(4)) +#define FCT_NOT_LOGGED_IN (FCT_FAILURE | STMF_FSC(5)) +#define FCT_ABTS_RECEIVED (FCT_FAILURE | STMF_FSC(6)) +#define FCT_RPORT_SENT_REJECT (FCT_FAILURE | STMF_FSC(7)) + +#define FCT_REJECT_STATUS(reason, expln) \ + (FCT_RPORT_SENT_REJECT | (((uint64_t)(reason)) << 8) | \ + ((uint64_t)(expln))) + +/* + * Event codes + */ +#define FCT_EVENT_LINK_UP 0x01 +#define FCT_EVENT_LINK_DOWN 0x02 +#define FCT_EVENT_LINK_RESET 0x03 +#define FCT_EVENT_ADAPTER_FATAL 0x04 + +/* + * ELS OP codes + */ +#define ELS_OP_LSRJT 0x01 +#define ELS_OP_ACC 0x02 +#define ELS_OP_PLOGI 0x03 +#define ELS_OP_FLOGI 0x04 +#define ELS_OP_LOGO 0x05 +#define ELS_OP_ABTX 0x06 +#define ELS_OP_RLS 0x0f +#define ELS_OP_ECHO 0x10 +#define ELS_OP_REC 0x13 +#define ELS_OP_SRR 0x14 +#define ELS_OP_PRLI 0x20 +#define ELS_OP_PRLO 0x21 +#define ELS_OP_SCN 0x22 +#define ELS_OP_TPRLO 0x24 +#define ELS_OP_PDISC 0x50 +#define ELS_OP_ADISC 0x52 +#define ELS_OP_RSCN 0x61 +#define ELS_OP_SCR 0x62 +#define ELS_OP_RNID 0x78 + +/* + * BLS replies + */ +#define BLS_OP_BA_ACC 0x84 +#define BLS_OP_BA_RJT 0x85 + +/* + * Name Service Command Codes + */ +#define NS_GA_NXT 0x0100 /* Get All next */ +#define NS_GPN_ID 0x0112 /* Get Port Name */ +#define NS_GNN_ID 0x0113 /* Get Node Name */ +#define NS_GCS_ID 0x0114 /* Get Class Of service */ +#define NS_GFT_ID 0x0117 /* Get FC-4 Types */ +#define NS_GSPN_ID 0x0118 /* Get Sym Port name */ +#define NS_GPT_ID 0x011A /* Get Port Type */ +#define NS_GID_PN 0x0121 /* Get port id for PN */ +#define NS_GID_NN 0x0131 /* Get port id for NN */ +#define NS_GIP_NN 0x0135 /* Get IP address */ +#define NS_GIPA_NN 0x0136 /* Get I.P.A */ +#define NS_GSNN_NN 0x0139 /* Get Sym Node name */ +#define NS_GNN_IP 0x0153 /* Get Node name for IP */ +#define NS_GIPA_IP 0x0156 /* Get I.P.A for IP */ +#define NS_GID_FT 0x0171 /* Get port Id for FC-4 type */ +#define NS_GID_PT 0x01A1 /* Get port Id for type */ +#define NS_RPN_ID 0x0212 /* Reg port name */ +#define NS_RNN_ID 0x0213 /* Reg node name */ +#define NS_RCS_ID 0x0214 /* Reg C.O.S */ +#define NS_RFT_ID 0x0217 /* Reg FC-4 Types */ +#define NS_RSPN_ID 0x0218 /* Reg Sym Port name */ +#define NS_RPT_ID 0x021A /* Reg Port Type */ +#define NS_RIP_NN 0x0235 /* Reg I.P address */ +#define NS_RIPA_NN 0x0236 /* Reg I.P.A */ +#define NS_RSNN_NN 0x0239 /* Reg Sym Node name */ +#define NS_DA_ID 0x0300 /* De-Register all */ + +#define CT_OP_RJT 0x8001 +#define CT_OP_ACC 0x8002 + +/* + * PRLI bits + */ +#define PRLI_BIT_WRITE_XRDY_DISABLED 0x00000001 +#define PRLI_BIT_READ_XRDY_DISABLED 0x00000002 +#define PRLI_BIT_TARGET_FUNCTION 0x00000010 +#define PRLI_BIT_INITIATOR_FUNCTION 0x00000020 +#define PRLI_BIT_DATA_OVERLAY_ALLOWED 0x00000040 +#define PRLI_BIT_FCP_CONF_ALLOWED 0x00000080 +#define PRLI_BIT_RETRY 0x00000100 +#define PRLI_BIT_TASK_RETRY_IDENT_REQUESTED 0x00000200 +#define PRLI_BIT_REC_SUPPORT 0x00000400 + +#define FC_NS_CLASSF 0x01 +#define FC_NS_CLASS1 0x02 +#define FC_NS_CLASS2 0x04 +#define FC_NS_CLASS3 0x08 +#define FC_NS_CLASS4 0x10 +#define FC_NS_CLASS5 0x20 +#define FC_NS_CLASS6 0x40 + +/* + * SCR function code + */ +#define FC_SCR_FABRIC_REGISTRATION 0x01 +#define FC_SCR_NPORT_REGISTRATION 0x02 +#define FC_SCR_FULL_REGISTRATION 0x03 +#define FC_SCR_CLEAR_REGISTRATION 0xFF + +/* + * FCP_CNTL bits + */ +#define FCP_CNTL_TASK_ATTR(fcp_cntl) ((((uint32_t)(fcp_cntl)) >> 16) & 7) +#define TASK_ATTR_SIMPLE_Q 0 +#define TASK_ATTR_HEAD_OF_Q 1 +#define TASK_ATTR_ORDERED_Q 2 +#define TASK_ATTR_ACA_Q 4 +#define TASK_ATTR_UNTAGGED 5 +#define FCP_CNTL_IS_TASK_MGMT(fcp_cntl) (((uint32_t)(fcp_cntl)) & 0xff00) +#define FCP_CNTL_TERMINATE_TASK 0x8000 +#define FCP_CNTL_CLEAR_ACA 0x4000 +#define FCP_CNTL_TARGET_RESET 0x2000 +#define FCP_CNTL_LUN_RESET 0x1000 +#define FCP_CNTL_CLEAR_TASK_SET 0x0400 +#define FCP_CNTL_ABORT_TASK_SET 0x0200 +#define FCP_CNTL_READ_DATA 0x2 +#define FCP_CNTL_WRITE_DATA 0x1 + +/* + * SCSI STATUS BITS + */ +#define FCP_BIDI_RESP 0x8000 +#define FCP_BIDI_UNDER 0x4000 +#define FCP_BIDI_OVER 0x2000 +#define FCP_CONF_REQ 0x1000 +#define FCP_RESID_UNDER 0x0800 +#define FCP_RESID_OVER 0x0400 +#define FCP_SNS_LEN_VALID 0x0200 +#define FCP_RESP_LEN_VALID 0x0100 + +/* + * Well known addresses ... + */ +#define NPORT_ID_DOM_CTLR_START 0xFFFC01 +#define NPORT_ID_DOM_CTLR_END 0xFFFCFE + +#define FS_GENERAL_MULTICAST 0xFFFFF7 +#define FS_WELL_KNOWN_MULTICAST 0xFFFFF8 +#define FS_HUNT_GROUP 0xFFFFF9 +#define FS_MANAGEMENT_SERVER 0xFFFFFA +#define FS_TIME_SERVER 0xFFFFFB +#define FS_NAME_SERVER 0xFFFFFC +#define FS_FABRIC_CONTROLLER 0xFFFFFD +#define FS_FABRIC_F_PORT 0xFFFFFE +#define FS_BROADCAST 0xFFFFFF + +#define FC_WELL_KNOWN_START 0xFFFFF0 +#define FC_WELL_KNOWN_END 0xFFFFFF +#define FC_WELL_KNOWN_ADDR(x) \ + ((((x) >= FC_WELL_KNOWN_START) && ((x) <= FC_WELL_KNOWN_END)) ||\ + (((x) >= NPORT_ID_DOM_CTLR_START) && ((x) <= NPORT_ID_DOM_CTLR_END))) + +#define FC_WWN_LEN 8 +/* + * NB: FC_WWN_BUFLEN should be 64-bit aligned (divisible by 8). + */ +#define FC_WWN_BUFLEN (FC_WWN_LEN * 3) +#define FC_WWN_STRLEN (FC_WWN_BUFLEN - 1) /* add trailing null */ + +struct fct_cmd; +struct fct_local_port; +struct fct_els; +struct fct_link_info; +struct fct_flogi_xchg; +struct fct_dbuf_store; + +#ifdef __cplusplus +} +#endif + +#endif /* _FCT_DEFINES_H */ diff --git a/illumos-x86_64/usr/include/sys/fctio.h b/illumos-x86_64/usr/include/sys/fctio.h new file mode 100644 index 00000000..f9cda2d7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fctio.h @@ -0,0 +1,196 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2020 RackTop Systems, Inc. + */ +#ifndef _FCTIO_H +#define _FCTIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define FCT_IOCTL (((uint32_t)'F') << 24) +#define FCTIO_CMD (FCT_IOCTL | 2007) +#define FCTIO_SUB_CMD ('Z' << 8) +#define FCTIO_ADAPTER_LIST (FCTIO_SUB_CMD + 0x01) +#define FCTIO_GET_ADAPTER_ATTRIBUTES (FCTIO_SUB_CMD + 0x02) +#define FCTIO_GET_ADAPTER_PORT_ATTRIBUTES (FCTIO_SUB_CMD + 0x03) +#define FCTIO_GET_DISCOVERED_PORT_ATTRIBUTES (FCTIO_SUB_CMD + 0x04) +#define FCTIO_GET_PORT_ATTRIBUTES (FCTIO_SUB_CMD + 0x05) +#define FCTIO_GET_ADAPTER_PORT_STATS (FCTIO_SUB_CMD + 0x06) +#define FCTIO_GET_LINK_STATUS (FCTIO_SUB_CMD + 0x07) +#define FCTIO_FORCE_LIP (FCTIO_SUB_CMD + 0x08) + +/* + * fcio_xfer definitions + */ +#define FCTIO_XFER_NONE 0x00 +#define FCTIO_XFER_READ 0x01 +#define FCTIO_XFER_WRITE 0x02 +#define FCTIO_XFER_RW (FCTIO_XFER_READ | FCTIO_XFER_WRITE) + +typedef struct fctio { + uint16_t fctio_xfer; /* direction */ + uint16_t fctio_cmd; /* sub command */ + uint16_t fctio_flags; /* flags */ + uint16_t fctio_cmd_flags; /* command specific flags */ + uint32_t fctio_ilen; /* Input buffer length */ + uint32_t fctio_olen; /* Output buffer length */ + uint32_t fctio_alen; /* Auxillary buffer length */ + uint32_t fctio_errno; /* FC internal error code */ + uint64_t fctio_ibuf; /* Input buffer */ + uint64_t fctio_obuf; /* Output buffer */ + uint64_t fctio_abuf; /* Auxillary buffer */ +} fctio_t; + +#define FCT_HBA_LIST_VERSION 1 +typedef struct fc_tgt_hba_list { + uint32_t version; + uint32_t numPorts; + uint8_t port_wwn[1][8]; +} fc_tgt_hba_list_t; + +#define FCT_HBA_ADAPTER_ATTRIBUTES_VERSION 1 +typedef struct fc_tgt_hba_adapter_attributes { + uint32_t version; /* Set to FC_HBA_ADAPTER_ATTRIBUTES_VERSION */ + uint32_t reserved_1; + char Manufacturer[64]; + char SerialNumber[64]; + char Model[256]; + char ModelDescription[256]; + uint8_t NodeWWN[8]; + char NodeSymbolicName[256]; + char HardwareVersion[256]; + char DriverVersion[256]; + char OptionROMVersion[256]; + char FirmwareVersion[256]; + uint32_t VendorSpecificID; + uint32_t NumberOfPorts; + char DriverName[256]; + uint64_t reserved_2; +} fc_tgt_hba_adapter_attributes_t; + +#define FCT_HBA_PORT_ATTRIBUTES_VERSION 1 +typedef struct fc_tgt_hba_port_attributes { + uint32_t version; /* FC_HBA_PORT_ATTRIBUTES_VERSION */ + uint32_t reserved_1; + uint64_t lastChange; + uint8_t NodeWWN[8]; + uint8_t PortWWN[8]; + uint32_t PortFcId; + uint32_t PortType; + uint32_t PortState; + uint32_t PortSupportedClassofService; + uint8_t PortSupportedFc4Types[32]; + uint8_t PortActiveFc4Types[32]; + char PortSymbolicName[256]; + uint32_t PortSupportedSpeed; + uint32_t PortSpeed; + uint32_t PortMaxFrameSize; + uint32_t NumberofDiscoveredPorts; + uint8_t FabricName[8]; + uint64_t reserved_2; +} fc_tgt_hba_port_attributes_t; + +#define FCT_HBA_ADAPTER_PORT_STATS_VERSION 1 +typedef struct fc_tgt_hba_adapter_port_stats { + uint32_t version; /* FC_HBA_ADAPTER_PORT_STATS_VERSION */ + uint32_t reserved_1; + uint64_t SecondsSinceLastReset; + uint64_t TxFrames; + uint64_t TxWords; + uint64_t RxFrames; + uint64_t RxWords; + uint64_t LIPCount; + uint64_t NOSCount; + uint64_t ErrorFrames; + uint64_t DumpedFrames; + uint64_t LinkFailureCount; + uint64_t LossOfSyncCount; + uint64_t LossOfSignalCount; + uint64_t PrimitiveSeqProtocolErrCount; + uint64_t InvalidTxWordCount; + uint64_t InvalidCRCCount; + uint64_t reserved_2; +} fc_tgt_hba_adapter_port_stats_t; + +/* + * Constant values derived from T11 FC-HBA + */ +#define FC_HBA_PORTTYPE_UNKNOWN 1 /* Unknown */ +#define FC_HBA_PORTTYPE_OTHER 2 /* Other */ +#define FC_HBA_PORTTYPE_NOTPRESENT 3 /* Not present */ +#define FC_HBA_PORTTYPE_NPORT 5 /* Fabric */ +#define FC_HBA_PORTTYPE_NLPORT 6 /* Public Loop */ +#define FC_HBA_PORTTYPE_FLPORT 7 +#define FC_HBA_PORTTYPE_FPORT 8 /* Fabric Port */ +#define FC_HBA_PORTTYPE_EPORT 9 /* Fabric expansion port */ +#define FC_HBA_PORTTYPE_GPORT 10 /* Generic Fabric Port */ +#define FC_HBA_PORTTYPE_LPORT 20 /* Private Loop */ +#define FC_HBA_PORTTYPE_PTP 21 /* Point to Point */ + +#define FC_HBA_PORTSTATE_UNKNOWN 1 /* Unknown */ +#define FC_HBA_PORTSTATE_ONLINE 2 /* Operational */ +#define FC_HBA_PORTSTATE_OFFLINE 3 /* User Offline */ +#define FC_HBA_PORTSTATE_BYPASSED 4 /* Bypassed */ +#define FC_HBA_PORTSTATE_DIAGNOSTICS 5 /* In diagnostics mode */ +#define FC_HBA_PORTSTATE_LINKDOWN 6 /* Link Down */ +#define FC_HBA_PORTSTATE_ERROR 7 /* Port Error */ +#define FC_HBA_PORTSTATE_LOOPBACK 8 /* Loopback */ + +/* + * HBA/Port attributes tracked for the T11 FC-HBA specification + */ +#define FC_HBA_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver */ + /* incable of reporting */ +#define FC_HBA_PORTSPEED_1GBIT 1 /* 1 GBit/sec */ +#define FC_HBA_PORTSPEED_2GBIT 2 /* 2 GBit/sec */ +#define FC_HBA_PORTSPEED_10GBIT 4 /* 10 GBit/sec */ +#define FC_HBA_PORTSPEED_4GBIT 8 /* 4 GBit/sec */ +#define FC_HBA_PORTSPEED_8GBIT 16 /* 8 GBit/sec */ +#define FC_HBA_PORTSPEED_16GBIT 32 /* 16 GBit/sec */ +#define FC_HBA_PORTSPEED_32GBIT 64 /* 32 GBit/sec */ +#define FC_HBA_PORTSPEED_NOT_NEGOTIATED (1<<15) /* Speed not established */ + +#define FCTIO_SUCCESS 0 +#define FCTIO_FAILURE 1 +#define FCTIO_BADWWN 2 +#define FCTIO_MOREDATA 3 +#define FCTIO_OUTOFBOUNDS 4 + +/* Sysevent defs */ +#define EC_SUNFC "EC_sunfc" +#define ESC_SUNFC_PORT_ATTACH "ESC_sunfc_port_attach" +#define ESC_SUNFC_PORT_DETACH "ESC_sunfc_port_detach" +#define ESC_SUNFC_PORT_ONLINE "ESC_sunfc_port_online" +#define ESC_SUNFC_PORT_OFFLINE "ESC_sunfc_port_offline" +#define ESC_SUNFC_PORT_RSCN "ESC_sunfc_port_rscn" +#define ESC_SUNFC_TARGET_ADD "ESC_sunfc_target_add" +#define ESC_SUNFC_TARGET_REMOVE "ESC_sunfc_target_remove" + +#ifdef __cplusplus +} +#endif + +#endif /* _FCTIO_H */ diff --git a/illumos-x86_64/usr/include/sys/fdbuffer.h b/illumos-x86_64/usr/include/sys/fdbuffer.h new file mode 100644 index 00000000..1e8144ac --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fdbuffer.h @@ -0,0 +1,162 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FDBUFFER_H +#define _SYS_FDBUFFER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef enum { + FDB_PAGEIO, /* fdbuffer is a page buffer */ + FDB_VADDR /* fdbuffer is a address buffer */ +} fdb_type_t; + +#define FDB_READ 0x01 /* fdbuffer is readable */ +#define FDB_WRITE 0x02 /* fdbuffer is asked for write */ +#define FDB_DONE 0x04 /* fdbuffer buffer io done */ +#define FDB_ERROR 0x08 /* fdbuffer in error state */ +#define FDB_ASYNC 0x10 /* fdbuffer using async i/o requests */ +#define FDB_SYNC 0x20 /* fdbuffer using direct i/o requests */ +#define FDB_ICALLBACK 0x40 /* fdbuffer immediate call back */ +#define FDB_ZEROHOLE 0x80 /* fdbuffer auto-zero holes */ + +typedef struct fdb_holes { + struct fdb_holes *next_hole; + u_offset_t off; /* start offset for this hole */ + size_t len; /* length of this hole */ +} fdb_holes_t; + +struct fdbuffer; + +typedef void (*fdb_iodone_t)(struct fdbuffer *fdbuf, void *kargp, buf_t *bp); + + +/* + * Implementation notes in the fdbuffer structure members: + * + * fd_state: The state variable carries four distinct types of information + * it could probably be a bit field as such. + * + * READ/WRITE: + * This information is stored in fdbuffer at the time the + * The buffer is created and is used for sanity check in + * subsequent calls to fdb_iosetup(). This information + * persists for the entire life of the buffer. + * + * [A]SYNC: + * The buffer can be either in sync or async mode. In + * async mode all calls are to be async and the i/o + * must take place for the entire range or the fdbuf + * i/o must be ended with a call to fdb_ioerrdone() + * In the async case the call back is made either + * for every i/o completed or only once at the end + * of i/o. This depends on how the call back function + * is registered. See fdb_set_iofunc(). The fdbuf has + * to be freed by the call back function. + * + * ZEROHOLE: + * This is the case the holes are to be zeroed. Note + * that we do not zero the holes when fdb_add_hole() is + * getting called. We leave the zeroing of the holes to + * when a list is requested or the buffer is freed. This + * so that we can avoid zeroing pages while holding ufs + * locks. + */ + + +typedef struct fdbuffer { + fdb_type_t fd_type; /* type of buffer */ + int fd_state; /* state of the fdbfer */ + size_t fd_len; /* length of this fdbuffer */ + size_t fd_iocount; /* total io acked, includes errors and holes */ + int fd_iodispatch; /* # of io's dispatched */ + int fd_err; /* last i/o error due from buf_t */ + ssize_t fd_resid; /* total len in error */ + + buf_t *fd_parentbp; /* buf associated with parent buf */ + + union { + page_t *pages; /* page list for FDPAGE_BUF */ + caddr_t addr; /* address for FDADDR_BUF */ + } fd_un; + + fdb_holes_t *fd_holes; /* holes list if this fdbuffer has holes */ + + page_t **fd_shadow; /* shadow pages used for direct i/o to uspace */ + struct proc *fd_procp; /* procp used in bp for direct i/o to uspace */ + + /* + * Call this function when the I/O on the full range of fdbuffer + * is completed. The call is made only if the i/o requests + * are asynchronous. + */ + + fdb_iodone_t fd_iofunc; + void *fd_iargp; /* iodone function argument to be passed */ + + /* + * The mutex protects iodispatch, iocount, state, and resid + * flags and variables since they are examined and updated by + * async call backs. All other structure members are modified + * in a single threaded fashion and do not require a lock. + */ + kmutex_t fd_mutex; + +} fdbuffer_t; + +#define fd_pages fd_un.pages +#define fd_addr fd_un.addr + +extern fdbuffer_t *fdb_page_create(page_t *pp, size_t len, int flag); +extern fdbuffer_t *fdb_addr_create(caddr_t addr, size_t len, int flag, + page_t **pplist, struct proc *procp); + +extern void fdb_set_iofunc(fdbuffer_t *fdbuf, fdb_iodone_t iofunc, void *ioarg, + int flags); +extern fdb_holes_t *fdb_get_holes(fdbuffer_t *fdbuf); +extern int fdb_get_error(fdbuffer_t *fdbuf); +extern void fdb_free(fdbuffer_t *fdbuf); +/* + * Need to add: + * fdb_get_iolen + */ +extern void fdb_add_hole(fdbuffer_t *fdbuf, u_offset_t off, size_t len); +extern buf_t *fdb_iosetup(fdbuffer_t *fdbuf, u_offset_t off, size_t len, + struct vnode *vn, int flags); +extern int fdb_iodone(buf_t *bufp); +extern void fdb_ioerrdone(fdbuffer_t *fdbuf, int error); +extern void fdb_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FDBUFFER_H */ diff --git a/illumos-x86_64/usr/include/sys/fdio.h b/illumos-x86_64/usr/include/sys/fdio.h new file mode 100644 index 00000000..b7fb0ce0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fdio.h @@ -0,0 +1,206 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FDIO_H +#define _SYS_FDIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Floppy Disk Characteristic Structure + */ +struct fd_char { + uchar_t fdc_medium; /* medium type. */ + int fdc_transfer_rate; /* transfer rate */ + int fdc_ncyl; /* number of cylinders */ + int fdc_nhead; /* number of heads */ + int fdc_sec_size; /* sector size */ + int fdc_secptrack; /* sectors per track */ + int fdc_steps; /* number of steps per */ +}; + +/* + * Floppy State Structure + */ +struct fd_state { + int fds_bsec; /* bytes per sector */ + int fds_strack; /* sectors per track */ + int fds_step; /* step rate */ + int fds_rate; /* data rate */ + int fds_error; /* error returned by controller */ +}; + +/* + * Used by FDGETCHANGE, return state of the sense disk change bit. + */ +#define FDGC_HISTORY 0x01 /* disk has changed since last i/o */ +#define FDGC_CURRENT 0x02 /* current state of disk change */ +#define FDGC_CURWPROT 0x10 /* current state of write protect */ +#define FDGC_DETECTED 0x20 /* previous state of DISK CHANGE */ + +/* + * Used by FD{G, S}ETDRIVECHAR + */ +struct fd_drive { + int fdd_ejectable; /* does the drive support eject? */ + int fdd_maxsearch; /* size of per-unit search table */ + + int fdd_writeprecomp; /* cyl to start write prcompensation */ + int fdd_writereduce; /* cyl to start recucing write current */ + int fdd_stepwidth; /* width of step pulse in 1 us units */ + int fdd_steprate; /* step rate in 100 us units */ + int fdd_headsettle; /* delay, in 100 us units */ + int fdd_headload; /* delay, in 100 us units */ + int fdd_headunload; /* delay, in 100 us units */ + int fdd_motoron; /* delay, in 100 ms units */ + int fdd_motoroff; /* delay, in 100 ms units */ + int fdd_precomplevel; /* bit shift, in nano-secs */ + int fdd_pins; /* defines meaning of pin 1, 2, 4, and 34 */ + int fdd_flags; /* TRUE READY, Starting Sector #, & Motor On */ +}; + +/* + * fdd_flags: + */ +#define FDD_READY 0x1 +#define FDD_MOTON 0x2 +#define FDD_POLLABLE 0x4 + +/* + * Used by FD{G, S}ETSEARCH + */ +struct fd_search { + int fds_numentries; /* number of elements in the table */ + struct fd_char *fds_search; +}; + +/* + * Used by FDIOCMD + */ +struct fd_cmd { + ushort_t fdc_cmd; /* command to be executed */ + int fdc_flags; /* execution flags */ + daddr_t fdc_blkno; /* disk address for command */ + int fdc_secnt; /* sector count for command */ + caddr_t fdc_bufaddr; /* user's buffer address */ + uint_t fdc_buflen; /* size of user's buffer */ +}; + +#if defined(_SYSCALL32) +struct fd_cmd32 { + ushort_t fdc_cmd; /* command to be executed */ + int fdc_flags; /* execution flags */ + daddr32_t fdc_blkno; /* disk address for command */ + int fdc_secnt; /* sector count for command */ + caddr32_t fdc_bufaddr; /* user's buffer address */ + uint_t fdc_buflen; /* size of user's buffer */ +}; +#endif /* _SYSCALL32 */ + +/* + * Floppy commands + */ +#define FDCMD_WRITE 1 +#define FDCMD_READ 2 +#define FDCMD_SEEK 3 +#define FDCMD_REZERO 4 +#define FDCMD_FORMAT_UNIT 5 +#define FDCMD_FORMAT_TRACK 6 + +/* + * Execution flags. + */ +#define FD_SILENT 0x01 /* no error messages */ +#define FD_DIAGNOSE 0x02 /* fail if any error occurs */ +#define FD_ISOLATE 0x04 /* isolate from normal commands */ +#define FD_READ 0x08 /* read from device */ +#define FD_WRITE 0x10 /* write to device */ + +/* + * Used by FDRAW + */ +struct fd_raw { + char fdr_cmd[10]; /* user-supplied command bytes */ + short fdr_cnum; /* number of command bytes */ + char fdr_result[10]; /* controller-supplied result bytes */ + ushort_t fdr_nbytes; /* number to transfer if read/write command */ + caddr_t fdr_addr; /* where to transfer if read/write command */ +}; + +#ifdef _SYSCALL32 + +struct fd_raw32 { + char fdr_cmd[10]; /* user-supplied command bytes */ + short fdr_cnum; /* number of command bytes */ + char fdr_result[10]; /* controller-supplied result bytes */ + ushort_t fdr_nbytes; /* number to transfer if read/write command */ + caddr32_t fdr_addr; /* where to transfer if read/write command */ +}; + +#endif /* _SYSCALL32 */ + + +/* + * Floppy raw commands + */ +#define FDRAW_SPECIFY 0x03 +#define FDRAW_READID 0x0a +#define FDRAW_SENSE_DRV 0x04 +#define FDRAW_REZERO 0x07 +#define FDRAW_SEEK 0x0f +#define FDRAW_SENSE_INT 0x08 +#define FDRAW_FORMAT 0x0d +#define FDRAW_READTRACK 0x02 +#define FDRAW_WRCMD 0x05 +#define FDRAW_RDCMD 0x06 +#define FDRAW_WRITEDEL 0x09 +#define FDRAW_READDEL 0x0c + + +/* + * Disk io control commands + */ +#define FDIOC (0x04 << 8) +#define FDIOGCHAR (FDIOC|51) /* GetCharacteristics */ +#define FDIOSCHAR (FDIOC|52) /* SetCharacteristics */ +#define FDEJECT (FDIOC|53) /* Eject floppy disk */ +#define FDGETCHANGE (FDIOC|54) /* Get diskchng stat */ +#define FDGETDRIVECHAR (FDIOC|55) /* Get drivechar */ +#define FDSETDRIVECHAR (FDIOC|56) /* Set drivechar */ +#define FDGETSEARCH (FDIOC|57) /* Get search tbl */ +#define FDSETSEARCH (FDIOC|58) /* Set search tbl */ +#define FDIOCMD (FDIOC|59) /* Floppy command */ +#define FDRAW (FDIOC|70) /* ECDstyle genericcmd */ +#define FDDEFGEOCHAR (FDIOC|86) /* restore default geometry */ + /* & characteristics */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FDIO_H */ diff --git a/illumos-x86_64/usr/include/sys/feature_tests.h b/illumos-x86_64/usr/include/sys/feature_tests.h new file mode 100644 index 00000000..53ee2c25 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/feature_tests.h @@ -0,0 +1,542 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2013 Garrett D'Amore + * Copyright 2016 Joyent, Inc. + * Copyright 2024 Oxide Computer Company + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FEATURE_TESTS_H +#define _SYS_FEATURE_TESTS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Values of _POSIX_C_SOURCE + * + * undefined not a POSIX compilation + * 1 POSIX.1-1990 compilation + * 2 POSIX.2-1992 compilation + * 199309L POSIX.1b-1993 compilation (Real Time) + * 199506L POSIX.1c-1995 compilation (POSIX Threads) + * 200112L POSIX.1-2001 compilation (Austin Group Revision) + * 200809L POSIX.1-2008 compilation + * 202405L POSIX.1-2024 compilation + */ +#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 1 +#endif + +/* + * The feature test macros __XOPEN_OR_POSIX, _STRICT_STDC, _STRICT_SYMBOLS, + * and _STDC_C99 are Sun implementation specific macros created in order to + * compress common standards specified feature test macros for easier reading. + * These macros should not be used by the application developer as + * unexpected results may occur. Instead, the user should reference + * standards(7) for correct usage of the standards feature test macros. + * + * __XOPEN_OR_POSIX Used in cases where a symbol is defined by both + * X/Open or POSIX or in the negative, when neither + * X/Open or POSIX defines a symbol. + * + * _STRICT_STDC __STDC__ is specified by the C Standards and defined + * by the compiler. For Sun compilers the value of + * __STDC__ is either 1, 0, or not defined based on the + * compilation mode (see cc(1)). When the value of + * __STDC__ is 1 and in the absence of any other feature + * test macros, the namespace available to the application + * is limited to only those symbols defined by the C + * Standard. _STRICT_STDC provides a more readable means + * of identifying symbols defined by the standard, or in + * the negative, symbols that are extensions to the C + * Standard. See additional comments for GNU C differences. + * + * _STDC_C99 __STDC_VERSION__ is specified by the C standards and + * defined by the compiler and indicates the version of + * the C standard. A value of 199901L indicates a + * compiler that complies with ISO/IEC 9899:1999, other- + * wise known as the C99 standard. + * + * _STDC_C11 Like _STDC_C99 except that the value of __STDC_VERSION__ + * is 201112L indicating a compiler that compiles with + * ISO/IEC 9899:2011, otherwise known as the C11 standard. + * + * _STDC_C17 C17 (201710L) standard variant. C17 did not add features + * relative to C11. + * + * _STDC_C23 C23 (202311L) standard variant. + * + * _STRICT_SYMBOLS Used in cases where symbol visibility is restricted + * by the standards, and the user has not explicitly + * relaxed the strictness via __EXTENSIONS__. + */ + +#if defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) +#define __XOPEN_OR_POSIX +#endif + +/* + * C90 (ISO/IEC 9899:1990) and its revisions, C99, C11, C17, C23, etc. specify + * the following predefined macro name: + * + * __STDC__ The integer constant 1, intended to indicate a conforming + * implementation. + * + * Furthermore, a strictly conforming program shall use only those features + * of the language and library specified in these standards. A conforming + * implementation shall accept any strictly conforming program. + * + * Based on these requirements, Sun's C compiler defines __STDC__ to 1 for + * strictly conforming environments and __STDC__ to 0 for environments that + * use ANSI C semantics but allow extensions to the C standard. For non-ANSI + * C semantics, Sun's C compiler does not define __STDC__. + * + * The GNU C project interpretation is that __STDC__ should always be defined + * to 1 for compilation modes that accept ANSI C syntax regardless of whether + * or not extensions to the C standard are used. Violations of conforming + * behavior are conditionally flagged as warnings via the use of the + * -pedantic option. In addition to defining __STDC__ to 1, the GNU C + * compiler also defines __STRICT_ANSI__ as a means of specifying strictly + * conforming environments using the -ansi or -std= options. + * + * In the absence of any other compiler options, Sun and GNU set the value + * of __STDC__ as follows when using the following options: + * + * Value of __STDC__ __STRICT_ANSI__ + * + * cc -Xa (default) 0 undefined + * cc -Xt (transitional) 0 undefined + * cc -Xc (strictly conforming) 1 undefined + * cc -Xs (K&R C) undefined undefined + * + * gcc (default) 1 undefined + * gcc -ansi, -std={c89, c99,...) 1 defined + * gcc -traditional (K&R) undefined undefined + * + * The default compilation modes for Sun C compilers versus GNU C compilers + * results in a differing value for __STDC__ which results in a more + * restricted namespace when using Sun compilers. To allow both GNU and Sun + * interpretations to peacefully co-exist, we use the following Sun + * implementation _STRICT_STDC_ macro: + */ + +#if (__STDC__ - 0 == 1 && !defined(__GNUC__)) || \ + (defined(__GNUC__) && defined(__STRICT_ANSI__)) +#define _STRICT_STDC +#else +#undef _STRICT_STDC +#endif + +/* + * Compiler complies with various versions of ISO C. + */ +#if __STDC_VERSION__ - 0 >= 202311L +#define _STDC_C23 +#endif + +#if __STDC_VERSION__ - 0 >= 201710L +#define _STDC_C17 +#endif + +#if __STDC_VERSION__ - 0 >= 201112L +#define _STDC_C11 +#endif + +#if __STDC_VERSION__ - 0 >= 199901L +#define _STDC_C99 +#endif + +/* + * Use strict symbol visibility. + */ +#if (defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)) && \ + !defined(__EXTENSIONS__) +#define _STRICT_SYMBOLS +#endif + +/* + * This is a variant of _STRICT_SYMBOLS that is meant to cover headers that are + * governed by POSIX, but have not been governed by ISO C. One can go two ways + * on what should happen if an application actively includes (not transitively) + * a header that isn't part of the ISO C spec, we opt to say that if someone has + * gone out of there way then they're doing it for a reason and that is an act + * of non-compliance and therefore it's not up to us to hide away every symbol. + * + * In general, prefer using _STRICT_SYMBOLS, but this is here in particular for + * cases where in the past we have only used a POSIX related check and we don't + * wish to make something stricter. Often applications are relying on the + * ability to, or more realistically unwittingly, have _STRICT_STDC declared and + * still use these interfaces. + */ +#if (defined(__XOPEN_OR_POSIX) && !defined(__EXTENSIONS__)) +#define _STRICT_POSIX +#endif + +/* + * Large file interfaces: + * + * _LARGEFILE_SOURCE + * 1 large file-related additions to POSIX + * interfaces requested (fseeko, etc.) + * _LARGEFILE64_SOURCE + * 1 transitional large-file-related interfaces + * requested (seek64, stat64, etc.) + * + * The corresponding announcement macros are respectively: + * _LFS_LARGEFILE + * _LFS64_LARGEFILE + * (These are set in .) + * + * Requesting _LARGEFILE64_SOURCE implies requesting _LARGEFILE_SOURCE as + * well. + * + * The large file interfaces are made visible regardless of the initial values + * of the feature test macros under certain circumstances: + * - If no explicit standards-conforming environment is requested (neither + * of _POSIX_SOURCE nor _XOPEN_SOURCE is defined and the value of + * __STDC__ does not imply standards conformance). + * - Extended system interfaces are explicitly requested (__EXTENSIONS__ + * is defined). + * - Access to in-kernel interfaces is requested (_KERNEL or _KMEMUSER is + * defined). (Note that this dependency is an artifact of the current + * kernel implementation and may change in future releases.) + */ +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_KERNEL) || defined(_KMEMUSER) || \ + defined(__EXTENSIONS__) +#undef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE 1 +#endif +#if _LARGEFILE64_SOURCE - 0 == 1 +#undef _LARGEFILE_SOURCE +#define _LARGEFILE_SOURCE 1 +#endif + +/* + * Large file compilation environment control: + * + * The setting of _FILE_OFFSET_BITS controls the size of various file-related + * types and governs the mapping between file-related source function symbol + * names and the corresponding binary entry points. + * + * In the 32-bit environment, the default value is 32; if not set, set it to + * the default here, to simplify tests in other headers. + * + * In the 64-bit compilation environment, the only value allowed is 64. + */ +#if defined(_LP64) +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 64 +#endif +#if _FILE_OFFSET_BITS - 0 != 64 +#error "invalid _FILE_OFFSET_BITS value specified" +#endif +#else /* _LP64 */ +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 32 +#endif +#if _FILE_OFFSET_BITS - 0 != 32 && _FILE_OFFSET_BITS - 0 != 64 +#error "invalid _FILE_OFFSET_BITS value specified" +#endif +#endif /* _LP64 */ + +/* + * Use of _XOPEN_SOURCE + * + * The following X/Open specifications are supported: + * + * X/Open Portability Guide, Issue 3 (XPG3) + * X/Open CAE Specification, Issue 4 (XPG4) + * X/Open CAE Specification, Issue 4, Version 2 (XPG4v2) + * X/Open CAE Specification, Issue 5 (XPG5) + * Open Group Technical Standard, Issue 6 (XPG6), also referred to as + * IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002. + * Open Group Technical Standard, Issue 7 (XPG7), also referred to as + * IEEE Std. 1003.1-2008 and ISO/IEC 9945:2009. + * Open Group Technical Standard, Issue 8 (XPG8), also referred to as + * IEEE Std. 1003.1-2024. + * + * XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1). + * XPG5 is also referred to as UNIX 98 or the Single Unix Specification, + * Version 2 (SUSv2) + * XPG6 is the result of a merge of the X/Open and POSIX specifications + * and as such is also referred to as IEEE Std. 1003.1-2001 in + * addition to UNIX 03 and SUSv3. + * XPG7 is also referred to as UNIX 08 and SUSv4. + * XPG8 will probably be referred to as SUSv5. + * + * When writing a conforming X/Open application, as per the specification + * requirements, the appropriate feature test macros must be defined at + * compile time. These are as follows. For more info, see standards(7). + * + * Feature Test Macro Specification + * ------------------------------------------------ ------------- + * _XOPEN_SOURCE XPG3 + * _XOPEN_SOURCE && _XOPEN_VERSION = 4 XPG4 + * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1 XPG4v2 + * _XOPEN_SOURCE = 500 XPG5 + * _XOPEN_SOURCE = 600 (or POSIX_C_SOURCE=200112L) XPG6 + * _XOPEN_SOURCE = 700 (or POSIX_C_SOURCE=200809L) XPG7 + * _XOPEN_SOURCE = 800 (or POSIX_C_SOURCE=202405L) XPG8 + * + * In order to simplify the guards within the headers, the following + * implementation private test macros have been created. Applications + * must NOT use these private test macros as unexpected results will + * occur. + * + * Note that in general, the use of these private macros is cumulative. + * For example, the use of _XPG3 with no other restrictions on the X/Open + * namespace will make the symbols visible for XPG3 through XPG6 + * compilation environments. The use of _XPG4_2 with no other X/Open + * namespace restrictions indicates that the symbols were introduced in + * XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation + * environments, but not for XPG3 or XPG4 compilation environments. + * + * _XPG3 X/Open Portability Guide, Issue 3 (XPG3) + * _XPG4 X/Open CAE Specification, Issue 4 (XPG4) + * _XPG4_2 X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS) + * _XPG5 X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2) + * _XPG6 Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3) + * _XPG7 Open Group Technical Standard, Issue 7 (XPG7/UNIX 08/SUSv4) + * _XPG8 Open Group Technical Standard, Issue 8 (XPG8/SUSv5) + */ + +/* + * Test for various versions of POSIX and X/Open. We do these in order from the + * newest standard to the oldest as the use of _XOPEN_SOURCE or _POSIX_C_SOURCE + * should take priority and we have found cases in the wild where + * _XOPEN_SOURCE_EXTENDED is set in the wild in addition to _XOPEN_SOURCE. + */ + +/* Open Group Technical Standard, Issue 8 */ +#if (_XOPEN_SOURCE - 0 == 800) || (_POSIX_C_SOURCE - 0 == 202405L) +#define _XPG8 +#define _XPG7 +#define _XPG6 +#define _XPG5 +#define _XPG4_2 +#define _XPG4 +#define _XPG3 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 202405L +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 800 + +/* Open Group Technical Standard, Issue 7 */ +#elif (_XOPEN_SOURCE - 0 == 700) || (_POSIX_C_SOURCE - 0 == 200809L) +#define _XPG7 +#define _XPG6 +#define _XPG5 +#define _XPG4_2 +#define _XPG4 +#define _XPG3 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 700 + +/* Open Group Technical Standard, Issue 6 */ +#elif (_XOPEN_SOURCE - 0 == 600) || (_POSIX_C_SOURCE - 0 == 200112L) +#define _XPG6 +#define _XPG5 +#define _XPG4_2 +#define _XPG4 +#define _XPG3 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112L +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 600 + +/* X/Open CAE Specification, Issue 5 */ +#elif (_XOPEN_SOURCE - 0 == 500) +#define _XPG5 +#define _XPG4_2 +#define _XPG4 +#define _XPG3 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199506L + +/* X/Open CAE Specification, Issue 4, Version 2 */ +#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1) +#define _XPG4_2 +#define _XPG4 +#define _XPG3 + +/* X/Open CAE Specification, Issue 4 */ +#elif (defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4) +#define _XPG4 +#define _XPG3 + +/* X/Open Portability Guide, Issue 3 */ +#elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 < 500) && \ + (_XOPEN_VERSION - 0 < 4) && !defined(_XOPEN_SOURCE_EXTENDED) +#define _XPG3 +#endif /* XPG/POSIX detection */ + +/* + * _XOPEN_VERSION is defined by the X/Open specifications and is not + * normally defined by the application, except in the case of an XPG4 + * application. On the implementation side, _XOPEN_VERSION defined with + * the value of 3 indicates an XPG3 application. _XOPEN_VERSION defined + * with the value of 4 indicates an XPG4 or XPG4v2 (UNIX 95) application. + * _XOPEN_VERSION defined with a value of 500 indicates an XPG5 (UNIX 98) + * application and with a value of 600 indicates an XPG6 (UNIX 03) + * application and with a value of 700 indicates an XPG7 (UNIX 08). + * The appropriate version is determined by the use of the + * feature test macros described earlier. The value of _XOPEN_VERSION + * defaults to 3 otherwise indicating support for XPG3 applications. + */ +#ifndef _XOPEN_VERSION +#if defined(_XPG8) +#define _XOPEN_VERSION 800 +#elif defined(_XPG7) +#define _XOPEN_VERSION 700 +#elif defined(_XPG6) +#define _XOPEN_VERSION 600 +#elif defined(_XPG5) +#define _XOPEN_VERSION 500 +#elif defined(_XPG4_2) +#define _XOPEN_VERSION 4 +#else +#define _XOPEN_VERSION 3 +#endif +#endif /* !_XOPEN_VERSION */ + +/* + * ANSI C and ISO 9899:1990 say the type long long doesn't exist in strictly + * conforming environments. ISO 9899:1999 says it does. + * + * The presence of _LONGLONG_TYPE says "long long exists" which is therefore + * defined in all but strictly conforming environments that disallow it. + */ +#if !defined(_STDC_C99) && defined(_STRICT_STDC) && !defined(__GNUC__) +/* + * Resist attempts to force the definition of long long in this case. + */ +#if defined(_LONGLONG_TYPE) +#error "No long long in strictly conforming ANSI C & 1990 ISO C environments" +#endif +#else +#if !defined(_LONGLONG_TYPE) +#define _LONGLONG_TYPE +#endif +#endif + +/* + * The following macro defines a value for the ISO C99 restrict + * keyword so that _RESTRICT_KYWD resolves to "restrict" if + * an ISO C99 compiler is used, "__restrict" for c++ and "" (null string) + * if any other compiler is used. This allows for the use of single + * prototype declarations regardless of compiler version. + */ +#if (defined(__STDC__) && defined(_STDC_C99)) +#ifdef __cplusplus +#define _RESTRICT_KYWD __restrict +#else +/* + * NOTE: The whitespace between the '#' and 'define' is significant. + * It foils gcc's fixincludes from defining a redundant 'restrict'. + */ +/* CSTYLED */ +# define _RESTRICT_KYWD restrict +#endif +#else +#define _RESTRICT_KYWD +#endif + +/* + * The following macro defines a value for the ISO C11 _Noreturn + * keyword so that _NORETURN_KYWD resolves to "_Noreturn" if + * an ISO C11 compiler is used and "" (null string) if any other + * compiler is used. This allows for the use of single prototype + * declarations regardless of compiler version. + */ +#if (defined(__STDC__) && defined(_STDC_C11)) && !defined(__cplusplus) +#define _NORETURN_KYWD _Noreturn +#else +#define _NORETURN_KYWD +#endif + +/* + * C23 adds the notion of attributes. These provide ways to use the attributes + * in code (particularly headers) that does not solely support C23. + */ +#if defined(_STDC_C23) +#define _C23_UNSEQ_ATTR [[unsequenced]] +#else +#define _C23_UNSEQ_ATTR +#endif /* _STDC_C23 */ + +/* ISO/IEC 9899:2011 Annex K */ +#if defined(__STDC_WANT_LIB_EXT1__) +#if __STDC_WANT_LIB_EXT1__ +#define __EXT1_VISIBLE 1 +#else +#define __EXT1_VISIBLE 0 +#endif +#else +#define __EXT1_VISIBLE 0 +#endif /* __STDC_WANT_LIB_EXT1__ */ + +/* + * The following macro indicates header support for the ANSI C++ + * standard. The ISO/IEC designation for this is ISO/IEC FDIS 14882. + */ +#define _ISO_CPP_14882_1998 + +/* + * The following macro indicates header support for the C99 standard, + * ISO/IEC 9899:1999, Programming Languages - C. + */ +#define _ISO_C_9899_1999 + +/* + * The following macro indicates header support for the C11 standard, + * ISO/IEC 9899:2011, Programming Languages - C. + */ +#define _ISO_C_9899_2011 + +/* + * The following macro indicates header support for the C11 standard, + * ISO/IEC 9899:2011 Annex K, Programming Languages - C. + */ +#undef __STDC_LIB_EXT1__ + +/* + * The following macro indicates header support for DTrace. The value is an + * integer that corresponds to the major version number for DTrace. + */ +#define _DTRACE_VERSION 1 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FEATURE_TESTS_H */ diff --git a/illumos-x86_64/usr/include/sys/fem.h b/illumos-x86_64/usr/include/sys/fem.h new file mode 100644 index 00000000..73716119 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fem.h @@ -0,0 +1,450 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_FEM_H +#define _SYS_FEM_H + +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +struct fs_operation_def; /* from vfs.h */ + +/* + * overview: + * + * fem - file event monitoring + * + * File Event Monitoring is a formalized mechanism to monitor events on a + * vnode or vfs by intercepting the vnode/vfs operations. The framework enables + * the consumer to request event notifications for specified files and + * directories. The consumers, which intercept the events, are responsible for + * delivering the event to the next interceptor or the terminal destination. + * + */ + +/* + * protocol: + * + * vnode -> fem_head. + * There can only be one fem_head for a vnode. + * Once attached, the fem_head persists until explicitly detached + * or the vnode expires. + * + * fem_head -> fem_list. + * There can be many lists for a head, as each reconfiguration of + * the list causes a new one to be created and initialized from the + * old one. For this reason, modules cannot assume that they can + * reach thier list by vnode->fem_head->fem_list->list[n] == mod; + * + * fem_arg -> vnode, &vnode. + * This relationship is established at the head of the call (ie. in + * femhead_open()) where the fem_arg is allocated. Intermediate nodes + * have direct access to this. + * + * fem_arg -> fem_node + * This relationship is established at the head of the call (ie. in + * femhead_open()) where the fem_arg is allocated. The fem_arg is + * updated as intermediate nodes are invoked, however not as they + * return. For this reason, nodes which are interested in maintaining + * context following a "next" should store a copy of the fem_available + * field before invoking the 'next'. + */ +typedef struct fem_arg femarg_t, fsemarg_t; +typedef struct fem fem_t; +typedef struct fsem fsem_t; + +typedef int femop_t(); + +typedef void (*fem_func_t)(void *); + +/* + * The following enumerations specify the conditions + * under which a monitor (operation/argument combination) + * should be installed. These are used when calling + * fem_install() and fsem_install() + */ +typedef enum femhow { + FORCE = 0, /* Force the installation of this monitor */ + OPUNIQ = 1, /* Install if operation set is unique */ + OPARGUNIQ = 2 /* Install if op/arg combination is unique */ +} femhow_t; + +struct fem_node { + void *fn_available; + union { + fem_t *fem; + vnodeops_t *vnode; + fsem_t *fsem; + vfsops_t *vfs; + void *anon; /* anonymous, for updates */ + } fn_op; + void (*fn_av_hold)(void *); /* Hold for "fn_available" */ + void (*fn_av_rele)(void *); /* Release for "fn_available" */ +}; + +struct fem_arg { + union { + vnode_t *vp, + **vpp; + vfs_t *vfsp; + void *anon; + } fa_vnode; + struct fem_node *fa_fnode; +}; + + +struct fem_list { + uint_t feml_refc; /* reference count */ + int feml_tos; /* top of stack pointer(index) */ + int feml_ssize; /* stack size */ + int feml_pad; /* alignment */ + struct fem_node feml_nodes[1]; /* variable bounds */ +}; + +struct fem_head { + kmutex_t femh_lock; + struct fem_list *femh_list; +}; + +/* + * FEM_OPS defines all the FEM operations. It is used to define + * the fem structure (below) and the fs_func_p union (vfs_opreg.h). + */ +#define FEM_OPS \ + int (*femop_open)(femarg_t *vf, int mode, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_close)(femarg_t *vf, int flag, int count, \ + offset_t offset, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_read)(femarg_t *vf, uio_t *uiop, int ioflag, \ + cred_t *cr, caller_context_t *ct); \ + int (*femop_write)(femarg_t *vf, uio_t *uiop, int ioflag, \ + cred_t *cr, caller_context_t *ct); \ + int (*femop_ioctl)(femarg_t *vf, int cmd, intptr_t arg, \ + int flag, cred_t *cr, int *rvalp, \ + caller_context_t *ct); \ + int (*femop_setfl)(femarg_t *vf, int oflags, int nflags, \ + cred_t *cr, caller_context_t *ct); \ + int (*femop_getattr)(femarg_t *vf, vattr_t *vap, int flags, \ + cred_t *cr, caller_context_t *ct); \ + int (*femop_setattr)(femarg_t *vf, vattr_t *vap, int flags, \ + cred_t *cr, caller_context_t *ct); \ + int (*femop_access)(femarg_t *vf, int mode, int flags, \ + cred_t *cr, caller_context_t *ct); \ + int (*femop_lookup)(femarg_t *vf, char *nm, vnode_t **vpp, \ + pathname_t *pnp, int flags, vnode_t *rdir, \ + cred_t *cr, caller_context_t *ct, \ + int *direntflags, pathname_t *realpnp); \ + int (*femop_create)(femarg_t *vf, char *name, vattr_t *vap, \ + vcexcl_t excl, int mode, vnode_t **vpp, \ + cred_t *cr, int flag, caller_context_t *ct, \ + vsecattr_t *vsecp); \ + int (*femop_remove)(femarg_t *vf, char *nm, cred_t *cr, \ + caller_context_t *ct, int flags); \ + int (*femop_link)(femarg_t *vf, vnode_t *svp, char *tnm, \ + cred_t *cr, caller_context_t *ct, int flags); \ + int (*femop_rename)(femarg_t *vf, char *snm, vnode_t *tdvp, \ + char *tnm, cred_t *cr, caller_context_t *ct, \ + int flags); \ + int (*femop_mkdir)(femarg_t *vf, char *dirname, vattr_t *vap, \ + vnode_t **vpp, cred_t *cr, \ + caller_context_t *ct, int flags, \ + vsecattr_t *vsecp); \ + int (*femop_rmdir)(femarg_t *vf, char *nm, vnode_t *cdir, \ + cred_t *cr, caller_context_t *ct, int flags); \ + int (*femop_readdir)(femarg_t *vf, uio_t *uiop, cred_t *cr, \ + int *eofp, caller_context_t *ct, int flags); \ + int (*femop_symlink)(femarg_t *vf, char *linkname, \ + vattr_t *vap, char *target, cred_t *cr, \ + caller_context_t *ct, int flags); \ + int (*femop_readlink)(femarg_t *vf, uio_t *uiop, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_fsync)(femarg_t *vf, int syncflag, cred_t *cr, \ + caller_context_t *ct); \ + void (*femop_inactive)(femarg_t *vf, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_fid)(femarg_t *vf, fid_t *fidp, \ + caller_context_t *ct); \ + int (*femop_rwlock)(femarg_t *vf, int write_lock, \ + caller_context_t *ct); \ + void (*femop_rwunlock)(femarg_t *vf, int write_lock, \ + caller_context_t *ct); \ + int (*femop_seek)(femarg_t *vf, offset_t ooff, \ + offset_t *noffp, caller_context_t *ct); \ + int (*femop_cmp)(femarg_t *vf, vnode_t *vp2, \ + caller_context_t *ct); \ + int (*femop_frlock)(femarg_t *vf, int cmd, struct flock64 *bfp, \ + int flag, offset_t offset, \ + struct flk_callback *flk_cbp, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_space)(femarg_t *vf, int cmd, struct flock64 *bfp, \ + int flag, offset_t offset, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_realvp)(femarg_t *vf, vnode_t **vpp, \ + caller_context_t *ct); \ + int (*femop_getpage)(femarg_t *vf, offset_t off, size_t len, \ + uint_t *protp, struct page **plarr, \ + size_t plsz, struct seg *seg, caddr_t addr, \ + enum seg_rw rw, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_putpage)(femarg_t *vf, offset_t off, size_t len, \ + int flags, cred_t *cr, caller_context_t *ct); \ + int (*femop_map)(femarg_t *vf, offset_t off, struct as *as, \ + caddr_t *addrp, size_t len, uchar_t prot, \ + uchar_t maxprot, uint_t flags, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_addmap)(femarg_t *vf, offset_t off, struct as *as, \ + caddr_t addr, size_t len, uchar_t prot, \ + uchar_t maxprot, uint_t flags, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_delmap)(femarg_t *vf, offset_t off, struct as *as, \ + caddr_t addr, size_t len, uint_t prot, \ + uint_t maxprot, uint_t flags, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_poll)(femarg_t *vf, short events, int anyyet, \ + short *reventsp, struct pollhead **phpp, \ + caller_context_t *ct); \ + int (*femop_dump)(femarg_t *vf, caddr_t addr, offset_t lbdn, \ + offset_t dblks, caller_context_t *ct); \ + int (*femop_pathconf)(femarg_t *vf, int cmd, ulong_t *valp, \ + cred_t *cr, caller_context_t *ct); \ + int (*femop_pageio)(femarg_t *vf, struct page *pp, \ + u_offset_t io_off, size_t io_len, int flags, \ + cred_t *cr, caller_context_t *ct); \ + int (*femop_dumpctl)(femarg_t *vf, int action, offset_t *blkp, \ + caller_context_t *ct); \ + void (*femop_dispose)(femarg_t *vf, struct page *pp, int flag, \ + int dn, cred_t *cr, caller_context_t *ct); \ + int (*femop_setsecattr)(femarg_t *vf, vsecattr_t *vsap, \ + int flag, cred_t *cr, caller_context_t *ct); \ + int (*femop_getsecattr)(femarg_t *vf, vsecattr_t *vsap, \ + int flag, cred_t *cr, caller_context_t *ct); \ + int (*femop_shrlock)(femarg_t *vf, int cmd, \ + struct shrlock *shr, int flag, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_vnevent)(femarg_t *vf, vnevent_t vnevent, \ + vnode_t *dvp, char *cname, \ + caller_context_t *ct); \ + int (*femop_reqzcbuf)(femarg_t *vf, enum uio_rw ioflag, \ + xuio_t *xuio, cred_t *cr, \ + caller_context_t *ct); \ + int (*femop_retzcbuf)(femarg_t *vf, xuio_t *xuio, cred_t *cr, \ + caller_context_t *ct) + /* NB: No ";" */ + +struct fem { + const char *name; + const struct fs_operation_def *templ; + FEM_OPS; /* Signatures of all FEM operations (femops) */ +}; + +/* + * FSEM_OPS defines all the FSEM operations. It is used to define + * the fsem structure (below) and the fs_func_p union (vfs_opreg.h). + */ +#define FSEM_OPS \ + int (*fsemop_mount)(fsemarg_t *vf, vnode_t *mvp, \ + struct mounta *uap, cred_t *cr); \ + int (*fsemop_unmount)(fsemarg_t *vf, int flag, cred_t *cr); \ + int (*fsemop_root)(fsemarg_t *vf, vnode_t **vpp); \ + int (*fsemop_statvfs)(fsemarg_t *vf, statvfs64_t *sp); \ + int (*fsemop_sync)(fsemarg_t *vf, short flag, cred_t *cr); \ + int (*fsemop_vget)(fsemarg_t *vf, vnode_t **vpp, fid_t *fidp); \ + int (*fsemop_mountroot)(fsemarg_t *vf, \ + enum whymountroot reason); \ + void (*fsemop_freevfs)(fsemarg_t *vf); \ + int (*fsemop_vnstate)(fsemarg_t *vf, vnode_t *vp, \ + vntrans_t nstate); \ + int (*fsemop_syncfs)(fsemarg_t *vf, uint64_t, cred_t *) /* NB: No ";" */ + +struct fsem { + const char *name; + const struct fs_operation_def *templ; + FSEM_OPS; /* Signatures of all FSEM operations (fsemops) */ +}; + +extern int vnext_open(femarg_t *vf, int mode, cred_t *cr, + caller_context_t *ct); +extern int vnext_close(femarg_t *vf, int flag, int count, offset_t offset, + cred_t *cr, caller_context_t *ct); +extern int vnext_read(femarg_t *vf, uio_t *uiop, int ioflag, cred_t *cr, + caller_context_t *ct); +extern int vnext_write(femarg_t *vf, uio_t *uiop, int ioflag, cred_t *cr, + caller_context_t *ct); +extern int vnext_ioctl(femarg_t *vf, int cmd, intptr_t arg, int flag, + cred_t *cr, int *rvalp, caller_context_t *ct); +extern int vnext_setfl(femarg_t *vf, int oflags, int nflags, cred_t *cr, + caller_context_t *ct); +extern int vnext_getattr(femarg_t *vf, vattr_t *vap, int flags, cred_t *cr, + caller_context_t *ct); +extern int vnext_setattr(femarg_t *vf, vattr_t *vap, int flags, cred_t *cr, + caller_context_t *ct); +extern int vnext_access(femarg_t *vf, int mode, int flags, cred_t *cr, + caller_context_t *ct); +extern int vnext_lookup(femarg_t *vf, char *nm, vnode_t **vpp, + pathname_t *pnp, int flags, vnode_t *rdir, + cred_t *cr, caller_context_t *ct, + int *direntflags, pathname_t *realpnp); +extern int vnext_create(femarg_t *vf, char *name, vattr_t *vap, + vcexcl_t excl, int mode, vnode_t **vpp, cred_t *cr, + int flag, caller_context_t *ct, vsecattr_t *vsecp); +extern int vnext_remove(femarg_t *vf, char *nm, cred_t *cr, + caller_context_t *ct, int flags); +extern int vnext_link(femarg_t *vf, vnode_t *svp, char *tnm, cred_t *cr, + caller_context_t *ct, int flags); +extern int vnext_rename(femarg_t *vf, char *snm, vnode_t *tdvp, char *tnm, + cred_t *cr, caller_context_t *ct, int flags); +extern int vnext_mkdir(femarg_t *vf, char *dirname, vattr_t *vap, + vnode_t **vpp, cred_t *cr, caller_context_t *ct, + int flags, vsecattr_t *vsecp); +extern int vnext_rmdir(femarg_t *vf, char *nm, vnode_t *cdir, cred_t *cr, + caller_context_t *ct, int flags); +extern int vnext_readdir(femarg_t *vf, uio_t *uiop, cred_t *cr, int *eofp, + caller_context_t *ct, int flags); +extern int vnext_symlink(femarg_t *vf, char *linkname, vattr_t *vap, + char *target, cred_t *cr, caller_context_t *ct, + int flags); +extern int vnext_readlink(femarg_t *vf, uio_t *uiop, cred_t *cr, + caller_context_t *ct); +extern int vnext_fsync(femarg_t *vf, int syncflag, cred_t *cr, + caller_context_t *ct); +extern void vnext_inactive(femarg_t *vf, cred_t *cr, caller_context_t *ct); +extern int vnext_fid(femarg_t *vf, fid_t *fidp, caller_context_t *ct); +extern int vnext_rwlock(femarg_t *vf, int write_lock, caller_context_t *ct); +extern void vnext_rwunlock(femarg_t *vf, int write_lock, caller_context_t *ct); +extern int vnext_seek(femarg_t *vf, offset_t ooff, offset_t *noffp, + caller_context_t *ct); +extern int vnext_cmp(femarg_t *vf, vnode_t *vp2, caller_context_t *ct); +extern int vnext_frlock(femarg_t *vf, int cmd, struct flock64 *bfp, + int flag, offset_t offset, + struct flk_callback *flk_cbp, cred_t *cr, + caller_context_t *ct); +extern int vnext_space(femarg_t *vf, int cmd, struct flock64 *bfp, + int flag, offset_t offset, cred_t *cr, + caller_context_t *ct); +extern int vnext_realvp(femarg_t *vf, vnode_t **vpp, caller_context_t *ct); +extern int vnext_getpage(femarg_t *vf, offset_t off, size_t len, + uint_t *protp, struct page **plarr, size_t plsz, + struct seg *seg, caddr_t addr, enum seg_rw rw, + cred_t *cr, caller_context_t *ct); +extern int vnext_putpage(femarg_t *vf, offset_t off, size_t len, int flags, + cred_t *cr, caller_context_t *ct); +extern int vnext_map(femarg_t *vf, offset_t off, struct as *as, + caddr_t *addrp, size_t len, uchar_t prot, uchar_t maxprot, + uint_t flags, cred_t *cr, caller_context_t *ct); +extern int vnext_addmap(femarg_t *vf, offset_t off, struct as *as, + caddr_t addr, size_t len, uchar_t prot, + uchar_t maxprot, uint_t flags, cred_t *cr, + caller_context_t *ct); +extern int vnext_delmap(femarg_t *vf, offset_t off, struct as *as, + caddr_t addr, size_t len, uint_t prot, + uint_t maxprot, uint_t flags, cred_t *cr, + caller_context_t *ct); +extern int vnext_poll(femarg_t *vf, short events, int anyyet, + short *reventsp, struct pollhead **phpp, + caller_context_t *ct); +extern int vnext_dump(femarg_t *vf, caddr_t addr, offset_t lbdn, + offset_t dblks, caller_context_t *ct); +extern int vnext_pathconf(femarg_t *vf, int cmd, ulong_t *valp, cred_t *cr, + caller_context_t *ct); +extern int vnext_pageio(femarg_t *vf, struct page *pp, u_offset_t io_off, + size_t io_len, int flags, cred_t *cr, + caller_context_t *ct); +extern int vnext_dumpctl(femarg_t *vf, int action, offset_t *blkp, + caller_context_t *ct); +extern void vnext_dispose(femarg_t *vf, struct page *pp, int flag, int dn, + cred_t *cr, caller_context_t *ct); +extern int vnext_setsecattr(femarg_t *vf, vsecattr_t *vsap, int flag, + cred_t *cr, caller_context_t *ct); +extern int vnext_getsecattr(femarg_t *vf, vsecattr_t *vsap, int flag, + cred_t *cr, caller_context_t *ct); +extern int vnext_shrlock(femarg_t *vf, int cmd, struct shrlock *shr, + int flag, cred_t *cr, caller_context_t *ct); +extern int vnext_vnevent(femarg_t *vf, vnevent_t vevent, vnode_t *dvp, + char *cname, caller_context_t *ct); +extern int vnext_reqzcbuf(femarg_t *vf, enum uio_rw ioflag, xuio_t *xuiop, + cred_t *cr, caller_context_t *ct); +extern int vnext_retzcbuf(femarg_t *vf, xuio_t *xuiop, cred_t *cr, + caller_context_t *ct); + +extern int vfsnext_mount(fsemarg_t *vf, vnode_t *mvp, struct mounta *uap, + cred_t *cr); +extern int vfsnext_unmount(fsemarg_t *vf, int flag, cred_t *cr); +extern int vfsnext_root(fsemarg_t *vf, vnode_t **vpp); +extern int vfsnext_statvfs(fsemarg_t *vf, statvfs64_t *sp); +extern int vfsnext_sync(fsemarg_t *vf, short flag, cred_t *cr); +extern int vfsnext_vget(fsemarg_t *vf, vnode_t **vpp, fid_t *fidp); +extern int vfsnext_mountroot(fsemarg_t *vf, enum whymountroot reason); +extern void vfsnext_freevfs(fsemarg_t *vf); +extern int vfsnext_vnstate(fsemarg_t *vf, vnode_t *vp, vntrans_t nstate); +extern int vfsnext_syncfs(fsemarg_t *vf, uint64_t flag, cred_t *cr); + + +extern void fem_init(void); /* called once, by startup */ + +/* fem api */ +extern int fem_create(char *name, const struct fs_operation_def *templ, + fem_t **actual); +extern void fem_free(fem_t *fem); +extern int fem_install(struct vnode *v, fem_t *mon, void *arg, femhow_t how, + void (*arg_hold)(void *), void (*arg_rele)(void *)); +extern int fem_is_installed(struct vnode *v, fem_t *mon, void *arg); +extern int fem_uninstall(struct vnode *v, fem_t *mon, void *arg); +extern vnodeops_t *fem_getvnops(struct vnode *v); +extern void fem_setvnops(struct vnode *v, struct vnodeops *nops); + + +extern int fsem_create(char *name, const struct fs_operation_def *templ, + fsem_t **actual); +extern void fsem_free(fsem_t *fsem); +extern int fsem_is_installed(struct vfs *v, fsem_t *mon, void *arg); +extern int fsem_install(struct vfs *v, fsem_t *mon, void *arg, femhow_t how, + void (*arg_hold)(void *), void (*arg_rele)(void *)); +extern int fsem_uninstall(struct vfs *v, fsem_t *mon, void *arg); +extern vfsops_t *fsem_getvfsops(struct vfs *v); +extern void fsem_setvfsops(struct vfs *v, struct vfsops *nops); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FEM_H */ diff --git a/illumos-x86_64/usr/include/sys/file.h b/illumos-x86_64/usr/include/sys/file.h new file mode 100644 index 00000000..fc145fa8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/file.h @@ -0,0 +1,260 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ +/* Copyright 2020 Joyent, Inc. */ +/* Copyright 2021 OmniOS Community Edition (OmniOSce) Association. */ + +#ifndef _SYS_FILE_H +#define _SYS_FILE_H + +#include +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * fio locking: + * f_rwlock protects f_vnode and f_cred + * f_tlock protects the rest + * + * The purpose of locking in this layer is to keep the kernel + * from panicing if, for example, a thread calls close() while + * another thread is doing a read(). It is up to higher levels + * to make sure 2 threads doing I/O to the same file don't + * screw each other up. + */ +/* + * One file structure is allocated for each open/creat/pipe call. + * Main use is to hold the read/write pointer (and OFD locks) associated with + * each open file. + */ +typedef struct file { + kmutex_t f_tlock; /* short term lock */ + ushort_t f_flag; + ushort_t f_flag2; /* extra flags (FSEARCH, FEXEC) */ + struct vnode *f_vnode; /* pointer to vnode structure */ + offset_t f_offset; /* read/write character pointer */ + struct cred *f_cred; /* credentials of user who opened it */ + struct f_audit_data *f_audit_data; /* file audit data */ + int f_count; /* reference count */ + struct filock *f_filock; /* ptr to single lock_descriptor_t */ +} file_t; + +/* + * fpollinfo struct - used by poll caching to track who has polled the fd + */ +typedef struct fpollinfo { + struct _kthread *fp_thread; /* thread caching poll info */ + struct fpollinfo *fp_next; +} fpollinfo_t; + +/* f_flag */ + +#define FOPEN 0xffffffff +#define FREAD 0x01 /* LIO_READ must be identical */ +#define FWRITE 0x02 /* LIO_WRITE must be identical */ +#define FNDELAY 0x04 +#define FAPPEND 0x08 +#define FSYNC 0x10 /* file (data+inode) integrity while writing */ +#define FREVOKED 0x20 /* Object reuse Revoked file */ +#define FDSYNC 0x40 /* file data only integrity while writing */ +#define FNONBLOCK 0x80 + +#define FMASK 0xa0ff /* all flags that can be changed by F_SETFL */ + +/* open-only modes */ + +#define FCREAT 0x0100 +#define FTRUNC 0x0200 +#define FEXCL 0x0400 +#define FASYNC 0x1000 /* asyncio in progress pseudo flag */ +#define FOFFMAX 0x2000 /* large file */ +#define FXATTR 0x4000 /* open as extended attribute */ +#define FNOCTTY 0x0800 +#define FRSYNC 0x8000 /* sync read operations at same level of */ + /* integrity as specified for writes by */ + /* FSYNC and FDSYNC flags */ + +#define FNODSYNC 0x10000 /* fsync pseudo flag */ + +#define FNOFOLLOW 0x20000 /* don't follow symlinks */ +#define FNOLINKS 0x40000 /* don't allow multiple hard links */ +#define FIGNORECASE 0x80000 /* request case-insensitive lookups */ +#define FXATTRDIROPEN 0x100000 /* only opening hidden attribute directory */ + +/* f_flag2 (open-only) */ + +#define FSEARCH 0x200000 /* O_SEARCH = 0x200000 */ +#define FEXEC 0x400000 /* O_EXEC = 0x400000 */ + +#define FCLOEXEC 0x800000 /* O_CLOEXEC = 0x800000 */ +#define FDIRECTORY 0x1000000 /* O_DIRECTORY = 0x1000000 */ +#define FDIRECT 0x2000000 /* O_DIRECT = 0x2000000 */ +#define FCLOFORK 0x4000000 /* O_CLOFORK = 0x4000000 */ +/* + * Private interface for lx O_PATH|O_NOFOLLOW emulation for symlinks. + */ +#define __FLXPATH 0x80000000 +/* + * Private interface for lx fstatat(AT_NO_AUTOMOUNT) emulation. + * Since usage is disjoint, the __FLXPATH bit is re-used. + */ +#define __FLXNOAUTO 0x80000000 + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * Fake flags for driver ioctl calls to inform them of the originating + * process' model. See + * + * Part of the Solaris 2.6+ DDI/DKI + */ +#define FMODELS DATAMODEL_MASK /* Note: 0x0ff00000 */ +#define FILP32 DATAMODEL_ILP32 +#define FLP64 DATAMODEL_LP64 +#define FNATIVE DATAMODEL_NATIVE + +/* + * Large Files: The macro gets the offset maximum (refer to LFS API doc) + * corresponding to a file descriptor. We had the choice of storing + * this value in file descriptor. Right now we only have two + * offset maximums one if MAXOFF_T and other is MAXOFFSET_T. It is + * inefficient to store these two values in a separate member in + * file descriptor. To avoid wasting spaces we define this macro. + * The day there are more than two offset maximum we may want to + * rewrite this macro. + */ + +#define OFFSET_MAX(fd) ((fd->f_flag & FOFFMAX) ? MAXOFFSET_T : MAXOFF32_T) + +/* + * Fake flag => internal ioctl call for layered drivers. + * Note that this flag deliberately *won't* fit into + * the f_flag field of a file_t. + * + * Part of the Solaris 2.x DDI/DKI. + */ +#define FKIOCTL 0x80000000 /* ioctl addresses are from kernel */ + +/* + * Fake flag => this time to specify that the open(9E) + * comes from another part of the kernel, not userland. + * + * Part of the Solaris 2.x DDI/DKI. + */ +#define FKLYR 0x40000000 /* layered driver call */ + +#endif /* _KERNEL */ + +/* miscellaneous defines */ + +#ifndef L_SET +#define L_SET 0 /* for lseek */ +#endif /* L_SET */ + +/* + * For flock(3C). These really don't belong here but for historical reasons + * the interface defines them to be here. + */ +#define LOCK_SH 1 +#define LOCK_EX 2 +#define LOCK_NB 4 +#define LOCK_UN 8 + +#if !defined(_STRICT_SYMBOLS) +extern int flock(int, int); +#endif + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * Routines dealing with user per-open file flags and + * user open files. + */ +struct proc; /* forward reference for function prototype */ +struct vnodeops; +struct vattr; +struct uf_info; + +extern file_t *getf(int); +extern file_t *getf_gen(int, uf_entry_gen_t *); +extern void releasef(int); +extern void areleasef(int, struct uf_info *); +#ifndef _BOOT +extern void closeall(struct uf_info *); +#endif +extern void flist_fork(struct uf_info *, struct uf_info *); +extern int closef(file_t *); +extern int closeandsetf(int, file_t *); +extern int ufalloc_file(int, file_t *); +extern int ufalloc(int); +extern int ufcanalloc(struct proc *, uint_t); +extern int falloc(struct vnode *, int, file_t **, int *); +extern void finit(void); +extern void unfalloc(file_t *); +extern void setf(int, file_t *); +extern int f_getfd_error(int, int *); +extern char f_getfd(int); +extern int f_setfd_error(int, int); +extern void f_setfd_or(int, short); +extern int f_getfl(int, int *); +extern int f_badfd(int, int *, int); +extern int fassign(struct vnode **, int, int *); +extern void fcnt_add(struct uf_info *, int); +extern void close_exec(struct uf_info *); +extern void clear_stale_fd(void); +extern void clear_active_fd(int); +extern void set_active_fd(int); +extern void free_afd(afd_t *afd); +extern int fgetstartvp(int, char *, struct vnode **); +extern int fsetattrat(int, char *, int, struct vattr *); +extern int fisopen(struct vnode *); +extern void delfpollinfo(int); +extern void addfpollinfo(int); +extern int sock_getfasync(struct vnode *); +extern int files_can_change_zones(void); +#ifdef DEBUG +/* The following functions are only used in ASSERT()s */ +extern void checkwfdlist(struct vnode *, fpollinfo_t *); +extern void checkfpollinfo(void); +extern int infpollinfo(int); +#endif /* DEBUG */ + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FILE_H */ diff --git a/illumos-x86_64/usr/include/sys/filio.h b/illumos-x86_64/usr/include/sys/filio.h new file mode 100644 index 00000000..7dc58800 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/filio.h @@ -0,0 +1,147 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +/* + * Copyright (c) 2013 by Delphix. All rights reserved. + */ + +#ifndef _SYS_FILIO_H +#define _SYS_FILIO_H + +/* + * General file ioctl definitions. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define FIOCLEX _IO('f', 1) /* set exclusive use on fd */ +#define FIONCLEX _IO('f', 2) /* remove exclusive use */ +/* another local */ +#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ +#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ +#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ +#define FIOSETOWN _IOW('f', 124, int) /* set owner */ +#define FIOGETOWN _IOR('f', 123, int) /* get owner */ + +/* + * ioctl's for Online: DiskSuite. + * WARNING - the support for these ioctls may be withdrawn + * in future OS releases. + */ +#define _FIOLFS _IO('f', 64) /* file system lock */ +#define _FIOLFSS _IO('f', 65) /* file system lock status */ +#define _FIOFFS _IO('f', 66) /* file system flush */ +#define _FIOAI _FIOOBSOLETE67 /* get allocation info is */ +#define _FIOOBSOLETE67 _IO('f', 67) /* obsolete and unsupported */ +#define _FIOSATIME _IO('f', 68) /* set atime */ +#define _FIOSDIO _IO('f', 69) /* set delayed io */ +#define _FIOGDIO _IO('f', 70) /* get delayed io */ +#define _FIOIO _IO('f', 71) /* inode open */ +#define _FIOISLOG _IO('f', 72) /* disksuite/ufs protocol */ +#define _FIOISLOGOK _IO('f', 73) /* disksuite/ufs protocol */ +#define _FIOLOGRESET _IO('f', 74) /* disksuite/ufs protocol */ + +/* + * Contract-private ioctl() + */ +#define _FIOISBUSY _IO('f', 75) /* networker/ufs protocol */ +#define _FIODIRECTIO _IO('f', 76) /* directio */ +#define _FIOTUNE _IO('f', 77) /* tuning */ + +/* + * Internal Logging UFS + */ +#define _FIOLOGENABLE _IO('f', 87) /* logging/ufs protocol */ +#define _FIOLOGDISABLE _IO('f', 88) /* logging/ufs protocol */ + +/* + * File system snapshot ioctls (see sys/fs/ufs_snap.h) + * (there is another snapshot ioctl, _FIOSNAPSHOTCREATE_MULTI, + * defined farther down in this file.) + */ +#define _FIOSNAPSHOTCREATE _IO('f', 89) /* create a snapshot */ +#define _FIOSNAPSHOTDELETE _IO('f', 90) /* delete a snapshot */ + +/* + * Return the current superblock of size SBSIZE + */ +#define _FIOGETSUPERBLOCK _IO('f', 91) + +/* + * Contract private ioctl + */ +#define _FIOGETMAXPHYS _IO('f', 92) + +/* + * TSufs support + */ +#define _FIO_SET_LUFS_DEBUG _IO('f', 93) /* set lufs_debug */ +#define _FIO_SET_LUFS_ERROR _IO('f', 94) /* set a lufs error */ +#define _FIO_GET_TOP_STATS _IO('f', 95) /* get lufs tranaction stats */ + +/* + * create a snapshot with multiple backing files + */ +#define _FIOSNAPSHOTCREATE_MULTI _IO('f', 96) + +/* + * handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge + */ +#define _FIO_SEEK_DATA _IO('f', 97) /* SEEK_DATA */ +#define _FIO_SEEK_HOLE _IO('f', 98) /* SEEK_HOLE */ + +/* + * boot archive compression + */ +#define _FIO_COMPRESSED _IO('f', 99) /* mark file as compressed */ + +/* + * Expose fill information through ioctl + */ +#define _FIO_COUNT_FILLED _IO('f', 100) /* count holes in a file */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FILIO_H */ diff --git a/illumos-x86_64/usr/include/sys/firmload.h b/illumos-x86_64/usr/include/sys/firmload.h new file mode 100644 index 00000000..f5ba4473 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/firmload.h @@ -0,0 +1,62 @@ +/* $NetBSD: firmload.h,v 1.2 2008/04/28 20:23:46 martin Exp $ */ + +/* + * Copyright 2016 Hans Rosenfeld + */ + +/* + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_FIRMLOAD_H +#define _SYS_FIRMLOAD_H + +#ifdef _KERNEL + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct firmware_handle *firmware_handle_t; + +extern int firmware_open(const char *, const char *, firmware_handle_t *); +extern int firmware_close(firmware_handle_t); + +extern off_t firmware_get_size(firmware_handle_t); + +extern int firmware_read(firmware_handle_t, off_t, void *, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _KERNEL */ + +#endif /* _SYS_FIRMLOAD_H */ diff --git a/illumos-x86_64/usr/include/sys/flock.h b/illumos-x86_64/usr/include/sys/flock.h new file mode 100644 index 00000000..616d67b5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/flock.h @@ -0,0 +1,277 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2015 Joyent, Inc. + */ + +#ifndef _SYS_FLOCK_H +#define _SYS_FLOCK_H + +#include +#include +#include +#include /* for */ +#include +#include +#include +#if defined(_KERNEL) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Private declarations and instrumentation for local locking. + */ + +/* + * The flag passed to fs_frlock() may be ORed together with either + * `F_REMOTELOCK' or `F_PXFSLOCK'. Since this flag is initialized using the + * `f_flag' field in the `file' structure, and that field is an unsigned short, + * we do not use the first 2 bytes. + */ +#define F_REMOTELOCK (0x01 << 16) /* Set if NLM lock */ +#define F_PXFSLOCK (0x02 << 16) /* Clustering: set if PXFS lock */ + +/* + * The command passed to reclock() is made by ORing together one or more of + * the following values. + */ + +#define INOFLCK 0x01 /* Vnode is locked when reclock() is called. */ +#define SETFLCK 0x02 /* Set a file lock. */ +#define SLPFLCK 0x04 /* Wait if blocked. */ +#define RCMDLCK 0x08 /* F_REMOTELOCK specified */ +#define PCMDLCK 0x10 /* Clustering: F_PXFSLOCK specified */ +#define NBMLCK 0x20 /* non-blocking mandatory locking */ + +/* + * Special pid value that can be passed to cleanlocks(). It means that + * cleanlocks() should flush all locks for the given sysid, not just the + * locks owned by a specific process. + */ + +#define IGN_PID (-1) + +/* file locking structure (connected to vnode) */ + +#define l_end l_len + +/* + * The lock manager is allowed to use unsigned offsets and lengths, though + * regular Unix processes are still required to use signed offsets and + * lengths. + */ +typedef ulong_t u_off_t; + +#define MAX_U_OFF_T ((u_off_t)~0) +#define MAX_U_OFFSET_T ((u_offset_t)~0) + +/* + * define MAXEND as the largest positive value the signed offset_t will hold. + */ +#define MAXEND MAXOFFSET_T + +/* + * Definitions for accessing the l_pad area of struct flock. The + * descriminant of the pad_info_t union is the fcntl command used in + * conjunction with the flock struct. + */ + +typedef union { + int pi_pad[4]; /* (original pad area) */ + int pi_has_rmt; /* F_HASREMOTELOCKS */ +} pad_info_t; + +#define l_has_rmt(flockp) (((pad_info_t *)((flockp)->l_pad))->pi_has_rmt) + +/* + * Optional callbacks for blocking lock requests. Each function is called + * twice. + * The first call is after the request is put in the "sleeping" list, but + * before waiting. At most one callback may return a callb_cpr_t object; + * the others must return NULL. If a callb_cpr_t is returned, the thread + * will be marked as safe to suspend while waiting for the lock. + * The second call is after the request wakes up. Note that the request + * might not have been granted at the second call (e.g., the request was + * signalled). + * New callbacks should be added to the head of the list. For the first + * call the list is walked in order. For the second call the list is + * walked backwards (in case the callbacks need to reacquire locks). + */ + +typedef enum {FLK_BEFORE_SLEEP, FLK_AFTER_SLEEP} flk_cb_when_t; + +struct flk_callback { + struct flk_callback *cb_next; /* circular linked list */ + struct flk_callback *cb_prev; + callb_cpr_t *(*cb_callback)(flk_cb_when_t, void *); /* fcn ptr */ + void *cb_data; /* ptr to callback data */ +}; + +typedef struct flk_callback flk_callback_t; + +/* + * This structure members are not used any more inside the kernel. + * The structure is used for casting some pointer assignments only. + */ + +typedef struct filock { + kcondvar_t cv; + struct flock set; /* contains type, start, and end */ + struct { + int granted_flag; /* granted flag */ + struct filock *blk; /* for sleeping locks only */ + struct attacher *blocking_list; + struct attacher *my_attacher; + } stat; + struct filock *prev; + struct filock *next; +} filock_t; + +#define FLP_DELAYED_FREE -1 /* special value for granted_flag */ + +/* structure that contains list of locks to be granted */ + +#define MAX_GRANT_LOCKS 52 + +typedef struct grant_lock { + struct filock *grant_lock_list[MAX_GRANT_LOCKS]; + struct grant_lock *next; +} grant_lock_t; + +/* + * Provide a way to cleanly enable and disable Network Lock Manager locking + * requests (i.e., requests from remote clients): + * FLK_NLM_SHUTTING_DOWN: Forces all blocked NLM requests to bail out + * and return ENOLCK. + * FLK_NLM_DOWN: Clears all granted NLM server locks. Both status + * codes cause new NLM lock requests to fail immediately with ENOLCK. + * FLK_NLM_UP: Changes the state of all locks to UP, after a server has + * shutdown and is restarting on the same node. + */ + +/* + * Enumerated type of the four possible states an NLM server can be in. + */ +typedef enum { + FLK_NLM_UP, + FLK_NLM_SHUTTING_DOWN, + FLK_NLM_DOWN, + FLK_NLM_UNKNOWN +} flk_nlm_status_t; + +/* + * Provide a way to cleanly enable and disable lock manager locking + * requests (i.e., requests from remote clients). FLK_WAKEUP_SLEEPERS + * forces all blocked lock manager requests to bail out and return ENOLCK. + * FLK_LOCKMGR_DOWN clears all granted lock manager locks. Both status + * codes cause new lock manager requests to fail immediately with ENOLCK. + */ + +typedef enum { + FLK_LOCKMGR_UP, + FLK_WAKEUP_SLEEPERS, + FLK_LOCKMGR_DOWN +} flk_lockmgr_status_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * The following structure is used to hold a list of locks returned + * by the F_ACTIVELIST or F_SLEEPINGLIST commands to fs_frlock. + * + * N.B. The lists returned by these commands are dynamically + * allocated and must be freed by the caller. The vnodes returned + * in the lists are held and must be released when the caller is done. + */ + +typedef struct locklist { + struct vnode *ll_vp; + struct flock64 ll_flock; + struct locklist *ll_next; +} locklist_t; + +#define FLK_QUERY_ACTIVE 0x1 +#define FLK_QUERY_SLEEPING 0x2 + +#if defined(_KERNEL) +int ofdlock(file_t *, int, struct flock64 *, int, u_offset_t); +void ofdcleanlock(file_t *); +#endif +int reclock(struct vnode *, struct flock64 *, int, int, u_offset_t, + flk_callback_t *); +int chklock(struct vnode *, int, u_offset_t, ssize_t, int, + caller_context_t *); +int convoff(struct vnode *, struct flock64 *, int, offset_t); +void cleanlocks(struct vnode *, pid_t, int); +locklist_t *flk_get_sleeping_locks(int sysid, pid_t pid); +locklist_t *flk_get_active_locks(int sysid, pid_t pid); +locklist_t *flk_active_locks_for_vp(const struct vnode *vp); +locklist_t *flk_active_nbmand_locks_for_vp(const struct vnode *vp); +locklist_t *flk_active_nbmand_locks(pid_t pid); +void flk_free_locklist(locklist_t *); +int flk_convert_lock_data(struct vnode *, struct flock64 *, + u_offset_t *, u_offset_t *, offset_t); +int flk_check_lock_data(u_offset_t, u_offset_t, offset_t); +int flk_has_remote_locks(struct vnode *vp); +void flk_set_lockmgr_status(flk_lockmgr_status_t status); +int flk_sysid_has_locks(int sysid, int chklck); +int flk_has_remote_locks_for_sysid(vnode_t *vp, int); +void flk_init_callback(flk_callback_t *, + callb_cpr_t *(*)(flk_cb_when_t, void *), void *); +void flk_add_callback(flk_callback_t *, + callb_cpr_t *(*)(flk_cb_when_t, void *), void *, + flk_callback_t *); +void flk_del_callback(flk_callback_t *); +callb_cpr_t *flk_invoke_callbacks(flk_callback_t *, flk_cb_when_t); + +/* Zones hooks */ +extern zone_key_t flock_zone_key; + +void *flk_zone_init(zoneid_t); +void flk_zone_fini(zoneid_t, void *); + +/* Clustering hooks */ +void cl_flk_set_nlm_status(int nlmid, flk_nlm_status_t nlm_state); +void cl_flk_remove_locks_by_sysid(int sysid); +int cl_flk_has_remote_locks_for_nlmid(struct vnode *vp, int nlmid); +void cl_flk_change_nlm_state_to_unknown(int nlmid); +void cl_flk_delete_pxfs_locks(struct vfs *vfsp, int pxfsid); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FLOCK_H */ diff --git a/illumos-x86_64/usr/include/sys/flock_impl.h b/illumos-x86_64/usr/include/sys/flock_impl.h new file mode 100644 index 00000000..b1be1d59 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/flock_impl.h @@ -0,0 +1,492 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. + */ + +#ifndef _SYS_FLOCK_IMPL_H +#define _SYS_FLOCK_IMPL_H + +#include +#include /* flock definition */ +#include /* FREAD etc */ +#include /* RCMD etc */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* just to get GETSYSID def */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct edge { + struct edge *edge_adj_next; /* adjacency list next */ + struct edge *edge_adj_prev; /* adjacency list prev */ + struct edge *edge_in_next; /* incoming edges list next */ + struct edge *edge_in_prev; /* incoming edges list prev */ + struct lock_descriptor *from_vertex; /* edge emanating from lock */ + struct lock_descriptor *to_vertex; /* edge pointing to lock */ +}; + +typedef struct edge edge_t; + +struct lock_descriptor { + struct lock_descriptor *l_next; /* next active/sleep lock */ + struct lock_descriptor *l_prev; /* previous active/sleep lock */ + struct edge l_edge; /* edge for adj and in lists */ + struct lock_descriptor *l_stack; /* for stack operations */ + struct lock_descriptor *l_stack1; /* for stack operations */ + struct lock_descriptor *l_dstack; /* stack for debug functions */ + struct edge *l_sedge; /* start edge for graph alg. */ + int l_index; /* used for barrier count */ + struct graph *l_graph; /* graph this belongs to */ + vnode_t *l_vnode; /* vnode being locked */ + int l_type; /* type of lock */ + int l_state; /* state described below */ + u_offset_t l_start; /* start offset */ + u_offset_t l_end; /* end offset */ + flock64_t l_flock; /* original flock request */ + int l_color; /* color used for graph alg */ + kcondvar_t l_cv; /* wait condition for lock */ + int pvertex; /* index to proc vertex */ + int l_status; /* status described below */ + flk_nlm_status_t l_nlm_state; /* state of NLM server */ + flk_callback_t *l_callbacks; /* callbacks, or NULL */ + zoneid_t l_zoneid; /* zone of request */ + file_t *l_ofd; /* OFD-style reference */ +}; + +typedef struct lock_descriptor lock_descriptor_t; + +/* + * Each graph holds locking information for some number of vnodes. The + * active and sleeping lists are circular, with a dummy head element. + */ + +struct graph { + kmutex_t gp_mutex; /* mutex for this graph */ + struct lock_descriptor active_locks; + struct lock_descriptor sleeping_locks; + int index; /* index of this graph into the hash table */ + int mark; /* used for coloring the graph */ +}; + +typedef struct graph graph_t; + +/* + * The possible states a lock can be in. These states are stored in the + * 'l_status' member of the 'lock_descriptor_t' structure. All locks start + * life in the INITIAL state, and end up in the DEAD state. Possible state + * transitions are : + * + * INITIAL--> START --> ACTIVE --> DEAD + * + * --> DEAD + * + * --> ACTIVE --> DEAD (new locks from flk_relation) + * + * --> SLEEPING --> GRANTED --> START --> ACTIVE --> DEAD + * + * --> INTR --> DEAD + * + * --> CANCELLED --> DEAD + * + * --> INTR --> DEAD + * + * --> INTR --> DEAD + * + * --> CANCELLED --> DEAD + * + * --> INTR --> DEAD + * + * Lock transitions are done in the following functions: + * --> INITIAL flk_get_lock(), reclock() + * --> START flk_execute_request() + * --> ACTIVE flk_insert_active_lock() + * --> SLEEPING flk_insert_sleeping_lock() + * --> GRANTED GRANT_WAKEUP + * --> INTERRUPTED INTERRUPT_WAKEUP + * --> CANCELLED CANCEL_WAKEUP + * --> DEAD reclock(), flk_delete_active_lock(), and + * flk_cancel_sleeping_lock() + */ + +#define FLK_INITIAL_STATE 1 /* Initial state of all requests */ +#define FLK_START_STATE 2 /* Request has started execution */ +#define FLK_ACTIVE_STATE 3 /* In active queue */ +#define FLK_SLEEPING_STATE 4 /* Request is blocked */ +#define FLK_GRANTED_STATE 5 /* Request is granted */ +#define FLK_INTERRUPTED_STATE 6 /* Request is interrupted */ +#define FLK_CANCELLED_STATE 7 /* Request is cancelled */ +#define FLK_DEAD_STATE 8 /* Request is done - will be deleted */ + +/* flags defining state of locks */ + +/* + * The LLM design has been modified so that lock states are now stored + * in the l_status field of lock_descriptor_t. The l_state field is + * currently preserved for binary compatibility, but may be modified or + * removed in a minor release of Solaris. Note that both of these + * fields (and the rest of the lock_descriptor_t structure) are private + * to the implementation of the lock manager and should not be used + * externally. + */ + +#define ACTIVE_LOCK 0x0001 /* in active queue */ +#define SLEEPING_LOCK 0x0002 /* in sleep queue */ +#define IO_LOCK 0x0004 /* is an IO lock */ +#define REFERENCED_LOCK 0x0008 /* referenced some where */ +#define QUERY_LOCK 0x0010 /* querying about lock */ +#define WILLING_TO_SLEEP_LOCK 0x0020 /* lock can be put in sleep queue */ +#define RECOMPUTE_LOCK 0x0040 /* used for recomputing dependencies */ +#define RECOMPUTE_DONE 0x0080 /* used for recomputing dependencies */ +#define BARRIER_LOCK 0x0100 /* used for recomputing dependencies */ +#define GRANTED_LOCK 0x0200 /* granted but still in sleep queue */ +#define CANCELLED_LOCK 0x0400 /* cancelled will be thrown out */ +#define DELETED_LOCK 0x0800 /* deleted - free at earliest */ +#define INTERRUPTED_LOCK 0x1000 /* pretend signal */ +#define LOCKMGR_LOCK 0x2000 /* remote lock (server-side) */ +/* Clustering: flag for PXFS locks */ +#define PXFS_LOCK 0x4000 /* lock created by PXFS file system */ +#define NBMAND_LOCK 0x8000 /* non-blocking mandatory locking */ + +#define HASH_SIZE 32 +#define HASH_SHIFT (HASH_SIZE - 1) +#define HASH_INDEX(vp) (((uintptr_t)vp >> 7) & HASH_SHIFT) + +/* extern definitions */ + +extern struct graph *lock_graph[HASH_SIZE]; +extern struct kmem_cache *flk_edge_cache; + +/* Clustering: functions called by PXFS */ +int flk_execute_request(lock_descriptor_t *); +void flk_cancel_sleeping_lock(lock_descriptor_t *, int); +void flk_set_state(lock_descriptor_t *, int); +graph_t *flk_get_lock_graph(vnode_t *, int); + +/* flags used for readability in flock.c */ + +#define FLK_USE_GRAPH 0 /* don't initialize the lock_graph */ +#define FLK_INIT_GRAPH 1 /* initialize the lock graph */ +#define NO_COLOR 0 /* vertex is not colored */ +#define NO_CHECK_CYCLE 0 /* don't mark vertex's in flk_add_edge */ +#define CHECK_CYCLE 1 /* mark vertex's in flk_add_edge */ + +#define SAME_OWNER(lock1, lock2) \ + (((lock1)->l_flock.l_pid == (lock2)->l_flock.l_pid) && \ + ((lock1)->l_flock.l_sysid == (lock2)->l_flock.l_sysid) && \ + ((lock1)->l_ofd == (lock2)->l_ofd)) + +#define COLORED(vertex) ((vertex)->l_color == (vertex)->l_graph->mark) +#define COLOR(vertex) ((vertex)->l_color = (vertex)->l_graph->mark) + +/* + * stack data structure and operations + */ + +#define STACK_INIT(stack) ((stack) = NULL) +#define STACK_PUSH(stack, ptr, stack_link) (ptr)->stack_link = (stack),\ + (stack) = (ptr) +#define STACK_POP(stack, stack_link) (stack) = (stack)->stack_link +#define STACK_TOP(stack) (stack) +#define STACK_EMPTY(stack) ((stack) == NULL) + + +#define ACTIVE_HEAD(gp) (&(gp)->active_locks) + +#define SLEEPING_HEAD(gp) (&(gp)->sleeping_locks) + +#define SET_LOCK_TO_FIRST_ACTIVE_VP(gp, lock, vp) \ +{ \ + (lock) = (lock_descriptor_t *)vp->v_filocks; \ +} + +#define SET_LOCK_TO_FIRST_SLEEP_VP(gp, lock, vp) \ +{ \ +for ((lock) = SLEEPING_HEAD((gp))->l_next; ((lock) != SLEEPING_HEAD((gp)) && \ + (lock)->l_vnode != (vp)); (lock) = (lock)->l_next) \ + ; \ +(lock) = ((lock) == SLEEPING_HEAD((gp))) ? NULL : (lock); \ +} + +#define OVERLAP(lock1, lock2) \ + (((lock1)->l_start <= (lock2)->l_start && \ + (lock2)->l_start <= (lock1)->l_end) || \ + ((lock2)->l_start <= (lock1)->l_start && \ + (lock1)->l_start <= (lock2)->l_end)) + +#define IS_INITIAL(lock) ((lock)->l_status == FLK_INITIAL_STATE) +#define IS_ACTIVE(lock) ((lock)->l_status == FLK_ACTIVE_STATE) +#define IS_SLEEPING(lock) ((lock)->l_status == FLK_SLEEPING_STATE) +#define IS_GRANTED(lock) ((lock)->l_status == FLK_GRANTED_STATE) +#define IS_INTERRUPTED(lock) ((lock)->l_status == FLK_INTERRUPTED_STATE) +#define IS_CANCELLED(lock) ((lock)->l_status == FLK_CANCELLED_STATE) +#define IS_DEAD(lock) ((lock)->l_status == FLK_DEAD_STATE) + +#define IS_QUERY_LOCK(lock) ((lock)->l_state & QUERY_LOCK) +#define IS_RECOMPUTE(lock) ((lock)->l_state & RECOMPUTE_LOCK) +#define IS_BARRIER(lock) ((lock)->l_state & BARRIER_LOCK) +#define IS_DELETED(lock) ((lock)->l_state & DELETED_LOCK) +#define IS_REFERENCED(lock) ((lock)->l_state & REFERENCED_LOCK) +#define IS_IO_LOCK(lock) ((lock)->l_state & IO_LOCK) +#define IS_WILLING_TO_SLEEP(lock) \ + ((lock)->l_state & WILLING_TO_SLEEP_LOCK) +#define IS_LOCKMGR(lock) ((lock)->l_state & LOCKMGR_LOCK) +#define IS_NLM_UP(lock) ((lock)->l_nlm_state == FLK_NLM_UP) +/* Clustering: Macro for PXFS locks */ +#define IS_PXFS(lock) ((lock)->l_state & PXFS_LOCK) + +/* + * "local" requests don't involve the NFS lock manager in any way. + * "remote" requests can be on the server (requests from a remote client), + * in which case they should be associated with a local vnode (UFS, tmpfs, + * etc.). These requests are flagged with LOCKMGR_LOCK and are made using + * kernel service threads. Remote requests can also be on an NFS client, + * because the NFS lock manager uses local locking for some of its + * bookkeeping. These requests are made by regular user processes. + */ +#define IS_LOCAL(lock) (GETSYSID((lock)->l_flock.l_sysid) == 0) +#define IS_REMOTE(lock) (! IS_LOCAL(lock)) + +/* Clustering: Return value for blocking PXFS locks */ +/* + * For PXFS locks, reclock() will return this error code for requests that + * need to block + */ +#define PXFS_LOCK_BLOCKED -1 + +/* Clustering: PXFS callback function */ +/* + * This function is a callback from the LLM into the PXFS server module. It + * is initialized as a weak stub, and is functional when the pxfs server module + * is loaded. + */ +extern void cl_flk_state_transition_notify(lock_descriptor_t *lock, + int old_state, int new_state); + +#define BLOCKS(lock1, lock2) (!SAME_OWNER((lock1), (lock2)) && \ + (((lock1)->l_type == F_WRLCK) || \ + ((lock2)->l_type == F_WRLCK)) && \ + OVERLAP((lock1), (lock2))) + +#define COVERS(lock1, lock2) \ + (((lock1)->l_start <= (lock2)->l_start) && \ + ((lock1)->l_end >= (lock2)->l_end)) + +#define IN_LIST_REMOVE(ep) \ + { \ + (ep)->edge_in_next->edge_in_prev = (ep)->edge_in_prev; \ + (ep)->edge_in_prev->edge_in_next = (ep)->edge_in_next; \ + } + +#define ADJ_LIST_REMOVE(ep) \ + { \ + (ep)->edge_adj_next->edge_adj_prev = (ep)->edge_adj_prev; \ + (ep)->edge_adj_prev->edge_adj_next = (ep)->edge_adj_next; \ + } + +#define NOT_BLOCKED(lock) \ + ((lock)->l_edge.edge_adj_next == &(lock)->l_edge && !IS_GRANTED(lock)) + +#define GRANT_WAKEUP(lock) \ + { \ + flk_set_state(lock, FLK_GRANTED_STATE); \ + (lock)->l_state |= GRANTED_LOCK; \ + /* \ + * Clustering: PXFS locks do not sleep in the LLM, \ + * so there is no need to signal them \ + */ \ + if (!IS_PXFS(lock)) { \ + cv_signal(&(lock)->l_cv); \ + } \ + } + +#define CANCEL_WAKEUP(lock) \ + { \ + flk_set_state(lock, FLK_CANCELLED_STATE); \ + (lock)->l_state |= CANCELLED_LOCK; \ + /* \ + * Clustering: PXFS locks do not sleep in the LLM, \ + * so there is no need to signal them \ + */ \ + if (!IS_PXFS(lock)) { \ + cv_signal(&(lock)->l_cv); \ + } \ + } + +#define INTERRUPT_WAKEUP(lock) \ + { \ + flk_set_state(lock, FLK_INTERRUPTED_STATE); \ + (lock)->l_state |= INTERRUPTED_LOCK; \ + /* \ + * Clustering: PXFS locks do not sleep in the LLM, \ + * so there is no need to signal them \ + */ \ + if (!IS_PXFS(lock)) { \ + cv_signal(&(lock)->l_cv); \ + } \ + } + +#define REMOVE_SLEEP_QUEUE(lock) \ + { \ + ASSERT(IS_SLEEPING(lock) || IS_GRANTED(lock) || \ + IS_INTERRUPTED(lock) || IS_CANCELLED(lock)); \ + (lock)->l_state &= ~SLEEPING_LOCK; \ + (lock)->l_next->l_prev = (lock)->l_prev; \ + (lock)->l_prev->l_next = (lock)->l_next; \ + (lock)->l_next = (lock)->l_prev = (lock_descriptor_t *)NULL; \ + } + +#define NO_DEPENDENTS(lock) \ + ((lock)->l_edge.edge_in_next == &(lock)->l_edge) + +#define GRANT(lock) \ + { \ + (lock)->l_state |= GRANTED_LOCK; \ + flk_set_state(lock, FLK_GRANTED_STATE); \ + } + +#define FIRST_IN(lock) ((lock)->l_edge.edge_in_next) +#define FIRST_ADJ(lock) ((lock)->l_edge.edge_adj_next) +#define HEAD(lock) (&(lock)->l_edge) +#define NEXT_ADJ(ep) ((ep)->edge_adj_next) +#define NEXT_IN(ep) ((ep)->edge_in_next) +#define IN_ADJ_INIT(lock) \ +{ \ +(lock)->l_edge.edge_adj_next = (lock)->l_edge.edge_adj_prev = &(lock)->l_edge; \ +(lock)->l_edge.edge_in_next = (lock)->l_edge.edge_in_prev = &(lock)->l_edge; \ +} + +#define COPY(lock1, lock2) \ +{ \ +(lock1)->l_graph = (lock2)->l_graph; \ +(lock1)->l_vnode = (lock2)->l_vnode; \ +(lock1)->l_type = (lock2)->l_type; \ +(lock1)->l_state = (lock2)->l_state; \ +(lock1)->l_start = (lock2)->l_start; \ +(lock1)->l_end = (lock2)->l_end; \ +(lock1)->l_flock = (lock2)->l_flock; \ +(lock1)->l_zoneid = (lock2)->l_zoneid; \ +(lock1)->pvertex = (lock2)->pvertex; \ +} + +/* + * Clustering + */ +/* Routines to set and get the NLM state in a lock request */ +#define SET_NLM_STATE(lock, nlm_state) ((lock)->l_nlm_state = nlm_state) +#define GET_NLM_STATE(lock) ((lock)->l_nlm_state) +/* + * NLM registry abstraction: + * Abstraction overview: + * This registry keeps track of the NLM servers via their nlmids + * that have requested locks at the LLM this registry is associated + * with. + */ +/* Routines to manipulate the NLM registry object state */ +#define FLK_REGISTRY_IS_NLM_UNKNOWN(nlmreg, nlmid) \ + ((nlmreg)[nlmid] == FLK_NLM_UNKNOWN) +#define FLK_REGISTRY_IS_NLM_UP(nlmreg, nlmid) \ + ((nlmreg)[nlmid] == FLK_NLM_UP) +#define FLK_REGISTRY_ADD_NLMID(nlmreg, nlmid) \ + ((nlmreg)[nlmid] = FLK_NLM_UP) +#define FLK_REGISTRY_CHANGE_NLM_STATE(nlmreg, nlmid, state) \ + ((nlmreg)[nlmid] = state) + +/* Indicates the effect of executing a request on the existing locks */ + +#define FLK_UNLOCK 0x1 /* request unlocks the existing lock */ +#define FLK_DOWNGRADE 0x2 /* request downgrades the existing lock */ +#define FLK_UPGRADE 0x3 /* request upgrades the existing lock */ +#define FLK_STAY_SAME 0x4 /* request type is same as existing lock */ + + +/* proc graph definitions */ + +/* + * Proc graph is the global process graph that maintains information + * about the dependencies between processes. An edge is added between two + * processes represented by proc_vertex's A and B, iff there exists l1 + * owned by process A in any of the lock_graph's dependent on l2 + * (thus having an edge to l2) owned by process B. + */ +struct proc_vertex { + pid_t pid; /* pid of the process */ + long sysid; /* sysid of the process */ + struct proc_edge *edge; /* adajcent edges of this process */ + int incount; /* Number of inedges to this process */ + struct proc_edge *p_sedge; /* used for implementing stack alg. */ + struct proc_vertex *p_stack; /* used for stack alg. */ + int atime; /* used for cycle detection algorithm */ + int dtime; /* used for cycle detection algorithm */ + int index; /* index into the array of proc_graph vertices */ +}; + +typedef struct proc_vertex proc_vertex_t; + +struct proc_edge { + struct proc_edge *next; /* next edge in adjacency list */ + int refcount; /* reference count of this edge */ + struct proc_vertex *to_proc; /* process this points to */ +}; + +typedef struct proc_edge proc_edge_t; + + +#define PROC_CHUNK 100 + +struct proc_graph { + struct proc_vertex **proc; /* list of proc_vertexes */ + int gcount; /* list size */ + int free; /* number of free slots in the list */ + int mark; /* used for graph coloring */ +}; + +typedef struct proc_graph proc_graph_t; + +extern struct proc_graph pgraph; + +#define PROC_SAME_OWNER(lock, pvertex) \ + (((lock)->l_flock.l_pid == (pvertex)->pid) && \ + ((lock)->l_flock.l_sysid == (pvertex)->sysid)) + +#define PROC_ARRIVE(pvertex) ((pvertex)->atime = pgraph.mark) +#define PROC_DEPART(pvertex) ((pvertex)->dtime = pgraph.mark) +#define PROC_ARRIVED(pvertex) ((pvertex)->atime == pgraph.mark) +#define PROC_DEPARTED(pvertex) ((pvertex)->dtime == pgraph.mark) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FLOCK_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/fs/zfs.h b/illumos-x86_64/usr/include/sys/fm/fs/zfs.h new file mode 100644 index 00000000..8e56f244 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/fs/zfs.h @@ -0,0 +1,103 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FM_FS_ZFS_H +#define _SYS_FM_FS_ZFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZFS_ERROR_CLASS "fs.zfs" + +#define FM_EREPORT_ZFS_CHECKSUM "checksum" +#define FM_EREPORT_ZFS_AUTHENTICATION "authentication" +#define FM_EREPORT_ZFS_IO "io" +#define FM_EREPORT_ZFS_DATA "data" +#define FM_EREPORT_ZFS_DELAY "delay" +#define FM_EREPORT_ZFS_POOL "zpool" +#define FM_EREPORT_ZFS_DEVICE_UNKNOWN "vdev.unknown" +#define FM_EREPORT_ZFS_DEVICE_OPEN_FAILED "vdev.open_failed" +#define FM_EREPORT_ZFS_DEVICE_CORRUPT_DATA "vdev.corrupt_data" +#define FM_EREPORT_ZFS_DEVICE_NO_REPLICAS "vdev.no_replicas" +#define FM_EREPORT_ZFS_DEVICE_BAD_GUID_SUM "vdev.bad_guid_sum" +#define FM_EREPORT_ZFS_DEVICE_TOO_SMALL "vdev.too_small" +#define FM_EREPORT_ZFS_DEVICE_BAD_LABEL "vdev.bad_label" +#define FM_EREPORT_ZFS_DEVICE_BAD_ASHIFT "vdev.bad_ashift" +#define FM_EREPORT_ZFS_IO_FAILURE "io_failure" +#define FM_EREPORT_ZFS_PROBE_FAILURE "probe_failure" +#define FM_EREPORT_ZFS_LOG_REPLAY "log_replay" +#define FM_EREPORT_ZFS_CONFIG_CACHE_WRITE "config_cache_write" + +#define FM_EREPORT_PAYLOAD_ZFS_POOL "pool" +#define FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE "pool_failmode" +#define FM_EREPORT_PAYLOAD_ZFS_POOL_GUID "pool_guid" +#define FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT "pool_context" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID "vdev_guid" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_TYPE "vdev_type" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_PATH "vdev_path" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_DEVID "vdev_devid" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_FRU "vdev_fru" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_STATE "vdev_state" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_ASHIFT "vdev_ashift" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_DELAYS "vdev_delays" +#define FM_EREPORT_PAYLOAD_ZFS_PARENT_GUID "parent_guid" +#define FM_EREPORT_PAYLOAD_ZFS_PARENT_TYPE "parent_type" +#define FM_EREPORT_PAYLOAD_ZFS_PARENT_PATH "parent_path" +#define FM_EREPORT_PAYLOAD_ZFS_PARENT_DEVID "parent_devid" +#define FM_EREPORT_PAYLOAD_ZFS_ZIO_OBJSET "zio_objset" +#define FM_EREPORT_PAYLOAD_ZFS_ZIO_OBJECT "zio_object" +#define FM_EREPORT_PAYLOAD_ZFS_ZIO_LEVEL "zio_level" +#define FM_EREPORT_PAYLOAD_ZFS_ZIO_BLKID "zio_blkid" +#define FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR "zio_err" +#define FM_EREPORT_PAYLOAD_ZFS_ZIO_OFFSET "zio_offset" +#define FM_EREPORT_PAYLOAD_ZFS_ZIO_SIZE "zio_size" +#define FM_EREPORT_PAYLOAD_ZFS_PREV_STATE "prev_state" +#define FM_EREPORT_PAYLOAD_ZFS_CKSUM_EXPECTED "cksum_expected" +#define FM_EREPORT_PAYLOAD_ZFS_CKSUM_ACTUAL "cksum_actual" +#define FM_EREPORT_PAYLOAD_ZFS_CKSUM_ALGO "cksum_algorithm" +#define FM_EREPORT_PAYLOAD_ZFS_CKSUM_BYTESWAP "cksum_byteswap" +#define FM_EREPORT_PAYLOAD_ZFS_BAD_OFFSET_RANGES "bad_ranges" +#define FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_MIN_GAP "bad_ranges_min_gap" +#define FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_SETS "bad_range_sets" +#define FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_CLEARS "bad_range_clears" +#define FM_EREPORT_PAYLOAD_ZFS_BAD_SET_BITS "bad_set_bits" +#define FM_EREPORT_PAYLOAD_ZFS_BAD_CLEARED_BITS "bad_cleared_bits" +#define FM_EREPORT_PAYLOAD_ZFS_BAD_SET_HISTOGRAM "bad_set_histogram" +#define FM_EREPORT_PAYLOAD_ZFS_BAD_CLEARED_HISTOGRAM "bad_cleared_histogram" + +#define FM_EREPORT_FAILMODE_WAIT "wait" +#define FM_EREPORT_FAILMODE_CONTINUE "continue" +#define FM_EREPORT_FAILMODE_PANIC "panic" + +#define FM_RESOURCE_REMOVED "removed" +#define FM_RESOURCE_AUTOREPLACE "autoreplace" +#define FM_RESOURCE_STATECHANGE "statechange" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_FS_ZFS_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/io/ddi.h b/illumos-x86_64/usr/include/sys/fm/io/ddi.h new file mode 100644 index 00000000..d8c772cd --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/io/ddi.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FM_IO_DDI_H +#define _SYS_FM_IO_DDI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define DDI_DVR_MAX_CLASS 32 + +/* IO-specific FMA ereport class defintions */ +#define DDI_IO_CLASS "io" + +/* leaf driver detected ereport definitions */ +#define DDI_FM_DEVICE "device" +#define DDI_FM_DEVICE_INVAL_STATE "inval_state" +#define DDI_FM_DEVICE_NO_RESPONSE "no_response" +#define DDI_FM_DEVICE_STALL "stall" +#define DDI_FM_DEVICE_BADINT_LIMIT "badint_limit" +#define DDI_FM_DEVICE_INTERN_CORR "intern_corr" +#define DDI_FM_DEVICE_INTERN_UNCORR "intern_uncorr" +#define DDI_FM_DEVICE_FW_CORRUPT "fw_corrupt" +#define DDI_FM_DEVICE_FW_MISMATCH "fw_mismatch" + +/* service impact ereport definitions */ +#define DDI_FM_SERVICE_IMPACT "service" +#define DDI_FM_SERVICE_LOST "lost" +#define DDI_FM_SERVICE_DEGRADED "degraded" +#define DDI_FM_SERVICE_RESTORED "restored" +#define DDI_FM_SERVICE_UNAFFECTED "unaffected" + +/* Driver defect ereport specifications */ +#define DVR_ERPT "ddi." +#define DVR_ECONTEXT "context" /* Invalid calling context */ +#define DVR_EINVAL "einval" /* Invalid calling semantic */ +#define DVR_EFMCAP "fm-capability" /* Improper FM capability */ +#define DVR_EVER "version" /* Invalid structure version */ + +/* Required payload member names */ +#define DVR_NAME "dvr-name" +#define DVR_STACK "dvr-stack" +#define DVR_STACK_DEPTH "dvr-stack-depth" +#define DVR_ERR_SPECIFIC "dvr-error-specific" + +/* Generic NIC driver ereports. */ +#define DDI_FM_NIC "nic" +#define DDI_FM_TXR_ERROR "txr-err" + +/* Valid values of the "error" field in txr-err ereports */ +#define DDI_FM_TXR_ERROR_WHITELIST "whitelist" +#define DDI_FM_TXR_ERROR_NOTSUPP "notsupp" +#define DDI_FM_TXR_ERROR_OVERTEMP "overtemp" +#define DDI_FM_TXR_ERROR_HWFAIL "hwfail" +#define DDI_FM_TXR_ERROR_UNKNOWN "unknown" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_IO_DDI_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/io/disk.h b/illumos-x86_64/usr/include/sys/fm/io/disk.h new file mode 100644 index 00000000..99a93321 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/io/disk.h @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_FM_IO_DISK_H +#define _SYS_FM_IO_DISK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define DISK_ERROR_CLASS "io.disk" + +#define FM_FAULT_DISK_PREDFAIL "predictive-failure" +#define FM_FAULT_DISK_OVERTEMP "over-temperature" +#define FM_FAULT_DISK_TESTFAIL "self-test-failure" +#define FM_FAULT_SSM_WEAROUT "ssm-wearout" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_IO_DISK_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/io/opl_mc_fm.h b/illumos-x86_64/usr/include/sys/fm/io/opl_mc_fm.h new file mode 100644 index 00000000..af8b2472 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/io/opl_mc_fm.h @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FM_IO_OPL_MC_FM_H +#define _SYS_FM_IO_OPL_MC_FM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* mc-opl ereport components */ +#define MC_OPL_ERROR_CLASS "asic.mac" +#define MC_OPL_PTRL_SUBCLASS "ptrl" +#define MC_OPL_MI_SUBCLASS "mi" + +/* + * ereport definition + */ +#define MC_OPL_UE "ue" +#define MC_OPL_CE "ce" +#define MC_OPL_ICE "ice" +#define MC_OPL_CMPE "cmpe" +#define MC_OPL_MUE "mue" +#define MC_OPL_SUE "sue" + +/* mc-opl payload name fields */ +#define MC_OPL_BOARD "board" +#define MC_OPL_BANK "bank" +#define MC_OPL_STATUS "status" +#define MC_OPL_ERR_ADD "err-add" +#define MC_OPL_ERR_LOG "err-log" +#define MC_OPL_ERR_SYND "syndrome" +#define MC_OPL_ERR_DIMMSLOT "dimm-slot" +#define MC_OPL_ERR_DRAM "dram-place" +#define MC_OPL_PA "pa" +#define MC_OPL_FLT_TYPE "flt-type" + +#define MC_OPL_RESOURCE "resource" + +#define MC_OPL_NO_UNUM "" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_IO_OPL_MC_FM_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/io/pci.h b/illumos-x86_64/usr/include/sys/fm/io/pci.h new file mode 100644 index 00000000..379b66dd --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/io/pci.h @@ -0,0 +1,164 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FM_IO_PCI_H +#define _SYS_FM_IO_PCI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define PCI_ERROR_SUBCLASS "pci" +#define PCI_SEC_ERROR_SUBCLASS "sec" + +/* Common PCI ereport classes */ +#define PCI_DET_PERR "dpe" +#define PCI_MDPE "mdpe" +#define PCI_REC_SERR "rserr" +#define PCI_SIG_SERR "sserr" +#define PCI_MA "ma" +#define PCI_REC_TA "rta" +#define PCI_SIG_TA "sta" +#define PCI_DTO "dto" +#define PCI_TARG_MDPE "target-mdpe" +#define PCI_TARG_MA "target-ma" +#define PCI_TARG_REC_TA "target-rta" +#define PCI_NR "nr" + +/* PCI Error payload name fields */ +#define PCI_CONFIG_STATUS "pci-status" +#define PCI_CONFIG_COMMAND "pci-command" +#define PCI_SEC_CONFIG_STATUS "pci-sec-status" +#define PCI_BCNTRL "pci-bdg-ctrl" +#define PCI_PA "pci-pa" + +/* + * PCI-X extensions + */ +#define PCIX_ERROR_SUBCLASS "pcix" +#define PCIX_SEC_ERROR_SUBCLASS "sec-" + +/* Common PCI-X ereport classes */ +#define PCIX_ECC_CE_ADDR "ecc.ce-addr" +#define PCIX_ECC_CE_ATTR "ecc.ce-attr" +#define PCIX_ECC_CE_DATA "ecc.ce-data" +#define PCIX_ECC_UE_ADDR "ecc.ue-addr" +#define PCIX_ECC_UE_ATTR "ecc.ue-attr" +#define PCIX_ECC_UE_DATA "ecc.ue-data" +#define PCIX_RX_SPL_MSG "rx-spl" +#define PCIX_ECC_S_CE "s-ce" +#define PCIX_ECC_S_UE "s-ue" +#define PCIX_SPL_DIS "spl-dis" +#define PCIX_BSS_SPL_DLY "spl-dly" +#define PCIX_BSS_SPL_OR "spl-or" +#define PCIX_UNEX_SPL "unex-spl" + +#define PCIX_SEC_STATUS "pcix-sec-status" +#define PCIX_BDG_STAT "pcix-bdg-stat" +#define PCIX_COMMAND "pcix-command" +#define PCIX_STATUS "pcix-status" +#define PCIX_ECC_CTLSTAT "pcix-ecc-ctlstat" +#define PCIX_ECC_ATTR "pcix-ecc-attr" + +/* + * PCI Express extensions + */ +#define PCIEX_ERROR_SUBCLASS "pciex" + +/* Common PCI Express ereport classes */ +#define PCIEX_RE "pl.re" +#define PCIEX_TE "pl.te" + +#define PCIEX_SD "dl.sd" +#define PCIEX_BDP "dl.bdllp" +#define PCIEX_BTP "dl.btlp" +#define PCIEX_DLP "dl.dllp" +#define PCIEX_RNR "dl.rnr" +#define PCIEX_RTO "dl.rto" + +#define PCIEX_CA "tl.ca" +#define PCIEX_CTO "tl.cto" +#define PCIEX_ECRC "tl.ecrc" +#define PCIEX_FCP "tl.fcp" +#define PCIEX_MFP "tl.mtlp" +#define PCIEX_POIS "tl.ptlp" +#define PCIEX_ROF "tl.rof" +#define PCIEX_UC "tl.uc" +#define PCIEX_UR "tl.ur" + +#define PCIEX_INTERR "bdg.sec-interr" +#define PCIEX_S_MA_SC "bdg.sec-ma-sc" +#define PCIEX_S_PERR "bdg.sec-perr" +#define PCIEX_S_RMA "bdg.sec-rma" +#define PCIEX_S_RTA "bdg.sec-rta" +#define PCIEX_S_SERR "bdg.sec-serr" +#define PCIEX_S_TA_SC "bdg.sec-ta-sc" +#define PCIEX_S_TEX "bdg.sec-tex" +#define PCIEX_S_UADR "bdg.sec-uadr" +#define PCIEX_S_UAT "bdg.sec-uat" +#define PCIEX_S_UDE "bdg.sec-ude" +#define PCIEX_S_USC "bdg.usc" +#define PCIEX_S_USCMD "bdg.uscmd" + +#define PCIEX_RC_FE_MSG "rc.fe-msg" +#define PCIEX_RC_NFE_MSG "rc.nfe-msg" +#define PCIEX_RC_CE_MSG "rc.ce-msg" +#define PCIEX_RC_MCE_MSG "rc.mce-msg" +#define PCIEX_RC_MUE_MSG "rc.mue-msg" + +#define PCIEX_CORR "correctable" +#define PCIEX_FAT "fatal" +#define PCIEX_NONFAT "nonfatal" +#define PCIEX_NADV "noadverr" +#define PCIEX_ANFE "a-nonfatal" + +/* PCI Express payload name fields */ +#define PCIEX_DEVSTS_REG "dev-status" +#define PCIEX_LINKSTS_REG "link-status" +#define PCIEX_ROOT_ERRSTS_REG "rc-status" +#define PCIEX_CE_STATUS_REG "ce-status" +#define PCIEX_UE_STATUS_REG "ue-status" +#define PCIEX_UE_SEV_REG "ue-severity" +#define PCIEX_SEC_UE_STATUS "sue-status" +#define PCIEX_SRC_ID "source-id" +#define PCIEX_SRC_VALID "source-valid" +#define PCIEX_ADV_CTL "adv-ctl" +#define PCIEX_UE_HDR0 "ue_hdr0" +#define PCIEX_UE_HDR1 "ue_hdr1" +#define PCIEX_UE_HDR2 "ue_hdr2" +#define PCIEX_UE_HDR3 "ue_hdr3" +#define PCIEX_SUE_HDR0 "sue_hdr0" +#define PCIEX_SUE_HDR1 "sue_hdr1" +#define PCIEX_SUE_HDR2 "sue_hdr2" +#define PCIEX_SUE_HDR3 "sue_hdr3" + +/* Common fabric class names */ +#define PCIEX_FABRIC "fabric" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_IO_PCI_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/io/scsi.h b/illumos-x86_64/usr/include/sys/fm/io/scsi.h new file mode 100644 index 00000000..f2052e73 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/io/scsi.h @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_FM_IO_SCSI_H +#define _SYS_FM_IO_SCSI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following ereports are generated by the userland disk-transport module in + * response to errors reported by the disks. + */ +#define SCSI_ERROR_CLASS "io.scsi" + +#define SCSI_DISK_CLASS "disk" + +#define FM_EREPORT_SCSI_PREDFAIL "predictive-failure" +#define FM_EREPORT_PAYLOAD_SCSI_ASC "additional-sense-code" +#define FM_EREPORT_PAYLOAD_SCSI_ASCQ "additional-sense-code-qualifier" + +#define FM_EREPORT_SCSI_OVERTEMP "over-temperature" +#define FM_EREPORT_PAYLOAD_SCSI_CURTEMP "current-temperature" +#define FM_EREPORT_PAYLOAD_SCSI_THRESHTEMP "threshold-temperature" + +#define FM_EREPORT_SCSI_SSMWEAROUT "ssm-wearout" +#define FM_EREPORT_PAYLOAD_SCSI_CURSSMWEAROUT "current-ssm-wearout" +#define FM_EREPORT_PAYLOAD_SCSI_THRSHSSMWEAROUT "threshold-ssm-wearout" + +#define FM_EREPORT_SCSI_TESTFAIL "self-test-failure" +#define FM_EREPORT_PAYLOAD_SCSI_RESULTCODE "result-code" +#define FM_EREPORT_PAYLOAD_SCSI_ADDRESS "address" +#define FM_EREPORT_PAYLOAD_SCSI_TIMESTAMP "timestamp" +#define FM_EREPORT_PAYLOAD_SCSI_SEGMENT "segment" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_IO_SCSI_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/io/sun4upci.h b/illumos-x86_64/usr/include/sys/fm/io/sun4upci.h new file mode 100644 index 00000000..93f8624f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/io/sun4upci.h @@ -0,0 +1,175 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FM_IO_SUN4UPCI_H +#define _SYS_FM_IO_SUN4UPCI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Sun4u PCI FMA Event Protocol definitions */ + +#define PCI_PSYCHO "psy" +#define PCI_SCHIZO "sch" +#define PCI_TOMATILLO "tom" +#define PCI_XMITS "xmits" + +/* PBM ereport classes */ +#define PCI_PBM_TTO "pbm.tto" +#define PCI_PBM_RETRY "pbm.rl" +#define PCI_SEC_PBM_TTO "pbm.s-tto" +#define PCI_SEC_PBM_RETRY "pbm.s-rl" +#define PCI_SEC_MA "pbm.s-ma" +#define PCI_SEC_REC_TA "pbm.s-rta" +#define PCI_SEC_MDPE "pbm.s-mdpe" +#define PCI_PBM_TARG_TTO "pbm.target-tto" +#define PCI_PBM_TARG_RETRY "pbm.target-rl" + +/* Schizo/Tomatillo ereport classes */ +#define PCI_SCH_MMU_ERR "mmu" +#define PCI_SCH_BUS_UNUSABLE_ERR "bu" +#define PCI_SEC_SCH_BUS_UNUSABLE_ERR "s-bu" +#define PCI_SCH_SLOT_LOCK_ERR "sl" +#define PCI_SCH_SBH "sbh" + +#define PCI_TOM_MMU_BAD_TSBTBW "mmu.btt" +#define PCI_TOM_MMU_BAD_VA "mmu.bva" +#define PCI_TOM_MMU_PROT_ERR "mmu.prot" +#define PCI_TOM_MMU_INVAL_ERR "mmu.inval" +#define PCI_TOM_MMU_TO_ERR "mmu.to" +#define PCI_TOM_MMU_UE "mmu.ue" + +/* Psycho ereport classes */ + +#define PCI_PSY_SBH "sbh" + +/* IO detected memory ereport classes */ +#define PCI_ECC_DRD_UE "ecc.drue" +#define PCI_ECC_DRD_CE "ecc.drce" +#define PCI_ECC_DWR_UE "ecc.dwue" +#define PCI_ECC_DWR_CE "ecc.dwce" +#define PCI_ECC_PIO_UE "ecc.pue" +#define PCI_ECC_PIO_CE "ecc.pce" +#define PCI_ECC_SEC_DRD_UE "ecc.s-drue" +#define PCI_ECC_SEC_DRD_CE "ecc.s-drce" +#define PCI_ECC_SEC_DWR_UE "ecc.s-dwue" +#define PCI_ECC_SEC_DWR_CE "ecc.s-dwce" +#define PCI_ECC_SEC_PIO_UE "ecc.s-pue" +#define PCI_ECC_SEC_PIO_CE "ecc.s-pce" + + +/* Safari ereport classes */ +#define SAFARI_APERR "saf.ape" +#define SAFARI_UNMAP_ERR "saf.um" +#define SAFARI_TO_ERR "saf.to" +#define SAFARI_BUS_ERR "saf.bus" +#define SAFARI_DSTAT_ERR "saf.dstat" +#define SAFARI_BAD_CMD "saf.bc" +#define SAFARI_SSM_DIS "saf.smm-dis" +#define SAFARI_BAD_CMD_PCIA "saf.bca" +#define SAFARI_BAD_CMD_PCIB "saf.bcb" +#define SAFARI_PAR_ERR_INT_PCIB "saf.parb" +#define SAFARI_PAR_ERR_INT_PCIA "saf.para" +#define SAFARI_PAR_ERR_INT_SAF "saf.pars" +#define SAFARI_PLL_ERR_PCIB "saf.pllb" +#define SAFARI_PLL_ERR_PCIA "saf.plla" +#define SAFARI_PLL_ERR_SAF "saf.plls" +#define SAFARI_SAF_CIQ_TO "saf.ciq-to" +#define SAFARI_SAF_LPQ_TO "saf.lpq-to" +#define SAFARI_SAF_SFPQ_TO "saf.sfpq-to" +#define SAFARI_SAF_UFPQ_TO "saf.ufpq-to" +#define SAFARI_CPU0_PAR_SINGLE "saf.cpu0-par" +#define SAFARI_CPU0_PAR_BIDI "saf.cpu0-bidi" +#define SAFARI_CPU1_PAR_SINGLE "saf.cpu1-par" +#define SAFARI_CPU1_PAR_BIDI "saf.cpu1-bidi" + +/* Jbus ereport classes */ +#define JBUS_APERR "jbus.ape" +#define JBUS_PWR_DATA_PERR "jbus.pwpe" +#define JBUS_DRD_DATA_PERR "jbus.drpe" +#define JBUS_DWR_DATA_PERR "jbus.dwpe" +#define JBUS_CTL_PERR "jbus.cpe" +#define JBUS_ILL_BYTE_EN "jbus.ibe" +#define JBUS_ILL_COH_IN "jbus.iis" +#define JBUS_SNOOP_ERR_RD "jbus.srd" +#define JBUS_SNOOP_ERR_RDS "jbus.srds" +#define JBUS_SNOOP_ERR_RDSA "jbus.srdsa" +#define JBUS_SNOOP_ERR_OWN "jbus.sown" +#define JBUS_SNOOP_ERR_RDO "jbus.srdo" +#define JBUS_BAD_CMD "jbus.bc" +#define JBUS_UNMAP_ERR "jbus.um" +#define JBUS_TO_ERR "jbus.to" +#define JBUS_BUS_ERR "jbus.bus" +#define JBUS_TO_EXP_ERR "jbus.to-exp" +#define JBUS_SNOOP_ERR_GR "jbus.sgr" +#define JBUS_SNOOP_ERR_PCI "jbus.spci" +#define JBUS_SNOOP_ERR "jbus.snp" + +/* PBM ereport payload */ +#define PCI_PBM_CSR "pbm-csr" +#define PCI_PBM_AFSR "pbm-afsr" +#define PCI_PBM_AFAR "pbm-afar" +#define PCI_PBM_SLOT "errant-slot" +#define PCI_PBM_VALOG "pbm-valog" + +/* IOMMU ereport payload */ +#define PCI_PBM_IOMMU_CTRL "iommu-csr" +#define PCI_PBM_IOMMU_TFAR "iommu-tfar" + +/* IO detected memory error payload */ +#define PCI_ECC_AFSR "ecc-afsr" +#define PCI_ECC_AFAR "ecc-afar" +#define PCI_ECC_CTRL "ecc-ctrl" +#define PCI_ECC_SYND "ecc-syndrome" +#define PCI_ECC_TYPE "ecc-err-type" +#define PCI_ECC_DISP "ecc-err-disposition" +#define PCI_ECC_UNUM "mem-unum" +#define PCI_ECC_RESOURCE "mem-resource" + +/* Safari ereport payload */ +#define SAFARI_CSR "safari-csr" +#define SAFARI_ERR "safari-err" +#define SAFARI_INTR "safari-intr" +#define SAFARI_ELOG "safari-elog" +#define SAFARI_PCR "safari-pcr" +#define SAFARI_RESOURCE "safari-resource" +#define PCI_PBM_LOG_1 "pbm-log1" +#define PCI_PBM_LOG_2 "pbm-log2" + +/* Jbus ereport payload */ +#define JBUS_CSR "jbus-csr" +#define JBUS_ERR "jbus-err" +#define JBUS_INTR "jbus-intr" +#define JBUS_ELOG "jbus-elog" +#define JBUS_PCR "jbus-pcr" +#define JBUS_RESOURCE "jbus-resource" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_IO_SUN4UPCI_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/protocol.h b/illumos-x86_64/usr/include/sys/fm/protocol.h new file mode 100644 index 00000000..e0140bb0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/protocol.h @@ -0,0 +1,382 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_FM_PROTOCOL_H +#define _SYS_FM_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +#include +#include +#else +#include +#include +#endif +#include + +/* FM common member names */ +#define FM_CLASS "class" +#define FM_VERSION "version" + +/* FM protocol category 1 class names */ +#define FM_EREPORT_CLASS "ereport" +#define FM_FAULT_CLASS "fault" +#define FM_DEFECT_CLASS "defect" +#define FM_RSRC_CLASS "resource" +#define FM_LIST_EVENT "list" +#define FM_IREPORT_CLASS "ireport" + +/* FM list.* event class values */ +#define FM_LIST_SUSPECT_CLASS FM_LIST_EVENT ".suspect" +#define FM_LIST_ISOLATED_CLASS FM_LIST_EVENT ".isolated" +#define FM_LIST_REPAIRED_CLASS FM_LIST_EVENT ".repaired" +#define FM_LIST_UPDATED_CLASS FM_LIST_EVENT ".updated" +#define FM_LIST_RESOLVED_CLASS FM_LIST_EVENT ".resolved" + +/* ereport class subcategory values */ +#define FM_ERROR_CPU "cpu" +#define FM_ERROR_IO "io" + +/* ereport version and payload member names */ +#define FM_EREPORT_VERS0 0 +#define FM_EREPORT_VERSION FM_EREPORT_VERS0 + +/* ereport payload member names */ +#define FM_EREPORT_DETECTOR "detector" +#define FM_EREPORT_ENA "ena" + +/* list.* event payload member names */ +#define FM_LIST_EVENT_SIZE "list-sz" + +/* ireport.* event payload member names */ +#define FM_IREPORT_DETECTOR "detector" +#define FM_IREPORT_UUID "uuid" +#define FM_IREPORT_PRIORITY "pri" +#define FM_IREPORT_ATTRIBUTES "attr" + +/* + * list.suspect, isolated, updated, repaired and resolved + * versions/payload member names. + */ +#define FM_SUSPECT_UUID "uuid" +#define FM_SUSPECT_DIAG_CODE "code" +#define FM_SUSPECT_DIAG_TIME "diag-time" +#define FM_SUSPECT_DE "de" +#define FM_SUSPECT_FAULT_LIST "fault-list" +#define FM_SUSPECT_FAULT_SZ "fault-list-sz" +#define FM_SUSPECT_FAULT_STATUS "fault-status" +#define FM_SUSPECT_INJECTED "__injected" +#define FM_SUSPECT_MESSAGE "message" +#define FM_SUSPECT_RETIRE "retire" +#define FM_SUSPECT_RESPONSE "response" +#define FM_SUSPECT_SEVERITY "severity" + +#define FM_SUSPECT_VERS0 0 +#define FM_SUSPECT_VERSION FM_SUSPECT_VERS0 + +#define FM_SUSPECT_FAULTY 0x1 +#define FM_SUSPECT_UNUSABLE 0x2 +#define FM_SUSPECT_NOT_PRESENT 0x4 +#define FM_SUSPECT_DEGRADED 0x8 +#define FM_SUSPECT_REPAIRED 0x10 +#define FM_SUSPECT_REPLACED 0x20 +#define FM_SUSPECT_ACQUITTED 0x40 + +/* fault event versions and payload member names */ +#define FM_FAULT_VERS0 0 +#define FM_FAULT_VERSION FM_FAULT_VERS0 + +#define FM_FAULT_ASRU "asru" +#define FM_FAULT_FRU "fru" +#define FM_FAULT_FRU_LABEL "fru-label" +#define FM_FAULT_CERTAINTY "certainty" +#define FM_FAULT_RESOURCE "resource" +#define FM_FAULT_LOCATION "location" + +/* resource event versions and payload member names */ +#define FM_RSRC_VERS0 0 +#define FM_RSRC_VERSION FM_RSRC_VERS0 +#define FM_RSRC_RESOURCE "resource" + +/* resource.fm.asru.* payload member names */ +#define FM_RSRC_ASRU_UUID "uuid" +#define FM_RSRC_ASRU_CODE "code" +#define FM_RSRC_ASRU_FAULTY "faulty" +#define FM_RSRC_ASRU_REPAIRED "repaired" +#define FM_RSRC_ASRU_REPLACED "replaced" +#define FM_RSRC_ASRU_ACQUITTED "acquitted" +#define FM_RSRC_ASRU_RESOLVED "resolved" +#define FM_RSRC_ASRU_UNUSABLE "unusable" +#define FM_RSRC_ASRU_EVENT "event" + +/* resource.fm.xprt.* versions and payload member names */ +#define FM_RSRC_XPRT_VERS0 0 +#define FM_RSRC_XPRT_VERSION FM_RSRC_XPRT_VERS0 +#define FM_RSRC_XPRT_UUID "uuid" +#define FM_RSRC_XPRT_SUBCLASS "subclass" +#define FM_RSRC_XPRT_FAULT_STATUS "fault-status" +#define FM_RSRC_XPRT_FAULT_HAS_ASRU "fault-has-asru" + +/* + * FM ENA Format Macros + */ +#define ENA_FORMAT_MASK 0x3 +#define ENA_FORMAT(ena) ((ena) & ENA_FORMAT_MASK) + +/* ENA format types */ +#define FM_ENA_FMT0 0 +#define FM_ENA_FMT1 1 +#define FM_ENA_FMT2 2 + +/* Format 1 */ +#define ENA_FMT1_GEN_MASK 0x00000000000003FCull +#define ENA_FMT1_ID_MASK 0xFFFFFFFFFFFFFC00ull +#define ENA_FMT1_CPUID_MASK 0x00000000000FFC00ull +#define ENA_FMT1_TIME_MASK 0xFFFFFFFFFFF00000ull +#define ENA_FMT1_GEN_SHFT 2 +#define ENA_FMT1_ID_SHFT 10 +#define ENA_FMT1_CPUID_SHFT ENA_FMT1_ID_SHFT +#define ENA_FMT1_TIME_SHFT 20 + +/* Format 2 */ +#define ENA_FMT2_GEN_MASK 0x00000000000003FCull +#define ENA_FMT2_ID_MASK 0xFFFFFFFFFFFFFC00ull +#define ENA_FMT2_TIME_MASK ENA_FMT2_ID_MASK +#define ENA_FMT2_GEN_SHFT 2 +#define ENA_FMT2_ID_SHFT 10 +#define ENA_FMT2_TIME_SHFT ENA_FMT2_ID_SHFT + +/* Common FMRI type names */ +#define FM_FMRI_AUTHORITY "authority" +#define FM_FMRI_SCHEME "scheme" +#define FM_FMRI_SVC_AUTHORITY "svc-authority" +#define FM_FMRI_FACILITY "facility" + +/* FMRI authority-type member names */ +#define FM_FMRI_AUTH_CHASSIS "chassis-id" +#define FM_FMRI_AUTH_PRODUCT_SN "product-sn" +#define FM_FMRI_AUTH_PRODUCT "product-id" +#define FM_FMRI_AUTH_DOMAIN "domain-id" +#define FM_FMRI_AUTH_SERVER "server-id" +#define FM_FMRI_AUTH_HOST "host-id" + +#define FM_AUTH_VERS0 0 +#define FM_FMRI_AUTH_VERSION FM_AUTH_VERS0 + +/* scheme name values */ +#define FM_FMRI_SCHEME_FMD "fmd" +#define FM_FMRI_SCHEME_DEV "dev" +#define FM_FMRI_SCHEME_HC "hc" +#define FM_FMRI_SCHEME_SVC "svc" +#define FM_FMRI_SCHEME_CPU "cpu" +#define FM_FMRI_SCHEME_MEM "mem" +#define FM_FMRI_SCHEME_MOD "mod" +#define FM_FMRI_SCHEME_PKG "pkg" +#define FM_FMRI_SCHEME_LEGACY "legacy-hc" +#define FM_FMRI_SCHEME_ZFS "zfs" +#define FM_FMRI_SCHEME_SW "sw" +#define FM_FMRI_SCHEME_PATH "path" + +/* Scheme versions */ +#define FMD_SCHEME_VERSION0 0 +#define FM_FMD_SCHEME_VERSION FMD_SCHEME_VERSION0 +#define DEV_SCHEME_VERSION0 0 +#define FM_DEV_SCHEME_VERSION DEV_SCHEME_VERSION0 +#define FM_HC_VERS0 0 +#define FM_HC_SCHEME_VERSION FM_HC_VERS0 +#define CPU_SCHEME_VERSION0 0 +#define CPU_SCHEME_VERSION1 1 +#define FM_CPU_SCHEME_VERSION CPU_SCHEME_VERSION1 +#define MEM_SCHEME_VERSION0 0 +#define FM_MEM_SCHEME_VERSION MEM_SCHEME_VERSION0 +#define MOD_SCHEME_VERSION0 0 +#define FM_MOD_SCHEME_VERSION MOD_SCHEME_VERSION0 +#define PKG_SCHEME_VERSION0 0 +#define FM_PKG_SCHEME_VERSION PKG_SCHEME_VERSION0 +#define LEGACY_SCHEME_VERSION0 0 +#define FM_LEGACY_SCHEME_VERSION LEGACY_SCHEME_VERSION0 +#define SVC_SCHEME_VERSION0 0 +#define FM_SVC_SCHEME_VERSION SVC_SCHEME_VERSION0 +#define ZFS_SCHEME_VERSION0 0 +#define FM_ZFS_SCHEME_VERSION ZFS_SCHEME_VERSION0 +#define SW_SCHEME_VERSION0 0 +#define FM_SW_SCHEME_VERSION SW_SCHEME_VERSION0 +#define PATH_SCHEME_VERSION0 0 +#define FM_PATH_SCHEME_VERSION PATH_SCHEME_VERSION0 + +/* hc scheme member names */ +#define FM_FMRI_HC_SERIAL_ID "serial" +#define FM_FMRI_HC_PART "part" +#define FM_FMRI_HC_REVISION "revision" +#define FM_FMRI_HC_ROOT "hc-root" +#define FM_FMRI_HC_LIST_SZ "hc-list-sz" +#define FM_FMRI_HC_LIST "hc-list" +#define FM_FMRI_HC_SPECIFIC "hc-specific" + +/* facility member names */ +#define FM_FMRI_FACILITY_NAME "facility-name" +#define FM_FMRI_FACILITY_TYPE "facility-type" + +/* hc-list version and member names */ +#define FM_FMRI_HC_NAME "hc-name" +#define FM_FMRI_HC_ID "hc-id" + +#define HC_LIST_VERSION0 0 +#define FM_HC_LIST_VERSION HC_LIST_VERSION0 + +/* hc-specific member names */ +#define FM_FMRI_HC_SPECIFIC_OFFSET "offset" +#define FM_FMRI_HC_SPECIFIC_PHYSADDR "physaddr" + +/* fmd module scheme member names */ +#define FM_FMRI_FMD_NAME "mod-name" +#define FM_FMRI_FMD_VERSION "mod-version" + +/* dev scheme member names */ +#define FM_FMRI_DEV_ID "devid" +#define FM_FMRI_DEV_TGTPTLUN0 "target-port-l0id" +#define FM_FMRI_DEV_PATH "device-path" + +/* pkg scheme member names */ +#define FM_FMRI_PKG_BASEDIR "pkg-basedir" +#define FM_FMRI_PKG_INST "pkg-inst" +#define FM_FMRI_PKG_VERSION "pkg-version" + +/* svc scheme member names */ +#define FM_FMRI_SVC_NAME "svc-name" +#define FM_FMRI_SVC_INSTANCE "svc-instance" +#define FM_FMRI_SVC_CONTRACT_ID "svc-contract-id" + +/* svc-authority member names */ +#define FM_FMRI_SVC_AUTH_SCOPE "scope" +#define FM_FMRI_SVC_AUTH_SYSTEM_FQN "system-fqn" + +/* cpu scheme member names */ +#define FM_FMRI_CPU_ID "cpuid" +#define FM_FMRI_CPU_SERIAL_ID "serial" +#define FM_FMRI_CPU_MASK "cpumask" +#define FM_FMRI_CPU_VID "cpuvid" +#define FM_FMRI_CPU_CPUFRU "cpufru" +#define FM_FMRI_CPU_CACHE_INDEX "cacheindex" +#define FM_FMRI_CPU_CACHE_WAY "cacheway" +#define FM_FMRI_CPU_CACHE_BIT "cachebit" +#define FM_FMRI_CPU_CACHE_TYPE "cachetype" + +#define FM_FMRI_CPU_CACHE_TYPE_L2 0 +#define FM_FMRI_CPU_CACHE_TYPE_L3 1 + +/* legacy-hc scheme member names */ +#define FM_FMRI_LEGACY_HC "component" +#define FM_FMRI_LEGACY_HC_PREFIX FM_FMRI_SCHEME_HC":///" \ + FM_FMRI_LEGACY_HC"=" + +/* mem scheme member names */ +#define FM_FMRI_MEM_UNUM "unum" +#define FM_FMRI_MEM_SERIAL_ID "serial" +#define FM_FMRI_MEM_PHYSADDR "physaddr" +#define FM_FMRI_MEM_MEMCONFIG "memconfig" +#define FM_FMRI_MEM_OFFSET "offset" + +/* mod scheme member names */ +#define FM_FMRI_MOD_PKG "mod-pkg" +#define FM_FMRI_MOD_NAME "mod-name" +#define FM_FMRI_MOD_ID "mod-id" +#define FM_FMRI_MOD_DESC "mod-desc" + +/* zfs scheme member names */ +#define FM_FMRI_ZFS_POOL "pool" +#define FM_FMRI_ZFS_VDEV "vdev" + +/* sw scheme member names - extra indentation for members of an nvlist */ +#define FM_FMRI_SW_OBJ "object" +#define FM_FMRI_SW_OBJ_PATH "path" +#define FM_FMRI_SW_OBJ_ROOT "root" +#define FM_FMRI_SW_OBJ_PKG "pkg" +#define FM_FMRI_SW_SITE "site" +#define FM_FMRI_SW_SITE_TOKEN "token" +#define FM_FMRI_SW_SITE_MODULE "module" +#define FM_FMRI_SW_SITE_FILE "file" +#define FM_FMRI_SW_SITE_LINE "line" +#define FM_FMRI_SW_SITE_FUNC "func" +#define FM_FMRI_SW_CTXT "context" +#define FM_FMRI_SW_CTXT_ORIGIN "origin" +#define FM_FMRI_SW_CTXT_EXECNAME "execname" +#define FM_FMRI_SW_CTXT_PID "pid" +#define FM_FMRI_SW_CTXT_ZONE "zone" +#define FM_FMRI_SW_CTXT_CTID "ctid" +#define FM_FMRI_SW_CTXT_STACK "stack" + +/* path scheme member names */ +#define FM_FMRI_PATH_VERSION "path-scheme-version" +#define FM_FMRI_PATH "path" +#define FM_FMRI_PATH_NAME "path-name" +#define FM_FMRI_PATH_INST "path-instance" +#define FM_FMRI_PATH_DIGRAPH_SCHEME "path-digraph-scheme" + +extern nv_alloc_t *fm_nva_xcreate(char *, size_t); +extern void fm_nva_xdestroy(nv_alloc_t *); + +extern nvlist_t *fm_nvlist_create(nv_alloc_t *); +extern void fm_nvlist_destroy(nvlist_t *, int); + +#define FM_NVA_FREE 0 /* free allocator on nvlist_destroy */ +#define FM_NVA_RETAIN 1 /* keep allocator on nvlist_destroy */ + +extern void fm_ereport_set(nvlist_t *, int, const char *, uint64_t, + const nvlist_t *, ...); +extern void fm_payload_set(nvlist_t *, ...); +extern int i_fm_payload_set(nvlist_t *, const char *, va_list); +extern void fm_fmri_hc_set(nvlist_t *, int, const nvlist_t *, nvlist_t *, + int, ...); +extern void fm_fmri_dev_set(nvlist_t *, int, const nvlist_t *, const char *, + const char *, const char *); +extern void fm_fmri_de_set(nvlist_t *, int, const nvlist_t *, const char *); +extern void fm_fmri_cpu_set(nvlist_t *, int, const nvlist_t *, uint32_t, + uint8_t *, const char *); +extern void fm_fmri_mem_set(nvlist_t *, int, const nvlist_t *, const char *, + const char *, uint64_t); +extern void fm_authority_set(nvlist_t *, int, const char *, const char *, + const char *, const char *); +extern void fm_fmri_zfs_set(nvlist_t *, int, uint64_t, uint64_t); +extern void fm_fmri_hc_create(nvlist_t *, int, const nvlist_t *, nvlist_t *, + nvlist_t *, int, ...); + +extern uint64_t fm_ena_increment(uint64_t); +extern uint64_t fm_ena_generate(uint64_t, uchar_t); +extern uint64_t fm_ena_generate_cpu(uint64_t, processorid_t, uchar_t); +extern uint64_t fm_ena_generation_get(uint64_t); +extern uchar_t fm_ena_format_get(uint64_t); +extern uint64_t fm_ena_id_get(uint64_t); +extern uint64_t fm_ena_time_get(uint64_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_PROTOCOL_H */ diff --git a/illumos-x86_64/usr/include/sys/fm/util.h b/illumos-x86_64/usr/include/sys/fm/util.h new file mode 100644 index 00000000..a9d4d06b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fm/util.h @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 RackTop Systems. + */ + +#ifndef _SYS_FM_UTIL_H +#define _SYS_FM_UTIL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Shared user/kernel definitions for class length, error channel name, + * and kernel event publisher string. + */ +#define FM_MAX_CLASS 100 +#define FM_ERROR_CHAN "com.sun:fm:error" +#define FM_PUB "fm" + +/* + * ereport dump device transport support + * + * Ereports are written out to the dump device at a proscribed offset from the + * end, similar to in-transit log messages. The ereports are represented as a + * erpt_dump_t header followed by ed_size bytes of packed native nvlist data. + * + * NOTE: All of these constants and the header must be defined so they have the + * same representation for *both* 32-bit and 64-bit producers and consumers. + */ +#define ERPT_MAGIC 0xf00d4eddU +#define ERPT_MAX_ERRS 16 +#define ERPT_DATA_SZ (6 * 1024) +#define ERPT_EVCH_MAX 256 +#define ERPT_HIWAT 64 + +typedef struct erpt_dump { + uint32_t ed_magic; /* ERPT_MAGIC or zero to indicate end */ + uint32_t ed_chksum; /* checksum32() of packed nvlist data */ + uint32_t ed_size; /* ereport (nvl) fixed buf size */ + uint32_t ed_pad; /* reserved for future use */ + hrtime_t ed_hrt_nsec; /* hrtime of this ereport */ + hrtime_t ed_hrt_base; /* hrtime sample corresponding to ed_tod_base */ + struct { + uint64_t sec; /* seconds since gettimeofday() Epoch */ + uint64_t nsec; /* nanoseconds past ed_tod_base.sec */ + } ed_tod_base; +} erpt_dump_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#include + +#define FM_STK_DEPTH 20 /* maximum stack depth */ +#define FM_SYM_SZ 64 /* maximum symbol size */ +#define FM_ERR_PIL 2 /* PIL for ereport_errorq drain processing */ + +#define FM_EREPORT_PAYLOAD_NAME_STACK "stack" + +extern errorq_t *ereport_errorq; +extern void *ereport_dumpbuf; +extern size_t ereport_dumplen; + +extern void fm_init(void); +extern void fm_nvprint(nvlist_t *); +extern void fm_panic(const char *, ...); +extern void fm_banner(void); + +extern void fm_ereport_dump(void); +extern void fm_ereport_post(nvlist_t *, int); + +extern void fm_payload_stack_add(nvlist_t *, const pc_t *, int); + +extern int is_fm_panic(); +#endif /* _KERNEL || _FAKE_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FM_UTIL_H */ diff --git a/illumos-x86_64/usr/include/sys/fork.h b/illumos-x86_64/usr/include/sys/fork.h new file mode 100644 index 00000000..aa455b35 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fork.h @@ -0,0 +1,79 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FORK_H +#define _SYS_FORK_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + +#if !defined(_KERNEL) + +extern pid_t forkx(int); +extern pid_t forkallx(int); +extern pid_t vforkx(int) __RETURNS_TWICE; + +#pragma unknown_control_flow(vforkx) + +#endif /* !defined(_KERNEL) */ + +/* + * The argument to any of the forkx() functions is a set of flags + * formed by or-ing together zero or more of the following flags. + * fork()/forkall()/vfork() are equivalent to the corresponding + * forkx()/forkallx()/vforkx() functions with a zero argument. + */ + +/* + * Do not post a SIGCHLD signal to the parent when the child terminates, + * regardless of the disposition of the SIGCHLD signal in the parent. + * SIGCHLD signals are still possible for job control stop and continue + * actions (CLD_STOPPED, CLD_CONTINUED) if the parent has requested them. + */ +#define FORK_NOSIGCHLD 0x0001 + +/* + * Do not allow wait-for-multiple-pids by the parent, as in waitid(P_ALL) + * or waitid(P_PGID), to reap the child and do not allow the child to + * be reaped automatically due the disposition of the SIGCHLD signal + * being set to be ignored. Only a specific wait for the child, as + * in waitid(P_PID, pid), is allowed and it is required, else when + * the child exits it will remain a zombie until the parent exits. + */ +#define FORK_WAITPID 0x0002 + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FORK_H */ diff --git a/illumos-x86_64/usr/include/sys/fp.h b/illumos-x86_64/usr/include/sys/fp.h new file mode 100644 index 00000000..b386597a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fp.h @@ -0,0 +1,407 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2023 Oxide Computer Company + * + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_FP_H +#define _SYS_FP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * 80287/80387 and SSE/SSE2 floating point processor definitions + */ + +/* + * values that go into fp_kind + */ +#define FP_NO 0 /* no fp chip, no emulator (no fp support) */ +#define FP_SW 1 /* no fp chip, using software emulator */ +#define FP_HW 2 /* chip present bit */ +#define FP_287 2 /* 80287 chip present */ +#define FP_387 3 /* 80387 chip present */ +#define FP_487 6 /* 80487 chip present */ +#define FP_486 6 /* 80486 chip present */ +/* + * The following values are bit flags instead of actual values. + * E.g. to know if we are using SSE, test (value & __FP_SSE) instead + * of (value == __FP_SSE). + */ +#define __FP_SSE 0x100 /* .. plus SSE-capable CPU */ +#define __FP_AVX 0x200 /* .. plus AVX-capable CPU */ + +/* + * values that go into fp_save_mech + */ +#define FP_FNSAVE 1 /* fnsave/frstor instructions */ +#define FP_FXSAVE 2 /* fxsave/fxrstor instructions */ +#define FP_XSAVE 3 /* xsave/xrstor instructions */ + +/* + * masks for 80387 control word + */ +#define FPIM 0x00000001 /* invalid operation */ +#define FPDM 0x00000002 /* denormalized operand */ +#define FPZM 0x00000004 /* zero divide */ +#define FPOM 0x00000008 /* overflow */ +#define FPUM 0x00000010 /* underflow */ +#define FPPM 0x00000020 /* precision */ +#define FPPC 0x00000300 /* precision control */ +#define FPRC 0x00000C00 /* rounding control */ +#define FPIC 0x00001000 /* infinity control */ +#define WFPDE 0x00000080 /* data chain exception */ + +/* + * (Old symbol compatibility) + */ +#define FPINV FPIM +#define FPDNO FPDM +#define FPZDIV FPZM +#define FPOVR FPOM +#define FPUNR FPUM +#define FPPRE FPPM + +/* + * precision, rounding, and infinity options in control word + */ +#define FPSIG24 0x00000000 /* 24-bit significand precision (short) */ +#define FPSIG53 0x00000200 /* 53-bit significand precision (long) */ +#define FPSIG64 0x00000300 /* 64-bit significand precision (temp) */ +#define FPRTN 0x00000000 /* round to nearest or even */ +#define FPRD 0x00000400 /* round down */ +#define FPRU 0x00000800 /* round up */ +#define FPCHOP 0x00000C00 /* chop (truncate toward zero) */ +#define FPP 0x00000000 /* projective infinity */ +#define FPA 0x00001000 /* affine infinity */ +#define WFPB17 0x00020000 /* bit 17 */ +#define WFPB24 0x00040000 /* bit 24 */ + +/* + * masks for 80387 status word + */ +#define FPS_IE 0x00000001 /* invalid operation */ +#define FPS_DE 0x00000002 /* denormalized operand */ +#define FPS_ZE 0x00000004 /* zero divide */ +#define FPS_OE 0x00000008 /* overflow */ +#define FPS_UE 0x00000010 /* underflow */ +#define FPS_PE 0x00000020 /* precision */ +#define FPS_SF 0x00000040 /* stack fault */ +#define FPS_ES 0x00000080 /* error summary bit */ +#define FPS_C0 0x00000100 /* C0 bit */ +#define FPS_C1 0x00000200 /* C1 bit */ +#define FPS_C2 0x00000400 /* C2 bit */ +#define FPS_TOP 0x00003800 /* top of stack pointer */ +#define FPS_C3 0x00004000 /* C3 bit */ +#define FPS_B 0x00008000 /* busy bit */ + +/* + * Exception flags manually cleared during x87 exception handling. + */ +#define FPS_SW_EFLAGS \ + (FPS_IE|FPS_DE|FPS_ZE|FPS_OE|FPS_UE|FPS_PE|FPS_SF|FPS_ES|FPS_B) + +/* + * Initial value of FPU control word as per 4th ed. ABI document + * - affine infinity + * - round to nearest or even + * - 64-bit double precision + * - all exceptions masked + * + * The 4th ed. SVR4 ABI didn't discuss the value of reserved bits. The ISA + * defines bit 6 (0x40) as reserved, but also that it is set (rather than clear, + * like many other Reserved bits). We preserve that in our value here. + */ +#define FPU_CW_INIT 0x137f + +/* + * This is the Intel mandated form of the default value of the x87 control word. + * This is different from what we use and should only be used in the context of + * representing that default state (e.g. in /proc xregs). + */ +#define FPU_CW_INIT_HW 0x037f + +/* + * masks and flags for SSE/SSE2 MXCSR + */ +#define SSE_IE 0x00000001 /* invalid operation */ +#define SSE_DE 0x00000002 /* denormalized operand */ +#define SSE_ZE 0x00000004 /* zero divide */ +#define SSE_OE 0x00000008 /* overflow */ +#define SSE_UE 0x00000010 /* underflow */ +#define SSE_PE 0x00000020 /* precision */ +#define SSE_DAZ 0x00000040 /* denormals are zero */ +#define SSE_IM 0x00000080 /* invalid op exception mask */ +#define SSE_DM 0x00000100 /* denormalize exception mask */ +#define SSE_ZM 0x00000200 /* zero-divide exception mask */ +#define SSE_OM 0x00000400 /* overflow exception mask */ +#define SSE_UM 0x00000800 /* underflow exception mask */ +#define SSE_PM 0x00001000 /* precision exception mask */ +#define SSE_RC 0x00006000 /* rounding control */ +#define SSE_RD 0x00002000 /* rounding control: round down */ +#define SSE_RU 0x00004000 /* rounding control: round up */ +#define SSE_FZ 0x00008000 /* flush to zero for masked underflow */ + +#define SSE_MXCSR_EFLAGS \ + (SSE_IE|SSE_DE|SSE_ZE|SSE_OE|SSE_UE|SSE_PE) /* 0x3f */ + +#define SSE_MXCSR_INIT \ + (SSE_IM|SSE_DM|SSE_ZM|SSE_OM|SSE_UM|SSE_PM) /* 0x1f80 */ + +#define SSE_MXCSR_MASK_DEFAULT \ + (0xffff & ~SSE_DAZ) /* 0xffbf */ + +#define SSE_FMT_MXCSR \ + "\20\20fz\17ru\16rd\15pm\14um\13om\12zm\11dm" \ + "\10im\7daz\6pe\5ue\4oe\3ze\2de\1ie" + +/* + * This structure is written to memory by an 'fnsave' instruction + */ +struct fnsave_state { + uint16_t f_fcw; + uint16_t __f_ign0; + uint16_t f_fsw; + uint16_t __f_ign1; + uint16_t f_ftw; + uint16_t __f_ign2; + uint32_t f_eip; + uint16_t f_cs; + uint16_t f_fop; + uint32_t f_dp; + uint16_t f_ds; + uint16_t __f_ign3; + union { + uint16_t fpr_16[5]; /* 80-bits of x87 state */ + } f_st[8]; +}; /* 108 bytes */ + +/* + * This structure is written to memory by an 'fxsave' instruction + * Note the variant behaviour of this instruction between long mode + * and legacy environments! + */ +struct fxsave_state { + uint16_t fx_fcw; + uint16_t fx_fsw; + uint16_t fx_fctw; /* compressed tag word */ + uint16_t fx_fop; +#if defined(__amd64) + uint64_t fx_rip; + uint64_t fx_rdp; +#else + uint32_t fx_eip; + uint16_t fx_cs; + uint16_t __fx_ign0; + uint32_t fx_dp; + uint16_t fx_ds; + uint16_t __fx_ign1; +#endif + uint32_t fx_mxcsr; + uint32_t fx_mxcsr_mask; + union { + uint16_t fpr_16[5]; /* 80-bits of x87 state */ + u_longlong_t fpr_mmx; /* 64-bit mmx register */ + uint32_t __fpr_pad[4]; /* (pad out to 128-bits) */ + } fx_st[8]; +#if defined(__amd64) + upad128_t fx_xmm[16]; /* 128-bit registers */ + upad128_t __fx_ign2[6]; +#else + upad128_t fx_xmm[8]; /* 128-bit registers */ + upad128_t __fx_ign2[14]; +#endif +} __aligned(16); /* 512 bytes */ + +/* + * This structure represents the header portion of the data layout used by the + * 'xsave' instruction variants. It is documented in section 13.4.2 of the + * Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 + * (IASDv1). Although "header" is somewhat of a misnomer, considering the data + * begins at offset 512 of the xsave area, its contents dictate which portions + * of the area are present and how they may be formatted. + */ +struct xsave_header { + uint64_t xsh_xstate_bv; + uint64_t xsh_xcomp_bv; + uint64_t xsh_reserved[6]; +}; + +/* + * This structure is written to memory by one of the 'xsave' instruction + * variants. The first 512 bytes are compatible with the format of the 'fxsave' + * area. The extended portion is documented in section 13.4.3. + * + * Our size is at least AVX_XSAVE_SIZE (832 bytes), which is asserted + * statically. Enabling additional xsave-related CPU features requires an + * increase in the size. We dynamically allocate the per-lwp xsave area at + * runtime, based on the size needed for the CPU-specific features. This + * xsave_state structure simply defines our historical layout for the beginning + * of the xsave area. The locations and size of new, extended, components is + * determined dynamically by querying the CPU. See the xsave_info structure in + * cpuid.c. + * + * xsave component usage is tracked using bits in the xstate_bv field of the + * header. The components are documented in section 13.1 of IASDv1. For easy + * reference, this is a summary of the currently defined component bit + * definitions: + * x87 0x0001 + * SSE 0x0002 + * AVX 0x0004 + * bndreg (MPX) 0x0008 + * bndcsr (MPX) 0x0010 + * opmask (AVX512) 0x0020 + * zmm hi256 (AVX512) 0x0040 + * zmm hi16 (AVX512) 0x0080 + * PT 0x0100 + * PKRU 0x0200 + * When xsaveopt_ctxt is being used to save into the xsave_state area, the + * xstate_bv field is updated by the xsaveopt instruction to indicate which + * elements of the xsave area are active. + * + * The xcomp_bv field should always be 0, since we do not currently use the + * compressed form of xsave (xsavec). + */ +struct xsave_state { + struct fxsave_state xs_fxsave; /* 0-511 legacy region */ + struct xsave_header xs_header; /* 512-575 XSAVE header */ + upad128_t xs_ymm[16]; /* 576 AVX component */ +} __aligned(64); + +/* + * While AVX_XSTATE_SIZE is the smallest the kernel will allocate for FPU + * state-saving, other consumers may constrain themselves to the minimum + * possible xsave state structure, which features only the legacy area and the + * bare xsave header. + */ +#define MIN_XSAVE_SIZE (sizeof (struct fxsave_state) + \ + sizeof (struct xsave_header)) + +/* + * Kernel's FPU save area + */ +typedef struct { + union _kfpu_u { + void *kfpu_generic; + struct fxsave_state *kfpu_fx; + struct xsave_state *kfpu_xs; + } kfpu_u; + uint32_t kfpu_status; /* saved at #mf exception */ + uint32_t kfpu_xstatus; /* saved at #xm exception */ +} kfpu_t; + +extern int fp_kind; /* kind of fp support */ +extern int fp_save_mech; /* fp save/restore mechanism */ +extern int fpu_exists; /* FPU hw exists */ +extern int fp_elf; /* FP elf type */ +extern uint64_t xsave_bv_all; /* Set of enabed xcr0 values */ + +#ifdef _KERNEL + +extern int fpu_ignored; +extern int fpu_pentium_fdivbug; + +extern uint32_t sse_mxcsr_mask; + +extern void fpu_probe(void); +extern uint_t fpu_initial_probe(void); + +extern void fpu_auxv_info(int *, size_t *); +extern boolean_t fpu_xsave_enabled(void); + +extern void fpnsave_ctxt(void *); +extern void fpxsave_ctxt(void *); +extern void xsave_ctxt(void *); +extern void xsaveopt_ctxt(void *); +extern void fpxsave_excp_clr_ctxt(void *); +extern void xsave_excp_clr_ctxt(void *); +extern void xsaveopt_excp_clr_ctxt(void *); +extern void (*fpsave_ctxt)(void *); +extern void (*xsavep)(struct xsave_state *, uint64_t); + +extern void fpxrestore_ctxt(void *); +extern void xrestore_ctxt(void *); +extern void (*fprestore_ctxt)(void *); + +extern void fxsave_insn(struct fxsave_state *); +extern void fpxsave(struct fxsave_state *); +extern void fpxrestore(struct fxsave_state *); +extern void xsave(struct xsave_state *, uint64_t); +extern void xsaveopt(struct xsave_state *, uint64_t); +extern void xrestore(struct xsave_state *, uint64_t); + +extern void fpenable(void); +extern void fpdisable(void); +extern void fpinit(void); + +extern uint32_t fperr_reset(void); +extern uint32_t fpxerr_reset(void); + +extern uint32_t fpgetcwsw(void); +extern uint32_t fpgetmxcsr(void); + +struct regs; +extern int fpexterrflt(struct regs *); +extern int fpsimderrflt(struct regs *); +extern void fpsetcw(uint16_t, uint32_t); +extern void fp_seed(void); +extern void fp_exec(void); +struct _klwp; +extern void fp_lwp_init(struct _klwp *); +extern void fp_lwp_cleanup(struct _klwp *); +extern void fp_lwp_dup(struct _klwp *); + +extern const struct fxsave_state sse_initial; +extern const struct xsave_state avx_initial; + +struct proc; +struct ucontext; +extern void fpu_proc_xregs_info(struct proc *, uint32_t *, uint32_t *, + uint32_t *); +extern size_t fpu_proc_xregs_max_size(void); +extern void fpu_proc_xregs_get(struct _klwp *, void *); +extern int fpu_proc_xregs_set(struct _klwp *, void *); +extern int fpu_signal_copyin(struct _klwp *, struct ucontext *); +typedef int (*fpu_copyout_f)(const void *, void *, size_t); +extern int fpu_signal_copyout(struct _klwp *, uintptr_t, fpu_copyout_f); +extern void fpu_set_xsave(struct _klwp *, const void *); +extern size_t fpu_signal_size(struct _klwp *); + +extern void fpu_get_fpregset(struct _klwp *, fpregset_t *); +extern void fpu_set_fpregset(struct _klwp *, const fpregset_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FP_H */ diff --git a/illumos-x86_64/usr/include/sys/frame.h b/illumos-x86_64/usr/include/sys/frame.h new file mode 100644 index 00000000..e3a647b3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/frame.h @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FRAME_H +#define _SYS_FRAME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * In the Intel world, a stack frame looks like this: + * + * %fp0->| | + * |-------------------------------| + * | Args to next subroutine | + * |-------------------------------|-\ + * %sp0->| One word struct-ret address | | + * |-------------------------------| > minimum stack frame + * %fp1->| Previous frame pointer (%fp0)| | + * |-------------------------------|-/ + * | Local variables | + * %sp1->|-------------------------------| + * + * For amd64, the minimum stack frame is 16 bytes and the frame pointer must + * be 16-byte aligned. + */ + +struct frame { + greg_t fr_savfp; /* saved frame pointer */ + greg_t fr_savpc; /* saved program counter */ +}; + +#ifdef _SYSCALL32 + +/* + * Kernel's view of a 32-bit stack frame. + */ +struct frame32 { + greg32_t fr_savfp; /* saved frame pointer */ + greg32_t fr_savpc; /* saved program counter */ +}; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FRAME_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/autofs.h b/illumos-x86_64/usr/include/sys/fs/autofs.h new file mode 100644 index 00000000..33aaeac2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/autofs.h @@ -0,0 +1,375 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_FS_AUTOFS_H +#define _SYS_FS_AUTOFS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _KERNEL + + +/* + * Tracing macro; expands to nothing for non-debug kernels. + */ +#ifndef DEBUG +#define AUTOFS_DPRINT(x) +#else +#define AUTOFS_DPRINT(x) auto_dprint x +#endif + +/* + * Per AUTOFS mountpoint information. + */ +typedef struct fninfo { + struct vfs *fi_mountvfs; /* mounted-here VFS */ + struct vnode *fi_rootvp; /* root vnode */ + struct knetconfig fi_knconf; /* netconfig */ + struct netbuf fi_addr; /* daemon address */ + char *fi_path; /* autofs mountpoint */ + char *fi_map; /* context/map-name */ + char *fi_subdir; /* subdir within map */ + char *fi_key; /* key to use on direct maps */ + char *fi_opts; /* default mount options */ + int fi_pathlen; /* autofs mountpoint len */ + int fi_maplen; /* size of context */ + int fi_subdirlen; + int fi_keylen; + int fi_optslen; /* default mount options len */ + int fi_refcnt; /* reference count */ + int fi_flags; + int fi_mount_to; + int fi_rpc_to; + zoneid_t fi_zoneid; /* zone mounted in */ +} fninfo_t; + +/* + * The AUTOFS locking scheme: + * + * The locks: + * fn_lock: protects the fn_node. It must be grabbed to change any + * field on the fn_node, except for those protected by + * fn_rwlock. + * + * fn_rwlock: readers/writers lock to protect the subdirectory and + * top level list traversal. + * Protects: fn_dirents + * fn_next + * fn_size + * fn_linkcnt + * - Grab readers when checking if certain fn_node exists + * under fn_dirents. + * - Grab readers when attempting to reference a node + * pointed to by fn_dirents, fn_next, and fn_parent. + * - Grab writers to add a new fnnode under fn_dirents and + * to remove a node pointed to by fn_dirents or fn_next. + * + * Lock ordering: + * fn_rwlock > fn_lock + * + * The flags: + * MF_INPROG: + * - Indicates a mount request has been sent to the daemon. + * - If this flag is set, the thread sets MF_WAITING on the + * fnnode and sleeps. + * + * MF_WAITING: + * - Set by a thread when it puts itself to sleep waiting for + * the ongoing operation on this fnnode to be done. + * + * MF_LOOKUP: + * - Indicates a lookup request has been sent to the daemon. + * - If this flag is set, the thread sets MF_WAITING on the + * fnnode and sleeps. + * + * MF_IK_MOUNT: + * - This flag is set to indicate the mount was done in the + * kernel, and so should the unmount. + * + * MF_DIRECT: + * - Direct mountpoint if set, indirect otherwise. + * + * MF_TRIGGER: + * - This is a trigger node. + * + * MF_THISUID_MATCH_RQD: + * - User-relative context binding kind of node. + * - Node with this flag set requires a name match as well + * as a cred match in order to be returned from the directory + * hierarchy. + * + * MF_MOUNTPOINT: + * - At some point automountd mounted a filesystem on this node. + * If fn_trigger is non-NULL, v_vfsmountedhere is NULL and this + * flag is set then the filesystem must have been forcibly + * unmounted. + */ + +/* + * The inode of AUTOFS + */ +typedef struct fnnode { + char *fn_name; + char *fn_symlink; /* if VLNK, this is what it */ + /* points to */ + int fn_namelen; + int fn_symlinklen; + uint_t fn_linkcnt; /* link count */ + mode_t fn_mode; /* file mode bits */ + uid_t fn_uid; /* owner's uid */ + gid_t fn_gid; /* group's uid */ + int fn_error; /* mount/lookup error */ + ino_t fn_nodeid; + off_t fn_offset; /* offset into directory */ + int fn_flags; + uint_t fn_size; /* size of directory */ + struct vnode *fn_vnode; + struct fnnode *fn_parent; + struct fnnode *fn_next; /* sibling */ + struct fnnode *fn_dirents; /* children */ + struct fnnode *fn_trigger; /* pointer to next level */ + /* AUTOFS trigger nodes */ + struct action_list *fn_alp; /* Pointer to mount info */ + /* used for remounting */ + /* trigger nodes */ + cred_t *fn_cred; /* pointer to cred, used for */ + /* "thisuser" processing */ + krwlock_t fn_rwlock; /* protects list traversal */ + kmutex_t fn_lock; /* protects the fnnode */ + timestruc_t fn_atime; + timestruc_t fn_mtime; + timestruc_t fn_ctime; + time_t fn_ref_time; /* time last referenced */ + time_t fn_unmount_ref_time; /* last time unmount was done */ + kcondvar_t fn_cv_mount; /* mount blocking variable */ + struct vnode *fn_seen; /* vnode already traversed */ + kthread_t *fn_thread; /* thread that has currently */ + /* modified fn_seen */ + struct autofs_globals *fn_globals; /* global variables */ +} fnnode_t; + + +#define vntofn(vp) ((struct fnnode *)((vp)->v_data)) +#define fntovn(fnp) (((fnp)->fn_vnode)) +#define vfstofni(vfsp) ((struct fninfo *)((vfsp)->vfs_data)) + +#define MF_DIRECT 0x001 +#define MF_INPROG 0x002 /* Mount in progress */ +#define MF_WAITING 0x004 +#define MF_LOOKUP 0x008 /* Lookup in progress */ +#define MF_ATTR_WAIT 0x010 +#define MF_IK_MOUNT 0x040 +#define MF_TRIGGER 0x080 +#define MF_THISUID_MATCH_RQD 0x100 /* UID match required for this node */ + /* required for thisuser kind of */ + /* nodes */ +#define MF_MOUNTPOINT 0x200 /* Node is/was a mount point */ + +#define AUTOFS_MODE 0555 +#define AUTOFS_BLOCKSIZE 1024 + +struct autofs_callargs { + fnnode_t *fnc_fnp; /* fnnode */ + char *fnc_name; /* path to lookup/mount */ + kthread_t *fnc_origin; /* thread that fired up this thread */ + /* used for debugging purposes */ + cred_t *fnc_cred; +}; + +struct autofs_globals { + fnnode_t *fng_rootfnnodep; + int fng_fnnode_count; + int fng_printed_not_running_msg; + kmutex_t fng_unmount_threads_lock; + int fng_unmount_threads; + int fng_verbose; + zoneid_t fng_zoneid; + pid_t fng_autofs_pid; + kmutex_t fng_autofs_daemon_lock; + /* + * autofs_daemon_lock protects fng_autofs_daemon_dh + */ + door_handle_t fng_autofs_daemon_dh; +}; + +extern kmutex_t autofs_minor_lock; +extern zone_key_t autofs_key; + +/* + * Sets the MF_INPROG flag on this fnnode. + * fnp->fn_lock should be held before this macro is called, + * operation is either MF_INPROG or MF_LOOKUP. + */ +#define AUTOFS_BLOCK_OTHERS(fnp, operation) { \ + ASSERT(MUTEX_HELD(&(fnp)->fn_lock)); \ + ASSERT(!((fnp)->fn_flags & operation)); \ + (fnp)->fn_flags |= (operation); \ +} + +#define AUTOFS_UNBLOCK_OTHERS(fnp, operation) { \ + auto_unblock_others((fnp), (operation)); \ +} + +extern struct vnodeops *auto_vnodeops; +extern const struct fs_operation_def auto_vnodeops_template[]; + +/* + * Utility routines + */ +extern int auto_search(fnnode_t *, char *, fnnode_t **, cred_t *); +extern int auto_enter(fnnode_t *, char *, fnnode_t **, cred_t *); +extern void auto_unblock_others(fnnode_t *, uint_t); +extern int auto_wait4mount(fnnode_t *); +extern fnnode_t *auto_makefnnode(vtype_t, vfs_t *, char *, cred_t *, + struct autofs_globals *); +extern void auto_freefnnode(fnnode_t *); +extern void auto_disconnect(fnnode_t *, fnnode_t *); +extern void auto_do_unmount(struct autofs_globals *); +/*PRINTFLIKE4*/ +extern void auto_log(int verbose, zoneid_t zoneid, int level, + const char *fmt, ...) + __KPRINTFLIKE(4); +/*PRINTFLIKE2*/ +extern void auto_dprint(int level, const char *fmt, ...) + __KPRINTFLIKE(2); +extern int auto_calldaemon(zoneid_t, int, xdrproc_t, void *, xdrproc_t, + void *, int, bool_t); +extern int auto_lookup_aux(fnnode_t *, char *, cred_t *); +extern void auto_new_mount_thread(fnnode_t *, char *, cred_t *); +extern int auto_nobrowse_option(char *); + +extern int unmount_subtree(fnnode_t *, boolean_t); +extern void unmount_tree(struct autofs_globals *, boolean_t); +extern void autofs_free_globals(struct autofs_globals *); +extern void autofs_shutdown_zone(struct autofs_globals *); + +#endif /* _KERNEL */ + +/* + * autofs structures and defines needed for use with doors. + */ +#define AUTOFS_NULL 0 +#define AUTOFS_MOUNT 1 +#define AUTOFS_UNMOUNT 2 +#define AUTOFS_READDIR 3 +#define AUTOFS_LOOKUP 4 +#define AUTOFS_SRVINFO 5 +#define AUTOFS_MNTINFO 6 + +/* + * autofs_door_args is a generic structure used to grab the command + * from any of the argument structures passed in. + */ + +typedef struct { + int cmd; + int xdr_len; + char xdr_arg[1]; /* buffer holding xdr encoded data */ +} autofs_door_args_t; + + +typedef struct { + int res_status; + int xdr_len; + char xdr_res[1]; /* buffer holding xdr encoded data */ +} autofs_door_res_t; + +typedef enum autofs_res autofs_res_t; +typedef enum autofs_stat autofs_stat_t; +typedef enum autofs_action autofs_action_t; + +typedef struct { + void * atsd_buf; + size_t atsd_len; +} autofs_tsd_t; + +typedef struct sec_desdata { + int nd_sec_syncaddr_len; + int nd_sec_knc_semantics; + int nd_sec_netnamelen; + uint64_t nd_sec_knc_rdev; + int nd_sec_knc_unused[8]; +} sec_desdata_t; + +typedef struct sec_gssdata { + int element_length; + rpc_gss_service_t service; + char uname[MAX_NAME_LEN]; + char inst[MAX_NAME_LEN]; + char realm[MAX_NAME_LEN]; + uint_t qop; +} sec_gssdata_t; + +typedef struct nfs_secdata { + sec_desdata_t nfs_des_clntdata; + sec_gssdata_t nfs_gss_clntdata; +} nfs_secdata_t; + +/* + * Comma separated list of mntoptions which are inherited when the + * "restrict" option is present. The RESTRICT option must be first! + * This define is shared between the kernel and the automount daemon. + */ +#define RESTRICTED_MNTOPTS \ + MNTOPT_RESTRICT, MNTOPT_NOSUID, MNTOPT_NOSETUID, MNTOPT_NODEVICES + +/* + * AUTOFS syscall entry point + */ +enum autofssys_op { AUTOFS_UNMOUNTALL, AUTOFS_SETDOOR }; + +#ifdef _KERNEL +extern int autofssys(enum autofssys_op, uintptr_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_AUTOFS_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/decomp.h b/illumos-x86_64/usr/include/sys/fs/decomp.h new file mode 100644 index 00000000..81708156 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/decomp.h @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DECOMP_H +#define _SYS_DECOMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define CH_MAGIC_ZLIB 0x5a636d70 /* ZLIB compression */ +#define CH_MAGIC_GZIP 0x8B1F /* GZIP compression */ + +#define CH_VERSION 1 + +#define CH_ALG_ZLIB 1 + +struct comphdr { + uint64_t ch_magic; + uint64_t ch_version; + uint64_t ch_algorithm; + uint64_t ch_fsize; + uint64_t ch_blksize; + uint64_t ch_blkmap[1]; +}; + +#define ZMAXBUF(n) ((n) + ((n) / 1000) + 12) + +#ifdef _KERNEL + +struct dcnode { + struct vnode *dc_vp; + struct vnode *dc_subvp; + struct kmem_cache *dc_bufcache; + kmutex_t dc_lock; + struct dcnode *dc_hash; + struct dcnode *dc_lrunext; + struct dcnode *dc_lruprev; + struct comphdr *dc_hdr; + size_t dc_hdrsize; + size_t dc_zmax; + int dc_mapcnt; +}; + +#define VTODC(vp) ((struct dcnode *)(vp)->v_data) +#define DCTOV(dp) ((dp)->dc_vp) + +struct vnode *decompvp(struct vnode *, struct cred *, caller_context_t *); + +#endif + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_DECOMP_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/dv_node.h b/illumos-x86_64/usr/include/sys/fs/dv_node.h new file mode 100644 index 00000000..ff9b4f98 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/dv_node.h @@ -0,0 +1,231 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DV_NODE_H +#define _SYS_DV_NODE_H + +/* + * dv_nodes are the file-system specific part of the + * vnodes for the device filesystem. + * + * The device filesystem exports two node types: + * + * VDIR nodes to represent nexus drivers + * VCHR & VBLK nodes to represent devices + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + + +/* + * Here's the focal point of this filesystem + */ +typedef struct dv_node { + char *dv_name; /* pointer to name */ + size_t dv_namelen; /* strlen(dv_name) */ + struct vnode *dv_vnode; /* vnode for this dv_node */ + + /* + * The dv_contents lock should be held (read) before looking at + * any of the fields below, and held (write) before modifying them. + */ + krwlock_t dv_contents; /* held while anything is changing */ + + dev_info_t *dv_devi; /* VDIR: underlying devinfo node */ + /* has ndi_devi_hold on device */ + + struct dv_node *dv_dotdot; /* parent: my parent dv_node */ + avl_tree_t dv_entries; /* VDIR: contents as avl tree */ + avl_node_t dv_avllink; /* avl node linkage */ + + struct vnode *dv_attrvp; /* persistent attribute store */ + struct vattr *dv_attr; /* attributes not yet persistent */ + + ino64_t dv_ino; /* fake inode */ + int dv_flags; /* state bits and stuff */ + uint_t dv_nlink; /* link count */ + uint_t dv_busy; /* directory busy count */ + devplcy_t *dv_priv; /* access privilege */ + mode_t dv_dflt_mode; /* create_priv_minor_node mode */ + struct sdev_dv *dv_sdev; /* sdev node[s] if exists */ +} dvnode_t; + +#define DV_BUILD 0x1 /* directory out-of-date */ +#define DV_NO_FSPERM 0x2 /* ignore fs permissions */ +#define DV_INTERNAL 0x04 /* internal node */ +#define DV_ACL 0x08 /* node has acl */ +#define DV_DFLT_MODE 0x010 /* dv_dflt_mode set */ + +#define DV_ROOTINO ((ino_t)2) /* root inode no. for devfs */ + +#define DVTOV(n) ((struct vnode *)(n)->dv_vnode) +#define VTODV(vp) ((struct dv_node *)(vp)->v_data) +#define DV_STALE(dv) (dv->dv_devi == NULL) + +#define DV_UID_DEFAULT 0 /* default uid for devs and dirs */ +#define DV_GID_DEFAULT 3 /* default gid for devs and dirs */ +#define DV_DIRMODE_DEFAULT (S_IFDIR | 0755) /* directories */ +#define DV_DEVMODE_DEFAULT (0600) /* special files */ +#define DV_DEVMODE_PRIV (0666) /* priv based access only */ + +/* flags for devfs_clean() */ +#define DV_CLEAN_FORCE 0x01 /* force clean of refed directories */ +#define DV_RESET_PERM 0x02 /* force resetting of node permission */ +#define DV_CLEANDIR_LCK 0x04 /* dv_contents already held */ + +struct devfs_data { + struct dv_node *devfs_root; + struct vfs *devfs_vfsp; +}; + +#define VFSTODVFS(vfsp) ((struct devfs_data *)((vfsp)->vfs_data)) + +/* dv_fid overlays the fid structure (for VFS_VGET) */ +struct dv_fid { + uint16_t dvfid_len; + ino32_t dvfid_ino; + int32_t dvfid_gen; +}; + +/* + * Compare a vattr's and mperm_t's minor permissions (uid, gid & mode) + */ +#define VATTRP_MP_CMP(attrp, mp) \ + (!((attrp->va_uid == mp.mp_uid) && \ + (attrp->va_gid == mp.mp_gid) && \ + ((attrp->va_mode & S_IAMB) == (mp.mp_mode & S_IAMB)))) + +/* + * Merge an mperm_t's minor permissions into a vattr + */ +#define VATTR_MP_MERGE(attr, mp) \ + attr.va_uid = mp.mp_uid; \ + attr.va_gid = mp.mp_gid; \ + attr.va_mode = \ + (attr.va_mode & ~S_IAMB) | (mp.mp_mode & S_IAMB); + +#define VATTRP_MP_MERGE(attrp, mp) \ + attrp->va_uid = mp.mp_uid; \ + attrp->va_gid = mp.mp_gid; \ + attrp->va_mode = \ + (attrp->va_mode & ~S_IAMB) | (mp.mp_mode & S_IAMB); + +/* + * dv_shadow_node flags + */ +#define DV_SHADOW_CREATE 0x01 /* create attribute node */ +#define DV_SHADOW_WRITE_HELD 0x02 /* dv_contents write held */ + +/* + * Directory tree traversal + */ +#define DV_FIRST_ENTRY(ddv) avl_first(&(ddv)->dv_entries) +#define DV_NEXT_ENTRY(ddv, dv) AVL_NEXT(&(ddv)->dv_entries, (dv)) + +extern uint_t devfs_clean_key; /* tsd key */ +extern const char dvnm[]; /* share some space.. */ +extern struct dv_node *dvroot; /* devfs root node */ + +extern void dv_node_cache_init(void); +extern void dv_node_cache_fini(void); +extern struct dv_node *dv_mkdir(struct dv_node *, dev_info_t *, char *); +extern struct dv_node *dv_mkroot(struct vfs *, dev_t); +extern void dv_destroy(struct dv_node *, uint_t); +extern void dv_insert(struct dv_node *, struct dv_node *); +extern void dv_shadow_node(struct vnode *, char *nm, struct vnode *, + struct pathname *, struct vnode *, struct cred *, int); +extern int dv_find(struct dv_node *, char *, struct vnode **, + struct pathname *, struct vnode *, struct cred *, uint_t); +extern void dv_filldir(struct dv_node *); +extern int dv_cleandir(struct dv_node *, char *, uint_t); +extern void dv_vattr_merge(struct dv_node *, struct vattr *); +extern void dv_walk(struct dv_node *, char *, + void (*f)(struct dv_node *, void *), void *); + +extern int devfs_clean(dev_info_t *, char *, uint_t); +extern int devfs_lookupname(char *, vnode_t **, vnode_t **); +extern int devfs_walk(char *, void (*f)(struct dv_node *, void *), void *); +extern int devfs_devpolicy(vnode_t *, devplcy_t **); +extern void devfs_get_defattr(vnode_t *, struct vattr *, int *); + +extern struct dv_node *devfs_dip_to_dvnode(dev_info_t *); +extern int devfs_reset_perm(uint_t); +extern int devfs_remdrv_cleanup(const char *, const char *); + +extern struct vnodeops *dv_vnodeops; +extern const struct fs_operation_def dv_vnodeops_template[]; + + +#ifdef DEBUG +extern int devfs_debug; +#define DV_DEBUG 0x01 +#define DV_DEBUG2 0x02 +#define DV_DEBUG3 0x04 +#define DV_DEBUG4 0x08 +#define DV_DEBUG5 0x10 +#define DV_SYSERR 0x1000 +#define DV_SYSTRACE 0x2000 +#define dcmn_err(args) if (devfs_debug & DV_DEBUG) printf args +#define dcmn_err2(args) if (devfs_debug & DV_DEBUG2) printf args +#define dcmn_err3(args) if (devfs_debug & DV_DEBUG3) printf args +#define dcmn_err4(args) if (devfs_debug & DV_DEBUG4) printf args +#define dcmn_err5(args) if (devfs_debug & DV_DEBUG5) printf args + +#define dsysdebug(err, args) \ + if ((err && (devfs_debug & DV_SYSERR)) || \ + (devfs_debug & DV_SYSTRACE)) printf args +#else +#define dcmn_err(args) /* nothing */ +#define dcmn_err2(args) /* nothing */ +#define dcmn_err3(args) /* nothing */ +#define dcmn_err4(args) /* nothing */ +#define dcmn_err5(args) /* nothing */ +#define dsysdebug(err, args) /* nothing */ +#endif + + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_DV_NODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/fifonode.h b/illumos-x86_64/usr/include/sys/fs/fifonode.h new file mode 100644 index 00000000..790d9543 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/fifonode.h @@ -0,0 +1,187 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_FS_FIFONODE_H +#define _SYS_FS_FIFONODE_H + +#if defined(_KERNEL) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Each FIFOFS object is identified by a struct fifonode/vnode pair. + * This is also the hierarchy + * flk_lock protects: + * fn_mp + * fn_tail + * fn_count + * fn_flag + * fn_wcnt + * fn_rcnt + * fn_open + * fn_rsynccnt + * fn_wsynccnt + * fn_wwaitcnt + * fn_atime + * fn_mtime + * fn_ctime + * fn_insync + * flk_ref + * flk_ocsync + * ftable lock protects - actually this is independent + * fifoalloc[] + * fn_nextp + * fn_backp + */ +typedef struct fifolock { + kmutex_t flk_lock; /* fifo lock */ + int flk_ref; /* number of fifonodes using this */ + short flk_ocsync; /* sync open/close */ + kcondvar_t flk_wait_cv; /* conditional for flk_ocsync */ + uint_t flk_fill[4]; /* cache align lock structure */ +} fifolock_t; + +typedef struct fifonode fifonode_t; + +struct fifonode { + struct vnode *fn_vnode; /* represents the fifo/pipe */ + struct vnode *fn_realvp; /* node being shadowed by fifo */ + ino_t fn_ino; /* node id for pipes */ + fifonode_t *fn_dest; /* the other end of a pipe */ + struct msgb *fn_mp; /* message waiting to be read */ + struct msgb *fn_tail; /* last message to read */ + fifolock_t *fn_lock; /* pointer to per fifo lock */ + uint_t fn_count; /* Number of bytes on fn_mp */ + uint_t fn_hiwat; /* pipe (fifofast) high water */ + kcondvar_t fn_wait_cv; /* fifo conditional variable */ + ushort_t fn_wcnt; /* number of writers */ + ushort_t fn_rcnt; /* number of readers */ + ushort_t fn_open; /* open count of node */ + ushort_t fn_wsynccnt; /* fifos waiting for open write sync */ + ushort_t fn_rsynccnt; /* fifos waiting for open read sync */ + ushort_t fn_wwaitcnt; /* threads waiting to write data */ + timestruc_t fn_atime; /* access times */ + timestruc_t fn_mtime; /* modification time */ + timestruc_t fn_ctime; /* change time */ + fifonode_t *fn_nextp; /* next link in the linked list */ + fifonode_t *fn_backp; /* back link in linked list */ + struct cred *fn_pcredp; /* credential associated with peer */ + pid_t fn_cpid; /* original peer pid */ + int fn_insync; + uint_t fn_flag; /* flags as defined below */ +}; + + +typedef struct fifodata { + fifolock_t fifo_lock; + fifonode_t fifo_fnode[2]; +} fifodata_t; + +/* + * Valid flags for fifonodes. + */ +#define ISPIPE 0x0001 /* fifonode is that of a pipe */ +#define FIFOSEND 0x0002 /* file descriptor at stream head of pipe */ +#define FIFOOPEN 0x0004 /* fifo is opening */ +#define FIFOCLOSE 0x0008 /* fifo is closing */ +#define FIFOCONNLD 0x0010 /* connld pushed on pipe */ +#define FIFOFAST 0x0020 /* FIFO in fast mode */ +#define FIFOWANTR 0x0040 /* reader waiting for data */ +#define FIFOWANTW 0x0080 /* writer waiting to write */ +#define FIFOSETSIG 0x0100 /* I_SETSIG ioctl was issued */ +#define FIFOHIWATW 0x0200 /* We have gone over hi water mark */ +#define FIFORWBUSY 0x0400 /* Fifo is busy in read or write */ +#define FIFOPOLLW 0x0800 /* process waiting on poll write */ +#define FIFOPOLLR 0x1000 /* process waiting on poll read */ +#define FIFOISOPEN 0x2000 /* pipe is open */ +#define FIFOSYNC 0x4000 /* FIFO is waiting for open sync */ +#define FIFOWOCR 0x8000 /* Write open occurred */ +#define FIFOROCR 0x10000 /* Read open occurred */ +/* + * process waiting on poll read on band data + * this can only occur if we go to streams + * mode + */ +#define FIFOPOLLRBAND 0x20000 +#define FIFOSTAYFAST 0x40000 /* don't turn into stream mode */ +#define FIFOWAITMODE 0x80000 /* waiting for the possibility to change mode */ +/* Data on loan, block reads. Use in conjunction with FIFOSTAYFAST. */ +#define FIFORDBLOCK 0x100000 + +#define FIFOHIWAT (16 * 1024) +#define FIFOLOWAT (0) + +/* + * Macros to convert a vnode to a fifnode, and vice versa. + */ +#define VTOF(vp) ((struct fifonode *)((vp)->v_data)) +#define FTOV(fp) ((fp)->fn_vnode) + +#if defined(_KERNEL) + +extern struct vnodeops *fifo_vnodeops; +extern const struct fs_operation_def fifo_vnodeops_template[]; +extern struct kmem_cache *fnode_cache; +extern struct kmem_cache *pipe_cache; + +struct vfssw; +struct queue; + +extern int fifoinit(int, char *); +extern int fifo_stropen(vnode_t **, int, cred_t *, int, int); +extern int fifo_open(vnode_t **, int, cred_t *, caller_context_t *); +extern int fifo_close(vnode_t *, int, int, offset_t, cred_t *, + caller_context_t *); +extern void fifo_cleanup(vnode_t *, int); +extern void fiforemove(fifonode_t *); +extern ino_t fifogetid(void); +extern vnode_t *fifovp(vnode_t *, cred_t *); +extern void makepipe(vnode_t **, vnode_t **); +extern void fifo_fastflush(fifonode_t *); +extern void fifo_vfastoff(vnode_t *); +extern void fifo_fastoff(fifonode_t *); +extern struct streamtab *fifo_getinfo(); +extern void fifo_wakereader(fifonode_t *, fifolock_t *); +extern void fifo_wakewriter(fifonode_t *, fifolock_t *); +extern boolean_t fifo_stayfast_enter(fifonode_t *); +extern void fifo_stayfast_exit(fifonode_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_FIFONODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/hsfs_isospec.h b/illumos-x86_64/usr/include/sys/fs/hsfs_isospec.h new file mode 100644 index 00000000..361dca12 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/hsfs_isospec.h @@ -0,0 +1,290 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_HSFS_ISOSPEC_H +#define _SYS_FS_HSFS_ISOSPEC_H + +/* + * ISO 9660 filesystem specification + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* macros to parse binary integers */ +#define ZERO(x) (uint_t)(((uchar_t *)(x))[0]) +#define ONE(x) (uint_t)(((uchar_t *)(x))[1]) +#define TWO(x) (uint_t)(((uchar_t *)(x))[2]) +#define THREE(x) (uint_t)(((uchar_t *)(x))[3]) + +#define MSB_INT(x) \ + ((((((ZERO(x) << 8) | ONE(x)) << 8) | TWO(x)) << 8) | THREE(x)) +#define LSB_INT(x) \ + ((((((THREE(x) << 8) | TWO(x)) << 8) | ONE(x)) << 8) | ZERO(x)) +#define MSB_SHORT(x) ((ZERO(x) << 8) | ONE(x)) +#define LSB_SHORT(x) ((ONE(x) << 8) | ZERO(x)) + +#if defined(__i386) || defined(__amd64) +#define BOTH_SHORT(x) (short)*((short *)x) +#define BOTH_INT(x) (int)*((int *)x) +#elif defined(__sparc) +/* + * SPARC machines require that integers must + * be aligned on a full word boundary. CD-ROM data aligns + * to even word boundary only. Because of this mismatch, + * we have to move integer data from CD-ROM to memory one + * byte at a time. LSB data starts first. We therefore + * use this to do byte by byte copying. + */ +#define BOTH_SHORT(x) LSB_SHORT(x) +#define BOTH_INT(x) LSB_INT(x) +#endif + +/* + * The following describes actual on-disk structures. + * To achieve portability, all structures are #defines + * rather than a structure definition. Macros are provided + * to get either the data or address of individual fields. + */ + +/* Overall High Sierra disk structure */ +#define ISO_SECTOR_SIZE 2048 /* bytes per logical sector */ +#define ISO_SECTOR_SHIFT 11 /* sector<->byte shift count */ +#define ISO_SEC_PER_PAGE (PAGESIZE/HS_SECTOR_SIZE) + /* sectors per page */ +#define ISO_SYSAREA_SEC 0 /* 1st sector of system area */ +#define ISO_VOLDESC_SEC 16 /* 1st sector of volume descriptors */ +#define MAXISOOFFSET (ISO_SECTOR_SIZE - 1) +#define MAXISOMASK (~MAXISOOFFSET) + + +/* Standard File Structure Volume Descriptor */ + +enum iso_voldesc_type { + ISO_VD_BOOT = 0, ISO_VD_PVD = 1, ISO_VD_SVD = 2, ISO_VD_VPD = 3, + ISO_VD_UNIX = 4, /* UNIX extension */ + ISO_VD_EOV = 255 +}; +#define ISO_ID_STRING "CD001" /* ISO_std_id field */ +#define ISO_ID_STRLEN 5 /* ISO_std_id field length */ +#define ISO_ID_VER 1 /* ISO_std_ver field ISO-9660:1988 */ +#define ISO_ID_VER2 2 /* ISO_std_ver field ISO-9660:1999 */ +#define ISO_FILE_STRUCT_ID_VER 1 /* ISO_file structure version field */ +#define ISO_SYS_ID_STRLEN 32 +#define ISO_VOL_ID_STRLEN 32 +#define ISO_VOL_SET_ID_STRLEN 128 +#define ISO_PUB_ID_STRLEN 128 +#define ISO_PREP_ID_STRLEN 128 +#define ISO_APPL_ID_STRLEN 128 +#define ISO_COPYR_ID_STRLEN 37 +#define ISO_ABSTR_ID_STRLEN 37 +#define ISO_SHORT_DATE_LEN 7 +#define ISO_DATE_LEN 17 + + + +/* macros to get the address of each field */ +#define ISO_desc_type(x) (&((uchar_t *)x)[0]) +#define ISO_std_id(x) (&((uchar_t *)x)[1]) +#define ISO_std_ver(x) (&((uchar_t *)x)[6]) +#define ISO_sys_id(x) (&((uchar_t *)x)[8]) +#define ISO_vol_id(x) (&((uchar_t *)x)[40]) +#define ISO_vol_size(x) (&((uchar_t *)x)[80]) +#define ISO_svd_esc(x) (&((uchar_t *)x)[88]) /* Supplemental VD */ +#define ISO_set_size(x) (&((uchar_t *)x)[120]) +#define ISO_set_seq(x) (&((uchar_t *)x)[124]) +#define ISO_blk_size(x) (&((uchar_t *)x)[128]) +#define ISO_ptbl_size(x) (&((uchar_t *)x)[132]) +#define ISO_ptbl_man_ls(x) (&((uchar_t *)x)[140]) +#define ISO_ptbl_opt_ls1(x) (&((uchar_t *)x)[144]) +#define ISO_ptbl_man_ms(x) (&((uchar_t *)x)[148]) +#define ISO_ptbl_opt_ms1(x) (&((uchar_t *)x)[152]) +#define ISO_root_dir(x) (&((uchar_t *)x)[156]) +#define ISO_vol_set_id(x) (&((uchar_t *)x)[190]) +#define ISO_pub_id(x) (&((uchar_t *)x)[318]) +#define ISO_prep_id(x) (&((uchar_t *)x)[446]) +#define ISO_appl_id(x) (&((uchar_t *)x)[574]) +#define ISO_copyr_id(x) (&((uchar_t *)x)[702]) +#define ISO_abstr_id(x) (&((uchar_t *)x)[739]) +#define ISO_bibli_id(x) (&((uchar_t *)x)[776]) +#define ISO_cre_date(x) (&((uchar_t *)x)[813]) +#define ISO_mod_date(x) (&((uchar_t *)x)[830]) +#define ISO_exp_date(x) (&((uchar_t *)x)[847]) +#define ISO_eff_date(x) (&((uchar_t *)x)[864]) +#define ISO_file_struct_ver(x) (&((uchar_t *)x)[881]) + +/* macros to get the values of each field (strings are returned as ptrs) */ +#define ISO_DESC_TYPE(x) ((enum iso_voldesc_type)*(ISO_desc_type(x))) +#define ISO_STD_ID(x) ISO_std_id(x) +#define ISO_STD_VER(x) *(ISO_std_ver(x)) +#define ISO_SYS_ID(x) ISO_sys_id(x) +#define ISO_VOL_ID(x) ISO_vol_id(x) +#define ISO_VOL_SIZE(x) BOTH_INT(ISO_vol_size(x)) +#define ISO_SET_SIZE(x) BOTH_SHORT(ISO_set_size(x)) +#define ISO_SET_SEQ(x) BOTH_SHORT(ISO_set_seq(x)) +#define ISO_BLK_SIZE(x) BOTH_SHORT(ISO_blk_size(x)) +#define ISO_PTBL_SIZE(x) BOTH_INT(ISO_ptbl_size(x)) +#define ISO_PTBL_MAN_LS(x) LSB_INT(ISO_ptbl_man_ls(x)) +#define ISO_PTBL_OPT_LS1(x) LSB_INT(ISO_ptbl_opt_ls1(x)) +#define ISO_PTBL_MAN_MS(x) MSB_INT(ISO_ptbl_man_ms(x)) +#define ISO_PTBL_OPT_MS1(x) MSB_INT(ISO_ptbl_opt_ms1(x)) +#define ISO_ROOT_DIR(x) ISO_root_dir(x) +#define ISO_VOL_SET_ID(x) ISO_vol_set_id(x) +#define ISO_PUB_ID(x) ISO_pub_id(x) +#define ISO_PREP_ID(x) ISO_prep_id(x) +#define ISO_APPL_ID(x) ISO_appl_id(x) +#define ISO_COPYR_ID(x) ISO_copyr_id(x) +#define ISO_ABSTR_ID(x) ISO_abstr_id(x) +#define ISO_BIBLI_ID(x) ISO_bibli_id(x) +#define ISO_CRE_DATE(x) HSV_cre_date(x) +#define ISO_MOD_DATE(x) HSV_mod_date(x) +#define ISO_EXP_DATE(x) HSV_exp_date(x) +#define ISO_EFF_DATE(x) HSV_eff_date(x) +#define ISO_FILE_STRUCT_VER(x) *(ISO_file_struct_ver(x)) + +/* Standard File Structure Volume Descriptor date fields */ +#define ISO_DATE_2DIG(x) ((((x)[0] - '0') * 10) + \ + ((x)[1] - '0')) +#define ISO_DATE_4DIG(x) ((((x)[0] - '0') * 1000) + \ + (((x)[1] - '0') * 100) + \ + (((x)[2] - '0') * 10) + \ + ((x)[3] - '0')) +#define ISO_DATE_YEAR(x) ISO_DATE_4DIG(&((uchar_t *)x)[0]) +#define ISO_DATE_MONTH(x) ISO_DATE_2DIG(&((uchar_t *)x)[4]) +#define ISO_DATE_DAY(x) ISO_DATE_2DIG(&((uchar_t *)x)[6]) +#define ISO_DATE_HOUR(x) ISO_DATE_2DIG(&((uchar_t *)x)[8]) +#define ISO_DATE_MIN(x) ISO_DATE_2DIG(&((uchar_t *)x)[10]) +#define ISO_DATE_SEC(x) ISO_DATE_2DIG(&((uchar_t *)x)[12]) +#define ISO_DATE_HSEC(x) ISO_DATE_2DIG(&((uchar_t *)x)[14]) +#define ISO_DATE_GMTOFF(x) (((char *)x)[16]) + + + +/* Directory Entry (Directory Record) */ +#define IDE_ROOT_DIR_REC_SIZE 34 /* size of root directory record */ +#define IDE_FDESIZE 33 /* fixed size for hsfs directory area */ + /* max size of a name */ +#define IDE_MAX_NAME_LEN (255 - IDE_FDESIZE) + + +/* macros to get the address of each field */ +#define IDE_dir_len(x) (&((uchar_t *)x)[0]) +#define IDE_xar_len(x) (&((uchar_t *)x)[1]) +#define IDE_ext_lbn(x) (&((uchar_t *)x)[2]) +#define IDE_ext_size(x) (&((uchar_t *)x)[10]) +#define IDE_cdate(x) (&((uchar_t *)x)[18]) +#define IDE_flags(x) (&((uchar_t *)x)[25]) +#define IDE_intrlv_size(x) (&((uchar_t *)x)[26]) +#define IDE_intrlv_skip(x) (&((uchar_t *)x)[27]) +#define IDE_vol_set(x) (&((uchar_t *)x)[28]) +#define IDE_name_len(x) (&((uchar_t *)x)[32]) +#define IDE_name(x) (&((uchar_t *)x)[33]) +#define IDE_sys_use_area(x) (&((uchar_t *)x)[IDE_NAME_LEN(x) + \ + IDE_PAD_LEN(x)] + IDE_FDESIZE) + +/* macros to get the values of each field (strings are returned as ptrs) */ +#define IDE_DIR_LEN(x) *(IDE_dir_len(x)) +#define IDE_XAR_LEN(x) *(IDE_xar_len(x)) +#define IDE_EXT_LBN(x) BOTH_INT(IDE_ext_lbn(x)) +#define IDE_EXT_SIZE(x) BOTH_INT(IDE_ext_size(x)) +#define IDE_CDATE(x) IDE_cdate(x) +#define IDE_FLAGS(x) *(IDE_flags(x)) +#define IDE_INTRLV_SIZE(x) *(IDE_intrlv_size(x)) +#define IDE_INTRLV_SKIP(x) *(IDE_intrlv_skip(x)) +#define IDE_VOL_SET(x) BOTH_SHORT(IDE_vol_set(x)) +#define IDE_NAME_LEN(x) *(IDE_name_len(x)) +#define IDE_NAME(x) IDE_name(x) +#define IDE_PAD_LEN(x) ((IDE_NAME_LEN(x) % 2) ? 0 : 1) +#define IDE_SUA_LEN(x) ((int)(IDE_DIR_LEN(x)) - (int)(IDE_FDESIZE) - \ + (int)(IDE_NAME_LEN(x)) - (int)(IDE_PAD_LEN(x))) + +/* mask bits for IDE_FLAGS */ +#define IDE_EXISTENCE 0x01 /* zero if file exists */ +#define IDE_DIRECTORY 0x02 /* zero if file is not a directory */ +#define IDE_ASSOCIATED 0x04 /* zero if file is not Associated */ +#define IDE_RECORD 0x08 /* zero if no record attributes */ +#define IDE_PROTECTION 0x10 /* zero if no protection attributes */ +#define IDE_UNUSED_FLAGS 0x60 +#define IDE_LAST_EXTENT 0x80 /* zero if last extent in file */ +#define IDE_PROHIBITED (IDE_DIRECTORY | IDE_RECORD | \ + IDE_LAST_EXTENT | IDE_UNUSED_FLAGS) + +/* Directory Record date fields */ +#define IDE_DATE_YEAR(x) (((uchar_t *)x)[0] + 1900) +#define IDE_DATE_MONTH(x) (((uchar_t *)x)[1]) +#define IDE_DATE_DAY(x) (((uchar_t *)x)[2]) +#define IDE_DATE_HOUR(x) (((uchar_t *)x)[3]) +#define IDE_DATE_MIN(x) (((uchar_t *)x)[4]) +#define IDE_DATE_SEC(x) (((uchar_t *)x)[5]) +#define IDE_DATE_GMTOFF(x) (((char *)x)[6]) + +/* tests for Interchange Levels 1 & 2 file types */ +#define IDE_REGULAR_FILE(x) (((x) & IDE_PROHIBITED) == 0) +#define IDE_REGULAR_DIR(x) (((x) & IDE_PROHIBITED) == IDE_DIRECTORY) + +/* + * A ISO filename is: "ABCDE.EEE;1" -> '.' ';' + * + * The ISO-9660:1988 (Version 1) maximum needed string length is: + * 30 chars (filename + ext) + * + 2 chars ('.' + ';') + * + strlen("32767") + * + null byte + * ================================ + * = 38 chars + * + * ISO_DIR_NAMELEN counts 30 chars + '.' + */ +#define ISO_DIR_NAMELEN 31 /* max length of a directory name */ +#define ISO_FILE_NAMELEN 31 /* max length of a filename, */ + /* excluding ";" and version num */ +#define ISO_NAMELEN_V2 207 /* ISOv2: 254 - 33 - 14 (XA Record) */ +#define ISO_NAMELEN_V2_MAX 221 /* max length, ignorig ISOv2 */ +#define JOLIET_NAMELEN 64 /* Joliet file name length (spec) */ +#define JOLIET_NAMELEN_MAX 110 /* max Joliet file name length */ + +/* Path table enry */ +/* fix size of path table entry */ +#define IPE_FPESIZE 8 +/* macros to get the address of each field */ +#define IPE_name_len(x) (&((uchar_t *)x)[0]) +#define IPE_xar_len(x) (&((uchar_t *)x)[1]) +#define IPE_ext_lbn(x) (&((uchar_t *)x)[2]) +#define IPE_parent_no(x) (&((uchar_t *)x)[6]) +#define IPE_name(x) (&((uchar_t *)x)[8]) + +/* macros to get the values of each field */ +#define IPE_EXT_LBN(x) (MSB_INT(IPE_ext_lbn(x))) +#define IPE_XAR_LEN(x) *(IPE_xar_len(x)) +#define IPE_NAME_LEN(x) *(IPE_name_len(x)) +#define IPE_PARENT_NO(x) *(short *)(IPE_parent_no(x)) +#define IPE_NAME(x) IPE_name(x) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_HSFS_ISOSPEC_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/hsfs_node.h b/illumos-x86_64/usr/include/sys/fs/hsfs_node.h new file mode 100644 index 00000000..636b63ab --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/hsfs_node.h @@ -0,0 +1,348 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * High Sierra filesystem structure definitions + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_HSFS_NODE_H +#define _SYS_FS_HSFS_NODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct hs_direntry { + uint_t ext_lbn; /* LBN of start of extent */ + uint_t ext_size; /* no. of data bytes in extent */ + struct timeval cdate; /* creation date */ + struct timeval mdate; /* last modification date */ + struct timeval adate; /* last access date */ + enum vtype type; /* file type */ + mode_t mode; /* mode and type of file (UNIX) */ + uint_t nlink; /* no. of links to file */ + uid_t uid; /* owner's user id */ + gid_t gid; /* owner's group id */ + ino64_t inode; /* inode number from rrip data */ + dev_t r_dev; /* major/minor device numbers */ + uint_t xar_prot :1; /* 1 if protection in XAR */ + uchar_t xar_len; /* no. of Logical blocks in XAR */ + uchar_t intlf_sz; /* intleaving size */ + uchar_t intlf_sk; /* intleaving skip factor */ + ushort_t sym_link_flag; /* flags for sym link */ + char *sym_link; /* path of sym link for readlink() */ +}; + +struct ptable { + uchar_t filler[7]; /* filler */ + uchar_t dname_len; /* length of directory name */ + uchar_t dname[HS_DIR_NAMELEN+1]; /* directory name */ +}; + +struct ptable_idx { + struct ptable_idx *idx_pptbl_idx; /* parent's path table index entry */ + struct ptable *idx_mptbl; /* path table entry for myself */ + ushort_t idx_nochild; /* no. of children */ + ushort_t idx_childid; /* directory no of first child */ +}; + +/* + * hsnode structure: + * + * hs_offset, hs_ptbl_idx, base apply to VDIR type only + * + * nodeid uniquely identifies an hsnode, ISO9660 means + * nodeid can be very big. + * For directories it is the disk address of + * the data extent of the dir (the directory itself, + * ".", and ".." all point to same data extent). + * For non-directories, it is the disk address of the + * directory entry for the file; note that this does + * not permit hard links, as it assumes a single dir + * entry per file. + */ + +struct hsnode { + struct hsnode *hs_hash; /* next hsnode in hash list */ + struct hsnode *hs_freef; /* next hsnode in free list */ + struct hsnode *hs_freeb; /* previous hsnode in free list */ + struct vnode *hs_vnode; /* the real vnode for the file */ + struct hs_direntry hs_dirent; /* the directory entry for this file */ + ino64_t hs_nodeid; /* "inode" number for hsnode */ + uint_t hs_dir_lbn; /* LBN of directory entry */ + uint_t hs_dir_off; /* offset in LBN of directory entry */ + struct ptable_idx *hs_ptbl_idx; /* path table index */ + uint_t hs_offset; /* start offset in dir for searching */ + long hs_mapcnt; /* mappings to file pages */ + uint_t hs_seq; /* sequence number */ + uint_t hs_flags; /* (see below) */ + u_offset_t hs_prev_offset; /* Last read end offset (readahead) */ + int hs_num_contig; /* Count of contiguous reads */ + int hs_ra_bytes; /* Bytes to readahead */ + kmutex_t hs_contents_lock; /* protects hsnode contents */ + /* except hs_offset */ +}; + +/* hs_flags */ +#define HREF 1 /* hsnode is referenced */ + +/* hs_modes */ + +#define HFDIR 0040000 /* directory */ +#define HFREG 0100000 /* regular file */ + +struct hsfid { + ushort_t hf_len; /* length of fid */ + ushort_t hf_dir_off; /* offset in LBN of directory entry */ + uint_t hf_dir_lbn; /* LBN of directory */ + uint32_t hf_ino; /* The inode number or HS_DUMMY_INO */ +}; + + +/* + * All of the fields in the hs_volume are read-only once they have been + * initialized. + */ +struct hs_volume { + ulong_t vol_size; /* no. of Logical blocks in Volume */ + uint_t lbn_size; /* no. of bytes in a block */ + uint_t lbn_shift; /* shift to convert lbn to bytes */ + uint_t lbn_secshift; /* shift to convert lbn to sec */ + uint_t lbn_maxoffset; /* max lbn-relative offset and mask */ + uchar_t file_struct_ver; /* version of directory structure */ + uid_t vol_uid; /* uid of volume */ + gid_t vol_gid; /* gid of volume */ + uint_t vol_prot; /* protection (mode) of volume */ + struct timeval cre_date; /* volume creation time */ + struct timeval mod_date; /* volume modification time */ + struct hs_direntry root_dir; /* dir entry for Root Directory */ + ushort_t ptbl_len; /* number of bytes in Path Table */ + uint_t ptbl_lbn; /* logical block no of Path Table */ + ushort_t vol_set_size; /* number of CD in this vol set */ + ushort_t vol_set_seq; /* the sequence number of this CD */ + char vol_id[32]; /* volume id in PVD */ +}; + +/* + * The hsnode table is no longer fixed in size but grows + * and shrinks dynamically. However a cache of nodes is still maintained + * for efficiency. This cache size (nhsnode) is a tunable which + * is either specified in /etc/system or calculated as the number + * that will fit into the number of bytes defined by HS_HSNODESPACE (below). + */ +#define HS_HASHSIZE 32 /* hsnode hash table size */ +#define HS_HSNODESPACE 16384 /* approx. space used for hsnodes */ + +/* + * We usually use the starting extent LBA for the inode numbers of files and + * directories. As this will not work for zero sized files, we assign a dummy + * inode number to all zero sized files. We use the number 16 as this is the + * LBA for the PVD, this number cannot be a valid starting extent LBA for a + * file. In case that the node number is the HS_DUMMY_INO, we use the LBA and + * offset of the directory entry of this file (which is what we used before + * we started to support correct hard links). + */ +#define HS_DUMMY_INO 16 /* dummy inode number for empty files */ + +/* + * Hsfs I/O Scheduling parameters and data structures. + * Deadline for reads is set at 5000 usec. + */ +#define HSFS_READ_DEADLINE 5000 +#define HSFS_NORMAL 0x0 + +/* + * This structure holds information for a read request that is enqueued + * for processing by the scheduling function. An AVL tree is used to + * access the read requests in a sorted manner. + */ +struct hio { + struct buf *bp; /* The buf for this read */ + struct hio *contig_chain; /* Next adjacent read if any */ + offset_t io_lblkno; /* Starting disk block of io */ + u_offset_t nblocks; /* # disk blocks */ + uint64_t io_timestamp; /* usec timestamp for deadline */ + ksema_t *sema; /* Completion flag */ + avl_node_t io_offset_node; /* Avl tree requirements */ + avl_node_t io_deadline_node; +}; + +/* + * This structure holds information about all the read requests issued + * during a read-ahead invocation. This is then enqueued on a task-queue + * for processing by a background thread that takes this read-ahead to + * completion and cleans up. + */ +struct hio_info { + struct buf *bufs; /* array of bufs issued for this R/A */ + caddr_t *vas; /* The kmem_alloced chunk for the bufs */ + ksema_t *sema; /* Semaphores used in the bufs */ + uint_t bufsused; /* # of bufs actually used */ + uint_t bufcnt; /* Tot bufs allocated. */ + struct page *pp; /* The list of I/O locked pages */ + struct hsfs *fsp; /* The filesystem structure */ +}; + +/* + * This is per-filesystem structure that stores toplevel data structures for + * the I/O scheduler. + */ +struct hsfs_queue { + /* + * A dummy hio holding the LBN of the last read processed. Easy + * to use in AVL_NEXT for Circular Look behavior. + */ + struct hio *next; + + /* + * A pre-allocated buf for issuing coalesced reads. The scheduling + * function is mostly single threaded by necessity. + */ + struct buf *nbuf; + kmutex_t hsfs_queue_lock; /* Protects the AVL trees */ + + /* + * Makes most of the scheduling function Single-threaded. + */ + kmutex_t strategy_lock; + avl_tree_t read_tree; /* Reads ordered by LBN */ + avl_tree_t deadline_tree; /* Reads ordered by timestamp */ + taskq_t *ra_task; /* Read-ahead Q */ + int max_ra_bytes; /* Max read-ahead quantum */ + + /* Device Max Transfer size in DEV_BSIZE */ + uint_t dev_maxtransfer; +}; + +/* + * High Sierra filesystem structure. + * There is one of these for each mounted High Sierra filesystem. + */ +enum hs_vol_type { + HS_VOL_TYPE_HS = 0, HS_VOL_TYPE_ISO = 1, HS_VOL_TYPE_ISO_V2 = 2, + HS_VOL_TYPE_JOLIET = 3 +}; +#define HSFS_MAGIC 0x03095500 +struct hsfs { + struct hsfs *hsfs_next; /* ptr to next entry in linked list */ + long hsfs_magic; /* should be HSFS_MAGIC */ + struct vfs *hsfs_vfs; /* vfs for this fs */ + struct vnode *hsfs_rootvp; /* vnode for root of filesystem */ + struct vnode *hsfs_devvp; /* device mounted on */ + enum hs_vol_type hsfs_vol_type; /* see above */ + struct hs_volume hsfs_vol; /* File Structure Volume Descriptor */ + struct ptable *hsfs_ptbl; /* pointer to incore Path Table */ + int hsfs_ptbl_size; /* size of incore path table */ + struct ptable_idx *hsfs_ptbl_idx; /* pointer to path table index */ + int hsfs_ptbl_idx_size; /* no. of path table index */ + ulong_t hsfs_ext_impl; /* ext. information bits */ + ushort_t hsfs_sua_off; /* the SUA offset */ + ushort_t hsfs_namemax; /* maximum file name length */ + ushort_t hsfs_namelen; /* "official" max. file name length */ + ulong_t hsfs_err_flags; /* ways in which fs is non-conformant */ + char *hsfs_fsmnt; /* name mounted on */ + ulong_t hsfs_flags; /* hsfs-specific mount flags */ + krwlock_t hsfs_hash_lock; /* protect hash table & hst_nohsnode */ + struct hsnode *hsfs_hash[HS_HASHSIZE]; /* head of hash lists */ + uint32_t hsfs_nohsnode; /* no. of allocated hsnodes */ + kmutex_t hsfs_free_lock; /* protects free list */ + struct hsnode *hsfs_free_f; /* first entry of free list */ + struct hsnode *hsfs_free_b; /* last entry of free list */ + + /* + * Counters exported through kstats. + */ + uint64_t physical_read_bytes; + uint64_t cache_read_pages; + uint64_t readahead_bytes; + uint64_t coalesced_bytes; + uint64_t total_pages_requested; + kstat_t *hsfs_kstats; + + struct hsfs_queue *hqueue; /* I/O Scheduling parameters */ +}; + +/* + * Error types: bit offsets into hsfs_err_flags. + * Also serves as index into hsfs_error[], so must be + * kept in sync with that data structure. + */ +#define HSFS_ERR_TRAILING_JUNK 0 +#define HSFS_ERR_LOWER_CASE_NM 1 +#define HSFS_ERR_BAD_ROOT_DIR 2 +#define HSFS_ERR_UNSUP_TYPE 3 +#define HSFS_ERR_BAD_FILE_LEN 4 +#define HSFS_ERR_BAD_JOLIET_FILE_LEN 5 +#define HSFS_ERR_TRUNC_JOLIET_FILE_LEN 6 +#define HSFS_ERR_BAD_DIR_ENTRY 7 +#define HSFS_ERR_NEG_SUA_LEN 8 +#define HSFS_ERR_BAD_SUA_LEN 9 + +#define HSFS_HAVE_LOWER_CASE(fsp) \ + ((fsp)->hsfs_err_flags & (1 << HSFS_ERR_LOWER_CASE_NM)) + + +/* + * File system parameter macros + */ +#define hs_blksize(HSFS, HSP, OFF) /* file system block size */ \ + ((HSP)->hs_vn.v_flag & VROOT ? \ + ((OFF) >= \ + ((HSFS)->hsfs_rdirsec & ~((HSFS)->hsfs_spcl - 1))*HS_SECSIZE ?\ + ((HSFS)->hsfs_rdirsec & ((HSFS)->hsfs_spcl - 1))*HS_SECSIZE :\ + (HSFS)->hsfs_clsize): \ + (HSFS)->hsfs_clsize) +#define hs_blkoff(OFF) /* offset within block */ \ + ((OFF) & (HS_SECSIZE - 1)) + +/* + * Conversion macros + */ +#define VFS_TO_HSFS(VFSP) ((struct hsfs *)(VFSP)->vfs_data) +#define HSFS_TO_VFS(FSP) ((FSP)->hsfs_vfs) + +#define VTOH(VP) ((struct hsnode *)(VP)->v_data) +#define HTOV(HP) (((HP)->hs_vnode)) + +/* + * Convert between Logical Block Number and Sector Number. + */ +#define LBN_TO_SEC(lbn, vfsp) ((lbn)>>((struct hsfs *)((vfsp)->vfs_data))-> \ + hsfs_vol.lbn_secshift) + +#define SEC_TO_LBN(sec, vfsp) ((sec)<<((struct hsfs *)((vfsp)->vfs_data))-> \ + hsfs_vol.lbn_secshift) + +#define LBN_TO_BYTE(lbn, vfsp) ((lbn)<<((struct hsfs *)((vfsp)->vfs_data))-> \ + hsfs_vol.lbn_shift) +#define BYTE_TO_LBN(boff, vfsp) ((boff)>>((struct hsfs *)((vfsp)->vfs_data))-> \ + hsfs_vol.lbn_shift) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_HSFS_NODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/hsfs_rrip.h b/illumos-x86_64/usr/include/sys/fs/hsfs_rrip.h new file mode 100644 index 00000000..ab0b04a2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/hsfs_rrip.h @@ -0,0 +1,308 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * ISO 9660 RRIP extension filesystem specifications + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_HSFS_RRIP_H +#define _SYS_FS_HSFS_RRIP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Mount options specific to HSFS. + * This is not a good place for them; we should probably have a file + * named hsfs_mount.h for such stuff. + */ +#define HSFSMNT_NORRIP 0x1 /* -nrr option found */ +#define HSFSMNT_NOTRAILDOT 0x2 /* ignore trailing '.' */ +#define HSFSMNT_NOMAPLCASE 0x4 /* do not map filenames to lcase */ +#define HSFSMNT_NOTRAILSPACE 0x8 /* no trailing space in iso 9660 */ +#define HSFSMNT_NOVERSION 0x10 /* no version info in iso 9660 */ +#define HSFSMNT_NOJOLIET 0x20 /* ignore Joliet even if present */ +#define HSFSMNT_JOLIETLONG 0x40 /* do not truncate Joliet filenames */ +#define HSFSMNT_NOVERS2 0x80 /* ignore ISO-9660:1999 */ +#define HSFSMNT_INODE 0x1000 /* May use ext_lbn as inode #, */ + /* FS is from a recent mkisofs */ + +/* + * XXX: The following flag was used in the past to instruct the kernel to + * ignore Rock Ridge extensions on a CD. Unfortunately, this was + * implemented as part of the generic mount flags, a bad idea. + * This flag should not be used anymore. The HSFSMNT_NORRIP + * flag should be used in its place. The hsfs_mount code currently + * understands this flag, but this functionality should go + * away in the future. + */ +#define MS_NO_RRIP 0x800000 /* if set, don't use Rock Ridge */ + + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +/* + * Make sure we have this first + */ + +#define RRIP_VERSION 1 +#define RRIP_SUF_VERSION 1 +#define RRIP_EXT_VERSION 1 + +#define RRIP_BIT 1 /* loc. in extension_name_table in susp.c */ + +#define IS_RRIP_IMPLEMENTED(fsp) (IS_IMPL_BIT_SET(fsp, RRIP_BIT) ? 1 : 0) + + + +/* + * RRIP signature macros + */ +#define RRIP_CL "CL" +#define RRIP_NM "NM" +#define RRIP_PL "PL" +#define RRIP_PN "PN" +#define RRIP_PX "PX" +#define RRIP_RE "RE" +#define RRIP_RR "RR" +#define RRIP_SL "SL" +#define RRIP_TF "TF" + +/* + * RRIP ER extension fields + */ +#define RRIP_ER_EXT_ID "RRIP_1991A" + +#define RRIP_ER_EXT_DES "THE ROCK RIDGE INTERCHANGE PROTOCOL PROVIDES \ +SUPPORT FOR POSIX FILE SYSTEM SEMANTICS." + +#define RRIP_ER_EXT_SRC "PLEASE CONTACT DISC PUBLISHER FOR \ +SPECIFICATION SOURCE. SEE PUBLISHER IDENTIFIER IN PRIMARY VOLUME DESCRIPTOR \ +FOR CONTACT INFORMATION." + +/* + * "TF" time macros + */ +#define RRIP_TF_FLAGS(x) *(RRIP_tf_flags(x)) +#define RRIP_tf_flags(x) (&((uchar_t *)(x))[4]) + +#define RRIP_TIME_START_BP 5 + +#define RRIP_TF_TIME_LENGTH(x) (IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \ + RRIP_TF_LONG_BIT) ? \ + ISO_DATE_LEN : ISO_SHORT_DATE_LEN) + +/* + * Time location bits + */ +#define RRIP_TF_CREATION_BIT 0x01 +#define RRIP_TF_MODIFY_BIT 0x02 +#define RRIP_TF_ACCESS_BIT 0x04 +#define RRIP_TF_ATTRIBUTES_BIT 0x08 +#define RRIP_TF_BACKUP_BIT 0x10 +#define RRIP_TF_EXPIRATION_BIT 0x20 +#define RRIP_TF_EFFECTIVE_BIT 0x40 +#define RRIP_TF_LONG_BIT 0x80 + + + +#define RRIP_tf_creation(x) (&((uchar_t *)x)[RRIP_TIME_START_BP]) +#define RRIP_tf_modify(x) (&((uchar_t *)x)[RRIP_TIME_START_BP + \ + (RRIP_TF_TIME_LENGTH(x) * \ + (IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \ + RRIP_TF_CREATION_BIT)))]) + +#define RRIP_tf_access(x) (&((uchar_t *)x)[RRIP_TIME_START_BP + \ + (RRIP_TF_TIME_LENGTH(x) * \ + (IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \ + RRIP_TF_CREATION_BIT) + \ + IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \ + RRIP_TF_MODIFY_BIT)))]) + +#define RRIP_tf_attributes(x) (&((uchar_t *)x)[RRIP_TIME_START_BP + \ + (RRIP_TF_TIME_LENGTH(x) * \ + (IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \ + RRIP_TF_CREATION_BIT) + \ + IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \ + RRIP_TF_MODIFY_BIT) + \ + IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \ + RRIP_TF_ACCESS_BIT)))]) + + + +/* + * Check if TF Bits are set. + * + * Note : IS_TIME_BIT_SET(x, y) must be kept returning 1 and 0. + * see RRIP_tf_*(x) Macros + */ +#define IS_TIME_BIT_SET(x, y) (((x) & (y)) ? 1 : 0) +#define SET_TIME_BIT(x, y) ((x) |= (y)) + + +/* + * "PX" Posix attibutes + */ +#define RRIP_mode(x) (&((uchar_t *)x)[4]) +#define RRIP_MODE(x) (mode_t)BOTH_INT(RRIP_mode(x)) + +#define RRIP_nlink(x) (&((uchar_t *)x)[12]) +#define RRIP_NLINK(x) (short)BOTH_INT(RRIP_nlink(x)) + +#define RRIP_uid(x) (&((uchar_t *)x)[20]) +#define RRIP_UID(x) (uid_t)BOTH_INT(RRIP_uid(x)) + +#define RRIP_gid(x) (&((uchar_t *)x)[28]) +#define RRIP_GID(x) (gid_t)BOTH_INT(RRIP_gid(x)) + +#define RRIP_ino(x) (&((uchar_t *)x)[36]) +#define RRIP_INO(x) (uint32_t)BOTH_INT(RRIP_ino(x)) + +#define RRIP_PX_OLD_SIZE 36 +#define RRIP_PX_SIZE 44 + +/* + * "PN" Posix major/minor numbers + */ + +#define RRIP_major(x) (&((uchar_t *)x)[4]) +#define RRIP_MAJOR(x) BOTH_INT(RRIP_major(x)) + +#define RRIP_minor(x) (&((uchar_t *)x)[12]) +#define RRIP_MINOR(x) BOTH_INT(RRIP_minor(x)) + + +/* + * "NM" alternate name and "SL" symbolic link macros... + */ + +#define SYM_LINK_LEN(x) (strlen(x) + 1) +#define RRIP_NAME_LEN_BASE 5 +#define RRIP_NAME_LEN(x) (SUF_LEN(x) - RRIP_NAME_LEN_BASE) + +#define RRIP_NAME_FLAGS(x) (((uchar_t *)x)[4]) + +/* + * These are for the flag bits in the NM and SL and must remain <= 8 bits + */ +#define RRIP_NAME_CONTINUE 0x01 +#define RRIP_NAME_CURRENT 0x02 +#define RRIP_NAME_PARENT 0x04 +#define RRIP_NAME_ROOT 0x08 +#define RRIP_NAME_VOLROOT 0x10 +#define RRIP_NAME_HOST 0x20 + + +/* + * These are unique to use in the > 8 bits of sig_args.name_flags + * They are > 8 so that we can share bits from above. + * This can grow to 32 bits. + */ +#define RRIP_NAME_CHANGE 0x40 +#define RRIP_SYM_LINK_COMPLETE 0x80 /* set if sym link already read */ + /* from SUA (no longer than a short) */ + +/* + * Bit handling.... + */ +#define SET_NAME_BIT(x, y) ((x) |= (y)) +#define UNSET_NAME_BIT(x, y) ((x) &= ~(y)) +#define IS_NAME_BIT_SET(x, y) ((x) & (y)) +#define NAME_HAS_CHANGED(flag) \ + (IS_NAME_BIT_SET(flag, RRIP_NAME_CHANGE) ? 1 : 0) + +#define RRIP_name(x) (&((uchar_t *)x)[5]) +#define RRIP_NAME(x) RRIP_name(x) + +/* + * This is the maximum filename length that we support + */ +#define RRIP_FILE_NAMELEN 255 + + +/* + * SL Symbolic link macros (in addition to common name flag macos + */ +/* these two macros are from the SL SUF pointer */ +#define RRIP_sl_comp(x) (&((uchar_t *)x)[5]) +#define RRIP_SL_COMP(x) RRIP_sl_comp(x) +#define RRIP_SL_FLAGS(x) (((uchar_t *)x)[4]) + + +/* these macros are from the component pointer within the SL SUF */ +#define RRIP_comp(x) (&((uchar_t *)x)[2]) +#define RRIP_COMP(x) RRIP_comp(x) +#define RRIP_COMP_FLAGS(x) (((uchar_t *)x)[0]) +#define RRIP_COMP_LEN(x) (RRIP_COMP_NAME_LEN(x) + 2) +#define RRIP_COMP_NAME_LEN(x) (((uchar_t *)x)[1]) + + +/* + * Directory hierarchy macros + */ + +/* + * Macros for checking relocation bits in flags member of dlist + * structure defined in iso_impl.h + */ +#define IS_RELOC_BIT_SET(x, y) (((x) & (y)) ? 1 : 0) +#define SET_RELOC_BIT(x, y) ((x) |= (y)) + +#define CHILD_LINK 0x01 +#define PARENT_LINK 0x02 +#define RELOCATED_DIR 0x04 + +#define RRIP_child_lbn(x) (&((uchar_t *)x)[4]) +#define RRIP_CHILD_LBN(x) (uint_t)BOTH_INT(RRIP_child_lbn(x)) + +#define RRIP_parent_lbn(x) (&((uchar_t *)x)[4]) +#define RRIP_PARENT_LBN(x) (uint_t)BOTH_INT(RRIP_parent_lbn(x)) + + +#ifdef _KERNEL + +/* + * Forward declarations + */ +extern uchar_t *rrip_name(sig_args_t *); +extern uchar_t *rrip_file_attr(sig_args_t *); +extern uchar_t *rrip_dev_nodes(sig_args_t *); +extern uchar_t *rrip_file_time(sig_args_t *); +extern uchar_t *rrip_sym_link(sig_args_t *); +extern uchar_t *rrip_parent_link(sig_args_t *); +extern uchar_t *rrip_child_link(sig_args_t *); +extern uchar_t *rrip_reloc_dir(sig_args_t *); +extern uchar_t *rrip_rock_ridge(sig_args_t *); +extern void hs_check_root_dirent(struct vnode *vp, struct hs_direntry *hdp); +extern int rrip_namecopy(char *from, char *to, char *tmp_name, + uchar_t *dirp, uint_t last_offset, + struct hsfs *fsp, struct hs_direntry *hdp); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_HSFS_RRIP_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/hsfs_spec.h b/illumos-x86_64/usr/include/sys/fs/hsfs_spec.h new file mode 100644 index 00000000..b7f54df4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/hsfs_spec.h @@ -0,0 +1,299 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_HSFS_SPEC_H +#define _SYS_FS_HSFS_SPEC_H + +/* + * High Sierra filesystem specification + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* routines required for date parsing */ +extern void hs_parse_dirdate(uchar_t *, struct timeval *); +extern void hs_parse_longdate(uchar_t *, struct timeval *); + +#endif /* _KERNEL */ + + +/* macros to parse binary integers */ +#define ZERO(x) (uint_t)(((uchar_t *)(x))[0]) +#define ONE(x) (uint_t)(((uchar_t *)(x))[1]) +#define TWO(x) (uint_t)(((uchar_t *)(x))[2]) +#define THREE(x) (uint_t)(((uchar_t *)(x))[3]) + +#define MSB_INT(x) \ + ((((((ZERO(x) << 8) | ONE(x)) << 8) | TWO(x)) << 8) | THREE(x)) +#define LSB_INT(x) \ + ((((((THREE(x) << 8) | TWO(x)) << 8) | ONE(x)) << 8) | ZERO(x)) +#define MSB_SHORT(x) ((ZERO(x) << 8) | ONE(x)) +#define LSB_SHORT(x) ((ONE(x) << 8) | ZERO(x)) + +#if defined(__i386) || defined(__amd64) +#define BOTH_SHORT(x) (short)*((short *)x) +#define BOTH_INT(x) (int)*((int *)x) +#elif defined(__sparc) +/* + * SPARC machines requires that integer must + * be in a full word boundary. CD-ROM data aligns + * to even word boundary only. Because of this mismatch, + * we have to move integer data from CD-ROM to memory one + * byte at a time. LSB data starts first. We therefore + * use this to do byte by byte copying. + */ +#define BOTH_SHORT(x) LSB_SHORT(x) +#define BOTH_INT(x) LSB_INT(x) +#endif + +/* + * The following describes actual on-disk structures. + * To achieve portability, all structures are #defines + * rather than a structure definition. Macros are provided + * to get either the data or address of individual fields. + */ + +/* Overall High Sierra disk structure */ +#define HS_SECTOR_SIZE 2048 /* bytes per logical sector */ +#define HS_SECTOR_SHIFT 11 /* sector<->byte shift count */ +#define HS_SEC_PER_PAGE (PAGESIZE/HS_SECTOR_SIZE) /* sectors per page */ +#define HS_SYSAREA_SEC 0 /* 1st sector of system area */ +#define HS_VOLDESC_SEC 16 /* 1st sector of volume descriptors */ +#define HS_MAXFILEOFF 4294967295U /* Max file offset (4Gb - 1). */ +#define MAXHSOFFSET (HS_SECTOR_SIZE - 1) +#define MAXHSMASK (~MAXHSOFFSET) + +/* Standard File Structure Volume Descriptor */ + +enum hs_voldesc_type { + VD_BOOT = 0, VD_SFS = 1, VD_CCFS = 2, VD_UNSPEC = 3, VD_EOV = 255 +}; +#define HSV_ID_STRING "CDROM" /* HSV_std_id field */ +#define HSV_ID_STRLEN 5 /* HSV_std_id field length */ +#define HSV_ID_VER 1 /* HSV_std_ver field */ +#define HSV_FILE_STRUCT_ID_VER 1 /* HSV_file_struct_ver field */ +#define HSV_SYS_ID_STRLEN 32 /* HSV_sys_id field length */ +#define HSV_VOL_ID_STRLEN 32 /* HSV_vol_id field length */ +#define HSV_VOL_SET_ID_STRLEN 128 /* HSV_vol_set_id field length */ +#define HSV_PUB_ID_STRLEN 128 /* HSV_pub_id field length */ +#define HSV_PREP_ID_STRLEN 128 /* HSV_prep_id field length */ +#define HSV_APPL_ID_STRLEN 128 /* HSV_appl_id field length */ +#define HSV_COPYR_ID_STRLEN 32 /* HSV_copyr_id field length */ +#define HSV_ABSTR_ID_STRLEN 32 /* HSV_abstr_id field length */ +#define HSV_DATE_LEN 16 /* HSV date filed length */ + +/* macros to get the address of each field */ +#define HSV_desc_lbn(x) (&((uchar_t *)x)[0]) +#define HSV_desc_type(x) (&((uchar_t *)x)[8]) +#define HSV_std_id(x) (&((uchar_t *)x)[9]) +#define HSV_std_ver(x) (&((uchar_t *)x)[14]) +#define HSV_sys_id(x) (&((uchar_t *)x)[16]) +#define HSV_vol_id(x) (&((uchar_t *)x)[48]) +#define HSV_vol_size(x) (&((uchar_t *)x)[88]) +#define HSV_set_size(x) (&((uchar_t *)x)[128]) +#define HSV_set_seq(x) (&((uchar_t *)x)[132]) +#define HSV_blk_size(x) (&((uchar_t *)x)[136]) +#define HSV_ptbl_size(x) (&((uchar_t *)x)[140]) +#define HSV_ptbl_man_ls(x) (&((uchar_t *)x)[148]) +#define HSV_ptbl_opt_ls1(x) (&((uchar_t *)x)[152]) +#define HSV_ptbl_opt_ls2(x) (&((uchar_t *)x)[156]) +#define HSV_ptbl_opt_ls3(x) (&((uchar_t *)x)[160]) +#define HSV_ptbl_man_ms(x) (&((uchar_t *)x)[164]) +#define HSV_ptbl_opt_ms1(x) (&((uchar_t *)x)[168]) +#define HSV_ptbl_opt_ms2(x) (&((uchar_t *)x)[172]) +#define HSV_ptbl_opt_ms3(x) (&((uchar_t *)x)[176]) +#define HSV_root_dir(x) (&((uchar_t *)x)[180]) +#define HSV_vol_set_id(x) (&((uchar_t *)x)[214]) +#define HSV_pub_id(x) (&((uchar_t *)x)[342]) +#define HSV_prep_id(x) (&((uchar_t *)x)[470]) +#define HSV_appl_id(x) (&((uchar_t *)x)[598]) +#define HSV_copyr_id(x) (&((uchar_t *)x)[726]) +#define HSV_abstr_id(x) (&((uchar_t *)x)[758]) +#define HSV_cre_date(x) (&((uchar_t *)x)[790]) +#define HSV_mod_date(x) (&((uchar_t *)x)[806]) +#define HSV_exp_date(x) (&((uchar_t *)x)[822]) +#define HSV_eff_date(x) (&((uchar_t *)x)[838]) +#define HSV_file_struct_ver(x) (&((uchar_t *)x)[854]) + +/* macros to get the values of each field (strings are returned as ptrs) */ +#define HSV_DESC_LBN(x) BOTH_INT(HSV_desc_lbn(x)) +#define HSV_DESC_TYPE(x) ((enum hs_voldesc_type)*(HSV_desc_type(x))) +#define HSV_STD_ID(x) HSV_std_id(x) +#define HSV_STD_VER(x) *(HSV_std_ver(x)) +#define HSV_SYS_ID(x) HSV_sys_id(x) +#define HSV_VOL_ID(x) HSV_vol_id(x) +#define HSV_VOL_SIZE(x) BOTH_INT(HSV_vol_size(x)) +#define HSV_SET_SIZE(x) BOTH_SHORT(HSV_set_size(x)) +#define HSV_SET_SEQ(x) BOTH_SHORT(HSV_set_seq(x)) +#define HSV_BLK_SIZE(x) BOTH_SHORT(HSV_blk_size(x)) +#define HSV_PTBL_SIZE(x) BOTH_INT(HSV_ptbl_size(x)) +#define HSV_PTBL_MAN_LS(x) LSB_INT(HSV_ptbl_man_ls(x)) +#define HSV_PTBL_OPT_LS1(x) LSB_INT(HSV_ptbl_opt_ls1(x)) +#define HSV_PTBL_OPT_LS2(x) LSB_INT(HSV_ptbl_opt_ls2(x)) +#define HSV_PTBL_OPT_LS3(x) LSB_INT(HSV_ptbl_opt_ls3(x)) +#define HSV_PTBL_MAN_MS(x) MSB_INT(HSV_ptbl_man_ms(x)) +#define HSV_PTBL_OPT_MS1(x) MSB_INT(HSV_ptbl_opt_ms1(x)) +#define HSV_PTBL_OPT_MS2(x) MSB_INT(HSV_ptbl_opt_ms2(x)) +#define HSV_PTBL_OPT_MS3(x) MSB_INT(HSV_ptbl_opt_ms3(x)) +#define HSV_ROOT_DIR(x) HSV_root_dir(x) +#define HSV_VOL_SET_ID(x) HSV_vol_set_id(x) +#define HSV_PUB_ID(x) HSV_pub_id(x) +#define HSV_PREP_ID(x) HSV_prep_id(x) +#define HSV_APPL_ID(x) HSV_appl_id(x) +#define HSV_COPYR_ID(x) HSV_copyr_id(x) +#define HSV_ABSTR_ID(x) HSV_abstr_id(x) +#define HSV_CRE_DATE(x) HSV_cre_date(x) +#define HSV_MOD_DATE(x) HSV_mod_date(x) +#define HSV_EXP_DATE(x) HSV_exp_date(x) +#define HSV_EFF_DATE(x) HSV_eff_date(x) +#define HSV_FILE_STRUCT_VER(x) *(HSV_file_struct_ver(x)) + +/* Standard File Structure Volume Descriptor date fields */ +#define HSV_DATE_2DIG(x) ((((x)[0] - '0') * 10) + \ + ((x)[1] - '0')) +#define HSV_DATE_4DIG(x) ((((x)[0] - '0') * 1000) + \ + (((x)[1] - '0') * 100) + \ + (((x)[2] - '0') * 10) + \ + ((x)[3] - '0')) +#define HSV_DATE_YEAR(x) HSV_DATE_4DIG(&((uchar_t *)x)[0]) +#define HSV_DATE_MONTH(x) HSV_DATE_2DIG(&((uchar_t *)x)[4]) +#define HSV_DATE_DAY(x) HSV_DATE_2DIG(&((uchar_t *)x)[6]) +#define HSV_DATE_HOUR(x) HSV_DATE_2DIG(&((uchar_t *)x)[8]) +#define HSV_DATE_MIN(x) HSV_DATE_2DIG(&((uchar_t *)x)[10]) +#define HSV_DATE_SEC(x) HSV_DATE_2DIG(&((uchar_t *)x)[12]) +#define HSV_DATE_HSEC(x) HSV_DATE_2DIG(&((uchar_t *)x)[14]) +#define HSV_DATE_GMTOFF(x) (((char *)x)[16]) + + +/* Path table enry */ +/* fix size of path table entry */ +#define HPE_FPESIZE 8 +/* macros to get the address of each field */ +#define HPE_ext_lbn(x) (&((uchar_t *)x)[0]) +#define HPE_xar_len(x) (&((uchar_t *)x)[4]) +#define HPE_name_len(x) (&((uchar_t *)x)[5]) +#define HPE_parent_no(x) (&((uchar_t *)x)[6]) +#define HPE_name(x) (&((uchar_t *)x)[8]) + +/* macros to get the values of each field */ +#if defined(__sparc) +#define HPE_EXT_LBN(x) (MSB_INT(HPE_ext_lbn(x))) +#else +#define HPE_EXT_LBN(x) *(int *)(HPE_ext_lbn(x)) +#endif +#define HPE_XAR_LEN(x) *(HPE_xar_len(x)) +#define HPE_NAME_LEN(x) *(HPE_name_len(x)) +#define HPE_PARENT_NO(x) *(short *)(HPE_parent_no(x)) +#define HPE_NAME(x) HPE_name(x) + +/* root record */ +#define HDE_ROOT_DIR_REC_SIZE 34 /* size of root directory record */ +#define HDE_FDESIZE 33 /* fixed size for hsfs directory area */ +#define HDE_FUSIZE 12 /* fixed size for unix area */ + /* max size of a name */ +#define HDE_MAX_NAME_LEN (255 - HDE_FDESIZE - HDE_FUSIZE) + +/* Directory Entry (Directory Record) */ + +#define UNIX_TO_HDE_DATE(t, p) parse_unixdate((t), (p)) + +/* macros to get the address of each field */ +#define HDE_dir_len(x) (&((uchar_t *)x)[0]) +#define HDE_xar_len(x) (&((uchar_t *)x)[1]) +#define HDE_ext_lbn(x) (&((uchar_t *)x)[2]) +#define HDE_ext_size(x) (&((uchar_t *)x)[10]) +#define HDE_cdate(x) (&((uchar_t *)x)[18]) +#define HDE_flags(x) (&((uchar_t *)x)[24]) +#define HDE_reserved(x) (&((uchar_t *)x)[25]) +#define HDE_intrlv_size(x) (&((uchar_t *)x)[26]) +#define HDE_intrlv_skip(x) (&((uchar_t *)x)[27]) +#define HDE_vol_set(x) (&((uchar_t *)x)[28]) +#define HDE_name_len(x) (&((uchar_t *)x)[32]) +#define HDE_name(x) (&((uchar_t *)x)[33]) + +/* **UNIX extension*** */ +#define HDE_mode(x) (&((uchar_t *)x)[0]) +#define HDE_uid(x) (&((uchar_t *)x)[4]) +#define HDE_gid(x) (&((uchar_t *)x)[8]) + +/* macros to get the values of each field (strings are returned as ptrs) */ +#define HDE_DIR_LEN(x) *(HDE_dir_len(x)) +#define HDE_XAR_LEN(x) *(HDE_xar_len(x)) +#define HDE_EXT_LBN(x) BOTH_INT(HDE_ext_lbn(x)) +#define HDE_EXT_SIZE(x) BOTH_INT(HDE_ext_size(x)) +#define HDE_CDATE(x) HDE_cdate(x) +#define HDE_FLAGS(x) *(HDE_flags(x)) +#define HDE_RESERVED(x) *(HDE_reserved(x)) +#define HDE_INTRLV_SIZE(x) *(HDE_intrlv_size(x)) +#define HDE_INTRLV_SKIP(x) *(HDE_intrlv_skip(x)) +#define HDE_VOL_SET(x) BOTH_SHORT(HDE_vol_set(x)) +#define HDE_NAME_LEN(x) *(HDE_name_len(x)) +#define HDE_NAME(x) HDE_name(x) + +/* **UNIX EXTENSION**** */ +#define HDE_MODE(x) *(HDE_mode(x)) +#define HDE_UID(x) *(HDE_uid(x)) +#define HDE_GID(x) *(HDE_gid(x)) + +/* mask bits for HDE_FLAGS */ +#define HDE_EXISTENCE 0x01 /* zero if file exists */ +#define HDE_DIRECTORY 0x02 /* zero if file is not a directory */ +#define HDE_ASSOCIATED 0x04 /* zero if file is not Associated */ +#define HDE_RECORD 0x08 /* zero if no record attributes */ +#define HDE_PROTECTION 0x10 /* zero if no protection attributes */ +#define HDE_UNUSED_FLAGS 0x60 +#define HDE_LAST_EXTENT 0x80 /* zero if last extent in file */ +#define HDE_PROHIBITED (HDE_DIRECTORY | HDE_RECORD | \ + HDE_LAST_EXTENT | HDE_UNUSED_FLAGS) + +/* Directory Record date fields */ +#define HDE_DATE_YEAR(x) (((uchar_t *)x)[0] + 1900) +#define HDE_DATE_MONTH(x) (((uchar_t *)x)[1]) +#define HDE_DATE_DAY(x) (((uchar_t *)x)[2]) +#define HDE_DATE_HOUR(x) (((uchar_t *)x)[3]) +#define HDE_DATE_MIN(x) (((uchar_t *)x)[4]) +#define HDE_DATE_SEC(x) (((uchar_t *)x)[5]) +#define HDE_DATE_GMTOFF(x) (((char *)x)[6]) + + +/* tests for Interchange Levels 1 & 2 file types */ +#define HDE_REGULAR_FILE(x) (((x) & HDE_PROHIBITED) == 0) +#define HDE_REGULAR_DIR(x) (((x) & HDE_PROHIBITED) == HDE_DIRECTORY) + +#define HS_DIR_NAMELEN 31 /* max length of a directory name */ +#define HS_FILE_NAMELEN 31 /* max length of a filename */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_HSFS_SPEC_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/hsfs_susp.h b/illumos-x86_64/usr/include/sys/fs/hsfs_susp.h new file mode 100644 index 00000000..c8337922 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/hsfs_susp.h @@ -0,0 +1,258 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * ISO 9660 RRIP extension filesystem specifications + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_HSFS_SUSP_H +#define _SYS_FS_HSFS_SUSP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define DEBUGGING_ALL 0 +#define DEBUGGING 0 +#define DPRINTF if (DEBUGGING) printf +#define DPRINTF_ALL if (DEBUGGING_ALL) printf + +/* + * return values from SUA parsing + */ +#define SUA_NULL_POINTER -1 +#define END_OF_SUA_PARSING -2 +#define END_OF_SUA -3 +#define GET_CONTINUATION -4 +#define SUA_ENOMEM -5 +#define SUA_EINVAL -6 +#define RELOC_DIR -7 /* actually for rrip */ + +/* + * For dealing with implemented bits... + * These here expect the fsp and a bit as an agument + */ +#define SET_IMPL_BIT(fsp, y) ((fsp->hsfs_ext_impl) |= (0x01L) << (y)) +#define UNSET_IMPL_BIT(fsp, y) ((fsp->hsfs_ext_impl) &= ~((0x01L) << (y))) +#define IS_IMPL_BIT_SET(fsp, y) ((fsp->hsfs_ext_impl) & ((0x01L) << (y))) + +#define HAVE_SUSP 0 /* have a SUSP */ +#define HAVE_PROHIBITED 1 /* prohibited file/dir type in fs */ + +/* + * For dealing with implemented bits... + * These here expect just the fsp->hsfs_ext_impl + */ +#define SET_SUSP_BIT(fsp) (SET_IMPL_BIT((fsp), HAVE_SUSP)) +#define UNSET_SUSP_BIT(fsp) (UNSET_IMPL_BIT((fsp), HAVE_SUSP)) +#define IS_SUSP_IMPLEMENTED(fsp) (IS_IMPL_BIT_SET(fsp, 0) ? 1 : 0) + +#define SUSP_VERSION 1 + +/* + * SUSP signagure definitions + */ +#define SUSP_SP "SP" +#define SUSP_CE "CE" +#define SUSP_PD "PD" +#define SUSP_ER "ER" +#define SUSP_ST "ST" + +/* + * Generic System Use Field (SUF) Macros and declarations + */ + +#define SUF_SIG_LEN 2 /* length of signatures */ +#define SUF_MIN_LEN 4 /* minimum length of a */ + /* signature field */ + +#define SUF_LEN(x) *(SUF_len(x)) /* SUF length */ +#define SUF_len(x) (&((uchar_t *)x)[2]) /* SUF length */ + +#define SUF_VER(x) *(SUF_ver(x)) /* SUF version */ +#define SUF_ver(x) (&((uchar_t *)x)[3]) /* SUF version */ + +/* + * Extension Reference Macros + */ + +#define ER_ID_LEN(x) *(ER_id_len(x)) /* Extension ref id length */ +#define ER_id_len(x) (&((uchar_t *)x)[4]) /* Extension ref id length */ + + +#define ER_DES_LEN(x) *(ER_des_len(x)) /* Extension ref description */ + /* length */ +#define ER_des_len(x) (&((uchar_t *)x)[5]) /* Extension ref description */ + /* length */ + +#define ER_SRC_LEN(x) *(ER_src_len(x)) /* Extension ref source */ + /* description length */ + +#define ER_src_len(x) (&((uchar_t *)x)[6]) /* Extension ref source */ + /* description length */ + + +#define ER_EXT_VER(x) *(ER_ext_ver(x)) /* Extension ref description */ + /* length */ +#define ER_ext_ver(x) (&((uchar_t *)x)[7]) /* Extension ref description */ + /* length */ + +#define ER_EXT_ID_LOC 8 /* location where the ER id */ + /* string begins */ + +#define ER_ext_id(x) (&((uchar_t *)x)[ER_EXT_ID_LOC]) + /* extension id string */ + +#define ER_ext_des(x) (&((uchar_t *)x)[ER_EXT_ID_LOC + ER_ID_LEN(x)]) + /* ext. description string */ + +#define ER_ext_src(x) (&((uchar_t *)x)[ER_EXT_ID_LOC + ER_ID_LEN(x) + \ + ER_DES_LEN(x)]) + /* ext. source string */ + + +/* + * Continuation Area Macros + */ +#define CE_BLK_LOC(x) BOTH_INT(CE_blk_loc(x)) /* cont. starting block */ +#define CE_blk_loc(x) (&((uchar_t *)x)[4]) /* cont. starting block */ + +#define CE_OFFSET(x) BOTH_INT(CE_offset(x)) /* cont. offset */ +#define CE_offset(x) (&((uchar_t *)x)[12]) /* cont. offset */ + +#define CE_CONT_LEN(x) BOTH_INT(CE_cont_len(x)) /* continuation len */ +#define CE_cont_len(x) (&((uchar_t *)x)[20]) /* continuation len */ + + +/* + * Sharing Protocol (SP) Macros + */ +#define SP_CHK_BYTE_1(x) *(SP_chk_byte_1(x)) /* check bytes */ +#define SP_chk_byte_1(x) (&((uchar_t *)x)[4]) /* check bytes */ + +#define SP_CHK_BYTE_2(x) *(SP_chk_byte_2(x)) /* check bytes */ +#define SP_chk_byte_2(x) (&((uchar_t *)x)[5]) /* check bytes */ + +#define SUSP_CHECK_BYTE_1 (uchar_t)0xBE /* check for 0xBE */ +#define SUSP_CHECK_BYTE_2 (uchar_t)0xEF /* check for 0xEF */ + +#define CHECK_BYTES_OK(x) ((SP_CHK_BYTE_1(x) == SUSP_CHECK_BYTE_1) && \ + (SP_CHK_BYTE_2(x) == SUSP_CHECK_BYTE_2)) + +#define SP_SUA_OFFSET(x) *(SP_sua_offset(x)) /* SUA bytes to skip */ +#define SP_sua_offset(x) (&((uchar_t *)x)[6]) /* SUA bytes to skip */ + + + +/* + * Forward declarations + */ + +#ifdef _KERNEL + +extern uchar_t *share_protocol(); +extern uchar_t *share_ext_ref(); +extern uchar_t *share_continue(); +extern uchar_t *share_padding(); +extern uchar_t *share_stop(); + +#endif + +/* + * Extension signature structure, to corrolate the handler functions + * with the signatures + */ +struct extension_signature_struct { + char *ext_signature; /* extension signature */ + uchar_t *(*sig_handler)(); /* extension handler function */ +}; + +typedef struct extension_signature_struct ext_signature_t; + + +/* + * Extension name structure, to corrolate the extensions with their own + * signature tables. + */ +struct extension_name_struct { + char *extension_name; /* ER field identifier */ + ushort_t ext_version; /* version # of extensions */ + ext_signature_t *signature_table; /* pointer to signature */ + /* table for appropriate */ + /* extension */ +}; + +typedef struct extension_name_struct extension_name_t; + +/* + * Extern declaration for all supported extensions + */ +struct cont_info_struct { + uint_t cont_lbn; /* location of cont */ + uint_t cont_offset; /* offset into cont */ + uint_t cont_len; /* len of cont */ +}; + +typedef struct cont_info_struct cont_info_t; + +/* + * Structure for passing arguments to sig_handler()'s. Since there are + * so many sig_handler()'s, it would be slower to pass multiple + * arguments to all of them. It would also ease maintainance + */ +struct sig_args_struct { + uchar_t *dirp; /* pointer to ISO dir entry */ + uchar_t *name_p; /* dir entry name */ + int *name_len_p; /* dir entry name length */ + short flags; /* misc flags */ + ulong_t name_flags; /* misc flags */ + uchar_t *SUF_ptr; /* pointer to current SUF */ + struct hs_direntry *hdp; /* directory entry */ + struct hsfs *fsp; /* file system */ + cont_info_t *cont_info_p; /* continuation area */ +}; + +typedef struct sig_args_struct sig_args_t; + + +/* + * Extern declaration for all supported extensions + */ + +#ifdef _KERNEL + +extern ext_signature_t rrip_signature_table[]; +extern ext_signature_t susp_signature_table[]; +extern extension_name_t extension_name_table[]; + +extern ext_signature_t *susp_sp; + +extern int parse_sua(uchar_t *, int *name_len_p, int *, uchar_t *, uint_t, + struct hs_direntry *, struct hsfs *, uchar_t *, int search_num); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_HSFS_SUSP_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/lofs_info.h b/illumos-x86_64/usr/include/sys/fs/lofs_info.h new file mode 100644 index 00000000..f06e1377 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/lofs_info.h @@ -0,0 +1,131 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Loopback mount info - one per mount + */ + +#ifndef _SYS_FS_LOFS_INFO_H +#define _SYS_FS_LOFS_INFO_H + +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct lnode; + +struct lobucket { + kmutex_t lh_lock; /* lock protecting bucket contents */ + struct lnode *lh_chain; /* vnode chain for this bucket */ + uint_t lh_count; /* Number of vnodes in chain */ + /* Pad up to 64-byte boundary to avoid false sharing */ +#ifdef _LP64 + char _pad[44]; +#else + char _pad[48]; +#endif +}; + +struct lo_retired_ht { + struct lo_retired_ht *lrh_next; + struct lobucket *lrh_table; + uint_t lrh_size; +}; + +struct loinfo { + struct vfs *li_realvfs; /* real vfs of mount */ + struct vfs *li_mountvfs; /* loopback vfs */ + struct vnode *li_rootvp; /* root vnode of this vfs */ + int li_mflag; /* mount flags to inherit */ + int li_dflag; /* mount flags to not inherit */ + uint_t li_refct; /* # outstanding vnodes */ + volatile uint_t li_htsize; /* # buckets in hashtable */ + struct lobucket *volatile li_hashtable; /* table of per-mount vnodes */ + struct lfsnode *li_lfs; /* list of other vfss */ + kmutex_t li_lfslock; /* lock protecting li_lfs */ + kmutex_t li_htlock; /* protect hashtable, htsize, retired */ + struct lo_retired_ht *li_retired; /* list of retired hashtables */ + int li_flag; /* filesystem behavior flags */ +}; + +/* inheritable mount flags - propagated from real vfs to loopback */ +#define INHERIT_VFS_FLAG \ + (VFS_RDONLY|VFS_NOSETUID|VFS_NODEVICES|VFS_XATTR|VFS_NBMAND|VFS_NOEXEC) + +/* + * "nosub" is used to provide NFS server-like semantics for lo_lookup(): never + * traverse mount points for sub-mounts. The lookup will instead look under + * the mount point. + */ +#define MNTOPT_LOFS_NOSUB "nosub" +#define MNTOPT_LOFS_SUB "sub" + +/* + * Flag values (for li_flag) + */ +#define LO_NOSUB 0x02 /* don't traverse sub-mounts */ + +/* + * lfsnodes are allocated as new real vfs's are encountered + * when looking up things in a loopback name space + * It contains a new vfs which is paired with the real vfs + * so that vfs ops (fsstat) can get to the correct real vfs + * given just a loopback vfs + */ +struct lfsnode { + struct lfsnode *lfs_next; /* next in loinfo list */ + struct vfs *lfs_realvfs; /* real vfs */ + struct vnode *lfs_realrootvp; /* real root vp */ + struct vfs lfs_vfs; /* new loopback vfs */ +}; + +#define vtoli(VFSP) ((struct loinfo *)((VFSP)->vfs_data)) + +#ifdef _KERNEL +extern struct vfs *lo_realvfs(struct vfs *, struct vnode **); +extern void lofs_subrinit(void); +extern void lofs_subrfini(void); + +extern void lsetup(struct loinfo *, uint_t); +extern void ldestroy(struct loinfo *); + +extern const struct fs_operation_def lo_vnodeops_template[]; + +extern struct vnodeops *lo_vnodeops; +extern vfsops_t *lo_vfsops; +extern struct mod_ops mod_fsops; + +#endif /* _KERNEL */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_LOFS_INFO_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/lofs_node.h b/illumos-x86_64/usr/include/sys/fs/lofs_node.h new file mode 100644 index 00000000..fb30cfb4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/lofs_node.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Loop-back file information structure. + */ + +#ifndef _SYS_FS_LOFS_NODE_H +#define _SYS_FS_LOFS_NODE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The lnode is the "inode" for loop-back files. It contains + * all the information necessary to handle loop-back file on the + * client side. + */ +typedef struct lnode { + struct lnode *lo_next; /* link for hash chain */ + struct vnode *lo_vp; /* pointer to real vnode */ + uint_t lo_looping; /* looping flags (see below) */ + struct vnode *lo_vnode; /* place holder vnode for file */ +} lnode_t; + +/* + * Flags used when looping has been detected. + */ +#define LO_LOOPING 0x01 /* Looping detected */ +#define LO_AUTOLOOP 0x02 /* Autonode looping detected */ + +/* + * Flag passed to makelonode(). + */ +#define LOF_FORCE 0x1 /* Force creation of new lnode */ + +/* + * Convert between vnode and lnode + */ +#define ltov(lp) (((lp)->lo_vnode)) +#define vtol(vp) ((struct lnode *)((vp)->v_data)) +#define realvp(vp) (vtol(vp)->lo_vp) + +#ifdef _KERNEL +extern vnode_t *makelonode(vnode_t *, struct loinfo *, int); +extern void freelonode(lnode_t *); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_LOFS_NODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/mntdata.h b/illumos-x86_64/usr/include/sys/fs/mntdata.h new file mode 100644 index 00000000..8d0efeaf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/mntdata.h @@ -0,0 +1,115 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_MNTFS_MNTDATA_H +#define _SYS_MNTFS_MNTDATA_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct mntelem { + /* Metadata. */ + struct mntelem *mnte_next; + struct mntelem *mnte_prev; + timespec_t mnte_birth; + timespec_t mnte_death; + timespec_t mnte_vfs_ctime; + int mnte_refcnt; + /* Payload. */ + int mnte_hidden; + char *mnte_text; + size_t mnte_text_size; + struct extmnttab mnte_tab; +} mntelem_t; + +typedef struct mntsnap { + timespec_t mnts_time; /* Time of this snapshot. */ + timespec_t mnts_last_mtime; /* mnttab modification time. */ + mntelem_t *mnts_first; /* First element in this snapshot. */ + mntelem_t *mnts_next; /* Next element to use. */ + int mnts_flags; /* flags; see below. */ + size_t mnts_nmnts; /* # of elements in this snapshot. */ + size_t mnts_text_size; /* Text size for this snapshot. */ + size_t mnts_foffset; /* File offset of last read(). */ + size_t mnts_ieoffset; /* Offset of last read() in element. */ +} mntsnap_t; + +typedef struct mntnode { + vnode_t *mnt_vnode; /* vnode for this mntnode */ + vnode_t *mnt_mountvp; /* vnode mounted on */ + krwlock_t mnt_contents; /* protects mnt_flags, mnt_read & mnt_ioctl */ + uint_t mnt_flags; /* flags; see below */ + mntsnap_t mnt_read; /* data for read() */ + mntsnap_t mnt_ioctl; /* data for ioctl() */ +} mntnode_t; + +/* + * Conversion macros. + */ +#define VTOM(vp) ((struct mntnode *)(vp)->v_data) +#define MTOV(pnp) ((pnp)->mnt_vnode) +#define MTOD(pnp) ((struct mntdata *)MTOV(pnp)->v_vfsp->vfs_data) + +#define MNTFS_ELEM_IS_DEAD(x) ((x)->mnte_death.tv_sec || \ + (x)->mnte_death.tv_nsec) +#define MNTFS_ELEM_IS_ALIVE(x) !MNTFS_ELEM_IS_DEAD(x) + +#if defined(_KERNEL) + +typedef struct mntdata { + zone_ref_t mnt_zone_ref; /* zone for mount point */ + uint_t mnt_nopen; /* count of vnodes open */ + size_t mnt_size; /* size of last normal snapshot */ + size_t mnt_hidden_size; /* size of last hidden snapshot */ + timespec_t mnt_mtime; /* mtime at last normal snapshot */ + timespec_t mnt_hidden_mtime; /* mtime at last hidden snapshot */ + struct mntnode mnt_node; /* embedded mntnode */ +} mntdata_t; + +/* + * Value for a mntsnap_t's mnts_flags. + */ +#define MNTS_SHOWHIDDEN 0x1 /* This snapshot contains hidden mounts. */ +#define MNTS_REWIND 0x2 /* This snapshot must be refreshed. */ +/* + * Values for a mntnode_t's mnt_flags. + */ +#define MNT_SHOWHIDDEN 0x1 /* Include MS_NOMNTTAB mounts in snapshots. */ + +extern struct vnodeops *mntvnodeops; +extern void mntfs_getmntopts(struct vfs *, char **, size_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MNTFS_MNTDATA_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/namenode.h b/illumos-x86_64/usr/include/sys/fs/namenode.h new file mode 100644 index 00000000..24d276b6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/namenode.h @@ -0,0 +1,110 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _SYS_FS_NAMENODE_H +#define _SYS_FS_NAMENODE_H + +#if defined(_KERNEL) +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This structure is used to pass a file descriptor from user + * level to the kernel. It is first used by fattach() and then + * be NAMEFS. + */ +struct namefd { + int fd; +}; + +#if defined(_KERNEL) +/* + * Each NAMEFS object is identified by a struct namenode/vnode pair. + */ +struct namenode { + struct vnode *nm_vnode; /* represents mounted file desc. */ + int nm_flag; /* flags defined below */ + struct vattr nm_vattr; /* attributes of mounted file desc. */ + struct vnode *nm_filevp; /* file desc. prior to mounting */ + struct file *nm_filep; /* file pointer of nm_filevp */ + struct vnode *nm_mountpt; /* mount point prior to mounting */ + struct namenode *nm_nextp; /* next link in the linked list */ + kmutex_t nm_lock; /* protects nm_vattr */ +}; + +/* + * Valid flags for namenodes. + */ +#define NMNMNT 0x01 /* namenode not mounted */ + +/* + * Macros to convert a vnode to a namenode, and vice versa. + */ +#define VTONM(vp) ((struct namenode *)((vp)->v_data)) +#define NMTOV(nm) ((nm)->nm_vnode) + +#define NM_FILEVP_HASH_SIZE 64 +#define NM_FILEVP_HASH_MASK (NM_FILEVP_HASH_SIZE - 1) +#define NM_FILEVP_HASH_SHIFT 7 +#define NM_FILEVP_HASH(vp) (&nm_filevp_hash[(((uintptr_t)vp) >> \ + NM_FILEVP_HASH_SHIFT) & NM_FILEVP_HASH_MASK]) + +extern struct namenode *nm_filevp_hash[NM_FILEVP_HASH_SIZE]; +extern struct vfs namevfs; + +extern int nameinit(int, char *); +extern int nm_unmountall(struct vnode *, struct cred *); +extern void nameinsert(struct namenode *); +extern void nameremove(struct namenode *); +extern struct namenode *namefind(struct vnode *, struct vnode *); +extern uint64_t namenodeno_alloc(void); +extern void namenodeno_free(uint64_t); +extern struct vnodeops *nm_vnodeops; +extern const struct fs_operation_def nm_vnodeops_template[]; +extern kmutex_t ntable_lock; + +typedef int nm_walk_mounts_f(const struct namenode *, cred_t *, void *); +extern int nm_walk_mounts(const vnode_t *, nm_walk_mounts_f *, cred_t *, + void *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_NAMENODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/pc_dir.h b/illumos-x86_64/usr/include/sys/fs/pc_dir.h new file mode 100644 index 00000000..2f12bea2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/pc_dir.h @@ -0,0 +1,332 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_PC_DIR_H +#define _SYS_FS_PC_DIR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PCFNAMESIZE 8 +#define PCFEXTSIZE 3 +#define PCMAXNAMLEN 255 +#define PCMAXNAM_UTF16 (256 * sizeof (uint16_t)) /* for UTF-16 */ +#define PCLFNCHUNKSIZE 13 + +struct pctime { + ushort_t pct_time; /* hh:mm:ss (little endian) */ + ushort_t pct_date; /* yy:mm:dd (little endian) */ +}; + +/* + * Shifts and masks for time and date fields, in host byte order. + */ +#define SECSHIFT 0 +#define SECMASK 0x1F +#define MINSHIFT 5 +#define MINMASK 0x3F +#define HOURSHIFT 11 +#define HOURMASK 0x1F + +#define DAYSHIFT 0 +#define DAYMASK 0x1F +#define MONSHIFT 5 +#define MONMASK 0x0F +#define YEARSHIFT 9 +#define YEARMASK 0x7F + +struct pcdir { + char pcd_filename[PCFNAMESIZE]; /* file name */ + char pcd_ext[PCFEXTSIZE]; /* file extension */ + uchar_t pcd_attr; /* file attributes */ + uchar_t pcd_ntattr; /* reserved for NT attributes */ + uchar_t pcd_crtime_msec; /* milliseconds after the minute */ + struct pctime pcd_crtime; /* creation time/date */ + ushort_t pcd_ladate; /* last-access date */ + union { + uint16_t pcd_eattr; /* OS/2 extended attribute */ + pc_cluster16_t pcd_scluster_hi; + } un; + struct pctime pcd_mtime; /* last modified time/date */ + pc_cluster16_t pcd_scluster_lo; /* starting cluster (little endian) */ + uint_t pcd_size; /* file size (little endian) */ +}; + +#ifdef __cplusplus +} +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Long filename support (introduced by Windows 95) is an interesting + * exercise in compatibility. Basically, it is now no longer the case + * that an entry in a directory (as described by the 'pcdir' structure above) + * contains the entire name of a file. Now, a directory entry can consist of + * a long filename component (a series of 'pcdir'-like structures) followed + * by a short filename (the old form). Each long filename component is + * identified by having it's Read-Only, Hidden, System, and Volume Label + * attributes set. Each can store 13 Unicode characters (16-bits, of + * which we only look at the lower 8 for now), broken into (gak) three + * sections of the entry (since that's the way the available bits fall out). + * In addition, each long filename entry has a sequence number (starting + * from 1). The first entry has bit 7 (0x40) set in the sequence number, and + * has the maximum value in the sequence. This may seem a bit backwards, and + * it gets worse: the first entry stores the last component of + * the name. So the directory entry for a file named + * "This is a very long filename indeed" might look like this: + * + * Offset Sequence Component Attributes Cluster Size + * 0 0x43 "me indeed" RSHV 0 0 + * 32 0x02 "y long filena" RSHV 0 0 + * 64 0x01 "This is a ver" RSHV 0 0 + * 96 ---- "THISIS~1.TXT" 2122 110 + * + * The last entry is for the short filename, which stores actual information + * about the file (like type, permissions, cluster, and size). The short name + * is also used by non-long-filename aware applications (like Windows 3.X and + * DOS). This name is generated by Windows 95 (and now Solaris) from the + * long name, and must (of course) be unique within the directory. + * Solaris continues to this entry to actually identify the file and its + * attributes (filenames only really matter when names are used, like at + * lookup/readdir/remove/create/rename time - for general access to the file + * they aren't used). + * + * Long filenames can also be broken by applications that don't + * understand them (for example, a Solaris 2.5.1 user could rename + * "THISIS~1.TXT" to "test.exe"). This can be detected because each long + * filename component has a checksum which is based on the short filename. + * After reading the long filename entry, if the checksum doesn't match the + * short name that follows, we simply ignore it and use the short name. + * + * One subtle thing - though long file names are case-sensitive, + * searches for them are not. + * + * Another _very_ subtle thing. The number of characters in the + * last long filename chunk (the first entry, with the 0x40 bit set) is + * either all the characters (if there is no null, '\0'), or all the + * characters up to the null. _However_, if the remaining characters are + * null, Norton Disk Doctor and Microsoft ScanDisk will claim + * that the filename entry is damaged. The remaining bytes must actually + * contain 0xff (discovered with Disk Doctor). + * + * Some information about long filename support can be found in the + * book "Inside Windows 95" by Adrian King. + */ + +/* + * The number of bytes in each section of the name in a long filename + * entry. This is _bytes_, not characters: each character is actually + * 16 bits. + */ +#define PCLF_FIRSTNAMESIZE 10 +#define PCLF_SECONDNAMESIZE 12 +#define PCLF_THIRDNAMESIZE 4 + +/* + * A long filename entry. It must match the 'pcdir' structure in size, + * and pcdl_attr must overlap pcd_attr. + */ +struct pcdir_lfn { + uchar_t pcdl_ordinal; /* lfn order. First is 01, next 02, */ + /* last has bit 7 (0x40) set */ + uchar_t pcdl_firstfilename[PCLF_FIRSTNAMESIZE]; + uchar_t pcdl_attr; + uchar_t pcdl_type; /* type - always contains 0 for an LFN entry */ + uchar_t pcdl_checksum; /* checksum to validate the LFN entry - */ + /* based on the short name */ + uchar_t pcdl_secondfilename[PCLF_SECONDNAMESIZE]; + pc_cluster16_t pcd_scluster; /* (not used, always 0) */ + uchar_t pcdl_thirdfilename[PCLF_THIRDNAMESIZE]; +}; + +/* + * FAT LFN entries are consecutively numbered downwards, and the last + * entry of a LFN chain will have the 0x40 'termination' marker logically + * or'ed in. The entry immediately preceeding the short name has number 1, + * consecutively increasing. Since the filename length limit on FAT is + * 255 unicode characters and every LFN entry contributes 13 characters, + * the maximum sequence number is 255/13 + 1 == 20. + */ +#define PCDL_IS_LAST_LFN(x) ((x->pcdl_ordinal) & 0x40) +#define PCDL_LFN_BITS (PCA_RDONLY | PCA_HIDDEN | PCA_SYSTEM | PCA_LABEL) +#define PCDL_LFN_MASK (PCDL_LFN_BITS | PCA_DIR | PCA_ARCH) +#define PCDL_LFN_VALID_ORD(x) \ + (((((struct pcdir_lfn *)(x))->pcdl_ordinal & ~0x40) > 0) && \ + ((((struct pcdir_lfn *)(x))->pcdl_ordinal & ~0x40) <= 20)) +#define PCDL_IS_LFN(x) \ + (enable_long_filenames && \ + (((x)->pcd_attr & PCDL_LFN_MASK) == PCDL_LFN_BITS) && \ + PCDL_LFN_VALID_ORD((x))) + +/* + * The first char of the file name has special meaning as follows: + */ +#define PCD_UNUSED ((char)0x00) /* entry has never been used */ +#define PCD_ERASED ((char)0xE5) /* entry was erased */ + +/* + * File attributes. + */ +#define PCA_RDONLY 0x01 /* file is read only */ +#define PCA_HIDDEN 0x02 /* file is hidden */ +#define PCA_SYSTEM 0x04 /* system file */ +#define PCA_LABEL 0x08 /* entry contains the volume label */ +#define PCA_DIR 0x10 /* subdirectory */ +#define PCA_ARCH 0x20 /* file has been modified since last backup */ + +/* + * Avoid hidden files unless the private variable is set. + * Always avoid the label. + */ +#define PCA_IS_HIDDEN(fsp, attr) \ + ((((attr) & PCA_LABEL) == PCA_LABEL) || \ + ((((fsp)->pcfs_flags & PCFS_HIDDEN) == 0) && \ + ((attr) & (PCA_HIDDEN | PCA_SYSTEM)))) + +#define PC_NAME_IS_DOT(namep) \ + (((namep)[0] == '.') && ((namep)[1] == '\0')) +#define PC_NAME_IS_DOTDOT(namep) \ + (((namep)[0] == '.') && ((namep)[1] == '.') && ((namep)[2] == '\0')) +#define PC_SHORTNAME_IS_DOT(namep) \ + (((namep)[0] == '.') && ((namep)[1] == ' ')) +#define PC_SHORTNAME_IS_DOTDOT(namep) \ + (((namep)[0] == '.') && ((namep)[1] == '.') && ((namep)[2] == ' ')) +/* + * slot structure is used by the directory search routine to return + * the results of the search. If the search is successful sl_blkno and + * sl_offset reflect the disk address of the entry and sl_ep points to + * the actual entry data in buffer sl_bp. sl_flags is set to whether the + * entry is dot or dotdot. If the search is unsuccessful sl_blkno and + * sl_offset points to an empty directory slot if there are any. Otherwise + * it is set to -1. + */ +struct pcslot { + enum {SL_NONE, SL_FOUND, SL_EXTEND} sl_status; /* slot status */ + daddr_t sl_blkno; /* disk block number which has entry */ + int sl_offset; /* offset of entry within block */ + struct buf *sl_bp; /* buffer containing entry data */ + struct pcdir *sl_ep; /* pointer to entry data */ + int sl_flags; /* flags (see below) */ +}; +#define SL_DOT 1 /* entry point to self */ +#define SL_DOTDOT 2 /* entry points to parent */ + +/* + * A pcfs directory entry. Directory entries are actually variable + * length, but this is the maximum size. + * + * This _must_ match a dirent64 structure in format. + * d_name is 512 bytes long to accomodate 256 UTF-16 characters. + */ +struct pc_dirent { + ino64_t d_ino; /* "inode number" of entry */ + off64_t d_off; /* offset of disk directory entry */ + unsigned short d_reclen; /* length of this record */ + char d_name[PCMAXNAM_UTF16]; +}; + +/* + * Check FAT 8.3 filename characters for validity. + * Lacking a kernel iconv, codepage support for short filenames + * is not provided. + * Short names must be uppercase ASCII (no support for MSDOS + * codepages right now, sorry) and may not contain any of + * *+=|\[];:",<>.?/ which are explicitly forbidden by the + * FAT specifications. + */ +#define pc_invalchar(c) \ + (((c) >= 'a' && (c) <= 'z') || \ + (c) == '"' || (c) == '*' || (c) == '+' || (c) == ',' || \ + (c) == '.' || (c) == '/' || (c) == ':' || (c) == ';' || \ + (c) == '<' || (c) == '=' || (c) == '>' || (c) == '?' || \ + (c) == '[' || (c) == '|' || (c) == ']' || (c) == '\\') + +#define pc_validchar(c) (((c) >= ' ' && !((c) & ~0177)) && !pc_invalchar(c)) + + +#ifdef _KERNEL + +/* + * macros for converting ASCII to/from upper or lower case. + * users may give and get names in lower case, but they are stored on the + * disk in upper case to be PCDOS compatible. + * These would better come from some shared source in but + * there is no such place yet. + */ +#define toupper(C) (((C) >= 'a' && (C) <= 'z') ? (C) - 'a' + 'A' : (C)) +#define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C)) + +extern int pc_tvtopct(timestruc_t *, struct pctime *); /* timeval to pctime */ +extern void pc_pcttotv(struct pctime *, int64_t *); /* pctime to timeval */ +extern int pc_valid_lfn_char(char); /* valid long filename ch */ + +extern int pc_read_long_fn(struct vnode *, struct uio *, + struct pc_dirent *, struct pcdir **, offset_t *, struct buf **); +extern int pc_read_short_fn(struct vnode *, struct uio *, + struct pc_dirent *, struct pcdir **, offset_t *, struct buf **); +extern int pc_match_long_fn(struct pcnode *, char *, struct pcdir **, + struct pcslot *, offset_t *); +extern int pc_match_short_fn(struct pcnode *, char *, + struct pcdir **, struct pcslot *, offset_t *); +extern uchar_t pc_checksum_long_fn(char *, char *); +extern void set_long_fn_chunk(struct pcdir_lfn *, char *, int); +extern int pc_valid_long_fn(char *, int); +extern int pc_extract_long_fn(struct pcnode *, char *, + struct pcdir **, offset_t *offset, struct buf **); +extern int pc_fname_ext_to_name(char *, char *, char *, int); + +extern pc_cluster32_t pc_getstartcluster(struct pcfs *, struct pcdir *); +extern void pc_setstartcluster(struct pcfs *, struct pcdir *, pc_cluster32_t); + +/* + * Private tunables + */ + +/* + * Use long filenames (Windows 95). Disabling this causes pcfs + * to not recognize long filenames at all, which may cause it to + * break associations between the short and long names. This is likely + * to leave unused long filename entries in directories (which may make + * apparently empty directories unremovable), and would require a fsck_pcfs + * to find and fix (or a Windows utility like Norton Disk Doctor or + * Microsoft ScanDisk). + */ +extern int enable_long_filenames; /* default: on */ + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_PC_DIR_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/pc_fs.h b/illumos-x86_64/usr/include/sys/fs/pc_fs.h new file mode 100644 index 00000000..d5850034 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/pc_fs.h @@ -0,0 +1,610 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_PC_FS_H +#define _SYS_FS_PC_FS_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint16_t pc_cluster16_t; +typedef uint32_t pc_cluster32_t; + +/* + * PC (MSDOS) compatible virtual file system. + * + * A main goal of the implementation was to maintain statelessness + * except while files are open. Thus mounting and unmounting merely + * declared the file system name. The user may change disks at almost + * any time without concern (just like the PC). It is assumed that when + * files are open for writing the disk access light will be on, as a + * warning not to change disks. The implementation must, however, detect + * disk change and recover gracefully. It does this by comparing the + * in core entry for a directory to the on disk entry whenever a directory + * is searched. If a discrepancy is found active directories become root and + * active files are marked invalid. + * + * There are only two type of nodes on the PC file system; files and + * directories. These are represented by two separate vnode op vectors, + * and they are kept in two separate tables. Files are known by the + * disk block number and block (cluster) offset of the files directory + * entry. Directories are known by the starting cluster number. + * + * The file system is locked for during each user operation. This is + * done to simplify disk verification error conditions. + * + * Notes on FAT32 support + * ---------------------- + * The basic difference between FAT32 and FAT16 is that cluster numbers are now + * 32-bit instead of 16-bit. The FAT is thus an array of 32-bit cluster numbers, + * and because of this the cluster size can be much smaller on a large disk + * (4k, say, on a 1 Gig drive instead of 16k). Unfortunately, the FAT is not + * the only place cluster numbers are stored - the starting cluster is stored + * in the directory entry for a file, and of course it's only 16-bit. Luckily, + * there's a 16-bit OS/2 Extended Attribute field that is now used to store the + * upper 16-bits of the starting cluster number. + * + * Most of the FAT32 changes to pcfs are under 'if it's FAT32' to minimize the + * effect on non-FAT32 filesystems (and still share the code), except for the + * starting cluster changes. It seemed easier to make common functions to + * handle that. + * + * Other changes: + * + * 1. FAT32 partitions are indicated by partition types 0xB and 0xC. + * 2. The boot sector is now 2 sectors, to make room for FAT32 extensions. + * 3. The root directory is no longer stored in a fixed location. Its' + * starting cluster is stored in the extended boot sector. + * 4. "Summary information" is now stored and we need to (at least) maintain + * the number of free clusters or scandisk will be upset. Though the + * sector this info is in is pointed to by the extensions in the boot + * sector, the magic offset of this information is just that so + * far - magic. 0x1e0. + * 5. FAT32 can use the alternate FAT. But we don't. + * + * FAT32 also exposed a latent bug: we bread() each copy of the FAT in one + * big chunk. This is not good on a large FAT32 drive, such as a 1 Gig + * Jaz drive that has 4k clusters, since the FAT becomes 1 Meg in size and + * bread blocks forever. So now we read the FAT in chunks. + */ + + +/* + * The FAT bootsector uses little-endian multibyte values not aligned at + * a 'native' wordsize. Instead of defining a strange data structure and + * odd accessor methods for some members while using standard C accesses + * for others, we don't bother and just define the structure offsets, and + * a common set of misaligned-littleendian accessor macros. + * + * The "bootsec" and "fat32_bootsec" structures are only provided for + * compatibility with old code including but not used + * by the PCFS kernel driver anymore. + */ +struct bootsec { + uchar_t instr[3]; + uchar_t version[8]; + uchar_t bps[2]; /* bytes per sector */ + uchar_t spcl; /* sectors per allocation unit */ + uchar_t res_sec[2]; /* reserved sectors, starting at 0 */ + uchar_t nfat; /* number of FATs */ + uchar_t rdirents[2]; /* number of root directory entries */ + uchar_t numsect[2]; /* old total sectors in logical image */ + uchar_t mediadesriptor; /* media descriptor byte */ + ushort_t fatsec; /* number of sectors per FAT */ + ushort_t spt; /* sectors per track */ + ushort_t nhead; /* number of heads */ + uint_t hiddensec; /* number of hidden sectors */ + uint_t totalsec; /* total sectors in logical image */ +}; + +/* + * FAT32 volumes have a bigger boot sector. They include the normal + * boot sector. + */ +struct fat32_bootsec { + struct bootsec f_bs; + uint32_t f_fatlength; /* size of FAT */ + uint16_t f_flags; + uint8_t f_major; /* major filesystem version #? */ + uint8_t f_minor; /* minor filesystem version #? */ + uint32_t f_rootcluster; /* first cluster in root directory */ + uint16_t f_infosector; /* where summary info is */ + uint16_t f_backupboot; /* backup boot sector */ + uint16_t f_reserved2[6]; +}; + + +#define OFF_JMPBOOT 0 +#define OFF_OEMNAME 3 +#define OFF_BYTESPERSEC 11 +#define OFF_SECPERCLUS 13 +#define OFF_RSVDSECCNT 14 +#define OFF_NUMFATS 16 +#define OFF_ROOTENTCNT 17 +#define OFF_TOTSEC16 19 +#define OFF_MEDIA 21 +#define OFF_FATSZ16 22 +#define OFF_SECPERTRK 24 +#define OFF_NUMHEADS 26 +#define OFF_HIDDSEC 28 +#define OFF_TOTSEC32 32 +#define OFF_BPBSIG 510 + +#define OFF_DRVNUM16 36 +#define OFF_BOOTSIG16 38 +#define OFF_VOLID16 39 +#define OFF_VOLLAB16 43 +#define OFF_FILSYSTYP16 54 + +#define OFF_FATSZ32 36 +#define OFF_EXTFLAGS32 40 +#define OFF_FSVER32 42 +#define OFF_ROOTCLUS32 44 +#define OFF_FSINFO32 48 +#define OFF_BKBOOTSEC32 50 +#define OFF_DRVNUM32 64 +#define OFF_BOOTSIG32 66 +#define OFF_VOLID32 67 +#define OFF_VOLLAB32 71 +#define OFF_FILSYSTYP32 82 + +#define LE_16_NA(addr) \ + (((uint16_t)*((uint8_t *)(addr))) + \ + ((uint16_t)*((uint8_t *)(addr) + 1) << 8)) + +#define LE_32_NA(addr) \ + (((uint32_t)*((uint8_t *)(addr))) + \ + ((uint32_t)*((uint8_t *)(addr) + 1) << 8) + \ + ((uint32_t)*((uint8_t *)(addr) + 2) << 16) + \ + ((uint32_t)*((uint8_t *)(addr) + 3) << 24)) + +/* + * Generic FAT BPB fields + */ +#define bpb_jmpBoot(bpb) ((unsigned char *)(bpb)) +#define bpb_OEMName(bpb) ((char *)(bpb) + OFF_OEMNAME) +#define bpb_get_BytesPerSec(bpb) LE_16_NA((bpb) + OFF_BYTESPERSEC) +#define bpb_get_SecPerClus(bpb) (((uint8_t *)(bpb))[OFF_SECPERCLUS]) +#define bpb_get_RsvdSecCnt(bpb) LE_16_NA((bpb) + OFF_RSVDSECCNT) +#define bpb_get_NumFATs(bpb) (((uint8_t *)(bpb))[OFF_NUMFATS]) +#define bpb_get_RootEntCnt(bpb) LE_16_NA((bpb) + OFF_ROOTENTCNT) +#define bpb_get_TotSec16(bpb) LE_16_NA((bpb) + OFF_TOTSEC16) +#define bpb_get_Media(bpb) (((uint8_t *)(bpb))[OFF_MEDIA]) +#define bpb_get_FatSz16(bpb) LE_16_NA((bpb) + OFF_FATSZ16) +#define bpb_get_SecPerTrk(bpb) LE_16_NA((bpb) + OFF_SECPERTRK) +#define bpb_get_NumHeads(bpb) LE_16_NA((bpb) + OFF_NUMHEADS) +#define bpb_get_HiddSec(bpb) LE_32_NA((bpb) + OFF_HIDDSEC) +#define bpb_get_TotSec32(bpb) LE_32_NA((bpb) + OFF_TOTSEC32) +#define bpb_get_BPBSig(bpb) LE_16_NA((bpb) + OFF_BPBSIG) + +/* + * FAT12/16 extended BPB fields + */ +#define bpb_get_DrvNum16(bpb) (((uint8_t *)(bpb))[OFF_DRVNUM16]) +#define bpb_get_BootSig16(bpb) (((uint8_t *)(bpb))[OFF_BOOTSIG16]) +#define bpb_VolLab16(bpb) ((char *)(bpb) + OFF_VOLLAB16) +#define bpb_FilSysType16(bpb) ((char *)(bpb) + OFF_FILSYSTYP16) +#define bpb_get_VolID16(bpb) LE_32_NA((bpb) + OFF_VOLID16) + +/* + * FAT32 extended BPB fields + */ +#define bpb_get_FatSz32(bpb) LE_32_NA((bpb) + OFF_FATSZ32) +#define bpb_get_ExtFlags32(bpb) LE_16_NA((bpb) + OFF_EXTFLAGS32) +#define bpb_get_FSVer32(bpb) LE_16_NA((bpb) + OFF_FSVER32) +#define bpb_get_RootClus32(bpb) LE_32_NA((bpb) + OFF_ROOTCLUS32) +#define bpb_get_FSInfo32(bpb) LE_16_NA((bpb) + OFF_FSINFO32) +#define bpb_get_BkBootSec32(bpb) LE_16_NA((bpb) + OFF_BKBOOTSEC32) +#define bpb_get_DrvNum32(bpb) (((uint8_t *)(bpb))[OFF_DRVNUM32]) +#define bpb_get_BootSig32(bpb) (((uint8_t *)(bpb))[OFF_BOOTSIG32]) +#define bpb_get_VolID32(bpb) LE_32_NA((bpb) + OFF_VOLID32) +#define bpb_VolLab32(bpb) ((char *)(bpb) + OFF_VOLLAB32) +#define bpb_FilSysType32(bpb) ((char *)(bpb) + OFF_FILSYSTYP32) + +/* + * Validators + */ +#define VALID_SECSIZE(s) \ + (s == 512 || s == 1024 || s == 2048 || s == 4096) +#define VALID_SPCL(s) (ISP2((s)) && (unsigned int)(s) <= 128) +#define VALID_CLSIZE(s) (ISP2((s)) && (unsigned int)(s) <= (64 * 1024)) +#define VALID_NUMFATS(n) ((n) > 0 && (n) < 8) +#define VALID_RSVDSEC(s) ((s) > 0) +#define VALID_BPBSIG(sig) ((sig) == MBB_MAGIC) +#define VALID_BOOTSIG(sig) ((sig) == 0x29) +#define VALID_MEDIA(m) ((m) == 0xF0 || ((m) >= 0xF8 && (m) <= 0xFF)) + +/* + * this might require a change for codepage support. In particular, + * pc_validchar() cannot be a macro anymore if codepages get involved. + */ +#define VALID_VOLLAB(l) ( \ + pc_validchar((l)[0]) && pc_validchar((l)[1]) && \ + pc_validchar((l)[2]) && pc_validchar((l)[3]) && \ + pc_validchar((l)[4]) && pc_validchar((l)[5]) && \ + pc_validchar((l)[6]) && pc_validchar((l)[7]) && \ + pc_validchar((l)[8]) && pc_validchar((l)[9]) && \ + pc_validchar((l)[10])) + +/* + * We might actually use the 'validchar' checks as well; it only needs + * to be printable. Should this ever caused failed media recognition, + * we can change it. Many ISVs put different strings into the "oemname" + * field. + */ +#define VALID_OEMNAME(nm) ( \ + bcmp((nm), "MSDOS", 5) == 0 || bcmp((nm), "MSWIN", 5) == 0) +#define VALID_FSTYPSTR16(typ) (bcmp((typ), "FAT", 3) == 0) +#define VALID_FSTYPSTR32(typ) (bcmp((typ), "FAT32", 5) == 0) +#define VALID_JMPBOOT(b) ( \ + ((b)[0] == 0xeb && (b)[2] == 0x90) || (b)[0] == 0xe9) +#define VALID_FSVER32(v) ((v) == PCFS_SUPPORTED_FSVER) +/* + * Can we check this properly somehow ? There should be a better way. + * The FAT spec doesn't mention reserved bits need to be zero ... + */ +#define VALID_EXTFLAGS(flags) (((flags) & 0x8f) == (flags)) + +/* + * Validation results + */ +#define BPB_SECSIZE_OK (1 << 0) /* ok: 512/1024/2048/4096 */ +#define BPB_OEMNAME_OK (1 << 1) /* "MSDOS" or "MSWIN" */ +#define BPB_JMPBOOT_OK (1 << 2) /* 16bit "jmp" / "call" */ +#define BPB_SECPERCLUS_OK (1 << 3) /* power of 2, [1 .. 128] */ +#define BPB_RSVDSECCNT_OK (1 << 4) /* cannot be zero */ +#define BPB_NUMFAT_OK (1 << 5) /* >= 1, <= 8 */ +#define BPB_ROOTENTCNT_OK (1 << 6) /* 0 on FAT32, != 0 else */ +#define BPB_TOTSEC_OK (1 << 7) /* smaller than volume */ +#define BPB_TOTSEC16_OK (1 << 8) /* 0 on FAT32, != 0 on FAT12 */ +#define BPB_TOTSEC32_OK (1 << 9) /* 0 on FAT12, != 0 on FAT32 */ +#define BPB_MEDIADESC_OK (1 << 10) /* 0xf0 or 0xf8..0xff */ +#define BPB_FATSZ_OK (1 << 11) /* [nclusters], no smaller */ +#define BPB_FATSZ16_OK (1 << 12) /* 0 on FAT32, != 0 else */ +#define BPB_FATSZ32_OK (1 << 13) /* non-zero on FAT32 */ +#define BPB_BPBSIG_OK (1 << 14) /* 0x55, 0xAA */ +#define BPB_BOOTSIG16_OK (1 << 15) /* 0x29 - if present */ +#define BPB_BOOTSIG32_OK (1 << 16) /* 0x29 - unless SYSLINUX2.x */ +#define BPB_FSTYPSTR16_OK (1 << 17) /* At least "FAT" */ +#define BPB_FSTYPSTR32_OK (1 << 18) /* "FAT32" */ +#define BPB_EXTFLAGS_OK (1 << 19) /* reserved bits should be 0 */ +#define BPB_FSVER_OK (1 << 20) /* must be 0 */ +#define BPB_ROOTCLUSTER_OK (1 << 21) /* must be != 0 and valid */ +#define BPB_FSISEC_OK (1 << 22) /* != 0, <= reserved */ +#define BPB_BKBOOTSEC_OK (1 << 23) /* != 0, <= reserved, != fsi */ +#define BPB_VOLLAB16_OK (1 << 24) /* passes pc_validchar() */ +#define BPB_VOLLAB32_OK (1 << 25) /* passes pc_validchar() */ +#define BPB_NCLUSTERS_OK (1 << 26) /* from FAT spec */ +#define BPB_CLSIZE_OK (1 << 27) /* cluster size */ +#define BPB_MEDIASZ_OK (1 << 28) /* filesystem fits on device */ + +#define FAT12_VALIDMSK \ + (BPB_SECSIZE_OK | BPB_SECPERCLUS_OK | BPB_CLSIZE_OK | \ + BPB_RSVDSECCNT_OK | BPB_NUMFAT_OK | BPB_ROOTENTCNT_OK | \ + BPB_TOTSEC_OK | BPB_TOTSEC16_OK | \ + BPB_FATSZ_OK | BPB_FATSZ16_OK | BPB_BPBSIG_OK) + +#define FAT16_VALIDMSK \ + (BPB_SECSIZE_OK | BPB_SECPERCLUS_OK | BPB_CLSIZE_OK | \ + BPB_RSVDSECCNT_OK | BPB_NUMFAT_OK | BPB_ROOTENTCNT_OK | \ + BPB_TOTSEC_OK | BPB_TOTSEC16_OK | BPB_TOTSEC32_OK | \ + BPB_FATSZ_OK | BPB_FATSZ16_OK | BPB_BPBSIG_OK) + +/* + * A note on FAT32: According to the FAT spec, FAT32 _must_ have a valid + * extended BPB and therefore, as a proof of its existance, the FAT32 + * boot signature (offset 66) must be valid as well. Why don't we check + * for BPB_BOOTSIG32_OK then ? + * + * We don't test for this here first-pass, because there are media out + * there that are valid FAT32 structurally but don't have a valid sig. + * This happens if older versions of the SYSLINUX bootloader (below 3.x) + * are installed on a media with a FAT32 on it. SYSLINUX 2.x and lower + * overwrite the BPB past the end of the FAT12/16 extension with its + * bootloader code - and the FAT16 extended BPB is 62 Bytes... + * All structurally relevant fields of the FAT32 BPB are within the first + * 52 Bytes, so the filesystem is accessible - but the signature check + * would reject it. + */ +#define FAT32_VALIDMSK \ + (BPB_SECSIZE_OK | BPB_SECPERCLUS_OK | BPB_CLSIZE_OK | \ + BPB_RSVDSECCNT_OK | BPB_NUMFAT_OK | BPB_ROOTENTCNT_OK | \ + BPB_TOTSEC_OK | BPB_TOTSEC16_OK | BPB_TOTSEC32_OK | \ + BPB_FATSZ_OK | BPB_FATSZ16_OK | BPB_FATSZ32_OK | \ + BPB_EXTFLAGS_OK | BPB_FSVER_OK | BPB_ROOTCLUSTER_OK | \ + BPB_BPBSIG_OK) + +/* + * FAT32 BPB allows 'versioning' via FSVer32. We follow the 'NULL' spec. + */ +#define PCFS_SUPPORTED_FSVER 0 + + +/* + * Filesystem summary information (introduced originally for FAT32 volumes). + * We need to maintain fs_free_clusters or Microsoft Scandisk will be upset. + * We keep these values in-core even for FAT12/FAT16 but will never attempt + * to write them out to disk then. + */ +typedef struct fat_fsinfo { + uint32_t fs_free_clusters; /* # free clusters. -1 if unknown */ + uint32_t fs_next_free; /* search next free after this cn */ +} fat_fsi_t; + +/* + * On-disk FSI. All values in little endian. Only FAT32 has this. + */ +typedef struct fat_od_fsi { + uint32_t fsi_leadsig; /* 0x41615252 */ + char fsi_reserved1[480]; + uint32_t fsi_strucsig; /* 0x61417272 */ + fat_fsi_t fsi_incore; /* free/nextfree */ + char fsi_reserved2[12]; + uint32_t fsi_trailsig; /* 0xaa550000 */ +} fat_od_fsi_t; + +#define FSI_LEADSIG LE_32(0x41615252) +#define FSI_STRUCSIG LE_32(0x61417272) +#define FSI_TRAILSIG LE_32(0xaa550000) /* same as MBB_MAGIC */ + +#define FSISIG_OK(fsi) ( \ + ((fat_od_fsi_t *)(fsi))->fsi_leadsig == FSI_LEADSIG && \ + ((fat_od_fsi_t *)(fsi))->fsi_strucsig == FSI_STRUCSIG && \ + ((fat_od_fsi_t *)(fsi))->fsi_trailsig == FSI_TRAILSIG) + +#define FSINFO_UNKNOWN ((uint32_t)(-1)) /* free/next not valid */ + +typedef enum { FAT12, FAT16, FAT32, FAT_UNKNOWN, FAT_QUESTIONABLE } fattype_t; + + +struct pcfs { + struct vfs *pcfs_vfs; /* vfs for this fs */ + int pcfs_flags; /* flags */ + int pcfs_ldrive; /* logical DOS drive number */ + fattype_t pcfs_fattype; + dev_t pcfs_xdev; /* actual device that is mounted */ + struct vnode *pcfs_devvp; /* and a vnode for it */ + int pcfs_secsize; /* sector size in bytes */ + int pcfs_spcl; /* sectors per cluster */ + int pcfs_spt; /* sectors per track */ + int pcfs_sdshift; /* shift to convert sector into */ + /* DEV_BSIZE "sectors"; assume */ + /* pcfs_secsize is 2**n times of */ + /* DEV_BSIZE */ + int pcfs_fatsec; /* number of sec per FAT */ + int pcfs_numfat; /* number of FAT copies */ + int pcfs_rdirsec; /* number of sec in root dir */ + daddr_t pcfs_dosstart; /* start blkno of DOS partition */ + daddr_t pcfs_fsistart; /* start blkno of FSI sector */ + daddr_t pcfs_fatstart; /* start blkno of first FAT */ + daddr_t pcfs_rdirstart; /* start blkno of root dir */ + daddr_t pcfs_datastart; /* start blkno of data area */ + int pcfs_clsize; /* cluster size in bytes */ + int pcfs_ncluster; /* number of clusters in fs */ + int pcfs_nrefs; /* number of active pcnodes */ + int pcfs_frefs; /* number of active file pcnodes */ + int pcfs_nxfrecls; /* next free cluster */ + uchar_t *pcfs_fatp; /* ptr to FAT data */ + uchar_t *pcfs_fat_changemap; /* map of changed fat data */ + int pcfs_fat_changemapsize; /* size of FAT changemap */ + time_t pcfs_fattime; /* time FAT becomes invalid */ + time_t pcfs_verifytime; /* time to reverify disk */ + kmutex_t pcfs_lock; /* per filesystem lock */ + kthread_id_t pcfs_owner; /* id of thread locking pcfs */ + int pcfs_count; /* # of pcfs locks for pcfs_owner */ + struct fat_fsinfo pcfs_fsinfo; /* in-core fsinfo */ + struct pcfs *pcfs_nxt; /* linked list of all mounts */ + int pcfs_fatjustread; /* Used to flag a freshly found FAT */ + struct vnode *pcfs_root; /* vnode for the root dir of the fs */ + int pcfs_secondswest; /* recording timezone for this fs */ + len_t pcfs_mediasize; + int pcfs_rootblksize; + int pcfs_mediadesc; /* media descriptor */ + pc_cluster32_t pcfs_lastclmark; + pc_cluster32_t pcfs_rootclnum; + timestruc_t pcfs_mounttime; /* timestamp for "/" */ +}; + +/* + * flags + */ +#define PCFS_FATMOD 0x01 /* FAT has been modified */ +#define PCFS_LOCKED 0x02 /* fs is locked */ +#define PCFS_WANTED 0x04 /* locked fs is wanted */ +#define PCFS_NOCHK 0x800 /* don't resync fat on error */ +#define PCFS_BOOTPART 0x1000 /* boot partition type */ +#define PCFS_HIDDEN 0x2000 /* show hidden files */ +#define PCFS_PCMCIA_NO_CIS 0x4000 /* PCMCIA psuedo floppy */ +#define PCFS_FOLDCASE 0x8000 /* fold filenames to lowercase */ +#define PCFS_FSINFO_OK 0x10000 /* valid FAT32 fsinfo sector */ +#define PCFS_IRRECOV 0x20000 /* FS was messed with during write */ +#define PCFS_NOCLAMPTIME 0x40000 /* expose full FAT timestamp range */ +#define PCFS_NOATIME 0x80000 /* disable atime updates */ + +#define IS_FAT12(PCFS) ((PCFS)->pcfs_fattype == FAT12) +#define IS_FAT16(PCFS) ((PCFS)->pcfs_fattype == FAT16) +#define IS_FAT32(PCFS) ((PCFS)->pcfs_fattype == FAT32) + +/* for compatibility */ +struct old_pcfs_args { + int secondswest; /* seconds west of Greenwich */ + int dsttime; /* type of dst correction */ +}; + +struct pcfs_args { + int secondswest; /* seconds west of Greenwich */ + int dsttime; /* type of dst correction */ + int flags; +}; + +/* + * pcfs mount options. + */ +#define MNTOPT_PCFS_HIDDEN "hidden" +#define MNTOPT_PCFS_NOHIDDEN "nohidden" +#define MNTOPT_PCFS_FOLDCASE "foldcase" +#define MNTOPT_PCFS_NOFOLDCASE "nofoldcase" +#define MNTOPT_PCFS_CLAMPTIME "clamptime" +#define MNTOPT_PCFS_NOCLAMPTIME "noclamptime" +#define MNTOPT_PCFS_TIMEZONE "timezone" +#define MNTOPT_PCFS_SECSIZE "secsize" + +/* + * Disk timeout value in sec. + * This is used to time out the in core FAT and to re-verify the disk. + * This should be less than the time it takes to change floppys + */ +#define PCFS_DISKTIMEOUT 2 + +#define PCFS_MAXOFFSET_T UINT32_MAX /* PCFS max file size */ + +#define VFSTOPCFS(VFSP) ((struct pcfs *)((VFSP)->vfs_data)) +#define PCFSTOVFS(FSP) ((FSP)->pcfs_vfs) + +/* + * special cluster numbers in FAT + */ +#define PCF_FREECLUSTER 0x00 /* cluster is available */ +#define PCF_ERRORCLUSTER 0x01 /* error occurred allocating cluster */ +#define PCF_12BCLUSTER 0xFF0 /* 12-bit version of reserved cluster */ +#define PCF_RESCLUSTER 0xFFF0 /* 16-bit version of reserved cluster */ +#define PCF_RESCLUSTER32 0xFFFFFF0 /* 32-bit version */ +#define PCF_BADCLUSTER 0xFFF7 /* bad cluster, do not use */ +#define PCF_BADCLUSTER32 0xFFFFFF7 /* 32-bit version */ +#define PCF_LASTCLUSTER 0xFFF8 /* >= means last cluster in file */ +#define PCF_LASTCLUSTER32 0xFFFFFF8 /* 32-bit version */ +#define PCF_LASTCLUSTERMARK 0xFFFF /* value used to mark last cluster */ +#define PCF_LASTCLUSTERMARK32 0xFFFFFFF /* 32-bit version */ +#define PCF_FIRSTCLUSTER 2 /* first valid cluster number */ + +/* + * file system constants + */ +#define PC_MAXFATSEC 256 /* maximum number of sectors in FAT */ + +/* + * file system parameter macros + */ + +#define pc_clear_fatchanges(PCFS) \ + bzero((PCFS)->pcfs_fat_changemap, (PCFS)->pcfs_fat_changemapsize) + +#define pc_blksize(PCFS, PCP, OFF) /* file system block size */ \ + (((PCTOV(PCP)->v_flag & VROOT) && !IS_FAT32(PCFS)) ? \ + ((OFF) >= \ + ((PCFS)->pcfs_rdirsec & \ + ~((PCFS)->pcfs_spcl - 1)) * ((PCFS)->pcfs_secsize)? \ + ((PCFS)->pcfs_rdirsec & \ + ((PCFS)->pcfs_spcl - 1)) * ((PCFS)->pcfs_secsize): \ + (PCFS)->pcfs_clsize): \ + (PCFS)->pcfs_clsize) + +#define pc_blkoff(PCFS, OFF) /* offset within block */ \ + ((int)((OFF) & ((PCFS)->pcfs_clsize - 1))) + +#define pc_lblkno(PCFS, OFF) /* logical block (cluster) no */ \ + ((daddr_t)((OFF) / (PCFS)->pcfs_clsize)) + +#define pc_dbtocl(PCFS, DB) /* disk blks to clusters */ \ + ((int)((DB) / (PCFS)->pcfs_spcl)) + +#define pc_cltodb(PCFS, CL) /* clusters to disk blks */ \ + ((daddr_t)((CL) * (PCFS)->pcfs_spcl)) + +#define pc_dbdaddr(PCFS, DB) /* sector to DEV_BSIZE "sector" addr */ \ + ((DB) << (PCFS)->pcfs_sdshift) + +#define pc_daddrdb(PCFS, DADDR) /* DEV_BSIZE "sector" addr to sector addr */ \ + ((DADDR) >> (PCFS)->pcfs_sdshift) + +#define pc_cldaddr(PCFS, CL) /* DEV_BSIZE "sector" addr for cluster */ \ + pc_dbdaddr(PCFS, ((daddr_t)((PCFS)->pcfs_datastart + \ + pc_cltodb(PCFS, (CL) - PCF_FIRSTCLUSTER)))) + +#define pc_daddrcl(PCFS, DADDR) /* cluster for disk address */ \ + ((int)(PCF_FIRSTCLUSTER + \ + pc_dbtocl(pc_daddrdb(PCFS, DADDR) - (PCFS)->pcfs_datastart))) + +/* + * Number of directory entries per sector / cluster + */ +#define pc_direntpersec(PCFS) \ + ((int)((PCFS)->pcfs_secsize / sizeof (struct pcdir))) + +#define pc_direntpercl(PCFS) \ + ((int)((PCFS)->pcfs_clsize / sizeof (struct pcdir))) + +/* + * out-of-range check for cluster numbers. + */ +#define pc_validcl(PCFS, CL) /* check that cluster no is legit */ \ + ((int)(CL) >= PCF_FIRSTCLUSTER && \ + (int)(CL) < (PCFS)->pcfs_ncluster + PCF_FIRSTCLUSTER) + +/* + * external routines. + */ +extern int pc_lockfs(struct pcfs *, int, int); /* lock fs and get fat */ +extern void pc_unlockfs(struct pcfs *); /* ulock the fs */ +extern int pc_getfat(struct pcfs *); /* get fat from disk */ +extern void pc_invalfat(struct pcfs *); /* invalidate incore fat */ +extern int pc_syncfat(struct pcfs *); /* sync fat to disk */ +extern int pc_freeclusters(struct pcfs *); /* num free clusters in fs */ +extern pc_cluster32_t pc_alloccluster(struct pcfs *, int); +extern void pc_setcluster(struct pcfs *, pc_cluster32_t, pc_cluster32_t); +extern void pc_mark_fat_updated(struct pcfs *fsp, pc_cluster32_t cn); +extern int pc_fat_is_changed(struct pcfs *fsp, pc_cluster32_t bn); + +/* + * debugging + */ +extern int pcfsdebuglevel; +#define PC_DPRINTF0(level, A) \ + if (pcfsdebuglevel >= level) \ + cmn_err(CE_CONT, (A)) +#define PC_DPRINTF1(level, A, B) \ + if (pcfsdebuglevel >= level) \ + cmn_err(CE_CONT, (A), (B)) +#define PC_DPRINTF2(level, A, B, C) \ + if (pcfsdebuglevel >= level) \ + cmn_err(CE_CONT, (A), (B), (C)) +#define PC_DPRINTF3(level, A, B, C, D) \ + if (pcfsdebuglevel >= level) \ + cmn_err(CE_CONT, (A), (B), (C), (D)) +#define PC_DPRINTF4(level, A, B, C, D, E) \ + if (pcfsdebuglevel >= level) \ + cmn_err(CE_CONT, (A), (B), (C), (D), (E)) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_PC_FS_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/pc_label.h b/illumos-x86_64/usr/include/sys/fs/pc_label.h new file mode 100644 index 00000000..1b25af82 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/pc_label.h @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_PC_LABEL_H +#define _SYS_FS_PC_LABEL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * PC master boot block & partition table defines. + */ + +#define PCB_BPSEC 11 /* (short) bytes per sector */ +#define PCB_SPC 13 /* (byte) sectors per cluster */ +#define PCB_RESSEC 14 /* (short) reserved sectors */ +#define PCB_NFAT 16 /* (byte) number of fats */ +#define PCB_NROOTENT 17 /* (short) number of root dir entries */ +#define PCB_NSEC 19 /* (short) number of sectors on disk */ +#define PCB_MEDIA 21 /* (byte) media descriptor */ +#define PCB_SPF 22 /* (short) sectors per fat */ +#define PCB_SPT 24 /* (short) sectors per track */ +#define PCB_NHEAD 26 /* (short) number of heads */ +#define PCB_HIDSEC 28 /* (short) number of hidden sectors */ + +#define PCFS_PART 0x1be /* partition table offs in blk 0 of unit */ +#define PCFS_NUMPART 4 /* Number of partitions in blk 0 of unit */ + +/* + * Offsets into the boot sector where the string 'FAT' is expected. + * First value is where the string is on 12 and 16 bit FATs, + * the second value is where it is on 32 bit FATs. + */ +#define PCFS_TYPESTRING_OFFSET16 0x36 +#define PCFS_TYPESTRING_OFFSET32 0x52 + +#define PCFS_BPB 0xb /* offset of the BPB in the boot block */ +#define PCFS_SIGN 0x1fe /* offset of the DOS signature */ +#define DOS_SYSFAT12 1 /* DOS FAT 12 system indicator */ +#define DOS_SYSFAT16 4 /* DOS FAT 16 system indicator */ +#define DOS_SYSHUGE 6 /* DOS FAT 16 system indicator > 32MB */ +#define DOS_FAT32 0xB /* FAT32 system indicator */ +#define DOS_FAT32_LBA 0xC /* FAT32 system indicator (LBA) */ +#define DOS_FAT16P_LBA 0xE /* FAT16 system indicator (Primary/LBA ) */ +#define DOS_FAT16_LBA 0xF /* FAT16 system indicator (Extended/LBA) */ +#define DOS_F12MAXS 20740 /* Max sector for 12 Bit FAT (DOS>=3.2) */ +#define DOS_F12MAXC 4086 /* Max cluster for 12 Bit FAT (DOS>=3.2) */ + +#define DOS_ID1 0xe9 /* JMP intrasegment */ +#define DOS_ID2a 0xeb /* JMP short */ +#define DOS_ID2b 0x90 +#define DOS_SIGN 0xaa55 /* DOS signature in boot and partition */ + +#define PC_FATBLOCK 1 /* starting block number of fat */ +/* + * Media descriptor byte. + * Found in the boot block and in the first byte of the FAT. + * Second and third byte in the FAT must be 0xFF. + * Note that all technical sources indicate that this means of + * identification is extremely unreliable. + */ +#define MD_FIXED 0xF8 /* fixed disk */ +#define SS8SPT 0xFE /* single sided 8 sectors per track */ +#define DS8SPT 0xFF /* double sided 8 sectors per track */ +#define SS9SPT 0xFC /* single sided 9 sectors per track */ +#define DS9SPT 0xFD /* double sided 9 sectors per track */ +#define DS18SPT 0xF0 /* double sided 18 sectors per track */ +#define DS9_15SPT 0xF9 /* double sided 9/15 sectors per track */ + +#define PC_SECSIZE 512 /* pc filesystem sector size */ + +/* + * conversions to/from little endian format + */ +#if defined(_LITTLE_ENDIAN) +/* e.g. i386 machines */ +#define ltohs(S) (*((ushort_t *)(&(S)))) +#define ltohi(I) (*((uint_t *)(&(I)))) +#define htols(S) (*((ushort_t *)(&(S)))) +#define htoli(I) (*((uint_t *)(&(I)))) + +#else +/* e.g. SPARC machines */ +#define getbyte(A, N) (((unsigned char *)(&(A)))[N]) +#define ltohs(S) ((getbyte(S, 1) << 8) | getbyte(S, 0)) +#define ltohi(I) ((getbyte(I, 3) << 24) | (getbyte(I, 2) << 16) | \ + (getbyte(I, 1) << 8) | getbyte(I, 0)) +#define htols(S) ((getbyte(S, 1) << 8) | getbyte(S, 0)) +#define htoli(I) ((getbyte(I, 3) << 24) | (getbyte(I, 2) << 16) | \ + (getbyte(I, 1) << 8) | getbyte(I, 0)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_PC_LABEL_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/pc_node.h b/illumos-x86_64/usr/include/sys/fs/pc_node.h new file mode 100644 index 00000000..5dd8439c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/pc_node.h @@ -0,0 +1,154 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_PC_NODE_H +#define _SYS_FS_PC_NODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#ifdef _KERNEL +#include +#endif + +/* + * This overlays the fid structure (see vfs.h) + * + * 10 bytes max. + */ +struct pc_fid { + ushort_t pcfid_len; + uint32_t pcfid_block; /* dblock containing directory entry */ + uint16_t pcfid_offset; /* offset within block of entry */ + uint16_t pcfid_ctime; /* creation time of entry (~= i_gen) */ +}; + +struct pcnode { + struct pcnode *pc_forw; /* active list ptrs, must be first */ + struct pcnode *pc_back; + int pc_flags; /* see below */ + struct vnode *pc_vn; /* vnode for pcnode */ + uint_t pc_size; /* size of file */ + pc_cluster32_t pc_scluster; /* starting cluster of file */ + daddr_t pc_eblkno; /* disk blkno for entry */ + int pc_eoffset; /* offset in disk block of entry */ + struct pcdir pc_entry; /* directory entry of file */ + pc_cluster32_t pc_lcluster; /* last cluster visited */ + daddr_t pc_lindex; /* index of last cluster visited */ +}; + +/* + * flags + */ +#define PC_MOD 0x01 /* file data has been modified */ +#define PC_CHG 0x02 /* node data has been changed */ +#define PC_INVAL 0x04 /* node is invalid */ +#define PC_EXTERNAL 0x08 /* vnode ref is held externally */ +#define PC_ACC 0x10 /* file data has been accessed */ +#define PC_RELEHOLD 0x80 /* node is being released */ + +#define PCTOV(PCP) ((PCP)->pc_vn) +#define VTOPC(VP) ((struct pcnode *)((VP)->v_data)) + +/* + * Make a unique integer for a file + */ +#define pc_makenodeid(BN, OFF, ATTR, SCLUSTER, ENTPS) \ + (ino_t)((ATTR) & PCA_DIR ? \ + (uint32_t)(-(SCLUSTER) - 1) : \ + ((BN) * (ENTPS)) + ((OFF) / sizeof (struct pcdir))) + +#define NPCHASH 1 + +#if NPCHASH == 1 +#define PCFHASH(FSP, BN, O) 0 +#define PCDHASH(FSP, SC) 0 +#else +#define PCFHASH(FSP, BN, O) (((unsigned)FSP + BN + O) % NPCHASH) +#define PCDHASH(FSP, SC) (((unsigned)FSP + SC) % NPCHASH) +#endif + +struct pchead { + struct pcnode *pch_forw; + struct pcnode *pch_back; +}; + +/* + * pcnode file and directory operations vectors + */ +extern struct vnodeops *pcfs_fvnodeops; +extern struct vnodeops *pcfs_dvnodeops; + +#ifdef _KERNEL +extern const struct fs_operation_def pcfs_fvnodeops_template[]; +extern const struct fs_operation_def pcfs_dvnodeops_template[]; +#endif + +extern struct pchead pcfhead[]; +extern struct pchead pcdhead[]; + +/* + * pcnode routines + */ +extern void pc_init(void); +extern struct pcnode *pc_getnode(struct pcfs *, daddr_t, int, struct pcdir *); +extern void pc_rele(struct pcnode *); +extern void pc_mark_mod(struct pcfs *, struct pcnode *); +extern void pc_mark_acc(struct pcfs *, struct pcnode *); +extern int pc_nodesync(struct pcnode *); +extern int pc_nodeupdate(struct pcnode *); +extern int pc_bmap(struct pcnode *, daddr_t, daddr_t *, uint_t *); + +extern int pc_balloc(struct pcnode *, daddr_t, int, daddr_t *); +extern int pc_bfree(struct pcnode *, pc_cluster32_t); +extern int pc_verify(struct pcfs *); +extern void pc_diskchanged(struct pcfs *); +extern void pc_mark_irrecov(struct pcfs *); + +extern int pc_dirlook(struct pcnode *, char *, struct pcnode **); +extern int pc_direnter(struct pcnode *, char *, struct vattr *, + struct pcnode **); +extern int pc_dirremove(struct pcnode *, char *, struct vnode *, enum vtype, + caller_context_t *); +extern int pc_rename(struct pcnode *, struct pcnode *, char *, char *, + caller_context_t *); +extern int pc_blkatoff(struct pcnode *, offset_t, struct buf **, + struct pcdir **); +extern int pc_truncate(struct pcnode *, uint_t); +extern int pc_fileclsize(struct pcfs *, pc_cluster32_t, pc_cluster32_t *); +extern int pcfs_putapage(struct vnode *, page_t *, u_offset_t *, size_t *, int, + struct cred *); +extern void pc_badfs(struct pcfs *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_PC_NODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/pxfs_ki.h b/illumos-x86_64/usr/include/sys/fs/pxfs_ki.h new file mode 100644 index 00000000..2904c446 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/pxfs_ki.h @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _PXFS_KI_H +#define _PXFS_KI_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Kernel interface to pxfs routines: definition of stubs. + */ + +/* + * kaio interface to pxfs + */ + +extern int clpxfs_aio_write(vnode_t *vp, struct aio_req *aio, cred_t *cred_p); +extern int clpxfs_aio_read(vnode_t *vp, struct aio_req *aio, cred_t *cred_p); + +#ifdef __cplusplus +} +#endif + +#endif /* _PXFS_KI_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/sdev_impl.h b/illumos-x86_64/usr/include/sys/fs/sdev_impl.h new file mode 100644 index 00000000..676193fc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/sdev_impl.h @@ -0,0 +1,642 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015, 2016 Joyent, Inc. All rights reserved. + * Copyright (c) 2014, 2017 by Delphix. All rights reserved. + */ + +#ifndef _SYS_SDEV_IMPL_H +#define _SYS_SDEV_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * sdev_nodes are the file-system specific part of the + * vnodes for the device filesystem. + * + * The device filesystem exports two node types: + * + * VDIR nodes to represent directories + * VCHR & VBLK nodes to represent devices + */ + +/* + * /dev mount arguments + */ +struct sdev_mountargs { + uint64_t sdev_attrdir; +}; + + +/* + * Nvpair names of profile information (list of device files available) of + * non-global /dev mounts. These strings must be unique among them. + */ +#define SDEV_NVNAME_MOUNTPT "prof_mountpt" +#define SDEV_NVNAME_INCLUDE "prof_include" +#define SDEV_NVNAME_EXCLUDE "prof_exclude" +#define SDEV_NVNAME_SYMLINK "prof_symlink" +#define SDEV_NVNAME_MAP "prof_map" + +/* + * supported devfsadm_cmd + */ +#define DEVFSADMD_RUN_ALL 1 + +/* + * devfsadm_error codes + */ +#define DEVFSADM_RUN_INVALID 1 +#define DEVFSADM_RUN_EPERM 2 +#define DEVFSADM_RUN_NOTSUP 3 + +/* + * devfsadm/devname door data structures + */ +typedef struct sdev_door_arg { + uint8_t devfsadm_cmd; /* what to do for devfsadm[d] */ +} sdev_door_arg_t; + +typedef struct sdev_door_res { + int32_t devfsadm_error; +} sdev_door_res_t; + +#ifdef _KERNEL + +struct sdev_dprof { + int has_glob; + nvlist_t *dev_name; + nvlist_t *dev_map; + nvlist_t *dev_symlink; + nvlist_t *dev_glob_incdir; + nvlist_t *dev_glob_excdir; +}; + +/* + * devname_handle_t + */ +struct devname_handle { + struct sdev_node *dh_data; /* the sdev_node */ + void *dh_args; +}; +typedef struct devname_handle devname_handle_t; + +/* + * Per-instance node data for the global zone instance + * Only one mount of /dev in the global zone + */ +typedef struct sdev_global_data { + struct devname_handle sdev_ghandle; + ulong_t sdev_dir_ggen; /* name space generation # */ +} sdev_global_data_t; + +/* + * Per-instance node data - profile data per non-global zone mount instance + */ +typedef struct sdev_local_data { + ulong_t sdev_dir_lgen; /* cached generation # of /dev dir */ + ulong_t sdev_devtree_lgen; /* cached generation # of devtree */ + struct sdev_node *sdev_lorigin; /* corresponding global sdev_node */ + struct sdev_dprof sdev_lprof; /* profile for multi-inst */ +} sdev_local_data_t; + +/* sdev_flags */ +typedef enum sdev_flags { + SDEV_BUILD = 0x0001, /* directory cache out-of-date */ + SDEV_GLOBAL = 0x0002, /* global /dev nodes */ + SDEV_PERSIST = 0x0004, /* backing store persisted node */ + SDEV_NO_NCACHE = 0x0008, /* do not include in neg. cache */ + SDEV_DYNAMIC = 0x0010, /* special-purpose vnode ops */ + /* (ex: pts) */ + SDEV_VTOR = 0x0020, /* validate sdev_nodes during search */ + SDEV_ATTR_INVALID = 0x0040, /* invalid node attributes, */ + /* need update */ + SDEV_SUBDIR = 0x0080, /* match all subdirs under here */ + SDEV_ZONED = 0x0100 /* zoned subdir */ +} sdev_flags_t; + +/* + * /dev filesystem sdev_node defines + */ +typedef struct sdev_node { + char *sdev_name; /* node name */ + size_t sdev_namelen; /* strlen(sdev_name) */ + char *sdev_path; /* absolute path */ + char *sdev_symlink; /* source for a symlink */ + struct vnode *sdev_vnode; /* vnode */ + + krwlock_t sdev_contents; /* rw lock for this data structure */ + struct sdev_node *sdev_dotdot; /* parent */ + + avl_tree_t sdev_entries; /* VDIR: contents as avl tree */ + avl_node_t sdev_avllink; /* avl node linkage */ + + struct vnode *sdev_attrvp; /* backing store vnode if persisted */ + struct vattr *sdev_attr; /* memory copy of the vattr */ + + ino64_t sdev_ino; /* inode */ + uint_t sdev_nlink; /* link count */ + int sdev_state; /* state of this node */ + sdev_flags_t sdev_flags; /* flags bit */ + + kmutex_t sdev_lookup_lock; /* node creation synch lock */ + kcondvar_t sdev_lookup_cv; /* node creation sync cv */ + int sdev_lookup_flags; /* node creation flags */ + + /* per-instance data, either global or non-global zone */ + union { + struct sdev_global_data sdev_globaldata; + struct sdev_local_data sdev_localdata; + } sdev_instance_data; + list_node_t sdev_plist; /* link on plugin list */ + void *sdev_private; +} sdev_node_t; + +#define sdev_ldata sdev_instance_data.sdev_localdata +#define sdev_gdata sdev_instance_data.sdev_globaldata + +#define sdev_handle sdev_gdata.sdev_ghandle +#define sdev_gdir_gen sdev_gdata.sdev_dir_ggen + +#define sdev_ldir_gen sdev_ldata.sdev_dir_lgen +#define sdev_devtree_gen sdev_ldata.sdev_devtree_lgen +#define sdev_origin sdev_ldata.sdev_lorigin +#define sdev_prof sdev_ldata.sdev_lprof + +/* + * Directory contents traversal + */ +#define SDEV_FIRST_ENTRY(ddv) avl_first(&(ddv)->sdev_entries) +#define SDEV_NEXT_ENTRY(ddv, dv) AVL_NEXT(&(ddv)->sdev_entries, (dv)) + +/* + * See the big theory statement in sdev_vnops.c for an explanation of these + * states. + */ +typedef enum { + SDEV_ZOMBIE = -1, + SDEV_INIT = 0, + SDEV_READY +} sdev_node_state_t; + +/* sdev_lookup_flags */ +#define SDEV_LOOKUP 0x0001 /* node creation in progress */ +#define SDEV_READDIR 0x0002 /* VDIR readdir in progress */ +#define SDEV_LGWAITING 0x0004 /* waiting for devfsadm completion */ + +/* convenient macros */ +#define SDEV_IS_GLOBAL(dv) \ + (dv->sdev_flags & SDEV_GLOBAL) +#define SDEV_IS_PERSIST(dv) \ + (dv->sdev_flags & SDEV_PERSIST) +#define SDEV_IS_DYNAMIC(dv) \ + (dv->sdev_flags & SDEV_DYNAMIC) +#define SDEV_IS_NO_NCACHE(dv) \ + (dv->sdev_flags & SDEV_NO_NCACHE) +#define SDEV_IS_LOOKUP(dv) \ + (dv->sdev_lookup_flags & SDEV_LOOKUP) +#define SDEV_IS_READDIR(dv) \ + (dv->sdev_lookup_flags & SDEV_READDIR) +#define SDEV_IS_LGWAITING(dv) \ + (dv->sdev_lookup_flags & SDEV_LGWAITING) + +#define SDEVTOV(n) ((struct vnode *)(n)->sdev_vnode) +#define VTOSDEV(vp) ((struct sdev_node *)(vp)->v_data) +#define VN_HELD(v) ((v)->v_count != 0) +#define SDEV_HELD(dv) (VN_HELD(SDEVTOV(dv))) +#define SDEV_HOLD(dv) VN_HOLD(SDEVTOV(dv)) +#define SDEV_RELE(dv) VN_RELE(SDEVTOV(dv)) +#define SDEV_SIMPLE_RELE(dv) { \ + struct vnode *vp = SDEVTOV(dv); \ + mutex_enter(&vp->v_lock); \ + VN_RELE_LOCKED(vp); \ + mutex_exit(&vp->v_lock); \ +} + +#define SDEV_ACL_FLAVOR(vp) (VFSTOSDEVFS(vp->v_vfsp)->sdev_acl_flavor) + +/* + * some defaults + */ +#define SDEV_ROOTINO ((ino_t)2) +#define SDEV_UID_DEFAULT (0) +#define SDEV_GID_DEFAULT (3) +#define SDEV_DIRMODE_DEFAULT (S_IFDIR |0755) +#define SDEV_DEVMODE_DEFAULT (0600) +#define SDEV_LNKMODE_DEFAULT (S_IFLNK | 0777) + +extern struct vattr sdev_vattr_dir; +extern struct vattr sdev_vattr_lnk; +extern struct vattr sdev_vattr_blk; +extern struct vattr sdev_vattr_chr; + +/* + * devname_lookup_func() + */ +extern int devname_lookup_func(struct sdev_node *, char *, struct vnode **, + struct cred *, int (*)(struct sdev_node *, char *, void **, struct cred *, + void *, char *), int); + +/* + * flags used by devname_lookup_func callbacks + */ +#define SDEV_VATTR 0x4 /* callback returning node vattr */ +#define SDEV_VLINK 0x8 /* callback returning /dev link */ + +/* + * devname_readdir_func() + */ +extern int devname_readdir_func(vnode_t *, uio_t *, cred_t *, int *, int); + +/* + * flags for devname_readdir_func + */ +#define SDEV_BROWSE 0x1 /* fetch all entries from backing store */ + +/* + * devname_setattr_func() + */ +extern int devname_setattr_func(struct vnode *, struct vattr *, int, + struct cred *, int (*)(struct sdev_node *, struct vattr *, int), int); +/* + * devname_inactive_func() + */ +extern void devname_inactive_func(struct vnode *, struct cred *, + void (*)(struct vnode *)); + +/* + * /dev file system instance defines + */ +/* + * /dev version of vfs_data + */ +struct sdev_data { + struct sdev_data *sdev_prev; + struct sdev_data *sdev_next; + struct sdev_node *sdev_root; + struct vfs *sdev_vfsp; + struct sdev_mountargs *sdev_mountargs; + ulong_t sdev_acl_flavor; +}; + +#define VFSTOSDEVFS(vfsp) ((struct sdev_data *)((vfsp)->vfs_data)) + +/* + * sdev_fid overlays the fid structure (for VFS_VGET) + */ +struct sdev_fid { + uint16_t sdevfid_len; + ino32_t sdevfid_ino; + int32_t sdevfid_gen; +}; + +/* + * devfsadm and devname communication defines + */ +typedef enum { + DEVNAME_DEVFSADM_STOPPED = 0, /* devfsadm has never run */ + DEVNAME_DEVFSADM_RUNNING, /* devfsadm is running */ + DEVNAME_DEVFSADM_RUN /* devfsadm ran once */ +} devname_devfsadm_state_t; + +extern volatile uint_t devfsadm_state; /* atomic mask for devfsadm status */ + +#define DEVNAME_DEVFSADM_SET_RUNNING(devfsadm_state) \ + (devfsadm_state = DEVNAME_DEVFSADM_RUNNING) +#define DEVNAME_DEVFSADM_SET_STOP(devfsadm_state) \ + (devfsadm_state = DEVNAME_DEVFSADM_STOPPED) +#define DEVNAME_DEVFSADM_SET_RUN(devfsadm_state) \ + (devfsadm_state = DEVNAME_DEVFSADM_RUN) +#define DEVNAME_DEVFSADM_IS_RUNNING(devfsadm_state) \ + (devfsadm_state == DEVNAME_DEVFSADM_RUNNING) +#define DEVNAME_DEVFSADM_HAS_RUN(devfsadm_state) \ + (devfsadm_state == DEVNAME_DEVFSADM_RUN) + +#define SDEV_BLOCK_OTHERS(dv, cmd) { \ + ASSERT(MUTEX_HELD(&dv->sdev_lookup_lock)); \ + dv->sdev_lookup_flags |= cmd; \ +} +extern void sdev_unblock_others(struct sdev_node *, uint_t); +#define SDEV_UNBLOCK_OTHERS(dv, cmd) { \ + sdev_unblock_others(dv, cmd); \ +} + +#define SDEV_CLEAR_LOOKUP_FLAGS(dv, cmd) { \ + dv->sdev_lookup_flags &= ~cmd; \ +} + +extern int sdev_wait4lookup(struct sdev_node *, int); +extern int devname_filename_register(char *); +extern int devname_nsmaps_register(char *, size_t); +extern void sdev_devfsadm_lockinit(void); +extern void sdev_devfsadm_lockdestroy(void); +extern void devname_add_devfsadm_node(char *); +extern void sdev_devfsadmd_thread(struct sdev_node *, struct sdev_node *, + struct cred *); +extern int devname_profile_update(char *, size_t); +extern struct sdev_data *sdev_find_mntinfo(char *); +void sdev_mntinfo_rele(struct sdev_data *); +typedef void (*sdev_mnt_walk_f)(struct sdev_node *, void *); +void sdev_mnt_walk(sdev_mnt_walk_f, void *); +extern struct vnodeops *devpts_getvnodeops(void); +extern struct vnodeops *devvt_getvnodeops(void); +extern void sdev_plugin_nodeready(struct sdev_node *); +extern int sdev_plugin_init(void); +extern int sdev_plugin_fini(void); + +/* + * boot states - warning, the ordering here is significant + * + * the difference between "system available" and "boot complete" + * is a debounce timeout to catch some daemon issuing a readdir + * triggering a nuisance implict reconfig on each boot. + */ +#define SDEV_BOOT_STATE_INITIAL 0 +#define SDEV_BOOT_STATE_RECONFIG 1 /* reconfig */ +#define SDEV_BOOT_STATE_SYSAVAIL 2 /* system available */ +#define SDEV_BOOT_STATE_COMPLETE 3 /* boot complete */ + +/* + * Negative cache list and list element + * The mutex protects the flags against multiple accesses and + * must only be acquired when already holding the r/w lock. + */ +typedef struct sdev_nc_list { + list_t ncl_list; /* the list itself */ + kmutex_t ncl_mutex; /* protects ncl_flags */ + krwlock_t ncl_lock; /* protects ncl_list */ + int ncl_flags; + int ncl_nentries; +} sdev_nc_list_t; + +typedef struct sdev_nc_node { + char *ncn_name; /* name of the node */ + int ncn_flags; /* state information */ + int ncn_expirecnt; /* remove once expired */ + list_node_t ncn_link; /* link to next in list */ +} sdev_nc_node_t; + +/* ncl_flags */ +#define NCL_LIST_DIRTY 0x01 /* needs to be flushed */ +#define NCL_LIST_WRITING 0x02 /* write in progress */ +#define NCL_LIST_WENABLE 0x04 /* write-enabled post boot */ + +/* ncn_flags */ +#define NCN_ACTIVE 0x01 /* a lookup has occurred */ +#define NCN_SRC_STORE 0x02 /* src: persistent store */ +#define NCN_SRC_CURRENT 0x04 /* src: current boot */ + +/* sdev_lookup_failed flags */ +#define SLF_NO_NCACHE 0x01 /* node should not be added to ncache */ +#define SLF_REBUILT 0x02 /* reconfig performed during lookup attempt */ + +/* + * The nvlist name and nvpair identifiers in the + * /etc/devices/devname_cache nvlist format + */ +#define DP_DEVNAME_ID "devname" +#define DP_DEVNAME_NCACHE_ID "ncache" +#define DP_DEVNAME_NC_EXPIRECNT_ID "expire-counts" + +/* devname-cache list element */ +typedef struct nvp_devname { + char **nvp_paths; + int *nvp_expirecnts; + int nvp_npaths; + list_node_t nvp_link; +} nvp_devname_t; + +/* + * name service globals and prototypes + */ + +/* + * vnodeops and vfsops helpers + */ + +typedef enum { + SDEV_CACHE_ADD = 0, + SDEV_CACHE_DELETE +} sdev_cache_ops_t; + +extern struct sdev_node *sdev_cache_lookup(struct sdev_node *, char *); +extern void sdev_cache_update(struct sdev_node *, struct sdev_node **, char *, + sdev_cache_ops_t); +extern void sdev_node_cache_init(void); +extern void sdev_node_cache_fini(void); +extern struct sdev_node *sdev_mkroot(struct vfs *, dev_t, struct vnode *, + struct vnode *, struct cred *); +extern void sdev_filldir_dynamic(struct sdev_node *); +extern int sdev_mknode(struct sdev_node *, char *, struct sdev_node **, + struct vattr *, struct vnode *, void *, struct cred *, sdev_node_state_t); +extern int sdev_getlink(struct vnode *linkvp, char **link); + +extern int sdev_nodeinit(struct sdev_node *, char *, struct sdev_node **, + vattr_t *); +extern int sdev_nodeready(struct sdev_node *, vattr_t *, vnode_t *, void *, + cred_t *); +extern int sdev_shadow_node(struct sdev_node *, struct cred *); +extern void sdev_nodedestroy(struct sdev_node *, uint_t); +extern void sdev_update_timestamps(struct vnode *, cred_t *, uint_t); +extern void sdev_vattr_merge(struct sdev_node *, struct vattr *); +extern void sdev_devstate_change(void); +extern int sdev_lookup_filter(sdev_node_t *, char *); +extern void sdev_lookup_failed(sdev_node_t *, char *, int); +extern int sdev_unlocked_access(void *, int, struct cred *); + +#define SDEV_ENFORCE 0x1 +extern void sdev_stale(struct sdev_node *); +extern int sdev_cleandir(struct sdev_node *, char *, uint_t); +extern int sdev_rnmnode(struct sdev_node *, struct sdev_node *, + struct sdev_node *, struct sdev_node **, char *, struct cred *); +extern size_t add_dir_entry(dirent64_t *, char *, size_t, ino_t, offset_t); +extern struct vattr *sdev_getdefault_attr(enum vtype type); +extern int sdev_to_vp(struct sdev_node *, struct vnode **); +extern ino_t sdev_mkino(struct sdev_node *); +extern int devname_backstore_lookup(struct sdev_node *, char *, + struct vnode **); +extern int sdev_is_devfs_node(char *); +extern int sdev_copyin_mountargs(struct mounta *, struct sdev_mountargs *); +extern int sdev_reserve_subdirs(struct sdev_node *); +extern int prof_lookup(); +extern void prof_filldir(struct sdev_node *); +extern int prof_name_matched(char *, struct sdev_node *); +extern int devpts_validate(struct sdev_node *dv); +extern int devnet_validate(struct sdev_node *dv); +extern int devipnet_validate(struct sdev_node *dv); +extern int devvt_validate(struct sdev_node *dv); +extern int devzvol_validate(struct sdev_node *dv); +extern void *sdev_get_vtor(struct sdev_node *dv); + +/* + * devinfo helpers + */ +extern int sdev_modctl_readdir(const char *, char ***, int *, int *, int); +extern void sdev_modctl_readdir_free(char **, int, int); +extern int sdev_modctl_devexists(const char *); + +/* + * ncache handlers + */ + +extern void sdev_ncache_init(void); +extern void sdev_ncache_setup(void); +extern void sdev_ncache_teardown(void); +extern void sdev_nc_addname(sdev_nc_list_t *, sdev_node_t *, char *, int); +extern void sdev_nc_node_exists(sdev_node_t *); +extern void sdev_nc_path_exists(sdev_nc_list_t *, char *); +extern void sdev_modctl_dump_files(void); + +/* + * plugin and legacy vtab stuff + */ +/* directory dependent vop table */ +typedef struct sdev_vop_table { + char *vt_name; /* subdirectory name */ + const fs_operation_def_t *vt_service; /* vnodeops table */ + struct vnodeops **vt_global_vops; /* global container for vop */ + int (*vt_vtor)(struct sdev_node *); /* validate sdev_node */ + int vt_flags; +} sdev_vop_table_t; + +extern struct sdev_vop_table vtab[]; +extern struct vnodeops *sdev_get_vop(struct sdev_node *); +extern void sdev_set_no_negcache(struct sdev_node *); +extern void *sdev_get_vtor(struct sdev_node *dv); + +/* + * globals + */ +extern kmutex_t sdev_lock; +extern int devtype; +extern kmem_cache_t *sdev_node_cache; +extern struct vnodeops *sdev_vnodeops; +extern struct vnodeops *devpts_vnodeops; +extern struct vnodeops *devnet_vnodeops; +extern struct vnodeops *devipnet_vnodeops; +extern struct vnodeops *devvt_vnodeops; +extern struct sdev_data *sdev_origins; /* mount info for global /dev instance */ +extern struct vnodeops *devzvol_vnodeops; +extern int sdev_vnodeops_tbl_size; + +extern const fs_operation_def_t sdev_vnodeops_tbl[]; +extern const fs_operation_def_t devpts_vnodeops_tbl[]; +extern const fs_operation_def_t devnet_vnodeops_tbl[]; +extern const fs_operation_def_t devipnet_vnodeops_tbl[]; +extern const fs_operation_def_t devvt_vnodeops_tbl[]; +extern const fs_operation_def_t devsys_vnodeops_tbl[]; +extern const fs_operation_def_t devpseudo_vnodeops_tbl[]; +extern const fs_operation_def_t devzvol_vnodeops_tbl[]; + +extern sdev_nc_list_t *sdev_ncache; +extern int sdev_reconfig_boot; +extern int sdev_boot_state; +extern int sdev_reconfig_verbose; +extern int sdev_reconfig_disable; +extern int sdev_nc_disable; +extern int sdev_nc_disable_reset; +extern int sdev_nc_verbose; + +extern taskq_t *sdev_taskq; + +/* + * misc. defines + */ +#ifdef DEBUG +extern int sdev_debug; +#define SDEV_DEBUG 0x01 /* error messages to console/log */ +#define SDEV_DEBUG_VOPS 0x02 /* vnode ops errors */ +#define SDEV_DEBUG_DLF 0x04 /* trace devname_lookup_func */ +#define SDEV_DEBUG_DRF 0x08 /* trace devname_readdir_func */ +#define SDEV_DEBUG_NCACHE 0x10 /* negative cache tracing */ +#define SDEV_DEBUG_DEVFSADMD 0x20 /* comm. of devnamefs & devfsadm */ +#define SDEV_DEBUG_PTS 0x40 /* /dev/pts tracing */ +#define SDEV_DEBUG_RECONFIG 0x80 /* events triggering reconfig */ +#define SDEV_DEBUG_SDEV_NODE 0x100 /* trace sdev_node activities */ +#define SDEV_DEBUG_PROFILE 0x200 /* trace sdev_profile */ +#define SDEV_DEBUG_MODCTL 0x400 /* trace modctl activity */ +#define SDEV_DEBUG_FLK 0x800 /* trace failed lookups */ +#define SDEV_DEBUG_NET 0x1000 /* /dev/net tracing */ +#define SDEV_DEBUG_ZVOL 0x2000 /* /dev/zvol/tracing */ + +#define sdcmn_err(args) if (sdev_debug & SDEV_DEBUG) printf args +#define sdcmn_err2(args) if (sdev_debug & SDEV_DEBUG_VOPS) printf args +#define sdcmn_err3(args) if (sdev_debug & SDEV_DEBUG_DLF) printf args +#define sdcmn_err4(args) if (sdev_debug & SDEV_DEBUG_DRF) printf args +#define sdcmn_err5(args) if (sdev_debug & SDEV_DEBUG_NCACHE) printf args +#define sdcmn_err6(args) if (sdev_debug & SDEV_DEBUG_DEVFSADMD) printf args +#define sdcmn_err7(args) if (sdev_debug & SDEV_DEBUG_PTS) printf args +#define sdcmn_err8(args) if (sdev_debug & SDEV_DEBUG_RECONFIG) printf args +#define sdcmn_err9(args) if (sdev_debug & SDEV_DEBUG_SDEV_NODE) printf args +#define sdcmn_err10(args) if (sdev_debug & SDEV_DEBUG_PROFILE) printf args +#define sdcmn_err11(args) if (sdev_debug & SDEV_DEBUG_MODCTL) printf args +#define sdcmn_err12(args) if (sdev_debug & SDEV_DEBUG_NET) printf args +#define sdcmn_err13(args) if (sdev_debug & SDEV_DEBUG_ZVOL) printf args +#define impossible(args) printf args +#else +#define sdcmn_err(args) ((void)0) +#define sdcmn_err2(args) ((void)0) +#define sdcmn_err3(args) ((void)0) +#define sdcmn_err4(args) ((void)0) +#define sdcmn_err5(args) ((void)0) +#define sdcmn_err6(args) ((void)0) +#define sdcmn_err7(args) ((void)0) +#define sdcmn_err8(args) ((void)0) +#define sdcmn_err9(args) ((void)0) +#define sdcmn_err10(args) ((void)0) +#define sdcmn_err11(args) ((void)0) +#define sdcmn_err12(args) ((void)0) +#define sdcmn_err13(args) ((void)0) +#define impossible(args) ((void)0) +#endif + +#ifdef DEBUG +#define SD_TRACE_FAILED_LOOKUP(ddv, nm, retried) \ + if ((sdev_debug & SDEV_DEBUG_FLK) || \ + ((retried) && (sdev_debug & SDEV_DEBUG_RECONFIG))) { \ + printf("lookup of %s/%s by %s failed, line %d\n", \ + (ddv)->sdev_name, (nm), curproc->p_user.u_comm, \ + __LINE__); \ + } +#else +#define SD_TRACE_FAILED_LOOKUP(ddv, nm, retried) ((void)0) +#endif + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SDEV_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/sdev_plugin.h b/illumos-x86_64/usr/include/sys/fs/sdev_plugin.h new file mode 100644 index 00000000..f4ed813c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/sdev_plugin.h @@ -0,0 +1,106 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2018, Joyent, Inc. + */ + +#ifndef _SYS_SDEV_PLUGIN_H +#define _SYS_SDEV_PLUGIN_H + +/* + * Kernel sdev plugin interface + */ + +#ifdef _KERNEL + +#include +#include +#include + +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +typedef uintptr_t sdev_plugin_hdl_t; +typedef uintptr_t sdev_ctx_t; + +/* + * Valid return values for sdev_plugin_validate_t. + */ +typedef enum sdev_plugin_validate { + SDEV_VTOR_INVALID = -1, + SDEV_VTOR_SKIP = 0, + SDEV_VTOR_VALID = 1, + SDEV_VTOR_STALE = 2 +} sdev_plugin_validate_t; + +/* + * Valid flags + */ +typedef enum sdev_plugin_flags { + SDEV_PLUGIN_NO_NCACHE = 0x1, + SDEV_PLUGIN_SUBDIR = 0x2 +} sdev_plugin_flags_t; + +#define SDEV_PLUGIN_FLAGS_MASK 0x3 + +/* + * Functions a module must implement + */ +typedef sdev_plugin_validate_t (*sp_valid_f)(sdev_ctx_t); +typedef int (*sp_filldir_f)(sdev_ctx_t); +typedef void (*sp_inactive_f)(sdev_ctx_t); + +#define SDEV_PLUGIN_VERSION 1 + +typedef struct sdev_plugin_ops { + int spo_version; + sdev_plugin_flags_t spo_flags; + sp_valid_f spo_validate; + sp_filldir_f spo_filldir; + sp_inactive_f spo_inactive; +} sdev_plugin_ops_t; + +extern sdev_plugin_hdl_t sdev_plugin_register(const char *, sdev_plugin_ops_t *, + int *); +extern int sdev_plugin_unregister(sdev_plugin_hdl_t); + +typedef enum sdev_ctx_flags { + SDEV_CTX_GLOBAL = 0x2 /* node belongs to the GZ */ +} sdev_ctx_flags_t; + +/* + * Context helper functions + */ +extern sdev_ctx_flags_t sdev_ctx_flags(sdev_ctx_t); +extern const char *sdev_ctx_name(sdev_ctx_t); +extern const char *sdev_ctx_path(sdev_ctx_t); +extern int sdev_ctx_minor(sdev_ctx_t, minor_t *); +extern enum vtype sdev_ctx_vtype(sdev_ctx_t); + +/* + * Callbacks to manipulate nodes + */ +extern int sdev_plugin_mkdir(sdev_ctx_t, char *); +extern int sdev_plugin_mknod(sdev_ctx_t, char *, mode_t, dev_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SDEV_PLUGIN_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/snode.h b/illumos-x86_64/usr/include/sys/fs/snode.h new file mode 100644 index 00000000..04397ebe --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/snode.h @@ -0,0 +1,236 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_SNODE_H +#define _SYS_FS_SNODE_H + +#include +#include +#include +#include + +/* + * The snode represents a special file in any filesystem. There is + * one snode for each active special file. Filesystems that support + * special files use specvp(vp, dev, type, cr) to convert a normal + * vnode to a special vnode in the ops lookup() and create(). + * + * To handle having multiple snodes that represent the same + * underlying device vnode without cache aliasing problems, + * the s_commonvp is used to point to the "common" vnode used for + * caching data. If an snode is created internally by the kernel, + * then the s_realvp field is NULL and s_commonvp points to s_vnode. + * The other snodes which are created as a result of a lookup of a + * device in a file system have s_realvp pointing to the vp which + * represents the device in the file system while the s_commonvp points + * into the "common" vnode for the device in another snode. + */ + +/* + * Include SUNDDI type definitions so that the s_dip tag doesn't urk. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct snode { + /* These fields are protected by stable_lock */ + struct snode *s_next; /* must be first */ + struct vnode *s_vnode; /* vnode associated with this snode */ + /* + * These fields are initialized once. + */ + struct vnode *s_realvp; /* vnode for the fs entry (if any) */ + struct vnode *s_commonvp; /* common device vnode */ + dev_t s_dev; /* device the snode represents */ + dev_info_t *s_dip; /* dev_info (common snode only) */ + /* + * Doesn't always need to be updated atomically because it is a hint. + * No lock required. + */ + u_offset_t s_nextr; /* next byte read offset (read-ahead) */ + + /* These fields are protected by spec_syncbusy */ + struct snode *s_list; /* used for syncing */ + /* These fields are protected by s_lock */ + struct devplcy *s_plcy; /* device node open policy (cs only) */ + u_offset_t s_size; /* block device size in bytes */ + uint_t s_flag; /* flags, see below */ + dev_t s_fsid; /* file system identifier */ + time_t s_atime; /* time of last access */ + time_t s_mtime; /* time of last modification */ + time_t s_ctime; /* time of last attributes change */ + int s_count; /* count of opened references */ + long s_mapcnt; /* count of mappings of pages */ + /* The locks themselves */ + kmutex_t s_lock; /* protects snode fields */ + kcondvar_t s_cv; /* synchronize open/closes */ +}; + +/* flags */ +#define SUPD 0x01 /* update device access time */ +#define SACC 0x02 /* update device modification time */ +#define SCHG 0x04 /* update device change time */ +#define SPRIV 0x08 /* file open for private access */ +#define SLOFFSET 0x10 /* device takes 64-bit uio offsets */ +#define SLOCKED 0x20 /* use to serialize open/closes */ +#define SWANT 0x40 /* some process waiting on lock */ +#define SANYOFFSET 0x80 /* device takes any uio offset */ +#define SCLONE 0x100 /* represents a cloned device */ +#define SNEEDCLOSE 0x200 /* needs driver close call */ +#define SDIPSET 0x400 /* the vnode has an association with */ + /* the driver, even though it may */ + /* not currently have an association */ + /* with a specific hardware instance */ + /* if s_dip is NULL */ +#define SSIZEVALID 0x800 /* s_size field is valid */ +#define SMUXED 0x1000 /* this snode is a stream that has */ + /* been multiplexed */ +#define SSELFCLONE 0x2000 /* represents a self cloning device */ +#define SNOFLUSH 0x4000 /* do not flush device on fsync */ +#define SCLOSING 0x8000 /* in last close(9E) */ +#define SFENCED 0x10000 /* snode fenced off for I/O retire */ + +#ifdef _KERNEL +/* + * Convert between vnode and snode + */ +#define VTOS(vp) ((struct snode *)((vp)->v_data)) +#define VTOCS(vp) (VTOS(VTOS(vp)->s_commonvp)) +#define STOV(sp) ((sp)->s_vnode) + +extern int spec_debug; + +#define SPEC_FENCE_DEBUG 0x0001 /* emit fence related debug messages */ + +#define FENDBG(args) if (spec_debug & SPEC_FENCE_DEBUG) cmn_err args + + +/* + * Forward declarations + */ +struct vfssw; +struct cred; + +extern struct vfs spec_vfs; +extern struct vfsops spec_vfsops; +extern struct kmem_cache *snode_cache; + +/* + * specfs functions + */ +offset_t spec_maxoffset(struct vnode *); +struct vnodeops *spec_getvnodeops(void); +struct vnode *specvp(struct vnode *, dev_t, vtype_t, struct cred *); +struct vnode *makespecvp(dev_t, vtype_t); +struct vnode *other_specvp(struct vnode *); +struct vnode *common_specvp(struct vnode *); +struct vnode *specfind(dev_t, vtype_t); +struct vnode *commonvp(dev_t, vtype_t); +struct vnode *makectty(vnode_t *); +void sdelete(struct snode *); +void smark(struct snode *, int); +int specinit(int, char *); +int device_close(struct vnode *, int, struct cred *); +int spec_putpage(struct vnode *, offset_t, size_t, int, struct cred *, + caller_context_t *); +int spec_segmap(dev_t, off_t, struct as *, caddr_t *, off_t, + uint_t, uint_t, uint_t, cred_t *); +struct vnode *specvp_devfs(struct vnode *, dev_t, vtype_t, + struct cred *, dev_info_t *); +void spec_assoc_vp_with_devi(struct vnode *, dev_info_t *); +dev_info_t *spec_hold_devi_by_vp(struct vnode *); +int spec_sync(struct vfs *, short, struct cred *); +void spec_snode_walk(int (*callback)(struct snode *, void *), void *); +int spec_devi_open_count(struct snode *, dev_info_t **); +int spec_is_clone(struct vnode *); +int spec_is_selfclone(struct vnode *); +int spec_fence_snode(dev_info_t *dip, struct vnode *vp); +int spec_unfence_snode(dev_info_t *dip); +void spec_size_invalidate(dev_t, vtype_t); + + +/* + * UNKNOWN_SIZE: If driver does not support the [Ss]ize or [Nn]blocks property + * then the size is assumed to be "infinite". Note that this "infinite" value + * may need to be converted to a smaller "infinite" value to avoid EOVERFLOW at + * field width conversion locations like the stat(2) and NFS code running + * against a special file. Special file code outside specfs may check the + * type of the vnode (VCHR|VBLK) and use MAXOFFSET_T directly to detect + * UNKNOWN_SIZE. + */ +#define UNKNOWN_SIZE MAXOFFSET_T + +/* + * SPEC_MAXOFFSET_T: Solaris does not fully support 64-bit offsets for D_64BIT + * (SLOFFSET) block drivers on a 32-bit kernels: daddr_t is still a signed + * 32-bit quantity - which limits the byte offset to 1TB. This issue goes + * beyond a driver needing to convert from daddr_t to diskaddr_t if it sets + * D_64BIT. Many of the DDI interfaces which take daddr_t arguments have no + * 64-bit counterpart (bioclone, blkflush, bread, bread_common, breada, getblk, + * getblk_common). SPEC_MAXOFFSET_T is used by 32-bit kernel code to enforce + * this restriction. + */ +#ifdef _ILP32 +#ifdef _LONGLONG_TYPE +#define SPEC_MAXOFFSET_T ((1LL << ((NBBY * sizeof (daddr32_t)) + \ + DEV_BSHIFT - 1)) - 1) +#else /* !defined(_LONGLONG_TYPE) */ +#define SPEC_MAXOFFSET_T MAXOFF_T +#endif /* _LONGLONG_TYPE */ +#endif /* _ILP32 */ + +/* + * Snode lookup stuff. + * These routines maintain a table of snodes hashed by dev so + * that the snode for an dev can be found if it already exists. + * NOTE: STABLESIZE must be a power of 2 for STABLEHASH to work! + */ + +#define STABLESIZE 256 +#define STABLEHASH(dev) ((getmajor(dev) + getminor(dev)) & (STABLESIZE - 1)) +extern struct snode *stable[]; +extern kmutex_t stable_lock; +extern kmutex_t spec_syncbusy; + +/* + * Variables used by during asynchronous VOP_PUTPAGE operations. + */ +extern struct async_reqs *spec_async_reqs; /* async request list */ +extern kmutex_t spec_async_lock; /* lock to protect async list */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_SNODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/swapnode.h b/illumos-x86_64/usr/include/sys/fs/swapnode.h new file mode 100644 index 00000000..0d7a98a3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/swapnode.h @@ -0,0 +1,70 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_FS_SWAPNODE_H +#define _SYS_FS_SWAPNODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * pointer to swapfs global data structures + */ +extern pgcnt_t swapfs_minfree; /* amount of availrmem (in pages) */ + /* that is unavailable to swapfs */ +extern pgcnt_t swapfs_desfree; + +extern pgcnt_t swapfs_reserve; /* amount of availrmem (in pages) */ + /* that is unavailable for swap */ + /* reservation to non-priv processes */ + +extern struct vnodeops *swap_vnodeops; +extern struct vnode *swapfs_getvp(ulong_t); + +#ifdef SWAPFS_DEBUG +extern int swapfs_debug; +#define SWAPFS_PRINT(X, S, Y1, Y2, Y3, Y4, Y5) \ + if (swapfs_debug & (X)) \ + printf(S, Y1, Y2, Y3, Y4, Y5); +#define SWAP_SUBR 0x01 +#define SWAP_VOPS 0x02 +#define SWAP_VFSOPS 0x04 +#define SWAP_PGC 0x08 +#define SWAP_PUTP 0x10 +#else /* SWAPFS_DEBUG */ +#define SWAPFS_PRINT(X, S, Y1, Y2, Y3, Y4, Y5) +#endif /* SWAPFS_DEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_SWAPNODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/tmp.h b/illumos-x86_64/usr/include/sys/fs/tmp.h new file mode 100644 index 00000000..fb07de65 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/tmp.h @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. + * All rights reserved. Use is subject to license terms. + */ +/* + * Copyright 2015 Joyent, Inc. + */ + +#ifndef _SYS_FS_TMP_H +#define _SYS_FS_TMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * tmpfs per-mount data structure. + * + * All fields are protected by tm_contents. + * File renames on a particular file system are protected tm_renamelck. + */ +struct tmount { + struct vfs *tm_vfsp; /* filesystem's vfs struct */ + struct tmpnode *tm_rootnode; /* root tmpnode */ + char *tm_mntpath; /* name of tmpfs mount point */ + ulong_t tm_anonmax; /* file system max anon reservation */ + pgcnt_t tm_anonmem; /* pages of reserved anon memory */ + dev_t tm_dev; /* unique dev # of mounted `device' */ + uint_t tm_gen; /* pseudo generation number for files */ + kmutex_t tm_contents; /* lock for tmount structure */ + kmutex_t tm_renamelck; /* rename lock for this mount */ +}; + +/* + * File system independent to tmpfs conversion macros + */ +#define VFSTOTM(vfsp) ((struct tmount *)(vfsp)->vfs_data) +#define VTOTM(vp) ((struct tmount *)(vp)->v_vfsp->vfs_data) +#define VTOTN(vp) ((struct tmpnode *)(vp)->v_data) +#define TNTOV(tp) ((tp)->tn_vnode) +#define tmpnode_hold(tp) VN_HOLD(TNTOV(tp)) +#define tmpnode_rele(tp) VN_RELE(TNTOV(tp)) + +/* + * enums + */ +enum de_op { DE_CREATE, DE_MKDIR, DE_LINK, DE_RENAME }; /* direnter ops */ +enum dr_op { DR_REMOVE, DR_RMDIR, DR_RENAME }; /* dirremove ops */ + +/* + * tmpfs_minfree is the amount (in pages) of anonymous memory that tmpfs + * leaves free for the rest of the system. E.g. in a system with 32MB of + * configured swap space, if 16MB were reserved (leaving 16MB free), + * tmpfs could allocate up to 16MB - tmpfs_minfree. The default value + * for tmpfs_minfree is btopr(TMPMINFREE) but it can cautiously patched + * to a different number of pages. + * NB: If tmpfs allocates too much swap space, other processes will be + * unable to execute. + */ +#define TMPMINFREE 2 * 1024 * 1024 /* 2 Megabytes */ + +extern size_t tmpfs_minfree; /* Anonymous memory in pages */ + +/* + * tmpfs can allocate only a certain percentage of kernel memory, + * which is used for tmpnodes, directories, file names, etc. + * This is statically set as TMPMAXFRACKMEM of physical memory. + * The actual number of allocatable bytes can be patched in tmpfs_maxkmem. + */ +#define TMPMAXFRACKMEM 25 /* 1/25 of physical memory */ + +extern size_t tmp_kmemspace; +extern size_t tmpfs_maxkmem; /* Allocatable kernel memory in bytes */ + +extern void tmpnode_init(struct tmount *, struct tmpnode *, + struct vattr *, struct cred *); +extern int tmpnode_trunc(struct tmount *, struct tmpnode *, ulong_t); +extern void tmpnode_growmap(struct tmpnode *, ulong_t); +extern int tdirlookup(struct tmpnode *, char *, struct tmpnode **, + struct cred *); +extern int tdirdelete(struct tmpnode *, struct tmpnode *, char *, + enum dr_op, struct cred *); +extern void tdirinit(struct tmpnode *, struct tmpnode *); +extern void tdirtrunc(struct tmpnode *); +extern void *tmp_memalloc(size_t, int); +extern void tmp_memfree(void *, size_t); +extern int tmp_resv(struct tmount *, struct tmpnode *, size_t, int); +extern int tmp_taccess(void *, int, struct cred *); +extern int tmp_sticky_remove_access(struct tmpnode *, struct tmpnode *, + struct cred *); +extern int tmp_convnum(char *, pgcnt_t *); +extern int tmp_convmode(char *, mode_t *); +extern int tdirenter(struct tmount *, struct tmpnode *, char *, + enum de_op, struct tmpnode *, struct tmpnode *, struct vattr *, + struct tmpnode **, struct cred *, caller_context_t *); + +#define TMP_MUSTHAVE 0x01 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_TMP_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/tmpnode.h b/illumos-x86_64/usr/include/sys/fs/tmpnode.h new file mode 100644 index 00000000..42e67f85 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/tmpnode.h @@ -0,0 +1,158 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_TMPNODE_H +#define _SYS_FS_TMPNODE_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * tmpnode is the file system dependent node for tmpfs. + * + * tn_rwlock protects access of the directory list at tn_dir + * as well as syncronizing read and writes to the tmpnode + * + * tn_contents protects growing, shrinking, reading and writing + * the file along with tn_rwlock (see below). + * + * tn_tlock protects updates to tn_mode and tn_nlink + * + * tm_contents in the tmount filesystem data structure protects + * tn_forw and tn_back which are used to maintain a linked + * list of all tmpfs files associated with that file system + * + * The anon array represents the secondary store for tmpfs. + * To grow or shrink the file or fill in holes requires + * manipulation of the anon array. These operations are protected + * by a combination of tn_rwlock and tn_contents. Growing or shrinking + * the array requires the write lock on tn_rwlock and tn_contents. + * Filling in a slot in the array requires the write lock on tn_contents. + * Reading the array requires the read lock on tn_contents. + * + * The ordering of the locking is: + * tn_rwlock -> tn_contents -> page locks on pages in file + * + * tn_tlock doesn't require any tmpnode locks + */ + +struct tmpnode { + struct tmpnode *tn_back; /* linked list of tmpnodes */ + struct tmpnode *tn_forw; /* linked list of tmpnodes */ + union { + struct { + struct tdirent *un_dirlist; /* dirent list */ + uint_t un_dirents; /* number of dirents */ + } un_dirstruct; + char *un_symlink; /* pointer to symlink */ + struct { + struct anon_hdr *un_anon; /* anon backing for file */ + pgcnt_t un_size; /* size repres. by array */ + } un_anonstruct; + } un_tmpnode; + struct vnode *tn_vnode; /* vnode for this tmpnode */ + int tn_gen; /* pseudo gen number for tfid */ + struct vattr tn_attr; /* attributes */ + krwlock_t tn_contents; /* vm side -serialize mods */ + krwlock_t tn_rwlock; /* rw,trunc size - serialize */ + /* mods and directory updates */ + kmutex_t tn_tlock; /* time, flag, and nlink lock */ + struct tmpnode *tn_xattrdp; /* ext. attribute directory */ + uint_t tn_flags; /* tmpnode specific flags */ +}; + +#define tn_dir un_tmpnode.un_dirstruct.un_dirlist +#define tn_dirents un_tmpnode.un_dirstruct.un_dirents +#define tn_symlink un_tmpnode.un_symlink +#define tn_anon un_tmpnode.un_anonstruct.un_anon +#define tn_asize un_tmpnode.un_anonstruct.un_size + +/* + * tmnode flag values. + */ +#define ISXATTR 0x1 + +/* + * Attributes + */ +#define tn_mask tn_attr.va_mask +#define tn_type tn_attr.va_type +#define tn_mode tn_attr.va_mode +#define tn_uid tn_attr.va_uid +#define tn_gid tn_attr.va_gid +#define tn_fsid tn_attr.va_fsid +#define tn_nodeid tn_attr.va_nodeid +#define tn_nlink tn_attr.va_nlink +#define tn_size tn_attr.va_size +#define tn_atime tn_attr.va_atime +#define tn_mtime tn_attr.va_mtime +#define tn_ctime tn_attr.va_ctime +#define tn_rdev tn_attr.va_rdev +#define tn_blksize tn_attr.va_blksize +#define tn_nblocks tn_attr.va_nblocks +#define tn_seq tn_attr.va_seq + +/* + * tmpfs directories are made up of a linked list of tdirent structures + * hanging off directory tmpnodes. File names are not fixed length, + * but are null terminated. + */ +struct tdirent { + struct tmpnode *td_tmpnode; /* tnode for this file */ + struct tdirent *td_next; /* next directory entry */ + struct tdirent *td_prev; /* prev directory entry */ + uint_t td_offset; /* "offset" of dir entry */ + uint_t td_hash; /* a hash of td_name */ + struct tdirent *td_link; /* linked via the hash table */ + struct tmpnode *td_parent; /* parent, dir we are in */ + char *td_name; /* must be null terminated */ + /* max length is MAXNAMELEN */ +}; + +/* + * tfid overlays the fid structure (for VFS_VGET) + */ +struct tfid { + uint16_t tfid_len; + ino32_t tfid_ino; + int32_t tfid_gen; +}; + +#define ESAME (-1) /* trying to rename linked files (special) */ + +extern struct vnodeops *tmp_vnodeops; +extern const struct fs_operation_def tmp_vnodeops_template[]; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_TMPNODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/udf_inode.h b/illumos-x86_64/usr/include/sys/fs/udf_inode.h new file mode 100644 index 00000000..e1417637 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/udf_inode.h @@ -0,0 +1,733 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_FS_UDF_INODE_H +#define _SYS_FS_UDF_INODE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SUN_IMPL_ID "*SUN SOLARIS UDF" +#define SUN_IMPL_ID_LEN 16 +#define SUN_OS_CLASS 4 +#define SUN_OS_ID 2 + +/* + * Size of each cluster + * and bits to be shifted + */ +#define CLSTR_SIZE 8 +#define CLSTR_MASK 7 + + +/* + * enums + */ +enum de_op { DE_CREATE, DE_MKDIR, DE_LINK, DE_RENAME }; /* direnter ops */ +enum dr_op { DR_REMOVE, DR_RMDIR, DR_RENAME }; /* dirremove ops */ + +/* + * The following macros optimize certain frequently calculated + * quantities by using shifts and masks in place of divisions + * modulos and multiplications. + */ + +#define blkoff(udfvfsp, loc) /* calculates (loc % udfcfs->udf_lbsize) */ \ + ((loc) & (udfvfsp)->udf_lbmask) + +#define lblkno(udf_vfsp, loc) \ + ((int32_t)((loc) / (udf_vfsp)->udf_lbsize)) + +#define fsbtodb(udf, blk) \ + ((blk) << udf->udf_l2d_shift) + + +struct udf_fid { + uint16_t udfid_len; /* Length of data */ + uint16_t udfid_prn; /* the partition number of icb */ + uint32_t udfid_icb_lbn; /* file entry block no */ + uint32_t udfid_uinq_lo; /* uniq id to validate the vnode */ +}; + + + + +#define MAXNAMLEN 255 + + + + +struct ud_part { + uint16_t udp_flags; /* See below */ + uint16_t udp_number; /* partition Number */ + uint32_t udp_seqno; /* to find the prevailaing desc */ + uint32_t udp_access; /* access type */ + uint32_t udp_start; /* Starting block no of partition */ + uint32_t udp_length; /* Lenght of the partition */ + uint32_t udp_unall_loc; /* unall space tbl or bitmap loc */ + uint32_t udp_unall_len; /* unall space tbl or bitmap length */ + uint32_t udp_freed_loc; /* freed space tbl or bitmap loc */ + uint32_t udp_freed_len; /* freed space tbl or bitmap length */ + /* From part desc */ + + uint32_t udp_nfree; /* No of free blocks in the partition */ + uint32_t udp_nblocks; /* Total no of blks in the partition */ + /* From lvid */ + uint32_t udp_last_alloc; /* Last allocated space in bitmap */ + + int32_t udp_cache_count; /* Cache is used for metadata */ + daddr_t udp_cache[CLSTR_SIZE]; +}; + +/* + * udp_flags + */ +#define UDP_BITMAPS 0x00 +#define UDP_SPACETBLS 0x01 + +/* + * udp_access + */ +#define UDP_MT_RO 0x0001 /* ROM */ +#define UDP_MT_WO 0x0002 /* WORM */ +#define UDP_MT_RW 0x0003 /* RW */ +#define UDP_MT_OW 0x0004 /* OW */ + + + +#define MAX_SPM 4 + +struct ud_map { + uint32_t udm_flags; /* Flags */ + uint16_t udm_vsn; /* Volume Sequence Number */ + uint16_t udm_pn; /* Partition Number */ + uint32_t udm_vat_icb; /* VAT ICB location */ + uint32_t udm_nent; /* Number of vat entries */ + uint32_t *udm_count; /* Number of entrues in each table */ + struct buf **udm_bp; /* VAT translation tables */ + uint32_t **udm_addr; + + + int32_t udm_plen; + int32_t udm_nspm; + uint32_t udm_spsz; + uint32_t udm_loc[MAX_SPM]; + struct buf *udm_sbp[MAX_SPM]; + caddr_t udm_spaddr[MAX_SPM]; +}; + +/* + * udm_flags + */ +#define UDM_MAP_NORM 0x00 +#define UDM_MAP_VPM 0x01 +#define UDM_MAP_SPM 0x02 + +struct udf_vfs { + struct vfs *udf_vfs; /* Back link */ + struct udf_vfs *udf_next; /* Chain of udf file-system's */ + struct udf_vfs *udf_wnext; /* work list link */ + + struct buf *udf_vds; /* most of the superblock */ + struct buf *udf_iseq; /* Integrity of the fs */ + struct vnode *udf_root; /* Root vnode */ + struct vnode *udf_devvp; /* Block device vnode */ + + char *udf_fsmnt; /* Path name of directory mouted on */ + uint32_t udf_flags; /* Flags */ + uint32_t udf_mtype; /* Media type */ + + int32_t udf_rdclustsz; /* read cluster size */ + int32_t udf_wrclustsz; /* write cluster size */ + + uint64_t udf_maxfsize; /* Max file size allowed in this fs */ + int32_t udf_maxfbits; /* No of bit's for max file size */ + + char udf_volid[32]; /* volume identifier */ + /* from pvd */ + uint16_t udf_tsno; /* Taken from pvd and */ + /* used in making tags */ + + int32_t udf_lbsize; /* Block size */ + /* from lvd */ + int32_t udf_lbmask; /* udf_lbsize - 1 */ + int32_t udf_l2b_shift; /* lbsize to bytes */ + int32_t udf_l2d_shift; /* right shift's to */ + /* make lbsize to DEV_BSIZE */ + + int32_t udf_npart; /* No. of partition's in the volume */ + /* restricted to 1 till udf 1.50 */ + struct ud_part *udf_parts; /* pointer to array of partitions */ + /* from part desc's */ + + int32_t udf_nmaps; + struct ud_map *udf_maps; + + int32_t udf_fragmented; /* File System fragmented */ + int32_t udf_mark_bad; /* force fsck at next mount */ + + /* + * sum of udp_nfree and udp_nblocks + * from the array udf_parts[0] to udf_parts[udf_nparts - 1] + */ + uint32_t udf_freeblks; /* Total udf_lbsize Free Blocks */ + uint32_t udf_totalblks; /* Total number of Blocks */ + /* udf_parts[0].udp_nfree == udf_freespace */ + /* till udf 1.50 (DVD-R?) */ + uint64_t udf_maxuniq; /* Maximum unique ID on the fs */ + uint32_t udf_nfiles; /* No of files */ + uint32_t udf_ndirs; /* No of directories */ + uint32_t udf_miread; /* minimum read revision */ + uint32_t udf_miwrite; /* minimum write revision */ + uint32_t udf_mawrite; /* maximum read revision */ + /* from lvid */ + + time_t udf_time; /* Last time super block is written */ + uint32_t udf_mod; /* file system was modified */ + uint32_t udf_clean; /* state of the file system */ + kmutex_t udf_lock; /* protects contents */ + + kmutex_t udf_rename_lck; /* lock for udf_rename */ + + /* + * Have them cached here for fast access + */ + struct pri_vol_desc *udf_pvd; + struct log_vol_desc *udf_lvd; + struct log_vol_int_desc *udf_lvid; + + uint32_t udf_mvds_loc; + uint32_t udf_mvds_len; + + uint32_t udf_rvds_loc; + uint32_t udf_rvds_len; + + uint32_t udf_iseq_loc; + uint32_t udf_iseq_len; + + uint16_t udf_fsd_prn; + uint32_t udf_fsd_loc; + uint32_t udf_fsd_len; + + uint16_t udf_ricb_prn; + uint32_t udf_ricb_loc; + uint32_t udf_ricb_len; + daddr_t udf_root_blkno; +}; + + +#ifndef __lint +_NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock, + udf_vfs::udf_fragmented)) +_NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock, + udf_vfs::udf_freeblks udf_vfs::udf_totalblks)) +_NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock, + udf_vfs::udf_maxuniq udf_vfs::udf_nfiles + udf_vfs::udf_ndirs)) +_NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock, + udf_vfs::udf_time + udf_vfs::udf_mod udf_vfs::udf_clean)) + +_NOTE(READ_ONLY_DATA(udf_vfs::udf_nmaps udf_vfs::udf_maps)) + +_NOTE(READ_ONLY_DATA(udf_vfs::udf_mtype + udf_vfs::udf_rdclustsz + udf_vfs::udf_wrclustsz + udf_vfs::udf_maxfsize + udf_vfs::udf_maxfbits + udf_vfs::udf_lbsize + udf_vfs::udf_l2b_shift + udf_vfs::udf_lbmask + udf_vfs::udf_l2d_shift)) + +_NOTE(READ_ONLY_DATA(udf_vfs::udf_pvd + udf_vfs::udf_lvd + udf_vfs::udf_lvid)) + +_NOTE(READ_ONLY_DATA(udf_vfs::udf_mvds_loc + udf_vfs::udf_mvds_len + udf_vfs::udf_iseq_loc + udf_vfs::udf_iseq_len + udf_vfs::udf_fsd_prn + udf_vfs::udf_fsd_loc + udf_vfs::udf_fsd_len + udf_vfs::udf_ricb_prn + udf_vfs::udf_ricb_loc + udf_vfs::udf_ricb_len + udf_vfs::udf_root_blkno)) + +_NOTE(READ_ONLY_DATA(ud_part::udp_flags + ud_part::udp_number + ud_part::udp_seqno + ud_part::udp_access + ud_part::udp_start + ud_part::udp_length + ud_part::udp_unall_loc + ud_part::udp_unall_len + ud_part::udp_freed_loc + ud_part::udp_freed_len + ud_part::udp_nblocks)) + +_NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock, + ud_part::udp_nfree + ud_part::udp_last_alloc + ud_part::udp_cache_count + ud_part::udp_cache)) +#endif + +/* + * udf_mtype + */ +#define UDF_MT_RO UDP_MT_RO /* ROM */ +#define UDF_MT_WO UDP_MT_OW /* WORM */ +#define UDF_MT_RW UDP_MT_RW /* RW */ +#define UDF_MT_OW UDP_MT_OW /* OW */ + +/* + * udf_flags + */ +#define UDF_FL_RDONLY 0x0001 /* file system is read only */ +#define UDF_FL_RW 0x0002 /* file system is read write */ + +/* + * udf_clean + */ +#define UDF_DIRTY 0x00 +#define UDF_CLEAN 0x01 + + +#define RD_CLUSTSZ(ip) ((ip)->i_udf->udf_rdclustsz) +#define WR_CLUSTSZ(ip) ((ip)->i_udf->udf_wrclustsz) + +/* + * Size can be a 64-bit value and therefore we sign extend fs_bmask + * to a 64-bit value too so that the higher 32 bits are masked + * properly. Note that the type of fs_bmask has to be signed. Otherwise + * compiler will set the higher 32 bits as zero and we don't want + * this to happen. + */ + +#ifdef UNDEF +#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \ + (((size) + (fs)->udf_lbsize - 1) & (offset_t)(fs)->udf_lbmask) +#endif + +#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \ + (((size) + (fs)->udf_lbmask) & (offset_t)(~(fs)->udf_lbmask)) + +#define blksize(fs) (fs->udf_lbsize) + + +/* + * Convert between inode pointers and vnode pointers + */ +#define VTOI(VP) ((struct ud_inode *)(VP)->v_data) +#define ITOV(IP) ((IP)->i_vnode) +#define i_vfs i_vnode->v_vfsp + +struct icb_ext { + uint16_t ib_flags; + + /* Direct Entry will go here */ + uint16_t ib_prn; /* partition reference number */ + uint32_t ib_block; /* block offset into partition */ + uint64_t ib_offset; /* offset into the file bytes */ + int32_t ib_count; /* No of bytes in current ext */ + uint32_t ib_marker1; /* 0xAAAAAAAA */ + uint32_t ib_marker2; /* 0xBBBBBBBB */ +}; + + +/* ib_flags */ +#define IB_UN_REC 0x1 /* The entry is not allocated */ +#define IB_UN_RE_AL 0x2 /* The entry is not recorded */ + /* and not unallocated */ +#define IB_CON 0x3 /* Continuation entry */ + +#define IB_MASK 0x3 + +#define IB_ALLOCATED(flags) \ + (((flags) & IB_MASK) != IB_UN_RE_AL) + +#define EXT_PER_MALLOC 8 + + +struct ud_inode { + struct ud_inode *i_forw; + struct ud_inode *i_back; + struct ud_inode *i_freef; + struct ud_inode *i_freeb; + + struct vnode *i_vnode; /* vnode associated with this inode */ + struct vnode *i_devvp; /* vnode for block I/O */ + struct udf_vfs *i_udf; /* incore fs associated with inode */ + krwlock_t i_rwlock; /* serializes write/setattr requests */ + krwlock_t i_contents; /* protects (most of) inode contents */ + dev_t i_dev; /* device where inode resides */ + u_offset_t i_diroff; /* last loc for fast name lookup */ + + daddr_t i_icb_lbano; /* Loc of file icb on disk */ + uint16_t i_icb_prn; /* partition reference number */ + kcondvar_t i_wrcv; /* sleep/wakeup for write throttle */ + uint32_t i_flag; + uint32_t i_icb_block; + + int16_t i_astrat; /* ICB strategy */ + int16_t i_desc_type; /* Allocation desc type */ + int32_t i_ext_count; /* Number of extents allocated */ + int32_t i_ext_used; /* Number of extents used */ + struct icb_ext *i_ext; /* array of extents */ + + kmutex_t i_con_lock; + struct icb_ext *i_con; + int32_t i_con_count; + int32_t i_con_used; + int32_t i_con_read; + + uint32_t i_cur_max_ext; + vtype_t i_type; /* File type */ + uint16_t i_char; /* File characteristics */ + uint16_t i_perm; /* File permissions */ + + uid_t i_uid; /* File owner's uid */ + gid_t i_gid; /* File owner's gid */ + uint32_t i_nlink; /* number of links to file */ + uint32_t i_maxent; /* Max entries that are recorded */ + u_offset_t i_size; /* File size in bytes */ + uint64_t i_lbr; /* Logical blocks recorded */ + uint64_t i_uniqid; /* from the file entry */ + + timespec32_t i_atime; + timespec32_t i_mtime; + timespec32_t i_ctime; + + size_t i_delaylen; /* delayed writes, units=bytes */ + offset_t i_delayoff; /* where we started delaying */ + offset_t i_nextrio; /* where to start the next clust */ + uint64_t i_writes; /* remaining bytes in write q */ + kmutex_t i_tlock; /* protects time fields, i_flag */ + major_t i_major; + minor_t i_minor; + + uint32_t i_marker1; /* 0xAAAAAAAA */ + uint32_t i_seq; /* sequence number attribute */ + offset_t i_nextr; /* next byte read offset (read-ahead) */ + long i_mapcnt; /* number of mappings of pages */ + int *i_map; /* block list for the file */ + dev_t i_rdev; /* INCORE rdev from */ + uint32_t i_marker2; /* 0xBBBBBBBB */ + uint32_t i_data_off; /* Data offset into embedded file */ + uint32_t i_max_emb; + uint32_t i_marker3; +}; + + +#ifndef __lint +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_astrat)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_desc_type)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext_count)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext_used)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext)) + +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_type)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_char)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_perm)) + +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_uid)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_gid)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_nlink)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_size)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_lbr)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_uniqid)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_major)) +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_minor)) + +_NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_atime)) +_NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_mtime)) +_NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_ctime)) +_NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_delayoff)) +_NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_delaylen)) +_NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_nextrio)) +_NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_writes)) +_NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_flag)) + +_NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, + icb_ext::ib_flags icb_ext::ib_prn + icb_ext::ib_block + icb_ext::ib_count icb_ext::ib_offset)) +#endif + + +/* i_flag */ +#define IUPD 0x0001 /* file has been modified */ +#define IACC 0x0002 /* inode access time to be updated */ +#define IMOD 0x0004 /* inode has been modified */ +#define ICHG 0x0008 /* inode has been changed */ +#define INOACC 0x0010 /* no access time update in getpage */ +#define IMODTIME 0x0020 /* mod time already set */ +#define IREF 0x0040 /* inode is being referenced */ +#define ISYNC 0x0080 /* do all allocation synchronously */ +#define IMODACC 0x0200 /* only access time changed; */ +#define IATTCHG 0x0400 /* only size/blocks have changed */ +#define IBDWRITE 0x0800 /* the inode has been scheduled for */ + /* write operation asynchrously */ + +/* + * i_char + * Do not change used by MANDLOCK macro in vnode.h + */ +#define ISUID VSUID /* set user id on execution */ +#define ISGID VSGID /* set group id on execution */ +#define ISVTX VSVTX /* save swapped text even after use */ +/* + * Setuid --S--------- + * Setgid -G---------- + * SaveTXT T----------- + */ + +/* i_perm */ +#define IEXEC 0x0400 /* read, write, execute permissions */ +#define IWRITE 0x0800 +#define IREAD 0x1000 +#define IATTR 0x2000 +#define IDELE 0x4000 + +#define UP_MASK 0x1CE7 +#define VA2UD_PERM(perm) \ + (((perm) & 0x7) | (((perm) & 0x38) << 2) | (((perm) & 0x1C0) << 4)) +#define UD2VA_PERM(perm) \ + (((perm) & 0x7) | (((perm) & 0xE0) >> 2) | (((perm) & 0x1C00) >> 4)) + +/* + * Permissions + * Other -----------DARWX + * Group ------DARWX----- + * Owner -DARWX---------- + */ +#define UD_DPERM2UPERM(dperm) ((((dperm) >> 4) & 0x1C0) | \ + (((dperm) >> 2) & 0x38) | \ + ((dperm) & 0x7)) +#define UD_UPERM2DPERM(uperm) ((((uperm) & 0x1C0) << 4) | \ + (((uperm) & 0x38) << 2) | \ + ((uperm) & 0x7)) + + +/* specify how the inode info is written in ud_syncip() */ +#define I_SYNC 1 /* wait for the inode written to disk */ +#define I_DSYNC 2 /* wait for the inode written to disk */ + /* only if IATTCHG is set */ +#define I_ASYNC 0 /* don't wait for the inode written */ + + +#define UD_HASH_SZ 512 + +#if ((UD_HASH_SZ & (UD_HASH_SZ - 1)) == 0) +#define UD_INOHASH(dev, bno) (hash2ints((int)dev, (int)bno) & UD_HASH_SZ - 1) +#else +#define UD_INOHASH(dev, bno) (hash2ints((int)dev, (int)bno) % UD_HASH_SZ) +#endif + +union ihead { + union ihead *ih_head[2]; + struct ud_inode *ih_chain[2]; +}; + + +#define IMARK(ip) ud_imark(ip) +#define ITIMES_NOLOCK(ip) ud_itimes_nolock(ip) + +#define ITIMES(ip) { \ + mutex_enter(&(ip)->i_tlock); \ + ITIMES_NOLOCK(ip); \ + mutex_exit(&(ip)->i_tlock); \ +} + +#define ESAME (-1) /* trying to rename linked files (special) */ + +#define UDF_HOLE (daddr32_t)-1 /* value used when no block allocated */ + + +extern int32_t ud_trace; +#define ud_printf(xyz) \ + if (ud_trace) { \ + cmn_err(CE_NOTE, xyz); \ + } + +#ifndef __lint +_NOTE(SCHEME_PROTECTS_DATA("Unshared data", + buf + dirent64 + fid + flock64 + statvfs64 + timespec32 + udf_fid + uio + vattr + vfs + vnode)) + +_NOTE(SCHEME_PROTECTS_DATA("Unshared data", + file_entry + file_id + icb_tag + indirect_entry + log_vol_int_desc + long_ad + lvid_iu + regid + short_ad + tag + tstamp)) + +_NOTE(LOCK_ORDER(ud_inode::i_rwlock + ud_inode::i_contents + ud_inode::i_tlock)) +#endif + +/* + * udf_vfsops.c + */ +void ud_update_superblock(struct vfs *); + + +/* + * udf_vnops.c + */ +int32_t ud_rdwri(enum uio_rw, int32_t, struct ud_inode *, caddr_t, + int32_t, offset_t, enum uio_seg, int32_t *, + struct cred *cr); +int32_t ud_putapage(struct vnode *, page_t *, u_offset_t *, + size_t *, int32_t, struct cred *); + + +/* + * udf_inode.c + */ +int32_t ud_iget(struct vfs *, uint16_t, uint32_t, struct ud_inode **, + struct buf *, struct cred *); +void ud_iinactive(struct ud_inode *, struct cred *); +void ud_iupdat(struct ud_inode *, int32_t); +int32_t ud_itrunc(struct ud_inode *, u_offset_t, int32_t, struct cred *); +int32_t ud_iaccess(struct ud_inode *, int32_t, struct cred *, int dolock); +int32_t ud_iflush(struct vfs *); +void ud_imark(struct ud_inode *); +void ud_itimes_nolock(struct ud_inode *); +void ud_delcache(struct ud_inode *); +void ud_idrop(struct ud_inode *); +void ud_init_inodes(void); + + +/* + * udf_alloc.c + */ +int32_t ud_alloc_space(struct vfs *, uint16_t, uint32_t, + uint32_t, uint32_t *, uint32_t *, int32_t, int32_t); +void ud_free_space(struct vfs *, uint16_t, uint32_t, uint32_t); +int32_t ud_ialloc(struct ud_inode *, struct ud_inode **, + struct vattr *, struct cred *); +void ud_ifree(struct ud_inode *, vtype_t); +int32_t ud_freesp(struct vnode *, struct flock64 *, int32_t, + struct cred *); +int32_t ud_alloc_from_cache(struct udf_vfs *, struct ud_part *, + uint32_t *); +int32_t ud_release_cache(struct udf_vfs *); + + +/* + * udf_subr.c + */ +void ud_vfs_add(struct udf_vfs *); +void ud_vfs_remove(struct udf_vfs *); +daddr_t ud_xlate_to_daddr(struct udf_vfs *, uint16_t, + uint32_t, int32_t, uint32_t *); +int32_t ud_ip_off2bno(struct ud_inode *, uint32_t, uint32_t *); +void ud_dtime2utime(struct timespec32 *, struct tstamp const *); +void ud_utime2dtime(struct timespec32 const *, struct tstamp *); +int32_t ud_syncip(struct ud_inode *, int32_t, int32_t); +void ud_update(int32_t); +int32_t ud_fbwrite(struct fbuf *, struct ud_inode *); +void ud_sbwrite(struct udf_vfs *); +int32_t ud_sync_indir(struct ud_inode *); +void ud_update_regid(struct regid *); +int32_t ud_read_icb_till_off(struct ud_inode *, u_offset_t); +void ud_make_tag(struct udf_vfs *, struct tag *, + uint16_t, uint32_t, uint16_t); +int32_t ud_make_dev_spec_ear(struct dev_spec_ear *, major_t, minor_t); +int32_t ud_make_ftimes_ear(struct ftimes_ear *, + int32_t, struct timespec32 *); +int32_t ud_get_next_fid(struct ud_inode *, struct fbuf **, uint32_t, + struct file_id **, uint8_t **, uint8_t *); +int32_t ud_verify_tag_and_desc(struct tag *, uint16_t, uint32_t, + int32_t, int32_t); +uint16_t ud_crc(uint8_t *, int32_t); +int32_t ud_compressunicode(int32_t, int32_t, uint16_t *, uint8_t *); +uint32_t ud_check_te_unrec(struct udf_vfs *, caddr_t, uint32_t); +int32_t ud_compress(int32_t, int32_t *, uint8_t *, uint8_t *); +int32_t ud_uncompress(int32_t, int32_t *, uint8_t *, uint8_t *); +struct buf *ud_bread(dev_t, daddr_t, long); +int ud_sticky_remove_access(struct ud_inode *, struct ud_inode *, + struct cred *); + + +/* + * udf_dir.c + */ +int32_t ud_dirlook(struct ud_inode *, + char *, struct ud_inode **, struct cred *, int32_t); +int32_t ud_direnter(struct ud_inode *, char *, enum de_op, + struct ud_inode *, struct ud_inode *, struct vattr *, + struct ud_inode **, struct cred *, caller_context_t *); +int32_t ud_dirremove(struct ud_inode *, + char *, struct ud_inode *, struct vnode *, + enum dr_op, struct cred *, caller_context_t *); + + +/* + * udf_bmap.c + */ +int32_t ud_bmap_has_holes(struct ud_inode *); +int32_t ud_bmap_write(struct ud_inode *, u_offset_t, + int, int32_t, struct cred *); +int32_t ud_bmap_read(struct ud_inode *, u_offset_t, + daddr_t *, int32_t *); +void ud_insert_new_ext(struct ud_inode *, + int32_t, struct icb_ext *); +int32_t ud_alloc_and_make_ext(struct ud_inode *, int32_t); +int32_t ud_create_new_icb(struct ud_inode *); +void ud_append_new_ext(struct ud_inode *, uint16_t, + u_offset_t, uint32_t, uint16_t, uint32_t); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UDF_INODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/udf_volume.h b/illumos-x86_64/usr/include/sys/fs/udf_volume.h new file mode 100644 index 00000000..c0f24bdd --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/udf_volume.h @@ -0,0 +1,949 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_UDF_VOLUME_H +#define _SYS_FS_UDF_VOLUME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define UDF_102 0x66 +#define UDF_150 0x96 +#define UDF_200 0xC8 + +/* fid_idlen include compression id */ +#define FID_LEN(fid) (((sizeof (struct file_id) + \ + SWAP_16((fid)->fid_iulen) + (fid)->fid_idlen - 2) + 3) & ~3) + +/* + * #define ID_LEN(fid) \ + * (((SWAP_16((fid)->fid_iulen) + (fid)->fid_idlen - 2) + 3) & ~3) + */ + +#define F_LEN (sizeof (struct file_id) - 2) + +#define UDF_DOMAIN_NAME "*OSTA UDF Compliant\0\0\0\0" +#define UDF_LV_INFO "*UDF LV Info\0\0\0\0\0\0\0\0\0\0\0\0" +#define UDF_FREEEASPACE "*UDF FreeEASpace\0\0\0\0\0\0\0\0" +#define UDF_FREEAEASPACE "*UDF FreeAppEASpace\0\0\0\0" +#define UDF_CGMS_INFO "*UDF DVD CGMS Info\0\0\0\0" +#define UDF_OS2_EA "*UDF OS/2 EA\0\0\0\0\0\0\0\0\0\0\0" +#define UDF_OS2_EA_LEN "*UDF OS/2 EALength\0\0\0\0\0\0" +#define UDF_MAC_VOLINFO "*UDF Mac VolumeInfo\0\0\0\0" +#define UDF_MAC_UNIQID "*UDF Mac UniqueIDTable\0" +#define UDF_MAC_RESFRK "*UDF Mac ResourceFork\0\0" +#define UDF_VIRT_PART "*UDF Virtual Partition\0" +#define UDF_SPAR_PART "*UDF Sparable Partition" +#define UDF_VAT "*UDF Virtual Alloc Tbl\0" +#define UDF_SPAR_TBL "*UDF Sparing Table\0\0\0\0\0" + + +#if defined(_BIG_ENDIAN) +#define SWAP_16(a) (((ushort_t)((a) & 0xff) << 8) | \ + ((ushort_t)((a) & 0xff00) >> 8)) +#define SWAP_32(a) ((((a) & 0xff) << 24) | \ + (((a) & 0xff00) << 8) | \ + (((a) & 0xff0000) >> 8) | \ + (((a) & 0xff000000) >> 24)) +#define SWAP_64(a) ((((a) & 0xffULL) << 56) | \ + (((a) & 0xff00ULL) << 40) | \ + (((a) & 0xff0000ULL) << 24) | \ + (((a) & 0xff000000ULL) << 8) | \ + (((a) & 0xff00000000ULL) >> 8) | \ + (((a) & 0xff0000000000ULL) >> 24) | \ + (((a) & 0xff000000000000ULL) >> 40) | \ + (((a) & 0xff00000000000000ULL) >> 56)) + +#define GET_32(a) ((uint32_t)(*((uint8_t *)a)) | \ + (((uint32_t)(*(((uint8_t *)a) + 1))) << 8) | \ + (((uint32_t)(*(((uint8_t *)a) + 2))) << 16) | \ + (((uint32_t)(*(((uint8_t *)a) + 3))) << 24)) +#else +#define SWAP_16(a) (a) +#define SWAP_32(a) (a) +#define SWAP_64(a) (a) + +#define GET_32(a) (*((uint32_t *)a)) +#endif /* _BIG_ENDIAN */ + + +#define BCD2HEX_16(a) (((a) & 0xf) + \ + (((ushort_t)((a) & 0xf0) >> 4) * 10) + \ + (((ushort_t)((a) & 0xf00) >> 8) * 100) + \ + (((ushort_t)((a) & 0xf000) >> 12) * 1000)) + +#define HEX2BCD_16(a) ((((ushort_t)a) % 10) | \ + (((ushort_t)((ushort_t)(a) / 10) % 10) << 4) | \ + (((ushort_t)((ushort_t)(a) / 100) % 10) << 8) | \ + (((ushort_t)((ushort_t)(a) / 1000) % 10) << 12)) + +#define ANCHOR_VOL_DESC_LOC (256) +#define ANCHOR_VOL_DESC_LEN 0x200 + + + +/* Basic data structures */ + + +typedef char dstring_t; + + +/* + * recorded at the start of the descriptor + * used to distinguish between different + * descriptors + */ +struct tag { + uint16_t tag_id; /* 00 Tag Identifier */ + uint16_t tag_desc_ver; /* 02 Descriptor Version */ + uint8_t tag_cksum; /* 04 Tag Checksum */ + uint8_t tag_res; /* 05 Reserved */ + uint16_t tag_sno; /* 06 Tag Serial Number */ + uint16_t tag_crc; /* 08 Descriptor CRC */ + uint16_t tag_crc_len; /* 0A Descriptor CRC length */ + uint32_t tag_loc; /* 0C Tag Location */ +}; +typedef struct tag tag_t; + +/* + * descriptor tag id values + */ + +#define UD_PRI_VOL_DESC 0x0001 +#define UD_ANCH_VOL_DESC 0x0002 +#define UD_VOL_DESC_PTR 0x0003 +#define UD_IMPL_USE_DESC 0x0004 +#define UD_PART_DESC 0x0005 +#define UD_LOG_VOL_DESC 0x0006 +#define UD_UNALL_SPA_DESC 0x0007 +#define UD_TERM_DESC 0x0008 +#define UD_LOG_VOL_INT 0x0009 + +#define UD_FILE_SET_DESC 0x0100 +#define UD_FILE_ID_DESC 0x0101 +#define UD_ALLOC_EXT_DESC 0x0102 +#define UD_INDIRECT_ENT 0x0103 +#define UD_TERMINAL_ENT 0x0104 +#define UD_FILE_ENTRY 0x0105 +#define UD_EXT_ATTR_HDR 0x0106 +#define UD_UNALL_SPA_ENT 0x0107 +#define UD_SPA_BMAP_DESC 0x0108 +#define UD_PART_INT_DESC 0x0109 +#define UD_EXT_FILE_ENT 0x010A + + + + +/* + * Character set's allowed in descriptor fields + * shall be specified + */ +struct charspec { + uint8_t cs_type; /* 00 Character Set Type */ + char cs_info[63]; /* 01 Character Set Information */ +}; +typedef struct charspec charspec_t; + +#define CS_TYPE0 0x00 +#define CS_TYPE1 0x01 +#define CS_TYPE2 0x02 +#define CS_TYPE3 0x03 +#define CS_TYPE4 0x04 +#define CS_TYPE5 0x05 +#define CS_TYPE6 0x06 +#define CS_TYPE7 0x07 +#define CS_TYPE8 0x08 + + + +/* + * Entity Identification + */ +struct regid { + uint8_t reg_flags; /* 00 Flags */ + char reg_id[23]; /* 01 Identifier */ + char reg_ids[8]; /* 18 Identifier Suffix */ +}; +typedef struct regid regid_t; + +#define EI_FLAG_DIRTY 0x00 +#define EI_FLAG_PROT 0x01 + +struct lb_addr { + /* uint32_t lba_number; 00 Logical Block Number */ + /* uint8_t lba_prn[2]; 04 Partition Reference Number */ + char lba_aaa[6]; +}; +typedef struct lb_addr lb_addr_t; +#define lba_number(x)(((x)->lba_aaa[0]) | \ + ((x)->lba_aaa[1] << 8) | \ + ((x)->lba_aaa[2] << 16) | \ + ((x)->lba_aaa[3] << 24)) + +#define lba_prn(x) ((x)->lba_aaa[4] | ((x)->lba_aaa[5] << 8)) + + +/* + * Extend Descriptor + */ +struct extent_ad { + uint32_t ext_len; /* 00 Extent Length */ + uint32_t ext_loc; /* 04 Extent Location */ +}; +typedef struct extent_ad extent_ad_t; + +/* + * Short Allocation Descriptor + */ +struct short_ad { + uint32_t sad_ext_len; /* 00 Extent Length */ + uint32_t sad_ext_loc; /* 04 extent Position */ +}; +typedef struct short_ad short_ad_t; + +/* + * Long Allocation Descriptor + */ +struct long_ad { + uint32_t lad_ext_len; /* 00 Extent Length */ + uint32_t lad_ext_loc; /* 04 Extent Location */ + uint16_t lad_ext_prn; /* 08 Extent part ref no */ + /* lb_addr_t lad_ext_loc; 04 Extent Location */ + char lad_iu[6]; /* 0A Implementation Use */ +}; +typedef struct long_ad long_ad_t; + + + + +/* + * Format to record date and time + * If zero date & time is not specified + */ +struct tstamp { + uint16_t ts_tzone; /* 00 Type and Time Zone */ + uint16_t ts_year; /* 02 Year */ + uint8_t ts_month; /* 04 Month */ + uint8_t ts_day; /* 05 Day */ + uint8_t ts_hour; /* 06 Hour */ + uint8_t ts_min; /* 07 Minute */ + uint8_t ts_sec; /* 08 Second */ + uint8_t ts_csec; /* 09 Centi-seconds */ + uint8_t ts_husec; /* 0A Hundreds of Micro sec's */ + uint8_t ts_usec; /* 0B Micro-seconds */ +}; +typedef struct tstamp tstamp_t; + + +/* + * ts_tzone + */ +#define TMODE 0xF000 +#define TSIGN 0x0800 +#define TOFFSET 0x07FF +#define TINVALID (TSIGN|TOFFSET) + + +/* + * Format of the ICB tag which specifies + * most of the infomation of the file + */ +struct icb_tag { + uint32_t itag_prnde; /* 00 Prior Recorded No of Dir Entry */ + uint16_t itag_strategy; /* 04 Strategy Type */ + uint16_t itag_param; /* 06 Strategy parameter */ + uint16_t itag_max_ent; /* 08 Maximum No of Entries */ + uint8_t itag_rsvd; /* 0A Reserved */ + uint8_t itag_ftype; /* 0B File Type */ + /* lb_addr_t itag_lb_addr; 0C parent ICB Location */ + uint32_t itag_lb_loc; /* 0C */ + uint16_t itag_lb_prn; /* 10 */ + uint16_t itag_flags; /* 12 Flags */ +}; +typedef struct icb_tag icb_tag_t; + +/* + * Different strategy types for the file + * For DVD_ROM we use onlt type4 + */ +#define STRAT_TYPE1 0x0001 +#define STRAT_TYPE2 0x0002 +#define STRAT_TYPE3 0x0003 +#define STRAT_TYPE4 0x0004 +#define STRAT_TYPE4096 0x1000 + +/* + * File types + */ +#define FTYPE_UNALL_SPACE 0x01 +#define FTYPE_PART_INTEG 0x02 +#define FTYPE_INDIRECT 0x03 +#define FTYPE_DIRECTORY 0x04 +#define FTYPE_FILE 0x05 +#define FTYPE_BLOCK_DEV 0x06 +#define FTYPE_CHAR_DEV 0x07 +#define FTYPE_EAR 0x08 +#define FTYPE_FIFO 0x09 +#define FTYPE_C_ISSOCK 0x0A +#define FTYPE_T_ENTRY 0x0B +#define FTYPE_SYMLINK 0x0C + +/* + * Flags + */ +#define ICB_FLAG_SHORT_AD 0x0000 +#define ICB_FLAG_LONG_AD 0x0001 +#define ICB_FLAG_EXT_AD 0x0002 +#define ICB_FLAG_ONE_AD 0x0003 +#define ICB_FLAG_SORTED 0x0008 +#define ICB_FLAG_NON_RELOC 0x0010 +#define ICB_FLAG_ARCHIVE 0x0020 +#define ICB_FLAG_SETUID 0x0040 +#define ICB_FLAG_SETGID 0x0080 +#define ICB_FLAG_STICKY 0x0100 +#define ICB_FLAG_CONTIG 0x0200 +#define ICB_FLAG_SYSTEM 0x0400 +#define ICB_FLAG_TRNSFRMED 0x0800 +#define ICB_FLAG_MVERS 0x1000 + + + + +/* Volume recognition descriptors */ + + + + +/* + * Primary volume descriptor identifis the + * volume and certain attributes of the volume + */ +struct pri_vol_desc { + tag_t pvd_tag; /* 00 Descriptor Tag */ + uint32_t pvd_vdsn; /* 10 Volume Descriptor Seq Num */ + uint32_t pvd_pvdn; /* 14 Primary Vol Desc Num */ + dstring_t pvd_vol_id[32]; /* 18 Volume Identifier */ + uint16_t pvd_vsn; /* 38 Volume Sequence Num */ + uint16_t pvd_mvsn; /* 3A Max Volume Sequence Num */ + uint16_t pvd_il; /* 3C Interchange Level */ + uint16_t pvd_mil; /* 3E Max Interchange Level */ + uint32_t pvd_csl; /* 40 Character Set List */ + uint32_t pvd_mcsl; /* 44 Max Character Set List */ + dstring_t pvd_vsi[128]; /* 48 Volume Set Identifier */ + charspec_t pvd_desc_cs; /* C8 Descriptor Character Set */ + charspec_t pvd_exp_cs; /* 108 Explanatory Char Set */ + extent_ad_t pvd_vol_abs; /* 148 Volume Abstract */ + extent_ad_t pvd_vcn; /* 150 Volume Copyright Notice */ + regid_t pvd_appl_id; /* 158 Application Identifier */ + tstamp_t pvd_time; /* 178 Recording Data & Time */ + regid_t pvd_ii; /* 184 Implementation Identifier */ + char pvd_iu[64]; /* 1A4 Implementation Use */ + uint32_t pvd_pvdsl; /* 1E4 Pred Vol Desc Seq Loc */ + uint16_t pvd_flags; /* 1E8 Flags */ + uint8_t pvd_res[22]; /* 1EA Reserved */ +}; + + + + +/* + * Anchor Volume Descriptor Pointer specifies + * the extent of Main & Reserve volume descriptor + */ +struct anch_vol_desc_ptr { + tag_t avd_tag; /* 00 Descriptor Tag */ + extent_ad_t avd_main_vdse; /* 10 Main Vol Desc Seq Extent */ + extent_ad_t avd_res_vdse; /* 18 Reserve Vol Desc Seq Ext */ + char avd_res[480]; /* 20 Reserved */ +}; +typedef struct anch_vol_desc_ptr anch_vol_desc_ptr_t; + + + + +/* + * Volume Descriptor Pointer + */ +struct vol_desc_ptr { + tag_t vdp_tag; /* 00 Descriptor Tag */ + uint32_t vdp_vdsn; /* 10 Volume Descriptor Seq Num */ + extent_ad_t vdp_nvdse; /* 14 Next Vol Desc Seq Extent */ + uint8_t vdp_res[484]; /* 1A Reserved */ +}; +typedef struct vol_desc_ptr vol_desc_ptr_t; + + + + +/* + * Implementation Use Volume Descriptor + * This is taken from udf1.02/1.50 documents + * the fields after iuvd_ii are defined only + * for the udf domain + */ +struct iuvd_desc { + tag_t iuvd_tag; /* 00 Descriptor Tag */ + uint32_t iuvd_vdsn; /* 10 Volume Desc Seq Num */ + regid_t iuvd_ii; /* 14 Domain Identifier */ + charspec_t iuvd_cset; /* 34 LVI Charset */ + dstring_t iuvd_lvi[128]; /* 74 Logical Vol Identifier */ + dstring_t iuvd_ifo1[36]; /* F4 LV Info1 */ + dstring_t iuvd_ifo2[36]; /* 118 LV Info2 */ + dstring_t iuvd_ifo3[36]; /* 13C LV Info3 */ + regid_t iuvd_iid; /* 160 Implementation ID */ + uint8_t iuvd_iu[128]; /* 180 Implementation Use */ +}; +typedef struct iuvd_desc iuvd_desc_t; + + + + + +/* + * Partition Descriptor + * specifies the size and location of the partition + */ +struct part_desc { + tag_t pd_tag; /* 00 Descriptor Tag */ + uint32_t pd_vdsn; /* 10 Volume Desc Seq Num */ + uint16_t pd_pflags; /* 14 Partition Flags */ + uint16_t pd_pnum; /* 16 partition Number */ + regid_t pd_pcontents; /* 18 Partition Contents */ + uint8_t pd_pc_use[128]; /* 38 Partition Contents Use */ + uint32_t pd_acc_type; /* B8 Access Type */ + uint32_t pd_part_start; /* BC Part Start Location */ + uint32_t pd_part_length; /* C0 partition Length */ + regid_t pd_ii; /* C4 Implementation Identifier */ + uint8_t pd_iu[128]; /* E4 Implementation Use */ + uint8_t pd_res[156]; /* 164 Reserved */ +}; +typedef struct part_desc part_desc_t; + + +/* + * pd_acc_type + */ +#define PART_ACC_RO 0x01 +#define PART_ACC_WO 0x02 +#define PART_ACC_RW 0x03 +#define PART_ACC_OW 0x04 + + +/* + * Partition Header Descriptor + * Overloads pd_pc_use + */ +struct phdr_desc { + struct short_ad phdr_ust; /* Unallocated Space Table */ + struct short_ad phdr_usb; /* Unallocated Space Bitmap */ + struct short_ad phdr_it; /* Partition Integrity Table */ + struct short_ad phdr_fst; /* Freed Space Table */ + struct short_ad phdr_fsb; /* Freed Space Bitmap */ +}; +typedef struct phdr_desc phdr_desc_t; + + + + + + +/* + * Logical Volume Descriptor + */ +struct log_vol_desc { + tag_t lvd_tag; /* 00 Descriptor Tag */ + uint32_t lvd_vdsn; /* 10 Volume Desc Seq Num */ + charspec_t lvd_desc_cs; /* 14 Descriptor Char Set */ + dstring_t lvd_lvid[128]; /* 54 Logical Vol Identifier */ + uint32_t lvd_log_bsize; /* D4 Logical Block Size */ + regid_t lvd_dom_id; /* D8 Domain Identifier */ + long_ad_t lvd_lvcu; /* F8 Logical Vol Contents Use */ + uint32_t lvd_mtbl_len; /* 108 Map Table Length */ + uint32_t lvd_num_pmaps; /* 10C Number of Partition Maps */ + regid_t lvd_ii; /* 110 Implementation Identifier */ + uint8_t lvd_iu[128]; /* 130 Implementation Use */ + extent_ad_t lvd_int_seq_ext; /* 1B0 Integrity Sequence Extent */ + uint8_t lvd_pmaps[72]; /* 1B8 Partition Maps */ +}; +typedef struct log_vol_desc log_vol_desc_t; + + + + + +/* + * Unallocated Space Descriptor + * Contains information about the space + * that does not belong to any of the + * partition + */ +struct unall_spc_desc { + tag_t ua_tag; /* 00 Descriptor Tag */ + uint32_t ua_vdsn; /* 10 Volume Desc Seq Num */ + uint32_t ua_nad; /* 14 Number of Allocation Desc */ + uint8_t ua_al_dsc[488]; /* 18 Allocation Desc */ +}; +typedef struct unall_spc_desc unall_spc_desc_t; + + + + +/* + * Terminating Descriptor + * this will be the last in a Volume Descriptor Sequence + */ +struct term_desc { + tag_t td_tag; /* 00 Descriptor Tag */ + uint8_t td_res[496]; /* 10 Reserved */ +}; +typedef struct term_desc term_desc_t; + + +/* + * Logical Volume Header Descriptor + * This will be overlaid on lvid_lvcu + * and will contain the maximum value of + * unique id on the media + */ +struct log_vol_hdr_desc { + uint64_t lvhd_uniqid; /* 00 Unique Id */ + uint8_t lvhd_pad[24]; /* 08 reserved */ +}; +typedef struct log_vol_hdr_desc log_vol_hdr_desc_t; + +/* + * Logical Volume Integrity Sequence + * This will contain the integrity of the + * file system + */ +struct log_vol_int_desc { + tag_t lvid_tag; /* 00 Descriptor Tag */ + tstamp_t lvid_tstamp; /* 10 Recording Date and Time */ + uint32_t lvid_int_type; /* 1C Integrity Type */ + extent_ad_t lvid_nie; /* 20 Next Integrity Extent */ + /* uint8_t lvid_lvcu[32]; */ + log_vol_hdr_desc_t lvid_lvcu; /* 28 Logical Volume Contents Use */ + uint32_t lvid_npart; /* 48 Number of Partitions */ + uint32_t lvid_liu; /* 4C Length of Implementation Use */ + uint32_t lvid_fst[2]; /* 50 Free Space Table */ + /* Size Table */ + /* Implementation Use */ +}; +typedef struct log_vol_int_desc log_vol_int_desc_t; + +#define lvid_uniqid lvid_lvcu.lvhd_uniqid + + +#define LOG_VOL_OPEN_INT 0x00 +#define LOG_VOL_CLOSE_INT 0x01 + + +/* + * Logical Volume integrity Implementation Use + * This is defined in udf spec + */ +struct lvid_iu { + regid_t lvidiu_regid; /* 00 Implementation ID */ + uint32_t lvidiu_nfiles; /* 20 Number of Files */ + uint32_t lvidiu_ndirs; /* 24 Number of Directories */ + uint16_t lvidiu_mread; /* 28 Minimum UDF read revision */ + uint16_t lvidiu_mwrite; /* 2A Minimum UDF write revision */ + uint16_t lvidiu_maxwr; /* 2C Maximum UDF write revision */ +}; + + + + + + + +/* + * File Set Descriptor + * This will point to the root directory. + */ +struct file_set_desc { + tag_t fsd_tag; /* 00 Descriptor Tag */ + tstamp_t fsd_time; /* 10 Recording Date and Time */ + uint16_t fsd_ilevel; /* 1C Interchange Level */ + uint16_t fsd_mi_level; /* 1E Max Interchange Level */ + uint32_t fsd_cs_list; /* 20 Character Set List */ + uint32_t fsd_mcs_list; /* 24 Max Character Set List */ + uint32_t fsd_fs_no; /* 28 File Set Number */ + uint32_t fsd_fsd_no; /* 2C File Set Desc Number */ + charspec_t fsd_lvidcs; /* 30 Log Vol Id Char Set */ + char fsd_lvid[128]; /* 70 Log Vol Identifier */ + charspec_t fsd_fscs; /* F0 File Set Character Set */ + char fsd_fsi[32]; /* 130 File Set Identifier */ + char fsd_cfi[32]; /* 150 Copyright File Identifier */ + char fsd_afi[32]; /* 170 Abstract File identifier */ + long_ad_t fsd_root_icb; /* 190 Root Directory ICB */ + regid_t fsd_did; /* 1A0 Domain Identifier */ + long_ad_t fsd_next; /* 1C0 Next Extent */ + uint8_t fsd_res[48]; /* 1D0 Reserved */ +}; +typedef struct file_set_desc file_set_desc_t; + + + + + + + +/* + * File Identifier Descriptor + * Directory entries + */ +struct file_id { + tag_t fid_tag; /* 00 Descriptor Tag */ + uint16_t fid_ver; /* 10 File Version Number */ + uint8_t fid_flags; /* 12 File characteristics */ + uint8_t fid_idlen; /* 13 Length File Identifier */ + long_ad_t fid_icb; /* 14 ICB */ + uint16_t fid_iulen; /* 24 Length of Implmentation use */ + uint8_t fid_spec[2]; /* iulen for iu name and padding */ +}; +typedef struct file_id file_id_t; + +#define FID_EXIST 0x01 +#define FID_DIR 0x02 +#define FID_DELETED 0x04 +#define FID_PARENT 0x08 + + + + + + + +/* + * Allocation Extent Descriptor + */ +struct alloc_ext_desc { + tag_t aed_tag; /* 00 Descriptor Tag */ + uint32_t aed_rev_ael; /* 10 Previous Alloc Extent Location */ + uint32_t aed_len_aed; /* 14 Length of Allocation Desc */ +}; +typedef struct alloc_ext_desc alloc_ext_desc_t; + + + + + +/* + * Indirect Entry + * used to specify the address of another ICB + */ +struct indirect_entry { + tag_t ie_tag; /* 00 Descriptor Tag */ + icb_tag_t ie_icb_tag; /* 10 ICB tag */ + long_ad_t ie_indirecticb; /* 24 Indirect ICB */ +}; +typedef struct indirect_entry indirect_entry_t; + + + + +/* + * Terminal Entry + */ +struct term_entry { + tag_t te_tag; /* 00 Descriptor Tag */ + icb_tag_t te_icb_tag; /* 10 ICB tag */ +}; +typedef struct term_entry term_entry_t; + + + + +/* + * File entry describes the + * file attributes and location it is recorded on the media + */ +struct file_entry { + tag_t fe_tag; /* 00 Descriptor Tag */ + icb_tag_t fe_icb_tag; /* 10 ICB tag */ + uint32_t fe_uid; /* 24 Uid */ + uint32_t fe_gid; /* 28 Gid */ + uint32_t fe_perms; /* 2C Permissions */ + uint16_t fe_lcount; /* 30 File Link Count */ + uint8_t fe_rec_for; /* 32 Record Format */ + uint8_t fe_rec_dis; /* 33 Record Display Attributes */ + uint32_t fe_rec_len; /* 34 Record Length */ + uint64_t fe_info_len; /* 38 Information Length */ + uint64_t fe_lbr; /* 40 Logical Blocks recorded */ + tstamp_t fe_acc_time; /* 48 Access Data and Time */ + tstamp_t fe_mod_time; /* 54 Modification Data and Time */ + tstamp_t fe_attr_time; /* 60 Attribute Data and Time */ + uint32_t fe_ckpoint; /* 6C Checkpoint */ + long_ad_t fe_ea_icb; /* 70 Extended Attr ICB */ + regid_t fe_impl_id; /* 80 Implementation Identifier */ + uint64_t fe_uniq_id; /* A0 Unique Id */ + uint32_t fe_len_ear; /* A8 Length of Extended Attr */ + uint32_t fe_len_adesc; /* AC Length of Alloc Desc */ + char fe_spec[336]; /* B0 used for EA and AD's */ +}; +typedef struct file_entry file_entry_t; + + + + + +/* + * Extended Attribute Header + */ +struct ext_attr_hdr { + tag_t eah_tag; /* 00 Descriptor Tag */ + uint32_t eah_ial; /* 10 Implementation Attr Location */ + uint32_t eah_aal; /* 14 Application Attr Location */ +}; +typedef struct ext_attr_hdr ext_attr_hdr_t; + + + + + + + +/* + * Unallocated Space Entry + */ +struct unall_space_ent { + tag_t use_tag; /* 00 Descriptor Tag */ + icb_tag_t use_icb_tag; /* 10 ICB tag */ + uint32_t use_len_ad; /* 24 Lenght of Allocation desc */ + uint8_t use_ad[484]; /* 28 Allocation Descriptors */ +}; +typedef struct unall_space_ent unall_space_ent_t; + + + + + +/* + * Space Bitmap Descriptor + */ +struct space_bmap_desc { + tag_t sbd_tag; /* 00 Descriptor Tag */ + uint32_t sbd_nbits; /* 10 Number of Bits */ + uint32_t sbd_nbytes; /* 14 Number of Bytes */ + uint8_t sbd_bmap[500]; /* 18 Bitmap */ +}; +typedef struct space_bmap_desc space_bmap_desc_t; + + + + + +/* + * Partition Integrity entry + */ +struct part_int_desc { + tag_t pid_tag; /* 00 Descriptor Tag */ + icb_tag_t pid_idb_tag; /* 10 ICB tag */ + tstamp_t pid_rtime; /* 24 Recording Data and Time */ + uint8_t pid_integ; /* 30 Integrity type */ + uint8_t pid_res[175]; /* 31 Reserved */ + regid_t pid_ii; /* E0 Implementation Identifier */ + uint8_t pid_iu[256]; /* 100 Implementation Use */ +}; +typedef struct part_int_desc part_int_desc_t; + + +#define PART_OPEN_INT 0x00 +#define PART_CLOSE_INT 0x01 +#define PART_STABLE_INT 0x02 + + + + +struct attr_hdr { + uint32_t ahdr_atype; /* Attribute Type */ + uint8_t ahdr_astype; /* Attribute Subtype */ + uint8_t ahdr_res[3]; /* Reserved */ + uint32_t ahdr_length; /* Attribute Length */ + uint8_t ahdr_data[4]; /* Attribute Data */ +}; + +/* + * We will support and use the + * following Extended Attributes + * we will ignore others while reading + * and will preserve then when updating + * the EAR's + * In all the EA's we allocate the last member + * as 4 bytes. This is a sort of hack + * since the structure has to be + * properly alined to 4 bytes. + */ + +struct dev_spec_ear { + uint32_t ds_atype; /* 00 Attribute Type */ + uint8_t ds_astype; /* 04 Attribute Subtype */ + uint8_t ds_res[3]; /* 05 Reserved */ + uint32_t ds_attr_len; /* 08 Attrbute Length */ + uint32_t ds_iu_len; /* 0C Impl Use Length */ + uint32_t ds_major_id; /* 10 Major Device ID */ + uint32_t ds_minor_id; /* 14 Minor Device ID */ + uint8_t ds_iu[4]; /* 18 Implementation Use */ +}; + + +struct ftimes_ear { + uint32_t ft_atype; /* 00 Attribute Type */ + uint8_t ft_astype; /* 04 Attribute Subtype */ + uint8_t ft_res[3]; /* 05 Reserved */ + uint32_t ft_attr_len; /* 08 Attrbute Length */ + uint32_t ft_data_len; /* 0C Data Length */ + uint32_t ft_exist; /* 10 File Time Existence */ + uint8_t ft_ft[4]; /* 14 File Times */ +}; + +/* ft_exit */ +#define FT_EXIST 0x0 +#define FT_DELETE 0x2 +#define FT_FEDT 0x3 +#define FT_BACKUP 0x5 + +struct iu_ea { + uint32_t iuea_atype; /* 00 Attribute Type */ + uint8_t iuea_astype; /* 04 Attribute Subtype */ + uint8_t iuea_res[3]; /* 05 Reserved */ + uint32_t iuea_attr_len; /* 08 Attrbute Length */ + uint32_t iuea_iu_len; /* 0C Implementation Use Length */ + regid_t iuea_ii; /* 10 Implementation ID */ + uint8_t iuea_iu[4]; /* 30 Impl Use */ +}; + + +/* + * CGMS & FREE_SPACE will be + * over laid on iu_iu field + */ + +struct copy_mgt_info { + uint16_t cgms_cksum; /* Header Checksum */ + uint8_t cgms_info; /* CGMS Information */ + uint8_t cgms_dstype; /* Data Structure Type */ + uint32_t cgms_psi; /* Protection System Info */ +}; + +#define COPY_PROTECTED 0x80 + +struct FREE_SPACE { + uint16_t fs_cksum; /* Header Checksum */ + uint8_t fs_freesp[2]; /* Free EA space */ +}; + + + + +struct nsr_desc { + uint8_t nsr_str_type; + uint8_t nsr_id[5]; + uint8_t nsr_ver; + uint8_t nsr_res; + uint8_t nsr_data[2040]; +}; + + + +/* + * Partition Map + */ +struct pmap_hdr { + uint8_t maph_type; /* Partition Map Type */ + uint8_t maph_length; /* Partition Map Length */ +}; + +#define MAP_TYPE1 1 +#define MAP_TYPE2 2 + +#define MAP_TYPE1_LEN 6 +#define MAP_TYPE2_LEN 64 + +struct pmap_typ1 { + uint8_t map1_type; /* Map type == 1 */ + uint8_t map1_length; /* Map length == 6 */ + uint16_t map1_vsn; /* Volume Sequence Number */ + uint16_t map1_pn; /* Partition Number */ +}; + + +/* + * Only two types of type2 maps + * are supported they are + * *UDF Virtual Partition + * *UDF Sparable Partition + * For vpm fields till map2_pn + * are valid and the entire structure is + * valid for spm + */ +struct pmap_typ2 { + uint8_t map2_type; /* 00 Map type == 2 */ + uint8_t map2_length; /* 01 Map length == 64 */ + uint16_t map2_pad1; /* 02 Reserved */ + regid_t map2_pti; /* 04 Entiry ID */ + uint16_t map2_vsn; /* 24 Volume Sequence Number */ + uint16_t map2_pn; /* 26 Partition Number */ + uint16_t map2_pl; /* 28 Packet Length == 32 */ + uint8_t map2_nst; /* 2A Number of sparing tables */ + uint8_t map2_pad2; /* 2B Reserved */ + uint32_t map2_sest; /* 2C Size of each sparing table */ + uint32_t map2_st[4]; /* 30 sparing Tables */ +}; + + +struct stbl_entry { + uint32_t sent_ol; /* Original Location */ + uint32_t sent_ml; /* Mapped Location */ +}; + +typedef struct stbl_entry stbl_entry_t; + +struct stbl { + tag_t stbl_tag; /* 00 Tag */ + regid_t stbl_si; /* 10 Sparing Identifier */ + uint16_t stbl_len; /* 30 Reallocation Table Len */ + uint16_t stbl_res1; /* 32 Reserved */ + uint32_t stbl_seqno; /* 34 Sequence Number */ + stbl_entry_t stbl_entry; /* 38 Sparing Table Entries */ +}; + +struct path_comp { + uint8_t pc_type; /* Component Type */ + uint8_t pc_len; /* Length of Component ID */ + uint16_t pc_ver; /* Component File Version Number */ + uint8_t pc_id[4]; /* Component ID */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UDF_VOLUME_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_acl.h b/illumos-x86_64/usr/include/sys/fs/ufs_acl.h new file mode 100644 index 00000000..a3733840 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_acl.h @@ -0,0 +1,203 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_FS_UFS_ACL_H +#define _SYS_FS_UFS_ACL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * On-disk UFS ACL structure + */ + +typedef struct ufs_acl { + union { + uint32_t acl_next; /* Pad for old structure */ + ushort_t acl_tag; /* Entry type */ + } acl_un; + o_mode_t acl_perm; /* Permission bits */ + uid_t acl_who; /* User or group ID */ +} ufs_acl_t; + +#define acl_tag acl_un.acl_tag +#define acl_next acl_un.acl_next + +/* + * In-core UFS ACL structure + */ + +typedef struct ufs_ic_acl { + struct ufs_ic_acl *acl_ic_next; /* Next ACL for this inode */ + o_mode_t acl_ic_perm; /* Permission bits */ + uid_t acl_ic_who; /* User or group ID */ +} ufs_ic_acl_t; + +/* + * In-core ACL mask + */ +typedef struct ufs_aclmask { + short acl_ismask; /* Is mask defined? */ + o_mode_t acl_maskbits; /* Permission mask */ +} ufs_aclmask_t; + +/* + * full acl + */ +typedef struct ic_acl { + ufs_ic_acl_t *owner; /* owner object */ + ufs_ic_acl_t *group; /* group object */ + ufs_ic_acl_t *other; /* other object */ + ufs_ic_acl_t *users; /* list of users */ + ufs_ic_acl_t *groups; /* list of groups */ + ufs_aclmask_t mask; /* mask */ +} ic_acl_t; + +/* + * In-core shadow inode + */ +typedef struct si { + struct si *s_next; /* signature hash next */ + struct si *s_forw; /* inode hash next */ + struct si *s_fore; /* unref'd list next */ + + int s_flags; /* see below */ + ino_t s_shadow; /* shadow inode number */ + dev_t s_dev; /* device (major,minor) */ + int s_signature; /* signature for all ACLs */ + int s_use; /* on disk use count */ + int s_ref; /* in core reference count */ + krwlock_t s_lock; /* lock for this structure */ + + ic_acl_t s_a; /* acls */ + ic_acl_t s_d; /* def acls */ +} si_t; + +#define aowner s_a.owner +#define agroup s_a.group +#define aother s_a.other +#define ausers s_a.users +#define agroups s_a.groups +#define aclass s_a.mask + +#define downer s_d.owner +#define dgroup s_d.group +#define dother s_d.other +#define dusers s_d.users +#define dgroups s_d.groups +#define dclass s_d.mask + +#define s_prev s_forw + +/* + * s_flags + */ +#define SI_CACHED 0x0001 /* Is in si_cache */ + +/* + * Header to identify data on disk + */ +typedef struct ufs_fsd { + int fsd_type; /* type of data */ + int fsd_size; /* size in bytes of ufs_fsd and data */ + char fsd_data[1]; /* data */ +} ufs_fsd_t; + +/* + * Data types (fsd_type) + */ +#define FSD_FREE (0) /* Free entry */ +#define FSD_ACL (1) /* Access Control Lists */ +#define FSD_DFACL (2) /* reserved for future use */ +#define FSD_RESERVED3 (3) /* reserved for future use */ +#define FSD_RESERVED4 (4) /* reserved for future use */ +#define FSD_RESERVED5 (5) /* reserved for future use */ +#define FSD_RESERVED6 (6) /* reserved for future use */ +#define FSD_RESERVED7 (7) /* reserved for future use */ + +/* + * FSD manipulation macros + * The FSD macros are aligned on integer boundary even if the preceeding + * record had a byte aligned length. So the record length is always + * integer length. All increments of the data pointers must use the + * FSD_RECSZ macro. + */ +#define FSD_TPSZ(fsdp) (sizeof (fsdp->fsd_type)) +#define FSD_TPMSK(fsdp) (FSD_TPSZ(fsdp) - 1) +#define FSD_RECSZ(fsdp, size) ((size + FSD_TPMSK(fsdp)) & ~FSD_TPMSK(fsdp)) +/* + * flags for acl_validate + */ +#define ACL_CHECK 0x01 +#define DEF_ACL_CHECK 0x02 + +#define MODE_CHECK(O, M, PERM, C, I) \ + secpolicy_vnode_access2(C, ITOV(I), O, (PERM), M) + +/* + * Check that the file type is one that accepts ACLs + */ +#define CHECK_ACL_ALLOWED(MODE) (((MODE) == IFDIR) || ((MODE) == IFREG) || \ + ((MODE) == IFIFO) || ((MODE) == IFCHR) || \ + ((MODE) == IFBLK) || ((MODE) == IFATTRDIR)) + +/* + * Get ACL group permissions if the mask is not present, and the ACL + * group permission intersected with the mask if the mask is present + */ +#define MASK2MODE(ACL) \ + ((ACL)->aclass.acl_ismask ? \ + ((((ACL)->aclass.acl_maskbits & \ + (ACL)->agroup->acl_ic_perm) & 07) << 3) : \ + (((ACL)->agroup->acl_ic_perm & 07) << 3)) + +#define MODE2ACL(P, MODE, CRED) \ + ASSERT((P)); \ + (P)->acl_ic_next = NULL; \ + (P)->acl_ic_perm &= ((MODE) & 7); \ + (P)->acl_ic_who = (CRED); + +#define ACL_MOVE(P, T, B) \ +{ \ + ufs_ic_acl_t *acl; \ + for (acl = (P); acl; acl = acl->acl_ic_next) { \ + (B)->acl_tag = (T); \ + (B)->acl_perm = acl->acl_ic_perm; \ + (B)->acl_who = acl->acl_ic_who; \ + (B)++; \ + } \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_ACL_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_bio.h b/illumos-x86_64/usr/include/sys/fs/ufs_bio.h new file mode 100644 index 00000000..06df6f68 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_bio.h @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997,2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FS_UFS_BIO_H +#define _SYS_FS_UFS_BIO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Statistics on ufs buffer cache + * Not protected by locks + */ +struct ufsbiostats { + kstat_named_t ub_breads; /* ufs_bread */ + kstat_named_t ub_bwrites; /* ufs_bwrite and ufs_bwrite2 */ + kstat_named_t ub_fbiwrites; /* ufs_fbiwrite */ + kstat_named_t ub_getpages; /* ufs_getpage_miss */ + kstat_named_t ub_getras; /* ufs_getpage_ra */ + kstat_named_t ub_putsyncs; /* ufs_putapage (B_SYNC) */ + kstat_named_t ub_putasyncs; /* ufs_putapage (B_ASYNC) */ + kstat_named_t ub_pageios; /* ufs_pageios (swap) */ +}; + +extern struct ufsbiostats ub; + +#if defined(_KERNEL) + +/* + * let's define macros for the ufs_bio calls (as they were originally + * defined name-wise). using these macros to access the appropriate + * *_common routines to minimize subroutine calls. + */ +extern struct buf *bread_common(void *arg, dev_t dev, + daddr_t blkno, long bsize); +extern void bwrite_common(void *arg, struct buf *bp, int force_wait, + int do_relse, int clear_flags); +extern struct buf *getblk_common(void * arg, dev_t dev, + daddr_t blkno, long bsize, int flag); + +#define UFS_BREAD(ufsvfsp, dev, blkno, bsize) \ + bread_common(ufsvfsp, dev, blkno, bsize) +#define UFS_BWRITE(ufsvfsp, bp) \ + bwrite_common(ufsvfsp, bp, /* force_wait */ 0, /* do_relse */ 1, \ + /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)) +#define UFS_BRWRITE(ufsvfsp, bp) \ + (bp)->b_flags |= B_RETRYWRI; \ + bwrite_common(ufsvfsp, bp, /* force_wait */ 0, /* do_relse */ 1, \ + /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)) +#define UFS_BWRITE2(ufsvfsp, bp) \ + bwrite_common(ufsvfsp, bp, /* force_wait */ 1, /* do_relse */ 0, \ + /* clear_flags */ (B_READ | B_DONE | B_ERROR | B_DELWRI)) +#define UFS_GETBLK(ufsvfsp, dev, blkno, bsize) \ + getblk_common(ufsvfsp, dev, blkno, bsize, /* errflg */ 0) + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_BIO_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_filio.h b/illumos-x86_64/usr/include/sys/fs/ufs_filio.h new file mode 100644 index 00000000..127a1972 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_filio.h @@ -0,0 +1,113 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_UFS_FILIO_H +#define _SYS_FS_UFS_FILIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * _FIOIO + * + * struct for _FIOIO ioctl(): + * Input: + * fio_ino - inode number + * fio_gen - generation number + * Output: + * fio_fd - readonly file descriptor + * + */ + +struct fioio { + ino_t fio_ino; /* input : inode number */ + int fio_gen; /* input : generation number */ + int fio_fd; /* output: readonly file descriptor */ +}; + +#if defined(_SYSCALL32) + +struct fioio32 { + ino32_t fio_ino; /* input : inode number */ + int32_t fio_gen; /* input : generation number */ + int32_t fio_fd; /* output: readonly file descriptor */ +}; + +#endif /* _SYSCALL32 */ + +/* + * _FIOTUNE + */ +struct fiotune { + int maxcontig; /* cluster and directio size */ + int rotdelay; /* skip blocks between contig allocations */ + int maxbpg; /* currently defaults to 2048 */ + int minfree; /* %age to reserve for root */ + int optim; /* space or time */ +}; + +/* + * UFS Logging + */ +typedef struct fiolog { + uint_t nbytes_requested; + uint_t nbytes_actual; + int error; +} fiolog_t; + +#define FIOLOG_ENONE 0 +#define FIOLOG_ETRANS 1 +#define FIOLOG_EROFS 2 +#define FIOLOG_EULOCK 3 +#define FIOLOG_EWLOCK 4 +#define FIOLOG_ECLEAN 5 +#define FIOLOG_ENOULOCK 6 + +#if defined(_KERNEL) + +extern int ufs_fiosatime(struct vnode *, struct timeval *, int, + struct cred *); +extern int ufs_fiosdio(struct vnode *, uint_t *, int flag, struct cred *); +extern int ufs_fiogdio(struct vnode *, uint_t *, int flag, struct cred *); +extern int ufs_fioio(struct vnode *, struct fioio *, int, struct cred *); +extern int ufs_fioisbusy(struct vnode *, int *, struct cred *); +extern int ufs_fiodirectio(struct vnode *, int, struct cred *); +extern int ufs_fiotune(struct vnode *, struct fiotune *, struct cred *); +extern int ufs_fiologenable(vnode_t *, fiolog_t *, cred_t *, int); +extern int ufs_fiologdisable(vnode_t *, fiolog_t *, cred_t *, int); +extern int ufs_fioislog(vnode_t *, uint32_t *, cred_t *, int); +extern int ufs_fio_holey(vnode_t *, int, offset_t *); +extern int ufs_mark_compressed(struct vnode *vp); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_FILIO_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_fs.h b/illumos-x86_64/usr/include/sys/fs/ufs_fs.h new file mode 100644 index 00000000..0b85014f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_fs.h @@ -0,0 +1,799 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_FS_UFS_FS_H +#define _SYS_FS_UFS_FS_H + +#include +#include +#include /* for kmutex_t */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following values are minor release values for UFS. + * The fs_version field in the superblock will equal one of them. + */ + +#define MTB_UFS_VERSION_MIN 1 +#define MTB_UFS_VERSION_1 1 +#define UFS_VERSION_MIN 0 +#define UFS_EFISTYLE4NONEFI_VERSION_2 2 + +/* + * Each disk drive contains some number of file systems. + * A file system consists of a number of cylinder groups. + * Each cylinder group has inodes and data. + * + * A file system is described by its super-block, which in turn + * describes the cylinder groups. The super-block is critical + * data and is replicated in the first 10 cylinder groups and the + * the last 10 cylinder groups to protect against + * catastrophic loss. This is done at mkfs time and the critical + * super-block data does not change, so the copies need not be + * referenced further unless disaster strikes. + * + * For file system fs, the offsets of the various blocks of interest + * are given in the super block as: + * [fs->fs_sblkno] Super-block + * [fs->fs_cblkno] Cylinder group block + * [fs->fs_iblkno] Inode blocks + * [fs->fs_dblkno] Data blocks + * The beginning of cylinder group cg in fs, is given by + * the ``cgbase(fs, cg)'' macro. + * + * The first boot and super blocks are given in absolute disk addresses. + * The byte-offset forms are preferred, as they don't imply a sector size. + */ +#define BBSIZE 8192 +#define SBSIZE 8192 +#define BBOFF ((off_t)(0)) +#define SBOFF ((off_t)(BBOFF + BBSIZE)) +#define BBLOCK ((daddr32_t)(0)) +#define SBLOCK ((daddr32_t)(BBLOCK + BBSIZE / DEV_BSIZE)) + +/* + * Addresses stored in inodes are capable of addressing fragments + * of `blocks'. File system blocks of at most size MAXBSIZE can + * be optionally broken into 2, 4, or 8 pieces, each of which is + * addressible; these pieces may be DEV_BSIZE, or some multiple of + * a DEV_BSIZE unit. + * + * Large files consist of exclusively large data blocks. To avoid + * undue wasted disk space, the last data block of a small file may be + * allocated as only as many fragments of a large block as are + * necessary. The file system format retains only a single pointer + * to such a fragment, which is a piece of a single large block that + * has been divided. The size of such a fragment is determinable from + * information in the inode, using the ``blksize(fs, ip, lbn)'' macro. + * + * The file system records space availability at the fragment level; + * to determine block availability, aligned fragments are examined. + * + * The root inode is the root of the file system. + * Inode 0 can't be used for normal purposes and + * historically bad blocks were linked to inode 1, + * thus the root inode is 2. (inode 1 is no longer used for + * this purpose, however numerous dump tapes make this + * assumption, so we are stuck with it) + * The lost+found directory is given the next available + * inode when it is created by ``mkfs''. + */ +#define UFSROOTINO ((ino_t)2) /* i number of all roots */ +#define LOSTFOUNDINO (UFSROOTINO + 1) +#ifndef _LONGLONG_TYPE +#define UFS_MAXOFFSET_T MAXOFF_T +#define UFS_FILESIZE_BITS 32 +#else +#define UFS_MAXOFFSET_T ((1LL << NBBY * sizeof (daddr32_t) + DEV_BSHIFT - 1) \ + - 1) +#define UFS_FILESIZE_BITS 41 +#endif /* _LONGLONG_TYPE */ + +/* + * MINBSIZE is the smallest allowable block size. + * In order to insure that it is possible to create files of size + * 2^32 with only two levels of indirection, MINBSIZE is set to 4096. + * MINBSIZE must be big enough to hold a cylinder group block, + * thus changes to (struct cg) must keep its size within MINBSIZE. + * Note that super blocks are always of size SBSIZE, + * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE. + */ +#define MINBSIZE 4096 + +/* + * The path name on which the file system is mounted is maintained + * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in + * the super block for this name. + * The limit on the amount of summary information per file system + * is defined by MAXCSBUFS. It is currently parameterized for a + * maximum of two million cylinders. + */ +#define MAXMNTLEN 512 +#define MAXCSBUFS 32 + +#define LABEL_TYPE_VTOC 1 +#define LABEL_TYPE_EFI 2 +#define LABEL_TYPE_OTHER 3 + +/* + * The following constant is taken from the ANSI T13 ATA Specification + * and defines the maximum size (in sectors) that an ATA disk can be + * and still has to provide CHS translation. For a disk above this + * size all sectors are to be accessed via their LBA address. This + * makes a good cut off value to move from disk provided geometry + * to the predefined defaults used in efi label disks. + */ +#define CHSLIMIT (63 * 256 * 1024) + +/* + * Per cylinder group information; summarized in blocks allocated + * from first cylinder group data blocks. These blocks have to be + * read in from fs_csaddr (size fs_cssize) in addition to the + * super block. + * + * N.B. sizeof (struct csum) must be a power of two in order for + * the ``fs_cs'' macro to work (see below). + */ +struct csum { + int32_t cs_ndir; /* number of directories */ + int32_t cs_nbfree; /* number of free blocks */ + int32_t cs_nifree; /* number of free inodes */ + int32_t cs_nffree; /* number of free frags */ +}; + +/* + * In the 5.0 release, the file system state flag in the superblock (fs_clean) + * is now used. The value of fs_clean can be: + * FSACTIVE file system may have fsck inconsistencies + * FSCLEAN file system has successfully unmounted (implies + * everything is ok) + * FSSTABLE No fsck inconsistencies, no guarantee on user data + * FSBAD file system is mounted from a partition that is + * neither FSCLEAN or FSSTABLE + * FSSUSPEND Clean flag processing is temporarily disabled + * FSLOG Logging file system + * Under this scheme, fsck can safely skip file systems that + * are FSCLEAN or FSSTABLE. To provide additional safeguard, + * fs_clean information could be trusted only if + * fs_state == FSOKAY - fs_time, where FSOKAY is a constant + * + * Note: mount(2) will now return ENOSPC if fs_clean is neither FSCLEAN nor + * FSSTABLE, or fs_state is not valid. The exceptions are the root or + * the read-only partitions + */ + +/* + * Super block for a file system. + * + * Most of the data in the super block is read-only data and needs + * no explicit locking to protect it. Exceptions are: + * fs_time + * fs_optim + * fs_cstotal + * fs_fmod + * fs_cgrotor + * fs_flags (largefiles flag - set when a file grows large) + * These fields require the use of fs->fs_lock. + */ +#define FS_MAGIC 0x011954 +#define MTB_UFS_MAGIC 0xdecade +#define FSOKAY (0x7c269d38) +/* #define FSOKAY (0x7c269d38 + 3) */ +/* + * fs_clean values + */ +#define FSACTIVE ((char)0) +#define FSCLEAN ((char)0x1) +#define FSSTABLE ((char)0x2) +#define FSBAD ((char)0xff) /* mounted !FSCLEAN and !FSSTABLE */ +#define FSSUSPEND ((char)0xfe) /* temporarily suspended */ +#define FSLOG ((char)0xfd) /* logging fs */ +#define FSFIX ((char)0xfc) /* being repaired while mounted */ + +/* + * fs_flags values + */ +#define FSLARGEFILES ((char)0x1) /* largefiles exist on filesystem */ + +struct fs { + uint32_t fs_link; /* linked list of file systems */ + uint32_t fs_rolled; /* logging only: fs fully rolled */ + daddr32_t fs_sblkno; /* addr of super-block in filesys */ + daddr32_t fs_cblkno; /* offset of cyl-block in filesys */ + daddr32_t fs_iblkno; /* offset of inode-blocks in filesys */ + daddr32_t fs_dblkno; /* offset of first data after cg */ + int32_t fs_cgoffset; /* cylinder group offset in cylinder */ + int32_t fs_cgmask; /* used to calc mod fs_ntrak */ + time32_t fs_time; /* last time written */ + int32_t fs_size; /* number of blocks in fs */ + int32_t fs_dsize; /* number of data blocks in fs */ + int32_t fs_ncg; /* number of cylinder groups */ + int32_t fs_bsize; /* size of basic blocks in fs */ + int32_t fs_fsize; /* size of frag blocks in fs */ + int32_t fs_frag; /* number of frags in a block in fs */ +/* these are configuration parameters */ + int32_t fs_minfree; /* minimum percentage of free blocks */ + int32_t fs_rotdelay; /* num of ms for optimal next block */ + int32_t fs_rps; /* disk revolutions per second */ +/* these fields can be computed from the others */ + int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */ + int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */ + int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */ + int32_t fs_fshift; /* ``numfrags'' calc number of frags */ +/* these are configuration parameters */ + int32_t fs_maxcontig; /* max number of contiguous blks */ + int32_t fs_maxbpg; /* max number of blks per cyl group */ +/* these fields can be computed from the others */ + int32_t fs_fragshift; /* block to frag shift */ + int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t fs_sbsize; /* actual size of super block */ + int32_t fs_csmask; /* csum block offset */ + int32_t fs_csshift; /* csum block number */ + int32_t fs_nindir; /* value of NINDIR */ + int32_t fs_inopb; /* value of INOPB */ + int32_t fs_nspf; /* value of NSPF */ +/* yet another configuration parameter */ + int32_t fs_optim; /* optimization preference, see below */ +/* these fields are derived from the hardware */ + /* USL SVR4 compatibility */ +#ifdef _LITTLE_ENDIAN + /* + * USL SVR4 compatibility + * + * There was a significant divergence here between Solaris and + * SVR4 for x86. By swapping these two members in the superblock, + * we get read-only compatibility of SVR4 filesystems. Otherwise + * there would be no compatibility. This change was introduced + * during bootstrapping of Solaris on x86. By making this ifdef'ed + * on byte order, we provide ongoing compatibility across all + * platforms with the same byte order, the highest compatibility + * that can be achieved. + */ + int32_t fs_state; /* file system state time stamp */ +#else + int32_t fs_npsect; /* # sectors/track including spares */ +#endif + int32_t fs_si; /* summary info state - lufs only */ + int32_t fs_trackskew; /* sector 0 skew, per track */ +/* a unique id for this filesystem (currently unused and unmaintained) */ +/* In 4.3 Tahoe this space is used by fs_headswitch and fs_trkseek */ +/* Neither of those fields is used in the Tahoe code right now but */ +/* there could be problems if they are. */ + int32_t fs_id[2]; /* file system id */ +/* sizes determined by number of cylinder groups and their sizes */ + daddr32_t fs_csaddr; /* blk addr of cyl grp summary area */ + int32_t fs_cssize; /* size of cyl grp summary area */ + int32_t fs_cgsize; /* cylinder group size */ +/* these fields are derived from the hardware */ + int32_t fs_ntrak; /* tracks per cylinder */ + int32_t fs_nsect; /* sectors per track */ + int32_t fs_spc; /* sectors per cylinder */ +/* this comes from the disk driver partitioning */ + int32_t fs_ncyl; /* cylinders in file system */ +/* these fields can be computed from the others */ + int32_t fs_cpg; /* cylinders per group */ + int32_t fs_ipg; /* inodes per group */ + int32_t fs_fpg; /* blocks per group * fs_frag */ +/* this data must be re-computed after crashes */ + struct csum fs_cstotal; /* cylinder summary information */ +/* these fields are cleared at mount time */ + char fs_fmod; /* super block modified flag */ + char fs_clean; /* file system state flag */ + char fs_ronly; /* mounted read-only flag */ + char fs_flags; /* largefiles flag, etc. */ + char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ +/* these fields retain the current block allocation info */ + int32_t fs_cgrotor; /* last cg searched */ + /* + * The following used to be fs_csp[MAXCSBUFS]. It was not + * used anywhere except in old utilities. We removed this + * in 5.6 and expect fs_u.fs_csp to be used instead. + * We no longer limit fs_cssize based on MAXCSBUFS. + */ + union { /* fs_cs (csum) info */ + uint32_t fs_csp_pad[MAXCSBUFS]; + struct csum *fs_csp; + } fs_u; + int32_t fs_cpc; /* cyl per cycle in postbl */ + short fs_opostbl[16][8]; /* old rotation block list head */ + int32_t fs_sparecon[51]; /* reserved for future constants */ + int32_t fs_version; /* minor version of ufs */ + int32_t fs_logbno; /* block # of embedded log */ + int32_t fs_reclaim; /* reclaim open, deleted files */ + int32_t fs_sparecon2; /* reserved for future constant */ +#ifdef _LITTLE_ENDIAN + /* USL SVR4 compatibility */ + int32_t fs_npsect; /* # sectors/track including spares */ +#else + int32_t fs_state; /* file system state time stamp */ +#endif + quad_t fs_qbmask; /* ~fs_bmask - for use with quad size */ + quad_t fs_qfmask; /* ~fs_fmask - for use with quad size */ + int32_t fs_postblformat; /* format of positional layout tables */ + int32_t fs_nrpos; /* number of rotaional positions */ + int32_t fs_postbloff; /* (short) rotation block list head */ + int32_t fs_rotbloff; /* (uchar_t) blocks for each rotation */ + int32_t fs_magic; /* magic number */ + uchar_t fs_space[1]; /* list of blocks for each rotation */ +/* actually longer */ +}; + +/* + * values for fs_reclaim + */ +#define FS_RECLAIM (0x00000001) /* run the reclaim-files thread */ +#define FS_RECLAIMING (0x00000002) /* running the reclaim-files thread */ +#define FS_CHECKCLEAN (0x00000004) /* checking for a clean file system */ +#define FS_CHECKRECLAIM (0x00000008) /* checking for a reclaimable file */ + +/* + * values for fs_rolled + */ +#define FS_PRE_FLAG 0 /* old system, prior to fs_rolled flag */ +#define FS_ALL_ROLLED 1 +#define FS_NEED_ROLL 2 + +/* + * values for fs_si, logging only + * si is the summary of the summary - a copy of the cylinder group summary + * info held in an array for perf. On a mount if this is out of date + * (FS_SI_BAD) it can be re-constructed by re-reading the cgs. + */ +#define FS_SI_OK 0 /* on-disk summary info ok */ +#define FS_SI_BAD 1 /* out of date on-disk si */ + +/* + * Preference for optimization. + */ +#define FS_OPTTIME 0 /* minimize allocation time */ +#define FS_OPTSPACE 1 /* minimize disk fragmentation */ + +/* + * Rotational layout table format types + */ +#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */ +#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */ + +/* + * Macros for access to superblock array structures + */ +#ifdef _KERNEL +#define fs_postbl(ufsvfsp, cylno) \ + (((ufsvfsp)->vfs_fs->fs_postblformat != FS_DYNAMICPOSTBLFMT) \ + ? ((ufsvfsp)->vfs_fs->fs_opostbl[cylno]) \ + : ((short *)((char *)(ufsvfsp)->vfs_fs + \ + (ufsvfsp)->vfs_fs->fs_postbloff) \ + + (cylno) * (ufsvfsp)->vfs_nrpos)) +#else +#define fs_postbl(fs, cylno) \ + (((fs)->fs_postblformat != FS_DYNAMICPOSTBLFMT) \ + ? ((fs)->fs_opostbl[cylno]) \ + : ((short *)((char *)(fs) + \ + (fs)->fs_postbloff) \ + + (cylno) * (fs)->fs_nrpos)) +#endif + +#define fs_rotbl(fs) \ + (((fs)->fs_postblformat != FS_DYNAMICPOSTBLFMT) \ + ? ((fs)->fs_space) \ + : ((uchar_t *)((char *)(fs) + (fs)->fs_rotbloff))) + +/* + * Convert cylinder group to base address of its global summary info. + * + * N.B. This macro assumes that sizeof (struct csum) is a power of two. + * We just index off the first entry into one big array + */ + +#define fs_cs(fs, indx) fs_u.fs_csp[(indx)] + +/* + * Cylinder group block for a file system. + * + * Writable fields in the cylinder group are protected by the associated + * super block lock fs->fs_lock. + */ +#define CG_MAGIC 0x090255 +struct cg { + uint32_t cg_link; /* NOT USED linked list of cyl groups */ + int32_t cg_magic; /* magic number */ + time32_t cg_time; /* time last written */ + int32_t cg_cgx; /* we are the cgx'th cylinder group */ + short cg_ncyl; /* number of cyl's this cg */ + short cg_niblk; /* number of inode blocks this cg */ + int32_t cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + int32_t cg_rotor; /* position of last used block */ + int32_t cg_frotor; /* position of last used frag */ + int32_t cg_irotor; /* position of last used inode */ + int32_t cg_frsum[MAXFRAG]; /* counts of available frags */ + int32_t cg_btotoff; /* (int32_t)block totals per cylinder */ + int32_t cg_boff; /* (short) free block positions */ + int32_t cg_iusedoff; /* (char) used inode map */ + int32_t cg_freeoff; /* (uchar_t) free block map */ + int32_t cg_nextfreeoff; /* (uchar_t) next available space */ + int32_t cg_sparecon[16]; /* reserved for future use */ + uchar_t cg_space[1]; /* space for cylinder group maps */ +/* actually longer */ +}; + +/* + * Macros for access to cylinder group array structures + */ + +#define cg_blktot(cgp) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_btot) \ + : ((int32_t *)((char *)(cgp) + (cgp)->cg_btotoff))) + +#ifdef _KERNEL +#define cg_blks(ufsvfsp, cgp, cylno) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_b[cylno]) \ + : ((short *)((char *)(cgp) + (cgp)->cg_boff) + \ + (cylno) * (ufsvfsp)->vfs_nrpos)) +#else +#define cg_blks(fs, cgp, cylno) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_b[cylno]) \ + : ((short *)((char *)(cgp) + (cgp)->cg_boff) + \ + (cylno) * (fs)->fs_nrpos)) +#endif + +#define cg_inosused(cgp) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_iused) \ + : ((char *)((char *)(cgp) + (cgp)->cg_iusedoff))) + +#define cg_blksfree(cgp) \ + (((cgp)->cg_magic != CG_MAGIC) \ + ? (((struct ocg *)(cgp))->cg_free) \ + : ((uchar_t *)((char *)(cgp) + (cgp)->cg_freeoff))) + +#define cg_chkmagic(cgp) \ + ((cgp)->cg_magic == CG_MAGIC || \ + ((struct ocg *)(cgp))->cg_magic == CG_MAGIC) + +/* + * The following structure is defined + * for compatibility with old file systems. + */ +struct ocg { + uint32_t cg_link; /* NOT USED linked list of cyl groups */ + uint32_t cg_rlink; /* NOT USED incore cyl groups */ + time32_t cg_time; /* time last written */ + int32_t cg_cgx; /* we are the cgx'th cylinder group */ + short cg_ncyl; /* number of cyl's this cg */ + short cg_niblk; /* number of inode blocks this cg */ + int32_t cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + int32_t cg_rotor; /* position of last used block */ + int32_t cg_frotor; /* position of last used frag */ + int32_t cg_irotor; /* position of last used inode */ + int32_t cg_frsum[8]; /* counts of available frags */ + int32_t cg_btot[32]; /* block totals per cylinder */ + short cg_b[32][8]; /* positions of free blocks */ + char cg_iused[256]; /* used inode map */ + int32_t cg_magic; /* magic number */ + uchar_t cg_free[1]; /* free block map */ +/* actually longer */ +}; + +/* + * Turn frag offsets into disk block addresses. + * This maps frags to device size blocks. + * (In the names of these macros, "fsb" refers to "frags", not + * file system blocks.) + */ +#ifdef KERNEL +#define fsbtodb(fs, b) (((daddr_t)(b)) << (fs)->fs_fsbtodb) +#else /* KERNEL */ +#define fsbtodb(fs, b) (((diskaddr_t)(b)) << (fs)->fs_fsbtodb) +#endif /* KERNEL */ + +#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb) + +/* + * Get the offset of the log, in either sectors, frags, or file system + * blocks. The interpretation of the fs_logbno field depends on whether + * this is UFS or MTB UFS. (UFS stores the value as sectors. MTBUFS + * stores the value as frags.) + */ + +#ifdef KERNEL +#define logbtodb(fs, b) ((fs)->fs_magic == FS_MAGIC ? \ + (daddr_t)(b) : ((daddr_t)(b) << (fs)->fs_fsbtodb)) +#else /* KERNEL */ +#define logbtodb(fs, b) ((fs)->fs_magic == FS_MAGIC ? \ + (diskaddr_t)(b) : ((diskaddr_t)(b) << (fs)->fs_fsbtodb)) +#endif /* KERNEL */ +#define logbtofrag(fs, b) ((fs)->fs_magic == FS_MAGIC ? \ + (b) >> (fs)->fs_fsbtodb : (b)) +#define logbtofsblk(fs, b) ((fs)->fs_magic == FS_MAGIC ? \ + (b) >> ((fs)->fs_fsbtodb + (fs)->fs_fragshift) : \ + (b) >> (fs)->fs_fragshift) + +/* + * Cylinder group macros to locate things in cylinder groups. + * They calc file system addresses of cylinder group data structures. + */ +#define cgbase(fs, c) ((daddr32_t)((fs)->fs_fpg * (c))) + +#define cgstart(fs, c) \ + (cgbase(fs, c) + (fs)->fs_cgoffset * ((c) & ~((fs)->fs_cgmask))) + +#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ + +#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */ + +#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ + +#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ + +/* + * Macros for handling inode numbers: + * inode number to file system block offset. + * inode number to cylinder group number. + * inode number to file system block address. + */ +#define itoo(fs, x) ((x) % (uint32_t)INOPB(fs)) + +#define itog(fs, x) ((x) / (uint32_t)(fs)->fs_ipg) + +#define itod(fs, x) \ + ((daddr32_t)(cgimin(fs, itog(fs, x)) + \ + (blkstofrags((fs), (((x)%(ulong_t)(fs)->fs_ipg)/(ulong_t)INOPB(fs)))))) + +/* + * Give cylinder group number for a file system block. + * Give cylinder group block number for a file system block. + */ +#define dtog(fs, d) ((d) / (fs)->fs_fpg) +#define dtogd(fs, d) ((d) % (fs)->fs_fpg) + +/* + * Extract the bits for a block from a map. + * Compute the cylinder and rotational position of a cyl block addr. + */ +#define blkmap(fs, map, loc) \ + (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & \ + (0xff >> (NBBY - (fs)->fs_frag))) + +#define cbtocylno(fs, bno) \ + ((bno) * NSPF(fs) / (fs)->fs_spc) + +#ifdef _KERNEL +#define cbtorpos(ufsvfsp, bno) \ + ((((bno) * NSPF((ufsvfsp)->vfs_fs) % (ufsvfsp)->vfs_fs->fs_spc) % \ + (ufsvfsp)->vfs_fs->fs_nsect) * \ + (ufsvfsp)->vfs_nrpos) / (ufsvfsp)->vfs_fs->fs_nsect +#else +#define cbtorpos(fs, bno) \ + ((((bno) * NSPF(fs) % (fs)->fs_spc) % \ + (fs)->fs_nsect) * \ + (fs)->fs_nrpos) / (fs)->fs_nsect +#endif + +/* + * The following macros optimize certain frequently calculated + * quantities by using shifts and masks in place of divisions + * modulos and multiplications. + */ + +/* + * This macro works for 40 bit offset support in ufs because + * this calculates offset in the block and therefore no loss of + * information while casting to int. + */ + +#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \ + ((int)((loc) & ~(fs)->fs_bmask)) + +/* + * This macro works for 40 bit offset support similar to blkoff + */ + +#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \ + ((int)((loc) & ~(fs)->fs_fmask)) + +/* + * The cast to int32_t does not result in any loss of information because + * the number of logical blocks in the file system is limited to + * what fits in an int32_t anyway. + */ + +#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \ + ((int32_t)((loc) >> (fs)->fs_bshift)) + +/* + * The same argument as above applies here. + */ + +#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \ + ((int32_t)((loc) >> (fs)->fs_fshift)) + +/* + * Size can be a 64-bit value and therefore we sign extend fs_bmask + * to a 64-bit value too so that the higher 32 bits are masked + * properly. Note that the type of fs_bmask has to be signed. Otherwise + * compiler will set the higher 32 bits as zero and we don't want + * this to happen. + */ + +#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \ + (((size) + (fs)->fs_bsize - 1) & (offset_t)(fs)->fs_bmask) + +/* + * Same argument as above. + */ + +#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \ + (((size) + (fs)->fs_fsize - 1) & (offset_t)(fs)->fs_fmask) + +/* + * frags cannot exceed 32-bit value since we only support 40bit sizes. + */ + +#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \ + ((frags) >> (fs)->fs_fragshift) + +#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \ + ((blks) << (fs)->fs_fragshift) + +#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \ + ((fsb) & ((fs)->fs_frag - 1)) + +#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \ + ((fsb) &~ ((fs)->fs_frag - 1)) + +/* + * Determine the number of available frags given a + * percentage to hold in reserve + */ +#define freespace(fs, ufsvfsp) \ + ((blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \ + (fs)->fs_cstotal.cs_nffree) - (ufsvfsp)->vfs_minfrags) + +/* + * Determining the size of a file block in the file system. + */ + +#define blksize(fs, ip, lbn) \ + (((lbn) >= NDADDR || \ + (ip)->i_size >= (offset_t)((lbn) + 1) << (fs)->fs_bshift) \ + ? (fs)->fs_bsize \ + : (fragroundup(fs, blkoff(fs, (ip)->i_size)))) + +#define dblksize(fs, dip, lbn) \ + (((lbn) >= NDADDR || \ + (dip)->di_size >= (offset_t)((lbn) + 1) << (fs)->fs_bshift) \ + ? (fs)->fs_bsize \ + : (fragroundup(fs, blkoff(fs, (dip)->di_size)))) + +/* + * Number of disk sectors per block; assumes DEV_BSIZE byte sector size. + */ +#define NSPB(fs) ((fs)->fs_nspf << (fs)->fs_fragshift) +#define NSPF(fs) ((fs)->fs_nspf) + +/* + * INOPB is the number of inodes in a secondary storage block. + */ +#define INOPB(fs) ((fs)->fs_inopb) +#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift) + +/* + * NINDIR is the number of indirects in a file system block. + */ +#define NINDIR(fs) ((fs)->fs_nindir) + +/* + * bit map related macros + */ +#define bitloc(a, i) ((a)[(i)/NBBY]) +#define setbit(a, i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a, i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) +#define isset(a, i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) +#define isclr(a, i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) + +#define getfs(vfsp) \ + ((struct fs *)((struct ufsvfs *)vfsp->vfs_data)->vfs_bufp->b_un.b_addr) + +#define RETRY_LOCK_DELAY 1 + +/* + * Macros to test and acquire i_rwlock: + * some vnops hold the target directory's i_rwlock after calling + * ufs_lockfs_begin but in many other operations (like ufs_readdir) + * VOP_RWLOCK is explicitly called by the filesystem independent code before + * calling the file system operation. In these cases the order is reversed + * (i.e i_rwlock is taken first and then ufs_lockfs_begin is called). This + * is fine as long as ufs_lockfs_begin acts as a VOP counter but with + * ufs_quiesce setting the SLOCK bit this becomes a synchronizing + * object which might lead to a deadlock. So we use rw_tryenter instead of + * rw_enter. If we fail to get this lock and find that SLOCK bit is set, we + * call ufs_lockfs_end and restart the operation. + */ + +#define ufs_tryirwlock(lock, mode, label) \ +{\ + indeadlock = 0;\ +label:\ + if (!rw_tryenter(lock, mode))\ + {\ + if (ulp && ULOCKFS_IS_SLOCK(ulp)) {\ + indeadlock = 1;\ + } else {\ + delay(RETRY_LOCK_DELAY);\ + goto label;\ + }\ + }\ +} + +/* + * The macro ufs_tryirwlock_trans is used in functions which call + * TRANS_BEGIN_CSYNC and ufs_lockfs_begin, hence the need to call + * TRANS_END_CSYNC and ufs_lockfs_end. + */ + +#define ufs_tryirwlock_trans(lock, mode, transmode, label) \ +{\ + indeadlock = 0;\ +label:\ + if (!rw_tryenter(lock, mode))\ + {\ + if (ulp && ULOCKFS_IS_SLOCK(ulp)) {\ + TRANS_END_CSYNC(ufsvfsp, error, issync,\ + transmode, trans_size);\ + ufs_lockfs_end(ulp);\ + indeadlock = 1;\ + } else {\ + delay(RETRY_LOCK_DELAY);\ + goto label;\ + }\ + }\ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_FS_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_fsdir.h b/illumos-x86_64/usr/include/sys/fs/ufs_fsdir.h new file mode 100644 index 00000000..8e1c8a7d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_fsdir.h @@ -0,0 +1,127 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_FS_UFS_FSDIR_H +#define _SYS_FS_UFS_FSDIR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A directory consists of some number of blocks of DIRBLKSIZ + * bytes, where DIRBLKSIZ is chosen such that it can be transferred + * to disk in a single atomic operation (e.g. 512 bytes on most machines). + * + * Each DIRBLKSIZ byte block contains some number of directory entry + * structures, which are of variable length. Each directory entry has + * a struct direct at the front of it, containing its inode number, + * the length of the entry, and the length of the name contained in + * the entry. These are followed by the name padded to a 4 byte boundary + * with null bytes. All names are guaranteed null terminated. + * The maximum length of a name in a directory is MAXNAMLEN. + * + * The macro DIRSIZ(dp) gives the amount of space required to represent + * a directory entry. Free space in a directory is represented by + * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes + * in a directory block are claimed by the directory entries. This + * usually results in the last entry in a directory having a large + * dp->d_reclen. When entries are deleted from a directory, the + * space is returned to the previous entry in the same directory + * block by increasing its dp->d_reclen. If the first entry of + * a directory block is free, then its dp->d_ino is set to 0. + * Entries other than the first in a directory do not normally have + * dp->d_ino set to 0. + */ +#define DIRBLKSIZ DEV_BSIZE +#define MAXNAMLEN 255 + +struct direct { + uint32_t d_ino; /* inode number of entry */ + ushort_t d_reclen; /* length of this record */ + ushort_t d_namlen; /* length of string in d_name */ + char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ +}; + +/* + * The DIRSIZ macro gives the minimum record length which will hold + * the directory entry. This requires the amount of space in struct direct + * without the d_name field, plus enough space for the name with a terminating + * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. + */ +#undef DIRSIZ +#define DIRSIZ(dp) \ + ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1+3) &~ 3)) + +#ifdef _KERNEL +/* + * Template for manipulating directories. + * Should use struct direct's, but the name field + * is MAXNAMLEN - 1, and this just won't do. + */ +struct dirtemplate { + uint32_t dot_ino; + short dot_reclen; + short dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + uint32_t dotdot_ino; + short dotdot_reclen; + short dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; + +/* + * Reduced structure for manipulating directories. + * Note, we are using __packed here to ensure the size of structure + * without changing the alignment. + */ +struct tmp_dir { + uint32_t d_ino; /* inode number of entry */ + ushort_t d_reclen; /* length of this record */ + ushort_t d_namlen; /* length of string in d_name */ + char d_name[4]; /* name must be no longer than this */ +} __packed; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_FSDIR_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_inode.h b/illumos-x86_64/usr/include/sys/fs/ufs_inode.h new file mode 100644 index 00000000..173e2759 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_inode.h @@ -0,0 +1,1025 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_FS_UFS_INODE_H +#define _SYS_FS_UFS_INODE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The I node is the focus of all local file activity in UNIX. + * There is a unique inode allocated for each active file, + * each current directory, each mounted-on file, each mapping, + * and the root. An inode is `named' by its dev/inumber pair. + * Data in icommon is read in from permanent inode on volume. + * + * Each inode has 5 locks associated with it: + * i_rwlock: Serializes ufs_write and ufs_setattr request + * and allows ufs_read requests to proceed in parallel. + * Serializes reads/updates to directories. + * vfs_dqrwlock: Manages quota sub-system quiescence. See below. + * i_contents: Protects almost all of the fields in the inode + * except for those listed below. When held + * in writer mode also protects those fields + * listed under i_tlock. + * i_tlock: When i_tlock is held with the i_contents reader + * lock the i_atime, i_mtime, i_ctime, + * i_delayoff, i_delaylen, i_nextrio, i_writes, i_flag + * i_seq, i_writer & i_mapcnt fields are protected. + * For more i_flag locking info see below. + * ih_lock: Protects inode hash chain buckets + * ifree_lock: Protects inode freelist + * + * Lock ordering: + * i_rwlock > i_contents > i_tlock + * i_rwlock > vfs_dqrwlock > i_contents(writer) > i_tlock + * i_contents > i_tlock + * vfs_dqrwlock > i_contents(writer) > i_tlock + * ih_lock > i_contents > i_tlock + * + * Making major changes to quota sub-system state, while the file + * system is mounted required the addition of another lock. The + * primary lock in the quota sub-system is vfs_dqrwlock in the ufsvfs + * structure. This lock is used to manage quota sub-system quiescence + * for a particular file system. Major changes to quota sub-system + * state (disabling quotas, enabling quotas, and setting new quota + * limits) all require the file system to be quiescent and grabbing + * vfs_dqrwlock as writer accomplishes this. On the other hand, + * grabbing vfs_dqrwlock as reader makes the quota sub-system + * non-quiescent and lets the quota sub-system know that now is not a + * good time to change major quota sub-system state. Typically + * vfs_dqrwlock is grabbed for reading before i_contents is grabbed for + * writing. However, there are cases where vfs_dqrwlock is grabbed for + * reading without a corresponding i_contents write grab because there + * is no relevant inode. There are also cases where i_contents is + * grabbed for writing when a vfs_dqrwlock read grab is not needed + * because the inode changes do not affect quotas. + * + * Unfortunately, performance considerations have required that we be more + * intelligent about using i_tlock when updating i_flag. Ideally, we would + * have simply separated out several of the bits in i_flag into their own + * ints to avoid problems. But, instead, we have implemented the following + * rules: + * + * o You can update any i_flag field while holding the writer-contents, + * or by holding the reader-contents AND holding i_tlock. + * You can only call ITIMES_NOLOCK while holding the writer-contents, + * or by holding the reader-contents AND holding i_tlock. + * + * o For a directory, holding the reader-rw_lock is sufficient for setting + * IACC. + * + * o Races with IREF are avoided by holding the reader contents lock + * and by holding i_tlock in ufs_rmidle, ufs_putapage, and ufs_getpage. + * And by holding the writer-contents in ufs_iinactive. + * + * o The callers are no longer required to handle the calls to ITIMES + * and ITIMES_NOLOCK. The functions that set the i_flag bits are + * responsible for managing those calls. The exceptions are the + * bmap routines. + * + * SVR4 Extended Fundamental Type (EFT) support: + * The inode structure has been enhanced to support + * 32-bit user-id, 32-bit group-id, and 32-bit device number. + * Standard SVR4 ufs also supports 32-bit mode field. For the reason + * of backward compatibility with the previous ufs disk format, + * 32-bit mode field is not supported. + * + * The current inode structure is 100% backward compatible with + * the previous inode structure if no user-id or group-id exceeds + * USHRT_MAX, and no major or minor number of a device number + * stored in an inode exceeds 255. + * + * Rules for managing i_seq: + * o i_seq is locked under the same rules as i_flag + * o The i_ctime or i_mtime MUST never change without increasing + * the value of i_seq. + * o You may increase the value of i_seq without the timestamps + * changing, this may decrease the callers performance but will + * be functionally correct. + * o The common case is when IUPD or ICHG is set, increase i_seq + * and immediately call ITIMES* or ufs_iupdat to create a new timestamp. + * o A less common case is the setting of IUPD or ICHG and while still + * holding the correct lock defer the timestamp and i_seq update + * until later, but it must still be done before the lock is released. + * bmap_write is an example of this, where the caller does the update. + * o If multiple changes are being made with the timestamps being + * updated only at the end, a single increase of i_seq is allowed. + * o If changes are made with IUPD or ICHG being set, but + * the controlling lock is being dropped before the timestamp is + * updated, there is a risk that another thread will also change + * the file, update i_flag, and push just one timestamp update. + * There is also the risk that another thread calls ITIMES or + * ufs_iupdat without setting IUPD|ICHG and thus not changing i_seq, + * this will cause ufs_imark to change the timestamps without changing + * i_seq. If the controlling lock is dropped, ISEQ must be set to + * force i_seq to be increased on next ufs_imark, but i_seq MUST still + * be increased by the original setting thread before its deferred + * call to ITIMES to insure it is increased the correct number of times. + */ + +#define UID_LONG (o_uid_t)65535 + /* flag value to indicate uid is 32-bit long */ +#define GID_LONG (o_uid_t)65535 + /* flag value to indicate gid is 32-bit long */ + +#define NDADDR 12 /* direct addresses in inode */ +#define NIADDR 3 /* indirect addresses in inode */ +#define FSL_SIZE (NDADDR + NIADDR - 1) * sizeof (daddr32_t) + /* max fast symbolic name length is 56 */ + +#define i_fs i_ufsvfs->vfs_bufp->b_un.b_fs +#define i_vfs i_vnode->v_vfsp + +struct icommon { + o_mode_t ic_smode; /* 0: mode and type of file */ + short ic_nlink; /* 2: number of links to file */ + o_uid_t ic_suid; /* 4: owner's user id */ + o_gid_t ic_sgid; /* 6: owner's group id */ + u_offset_t ic_lsize; /* 8: number of bytes in file */ +#ifdef _KERNEL + struct timeval32 ic_atime; /* 16: time last accessed */ + struct timeval32 ic_mtime; /* 24: time last modified */ + struct timeval32 ic_ctime; /* 32: last time inode changed */ +#else + time32_t ic_atime; /* 16: time last accessed */ + int32_t ic_atspare; + time32_t ic_mtime; /* 24: time last modified */ + int32_t ic_mtspare; + time32_t ic_ctime; /* 32: last time inode changed */ + int32_t ic_ctspare; +#endif + daddr32_t ic_db[NDADDR]; /* 40: disk block addresses */ + daddr32_t ic_ib[NIADDR]; /* 88: indirect blocks */ + int32_t ic_flags; /* 100: cflags */ + int32_t ic_blocks; /* 104: 512 byte blocks actually held */ + int32_t ic_gen; /* 108: generation number */ + int32_t ic_shadow; /* 112: shadow inode */ + uid_t ic_uid; /* 116: long EFT version of uid */ + gid_t ic_gid; /* 120: long EFT version of gid */ + uint32_t ic_oeftflag; /* 124: extended attr directory ino, 0 = none */ +}; + +/* + * Large directories can be cached. Directory caching can take the following + * states: + */ +typedef enum { + CD_DISABLED_NOMEM = -2, + CD_DISABLED_TOOBIG, + CD_DISABLED, + CD_ENABLED +} cachedir_t; + +/* + * Large Files: Note we use the inline functions load_double, store_double + * to load and store the long long values of i_size. Therefore the + * address of i_size must be eight byte aligned. Kmem_alloc of incore + * inode structure makes sure that the structure is 8-byte aligned. + * XX64 - reorder this structure? + */ +typedef struct inode { + struct inode *i_chain[2]; /* must be first */ + struct inode *i_freef; /* free list forward - must be before i_ic */ + struct inode *i_freeb; /* free list back - must be before i_ic */ + struct icommon i_ic; /* Must be here */ + struct vnode *i_vnode; /* vnode associated with this inode */ + struct vnode *i_devvp; /* vnode for block I/O */ + dev_t i_dev; /* device where inode resides */ + ino_t i_number; /* i number, 1-to-1 with device address */ + off_t i_diroff; /* offset in dir, where we found last entry */ + /* just a hint - no locking needed */ + struct ufsvfs *i_ufsvfs; /* incore fs associated with inode */ + struct dquot *i_dquot; /* quota structure controlling this file */ + krwlock_t i_rwlock; /* serializes write/setattr requests */ + krwlock_t i_contents; /* protects (most of) inode contents */ + kmutex_t i_tlock; /* protects time fields, i_flag */ + offset_t i_nextr; /* */ + /* next byte read offset (read-ahead) */ + /* No lock required */ + /* */ + uint_t i_flag; /* inode flags */ + uint_t i_seq; /* modification sequence number */ + cachedir_t i_cachedir; /* Cache this directory on next lookup */ + /* - no locking needed */ + long i_mapcnt; /* mappings to file pages */ + int *i_map; /* block list for the corresponding file */ + dev_t i_rdev; /* INCORE rdev from i_oldrdev by ufs_iget */ + size_t i_delaylen; /* delayed writes, units=bytes */ + offset_t i_delayoff; /* where we started delaying */ + offset_t i_nextrio; /* where to start the next clust */ + long i_writes; /* number of outstanding bytes in write q */ + kcondvar_t i_wrcv; /* sleep/wakeup for write throttle */ + offset_t i_doff; /* dinode byte offset in file system */ + si_t *i_ufs_acl; /* pointer to acl entry */ + dcanchor_t i_danchor; /* directory cache anchor */ + kthread_t *i_writer; /* thread which is in window in wrip() */ +} inode_t; + +struct dinode { + union { + struct icommon di_icom; + char di_size[128]; + } di_un; +}; + +#define i_mode i_ic.ic_smode +#define i_nlink i_ic.ic_nlink +#define i_uid i_ic.ic_uid +#define i_gid i_ic.ic_gid +#define i_smode i_ic.ic_smode +#define i_suid i_ic.ic_suid +#define i_sgid i_ic.ic_sgid + +#define i_size i_ic.ic_lsize +#define i_db i_ic.ic_db +#define i_ib i_ic.ic_ib + +#define i_atime i_ic.ic_atime +#define i_mtime i_ic.ic_mtime +#define i_ctime i_ic.ic_ctime + +#define i_shadow i_ic.ic_shadow +#define i_oeftflag i_ic.ic_oeftflag +#define i_blocks i_ic.ic_blocks +#define i_cflags i_ic.ic_flags +#ifdef _LITTLE_ENDIAN +/* + * Originally done on x86, but carried on to all other little + * architectures, which provides for file system compatibility. + */ +#define i_ordev i_ic.ic_db[1] /* USL SVR4 compatibility */ +#else +#define i_ordev i_ic.ic_db[0] /* was i_oldrdev */ +#endif +#define i_gen i_ic.ic_gen +#define i_forw i_chain[0] +#define i_back i_chain[1] + +/* EFT transition aids - obsolete */ +#define oEFT_MAGIC 0x90909090 +#define di_oeftflag di_ic.ic_oeftflag + +#define di_ic di_un.di_icom +#define di_mode di_ic.ic_smode +#define di_nlink di_ic.ic_nlink +#define di_uid di_ic.ic_uid +#define di_gid di_ic.ic_gid +#define di_smode di_ic.ic_smode +#define di_suid di_ic.ic_suid +#define di_sgid di_ic.ic_sgid + +#define di_size di_ic.ic_lsize +#define di_db di_ic.ic_db +#define di_ib di_ic.ic_ib + +#define di_atime di_ic.ic_atime +#define di_mtime di_ic.ic_mtime +#define di_ctime di_ic.ic_ctime +#define di_cflags di_ic.ic_flags + +#ifdef _LITTLE_ENDIAN +#define di_ordev di_ic.ic_db[1] +#else +#define di_ordev di_ic.ic_db[0] +#endif +#define di_shadow di_ic.ic_shadow +#define di_blocks di_ic.ic_blocks +#define di_gen di_ic.ic_gen + +/* flags */ +#define IUPD 0x0001 /* file has been modified */ +#define IACC 0x0002 /* inode access time to be updated */ +#define IMOD 0x0004 /* inode has been modified */ +#define ICHG 0x0008 /* inode has been changed */ +#define INOACC 0x0010 /* no access time update in getpage */ +#define IMODTIME 0x0020 /* mod time already set */ +#define IREF 0x0040 /* inode is being referenced */ +#define ISYNC 0x0080 /* do all allocation synchronously */ +#define IFASTSYMLNK 0x0100 /* fast symbolic link */ +#define IMODACC 0x0200 /* only access time changed; */ + /* filesystem won't become active */ +#define IATTCHG 0x0400 /* only size/blocks have changed */ +#define IBDWRITE 0x0800 /* the inode has been scheduled for */ + /* write operation asynchronously */ +#define ISTALE 0x1000 /* inode couldn't be read from disk */ +#define IDEL 0x2000 /* inode is being deleted */ +#define IDIRECTIO 0x4000 /* attempt directio */ +#define ISEQ 0x8000 /* deferred i_seq increase */ +#define IJUNKIQ 0x10000 /* on junk idle queue */ +#define IQUIET 0x20000 /* No file system full messages */ + +/* cflags */ +#define IXATTR 0x0001 /* extended attribute */ +#define IFALLOCATE 0x0002 /* fallocate'd file */ +#define ICOMPRESS 0x0004 /* compressed for dcfs - see */ + /* `ufs_ioctl()`_FIO_COMPRESSED */ + +/* modes */ +#define IFMT 0170000 /* type of file */ +#define IFIFO 0010000 /* named pipe (fifo) */ +#define IFCHR 0020000 /* character special */ +#define IFDIR 0040000 /* directory */ +#define IFBLK 0060000 /* block special */ +#define IFREG 0100000 /* regular */ +#define IFLNK 0120000 /* symbolic link */ +#define IFSHAD 0130000 /* shadow indode */ +#define IFSOCK 0140000 /* socket */ +#define IFATTRDIR 0160000 /* Attribute directory */ + +#define ISUID 04000 /* set user id on execution */ +#define ISGID 02000 /* set group id on execution */ +#define ISVTX 01000 /* save swapped text even after use */ +#define IREAD 0400 /* read, write, execute permissions */ +#define IWRITE 0200 +#define IEXEC 0100 + +/* specify how the inode info is written in ufs_syncip() */ +#define I_SYNC 1 /* wait for the inode written to disk */ +#define I_DSYNC 2 /* wait for the inode written to disk */ + /* only if IATTCHG is set */ +#define I_ASYNC 0 /* don't wait for the inode written */ + +/* flags passed to ufs_itrunc(), indirtrunc(), and free() */ +#define I_FREE 0x00000001 /* inode is being freed */ +#define I_DIR 0x00000002 /* inode is a directory */ +#define I_IBLK 0x00000004 /* indirect block */ +#define I_CHEAP 0x00000008 /* cheap free */ +#define I_SHAD 0x00000010 /* inode is a shadow inode */ +#define I_QUOTA 0x00000020 /* quota file */ +#define I_NOCANCEL 0x40 /* Don't cancel these fragments */ +#define I_ACCT 0x00000080 /* Update ufsvfs' unreclaimed_blocks */ + +/* + * If ufs_dircheckforname() fails to find an entry with the given name, + * this "slot" structure holds state for ufs_direnter_*() as to where + * there is space to put an entry with that name. + * If ufs_dircheckforname() finds an entry with the given name, this structure + * holds state for ufs_dirrename() and ufs_dirremove() as to where the + * entry is. "status" indicates what ufs_dircheckforname() found: + * NONE name not found, large enough free slot not found, + * FOUND name not found, large enough free slot found + * EXIST name found + * If ufs_dircheckforname() fails due to an error, this structure is not + * filled in. + * + * After ufs_dircheckforname() succeeds the values are: + * status offset size fbp, ep + * ------ ------ ---- ------- + * NONE end of dir needed not valid + * FOUND start of entry of ent both valid if fbp != NULL + * EXIST start of entry of prev ent valid + * + * "endoff" is set to 0 if the an entry with the given name is found, or if no + * free slot could be found or made; this means that the directory should not + * be truncated. If the entry was found, the search terminates so + * ufs_dircheckforname() didn't find out where the last valid entry in the + * directory was, so it doesn't know where to cut the directory off; if no free + * slot could be found or made, the directory has to be extended to make room + * for the new entry, so there's nothing to cut off. + * Otherwise, "endoff" is set to the larger of the offset of the last + * non-empty entry in the directory, or the offset at which the new entry will + * be placed, whichever is larger. This is used by ufs_diraddentry(); if a new + * entry is to be added to the directory, any complete directory blocks at the + * end of the directory that contain no non-empty entries are lopped off the + * end, thus shrinking the directory dynamically. + */ +typedef enum {NONE, FOUND, EXIST} slotstat_t; +struct ufs_slot { + struct direct *ep; /* pointer to slot */ + struct fbuf *fbp; /* dir buf where slot is */ + off_t offset; /* offset of area with free space */ + off_t endoff; /* last useful location found in search */ + slotstat_t status; /* status of slot */ + int size; /* size of area at slotoffset */ + int cached; /* cached directory */ +}; + +/* + * Statistics on inodes + * Not protected by locks + */ +struct instats { + kstat_named_t in_size; /* current cache size */ + kstat_named_t in_maxsize; /* maximum cache size */ + kstat_named_t in_hits; /* cache hits */ + kstat_named_t in_misses; /* cache misses */ + kstat_named_t in_malloc; /* kmem_alloce'd */ + kstat_named_t in_mfree; /* kmem_free'd */ + kstat_named_t in_maxreached; /* Largest size reached by cache */ + kstat_named_t in_frfront; /* # put at front of freelist */ + kstat_named_t in_frback; /* # put at back of freelist */ + kstat_named_t in_qfree; /* q's to delete thread */ + kstat_named_t in_scan; /* # inodes scanned */ + kstat_named_t in_tidles; /* # inodes idled by idle thread */ + kstat_named_t in_lidles; /* # inodes idled by ufs_lookup */ + kstat_named_t in_vidles; /* # inodes idled by ufs_vget */ + kstat_named_t in_kcalloc; /* # inodes kmem_cache_alloced */ + kstat_named_t in_kcfree; /* # inodes kmem_cache_freed */ + kstat_named_t in_poc; /* # push-on-close's */ +}; + +#ifdef _KERNEL + +/* + * Extended attributes + */ + +#define XATTR_DIR_NAME "/@/" +extern int ufs_ninode; /* high-water mark for inode cache */ + +extern struct vnodeops *ufs_vnodeops; /* vnode operations for ufs */ +extern const struct fs_operation_def ufs_vnodeops_template[]; + +/* + * Convert between inode pointers and vnode pointers + */ +#define VTOI(VP) ((struct inode *)(VP)->v_data) +#define ITOV(IP) ((struct vnode *)(IP)->i_vnode) + +/* + * convert to fs + */ +#define ITOF(IP) ((struct fs *)(IP)->i_fs) + +/* + * Convert between vnode types and inode formats + */ +extern enum vtype iftovt_tab[]; + +#ifdef notneeded + +/* Look at sys/mode.h and os/vnode.c */ + +extern int vttoif_tab[]; + +#endif + +/* + * Mark an inode with the current (unique) timestamp. + * (Note that UFS's concept of time only keeps 32 bits of seconds + * in the on-disk format). + */ +extern struct timeval32 iuniqtime; +extern kmutex_t ufs_iuniqtime_lock; + +#define ITIMES_NOLOCK(ip) ufs_itimes_nolock(ip) + +#define ITIMES(ip) { \ + mutex_enter(&(ip)->i_tlock); \ + ITIMES_NOLOCK(ip); \ + mutex_exit(&(ip)->i_tlock); \ +} + +/* + * The following interfaces are used to do atomic loads and stores + * of an inode's i_size, which is a long long data type. + * + * For LP64, we just to a load or a store - atomicity and alignment + * are 8-byte guaranteed. For x86 there are no such instructions, + * so we grab i_contents as reader to get the size; we already hold + * it as writer when we're setting the size. + */ + +#ifdef _LP64 + +#define UFS_GET_ISIZE(resultp, ip) *(resultp) = (ip)->i_size +#define UFS_SET_ISIZE(value, ip) (ip)->i_size = (value) + +#else /* _LP64 */ + +#define UFS_GET_ISIZE(resultp, ip) \ + { \ + rw_enter(&(ip)->i_contents, RW_READER); \ + *(resultp) = (ip)->i_size; \ + rw_exit(&(ip)->i_contents); \ + } +#define UFS_SET_ISIZE(value, ip) \ + { \ + ASSERT(RW_WRITE_HELD(&(ip)->i_contents)); \ + (ip)->i_size = (value); \ + } + +#endif /* _LP64 */ + +/* + * Allocate the specified block in the inode + * and make sure any in-core pages are initialized. + */ +#define BMAPALLOC(ip, off, size, cr) \ + bmap_write((ip), (u_offset_t)(off), (size), BI_NORMAL, NULL, cr) + +#define ESAME (-1) /* trying to rename linked files (special) */ + +#define UFS_HOLE (daddr32_t)-1 /* value used when no block allocated */ + +/* + * enums + */ + +/* direnter ops */ +enum de_op { DE_CREATE, DE_MKDIR, DE_LINK, DE_RENAME, DE_SYMLINK, DE_ATTRDIR}; + +/* dirremove ops */ +enum dr_op { DR_REMOVE, DR_RMDIR, DR_RENAME }; + +/* + * block initialization type for bmap_write + * + * BI_NORMAL - allocate and zero fill pages in memory + * BI_ALLOC_ONLY - only allocate the block, do not zero out pages in mem + * BI_FALLOCATE - allocate only, do not zero out pages, and store as negative + * block number in inode block list + */ +enum bi_type { BI_NORMAL, BI_ALLOC_ONLY, BI_FALLOCATE }; + +/* + * This overlays the fid structure (see vfs.h) + * + * LP64 note: we use int32_t instead of ino_t since UFS does not use + * inode numbers larger than 32-bits and ufid's are passed to NFS + * which expects them to not grow in size beyond 10 bytes (12 including + * the length). + */ +struct ufid { + ushort_t ufid_len; + ushort_t ufid_flags; + int32_t ufid_ino; + int32_t ufid_gen; +}; + +/* + * each ufs thread (see ufs_thread.c) is managed by this struct + */ +struct ufs_q { + union uq_head { + void *_uq_generic; /* first entry on q */ + struct inode *_uq_i; + ufs_failure_t *_uq_uf; + } _uq_head; + int uq_ne; /* # of entries/failures found */ + int uq_lowat; /* thread runs when ne == lowat */ + int uq_hiwat; /* synchronous idle if ne >= hiwat */ + ushort_t uq_flags; /* flags (see below) */ + kcondvar_t uq_cv; /* for sleep/wakeup */ + kthread_id_t uq_threadp; /* thread managing this q */ + kmutex_t uq_mutex; /* protects this struct */ +}; + +#define uq_head _uq_head._uq_generic +#define uq_ihead _uq_head._uq_i +#define uq_ufhead _uq_head._uq_uf + +/* + * uq_flags + */ +#define UQ_EXIT (0x0001) /* q server exits at its convenience */ +#define UQ_WAIT (0x0002) /* thread is waiting on q server */ +#define UQ_SUSPEND (0x0004) /* request for suspension */ +#define UQ_SUSPENDED (0x0008) /* thread has suspended itself */ + +/* + * When logging is enabled, statvfs must account for blocks and files that + * may be on the delete queue. Protected by ufsvfsp->vfs_delete.uq_mutex + */ +struct ufs_delq_info { + u_offset_t delq_unreclaimed_blocks; + ulong_t delq_unreclaimed_files; +}; + + +/* + * global idle queues + * The queues are sized dynamically in proportion to ufs_ninode + * which, unless overridden, scales with the amount of memory. + * The idle queue is halved whenever it hits the low water mark + * (1/4 of ufs_ninode), but can burst to sizes much larger. The number + * of hash queues is currently maintained to give on average IQHASHQLEN + * entries when the idle queue is at the low water mark. + * Note, we do not need to search along the hash queues, but use them + * in order to batch together geographically local inodes to allow + * their updates (via the log or buffer cache) to require less disk seeks. + * This gives an incredible performance boost for logging and a boost for + * non logging file systems. + */ +typedef struct { + inode_t *i_chain[2]; /* must match inode_t, but unused */ + inode_t *i_freef; /* must match inode_t, idle list forward */ + inode_t *i_freeb; /* must match inode_t, idle list back */ +} iqhead_t; + +extern struct ufs_q ufs_idle_q; /* used by global ufs idle thread */ +extern iqhead_t *ufs_junk_iq; /* junk idle queues */ +extern iqhead_t *ufs_useful_iq; /* useful idle queues */ +extern int ufs_njunk_iq; /* number of entries in junk iq */ +extern int ufs_nuseful_iq; /* number of entries in useful iq */ +extern int ufs_niqhash; /* number of iq hash qs - power of 2 */ +extern int ufs_iqhashmask; /* iq hash mask = ufs_niqhash - 1 */ + +#define IQHASHQLEN 32 /* see comments above */ +#define INOCGSHIFT 7 /* 128 inodes per cylinder group */ +#define IQHASH(ip) (((ip)->i_number >> INOCGSHIFT) & ufs_iqhashmask) +#define IQNEXT(i) ((i) + 1) & ufs_iqhashmask /* next idle queue */ + +extern struct ufs_q ufs_hlock; /* used by global ufs hlock thread */ + +/* + * vfs_lfflags flags + */ +#define UFS_LARGEFILES ((ushort_t)0x1) /* set if mount allows largefiles */ + +/* + * vfs_dfritime flags + */ +#define UFS_DFRATIME 0x1 /* deferred access time */ + +/* + * UFS VFS private data. + * + * UFS file system instances may be linked on several lists. + * + * - The vfs_next field chains together every extant ufs instance; this + * list is rooted at ufs_instances and should be used in preference to + * the overall vfs list (which is properly the province of the generic + * file system code, not of file system implementations). This same list + * link is used during forcible unmounts to chain together instances that + * can't yet be completely dismantled, + * + * - The vfs_wnext field is used within ufs_update to form a work list of + * UFS instances to be synced out. + */ +typedef struct ufsvfs { + struct vfs *vfs_vfs; /* back link */ + struct ufsvfs *vfs_next; /* instance list link */ + struct ufsvfs *vfs_wnext; /* work list link */ + struct vnode *vfs_root; /* root vnode */ + struct buf *vfs_bufp; /* buffer containing superblock */ + struct vnode *vfs_devvp; /* block device vnode */ + ushort_t vfs_lfflags; /* Large files (set by mount) */ + ushort_t vfs_qflags; /* QUOTA: filesystem flags */ + struct inode *vfs_qinod; /* QUOTA: pointer to quota file */ + uint_t vfs_btimelimit; /* QUOTA: block time limit */ + uint_t vfs_ftimelimit; /* QUOTA: file time limit */ + krwlock_t vfs_dqrwlock; /* QUOTA: protects quota fields */ + /* + * some fs local threads + */ + struct ufs_q vfs_delete; /* delayed inode delete */ + struct ufs_q vfs_reclaim; /* reclaim open, deleted files */ + + /* + * This is copied from the super block at mount time. + */ + int vfs_nrpos; /* # rotational positions */ + /* + * This lock protects cg's and super block pointed at by + * vfs_bufp->b_fs. Locks contents of fs and cg's and contents + * of vfs_dio. + */ + kmutex_t vfs_lock; + struct ulockfs vfs_ulockfs; /* ufs lockfs support */ + uint_t vfs_dio; /* delayed io (_FIODIO) */ + uint_t vfs_nointr; /* disallow lockfs interrupts */ + uint_t vfs_nosetsec; /* disallow ufs_setsecattr */ + uint_t vfs_syncdir; /* synchronous local directory ops */ + uint_t vfs_dontblock; /* don't block on forced umount */ + + /* + * trans (logging ufs) stuff + */ + uint_t vfs_domatamap; /* set if matamap enabled */ + ulong_t vfs_maxacl; /* transaction stuff - max acl size */ + ulong_t vfs_dirsize; /* logspace for directory creation */ + ulong_t vfs_avgbfree; /* average free blks in cg (blkpref) */ + /* + * Some useful constants + */ + int vfs_nindirshift; /* calc. from fs_nindir */ + int vfs_nindiroffset; /* calc. from fs_ninidr */ + int vfs_ioclustsz; /* bytes in read/write cluster */ + int vfs_iotransz; /* max device i/o transfer size */ + + vfs_ufsfx_t vfs_fsfx; /* lock/fix-on-panic support */ + /* + * More useful constants + */ + int vfs_minfrags; /* calc. from fs_minfree */ + /* + * Force DirectIO on all files + */ + uint_t vfs_forcedirectio; + /* + * Deferred inode time related fields + */ + clock_t vfs_iotstamp; /* last I/O timestamp */ + uint_t vfs_dfritime; /* deferred inode time flags */ + /* + * Some more useful info + */ + dev_t vfs_dev; /* device mounted from */ + struct ml_unit *vfs_log; /* pointer to embedded log struct */ + uint_t vfs_noatime; /* disable inode atime updates */ + /* + * snapshot stuff + */ + void *vfs_snapshot; /* snapshot handle */ + /* + * Controls logging "file system full" messages to messages file + */ + clock_t vfs_lastwhinetime; + + int vfs_nolog_si; /* not logging summary info */ + int vfs_validfs; /* indicates mounted fs */ + + /* + * Additional information about vfs_delete above + */ + struct ufs_delq_info vfs_delete_info; /* what's on the delete queue */ +} ufsvfs_t; + +#define vfs_fs vfs_bufp->b_un.b_fs + +/* + * values for vfs_validfs + */ +#define UT_UNMOUNTED 0 +#define UT_MOUNTED 1 +#define UT_HLOCKING 2 + +/* inohsz is guaranteed to be a power of 2 */ +#define INOHASH(ino) (((int)ino) & (inohsz - 1)) + +#define ISFALLOCBLK(ip, bn) \ + (((bn) < 0) && ((bn) % ip->i_fs->fs_frag == 0) && \ + ((ip)->i_cflags & IFALLOCATE && (bn) != UFS_HOLE)) + +union ihead { + union ihead *ih_head[2]; + struct inode *ih_chain[2]; +}; + +extern union ihead *ihead; +extern kmutex_t *ih_lock; +extern int *ih_ne; +extern int inohsz; + +extern clock_t ufs_iowait; + +#endif /* _KERNEL */ + +/* + * ufs function prototypes + */ +#if defined(_KERNEL) && !defined(_BOOT) + +extern void ufs_iinit(void); +extern int ufs_iget(struct vfs *, ino_t, struct inode **, cred_t *); +extern int ufs_iget_alloced(struct vfs *, ino_t, struct inode **, + cred_t *); +extern void ufs_reset_vnode(vnode_t *); +extern void ufs_iinactive(struct inode *); +extern void ufs_iupdat(struct inode *, int); +extern int ufs_rmidle(struct inode *); +extern int ufs_itrunc(struct inode *, u_offset_t, int, cred_t *); +extern int ufs_iaccess(struct inode *, int, cred_t *, int); +extern int rdip(struct inode *, struct uio *, int, struct cred *); +extern int wrip(struct inode *, struct uio *, int, struct cred *); + +extern void ufs_imark(struct inode *); +extern void ufs_itimes_nolock(struct inode *); + +extern int ufs_diraccess(struct inode *, int, struct cred *); +extern int ufs_dirlook(struct inode *, char *, struct inode **, + cred_t *, int, int); +extern int ufs_direnter_cm(struct inode *, char *, enum de_op, + struct vattr *, struct inode **, cred_t *, int); +extern int ufs_direnter_lr(struct inode *, char *, enum de_op, + struct inode *, struct inode *, cred_t *); +extern int ufs_dircheckpath(ino_t, struct inode *, struct inode *, + struct cred *); +extern int ufs_dirmakeinode(struct inode *, struct inode **, + struct vattr *, enum de_op, cred_t *); +extern int ufs_dirremove(struct inode *, char *, struct inode *, + vnode_t *, enum dr_op, cred_t *); +extern int ufs_dircheckforname(struct inode *, char *, int, + struct ufs_slot *, struct inode **, struct cred *, int); +extern int ufs_xattrdirempty(struct inode *, ino_t, cred_t *); +extern int blkatoff(struct inode *, off_t, char **, struct fbuf **); + +extern void sbupdate(struct vfs *); + +extern int ufs_ialloc(struct inode *, ino_t, mode_t, struct inode **, + cred_t *); +extern void ufs_ifree(struct inode *, ino_t, mode_t); +extern void free(struct inode *, daddr_t, off_t, int); +extern int alloc(struct inode *, daddr_t, int, daddr_t *, cred_t *); +extern int realloccg(struct inode *, daddr_t, daddr_t, int, int, + daddr_t *, cred_t *); +extern int ufs_allocsp(struct vnode *, struct flock64 *, cred_t *); +extern int ufs_freesp(struct vnode *, struct flock64 *, int, cred_t *); +extern ino_t dirpref(inode_t *); +extern daddr_t blkpref(struct inode *, daddr_t, int, daddr32_t *); +extern daddr_t contigpref(ufsvfs_t *, size_t, size_t); + +extern int ufs_rdwri(enum uio_rw, int, struct inode *, caddr_t, ssize_t, + offset_t, enum uio_seg, int *, cred_t *); + +extern int bmap_read(struct inode *, u_offset_t, daddr_t *, int *); +extern int bmap_write(struct inode *, u_offset_t, int, enum bi_type, + daddr_t *, struct cred *); +extern int bmap_has_holes(struct inode *); +extern int bmap_find(struct inode *, boolean_t, u_offset_t *); +extern int bmap_set_bn(struct vnode *, u_offset_t, daddr32_t); + +extern void ufs_vfs_add(struct ufsvfs *); +extern void ufs_vfs_remove(struct ufsvfs *); + +extern void ufs_sbwrite(struct ufsvfs *); +extern void ufs_update(int); +extern int ufs_getsummaryinfo(dev_t, struct ufsvfs *, struct fs *); +extern int ufs_putsummaryinfo(dev_t, struct ufsvfs *, struct fs *); +extern int ufs_syncip(struct inode *, int, int, top_t); +extern int ufs_sync_indir(struct inode *); +extern int ufs_indirblk_sync(struct inode *, offset_t); +extern int ufs_badblock(struct inode *, daddr_t); +extern int ufs_indir_badblock(struct inode *, daddr32_t *); +extern void ufs_notclean(struct ufsvfs *); +extern void ufs_checkclean(struct vfs *); +extern int isblock(struct fs *, uchar_t *, daddr_t); +extern void setblock(struct fs *, uchar_t *, daddr_t); +extern void clrblock(struct fs *, uchar_t *, daddr_t); +extern int isclrblock(struct fs *, uchar_t *, daddr_t); +extern void fragacct(struct fs *, int, int32_t *, int); +extern int skpc(char, uint_t, char *); +extern int ufs_fbwrite(struct fbuf *, struct inode *); +extern int ufs_fbiwrite(struct fbuf *, struct inode *, daddr_t, long); +extern int ufs_putapage(struct vnode *, struct page *, u_offset_t *, + size_t *, int, struct cred *); +extern inode_t *ufs_alloc_inode(ufsvfs_t *, ino_t); +extern void ufs_free_inode(inode_t *); + +/* + * special stuff + */ +extern void ufs_setreclaim(struct inode *); +extern int ufs_scan_inodes(int, int (*)(struct inode *, void *), void *, + struct ufsvfs *); +extern int ufs_sync_inode(struct inode *, void *); +extern int ufs_sticky_remove_access(struct inode *, struct inode *, + struct cred *); +/* + * quota + */ +extern int chkiq(struct ufsvfs *, int, struct inode *, uid_t, int, + struct cred *, char **errp, size_t *lenp); + +/* + * ufs thread stuff + */ +extern void ufs_thread_delete(struct vfs *); +extern void ufs_delete_drain(struct vfs *, int, int); +extern void ufs_delete(struct ufsvfs *, struct inode *, int); +extern void ufs_inode_cache_reclaim(void *); +extern void ufs_idle_drain(struct vfs *); +extern void ufs_idle_some(int); +extern void ufs_thread_idle(void); +extern void ufs_thread_reclaim(struct vfs *); +extern void ufs_thread_init(struct ufs_q *, int); +extern void ufs_thread_start(struct ufs_q *, void (*)(), struct vfs *); +extern void ufs_thread_exit(struct ufs_q *); +extern void ufs_thread_suspend(struct ufs_q *); +extern void ufs_thread_continue(struct ufs_q *); +extern void ufs_thread_hlock(void *); +extern void ufs_delete_init(struct ufsvfs *, int); +extern void ufs_delete_adjust_stats(struct ufsvfs *, struct statvfs64 *); +extern void ufs_delete_drain_wait(struct ufsvfs *, int); + +/* + * ufs lockfs stuff + */ +struct seg; +extern int ufs_reconcile_fs(struct vfs *, struct ufsvfs *, int); +extern int ufs_quiesce(struct ulockfs *); +extern int ufs_flush(struct vfs *); +extern int ufs_fiolfs(struct vnode *, struct lockfs *, int); +extern int ufs__fiolfs(struct vnode *, struct lockfs *, int, int); +extern int ufs_fiolfss(struct vnode *, struct lockfs *); +extern int ufs_fioffs(struct vfs *, struct cred *); +extern int ufs_check_lockfs(struct ufsvfs *, struct ulockfs *, ulong_t); +extern int ufs_lockfs_begin(struct ufsvfs *, struct ulockfs **, ulong_t); +extern int ufs_lockfs_trybegin(struct ufsvfs *, struct ulockfs **, ulong_t); +extern int ufs_lockfs_begin_getpage(struct ufsvfs *, struct ulockfs **, + struct seg *, int, uint_t *); +extern void ufs_lockfs_end(struct ulockfs *); +/* + * ufs acl stuff + */ +extern int ufs_si_inherit(struct inode *, struct inode *, o_mode_t, cred_t *); +extern void si_cache_init(void); +extern int ufs_si_load(struct inode *, cred_t *); +extern void ufs_si_del(struct inode *); +extern int ufs_acl_access(struct inode *, int, cred_t *); +extern void ufs_si_cache_flush(dev_t); +extern int ufs_si_free(si_t *, struct vfs *, cred_t *); +extern int ufs_acl_setattr(struct inode *, struct vattr *, cred_t *); +extern int ufs_acl_get(struct inode *, vsecattr_t *, int, cred_t *); +extern int ufs_acl_set(struct inode *, vsecattr_t *, int, cred_t *); +/* + * ufs directio stuff + */ +extern void ufs_directio_init(); +extern int ufs_directio_write(struct inode *, uio_t *, int, int, cred_t *, + int *); +extern int ufs_directio_read(struct inode *, uio_t *, cred_t *, int *); +#define DIRECTIO_FAILURE (0) +#define DIRECTIO_SUCCESS (1) + +/* + * ufs extensions for PXFS + */ + +int ufs_rdwr_data(vnode_t *vp, u_offset_t offset, size_t len, fdbuffer_t *fdb, + int flags, cred_t *cr); +int ufs_alloc_data(vnode_t *vp, u_offset_t offset, size_t *len, fdbuffer_t *fdb, + int flags, cred_t *cr); + +/* + * prototypes to support the forced unmount + */ + +void ufs_freeze(struct ulockfs *, struct lockfs *); +int ufs_thaw(struct vfs *, struct ufsvfs *, struct ulockfs *); + +/* + * extended attributes + */ + +int ufs_xattrmkdir(inode_t *, inode_t **, int, struct cred *); +int ufs_xattr_getattrdir(vnode_t *, inode_t **, int, struct cred *); +void ufs_unhook_shadow(inode_t *, inode_t *); + +#endif /* defined(_KERNEL) && !defined(_BOOT) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_INODE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_lockfs.h b/illumos-x86_64/usr/include/sys/fs/ufs_lockfs.h new file mode 100644 index 00000000..6e2ef0aa --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_lockfs.h @@ -0,0 +1,219 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_UFS_LOCKFS_H +#define _SYS_FS_UFS_LOCKFS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Sun ufs file system locking (lockfs) + * + * ufs file system supports the following lock types: + * unlock - releasing existing locks, or do a file system flush + * name lock - no delete, no rename + * write lock - no update to file system, including delete + * delete lock - no delete, rename is allowed + * hard lock - no update, no access, cannot be unlocked + * - for supporting forcible umount + * error lock - no update, no access, may only be unlocked + * - once fs becomes clean, may be upgraded to + * - a hard lock + * error lock (read-only) -- not yet implemented -- + * - no write changes allowed to fs, may be upgraded + * - to error or hard lock + * - degrades to panic on subsequent failures + * + * ufs_vnodeops(es) that conflict with the above file system lock types + * will get either suspended, or get a EAGAIN error, + * or get an EIO error if the file system is hard locked, + * or will block if the file system is error locked. + * + * There are exceptions. + * The following ufs_vnops do not obey the locking protocol: + * ufs_close, ufs_putpage, ufs_inactive, ufs_addmap, ufs_delmap, + * ufs_rwlock, ufs_rwunlock, ufs_poll. + * + * ul_vnops_cnt will get increment by 1 when a ufs vnodeops is entered; + * it will be decremented by 1 when a ufs_vnodeops is exited. + * A file system is in a quiescent state if ufs_vnops_cnt is zero. + * Since ufs_pageio() has to change ul_vnops_cnt without using ul_lock + * all users of ul_vnops_cnt increment and decrement it via atomic_add_long(). + */ + +#include +#include + +/* + * ul_flag + */ +#define ULOCKFS_BUSY 0x00000001 /* ul_fs_lock is being set */ +#define ULOCKFS_NOIACC 0x00000004 /* don't keep access times */ +#define ULOCKFS_NOIDEL 0x00000008 /* don't free deleted files */ +#define ULOCKFS_FALLOC 0x00000010 /* fallocate threads exist */ + +#define ULOCKFS_IS_BUSY(LF) ((LF)->ul_flag & ULOCKFS_BUSY) +#define ULOCKFS_IS_NOIACC(LF) ((LF)->ul_flag & ULOCKFS_NOIACC) +#define ULOCKFS_IS_NOIDEL(LF) ((LF)->ul_flag & ULOCKFS_NOIDEL) +#define ULOCKFS_IS_FALLOC(LF) ((LF)->ul_flag & ULOCKFS_FALLOC) + +#define ULOCKFS_CLR_BUSY(LF) ((LF)->ul_flag &= ~ULOCKFS_BUSY) +#define ULOCKFS_SET_BUSY(LF) ((LF)->ul_flag |= ULOCKFS_BUSY) + +#define ULOCKFS_CLR_FALLOC(LF) ((LF)->ul_flag &= ~ULOCKFS_FALLOC) +#define ULOCKFS_SET_FALLOC(LF) ((LF)->ul_flag |= ULOCKFS_FALLOC) + +/* + * ul_fs_mod + */ +#define ULOCKFS_SET_MOD(LF) ((LF)->ul_fs_mod = 1) +#define ULOCKFS_CLR_MOD(LF) ((LF)->ul_fs_mod = 0) +#define ULOCKFS_IS_MOD(LF) ((LF)->ul_fs_mod) + +/* + * ul_fs_lock + * + * softlock will temporarily block most ufs_vnodeops. + * it is used so that a waiting lockfs command will not be starved + * + * fwlock will block other fallocate threads wanting to obtain a write lock + * on the file system. + */ +#define ULOCKFS_ULOCK ((1 << LOCKFS_ULOCK)) /* unlock */ +#define ULOCKFS_WLOCK ((1 << LOCKFS_WLOCK)) /* write lock */ +#define ULOCKFS_NLOCK ((1 << LOCKFS_NLOCK)) /* name lock */ +#define ULOCKFS_DLOCK ((1 << LOCKFS_DLOCK)) /* delete lock */ +#define ULOCKFS_HLOCK ((1 << LOCKFS_HLOCK)) /* hard lock */ +#define ULOCKFS_ELOCK ((1 << LOCKFS_ELOCK)) /* error lock */ +#define ULOCKFS_ROELOCK ((1 << LOCKFS_ROELOCK)) /* error lock (read-only) */ +/* Maximum number of LOCKFS lockfs defined in sys/lockfs.h are 6 */ +#define ULOCKFS_FWLOCK (1 << (LOCKFS_MAXLOCK + 1)) /* fallocate write lock */ +#define ULOCKFS_SLOCK 0x80000000 /* soft lock */ + +#define ULOCKFS_IS_WLOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_WLOCK) +#define ULOCKFS_IS_HLOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_HLOCK) +#define ULOCKFS_IS_ELOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_ELOCK) +#define ULOCKFS_IS_ROELOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_ROELOCK) +#define ULOCKFS_IS_ULOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_ULOCK) +#define ULOCKFS_IS_NLOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_NLOCK) +#define ULOCKFS_IS_DLOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_DLOCK) +#define ULOCKFS_IS_SLOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_SLOCK) +#define ULOCKFS_IS_FWLOCK(LF) ((LF)->ul_fs_lock & ULOCKFS_FWLOCK) +#define ULOCKFS_IS_JUSTULOCK(LF) \ + (((LF)->ul_fs_lock & (ULOCKFS_SLOCK | ULOCKFS_ULOCK)) == ULOCKFS_ULOCK) + +#define ULOCKFS_SET_SLOCK(LF) ((LF)->ul_fs_lock |= ULOCKFS_SLOCK) +#define ULOCKFS_CLR_SLOCK(LF) ((LF)->ul_fs_lock &= ~ULOCKFS_SLOCK) + +#define ULOCKFS_SET_FWLOCK(LF) ((LF)->ul_fs_lock |= ULOCKFS_FWLOCK) +#define ULOCKFS_CLR_FWLOCK(LF) ((LF)->ul_fs_lock &= ~ULOCKFS_FWLOCK) + +#define ULOCKFS_READ_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_WRITE_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +/* used by both ufs_getattr and ufs_getsecattr */ +#define ULOCKFS_GETATTR_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +/* used by both ufs_setattr and ufs_setsecattr */ +#define ULOCKFS_SETATTR_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_ACCESS_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_LOOKUP_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_CREATE_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_REMOVE_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK | \ + ULOCKFS_NLOCK | ULOCKFS_DLOCK) +#define ULOCKFS_LINK_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_RENAME_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_SLOCK | ULOCKFS_WLOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_NLOCK) +#define ULOCKFS_MKDIR_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_RMDIR_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK | \ + ULOCKFS_NLOCK | ULOCKFS_DLOCK) +#define ULOCKFS_READDIR_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_SYMLINK_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_READLINK_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_FSYNC_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_FID_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_RWLOCK_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_RWUNLOCK_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_SEEK_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_FRLOCK_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_SPACE_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_FALLOCATE_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | \ + ULOCKFS_WLOCK | ULOCKFS_FWLOCK) +#define ULOCKFS_QUOTA_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +/* GETPAGE breaks up into two masks */ +#define ULOCKFS_GETREAD_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_GETWRITE_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_MAP_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_FIODUTIMES_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_FIODIO_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) +#define ULOCKFS_FIODIOS_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_PATHCONF_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) + +#define ULOCKFS_VGET_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | ULOCKFS_SLOCK) +#define ULOCKFS_DELETE_MASK (ULOCKFS_HLOCK | ULOCKFS_ELOCK | \ + ULOCKFS_ROELOCK | ULOCKFS_SLOCK | ULOCKFS_WLOCK) + +struct ulockfs { + ulong_t ul_flag; /* flags */ + ulong_t ul_fs_lock; /* current file system lock state */ + ulong_t ul_fs_mod; /* for test; fs was modified */ + ulong_t ul_vnops_cnt; /* # of active ufs vnops outstanding */ + kmutex_t ul_lock; /* mutex to protect ulockfs structure */ + kcondvar_t ul_cv; + kthread_id_t ul_sbowner; /* thread than can write superblock */ + struct lockfs ul_lockfs; /* ioctl lock struct */ + ulong_t ul_falloc_cnt; /* # of on-going fallocate ops */ +}; + +extern ulong_t ufs_quiesce_pend; + +#define VTOUL(VP) \ + ((struct ulockfs *) \ + &((struct ufsvfs *)((VP)->v_vfsp->vfs_data))->vfs_ulockfs) +#define ITOUL(IP) ((struct ulockfs *)&((IP)->i_ufsvfs->vfs_ulockfs)) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_LOCKFS_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_log.h b/illumos-x86_64/usr/include/sys/fs/ufs_log.h new file mode 100644 index 00000000..d71aff1d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_log.h @@ -0,0 +1,691 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_UFS_LOG_H +#define _SYS_FS_UFS_LOG_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct lufs_save { + buf_t *sv_bp; + size_t sv_nb_left; + int sv_error; +} lufs_save_t; + +typedef struct lufs_buf { + buf_t lb_buf; + void *lb_ptr; +} lufs_buf_t; + +/* + * Log space is stored as extents + */ +#define LUFS_EXTENTS (UINT32_C(0)) +#define LS_SECTORS 2 + +typedef struct extent { + uint32_t lbno; /* Logical block # within the space */ + uint32_t pbno; /* Physical block number of extent. */ + /* in disk blocks for non-MTB ufs */ + /* in frags for MTB ufs */ + uint32_t nbno; /* # blocks in this extent */ +} extent_t; + +typedef struct ic_extent { + uint32_t ic_lbno; /* Logical block # within the space */ + uint32_t ic_nbno; /* # blocks in this extent */ + daddr_t ic_pbno; /* Physical block number of extent. */ + /* (always in disk blocks) */ +} ic_extent_t; + +typedef struct extent_block { + uint32_t type; /* Set to LUFS_EXTENTS to identify */ + /* structure on disk. */ + int32_t chksum; /* Checksum over entire block. */ + uint32_t nextents; /* Size of extents array. */ + uint32_t nbytes; /* # bytes mapped by extent_block. */ + uint32_t nextbno; /* blkno of next extent_block. */ + extent_t extents[1]; +} extent_block_t; + +typedef struct ic_extent_block { + uint32_t ic_nextents; /* Size of extents array. */ + uint32_t ic_nbytes; /* # bytes mapped by extent_block. */ + uint32_t ic_nextbno; /* blkno of next extent_block. */ + ic_extent_t ic_extents[1]; +} ic_extent_block_t; + +/* + * Don't size the incore buffers too small or too large + */ +#define LDL_MINTRANSFER (UINT32_C(32768)) /* 32 k */ +#define LDL_MAXTRANSFER (UINT32_C(1048576)) /* 1 M */ + +/* + * LDL_DIVISOR (ldl_divisor) is the number to calculate the log size + * from the file system size according to the calculation in lufs_enable() + */ +#define LDL_DIVISOR 1024 /* 1024 gives 1MB per 1GB */ + +/* + * This gives the maximum size of log for which the 1MB per 1GB rule + * applies. The size of the log will only be greater than this based + * on the cylinder group space requirements. + */ +#define LDL_SOFTLOGCAP (256 * 1024 * 1024) + +/* + * But set reasonable min/max units + */ +#define LDL_MINLOGSIZE (1024 * 1024) +#define LDL_MAXLOGSIZE (512 * 1024 * 1024) + +/* + * Log space requirement per cylinder group. This needs to accommodate a + * cg delta (inc. header) and have a factor to cover other deltas involved + * in a single transaction which could touch all cyl groups in a file system. + */ +#define LDL_CGSIZEREQ(fs) \ + ((fs)->fs_cgsize + ((fs)->fs_cgsize >> 1)) + +#define LDL_MINBUFSIZE (32 * 1024) +#define LDL_USABLE_BSIZE (DEV_BSIZE - sizeof (sect_trailer_t)) +#define NB_LEFT_IN_SECTOR(off) (LDL_USABLE_BSIZE - ((off) - dbtob(btodb(off)))) + +typedef struct cirbuf { + buf_t *cb_bp; /* buf's with space in circular buf */ + buf_t *cb_dirty; /* filling this buffer for log write */ + buf_t *cb_free; /* free bufs list */ + caddr_t cb_va; /* address of circular buffer */ + size_t cb_nb; /* size of circular buffer */ + krwlock_t cb_rwlock; /* r/w lock to protect list mgmt. */ +} cirbuf_t; + +#define LUFS_VERSION (UINT32_C(1)) /* Version 1 */ +#define LUFS_VERSION_LATEST LUFS_VERSION + +/* + * The old Disksuite unit structure has been split into two parts -- the + * incore part which is created at run time and the ondisk structure. To + * minimize code changes, the incore structure retains the old name, + * ml_unit_t and the ondisk structure is called ml_odunit_t. The ondisk + * structure is stored at the beginning of the log. + * + * This structure must fit into a sector (512b) + * + */ +typedef struct ml_odunit { + uint32_t od_version; /* version number */ + uint32_t od_badlog; /* is the log okay? */ + uint32_t od_unused1; + + /* + * Important constants + */ + uint32_t od_maxtransfer; /* max transfer in bytes */ + uint32_t od_devbsize; /* device bsize */ + int32_t od_bol_lof; /* byte offset to begin of log */ + int32_t od_eol_lof; /* byte offset to end of log */ + + /* + * The disk space is split into state and circular log + */ + uint32_t od_requestsize; /* size requested by user */ + uint32_t od_statesize; /* size of state area in bytes */ + uint32_t od_logsize; /* size of log area in bytes */ + int32_t od_statebno; /* first block of state area */ + int32_t od_unused2; + + /* + * Head and tail of log + */ + int32_t od_head_lof; /* byte offset of head */ + uint32_t od_head_ident; /* head sector id # */ + int32_t od_tail_lof; /* byte offset of tail */ + uint32_t od_tail_ident; /* tail sector id # */ + uint32_t od_chksum; /* checksum to verify ondisk contents */ + + /* + * Used for error recovery + */ + uint32_t od_head_tid; /* used for logscan; set at sethead */ + + /* + * Debug bits + */ + int32_t od_debug; + + /* + * Misc + */ + struct timeval od_timestamp; /* time of last state change */ +} ml_odunit_t; + +typedef struct ml_unit { + struct ml_unit *un_next; /* next incore log */ + int un_flags; /* Incore state */ + buf_t *un_bp; /* contains memory for un_ondisk */ + struct ufsvfs *un_ufsvfs; /* backpointer to ufsvfs */ + dev_t un_dev; /* for convenience */ + ic_extent_block_t *un_ebp; /* block of extents */ + size_t un_nbeb; /* # bytes used by *un_ebp */ + struct mt_map *un_deltamap; /* deltamap */ + struct mt_map *un_logmap; /* logmap includes moby trans stuff */ + struct mt_map *un_matamap; /* optional - matamap */ + + /* + * Used for managing transactions + */ + uint32_t un_maxresv; /* maximum reservable space */ + uint32_t un_resv; /* reserved byte count for this trans */ + uint32_t un_resv_wantin; /* reserved byte count for next trans */ + + /* + * Used during logscan + */ + uint32_t un_tid; + + /* + * Read/Write Buffers + */ + cirbuf_t un_rdbuf; /* read buffer space */ + cirbuf_t un_wrbuf; /* write buffer space */ + + /* + * Ondisk state + */ + ml_odunit_t un_ondisk; /* ondisk log information */ + + /* + * locks + */ + kmutex_t un_log_mutex; /* allows one log write at a time */ + kmutex_t un_state_mutex; /* only 1 state update at a time */ +} ml_unit_t; + +/* + * Macros to allow access to the ondisk elements via the ml_unit_t incore + * structure. + */ + +#define un_version un_ondisk.od_version +#define un_badlog un_ondisk.od_badlog +#define un_maxtransfer un_ondisk.od_maxtransfer +#define un_devbsize un_ondisk.od_devbsize +#define un_bol_lof un_ondisk.od_bol_lof +#define un_eol_lof un_ondisk.od_eol_lof +#define un_statesize un_ondisk.od_statesize +#define un_logsize un_ondisk.od_logsize +#define un_statebno un_ondisk.od_statebno +#define un_requestsize un_ondisk.od_requestsize +#define un_head_lof un_ondisk.od_head_lof +#define un_head_ident un_ondisk.od_head_ident +#define un_tail_lof un_ondisk.od_tail_lof +#define un_tail_ident un_ondisk.od_tail_ident +#define un_chksum un_ondisk.od_chksum +#define un_head_tid un_ondisk.od_head_tid +#define un_debug un_ondisk.od_debug +#define un_timestamp un_ondisk.od_timestamp + +/* + * un_flags + */ +#define LDL_SCAN 0x0001 /* log scan in progress */ +#define LDL_ERROR 0x0002 /* in error state */ +#define LDL_NOROLL 0x0004 /* Log Not Yet Rollable */ + +typedef struct sect_trailer { + uint32_t st_tid; /* transaction id */ + uint32_t st_ident; /* unique sector id */ +} sect_trailer_t; + +/* + * map block + */ +#define MAPBLOCKSIZE (8192) +#define MAPBLOCKSHIFT (13) +#define MAPBLOCKOFF (MAPBLOCKSIZE-1) +#define MAPBLOCKMASK (~MAPBLOCKOFF) +#define DEV_BMASK (DEV_BSIZE - 1) + +/* + * cached roll buffer + */ +typedef struct crb { + int64_t c_mof; /* master file offset of buffer */ + caddr_t c_buf; /* pointer to cached roll buffer */ + uint32_t c_nb; /* size of buffer */ + ushort_t c_refcnt; /* reference count on crb */ + uchar_t c_invalid; /* crb should not be used */ +} crb_t; + +#define CRB_END ((crb_t *)1) /* must be non zero */ + +/* + * delta header + */ +struct delta { + int64_t d_mof; /* byte offset on device to start writing */ + /* delta */ + int32_t d_nb; /* # bytes in the delta */ + delta_t d_typ; /* Type of delta. Defined in ufs_trans.h */ +}; +/* + * common map entry + */ +typedef struct mapentry mapentry_t; +struct mapentry { + /* + * doubly linked list of all mapentries in map -- MUST BE FIRST + */ + mapentry_t *me_next; + mapentry_t *me_prev; + + mapentry_t *me_hash; + mapentry_t *me_agenext; + mapentry_t *me_cancel; + crb_t *me_crb; + int (*me_func)(); + ulong_t me_arg; + ulong_t me_age; + struct delta me_delta; + uint32_t me_tid; + off_t me_lof; + ushort_t me_flags; +}; + +#define me_mof me_delta.d_mof +#define me_nb me_delta.d_nb +#define me_dt me_delta.d_typ + +/* + * me_flags + */ +#define ME_SCAN (0x0001) /* entry from log scan */ +#define ME_HASH (0x0002) /* on hash list */ +#define ME_CANCEL (0x0004) /* on cancel list */ +#define ME_AGE (0x0008) /* on age list */ +#define ME_LIST (0x0010) /* on list list */ +#define ME_ROLL (0x0020) /* on pseudo-roll list */ +#define ME_USER (0x0040) /* User Block DT_CANCEL entry */ + +/* + * MAP TYPES + */ +enum maptypes { + deltamaptype, logmaptype, matamaptype +}; + +/* + * MAP + */ +#define DELTAMAP_NHASH (512) +#define LOGMAP_NHASH (2048) +#define MAP_INDEX(mof, mtm) \ + (((mof) >> MAPBLOCKSHIFT) & (mtm->mtm_nhash-1)) +#define MAP_HASH(mof, mtm) \ + ((mtm)->mtm_hash + MAP_INDEX((mof), (mtm))) + +typedef struct mt_map { + /* + * anchor doubly linked list this map's entries -- MUST BE FIRST + */ + mapentry_t *mtm_next; + mapentry_t *mtm_prev; + + enum maptypes mtm_type; /* map type */ + int mtm_flags; /* generic flags */ + int mtm_ref; /* PTE like ref bit */ + ulong_t mtm_debug; /* set at create time */ + ulong_t mtm_age; /* mono-inc; tags mapentries */ + mapentry_t *mtm_cancel; /* to be canceled at commit */ + ulong_t mtm_nhash; /* # of hash anchors */ + mapentry_t **mtm_hash; /* array of singly linked lists */ + struct topstats *mtm_tops; /* trans ops - enabled by an ioctl */ + long mtm_nme; /* # of mapentries */ + long mtm_nmet; /* # of mapentries this transaction */ + long mtm_cfrags; /* Canceled frags */ + long mtm_cfragmax; /* Maximum canceled frags */ + /* + * used after logscan to set the log's tail + */ + off_t mtm_tail_lof; + size_t mtm_tail_nb; + + /* + * debug field for Scan test + */ + off_t mtm_trimlof; /* log was trimmed to this lof */ + off_t mtm_trimtail; /* tail lof before trimming */ + off_t mtm_trimalof; /* lof of last allocation delta */ + off_t mtm_trimclof; /* lof of last commit delta */ + off_t mtm_trimrlof; /* lof of last rolled delta */ + ml_unit_t *mtm_ul; /* log unit for this map */ + + /* + * moby trans stuff + */ + uint32_t mtm_tid; + uint32_t mtm_committid; + ushort_t mtm_closed; + ushort_t mtm_seq; + long mtm_wantin; + long mtm_active; + long mtm_activesync; + ulong_t mtm_dirty; + kmutex_t mtm_lock; + kcondvar_t mtm_cv_commit; + kcondvar_t mtm_cv_next; + kcondvar_t mtm_cv_eot; + + /* + * mutex that protects all the fields in mt_map except + * mtm_mapnext and mtm_refcnt + */ + kmutex_t mtm_mutex; + + /* + * logmap only condition variables + */ + kcondvar_t mtm_to_roll_cv; /* roll log or kill roll thread */ + kcondvar_t mtm_from_roll_cv; /* log rolled or thread exiting */ + + /* + * rw lock for the agenext mapentry field + */ + krwlock_t mtm_rwlock; + /* + * DEBUG: runtestscan + */ + kmutex_t mtm_scan_mutex; + + /* + * logmap only taskq sync count variable, protected by mtm_lock. + * keeps track of the number of pending top_issue_sync + * dispatches. + */ + int mtm_taskq_sync_count; + + /* + * logmap only condition variable, to synchronize with lufs_unsnarf. + */ + kcondvar_t mtm_cv; +} mt_map_t; + +/* + * mtm_flags + */ +#define MTM_ROLL_EXIT 0x00000001 /* force roll thread to exit */ +#define MTM_ROLL_RUNNING 0x00000002 /* roll thread is running */ +#define MTM_FORCE_ROLL 0x00000004 /* force at least one roll cycle */ +#define MTM_ROLLING 0x00000008 /* currently rolling the log */ +#define MTM_CANCELED 0x00000010 /* cancel entries were removed */ + +/* + * Generic range checking macros + */ +#define OVERLAP(sof, snb, dof, dnb) \ + (((sof) >= (dof) && (sof) < ((dof) + (dnb))) || \ + ((dof) >= (sof) && (dof) < ((sof) + (snb)))) +#define WITHIN(sof, snb, dof, dnb) \ + (((sof) >= (dof)) && (((sof) + (snb)) <= ((dof) + (dnb)))) +#define DATAoverlapME(mof, hnb, me) \ + (OVERLAP((mof), (hnb), (me)->me_mof, (me)->me_nb)) +#define MEwithinDATA(me, mof, hnb) \ + (WITHIN((me)->me_mof, (me)->me_nb, (mof), (hnb))) +#define DATAwithinME(mof, hnb, me) \ + (WITHIN((mof), (hnb), (me)->me_mof, (me)->me_nb)) +#define DATAwithinCRB(mof, nb, crb) \ + (WITHIN((mof), (nb), (crb)->c_mof, (crb)->c_nb)) + +/* + * TRANSACTION OPS STATS + */ +typedef struct topstats { + uint64_t mtm_top_num[TOP_MAX]; + uint64_t mtm_top_size_etot[TOP_MAX]; + uint64_t mtm_top_size_rtot[TOP_MAX]; + uint64_t mtm_top_size_max[TOP_MAX]; + uint64_t mtm_top_size_min[TOP_MAX]; + uint64_t mtm_delta_num[DT_MAX]; +} topstats_t; + +/* + * fio_lufs_stats_t is used by _FIO_GET_TOP_STATS ioctl for getting topstats + */ +typedef struct fio_lufs_stats { + uint32_t ls_debug; /* out: un_debug value */ + uint32_t _ls_pad; /* make size 64-bit aligned on x86 */ + topstats_t ls_topstats; /* out: transaction stats */ +} fio_lufs_stats_t; + +/* + * roll buf structure; one per roll buffer + */ +typedef uint16_t rbsecmap_t; +typedef struct rollbuf { + buf_t rb_bh; /* roll buffer header */ + struct rollbuf *rb_next; /* link for mof ordered roll bufs */ + crb_t *rb_crb; /* cached roll buffer to roll */ + mapentry_t *rb_age; /* age list */ + rbsecmap_t rb_secmap; /* sector map */ +} rollbuf_t; + +/* + * un_debug + * MT_TRANSACT - keep per thread accounting of tranactions + * MT_MATAMAP - double check deltas and ops against matamap + * MT_WRITE_CHECK - check master+deltas against metadata write + * MT_LOG_WRITE_CHECK - read after write for log writes + * MT_CHECK_MAP - check map after every insert/delete + * MT_TRACE - trace transactions (used with MT_TRANSACT) + * MT_SIZE - fail on size errors (used with MT_TRANSACT) + * MT_NOASYNC - force every op to be sync + * MT_FORCEROLL - forcibly roll the log after every commit + * MT_SCAN - running runtestscan; special case as needed + */ +#define MT_NONE (0x00000000) +#define MT_TRANSACT (0x00000001) +#define MT_MATAMAP (0x00000002) +#define MT_WRITE_CHECK (0x00000004) +#define MT_LOG_WRITE_CHECK (0x00000008) +#define MT_CHECK_MAP (0x00000010) +#define MT_TRACE (0x00000020) +#define MT_SIZE (0x00000040) +#define MT_NOASYNC (0x00000080) +#define MT_FORCEROLL (0x00000100) +#define MT_SCAN (0x00000200) + +struct logstats { + kstat_named_t ls_lreads; /* master reads */ + kstat_named_t ls_lwrites; /* master writes */ + kstat_named_t ls_lreadsinmem; /* log reads in memory */ + kstat_named_t ls_ldlreads; /* log reads */ + kstat_named_t ls_ldlwrites; /* log writes */ + kstat_named_t ls_mreads; /* log master reads */ + kstat_named_t ls_rreads; /* log roll reads */ + kstat_named_t ls_rwrites; /* log roll writes */ +}; + +#ifdef _KERNEL + +typedef struct threadtrans { + ulong_t deltas_size; /* size of deltas this transaction */ + uint32_t last_async_tid; /* last async transaction id */ + uchar_t any_deltas; /* any deltas done this transaction */ +#ifdef DEBUG + uint_t topid; /* transaction type */ + ulong_t esize; /* estimated trans size */ + ulong_t rsize; /* real trans size */ + dev_t dev; /* device */ +#endif /* DEBUG */ +} threadtrans_t; + +/* + * Log layer protos -- lufs_log.c + */ +extern void ldl_strategy(ml_unit_t *, buf_t *); +extern void ldl_round_commit(ml_unit_t *); +extern void ldl_push_commit(ml_unit_t *); +extern int ldl_need_commit(ml_unit_t *); +extern int ldl_has_space(ml_unit_t *, mapentry_t *); +extern void ldl_write(ml_unit_t *, caddr_t, offset_t, mapentry_t *); +extern void ldl_waito(ml_unit_t *); +extern int ldl_read(ml_unit_t *, caddr_t, offset_t, off_t, + mapentry_t *); +extern void ldl_sethead(ml_unit_t *, off_t, uint32_t); +extern void ldl_settail(ml_unit_t *, off_t, size_t); +extern ulong_t ldl_logscan_nbcommit(off_t); +extern int ldl_logscan_read(ml_unit_t *, off_t *, size_t, caddr_t); +extern void ldl_logscan_begin(ml_unit_t *); +extern void ldl_logscan_end(ml_unit_t *); +extern int ldl_need_roll(ml_unit_t *); +extern void ldl_seterror(ml_unit_t *, char *); +extern size_t ldl_bufsize(ml_unit_t *); +extern void ldl_savestate(ml_unit_t *); +extern void free_cirbuf(cirbuf_t *); +extern void alloc_rdbuf(cirbuf_t *, size_t, size_t); +extern void alloc_wrbuf(cirbuf_t *, size_t); + +/* + * trans driver layer -- lufs.c + */ +extern int trans_not_wait(struct buf *cb); +extern int trans_not_done(struct buf *cb); +extern int trans_wait(struct buf *cb); +extern int trans_done(struct buf *cb); +extern void lufs_strategy(ml_unit_t *, buf_t *); +extern void lufs_read_strategy(ml_unit_t *, buf_t *); +extern void lufs_write_strategy(ml_unit_t *, buf_t *); +extern void lufs_init(void); +extern uint32_t lufs_hd_genid(const ml_unit_t *); +extern int lufs_enable(struct vnode *, struct fiolog *, cred_t *); +extern int lufs_disable(vnode_t *, struct fiolog *); + +/* + * transaction op layer -- lufs_top.c + */ +extern void _init_top(void); +extern int top_read_roll(rollbuf_t *, ml_unit_t *); + + +/* + * map layer -- lufs_map.c + */ +extern void map_free_entries(mt_map_t *); +extern int matamap_overlap(mt_map_t *, offset_t, off_t); +extern int matamap_within(mt_map_t *, offset_t, off_t); +extern int deltamap_need_commit(mt_map_t *); +extern void deltamap_add(mt_map_t *, offset_t, off_t, delta_t, + int (*)(), ulong_t, threadtrans_t *tp); +extern mapentry_t *deltamap_remove(mt_map_t *, offset_t, off_t); +extern void deltamap_del(mt_map_t *, offset_t, off_t); +extern void deltamap_push(ml_unit_t *); +extern void logmap_cancel_remove(mt_map_t *); +extern int logmap_need_commit(mt_map_t *); +extern int logmap_need_roll_async(mt_map_t *); +extern int logmap_need_roll_sync(mt_map_t *); +extern void logmap_start_roll(ml_unit_t *); +extern void logmap_kill_roll(ml_unit_t *); +extern void logmap_forceroll(mt_map_t *); +extern void logmap_forceroll_nowait(mt_map_t *); +extern int logmap_overlap(mt_map_t *, offset_t, off_t); +extern void logmap_remove_roll(mt_map_t *, offset_t, off_t); +extern int logmap_next_roll(mt_map_t *, offset_t *); +extern int logmap_list_get(mt_map_t *, offset_t, off_t, + mapentry_t **); +extern int logmap_list_get_roll(mt_map_t *, offset_t, rollbuf_t *); +extern void logmap_list_put(mt_map_t *, mapentry_t *); +extern void logmap_list_put_roll(mt_map_t *, mapentry_t *); +extern int logmap_setup_read(mapentry_t *, rollbuf_t *); +extern void logmap_make_space(struct mt_map *, ml_unit_t *, + mapentry_t *); +extern void logmap_add(ml_unit_t *, char *, offset_t, mapentry_t *); +extern void logmap_add_buf(ml_unit_t *, char *, offset_t, + mapentry_t *, caddr_t, uint32_t); +extern void logmap_commit(ml_unit_t *, uint32_t); +extern void logmap_sethead(mt_map_t *, ml_unit_t *); +extern void logmap_settail(mt_map_t *, ml_unit_t *); +extern void logmap_roll_dev(ml_unit_t *ul); +extern void logmap_cancel(ml_unit_t *, offset_t, off_t, int); +extern void logmap_free_cancel(mt_map_t *, mapentry_t **); +extern int logmap_iscancel(mt_map_t *, offset_t, off_t); +extern void logmap_logscan(ml_unit_t *); +extern mt_map_t *map_put(mt_map_t *); +extern mt_map_t *map_get(ml_unit_t *, enum maptypes, int); +extern void _init_map(void); + +/* + * scan and roll threads -- lufs_thread.c + */ +extern void trans_roll(ml_unit_t *); + +/* + * DEBUG + */ +#ifdef DEBUG +extern int map_put_debug(mt_map_t *); +extern int map_get_debug(ml_unit_t *, mt_map_t *); +extern int top_write_debug(ml_unit_t *, mapentry_t *, offset_t, off_t); +extern int matamap_overlap(mt_map_t *, offset_t, off_t); +extern int ldl_sethead_debug(ml_unit_t *); +extern int map_check_linkage(mt_map_t *); +extern int logmap_logscan_debug(mt_map_t *, mapentry_t *); +extern int map_check_ldl_write(ml_unit_t *, caddr_t, offset_t, + mapentry_t *); +extern int logmap_logscan_commit_debug(off_t, mt_map_t *); +extern int logmap_logscan_add_debug(struct delta *, mt_map_t *); +extern int top_delta_debug(ml_unit_t *, offset_t, off_t, delta_t); +extern int top_begin_debug(ml_unit_t *, top_t, ulong_t); +extern int top_end_debug(ml_unit_t *, mt_map_t *, top_t, ulong_t); +extern int top_roll_debug(ml_unit_t *); +extern int top_init_debug(void); +extern int lufs_initialize_debug(ml_odunit_t *); +#endif /* DEBUG */ + +extern uint64_t delta_stats[DT_MAX]; +extern uint64_t roll_stats[DT_MAX]; +extern struct logstats logstats; +extern int ufs_crb_enable; + +extern uint_t topkey; +extern uint32_t ufs_ncg_log; + +extern uint_t lufs_debug; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_LOG_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_mount.h b/illumos-x86_64/usr/include/sys/fs/ufs_mount.h new file mode 100644 index 00000000..71d7fb3e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_mount.h @@ -0,0 +1,72 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 1996-1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FS_UFS_MOUNT_H +#define _SYS_FS_UFS_MOUNT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct ufs_args { + int flags; +}; + +/* + * UFS mount option flags + */ +#define UFSMNT_NOINTR 0x00000001 /* disallow interrupts on lockfs */ +#define UFSMNT_SYNCDIR 0x00000002 /* synchronous local directory ops */ +#define UFSMNT_NOSETSEC 0x00000004 /* disallow use of ufs_setsecattr */ +#define UFSMNT_LARGEFILES 0x00000008 /* allow large files */ +#define UFSMNT_NOATIME 0x00001000 /* disable updates of i_atime */ +/* deferred inode time */ +#define UFSMNT_NODFRATIME 0x00002000 /* no deferred access time */ +/* action to take when internal inconsistency is detected */ +#define UFSMNT_ONERROR_PANIC 0x00000020 /* forced system shutdown */ +#define UFSMNT_ONERROR_LOCK 0x00000040 /* error lock the fs */ +#define UFSMNT_ONERROR_UMOUNT 0x00000080 /* forced umount of the fs */ +#define UFSMNT_ONERROR_FLGMASK 0x000000E0 +/* default action is to repair fs */ +#define UFSMNT_ONERROR_DEFAULT UFSMNT_ONERROR_PANIC +#define UFSMNT_DISABLEDIRECTIO 0x00000100 /* disable directio ioctls */ +/* Force DirectIO */ +#define UFSMNT_FORCEDIRECTIO 0x00000200 /* directio for all files */ +#define UFSMNT_NOFORCEDIRECTIO 0x00000400 /* no directio for all files */ +/* logging */ +#define UFSMNT_LOGGING 0x00000800 /* enable logging */ + +#define UFSMNT_ONERROR_PANIC_STR "panic" +#define UFSMNT_ONERROR_LOCK_STR "lock" +#define UFSMNT_ONERROR_UMOUNT_STR "umount" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_MOUNT_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_panic.h b/illumos-x86_64/usr/include/sys/fs/ufs_panic.h new file mode 100644 index 00000000..2a802436 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_panic.h @@ -0,0 +1,159 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_UFS_PANIC_H +#define _SYS_FS_UFS_PANIC_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) + +/* + * failures have an associated state + * making them bit values simplifies state transition validity checking + */ + +typedef enum ufs_failure_states { + /* initial states, set mostly by thread encountering failure */ + UF_UNDEF = 0x0000, /* freshly-allocated memory */ + UF_INIT = 0x0001, /* being created */ + UF_QUEUE = 0x0002, /* queued for fix thread */ + + /* transitional states, set mostly by fix failure thread */ + UF_TRYLCK = 0x0010, /* attempting to be locked */ + UF_LOCKED = 0x0020, /* error lock set */ + UF_UMOUNT = 0x0040, /* attempting to be unmounted */ + UF_FIXING = 0x0080, /* fsck started; attempting unlock */ + + /* terminal states, once in this state, fix failure thread is done */ + UF_FIXED = 0x0100, /* no problemo, man */ + UF_NOTFIX = 0x0200, /* can't fix; shouldn't panic */ + UF_REPLICA = 0x0400, /* replica panic; fix original only */ + UF_PANIC = 0x0800, /* gave up/exceeded limits/can't fix */ + /* not strictly a terminal state, */ + /* because we will do some actions */ + /* if we find a failure in this state */ + /* but those actions will be terminal */ + + /* handy, but used only as terminators and placeholders */ + UF_ILLEGAL = 0xffff, /* invalid state */ + UF_ALLSTATES = 0x0ff3 /* all possible state */ +} ufs_failure_states_t; + +/* + * each manifestation of a fault (ie. "panic") is + * associated with a distinct ufs_failure event + */ + +typedef struct ufs_failure +{ + struct ufs_failure *uf_chain[2]; /* protected by ufs_elock mux */ + struct ufs_failure *uf_orig; /* if duplicate event, */ + /* here's the original */ + struct ufs_failure *uf_master; /* if sharing a logged device */ + /* here's the master failure */ + struct buf *uf_bp; /* ptr to buf containing sb */ + kmutex_t *uf_vfs_lockp; /* ptr to vfs_lock */ + struct vfs_ufsfx *uf_vfs_ufsfxp; /* ptr to fix-on-panic per fs */ + struct vfs *uf_vfsp; /* ptr to vfs */ + struct ufsvfs *uf_ufsvfsp; /* to match if unmounted */ + dev_t uf_dev; /* device id */ + ufs_failure_states_t uf_s; /* current failure state */ + int uf_flags; /* internal flags */ + time_t uf_begin_tm; /* when did panic begin? */ + time_t uf_end_tm; /* ... end? */ + time_t uf_entered_tm; /* ... was state entered? */ + struct lockfs uf_lf; /* needed to set lockfs lock */ + int uf_lf_err; /* errno if lockfs fails */ + long uf_retry; /* seconds */ + unsigned uf_counter; /* of state-specific actions */ + kmutex_t uf_mutex; /* protects struct body */ + char uf_fsname[MAXMNTLEN]; /* for post-unmount errors */ + /* after ufsvfsp is free'd */ + char uf_panic_str[LOCKFS_MAXCOMMENTLEN]; /* original panic message */ + /* XXX could be smaller */ +} ufs_failure_t; + +#define uf_next uf_chain[0] +#define uf_prev uf_chain[1] +#define uf_fs uf_bp->b_un.b_fs + +/* + * per-filesystem panic event state + */ +typedef struct vfs_ufsfx { + long fx_flags; /* see ufs_panic.h for the */ + ufs_failure_t *fx_current; /* currently being fixed */ +} vfs_ufsfx_t; + +/* + * External entry points + * + * ufs_fault(vnode_t *, char *fmt, ...) + * replaces calls to cmn_err(CE_PANIC, char *fmt, ...) + * The vnode is any vnode in the filesystem. + * ufs_fault returns an errno to bubble up. + * ufsfx_init() + * is called at modload time to set global values etc. + * ufsfx_mount() + * is called at mount time to do per-fs initialization + * returns 0 (ok) or errno + * ufsfx_unmount() + * is called at unmount time to prevent spinning on work + * to fix an unmounted fs + * ufsfx_lockfs() + * ufsfx_unlockfs() + * are called at upon (un)locking of a fs for coordination + * ufsfx_get_failure_qlen() + * is called by the hlock thread to coordinate with the fix + * failure thread + */ + +/*PRINTFLIKE2*/ +int ufs_fault(vnode_t *, char *fmt, ...) __KPRINTFLIKE(2); +void ufsfx_init(void); +int ufsfx_mount(struct ufsvfs *, int); +void ufsfx_unmount(struct ufsvfs *); +void ufsfx_lockfs(struct ufsvfs *); +void ufsfx_unlockfs(struct ufsvfs *); +int ufsfx_get_failure_qlen(void); + +extern struct ufs_q ufs_fix; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_PANIC_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_prot.h b/illumos-x86_64/usr/include/sys/fs/ufs_prot.h new file mode 100644 index 00000000..2cd9683a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_prot.h @@ -0,0 +1,210 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _SYS_FS_UFS_PROT_H +#define _SYS_FS_UFS_PROT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +enum ufsdrc_t { + UFSDRC_OK = 0, + UFSDRC_NOENT = ENOENT, + UFSDRC_PERM = EPERM, + UFSDRC_INVAL = EINVAL, + UFSDRC_NOEXEC = ENOEXEC, + UFSDRC_NODEV = ENODEV, + UFSDRC_NXIO = ENXIO, + UFSDRC_BUSY = EBUSY, + UFSDRC_OPNOTSUP = EOPNOTSUPP, + UFSDRC_EXECERR = 254, + UFSDRC_ERR = 255 +}; +typedef enum ufsdrc_t ufsdrc_t; + +struct fs_identity_t { + dev32_t fs_dev; + char *fs_name; +}; +typedef struct fs_identity_t fs_identity_t; + +struct ufsd_repairfs_args_t { + fs_identity_t ua_fsid; + uint_t ua_attempts; +}; +typedef struct ufsd_repairfs_args_t ufsd_repairfs_args_t; + +struct ufsd_repairfs_list_t { + int ual_listlen; + ufsd_repairfs_args_t *ual_list; +}; +typedef struct ufsd_repairfs_list_t ufsd_repairfs_list_t; + +enum ufsd_event_t { + UFSDEV_NONE = 0, + UFSDEV_REBOOT = 0 + 1, + UFSDEV_FSCK = 0 + 2, + UFSDEV_LOG_OP = 0 + 3 +}; +typedef enum ufsd_event_t ufsd_event_t; + +enum ufsd_boot_type_t { + UFSDB_NONE = 0, + UFSDB_CLEAN = 0 + 1, + UFSDB_POSTPANIC = 0 + 2 +}; +typedef enum ufsd_boot_type_t ufsd_boot_type_t; + +enum ufsd_log_op_t { + UFSDLO_NONE = 0, + UFSDLO_COMMIT = 0 + 1, + UFSDLO_GET = 0 + 2, + UFSDLO_PUT = 0 + 3, + UFSDLO_RESET = 0 + 4 +}; +typedef enum ufsd_log_op_t ufsd_log_op_t; + +enum ufsd_fsck_state_t { + UFSDFS_NONE = 0, + UFSDFS_DISPATCH = 0 + 1, + UFSDFS_ERREXIT = 0 + 2, + UFSDFS_SUCCESS = 0 + 3 +}; +typedef enum ufsd_fsck_state_t ufsd_fsck_state_t; +#define UFSD_VARMSGMAX 1024 +#define UFSD_SPAREMSGBYTES 4 + +struct ufsd_log_data_t { + int umld_eob; + int umld_seq; + struct { + uint_t umld_buf_len; + char *umld_buf_val; + } umld_buf; +}; +typedef struct ufsd_log_data_t ufsd_log_data_t; + +struct ufsd_log_msg_t { + ufsd_log_op_t um_lop; + union { + ufsd_log_data_t um_logdata; + } ufsd_log_msg_t_u; +}; +typedef struct ufsd_log_msg_t ufsd_log_msg_t; + +struct ufsd_msg_vardata_t { + ufsd_event_t umv_ev; + union { + ufsd_boot_type_t umv_b; + ufsd_fsck_state_t umv_fs; + ufsd_log_msg_t umv_lm; + } ufsd_msg_vardata_t_u; +}; +typedef struct ufsd_msg_vardata_t ufsd_msg_vardata_t; + +struct ufsd_msg_t { + time32_t um_time; + uint_t um_from; + struct { + uint_t um_spare_len; + char *um_spare_val; + } um_spare; + ufsd_msg_vardata_t um_var; +}; +typedef struct ufsd_msg_t ufsd_msg_t; +#define UFSD_SERVNAME "ufsd" +#define xdr_dev_t xdr_u_int +#define xdr_time_t xdr_int +/* + * Set UFSD_THISVERS to the newest version of the protocol + * This allows the preprocessor to force an error if the + * protocol changes, since the kernel xdr routines may need to be + * recoded. Note that we can't explicitly set the version to a + * symbol as rpcgen will then create erroneous routine names. + */ +#define UFSD_V1 1 +#define UFSD_ORIGVERS UFSD_V1 +#define UFSD_THISVERS 1 + +#define UFSD_PROG ((unsigned long)(100233)) +#define UFSD_VERS ((unsigned long)(1)) + +#define UFSD_NULL ((unsigned long)(0)) +extern ufsdrc_t *ufsd_null_1(void *, CLIENT *); +extern ufsdrc_t *ufsd_null_1_svc(void *, struct svc_req *); +#define UFSD_REPAIRFS ((unsigned long)(1)) +extern ufsdrc_t *ufsd_repairfs_1(ufsd_repairfs_args_t *, CLIENT *); +extern ufsdrc_t * + ufsd_repairfs_1_svc(ufsd_repairfs_args_t *, struct svc_req *); +#define UFSD_REPAIRFSLIST ((unsigned long)(2)) +extern ufsdrc_t *ufsd_repairfslist_1(ufsd_repairfs_list_t *, CLIENT *); +extern ufsdrc_t * + ufsd_repairfslist_1_svc(ufsd_repairfs_list_t *, struct svc_req *); +#define UFSD_SEND ((unsigned long)(3)) +extern ufsdrc_t *ufsd_send_1(ufsd_msg_t *, CLIENT *); +extern ufsdrc_t *ufsd_send_1_svc(ufsd_msg_t *, struct svc_req *); +#define UFSD_RECV ((unsigned long)(4)) +extern ufsdrc_t *ufsd_recv_1(ufsd_msg_t *, CLIENT *); +extern ufsdrc_t *ufsd_recv_1_svc(ufsd_msg_t *, struct svc_req *); +#define UFSD_EXIT ((unsigned long)(5)) +extern ufsdrc_t *ufsd_exit_1(void *, CLIENT *); +extern ufsdrc_t *ufsd_exit_1_svc(void *, struct svc_req *); +extern int ufsd_prog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t); + +/* the xdr functions */ + +extern bool_t xdr_ufsdrc_t(XDR *, ufsdrc_t *); +extern bool_t xdr_fs_identity_t(XDR *, fs_identity_t *); +extern bool_t xdr_ufsd_repairfs_args_t(XDR *, ufsd_repairfs_args_t *); +extern bool_t xdr_ufsd_repairfs_list_t(XDR *, ufsd_repairfs_list_t *); +extern bool_t xdr_ufsd_event_t(XDR *, ufsd_event_t *); +extern bool_t xdr_ufsd_boot_type_t(XDR *, ufsd_boot_type_t *); +extern bool_t xdr_ufsd_log_op_t(XDR *, ufsd_log_op_t *); +extern bool_t xdr_ufsd_fsck_state_t(XDR *, ufsd_fsck_state_t *); +extern bool_t xdr_ufsd_log_data_t(XDR *, ufsd_log_data_t *); +extern bool_t xdr_ufsd_log_msg_t(XDR *, ufsd_log_msg_t *); +extern bool_t xdr_ufsd_msg_vardata_t(XDR *, ufsd_msg_vardata_t *); +extern bool_t xdr_ufsd_msg_t(XDR *, ufsd_msg_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_FS_UFS_PROT_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_quota.h b/illumos-x86_64/usr/include/sys/fs/ufs_quota.h new file mode 100644 index 00000000..d05134aa --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_quota.h @@ -0,0 +1,200 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1999 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_FS_UFS_QUOTA_H +#define _SYS_FS_UFS_QUOTA_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Lock order for the quota sub-system: + * + * vfs_dqrwlock > ip.i_contents > dq_cachelock > dquot.dq_lock > dq_freelock + * vfs_dqrwlock > ip.i_contents > dq_cachelock > dq_freelock + * vfs_dqrwlock > ip.i_contents > dquot.dq_lock > dq_freelock + * vfs_dqrwlock > ip.i_contents > dq_freelock + * vfs_dqrwlock > ip.i_contents > dq_cachelock > dquot.dq_lock > qip.i_contents + */ + +/* + * The following constants define the default amount of time given a user + * before the soft limits are treated as hard limits (usually resulting + * in an allocation failure). These may be modified by the quotactl + * system call with the Q_SETQLIM or Q_SETQUOTA commands. + */ + +#define DQ_FTIMELIMIT (7 * 24*60*60) /* 1 week */ +#define DQ_BTIMELIMIT (7 * 24*60*60) /* 1 week */ + +/* + * The dqblk structure defines the format of the disk quota file + * (as it appears on disk) - the file is an array of these structures + * indexed by user number. The setquota sys call establishes the inode + * for each quota file (a pointer is retained in the mount structure). + */ + +struct dqblk { + uint32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */ + uint32_t dqb_bsoftlimit; /* preferred limit on disk blks */ + uint32_t dqb_curblocks; /* current block count */ + uint32_t dqb_fhardlimit; /* maximum # allocated files + 1 */ + uint32_t dqb_fsoftlimit; /* preferred file limit */ + uint32_t dqb_curfiles; /* current # allocated files */ + uint32_t dqb_btimelimit; /* time limit for excessive disk use */ + uint32_t dqb_ftimelimit; /* time limit for excessive files */ +}; + +#define dqoff(UID) (((offset_t)(UID) * sizeof (struct dqblk))) + +/* + * The dquot structure records disk usage for a user on a filesystem. + * There is one allocated for each quota that exists on any filesystem + * for the current user. A cache is kept of recently used entries. + * Active inodes have a pointer to the dquot associated with them. + */ +struct dquot { + struct dquot *dq_forw, *dq_back; /* hash list, MUST be first entry */ + struct dquot *dq_freef, *dq_freeb; /* free list */ + short dq_flags; +#define DQ_ERROR 0x01 /* An error occurred reading dq */ +#define DQ_MOD 0x04 /* this quota modified since read */ +#define DQ_BLKS 0x10 /* has been warned about blk limit */ +#define DQ_FILES 0x20 /* has been warned about file limit */ +#define DQ_TRANS 0x40 /* logging ufs operation started */ + ulong_t dq_cnt; /* count of active references */ + uid_t dq_uid; /* user this applies to */ + struct ufsvfs *dq_ufsvfsp; /* filesystem this relates to */ + offset_t dq_mof; /* master disk offset of quota record */ + struct dqblk dq_dqb; /* actual usage & quotas */ +#ifdef _KERNEL + kmutex_t dq_lock; /* per dq structure lock */ +#endif /* _KERNEL */ +}; + +#define dq_bhardlimit dq_dqb.dqb_bhardlimit +#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit +#define dq_curblocks dq_dqb.dqb_curblocks +#define dq_fhardlimit dq_dqb.dqb_fhardlimit +#define dq_fsoftlimit dq_dqb.dqb_fsoftlimit +#define dq_curfiles dq_dqb.dqb_curfiles +#define dq_btimelimit dq_dqb.dqb_btimelimit +#define dq_ftimelimit dq_dqb.dqb_ftimelimit + +/* + * flags for vfs_qflags in ufsvfs struct + */ +#define MQ_ENABLED 0x01 /* quotas are enabled */ + +#if defined(_KERNEL) + +/* + * dquot chach hash chain headers + */ +#define NDQHASH 64 /* smallish power of two */ +#define DQHASH(uid, mp) \ + (((uintptr_t)(mp) + (unsigned)(uid)) & (NDQHASH-1)) + +struct dqhead { + struct dquot *dqh_forw; /* MUST be first */ + struct dquot *dqh_back; /* MUST be second */ +}; + +extern struct dqhead dqhead[NDQHASH]; + +extern struct dquot *dquot, *dquotNDQUOT; +extern int ndquot; +extern krwlock_t dq_rwlock; /* quota sub-system init lock */ +extern int quotas_initialized; /* quota sub-system init flag */ + +extern void qtinit(); +extern void qtinit2(); +extern struct dquot *getinoquota(struct inode *); +extern int chkdq(struct inode *ip, long, int, struct cred *, char **errp, + size_t *lenp); +extern int chkiq(struct ufsvfs *, int, struct inode *, uid_t, int, + struct cred *, char **errp, size_t *lenp); +extern void dqrele(struct dquot *); +extern int closedq(struct ufsvfs *, struct cred *); +extern int qsync(struct ufsvfs *); + +extern int getdiskquota(uid_t, struct ufsvfs *, int, struct dquot **); +extern void dqput(struct dquot *); +extern void dqupdate(struct dquot *); +extern void dqinval(struct dquot *); +extern void invalidatedq(struct ufsvfs *); + +extern int quotactl(struct vnode *, intptr_t, int flag, struct cred *); + +#endif /* _KERNEL */ + +/* + * Definitions for the 'quotactl' system call. + */ +#define Q_QUOTAON 1 /* turn quotas on */ +#define Q_QUOTAOFF 2 /* turn quotas off */ +#define Q_SETQUOTA 3 /* set disk limits & usage */ +#define Q_GETQUOTA 4 /* get disk limits & usage */ +#define Q_SETQLIM 5 /* set disk limits only */ +#define Q_SYNC 6 /* update disk copy of quota usages */ +#define Q_ALLSYNC 7 /* update disk copy of quota usages for all */ + +#ifdef _SYSCALL32 +/* ILP32 compatible structure for LP64 kernel. */ +struct quotctl32 { + int op; + uid_t uid; + uint32_t addr; +}; +#endif /* SYSCALL32 */ + +struct quotctl { + int op; + uid_t uid; + caddr_t addr; +}; + +#define Q_QUOTACTL 0x00030189 /* ioctl command for quotactl */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_QUOTA_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_snap.h b/illumos-x86_64/usr/include/sys/fs/ufs_snap.h new file mode 100644 index 00000000..f03dfc00 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_snap.h @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_UFS_SNAP_H +#define _SYS_FS_UFS_SNAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* debug levels */ +#define UFSSNAPDB_CREATE 0x01 +#define UFSSNAPDB_DELETE 0x02 + +/* Constants */ +#define UFS_MAX_SNAPBACKFILESIZE (1LL << 39) /* 512 GB */ + +extern int ufs_snap_create(struct vnode *, struct fiosnapcreate_multi *, + cred_t *); +extern int ufs_snap_delete(struct vnode *, struct fiosnapdelete *, cred_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_SNAP_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/ufs_trans.h b/illumos-x86_64/usr/include/sys/fs/ufs_trans.h new file mode 100644 index 00000000..cdaf55c8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/ufs_trans.h @@ -0,0 +1,547 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_UFS_TRANS_H +#define _SYS_FS_UFS_TRANS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * Types of deltas + */ +typedef enum delta_type { + DT_NONE, /* 0 no assigned type */ + DT_SB, /* 1 superblock */ + DT_CG, /* 2 cylinder group */ + DT_SI, /* 3 summary info */ + DT_AB, /* 4 allocation block */ + DT_ABZERO, /* 5 a zero'ed allocation block */ + DT_DIR, /* 6 directory */ + DT_INODE, /* 7 inode */ + DT_FBI, /* 8 fbiwrite */ + DT_QR, /* 9 quota record */ + DT_COMMIT, /* 10 commit record */ + DT_CANCEL, /* 11 cancel record */ + DT_BOT, /* 12 begin transaction */ + DT_EOT, /* 13 end transaction */ + DT_UD, /* 14 userdata */ + DT_SUD, /* 15 userdata found during log scan */ + DT_SHAD, /* 16 data for a shadow inode */ + DT_MAX /* 17 maximum delta type */ +} delta_t; + +/* + * transaction operation types + */ +typedef enum top_type { + TOP_READ_SYNC, /* 0 */ + TOP_WRITE, /* 1 */ + TOP_WRITE_SYNC, /* 2 */ + TOP_SETATTR, /* 3 */ + TOP_CREATE, /* 4 */ + TOP_REMOVE, /* 5 */ + TOP_LINK, /* 6 */ + TOP_RENAME, /* 7 */ + TOP_MKDIR, /* 8 */ + TOP_RMDIR, /* 9 */ + TOP_SYMLINK, /* 10 */ + TOP_FSYNC, /* 11 */ + TOP_GETPAGE, /* 12 */ + TOP_PUTPAGE, /* 13 */ + TOP_SBUPDATE_FLUSH, /* 14 */ + TOP_SBUPDATE_UPDATE, /* 15 */ + TOP_SBUPDATE_UNMOUNT, /* 16 */ + TOP_SYNCIP_CLOSEDQ, /* 17 */ + TOP_SYNCIP_FLUSHI, /* 18 */ + TOP_SYNCIP_HLOCK, /* 19 */ + TOP_SYNCIP_SYNC, /* 20 */ + TOP_SYNCIP_FREE, /* 21 */ + TOP_SBWRITE_RECLAIM, /* 22 */ + TOP_SBWRITE_STABLE, /* 23 */ + TOP_IFREE, /* 24 */ + TOP_IUPDAT, /* 25 */ + TOP_MOUNT, /* 26 */ + TOP_COMMIT_ASYNC, /* 27 */ + TOP_COMMIT_FLUSH, /* 28 */ + TOP_COMMIT_UPDATE, /* 29 */ + TOP_COMMIT_UNMOUNT, /* 30 */ + TOP_SETSECATTR, /* 31 */ + TOP_QUOTA, /* 32 */ + TOP_ITRUNC, /* 33 */ + TOP_ALLOCSP, /* 34 */ + TOP_MAX /* 35 TOP_MAX MUST be the last entry */ +} top_t; + +struct inode; +struct ufsvfs; + +/* + * vfs_log == NULL means not logging + */ +#define TRANS_ISTRANS(ufsvfsp) (ufsvfsp->vfs_log) + +/* + * begin a synchronous transaction + */ +#define TRANS_BEGIN_SYNC(ufsvfsp, vid, vsize, error)\ +{\ + if (TRANS_ISTRANS(ufsvfsp)) { \ + error = 0; \ + top_begin_sync(ufsvfsp, vid, vsize, &error); \ + } \ +} + +/* + * begin a asynchronous transaction + */ +#define TRANS_BEGIN_ASYNC(ufsvfsp, vid, vsize)\ +{\ + if (TRANS_ISTRANS(ufsvfsp))\ + (void) top_begin_async(ufsvfsp, vid, vsize, 0); \ +} + +/* + * try to begin a asynchronous transaction + */ +#define TRANS_TRY_BEGIN_ASYNC(ufsvfsp, vid, vsize, err)\ +{\ + if (TRANS_ISTRANS(ufsvfsp))\ + err = top_begin_async(ufsvfsp, vid, vsize, 1); \ + else\ + err = 0; \ +} + +/* + * Begin a synchronous or asynchronous transaction. + * The lint case is needed because vsize can be a constant. + */ +#ifndef __lint + +#define TRANS_BEGIN_CSYNC(ufsvfsp, issync, vid, vsize)\ +{\ + if (TRANS_ISTRANS(ufsvfsp)) {\ + if (ufsvfsp->vfs_syncdir) {\ + int error = 0; \ + ASSERT(vsize); \ + top_begin_sync(ufsvfsp, vid, vsize, &error); \ + ASSERT(error == 0); \ + issync = 1; \ + } else {\ + (void) top_begin_async(ufsvfsp, vid, vsize, 0); \ + issync = 0; \ + }\ + }\ +} + +#else /* __lint */ + +#define TRANS_BEGIN_CSYNC(ufsvfsp, issync, vid, vsize)\ +{\ + if (TRANS_ISTRANS(ufsvfsp)) {\ + if (ufsvfsp->vfs_syncdir) {\ + int error = 0; \ + top_begin_sync(ufsvfsp, vid, vsize, &error); \ + issync = 1; \ + } else {\ + (void) top_begin_async(ufsvfsp, vid, vsize, 0); \ + issync = 0; \ + }\ + }\ +} +#endif /* __lint */ + +/* + * try to begin a synchronous or asynchronous transaction + */ + +#define TRANS_TRY_BEGIN_CSYNC(ufsvfsp, issync, vid, vsize, error)\ +{\ + if (TRANS_ISTRANS(ufsvfsp)) {\ + if (ufsvfsp->vfs_syncdir) {\ + ASSERT(vsize); \ + top_begin_sync(ufsvfsp, vid, vsize, &error); \ + ASSERT(error == 0); \ + issync = 1; \ + } else {\ + error = top_begin_async(ufsvfsp, vid, vsize, 1); \ + issync = 0; \ + }\ + }\ +}\ + + +/* + * end a asynchronous transaction + */ +#define TRANS_END_ASYNC(ufsvfsp, vid, vsize)\ +{\ + if (TRANS_ISTRANS(ufsvfsp))\ + top_end_async(ufsvfsp, vid, vsize); \ +} + +/* + * end a synchronous transaction + */ +#define TRANS_END_SYNC(ufsvfsp, error, vid, vsize)\ +{\ + if (TRANS_ISTRANS(ufsvfsp))\ + top_end_sync(ufsvfsp, &error, vid, vsize); \ +} + +/* + * end a synchronous or asynchronous transaction + */ +#define TRANS_END_CSYNC(ufsvfsp, error, issync, vid, vsize)\ +{\ + if (TRANS_ISTRANS(ufsvfsp))\ + if (issync)\ + top_end_sync(ufsvfsp, &error, vid, vsize); \ + else\ + top_end_async(ufsvfsp, vid, vsize); \ +} +/* + * record a delta + */ +#define TRANS_DELTA(ufsvfsp, mof, nb, dtyp, func, arg) \ + if (TRANS_ISTRANS(ufsvfsp)) \ + top_delta(ufsvfsp, (offset_t)(mof), nb, dtyp, func, arg) + +/* + * cancel a delta + */ +#define TRANS_CANCEL(ufsvfsp, mof, nb, flags) \ + if (TRANS_ISTRANS(ufsvfsp)) \ + top_cancel(ufsvfsp, (offset_t)(mof), nb, flags) +/* + * log a delta + */ +#define TRANS_LOG(ufsvfsp, va, mof, nb, buf, bufsz) \ + if (TRANS_ISTRANS(ufsvfsp)) \ + top_log(ufsvfsp, va, (offset_t)(mof), nb, buf, bufsz) +/* + * check if a range is being canceled (converting from metadata into userdata) + */ +#define TRANS_ISCANCEL(ufsvfsp, mof, nb) \ + ((TRANS_ISTRANS(ufsvfsp)) ? \ + top_iscancel(ufsvfsp, (offset_t)(mof), nb) : 0) +/* + * put the log into error state + */ +#define TRANS_SETERROR(ufsvfsp) \ + if (TRANS_ISTRANS(ufsvfsp)) \ + top_seterror(ufsvfsp) +/* + * check if device has had an error + */ +#define TRANS_ISERROR(ufsvfsp) \ + ((TRANS_ISTRANS(ufsvfsp)) ? \ + ufsvfsp->vfs_log->un_flags & LDL_ERROR : 0) + +/* + * The following macros provide a more readable interface to TRANS_DELTA + */ +#define TRANS_BUF(ufsvfsp, vof, nb, bp, type) \ + TRANS_DELTA(ufsvfsp, \ + ldbtob(bp->b_blkno) + (offset_t)(vof), nb, type, \ + ufs_trans_push_buf, bp->b_blkno) + +#define TRANS_BUF_ITEM_128(ufsvfsp, item, base, bp, type) \ + TRANS_BUF(ufsvfsp, \ + (((uintptr_t)&(item)) & ~(128 - 1)) - (uintptr_t)(base), 128, bp, type) + +#define TRANS_INODE(ufsvfsp, ip) \ + TRANS_DELTA(ufsvfsp, ip->i_doff, sizeof (struct dinode), \ + DT_INODE, ufs_trans_push_inode, ip->i_number) + +/* + * If ever parts of an inode except the timestamps are logged using + * this macro (or any other technique), bootloader logging support must + * be made aware of these changes. + */ +#define TRANS_INODE_DELTA(ufsvfsp, vof, nb, ip) \ + TRANS_DELTA(ufsvfsp, (ip->i_doff + (offset_t)(vof)), \ + nb, DT_INODE, ufs_trans_push_inode, ip->i_number) + +#define TRANS_INODE_TIMES(ufsvfsp, ip) \ + TRANS_INODE_DELTA(ufsvfsp, (caddr_t)&ip->i_atime - (caddr_t)&ip->i_ic, \ + sizeof (struct timeval32) * 3, ip) + +/* + * Check if we need to log cylinder group summary info. + */ +#define TRANS_SI(ufsvfsp, fs, cg) \ + if (TRANS_ISTRANS(ufsvfsp)) \ + if (ufsvfsp->vfs_nolog_si) \ + fs->fs_si = FS_SI_BAD; \ + else \ + TRANS_DELTA(ufsvfsp, \ + ldbtob(fsbtodb(fs, fs->fs_csaddr)) + \ + ((caddr_t)&fs->fs_cs(fs, cg) - \ + (caddr_t)fs->fs_u.fs_csp), \ + sizeof (struct csum), DT_SI, \ + ufs_trans_push_si, cg) + +#define TRANS_DIR(ip, offset) \ + (TRANS_ISTRANS(ip->i_ufsvfs) ? ufs_trans_dir(ip, offset) : 0) + +#define TRANS_QUOTA(dqp) \ + if (TRANS_ISTRANS(dqp->dq_ufsvfsp)) \ + ufs_trans_quota(dqp); + +#define TRANS_DQRELE(ufsvfsp, dqp) \ + if (TRANS_ISTRANS(ufsvfsp) && \ + ((curthread->t_flag & T_DONTBLOCK) == 0)) { \ + ufs_trans_dqrele(dqp); \ + } else { \ + rw_enter(&ufsvfsp->vfs_dqrwlock, RW_READER); \ + dqrele(dqp); \ + rw_exit(&ufsvfsp->vfs_dqrwlock); \ + } + +#define TRANS_ITRUNC(ip, length, flags, cr) \ + ufs_trans_itrunc(ip, length, flags, cr); + +#define TRANS_WRITE_RESV(ip, uiop, ulp, resvp, residp) \ + if ((TRANS_ISTRANS(ip->i_ufsvfs) != NULL) && (ulp != NULL)) \ + ufs_trans_write_resv(ip, uiop, resvp, residp); + +#define TRANS_WRITE(ip, uiop, ioflag, err, ulp, cr, resv, resid) \ + if ((TRANS_ISTRANS(ip->i_ufsvfs) != NULL) && (ulp != NULL)) \ + err = ufs_trans_write(ip, uiop, ioflag, cr, resv, resid); \ + else \ + err = wrip(ip, uiop, ioflag, cr); + +/* + * These functions "wrap" functions that are not VOP or VFS + * entry points but must still use the TRANS_BEGIN/TRANS_END + * protocol + */ +#define TRANS_SBUPDATE(ufsvfsp, vfsp, topid) \ + ufs_trans_sbupdate(ufsvfsp, vfsp, topid) +#define TRANS_SYNCIP(ip, bflags, iflag, topid) \ + ufs_syncip(ip, bflags, iflag, topid) +#define TRANS_SBWRITE(ufsvfsp, topid) ufs_trans_sbwrite(ufsvfsp, topid) +#define TRANS_IUPDAT(ip, waitfor) ufs_trans_iupdat(ip, waitfor) + +#ifdef DEBUG +/* + * Test/Debug ops + * The following ops maintain the metadata map. + * The metadata map is a debug/test feature. + * These ops are *not* used in the production product. + */ + +/* + * Set a flag if meta data checking. + */ +#define TRANS_DOMATAMAP(ufsvfsp) \ + ufsvfsp->vfs_domatamap = \ + (TRANS_ISTRANS(ufsvfsp) && \ + (ufsvfsp->vfs_log->un_debug & MT_MATAMAP)) + +#define TRANS_MATA_IGET(ufsvfsp, ip) \ + if (ufsvfsp->vfs_domatamap) \ + ufs_trans_mata_iget(ip) + +#define TRANS_MATA_FREE(ufsvfsp, mof, nb) \ + if (ufsvfsp->vfs_domatamap) \ + ufs_trans_mata_free(ufsvfsp, (offset_t)(mof), nb) + +#define TRANS_MATA_ALLOC(ufsvfsp, ip, bno, size, zero) \ + if (ufsvfsp->vfs_domatamap) \ + ufs_trans_mata_alloc(ufsvfsp, ip, bno, size, zero) + +#define TRANS_MATA_MOUNT(ufsvfsp) \ + if (ufsvfsp->vfs_domatamap) \ + ufs_trans_mata_mount(ufsvfsp) + +#define TRANS_MATA_UMOUNT(ufsvfsp) \ + if (ufsvfsp->vfs_domatamap) \ + ufs_trans_mata_umount(ufsvfsp) + +#define TRANS_MATA_SI(ufsvfsp, fs) \ + if (ufsvfsp->vfs_domatamap) \ + ufs_trans_mata_si(ufsvfsp, fs) + +#define TRANS_MATAADD(ufsvfsp, mof, nb) \ + top_mataadd(ufsvfsp, (offset_t)(mof), nb) + +#else /* !DEBUG */ + +#define TRANS_DOMATAMAP(ufsvfsp) +#define TRANS_MATA_IGET(ufsvfsp, ip) +#define TRANS_MATA_FREE(ufsvfsp, mof, nb) +#define TRANS_MATA_ALLOC(ufsvfsp, ip, bno, size, zero) +#define TRANS_MATA_MOUNT(ufsvfsp) +#define TRANS_MATA_UMOUNT(ufsvfsp) +#define TRANS_MATA_SI(ufsvfsp, fs) +#define TRANS_MATAADD(ufsvfsp, mof, nb) + +#endif /* !DEBUG */ + +#include +#include +/* + * identifies the type of operation passed into TRANS_BEGIN/END + */ +#define TOP_SYNC (0x00000001) +#define TOP_ASYNC (0x00000002) +#define TOP_SYNC_FORCED (0x00000004) /* forced sync transaction */ +/* + * estimated values + */ +#define HEADERSIZE (128) +#define ALLOCSIZE (160) +#define INODESIZE (sizeof (struct dinode) + HEADERSIZE) +#define SIZESB ((sizeof (struct fs)) + HEADERSIZE) +#define SIZEDIR (DIRBLKSIZ + HEADERSIZE) +/* + * calculated values + */ +#define SIZECG(IP) ((IP)->i_fs->fs_cgsize + HEADERSIZE) +#define FRAGSIZE(IP) ((IP)->i_fs->fs_fsize + HEADERSIZE) +#define ACLSIZE(IP) (((IP)->i_ufsvfs->vfs_maxacl + HEADERSIZE) + \ + INODESIZE) +#define MAXACLSIZE ((MAX_ACL_ENTRIES << 1) * sizeof (aclent_t)) +#define DIRSIZE(IP) (INODESIZE + (4 * ALLOCSIZE) + \ + (IP)->i_fs->fs_fsize + HEADERSIZE) +#define QUOTASIZE sizeof (struct dquot) + HEADERSIZE +/* + * size calculations + */ +#define TOP_CREATE_SIZE(IP) \ + (ACLSIZE(IP) + SIZECG(IP) + DIRSIZE(IP) + INODESIZE) +#define TOP_REMOVE_SIZE(IP) \ + DIRSIZE(IP) + SIZECG(IP) + INODESIZE + SIZESB +#define TOP_LINK_SIZE(IP) \ + DIRSIZE(IP) + INODESIZE +#define TOP_RENAME_SIZE(IP) \ + DIRSIZE(IP) + DIRSIZE(IP) + SIZECG(IP) +#define TOP_MKDIR_SIZE(IP) \ + DIRSIZE(IP) + INODESIZE + DIRSIZE(IP) + INODESIZE + FRAGSIZE(IP) + \ + SIZECG(IP) + ACLSIZE(IP) +#define TOP_SYMLINK_SIZE(IP) \ + DIRSIZE((IP)) + INODESIZE + INODESIZE + SIZECG(IP) +#define TOP_GETPAGE_SIZE(IP) \ + ALLOCSIZE + ALLOCSIZE + ALLOCSIZE + INODESIZE + SIZECG(IP) +#define TOP_SYNCIP_SIZE INODESIZE +#define TOP_READ_SIZE INODESIZE +#define TOP_RMDIR_SIZE (SIZESB + (INODESIZE * 2) + SIZEDIR) +#define TOP_SETQUOTA_SIZE(FS) ((FS)->fs_bsize << 2) +#define TOP_QUOTA_SIZE (QUOTASIZE) +#define TOP_SETSECATTR_SIZE(IP) (MAXACLSIZE) +#define TOP_IUPDAT_SIZE(IP) INODESIZE + SIZECG(IP) +#define TOP_SBUPDATE_SIZE (SIZESB) +#define TOP_SBWRITE_SIZE (SIZESB) +#define TOP_PUTPAGE_SIZE(IP) (INODESIZE + SIZECG(IP)) +#define TOP_SETATTR_SIZE(IP) (SIZECG(IP) + INODESIZE + QUOTASIZE + \ + ACLSIZE(IP)) +#define TOP_IFREE_SIZE(IP) (SIZECG(IP) + INODESIZE + QUOTASIZE) +#define TOP_MOUNT_SIZE (SIZESB) +#define TOP_COMMIT_SIZE (0) + +/* + * The minimum log size is 1M. So we will allow 1 fs operation to + * reserve at most 512K of log space. + */ +#define TOP_MAX_RESV (512 * 1024) + + +/* + * ufs trans function prototypes + */ +#if defined(_KERNEL) + +extern int ufs_trans_hlock(); +extern void ufs_trans_onerror(); +extern int ufs_trans_push_inode(struct ufsvfs *, delta_t, ino_t); +extern int ufs_trans_push_buf(struct ufsvfs *, delta_t, daddr_t); +extern int ufs_trans_push_si(struct ufsvfs *, delta_t, int); +extern void ufs_trans_sbupdate(struct ufsvfs *, struct vfs *, + top_t); +extern void ufs_trans_sbwrite(struct ufsvfs *, top_t); +extern void ufs_trans_iupdat(struct inode *, int); +extern void ufs_trans_mata_mount(struct ufsvfs *); +extern void ufs_trans_mata_umount(struct ufsvfs *); +extern void ufs_trans_mata_si(struct ufsvfs *, struct fs *); +extern void ufs_trans_mata_iget(struct inode *); +extern void ufs_trans_mata_free(struct ufsvfs *, offset_t, off_t); +extern void ufs_trans_mata_alloc(struct ufsvfs *, struct inode *, + daddr_t, ulong_t, int); +extern int ufs_trans_dir(struct inode *, off_t); +extern void ufs_trans_quota(struct dquot *); +extern void ufs_trans_dqrele(struct dquot *); +extern int ufs_trans_itrunc(struct inode *, u_offset_t, int, + cred_t *); +extern int ufs_trans_write(struct inode *, struct uio *, int, + cred_t *, int, long); +extern void ufs_trans_write_resv(struct inode *, struct uio *, + int *, int *); +extern int ufs_trans_check(dev_t); +extern void ufs_trans_redev(dev_t odev, dev_t ndev); +extern void ufs_trans_trunc_resv(struct inode *, u_offset_t, int *, + u_offset_t *); + +/* + * transaction prototypes + */ +void lufs_unsnarf(struct ufsvfs *ufsvfsp); +int lufs_snarf(struct ufsvfs *ufsvfsp, struct fs *fs, int ronly); +void top_delta(struct ufsvfs *ufsvfsp, offset_t mof, off_t nb, delta_t dtyp, + int (*func)(), ulong_t arg); +void top_cancel(struct ufsvfs *ufsvfsp, offset_t mof, off_t nb, int flags); +int top_iscancel(struct ufsvfs *ufsvfsp, offset_t mof, off_t nb); +void top_seterror(struct ufsvfs *ufsvfsp); +int top_iserror(struct ufsvfs *ufsvfsp); +void top_begin_sync(struct ufsvfs *ufsvfsp, top_t topid, ulong_t size, + int *error); +int top_begin_async(struct ufsvfs *ufsvfsp, top_t topid, ulong_t size, + int tryasync); +void top_end_sync(struct ufsvfs *ufsvfsp, int *ep, top_t topid, + ulong_t size); +void top_end_async(struct ufsvfs *ufsvfsp, top_t topid, ulong_t size); +void top_log(struct ufsvfs *ufsvfsp, char *va, offset_t vamof, off_t nb, + caddr_t buf, uint32_t bufsz); +void top_mataadd(struct ufsvfs *ufsvfsp, offset_t mof, off_t nb); +void top_matadel(struct ufsvfs *ufsvfsp, offset_t mof, off_t nb); +void top_mataclr(struct ufsvfs *ufsvfsp); + + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_UFS_TRANS_H */ diff --git a/illumos-x86_64/usr/include/sys/fs/zfs.h b/illumos-x86_64/usr/include/sys/fs/zfs.h new file mode 100644 index 00000000..d1488581 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs/zfs.h @@ -0,0 +1,1490 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020 by Delphix. All rights reserved. + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2014 Integros [integros.com] + * Copyright 2020 Joyent, Inc. + * Copyright (c) 2017 Datto Inc. + * Copyright (c) 2017, Intel Corporation. + */ + +/* Portions Copyright 2010 Robert Milkowski */ + +#ifndef _SYS_FS_ZFS_H +#define _SYS_FS_ZFS_H + +#include +/* + * In OpenZFS we include sys/zio_priority.h to get the enum value of + * ZIO_PRIORITY_NUM_QUEUEABLE, which is used for the various array sizes in + * the structure definitions below. However, in illumos zio_priority.h is not + * readily available to the userland code where we have a very large number of + * files including sys/zfs.h. Thus, we define ZIO_PRIORITY_N_QUEUEABLE here and + * this should be kept in sync if ZIO_PRIORITY_NUM_QUEUEABLE changes. + */ +#define ZIO_PRIORITY_N_QUEUEABLE 8 + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Types and constants shared between userland and the kernel. + */ + +/* + * Each dataset can be one of the following types. These constants can be + * combined into masks that can be passed to various functions. + */ +typedef enum { + ZFS_TYPE_FILESYSTEM = (1 << 0), + ZFS_TYPE_SNAPSHOT = (1 << 1), + ZFS_TYPE_VOLUME = (1 << 2), + ZFS_TYPE_POOL = (1 << 3), + ZFS_TYPE_BOOKMARK = (1 << 4) +} zfs_type_t; + +/* + * NB: lzc_dataset_type should be updated whenever a new objset type is added, + * if it represents a real type of a dataset that can be created from userland. + */ +typedef enum dmu_objset_type { + DMU_OST_NONE, + DMU_OST_META, + DMU_OST_ZFS, + DMU_OST_ZVOL, + DMU_OST_OTHER, /* For testing only! */ + DMU_OST_ANY, /* Be careful! */ + DMU_OST_NUMTYPES +} dmu_objset_type_t; + +#define ZFS_TYPE_DATASET \ + (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) + +/* + * All of these include the terminating NUL byte. + */ +#define ZAP_MAXNAMELEN 256 +#define ZAP_MAXVALUELEN (1024 * 8) +#define ZAP_OLDMAXVALUELEN 1024 +#define ZFS_MAX_DATASET_NAME_LEN 256 + +/* + * Dataset properties are identified by these constants and must be added to + * the end of this list to ensure that external consumers are not affected + * by the change. If you make any changes to this list, be sure to update + * the property table in usr/src/common/zfs/zfs_prop.c. + */ +typedef enum { + ZPROP_CONT = -2, + ZPROP_INVAL = -1, + ZFS_PROP_TYPE = 0, + ZFS_PROP_CREATION, + ZFS_PROP_USED, + ZFS_PROP_AVAILABLE, + ZFS_PROP_REFERENCED, + ZFS_PROP_COMPRESSRATIO, + ZFS_PROP_MOUNTED, + ZFS_PROP_ORIGIN, + ZFS_PROP_QUOTA, + ZFS_PROP_RESERVATION, + ZFS_PROP_VOLSIZE, + ZFS_PROP_VOLBLOCKSIZE, + ZFS_PROP_RECORDSIZE, + ZFS_PROP_MOUNTPOINT, + ZFS_PROP_SHARENFS, + ZFS_PROP_CHECKSUM, + ZFS_PROP_COMPRESSION, + ZFS_PROP_ATIME, + ZFS_PROP_DEVICES, + ZFS_PROP_EXEC, + ZFS_PROP_SETUID, + ZFS_PROP_READONLY, + ZFS_PROP_ZONED, + ZFS_PROP_SNAPDIR, + ZFS_PROP_ACLMODE, + ZFS_PROP_ACLINHERIT, + ZFS_PROP_ACLIMPLICIT, /* ACL Implicit Owner Rights (RackTop) */ + ZFS_PROP_CREATETXG, + ZFS_PROP_NAME, /* not exposed to the user */ + ZFS_PROP_CANMOUNT, + ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ + ZFS_PROP_XATTR, + ZFS_PROP_NUMCLONES, /* not exposed to the user */ + ZFS_PROP_COPIES, + ZFS_PROP_VERSION, + ZFS_PROP_UTF8ONLY, + ZFS_PROP_NORMALIZE, + ZFS_PROP_CASE, + ZFS_PROP_VSCAN, + ZFS_PROP_NBMAND, + ZFS_PROP_SHARESMB, + ZFS_PROP_REFQUOTA, + ZFS_PROP_REFRESERVATION, + ZFS_PROP_GUID, + ZFS_PROP_PRIMARYCACHE, + ZFS_PROP_SECONDARYCACHE, + ZFS_PROP_USEDSNAP, + ZFS_PROP_USEDDS, + ZFS_PROP_USEDCHILD, + ZFS_PROP_USEDREFRESERV, + ZFS_PROP_USERACCOUNTING, /* not exposed to the user */ + ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */ + ZFS_PROP_DEFER_DESTROY, + ZFS_PROP_USERREFS, + ZFS_PROP_LOGBIAS, + ZFS_PROP_UNIQUE, /* not exposed to the user */ + ZFS_PROP_OBJSETID, /* not exposed to the user */ + ZFS_PROP_DEDUP, + ZFS_PROP_MLSLABEL, + ZFS_PROP_SYNC, + ZFS_PROP_DNODESIZE, + ZFS_PROP_REFRATIO, + ZFS_PROP_WRITTEN, + ZFS_PROP_CLONES, + ZFS_PROP_LOGICALUSED, + ZFS_PROP_LOGICALREFERENCED, + ZFS_PROP_INCONSISTENT, /* not exposed to the user */ + ZFS_PROP_FILESYSTEM_LIMIT, + ZFS_PROP_SNAPSHOT_LIMIT, + ZFS_PROP_FILESYSTEM_COUNT, + ZFS_PROP_SNAPSHOT_COUNT, + ZFS_PROP_REDUNDANT_METADATA, + ZFS_PROP_PREV_SNAP, + ZFS_PROP_RECEIVE_RESUME_TOKEN, + ZFS_PROP_REMAPTXG, /* not exposed to the user */ + ZFS_PROP_SPECIAL_SMALL_BLOCKS, + ZFS_PROP_ENCRYPTION, + ZFS_PROP_KEYLOCATION, + ZFS_PROP_KEYFORMAT, + ZFS_PROP_PBKDF2_SALT, + ZFS_PROP_PBKDF2_ITERS, + ZFS_PROP_ENCRYPTION_ROOT, + ZFS_PROP_KEY_GUID, + ZFS_PROP_KEYSTATUS, + ZFS_PROP_IVSET_GUID, /* not exposed to the user */ + ZFS_NUM_PROPS +} zfs_prop_t; + +typedef enum { + ZFS_PROP_USERUSED, + ZFS_PROP_USERQUOTA, + ZFS_PROP_GROUPUSED, + ZFS_PROP_GROUPQUOTA, + ZFS_PROP_USEROBJUSED, + ZFS_PROP_USEROBJQUOTA, + ZFS_PROP_GROUPOBJUSED, + ZFS_PROP_GROUPOBJQUOTA, + ZFS_PROP_PROJECTUSED, + ZFS_PROP_PROJECTQUOTA, + ZFS_PROP_PROJECTOBJUSED, + ZFS_PROP_PROJECTOBJQUOTA, + ZFS_NUM_USERQUOTA_PROPS +} zfs_userquota_prop_t; + +extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS]; + +/* + * Pool properties are identified by these constants and must be added to the + * end of this list to ensure that external consumers are not affected + * by the change. If you make any changes to this list, be sure to update + * the property table in usr/src/common/zfs/zpool_prop.c. + */ +typedef enum { + ZPOOL_PROP_INVAL = -1, + ZPOOL_PROP_NAME, + ZPOOL_PROP_SIZE, + ZPOOL_PROP_CAPACITY, + ZPOOL_PROP_ALTROOT, + ZPOOL_PROP_HEALTH, + ZPOOL_PROP_GUID, + ZPOOL_PROP_VERSION, + ZPOOL_PROP_BOOTFS, + ZPOOL_PROP_DELEGATION, + ZPOOL_PROP_AUTOREPLACE, + ZPOOL_PROP_CACHEFILE, + ZPOOL_PROP_FAILUREMODE, + ZPOOL_PROP_LISTSNAPS, + ZPOOL_PROP_AUTOEXPAND, + ZPOOL_PROP_DEDUPDITTO, + ZPOOL_PROP_DEDUPRATIO, + ZPOOL_PROP_FREE, + ZPOOL_PROP_ALLOCATED, + ZPOOL_PROP_READONLY, + ZPOOL_PROP_COMMENT, + ZPOOL_PROP_EXPANDSZ, + ZPOOL_PROP_FREEING, + ZPOOL_PROP_FRAGMENTATION, + ZPOOL_PROP_LEAKED, + ZPOOL_PROP_MAXBLOCKSIZE, + ZPOOL_PROP_BOOTSIZE, + ZPOOL_PROP_CHECKPOINT, + ZPOOL_PROP_TNAME, + ZPOOL_PROP_MAXDNODESIZE, + ZPOOL_PROP_MULTIHOST, + ZPOOL_PROP_ASHIFT, + ZPOOL_PROP_AUTOTRIM, + ZPOOL_NUM_PROPS +} zpool_prop_t; + +/* Small enough to not hog a whole line of printout in zpool(8). */ +#define ZPROP_MAX_COMMENT 32 + +#define ZPROP_VALUE "value" +#define ZPROP_SOURCE "source" + +typedef enum { + ZPROP_SRC_NONE = 0x1, + ZPROP_SRC_DEFAULT = 0x2, + ZPROP_SRC_TEMPORARY = 0x4, + ZPROP_SRC_LOCAL = 0x8, + ZPROP_SRC_INHERITED = 0x10, + ZPROP_SRC_RECEIVED = 0x20 +} zprop_source_t; + +#define ZPROP_SRC_ALL 0x3f + +#define ZPROP_SOURCE_VAL_RECVD "$recvd" +#define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS" +/* + * Dataset flag implemented as a special entry in the props zap object + * indicating that the dataset has received properties on or after + * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties + * just as it did in earlier versions, and thereafter, local properties are + * preserved. + */ +#define ZPROP_HAS_RECVD "$hasrecvd" + +typedef enum { + ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */ + ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */ +} zprop_errflags_t; + +typedef int (*zprop_func)(int, void *); + +/* + * Properties to be set on the root file system of a new pool + * are stuffed into their own nvlist, which is then included in + * the properties nvlist with the pool properties. + */ +#define ZPOOL_ROOTFS_PROPS "root-props-nvl" + +/* + * Length of 'written@' and 'written#' + */ +#define ZFS_WRITTEN_PROP_PREFIX_LEN 8 + +/* + * Dataset property functions shared between libzfs and kernel. + */ +const char *zfs_prop_default_string(zfs_prop_t); +uint64_t zfs_prop_default_numeric(zfs_prop_t); +boolean_t zfs_prop_readonly(zfs_prop_t); +boolean_t zfs_prop_visible(zfs_prop_t prop); +boolean_t zfs_prop_inheritable(zfs_prop_t); +boolean_t zfs_prop_setonce(zfs_prop_t); +boolean_t zfs_prop_encryption_key_param(zfs_prop_t); +boolean_t zfs_prop_valid_keylocation(const char *, boolean_t); +const char *zfs_prop_to_name(zfs_prop_t); +zfs_prop_t zfs_name_to_prop(const char *); +boolean_t zfs_prop_user(const char *); +boolean_t zfs_prop_userquota(const char *); +boolean_t zfs_prop_written(const char *); +int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); +int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); +uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed); +boolean_t zfs_prop_valid_for_type(int, zfs_type_t, boolean_t); + +/* + * Pool property functions shared between libzfs and kernel. + */ +zpool_prop_t zpool_name_to_prop(const char *); +const char *zpool_prop_to_name(zpool_prop_t); +const char *zpool_prop_default_string(zpool_prop_t); +uint64_t zpool_prop_default_numeric(zpool_prop_t); +boolean_t zpool_prop_readonly(zpool_prop_t); +boolean_t zpool_prop_feature(const char *); +boolean_t zpool_prop_unsupported(const char *name); +int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); +int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); +uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed); + +/* + * Definitions for the Delegation. + */ +typedef enum { + ZFS_DELEG_WHO_UNKNOWN = 0, + ZFS_DELEG_USER = 'u', + ZFS_DELEG_USER_SETS = 'U', + ZFS_DELEG_GROUP = 'g', + ZFS_DELEG_GROUP_SETS = 'G', + ZFS_DELEG_EVERYONE = 'e', + ZFS_DELEG_EVERYONE_SETS = 'E', + ZFS_DELEG_CREATE = 'c', + ZFS_DELEG_CREATE_SETS = 'C', + ZFS_DELEG_NAMED_SET = 's', + ZFS_DELEG_NAMED_SET_SETS = 'S' +} zfs_deleg_who_type_t; + +typedef enum { + ZFS_DELEG_NONE = 0, + ZFS_DELEG_PERM_LOCAL = 1, + ZFS_DELEG_PERM_DESCENDENT = 2, + ZFS_DELEG_PERM_LOCALDESCENDENT = 3, + ZFS_DELEG_PERM_CREATE = 4 +} zfs_deleg_inherit_t; + +#define ZFS_DELEG_PERM_UID "uid" +#define ZFS_DELEG_PERM_GID "gid" +#define ZFS_DELEG_PERM_GROUPS "groups" + +#define ZFS_MLSLABEL_DEFAULT "none" + +#define ZFS_SMB_ACL_SRC "src" +#define ZFS_SMB_ACL_TARGET "target" + +typedef enum { + ZFS_CANMOUNT_OFF = 0, + ZFS_CANMOUNT_ON = 1, + ZFS_CANMOUNT_NOAUTO = 2 +} zfs_canmount_type_t; + +typedef enum { + ZFS_LOGBIAS_LATENCY = 0, + ZFS_LOGBIAS_THROUGHPUT = 1 +} zfs_logbias_op_t; + +typedef enum zfs_share_op { + ZFS_SHARE_NFS = 0, + ZFS_UNSHARE_NFS = 1, + ZFS_SHARE_SMB = 2, + ZFS_UNSHARE_SMB = 3 +} zfs_share_op_t; + +typedef enum zfs_smb_acl_op { + ZFS_SMB_ACL_ADD, + ZFS_SMB_ACL_REMOVE, + ZFS_SMB_ACL_RENAME, + ZFS_SMB_ACL_PURGE +} zfs_smb_acl_op_t; + +typedef enum zfs_cache_type { + ZFS_CACHE_NONE = 0, + ZFS_CACHE_METADATA = 1, + ZFS_CACHE_ALL = 2 +} zfs_cache_type_t; + +typedef enum { + ZFS_SYNC_STANDARD = 0, + ZFS_SYNC_ALWAYS = 1, + ZFS_SYNC_DISABLED = 2 +} zfs_sync_type_t; + +typedef enum { + ZFS_DNSIZE_LEGACY = 0, + ZFS_DNSIZE_AUTO = 1, + ZFS_DNSIZE_1K = 1024, + ZFS_DNSIZE_2K = 2048, + ZFS_DNSIZE_4K = 4096, + ZFS_DNSIZE_8K = 8192, + ZFS_DNSIZE_16K = 16384 +} zfs_dnsize_type_t; + +typedef enum { + ZFS_REDUNDANT_METADATA_ALL, + ZFS_REDUNDANT_METADATA_MOST +} zfs_redundant_metadata_type_t; + +typedef enum zfs_keystatus { + ZFS_KEYSTATUS_NONE = 0, + ZFS_KEYSTATUS_UNAVAILABLE, + ZFS_KEYSTATUS_AVAILABLE +} zfs_keystatus_t; + +typedef enum zfs_keyformat { + ZFS_KEYFORMAT_NONE = 0, + ZFS_KEYFORMAT_RAW, + ZFS_KEYFORMAT_HEX, + ZFS_KEYFORMAT_PASSPHRASE, + ZFS_KEYFORMAT_FORMATS +} zfs_keyformat_t; + +typedef enum zfs_key_location { + ZFS_KEYLOCATION_NONE = 0, + ZFS_KEYLOCATION_PROMPT, + ZFS_KEYLOCATION_URI, + ZFS_KEYLOCATION_LOCATIONS +} zfs_keylocation_t; + +#define DEFAULT_PBKDF2_ITERATIONS 350000 +#define MIN_PBKDF2_ITERATIONS 100000 + +/* + * On-disk version number. + */ +#define SPA_VERSION_1 1ULL +#define SPA_VERSION_2 2ULL +#define SPA_VERSION_3 3ULL +#define SPA_VERSION_4 4ULL +#define SPA_VERSION_5 5ULL +#define SPA_VERSION_6 6ULL +#define SPA_VERSION_7 7ULL +#define SPA_VERSION_8 8ULL +#define SPA_VERSION_9 9ULL +#define SPA_VERSION_10 10ULL +#define SPA_VERSION_11 11ULL +#define SPA_VERSION_12 12ULL +#define SPA_VERSION_13 13ULL +#define SPA_VERSION_14 14ULL +#define SPA_VERSION_15 15ULL +#define SPA_VERSION_16 16ULL +#define SPA_VERSION_17 17ULL +#define SPA_VERSION_18 18ULL +#define SPA_VERSION_19 19ULL +#define SPA_VERSION_20 20ULL +#define SPA_VERSION_21 21ULL +#define SPA_VERSION_22 22ULL +#define SPA_VERSION_23 23ULL +#define SPA_VERSION_24 24ULL +#define SPA_VERSION_25 25ULL +#define SPA_VERSION_26 26ULL +#define SPA_VERSION_27 27ULL +#define SPA_VERSION_28 28ULL +#define SPA_VERSION_5000 5000ULL + +/* + * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk + * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*}, + * and do the appropriate changes. Also bump the version number in + * usr/src/grub/capability. + */ +#define SPA_VERSION SPA_VERSION_5000 +#define SPA_VERSION_STRING "5000" + +/* + * Symbolic names for the changes that caused a SPA_VERSION switch. + * Used in the code when checking for presence or absence of a feature. + * Feel free to define multiple symbolic names for each version if there + * were multiple changes to on-disk structures during that version. + * + * NOTE: When checking the current SPA_VERSION in your code, be sure + * to use spa_version() since it reports the version of the + * last synced uberblock. Checking the in-flight version can + * be dangerous in some cases. + */ +#define SPA_VERSION_INITIAL SPA_VERSION_1 +#define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 +#define SPA_VERSION_SPARES SPA_VERSION_3 +#define SPA_VERSION_RAIDZ2 SPA_VERSION_3 +#define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3 +#define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 +#define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 +#define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 +#define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 +#define SPA_VERSION_BOOTFS SPA_VERSION_6 +#define SPA_VERSION_SLOGS SPA_VERSION_7 +#define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 +#define SPA_VERSION_FUID SPA_VERSION_9 +#define SPA_VERSION_REFRESERVATION SPA_VERSION_9 +#define SPA_VERSION_REFQUOTA SPA_VERSION_9 +#define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 +#define SPA_VERSION_L2CACHE SPA_VERSION_10 +#define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 +#define SPA_VERSION_ORIGIN SPA_VERSION_11 +#define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 +#define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 +#define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 +#define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 +#define SPA_VERSION_USERSPACE SPA_VERSION_15 +#define SPA_VERSION_STMF_PROP SPA_VERSION_16 +#define SPA_VERSION_RAIDZ3 SPA_VERSION_17 +#define SPA_VERSION_USERREFS SPA_VERSION_18 +#define SPA_VERSION_HOLES SPA_VERSION_19 +#define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20 +#define SPA_VERSION_DEDUP SPA_VERSION_21 +#define SPA_VERSION_RECVD_PROPS SPA_VERSION_22 +#define SPA_VERSION_SLIM_ZIL SPA_VERSION_23 +#define SPA_VERSION_SA SPA_VERSION_24 +#define SPA_VERSION_SCAN SPA_VERSION_25 +#define SPA_VERSION_DIR_CLONES SPA_VERSION_26 +#define SPA_VERSION_DEADLISTS SPA_VERSION_26 +#define SPA_VERSION_FAST_SNAP SPA_VERSION_27 +#define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28 +#define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28 +#define SPA_VERSION_FEATURES SPA_VERSION_5000 + +#define SPA_VERSION_IS_SUPPORTED(v) \ + (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \ + ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION)) + +/* + * ZPL version - rev'd whenever an incompatible on-disk format change + * occurs. This is independent of SPA/DMU/ZAP versioning. You must + * also update the version_table[] and help message in zfs_prop.c. + * + * When changing, be sure to teach GRUB how to read the new format! + * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*} + */ +#define ZPL_VERSION_1 1ULL +#define ZPL_VERSION_2 2ULL +#define ZPL_VERSION_3 3ULL +#define ZPL_VERSION_4 4ULL +#define ZPL_VERSION_5 5ULL +#define ZPL_VERSION ZPL_VERSION_5 +#define ZPL_VERSION_STRING "5" + +#define ZPL_VERSION_INITIAL ZPL_VERSION_1 +#define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 +#define ZPL_VERSION_FUID ZPL_VERSION_3 +#define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 +#define ZPL_VERSION_SYSATTR ZPL_VERSION_3 +#define ZPL_VERSION_USERSPACE ZPL_VERSION_4 +#define ZPL_VERSION_SA ZPL_VERSION_5 + +/* Persistent L2ARC version */ +#define L2ARC_PERSISTENT_VERSION_1 1ULL +#define L2ARC_PERSISTENT_VERSION L2ARC_PERSISTENT_VERSION_1 +#define L2ARC_PERSISTENT_VERSION_STRING "1" + +/* Rewind policy information */ +#define ZPOOL_NO_REWIND 1 /* No policy - default behavior */ +#define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */ +#define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */ +#define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */ +#define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */ +#define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */ +#define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */ + +typedef struct zpool_load_policy { + uint32_t zlp_rewind; /* rewind policy requested */ + uint64_t zlp_maxmeta; /* max acceptable meta-data errors */ + uint64_t zlp_maxdata; /* max acceptable data errors */ + uint64_t zlp_txg; /* specific txg to load */ +} zpool_load_policy_t; + +/* + * The following are configuration names used in the nvlist describing a pool's + * configuration. New on-disk names should be prefixed with ":" + * (e.g. "org.open-zfs:") to avoid conflicting names being developed + * independently. + */ +#define ZPOOL_CONFIG_VERSION "version" +#define ZPOOL_CONFIG_POOL_NAME "name" +#define ZPOOL_CONFIG_POOL_STATE "state" +#define ZPOOL_CONFIG_POOL_TXG "txg" +#define ZPOOL_CONFIG_POOL_GUID "pool_guid" +#define ZPOOL_CONFIG_CREATE_TXG "create_txg" +#define ZPOOL_CONFIG_TOP_GUID "top_guid" +#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" +#define ZPOOL_CONFIG_TYPE "type" +#define ZPOOL_CONFIG_CHILDREN "children" +#define ZPOOL_CONFIG_ID "id" +#define ZPOOL_CONFIG_GUID "guid" +#define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object" +#define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births" +#define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev" +#define ZPOOL_CONFIG_PATH "path" +#define ZPOOL_CONFIG_DEVID "devid" +#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" +#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" +#define ZPOOL_CONFIG_ASHIFT "ashift" +#define ZPOOL_CONFIG_ASIZE "asize" +#define ZPOOL_CONFIG_DTL "DTL" +#define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */ +#define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */ +#define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */ +#define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */ +#define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */ + +/* container nvlist of extended stats */ +#define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex" + +/* Active queue read/write stats */ +#define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue" +#define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue" +#define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue" +#define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue" +#define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue" +#define ZPOOL_CONFIG_VDEV_TRIM_ACTIVE_QUEUE "vdev_async_trim_active_queue" + +/* Queue sizes */ +#define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue" +#define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue" +#define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue" +#define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue" +#define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue" +#define ZPOOL_CONFIG_VDEV_TRIM_PEND_QUEUE "vdev_async_trim_pend_queue" + +/* Latency read/write histogram stats */ +#define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo" +#define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo" +#define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo" +#define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo" +#define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo" +#define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo" +#define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo" +#define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo" +#define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo" +#define ZPOOL_CONFIG_VDEV_TRIM_LAT_HISTO "vdev_trim_histo" + +/* Request size histograms */ +#define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo" +#define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo" +#define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo" +#define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo" +#define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo" +#define ZPOOL_CONFIG_VDEV_IND_TRIM_HISTO "vdev_ind_trim_histo" +#define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo" +#define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo" +#define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo" +#define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo" +#define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo" +#define ZPOOL_CONFIG_VDEV_AGG_TRIM_HISTO "vdev_agg_trim_histo" + +/* Number of slow IOs */ +#define ZPOOL_CONFIG_VDEV_SLOW_IOS "vdev_slow_ios" + +#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" +#define ZPOOL_CONFIG_ERRCOUNT "error_count" +#define ZPOOL_CONFIG_NOT_PRESENT "not_present" +#define ZPOOL_CONFIG_SPARES "spares" +#define ZPOOL_CONFIG_IS_SPARE "is_spare" +#define ZPOOL_CONFIG_NPARITY "nparity" +#define ZPOOL_CONFIG_HOSTID "hostid" +#define ZPOOL_CONFIG_HOSTNAME "hostname" +#define ZPOOL_CONFIG_LOADED_TIME "initial_load_time" +#define ZPOOL_CONFIG_UNSPARE "unspare" +#define ZPOOL_CONFIG_PHYS_PATH "phys_path" +#define ZPOOL_CONFIG_IS_LOG "is_log" +#define ZPOOL_CONFIG_L2CACHE "l2cache" +#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" +#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" +#define ZPOOL_CONFIG_IS_HOLE "is_hole" +#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" +#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" +#define ZPOOL_CONFIG_DDT_STATS "ddt_stats" +#define ZPOOL_CONFIG_SPLIT "splitcfg" +#define ZPOOL_CONFIG_ORIG_GUID "orig_guid" +#define ZPOOL_CONFIG_SPLIT_GUID "split_guid" +#define ZPOOL_CONFIG_SPLIT_LIST "guid_list" +#define ZPOOL_CONFIG_REMOVING "removing" +#define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg" +#define ZPOOL_CONFIG_COMMENT "comment" +#define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ +#define ZPOOL_CONFIG_SUSPENDED_REASON "suspended_reason" /* not stored */ +#define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ +#define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ +#define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */ +#define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */ +#define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */ +#define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */ +#define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */ +#define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */ +#define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read" +#define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */ +#define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */ +#define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top" +#define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf" +#define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps" +#define ZPOOL_CONFIG_RESILVER_DEFER "com.datto:resilver_defer" +#define ZPOOL_CONFIG_CACHEFILE "cachefile" /* not stored on disk */ +#define ZPOOL_CONFIG_MMP_STATE "mmp_state" /* not stored on disk */ +#define ZPOOL_CONFIG_MMP_TXG "mmp_txg" /* not stored on disk */ +#define ZPOOL_CONFIG_MMP_SEQ "mmp_seq" /* not stored on disk */ +#define ZPOOL_CONFIG_MMP_HOSTNAME "mmp_hostname" /* not stored on disk */ +#define ZPOOL_CONFIG_MMP_HOSTID "mmp_hostid" /* not stored on disk */ +#define ZPOOL_CONFIG_ALLOCATION_BIAS "alloc_bias" /* not stored on disk */ + +/* + * The persistent vdev state is stored as separate values rather than a single + * 'vdev_state' entry. This is because a device can be in multiple states, such + * as offline and degraded. + */ +#define ZPOOL_CONFIG_OFFLINE "offline" +#define ZPOOL_CONFIG_FAULTED "faulted" +#define ZPOOL_CONFIG_DEGRADED "degraded" +#define ZPOOL_CONFIG_REMOVED "removed" +#define ZPOOL_CONFIG_FRU "fru" +#define ZPOOL_CONFIG_AUX_STATE "aux_state" + +/* Pool load policy parameters */ +#define ZPOOL_LOAD_POLICY "load-policy" +#define ZPOOL_LOAD_REWIND_POLICY "load-rewind-policy" +#define ZPOOL_LOAD_REQUEST_TXG "load-request-txg" +#define ZPOOL_LOAD_META_THRESH "load-meta-thresh" +#define ZPOOL_LOAD_DATA_THRESH "load-data-thresh" + +/* Rewind data discovered */ +#define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts" +#define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors" +#define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind" + +#define VDEV_TYPE_ROOT "root" +#define VDEV_TYPE_MIRROR "mirror" +#define VDEV_TYPE_REPLACING "replacing" +#define VDEV_TYPE_RAIDZ "raidz" +#define VDEV_TYPE_DISK "disk" +#define VDEV_TYPE_FILE "file" +#define VDEV_TYPE_MISSING "missing" +#define VDEV_TYPE_HOLE "hole" +#define VDEV_TYPE_SPARE "spare" +#define VDEV_TYPE_LOG "log" +#define VDEV_TYPE_L2CACHE "l2cache" +#define VDEV_TYPE_INDIRECT "indirect" + +/* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */ +#define VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \ + "com.delphix:indirect_obsolete_sm" +#define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \ + "com.delphix:obsolete_counts_are_precise" +#define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \ + "com.delphix:pool_checkpoint_sm" +#define VDEV_TOP_ZAP_MS_UNFLUSHED_PHYS_TXGS \ + "com.delphix:ms_unflushed_phys_txgs" + +#define VDEV_TOP_ZAP_ALLOCATION_BIAS \ + "org.zfsonlinux:allocation_bias" + +/* vdev metaslab allocation bias */ +#define VDEV_ALLOC_BIAS_LOG "log" +#define VDEV_ALLOC_BIAS_SPECIAL "special" +#define VDEV_ALLOC_BIAS_DEDUP "dedup" + +/* vdev initialize state */ +#define VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET \ + "com.delphix:next_offset_to_initialize" +#define VDEV_LEAF_ZAP_INITIALIZE_STATE \ + "com.delphix:vdev_initialize_state" +#define VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME \ + "com.delphix:vdev_initialize_action_time" + +/* vdev TRIM state */ +#define VDEV_LEAF_ZAP_TRIM_LAST_OFFSET \ + "org.zfsonlinux:next_offset_to_trim" +#define VDEV_LEAF_ZAP_TRIM_STATE \ + "org.zfsonlinux:vdev_trim_state" +#define VDEV_LEAF_ZAP_TRIM_ACTION_TIME \ + "org.zfsonlinux:vdev_trim_action_time" +#define VDEV_LEAF_ZAP_TRIM_RATE \ + "org.zfsonlinux:vdev_trim_rate" +#define VDEV_LEAF_ZAP_TRIM_PARTIAL \ + "org.zfsonlinux:vdev_trim_partial" +#define VDEV_LEAF_ZAP_TRIM_SECURE \ + "org.zfsonlinux:vdev_trim_secure" + +/* + * This is needed in userland to report the minimum necessary device size. + * + * Note that the zfs test suite uses 64MB vdevs. + */ +#define SPA_MINDEVSIZE (64ULL << 20) + +/* + * Set if the fragmentation has not yet been calculated. This can happen + * because the space maps have not been upgraded or the histogram feature + * is not enabled. + */ +#define ZFS_FRAG_INVALID UINT64_MAX + +/* + * The location of the pool configuration repository, shared between kernel and + * userland. + */ +#define ZPOOL_CACHE "/etc/zfs/zpool.cache" + +/* + * vdev states are ordered from least to most healthy. + * A vdev that's CANT_OPEN or below is considered unusable. + */ +typedef enum vdev_state { + VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ + VDEV_STATE_CLOSED, /* Not currently open */ + VDEV_STATE_OFFLINE, /* Not allowed to open */ + VDEV_STATE_REMOVED, /* Explicitly removed from system */ + VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ + VDEV_STATE_FAULTED, /* External request to fault device */ + VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ + VDEV_STATE_HEALTHY /* Presumed good */ +} vdev_state_t; + +#define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY + +/* + * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field + * of the vdev stats structure uses these constants to distinguish why. + */ +typedef enum vdev_aux { + VDEV_AUX_NONE, /* no error */ + VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ + VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ + VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ + VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ + VDEV_AUX_TOO_SMALL, /* vdev size is too small */ + VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ + VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ + VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ + VDEV_AUX_UNSUP_FEAT, /* unsupported features */ + VDEV_AUX_SPARED, /* hot spare used in another pool */ + VDEV_AUX_ERR_EXCEEDED, /* too many errors */ + VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ + VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */ + VDEV_AUX_EXTERNAL, /* external diagnosis */ + VDEV_AUX_SPLIT_POOL, /* vdev was split off into another pool */ + VDEV_AUX_ACTIVE, /* vdev active on a different host */ + VDEV_AUX_CHILDREN_OFFLINE, /* all children are offline */ + VDEV_AUX_BAD_ASHIFT /* vdev ashift is invalid */ +} vdev_aux_t; + +/* + * pool state. The following states are written to disk as part of the normal + * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining + * states are software abstractions used at various levels to communicate + * pool state. + */ +typedef enum pool_state { + POOL_STATE_ACTIVE = 0, /* In active use */ + POOL_STATE_EXPORTED, /* Explicitly exported */ + POOL_STATE_DESTROYED, /* Explicitly destroyed */ + POOL_STATE_SPARE, /* Reserved for hot spare use */ + POOL_STATE_L2CACHE, /* Level 2 ARC device */ + POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ + POOL_STATE_UNAVAIL, /* Internal libzfs state */ + POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ +} pool_state_t; + +/* + * mmp state. The following states provide additional detail describing + * why a pool couldn't be safely imported. + */ +typedef enum mmp_state { + MMP_STATE_ACTIVE = 0, /* In active use */ + MMP_STATE_INACTIVE, /* Inactive and safe to import */ + MMP_STATE_NO_HOSTID /* System hostid is not set */ +} mmp_state_t; + +/* + * Scan Functions. + */ +typedef enum pool_scan_func { + POOL_SCAN_NONE, + POOL_SCAN_SCRUB, + POOL_SCAN_RESILVER, + POOL_SCAN_FUNCS +} pool_scan_func_t; + +/* + * Used to control scrub pause and resume. + */ +typedef enum pool_scrub_cmd { + POOL_SCRUB_NORMAL = 0, + POOL_SCRUB_PAUSE, + POOL_SCRUB_FLAGS_END +} pool_scrub_cmd_t; + +/* + * Initialize functions. + */ +typedef enum pool_initialize_func { + POOL_INITIALIZE_START, + POOL_INITIALIZE_CANCEL, + POOL_INITIALIZE_SUSPEND, + POOL_INITIALIZE_FUNCS +} pool_initialize_func_t; + +/* + * TRIM functions. + */ +typedef enum pool_trim_func { + POOL_TRIM_START, + POOL_TRIM_CANCEL, + POOL_TRIM_SUSPEND, + POOL_TRIM_FUNCS +} pool_trim_func_t; + +/* + * ZIO types. Needed to interpret vdev statistics below. + */ +typedef enum zio_type { + ZIO_TYPE_NULL = 0, + ZIO_TYPE_READ, + ZIO_TYPE_WRITE, + ZIO_TYPE_FREE, + ZIO_TYPE_CLAIM, + ZIO_TYPE_IOCTL, + ZIO_TYPE_TRIM, + ZIO_TYPES +} zio_type_t; + +/* + * Pool statistics. Note: all fields should be 64-bit because this + * is passed between kernel and userland as an nvlist uint64 array. + */ +typedef struct pool_scan_stat { + /* values stored on disk */ + uint64_t pss_func; /* pool_scan_func_t */ + uint64_t pss_state; /* dsl_scan_state_t */ + uint64_t pss_start_time; /* scan start time */ + uint64_t pss_end_time; /* scan end time */ + uint64_t pss_to_examine; /* total bytes to scan */ + uint64_t pss_examined; /* total bytes located by scanner */ + uint64_t pss_to_process; /* total bytes to process */ + uint64_t pss_processed; /* total processed bytes */ + uint64_t pss_errors; /* scan errors */ + + /* values not stored on disk */ + uint64_t pss_pass_exam; /* examined bytes per scan pass */ + uint64_t pss_pass_issued; /* issued bytes per scan pass */ + uint64_t pss_pass_start; /* start time of a scan pass */ + uint64_t pss_pass_scrub_pause; /* pause time of a scurb pass */ + /* cumulative time scrub spent paused, needed for rate calculation */ + uint64_t pss_pass_scrub_spent_paused; + + /* Sorted scrubbing new fields */ + /* Stored on disk */ + uint64_t pss_issued; /* total bytes checked by scanner */ +} pool_scan_stat_t; + +/* + * Errata described by http://zfsonlinux.org/msg/ZFS-8000-ER. The ordering + * of this enum must be maintained to ensure the errata identifiers map to + * the correct documentation. New errata may only be appended to the list + * and must contain corresponding documentation at the above link. + */ +typedef enum zpool_errata { + ZPOOL_ERRATA_NONE, + ZPOOL_ERRATA_ZOL_2094_SCRUB, + ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY, + ZPOOL_ERRATA_ZOL_6845_ENCRYPTION, + ZPOOL_ERRATA_ZOL_8308_ENCRYPTION, +} zpool_errata_t; + +typedef struct pool_removal_stat { + uint64_t prs_state; /* dsl_scan_state_t */ + uint64_t prs_removing_vdev; + uint64_t prs_start_time; + uint64_t prs_end_time; + uint64_t prs_to_copy; /* bytes that need to be copied */ + uint64_t prs_copied; /* bytes copied so far */ + /* + * bytes of memory used for indirect mappings. + * This includes all removed vdevs. + */ + uint64_t prs_mapping_memory; +} pool_removal_stat_t; + +typedef enum dsl_scan_state { + DSS_NONE, + DSS_SCANNING, + DSS_FINISHED, + DSS_CANCELED, + DSS_NUM_STATES +} dsl_scan_state_t; + +typedef enum { + CS_NONE, + CS_CHECKPOINT_EXISTS, + CS_CHECKPOINT_DISCARDING, + CS_NUM_STATES +} checkpoint_state_t; + +typedef struct pool_checkpoint_stat { + uint64_t pcs_state; /* checkpoint_state_t */ + uint64_t pcs_start_time; /* time checkpoint/discard started */ + uint64_t pcs_space; /* checkpointed space */ +} pool_checkpoint_stat_t; + +typedef enum { + VDEV_INITIALIZE_NONE, + VDEV_INITIALIZE_ACTIVE, + VDEV_INITIALIZE_CANCELED, + VDEV_INITIALIZE_SUSPENDED, + VDEV_INITIALIZE_COMPLETE +} vdev_initializing_state_t; + +typedef enum { + VDEV_TRIM_NONE, + VDEV_TRIM_ACTIVE, + VDEV_TRIM_CANCELED, + VDEV_TRIM_SUSPENDED, + VDEV_TRIM_COMPLETE, +} vdev_trim_state_t; + +/* + * Vdev statistics. Note: all fields should be 64-bit because this + * is passed between kernel and user land as an nvlist uint64 array. + * + * The vs_ops[] and vs_bytes[] arrays must always be an array size of 6 in + * order to keep subsequent members at their known fixed offsets. When + * adding a new field it must be added to the end the structure. + */ +#define VS_ZIO_TYPES 6 + +typedef struct vdev_stat { + hrtime_t vs_timestamp; /* time since vdev load */ + uint64_t vs_state; /* vdev state */ + uint64_t vs_aux; /* see vdev_aux_t */ + uint64_t vs_alloc; /* space allocated */ + uint64_t vs_space; /* total capacity */ + uint64_t vs_dspace; /* deflated capacity */ + uint64_t vs_rsize; /* replaceable dev size */ + uint64_t vs_esize; /* expandable dev size */ + uint64_t vs_ops[VS_ZIO_TYPES]; /* operation count */ + uint64_t vs_bytes[VS_ZIO_TYPES]; /* bytes read/written */ + uint64_t vs_read_errors; /* read errors */ + uint64_t vs_write_errors; /* write errors */ + uint64_t vs_checksum_errors; /* checksum errors */ + uint64_t vs_initialize_errors; /* initializing errors */ + uint64_t vs_self_healed; /* self-healed bytes */ + uint64_t vs_scan_removing; /* removing? */ + uint64_t vs_scan_processed; /* scan processed bytes */ + uint64_t vs_fragmentation; /* device fragmentation */ + uint64_t vs_initialize_bytes_done; /* bytes initialized */ + uint64_t vs_initialize_bytes_est; /* total bytes to initialize */ + uint64_t vs_initialize_state; /* vdev_initialzing_state_t */ + uint64_t vs_initialize_action_time; /* time_t */ + uint64_t vs_checkpoint_space; /* checkpoint-consumed space */ + uint64_t vs_resilver_deferred; /* resilver deferred */ + uint64_t vs_slow_ios; /* slow IOs */ + uint64_t vs_trim_errors; /* trimming errors */ + uint64_t vs_trim_notsup; /* supported by device */ + uint64_t vs_trim_bytes_done; /* bytes trimmed */ + uint64_t vs_trim_bytes_est; /* total bytes to trim */ + uint64_t vs_trim_state; /* vdev_trim_state_t */ + uint64_t vs_trim_action_time; /* time_t */ +} vdev_stat_t; + +/* + * Extended stats + * + * These are stats which aren't included in the original iostat output. For + * convenience, they are grouped together in vdev_stat_ex, although each stat + * is individually exported as a nvlist. + */ +typedef struct vdev_stat_ex { + /* Number of ZIOs issued to disk and waiting to finish */ + uint64_t vsx_active_queue[ZIO_PRIORITY_N_QUEUEABLE]; + + /* Number of ZIOs pending to be issued to disk */ + uint64_t vsx_pend_queue[ZIO_PRIORITY_N_QUEUEABLE]; + + /* + * Below are the histograms for various latencies. Buckets are in + * units of nanoseconds. + */ + + /* + * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in + * before this. + */ +#define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */ +#define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */ + + /* Amount of time in ZIO queue (ns) */ + uint64_t vsx_queue_histo[ZIO_PRIORITY_N_QUEUEABLE] + [VDEV_L_HISTO_BUCKETS]; + + /* Total ZIO latency (ns). Includes queuing and disk access time */ + uint64_t vsx_total_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS]; + + /* Amount of time to read/write the disk (ns) */ + uint64_t vsx_disk_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS]; + + /* "lookup the bucket for a value" macro */ +#define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \ + buckets - 1) : 0) +#define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS) +#define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS) + + /* Physical IO histogram */ + uint64_t vsx_ind_histo[ZIO_PRIORITY_N_QUEUEABLE] + [VDEV_RQ_HISTO_BUCKETS]; + + /* Delegated (aggregated) physical IO histogram */ + uint64_t vsx_agg_histo[ZIO_PRIORITY_N_QUEUEABLE] + [VDEV_RQ_HISTO_BUCKETS]; + +} vdev_stat_ex_t; + +/* + * DDT statistics. Note: all fields should be 64-bit because this + * is passed between kernel and userland as an nvlist uint64 array. + */ +typedef struct ddt_object { + uint64_t ddo_count; /* number of elments in ddt */ + uint64_t ddo_dspace; /* size of ddt on disk */ + uint64_t ddo_mspace; /* size of ddt in-core */ +} ddt_object_t; + +typedef struct ddt_stat { + uint64_t dds_blocks; /* blocks */ + uint64_t dds_lsize; /* logical size */ + uint64_t dds_psize; /* physical size */ + uint64_t dds_dsize; /* deflated allocated size */ + uint64_t dds_ref_blocks; /* referenced blocks */ + uint64_t dds_ref_lsize; /* referenced lsize * refcnt */ + uint64_t dds_ref_psize; /* referenced psize * refcnt */ + uint64_t dds_ref_dsize; /* referenced dsize * refcnt */ +} ddt_stat_t; + +typedef struct ddt_histogram { + ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */ +} ddt_histogram_t; + +#define ZVOL_DRIVER "zvol" +#define ZFS_DRIVER "zfs" +#define ZFS_DEV "/dev/zfs" +#define ZFS_DISK_ROOT "/dev/dsk" +#define ZFS_DISK_ROOTD ZFS_DISK_ROOT "/" +#define ZFS_RDISK_ROOT "/dev/rdsk" +#define ZFS_RDISK_ROOTD ZFS_RDISK_ROOT "/" + +/* general zvol path */ +#define ZVOL_DIR "/dev/zvol" +/* expansion */ +#define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:" +/* for dump and swap */ +#define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/" +#define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/" + +#define ZVOL_PROP_NAME "name" +#define ZVOL_DEFAULT_BLOCKSIZE 8192 + +/* + * /dev/zfs ioctl numbers. + */ +typedef enum zfs_ioc { + /* + * Core features - 81/128 numbers reserved. + */ +#ifdef __FreeBSD__ + ZFS_IOC_FIRST = 0, +#else + ZFS_IOC_FIRST = ('Z' << 8), +#endif + ZFS_IOC = ZFS_IOC_FIRST, + ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST, /* 0x5a00 */ + ZFS_IOC_POOL_DESTROY, /* 0x5a01 */ + ZFS_IOC_POOL_IMPORT, /* 0x5a02 */ + ZFS_IOC_POOL_EXPORT, /* 0x5a03 */ + ZFS_IOC_POOL_CONFIGS, /* 0x5a04 */ + ZFS_IOC_POOL_STATS, /* 0x5a05 */ + ZFS_IOC_POOL_TRYIMPORT, /* 0x5a06 */ + ZFS_IOC_POOL_SCAN, /* 0x5a07 */ + ZFS_IOC_POOL_FREEZE, /* 0x5a08 */ + ZFS_IOC_POOL_UPGRADE, /* 0x5a09 */ + ZFS_IOC_POOL_GET_HISTORY, /* 0x5a0a */ + ZFS_IOC_VDEV_ADD, /* 0x5a0b */ + ZFS_IOC_VDEV_REMOVE, /* 0x5a0c */ + ZFS_IOC_VDEV_SET_STATE, /* 0x5a0d */ + ZFS_IOC_VDEV_ATTACH, /* 0x5a0e */ + ZFS_IOC_VDEV_DETACH, /* 0x5a0f */ + ZFS_IOC_VDEV_SETPATH, /* 0x5a10 */ + ZFS_IOC_VDEV_SETFRU, /* 0x5a11 */ + ZFS_IOC_OBJSET_STATS, /* 0x5a12 */ + ZFS_IOC_OBJSET_ZPLPROPS, /* 0x5a13 */ + ZFS_IOC_DATASET_LIST_NEXT, /* 0x5a14 */ + ZFS_IOC_SNAPSHOT_LIST_NEXT, /* 0x5a15 */ + ZFS_IOC_SET_PROP, /* 0x5a16 */ + ZFS_IOC_CREATE, /* 0x5a17 */ + ZFS_IOC_DESTROY, /* 0x5a18 */ + ZFS_IOC_ROLLBACK, /* 0x5a19 */ + ZFS_IOC_RENAME, /* 0x5a1a */ + ZFS_IOC_RECV, /* 0x5a1b */ + ZFS_IOC_SEND, /* 0x5a1c */ + ZFS_IOC_INJECT_FAULT, /* 0x5a1d */ + ZFS_IOC_CLEAR_FAULT, /* 0x5a1e */ + ZFS_IOC_INJECT_LIST_NEXT, /* 0x5a1f */ + ZFS_IOC_ERROR_LOG, /* 0x5a20 */ + ZFS_IOC_CLEAR, /* 0x5a21 */ + ZFS_IOC_PROMOTE, /* 0x5a22 */ + ZFS_IOC_SNAPSHOT, /* 0x5a23 */ + ZFS_IOC_DSOBJ_TO_DSNAME, /* 0x5a24 */ + ZFS_IOC_OBJ_TO_PATH, /* 0x5a25 */ + ZFS_IOC_POOL_SET_PROPS, /* 0x5a26 */ + ZFS_IOC_POOL_GET_PROPS, /* 0x5a27 */ + ZFS_IOC_SET_FSACL, /* 0x5a28 */ + ZFS_IOC_GET_FSACL, /* 0x5a29 */ + ZFS_IOC_SHARE, /* 0x5a2a */ + ZFS_IOC_INHERIT_PROP, /* 0x5a2b */ + ZFS_IOC_SMB_ACL, /* 0x5a2c */ + ZFS_IOC_USERSPACE_ONE, /* 0x5a2d */ + ZFS_IOC_USERSPACE_MANY, /* 0x5a2e */ + ZFS_IOC_USERSPACE_UPGRADE, /* 0x5a2f */ + ZFS_IOC_HOLD, /* 0x5a30 */ + ZFS_IOC_RELEASE, /* 0x5a31 */ + ZFS_IOC_GET_HOLDS, /* 0x5a32 */ + ZFS_IOC_OBJSET_RECVD_PROPS, /* 0x5a33 */ + ZFS_IOC_VDEV_SPLIT, /* 0x5a34 */ + ZFS_IOC_NEXT_OBJ, /* 0x5a35 */ + ZFS_IOC_DIFF, /* 0x5a36 */ + ZFS_IOC_TMP_SNAPSHOT, /* 0x5a37 */ + ZFS_IOC_OBJ_TO_STATS, /* 0x5a38 */ + ZFS_IOC_SPACE_WRITTEN, /* 0x5a39 */ + ZFS_IOC_SPACE_SNAPS, /* 0x5a3a */ + ZFS_IOC_DESTROY_SNAPS, /* 0x5a3b */ + ZFS_IOC_POOL_REGUID, /* 0x5a3c */ + ZFS_IOC_POOL_REOPEN, /* 0x5a3d */ + ZFS_IOC_SEND_PROGRESS, /* 0x5a3e */ + ZFS_IOC_LOG_HISTORY, /* 0x5a3f */ + ZFS_IOC_SEND_NEW, /* 0x5a40 */ + ZFS_IOC_SEND_SPACE, /* 0x5a41 */ + ZFS_IOC_CLONE, /* 0x5a42 */ + ZFS_IOC_BOOKMARK, /* 0x5a43 */ + ZFS_IOC_GET_BOOKMARKS, /* 0x5a44 */ + ZFS_IOC_DESTROY_BOOKMARKS, /* 0x5a45 */ + ZFS_IOC_POOL_SYNC, /* 0x5a46 */ + ZFS_IOC_CHANNEL_PROGRAM, /* 0x5a47 */ + ZFS_IOC_LOAD_KEY, /* 0x5a48 */ + ZFS_IOC_UNLOAD_KEY, /* 0x5a49 */ + ZFS_IOC_CHANGE_KEY, /* 0x5a4a */ + ZFS_IOC_REMAP, /* 0x5a4b */ + ZFS_IOC_POOL_CHECKPOINT, /* 0x5a4c */ + ZFS_IOC_POOL_DISCARD_CHECKPOINT, /* 0x5a4d */ + ZFS_IOC_POOL_INITIALIZE, /* 0x5a4e */ + ZFS_IOC_POOL_TRIM, /* 0x5a4f */ + ZFS_IOC_REDACT, /* 0x5a50 */ + ZFS_IOC_GET_BOOKMARK_PROPS, /* 0x5a51 */ + + /* + * Per-platform (Optional) - 8/128 numbers reserved. + */ + ZFS_IOC_PLATFORM = ZFS_IOC_FIRST + 0x80, + ZFS_IOC_EVENTS_NEXT, /* 0x81 (Linux) */ + ZFS_IOC_EVENTS_CLEAR, /* 0x82 (Linux) */ + ZFS_IOC_EVENTS_SEEK, /* 0x83 (Linux) */ + ZFS_IOC_NEXTBOOT, /* 0x84 (FreeBSD) */ + ZFS_IOC_JAIL, /* 0x85 (FreeBSD) */ + ZFS_IOC_UNJAIL, /* 0x86 (FreeBSD) */ + ZFS_IOC_SET_BOOTENV, /* 0x87 */ + ZFS_IOC_GET_BOOTENV, /* 0x88 */ + ZFS_IOC_LAST +} zfs_ioc_t; + +/* + * ZFS-specific error codes used for returning descriptive errors + * to the userland through zfs ioctls. + * + * The enum implicitly includes all the error codes from errno.h. + * New code should use and extend this enum for errors that are + * not described precisely by generic errno codes. + */ +typedef enum { + ZFS_ERR_CHECKPOINT_EXISTS = 1024, + ZFS_ERR_DISCARDING_CHECKPOINT, + ZFS_ERR_NO_CHECKPOINT, + ZFS_ERR_DEVRM_IN_PROGRESS, + ZFS_ERR_VDEV_TOO_BIG, + ZFS_ERR_FROM_IVSET_GUID_MISSING, + ZFS_ERR_FROM_IVSET_GUID_MISMATCH, + ZFS_ERR_SPILL_BLOCK_FLAG_MISSING, + ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE, + ZFS_ERR_IOC_CMD_UNAVAIL, + ZFS_ERR_IOC_ARG_UNAVAIL, + ZFS_ERR_IOC_ARG_REQUIRED, + ZFS_ERR_IOC_ARG_BADTYPE, +} zfs_errno_t; + +/* + * Internal SPA load state. Used by FMA diagnosis engine. + */ +typedef enum { + SPA_LOAD_NONE, /* no load in progress */ + SPA_LOAD_OPEN, /* normal open */ + SPA_LOAD_IMPORT, /* import in progress */ + SPA_LOAD_TRYIMPORT, /* tryimport in progress */ + SPA_LOAD_RECOVER, /* recovery requested */ + SPA_LOAD_ERROR, /* load failed */ + SPA_LOAD_CREATE /* creation in progress */ +} spa_load_state_t; + +/* supported encryption algorithms */ +enum zio_encrypt { + ZIO_CRYPT_INHERIT = 0, + ZIO_CRYPT_ON, + ZIO_CRYPT_OFF, + ZIO_CRYPT_AES_128_CCM, + ZIO_CRYPT_AES_192_CCM, + ZIO_CRYPT_AES_256_CCM, + ZIO_CRYPT_AES_128_GCM, + ZIO_CRYPT_AES_192_GCM, + ZIO_CRYPT_AES_256_GCM, + ZIO_CRYPT_FUNCTIONS +}; + +/* + * Bookmark name values. + */ +#define ZPOOL_ERR_LIST "error list" +#define ZPOOL_ERR_DATASET "dataset" +#define ZPOOL_ERR_OBJECT "object" + +#define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) + +/* + * The following are names used in the nvlist describing + * the pool's history log. + */ +#define ZPOOL_HIST_RECORD "history record" +#define ZPOOL_HIST_TIME "history time" +#define ZPOOL_HIST_CMD "history command" +#define ZPOOL_HIST_WHO "history who" +#define ZPOOL_HIST_ZONE "history zone" +#define ZPOOL_HIST_HOST "history hostname" +#define ZPOOL_HIST_TXG "history txg" +#define ZPOOL_HIST_INT_EVENT "history internal event" +#define ZPOOL_HIST_INT_STR "history internal str" +#define ZPOOL_HIST_INT_NAME "internal_name" +#define ZPOOL_HIST_IOCTL "ioctl" +#define ZPOOL_HIST_INPUT_NVL "in_nvl" +#define ZPOOL_HIST_OUTPUT_NVL "out_nvl" +#define ZPOOL_HIST_DSNAME "dsname" +#define ZPOOL_HIST_DSID "dsid" +#define ZPOOL_HIST_ERRNO "errno" + +/* + * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE. + */ +#define ZPOOL_INITIALIZE_COMMAND "initialize_command" +#define ZPOOL_INITIALIZE_VDEVS "initialize_vdevs" + +/* + * Special nvlist name that will not have its args recorded in the pool's + * history log. + */ +#define ZPOOL_HIDDEN_ARGS "hidden_args" + +/* + * The following are names used when invoking ZFS_IOC_POOL_TRIM. + */ +#define ZPOOL_TRIM_COMMAND "trim_command" +#define ZPOOL_TRIM_VDEVS "trim_vdevs" +#define ZPOOL_TRIM_RATE "trim_rate" +#define ZPOOL_TRIM_SECURE "trim_secure" + +/* + * Flags for ZFS_IOC_VDEV_SET_STATE + */ +#define ZFS_ONLINE_CHECKREMOVE 0x1 +#define ZFS_ONLINE_UNSPARE 0x2 +#define ZFS_ONLINE_FORCEFAULT 0x4 +#define ZFS_ONLINE_EXPAND 0x8 +#define ZFS_OFFLINE_TEMPORARY 0x1 + +/* + * Flags for ZFS_IOC_POOL_IMPORT + */ +#define ZFS_IMPORT_NORMAL 0x0 +#define ZFS_IMPORT_VERBATIM 0x1 +#define ZFS_IMPORT_ANY_HOST 0x2 +#define ZFS_IMPORT_MISSING_LOG 0x4 +#define ZFS_IMPORT_ONLY 0x8 +#define ZFS_IMPORT_CHECKPOINT 0x10 +#define ZFS_IMPORT_TEMP_NAME 0x20 +#define ZFS_IMPORT_SKIP_MMP 0x40 +#define ZFS_IMPORT_LOAD_KEYS 0x80 + +/* + * Channel program argument/return nvlist keys and defaults. + */ +#define ZCP_ARG_PROGRAM "program" +#define ZCP_ARG_ARGLIST "arg" +#define ZCP_ARG_SYNC "sync" +#define ZCP_ARG_INSTRLIMIT "instrlimit" +#define ZCP_ARG_MEMLIMIT "memlimit" + +#define ZCP_ARG_CLIARGV "argv" + +#define ZCP_RET_ERROR "error" +#define ZCP_RET_RETURN "return" + +#define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000) +#define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT) +#define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024) +#define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT) + +/* + * Sysevent payload members. ZFS will generate the following sysevents with the + * given payloads: + * + * ESC_ZFS_RESILVER_START + * ESC_ZFS_RESILVER_END + * ESC_ZFS_POOL_DESTROY + * ESC_ZFS_POOL_REGUID + * + * ZFS_EV_POOL_NAME DATA_TYPE_STRING + * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 + * + * ESC_ZFS_VDEV_REMOVE + * ESC_ZFS_VDEV_CLEAR + * ESC_ZFS_VDEV_CHECK + * + * ZFS_EV_POOL_NAME DATA_TYPE_STRING + * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 + * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) + * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 + * + * ESC_ZFS_HISTORY_EVENT + * + * ZFS_EV_POOL_NAME DATA_TYPE_STRING + * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 + * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional) + * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional) + * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional) + * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional) + * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional) + * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional) + * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional) + * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional) + * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional) + * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional) + * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional) + * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional) + * + * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the + * history log nvlist. The keynames will be free of any spaces or other + * characters that could be potentially unexpected to consumers of the + * sysevents. + */ +#define ZFS_EV_POOL_NAME "pool_name" +#define ZFS_EV_POOL_GUID "pool_guid" +#define ZFS_EV_VDEV_PATH "vdev_path" +#define ZFS_EV_VDEV_GUID "vdev_guid" +#define ZFS_EV_HIST_TIME "history_time" +#define ZFS_EV_HIST_CMD "history_command" +#define ZFS_EV_HIST_WHO "history_who" +#define ZFS_EV_HIST_ZONE "history_zone" +#define ZFS_EV_HIST_HOST "history_hostname" +#define ZFS_EV_HIST_TXG "history_txg" +#define ZFS_EV_HIST_INT_EVENT "history_internal_event" +#define ZFS_EV_HIST_INT_STR "history_internal_str" +#define ZFS_EV_HIST_INT_NAME "history_internal_name" +#define ZFS_EV_HIST_IOCTL "history_ioctl" +#define ZFS_EV_HIST_DSNAME "history_dsname" +#define ZFS_EV_HIST_DSID "history_dsid" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_ZFS_H */ diff --git a/illumos-x86_64/usr/include/sys/fs_reparse.h b/illumos-x86_64/usr/include/sys/fs_reparse.h new file mode 100644 index 00000000..68f7c560 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs_reparse.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _FS_REPARSE_H +#define _FS_REPARSE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#include +#include +#else +#include +#endif + +#define FS_REPARSE_TAG_STR "@{REPARSE" +#define FS_REPARSE_TAG_END_CHAR '}' +#define FS_REPARSE_TAG_END_STR "}" +#define FS_TOKEN_START_STR "@{" +#define FS_TOKEN_END_STR "}" + +#define REPARSED "svc:/system/filesystem/reparse:default" +#define MAXREPARSELEN MAXPATHLEN +#define REPARSED_DOOR "/var/run/reparsed_door" +#define REPARSED_DOORCALL_MAX_RETRY 4 + +/* + * This structure is shared between kernel code and user reparsed daemon. + * The 'res_len' must be defined as int, and not size_t, for 32-bit reparsed + * binary and 64-bit kernel code to work together. + */ +typedef struct reparsed_door_res { + int res_status; + int res_len; + char res_data[1]; +} reparsed_door_res_t; + +extern nvlist_t *reparse_init(void); +extern void reparse_free(nvlist_t *nvl); +extern int reparse_parse(const char *reparse_data, nvlist_t *nvl); +extern int reparse_validate(const char *reparse_data); + +#ifdef _KERNEL +extern int reparse_kderef(const char *svc_type, const char *svc_data, + char *buf, size_t *bufsz); +extern int reparse_vnode_parse(vnode_t *vp, nvlist_t *nvl); +#else +extern int reparse_add(nvlist_t *nvl, const char *svc_type, + const char *svc_data); +extern int reparse_remove(nvlist_t *nvl, const char *svc_type); +extern int reparse_unparse(nvlist_t *nvl, char **stringp); +extern int reparse_create(const char *path, const char *data); +extern int reparse_delete(const char *path); +extern int reparse_deref(const char *svc_type, const char *svc_data, + char *buf, size_t *bufsz); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _FS_REPARSE_H */ diff --git a/illumos-x86_64/usr/include/sys/fs_subr.h b/illumos-x86_64/usr/include/sys/fs_subr.h new file mode 100644 index 00000000..551cb0ed --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fs_subr.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Joyent, Inc. + */ + +#ifndef _SYS_FS_SUBR_H +#define _SYS_FS_SUBR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Utilities shared among file system implementations. + */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern int fs_nosys(); +extern int fs_inval(); +extern int fs_notdir(); +extern int fs_nosys_syncfs(vfs_t *, uint64_t, cred_t *); +extern int fs_nosys_map(struct vnode *, offset_t, struct as *, caddr_t *, + size_t, uchar_t, uchar_t, uint_t, struct cred *, + caller_context_t *); +extern int fs_nosys_addmap(struct vnode *, offset_t, struct as *, caddr_t, + size_t, uchar_t, uchar_t, uint_t, struct cred *, + caller_context_t *); +extern int fs_nosys_poll(struct vnode *, short, int, short *, + struct pollhead **, caller_context_t *); +extern int fs_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *); +extern int fs_putpage(vnode_t *, offset_t, size_t, int, cred_t *, + caller_context_t *); +extern int fs_fsync(vnode_t *, int, cred_t *, caller_context_t *); +extern int fs_sync(struct vfs *, short, cred_t *); +extern int fs_syncfs_nop(vfs_t *, uint64_t, cred_t *); +extern int fs_rwlock(vnode_t *, int, caller_context_t *); +extern void fs_rwunlock(vnode_t *, int, caller_context_t *); +extern int fs_cmp(vnode_t *, vnode_t *, caller_context_t *); +extern int fs_seek(vnode_t *, offset_t, offset_t *, caller_context_t *); +extern int fs_frlock(vnode_t *, int, struct flock64 *, int, offset_t, + struct flk_callback *, cred_t *, caller_context_t *); +extern int fs_setfl(vnode_t *, int, int, cred_t *, caller_context_t *); +extern int fs_poll(vnode_t *, short, int, short *, struct pollhead **, + caller_context_t *); +extern int fs_pathconf(struct vnode *, int, ulong_t *, struct cred *, + caller_context_t *); +extern void clkset(time_t); +extern void fs_dispose(struct vnode *, page_t *, int, int, struct cred *, + caller_context_t *); +extern void fs_nodispose(struct vnode *, page_t *, int, int, struct cred *, + caller_context_t *); +extern int fs_fab_acl(struct vnode *, vsecattr_t *, int flag, cred_t *, + caller_context_t *); +extern int fs_shrlock(struct vnode *, int, struct shrlock *, int, + cred_t *, caller_context_t *); +extern int fs_vnevent_nosupport(vnode_t *, vnevent_t, vnode_t *dvp, + char *fnm, caller_context_t *); +extern int fs_vnevent_support(vnode_t *, vnevent_t, vnode_t *dvp, + char *fnm, caller_context_t *); +extern int fs_acl_nontrivial(struct vnode *vp, struct cred *cr); +extern int fs_need_estale_retry(int); +extern void fs_vscan_register(int (*av_scan)(vnode_t *, cred_t *, int)); +extern int fs_vscan(vnode_t *, cred_t *, int); + +extern vfs_t *fs_vfsp_global(struct vfsops *, dev_t, int, uint_t); + +/* Helper function to detect when epoll checks VOP_POLL handlers */ +extern boolean_t fs_reject_epoll(); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_SUBR_H */ diff --git a/illumos-x86_64/usr/include/sys/fsid.h b/illumos-x86_64/usr/include/sys/fsid.h new file mode 100644 index 00000000..bf186bd9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fsid.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_FSID_H +#define _SYS_FSID_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Fstyp names for use in fsinfo structure. These names */ +/* must be constant across releases and will be used by a */ +/* user level routine to map fstyp to fstyp index as used */ +/* ip->i_fstyp. This is necessary for programs like mount. */ + +#define S51K "S51K" +#define PROC "PROC" +#define DUFST "DUFST" +#define NFS "NFS" +#define S52K "S52K" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FSID_H */ diff --git a/illumos-x86_64/usr/include/sys/fss.h b/illumos-x86_64/usr/include/sys/fss.h new file mode 100644 index 00000000..87d798d6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fss.h @@ -0,0 +1,175 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_FSS_H +#define _SYS_FSS_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +typedef uint64_t fsspri_t; +typedef uint64_t fssusage_t; +struct cpupart; +struct zone; + +/* + * Valid arg1's for fss_allocbuf() + */ +#define FSS_NPSET_BUF 1 +#define FSS_NPROJ_BUF 2 +#define FSS_ONE_BUF 3 + +/* + * Valid arg2's for fss_allocbuf() + */ +#define FSS_ALLOC_PROJ 1 +#define FSS_ALLOC_ZONE 2 + +#define FSS_MAXSHARES 65535 + +typedef struct fssbuf { + int fssb_size; + void **fssb_list; +} fssbuf_t; + +void *fss_allocbuf(int, int); +void fss_freebuf(fssbuf_t *, int); +void fss_changeproj(kthread_id_t, void *, void *, fssbuf_t *, fssbuf_t *); +void fss_changepset(kthread_id_t, void *, fssbuf_t *, fssbuf_t *); + +/* + * Fair share scheduling class specific cpu partition structure + */ +typedef struct fsspset { + kmutex_t fssps_lock; /* lock to protect per-pset */ + /* list of fssproj structures */ + disp_lock_t fssps_displock; /* lock for fsps_maxfsspri */ + struct cpupart *fssps_cpupart; /* ptr to our cpu partition */ + /* protected by fsspsets_lock */ + fsspri_t fssps_maxfsspri; /* maximum fsspri value among */ + /* all projects on this pset */ + uint32_t fssps_shares; /* number of active shares */ + uint32_t fssps_nproj; /* number of fssproj structures */ + /* on the list */ + struct fssproj *fssps_list; /* list of project parts */ + struct fsszone *fssps_zones; /* list of fsszone_t's in pset */ + uint32_t fssps_gen; /* generation for zone's kstats */ +} fsspset_t; + +/* + * One of these structures is allocated to each project running within each + * active cpu partition. + */ +typedef struct fssproj { + kproject_t *fssp_proj; /* ptr to our project structure */ + fsspset_t *fssp_pset; /* ptr to our fsspset structure */ + uint32_t fssp_threads; /* total number of threads here */ + /* protected by fssps_lock */ + uint32_t fssp_runnable; /* number of runnable threads */ + /* protected by fssps_lock */ + uint32_t fssp_shares; /* copy of our kpj_shares */ + /* protected by fssps_displock */ + uint32_t fssp_ticks; /* total of nice tick values */ + /* protected by fssps_displock */ + uint32_t fssp_tick_cnt; /* cnt of all ticks in this sec */ + uint32_t fssp_shr_pct; /* active shr % in this sec */ + /* protected by fssps_displock */ + fssusage_t fssp_usage; /* this project's decayed usage */ + fssusage_t fssp_shusage; /* normalized usage */ + struct fssproj *fssp_next; /* next project on this pset */ + struct fssproj *fssp_prev; /* prev project on this pset */ + struct fsszone *fssp_fsszone; /* fsszone_t for this fssproj */ +} fssproj_t; + +/* + * Fair share scheduling class specific thread structure + */ +typedef struct fssproc { + kthread_t *fss_tp; /* pointer back to our thread */ + fssproj_t *fss_proj; /* pointer to our project FSS data */ + uchar_t fss_flags; /* flags defined below */ + int fss_timeleft; /* time remaining in procs quantum */ + uint32_t fss_ticks; /* ticks accumulated by this thread */ + pri_t fss_upri; /* user supplied priority (to priocntl) */ + pri_t fss_uprilim; /* user priority limit */ + pri_t fss_umdpri; /* user mode priority within fs class */ + pri_t fss_scpri; /* remembered priority, for schedctl */ + int fss_nice; /* nice value for compatibility with ts */ + fsspri_t fss_fsspri; /* internal fair share priority */ + int fss_runnable; /* to indicate runnable/sleeping thread */ + struct fssproc *fss_next; /* pointer to next fssproc_t struct */ + struct fssproc *fss_prev; /* pointer to prev fssproc_t sturct */ + caps_sc_t fss_caps; /* CPU caps specific data */ +} fssproc_t; + +/* + * One of these structures is allocated to each zone running within + * each active cpu partition. This means that if a zone spans more + * than one cpu partition then it will have a few of these structures. + */ +typedef struct fsszone { + struct zone *fssz_zone; /* ptr to our zone structure */ + struct fsszone *fssz_next; /* next fsszone_t in fsspset_t */ + struct fsszone *fssz_prev; /* prev fsszone_t in fsspset_t */ + uint32_t fssz_shares; /* sum of all project shares */ + uint32_t fssz_nproj; /* # of projects */ + uint32_t fssz_rshares; /* "real" shares given to zone */ + uint32_t fssz_runnable; /* # of runnable projects */ +} fsszone_t; + +#define FSSPROC(tx) ((fssproc_t *)(tx->t_cldata)) +#define FSSPROC2FSSPROJ(fssx) ((fssx)->fss_proj); +#define FSSPROC2FSSPSET(fssx) (FSSPROC2FSSPROJ(fssx)->fssp_pset) +#define FSSPROJ(tx) (FSSPROC(tx)->fss_proj) +#define FSSPROJ2FSSPSET(fssx) ((fssx)->fssp_pset) +#define FSSPROJ2KPROJ(fssx) ((fssx)->fssp_proj) +#define FSSPROJ2FSSZONE(fssx) ((fssx)->fssp_fsszone) + +/* + * fss_flags + */ +/* Formerly: FSSKPRI 0x01 - the thread is in kernel mode */ +#define FSSBACKQ 0x02 /* thread should be placed at the back of */ + /* the dispatch queue if preempted */ +#define FSSRESTORE 0x04 /* thread was not preempted, due to schedctl */ + /* restore priority from fss_scpri */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FSS_H */ diff --git a/illumos-x86_64/usr/include/sys/fssnap.h b/illumos-x86_64/usr/include/sys/fssnap.h new file mode 100644 index 00000000..c0690c87 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fssnap.h @@ -0,0 +1,185 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FSSNAP_H +#define _SYS_FSSNAP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* snapshot backend interfaces, macros, and data structures */ + +#if defined(_KERNEL) + +/* + * defines for the number of threads used to handle tasks, the maximum + * number of chunks in memory at a time, and the maximum number of tasks to + * allow before the taskqs start throttling. MAXTASKS should be greater than + * or equal to MAX_MEM_CHUNKS. + */ +#define FSSNAP_TASKQ_THREADS (2) +#define FSSNAP_MAX_MEM_CHUNKS (32) +#define FSSNAP_TASKQ_MAXTASKS (FSSNAP_MAX_MEM_CHUNKS) + +/* + * It is assumed that a chunk is a multiple of a disk sector so that + * the chunk size can be reduced before using it as a conversion + * factor. Therefore the number of chunks on a file system will + * always be less than the number of blocks it occupies, and these + * conversions will not overflow. (do not convert to bytes first!) + */ + +typedef unsigned long long chunknumber_t; + +/* disk blocks to snapshot chunks */ +#define dbtocowchunk(cmap, dblkno) ((dblkno) / \ + ((cmap)->cmap_chunksz >> DEV_BSHIFT)) + +/* snapshot chunks to disk blocks */ +#define cowchunktodb(cmap, cowchunk) ((cowchunk) * \ + ((cmap)->cmap_chunksz >> DEV_BSHIFT)) + +/* + * A snapshot_id is the shared structure between the snapshot driver + * and the file system. + */ +typedef struct snapshot_id { + struct snapshot_id *sid_next; /* next snapshot in list */ + krwlock_t sid_rwlock; /* protects enable/disable */ + struct cow_info *sid_cowinfo; /* pointer to cow state */ + uint_t sid_snapnumber; /* snapshot number */ + uint_t sid_flags; /* general flags */ + struct vnode *sid_fvp; /* root vnode to snapshot */ +} snapshot_id_t; + +/* snapshot_id flags */ +#define SID_DISABLED (0x01) /* this snapshot has been disabled */ +#define SID_DISABLING (0x02) /* this snapshot is being disabled */ +#define SID_BLOCK_BUSY (0x04) /* snapshot block driver is attached */ +#define SID_CHAR_BUSY (0x08) /* snapshot character driver is attached */ +#define SID_CREATING (0x10) /* snapshot is being created */ +#define SID_DELETE (0x20) /* error condition found, delete snapshot */ + +/* true if snapshot device is open */ +#define SID_BUSY(sidp) (((sidp)->sid_flags & SID_BLOCK_BUSY) || \ + ((sidp)->sid_flags & SID_CHAR_BUSY)) + +/* true if snapshot can not be used */ +#define SID_INACTIVE(sidp) (((sidp)->sid_flags & SID_DISABLED) || \ + ((sidp)->sid_flags & SID_DISABLING) || \ + ((sidp)->sid_flags & SID_CREATING) || \ + ((sidp)->sid_flags & SID_DELETE) || \ + ((sidp)->sid_cowinfo == NULL)) + +/* true if snapshot can be reused now */ +#define SID_AVAILABLE(sidp) (!SID_BUSY(sidp) && \ + ((sidp)->sid_flags & SID_DISABLED)) + +/* + * The cow_map keeps track of all translations, and two bitmaps to + * determine whether the chunk is eligible for translation, and if so + * whether or not it already has a translation. The candidate bitmap + * is read-only and does not require a lock, the hastrans bitmap and + * the translation table are protected by the cmap_rwlock. + */ +typedef struct cow_map { + krwlock_t cmap_rwlock; /* protects this structure */ + ksema_t cmap_throttle_sem; /* used to throttle writes */ + uint32_t cmap_waiters; /* semaphore waiters */ + uint_t cmap_chunksz; /* granularity of COW operations */ + chunknumber_t cmap_chunksperbf; /* chunks in max backing file */ + chunknumber_t cmap_nchunks; /* number of chunks in backing file */ + u_offset_t cmap_maxsize; /* max bytes allowed (0 is no limit) */ + size_t cmap_bmsize; /* size of bitmaps (in bytes) */ + caddr_t cmap_candidate; /* 1 = block is a candidate for COW */ + caddr_t cmap_hastrans; /* 1 = an entry exists in the table */ + struct cow_map_node *cmap_table; /* translation table */ +} cow_map_t; + +/* + * The cow_map_node keeps track of chunks that are still in memory. + */ + +typedef struct cow_map_node { + struct cow_map_node *cmn_next; + struct cow_map_node *cmn_prev; + struct snapshot_id *cmn_sid; /* backpointer to snapshot */ + chunknumber_t cmn_chunk; /* original chunk number */ + caddr_t cmn_buf; /* the data itself */ + int release_sem; /* flag to release */ + /* cmap_throttle_sem */ +} cow_map_node_t; + +/* + * The cow_info structure holds basic snapshot state information. It is + * mostly read-only once the snapshot is created so no locking is required. + * The exception is cow_nextchunk, which is ever-increasing and updated with + * atomic_add(). This structure is allocated dynamically, and creation and + * deletion of the snapshot is protected by the snapshot_mutex variable. + */ +typedef struct cow_info { + int cow_backcount; /* number of backing files */ + vnode_t **cow_backfile_array; /* array of backing files */ + u_offset_t cow_backfile_sz; /* max size of a backfile */ + taskq_t *cow_taskq; /* task queue for async writes */ + struct kstat *cow_kstat_mntpt; /* kstat for mount point */ + struct kstat *cow_kstat_bfname; /* kstat for backing file */ + struct kstat *cow_kstat_num; /* named numeric kstats */ + struct cow_map cow_map; /* block translation table */ +} cow_info_t; + +/* kstat information */ +struct cow_kstat_num { + kstat_named_t ckn_state; /* state of the snapshot device */ + kstat_named_t ckn_bfsize; /* sum of sizes of backing files */ + kstat_named_t ckn_maxsize; /* maximum backing file size */ + kstat_named_t ckn_createtime; /* snapshot creation time */ + kstat_named_t ckn_chunksize; /* chunk size */ +}; + +/* ckn_state values */ +#define COWSTATE_CREATING (0) /* snapshot being created */ +#define COWSTATE_IDLE (1) /* snapshot exists, but not open */ +#define COWSTATE_ACTIVE (2) /* snapshot open */ +#define COWSTATE_DISABLED (3) /* snapshot deleted (pending close) */ + +extern uint_t bypass_snapshot_throttle_key; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FSSNAP_H */ diff --git a/illumos-x86_64/usr/include/sys/fssnap_if.h b/illumos-x86_64/usr/include/sys/fssnap_if.h new file mode 100644 index 00000000..6a411d78 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fssnap_if.h @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FSSNAP_IF_H +#define _SYS_FSSNAP_IF_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ioctl's for communicating between the user and the fssnapctl device. + * Also used to communicate between fssnapctl and the file system. + * Pack fiosnapcreate for amd64 to make struct size same as x86. + */ + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +struct fiosnapcreate { + int rootfiledesc; /* IN fd for root of fs to be snapshotted */ + int backfiledesc; /* IN backing store file for snapshot data */ + uint_t snapshotnumber; /* OUT snapshot number created */ + uint_t chunksize; /* IN chunk size, 0 == fs defined */ + u_offset_t maxsize; /* IN maximum size of backing file */ + char backfilename[MAXPATHLEN]; /* IN for bookkeeping */ + int error; /* OUT error code */ +}; + +struct fiosnapcreate_multi { + int rootfiledesc; /* IN fd for root of fs to be snapshotted */ + uint_t snapshotnumber; /* OUT snapshot number created */ + uint_t chunksize; /* IN chunk size, 0 == fs defined */ + u_offset_t maxsize; /* IN max size of entire backing store */ + char backfilename[MAXPATHLEN]; /* IN for bookkeeping */ + int error; /* OUT error code */ + int backfilecount; /* IN number of backing store files */ + u_offset_t backfilesize; /* IN maximum size of each backfile */ + int backfiledesc[1]; /* IN backing store files for snapshot data */ +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +struct fiosnapdelete { + int rootfiledesc; /* IN fd for root of fs to be unsnapshotted */ + uint_t snapshotnumber; /* OUT snapshot number deleted */ + int error; /* OUT error code */ +}; + +/* ioctl error returns */ +#define FIOCOW_EREADONLY (1) /* read only file system */ +#define FIOCOW_EBUSY (2) /* snapshot already enabled */ +#define FIOCOW_EULOCK (3) /* file system is locked */ +#define FIOCOW_EWLOCK (4) /* file system could not be write locked */ +#define FIOCOW_EFLUSH (5) /* file system could not be flushed */ +#define FIOCOW_ECLEAN (6) /* file system may not be stable */ +#define FIOCOW_ENOULOCK (7) /* file system could not be unlocked */ +#define FIOCOW_ECHUNKSZ (8) /* chunksize is less than fs fragment size */ +#define FIOCOW_ECREATE (9) /* could not allocate/create snapshot */ +#define FIOCOW_EBITMAP (10) /* error scanning file system bitmaps */ +#define FIOCOW_EBACKFILE (11) /* bad backing file path passed in */ + +/* + * make the control device minor number high so minor numbers match + * snapshot numbers. + */ +#define SNAP_CTL_MINOR (L_MAXMIN32) +#define SNAP_NAME "fssnap" +#define SNAP_CTL_NODE "ctl" +#define SNAP_CTL_NAME SNAP_NAME SNAP_CTL_NODE +#define SNAP_BLOCK_NAME SNAP_NAME +#define SNAP_CHAR_NAME "r" SNAP_NAME + +/* kstat names */ +#define FSSNAP_KSTAT_HIGHWATER "highwater" +#define FSSNAP_KSTAT_MNTPT "mountpoint" +#define FSSNAP_KSTAT_BFNAME "bfname" +#define FSSNAP_KSTAT_NUM "numericstats" + +/* numericstats kstat names */ +#define FSSNAP_KSTAT_NUM_STATE "state" +#define FSSNAP_KSTAT_NUM_BFSIZE "bfsize" +#define FSSNAP_KSTAT_NUM_MAXSIZE "maxsize" +#define FSSNAP_KSTAT_NUM_CHUNKSIZE "chunksize" +#define FSSNAP_KSTAT_NUM_CREATETIME "createtime" + +#if defined(_KERNEL) +/* + * snapshot operations implemented by the loadable snapshot subsystem + */ +struct fssnap_operations { + void *(*fssnap_create)(chunknumber_t, uint_t, u_offset_t, + struct vnode *, int, struct vnode **, char *, u_offset_t); + void (*fssnap_set_candidate)(void *, chunknumber_t); + int (*fssnap_is_candidate)(void *, u_offset_t); + int (*fssnap_create_done)(void *); + int (*fssnap_delete)(void *); + void (*fssnap_strategy)(void *, struct buf *); +}; + + +/* global variables to manage interface operations */ +extern struct fssnap_operations snapops; + +/* External functions called by file systems that use snapshots */ +extern int fssnap_init(void); +extern int fssnap_fini(void); +extern void *fssnap_create(chunknumber_t, uint_t, u_offset_t, struct vnode *, + int, struct vnode **, char *, u_offset_t); +extern void fssnap_set_candidate(void *, chunknumber_t); +extern int fssnap_is_candidate(void *, u_offset_t); +extern int fssnap_create_done(void *); +extern int fssnap_delete(void *); +extern void fssnap_strategy(void *, struct buf *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FSSNAP_IF_H */ diff --git a/illumos-x86_64/usr/include/sys/fsspriocntl.h b/illumos-x86_64/usr/include/sys/fsspriocntl.h new file mode 100644 index 00000000..4f61519a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fsspriocntl.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FSSPRIOCNTL_H +#define _SYS_FSSPRIOCNTL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fair-share class specific structures for the priocntl system call. + */ +typedef struct fssparms { + pri_t fss_uprilim; /* user priority limit */ + pri_t fss_upri; /* user priority */ +} fssparms_t; + +typedef struct fssinfo { + pri_t fss_maxupri; /* configured limit on user priority range */ +} fssinfo_t; + +#define FSS_NOCHANGE -32768 + +/* + * Fair-sharing class specific keys for the priocntl system call varargs + * interface. + */ +#define FSS_KY_UPRILIM 1 /* user priority limit */ +#define FSS_KY_UPRI 2 /* user priority */ + +/* + * The following is used by the dispadmin(8) command for scheduler + * administration and is not for general use. + */ +typedef struct fssadmin { + short fss_quantum; + short fss_cmd; +} fssadmin_t; + +#define FSS_GETADMIN 1 +#define FSS_SETADMIN 2 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FSSPRIOCNTL_H */ diff --git a/illumos-x86_64/usr/include/sys/fstyp.h b/illumos-x86_64/usr/include/sys/fstyp.h new file mode 100644 index 00000000..757ad67c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fstyp.h @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_FSTYP_H +#define _SYS_FSTYP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef FSTYPSZ +#define FSTYPSZ 16 /* max size of fs identifier */ +#endif + +/* + * Opcodes for the sysfs() system call. + */ +#define GETFSIND 1 /* translate fs identifier to fstype index */ +#define GETFSTYP 2 /* translate fstype index to fs identifier */ +#define GETNFSTYP 3 /* return the number of fstypes */ + +#if !defined(_KERNEL) +int sysfs(int, ...); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FSTYP_H */ diff --git a/illumos-x86_64/usr/include/sys/ftrace.h b/illumos-x86_64/usr/include/sys/ftrace.h new file mode 100644 index 00000000..1c29bbba --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ftrace.h @@ -0,0 +1,130 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FTRACE_H +#define _SYS_FTRACE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Constants used by both asm and non-asm code. + */ + +/* + * Flags determining the state of tracing - + * both for the "ftrace_state" variable, and for the per-CPU variable + * "cpu[N]->cpu_ftrace_state". + */ +#define FTRACE_READY 0x00000001 +#define FTRACE_ENABLED 0x00000002 + +#if !defined(_ASM) + +#include +#include +#include + +/* + * The record of a single event. + * + * Should fit nicely into a standard cache line. + * Here, the 32-bit version is 32 bytes, and the 64-bit version is 64 bytes. + */ +typedef struct ftrace_record { + char *ftr_event; + kthread_t *ftr_thread; + uint64_t ftr_tick; + caddr_t ftr_caller; + ulong_t ftr_data1; + ulong_t ftr_data2; + ulong_t ftr_data3; +#ifdef _LP64 + ulong_t __pad; +#endif +} ftrace_record_t; + +/* + * Default per-CPU event ring buffer size. + */ +#define FTRACE_NENT 1024 + +#ifdef _KERNEL + +/* + * Tunable parameters in /etc/system. + */ +extern int ftrace_atboot; /* Whether to start fast tracing on boot. */ +extern int ftrace_nent; /* Size of the per-CPU event ring buffer. */ + +extern int ftrace_cpu_setup(cpu_setup_t, int, void *); +extern void ftrace_init(void); +extern int ftrace_start(void); +extern int ftrace_stop(void); +extern void ftrace_0(char *, caddr_t); +extern void ftrace_1(char *, ulong_t, caddr_t); +extern void ftrace_2(char *, ulong_t, ulong_t, caddr_t); +extern void ftrace_3(char *, ulong_t, ulong_t, ulong_t, caddr_t); +extern void ftrace_3_notick(char *, ulong_t, ulong_t, ulong_t, + caddr_t); + +typedef uintptr_t ftrace_icookie_t; +extern ftrace_icookie_t ftrace_interrupt_disable(void); +extern void ftrace_interrupt_enable(ftrace_icookie_t); +extern caddr_t caller(void); + +#define FTRACE_0(fmt) \ + { \ + if (CPU->cpu_ftrace.ftd_state & FTRACE_ENABLED) \ + ftrace_0(fmt, caller()); \ + } +#define FTRACE_1(fmt, d1) \ + { \ + if (CPU->cpu_ftrace.ftd_state & FTRACE_ENABLED) \ + ftrace_1(fmt, d1, caller()); \ + } +#define FTRACE_2(fmt, d1, d2) \ + { \ + if (CPU->cpu_ftrace.ftd_state & FTRACE_ENABLED) \ + ftrace_2(fmt, d1, d2, caller()); \ + } +#define FTRACE_3(fmt, d1, d2, d3) \ + { \ + if (CPU->cpu_ftrace.ftd_state & FTRACE_ENABLED) \ + ftrace_3(fmt, d1, d2, d3, caller()); \ + } +#define FTRACE_START() ftrace_start() +#define FTRACE_STOP() ftrace_stop() + +#endif /* _KERNEL */ + +#endif /* !defined(_ASM) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FTRACE_H */ diff --git a/illumos-x86_64/usr/include/sys/fx.h b/illumos-x86_64/usr/include/sys/fx.h new file mode 100644 index 00000000..4a48af52 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fx.h @@ -0,0 +1,171 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. + */ + +#ifndef _SYS_FX_H +#define _SYS_FX_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fixed-priority dispatcher parameter table entry + */ +typedef struct fxdpent { + pri_t fx_globpri; /* global (class independent) priority */ + int fx_quantum; /* time quantum given to procs at this level */ +} fxdpent_t; + +#ifdef _KERNEL + +typedef uintptr_t fx_cookie_t; /* handle for callback supplied storage */ + +/* + * callbacks supplied by custom scheduler. In general, a change to quantum + * and/or priority when returning from a callback has immediate effect. + * + * fx_exit - called when a thread exits. This also needs to free any storage + * for the fx_cookie_t. + * + * fx_callb_tick - called at every clock tick attributed to this thread + * + * fx_callb_preempt - called when a thread is being preempted or yielding + * + * fx_callb_stop/fx_callb_sleep - called when a thread stops running + * + * fx_callb_wakeup - called when a thread is again runnable + */ +typedef struct fx_callbacks { + int fx_callb_version; + void (*fx_callb_exit)(fx_cookie_t); + void (*fx_callb_tick)(fx_cookie_t, clock_t *, pri_t *); + void (*fx_callb_preempt)(fx_cookie_t, clock_t *, pri_t *); + void (*fx_callb_stop)(fx_cookie_t); + void (*fx_callb_sleep)(fx_cookie_t); + void (*fx_callb_wakeup)(fx_cookie_t, clock_t *, pri_t *); + +} fx_callbacks_t; + + +#define FX_CALLB_VERSION_1 1 + +#define FX_CALLB_REV FX_CALLB_VERSION_1 + +#define FX_CB_VERSION(cb) cb->fx_callb_version + +#define FX_CB_EXIT(cb, c) cb->fx_callb_exit(c) + +#define FX_CB_TICK(cb, c, q, p) cb->fx_callb_tick(c, q, p) + +#define FX_CB_PREEMPT(cb, c, q, p) cb->fx_callb_preempt(c, q, p) + +#define FX_CB_STOP(cb, c) cb->fx_callb_stop(c) + +#define FX_CB_SLEEP(cb, c) cb->fx_callb_sleep(c) + +#define FX_CB_WAKEUP(cb, c, q, p) cb->fx_callb_wakeup(c, q, p) + +/* priority setting */ +#define FX_CB_NOCHANGE -32768 + + +/* + * Fixed-priority class specific thread structure + */ +typedef struct fxproc { + int fx_pquantum; /* time quantum given to this proc */ + int fx_timeleft; /* time remaining in procs quantum */ + + pri_t fx_pri; /* relative priority within fx class */ + /* same as user priority */ + + pri_t fx_uprilim; /* user priority limit */ + + char fx_nice; /* nice value for compatibility */ + uchar_t fx_flags; /* flags defined below */ + kthread_t *fx_tp; /* pointer to thread */ + + /* the following are used only when we have callbacks registered */ + kt_did_t fx_ktid; + struct fxproc *fx_cb_next; /* pointer to next fxproc that */ + /* has a callback */ + + struct fxproc *fx_cb_prev; /* pointer to previous fxproc that */ + /* has a callback */ + fx_cookie_t fx_cookie; /* cookie with which callback */ + /* was registered */ + fx_callbacks_t *fx_callback; /* pointer to callback structure */ + caps_sc_t fx_caps; /* CPU caps specific data */ +} fxproc_t; + + +#define FX_CALLB(fxpp) fxpp->fx_callback + + +/* flags */ +#define FXBACKQ 0x02 /* thread goes to back of disp q when preempted */ + +/* + * Kernel version of fixed-priority class specific parameter structure + */ +typedef struct fxkparms { + pri_t fx_upri; + pri_t fx_uprilim; + int fx_tqntm; + uint_t fx_cflags; +} fxkparms_t; + +/* + * control flags (kparms->fx_cflags). + */ +#define FX_DOUPRILIM 0x01 /* change user priority limit */ +#define FX_DOUPRI 0x02 /* change user priority */ +#define FX_DOTQ 0x04 /* change FX time quantum */ + +#define FXMAXUPRI 60 /* maximum user priority setting */ + +/* + * Interface for partner private code. This is not a public interface. + */ +extern int fx_register_callbacks(fx_callbacks_t *, fx_cookie_t, pri_t, clock_t); +extern int fx_unregister_callbacks(); +extern int fx_modify_priority(kt_did_t, clock_t, pri_t); +extern void *fx_get_mutex_cookie(); +extern pri_t fx_get_maxpri(); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FX_H */ diff --git a/illumos-x86_64/usr/include/sys/fxpriocntl.h b/illumos-x86_64/usr/include/sys/fxpriocntl.h new file mode 100644 index 00000000..8a1c680e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/fxpriocntl.h @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_FXPRIOCNTL_H +#define _SYS_FXPRIOCNTL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fixed-priority class specific structures for the priocntl system call. + */ + +typedef struct fxparms { + pri_t fx_upri; /* fixed-priority user priority */ + pri_t fx_uprilim; /* fixed-priority user priority limit */ + uint_t fx_tqsecs; /* seconds in time quantum */ + int fx_tqnsecs; /* additional nanosecs in time quant */ +} fxparms_t; + + +typedef struct fxinfo { + pri_t fx_maxupri; /* configured limits of user priority range */ +} fxinfo_t; + + +#define FX_NOCHANGE -32768 +#define FX_TQINF -2 +#define FX_TQDEF -3 + +/* + * Fixed-priority class specific keys for the priocntl system call varargs + * interface. + */ +#define FX_KY_UPRILIM 1 /* fixed-priority user priority limit */ +#define FX_KY_UPRI 2 /* fixed-priority user priority */ +#define FX_KY_TQSECS 3 /* seconds in time quantum */ +#define FX_KY_TQNSECS 4 /* nanoseconds in time quantum */ + + +/* + * The following is used by the dispadmin(8) command for + * scheduler administration and is not for general use. + */ + +#ifdef _SYSCALL32 +/* Data structure for ILP32 clients */ +typedef struct fxadmin32 { + caddr32_t fx_dpents; + int16_t fx_ndpents; + int16_t fx_cmd; +} fxadmin32_t; +#endif /* _SYSCALL32 */ + +typedef struct fxadmin { + struct fxdpent *fx_dpents; + short fx_ndpents; + short fx_cmd; +} fxadmin_t; + +#define FX_GETDPSIZE 1 +#define FX_GETDPTBL 2 +#define FX_SETDPTBL 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FXPRIOCNTL_H */ diff --git a/illumos-x86_64/usr/include/sys/gfs.h b/illumos-x86_64/usr/include/sys/gfs.h new file mode 100644 index 00000000..71c7c2ef --- /dev/null +++ b/illumos-x86_64/usr/include/sys/gfs.h @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * These are Consolidation Private interfaces and are subject to change. + */ + +#ifndef _SYS_GFS_H +#define _SYS_GFS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct gfs_opsvec { + const char *gfsv_name; /* vnode description */ + const fs_operation_def_t *gfsv_template; /* ops template */ + vnodeops_t **gfsv_ops; /* ptr to result */ +} gfs_opsvec_t; + +int gfs_make_opsvec(gfs_opsvec_t *); + +#define GFS_CACHE_VNODE 0x1 + +typedef struct gfs_dirent { + char *gfse_name; /* entry name */ + vnode_t *(*gfse_ctor)(vnode_t *); /* constructor */ + int gfse_flags; /* flags */ + list_node_t gfse_link; /* dynamic list */ + vnode_t *gfse_vnode; /* cached vnode */ +} gfs_dirent_t; + +typedef enum gfs_type { + GFS_DIR, + GFS_FILE +} gfs_type_t; + +typedef struct gfs_file { + vnode_t *gfs_vnode; /* current vnode */ + vnode_t *gfs_parent; /* parent vnode */ + size_t gfs_size; /* size of private data structure */ + gfs_type_t gfs_type; /* type of vnode */ + int gfs_index; /* index in parent dir */ + ino64_t gfs_ino; /* inode for this vnode */ +} gfs_file_t; + +typedef int (*gfs_readdir_cb)(vnode_t *, void *, int *, offset_t *, + offset_t *, void *, int); +typedef int (*gfs_lookup_cb)(vnode_t *, const char *, vnode_t **, ino64_t *, + cred_t *, int, int *, pathname_t *); +typedef ino64_t (*gfs_inode_cb)(vnode_t *, int); + +typedef struct gfs_dir { + gfs_file_t gfsd_file; /* generic file attributes */ + gfs_dirent_t *gfsd_static; /* statically defined entries */ + int gfsd_nstatic; /* # static entries */ + kmutex_t gfsd_lock; /* protects entries */ + int gfsd_maxlen; /* maximum name length */ + gfs_readdir_cb gfsd_readdir; /* readdir() callback */ + gfs_lookup_cb gfsd_lookup; /* lookup() callback */ + gfs_inode_cb gfsd_inode; /* get an inode number */ +} gfs_dir_t; + +struct vfs; + +extern vnode_t *gfs_file_create(size_t, vnode_t *, vnodeops_t *); +extern vnode_t *gfs_dir_create(size_t, vnode_t *, vnodeops_t *, + gfs_dirent_t *, gfs_inode_cb, int, gfs_readdir_cb, gfs_lookup_cb); +extern vnode_t *gfs_root_create(size_t, struct vfs *, vnodeops_t *, ino64_t, + gfs_dirent_t *, gfs_inode_cb, int, gfs_readdir_cb, gfs_lookup_cb); +extern vnode_t *gfs_root_create_file(size_t, struct vfs *, vnodeops_t *, + ino64_t); + +extern void *gfs_file_inactive(vnode_t *); +extern void *gfs_dir_inactive(vnode_t *); + +extern int gfs_dir_case_lookup(vnode_t *, const char *, vnode_t **, cred_t *, + int, int *, pathname_t *); +extern int gfs_dir_lookup(vnode_t *, const char *, vnode_t **, cred_t *, + int, int *, pathname_t *); +extern int gfs_dir_readdir(vnode_t *, uio_t *, int *, void *, cred_t *, + caller_context_t *, int flags); + +#define gfs_dir_lock(gd) mutex_enter(&(gd)->gfsd_lock) +#define gfs_dir_unlock(gd) mutex_exit(&(gd)->gfsd_lock) +#define GFS_DIR_LOCKED(gd) MUTEX_HELD(&(gd)->gfsd_lock) + +#define gfs_file_parent(vp) (((gfs_file_t *)(vp)->v_data)->gfs_parent) + +#define gfs_file_index(vp) (((gfs_file_t *)(vp)->v_data)->gfs_index) +#define gfs_file_set_index(vp, idx) \ + (((gfs_file_t *)(vp)->v_data)->gfs_index = (idx)) + +#define gfs_file_inode(vp) (((gfs_file_t *)(vp)->v_data)->gfs_ino) +#define gfs_file_set_inode(vp, ino) \ + (((gfs_file_t *)(vp)->v_data)->gfs_ino = (ino)) + +typedef struct gfs_readdir_state { + void *grd_dirent; /* directory entry buffer */ + size_t grd_namlen; /* max file name length */ + size_t grd_ureclen; /* exported record size */ + ssize_t grd_oresid; /* original uio_resid */ + ino64_t grd_parent; /* inode of parent */ + ino64_t grd_self; /* inode of self */ + int grd_flags; /* flags from VOP_READDIR */ +} gfs_readdir_state_t; + +extern int gfs_readdir_init(gfs_readdir_state_t *, int, int, uio_t *, ino64_t, + ino64_t, int); +extern int gfs_readdir_emit(gfs_readdir_state_t *, uio_t *, offset_t, ino64_t, + const char *, int); +extern int gfs_readdir_emitn(gfs_readdir_state_t *, uio_t *, offset_t, ino64_t, + unsigned long); +extern int gfs_readdir_pred(gfs_readdir_state_t *, uio_t *, offset_t *); +extern int gfs_readdir_fini(gfs_readdir_state_t *, int, int *, int); +extern int gfs_get_parent_ino(vnode_t *, cred_t *, caller_context_t *, + ino64_t *, ino64_t *); + +/* + * Objects with real extended attributes will get their . and .. + * readdir entries from the real xattr directory. GFS_STATIC_ENTRY_OFFSET + * lets us skip right to the static entries in the GFS directory. + */ +#define GFS_STATIC_ENTRY_OFFSET ((offset_t)2) + +extern int gfs_lookup_dot(vnode_t **, vnode_t *, vnode_t *, const char *); + +extern int gfs_vop_lookup(vnode_t *, char *, vnode_t **, pathname_t *, + int, vnode_t *, cred_t *, caller_context_t *, int *, pathname_t *); +extern int gfs_vop_readdir(vnode_t *, uio_t *, cred_t *, int *, + caller_context_t *, int); +extern int gfs_vop_map(vnode_t *, offset_t, struct as *, caddr_t *, + size_t, uchar_t, uchar_t, uint_t, cred_t *, caller_context_t *); +extern void gfs_vop_inactive(vnode_t *, cred_t *, caller_context_t *); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_GFS_H */ diff --git a/illumos-x86_64/usr/include/sys/gfx_private.h b/illumos-x86_64/usr/include/sys/gfx_private.h new file mode 100644 index 00000000..02cacb10 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/gfx_private.h @@ -0,0 +1,166 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * This file defines interfaces consumed by the AGP kernel modules, + * and indirectly by the DRM system. Please consider everything in + * this file to be a "contract private interface", and keep in sync + * with the consumers in the "DRM" gate. + */ + +#ifndef _GFX_PRIVATE_H +#define _GFX_PRIVATE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Updated "glue" for newer libdrm code. + * See: kernel/drm/src/drm_fb_helper.c + */ + +typedef char *gfxp_fb_softc_ptr_t; + +/* Memory cache attributes */ +#define GFXP_MEMORY_CACHED 0 +#define GFXP_MEMORY_UNCACHED 1 +#define GFXP_MEMORY_WRITECOMBINED 2 + +enum gfxp_type { + GFXP_BITMAP, + GFXP_VGATEXT +}; + +typedef uint64_t gfx_maddr_t; +typedef char *gfxp_acc_handle_t; + +extern int gfxp_ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, + caddr_t *addrp, off_t len, uint_t prot, uint_t maxprot, uint_t flags, + cred_t *cred, ddi_device_acc_attr_t *accattrp, uint_t rnumber); + +extern ddi_umem_cookie_t gfxp_umem_cookie_init(caddr_t kva, size_t size); +extern void gfxp_umem_cookie_destroy(ddi_umem_cookie_t cookie); +extern int gfxp_devmap_umem_setup(devmap_cookie_t dhc, dev_info_t *dip, + struct devmap_callback_ctl *callbackops, ddi_umem_cookie_t cookie, + offset_t off, size_t len, uint_t maxprot, uint_t flags, + ddi_device_acc_attr_t *accattrp); +extern void gfxp_map_devmem(devmap_cookie_t dhc, gfx_maddr_t maddr, + size_t length, ddi_device_acc_attr_t *attrp); + +extern gfxp_acc_handle_t gfxp_pci_init_handle(uint8_t bus, uint8_t slot, + uint8_t function, uint16_t *vendor, uint16_t *device); +extern uint8_t gfxp_pci_read_byte(gfxp_acc_handle_t handle, uint16_t offset); +extern uint16_t gfxp_pci_read_word(gfxp_acc_handle_t handle, uint16_t offset); +extern uint32_t gfxp_pci_read_dword(gfxp_acc_handle_t handle, uint16_t offset); +extern void gfxp_pci_write_byte(gfxp_acc_handle_t handle, uint16_t offset, + uint8_t value); +extern void gfxp_pci_write_word(gfxp_acc_handle_t handle, uint16_t offset, + uint16_t value); +extern void gfxp_pci_write_dword(gfxp_acc_handle_t handle, uint16_t offset, + uint32_t value); +extern int gfxp_pci_device_present(uint16_t vendor, uint16_t device); + +typedef char *gfxp_kva_t; +extern gfxp_kva_t gfxp_map_kernel_space(uint64_t start, size_t size, + uint32_t mode); +extern void gfxp_unmap_kernel_space(gfxp_kva_t address, size_t size); +extern int gfxp_va2pa(struct as *as, caddr_t addr, uint64_t *pa); +extern void gfxp_fix_mem_cache_attrs(caddr_t kva_start, size_t length, + int cache_attr); +extern gfx_maddr_t gfxp_convert_addr(paddr_t paddr); + +extern gfxp_fb_softc_ptr_t gfxp_fb_softc_alloc(void); +extern void gfxp_fb_softc_free(gfxp_fb_softc_ptr_t ptr); +extern int gfxp_fb_attach(dev_info_t *devi, ddi_attach_cmd_t cmd, + gfxp_fb_softc_ptr_t ptr); +extern int gfxp_fb_detach(dev_info_t *devi, ddi_detach_cmd_t cmd, + gfxp_fb_softc_ptr_t ptr); +extern int gfxp_fb_open(dev_t *devp, int flag, int otyp, cred_t *cred, + gfxp_fb_softc_ptr_t ptr); +extern int gfxp_fb_close(dev_t devp, int flag, int otyp, cred_t *cred, + gfxp_fb_softc_ptr_t ptr); +extern int gfxp_fb_ioctl(dev_t dev, int cmd, intptr_t data, int mode, + cred_t *cred, int *rval, gfxp_fb_softc_ptr_t ptr); + +extern int gfxp_mlock_user_memory(caddr_t address, size_t length); +extern int gfxp_munlock_user_memory(caddr_t address, size_t length); +extern int gfxp_fb_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, + size_t len, size_t *maplen, uint_t model, void *ptr); + +/* + * Used by drm_register_fbops(). + * Note: only setmode is supplied. + */ +struct gfxp_blt_ops { + int (*blt)(void *); + int (*copy) (void *); + int (*clear) (void *); + int (*setmode) (int); +}; + +extern void gfxp_bm_register_fbops(gfxp_fb_softc_ptr_t, + struct gfxp_blt_ops *); + +/* See: kernel/drm/src/drm_fb_helper.c */ + +struct gfxp_bm_fb_info { + uint16_t xres; + uint16_t yres; + uint8_t bpp; + uint8_t depth; +}; + +void gfxp_bm_getfb_info(gfxp_fb_softc_ptr_t, struct gfxp_bm_fb_info *); + +/* See: kernel/drm/src/drm_bufs.c etc */ + +caddr_t gfxp_alloc_kernel_space(size_t size); /* vmem_alloc heap_arena */ +void gfxp_free_kernel_space(caddr_t address, size_t size); + +void gfxp_load_kernel_space(uint64_t start, size_t size, + uint32_t mode, caddr_t cvaddr); +void gfxp_unload_kernel_space(caddr_t address, size_t size); + +/* + * Note that "mempool" is optional and normally disabled in drm_gem.c + * (see HAS_MEM_POOL). Let's just stub these out so we can reduce + * changes from the upstream in the DRM driver code. + */ +struct gfxp_pmem_cookie { + ulong_t a, b, c; +}; +void gfxp_mempool_init(void); +void gfxp_mempool_destroy(void); +int gfxp_alloc_from_mempool(struct gfxp_pmem_cookie *, caddr_t *, + pfn_t *, pgcnt_t, int); +void gfxp_free_mempool(struct gfxp_pmem_cookie *, caddr_t, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _GFX_PRIVATE_H */ diff --git a/illumos-x86_64/usr/include/sys/gld.h b/illumos-x86_64/usr/include/sys/gld.h new file mode 100644 index 00000000..59dced72 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/gld.h @@ -0,0 +1,375 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2022 Garrett D'Amore + */ + +/* + * gld - Generic LAN Driver support system for DLPI drivers. + */ + +#ifndef _SYS_GLD_H +#define _SYS_GLD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Media specific MIB-II counters/statistics + * + * This only includes those that aren't in the legacy counters. + */ + +typedef union media_stats { + struct dot3stat { + /* Ethernet: RFC1643 Dot3Stats (subset) */ + uint32_t first_coll; /* SingleCollisionFrames */ + uint32_t multi_coll; /* MultipleCollisionFrames */ + uint32_t sqe_error; /* SQETestErrors */ + uint32_t mac_xmt_error; /* InternalMacTransmitErrors */ + uint32_t frame_too_long; /* FrameTooLongs */ + uint32_t mac_rcv_error; /* InternalMacReceiveErrors */ + } dot3; + struct dot5stat { + /* Token Ring: RFC1748 Dot5Stats (subset) */ + uint32_t ace_error; + uint32_t internal_error; + uint32_t lost_frame_error; + uint32_t frame_copied_error; + uint32_t token_error; + uint32_t freq_error; + } dot5; + struct fddistat { + /* FDDI: RFC1512 (subset) */ + uint32_t mac_error; + uint32_t mac_lost; + uint32_t mac_token; + uint32_t mac_tvx_expired; + uint32_t mac_late; + uint32_t mac_ring_op; + } fddi; + uint32_t pad[16]; +} media_stats_t; + +#define glds_dot3_first_coll glds_media_specific.dot3.first_coll +#define glds_dot3_multi_coll glds_media_specific.dot3.multi_coll +#define glds_dot3_sqe_error glds_media_specific.dot3.sqe_error +#define glds_dot3_mac_xmt_error glds_media_specific.dot3.mac_xmt_error +#define glds_dot3_mac_rcv_error glds_media_specific.dot3.mac_rcv_error +#define glds_dot3_frame_too_long glds_media_specific.dot3.frame_too_long + +#define glds_dot5_line_error glds_crc +#define glds_dot5_burst_error glds_frame +#define glds_dot5_ace_error glds_media_specific.dot5.ace_error +#define glds_dot5_internal_error glds_media_specific.dot5.internal_error +#define glds_dot5_lost_frame_error glds_media_specific.dot5.lost_frame_error +#define glds_dot5_frame_copied_error glds_media_specific.dot5.frame_copied_error +#define glds_dot5_token_error glds_media_specific.dot5.token_error +#define glds_dot5_signal_loss glds_nocarrier +#define glds_dot5_freq_error glds_media_specific.dot5.freq_error + +#define glds_fddi_mac_error glds_media_specific.fddi.mac_error +#define glds_fddi_mac_lost glds_media_specific.fddi.mac_lost +#define glds_fddi_mac_token glds_media_specific.fddi.mac_token +#define glds_fddi_mac_tvx_expired glds_media_specific.fddi.mac_tvx_expired +#define glds_fddi_mac_late glds_media_specific.fddi.mac_late +#define glds_fddi_mac_ring_op glds_media_specific.fddi.mac_ring_op + +/* + * structure for driver statistics + */ +struct gld_stats { + ulong_t glds_multixmt; /* (G) ifOutMulticastPkts */ + ulong_t glds_multircv; /* (G) ifInMulticastPkts */ + ulong_t glds_brdcstxmt; /* (G) ifOutBroadcastPkts */ + ulong_t glds_brdcstrcv; /* (G) ifInBroadcastPkts */ + uint32_t glds_blocked; /* (G) discard: upstream flow cntrl */ + uint32_t glds_reserved1; + uint32_t glds_reserved2; + uint32_t glds_reserved3; + uint32_t glds_reserved4; + uint32_t glds_errxmt; /* (D) ifOutErrors */ + uint32_t glds_errrcv; /* (D) ifInErrors */ + uint32_t glds_collisions; /* (e) Sun MIB's rsIfCollisions */ + uint32_t glds_excoll; /* (e) dot3StatsExcessiveCollisions */ + uint32_t glds_defer; /* (e) dot3StatsDeferredTransmissions */ + uint32_t glds_frame; /* (e) dot3StatsAlignErrors */ + uint32_t glds_crc; /* (e) dot3StatsFCSErrors */ + uint32_t glds_overflow; /* (D) */ + uint32_t glds_underflow; /* (D) */ + uint32_t glds_short; /* (e) */ + uint32_t glds_missed; /* (D) */ + uint32_t glds_xmtlatecoll; /* (e) dot3StatsLateCollisions */ + uint32_t glds_nocarrier; /* (e) dot3StatsCarrierSenseErrors */ + uint32_t glds_noxmtbuf; /* (G) ifOutDiscards */ + uint32_t glds_norcvbuf; /* (D) ifInDiscards */ + uint32_t glds_intr; /* (D) */ + uint32_t glds_xmtretry; /* (G) */ + uint64_t glds_pktxmt64; /* (G) 64-bit rsIfOutPackets */ + uint64_t glds_pktrcv64; /* (G) 64-bit rsIfInPackets */ + uint64_t glds_bytexmt64; /* (G) ifHCOutOctets */ + uint64_t glds_bytercv64; /* (G) ifHCInOctets */ + uint64_t glds_speed; /* (D) ifSpeed */ + uint32_t glds_duplex; /* (e) Invented for GLD */ + uint32_t glds_media; /* (D) Invented for GLD */ + uint32_t glds_unknowns; /* (G) ifInUnknownProtos */ + uint32_t reserved[19]; + media_stats_t glds_media_specific; + uint32_t glds_xmtbadinterp; /* (G) bad packet len/format */ + uint32_t glds_rcvbadinterp; /* (G) bad packet len/format */ + uint32_t glds_gldnorcvbuf; /* (G) norcvbuf from inside GLD */ +}; + +/* + * gld_mac_info structure. Used to define the per-board data for all + * drivers. + * + * The below definition of gld_mac_info contains GLD PRIVATE entries that must + * not be used by the device driver. Only entries marked SET BY DRIVER should + * be modified. + */ + +#define GLD_STATS_SIZE_ORIG (sizeof (uint32_t) * 26) /* don't change */ +#define GLD_KSTAT_SIZE_ORIG (sizeof (kstat_named_t) * 26) /* don't change */ +#define GLD_PAD ((int)GLD_KSTAT_SIZE_ORIG + (int)GLD_STATS_SIZE_ORIG) + +typedef union gld_lock { + kmutex_t reserved; + krwlock_t gldl_rw_lock; +} gld_lock_t; + +typedef struct gld_mac_info { + struct gld_mac_info *gldm_next; /* GLD PRIVATE */ + struct gld_mac_info *gldm_prev; /* GLD PRIVATE */ + caddr_t reserved1; /* GLD PRIVATE */ + caddr_t reserved2; /* GLD PRIVATE */ + uint16_t gldm_driver_version; /* GLD PRIVATE */ + uint16_t gldm_GLD_version; /* GLD PRIVATE */ + uint16_t gldm_GLD_flags; /* GLD PRIVATE */ + uint16_t gldm_options; /* GLD_PRIVATE */ + dev_info_t *gldm_devinfo; /* SET BY DRIVER */ + uchar_t *gldm_vendor_addr; /* SET BY DRIVER */ + uchar_t *gldm_broadcast_addr; /* SET BY DRIVER */ + gld_lock_t gldm_lock; /* GLD PRIVATE */ + ddi_iblock_cookie_t gldm_cookie; /* SET BY DRIVER */ + uint32_t gldm_margin; /* SET BY DRIVER */ + uint32_t reserved4; /* GLD PRIVATE */ + uint32_t gldm_maxpkt; /* SET BY DRIVER */ + uint32_t gldm_minpkt; /* SET BY DRIVER */ + char *gldm_ident; /* SET BY DRIVER */ + uint32_t gldm_type; /* SET BY DRIVER */ + uint32_t reserved5; /* GLD PRIVATE */ + uint32_t gldm_addrlen; /* SET BY DRIVER */ + int32_t gldm_saplen; /* SET BY DRIVER */ + /* NOTE: MUST BE -2 */ + unsigned char reserved7[ETHERADDRL]; /* GLD PRIVATE */ + unsigned char reserved8[ETHERADDRL]; /* GLD PRIVATE */ + unsigned char reserved9[ETHERADDRL]; /* GLD PRIVATE */ + t_uscalar_t gldm_ppa; /* SET BY DRIVER */ + int32_t reserved10; /* GLD PRIVATE */ + uint32_t gldm_capabilities; /* SET BY DRIVER */ + int32_t gldm_linkstate; /* GLD PRIVATE */ + uint32_t reserved11; /* GLD PRIVATE */ + caddr_t reserved12; /* GLD PRIVATE */ + int32_t reserved13; /* GLD PRIVATE */ + uint32_t reserved14; /* GLD PRIVATE */ + int32_t reserved15; /* GLD PRIVATE */ + caddr_t gldm_mac_pvt; /* GLD PRIVATE */ + caddr_t reserved16; /* GLD PRIVATE */ + char reserved17[GLD_PAD]; /* GLD PRIVATE */ + caddr_t reserved18; /* GLD PRIVATE */ + caddr_t gldm_private; /* GLD PRIVATE */ + int (*gldm_reset)(); /* SET BY DRIVER */ + int (*gldm_start)(); /* SET BY DRIVER */ + int (*gldm_stop)(); /* SET BY DRIVER */ + int (*gldm_set_mac_addr)(); /* SET BY DRIVER */ + int (*gldm_send)(); /* SET BY DRIVER */ + int (*gldm_set_promiscuous)(); /* SET BY DRIVER */ + int (*gldm_get_stats)(); /* SET BY DRIVER */ + int (*gldm_ioctl)(); /* SET BY DRIVER */ + int (*gldm_set_multicast)(); /* SET BY DRIVER */ + uint_t (*gldm_intr)(); /* SET BY DRIVER */ + int (*gldm_mctl)(); /* SET BY DRIVER */ + int (*gldm_send_tagged)(); /* SET BY DRIVER */ +} gld_mac_info_t; + +/* flags for physical promiscuous state */ +#define GLD_MAC_PROMISC_NOOP -1 /* leave mode unchanged */ +#define GLD_MAC_PROMISC_NONE 0 /* promiscuous mode(s) OFF */ +#define GLD_MAC_PROMISC_PHYS 1 /* receive all packets */ +#define GLD_MAC_PROMISC_MULTI 2 /* receive all multicast packets */ + +#define GLD_MULTI_ENABLE 1 +#define GLD_MULTI_DISABLE 0 + +/* flags for gldm_capabilities */ +#define GLD_CAP_LINKSTATE 0x00000001 /* will call gld_linkstate() */ +#define GLD_CAP_CKSUM_IPHDR 0x00000008 /* IP checksum offload */ +#define GLD_CAP_CKSUM_PARTIAL 0x00000010 /* TCP/UDP partial */ +#define GLD_CAP_CKSUM_FULL_V4 0x00000020 /* TCP/UDP full for IPv4 */ +#define GLD_CAP_ZEROCOPY 0x00000040 /* zerocopy */ +#define GLD_CAP_CKSUM_FULL_V6 0x00000080 /* TCP/UDP full for IPv6 */ +#define GLD_CAP_CKSUM_ANY \ + (GLD_CAP_CKSUM_IPHDR|GLD_CAP_CKSUM_PARTIAL| \ + GLD_CAP_CKSUM_FULL_V4|GLD_CAP_CKSUM_FULL_V6) + +/* values of gldm_linkstate, as passed to gld_linkstate() */ +#define GLD_LINKSTATE_DOWN -1 +#define GLD_LINKSTATE_UNKNOWN 0 +#define GLD_LINKSTATE_UP 1 + +/* + * media type: this identifies the media/connector currently used by the + * driver. Possible types will be defined for each DLPI type defined in + * gldm_type. The below definitions should be used by the device dependent + * drivers to set glds_media. + */ + +/* if driver cannot determine media/connector type */ +#define GLDM_UNKNOWN 0 + +#define GLDM_AUI 1 +#define GLDM_BNC 2 +#define GLDM_TP 3 +#define GLDM_FIBER 4 +#define GLDM_100BT 5 +#define GLDM_VGANYLAN 6 +#define GLDM_10BT 7 +#define GLDM_RING4 8 +#define GLDM_RING16 9 +#define GLDM_PHYMII 10 +#define GLDM_100BTX 11 +#define GLDM_100BT4 12 +#define GLDM_IB 14 + +/* defines for possible duplex states (glds_duplex) */ +#define GLD_DUPLEX_UNKNOWN 0 +#define GLD_DUPLEX_HALF 1 +#define GLD_DUPLEX_FULL 2 + +/* Values returned from driver entry points */ +#define GLD_SUCCESS 0 +#define GLD_NORESOURCES 1 +#define GLD_NOTSUPPORTED 2 +#define GLD_BADARG 3 +#define GLD_NOLINK 4 +#define GLD_RETRY 5 +#define GLD_FAILURE (-1) + +#if defined(_KERNEL) +/* Functions exported to drivers */ +extern gld_mac_info_t *gld_mac_alloc(dev_info_t *); +extern void gld_mac_free(gld_mac_info_t *); +extern int gld_register(dev_info_t *, char *, gld_mac_info_t *); +extern int gld_unregister(gld_mac_info_t *); +extern void gld_recv(gld_mac_info_t *, mblk_t *); +extern void gld_recv_tagged(gld_mac_info_t *, mblk_t *, uint32_t); +extern void gld_linkstate(gld_mac_info_t *, int32_t); +extern void gld_sched(gld_mac_info_t *); +extern uint_t gld_intr(); + +extern int gld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); +extern int gld_open(queue_t *, dev_t *, int, int, cred_t *); +extern int gld_close(queue_t *, int, cred_t *); +extern int gld_wput(queue_t *, mblk_t *); +extern int gld_wsrv(queue_t *); +extern int gld_rsrv(queue_t *); +#endif + +/* + * VLAN tag macros + * + * Per IEEE802.1Q, a VLAN tag is made up of a 2-byte Tagged Protocol + * Identifier (TPID) and two bytes of Tag/Control information (TCI). + * All fields should be treated as unsigned, and so a VTAG is held as + * a 'uint32_t' + */ +#define VTAG_SIZE 4 /* bytes (octets) */ + +#define VLAN_TPID_MASK 0xffff0000u +#define VLAN_TPID_SHIFT 16 +#define VLAN_TCI_MASK 0x0000ffffu +#define VLAN_TCI_SHIFT 0 + +#define VLAN_PRI_MASK 0x0000e000u +#define VLAN_PRI_SHIFT 13 +#define VLAN_CFI_MASK 0x00001000u +#define VLAN_CFI_SHIFT 12 +#define VLAN_VID_MASK 0x00000fffu +#define VLAN_VID_SHIFT 0 + +#define VLAN_TPID 0x8100u /* Per IEEE 802.1Q standard */ +#define VLAN_CFI_ETHER 0 /* CFI on Ethernet must be 0 */ +#define VLAN_PRI_DFLT 0 +#define VLAN_PRI_MAX 7 +#define VLAN_VID_NONE 0 /* Not a valid VID */ +#define VLAN_VID_MIN 1 +#define VLAN_VID_MAX 4094 /* IEEE std; 4095 is reserved */ + +#define VLAN_VTAG_NONE 0 /* Special case: "untagged" */ + +/* + * Macros to construct a TCI or VTAG. The user must ensure values are in + * range. Note that in the special case of priority tag, VLAN_VID_NONE + * is also a valid argument to these constructor macros. + */ +#define GLD_MAKE_TCI(pri, cfi, vid) (((pri) << VLAN_PRI_SHIFT) | \ + ((cfi) << VLAN_CFI_SHIFT) | \ + ((vid) << VLAN_VID_SHIFT)) + +#define GLD_MAKE_VTAG(pri, cfi, vid) \ + (((uint32_t)ETHERTYPE_VLAN << VLAN_TPID_SHIFT) | \ + ((pri) << VLAN_PRI_SHIFT) | \ + ((cfi) << VLAN_CFI_SHIFT) | \ + ((vid) << VLAN_VID_SHIFT)) + +#define GLD_TCI2VTAG(tci) \ + (((uint32_t)ETHERTYPE_VLAN << VLAN_TPID_SHIFT) | (tci)) + +/* + * Macros to construct a prototype TCI/VTAG and then convert it to a real one + */ +#define GLD_MK_PTCI(cfi, vid) GLD_MAKE_TCI(VLAN_PRI_MAX, cfi, vid) +#define GLD_MK_PTAG(cfi, vid) GLD_MAKE_VTAG(VLAN_PRI_MAX, cfi, vid) +#define GLD_MK_PMSK(pri) (((pri) << VLAN_PRI_SHIFT) | ~VLAN_PRI_MASK) +#define GLD_MK_VTAG(ptag, pri) ((ptag) & GLD_MK_PMSK(pri)) + +/* + * Deconstruct a VTAG ... + */ +#define GLD_VTAG_TPID(vtag) (((vtag) & VLAN_TPID_MASK) >> VLAN_TPID_SHIFT) +#define GLD_VTAG_TCI(vtag) (((vtag) & VLAN_TCI_MASK) >> VLAN_TCI_SHIFT) + +#define GLD_VTAG_PRI(vtag) (((vtag) & VLAN_PRI_MASK) >> VLAN_PRI_SHIFT) +#define GLD_VTAG_CFI(vtag) (((vtag) & VLAN_CFI_MASK) >> VLAN_CFI_SHIFT) +#define GLD_VTAG_VID(vtag) (((vtag) & VLAN_VID_MASK) >> VLAN_VID_SHIFT) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_GLD_H */ diff --git a/illumos-x86_64/usr/include/sys/gldpriv.h b/illumos-x86_64/usr/include/sys/gldpriv.h new file mode 100644 index 00000000..263bdd88 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/gldpriv.h @@ -0,0 +1,645 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2022 Garrett D'Amore + */ + +/* + * gldpriv.h - Private interfaces/structures needed by gld.c + * + * The definitions in this file are private to GLD and may change at any time. + * They must not be used by any driver. + */ + +#ifndef _SYS_GLDPRIV_H +#define _SYS_GLDPRIV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef DEBUG +#define GLD_DEBUG 1 +#endif + +/* + * The version number should not be changed. + */ +#define GLD_VERSION_200 0x200 /* version 2.0 */ +#define GLD_VERSION GLD_VERSION_200 /* current version */ +#define GLD_VERSION_STRING "v2" /* in modinfo string */ + +/* gld_global_options bits */ +#define GLD_OPT_NO_IPQ 0x00000001 /* don't use IP shortcut */ +#define GLD_OPT_NO_FASTPATH 0x00000002 /* don't implement fastpath */ +#define GLD_OPT_NO_ETHRXSNAP 0x00000008 /* don't interp SNAP on ether */ + +/* gld per instance options */ +#define GLDOPT_FAST_RECV 0x40 +#define GLDOPT_CANONICAL_ADDR 0x08 + +/* + * This version of GLD allows a "Virtual-LAN-PPA" to be specified in + * the same manner as Cassini: the virtual PPA number is composed of + * the VLAN tag number (1-4094), multiplied by 1000(!), plus the real + * (hardware) PPA. Thus "bge23001" refers to the "device" which + * transports packets with tag VLAN "23" over the hardware of "bge1". + * + * This scheme limits the number of physical devices of a single type to + * 1000 e.g. bge0 .. bge999 (since bge1000 would instead be interpreted + * as VLAN1 over bge0). + */ +#define GLD_VLAN_SCALE 1000 +#define GLD_MAX_PPA (GLD_VLAN_SCALE-1) + +/* + * Minor numbers: + * + * For each device type, GLD creates a single "style 2" node with minor 0. + * For each instance of that device type, GLD also creates a "style 1" + * node with minor number one greater than the PPA. Thus, nodes with + * minor numbers 0..1000 may exist in the /dev* filesystem. + * + * So, on open: + * + * Minor 0 implies DLPI "style 2": the STREAM is not intrinsically + * associated with any particular device/PPA. The association is set + * (and may be changed) dynamically, by DLPI_ATTACH/DETACH messages. + * + * Minors 1..1000 are "style 1", where the PPA is entirely defined by + * the minor; GLD defines the mapping as PPA=minor-1 (minor=PPA+1). + * Note that the upper bound of 1000 is (now) limited by the VLAN + * mapping scheme set out above. + * + * GLD devices are "self-cloning": each new open will cause a new minor + * number to be allocated; these are selected from the range 1001..0x3ffff. + * This minor number is only associated with the open stream and doesn't + * appear in the /dev* filesystem; manually created nodes with minors in + * this range will be rejected by gld_open(). + */ +#define GLD_USE_STYLE2 0 + +#define GLD_MIN_STYLE1_MINOR 1 +#define GLD_MAX_STYLE1_MINOR (GLD_MAX_PPA+1) + +#define GLD_STYLE1_MINOR_TO_PPA(minor) (minor - 1) +#define GLD_STYLE1_PPA_TO_MINOR(ppa) (ppa + 1) + +#define GLD_MIN_CLONE_MINOR (GLD_MAX_STYLE1_MINOR+1) +#define GLD_MAX_CLONE_MINOR 0x3ffff + +/* gldm_GLD_flags */ +#define GLD_MAC_READY 0x0001 /* this mac has succeeded gld_register */ +#define GLD_INTR_READY 0x0001 /* v0 compat name */ +#define GLD_INTR_WAIT 0x0002 /* v1: waiting for interrupt to do scheduling */ +#define GLD_LOCK_INITED 0x0004 /* maclock is currently initialized */ +#define GLD_UNREGISTERED 0x0008 /* this mac has succeeded gld_unregister */ + +/* This is the largest macaddr currently supported by GLD */ +#define GLD_MAX_ADDRLEN 32 /* Largest mac addr in all media */ + +#define GLD_MAX_MULTICAST 64 /* default multicast table size */ + +/* multicast structures */ +typedef struct gld_multicast_addr { + int gldm_refcnt; /* number of streams referring */ + /* to this per-mac entry */ + unsigned char gldm_addr[GLD_MAX_ADDRLEN]; +} gld_mcast_t; + +/* gld_flag bits -- GLD PRIVATE */ +#define GLD_RAW 0x0001 /* lower stream is in RAW mode */ +#define GLD_FAST 0x0002 /* use "fast" path */ +#define GLD_PROM_PHYS 0x0004 /* stream is in physical promiscuous mode */ +#define GLD_PROM_SAP 0x0008 +#define GLD_PROM_MULT 0x0010 +#define GLD_STR_CLOSING 0x0020 /* stream is closing; don't putnext */ + +/* + * gld structure. Used to define the per-stream information required to + * implement DLPI. + */ +typedef struct gld { + struct gld *gld_next, *gld_prev; + caddr_t gld_dummy1; + int32_t gld_state; /* DL_UNATTACHED, DL_UNBOUND, DL_IDLE */ + int32_t gld_style; /* open style 1 or style 2 */ + int32_t gld_minor; /* cloned minor number */ + int32_t gld_type; /* DL_ETHER, DL_TPR, DL_FDDI, etc */ + int32_t gld_sap; /* Bound SAP */ + int32_t gld_flags; /* flags defined in gldpriv.h */ + int32_t gld_multicnt; /* # of stream multicast addresses */ + gld_mcast_t **gld_mcast; /* multicast table or NULL */ + queue_t *gld_qptr; /* pointer to streams queue */ + caddr_t gld_dummy2; + caddr_t gld_dummy3; + struct gld_mac_info *gld_mac_info; /* if not DL_UNATTACHED */ + caddr_t gld_dummy4; + struct glddevice *gld_device; /* per-major structure */ + + volatile boolean_t gld_xwait; /* want an xmit qenable */ + volatile boolean_t gld_sched_ran; /* gld_sched examined this Q */ + volatile boolean_t gld_in_unbind; /* DL_UNBIND in progress */ + volatile uint32_t gld_wput_count; /* number of threads in wput=>start */ + volatile boolean_t gld_in_wsrv; /* Q thread currently running in wsrv */ + + boolean_t gld_ethertype; /* ethertype/LLC stream */ + uint32_t gld_notifications; + uint32_t gld_upri; /* user priority */ + void *gld_vlan; + int (*gld_send)(); +} gld_t; + +/* + * definitions for the per driver class structure + */ +typedef struct glddevice { + struct glddevice *gld_next, *gld_prev; + int gld_ndevice; /* number of mac devices linked */ + gld_mac_info_t *gld_mac_next, *gld_mac_prev; /* the various macs */ + gld_t *gld_str_next, *gld_str_prev; /* open, unattached, */ + /* style 2 streams */ + char gld_name[16]; /* name of device */ + kmutex_t gld_devlock; /* used to serialize read/write locks */ + int gld_nextminor; /* next unused minor number for clone */ + int gld_major; /* device's major number */ + int gld_multisize; /* # of multicast entries to alloc */ + int gld_type; /* for use before attach */ + int gld_minsdu; + int gld_maxsdu; + int gld_addrlen; /* physical address length */ + int gld_saplen; /* sap length, neg appends */ + unsigned char *gld_broadcast; /* pointer to broadcast address */ + int gld_styles; /* provider styles */ +} glddev_t; + +typedef struct pktinfo { + uint_t isBroadcast:1; + uint_t isMulticast:1; + uint_t isLooped:1; + uint_t isForMe:1; + uint_t isLLC:1; + uint_t user_pri:3; + uint_t cfi:1; + uint_t vid:12; + uint_t wasAccepted:1; + uint_t nosource:1; + uint_t isTagged:1; + uint_t macLen; + uint_t hdrLen; + uint_t pktLen; + uchar_t dhost[GLD_MAX_ADDRLEN]; + uchar_t shost[GLD_MAX_ADDRLEN]; + uint_t ethertype; +} pktinfo_t; + +/* + * Flags input to the gld_interpret_*() interpreter routines. + */ +typedef enum packet_flag { + GLD_RXQUICK, + GLD_RXLOOP, + GLD_RX, + GLD_TX +} packet_flag_t; + +/* + * Describes characteristics of the Media Access Layer. + * The mac_type is one of the supported DLPI media types (see ). + * The mtu_size is the size of the largest frame. + * The interpreter is the function that "knows" how to interpret the frame. + * Other routines create and/or add headers to packets. + */ +typedef struct { + uint_t mac_type; + uint_t mtu_size; + int hdr_size; + int (*interpreter)(gld_mac_info_t *, mblk_t *, pktinfo_t *, + packet_flag_t); + mblk_t *(*mkfastpath)(gld_t *, mblk_t *); + mblk_t *(*mkunitdata)(gld_t *, mblk_t *); + void (*init)(gld_mac_info_t *); + void (*uninit)(gld_mac_info_t *); + char *mac_string; +} gld_interface_t; + +/* + * structure for names stat structure usage as required by "netstat" + */ +typedef union media_kstats { + struct dot3kstat { + kstat_named_t first_coll; + kstat_named_t multi_coll; + kstat_named_t sqe_error; + kstat_named_t mac_xmt_error; + kstat_named_t frame_too_long; + kstat_named_t mac_rcv_error; + } dot3; + struct dot5kstat { + kstat_named_t ace_error; + kstat_named_t internal_error; + kstat_named_t lost_frame_error; + kstat_named_t frame_copied_error; + kstat_named_t token_error; + kstat_named_t freq_error; + } dot5; + struct fddikstat { + kstat_named_t mac_error; + kstat_named_t mac_lost; + kstat_named_t mac_token; + kstat_named_t mac_tvx_expired; + kstat_named_t mac_late; + kstat_named_t mac_ring_op; + } fddi; +} media_kstats_t; + +struct gldkstats { + kstat_named_t glds_pktxmt; + kstat_named_t glds_pktrcv; + kstat_named_t glds_errxmt; + kstat_named_t glds_errrcv; + kstat_named_t glds_collisions; + kstat_named_t glds_bytexmt; + kstat_named_t glds_bytercv; + kstat_named_t glds_multixmt; + kstat_named_t glds_multircv; /* multicast but not broadcast */ + kstat_named_t glds_brdcstxmt; + kstat_named_t glds_brdcstrcv; + kstat_named_t glds_unknowns; + kstat_named_t glds_blocked; /* discard due to upstream flow */ + /* control */ + kstat_named_t glds_excoll; + kstat_named_t glds_defer; + kstat_named_t glds_frame; + kstat_named_t glds_crc; + kstat_named_t glds_overflow; + kstat_named_t glds_underflow; + kstat_named_t glds_short; + kstat_named_t glds_missed; + kstat_named_t glds_xmtlatecoll; + kstat_named_t glds_nocarrier; + kstat_named_t glds_noxmtbuf; + kstat_named_t glds_norcvbuf; + kstat_named_t glds_xmtbadinterp; + kstat_named_t glds_rcvbadinterp; + kstat_named_t glds_intr; + kstat_named_t glds_xmtretry; + kstat_named_t glds_pktxmt64; + kstat_named_t glds_pktrcv64; + kstat_named_t glds_bytexmt64; + kstat_named_t glds_bytercv64; + kstat_named_t glds_speed; + kstat_named_t glds_duplex; + kstat_named_t glds_media; + kstat_named_t glds_prom; + media_kstats_t glds_media_specific; +}; + +typedef struct gld_mac_pvt gld_mac_pvt_t; + +typedef struct gld_vlan { + struct gld_vlan *gldv_next, *gldv_prev; + uint32_t gldv_id; + uint32_t gldv_ptag; + int gldv_nstreams; + gld_mac_info_t *gldv_mac; + queue_t *gldv_ipq; + queue_t *gldv_ipv6q; + struct gld *gldv_str_next; /* list of attached streams */ + struct gld *gldv_str_prev; + kstat_t *gldv_kstatp; + struct gld_stats *gldv_stats; + /* The number of streams that are in promiscous mode */ + uint_t gldv_nprom; + /* The number of streams that are interested in VLAN tagged packets. */ + uint_t gldv_nvlan_sap; +} gld_vlan_t; + +#define VLAN_HASHSZ 23 + +/* Per-mac info used by GLD */ +struct gld_mac_pvt { + gld_interface_t *interfacep; + kmutex_t datalock; /* data lock for "data" */ + caddr_t data; /* media specific private data */ + gld_vlan_t *vlan_hash[VLAN_HASHSZ]; + struct gld *last_sched; /* last scheduled stream */ + struct glddevice *major_dev; /* per-major device struct */ + int nvlan; /* VLANs in use on this mac */ + int nprom; /* num streams in promiscuous mode */ + int nprom_multi; /* streams in promiscuous multicast */ + gld_mcast_t *mcast_table; /* per device multicast table */ + unsigned char *curr_macaddr; /* Currently programmed mac address */ + kstat_t *kstatp; + struct gld_stats *statistics; /* The ones the driver updates */ + int rde_enabled; /* RDE (Source Routing) Enabled */ + int rde_str_indicator_ste; /* use STE when no SR info */ + int rde_timeout; /* route link inactivity timeout */ + uint32_t notifications; /* DL_NOTE options supported */ + boolean_t started; /* Has the MAC been started? */ +}; + +/* return values from gld_cmds */ +#define GLDE_OK (-1) /* internal procedure status is OK */ +#define GLDE_RETRY 0x1002 /* want to retry later */ + +/* caller argument to gld_start */ +#define GLD_WPUT 0 +#define GLD_WSRV 1 + +#define GLD_MAX_802_SAP 0xff + +/* + * definitions for debug tracing + */ +#define GLDTRACE 0x0001 /* basic procedure level tracing */ +#define GLDERRS 0x0002 /* trace errors */ +#define GLDRECV 0x0004 /* trace receive path */ +#define GLDSEND 0x0008 /* trace send path */ +#define GLDPROT 0x0010 /* trace DLPI protocol */ +#define GLDNOBR 0x0020 /* do not show broadcast messages */ +#define GLDETRACE 0x0040 /* trace "normal case" errors */ +#define GLDRDE 0x0080 /* netstat -k dump routing table */ + +/* + * Lock manipulation macros for GLDM_LOCK. Conceptually, the + * GLD layer treats the lock as a rw lock; for v0 binary and + * semantic compatibility, the underlying implementation still + * uses a mutex, whereas for v2 drivers, the more scalable rwlock + * is used instead. See notes in gld.h. + */ +#define GLDM_LOCK_INIT(macinfo) \ + rw_init(&(macinfo)->gldm_lock.gldl_rw_lock, NULL, \ + RW_DRIVER, (macinfo)->gldm_cookie); \ + (macinfo)->gldm_GLD_flags |= GLD_LOCK_INITED + +#define GLDM_LOCK_INITED(macinfo) \ + ((macinfo)->gldm_GLD_flags & GLD_LOCK_INITED) + +#define GLDM_LOCK_DESTROY(macinfo) \ + if ((macinfo)->gldm_GLD_flags & GLD_LOCK_INITED) { \ + rw_destroy(&(macinfo)->gldm_lock.gldl_rw_lock); \ + (macinfo)->gldm_GLD_flags &= ~GLD_LOCK_INITED; \ + } + +#define GLDM_LOCK(macinfo, rw) \ + rw_enter(&(macinfo)->gldm_lock.gldl_rw_lock, (rw)) + +#define GLDM_UNLOCK(macinfo) \ + rw_exit(&(macinfo)->gldm_lock.gldl_rw_lock) + +#define GLDM_TRYLOCK(macinfo, rw) \ + rw_tryenter(&(macinfo)->gldm_lock.gldl_rw_lock, (rw)) + +/* lock held in read or write mode? */ +#define GLDM_LOCK_HELD(macinfo) \ + rw_lock_held(&(macinfo)->gldm_lock.gldl_rw_lock) + +/* lock held in write mode? */ +#define GLDM_LOCK_HELD_WRITE(macinfo) \ + rw_write_held(&(macinfo)->gldm_lock.gldl_rw_lock) + +/* + * Compare/copy two MAC addresses. + * Note that unlike bcmp, we return zero if they are different. + */ +#define mac_eq(a, b, l) (bcmp((caddr_t)(a), (caddr_t)(b), (l)) == 0) +#define mac_copy(a, b, l) (bcopy((caddr_t)(a), (caddr_t)(b), (l))) +/* copy a mac address to/from canonical form */ +#define cmac_copy(a, b, l, macinfo) { \ + if ((macinfo)->gldm_options & GLDOPT_CANONICAL_ADDR) \ + gld_bitrevcopy((caddr_t)(a), (caddr_t)(b), (l)); \ + else \ + mac_copy((a), (b), (l)); \ + } + +/* + * Macros to access possibly-unaligned variables + */ + +#if (_ALIGNMENT_REQUIRED == 0) + +#define REF_HOST_USHORT(lvalue) (lvalue) +#define REF_NET_USHORT(lvalue) (ntohs(lvalue)) +#define SET_NET_USHORT(lvalue, val) ((lvalue) = htons(val)) + +#else /* ALIGNMENT_REQUIRED */ + +#define REF_NET_USHORT(lvalue) \ + ((ushort_t)((((uchar_t *)(&(lvalue)))[0]<<8) | \ + ((uchar_t *)(&(lvalue)))[1])) + +#define SET_NET_USHORT(lvalue, val) { \ + ((uchar_t *)(&(lvalue)))[0] = (uchar_t)((val)>>8); \ + ((uchar_t *)(&(lvalue)))[1] = (uchar_t)(val); \ +} + +#if defined(_LITTLE_ENDIAN) + +#define REF_HOST_USHORT(lvalue) \ + ((ushort_t)((((uchar_t *)(&(lvalue)))[1]<<8) | \ + ((uchar_t *)(&(lvalue)))[0])) + +#elif defined(_BIG_ENDIAN) + +#define REF_HOST_USHORT(lvalue) \ + ((ushort_t)((((uchar_t *)(&(lvalue)))[0]<<8) | \ + ((uchar_t *)(&(lvalue)))[1])) + +#else /* unknown endian */ +#error "what endian is this machine?" +#endif /* endian */ + +#endif /* ALIGNMENT_REQUIRED */ + +/* ================================================================ */ +/* Route Determination Entity definitions (IEEE 802.2 1994 edition) */ +/* ================================================================ */ + +struct rde_pdu { + uchar_t rde_ver; + uchar_t rde_ptype; + uchar_t rde_target_mac[6]; + uchar_t rde_orig_mac[6]; + uchar_t rde_target_sap; + uchar_t rde_orig_sap; +}; + +#define LSAP_RDE 0xa6 /* IEEE 802.2 section 3.3.1.2 */ +#define RDE_RQC 0x01 /* Route Query Command */ +#define RDE_RQR 0x02 /* Route Query Response */ +#define RDE_RS 0x03 /* Route Selected */ + +/* ============================================================= */ +/* Source Routing fields and definitions (IEEE 802.2 and 802.1D) */ +/* ============================================================= */ + +#define MAX_RDFLDS 14 /* changed to 14 from 8 as per IEEE */ + +/* + * Source Routing Route Information field. + */ +struct gld_ri { +#if defined(_BIT_FIELDS_LTOH) + uchar_t len:5; /* length */ + uchar_t rt:3; /* routing type */ + uchar_t res:4; /* reserved */ + uchar_t mtu:3; /* largest frame */ + uchar_t dir:1; /* direction bit */ + struct tr_rd { /* route designator fields */ + ushort_t bridge:4; /* Note: assumes network order... */ + ushort_t ring:12; /* ...(Big Endian) -- needs ntohs() */ + } rd[MAX_RDFLDS]; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t rt:3; /* routing type */ + uchar_t len:5; /* length */ + uchar_t dir:1; /* direction bit */ + uchar_t mtu:3; /* largest frame */ + uchar_t res:4; /* reserved */ + struct tr_rd { /* route designator fields */ + ushort_t ring:12; + ushort_t bridge:4; + } rd[MAX_RDFLDS]; +#else +#error "which way do bit fields get allocated?" +#endif +}; + +#define RT_SRF 0x0 /* 0xx: specifically routed frame */ +#define RT_ARE 0x4 /* 10x: all routes explorer frame */ +#define RT_STE 0x6 /* 11x: spanning tree explorer frame */ + +#define RT_MTU_MAX 0x7 /* Max MTU field (base only) */ + +/* + * Source route table info + */ +struct srtab { + struct srtab *sr_next; /* next in linked list */ + uchar_t sr_mac[6]; /* MAC address */ + struct gld_ri sr_ri; /* routing information */ + clock_t sr_timer; +}; + +#define SR_HASH_SIZE 256 /* Number of bins */ + +/* ================================================================= */ +/* Media dependent defines for media dependent routines in gldutil.c */ +/* ================================================================= */ + +/* + * Some "semi-generic" defines used by ether, token, and fddi, + * and probably anything else with addrlen == 6 && saplen == -2. + */ + +struct gld_dlsap { + unsigned char glda_addr[ETHERADDRL]; + unsigned short glda_sap; +}; + +#define DLSAP(p, offset) ((struct gld_dlsap *)((caddr_t)(p)+offset)) + +typedef uchar_t mac_addr_t[ETHERADDRL]; + +struct llc_snap_hdr { + uchar_t d_lsap; /* destination service access point */ + uchar_t s_lsap; /* source link service access point */ + uchar_t control; /* short control field */ + uchar_t org[3]; /* Ethernet style organization field */ + ushort_t type; /* Ethernet style type field */ +}; + +#define LLC_HDR1_LEN 3 /* Length of the LLC1 header */ +#define LLC_SNAP_HDR_LEN 8 /* Full length of SNAP header */ +#define LSAP_SNAP 0xaa /* SAP for SubNet Access Protocol */ +#define CNTL_LLC_UI 0x03 /* un-numbered information packet */ + +/* ======================== */ +/* FDDI related definitions */ +/* ======================== */ + +struct fddi_mac_frm { + uchar_t fddi_fc; + mac_addr_t fddi_dhost; + mac_addr_t fddi_shost; +}; + +/* ============================== */ +/* Token Ring related definitions */ +/* ============================== */ + +struct tr_mac_frm_nori { + uchar_t tr_ac; + uchar_t tr_fc; + mac_addr_t tr_dhost; + mac_addr_t tr_shost; +}; + +struct tr_mac_frm { + uchar_t tr_ac; + uchar_t tr_fc; + mac_addr_t tr_dhost; + mac_addr_t tr_shost; + struct gld_ri tr_ri; /* Routing Information Field */ +}; + +/* + * Note that the pad field is used to save the value of tci. + */ +#define GLD_SAVE_MBLK_VTAG(mp, vtag) (DB_TCI(mp) = GLD_VTAG_TCI(vtag)) +#define GLD_CLEAR_MBLK_VTAG(mp) GLD_SAVE_MBLK_VTAG(mp, 0) +#define GLD_GET_MBLK_VTAG(mp) GLD_TCI2VTAG(DB_TCI(mp)) + +int gld_interpret_ether(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); +int gld_interpret_fddi(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); +int gld_interpret_tr(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); +int gld_interpret_ib(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); + +mblk_t *gld_fastpath_ether(gld_t *, mblk_t *); +mblk_t *gld_fastpath_fddi(gld_t *, mblk_t *); +mblk_t *gld_fastpath_tr(gld_t *, mblk_t *); +mblk_t *gld_fastpath_ib(gld_t *, mblk_t *); + +mblk_t *gld_insert_vtag_ether(mblk_t *, uint32_t); + +mblk_t *gld_unitdata_ether(gld_t *, mblk_t *); +mblk_t *gld_unitdata_fddi(gld_t *, mblk_t *); +mblk_t *gld_unitdata_tr(gld_t *, mblk_t *); +mblk_t *gld_unitdata_ib(gld_t *, mblk_t *); + +void gld_init_ether(gld_mac_info_t *); +void gld_init_fddi(gld_mac_info_t *); +void gld_init_tr(gld_mac_info_t *); +void gld_init_ib(gld_mac_info_t *); + +void gld_uninit_ether(gld_mac_info_t *); +void gld_uninit_fddi(gld_mac_info_t *); +void gld_uninit_tr(gld_mac_info_t *); +void gld_uninit_ib(gld_mac_info_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_GLDPRIV_H */ diff --git a/illumos-x86_64/usr/include/sys/group.h b/illumos-x86_64/usr/include/sys/group.h new file mode 100644 index 00000000..2db1ac01 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/group.h @@ -0,0 +1,121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _GROUP_H +#define _GROUP_H + +/* + * Group Abstraction + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined(_KERNEL) || defined(_KMEMUSER)) +#include + +#define GRP_RESIZE 0x1 /* Resize group capacity if needed */ +#define GRP_NORESIZE 0x2 /* Do not resize group capacity; may fail */ + +/* + * group structure + */ +typedef struct group { + uint_t grp_size; /* # of elements */ + uint_t grp_capacity; /* current group capacity */ + void **grp_set; /* element vector */ +} group_t; + +typedef uint_t group_iter_t; + + +/* + * Return the number of elements in the group + */ +#define GROUP_SIZE(grp) ((grp)->grp_size) + +/* + * Access the element at the specified group index + */ +#define GROUP_ACCESS(grp, index) ((grp)->grp_set[index]) + +/* + * Group creation / destruction + */ +void group_create(group_t *); +void group_destroy(group_t *); + +/* + * Expand a group's holding capacity + */ +void group_expand(group_t *, uint_t); + +/* + * Group element iteration + */ +void group_iter_init(group_iter_t *); +void *group_iterate(group_t *, group_iter_t *); + +/* + * Add / remove an element (or elements) from the group + */ +int group_add(group_t *, void *, int); +int group_remove(group_t *, void *, int); +void group_empty(group_t *); + +/* + * Add / remove / access an element at a specified index. + * The group must already have sufficient capacity to hold + * an element at the specified index. + */ +int group_add_at(group_t *, void *, uint_t); +void group_remove_at(group_t *, uint_t); + +/* + * Search for an element in a group. + * Returns an index that may be used with the *_at() + * routines above to add or remove the element. + */ +uint_t group_find(group_t *, void *); + +/* + * Convert a group to a string with list of integers. + * + * The consecutive integer values are represented using x-y notation. + * The resulting string looks like "1,2-5,8" + * + * The convert argument is used to map group elements to integer IDs. + * The output buffer and its length are specfied in the arguments. + */ +extern char *group2intlist(group_t *, char *, size_t, int (convert)(void*)); + +#endif /* !_KERNEL && !_KMEMUSER */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GROUP_H */ diff --git a/illumos-x86_64/usr/include/sys/hdio.h b/illumos-x86_64/usr/include/sys/hdio.h new file mode 100644 index 00000000..56d82ce9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hdio.h @@ -0,0 +1,141 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_HDIO_H +#define _SYS_HDIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Used for generic commands + */ +struct hdk_cmd { + ushort_t hdkc_cmd; /* command to be executed */ + int hdkc_flags; /* execution flags */ + daddr_t hdkc_blkno; /* disk address for command */ + int hdkc_secnt; /* sector count for command */ + caddr_t hdkc_bufaddr; /* user's buffer address */ + uint_t hdkc_buflen; /* size of user's buffer */ +}; + +/* + * Used for drive info + */ +struct hdk_type { + ushort_t hdkt_hsect; /* hard sector count (read only) */ + ushort_t hdkt_promrev; /* prom revision (read only) */ + uchar_t hdkt_drtype; /* drive type (ctlr specific) */ + uchar_t hdkt_drstat; /* drive status (ctlr specific, ro) */ +}; + +/* + * Used for bad sector map + */ +struct hdk_badmap { + caddr_t hdkb_bufaddr; /* address of user's map buffer */ +}; + +/* + * Execution flags. + */ +#define HDK_SILENT 0x01 /* no error messages */ +#define HDK_DIAGNOSE 0x02 /* fail if any error occurs */ +#define HDK_ISOLATE 0x04 /* isolate from normal commands */ +#define HDK_READ 0x08 /* read from device */ +#define HDK_WRITE 0x10 /* write to device */ +#define HDK_KBUF 0x20 /* write to device */ + +/* + * Used for disk diagnostics + */ +struct hdk_diag { + ushort_t hdkd_errcmd; /* most recent command in error */ + daddr_t hdkd_errsect; /* most recent sector in error */ + uchar_t hdkd_errno; /* most recent error number */ + uchar_t hdkd_severe; /* severity of most recent error */ +}; + +/* + * Used for getting disk error log. + */ +struct hdk_loghdr { + long hdkl_entries; /* number of dk_log entries */ + long hdkl_max_size; /* max. size of dk_log table */ + caddr_t hdkl_logbfr; /* pointer to dk_log table */ +}; + +/* + * Disk error log table entry. + */ +struct hdk_log { + daddr_t hdkl_block; /* location of block in error */ + ulong_t hdkl_count; /* number of failures */ + short hdkl_type; /* type of error (e.g. soft error) */ + short hdkl_err1; /* primary error code (e.g sense key) */ + short hdkl_err2; /* secondary error code */ +}; + +/* + * Dk_log type flags. + * + * FIXME: Really should specify dkd_errno error codes. + * For some reason they're specified in the drivers + * instead of here?? Should also use those here for + * dk_log.type too. + */ +#define HDKL_SOFT 0x01 /* recoverable erro */ +#define HDKL_HARD 0x02 /* unrecoverable error */ + +/* + * Severity values + */ +#define HDK_NOERROR 0 +#define HDK_CORRECTED 1 +#define HDK_RECOVERED 2 +#define HDK_FATAL 3 + +/* + * Error types + */ +#define HDK_NONMEDIA 0 /* not caused by a media defect */ +#define HDK_ISMEDIA 1 /* caused by a media defect */ + + +#define HDIOC (0x04 << 8) +#define HDKIOCSTYPE (HDIOC|101) /* Set drive info */ +#define HDKIOCGTYPE (HDIOC|102) /* Get drive info */ +#define HDKIOCSBAD (HDIOC|103) /* Set bad sector map */ +#define HDKIOCGBAD (HDIOC|104) /* Get bad sector map */ +#define HDKIOCSCMD (HDIOC|105) /* Set generic cmd */ +#define HDKIOCGDIAG (HDIOC|106) /* Get diagnostics */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HDIO_H */ diff --git a/illumos-x86_64/usr/include/sys/hook.h b/illumos-x86_64/usr/include/sys/hook.h new file mode 100644 index 00000000..464f2b8b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hook.h @@ -0,0 +1,148 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * This file includes definitions of kernel hook framework components + */ + +#ifndef _SYS_HOOK_H +#define _SYS_HOOK_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definition exposed to hook provider and consumer + */ + +#define HOOK_VERSION 1 + +typedef uintptr_t hook_data_t; + +struct hook_event_int; +typedef struct hook_event_int *hook_event_token_t; +struct hook_int; +typedef struct hook_int *hook_token_t; + +typedef int (* hook_func_t)(hook_event_token_t, hook_data_t, void *); + +/* + * A hook_notify_cmd_t is given as an argument to functions called as part of + * the notify callbacks that have been registered firing. + */ +typedef enum hook_notify_cmd_e { + HN_NONE = 0, + HN_REGISTER = 1, + HN_UNREGISTER = 2 +} hook_notify_cmd_t; + +/* + * + */ +typedef enum hook_hint_e { + HH_NONE = 0, + HH_FIRST, + HH_LAST, + HH_BEFORE, + HH_AFTER +} hook_hint_t; + +/* + * Hook + */ +typedef struct hook_s { + int h_version; + hook_func_t h_func; /* callback func */ + char *h_name; /* name of this hook */ + uint_t h_flags; /* extra hook properties */ + hook_hint_t h_hint; /* What type of hint is hintvalue */ + uintptr_t h_hintvalue; + void *h_arg; /* value to pass back into the hook */ +} hook_t; + +#define HOOK_INIT(x, fn, r, a) \ + do { \ + (x) = hook_alloc(HOOK_VERSION); \ + (x)->h_func = (fn); \ + (x)->h_name = (r); \ + (x)->h_flags = 0; \ + (x)->h_hint = HH_NONE; \ + (x)->h_hintvalue = 0; \ + (x)->h_arg = (a); \ + _NOTE(CONSTCOND) \ + } while (0) + +/* + * Family + */ +typedef struct hook_family_s { + int hf_version; /* version number */ + char *hf_name; /* family name */ +} hook_family_t; + +#define HOOK_FAMILY_INIT(x, y) \ + do { \ + (x)->hf_version = HOOK_VERSION; \ + (x)->hf_name = (y); \ + _NOTE(CONSTCOND) \ + } while (0) + +/* + * Event + */ +typedef struct hook_event_s { + int he_version; + char *he_name; /* name of this hook list */ + int he_flags; /* 1 = multiple entries allowed */ + boolean_t he_interested; /* true if callback exist */ +} hook_event_t; + +#define HOOK_RDONLY 0x1 /* Callbacks must not change data */ + /* Multiple callbacks are allowed */ + +#define HOOK_EVENT_INIT(x, y) \ + do { \ + (x)->he_version = HOOK_VERSION; \ + (x)->he_name = (y); \ + (x)->he_flags = 0; \ + (x)->he_interested = B_FALSE; \ + _NOTE(CONSTCOND) \ + } while (0) + +typedef int (* hook_notify_fn_t)(hook_notify_cmd_t, void *, const char *, + const char *, const char *); + +extern hook_t *hook_alloc(const int version); +extern void hook_free(hook_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HOOK_H */ diff --git a/illumos-x86_64/usr/include/sys/hook_event.h b/illumos-x86_64/usr/include/sys/hook_event.h new file mode 100644 index 00000000..193d1f65 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hook_event.h @@ -0,0 +1,171 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * This file include definition of message passed from hook provider + * to hook consumer. If necessary, each hook provider can add its + * own message definition here. + */ + +#ifndef _SYS_HOOK_EVENT_H +#define _SYS_HOOK_EVENT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct msgb; /* avoiding sys/stream.h here */ + +/* + * The hook_pkt_event_t structure is supplied with packet events on + * associated network interfaces. + * + * The members of this structure are defined as follows: + * hpe_protocol - protocol identifier that indicates which protocol the + * header data is associated with. + * hpe_ifp - "in" interface for packets coming into the system or forwarded + * hpe_ofp - "out" interface for packets being transmitted or forwarded + * hpe_hdr - pointer to protocol header within the packet + * hpe_mp - pointer to the mblk pointer starting the chain for this packet + * hpe_mb - pointer to the mblk that contains hpe_hdr + */ +typedef struct hook_pkt_event { + net_handle_t hpe_protocol; + phy_if_t hpe_ifp; + phy_if_t hpe_ofp; + void *hpe_hdr; + struct msgb **hpe_mp; + struct msgb *hpe_mb; + int hpe_flags; + void *hpe_reserved[2]; +} hook_pkt_event_t; + +#define HPE_MULTICAST 0x01 +#define HPE_BROADCAST 0x02 + +/* + * NIC events hook provider + */ +typedef enum nic_event { + NE_PLUMB = 1, + NE_UNPLUMB, + NE_UP, + NE_DOWN, + NE_ADDRESS_CHANGE, + NE_LIF_UP, + NE_LIF_DOWN, + NE_IFINDEX_CHANGE +} nic_event_t; + +typedef void *nic_event_data_t; + +/* + * The hook_nic_event data structure is provided with all network interface + * events. + * + * hne_protocol- network protocol for events, returned from net_lookup + * hne_nic - physical interface associated with event + * hne_lif - logical interface (if any) associated with event + * hne_event - type of event occuring + * hne_data - pointer to extra data about event or NULL if none + * hne_datalen - size of data pointed to by hne_data (can be 0) + */ +typedef struct hook_nic_event { + net_handle_t hne_protocol; + phy_if_t hne_nic; + lif_if_t hne_lif; + nic_event_t hne_event; + nic_event_data_t hne_data; + size_t hne_datalen; +} hook_nic_event_t; + +/* + * This structure is used internally by ip to queue events. + */ +struct hook_nic_event_int { + netstackid_t hnei_stackid; + hook_nic_event_t hnei_event; +}; +typedef struct hook_nic_event_int hook_nic_event_int_t; + +/* + * This structure holds the data passed back from the ip module to + * observability consumers. + * + * Externally exposed fields, that must match the order and size of + * dl_ipnetinfo_t in are: + * hpo_version Version number for this header + * hpo_family Address family of the attached packet + * hpo_htype IPobs hook type + * hpo_pktlen Length of the attached packet + * hpo_ifindex Interface index that the packet was received/sent over. + * For local packets, this is the index of the interface + * associated with the local destination address. + * hpo_grifindex IPMP group interface index (zero unless ihd_ifindex + * is an IPMP underlying interface). + * hpo_zsrc Source zoneid; set to ALL_ZONES when unknown. + * hpo_zdst Destination zoneid; set to ALL_ZONES when unknown. + * + * Fields used internally are: + * hpo_pkt Pointer to the mblk_t containig this structure with + * the real packet found at b_cont + */ +typedef struct hook_pkt_observe_s { + uint8_t hpo_version; + uint8_t hpo_family; + uint16_t hpo_htype; + uint32_t hpo_pktlen; + uint32_t hpo_ifindex; + uint32_t hpo_grifindex; + uint32_t hpo_zsrc; + uint32_t hpo_zdst; + /* + * Fields used internally are below. + */ + struct msgb *hpo_pkt; + void *hpo_ctx; +} hook_pkt_observe_t; + +/* + * ipobs_hooktype_t describes the hook types supported + * by the ip module. IPOBS_HOOK_LOCAL refers to packets + * which are looped back internally within the ip module. + */ + +typedef enum ipobs_hook_type { + IPOBS_HOOK_INBOUND = 0, + IPOBS_HOOK_OUTBOUND = 1, + IPOBS_HOOK_LOCAL = 2 +} ipobs_hook_type_t; + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HOOK_EVENT_H */ diff --git a/illumos-x86_64/usr/include/sys/hook_impl.h b/illumos-x86_64/usr/include/sys/hook_impl.h new file mode 100644 index 00000000..f3337bba --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hook_impl.h @@ -0,0 +1,243 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2018, Joyent, Inc. + */ + +/* + * This file include internal used definition and data structure of hooks + */ + +#ifndef _SYS_HOOK_IMPL_H +#define _SYS_HOOK_IMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum fwflag_e { + FWF_NONE = 0x00, + FWF_DESTROY_ACTIVE = 0x01, + FWF_ADD_ACTIVE = 0x04, + FWF_DEL_ACTIVE = 0x08, + FWF_DESTROY_WANTED = 0x10, + FWF_ADD_WANTED = 0x40, + FWF_DEL_WANTED = 0x80, + FWF_NOT_READY = 0x100 +} fwflag_t; + +#define FWF_ADD_WAIT_MASK (FWF_ADD_ACTIVE|FWF_DEL_ACTIVE|FWF_ADD_WANTED) +#define FWF_DEL_WAIT_MASK (FWF_ADD_ACTIVE|FWF_DEL_ACTIVE|\ + FWF_ADD_WANTED|FWF_DEL_WANTED) +#define FWF_UNSAFE (FWF_DESTROY_ACTIVE|FWF_NOT_READY) +#define FWF_DESTROY (FWF_DESTROY_ACTIVE|FWF_DESTROY_WANTED) +#define FWF_DESTROY_OK(x) ((x)->fw_flags == FWF_DESTROY_WANTED) + +typedef struct flagwait_s { + kcondvar_t fw_cv; + kmutex_t fw_lock; + uint32_t fw_flags; + cvwaitlock_t *fw_owner; +} flagwait_t; + + +/* + * The following diagram describes the linking together of data structures + * used in this implementation of callback hooks. The start of it all is + * the "familylist" variable in hook.c. The relationships between data + * structures is: + * - there is a list of hook families; + * - each hook family can have a list of hook events; + * - each hook_event_t must be uniquely associated with one family and event; + * - each hook event can have a list of registered hooks to call. + * + * familylist +--------------+ + * | | hook_event_t |<--\ + * | +--------------+ | + * V | + * +-------------------+ ->+------------------+ | ->+--------------+ + * | hook_family_int_t | / | hook_event_int_t | | / | hook_int_t | + * | +---------------+ | / | | / / | +----------+ | + * | | hook_family_t | | / | hei_event---------/ / | | hook_t | | + * | +---------------+ | / | hei_nhead----------\ / | +----------+ | + * | | / | | X | | + * | hfi_head------------/ | hei_head-----------/ \ | hi_entry--\ | + * | hfi_entry--\ | | hei_entry--\ | | +-----------|--+ + * +------------|------+ +------------|-----+ | | + * | | | | + * V V | V + * +-------------------+ +------------------+ | +--------------+ + * | hook_family_int_t | | hook_event_int_t | | | hook_int_t | + * V + * +--------------+ + * | + * ... + */ + +typedef struct hook_hook_kstat { + kstat_named_t hook_version; + kstat_named_t hook_flags; + kstat_named_t hook_hint; + kstat_named_t hook_hintvalue; + kstat_named_t hook_position; + kstat_named_t hook_hits; +} hook_hook_kstat_t; + +/* + * hook_int: internal storage of hook + */ +typedef struct hook_int { + TAILQ_ENTRY(hook_int) hi_entry; + hook_t hi_hook; + hook_hook_kstat_t hi_kstats; + kstat_t *hi_kstatp; + char *hi_ksname; + cvwaitlock_t hi_notify_lock; +} hook_int_t; + +/* + * hook_int_head: tail queue of hook_int + */ +TAILQ_HEAD(hook_int_head, hook_int); +typedef struct hook_int_head hook_int_head_t; + + +typedef struct hook_notify { + TAILQ_ENTRY(hook_notify) hn_entry; + hook_notify_fn_t hn_func; + void *hn_arg; + uint32_t hn_flags; +} hook_notify_t; + +TAILQ_HEAD(hook_notify_head, hook_notify); +typedef struct hook_notify_head hook_notify_head_t; + + +typedef struct hook_event_kstat { + kstat_named_t hooks_added; + kstat_named_t hooks_removed; + kstat_named_t events; +} hook_event_kstat_t; + +/* + * hook_event_int: internal storage of hook_event + */ +typedef struct hook_event_int { + cvwaitlock_t hei_lock; + SLIST_ENTRY(hook_event_int) hei_entry; + hook_event_t *hei_event; + hook_int_head_t hei_head; + kstat_t *hei_kstatp; + hook_event_kstat_t hei_kstats; + hook_notify_head_t hei_nhead; + flagwait_t hei_waiter; + boolean_t hei_condemned; + boolean_t hei_shutdown; +} hook_event_int_t; + +/* + * hook_event_int_head: singly-linked list of hook_event_int + */ +SLIST_HEAD(hook_event_int_head, hook_event_int); +typedef struct hook_event_int_head hook_event_int_head_t; + +/* + * hook_family_int: internal storage of hook_family + */ +typedef struct hook_family_int { + cvwaitlock_t hfi_lock; + SLIST_ENTRY(hook_family_int) hfi_entry; + hook_event_int_head_t hfi_head; + hook_family_t hfi_family; + kstat_t *hfi_kstat; + struct hook_stack *hfi_stack; + hook_notify_head_t hfi_nhead; + flagwait_t hfi_waiter; + boolean_t hfi_condemned; + boolean_t hfi_shutdown; +} hook_family_int_t; + +/* + * hook_family_int_head: singly-linked list of hook_family + */ +SLIST_HEAD(hook_family_int_head, hook_family_int); +typedef struct hook_family_int_head hook_family_int_head_t; + +/* + * hook stack instances + */ +struct hook_stack { + cvwaitlock_t hks_lock; + SLIST_ENTRY(hook_stack) hks_entry; + hook_family_int_head_t hks_familylist; /* family list head */ + netstack_t *hks_netstack; + netstackid_t hks_netstackid; + hook_notify_head_t hks_nhead; + int hks_shutdown; + flagwait_t hks_waiter; +}; +typedef struct hook_stack hook_stack_t; +SLIST_HEAD(hook_stack_head, hook_stack); +typedef struct hook_stack_head hook_stack_head_t; + +/* + * Names of hooks families currently defined by Solaris + */ +#define Hn_ARP "arp" +#define Hn_IPV4 "inet" +#define Hn_IPV6 "inet6" +#define Hn_VIONA "viona_inet" + +extern int hook_run(hook_family_int_t *, hook_event_token_t, hook_data_t); +extern int hook_register(hook_family_int_t *, char *, hook_t *); + +extern int hook_unregister(hook_family_int_t *, char *, hook_t *); +extern hook_event_int_t *hook_event_add(hook_family_int_t *, hook_event_t *); +extern int hook_event_notify_register(hook_family_int_t *, char *, + hook_notify_fn_t, void *); +extern int hook_event_notify_unregister(hook_family_int_t *, char *, + hook_notify_fn_t); +extern int hook_event_remove(hook_family_int_t *, hook_event_t *); +extern int hook_event_shutdown(hook_family_int_t *, hook_event_t *); + +extern hook_family_int_t *hook_family_add(hook_family_t *, hook_stack_t *, + void **); +extern int hook_family_notify_register(hook_family_int_t *, hook_notify_fn_t, + void *); +extern int hook_family_notify_unregister(hook_family_int_t *, hook_notify_fn_t); +extern int hook_family_remove(hook_family_int_t *); +extern int hook_family_shutdown(hook_family_int_t *); + +extern int hook_stack_notify_register(netstackid_t, hook_notify_fn_t, void *); +extern int hook_stack_notify_unregister(netstackid_t, hook_notify_fn_t); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HOOK_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/hotplug/hpcsvc.h b/illumos-x86_64/usr/include/sys/hotplug/hpcsvc.h new file mode 100644 index 00000000..7ef8935c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hotplug/hpcsvc.h @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1999-2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_HOTPLUG_HPCSVC_H +#define _SYS_HOTPLUG_HPCSVC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* flags for event handling */ +#define HPC_EVENT_NORMAL 0 /* normal, queued event handling */ +#define HPC_EVENT_SYNCHRONOUS 1 /* unqueued sync. event handling */ + +extern int hpc_nexus_register_bus(dev_info_t *dip, + int (* callback)(dev_info_t *dip, hpc_slot_t handle, + hpc_slot_info_t *slot_info, int slot_state), + uint_t flags); +extern int hpc_nexus_unregister_bus(dev_info_t *dip); +extern int hpc_nexus_connect(hpc_slot_t handle, void *data, uint_t flags); +extern int hpc_nexus_disconnect(hpc_slot_t handle, void *data, uint_t flags); +extern int hpc_nexus_insert(hpc_slot_t handle, void *data, uint_t flags); +extern int hpc_nexus_remove(hpc_slot_t handle, void *data, uint_t flags); +extern int hpc_nexus_control(hpc_slot_t handle, int request, caddr_t arg); +extern int hpc_install_event_handler(hpc_slot_t handle, uint_t event_mask, + int (*event_handler)(caddr_t, uint_t), caddr_t arg); +extern int hpc_remove_event_handler(hpc_slot_t handle); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HOTPLUG_HPCSVC_H */ diff --git a/illumos-x86_64/usr/include/sys/hotplug/hpctrl.h b/illumos-x86_64/usr/include/sys/hotplug/hpctrl.h new file mode 100644 index 00000000..1fbd7596 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hotplug/hpctrl.h @@ -0,0 +1,327 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_HOTPLUG_HPCTRL_H +#define _SYS_HOTPLUG_HPCTRL_H + +/* + * **************************************************************** + * Hot Plug Controller interfaces for PCI and CompactPCI platforms. + * **************************************************************** + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Type definition for slot handle. This is an opaque pointer + * created by the HPS framework. + */ +typedef void *hpc_slot_t; + +#define HPC_SLOT_OPS_VERSION 0 + +/* + * slot operations structure definition. + * + * Function Description + * -------- ----------- + * xxx_op_connect CONNECT the slot to the bus to enable + * access to the adapter. + * xxx_op_disconnect DISCONNECT the slot from the bus. For PCI, + * this disables the power to the slot. + * xxx_op_insert Prepare the slot for card insertion. This + * may not be applicable for all bus types. + * xxx_op_remove Prepare the slot for card removal. This + * may not be applicable for all bus types. + * xxx_op_control Perform misc. commands to control the + * LEDs, get status information, etc. + */ +typedef struct hpc_slot_ops { + int hpc_version; /* HPC_SLOT_OPS_VERSION */ + int (*hpc_op_connect)(caddr_t ops_arg, hpc_slot_t slot_hdl, + void *data, uint_t flags); + int (*hpc_op_disconnect)(caddr_t ops_arg, hpc_slot_t slot_hdl, + void *data, uint_t flags); + int (*hpc_op_insert)(caddr_t ops_arg, hpc_slot_t slot_hdl, + void *data, uint_t flags); + int (*hpc_op_remove)(caddr_t ops_arg, hpc_slot_t slot_hdl, + void *data, uint_t flags); + int (*hpc_op_control)(caddr_t ops_arg, hpc_slot_t slot_hdl, + int request, caddr_t arg); +} hpc_slot_ops_t; + +#define HPC_SLOT_INFO_VERSION 1 +#define PCI_SLOT_NAME_LEN 256 +/* + * Slot information structure. + */ +typedef struct hpc_slot_info { + uint16_t version; /* HPC_SLOT_INFO_VERSION */ + uint16_t slot_type; /* slot type: PCI, ... */ + uint16_t slot_flags; + union { + /* pci bus slot */ + struct pci_slot_info { + uint16_t device_number; /* PCI device number */ + uint16_t slot_capabilities; /* 64bit, etc. */ + char slot_logical_name[PCI_SLOT_NAME_LEN]; + } pci; + struct sbd_slot_info { + int slot_num; + } sbd; + /* other bus types go here... */ + } slot; +} hpc_slot_info_t; + +/* short names for bus specific fields in hpc_slot_info structure */ +#define pci_dev_num slot.pci.device_number +#define pci_slot_name slot.pci.slot_logical_name +#define pci_slot_capabilities slot.pci.slot_capabilities + +#define sbd_slot_num slot.sbd.slot_num + +/* slot_type definitions */ +#define HPC_SLOT_TYPE_PCI 0x1 /* PCI bus slot */ +#define HPC_SLOT_TYPE_CPCI 0x2 /* Compact PCI bus slot */ +#define HPC_SLOT_TYPE_SBD 0x3 /* System bus slot */ +#define HPC_SLOT_TYPE_PCIE 0x4 /* PCI Express slot */ + +/* bit definitions in slot_capabilities field for PCI or cPCI bus slots */ +#define HPC_SLOT_64BITS 0x0001 /* slot is a 64bit slot */ +#define HPC_SLOT_TEST 0x0002 /* testing capability on the slot */ + +/* slot_flags definitions */ +#define HPC_SLOT_NO_AUTO_ENABLE 0x1 /* No auto-enable on registration */ +#define HPC_SLOT_CREATE_DEVLINK 0x2 /* create device link under /dev/cfg */ + +/* + * xxx_op_control command definitions. + * + * Command (request) arg Descritpion + * ----------------- --- ----------- + * HPC_CTRL_GET_LED_STATE hpc_led_info * Get state of an LED. + * HPC_CTRL_SET_LED_STATE hpc_led_info * Set state of an LED. + * HPC_CTRL_GET_SLOT_STATE hpc_slot_state_t * Get the slot state. + * HPC_CTRL_DEV_CONFIGURED NULL Board is configured. + * HPC_CTRL_DEV_UNCONFIGURED NULL Board is unconfigured. + * HPC_CTRL_DEV_CONFIG_FAILURE NULL Board Configuration Failed + * HPC_CTRL_DEV_UNCONFIG_FAILURE NULL Board Unconfiguration Failed + * HPC_CTRL_GET_BOARD_TYPE hpc_board_type_t * Get board type info. + * HPC_CTRL_DISABLE_AUTOCFG NULL Disable auto config- + * uration for this slot. + * HPC_CTRL_ENABLE_AUTOCFG NULL Enable auto config- + * uration for this slot. + * HPC_CTRL_DISABLE_SLOT NULL Disable the slot for + * hot plug operations. + * HPC_CTRL_ENABLE_SLOT NULL ReEnable the slot for + * hot plug operations. + */ +#define HPC_CTRL_GET_LED_STATE 0x1 +#define HPC_CTRL_SET_LED_STATE 0x2 +#define HPC_CTRL_GET_SLOT_STATE 0x3 +#define HPC_CTRL_DEV_CONFIGURED 0x4 +#define HPC_CTRL_DEV_UNCONFIGURED 0x5 +#define HPC_CTRL_GET_BOARD_TYPE 0x6 +#define HPC_CTRL_DISABLE_AUTOCFG 0x7 +#define HPC_CTRL_ENABLE_AUTOCFG 0x8 +#define HPC_CTRL_DISABLE_SLOT 0x9 +#define HPC_CTRL_ENABLE_SLOT 0xa +#define HPC_CTRL_DISABLE_ENUM 0xb +#define HPC_CTRL_ENABLE_ENUM 0xc +#define HPC_CTRL_DEV_CONFIG_FAILURE 0xd +#define HPC_CTRL_DEV_UNCONFIG_FAILURE 0xe +#define HPC_CTRL_DEV_CONFIG_START 0xf +#define HPC_CTRL_DEV_UNCONFIG_START 0x10 + +/* + * type definitions for led information. + * + * Note: ATTN/ACTIVE leds are platform specific and they may not be + * available on all platforms. + */ +typedef enum { HPC_FAULT_LED, HPC_POWER_LED, HPC_ATTN_LED, + HPC_ACTIVE_LED} hpc_led_t; + +typedef enum { HPC_LED_OFF, HPC_LED_ON, HPC_LED_BLINK } hpc_led_state_t; + +typedef struct hpc_led_info { + hpc_led_t led; /* led id: HPC_POWER_LED, HPC_FAULT_LED, ... */ + hpc_led_state_t state; /* led state: HPC_LED_ON, HPC_LED_OFF, ... */ +} hpc_led_info_t; + +/* + * type definition for slot state. + * + * HPC_SLOT_EMPTY Slot has no card present. + * HPC_SLOT_CONNECTED Card is present in the slot and it is + * connected to the bus. + * HPC_SLOT_DISCONNECTED Card is present in the slot and it is + * disconnected from the bus. + * HPC_SLOT_UNKNOWN If the HPC driver can not figure out + * the receptacle state. This is possible + * on Compact PCI Hot Swap platform. + */ +typedef enum { HPC_SLOT_EMPTY, HPC_SLOT_DISCONNECTED, + HPC_SLOT_CONNECTED, HPC_SLOT_UNKNOWN } hpc_slot_state_t; + +/* + * type definition for board type. + * + * HPC_BOARD_UNKNOWN Board is either not present or unknown. + * HPC_BOARD_PCI_HOTPLUG PCI or PCIe adapter. + * HPC_BOARD_CPCI_NON_HS Non Hot Swap cPCI board. + * HPC_BOARD_CPCI_BASIC_HS Basic Hot Swap cPCI board. + * HPC_BOARD_CPCI_FULL_HS Full Hot Swap cPCI board. + * HPC_BOARD_CPCI_HS Indicates if HSC driver can not determine + * the type of Hot Swap board. + */ +typedef enum { HPC_BOARD_UNKNOWN, HPC_BOARD_PCI_HOTPLUG, + HPC_BOARD_CPCI_NON_HS, HPC_BOARD_CPCI_BASIC_HS, + HPC_BOARD_CPCI_FULL_HS, HPC_BOARD_CPCI_HS } hpc_board_type_t; + +/* + * Event type definitions (for hpc_event_notify() interface). + * + * Event Descritpion + * ----- ----------- + * HPC_EVENT_SLOT_INSERTION Card is inserted in the slot. + * HPC_EVENT_SLOT_REMOVAL Card is removed from the slot. + * HPC_EVENT_SLOT_POWER_ON Slot is powered ON. + * HPC_EVENT_SLOT_POWER_OFF Slot is powered OFF. + * HPC_EVENT_SLOT_LATCH_OPEN LATCH on the slot is open. + * HPC_EVENT_SLOT_LATCH_SHUT LATCH on the slot is shut. + * HPC_EVENT_SLOT_ENUM ENUM# signal is generated on the bus + * and it may be generated from this slot. + * HPC_EVENT_SLOT_NOT_HEALTHY HEALTHY# signal is lost on this slot. + * HPC_EVENT_SLOT_HEALTHY_OK HEALTHY# signal on this slot is OK now. + * HPC_EVENT_SLOT_CONFIGURE Configure the occupant in the slot. + * HPC_EVENT_SLOT_UNCONFIGURE Unconfigure the occupant in the slot. + */ +#define HPC_EVENT_SLOT_INSERTION 0x00000001 +#define HPC_EVENT_SLOT_REMOVAL 0x00000002 +#define HPC_EVENT_SLOT_POWER_ON 0x00000004 +#define HPC_EVENT_SLOT_POWER_OFF 0x00000008 +#define HPC_EVENT_SLOT_LATCH_OPEN 0x00000010 +#define HPC_EVENT_SLOT_LATCH_SHUT 0x00000020 +#define HPC_EVENT_SLOT_ENUM 0x00000040 +#define HPC_EVENT_SLOT_NOT_HEALTHY 0x00000080 +#define HPC_EVENT_SLOT_HEALTHY_OK 0x00000100 +#define HPC_EVENT_SLOT_CONFIGURE 0x00000200 +#define HPC_EVENT_SLOT_UNCONFIGURE 0x00000400 +#define HPC_EVENT_SLOT_BLUE_LED_ON 0x00000800 +#define HPC_EVENT_SLOT_BLUE_LED_OFF 0x00001000 +#define HPC_EVENT_CLEAR_ENUM 0x00002000 +#define HPC_EVENT_PROCESS_ENUM 0x00004000 +#define HPC_EVENT_ENABLE_ENUM 0x00008000 +#define HPC_EVENT_DISABLE_ENUM 0x00010000 +#define HPC_EVENT_BUS_ENUM HPC_EVENT_SLOT_ENUM +#define HPC_EVENT_SLOT_ATTN 0x00020000 +#define HPC_EVENT_SLOT_POWER_FAULT 0x00040000 + +/* + * return values for errors from HPS framework interfaces. + */ +#define HPC_SUCCESS 0x0 +#define HPC_ERR_INVALID 0x1 /* invalid arguments */ +#define HPC_ERR_SLOT_NOTREGISTERED 0x2 /* slot is not registered */ +#define HPC_ERR_SLOT_DUPLICATE 0x3 /* slot is already registered */ +#define HPC_ERR_BUS_NOTREGISTERED 0x4 /* slot is not registered */ +#define HPC_ERR_BUS_DUPLICATE 0x5 /* slot is already registered */ +#define HPC_ERR_NOTSUPPORTED 0x6 /* operation not supported */ +#define HPC_ERR_FAILED 0x7 /* operation failed */ + +/* return values for event notifications */ +#define HPC_EVENT_CLAIMED 0x10 /* HPC event is claimed */ +#define HPC_EVENT_UNCLAIMED -1 /* HPC event is not claimed */ + +/* definitions for slot (un)registration events */ +#define HPC_SLOT_ONLINE 1 /* slot is registered */ +#define HPC_SLOT_OFFLINE 2 /* slot is unregistered */ + +/* + * function prototype definitions for interfaces between HPC driver + * and Hot Plug Services framework. + */ +extern int hpc_slot_register(dev_info_t *dip, char *bus_path, + hpc_slot_info_t *slot_info, hpc_slot_t *slot_hdl, + hpc_slot_ops_t *slot_ops, caddr_t ops_arg, uint_t flags); +extern int hpc_slot_unregister(hpc_slot_t *slot_hdl); +extern struct hpc_slot_ops *hpc_alloc_slot_ops(int sleepflag); +extern void hpc_free_slot_ops(hpc_slot_ops_t *ops); +extern int hpc_slot_event_notify(hpc_slot_t slot_hdl, uint_t event, + uint_t flags); +extern boolean_t hpc_bus_registered(hpc_slot_t slot_hdl); + +/* + * ***************************************************************** + * Implementation specific data structures and definitons. These are + * the private interfaces between cfgadm plug-in and the PCI nexus + * driver. + * ***************************************************************** + */ + +/* + * Data structure used for DEVCTL_AP_CONTROL ioctl on the AP. + */ +struct hpc_control_data { + uint_t cmd; /* HPC_CTRL_* command */ + void *data; /* pointer to data that is exchanged */ +}; + +struct hpc_control32_data { + uint_t cmd; /* HPC_CTRL_* command */ + caddr32_t data; /* pointer to data that is exchanged */ +}; + +/* misc. control commands for DEVCTL_AP_CONTROL ioctl interface */ +#define HPC_CTRL_GET_SLOT_INFO 0x100 +#define HPC_CTRL_GET_CARD_INFO 0x101 + +/* card information structure to get data from the PCI config header */ +typedef struct hpc_card_info { + uint8_t prog_class; /* PCI_CONF_PROGCLASS byte */ + uint8_t base_class; /* PCI_CONF_BASCLASS byte */ + uint8_t sub_class; /* PCI_CONF_SUBCLASS byte */ + uint8_t header_type; /* PCI_CONF_HEADER byte */ +} hpc_card_info_t; + +/* Slot occupant information structure */ +#define HPC_MAX_OCCUPANTS 128 +typedef struct hpc_occupant_info { + int i; + char *id[HPC_MAX_OCCUPANTS]; +} hpc_occupant_info_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HOTPLUG_HPCTRL_H */ diff --git a/illumos-x86_64/usr/include/sys/hotplug/pci/pcicfg.h b/illumos-x86_64/usr/include/sys/hotplug/pci/pcicfg.h new file mode 100644 index 00000000..943ece48 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hotplug/pci/pcicfg.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_HOTPLUG_PCI_PCICFG_H +#define _SYS_HOTPLUG_PCI_PCICFG_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum pcicfg_flags { + /* No probing; used in case of virtual hotplug */ + PCICFG_FLAG_READ_ONLY = 0x1, + /* Enable ARI; used in case of boot case */ + PCICFG_FLAG_ENABLE_ARI = 0x2 +} pcicfg_flags_t; + +/* + * Interfaces exported by PCI configurator module, kernel/misc/pcicfg. + */ +int pcicfg_configure(dev_info_t *, uint_t, uint_t, pcicfg_flags_t); +int pcicfg_unconfigure(dev_info_t *, uint_t, uint_t, pcicfg_flags_t); + +#define PCICFG_SUCCESS DDI_SUCCESS +#define PCICFG_FAILURE DDI_FAILURE + +#define PCICFG_ALL_FUNC 0xffffffff + +/* + * The following subclass definition for Non Transparent bridge should + * be moved to pci.h. + */ +#define PCI_BRIDGE_STBRIDGE 0x9 + +#define PCICFG_CONF_INDIRECT_MAP 1 +#define PCICFG_CONF_DIRECT_MAP 0 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HOTPLUG_PCI_PCICFG_H */ diff --git a/illumos-x86_64/usr/include/sys/hotplug/pci/pcihp.h b/illumos-x86_64/usr/include/sys/hotplug/pci/pcihp.h new file mode 100644 index 00000000..eb96e924 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hotplug/pci/pcihp.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_HOTPLUG_PCI_PCIHP_H +#define _SYS_HOTPLUG_PCI_PCIHP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +/* + * Interfaces exported by PCI Nexus extension module, kernel/misc/pcihp. + */ +int pcihp_init(dev_info_t *); +int pcihp_uninit(dev_info_t *); +int pcihp_info(dev_info_t *, ddi_info_cmd_t, void *, void **); +struct cb_ops *pcihp_get_cb_ops(void); +#endif + +/* definitions for minor numbers */ +#define PCIHP_AP_MINOR_NUM(x, y) (((uint_t)(x) << 8) | \ + ((y) & 0xFF)) +#define PCIHP_AP_MINOR_NUM_TO_PCI_DEVNUM(x) ((x) & 0xFF) +#define PCIHP_AP_MINOR_NUM_TO_INSTANCE(x) ((x) >> 8) +#define PCIHP_DEVCTL_MINOR 0xFF +#define PCIHP_DEBUG_MINOR 0xFE + +/* definitons for cPCI platforms */ +#define PCI_CONF_EXTCAP 0x34 /* Extended Capabilities Pointer */ +#define PCI_ECP_CAPID 0x00 /* Capability ID */ +#define PCI_ECP_NEXT 0x01 /* Pointer to Next Capability */ +#define PCI_ECP_HS_CSR 0x02 /* Hot Swap Control and Status Reg */ +#define CPCI_HOTSWAP_CAPID 0x06 /* Hot Swap Capability ID */ + +#define HS_CSR_INS 0x80 /* ENUM Status - Insertion */ +#define HS_CSR_EXT 0x40 /* ENUM Status - Extraction */ +#define HS_CSR_LOO 0x08 /* LED ON/OFF 1=ON 0=OFF */ +#define HS_CSR_EIM 0x02 /* ENUM# Signal Mask */ + +#define PCIHP_MAKE_REG_HIGH(busnum, devnum, funcnum, register)\ + (\ + ((ulong_t)(busnum & 0xff) << 16) |\ + ((ulong_t)(devnum & 0x1f) << 11) |\ + ((ulong_t)(funcnum & 0x7) << 8) |\ + ((ulong_t)(register & 0x3f))) + +#define PCIHP_SUCCESS DDI_SUCCESS +#define PCIHP_FAILURE DDI_FAILURE + +/* cPCI hotswap definitions */ +#define PCIHP_HANDLE_ENUM 1 /* clear interrupt and take action */ +#define PCIHP_CLEAR_ENUM 2 /* clear interrupt only. */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HOTPLUG_PCI_PCIHP_H */ diff --git a/illumos-x86_64/usr/include/sys/hwconf.h b/illumos-x86_64/usr/include/sys/hwconf.h new file mode 100644 index 00000000..af240461 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hwconf.h @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_HWCONF_H +#define _SYS_HWCONF_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_HWC_LINESIZE 1024 + +struct hwc_class { + struct hwc_class *class_next; + char *class_exporter; + char *class_name; +}; + +struct hwc_spec { + struct hwc_spec *hwc_next; + char *hwc_parent_name; + char *hwc_class_name; + char *hwc_devi_name; + ddi_prop_t *hwc_devi_sys_prop_ptr; + /* For hashing */ + struct hwc_spec *hwc_hash_next; + major_t hwc_major; +}; + +/* + * used to create sorted linked lists of hwc_spec structs for loading parents + */ +struct par_list { + struct par_list *par_next; + struct hwc_spec *par_specs; /* List of prototype nodes */ + major_t par_major; /* Simple name of parent */ +}; + +struct bind { + struct bind *b_next; + char *b_name; + char *b_bind_name; + int b_num; +}; + +typedef struct mperm { + struct mperm *mp_next; + char *mp_minorname; + mode_t mp_mode; + uid_t mp_uid; + gid_t mp_gid; +#ifndef _KERNEL + char *mp_drvname; + char *mp_owner; + char *mp_group; +#endif /* !_KERNEL */ +} mperm_t; + +#ifdef _KERNEL + +extern struct bind *mb_hashtab[]; +extern struct bind *sb_hashtab[]; + +extern int hwc_parse(char *, struct par_list **, ddi_prop_t **); +extern struct par_list *impl_make_parlist(major_t); +extern int impl_free_parlist(major_t); +extern void impl_delete_par_list(struct par_list *); +extern int impl_parlist_to_major(struct par_list *, char []); +extern struct hwc_spec *hwc_get_child_spec(dev_info_t *, major_t); +extern void hwc_free_spec_list(struct hwc_spec *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HWCONF_H */ diff --git a/illumos-x86_64/usr/include/sys/hypervisor.h b/illumos-x86_64/usr/include/sys/hypervisor.h new file mode 100644 index 00000000..acb6ad72 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/hypervisor.h @@ -0,0 +1,267 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * + * Communication to/from hypervisor. + * + * Copyright (c) 2002-2004, K A Fraser + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this source file (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef _SYS_HYPERVISOR_H +#define _SYS_HYPERVISOR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define xen_mb membar_enter +#define xen_wmb membar_producer + +#ifndef __xpv +#include +#else +#include +#endif +#include + +#if !defined(_ASM) + +#include +#include +#ifdef __xpv +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern shared_info_t *HYPERVISOR_shared_info; +extern void *HYPERVISOR_console_page; + +/* -- move these definitions elsewhere -- */ + +extern uint_t xen_debug_handler(caddr_t, caddr_t); +extern void xen_printf(const char *, ...) __KPRINTFLIKE(1); +#pragma rarely_called(xen_printf) + +extern void xen_callback(void); +extern void xen_failsafe_callback(void); + +extern hrtime_t xpv_gethrtime(void); +extern hrtime_t xpv_getsystime(void); + +extern void xpv_time_suspend(void); +extern void xpv_time_resume(void); + +extern void startup_xen_version(void); +extern void startup_xen_mca(void); + +extern void mach_cpucontext_reset(cpu_t *); +extern void mach_cpucontext_restore(cpu_t *); + +extern void mp_enter_barrier(void); +extern void mp_leave_barrier(void); + +extern cpuset_t cpu_suspend_lost_set; + +extern int xen_gdt_setprot(cpu_t *, uint_t); +extern int xen_ldt_setprot(user_desc_t *, size_t, uint_t); + +/* -- while you're down there, move these too -- */ + +typedef struct xen_mc_lcpu_cookie *xen_mc_lcpu_cookie_t; + +extern xen_mc_lcpu_cookie_t xen_physcpu_next(xen_mc_lcpu_cookie_t); +extern const char *xen_physcpu_vendorstr(xen_mc_lcpu_cookie_t); +extern int xen_physcpu_family(xen_mc_lcpu_cookie_t); +extern int xen_physcpu_model(xen_mc_lcpu_cookie_t); +extern int xen_physcpu_stepping(xen_mc_lcpu_cookie_t); +extern id_t xen_physcpu_chipid(xen_mc_lcpu_cookie_t); +extern id_t xen_physcpu_coreid(xen_mc_lcpu_cookie_t); +extern id_t xen_physcpu_strandid(xen_mc_lcpu_cookie_t); +extern id_t xen_physcpu_initial_apicid(xen_mc_lcpu_cookie_t); +extern boolean_t xen_physcpu_is_cmt(xen_mc_lcpu_cookie_t); +extern id_t xen_physcpu_logical_id(xen_mc_lcpu_cookie_t); +extern uint64_t xen_physcpu_mcg_cap(xen_mc_lcpu_cookie_t); + +extern int xen_map_gref(uint_t cmd, gnttab_map_grant_ref_t *mapop, + uint_t count, boolean_t uvaddr); + +/* + * Wrappered versions of the hypercalls that diagnose/panic on failure + */ +extern void xen_set_gdt(ulong_t *, int); +extern void xen_set_ldt(user_desc_t *, uint_t); +extern void xen_stack_switch(ulong_t, ulong_t); +extern long xen_set_trap_table(trap_info_t *); + +#if defined(__amd64) +extern void xen_set_segment_base(int, ulong_t); +#endif /* __amd64 */ +extern long xen_vcpu_up(processorid_t); +extern long xen_vcpu_down(processorid_t); +extern void xen_enable_user_iopl(void *); +extern void xen_disable_user_iopl(void *); + +extern int xen_get_mc_physcpuinfo(xen_mc_logical_cpu_t *, uint_t *); +extern uint_t xen_phys_ncpus; +extern xen_mc_logical_cpu_t *xen_phys_cpus; + +extern uint_t xpv_nr_phys_cpus(void); +extern pgcnt_t xpv_nr_phys_pages(void); +extern uint64_t xpv_cpu_khz(void); + + +/* + * A quick way to ask if we're DOM0 or not .. + */ +#ifndef __xpv + +#define DOMAIN_IS_INITDOMAIN(info) (__lintzero) +#define DOMAIN_IS_PRIVILEGED(info) (__lintzero) + +#else + +#define DOMAIN_IS_INITDOMAIN(info) \ + (((info)->flags & SIF_INITDOMAIN) == SIF_INITDOMAIN) + +#define DOMAIN_IS_PRIVILEGED(info) \ + (((info)->flags & SIF_PRIVILEGED) == SIF_PRIVILEGED) + +#endif + +/* + * start of day information passed up from the hypervisor + */ +extern start_info_t *xen_info; + +extern long __hypercall0(int); +extern long __hypercall1(int, ulong_t); +extern long __hypercall2(int, ulong_t, ulong_t); +extern long __hypercall3(int, ulong_t, ulong_t, ulong_t); +extern long __hypercall4(int, ulong_t, ulong_t, ulong_t, ulong_t); +extern long __hypercall5(int, ulong_t, ulong_t, ulong_t, ulong_t, ulong_t); + +extern int __hypercall0_int(int); +extern int __hypercall1_int(int, ulong_t); +extern int __hypercall2_int(int, ulong_t, ulong_t); +extern int __hypercall3_int(int, ulong_t, ulong_t, ulong_t); +extern int __hypercall4_int(int, ulong_t, ulong_t, ulong_t, ulong_t); +extern int __hypercall5_int(int, ulong_t, ulong_t, ulong_t, ulong_t, ulong_t); + +extern long HYPERVISOR_set_trap_table(trap_info_t *); +extern int HYPERVISOR_mmu_update(mmu_update_t *, int, int *, domid_t); +extern long HYPERVISOR_set_gdt(ulong_t *, int); +extern long HYPERVISOR_stack_switch(ulong_t, ulong_t); +#if defined(__amd64) +extern long HYPERVISOR_set_callbacks(ulong_t, ulong_t, ulong_t); +#else +extern long HYPERVISOR_set_callbacks(ulong_t, ulong_t, ulong_t, ulong_t); +#endif +extern long HYPERVISOR_fpu_taskswitch(int); +/* *** __HYPERVISOR_sched_op_compat *** OBSOLETED */ +extern long HYPERVISOR_platform_op(xen_platform_op_t *); +/* *** __HYPERVISOR_set_debugreg *** NOT IMPLEMENTED */ +/* *** __HYPERVISOR_get_debugreg *** NOT IMPLEMENTED */ +extern long HYPERVISOR_update_descriptor(maddr_t, uint64_t); +extern long HYPERVISOR_memory_op(int, void *); +extern long HYPERVISOR_multicall(void *, uint_t); +extern int HYPERVISOR_update_va_mapping(ulong_t, uint64_t, ulong_t); +extern long HYPERVISOR_set_timer_op(uint64_t); +/* *** __HYPERVISOR_event_channel_op_compat *** OBSOLETED */ +extern long HYPERVISOR_xen_version(int, void *); +extern long HYPERVISOR_console_io(int, int, char *); +/* *** __HYPERVISOR_physdev_op_compat *** OBSOLETED */ +extern long HYPERVISOR_grant_table_op(unsigned int, void *, unsigned int); +extern long HYPERVISOR_vm_assist(unsigned int, unsigned int); +extern int HYPERVISOR_update_va_mapping_otherdomain(ulong_t, + uint64_t, ulong_t, domid_t); +/* *** __HYPERVISOR_iret *** IN i86xpv/sys/machprivregs.h */ +extern long HYPERVISOR_vcpu_op(int, int, void *); +#if defined(__amd64) +extern long HYPERVISOR_set_segment_base(int, ulong_t); +#endif /* __amd64 */ +extern int HYPERVISOR_mmuext_op(struct mmuext_op *, int, uint_t *, domid_t); +extern long HYPERVISOR_nmi_op(int cmd, void *); +extern long HYPERVISOR_sched_op(int, void *); +extern long HYPERVISOR_callback_op(int, void *); +/* *** __HYPERVISOR_xenoprof_op *** NOT IMPLEMENTED */ +extern long HYPERVISOR_event_channel_op(int, void *); /* does return long */ +extern long HYPERVISOR_physdev_op(int, void *); +extern long HYPERVISOR_hvm_op(int cmd, void *); +/* *** __HYPERVISOR_kexec_op *** NOT IMPLEMENTED */ +#if defined(__xpv) +extern long HYPERVISOR_mca(uint32_t, xen_mc_t *); +#endif + +/* + * HYPERCALL HELPER ROUTINES + * These don't have their own unique hypercalls. + */ +extern long HYPERVISOR_yield(void); +extern long HYPERVISOR_block(void); +extern long HYPERVISOR_shutdown(uint_t); +extern long HYPERVISOR_poll(evtchn_port_t *, uint_t, uint64_t); +extern long HYPERVISOR_suspend(ulong_t); + +#endif /* !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_HYPERVISOR_H */ diff --git a/illumos-x86_64/usr/include/sys/i8272A.h b/illumos-x86_64/usr/include/sys/i8272A.h new file mode 100644 index 00000000..ea2cdc91 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/i8272A.h @@ -0,0 +1,172 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_I8272A_H +#define _SYS_I8272A_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * i/o port numbers + */ +#define FCR_BASE 0x3f0 /* default i/o base address */ + +#define FCR_SRA 0x000 /* only 82077AA (not AT mode) or SMC */ +#define FCR_SRB 0x001 /* only 82077AA (not AT mode) or SMC */ +#define FCR_DOR 0x002 +#define FCR_MSR 0x004 +#define FCR_DSR 0x004 /* only enhanced controllers */ +#define FCR_DATA 0x005 +#define FCR_DIR 0x007 +#define FCR_CCR 0x007 /* 82077AA term; == DSR on PC/AT */ + +/* SRA : values for Configuration Select Register for SMC FDC37C66xGT */ +#define FSA_ENA5 0x55 /* enable config mode, issue twice */ +#define FSA_ENA6 0x44 /* enable config mode, issue twice */ +#define FSA_DISB 0xAA /* disable config mode */ +#define FSA_CR5 0x05 /* select config register 5 */ + +/* SRB : Configuration Data Register for SMC FDC37C66xGT */ +#define FSB_DSDEF 0xE7 /* bit mask for density select in reg 5 */ +#define FSB_DSLO 0x10 /* density select = LOW (300 rpm) */ +#define FSB_DSHI 0x18 /* density select = HIGH (360 rpm) */ + +/* DOR : Digital Output Register */ +#define FD_DMTREN 0xF0 +#define FD_D3MTR 0x80 +#define FD_D2MTR 0x40 +#define FD_DBMTR 0x20 +#define FD_DAMTR 0x10 +#define FD_ENABLE 0x08 /* DMA gate */ +#define FD_RSETZ 0x04 +#define FD_DRSEL 0x03 +#define FD_DBSEL 0x01 +#define FD_DASEL 0x00 + +#define ENAB_MCA_INT 0x00 + + +/* MSR - Main Status Register */ +#define MS_RQM 0x80 /* request for master - chip needs attention */ +#define MS_DIO 0x40 /* data in/out, 1 = remove bytes from fifo */ +#define MS_NDM 0x20 /* non-dma mode - 1 during execution phase */ +#define MS_CB 0x10 /* controller busy, command in progress */ +#define MS_D3B 0x08 /* drive 3 busy */ +#define MS_D2B 0x04 /* drive 2 busy */ +#define MS_DBB 0x02 /* drive B busy */ +#define MS_DAB 0x01 /* drive A busy */ + +#define FDC_RQM_RETRY 300 + + +/* DIR : Digital Input Register */ +#define FDI_DKCHG 0x80 /* this is inverted in Model 30 mode */ +#define FDI_DMAGAT 0x08 /* Model 30: DMA gate */ +#define FDI_NOPREC 0x04 /* Model 30 only */ +#define FDI_DRATE 0x03 /* Model 30: selected datarate mask */ + + +/* DSR : Datarate Select Register on 82072 and 82077AA */ +#define FSR_SWR 0x80 /* software reset */ +#define FSR_PD 0x40 /* power down */ +#define FSR_PRECP 0x1C /* precomp mask */ +#define FSR_DRATE 0x3 /* datarate select mask */ + + +/* CCR : Configuration Control Register, aka Datarate Select Register */ +#define FCC_NOPREC 0x4 /* Model 30 only */ +#define FCC_DRATE 0x3 /* datarate select mask */ + + +/* + * Floppy controller command opcodes + */ +#define FO_MODE 0x01 /* National PC8477 types only */ +#define FO_RDTRK 0x02 +#define FO_SPEC 0x03 +#define FO_SDRV 0x04 /* read status register 3 */ +#define FO_WRDAT 0x05 +#define FO_RDDAT 0x06 +#define FO_RECAL 0x07 +#define FO_SINT 0x08 +#define FO_WRDEL 0x09 +#define FO_RDID 0x0A +#define FO_RDDEL 0x0C +#define FO_FRMT 0x0D +#define FO_SEEK 0x0F +#define FO_VRSN 0x10 /* get version */ +#define FO_PERP 0x12 /* perpendicular mode */ +#define FO_CNFG 0x13 /* configure */ +#define FO_NSC 0x18 /* identify National chip */ + + /* option bits */ +#define FO_MT 0x80 /* multi-track operation */ +#define FO_MFM 0x40 /* double & high density disks */ +#define FO_FM 0x00 /* single density disks */ +#define FO_SK 0x20 /* skip deleted adr mark */ + + +#define S0_ICMASK 0xC0 /* status register 0 */ +#define S0_XRDY 0xC0 +#define S0_IVCMD 0x80 +#define S0_ABTERM 0x40 +#define S0_SEKEND 0x20 +#define S0_ECHK 0x10 +#define S0_NOTRDY 0x08 + +#define S1_EOCYL 0x80 /* status register 1 */ +#define S1_CRCER 0x20 +#define S1_OVRUN 0x10 +#define S1_NODATA 0x04 +#define S1_MADMK 0x01 + +#define S3_FAULT 0x80 /* status register 3 */ +#define S3_WPROT 0x40 +#define S3_DRRDY 0x20 +#define S3_TRK0 0x10 +#define S3_2SIDE 0x08 +#define S3_HEAD 0x04 +#define S3_UNIT 0x03 + + +/* + * controller chip values + */ +#define i8272A 0x8272 +#define uPD72064 0x72064 /* NEC */ +/* enhanced floppy controllers */ +#define i82077 0x82077 +#define PC87322 0x87322 /* National Semiconducter */ +#define FDC37C665 0x37c665 /* SMC */ +#define FDC37C666 0x37c666 /* SMC */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_I8272A_H */ diff --git a/illumos-x86_64/usr/include/sys/ia.h b/illumos-x86_64/usr/include/sys/ia.h new file mode 100644 index 00000000..567c121b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ia.h @@ -0,0 +1,98 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + * Copyright 2019 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_IA_H +#define _SYS_IA_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define dcmn_err if (ia_debug) cmn_err +#define IA_OFF_QUANTUM 1 +#define IA_OFF_PRIORITY 20 +#define iaumdpri (iapp->ia_umdpri) +#define iamedumdpri (ia_maxumdpri >> 1) + +/* + * interactive dispatcher parameter table entry + */ +typedef struct iadpent { + pri_t ia_globpri; /* global (class independent) priority */ + long ia_quantum; /* time quantum given to procs at this level */ + pri_t ia_tqexp; /* ia_umdpri assigned when proc at this level */ + /* exceeds its time quantum */ + pri_t ia_slpret; /* ia_umdpri assigned when proc at this level */ + /* returns to user mode after sleeping */ + short ia_maxwait; /* bumped to ia_lwait if more than ia_maxwait */ + /* secs elapse before receiving full quantum */ + short ia_lwait; /* ia_umdpri assigned if ia_dispwait exceeds */ + /* ia_maxwait */ +} iadpent_t; + + +/* + * time-sharing class specific thread structure + */ +typedef struct iaproc { + long ia_timeleft; /* time remaining in procs quantum */ + pri_t ia_cpupri; /* system controlled component of ia_umdpri */ + pri_t ia_uprilim; /* user priority limit */ + pri_t ia_upri; /* user priority */ + pri_t ia_umdpri; /* user mode priority within ia class */ + char ia_nice; /* nice value for compatibility */ + unsigned char ia_flags; /* flags defined below */ + short ia_dispwait; /* number of wall clock seconds since start */ + /* of quantum (not reset upon preemption */ + kthread_t *ia_tp; /* pointer to thread */ + int *ia_pstatp; /* pointer to p_stat */ + pri_t *ia_pprip; /* pointer to t_pri */ + uint_t *ia_pflagp; /* pointer to p_flag */ + struct iaproc *ia_next; /* link to next iaproc on list */ + struct iaproc *ia_prev; /* link to previous iaproc on list */ + int ia_mode; /* interactive on/off */ +} iaproc_t; + + +/* flags */ +/* Formerly: IAKPRI 0x01 - thread at kernel model priority */ +#define IABACKQ 0x02 /* thread goes to back of disp q when preempted */ +#define IASLEPT 0x04 /* thread had long-term suspend - give new slice */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IA_H */ diff --git a/illumos-x86_64/usr/include/sys/iapriocntl.h b/illumos-x86_64/usr/include/sys/iapriocntl.h new file mode 100644 index 00000000..d35577f9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/iapriocntl.h @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_IAPRIOCNTL_H +#define _SYS_IAPRIOCNTL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Interactive class specific structures for the priocntl system call. + */ + +/* + * Beginning of iaparms structure must match tsparms structure so they + * can be used interchangeably. + */ + +typedef struct iaparms { + pri_t ia_uprilim; /* user priority limit */ + pri_t ia_upri; /* user priority */ + int ia_mode; /* interactive on/off */ +} iaparms_t; + +typedef struct iaclass { + id_t pc_cid; + int pc_clparms[PC_CLPARMSZ]; +} iaclass_t; + +typedef struct iainfo { + pri_t ia_maxupri; /* configured limits of user priority range */ +} iainfo_t; + +#define IA_NOCHANGE -32768 +#define IAMAXUPRI 60 +#define IAOFFUPRI 29 +#define IANPROCS 60 +#define IA_INTERACTIVE_OFF 0x00 /* thread is not interactive */ +#define IA_SET_INTERACTIVE 0x01 /* thread is interactive */ +#define IA_BOOST 10 /* value for boost */ + +/* + * Interactive class specific keys for the priocntl system call + * varargs interface. + */ +#define IA_KY_UPRILIM 1 /* user priority limit */ +#define IA_KY_UPRI 2 /* user priority */ +#define IA_KY_MODE 3 /* interactive on/off */ + +/* + * The following is used by the dispadmin(8) command for + * scheduler administration and is not for general use. + */ + +#ifdef _SYSCALL32 +/* Data structure for ILP32 clients */ +typedef struct iaadmin32 { + caddr32_t ia_dpents; + int16_t ia_ndpents; + int16_t ia_cmd; +} iaadmin32_t; +#endif /* _SYSCALL32 */ + +typedef struct iaadmin { + struct iadpent *ia_dpents; + short ia_ndpents; + short ia_cmd; +} iaadmin_t; + +#define IA_GETDPSIZE 1 +#define IA_GETDPTBL 2 +#define IA_SETDPTBL 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IAPRIOCNTL_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/adapters/hermon/hermon_ioctl.h b/illumos-x86_64/usr/include/sys/ib/adapters/hermon/hermon_ioctl.h new file mode 100644 index 00000000..1660bdb3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/adapters/hermon/hermon_ioctl.h @@ -0,0 +1,293 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_ADAPTERS_HERMON_IOCTL_H +#define _SYS_IB_ADAPTERS_HERMON_IOCTL_H + +#include + +/* + * hermon_ioctl.h + * Contains all of the prototypes, #defines, and structures necessary + * for all ioctl access into the driver. This includes everything + * necessary for updating firmware, accessing the hermon flash device, + * providing interfaces for VTS. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +int hermon_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, + int *rvalp); + +/* + * Enumerated type for the Hermon ioctl() interface types + */ +/* + * originally, to make a unique set of IOCTLs but now share the actual + * value w/ tavor & arbel (memfree) to make VTS consistent & simpler + * + * #define HERMON_IOCTL ('h' << 8) + */ +#define HERMON_IOCTL ('t' << 8) + +#ifdef DEBUG +typedef enum { + HERMON_IOCTL_FLASH_READ = HERMON_IOCTL | 0x00, + HERMON_IOCTL_FLASH_WRITE = HERMON_IOCTL | 0x01, + HERMON_IOCTL_FLASH_ERASE = HERMON_IOCTL | 0x02, + HERMON_IOCTL_FLASH_INIT = HERMON_IOCTL | 0x03, + HERMON_IOCTL_FLASH_FINI = HERMON_IOCTL | 0x04, + HERMON_IOCTL_REG_WRITE = HERMON_IOCTL | 0x10, + HERMON_IOCTL_REG_READ = HERMON_IOCTL | 0x11, + HERMON_IOCTL_LOOPBACK = HERMON_IOCTL | 0x20, + HERMON_IOCTL_INFO = HERMON_IOCTL | 0x21, + HERMON_IOCTL_PORTS = HERMON_IOCTL | 0x22, + HERMON_IOCTL_DDR_READ = HERMON_IOCTL | 0x23, + HERMON_IOCTL_WRITE_BOOT_ADDR = HERMON_IOCTL | 0x24 +} hermon_ioctl_enum_t; +#else +typedef enum { + HERMON_IOCTL_FLASH_READ = HERMON_IOCTL | 0x00, + HERMON_IOCTL_FLASH_WRITE = HERMON_IOCTL | 0x01, + HERMON_IOCTL_FLASH_ERASE = HERMON_IOCTL | 0x02, + HERMON_IOCTL_FLASH_INIT = HERMON_IOCTL | 0x03, + HERMON_IOCTL_FLASH_FINI = HERMON_IOCTL | 0x04, + HERMON_IOCTL_LOOPBACK = HERMON_IOCTL | 0x20, + HERMON_IOCTL_INFO = HERMON_IOCTL | 0x21, + HERMON_IOCTL_PORTS = HERMON_IOCTL | 0x22, + HERMON_IOCTL_DDR_READ = HERMON_IOCTL | 0x23, + HERMON_IOCTL_WRITE_BOOT_ADDR = HERMON_IOCTL | 0x24 +} hermon_ioctl_enum_t; +#endif /* DEBUG */ + +/* + * Specific operations for each of the flash ioctl interfaces + */ +#define HERMON_FLASH_READ_SECTOR 0x01 +#define HERMON_FLASH_READ_QUADLET 0x02 +#define HERMON_FLASH_WRITE_SECTOR 0x01 +#define HERMON_FLASH_WRITE_BYTE 0x02 +#define HERMON_FLASH_ERASE_SECTOR 0x01 +#define HERMON_FLASH_ERASE_CHIP 0x02 + +/* + * Default values for the flash (overridden by CFI info, if available) + */ +#define HERMON_FLASH_SECTOR_SZ_DEFAULT 0x10000 +#define HERMON_FLASH_DEVICE_SZ_DEFAULT 0x400000 +#define HERMON_FLASH_SPI_LOG_SECTOR_SIZE 0x10 +#define HERMON_FLASH_SPI_SECTOR_SIZE 0x10000 +#define HERMON_FLASH_SPI_DEVICE_SIZE 0x200000 + +/* + * CFI (Common Flash Interface) initialization + */ +#define HERMON_FLASH_CFI_INIT 0x98 + +/* For compatability */ +#define HERMON_FLASH_CFI_SIZE 0x4C +#define HERMON_FLASH_CFI_SIZE_QUADLET HERMON_FLASH_CFI_SIZE >> 2 + +/* + * Expand CFI data size to support the Intel Expanded Command Set. + */ +#define HERMON_CFI_INFO_SIZE 0x100 +#define HERMON_CFI_INFO_QSIZE HERMON_CFI_INFO_SIZE >> 2 + +/* + * Mellanox uses two different parallel Flash devices for Hermon + * HCAs: the AMD AM29LV033C and the Intel 28F320J3C. The AM29LV033C + * utilizes the AMD Standard CFI command set while the 28F320J3C + * utliizes the Intel Extended CFI command set. Additionally, serial + * SPI flash is supported, such as the STMicroelectronics M25Pxx family + * of SPI Flash parts. + */ +#define HERMON_FLASH_INTEL_CMDSET 0x0001 +#define HERMON_FLASH_AMD_CMDSET 0x0002 +#define HERMON_FLASH_SPI_CMDSET 0x0003 +#define HERMON_FLASH_UNKNOWN_CMDSET 0XFFFF + +/* + * The firmware version structure used in HERMON_IOCTL_INFO and + * HERMON_IOCTL_FLASH_INIT interfaces. The structure consists of major, + * minor and subminor portions for firmware revision number. + */ +typedef struct hermon_fw_info_ioctl_s { + uint32_t afi_maj; + uint32_t afi_min; + uint32_t afi_sub; +} hermon_fw_info_ioctl_t; + +/* + * structure used for read, write, and erase flash routines + * Supported fields for each type: + * read_sector: af_type, af_sector, af_sector_num + * read_quadlet: af_type, af_addr, af_quadlet + * write_sector: af_type, af_sector, af_sector_num + * write_byte: af_type, af_addr, af_byte + * erase_sector: af_type, af_sector_num + * erase_chip: af_type + * + * The 'tf_sector' field must point to a sector sized portion of memory, as + * all sector read/write ioctl calls are done as one complete sector only. + */ +typedef struct hermon_flash_ioctl_s { + uint32_t af_type; + caddr_t af_sector; + uint32_t af_sector_num; + uint32_t af_addr; + uint32_t af_quadlet; + uint8_t af_byte; +} hermon_flash_ioctl_t; + +/* Structure used for flash init interface */ +typedef struct hermon_flash_init_ioctl_s { + uint32_t af_hwrev; + hermon_fw_info_ioctl_t af_fwrev; + uint32_t af_cfi_info[HERMON_FLASH_CFI_SIZE_QUADLET]; + char af_hwpn[64]; + int af_pn_len; +} hermon_flash_init_ioctl_t; + +/* + * The structure used for Hermon register read/write interface. + * The "trg_reg_set" field indicates the register set (the BAR) from which + * the access is desired (HERMON_CMD_BAR, HERMON_UAR_BAR, or HERMON_DDR_BAR). + * The "trg_offset" and "trg_data" fields indicate the register and either + * the destination or source of the data to be read/written. + */ +typedef struct hermon_reg_ioctl_s { + uint_t arg_reg_set; + uint_t arg_offset; + uint32_t arg_data; +} hermon_reg_ioctl_t; + + +/* + * Hermon VTS IOCTL revision number. This revision number is currently + * expected to be passed in all Hermon VTS ioctl interfaces. + */ +#define HERMON_VTS_IOCTL_REVISION 1 + +/* + * The port structure used in HERMON_IOCTL_PORTS interface. + * Each port has an associated guid, port number, and IBA-defined + * logical port state. + */ +typedef struct hermon_stat_port_ioctl_s { + uint64_t asp_guid; + uint32_t asp_port_num; + uint32_t asp_state; +} hermon_stat_port_ioctl_t; + +/* + * The structure used for the HERMON_IOCTL_PORTS interface. + * The number of ports and a buffer large enough for 256 + * port structures will be supplied by the caller. The + * revision should be set to HERMON_VTS_IOCTL_REVISION. The + * number of ports ("tp_num_ports") is always returned, + * regardless of success or failure otherwise. + */ +typedef struct hermon_ports_ioctl_s { + uint_t ap_revision; + hermon_stat_port_ioctl_t *ap_ports; + uint8_t ap_num_ports; +} hermon_ports_ioctl_t; + +/* + * These are the status codes that can be returned by the + * HERMON_IOCTL_LOOPBACK test. They are returned as part of + * the hermon_loopback_ioctl_t struct (below). + */ +typedef enum { + HERMON_LOOPBACK_SUCCESS, + HERMON_LOOPBACK_INVALID_REVISION, + HERMON_LOOPBACK_INVALID_PORT, + HERMON_LOOPBACK_PROT_DOMAIN_ALLOC_FAIL, + HERMON_LOOPBACK_SEND_BUF_INVALID, + HERMON_LOOPBACK_SEND_BUF_MEM_REGION_ALLOC_FAIL, + HERMON_LOOPBACK_SEND_BUF_COPY_FAIL, + HERMON_LOOPBACK_RECV_BUF_MEM_REGION_ALLOC_FAIL, + HERMON_LOOPBACK_XMIT_SEND_CQ_ALLOC_FAIL, + HERMON_LOOPBACK_XMIT_RECV_CQ_ALLOC_FAIL, + HERMON_LOOPBACK_XMIT_QP_ALLOC_FAIL, + HERMON_LOOPBACK_RECV_SEND_CQ_ALLOC_FAIL, + HERMON_LOOPBACK_RECV_RECV_CQ_ALLOC_FAIL, + HERMON_LOOPBACK_RECV_QP_ALLOC_FAIL, + HERMON_LOOPBACK_XMIT_QP_INIT_FAIL, + HERMON_LOOPBACK_XMIT_QP_RTR_FAIL, + HERMON_LOOPBACK_XMIT_QP_RTS_FAIL, + HERMON_LOOPBACK_RECV_QP_INIT_FAIL, + HERMON_LOOPBACK_RECV_QP_RTR_FAIL, + HERMON_LOOPBACK_RECV_QP_RTS_FAIL, + HERMON_LOOPBACK_WQE_POST_FAIL, + HERMON_LOOPBACK_CQ_POLL_FAIL, + HERMON_LOOPBACK_SEND_RECV_COMPARE_FAIL +} hermon_loopback_error_t; + +/* + * The structure used for HERMON_IOCTL_LOOPBACK interface. + * It defines the port number, number of iterations, wait duration, + * number of retries and the data pattern to be sent. Upon return, + * the driver will supply the number of iterations succesfully + * completed, and the kind of failure (if any, along with the failing + * data pattern). + */ +typedef struct hermon_loopback_ioctl_s { + uint_t alb_revision; + caddr_t alb_send_buf; + caddr_t alb_fail_buf; + uint_t alb_buf_sz; + uint_t alb_num_iter; + uint_t alb_pass_done; + uint_t alb_timeout; + hermon_loopback_error_t alb_error_type; + uint8_t alb_port_num; + uint8_t alb_num_retry; +} hermon_loopback_ioctl_t; + +/* + * The structure used for the HERMON_IOCTL_INFO interface. It + * includes firmware version, hardware version, accessable + * range of adapter DDR memory, and adapter flash memory size. + */ +typedef struct hermon_info_ioctl_s { + uint_t ai_revision; + hermon_fw_info_ioctl_t ai_fw_rev; + uint32_t ai_hw_rev; + uint_t ai_flash_sz; + uint_t rsvd1; /* DDR start */ + uint_t rsvd2; /* DDR end */ +} hermon_info_ioctl_t; + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_ADAPTERS_HERMON_IOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/adapters/mlnx_umap.h b/illumos-x86_64/usr/include/sys/ib/adapters/mlnx_umap.h new file mode 100644 index 00000000..22a04f9c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/adapters/mlnx_umap.h @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_ADAPTERS_MLNX_UMAP_H +#define _SYS_IB_ADAPTERS_MLNX_UMAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * mlnx_umap.h + * Contains all of the definions necessary for communicating the data + * needed for direct userland access to resources on Mellanox HCAs. + */ + +/* + * Note: The structs in this file are used in the interface(s) + * between kernel service drivers, e.g. daplt, and the libraries + * on top of them, e.g. udapl_tavor.so.1. When any of the + * structs in this file change, any version control between the + * kernel service driver and the library will need to change. + * + * There is a version control on the structs defined here. The library + * (consumer of structs from ibt_ci_data_out()) must verify a version + * field to correctly read the data provided by the kernel driver + * (tavor, arbel, and hermon). + */ + +#define MLNX_UMAP_IF_VERSION 2 + +/* + * The following defines are used in the database type field for each database + * entry. They specify the type of object (UAR pages, PIDs, CQ, QP, and MR + * umemcookie) that corresponds to the database key value. On database queries, + * this type value must match the search criterion. + */ +#define MLNX_UMAP_UARPG_RSRC 0x11 +#define MLNX_UMAP_BLUEFLAMEPG_RSRC 0x12 +#define MLNX_UMAP_PID_RSRC 0x22 +#define MLNX_UMAP_CQMEM_RSRC 0x33 +#define MLNX_UMAP_QPMEM_RSRC 0x44 +#define MLNX_UMAP_MRMEM_RSRC 0x55 +#define MLNX_UMAP_SRQMEM_RSRC 0x66 +#define MLNX_UMAP_DBRMEM_RSRC 0x77 +#define MLNX_UMAP_RSRC_TYPE_MASK 0xFF +#define MLNX_UMAP_RSRC_TYPE_SHIFT 8 + +/* umap structures */ + +typedef struct mlnx_umap_cq_data_out_s { + uint_t mcq_rev; + uint32_t mcq_cqnum; + uint64_t mcq_mapoffset; + uint64_t mcq_maplen; + uint32_t mcq_numcqe; + uint32_t mcq_cqesz; + + /* Arbel/Hermon doorbell records */ + uint64_t mcq_armdbr_mapoffset; + uint64_t mcq_armdbr_maplen; + uint64_t mcq_polldbr_mapoffset; + uint64_t mcq_polldbr_maplen; + uint32_t mcq_armdbr_offset; + uint32_t mcq_polldbr_offset; +} mlnx_umap_cq_data_out_t; + +typedef struct mlnx_umap_qp_data_out_s { + uint_t mqp_rev; + uint32_t mqp_qpnum; + uint64_t mqp_mapoffset; + uint64_t mqp_maplen; + + uint32_t mqp_rq_off; + uint32_t mqp_rq_desc_addr; + uint32_t mqp_rq_numwqe; + uint32_t mqp_rq_wqesz; + + uint32_t mqp_sq_off; + uint32_t mqp_sq_desc_addr; + uint32_t mqp_sq_numwqe; + uint32_t mqp_sq_wqesz; + + /* Arbel/Hermon doorbell records */ + uint64_t mqp_sdbr_mapoffset; + uint64_t mqp_sdbr_maplen; + uint64_t mqp_rdbr_mapoffset; + uint64_t mqp_rdbr_maplen; + uint32_t mqp_sdbr_offset; + uint32_t mqp_rdbr_offset; + + /* Hermon send queue headroom, in units of wqes */ + uint32_t mqp_sq_headroomwqes; +} mlnx_umap_qp_data_out_t; + +typedef struct mlnx_umap_srq_data_out_s { + uint_t msrq_rev; + uint32_t msrq_srqnum; + uint64_t msrq_mapoffset; + uint64_t msrq_maplen; + uint32_t msrq_desc_addr; + uint32_t msrq_numwqe; + uint32_t msrq_wqesz; + uint32_t msrq_pad1; /* reserved */ + + /* Arbel/Hermon doorbell records */ + uint64_t msrq_rdbr_mapoffset; + uint64_t msrq_rdbr_maplen; + uint32_t msrq_rdbr_offset; + uint32_t msrq_reserved; +} mlnx_umap_srq_data_out_t; + +typedef struct mlnx_umap_pd_data_out_s { + uint_t mpd_rev; + uint32_t mpd_pdnum; +} mlnx_umap_pd_data_out_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_ADAPTERS_MLNX_UMAP_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/adapters/tavor/tavor_ioctl.h b/illumos-x86_64/usr/include/sys/ib/adapters/tavor/tavor_ioctl.h new file mode 100644 index 00000000..11c533f8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/adapters/tavor/tavor_ioctl.h @@ -0,0 +1,293 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_ADAPTERS_TAVOR_IOCTL_H +#define _SYS_IB_ADAPTERS_TAVOR_IOCTL_H + +#include + +/* + * tavor_ioctl.h + * Contains all of the prototypes, #defines, and structures necessary + * for all ioctl access into the driver. This includes everything + * necessary for updating firmware, accessing the tavor flash device, + * providing interfaces for VTS. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +int tavor_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, + int *rvalp); + +/* + * Enumerated type for the Tavor ioctl() interface types + */ +#define TAVOR_IOCTL ('t' << 8) +#ifdef DEBUG +typedef enum { + TAVOR_IOCTL_FLASH_READ = TAVOR_IOCTL | 0x00, + TAVOR_IOCTL_FLASH_WRITE = TAVOR_IOCTL | 0x01, + TAVOR_IOCTL_FLASH_ERASE = TAVOR_IOCTL | 0x02, + TAVOR_IOCTL_FLASH_INIT = TAVOR_IOCTL | 0x03, + TAVOR_IOCTL_FLASH_FINI = TAVOR_IOCTL | 0x04, + TAVOR_IOCTL_REG_WRITE = TAVOR_IOCTL | 0x10, + TAVOR_IOCTL_REG_READ = TAVOR_IOCTL | 0x11, + TAVOR_IOCTL_LOOPBACK = TAVOR_IOCTL | 0x20, + TAVOR_IOCTL_INFO = TAVOR_IOCTL | 0x21, + TAVOR_IOCTL_PORTS = TAVOR_IOCTL | 0x22, + TAVOR_IOCTL_DDR_READ = TAVOR_IOCTL | 0x23 +} tavor_ioctl_enum_t; +#else +typedef enum { + TAVOR_IOCTL_FLASH_READ = TAVOR_IOCTL | 0x00, + TAVOR_IOCTL_FLASH_WRITE = TAVOR_IOCTL | 0x01, + TAVOR_IOCTL_FLASH_ERASE = TAVOR_IOCTL | 0x02, + TAVOR_IOCTL_FLASH_INIT = TAVOR_IOCTL | 0x03, + TAVOR_IOCTL_FLASH_FINI = TAVOR_IOCTL | 0x04, + TAVOR_IOCTL_LOOPBACK = TAVOR_IOCTL | 0x20, + TAVOR_IOCTL_INFO = TAVOR_IOCTL | 0x21, + TAVOR_IOCTL_PORTS = TAVOR_IOCTL | 0x22, + TAVOR_IOCTL_DDR_READ = TAVOR_IOCTL | 0x23 +} tavor_ioctl_enum_t; +#endif /* DEBUG */ + +/* + * Specific operations for each of the flash ioctl interfaces + */ +#define TAVOR_FLASH_READ_SECTOR 0x01 +#define TAVOR_FLASH_READ_QUADLET 0x02 +#define TAVOR_FLASH_WRITE_SECTOR 0x01 +#define TAVOR_FLASH_WRITE_BYTE 0x02 +#define TAVOR_FLASH_ERASE_SECTOR 0x01 +#define TAVOR_FLASH_ERASE_CHIP 0x02 + +/* + * Default values for the flash (overridden by CFI info, if available) + */ +#define TAVOR_FLASH_SECTOR_SZ_DEFAULT 0x10000 +#define TAVOR_FLASH_DEVICE_SZ_DEFAULT 0x400000 + +/* + * CFI (Common Flash Interface) initialization + */ +#define TAVOR_FLASH_CFI_INIT 0x98 + +/* + * Needed for compatability + */ +#define TAVOR_FLASH_CFI_SIZE 0x4c +#define TAVOR_FLASH_CFI_SIZE_QUADLET TAVOR_FLASH_CFI_SIZE >> 2 + +/* + * Expand CFI data size to support the Intel Expanded Command Set. + */ +#define TAVOR_CFI_INFO_SIZE 0x100 +#define TAVOR_CFI_INFO_QSIZE TAVOR_CFI_INFO_SIZE >> 2 + +/* + * Mellanox uses two different parallel Flash devices for their + * HCAs that tavor supports. They are the AMD AM29LV033C and the + * Intel 28F320J3C. The AM29LV033C utilizes the AMD Standard CFI + * command set while the 28F320J3C utliizes the Intel Extended + * CFI command set. + */ +#define TAVOR_FLASH_INTEL_CMDSET 0x0001 +#define TAVOR_FLASH_AMD_CMDSET 0x0002 +#define TAVOR_FLASH_UNKNOWN_CMDSET 0XFFFF + +/* + * The firmware version structure used in TAVOR_IOCTL_INFO and + * TAVOR_IOCTL_FLASH_INIT interfaces. The structure consists of major, + * minor and subminor portions for firmware revision number. + */ +typedef struct tavor_fw_info_ioctl_s { + uint32_t tfi_maj; + uint32_t tfi_min; + uint32_t tfi_sub; +} tavor_fw_info_ioctl_t; + +/* + * structure used for read, write, and erase flash routines + * Supported fields for each type: + * read_sector: tf_type, tf_sector, tf_sector_num + * read_quadlet: tf_type, tf_addr, tf_quadlet + * write_sector: tf_type, tf_sector, tf_sector_num + * write_byte: tf_type, tf_addr, tf_byte + * erase_sector: tf_type, tf_sector_num + * erase_chip: tf_type + * + * The 'tf_sector' field must point to a sector sized portion of memory, as + * all sector read/write ioctl calls are done as one complete sector only. + */ +typedef struct tavor_flash_ioctl_s { + uint32_t tf_type; + caddr_t tf_sector; + uint32_t tf_sector_num; + uint32_t tf_addr; + uint32_t tf_quadlet; + uint8_t tf_byte; +} tavor_flash_ioctl_t; + +/* Structure used for flash init interface */ +typedef struct tavor_flash_init_ioctl_s { + uint32_t tf_hwrev; + tavor_fw_info_ioctl_t tf_fwrev; + uint32_t tf_cfi_info[TAVOR_FLASH_CFI_SIZE_QUADLET]; + char tf_hwpn[64]; + int tf_pn_len; +} tavor_flash_init_ioctl_t; + +/* + * The structure used for Tavor register read/write interface. + * The "trg_reg_set" field indicates the register set (the BAR) from which + * the access is desired (TAVOR_CMD_BAR, TAVOR_UAR_BAR, or TAVOR_DDR_BAR). + * The "trg_offset" and "trg_data" fields indicate the register and either + * the destination or source of the data to be read/written. + */ +typedef struct tavor_reg_ioctl_s { + uint_t trg_reg_set; + uint_t trg_offset; + uint32_t trg_data; +} tavor_reg_ioctl_t; + + +/* + * Tavor VTS IOCTL revision number. This revision number is currently + * expected to be passed in all Tavor VTS ioctl interfaces. + */ +#define TAVOR_VTS_IOCTL_REVISION 1 + +/* + * The port structure used in TAVOR_IOCTL_PORTS interface. + * Each port has an associated guid, port number, and IBA-defined + * logical port state. + */ +typedef struct tavor_stat_port_ioctl_s { + uint64_t tsp_guid; + uint32_t tsp_port_num; + uint32_t tsp_state; +} tavor_stat_port_ioctl_t; + +/* + * The structure used for the TAVOR_IOCTL_PORTS interface. + * The number of ports and a buffer large enough for 256 + * port structures will be supplied by the caller. The + * revision should be set to TAVOR_VTS_IOCTL_REVISION. The + * number of ports ("tp_num_ports") is always returned, + * regardless of success or failure otherwise. + */ +typedef struct tavor_ports_ioctl_s { + uint_t tp_revision; + tavor_stat_port_ioctl_t *tp_ports; + uint8_t tp_num_ports; +} tavor_ports_ioctl_t; + +/* + * The structure used for TAVOR_IOCTL_DDR_READ interface. + * It includes byte offset within DDR from which to read + * a 32-bit value (offset will be rounded off to 32-bit + * alignment). + */ +typedef struct tavor_ddr_read_ioctl_s { + uint_t tdr_revision; + uint_t tdr_offset; + uint32_t tdr_data; +} tavor_ddr_read_ioctl_t; + +/* + * These are the status codes that can be returned by the + * TAVOR_IOCTL_LOOPBACK test. They are returned as part of + * the tavor_loopback_ioctl_t struct (below). + */ +typedef enum { + TAVOR_LOOPBACK_SUCCESS, + TAVOR_LOOPBACK_INVALID_REVISION, + TAVOR_LOOPBACK_INVALID_PORT, + TAVOR_LOOPBACK_PROT_DOMAIN_ALLOC_FAIL, + TAVOR_LOOPBACK_SEND_BUF_INVALID, + TAVOR_LOOPBACK_SEND_BUF_MEM_REGION_ALLOC_FAIL, + TAVOR_LOOPBACK_SEND_BUF_COPY_FAIL, + TAVOR_LOOPBACK_RECV_BUF_MEM_REGION_ALLOC_FAIL, + TAVOR_LOOPBACK_XMIT_SEND_CQ_ALLOC_FAIL, + TAVOR_LOOPBACK_XMIT_RECV_CQ_ALLOC_FAIL, + TAVOR_LOOPBACK_XMIT_QP_ALLOC_FAIL, + TAVOR_LOOPBACK_RECV_SEND_CQ_ALLOC_FAIL, + TAVOR_LOOPBACK_RECV_RECV_CQ_ALLOC_FAIL, + TAVOR_LOOPBACK_RECV_QP_ALLOC_FAIL, + TAVOR_LOOPBACK_XMIT_QP_INIT_FAIL, + TAVOR_LOOPBACK_XMIT_QP_RTR_FAIL, + TAVOR_LOOPBACK_XMIT_QP_RTS_FAIL, + TAVOR_LOOPBACK_RECV_QP_INIT_FAIL, + TAVOR_LOOPBACK_RECV_QP_RTR_FAIL, + TAVOR_LOOPBACK_RECV_QP_RTS_FAIL, + TAVOR_LOOPBACK_WQE_POST_FAIL, + TAVOR_LOOPBACK_CQ_POLL_FAIL, + TAVOR_LOOPBACK_SEND_RECV_COMPARE_FAIL +} tavor_loopback_error_t; + +/* + * The structure used for TAVOR_IOCTL_LOOPBACK interface. + * It defines the port number, number of iterations, wait duration, + * number of retries and the data pattern to be sent. Upon return, + * the driver will supply the number of iterations succesfully + * completed, and the kind of failure (if any, along with the failing + * data pattern). + */ +typedef struct tavor_loopback_ioctl_s { + uint_t tlb_revision; + caddr_t tlb_send_buf; + caddr_t tlb_fail_buf; + uint_t tlb_buf_sz; + uint_t tlb_num_iter; + uint_t tlb_pass_done; + uint_t tlb_timeout; + tavor_loopback_error_t tlb_error_type; + uint8_t tlb_port_num; + uint8_t tlb_num_retry; +} tavor_loopback_ioctl_t; + +/* + * The structure used for the TAVOR_IOCTL_INFO interface. It + * includes firmware version, hardware version, accessable + * range of adapter DDR memory, and adapter flash memory size. + */ +typedef struct tavor_info_ioctl_s { + uint_t ti_revision; + tavor_fw_info_ioctl_t ti_fw_rev; + uint32_t ti_hw_rev; + uint_t ti_flash_sz; + uint_t ti_mem_start_offset; + uint_t ti_mem_end_offset; +} tavor_info_ioctl_t; + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_ADAPTERS_TAVOR_IOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/ibd/ibd.h b/illumos-x86_64/usr/include/sys/ib/clients/ibd/ibd.h new file mode 100644 index 00000000..3fc25d7c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/ibd/ibd.h @@ -0,0 +1,1348 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_IBD_H +#define _SYS_IB_CLIENTS_IBD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* The following macros are used in both ibd.c and ibd_cm.c */ + +/* + * Completion queue polling control + */ +#define IBD_CQ_POLLING 0x1 +#define IBD_REDO_CQ_POLLING 0x2 + +/* + * Maximum length for returning chained mps back to crossbow. + * Also used as the maximum number of rx wc's polled at a time. + */ +#define IBD_MAX_RX_MP_LEN 16 + +/* + * When doing multiple-send-wr, this value determines how many to do at + * a time (in a single ibt_post_send). + */ +#define IBD_MAX_TX_POST_MULTIPLE 4 + +/* + * Flag bits for resources to reap + */ +#define IBD_RSRC_SWQE 0x1 +#define IBD_RSRC_LSOBUF 0x2 +#define IBD_RSRC_RC_SWQE 0x4 +#define IBD_RSRC_RC_TX_LARGEBUF 0x8 + +/* + * Async operation types + */ +#define IBD_ASYNC_GETAH 1 +#define IBD_ASYNC_JOIN 2 +#define IBD_ASYNC_LEAVE 3 +#define IBD_ASYNC_PROMON 4 +#define IBD_ASYNC_PROMOFF 5 +#define IBD_ASYNC_REAP 6 +#define IBD_ASYNC_TRAP 7 +#define IBD_ASYNC_SCHED 8 +#define IBD_ASYNC_LINK 9 +#define IBD_ASYNC_EXIT 10 +#define IBD_ASYNC_RC_TOO_BIG 11 +#define IBD_ASYNC_RC_CLOSE_ACT_CHAN 12 +#define IBD_ASYNC_RC_RECYCLE_ACE 13 +#define IBD_ASYNC_RC_CLOSE_PAS_CHAN 14 + +/* + * State of IBD driver initialization during attach/m_start + */ +#define IBD_DRV_STATE_INITIALIZED 0x000001 +#define IBD_DRV_RXINTR_ADDED 0x000002 +#define IBD_DRV_TXINTR_ADDED 0x000004 +#define IBD_DRV_IBTL_ATTACH_DONE 0x000008 +#define IBD_DRV_HCA_OPENED 0x000010 +#define IBD_DRV_PD_ALLOCD 0x000020 +#define IBD_DRV_MAC_REGISTERED 0x000040 +#define IBD_DRV_PORT_DETAILS_OBTAINED 0x000080 +#define IBD_DRV_BCAST_GROUP_FOUND 0x000100 +#define IBD_DRV_ACACHE_INITIALIZED 0x000200 +#define IBD_DRV_CQS_ALLOCD 0x000400 +#define IBD_DRV_UD_CHANNEL_SETUP 0x000800 +#define IBD_DRV_TXLIST_ALLOCD 0x001000 +#define IBD_DRV_SCQ_NOTIFY_ENABLED 0x002000 +#define IBD_DRV_RXLIST_ALLOCD 0x004000 +#define IBD_DRV_BCAST_GROUP_JOINED 0x008000 +#define IBD_DRV_ASYNC_THR_CREATED 0x010000 +#define IBD_DRV_RCQ_NOTIFY_ENABLED 0x020000 +#define IBD_DRV_SM_NOTICES_REGISTERED 0x040000 +#define IBD_DRV_STARTED 0x080000 +#define IBD_DRV_RC_SRQ_ALLOCD 0x100000 +#define IBD_DRV_RC_LARGEBUF_ALLOCD 0x200000 +#define IBD_DRV_RC_LISTEN 0x400000 +#ifdef DEBUG +#define IBD_DRV_RC_PRIVATE_STATE 0x800000 +#endif +#define IBD_DRV_IN_DELETION 0x1000000 +#define IBD_DRV_IN_LATE_HCA_INIT 0x2000000 +#define IBD_DRV_REQ_LIST_INITED 0x4000000 +#define IBD_DRV_RC_TIMEOUT 0x8000000 + +/* + * Miscellaneous constants + */ +#define IBD_SEND 0 +#define IBD_RECV 1 + +/* Tunables defaults and limits */ +#define IBD_LINK_MODE_UD 0 +#define IBD_LINK_MODE_RC 1 + +#define IBD_DEF_LINK_MODE IBD_LINK_MODE_RC +#define IBD_DEF_LSO_POLICY B_TRUE +#define IBD_DEF_NUM_LSO_BUFS 1024 +#define IBD_DEF_CREATE_BCAST_GROUP B_TRUE +#define IBD_DEF_COALESCE_COMPLETIONS B_TRUE +#define IBD_DEF_UD_RX_COMP_COUNT 4 +#define IBD_DEF_UD_RX_COMP_USEC 10 +#define IBD_DEF_UD_TX_COMP_COUNT 16 +#define IBD_DEF_UD_TX_COMP_USEC 300 +#define IBD_DEF_RC_RX_COMP_COUNT 4 +#define IBD_DEF_RC_RX_COMP_USEC 10 +#define IBD_DEF_RC_TX_COMP_COUNT 10 +#define IBD_DEF_RC_TX_COMP_USEC 300 +#define IBD_DEF_UD_TX_COPY_THRESH 4096 +#define IBD_DEF_RC_RX_COPY_THRESH 4096 +#define IBD_DEF_RC_TX_COPY_THRESH 4096 +#define IBD_DEF_UD_NUM_RWQE 4000 +#define IBD_DEF_UD_NUM_SWQE 4000 +#define IBD_DEF_RC_ENABLE_SRQ B_TRUE +#if defined(__i386) +#define IBD_DEF_RC_NUM_RWQE 511 +#define IBD_DEF_RC_NUM_SWQE 255 +#else +#define IBD_DEF_RC_NUM_RWQE 2047 +#define IBD_DEF_RC_NUM_SWQE 511 +#endif +#define IBD_DEF_NUM_AH 256 +#define IBD_DEF_HASH_SIZE 32 +#define IBD_DEF_RC_NUM_SRQ (IBD_DEF_RC_NUM_RWQE - 1) +#define IBD_DEF_RC_RX_RWQE_THRESH (IBD_DEF_RC_NUM_RWQE >> 2) + +/* Tunable limits */ +#define IBD_MIN_NUM_LSO_BUFS 512 +#define IBD_MAX_NUM_LSO_BUFS 4096 +#define IBD_MIN_UD_TX_COPY_THRESH 2048 +#define IBD_MAX_UD_TX_COPY_THRESH 65536 +#define IBD_MIN_UD_NUM_SWQE 512 +#define IBD_MAX_UD_NUM_SWQE 8000 +#define IBD_MIN_UD_NUM_RWQE 512 +#define IBD_MAX_UD_NUM_RWQE 8000 +#define IBD_MIN_NUM_AH 32 +#define IBD_MAX_NUM_AH 8192 +#define IBD_MIN_HASH_SIZE 32 +#define IBD_MAX_HASH_SIZE 1024 + +#if defined(__i386) +#define IBD_MIN_RC_NUM_SWQE 255 +#else +#define IBD_MIN_RC_NUM_SWQE 511 +#endif +#define IBD_MAX_RC_NUM_SWQE 8000 +#define IBD_MIN_RC_NUM_RWQE 511 +#define IBD_MAX_RC_NUM_RWQE 8000 +#define IBD_MIN_RC_RX_COPY_THRESH 1500 +#define IBD_MAX_RC_RX_COPY_THRESH 65520 +#define IBD_MIN_RC_TX_COPY_THRESH 1500 +#define IBD_MAX_RC_TX_COPY_THRESH 65520 +#define IBD_MIN_RC_NUM_SRQ (IBD_MIN_RC_NUM_RWQE - 1) +#define IBD_MIN_RC_RX_RWQE_THRESH (IBD_MIN_RC_NUM_RWQE >> 2) + +/* + * Thresholds + * + * When waiting for resources (swqes or lso buffers) to become available, + * the first two thresholds below determine how long to wait before informing + * the network layer to start sending packets again. The IBD_TX_POLL_THRESH + * determines how low the available swqes should go before we start polling + * the completion queue. + */ +#define IBD_FREE_LSOS_THRESH 8 +#define IBD_FREE_SWQES_THRESH 20 +#define IBD_TX_POLL_THRESH 80 + +#ifdef DEBUG +void debug_print(int l, char *fmt, ...); +#define DPRINT debug_print +#else +#define DPRINT 0 && +#endif + +/* + * AH and MCE active list manipulation: + * + * Multicast disable requests and MCG delete traps are two cases + * where the active AH entry for the mcg (if any unreferenced one exists) + * will be moved to the free list (to force the next Tx to the mcg to + * join the MCG in SendOnly mode). Port up handling will also move AHs + * from active to free list. + * + * In the case when some transmits are still pending on an entry + * for an mcg, but a multicast disable has already been issued on the + * mcg, there are some options to consider to preserve the join state + * to ensure the emitted packet is properly routed on the IBA fabric. + * For the AH, we can + * 1. take out of active list at multicast disable time. + * 2. take out of active list only when last pending Tx completes. + * For the MCE, we can + * 3. take out of active list at multicast disable time. + * 4. take out of active list only when last pending Tx completes. + * 5. move from active list to stale list at multicast disable time. + * We choose to use 2,4. We use option 4 so that if a multicast enable + * is tried before the pending Tx completes, the enable code finds the + * mce in the active list and just has to make sure it will not be reaped + * (ie the mcg leave done) when the pending Tx does complete. Alternatively, + * a stale list (#5) that would be checked in the enable code would need + * to be implemented. Option 2 is used, because otherwise, a Tx attempt + * after the multicast disable would try to put an AH in the active list, + * and associate the mce it finds in the active list to this new AH, + * whereas the mce is already associated with the previous AH (taken off + * the active list), and will be removed once the pending Tx's complete + * (unless a reference count on mce's is implemented). One implication of + * using 2,4 is that new Tx's posted before the pending Tx's complete will + * grab new references on the AH, further delaying the leave. + * + * In the case of mcg delete (or create) trap when the port is sendonly + * joined, the AH and MCE handling is different: the AH and MCE has to be + * immediately taken off the active lists (forcing a join and path lookup + * at the next Tx is the only guaranteed means of ensuring a proper Tx + * to an mcg as it is repeatedly created and deleted and goes thru + * reincarnations). + * + * When a port is already sendonly joined, and a multicast enable is + * attempted, the same mce structure is promoted; this ensures only a + * single mce on the active list tracks the most powerful join state. + * + * In the case of port up event handling, the MCE for sendonly membership + * is freed up, and the ACE is put into the free list as soon as possible + * (depending on whether posted Tx's have completed). For fullmembership + * MCE's though, the ACE is similarly handled; but the MCE is kept around + * (a re-JOIN is attempted) only if the DLPI leave has not already been + * done; else the mce is deconstructed (mc_fullreap case). + * + * MCG creation and deletion trap handling: + * + * These traps are unreliable (meaning sometimes the trap might never + * be delivered to the subscribed nodes) and may arrive out-of-order + * since they use UD transport. An alternative to relying on these + * unreliable traps is to poll for mcg presence every so often, but + * instead of doing that, we try to be as conservative as possible + * while handling the traps, and hope that the traps do arrive at + * the subscribed nodes soon. Note that if a node is fullmember + * joined to an mcg, it can not possibly receive a mcg create/delete + * trap for that mcg (by fullmember definition); if it does, it is + * an old trap from a previous incarnation of the mcg. + * + * Whenever a trap is received, the driver cleans up its sendonly + * membership to the group; we choose to do a sendonly leave even + * on a creation trap to handle the case of a prior deletion of the mcg + * having gone unnoticed. Consider an example scenario: + * T1: MCG M is deleted, and fires off deletion trap D1. + * T2: MCG M is recreated, fires off creation trap C1, which is lost. + * T3: Node N tries to transmit to M, joining in sendonly mode. + * T4: MCG M is deleted, and fires off deletion trap D2. + * T5: N receives a deletion trap, but can not distinguish D1 from D2. + * If the trap is D2, then a LEAVE is not required, since the mcg + * is already deleted; but if it is D1, a LEAVE is required. A safe + * approach is to always LEAVE, but the SM may be confused if it + * receives a LEAVE without a prior JOIN. + * + * Management of the non-membership to an mcg is similar to the above, + * except that if the interface is in promiscuous mode, it is required + * to attempt to re-join the mcg after receiving a trap. Unfortunately, + * if the re-join attempt fails (in which case a warning message needs + * to be printed), it is not clear whether it failed due to the mcg not + * existing, or some fabric/hca issues, due to the delayed nature of + * trap delivery. Querying the SA to establish presence/absence of the + * mcg is also racy at best. Thus, the driver just prints a warning + * message when it can not rejoin after receiving a create trap, although + * this might be (on rare occasions) a mis-warning if the create trap is + * received after the mcg was deleted. + */ + +/* + * Implementation of atomic "recycle" bits and reference count + * on address handles. This utilizes the fact that max reference + * count on any handle is limited by number of send wqes, thus + * high bits in the ac_ref field can be used as the recycle bits, + * and only the low bits hold the number of pending Tx requests. + * This atomic AH reference counting allows the Tx completion + * handler not to acquire the id_ac_mutex to process every completion, + * thus reducing lock contention problems between completion and + * the Tx path. + */ +#define CYCLEVAL 0x80000 +#define CLEAR_REFCYCLE(ace) (ace)->ac_ref = 0 +#define CYCLE_SET(ace) (((ace)->ac_ref & CYCLEVAL) == CYCLEVAL) +#define GET_REF(ace) ((ace)->ac_ref) +#define GET_REF_CYCLE(ace) ( \ + /* \ + * Make sure "cycle" bit is set. \ + */ \ + ASSERT(CYCLE_SET(ace)), \ + ((ace)->ac_ref & ~(CYCLEVAL)) \ +) +#define INC_REF(ace, num) { \ + atomic_add_32(&(ace)->ac_ref, num); \ +} +#define SET_CYCLE_IF_REF(ace) ( \ + CYCLE_SET(ace) ? B_TRUE : \ + atomic_add_32_nv(&ace->ac_ref, CYCLEVAL) == \ + CYCLEVAL ? \ + /* \ + * Clear the "cycle" bit we just set; \ + * ref count known to be 0 from above. \ + */ \ + CLEAR_REFCYCLE(ace), B_FALSE : \ + /* \ + * We set "cycle" bit; let caller know. \ + */ \ + B_TRUE \ +) +#define DEC_REF_DO_CYCLE(ace) ( \ + atomic_dec_32_nv(&ace->ac_ref) == CYCLEVAL ? \ + /* \ + * Ref count known to be 0 from above. \ + */ \ + B_TRUE : \ + B_FALSE \ +) + +/* + * Address handle entries maintained by the driver are kept in the + * free and active lists. Each entry starts out in the free list; + * it migrates to the active list when primed using ibt_get_paths() + * and ibt_modify_ud_dest() for transmission to a specific destination. + * In the active list, the entry has a reference count indicating the + * number of ongoing/uncompleted transmits that reference it. The + * entry is left in the active list even after the reference count + * goes to 0, since successive transmits can find it there and do + * not need to set up another entry (ie the path information is + * cached using the active list). Entries on the active list are + * also hashed using the destination link address as a key for faster + * lookups during transmits. + * + * For any destination address (unicast or multicast, whatever the + * join states), there will be at most one entry in the active list. + * Entries with a 0 reference count on the active list can be reused + * for a transmit to a new destination, if the free list is empty. + * + * The AH free list insertion/deletion is protected with the id_ac_mutex, + * since the async thread and Tx callback handlers insert/delete. The + * active list does not need a lock (all operations are done by the + * async thread) but updates to the reference count are atomically + * done (increments done by Tx path, decrements by the Tx callback handler). + */ +#define IBD_ACACHE_INSERT_FREE(state, ce) \ + list_insert_head(&state->id_ah_free, ce) +#define IBD_ACACHE_GET_FREE(state) \ + list_get_head(&state->id_ah_free) +#define IBD_ACACHE_INSERT_ACTIVE(state, ce) { \ + int _ret_; \ + list_insert_head(&state->id_ah_active, ce); \ + _ret_ = mod_hash_insert(state->id_ah_active_hash, \ + (mod_hash_key_t)&ce->ac_mac, (mod_hash_val_t)ce); \ + ASSERT(_ret_ == 0); \ + state->id_ac_hot_ace = ce; \ +} +#define IBD_ACACHE_PULLOUT_ACTIVE(state, ce) { \ + list_remove(&state->id_ah_active, ce); \ + if (state->id_ac_hot_ace == ce) \ + state->id_ac_hot_ace = NULL; \ + (void) mod_hash_remove(state->id_ah_active_hash, \ + (mod_hash_key_t)&ce->ac_mac, (mod_hash_val_t)ce); \ +} +#define IBD_ACACHE_GET_ACTIVE(state) \ + list_get_head(&state->id_ah_active) + +/* + * Padding for nd6 Neighbor Solicitation and Advertisement needs to be at + * front of optional src/tgt link layer address. Right now Solaris inserts + * padding by default at the end. The routine which is doing is nce_xmit() + * in ip_ndp.c. It copies the nd_lla_addr after the nd_opt_hdr_t. So when + * the packet comes down from IP layer to the IBD driver, it is in the + * following format: [IPoIB_PTXHDR_T][INET6 packet][ICMP6][OPT_ND_HDR_T] + * This size is 2 bytes followed by [22 bytes of ipoib_machdr]. As a result + * machdr is not 4 byte aligned and had 2 bytes of padding at the end. + * + * The send routine at IBD driver changes this packet as follows: + * [IPoIB_HDR_T][INET6 packet][ICMP6][OPT_ND_HDR_T + 2 bytes of padding] + * followed by [22 bytes of ipoib_machdr] resulting in machdr 4 byte + * aligned. + * + * At the receiving side again ibd_process_rx takes the above packet and + * removes the two bytes of front padding and inserts it at the end. This + * is since the IP layer does not understand padding at the front. + */ +#define IBD_PAD_NSNA(ip6h, len, type) { \ + uchar_t *nd_lla_ptr; \ + icmp6_t *icmp6; \ + nd_opt_hdr_t *opt; \ + int i; \ + \ + icmp6 = (icmp6_t *)&ip6h[1]; \ + len -= sizeof (nd_neighbor_advert_t); \ + if (((icmp6->icmp6_type == ND_NEIGHBOR_SOLICIT) || \ + (icmp6->icmp6_type == ND_NEIGHBOR_ADVERT)) && \ + (len != 0)) { \ + opt = (nd_opt_hdr_t *)((uint8_t *)ip6h \ + + IPV6_HDR_LEN + sizeof (nd_neighbor_advert_t)); \ + ASSERT(opt != NULL); \ + nd_lla_ptr = (uchar_t *)&opt[1]; \ + if (type == IBD_SEND) { \ + for (i = IPOIB_ADDRL; i > 0; i--) \ + *(nd_lla_ptr + i + 1) = \ + *(nd_lla_ptr + i - 1); \ + } else { \ + for (i = 0; i < IPOIB_ADDRL; i++) \ + *(nd_lla_ptr + i) = \ + *(nd_lla_ptr + i + 2); \ + } \ + *(nd_lla_ptr + i) = 0; \ + *(nd_lla_ptr + i + 1) = 0; \ + } \ +} + + +/* + * IETF defined IPoIB encapsulation header, with 2b of ethertype + * followed by 2 reserved bytes. This is at the start of the + * datagram sent to and received over the wire by the driver. + */ +typedef struct ipoib_header { + ushort_t ipoib_type; + ushort_t ipoib_mbz; +} ipoib_hdr_t; + +#define IPOIB_HDRSIZE sizeof (struct ipoib_header) + +/* + * IETF defined IPoIB link address; IBA QPN, followed by GID, + * which has a prefix and suffix, as reported via ARP. + */ +typedef struct ipoib_mac { + uint32_t ipoib_qpn; + uint32_t ipoib_gidpref[2]; + uint32_t ipoib_gidsuff[2]; +} ipoib_mac_t; + +#define IPOIB_ADDRL sizeof (struct ipoib_mac) + +/* + * Pseudo header prepended to datagram in DLIOCRAW transmit path + * and when GLD hands the datagram to the gldm_send entry point. + */ +typedef struct ipoib_ptxhdr { + ipoib_mac_t ipoib_dest; + ipoib_hdr_t ipoib_rhdr; +} ipoib_ptxhdr_t; + +#define IPOIBDLSAP(p, offset) ((ipoib_ptxhdr_t *)((caddr_t)(p)+offset)) + +/* + * The pseudo-GRH structure that sits before the data in the + * receive buffer, and is overlaid on top of the real GRH. + * The driver sets the ipoib_vertcflow to 0 if the pseudo-GRH + * does not hold valid information. If it is indicated valid, + * the driver must additionally provide the sender's qpn in + * network byte order in ipoib_sqpn, and not touch the + * remaining parts which were DMA'ed in by the IBA hardware. + */ +typedef struct ipoib_pgrh { + uint32_t ipoib_vertcflow; + uint32_t ipoib_sqpn; + uint32_t ipoib_sgid_pref[2]; + uint32_t ipoib_sgid_suff[2]; + uint32_t ipoib_dgid_pref[2]; + uint32_t ipoib_dgid_suff[2]; +} ipoib_pgrh_t; + +/* + * The GRH is also dma'ed into recv buffers, thus space needs + * to be allocated for them. + */ +#define IPOIB_GRH_SIZE sizeof (ipoib_pgrh_t) + +/* support the RC (reliable connected) mode */ +#define IBD_MAC_ADDR_RC 0x80000000 +/* support the UC (unreliable connected) mode */ +#define IBD_MAC_ADDR_UC 0x40000000 + +#define IBD_RC_SERVICE_ID 0x100000000000000ULL + +/* + * Legacy OFED had used a wrong service ID (one additional zero digit) for + * many years. To interop with legacy OFED, we support this wrong service ID + * here. + */ +#define IBD_RC_SERVICE_ID_OFED_INTEROP 0x1000000000000000ULL + +#define IBD_RC_MIN_CQ_SIZE 0x7f + +/* Number of ibt_wc_t provided for each RC channel */ +#define IBD_RC_MAX_CQ_WC 0x3f + +#if defined(_KERNEL) && !defined(_BOOT) + +#include +#include +#include +#include +#include +#include + +/* State of a reliable connected channel (ibd_rc_chan_t->chan_state) */ +typedef enum { + IBD_RC_STATE_INIT = 0, + + /* Active side */ + IBD_RC_STATE_ACT_REP_RECV, /* reply received */ + IBD_RC_STATE_ACT_ESTAB, /* established, ready to send */ + IBD_RC_STATE_ACT_REJECT, /* rejected */ + /* Someone else is closing this channel, please don't re-close it */ + IBD_RC_STATE_ACT_CLOSING, + IBD_RC_STATE_ACT_CLOSED, + IBD_RC_STATE_ACT_ERROR, + + /* Passive side */ + IBD_RC_STATE_PAS_REQ_RECV, /* request received */ + IBD_RC_STATE_PAS_ESTAB, /* established, ready to receive */ + IBD_RC_STATE_PAS_REJECT, /* rejected */ + + IBD_RC_STATE_PAS_CLOSED +} ibd_rc_chan_state_t; + +/* + * Structure to encapsulate various types of async requests. + */ +typedef struct ibd_acache_rq { + struct list_node rq_list; /* list of pending work */ + int rq_op; /* what operation */ + ipoib_mac_t rq_mac; + ib_gid_t rq_gid; + void *rq_ptr; + void *rq_ptr2; +} ibd_req_t; + +typedef struct ibd_mcache { + struct list_node mc_list; /* full/non list */ + uint8_t mc_jstate; + boolean_t mc_fullreap; + ibt_mcg_info_t mc_info; + ibd_req_t mc_req; /* to queue LEAVE req */ +} ibd_mce_t; + +typedef struct ibd_acache_s { + struct list_node ac_list; /* free/active list */ + ibt_ud_dest_hdl_t ac_dest; + ipoib_mac_t ac_mac; + uint32_t ac_ref; + ibd_mce_t *ac_mce; /* for MCG AHs */ + + /* For Reliable Connected mode */ + struct ibd_rc_chan_s *ac_chan; + /* protect tx_too_big_ongoing */ + kmutex_t tx_too_big_mutex; + /* Deal with too big packet */ + boolean_t tx_too_big_ongoing; +} ibd_ace_t; + +#define IBD_MAX_SQSEG 59 +#define IBD_MAX_RQSEG 1 + +typedef enum { + IBD_WQE_SEND, + IBD_WQE_RECV +} ibd_wqe_type_t; + +typedef enum { + IBD_WQE_TXBUF = 1, + IBD_WQE_LSOBUF = 2, + IBD_WQE_MAPPED = 3, + IBD_WQE_RC_COPYBUF = 4 +} ibd_wqe_buftype_t; + +#ifdef DEBUG +typedef struct ibd_rc_stat_s { + kstat_named_t rc_rcv_trans_byte; + kstat_named_t rc_rcv_trans_pkt; + kstat_named_t rc_rcv_copy_byte; + kstat_named_t rc_rcv_copy_pkt; + kstat_named_t rc_rcv_alloc_fail; + + kstat_named_t rc_rcq_err; /* fail in rcq handler */ + + kstat_named_t rc_rwqe_short; /* short rwqe */ + + kstat_named_t rc_xmt_bytes; + /* pkt size <= state->id_rc_tx_copy_thresh */ + kstat_named_t rc_xmt_small_pkt; + kstat_named_t rc_xmt_fragmented_pkt; + /* fail in ibt_map_mem_iov() */ + kstat_named_t rc_xmt_map_fail_pkt; + /* succ in ibt_map_mem_iov() */ + kstat_named_t rc_xmt_map_succ_pkt; + + kstat_named_t rc_ace_not_found; /* ace not found */ + /* no swqe even after recycle */ + kstat_named_t rc_scq_no_swqe; + /* no tx large buf even after recycle */ + kstat_named_t rc_scq_no_largebuf; + + /* short swqe in ibd_send() */ + kstat_named_t rc_swqe_short; + /* call mac_tx_update() when there is enough swqe */ + kstat_named_t rc_swqe_mac_update; + /* short large buf in ibd_send() */ + kstat_named_t rc_xmt_buf_short; + /* call mac_tx_update() when there is enough Tx large buffers */ + kstat_named_t rc_xmt_buf_mac_update; + + kstat_named_t rc_conn_succ; /* # of success connect */ + kstat_named_t rc_conn_fail; /* # of fail connect */ + /* ace->ac_chan == NULL for unicast packet */ + kstat_named_t rc_null_conn; + /* not in active established state */ + kstat_named_t rc_no_estab_conn; + + kstat_named_t rc_act_close; /* call ibd_rc_act_close() */ + kstat_named_t rc_pas_close; /* call ibd_rc_pas_close() */ + kstat_named_t rc_delay_ace_recycle; + kstat_named_t rc_act_close_simultaneous; + + kstat_named_t rc_reset_cnt; /* # of Reset RC channel */ + kstat_named_t rc_timeout_act; + kstat_named_t rc_timeout_pas; +} ibd_rc_stat_t; +#endif + +typedef struct ibd_rc_chan_list_s { + /* This mutex protects chan_list and ibd_rc_chan_t.next */ + kmutex_t chan_list_mutex; + struct ibd_rc_chan_s *chan_list; +} ibd_rc_chan_list_t; + +typedef struct ibd_rc_tx_largebuf_s { + struct ibd_rc_tx_largebuf_s *lb_next; + uint8_t *lb_buf; +} ibd_rc_tx_largebuf_t; + +/* + * Pre-registered copybuf used for send and receive + */ +typedef struct ibd_copybuf_s { + ibt_wr_ds_t ic_sgl; + uint8_t *ic_bufaddr; +} ibd_copybuf_t; + +typedef struct ibd_wqe_s { + struct ibd_wqe_s *w_next; + ibd_copybuf_t w_copybuf; + mblk_t *im_mblk; +} ibd_wqe_t; + +/* + * Send WQE + */ +typedef struct ibd_swqe_s { + ibd_wqe_t w_ibd_swqe; + ibd_wqe_buftype_t w_buftype; + ibt_send_wr_t w_swr; + ibd_ace_t *w_ahandle; + ibt_mi_hdl_t w_mi_hdl; + ibt_wr_ds_t w_sgl[IBD_MAX_SQSEG]; + ibd_rc_tx_largebuf_t *w_rc_tx_largebuf; +} ibd_swqe_t; + +#define swqe_next w_ibd_swqe.w_next +#define swqe_copybuf w_ibd_swqe.w_copybuf +#define swqe_im_mblk w_ibd_swqe.im_mblk +#define SWQE_TO_WQE(swqe) (ibd_wqe_t *)&((swqe)->w_ibd_swqe) +#define WQE_TO_SWQE(wqe) (ibd_swqe_t *)wqe + +/* + * Receive WQE + */ +typedef struct ibd_rwqe_s { + ibd_wqe_t w_ibd_rwqe; + struct ibd_state_s *w_state; + ibt_recv_wr_t w_rwr; + frtn_t w_freemsg_cb; + boolean_t w_freeing_wqe; + struct ibd_rc_chan_s *w_chan; +} ibd_rwqe_t; + +#define rwqe_next w_ibd_rwqe.w_next +#define rwqe_copybuf w_ibd_rwqe.w_copybuf +#define rwqe_im_mblk w_ibd_rwqe.im_mblk +#define RWQE_TO_WQE(rwqe) (ibd_wqe_t *)&((rwqe)->w_ibd_rwqe) +#define WQE_TO_RWQE(wqe) (ibd_rwqe_t *)wqe + +typedef struct ibd_list_s { + kmutex_t dl_mutex; + ibd_wqe_t *dl_head; + union { + boolean_t pending_sends; + uint32_t bufs_outstanding; + } ustat; + uint32_t dl_cnt; +} ibd_list_t; + +#define dl_pending_sends ustat.pending_sends +#define dl_bufs_outstanding ustat.bufs_outstanding + +/* + * LSO buffers + * + * Under normal circumstances we should never need to use any buffer + * that's larger than MTU. Unfortunately, IB HCA has limitations + * on the length of SGL that are much smaller than those for regular + * ethernet NICs. Since the network layer doesn't care to limit the + * number of mblk fragments in any send mp chain, we end up having to + * use these larger-than-MTU sized (larger than id_tx_buf_sz actually) + * buffers occasionally. + */ +typedef struct ibd_lsobuf_s { + struct ibd_lsobuf_s *lb_next; + uint8_t *lb_buf; + int lb_isfree; +} ibd_lsobuf_t; + +typedef struct ibd_lsobkt_s { + uint8_t *bkt_mem; + ibd_lsobuf_t *bkt_bufl; + ibd_lsobuf_t *bkt_free_head; + ibt_mr_hdl_t bkt_mr_hdl; + ibt_mr_desc_t bkt_mr_desc; + uint_t bkt_nelem; + uint_t bkt_nfree; +} ibd_lsobkt_t; + +#define IBD_PORT_DRIVER 0x1 +#define IBD_PARTITION_OBJ 0x2 + +/* + * Posting to a single software rx post queue is contentious, + * so break it out to (multiple) an array of queues. + * + * Try to ensure rx_queue structs fall in different cache lines using a filler. + * Note: the RX_QUEUE_CACHE_LINE needs to change if the struct changes. + */ +#define RX_QUEUE_CACHE_LINE \ + (64 - (sizeof (kmutex_t) + sizeof (ibd_wqe_t *) + sizeof (uint_t))) +typedef struct ibd_rx_queue_s { + kmutex_t rx_post_lock; + ibd_wqe_t *rx_head; + uint_t rx_cnt; + uint8_t rx_pad[RX_QUEUE_CACHE_LINE]; +} ibd_rx_queue_t; + +/* + * This structure maintains information per port per HCA + * (per network interface). + */ +typedef struct ibd_state_s { + uint_t id_type; + dev_info_t *id_dip; + ibt_clnt_hdl_t id_ibt_hdl; + ibt_hca_hdl_t id_hca_hdl; + ibt_pd_hdl_t id_pd_hdl; + kmem_cache_t *id_req_kmc; + + ibd_list_t id_tx_rel_list; + + uint32_t id_running; + + uint32_t id_max_sqseg; + uint32_t id_max_sqseg_hiwm; + ibd_list_t id_tx_list; + ddi_softintr_t id_tx; + uint32_t id_tx_sends; + + kmutex_t id_txpost_lock; + ibd_swqe_t *id_tx_head; + ibd_swqe_t *id_tx_tail; + int id_tx_busy; + + uint_t id_tx_buf_sz; + uint8_t *id_tx_bufs; + ibd_swqe_t *id_tx_wqes; + ibt_mr_hdl_t id_tx_mr_hdl; + ibt_mr_desc_t id_tx_mr_desc; + + kmutex_t id_lso_lock; + ibd_lsobkt_t *id_lso; + + kmutex_t id_scq_poll_lock; + int id_scq_poll_busy; + + ibt_cq_hdl_t id_scq_hdl; + ibt_wc_t *id_txwcs; + uint32_t id_txwcs_size; + + int id_rx_nqueues; + ibd_rx_queue_t *id_rx_queues; + int id_rx_post_queue_index; + uint32_t id_rx_post_active; + + ibd_rwqe_t *id_rx_wqes; + uint8_t *id_rx_bufs; + ibt_mr_hdl_t id_rx_mr_hdl; + ibt_mr_desc_t id_rx_mr_desc; + uint_t id_rx_buf_sz; + /* + * id_ud_num_rwqe + * Number of "receive WQE" elements that will be allocated and used + * by ibd. This parameter is limited by the maximum channel size of + * the HCA. Each buffer in the receive wqe will be of MTU size. + */ + uint32_t id_ud_num_rwqe; + ibd_list_t id_rx_list; + ddi_softintr_t id_rx; + uint32_t id_rx_bufs_outstanding_limit; + uint32_t id_rx_allocb; + uint32_t id_rx_allocb_failed; + ibd_list_t id_rx_free_list; + + kmutex_t id_rcq_poll_lock; + int id_rcq_poll_busy; + uint32_t id_rxwcs_size; + ibt_wc_t *id_rxwcs; + ibt_cq_hdl_t id_rcq_hdl; + + ibt_channel_hdl_t id_chnl_hdl; + ib_pkey_t id_pkey; + uint16_t id_pkix; + uint8_t id_port; + ibt_mcg_info_t *id_mcinfo; + + mac_handle_t id_mh; + mac_resource_handle_t id_rh; + ib_gid_t id_sgid; + ib_qpn_t id_qpnum; + ipoib_mac_t id_macaddr; + ib_gid_t id_mgid; + ipoib_mac_t id_bcaddr; + + int id_mtu; + uchar_t id_scope; + + kmutex_t id_acache_req_lock; + kcondvar_t id_acache_req_cv; + struct list id_req_list; + kt_did_t id_async_thrid; + + kmutex_t id_ac_mutex; + ibd_ace_t *id_ac_hot_ace; + struct list id_ah_active; + struct list id_ah_free; + ipoib_mac_t id_ah_addr; + ibd_req_t id_ah_req; + char id_ah_op; + uint64_t id_ah_error; + ibd_ace_t *id_ac_list; + mod_hash_t *id_ah_active_hash; + + kmutex_t id_mc_mutex; + struct list id_mc_full; + struct list id_mc_non; + + kmutex_t id_trap_lock; + kcondvar_t id_trap_cv; + boolean_t id_trap_stop; + uint32_t id_trap_inprog; + + char id_prom_op; + + kmutex_t id_sched_lock; + int id_sched_needed; + int id_sched_cnt; + int id_sched_lso_cnt; + + kmutex_t id_link_mutex; + link_state_t id_link_state; + uint64_t id_link_speed; + + uint64_t id_num_intrs; + uint64_t id_tx_short; + /* + * id_ud_num_swqe + * Number of "send WQE" elements that will be allocated and used by + * ibd. When tuning this parameter, the size of pre-allocated, pre- + * mapped copy buffer in each of these send wqes must be taken into + * account. This copy buffer size is determined by the value of + * IBD_TX_BUF_SZ (this is currently set to the same value of + * ibd_tx_copy_thresh, but may be changed independently if needed). + */ + uint32_t id_ud_num_swqe; + + uint64_t id_xmt_bytes; + uint64_t id_rcv_bytes; + uint64_t id_multi_xmt; + uint64_t id_brd_xmt; + uint64_t id_multi_rcv; + uint64_t id_brd_rcv; + uint64_t id_xmt_pkt; + uint64_t id_rcv_pkt; + + uint32_t id_hwcksum_capab; + boolean_t id_lso_policy; + boolean_t id_lso_capable; + uint_t id_lso_maxlen; + int id_hca_res_lkey_capab; + ibt_lkey_t id_res_lkey; + + boolean_t id_bgroup_created; + kmutex_t id_macst_lock; + kcondvar_t id_macst_cv; + uint32_t id_mac_state; + + /* For Reliable Connected Mode */ + boolean_t id_enable_rc; + boolean_t rc_enable_srq; + + int rc_mtu; + uint32_t rc_tx_max_sqseg; + /* + * In IPoIB over Reliable Connected mode, its mac address is added + * an "IBD_MAC_ADDR_RC" prefix. But for loopback filter in function + * ibd_process_rx(), the input mac address should not include the + * "IBD_MAC_ADDR_RC" prefix. + * + * So, we introduce the rc_macaddr_loopback for the loopback filter in + * IPoIB over Reliable Connected mode. + * + * rc_macaddr_loopback = id_macaddr excludes "IBD_MAC_ADDR_RC" prefix. + */ + ipoib_mac_t rc_macaddr_loopback; + + ibt_srv_hdl_t rc_listen_hdl; + ibt_sbind_hdl_t rc_listen_bind; + ibt_srv_hdl_t rc_listen_hdl_OFED_interop; + ibt_sbind_hdl_t rc_listen_bind_OFED_interop; + + ibd_rc_chan_list_t rc_pass_chan_list; + /* obsolete active channel list */ + ibd_rc_chan_list_t rc_obs_act_chan_list; + + kmutex_t rc_ace_recycle_lock; + ibd_ace_t *rc_ace_recycle; + + /* Send */ + /* + * This mutex protects rc_tx_largebuf_free_head, rc_tx_largebuf_nfree + * and ibd_rc_tx_largebuf_t->lb_next + */ + kmutex_t rc_tx_large_bufs_lock; + ibd_rc_tx_largebuf_t *rc_tx_largebuf_free_head; + uint_t rc_tx_largebuf_nfree; + /* The chunk of whole Tx large buffers */ + uint8_t *rc_tx_mr_bufs; + ibt_mr_hdl_t rc_tx_mr_hdl; + ibt_mr_desc_t rc_tx_mr_desc; + ibd_rc_tx_largebuf_t *rc_tx_largebuf_desc_base; /* base addr */ + + boolean_t rc_enable_iov_map; + uint_t rc_max_sqseg_hiwm; + + /* For SRQ */ + uint32_t rc_srq_size; + ibt_srq_hdl_t rc_srq_hdl; + ibd_list_t rc_srq_rwqe_list; + ibd_list_t rc_srq_free_list; + ibd_rwqe_t *rc_srq_rwqes; + uint8_t *rc_srq_rx_bufs; + ibt_mr_hdl_t rc_srq_rx_mr_hdl; + ibt_mr_desc_t rc_srq_rx_mr_desc; + + /* For chained receive */ + kmutex_t rc_rx_lock; + mblk_t *rc_rx_mp; + mblk_t *rc_rx_mp_tail; + uint32_t rc_rx_mp_len; + + uint32_t rc_num_tx_chan; + uint32_t rc_num_rx_chan; + + /* Protect rc_timeout_start and rc_timeout */ + kmutex_t rc_timeout_lock; + boolean_t rc_timeout_start; + timeout_id_t rc_timeout; + + /* Counters for RC mode */ + /* RX */ + /* + * # of Received packets. These packets are directly transferred to GLD + * without copy it + */ + uint64_t rc_rcv_trans_byte; + uint64_t rc_rcv_trans_pkt; + /* + * # of Received packets. We will allocate new buffers for these packet, + * copy their content into new buffers, then transfer to GLD + */ + uint64_t rc_rcv_copy_byte; + uint64_t rc_rcv_copy_pkt; + uint64_t rc_rcv_alloc_fail; + +#ifdef DEBUG + uint64_t rc_rwqe_short; /* short rwqe */ +#endif + + /* wc->wc_status != IBT_WC_SUCCESS */ + uint64_t rc_rcq_err; + + /* Tx */ + uint64_t rc_xmt_bytes; + + /* pkt size <= ibd_rc_tx_copy_thresh */ + uint64_t rc_xmt_small_pkt; + uint64_t rc_xmt_fragmented_pkt; + /* fail in ibt_map_mem_iov() */ + uint64_t rc_xmt_map_fail_pkt; + /* succ in ibt_map_mem_iov() */ + uint64_t rc_xmt_map_succ_pkt; + + uint64_t rc_ace_not_found; + + uint64_t rc_xmt_drop_too_long_pkt; + uint64_t rc_xmt_icmp_too_long_pkt; + uint64_t rc_xmt_reenter_too_long_pkt; + + /* short swqe in ibd_send() */ + uint64_t rc_swqe_short; + /* call mac_tx_update when there is enough swqe */ + uint64_t rc_swqe_mac_update; + /* short tx large copy buf in ibd_send() */ + uint64_t rc_xmt_buf_short; + /* call mac_tx_update when there is enough Tx copy buf */ + uint64_t rc_xmt_buf_mac_update; + + /* No swqe even after call swqe recycle function */ + uint64_t rc_scq_no_swqe; + /* No large Tx buf even after call swqe recycle function */ + uint64_t rc_scq_no_largebuf; + + /* Connection setup and close */ + uint64_t rc_conn_succ; /* time of succ connect */ + uint64_t rc_conn_fail; /* time of fail connect */ + /* ace->ac_chan == NULL for unicast packet */ + uint64_t rc_null_conn; + /* not in active established state */ + uint64_t rc_no_estab_conn; + + uint64_t rc_act_close; /* call ibd_rc_act_close() */ + uint64_t rc_pas_close; /* call ibd_rc_pas_close() */ + uint64_t rc_delay_ace_recycle; + uint64_t rc_act_close_simultaneous; + /* Fail to close a channel because someone else is still using it */ + uint64_t rc_act_close_not_clean; + /* RCQ is being invoked when closing RC channel */ + uint64_t rc_pas_close_rcq_invoking; + + /* the counter of reset RC channel */ + uint64_t rc_reset_cnt; + + uint64_t rc_timeout_act; + uint64_t rc_timeout_pas; + + /* + * Fail to stop this port because this port is connecting to a remote + * port + */ + uint64_t rc_stop_connect; + +#ifdef DEBUG + kstat_t *rc_ksp; +#endif + ib_guid_t id_hca_guid; + ib_guid_t id_port_guid; + datalink_id_t id_dlinkid; + datalink_id_t id_plinkid; + int id_port_inst; + struct ibd_state_s *id_next; + boolean_t id_force_create; + boolean_t id_bgroup_present; + uint_t id_hca_max_chan_sz; + + /* + * UD Mode Tunables + * + * id_ud_tx_copy_thresh + * This sets the threshold at which ibd will attempt to do a bcopy + * of the outgoing data into a pre-mapped buffer. IPoIB driver's + * send behavior is restricted by various parameters, so setting of + * this value must be made after careful considerations only. For + * instance, IB HCAs currently impose a relatively small limit + * (when compared to ethernet NICs) on the length of the SGL for + * transmit. On the other hand, the ip stack could send down mp + * chains that are quite long when LSO is enabled. + * + * id_num_lso_bufs + * Number of "larger-than-MTU" copy buffers to use for cases when the + * outgoing mblk chain is too fragmented to be used with + * ibt_map_mem_iov() and too large to be used with regular MTU-sized + * copy buffers. It is not recommended to tune this variable without + * understanding the application environment and/or memory resources. + * The size of each of these lso buffers is determined by the value of + * IBD_LSO_BUFSZ. + * + * id_num_ah + * Number of AH cache entries to allocate + * + * id_hash_size + * Hash table size for the active AH list + * + */ + uint_t id_ud_tx_copy_thresh; + uint_t id_num_lso_bufs; + uint_t id_num_ah; + uint_t id_hash_size; + + boolean_t id_create_broadcast_group; + + boolean_t id_allow_coalesce_comp_tuning; + uint_t id_ud_rx_comp_count; + uint_t id_ud_rx_comp_usec; + uint_t id_ud_tx_comp_count; + uint_t id_ud_tx_comp_usec; + + /* RC Mode Tunables */ + + uint_t id_rc_rx_comp_count; + uint_t id_rc_rx_comp_usec; + uint_t id_rc_tx_comp_count; + uint_t id_rc_tx_comp_usec; + /* + * id_rc_tx_copy_thresh + * This sets the threshold at which ibd will attempt to do a bcopy + * of the outgoing data into a pre-mapped buffer. + * + * id_rc_rx_copy_thresh + * If (the size of incoming buffer <= id_rc_rx_copy_thresh), ibd + * will attempt to allocate a buffer and do a bcopy of the incoming + * data into the allocated buffer. + * + * id_rc_rx_rwqe_thresh + * If (the number of available rwqe < ibd_rc_rx_rwqe_thresh), ibd + * will attempt to allocate a buffer and do a bcopy of the incoming + * data into the allocated buffer. + * + * id_rc_num_swqe + * 1) Send CQ size = ibd_rc_num_swqe + * 2) The send queue size = ibd_rc_num_swqe -1 + * 3) Number of pre-allocated Tx buffers for ibt_post_send() = + * ibd_rc_num_swqe - 1. + * + * id_rc_num_rwqe + * 1) For non-SRQ, we pre-post id_rc_num_rwqe number of WRs + * via ibt_post_receive() for receive queue of each RC channel. + * 2) For SRQ and non-SRQ, receive CQ size = id_rc_num_rwqe + * + * For SRQ + * If using SRQ, we allocate id_rc_num_srq number of buffers (the + * size of each buffer is equal to RC mtu). And post them by + * ibt_post_srq(). + * + * id_rc_num_srq + * id_rc_num_srq should not be larger than id_rc_num_rwqe, + * otherwise it will cause a bug with the following warnings: + * NOTICE: hermon0: Device Error: EQE cq overrun or protection error + * NOTICE: hermon0: Device Error: EQE local work queue catastrophic + * error + * NOTICE: ibd0: HCA GUID 0003ba0001008984 port 1 PKEY ffff + * catastrophic channel error + * NOTICE: ibd0: HCA GUID 0003ba0001008984 port 1 PKEY ffff + * completion queue error + */ + uint_t id_rc_tx_copy_thresh; + uint_t id_rc_rx_copy_thresh; + uint_t id_rc_rx_rwqe_thresh; + uint_t id_rc_num_swqe; + uint_t id_rc_num_rwqe; + uint_t id_rc_num_srq; +} ibd_state_t; + +/* + * Structures to track global IBTF data, data that is shared + * among the IBD device instances. This includes the one ibt_hdl + * and the list of service registrations. + */ +typedef struct ibd_service_s { + struct ibd_service_s *is_link; + ibt_srv_hdl_t is_srv_hdl; + ib_svc_id_t is_sid; + uint_t is_ref_cnt; +} ibd_service_t; + +typedef struct ibd_global_state_s { + kmutex_t ig_mutex; + ibt_clnt_hdl_t ig_ibt_hdl; + uint_t ig_ibt_hdl_ref_cnt; + ibd_service_t *ig_service_list; +} ibd_global_state_t; + +typedef struct ibd_rc_msg_hello_s { + uint32_t reserved_qpn; + uint32_t rx_mtu; +} ibd_rc_msg_hello_t; + +typedef struct ibd_rc_chan_s { + struct ibd_rc_chan_s *next; + /* channel hdl that we'll be using for Reliable Connected Mode */ + ibt_channel_hdl_t chan_hdl; + struct ibd_state_s *state; + ibd_ace_t *ace; + ibd_rc_chan_state_t chan_state; + + ibd_list_t tx_wqe_list; /* free wqe list */ + ibd_list_t tx_rel_list; /* for swqe recycle */ + + ibd_swqe_t *tx_wqes; + + /* start address of Tx Buffers */ + uint8_t *tx_mr_bufs; + ibt_mr_hdl_t tx_mr_hdl; + ibt_mr_desc_t tx_mr_desc; + + ibt_cq_hdl_t scq_hdl; /* Tx completion queue */ + ibt_wc_t tx_wc[IBD_RC_MAX_CQ_WC]; + ddi_softintr_t scq_softintr; + + /* For chained send */ + kmutex_t tx_post_lock; + ibd_swqe_t *tx_head; + ibd_swqe_t *tx_tail; + int tx_busy; + + /* For tx buffer recycle */ + kmutex_t tx_poll_lock; + int tx_poll_busy; + + /* Rx */ + ibd_list_t rx_wqe_list; /* used by ibt_post_recv */ + ibd_list_t rx_free_list; /* free rwqe list */ + + ibt_cq_hdl_t rcq_hdl; /* Rx completion queue */ + ibt_wc_t rx_wc[IBD_RC_MAX_CQ_WC]; + + ibd_rwqe_t *rx_rwqes; /* the chuck of whole rwqes */ + uint8_t *rx_bufs; /* the chuck of whole Rx bufs */ + ibt_mr_hdl_t rx_mr_hdl; /* ibt_mr_hdl_t for rx_bufs */ + ibt_mr_desc_t rx_mr_desc; /* ibt_mr_desc_t for rx_bufs */ + + /* For chained receive */ + kmutex_t rx_lock; + mblk_t *rx_mp; + mblk_t *rx_mp_tail; + uint32_t rx_mp_len; + + uint32_t rcq_size; + uint32_t scq_size; + /* + * We need two channels for each connection. + * One channel for Tx; another channel for Rx. + * If "is_tx_chan == B_TRUE", this is a Tx channel. + */ + boolean_t is_tx_chan; + + /* + * For the connection reaper routine ibd_rc_conn_timeout_call(). + * "is_used == B_FALSE" indicates this RC channel has not been used for + * a long (=ibd_rc_conn_timeout) time. + */ + boolean_t is_used; + /* + * When closing this channel, we need to make sure + * "chan->rcq_invoking == 0". + */ + uint32_t rcq_invoking; +} ibd_rc_chan_t; + +/* + * The following functions are defined in "ibd.c". + * They are also used by "ibd_cm.c" + */ +void ibd_print_warn(ibd_state_t *, char *, ...); +void ibd_unmap_mem(ibd_state_t *, ibd_swqe_t *); +void ibd_queue_work_slot(ibd_state_t *, ibd_req_t *, int); +boolean_t ibd_acache_recycle(ibd_state_t *, ipoib_mac_t *, boolean_t); +void ibd_dec_ref_ace(ibd_state_t *, ibd_ace_t *); +ibd_ace_t *ibd_acache_find(ibd_state_t *, ipoib_mac_t *, boolean_t, int); + +/* + * The following functions are defined in "ibd_cm.c". + * They are also used in "ibd.c". + */ +void ibd_async_rc_process_too_big(ibd_state_t *, ibd_req_t *); +void ibd_async_rc_close_act_chan(ibd_state_t *, ibd_req_t *); +void ibd_async_rc_recycle_ace(ibd_state_t *, ibd_req_t *); + +/* Connection Setup/Close Functions */ +ibt_status_t ibd_rc_listen(ibd_state_t *); +void ibd_rc_stop_listen(ibd_state_t *); +ibt_status_t ibd_rc_connect(ibd_state_t *, ibd_ace_t *, ibt_path_info_t *, + uint64_t); +void ibd_rc_try_connect(ibd_state_t *, ibd_ace_t *, ibt_path_info_t *); +void ibd_rc_signal_act_close(ibd_state_t *, ibd_ace_t *); +void ibd_rc_signal_ace_recycle(ibd_state_t *, ibd_ace_t *); +int ibd_rc_pas_close(ibd_rc_chan_t *, boolean_t, boolean_t); +void ibd_rc_close_all_chan(ibd_state_t *); +void ibd_rc_conn_timeout_call(void *carg); + +/* Receive Functions */ +int ibd_rc_init_srq_list(ibd_state_t *); +void ibd_rc_fini_srq_list(ibd_state_t *); +int ibd_rc_repost_srq_free_list(ibd_state_t *); + +/* Send Functions */ +int ibd_rc_init_tx_largebuf_list(ibd_state_t *); +void ibd_rc_fini_tx_largebuf_list(ibd_state_t *); +ibd_swqe_t *ibd_rc_acquire_swqes(ibd_rc_chan_t *); +void ibd_rc_post_send(ibd_rc_chan_t *, ibd_swqe_t *); +void ibd_rc_drain_scq(ibd_rc_chan_t *, ibt_cq_hdl_t); +void ibd_rc_tx_cleanup(ibd_swqe_t *); + +/* Others */ +void ibd_rc_get_conf(ibd_state_t *); +int ibd_rc_init_stats(ibd_state_t *); + +#endif /* _KERNEL && !_BOOT */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_IBD_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/ofa_solaris.h b/illumos-x86_64/usr/include/sys/ib/clients/of/ofa_solaris.h new file mode 100644 index 00000000..1a419263 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/ofa_solaris.h @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * + * NAME: ofa_solaris.h + * + * DESC: OFED Solaris wrapper + * + */ +#ifndef _SYS_IB_CLIENTS_OFA_SOLARIS_H +#define _SYS_IB_CLIENTS_OFA_SOLARIS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include +#include + +typedef struct ofv_resp_addr_t { + union { + uint64_t _r_ll; + uint32_t _r_la[2]; + } _resp_un; +} ofv_resp_addr_t; + +#define r_laddr _resp_un._r_ll +#ifdef _LONG_LONG_HTOL +#define r_notused _resp_un._r_la[0] +#define r_addr _resp_un._r_la[1] +#else +#define r_addr _resp_un._r_la[0] +#define r_notused _resp_un._r_la[1] +#endif /* _LONG_LONG_HTOL */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OFA_SOLARIS_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/ofed_kernel.h b/illumos-x86_64/usr/include/sys/ib/clients/of/ofed_kernel.h new file mode 100644 index 00000000..c9f8e48d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/ofed_kernel.h @@ -0,0 +1,193 @@ +/* + * This file contains definitions used in the OFED defined user/kernel + * interfaces. These are imported from the OFED headers ib_mad.h, ib_cm.h + * and ib_sa.h. Oracle elects to have and use the contents of these headers + * under and governed by the OpenIB.org BSD license (see below for full + * license text). However, the following notice accompanied the original + * version of these files: + */ + +/* ib_mad.h */ + +/* + * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. + * Copyright (c) 2004 Infinicon Corporation. All rights reserved. + * Copyright (c) 2004 Intel Corporation. All rights reserved. + * Copyright (c) 2004 Topspin Corporation. All rights reserved. + * Copyright (c) 2004-2006 Voltaire Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* ib_cm.h */ + +/* + * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. + * Copyright (c) 2004 Topspin Corporation. All rights reserved. + * Copyright (c) 2004 Voltaire Corporation. All rights reserved. + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* ib_sa.h */ + +/* + * Copyright (c) 2004 Topspin Communications. All rights reserved. + * Copyright (c) 2005 Voltaire, Inc. All rights reserved. + * Copyright (c) 2006 Intel Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef _SYS_IB_CLIENTS_OF_OFED_KERNEL_H +#define _SYS_IB_CLIENTS_OF_OFED_KERNEL_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + + +/* + * From ib_mad.h + */ +enum { + IB_MGMT_MAD_HDR = 24, + IB_MGMT_MAD_DATA = 232, + IB_MGMT_RMPP_HDR = 36, + IB_MGMT_RMPP_DATA = 220, + IB_MGMT_VENDOR_HDR = 40, + IB_MGMT_VENDOR_DATA = 216, + IB_MGMT_SA_HDR = 56, + IB_MGMT_SA_DATA = 200, + IB_MGMT_DEVICE_HDR = 64, + IB_MGMT_DEVICE_DATA = 192, + IB_MGMT_SNMP_HDR = 56, + IB_MGMT_SNMP_DATA = 64, +}; + +/* + * From ib_cm.h + */ +enum ib_cm_sidr_status { + IB_SIDR_SUCCESS, + IB_SIDR_UNSUPPORTED, + IB_SIDR_REJECT, + IB_SIDR_NO_QP, + IB_SIDR_REDIRECT, + IB_SIDR_UNSUPPORTED_VERSION +}; + +/* + * From ib_sa.h + */ +struct ib_sa_path_rec { + uint64_t service_id; + union ib_gid dgid; + union ib_gid sgid; + uint16_t dlid; + uint16_t slid; + int raw_traffic; + /* reserved */ + uint32_t flow_label; + uint8_t hop_limit; + uint8_t traffic_class; + int reversible; + uint8_t numb_path; + uint16_t pkey; + uint16_t qos_class; + uint8_t sl; + uint8_t mtu_selector; + uint8_t mtu; + uint8_t rate_selector; + uint8_t rate; + uint8_t packet_life_time_selector; + uint8_t packet_life_time; + uint8_t preference; +}; + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_OFED_KERNEL_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_addr.h b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_addr.h new file mode 100644 index 00000000..6fa63cd7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_addr.h @@ -0,0 +1,112 @@ +/* + * This file contains definitions used in OFED defined user/kernel + * interfaces. These are imported from the OFED header ib_addr.h. Oracle + * elects to have and use the contents of ib_addr.h under and governed + * by the OpenIB.org BSD license (see below for details). However, + * the following notice accompanied the original version of this file: + */ + +/* + * Copyright (c) 2005 Voltaire Inc. All rights reserved. + * Copyright (c) 2005 Intel Corporation. All rights reserved. + * + * This Software is licensed under one of the following licenses: + * + * 1) under the terms of the "Common Public License 1.0" a copy of which is + * available from the Open Source Initiative, see + * http://www.opensource.org/licenses/cpl.php. + * + * 2) under the terms of the "The BSD License" a copy of which is + * available from the Open Source Initiative, see + * http://www.opensource.org/licenses/bsd-license.php. + * + * 3) under the terms of the "GNU General Public License (GPL) Version 2" a + * copy of which is available from the Open Source Initiative, see + * http://www.opensource.org/licenses/gpl-license.php. + * + * Licensee has the right to choose one of the above licenses. + * + * Redistributions of source code must retain the above copyright + * notice and one of the license notices. + * + * Redistributions in binary form must reproduce both the above copyright + * notice, one of the license notices in the documentation + * and/or other materials provided with the distribution. + * + */ + +#ifndef _SYS_IB_CLIENTS_OF_RDMA_IB_ADDR_H +#define _SYS_IB_CLIENTS_OF_RDMA_IB_ADDR_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include +#include + +#define MAX_ADDR_LEN 32 /* Maximim hardware length */ + +struct rdma_dev_addr { + unsigned char src_dev_addr[MAX_ADDR_LEN]; + unsigned char dst_dev_addr[MAX_ADDR_LEN]; + unsigned char broadcast[MAX_ADDR_LEN]; + enum rdma_node_type dev_type; +}; + +static inline int ip_addr_size(struct sockaddr *addr) +{ + return addr->sa_family == AF_INET6 ? + sizeof (struct sockaddr_in6) : + sizeof (struct sockaddr_in); +} + +static inline uint16_t ib_addr_get_pkey(struct rdma_dev_addr *dev_addr) +{ + return (((uint16_t)dev_addr->broadcast[8] << 8) | + (uint16_t)dev_addr->broadcast[9]); +} + +static inline void ib_addr_set_pkey(struct rdma_dev_addr *dev_addr, + uint16_t pkey) +{ + dev_addr->broadcast[8] = pkey >> 8; + dev_addr->broadcast[9] = (unsigned char) pkey; +} + +static inline void ib_addr_get_mgid(struct rdma_dev_addr *dev_addr, + union ib_gid *gid) +{ + (void) memcpy(gid, dev_addr->broadcast + 4, sizeof (*gid)); +} + +static inline void ib_addr_get_sgid(struct rdma_dev_addr *dev_addr, + union ib_gid *gid) +{ + (void) memcpy(gid, dev_addr->src_dev_addr + 4, sizeof (*gid)); +} + +static inline void ib_addr_set_sgid(struct rdma_dev_addr *dev_addr, + union ib_gid *gid) +{ + (void) memcpy(dev_addr->src_dev_addr + 4, gid, sizeof (*gid)); +} + +static inline void ib_addr_get_dgid(struct rdma_dev_addr *dev_addr, + union ib_gid *gid) +{ + (void) memcpy(gid, dev_addr->dst_dev_addr + 4, sizeof (*gid)); +} + +static inline void ib_addr_set_dgid(struct rdma_dev_addr *dev_addr, + union ib_gid *gid) +{ + (void) memcpy(dev_addr->dst_dev_addr + 4, gid, sizeof (*gid)); +} + + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_RDMA_IB_ADDR_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_mad.h b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_mad.h new file mode 100644 index 00000000..b25a9b30 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_mad.h @@ -0,0 +1,179 @@ +/* + * This file contains definitions used in OFED defined user/kernel + * interfaces. These are imported from the OFED header ib_user_mad.h. Oracle + * elects to have and use the contents of ib_user_mad.h under and governed + * by the OpenIB.org BSD license (see below for full license text). However, + * the following notice accompanied the original version of this file: + */ + +/* + * Copyright (c) 2004 Topspin Communications. All rights reserved. + * Copyright (c) 2005 Voltaire, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifndef _SYS_IB_CLIENTS_OF_RDMA_IB_USER_MAD_H +#define _SYS_IB_CLIENTS_OF_RDMA_IB_USER_MAD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Increment this value if any changes that break userspace ABI + * compatibility are made. + */ +#define IB_USER_MAD_ABI_VERSION 5 + +/* + * Make sure that all structs defined in this file remain laid out so + * that they pack the same way on 32-bit and 64-bit architectures (to + * avoid incompatibility between 32-bit userspace and 64-bit kernels). + */ + +/* + * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index + * @id - ID of agent MAD received with/to be sent with + * @status - 0 on successful receive, ETIMEDOUT if no response + * received (transaction ID in data[] will be set to TID of original + * request) (ignored on send) + * @timeout_ms - Milliseconds to wait for response (unset on receive) + * @retries - Number of automatic retries to attempt + * @qpn - Remote QP number received from/to be sent to + * @qkey - Remote Q_Key to be sent with (unset on receive) + * @lid - Remote lid received from/to be sent to + * @sl - Service level received with/to be sent with + * @path_bits - Local path bits received with/to be sent with + * @grh_present - If set, GRH was received/should be sent + * @gid_index - Local GID index to send with (unset on receive) + * @hop_limit - Hop limit in GRH + * @traffic_class - Traffic class in GRH + * @gid - Remote GID in GRH + * @flow_label - Flow label in GRH + * + */ + +/* + * ib_user_mad_hdr - MAD packet header + * This layout allows specifying/receiving the P_Key index. To use + * this capability, an application must call the + * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before + * any other actions with the file handle. + * @id - ID of agent MAD received with/to be sent with + * @status - 0 on successful receive, ETIMEDOUT if no response + * received (transaction ID in data[] will be set to TID of original + * request) (ignored on send) + * @timeout_ms - Milliseconds to wait for response (unset on receive) + * @retries - Number of automatic retries to attempt + * @qpn - Remote QP number received from/to be sent to + * @qkey - Remote Q_Key to be sent with (unset on receive) + * @lid - Remote lid received from/to be sent to + * @sl - Service level received with/to be sent with + * @path_bits - Local path bits received with/to be sent with + * @grh_present - If set, GRH was received/should be sent + * @gid_index - Local GID index to send with (unset on receive) + * @hop_limit - Hop limit in GRH + * @traffic_class - Traffic class in GRH + * @gid - Remote GID in GRH + * @flow_label - Flow label in GRH + * + */ +struct ib_user_mad_hdr { + uint32_t id; + uint32_t status; + uint32_t timeout_ms; + uint32_t retries; + uint32_t length; + uint32_t qpn; + uint32_t qkey; + uint16_t lid; + uint8_t sl; + uint8_t path_bits; + uint8_t grh_present; + uint8_t gid_index; + uint8_t hop_limit; + uint8_t traffic_class; + uint8_t gid[16]; + uint32_t flow_label; + uint16_t pkey_index; + uint8_t reserved[6]; +}; + +/* + * ib_user_mad - MAD packet + * @hdr - MAD packet header + * @data - Contents of MAD + * + */ +struct ib_user_mad { + struct ib_user_mad_hdr hdr; + uint64_t data[]; +}; + +/* + * ib_user_mad_reg_req - MAD registration request + * @id - Set by the kernel; used to identify agent in future requests. + * @qpn - Queue pair number; must be 0 or 1. + * @method_mask - The caller will receive unsolicited MADs for any method + * where @method_mask = 1. + * @mgmt_class - Indicates which management class of MADs should be receive + * by the caller. This field is only required if the user wishes to + * receive unsolicited MADs, otherwise it should be 0. + * @mgmt_class_version - Indicates which version of MADs for the given + * management class to receive. + * @oui: Indicates IEEE OUI when mgmt_class is a vendor class + * in the range from 0x30 to 0x4f. Otherwise not used. + * @rmpp_version: If set, indicates the RMPP version used. + * + */ +struct ib_user_mad_reg_req { + uint32_t id; + uint32_t method_mask[4]; + uint8_t qpn; + uint8_t mgmt_class; + uint8_t mgmt_class_version; + uint8_t oui[3]; + uint8_t rmpp_version; +}; + +#define IB_IOCTL_MAGIC 0x1b + +#define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \ + struct ib_user_mad_reg_req) + +#define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, uint32_t) + +#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3) + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_RDMA_IB_USER_MAD_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_sa.h b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_sa.h new file mode 100644 index 00000000..5592749d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_sa.h @@ -0,0 +1,74 @@ +/* + * This file contains definitions used in OFED defined user/kernel + * interfaces. These are imported from the OFED header ib_user_sa.h. Oracle + * elects to have and use the contents of ib_user_sa.h under and governed + * by the OpenIB.org BSD license (see below for full license text). However, + * the following notice accompanied the original version of this file: + */ + +/* + * Copyright (c) 2005 Intel Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _SYS_IB_CLIENTS_OF_RDMA_IB_USER_SA_H +#define _SYS_IB_CLIENTS_OF_RDMA_IB_USER_SA_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct ib_user_path_rec { + uint8_t dgid[16]; + uint8_t sgid[16]; + uint16_t dlid; + uint16_t slid; + uint32_t raw_traffic; + uint32_t flow_label; + uint32_t reversible; + uint32_t mtu; + uint16_t pkey; + uint8_t hop_limit; + uint8_t traffic_class; + uint8_t numb_path; + uint8_t sl; + uint8_t mtu_selector; + uint8_t rate_selector; + uint8_t rate; + uint8_t packet_life_time_selector; + uint8_t packet_life_time; + uint8_t preference; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_RDMA_IB_USER_SA_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_verbs.h b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_verbs.h new file mode 100644 index 00000000..10ba5863 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_user_verbs.h @@ -0,0 +1,763 @@ +/* + * This file contains definitions used in OFED defined user/kernel + * interfaces. These are imported from the OFED header ib_user_verbs.h. Oracle + * elects to have and use the contents of ib_user_verbs.h under and governed + * by the OpenIB.org BSD license (see below for full license text). However, + * the following notice accompanied the original version of this file: + */ + +/* + * Copyright (c) 2005 Topspin Communications. All rights reserved. + * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. + * Copyright (c) 2005 PathScale, Inc. All rights reserved. + * Copyright (c) 2006 Mellanox Technologies. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifndef _SYS_IB_CLIENTS_OF_RDMA_IB_USER_VERBS_H +#define _SYS_IB_CLIENTS_OF_RDMA_IB_USER_VERBS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Increment this value if any changes that break userspace ABI + * compatibility are made. + */ +#define IB_USER_VERBS_ABI_VERSION 6 + +enum { + IB_USER_VERBS_CMD_GET_CONTEXT, + IB_USER_VERBS_CMD_QUERY_DEVICE, + IB_USER_VERBS_CMD_QUERY_PORT, + IB_USER_VERBS_CMD_ALLOC_PD, + IB_USER_VERBS_CMD_DEALLOC_PD, + IB_USER_VERBS_CMD_CREATE_AH, + IB_USER_VERBS_CMD_MODIFY_AH, + IB_USER_VERBS_CMD_QUERY_AH, + IB_USER_VERBS_CMD_DESTROY_AH, + IB_USER_VERBS_CMD_REG_MR, + IB_USER_VERBS_CMD_REG_SMR, + IB_USER_VERBS_CMD_REREG_MR, + IB_USER_VERBS_CMD_QUERY_MR, + IB_USER_VERBS_CMD_DEREG_MR, + IB_USER_VERBS_CMD_ALLOC_MW, + IB_USER_VERBS_CMD_BIND_MW, + IB_USER_VERBS_CMD_DEALLOC_MW, + IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL, + IB_USER_VERBS_CMD_CREATE_CQ, + IB_USER_VERBS_CMD_RESIZE_CQ, + IB_USER_VERBS_CMD_DESTROY_CQ, + IB_USER_VERBS_CMD_POLL_CQ, + IB_USER_VERBS_CMD_PEEK_CQ, + IB_USER_VERBS_CMD_REQ_NOTIFY_CQ, + IB_USER_VERBS_CMD_CREATE_QP, + IB_USER_VERBS_CMD_QUERY_QP, + IB_USER_VERBS_CMD_MODIFY_QP, + IB_USER_VERBS_CMD_DESTROY_QP, + IB_USER_VERBS_CMD_POST_SEND, + IB_USER_VERBS_CMD_POST_RECV, + IB_USER_VERBS_CMD_ATTACH_MCAST, + IB_USER_VERBS_CMD_DETACH_MCAST, + IB_USER_VERBS_CMD_CREATE_SRQ, + IB_USER_VERBS_CMD_MODIFY_SRQ, + IB_USER_VERBS_CMD_QUERY_SRQ, + IB_USER_VERBS_CMD_DESTROY_SRQ, + IB_USER_VERBS_CMD_POST_SRQ_RECV, + IB_USER_VERBS_CMD_CREATE_XRC_SRQ, + IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN, + IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN, + IB_USER_VERBS_CMD_CREATE_XRC_RCV_QP, + IB_USER_VERBS_CMD_MODIFY_XRC_RCV_QP, + IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP, + IB_USER_VERBS_CMD_REG_XRC_RCV_QP, + IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP, + IB_USER_VERBS_CMD_QUERY_GID, + IB_USER_VERBS_CMD_QUERY_PKEY +}; + +/* + * Make sure that all structs defined in this file remain laid out so + * that they pack the same way on 32-bit and 64-bit architectures (to + * avoid incompatibility between 32-bit userspace and 64-bit kernels). + * Specifically: + * - Do not use pointer types -- pass pointers in uint64_t instead. + * - Make sure that any structure larger than 4 bytes is padded to a + * multiple of 8 bytes. Otherwise the structure size will be + * different between 32-bit and 64-bit architectures. + */ + +struct ib_uverbs_async_event_desc { + uint64_t element; + uint32_t event_type; /* enum ib_event_type */ + uint32_t reserved; +}; + +struct ib_uverbs_comp_event_desc { + uint64_t cq_handle; +}; + +/* + * All commands from userspace should start with a uint32_t command field + * followed by uint16_t in_words and out_words fields (which give the + * length of the command block and response buffer if any in 32-bit + * words). The kernel driver will read these fields first and read + * the rest of the command struct based on these value. + */ + +struct ib_uverbs_cmd_hdr { + uint32_t command; + uint16_t in_words; + uint16_t out_words; +}; + +struct ib_uverbs_get_context { + ofv_resp_addr_t response; + uint64_t driver_data[]; +}; + +struct ib_uverbs_get_context_resp { + uint32_t async_fd; + uint32_t num_comp_vectors; +}; + +struct ib_uverbs_query_device { + ofv_resp_addr_t response; + uint64_t driver_data[]; +}; + +struct ib_uverbs_query_device_resp { + uint64_t fw_ver; + uint64_t node_guid; + uint64_t sys_image_guid; + uint64_t max_mr_size; + uint64_t page_size_cap; + uint32_t vendor_id; + uint32_t vendor_part_id; + uint32_t hw_ver; + uint32_t max_qp; + uint32_t max_qp_wr; + uint32_t device_cap_flags; + uint32_t max_sge; + uint32_t max_sge_rd; + uint32_t max_cq; + uint32_t max_cqe; + uint32_t max_mr; + uint32_t max_pd; + uint32_t max_qp_rd_atom; + uint32_t max_ee_rd_atom; + uint32_t max_res_rd_atom; + uint32_t max_qp_init_rd_atom; + uint32_t max_ee_init_rd_atom; + uint32_t atomic_cap; + uint32_t max_ee; + uint32_t max_rdd; + uint32_t max_mw; + uint32_t max_raw_ipv6_qp; + uint32_t max_raw_ethy_qp; + uint32_t max_mcast_grp; + uint32_t max_mcast_qp_attach; + uint32_t max_total_mcast_qp_attach; + uint32_t max_ah; + uint32_t max_fmr; + uint32_t max_map_per_fmr; + uint32_t max_srq; + uint32_t max_srq_wr; + uint32_t max_srq_sge; + uint16_t max_pkeys; + uint8_t local_ca_ack_delay; + uint8_t phys_port_cnt; + uint8_t reserved[4]; +}; + +struct ib_uverbs_query_port { + ofv_resp_addr_t response; + uint8_t port_num; + uint8_t reserved[7]; + uint64_t driver_data[]; +}; + +struct ib_uverbs_query_port_resp { + uint32_t port_cap_flags; + uint32_t max_msg_sz; + uint32_t bad_pkey_cntr; + uint32_t qkey_viol_cntr; + uint32_t gid_tbl_len; + uint16_t pkey_tbl_len; + uint16_t lid; + uint16_t sm_lid; + uint8_t state; + uint8_t max_mtu; + uint8_t active_mtu; + uint8_t lmc; + uint8_t max_vl_num; + uint8_t sm_sl; + uint8_t subnet_timeout; + uint8_t init_type_reply; + uint8_t active_width; + uint8_t active_speed; + uint8_t phys_state; + uint8_t reserved[3]; +}; + +struct ib_uverbs_query_gid { + ofv_resp_addr_t response; + uint32_t gid_index; + uint8_t port_num; + uint8_t reserved[3]; + uint64_t driver_data; +}; + +struct ib_uverbs_query_gid_resp { + uint8_t gid[16]; +}; + +struct ib_uverbs_query_pkey { + ofv_resp_addr_t response; + uint32_t pkey_index; + uint8_t port_num; + uint8_t reserved[3]; + uint64_t driver_data; +}; + +struct ib_uverbs_query_pkey_resp { + uint16_t pkey; + uint16_t reserved; +}; + +struct ib_uverbs_alloc_pd { + ofv_resp_addr_t response; + uint64_t driver_data[]; +}; + +/* + * PD responses may pass opaque data to userspace drivers, we choose a value + * larger than what any HCA requires. + */ +#define SOL_UVERBS_PD_DATA_OUT_SIZE 24 +typedef uint64_t uverbs_pd_drv_out_data_t[SOL_UVERBS_PD_DATA_OUT_SIZE]; + +struct ib_uverbs_alloc_pd_resp { + uint32_t pd_handle; + uint32_t reserved; + uverbs_pd_drv_out_data_t drv_out; +}; + +struct ib_uverbs_dealloc_pd { + uint32_t pd_handle; +}; + +struct ib_uverbs_reg_mr { + ofv_resp_addr_t response; + uint64_t start; + uint64_t length; + uint64_t hca_va; + uint32_t pd_handle; + uint32_t access_flags; + uint64_t driver_data[]; +}; + +struct ib_uverbs_reg_mr_resp { + uint32_t mr_handle; + uint32_t lkey; + uint32_t rkey; +}; + +struct ib_uverbs_dereg_mr { + uint32_t mr_handle; +}; + +struct ib_uverbs_create_comp_channel { + ofv_resp_addr_t response; +}; + +struct ib_uverbs_create_comp_channel_resp { + uint32_t fd; +}; + +struct ib_uverbs_create_cq { + ofv_resp_addr_t response; + uint64_t user_handle; + uint32_t cqe; + uint32_t comp_vector; + int32_t comp_channel; + uint32_t reserved; + uint64_t driver_data[]; +}; + +/* + * CQ responses pass opaque data to userspace drivers, we choose a value + * larger than what any HCA requires. + */ +#define SOL_UVERBS_CQ_DATA_OUT_SIZE 24 +typedef uint64_t uverbs_cq_drv_out_data_t[SOL_UVERBS_CQ_DATA_OUT_SIZE]; + +struct ib_uverbs_create_cq_resp { + uint32_t cq_handle; + uint32_t cqe; + uverbs_cq_drv_out_data_t drv_out; +}; + +struct ib_uverbs_resize_cq { + ofv_resp_addr_t response; + uint32_t cq_handle; + uint32_t cqe; + uint64_t driver_data[]; +}; + +struct ib_uverbs_resize_cq_resp { + uint32_t cqe; + uint32_t reserved; + uverbs_cq_drv_out_data_t drv_out; +}; + +struct ib_uverbs_poll_cq { + ofv_resp_addr_t response; + uint32_t cq_handle; + uint32_t ne; +}; + +struct ib_uverbs_wc { + uint64_t wr_id; + uint32_t status; + uint32_t opcode; + uint32_t vendor_err; + uint32_t byte_len; + uint32_t imm_data; + uint32_t qp_num; + uint32_t src_qp; + uint32_t wc_flags; + uint16_t pkey_index; + uint16_t slid; + uint8_t sl; + uint8_t dlid_path_bits; + uint8_t port_num; + uint8_t reserved; +}; + +struct ib_uverbs_poll_cq_resp { + uint32_t count; + uint32_t reserved; + struct ib_uverbs_wc wc[]; +}; + +struct ib_uverbs_req_notify_cq { + uint32_t cq_handle; + uint32_t solicited_only; +}; + +struct ib_uverbs_destroy_cq { + ofv_resp_addr_t response; + uint32_t cq_handle; + uint32_t reserved; +}; + +struct ib_uverbs_destroy_cq_resp { + uint32_t comp_events_reported; + uint32_t async_events_reported; +}; + +struct ib_uverbs_global_route { + uint8_t dgid[16]; + uint32_t flow_label; + uint8_t sgid_index; + uint8_t hop_limit; + uint8_t traffic_class; + uint8_t reserved; +}; + +struct ib_uverbs_ah_attr { + struct ib_uverbs_global_route grh; + uint16_t dlid; + uint8_t sl; + uint8_t src_path_bits; + uint8_t static_rate; + uint8_t is_global; + uint8_t port_num; + uint8_t reserved; +}; + +struct ib_uverbs_qp_attr { + uint32_t qp_attr_mask; + uint32_t qp_state; + uint32_t cur_qp_state; + uint32_t path_mtu; + uint32_t path_mig_state; + uint32_t qkey; + uint32_t rq_psn; + uint32_t sq_psn; + uint32_t dest_qp_num; + uint32_t qp_access_flags; + + struct ib_uverbs_ah_attr ah_attr; + struct ib_uverbs_ah_attr alt_ah_attr; + + /* ib_qp_cap */ + uint32_t max_send_wr; + uint32_t max_recv_wr; + uint32_t max_send_sge; + uint32_t max_recv_sge; + uint32_t max_inline_data; + + uint16_t pkey_index; + uint16_t alt_pkey_index; + uint8_t en_sqd_async_notify; + uint8_t sq_draining; + uint8_t max_rd_atomic; + uint8_t max_dest_rd_atomic; + uint8_t min_rnr_timer; + uint8_t port_num; + uint8_t timeout; + uint8_t retry_cnt; + uint8_t rnr_retry; + uint8_t alt_port_num; + uint8_t alt_timeout; + uint8_t reserved[5]; +}; + +struct ib_uverbs_create_qp { + ofv_resp_addr_t response; + uint64_t user_handle; + uint32_t pd_handle; + uint32_t send_cq_handle; + uint32_t recv_cq_handle; + uint32_t srq_handle; + uint32_t max_send_wr; + uint32_t max_recv_wr; + uint32_t max_send_sge; + uint32_t max_recv_sge; + uint32_t max_inline_data; + uint8_t sq_sig_all; + uint8_t qp_type; + uint8_t is_srq; + uint8_t reserved; + uint64_t driver_data[]; +}; + +/* + * QP responses pass opaque data to userspace drivers, we choose a value + * larger than what any HCA requires. + */ +#define SOL_UVERBS_QP_DATA_OUT_SIZE 24 +typedef uint64_t uverbs_qp_drv_out_data_t[SOL_UVERBS_QP_DATA_OUT_SIZE]; + +struct ib_uverbs_create_qp_resp { + uint32_t qp_handle; + uint32_t qpn; + uint32_t max_send_wr; + uint32_t max_recv_wr; + uint32_t max_send_sge; + uint32_t max_recv_sge; + uint32_t max_inline_data; + uint32_t reserved; + uverbs_qp_drv_out_data_t drv_out; +}; + +/* + * This struct needs to remain a multiple of 8 bytes to keep the + * alignment of the modify QP parameters. + */ +struct ib_uverbs_qp_dest { + uint8_t dgid[16]; + uint32_t flow_label; + uint16_t dlid; + uint16_t reserved; + uint8_t sgid_index; + uint8_t hop_limit; + uint8_t traffic_class; + uint8_t sl; + uint8_t src_path_bits; + uint8_t static_rate; + uint8_t is_global; + uint8_t port_num; +}; + +struct ib_uverbs_query_qp { + ofv_resp_addr_t response; + uint32_t qp_handle; + uint32_t attr_mask; + uint64_t driver_data[]; +}; + +struct ib_uverbs_query_qp_resp { + struct ib_uverbs_qp_dest dest; + struct ib_uverbs_qp_dest alt_dest; + uint32_t max_send_wr; + uint32_t max_recv_wr; + uint32_t max_send_sge; + uint32_t max_recv_sge; + uint32_t max_inline_data; + uint32_t qkey; + uint32_t rq_psn; + uint32_t sq_psn; + uint32_t dest_qp_num; + uint32_t qp_access_flags; + uint16_t pkey_index; + uint16_t alt_pkey_index; + uint8_t qp_state; + uint8_t cur_qp_state; + uint8_t path_mtu; + uint8_t path_mig_state; + uint8_t sq_draining; + uint8_t max_rd_atomic; + uint8_t max_dest_rd_atomic; + uint8_t min_rnr_timer; + uint8_t port_num; + uint8_t timeout; + uint8_t retry_cnt; + uint8_t rnr_retry; + uint8_t alt_port_num; + uint8_t alt_timeout; + uint8_t sq_sig_all; + uint8_t reserved[5]; + uint64_t driver_data[]; +}; + +struct ib_uverbs_modify_qp { + struct ib_uverbs_qp_dest dest; + struct ib_uverbs_qp_dest alt_dest; + uint32_t qp_handle; + uint32_t attr_mask; + uint32_t qkey; + uint32_t rq_psn; + uint32_t sq_psn; + uint32_t dest_qp_num; + uint32_t qp_access_flags; + uint16_t pkey_index; + uint16_t alt_pkey_index; + uint8_t qp_state; + uint8_t cur_qp_state; + uint8_t path_mtu; + uint8_t path_mig_state; + uint8_t en_sqd_async_notify; + uint8_t max_rd_atomic; + uint8_t max_dest_rd_atomic; + uint8_t min_rnr_timer; + uint8_t port_num; + uint8_t timeout; + uint8_t retry_cnt; + uint8_t rnr_retry; + uint8_t alt_port_num; + uint8_t alt_timeout; + uint8_t reserved[2]; + uint64_t driver_data[]; +}; + + +struct ib_uverbs_destroy_qp { + ofv_resp_addr_t response; + uint32_t qp_handle; + uint32_t reserved; +}; + +struct ib_uverbs_destroy_qp_resp { + uint32_t events_reported; +}; + +/* + * The ib_uverbs_sge structure isn't used anywhere, since we assume + * the ib_sge structure is packed the same way on 32-bit and 64-bit + * architectures in both kernel and user space. It's just here to + * document the ABI. + */ +struct ib_uverbs_sge { + uint64_t addr; + uint32_t length; + uint32_t lkey; +}; + +struct ib_uverbs_send_wr { + uint64_t wr_id; + uint32_t num_sge; + uint32_t opcode; + uint32_t send_flags; + uint32_t imm_data; + union { + struct { + uint64_t remote_addr; + uint32_t rkey; + uint32_t reserved; + } rdma; + struct { + uint64_t remote_addr; + uint64_t compare_add; + uint64_t swap; + uint32_t rkey; + uint32_t reserved; + } atomic; + struct { + uint32_t ah; + uint32_t remote_qpn; + uint32_t remote_qkey; + uint32_t reserved; + } ud; + } wr; +}; + +struct ib_uverbs_post_send { + uint64_t response; + uint32_t qp_handle; + uint32_t wr_count; + uint32_t sge_count; + uint32_t wqe_size; + struct ib_uverbs_send_wr send_wr[]; +}; + +struct ib_uverbs_post_send_resp { + uint32_t bad_wr; +}; + +struct ib_uverbs_recv_wr { + uint64_t wr_id; + uint32_t num_sge; + uint32_t reserved; +}; + +struct ib_uverbs_post_recv { + uint64_t response; + uint32_t qp_handle; + uint32_t wr_count; + uint32_t sge_count; + uint32_t wqe_size; + struct ib_uverbs_recv_wr recv_wr[]; +}; + +struct ib_uverbs_post_recv_resp { + uint32_t bad_wr; +}; + +struct ib_uverbs_post_srq_recv { + uint64_t response; + uint32_t srq_handle; + uint32_t wr_count; + uint32_t sge_count; + uint32_t wqe_size; + struct ib_uverbs_recv_wr recv[]; +}; + +struct ib_uverbs_post_srq_recv_resp { + uint32_t bad_wr; +}; + +struct ib_uverbs_create_ah { + uint64_t response; + uint64_t user_handle; + uint32_t pd_handle; + uint32_t reserved; + struct ib_uverbs_ah_attr attr; +}; + +struct ib_uverbs_create_ah_resp { + uint32_t ah_handle; +}; + +struct ib_uverbs_destroy_ah { + uint32_t ah_handle; +}; + +struct ib_uverbs_attach_mcast { + uint8_t gid[16]; + uint32_t qp_handle; + uint16_t mlid; + uint16_t reserved; + uint64_t driver_data[]; +}; + +struct ib_uverbs_detach_mcast { + uint8_t gid[16]; + uint32_t qp_handle; + uint16_t mlid; + uint16_t reserved; + uint64_t driver_data[]; +}; + +struct ib_uverbs_create_srq { + ofv_resp_addr_t response; + uint64_t user_handle; + uint32_t pd_handle; + uint32_t max_wr; + uint32_t max_sge; + uint32_t srq_limit; + uint64_t driver_data[]; +}; + +/* + * SRQ responses pass opaque data to userspace drivers, we choose a value + * larger than what any HCA requires. + */ +#define SOL_UVERBS_SRQ_DATA_OUT_SIZE 24 +typedef uint64_t uverbs_srq_drv_out_data_t[SOL_UVERBS_SRQ_DATA_OUT_SIZE]; + +struct ib_uverbs_create_srq_resp { + uint32_t srq_handle; + uint32_t max_wr; + uint32_t max_sge; + uint32_t reserved; + uverbs_srq_drv_out_data_t drv_out; +}; + +struct ib_uverbs_modify_srq { + uint32_t srq_handle; + uint32_t attr_mask; + uint32_t max_wr; + uint32_t srq_limit; + uint64_t driver_data[]; +}; + +struct ib_uverbs_query_srq { + ofv_resp_addr_t response; + uint32_t srq_handle; + uint32_t reserved; + uint64_t driver_data[]; +}; + +struct ib_uverbs_query_srq_resp { + uint32_t max_wr; + uint32_t max_sge; + uint32_t srq_limit; + uint32_t reserved; +}; + +struct ib_uverbs_destroy_srq { + ofv_resp_addr_t response; + uint32_t srq_handle; + uint32_t reserved; +}; + +struct ib_uverbs_destroy_srq_resp { + uint32_t events_reported; +}; + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_RDMA_IB_USER_VERBS_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_verbs.h b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_verbs.h new file mode 100644 index 00000000..00f7495c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/ib_verbs.h @@ -0,0 +1,791 @@ +/* + * This file contains definitions used in OFED defined user/kernel + * interfaces. These are imported from the OFED header ib_verbs.h. Oracle + * elects to have and use the contents of ib_verbs.h under and governed + * by the OpenIB.org BSD license (see below for full license text). However, + * the following notice accompanied the original version of this file: + */ + +/* + * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. + * Copyright (c) 2004 Infinicon Corporation. All rights reserved. + * Copyright (c) 2004 Intel Corporation. All rights reserved. + * Copyright (c) 2004 Topspin Corporation. All rights reserved. + * Copyright (c) 2004 Voltaire Corporation. All rights reserved. + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef _SYS_IB_CLIENTS_OF_IB_VERBS_H +#define _SYS_IB_CLIENTS_OF_IB_VERBS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +typedef struct sol_ofs_client_s *ofs_client_p_t; + +union ib_gid { + uint8_t raw[16]; + struct { + uint64_t subnet_prefix; + uint64_t interface_id; + } global; +}; + +enum rdma_node_type { + /* IB values map to NodeInfo:NodeType. */ + RDMA_NODE_IB_CA = 1, + RDMA_NODE_IB_SWITCH, + RDMA_NODE_IB_ROUTER, + RDMA_NODE_RNIC +}; + +enum rdma_transport_type { + RDMA_TRANSPORT_IB, + RDMA_TRANSPORT_IWARP +}; + +#define __attribute_const__ __attribute__((__const__)) +enum rdma_transport_type +rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__; + +enum ib_device_cap_flags { + IB_DEVICE_RESIZE_MAX_WR = 1, + IB_DEVICE_BAD_PKEY_CNTR = (1<<1), + IB_DEVICE_BAD_QKEY_CNTR = (1<<2), + IB_DEVICE_RAW_MULTI = (1<<3), + IB_DEVICE_AUTO_PATH_MIG = (1<<4), + IB_DEVICE_CHANGE_PHY_PORT = (1<<5), + IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6), + IB_DEVICE_CURR_QP_STATE_MOD = (1<<7), + IB_DEVICE_SHUTDOWN_PORT = (1<<8), + IB_DEVICE_INIT_TYPE = (1<<9), + IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10), + IB_DEVICE_SYS_IMAGE_GUID = (1<<11), + IB_DEVICE_RC_RNR_NAK_GEN = (1<<12), + IB_DEVICE_SRQ_RESIZE = (1<<13), + IB_DEVICE_N_NOTIFY_CQ = (1<<14), + IB_DEVICE_ZERO_STAG = (1<<15), + IB_DEVICE_SEND_W_INV = (1<<16), + IB_DEVICE_MEM_WINDOW = (1<<17) +}; + +enum ib_atomic_cap { + IB_ATOMIC_NONE, + IB_ATOMIC_HCA, + IB_ATOMIC_GLOB +}; + +struct ib_device_attr { + uint64_t fw_ver; + uint64_t sys_image_guid; + uint64_t max_mr_size; + uint64_t page_size_cap; + uint32_t vendor_id; + uint32_t vendor_part_id; + uint32_t hw_ver; + int max_qp; + int max_qp_wr; + int device_cap_flags; + int max_sge; + int max_sge_rd; + int max_cq; + int max_cqe; + int max_mr; + int max_pd; + int max_qp_rd_atom; + int max_ee_rd_atom; + int max_res_rd_atom; + int max_qp_init_rd_atom; + int max_ee_init_rd_atom; + enum ib_atomic_cap atomic_cap; + int max_ee; + int max_rdd; + int max_mw; + int max_raw_ipv6_qp; + int max_raw_ethy_qp; + int max_mcast_grp; + int max_mcast_qp_attach; + int max_total_mcast_qp_attach; + int max_ah; + int max_fmr; + int max_map_per_fmr; + int max_srq; + int max_srq_wr; + int max_srq_sge; + uint16_t max_pkeys; + uint8_t local_ca_ack_delay; +}; + +enum ib_mtu { + OFED_IB_MTU_256 = 1, + OFED_IB_MTU_512 = 2, + OFED_IB_MTU_1024 = 3, + OFED_IB_MTU_2048 = 4, + OFED_IB_MTU_4096 = 5 +}; + +enum ib_port_state { + IB_PORT_NOP = 0, + IB_PORT_DOWN = 1, + IB_PORT_INIT = 2, + IB_PORT_ARMED = 3, + IB_PORT_ACTIVE = 4, + IB_PORT_ACTIVE_DEFER = 5 +}; + +enum ib_port_cap_flags { + IB_PORT_SM = 1 << 1, + IB_PORT_NOTICE_SUP = 1 << 2, + IB_PORT_TRAP_SUP = 1 << 3, + IB_PORT_OPT_IPD_SUP = 1 << 4, + IB_PORT_AUTO_MIGR_SUP = 1 << 5, + IB_PORT_SL_MAP_SUP = 1 << 6, + IB_PORT_MKEY_NVRAM = 1 << 7, + IB_PORT_PKEY_NVRAM = 1 << 8, + IB_PORT_LED_INFO_SUP = 1 << 9, + IB_PORT_SM_DISABLED = 1 << 10, + IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11, + IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12, + IB_PORT_CM_SUP = 1 << 16, + IB_PORT_SNMP_TUNNEL_SUP = 1 << 17, + IB_PORT_REINIT_SUP = 1 << 18, + IB_PORT_DEVICE_MGMT_SUP = 1 << 19, + IB_PORT_VENDOR_CLASS_SUP = 1 << 20, + IB_PORT_DR_NOTICE_SUP = 1 << 21, + IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22, + IB_PORT_BOOT_MGMT_SUP = 1 << 23, + IB_PORT_LINK_LATENCY_SUP = 1 << 24, + IB_PORT_CLIENT_REG_SUP = 1 << 25 +}; + +enum ib_port_width { + IB_WIDTH_1X = 1, + IB_WIDTH_4X = 2, + IB_WIDTH_8X = 4, + IB_WIDTH_12X = 8 +}; + +static inline int ib_width_enum_to_int(enum ib_port_width width) +{ + switch (width) { + case IB_WIDTH_1X: return 1; + case IB_WIDTH_4X: return 4; + case IB_WIDTH_8X: return 8; + case IB_WIDTH_12X: return 12; + default: return -1; + } +} + +struct ib_port_attr { + enum ib_port_state state; + enum ib_mtu max_mtu; + enum ib_mtu active_mtu; + int gid_tbl_len; + uint32_t port_cap_flags; + uint32_t max_msg_sz; + uint32_t bad_pkey_cntr; + uint32_t qkey_viol_cntr; + uint16_t pkey_tbl_len; + uint16_t lid; + uint16_t sm_lid; + uint8_t lmc; + uint8_t max_vl_num; + uint8_t sm_sl; + uint8_t subnet_timeout; + uint8_t init_type_reply; + uint8_t active_width; + uint8_t active_speed; + uint8_t phys_state; +}; + +enum ib_device_modify_flags { + IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0, + IB_DEVICE_MODIFY_NODE_DESC = 1 << 1 +}; + +struct ib_device_modify { + uint64_t sys_image_guid; + char node_desc[64]; +}; + +enum ib_port_modify_flags { + IB_PORT_SHUTDOWN = 1, + IB_PORT_INIT_TYPE = (1<<2), + IB_PORT_RESET_QKEY_CNTR = (1<<3) +}; + +struct ib_port_modify { + uint32_t set_port_cap_mask; + uint32_t clr_port_cap_mask; + uint8_t init_type; +}; + +enum ib_event_type { + IB_EVENT_CQ_ERR, + IB_EVENT_QP_FATAL, + IB_EVENT_QP_REQ_ERR, + IB_EVENT_QP_ACCESS_ERR, + IB_EVENT_COMM_EST, + IB_EVENT_SQ_DRAINED, + IB_EVENT_PATH_MIG, + IB_EVENT_PATH_MIG_ERR, + IB_EVENT_DEVICE_FATAL, + IB_EVENT_PORT_ACTIVE, + IB_EVENT_PORT_ERR, + IB_EVENT_LID_CHANGE, + IB_EVENT_PKEY_CHANGE, + IB_EVENT_SM_CHANGE, + IB_EVENT_SRQ_ERR, + IB_EVENT_SRQ_LIMIT_REACHED, + IB_EVENT_QP_LAST_WQE_REACHED, + IB_EVENT_CLIENT_REREGISTER +}; + +struct ib_event { + struct ib_device *device; + union { + struct ib_cq *cq; + struct ib_qp *qp; + struct ib_srq *srq; + uint8_t port_num; + } element; + enum ib_event_type event; +}; + +struct ib_event_handler { + struct ib_device *device; + void (*handler)(struct ib_event_handler *, + struct ib_event *); + llist_head_t list; +}; + +struct ib_global_route { + union ib_gid dgid; + uint32_t flow_label; + uint8_t sgid_index; + uint8_t hop_limit; + uint8_t traffic_class; +}; + +enum ib_ah_flags { + IB_AH_GRH = 1 +}; + +enum ib_rate { + IB_RATE_PORT_CURRENT = 0, + IB_RATE_2_5_GBPS = 2, + IB_RATE_5_GBPS = 5, + IB_RATE_10_GBPS = 3, + IB_RATE_20_GBPS = 6, + IB_RATE_30_GBPS = 4, + IB_RATE_40_GBPS = 7, + IB_RATE_60_GBPS = 8, + IB_RATE_80_GBPS = 9, + IB_RATE_120_GBPS = 10 +}; + +struct ib_ah_attr { + struct ib_global_route grh; + uint16_t dlid; + uint8_t sl; + uint8_t src_path_bits; + uint8_t static_rate; + uint8_t ah_flags; + uint8_t port_num; +}; + +enum ib_wc_status { + IB_WC_SUCCESS, + IB_WC_LOC_LEN_ERR, + IB_WC_LOC_QP_OP_ERR, + IB_WC_LOC_EEC_OP_ERR, + IB_WC_LOC_PROT_ERR, + IB_WC_WR_FLUSH_ERR, + IB_WC_MW_BIND_ERR, + IB_WC_BAD_RESP_ERR, + IB_WC_LOC_ACCESS_ERR, + IB_WC_REM_INV_REQ_ERR, + IB_WC_REM_ACCESS_ERR, + IB_WC_REM_OP_ERR, + IB_WC_RETRY_EXC_ERR, + IB_WC_RNR_RETRY_EXC_ERR, + IB_WC_LOC_RDD_VIOL_ERR, + IB_WC_REM_INV_RD_REQ_ERR, + IB_WC_REM_ABORT_ERR, + IB_WC_INV_EECN_ERR, + IB_WC_INV_EEC_STATE_ERR, + IB_WC_FATAL_ERR, + IB_WC_RESP_TIMEOUT_ERR, + IB_WC_GENERAL_ERR +}; + +enum ib_wc_opcode { + IB_WC_SEND, + IB_WC_RDMA_WRITE, + IB_WC_RDMA_READ, + IB_WC_COMP_SWAP, + IB_WC_FETCH_ADD, + IB_WC_BIND_MW, +/* + * Set value of IB_WC_RECV so consumers can test if a completion is a + * receive by testing (opcode & IB_WC_RECV). + */ + IB_WC_RECV = 1 << 7, + IB_WC_RECV_RDMA_WITH_IMM +}; + +enum ib_wc_flags { + IB_WC_GRH = 1, + IB_WC_WITH_IMM = (1<<1), +}; + +struct ib_wc { + uint64_t wr_id; + enum ib_wc_status status; + enum ib_wc_opcode opcode; + uint32_t vendor_err; + uint32_t byte_len; + struct ib_qp *qp; + uint32_t imm_data; + uint32_t src_qp; + int wc_flags; + uint16_t pkey_index; + uint16_t slid; + uint8_t sl; + uint8_t dlid_path_bits; + uint8_t port_num; +}; + +enum ib_cq_notify_flags { + IB_CQ_SOLICITED = 1 << 0, + IB_CQ_NEXT_COMP = 1 << 1, + IB_CQ_SOLICITED_MASK = IB_CQ_SOLICITED | IB_CQ_NEXT_COMP, + IB_CQ_REPORT_MISSED_EVENTS = 1 << 2, +}; + +enum ib_srq_attr_mask { + IB_SRQ_MAX_WR = 1 << 0, + IB_SRQ_LIMIT = 1 << 1, +}; + +struct ib_srq_attr { + uint32_t max_wr; + uint32_t max_sge; + uint32_t srq_limit; +}; + +struct ib_srq_init_attr { + void (*event_handler)(struct ib_event *, void *); + void *srq_context; + struct ib_srq_attr attr; +}; + +struct ib_qp_cap { + uint32_t max_send_wr; + uint32_t max_recv_wr; + uint32_t max_send_sge; + uint32_t max_recv_sge; + uint32_t max_inline_data; +}; + +enum ib_sig_type { + IB_SIGNAL_ALL_WR, + IB_SIGNAL_REQ_WR +}; + +enum ib_qp_type { + /* + * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries + * here (and in that order) since the MAD layer uses them as + * indices into a 2-entry table. + */ + IB_QPT_SMI, + IB_QPT_GSI, + + IB_QPT_RC, + IB_QPT_UC, + IB_QPT_UD, + IB_QPT_RAW_IPV6, + IB_QPT_RAW_ETY +}; + +struct ib_qp_init_attr { + void (*event_handler)(struct ib_event *, void *); + void *qp_context; + struct ib_cq *send_cq; + struct ib_cq *recv_cq; + struct ib_srq *srq; + struct ib_qp_cap cap; + enum ib_sig_type sq_sig_type; + enum ib_qp_type qp_type; + uint8_t port_num; /* special QP types only */ +}; + +enum ib_rnr_timeout { + IB_RNR_TIMER_655_36 = 0, + IB_RNR_TIMER_000_01 = 1, + IB_RNR_TIMER_000_02 = 2, + IB_RNR_TIMER_000_03 = 3, + IB_RNR_TIMER_000_04 = 4, + IB_RNR_TIMER_000_06 = 5, + IB_RNR_TIMER_000_08 = 6, + IB_RNR_TIMER_000_12 = 7, + IB_RNR_TIMER_000_16 = 8, + IB_RNR_TIMER_000_24 = 9, + IB_RNR_TIMER_000_32 = 10, + IB_RNR_TIMER_000_48 = 11, + IB_RNR_TIMER_000_64 = 12, + IB_RNR_TIMER_000_96 = 13, + IB_RNR_TIMER_001_28 = 14, + IB_RNR_TIMER_001_92 = 15, + IB_RNR_TIMER_002_56 = 16, + IB_RNR_TIMER_003_84 = 17, + IB_RNR_TIMER_005_12 = 18, + IB_RNR_TIMER_007_68 = 19, + IB_RNR_TIMER_010_24 = 20, + IB_RNR_TIMER_015_36 = 21, + IB_RNR_TIMER_020_48 = 22, + IB_RNR_TIMER_030_72 = 23, + IB_RNR_TIMER_040_96 = 24, + IB_RNR_TIMER_061_44 = 25, + IB_RNR_TIMER_081_92 = 26, + IB_RNR_TIMER_122_88 = 27, + IB_RNR_TIMER_163_84 = 28, + IB_RNR_TIMER_245_76 = 29, + IB_RNR_TIMER_327_68 = 30, + IB_RNR_TIMER_491_52 = 31 +}; + +enum ib_qp_attr_mask { + IB_QP_STATE = 1, + IB_QP_CUR_STATE = (1<<1), + IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2), + IB_QP_ACCESS_FLAGS = (1<<3), + IB_QP_PKEY_INDEX = (1<<4), + IB_QP_PORT = (1<<5), + IB_QP_QKEY = (1<<6), + IB_QP_AV = (1<<7), + IB_QP_PATH_MTU = (1<<8), + IB_QP_TIMEOUT = (1<<9), + IB_QP_RETRY_CNT = (1<<10), + IB_QP_RNR_RETRY = (1<<11), + IB_QP_RQ_PSN = (1<<12), + IB_QP_MAX_QP_RD_ATOMIC = (1<<13), + IB_QP_ALT_PATH = (1<<14), + IB_QP_MIN_RNR_TIMER = (1<<15), + IB_QP_SQ_PSN = (1<<16), + IB_QP_MAX_DEST_RD_ATOMIC = (1<<17), + IB_QP_PATH_MIG_STATE = (1<<18), + IB_QP_CAP = (1<<19), + IB_QP_DEST_QPN = (1<<20) +}; + +enum ib_qp_state { + IB_QPS_RESET, + IB_QPS_INIT, + IB_QPS_RTR, + IB_QPS_RTS, + IB_QPS_SQD, + IB_QPS_SQE, + IB_QPS_ERR +}; + +enum ib_mig_state { + IB_MIG_MIGRATED, + IB_MIG_REARM, + IB_MIG_ARMED +}; + +struct ib_qp_attr { + enum ib_qp_state qp_state; + enum ib_qp_state cur_qp_state; + enum ib_mtu path_mtu; + enum ib_mig_state path_mig_state; + uint32_t qkey; + uint32_t rq_psn; + uint32_t sq_psn; + uint32_t dest_qp_num; + int qp_access_flags; + struct ib_qp_cap cap; + struct ib_ah_attr ah_attr; + struct ib_ah_attr alt_ah_attr; + uint16_t pkey_index; + uint16_t alt_pkey_index; + uint8_t en_sqd_async_notify; + uint8_t sq_draining; + uint8_t max_rd_atomic; + uint8_t max_dest_rd_atomic; + uint8_t min_rnr_timer; + uint8_t port_num; + uint8_t timeout; + uint8_t retry_cnt; + uint8_t rnr_retry; + uint8_t alt_port_num; + uint8_t alt_timeout; +}; + +enum ib_wr_opcode { + IB_WR_RDMA_WRITE, + IB_WR_RDMA_WRITE_WITH_IMM, + IB_WR_SEND, + IB_WR_SEND_WITH_IMM, + IB_WR_RDMA_READ, + IB_WR_ATOMIC_CMP_AND_SWP, + IB_WR_ATOMIC_FETCH_AND_ADD +}; + +enum ib_access_flags { + IB_ACCESS_LOCAL_WRITE = 1, + IB_ACCESS_REMOTE_WRITE = (1<<1), + IB_ACCESS_REMOTE_READ = (1<<2), + IB_ACCESS_REMOTE_ATOMIC = (1<<3), + IB_ACCESS_MW_BIND = (1<<4), + IB_ACCESS_SO = (1<<5) /* MR with Strong Ordering */ +}; + +struct ib_pd { + struct ib_device *device; + ibt_pd_hdl_t ibt_pd; +}; + +typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); + +struct ib_cq { + struct ib_device *device; + ib_comp_handler comp_handler; + void (*event_handler)(struct ib_event *, void *); + void *cq_context; + int cqe; + ibt_cq_hdl_t ibt_cq; + kmutex_t lock; +}; + +struct ib_srq { + struct ib_device *device; + struct ib_pd *pd; + void (*event_handler)(struct ib_event *, void *); + void *srq_context; + ibt_srq_hdl_t ibt_srq; +}; + +struct ib_qp { + struct ib_device *device; + struct ib_pd *pd; + struct ib_cq *send_cq; + struct ib_cq *recv_cq; + struct ib_srq *srq; + void (*event_handler)(struct ib_event *, void *); + void *qp_context; + uint32_t qp_num; + enum ib_qp_type qp_type; + ibt_qp_hdl_t ibt_qp; + kmutex_t lock; +}; + +#define IB_DEVICE_NAME_MAX 64 + +typedef struct ib_device { + ibt_hca_hdl_t hca_hdl; + char name[IB_DEVICE_NAME_MAX]; + uint64_t node_guid; + uint32_t local_dma_lkey; + uint8_t phys_port_cnt; + uint8_t node_type; + enum { + IB_DEV_UNINITIALIZED, + IB_DEV_REGISTERED, + IB_DEV_UNREGISTERED, + IB_DEV_CLOSE = 100, + IB_DEV_OPEN + } reg_state; + void *data; + ofs_client_p_t clnt_hdl; + struct llist_head list; +} ib_device_t; + +typedef struct ib_client { + char *name; + void (*add) (struct ib_device *); + void (*remove)(struct ib_device *); + dev_info_t *dip; + ofs_client_p_t clnt_hdl; + enum { + IB_CLNT_UNINITIALIZED, + IB_CLNT_INITIALIZED + } state; +} ib_client_t; + +int ib_register_client(struct ib_client *client); +void ib_unregister_client(struct ib_client *client); + +void *ib_get_client_data(struct ib_device *device, struct ib_client *client); +void ib_set_client_data(struct ib_device *device, struct ib_client *client, + void *data); + +int ib_query_device(struct ib_device *device, + struct ib_device_attr *device_attr); + +/* + * ib_alloc_pd - Allocates an unused protection domain. + * @device: The device on which to allocate the protection domain. + * + * A protection domain object provides an association between QPs, shared + * receive queues, address handles, memory regions, and memory windows. + */ +struct ib_pd *ib_alloc_pd(struct ib_device *device); + +/* + * ib_dealloc_pd - Deallocates a protection domain. + * @pd: The protection domain to deallocate. + */ +int ib_dealloc_pd(struct ib_pd *pd); + +/* + * ib_create_qp - Creates a QP associated with the specified protection + * domain. + * @pd: The protection domain associated with the QP. + * @qp_init_attr: A list of initial attributes required to create the + * QP. If QP creation succeeds, then the attributes are updated to + * the actual capabilities of the created QP. + */ +struct ib_qp *ib_create_qp(struct ib_pd *pd, + struct ib_qp_init_attr *qp_init_attr); + +/* + * ib_modify_qp - Modifies the attributes for the specified QP and then + * transitions the QP to the given state. + * @qp: The QP to modify. + * @qp_attr: On input, specifies the QP attributes to modify. On output, + * the current values of selected QP attributes are returned. + * @qp_attr_mask: A bit-mask used to specify which attributes of the QP + * are being modified. + */ +int ib_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr, + int qp_attr_mask); + +/* + * ib_destroy_qp - Destroys the specified QP. + * @qp: The QP to destroy. + */ +int ib_destroy_qp(struct ib_qp *qp); + +/* + * IB_CQ_VECTOR_LEAST_ATTACHED: The constant specifies that + * the CQ will be attached to the completion vector that has + * the least number of CQs already attached to it. + */ +#define IB_CQ_VECTOR_LEAST_ATTACHED 0xffffffff + +/* + * ib_create_cq - Creates a CQ on the specified device. + * @device: The device on which to create the CQ. + * @comp_handler: A user-specified callback that is invoked when a + * completion event occurs on the CQ. + * @event_handler: A user-specified callback that is invoked when an + * asynchronous event not associated with a completion occurs on the CQ. + * @cq_context: Context associated with the CQ returned to the user via + * the associated completion and event handlers. + * @cqe: The minimum size of the CQ. + * @comp_vector - Completion queue sched handle. + * + * Users can examine the cq structure to determine the actual CQ size. + */ +struct ib_cq *ib_create_cq(struct ib_device *device, + ib_comp_handler comp_handler, + void (*event_handler)(struct ib_event *, void *), + void *cq_context, int cqe, void *comp_vector); + +/* + * ib_destroy_cq - Destroys the specified CQ. + * @cq: The CQ to destroy. + */ +int ib_destroy_cq(struct ib_cq *cq); + +/* + * ib_poll_cq - poll a CQ for completion(s) + * @cq:the CQ being polled + * @num_entries:maximum number of completions to return + * @wc:array of at least @num_entries &struct ib_wc where completions + * will be returned + * + * Poll a CQ for (possibly multiple) completions. If the return value + * is < 0, an error occurred. If the return value is >= 0, it is the + * number of completions returned. If the return value is + * non-negative and < num_entries, then the CQ was emptied. + */ +int ib_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc); + +/* + * ib_req_notify_cq - Request completion notification on a CQ. + * @cq: The CQ to generate an event for. + * @flags: + * Must contain exactly one of %IB_CQ_SOLICITED or %IB_CQ_NEXT_COMP + * to request an event on the next solicited event or next work + * completion at any type, respectively. %IB_CQ_REPORT_MISSED_EVENTS + * may also be |ed in to request a hint about missed events, as + * described below. + * + * Return Value: + * < 0 means an error occurred while requesting notification + * == 0 means notification was requested successfully, and if + * IB_CQ_REPORT_MISSED_EVENTS was passed in, then no events + * were missed and it is safe to wait for another event. In + * this case is it guaranteed that any work completions added + * to the CQ since the last CQ poll will trigger a completion + * notification event. + * > 0 is only returned if IB_CQ_REPORT_MISSED_EVENTS was passed + * in. It means that the consumer must poll the CQ again to + * make sure it is empty to avoid missing an event because of a + * race between requesting notification and an entry being + * added to the CQ. This return value means it is possible + * (but not guaranteed) that a work completion has been added + * to the CQ since the last poll without triggering a + * completion notification event. + */ +int ib_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags); + +struct rdma_cm_id; +ibt_hca_hdl_t ib_get_ibt_hca_hdl(struct ib_device *device); + +ibt_channel_hdl_t +ib_get_ibt_channel_hdl(struct rdma_cm_id *cm); + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_IB_VERBS_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/rdma_cm.h b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/rdma_cm.h new file mode 100644 index 00000000..ac2bf5d5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/rdma_cm.h @@ -0,0 +1,361 @@ +/* + * This file contains definitions used in OFED defined user/kernel + * interfaces. These are imported from the OFED header rdma_cm.h. Oracle + * elects to have and use the contents of rdma_cm.h under and governed + * by the OpenIB.org BSD license (see below for details). However, + * the following notice accompanied the original version of this file: + */ + +/* + * Copyright (c) 2005 Voltaire Inc. All rights reserved. + * Copyright (c) 2005 Intel Corporation. All rights reserved. + * + * This Software is licensed under one of the following licenses: + * + * 1) under the terms of the "Common Public License 1.0" a copy of which is + * available from the Open Source Initiative, see + * http://www.opensource.org/licenses/cpl.php. + * + * 2) under the terms of the "The BSD License" a copy of which is + * available from the Open Source Initiative, see + * http://www.opensource.org/licenses/bsd-license.php. + * + * 3) under the terms of the "GNU General Public License (GPL) Version 2" a + * copy of which is available from the Open Source Initiative, see + * http://www.opensource.org/licenses/gpl-license.php. + * + * Licensee has the right to choose one of the above licenses. + * + * Redistributions of source code must retain the above copyright + * notice and one of the license notices. + * + * Redistributions in binary form must reproduce both the above copyright + * notice, one of the license notices in the documentation + * and/or other materials provided with the distribution. + * + */ + +#ifndef _SYS_IB_CLIENTS_OF_RDMA_RDMA_CM_H +#define _SYS_IB_CLIENTS_OF_RDMA_RDMA_CM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Upon receiving a device removal event, users must destroy the associated + * RDMA identifier and release all resources allocated with the device. + */ +enum rdma_cm_event_type { + RDMA_CM_EVENT_ADDR_RESOLVED, + RDMA_CM_EVENT_ADDR_ERROR, + RDMA_CM_EVENT_ROUTE_RESOLVED, + RDMA_CM_EVENT_ROUTE_ERROR, + RDMA_CM_EVENT_CONNECT_REQUEST, + RDMA_CM_EVENT_CONNECT_RESPONSE, + RDMA_CM_EVENT_CONNECT_ERROR, + RDMA_CM_EVENT_UNREACHABLE, + RDMA_CM_EVENT_REJECTED, + RDMA_CM_EVENT_ESTABLISHED, + RDMA_CM_EVENT_DISCONNECTED, + RDMA_CM_EVENT_DEVICE_REMOVAL, + RDMA_CM_EVENT_MULTICAST_JOIN, + RDMA_CM_EVENT_MULTICAST_ERROR, + RDMA_CM_EVENT_ADDR_CHANGE +}; + +enum rdma_port_space { + RDMA_PS_SDP = 0x0001, + RDMA_PS_IPOIB = 0x0002, + RDMA_PS_TCP = 0x0106, + RDMA_PS_UDP = 0x0111, + RDMA_PS_SCTP = 0x0183 +}; + +struct rdma_addr { + struct sockaddr src_addr; + uint8_t src_pad[sizeof (struct sockaddr_in6) - + sizeof (struct sockaddr)]; + struct sockaddr dst_addr; + uint8_t dst_pad[sizeof (struct sockaddr_in6) - + sizeof (struct sockaddr)]; + struct rdma_dev_addr dev_addr; +}; + +struct rdma_route { + struct rdma_addr addr; + struct ib_sa_path_rec *path_rec; + int num_paths; +}; + +struct rdma_conn_param { + const void *private_data; + uint8_t private_data_len; + uint8_t responder_resources; + uint8_t initiator_depth; + uint8_t flow_control; + uint8_t retry_count; /* ignored when accepting */ + uint8_t rnr_retry_count; + /* Fields below ignored if a QP is created on the rdma_cm_id. */ + uint8_t srq; + uint32_t qp_num; +}; + +struct rdma_ud_param { + const void *private_data; + uint8_t private_data_len; + struct ib_ah_attr ah_attr; + uint32_t qp_num; + uint32_t qkey; +}; + +struct rdma_cm_event { + enum rdma_cm_event_type event; + int status; + union { + struct rdma_conn_param conn; + struct rdma_ud_param ud; + } param; +}; + +struct rdma_cm_id; + +/* + * rdma_cm_event_handler - Callback used to report user events. + * + * Notes: Users may not call rdma_destroy_id from this callback to destroy + * the passed in id, or a corresponding listen id. Returning a + * non-zero value from the callback will destroy the passed in id. + */ +typedef int (*rdma_cm_event_handler)(struct rdma_cm_id *id, + struct rdma_cm_event *event); + +struct rdma_cm_id { + struct ib_device *device; + void *context; + struct ib_qp *qp; + rdma_cm_event_handler event_handler; + struct rdma_route route; + enum rdma_port_space ps; + uint8_t port_num; +}; + +/* + * rdma_create_id - Create an RDMA identifier. + * + * @event_handler: User callback invoked to report events associated with the + * returned rdma_id. + * @context: User specified context associated with the id. + * @ps: RDMA port space. + */ +struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler, + void *context, enum rdma_port_space ps); + +/* + * rdma_map_id2clnthdl - + * Maps RDMA identifier with IBTF and / or ROF client handles. Either + * of the handles can be NULL, but both should not be NULL. This API + * is called just after calling rdma_create_id() on the passive side. + * + * rdma_map_id2qphdl - + * This is used to map RDMA-CM ID to IBTF or ROF client handle and + * the QP handle. This is called by the passive side just after + * rdma_create_id() and on the active side just before rdma_accept() + * in the CONNECTION_REQUEST event handler. + */ +void rdma_map_id2clnthdl(struct rdma_cm_id *id, void *ib_client_hdl, + void *iw_client_hdl); +void rdma_map_id2qphdl(struct rdma_cm_id *id, void *qp_hdl); + +/* + * rdma_destroy_id - Destroys an RDMA identifier. + * + * @id: RDMA identifier. + * + * Note: calling this function has the effect of canceling in-flight + * asynchronous operations associated with the id. + */ +void rdma_destroy_id(struct rdma_cm_id *id); + +/* + * rdma_bind_addr - Bind an RDMA identifier to a source address and + * associated RDMA device, if needed. + * + * @id: RDMA identifier. + * @addr: Local address information. Wildcard values are permitted. + * + * This associates a source address with the RDMA identifier before calling + * rdma_listen. If a specific local address is given, the RDMA identifier will + * be bound to a local RDMA device. + */ +int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr); + +/* + * rdma_resolve_addr - Resolve destination and optional source addresses + * from IP addresses to an RDMA address. If successful, the specified + * rdma_cm_id will be bound to a local device. + * + * @id: RDMA identifier. + * @src_addr: Source address information. This parameter may be NULL. + * @dst_addr: Destination address information. + * @timeout_ms: Time to wait for resolution to complete. + */ +int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, + struct sockaddr *dst_addr, int timeout_ms); + +/* + * rdma_resolve_route - Resolve the RDMA address bound to the RDMA identifier + * into route information needed to establish a connection. + * + * This is called on the client side of a connection. + * Users must have first called rdma_resolve_addr to resolve a dst_addr + * into an RDMA address before calling this routine. + */ +int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms); + + +/* + * rdma_init_qp_attr - Initializes the QP attributes for use in transitioning + * to a specified QP state. + * @id: Communication identifier associated with the QP attributes to + * initialize. + * @qp_attr: On input, specifies the desired QP state. On output, the + * mandatory and desired optional attributes will be set in order to + * modify the QP to the specified state. + * @qp_attr_mask: The QP attribute mask that may be used to transition the + * QP to the specified state. + * + * Users must set the @qp_attr->qp_state to the desired QP state. This call + * will set all required attributes for the given transition, along with + * known optional attributes. Users may override the attributes returned from + * this call before calling ib_modify_qp. + * + * Users that wish to have their QP automatically transitioned through its + * states can associate a QP with the rdma_cm_id by calling rdma_create_qp(). + */ +int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr, + int *qp_attr_mask); +/* + * rdma_connect - Initiate an active connection request. + * @id: Connection identifier to connect. + * @conn_param: Connection information used for connected QPs. + * + * Users must have resolved a route for the rdma_cm_id to connect with + * by having called rdma_resolve_route before calling this routine. + * + * This call will either connect to a remote QP or obtain remote QP + * information for unconnected rdma_cm_id's. The actual operation is + * based on the rdma_cm_id's port space. + */ +int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param); + +/* + * rdma_listen - This function is called by the passive side to + * listen for incoming connection requests. + * + * Users must have bound the rdma_cm_id to a local address by calling + * rdma_bind_addr before calling this routine. + */ +int rdma_listen(struct rdma_cm_id *id, int backlog); + +/* + * rdma_accept - Called to accept a connection request or response. + * @id: Connection identifier associated with the request. + * @conn_param: Information needed to establish the connection. This must be + * provided if accepting a connection request. If accepting a connection + * response, this parameter must be NULL. + * + * Typically, this routine is only called by the listener to accept a connection + * request. It must also be called on the active side of a connection if the + * user is performing their own QP transitions. + * + * In the case of error, a reject message is sent to the remote side and the + * state of the qp associated with the id is modified to error, such that any + * previously posted receive buffers would be flushed. + */ +int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param); + +/* + * rdma_notify - Notifies the RDMA CM of an asynchronous event that has + * occurred on the connection. + * @id: Connection identifier to transition to established. + * @event: Asynchronous event. + * + * This routine should be invoked by users to notify the CM of relevant + * communication events. Events that should be reported to the CM and + * when to report them are: + * + * IB_EVENT_COMM_EST - Used when a message is received on a connected + * QP before an RTU has been received. + */ +int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event); + +/* + * rdma_reject - Called to reject a connection request or response. + */ +int rdma_reject(struct rdma_cm_id *id, const void *private_data, + uint8_t private_data_len); + +/* + * rdma_disconnect - This function disconnects the associated QP and + * transitions it into the error state. + */ +int rdma_disconnect(struct rdma_cm_id *id); + +/* + * rdma_join_multicast - Join the multicast group specified by the given + * address. + * @id: Communication identifier associated with the request. + * @addr: Multicast address identifying the group to join. + * @context: User-defined context associated with the join request, returned + * to the user through the private_data pointer in multicast events. + */ +int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, + void *context); + +/* + * rdma_leave_multicast - Leave the multicast group specified by the given + * address. + */ +void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr); + +/* + * rdma_set_service_type - Set the type of service associated with a + * connection identifier. + * @id: Communication identifier to associated with service type. + * @tos: Type of service. + * + * The type of service is interpretted as a differentiated service + * field (RFC 2474). The service type should be specified before + * performing route resolution, as existing communication on the + * connection identifier may be unaffected. The type of service + * requested may not be supported by the network to all destinations. + */ +void rdma_set_service_type(struct rdma_cm_id *id, int tos); + + +/* + * rdma_create_qp - Allocate a QP and associate it with the specified RDMA + * identifier. + * + * QPs allocated to an rdma_cm_id will automatically be transitioned by the CMA + * through their states. + */ +int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd, + struct ib_qp_init_attr *qp_init_attr); + +/* + * rdma_destroy_qp - Deallocate the QP associated with the specified RDMA + * identifier. + * + * Users must destroy any QP associated with an RDMA identifier before + * destroying the RDMA ID. + */ +void rdma_destroy_qp(struct rdma_cm_id *id); + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_RDMA_RDMA_CM_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/rdma_user_cm.h b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/rdma_user_cm.h new file mode 100644 index 00000000..18dee7d2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/rdma/rdma_user_cm.h @@ -0,0 +1,254 @@ +/* + * This file contains definitions used in OFED defined user/kernel + * interfaces. These are imported from the OFED header rdma_user_cm.h. Oracle + * elects to have and use the contents of rdma_user_cm.h under and governed + * by the OpenIB.org BSD license (see below for for full license text). + * However, * the following notice accompanied the original version of this + * file: + */ + +/* + * Copyright (c) 2005-2006 Intel Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _SYS_IB_CLIENTS_OF_RDMA_RDMA_USER_CM_H +#define _SYS_IB_CLIENTS_OF_RDMA_RDMA_USER_CM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#define RDMA_USER_CM_ABI_VERSION 4 + +#define RDMA_MAX_PRIVATE_DATA 256 + +#pragma pack(1) +enum { + RDMA_USER_CM_CMD_CREATE_ID, + RDMA_USER_CM_CMD_DESTROY_ID, + RDMA_USER_CM_CMD_BIND_ADDR, + RDMA_USER_CM_CMD_RESOLVE_ADDR, + RDMA_USER_CM_CMD_RESOLVE_ROUTE, + RDMA_USER_CM_CMD_QUERY_ROUTE, + RDMA_USER_CM_CMD_CONNECT, + RDMA_USER_CM_CMD_LISTEN, + RDMA_USER_CM_CMD_ACCEPT, + RDMA_USER_CM_CMD_REJECT, + RDMA_USER_CM_CMD_DISCONNECT, + RDMA_USER_CM_CMD_INIT_QP_ATTR, + RDMA_USER_CM_CMD_GET_EVENT, + RDMA_USER_CM_CMD_GET_OPTION, + RDMA_USER_CM_CMD_SET_OPTION, + RDMA_USER_CM_CMD_NOTIFY, + RDMA_USER_CM_CMD_JOIN_MCAST, + RDMA_USER_CM_CMD_LEAVE_MCAST +}; + +/* + * command ABI structures. + */ +struct rdma_ucm_cmd_hdr { + uint32_t cmd; + uint16_t in; + uint16_t out; +}; + +struct rdma_ucm_create_id { + uint64_t uid; + ofv_resp_addr_t response; + uint16_t ps; + uint8_t reserved[6]; +}; + +struct rdma_ucm_create_id_resp { + uint32_t id; +}; + +struct rdma_ucm_destroy_id { + ofv_resp_addr_t response; + uint32_t id; + uint32_t reserved; +}; + +struct rdma_ucm_destroy_id_resp { + uint32_t events_reported; +}; + +struct rdma_ucm_bind_addr { + uint64_t response; + struct sockaddr_in6 addr; + uint32_t id; + uint32_t reserved; +}; + +struct rdma_ucm_resolve_addr { + struct sockaddr_in6 src_addr; + struct sockaddr_in6 dst_addr; + uint32_t id; + uint32_t timeout_ms; +}; + +struct rdma_ucm_resolve_route { + uint32_t id; + uint32_t timeout_ms; +}; + +struct rdma_ucm_query_route { + ofv_resp_addr_t response; + uint32_t id; + uint32_t reserved; +}; + +struct rdma_ucm_query_route_resp { + uint64_t node_guid; + struct ib_user_path_rec ib_route[2]; + struct sockaddr_in6 src_addr; + struct sockaddr_in6 dst_addr; + uint32_t num_paths; + uint8_t port_num; + uint8_t reserved[3]; +}; + +struct rdma_ucm_conn_param { + uint32_t qp_num; + uint32_t reserved; + uint8_t private_data[RDMA_MAX_PRIVATE_DATA]; + uint8_t private_data_len; + uint8_t srq; + uint8_t responder_resources; + uint8_t initiator_depth; + uint8_t flow_control; + uint8_t retry_count; + uint8_t rnr_retry_count; + uint8_t valid; +}; + +struct rdma_ucm_ud_param { + uint32_t qp_num; + uint32_t qkey; + struct ib_uverbs_ah_attr ah_attr; + uint8_t private_data[RDMA_MAX_PRIVATE_DATA]; + uint8_t private_data_len; + uint8_t reserved[7]; + uint8_t reserved2[4]; +}; + +struct rdma_ucm_connect { + struct rdma_ucm_conn_param conn_param; + uint32_t id; + uint32_t reserved; +}; + +struct rdma_ucm_listen { + uint32_t id; + uint32_t backlog; +}; + +struct rdma_ucm_accept { + uint64_t uid; + struct rdma_ucm_conn_param conn_param; + uint32_t id; + uint32_t reserved; +}; + +struct rdma_ucm_reject { + uint32_t id; + uint8_t private_data_len; + uint8_t reserved[3]; + uint8_t private_data[RDMA_MAX_PRIVATE_DATA]; +}; + +struct rdma_ucm_disconnect { + uint32_t id; +}; + +struct rdma_ucm_init_qp_attr { + ofv_resp_addr_t response; + uint32_t id; + uint32_t qp_state; +}; + +struct rdma_ucm_notify { + uint32_t id; + uint32_t event; +}; + +struct rdma_ucm_join_mcast { + ofv_resp_addr_t response; + uint64_t uid; + struct sockaddr_in6 addr; + uint32_t id; + uint32_t reserved; +}; + +struct rdma_ucm_get_event { + ofv_resp_addr_t response; +}; + +struct rdma_ucm_event_resp { + uint64_t uid; + uint32_t id; + uint32_t event; + uint32_t status; + union { + struct rdma_ucm_conn_param conn; + struct rdma_ucm_ud_param ud; + } param; +}; + +/* Option levels */ +enum { + RDMA_OPTION_ID = 0 +}; + +/* Option details */ +enum { + RDMA_OPTION_ID_TOS = 0 +}; + +struct rdma_ucm_set_option { + uint64_t optval; + uint32_t id; + uint32_t level; + uint32_t optname; + uint32_t optlen; +}; +#pragma pack() + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_RDMA_RDMA_USER_CM_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_cma.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_cma.h new file mode 100644 index 00000000..643b720c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_cma.h @@ -0,0 +1,375 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H +#define _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include +#include /* Transport Specific */ + + +#define IS_UDP_CMID(idp) ((idp)->ps == RDMA_PS_UDP || \ + (idp)->ps == RDMA_PS_IPOIB) +#define IS_VALID_SOCKADDR(sockaddrp) \ + ((sockaddrp)->sa_family == AF_INET || \ + (sockaddrp)->sa_family == AF_INET6) + +/* + * Global structure which contains information about all + * CMIDs, which have called rdma_listen(). + */ +typedef struct sol_cma_glbl_listen_s { + avl_node_t cma_listen_node; + + uint64_t cma_listen_chan_sid; + void *cma_listen_clnt_hdl; + void *cma_listen_svc_hdl; + genlist_t cma_listen_chan_list; +} sol_cma_glbl_listen_t; + +/* State of the RDMA-CM ID */ +typedef enum { + SOL_CMA_CHAN_IDLE, + SOL_CMA_CHAN_BOUND, + SOL_CMA_CHAN_ADDR_QUERY, + SOL_CMA_CHAN_ADDR_BOUND, + SOL_CMA_CHAN_ADDR_RESLVD, + SOL_CMA_CHAN_ROUTE_QUERY, + SOL_CMA_CHAN_ROUTE_RESLVD, + + SOL_CMA_CHAN_EVENT_NOTIFIED, + + SOL_CMA_CHAN_CONNECT, + SOL_CMA_CHAN_LISTEN, + SOL_CMA_CHAN_DISCONNECT, + SOL_CMA_CHAN_ACCEPT, + SOL_CMA_CHAN_REJECT, + + SOL_CMA_CHAN_DESTROYING, + SOL_CMA_CHAN_DESTROY_PENDING, + SOL_CMA_CHAN_DESTROY_WAIT, + + SOL_CMA_CHAN_HCA_DOWN, + SOL_CMA_CHAN_PORT_DOWN +} cma_chan_state_t; + +typedef struct listen_info_s { + uint8_t listen_is_root; + + /* For Root CMIDs, pointer to global listen info */ + genlist_entry_t *listen_entry; + sol_cma_glbl_listen_t *chan_glbl_listen_info; + + /* + * For EP CMIDs, pointer to ib_device and root CMID + * for HCA DR + */ + genlist_entry_t *listen_ep_dev_entry; + genlist_entry_t *listen_ep_root_entry; + struct ib_device *listen_ep_device; + + /* + * Count & list of EPs for this listen_info. + * This is 0, if listen_is_root is 0. + */ + uint32_t listen_eps; + genlist_t listen_list; + + /* Transport Specific */ + union { + /* For Root CMID */ + ibt_srv_hdl_t _listen_srv_hdl; + + /* For Endpoint CMID */ + ibt_sbind_hdl_t _listen_sbind_hdl; + } un_listen; +#define listen_ib_srv_hdl un_listen._listen_srv_hdl +#define listen_ib_sbind_hdl un_listen._listen_sbind_hdl +} sol_cma_listen_info_t; + +typedef enum { + SOL_CMA_XPORT_NONE = 0, + SOL_CMA_XPORT_IB, + SOL_CMA_XPORT_IWARP +} sol_cma_xport_type_t; + +/* + * This is used to track the state of a client side CMID. + * CONNECT_NONE Server side CMID, or CMID for which + * rdma_connect() has not been called. + * + * CLIENT_NONE Client side CMID for which connection + * has been torn down. + * + * For UDP it also represents connection + * established (no more IBTF CM events + * expected). + * + * INITIATED rdma_connect() has been called not yet + * established. + * + * ESTABLISHED Client CMID has connection established. + */ +typedef enum { + SOL_CMA_CONNECT_NONE = 0, + SOL_CMA_CONNECT_CLIENT_NONE, + SOL_CMA_CONNECT_INITIATED, + SOL_CMA_CONNECT_ESTABLISHED, +} sol_cma_connect_flag_t; + +/* + * This is used to track the state of CMIDs created for Connection + * Requests and listening CMID. + * + * NONE Client CMID, listen CMID with no REQs yet. + * + * SERVER_DONE REQ CMID connection done, no more events. + * + * For listening CMID all REQ CMIDs have events + * completed. + * + * CREATED listening CMID with > 1 REQ CMID with events + * pending. + * + * QUEUED REQ CMID in REQ AVL tree of listening CMID + * + * ACCEPTED REQ CMID accepted and in ACPT AVL tree of the + * listening CMID. + */ +typedef enum { + REQ_CMID_NONE = 0, + REQ_CMID_SERVER_NONE, + REQ_CMID_CREATED, + REQ_CMID_QUEUED, + REQ_CMID_NOTIFIED, + REQ_CMID_ACCEPTED, +} cma_req_cmid_state_t; + +#define SOL_IS_SERVER_CMID(chanp) \ + ((chanp)->chan_req_state != REQ_CMID_NONE) +#define SOL_IS_CLIENT_CMID(chanp) \ + ((chanp)->chan_connect_flag != SOL_CMA_CONNECT_NONE) + +#define REQ_CMID_IN_REQ_AVL_TREE(chanp) \ + ((chanp)->chan_req_state == REQ_CMID_QUEUED || \ + (chanp)->chan_req_state == REQ_CMID_NOTIFIED) +#define SOL_CMID_CLOSE_REQUIRED(chanp) \ + ((chanp)->chan_connect_flag == SOL_CMA_CONNECT_INITIATED || \ + (chanp)->chan_connect_flag == SOL_CMA_CONNECT_ESTABLISHED || \ + (chanp)->chan_req_state == REQ_CMID_ACCEPTED) +#define SOL_CMAID_CONNECTED(chanp) \ + (SOL_CMID_CLOSE_REQUIRED(chanp) || \ + (chanp)->chan_req_state == REQ_CMID_NOTIFIED) + +/* + * CMID_DESTROYED - Flag to indicate rdma_destroy_id has been + * called for this CMID + * + * EVENT_PROGRESS - RDMACM Event for this CMID been passed to + * the sol_ofs client. + * + * API_PROGRESS - rdma_resolve_addr() / rdma_resolve_route() / + * rdma_listen() is in progress. + */ +#define SOL_CMA_CALLER_CMID_DESTROYED 0x01 +#define SOL_CMA_CALLER_EVENT_PROGRESS 0x02 +#define SOL_CMA_CALLER_API_PROGRESS 0x04 + +typedef struct { + struct rdma_cm_id chan_rdma_cm; + + /* + * Below are all CMA Channel specific fields required in Solaris, + * apart from rdma_cm_id. + */ + + /* AVL Tree for REQs and EST CMIDs */ + avl_node_t chan_req_avl_node; + avl_node_t chan_acpt_avl_node; + avl_tree_t chan_req_avl_tree; + avl_tree_t chan_acpt_avl_tree; + + /* + * chan_req_cnt - + * REQ CMIDs created not yet notified to client + * chan_total_req_cnt - + * REQ CMIDs created not destroy_id(0 not called. + */ + uint64_t chan_req_cnt; + uint64_t chan_req_total_cnt; + + + /* State for Server side and client side CMIDs */ + cma_req_cmid_state_t chan_req_state; + sol_cma_connect_flag_t chan_connect_flag; + + kmutex_t chan_mutex; + kcondvar_t chan_destroy_cv; + cma_chan_state_t chan_state; + uint8_t chan_cmid_destroy_state; + + /* + * Transport type for the rdma_id, IB or IWARP. This is set to + * NONE, when the transport type is not yet determined. + */ + sol_cma_xport_type_t chan_xport_type; + + /* + * Passed from sol_ofs consumer, using the rdma_map_id2clnthdl + * and rdma_map_id2qphdl + */ + void *chan_ib_client_hdl; + void *chan_iw_client_hdl; + void *chan_qp_hdl; + + /* Data for root / endpoint CM ID. */ + sol_cma_listen_info_t *chan_listenp; + + /* Ptr to the root CMID for Endpoint & Req CMID */ + struct rdma_cm_id *listen_root; +#define CHAN_LISTEN_LIST(chanp) (((chanp)->chan_listenp)->listen_list) +#define CHAN_LISTEN_ROOT(chanp) ((chanp)->listen_root) + + struct rdma_conn_param chan_param; + + /* Session ID for completion */ + void *chan_session_id; + + uint32_t chan_qp_num; + uint8_t chan_is_srq; + + union { + ibcma_chan_t chan_ib_xport; + } un_xport; /* Transport specific fields */ +#define chan_ib un_xport.chan_ib_xport +} sol_cma_chan_t; + +void ibcma_append_listen_list(struct rdma_cm_id *); +#ifdef IWARP_SUPPORT +void iwcma_append_listen_list(struct rdma_cm_id *); +#endif + + +extern void cma_generate_event(struct rdma_cm_id *, enum rdma_cm_event_type, + int, struct rdma_conn_param *, struct rdma_ud_param *); +extern struct ib_device *sol_cma_acquire_device(ib_guid_t); + +static inline int +sol_cma_any_addr(struct sockaddr *addr) +{ + ASSERT(addr); + if (addr->sa_family == AF_INET) { + struct sockaddr_in *in_addr; + in_addr = (struct sockaddr_in *)addr; + + return (in_addr->sin_addr.s_addr == INADDR_ANY); + } else if (addr->sa_family == AF_INET6) { + struct sockaddr_in6 *in6_addr; + in6_addr = (struct sockaddr_in6 *)addr; + + return (IN6_IS_ADDR_UNSPECIFIED(&(in6_addr->sin6_addr))); + } + return (0); +} + +static inline struct rdma_cm_id * +cma_create_new_id(struct rdma_cm_id *srcid) +{ + struct rdma_cm_id *newid; + sol_cma_chan_t *new_chanp, *src_chanp; + + newid = rdma_create_id(srcid->event_handler, srcid->context, + srcid->ps); + if (newid == NULL) + return (newid); + + if (srcid->device) { + newid->device = + sol_cma_acquire_device(srcid->device->node_guid); + } + bcopy(&((srcid->route).addr), &((newid->route).addr), + sizeof (struct rdma_addr)); + if ((srcid->route).num_paths) { + int num_paths; + + num_paths = (newid->route).num_paths = + (srcid->route).num_paths; + (newid->route).path_rec = kmem_zalloc(num_paths * + sizeof (struct ib_sa_path_rec), KM_SLEEP); + bcopy(&((srcid->route).path_rec), + &((newid->route).path_rec), + num_paths * sizeof (struct ib_sa_path_rec)); + } + newid->port_num = srcid->port_num; + + new_chanp = (sol_cma_chan_t *)newid; + src_chanp = (sol_cma_chan_t *)srcid; + new_chanp->chan_state = src_chanp->chan_state; + new_chanp->chan_xport_type = src_chanp->chan_xport_type; + if (CHAN_LISTEN_ROOT(src_chanp)) + CHAN_LISTEN_ROOT(new_chanp) = CHAN_LISTEN_ROOT(src_chanp); + else + CHAN_LISTEN_ROOT(new_chanp) = srcid; + return (newid); +} + + +static inline struct rdma_cm_id * +cma_get_req_idp(struct rdma_cm_id *root_idp, void *qp_hdl) +{ + struct rdma_cm_id *req_idp; + sol_cma_chan_t *root_chanp; + + root_chanp = (sol_cma_chan_t *)root_idp; + ASSERT(MUTEX_HELD(&root_chanp->chan_mutex)); + req_idp = (struct rdma_cm_id *)avl_find( + &root_chanp->chan_req_avl_tree, (void *)qp_hdl, NULL); + return (req_idp); +} + +static inline struct rdma_cm_id * +cma_get_acpt_idp(struct rdma_cm_id *root_idp, void *qp_hdl) +{ + struct rdma_cm_id *acpt_idp; + sol_cma_chan_t *root_chanp; + + root_chanp = (sol_cma_chan_t *)root_idp; + ASSERT(MUTEX_HELD(&root_chanp->chan_mutex)); + acpt_idp = (struct rdma_cm_id *)avl_find( + &root_chanp->chan_acpt_avl_tree, (void *)qp_hdl, NULL); + return (acpt_idp); +} +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_ib_cma.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_ib_cma.h new file mode 100644 index 00000000..aec9b202 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_ib_cma.h @@ -0,0 +1,101 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_IB_CMA_H +#define _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_IB_CMA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Global qkey for UDP QPs and multicast groups. */ +#define RDMA_UDP_QKEY 0x01234567 + +typedef struct { + uint64_t dev_node_guid; + uint8_t dev_port_num; + uint16_t dev_pkey_ix; + ib_pkey_t dev_pkey; + ib_gid_t dev_sgid; + ibt_ip_addr_t dev_ipaddr; +} ibcma_dev_t; + +#define IBCMA_LOCAL_ADDR_SET_FLAG 0x01 +#define IBCMA_REMOTE_ADDR_SET_FLAG 0x02 +#define IBCMA_LOCAL_ADDR_IFADDRANY 0x10 + +typedef struct ibcma_chan_s { + /* Pathinfo for CM ID */ + ibt_path_info_t *chan_pathp; + uint8_t chan_numpaths; + size_t chan_path_size; + + /* Address & Service ID for CM ID */ + ibt_ip_addr_t chan_local_addr; + ibt_ip_addr_t chan_remote_addr; + in_port_t chan_port; + ib_svc_id_t chan_sid; + uint8_t chan_addr_flag; + + /* RC REQ information */ + struct rdma_cm_id *chan_req_idp; /* Chan created for Req */ + ibt_adds_vect_t chan_rcreq_addr; + ib_qpn_t chan_rcreq_qpn; + uint8_t chan_rcreq_ra_in; + ibt_ofuvcm_req_data_t chan_rtr_data; + + /* QP Information for CM ID */ + uint8_t chan_qpmodifyflag; + + /* Local device Information */ + ibcma_dev_t *chan_devp; + + /* Multicast list for the CM ID */ + genlist_t chan_mcast_list; + int chan_mcast_cnt; +} ibcma_chan_t; + +typedef struct ibcma_mcast_s { + struct rdma_cm_id *mcast_idp; + void *mcast_ctx; + struct sockaddr_in6 mcast_addr; + ib_gid_t mcast_gid; +} ibcma_mcast_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_IB_CMA_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_kverb_impl.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_kverb_impl.h new file mode 100644 index 00000000..07168b0a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_kverb_impl.h @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H +#define _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * If there is yet an active async event, hdl is not freed. However, + * if the device state is IB_DEV_CLOSE, the device is about to be closed + * so that the event should be discarded. + */ +#define FIRE_QP_EVENT(clnt, hdl, ib_event, qpp, type) \ + rw_enter(&clnt->lock, RW_READER); \ + if (qpp && qpp->event_handler && \ + qpp->device->reg_state == IB_DEV_OPEN) { \ + ib_event.device = qpp->device; \ + ib_event.event = type; \ + ib_event.element.qp = qpp; \ + qpp->event_handler(&ib_event, qpp->qp_context); \ + } \ + rw_exit(&clnt->lock) + +#define FIRE_CQ_EVENT(clnt, hdl, ib_event, cqp, type) \ + rw_enter(&clnt->lock, RW_READER); \ + if (cqp && cqp->event_handler && \ + cqp->device->reg_state == IB_DEV_OPEN) { \ + ib_event.device = cqp->device; \ + ib_event.event = type; \ + ib_event.element.cq = cqp; \ + cqp->event_handler(&ib_event, cqp->cq_context); \ + } \ + rw_exit(&clnt->lock) + +#define IBTF2OF_PGSZ(hca_page_sz) ((hca_page_sz) << 10) +#define OF2IBTF_STATE(s) ((enum ibt_cep_state_e)(s)) +#define OF2IBTF_SRATE(r) ((enum ibt_srate_e)(r)) +#define OF2IBTF_PATH_MIG_STATE(s) ((ibt_cep_cmstate_t)((s)+1)) +#define OF2IBTF_PATH_MTU(m) ((ib_mtu_t)(m)) + +typedef unsigned int gfp_t; + +typedef struct sol_ofs_client_s { + ib_client_t *ib_client; + ibt_clnt_modinfo_t ibt_client; + ibt_clnt_hdl_t ibt_hdl; + uint_t hca_num; + uint_t hca_open_num; + llist_head_t device_list; + llist_head_t client_list; + krwlock_t lock; + enum { + IB_OFS_CLNT_UNINITIALIZED, + IB_OFS_CLNT_INITIALIZED + } state; +} ofs_client_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_ofs_common.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_ofs_common.h new file mode 100644 index 00000000..306f7623 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ofs/sol_ofs_common.h @@ -0,0 +1,252 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * This header file contains definations for utility routines + * which can be used by all Solaris OFUV related kernel drivers + * and misc modules. The kernel modules using these APIs, should + * load sol_ofs using : + * ld -r -N misc/sol_ofs + * + * The APIs defined are : + * 1. User Objects + * 2. Linked Lists + * 3. Debug Routines + */ +#ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_OFS_COMMON_H +#define _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_OFS_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * User Objects functions and structures. + */ +typedef enum { + /* User objects for sol_uverbs driver */ + SOL_UVERBS_UCTXT_UOBJ_TYPE = 0, + SOL_UVERBS_UPD_UOBJ_TYPE, + SOL_UVERBS_UAH_UOBJ_TYPE, + SOL_UVERBS_UMR_UOBJ_TYPE, + SOL_UVERBS_UCQ_UOBJ_TYPE, + SOL_UVERBS_USRQ_UOBJ_TYPE, + SOL_UVERBS_UQP_UOBJ_TYPE, + SOL_UVERBS_UFILE_UOBJ_TYPE, + + /* User Objects for sol_ucma driver */ + SOL_UCMA_EVT_FILE_TYPE, + SOL_UCMA_CM_ID_TYPE, + SOL_UCMA_MCAST_TYPE +} sol_ofs_uobj_type_t; + +typedef struct { + uint64_t uo_user_handle; + sol_ofs_uobj_type_t uo_type; + krwlock_t uo_lock; + uint32_t uo_id; + kmutex_t uo_reflock; + uint32_t uo_refcnt; + uint32_t uo_live; + size_t uo_uobj_sz; +} sol_ofs_uobj_t; + +/* + * Objects are maintained in tables that allow an easy table ID to User Object + * mapping and can grow as resources are created. + */ +#define SOL_OFS_UO_BLKSZ 16 + +typedef struct { + int ofs_uo_blk_avail; + sol_ofs_uobj_t *ofs_uoblk_blks[SOL_OFS_UO_BLKSZ]; +} sol_ofs_uobj_blk_t; + +typedef struct { + krwlock_t uobj_tbl_lock; + int uobj_tbl_used_blks; + uint_t uobj_tbl_num_blks; + size_t uobj_tbl_uo_sz; + int uobj_tbl_uo_cnt; + sol_ofs_uobj_blk_t **uobj_tbl_uo_root; +} sol_ofs_uobj_table_t; + +/* User object table management routines */ +void sol_ofs_uobj_tbl_init(sol_ofs_uobj_table_t *, size_t); +void sol_ofs_uobj_tbl_fini(sol_ofs_uobj_table_t *); + +void sol_ofs_uobj_init(sol_ofs_uobj_t *, uint64_t, sol_ofs_uobj_type_t); +void sol_ofs_uobj_ref(sol_ofs_uobj_t *); +void sol_ofs_uobj_deref(sol_ofs_uobj_t *, +void (*free_func)(sol_ofs_uobj_t *)); +void sol_ofs_uobj_put(sol_ofs_uobj_t *); +void sol_ofs_uobj_free(sol_ofs_uobj_t *uobj); + +int sol_ofs_uobj_add(sol_ofs_uobj_table_t *, sol_ofs_uobj_t *); +sol_ofs_uobj_t *sol_ofs_uobj_remove(sol_ofs_uobj_table_t *, + sol_ofs_uobj_t *); +sol_ofs_uobj_t *sol_ofs_uobj_get_read(sol_ofs_uobj_table_t *, uint32_t); +sol_ofs_uobj_t *sol_ofs_uobj_get_write(sol_ofs_uobj_table_t *, uint32_t); + +/* + * Generic linked list management functions + */ +typedef uchar_t bool; +#define FALSE 0 +#define TRUE 1 +#define INVALID_HANDLE 0xFFFFFFFF +#define MAX_HASH_SIZE 1024 + +/* + * Simple doubly linked list for opaque addresses. Protection must occur + * outside of the list. These behavior very much like the linux kernel + * lists, hence the familiar look of the API; but note there are + * some signficant differences, mainly the list header is not embedded + * in the element, so the container (typeof) constructs are not required. + */ +typedef struct llist_head { + struct llist_head *prv; + struct llist_head *nxt; + void *ptr; +} llist_head_t; + + +#define LLIST_HEAD_INIT(x) { &(x), &(x), NULL } + +static inline void llist_head_init(llist_head_t *list, void *ptr) +{ + list->prv = list->nxt = list; + list->ptr = ptr; +} + +static inline void __llist_add(llist_head_t *new, llist_head_t *prv, + llist_head_t *nxt) +{ + nxt->prv = new; + new->nxt = nxt; + new->prv = prv; + prv->nxt = new; +} +static inline void llist_add(llist_head_t *new, llist_head_t *head) +{ + __llist_add(new, head, head->nxt); +} + +static inline void llist_add_tail(llist_head_t *new, llist_head_t *head) +{ + __llist_add(new, head->prv, head); +} + +static inline void llist_del(llist_head_t *entry) +{ + entry->nxt->prv = entry->prv; + entry->prv->nxt = entry->nxt; +} + +static inline int llist_is_last(llist_head_t *list, llist_head_t *head) +{ + return (list->nxt == head); +} + +static inline int llist_empty(llist_head_t *head) +{ + return (head->nxt == head); +} + +#define list_for_each(_pos, _head) \ + for (_pos = (_head)->nxt; _pos != (_head); _pos = _pos->nxt) +#define list_for_each_safe(_pos, n, _head) \ + for (_pos = (_head)->nxt, n = _pos->nxt; _pos != (_head); \ + _pos = n, n = _pos->nxt) + +/* + * Doubly linked per user context IB resource list definitions + * Protection must occur * outside of the list. + */ +typedef struct genlist_entry_s { + uintptr_t data; + void *data_context; + struct genlist_entry_s *next; + struct genlist_entry_s *prev; +} genlist_entry_t; + +typedef struct genlist_s { + uint32_t count; + genlist_entry_t *head; + genlist_entry_t *tail; +} genlist_t; + + +genlist_entry_t *add_genlist(genlist_t *list, uintptr_t data, + void *data_context); + +#define genlist_for_each(_pos, _head) \ + for (_pos = (_head)->head; _pos; _pos = _pos->next) + +void delete_genlist(genlist_t *list, genlist_entry_t *entry); + +genlist_entry_t *remove_genlist_head(genlist_t *list); + +void insert_genlist_tail(genlist_t *list, genlist_entry_t *entry); + +void flush_genlist(genlist_t *list); + +bool genlist_empty(genlist_t *list); + +static inline void init_genlist(genlist_t *list) +{ + list->head = list->tail = NULL; + list->count = 0; +} + + +/* + * Debug printfs defines + */ +void sol_ofs_dprintf_l5(char *name, char *fmt, ...); +void sol_ofs_dprintf_l4(char *name, char *fmt, ...); +void sol_ofs_dprintf_l3(char *name, char *fmt, ...); +void sol_ofs_dprintf_l2(char *name, char *fmt, ...); +void sol_ofs_dprintf_l1(char *name, char *fmt, ...); +void sol_ofs_dprintf_l0(char *name, char *fmt, ...); + +#define SOL_OFS_DPRINTF_L5 sol_ofs_dprintf_l5 +#define SOL_OFS_DPRINTF_L4 sol_ofs_dprintf_l4 +#define SOL_OFS_DPRINTF_L3 sol_ofs_dprintf_l3 +#define SOL_OFS_DPRINTF_L2 sol_ofs_dprintf_l2 +#define SOL_OFS_DPRINTF_L1 sol_ofs_dprintf_l1 +#define SOL_OFS_DPRINTF_L0 sol_ofs_dprintf_l0 + +/* Misc */ +#define SOL_OFS_DRV_NAME_LEN 64 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_OFS_COMMON_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ucma/sol_rdma_user_cm.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ucma/sol_rdma_user_cm.h new file mode 100644 index 00000000..c2d41d02 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ucma/sol_rdma_user_cm.h @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_UCMA_SOL_RDMA_USER_CM_H +#define _SYS_IB_CLIENTS_OF_SOL_UCMA_SOL_RDMA_USER_CM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Typedefs for data structures defined in rdma_user_cm.h + */ +typedef struct rdma_ucm_cmd_hdr sol_ucma_cmd_hdr_t; +typedef struct rdma_ucm_create_id sol_ucma_create_id_t; +typedef struct rdma_ucm_create_id_resp sol_ucma_create_id_resp_t; +typedef struct rdma_ucm_destroy_id sol_ucma_destroy_id_t; +typedef struct rdma_ucm_destroy_id_resp sol_ucma_destroy_id_resp_t; +typedef struct rdma_ucm_bind_addr sol_ucma_bind_addr_t; +typedef struct rdma_ucm_resolve_addr sol_ucma_resolve_addr_t; +typedef struct rdma_ucm_resolve_route sol_ucma_resolve_route_t; +typedef struct rdma_ucm_query_route sol_ucma_query_route_t; +typedef struct rdma_ucm_query_route_resp + sol_ucma_query_route_resp_t; +typedef struct rdma_ucm_connect sol_ucma_connect_t; +typedef struct rdma_ucm_listen sol_ucma_listen_t; +typedef struct rdma_ucm_accept sol_ucma_accept_t; +typedef struct rdma_ucm_reject sol_ucma_reject_t; +typedef struct rdma_ucm_disconnect sol_ucma_disconnect_t; +typedef struct rdma_ucm_init_qp_attr sol_ucma_init_qp_attr_t; +typedef struct rdma_ucm_notify sol_ucma_notify_t; +typedef struct rdma_ucm_join_mcast sol_ucma_join_mcast_t; +typedef struct rdma_ucm_get_event sol_ucma_get_event_t; +typedef struct rdma_ucm_event_resp sol_ucma_event_resp_t; +typedef struct rdma_ucm_ud_param sol_ucma_ud_param_t; +typedef struct rdma_ucm_set_option sol_ucma_set_option_t; + +#pragma pack(1) +typedef struct { + uint64_t response; + struct sockaddr_in6 addr; + uint32_t id; +} sol_ucma_bind_addr32_t; + +typedef struct { + uint64_t response; + struct sockaddr_in6 addr; + uint32_t id; + uint32_t reserved; +} sol_ucma_bind_addr64_t; + +typedef struct { + uint64_t response; + uint64_t uid; + struct sockaddr_in6 addr; + uint32_t id; +} sol_ucma_join_mcast32_t; + +typedef struct { + uint64_t response; + uint64_t uid; + struct sockaddr_in6 addr; + uint32_t id; + uint32_t reserved; +} sol_ucma_join_mcast64_t; +#pragma pack() + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_SOL_UCMA_SOL_RDMA_USER_CM_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ucma/sol_ucma.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ucma/sol_ucma.h new file mode 100644 index 00000000..f9a000d9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_ucma/sol_ucma.h @@ -0,0 +1,164 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * This is the Solaris uCMA header file. This contains Solaris specific + * data structures and defines for the sol_ucma driver. + */ +#ifndef _SYS_IB_CLIENTS_OF_SOL_UCMA_SOL_UCMA_H +#define _SYS_IB_CLIENTS_OF_SOL_UCMA_SOL_UCMA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +/* + * MAX Number of PATHS supported. This is the same as + * supported by RDMA CM library API revisit - TBD + * + * MAX Number of Listens supported + */ +#define SOL_UCMA_MAX_PATHS 2 +#define SOL_UCMA_MAX_LISTEN 128 + +/* Defines for file_evt_close_flag */ +#define SOL_UCMA_EVT_NONE 0x00 +#define SOL_UCMA_EVT_PROGRESS 0x01 +#define SOL_UCMA_EVT_DISABLED 0x02 + +/* + * RDMA-CM Event File structure + */ +typedef struct { + sol_ofs_uobj_t file_uobj; + kmutex_t file_mutex; + genlist_t file_id_list; + + /* + * Events data + * pollhead - for chpoll(9e) + * event_cv - for blocking wait at GET_EVENT + * evt_list - List of Events + * pending_evt_cnt - Pending Events to be pushed + * to userland. + */ + struct pollhead *file_pollhead; + kcondvar_t file_evt_cv; + kcondvar_t file_evt_close_cv; + genlist_t file_evt_list; + uint32_t file_pending_evt_cnt; + uint8_t file_evt_close_flag; +} sol_ucma_file_t; + +typedef enum { + SOL_UCMA_FLUSH_QP_NONE, + SOL_UCMA_FLUSH_QP_DONE, + SOL_UCMA_FLUSH_QP_PENDING, +} sol_ucma_flush_qp_t; + +/* + * Structure for each IDs created using rdma_create_id() + */ +#define SOL_UCMA_CHAN_CONNECT_FLAG 0x01 + +typedef struct { + sol_ofs_uobj_t chan_uobj; + kmutex_t chan_mutex; + genlist_entry_t *chan_list_ent; + sol_ucma_file_t *chan_file; + + /* Channel id and user ID for this Channel */ + uint32_t chan_id; + uint64_t chan_user_id; + + /* Total events for this channel */ + uint32_t chan_evt_cnt; + + /* rdma_cm_id for this channel */ + struct rdma_cm_id *chan_rdma_id; + + uint32_t chan_qp_num; + void *chan_qp_hdl; + + /* Flush QP flag for this channel */ + sol_ucma_flush_qp_t chan_flush_qp_flag; + + int chan_backlog; + + uint16_t chan_flags; +} sol_ucma_chan_t; + +typedef struct sol_ucma_mcast_s { + sol_ofs_uobj_t mcast_uobj; + uint64_t mcast_uid; + uint32_t mcast_id; + sol_ucma_chan_t *mcast_chan; + struct sockaddr mcast_addr; + uint32_t mcast_events; +} sol_ucma_mcast_t; + +/* + * UCMA Event Structure + */ +typedef struct sol_ucma_event_s { + sol_ucma_event_resp_t event_resp; + sol_ucma_chan_t *event_chan; + sol_ucma_mcast_t *event_mcast; +} sol_ucma_event_t; + +/* + * Global structure for Solaris UCMA Driver. + */ +#define SOL_UCMA_CLNT_HDL_UNINITIALIZED 0x00 +#define SOL_UCMA_CLNT_HDL_INITIALIZING 0x01 +#define SOL_UCMA_CLNT_HDL_INITIALIZED 0x02 +typedef struct sol_ucma_s { + kmutex_t ucma_mutex; + kcondvar_t ucma_open_cv; + dev_info_t *ucma_dip; + uint_t ucma_num_file; + + ldi_ident_t ucma_ldi_ident; + ldi_handle_t ucma_ldi_hdl; + ddi_modhandle_t ucma_mod_hdl; + + void *ucma_ib_clnt_hdl; + void *ucma_iw_clnt_hdl; + + /* Client Handle flag */ + uint8_t ucma_clnt_hdl_flag; +} sol_ucma_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_SOL_UCMA_SOL_UCMA_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_umad/sol_umad.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_umad/sol_umad.h new file mode 100644 index 00000000..07a5252f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_umad/sol_umad.h @@ -0,0 +1,180 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_UMAD_SOL_UMAD_H +#define _SYS_IB_CLIENTS_OF_SOL_UMAD_SOL_UMAD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * map between minor node #s and HCA indexes and Port #s. This leaves + * room for 16 boards with up to 16 ports each. + */ +#define GET_UMAD_MINOR(node, port) ((node << 4) | port) +#define GET_ISSM_MINOR(node, port) ((node << 4) | port | 0x8000) +#define GET_NODE(minor) ((minor >> 4) & 0xf) +#define GET_PORT(minor) ((minor) & 0xf) +#define ISSM_MINOR(minor) (minor & 0x8000) +#define GET_UCTX(minor) (minor >> 8) +#define GET_NEW_UCTX_MINOR(minor, uctxnum) ((uctxnum << 8) | minor) + +/* UMAD KA instance, only one instance allowed */ +#define UMAD_INSTANCE 0 + +#define MAX_UCTX 16 /* Maximum number of contexts. */ + +typedef struct umad_port_info_s umad_port_info_t; + +/* + * User context. One per open file descriptor. + */ +typedef struct umad_uctx_s { + kmutex_t uctx_lock; /* protects agent_list */ + umad_port_info_t *uctx_port; + struct pollhead uctx_pollhead; + llist_head_t uctx_agent_list; /* list of agents registered */ + kmutex_t uctx_recv_lock; /* protects recv_list below */ + genlist_t uctx_recv_list; /* Queue of received MADs */ + kcondvar_t uctx_recv_cv; /* wait on for received data */ +} umad_uctx_t; + +typedef struct umad_agent_s { + llist_head_t agent_list; + struct ib_user_mad_reg_req agent_req; /* Params given during */ + /* registration */ + struct ibmf_reg_info *agent_reg; /* IBMF information */ + umad_uctx_t *agent_uctx; /* User context to which */ + /* this agent belongs. */ + int agent_outstanding_msgs; /* # of msgs waiting */ + /* for a response */ + kmutex_t agent_lock; /* protects this structure */ + int agent_flags; + kcondvar_t agent_cv; /* used to wake up unregister */ +} umad_agent_t; + +enum umad_agent_flags { + UMAD_AGENT_UNREGISTERING = 1 << 0, + UMAD_HANDLING_ASYNC = 1 << 1 +}; + +typedef struct umad_hca_info_s { + ib_guid_t hca_guid; + ibt_hca_hdl_t hca_handle; + ibt_hca_attr_t hca_attr; + uint8_t hca_nports; + umad_port_info_t *hca_ports; +} umad_hca_info_t; + +struct umad_port_info_s { + kmutex_t port_lock; + const umad_hca_info_t *port_hca; /* backpointer to hca */ + unsigned int port_minor_name; /* number in device name. */ + uint8_t port_num; + ib_guid_t port_guid; + int port_issm_open_cnt; + ib_lid_t port_lid; + bool port_has_umad_minor_node; + bool port_has_issm_minor_node; + llist_head_t port_ibmf_regs; +}; + +typedef struct umad_info_s { + dev_info_t *info_dip; /* back pointer to devinfo */ + kmutex_t info_mutex; /* protects this device */ + ibt_clnt_hdl_t info_clnt_hdl; + uint32_t info_hca_count; + ib_guid_t *info_hca_guids; + umad_hca_info_t *info_hcas; /* hca list */ + umad_uctx_t *info_uctx[MAX_UCTX]; +} umad_info_t; + + +typedef struct ib_umad_msg_s { + struct ib_user_mad_hdr umad_msg_hdr; + ibmf_msg_t *umad_msg_ibmf_msg; +} ib_umad_msg_t; + +/* + * A UMAD we send is linked to a user context. + */ +struct umad_send { + struct umad_agent_s *send_agent; /* agent that sent the MAD */ + size_t send_len; + uint8_t send_umad[]; /* MAD from userspace */ +}; + +struct ibmf_reg_info { + ibmf_handle_t ibmf_reg_handle; + unsigned int ibmf_reg_refcnt; + umad_uctx_t *ibmf_reg_uctx; + kmutex_t ibmf_reg_lock; + kcondvar_t ibmf_cv; + unsigned int ibmf_flags; + enum _ibmf_client_type_t ibmf_class; +}; + +/* Flags values for ibmf_flags above */ +enum ibmf_flag_values { + UMAD_IBMF_UNREGISTERING = 1 << 0 +}; + +static inline int +is_supported_mad_method(int nr, void *addr) +{ + return (1 & (((uint32_t *)addr)[nr >> 5] >> (nr & 31))); +} + +static int umad_attach(dev_info_t *dip, ddi_attach_cmd_t cmd); +static int umad_detach(dev_info_t *dip, ddi_detach_cmd_t cmd); +static int umad_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, + void **resultp); +static int umad_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, + int flags, char *name, caddr_t valuep, + int *lengthp); +static int umad_open(dev_t *devp, int flag, int otyp, cred_t *cred); +static int umad_close(dev_t dev, int flag, int otyp, cred_t *cred); +static int umad_read(dev_t dev, struct uio *uiop, cred_t *credp); +static int umad_write(dev_t dev, struct uio *uiop, cred_t *credp); +static int umad_poll(dev_t dev, short events, int anyyet, + short *reventsp, struct pollhead **phpp); +static int umad_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, + cred_t *credp, int *rvalp); + +static void umad_async_handler(void *private, ibt_hca_hdl_t hca_hdl, + ibt_async_code_t code, + ibt_async_event_t *event); +static int umad_register(struct ib_user_mad_reg_req *req, + umad_uctx_t *uctx); +static int umad_unregister(struct ib_user_mad_reg_req *agent, + umad_uctx_t *uctx); +static void umad_unsolicited_cb(ibmf_handle_t ibmf_handle, + ibmf_msg_t *msgp, void *args); +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_SOL_UMAD_SOL_UMAD_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs.h new file mode 100644 index 00000000..ad34be4b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs.h @@ -0,0 +1,438 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_H +#define _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * NAME: sol_uverbs.h + * + * DESC: Solaris OFED User Verbs Kernel Agent header file. + * + */ +#include +#include +#include +#include +#include + +/* + * Definitions + */ +#define SOL_UVERBS_DRIVER_MAX_HCA_MINOR (16) +#define SOL_UVERBS_DRIVER_EVENT_MINOR (17) +#define SOL_UVERBS_DRIVER_MAX_MINOR (18) + + +/* + * Structures + */ + +/* + * Kernel User Verbs Events. + * + * User verbs kernel events (asynchronous and completion) representation. + * IBT events are mapped back to OFA events. + */ +typedef struct uverbs_event { + + union { + struct ib_uverbs_async_event_desc async; + struct ib_uverbs_comp_event_desc comp; + } ev_desc; + + llist_head_t ev_list; + llist_head_t ev_obj_list; + uint32_t *ev_counter; +} uverbs_event_t; + + +/* + * Module Context. + * + * There is a single module context which maintains the list + * of HCA's retrieved from IBT. A user process indicates the + * target HCA open via the uverbs unique minor device number + * associated with the HCA. + */ +typedef struct { + kmutex_t lock; + dev_info_t *dip; + + /* + * Underlying IBT HCA Info + */ + + ibt_clnt_modinfo_t clnt_modinfo; + ibt_clnt_hdl_t clnt_hdl; + uint32_t hca_count; + ib_guid_t *hca_guid_list; + sol_uverbs_hca_t *hcas; + + /* + * Support user asyncrhonous and completion event delivery via + * user event filesystem. + */ + dev_t dev; +} uverbs_module_context_t; + +/* + * User Event File. + * + * Used for delivery of asynchronous and synchronous events to the user. + * An asynchronous event file is created during the allocation of + * a user verbs consumer context, a completion event file is created + * when the user verbs consumer creates a completion channel. + */ +typedef struct uverbs_ufile_uobj { + sol_ofs_uobj_t uobj; + kmutex_t lock; + int ref; + kcondvar_t poll_wait; + pollhead_t poll_head; + struct uverbs_uctxt_uobj *uctxt; + int is_async; + llist_head_t event_list; + sol_uverbs_cq_ctrl_t ufile_notify_enabled; + uint32_t ufile_cq_cnt; +} uverbs_ufile_uobj_t; + +/* + * Type of user context - + */ +#define SOL_UVERBS_UCTXT_VERBS 0x001 +#define SOL_UVERBS_UCTXT_EVENT 0x100 +#define SOL_UVERBS_UCTXT_ASYNC 0x101 +#define SOL_UVERBS_UCTXT_COMPL 0x110 + +/* + * User Context. + * + * A user context is created when a user process opens a specific minor + * device. The context maintains a list of resources created by this + * user that allows the resources to be cleaned up on user close. + */ +typedef struct uverbs_uctxt_uobj { + sol_ofs_uobj_t uobj; + kmutex_t lock; + uverbs_module_context_t *mod_ctxt; + sol_uverbs_hca_t *hca; /* short cut to specific hca */ + + /* + * List of user resource objects created by this context. The + * objects themselves live in the associated object table, and + * the code should use the table to access and use resources. + * Any objects that remain in these list will be destroyed at + * user close to free the associated resources. + * + * The user context "lock" should be held when invoking + * routines to manipulate the lists. + */ + genlist_t pd_list; + genlist_t mr_list; + genlist_t cq_list; + genlist_t qp_list; + genlist_t srq_list; + genlist_t ah_list; + + /* + * Event filesystem interfaces for IB asyncrhonous events + * and completion events. + */ + uverbs_ufile_uobj_t *comp_evfile; + uverbs_ufile_uobj_t *async_evfile; + + /* + * User context can be created for : + * 1. All Verbs API + * 2. For getting a file for async events. + * 3. For getting a file for completion events. + * For (1) - pointers to (2) & (3) will be updated. For (2) and (3) + * pointer to (1) will be maintained. + */ + uint16_t uctxt_type; + uint32_t uctxt_verbs_id; + uint32_t uctxt_async_id; + uint32_t uctxt_comp_id; + uint8_t uctxt_free_pending; +} uverbs_uctxt_uobj_t; + +/* + * User PD objects created at PD allocation + */ +typedef struct uverbs_upd_uobj { + sol_ofs_uobj_t uobj; + ibt_pd_hdl_t pd; + genlist_entry_t *list_entry; /* per user ctx list entry */ + uint32_t active_qp_cnt; + uint8_t free_pending; +} uverbs_upd_uobj_t; + +/* + * User MR objects created at MR registration + */ +typedef struct uverbs_umr_uobj { + sol_ofs_uobj_t uobj; + ibt_mr_hdl_t mr; + genlist_entry_t *list_entry; /* per user ctx list entry */ +} uverbs_umr_uobj_t; + +/* + * User CQ objects created at CQ allocation + */ +typedef struct uverbs_ucq_uobj { + sol_ofs_uobj_t uobj; + ibt_cq_hdl_t cq; + genlist_entry_t *list_entry; /* per user ctx list entry */ + uverbs_uctxt_uobj_t *uctxt; + uverbs_ufile_uobj_t *comp_chan; + uint32_t comp_events_reported; + uint32_t async_events_reported; + llist_head_t async_list; + llist_head_t comp_list; + uint32_t active_qp_cnt; + uint8_t free_pending; +} uverbs_ucq_uobj_t; + +/* + * User Shared Receive CQ objects created at SRQ allocation + */ +typedef struct uverbs_usrq_uobj { + sol_ofs_uobj_t uobj; + ibt_srq_hdl_t srq; + genlist_entry_t *list_entry; /* per user ctx list entry */ + uverbs_uctxt_uobj_t *uctxt; + uint32_t async_events_reported; + llist_head_t async_list; + uint32_t active_qp_cnt; + uint8_t free_pending; +} uverbs_usrq_uobj_t; + +/* + * User address handle objects created at AH allocation + */ +typedef struct uverbs_uah_uobj { + sol_ofs_uobj_t uobj; + ibt_ah_hdl_t ah; + genlist_entry_t *list_entry; /* per user ctx list entry */ +} uverbs_uah_uobj_t; + +/* + * User QP objects created at QP allocation + */ +#define SOL_UVERBS_UQP_RCQ_VALID 0x01 +#define SOL_UVERBS_UQP_SRQ_VALID 0x02 + +typedef struct uverbs_uqp_uobj { + sol_ofs_uobj_t uobj; + ibt_qp_hdl_t qp; + genlist_entry_t *list_entry; /* per uctx list */ + uint32_t max_inline_data; + uverbs_uctxt_uobj_t *uctxt; + uint32_t qp_num; /* 24 bits valid */ + uint32_t disable_qp_mod; + enum ib_qp_type ofa_qp_type; + llist_head_t mcast_list; + llist_head_t async_list; + uint32_t async_events_reported; + uverbs_ucq_uobj_t *uqp_rcq; + uverbs_ucq_uobj_t *uqp_scq; + + uint32_t uqp_pd_hdl; + uint32_t uqp_scq_hdl; + uint32_t uqp_rcq_hdl; + uint32_t uqp_srq_hdl; + uint8_t uqp_rcq_srq_valid; + + sol_uverbs_qp_free_state_t uqp_free_state; +} uverbs_uqp_uobj_t; + +extern sol_ofs_uobj_table_t uverbs_uctxt_uo_tbl; +extern sol_ofs_uobj_table_t uverbs_upd_uo_tbl; +extern sol_ofs_uobj_table_t uverbs_uah_uo_tbl; +extern sol_ofs_uobj_table_t uverbs_umr_uo_tbl; +extern sol_ofs_uobj_table_t uverbs_ucq_uo_tbl; +extern sol_ofs_uobj_table_t uverbs_usrq_uo_tbl; +extern sol_ofs_uobj_table_t uverbs_uqp_uo_tbl; +extern sol_ofs_uobj_table_t uverbs_ufile_uo_tbl; + +/* + * The following structure is used currently to pass data back to + * libmthca on user allocation context. This should be passed opaquely + * to maintain a true hal, we'll look for a generic way to get this information + * and deliver it opaquely post EA-1. + */ +struct mthca_alloc_ucontext_resp { + uint32_t qp_tab_size; + uint32_t uarc_size; +}; + +struct ib_udata { + void *inbuf; + void *outbuf; + size_t inlen; + size_t outlen; +}; + +int sol_uverbs_dummy_command(uverbs_uctxt_uobj_t *uctxt, char *buf, + int in_len, int out_len); +int sol_uverbs_get_context(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_alloc_pd(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_dealloc_pd(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_create_ah(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_destroy_ah(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_query_device(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_query_port(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_query_gid(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_query_pkey(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_reg_mr(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_dereg_mr(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); +int sol_uverbs_create_comp_channel(uverbs_uctxt_uobj_t *uctxt, char *buf, + int in_len, int out_len); + +uint32_t +sol_uverbs_ibt_to_of_device_cap_flags(ibt_hca_flags_t flags, + ibt_hca_flags2_t flags2); + +uint64_t +sol_uverbs_ibt_to_of_page_sz(ibt_page_sizes_t page_szs); + +int sol_uverbs_ibt_to_kernel_status(ibt_status_t status); +uint32_t sol_uverbs_qpnum2uqpid(uint32_t qp_num); + +int uverbs_upd_free(uverbs_upd_uobj_t *, uverbs_uctxt_uobj_t *); +int uverbs_uqp_free(uverbs_uqp_uobj_t *, uverbs_uctxt_uobj_t *); +int uverbs_usrq_free(uverbs_usrq_uobj_t *, uverbs_uctxt_uobj_t *); +int uverbs_ucq_free(uverbs_ucq_uobj_t *, uverbs_uctxt_uobj_t *); + +/* + * The following helpers simply provide easy access for acquiring and locking + * User Objects. + */ +static inline uverbs_uctxt_uobj_t * +uverbs_uobj_get_uctxt_read(uint32_t id) +{ + return (uverbs_uctxt_uobj_t *) + sol_ofs_uobj_get_read(&uverbs_uctxt_uo_tbl, id); +} +static inline uverbs_uctxt_uobj_t * +uverbs_uobj_get_uctxt_write(uint32_t id) +{ + return (uverbs_uctxt_uobj_t *) + sol_ofs_uobj_get_write(&uverbs_uctxt_uo_tbl, id); +} +static inline uverbs_upd_uobj_t * +uverbs_uobj_get_upd_read(uint32_t id) +{ + return (uverbs_upd_uobj_t *) + sol_ofs_uobj_get_read(&uverbs_upd_uo_tbl, id); +} +static inline uverbs_upd_uobj_t * +uverbs_uobj_get_upd_write(uint32_t id) +{ + return (uverbs_upd_uobj_t *) + sol_ofs_uobj_get_write(&uverbs_upd_uo_tbl, id); +} +static inline uverbs_umr_uobj_t * +uverbs_uobj_get_umr_read(uint32_t id) +{ + return (uverbs_umr_uobj_t *) + sol_ofs_uobj_get_read(&uverbs_umr_uo_tbl, id); +} +static inline uverbs_umr_uobj_t * +uverbs_uobj_get_umr_write(uint32_t id) +{ + return (uverbs_umr_uobj_t *) + sol_ofs_uobj_get_write(&uverbs_umr_uo_tbl, id); +} +static inline uverbs_ucq_uobj_t * +uverbs_uobj_get_ucq_read(uint32_t id) +{ + return (uverbs_ucq_uobj_t *) + sol_ofs_uobj_get_read(&uverbs_ucq_uo_tbl, id); +} +static inline uverbs_ucq_uobj_t * +uverbs_uobj_get_ucq_write(uint32_t id) +{ + return (uverbs_ucq_uobj_t *) + sol_ofs_uobj_get_write(&uverbs_ucq_uo_tbl, (int)id); +} +static inline uverbs_usrq_uobj_t * +uverbs_uobj_get_usrq_read(uint32_t id) +{ + return (uverbs_usrq_uobj_t *) + sol_ofs_uobj_get_read(&uverbs_usrq_uo_tbl, id); +} +static inline uverbs_usrq_uobj_t * +uverbs_uobj_get_usrq_write(uint32_t id) +{ + return (uverbs_usrq_uobj_t *) + sol_ofs_uobj_get_write(&uverbs_usrq_uo_tbl, id); +} +static inline uverbs_uah_uobj_t * +uverbs_uobj_get_uah_read(uint32_t id) +{ + return (uverbs_uah_uobj_t *) + sol_ofs_uobj_get_read(&uverbs_uah_uo_tbl, id); +} +static inline uverbs_uah_uobj_t * +uverbs_uobj_get_uah_write(uint32_t id) +{ + return (uverbs_uah_uobj_t *) + sol_ofs_uobj_get_write(&uverbs_uah_uo_tbl, id); +} +static inline uverbs_uqp_uobj_t * +uverbs_uobj_get_uqp_read(uint32_t id) +{ + return (uverbs_uqp_uobj_t *) + sol_ofs_uobj_get_read(&uverbs_uqp_uo_tbl, id); +} +static inline uverbs_uqp_uobj_t * +uverbs_uobj_get_uqp_write(uint32_t id) +{ + return (uverbs_uqp_uobj_t *) + sol_ofs_uobj_get_write(&uverbs_uqp_uo_tbl, id); +} + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs2ucma.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs2ucma.h new file mode 100644 index 00000000..a90cb635 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs2ucma.h @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * This header file contains definations for APIs which are exported by + * sol_uverbs for use by sol_ucma + */ +#ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS2UCMA_H +#define _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS2UCMA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define SOL_UCMA_UVERBS_PATH "/ib/sol_uverbs@0:ucma" + +/* + * This API returns the IB & iWARP client handles that sol_uverbs uses + * to interact with Solaris IBTF and iWARP frameworks. + */ +#define SOL_UVERBS_GET_CLNT_HDL "sol_uverbs_get_clnt_hdl" +typedef void (*uverbs_get_clnt_hdl_t) (void **, void **); + +/* + * This API returns the QP handle used by Solaris IBTF / iWARP framework + * for an QP. The QP number is the input for this API. NULL is returned + * for QP not allocated by sol_uverbs. + */ +#define SOL_UVERBS_QPNUM2QPHDL "sol_uverbs_qpnum2qphdl" +typedef void *(*uverbs_qpnum2qphdl_t) (uint32_t); + +/* + * This API disables user QP modifies for an QP specified by the input + * QP number. It returns 0 on succcess and non-0 on failure. + */ +#define SOL_UVERBS_DISABLE_UQPN_MODIFY "sol_uverbs_disable_uqpn_modify" +typedef int (*uverbs_disable_uqpn_mod_t)(uint32_t); + +/* + * This API enables / disables CQ notification for all CQs assosiated + * with the QP. This is done to ensure that the first completion event + * is send to userland *after* connection is established. + */ +typedef enum { + SOL_UVERBS2UCMA_CQ_NOTIFY_NOT_SET = 0, + SOL_UVERBS2UCMA_CQ_NOTIFY_ENABLE, + SOL_UVERBS2UCMA_CQ_NOTIFY_DISABLE +} sol_uverbs_cq_ctrl_t; +#define SOL_UVERBS_UQPN_CQ_CTRL "sol_uverbs_uqpn_cq_ctrl" +typedef int (*uverbs_uqpn_cq_ctrl_t)(uint32_t, sol_uverbs_cq_ctrl_t); + +/* + * This API sets the QP free state. The uint32_t uqpid is passed for + * disabling QP free and void *qphdl is passed for enabling QP free. + */ +typedef enum { + SOL_UVERBS2UCMA_ENABLE_QP_FREE, + SOL_UVERBS2UCMA_DISABLE_QP_FREE, + SOL_UVERBS2UCMA_FREE_PENDING +} sol_uverbs_qp_free_state_t; +#define SOL_UVERBS_SET_QPFREE_STATE "sol_uverbs_set_qp_free_state" +typedef void (*uverbs_set_qp_free_state_t)(sol_uverbs_qp_free_state_t, + uint32_t, void *); + +/* + * This API flushes the QP specified by the QP num + */ +#define SOL_UVERBS_FLUSH_QP "sol_uverbs_flush_qp" +typedef void (*uverbs_flush_qp_t)(uint32_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS2UCMA_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_comp.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_comp.h new file mode 100644 index 00000000..7edfa743 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_comp.h @@ -0,0 +1,79 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_COMP_H +#define _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_COMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * NAME: sol_uverbs_comp.h + * + * DESC: OFED User Verbs Kernel Completion Queue related defines and structures. + * + */ + + +/* + * Definitions + */ + +/* + * Structures + */ + +/* + * Functions - See sol_uverbs_comp.c for descriptions. + */ +int +sol_uverbs_create_cq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int +sol_uverbs_destroy_cq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int +sol_uverbs_resize_cq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int +sol_uverbs_req_notify_cq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int +sol_uverbs_poll_cq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +void +sol_uverbs_comp_event_handler(ibt_cq_hdl_t ibt_cq, void *arg); + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_COMP_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_event.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_event.h new file mode 100644 index 00000000..83e71ee5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_event.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_EVENT_H +#define _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_EVENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * NAME: sol_uverbs_event.h + * + * DESC: Solaris User Verbs Kernel Async Event structures and definitions. + * + */ + + +/* + * Functions - See sol_uverbs_event.c for descriptions. + */ +uverbs_ufile_uobj_t *uverbs_alloc_event_file(uverbs_uctxt_uobj_t *uctxt, + int is_async); + +void uverbs_release_event_file(sol_ofs_uobj_t *uobj); + +void uverbs_async_event_handler(void *clnt_private, ibt_hca_hdl_t hca_hdl, + ibt_async_code_t code, ibt_async_event_t *event); + +void uverbs_release_ucq_channel(uverbs_uctxt_uobj_t *uctxt, + uverbs_ufile_uobj_t *comp_chan, uverbs_ucq_uobj_t *ucq); + +void uverbs_release_ucq_uevents(uverbs_ufile_uobj_t *ev_file, + uverbs_ucq_uobj_t *ucq); + +void uverbs_release_uqp_uevents(uverbs_ufile_uobj_t *ev_file, + uverbs_uqp_uobj_t *uqp); + +void uverbs_release_usrq_uevents(uverbs_ufile_uobj_t *ev_file, + uverbs_usrq_uobj_t *usrq); + +void sol_uverbs_event_file_close(uverbs_ufile_uobj_t *); + +int sol_uverbs_event_file_read(uverbs_ufile_uobj_t *, struct uio *uiop, + cred_t *cred); + +int sol_uverbs_event_file_poll(uverbs_ufile_uobj_t *, short events, int anyyet, + short *reventsp, pollhead_t **phpp); + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_EVENT_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_hca.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_hca.h new file mode 100644 index 00000000..46b6cc11 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_hca.h @@ -0,0 +1,184 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H +#define _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * NAME: sol_uverbs_hca.h + * + * DESC: Solaris OFED hca management utility. + * + * This file implements a very thin layer that provides the OFA user kernel + * agents the ability to operate in the same IBT/HCA domain. That is all + * of the OFA user space kernel agents share the same IBT client handle, + * opened by the sol_uverbs driver. + * + */ + +#include + +/* + * Definitions + */ + +/* + * Structures + */ + +/* + * HCA Info. + * + * Each IBT HCA the sol_uverbs driver knows about is maintained in a + * a list that points to IBT handles and the client event handler + * callbacks. + */ +typedef struct sol_uverbs_hca { + llist_head_t list; + llist_head_t event_handler_list; + kmutex_t event_handler_lock; + llist_head_t client_data_list; + kmutex_t client_data_lock; + ibt_clnt_hdl_t clnt_hdl; + ib_guid_t guid; + ibt_hca_hdl_t hdl; + ibt_hca_attr_t attr; + uint32_t nports; + ibt_hca_portinfo_t *ports; + size_t pinfosz; +} sol_uverbs_hca_t; + +/* + * Client structure passed to Solaris User Verbs to provide addtion and + * removal callbacks. The "add" function will be invoked for each + * IBT hca in the system when it is available, the "remove" will be + * invoked when an IBT hca is no longer available. + */ +typedef struct sol_uverbs_ib_client { + llist_head_t list; + char *name; + void (*add)(sol_uverbs_hca_t *); + void (*remove)(sol_uverbs_hca_t *); +} sol_uverbs_ib_client_t; + +/* + * Event handler structure passed to Solaris User Verbs hca management + * to register an asynchronous event handler for an IBT hca. + */ +typedef struct sol_uverbs_ib_event_handler { + llist_head_t list; + sol_uverbs_hca_t *hca; + void (*handler)(struct sol_uverbs_ib_event_handler *, + ibt_hca_hdl_t hca, + ibt_async_code_t code, + ibt_async_event_t *event); +} sol_uverbs_ib_event_handler_t; + +#define SOL_UVERBS_INIT_IB_EVENT_HANDLER(_struct_ptr, _hca_ptr, _func_ptr) \ + do { \ + (_struct_ptr)->hca = _hca_ptr; \ + (_struct_ptr)->handler = _func_ptr; \ + llist_head_init(&(_struct_ptr)->list, 0); \ + } while (0) + +/* + * Control structures for managmenet of common HCA list. + */ +extern kmutex_t sol_uverbs_hca_lock; +extern llist_head_t sol_uverbs_hca_list; +extern llist_head_t sol_uverbs_client_list; + +/* + * Functions + */ +/* + * sol_uverbs HCA list management and helper sol_uverbs nternal functions. + */ +int sol_uverbs_common_hca_init(); +void sol_uverbs_common_hca_fini(); +sol_uverbs_hca_t *sol_uverbs_ibt_hdl_to_hca(ibt_hca_hdl_t hdl); + +/* + * COMMON HCA CLIENT API - See sol_uverbs_hca.c for complete + * function description. + */ + +/* + * Register for client notifications. The "add" function pointer + * in the client structure will be invoked for each hca in the system, the + * "remove" function pointer will be invoked as hca's are no longer + * available. + */ +int sol_uverbs_ib_register_client(sol_uverbs_ib_client_t *client); + +/* + * Unregister for client notifications. + */ +void sol_uverbs_ib_unregister_client(sol_uverbs_ib_client_t *client); + +/* + * Mechanism for client to associate private data with each IBT hca. + */ +void *sol_uverbs_ib_get_client_data(sol_uverbs_hca_t *hca, + sol_uverbs_ib_client_t *client); + +void sol_uverbs_ib_set_client_data(sol_uverbs_hca_t *hca, + sol_uverbs_ib_client_t *client, void *data); + +/* + * Mechanism for client to register/unregister for asynchronous event callbacks. + */ +int +sol_uverbs_ib_register_event_handler(sol_uverbs_ib_event_handler_t *handler); + +int +sol_uverbs_ib_unregister_event_handler(sol_uverbs_ib_event_handler_t *handler); + +/* + * HELPER API provided by sol_uverbs, see sol_uverbs_qp.c for complete + * descriptions. + */ + +/* + * Map a user QP id to an IBT QP Handle. + */ +ibt_qp_hdl_t sol_uverbs_uqpid_to_ibt_handle(uint32_t u_qpid); + +/* + * Inform sol_uverbs to igonore requested modify QP calls for the + * specific QP. + */ +int sol_uverbs_disable_user_qp_modify(uint32_t u_qpid); +int sol_uverbs_enable_user_qp_modify(uint32_t u_qpid); + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_qp.h b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_qp.h new file mode 100644 index 00000000..03f49b3b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/clients/of/sol_uverbs/sol_uverbs_qp.h @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_QP_H +#define _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_QP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NAME: sol_uverbs_qp.h + * + * DESC: OFED User Verbs Kernel Queue Pair structures and definitions + * + */ + +/* + * Definitions + */ +#define IBT_TO_OFA_QP_STATE(_state) ((_state) < IBT_STATE_SQDRAIN ? \ + (enum ib_qp_state)(_state) : IB_QPS_SQD) + +/* + * Structures + */ + +/* + * Functions - See sol_uverbs_qp.c for descriptions + */ +int sol_uverbs_create_qp(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_destroy_qp(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_modify_qp(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_query_qp(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_create_srq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_modify_srq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_query_srq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_destroy_srq(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_attach_mcast(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +int sol_uverbs_detach_mcast(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len, + int out_len); + +void uverbs_detach_uqp_mcast_entries(uverbs_uqp_uobj_t *uqp); + +#ifdef __cplusplus +} +#endif +#endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_QP_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ib_pkt_hdrs.h b/illumos-x86_64/usr/include/sys/ib/ib_pkt_hdrs.h new file mode 100644 index 00000000..3dcc5cb7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ib_pkt_hdrs.h @@ -0,0 +1,105 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_IB_PKT_HDRS_H +#define _SYS_IB_IB_PKT_HDRS_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _ib_lrh_hdr_t { + uint8_t VL_LVer; /* virtual lane pkt is using & */ + /* link level protocol of pkt */ + uint8_t SL_LNH; /* requested service level */ + /* & headers following LRH */ + ib_lid_t DLID; /* dest port and path on subnet */ + uint16_t PktLen; /* size of packet in four-byte words */ + ib_lid_t SLID; /* source port on subnet */ +} ib_lrh_hdr_t; + +/* defines and masks that go with local routing header */ +#define IB_LRH_VL_MASK 0xF0 +#define IB_LRH_VERSION_MASK 0x0F +#define IB_LRH_SL_MASK 0xF0 +#define IB_LRH_NEXT_HDR_MASK 0x03 +#define IB_LRH_NEXT_HDR_RWH 0x00 +#define IB_LRH_NEXT_HDR_IPV6 0x01 +#define IB_LRH_NEXT_HDR_BTH 0x02 +#define IB_LRH_NEXT_HDR_GRH 0x03 +#define IB_LRH_PACKET_LENGTH_MASK 0x07FF + +typedef struct _ib_grh_t { + uint32_t IPVer_TC_Flow; /* version, traffic class & */ + /* flow label of the packet */ + uint16_t PayLen; /* len of the pkt following the GRH */ + uint8_t NxtHdr; /* Header following the GRH */ + uint8_t HopLmt; /* max hops the pkt can take */ + ib_gid_t SGID; /* GID of the source port */ + ib_gid_t DGID; /* GID of the consuming port */ +} ib_grh_t; + +/* defines and masks that go with global route header */ +#define IB_GRH_IPVER_MASK 0xF0000000 +#define IB_GRH_TCLASS_MASK 0x0FF00000 +#define IB_GRH_FLOW_LABEL_MASK 0x000FFFFF +#define IB_GRH_NEXT_HDR_BTH 0x1B + +typedef struct _ib_bth_hdr_t { + uint8_t OpCode; /* iba packet type */ + uint8_t SE_M_PadCnt_TVer; /* responder should generate event */ + /* & migration state & payload pad count */ + /* & version of ibta transport headers */ + uint16_t P_Key; /* logical partition assoc with pkt */ + uint32_t Reserved_DestQP; /* queue pair of dest */ + uint32_t A_PSN; /* responder should generate ack & */ + /* packet sequence number */ +} ib_bth_hdr_t; + +/* defines and masks that go with base transport header */ +#define IB_BTH_SOLICITED_EVENT_MASK 0x80 +#define IB_BTH_MIG_REQ_MASK 0x40 +#define IB_BTH_PAD_CNT_MASK 0x30 +#define IB_BTH_TVER_MASK 0x0F +#define IB_BTH_DEST_QP_MASK 0x00FFFFFF +#define IB_BTH_ACK_REQ_MASK 0x80000000 +#define IB_BTH_PSN_MASK 0x00FFFFFF + +typedef struct _ib_deth_hdr_t { + uint32_t Q_Key; /* queue key */ + uint32_t Reserved_SrcQP; /* queue pair of the source */ +} ib_deth_hdr_t; + +#define IB_DETH_SRC_QP_MASK 0x00FFFFFF + +/* defines and masks that go with datagram extended transport header */ +#define IB_DETH_SRC_QP_MASK 0x00FFFFFF + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IB_PKT_HDRS_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ib_types.h b/illumos-x86_64/usr/include/sys/ib/ib_types.h new file mode 100644 index 00000000..2855bfb2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ib_types.h @@ -0,0 +1,208 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_IB_TYPES_H +#define _SYS_IB_IB_TYPES_H + +/* + * ib_types.h + * + * Data definitions for all IBTA primitive data types. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Addressing types + * See Chapter 4 of the IBTA Volume 1 IB specification for more details. + */ +#define IB_EUI64_COMPANYID_MASK 0x0000000000FFFFFF +#define IB_EUI64_COMPANYID_SHIFT 40 +#define IB_EUI64_IDENTIFIER_MASK 0x000000FFFFFFFFFF + +/* LID Ranges */ +#define IB_LID_UC_FIRST 0x0001 +#define IB_LID_UC_LAST 0xBFFF +#define IB_LID_MC_FIRST 0xC000 +#define IB_LID_MC_LAST 0xFFFE +#define IB_LID_PERMISSIVE 0xFFFF + +/* Unicast GID & Multicast GID */ +typedef uint64_t ib_guid_t; /* EUI-64 GUID */ +typedef uint64_t ib_sn_prefix_t; /* Subnet Prefix */ + +typedef struct ib_ucast_gid_s { + ib_sn_prefix_t ugid_prefix; /* GID prefix */ + ib_guid_t ugid_guid; /* Port GUID */ +} ib_ucast_gid_t; + +typedef struct ib_mcast_gid_s { + uint32_t mcast_gid_prefix; /* flags, scope, and signature */ + uint8_t mcast_gid_bytes[12]; +} ib_mcast_gid_t; + +typedef struct ib_gid_s { + union { + ib_ucast_gid_t ucast_gid; /* unicast gid */ + ib_mcast_gid_t mcast_gid; /* multicast gid */ + } gid; +} ib_gid_t; + +#define gid_prefix gid.ucast_gid.ugid_prefix +#define gid_guid gid.ucast_gid.ugid_guid + +#define mgid_prefix gid.mcast_gid.mcast_gid_prefix +#define mgid_bytes gid.mcast_gid.mcast_gid_bytes + +#define IB_GID_DEFAULT_PREFIX 0xFE80000000000000 +#define IB_GID_SUBNET_LOCAL_PREFIX IB_GID_DEFAULT_PREFIX +#define IB_GID_SITE_LOCAL_PREFIX 0xFEC0000000000000 +#define IB_GID_SITE_LOCAL_SUBNET_MASK 0x000000000000FFFF + +/* Multicast GID. */ +#define IB_MCGID_PREFIX 0xFF000000 +#define IB_MCGID_TRANSIENT_FLAG 0x00100000 + +/* Multicast Address Scope. */ +#define IB_MC_SCOPE_SUBNET_LOCAL 0x02 +#define IB_MC_SCOPE_SITE_LOCAL 0x05 +#define IB_MC_SCOPE_ORG_LOCAL 0x08 +#define IB_MC_SCOPE_GLOBAL 0x0E + +/* Multicast Join State. */ +#define IB_MC_JSTATE_FULL 0x01 /* Full Member */ +#define IB_MC_JSTATE_NON 0x02 /* Non Member */ +#define IB_MC_JSTATE_SEND_ONLY_NON 0x04 /* Send Only Non Member */ + +#define IB_MC_QPN 0xFFFFFF /* Multicast QPN */ + +/* + * IP-on-IB Multicast GIDs + * + * IPV4 gid_prefix: + * IB_MCGID_IPV4_PREFIX + * IB_MCGID_SCOPE_MASK + * IB_MCGID_IP_PKEY_MASK + * IPV4 gid_guid: + * IB_MCGID_IPV4_LOW_GROUP_MASK + * + * IPV6 gid_prefix: + * IB_MCGID_IPV6_PREFIX + * IB_MCGID_SCOPE_MASK + * IB_MCGID_IP_PKEY_MASK + * IB_MCGID_IPV6_HI_GROUP_MASK + * IPV6 gid_guid: + * entire gid_guid holds low part of group ID + */ +#define IB_MCGID_IPV4_PREFIX 0xFF10401B +#define IB_MCGID_IPV6_PREFIX 0xFF10601B +#define IB_MCGID_SA_PREFIX 0xFF10A01B + +typedef uint16_t ib_lid_t; /* Port Local ID (LID) */ +typedef uint8_t ib_path_bits_t; /* From 0 to 7 low order bits of LID */ + +/* + * PKeys and QKeys + */ +#define IB_PKEY_DEFAULT_FULL 0xFFFF +#define IB_PKEY_DEFAULT_LIMITED 0x7FFF +#define IB_PKEY_INVALID_FULL 0x8000 +#define IB_PKEY_INVALID_LIMITED 0x0000 +#define IB_GSI_QKEY 0x80010000 +#define IB_PRIVILEGED_QKEY_BIT 0x80000000 + +typedef uint16_t ib_pkey_t; /* P_Key */ +typedef uint32_t ib_qkey_t; /* Q_Key */ +typedef uint16_t ib_pkey_cntr_t; +typedef uint16_t ib_qkey_cntr_t; + +/* + * General IBT types + */ +typedef uint64_t ib_smkey_t; /* subnet manager key */ + +typedef uint16_t ib_ethertype_t; /* Ethertype */ +typedef uint32_t ib_qpn_t; /* 24 bit QP number */ +typedef uint32_t ib_eecn_t; /* 24 bit EEC number */ + +#define IB_QPN_MASK 0xFFFFFF + +typedef uint32_t ib_msglen_t; /* message length */ + +typedef uint64_t ib_vaddr_t; /* registered memory Virtual Address */ +typedef uint64_t ib_memlen_t; /* registered memory length */ + +typedef uint64_t ib_svc_id_t; /* CM Service ID */ + +#define IB_SVC_NAME_LEN 64 /* Maximum length of Service Name, */ + /* which includes a terminating NULL */ +#define IB_SVC_DATA_LEN 64 /* Length of Service Data */ + +/* MTU Size */ +typedef enum { + IB_MTU_NOT_SPECIFIED = 0, + IB_MTU_256 = 1, /* 256 bytes */ + IB_MTU_512 = 2, /* 512 bytes */ + IB_MTU_1K = 3, /* 1k bytes */ + IB_MTU_2K = 4, /* 2k bytes */ + IB_MTU_4K = 5 /* 4k bytes */ +} ib_mtu_t; + +typedef uint8_t ib_time_t; /* 6 bits of timeout exponent */ +#define IB_TIME_EXP_MASK 0x3F /* time = 4.096us * 2 ^ exp */ + +/* + * Infiniband Identifiers, based on Administration Group Number (AGN) codes + * there are different types of Service IDs which identifies the group. + * The first byte of the Service ID comprises of AGN field and following + * specifies the values for AGN field. + * + * 0x0 - IBTA assigned Ids (WellKnown) + * 0x1 - IETF (any category) + * 0x2 - Locally assigned Ids with limited cacheability + * 0x10 to 0x1f - External Organizations assigned Ids (Well Known) + * others - Reserved + */ +#define IB_SID_MASK 0x00FFFFFFFFFFFFFF +#define IB_SID_AGN_MASK 0xFF00000000000000 + +#define IB_SID_AGN_IBTA 0x0000000000000000 +#define IB_SID_AGN_IETF 0x0100000000000000 +#define IB_SID_AGN_LOCAL 0x0200000000000000 + +#define IB_SID_IPADDR_PREFIX 0x0000000001000000 /* Byte 4 */ +#define IB_SID_IPADDR_PREFIX_MASK 0xFFFFFFFFFE000000 +#define IB_SID_IPADDR_IPNUM_MASK 0x0000000000FF0000 /* Byte 5 */ +#define IB_SID_IPADDR_PORTNUM_MASK 0x000000000000FFFF /* Byte 6 & 7 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IB_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibnex/ibnex_devctl.h b/illumos-x86_64/usr/include/sys/ib/ibnex/ibnex_devctl.h new file mode 100644 index 00000000..8d74d61c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibnex/ibnex_devctl.h @@ -0,0 +1,628 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_IBNEX_IBNEX_DEVCTL_H +#define _SYS_IB_IBNEX_IBNEX_DEVCTL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains info for devctls issued by IB cfgadm plugin. + * The only devctl of interest is DEVCTL_AP_CONTROL which uses + * these defines and data structures. + */ + +#define IBNEX_HCAGUID_STRSZ 17 + +/* + * types of attachment point Identifiers (APID)s supported + */ +#define IBNEX_BASE_APID 0x01 /* Base static attachment point */ +#define IBNEX_HCA_APID 0x02 /* HCA static attachment point */ +#define IBNEX_DYN_APID 0x04 /* Dynamic IOC/DLPI attachment point */ +#define IBNEX_UNKNOWN_APID 0x08 /* Unknown attachment point */ + + +/* defines for dynamic APID handling */ +#define DYN_SEP "::" +#define GET_DYN(a) (((a) != NULL) ? strstr((a), DYN_SEP) : (void *)0) + +#define IBNEX_FABRIC "fabric" +#define IBNEX_VPPA_STR "vppa" +#define IBNEX_PORT_STR "port" +#define IBNEX_HCASVC_STR "hca-svc" + +/* Enums while reading ib.conf file */ +typedef enum ib_service_type_e { + IB_NAME, /* name = */ + IB_CLASS, /* class = */ + IB_PORT_SERVICE, /* port-svc-list = */ + IB_VPPA_SERVICE, /* vppa-svc-list = */ + IB_HCASVC_SERVICE, /* hca-svc-list = */ + IB_NONE +} ib_service_type_t; + +/* + * defines for nvlist types: (for PORT devices and IOCs) + * The first 6 are common to both IOC and PORT devices. + * The last 9 are used only for IOC devices. + */ +#define IBNEX_NODE_INFO_NVL "node_info" +#define IBNEX_NODE_APID_NVL "node_apid" +#define IBNEX_NODE_TYPE_NVL "node_type" +#define IBNEX_NODE_RSTATE_NVL "node_rstate" +#define IBNEX_NODE_OSTATE_NVL "node_ostate" +#define IBNEX_NODE_COND_NVL "node_condition" + +/* + * This flag is passed from cfgadm to ib(4D) to convey that it + * need not attempt to probe the fabric. + * + * The value of these flags should be same as flags in enum + * ibdm_ibnex_get_ioclist_mtd_t. + */ +#define IBNEX_DONOT_PROBE_FLAG 1 +#define IBNEX_NORMAL_PROBE 0 /* flag used by ib(4D) only */ + +/* + * The following are sub-commands to DEVCTL_AP_CONTROL. + * NOTE: IBNEX_NUM_DEVICE_NODES and IBNEX_NUM_HCA_NODES need to be + * separate. The former is used to figure out the dynamic ap_ids for + * the IB fabric. The latter is used for a HCA count on a given host only. + */ +#define IBNEX_NUM_DEVICE_NODES 0x00010 /* how many device nodes exist? */ +#define IBNEX_NUM_HCA_NODES 0x00020 /* how many HCAs exist in the host? */ +#define IBNEX_SNAPSHOT_SIZE 0x00040 /* What is the "snapshot" size? */ +#define IBNEX_GET_SNAPSHOT 0x00080 /* Get the actual dynamic "snapshot" */ +#define IBNEX_DEVICE_PATH_SZ 0x00100 /* Given APID's device path size */ +#define IBNEX_GET_DEVICE_PATH 0x00200 /* Get device path for a Dynamic APID */ +#define IBNEX_HCA_LIST_SZ 0x00400 /* -x list_clients size for HCA APID */ +#define IBNEX_HCA_LIST_INFO 0x00800 /* -x list_clients info for HCA APID */ +#define IBNEX_UNCFG_CLNTS_SZ 0x01000 /* -x unconfig_clients option size */ +#define IBNEX_UNCFG_CLNTS_INFO 0x02000 /* -x unconfig_clients option data */ +#define IBNEX_UPDATE_PKEY_TBLS 0x04000 /* -x update_pkey_tbls */ +#define IBNEX_CONF_ENTRY_ADD 0x08000 /* -x conf_file add_service */ +#define IBNEX_CONF_ENTRY_DEL 0x10000 /* -x conf_file delete_service */ +#define IBNEX_HCA_VERBOSE_SZ 0x20000 /* -alv hca_apid devctl size */ +#define IBNEX_HCA_VERBOSE_INFO 0x40000 /* -alv hca_apid devctl data */ +#define IBNEX_UPDATE_IOC_CONF 0x80000 /* -x update_ioc_conf */ + +/* + * Data structure passed back and forth user/kernel w/ DEVCTL_AP_CONTROL + * devctl. Note that these are separate structures as some fields are pointers. + */ +typedef struct ibnex_ioctl_data { + uint_t cmd; /* one of the above commands */ + caddr_t buf; /* data buffer */ + uint_t bufsiz; /* data buffer size */ + caddr_t ap_id; /* Search based on this AP_ID name */ + uint_t ap_id_len; /* AP_ID name len */ + uint_t misc_arg; /* reserved */ +} ibnex_ioctl_data_t; + + +/* For 32-bit app/64-bit kernel */ +typedef struct ibnex_ioctl_data_32 { + uint32_t cmd; /* one of the above commands */ + caddr32_t buf; /* data buffer */ + uint32_t bufsiz; /* data buffer size */ + caddr32_t ap_id; /* Search based on this AP_ID name */ + uint32_t ap_id_len; /* AP_ID name len */ + uint32_t misc_arg; /* reserved */ +} ibnex_ioctl_data_32_t; + +/* + * General ibnex IOCTLs + * + * IBNEX_CTL_GET_API_VER + * ====================== + * + * Gets the version number of the API that IB nexus currently supports. + * + * arg - pointer to a structure of type ibnex_ctl_api_ver_t + * + * Caller does not set any field of this structure. When this IOCTL is issued, + * ib nexus will set api_ver_num field to the currently supported API + * version number. + * + * The caller could issue this IOCTL prior to issuing any other general + * ibnex IOCTLs to detect incompatible changes to the API. The caller may + * call other IOCTLs only if the api_ver_num matches the API version number + * used by the caller. + * + * + * IBNEX_CTL_GET_HCA_LIST + * ====================== + * + * Gets GUIDs of all HCAs in the system + * + * arg - pointer to a structure of type ibnex_ctl_get_hca_list_t + * + * Caller allocates memory for HCA GUIDs. Sets hca_guids field to point to the + * allocated memory. Sets hca_guids_alloc_sz to the number of GUIDs for which + * memory has been allocated. + * + * Upon successful return from the IOCTL, nhcas will contain the number of + * HCAs in the system. HCA GUIDs will be copied into hca_guids array. + * The number of GUIDs copied are nhcas or hca_guids_alloc_sz which ever is + * smaller. + * + * + * IBNEX_CTL_QUERY_HCA + * =================== + * + * Query HCA attributes + * + * arg - pointer to a structure of type ibnex_ctl_query_hca_t + * + * Caller sets hca_guid field of this structure. + * + * Caller allocates memory for hca device path. Sets hca_device_path to point + * to the allocated memory and hca_device_path_alloc_sz to the number of bytes + * allocated. + * + * Upon successful return from the IOCTL, hca_info will contain HCA attributes + * for the specified GUID. hca_info.hca_device_path_len will contain the actual + * string length of the hca device path plus one (for the terminating null + * character). hca_info.hca_device_path will point to null terminated hca device + * path string if the caller allocated memory for the hca device path is large + * enough to hold the hca device path and the terminating null character. + * Otherwise hca_info.hca_device_path will be set to NULL. + * + * + * IBNEX_CTL_QUERY_HCA_PORT + * ======================== + * + * Query HCA port attributes + * + * arg - pointer to a structure of type ibnex_ctl_query_hca_port_t + * + * Caller sets hca_guid and port_num fields. + * + * Caller allocates memory for sgid entries. Sets sgid_tbl to point to + * the allocated memory and sgid_tbl_alloc_sz to the number of sgid entries + * for which memory has been allocated. + * + * Caller allocates memory for pkey entries. Sets pkey_tbl to point to + * the allocated memory and pkey_tbl_alloc_sz to the number of pkey entries + * for which memory has been allocated. + * + * Upon successful return from the IOCTL, port_info will contain HCA port + * attributes for the specified HCA port. port_info.p_sgid_tbl_sz will contain + * the actual number of sgids associated with this port. port_info.p_pkey_tbl_sz + * will contain the actual number of pkeys associated with this port. + * + * port_info.p_sgid_tbl will point to an array containing sgids. The number of + * sgids in the array is sgid_tbl_alloc_sz or port_info.p_sgid_tbl_sz + * whichever is smaller. + * + * port_info.p_pkey_tbl will point to an array containing pkeys. The number of + * pkeys in the array is pkey_tbl_alloc_sz or port_info.p_pkey_tbl_sz + * whichever is smaller. + * + * Error numbers for the above ioctls upon failure: + * EINVAL Invalid parameter passed + * EFAULT A fault occurred copying data to or from the user space + * to the kernel space. + * ENXIO Specified HCA GUID does not exist + * ENOENT Specified HCA port does not exist + * + */ + + +/* + * ibnex specific ioctls + * + * NOTE: The ioctl codes should not collide with generic devctl ioctls + * such as DEVCTL_AP_CONFIGURE. + */ +#define IBNEX_IOC (1 << 16) +#define IBNEX_CTL_GET_API_VER (IBNEX_IOC + 1) /* Get API version # */ +#define IBNEX_CTL_GET_HCA_LIST (IBNEX_IOC + 2) /* Get HCA GUID list */ +#define IBNEX_CTL_QUERY_HCA (IBNEX_IOC + 3) /* Query HCA attributes */ +#define IBNEX_CTL_QUERY_HCA_PORT (IBNEX_IOC + 4) /* Query HCA port attributes */ + +/* + * The device to open for issuing ibnex IOCTLs + */ +#define IBNEX_DEVCTL_DEV "/devices/ib:devctl" + +/* + * ibnex IOCTL API version number - to be incremented when making an + * incompatible change to the API. + */ +#define IBNEX_CTL_API_VERSION 1 + +#define MAX_HCA_DRVNAME_LEN 16 + +/* + * Data structure for IBNEX_CTL_GET_API_VER + */ +typedef struct ibnex_ctl_api_ver_s { + uint_t api_ver_num; /* out: supported API version */ +} ibnex_ctl_api_ver_t; + +/* + * Data structure for IBNEX_CTL_GET_HCA_LIST + */ +typedef struct ibnex_ctl_get_hca_list_s { + ib_guid_t *hca_guids; /* in/out: HCA GUID array */ + uint_t hca_guids_alloc_sz; /* in: # of HCA GUIDs for */ + /* which storage is allocated */ + uint_t nhcas; /* out: actual number of HCAs */ +} ibnex_ctl_get_hca_list_t; + +typedef struct ibnex_ctl_get_hca_list_32_s { + caddr32_t hca_guids; /* in/out: HCA GUID array */ + uint_t hca_guids_alloc_sz; /* in: # of HCA GUIDs for */ + /* which storage is allocated */ + uint_t nhcas; /* out: actual number of HCAs */ +} ibnex_ctl_get_hca_list_32_t; + +/* + * HCA information structure + */ +typedef struct ibnex_ctl_hca_info_s { + ib_guid_t hca_node_guid; /* Node GUID */ + ib_guid_t hca_si_guid; /* Optional System Image GUID */ + uint_t hca_nports; /* Number of physical ports */ + + /* HCA driver name and instance number */ + char hca_driver_name[MAX_HCA_DRVNAME_LEN]; + int hca_driver_instance; + + /* + * hca device path and the length. + * hca_device_path_len contains the string length of the actual hca + * device path plus one (for the terminating null character). + */ + char *hca_device_path; + uint_t hca_device_path_len; + + ibt_hca_flags_t hca_flags; /* HCA capabilities etc */ + ibt_hca_flags2_t hca_flags2; /* HCA capabilities etc */ + + uint32_t hca_vendor_id; /* Vendor ID */ + uint16_t hca_device_id; /* Device ID */ + uint32_t hca_version_id; /* Version ID */ + + uint_t hca_max_chans; /* Max channels supported */ + uint_t hca_max_chan_sz; /* Max outstanding WRs on any */ + /* channel */ + + uint_t hca_max_sgl; /* Max SGL entries per WR */ + + uint_t hca_max_cq; /* Max num of CQs supported */ + uint_t hca_max_cq_sz; /* Max capacity of each CQ */ + + ibt_page_sizes_t hca_page_sz; /* Bit mask of page sizes */ + + uint_t hca_max_memr; /* Max num of HCA mem regions */ + ib_memlen_t hca_max_memr_len; /* Largest block, in bytes of */ + /* mem that can be registered */ + uint_t hca_max_mem_win; /* Max Memory windows in HCA */ + + uint_t hca_max_rsc; /* Max Responder Resources of */ + /* this HCA for RDMAR/Atomics */ + /* with this HCA as target. */ + uint8_t hca_max_rdma_in_chan; /* Max RDMAR/Atomics in per */ + /* chan this HCA as target. */ + uint8_t hca_max_rdma_out_chan; /* Max RDMA Reads/Atomics out */ + /* per channel by this HCA */ + uint_t hca_max_ipv6_chan; /* Max IPV6 channels in HCA */ + uint_t hca_max_ether_chan; /* Max Ether channels in HCA */ + + uint_t hca_max_mcg_chans; /* Max number of channels */ + /* that can join multicast */ + /* groups */ + uint_t hca_max_mcg; /* Max multicast groups */ + uint_t hca_max_chan_per_mcg; /* Max number of channels per */ + /* Multicast group in HCA */ + uint16_t hca_max_partitions; /* Max partitions in HCA */ + + ib_time_t hca_local_ack_delay; + + uint_t hca_max_port_sgid_tbl_sz; + uint16_t hca_max_port_pkey_tbl_sz; + uint_t hca_max_pd; /* Max# of Protection Domains */ + + uint_t hca_max_ud_dest; + uint_t hca_max_srqs; /* Max SRQs supported */ + uint_t hca_max_srqs_sz; /* Max outstanding WRs on any */ + /* SRQ */ + uint_t hca_max_srq_sgl; /* Max SGL entries per SRQ WR */ + uint_t hca_max_cq_handlers; + ibt_lkey_t hca_reserved_lkey; /* Reserved L_Key value */ + uint_t hca_max_fmrs; /* Max FMR Supported */ + + uint_t hca_max_lso_size; + uint_t hca_max_lso_hdr_size; + uint_t hca_max_inline_size; + + uint_t hca_max_cq_mod_count; /* CQ notify moderation */ + uint_t hca_max_cq_mod_usec; + + uint32_t hca_fw_major_version; /* firmware version */ + uint16_t hca_fw_minor_version; + uint16_t hca_fw_micro_version; + + /* detailed WQE size info */ + uint_t hca_ud_send_inline_sz; /* inline size in bytes */ + uint_t hca_conn_send_inline_sz; + uint_t hca_conn_rdmaw_inline_overhead; + uint_t hca_recv_sgl_sz; /* detailed SGL sizes */ + uint_t hca_ud_send_sgl_sz; + uint_t hca_conn_send_sgl_sz; + uint_t hca_conn_rdma_sgl_overhead; + int32_t hca_pad; +} ibnex_ctl_hca_info_t; + +typedef struct ibnex_ctl_hca_info_32_s { + ib_guid_t hca_node_guid; /* Node GUID */ + ib_guid_t hca_si_guid; /* Optional System Image GUID */ + uint_t hca_nports; /* Number of physical ports */ + + /* HCA driver name and instance number */ + char hca_driver_name[MAX_HCA_DRVNAME_LEN]; + int hca_driver_instance; + + /* + * hca device path and the length. + * hca_device_path_len contains the string length of the actual hca + * device path plus one (for the terminating null character). + */ + caddr32_t hca_device_path; + uint_t hca_device_path_len; + + ibt_hca_flags_t hca_flags; /* HCA capabilities etc */ + ibt_hca_flags2_t hca_flags2; /* HCA capabilities etc */ + + uint32_t hca_vendor_id; /* Vendor ID */ + uint16_t hca_device_id; /* Device ID */ + uint32_t hca_version_id; /* Version ID */ + + uint_t hca_max_chans; /* Max channels supported */ + uint_t hca_max_chan_sz; /* Max outstanding WRs on any */ + /* channel */ + + uint_t hca_max_sgl; /* Max SGL entries per WR */ + + uint_t hca_max_cq; /* Max num of CQs supported */ + uint_t hca_max_cq_sz; /* Max capacity of each CQ */ + + ibt_page_sizes_t hca_page_sz; /* Bit mask of page sizes */ + + uint_t hca_max_memr; /* Max num of HCA mem regions */ + ib_memlen_t hca_max_memr_len; /* Largest block, in bytes of */ + /* mem that can be registered */ + uint_t hca_max_mem_win; /* Max Memory windows in HCA */ + + uint_t hca_max_rsc; /* Max Responder Resources of */ + /* this HCA for RDMAR/Atomics */ + /* with this HCA as target. */ + uint8_t hca_max_rdma_in_chan; /* Max RDMAR/Atomics in per */ + /* chan this HCA as target. */ + uint8_t hca_max_rdma_out_chan; /* Max RDMA Reads/Atomics out */ + /* per channel by this HCA */ + uint_t hca_max_ipv6_chan; /* Max IPV6 channels in HCA */ + uint_t hca_max_ether_chan; /* Max Ether channels in HCA */ + + uint_t hca_max_mcg_chans; /* Max number of channels */ + /* that can join multicast */ + /* groups */ + uint_t hca_max_mcg; /* Max multicast groups */ + uint_t hca_max_chan_per_mcg; /* Max number of channels per */ + /* Multicast group in HCA */ + uint16_t hca_max_partitions; /* Max partitions in HCA */ + + ib_time_t hca_local_ack_delay; + + uint_t hca_max_port_sgid_tbl_sz; + uint16_t hca_max_port_pkey_tbl_sz; + uint_t hca_max_pd; /* Max# of Protection Domains */ + + uint_t hca_max_ud_dest; + uint_t hca_max_srqs; /* Max SRQs supported */ + uint_t hca_max_srqs_sz; /* Max outstanding WRs on any */ + /* SRQ */ + uint_t hca_max_srq_sgl; /* Max SGL entries per SRQ WR */ + uint_t hca_max_cq_handlers; + ibt_lkey_t hca_reserved_lkey; /* Reserved L_Key value */ + uint_t hca_max_fmrs; /* Max FMR Supported */ + + uint_t hca_max_lso_size; + uint_t hca_max_lso_hdr_size; + uint_t hca_max_inline_size; + + uint_t hca_max_cq_mod_count; /* CQ notify moderation */ + uint_t hca_max_cq_mod_usec; + + uint32_t hca_fw_major_version; /* firmware version */ + uint16_t hca_fw_minor_version; + uint16_t hca_fw_micro_version; + + /* detailed WQE size info */ + uint_t hca_ud_send_inline_sz; /* inline size in bytes */ + uint_t hca_conn_send_inline_sz; + uint_t hca_conn_rdmaw_inline_overhead; + uint_t hca_recv_sgl_sz; /* detailed SGL sizes */ + uint_t hca_ud_send_sgl_sz; + uint_t hca_conn_send_sgl_sz; + uint_t hca_conn_rdma_sgl_overhead; + int32_t hca_pad; +} ibnex_ctl_hca_info_32_t; + +/* + * Data structure for IBNEX_CTL_QUERY_HCA + */ +typedef struct ibnex_ctl_query_hca_s { + ib_guid_t hca_guid; /* in: HCA GUID */ + + /* + * in: user allocated memory pointer for hca device path and number of + * bytes allocated for the hca device path. + */ + char *hca_device_path; + uint_t hca_device_path_alloc_sz; + + ibnex_ctl_hca_info_t hca_info; /* out: HCA information */ +} ibnex_ctl_query_hca_t; + +typedef struct ibnex_ctl_query_hca_32_s { + ib_guid_t hca_guid; /* in: HCA GUID */ + + /* + * in: user allocated memory pointer for hca device path and number of + * bytes allocated for the hca device path. + */ + caddr32_t hca_device_path; + uint_t hca_device_path_alloc_sz; + + ibnex_ctl_hca_info_32_t hca_info; /* out: HCA information */ +} ibnex_ctl_query_hca_32_t; + +/* + * HCA port information structure + */ +typedef struct ibnex_ctl_hca_port_info_s { + ib_lid_t p_lid; /* Base LID of port */ + ib_qkey_cntr_t p_qkey_violations; /* Bad Q_Key cnt */ + ib_pkey_cntr_t p_pkey_violations; /* Optional bad P_Key cnt */ + uint8_t p_sm_sl; /* SM Service level */ + ib_port_phys_state_t p_phys_state; + ib_lid_t p_sm_lid; /* SM LID */ + ibt_port_state_t p_linkstate; /* Port state */ + uint8_t p_port_num; /* Port number */ + + ib_link_width_t p_width_supported; + ib_link_width_t p_width_enabled; + ib_link_width_t p_width_active; + + ib_mtu_t p_mtu; /* Max transfer unit - pkt */ + uint8_t p_lmc; /* LID mask control */ + + ib_link_speed_t p_speed_supported; + ib_link_speed_t p_speed_enabled; + ib_link_speed_t p_speed_active; + + ib_gid_t *p_sgid_tbl; /* SGID Table */ + uint_t p_sgid_tbl_sz; /* # of entries in SGID table */ + + ib_pkey_t *p_pkey_tbl; /* P_Key table */ + uint16_t p_pkey_tbl_sz; /* # of entries in P_Key tbl */ + uint16_t p_def_pkey_ix; /* default pkey index for TI */ + + uint8_t p_max_vl; /* Max num of virtual lanes */ + uint8_t p_init_type_reply; /* Optional InitTypeReply */ + ib_time_t p_subnet_timeout; /* Max Subnet Timeout */ + ibt_port_caps_t p_capabilities; /* Port Capabilities */ + uint32_t p_msg_sz; /* Max message size */ +} ibnex_ctl_hca_port_info_t; + +typedef struct ibnex_ctl_hca_port_info_32_s { + ib_lid_t p_lid; /* Base LID of port */ + ib_qkey_cntr_t p_qkey_violations; /* Bad Q_Key cnt */ + ib_pkey_cntr_t p_pkey_violations; /* Optional bad P_Key cnt */ + uint8_t p_sm_sl; /* SM Service level */ + ib_port_phys_state_t p_phys_state; + ib_lid_t p_sm_lid; /* SM LID */ + ibt_port_state_t p_linkstate; /* Port state */ + uint8_t p_port_num; /* Port number */ + + ib_link_width_t p_width_supported; + ib_link_width_t p_width_enabled; + ib_link_width_t p_width_active; + + ib_mtu_t p_mtu; /* Max transfer unit - pkt */ + uint8_t p_lmc; /* LID mask control */ + + ib_link_speed_t p_speed_supported; + ib_link_speed_t p_speed_enabled; + ib_link_speed_t p_speed_active; + + caddr32_t p_sgid_tbl; /* SGID Table */ + uint_t p_sgid_tbl_sz; /* # of entries in SGID table */ + + caddr32_t p_pkey_tbl; /* P_Key table */ + uint16_t p_pkey_tbl_sz; /* # of entries in P_Key tbl */ + uint16_t p_def_pkey_ix; /* default pkey index for TI */ + + uint8_t p_max_vl; /* Max num of virtual lanes */ + uint8_t p_init_type_reply; /* Optional InitTypeReply */ + ib_time_t p_subnet_timeout; /* Max Subnet Timeout */ + ibt_port_caps_t p_capabilities; /* Port Capabilities */ + uint32_t p_msg_sz; /* Max message size */ +} ibnex_ctl_hca_port_info_32_t; + +/* + * Data structure for IBNEX_CTL_QUERY_HCA_PORT + */ +typedef struct ibnex_ctl_query_hca_port_s { + ib_guid_t hca_guid; /* in: HCA GUID */ + uint_t port_num; /* in: port number */ + + ib_gid_t *sgid_tbl; /* in: SGID Table */ + uint_t sgid_tbl_alloc_sz; /* in: # of entries in SGID table */ + + ib_pkey_t *pkey_tbl; /* in: P_Key table */ + uint_t pkey_tbl_alloc_sz; /* in: # of entries in P_Key table */ + + uint32_t pad; + ibnex_ctl_hca_port_info_t port_info; /* out: port information */ +} ibnex_ctl_query_hca_port_t; + +typedef struct ibnex_ctl_query_hca_port_32_s { + ib_guid_t hca_guid; /* in: HCA GUID */ + uint_t port_num; /* in: port number */ + + caddr32_t sgid_tbl; /* in: SGID Table */ + uint_t sgid_tbl_alloc_sz; /* in: # of entries in SGID table */ + + caddr32_t pkey_tbl; /* in: P_Key table */ + uint_t pkey_tbl_alloc_sz; /* in: # of entries in P_Key table */ + + uint32_t pad; + ibnex_ctl_hca_port_info_32_t port_info; /* out: port information */ +} ibnex_ctl_query_hca_port_32_t; + +#ifdef _KERNEL +_NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_hca_info_s)) +_NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_hca_port_info_s)) +_NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_hca_port_info_32_s)) +_NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_query_hca_port_s)) +_NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_query_hca_port_32_s)) +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBNEX_IBNEX_DEVCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/ibci.h b/illumos-x86_64/usr/include/sys/ib/ibtl/ibci.h new file mode 100644 index 00000000..b620b51e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/ibci.h @@ -0,0 +1,503 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_IBTL_IBCI_H +#define _SYS_IB_IBTL_IBCI_H + +/* + * ibci.h + * + * Define the data structures and function prototypes that comprise + * the IB Channel API (API for HCA drivers). All CI handles are opaque + * to the IBTF here, real data is accessed in the HCA driver by a + * typecast to a driver specific struct. + */ + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Define CI opaque IBTF handles. + */ +typedef struct ibtl_qp_s *ibtl_qp_hdl_t; /* ibt_alloc_qp() */ +typedef struct ibtl_eec_s *ibtl_eec_hdl_t; /* ibt_alloc_eec() */ + +/* + * Define IBTF opaque CI handles. + */ +typedef struct ibc_hca_s *ibc_hca_hdl_t; /* HCA/CI Handle */ +typedef struct ibc_pd_s *ibc_pd_hdl_t; /* Protection Domain Handle */ +typedef struct ibc_rdd_s *ibc_rdd_hdl_t; /* Reliable Datagram Domain */ +typedef struct ibc_ah_s *ibc_ah_hdl_t; /* Address Handle */ +typedef struct ibc_qp_s *ibc_qp_hdl_t; /* Queue Pair Handle */ +typedef struct ibc_srq_s *ibc_srq_hdl_t; /* Shared Receive Queue Hdl */ +typedef struct ibc_qpn_s *ibc_qpn_hdl_t; /* Queue Pair Number Handle */ +typedef struct ibc_cq_s *ibc_cq_hdl_t; /* Completion Queue Handle */ +typedef struct ibc_eec_s *ibc_eec_hdl_t; /* End-to-End Context Handle */ +typedef struct ibc_mem_alloc_s *ibc_mem_alloc_hdl_t; /* Memory Handle */ + +#define ibc_sched_hdl_t ibt_sched_hdl_t /* CQ Sched Handle */ +#define ibc_fmr_pool_hdl_t ibt_fmr_pool_hdl_t /* FMR Pool Handle */ +#define ibc_mr_hdl_t ibt_mr_hdl_t /* Memory Region Handle */ +#define ibc_mw_hdl_t ibt_mw_hdl_t /* Memory Window Handle */ +#define ibc_ma_hdl_t ibt_ma_hdl_t /* Memory Area Handle */ +#define ibc_mi_hdl_t ibt_mi_hdl_t /* Memory IOV Handle */ + +/* Handle used by CI for up calls to IBTF */ +typedef struct ibtl_hca_devinfo_s *ibc_clnt_hdl_t; /* ibc_attach() */ + +/* + * Fields opaque to TI, but visible to CI + */ + +/* + * ibt_qp_alloc_attr_t + */ +#define qp_ibc_scq_hdl qp_opaque1 +#define qp_ibc_rcq_hdl qp_opaque2 +#define qp_ibc_srq_hdl qp_opaque3 + + +/* + * ibt_status_t + */ +#define IBT_HCA_RAWD_CHAN_EXCEEDED IBT_ERR_OPAQUE1 /* Requested raw QP */ + /* exceeds HCA max */ + /* limit */ +#define IBT_CHAN_RAWD_NOT_SUPPORTED IBT_ERR_OPAQUE2 /* Raw datagram QPs */ + /* not supported */ +#define IBT_CHAN_RD_NOT_SUPPORTED IBT_ERR_OPAQUE3 /* RD not supported */ +#define IBT_EEC_HDL_INVALID IBT_ERR_OPAQUE4 /* Invalid EEC handle */ +#define IBT_EEC_STATE_INVALID IBT_ERR_OPAQUE5 /* Invalid EEC State */ +#define IBT_EEC_ATTR_RO IBT_ERR_OPAQUE6 /* Can't Change EEC */ + /* Attribute */ +#define IBT_RDD_IN_USE IBT_ERR_OPAQUE7 /* RDD in Use */ +#define IBT_RDD_HDL_INVALID IBT_ERR_OPAQUE8 /* Invalid RDD */ +#define IBT_RNR_NAK_TIMER_INVALID IBT_ERR_OPAQUE9 /* Invalid RNR NAK */ + /* Timer Value */ +#define IBT_RDD_NOT_SUPPORTED IBT_ERR_OPAQUE10 + + +/* + * ibt_wc_status_t + */ +#define IBT_WC_LOCAL_EEC_OP_ERR 12 /* Internal consistency error */ +#define IBT_WC_LOCAL_RDD_VIOLATION_ERR 30 /* The RDD associated with */ + /* the QP does not match */ + /* the RDD associated with */ + /* the EE Context */ +#define IBT_WC_REMOTE_RD_REQ_INVALID 31 /* Detected an invalid */ + /* incoming RD message */ +#define IBT_WC_EEC_REMOTE_ABORTED 32 /* Requester aborted the */ + /* operation */ +#define IBT_WC_EEC_NUM_INVALID 33 /* Invalid EEC Number */ + /* detected */ +#define IBT_WC_EEC_STATE_INVALID 34 /* Invalid EEC state */ + +/* + * ibt_async_code_t + */ +#define IBT_EVENT_PATH_MIGRATED_EEC IBT_ASYNC_OPAQUE1 +#define IBT_ERROR_CATASTROPHIC_EEC IBT_ASYNC_OPAQUE3 +#define IBT_ERROR_PATH_MIGRATE_REQ_EEC IBT_ASYNC_OPAQUE4 + +/* + * ibt_object_type_t + */ +#define IBT_HDL_EEC IBT_HDL_OPAQUE1 +#define IBT_HDL_RDD IBT_HDL_OPAQUE2 + + +/* + * ibt_wc_t + */ +#define wc_eecn wc_detail /* End-to-End Context RD's only */ + + +/* Channel Interface version */ +typedef int ibc_version_t; +#define IBCI_V1 1 +#define IBCI_V2 2 +#define IBCI_V3 3 +#define IBCI_V4 4 + + +typedef enum ibc_free_qp_flags_e { + IBC_FREE_QP_AND_QPN = 0, /* free all qp resources */ + IBC_FREE_QP_ONLY = 1 /* OK to free the QP, but the QPN */ + /* cannot be reused until a future */ + /* call to ibc_release_qpn(qpn_hdl), */ + /* where qpn_hdl is a return value */ + /* of ibc_free_qp() */ +} ibc_free_qp_flags_t; + +/* + * RDD alloc flags + */ +typedef enum ibc_rdd_flags_e { + IBT_RDD_NO_FLAGS = 0, + IBT_RDD_USER_MAP = (1 << 0), + IBT_RDD_DEFER_ALLOC = (1 << 1) +} ibc_rdd_flags_t; + +/* + * EEC alloc flags + */ +typedef enum ibc_eec_flags_e { + IBT_EEC_NO_FLAGS = 0, + IBT_EEC_USER_MAP = (1 << 0), + IBT_EEC_DEFER_ALLOC = (1 << 1) +} ibc_eec_flags_t; + +/* + * Event data for asynchronous events and errors. The QP/EEC/CQ/SRQ handle, + * or port number associated with the Event/Error is passed as an argument + * to the async handler. + */ +typedef struct ibc_async_event_s { + uint64_t ev_fma_ena; /* fault management error data */ + ibtl_qp_hdl_t ev_qp_hdl; /* IBTF QP handle. */ + ibtl_eec_hdl_t ev_eec_hdl; /* IBTF EEC handle. */ + ibt_cq_hdl_t ev_cq_hdl; /* IBT CQ handle. */ + ibt_srq_hdl_t ev_srq_hdl; /* SRQ handle */ + ibt_port_change_t ev_port_flags; /* Port Change flags */ + uint8_t ev_port; /* For PORT UP/DOWN/CHANGE events */ + ibt_fc_syndrome_t ev_fc; /* FEXCH syndrome */ +} ibc_async_event_t; + + +typedef struct ibc_operations_s { + /* HCA */ + ibt_status_t (*ibc_query_hca_ports)(ibc_hca_hdl_t hca, uint8_t port, + ibt_hca_portinfo_t *info_p); + ibt_status_t (*ibc_modify_ports)(ibc_hca_hdl_t hca, uint8_t port, + ibt_port_modify_flags_t flags, uint8_t init_type); + ibt_status_t (*ibc_modify_system_image)(ibc_hca_hdl_t hca, + ib_guid_t sys_guid); + + /* Protection Domain */ + ibt_status_t (*ibc_alloc_pd)(ibc_hca_hdl_t hca, ibt_pd_flags_t flags, + ibc_pd_hdl_t *pd_p); + ibt_status_t (*ibc_free_pd)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd); + + /* Reliable Datagram Domain */ + ibt_status_t (*ibc_alloc_rdd)(ibc_hca_hdl_t hca, ibc_rdd_flags_t flags, + ibc_rdd_hdl_t *rdd_p); + ibt_status_t (*ibc_free_rdd)(ibc_hca_hdl_t hca, ibc_rdd_hdl_t rdd); + + /* Address Handle */ + ibt_status_t (*ibc_alloc_ah)(ibc_hca_hdl_t hca, ibt_ah_flags_t flags, + ibc_pd_hdl_t pd, ibt_adds_vect_t *attr_p, ibc_ah_hdl_t *ah_p); + ibt_status_t (*ibc_free_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah); + ibt_status_t (*ibc_query_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah, + ibc_pd_hdl_t *pd_p, ibt_adds_vect_t *attr_p); + ibt_status_t (*ibc_modify_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah, + ibt_adds_vect_t *attr_p); + + /* Queue Pair */ + ibt_status_t (*ibc_alloc_qp)(ibc_hca_hdl_t hca, ibtl_qp_hdl_t ibtl_qp, + ibt_qp_type_t type, ibt_qp_alloc_attr_t *attr_p, + ibt_chan_sizes_t *queue_sizes_p, ib_qpn_t *qpn, ibc_qp_hdl_t *qp_p); + ibt_status_t (*ibc_alloc_special_qp)(ibc_hca_hdl_t hca, uint8_t port, + ibtl_qp_hdl_t ibt_qp, ibt_sqp_type_t type, + ibt_qp_alloc_attr_t *attr_p, ibt_chan_sizes_t *queue_sizes_p, + ibc_qp_hdl_t *qp_p); + ibt_status_t (*ibc_alloc_qp_range)(ibc_hca_hdl_t hca, uint_t log2, + ibtl_qp_hdl_t *ibtl_qp_p, ibt_qp_type_t type, + ibt_qp_alloc_attr_t *attr_p, ibt_chan_sizes_t *queue_sizes_p, + ibc_cq_hdl_t *send_cq_p, ibc_cq_hdl_t *recv_cq_p, + ib_qpn_t *qpn_p, ibc_qp_hdl_t *qp_p); + ibt_status_t (*ibc_free_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, + ibc_free_qp_flags_t free_qp_flags, ibc_qpn_hdl_t *qpnh_p); + ibt_status_t (*ibc_release_qpn)(ibc_hca_hdl_t hca, ibc_qpn_hdl_t qpnh); + ibt_status_t (*ibc_query_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, + ibt_qp_query_attr_t *attr_p); + ibt_status_t (*ibc_modify_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, + ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p, + ibt_queue_sizes_t *actual_sz); + + /* Completion Queues */ + ibt_status_t (*ibc_alloc_cq)(ibc_hca_hdl_t hca, ibt_cq_hdl_t ibt_cq, + ibt_cq_attr_t *attr_p, ibc_cq_hdl_t *cq_p, uint_t *actual_size); + ibt_status_t (*ibc_free_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq); + ibt_status_t (*ibc_query_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, + uint_t *entries, uint_t *count_p, uint_t *usec_p, + ibt_cq_handler_id_t *hid_p); + ibt_status_t (*ibc_resize_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, + uint_t size, uint_t *actual_size); + ibt_status_t (*ibc_modify_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, + uint_t count, uint_t usec, ibt_cq_handler_id_t hid); + ibt_status_t (*ibc_alloc_cq_sched)(ibc_hca_hdl_t hca, + ibt_cq_sched_attr_t *attr, ibc_sched_hdl_t *sched_hdl_p); + ibt_status_t (*ibc_free_cq_sched)(ibc_hca_hdl_t hca, + ibc_sched_hdl_t sched_hdl); + ibt_status_t (*ibc_query_cq_handler_id)(ibc_hca_hdl_t hca, + ibt_cq_handler_id_t hid, ibt_cq_handler_attr_t *attrs); + + /* EE Context */ + ibt_status_t (*ibc_alloc_eec)(ibc_hca_hdl_t hca, ibc_eec_flags_t flags, + ibtl_eec_hdl_t ibtl_eec, ibc_rdd_hdl_t rdd, ibc_eec_hdl_t *eec_p); + ibt_status_t (*ibc_free_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec); + ibt_status_t (*ibc_query_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec, + ibt_eec_query_attr_t *attr_p); + ibt_status_t (*ibc_modify_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec, + ibt_cep_modify_flags_t flags, ibt_eec_info_t *info_p); + + /* Memory Registration */ + ibt_status_t (*ibc_register_mr)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd, + ibt_mr_attr_t *attr_p, void *ibtl_reserved, ibc_mr_hdl_t *mr_p, + ibt_mr_desc_t *mem_desc); + ibt_status_t (*ibc_register_buf)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd, + ibt_smr_attr_t *attrp, struct buf *buf, void *ibtl_reserved, + ibc_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc); + ibt_status_t (*ibc_register_shared_mr)(ibc_hca_hdl_t hca, + ibc_mr_hdl_t mr, ibc_pd_hdl_t pd, ibt_smr_attr_t *attr_p, + void *ibtl_reserved, ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc); + ibt_status_t (*ibc_deregister_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr); + ibt_status_t (*ibc_query_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr, + ibt_mr_query_attr_t *info_p); + ibt_status_t (*ibc_reregister_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr, + ibc_pd_hdl_t pd, ibt_mr_attr_t *attr_p, void *ibtl_reserved, + ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc); + ibt_status_t (*ibc_reregister_buf)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr, + ibc_pd_hdl_t pd, ibt_smr_attr_t *attrp, struct buf *buf, + void *ibtl_reserved, ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc); + ibt_status_t (*ibc_sync_mr)(ibc_hca_hdl_t hca, + ibt_mr_sync_t *mr_segments, size_t num_segments); + + /* Memory Window */ + ibt_status_t (*ibc_alloc_mw)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd, + ibt_mw_flags_t flags, ibc_mw_hdl_t *mw_p, ibt_rkey_t *rkey_p); + ibt_status_t (*ibc_free_mw)(ibc_hca_hdl_t hca, ibc_mw_hdl_t mw); + ibt_status_t (*ibc_query_mw)(ibc_hca_hdl_t hca, ibc_mw_hdl_t mw, + ibt_mw_query_attr_t *mw_attr_p); + + /* Multicast Group */ + ibt_status_t (*ibc_attach_mcg)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, + ib_gid_t gid, ib_lid_t lid); + ibt_status_t (*ibc_detach_mcg)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, + ib_gid_t gid, ib_lid_t lid); + + /* WR processing */ + ibt_status_t (*ibc_post_send)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, + ibt_send_wr_t *wr_p, uint_t num_wr, uint_t *num_posted); + ibt_status_t (*ibc_post_recv)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp, + ibt_recv_wr_t *wr_p, uint_t num_wr, uint_t *num_posted); + ibt_status_t (*ibc_poll_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, + ibt_wc_t *wc_p, uint_t num_wc, uint_t *num_polled); + ibt_status_t (*ibc_notify_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq, + ibt_cq_notify_flags_t flags); + + /* CI Object Private Data */ + ibt_status_t (*ibc_ci_data_in)(ibc_hca_hdl_t hca, + ibt_ci_data_flags_t flags, ibt_object_type_t object, + void *ibc_object_handle, void *data_p, size_t data_sz); + ibt_status_t (*ibc_ci_data_out)(ibc_hca_hdl_t hca, + ibt_ci_data_flags_t flags, ibt_object_type_t object, + void *ibc_object_handle, void *data_p, size_t data_sz); + + /* Shared Receive Queues */ + ibt_status_t (*ibc_alloc_srq)(ibc_hca_hdl_t hca, ibt_srq_flags_t flags, + ibt_srq_hdl_t ibt_srq, ibc_pd_hdl_t pd, ibt_srq_sizes_t *sizes, + ibc_srq_hdl_t *ibc_srq_p, ibt_srq_sizes_t *real_size_p); + ibt_status_t (*ibc_free_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq); + ibt_status_t (*ibc_query_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq, + ibc_pd_hdl_t *pd_p, ibt_srq_sizes_t *sizes_p, uint_t *limit); + ibt_status_t (*ibc_modify_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq, + ibt_srq_modify_flags_t flags, uint_t size, uint_t limit, + uint_t *real_size_p); + ibt_status_t (*ibc_post_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq, + ibt_recv_wr_t *wr, uint_t num_wr, uint_t *num_posted_p); + + /* Address translation */ + ibt_status_t (*ibc_map_mem_area)(ibc_hca_hdl_t hca_hdl, + ibt_va_attr_t *va_attrs, void *ibtl_reserved, + uint_t paddr_list_len, ibt_reg_req_t *reg_req, + ibc_ma_hdl_t *ma_hdl_p); + ibt_status_t (*ibc_unmap_mem_area)(ibc_hca_hdl_t hca_hdl, + ibc_ma_hdl_t ma_hdl); + ibt_status_t (*ibc_map_mem_iov)(ibc_hca_hdl_t hca_hdl, + ibt_iov_attr_t *iov_attr, ibt_all_wr_t *wr, + ibc_mi_hdl_t *mi_hdl); + ibt_status_t (*ibc_unmap_mem_iov)(ibc_hca_hdl_t hca_hdl, + ibc_mi_hdl_t mi_hdl); + + /* Allocate L_Key */ + ibt_status_t (*ibc_alloc_lkey)(ibc_hca_hdl_t hca_hdl, ibc_pd_hdl_t pd, + ibt_lkey_flags_t flags, uint_t phys_buf_list_sz, + ibc_mr_hdl_t *mr_p, ibt_pmr_desc_t *mem_desc_p); + + /* Physical Register Memory Region */ + ibt_status_t (*ibc_register_physical_mr)(ibc_hca_hdl_t hca, + ibc_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr, void *ibtl_reserved, + ibc_mr_hdl_t *mr_p, ibt_pmr_desc_t *mem_desc_p); + ibt_status_t (*ibc_reregister_physical_mr)(ibc_hca_hdl_t hca, + ibc_mr_hdl_t mr, ibc_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr, + void *ibtl_reserved, ibc_mr_hdl_t *mr_p, + ibt_pmr_desc_t *mem_desc_p); + + /* Fast Memory Registration (FMR) */ + ibt_status_t (*ibc_create_fmr_pool)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd, + ibt_fmr_pool_attr_t *fmr_params, ibc_fmr_pool_hdl_t *fmr_pool_p); + ibt_status_t (*ibc_destroy_fmr_pool)(ibc_hca_hdl_t hca, + ibc_fmr_pool_hdl_t fmr_pool); + ibt_status_t (*ibc_flush_fmr_pool)(ibc_hca_hdl_t hca, + ibc_fmr_pool_hdl_t fmr_pool); + ibt_status_t (*ibc_register_physical_fmr)(ibc_hca_hdl_t hca, + ibc_fmr_pool_hdl_t fmr_pool, ibt_pmr_attr_t *mem_pattr, + void *ibtl_reserved, ibc_mr_hdl_t *mr_hdl_p, + ibt_pmr_desc_t *mem_desc_p); + ibt_status_t (*ibc_deregister_fmr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr); + + /* IO memory management */ + ibt_status_t (*ibc_alloc_io_mem)(ibc_hca_hdl_t hca_hdl, size_t size, + ibt_mr_flags_t mr_flag, caddr_t *kaddrp, + ibc_mem_alloc_hdl_t *mem_alloc_hdl); + ibt_status_t (*ibc_free_io_mem)(ibc_hca_hdl_t hca_hdl, + ibc_mem_alloc_hdl_t mem_alloc_hdl); + + /* Extended RC (XRC) */ + ibt_status_t (*ibc_alloc_xrc_domain)(); + ibt_status_t (*ibc_free_xrc_domain)(); + ibt_status_t (*ibc_alloc_xrc_srq)(); + ibt_status_t (*ibc_free_xrc_srq)(); + ibt_status_t (*ibc_query_xrc_srq)(); + ibt_status_t (*ibc_modify_xrc_srq)(); + ibt_status_t (*ibc_alloc_xrc_tgt_qp)(); + ibt_status_t (*ibc_free_xrc_tgt_qp)(); + ibt_status_t (*ibc_query_xrc_tgt_qp)(); + ibt_status_t (*ibc_modify_xrc_tgt_qp)(); + + /* DMA memory region */ + ibt_status_t (*ibc_register_dma_mr)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd, + ibt_dmr_attr_t *attr_p, void *ibtl_reserved, ibc_mr_hdl_t *mr_p, + ibt_mr_desc_t *mem_desc); + + /* OPS extensions for next round of enhancements */ + ibt_status_t (*ibc_enhancement1)(); + ibt_status_t (*ibc_enhancement2)(); + ibt_status_t (*ibc_enhancement3)(); + ibt_status_t (*ibc_enhancement4)(); +} ibc_operations_t; + + +/* + * The ibc_hca_info_s structure is used for HCA drivers to communicate its + * HCA specific information to IBTF when it attaches a device via ibc_attach(). + * + * IBTF assumes that the structures pointed to by the hca_ops and hca_attr + * structure members are persistent. + */ +typedef struct ibc_hca_info_s { + ibc_version_t hca_ci_vers; /* CI Version */ + ibc_hca_hdl_t hca_handle; /* used for call through */ + /* "hca_ops" */ + ibc_operations_t *hca_ops; + ibt_hca_attr_t *hca_attr; +} ibc_hca_info_t; + + +/* Channel Interface return status */ +typedef enum ibc_status_e { + IBC_SUCCESS = 0, + IBC_FAILURE = 1 +} ibc_status_t; + +/* + * CI up-calls to IBTF. + */ + +/* + * ibc_init + * Registers CI clients with the Solaris I/O framework + * + * ibc_fini + * Un-Registers CI clients with the Solaris I/O framework + */ +int ibc_init(struct modlinkage *modlp); +void ibc_fini(struct modlinkage *modlp); + +/* + * ibc_attach + * Register HCA device with IBTF. During this call HCA driver provides + * driver's information neededby IBTF. + * + * ibc_post_attach + * After a successful ibc_attach, this must be called. + * + * ibc_pre_detach + * Attempt to De-Register HCA Device from IBTF. + * This requires the cooperation of IBTF clients to + * stop using this HCA. Upon success, the HCA driver + * is committed to calling ibc_detach. + * + * ibc_detach + * De-Register HCA Device from IBTF. + * This function will succeed if ibc_pre_detach has previously + * succeeded for this device. + */ +ibc_status_t ibc_attach(ibc_clnt_hdl_t *ibc_hdl_p, ibc_hca_info_t *info_p); +void ibc_post_attach(ibc_clnt_hdl_t ibc_hdl); +ibc_status_t ibc_pre_detach(ibc_clnt_hdl_t ibc_hdl, ddi_detach_cmd_t cmd); +void ibc_detach(ibc_clnt_hdl_t ibc_hdl); + +/* + * ibc_cq_handler + * IBTF Completion Queue Notification Handler. + */ +void ibc_cq_handler(ibc_clnt_hdl_t ibc_hdl, ibt_cq_hdl_t ibt_cq); + +/* + * ibc_async_handler + * IBTF Asynchronous event/error handler. + */ +void ibc_async_handler(ibc_clnt_hdl_t ibc_hdl, ibt_async_code_t code, + ibc_async_event_t *event_p); + +/* + * ibc_memory_handler + * IBTF memory event/error handler. + */ +void ibc_memory_handler(ibc_clnt_hdl_t ibc_hdl, ibt_mem_code_t code, + ibt_mem_data_t *data_p, void *ibtl_reserved); + +/* + * ibc_get_ci_failure() + * + * Used to obtain a special IBTF failure code for CI specific failures, + * failures other than those defined in ibt_status_t. + */ +ibt_status_t ibc_get_ci_failure(uint64_t ena); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IBCI_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/ibti.h b/illumos-x86_64/usr/include/sys/ib/ibtl/ibti.h new file mode 100644 index 00000000..9d8407d3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/ibti.h @@ -0,0 +1,414 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_IBTL_IBTI_H +#define _SYS_IB_IBTL_IBTI_H + +/* + * ibti.h + * + * This file contains the IBTI prototypes and associated data structures. + * It is the only header file that should be included by IBTI clients. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Allocate channel flags. + */ +typedef enum ibt_chan_alloc_flags_e { + IBT_ACHAN_NO_FLAGS = 0, + IBT_ACHAN_CLONE = (1 << 0), + IBT_ACHAN_USER_MAP = (1 << 1), + IBT_ACHAN_DEFER_ALLOC = (1 << 2), + IBT_ACHAN_USES_SRQ = (1 << 3), + IBT_ACHAN_USES_RSS = (1 << 4), + + /* UD variants for FC support */ + IBT_ACHAN_USES_RFCI = (1 << 5), /* from RFCI pool */ + IBT_ACHAN_USES_FCMD = (1 << 6), + IBT_ACHAN_USES_FEXCH = (1 << 7) /* from FEXCH pool */ +} ibt_chan_alloc_flags_t; + + +/* + * Allocate RC channel ibt_alloc_rc_channel() argument. + */ +typedef struct ibt_rc_chan_alloc_args_s { + ibt_attr_flags_t rc_flags; /* Signal type etc */ + ibt_cep_flags_t rc_control; + uint8_t rc_hca_port_num; + ibt_chan_sizes_t rc_sizes; + ibt_cq_hdl_t rc_scq; /* Send CQ */ + ibt_cq_hdl_t rc_rcq; /* Recv CQ */ + ibt_pd_hdl_t rc_pd; /* PD */ + ibt_channel_hdl_t rc_clone_chan; /* Optional Clone handle */ + ibt_srq_hdl_t rc_srq; /* Optional Shared Rcv Queue */ +} ibt_rc_chan_alloc_args_t; + +/* + * RC channel query attributes structure. + */ +typedef struct ibt_rc_chan_query_attr_s { + ib_guid_t rc_hca_guid; /* Local HCA GUID */ + ibt_cq_hdl_t rc_scq; /* SendCQ handle */ + ibt_cq_hdl_t rc_rcq; /* RecvCQ handle */ + ibt_pd_hdl_t rc_pd; /* PD Handle. */ + ibt_cep_state_t rc_state; /* Channel state */ + ib_mtu_t rc_path_mtu; + uint8_t rc_path_retry_cnt:3; + ibt_rnr_retry_cnt_t rc_path_rnr_retry_cnt; + ibt_rnr_nak_time_t rc_min_rnr_nak; /* min RNR-NAK timer */ + ibt_cep_path_t rc_prim_path; + ibt_cep_path_t rc_alt_path; + ibt_chan_sizes_t rc_chan_sizes; /* Queue/SGL sizes */ + uint8_t rc_rdma_ra_out; /* max RDMA-Reads/Atomics out */ + uint8_t rc_rdma_ra_in; /* max RDMA-Reads/Atomics in */ + ibt_attr_flags_t rc_flags; /* SQ Signaling Type etc */ + ibt_cep_flags_t rc_control; /* Control Flags */ + ibt_cep_cmstate_t rc_mig_state; + ib_qpn_t rc_qpn; /* Local QPN */ + ib_qpn_t rc_dst_qpn; /* Destination QPN */ + ibt_srq_hdl_t rc_srq; /* Optional Shared Rcv Queue */ +} ibt_rc_chan_query_attr_t; + +/* + * RC Channel Modify Attributes definition. + * + * It is only possible to modify a channel that has previously been + * opened. The channel must either be in operational state (IBT_STATE_RTS) + * or paused (IBT_STATE_SQD). If channel is in paused state, then a modify + * operation will unpause the channel. + * + * See the ibt_modify_rc_channel() for details of the required corresponding + * modify flags. + * Not specified attributes should be set to "NULL" or "0". + */ +typedef struct ibt_rc_chan_modify_attr_s { + ibt_cep_flags_t rc_control; /* Channel Control Flags */ + uint_t rc_sq_sz; /* Set SQ Max outstanding WRs */ + uint_t rc_rq_sz; /* Set RQ Max outstanding WRs */ + + ibt_adds_vect_t rc_prim_adds_vect; /* Primary Path Address */ + ibt_adds_vect_t rc_alt_adds_vect; /* Alternate Path Address */ + uint8_t rc_path_retry_cnt:3; + ibt_rnr_retry_cnt_t rc_path_rnr_retry_cnt; + ibt_rnr_nak_time_t rc_min_rnr_nak; /* min RNR-NAK timer */ + uint8_t rc_prim_port_num; /* Port of Primary Path */ + uint8_t rc_alt_port_num; /* Port of Alternate Path */ + uint8_t rc_rdma_ra_out; /* Initiator Depth, Number of */ + /* RDMA RD's & Atomics */ + /* outstanding. */ + uint8_t rc_rdma_ra_in; /* Responder resources for */ + /* handling incoming RDMA rds */ + /* and Atomics. */ +} ibt_rc_chan_modify_attr_t; + +/* + * UD remote destination query attributes + */ +typedef struct ibt_ud_dest_query_attr_s { + ibt_hca_hdl_t ud_hca_hdl; /* Local HCA Handle */ + ib_qpn_t ud_dst_qpn; /* Destination QPN */ + ib_qkey_t ud_qkey; /* Q_Key */ + ibt_adds_vect_t ud_addr_vect; /* Address Information */ + ibt_pd_hdl_t ud_pd; +} ibt_ud_dest_query_attr_t; + +/* + * Allocate UD channel ibt_alloc_ud_channel() arguments; see below at + * ibt_alloc_ud_channel() for a description of what's required and optional. + */ +typedef struct ibt_ud_chan_alloc_args_s { + ibt_attr_flags_t ud_flags; /* Sig type etc */ + uint8_t ud_hca_port_num; + uint16_t ud_pkey_ix; /* P_Key Index */ + ibt_chan_sizes_t ud_sizes; + ib_qkey_t ud_qkey; /* Q_Key */ + ibt_cq_hdl_t ud_scq; /* Send CQ */ + ibt_cq_hdl_t ud_rcq; /* Recv CQ */ + ibt_pd_hdl_t ud_pd; /* PD */ + ibt_channel_hdl_t ud_clone_chan; /* Optional clone handle */ + ibt_srq_hdl_t ud_srq; /* Optional Shared Rcv Queue */ + ibt_rss_attr_t ud_rss; + ibt_fc_attr_t ud_fc; +} ibt_ud_chan_alloc_args_t; + +/* + * UD channel query attributes. + */ +typedef struct ibt_ud_chan_query_attr_s { + ib_qpn_t ud_qpn; /* QPN */ + ib_guid_t ud_hca_guid; /* Local HCA GUID */ + ibt_cq_hdl_t ud_scq; /* SendCQ handle. */ + ibt_cq_hdl_t ud_rcq; /* RecvCQ handle. */ + ibt_pd_hdl_t ud_pd; /* PD Handle. */ + uint8_t ud_hca_port_num; /* Local HCA port */ + ibt_cep_state_t ud_state; /* Channel state */ + uint16_t ud_pkey_ix; /* P_Key Index */ + ib_qkey_t ud_qkey; /* Q_Key */ + ibt_chan_sizes_t ud_chan_sizes; /* Queue/SGL sizes */ + ibt_attr_flags_t ud_flags; /* Signaling Type etc */ + ibt_srq_hdl_t ud_srq; /* Optional Shared Rcv Queue */ + ibt_rss_attr_t ud_rss; + ibt_fc_attr_t ud_fc; + ibt_fexch_query_attr_t ud_query_fc; /* query only set */ +} ibt_ud_chan_query_attr_t; + +/* + * UD Channel Modify Attributes definition. + * + * It is only possible to modify a channel that is either in the operational + * state (IBT_STATE_RTS) or paused (IBT_STATE_SQD). If channel is in paused + * state, then a modify operation will unpause the channel. + * + * See the ibt_modify_ud_channel() for details of the required corresponding + * modify flags. + */ +typedef struct ibt_ud_chan_modify_attr_s { + uint_t ud_sq_sz; /* Set SQ Max outstanding WRs */ + uint_t ud_rq_sz; /* Set RQ Max outstanding WRs */ + ib_qkey_t ud_qkey; /* Set Q_Key */ + ibt_rss_attr_t ud_rss; /* Set RSS stuff */ + ibt_fc_attr_t ud_fc; +} ibt_ud_chan_modify_attr_t; + + +/* + * FUNCTION PROTOTYPES + */ + +/* + * CONNECTION ESTABLISHMENT/TEAR DOWN FUNCTIONS. + */ + +/* + * ibt_alloc_rc_channel + * Allocates a RC communication channels that satisfy the specified + * channel attributes. + */ +ibt_status_t ibt_alloc_rc_channel(ibt_hca_hdl_t hca_hdl, + ibt_chan_alloc_flags_t flags, ibt_rc_chan_alloc_args_t *args, + ibt_channel_hdl_t *rc_chan_p, ibt_chan_sizes_t *sizes); + +/* + * ibt_flush_channel + * Flush the specified channel. Outstanding work requests are flushed + * so that the client can do the associated clean up. After that, the + * client will usually deregister the previously registered memory, + * then free the channel by calling ibt_free_channel(). RC channels + * that have been successfully opened will fail this call, as they + * need to instead be handled by ibt_close_rc_channel(). + */ +ibt_status_t ibt_flush_channel(ibt_channel_hdl_t chan); + +/* + * ibt_free_channel + * Releases the resources associated with the specified channel + */ +ibt_status_t ibt_free_channel(ibt_channel_hdl_t chan); + +/* + * ibt_query_rc_channel + * Query an RC channel's attributes. Should only be called on an + * opened RC channel. If called on a channel before it is opened, + * some channel attributes may change when the channel is opened. + */ +ibt_status_t ibt_query_rc_channel(ibt_channel_hdl_t rc_chan, + ibt_rc_chan_query_attr_t *chan_attrs); + +/* + * ibt_modify_rc_channel() + * Modifies a previous opened operational or paused RC channel's + * attributes. + * + * NOTE: + * It is only possible to modify a channel that has previously been opened. + * The channel must either be in operational state (IBT_STATE_RTS) or + * paused (IBT_STATE_SQD). If channel is in paused state, then a modify + * operation will will unpause the channel. + */ +ibt_status_t ibt_modify_rc_channel(ibt_channel_hdl_t rc_chan, + ibt_cep_modify_flags_t flags, ibt_rc_chan_modify_attr_t *attrs, + ibt_queue_sizes_t *actual_sz); + +/* + * ibt_alloc_ud_channel + * Allocate UD channels that satisfy the specified channel attributes. + */ +ibt_status_t ibt_alloc_ud_channel(ibt_hca_hdl_t hca_hdl, + ibt_chan_alloc_flags_t flags, ibt_ud_chan_alloc_args_t *args, + ibt_channel_hdl_t *ud_chan_p, ibt_chan_sizes_t *sizes); + +/* + * ibt_alloc_ud_channel_range + * Allocate a range of UD channels that have consecutive QPNs for RSS. + */ +ibt_status_t ibt_alloc_ud_channel_range(ibt_hca_hdl_t hca_hdl, + uint_t log2, ibt_chan_alloc_flags_t flags, + ibt_ud_chan_alloc_args_t *args, ibt_cq_hdl_t *send_cq_p, + ibt_cq_hdl_t *recv_cq_p, ib_qpn_t *base_qpn_p, + ibt_channel_hdl_t *ud_chan_p, ibt_chan_sizes_t *sizes); + +/* + * ibt_query_ud_channel + * Query a UD channel's attributes. + */ +ibt_status_t ibt_query_ud_channel(ibt_channel_hdl_t ud_chan, + ibt_ud_chan_query_attr_t *ud_chan_attrs); + +/* + * ibt_modify_ud_channel() + * Modifies an UD channel's attributes, as specified by a + * ibt_cep_modify_flags_t parameter to those specified in the + * ibt_ud_chan_modify_attr_t structure. + * + * NOTE: + * It is only possible to modify a channel that is either in the + * operational state (IBT_STATE_RTS) or paused (IBT_STATE_SQD). If + * channel is in paused state, then a modify operation will unpause the + * channel. + */ +ibt_status_t ibt_modify_ud_channel(ibt_channel_hdl_t ud_chan, + ibt_cep_modify_flags_t flags, ibt_ud_chan_modify_attr_t *attrs, + ibt_queue_sizes_t *actual_sz); + +/* + * ibt_recover_ud_channel() + * Recover an UD Channel which has transitioned to SQ Error state. The + * ibt_recover_ud_channel() transitions the channel from SQ Error state + * to Ready-To-Send channel state. + * + * If a work request posted to a UD channel's send queue completes with + * an error (see ibt_wc_status_t), the channel gets transitioned to SQ + * Error state. In order to reuse this channel, ibt_recover_ud_channel() + * can be used to recover the channel to a usable (Ready-to-Send) state. + */ +ibt_status_t ibt_recover_ud_channel(ibt_channel_hdl_t ud_chan); + + +/* + * ibt_alloc_ud_dest + * Allocate a UD destination handle. This allocates local resources + * that will need subsequent modification/initialization before use + * (in send work requests). Functions that can be used to do this are + * ibt_modify_ud_dest (data supplied by caller), ibt_modify_reply_ud_dest + * (data supplied from a successfully completed receive work request), + * and ibt_request_ud_dest (data retrieved using SIDR protocol). + */ +ibt_status_t ibt_alloc_ud_dest(ibt_hca_hdl_t hca_hdl, + ibt_ud_dest_flags_t flags, ibt_pd_hdl_t pd, ibt_ud_dest_hdl_t *ud_dest_p); + +/* + * ibt_modify_ud_dest + * Modify a previously allocated UD destination handle from the + * argument data. After the ud_dest has already been made usable, + * the adds_vect argument to this function is optional (NULL). + */ +ibt_status_t ibt_modify_ud_dest(ibt_ud_dest_hdl_t ud_dest, ib_qkey_t qkey, + ib_qpn_t dest_qpn, ibt_adds_vect_t *adds_vect); + +/* + * ibt_modify_reply_ud_dest + * Modify a previously allocated UD destination handle, so that it + * can be used to reply to the sender of the datagram contained in the + * specified work request completion. + */ +ibt_status_t ibt_modify_reply_ud_dest(ibt_channel_hdl_t ud_chan, + ibt_ud_dest_hdl_t ud_dest, ib_qkey_t qkey, ibt_wc_t *wc, + ib_vaddr_t recv_buf); + +/* + * ibt_request_ud_dest + * Modify a previously allocated UD destination handle based on the + * data retrieved by making an SIDR request. + */ +ibt_status_t ibt_request_ud_dest(ibt_ud_dest_hdl_t ud_dest, + ibt_execution_mode_t mode, ibt_ud_dest_attr_t *dest_attrs, + ibt_ud_returns_t *ud_ret_args); + +/* + * ibt_free_ud_dest + * Releases the resources associated with the specified UD destination + * handle. + */ +ibt_status_t ibt_free_ud_dest(ibt_ud_dest_hdl_t ud_dest); + +/* + * ibt_query_ud_dest + * Query a UD destination's attributes. + */ +ibt_status_t ibt_query_ud_dest(ibt_ud_dest_hdl_t ud_dest, + ibt_ud_dest_query_attr_t *dest_attrs); + + +/* + * ibt_is_privileged_ud_dest + * Determine if a UD destination Handle is a privileged handle. + */ +boolean_t ibt_is_privileged_ud_dest(ibt_ud_dest_hdl_t ud_dest); + + +/* + * ibt_update_channel_qkey + * + * ibt_update_channel_qkey() set's the Qkey in the specified channel context + * to the Qkey in the specified destination handle. This function can be used + * to enable sends to a privileged destination. All posted Send Work Requests + * that contain a privileged destination handle now use the Qkey in the + * channel context. + * + * ibt_update_channel_qkey() can also be used to enable the caller to receive + * from the specified remote destination on the specified channel. + * + */ +ibt_status_t ibt_update_channel_qkey(ibt_channel_hdl_t ud_chan, + ibt_ud_dest_hdl_t ud_dest); + + +/* + * ibt_set_chan_private() + * ibt_get_chan_private() + * Set/get a pointer to client private data. + * Applicable for both RC and UD channels. + */ +void ibt_set_chan_private(ibt_channel_hdl_t chan, void *clnt_private); + +void *ibt_get_chan_private(ibt_channel_hdl_t chan); + +/* + * ibt_channel_to_hca_guid() + * + * A helper function to retrieve HCA GUID for the specified Channel. + */ +ib_guid_t ibt_channel_to_hca_guid(ibt_channel_hdl_t chan); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IBTI_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/ibti_cm.h b/illumos-x86_64/usr/include/sys/ib/ibtl/ibti_cm.h new file mode 100644 index 00000000..c5eb7d2d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/ibti_cm.h @@ -0,0 +1,674 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_IBTL_IBTI_CM_H +#define _SYS_IB_IBTL_IBTI_CM_H + +/* + * ibti_cm.h + * + * This file contains the data structure definitions for the IBTI + * communication manager (CM). It is only included in ibti.h + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Defines. + */ +#define IBT_MAX_PRIV_DATA_SZ 224 +#define IBT_DREP_PRIV_DATA_SZ 224 +#define IBT_RTU_PRIV_DATA_SZ 224 +#define IBT_MRA_PRIV_DATA_SZ 222 +#define IBT_DREQ_PRIV_DATA_SZ 220 +#define IBT_REP_PRIV_DATA_SZ 196 +#define IBT_LAP_PRIV_DATA_SZ 168 +#define IBT_APR_PRIV_DATA_SZ 148 +#define IBT_REJ_PRIV_DATA_SZ 148 +#define IBT_REQ_PRIV_DATA_SZ 92 +#define IBT_SIDR_REQ_PRIV_DATA_SZ 216 +#define IBT_SIDR_REP_PRIV_DATA_SZ 136 +#define IBT_IP_HDR_PRIV_DATA_SZ 36 + +#define IBT_CM_ADDL_REJ_LEN 72 /* Additional Rej Info len */ + /* This is the max consumer addl */ + /* reject info len */ +#define IBT_CM_SIDR_CP_LEN 72 /* SIDR REP Class Port Info len */ +#define IBT_CM_APR_ADDL_LEN 72 /* Additional Info len in APR message */ + +typedef uint8_t ibt_priv_data_len_t; + +/* + * CM channel handler reject reasons. + * + * Refer to InfiniBand Architecture Release Volume 1 Rev 1.0a: + * Section 12.6.7.2 Rejection Reason, and RDMA IP CM Service Annex + * + * Note: + * When a REJ happens for an RDMA-aware ULP, a consumer reject code + * indicating an IP CM Service reject or a RDMA-Aware ULP reject can + * be returned. In the IBTA spec both use the consumer reject code, but + * are distinguished by the REJ layer byte (table 3 of the annex 11). + * The IBTF CM can thus tell what type of reject has been returned. When + * a RDMA ULP issues a consumer REJ to an RDMA REQ then the CM will + * return an IBT_CM_CONSUMER ibt_cm_reason_t. The ARI data is returned + * in an ibt_ari_con_t struct accessed by the 'ari_consumer' member of + * the ibt_arej_info_t. However the consumer reject data begins at + * 'ari_consumer.rej_ari[1]', and is of length + * 'ari_consumer.rej_ari_len - 1' (the first byte is the REJ layer byte), + * where as for a non RDMA-aware ULP consumer REJ, the ARI data begins + * at 'ari_consumer.rej_ari[0]' and is of length 'ari_consumer.rej_ari_len' + * + * If an RDMA-aware ULP REQ is rejected by the IP CM Service layer, the + * CM will return the new IBT_CM_RDMA_IP ibt_cm_reason_t, and the + * private data is returned in an ibt_ari_ip_t struct accessed via the + * 'ari_ip' member of the ibt_arej_info_t struct. + * + * If an RDMA IP CM REQ is sent to a non RDMA-aware ULP consumer, then + * the REQ is Rejected with an IBT_CM_INVALID_SID ibt_cm_reason_t. + */ +typedef enum ibt_cm_reason_e { + IBT_CM_SUCCESS = 0, /* Success */ + IBT_CM_NO_CHAN = 1, /* Remote unable to allocate a CHAN */ + IBT_CM_NO_EEC = 2, /* Remote unable to allocate an EEC */ + IBT_CM_NO_RESC = 3, /* Remote unable to allocate resource */ + IBT_CM_TIMEOUT = 4, /* CM protocol timed out waiting for */ + /* a msg */ + IBT_CM_NOT_SUPPORTED = 5, /* Request not supported */ + IBT_CM_INVALID_CID = 6, /* Local CID or Remote CID invalid */ + IBT_CM_INVALID_COMM_INS = 7, /* Local CID, Remote CID, Channel */ + /* does not refer to a valid */ + /* communication Instance. */ + IBT_CM_INVALID_SID = 8, /* Service not supported or not */ + /* recognized */ + IBT_CM_INVALID_SRV_TYPE = 9, /* Invalid transport service type */ + IBT_CM_CONN_STALE = 10, /* Stale connection */ + IBT_CM_INVALID_RDC = 11, /* RDC does not exist */ + IBT_CM_PRIM_GID = 12, /* Primary remote port gid rejected. */ + IBT_CM_PRIM_LID = 13, /* Primary remote port lid rejected. */ + IBT_CM_INVALID_PRIM_SL = 14, /* Primary Requested SL not supported */ + IBT_CM_INVALID_PRIM_TC = 15, /* Primary Requested traffic class */ + /* not supported */ + IBT_CM_INVALID_PRIM_HOP = 16, /* Primary Requested hop limit not */ + /* accepted */ + IBT_CM_INVALID_PRIM_RATE = 17, /* Primary Packet rate not accepted */ + IBT_CM_ALT_GID = 18, /* Alternate remote port gid rejected */ + IBT_CM_ALT_LID = 19, /* Alternate remote port lid rejected */ + IBT_CM_INVALID_ALT_SL = 20, /* Alternate Requested SL not */ + /* supported */ + IBT_CM_INVALID_ALT_TC = 21, /* Alternate Requested traffic class */ + /* not supported */ + IBT_CM_INVALID_ALT_HOP = 22, /* Alternate Requested hop limit */ + /* accepted */ + IBT_CM_INVALID_ALT_RATE = 23, /* Alternate Packet rate not accepted */ + IBT_CM_REDIRECT_CM = 24, /* Port & CM redirected */ + IBT_CM_PORT_REDIRECT = 25, /* Port redirected */ + IBT_CM_INVALID_MTU = 26, /* Path MTU not supported */ + IBT_CM_INSUFF_RESOURCE = 27, /* Insufficient responder resources */ + IBT_CM_CONSUMER = 28, /* Consumer rejected connection */ + IBT_CM_RNR_RETRY_CNT_REJ = 29, /* RNR NAK retry count rejected */ + IBT_CM_DUP_COM_ID = 30, /* Local CID in REQ is duplicated */ + IBT_CM_CLASS_NO_SUPPORT = 31, /* Class version not supported */ + IBT_CM_INVALID_PRIM_FLOW = 32, /* Invalid primary flow label */ + IBT_CM_INVALID_ALT_FLOW = 33, /* Invalid alternate flow label */ + IBT_CM_DUP_CONN_REQ = 1000, /* Duplicate connection request */ + IBT_CM_ABORT = 1001, /* Connection aborted */ + IBT_CM_CI_FAILURE = 1002, /* A call to CI failed, could be */ + /* query/modify channel */ + IBT_CM_CHAN_INVALID_STATE = 1003, /* Passive's QP is not in Init */ + /* state */ + IBT_CM_RDMA_IP = 1004 /* RDMA IP CM reject */ +} ibt_cm_reason_t; + +/* + * CM flags. + */ +typedef uint8_t ibt_cm_flags_t; + +#define IBT_CM_NO_FLAGS 0x0 +#define IBT_CM_FLOW_CONTROL 0x1 +#define IBT_CM_SRQ_EXISTS 0x2 + + +/* + * The CM Handler function return values. + */ +typedef enum ibt_cm_status_e { + IBT_CM_ACCEPT = 0, + IBT_CM_REJECT = 1, + IBT_CM_REDIRECT_PORT = 2, /* Redirect port */ + IBT_CM_REDIRECT = 3, /* Redirect port and CM */ + IBT_CM_NO_CHANNEL = 4, /* Unable to allocate a channel */ + IBT_CM_NO_RESOURCE = 5, /* Unable to allocate a resource */ + IBT_CM_DEFAULT = 6, /* Do the default action */ + IBT_CM_DEFER = 7 /* Can't complete processing now */ +} ibt_cm_status_t; /* will call ibt_cm_proceed() */ + /* later */ + +/* + * SIDR_REP status type + */ +typedef enum ibt_sidr_status_e { + IBT_CM_SREP_CHAN_VALID = 0, + IBT_CM_SREP_SID_INVALID = 1, /* Service ID not supported */ + IBT_CM_SREP_REJ = 2, /* Service provider reject */ + IBT_CM_SREP_NO_CHAN = 3, /* No channel available */ + IBT_CM_SREP_REDIRECT = 4, /* Redirect request */ + IBT_CM_SREP_CL_INVALID = 5, /* Class Version is invalid */ + IBT_CM_SREP_TIMEOUT = 1000 /* No SIDR_REP received */ +} ibt_sidr_status_t; + +/* + * Alternate path status type + * The implementation defined status codes begin from 20. The status codes + * below 20 are based on apr_status in the APR mad. + */ +typedef enum ibt_ap_status_e { + IBT_CM_AP_LOADED = 0, /* AP loaded successfully */ + IBT_CM_AP_INVALID_COMMID = 1, /* Invalid communication instance */ + IBT_CM_AP_NOT_SUPPORTED = 2, /* Alternate paths not supported */ + IBT_CM_AP_REJECT = 3, /* Failover port rejected */ + IBT_CM_AP_REDIRECT = 4, /* Reject - redirect */ + IBT_CM_AP_MATCH_PRIM = 5, /* AP matches primary path */ + IBT_CM_AP_QPNEECN_INVALID = 6, /* AP QPN/EECN does not match */ + IBT_CM_AP_RLID_REJECTED = 7, /* AP remote port lid rejected */ + IBT_CM_AP_RGID_REJECTED = 8, /* AP remote port gid rejected */ + IBT_CM_AP_FLOW_REJECTED = 9, /* AP flow label rejected */ + IBT_CM_AP_TCLASS_REJECTED = 10, /* AP traffic class rejected */ + IBT_CM_AP_HOP_REJECTED = 11, /* AP hop limit rejected */ + IBT_CM_AP_RATE_REJECTED = 12, /* AP static packet rate rejected */ + IBT_CM_AP_SL_REJECTED = 13, /* AP service level rejected */ + IBT_CM_AP_TIMEOUT = 1000, /* LAP timed out */ + IBT_CM_AP_ABORT = 1001 /* ibt_set_alternate_path returned */ + /* earlier because of connection */ + /* getting closed */ +} ibt_ap_status_t; + +/* + * Communication event types. + */ +typedef enum ibt_cm_event_type_e { + IBT_CM_EVENT_REQ_RCV = 0x1, + IBT_CM_EVENT_REP_RCV, + IBT_CM_EVENT_MRA_RCV, + IBT_CM_EVENT_LAP_RCV, + IBT_CM_EVENT_APR_RCV, + IBT_CM_EVENT_CONN_EST, /* RTU has been sent/recvd and it is */ + /* OK to use the connection */ + IBT_CM_EVENT_CONN_CLOSED, /* Connection has been closed and it */ + /* is OK to free resources associated */ + /* with the connection. */ + IBT_CM_EVENT_FAILURE /* The CM Failure see cf_code in the */ + /* ibt_cm_conn_failed_t struct for */ + /* details of the failure */ +} ibt_cm_event_type_t; + +/* + * CM and Port redirect information. + */ +typedef struct ibt_redirect_info_s { + ib_gid_t rdi_gid; + uint8_t rdi_tclass; + uint8_t rdi_sl:4; + uint_t rdi_flow:20; + ib_lid_t rdi_dlid; + ib_qpn_t rdi_qpn; + ib_qkey_t rdi_qkey; + ib_pkey_t rdi_pkey; +} ibt_redirect_info_t; + +/* + * Values for rep_failover_status. + */ +#define IBT_CM_FAILOVER_ACCEPT 0x00 /* Failover port accepted */ +#define IBT_CM_FAILOVER_REJ_NOTSUPP 0x01 /* Failover not supported */ +#define IBT_CM_FAILOVER_REJ 0x02 /* Failover port rejected */ + +/* + * CM REP_RCV event structure. + */ +typedef struct ibt_cm_rep_rcv_s { + uint8_t rep_rdma_ra_in; /* Arbitrated responder */ + /* resources (rdma_ra_in) */ + uint8_t rep_rdma_ra_out; /* Arbitrated initiator */ + /* depth (rdma_ra_out) */ + clock_t rep_service_time; /* time in clock ticks */ + /* Time to complete */ + /* processing of REP event */ + uint8_t rep_failover_status; /* Failover Port status */ + ibt_cm_flags_t rep_flags; /* EE flow control, SRQ etc */ +} ibt_cm_rep_rcv_t; + + +/* + * Values for mra_msg_type. + */ +#define IBT_CM_MRA_TYPE_REQ 0x00 /* mra_msg values */ +#define IBT_CM_MRA_TYPE_REP 0x01 +#define IBT_CM_MRA_TYPE_LAP 0x02 + +/* + * CM MRA_RCV event structure. + */ +typedef struct ibt_cm_mra_rcv_s { + uint8_t mra_msg_type; /* The message being MRA'd */ + clock_t mra_service_time; /* timeout in microseconds */ +} ibt_cm_mra_rcv_t; + +/* + * CM LAP_RCV event structure. + */ +typedef struct ibt_cm_lap_rcv_s { + ibt_adds_vect_t lap_alternate_path; + clock_t lap_timeout; /* timeout in microseconds */ + /* This is the time that the */ + /* Service handler has to */ + /* return to the CM */ +} ibt_cm_lap_rcv_t; + +#define IBT_CM_IP_MAJ_VER 0 +#define IBT_CM_IP_MIN_VER 0 +#define IBT_CM_IP_IPV_V4 0x4 +#define IBT_CM_IP_IPV_V6 0x6 + +/* + * Consumer defined Additional reject information. + */ +typedef struct ibt_ari_con_s { + uint8_t rej_ari_len; /* Length */ + uint8_t rej_ari[IBT_CM_ADDL_REJ_LEN]; /* Buffer */ +} ibt_ari_con_t; + +/* + * Consumer defined Additional reject information. + * For RDMA IP CM Service. + */ +typedef uint8_t ibt_ari_ip_reason_t; +#define IBT_ARI_IP_UNSPECIFIED 0x0 +#define IBT_ARI_IP_MAJOR_VERSION 0x1 +#define IBT_ARI_IP_MINOR_VERSION 0x2 +#define IBT_ARI_IP_IPV 0x3 +#define IBT_ARI_IP_SRC_ADDR 0x4 +#define IBT_ARI_IP_DST_ADDR 0x5 +#define IBT_ARI_IP_UNKNOWN_ADDR 0x6 + +typedef struct ibt_ari_ip_s { + ibt_ip_addr_t ip_suggested_addr; /* IP_UNKNOWN_ADDR */ + boolean_t ip_suggested; /* suggested valid */ + ibt_ari_ip_reason_t ip_reason; + uint8_t ip_suggested_version:4; /* IP_MAJOR_VERSION */ + /* IP_MINOR_VERSION */ + /* IP_IPV, */ + /* IP_SRC_ADDR, */ + /* IP_DST_ADDR */ +} ibt_ari_ip_t; + +/* + * Additional reject information. + */ +typedef union ibt_arej_info_u { + ibt_ari_con_t ari_consumer; /* IBT_CM_CONSUMER */ + ib_gid_t ari_gid; /* IBT_CM_PRIM_GID, */ + /* IBT_CM_ALT_GID, */ + /* IBT_CM_PORT_REDIRECT */ + ib_lid_t ari_lid; /* IBT_CM_PRIM_LID, */ + /* IBT_CM_ALT_LID */ + uint8_t ari_sl:4; /* IBT_CM_INVALID_PRIM_SL, */ + /* IBT_CM_INVALID_ALT_SL */ + uint8_t ari_tclass; /* IBT_CM_INVALID_PRIM_TC, */ + /* IBT_CM_INVALID_ALT_TC */ + uint8_t ari_hop; /* IBT_CM_INVALID_PRIM_HOP, */ + /* IBT_CM_INVALID_ALT_HOP */ + uint_t ari_flow:20; /* IBT_CM_INVALID_PRIM_FLOW, */ + /* IBT_CM_INVALID_ALT_FLOW */ + ibt_srate_t ari_rate; /* IBT_CM_INVALID_PRIM_RATE, */ + /* IBT_CM_INVALID_ALT_RATE */ + ib_mtu_t ari_mtu; /* IBT_CM_INVALID_MTU */ + ibt_redirect_info_t ari_redirect; /* IBT_CM_REDIRECT_CM */ + ibt_ari_ip_t ari_ip; /* IBT_CM_RDMA_IP */ +} ibt_arej_info_t; + +/* + * CM APR_RCV event structure. + */ +typedef struct ibt_cm_apr_rcv_s { + ibt_ap_status_t apr_status; + boolean_t apr_arej_info_valid; + ibt_arej_info_t apr_arej_info; +} ibt_cm_apr_rcv_t; + + +/* + * Connection Failed Message type (values of cf_msg). + * Identifies the CM message that either timed out or is being rejected. + */ +#define IBT_CM_FAILURE_REQ 0x00 +#define IBT_CM_FAILURE_REP 0x01 +#define IBT_CM_FAILURE_UNKNOWN 0x02 +#define IBT_CM_FAILURE_LAP 0x03 + +/* + * CM Failure code (values of cf_code). + * Identifies the reason for failure. + */ +#define IBT_CM_FAILURE_REJ_SENT 0x00 +#define IBT_CM_FAILURE_REJ_RCV 0x01 +#define IBT_CM_FAILURE_TIMEOUT 0x02 +#define IBT_CM_FAILURE_DUP 0x03 +#define IBT_CM_FAILURE_STALE 0x04 + +/* + * IBT_CM_EVENT_FAILURE event struct. + */ +typedef struct ibt_cm_conn_failed_s { + uint8_t cf_code; /* Failure Code */ + uint8_t cf_msg; /* The message that timed out or is */ + /* being rejected */ + boolean_t cf_arej_info_valid; /* Is cf_additional valid? */ + ibt_cm_reason_t cf_reason; /* Reject reason */ + ibt_arej_info_t cf_additional; /* Additional Reject info */ +} ibt_cm_conn_failed_t; + + +/* + * CM REQ_RCV event structure. + * + * The req_cm_opaque is an IBTF CM opaque (to the client) value, that should + * be returned to the IBTF CM if the client/server CM handler wishes to call + * ibt_cm_delay(). + * + * prim_addr->av_dgid Is the GID of the requester. + * prim_addr->av_sgid Is the local GID to which the + * requester is attempting to establish + * a connection to. + * hca_guid Is the HCA GUID that contains the + * prim_addr->av_sgid + * prim_hca_port Is the port on the hca_guid that + * prim_addr->av_sgid is on. + */ +typedef struct ibt_cm_req_rcv_s { + ib_svc_id_t req_service_id; + ibt_tran_srv_t req_transport; + ib_guid_t req_hca_guid; + uint8_t req_prim_hca_port; + uint8_t req_alt_hca_port; + ibt_adds_vect_t req_prim_addr; + ibt_adds_vect_t req_alt_addr; + uint8_t req_rdma_ra_in; /* Offered responder */ + /* resources. */ + uint8_t req_rdma_ra_out; /* Offered initiator depth */ + clock_t req_timeout; /* timeout in microseconds */ + /* This is the time that the */ + /* Service handler has to */ + /* return to the CM */ + ib_qpn_t req_remote_qpn; + ib_qkey_t req_remote_qkey; + ib_pkey_t req_pkey; + ibt_cm_flags_t req_flags; /* EE flow control etc */ + uint8_t req_retry_cnt:3; + ibt_rnr_retry_cnt_t req_rnr_retry_cnt; + ib_eecn_t req_opaque1; + ib_eecn_t req_opaque2; +} ibt_cm_req_rcv_t; + +typedef struct ibt_ofuvcm_req_data_s { + uint32_t req_rq_psn:24; + uint32_t reserved:8; + ib_mtu_t req_path_mtu; + ibt_rnr_nak_time_t req_rnr_nak_time; +} ibt_ofuvcm_req_data_t; + +/* + * The IBT_CM_EVENT_CONN_CLOSED event is generated by the CM when a connection + * has been closed. The reason the connection was closed is given in the + * "closed" member of the cm_event as one of: + * + * A client can only call ibt_free_channel() to free channel resources on + * receipt of the IBT_CM_EVENT_CONN_CLOSED event. + */ +#define IBT_CM_CLOSED_DREP_RCVD 0x01 +#define IBT_CM_CLOSED_DREQ_RCVD 0x02 +#define IBT_CM_CLOSED_REJ_RCVD 0x03 +#define IBT_CM_CLOSED_DREQ_TIMEOUT 0x04 +#define IBT_CM_CLOSED_DUP 0x05 +#define IBT_CM_CLOSED_ABORT 0x06 +#define IBT_CM_CLOSED_STALE 0x07 +#define IBT_CM_CLOSED_ALREADY 0x08 + +/* + * Operation type in ibt_cm_event_type_t. + * + * Note: + * The IBT_CM_EVENT_CONN_EST event has no associated "cm_event" + * field in the ibt_cm_event_t structure. + * + * The cm_session_id is a CM opaque (to the client) value, that + * should be returned to the CM if the client/server CM handler wishes + * to call ibt_cm_delay() or ibt_cm_proceed(). + * + */ +typedef struct ibt_cm_event_s { + ibt_cm_event_type_t cm_type; /* Describes the event */ + void *cm_session_id; /* Used by the CM */ + ibt_channel_hdl_t cm_channel; /* Event channel. Not valid */ + /* for ibt_cm_req_rcv_t */ + ibt_eec_hdl_t cm_opaque; + ibt_priv_data_len_t cm_priv_data_len; /* 0 if no private */ + void *cm_priv_data; /* data returned */ + union { + ibt_cm_rep_rcv_t rep; + ibt_cm_req_rcv_t req; + ibt_cm_lap_rcv_t lap; + ibt_cm_apr_rcv_t apr; + ibt_cm_mra_rcv_t mra; + ibt_cm_conn_failed_t failed; + uint8_t closed; + } cm_event; /* operation specific */ +} ibt_cm_event_t; + +/* + * CM Return structure for an incoming REQ + * Server handler that wishes to accept the connection, fills all the + * values before returning to CM + */ +typedef struct ibt_cm_ret_rep_s { + ibt_channel_hdl_t cm_channel; /* The channel overwhich the */ + /* connection will be */ + /* established */ + /* can be returned NULL */ + /* if no resources available */ + uint8_t cm_rdma_ra_out; /* max RDMA-R/Atomic sent */ + /* Number of RDMA RD's & */ + /* Atomics outstanding */ + uint8_t cm_rdma_ra_in; /* Incoming RDMA-R/Atomic */ + /* Responder resources for */ + /* handling incoming */ + /* RDMA RD's & Atomics */ + ibt_rnr_retry_cnt_t cm_rnr_retry_cnt; +} ibt_cm_ret_rep_t; + +/* + * Define an ibt_cm_proceed() argument union. + * + * rep is valid when an IBT client cm handler has decided to continue a + * REQ_RCV, accepting the connection. + * + * rej is valid when an IBT client cm handler has decided to continue a + * REQ_RCV or REP_RCV, rejecting the message. + * + * apr is valid when an IBT client cm handler has decided to continue a + * LAP_RCV, redirecting the lap request. + */ +typedef union ibt_cm_proceed_reply_s { + ibt_cm_ret_rep_t rep; /* Return for REP */ + ibt_arej_info_t rej; /* Return for REJ */ + ibt_redirect_info_t apr; /* Return for APR */ +} ibt_cm_proceed_reply_t; + + +/* + * Define a CM handler return arguments structure. + * + * cm_ret.rep is returned to the CM when an IBT client cm handler has + * decided to accept a connection in response to a CM REQ_RCV event. + * + * cm_ret.rej is returned to the CM when an IBT client cm handler + * has decided to reject the connection in response to a CM REQ_RCV event. + * + * cm_ret.apr is returned to the CM when an IBT client cm handler + * has decided to redirect the lap request in response to a CM LAP RCV event. + * + * The client/server should update cm_ret_len with number of private data + * bytes filled in priv_data arg of the cm handler. + */ +typedef struct ibt_cm_return_args_s { + ibt_priv_data_len_t cm_ret_len; + union { + ibt_cm_ret_rep_t rep; /* Return for REP */ + ibt_arej_info_t rej; /* Return for REJ */ + ibt_redirect_info_t apr; /* Return for APR */ + } cm_ret; /* reply specific */ +} ibt_cm_return_args_t; + + +/* + * Communication Manager UD event types. + */ +typedef enum ibt_cm_ud_event_type_e { + IBT_CM_UD_EVENT_SIDR_REQ = 1, + IBT_CM_UD_EVENT_SIDR_REP = 2 +} ibt_cm_ud_event_type_t; + +/* + * CM SIDR_REQ event structure. + */ +typedef struct ibt_cm_sidr_req_s { + ib_guid_t sreq_hca_guid; + uint8_t sreq_hca_port; + ib_pkey_t sreq_pkey; + ib_svc_id_t sreq_service_id; +} ibt_cm_sidr_req_t; + +/* + * CM SIDR_REP event structure. + */ +typedef struct ibt_cm_sidr_rep_s { + ibt_sidr_status_t srep_status; + ib_svc_id_t srep_service_id; + ib_qkey_t srep_remote_qkey; + ib_qpn_t srep_remote_qpn; + ibt_redirect_info_t srep_redirect; /* Only valid if redirect */ +} ibt_cm_sidr_rep_t; + +/* + * Operation type in ibt_cm_ud_event_type_t. + * + * The cm_session_id is a CM opaque (to the client) value, that + * should be returned to the CM if the client/server CM handler + * wishes to call ibt_cm_ud_proceed(). + */ +typedef struct ibt_cm_ud_event_s { + ibt_cm_ud_event_type_t cm_type; /* Describes the event record */ + void *cm_session_id; /* Used by the CM */ + ibt_priv_data_len_t cm_priv_data_len; + void *cm_priv_data; + union { + ibt_cm_sidr_rep_t sidr_rep; + ibt_cm_sidr_req_t sidr_req; + } cm_event; /* operation specific */ +} ibt_cm_ud_event_t; + + +/* + * Define a CM UD handler return arguments structure. + * + * The information here is returned to the CM when an IBT client CM UD + * handler has decided to communicate (via UD messages) with the requester + * of the SIDR_REQ_RCV event. + * + * The ud_channel encodes the QPN and Q_Key to be placed in the SIDR_REP. + * + * CM sets ud_ret_len to 0 before calling the UD CM handler. If the CM UD + * handler wishes to send private data back, it needs to update ud_ret_len + * with the actual number of bytes to be sent back in the SIDR_REP MAD. It + * copies said data to the buffer pointed to by the ret_priv_data argument. + * + * The ud_redirect structure should only be updated if the UD CM handler is + * Redirecting a CM request. + */ +typedef struct ibt_cm_ud_return_args_s { + ibt_priv_data_len_t ud_ret_len; + ibt_channel_hdl_t ud_channel; + ibt_redirect_info_t ud_redirect; +} ibt_cm_ud_return_args_t; + + +/* + * IBT Client CM Callback function typedefs. + * + * ibt_cm_handler_t: + * + * The CM event handler function. An IBT client callback that handles + * CM events. If the handler will exceed the event service timeout + * then it should call ibt_cm_delay(), specifying the maximum time it + * will take to complete processing the CM event. + * + * Clients are advised not to issue blocking calls from a cm handler, as this + * would block the CM threads, and could delay or block other client + * connections. + * + * Clients are allowed to make resource clean up/free calls in the CM handler + * such as ibt_free_cq, ibt_free_rc/ud_channel, etc. on connection failure + * or tear down. + * + * Clients should not call ibt_close_rc_channel in the cm handler for connection + * failure or tear down events, as these events already perform the processing + * necessary to close the channel. + * + * Clients can call ibt_close_rc_channel only in the non-blocking mode from + * the cm handler for connection abort. + */ +typedef ibt_cm_status_t (*ibt_cm_handler_t)(void *cm_private, + ibt_cm_event_t *event, ibt_cm_return_args_t *ret_args, + void *ret_priv_data, ibt_priv_data_len_t ret_len_max); + +/* + * ibt_cm_ud_handler_t - Pointer to the CM UD event handler function. + * This function should handle the following CM + * events: + * IBT_CM_UD_EVENT_SIDR_REQ + * IBT_CM_UD_EVENT_SIDR_REP + */ +typedef ibt_cm_status_t (*ibt_cm_ud_handler_t)(void *ud_cm_private, + ibt_cm_ud_event_t *event, ibt_cm_ud_return_args_t *ret_args, + void *ret_priv_data, ibt_priv_data_len_t ret_len_max); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IBTI_CM_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/ibti_common.h b/illumos-x86_64/usr/include/sys/ib/ibtl/ibti_common.h new file mode 100644 index 00000000..e71c12b6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/ibti_common.h @@ -0,0 +1,1967 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_IBTL_IBTI_COMMON_H +#define _SYS_IB_IBTL_IBTI_COMMON_H + +/* + * ibti_common.h + * + * This file contains the shared/common transport data types and function + * prototypes. + */ +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Max number of paths that can be requested in an ibt_get_paths() call, + * if IBT_PATH_PERF or IBT_PATH_AVAIL flag (ibt_path_flags_t) is set. + */ +#define IBT_MAX_SPECIAL_PATHS 2 + +/* + * The name of DDI Event, generated when the properties of IOC device + * node properties were modified. + */ +#define IB_PROP_UPDATE_EVENT "SUNW,IB:IB_PROP_UPDATE" + + +/* Transport Interface version */ +typedef int ibt_version_t; +#define IBTI_V1 1 +#define IBTI_V2 2 +#define IBTI_V3 3 +#define IBTI_V4 4 +#define IBTI_V_CURR IBTI_V4 + +/* + * Driver class type. Identifies a type of client driver so that + * "IBTF Policy" decisions can be made on a driver class basis. + * The last class should always be IBT_CLNT_NUM, and any new classes added + * must be defined before IBT_CLNT_NUM. The class values must be above 0. + * Any class values below or equal to 0 shall be invalid + */ +typedef enum ibt_clnt_class_e { + IBT_STORAGE_DEV = 0x1, /* SCSI, FC, etc.. */ + IBT_NETWORK_DEV, /* Network driver with associated client H/W */ + IBT_GENERIC_DEV, /* Generic client H/W device driver */ + IBT_NETWORK, /* Network driver with no associated */ + /* client H/W, e.g., IPoIB */ + IBT_GENERIC, /* A generic IB driver not */ + /* associated with client H/W */ + IBT_USER, /* A user application IBT interface driver */ + IBT_IBMA, /* The IBMA Module */ + IBT_CM, /* The CM Module */ + IBT_DM, /* The DM Module */ + IBT_DM_AGENT, /* DM Agent Module */ + IBT_GENERIC_MISC, /* Generic Misc Module */ + IBT_CLASS_NUM /* Place holder for class count */ +} ibt_clnt_class_t; + +#define IBT_TEST_DEV 999 /* Place holder for modules that test IBTL */ + +#define IBT_CLNT_DEVICE_CLASS(class) ((class) == IBT_STORAGE_DEV || \ + (class) == IBT_NETWORK_DEV || \ + (class) == IBT_GENERIC_DEV) + +#define IBT_CLNT_GENERAL_CLASS(class) ((class) == IBT_NETWORK || \ + (class) == IBT_GENERIC || \ + (class) == IBT_DM_AGENT || \ + (class) == IBT_TEST_DEV || \ + (class) == IBT_GENERIC_MISC || \ + (class) == IBT_USER) + +#define IBT_CLNT_MGMT_CLASS(class) ((class) == IBT_IBMA || \ + (class) == IBT_CM || \ + (class) == IBT_DM) + +/* + * These are some special client classes which don't have a 'dip' hence have + * to be handled specially in ibt_attach, where we bypass the check for a valid + * dip if the client belongs to the class below. + */ +#define IBT_MISCMOD_CLIENTS(class) ((class) == IBT_IBMA || \ + (class) == IBT_CM || \ + (class) == IBT_DM || \ + (class) == IBT_DM_AGENT || \ + (class) == IBT_GENERIC_MISC || \ + (class) == IBT_TEST_DEV) + +/* + * Event record & status returns for asynchronous events and errors. + */ +typedef struct ibt_async_event_s { + uint64_t ev_fma_ena; /* FMA Error data */ + ibt_channel_hdl_t ev_chan_hdl; /* Channel handle */ + ibt_cq_hdl_t ev_cq_hdl; /* CQ handle */ + ib_guid_t ev_hca_guid; /* HCA node GUID */ + ibt_srq_hdl_t ev_srq_hdl; /* SRQ handle */ + ibt_port_change_t ev_port_flags; /* Port Change flags */ + uint8_t ev_port; /* HCA port */ + ibt_fc_syndrome_t ev_fc; /* FEXCH syndrome */ +} ibt_async_event_t; + +/* + * IBT Client Callback function typedefs. + * + * ibt_async_handler_t + * Pointer to an async event/error handler function. This function is + * called when an async event/error is detected on a HCA that is being + * used by the IBT client driver that registered the function. + */ +typedef void (*ibt_async_handler_t)(void *clnt_private, + ibt_hca_hdl_t hca_hdl, ibt_async_code_t code, ibt_async_event_t *event); + +/* + * IBT Client Memory Error Callback function typedefs. + * + * ibt_memory_handler_t + * Pointer to an memory event/error handler function. + */ +typedef void (*ibt_memory_handler_t)(void *clnt_private, + ibt_hca_hdl_t hca_hdl, ibt_mem_code_t code, ibt_mem_data_t *data); + +/* + * Define a client module information structure. All clients MUST + * define a global of type ibt_clnt_modinfo_t. A pointer to this global + * is passed into the IBTF by a client when calling ibt_attach(). + * This struct must persist during the life of the client. + * + * The client's mi_async_handler is called when an async event/error is + * detected on a HCA that is being used by this client. + */ +typedef struct ibt_clnt_modinfo_s { + ibt_version_t mi_ibt_version; /* TI version */ + ibt_clnt_class_t mi_clnt_class; /* Type of client */ + ibt_async_handler_t mi_async_handler; /* Async Handler */ + ibt_memory_handler_t mi_reserved; /* Memory handler */ + char *mi_clnt_name; /* Client Name. */ +} ibt_clnt_modinfo_t; + + +/* + * Definitions for use with ibt_register_subnet_notices() + */ +typedef enum ibt_subnet_event_code_e { + IBT_SM_EVENT_MCG_CREATED = 1, + IBT_SM_EVENT_MCG_DELETED = 2, + IBT_SM_EVENT_AVAILABLE = 3, + IBT_SM_EVENT_UNAVAILABLE = 4, + IBT_SM_EVENT_GID_AVAIL = 5, + IBT_SM_EVENT_GID_UNAVAIL = 6 +} ibt_subnet_event_code_t; + +typedef struct ibt_subnet_event_s { + ib_gid_t sm_notice_gid; +} ibt_subnet_event_t; + +typedef void (*ibt_sm_notice_handler_t)(void *private, ib_gid_t gid, + ibt_subnet_event_code_t code, ibt_subnet_event_t *event); + + +/* + * MTU Request type. + */ +typedef struct ibt_mtu_req_s { + ib_mtu_t r_mtu; /* Requested MTU */ + ibt_selector_t r_selector; /* Qualifier for r_mtu */ +} ibt_mtu_req_t; + + +/* + * Qflags, used by ibt_resize_queues(). + */ +typedef enum ibt_qflags_e { + IBT_SEND_Q = 1 << 0, /* Op applies to the Send Q */ + IBT_RECV_Q = 1 << 1 /* Op applies to the Recv Q */ +} ibt_qflags_t; + + +/* + * ibt_cq_handler_t + * Pointer to a work request completion handler function. This function + * is called when a WR completes on a CQ that is being used by the IBTF + * client driver that registered the function. + */ +typedef void (*ibt_cq_handler_t)(ibt_cq_hdl_t ibt_cq, void *arg); + +/* default CQ handler ID */ +#define IBT_CQ_HID_DEFAULT (1) + +/* + * Service Data and flags. + * (IBTA Spec Release 1.1, Vol-1 Ref: 15.2.5.14.4) + * + * The ServiceData8.1 (sb_data8[0]) through ServiceData64.2 (sb_data64[1]) + * components together constitutes a 64-byte area in which any data may be + * placed. It is intended to be a convenient way for a service to provide its + * clients with some initial data. + * + * In addition, this 64-byte area is formally divided into a total of 30 + * components, 16 8-bit (uint8_t) components, then 8 16-bit (uint16_t) + * components, then 6 32-bit (uint32_t) components, then 2 64-bit (uint64_t) + * components, thereby assigning ComponentMask bits (ibt_srv_data_flags_t) to + * variously-sized segments of the data. All data are in host endian format. + * This allows query operations (ibt_get_paths()) to be used which match + * parts of the Service Data, making it possible, for example, for + * service-specific parts of the ServiceData to serve as a binary-coded + * extension to the ServiceName for purposes of lookup. + */ +typedef enum ibt_srv_data_flags_e { + IBT_NO_SDATA = 0, + + IBT_SDATA8_0 = (1 << 0), + IBT_SDATA8_1 = (1 << 1), + IBT_SDATA8_2 = (1 << 2), + IBT_SDATA8_3 = (1 << 3), + IBT_SDATA8_4 = (1 << 4), + IBT_SDATA8_5 = (1 << 5), + IBT_SDATA8_6 = (1 << 6), + IBT_SDATA8_7 = (1 << 7), + IBT_SDATA8_8 = (1 << 8), + IBT_SDATA8_9 = (1 << 9), + IBT_SDATA8_10 = (1 << 10), + IBT_SDATA8_11 = (1 << 11), + IBT_SDATA8_12 = (1 << 12), + IBT_SDATA8_13 = (1 << 13), + IBT_SDATA8_14 = (1 << 14), + IBT_SDATA8_15 = (1 << 15), + + IBT_SDATA16_0 = (1 << 16), + IBT_SDATA16_1 = (1 << 17), + IBT_SDATA16_2 = (1 << 18), + IBT_SDATA16_3 = (1 << 19), + IBT_SDATA16_4 = (1 << 20), + IBT_SDATA16_5 = (1 << 21), + IBT_SDATA16_6 = (1 << 22), + IBT_SDATA16_7 = (1 << 23), + + IBT_SDATA32_0 = (1 << 24), + IBT_SDATA32_1 = (1 << 25), + IBT_SDATA32_2 = (1 << 26), + IBT_SDATA32_3 = (1 << 27), + + IBT_SDATA64_0 = (1 << 28), + IBT_SDATA64_1 = (1 << 29), + + IBT_SDATA_ALL = 0x3FFFFFFF +} ibt_srv_data_flags_t; + +typedef struct ibt_srv_data_s { + uint8_t s_data8[16]; /* 8-bit service data fields. */ + uint16_t s_data16[8]; /* 16-bit service data fields. */ + uint32_t s_data32[4]; /* 32-bit service data fields. */ + uint64_t s_data64[2]; /* 64-bit service data fields. */ +} ibt_srv_data_t; + +/* + * Path flags, used in ibt_get_paths() + */ +typedef enum ibt_path_flags_e { + IBT_PATH_NO_FLAGS = 0, + IBT_PATH_APM = 1 << 0, /* APM is desired. */ + IBT_PATH_AVAIL = 1 << 2, + IBT_PATH_PERF = 1 << 3, + IBT_PATH_MULTI_SVC_DEST = 1 << 4, /* Multiple ServiceRecords */ + IBT_PATH_HOP = 1 << 5, /* pa_hop is specified. */ + IBT_PATH_PKEY = 1 << 6 /* pa_pkey is specified. */ +} ibt_path_flags_t; + +/* + * Path attributes. + * + * The ibt_path_attr_t structure is used to specify required attributes in a + * path from the requesting (source) node to a specified destination node. + * Attributes that are don't care should be set to NULL or '0'. + * A destination must be specified, where a destination can be defined as + * one of the following: + * + * o Service Name + * o Service ID (SID) + * o Array of DGIDs. + * o Service Name and Array of DGIDs. + */ +typedef struct ibt_path_attr_s { + ib_gid_t *pa_dgids; /* Array of DGIDs */ + ib_gid_t pa_sgid; + ib_guid_t pa_hca_guid; + char *pa_sname; /* ASCII Service name */ + /* NULL Terminated */ + ib_svc_id_t pa_sid; /* Service ID */ + ibt_srv_data_flags_t pa_sd_flags; /* Service Data flags. */ + ibt_srv_data_t pa_sdata; /* Service Data */ + uint8_t pa_hca_port_num; + uint8_t pa_num_dgids; /* size of pa_dgids array */ + uint8_t pa_sl:4; + ibt_mtu_req_t pa_mtu; + ibt_srate_req_t pa_srate; + ibt_pkt_lt_req_t pa_pkt_lt; /* Packet Life Time Request */ + uint_t pa_flow:20; + uint8_t pa_hop; /* IBT_PATH_HOP */ + uint8_t pa_tclass; + ib_pkey_t pa_pkey; /* IBT_PATH_PKEY */ +} ibt_path_attr_t; + +/* + * Path Information. + * + * The ibt_get_paths() performs SA Path record lookups to select a path(s) to + * a given destination(s), details of selected path(s) are returned in this + * structure. + * + * The ibt_path_info_t contains all the attributes of the best path(s), as + * as determined by IBTL, to the specified destination(s), including the + * local HCA and HCA port to use to access the fabric. + * + * The Service ID (pi_sid) and Service Data (pi_sdata) are returned only for + * lookups based on Service ID or/and Service Name. + */ +typedef struct ibt_path_info_s { + ib_guid_t pi_hca_guid; /* Local HCA GUID; 0 implies */ + /* this record is invalid */ + ib_svc_id_t pi_sid; /* Service ID */ + ibt_srv_data_t pi_sdata; /* Service Data */ + + ibt_cep_path_t pi_prim_cep_path; /* Contains CEP adds info */ + ibt_cep_path_t pi_alt_cep_path; /* RC & UC Only, valid if */ + /* cep_hca_port_num is not */ + /* '0' */ + ib_mtu_t pi_path_mtu; /* Common path MTU */ + ib_time_t pi_prim_pkt_lt; + ib_time_t pi_alt_pkt_lt; +} ibt_path_info_t; + +/* + * Optional Alternate Path attributes. + * + * The ibt_alt_path_attr_t structure is used to specify additional optional + * attributes when requesting an alternate path for an existing channel. + * + * Attributes that are don't care should be set to NULL or '0'. + */ +typedef struct ibt_alt_path_attr_s { + ib_gid_t apa_sgid; + ib_gid_t apa_dgid; + ibt_srate_req_t apa_srate; + ibt_pkt_lt_req_t apa_pkt_lt; /* Packet Life Time Request */ + uint_t apa_flow:20; + uint8_t apa_sl:4; + uint8_t apa_hop; + uint8_t apa_tclass; +} ibt_alt_path_attr_t; + +/* + * Path Information for Alternate Path - input to ibt_set_alt_path(). + */ +typedef struct ibt_alt_path_info_s { + ibt_cep_path_t ap_alt_cep_path; /* RC & UC Only, valid if */ + /* cep_hca_port_num is not */ + /* '0' */ + ib_time_t ap_alt_pkt_lt; +} ibt_alt_path_info_t; + +/* + * Open Channel flags, Used in ibt_open_rc_channel call + */ +typedef enum ibt_chan_open_flags_e { + IBT_OCHAN_NO_FLAGS = 0, + IBT_OCHAN_REDIRECTED = 1 << 0, + IBT_OCHAN_PORT_REDIRECTED = 1 << 1, + IBT_OCHAN_DUP = 1 << 2, + IBT_OCHAN_PORT_FIXED = 1 << 3, + IBT_OCHAN_OPAQUE1 = 1 << 4, + IBT_OCHAN_OPAQUE2 = 1 << 5, + IBT_OCHAN_OPAQUE3 = 1 << 6, + IBT_OCHAN_OPAQUE4 = 1 << 7, + IBT_OCHAN_OPAQUE5 = 1 << 8, + IBT_OCHAN_OPAQUE6 = 1 << 9 +} ibt_chan_open_flags_t; + +/* + * Arguments for ibt_open_rc_channel(). + * + * oc_priv_data should be NULL or point to a buffer allocated by the caller, + * the size of which should be in oc_priv_data_len, where oc_priv_data_len <= + * IBT_REQ_PRIV_DATA_SZ. + * + * When ibt_open_rc_channel returns with ibt_cm_reason_t of + * IBT_CM_REDIRECT_PORT, the client can re-issue ibt_open_rc_channel setting + * new fields as follows: + * + * Set (ibt_chan_args_t)->oc_cm_cep_path = + * original (ibt_chan_open_args_t)->oc_path->pi_prim_cep_path. + * Set (ibt_chan_args_t)->oc_cm_pkt_lt = + * original (ibt_chan_open_args_t)->oc_prim_pkt_lt. + * Update (ibt_chan_args_t)->oc_path based on path information returned + * from ibt_get_paths using the gid in the return data below: + * (ibt_rc_returns_t)->rc_arej_info.ari_redirect_info.ari_gid. + * Set flags to IBT_OCHAN_PORT_REDIRECTED. + * + * Note : oc_cm_path is not used for any other scenario, and must be set for + * IBT_OCHAN_PORT_REDIRECTED. + * + * When ibt_open_rc_channel returns with ibt_cm_reason_t of + * IBT_CM_REDIRECT_CM, the client can re-issue ibt_open_rc_channel setting + * new fields as follows: + * + * Update (ibt_chan_args_t)->oc_path based on path information returned + * from ibt_get_paths using the return data in + * (ibt_rc_returns_t)->rc_arej_info.ari_redirect_info. + * + * Set (ibt_chan_args_t)->oc_cm_redirect_info = + * Returned (ibt_rc_returns_t)->rc_arej_info.ari_redirect_info. + * Set flags to IBT_OCHAN_REDIRECTED. + * + * Note: + * + * IBT_OCHAN_PORT_REDIRECTED flag cannot be used to specify a remote CM MAD + * address, that is on a different subnet than the RC connection itself. + * + * Not specified attributes should be set to "NULL" or "0". + */ +typedef struct ibt_chan_open_args_s { + ibt_path_info_t *oc_path; /* Primary & Alternate */ + ibt_cm_handler_t oc_cm_handler; /* cm_handler - required */ + void *oc_cm_clnt_private; /* First argument to */ + /* cm_handler */ + ibt_rnr_retry_cnt_t oc_path_rnr_retry_cnt; + uint8_t oc_path_retry_cnt:3; + uint8_t oc_rdma_ra_out; + uint8_t oc_rdma_ra_in; + ibt_priv_data_len_t oc_priv_data_len; /* Number of bytes of */ + /* REQ Private data */ + void *oc_priv_data; /* REQ private data */ + ibt_channel_hdl_t oc_dup_channel; /* IBT_OCHAN_DUP */ + ibt_redirect_info_t *oc_cm_redirect_info; /* Redirect params */ + /* for port and CM */ + /* redirection */ + ibt_cep_path_t *oc_cm_cep_path; /* Optional Path for */ + /* CM MADs on */ + /* port redirection */ + ib_time_t oc_cm_pkt_lt; /* Pkt life time for */ + /* CM MADs */ + uint32_t oc_opaque1:4; + uint32_t oc_opaque2:24; + uint32_t oc_opaque3; + uint32_t oc_opaque4; +} ibt_chan_open_args_t; + + +/* + * Define an optional RC return arguments structure. This contains return + * parameters from ibt_open_rc_channel() when called in BLOCKING mode. + * + * rc_priv_data should be NULL or point to a buffer allocated by the caller, + * the size of which should be in rc_priv_data_len, where rc_priv_data_len <= + * IBT_REP_PRIV_DATA_SZ. + */ +typedef struct ibt_rc_returns_s { + uint8_t rc_rdma_ra_in; /* Arbitrated resp resources */ + uint8_t rc_rdma_ra_out; /* Arbitrated initiator depth */ + ibt_arej_info_t rc_arej_info; + ibt_cm_reason_t rc_status; + uint8_t rc_failover_status; /* Failover status */ + ibt_priv_data_len_t rc_priv_data_len; + void *rc_priv_data; +} ibt_rc_returns_t; + +/* + * Define a callback function that can be used in Non-Blocking calls to + * ibt_recycle_rc(). + */ + +typedef void (*ibt_recycle_handler_t)(ibt_status_t ibt_status, void *arg); + +/* + * Define an optional return arguments structure from ibt_set_alt_path() + * This contains return parameters, when called in BLOCKING mode. + * + * ap_priv_data should be NULL or point to a buffer allocated by the caller, + * the size of which should be in ap_priv_data_len, where ap_priv_data_len <= + * IBT_APR_PRIV_DATA_SZ. + * The private data from APR is returned in ap_priv_data. + * The caller specifies amount of APR private data to be returned in + * ap_priv_data_len. + */ +typedef struct ibt_ap_returns_s { + ibt_ap_status_t ap_status; + boolean_t ap_arej_info_valid; + ibt_arej_info_t ap_arej_info; /* Only valid if redirect */ + ibt_priv_data_len_t ap_priv_data_len; + void *ap_priv_data; +} ibt_ap_returns_t; + +/* + * UD remote destination attributes. + * + * ud_sid, ud_addr, ud_pkt_lt and ud_pkey_ix must be specified. + * These values can be as returned in an ibt_path_info_t struct from an + * ibt_get_paths() call. + * + * ud_priv_data should be NULL or point to a buffer allocated by the caller, + * the size of which is in ud_priv_data_len, where ud_priv_data_len <= + * IBT_SIDR_REQ_PRIV_DATA_SZ. + */ +typedef struct ibt_ud_dest_attr_s { + ib_svc_id_t ud_sid; /* Service ID */ + ibt_adds_vect_t *ud_addr; /* Address Info */ + uint16_t ud_pkey_ix; /* Pkey Index */ + ib_time_t ud_pkt_lt; + ibt_cm_ud_handler_t ud_cm_handler; /* An optional CM UD event */ + /* which must be NULL */ + /* if not specified. */ + void *ud_cm_private; /* First arg to ud_cm_handler */ + ibt_priv_data_len_t ud_priv_data_len; + void *ud_priv_data; /* SIDR REQ private data */ +} ibt_ud_dest_attr_t; + +/* + * Define an optional UD return arguments structure. + * + * ud_priv_data should be NULL or point to a buffer allocated by the caller, + * the size of which should be in ud_priv_data_len, where ud_priv_data_len <= + * IBT_SIDR_REP_PRIV_DATA_SZ. + */ +typedef struct ibt_ud_returns_s { + ibt_sidr_status_t ud_status; + ibt_redirect_info_t ud_redirect; + ib_qpn_t ud_dqpn; /* Returned destination QPN */ + ib_qkey_t ud_qkey; /* Q_Key for destination QPN */ + ibt_priv_data_len_t ud_priv_data_len; + void *ud_priv_data; +} ibt_ud_returns_t; + +/* + * Multicast group attributes + * Not specified attributes should be set to "NULL" or "0". + * Used by ibt_join_mcg()/ibt_query_mcg(). + * + * mc_qkey, mc_pkey, mc_flow, mc_tclass, mc_sl, mc_join_state are required for + * create - ibt_join_mcg(). + */ +typedef struct ibt_mcg_attr_s { + ib_gid_t mc_mgid; /* MGID */ + ib_gid_t mc_pgid; /* SGID of the end port being */ + /* added to the MCG. */ + ib_qkey_t mc_qkey; /* Q_Key */ + ib_pkey_t mc_pkey; /* Partition key for this MCG */ + ibt_mtu_req_t mc_mtu_req; /* MTU */ + ibt_srate_req_t mc_rate_req; /* Static rate */ + ibt_pkt_lt_req_t mc_pkt_lt_req; /* Packet Life Time Request */ + uint_t mc_flow:20; /* FlowLabel. */ + uint8_t mc_hop; /* HopLimit */ + uint8_t mc_tclass; /* Traffic Class. */ + uint8_t mc_sl:4; /* Service Level */ + uint8_t mc_scope:4, /* Multicast Address Scope */ + mc_join_state:4; /* FULL For create */ + ib_lid_t mc_opaque1; +} ibt_mcg_attr_t; + +/* + * Multicast group attributes. + * returned by ibt_join_mcg()/ibt_query_mcg(). + */ +typedef struct ibt_mcg_info_s { + ibt_adds_vect_t mc_adds_vect; /* Address information */ + ib_mtu_t mc_mtu; /* MTU */ + ib_qkey_t mc_qkey; /* Q_Key */ + uint16_t mc_pkey_ix; /* Pkey Index */ + uint8_t mc_scope:4; /* Multicast Address Scope */ + clock_t mc_opaque2; +} ibt_mcg_info_t; + +/* + * Define a callback function that can be used in Non-Blocking calls to + * ibt_join_mcg(). + */ +typedef void (*ibt_mcg_handler_t)(void *arg, ibt_status_t retval, + ibt_mcg_info_t *mcg_info_p); + + +/* + * Service Flags - sd_flags + * + * IBT_SRV_PEER_TYPE_SID Peer-to-peer Service IDs. + */ + +typedef enum ibt_service_flags_e { + IBT_SRV_NO_FLAGS = 0x0, + IBT_SRV_PEER_TYPE_SID = 0x1 +} ibt_service_flags_t; + +/* + * Define a Service ID Registration structure. + */ +typedef struct ibt_srv_desc_s { + ibt_cm_ud_handler_t sd_ud_handler; /* UD Service Handler */ + ibt_cm_handler_t sd_handler; /* Non-UD Service Handler */ + ibt_service_flags_t sd_flags; /* Flags */ +} ibt_srv_desc_t; + +/* + * Flag to indicate ibt_bind_service() to or NOT-to clean-up Stale matching + * Local Service Records with SA prior to binding the new request. + */ +#define IBT_SBIND_NO_FLAGS 0 +#define IBT_SBIND_NO_CLEANUP 1 + +/* + * Define a Service ID Binding structure (data for service records). + */ +typedef struct ibt_srv_bind_s { + uint64_t sb_key[2]; /* Service Key */ + char *sb_name; /* Service Name (up to 63 chars) */ + uint32_t sb_lease; /* Service Lease period (in seconds) */ + ib_pkey_t sb_pkey; /* Service P_Key */ + ibt_srv_data_t sb_data; /* Service Data */ + uint_t sb_flag; /* indicates to/not-to clean-up stale */ + /* matching local service records. */ +} ibt_srv_bind_t; + +/* + * ibt_cm_delay() flags. + * + * Refer to InfiniBand Architecture Release Volume 1 Rev 1.0a: + * Section 12.6.6 MRA + */ +typedef enum ibt_cmdelay_flags_e { + IBT_CM_DELAY_REQ = 0, + IBT_CM_DELAY_REP = 1, + IBT_CM_DELAY_LAP = 2 +} ibt_cmdelay_flags_t; + +/* + * The payload for DDI events passed on IB_PROP_UPDATE_EVENT. + * This is passed as the bus nexus data to event_handler(9e). + */ +typedef struct ibt_prop_update_payload_s { + union { + struct { + uint32_t srv_updated:1; + uint32_t gid_updated:1; + } _ib_prop_update_struct; + uint32_t prop_updated; + } _ib_prop_update_union; + ibt_status_t ib_reprobe_status; + +#define ib_srv_prop_updated \ + _ib_prop_update_union._ib_prop_update_struct.srv_updated +#define ib_gid_prop_updated \ + _ib_prop_update_union._ib_prop_update_struct.gid_updated +#define ib_prop_updated \ + _ib_prop_update_union.prop_updated +} ibt_prop_update_payload_t; + + +/* + * FUNCTION PROTOTYPES. + */ + +/* + * ibt_attach() and ibt_detach(): + * These are the calls into IBTF used during client driver attach() and + * detach(). + * + * The IBTF returns an ibt_clnt_hdl_t to the client. This handle is used + * to identify this client device in all subsequent calls into the IBTF. + * + * The ibt_detach() routine is called from a client driver's detach() + * routine to deregister itself from the IBTF. + */ +ibt_status_t ibt_attach(ibt_clnt_modinfo_t *mod_infop, dev_info_t *arg, + void *clnt_private, ibt_clnt_hdl_t *ibt_hdl_p); + +ibt_status_t ibt_detach(ibt_clnt_hdl_t ibt_hdl); + +/* + * HCA FUNCTIONS + */ + +/* + * ibt_get_hca_list() + * Returns the number of HCAs in a system and their node GUIDS. + * + * If hca_list_p is not NULL then the memory for the array of GUIDs is + * allocated by the IBTF and should be freed by the caller using + * ibt_free_hca_list(). If hca_list_p is NULL then no memory is allocated + * by ibt_get_hca_list and only the number of HCAs in a system is returned. + * + * It is assumed that the caller can block in kmem_alloc. + * + * ibt_free_hca_list() + * Free the memory allocated by ibt_get_hca_list(). + */ +uint_t ibt_get_hca_list(ib_guid_t **hca_list_p); + +void ibt_free_hca_list(ib_guid_t *hca_list, uint_t entries); + +/* + * ibt_open_hca() - Open/Close a HCA. HCA can only be opened/closed + * ibt_close_hca() once. ibt_open_hca() takes a client's ibt handle + * and a GUID and returns a unique IBT client HCA + * handle. + * + * These routines can not be called from interrupt context. + */ +ibt_status_t ibt_open_hca(ibt_clnt_hdl_t ibt_hdl, ib_guid_t hca_guid, + ibt_hca_hdl_t *hca_hdl); + +ibt_status_t ibt_close_hca(ibt_hca_hdl_t hca_hdl); + + +/* + * ibt_query_hca() + * ibt_query_hca_byguid() + * Returns the static attributes of the specified HCA + */ +ibt_status_t ibt_query_hca(ibt_hca_hdl_t hca_hdl, ibt_hca_attr_t *hca_attrs); + +ibt_status_t ibt_query_hca_byguid(ib_guid_t hca_guid, + ibt_hca_attr_t *hca_attrs); + + +/* + * ibt_query_hca_ports() + * ibt_query_hca_ports_byguid() + * Returns HCA port/ports attributes for the specified HCA port/ports. + * ibt_query_hca_ports() allocates the memory required for the + * ibt_hca_portinfo_t struct as well as the memory required for the SGID + * and P_Key tables contained within that struct. + * + * ibt_free_portinfo() + * Frees the memory allocated for a specified ibt_hca_portinfo_t struct. + */ +ibt_status_t ibt_query_hca_ports(ibt_hca_hdl_t hca_hdl, uint8_t port, + ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p); + +ibt_status_t ibt_query_hca_ports_byguid(ib_guid_t hca_guid, uint8_t port, + ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p); + +void ibt_free_portinfo(ibt_hca_portinfo_t *port_info, uint_t size); + +/* + * ibt_set_hca_private() - Set/get the client private data. + * ibt_get_hca_private() + */ +void ibt_set_hca_private(ibt_hca_hdl_t hca_hdl, void *clnt_private); +void *ibt_get_hca_private(ibt_hca_hdl_t hca_hdl); + +/* + * ibt_hca_handle_to_guid() + * A helper function to retrieve HCA GUID for the specified handle. + * Returns HCA GUID on which the specified Channel is allocated. Valid + * if it is non-NULL on return. + */ +ib_guid_t ibt_hca_handle_to_guid(ibt_hca_hdl_t hca); + +/* + * ibt_hca_guid_to_handle() + * A helper function to retrieve a hca handle from a HCA GUID. + */ +ibt_status_t ibt_hca_guid_to_handle(ibt_clnt_hdl_t ibt_hdl, ib_guid_t hca_guid, + ibt_hca_hdl_t *hca_hdl); + +/* + * CONNECTION ESTABLISHMENT/TEAR DOWN FUNCTIONS. + */ + +/* + * ibt_get_paths + * Finds the best path to a specified destination (as determined by the + * IBTL) that satisfies the requirements specified in an ibt_path_attr_t + * struct. + */ +ibt_status_t ibt_get_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags, + ibt_path_attr_t *attr, uint8_t max_paths, ibt_path_info_t *paths, + uint8_t *num_paths_p); + + +/* + * Callback function that can be used in ibt_aget_paths(), a Non-Blocking + * version of ibt_get_paths(). + */ +typedef void (*ibt_path_handler_t)(void *arg, ibt_status_t retval, + ibt_path_info_t *paths, uint8_t num_paths); + +/* + * Find path(s) to a given destination or service asynchronously. + * ibt_aget_paths() is a Non-Blocking version of ibt_get_paths(). + */ +ibt_status_t ibt_aget_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags, + ibt_path_attr_t *attr, uint8_t max_paths, ibt_path_handler_t func, + void *arg); + +/* + * ibt_get_alt_path + * Finds the best alternate path to a specified channel (as determined by + * the IBTL) that satisfies the requirements specified in an + * ibt_alt_path_attr_t struct. The specified channel must have been + * previously opened successfully using ibt_open_rc_channel. + */ +ibt_status_t ibt_get_alt_path(ibt_channel_hdl_t chan, ibt_path_flags_t flags, + ibt_alt_path_attr_t *attr, ibt_alt_path_info_t *alt_path); + +/* + * ibt_open_rc_channel + * ibt_open_rc_channel() opens a previously allocated RC communication + * channel. The IBTL initiates the channel establishment protocol. + */ +ibt_status_t ibt_open_rc_channel(ibt_channel_hdl_t rc_chan, + ibt_chan_open_flags_t flags, ibt_execution_mode_t mode, + ibt_chan_open_args_t *args, ibt_rc_returns_t *returns); + +/* + * ibt_close_rc_channel + * Close the specified channel. Outstanding work requests are flushed + * so that the client can do the associated clean up. After that, the + * client will usually deregister the previously registered memory, + * then free the channel by calling ibt_free_rc_channel(). + * + * This function will reuse CM event Handler provided in + * ibt_open_rc_channel(). + */ +ibt_status_t ibt_close_rc_channel(ibt_channel_hdl_t rc_chan, + ibt_execution_mode_t mode, void *priv_data, + ibt_priv_data_len_t priv_data_len, uint8_t *ret_status, + void *ret_priv_data, ibt_priv_data_len_t *ret_priv_data_len_p); + +/* + * ibt_prime_close_rc_channel + * + * Allocates resources required for a close rc channel operation. + * Calling ibt_prime_close_rc_channel() allows a channel to be + * subsequently closed in interrupt context. + * + * A call is first made to ibt_prime_close_rc_channel in non-interrupt + * context, followed by ibt_close_rc_channel in non-blocking mode from + * interrupt context + * + * ibt_prime_close_rc_channel() can only be called on a previously opened + * channel. + */ +ibt_status_t ibt_prime_close_rc_channel(ibt_channel_hdl_t rc_chan); + +/* + * ibt_recycle_rc + * + * Recycle a RC channel which has transitioned to Error state. The + * ibt_recycle_rc() function transitions the channel from Error + * state (IBT_STATE_ERROR) to the state ready for use by + * ibt_open_rc_channel. Basically, this function is very similar to + * ibt_alloc_rc_channel, but reuses an existing RC channel. + * + * Clients are allowed to make resource clean up/free calls in the CM handler + * + * Client(s) must not invoke blocking version (ie., func specified as NULL) of + * ibt_recycle_rc from cm callback for IBT_CM_EVENT_CONN_CLOSED + * + * Clients are strongly advised not to issue blocking calls from func, as this + * would block the CM threads, and could delay or block other client connections + * and ibtl related API invocations. + */ +ibt_status_t ibt_recycle_rc(ibt_channel_hdl_t rc_chan, ibt_cep_flags_t control, + uint8_t hca_port_num, ibt_recycle_handler_t func, void *arg); + +/* + * ibt_recycle_ud + * + * Recycle a UD channel which has transitioned to Error state. The + * ibt_recycle_ud() function transitions the channel from Error + * state (IBT_STATE_ERROR) to a usable state (IBT_STATE_RTS). + * Basically, this function is very similar to ibt_alloc_ud_channel, + * but reuses an existing UD channel. + */ +ibt_status_t ibt_recycle_ud(ibt_channel_hdl_t ud_chan, uint8_t hca_port_num, + uint16_t pkey_ix, ib_qkey_t qkey); + +/* + * MODIFY CHANNEL ATTRIBUTE FUNCTIONs. + */ + +/* + * ibt_pause_sendq + * ibt_unpause_sendq + * Place the send queue of the specified channel into the send queue + * drained state. + * Applicable for both RC and UD channels. + */ +ibt_status_t ibt_pause_sendq(ibt_channel_hdl_t chan, + ibt_cep_modify_flags_t modify_flags); + +ibt_status_t ibt_unpause_sendq(ibt_channel_hdl_t chan); + +/* + * ibt_resize_queues() + * Resize the SendQ/RecvQ sizes of a channel. + * + * Applicable for both RC and UD channels. + */ +ibt_status_t ibt_resize_queues(ibt_channel_hdl_t chan, ibt_qflags_t flags, + ibt_queue_sizes_t *request_sz, ibt_queue_sizes_t *actual_sz); + +/* + * ibt_query_queues() + * + * Query the SendQ/RecvQ sizes of a channel. + * Applicable for both RC and UD channels. + */ +ibt_status_t ibt_query_queues(ibt_channel_hdl_t chan, + ibt_queue_sizes_t *actual_sz); + +/* + * ibt_modify_rdma + * Enable/disable RDMA operations. + * + * Applicable for RC channels only. + */ +ibt_status_t ibt_modify_rdma(ibt_channel_hdl_t rc_chan, + ibt_cep_modify_flags_t modify_flags, ibt_cep_flags_t flags); + + +/* + * ibt_set_rdma_resource + * Change the number of resources to be used for incoming and outgoing + * RDMA reads & Atomics. + */ +ibt_status_t ibt_set_rdma_resource(ibt_channel_hdl_t rc_chan, + ibt_cep_modify_flags_t modify_flags, uint8_t rdma_ra_out, + uint8_t rdma_ra_in); + +/* + * ibt_change_port + * Change the primary physical port of an RC channel. (This is done only + * if HCA supports this capability). Can only be called on a paused + * channel. + * Applicable for RC channels only. + */ +ibt_status_t ibt_change_port(ibt_channel_hdl_t rc_chan, uint8_t port_num); + + +/* + * SERVICE REGISTRATION FUNCTIONS + */ + +/* + * ibt_register_service() + * ibt_deregister_service() + * Register/deregister a Service (range of Service IDs) with the IBTF. + * + * ibt_bind_service() + * ibt_unbind_service() + * ibt_unbind_all_services() + * Bind a Service to a given port (GID), and optionally create + * service record(s) with the SA for ibt_get_paths() to find. + */ +ibt_status_t ibt_register_service(ibt_clnt_hdl_t ibt_hdl, + ibt_srv_desc_t *service, ib_svc_id_t sid, int num_sids, + ibt_srv_hdl_t *srv_hdl_p, ib_svc_id_t *ret_sid_p); + +ibt_status_t ibt_deregister_service(ibt_clnt_hdl_t ibt_hdl, + ibt_srv_hdl_t srv_hdl); + +ibt_status_t ibt_bind_service(ibt_srv_hdl_t srv_hdl, ib_gid_t gid, + ibt_srv_bind_t *srv_bind, void *cm_private, ibt_sbind_hdl_t *sb_hdl_p); + +ibt_status_t ibt_unbind_service(ibt_srv_hdl_t srv_hdl, ibt_sbind_hdl_t sb_hdl); +ibt_status_t ibt_unbind_all_services(ibt_srv_hdl_t srv_hdl); + +/* + * ibt_cm_delay + * A client CM handler/srv_handler function can call this function to + * extend its response time to a CM event. + * Applicable for RC channels only. + */ +ibt_status_t ibt_cm_delay(ibt_cmdelay_flags_t flags, void *cm_session_id, + clock_t service_time, void *priv_data, ibt_priv_data_len_t priv_data_len); + +/* + * ibt_cm_proceed + * + * An IBT client calls ibt_cm_proceed() to proceed with a connection that + * previously deferred by the client returning IBT_CM_DEFER on a CM handler + * callback. CM events that can be deferred and continued with ibt_cm_proceed() + * are REQ_RCV, REP_RCV, LAP_RCV, and DREQ_RCV. + * + * NOTE : + * + * Typically CM completes processing of a client's CM handler return, with + * IBT_CM_DEFER status, before processing of the corresponding ibt_cm_proceed() + * is started. However a race exists where by CM may not have completed the + * client's handler return processing when ibt_cm_proceed() is called by a + * client. In this case ibt_cm_proceed() will block until processing of the + * client's CM handler return is complete. + * + * A client that returns IBT_CM_DEFER from the cm handler must + * subsequently make a call to ibt_cm_proceed(). It is illegal to call + * ibt_cm_proceed() on a channel that has not had the connection + * establishment deferred. + * + * Client cannot call ibt_cm_proceed from the cm handler. + */ +ibt_status_t ibt_cm_proceed(ibt_cm_event_type_t event, void *session_id, + ibt_cm_status_t status, ibt_cm_proceed_reply_t *cm_event_data, + void *priv_data, ibt_priv_data_len_t priv_data_len); + +/* + * ibt_cm_ud_proceed + * + * An IBT client calls ibt_cm_ud_proceed() to proceed with an + * IBT_CM_UD_EVENT_SIDR_REQ UD event that was previously deferred by the + * client returning IBT_CM_DEFER on a CM UD handler callback. + * NOTE : + * + * Typically CM completes processing of a client's CM handler return, with + * IBT_CM_DEFER status, before processing of the corresponding + * ibt_cm_ud_proceed() is started. However a race exists where by CM may not + * have completed the client's handler return processing when + * ibt_cm_ud_proceed() is called by a client. In this case ibt_cm_ud_proceed() + * will block until processing of the client's CM handler return is complete. + * + * A client that returns IBT_CM_DEFER from the cm handler must + * subsequently make a call to ibt_cm_ud_proceed(). It is illegal to call + * ibt_cm_ud_proceed() on a channel that has not had the connection + * establishment deferred. + * + * Client cannot call ibt_cm_ud_proceed from the cm handler. + */ +ibt_status_t ibt_cm_ud_proceed(void *session_id, ibt_channel_hdl_t ud_channel, + ibt_cm_status_t status, ibt_redirect_info_t *redirect_infop, + void *priv_data, ibt_priv_data_len_t priv_data_len); + + +/* + * COMPLETION QUEUES. + * + * ibt_alloc_cq_sched() + * Reserve CQ scheduling class resources + * + * ibt_free_cq_sched() + * Free CQ scheduling class resources + */ +ibt_status_t ibt_alloc_cq_sched(ibt_hca_hdl_t hca_hdl, + ibt_cq_sched_attr_t *attr, ibt_sched_hdl_t *sched_hdl_p); + +ibt_status_t ibt_free_cq_sched(ibt_hca_hdl_t hca_hdl, + ibt_sched_hdl_t sched_hdl); + +/* + * ibt_alloc_cq() + * Allocate a completion queue. + */ +ibt_status_t ibt_alloc_cq(ibt_hca_hdl_t hca_hdl, ibt_cq_attr_t *cq_attr, + ibt_cq_hdl_t *ibt_cq_p, uint_t *real_size); + +/* + * ibt_free_cq() + * Free allocated CQ resources. + */ +ibt_status_t ibt_free_cq(ibt_cq_hdl_t ibt_cq); + + +/* + * ibt_enable_cq_notify() + * Enable notification requests on the specified CQ. + * Applicable for both RC and UD channels. + * + * Completion notifications are disabled by setting the completion + * handler to NULL by calling ibt_set_cq_handler(). + */ +ibt_status_t ibt_enable_cq_notify(ibt_cq_hdl_t ibt_cq, + ibt_cq_notify_flags_t notify_type); + +/* + * ibt_set_cq_handler() + * Register a work request completion handler with the IBTF. + * Applicable for both RC and UD channels. + * + * Completion notifications are disabled by setting the completion + * handler to NULL. When setting the handler to NULL, no additional + * calls to the CQ handler will be initiated. + * + * This function does not otherwise change the state of previous + * calls to ibt_enable_cq_notify(). + */ +void ibt_set_cq_handler(ibt_cq_hdl_t ibt_cq, + ibt_cq_handler_t completion_handler, void *arg); + +/* + * ibt_poll_cq() + * Poll the specified CQ for the completion of work requests (WRs). + * If the CQ contains completed WRs, up to num_wc of them are returned. + * Applicable for both RC and UD channels. + */ +ibt_status_t ibt_poll_cq(ibt_cq_hdl_t ibt_cq, ibt_wc_t *work_completions, + uint_t num_wc, uint_t *num_polled); + +/* + * ibt_query_cq() + * Return the total number of entries in the CQ. + */ +ibt_status_t ibt_query_cq(ibt_cq_hdl_t ibt_cq, uint_t *entries, + uint_t *count_p, uint_t *usec_p, ibt_cq_handler_id_t *hid_p); + +/* + * ibt_query_cq_handler_id() + * Return interrupt characteristics of the CQ handler + */ +ibt_status_t ibt_query_cq_handler_id(ibt_hca_hdl_t hca_hdl, + ibt_cq_handler_id_t hid, ibt_cq_handler_attr_t *attrs); + +/* + * ibt_resize_cq() + * Change the size of a CQ. + */ +ibt_status_t ibt_resize_cq(ibt_cq_hdl_t ibt_cq, uint_t new_sz, uint_t *real_sz); + +/* + * ibt_modify_cq() + * Change the interrupt moderation values of a CQ. + * "count" is number of completions before interrupting. + * "usec" is the number of microseconds before interrupting. + */ +ibt_status_t ibt_modify_cq(ibt_cq_hdl_t ibt_cq, uint_t count, uint_t usec, + ibt_cq_handler_id_t hid); + +/* + * ibt_set_cq_private() + * ibt_get_cq_private() + * Set/get the client private data. + */ +void ibt_set_cq_private(ibt_cq_hdl_t ibt_cq, void *clnt_private); +void *ibt_get_cq_private(ibt_cq_hdl_t ibt_cq); + + +/* + * Memory Management Functions. + * Applicable for both RC and UD channels. + * + * ibt_register_mr() + * Prepares a virtually addressed memory region for use by a HCA. A + * description of the registered memory suitable for use in Work Requests + * (WRs) is returned in the ibt_mr_desc_t parameter. + * + * ibt_register_buf() + * Prepares a memory region described by a buf(9S) struct for use by a + * HCA. A description of the registered memory suitable for use in + * Work Requests (WRs) is returned in the ibt_mr_desc_t parameter. + * + * ibt_query_mr() + * Retrieves information about a specified memory region. + * + * ibt_deregister_mr() + * Remove a memory region from a HCA translation table, and free all + * resources associated with the memory region. + * + * ibt_reregister_mr() + * ibt_reregister_buf() + * Modify the attributes of an existing memory region. + * + * ibt_register_shared_mr() + * Given an existing memory region, a new memory region associated with + * the same physical locations is created. + * + * ibt_sync_mr() + * Sync a memory region for either RDMA reads or RDMA writes + * + * ibt_alloc_mw() + * Allocate a memory window. + * + * ibt_query_mw() + * Retrieves information about a specified memory window. + * + * ibt_free_mw() + * De-allocate the Memory Window. + */ +ibt_status_t ibt_register_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, + ibt_mr_attr_t *mem_attr, ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc); + +ibt_status_t ibt_register_buf(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, + ibt_smr_attr_t *mem_bpattr, struct buf *bp, ibt_mr_hdl_t *mr_hdl_p, + ibt_mr_desc_t *mem_desc); + +ibt_status_t ibt_query_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, + ibt_mr_query_attr_t *attr); + +ibt_status_t ibt_deregister_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl); + +ibt_status_t ibt_reregister_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, + ibt_pd_hdl_t pd, ibt_mr_attr_t *mem_attr, ibt_mr_hdl_t *mr_hdl_p, + ibt_mr_desc_t *mem_desc); + +ibt_status_t ibt_reregister_buf(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, + ibt_pd_hdl_t pd, ibt_smr_attr_t *mem_bpattr, struct buf *bp, + ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc); + +ibt_status_t ibt_register_shared_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, + ibt_pd_hdl_t pd, ibt_smr_attr_t *mem_sattr, ibt_mr_hdl_t *mr_hdl_p, + ibt_mr_desc_t *mem_desc); + +ibt_status_t ibt_sync_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_sync_t *mr_segments, + size_t num_segments); + +ibt_status_t ibt_alloc_mw(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, + ibt_mw_flags_t flags, ibt_mw_hdl_t *mw_hdl_p, ibt_rkey_t *rkey); + +ibt_status_t ibt_query_mw(ibt_hca_hdl_t hca_hdl, ibt_mw_hdl_t mw_hdl, + ibt_mw_query_attr_t *mw_attr_p); + +ibt_status_t ibt_free_mw(ibt_hca_hdl_t hca_hdl, ibt_mw_hdl_t mw_hdl); + +/* + * ibt_alloc_lkey() + * Allocates physical buffer list resources for use in memory + * registrations. + * + * Applicable for both RC and UD channels. + */ +ibt_status_t ibt_alloc_lkey(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, + ibt_lkey_flags_t flags, uint_t phys_buf_list_sz, ibt_mr_hdl_t *mr_p, + ibt_pmr_desc_t *mem_desc_p); + + +/* + * Physical Memory Management Functions. + * Applicable for both RC and UD channels. + * + * ibt_register_phys_mr() + * Prepares a physically addressed memory region for use by a HCA. + * + * ibt_reregister_phys_mr() + * Modify the attributes of an existing memory region. + */ +ibt_status_t ibt_register_phys_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, + ibt_pmr_attr_t *mem_pattr, ibt_mr_hdl_t *mr_hdl_p, + ibt_pmr_desc_t *mem_desc_p); + +ibt_status_t ibt_reregister_phys_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, + ibt_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr, ibt_mr_hdl_t *mr_hdl_p, + ibt_pmr_desc_t *mem_desc_p); + + +/* + * Register DMA Memory Region + */ +ibt_status_t ibt_register_dma_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, + ibt_dmr_attr_t *mem_attr, ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc); + + +/* + * Address Translation. + */ + +/* + * ibt_map_mem_area() + * Translate a kernel virtual address range into HCA physical addresses. + * A set of physical addresses, that can be used with "Reserved L_Key", + * register physical, and "Fast Registration Work Request" operations + * is returned. + */ +ibt_status_t ibt_map_mem_area(ibt_hca_hdl_t hca_hdl, ibt_va_attr_t *va_attrs, + uint_t paddr_list_len, ibt_reg_req_t *reg_req, ibt_ma_hdl_t *ma_hdl_p); + +/* + * ibt_unmap_mem_area() + * Un pin physical pages pinned during an ibt_map_mem_area() call. + */ +ibt_status_t ibt_unmap_mem_area(ibt_hca_hdl_t hca_hdl, ibt_ma_hdl_t ma_hdl); + +/* ibt_map_mem_iov() */ +ibt_status_t ibt_map_mem_iov(ibt_hca_hdl_t hca_hdl, + ibt_iov_attr_t *iov_attr, ibt_all_wr_t *wr, ibt_mi_hdl_t *mi_hdl); + +/* ibt_unmap_mem_iov() */ +ibt_status_t ibt_unmap_mem_iov(ibt_hca_hdl_t hca_hdl, ibt_mi_hdl_t mi_hdl); + +/* + * Work Request Functions + * Applicable for RC and UD channels. + * + * ibt_post_send() + * Post send work requests to the specified channel. + * + * ibt_post_recv() + * ibt_post_srq() + * Post receive work requests to the specified channel. + */ +ibt_status_t ibt_post_send(ibt_channel_hdl_t chan, ibt_send_wr_t *wr_list, + uint_t num_wr, uint_t *posted); + +ibt_status_t ibt_post_recv(ibt_channel_hdl_t chan, ibt_recv_wr_t *wr_list, + uint_t num_wr, uint_t *posted); + +ibt_status_t ibt_post_srq(ibt_srq_hdl_t srq, ibt_recv_wr_t *wr_list, + uint_t num_wr, uint_t *posted); + + +/* + * Alternate Path Migration Functions. + * Applicable for RC channels only. + * + * + * ibt_get_alt_path() + * Finds the best alternate path to a specified channel (as determined by + * the IBTL) that satisfies the requirements specified in an + * ibt_alt_path_attr_t struct. The specified channel must have been + * previously opened successfully using ibt_open_rc_channel. + * This function also ensures that the service being accessed by the + * channel is available at the selected alternate port. + * + * Note: The apa_dgid must be on the same destination channel adapter, + * if specified. + * + * + * ibt_set_alt_path() + * Load the specified alternate path. Causes the CM to send an LAP message + * to the remote node. If successful, the local channel is updated with + * the new alternate path and the channel migration state is set to REARM. + * Can only be called on a previously opened RC channel. The channel must + * be either in RTS or paused state. + * + * + * ibt_migrate_path() + * Force the CI to use the alternate path. The alternate path becomes + * the primary path. A new alternate path should be loaded and enabled. + */ +ibt_status_t ibt_get_alt_path(ibt_channel_hdl_t rc_chan, ibt_path_flags_t flags, + ibt_alt_path_attr_t *attr, ibt_alt_path_info_t *alt_pathp); + +ibt_status_t ibt_set_alt_path(ibt_channel_hdl_t rc_chan, + ibt_execution_mode_t mode, ibt_alt_path_info_t *alt_pinfo, void *priv_data, + ibt_priv_data_len_t priv_data_len, ibt_ap_returns_t *ret_args); + +ibt_status_t ibt_migrate_path(ibt_channel_hdl_t rc_chan); + + +/* + * Multicast group Functions. + * Applicable for UD channels only. + */ + +/* + * ibt_attach_mcg() + * Attaches a UD channel to the specified multicast group. On successful + * completion, this channel will be provided with a copy of every + * multicast message addressed to the group specified by the MGID + * (mcg_info->mc_adds_vect.av_dgid) and received on the HCA port with + * which the channel is associated. + */ +ibt_status_t ibt_attach_mcg(ibt_channel_hdl_t ud_chan, + ibt_mcg_info_t *mcg_info); + +/* + * ibt_detach_mcg() + * Detach the specified UD channel from the specified multicast group. + */ +ibt_status_t ibt_detach_mcg(ibt_channel_hdl_t ud_chan, + ibt_mcg_info_t *mcg_info); + +/* + * ibt_join_mcg() + * Join a multicast group. The first full member "join" causes the MCG + * to be created. + */ +ibt_status_t ibt_join_mcg(ib_gid_t rgid, ibt_mcg_attr_t *mcg_attr, + ibt_mcg_info_t *mcg_info_p, ibt_mcg_handler_t func, void *arg); + +/* + * ibt_leave_mcg() + * The port associated with the port GID shall be removed from the + * multicast group specified by MGID (mc_gid) or from all the multicast + * groups of which it is a member if the MGID (mc_gid) is not specified + * (i.e. mc_gid.mgid_prefix must have 8-bits of 11111111 at the start of + * the GID to identify this as being a multicast GID). + * + * The last full member to leave causes the destruction of the Multicast + * Group. + */ +ibt_status_t ibt_leave_mcg(ib_gid_t rgid, ib_gid_t mc_gid, ib_gid_t port_gid, + uint8_t mc_join_state); + +/* + * ibt_query_mcg() + * Request information on multicast groups that match the parameters + * specified in mcg_attr. Information on each multicast group is returned + * to the caller in the form of an array of ibt_mcg_info_t. + * ibt_query_mcg() allocates the memory for this array and returns a + * pointer to the array (mcgs_p) and the number of entries in the array + * (entries_p). This memory should be freed by the client using + * ibt_free_mcg_info(). + */ +ibt_status_t ibt_query_mcg(ib_gid_t rgid, ibt_mcg_attr_t *mcg_attr, + uint_t mcgs_max_num, ibt_mcg_info_t **mcgs_info_p, uint_t *entries_p); + +/* + * ibt_free_mcg_info() + * Free the memory allocated by successful ibt_query_mcg() + */ +void ibt_free_mcg_info(ibt_mcg_info_t *mcgs_info, uint_t entries); + + +/* + * ibt_register_subnet_notices() + * Register a handler to be called for subnet notifications. + */ +void ibt_register_subnet_notices(ibt_clnt_hdl_t ibt_hdl, + ibt_sm_notice_handler_t sm_notice_handler, void *private); + + +/* + * Protection Domain Functions. + * + * ibt_alloc_pd() + * ibt_free_pd() + * Allocate/Release a protection domain + */ +ibt_status_t ibt_alloc_pd(ibt_hca_hdl_t hca_hdl, ibt_pd_flags_t flags, + ibt_pd_hdl_t *pd); +ibt_status_t ibt_free_pd(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd); + +/* + * P_Key to P_Key Index conversion Functions. + * + * ibt_pkey2index_byguid + * ibt_pkey2index Convert a P_Key into a P_Key index. + * + * ibt_index2pkey_byguid + * ibt_index2pkey Convert a P_Key Index into a P_Key. + */ +ibt_status_t ibt_pkey2index(ibt_hca_hdl_t hca_hdl, uint8_t port_num, + ib_pkey_t pkey, uint16_t *pkey_ix); + +ibt_status_t ibt_index2pkey(ibt_hca_hdl_t hca_hdl, uint8_t port_num, + uint16_t pkey_ix, ib_pkey_t *pkey); + +ibt_status_t ibt_pkey2index_byguid(ib_guid_t hca_guid, uint8_t port_num, + ib_pkey_t pkey, uint16_t *pkey_ix); + +ibt_status_t ibt_index2pkey_byguid(ib_guid_t hca_guid, uint8_t port_num, + uint16_t pkey_ix, ib_pkey_t *pkey); + +/* + * ibt_ci_data_in() + * + * Pass CI specific userland data for CI objects to the CI. + */ +ibt_status_t ibt_ci_data_in(ibt_hca_hdl_t hca, ibt_ci_data_flags_t flags, + ibt_object_type_t object, void *ibt_object_handle, void *data_p, + size_t data_sz); + +/* + * ibt_ci_data_out() + * + * Obtain CI specific userland data for CI objects. + */ +ibt_status_t ibt_ci_data_out(ibt_hca_hdl_t hca, ibt_ci_data_flags_t flags, + ibt_object_type_t object, void *ibt_object_handle, void *data_p, + size_t data_sz); + + +/* + * Node Information. + */ + +/* Node type : n_node_type */ +#define IBT_NODE_TYPE_CHANNEL_ADAPTER 1 /* HCA or TCA */ +#define IBT_NODE_TYPE_SWITCH 2 +#define IBT_NODE_TYPE_ROUTER 3 + +typedef struct ibt_node_info_s { + ib_guid_t n_sys_img_guid; /* System Image GUID */ + ib_guid_t n_node_guid; /* Node GUID */ + ib_guid_t n_port_guid; /* Port GUID */ + uint16_t n_dev_id; /* Device ID */ + uint32_t n_revision; /* Device Revision */ + uint32_t n_vendor_id:24; /* Device Vendor ID */ + uint8_t n_num_ports; /* Number of ports on this node. */ + uint8_t n_port_num; /* Port number. */ + uint8_t n_node_type; /* Node type */ + char n_description[64]; /* NULL terminated ASCII string */ +} ibt_node_info_t; + + +/* + * ibt_gid_to_node_info() + * Retrieve node information for the specified GID. + */ +ibt_status_t ibt_gid_to_node_info(ib_gid_t gid, ibt_node_info_t *node_info_p); + +/* + * ibt_reprobe_dev + * Reprobe properties for IOC device node. + */ +ibt_status_t ibt_reprobe_dev(dev_info_t *dip); + +/* + * ibt_get_companion_port_gids() + * + * Get list of GID's available on a companion port(s) of the specified + * GID or list of GIDs available on a specified Node GUID/System Image + * GUID. + */ +ibt_status_t ibt_get_companion_port_gids(ib_gid_t gid, ib_guid_t hca_guid, + ib_guid_t sysimg_guid, ib_gid_t **gids_p, uint_t *num_gids_p); + +/* + * SHARED RECEIVE QUEUE + */ + + +/* + * ibt_alloc_srq() + * Allocate a shared receive queue. + */ +ibt_status_t ibt_alloc_srq(ibt_hca_hdl_t hca_hdl, ibt_srq_flags_t flags, + ibt_pd_hdl_t pd, ibt_srq_sizes_t *sizes, ibt_srq_hdl_t *ibt_srq_p, + ibt_srq_sizes_t *real_size_p); + +/* + * ibt_free_srq() + * Free allocated SRQ resources. + */ +ibt_status_t ibt_free_srq(ibt_srq_hdl_t ibt_srq); + +/* + * ibt_query_srq() + * Query a shared receive queue. + */ +ibt_status_t ibt_query_srq(ibt_srq_hdl_t ibt_srq, ibt_pd_hdl_t *pd_p, + ibt_srq_sizes_t *sizes_p, uint_t *limit_p); + +/* + * ibt_modify_srq() + * Modify a shared receive queue. + */ +ibt_status_t ibt_modify_srq(ibt_srq_hdl_t ibt_srq, ibt_srq_modify_flags_t flags, + uint_t size, uint_t limit, uint_t *real_size_p); + +/* + * ibt_set_srq_private() + * ibt_get_srq_private() + * Set/get the SRQ client private data. + */ +void ibt_set_srq_private(ibt_srq_hdl_t ibt_srq, void *clnt_private); +void *ibt_get_srq_private(ibt_srq_hdl_t ibt_srq); + +/* + * ibt_check_failure() + * Function to test for special case failures + */ +ibt_failure_type_t ibt_check_failure(ibt_status_t status, uint64_t *reserved_p); + + +/* + * ibt_hw_is_present() returns 0 when there is no IB hardware actively + * running. This is primarily useful for modules like rpcmod which needs a + * quick check to decide whether or not it should try to use InfiniBand. + */ +int ibt_hw_is_present(); + +/* + * Fast Memory Registration (FMR). + * + * ibt_create_fmr_pool + * Not fast-path. + * ibt_create_fmr_pool() verifies that the HCA supports FMR and allocates + * and initializes an "FMR pool". This pool contains state specific to + * this registration, including the watermark setting to determine when + * to sync, and the total number of FMR regions available within this pool. + * + * ibt_destroy_fmr_pool + * ibt_destroy_fmr_pool() deallocates all of the FMR regions in a specific + * pool. All state and information regarding the pool are destroyed and + * returned as free space once again. No more use of FMR regions in this + * pool are possible without a subsequent call to ibt_create_fmr_pool(). + * + * ibt_flush_fmr_pool + * ibt_flush_fmr_pool forces a flush to occur. At the client's request, + * any unmapped FMR regions (See 'ibt_deregister_mr())') are returned to + * a free state. This function allows for an asynchronous cleanup of + * formerly used FMR regions. Sync operation is also performed internally + * by HCA driver, when 'watermark' settings for the number of free FMR + * regions left in the "pool" is reached. + * + * ibt_register_physical_fmr + * ibt_register_physical_fmr() assigns a "free" entry from the FMR Pool. + * It first consults the "FMR cache" to see if this is a duplicate memory + * registration to something already in use. If not, then a free entry + * in the "pool" is marked used. + * + * ibt_deregister_fmr + * The ibt_deregister_fmr un-maps the resources reserved from the FMR + * pool by ibt_register_physical_fmr(). The ibt_deregister_fmr() will + * mark the region as free in the FMR Pool. + */ +ibt_status_t ibt_create_fmr_pool(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, + ibt_fmr_pool_attr_t *fmr_params, ibt_fmr_pool_hdl_t *fmr_pool_p); + +ibt_status_t ibt_destroy_fmr_pool(ibt_hca_hdl_t hca_hdl, + ibt_fmr_pool_hdl_t fmr_pool); + +ibt_status_t ibt_flush_fmr_pool(ibt_hca_hdl_t hca_hdl, + ibt_fmr_pool_hdl_t fmr_pool); + +ibt_status_t ibt_register_physical_fmr(ibt_hca_hdl_t hca_hdl, + ibt_fmr_pool_hdl_t fmr_pool, ibt_pmr_attr_t *mem_pattr, + ibt_mr_hdl_t *mr_hdl_p, ibt_pmr_desc_t *mem_desc_p); + +ibt_status_t ibt_deregister_fmr(ibt_hca_hdl_t hca, ibt_mr_hdl_t mr_hdl); + +/* + * IP SUPPORT + */ + +/* + * IP get_paths + * Returns an array (or single) of paths and source IP addresses. In the + * simplest form just the destination IP address is specified, and one path + * is requested, then one ibt_path_info_t struct and one source IP. + * + * More than one path can be requested to a single destination, in which case + * the requested number of ibt_path_info_t's are returned, and the same + * number of SRC IP address, with the first SRC IP address corrosponding + * to the first ibt_path_info_t, etc. + * + * Restrictions on the source end point can be specified, in the form of a + * source IP address (this implicitly defines the HCA, HCA port and Pkey) + * HCA, HCA port, and sgid (implicitly defines HCA and HCA port). + * Combinations are allowed but they must be consistent. + * + * Path attributes can also be specified, these can also affect local HCA + * selection. + * + * ibt_get_ip_paths() internally does (among other things): + * + * o ibt_get_list_of_ibd_ipaddr_and_macaddr( OUT list_ipaddr_macaddr) + * + * o extract_pkey_and_sgid(IN list_ipaddr_macaddr, OUT list_pkey_and_sgid) + * + * o map_dst_ip_addr(IN dst_ip_addr, OUT dst_pkey, OUT dgid) - See Note + * + * o filter_by_pkey(IN list_pkey_and_sgid, IN dst_pkey, OUT list_of_sgid) + * + * o do_multipath_query(IN list_of_sgid, IN dst_pkey, IN dgid, OUT path_list) + * + * o pick_a_good_path(IN path_list, OUT the_path) + * + * o find_matching_src_ip(IN the_path, IN list_ipaddr_macaddr, OUT src_ip) + * + * The ibd instance which got the ARP response is only on one P_Key + * knowing the ibd instance (or which IPonIB MCG) got the ARP response + * determins the P_Key associated with a dgid. If the proposedi "ip2mac()" + * API is used to get an IP to GID translations, then returned 'sockaddr_dl' + * contains the interface name and index. + * + * + * Example: + * ip_path_attr.ipa_dst_ip = dst_ip_addr; + * ip_path_attr.ipa_ndst = 1; + * ip_path_attr.ipa_max_paths = 1; + * + * status = ibt_get_ip_paths(clnt_hdl, flags, &ip_path_attr, &paths, + * &num_paths_p, &src_ip); + * + * sid = ibt_get_ip_sid(protocol_num, dst_port); + * path_info->sid = sid; + * + * ip_cm_info.src_addr = src_ip; + * ip_cm_info.dst_addr = dst_ip_addr; + * ip_cm_info.src_port = src_port + * + * ibt_format_ip_private_data(ip_cm_info, priv_data_len, &priv_data); + * ibt_open_rc_channel(chan, private_data); + */ +typedef struct ibt_ip_path_attr_s { + ibt_ip_addr_t *ipa_dst_ip; /* Required */ + ibt_ip_addr_t ipa_src_ip; /* Optional */ + ib_guid_t ipa_hca_guid; /* Optional */ + uint8_t ipa_hca_port_num; /* Optional */ + uint8_t ipa_max_paths; /* Required */ + uint8_t ipa_ndst; /* Required */ + uint8_t ipa_sl:4; /* Optional */ + ibt_mtu_req_t ipa_mtu; /* Optional */ + ibt_srate_req_t ipa_srate; /* Optional */ + ibt_pkt_lt_req_t ipa_pkt_lt; /* Optional */ + uint_t ipa_flow:20; /* Optional */ + uint8_t ipa_hop; /* Optional */ + uint8_t ipa_tclass; /* Optional */ + zoneid_t ipa_zoneid; /* Default 0 = Global Zone */ +} ibt_ip_path_attr_t; + +/* + * Path SRC IP addresses + */ +typedef struct ibt_path_ip_src_s { + ibt_ip_addr_t ip_primary; + ibt_ip_addr_t ip_alternate; +} ibt_path_ip_src_t; + + +ibt_status_t ibt_get_ip_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags, + ibt_ip_path_attr_t *attr, ibt_path_info_t *paths_p, uint8_t *num_paths_p, + ibt_path_ip_src_t *src_ip_p); + +/* + * ibt_get_src_ip() + * Get List of IP-Address that matches the parameters specified in + * srcip_attr. As a given MAC address can have both IPv4 and IPv6 + * addressed configured, caller can optional request to return only + * the desired family by specifying the "sip_family" field. If + * "sip_family" is AF_UNSPEC, then all assigned IP address (IPv4 + * and/or IPv6) will be returned. In case of IPv6 address, scope_id + * for that specific address will also be returned. + * "sip_zoneid" will specify the zones the user is interested in. + * + * Information on each ip-address is returned to the caller in the + * form of an array of ibt_srcip_info_t. ibt_get_src_ip() allocates the + * memory for this array and returns a pointer to the array (src_info_p) + * and the number of entries in the array (entries_p). This memory + * should be freed by the client using ibt_free_srcip_info(). + * + * ibt_free_srcip_info() + * Free the memory allocated by successful ibt_get_src_ip() + */ +typedef struct ibt_srcip_attr_s { + ib_gid_t sip_gid; /* REQUIRED: Local Port GID */ + zoneid_t sip_zoneid; /* Zero means Global Zone */ + ib_pkey_t sip_pkey; /* Optional */ + sa_family_t sip_family; /* Optional : IPv4 or IPv6 */ +} ibt_srcip_attr_t; + +/* + * ip_flag : Flag to indicate whether the returned list of ip-address + * has any duplicate records. + */ +#define IBT_IPADDR_NO_FLAGS 0 +#define IBT_IPADDR_DUPLICATE 1 + +typedef struct ibt_srcip_info_s { + ibt_ip_addr_t ip_addr; + zoneid_t ip_zoneid; /* ZoneId of this ip-addr */ + uint_t ip_flag; /* Flag to indicate any gotchas */ +} ibt_srcip_info_t; + +ibt_status_t ibt_get_src_ip(ibt_srcip_attr_t *srcip_attr, + ibt_srcip_info_t **src_info_p, uint_t *entries_p); + +void ibt_free_srcip_info(ibt_srcip_info_t *src_info, uint_t entries); + + +/* + * Callback function that can be used in ibt_aget_ip_paths(), a Non-Blocking + * version of ibt_get_ip_paths(). + */ +typedef void (*ibt_ip_path_handler_t)(void *arg, ibt_status_t retval, + ibt_path_info_t *paths_p, uint8_t num_paths, ibt_path_ip_src_t *src_ip_p); + +/* + * Find path(s) to a given destination or service asynchronously. + * ibt_aget_ip_paths() is a Non-Blocking version of ibt_get_ip_paths(). + */ +ibt_status_t ibt_aget_ip_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags, + ibt_ip_path_attr_t *attr, ibt_ip_path_handler_t func, void *arg); + +/* + * IP RDMA protocol functions + */ + +/* + * IBTF manages the port number space for non well known ports. If a ULP + * is not using TCP/UDP and a well known port, then ibt_get_ip_sid() returns + * an sid based on the IP protocol number '0' (reserved) and an IBTF assigned + * port number. ibt_release_ip_sid() should be used to release the hold + * of SID created by ibt_get_ip_sid(). + */ +ib_svc_id_t ibt_get_ip_sid(uint8_t protocol_num, in_port_t dst_port); +ibt_status_t ibt_release_ip_sid(ib_svc_id_t sid); + +uint8_t ibt_get_ip_protocol_num(ib_svc_id_t sid); +in_port_t ibt_get_ip_dst_port(ib_svc_id_t sid); + +/* + * Functions to format/extract the RDMA IP CM private data + */ +typedef struct ibt_ip_cm_info_s { + ibt_ip_addr_t src_addr; + ibt_ip_addr_t dst_addr; + in_port_t src_port; +} ibt_ip_cm_info_t; + +/* + * If a ULP is using IP addressing as defined by the RDMA IP CM Service IBTA + * Annex 11, then it must always allocate a private data buffer for use in + * the ibt_open_rc_channel(9F) call. The minimum size of the buffer is + * IBT_IP_HDR_PRIV_DATA_SZ, if the ULP has no ULP specific private data. + * This allows ibt_format_ip_private_data() to place the RDMA IP CM service + * hello message in the private data of the REQ. If the ULP has some ULP + * specific private data then it should allocate a buffer big enough to + * contain that data plus an additional IBT_IP_HDR_PRIV_DATA_SZ bytes. + * The ULP should place its ULP specific private data at offset + * IBT_IP_HDR_PRIV_DATA_SZ in the allocated buffer before calling + * ibt_format_ip_private_data(). + */ +ibt_status_t ibt_format_ip_private_data(ibt_ip_cm_info_t *ip_cm_info, + ibt_priv_data_len_t priv_data_len, void *priv_data_p); +ibt_status_t ibt_get_ip_data(ibt_priv_data_len_t priv_data_len, + void *priv_data, ibt_ip_cm_info_t *ip_info_p); + +/* + * The ibt_alt_ip_path_attr_t structure is used to specify additional optional + * attributes when requesting an alternate path for an existing channel. + * + * Attributes that are don't care should be set to NULL or '0'. + */ +typedef struct ibt_alt_ip_path_attr_s { + ibt_ip_addr_t apa_dst_ip; + ibt_ip_addr_t apa_src_ip; + ibt_srate_req_t apa_srate; + ibt_pkt_lt_req_t apa_pkt_lt; /* Packet Life Time Request */ + uint_t apa_flow:20; + uint8_t apa_sl:4; + uint8_t apa_hop; + uint8_t apa_tclass; + zoneid_t apa_zoneid; /* Default 0 = Global Zone */ +} ibt_alt_ip_path_attr_t; + +ibt_status_t ibt_get_ip_alt_path(ibt_channel_hdl_t rc_chan, + ibt_path_flags_t flags, ibt_alt_ip_path_attr_t *attr, + ibt_alt_path_info_t *alt_path); + +/* + * CONTRACT PRIVATE ONLY INTERFACES + * + * DO NOT USE THE FOLLOWING FUNCTIONS WITHOUT SIGNING THE CONTRACT + * WITH IBTF GROUP. + */ + +/* Define an Address Record structure (data for ATS service records). */ +typedef struct ibt_ar_s { + ib_gid_t ar_gid; /* GID of local HCA port */ + ib_pkey_t ar_pkey; /* P_Key valid on port of ar_gid */ + uint8_t ar_data[16]; /* Data affiliated with GID/P_Key */ +} ibt_ar_t; + +/* + * ibt_register_ar() + * ibt_deregister_ar() + * Register/deregister an Address Record with the SA. + * ibt_query_ar() + * Query the SA for Address Records matching either GID/P_Key or Data. + */ +ibt_status_t ibt_register_ar(ibt_clnt_hdl_t ibt_hdl, ibt_ar_t *arp); + +ibt_status_t ibt_deregister_ar(ibt_clnt_hdl_t ibt_hdl, ibt_ar_t *arp); + +ibt_status_t ibt_query_ar(ib_gid_t *sgid, ibt_ar_t *queryp, ibt_ar_t *resultp); + + +/* + * ibt_modify_system_image() + * ibt_modify_system_image_byguid() + * Modify specified HCA's system image GUID. + */ +ibt_status_t ibt_modify_system_image(ibt_hca_hdl_t hca_hdl, ib_guid_t sys_guid); + +ibt_status_t ibt_modify_system_image_byguid(ib_guid_t hca_guid, + ib_guid_t sys_guid); + + +/* + * ibt_modify_port() + * ibt_modify_port_byguid() + * Modify the specified port, or all ports attribute(s). + */ +ibt_status_t ibt_modify_port(ibt_hca_hdl_t hca_hdl, uint8_t port, + ibt_port_modify_flags_t flags, uint8_t init_type); + +ibt_status_t ibt_modify_port_byguid(ib_guid_t hca_guid, uint8_t port, + ibt_port_modify_flags_t flags, uint8_t init_type); + + +/* + * ibt_get_port_state() + * ibt_get_port_state_byguid() + * Return the most commonly requested attributes of an HCA port. + * If the link state is not IBT_PORT_ACTIVE, the other returned values + * are undefined. + */ +ibt_status_t ibt_get_port_state(ibt_hca_hdl_t hca_hdl, uint8_t port, + ib_gid_t *sgid_p, ib_lid_t *base_lid_p); + +ibt_status_t ibt_get_port_state_byguid(ib_guid_t hca_guid, uint8_t port, + ib_gid_t *sgid_p, ib_lid_t *base_lid_p); + +/* + * ibt_alloc_io_mem() + * ibt_free_io_mem() + * Allocate and deallocate dma-able memory. + */ +ibt_status_t ibt_alloc_io_mem(ibt_hca_hdl_t, size_t, ibt_mr_flags_t, + caddr_t *, ibt_mem_alloc_hdl_t *); + +ibt_status_t ibt_free_io_mem(ibt_hca_hdl_t, ibt_mem_alloc_hdl_t); + +/* + * Interfaces to get IB partition information. + */ + +typedef struct ibt_part_attr_s { + datalink_id_t pa_dlinkid; + datalink_id_t pa_plinkid; + uint8_t pa_port; + ib_guid_t pa_hca_guid; + ib_guid_t pa_port_guid; + ib_pkey_t pa_pkey; +} ibt_part_attr_t; + +void ibt_register_part_attr_cb( + ibt_status_t (*)(datalink_id_t, ibt_part_attr_t *), + ibt_status_t (*)(ibt_part_attr_t **, int *)); +void ibt_unregister_part_attr_cb(void); + +ibt_status_t ibt_get_part_attr(datalink_id_t, ibt_part_attr_t *); +ibt_status_t ibt_get_all_part_attr(ibt_part_attr_t **, int *); +ibt_status_t ibt_free_part_attr(ibt_part_attr_t *, int); + + +/* + * ibt_lid_to_node_info() + * Retrieve node record information for the specified LID. + */ +ibt_status_t ibt_lid_to_node_info(ib_lid_t lid, ibt_node_info_t *node_info_p); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IBTI_COMMON_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_ci_types.h b/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_ci_types.h new file mode 100644 index 00000000..ab77ba3f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_ci_types.h @@ -0,0 +1,408 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_IBTL_IBTL_CI_TYPES_H +#define _SYS_IB_IBTL_IBTL_CI_TYPES_H + +/* + * ibtl_ci_types.h + * Definitions shared between the IBTL and CI interface. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ibc_cq_s *ibt_opaque1_t; +typedef struct ibc_srq_s *ibt_opaque2_t; +typedef struct ibc_rdd_s *ibt_rdd_hdl_t; /* ibt_alloc_eec() */ + + +/* + * Channel Modify flags - ibt_cep_modify_flags_t + * + * Note: + * That the IBT_CEP_SET_RESET_INIT, IBT_CEP_SET_INIT_RTR + * IBT_CEP_SET_RTR_RTS flags are mutually exclusive. However if one of the + * optional attributes associated with these flags is to be modified then + * the corresponding modify flag must also be specified. For example if + * a client wishes to transit from the INIT to RTR state but additionally + * they want to disable atomics, then the modify flags should be: + * + * (IBT_CEP_SET_INIT_RTR | IBT_CEP_SET_ATOMIC) + * + * And the following attributes specified: + * + * - Number of responder resources for RDMA read/atomic ops. + * - Primary Path Address Vector Information. + * - Destination QPN. + * - PSN for ReceiveQ. + * - Minimum RNR NAK Timer field value. + * - ibt_cep_flags_t set to IBT_CEP_ATOMIC + * + */ +#define IBT_CEP_SET_RESET_INIT IBT_CEP_SET_OPAQUE1 +#define IBT_CEP_SET_INIT_RTR IBT_CEP_SET_OPAQUE2 +#define IBT_CEP_SET_RTR_RTS IBT_CEP_SET_OPAQUE3 + +#define IBT_CEP_SET_STATE IBT_CEP_SET_OPAQUE4 +#define IBT_CEP_SET_MTU IBT_CEP_SET_OPAQUE5 + +#define IBT_CEP_SET_TIMEOUT IBT_CEP_SET_OPAQUE6 +#define IBT_CEP_SET_PKEY_IX IBT_CEP_SET_OPAQUE7 +#define IBT_CEP_SET_MIG IBT_CEP_SET_OPAQUE8 + +/* + * ibt_async_code_t + */ +#define IBT_EVENT_PATH_MIGRATED_QP IBT_EVENT_PATH_MIGRATED +#define IBT_EVENT_COM_EST_QP IBT_EVENT_COM_EST +#define IBT_EVENT_COM_EST_EEC IBT_ASYNC_OPAQUE2 +#define IBT_ERROR_CATASTROPHIC_QP IBT_ERROR_CATASTROPHIC_CHAN +#define IBT_ERROR_INVALID_REQUEST_QP IBT_ERROR_INVALID_REQUEST_CHAN +#define IBT_ERROR_ACCESS_VIOLATION_QP IBT_ERROR_ACCESS_VIOLATION_CHAN +#define IBT_ERROR_PATH_MIGRATE_REQ_QP IBT_ERROR_PATH_MIGRATE_REQ +#define IBT_EVENT_EMPTY_QP IBT_EVENT_EMPTY_CHAN + + +/* + * ibt_adds_vect_t + */ +#define av_send_grh av_opaque1 /* flag to specify if GRH is there */ +#define av_dlid av_opaque2 /* destination LID, or router LID */ +#define av_src_path av_opaque3 /* Source path bits */ +#define av_sgid_ix av_opaque4 + +/* + * ibt_wc_t + */ +#define wc_slid wc_opaque1 /* source LID */ +#define wc_pkey_ix wc_opaque2 /* The P_Key index, GSI only */ +#define wc_path_bits wc_opaque4 /* DLID path bits, UD's, RawIPv6 & */ + /* RawEthr only */ + +/* + * ibt_mcg_attr_t + */ +#define mc_mlid mc_opaque1 /* Multicast LID */ + +/* + * ibt_mcg_info_t + */ +#define mc_pkt_lt mc_opaque2 + +/* + * ibt_hca_flags_t + */ +#define IBT_HCA_RESIZE_QP IBT_HCA_RESIZE_CHAN + +/* + * ibt_object_type_t + */ +#define IBT_HDL_QP IBT_HDL_CHANNEL +#define IBT_HDL_AH IBT_HDL_UD_DEST + +/* + * ibt_hca_attr_t + */ +#define hca_max_ah hca_max_ud_dest /* Max address handles in HCA */ +#define hca_ah_max_ci_priv_sz hca_ud_dest_max_ci_priv_sz +#define hca_qp_max_ci_priv_sz hca_chan_max_ci_priv_sz +#define hca_max_qp hca_max_chans /* Max Channels supported by the HCA */ +#define hca_max_qp_sz hca_max_chan_sz /* Max outstanding WRs on any channel */ +#define hca_max_rdma_out_qp hca_max_rdma_out_chan +#define hca_max_rdma_in_qp hca_max_rdma_in_chan +#define hca_max_mcg_qps hca_max_mcg_chans +#define hca_max_qp_per_mcg hca_max_chan_per_mcg + +/* + * ibt_hca_portinfo_t + */ +#define p_base_lid p_opaque1 /* Base LID of the port */ + + +/* Mapping of Verbs defined return status to channel specific. */ +#define IBT_QP_FULL IBT_CHAN_FULL +#define IBT_QP_HDL_INVALID IBT_CHAN_HDL_INVALID +#define IBT_QP_ATTR_RO IBT_CHAN_ATTR_RO +#define IBT_QP_STATE_INVALID IBT_CHAN_STATE_INVALID +#define IBT_QP_SRV_TYPE_INVALID IBT_CHAN_SRV_TYPE_INVALID +#define IBT_QP_IN_USE IBT_CHAN_IN_USE +#define IBT_QP_ATOMICS_NOT_SUPPORTED IBT_CHAN_ATOMICS_NOT_SUPPORTED +#define IBT_QP_OP_TYPE_INVALID IBT_CHAN_OP_TYPE_INVALID +#define IBT_QP_SGL_FORMAT_INVALID IBT_CHAN_SGL_FORMAT_INVALID +#define IBT_QP_SGL_LEN_INVALID IBT_CHAN_SGL_LEN_INVALID +#define IBT_QP_APM_STATE_INVALID IBT_CHAN_APM_STATE_INVALID +#define IBT_QP_SZ_INSUFFICIENT IBT_CHAN_SZ_INSUFFICIENT +#define IBT_QP_SPECIAL_TYPE_INVALID IBT_CHAN_SPECIAL_TYPE_INVALID +#define IBT_WC_LOCAL_QP_OP_ERR IBT_WC_LOCAL_CHAN_OP_ERR +#define IBT_AH_HDL_INVALID IBT_UD_DEST_HDL_INVALID +#define IBT_HCA_MCG_QP_EXCEEDED IBT_HCA_MCG_CHAN_EXCEEDED +#define IBT_MC_MLID_INVALID IBT_MC_OPAQUE +#define IBT_QP_SRQ IBT_CHAN_SRQ +#define IBT_QP_TYPE_2A_MW_BOUND IBT_CHAN_TYPE_2A_MW_BOUND +#define IBT_QP_WQE_SZ_INSUFF IBT_CHAN_WQE_SZ_INSUFF + + +/* + * ibt_cep_path_t + */ +#define cep_timeout cep_cm_opaque1 /* 6 bits of timeout exponent */ + /* Local ACK timeout for RC */ + +/* + * Define an ibt UD Destination struct. This holds all the information + * needed to reach a UD destination. + * + * The ibt_ud_dest_s struct is known by the CI and IBTL. This structure is + * referenced by the CI during UD work request processing. It is defined here + * here so that IBTL does not need to do any data copying during ibt_post_send. + */ +typedef struct ibt_ud_dest_s { + ibt_ah_hdl_t ud_ah; /* Address handle */ + ib_qpn_t ud_dst_qpn; /* Destination QPN */ + ib_qkey_t ud_qkey; /* Q_Key */ + + /* The following fields are IBTL-only, i.e., opaque to the CI */ + struct ibtl_hca_s *ud_dest_opaque1; +} ibt_ud_dest_t; + +/* + * Reserved For Future Use + * RD destination address info. + */ +typedef struct ibt_rd_dest_s { + ibt_ah_hdl_t rd_ah; /* Address handle */ + ib_eecn_t rd_eecn; /* Local EEC Number */ + ib_qpn_t rd_dst_qpn; /* Destination QP Number */ + ib_qkey_t rd_dst_qkey; /* The Q_Key for the destination QP */ +} ibt_rd_dest_t; + +/* + * QP Type. + */ +typedef enum ibt_qp_type_e { + IBT_RC_RQP = 0, + IBT_RD_RQP = 1, /* Reserved For Future Use */ + IBT_UC_RQP = 2, /* Reserved For Future Use */ + IBT_UD_RQP = 3 +} ibt_qp_type_t; + +/* + * Special QP Type. + */ +typedef enum ibt_sqp_type_e { + IBT_SMI_SQP = 0, + IBT_GSI_SQP = 1, + IBT_RAWIP_SQP = 2, /* Reserved For Future Use */ + IBT_RAWETHER_SQP = 3 /* Reserved For Future Use */ +} ibt_sqp_type_t; + +/* + * QP alloc flags. + */ +typedef enum ibt_qp_alloc_flags_e { + IBT_QP_NO_FLAGS = 0, + IBT_QP_USER_MAP = (1 << 0), + IBT_QP_DEFER_ALLOC = (1 << 1), + IBT_QP_USES_SRQ = (1 << 2), + IBT_QP_USES_RSS = (1 << 3), + + /* FC variants of UD */ + IBT_QP_USES_RFCI = (1 << 4), + IBT_QP_USES_FCMD = (1 << 5), + IBT_QP_USES_FEXCH = (1 << 6) +} ibt_qp_alloc_flags_t; + +/* + * QP Alloc Attributes definition. + * + * Contains the QP attributes that are required to create a QP. + */ +typedef struct ibt_qp_alloc_attr_s { + ibt_qp_alloc_flags_t qp_alloc_flags; + ibt_cq_hdl_t qp_scq_hdl; /* SQ CQ IBT Hdl */ + ibt_cq_hdl_t qp_rcq_hdl; /* RQ CQ IBT Hdl */ + ibt_rdd_hdl_t qp_rdd_hdl; /* Reserved */ + ibt_pd_hdl_t qp_pd_hdl; /* PD handle. */ + ibt_chan_sizes_t qp_sizes; /* Queue and SGL */ + ibt_attr_flags_t qp_flags; /* SQ Signaling Type etc */ + ibt_opaque1_t qp_opaque1; + ibt_opaque1_t qp_opaque2; + ibt_srq_hdl_t qp_srq_hdl; /* SRQ ibt hdl */ + ibt_opaque2_t qp_opaque3; + ibt_fc_attr_t qp_fc; +} ibt_qp_alloc_attr_t; + + +/* + * QP query info + */ +/* RC transport specific */ +typedef struct ibt_qp_rc_attr_s { + uint32_t rc_sq_psn:24; /* SQ PSN */ + uint32_t rc_rq_psn:24; /* RQ PSN */ + ib_qpn_t rc_dst_qpn; /* Destination QPN */ + ibt_cep_cmstate_t rc_mig_state; /* Channel Migration State */ + ibt_rnr_retry_cnt_t rc_rnr_retry_cnt; + uint8_t rc_retry_cnt:3; + uint8_t rc_rdma_ra_out; /* max RDMA-R/Atomic sent */ + /* Number of RDMA RD's & */ + /* Atomics outstanding */ + uint8_t rc_rdma_ra_in; /* Incoming RDMA-R/Atomic */ + /* Responder resources for */ + /* handling incoming RDMA */ + /* RD's & Atomics */ + ibt_rnr_nak_time_t rc_min_rnr_nak; /* min RNR-NAK timer */ + ib_mtu_t rc_path_mtu; + ibt_cep_path_t rc_path; /* primary path */ + ibt_cep_path_t rc_alt_path; /* alternate path */ +} ibt_qp_rc_attr_t; + +/* + * Reserved For Future Use. + * UC transport specific + */ +typedef struct ibt_qp_uc_attr_s { + uint32_t uc_sq_psn:24; /* SQ PSN */ + uint32_t uc_rq_psn:24; /* RQ PSN */ + ib_qpn_t uc_dst_qpn; /* destination QPN */ + ibt_cep_cmstate_t uc_mig_state; /* Channel Migration State */ + ib_mtu_t uc_path_mtu; + ibt_cep_path_t uc_path; /* primary path */ + ibt_cep_path_t uc_alt_path; /* alternate path */ +} ibt_qp_uc_attr_t; + +/* + * Reserved For Future Use. + * RD transport specific + */ +typedef struct ibt_qp_rd_attr_s { + ib_qkey_t rd_qkey; + ibt_rnr_nak_time_t rd_min_rnr_nak; /* min RNR-NAK timer */ +} ibt_qp_rd_attr_t; + +/* UD transport specific */ +typedef struct ibt_qp_ud_attr_s { + ib_qkey_t ud_qkey; /* Q_Key */ + uint32_t ud_sq_psn:24; /* SQ PSN */ + uint16_t ud_pkey_ix; /* P_Key Index */ + uint8_t ud_port; /* port */ + ibt_rss_attr_t ud_rss; /* RSS stuff */ + ibt_fc_attr_t ud_fc; +} ibt_qp_ud_attr_t; + +/* + * Common QP Info + */ +typedef struct ibt_qp_info_s { + uint_t qp_sq_sz; /* SQ WQEs */ + uint_t qp_rq_sz; /* RQ WQEs */ + ibt_cep_state_t qp_state; /* QP state */ + ibt_cep_state_t qp_current_state; /* current state for */ + /* modify_qp to RTS state */ + ibt_cep_flags_t qp_flags; /* QP flags */ + ibt_tran_srv_t qp_trans; /* transport service type */ + union { /* transport specific */ + ibt_qp_rc_attr_t rc; + ibt_qp_rd_attr_t rd; /* Reserved For Future Use */ + ibt_qp_uc_attr_t uc; /* Reserved For Future Use */ + ibt_qp_ud_attr_t ud; + } qp_transport; +} ibt_qp_info_t; + +/* + * QP Query Attributes definition. + */ +typedef struct ibt_qp_query_attr_s { + ibt_cq_hdl_t qp_sq_cq; /* SQ CQ */ + ibt_cq_hdl_t qp_rq_cq; /* RQ CQ */ + ibt_rdd_hdl_t qp_rdd_hdl; /* Reserved */ + ib_qpn_t qp_qpn; /* QPN */ + uint_t qp_sq_sgl; /* max SQ SGL */ + uint_t qp_rq_sgl; /* max RQ SGL */ + ibt_qp_info_t qp_info; /* Modifiable attributes */ + ibt_srq_hdl_t qp_srq; /* SRQ hdl or NULL */ + ibt_attr_flags_t qp_flags; + ibt_fexch_query_attr_t qp_query_fexch; /* FEXCH query only set */ +} ibt_qp_query_attr_t; + + +/* + * Reserved For Future Use. + * EEC Info. + */ +typedef struct ibt_eec_info_s { + uint32_t eec_sq_psn:24; /* SQ PSN */ + uint32_t eec_rq_psn:24; /* RQ PSN */ + ib_eecn_t eec_dst_eecn; /* destination EECN */ + ibt_cep_state_t eec_state; /* EEC state */ + ibt_cep_cmstate_t eec_mig; /* channel migration state */ + uint8_t eec_rdma_ra_out; /* RDMA-R/Atomics out */ + uint8_t eec_rdma_ra_in; /* RDMA-R/Atomics in */ + uint8_t eec_retry_cnt:3; + ibt_rnr_retry_cnt_t eec_rnr_retry_cnt; + ib_mtu_t eec_path_mtu; + ibt_cep_path_t eec_prim_path; /* primary path */ + ibt_cep_path_t eec_alt_path; /* alternate path */ +} ibt_eec_info_t; + +/* + * Reserved For Future Use. + * EEC Query Attributes definition. + */ +typedef struct ibt_eec_query_attr_s { + ib_eecn_t eec_eecn; /* The EEC Number */ + ibt_rdd_hdl_t eec_rdd_hdl; + ibt_eec_info_t eec_info; /* Modifiable attributes */ +} ibt_eec_query_attr_t; + + +#define ibt_ah_flags_t ibt_ud_dest_flags_t +#define IBT_AH_NO_FLAGS IBT_UD_DEST_NO_FLAGS +#define IBT_AH_USER_MAP IBT_UD_DEST_USER_MAP +#define IBT_AH_DEFER_ALLOC IBT_UD_DEST_DEFER_ALLOC + + +/* + * ibt_hca_attr_t + */ +#define hca_max_rdd hca_opaque2 /* Max RDDs in HCA */ +#define hca_max_eec hca_opaque3 /* Max EEContexts in HCA */ +#define hca_max_rd_sgl hca_opaque4 /* Max SGL entries per RD WR */ +#define hca_max_rdma_in_ee hca_opaque5 /* Max RDMA Reads/Atomics in */ + /* per EEC with HCA as target */ +#define hca_max_rdma_out_ee hca_opaque6 /* Max RDMA Reads/Atomics out */ + /* per EE by this HCA */ +#define hca_max_ipv6_qp hca_max_ipv6_chan +#define hca_max_ether_qp hca_max_ether_chan +#define hca_eec_max_ci_priv_sz hca_opaque7 +#define hca_rdd_max_ci_priv_sz hca_opaque8 +#define hca_max_map_per_fmr hca_opaque9 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IBTL_CI_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_status.h b/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_status.h new file mode 100644 index 00000000..5afb2a76 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_status.h @@ -0,0 +1,352 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_IBTL_IBTL_STATUS_H +#define _SYS_IB_IBTL_IBTL_STATUS_H + +/* + * ibtl_status.h + * + * Define global IBTL return codes. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Mnemonics + * APM - Automatic Path Migration + * APR - Alternate Path Response + * AH - Address Handle + * CI - Channel Interface (HCA) + * CQ - Completion Queue + * DLID - Destination Local Id + * DS - Data Segment. + * GSI - General Service Interface + * GUID - Globally Unique Identifier + * HCA - Host Channel Adapter. + * L_KEY - Local Key + * LAP - Load Alternative Path + * MC - Multicast + * MCG - Multicast Group + * MR - Memory Region + * MW - Memory Window + * MTU - Maximum Transfer Unit + * NAK - Negative Acknowledge + * P_KEY - Partition Key + * PD - Protection Domain + * PSN - Packet Serial Number + * QP - Queue Pair + * QPN - Queue Pair Number + * R_KEY - Remote Key + * RC - Reliable Connected + * RDMA - Remote DMA + * RNR - Receiver Not Ready + * RQ - Receive Work Queue + * SGL - Scatter/Gather List + * SL - Service Level + * SMI - Subnet Management Interface + * SQ - Send Work Queue + * UC - Unreliable Connected + * UD - Unreliable Datagram + * VA - Virtual Address + * WR - Work Request + * WC - Work Completion + * WRC - Work Request Completion + */ + +/* + * IBTF Immediate status codes. + */ +typedef enum ibt_status_e { + /* + * Generic Status codes. + */ + IBT_SUCCESS = 0, /* Operation Successful */ + IBT_FAILURE = 1, /* Undefined IBTF Failure */ + IBT_NOT_SUPPORTED = 2, /* Feature not supported */ + IBT_ILLEGAL_OP = 3, /* Operation not supported */ + IBT_INVALID_PARAM = 4, /* Invalid argument specified */ + IBT_INSUFF_KERNEL_RESOURCE = 5, /* Not enough Kernel Resource */ + IBT_CM_FAILURE = 6, /* A call to CM returned */ + /* look into detailed error */ + /* code for actual failure */ + IBT_CM_SERVICE_EXISTS = 7, /* For the given parameters */ + /* serviceId already exists */ + IBT_APM_NOT_SUPPORTED = 8, /* Can not satisfy a request */ + /* for APM */ + IBT_IBMF_TIMEOUT = 10, /* IBMF call returned with */ + /* TIMEOUT error code. */ + IBT_INSUFF_DATA = 11, /* Requested number of */ + /* paths/records are not */ + /* available. */ + IBT_NO_HCAS_AVAILABLE = 12, /* No HCAs have attached. */ + IBT_PATH_RECORDS_NOT_FOUND = 13, /* Path records not found. */ + IBT_SERVICE_RECORDS_NOT_FOUND = 14, /* Service records not found. */ + IBT_MCG_RECORDS_NOT_FOUND = 15, /* MCG records not found. */ + IBT_PATH_PKT_LT_TOO_HIGH = 16, /* Path's packet life time */ + /* is too high. */ + IBT_CM_SERVICE_BUSY = 17, /* Service still has bindings */ + IBT_STATIC_RATE_INVALID = 18, /* Invalid Static Rate */ + IBT_SGID_INVALID = 19, /* Invalid SGID or SGID index */ + IBT_NODE_RECORDS_NOT_FOUND = 20, /* NODEInfo records not found */ + IBT_GIDS_NOT_FOUND = 21, /* Companion GIDs not found */ + IBT_INCONSISTENT_AR = 22, /* Address Record contradicts */ + /* an existing Address Record */ + IBT_AR_NOT_REGISTERED = 23, /* Address Record is not */ + /* currently registered */ + IBT_MULTIPLE_AR = 24, /* Multiple records exist for */ + /* what should be a unique */ + /* query result. One of the */ + /* records was returned. */ + IBT_DEST_IP_GID_NOT_FOUND = 25, /* No IP to GID Mapping */ + IBT_SRC_IP_NOT_FOUND = 26, /* SRC IP Endpoint not found */ + IBT_NO_SUCH_OBJECT = 27, /* No such object */ + + /* + * Resource Errors + */ + IBT_INSUFF_RESOURCE = 100, /* Not enough resources */ + IBT_HCA_CQ_EXCEEDED = 101, /* CQ capacity requested */ + /* exceeds HCA capability */ + IBT_HCA_WR_EXCEEDED = 102, /* Requested WRs exceed limit */ + IBT_HCA_SGL_EXCEEDED = 103, /* Requested SGL entries */ + /* exceed HCA max limit */ + IBT_ERR_OPAQUE1 = 104, + IBT_HCA_MCG_CHAN_EXCEEDED = 105, /* Requested Channel exceeds */ + /* HCA multicast groups */ + /* channel limit */ + IBT_HCA_IN_USE = 106, /* HCA already open (in use) */ + IBT_HCA_RESOURCES_NOT_FREED = 107, /* HCA resources still in use */ + IBT_HCA_BUSY_DETACHING = 108, /* HCA detach in progress */ + IBT_HCA_BUSY_CLOSING = 109, /* This client is in the */ + /* process of closing this */ + /* HCA */ + + /* + * Host Channel Adapter (HCA) Attribute Errors. + */ + IBT_HCA_INVALID = 200, /* Invalid HCA GUID */ + IBT_HCA_HDL_INVALID = 201, /* Invalid HCA Handle */ + IBT_HCA_PORT_MTU_EXCEEDED = 202, /* MTU of HCA port exceeded */ + IBT_HCA_PORT_INVALID = 203, /* Invalid HCA physical port */ + IBT_HCA_CNTR_INVALID = 204, /* Invalid Counter Specified */ + IBT_HCA_CNTR_VAL_INVALID = 205, /* Invalid Counter value */ + IBT_HCA_PORT_NOT_ACTIVE = 206, /* Port is down */ + IBT_HCA_SRQ_NOT_SUPPORTED = 207, /* Shared Receive Queue */ + /* not supported */ + IBT_HCA_RESIZE_SRQ_NOT_SUPPORTED = 208, /* SRQ Resize not supported */ + IBT_HCA_PAGE_MODE = 209, /* Not opened in page mode */ + IBT_HCA_BLOCK_MODE = 210, /* HCA does not support Block */ + /* mode or Not opened in */ + /* Block mode */ + IBT_HCA_BMM_NOT_SUPPORTED = 211, /* Base Memory Management */ + /* Extensions not supported */ + IBT_HCA_BQM_NOT_SUPPORTED = 212, /* Base Queue Management */ + /* Extensions not supported */ + IBT_HCA_ZBVA_NOT_SUPPORTED = 213, /* Zero Based Virtual */ + /* Addresses not supported */ + IBT_HCA_MR_MPB_SZ_NOT_SUPPORTED = 214, /* Multiple physical buffer */ + /* sizes per MR not supported */ + IBT_HCA_TYPE_2_MW_NOT_SUPPORTED = 215, + + IBT_HCA_LIF_NOT_SUPPORTED = 216, /* Local Invalidate Fencing */ + /* not supported */ + IBT_HCA_FMR_NOT_SUPPORTED = 217, /* Fast Memory Registration */ + /* not supported */ + /* + * Address errors + */ + IBT_UD_DEST_HDL_INVALID = 300, /* Invalid Address Handle */ + + /* + * Channel Errors + */ + IBT_CHAN_HDL_INVALID = 400, /* Invalid channel Handle */ + IBT_CHAN_ATTR_RO = 401, /* Cannot Change channel */ + /* Attribute */ + IBT_CHAN_STATE_INVALID = 402, /* Invalid channel State */ + IBT_CHAN_SRV_TYPE_INVALID = 403, /* Invalid channel Service */ + /* Type */ + IBT_CHAN_IN_USE = 404, /* SMI/GSI channel in use */ + IBT_CHAN_ATOMICS_NOT_SUPPORTED = 405, /* Atomics not supported */ + IBT_ERR_OPAQUE2 = 406, + IBT_ERR_OPAQUE3 = 407, + IBT_CHAN_OP_TYPE_INVALID = 408, /* Invalid Operation Type */ + IBT_CHAN_SGL_FORMAT_INVALID = 409, /* Invalid SG List format */ + IBT_CHAN_SGL_LEN_INVALID = 410, /* Invalid SG List length */ + IBT_CHAN_APM_STATE_INVALID = 411, /* Invalid Path Migration */ + /* State */ + IBT_CHAN_SPECIAL_TYPE_INVALID = 412, /* Invalid Special channel */ + IBT_CHAN_SZ_INSUFFICIENT = 413, /* The Size of the WQ is too */ + /* small, there are more */ + /* outstanding entries than */ + /* than the requested size. */ + IBT_CHAN_FULL = 414, /* Too many WRs posted */ + IBT_CHAN_SRQ = 415, /* Handle used on a channel */ + /* that is associated with an */ + /* SRQ */ + IBT_CHAN_TYPE_2A_MW_BOUND = 416, /* Channel still has a type */ + /* 2A memory window bound */ + IBT_CHAN_WQE_SZ_INSUFF = 417, /* inline-data/LSO too large */ + + /* + * Completion Queue (CQ) errors + */ + IBT_CQ_HDL_INVALID = 500, /* Invalid CQ Handle */ + IBT_CQ_SZ_INSUFFICIENT = 501, /* The Size of the CQ is too */ + /* small, there are more */ + /* outstanding completions */ + /* than the requested size. */ + IBT_CQ_BUSY = 502, /* WQ(s) Still Reference CQ */ + IBT_CQ_EMPTY = 503, /* Completion Queue Empty */ + IBT_CQ_NOTIFY_TYPE_INVALID = 504, /* Invalid notification type */ + IBT_CQ_INVALID_PRIORITY = 505, /* Invalid CQ Priority */ + IBT_CQ_SCHED_INVALID = 550, /* Invalid CQ Sched Handle */ + IBT_CQ_NO_SCHED_GROUP = 551, /* Schedule group not found */ + IBT_CQ_HID_INVALID = 552, /* CQ Handler ID invalid */ + + /* + * Reserved for future use. + */ + IBT_ERR_OPAQUE4 = 600, + IBT_ERR_OPAQUE5 = 601, + IBT_ERR_OPAQUE6 = 602, + IBT_ERR_OPAQUE7 = 700, + IBT_ERR_OPAQUE8 = 701, + IBT_ERR_OPAQUE9 = 702, + IBT_ERR_OPAQUE10 = 703, + + /* + * Memory operation errors + */ + IBT_MR_VA_INVALID = 800, /* Invalid Virtual Address */ + IBT_MR_LEN_INVALID = 801, /* Invalid Memory Length */ + IBT_MR_PHYSBUF_INVALID = 802, /* Invalid Physical Buffer */ + /* List */ + IBT_MR_OFFSET_INVALID = 803, /* Invalid Memory Offset */ + IBT_MR_LKEY_INVALID = 804, /* Invalid Memory L_KEY */ + IBT_MR_RKEY_INVALID = 805, /* Invalid Memory R_KEY */ + IBT_MR_HDL_INVALID = 806, /* Invalid Memory Region */ + /* Handle */ + IBT_MR_ACCESS_REQ_INVALID = 807, /* Invalid Access Control */ + /* Specifier */ + IBT_MR_IN_USE = 808, /* Mem region in Use */ + IBT_MW_HDL_INVALID = 809, /* Invalid Memory Window */ + /* Handle */ + IBT_MW_TYPE_INVALID = 810, + IBT_MA_HDL_INVALID = 811, /* Invalid Memory Area Hdl */ + IBT_SGL_TOO_SMALL = 812, + IBT_MI_HDL_INVALID = 813, + + /* + * Multicast errors + */ + IBT_MC_OPAQUE = 900, /* Invalid MLID */ + IBT_MC_MGID_INVALID = 901, /* Invalid MGID */ + IBT_MC_GROUP_INVALID = 902, /* Invalid MC Group */ + + /* + * Partition table errors. + */ + IBT_PKEY_IX_ILLEGAL = 1000, /* P_Key index Out of range */ + IBT_PKEY_IX_INVALID = 1001, /* P_Key index specifies */ + /* invalid entry in table */ + /* + * Protection Domain errors + */ + IBT_PD_HDL_INVALID = 1100, /* Invalid protection domain */ + IBT_PD_IN_USE = 1101, /* Protection Domain in Use */ + IBT_MEM_ALLOC_HDL_INVALID = 1102, /* Invalid MEM handle */ + + /* + * Shared Receive Queue errors + */ + IBT_SRQ_HDL_INVALID = 1200, /* Invalid SRQ Handle */ + IBT_SRQ_ERROR_STATE = 1201, /* SRQ in Error State */ + IBT_SRQ_LIMIT_EXCEEDED = 1202, /* SRQ Limit exceeds max SRQ */ + /* size */ + IBT_SRQ_SZ_INSUFFICIENT = 1203, /* The Size of the WQ is too */ + /* small, there are more */ + /* outstanding entries than */ + IBT_SRQ_IN_USE = 1204, /* SRQ Still has QPs */ + /* associated with it */ + /* + * FMR Errors + */ + IBT_FMR_POOL_HDL_INVALID = 1300, /* Invalid FMR Pool handle */ + IBT_FMR_POOL_IN_USE = 1301, /* FMR Pool in use. */ + IBT_PBL_TOO_SMALL = 1302 +} ibt_status_t; + +/* + * Work Request Completion Return Status. + * + * Refer InfiniBand Architecture Release Volume 1: + * Section 11.6.2 Completion Return Status. + * + * NOTE: this was converted from an enum to a uint8_t to save space. + */ +typedef uint8_t ibt_wc_status_t; +#define IBT_WC_SUCCESS 0 /* WR Completed Successfully */ +#define IBT_WC_LOCAL_LEN_ERR 10 /* Data in WR posted to local */ + /* queue too big */ +#define IBT_WC_LOCAL_CHAN_OP_ERR 11 /* Internal consistency error */ +#define IBT_WC_LOCAL_PROTECT_ERR 13 /* Memory Region violation */ + /* for posted WR */ +#define IBT_WC_WR_FLUSHED_ERR 14 /* WR was in process when the */ + /* chan went to error state */ +#define IBT_WC_MEM_MGT_OP_ERR 15 /* bind plus 1.2 mem ext */ +#define IBT_WC_MEM_WIN_BIND_ERR IBT_WC_MEM_MGT_OP_ERR + + /* + * Errors that are only reported for Reliable Queue Pairs. + */ +#define IBT_WC_BAD_RESPONSE_ERR 20 /* An unexpected transport */ + /* layer opcode was returned */ + /* by the responder */ +#define IBT_WC_LOCAL_ACCESS_ERR 21 /* A protection error */ + /* occurred on a local data */ + /* buffer during the */ + /* processing of a RDMA Write */ + /* with Immediate Data */ + /* operation sent from the */ + /* remote node */ + /* data buffer */ +#define IBT_WC_REMOTE_INVALID_REQ_ERR 22 /* Responder detected invalid */ + /* message on the channel */ +#define IBT_WC_REMOTE_ACCESS_ERR 23 /* Protection Error on remote */ + /* data buffer */ +#define IBT_WC_REMOTE_OP_ERR 24 /* Operation could not be */ + /* completed by the responder */ +#define IBT_WC_TRANS_TIMEOUT_ERR 25 /* Local transport retry */ + /* counter exceeded */ +#define IBT_WC_RNR_NAK_TIMEOUT_ERR 26 /* RNR NAK retry counter */ + /* exceeded */ +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IBTL_STATUS_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_types.h b/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_types.h new file mode 100644 index 00000000..67d890c8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/ibtl_types.h @@ -0,0 +1,1772 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_IBTL_IBTL_TYPES_H +#define _SYS_IB_IBTL_IBTL_TYPES_H + +/* + * ibtl_types.h + * + * All common IBTL defined types. These are common data types + * that are shared by the IBTI and IBCI interfaces, it is only included + * by ibti.h and ibci.h + */ +#include +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Endian Macros + * h2b - host endian to big endian protocol + * b2h - big endian protocol to host endian + * h2l - host endian to little endian protocol + * l2h - little endian protocol to host endian + */ +#if defined(_LITTLE_ENDIAN) +#define h2b16(x) (htons(x)) +#define h2b32(x) (htonl(x)) +#define h2b64(x) (htonll(x)) +#define b2h16(x) (ntohs(x)) +#define b2h32(x) (ntohl(x)) +#define b2h64(x) (htonll(x)) + +#define h2l16(x) (x) +#define h2l32(x) (x) +#define h2l64(x) (x) +#define l2h16(x) (x) +#define l2h32(x) (x) +#define l2h64(x) (x) + +#elif defined(_BIG_ENDIAN) +#define h2b16(x) (x) +#define h2b32(x) (x) +#define h2b64(x) (x) +#define b2h16(x) (x) +#define b2h32(x) (x) +#define b2h64(x) (x) + +#define h2l16(x) (ddi_swap16(x)) +#define h2l32(x) (ddi_swap32(x)) +#define h2l64(x) (ddi_swap64(x)) +#define l2h16(x) (ddi_swap16(x)) +#define l2h32(x) (ddi_swap32(x)) +#define l2h64(x) (ddi_swap64(x)) + +#else +#error "what endian is this machine?" +#endif + +/* + * Define Internal IBTL handles + */ +typedef struct ibtl_clnt_s *ibt_clnt_hdl_t; /* ibt_attach() */ +typedef struct ibtl_hca_s *ibt_hca_hdl_t; /* ibt_open_hca() */ +typedef struct ibtl_channel_s *ibt_channel_hdl_t; /* alloc_rc|ud_channel() */ +typedef struct ibtl_srq_s *ibt_srq_hdl_t; /* ibt_alloc_srq() */ +typedef struct ibtl_cq_s *ibt_cq_hdl_t; /* ibt_alloc_cq() */ +typedef struct ibcm_svc_info_s *ibt_srv_hdl_t; /* ibt_register_service() */ +typedef struct ibcm_svc_bind_s *ibt_sbind_hdl_t; /* ibt_bind_service() */ + +typedef struct ibc_fmr_pool_s *ibt_fmr_pool_hdl_t; /* ibt_create_fmr_pool() */ +typedef struct ibc_ma_s *ibt_ma_hdl_t; /* ibt_map_mem_area() */ +typedef struct ibc_pd_s *ibt_pd_hdl_t; /* ibt_alloc_pd() */ +typedef struct ibc_sched_s *ibt_sched_hdl_t; /* ibt_alloc_cq_sched() */ +typedef struct ibc_mr_s *ibt_mr_hdl_t; /* ibt_register_mr() */ +typedef struct ibc_mw_s *ibt_mw_hdl_t; /* ibt_alloc_mw() */ +typedef struct ibt_ud_dest_s *ibt_ud_dest_hdl_t; /* UD dest handle */ +typedef struct ibc_ah_s *ibt_ah_hdl_t; /* ibt_alloc_ah() */ +typedef struct ibtl_eec_s *ibt_eec_hdl_t; +typedef struct ibt_rd_dest_s *ibt_rd_dest_hdl_t; /* Reserved for */ + /* Future use */ +typedef struct ibc_mem_alloc_s *ibt_mem_alloc_hdl_t; /* ibt_alloc_io_mem() */ +typedef struct ibc_mi_s *ibt_mi_hdl_t; /* ibt_map_mem_iov() */ + +/* + * Some General Types. + */ +typedef uint32_t ibt_lkey_t; /* L_Key */ +typedef uint32_t ibt_rkey_t; /* R_Key */ +typedef uint64_t ibt_wrid_t; /* Client assigned WR ID */ +typedef uint32_t ibt_immed_t; /* WR Immediate Data */ +typedef uint64_t ibt_atom_arg_t; /* WR Atomic Operation arg */ +typedef uint_t ibt_cq_handler_id_t; /* Event handler ID */ + +/* + * IBT selector type, used when looking up/requesting either an + * MTU, Pkt lifetime, or Static rate. + * The interpretation of IBT_BEST depends on the attribute being selected. + */ +typedef enum ibt_selector_e { + IBT_GT = 0, /* Greater than */ + IBT_LT = 1, /* Less than */ + IBT_EQU = 2, /* Equal to */ + IBT_BEST = 3 /* Best */ +} ibt_selector_t; + + +/* + * Static rate definitions. + */ +typedef enum ibt_srate_e { + IBT_SRATE_NOT_SPECIFIED = 0, + IBT_SRATE_2 = 2, /* 1X SDR i.e 2.5 Gbps */ + IBT_SRATE_10 = 3, /* 4X SDR or 1X QDR i.e 10 Gbps */ + IBT_SRATE_30 = 4, /* 12X SDR i.e 30 Gbps */ + + IBT_SRATE_5 = 5, /* 1X DDR i.e 5 Gbps */ + IBT_SRATE_20 = 6, /* 4X DDR or 8X SDR i.e 20 Gbps */ + IBT_SRATE_40 = 7, /* 8X DDR or 4X QDR i.e 40 Gbps */ + + IBT_SRATE_60 = 8, /* 12X DDR i.e 60 Gbps */ + IBT_SRATE_80 = 9, /* 8X QDR i.e 80 Gbps */ + IBT_SRATE_120 = 10 /* 12X QDR i.e 120 Gbps */ +} ibt_srate_t; + +/* retain old definition to be compatible with older bits. */ +#define IBT_SRATE_1X IBT_SRATE_2 +#define IBT_SRATE_4X IBT_SRATE_10 +#define IBT_SRATE_12X IBT_SRATE_30 + +/* + * Static rate request type. + */ +typedef struct ibt_srate_req_s { + ibt_srate_t r_srate; /* Requested srate */ + ibt_selector_t r_selector; /* Qualifier for r_srate */ +} ibt_srate_req_t; + +/* + * Packet Life Time Request Type. + */ +typedef struct ibt_pkt_lt_req_s { + clock_t p_pkt_lt; /* Requested Packet Life Time */ + ibt_selector_t p_selector; /* Qualifier for p_pkt_lt */ +} ibt_pkt_lt_req_t; + +/* + * Queue size struct. + */ +typedef struct ibt_queue_sizes_s { + uint_t qs_sq; /* SendQ size. */ + uint_t qs_rq; /* RecvQ size. */ +} ibt_queue_sizes_t; + +/* + * Channel sizes struct, used by functions that allocate/query RC or UD + * channels. + */ +typedef struct ibt_chan_sizes_s { + uint_t cs_sq; /* SendQ size. */ + uint_t cs_rq; /* ReceiveQ size. */ + uint_t cs_sq_sgl; /* Max SGL elements in a SQ WR. */ + uint_t cs_rq_sgl; /* Max SGL elements in a RQ Wr. */ + uint_t cs_inline; /* max inline payload size */ +} ibt_chan_sizes_t; + +/* + * Shared Queue size struct. + */ +typedef struct ibt_srq_sizes_s { + uint_t srq_wr_sz; + uint_t srq_sgl_sz; +} ibt_srq_sizes_t; + +/* + * SRQ Modify Flags + */ +typedef enum ibt_srq_modify_flags_e { + IBT_SRQ_SET_NOTHING = 0, + IBT_SRQ_SET_SIZE = (1 << 1), + IBT_SRQ_SET_LIMIT = (1 << 2) +} ibt_srq_modify_flags_t; + + +/* + * Execution flags, indicates if the function should block or not. + * Note: in some cases, e.g., a NULL rc_cm_handler, IBT_NONBLOCKING + * will not have an effect, and the thread will block. + * IBT_NOCALLBACKS is valid for ibt_close_rc_channel only. + */ +typedef enum ibt_execution_mode_e { + IBT_BLOCKING = 0, /* Block */ + IBT_NONBLOCKING = 1, /* Return as soon as possible */ + IBT_NOCALLBACKS = 2 /* cm_handler is not invoked after */ + /* ibt_close_rc_channel returns */ +} ibt_execution_mode_t; + +/* + * Memory window alloc flags + */ +typedef enum ibt_mw_flags_e { + IBT_MW_SLEEP = 0, /* Can block */ + IBT_MW_NOSLEEP = (1 << 0), /* Can't block */ + IBT_MW_USER_MAP = (1 << 1), + IBT_MW_DEFER_ALLOC = (1 << 2), + IBT_MW_TYPE_1 = (1 << 3), + IBT_MW_TYPE_2 = (1 << 4) +} ibt_mw_flags_t; + +/* + * PD alloc flags + */ +typedef enum ibt_pd_flags_e { + IBT_PD_NO_FLAGS = 0, + IBT_PD_USER_MAP = (1 << 0), + IBT_PD_DEFER_ALLOC = (1 << 1) +} ibt_pd_flags_t; + +/* + * UD Dest alloc flags + */ +typedef enum ibt_ud_dest_flags_e { + IBT_UD_DEST_NO_FLAGS = 0, + IBT_UD_DEST_USER_MAP = (1 << 0), + IBT_UD_DEST_DEFER_ALLOC = (1 << 1) +} ibt_ud_dest_flags_t; + +/* + * SRQ alloc flags + */ +typedef enum ibt_srq_flags_e { + IBT_SRQ_NO_FLAGS = 0, + IBT_SRQ_USER_MAP = (1 << 0), + IBT_SRQ_DEFER_ALLOC = (1 << 1) +} ibt_srq_flags_t; + +/* + * ibt_alloc_lkey() alloc flags + */ +typedef enum ibt_lkey_flags_e { + IBT_KEY_SLEEP = 0, + IBT_KEY_NOSLEEP = (1 << 0), + IBT_KEY_REMOTE = (1 << 1) +} ibt_lkey_flags_t; + +/* + * RNR NAK retry counts. + */ +typedef enum ibt_rnr_retry_cnt_e { + IBT_RNR_NO_RETRY = 0x0, /* Don't retry, fail on first timeout */ + IBT_RNR_RETRY_1 = 0x1, /* Retry once */ + IBT_RNR_RETRY_2 = 0x2, /* Retry twice */ + IBT_RNR_RETRY_3 = 0x3, /* Retry three times */ + IBT_RNR_RETRY_4 = 0x4, /* Retry four times */ + IBT_RNR_RETRY_5 = 0x5, /* Retry five times */ + IBT_RNR_RETRY_6 = 0x6, /* Retry six times */ + IBT_RNR_INFINITE_RETRY = 0x7 /* Retry forever */ +} ibt_rnr_retry_cnt_t; + +/* + * Valid values for RNR NAK timer fields, part of a channel's context. + */ +typedef enum ibt_rnr_nak_time_e { + IBT_RNR_NAK_655ms = 0x0, + IBT_RNR_NAK_10us = 0x1, + IBT_RNR_NAK_20us = 0x2, + IBT_RNR_NAK_30us = 0x3, + IBT_RNR_NAK_40us = 0x4, + IBT_RNR_NAK_60us = 0x5, + IBT_RNR_NAK_80us = 0x6, + IBT_RNR_NAK_120us = 0x7, + IBT_RNR_NAK_160us = 0x8, + IBT_RNR_NAK_240us = 0x9, + IBT_RNR_NAK_320us = 0xA, + IBT_RNR_NAK_480us = 0xB, + IBT_RNR_NAK_640us = 0xC, + IBT_RNR_NAK_960us = 0xD, + IBT_RNR_NAK_1280us = 0xE, + IBT_RNR_NAK_1920us = 0xF, + IBT_RNR_NAK_2560us = 0x10, + IBT_RNR_NAK_3840us = 0x11, + IBT_RNR_NAK_5120us = 0x12, + IBT_RNR_NAK_7680us = 0x13, + IBT_RNR_NAK_10ms = 0x14, + IBT_RNR_NAK_15ms = 0x15, + IBT_RNR_NAK_20ms = 0x16, + IBT_RNR_NAK_31ms = 0x17, + IBT_RNR_NAK_41ms = 0x18, + IBT_RNR_NAK_61ms = 0x19, + IBT_RNR_NAK_82ms = 0x1A, + IBT_RNR_NAK_123ms = 0x1B, + IBT_RNR_NAK_164ms = 0x1C, + IBT_RNR_NAK_246ms = 0x1D, + IBT_RNR_NAK_328ms = 0x1E, + IBT_RNR_NAK_492ms = 0x1F +} ibt_rnr_nak_time_t; + +/* + * The definition of HCA capabilities etc as a bitfield. + */ +typedef enum ibt_hca_flags_e { + IBT_HCA_NO_FLAGS = 0, + + IBT_HCA_RD = 1 << 0, + IBT_HCA_UD_MULTICAST = 1 << 1, + IBT_HCA_RAW_MULTICAST = 1 << 2, + + IBT_HCA_ATOMICS_HCA = 1 << 3, + IBT_HCA_ATOMICS_GLOBAL = 1 << 4, + + IBT_HCA_RESIZE_CHAN = 1 << 5, /* Is resize supported? */ + IBT_HCA_AUTO_PATH_MIG = 1 << 6, /* Is APM supported? */ + IBT_HCA_SQD_SQD_PORT = 1 << 7, /* Can change physical port */ + /* on transit from SQD to SQD */ + IBT_HCA_PKEY_CNTR = 1 << 8, + IBT_HCA_QKEY_CNTR = 1 << 9, + IBT_HCA_AH_PORT_CHECK = 1 << 10, /* HCA checks AH port match */ + /* in UD WRs */ + IBT_HCA_PORT_UP = 1 << 11, /* PortActive event supported */ + IBT_HCA_INIT_TYPE = 1 << 12, /* InitType supported */ + IBT_HCA_SI_GUID = 1 << 13, /* System Image GUID */ + /* supported */ + IBT_HCA_SHUTDOWN_PORT = 1 << 14, /* ShutdownPort supported */ + IBT_HCA_RNR_NAK = 1 << 15, /* RNR-NAK supported for RC */ + IBT_HCA_CURRENT_QP_STATE = 1 << 16, /* Does modify_qp support */ + /* checking of current state? */ + IBT_HCA_SRQ = 1 << 17, /* Shared Receive Queue (RC) */ + IBT_HCA_RC_SRQ = IBT_HCA_SRQ, + IBT_HCA_RESIZE_SRQ = 1 << 18, /* Is resize SRQ supported? */ + IBT_HCA_UD_SRQ = 1 << 19, /* UD with SRQ */ + + IBT_HCA_MULT_PAGE_SZ_MR = 1 << 20, /* Support of multiple page */ + /* sizes per memory region? */ + IBT_HCA_BLOCK_LIST = 1 << 21, /* Block list physical buffer */ + /* lists supported? */ + IBT_HCA_ZERO_BASED_VA = 1 << 22, /* Zero Based Virtual */ + /* Addresses supported? */ + IBT_HCA_LOCAL_INVAL_FENCE = 1 << 23, /* Local invalidate fencing? */ + IBT_HCA_BASE_QUEUE_MGT = 1 << 24, /* Base Queue Mgt supported? */ + IBT_HCA_CKSUM_FULL = 1 << 25, /* Checksum offload supported */ + IBT_HCA_MEM_WIN_TYPE_2B = 1 << 26, /* Type 2B memory windows */ + IBT_HCA_PHYS_BUF_BLOCK = 1 << 27, /* Block mode phys buf lists */ + IBT_HCA_FMR = 1 << 28, /* FMR Support */ + IBT_HCA_WQE_SIZE_INFO = 1 << 29, /* detailed WQE size info */ + IBT_HCA_SQD_STATE = 1 << 30 /* SQD QP state */ +} ibt_hca_flags_t; + +typedef enum ibt_hca_flags2_e { + IBT_HCA2_NO_FLAGS = 0, + + IBT_HCA2_UC = 1 << 1, /* Unreliable Connected */ + IBT_HCA2_UC_SRQ = 1 << 2, /* UC with SRQ */ + IBT_HCA2_RES_LKEY = 1 << 3, /* Reserved L_Key */ + IBT_HCA2_PORT_CHANGE = 1 << 4, /* Port Change event */ + IBT_HCA2_IP_CLASS = 1 << 5, /* IP Classification flags */ + IBT_HCA2_RSS_TPL_ALG = 1 << 6, /* RSS: Toeplitz algorithm */ + IBT_HCA2_RSS_XOR_ALG = 1 << 7, /* RSS: XOR algorithm */ + IBT_HCA2_XRC = 1 << 8, /* Extended RC (XRC) */ + IBT_HCA2_XRC_SRQ_RESIZE = 1 << 9, /* resize XRC SRQ */ + IBT_HCA2_MEM_MGT_EXT = 1 << 10, /* FMR-WR, send-inv, local-inv */ + IBT_HCA2_DMA_MR = 1 << 11, /* DMA MR */ + IBT_HCA2_FC = 1 << 12 /* FCoIB or FCoE offload */ +} ibt_hca_flags2_t; + +/* + * The definition of HCA page size capabilities as a bitfield + */ +typedef enum ibt_page_sizes_e { + IBT_PAGE_4K = 0x1 << 2, + IBT_PAGE_8K = 0x1 << 3, + IBT_PAGE_16K = 0x1 << 4, + IBT_PAGE_32K = 0x1 << 5, + IBT_PAGE_64K = 0x1 << 6, + IBT_PAGE_128K = 0x1 << 7, + IBT_PAGE_256K = 0x1 << 8, + IBT_PAGE_512K = 0x1 << 9, + IBT_PAGE_1M = 0x1 << 10, + IBT_PAGE_2M = 0x1 << 11, + IBT_PAGE_4M = 0x1 << 12, + IBT_PAGE_8M = 0x1 << 13, + IBT_PAGE_16M = 0x1 << 14, + IBT_PAGE_32M = 0x1 << 15, + IBT_PAGE_64M = 0x1 << 16, + IBT_PAGE_128M = 0x1 << 17, + IBT_PAGE_256M = 0x1 << 18, + IBT_PAGE_512M = 0x1 << 19, + IBT_PAGE_1G = 0x1 << 20, + IBT_PAGE_2G = 0x1 << 21, + IBT_PAGE_4G = 0x1 << 22, + IBT_PAGE_8G = 0x1 << 23, + IBT_PAGE_16G = 0x1 << 24 +} ibt_page_sizes_t; + +/* + * Memory Window Type. + */ +typedef enum ibt_mem_win_type_e { + IBT_MEM_WIN_TYPE_NOT_DEFINED = 0, + IBT_MEM_WIN_TYPE_1 = (1 << 0), + IBT_MEM_WIN_TYPE_2 = (1 << 1) +} ibt_mem_win_type_t; + +/* + * HCA attributes. + * Contains all HCA static attributes. + */ +typedef struct ibt_hca_attr_s { + ibt_hca_flags_t hca_flags; /* HCA capabilities etc */ + ibt_hca_flags2_t hca_flags2; + + /* device/version inconsistency w/ NodeInfo and IOControllerProfile */ + uint32_t hca_vendor_id:24; /* 24 bit Vendor ID */ + uint16_t hca_device_id; + uint32_t hca_version_id; + + uint_t hca_max_chans; /* Max Chans supported */ + uint_t hca_max_chan_sz; /* Max outstanding WRs on any */ + /* channel */ + + uint_t hca_max_sgl; /* Max SGL entries per WR */ + + uint_t hca_max_cq; /* Max num of CQs supported */ + uint_t hca_max_cq_sz; /* Max capacity of each CQ */ + + ibt_page_sizes_t hca_page_sz; /* Bit mask of page sizes */ + + uint_t hca_max_memr; /* Max num of HCA mem regions */ + ib_memlen_t hca_max_memr_len; /* Largest block, in bytes of */ + /* mem that can be registered */ + uint_t hca_max_mem_win; /* Max Memory windows in HCA */ + + uint_t hca_max_rsc; /* Max Responder Resources of */ + /* this HCA for RDMAR/Atomics */ + /* with this HCA as target. */ + uint8_t hca_max_rdma_in_chan; /* Max RDMAR/Atomics in per */ + /* chan this HCA as target. */ + uint8_t hca_max_rdma_out_chan; /* Max RDMA Reads/Atomics out */ + /* per channel by this HCA */ + uint_t hca_max_ipv6_chan; /* Max IPV6 channels in HCA */ + uint_t hca_max_ether_chan; /* Max Ether channels in HCA */ + + uint_t hca_max_mcg_chans; /* Max number of channels */ + /* that can join multicast */ + /* groups */ + uint_t hca_max_mcg; /* Max multicast groups */ + uint_t hca_max_chan_per_mcg; /* Max number of channels per */ + /* Multicast group in HCA */ + + uint16_t hca_max_partitions; /* Max partitions in HCA */ + uint8_t hca_nports; /* Number of physical ports */ + ib_guid_t hca_node_guid; /* Node GUID */ + + ib_time_t hca_local_ack_delay; + + uint_t hca_max_port_sgid_tbl_sz; + uint16_t hca_max_port_pkey_tbl_sz; + uint_t hca_max_pd; /* Max# of Protection Domains */ + ib_guid_t hca_si_guid; /* Optional System Image GUID */ + uint_t hca_hca_max_ci_priv_sz; + uint_t hca_chan_max_ci_priv_sz; + uint_t hca_cq_max_ci_priv_sz; + uint_t hca_pd_max_ci_priv_sz; + uint_t hca_mr_max_ci_priv_sz; + uint_t hca_mw_max_ci_priv_sz; + uint_t hca_ud_dest_max_ci_priv_sz; + uint_t hca_cq_sched_max_ci_priv_sz; + uint_t hca_max_ud_dest; + uint_t hca_opaque2; + uint_t hca_opaque3; + uint_t hca_opaque4; + uint8_t hca_opaque5; + uint8_t hca_opaque6; + uint8_t hca_rss_max_log2_table; /* max RSS log2 table size */ + uint_t hca_opaque7; + uint_t hca_opaque8; + uint_t hca_max_srqs; /* Max SRQs supported */ + uint_t hca_max_srqs_sz; /* Max outstanding WRs on any */ + /* SRQ */ + uint_t hca_max_srq_sgl; /* Max SGL entries per SRQ WR */ + uint_t hca_max_phys_buf_list_sz; + size_t hca_block_sz_lo; /* Range of block sizes */ + size_t hca_block_sz_hi; /* supported by the HCA */ + uint_t hca_max_cq_handlers; + ibt_lkey_t hca_reserved_lkey; /* Reserved L_Key value */ + uint_t hca_max_fmrs; /* Max FMR Supported */ + uint_t hca_opaque9; + + uint_t hca_max_lso_size; + uint_t hca_max_lso_hdr_size; + uint_t hca_max_inline_size; + + uint_t hca_max_cq_mod_count; /* CQ notify moderation */ + uint_t hca_max_cq_mod_usec; + + uint32_t hca_fw_major_version; /* firmware version */ + uint16_t hca_fw_minor_version; + uint16_t hca_fw_micro_version; + + uint_t hca_max_xrc_domains; /* XRC items */ + uint_t hca_max_xrc_srqs; + uint_t hca_max_xrc_srq_size; + uint_t hca_max_xrc_srq_sgl; + + /* detailed WQE size info */ + uint_t hca_ud_send_inline_sz; /* inline size in bytes */ + uint_t hca_conn_send_inline_sz; + uint_t hca_conn_rdmaw_inline_overhead; + uint_t hca_recv_sgl_sz; /* detailed SGL sizes */ + uint_t hca_ud_send_sgl_sz; + uint_t hca_conn_send_sgl_sz; + uint_t hca_conn_rdma_read_sgl_sz; + uint_t hca_conn_rdma_write_sgl_sz; + uint_t hca_conn_rdma_sgl_overhead; + + /* FC Support */ + uint8_t hca_rfci_max_log2_qp; /* max log2 RFCI QPs */ + uint8_t hca_fexch_max_log2_qp; /* max log2 FEXCH QPs */ + uint8_t hca_fexch_max_log2_mem; /* max log2 mem per FEXCH */ + + dev_info_t *hca_dip; /* HCA dev_info */ +} ibt_hca_attr_t; + +/* + * HCA Port link states. + */ +typedef enum ibt_port_state_e { + IBT_PORT_DOWN = 1, + IBT_PORT_INIT, + IBT_PORT_ARM, + IBT_PORT_ACTIVE +} ibt_port_state_t; + +/* + * HCA Port capabilities as a bitfield. + */ +typedef enum ibt_port_caps_e { + IBT_PORT_CAP_NO_FLAGS = 0, + IBT_PORT_CAP_SM = 1 << 0, /* SM port */ + IBT_PORT_CAP_SM_DISABLED = 1 << 1, + IBT_PORT_CAP_SNMP_TUNNEL = 1 << 2, /* SNMP Tunneling */ + IBT_PORT_CAP_DM = 1 << 3, /* DM supported */ + IBT_PORT_CAP_VENDOR = 1 << 4, /* Vendor Class */ + IBT_PORT_CAP_CLNT_REREG = 1 << 5 /* Client Rereg */ +} ibt_port_caps_t; + + +/* LinkWidth fields from PortInfo */ +typedef uint8_t ib_link_width_t; + +/* + * When reading LinkWidthSupported and LinkWidthEnabled, these + * values will be OR-ed together. See IB spec 14.2.5.6 for allowed + * combinations. For LinkWidthActive, only one will be returned. + */ +#define IBT_LINK_WIDTH_1X (1) +#define IBT_LINK_WIDTH_4X (2) +#define IBT_LINK_WIDTH_8X (4) +#define IBT_LINK_WIDTH_12X (8) + +/* LinkSpeed fields from PortInfo */ +typedef uint8_t ib_link_speed_t; + +/* + * When reading LinkSpeedSupported and LinkSpeedEnabled, these + * values will be OR-ed together. See IB spec 14.2.5.6 for allowed + * combinations. For LinkSpeedActive, only one will be returned. + */ +#define IBT_LINK_SPEED_SDR (1) +#define IBT_LINK_SPEED_DDR (2) +#define IBT_LINK_SPEED_QDR (4) + +/* PortPhysicalState field from PortInfo */ +typedef uint8_t ib_port_phys_state_t; + +#define IBT_PORT_PHYS_STATE_SLEEP (1) +#define IBT_PORT_PHYS_STATE_POLLING (2) +#define IBT_PORT_PHYS_STATE_DISABLED (3) +#define IBT_PORT_PHYS_STATE_TRAINING (4) +#define IBT_PORT_PHYS_STATE_UP (5) +#define IBT_PORT_PHYS_STATE_RECOVERY (6) +#define IBT_PORT_PHYS_STATE_TEST (7) + +/* + * HCA port attributes structure definition. The number of ports per HCA + * can be found from the "ibt_hca_attr_t" structure. + * + * p_pkey_tbl is a pointer to an array of ib_pkey_t, members are + * accessed as: + * hca_portinfo->p_pkey_tbl[i] + * + * Where 0 <= i < hca_portinfo.p_pkey_tbl_sz + * + * Similarly p_sgid_tbl is a pointer to an array of ib_gid_t. + * + * The Query Port function - ibt_query_hca_ports() allocates the memory + * required for the ibt_hca_portinfo_t struct as well as the memory + * required for the SGID and P_Key tables. The memory is freed by calling + * ibt_free_portinfo(). + */ +typedef struct ibt_hca_portinfo_s { + ib_lid_t p_opaque1; /* Base LID of port */ + ib_qkey_cntr_t p_qkey_violations; /* Bad Q_Key cnt */ + ib_pkey_cntr_t p_pkey_violations; /* Optional bad P_Key cnt */ + uint8_t p_sm_sl:4; /* SM Service level */ + ib_port_phys_state_t p_phys_state; + ib_lid_t p_sm_lid; /* SM LID */ + ibt_port_state_t p_linkstate; /* Port state */ + uint8_t p_port_num; + ib_link_width_t p_width_supported; + ib_link_width_t p_width_enabled; + ib_link_width_t p_width_active; + ib_mtu_t p_mtu; /* Max transfer unit - pkt */ + uint8_t p_lmc:3; /* Local mask control */ + ib_link_speed_t p_speed_supported; + ib_link_speed_t p_speed_enabled; + ib_link_speed_t p_speed_active; + ib_gid_t *p_sgid_tbl; /* SGID Table */ + uint_t p_sgid_tbl_sz; /* Size of SGID table */ + uint16_t p_pkey_tbl_sz; /* Size of P_Key table */ + uint16_t p_def_pkey_ix; /* default pkey index for TI */ + ib_pkey_t *p_pkey_tbl; /* P_Key table */ + uint8_t p_max_vl; /* Max num of virtual lanes */ + uint8_t p_init_type_reply; /* Optional InitTypeReply */ + ib_time_t p_subnet_timeout; /* Max Subnet Timeout */ + ibt_port_caps_t p_capabilities; /* Port Capabilities */ + uint32_t p_msg_sz; /* Max message size */ +} ibt_hca_portinfo_t; + +/* + * Modify HCA port attributes flags, specifies which HCA port + * attributes to modify. + */ +typedef enum ibt_port_modify_flags_e { + IBT_PORT_NO_FLAGS = 0, + + IBT_PORT_RESET_QKEY = 1 << 0, /* Reset Q_Key violation */ + /* counter */ + IBT_PORT_RESET_SM = 1 << 1, /* SM */ + IBT_PORT_SET_SM = 1 << 2, + IBT_PORT_RESET_SNMP = 1 << 3, /* SNMP Tunneling */ + IBT_PORT_SET_SNMP = 1 << 4, + IBT_PORT_RESET_DEVMGT = 1 << 5, /* Device Management */ + IBT_PORT_SET_DEVMGT = 1 << 6, + IBT_PORT_RESET_VENDOR = 1 << 7, /* Vendor Class */ + IBT_PORT_SET_VENDOR = 1 << 8, + IBT_PORT_SHUTDOWN = 1 << 9, /* Shut down the port */ + IBT_PORT_SET_INIT_TYPE = 1 << 10 /* InitTypeReply value */ +} ibt_port_modify_flags_t; + +/* + * Modify HCA port InitType bit definitions, applicable only if + * IBT_PORT_SET_INIT_TYPE modify flag (ibt_port_modify_flags_t) is set. + */ +#define IBT_PINIT_NO_LOAD 0x1 +#define IBT_PINIT_PRESERVE_CONTENT 0x2 +#define IBT_PINIT_PRESERVE_PRESENCE 0x4 +#define IBT_PINIT_NO_RESUSCITATE 0x8 + + +/* + * Address vector definition. + */ +typedef struct ibt_adds_vect_s { + ib_gid_t av_dgid; /* IPV6 dest GID in GRH */ + ib_gid_t av_sgid; /* SGID */ + ibt_srate_t av_srate; /* Max static rate */ + uint8_t av_srvl:4; /* Service level in LRH */ + uint_t av_flow:20; /* 20 bit Flow Label */ + uint8_t av_tclass; /* Traffic Class */ + uint8_t av_hop; /* Hop Limit */ + uint8_t av_port_num; /* Port number for UD */ + boolean_t av_opaque1; + ib_lid_t av_opaque2; + ib_path_bits_t av_opaque3; + uint32_t av_opaque4; +} ibt_adds_vect_t; + +typedef struct ibt_cep_path_s { + ibt_adds_vect_t cep_adds_vect; /* Address Vector */ + uint16_t cep_pkey_ix; /* P_Key Index */ + uint8_t cep_hca_port_num; /* Port number for connected */ + /* channels. A value of 0 */ + /* indicates an invalid path */ + ib_time_t cep_cm_opaque1; +} ibt_cep_path_t; + +/* + * Define Receive Side Scaling types for IP over IB. + */ +typedef enum ibt_rss_flags_e { + IBT_RSS_ALG_TPL = (1 << 0), /* RSS: Toeplitz hash */ + IBT_RSS_ALG_XOR = (1 << 1), /* RSS: XOR hash */ + IBT_RSS_HASH_IPV4 = (1 << 2), /* RSS: hash IPv4 headers */ + IBT_RSS_HASH_IPV6 = (1 << 3), /* RSS: hash IPv6 headers */ + IBT_RSS_HASH_TCP_IPV4 = (1 << 4), /* RSS: hash TCP/IPv4 hdrs */ + IBT_RSS_HASH_TCP_IPV6 = (1 << 5) /* RSS: hash TCP/IPv6 hdrs */ +} ibt_rss_flags_t; + +typedef struct ibt_rss_attr_s { + ibt_rss_flags_t rss_flags; /* RSS: flags */ + uint_t rss_log2_table; /* RSS: log2 table size */ + ib_qpn_t rss_base_qpn; /* RSS: base QPN */ + ib_qpn_t rss_def_qpn; /* RSS: default QPN */ + uint8_t rss_toe_key[40]; /* RSS: Toeplitz hash key */ +} ibt_rss_attr_t; + +/* + * Channel Migration State. + */ +typedef enum ibt_cep_cmstate_e { + IBT_STATE_NOT_SUPPORTED = 0, + IBT_STATE_MIGRATED = 1, + IBT_STATE_REARMED = 2, + IBT_STATE_ARMED = 3 +} ibt_cep_cmstate_t; + +/* + * Transport service type + * + * NOTE: this was converted from an enum to a uint8_t to save space. + */ +typedef uint8_t ibt_tran_srv_t; + +#define IBT_RC_SRV 0 +#define IBT_UC_SRV 1 +#define IBT_RD_SRV 2 +#define IBT_UD_SRV 3 +#define IBT_RAWIP_SRV 4 +#define IBT_RAWETHER_SRV 5 +#define IBT_RFCI_SRV 6 +#define IBT_FCMD_SRV 7 +#define IBT_FEXCH_SRV 8 + +/* + * Channel (QP/EEC) state definitions. + */ +typedef enum ibt_cep_state_e { + IBT_STATE_RESET = 0, /* Reset */ + IBT_STATE_INIT, /* Initialized */ + IBT_STATE_RTR, /* Ready to Receive */ + IBT_STATE_RTS, /* Ready to Send */ + IBT_STATE_SQD, /* Send Queue Drained */ + IBT_STATE_SQE, /* Send Queue Error */ + IBT_STATE_ERROR, /* Error */ + IBT_STATE_SQDRAIN, /* Send Queue Draining */ + IBT_STATE_NUM /* Number of states */ +} ibt_cep_state_t; + + +/* + * Channel Attribute flags. + */ +typedef enum ibt_attr_flags_e { + IBT_ALL_SIGNALED = 0, /* All sends signaled */ + IBT_WR_SIGNALED = 1, /* Signaled on a WR basis */ + IBT_FAST_REG_RES_LKEY = (1 << 1), + IBT_USES_LSO = (1 << 2) +} ibt_attr_flags_t; + +/* + * Channel End Point (CEP) Control Flags. + */ +typedef enum ibt_cep_flags_e { + IBT_CEP_NO_FLAGS = 0, /* Enable Nothing */ + IBT_CEP_RDMA_RD = (1 << 0), /* Enable incoming RDMA RD's */ + /* RC & RD only */ + IBT_CEP_RDMA_WR = (1 << 1), /* Enable incoming RDMA WR's */ + /* RC & RD only */ + IBT_CEP_ATOMIC = (1 << 2) /* Enable incoming Atomics, */ + /* RC & RD only */ +} ibt_cep_flags_t; + +/* + * Channel Modify Flags + */ +typedef enum ibt_cep_modify_flags_e { + IBT_CEP_SET_NOTHING = 0, + IBT_CEP_SET_SQ_SIZE = (1 << 1), + IBT_CEP_SET_RQ_SIZE = (1 << 2), + + IBT_CEP_SET_RDMA_R = (1 << 3), + IBT_CEP_SET_RDMA_W = (1 << 4), + IBT_CEP_SET_ATOMIC = (1 << 5), + + IBT_CEP_SET_ALT_PATH = (1 << 6), /* Alternate Path */ + + IBT_CEP_SET_ADDS_VECT = (1 << 7), + IBT_CEP_SET_PORT = (1 << 8), + IBT_CEP_SET_OPAQUE5 = (1 << 9), + IBT_CEP_SET_RETRY = (1 << 10), + IBT_CEP_SET_RNR_NAK_RETRY = (1 << 11), + IBT_CEP_SET_MIN_RNR_NAK = (1 << 12), + + IBT_CEP_SET_QKEY = (1 << 13), + IBT_CEP_SET_RDMARA_OUT = (1 << 14), + IBT_CEP_SET_RDMARA_IN = (1 << 15), + + IBT_CEP_SET_OPAQUE1 = (1 << 16), + IBT_CEP_SET_OPAQUE2 = (1 << 17), + IBT_CEP_SET_OPAQUE3 = (1 << 18), + IBT_CEP_SET_OPAQUE4 = (1 << 19), + IBT_CEP_SET_SQD_EVENT = (1 << 20), + IBT_CEP_SET_OPAQUE6 = (1 << 21), + IBT_CEP_SET_OPAQUE7 = (1 << 22), + IBT_CEP_SET_OPAQUE8 = (1 << 23), + IBT_CEP_SET_RSS = (1 << 24), + IBT_CEP_SET_FEXCH_RANGE = (1 << 25) +} ibt_cep_modify_flags_t; + +/* + * CQ notify types. + */ +typedef enum ibt_cq_notify_flags_e { + IBT_NEXT_COMPLETION = 1, + IBT_NEXT_SOLICITED = 2 +} ibt_cq_notify_flags_t; + +/* + * CQ types shared across TI and CI. + */ +typedef enum ibt_cq_flags_e { + IBT_CQ_NO_FLAGS = 0, + IBT_CQ_HANDLER_IN_THREAD = 1 << 0, /* A thread calls the */ + /* CQ handler */ + IBT_CQ_USER_MAP = 1 << 1, + IBT_CQ_DEFER_ALLOC = 1 << 2, + IBT_CQ_HID = 1 << 3 +} ibt_cq_flags_t; + +typedef enum ibt_cq_sched_flags_e { + IBT_CQS_NO_FLAGS = 0, + IBT_CQS_WARM_CACHE = 1 << 0, /* run on same CPU */ + IBT_CQS_EXACT_SCHED_GROUP = 1 << 1, + IBT_CQS_SCHED_GROUP = 1 << 2, + IBT_CQS_USER_MAP = 1 << 3, + IBT_CQS_DEFER_ALLOC = 1 << 4 +} ibt_cq_sched_flags_t; + +/* + * Attributes when creating a Completion Queue Scheduling Handle. + */ +typedef struct ibt_cq_sched_attr_s { + ibt_cq_sched_flags_t cqs_flags; + char *cqs_pool_name; +} ibt_cq_sched_attr_t; + +typedef void *ibt_intr_handle_t; + +typedef struct ibt_cq_handler_attr_s { + dev_info_t *cha_dip; + ibt_intr_handle_t cha_ih; +} ibt_cq_handler_attr_t; + +/* + * Attributes when creating a Completion Queue. + * + * Note: + * The IBT_CQ_HANDLER_IN_THREAD cq_flags bit should be ignored by the CI. + */ +typedef struct ibt_cq_attr_s { + uint_t cq_size; + ibt_sched_hdl_t cq_sched; /* 0 = no hint, */ + /* other = cq_sched value */ + ibt_cq_flags_t cq_flags; + ibt_cq_handler_id_t cq_hid; +} ibt_cq_attr_t; + +/* + * Memory Management + */ + +/* Memory management flags */ +typedef enum ibt_mr_flags_e { + IBT_MR_SLEEP = 0, + IBT_MR_NOSLEEP = (1 << 1), + IBT_MR_NONCOHERENT = (1 << 2), + IBT_MR_PHYS_IOVA = (1 << 3), /* ibt_(re)register_buf */ + + /* Access control flags */ + IBT_MR_ENABLE_WINDOW_BIND = (1 << 4), + IBT_MR_ENABLE_LOCAL_WRITE = (1 << 5), + IBT_MR_ENABLE_REMOTE_READ = (1 << 6), + IBT_MR_ENABLE_REMOTE_WRITE = (1 << 7), + IBT_MR_ENABLE_REMOTE_ATOMIC = (1 << 8), + + /* Reregister flags */ + IBT_MR_CHANGE_TRANSLATION = (1 << 9), + IBT_MR_CHANGE_ACCESS = (1 << 10), + IBT_MR_CHANGE_PD = (1 << 11), + + /* Additional registration flags */ + IBT_MR_ZBVA = (1 << 12), + + /* Additional physical registration flags */ + IBT_MR_CONSUMER_KEY = (1 << 13), /* Consumer owns key */ + /* portion of keys */ + IBT_MR_DISABLE_RO = (1 << 14), + IBT_MR_USER_BUF = (1 << 15) /* ibt_(re)register_buf */ +} ibt_mr_flags_t; + + +/* Memory Region attribute flags */ +typedef enum ibt_mr_attr_flags_e { + /* Access control flags */ + IBT_MR_WINDOW_BIND = (1 << 0), + IBT_MR_LOCAL_WRITE = (1 << 1), + IBT_MR_REMOTE_READ = (1 << 2), + IBT_MR_REMOTE_WRITE = (1 << 3), + IBT_MR_REMOTE_ATOMIC = (1 << 4), + IBT_MR_ZERO_BASED_VA = (1 << 5), + IBT_MR_CONSUMER_OWNED_KEY = (1 << 6), + IBT_MR_SHARED = (1 << 7), + IBT_MR_FMR = (1 << 8), + IBT_MR_RO_DISABLED = (1 << 9) +} ibt_mr_attr_flags_t; + +/* Memory region physical descriptor. */ +typedef struct ibt_phys_buf_s { + union { + uint64_t _p_ll; /* 64 bit DMA address */ + uint32_t _p_la[2]; /* 2 x 32 bit address */ + } _phys_buf; + size_t p_size; +} ibt_phys_buf_t; + +/* version of above for uniform buffer size */ +typedef struct ib_phys_addr_t { + union { + uint64_t _p_ll; /* 64 bit DMA address */ + uint32_t _p_la[2]; /* 2 x 32 bit address */ + } _phys_buf; +} ibt_phys_addr_t; + +#define p_laddr _phys_buf._p_ll +#ifdef _LONG_LONG_HTOL +#define p_notused _phys_buf._p_la[0] +#define p_addr _phys_buf._p_la[1] +#else +#define p_addr _phys_buf._p_la[0] +#define p_notused _phys_buf._p_la[1] +#endif + + +/* Memory region descriptor. */ +typedef struct ibt_mr_desc_s { + ib_vaddr_t md_vaddr; /* IB virtual adds of memory */ + ibt_lkey_t md_lkey; + ibt_rkey_t md_rkey; + boolean_t md_sync_required; +} ibt_mr_desc_t; + +/* Physical Memory region descriptor. */ +typedef struct ibt_pmr_desc_s { + ib_vaddr_t pmd_iova; /* Returned I/O Virtual Address */ + ibt_lkey_t pmd_lkey; + ibt_rkey_t pmd_rkey; + uint_t pmd_phys_buf_list_sz; /* Allocated Phys buf sz */ + boolean_t pmd_sync_required; +} ibt_pmr_desc_t; + +/* Memory region protection bounds. */ +typedef struct ibt_mr_prot_bounds_s { + ib_vaddr_t pb_addr; /* Beginning address */ + size_t pb_len; /* Length of protected region */ +} ibt_mr_prot_bounds_t; + +/* Memory Region (Re)Register attributes */ +typedef struct ibt_mr_attr_s { + ib_vaddr_t mr_vaddr; /* Virtual address to register */ + ib_memlen_t mr_len; /* Length of region to register */ + struct as *mr_as; /* A pointer to an address space */ + /* structure. This parameter should */ + /* be set to NULL, which implies */ + /* kernel address space. */ + ibt_mr_flags_t mr_flags; +} ibt_mr_attr_t; + +/* Physical Memory Region (Re)Register */ +typedef struct ibt_pmr_attr_s { + ib_vaddr_t pmr_iova; /* I/O virtual address requested by */ + /* client for the first byte of the */ + /* region */ + ib_memlen_t pmr_len; /* Length of region to register */ + ib_memlen_t pmr_offset; /* Offset of the regions starting */ + /* IOVA within the 1st physical */ + /* buffer */ + ibt_ma_hdl_t pmr_ma; /* Memory handle used to obtain the */ + /* pmr_buf_list */ + ibt_phys_addr_t *pmr_addr_list; /* List of physical buffers accessed */ + /* as an array */ + size_t pmr_buf_sz; + uint_t pmr_num_buf; /* Num of entries in the pmr_buf_list */ + ibt_lkey_t pmr_lkey; /* Reregister only */ + ibt_rkey_t pmr_rkey; /* Reregister only */ + ibt_mr_flags_t pmr_flags; + uint8_t pmr_key; /* Key to use on new Lkey & Rkey */ +} ibt_pmr_attr_t; + +/* DMA Memory Region */ +typedef struct ibt_dmr_attr_s { + uint64_t dmr_paddr; /* starting physical addr */ + ib_memlen_t dmr_len; /* length in bytes */ + ibt_mr_flags_t dmr_flags; /* no sleep, memory permissions */ +} ibt_dmr_attr_t; + +/* addr/length pair */ +typedef struct ibt_iov_s { + caddr_t iov_addr; /* Beginning address */ + size_t iov_len; /* Length */ +} ibt_iov_t; + +/* Map memory IOV */ +typedef enum ibt_iov_flags_e { + IBT_IOV_SLEEP = 0, + IBT_IOV_NOSLEEP = (1 << 0), + IBT_IOV_BUF = (1 << 1), + IBT_IOV_RECV = (1 << 2), + IBT_IOV_USER_BUF = (1 << 3), + IBT_IOV_ALT_LKEY = (1 << 4) +} ibt_iov_flags_t; + +typedef struct ibt_iov_attr_s { + struct as *iov_as; + ibt_iov_t *iov; + struct buf *iov_buf; + uint32_t iov_list_len; + uint32_t iov_wr_nds; + ib_msglen_t iov_lso_hdr_sz; + ibt_lkey_t iov_alt_lkey; + ibt_iov_flags_t iov_flags; +} ibt_iov_attr_t; + +/* + * Memory Region (Re)Register attributes - used by ibt_register_shared_mr(), + * ibt_register_buf() and ibt_reregister_buf(). + */ +typedef struct ibt_smr_attr_s { + ib_vaddr_t mr_vaddr; + ibt_mr_flags_t mr_flags; + uint8_t mr_key; /* Only for physical */ + /* ibt_(Re)register_buf() */ + ibt_lkey_t mr_lkey; /* Only for physical */ + ibt_rkey_t mr_rkey; /* ibt_Reregister_buf() */ +} ibt_smr_attr_t; + +/* + * key states. + */ +typedef enum ibt_key_state_e { + IBT_KEY_INVALID = 0, + IBT_KEY_FREE, + IBT_KEY_VALID +} ibt_key_state_t; + +/* Memory region query attributes */ +typedef struct ibt_mr_query_attr_s { + ibt_lkey_t mr_lkey; + ibt_rkey_t mr_rkey; + ibt_mr_prot_bounds_t mr_lbounds; /* Actual local CI protection */ + /* bounds */ + ibt_mr_prot_bounds_t mr_rbounds; /* Actual remote CI */ + /* protection bounds */ + ibt_mr_attr_flags_t mr_attr_flags; /* Access rights etc. */ + ibt_pd_hdl_t mr_pd; /* Protection domain */ + boolean_t mr_sync_required; + ibt_key_state_t mr_lkey_state; + uint_t mr_phys_buf_list_sz; +} ibt_mr_query_attr_t; + +/* Memory window query attributes */ +typedef struct ibt_mw_query_attr_s { + ibt_pd_hdl_t mw_pd; + ibt_mem_win_type_t mw_type; + ibt_rkey_t mw_rkey; + ibt_key_state_t mw_state; +} ibt_mw_query_attr_t; + + +/* Memory Region Sync Flags. */ +#define IBT_SYNC_READ 0x1 /* Make memory changes visible to incoming */ + /* RDMA reads */ + +#define IBT_SYNC_WRITE 0x2 /* Make the affects of an incoming RDMA write */ + /* visible to the consumer */ + +/* Memory region sync args */ +typedef struct ibt_mr_sync_s { + ibt_mr_hdl_t ms_handle; + ib_vaddr_t ms_vaddr; + ib_memlen_t ms_len; + uint32_t ms_flags; /* IBT_SYNC_READ or IBT_SYNC_WRITE */ +} ibt_mr_sync_t; + +/* + * Flags for Virtual Address to HCA Physical Address translation. + */ +typedef enum ibt_va_flags_e { + IBT_VA_SLEEP = 0, + IBT_VA_NOSLEEP = (1 << 0), + IBT_VA_NONCOHERENT = (1 << 1), + IBT_VA_FMR = (1 << 2), + IBT_VA_BLOCK_MODE = (1 << 3), + IBT_VA_BUF = (1 << 4), + IBT_VA_REG_FN = (1 << 5), + IBT_VA_USER_BUF = (1 << 6) +} ibt_va_flags_t; + + +/* Address Translation parameters */ +typedef struct ibt_va_attr_s { + ib_vaddr_t va_vaddr; /* Virtual address to register */ + ib_memlen_t va_len; /* Length of region to register */ + struct as *va_as; /* A pointer to an address space */ + /* structure. */ + size_t va_phys_buf_min; /* block mode only */ + size_t va_phys_buf_max; /* block mode only */ + ibt_va_flags_t va_flags; + struct buf *va_buf; +} ibt_va_attr_t; + + +/* + * Fast Memory Registration (FMR) support. + */ + +/* FMR flush function handler. */ +typedef void (*ibt_fmr_flush_handler_t)(ibt_fmr_pool_hdl_t fmr_pool, + void *fmr_func_arg); + +/* FMR Pool create attributes. */ +typedef struct ibt_fmr_pool_attr_s { + uint_t fmr_max_pages_per_fmr; + uint_t fmr_pool_size; + uint_t fmr_dirty_watermark; + size_t fmr_page_sz; + boolean_t fmr_cache; + ibt_mr_flags_t fmr_flags; + ibt_fmr_flush_handler_t fmr_func_hdlr; + void *fmr_func_arg; +} ibt_fmr_pool_attr_t; + +/* + * Define types for Fibre Channel over IB (fcoib) + */ +typedef enum ibt_fexch_query_flags_e { + IBT_FEXCH_NO_FLAGS = 0, + IBT_FEXCH_HEART_BEAT_OK = (1 << 0) /* FEXCH only */ +} ibt_fexch_query_flags_t; + +typedef struct ibt_fexch_query_attr_s { + ibt_pmr_desc_t fq_uni_mem_desc; /* FEXCH: uni-directional MR attrs */ + ibt_pmr_desc_t fq_bi_mem_desc; /* FEXCH: bi-directional MR attrs */ + ibt_fexch_query_flags_t fq_flags; +} ibt_fexch_query_attr_t; + +typedef struct ibt_fc_attr_s { + uint32_t fc_src_id; /* S_ID assigned to the RFCI QP */ + /* FCMD, FEXCH: matching RFCI QP = RFCI base + idx */ + ib_qpn_t fc_rfci_qpn; + uint16_t fc_exch_base_off; /* FCMD: FEXCH usable base */ + uint8_t fc_exch_log2_sz; /* FCMD: FEXCH log2 size */ + uint8_t fc_hca_port; /* RFCI, FEXCH: HCA port number */ +} ibt_fc_attr_t; + + +/* + * WORK REQUEST AND WORK REQUEST COMPLETION DEFINITIONS. + */ + +/* + * Work Request and Work Request Completion types - These types are used + * to indicate the type of work requests posted to a work queue + * or the type of completion received. Immediate Data is indicated via + * ibt_wr_flags_t or ibt_wc_flags_t. + * + * IBT_WRC_RECV and IBT_WRC_RECV_RDMAWI are only used as opcodes in the + * work completions. + * + * NOTE: this was converted from an enum to a uint8_t to save space. + */ +typedef uint8_t ibt_wrc_opcode_t; + +#define IBT_WRC_SEND 1 /* Send */ +#define IBT_WRC_RDMAR 2 /* RDMA Read */ +#define IBT_WRC_RDMAW 3 /* RDMA Write */ +#define IBT_WRC_CSWAP 4 /* Compare & Swap Atomic */ +#define IBT_WRC_FADD 5 /* Fetch & Add Atomic */ +#define IBT_WRC_BIND 6 /* Bind Memory Window */ +#define IBT_WRC_RECV 7 /* Receive */ +#define IBT_WRC_RECV_RDMAWI 8 /* Received RDMA Write w/ Immediate */ +#define IBT_WRC_FAST_REG_PMR 9 /* Fast Register Physical mem region */ +#define IBT_WRC_LOCAL_INVALIDATE 10 +#define IBT_WRC_SEND_LSO 11 +#define IBT_WRC_INIT_SEND_FCMD 12 /* Init & Send for FCMD initiator */ +#define IBT_WRC_INIT_FEXCH 13 /* Init for FEXCH target */ + + +/* + * Work Request Completion flags - These flags indicate what type + * of data is present in the Work Request Completion structure + */ +typedef uint8_t ibt_wc_flags_t; + +#define IBT_WC_NO_FLAGS 0 +#define IBT_WC_GRH_PRESENT (1 << 0) +#define IBT_WC_IMMED_DATA_PRESENT (1 << 1) +#define IBT_WC_RKEY_INVALIDATED (1 << 2) +#define IBT_WC_CKSUM_OK (1 << 3) +#define IBT_WC_FEXCH_FMT (1 << 4) +#define IBT_WC_DIF_ERROR (1 << 5) + +/* IPoIB flags for wc_detail field */ +#define IBT_WC_DETAIL_ALL_FLAGS_MASK (0x0FC00000) +#define IBT_WC_DETAIL_IPV4 (1 << 22) +#define IBT_WC_DETAIL_IPV4_FRAG (1 << 23) +#define IBT_WC_DETAIL_IPV6 (1 << 24) +#define IBT_WC_DETAIL_IPV4_OPT (1 << 25) +#define IBT_WC_DETAIL_TCP (1 << 26) +#define IBT_WC_DETAIL_UDP (1 << 27) + +#define IBT_WC_DETAIL_RSS_MATCH_MASK (0x003F0000) +#define IBT_WC_DETAIL_RSS_TCP_IPV6 (1 << 18) +#define IBT_WC_DETAIL_RSS_IPV6 (1 << 19) +#define IBT_WC_DETAIL_RSS_TCP_IPV4 (1 << 20) +#define IBT_WC_DETAIL_RSS_IPV4 (1 << 21) + +/* FEXCH flags for wc_detail field */ +#define IBT_WC_DETAIL_FC_MATCH_MASK (0xE000000) +#define IBT_WC_DETAIL_FEXCH_INIT_XFER (1 << 25) +#define IBT_WC_DETAIL_FEXCH_LAST (1 << 26) +#define IBT_WC_DETAIL_RFCI_CRC_OK (1 << 27) + +/* + * Work Request Completion - This structure encapsulates the information + * necessary to define a work request completion. + */ +typedef struct ibt_wc_s { + ibt_wrid_t wc_id; /* Work Request Id */ + uint64_t wc_fma_ena; /* fault management err data */ + ib_msglen_t wc_bytes_xfer; /* Number of Bytes */ + /* Transferred */ + ibt_wc_flags_t wc_flags; /* WR Completion Flags */ + ibt_wrc_opcode_t wc_type; /* Operation Type */ + uint16_t wc_cksum; /* payload checksum */ + ibt_immed_t wc_immed_data; /* Immediate Data */ + uint32_t wc_res_hash; /* RD: Freed Res, RSS: hash */ + ibt_wc_status_t wc_status; /* Completion Status */ + uint8_t wc_sl:4; /* Remote SL */ + uint16_t wc_ethertype; /* Ethertype Field - RE */ + ib_lid_t wc_opaque1; + uint16_t wc_opaque2; + ib_qpn_t wc_qpn; /* Source QPN Datagram only */ + uint32_t wc_detail; /* RD: EECN, UD: IPoIB flags */ + ib_qpn_t wc_local_qpn; + ibt_rkey_t wc_rkey; + ib_path_bits_t wc_opaque4; +} ibt_wc_t; + +/* FC format alternative field names */ +#define wc_fexch_seq_cnt wc_cksum +#define wc_fexch_tx_bytes_xfer wc_immed_data +#define wc_fexch_rx_bytes_xfer wc_res_hash +#define wc_fexch_seq_id wc_opaque2 + + +/* + * WR Flags. Common for both RC and UD + * + * NOTE: this was converted from an enum to a uint8_t to save space. + */ +typedef uint8_t ibt_wr_flags_t; + +#define IBT_WR_NO_FLAGS 0 +#define IBT_WR_SEND_IMMED (1 << 0) /* Immediate Data Indicator */ +#define IBT_WR_SEND_SIGNAL (1 << 1) /* Signaled, if set */ +#define IBT_WR_SEND_FENCE (1 << 2) /* Fence Indicator */ +#define IBT_WR_SEND_SOLICIT (1 << 3) /* Solicited Event Indicator */ +#define IBT_WR_SEND_REMOTE_INVAL (1 << 4) /* Remote Invalidate */ +#define IBT_WR_SEND_CKSUM (1 << 5) /* Checksum offload Indicator */ +#define IBT_WR_SEND_FC_CRC IBT_WR_SEND_CKSUM /* RFCI: FC CRC */ +#define IBT_WR_SEND_INLINE (1 << 6) /* INLINE required (no lkey) */ + +/* + * Access control flags for Bind Memory Window operation, + * applicable for RC/UC/RD only. + * + * If IBT_WR_BIND_WRITE or IBT_WR_BIND_ATOMIC is desired then + * it is required that Memory Region should have Local Write Access. + */ +typedef enum ibt_bind_flags_e { + IBT_WR_BIND_READ = (1 << 0), /* enable remote read */ + IBT_WR_BIND_WRITE = (1 << 1), /* enable remote write */ + IBT_WR_BIND_ATOMIC = (1 << 2), /* enable remote atomics */ + IBT_WR_BIND_ZBVA = (1 << 3) /* Zero Based Virtual Address */ +} ibt_bind_flags_t; + +/* + * Data Segment for scatter-gather list + * + * SGL consists of an array of data segments and the length of the SGL. + */ +typedef struct ibt_wr_ds_s { + ib_vaddr_t ds_va; /* Virtual Address */ + ibt_lkey_t ds_key; /* L_Key */ + ib_msglen_t ds_len; /* Length of DS */ +} ibt_wr_ds_t; + +/* + * Bind Memory Window WR + * + * WR ID from ibt_send_wr_t applies here too, SWG_0038 errata. + */ +typedef struct ibt_wr_bind_s { + ibt_bind_flags_t bind_flags; + ibt_rkey_t bind_rkey; /* Mem Window's R_key */ + ibt_lkey_t bind_lkey; /* Mem Region's L_Key */ + ibt_rkey_t bind_rkey_out; /* OUT: new R_Key */ + ibt_mr_hdl_t bind_ibt_mr_hdl; /* Mem Region handle */ + ibt_mw_hdl_t bind_ibt_mw_hdl; /* Mem Window handle */ + ib_vaddr_t bind_va; /* Virtual Address */ + ib_memlen_t bind_len; /* Length of Window */ +} ibt_wr_bind_t; + +/* + * Atomic WR + * + * Operation type (compare & swap or fetch & add) in ibt_wrc_opcode_t. + * + * A copy of the original contents of the remote memory will be stored + * in the local data segment described by wr_sgl within ibt_send_wr_t, + * and wr_nds should be set to 1. + * + * Atomic operation operands: + * Compare & Swap Operation: + * atom_arg1 - Compare Operand + * atom_arg2 - Swap Operand + * + * Fetch & Add Operation: + * atom_arg1 - Add Operand + * atom_arg2 - ignored + */ +typedef struct ibt_wr_atomic_s { + ib_vaddr_t atom_raddr; /* Remote address. */ + ibt_atom_arg_t atom_arg1; /* operand #1 */ + ibt_atom_arg_t atom_arg2; /* operand #2 */ + ibt_rkey_t atom_rkey; /* R_Key. */ +} ibt_wr_atomic_t; + +/* + * RDMA WR + * Immediate Data indicator in ibt_wr_flags_t. + */ +typedef struct ibt_wr_rdma_s { + ib_vaddr_t rdma_raddr; /* Remote address. */ + ibt_rkey_t rdma_rkey; /* R_Key. */ + ibt_immed_t rdma_immed; /* Immediate Data */ +} ibt_wr_rdma_t; + +/* + * Fast Register Physical Memory Region Work Request. + */ +typedef struct ibt_wr_reg_pmr_s { + ib_vaddr_t pmr_iova; /* I/O virtual address requested by */ + /* client for the first byte of the */ + /* region */ + ib_memlen_t pmr_len; /* Length of region to register */ + ib_memlen_t pmr_offset; /* Offset of the region's starting */ + /* IOVA within the 1st physical */ + /* buffer */ + ibt_mr_hdl_t pmr_mr_hdl; + ibt_phys_addr_t *pmr_addr_list; /* List of physical buffers accessed */ + /* as an array */ + size_t pmr_buf_sz; /* size of uniform size PBEs */ + uint_t pmr_num_buf; /* #entries in the pmr_addr_list */ + ibt_lkey_t pmr_lkey; /* new lkey upon return */ + ibt_rkey_t pmr_rkey; /* new rkey upon return */ + ibt_mr_flags_t pmr_flags; + uint8_t pmr_key; /* Key to use on new Lkey & Rkey */ +} ibt_wr_reg_pmr_t; + +/* phys reg function or WR */ +typedef union ibt_reg_req_u { + ibt_pmr_attr_t fn_arg; + ibt_wr_reg_pmr_t wr; +} ibt_reg_req_t; + +/* + * Local Invalidate. + */ +typedef struct ibt_wr_li_s { + ibt_mr_hdl_t li_mr_hdl; /* Null for MW invalidates */ + ibt_mw_hdl_t li_mw_hdl; /* Null for MR invalidates */ + ibt_lkey_t li_lkey; /* Ignore for MW invalidates */ + ibt_rkey_t li_rkey; +} ibt_wr_li_t; + +/* + * Reserved For Future Use. + * Raw IPv6 Send WR + */ +typedef struct ibt_wr_ripv6_s { + ib_lid_t rip_dlid; /* DLID */ + ib_path_bits_t rip_slid_bits; /* SLID path bits, SWG_0033 errata */ + uint8_t rip_sl:4; /* SL */ + ibt_srate_t rip_rate; /* Max Static Rate, SWG_0007 errata */ +} ibt_wr_ripv6_t; + +/* + * Reserved For Future Use. + * Raw Ethertype Send WR + */ +typedef struct ibt_wr_reth_s { + ib_ethertype_t reth_type; /* Ethertype */ + ib_lid_t reth_dlid; /* DLID */ + ib_path_bits_t reth_slid_bits; /* SLID path bits, SWG_0033 errata */ + uint8_t reth_sl:4; /* SL */ + ibt_srate_t reth_rate; /* Max Static Rate, SWG_0007 errata */ +} ibt_wr_reth_t; + +/* + * Reserved For future Use. + * RD Send WR, Operation type in ibt_wrc_opcode_t. + */ +typedef struct ibt_wr_rd_s { + ibt_rd_dest_hdl_t rdwr_dest_hdl; + union { + ibt_immed_t send_immed; /* IBT_WRC_SEND */ + ibt_wr_rdma_t rdma; /* IBT_WRC_RDMAR */ + /* IBT_WRC_RDMAW */ + ibt_wr_li_t *li; /* IBT_WRC_LOCAL_INVALIDATE */ + ibt_wr_atomic_t *atomic; /* IBT_WRC_FADD */ + /* IBT_WRC_CSWAP */ + ibt_wr_bind_t *bind; /* IBT_WRC_BIND */ + ibt_wr_reg_pmr_t *reg_pmr; /* IBT_WRC_FAST_REG_PMR */ + } rdwr; +} ibt_wr_rd_t; + +/* + * Reserved For Future Use. + * UC Send WR, Operation type in ibt_wrc_opcode_t, the only valid + * ones are: + * IBT_WRC_SEND + * IBT_WRC_RDMAW + * IBT_WRC_BIND + */ +typedef struct ibt_wr_uc_s { + union { + ibt_immed_t send_immed; /* IBT_WRC_SEND */ + ibt_wr_rdma_t rdma; /* IBT_WRC_RDMAW */ + ibt_wr_li_t *li; /* IBT_WRC_LOCAL_INVALIDATE */ + ibt_wr_bind_t *bind; /* IBT_WRC_BIND */ + ibt_wr_reg_pmr_t *reg_pmr; /* IBT_WRC_FAST_REG_PMR */ + } ucwr; +} ibt_wr_uc_t; + +/* + * RC Send WR, Operation type in ibt_wrc_opcode_t. + */ +typedef struct ibt_wr_rc_s { + union { + ibt_immed_t send_immed; /* IBT_WRC_SEND w/ immediate */ + ibt_rkey_t send_inval; /* IBT_WRC_SEND w/ invalidate */ + ibt_wr_rdma_t rdma; /* IBT_WRC_RDMAR */ + /* IBT_WRC_RDMAW */ + ibt_wr_li_t *li; /* IBT_WRC_LOCAL_INVALIDATE */ + ibt_wr_atomic_t *atomic; /* IBT_WRC_CSWAP */ + /* IBT_WRC_FADD */ + ibt_wr_bind_t *bind; /* IBT_WRC_BIND */ + ibt_wr_reg_pmr_t *reg_pmr; /* IBT_WRC_FAST_REG_PMR */ + } rcwr; +} ibt_wr_rc_t; + +/* + * UD Send WR, the only valid Operation is IBT_WRC_SEND. + */ +typedef struct ibt_wr_ud_s { + ibt_immed_t udwr_immed; + ibt_ud_dest_hdl_t udwr_dest; +} ibt_wr_ud_t; + +/* LSO variant */ +typedef struct ibt_wr_lso_s { + ibt_ud_dest_hdl_t lso_ud_dest; + uint8_t *lso_hdr; + ib_msglen_t lso_hdr_sz; + ib_msglen_t lso_mss; +} ibt_wr_lso_t; + +/* FC WR definitions */ +typedef enum ibt_fctl_flags_e { /* F_CTL flags */ + IBT_FCTL_NO_FLAGS = 0, + IBT_FCTL_SIT = (1 << 16), /* seq initiative transfer */ + IBT_FCTL_PRIO = (1 << 17), /* InitAndSend WR: priority */ + IBT_FCTL_LAST_SEQ = (1 << 20), + /* InitAndSend WR: Exchange Originator, set = initiator, off = tgt */ + IBT_FCTL_ORIG_INIT = (1 << 23) +} ibt_fctl_flags_t; +#define IBT_FCTL_SET_ABORT_FIELD(VAL) (((VAL) & 0x3) << 4) /* InitAndSend WR */ +#define IBT_FCTL_GET_ABORT_FIELD(FCTL) (((FCTL) & 0x30) >> 4) + +/* FC information category value, low 4 bits of routing control */ +#define IBT_FC_INFO_SOL_DATA 1 /* solicited data */ +#define IBT_FC_INFO_DATA_DESC 5 /* data descriptor */ +#define IBT_FC_INFO_UNSOL_CMD 6 /* unsolicited command */ +#define IBT_FC_INFO_CMD_STAT 7 /* command status */ + +typedef struct ibt_fc_ctl_s { + ibt_ud_dest_hdl_t fc_dest; + ibt_fctl_flags_t fc_frame_ctrl; + uint32_t fc_parameter; + uint8_t fc_seq_id; + /* FC R_CTL containing information category */ + uint8_t fc_routing_ctrl; +} ibt_fc_ctl_t; + +/* RFCI version of send */ +typedef struct ibt_wr_rfci_send_s { + ibt_ud_dest_hdl_t rfci_dest; + uint8_t rfci_eof; /* RFCI: when FC CRC set */ +} ibt_wr_rfci_send_t; + +typedef uint8_t ibt_init_send_op_t; +#define IBT_IS_OP_TARGET 0x0 /* target mode or no IO initiator op */ +#define IBT_IS_OP_NO_IO IBT_IS_OP_TARGET +#define IBT_IS_OP_IO_READ 0x1 /* IO read */ +#define IBT_IS_OP_IO_WRITE 0x2 /* IO write */ +#define IBT_IS_OP_BIDIR 0x3 /* bidirectional command */ + +/* Init and Send for FCMD initiator and also Init for FEXCH target */ +typedef struct ibt_wr_init_send_s { + ibt_fc_ctl_t is_ctl; + uint32_t is_dest_id; /* FC hdr: D_ID, low 24 bits */ + uint16_t is_fc_mtu; /* packet MTU (4B), low 10 bits */ + uint16_t is_rem_exch; /* target: remote exchange */ + uint16_t is_exch_qp_idx; /* FEXCH index for ULP */ + uint8_t is_cs_priority; /* FC hdr: CS_CTL/Priority */ + uint8_t is_tx_seq_id; /* initiator: FCP_DATA seq_id */ + ibt_init_send_op_t is_op; +} ibt_wr_init_send_t; + +typedef union ibt_wr_fc_u { + ibt_wr_rfci_send_t rfci_send; /* RFCI send */ + ibt_wr_init_send_t *fc_is; /* FCMD, FEXCH */ + ibt_wr_reg_pmr_t *reg_pmr; /* FCMD */ +} ibt_wr_fc_t; + + +/* + * Send Work Request (WR) attributes structure. + * + * Operation type in ibt_wrc_opcode_t. + * Immediate Data indicator in ibt_wr_flags_t. + * + * RFCI initiator QP: send (FCP_CONF) + * FCMD initiator QP: init & send (FCP_CMND), FRWR + * FEXCH target QP: init, FRWR, RDMA-R (FCP_XFER_RDY), RDMA-W (FCP_DATA), + * Send (FCP_RSP) + */ +typedef struct ibt_send_wr_s { + ibt_wrid_t wr_id; /* WR ID */ + ibt_wr_flags_t wr_flags; /* Work Request Flags. */ + ibt_tran_srv_t wr_trans; /* Transport Type. */ + ibt_wrc_opcode_t wr_opcode; /* Operation Type. */ + uint8_t wr_rsvd; /* maybe later */ + uint32_t wr_nds; /* Number of data segments */ + /* pointed to by wr_sgl */ + ibt_wr_ds_t *wr_sgl; /* SGL */ + union { + ibt_wr_ud_t ud; + ibt_wr_rc_t rc; + ibt_wr_rd_t rd; /* Reserved For Future Use */ + ibt_wr_uc_t uc; /* Reserved For Future Use */ + ibt_wr_reth_t reth; /* Reserved For Future Use */ + ibt_wr_ripv6_t ripv6; /* Reserved For Future Use */ + ibt_wr_lso_t ud_lso; + ibt_wr_fc_t fc; /* RFCI, FCMD, FEXCH */ + } wr; /* operation specific */ +} ibt_send_wr_t; + +/* + * Receive Work Request (WR) attributes structure. + * + * also used by these FC QP types: + * RFCI initiator QP + * FEXCH initiator QP (FCP_RSP) + * RFCI target QP (FCP_CMND) + */ +typedef struct ibt_recv_wr_s { + ibt_wrid_t wr_id; /* WR ID */ + uint32_t wr_nds; /* number of data segments */ + /* pointed to by wr_sgl */ + ibt_wr_ds_t *wr_sgl; /* SGL */ +} ibt_recv_wr_t; + +typedef union ibt_all_wr_u { + ibt_send_wr_t send; + ibt_recv_wr_t recv; +} ibt_all_wr_t; + + +/* + * Asynchronous Events and Errors. + * + * The following codes are not used in calls to ibc_async_handler, but + * are used by IBTL to inform IBT clients of a significant event. + * + * IBT_HCA_ATTACH_EVENT - New HCA available. + * IBT_HCA_DETACH_EVENT - HCA is requesting not to be used. + * + * ERRORs on a channel indicate that the channel has entered error state. + * EVENTs on a channel indicate that the channel has not changed state. + * + */ +typedef enum ibt_async_code_e { + IBT_EVENT_PATH_MIGRATED = 0x000001, + IBT_EVENT_SQD = 0x000002, + IBT_EVENT_COM_EST = 0x000004, + IBT_ERROR_CATASTROPHIC_CHAN = 0x000008, + IBT_ERROR_INVALID_REQUEST_CHAN = 0x000010, + IBT_ERROR_ACCESS_VIOLATION_CHAN = 0x000020, + IBT_ERROR_PATH_MIGRATE_REQ = 0x000040, + + IBT_ERROR_CQ = 0x000080, + + IBT_EVENT_PORT_UP = 0x000100, + IBT_ERROR_PORT_DOWN = 0x000200, + IBT_ERROR_LOCAL_CATASTROPHIC = 0x000400, + + IBT_HCA_ATTACH_EVENT = 0x000800, + IBT_HCA_DETACH_EVENT = 0x001000, + IBT_ASYNC_OPAQUE1 = 0x002000, + IBT_ASYNC_OPAQUE2 = 0x004000, + IBT_ASYNC_OPAQUE3 = 0x008000, + IBT_ASYNC_OPAQUE4 = 0x010000, + IBT_EVENT_LIMIT_REACHED_SRQ = 0x020000, + IBT_EVENT_EMPTY_CHAN = 0x040000, + IBT_ERROR_CATASTROPHIC_SRQ = 0x080000, + + IBT_PORT_CHANGE_EVENT = 0x100000, + IBT_CLNT_REREG_EVENT = 0x200000, + IBT_FEXCH_ERROR = 0x400000 +} ibt_async_code_t; + +#define IBT_PORT_EVENTS (IBT_EVENT_PORT_UP|IBT_PORT_CHANGE_EVENT|\ + IBT_ERROR_PORT_DOWN|IBT_CLNT_REREG_EVENT) + +typedef enum ibt_port_change_e { + IBT_PORT_CHANGE_SGID = 0x000001, /* SGID table */ + IBT_PORT_CHANGE_PKEY = 0x000002, /* P_Key table */ + IBT_PORT_CHANGE_SM_LID = 0x000004, /* Master SM LID */ + IBT_PORT_CHANGE_SM_SL = 0x000008, /* Master SM SL */ + IBT_PORT_CHANGE_SUB_TIMEOUT = 0x000010, /* Subnet Timeout */ + IBT_PORT_CHANGE_SM_FLAG = 0x000020, /* IsSMDisabled bit */ + IBT_PORT_CHANGE_REREG = 0x000040 /* IsClientReregSupport */ +} ibt_port_change_t; + +typedef uint8_t ibt_fc_syndrome_t; +#define IBT_FC_BAD_IU 0x0 +#define IBT_FC_BROKEN_SEQ 0x1 + +/* + * ibt_ci_data_in() and ibt_ci_data_out() flags. + */ +typedef enum ibt_ci_data_flags_e { + IBT_CI_NO_FLAGS = 0, + IBT_CI_COMPLETE_ALLOC = (1 << 0) +} ibt_ci_data_flags_t; + +/* + * Used by ibt_ci_data_in() and ibt_ci_data_out() identifies the type of handle + * mapping data is being obtained for. + */ +typedef enum ibt_object_type_e { + IBT_HDL_HCA = 1, + IBT_HDL_CHANNEL, + IBT_HDL_CQ, + IBT_HDL_PD, + IBT_HDL_MR, + IBT_HDL_MW, + IBT_HDL_UD_DEST, + IBT_HDL_SCHED, + IBT_HDL_OPAQUE1, + IBT_HDL_OPAQUE2, + IBT_HDL_SRQ +} ibt_object_type_t; + +/* + * Standard information for ibt_ci_data_in() for memory regions. + * + * IBT_MR_DATA_IN_IF_VERSION is the value used in the mr_rev member. + * mr_func is the callback handler. mr_arg1 and mr_arg2 are its arguments. + */ +#define IBT_MR_DATA_IN_IF_VERSION 1 +typedef struct ibt_mr_data_in_s { + uint_t mr_rev; + void (*mr_func)(void *, void *); + void *mr_arg1; + void *mr_arg2; +} ibt_mr_data_in_t; + +/* + * Memory error handler data structures; code, and payload data. + */ +typedef enum ibt_mem_code_s { + IBT_MEM_AREA = 0x1, + IBT_MEM_REGION = 0x2 +} ibt_mem_code_t; + +typedef struct ibt_mem_data_s { + uint64_t ev_fma_ena; /* FMA Error data */ + ibt_mr_hdl_t ev_mr_hdl; /* MR handle */ + ibt_ma_hdl_t ev_ma_hdl; /* MA handle */ +} ibt_mem_data_t; + +/* + * Special case failure type. + */ +typedef enum ibt_failure_type_e { + IBT_FAILURE_STANDARD = 0, + IBT_FAILURE_CI, + IBT_FAILURE_IBMF, + IBT_FAILURE_IBTL, + IBT_FAILURE_IBCM, + IBT_FAILURE_IBDM, + IBT_FAILURE_IBSM +} ibt_failure_type_t; + +/* + * RDMA IP CM service Annex definitions + */ +typedef struct ibt_ip_addr_s { + sa_family_t family; /* AF_INET or AF_INET6 */ + union { + in_addr_t ip4addr; + in6_addr_t ip6addr; + } un; + uint32_t ip6_scope_id; /* Applicable only for AF_INET6 */ +} ibt_ip_addr_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IBTL_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/ibvti.h b/illumos-x86_64/usr/include/sys/ib/ibtl/ibvti.h new file mode 100644 index 00000000..64f7563f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/ibvti.h @@ -0,0 +1,250 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IB_IBTL_IBVTI_H +#define _SYS_IB_IBTL_IBVTI_H + +/* + * ibvti.h + * + * This file contains private verbs level transport interface extensions. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define IBT_CM_NO_QP IBT_CM_NO_CHAN /* ibt_cm_reason_t */ + +#define IBT_CM_SREP_QPN_VALID IBT_CM_SREP_CHAN_VALID /* ibt_sidr_status_t */ +#define IBT_CM_SREP_NO_QP IBT_CM_SREP_NO_CHAN /* ibt_sidr_status_t */ + +#define IBT_OCHAN_CM_RETRY IBT_OCHAN_OPAQUE1 /* ibt_chan_open_flags_t */ +#define IBT_OCHAN_STARTING_PSN IBT_OCHAN_OPAQUE2 /* ibt_chan_open_flags_t */ +#define IBT_OCHAN_LOCAL_CM_TM IBT_OCHAN_OPAQUE3 /* ibt_chan_open_flags_t */ +#define IBT_OCHAN_REMOTE_CM_TM IBT_OCHAN_OPAQUE4 /* ibt_chan_open_flags_t */ +#define IBT_OCHAN_RDC_EXISTS IBT_OCHAN_OPAQUE5 /* ibt_chan_open_flags_t */ +#define IBT_OCHAN_OFUV IBT_OCHAN_OPAQUE6 /* ibt_chan_open_flags_t */ + +#define oc_cm_retry_cnt oc_opaque1 /* ibt_chan_open_args_t */ + /* The number of times the */ + /* CM will retry its MADs */ + /* when IBT_OCHAN_CM_RETRY */ + /* is set */ +#define oc_starting_psn oc_opaque2 /* ibt_chan_open_args_t */ + /* use oc_starting_psn when */ + /* IBT_OCHAN_STARTING_PSN is */ + /* set */ + +#define oc_local_cm_time oc_opaque3 /* ibt_chan_open_args_t */ + /* The maximum time in */ + /* microseconds that local */ + /* client takes to respond */ + /* for a CM callback */ + +#define oc_remote_cm_time oc_opaque4 /* ibt_chan_open_args_t */ + /* The maximum time in */ + /* microseconds that remote */ + /* node takes to respond */ + /* for a CM MAD */ + +#define cm_eec_hdl cm_opaque /* ibt_cm_event_t */ + +#define req_remote_eecn req_opaque1 /* ibt_cm_req_rcv_t */ +#define req_local_eecn req_opaque2 /* ibt_cm_req_rcv_t */ + +#define IBT_CM_RDC_EXISTS 0x4 /* ibt_cm_flags_t */ + +#define ai_dlid ai_opaque1 /* Local dest, or router LID */ +#define ai_src_path ai_opaque2 /* Source path bits */ + + +/* + * Note that variables of type ibt_qp_hdl_t (really ibt_channel_hdl_t) + * can be used in some of the IBTI interfaces, e.g., ibt_open_rc_channel(). + */ +#define ibt_qp_hdl_t ibt_channel_hdl_t + + +/* + * FUNCTION PROTOTYPES. + */ +/* + * ibt_alloc_ah() + * Allocates and returns an address handle (ibt_ah_hdl_t). + */ +ibt_status_t ibt_alloc_ah(ibt_hca_hdl_t hca_hdl, ibt_ah_flags_t flags, + ibt_pd_hdl_t pd, ibt_adds_vect_t *adds_vectp, ibt_ah_hdl_t *ah_p); + +/* + * ibt_free_ah() + * Release/de-allocate the specified handle. + */ +ibt_status_t ibt_free_ah(ibt_hca_hdl_t hca_hdl, ibt_ah_hdl_t ah); + +/* + * ibt_query_ah + * Obtain the address vector information for the specified address handle. + */ +ibt_status_t ibt_query_ah(ibt_hca_hdl_t hca_hdl, ibt_ah_hdl_t ah, + ibt_pd_hdl_t *pd_p, ibt_adds_vect_t *adds_vectp); + +/* + * ibt_modify_ah + * Modify the address vector information for the specified address handle. + */ +ibt_status_t ibt_modify_ah(ibt_hca_hdl_t hca_hdl, ibt_ah_hdl_t ah, + ibt_adds_vect_t *adds_vectp); + + +/* + * ibt_alloc_qp() + * Allocate a QP with specified attributes. + * + * Note: + * QPs allocated by ibt_alloc_qp are in the RESET state. The client + * needs to transition an RC QP into the INIT state if it is going to + * use ibt_open_rc_channel to establish the connection. + * The client needs to transition an UD QP into the RTS state. + */ +ibt_status_t ibt_alloc_qp(ibt_hca_hdl_t hca_hdl, ibt_qp_type_t type, + ibt_qp_alloc_attr_t *qp_attr, ibt_chan_sizes_t *queue_sizes_p, + ib_qpn_t *qpn_p, ibt_qp_hdl_t *ibt_qp_p); + +/* + * ibt_alloc_special_qp() + * Allocate a special QP with specified attributes. + * + * Note: + * QPs allocated by ibt_alloc_special_qp are in the RESET state. + * The client needs to transition an UD QP into the RTS state. + */ +ibt_status_t ibt_alloc_special_qp(ibt_hca_hdl_t hca_hdl, uint8_t port, + ibt_sqp_type_t type, ibt_qp_alloc_attr_t *qp_attr, + ibt_chan_sizes_t *queue_sizes_p, ibt_qp_hdl_t *ibt_qp_p); + +/* + * ibt_flush_qp() + * Transition a QP into error state to flush all outstanding + * work requests. Must be called before calling ibt_free_qp(). + * Use ibt_close_rc_channel for RC QPs that have been opened + * successfully. + */ +ibt_status_t ibt_flush_qp(ibt_qp_hdl_t ibt_qp); + +/* + * ibt_initialize_qp() + * Transition a QP from RESET state into a usable state. + * An RC QP is transitioned into the INIT state, ready for + * a call to ibt_open_rc_channel(). A UD QP is transitioned + * all the way to the RTS state. + */ +ibt_status_t ibt_initialize_qp(ibt_qp_hdl_t ibt_qp, + ibt_qp_info_t *modify_attrp); + + +/* + * ibt_free_qp() + * De-allocate or free the resources associated with an existing QP. + */ +ibt_status_t ibt_free_qp(ibt_qp_hdl_t ibt_qp); + + +/* + * ibt_query_qp() + * Query the attributes of an existing QP. + */ +ibt_status_t ibt_query_qp(ibt_qp_hdl_t ibt_qp, ibt_qp_query_attr_t *qp_attrp); + + +/* + * ibt_modify_qp() + * Modify the attributes of an existing QP. + */ +ibt_status_t ibt_modify_qp(ibt_qp_hdl_t ibt_qp, ibt_cep_modify_flags_t flags, + ibt_qp_info_t *qp_attr, ibt_queue_sizes_t *actual_sz); + +/* + * ibt_set_qp_private(), ibt_get_qp_private() + * Set/Get the client private data. + */ +void ibt_set_qp_private(ibt_qp_hdl_t ibt_qp, void *clnt_private); +void *ibt_get_qp_private(ibt_qp_hdl_t ibt_qp); + + +/* + * ibt_qp_to_hca_guid + * A helper function to retrieve HCA GUID for the specified QP. + */ +ib_guid_t ibt_qp_to_hca_guid(ibt_qp_hdl_t ibt_qp); + + +/* + * ibt_recover_ud_qp() + * Recover an UD QP which has transitioned to SQ Error state. The + * ibt_recover_ud_qp() transitions the QP from SQ Error state to + * Ready-To-Send QP state. + * + * If a work request posted to a UD QP's send queue completes with + * an error (see ibt_wc_status_t), the QP gets transitioned to SQ + * Error state. In order to reuse this QP, ibt_recover_ud_qp() can + * be used to recover the QP to a usable (Ready-to-Send) state. + */ +ibt_status_t ibt_recover_ud_qp(ibt_qp_hdl_t ibt_qp); + + +/* + * Datagram Domain Functions + */ + +/* + * ibt_ud_get_dqpn + * Finds the destination QPN at the specified destination that the + * specified service can be reached on. The IBTF CM initiates the + * service ID resolution protocol (SIDR) to determine a destination QPN. + */ +ibt_status_t ibt_ud_get_dqpn(ibt_ud_dest_attr_t *attr, + ibt_execution_mode_t mode, ibt_ud_returns_t *returns); + +/* + * ibt_get_module_failure() + * + * Used to obtain a special IBTF failure code for IB module specific + * failures, i.e. failures other than those defined in ibt_status_t. + */ +ibt_status_t ibt_get_module_failure(ibt_failure_type_t type, uint64_t ena); + +ibt_status_t ibt_ofuvcm_get_req_data(void *, ibt_ofuvcm_req_data_t *); + +ibt_status_t ibt_ofuvcm_proceed(ibt_cm_event_type_t, void *, + ibt_cm_status_t, ibt_cm_proceed_reply_t *, void *, + ibt_priv_data_len_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IBVTI_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/ibtl/impl/ibtl_util.h b/illumos-x86_64/usr/include/sys/ib/ibtl/impl/ibtl_util.h new file mode 100644 index 00000000..c49b06a0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/ibtl/impl/ibtl_util.h @@ -0,0 +1,160 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2019, Joyent, Inc. + */ + +#ifndef _SYS_IB_IBTL_IMPL_IBTL_UTIL_H +#define _SYS_IB_IBTL_IMPL_IBTL_UTIL_H + +/* + * ibtl_util.h + * + * All data structures and function prototypes that serve as helper + * routines for IBTF implementation. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Time Related Functions + * + * ibt_usec2ib + * This function converts the standard input time in microseconds to + * IB's 6 bits of timeout exponent, calculated based on + * time = 4.096us * 2 ^ exp. + * + * ibt_ib2usec + * This function converts the input IB timeout exponent (6 bits) to + * standard time in microseconds, calculated based on + * time = 4.096us * 2 ^ exp. + */ +ib_time_t ibt_usec2ib(clock_t microsecs); +clock_t ibt_ib2usec(ib_time_t ib_time); + + +/* + * IB logging, debug and console message handling + */ + + +/* + * warnings, console & syslog buffer. + * For Non recoverable or Major Errors + */ +#define IBTF_LOG_L0 0 + +/* + * syslog buffer or IBTF trace buffer (console if booted /w debug) + * For additional information on Non recoverable errors and + * warnings/informational message for sys-admin types. + */ +#define IBTF_LOG_L1 1 + +/* + * debug only + * for more verbose trace than L1, for e.g. recoverable errors, + * or intersting trace + */ +#define IBTF_LOG_L2 2 + +/* + * debug only + * for more verbose trace than L2, for e.g. printing function entries.... + */ +#define IBTF_LOG_L3 3 + +/* + * debug only + * for more verbose trace than L3, for e.g. printing minor function entries... + */ +#define IBTF_LOG_L4 4 + +/* + * debug only + * most verbose level. Used only for excessive trace, for e.g. + * printing structures etc. + */ +#define IBTF_LOG_L5 5 + +/* + * debug only + * for messages from softints, taskqs, intr handlers, timeout handlers etc. + * Only gets printed if "ibtl_allow_intr_msgs" is set + */ +#define IBTF_LOG_LINTR 6 + + +#ifdef DEBUG +#define IBTF_DPRINTF_LINTR ibtl_dprintf_intr +#define IBTF_DPRINTF_L5 ibtl_dprintf5 +#define IBTF_DPRINTF_L4 ibtl_dprintf4 +#define IBTF_DPRINTF_L3 ibtl_dprintf3 + +void ibtl_dprintf_intr( + char *name, + char *fmt, ...); +void ibtl_dprintf5( + char *name, + char *fmt, ...); +void ibtl_dprintf4( + char *name, + char *fmt, ...); +void ibtl_dprintf3( + char *name, + char *fmt, ...); +#else +#define IBTF_DPRINTF_LINTR(...) (void)(0) +#define IBTF_DPRINTF_L5(...) (void)(0) +#define IBTF_DPRINTF_L4(...) (void)(0) +#define IBTF_DPRINTF_L3(...) (void)(0) +#endif + +#define IBTF_DPRINTF_L2 ibtl_dprintf2 +#define IBTF_DPRINTF_L1 ibtl_dprintf1 +#define IBTF_DPRINTF_L0 ibtl_dprintf0 + +void ibtl_dprintf2( + char *name, + char *fmt, ...); +void ibtl_dprintf1( + char *name, + char *fmt, ...); +void ibtl_dprintf0( + char *name, + char *fmt, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_IBTL_IMPL_IBTL_UTIL_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/mgt/ib_dm_attr.h b/illumos-x86_64/usr/include/sys/ib/mgt/ib_dm_attr.h new file mode 100644 index 00000000..0dfc84ae --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/mgt/ib_dm_attr.h @@ -0,0 +1,174 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_MGT_IB_DM_ATTR_H +#define _SYS_IB_MGT_IB_DM_ATTR_H + +/* + * ib_dm_attr.h + * + * This file contains definitions for Device Management data structures + * defined in the IB specification (Section 16.3). + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Device management Methods */ +#define IB_DM_DEVMGT_METHOD_GET 0x01 +#define IB_DM_DEVMGT_METHOD_SET 0x02 +#define IB_DM_DEVMGT_METHOD_GET_RESP 0x81 +#define IB_DM_DEVMGT_METHOD_TRAP 0x05 +#define IB_DM_DEVMGT_METHOD_TRAP_REPRESS 0x07 + +/* Device Class version */ +#define IB_DM_CLASS_VERSION_1 0x1 + +/* Device Management Status field */ +#define IB_DM_DEVMGT_MAD_STAT_NORESP 0x0100 +#define IB_DM_DEVMGT_MAD_STAT_NOSVC_ENTRIES 0x0200 +#define IB_DM_DEVMGT_MAD_STAT_GEN_FAILURE 0x8000 + +/* Device Management attributes */ +#define IB_DM_ATTR_CLASSPORTINFO 0x1 +#define IB_DM_ATTR_NOTICE 0x2 +#define IB_DM_ATTR_IO_UNITINFO 0x10 +#define IB_DM_ATTR_IOC_CTRL_PROFILE 0x11 +#define IB_DM_ATTR_SERVICE_ENTRIES 0x12 +#define IB_DM_ATTR_DIAG_TIMEOUT 0x20 +#define IB_DM_ATTR_PREPARE_TO_TEST 0x21 +#define IB_DM_ATTR_TEST_DEV_ONCE 0x22 +#define IB_DM_ATTR_TEST_DEV_LOOP 0x23 +#define IB_DM_ATTR_DIAG_CODE 0x24 + +/* IOUnitInfo DM attribute (Section 16.3.3.3 in vol1a) definition */ +#define IB_DM_MAX_IOCS_IN_IOU 256 + +typedef struct ib_dm_io_unitinfo_s { + /* Incremented, with rollover, by any change in the controller list */ + uint16_t iou_changeid; + uint8_t iou_num_ctrl_slots; /* # controllers in the IOU */ + + /* + * Bit 0 : Option ROM present + * Bit 1 : Diag Device ID + */ + uint8_t iou_flag; + + /* + * List of nibbles representing a slot in the IOU + * Contains iou_num_ctrl_slots valid entries + * 0x0 = IOC not installed + * 0x1 = IOC present + * 0xf = Slot does not exist + * Note: Bits 7-4 of the first byte represent slot 1 and + * bits 3-0 of first byte represents slot 2, bits 7-4 of + * second byte represents slot 3, and so on + */ + uint8_t iou_ctrl_list[128]; +} ib_dm_io_unitinfo_t; + +/* values for iou_flag */ +#define IB_DM_IOU_OPTIONROM_ABSENT 0x0 +#define IB_DM_IOU_OPTIONROM_PRESENT 0x1 + +/* masks for iou_flag */ +#define IB_DM_IOU_OPTIONROM_MASK 0x1 +#define IB_DM_IOU_DEVICEID_MASK 0x2 + +#define IB_DM_IOC_ID_STRING_LEN 64 /* see ioc_id_string later */ +#define IB_DM_VENDORID_MASK 0xFFFFFF00 +#define IB_DM_VENDORID_SHIFT 8 + +typedef struct ib_dm_ioc_ctrl_profile_s { + ib_guid_t ioc_guid; /* GUID of the IOC */ + uint32_t ioc_vendorid; /* Vendor ID of the IOC */ + uint32_t ioc_deviceid; /* Device ID/Product ID */ + uint16_t ioc_device_ver; /* Device Version */ + uint16_t ioc_rsvd1; /* RESERVED */ + uint32_t ioc_subsys_vendorid; /* Subsystem vendor ID */ + uint32_t ioc_subsys_id; /* Subsystem ID */ + uint16_t ioc_io_class; /* I/O Class */ + uint16_t ioc_io_subclass; /* I/O Sub Class */ + uint16_t ioc_protocol; /* Type of protocol */ + uint16_t ioc_protocol_ver; /* Protocol version */ + uint16_t ioc_rsvd2; /* RESERVED */ + uint16_t ioc_rsvd3; /* RESERVED */ + uint16_t ioc_send_msg_qdepth; /* Send message Q depth */ + uint8_t ioc_rsvd4; /* RESERVED */ + uint8_t ioc_rdma_read_qdepth; /* RDMA read Q depth */ + uint32_t ioc_send_msg_sz; /* Send message Size */ + uint32_t ioc_rdma_xfer_sz; /* RDMA transfer size */ + uint8_t ioc_ctrl_opcap_mask; /* Ctrl operations */ + /* capability mask */ + uint8_t ioc_rsvd5; /* RESERVED */ + uint8_t ioc_service_entries; /* Number of service entries */ + uint8_t ioc_rsvd6[9]; /* RESERVED */ + uint8_t ioc_id_string[IB_DM_IOC_ID_STRING_LEN]; + /* ID string, UTF-8 format */ +} ib_dm_ioc_ctrl_profile_t; + +/* I/O class definitions as defined in the I/O annex A0 Table 4 */ +#define IB_DM_IO_CLASS_VENDOR_SPECIFIC 0xFFFF +#define IB_DM_IO_CLASS_NONE 0x00FF +#define IB_DM_IO_CLASS_STORAGE 0x10FF +#define IB_DM_IO_CLASS_NETWORK 0x20FF +#define IB_DM_IO_CLASS_VEDIO_MULTIMEDIA 0x40FF +#define IB_DM_IO_CLASS_UNKNOWN_OR_MULTIPLE 0xF0FF +#define IB_DM_IO_SUBCLASS_VENDOR_SPECIFIC 0xFFFF + +/* Controller Capability Mask values */ +#define IB_DM_CTRL_CAP_MASK_ST 0x0 +#define IB_DM_CTRL_CAP_MASK_SF 0x1 +#define IB_DM_CTRL_CAP_MASK_RT 0x2 +#define IB_DM_CTRL_CAP_MASK_RF 0x3 +#define IB_DM_CTRL_CAP_MASK_WT 0x4 +#define IB_DM_CTRL_CAP_MASK_WF 0x5 +#define IB_DM_CTRL_CAP_MASK_AT 0x6 +#define IB_DM_CTRL_CAP_MASK_AF 0x7 + +/* Controller Service Capability Mask */ +#define IB_DM_CTRL_SRVC_MASK_CS 0x0 +#define IB_DM_CTRL_SRVC_MASK_SBWP 0x1 +#define IB_DM_CTRL_SRVC_MASK_NBWP 0x2 + +/* Definition for service entry table 219, 16.3.3.5 */ +#define IB_DM_MAX_SVC_ENTS_PER_REQ 4 +#define IB_DM_MAX_SVC_NAME_LEN 40 +#define IB_DM_MAX_SVC_ENTRIES 0x100 + +typedef struct ib_dm_srv_s { + /* Service name string in UTF-8 format */ + uint8_t srv_name[IB_DM_MAX_SVC_NAME_LEN]; + ib_svc_id_t srv_id; /* Service Identifier */ +} ib_dm_srv_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_MGT_IB_DM_ATTR_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/mgt/ib_mad.h b/illumos-x86_64/usr/include/sys/ib/mgt/ib_mad.h new file mode 100644 index 00000000..68a55af4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/mgt/ib_mad.h @@ -0,0 +1,278 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_MGT_IB_MAD_H +#define _SYS_IB_MGT_IB_MAD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define MAD_SIZE_IN_BYTES 256 + +typedef struct _ib_mad_hdr_t { + uint8_t BaseVersion; /* version of MAD base format */ + uint8_t MgmtClass; /* class of operation */ + uint8_t ClassVersion; /* ver. of MAD class format */ + uint8_t R_Method; /* response bit & method to */ + /* perform based on mgmtclass */ + uint16_t Status; /* status of operation */ + uint16_t ClassSpecific; /* reserved except for SMPs */ + uint64_t TransactionID; /* transaction id */ + uint16_t AttributeID; /* defines class spec objects */ + uint16_t Reserved; + uint32_t AttributeModifier; /* further scope to attrs. */ +} ib_mad_hdr_t; + +#define MAD_CLASS_BASE_VERS_1 1 + +/* Defines and Masks that go with MAD header */ +#define MAD_MGMT_CLASS_SUBN_LID_ROUTED 0x01 +#define MAD_MGMT_CLASS_SUBN_DIRECT_ROUTE 0x81 +#define MAD_MGMT_CLASS_SUBN_ADM 0x03 +#define MAD_MGMT_CLASS_PERF 0x04 +#define MAD_MGMT_CLASS_BM 0x05 +#define MAD_MGMT_CLASS_DEV_MGT 0x06 +#define MAD_MGMT_CLASS_COMM_MGT 0x07 +#define MAD_MGMT_CLASS_SNMP 0x08 +#define MAD_MGMT_CLASS_VENDOR_START 0x09 +#define MAD_MGMT_CLASS_VENDOR_END 0x0F +#define MAD_MGMT_CLASS_VENDOR2_START 0x30 +#define MAD_MGMT_CLASS_VENDOR2_END 0x4F +#define MAD_MGMT_CLASS_APPLICATION_START 0x10 +#define MAD_MGMT_CLASS_APPLICATION_END 0x2F +#define MAD_RESPONSE_BIT 0x80 +#define MAD_RESPONSE_BIT_MASK 0x80 +#define MAD_METHOD_MASK 0x7F +#define MAD_METHOD_GET 0x01 +#define MAD_METHOD_SET 0x02 +#define MAD_METHOD_GET_RESPONSE 0x81 +#define MAD_METHOD_SEND 0x03 +#define MAD_METHOD_TRAP 0x05 +#define MAD_METHOD_REPORT 0x06 +#define MAD_METHOD_REPORT_RESPONSE 0x86 +#define MAD_METHOD_TRAP_REPRESS 0x07 +#define MAD_STATUS_BUSY 0x01 +#define MAD_STATUS_REDIRECT_REQUIRED 0x02 +#define MAD_STATUS_NO_INVALID_FIELDS 0x00 +#define MAD_STATUS_BAD_VERSION 0x04 +#define MAD_STATUS_UNSUPP_METHOD 0x08 +#define MAD_STATUS_UNSUPP_METHOD_ATTR 0x0C +#define MAD_STATUS_INVALID_FIELD 0x1C +#define MAD_ATTR_ID_CLASSPORTINFO 0x01 +#define MAD_ATTR_ID_NOTICE 0x02 +#define MAD_ATTR_ID_INFORMINFO 0x03 + +/* ClassPortInfo: table 104 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct ib_mad_classportinfo_s { + uint8_t BaseVersion; /* ver. of MAD base format */ + uint8_t ClassVersion; /* ver. of MAD class format */ + uint16_t CapabilityMask; /* capabilities of this class */ + uint32_t RespTimeValue; /* max time btwn req and resp */ + /* (lower 5 bit field, upper */ + /* 27 bits are reserved) */ + uint64_t RedirectGID_hi; /* dest gid of redirect msgs */ + uint64_t RedirectGID_lo; /* dest gid of redirect msgs */ + uint32_t RedirectTC :8; /* traffic class */ + uint32_t RedirectSL :4; /* SL to access services */ + uint32_t RedirectFL :20; /* flow label to use */ + ib_lid_t RedirectLID; /* dlid for class services */ + ib_pkey_t RedirectP_Key; /* p_key for class services */ + uint32_t Reserved2 :8; + uint32_t RedirectQP :24; /* QP for class services */ + ib_qkey_t RedirectQ_Key; /* q_key for class services */ + uint64_t TrapGID_hi; /* dest gid of trap msgs */ + uint64_t TrapGID_lo; /* dest gid of trap msgs */ + uint32_t TrapTC :8; /* traffic class for traps */ + uint32_t TrapSL :4; /* SL for traps */ + uint32_t TrapFL :20; /* flow label for traps */ + ib_lid_t TrapLID; /* dlid for traps */ + ib_pkey_t TrapP_Key; /* p_key for traps */ + uint32_t TrapHL :8; /* hop limit for traps */ + uint32_t TrapQP :24; /* QP for traps */ + ib_qkey_t TrapQ_Key; /* q_key for traps */ +} ib_mad_classportinfo_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct ib_mad_classportinfo_s { + uint8_t BaseVersion; /* ver. of MAD base format */ + uint8_t ClassVersion; /* ver. of MAD class format */ + uint16_t CapabilityMask; /* capabilities of this class */ + uint32_t RespTimeValue; /* max time btwn req and resp */ + /* (lower 5 bit field, upper */ + /* 27 bits are reserved) */ + uint64_t RedirectGID_hi; /* dest gid of redirect msgs */ + uint64_t RedirectGID_lo; /* dest gid of redirect msgs */ + uint32_t RedirectFL :20; /* flow label to use */ + uint32_t RedirectSL :4; /* SL to access services */ + uint32_t RedirectTC :8; /* traffic class */ + ib_lid_t RedirectLID; /* dlid for class services */ + ib_pkey_t RedirectP_Key; /* p_key for class services */ + uint32_t RedirectQP :24; /* QP for class services */ + uint32_t Reserved2 :8; + ib_qkey_t RedirectQ_Key; /* q_key for class services */ + uint64_t TrapGID_hi; /* dest gid of trap msgs */ + uint64_t TrapGID_lo; /* dest gid of trap msgs */ + uint32_t TrapFL :20; /* flow label for traps */ + uint32_t TrapSL :4; /* SL for traps */ + uint32_t TrapTC :8; /* traffic class for traps */ + ib_lid_t TrapLID; /* dlid for traps */ + ib_pkey_t TrapP_Key; /* p_key for traps */ + uint32_t TrapQP :24; /* QP for traps */ + uint32_t TrapHL :8; /* hop limit for traps */ + ib_qkey_t TrapQ_Key; /* q_key for traps */ +} ib_mad_classportinfo_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +#define MAD_CLASSPORTINFO_CAP_MASK_TRAPS 0x01 +#define MAD_CLASSPORTINFO_CAP_MASK_NOTICES 0x02 + +/* + * Trap/Notice: Table 105 + */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct ib_mad_notice_s { + uint32_t IsGeneric :1; /* is generic or vendor spec. */ + uint32_t Type :7; /* type of the trap */ + + /* if generic, indicates type of event's producer, else vendor id */ + uint32_t ProducerType_VendorID:24; + + uint16_t TrapNumber_DeviceID; /* trap num or device id */ + uint16_t IssuerLID; /* generator's LID */ + uint16_t NoticeToggle :1; /* alt 0/1 between notices */ + uint16_t NoticeCount :15; /* num notices queued */ + uint8_t DataDetails[54]; /* notice/dtrap data details */ + ib_gid_t IssuerGID; /* GID of issuer port */ +} ib_mad_notice_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct ib_mad_notice_s { + /* if generic, indicates type of event's producer, else vendor id */ + uint32_t ProducerType_VendorID:24; + + uint32_t Type :7; /* type of the trap */ + uint32_t IsGeneric :1; /* is generic or vendor spec. */ + + uint16_t TrapNumber_DeviceID; /* trap num or device id */ + uint16_t IssuerLID; /* generator's LID */ + uint16_t NoticeCount :15; /* num notices queued */ + uint16_t NoticeToggle :1; /* alt 0/1 between notices */ + uint8_t DataDetails[54]; /* notice/dtrap data details */ + ib_gid_t IssuerGID; /* GID of issuer port */ +} ib_mad_notice_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +#define MAD_NOTICE_IS_GENERIC 0x1 + +#define MAD_NOTICE_TYPE_FATAL 0x0 +#define MAD_NOTICE_TYPE_URGENT 0x1 +#define MAD_NOTICE_TYPE_SECURITY 0x2 +#define MAD_NOTICE_TYPE_SUBNET_MGMT 0x3 +#define MAD_NOTICE_TYPE_INFO 0x4 + +#define MAD_NOTICE_NODETYPE_CA 0x1 +#define MAD_NOTICE_NODETYPE_SWITCH 0x2 +#define MAD_NOTICE_NODETYPE_ROUTER 0x3 +#define MAD_NOTICE_NODETYPE_SUBNET_MANAGEMENT 0x4 + +#define MAD_NOTICE_TRAP_NUMBER_RESERVED 0xFFFF + +/* InformInfo: Table 106 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct ib_mad_informinfo_s { + ib_gid_t GID; /* specific GID to sub. for */ + ib_lid_t LIDRangeBegin; /* lowest LID to sub. for */ + ib_lid_t LIDRangeEnd; /* highest LID to sub. for */ + uint16_t Reserved; + uint8_t IsGeneric; /* forward generic traps */ + uint8_t Subscribe; /* 1 subscribe, 0 unsubscribe */ + uint16_t Type; /* type of trap */ + uint16_t TrapNumber_DeviceID; /* trap num or device id */ + uint32_t QPN :24; /* queue pair for results */ + uint32_t Reserved2 :3; + uint32_t RespTimeValue :5; /* response time value */ + uint32_t Reserved3 :8; + uint32_t ProducerType_VendorID:24; /* type of event's producer */ +} ib_mad_informinfo_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct ib_mad_informinfo_s { + ib_gid_t GID; /* specific GID to sub. for */ + ib_lid_t LIDRangeBegin; /* lowest LID to sub. for */ + ib_lid_t LIDRangeEnd; /* highest LID to sub. for */ + uint16_t Reserved; + uint8_t IsGeneric; /* forward generic traps */ + uint8_t Subscribe; /* 1 subscribe, 0 unsubscribe */ + uint16_t Type; /* type of trap */ + uint16_t TrapNumber_DeviceID; /* trap num or device id */ + uint32_t RespTimeValue :5; /* response time value */ + uint32_t Reserved2 :3; + uint32_t QPN :24; /* queue pair for results */ + uint32_t ProducerType_VendorID:24; /* type of event's producer */ + uint32_t Reserved3 :8; +} ib_mad_informinfo_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +#define MAD_INFORMINFO_ALL_ENDPORTS_RANGE 0xFFFF + +#define MAD_INFORMINFO_FORWARD_GENERIC 0x1 +#define MAD_INFORMINFO_FORWARD_VENDOR_SPECIFIC 0x0 + +#define MAD_INFORMINFO_SUBSCRIBE 0x1 +#define MAD_INFORMINFO_UNSUBSCRIBE 0x0 + +#define MAD_INFORMINFO_TRAP_NUMBER_FORWARD_ALL 0xFFFF + +#define MAD_INFORMINFO_TRAP_TYPE_FATAL 0x0 +#define MAD_INFORMINFO_TRAP_TYPE_URGENT 0x1 +#define MAD_INFORMINFO_TRAP_TYPE_SECURITY 0x2 +#define MAD_INFORMINFO_TRAP_TYPE_SUBNET_MGMT 0x3 +#define MAD_INFORMINFO_TRAP_TYPE_INFORM 0x4 +#define MAD_INFORMINFO_TRAP_TYPE_FORWARD_ALL 0xFFFF + +#define MAD_INFORMINFO_NODETYPE_CA 0x1 +#define MAD_INFORMINFO_NODETYPE_SWITCH 0x2 +#define MAD_INFORMINFO_NODETYPE_ROUTER 0x3 +#define MAD_INFORMINFO_NODETYPE_SUBNET_MANAGEMENT 0x4 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_MGT_IB_MAD_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf.h b/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf.h new file mode 100644 index 00000000..dcbe6631 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf.h @@ -0,0 +1,1007 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_MGT_IBMF_IBMF_H +#define _SYS_IB_MGT_IBMF_IBMF_H + +/* + * This file defines the IBMF client interface. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include + +/* IBMF API function return values */ +#define IBMF_SUCCESS 0 /* successful call */ +#define IBMF_FAILURE -1 /* ibmf internal error */ +#define IBMF_PORT_IN_USE -2 /* class already registered */ +#define IBMF_BAD_CLASS -3 /* bad class specified */ +#define IBMF_BAD_HANDLE -4 /* bad ibmf handle */ +#define IBMF_BAD_QP_HANDLE -5 /* bad QP handle */ +#define IBMF_BAD_NODE -6 /* bad node specified to reg */ +#define IBMF_BAD_PORT -7 /* bad port specified to reg */ +#define IBMF_BAD_PORT_STATE -8 /* port in incorrect state */ +#define IBMF_BAD_VERSION -9 /* bad IBMF version */ +#define IBMF_BAD_FLAGS -10 /* bad IBMF flags */ +#define IBMF_BAD_SIZE -11 /* bad data size in message */ +#define IBMF_BAD_RMPP_OPT -12 /* more than one class used */ +#define IBMF_BUSY -13 /* resources held by client */ +#define IBMF_NO_RESOURCES -14 /* no resources */ +#define IBMF_NOT_SUPPORTED -15 /* function not supported */ +#define IBMF_PARTIAL_TRANSFER -16 /* excess response data */ +#define IBMF_UNEXP_TRANS_RECVD -17 /* unexpected trans received */ +#define IBMF_TRANS_TIMEOUT -18 /* transaction timed out */ +#define IBMF_TRANS_FAILURE -19 /* transaction failure */ +#define IBMF_NO_MEMORY -20 /* could not alloc memory */ +#define IBMF_REQ_INVALID -21 /* request was invalid */ +#define IBMF_NO_RECORDS -22 /* no records match query */ +#define IBMF_TOO_MANY_RECORDS -23 /* too many recs match query */ +#define IBMF_INVALID_GID -24 /* invalid gid in sa request */ +#define IBMF_INSUFF_COMPS -25 /* insufficient components */ +#define IBMF_UNSUPP_METHOD -26 /* unsupported method */ +#define IBMF_UNSUPP_METHOD_ATTR -27 /* unsupp. method/attrbute */ +#define IBMF_INVALID_FIELD -28 /* invalid field in MAD */ +#define IBMF_INVALID_ARG -29 /* invalid function argument */ +#define IBMF_CB_REGISTERED -30 /* callback already regd */ +#define IBMF_CB_NOT_REGISTERED -31 /* callback not registered */ +#define IBMF_TRANSPORT_FAILURE -32 /* a transport call failed */ +#define IBMF_TID_IN_USE -33 /* client's TID in use */ + +/* flags to ibmf_alloc_msg() */ +#define IBMF_ALLOC_SLEEP 0 +#define IBMF_ALLOC_NOSLEEP 1 + +/* + * IBMF version + */ +#define IBMF_VERSION 1 + +typedef struct _ibmf_handle_dummy *ibmf_handle_t; + +typedef struct _ibmf_qp_dummy *ibmf_qp_handle_t; + +/* + * IBMF default QP handles + */ +#define IBMF_QP_HANDLE_DEFAULT (ibmf_qp_handle_t)0 + +/* + * ir_client_type + */ +typedef enum _ibmf_client_type_t { + SUBN_AGENT = 0x00010001, + SUBN_MANAGER = 0x00020001, + SUBN_ADM_AGENT = 0x00010003, + SUBN_ADM_MANAGER = 0x00020003, + PERF_AGENT = 0x00010004, + PERF_MANAGER = 0x00020004, + BM_AGENT = 0x00010005, + BM_MANAGER = 0x00020005, + DEV_MGT_AGENT = 0x00010006, + DEV_MGT_MANAGER = 0x00020006, + COMM_MGT_MANAGER_AGENT = 0x00030007, + SNMP_MANAGER_AGENT = 0x00030008, + VENDOR_09_MANAGER_AGENT = 0x00030009, + VENDOR_0A_MANAGER_AGENT = 0x0003000A, + VENDOR_0B_MANAGER_AGENT = 0x0003000B, + VENDOR_0C_MANAGER_AGENT = 0x0003000C, + VENDOR_0D_MANAGER_AGENT = 0x0003000D, + VENDOR_0E_MANAGER_AGENT = 0x0003000E, + VENDOR_0F_MANAGER_AGENT = 0x0003000F, + VENDOR_30_MANAGER_AGENT = 0x00030030, + VENDOR_31_MANAGER_AGENT = 0x00030031, + VENDOR_32_MANAGER_AGENT = 0x00030032, + VENDOR_33_MANAGER_AGENT = 0x00030033, + VENDOR_34_MANAGER_AGENT = 0x00030034, + VENDOR_35_MANAGER_AGENT = 0x00030035, + VENDOR_36_MANAGER_AGENT = 0x00030036, + VENDOR_37_MANAGER_AGENT = 0x00030037, + VENDOR_38_MANAGER_AGENT = 0x00030038, + VENDOR_39_MANAGER_AGENT = 0x00030039, + VENDOR_3A_MANAGER_AGENT = 0x0003003A, + VENDOR_3B_MANAGER_AGENT = 0x0003003B, + VENDOR_3C_MANAGER_AGENT = 0x0003003C, + VENDOR_3D_MANAGER_AGENT = 0x0003003D, + VENDOR_3E_MANAGER_AGENT = 0x0003003E, + VENDOR_3F_MANAGER_AGENT = 0x0003003F, + VENDOR_40_MANAGER_AGENT = 0x00030040, + VENDOR_41_MANAGER_AGENT = 0x00030041, + VENDOR_42_MANAGER_AGENT = 0x00030042, + VENDOR_43_MANAGER_AGENT = 0x00030043, + VENDOR_44_MANAGER_AGENT = 0x00030044, + VENDOR_45_MANAGER_AGENT = 0x00030045, + VENDOR_46_MANAGER_AGENT = 0x00030046, + VENDOR_47_MANAGER_AGENT = 0x00030047, + VENDOR_48_MANAGER_AGENT = 0x00030048, + VENDOR_49_MANAGER_AGENT = 0x00030049, + VENDOR_4A_MANAGER_AGENT = 0x0003004A, + VENDOR_4B_MANAGER_AGENT = 0x0003004B, + VENDOR_4C_MANAGER_AGENT = 0x0003004C, + VENDOR_4D_MANAGER_AGENT = 0x0003004D, + VENDOR_4E_MANAGER_AGENT = 0x0003004E, + VENDOR_4F_MANAGER_AGENT = 0x0003004F, + APPLICATION_10_MANAGER_AGENT = 0x00030010, + APPLICATION_11_MANAGER_AGENT = 0x00030011, + APPLICATION_12_MANAGER_AGENT = 0x00030012, + APPLICATION_13_MANAGER_AGENT = 0x00030013, + APPLICATION_14_MANAGER_AGENT = 0x00030014, + APPLICATION_15_MANAGER_AGENT = 0x00030015, + APPLICATION_16_MANAGER_AGENT = 0x00030016, + APPLICATION_17_MANAGER_AGENT = 0x00030017, + APPLICATION_18_MANAGER_AGENT = 0x00030018, + APPLICATION_19_MANAGER_AGENT = 0x00030019, + APPLICATION_1A_MANAGER_AGENT = 0x0003001A, + APPLICATION_1B_MANAGER_AGENT = 0x0003001B, + APPLICATION_1C_MANAGER_AGENT = 0x0003001C, + APPLICATION_1D_MANAGER_AGENT = 0x0003001D, + APPLICATION_1E_MANAGER_AGENT = 0x0003001E, + APPLICATION_1F_MANAGER_AGENT = 0x0003001F, + APPLICATION_20_MANAGER_AGENT = 0x00030020, + APPLICATION_21_MANAGER_AGENT = 0x00030021, + APPLICATION_22_MANAGER_AGENT = 0x00030022, + APPLICATION_23_MANAGER_AGENT = 0x00030023, + APPLICATION_24_MANAGER_AGENT = 0x00030024, + APPLICATION_25_MANAGER_AGENT = 0x00030025, + APPLICATION_26_MANAGER_AGENT = 0x00030026, + APPLICATION_27_MANAGER_AGENT = 0x00030027, + APPLICATION_28_MANAGER_AGENT = 0x00030028, + APPLICATION_29_MANAGER_AGENT = 0x00030029, + APPLICATION_2A_MANAGER_AGENT = 0x0003002A, + APPLICATION_2B_MANAGER_AGENT = 0x0003002B, + APPLICATION_2C_MANAGER_AGENT = 0x0003002C, + APPLICATION_2D_MANAGER_AGENT = 0x0003002D, + APPLICATION_2E_MANAGER_AGENT = 0x0003002E, + APPLICATION_2F_MANAGER_AGENT = 0x0003002F, + UNIVERSAL_CLASS = 0x00040001 +} ibmf_client_type_t; + +/* + * ibmf_retrans_t data type is used to specify the maximum values + * of the retransmission parameters, number of retries, + * response time value, round trip travel time, and transaction timeout. + * + * The retries value must be provided by the client + * for all the transaction types enumerated by ibmf_trans_t. + * The retries value will be used to retry any section of + * the underlying transmission and reception protocol that + * are time bound by timers. + * + * The response time value must be specified for all transaction types except an + * unsequenced, non-RMPP send (see the table below). + * The response time value is the length of processing time for the + * responder to process the requested transaction, from the point of receiving + * the last request packet, to the point of returning the first response packet. + * This value is interpreted in microseconds. + * If the response time value is zero, an implementation default is used. + * + * The round trip time must be specified for all transaction types except an + * unsequenced, non-RMPP send (see the table below). + * The round trip travel time is the maximum time it should take a packet + * to travel from the requester to the responder and back to the requester. + * This value does not include the processing time at the responder. + * This value is interpreted in microseconds. + * If the round trip time value is zero, an implementation default is used. + * + * The transaction timeout should be specified for all transactions + * using RMPP to receive a message. + * Since, it is not possible for the client to know the size of the + * response, IBMF will calculate a reasonable transaction timeout after + * receiving the first RMPP data packet of the response at which time the + * size of the message will be known. If this value is greater than the + * client's transaction timeout parameter the client's value will be used. + * If the client's transaction timeout parameter is 0 the calculated value will + * be used. + * This value is interpreted in microseconds. + * If the transaction timeout value is zero, an implementation default is used. + * + * See Section 13.6.3.1, of the InfiniBand Architecture Specification, + * Volume 1, Release 1.1 for details on how to deduce this value. + * + * The following table describes the retrans parameters needed for + * the various ibmf_msg_transport() flag combinations. + * + * ibmf_msg_transport() flags retries rtv/rttv trans_to + * No Flags ignored ignored ignored + * Sequenced Flag required required required + * RMPP Flag required required ignored + * RMPP + Sequenced Flags required required optional + */ +typedef struct _ibmf_retrans_t { + uint32_t retrans_retries; /* number of retries */ + uint32_t retrans_rtv; /* response time value */ + uint32_t retrans_rttv; /* round trip travel time */ + uint32_t retrans_trans_to; /* transaction timeout */ +} ibmf_retrans_t; + +typedef struct _ibmf_register_info { + ib_guid_t ir_ci_guid; + uint_t ir_port_num; + ibmf_client_type_t ir_client_class; +} ibmf_register_info_t; + +typedef enum _ibmf_impl_caps { + IBMF_DEF_QP_HDL_P_KEY_ANY = 0x0001, + IBMF_DEF_QP_HDL_Q_KEY_ANY = 0x0002, + IBMF_NON_DEF_QP_HDL_P_KEY_ANY = 0x0004, + IBMF_NON_DEF_QP_HDL_Q_KEY_ANY = 0x0008 +} ibmf_impl_caps_t; + + +/* + * Defines for channel interface events. + * IBMF_CI_OFFLINE : + * Indication to the client that it must cease all ibmf activity + * (after any current activity has terminated). The client must + * release all ibmf resources and unregister from ibmf prior to + * returning from the callback. + * + * NOTE1: It is expected that there will exist some higher level + * management entity that will "wake up" the ibmf client once + * the CI is available. The ibmf client may then register with the + * available CI's nodeguid and portnumber. + * + * NOTE2: callback implementors must handle the case where the + * callback is invoked AFTER the ibmf resources have been freed by + * another thread. + */ +typedef enum ibmf_async_event_e { + IBMF_CI_OFFLINE = 0x1 +} ibmf_async_event_t; + +/* + * ibmf_async_event_cb_t(): + * IBMF's callback to clients to inform them of events such as + * the ibmf services temporarily suspending or resuming. + * This notification mechanism covers all asynchronous events + * of interest that are not related to IB messages. + * + * NOTE: + * It is possible for the callback function to be called before + * ibmf_register() returns. When this happens, the entity doing the + * ibmf_register() may see an ibmf_handle being passed to the + * callback function that it does not recognize. + * + * Input arguments: + * ibmf_handle - Handle to the IBMF interface + * clnt_private - is an opaque handle to client specific data + * event_type - specifies the event type the client is being notified of + * + * Output arguments: + * None + * + * Return values: + * None + */ +typedef void (*ibmf_async_event_cb_t)( + ibmf_handle_t ibmf_handle, + void *clnt_private, + ibmf_async_event_t event_type); + +/* + * ibmf_msg_cb_t(): + * + * This routine type is called by IBMF when an unsolicited message that + * corresponds to one of the class registrants is received. An unsolicited + * message is one that was not allocated by this client for the purpose + * of executing a transaction using the ibmf_msg_transport() call. + * Examples of unsolicited messages are traps, and requests from other + * management entities. + * + * This routine type is also called by IBMF at the end of a transaction + * specified in a call to ibmf_msg_transport(). + * + * When it is called as result of an incoming message: + * + * The recipient is expected to free the ibmf_msg_t passed in by + * calling ibmf_free_msg(); this freeing should be done before the + * client unregisters. + * + * The recipient is expected to not call any routines in the callback + * that may block. + * + * Blocking within the callback is not allowed, but ibmf doesn't enforce + * this. + * + * This routine may be called before ibmf_setup_async_cb() returns. + * + * + * Input arguments: + * Handle to the IBMF interface + * Pointer to the Message sent or received + * Callback arguments, specified at registration time (for async callbacks) + * or specified to ibmf_msg_transport() + * + * Output arguments: + * None + * + * Return values: + * None + */ +typedef void (*ibmf_msg_cb_t)( + ibmf_handle_t ibmf_handle, + ibmf_msg_t *msgp, + void *args); + +/* defines for im_msg_flags */ +#define IBMF_MSG_FLAGS_GLOBAL_ADDRESS 0x00000010 /* has global addr */ + +/* + * ibmf_register(): + * + * An agent needs to register before it can receive any management packets + * and a manager needs to register before it can send/receive any management + * packets. The registration is on a per port of the node basis. + * + * A client can register for one class per call to ibmf_register(). + * The client should set ir_client_class component of the client_info argument + * to the class it wants to register for. + * ibmf_register() will fail if the class is already registered for, + * with the error code IBMF_PORT_IN_USE. + * + * Note that for some classes, the client can register as agent or manager only + * and agent+manager only. An exception to this rule is the UNIVERSAL_CLASS + * described below. + * + * Clients that require to send/receive general UD traffic, + * not limited to MADs, over a UD QP may do so by registering + * with the UNIVERSAL_CLASS client type. + * Unlike the other IBMF client types, any number of clients may + * be simultaneously registered for the UNIVERSAL_CLASS on a port. + * When registered with the UNIVERSAL_CLASS, a client should only use the + * alternate QPs, and never use the default QP handle. + * However, a client registered for any other client type may also use + * the alternate QPs in addition to using the default QP handle. + * IBMF implementations that do not support registration for the UNIVERSAL class + * will return IBMF_NOT_SUPPORTED. + * + * NOTE on usage of qp handles: + * + * Some implementations support specifying any Q_Key and P_Key + * combination when ibmf_qp_handle_t arg is set to IBMF_QP_HANDLE_DEFAULT + * in the call to ibmf_msg_transport() and some implementations allow only + * the default values of Q_Key (0x8001_0000) and P_Key (0xFFFF/0x7FFFF) + * when ibmf_qp_handle_t arg is IBMF_QP_HANDLE_DEFAULT. The client can know + * the behavior supported via ibmf_impl_caps_t arg on successful return from + * ibmf_register(). ibmf_impl_caps_t arg points to a bit mask of the + * capabilities of the platform. If the implementation supports any + * P_Key and/or Q_Key value with IBMF_QP_HANDLE_DEFAULT, then + * IBMF_DEF_QP_HDL_P_KEY_ANY and/or IBMF_DEF_QP_HDL_Q_KEY_ANY will be set in + * ibmf_impl_caps_t. + * + * Some implementations support specifying any P_Key and Q_Key combination on + * a per-request basis when ibmf_qp_handle_t is set to an explicitly allocated + * qp handle (the client specifies the P_Key/Q_Key value in ibmf_addr_info_t + * argument). IBMA indicates this behavior by setting + * IBMF_NON_DEF_QP_HDL_P_KEY_ANY and/or IBMF_NON_DEF_QP_HDL_Q_KEY_ANY in the + * ibmf_impl_caps_t arg. In such an implementation, ibmf_modify_qp() does not + * change anything in the transport and always returns IBMF_SUCCESS. + * + * When the implementation supports IBMF_DEF_QP_HDL_P_KEY_ANY and/or + * IBMF_DEF_QP_HDL_Q_KEY_ANY, it may map IBMF_QP_HANDLE_DEFAULT to any qp + * number(s) supported by the + * underlying transport. The client can not not make any assumptions on this + * mapping nor can it query ibmf for the qp num being used with + * IBMF_QP_HANDLE_DEFAULT. There are cases where the client needs to have + * explicit control over the qp number being used by ibmf (eg., agent + * redirection). The client should explicitly allocate a qp using + * ibmf_alloc_qp() in such cases. + * + * Also, IBMF_QP_HANDLE_DEFAULT can only be used when the class of the MAD + * being sent using ibmf_msg_transport() is the same as the class the client + * registered for. If a client wishes to send a MAD class other than the + * one it registered for, it should explicitly allocate a qp and use that + * qp while sending MADs. + * + * If the implementation supports + * IBMF_DEF_QP_HDL_P_KEY_ANY/IBMF_DEF_QP_HDL_Q_KEY_ANY and/or + * IBMF_NON_DEF_QP_HDL_P_KEY_ANY/IBMF_NON_DEF_QP_HDL_Q_KEY_ANY, it is the + * implementation's responsibility to ensure that the + * requested P_Key and Q_Key can be used by, with in resource limitations, + * concurrent sends. + * + * Clients registering for classes that include an RMPP header in their + * MADs must set the IBMF_REG_FLAG_RMPP flag when registering with IBMF. + * This must be done regardless of whether the client intends to use + * the RMPP protocol or not. The flag is an indicator to IBMF of the + * presence of the RMPP header in the MAD. + * + * IBMF will always insure that receive buffer pointers are offsets into a + * single contiguous buffer of memory. The im_msgbufs_recv.im_bufs_mad_hdr, + * points to the start of the buffer. The other two pointers, + * im_msgbufs_recv.im_bufs_cl_hdr, and im_msgbufs_recv.im_bufs_cl_data, + * will point to class specific offsets within the buffer. + * + * Clients may provide a pointer to a callback function in the client_cb + * argument. Implementations of ibmf that require the client_cb to + * be specified should return IBMF_INVALID_ARG if the client_cb argument + * is NULL. + * + * This interface may block + * + * Input arguments: + * Pointer to client registration information + * Version of the interface (IBMF_VERSION) + * flags - set IBMF_REG_FLAG_RMPP if client supports RMPP MAD + * set IBMF_REG_FLAG_NO_OFFLOAD for requiring that processing + * not be offloaded onto a non-interrupt context thread + * on send completions and receive completions. + * (Processsing will be done in the interrupt context) + * The default is to offload the processing to a + * non-interrupt context thread(s). + * set IBMF_REG_FLAG_SINGLE_OFFLOAD for requiring single + * threaded processing if IBMF_REG_FLAG_NO_OFFLOAD + * is not specified. The default is multi-threaded + * processing. It is an error to set this flag if + * IBMF_REG_FLAG_NO_OFFLOAD is set. + * client_cb - callback to be called for asynchronous events that + * are not related to IB messages + * client_cb_args - opaque pointer to client private data area + * + * Output arguments: + * Handle to the IBMF interface; used in subsequent interactions + * Pointer to ibmf_impl_caps_t; gives capabilities of the platform + * + * Return values: + * IBMF_SUCCESS - registration successful + * IBMF_BAD_VERSION - registration failed due to invalid version + * IBMF_PORT_IN_USE - registration failed - some entity already + * registered for the class on the node/port + * specified. + * IBMF_BAD_CLASS - registration failed - invalid class + * IBMF_BAD_PORT - registration failed - non existent port + * IBMF_BAD_NODE - registration failed - non existent node + * IBMF_BAD_FLAGS - IBMF_REG_FLAG_NO_OFFLOAD is specified with + * IBMF_REG_FLAG_SINGLE_OFFLOAD + * IBMF_INVALID_ARG - registration failed - invalid argument + * IBMF_FAILURE - registration failed - ibmf internal error + * IBMF_NO_RESOURCES - registration failed - not enough resources + * IBMF_TRANSPORT_FAILURE - registration failed - transport call failed + * + */ +int ibmf_register( + ibmf_register_info_t *client_info, + uint_t ibmf_version, + uint_t flags, + ibmf_async_event_cb_t client_cb, + void *client_cb_args, + ibmf_handle_t *ibmf_handle, + ibmf_impl_caps_t *ibmf_impl_features); + +#define IBMF_REG_FLAG_RMPP 0x1 +#define IBMF_REG_FLAG_NO_OFFLOAD 0x2 +#define IBMF_REG_FLAG_SINGLE_OFFLOAD 0x4 + +/* + * ibmf_unregister(): + * + * Unregister a previously established registration. + * + * This interface may block. + * + * The client should free any and all ibmf_msg_t's passed in all + * "receive msg callbacks" before unregistering. Also, the client should + * ensure that it is not trying to send any messages before calling this + * routine. + * + * After successfully returning from this call, ibmf_handle should not be used + * for any further interactions with the IBMF. + * + * Input arguments: + * Handle to the IBMF interface + * flags - unused (should be 0) + * + * Output arguments: + * Handle to the IBMF interface; will be invalidated following + * this call. + * + * Return values: + * IBMF_SUCCESS - unregistration successful + * IBMF_BAD_HANDLE - unregistration failed - invalid handle + * passed in. + * IBMF_BUSY - unregistration failed - client has not + * freed all the resources (ibmf_msg_t's etc) + * allocated by the IBMF, the client + * has not removed all recv callbacks. + * IBMF_INVALID_ARG - invalid argument + * IBMF_FAILURE - ibmf internal error + * IBMF_NO_RESOURCES - not enough resources + * IBMF_TRANSPORT_FAILURE - transport call failed + */ +int ibmf_unregister( + ibmf_handle_t *ibmf_handle, + uint_t flags); + +/* + * ibmf_setup_async_cb(): + * + * This routine establishes a callback that the IBMF invokes when a message + * corresponding to the class corresponding to ibmf_handle is received. + * It is an error to call this routine twice without an intervening + * call to ibmf_tear_down_async_cb() for the same ibmf_qp_handle/ibmf_handle + * combination. Only unsolicited message reception will result in this + * callback being invoked. + * + * This interface may block. + * + * The callback routine could be invoked before this function returns. + * + * Input arguments: + * Handle to the IBMF interface + * IBMF QP handle (either allocated via ibmf_alloc_qp() or + * IBMF_QP_HANDLE_DEFAULT) + * Callback routine + * Argument to be passed when the callback is invoked + * flags - unused (should be 0) + * + * Output arguments: + * None + * + * Return values: + * IBMF_SUCCESS - Callback established successfully + * IBMF_BAD_HANDLE - failure - invalid handle + * IBMF_BAD_QP_HANDLE - failure - invalid qp handle + * IBMF_CB_REGISTERED - failure - callback is already established + * IBMF_INVALID_ARG - failure - invalid argument + */ +int ibmf_setup_async_cb( + ibmf_handle_t ibmf_handle, + ibmf_qp_handle_t ibmf_qp_handle, + ibmf_msg_cb_t async_msg_cb, + void *async_msg_cb_args, + uint_t flags); + +/* + * ibmf_tear_down_async_cb(): + * + * This routine removes the callback set up using ibmf_setup_async_cb. + * There will not be any callbacks if messages are received after successful + * return from this routine. There could be message received callbacks during + * the execution of this routine. + * + * This interface may block. + * + * Input arguments: + * Handle to the IBMF interface + * IBMF QP handle (either allocated via ibmf_alloc_qp() or + * IBMF_QP_HANDLE_DEFAULT) + * flags - unused (should be 0) + * + * Output arguments: + * None + * + * Return values: + * IBMF_SUCCESS - call successful + * IBMF_BAD_HANDLE - failure - invalid ibmf handle or qp handle + * IBMF_BAD_QP_HANDLE - failure - invalid qp handle + * IBMF_CB_NOT_REGISTERED - No callback currently registered + * IBMF_INVALID_ARG - failure - invalid argument + */ +int ibmf_tear_down_async_cb( + ibmf_handle_t ibmf_handle, + ibmf_qp_handle_t ibmf_qp_handle, + uint_t flags); + +/* + * ibmf_msg_transport(): + * + * This interface does not block if a callback is specified. + * + * IBMF makes some preliminary checks and returns failure if the + * checks fail. The callback, if any, is not called in this case. If the + * checks pass, the message specified in msgp->im_msgbufs_send is relayed + * down into the transport layer over as many MAD packets as necessary + * to accommodate the entire message. The IBMF_MSG_TRANS_FLAG_RMPP flag is set + * when the RMPP protocol should be used when sending out the message. + * The IBMF_MSG_TRANS_FLAG_SEQ is set when the the transaction is a + * sequenced transaction (send and receive) where the client expects a reply. + * The transaction completion callback will be invoked when IBMF + * is done processing the send operation and after having received the + * complete response if one is due, with or without errors. + * If no callback is specified, the routine blocks till the underlying + * transport is done processing the send request and received the complete + * response, with or without errors + * + * When sending non-MAD traffic over the alternate QPs, + * if the message data exceeds the maximum MTU supported, the call will fail + * with the status IBMF_BAD_SIZE. + * + * NOTE: If the call is asynchronous, the callback may be invoked before + * the call returns. The client should be prepared to handle this possibility. + * + * The message is sent to the address specified by msgp->im_local_addr and + * msgp->im_global_addr (global address invalid for SMPs and is ignored). + * Note that the desired Q_Key and P_Key can be specified via + * msgp->im_local_addr. If the ibmf implementation does not support any + * value of Q_Key/P_Key with IBMF_QP_HANDLE_DEFAULT, it is an error to specify + * a Q_Key other than 0x8001_0000 and a P_Key other than 0xFFFF/0x7FFF when + * ibmf_qp_handle_t arg is set IBMF_QP_HANDLE_DEFAULT. (See the NOTE in + * ibmf_register() on what the platform supports.) In this case, when a q_key + * value other than 0x8001_0000 and/or P_Key value other than + * 0xFFFF/0x7FFF is desired, the client should allocate its own qp handle + * with the desired values and use that in the ibmf_msg_transport() call. + * ibmf_msg_transport() returns IBMF_BAD_HANDLE to flag the error. + * + * NOTE: If the qp handle is not the default handle (ie., not + * IBMF_QP_HANDLE_DEFAULT), it is possible for some other thread to modify + * P_Key and Q_Key value associated with the qp_handle while this function + * is executing; this routine may return IBMF_BAD_HANDLE if that + * happens. It is possible that the modification happens after this routine + * validates the values, in which case no error may be flagged. + * + * NOTE: if the class of the MAD being sent is not the same as what the + * ibmf_handle (obtained via ibmf_register()) corresponds to, ibmf_qp_handle + * can not be set to IBMF_QP_HANDLE_DEFAULT. + * + * NOTE on notation: A message structure allocated by an ibmf_alloc_msg() + * call or one returned in an unsolicted callback will be referred to as + * "Message". When referring to a message in the general sense of the word, + * it will be referred to as "message". + * NOTE: Rules for reusing an IBMF Message: + * Clients may reuse a Message, either provided by IBMF in an unsolicited + * request, or one obtained through the ibmf_alloc_msg() call, for a + * subsequent request from the client itself. The client may reuse a Message + * to avoid the overhead of allocating a new Message and new send buffers. + * To safely reuse Messages, the client must follow the rules listed below. + * 1) Using the receive buffers to send the message header and data: + * If the Message has been provided by IBMF in an unsolicited request, + * it will have its receive buffers already allocated and pointed to by + * im_msgbufs_recv pointers by IBMF. In such a case, a client may set + * the im_msgbufs_send pointers to the values in the im_msgbufs_recv + * thus reusing the buffer allocated by IBMF for the incoming Message. + * However, this may be done only when the request from the client is + * a non-sequenced operation i.e. IBMF_MSG_TRANS_FLAG_SEQ flag is not set. + * An attempt to reuse the receive buffer for any other operation will + * result in the failure of the ibmf_msg_transport() call with the error + * status IBMF_REQ_INVALID. + * 2) Providing send buffers to send the message header and data: + * If the client provides its own send buffers for the message header and data, + * the IBMF Message may be reused for both sequenced and non-sequenced + * transactions. Any receive buffers that were allocated by IBMF from a + * previous transaction, will be freed up once the Message is reused in an + * ibmf_msg_transport() call. New receive buffers will be provided by IBMF + * if the new transaction is a sequenced transaction. + * + * Input arguments: + * Handle to the IBMF interface + * IBMF QP handle (either allocated via ibmf_alloc_qp() or + * IBMF_QP_HANDLE_DEFAULT [see the NOTE above regarding MAD class]) + * Pointer to ibmf_msg_t to be sent + * A pointer to ibmf_retrans_t to specify retries and timeout + * values to use during the transaction. + * Function to be called when the operation is done. + * (the routine is blocking if this function is NULL). + * Argument to be passed when the callback is invoked + * flags - set IBMF_MSG_TRANS_FLAG_RMPP if send should use RMPP + * set IBMF_MSG_TRANS_FLAG_SEQ if transaction is sequenced + * + * Output arguments: + * None + * + * Return values: + * IBMF_SUCCESS - If blocking call, the operation was + * completed by the transport. For + * non blocking call, the request passed basic + * checks and the callback should be expected. + * IBMF_BAD_HANDLE - operation failure - invalid ibmf handle + * IBMF_BAD_QP_HANDLE - operation failure - invalid qp handle or + * q_key/p_key in msgp->ip_local_addr is + * inconsistent with ibmf_qp_handle (for eg., + * handle is IBMF_QP_HANDLE_DEFAULT and + * Q_Key/P_Key is non-default and platform + * doesn't support non-default keys on this + * qp_handle or handle is IBMF_QP_HANDLE_DEFAULT + * but MAD class is not the one specified to + * ibmf_register()) + * IBMF_BAD_PORT_STATE - operation failure - port in incorrect state + * for packet transmission + * IBMF_NO_RESOURCES - operation failure - temporarily out of + * resources and call may succeed on a retry + * IBMF_FAILURE - operation failure - unspecified error + * IBMF_BAD_SIZE - data size in message to long for single UD pkt + * IBMF_BAD_RMPP_OPT - the class or QP does not support RMPP + * IBMF_PARTIAL_TRANSFER - only part of the received data was returned + * to the client up to the message size limit. + * IBMF_TRANS_TIMEOUT - transaction timed out + * IBMF_TRANS_FAILURE - transaction failure + * IBMF_REQ_INVALID - tried to reuse receive buffer for sending + * message data in a sequenced operation. + * IBMF_BUSY - message already being processed + * IBMF_INVALID_ARG - invalid argument + * IBMF_FAILURE - ibmf internal error + * IBMF_NO_RESOURCES - not enough resources + * IBMF_TRANSPORT_FAILURE - transport call failed + * IBMF_BAD_SIZE - if msgp->im_msgbufs_send.im_bufs_mad_hdr + * is NULL when ibmf_qp_handle is the default + * QP handle, OR, if + * msgp->im_msgbufs_send.im_bufs_mad_hdr + * is NULL when ibmf_qp_handle is not the default + * QP handle and the alternate QP is not being + * used for RAW data traffic. + */ +int ibmf_msg_transport( + ibmf_handle_t ibmf_handle, + ibmf_qp_handle_t ibmf_qp_handle, + ibmf_msg_t *msgp, + ibmf_retrans_t *retrans, + ibmf_msg_cb_t msg_cb, + void *msg_cb_args, + uint_t flags); + +#define IBMF_MSG_TRANS_FLAG_RMPP 0x1 +#define IBMF_MSG_TRANS_FLAG_SEQ 0x2 + +/* + * ibmf_alloc_msg(): + * + * Alloc memory to hold the message being sent out or being received. + * The IBMF client must provide the buffers in im_msgbufs_send before + * calling ibmf_msg_transport(). If this message is used in a sequenced + * transaction response or an unsolicited transaction, IBMF will provide + * the buffers in im_msgbufs_recv with the response, once the + * transaction is complete. + * The client is responsible for freeing the buffers pointed to in + * im_msgbufs_send when they are no longer needed. IBMF will free the buffers + * in im_msgbufs_send once ibmf_free_msg() is called by the client. + * + * This interface may block if IBMF_ALLOC_SLEEP is specified. + * + * Input arguments: + * Handle to the IBMF interface + * sleep flag - IBMF_ALLOC_SLEEP/IBMF_ALLOC_NOSLEEP + * + * Output arguments: + * Pointer to the buffer allocated; may be NULL if system runs out + * of memory and IBMF_ALLOC_NOSLEEP is specified. + * + * Return values: + * IBMF_SUCCESS - allocation successful + * IBMF_BAD_HANDLE - alloc failed - Invalid IBMF handle passed in + * IBMF_BAD_FLAGS - allocation failed - invalid flags + * IBMF_INVALID_ARG - allocation failed - invalid argument + * IBMF_FAILURE - ibmf internal error + * IBMF_NO_RESOURCES - not enough resources + * IBMF_TRANSPORT_FAILURE - transport call failed + */ +int ibmf_alloc_msg( + ibmf_handle_t ibmf_handle, + int flag, + ibmf_msg_t **ibmf_msgpp); + + +/* + * ibmf_free_msg(): + * + * Free message context. This message context is either allocated when + * the client calls ibmf_alloc_msg() or is allocated by IBMF automatically in + * response to incoming unsolicited messages. For all incoming messages, + * solicited or unsolicited, IBMF will provide the buffers pointed to + * in im_msgbufs_recv. In addition to freeing the message context, + * IBMF is responsible for freeing any buffers allocated by itself, + * and pointed to in im_msgbufs_recv when the client calls ibmf_free_msg(). + * + * This interface does not block + * + * Input arguments: + * Handle to the IBMF interface + * Pointer to the buffer to be freed + * + * Output arguments: + * None + * + * Return values: + * IBMF_SUCCESS - free successful + * IBMF_BAD_HANDLE - free failed - Invalid IBMF handle passed in + * IBMF_BUSY - free failed - message in use + * IBMF_INVALID_ARG - free failed - invalid argument + * IBMF_FAILURE - ibmf internal error + * IBMF_NO_RESOURCES - not enough resources + * IBMF_TRANSPORT_FAILURE - transport call failed + */ +int ibmf_free_msg( + ibmf_handle_t ibmf_handle, + ibmf_msg_t **ibmf_msgpp); + + +/* + * ibmf_alloc_qp(): + * + * Alloc a qp with the specified P_key and Q_key values. A pointer to + * ibmf_qp_handle_t is returned if the call is successful. The qp is + * associated with the port that ibmf_handle corresponds to. + * + * Non-special QPs may be tagged to send and receive + * one of the three types of traffic, either non-MAD UD, or MADs with + * RMPP or MADs without RMPP. + * The tagging should be done when calling ibmf_alloc_qp() + * by setting the flags argument in the ibmf_alloc_qp() interface + * function call to specifically defined values. + * Only one, and at least one, of these flags must be specified. + * + * A client may specify the IBMF_ALT_QP_RAW_ONLY flag to limit + * the QP to non-MAD UD traffic. If this flag is specified, and the + * IBMF implementation supports this flag, the client may send + * and receive MADs up to the maximum MTU supported on the link + * connected to the chosen port. + * + * If any of the flag options are not supported by the IBMF implementation, + * IBMF will return IBMF_NOT_SUPPORTED. + * + * This interface may block + * + * Input arguments: + * Handle to the IBMF interface + * P_Key + * Q_Key + * flags - IBMF_ALT_QP_MAD_NO_RMPP = MAD traffic only, + * IBMF_ALT_QP_MAD_RMPP = RMPP MADs only, + * IBMF_ALT_QP_RAW_ONLY = Non-MAD UD traffic only + * + * Output arguments: + * Pointer to the qp handle + * + * Return values: + * IBMF_SUCCESS - allocation successful + * IBMF_BAD_HANDLE - alloc failed - Invalid IBMF handle passed in + * IBMF_NO_RESOURCES - alloc failed - no resources for qp allocation + * IBMF_BAD_FLAGS - allocation failed - bad flag combination + * IBMF_NOT_SUPPORTED - allocation failed - unsupported traffic + * IBMF_INVALID_ARG - allocation failed - invalid argument + * IBMF_NO_RESOURCES - not enough resources + * IBMF_TRANSPORT_FAILURE - transport call failed + * + */ +int ibmf_alloc_qp( + ibmf_handle_t ibmf_handle, + ib_pkey_t p_key, + ib_qkey_t q_key, + uint_t flags, + ibmf_qp_handle_t *ibmf_qp_handlep); + +/* Flags values for ibmf_alloc_qp() flags argument */ +#define IBMF_ALT_QP_MAD_NO_RMPP 0x1 +#define IBMF_ALT_QP_MAD_RMPP 0x2 +#define IBMF_ALT_QP_RAW_ONLY 0x4 + +/* + * ibmf_query_qp(): + * + * This function returns the P_Key, Q_Key, qp num and the port num that the + * qp_handle corresponds to. It is possible that some other thread is + * modifying the p_key and q_key for the qp_handle while this function is + * executing or some other thread modifies the p_key/q_key values after the + * function returns. + * It is the callers responsibility to deal with these cases. + * + * This interface does not block. + * + * Input arguments: + * Handle to the IBMF interface + * IBMF qp handle (this can not be IBMF_QP_HANDLE_DEFAULT) + * flags - unused (should be 0) + * + * Output arguments: + * Pointer to QP num + * Pointer to P_key + * Pointer to Q_key + * Pointer to the port num + * + * Return values: + * IBMF_SUCCESS - call successful + * IBMF_BAD_HANDLE - failure - Invalid IBMF handle + * IBMF_BAD_QP_HANDLE - failure - Invalid qp handle + * IBMF_INVALID_ARG - failure - invalid argument + * IBMF_TRANSPORT_FAILURE - transport call failed + */ +int ibmf_query_qp( + ibmf_handle_t ibmf_handle, + ibmf_qp_handle_t ibmf_qp_handle, + uint_t *qp_num, + ib_pkey_t *p_key, + ib_qkey_t *q_key, + uint8_t *portnum, + uint_t flags); + +/* + * ibmf_modify_qp(): + * + * This function sets the p_key and q_key associated with the qp handle to the + * values specified. + * + * This interface may block. + * + * Input arguments: + * Handle to the IBMF interface + * IBMF qp handle (this can not be IBMF_QP_HANDLE_DEFAULT) + * P_key + * Q_key + * flags - unused (should be 0) + * + * Output arguments: + * None + * + * Return values: + * IBMF_SUCCESS - call successful + * IBMF_BAD_HANDLE - failure - Invalid IBMF handle or qp handle + * IBMF_BAD_QP_HANDLE - failure - Invalid qp handle + * IBMF_INVALID_ARG - failure - invalid argument + * IBMF_TRANSPORT_FAILURE - transport call failed + */ +int ibmf_modify_qp( + ibmf_handle_t ibmf_handle, + ibmf_qp_handle_t ibmf_qp_handle, + ib_pkey_t p_key, + ib_qkey_t q_key, + uint_t flags); + +/* + * ibmf_free_qp(): + * + * This function frees a qp allocated by ibmf_alloc_qp(). + * The ibmf handle argument must be the same ibmf handle used in the + * corresponding ibmf_alloc_qp() call. ibmf_unregister() for the ibmf + * handle will not be allowed until all associated qps are freed. + * The client must have already invoked ibmf_tear_down_recv_cb() + * for this qp handle prior to calling ibmf_free_qp(), else IBMF_BUSY + * will be returned. + * + * This interface may block. + * + * Input arguments: + * Handle to the IBMF interface + * IBMF qp handle pointer (this can not be IBMF_QP_HANDLE_DEFAULT) + * flags - unused (should be 0) + * + * Output arguments: + * IBMF qp handle; will be invalidated following successful return from + * this call + * + * Return values: + * IBMF_SUCCESS - call successful + * IBMF_BAD_HANDLE - failure - Invalid IBMF handle or qp handle + * IBMF_BAD_QP_HANDLE - failure - Invalid qp handle + * IBMF_BUSY - failure - callback is active + * IBMF_INVALID_ARG - failure - invalid argument + * IBMF_TRANSPORT_FAILURE - transport call failed + */ +int ibmf_free_qp( + ibmf_handle_t ibmf_handle, + ibmf_qp_handle_t *ibmf_qp_handle, + uint_t flags); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_MGT_IBMF_IBMF_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_msg.h b/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_msg.h new file mode 100644 index 00000000..c7ae7a9a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_msg.h @@ -0,0 +1,161 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_MGT_IBMF_IBMF_MSG_H +#define _SYS_IB_MGT_IBMF_IBMF_MSG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define IBMF_MAD_SIZE 0x100 + +/* + * ibmf_addr definition + * This is local address information. + * + * When used in ibmf_msg_transport, local_lid refers to the (local) sender + * and remote_lid/remote_qno refer to the destination (ie., receiver). + * When used in async message callback, local_lid is the (local) receiver + * and remote_lid/remote_qno refer to the (remote) source; ibmf fills + * all fields of the addr_info_t when generating the receive callback. + * + * Note that the sender and receiver may be on the same node/port. + */ +typedef struct _ibmf_addr_info { + ib_lid_t ia_local_lid; + ib_lid_t ia_remote_lid; + ib_qpn_t ia_remote_qno; + ib_pkey_t ia_p_key; + ib_qkey_t ia_q_key; + uint8_t ia_service_level:4; +} ibmf_addr_info_t; + +/* + * ibmf_global_addr_info_t + * This has the global address information. This is filled in by the + * client when sending the message and will be filled in by IBMF when + * a message is received. ip_global_addr_valid is B_TRUE if global + * address component of the message is valid (ip_global_addr_valid is + * set by the client when sending packets and set by IBMF when packets + * are received). + */ +typedef struct _ibmf_global_addr_info { + ib_gid_t ig_sender_gid; /* gid of the sender */ + ib_gid_t ig_recver_gid; /* gid of the receiver */ + uint32_t ig_flow_label; /* pkt grouping */ + uint8_t ig_tclass; /* end-to-end service level */ + uint8_t ig_hop_limit; /* inter subnet hops */ +} ibmf_global_addr_info_t; + +/* + * ibmf_msg_bufs_t + * From the client's perspective, the message will consist of three + * sections, the MAD header, the Management Class header, and the + * data payload. IBMF will either assemble these sections into + * a message or disassemble the incoming message into these sections. + * + * The MAD header buffer is always 24 bytes in length. + * It may be set to NULL only when the QP is configured for raw + * UD traffic through the flags specified in ibmf_alloc_qp(). + * + * The class header buffer pointer may point to a buffer containing + * the class specific header as defined by the IB Architecture + * Specification, rev1.1. Note that the RMPP header should not be + * included in the class header for classes that support RMPP. + * For example, for the Subnet Administration (SA) class, the class + * header starts at byte offset 36 in the MAD and is of length 20 bytes. + * + * The data is provided in a buffer pointed to by im_bufs_cl_data, + * with the data length provided in im_bufs_cl_data_len. + * + * When sending a MAD message, the client may choose to not provide + * a class header buffer in im_msgbufs_send.im_bufs_cl_hdr. + * In this case, the im_msgbufs_send.im_bufs_cl_hdr must be NULL, + * and IBMF will interpret this to imply that the class header + * and data buffer are grouped together in the + * im_msgbufs_send.im_bufs_cl_data buffer. + * + * When sending a RAW UD packet over a non-special QP (i.e. not + * IBMF_QP_HANDLE_DEFAULT), the entire packet must be provided + * in a buffer pointed to by im_msgbufs_send.im_bufs_cl_data. + * The im_msgbufs_send.im_bufs_mad_hdr and + * im_msgbufs_send.im_bufs_cl_hdr pointers should be NULL. + * + * The data contained in these buffers, MAD header, Management Class + * header, and data payload buffers, must be in wire format which + * is the big-endian format. + */ +typedef struct _ibmf_msg_bufs { + ib_mad_hdr_t *im_bufs_mad_hdr; /* mad hdr (24 bytes) */ + void *im_bufs_cl_hdr; /* class hdr buffer ptr */ + size_t im_bufs_cl_hdr_len; /* class hdr buffer len ptr */ + void *im_bufs_cl_data; /* mad class data buf ptr */ + size_t im_bufs_cl_data_len; /* mad class data len ptr */ +} ibmf_msg_bufs_t; + +/* + * ibmf_msg definition + * The IBMF client initializes various members of the msg while sending + * the message. IBMF fills in the various members of the msg when a message + * is received. + * The im_msgbufs_send buffers must always be allocated and freed + * by the client of ibmf. Message content passed from client to ibmf + * must be through the im_msgbufs_send buffers. + * The im_msgbufs_recv buffers must always be allocated and freed + * by ibmf. Message content passed from ibmf to client + * will always be through the im_msgbufs_recv buffers. + * + * im_msg_status: contains the IBMF status (defined in ibmf.h) of + * the transaction. This is the same as the return value of the + * ibmf_msg_transport() call for a blocking transaction. + * + * im_msg_flags: must be set to IBMF_MSG_FLAGS_GLOBAL_ADDRESS by + * the IBMF client if the send buffer contains a valid GRH, and by + * IBMF if the receive buffer contains a valid GRH + * + * Note on Host versus IB Wire format: + * Any MAD data passed in the buffers pointed to by im_bufs_mad_hdr, + * im_bufs_cl_hdr, and im_bufs_cl_data in im_msgbufs_send and + * im_msgbufs_recv should be in IB wire format. + * All other data in the ibmf_msg_t structure should be in host format, + * including the data in im_local_addr and im_global_addr. + */ +typedef struct _ibmf_msg { + ibmf_addr_info_t im_local_addr; /* local addressing info */ + ibmf_global_addr_info_t im_global_addr; /* global addressing info */ + int32_t im_msg_status; /* completion status */ + uint32_t im_msg_flags; /* flags */ + size_t im_msg_sz_limit; /* max. message size */ + ibmf_msg_bufs_t im_msgbufs_send; /* input data to ibmf */ + ibmf_msg_bufs_t im_msgbufs_recv; /* output data from ibmf */ +} ibmf_msg_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_MGT_IBMF_IBMF_MSG_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_saa.h b/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_saa.h new file mode 100644 index 00000000..c517e708 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_saa.h @@ -0,0 +1,566 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_MGT_IBMF_IBMF_SAA_H +#define _SYS_IB_MGT_IBMF_IBMF_SAA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * SA Access Interface: Interfaces to enable access to the SA + */ + +#define IBMF_SAA_PKEY_WC 0 /* partition key wildcard */ +#define IBMF_SAA_MTU_WC 0 /* mtu wilcard for gid_to_pathrecords */ + +typedef enum _ibmf_saa_access_type_t { + IBMF_SAA_RETRIEVE, + IBMF_SAA_UPDATE, + IBMF_SAA_DELETE +} ibmf_saa_access_type_t; + +/* + * ibmf_saa_handle + * Opaque handle to identify the consumer + */ +typedef struct ibmf_saa_handle *ibmf_saa_handle_t; + +/* + * ibmf_saa_cb_t + * ibmf_saa's callback to clients to inform them that the response to an + * asynchronous request has arrived or that the request timed out. + * + * Input Arguments + * clnt_private - opaque handle to client specific data (sq_callback_arg) + * length - size of response returned + * result - pointer to buffer of response. Data will be in host-endian format + * and unpacked. Client can just cast to a pointer to the structure + * status - ibmf status. Status can be any of the values returned by a + * synchronous ibmf_sa_access() call. + * + * Output Arguments + * none + * + * Returns + * none + */ +typedef void (*ibmf_saa_cb_t) ( + void *callback_arg, + size_t length, + char *result, + int status); + +/* + * structure to provide parameters to ibmf_sa_access call + */ +typedef struct ibmf_saa_access_args_s { + /* MAD attribute ID */ + uint16_t sq_attr_id; + + /* retrieve, update, or delete */ + ibmf_saa_access_type_t sq_access_type; + + /* SA MAD component mask indicating fields in template to query on */ + uint64_t sq_component_mask; + + /* pointer to template */ + void *sq_template; + + /* + * length, in bytes, of template size for attributes which ibmf does + * not know about; ignored for known attribute id's. length should be + * wire length and template for unknown attributes should be in wire + * format as ibmf will not be able to pack data. + */ + size_t sq_template_length; + + /* callback and argument when asynchronous request returns */ + ibmf_saa_cb_t sq_callback; + void *sq_callback_arg; +} ibmf_saa_access_args_t; + +/* + * enumeration of subnet events + * + * IBMF_SAA_EVENT_GID_AVAILABLE + * the identified gid is available + * IBMF_SAA_EVENT_GID_UNAVAILABLE + * the identified gid is unavailable + * IBMF_SAA_EVENT_MCG_CREATED + * MC group identified by mgid is created + * IBMF_SAA_EVENT_MCG_DELETED + * MC group identified by mgid is deleted + * IBMF_SAA_EVENT_CAP_MASK_CHG + * Portinfo.CapabilityMask changed + * IBMF_SAA_EVENT_SYS_IMG_GUID_CHG + * System Image GUID changed + * IBMF_SAA_EVENT_SUBSCRIBER_STATUS_CHG + * Status of ibmf subscriptions changed + */ +typedef enum ibmf_saa_subnet_event_e { + + IBMF_SAA_EVENT_GID_AVAILABLE, + IBMF_SAA_EVENT_GID_UNAVAILABLE, + IBMF_SAA_EVENT_MCG_CREATED, + IBMF_SAA_EVENT_MCG_DELETED, + IBMF_SAA_EVENT_CAP_MASK_CHG, + IBMF_SAA_EVENT_SYS_IMG_GUID_CHG, + IBMF_SAA_EVENT_SUBSCRIBER_STATUS_CHG + +} ibmf_saa_subnet_event_t; + +/* + * ibmf must subscribe with the Subnet Administrator to provide the subnet + * events for its clients. It registers for the four trap producer types: CA, + * switch, router, and subnet management. If any of these registrations fails + * the ibmf will notify each client that registered for events. Clients are + * notified by ibmf through their registered callback and the + * SUBSCRIBER_STATUS_CHG event. + * + * For this event, the event_details producer_type_status_mask will be set. + * Each bit in the mask corresponds to a different producer type. When the bit + * is on the ibmf was able to successfully subscribe for events from that + * producer. When the bit is off, ibmf was unable to subscribe and clients may + * not receive events from that producer type. + * + * For example, if the status_mask is 0xb then events will be received that + * correspond to CA's, switches, and subnet management traps. However, traps + * generated by routers may not be received. + * + * The ibmf re-registers for events when the port transitions to active. If the + * event status mask changes the ibmf will generate another + * SUBSCRIBER_STATUS_CHG event with the new producer type status mask. When + * clients register they should only expect to receive a SUBSCRIBER_STATUS_CHG + * event if one of the registrations failed. If all four registrations + * succeeded no event will be generated. + * + * If the port goes down, a SUBSCRIBER_STATUS_CHG event is not generated. + * Clients should realize that events will not be forwarded. If the port + * transitions back to active ibmf_saa will resubscribe on behalf of the client. + * If this subscription fails a SUBSCRIBER_STATUS_CHG event will be generated. + * + */ + +#define IBMF_SAA_EVENT_STATUS_MASK_PRODUCER_CA (1 << 0) +#define IBMF_SAA_EVENT_STATUS_MASK_PRODUCER_SWITCH (1 << 1) +#define IBMF_SAA_EVENT_STATUS_MASK_PRODUCER_ROUTER (1 << 2) +#define IBMF_SAA_EVENT_STATUS_MASK_PRODUCER_SM (1 << 3) + +/* + * structure passed as event_details argument of ibmf_saa subnet event + * callback. + * + * Only some of the structure members are valid for a given event as given + * below: + * + * member event type + * ------ ---------- + * ie_gid IBMF_SAA_EVENT_GID_AVAILABLE, + * IBMF_SAA_EVENT_GID_UNAVAILABLE, + * IBMF_SAA_EVENT_MCG_CREATED, and + * IBMF_SAA_EVENT_MCG_DELETED + * ie_lid IBMF_SAA_EVENT_CAP_MASK_CHG and + * IBMF_SAA_EVENT_SYS_IMG_GUID_CHG + * ie_capability_mask IBMF_SAA_EVENT_CAP_MASK_CHG + * ie_sysimg_guid IBMF_SAA_EVENT_SYS_IMG_GUID_CHG + * ie_producer_type_status_mask IBMF_SAA_EVENT_SUBSCRIBER_STATUS_CHG + * + */ +typedef struct ibmf_saa_event_details_s { + ib_gid_t ie_gid; + ib_guid_t ie_sysimg_guid; + uint32_t ie_capability_mask; /* values defined in sm_attr.h */ + ib_lid_t ie_lid; + uint8_t ie_producer_event_status_mask; +} ibmf_saa_event_details_t; + +/* + * Callback invoked when one of the events the client subscribed for + * at ibmf_sa_session_open() time happens. + * + * This callback can occur before ibmf_sa_session_open() returns. + * + * Each callback is on a separate thread. ibmf clients may block in the event + * callback. However, under heavy system load ibmf may not be able to generate + * event callbacks. Also, event callbacks, including SUBSCRIBER_STATUS_CHG, + * could be dispatched out-of-order. + * + * Arguments: + * ibmf_saa_handle - Client's ibmf_saa_handle + * ibmf_saa_event - event that caused the callback + * event_details - additional data for the event + * callback_arg - event_callback_arg member of + * ibmf_saa_subnet_event_args_t + */ +typedef void (*ibmf_saa_subnet_event_cb_t)( + ibmf_saa_handle_t ibmf_saa_handle, + ibmf_saa_subnet_event_t ibmf_saa_event, + ibmf_saa_event_details_t *event_details, + void *callback_arg); + +typedef struct ibmf_saa_subnet_event_args_s { + + /* func to be called when a subnet event happens */ + ibmf_saa_subnet_event_cb_t is_event_callback; + + /* call back arg */ + void *is_event_callback_arg; + +} ibmf_saa_subnet_event_args_t; + +/* + * ibmf_sa_session_open(): + * + * Before using the ibmf_saa interface, consumers should register with the + * ibmf_saa interface by calling ibmf_sa_session_open(). Upon a successful + * registration, a handle is returned for use in subsequent interaction with the + * ibmf_saa interface; this handle is also provided as an argument to subnet + * event notification function. + * + * Consumers can register to be notified of subnet events such as GID + * being available/unavailable. Clients which provide a non-NULL event args + * structure will have the is_event_callback function called when an event is + * received or there is a failure in subscribing for events. This callback may + * be generated before the ibmf_sa_session_open() call returns. + * + * This interface blocks allocating memory, but not waiting for any packet + * responses. + * + * Arguments: + * port_guid - GUID of the port. + * event_args - subnet event registration details + * sm_key - only filled in if the consumer is an SM + * ibmf_version - version of the interface (IBMF_VERSION) + * flags - unused + * + * Return values: + * IBMF_SUCCESS - registration succeeded + * IBMF_BAD_PORT - registration failed; active port not found + * IBMF_BAD_PORT_STATE - registration failed; port found but not active or + * previous registration failed + * IBMF_NO_MEMORY - registration failed; could not allocate memory + * IBMF_NO_RESOURCES - registration failed due to a resource issue + * IBMF_BUSY - registration failed; too many clients registered + * for this port + * IBMF_TRANSPORT_FAILURE - failure with underlying transport framework + * IBMF_INVALID_ARG - ibmf_saa_handle arg was NULL + */ +int ibmf_sa_session_open( + ib_guid_t port_guid, + ib_smkey_t sm_key, + ibmf_saa_subnet_event_args_t *event_args, + uint_t ibmf_version, + uint_t flags, + ibmf_saa_handle_t *ibmf_saa_handle); + +/* + * ibmf_sa_session_close() + * + * Unregister a consumer of the SA_Access interface + * + * This interface blocks. + * + * Arguments: + * ibmf_saa_handle - handle returned from sa_session_open() + * flags - unused + * + * Return values: + * IBMF_SUCCESS - unregistration succeeded + * IBMF_BAD_HANDLE - unregistration failed; handle is not valid or + * session_close has already been called + * IBMF_INVALID_ARG - ibmf_saa_handle arg was NULL + * + * All outstanding callbacks will be canceled before this function returns. + */ +int ibmf_sa_session_close( + ibmf_saa_handle_t *ibmf_saa_handle, + uint_t flags); + +/* + * ibmf_sa_access + * + * Retrieve records from the SA given an AttributeID, ComponentMask, + * and a template + * + * This interface blocks if the callback parameter is NULL. + * + * Input Arguments: + * ibmf_saa_handle - handle returned from ibmf_sa_session_open() + * access_args - structure containing various parameters for the query + * flags - unsused + * + * Output Arguments: + * length - size of buffer returned + * result - pointer to buffer of records returned in response. + * Buffer is host-endian, unpacked can be cast to one of + * the record types in sa_recs.h + * + * Return values: + * IBMF_SUCCESS - query succeeded + * IBMF_BAD_HANDLE - sa session handle is invalid + * IBMF_BAD_PORT_STATE - port in incorrect state + * IBMF_INVALID_ARG - one of the pointer parameters was NULL + * IBMF_NO_RESOURCES - ibmf could not allocate ib resources or SA returned + * ERR_NO_RESOURCES + * IBMF_TRANS_TIMEOUT - transaction timed out + * IBMF_TRANS_FAILURE - transaction failure + * IBMF_NO_MEMORY - ibmf could not allocate memory + * IBMF_REQ_INVALID - send and recv buffer the same for a sequenced + * transaction or the SA returned an ERR_REQ_INVALID + * IBMF_NO_RECORDS - no records matched query + * IBMF_TOO_MANY_RECORDS- SA returned SA_ERR_TOO_MANY_RECORDS + * IBMF_INVALID_GID - SA returned SA_INVALID_GID + * IBMF_INSUFF_COMPS - SA returned SA_ERR_INSUFFICIENT_COMPS + * IBMF_UNSUPP_METHOD - SA returned MAD_STATUS_UNSUPP_METHOD + * IBMF_UNSUPP_METHOD_ATTR - SA returned MAD_STATUS_UNSUPP_METHOD_ATTR + * IBMF_INVALID_FIELD - SA returned MAD_STATUS_INVALID_FIELD + * IBMF_NO_ACTIVE_PORTS - no active ports found + * + * Upon successful completion, result points to a buffer containing the records. + * length is the size in bytes of the buffer returned in result. If there are + * no records or the call failed the length is 0. + * + * The consumer is responsible for freeing the memory associated with result. + */ +int ibmf_sa_access( + ibmf_saa_handle_t ibmf_saa_handle, + ibmf_saa_access_args_t *access_args, + uint_t flags, + size_t *length, + void **result); + +/* + * Helper Functions. + * Ease of use functions so that the consumer doesn't + * have to do the overhead of calling ibmf_sa_access() for + * commonly used queries + */ + +/* + * ibmf_saa_gid_to_pathrecords + * Given a source gid and a destination gid, return paths + * between the gids. + * + * This interface blocks. + * + * Input Arguments: + * ibmf_saa_handle - handle returned from ibmf_sa_session_open() + * sgid - source gid of path + * dgid - destination gid of path + * p_key - partition of path. This value may be wildcarded with + * IBMF_SAA_PKEY_WC. + * mtu - preferred MTU of the path. This argument may be + * wildcarded with IBMF_SAA_MTU_WC. + * reversible - if B_TRUE, ibmf will query only reversible paths + * see Infiniband Specification table 171 + * num_paths - maximum number of paths to return + * numpaths should be checked for the actual number of + * records returned. + * flags - unused + * + * Output Arguments: + * num_paths - actual number of paths returned + * length - size of buffer returned + * result - pointer to buffer of path records returned in response + * + * Return values: + * Error codes are the same as ibmf_sa_access() return values + * + * Upon successful completion, result points to a buffer containing the records. + * length is the size in bytes of the buffer returned in result. If there are + * no records or the call failed the length is 0. + * + * The consumer is responsible for freeing the memory associated with result. + */ +int ibmf_saa_gid_to_pathrecords( + ibmf_saa_handle_t ibmf_saa_handle, + ib_gid_t sgid, + ib_gid_t dgid, + ib_pkey_t p_key, + ib_mtu_t mtu, + boolean_t reversible, + uint8_t *num_paths, + uint_t flags, + size_t *length, + sa_path_record_t **result); +/* + * ibmf_saa_paths_from_gid + * Given a source GID, return a path from the source gid + * to every other port on the subnet. It is assumed that the + * subnet is fully connected. Only one path per port on the subnet + * is returned. + * + * This interface blocks. + * + * Arguments: + * ibmf_saa_handle - handle returned from ibmf_sa_session_open() + * sgid - source gid of path + * pkey - paritition of path. This value may be wildcarded with + * IBMF_SAA_PKEY_WC. + * reversible - if B_TRUE, ibmf will query only reversible paths; + * see Infiniband Specification table 171 + * flags - unused + * + * Output Arguments: + * num_paths - number of paths returned + * length - size of buffer returned + * result - pointer to buffer of path records returned in response + * + * Return values: + * Error codes are the same as ibmf_sa_access() return values + * + * Upon successful completion, result points to a buffer containing the records. + * and num_paths is the number of path records returned. length is the size + * in bytes of the buffer returned in result. If there are no records or the + * call failed the length is 0. + * + * The consumer is responsible for freeing the memory associated with result. + */ +int ibmf_saa_paths_from_gid( + ibmf_saa_handle_t ibmf_saa_handle, + ib_gid_t sgid, + ib_pkey_t pkey, + boolean_t reversible, + uint_t flags, + uint_t *num_paths, + size_t *length, + sa_path_record_t **result); + +/* + * ibmf_saa_name_to_service_record: + * Given a service name, return the service records associated + * with it. + * + * This interface blocks. + * + * Input Arguments: + * ibmf_saa_handle - handle returned from ibmf_sa_session_open() + * name - service name, a null terminated string + * p_key - partition that the service is requested on. This + * value may be wildcarded with IBMF_SAA_PKEY_WC. + * flags - unused + * + * Output Arguments: + * num_records - number of service records returned + * length - size of buffer returned + * result - pointer to buffer of service records returned in + * response + * + * Return values: + * Error codes are the same as ibmf_sa_access() return values + * + * Upon successful completion, result points to a buffer containing the records. + * and num_records is the number of service records returned. length is the + * size in bytes of the buffer returned in result. If there are no records or + * the call failed the length is 0. + * + * The consumer is responsible for freeing the memory associated with result. + */ +int ibmf_saa_name_to_service_record( + ibmf_saa_handle_t ibmf_saa_handle, + char *service_name, + ib_pkey_t p_key, + uint_t flags, + uint_t *num_records, + size_t *length, + sa_service_record_t **result); + +/* + * ibmf_saa_id_to_service_record: + * Given a service id, return the service records associated + * with it. + * + * This interface blocks. + * + * Input Arguments: + * ibmf_saa_handle - handle returned from ibmf_sa_session_open() + * id - service id + * p_key - partition that the service is requested on. This + * value may be wildcarded with IBMF_SAA_PKEY_WC. + * flags - unused + * + * Output Arguments: + * num_records - number of service records returned + * length - size of buffer returned + * result - pointer to buffer of service records returned in + * response + * + * Return values: + * Error codes are the same as ibmf_sa_access() return values + * + * Upon successful completion, result points to a buffer containing the records. + * and num_records is the number of service records returned. length is the + * size in bytes of the buffer returned in result. If there are no records or + * the call failed the length is 0. + * + * The consumer is responsible for freeing the memory associated with result. + */ +int ibmf_saa_id_to_service_record( + ibmf_saa_handle_t ibmf_saa_handle, + ib_svc_id_t service_id, + ib_pkey_t p_key, + uint_t flags, + uint_t *num_records, + size_t *length, + sa_service_record_t **result); + +/* + * ibmf_saa_update_service_record + * Given a pointer to a service record, either insert or delete it + * + * This interface blocks. + * + * Input Arguments: + * ibmf_saa_handle - handle returned from ibmf_sa_session_open() + * service_record - service record is to be inserted or deleted. To + * delete a service record the GID, ID, P_Key, and + * Service Key must match what is in the SA. + * access_type - indicates whether this is an insertion or deletion. + * valid values are IBMF_SAA_UPDATE or IBMF_SAA_DELETE + * flags - unused + * + * Ouptut Arguments + * none + * + * Return values: + * Error codes are the same as ibmf_sa_access() return values + */ +int ibmf_saa_update_service_record( + ibmf_saa_handle_t ibmf_saa_handle, + sa_service_record_t *service_record, + ibmf_saa_access_type_t access_type, + uint_t flags); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_MGT_IBMF_IBMF_SAA_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_utils.h b/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_utils.h new file mode 100644 index 00000000..1d64ff41 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/mgt/ibmf/ibmf_utils.h @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_MGT_IBMF_IBMF_UTILS_H +#define _SYS_IB_MGT_IBMF_IBMF_UTILS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains helper functions for parsing management + * datagram MADs. + */ +void +ibmf_utils_unpack_data(char *format, uchar_t *data, size_t datalen, + void *structure, size_t structlen); + +void +ibmf_utils_pack_data(char *format, void *structure, size_t structlen, + uchar_t *data, size_t datalen); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_MGT_IBMF_IBMF_UTILS_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/mgt/sa_recs.h b/illumos-x86_64/usr/include/sys/ib/mgt/sa_recs.h new file mode 100644 index 00000000..ee67b259 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/mgt/sa_recs.h @@ -0,0 +1,773 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_MGT_SA_RECS_H +#define _SYS_IB_MGT_SA_RECS_H + +/* + * This file contains the definitions of the SA-specific records in IB spec + * volume 1, release 1.1, chapter 15. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* class header for SA MADs */ +typedef struct _ib_sa_hdr_t { + uint64_t SM_KEY; + uint16_t AttributeOffset; + uint16_t Reserved; + uint64_t ComponentMask; +} ib_sa_hdr_t; + +/* subnet administration methods */ +#define SA_SUBN_ADM_GET 0x01 +#define SA_SUBN_ADM_GET_RESP 0x81 +#define SA_SUBN_ADM_SET 0x02 +#define SA_SUBN_ADM_REPORT 0x06 +#define SA_SUBN_ADM_REPORT_RESP 0x86 +#define SA_SUBN_ADM_GET_TABLE 0x12 +#define SA_SUBN_ADM_GET_TABLE_RESP 0x92 +#define SA_SUBN_ADM_GET_TRACE_TABLE 0x13 +#define SA_SUBN_ADM_GET_MULTI 0x14 +#define SA_SUBN_ADM_GET_MULTI_RESP 0x94 +#define SA_SUBN_ADM_DELETE 0x15 +#define SA_SUBN_ADM_DELETE_RESP 0x95 + +/* sa MAD status field bit value */ +#define SA_STATUS_NO_ERROR 0x0000 +#define SA_STATUS_ERR_NO_RESOURCES 0x0100 +#define SA_STATUS_ERR_REQ_INVALID 0x0200 +#define SA_STATUS_ERR_NO_RECORDS 0x0300 +#define SA_STATUS_ERR_TOO_MANY_RECORDS 0x0400 +#define SA_STATUS_ERR_REQ_INVALID_GID 0x0500 +#define SA_STATUS_ERR_REQ_INSUFFICIENT_COMPONENTS 0x0600 +#define SA_STATUS_ERROR_MASK 0xFF00 + + +/* SA-Specific ClassPortinfo::CapabilityMask Bits: Table 152 */ +#define SA_CAPMASK_OPT_RECORDS_SUPPORTED 0x100 +#define SA_CAPMASK_UD_MCAST_SUPPORTED 0x200 +#define SA_CAPMASK_MULTIPATH_SUPPORTED 0x400 +#define SA_CAPMASK_REINIT_SUPPORTED 0x800 + +/* SA attribute IDs: Table 155 */ +#define SA_CLASSPORTINFO_ATTRID 0x01 +#define SA_NOTICE_ATTRID 0x02 +#define SA_INFORMINFO_ATTRID 0x03 +#define SA_NODERECORD_ATTRID 0x11 +#define SA_PORTINFORECORD_ATTRID 0x12 +#define SA_SLTOVLRECORD_ATTRID 0x13 +#define SA_SWITCHINFORECORD_ATTRID 0x14 +#define SA_LINEARFDBRECORD_ATTRID 0x15 +#define SA_RANDOMFDBRECORD_ATTRID 0x16 +#define SA_MULTICASTFDBRECORD_ATTRID 0x17 +#define SA_SMINFORECORD_ATTRID 0x18 +#define SA_INFORMINFORECORD_ATTRID 0xF3 +#define SA_LINKRECORD_ATTRID 0x20 +#define SA_GUIDINFORECORD_ATTRID 0x30 +#define SA_SERVICERECORD_ATTRID 0x31 +#define SA_PARTITIONRECORD_ATTRID 0x33 +#define SA_PATHRECORD_ATTRID 0x35 +#define SA_VLARBRECORD_ATTRID 0x36 +#define SA_MCMEMBERRECORD_ATTRID 0x38 +#define SA_TRACERECORD_ATTRID 0x39 +#define SA_MULTIPATHRECORD_ATTRID 0x3A +#define SA_SERVICEASSNRECORD_ATTRID 0x3B + +/* Node Record: Table 157 */ +typedef struct sa_node_record_s { + ib_lid_t LID; /* LID of a port of the node */ + uint16_t Reserved; + sm_nodeinfo_t NodeInfo; /* NodeInfo attr. contents */ + sm_nodedesc_t NodeDescription; /* NodeDesc attr. contents */ +} sa_node_record_t; + +#define SA_NODEINFO_COMPMASK_NODELID 0x1 +#define SA_NODEINFO_COMPMASK_RESERVED 0x2 +#define SA_NODEINFO_COMPMASK_BASEVERSION 0x4 +#define SA_NODEINFO_COMPMASK_CLASSVERSION 0x8 +#define SA_NODEINFO_COMPMASK_NODETYPE 0x10 +#define SA_NODEINFO_COMPMASK_NUMPORTS 0x20 +#define SA_NODEINFO_COMPMASK_SYSIMAGEGUID 0x40 +#define SA_NODEINFO_COMPMASK_NODEGUID 0x80 +#define SA_NODEINFO_COMPMASK_PORTGUID 0x100 +#define SA_NODEINFO_COMPMASK_PARTITIONCAP 0x200 +#define SA_NODEINFO_COMPMASK_DEVICEID 0x400 +#define SA_NODEINFO_COMPMASK_REVISION 0x800 +#define SA_NODEINFO_COMPMASK_LOCALPORTNUM 0x1000 +#define SA_NODEINFO_COMPMASK_VENDORID 0x2000 +#define SA_NODEINFO_COMPMASK_NODEDESCRIPTION 0x4000 + +/* Portinfo Record: Table 158 */ +typedef struct sa_portinfo_record_s { + ib_lid_t EndportLID; /* LID of the port */ + uint8_t PortNum; /* port number (for switch) */ + uint8_t Reserved; + sm_portinfo_t PortInfo; /* PortInfo attr. contents */ +} sa_portinfo_record_t; + +/* first 3 components are atomic */ +#define SA_PORTINFO_COMPMASK_PORTLID 0x1 +#define SA_PORTINFO_COMPMASK_PORTNUM 0x2 +#define SA_PORTINFO_COMPMASK_RESERVED 0x4 +#define SA_PORTINFO_COMPMASK_MKEY 0x8 +#define SA_PORTINFO_COMPMASK_GIDPREFIX 0x10 +#define SA_PORTINFO_COMPMASK_LID 0x20 +#define SA_PORTINFO_COMPMASK_MASTERSMLID 0x40 +#define SA_PORTINFO_COMPMASK_CAPMASK 0x80 +#define SA_PORTINFO_COMPMASK_DIAGCODE 0x100 +#define SA_PORTINFO_COMPMASK_MKEYLEASE 0x200 +#define SA_PORTINFO_COMPMASK_LOCALPORTNUM 0x400 +#define SA_PORTINFO_COMPMASK_LINKWIDTHEN 0x800 +#define SA_PORTINFO_COMPMASK_LINKWIDTHSUPP 0x1000 +#define SA_PORTINFO_COMPMASK_LINKWIDTHACT 0x2000 +#define SA_PORTINFO_COMPMASK_LINKSPEEDSUPP 0x4000 +#define SA_PORTINFO_COMPMASK_PORTSTATE 0x8000 +#define SA_PORTINFO_COMPMASK_PORTPHYSICALSTATE 0x10000 +#define SA_PORTINFO_COMPMASK_LINKDOWNDEFSTATE 0x20000 +#define SA_PORTINFO_COMPMASK_MKEYPROTBITS 0x40000 +#define SA_PORTINFO_COMPMASK_RESERVED2 0x80000 +#define SA_PORTINFO_COMPMASK_LMC 0x100000 +#define SA_PORTINFO_COMPMASK_LINKSPEEDACT 0x200000 +#define SA_PORTINFO_COMPMASK_LINKSPEEDEN 0x400000 +#define SA_PORTINFO_COMPMASK_NEIGHBORMTU 0x800000 +#define SA_PORTINFO_COMPMASK_MASTERSMSL 0x1000000 +#define SA_PORTINFO_COMPMASK_VLCAP 0x2000000 +#define SA_PORTINFO_COMPMASK_INITTYPE 0x4000000 +#define SA_PORTINFO_COMPMASK_VLHIGHLIMIT 0x8000000 +#define SA_PORTINFO_COMPMASK_VLARBHIGHCAP 0x10000000 +#define SA_PORTINFO_COMPMASK_VLARBLOWCAP 0x20000000 +#define SA_PORTINFO_COMPMASK_INITTYPEREPLY 0x40000000 +#define SA_PORTINFO_COMPMASK_MTUCAP 0x80000000 +#define SA_PORTINFO_COMPMASK_VLSTALLCOUNT 0x100000000 +#define SA_PORTINFO_COMPMASK_HOQLIFE 0x200000000 +#define SA_PORTINFO_COMPMASK_OPERATIONALVLS 0x400000000 +#define SA_PORTINFO_COMPMASK_PARTENFINBOUND 0x800000000 +#define SA_PORTINFO_COMPMASK_PARTENFOUTBOUND 0x1000000000 +#define SA_PORTINFO_COMPMASK_FILTERRAWPKTIN 0x2000000000 +#define SA_PORTINFO_COMPMASK_FILTERRAWPKTOUT 0x4000000000 +#define SA_PORTINFO_COMPMASK_MKEYVIOLATIONS 0x8000000000 +#define SA_PORTINFO_COMPMASK_PKEYVIOLATIONS 0x10000000000 +#define SA_PORTINFO_COMPMASK_QKEYVIOLATIONS 0x20000000000 +#define SA_PORTINFO_COMPMASK_GUIDCAP 0x40000000000 +#define SA_PORTINFO_COMPMASK_RESERVED5 0x80000000000 +#define SA_PORTINFO_COMPMASK_SUBNETTIMEOUT 0x100000000000 +#define SA_PORTINFO_COMPMASK_RESERVED6 0x200000000000 +#define SA_PORTINFO_COMPMASK_RESPTIMEVALUE 0x400000000000 +#define SA_PORTINFO_COMPMASK_LOCALPHYERRORS 0x800000000000 +#define SA_PORTINFO_COMPMASK_OVERRUNERRORS 0x1000000000000 + +/* SLtoVL Mapping Table Record: Table 159 */ +typedef struct sa_SLtoVLmapping_record_s { + ib_lid_t LID; + uint8_t InputPortNum; + uint8_t OutputPortNum; + uint32_t Reserved; + sm_SLtoVL_mapping_table_t SLtoVLMappingTable; +} sa_SLtoVLmapping_record_t; + +#define SA_SLTOVL_COMPMASK_PORTLID 0x1 +#define SA_SLTOVL_COMPMASK_INPUTPORTNUM 0x2 +#define SA_SLTOVL_COMPMASK_OUTPUTPORTNUM 0x4 +#define SA_SLTOVL_COMPMASK_RESERVED 0x8 +#define SA_SLTOVL_COMPMASK_SL0TOVL 0x10 +#define SA_SLTOVL_COMPMASK_SL1TOVL 0x20 +#define SA_SLTOVL_COMPMASK_SL2TOVL 0x40 +#define SA_SLTOVL_COMPMASK_SL3TOVL 0x80 +#define SA_SLTOVL_COMPMASK_SL4TOVL 0x100 +#define SA_SLTOVL_COMPMASK_SL5TOVL 0x200 +#define SA_SLTOVL_COMPMASK_SL6TOVL 0x400 +#define SA_SLTOVL_COMPMASK_SL7TOVL 0x800 +#define SA_SLTOVL_COMPMASK_SL8TOVL 0x1000 +#define SA_SLTOVL_COMPMASK_SL9TOVL 0x2000 +#define SA_SLTOVL_COMPMASK_SL10TOVL 0x4000 +#define SA_SLTOVL_COMPMASK_SL11TOVL 0x8000 +#define SA_SLTOVL_COMPMASK_SL12TOVL 0x10000 +#define SA_SLTOVL_COMPMASK_SL13TOVL 0x20000 +#define SA_SLTOVL_COMPMASK_SL14TOVL 0x40000 +#define SA_SLTOVL_COMPMASK_SL15TOVL 0x80000 + +/* Switchinfo Record: Table 160 */ +typedef struct sa_switchinfo_record_s { + ib_lid_t LID; /* LID of switch port 0 */ + uint16_t Reserved; + sm_switchinfo_t SwitchInfo; /* SwitchInfo attr. contents */ +} sa_switchinfo_record_t; + +#define SA_SWITCHINFO_COMPMASK_SWITCHLID 0x1 +#define SA_SWITCHINFO_COMPMASK_RESERVED 0x2 +#define SA_SWITCHINFO_COMPMASK_LINEARFDBCAP 0x4 +#define SA_SWITCHINFO_COMPMASK_RANDOMFDBCAP 0x8 +#define SA_SWITCHINFO_COMPMASK_MCASTFDBCAP 0x10 +#define SA_SWITCHINFO_COMPMASK_LINEARFDBTOP 0x20 +#define SA_SWITCHINFO_COMPMASK_DEFAULTPORT 0x40 +#define SA_SWITCHINFO_COMPMASK_DEFAULTMCASTPPORT 0x80 +#define SA_SWITCHINFO_COMPMASK_DEFAULTMCASTNPPORT 0x100 +#define SA_SWITCHINFO_COMPMASK_LIFETIMEVALUE 0x200 +#define SA_SWITCHINFO_COMPMASK_PORTSTATECHANGE 0x400 +#define SA_SWITCHINFO_COMPMASK_RESERVED2 0x800 +#define SA_SWITCHINFO_COMPMASK_LIDSPERPORT 0x1000 +#define SA_SWITCHINFO_COMPMASK_PARTENFCAP 0x2000 +#define SA_SWITCHINFO_COMPMASK_INBOUNDENFCAP 0x4000 +#define SA_SWITCHINFO_COMPMASK_OUTBOUNDENFCAP 0x8000 +#define SA_SWITCHINFO_COMPMASK_FILTERRAWPKTINCAP 0x10000 +#define SA_SWITCHINFO_COMPMASK_FILTERRAWPKTOUTCAP 0x20000 +#define SA_SWITCHINFO_COMPMASK_ENHANCED_PORT_0 0x40000 + +/* Linear Forwarding Table Record: Table 161 */ +typedef struct sa_linearft_record_s { + ib_lid_t LID; + uint16_t BlockNum; + uint32_t Reserved; + sm_linear_forwarding_table_t LinearFT; +} sa_linearft_record_t; + +#define SA_LFT_COMPMASK_LFTLID 0x1 +#define SA_LFT_COMPMASK_BLOCKNUM 0x2 +#define SA_LFT_COMPMASK_RESERVED 0x4 +#define SA_LFT_COMPMASK_LINEARFORWARDINGTABLE 0x8 + +/* Random Forwarding Table Record: Table 162 */ +typedef struct sa_randomft_record_s { + ib_lid_t LID; + uint16_t BlockNum; + uint32_t Reserved; + sm_random_forwarding_table_t RandomFT; +} sa_randomft_record_t; + +#define SA_RFT_COMPMASK_RFTLID 0x1 +#define SA_RFT_COMPMASK_BLOCKNUM 0x2 +#define SA_RFT_COMPMASK_RESERVED 0x4 +#define SA_RFT_COMPMASK_RANDOMFORWARDINGTABLE 0x8 + +/* Multicast Forwarding Table Record: Table 163 */ + +#if defined(_BIT_FIELDS_HTOL) +typedef struct sa_multicastft_record_s { + ib_lid_t LID; + uint16_t Position :4; /* position field of attr */ + uint16_t Reserved :3; + uint16_t BlockNum :9; + uint32_t Reserved2; + sm_multicast_forwarding_table_t MulticastFT; +} sa_multicastft_record_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sa_multicastft_record_s { + ib_lid_t LID; + uint16_t BlockNum :9; + uint16_t Reserved :3; + uint16_t Position :4; /* position field of attr */ + uint32_t Reserved2; + sm_multicast_forwarding_table_t MulticastFT; +} sa_multicastft_record_t; + +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_HTOL */ + +#define SA_MFT_COMPMASK_MFTLID 0x1 +#define SA_MFT_COMPMASK_POSITION 0x2 +#define SA_MFT_COMPMASK_RESERVED 0x4 +#define SA_MFT_COMPMASK_BLOCKNUM 0x8 +#define SA_MFT_COMPMASK_RESERVED2 0x10 +#define SA_MFT_COMPMASK_MULTICASTFORWARDINGTABLE 0x20 + +/* VLArbitration Table Record: Table 164 */ +typedef struct sa_VLarb_table_record_s { + ib_lid_t LID; + uint8_t OutputPortNum; + uint8_t BlockNum; + uint32_t Reserved; + sm_VLarb_table_t VLArbTable; +} sa_VLarb_table_record_t; + +#define SA_VLARB_COMPMASK_NODELID 0x1 +#define SA_VLARB_COMPMASK_OUTPUTPORTNUM 0x2 +#define SA_VLARB_COMPMASK_BLOCKNUM 0x4 +#define SA_VLARB_COMPMASK_RESERVED 0x8 +#define SA_VLARB_COMPMASK_VLARBTABLE 0x10 + +/* SMInfo Record: Table 165 */ +typedef struct _sminfo_record_s { + ib_lid_t LID; + uint16_t Reserved; + sm_sminfo_t SMInfo; +} sa_sminfo_record_t; + +#define SA_SMINFO_COMPMASK_NODELID 0x1 +#define SA_SMINFO_COMPMASK_RESERVED 0x2 +#define SA_SMINFO_COMPMASK_GUID 0x4 +#define SA_SMINFO_COMPMASK_SMKEY 0x8 +#define SA_SMINFO_COMPMASK_ACTCOUNT 0x10 +#define SA_SMINFO_COMPMASK_PRIORITY 0x20 +#define SA_SMINFO_COMPMASK_SMSTATE 0x40 + +/* P_Key Table Record: Table 166 */ +typedef struct sa_pkey_table_record_s { + ib_lid_t LID; + uint16_t BlockNum; + uint8_t PortNum; + uint8_t Reserved[3]; + sm_pkey_table_t P_KeyTable; +} sa_pkey_table_record_t; + +#define SA_PKEY_COMPMASK_PORTLID 0x1 +#define SA_PKEY_COMPMASK_BLOCKNUM 0x2 +#define SA_PKEY_COMPMASK_PORTNUM 0x4 +#define SA_PKEY_COMPMASK_RESERVED 0x8 +#define SA_PKEY_COMPMASK_PKEYTABLE 0x10 + +/* InformInfo Record: Table 167 */ +typedef struct sa_informinfo_record_s { + ib_gid_t SubscriberGID; + uint16_t Enum; + uint8_t Reserved[6]; + ib_mad_informinfo_t InformInfo; +} sa_informinfo_record_t; + +#define SA_INFORMINFO_COMPMASK_SUBGID 0x1 +#define SA_INFORMINFO_COMPMASK_ENUM 0x2 +#define SA_INFORMINFO_COMPMASK_RESERVED 0x4 +#define SA_INFORMINFO_COMPMASK_GID 0x8 +#define SA_INFORMINFO_COMPMASK_LIDRANGEBEGIN 0x10 +#define SA_INFORMINFO_COMPMASK_LIDRANGEEND 0x20 +#define SA_INFORMINFO_COMPMASK_RESERVED2 0x40 +#define SA_INFORMINFO_COMPMASK_ISGENERIC 0x80 +#define SA_INFORMINFO_COMPMASK_SUBSCRIBE 0x100 +#define SA_INFORMINFO_COMPMASK_TYPE 0x200 +#define SA_INFORMINFO_COMPMASK_TRAPNUM_DEVID 0x400 +#define SA_INFORMINFO_COMPMASK_QPN 0x800 +#define SA_INFORMINFO_COMPMASK_RESERVED3 0x1000 +#define SA_INFORMINFO_COMPMASK_RESPTIMEVALUE 0x2000 +#define SA_INFORMINFO_COMPMASK_RESERVED4 0x4000 +#define SA_INFORMINFO_COMPMASK_PRODTYPE_VENDID 0x8000 + +/* Link Record: Table 168 */ +typedef struct sa_link_record_s { + ib_lid_t FromLID; + uint8_t FromPort; + uint8_t ToPort; + ib_lid_t ToLID; +} sa_link_record_t; + +#define SA_LINKRECORD_COMPMASK_FROMLID 0x1 +#define SA_LINKRECORD_COMPMASK_FROMPORT 0x2 +#define SA_LINKRECORD_COMPMASK_TOPORT 0x4 +#define SA_LINKRECORD_COMPMASK_TOLID 0x8 + +/* Service Record: Table 169 */ +typedef struct sa_service_record_s { + uint64_t ServiceID; /* id of service on port */ + ib_gid_t ServiceGID; /* port GID for this service */ + uint16_t ServiceP_Key; /* p_key used to contact serv */ + uint16_t Reserved; + uint32_t ServiceLease; /* lease period remaining */ + uint64_t ServiceKey_hi; /* key value assoc. with serv */ + uint64_t ServiceKey_lo; + uint8_t ServiceName[IB_SVC_NAME_LEN]; + /* UTF-8 encoded service name */ + uint8_t ServiceData[IB_SVC_DATA_LEN]; + /* data for this service rec. */ +} sa_service_record_t; + +#define SA_SR_INDEFINITE_SERVICE_LEASE 0xFFFFFFFF + +/* + * #defines mapping individual bits of the service record component mask + * to components in the service record. ServiceData uses one component mask per + * bit. See the IB spec for details. + */ +#define SA_SR_COMPMASK_ID 0x1 +#define SA_SR_COMPMASK_GID 0x2 +#define SA_SR_COMPMASK_PKEY 0x4 +#define SA_SR_COMPMASK_RESERVED 0x8 +#define SA_SR_COMPMASK_LEASE 0x10 +#define SA_SR_COMPMASK_KEY 0x20 +#define SA_SR_COMPMASK_NAME 0x40 + +/* masks all ServiceData fields */ +#define SA_SR_COMPMASK_ALL_DATA 0x1FFFFFFF80 + +/* Service Association Record: Table 170 */ +typedef struct sa_service_assn_record_s { + uint64_t ServiceKey_hi; + uint64_t ServiceKey_lo; + uint8_t ServiceName[IB_SVC_NAME_LEN]; +} sa_service_assn_record_t; + +#define SA_SERVASSOC_COMPMASK_SERVICEKEY 0x1 +#define SA_SERVASSOC_COMPMASK_SERVICENAME 0x2 + +/* Path Record: Table 171 */ + +#if defined(_BIT_FIELDS_HTOL) +typedef struct sa_path_record_s { + uint32_t Reserved; + uint32_t Reserved2; + ib_gid_t DGID; /* dest gid of path */ + ib_gid_t SGID; /* source gid of path */ + uint16_t DLID; /* dest lid */ + uint16_t SLID; /* source lid */ + uint32_t RawTraffic :1; /* raw pkt path */ + uint32_t Reserved3 :3; + uint32_t FlowLabel :20; /* flow label */ + uint32_t HopLimit :8; /* hop limit */ + uint8_t TClass; /* TClass */ + uint8_t Reversible :1; /* reversible path required */ + uint8_t NumbPath :7; /* max num. of paths to ret. */ + uint16_t P_Key; /* partition key for path */ + uint16_t Reserved4 :12; + uint16_t SL :4; /* service level for path */ + uint8_t MtuSelector :2; /* MTU selector */ + uint8_t Mtu :6; /* required MTU */ + uint8_t RateSelector :2; /* rate selector */ + uint8_t Rate :6; /* value of rate */ + uint8_t PacketLifeTimeSelector:2; /* pkt life time selector */ + uint8_t PacketLifeTime :6; /* total packet life time */ + uint8_t Preference; /* in response, order of pref */ + /* among all paths */ + uint8_t Reserved5[6]; +} sa_path_record_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sa_path_record_s { + uint32_t Reserved; + uint32_t Reserved2; + ib_gid_t DGID; /* dest gid of path */ + ib_gid_t SGID; /* source gid of path */ + uint16_t DLID; /* dest lid */ + uint16_t SLID; /* source lid */ + uint32_t HopLimit :8; /* hop limit */ + uint32_t FlowLabel :20; /* flow label */ + uint32_t Reserved3 :3; + uint32_t RawTraffic :1; /* raw pkt path */ + uint8_t TClass; /* TClass */ + uint8_t NumbPath :7; /* max num. of paths to ret. */ + uint8_t Reversible :1; /* reversible path required */ + uint16_t P_Key; /* partition key for path */ + uint16_t SL :4; /* service level for path */ + uint16_t Reserved4 :12; + uint8_t Mtu :6; /* required MTU */ + uint8_t MtuSelector :2; /* MTU selector */ + uint8_t Rate :6; /* value of rate */ + uint8_t RateSelector :2; /* rate selector */ + uint8_t PacketLifeTime :6; /* total packet life time */ + uint8_t PacketLifeTimeSelector:2; /* pkt life time selector */ + uint8_t Preference; /* in response, order of pref */ + /* among all paths */ + uint8_t Reserved5[6]; +} sa_path_record_t; + +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* + * #defines mapping individual bits of the path record component mask + * to components in the path record + */ +#define SA_PR_COMPMASK_RESERVED 0x1 +#define SA_PR_COMPMASK_RESERVED2 0x2 +#define SA_PR_COMPMASK_DGID 0x4 +#define SA_PR_COMPMASK_SGID 0x8 +#define SA_PR_COMPMASK_DLID 0x10 +#define SA_PR_COMPMASK_SLID 0x20 +#define SA_PR_COMPMASK_RAWTRAFFIC 0x40 +#define SA_PR_COMPMASK_RESERVED3 0x80 +#define SA_PR_COMPMASK_FLOWLABEL 0x100 +#define SA_PR_COMPMASK_HOPLIMIT 0x200 +#define SA_PR_COMPMASK_TCLASS 0x400 +#define SA_PR_COMPMASK_REVERSIBLE 0x800 +#define SA_PR_COMPMASK_NUMBPATH 0x1000 +#define SA_PR_COMPMASK_PKEY 0x2000 +#define SA_PR_COMPMASK_RESERVED4 0x4000 +#define SA_PR_COMPMASK_SL 0x8000 +#define SA_PR_COMPMASK_MTUSELECTOR 0x10000 +#define SA_PR_COMPMASK_MTU 0x20000 +#define SA_PR_COMPMASK_RATESELECTOR 0x40000 +#define SA_PR_COMPMASK_RATE 0x80000 +#define SA_PR_COMPMASK_PKTLTSELECTOR 0x100000 +#define SA_PR_COMPMASK_PKTLT 0x200000 +#define SA_PR_COMPMASK_PREFERENCE 0x400000 + +#define SA_PR_RAWTRAFFIC_PKEY 0x1 +#define SA_PR_RAWTRAFFIC_NO_PKEY 0x0 +#define SA_PR_MTU_SEL_GREATER 0x0 +#define SA_PR_MTU_SEL_LESS 0x1 +#define SA_PR_MTU_SEL_EXACTLY 0x2 +#define SA_PR_MTU_SEL_LARGEST_AVAIL 0x3 +#define SA_PR_MTU_256 0x1 +#define SA_PR_MTU_512 0x2 +#define SA_PR_MTU_1024 0x3 +#define SA_PR_MTU_2048 0x4 +#define SA_PR_MTU_4096 0x5 +#define SA_PR_RATE_SEL_GREATER 0x0 +#define SA_PR_RATE_SEL_LESS 0x1 +#define SA_PR_RATE_SEL_EXACTLY 0x2 +#define SA_PR_RATE_SEL_LARGEST_AVAIL 0x3 +#define SA_PR_RATE_25 0x2 +#define SA_PR_RATE_10 0x3 +#define SA_PR_RATE_30 0x4 +#define SA_PR_LT_SEL_GREATER 0x0 +#define SA_PR_LT_SEL_LESS 0x1 +#define SA_PR_LT_SEL_EXACTLY 0x2 +#define SA_PR_LT_SEL_SMALLEST_AVAIL 0x3 + +/* MCMember Record: Table 176 */ + +#if defined(_BIT_FIELDS_HTOL) +typedef struct sa_mcmember_record_s { + ib_gid_t MGID; + ib_gid_t PortGID; + uint32_t Q_Key; + ib_lid_t MLID; + uint8_t MTUSelector :2; + uint8_t MTU :6; + uint8_t TClass; + uint16_t P_Key; + uint8_t RateSelector :2; + uint8_t Rate :6; + uint8_t PacketLifeTimeSelector :2; + uint8_t PacketLifeTime :6; + uint32_t SL :4; + uint32_t FlowLabel :20; + uint32_t HopLimit :8; + uint32_t Scope :4; + uint32_t JoinState :4; + uint32_t ProxyJoin :1; + uint32_t Reserved :23; +} sa_mcmember_record_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sa_mcmember_record_s { + ib_gid_t MGID; + ib_gid_t PortGID; + uint32_t Q_Key; + ib_lid_t MLID; + uint8_t MTU :6; + uint8_t MTUSelector :2; + uint8_t TClass; + uint16_t P_Key; + uint8_t Rate :6; + uint8_t RateSelector :2; + uint8_t PacketLifeTime :6; + uint8_t PacketLifeTimeSelector :2; + uint32_t HopLimit :8; + uint32_t FlowLabel :20; + uint32_t SL :4; + uint32_t Reserved :23; + uint32_t ProxyJoin :1; + uint32_t JoinState :4; + uint32_t Scope :4; +} sa_mcmember_record_t; + +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_HTOL */ + +#define SA_MC_COMPMASK_MGID 0x1 +#define SA_MC_COMPMASK_PORTGID 0x2 +#define SA_MC_COMPMASK_QKEY 0x4 +#define SA_MC_COMPMASK_MLID 0x8 +#define SA_MC_COMPMASK_MTUSELECTOR 0x10 +#define SA_MC_COMPMASK_MTU 0x20 +#define SA_MC_COMPMASK_TCLASS 0x40 +#define SA_MC_COMPMASK_PKEY 0x80 +#define SA_MC_COMPMASK_RATESELECTOR 0x100 +#define SA_MC_COMPMASK_RATE 0x200 +#define SA_MC_COMPMASK_PKTLTSELECTOR 0x400 +#define SA_MC_COMPMASK_PKTLT 0x800 +#define SA_MC_COMPMASK_SL 0x1000 +#define SA_MC_COMPMASK_FLOWLABEL 0x2000 +#define SA_MC_COMPMASK_HOPLIMIT 0x4000 +#define SA_MC_COMPMASK_SCOPE 0x8000 +#define SA_MC_COMPMASK_JOINSTATE 0x10000 +#define SA_MC_COMPMASK_PROXYJOIN 0x20000 +#define SA_MC_COMPMASK_RESERVED 0x40000 + +#define SA_MC_MTU_SEL_GREATER 0x0 +#define SA_MC_MTU_SEL_LESS 0x1 +#define SA_MC_MTU_SEL_EXACTLY 0x2 +#define SA_MC_MTU_SEL_LARGEST_AVAIL 0x3 +#define SA_MC_MTU_256 0x1 +#define SA_MC_MTU_512 0x2 +#define SA_MC_MTU_1024 0x3 +#define SA_MC_MTU_2048 0x4 +#define SA_MC_MTU_4096 0x5 +#define SA_MC_RATE_SEL_GREATER 0x0 +#define SA_MC_RATE_SEL_LESS 0x1 +#define SA_MC_RATE_SEL_EXACTLY 0x2 +#define SA_MC_RATE_SEL_LARGEST_AVAIL 0x3 +#define SA_MC_RATE_25 0x2 +#define SA_MC_RATE_10 0x3 +#define SA_MC_RATE_30 0x4 +#define SA_MC_LT_SEL_GREATER 0x0 +#define SA_MC_LT_SEL_LESS 0x1 +#define SA_MC_LT_SEL_EXACTLY 0x2 +#define SA_MC_LT_SMALLEST_AVAIL 0x3 + +/* GUIDInfo Record: Table 177 */ +typedef struct sa_guidinfo_record_s { + ib_lid_t LID; + uint8_t BlockNum; + uint8_t Reserved; + uint32_t Reserved2; + sm_guidinfo_t GUIDInfo; +} sa_guidinfo_record_t; + +#define SA_GUIDINFO_COMPMASK_PORTLID 0x1 +#define SA_GUIDINFO_COMPMASK_BLOCKNUM 0x2 +#define SA_GUIDINFO_COMPMASK_RESERVED 0x4 +#define SA_GUIDINFO_COMPMASK_RESERVEVD2 0x8 +#define SA_GUIDINFO_COMPMASK_GUIDINFO 0x10 + +/* Trace Record: Table 178 */ +typedef struct sa_trace_record_s { + ib_sn_prefix_t GIDPrefix; + uint16_t IOCGeneration; + uint8_t Reserved; + uint8_t NodeType; + uint64_t NodeID; + uint64_t ChassisID; + uint64_t EntryPortID; + uint64_t ExitPortID; + uint8_t EntryPort; + uint8_t ExitPort; +} sa_trace_record_t; + +#define SA_TRACE_COMPMASK_GIDPREFIX 0x1 +#define SA_TRACE_COMPMASK_IOCGENERATION 0x2 +#define SA_TRACE_COMPMASK_RESERVED 0x4 +#define SA_TRACE_COMPMASK_NODETYPE 0x8 +#define SA_TRACE_COMPMASK_NODEID 0x10 +#define SA_TRACE_COMPMASK_CHASSISID 0x20 +#define SA_TRACE_COMPMASK_ENTRYPORTID 0x40 +#define SA_TRACE_COMPMASK_EXITPORTID 0x80 +#define SA_TRACE_COMPMASK_ENTRYPORT 0x100 +#define SA_TRACE_COMPMASK_EXITPORT 0x200 + +/* + * MultiPath Record: Table 179 + * This structure only includes the constant portion of the multipath record. + * The multipath record request will contain a variable number of SGIDs and + * DGIDs at the end of this structure, as specified in the SGIDCount and + * DGIDCount fields. + */ + +#if defined(_BIT_FIELDS_HTOL) +typedef struct sa_mutipath_record_s { + uint32_t RawTraffic :1; /* raw pkt path */ + uint32_t Reserved :3; + uint32_t FlowLabel :20; /* flow label */ + uint32_t HopLimit :8; /* hop limit */ + uint8_t TClass; /* TClass */ + uint8_t Reversible :1; /* reversible path required */ + uint8_t NumbPath :7; /* max num. of paths to ret. */ + uint16_t P_Key; /* partition key for path */ + uint16_t Reserved2 :12; + uint16_t SL :4; /* service level for path */ + uint8_t MtuSelector :2; /* MTU selector */ + uint8_t Mtu :6; /* required MTU */ + uint8_t RateSelector :2; /* rate selector */ + uint8_t Rate :6; /* value of rate */ + uint8_t PacketLifeTimeSelector:2; /* pkt life time selector */ + uint8_t PacketLifeTime :6; /* total packet life time */ + uint8_t Reserved3; + uint8_t IndependenceSelector:2; /* fault-tolerant paths */ + uint8_t Reserved4 :6; + uint8_t SGIDCount; /* number of SGIDS */ + uint8_t DGIDCount; /* number of DGIDS */ + uint8_t Reserved5[7]; +} sa_multipath_record_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sa_mutipath_record_s { + uint32_t HopLimit :8; /* hop limit */ + uint32_t FlowLabel :20; /* flow label */ + uint32_t Reserved :3; + uint32_t RawTraffic :1; /* raw pkt path */ + uint8_t TClass; /* TClass */ + uint8_t NumbPath :7; /* max num. of paths to ret. */ + uint8_t Reversible :1; /* reversible path required */ + uint16_t P_Key; /* partition key for path */ + uint16_t SL :4; /* service level for path */ + uint16_t Reserved2 :12; + uint8_t Mtu :6; /* required MTU */ + uint8_t MtuSelector :2; /* MTU selector */ + uint8_t Rate :6; /* value of rate */ + uint8_t RateSelector :2; /* rate selector */ + uint8_t PacketLifeTime :6; /* total packet life time */ + uint8_t PacketLifeTimeSelector:2; /* pkt life time selector */ + uint8_t Reserved3; + uint8_t Reserved4 :6; + uint8_t IndependenceSelector:2; /* fault-tolerant paths */ + uint8_t SGIDCount; /* number of SGIDS */ + uint8_t DGIDCount; /* number of DGIDS */ + uint8_t Reserved5[7]; +} sa_multipath_record_t; + +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_HTOL */ + +#define SA_MPR_COMPMASK_RAWTRAFFIC 0x1 +#define SA_MPR_COMPMASK_RESERVED 0x2 +#define SA_MPR_COMPMASK_FLOWLABEL 0x4 +#define SA_MPR_COMPMASK_HOPLIMIT 0x8 +#define SA_MPR_COMPMASK_TCLASS 0x10 +#define SA_MPR_COMPMASK_REVERSIBLE 0x20 +#define SA_MPR_COMPMASK_NUMBPATH 0x40 +#define SA_MPR_COMPMASK_PKEY 0x80 +#define SA_MPR_COMPMASK_RESERVED2 0x100 +#define SA_MPR_COMPMASK_SL 0x200 +#define SA_MPR_COMPMASK_MTUSELECTOR 0x400 +#define SA_MPR_COMPMASK_MTU 0x800 +#define SA_MPR_COMPMASK_RATESELECTOR 0x1000 +#define SA_MPR_COMPMASK_RATE 0x2000 +#define SA_MPR_COMPMASK_PKTLTSELECTOR 0x4000 +#define SA_MPR_COMPMASK_PKTLT 0x8000 +#define SA_MPR_COMPMASK_RESERVED3 0x10000 +#define SA_MPR_COMPMASK_INDEPSEL 0x20000 +#define SA_MPR_COMPMASK_RESERVED4 0x40000 +#define SA_MPR_COMPMASK_SGIDCOUNT 0x80000 +#define SA_MPR_COMPMASK_DGIDCOUNT 0x100000 +#define SA_MPR_COMPMASK_RESERVED5 0x200000 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_MGT_SA_RECS_H */ diff --git a/illumos-x86_64/usr/include/sys/ib/mgt/sm_attr.h b/illumos-x86_64/usr/include/sys/ib/mgt/sm_attr.h new file mode 100644 index 00000000..e845651b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ib/mgt/sm_attr.h @@ -0,0 +1,856 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IB_MGT_SM_ATTR_H +#define _SYS_IB_MGT_SM_ATTR_H + +/* + * This file contains the definitions of the various attributes specified + * in IB spec volume 1, release 1.1, chapter 14. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define SM_MAX_DR_PATH 64 /* max ports in a DR path */ + +/* + * LID routed smp class header + */ +typedef struct sm_lid_class_hdr_s { + uint64_t M_Key; + uint8_t Reserved[32]; +} sm_lid_class_hdr_t; + +/* + * Directed route smp mad header + */ +typedef struct sm_dr_mad_hdr_s { + /* Common MAD Header1: 4 bytes, bytes 0-3 of header */ + uint8_t BaseVersion; /* version of MAD base format */ + uint8_t MgmtClass; /* class of operation */ + uint8_t ClassVersion; /* version of MAD class format */ + uint8_t R_Method; /* response bit & method to */ + /* perform based on mgmtclass */ + + uint16_t D_Status; /* direction, status unused */ + uint8_t HopPointer; /* index into Initial/Return Paths */ + uint8_t HopCount; /* number of directed route hops */ + + + /* Common MAD Header2: 16 bytes, bytes 8-23 of header */ + uint64_t TransactionID; /* transaction id */ + uint16_t AttributeID; /* defines class spec. objects */ + uint16_t Reserved; + uint32_t AttributeModifier; /* further scope to attributes */ +} sm_dr_mad_hdr_t; + +/* Direction bit */ +#define SM_DR_SMP_D_OUT 0x0000 /* SMP is outbound from SM */ +#define SM_DR_SMP_D_IN 0x8000 /* SMP is inbound to SM */ +#define SM_DR_SMP_D_MASK 0x8000 /* direction mask */ + +#define SM_DR_SMP_STATUS_MASK 0x7FFF + +/* + * Direct route smp class header: + */ +typedef struct sm_dr_class_hdr_s { + uint64_t M_Key; + ib_lid_t DrSLID; + ib_lid_t DrDLID; + uint8_t Reserved[28]; +} sm_dr_class_hdr_t; + +typedef struct sm_dr_data_s { + uint8_t Data[64]; + uint8_t InitialPath[SM_MAX_DR_PATH]; + uint8_t ReturnPath[SM_MAX_DR_PATH]; +} sm_dr_data_t; + +/* Traps: Table 118 */ +#define SM_GID_IN_SERVICE_TRAP 64 +#define SM_GID_OUT_OF_SERVICE_TRAP 65 +#define SM_MGID_CREATED_TRAP 66 +#define SM_MGID_DESTROYED_TRAP 67 +#define SM_LINK_STATE_CHANGED_TRAP 128 +#define SM_LINK_INTEGRITY_THRESHOLD_TRAP 129 +#define SM_BUFFER_OVERRUN_THRESHOLD_TRAP 130 +#define SM_WATCHDOG_TIMER_EXPIRED_TRAP 131 +#define SM_CAP_MASK_CHANGED_TRAP 144 +#define SM_SYS_IMG_GUID_CHANGED_TRAP 145 +#define SM_BAD_MKEY_TRAP 256 +#define SM_BAD_PKEY_TRAP 257 +#define SM_BAD_QKEY_TRAP 258 +#define SM_BAD_SWITCH_PKEY_TRAP 259 + +/* + * Notice Data details for various sm traps + */ +/* Traps 64, 65, 66,and 67: Table 119 */ +typedef struct sm_trap_64_s { + uint8_t Reserved[6]; + ib_gid_t GIDADDR; /* global identifier */ + uint8_t Padding[32]; +} sm_trap_64_t; + +typedef sm_trap_64_t sm_trap_65_t; +typedef sm_trap_64_t sm_trap_66_t; +typedef sm_trap_64_t sm_trap_67_t; + +/* Trap 128: Table 120 */ +typedef struct sm_trap_128_s { + ib_lid_t LIDADDR; /* trap generator's LID */ + uint8_t Padding[52]; +} sm_trap_128_t; + +/* Traps 129, 130, and 131: Table 121 */ +typedef struct sm_trap_129_s { + uint16_t Reserved; + ib_lid_t LIDADDR; /* generator's LID */ + uint8_t PORTNO; /* generator's port */ + uint8_t Padding[49]; +} sm_trap_129_t; + +typedef sm_trap_129_t sm_trap_130_t; +typedef sm_trap_129_t sm_trap_131_t; + +/* Trap 144: Table 122 */ +typedef struct sm_trap_144_s { + uint16_t Reserved; + ib_lid_t LIDADDR; /* generator's LID */ + uint16_t Reserved2; + uint32_t CAPABILITYMASK; /* generator's CapMask */ + uint8_t Padding[44]; +} sm_trap_144_t; + +/* Trap 145: Table 123 */ +typedef struct sm_trap_145_s { + uint16_t Reserved; + ib_lid_t LIDADDR; + uint16_t Reserved2; + ib_guid_t SYSTEMIMAGEGUID; /* generator's SysImage GUID */ + uint8_t Padding[40]; +} sm_trap_145_t; + +/* Trap 256: Table 124 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_trap_256_s { + uint16_t Reserved; + ib_lid_t LIDADDR; /* generator's LID */ + uint16_t Reserved1; + uint8_t METHOD; /* method */ + uint8_t Reserved2; + uint16_t ATTRIBUTEID; /* attribute casuing the trap */ + uint32_t ATTRIBUTEMODIFIER; /* modifier for the attrib */ + uint64_t MKEY; + uint8_t DRSLID; /* SLID of SMP causing notice */ + uint8_t DRNotice :1; /* notice from a dr SMP */ + uint8_t DRPathTruncated :1; /* return path is truncated */ + uint8_t DRHopCount :6; /* num bytes in return path */ + uint8_t DRNoticeReturnPath[30]; /* return path from the SMP */ +} sm_trap_256_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_trap_256_s { + uint16_t Reserved; + ib_lid_t LIDADDR; /* generator's LID */ + uint16_t Reserved1; + uint8_t METHOD; /* method */ + uint8_t Reserved2; + uint16_t ATTRIBUTEID; /* attribute casuing the trap */ + uint32_t ATTRIBUTEMODIFIER; /* modifier for the attrib */ + uint64_t MKEY; + uint8_t DRSLID; /* SLID of SMP causing notice */ + uint8_t DRHopCount :6; /* num bytes in return path */ + uint8_t DRPathTruncated :1; /* return path is truncated */ + uint8_t DRNotice :1; /* notice from a dr SMP */ + uint8_t DRNoticeReturnPath[30]; /* return path from the SMP */ +} sm_trap_256_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* Traps 257 and 258: Table 125 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_trap_257_s { + uint16_t Reserved; + ib_lid_t LIDADDR1; /* see spec description */ + ib_lid_t LIDADDR2; + uint32_t KEY; /* qkey or pkey */ + uint32_t SL :4; /* sl for the trap */ + uint32_t Reserved2 :4; /* reserved */ + uint32_t QP :24; /* queue pair */ + uint32_t Reserved3 :8; + uint32_t QP2 :24; /* queue pair */ + ib_gid_t GIDADDR1; /* see spec description */ + ib_gid_t GIDADDR2; + uint8_t Padding[4]; +} sm_trap_257_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_trap_257_s { + uint16_t Reserved; + ib_lid_t LIDADDR1; /* see spec description */ + ib_lid_t LIDADDR2; + uint32_t KEY; /* qkey or pkey */ + uint32_t QP :24; /* queue pair */ + uint32_t Reserved2 :4; /* reserved */ + uint32_t SL :4; /* sl for the trap */ + uint32_t QP2 :24; /* queue pair */ + uint32_t Reserved3 :8; + ib_gid_t GIDADDR1; /* see spec description */ + ib_gid_t GIDADDR2; + uint8_t Padding[4]; +} sm_trap_257_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +typedef sm_trap_257_t sm_trap_258_t; + +/* Trap 259: Table 126 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_trap_259_s { + uint16_t DataValid; /* validity of optional data */ + ib_lid_t LIDADDR1; /* see spec description */ + ib_lid_t LIDADDR2; + uint16_t PKEY; /* pkey */ + uint32_t SL :4; /* service level */ + uint32_t Reserved :4; + uint32_t QP1 :24; /* queue pair */ + uint32_t Reserved8 :8; + uint32_t QP2 :24; /* queue pair */ + ib_gid_t GIDADDR1; /* see spec description */ + ib_gid_t GIDADDR2; + ib_lid_t SWLIDADDR; /* lid of switch */ + uint8_t PORTNO; /* port number */ + uint8_t Padding[3]; +} sm_trap_259_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_trap_259_s { + uint16_t DataValid; /* validity of optional data */ + ib_lid_t LIDADDR1; /* see spec description */ + ib_lid_t LIDADDR2; + uint16_t PKEY; /* pkey */ + uint32_t QP1 :24; /* queue pair */ + uint32_t Reserved :4; + uint32_t SL :4; /* service level */ + uint32_t QP2 :24; /* queue pair */ + uint32_t Reserved8 :8; + ib_gid_t GIDADDR1; /* see spec description */ + ib_gid_t GIDADDR2; + ib_lid_t SWLIDADDR; /* lid of switch */ + uint8_t PORTNO; /* port number */ + uint8_t Padding[3]; +} sm_trap_259_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* + * NodeDescription: Table 127 + * NodeDescription is applicable to all ports of a node. + */ +typedef struct sm_nodedesc_s { + uint8_t NodeString[64]; /* description string */ +} sm_nodedesc_t; + +/* + * NodeInfo: Table 128 + * The value of some NodeInfo components varies by port within a node. + */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_nodeinfo_s { + uint8_t BaseVersion; /* supported MAD base version */ + uint8_t ClassVersion; /* support SMP version */ + uint8_t NodeType; /* node type(CA, switch, etc) */ + uint8_t NumPorts; /* # of phys ports on node */ + ib_guid_t SystemImageGUID; /* GUID associating this node */ + /* with nodes controlled by */ + /* common supervisory code */ + ib_guid_t NodeGUID; /* GUID of the node itself */ + ib_guid_t PortGUID; /* GUID of this port */ + uint16_t PartitionCap; /* # of entries in part. tbl. */ + uint16_t DeviceID; /* device ID info */ + uint32_t Revision; /* device revision */ + uint32_t LocalPortNum :8; /* link port # SMP came in on */ + uint32_t VendorID :24; /* device vendor, per IEEE */ +} sm_nodeinfo_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_nodeinfo_s { + uint8_t BaseVersion; /* supported MAD base version */ + uint8_t ClassVersion; /* support SMP version */ + uint8_t NodeType; /* node type(CA, switch, etc) */ + uint8_t NumPorts; /* # of phys ports on node */ + ib_guid_t SystemImageGUID; /* GUID associating this node */ + /* with nodes controlled by */ + /* common supervisory code */ + ib_guid_t NodeGUID; /* GUID of the node itself */ + ib_guid_t PortGUID; /* GUID of this port */ + uint16_t PartitionCap; /* # of entries in part. tbl. */ + uint16_t DeviceID; /* device ID info */ + uint32_t Revision; /* device revision */ + uint32_t VendorID :24; /* device vendor, per IEEE */ + uint32_t LocalPortNum :8; /* link port # SMP came in on */ +} sm_nodeinfo_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* Defines and Masks that go with NodeInfo */ +#define SM_NODE_TYPE_CA 0x01 +#define SM_NODE_TYPE_SWITCH 0x02 +#define SM_NODE_TYPE_ROUTER 0x03 + +/* SwitchInfo: Table 129 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_switchinfo_s { + uint16_t LinearFDBCap; /* max # of lin FDB entries */ + uint16_t RandomFDBCap; /* max # of ran FDB entries */ + uint16_t MulticastFDBCap; /* max # of mc FDB entries */ + uint16_t LinearFDBTop; /* top of the linear FDB */ + uint8_t DefaultPort; /* port when DLID not in FDB */ + uint8_t DefaultMulticastPrimaryPort; /* mcast port when DLID */ + /* not in FDB */ + uint8_t DefaultMulticastNotPrimaryPort; /* mcast port when */ + /* pkts from def port */ + /* have DLID not in FDB */ + uint8_t LifeTimeValue :5; /* time pkt can live in sw */ + uint8_t PortStateChange :1; /* change in port state value */ + uint8_t Reserved :2; + uint16_t LIDsPerPort; /* max # of LID/LMCs per port */ + uint16_t PartitionEnforcementCap; /* max entries in p. enf tbl */ + uint8_t PartitionChecks :4; /* switch enforcement knobs */ + uint8_t EnhancedPort0 :1; /* enhanced port 0 supported */ + uint8_t Reserved2 :3; +} sm_switchinfo_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_switchinfo_s { + uint16_t LinearFDBCap; /* max # of lin FDB entries */ + uint16_t RandomFDBCap; /* max # of ran FDB entries */ + uint16_t MulticastFDBCap; /* max # of mc FDB entries */ + uint16_t LinearFDBTop; /* top of the linear FDB */ + uint8_t DefaultPort; /* port when DLID not in FDB */ + uint8_t DefaultMulticastPrimaryPort; /* mcast port when DLID */ + /* not in FDB */ + uint8_t DefaultMulticastNotPrimaryPort; /* mcast port when */ + /* pkts from def port */ + /* have DLID not in FDB */ + uint8_t Reserved :2; + uint8_t PortStateChange :1; /* change in port state value */ + uint8_t LifeTimeValue :5; /* time pkt can live in sw */ + uint16_t LIDsPerPort; /* max # of LID/LMCs per port */ + uint16_t PartitionEnforcementCap; /* max entries in p. enf tbl */ + uint8_t Reserved2 :3; + uint8_t EnhancedPort0 :1; /* enhanced port 0 supported */ + uint8_t PartitionChecks :4; /* switch enforcement knobs */ +} sm_switchinfo_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* Defines and Masks that go with SwitchInfo */ +#define SM_PORT_STATE_CHANGE_CLEAR 0x1 +#define SM_SWITCH_PART_ENF_IN 0x8 +#define SM_SWITCH_PART_ENF_IN_MASK 0x8 +#define SM_SWITCH_PART_ENF_OUT 0x4 +#define SM_SWITCH_PART_ENF_OUT_MASK 0x4 +#define SM_SWITCH_FILTER_RAW_IN 0x2 +#define SM_SWITCH_FILTER_RAW_IN_MASK 0x2 +#define SM_SWITCH_FILTER_RAW_OUT 0x1 +#define SM_SWITCH_FILTER_RAW_OUT_MASK 0x1 + +/* GUIDInfo: Table 130 */ +typedef struct sm_guidinfo_s { + ib_guid_t GUIDBlocks[8]; +} sm_guidinfo_t; + +/* defines that go with guid info */ +#define SM_GUIDINFO_BLOCK_MAX 31 + +/* + * PortInfo: Table 132 + * PortInfo is applicable to all ports of a node. + */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_portinfo_s { + uint64_t M_Key; /* M_key */ + ib_sn_prefix_t GidPrefix; /* Gid prefix */ + ib_lid_t LID; /* base LID of the port */ + ib_lid_t MasterSMLID; /* LID of the master SM */ + uint32_t CapabilityMask; /* Capability Mask */ + uint16_t DiagCode; /* diag code */ + uint16_t M_KeyLeasePeriod; /* M_key lease period */ + uint8_t LocalPortNum; /* port which recvd the MAD */ + uint8_t LinkWidthEnabled; /* link width(s) enabled */ + uint8_t LinkWidthSupported; /* widths supported by port */ + uint8_t LinkWidthActive; /* Currently active width */ + uint8_t LinkSpeedSupported:4; /* link speed supported */ + uint8_t PortState :4; /* port state */ + uint8_t PortPhysicalState:4; /* port physical state */ + uint8_t LinkDownDefaultState:4; /* see spec description */ + uint8_t M_KeyProtectBits:2; /* M-key protection bits */ + uint8_t Reserved :3; + uint8_t LMC :3; /* LID mask count */ + uint8_t LinkSpeedActive :4; /* current active link speed */ + uint8_t LinkSpeedEnabled:4; /* enabled link speed */ + uint8_t NeighborMTU :4; /* Active max MTU for port */ + uint8_t MasterSMSL :4; /* admin SL of master SM */ + uint8_t VLCap :4; /* virtual lanes supported */ + uint8_t InitType :4; /* type of init requested */ + uint8_t VLHighLimit; /* VL high pri limit */ + uint8_t VLArbitrationHighCap; /* max high pri entries in */ + /* VL arbitration table */ + uint8_t VLArbitrationLowCap; /* max low pri entries */ + uint8_t InitTypeReply :4; /* type of init performed */ + uint8_t MTUCap :4; /* max MTU supported */ + uint8_t VLStallCount :3; /* # pkts to enter stall st. */ + uint8_t HOQLife :5; /* time pkt can live at HOQ */ + uint8_t OperationalVLs :4; /* virtual lanes operational */ + uint8_t PartitionChecks :4; /* port enforcement knbos */ + uint16_t M_KeyViolations; /* count of M_key violations */ + uint16_t P_KeyViolations; /* count of P_key violations */ + uint16_t Q_KeyViolations; /* count of Q_key violations */ + uint8_t GUIDCap; /* number of GUIDs supported */ + uint8_t ClientRereg :1; /* Client ReReg supported */ + uint8_t Reserved2 :2; + uint8_t SubnetTimeOut :5; /* defines subnet prop. dely */ + uint8_t Reserved3 :3; + uint8_t RespTimeValue :5; /* defines resp time to SMPs */ + uint8_t LocalPhyErrors :4; /* threshold for errors */ + uint8_t OverrunErrors :4; /* threshold for errors */ +} sm_portinfo_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_portinfo_s { + uint64_t M_Key; /* M_key */ + ib_sn_prefix_t GidPrefix; /* Gid prefix */ + ib_lid_t LID; /* base LID of the port */ + ib_lid_t MasterSMLID; /* LID of the master SM */ + uint32_t CapabilityMask; /* Capability Mask */ + uint16_t DiagCode; /* diag code */ + uint16_t M_KeyLeasePeriod; /* M_key lease period */ + uint8_t LocalPortNum; /* port which recvd the MAD */ + uint8_t LinkWidthEnabled; /* link width(s) enabled */ + uint8_t LinkWidthSupported; /* widths supported by port */ + uint8_t LinkWidthActive; /* Currently active width */ + uint8_t PortState :4; /* port state */ + uint8_t LinkSpeedSupported:4; /* link speed supported */ + uint8_t LinkDownDefaultState:4; /* see spec description */ + uint8_t PortPhysicalState:4; /* port physical state */ + uint8_t LMC :3; /* LID mask count */ + uint8_t Reserved :3; + uint8_t M_KeyProtectBits:2; /* M-key protection bits */ + uint8_t LinkSpeedEnabled:4; /* enabled link speed */ + uint8_t LinkSpeedActive :4; /* current active link speed */ + uint8_t MasterSMSL :4; /* admin SL of master SM */ + uint8_t NeighborMTU :4; /* Active max MTU for port */ + uint8_t InitType :4; /* type of init requested */ + uint8_t VLCap :4; /* virtual lanes supported */ + uint8_t VLHighLimit; /* VL high pri limit */ + uint8_t VLArbitrationHighCap; /* max high pri entries in */ + /* VL arbitration table */ + uint8_t VLArbitrationLowCap; /* max low pri entries */ + uint8_t MTUCap :4; /* max MTU supported */ + uint8_t InitTypeReply :4; /* type of init performed */ + uint8_t HOQLife :5; /* time pkt can live at HOQ */ + uint8_t VLStallCount :3; /* # pkts to enter stall st. */ + uint8_t PartitionChecks :4; /* port enforcement knbos */ + uint8_t OperationalVLs :4; /* virtual lanes operational */ + uint16_t M_KeyViolations; /* count of M_key violations */ + uint16_t P_KeyViolations; /* count of P_key violations */ + uint16_t Q_KeyViolations; /* count of Q_key violations */ + uint8_t GUIDCap; /* number of GUIDs supported */ + uint8_t SubnetTimeOut :5; /* defines subnet prop. dely */ + uint8_t Reserved2 :2; + uint8_t ClientRereg :1; /* Client ReReg supported */ + uint8_t RespTimeValue :5; /* defines resp time to SMPs */ + uint8_t Reserved3 :3; + uint8_t OverrunErrors :4; /* threshold for errors */ + uint8_t LocalPhyErrors :4; /* threshold for errors */ +} sm_portinfo_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* Defines and Masks that go with PortInfo */ +#define SM_CAP_MASK_IS_SM 0x00000002 +#define SM_CAP_MASK_IS_NOTICE_SUPPD 0x00000004 +#define SM_CAP_MASK_IS_TRAP_SUPPD 0x00000008 +#define SM_CAP_MASK_IS_RESET_SUPPD 0x00000010 +#define SM_CAP_MASK_IS_APM_SUPPD 0x00000020 +#define SM_CAP_MASK_IS_SLMAPP_SUPPD 0x00000040 +#define SM_CAP_MASK_IS_NVRAM_MKEY 0x00000080 +#define SM_CAP_MASK_IS_NVRAM_PKEY 0x00000100 +#define SM_CAP_MASK_IS_LEDINFO_SUPPD 0x00000200 +#define SM_CAP_MASK_IS_SM_DISABLED 0x00000400 +#define SM_CAP_MASK_IS_SYSIMG_GUID_DISABLED 0x00000800 +#define SM_CAP_MASK_IS_PKEY_SW_TRAP_DISABLED 0x00001000 +#define SM_CAP_MASK_IS_CM_SUPPD 0x00010000 +#define SM_CAP_MASK_IS_SNMP_SUPPD 0x00020000 +#define SM_CAP_MASK_IS_DM_SUPPD 0x00080000 +#define SM_CAP_MASK_IS_VM_SUPPD 0x00100000 +#define SM_CAP_MASK_IS_DR_NOTICE_SUPPD 0x00200000 +#define SM_CAP_MASK_IS_CAP_MASK_NOTICE_SUPPD 0x00400000 +#define SM_CAP_MASK_IS_BOOT_MGMT_SUPPD 0x00800000 +#define SM_CAP_MASK_IS_CLNT_REREG_SUPPD 0x02000000 + +/* Standard Encoding of DiagCode Bits 3-0: Table 133 */ +#define SM_DIAG_CODE_PORT_READY 0x0 +#define SM_DIAG_CODE_PERFORMING_SELF_TEST 0x1 +#define SM_DIAG_CODE_INITIALIZING 0x2 +#define SM_DIAG_CODE_SOFT_ERROR 0x3 +#define SM_DIAG_CODE_HARD_ERROR 0x4 + +#define SM_LINK_WIDTH_ENABLED_NOP 0x00 +#define SM_LINK_WIDTH_ENABLED_1X 0x01 +#define SM_LINK_WIDTH_ENABLED_4X 0x02 +#define SM_LINK_WIDTH_ENABLED_1X_4X 0x03 +#define SM_LINK_WIDTH_ENABLED_12X 0x08 +#define SM_LINK_WIDTH_ENABLED_1X_12X 0x09 +#define SM_LINK_WIDTH_ENABLED_4X_12X 0x0A +#define SM_LINK_WIDTH_ENABLED_1X_4X_12X 0x0B +#define SM_LINK_WIDTH_ENABLED_SUPPORTED 0xFF + +#define SM_LINK_WIDTH_SUPP_1X 0x01 +#define SM_LINK_WIDTH_SUPP_1X_4X 0x03 +#define SM_LINK_WIDTH_SUPP_1X_4X_12X 0x0B + +#define SM_LINK_WIDTH_ACTIVE_1X 0x01 +#define SM_LINK_WIDTH_ACTIVE_4X 0x02 +#define SM_LINK_WIDTH_ACTIVE_8X 0x04 +#define SM_LINK_WIDTH_ACTIVE_12X 0x08 + +#define SM_LINK_SPEED_SUPP_2_5_GBPS 0x1 + +#define SM_PORT_STATE_NOP 0x0 +#define SM_PORT_STATE_DOWN 0x1 +#define SM_PORT_STATE_INITIALIZE 0x2 +#define SM_PORT_STATE_ARMED 0x3 +#define SM_PORT_STATE_ACTIVE 0x4 + +#define SM_PORT_PHYS_STATE_NOP 0x0 +#define SM_PORT_PHYS_STATE_SLEEP 0x1 +#define SM_PORT_PHYS_STATE_POLLING 0x2 +#define SM_PORT_PHYS_STATE_DISABLED 0x3 +#define SM_PORT_PHYS_STATE_TRAINING 0x4 +#define SM_PORT_PHYS_STATE_LINK_UP 0x5 +#define SM_PORT_PHYS_STATE_LINK_REC 0x6 + +#define SM_LINK_DOWN_DEFAULT_NOP 0x0 +#define SM_LINK_DOWN_DEFAULT_SLEEP 0x1 +#define SM_LINK_DOWN_DEFAULT_POLLING 0x2 + +/* MKey Protection Levels: Table 115 */ +#define SM_MKEY_PROT_BITS_ALL_SUCCEED 0x0 +#define SM_MKEY_PROT_BITS_GETRESP_RESETS 0x1 +#define SM_MKEY_PROT_BITS_SET_FAIL 0x2 +#define SM_MKEY_PROT_BITS_SET_FAILX 0x3 + +#define SM_LINK_SPEED_ACTIVE_2_5_GBPS 0x1 +#define SM_LINK_SPEED_ACTIVE_5_GBPS 0x2 +#define SM_LINK_SPEED_ACTIVE_10_GBPS 0x4 + +#define SM_LINK_SPEED_ENABLED_NOP 0x0 +#define SM_LINK_SPEED_ENABLED_2_5_GBPS 0x1 +#define SM_LINK_SPEED_ENABLED_SUPP_VALUE 0xF + +#define SM_NEIGHBOR_MTU_256 0x1 +#define SM_NEIGHBOR_MTU_512 0x2 +#define SM_NEIGHBOR_MTU_1024 0x3 +#define SM_NEIGHBOR_MTU_2048 0x4 +#define SM_NEIGHBOR_MTU_4096 0x5 + +#define SM_VL_CAP_VL0 0x1 +#define SM_VL_CAP_VL0_VL1 0x2 +#define SM_VL_CAP_VL0_VL3 0x3 +#define SM_VL_CAP_VL0_VL7 0x4 +#define SM_VL_CAP_VL0_VL14 0x5 + +#define SM_INIT_TYPE_NO_LOAD 0x1 +#define SM_INIT_TYPE_PRESERVE_CONTENT 0x2 +#define SM_INIT_TYPE_PRESERVE_PRESENCE 0x4 +#define SM_INIT_TYPE_DO_NOT_RESUSCITATE 0x8 + +#define SM_INIT_TYPE_REPLY_NO_LOAD_REPLY 0x1 +#define SM_INIT_TYPE_PRESERVE_CONTENT_REPLY 0x2 +#define SM_INIT_TYPE_PRESERVE_PRESENCE_REPLY 0x4 + +#define SM_MTU_CAP_256 0x1 +#define SM_MTU_CAP_512 0x2 +#define SM_MTU_CAP_1024 0x3 +#define SM_MTU_CAP_2048 0x4 +#define SM_MTU_CAP_4096 0x5 + +#define SM_HOQ_LIFE_INFINITY 19 /* from IB spec 18.2.5.4 */ + +#define SM_OPERATIONAL_VLS_NOP 0x0 +#define SM_OPERATIONAL_VLS_VL0 0x1 +#define SM_OPERATIONAL_VLS_VL0_VL1 0x2 +#define SM_OPERATIONAL_VLS_VL0_VL3 0x3 +#define SM_OPERATIONAL_VLS_VL0_VL7 0x4 +#define SM_OPERATIONAL_VLS_VLO_VL14 0x5 + +#define SM_PART_ENF_IN_BOUND 0x8 +#define SM_PART_ENF_OUT_BOUND 0x4 +#define SM_FILTER_RAW_IN_BOUND 0x2 +#define SM_FILTER_RAW_OUT_BOUND 0x1 + +/* P_Key Table: Table 134 */ +typedef struct sm_pkey_table_s { + uint16_t P_KeyTableBlocks[32]; /* List of 32 P_Key Block Elements */ +} sm_pkey_table_t; + +/* P_Key Block Element: Table 135 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_pkey_block_element_s { + uint16_t MembershipType :1; /* 0 is limited; 1 is full type */ + uint16_t P_KeyBase :15; /* base value of P_Key */ +} sm_pkey_block_element_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_pkey_block_element_s { + uint16_t P_KeyBase :15; /* base value of P_Key */ + uint16_t MembershipType :1; /* 0 is limited; 1 is full type */ +} sm_pkey_block_element_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* + * SLtoVLMapping Table: Table 136 + * Each field specifies the VL onto which packets using that SL are dropped. + */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_SLtoVL_mapping_table_s { + uint8_t SL0toVL :4; + uint8_t SL1toVL :4; + uint8_t SL2toVL :4; + uint8_t SL3toVL :4; + uint8_t SL4toVL :4; + uint8_t SL5toVL :4; + uint8_t SL6toVL :4; + uint8_t SL7toVL :4; + uint8_t SL8toVL :4; + uint8_t SL9toVL :4; + uint8_t SL10toVL :4; + uint8_t SL11toVL :4; + uint8_t SL12toVL :4; + uint8_t SL13toVL :4; + uint8_t SL14toVL :4; + uint8_t SL15toVL :4; +} sm_SLtoVL_mapping_table_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_SLtoVL_mapping_table_s { + uint8_t SL1toVL :4; + uint8_t SL0toVL :4; + uint8_t SL3toVL :4; + uint8_t SL2toVL :4; + uint8_t SL5toVL :4; + uint8_t SL4toVL :4; + uint8_t SL7toVL :4; + uint8_t SL6toVL :4; + uint8_t SL9toVL :4; + uint8_t SL8toVL :4; + uint8_t SL11toVL :4; + uint8_t SL10toVL :4; + uint8_t SL13toVL :4; + uint8_t SL12toVL :4; + uint8_t SL15toVL :4; + uint8_t SL14toVL :4; +} sm_SLtoVL_mapping_table_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* VL/Weight Block Element: Table 138 */ +typedef struct sm_VL_weight_block_s { + uint8_t Reserved :4; + uint8_t VL :4; /* VL assoc. with this element */ + uint8_t Weight; /* weight assoc. with this element */ +} sm_VL_weight_block_t; + +/* VLArbitration Table: Table 137 */ +typedef struct sm_VLarb_table_s { + sm_VL_weight_block_t VLWeightPairs[32]; +} sm_VLarb_table_t; + +/* Defines and masks that go with VLArbitrationTable & address modifier */ +#define SM_LOW_PRI_VL_ARB_LOWER_32 0x1 +#define SM_LOW_PRI_VL_ARB_UPPER_32 0x2 +#define SM_HI_PRI_VL_ARB_LOWER_32 0x3 +#define SM_HI_PRI_VL_ARB_UPPER_32 0x4 + +/* Defines that go with the linear forwarding table */ +#define SM_LFT_BLOCK_MAX 767 +#define SM_LFT_PORTS_PER_BLOCK 64 + +/* Linear Forwarding Table: Table 139 */ +typedef struct sm_linear_forwarding_table_s { + uint8_t PortBlocks[64]; +} sm_linear_forwarding_table_t; + +/* LID/Port Block Element: Table 142 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_lid_port_block_s { + ib_lid_t LID; /* base LID */ + uint8_t Valid :1; /* this LID/Port pair is valid */ + uint8_t LMC :3; /* the LMC of this lid */ + uint8_t Reserved :4; + uint8_t Port; /* port to forward entries to */ +} sm_lid_port_block_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_lid_port_block_s { + ib_lid_t LID; /* base LID */ + uint8_t Reserved :4; + uint8_t LMC :3; /* the LMC of this lid */ + uint8_t Valid :1; /* this LID/Port pair is valid */ + uint8_t Port; /* port to forward entries to */ +} sm_lid_port_block_t; +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* Random Forwarding Table: Table 141 */ +typedef struct sm_random_forwarding_table_s { + sm_lid_port_block_t LIDPortBlocks[16]; +} sm_random_forwarding_table_t; + +/* Multicast Forwarding Table: Table 143 */ +typedef struct sm_multicast_forwarding_table_s { + uint16_t PortMaskBlocks[32]; +} sm_multicast_forwarding_table_t; + +/* + * SMInfo: Table 145 + * SMInfo struct is applicable to all end ports hosting an SM + */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_sminfo_s { + ib_guid_t GUID; /* Port GUID hosting the SM */ + uint64_t SM_Key; /* Key of the SM */ + uint32_t ActCount; /* heartbeat counter */ + uint8_t Priority :4; /* priority */ + uint8_t SMState :4; /* SM's state */ +} sm_sminfo_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_sminfo_s { + ib_guid_t GUID; /* Port GUID hosting the SM */ + uint64_t SM_Key; /* Key of the SM */ + uint32_t ActCount; /* heartbeat counter */ + uint8_t SMState :4; /* SM's state */ + uint8_t Priority :4; /* priority */ +} sm_sminfo_t; + +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* defines that go with the sminfo structure */ + +/* SMState Defines */ +#define SM_SMSTATE_INACTIVE 0 +#define SM_SMSTATE_DISCOVERING 1 +#define SM_SMSTATE_STANDBY 2 +#define SM_SMSTATE_MASTER 3 + +/* SMInfo Control Packets: Table 148 */ +#define SM_SMINFO_AM_HANDOVER 1 +#define SM_SMINFO_AM_ACKNOWLEDGE 2 +#define SM_SMINFO_AM_DISABLE 3 +#define SM_SMINFO_AM_STANDBY 4 +#define SM_SMINFO_AM_DISCOVER 5 + +/* attribute ID defines */ +#define SM_NOTICE_ATTRID 0x02 +#define SM_NODEDESC_ATTRID 0x10 +#define SM_NODEINFO_ATTRID 0x11 +#define SM_SWITCHINFO_ATTRID 0x12 +#define SM_GUIDINFO_ATTRID 0x14 +#define SM_PORTINFO_ATTRID 0x15 +#define SM_PKEY_TABLE_ATTRID 0x16 +#define SM_SLTOVLTABLE_ATTRID 0x17 +#define SM_VLARBITRATION_ATTRID 0x18 +#define SM_LINEARFDB_ATTRID 0x19 +#define SM_RANDOMFDB_ATTRID 0x1A +#define SM_MCASTFDB_ATTRID 0x1B +#define SM_SMINFO_ATTRID 0x20 +#define SM_VENDORDIAG_ATTRID 0x30 +#define SM_LEDINFO_ATTRID 0x31 + +/* VendorDiag: Table 146 */ +typedef struct sm_vendor_diag_s { + uint16_t NextIndex; /* next attr mod to get diag info */ + uint8_t DiagData[62]; /* vendor specific diag info */ +} sm_vendor_diag_t; + +/* LedInfo: Table 147 */ +#if defined(_BIT_FIELDS_HTOL) +typedef struct sm_ledinfo_s { + uint32_t LedMask :1; /* 1 for LED on, 0 for off */ + uint32_t Reserved :31; +} sm_ledinfo_t; + +#elif defined(_BIT_FIELDS_LTOH) + +typedef struct sm_ledinfo_s { + uint32_t Reserved :31; + uint32_t LedMask :1; /* 1 for LED on, 0 for off */ +} sm_ledinfo_t; + +#else +#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined +#endif /* _BIT_FIELDS_HTOL */ + +/* LED Info Defines */ +#define SM_LEDINFO_ON 0x1 +#define SM_LEDINFO_OFF 0x0 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IB_MGT_SM_ATTR_H */ diff --git a/illumos-x86_64/usr/include/sys/ibpart.h b/illumos-x86_64/usr/include/sys/ibpart.h new file mode 100644 index 00000000..9f526670 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ibpart.h @@ -0,0 +1,102 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_IBPART_H +#define _SYS_IBPART_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define IBD_CREATE_IBPART IBPARTIOC(1) +#define IBD_DELETE_IBPART IBPARTIOC(2) +#define IBD_INFO_IBPART IBPARTIOC(3) + +#define IBD_INFO_CMD_IBPART 1 +#define IBD_INFO_CMD_IBPORT 2 +#define IBD_INFO_CMD_PKEYTBLSZ 3 + +typedef enum ibd_part_err_e { + IBD_INVALID_PORT_INST = 1, + IBD_PORT_IS_DOWN, + IBD_PKEY_NOT_PRESENT, + IBD_INVALID_PKEY, + IBD_PARTITION_EXISTS, + IBD_NO_HW_RESOURCE, + IBD_INVALID_PKEY_TBL_SIZE +} ibd_part_err_t; +/* + * NOTE: If you change this structure make sure that alignments are correct + * for the proper operation of the ioctl in both the 32 and 64 bit modes. + */ +typedef struct ibd_ioctl_s { + int ioc_info_cmd; + datalink_id_t ioc_linkid; + int ioc_port_inst; + uint_t ioc_portnum; + ib_guid_t ioc_hcaguid; + ib_guid_t ioc_portguid; + int ioc_status; + uint32_t align1; +} ibd_ioctl_t; + +/* + * NOTE: If you change this structure make sure that alignments are correct + * for the proper operation of the ioctl in both the 32 and 64 bit modes. + */ +typedef struct ibpart_ioctl_s { + ibd_ioctl_t ibdioc; + datalink_id_t ioc_partid; + boolean_t ioc_force_create; + ib_pkey_t ioc_pkey; + uint16_t align1; + uint32_t align2; +} ibpart_ioctl_t; + +typedef struct ibpart_ioctl_s ibd_create_ioctl_t; +typedef struct ibpart_ioctl_s ibd_delete_ioctl_t; + +typedef struct ibport_ioctl_s { + ibd_ioctl_t ibdioc; + uint_t ioc_pkey_tbl_sz; + ib_pkey_t *ioc_pkeys; +} ibport_ioctl_t; + +#ifdef _SYSCALL32 +typedef struct ibport_ioctl32_s { + ibd_ioctl_t ibdioc; + uint_t ioc_pkey_tbl_sz; + caddr32_t ioc_pkeys; +} ibport_ioctl32_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IBPART_H */ diff --git a/illumos-x86_64/usr/include/sys/id32.h b/illumos-x86_64/usr/include/sys/id32.h new file mode 100644 index 00000000..f6923bdc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/id32.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_ID32_H +#define _SYS_ID32_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +extern void id32_init(void); +extern uint32_t id32_alloc(void *, int); +extern void id32_free(uint32_t); +extern void *id32_lookup(uint32_t); + +#endif /* KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ID32_H */ diff --git a/illumos-x86_64/usr/include/sys/id_space.h b/illumos-x86_64/usr/include/sys/id_space.h new file mode 100644 index 00000000..46d25f20 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/id_space.h @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Joyent, Inc. All Rights reserved. + */ + +#ifndef _ID_SPACE_H +#define _ID_SPACE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +typedef vmem_t id_space_t; + +id_space_t *id_space_create(const char *, id_t, id_t); +void id_space_destroy(id_space_t *); +void id_space_extend(id_space_t *, id_t, id_t); +id_t id_alloc(id_space_t *); +id_t id_alloc_nosleep(id_space_t *); +id_t id_allocff(id_space_t *); +id_t id_allocff_nosleep(id_space_t *); +id_t id_alloc_specific_nosleep(id_space_t *, id_t); +void id_free(id_space_t *, id_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _ID_SPACE_H */ diff --git a/illumos-x86_64/usr/include/sys/idmap.h b/illumos-x86_64/usr/include/sys/idmap.h new file mode 100644 index 00000000..39eeb905 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/idmap.h @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IDMAP_H +#define _SYS_IDMAP_H + + +/* Idmap status codes */ +#define IDMAP_SUCCESS 0 +#define IDMAP_NEXT 1 +#define IDMAP_ERR_OTHER -10000 +#define IDMAP_ERR_INTERNAL -9999 +#define IDMAP_ERR_MEMORY -9998 +#define IDMAP_ERR_NORESULT -9997 +#define IDMAP_ERR_NOTUSER -9996 +#define IDMAP_ERR_NOTGROUP -9995 +#define IDMAP_ERR_NOTSUPPORTED -9994 +#define IDMAP_ERR_W2U_NAMERULE -9993 +#define IDMAP_ERR_U2W_NAMERULE -9992 +#define IDMAP_ERR_CACHE -9991 +#define IDMAP_ERR_DB -9990 +#define IDMAP_ERR_ARG -9989 +#define IDMAP_ERR_SID -9988 +#define IDMAP_ERR_IDTYPE -9987 +#define IDMAP_ERR_RPC_HANDLE -9986 +#define IDMAP_ERR_RPC -9985 +#define IDMAP_ERR_CLIENT_HANDLE -9984 +#define IDMAP_ERR_BUSY -9983 +#define IDMAP_ERR_PERMISSION_DENIED -9982 +#define IDMAP_ERR_NOMAPPING -9981 +#define IDMAP_ERR_NEW_ID_ALLOC_REQD -9980 +#define IDMAP_ERR_DOMAIN -9979 +#define IDMAP_ERR_SECURITY -9978 +#define IDMAP_ERR_NOTFOUND -9977 +#define IDMAP_ERR_DOMAIN_NOTFOUND -9976 +#define IDMAP_ERR_UPDATE_NOTALLOWED -9975 +#define IDMAP_ERR_CFG -9974 +#define IDMAP_ERR_CFG_CHANGE -9973 +#define IDMAP_ERR_NOTMAPPED_WELLKNOWN -9972 +#define IDMAP_ERR_RETRIABLE_NET_ERR -9971 +#define IDMAP_ERR_W2U_NAMERULE_CONFLICT -9970 +#define IDMAP_ERR_U2W_NAMERULE_CONFLICT -9969 +#define IDMAP_ERR_BAD_UTF8 -9968 +#define IDMAP_ERR_NONE_GENERATED -9967 +#define IDMAP_ERR_PROP_UNKNOWN -9966 +#define IDMAP_ERR_NS_LDAP_OP_FAILED -9965 +#define IDMAP_ERR_NS_LDAP_PARTIAL -9964 +#define IDMAP_ERR_NS_LDAP_CFG -9963 +#define IDMAP_ERR_NS_LDAP_BAD_WINNAME -9962 +#define IDMAP_ERR_NO_ACTIVEDIRECTORY -9961 + +/* Reserved GIDs for some well-known SIDs */ +#define IDMAP_WK_LOCAL_SYSTEM_GID 2147483648U /* 0x80000000 */ +#define IDMAP_WK_CREATOR_GROUP_GID 2147483649U +#define IDMAP_WK__MAX_GID 2147483649U + +/* Reserved UIDs for some well-known SIDs */ +#define IDMAP_WK_CREATOR_OWNER_UID 2147483648U +#define IDMAP_WK__MAX_UID 2147483648U + +/* Reserved SIDs */ +#define IDMAP_WK_CREATOR_SID_AUTHORITY "S-1-3" + +/* + * Max door RPC size for ID mapping (can't be too large relative to the + * default user-land thread stack size, since clnt_door_call() + * alloca()s). See libidmap:idmap_init(). + */ +#define IDMAP_MAX_DOOR_RPC (256 * 1024) + +#define IDMAP_SENTINEL_PID UINT32_MAX +#define IDMAP_ID_IS_EPHEMERAL(pid) \ + (((pid) > INT32_MAX) && ((pid) != IDMAP_SENTINEL_PID)) + +#endif /* _SYS_IDMAP_H */ diff --git a/illumos-x86_64/usr/include/sys/ieeefp.h b/illumos-x86_64/usr/include/sys/ieeefp.h new file mode 100644 index 00000000..2ee4ec4d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ieeefp.h @@ -0,0 +1,121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IEEEFP_H +#define _SYS_IEEEFP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Sun types for IEEE floating point. + */ + +#if defined(__sparc) + +enum fp_direction_type { /* rounding direction */ + fp_nearest = 0, + fp_tozero = 1, + fp_positive = 2, + fp_negative = 3 +}; + +enum fp_precision_type { /* extended rounding precision */ + fp_extended = 0, + fp_single = 1, + fp_double = 2, + fp_precision_3 = 3 +}; + +enum fp_exception_type { /* exceptions according to bit number */ + fp_inexact = 0, + fp_division = 1, + fp_underflow = 2, + fp_overflow = 3, + fp_invalid = 4 +}; +#define N_IEEE_EXCEPTION 5 /* Number of floating-point exceptions. */ + +enum fp_trap_enable_type { /* trap enable bits according to bit number */ + fp_trap_inexact = 0, + fp_trap_division = 1, + fp_trap_underflow = 2, + fp_trap_overflow = 3, + fp_trap_invalid = 4 +}; + +#elif defined(__i386) || defined(__amd64) + +enum fp_direction_type { /* rounding direction */ + fp_nearest = 0, + fp_negative = 1, + fp_positive = 2, + fp_tozero = 3 +}; + +enum fp_precision_type { /* extended rounding precision */ + fp_single = 0, + fp_precision_3 = 1, + fp_double = 2, + fp_extended = 3 +}; + +enum fp_exception_type { /* exceptions according to bit number */ + fp_invalid = 0, + fp_denormalized = 1, + fp_division = 2, + fp_overflow = 3, + fp_underflow = 4, + fp_inexact = 5 +}; +#define N_IEEE_EXCEPTION 6 /* Number of floating-point exceptions. */ + +enum fp_trap_enable_type { /* trap enable bits according to bit number */ + fp_trap_invalid = 0, + fp_trap_denormalized = 1, + fp_trap_division = 2, + fp_trap_overflow = 3, + fp_trap_underflow = 4, + fp_trap_inexact = 5 +}; + +#endif /* __i386 || __amd64 */ + +enum fp_class_type { /* floating-point classes */ + fp_zero = 0, + fp_subnormal = 1, + fp_normal = 2, + fp_infinity = 3, + fp_quiet = 4, + fp_signaling = 5 +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IEEEFP_H */ diff --git a/illumos-x86_64/usr/include/sys/inline.h b/illumos-x86_64/usr/include/sys/inline.h new file mode 100644 index 00000000..83a5fdee --- /dev/null +++ b/illumos-x86_64/usr/include/sys/inline.h @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_INLINE_H +#define _SYS_INLINE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(CXREF) && !defined(__lint) + +/* asm inline replacement templates go here */ + +#else + +/* extern function declarations go here */ + +#endif /* !defined(CXREF) && !defined(__lint) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_INLINE_H */ diff --git a/illumos-x86_64/usr/include/sys/inotify.h b/illumos-x86_64/usr/include/sys/inotify.h new file mode 100644 index 00000000..8acc1a72 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/inotify.h @@ -0,0 +1,153 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2014 Joyent, Inc. All rights reserved. + */ + +/* + * Header file to support for the inotify facility. Note that this facility + * is designed to be binary compatible with the Linux inotify facility; values + * for constants here should therefore exactly match those found in Linux, and + * this facility shouldn't be extended independently of Linux. + */ + +#ifndef _SYS_INOTIFY_H +#define _SYS_INOTIFY_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Events that can be explicitly requested on any inotify watch. + */ +#define IN_ACCESS 0x00000001 +#define IN_MODIFY 0x00000002 +#define IN_ATTRIB 0x00000004 +#define IN_CLOSE_WRITE 0x00000008 +#define IN_CLOSE_NOWRITE 0x00000010 +#define IN_OPEN 0x00000020 +#define IN_MOVED_FROM 0x00000040 +#define IN_MOVED_TO 0x00000080 +#define IN_CREATE 0x00000100 +#define IN_DELETE 0x00000200 +#define IN_DELETE_SELF 0x00000400 +#define IN_MOVE_SELF 0x00000800 + +/* + * Events that can be sent to an inotify watch -- requested or not. + */ +#define IN_UNMOUNT 0x00002000 +#define IN_Q_OVERFLOW 0x00004000 +#define IN_IGNORED 0x00008000 + +/* + * Flags that can modify an inotify event. + */ +#define IN_ONLYDIR 0x01000000 +#define IN_DONT_FOLLOW 0x02000000 +#define IN_EXCL_UNLINK 0x04000000 +#define IN_MASK_ADD 0x20000000 +#define IN_ISDIR 0x40000000 +#define IN_ONESHOT 0x80000000 + +/* + * Helpful constants. + */ +#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) +#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) +#define IN_ALL_EVENTS \ + (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ + IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | \ + IN_DELETE | IN_CREATE | IN_DELETE_SELF | IN_MOVE_SELF) + +#define IN_CHILD_EVENTS \ + (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ + IN_CLOSE_NOWRITE | IN_MODIFY | IN_OPEN) + +/* + * To assure binary compatibility with Linux, these values are fixed at their + * Linux equivalents, not their native ones. + */ +#define IN_CLOEXEC 02000000 /* LX_O_CLOEXEC */ +#define IN_NONBLOCK 04000 /* LX_O_NONBLOCK */ + +struct inotify_event { + int32_t wd; /* watch descriptor */ + uint32_t mask; /* mask of events */ + uint32_t cookie; /* event association cookie, if any */ + uint32_t len; /* size of name field */ + char name[]; /* optional NUL-terminated name */ +}; + +/* + * These ioctl values are specific to the native implementation; applications + * shouldn't be using them directly, and they should therefore be safe to + * change without breaking apps. + */ +#define INOTIFYIOC (('i' << 24) | ('n' << 16) | ('y' << 8)) +#define INOTIFYIOC_ADD_WATCH (INOTIFYIOC | 1) /* add watch */ +#define INOTIFYIOC_RM_WATCH (INOTIFYIOC | 2) /* remove watch */ +#define INOTIFYIOC_ADD_CHILD (INOTIFYIOC | 3) /* add child watch */ +#define INOTIFYIOC_ACTIVATE (INOTIFYIOC | 4) /* activate watch */ + +#ifndef _LP64 +#ifndef _LITTLE_ENDIAN +#define INOTIFY_PTR(type, name) uint32_t name##pad; type *name +#else +#define INOTIFY_PTR(type, name) type *name; uint32_t name##pad +#endif +#else +#define INOTIFY_PTR(type, name) type *name +#endif + +typedef struct inotify_addwatch { + int inaw_fd; /* open fd for object */ + uint32_t inaw_mask; /* desired mask */ +} inotify_addwatch_t; + +typedef struct inotify_addchild { + INOTIFY_PTR(char, inac_name); /* pointer to name */ + int inac_fd; /* open fd for parent */ +} inotify_addchild_t; + +#ifndef _KERNEL + +extern int inotify_init(void); +extern int inotify_init1(int); +extern int inotify_add_watch(int, const char *, uint32_t); +extern int inotify_rm_watch(int, int); + +#else + +#define IN_UNMASKABLE \ + (IN_UNMOUNT | IN_Q_OVERFLOW | IN_IGNORED | IN_ISDIR) + +#define IN_MODIFIERS \ + (IN_EXCL_UNLINK | IN_ONESHOT) + +#define IN_FLAGS \ + (IN_ONLYDIR | IN_DONT_FOLLOW | IN_MASK_ADD) + +#define IN_REMOVAL (1ULL << 32) +#define INOTIFYMNRN_INOTIFY 0 +#define INOTIFYMNRN_CLONE 1 + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_INOTIFY_H */ diff --git a/illumos-x86_64/usr/include/sys/instance.h b/illumos-x86_64/usr/include/sys/instance.h new file mode 100644 index 00000000..01a40401 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/instance.h @@ -0,0 +1,149 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_INSTANCE_H +#define _SYS_INSTANCE_H + +/* + * Instance number assignment data structures + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define INSTANCE_FILE "/etc/path_to_inst" +#define INSTANCE_FILE_SUFFIX ".old" + + +#if defined(_KERNEL) || defined(_KMEMUSER) + +/* + * The form of a node; These form a tree that is parallel to the + * dev_info tree, but always fully populated. The tree is rooted in + * the in_softstate struct (e_ddi_inst_state.ins_root). + * + * Each node has one or more in_drv entries hanging from it. + * (It will have more than one if it has been driven by more than one driver + * over its lifetime. This can happen due to a generic name + * or to a "compatible" name giving a more specific driver). + */ + +typedef struct in_node { + char *in_node_name; /* devi_node_name of this node */ + char *in_unit_addr; /* address part of name */ + struct in_node *in_child; /* children of this node */ + struct in_node *in_sibling; /* "peers" of this node */ + struct in_drv *in_drivers; /* drivers bound to this node */ + struct in_node *in_parent; /* parent of this node */ + dev_info_t *in_devi; /* corresponding devinfo */ +} in_node_t; + +typedef struct in_drv { + char *ind_driver_name; /* canonical name of driver */ + int ind_instance; /* current instance number */ + int ind_state; /* see below */ + /* + * The following field is used to link instance numbers for the + * same driver off of devnamesp or in_no_major or in_no_instance + */ + struct in_drv *ind_next; /* next for this driver */ + struct in_drv *ind_next_drv; /* next driver this node */ + struct in_node *ind_node; /* node that these hang on */ +} in_drv_t; + +/* + * Values for in_state + */ +#define IN_PROVISIONAL 0x1 /* provisional instance number assigned */ +#define IN_PERMANENT 0x2 /* instance number has been confirmed */ +#define IN_UNKNOWN 0x3 /* instance number not yet assigned */ +#define IN_BORROWED 0x4 /* instance number from alias */ + + +/* + * Guard for path to instance file + */ +#define PTI_GUARD "#\n#\tCaution! This file contains critical kernel state\n#\n" + + +/* + * special value for dn_instance + */ +#define IN_SEARCHME (-1) + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +#ifdef _KERNEL +void e_ddi_instance_init(void); +uint_t e_ddi_assign_instance(dev_info_t *dip); +void e_ddi_keep_instance(dev_info_t *dip); +void e_ddi_free_instance(dev_info_t *dip, char *addr); +int e_ddi_instance_majorinstance_to_path(major_t major, + uint_t instance, char *path); +void e_ddi_unorphan_instance_nos(void); +void e_ddi_enter_instance(void); +void e_ddi_exit_instance(void); +in_node_t *e_ddi_instance_root(void); +int e_ddi_instance_is_clean(void); +void e_ddi_instance_set_clean(void); + +/* Platform instance override functions */ +uint_t impl_assign_instance(dev_info_t *dip); +int impl_keep_instance(dev_info_t *dip); +int impl_free_instance(dev_info_t *dip); + +/* walk the instance tree */ +int e_ddi_walk_instances(int (*)(const char *, + in_node_t *, in_drv_t *, void *), void *); + +/* for DDI-MP */ +in_node_t *e_ddi_path_to_instance(char *path); +void e_ddi_borrow_instance(dev_info_t *cdip, in_node_t *cnp); +void e_ddi_return_instance(dev_info_t *cdip, char *addr, in_node_t *cnp); + +/* return values from e_ddi_walk_instances callback */ +#define INST_WALK_CONTINUE 0 +#define INST_WALK_TERMINATE 1 + + +#else /* _KERNEL */ +extern int inst_sync(char *pathname, int flags); +#endif /* _KERNEL */ + +#define INST_SYNC_IF_REQUIRED 0 +#define INST_SYNC_ALWAYS 1 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_INSTANCE_H */ diff --git a/illumos-x86_64/usr/include/sys/int_const.h b/illumos-x86_64/usr/include/sys/int_const.h new file mode 100644 index 00000000..a32da14b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/int_const.h @@ -0,0 +1,128 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_INT_CONST_H +#define _SYS_INT_CONST_H + +/* + * This file, , is part of the Sun Microsystems implementation + * of as proposed in the ISO/JTC1/SC22/WG14 C committee's working + * draft for the revision of the current ISO C standard, ISO/IEC 9899:1990 + * Programming language - C. + * + * Programs/Modules should not directly include this file. Access to the + * types defined in this file should be through the inclusion of one of the + * following files: + * + * Provides the Kernel and Driver appropriate + * components of . + * + * For use by applications. + * + * See these files for more details. + * + * Use at your own risk. This file will track the evolution of the revision + * of the current ISO C standard. As of February 1996, the committee is + * squarely behind the fixed sized types. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Constants + * + * The following macros create constants of the types defined in + * . The intent is that: + * Constants defined using these macros have a specific size and + * signedness. The suffix used for int64_t and uint64_t (ll and ull) + * are for examples only. Implementations are permitted to use other + * suffixes. + * + * The "CSTYLED" comments are flags to an internal code style analysis tool + * telling it to silently accept the line which follows. This internal + * standard requires a space between arguments, but the historical, + * non-ANSI-C ``method'' of concatenation can't tolerate those spaces. + */ +/* CSTYLED */ +#define __CONCAT__(A,B) A ## B + +#define INT8_C(c) (c) +#define INT16_C(c) (c) +#define INT32_C(c) (c) +#ifdef _LP64 +/* CSTYLED */ +#define INT64_C(c) __CONCAT__(c,l) +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +/* CSTYLED */ +#define INT64_C(c) __CONCAT__(c,ll) +#endif +#endif + +/* CSTYLED */ +#define UINT8_C(c) __CONCAT__(c,u) +/* CSTYLED */ +#define UINT16_C(c) __CONCAT__(c,u) +/* CSTYLED */ +#define UINT32_C(c) __CONCAT__(c,u) +#ifdef _LP64 +/* CSTYLED */ +#define UINT64_C(c) __CONCAT__(c,ul) +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +/* CSTYLED */ +#define UINT64_C(c) __CONCAT__(c,ull) +#endif +#endif + +#ifdef _LP64 +/* CSTYLED */ +#define INTMAX_C(c) __CONCAT__(c,l) +/* CSTYLED */ +#define UINTMAX_C(c) __CONCAT__(c,ul) +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +/* CSTYLED */ +#define INTMAX_C(c) __CONCAT__(c,ll) +/* CSTYLED */ +#define UINTMAX_C(c) __CONCAT__(c,ull) +#else +#define INTMAX_C(c) (c) +#define UINTMAX_C(c) (c) +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_INT_CONST_H */ diff --git a/illumos-x86_64/usr/include/sys/int_fmtio.h b/illumos-x86_64/usr/include/sys/int_fmtio.h new file mode 100644 index 00000000..26052aaa --- /dev/null +++ b/illumos-x86_64/usr/include/sys/int_fmtio.h @@ -0,0 +1,437 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_INT_FMTIO_H +#define _SYS_INT_FMTIO_H + +/* + * This file, , is part of the Sun Microsystems implementation + * of as defined by the ISO C Standard, ISO/IEC 9899:1999 + * Programming language - C. + * + * ISO International Organization for Standardization. + * + * Programs/Modules should not directly include this file. Access to the + * types defined in this file should be through the inclusion of one of the + * following files: + * + * Provides the Kernel and Driver appropriate + * components of . + * + * For use by applications. + * + * See these files for more details. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Formatted I/O + * + * The following macros can be used even when an implementation has not + * extended the printf/scanf family of functions. + * + * The form of the names of the macros is either "PRI" for printf specifiers + * or "SCN" for scanf specifiers, followed by the conversion specifier letter + * followed by the datatype size. For example, PRId32 is the macro for + * the printf d conversion specifier with the flags for 32 bit datatype. + * + * An example using one of these macros: + * + * uint64_t u; + * printf("u = %016" PRIx64 "\n", u); + * + * For the purpose of example, the definitions of the printf/scanf macros + * below have the values appropriate for a machine with 8 bit shorts, 16 + * bit shorts, 32 bit ints, 32 or 64 bit longs depending on compilation + * mode, and 64 bit long longs. + */ + +/* + * fprintf macros for signed integers + */ +#if defined(_KERNEL) +#define _MODF8 "" +#define _MODF16 "" +#else +#define _MODF8 "hh" +#define _MODF16 "h" +#endif + +#define _PRId "d" +#define _PRIi "i" +#define _PRIo "o" +#define _PRIu "u" +#define _PRIx "x" +#define _PRIX "X" + +#define PRId8 _MODF8 _PRId +#define PRIdLEAST8 PRId8 +#define PRIdFAST8 PRId8 +#define PRId16 _MODF16 _PRId +#define PRIdLEAST16 PRId16 +#define PRId32 "d" +#define PRIdFAST16 PRId32 +#define PRIdLEAST32 PRId32 +#define PRIdFAST32 PRId32 +#ifdef _LP64 +#define PRId64 "ld" +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +#define PRId64 "lld" +#endif +#endif +#ifdef PRId64 +#define PRIdLEAST64 PRId64 +#define PRIdFAST64 PRId64 +#endif + +#define PRIi8 _MODF8 _PRIi +#define PRIiLEAST8 PRIi8 +#define PRIiFAST8 PRIi8 +#define PRIi16 _MODF16 _PRIi +#define PRIiLEAST16 PRIi16 +#define PRIi32 "i" +#define PRIiFAST16 PRIi32 +#define PRIiLEAST32 PRIi32 +#define PRIiFAST32 PRIi32 +#ifdef _LP64 +#define PRIi64 "li" +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +#define PRIi64 "lli" +#endif +#endif +#ifdef PRIi64 +#define PRIiLEAST64 PRIi64 +#define PRIiFAST64 PRIi64 +#endif + +/* + * fprintf macros for unsigned integers + */ + +#define PRIo8 _MODF8 _PRIo +#define PRIoLEAST8 PRIo8 +#define PRIoFAST8 PRIo8 +#define PRIo16 _MODF16 _PRIo +#define PRIoLEAST16 PRIo16 +#define PRIo32 "o" +#define PRIoFAST16 PRIo32 +#define PRIoLEAST32 PRIo32 +#define PRIoFAST32 PRIo32 +#ifdef _LP64 +#define PRIo64 "lo" +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +#define PRIo64 "llo" +#endif +#endif +#ifdef PRIo64 +#define PRIoLEAST64 PRIo64 +#define PRIoFAST64 PRIo64 +#endif + +#define PRIu8 _MODF8 _PRIu +#define PRIuLEAST8 PRIu8 +#define PRIuFAST8 PRIu8 +#define PRIu16 _MODF16 _PRIu +#define PRIuLEAST16 PRIu16 +#define PRIu32 "u" +#define PRIuFAST16 PRIu32 +#define PRIuLEAST32 PRIu32 +#define PRIuFAST32 PRIu32 +#ifdef _LP64 +#define PRIu64 "lu" +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +#define PRIu64 "llu" +#endif +#endif +#ifdef PRIu64 +#define PRIuLEAST64 PRIu64 +#define PRIuFAST64 PRIu64 +#endif + +#define PRIx8 _MODF8 _PRIx +#define PRIxLEAST8 PRIx8 +#define PRIxFAST8 PRIx8 +#define PRIx16 _MODF16 _PRIx +#define PRIxLEAST16 PRIx16 +#define PRIx32 "x" +#define PRIxFAST16 PRIx32 +#define PRIxLEAST32 PRIx32 +#define PRIxFAST32 PRIx32 +#ifdef _LP64 +#define PRIx64 "lx" +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +#define PRIx64 "llx" +#endif +#endif +#ifdef PRIx64 +#define PRIxLEAST64 PRIx64 +#define PRIxFAST64 PRIx64 +#endif + +#define PRIX8 _MODF8 _PRIX +#define PRIXLEAST8 PRIX8 +#define PRIXFAST8 PRIX8 +#define PRIX16 _MODF16 _PRIX +#define PRIXLEAST16 PRIX16 +#define PRIX32 "X" +#define PRIXFAST16 PRIX32 +#define PRIXLEAST32 PRIX32 +#define PRIXFAST32 PRIX32 +#ifdef _LP64 +#define PRIX64 "lX" +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +#define PRIX64 "llX" +#endif +#endif +#ifdef PRIX64 +#define PRIXLEAST64 PRIX64 +#define PRIXFAST64 PRIX64 +#endif + +/* + * fprintf macros for pointers + */ + +#if defined(_LP64) +#define PRIdPTR "ld" +#define PRIiPTR "li" +#define PRIoPTR "lo" +#define PRIuPTR "lu" +#define PRIxPTR "lx" +#define PRIXPTR "lX" +#else +#define PRIdPTR "d" +#define PRIiPTR "i" +#define PRIoPTR "o" +#define PRIuPTR "u" +#define PRIxPTR "x" +#define PRIXPTR "X" +#endif /* defined(_LP64) */ + +/* + * fscanf macros for signed integers + */ +#define SCNd8 "hhd" +#define SCNdLEAST8 SCNd8 +#define SCNdFAST8 SCNd8 +#define SCNd16 "hd" +#define SCNdLEAST16 SCNd16 +#define SCNd32 "d" +#define SCNdFAST16 SCNd32 +#define SCNdLEAST32 SCNd32 +#define SCNdFAST32 SCNd32 +#ifdef PRId64 +#define SCNd64 PRId64 +#define SCNdLEAST64 PRId64 +#define SCNdFAST64 PRId64 +#endif +#define SCNdPTR PRIdPTR + +#define SCNi8 "hhi" +#define SCNiLEAST8 SCNi8 +#define SCNiFAST8 SCNi8 +#define SCNi16 "hi" +#define SCNiLEAST16 SCNi16 +#define SCNi32 "i" +#define SCNiFAST16 SCNi32 +#define SCNiLEAST32 SCNi32 +#define SCNiFAST32 SCNi32 +#ifdef PRIi64 +#define SCNi64 PRIi64 +#define SCNiLEAST64 PRIi64 +#define SCNiFAST64 PRIi64 +#endif +#define SCNiPTR PRIiPTR + +/* + * fscanf macros for unsigned integers + */ +#define SCNo8 "hho" +#define SCNoLEAST8 SCNo8 +#define SCNoFAST8 SCNo8 +#define SCNo16 "ho" +#define SCNoLEAST16 SCNo16 +#define SCNo32 "o" +#define SCNoFAST16 SCNo32 +#define SCNoLEAST32 SCNo32 +#define SCNoFAST32 SCNo32 +#ifdef PRIo64 +#define SCNo64 PRIo64 +#define SCNoLEAST64 PRIo64 +#define SCNoFAST64 PRIo64 +#endif +#define SCNoPTR PRIoPTR + +#define SCNu8 "hhu" +#define SCNuLEAST8 SCNu8 +#define SCNuFAST8 SCNu8 +#define SCNu16 "hu" +#define SCNuLEAST16 SCNu16 +#define SCNu32 "u" +#define SCNuFAST16 SCNu32 +#define SCNuLEAST32 SCNu32 +#define SCNuFAST32 SCNu32 +#ifdef PRIu64 +#define SCNu64 PRIu64 +#define SCNuLEAST64 PRIu64 +#define SCNuFAST64 PRIu64 +#endif +#define SCNuPTR PRIuPTR + +#define SCNx8 "hhx" +#define SCNxLEAST8 SCNx8 +#define SCNxFAST8 SCNx8 +#define SCNx16 "hx" +#define SCNxLEAST16 SCNx16 +#define SCNx32 "x" +#define SCNxFAST16 SCNx32 +#define SCNxLEAST32 SCNx32 +#define SCNxFAST32 SCNx32 +#ifdef PRIx64 +#define SCNx64 PRIx64 +#define SCNxLEAST64 PRIx64 +#define SCNxFAST64 PRIx64 +#endif +#define SCNxPTR PRIxPTR + +#define SCNX8 "hhX" +#define SCNXLEAST8 SCNX8 +#define SCNXFAST8 SCNX8 +#define SCNX16 "hX" +#define SCNXLEAST16 SCNX16 +#define SCNX32 "X" +#define SCNXFAST16 SCNX32 +#define SCNXLEAST32 SCNX32 +#define SCNXFAST32 SCNX32 +#ifdef PRIX64 +#define SCNX64 PRIX64 +#define SCNXLEAST64 PRIX64 +#define SCNXFAST64 PRIX64 +#endif +#define SCNXPTR PRIXPTR + +/* + * The following macros define I/O formats for intmax_t and uintmax_t. + */ +#if !defined(_LP64) && defined(_LONGLONG_TYPE) +#define PRIdMAX "lld" +#define PRIiMAX "lli" +#define PRIoMAX "llo" +#define PRIxMAX "llx" +#define PRIuMAX "llu" +#define PRIXMAX "llX" +#else +#define PRIdMAX "ld" +#define PRIiMAX "li" +#define PRIoMAX "lo" +#define PRIxMAX "lx" +#define PRIuMAX "lu" +#define PRIXMAX "lX" +#endif /* !defined(_LP64) && defined(_LONGLONG_TYPE) */ + +#define SCNdMAX PRIdMAX +#define SCNiMAX PRIiMAX +#define SCNoMAX PRIoMAX +#define SCNxMAX PRIxMAX +#define SCNuMAX PRIuMAX +#define SCNXMAX PRIXMAX + +/* + * Non-standard formatters and scanners, which are protected namespace-wise + * lest they become standard. There are few good reasons to add to these, + * luckily. + * + * We define the full suite of formats per type, even in cases where that's + * not exactly useful. + */ +#if !defined(_STRICT_SYMBOLS) + +/* + * The following macros define I/O formats for id_t, which is always 32bit but + * for historical reasons a real pain to format. + */ +#if !defined(_LP64) +#define _PRIdID "ld" +#define _PRIiID "li" +#define _PRIoID "lo" +#define _PRIxID "lx" +#define _PRIuID "lu" +#define _PRIXID "lX" +#else +#define _PRIdID "d" +#define _PRIiID "i" +#define _PRIoID "o" +#define _PRIxID "x" +#define _PRIuID "u" +#define _PRIXID "X" +#endif + +#define _SCNdID _PRIdID +#define _SCNiID _PRIiID +#define _SCNoID _PRIoID +#define _SCNxID _PRIxID +#define _SCNuID _PRIuID +#define _SCNXID _PRIXID + +/* + * The following are set up for the wint_t and wchar_t which have the same + * general problem. They have the same types as above, but we use unique macros + * to help readers. + */ +#define _PRIdWC _PRIdID +#define _PRIiWC _PRIiID +#define _PRIoWC _PRIoID +#define _PRIxWC _PRIxID +#define _PRIuWC _PRIuID +#define _PRIXWC _PRIXID +#define _SCNdWC _PRIdID +#define _SCNiWC _PRIiID +#define _SCNoWC _PRIoID +#define _SCNxWC _PRIxID +#define _SCNuWC _PRIuID +#define _SCNXWC _PRIXID + + +#endif /* _STRICT_SYMBOLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_INT_FMTIO_H */ diff --git a/illumos-x86_64/usr/include/sys/int_limits.h b/illumos-x86_64/usr/include/sys/int_limits.h new file mode 100644 index 00000000..1749b700 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/int_limits.h @@ -0,0 +1,269 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_INT_LIMITS_H +#define _SYS_INT_LIMITS_H + +/* + * This file, , is part of the Sun Microsystems implementation + * of as defined in the ISO C standard, ISO/IEC 9899:1999 + * Programming language - C. + * + * Programs/Modules should not directly include this file. Access to the + * types defined in this file should be through the inclusion of one of the + * following files: + * + * This nested inclusion is disabled for strictly + * ANSI-C conforming compilations. The *_MIN + * definitions are not visible to POSIX or XPG + * conforming applications (due to what may be + * a bug in the specification - this is under + * investigation) + * + * Provides the Kernel and Driver appropriate + * components of . + * + * For use by applications. + * + * See these files for more details. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Limits + * + * The following define the limits for the types defined in . + * + * INTMAX_MIN (minimum value of the largest supported signed integer type), + * INTMAX_MAX (maximum value of the largest supported signed integer type), + * and UINTMAX_MAX (maximum value of the largest supported unsigned integer + * type) can be set to implementation defined limits. + * + * NOTE : A programmer can test to see whether an implementation supports + * a particular size of integer by testing if the macro that gives the + * maximum for that datatype is defined. For example, if #ifdef UINT64_MAX + * tests false, the implementation does not support unsigned 64 bit integers. + * + * The type of these macros is intentionally unspecified. + * + * The types int8_t, int_least8_t, and int_fast8_t are not defined for ISAs + * where the ABI specifies "char" as unsigned when the translation mode is + * not ANSI-C. + */ +#define INT8_MAX (127) +#define INT16_MAX (32767) +#define INT32_MAX (2147483647) +#if defined(_LP64) +#define INT64_MAX (9223372036854775807L) +#elif defined(_LONGLONG_TYPE) +#define INT64_MAX (9223372036854775807LL) +#endif + +#define UINT8_MAX (255U) +#define UINT16_MAX (65535U) +#define UINT32_MAX (4294967295U) +#if defined(_LP64) +#define UINT64_MAX (18446744073709551615UL) +#elif defined(_LONGLONG_TYPE) +#define UINT64_MAX (18446744073709551615ULL) +#endif + +#ifdef INT64_MAX +#define INTMAX_MAX INT64_MAX +#else +#define INTMAX_MAX INT32_MAX +#endif + +#ifdef UINT64_MAX +#define UINTMAX_MAX UINT64_MAX +#else +#define UINTMAX_MAX UINT32_MAX +#endif + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#ifdef INT64_MAX +#define INT_LEAST64_MAX INT64_MAX +#endif + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#ifdef UINT64_MAX +#define UINT_LEAST64_MAX UINT64_MAX +#endif + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MAX INT32_MAX +#ifdef INT64_MAX +#define INT_FAST64_MAX INT64_MAX +#endif + +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#ifdef UINT64_MAX +#define UINT_FAST64_MAX UINT64_MAX +#endif + +/* + * The following 2 macros are provided for testing whether the types + * intptr_t and uintptr_t (integers large enough to hold a void *) are + * defined in this header. They are needed in case the architecture can't + * represent a pointer in any standard integral type. + */ +#if defined(_LP64) +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX +#else +#define INTPTR_MAX INT32_MAX +#define UINTPTR_MAX UINT32_MAX +#endif + +/* Maximum limits of ptrdiff_t defined in */ +#if defined(_LP64) +#define PTRDIFF_MAX 9223372036854775807L +#else +#define PTRDIFF_MAX 2147483647 +#endif + +/* + * Maximum value of a "size_t". SIZE_MAX was previously defined + * in , however, the standards specify it be defined + * in . The headers includes this header as + * does . The value of SIZE_MAX should not deviate + * from the value of ULONG_MAX defined . + */ +#if defined(_LP64) +#define SIZE_MAX 18446744073709551615UL +#else +#define SIZE_MAX 4294967295UL +#endif + +/* Maximum limit of sig_atomic_t defined in */ +#ifndef SIG_ATOMIC_MAX +#define SIG_ATOMIC_MAX 2147483647 +#endif + +/* + * Maximum limit of wchar_t. The WCHAR_* macros are also + * defined in , but inclusion of that header + * will break ISO/IEC C namespace. + */ +#ifndef WCHAR_MAX +#define WCHAR_MAX 2147483647 +#endif + +/* Maximum limit of wint_t */ +#ifndef WINT_MAX +#define WINT_MAX 2147483647 +#endif + +/* + * It is probably a bug in the POSIX specification (IEEE-1003.1-1990) that + * when including that the suffix _MAX is reserved but not the + * suffix _MIN. However, until that issue is resolved.... + */ +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG6) + +#define INT8_MIN (-128) +#define INT16_MIN (-32767-1) +#define INT32_MIN (-2147483647-1) +#if defined(_LP64) +#define INT64_MIN (-9223372036854775807L-1) +#elif defined(_LONGLONG_TYPE) +#define INT64_MIN (-9223372036854775807LL-1) +#endif + +#ifdef INT64_MIN +#define INTMAX_MIN INT64_MIN +#else +#define INTMAX_MIN INT32_MIN +#endif + +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#ifdef INT64_MIN +#define INT_LEAST64_MIN INT64_MIN +#endif + +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST32_MIN INT32_MIN +#ifdef INT64_MIN +#define INT_FAST64_MIN INT64_MIN +#endif + +/* Minimum value of a pointer-holding signed integer type */ +#if defined(_LP64) +#define INTPTR_MIN INT64_MIN +#else +#define INTPTR_MIN INT32_MIN +#endif + +/* Minimum limits of ptrdiff_t defined in */ +#if defined(_LP64) +#define PTRDIFF_MIN (-9223372036854775807L-1L) +#else +#define PTRDIFF_MIN (-2147483647-1) +#endif + +/* Minimum limit of sig_atomic_t defined in */ +#ifndef SIG_ATOMIC_MIN +#define SIG_ATOMIC_MIN (-2147483647-1) +#endif + +/* + * Minimum limit of wchar_t. The WCHAR_* macros are also + * defined in , but inclusion of that header + * will break ISO/IEC C namespace. + */ +#ifndef WCHAR_MIN +#define WCHAR_MIN (-2147483647-1) +#endif + +/* Minimum limit of wint_t */ +#ifndef WINT_MIN +#define WINT_MIN (-2147483647-1) +#endif + +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_INT_LIMITS_H */ diff --git a/illumos-x86_64/usr/include/sys/int_types.h b/illumos-x86_64/usr/include/sys/int_types.h new file mode 100644 index 00000000..d8acb850 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/int_types.h @@ -0,0 +1,194 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_INT_TYPES_H +#define _SYS_INT_TYPES_H + +/* + * This file, , is part of the Sun Microsystems implementation + * of defined in the ISO C standard, ISO/IEC 9899:1999 + * Programming language - C. + * + * Programs/Modules should not directly include this file. Access to the + * types defined in this file should be through the inclusion of one of the + * following files: + * + * Provides only the "_t" types defined in this + * file which is a subset of the contents of + * . (This can be appropriate for + * all programs/modules except those claiming + * ANSI-C conformance.) + * + * Provides the Kernel and Driver appropriate + * components of . + * + * For use by applications. + * + * See these files for more details. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Basic / Extended integer types + * + * The following defines the basic fixed-size integer types. + * + * Implementations are free to typedef them to Standard C integer types or + * extensions that they support. If an implementation does not support one + * of the particular integer data types below, then it should not define the + * typedefs and macros corresponding to that data type. Note that int8_t + * is not defined in -Xs mode on ISAs for which the ABI specifies "char" + * as an unsigned entity because there is no way to define an eight bit + * signed integral. + */ +#if defined(_CHAR_IS_SIGNED) +typedef char int8_t; +#else +typedef signed char int8_t; +#endif +typedef short int16_t; +typedef int int32_t; +#ifdef _LP64 +#define _INT64_TYPE +typedef long int64_t; +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +#define _INT64_TYPE +typedef long long int64_t; +#endif +#endif + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +#ifdef _LP64 +typedef unsigned long uint64_t; +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +typedef unsigned long long uint64_t; +#endif +#endif + +/* + * intmax_t and uintmax_t are to be the longest (in number of bits) signed + * and unsigned integer types supported by the implementation. + */ +#if defined(_INT64_TYPE) +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; +#else +typedef int32_t intmax_t; +typedef uint32_t uintmax_t; +#endif + +/* + * intptr_t and uintptr_t are signed and unsigned integer types large enough + * to hold any data pointer; that is, data pointers can be assigned into or + * from these integer types without losing precision. + */ +#if defined(_LP64) +typedef long intptr_t; +typedef unsigned long uintptr_t; +#else +typedef int intptr_t; +typedef unsigned int uintptr_t; +#endif + +/* + * The following define the fastest integer types that can hold the + * specified number of bits. + */ +#if defined(_CHAR_IS_SIGNED) +typedef char int_fast8_t; +#else +typedef signed char int_fast8_t; +#endif +typedef int int_fast16_t; +typedef int int_fast32_t; +#ifdef _LP64 +typedef long int_fast64_t; +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +typedef long long int_fast64_t; +#endif +#endif + +typedef unsigned char uint_fast8_t; +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; +#ifdef _LP64 +typedef unsigned long uint_fast64_t; +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +typedef unsigned long long uint_fast64_t; +#endif +#endif + +/* + * The following define the smallest integer types that can hold the + * specified number of bits. + */ +#if defined(_CHAR_IS_SIGNED) +typedef char int_least8_t; +#else +typedef signed char int_least8_t; +#endif +typedef short int_least16_t; +typedef int int_least32_t; +#ifdef _LP64 +typedef long int_least64_t; +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +typedef long long int_least64_t; +#endif +#endif + +/* + * If these are changed, please update char16_t and char32_t in head/uchar.h. + */ +typedef unsigned char uint_least8_t; +typedef unsigned short uint_least16_t; +typedef unsigned int uint_least32_t; +#ifdef _LP64 +typedef unsigned long uint_least64_t; +#else /* _ILP32 */ +#if defined(_LONGLONG_TYPE) +typedef unsigned long long uint_least64_t; +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_INT_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/inttypes.h b/illumos-x86_64/usr/include/sys/inttypes.h new file mode 100644 index 00000000..8bf21a1b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/inttypes.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_INTTYPES_H +#define _SYS_INTTYPES_H + +/* + * This header, , contains (through nested inclusion) the + * vast majority of the facilities specified for as defined + * by the ISO C Standard, ISO/IEC 9899:1999 Programming language - C. + * + * Kernel/Driver developers are encouraged to include this file to access + * the fixed size types, limits and utility macros. Application developers + * should use the standard defined header . + */ + +#include +#include +#if !defined(_XOPEN_SOURCE) || defined(_XPG6) || defined(__EXTENSIONS__) +#include +#include +#include +#endif + +#endif /* _SYS_INTTYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/ioccom.h b/illumos-x86_64/usr/include/sys/ioccom.h new file mode 100644 index 00000000..d08e7c41 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ioccom.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_IOCCOM_H +#define _SYS_IOCCOM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Ioctl's have the command encoded in the lower word, + * and the size of any in or out parameters in the upper + * word. The high 2 bits of the upper word are used + * to encode the in/out status of the parameter; for now + * we restrict parameters to at most 255 bytes. + */ +#define IOCPARM_MASK 0xff /* parameters must be < 256 bytes */ +#define IOC_VOID 0x20000000 /* no parameters */ +#define IOC_OUT 0x40000000 /* copy out parameters */ +#define IOC_IN 0x80000000 /* copy in parameters */ +#define IOC_INOUT (IOC_IN|IOC_OUT) + +/* + * The 0x20000000 is so we can distinguish new ioctl's from old. + */ +#define _IO(x, y) (IOC_VOID|(x<<8)|y) +#define _IOR(x, y, t) \ + ((int)((uint32_t) \ + (IOC_OUT|(((sizeof (t))&IOCPARM_MASK)<<16)|(x<<8)|y))) + +#define _IORN(x, y, t) ((int)((uint32_t)(IOC_OUT|(((t)&IOCPARM_MASK)<<16)| \ + (x<<8)|y))) + +#define _IOW(x, y, t) \ + ((int)((uint32_t)(IOC_IN|(((sizeof (t))&IOCPARM_MASK)<<16)| \ + (x<<8)|y))) + +#define _IOWN(x, y, t) ((int32_t)(uint32_t)(IOC_IN|(((t)&IOCPARM_MASK)<<16)| \ + (x<<8)|y)) + +#define _IOWR(x, y, t) \ + ((int)((uint32_t)(IOC_INOUT|(((sizeof (t))&IOCPARM_MASK)<<16)| \ + (x<<8)|y))) + +#define _IOWRN(x, y, t) \ + ((int)((uint32_t)(IOC_INOUT|(((t)&IOCPARM_MASK)<<16)| \ + (x<<8)|y))) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IOCCOM_H */ diff --git a/illumos-x86_64/usr/include/sys/ioctl.h b/illumos-x86_64/usr/include/sys/ioctl.h new file mode 100644 index 00000000..4492c09b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ioctl.h @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1991 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_IOCTL_H +#define _SYS_IOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * There are some inherent problems in having a single file + * ioctl.h, with both System V and BSD flags. Introducing + * BSD flags into this file creates compilation problems + * with flags such as ECHO, NL1 etc., if termio.h and ioctl.h + * are included by the same file. Since these two files can + * be only included by System V applications, /usr/inclule/sys/ioctl.h + * will be System V mode and all the BSD flags will be turned off + * using #ifdef BSD_COMP. This file will also exist in + * /usr/ucbinclude/sys/ioctl.h for BSD applications but without the + * BSD flags turned off. System V appliactions can use ioctl.h without + * any changes, System V applications requiring BSD flags should + * -D BSD_COMP when compiling (and be warned about the common + * flags between System V and BSD) and BSD applications should + * use /usr/ucbinclude/sys/ioctl.h. + * + */ + +#define IOCTYPE 0xff00 + +#define LIOC ('l'<<8) +#define LIOCGETP (LIOC|1) +#define LIOCSETP (LIOC|2) +#define LIOCGETS (LIOC|5) +#define LIOCSETS (LIOC|6) + +#define DIOC ('d'<<8) +#define DIOCGETC (DIOC|1) +#define DIOCGETB (DIOC|2) +#define DIOCSETE (DIOC|3) + +/* + * While ioctl was at one point only defined in by POSIX, it was + * removed in Issue 8 (2024). We also have traditionally had a definition of + * this in , which is namespaced. We add this here without namespacing + * to aid broader portability. + */ +extern int ioctl(int, int, ...); + +#ifdef __cplusplus +} +#endif + +/* BSD related defines */ + +#ifdef BSD_COMP + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TANDEM O_TANDEM +#define CBREAK O_CBREAK +#ifndef _SGTTY_H +#define LCASE O_LCASE +#define ECHO O_ECHO +#define CRMOD O_CRMOD +#define RAW O_RAW +#define ODDP O_ODDP +#define EVENP O_EVENP +#define ANYP O_ANYP +#define NLDELAY O_NLDELAY +#define NL0 O_NL0 +#define NL1 O_NL1 +#define NL2 O_NL2 +#define NL3 O_NL3 +#define TBDELAY O_TBDELAY +#define TAB0 O_TAB0 +#define TAB1 O_TAB1 +#define TAB2 O_TAB2 +#define XTABS O_XTABS +#define CRDELAY O_CRDELAY +#define CR0 O_CR0 +#define CR1 O_CR1 +#define CR2 O_CR2 +#define CR3 O_CR3 +#define VTDELAY O_VTDELAY +#define FF0 O_FF0 +#define FF1 O_FF1 +#define BSDELAY O_BSDELAY +#define BS0 O_BS0 +#define BS1 O_BS1 +#define ALLDELAY O_ALLDELAY +#endif /* _SGTTY_H */ +#define CRTBS O_CRTBS +#define PRTERA O_PRTERA +#define CRTERA O_CRTERA +#define TILDE O_TILDE +#define MDMBUF O_MDMBUF +#define LITOUT O_LITOUT +#define TOSTOP O_TOSTOP +#define FLUSHO O_FLUSHO +#define NOHANG O_NOHANG +#define L001000 O_L001000 +#define CRTKIL O_CRTKIL +#define PASS8 O_PASS8 +#define CTLECH O_CTLECH +#define PENDIN O_PENDIN +#define DECCTQ O_DECCTQ +#define NOFLSH O_NOFLSH + +#ifdef __cplusplus +} +#endif + +#include +#include + +#endif /* BSD_COMP */ + +#endif /* _SYS_IOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/iommulib.h b/illumos-x86_64/usr/include/sys/iommulib.h new file mode 100644 index 00000000..7fb525ed --- /dev/null +++ b/illumos-x86_64/usr/include/sys/iommulib.h @@ -0,0 +1,319 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore . All rights reserved. + */ + +#ifndef _SYS_IOMMULIB_H +#define _SYS_IOMMULIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#ifdef _KERNEL + +typedef enum { + INVALID_VENDOR = 0, + AMD_IOMMU, + INTEL_IOMMU +} iommulib_vendor_t; + +typedef enum { + IOMMU_OPS_VERSION_INVALID = 0, + IOMMU_OPS_VERSION_1 = 1, + IOMMU_OPS_VERSION_2 = 2, + IOMMU_OPS_VERSION_3 = 3 +} iommulib_opsversion_t; + +#define IOMMU_OPS_VERSION IOMMU_OPS_VERSION_3 + +typedef struct iommulib_ops { + iommulib_opsversion_t ilops_vers; + iommulib_vendor_t ilops_vendor; + char *ilops_id; + void *ilops_data; + + int (*ilops_probe)(iommulib_handle_t handle, dev_info_t *rdip); + + int (*ilops_dma_allochdl)(iommulib_handle_t handle, + dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr, + int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *dma_handlep); + + int (*ilops_dma_freehdl)(iommulib_handle_t handle, + dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle); + + int (*ilops_dma_bindhdl)(iommulib_handle_t handle, dev_info_t *dip, + dev_info_t *rdip, ddi_dma_handle_t dma_handle, + struct ddi_dma_req *dmareq, ddi_dma_cookie_t *cookiep, + uint_t *ccountp); + + int (*ilops_dma_unbindhdl)(iommulib_handle_t handle, + dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle); + + int (*ilops_dma_sync)(iommulib_handle_t handle, dev_info_t *dip, + dev_info_t *rdip, ddi_dma_handle_t dma_handle, off_t off, + size_t len, uint_t cache_flags); + + int (*ilops_dma_win)(iommulib_handle_t handle, dev_info_t *dip, + dev_info_t *rdip, ddi_dma_handle_t dma_handle, uint_t win, + off_t *offp, size_t *lenp, ddi_dma_cookie_t *cookiep, + uint_t *ccountp); + + int (*ilops_dma_mapobject)(iommulib_handle_t handle, + dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle, + struct ddi_dma_req *dmareq, ddi_dma_obj_t *dmao); + + int (*ilops_dma_unmapobject)(iommulib_handle_t handle, + dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle, + ddi_dma_obj_t *dmao); + +} iommulib_ops_t; + +/* + * Fake pointer value to indicate that a device will not use an IOMMU + * for DMA (it's either set up for passthrough or uses a unity mapping). + */ +#define IOMMU_HANDLE_UNUSED (void *)-1 + +/* + * IOMMU_UNITIALIZED() is true if it has not been determined whether + * a device uses an IOMMU for DMA or not. After it has been determined, + * the USED and UNUSED macros may be used to see if an IOMMU is being + * used or not. + * + * IOMMU_USED() is true if a device uses an IOMMU for DMA + * + * IOMMU_UNUSED() is true if a device does not use an IOMMU for DMA + */ +#define IOMMU_USED(dip) \ + (DEVI(dip)->devi_iommulib_handle != NULL && \ + DEVI(dip)->devi_iommulib_handle != IOMMU_HANDLE_UNUSED) +#define IOMMU_UNUSED(dip) \ + (DEVI(dip)->devi_iommulib_handle == IOMMU_HANDLE_UNUSED) +#define IOMMU_UNITIALIZED(dip) \ + (DEVI(dip)->devi_iommulib_handle == NULL) + +typedef enum { + IOMMU_NEXOPS_VERSION_INVALID = 0, + IOMMU_NEXOPS_VERSION_1 = 1, + IOMMU_NEXOPS_VERSION_2 = 2, + IOMMU_NEXOPS_VERSION_3 = 3 +} iommulib_nexops_version_t; + +#define IOMMU_NEXOPS_VERSION IOMMU_NEXOPS_VERSION_3 + +typedef struct iommulib_nexops { + iommulib_nexops_version_t nops_vers; + char *nops_id; + void *nops_data; + + int (*nops_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg, + ddi_dma_handle_t *handlep); + + int (*nops_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + + int (*nops_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, struct ddi_dma_req *dmareq, + ddi_dma_cookie_t *cookiep, uint_t *ccountp); + + int (*nops_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + + void (*nops_dma_reset_cookies)(dev_info_t *dip, + ddi_dma_handle_t handle); + + int (*nops_dma_get_cookies)(dev_info_t *dip, ddi_dma_handle_t handle, + ddi_dma_cookie_t **cookiepp, uint_t *ccountp); + + int (*nops_dma_set_cookies)(dev_info_t *dip, ddi_dma_handle_t handle, + ddi_dma_cookie_t *cookiep, uint_t ccount); + + int (*nops_dma_clear_cookies)(dev_info_t *dip, ddi_dma_handle_t handle); + + int (*nops_dma_get_sleep_flags)(ddi_dma_handle_t handle); + + int (*nops_dma_sync)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags); + + int (*nops_dma_win)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp, + ddi_dma_cookie_t *cookiep, uint_t *ccountp); + + int (*nops_dmahdl_setprivate)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, void *priv); + + void * (*nops_dmahdl_getprivate)(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); +} iommulib_nexops_t; + +/* + * struct iommu_dip_private + * private iommu structure hook on dev_info + */ +typedef struct iommu_private { + /* pci seg, bus, dev, func */ + int idp_seg; + int idp_bus; + int idp_devfn; + + /* ppb information */ + boolean_t idp_is_bridge; + int idp_bbp_type; + int idp_sec; + int idp_sub; + + /* identifier for special devices */ + boolean_t idp_is_display; + boolean_t idp_is_lpc; + + /* domain ptr */ + void *idp_intel_domain; +} iommu_private_t; + +#define INTEL_IOMMU_PRIVATE(i) (dmar_domain_state_t *)(i) + +typedef struct gfx_entry { + int g_ref; + dev_info_t *g_dip; + struct gfx_entry *g_prev; + struct gfx_entry *g_next; +} gfx_entry_t; + +/* + * Interfaces for nexus drivers - typically rootnex + */ + +int iommulib_nexus_register(dev_info_t *dip, iommulib_nexops_t *nexops, + iommulib_nexhandle_t *handle); + +int iommulib_nexus_unregister(iommulib_nexhandle_t handle); + +int iommulib_nex_open(dev_info_t *dip, dev_info_t *rdip); +void iommulib_nex_close(dev_info_t *rdip); + +int iommulib_nexdma_allochdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), + caddr_t arg, ddi_dma_handle_t *dma_handlep); + +int iommulib_nexdma_freehdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t dma_handle); + +int iommulib_nexdma_bindhdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq, + ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +int iommulib_nexdma_unbindhdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t dma_handle); + +int iommulib_nexdma_sync(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t dma_handle, off_t off, size_t len, + uint_t cache_flags); + +int iommulib_nexdma_win(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t dma_handle, uint_t win, off_t *offp, size_t *lenp, + ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +int iommulib_nexdma_mapobject(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq, + ddi_dma_obj_t *dmao); +int iommulib_nexdma_unmapobject(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t dma_handle, ddi_dma_obj_t *dmao); + +/* + * Interfaces for IOMMU drivers provided by IOMMULIB + */ + +int iommulib_iommu_register(dev_info_t *dip, iommulib_ops_t *ops, + iommulib_handle_t *handle); + +int iommulib_iommu_unregister(iommulib_handle_t handle); + +int iommulib_iommu_getunitid(iommulib_handle_t handle, uint64_t *unitidp); + +dev_info_t *iommulib_iommu_getdip(iommulib_handle_t handle); + +iommulib_ops_t *iommulib_iommu_getops(iommulib_handle_t handle); + +void *iommulib_iommu_getdata(iommulib_handle_t handle); + + +/* Interfaces for IOMMU drivers provided by NEXUS drivers (typically rootnex) */ + +int iommulib_iommu_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg, + ddi_dma_handle_t *handlep); + +int iommulib_iommu_dma_freehdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + +int iommulib_iommu_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, struct ddi_dma_req *dmareq, + ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +int iommulib_iommu_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + +void iommulib_iommu_dma_reset_cookies(dev_info_t *dip, ddi_dma_handle_t handle); + +int iommulib_iommu_dma_get_cookies(dev_info_t *dip, ddi_dma_handle_t handle, + ddi_dma_cookie_t **cookiepp, uint_t *ccountp); + +int iommulib_iommu_dma_set_cookies(dev_info_t *dip, ddi_dma_handle_t handle, + ddi_dma_cookie_t *cookiep, uint_t ccount); + +int iommulib_iommu_dma_clear_cookies(dev_info_t *dip, ddi_dma_handle_t handle); + +int iommulib_iommu_dma_get_sleep_flags(dev_info_t *dip, + ddi_dma_handle_t handle); + +int iommulib_iommu_dma_sync(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags); + +int iommulib_iommu_dma_win(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp, + ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +int iommulib_iommu_dmahdl_setprivate(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, void *priv); + +void *iommulib_iommu_dmahdl_getprivate(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + + +/* + * For SMBIOS access from IOMMU drivers + */ +extern smbios_hdl_t *iommulib_smbios; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IOMMULIB_H */ diff --git a/illumos-x86_64/usr/include/sys/ipc.h b/illumos-x86_64/usr/include/sys/ipc.h new file mode 100644 index 00000000..7ff9e2f2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ipc.h @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + + +#ifndef _SYS_IPC_H +#define _SYS_IPC_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Common IPC access structure */ + +struct ipc_perm { + uid_t uid; /* owner's user id */ + gid_t gid; /* owner's group id */ + uid_t cuid; /* creator's user id */ + gid_t cgid; /* creator's group id */ + mode_t mode; /* access modes */ + uint_t seq; /* slot usage sequence number */ + key_t key; /* key */ +#if !defined(_LP64) + int pad[4]; /* reserve area */ +#endif +}; + + +/* Common IPC definitions */ + +/* Mode bits */ +#define IPC_ALLOC 0100000 /* entry currently allocated */ +#define IPC_CREAT 0001000 /* create entry if key doesn't exist */ +#define IPC_EXCL 0002000 /* fail if key exists */ +#define IPC_NOWAIT 0004000 /* error if request must wait */ + +/* Keys */ +#define IPC_PRIVATE (key_t)0 /* private key */ + + +/* Common IPC control commands */ +#define IPC_RMID 10 /* remove identifier */ +#define IPC_SET 11 /* set options */ +#define IPC_STAT 12 /* get options */ + + +#if (!defined(_KERNEL) && !defined(_XOPEN_SOURCE)) || defined(_XPG4_2) || \ + defined(__EXTENSIONS__) +key_t ftok(const char *, int); +#endif /* (!defined(_KERNEL) && !defined(_XOPEN_SOURCE))... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IPC_H */ diff --git a/illumos-x86_64/usr/include/sys/ipc_impl.h b/illumos-x86_64/usr/include/sys/ipc_impl.h new file mode 100644 index 00000000..d7dc365c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ipc_impl.h @@ -0,0 +1,249 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016, Joyent, Inc. + */ + +#ifndef _IPC_IMPL_H +#define _IPC_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint64_t ipc_time_t; + +/* For xxxctl64 */ +#define IPC_SET64 13 /* set options */ +#define IPC_STAT64 14 /* get options */ + +/* + * There are two versions of the userland ipc_perm structure: + * ipc_perm - the version used by user applications and by the kernel + * when the user and kernel data models match (in ipc.h) + * ipc_perm32 - the 64-bit kernel's view of a 32-bit struct ipc_perm + */ +#if defined(_SYSCALL32) +struct ipc_perm32 { + uid32_t uid; /* owner's user id */ + gid32_t gid; /* owner's group id */ + uid32_t cuid; /* creator's user id */ + gid32_t cgid; /* creator's group id */ + mode32_t mode; /* access modes */ + uint32_t seq; /* slot usage sequence number */ + key32_t key; /* key */ + int32_t pad[4]; /* reserve area */ +}; +#endif /* _SYSCALL32 */ + +/* + * This is the ipc_perm equivalent used in the xxxid_ds64 structures. + * It, like the structures it is used in, is intended only for use in + * communication between the kernel and user programs, and has the same + * layout across all data models. + * + * The xxxid_ds64 structures rely on ipc_perm64 being a multiple of + * 8 bytes so subsequent fields are 64-bit aligned on x86. + */ +typedef struct ipc_perm64 { + uid_t ipcx_uid; /* owner's user id */ + gid_t ipcx_gid; /* owner's group id */ + uid_t ipcx_cuid; /* creator's user id */ + gid_t ipcx_cgid; /* creator's group id */ + mode_t ipcx_mode; /* access modes */ + key_t ipcx_key; /* key */ + projid_t ipcx_projid; /* allocating project id */ + zoneid_t ipcx_zoneid; /* creator's zone id */ +} ipc_perm64_t; + +/* + * These are versions of xxxid_ds which are intended only for use in + * communication between the kernel and user programs, and therefore + * have the same layout across all data models. Omitted are all + * implementation-specific fields which would be of no use to user + * programs. + */ +struct shmid_ds64 { + ipc_perm64_t shmx_perm; /* operation permission struct */ + pid_t shmx_lpid; /* pid of last shmop */ + pid_t shmx_cpid; /* pid of creator */ + uint64_t shmx_segsz; /* size of segment in bytes */ + uint64_t shmx_nattch; /* # of attaches */ + uint64_t shmx_cnattch; /* # of ISM attaches */ + uint64_t shmx_lkcnt; /* lock count ??? */ + ipc_time_t shmx_atime; /* last shmat time */ + ipc_time_t shmx_dtime; /* last shmdt time */ + ipc_time_t shmx_ctime; /* last change time */ +}; + +struct semid_ds64 { + ipc_perm64_t semx_perm; /* operation permission struct */ + ushort_t semx_nsems; /* # of semaphores in set */ + ushort_t _semx_pad[3]; /* pad to 8-byte multiple */ + ipc_time_t semx_otime; /* last semop time */ + ipc_time_t semx_ctime; /* last change time */ +}; + +struct msqid_ds64 { + ipc_perm64_t msgx_perm; /* operation permission struct */ + uint64_t msgx_cbytes; /* current # bytes on q */ + uint64_t msgx_qnum; /* # of messages on q */ + uint64_t msgx_qbytes; /* max # of bytes on q */ + pid_t msgx_lspid; /* pid of last msgsnd */ + pid_t msgx_lrpid; /* pid of last msgrcv */ + ipc_time_t msgx_stime; /* last msgsnd time */ + ipc_time_t msgx_rtime; /* last msgrcv time */ + ipc_time_t msgx_ctime; /* last change time */ +}; + +#ifdef _KERNEL + +/* + * Implementation macros + */ +#define IPC_FREE(x) (((x)->ipc_mode & IPC_ALLOC) == 0) + +#define IPC_SEQ_BITS 7 +#define IPC_SEQ_MASK ((1 << IPC_SEQ_BITS) - 1) +#define IPC_SEQ_SHIFT (31 - IPC_SEQ_BITS) +#define IPC_INDEX_MASK ((1 << IPC_SEQ_SHIFT) - 1) +#define IPC_SEQ(x) ((unsigned int)(x) >> IPC_SEQ_SHIFT) +#define IPC_INDEX(x) ((unsigned int)(x) & IPC_INDEX_MASK) + +#define IPC_IDS_MIN (PAGESIZE / 64) /* starting # of entries */ +#define IPC_IDS_MAX (1 << IPC_SEQ_SHIFT) /* maximum # of entries */ +#define IPC_ID_INVAL UINT_MAX + +#define IPC_PROJ_USAGE(p, s) \ + (*(rctl_qty_t *)(((char *)&p->ipc_proj->kpj_data.kpd_ipc) + \ + s->ipcs_rctlofs)) +#define IPC_ZONE_USAGE(p, s) \ + (*(rctl_qty_t *)(((char *)&p->ipc_zone_ref.zref_zone->zone_ipc) + \ + s->ipcs_rctlofs)) +#define IPC_LOCKED(s, o) \ + MUTEX_HELD(&s->ipcs_table[IPC_INDEX(o->ipc_id)].ipct_lock) + +/* + * The kernel's ipc_perm structure. + */ +typedef struct kipc_perm { + avl_node_t ipc_avl; /* avl node if key is non-private */ + list_node_t ipc_list; /* list node in list of all ids */ + uint_t ipc_ref; /* reference count */ + uid_t ipc_uid; /* owner's user id */ + gid_t ipc_gid; /* owner's group id */ + uid_t ipc_cuid; /* creator's user id */ + gid_t ipc_cgid; /* creator's group id */ + mode_t ipc_mode; /* access modes */ + key_t ipc_key; /* key */ + kproject_t *ipc_proj; /* creator's project */ + uint_t ipc_id; /* id */ + zoneid_t ipc_zoneid; /* creator's zone id */ + zone_ref_t ipc_zone_ref; /* reference to creator's zone */ +} kipc_perm_t; + +typedef struct ipc_slot { + kmutex_t ipct_lock; /* bucket lock */ + kipc_perm_t *ipct_data; /* data */ + uint_t ipct_seq; /* sequence number */ + struct ipc_slot *ipct_chain; /* for stale arrays */ + char ipct_pad[64 - sizeof (kmutex_t) - 3 * sizeof (void *)]; +} ipc_slot_t; + +typedef void(ipc_func_t)(kipc_perm_t *); + +typedef struct ipc_service { + kmutex_t ipcs_lock; /* lock for (de)allocation, keys */ + avl_tree_t ipcs_keys; /* objects sorted by key */ + ipc_slot_t *ipcs_table; /* table of objects */ + uint_t ipcs_tabsz; /* size of table */ + uint_t ipcs_count; /* # of objects allocated */ + rctl_hndl_t ipcs_proj_rctl; /* id limiting rctl handle */ + rctl_hndl_t ipcs_zone_rctl; /* id limiting rctl handle */ + size_t ipcs_rctlofs; /* offset in kproject_data_t */ + id_space_t *ipcs_ids; /* id space for objects */ + size_t ipcs_ssize; /* object size (for allocation) */ + ipc_func_t *ipcs_dtor; /* object destructor */ + ipc_func_t *ipcs_rmid; /* object removal */ + list_t ipcs_usedids; /* list of allocated ids */ + int ipcs_atype; /* audit type (see c2/audit.h) */ +} ipc_service_t; + +int ipcperm_access(kipc_perm_t *, int, cred_t *); +int ipcperm_set(ipc_service_t *, struct cred *, kipc_perm_t *, + struct ipc_perm *, model_t); +void ipcperm_stat(struct ipc_perm *, kipc_perm_t *, model_t); +int ipcperm_set64(ipc_service_t *, struct cred *, kipc_perm_t *, + ipc_perm64_t *); +void ipcperm_stat64(ipc_perm64_t *, kipc_perm_t *); + +ipc_service_t *ipcs_create(const char *, rctl_hndl_t, rctl_hndl_t, size_t, + ipc_func_t *, ipc_func_t *, int, size_t); +void ipcs_destroy(ipc_service_t *); +void ipcs_lock(ipc_service_t *); +void ipcs_unlock(ipc_service_t *); + +kmutex_t *ipc_lock(ipc_service_t *, int); +kmutex_t *ipc_relock(ipc_service_t *, int, kmutex_t *); +kmutex_t *ipc_lookup(ipc_service_t *, int, kipc_perm_t **); + +void ipc_hold(ipc_service_t *, kipc_perm_t *); +void ipc_rele(ipc_service_t *, kipc_perm_t *); +void ipc_rele_locked(ipc_service_t *, kipc_perm_t *); + +int ipc_get(ipc_service_t *, key_t, int, kipc_perm_t **, kmutex_t **); +int ipc_commit_begin(ipc_service_t *, key_t, int, kipc_perm_t *); +kmutex_t *ipc_commit_end(ipc_service_t *, kipc_perm_t *); +void ipc_cleanup(ipc_service_t *, kipc_perm_t *); + +void ipc_rmsvc(ipc_service_t *, kipc_perm_t *); +int ipc_rmid(ipc_service_t *, int, cred_t *); +int ipc_ids(ipc_service_t *, int *, uint_t, uint_t *); + +void ipc_remove_zone(ipc_service_t *, zoneid_t); + +#else /* _KERNEL */ + +int msgctl64(int, int, struct msqid_ds64 *); +int semctl64(int, int, int, ...); +int shmctl64(int, int, struct shmid_ds64 *); + +#endif /* _KERNEL */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _IPC_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/ipc_rctl.h b/illumos-x86_64/usr/include/sys/ipc_rctl.h new file mode 100644 index 00000000..f1c8303e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ipc_rctl.h @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_IPC_RCTL_H +#define _SYS_IPC_RCTL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ipc_rqty { /* datum protected by: */ + rctl_qty_t ipcq_shmmni; /* shm's ipcs_lock */ + rctl_qty_t ipcq_semmni; /* sem's ipcs_lock */ + rctl_qty_t ipcq_msgmni; /* msg's ipcs_lock */ +} ipc_rqty_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IPC_RCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/isa_defs.h b/illumos-x86_64/usr/include/sys/isa_defs.h new file mode 100644 index 00000000..e9de4b2d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/isa_defs.h @@ -0,0 +1,496 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _SYS_ISA_DEFS_H +#define _SYS_ISA_DEFS_H + +/* + * This header file serves to group a set of well known defines and to + * set these for each instruction set architecture. These defines may + * be divided into two groups; characteristics of the processor and + * implementation choices for Solaris on a processor. + * + * Processor Characteristics: + * + * _LITTLE_ENDIAN / _BIG_ENDIAN: + * The natural byte order of the processor. A pointer to an int points + * to the least/most significant byte of that int. + * + * _STACK_GROWS_UPWARD / _STACK_GROWS_DOWNWARD: + * The processor specific direction of stack growth. A push onto the + * stack increases/decreases the stack pointer, so it stores data at + * successively higher/lower addresses. (Stackless machines ignored + * without regrets). + * + * _LONG_LONG_HTOL / _LONG_LONG_LTOH: + * A pointer to a long long points to the most/least significant long + * within that long long. + * + * _BIT_FIELDS_HTOL / _BIT_FIELDS_LTOH: + * The C compiler assigns bit fields from the high/low to the low/high end + * of an int (most to least significant vs. least to most significant). + * + * _IEEE_754: + * The processor (or supported implementations of the processor) + * supports the ieee-754 floating point standard. No other floating + * point standards are supported (or significant). Any other supported + * floating point formats are expected to be cased on the ISA processor + * symbol. + * + * _CHAR_IS_UNSIGNED / _CHAR_IS_SIGNED: + * The C Compiler implements objects of type `char' as `unsigned' or + * `signed' respectively. This is really an implementation choice of + * the compiler writer, but it is specified in the ABI and tends to + * be uniform across compilers for an instruction set architecture. + * Hence, it has the properties of a processor characteristic. + * + * _CHAR_ALIGNMENT / _SHORT_ALIGNMENT / _INT_ALIGNMENT / _LONG_ALIGNMENT / + * _LONG_LONG_ALIGNMENT / _DOUBLE_ALIGNMENT / _LONG_DOUBLE_ALIGNMENT / + * _POINTER_ALIGNMENT / _FLOAT_ALIGNMENT: + * The ABI defines alignment requirements of each of the primitive + * object types. Some, if not all, may be hardware requirements as + * well. The values are expressed in "byte-alignment" units. + * + * _MAX_ALIGNMENT: + * The most stringent alignment requirement as specified by the ABI. + * Equal to the maximum of all the above _XXX_ALIGNMENT values. + * + * _MAX_ALIGNMENT_TYPE: + * The name of the C type that has the value descried in _MAX_ALIGNMENT. + * + * _ALIGNMENT_REQUIRED: + * True or false (1 or 0) whether or not the hardware requires the ABI + * alignment. + * + * _LONG_LONG_ALIGNMENT_32 + * The 32-bit ABI supported by a 64-bit kernel may have different + * alignment requirements for primitive object types. The value of this + * identifier is expressed in "byte-alignment" units. + * + * _HAVE_CPUID_INSN + * This indicates that the architecture supports the 'cpuid' + * instruction as defined by Intel. (Intel allows other vendors + * to extend the instruction for their own purposes.) + * + * _CACHE_LINE_SHIFT + * _CACHE_LINE_SIZE + * Compile time maximum cache line size for an architecture. + * + * Implementation Choices: + * + * _ILP32 / _LP64: + * This specifies the compiler data type implementation as specified in + * the relevant ABI. The choice between these is strongly influenced + * by the underlying hardware, but is not absolutely tied to it. + * Currently only two data type models are supported: + * + * _ILP32: + * Int/Long/Pointer are 32 bits. This is the historical UNIX + * and Solaris implementation. Due to its historical standing, + * this is the default case. + * + * _LP64: + * Long/Pointer are 64 bits, Int is 32 bits. This is the chosen + * implementation for 64-bit ABIs such as SPARC V9. + * + * NOTE: This header used to define _I32LPx, which expressed a compilation + * environment where 'int' is 32-bit, and 'long' and pointers are the same + * size (although that size is not specified). This was true for all + * compilation targets, making it of little value. Additionally, it was + * erroneously interpreted as implying that long/pointer were 64-bit. + * + * In all cases, Char is 8 bits and Short is 16 bits. + * + * _SUNOS_VTOC_8 / _SUNOS_VTOC_16 / _SVR4_VTOC_16: + * This specifies the form of the disk VTOC (or label): + * + * _SUNOS_VTOC_8: + * This is a VTOC form which is upwardly compatible with the + * SunOS 4.x disk label and allows 8 partitions per disk. + * + * _SUNOS_VTOC_16: + * In this format the incore vtoc image matches the ondisk + * version. It allows 16 slices per disk, and is not + * compatible with the SunOS 4.x disk label. + * + * Note that these are not the only two VTOC forms possible and + * additional forms may be added. One possible form would be the + * SVr4 VTOC form. The symbol for that is reserved now, although + * it is not implemented. + * + * _SVR4_VTOC_16: + * This VTOC form is compatible with the System V Release 4 + * VTOC (as implemented on the SVr4 Intel and 3b ports) with + * 16 partitions per disk. + * + * + * _DMA_USES_PHYSADDR / _DMA_USES_VIRTADDR + * This describes the type of addresses used by system DMA: + * + * _DMA_USES_PHYSADDR: + * This type of DMA, used in the x86 implementation, + * requires physical addresses for DMA buffers. The 24-bit + * addresses used by some legacy boards is the source of the + * "low-memory" (<16MB) requirement for some devices using DMA. + * + * _DMA_USES_VIRTADDR: + * This method of DMA allows the use of virtual addresses for + * DMA transfers. + * + * _FIRMWARE_NEEDS_FDISK / _NO_FDISK_PRESENT + * This indicates the presence/absence of an fdisk table. + * + * _FIRMWARE_NEEDS_FDISK + * The fdisk table is required by system firmware. If present, + * it allows a disk to be subdivided into multiple fdisk + * partitions, each of which is equivalent to a separate, + * virtual disk. This enables the co-existence of multiple + * operating systems on a shared hard disk. + * + * _NO_FDISK_PRESENT + * If the fdisk table is absent, it is assumed that the entire + * media is allocated for a single operating system. + * + * _HAVE_TEM_FIRMWARE + * Defined if this architecture has the (fallback) option of + * using prom_* calls for doing I/O if a suitable kernel driver + * is not available to do it. + * + * _DONT_USE_1275_GENERIC_NAMES + * Controls whether or not device tree node names should + * comply with the IEEE 1275 "Generic Names" Recommended + * Practice. With _DONT_USE_GENERIC_NAMES, device-specific + * names identifying the particular device will be used. + * + * __i386_COMPAT + * This indicates whether the i386 ABI is supported as a *non-native* + * mode for the platform. When this symbol is defined: + * - 32-bit xstat-style system calls are enabled + * - 32-bit xmknod-style system calls are enabled + * - 32-bit system calls use i386 sizes -and- alignments + * + * Note that this is NOT defined for the i386 native environment! + * + * __x86 + * This is ONLY a synonym for defined(__i386) || defined(__amd64) + * which is useful only insofar as these two architectures share + * common attributes. Analogous to __sparc. + * + * _PSM_MODULES + * This indicates whether or not the implementation uses PSM + * modules for processor support, reading /etc/mach from inside + * the kernel to extract a list. + * + * _RTC_CONFIG + * This indicates whether or not the implementation uses /etc/rtc_config + * to configure the real-time clock in the kernel. + * + * _UNIX_KRTLD + * This indicates that the implementation uses a dynamically + * linked unix + krtld to form the core kernel image at boot + * time, or (in the absence of this symbol) a prelinked kernel image. + * + * _OBP + * This indicates the firmware interface is OBP. + * + * _SOFT_HOSTID + * This indicates that the implementation obtains the hostid + * from the file /etc/hostid, rather than from hardware. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following set of definitions characterize Solaris on AMD's + * 64-bit systems. + */ +#if defined(__x86_64) || defined(__amd64) + +#if !defined(__amd64) +#define __amd64 /* preferred guard */ +#endif + +#if !defined(__x86) +#define __x86 +#endif + +/* + * Define the appropriate "processor characteristics" + */ +#define _LITTLE_ENDIAN +#define _STACK_GROWS_DOWNWARD +#define _LONG_LONG_LTOH +#define _BIT_FIELDS_LTOH +#define _IEEE_754 +#define _CHAR_IS_SIGNED +#define _BOOL_ALIGNMENT 1 +#define _CHAR_ALIGNMENT 1 +#define _SHORT_ALIGNMENT 2 +#define _INT_ALIGNMENT 4 +#define _FLOAT_ALIGNMENT 4 +#define _FLOAT_COMPLEX_ALIGNMENT 4 +#define _LONG_ALIGNMENT 8 +#define _LONG_LONG_ALIGNMENT 8 +#define _DOUBLE_ALIGNMENT 8 +#define _DOUBLE_COMPLEX_ALIGNMENT 8 +#define _LONG_DOUBLE_ALIGNMENT 16 +#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 +#define _POINTER_ALIGNMENT 8 +#define _MAX_ALIGNMENT 16 +#define _ALIGNMENT_REQUIRED 1 +#define _MAX_ALIGNMENT_TYPE long double +#define _CACHE_LINE_SHIFT 6 +#define _CACHE_LINE_SIZE (1 << _CACHE_LINE_SHIFT) + +/* + * Different alignment constraints for the i386 ABI in compatibility mode + */ +#define _LONG_LONG_ALIGNMENT_32 4 + +/* + * Define the appropriate "implementation choices". + */ +#if !defined(_LP64) +#define _LP64 +#endif +#define _MULTI_DATAMODEL +#define _SUNOS_VTOC_16 +#define _DMA_USES_PHYSADDR +#define _FIRMWARE_NEEDS_FDISK +#define __i386_COMPAT +#define _PSM_MODULES +#define _RTC_CONFIG +#define _SOFT_HOSTID +#define _DONT_USE_1275_GENERIC_NAMES +#define _HAVE_CPUID_INSN + +/* + * The feature test macro __i386 is generic for all processors implementing + * the Intel 386 instruction set or a superset of it. Specifically, this + * includes all members of the 386, 486, and Pentium family of processors. + */ +#elif defined(__i386) || defined(__i386__) + +#if !defined(__i386) +#define __i386 +#endif + +#if !defined(__x86) +#define __x86 +#endif + +/* + * Define the appropriate "processor characteristics" + */ +#define _LITTLE_ENDIAN +#define _STACK_GROWS_DOWNWARD +#define _LONG_LONG_LTOH +#define _BIT_FIELDS_LTOH +#define _IEEE_754 +#define _CHAR_IS_SIGNED +#define _BOOL_ALIGNMENT 1 +#define _CHAR_ALIGNMENT 1 +#define _SHORT_ALIGNMENT 2 +#define _INT_ALIGNMENT 4 +#define _FLOAT_ALIGNMENT 4 +#define _FLOAT_COMPLEX_ALIGNMENT 4 +#define _LONG_ALIGNMENT 4 +#define _LONG_LONG_ALIGNMENT 4 +#define _DOUBLE_ALIGNMENT 4 +#define _DOUBLE_COMPLEX_ALIGNMENT 4 +#define _LONG_DOUBLE_ALIGNMENT 4 +#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4 +#define _POINTER_ALIGNMENT 4 +#define _MAX_ALIGNMENT 4 +#define _ALIGNMENT_REQUIRED 0 +#define _MAX_ALIGNMENT_TYPE long +#define _CACHE_LINE_SHIFT 6 +#define _CACHE_LINE_SIZE (1 << _CACHE_LINE_SHIFT) + +#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT + +/* + * Define the appropriate "implementation choices". + */ +#if !defined(_ILP32) +#define _ILP32 +#endif +#define _SUNOS_VTOC_16 +#define _DMA_USES_PHYSADDR +#define _FIRMWARE_NEEDS_FDISK +#define _PSM_MODULES +#define _RTC_CONFIG +#define _SOFT_HOSTID +#define _DONT_USE_1275_GENERIC_NAMES +#define _HAVE_CPUID_INSN + +/* + * The following set of definitions characterize the Solaris on SPARC systems. + * + * The symbol __sparc indicates any of the SPARC family of processor + * architectures. This includes SPARC V7, SPARC V8 and SPARC V9. + * + * The symbol __sparcv8 indicates the 32-bit SPARC V8 architecture as defined + * by Version 8 of the SPARC Architecture Manual. (SPARC V7 is close enough + * to SPARC V8 for the former to be subsumed into the latter definition.) + * + * The symbol __sparcv9 indicates the 64-bit SPARC V9 architecture as defined + * by Version 9 of the SPARC Architecture Manual. + * + * The symbols __sparcv8 and __sparcv9 are mutually exclusive, and are only + * relevant when the symbol __sparc is defined. + */ +/* + * XXX Due to the existence of 5110166, "defined(__sparcv9)" needs to be added + * to support backwards builds. This workaround should be removed in s10_71. + */ +#elif defined(__sparc) || defined(__sparcv9) || defined(__sparc__) +#if !defined(__sparc) +#define __sparc +#endif + +/* + * You can be 32-bit or 64-bit, but not both at the same time. + */ +#if defined(__sparcv8) && defined(__sparcv9) +#error "SPARC Versions 8 and 9 are mutually exclusive choices" +#endif + +/* + * Existing compilers do not set __sparcv8. Years will transpire before + * the compilers can be depended on to set the feature test macro. In + * the interim, we'll set it here on the basis of historical behaviour; + * if you haven't asked for SPARC V9, then you must've meant SPARC V8. + */ +#if !defined(__sparcv9) && !defined(__sparcv8) +#define __sparcv8 +#endif + +/* + * Define the appropriate "processor characteristics" shared between + * all Solaris on SPARC systems. + */ +#define _BIG_ENDIAN +#define _STACK_GROWS_DOWNWARD +#define _LONG_LONG_HTOL +#define _BIT_FIELDS_HTOL +#define _IEEE_754 +#define _CHAR_IS_SIGNED +#define _BOOL_ALIGNMENT 1 +#define _CHAR_ALIGNMENT 1 +#define _SHORT_ALIGNMENT 2 +#define _INT_ALIGNMENT 4 +#define _FLOAT_ALIGNMENT 4 +#define _FLOAT_COMPLEX_ALIGNMENT 4 +#define _LONG_LONG_ALIGNMENT 8 +#define _DOUBLE_ALIGNMENT 8 +#define _DOUBLE_COMPLEX_ALIGNMENT 8 +#define _ALIGNMENT_REQUIRED 1 + +/* + * Define the appropriate "implementation choices" shared between versions. + */ +#define _SUNOS_VTOC_8 +#define _DMA_USES_VIRTADDR +#define _NO_FDISK_PRESENT +#define _HAVE_TEM_FIRMWARE +#define _OBP + +/* + * The following set of definitions characterize the implementation of + * 32-bit Solaris on SPARC V8 systems. + */ +#if defined(__sparcv8) + +/* + * Define the appropriate "processor characteristics" + */ +#define _LONG_ALIGNMENT 4 +#define _LONG_DOUBLE_ALIGNMENT 8 +#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 8 +#define _POINTER_ALIGNMENT 4 +#define _MAX_ALIGNMENT 8 +#define _MAX_ALIGNMENT_TYPE long double + +#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT + +/* + * Define the appropriate "implementation choices" + */ +#if !defined(_ILP32) +#define _ILP32 +#endif + +/* + * The following set of definitions characterize the implementation of + * 64-bit Solaris on SPARC V9 systems. + */ +#elif defined(__sparcv9) + +/* + * Define the appropriate "processor characteristics" + */ +#define _LONG_ALIGNMENT 8 +#define _LONG_DOUBLE_ALIGNMENT 16 +#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 +#define _POINTER_ALIGNMENT 8 +#define _MAX_ALIGNMENT 16 +#define _MAX_ALIGNMENT_TYPE long double + +#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT + +/* + * Define the appropriate "implementation choices" + */ +#if !defined(_LP64) +#define _LP64 +#endif +#define _MULTI_DATAMODEL + +#else +#error "unknown SPARC version" +#endif + +/* + * #error is strictly ansi-C, but works as well as anything for K&R systems. + */ +#else +#error "ISA not supported" +#endif + +#if defined(_ILP32) && defined(_LP64) +#error "Both _ILP32 and _LP64 are defined" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ISA_DEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/iso/signal_iso.h b/illumos-x86_64/usr/include/sys/iso/signal_iso.h new file mode 100644 index 00000000..ecffd944 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/iso/signal_iso.h @@ -0,0 +1,139 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015, Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The contents of this header is limited to identifiers specified in the + * C Standard. Any new identifiers specified in future amendments to the + * C Standard must be placed in this header. If these new identifiers + * are required to also be in the C++ Standard "std" namespace, then for + * anything other than macro definitions, corresponding "using" directives + * must also be added to . + */ + +#ifndef _SYS_SIGNAL_ISO_H +#define _SYS_SIGNAL_ISO_H + +#include /* needed for _SC_SIGRT_MIN/MAX */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SIGHUP 1 /* hangup */ +#define SIGINT 2 /* interrupt (rubout) */ +#define SIGQUIT 3 /* quit (ASCII FS) */ +#define SIGILL 4 /* illegal instruction (not reset when caught) */ +#define SIGTRAP 5 /* trace trap (not reset when caught) */ +#define SIGIOT 6 /* IOT instruction */ +#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ +#define SIGEMT 7 /* EMT instruction */ +#define SIGFPE 8 /* floating point exception */ +#define SIGKILL 9 /* kill (cannot be caught or ignored) */ +#define SIGBUS 10 /* bus error */ +#define SIGSEGV 11 /* segmentation violation */ +#define SIGSYS 12 /* bad argument to system call */ +#define SIGPIPE 13 /* write on a pipe with no one to read it */ +#define SIGALRM 14 /* alarm clock */ +#define SIGTERM 15 /* software termination signal from kill */ +#define SIGUSR1 16 /* user defined signal 1 */ +#define SIGUSR2 17 /* user defined signal 2 */ +#define SIGCLD 18 /* child status change */ +#define SIGCHLD 18 /* child status change alias (POSIX) */ +#define SIGPWR 19 /* power-fail restart */ +#define SIGWINCH 20 /* window size change */ +#define SIGURG 21 /* urgent socket condition */ +#define SIGPOLL 22 /* pollable event occured */ +#define SIGIO SIGPOLL /* socket I/O possible (SIGPOLL alias) */ +#define SIGSTOP 23 /* stop (cannot be caught or ignored) */ +#define SIGTSTP 24 /* user stop requested from tty */ +#define SIGCONT 25 /* stopped process has been continued */ +#define SIGTTIN 26 /* background tty read attempted */ +#define SIGTTOU 27 /* background tty write attempted */ +#define SIGVTALRM 28 /* virtual timer expired */ +#define SIGPROF 29 /* profiling timer expired */ +#define SIGXCPU 30 /* exceeded cpu limit */ +#define SIGXFSZ 31 /* exceeded file size limit */ +#define SIGWAITING 32 /* reserved signal no longer used by threading code */ +#define SIGLWP 33 /* reserved signal no longer used by threading code */ +#define SIGFREEZE 34 /* special signal used by CPR */ +#define SIGTHAW 35 /* special signal used by CPR */ +#define SIGCANCEL 36 /* reserved signal for thread cancellation */ +#define SIGLOST 37 /* resource lost (eg, record-lock lost) */ +#define SIGXRES 38 /* resource control exceeded */ +#define SIGJVM1 39 /* reserved signal for Java Virtual Machine */ +#define SIGJVM2 40 /* reserved signal for Java Virtual Machine */ +#define SIGINFO 41 /* information request */ + +/* insert new signals here, and move _SIGRTM* appropriately */ +#define _SIGRTMIN 42 /* first (highest-priority) realtime signal */ +#define _SIGRTMAX 74 /* last (lowest-priority) realtime signal */ +extern long _sysconf(int); /* System Private interface to sysconf() */ +#define SIGRTMIN ((int)_sysconf(_SC_SIGRT_MIN)) /* first realtime signal */ +#define SIGRTMAX ((int)_sysconf(_SC_SIGRT_MAX)) /* last realtime signal */ + +#if defined(__cplusplus) + +typedef void SIG_FUNC_TYP(int); +typedef SIG_FUNC_TYP *SIG_TYP; +#define SIG_PF SIG_TYP + +#define SIG_DFL (SIG_PF)0 +#define SIG_ERR (SIG_PF)-1 +#define SIG_IGN (SIG_PF)1 +#define SIG_HOLD (SIG_PF)2 + +#elif defined(__lint) + +#define SIG_DFL (void(*)(int))0 +#define SIG_ERR (void(*)(int))0 +#define SIG_IGN (void(*)(int))0 +#define SIG_HOLD (void(*)(int))0 + +#else + +#define SIG_DFL (void(*)(int))0 +#define SIG_ERR (void(*)(int))-1 +#define SIG_IGN (void(*)(int))1 +#define SIG_HOLD (void(*)(int))2 + +#endif + +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SIGNAL_ISO_H */ diff --git a/illumos-x86_64/usr/include/sys/jioctl.h b/illumos-x86_64/usr/include/sys/jioctl.h new file mode 100644 index 00000000..b2f4632d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/jioctl.h @@ -0,0 +1,130 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_JIOCTL_H +#define _SYS_JIOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * jioctl.h + * + * Low level control codes for communication between the host and a + * windowing terminal. See windows.h for additional messages used by + * libwindows. + * + * In case you are wondering what the "j" in jioctl stands for, + * the "j" stands for jerq which was the first windowing terminal. + * The jerq became the Blit which begot the 5620 DMD which begot + * the 615, the 620 and the 630 MTG. + */ + + +/* + * Ioctl requests sent to the xt driver. The types JMPX, JWINSIZE, + * and JTRUN are processed locally by xt. The others involve sending + * a control message to the terminal on channel 0 (the control + * channel). In the control message, the lower bytes of these defines + * are used as the first byte of the control message. + * + * Note that packets sent from the host to the terminal on channels + * other than 0 are implicitly data packets. + */ + +#define JTYPE ('j'<<8) +#define JBOOT (JTYPE|1) /* start a download in a window */ +#define JTERM (JTYPE|2) /* return to default terminal emulator */ +#define JMPX (JTYPE|3) /* currently running layers? */ + +/* + * Timeout in seconds. Not supported by streams xt, but reserve + * this number to avoid confusion. + * #define JTIMO (JTYPE|4) + */ + +#define JWINSIZE (JTYPE|5) /* inquire window size */ +#define JTIMOM (JTYPE|6) /* timeouts in millisecs */ +#define JZOMBOOT (JTYPE|7) /* JBOOT but wait for debugger to run */ +#define JAGENT (JTYPE|9) /* control for both directions */ +#define JTRUN (JTYPE|10) /* send runlayer command to layers cmd */ +#define JXTPROTO (JTYPE|11) /* set xt protocol type */ + +/* + * jwinsize structure used by JWINSIZE message. + */ + +struct jwinsize +{ + char bytesx, bytesy; /* Window size in characters */ + short bitsx, bitsy; /* Window size in bits */ +}; + +/* + * Channel 0 control message format. + */ + +struct jerqmesg +{ + char cmd; /* A control code above */ + char chan; /* Channel it refers to */ +}; + +/* + * The first byte of every xt packet from the terminal to the host + * is one of these control codes. Data packets start with either + * C_SENDCHAR or C_SENDNCHARS. + * + * The usual format is: [command][data] + */ + +#define C_SENDCHAR 1 /* Send character to layer process */ +#define C_NEW 2 /* Create a new layer */ +#define C_UNBLK 3 /* Unblock layer process */ +#define C_DELETE 4 /* Delete layer process group */ +#define C_EXIT 5 /* Exit layers */ +#define C_DEFUNCT 6 /* Send terminate signal to proc. group */ +#define C_SENDNCHARS 7 /* Send several characters to layer proc. */ +#define C_RESHAPE 8 /* Layer has been reshaped */ +#define C_RUN 9 /* Run command in layer (local to xt/layers) */ +#define C_NOFLOW 10 /* Disable network xt flow control */ +#define C_YESFLOW 11 /* Enable network xt flow control */ + +/* + * Format of JAGENT packets. + */ + +struct bagent { + int size; /* size of src string going in and dest string out */ + char * src; /* address of the source byte string */ + char * dest; /* address of the destination byte string */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_JIOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/kbd.h b/illumos-x86_64/usr/include/sys/kbd.h new file mode 100644 index 00000000..c098d7a8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kbd.h @@ -0,0 +1,476 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_KBD_H +#define _SYS_KBD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Following #defines are related to the older keyboards which + * are no longer supported by kb module. The #defines ane left + * for older programs to still compile. + */ +#define KB_KLUNK 0x00 /* Micro Switch 103SD32-2 */ +#define KB_VT100 0x01 /* Keytronics VT100 compatible */ +#define KB_SUN2 0x02 /* Sun-2 custom keyboard */ +#define KB_VT220 0x81 /* Emulation VT220 */ +#define KB_VT220I 0x82 /* International VT220 Emulation */ + +#define NOTPRESENT 0xFF /* Keyboard is not plugged in */ +#define KBD_CMD_LED1 0x04 /* Turn on LED 1 for Sun-2 */ +#define KBD_CMD_NOLED1 0x05 /* Turn off LED 1 for Sun-2 */ +#define KBD_CMD_LED2 0x06 /* Turn on LED 2 for Sun-2 */ +#define KBD_CMD_NOLED2 0x07 /* Turn off LED 2 for Sun-2 */ + +#define CTLSMASK 0x0100 /* Set if ^S was last keyed of ^S, ^Q */ + /* determines which NOSCROLL sends. */ + +#define NOSCROLL 0x303 /* This key alternately sends ^S or ^Q */ +#define CTRLS 0x304 /* This sends ^S and lets NOSCROLL know */ +#define CTRLQ 0x305 /* This sends ^Q and lets NOSCROLL know */ + + +/* + * Following are the only keyboard types supported by kb module. + * (Type 5, Hobo, US101A are also supported but they report + * themselves as Type 4 keyboard with a different layout id.) + */ +#define KB_SUN3 3 /* Type 3 Sun keyboard */ +#define KB_SUN4 4 /* Type 4 Sun keyboard */ +#define KB_USB 6 /* USB keyboard */ +#define KB_PC 101 /* Type 101 AT keyboard */ + +#define KB_ASCII 0x0F /* Ascii terminal masquerading as kbd */ + +/* + * This structure is used to enumerate the supported keyboard types. + * The array of these is terminated by an entry with a NULL table entry. + * The first entry is used if none match. + */ +struct keyboards { + int id; /* Keyboard type, per KIOCTYPE */ + struct keyboard *table; /* Keyboard table to use. */ +}; + +/* + * Various special characters that might show up on the port + */ +#define IDLEKEY 0x7F /* Keyboard is idle; no keys down */ +#define ERRORKEY 0x7E /* Keyboard detected an error */ +#define RESETKEY 0xFF /* Keyboard was just reset */ +#define LAYOUTKEY 0xFE /* Keyboard layout byte follows */ + +#define PRESSED 0x00 /* 0x80 bit off: key was pressed */ +#define RELEASED 0x80 /* 0x80 bit on : key was released */ + +/* + * Commands to the Sun-3 keyboard. + */ +#define KBD_CMD_RESET 0x01 /* Reset keyboard as if power-up */ +#define KBD_CMD_BELL 0x02 /* Turn on the bell */ +#define KBD_CMD_NOBELL 0x03 /* Turn off the bell */ +#define KBD_CMD_CLICK 0x0A /* Turn on the click annunciator */ +#define KBD_CMD_NOCLICK 0x0B /* Turn off the click annunciator */ + +/* + * Commands to the Type 4 keyboard, in addition to those above. + */ +#define KBD_CMD_AUTOTEST 0x0C /* Initiate test sequence */ +#define KBD_CMD_SETLED 0x0E /* Set keyboard LED's */ +#define KBD_CMD_GETLAYOUT 0x0F /* Request that keyboard indicate */ + /* layout */ +/* + * Type 4 keyboard LED masks (used to set LED's) + */ +#define LED_NUM_LOCK 0x1 +#define LED_COMPOSE 0x2 +#define LED_SCROLL_LOCK 0x4 +#define LED_CAPS_LOCK 0x8 +#define LED_KANA 0x10 /* Valid only on Japanese layout */ + +/* + * Software related definitions + */ +/* + * These are the states that the keyboard scanner can be in. + * + * It starts out in NORMAL state. + */ +#define NORMAL 0 /* The usual (ho, hum) */ +#define ABORT1 1 /* Got KEYABORT1 */ +#define COMPOSE1 2 /* Got COMPOSE */ +#define COMPOSE2 3 /* Got COMPOSE plus first key */ +#define FLTACCENT 4 /* Got floating accent key */ +#define NEWABORT1 5 /* Got NEW KEYABORT1 */ + +/* + * Size of ASCII set as used in compose handling. + */ +#define ASCII_SET_SIZE 128 + +/* + * These are how you can have your input translated. + * TR_EVENT means that each keystroke is sent as a firm event. + * TR_UNTRANS_EVENT also sends a firm event for each up / down transition, + * but the value is untranslated: the event id is the key station; the + * value indicates whether the transition was up or down; the value of the + * shift-mask is undefined. + */ +#define TR_NONE 0 +#define TR_ASCII 1 +#define TR_EVENT 2 +#define TR_UNTRANS_EVENT 3 + +/* + * These bits can appear in the result of TR_NONE & TR_UNTRANS_EVENT getkey()s. + */ +#define BUILDKEY(key, state) (key | state) +#define STATEOF(key) ((key) & RELEASED) /* 0 = key down, !=0 = key up */ +#define KEYOF(key) ((key) & ~RELEASED) /* The key number that moved */ +#define NOKEY (-1) /* The argument was 0, and no key was */ + /* depressed. They were all elated. */ + +/* + * "Bucky" bits. These are bits for mode keys. The META bit is ORed into the + * result of TR_ASCII getkey()s, and can be ORed into the result of TR_EVENT + * getkey()s for backwards compatibility. + * (NOKEY can also appear if no keypress was queued up.) + */ +#define METABIT 0 /* Meta key depressed with key */ +#define METAMASK 0x000080 +#define SYSTEMBIT 1 /* Upper left key was down w/key */ +#define SYSTEMMASK 0x000100 +/* other "bucky" bits can be defined at will. See "BUCKYBITS" below. */ + +/* + * This defines the bit positions used within "shiftmask" to + * indicate the "pressed" (1) or "released" (0) state of shift keys. + * Both the bit numbers, and the aggregate masks, are defined. + * + * The "UPMASK" is a minor kludge. Since whether the key is going + * up or down determines the translation table (just as the shift + * keys' positions do), we OR it with "shiftmask" to get "tempmask", + * which is the mask which is actually used to determine the + * translation table to use. Don't reassign 0x0080 for anything + * else, or we'll have to shift and such to squeeze in UPMASK, + * since it comes in from the hardware as 0x80. + */ +#define CAPSLOCK 0 /* Caps Lock key */ +#define CAPSMASK 0x0001 +#define SHIFTLOCK 1 /* Shift Lock key */ +#define LEFTSHIFT 2 /* Left-hand shift key */ +#define RIGHTSHIFT 3 /* Right-hand shift key */ +#define SHIFTMASK 0x000E +#define LEFTCTRL 4 /* Left-hand (or only) control key */ +#define RIGHTCTRL 5 /* Right-hand control key */ +#define CTRLMASK 0x0030 +/* META 6 Meta keys */ +/* META_SHIFT_MASK 0x0040 reserved */ +/* TOP 7 do not use! */ +/* TOPMASK 0x0080 UPMASK in keyboard driver */ +/* CMD 8 reserved */ +/* CMDMASK 0x0100 reserved */ +#define ALTGRAPH 9 /* Alt Graph key */ +#define ALTGRAPHMASK 0x0200 +#define ALT 10 /* Left (or only) Alt key */ +#define LEFTALT 10 /* Left Alt key */ +#define ALTMASK 0x1400 +#define NUMLOCK 11 /* Num Lock key */ +#define NUMLOCKMASK 0x0800 +#define RIGHTALT 12 /* Right Alt key */ +#define UPMASK 0x0080 + +/* + * This defines the format of translation tables. + * + * A translation table is KEYMAP_SIZE "entries", each of which is 2 bytes + * (unsigned shorts). The top 8 bits of each entry are decoded by + * a case statement in getkey.c. If the entry is less than 0x100, it + * is sent out as an EUC character (possibly with bucky bits + * OR-ed in). "Special" entries are 0x100 or greater, and + * invoke more complicated actions. + * + * The KEYMAP_SIZE is dependent upon the keyboard type. For example, the + * Sun Type 4/5 keyboards have a KEYMAP_SIZE of 128 where a USB keyboard + * has a KEYMAP_SIZE of 255. Instead of defining a KEYMAP_SIZE per + * keyboard type, a keyboard specific module/driver may supply the value + * at run time by defining the KEYMAP_SIZE_VARIABLE and filling in the + * keyboard struct appropriately. + */ + +typedef unsigned int keymap_entry_t; +#ifdef KEYMAP_SIZE_VARIABLE + + +#else +#define KEYMAP_SIZE 128 + +struct keymap { + keymap_entry_t keymap[KEYMAP_SIZE]; /* maps keycodes to actions */ +}; + +#endif + +/* + * This structure is used for "exception" cases for key sequences that + * we want to map, that should not be handled by keymap entries (For + * example: using Control-Shift-F1 on PC's for the compose key). + */ +struct exception_map { + /* + * these are the modifier keys that we "care" about + */ + unsigned int exc_care; + + /* + * This is the mask of modifier keys that we want to match + */ + unsigned int exc_mask; + + /* + * This is the key that we want to match. + */ + int exc_key; + + /* + * This is our translated version of the matching sequence. + */ + keymap_entry_t exc_entry; +}; + +/* + * A keyboard is defined by its keymaps and what state it resets at idle. + * + * The masks k_idleshifts and k_idlebuckys are AND-ed with the current + * state of shiftmask and buckybits when a "keyboard idle" code + * is received. This ensures that where we "think" the shift & bucky + * keys are, more accurately reflects where they really are, since the + * keyboard knows better than us. However, some keyboards don't know + * about shift states that should be remembered across idles. Such + * shifts are described by k_toggleshifts. k_toggleshifts are used to + * identify such shifts. A toggle shift state is maintained separately + * from the general shift state. The toggle shift state is OR-ed + * with the state general shift state when an idle is received. + * k_toggleshifts should not appear in the k_up table. + */ +struct keyboard { +#ifdef KEYMAP_SIZE_VARIABLE + int k_keymap_size; /* Number of entries in keymaps */ + keymap_entry_t *k_normal; /* Unshifted */ + keymap_entry_t *k_shifted; /* Shifted */ + keymap_entry_t *k_caps; /* Caps locked */ + keymap_entry_t *k_altgraph; /* Alt Graph down */ + keymap_entry_t *k_numlock; /* Num Lock down */ + keymap_entry_t *k_control; /* Controlled */ + keymap_entry_t *k_up; /* Key went up */ +#else + struct keymap *k_normal; /* Unshifted */ + struct keymap *k_shifted; /* Shifted */ + struct keymap *k_caps; /* Caps locked */ + struct keymap *k_altgraph; /* Alt Graph down */ + struct keymap *k_numlock; /* Num Lock down */ + struct keymap *k_control; /* Controlled */ + struct keymap *k_up; /* Key went up */ +#endif + int k_idleshifts; /* Shifts that keep across idle */ + int k_idlebuckys; /* Bucky bits that keep across idle */ + unsigned char k_abort1; /* 1st key of abort sequence */ + unsigned char k_abort1a; /* alternate 1st key */ + unsigned char k_abort2; /* 2nd key of abort sequence */ + int k_toggleshifts; /* Shifts that toggle on down from */ + /* kbd and keep across idle */ + struct exception_map *k_except; /* Oddball cases */ + unsigned char k_newabort1; /* 1st key of new abort sequence */ + unsigned char k_newabort1a; /* alternate 1st key */ + unsigned char k_newabort2; /* 2nd key of new abort sequence */ +}; + +/* + * Define the compose sequence structure. First and second + * ASCII chars of 0 indicate the end of the table. + */ +struct compose_sequence_t { + unsigned char first; /* first ASCII char after COMPOSE key */ + unsigned char second; /* second ASCII char after COMPOSE key */ + keymap_entry_t utf8; /* equivalent UTF-8 code */ +}; + +/* + * Define the floating accent sequence structure. + */ +struct fltaccent_sequence_t { + keymap_entry_t fa_entry; /* floating accent keymap entry */ + unsigned char ascii; /* ASCII char after FA-type key */ + keymap_entry_t utf8; /* equivalent UTF-8 code */ +}; + +/* + * The top byte is used to store the flags, leaving 24 bits for char. + */ +#define KEYCHAR(c) ((c) & 0x00ffffff) +#define KEYFLAGS(c) ((c) & ~0x00ffffff) + +/* + * The "special" entries' top 4 bits are defined below. Generally they are + * used with a 4-bit parameter (such as a bit number) in the low 4 bits. + * The bytes whose top 4 bits are 0x0 thru 0x7 happen to be ascii + * characters. They are not special cased, but just normal cased. + */ + +#define SPECIAL(h, l) (((h) << 24) | (l)) + +#define SHIFTKEYS SPECIAL(0x1, 0) + /* thru 0x10F. This key helps to determine */ + /* the translation table used. The bit */ + /* position of its bit in "shiftmask" */ + /* is added to the entry, eg */ + /* SHIFTKEYS+LEFTCTRL. When this entry is */ + /* invoked, the bit in "shiftmask" is */ + /* toggled. Depending which tables you put */ + /* it in, this works well for hold-down */ + /* keys or press-on, press-off keys. */ +#define BUCKYBITS SPECIAL(0x2, 0) + /* thru 0x20F. This key determines the state */ + /* of one of the "bucky" bits above the */ + /* returned ASCII character. This is */ + /* basically a way to pass mode-key-up/down */ + /* information back to the caller with each */ + /* "real" key depressed. The concept, and */ + /* name "bucky" (derivation unknown) comes */ + /* from the MIT/SAIL "TV" system...they had */ + /* TOP, META, CTRL, and a few other bucky */ + /* bits. The bit position of its bit in */ + /* "buckybits", minus 7, is added to the */ + /* entry; eg bit 0x00000400 is BUCKYBITS+3. */ + /* The "-7" prevents us from messing up the */ + /* ASCII char, and gives us 16 useful bucky */ + /* bits. When this entry is invoked, */ + /* the designated bit in "buckybits" is */ + /* toggled. Depending which tables you put */ + /* it in, this works well for hold-down */ + /* keys or press-on, press-off keys. */ +#define FUNNY SPECIAL(0x3, 0) /* thru 0x30F. This key does one of 16 funny */ + /* things based on the low 4 bits: */ +#define NOP SPECIAL(0x3, 0x0) /* This key does nothing. */ +#define OOPS SPECIAL(0x3, 0x1) /* This key exists but is undefined. */ +#define HOLE SPECIAL(0x3, 0x2) /* This key does not exist on the keyboard. */ + /* Its position code should never be */ + /* generated. This indicates a software/ */ + /* hardware mismatch, or bugs. */ +#define RESET SPECIAL(0x3, 0x6) /* Kbd was just reset */ +#define ERROR SPECIAL(0x3, 0x7) /* Kbd just detected an internal error */ +#define IDLE SPECIAL(0x3, 0x8) /* Kbd is idle (no keys down) */ +#define COMPOSE SPECIAL(0x3, 0x9) /* This key is the Compose key. */ +#define NONL SPECIAL(0x3, 0xA) /* This key not affected by Num Lock */ +/* Combinations 0x30B to 0x30F are reserved for non-parameterized functions */ + +#define FA_CLASS SPECIAL(0x4, 0) + /* thru 0x40F. These are for "floating */ + /* accent" characters. The low-order 4 bits */ + /* select one of those characters. */ +/* Definitions for the individual floating accents: */ +#define FA_UMLAUT SPECIAL(0x4, 0x0) /* umlaut accent */ +#define FA_CFLEX SPECIAL(0x4, 0x1) /* circumflex accent */ +#define FA_TILDE SPECIAL(0x4, 0x2) /* tilde accent */ +#define FA_CEDILLA SPECIAL(0x4, 0x3) /* cedilla accent */ +#define FA_ACUTE SPECIAL(0x4, 0x4) /* acute accent */ +#define FA_GRAVE SPECIAL(0x4, 0x5) /* grave accent */ +#define FA_MACRON SPECIAL(0x4, 0x6) /* macron accent */ +#define FA_BREVE SPECIAL(0x4, 0x7) /* breve accent */ +#define FA_DOT SPECIAL(0x4, 0x8) /* dot accent */ +#define FA_SLASH SPECIAL(0x4, 0x9) /* slash accent */ +#define FA_RING SPECIAL(0x4, 0xa) /* ring accent */ +#define FA_APOSTROPHE SPECIAL(0x4, 0xb) /* apostrophe accent */ +#define FA_DACUTE SPECIAL(0x4, 0xc) /* double acute accent */ +#define FA_OGONEK SPECIAL(0x4, 0xd) /* ogonek accent */ +#define FA_CARON SPECIAL(0x4, 0xe) /* caron accent */ + +#define STRING SPECIAL(0x5, 0) /* thru 0x50F. The low-order 4 bits index */ + /* a table select a string to be returned, */ + /* char by char. Each entry the table is */ + /* null terminated. */ +#define KTAB_STRLEN 10 /* Maximum string length (including null) */ +/* Definitions for the individual string numbers: */ +#define HOMEARROW 0x00 +#define UPARROW 0x01 +#define DOWNARROW 0x02 +#define LEFTARROW 0x03 +#define RIGHTARROW 0x04 +/* string numbers 5 thru F are available to users making custom entries */ + +/* + * In the following function key groupings, the low-order 4 bits indicate + * the function key number within the group, and the next 4 bits indicate + * the group. + */ +#define FUNCKEYS SPECIAL(0x6, 0) +#define LEFTFUNC SPECIAL(0x6, 0x0) /* thru 0x60F. The "left" group. */ +#define RIGHTFUNC SPECIAL(0x6, 0x10) /* thru 0x61F. The "right" group. */ +#define TOPFUNC SPECIAL(0x6, 0x20) /* thru 0x62F. The "top" group. */ +#define BOTTOMFUNC SPECIAL(0x6, 0x30) /* thru 0x63F. The "bottom" group. */ +#define LF(n) (LEFTFUNC+(n)-1) +#define RF(n) (RIGHTFUNC+(n)-1) +#define TF(n) (TOPFUNC+(n)-1) +#define BF(n) (BOTTOMFUNC+(n)-1) + +/* + * The actual keyboard positions may not be on the left/right/top/bottom + * of the physical keyboard (although they usually are). + * What is important is that we have reserved 64 keys for function keys. + * + * Normally, striking a function key will cause the following escape sequence + * to be sent through the character stream: + * ESC[0..9z + * where ESC is a single escape character and 0..9 indicate some number of + * digits needed to encode the function key as a decimal number. + */ +#define PADKEYS SPECIAL(0x7, 0) +#define PADEQUAL SPECIAL(0x7, 0x00) /* keypad = */ +#define PADSLASH SPECIAL(0x7, 0x01) /* keypad / */ +#define PADSTAR SPECIAL(0x7, 0x02) /* keypad * */ +#define PADMINUS SPECIAL(0x7, 0x03) /* keypad - */ +#define PADSEP SPECIAL(0x7, 0x04) /* keypad, */ +#define PAD7 SPECIAL(0x7, 0x05) /* keypad 7 */ +#define PAD8 SPECIAL(0x7, 0x06) /* keypad 8 */ +#define PAD9 SPECIAL(0x7, 0x07) /* keypad 9 */ +#define PADPLUS SPECIAL(0x7, 0x08) /* keypad + */ +#define PAD4 SPECIAL(0x7, 0x09) /* keypad 4 */ +#define PAD5 SPECIAL(0x7, 0x0A) /* keypad 5 */ +#define PAD6 SPECIAL(0x7, 0x0B) /* keypad 6 */ +#define PAD1 SPECIAL(0x7, 0x0C) /* keypad 1 */ +#define PAD2 SPECIAL(0x7, 0x0D) /* keypad 2 */ +#define PAD3 SPECIAL(0x7, 0x0E) /* keypad 3 */ +#define PAD0 SPECIAL(0x7, 0x0F) /* keypad 0 */ +#define PADDOT SPECIAL(0x7, 0x10) /* keypad . */ +#define PADENTER SPECIAL(0x7, 0x11) /* keypad Enter */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KBD_H */ diff --git a/illumos-x86_64/usr/include/sys/kbdreg.h b/illumos-x86_64/usr/include/sys/kbdreg.h new file mode 100644 index 00000000..2beb4a8d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kbdreg.h @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1985-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_KBDREG_H +#define _SYS_KBDREG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Keyboard implementation private definitions. + */ + +struct keyboardstate { + int k_id; + uchar_t k_idstate; + uchar_t k_state; + uchar_t k_rptkey; + uint_t k_buckybits; + uint_t k_shiftmask; + struct keyboard *k_curkeyboard; + uint_t k_togglemask; /* Toggle shifts state */ +}; + +/* + * States of keyboard ID recognizer + */ +#define KID_NONE 0 /* startup */ +#define KID_GOT_PREFACE 1 /* got id preface */ +#define KID_OK 2 /* locked on ID */ +#define KID_GOT_LAYOUT 3 /* got layout prefix */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KBDREG_H */ diff --git a/illumos-x86_64/usr/include/sys/kbio.h b/illumos-x86_64/usr/include/sys/kbio.h new file mode 100644 index 00000000..b2fa36c4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kbio.h @@ -0,0 +1,250 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_KBIO_H +#define _SYS_KBIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Keyboard related ioctls + */ + +/* + * See sys/kbd.h for TR_NONE (don't translate) and TR_ASCII + * (translate to ASCII) TR_EVENT (translate to virtual input + * device codes) + */ +#define KIOC ('k'<<8) + +#if defined(__i386) || defined(__i386_COMPAT) + +/* + * For x86, these numbers conflict with KD "Xenix" ioctl numbers, so each + * conflicting command has been offset by 30. + */ +#define KIOCTRANS (KIOC|30) /* set keyboard translation */ +#define KIOCGTRANS (KIOC|35) /* get keyboard translation */ +#define KIOCTRANSABLE (KIOC|36) /* set keyboard translatability */ +#define KIOCGTRANSABLE (KIOC|37) /* get keyboard translatability */ + +#else /* __i386 || __i386_COMPAT */ + +#define KIOCTRANS (KIOC|0) /* set keyboard translation */ +#define KIOCGTRANS (KIOC|5) /* get keyboard translation */ +#define KIOCTRANSABLE (KIOC|6) /* set keyboard translatability */ +#define KIOCGTRANSABLE (KIOC|7) /* get keyboard translatability */ + +#endif /* __i386 || __i386_COMPAT */ + + +#define TR_CANNOT 0 /* Cannot translate keyboard using tables */ +#define TR_CAN 1 /* Can translate keyboard using tables */ + +/* + * Old-style keymap entry, for backwards compatibility only. + */ +struct kiockey { + int kio_tablemask; /* Translation table (one of: 0, CAPSMASK, */ + /* SHIFTMASK, CTRLMASK, UPMASK, */ + /* ALTGRAPHMASK, NUMLOCKMASK) */ +#define KIOCABORT1 -1 /* Special "mask": abort1 keystation */ +#define KIOCABORT2 -2 /* Special "mask": abort2 keystation */ +#define KIOCABORT1A -3 /* Special "mask": alt abort1 keystation */ + uchar_t kio_station; /* Physical keyboard key station (0-127) */ + uchar_t kio_entry; /* Translation table station's entry */ + char kio_string[10]; /* Value for STRING entries (null terminated) */ +}; + +/* + * Set kio_tablemask table's kio_station to kio_entry. + * Copy kio_string to string table if kio_entry is between STRING and + * STRING+15. EINVAL is possible if there are invalid arguments. + */ +#if defined(__i386) || defined(__i386_COMPAT) +#define KIOCSETKEY (KIOC|31) /* avoid conflict with "SETFKEY" */ +#else +#define KIOCSETKEY (KIOC|1) +#endif + +/* + * Get kio_tablemask table's kio_station to kio_entry. + * Get kio_string from string table if kio_entry is between STRING and + * STRING+15. EINVAL is possible if there are invalid arguments. + */ +#if defined(__i386) || defined(__i386_COMPAT) +#define KIOCGETKEY (KIOC|32) /* avoid conflict with "GIO_SCRNMAP" */ +#else +#define KIOCGETKEY (KIOC|2) +#endif + +/* + * Send the keyboard device a control command. sys/kbd.h contains + * the constants that define the commands. Normal values are: + * KBD_CMD_BELL, KBD_CMD_NOBELL, KBD_CMD_CLICK, KBD_CMD_NOCLICK. + * Inappropriate commands for particular keyboard types are ignored. + * + * Since there is no reliable way to get the state of the bell or click + * or LED (because we can't query the kdb, and also one could do writes + * to the appropriate serial driver--thus going around this ioctl) + * we don't provide an equivalent state querying ioctl. + */ +#define KIOCCMD (KIOC|8) + +/* + * Get keyboard type. Return values are one of KB_* from sys/kbd.h, + * e.g., KB_KLUNK, KB_VT100, KB_SUN2, KB_SUN3, KB_SUN4, KB_ASCII. + * -1 means that the type is not known. + */ +#define KIOCTYPE (KIOC|9) /* get keyboard type */ + +/* + * Set flag indicating whether keystrokes get routed to /dev/console. + */ +#define KIOCSDIRECT (KIOC|10) + +/* + * Get flag indicating whether keystrokes get routed to /dev/console. + */ +#if defined(__i386) || defined(__i386_COMPAT) +#define KIOCGDIRECT (KIOC|41) /* avoid conflict with "GIO_STRMAP" */ +#else +#define KIOCGDIRECT (KIOC|11) +#endif + +/* + * New-style key map entry. + */ +struct kiockeymap { + int kio_tablemask; /* Translation table (one of: 0, CAPSMASK, */ + /* SHIFTMASK, CTRLMASK, UPMASK, */ + /* ALTGRAPHMASK) */ + uchar_t kio_station; /* Physical keyboard key station (0-127) */ + unsigned kio_entry; /* Translation table station's entry */ + char kio_string[10]; /* Value for STRING entries (null terminated) */ +}; + +/* + * Set kio_tablemask table's kio_station to kio_entry. + * Copy kio_string to string table if kio_entry is between STRING and + * STRING+15. EINVAL is possible if there are invalid arguments. + */ +#if defined(__i386) || defined(__i386_COMPAT) +#define KIOCSKEY (KIOC|42) /* avoid conflict with "PIO_STRMAP" */ +#else +#define KIOCSKEY (KIOC|12) +#endif + +/* + * Get kio_tablemask table's kio_station to kio_entry. + * Get kio_string from string table if kio_entry is between STRING and + * STRING+15. EINVAL is possible if there are invalid arguments. + */ +#define KIOCGKEY (KIOC|13) + +/* + * Set and get LED state. + */ +#define KIOCSLED (KIOC|14) +#define KIOCGLED (KIOC|15) + +/* + * Set and get compatibility mode. + */ +#define KIOCSCOMPAT (KIOC|16) +#define KIOCGCOMPAT (KIOC|17) + +/* + * Set and get keyboard layout. + */ +#define KIOCSLAYOUT (KIOC|19) +#define KIOCLAYOUT (KIOC|20) + +/* + * KIOCSKABORTEN: + * + * Enable/Disable/Alternate Keyboard abort effect (Stop/A, Break or other seq). + * The argument is a pointer to an integer. If the integer is zero, + * keyboard abort is disabled, one will enable keyboard abort (hardware BREAK + * signal), two will revert to the Alternative Break Sequence. NB: This ioctl + * requires root credentials and applies to serial input devices and keyboards. + * When the Alternative Break Sequence is enabled it applies to serial input + * devices ONLY. + */ +#define KIOCSKABORTEN (KIOC|21) + +#define KIOCABORTDISABLE 0 /* Disable Aborts */ +#define KIOCABORTENABLE 1 /* Enable BREAK Signal Aborts */ +#define KIOCABORTALTERNATE 2 /* Enable Alternative Aborts */ + +/* + * Get/Set Keyboard autorepeat delay/rate. + * Use millisecond as unit used by the user-level application + */ +#define KIOCGRPTDELAY (KIOC|22) +#define KIOCSRPTDELAY (KIOC|23) +#define KIOCGRPTRATE (KIOC|24) +#define KIOCSRPTRATE (KIOC|25) + +/* Set keyboard and console beeper frequencies */ +#define KIOCSETFREQ (KIOC|26) + +/* Beeper type for struct freq_request */ +enum fr_beep_type {CONSOLE_BEEP = 1, KBD_BEEP = 2}; + +/* Frequency request structure */ +struct freq_request { + enum fr_beep_type type; /* Beeper type */ + int16_t freq; /* Frequency */ +}; + +#define KIOCMKTONE (KIOC|27) + +/* + * For historical reasons, the frequency argument to KIOCMKTONE is + * in i8254 clock cycles. + */ + +#define PIT_HZ 1193182 /* 8254's cycles per second */ + +#define KDMKTONE KIOCMKTONE + +/* Used to control the AutoRepeat Min-delay and Min-Rate */ +#define KIOCRPTDELAY_MIN (100) +#define KIOCRPTRATE_MIN (1) + +/* + * Get/Set Keyboard autorepeat count. + */ +#define KIOCGRPTCOUNT (KIOC|28) +#define KIOCSRPTCOUNT (KIOC|29) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KBIO_H */ diff --git a/illumos-x86_64/usr/include/sys/kcpc.h b/illumos-x86_64/usr/include/sys/kcpc.h new file mode 100644 index 00000000..9644d019 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kcpc.h @@ -0,0 +1,242 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_KCPC_H +#define _SYS_KCPC_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Kernel clients need this file in order to know what a request is and how to + * program one. + */ + +typedef struct _kcpc_set kcpc_set_t; + +#ifdef _KERNEL + +/* + * Forward declarations. + */ +struct _kthread; +struct cpu; +typedef struct _kcpc_request kcpc_request_t; +struct __pcbe_ops; + +#define KCPC_SET_BOUND 0x0001 /* Used in ks_state */ + +struct _kcpc_set { + int ks_flags; + int ks_nreqs; /* Number of reqs */ + kcpc_request_t *ks_req; /* Pointer to reqs */ + uint64_t *ks_data; /* Data store for this set */ + kcpc_ctx_t *ks_ctx; /* ctx this set belongs to */ + ushort_t ks_state; /* Set is bound or unbound */ + kmutex_t ks_lock; /* Protects ks_state */ + kcondvar_t ks_condv; /* Wait for bind to complete */ +}; + +struct _kcpc_request { + void *kr_config; + int kr_index; /* indx of data for this req */ + int kr_picnum; /* Number of phys pic */ + kcpc_pic_t *kr_picp; /* Ptr to PIC in context */ + uint64_t *kr_data; /* Ptr to virtual 64-bit pic */ + char kr_event[CPC_MAX_EVENT_LEN]; + uint64_t kr_preset; + uint_t kr_flags; + uint_t kr_nattrs; + kcpc_attr_t *kr_attr; + void *kr_ptr; /* Ptr assigned by requester */ +}; + +typedef struct _kcpc_request_list { + kcpc_request_t *krl_list; /* counter event requests */ + int krl_cnt; /* how many requests */ + int krl_max; /* max request entries */ +} kcpc_request_list_t; + +/* + * Type of update function to be called when reading counters on current CPU in + * kcpc_read() + */ +typedef int (*kcpc_update_func_t)(void *, uint64_t); + +/* + * Type of read function to be called when reading counters on current CPU + * (ie. should be same type signature as kcpc_read()) + */ +typedef int (*kcpc_read_func_t)(kcpc_update_func_t); + + +/* + * Initialize the kcpc framework + */ +extern int kcpc_init(void); + +/* + * Bind the set to the indicated thread. + * Returns 0 on success, or an errno in case of error. If EINVAL is returned, + * a specific error code will be returned in the subcode parameter. + */ +extern int kcpc_bind_thread(kcpc_set_t *set, struct _kthread *t, int *subcode); + +/* + * Bind the set to the indicated CPU. + * Same return convention as kcpc_bind_thread(). + */ +extern int kcpc_bind_cpu(kcpc_set_t *set, int cpuid, int *subcode); + +/* + * Request the system to sample the current state of the set into users buf. + */ +extern int kcpc_sample(kcpc_set_t *set, uint64_t *buf, hrtime_t *hrtime, + uint64_t *tick); + +/* + * Create CPC context containing specified list of requested counter events + */ +extern int kcpc_cpu_ctx_create(struct cpu *cp, kcpc_request_list_t *req_list, + int kmem_flags, kcpc_ctx_t ***ctx_ptr_array, size_t *ctx_ptr_array_sz); + +/* + * Returns whether specified counter event is supported + */ +extern boolean_t kcpc_event_supported(char *event); + +/* + * Initialize list of CPC event requests + */ +extern kcpc_request_list_t *kcpc_reqs_init(int nreqs, int kmem_flags); + +/* + * Add counter event request to given list of counter event requests + */ +extern int kcpc_reqs_add(kcpc_request_list_t *req_list, char *event, + uint64_t preset, uint_t flags, uint_t nattrs, kcpc_attr_t *attr, void *ptr, + int kmem_flags); + +/* + * Reset list of CPC event requests so its space can be used for another set + * of requests + */ +extern int kcpc_reqs_reset(kcpc_request_list_t *req_list); + +/* + * Free given list of counter event requests + */ +extern int kcpc_reqs_fini(kcpc_request_list_t *req_list); + +/* + * Read CPC data for given event on current CPU + */ +extern int kcpc_read(kcpc_update_func_t); + +/* + * Program current CPU with given CPC context + */ +extern void kcpc_program(kcpc_ctx_t *ctx, boolean_t for_thread, + boolean_t cu_interpose); + +/* + * Unprogram CPC counters on current CPU + */ +extern void kcpc_unprogram(kcpc_ctx_t *ctx, boolean_t cu_interpose); + +/* + * Unbind a request and release the associated resources. + */ +extern int kcpc_unbind(kcpc_set_t *set); + +/* + * Preset the indicated request's counter and underlying PCBE config to the + * given value. + */ +extern int kcpc_preset(kcpc_set_t *set, int index, uint64_t preset); + +/* + * Unfreeze the set and get it counting again. + */ +extern int kcpc_restart(kcpc_set_t *set); + +extern int kcpc_enable(struct _kthread *t, int cmd, int enable); + +/* + * Mark a thread's CPC context, if it exists, INVALID. + */ +extern void kcpc_invalidate(struct _kthread *t); + +extern int kcpc_overflow_ast(void); +extern uint_t kcpc_hw_overflow_intr(caddr_t, caddr_t); +extern int kcpc_hw_cpu_hook(int cpuid, ulong_t *kcpc_cpumap); +extern int kcpc_hw_lwp_hook(void); +extern void kcpc_idle_ctxop_install(struct _kthread *, struct cpu *); + +extern krwlock_t kcpc_cpuctx_lock; /* lock for 'kcpc_cpuctx' below */ +extern int kcpc_cpuctx; /* number of cpu-specific contexts */ + +extern void kcpc_free_cpu(kcpc_ctx_t *); + +/* + * 'dtrace_cpc_in_use' contains the number of currently active cpc provider + * based enablings. See the block comment in uts/common/os/dtrace_subr.c for + * details of its actual usage. + */ +extern uint32_t dtrace_cpc_in_use; +extern void (*dtrace_cpc_fire)(uint64_t); + +extern void kcpc_free_set(kcpc_set_t *set); + +extern void *kcpc_next_config(void *token, void *current, + uint64_t **data); +extern void kcpc_invalidate_config(void *token); +extern char *kcpc_list_attrs(void); +extern char *kcpc_list_events(uint_t pic); +extern void kcpc_free_configs(kcpc_set_t *set); +extern uint_t kcpc_pcbe_capabilities(void); +extern int kcpc_pcbe_loaded(void); + +/* + * Called by a PCBE to determine if nonprivileged access to counters should be + * allowed. Returns non-zero if non-privileged access is allowed, 0 if not. + */ +extern int kcpc_allow_nonpriv(void *token); + +extern void kcpc_register_pcbe(struct __pcbe_ops *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KCPC_H */ diff --git a/illumos-x86_64/usr/include/sys/kd.h b/illumos-x86_64/usr/include/sys/kd.h new file mode 100644 index 00000000..447e9374 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kd.h @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_KD_H +#define _SYS_KD_H + +/* + * Minimal compatibility support for "kd" ioctls. + * + * This file may be deleted or changed without notice. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define KDIOC ('K'<<8) +#define KDGETMODE (KDIOC|9) /* get text/graphics mode */ +#define KDSETMODE (KDIOC|10) /* set text/graphics mode */ +#define KD_TEXT 0 +#define KD_GRAPHICS 1 +#define KD_RESETTEXT 2 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KD_H */ diff --git a/illumos-x86_64/usr/include/sys/kdi.h b/illumos-x86_64/usr/include/sys/kdi.h new file mode 100644 index 00000000..ab0680bf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kdi.h @@ -0,0 +1,103 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _KDI_H +#define _KDI_H + +#include + +/* + * The Kernel/Debugger interface. + * + * The Debugger -> Kernel portion of the interface is handled by the kdi_t, + * which is defined in the archkdi.h files. These functions are intended to + * be called only when the system is stopped and the debugger is in control. + * + * The Kernel -> Debugger portion is handled by the debugvec_t, which is + * defined here. These functions are used by the kernel to inform the debugger + * of various state changes. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The VA range reserved for the debugger; used by kmdb. + */ +extern const caddr_t kdi_segdebugbase; +extern const size_t kdi_segdebugsize; + +struct cpu; +struct modctl; +struct gate_desc; +struct user_desc; + +typedef struct kdi_debugvec kdi_debugvec_t; +typedef struct kdi kdi_t; + +extern kdi_debugvec_t *kdi_dvec; +extern struct modctl *kdi_dmods; + +#define KDI_VERSION 7 + +extern void kdi_dvec_vmready(void); +extern void kdi_dvec_memavail(void); +#if defined(__sparc) +extern void kdi_dvec_cpu_init(struct cpu *); +extern void kdi_dvec_cpr_restart(void); +#endif +extern void kdi_dvec_modavail(void); +extern void kdi_dvec_thravail(void); +extern void kdi_dvec_mod_loaded(struct modctl *); +extern void kdi_dvec_mod_unloading(struct modctl *); + +/* + * The state machine described below is used to coordinate the efforts of + * kmdb and dtrace. As both use breakpoints, only one may be currently be + * active at a given time. Transitions are possible between the idle state + * and either of the active states, but not directly between the two active + * states. + */ +typedef enum kdi_dtrace_set { + KDI_DTSET_DTRACE_ACTIVATE, + KDI_DTSET_DTRACE_DEACTIVATE, + KDI_DTSET_KMDB_BPT_ACTIVATE, + KDI_DTSET_KMDB_BPT_DEACTIVATE +} kdi_dtrace_set_t; + +typedef enum { + KDI_DTSTATE_DTRACE_ACTIVE, + KDI_DTSTATE_IDLE, + KDI_DTSTATE_KMDB_BPT_ACTIVE +} kdi_dtrace_state_t; + +extern int kdi_dtrace_set(kdi_dtrace_set_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _KDI_H */ diff --git a/illumos-x86_64/usr/include/sys/kdi_impl.h b/illumos-x86_64/usr/include/sys/kdi_impl.h new file mode 100644 index 00000000..e2de9a89 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kdi_impl.h @@ -0,0 +1,162 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _KDI_IMPL_H +#define _KDI_IMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct module; +struct gdscr; + +/* + * The debugvec is used by the kernel to interact with the debugger. + */ +struct kdi_debugvec { + void (*dv_kctl_vmready)(void); + void (*dv_kctl_memavail)(void); + void (*dv_kctl_modavail)(void); + void (*dv_kctl_thravail)(void); + + void (*dv_vmready)(void); + void (*dv_memavail)(caddr_t, size_t); + void (*dv_mod_loaded)(struct modctl *); + void (*dv_mod_unloading)(struct modctl *); + +#if defined(__i386) || defined(__amd64) + void (*dv_handle_fault)(greg_t, greg_t, greg_t, int); +#endif +#if defined(__sparc) + void (*dv_kctl_cpu_init)(void); + void (*dv_cpu_init)(struct cpu *); + void (*dv_cpr_restart)(void); +#endif +}; + +typedef struct kdi_plat { + void (*pkdi_system_claim)(void); + void (*pkdi_system_release)(void); + void (*pkdi_console_claim)(void); + void (*pkdi_console_release)(void); +} kdi_plat_t; + +#define pkdi_system_claim kdi_plat.pkdi_system_claim +#define pkdi_system_release kdi_plat.pkdi_system_release +#define pkdi_console_claim kdi_plat.pkdi_console_claim +#define pkdi_console_release kdi_plat.pkdi_console_release + +/* + * The KDI, or Kernel/Debugger Interface, consists of an ops vector describing + * kernel services that may be directly invoked by the debugger. Unless + * otherwise specified, the functions implementing this ops vector are designed + * to function when the debugger has control of the system - when all other CPUs + * have been stopped. In such an environment, blocking services such as memory + * allocation or synchronization primitives are not available. + */ + +struct kdi { + int kdi_version; + + /* + * Determines whether significant changes (loads or unloads) have + * been made to the modules since the last time this op was invoked. + */ + int (*kdi_mods_changed)(void); + + /* + * Iterates through the current set of modctls, and invokes the + * caller-provided callback on each one. + */ + int (*kdi_mod_iter)(int (*)(struct modctl *, void *), void *); + + /* + * Determines whether or not a given module is loaded. + */ + int (*kdi_mod_isloaded)(struct modctl *); + + /* + * Has anything changed between two versions of the same modctl? + */ + int (*kdi_mod_haschanged)(struct modctl *, struct module *, + struct modctl *, struct module *); + + /* + * Invoked by the debugger when it assumes control of the machine. + */ + void (*kdi_system_claim)(void); + + /* + * Invoked by the debugger when it relinquishes control of the machine. + */ + void (*kdi_system_release)(void); + + int (*kdi_pread)(caddr_t, size_t, uint64_t, size_t *); + int (*kdi_pwrite)(caddr_t, size_t, uint64_t, size_t *); + void (*kdi_flush_caches)(void); + + size_t (*kdi_range_is_nontoxic)(uintptr_t, size_t, int); + + struct cons_polledio *(*kdi_get_polled_io)(void); + + int (*kdi_vtop)(uintptr_t, uint64_t *); + + kdi_dtrace_state_t (*kdi_dtrace_get_state)(void); + int (*kdi_dtrace_set)(kdi_dtrace_set_t); + + void (*kdi_plat_call)(void (*)(void)); + + void (*kdi_kmdb_enter)(void); + + kdi_mach_t kdi_mach; + kdi_plat_t kdi_plat; +}; + +extern void kdi_softcall(void (*)(void)); +extern void kdi_setsoftint(uint64_t); +extern int kdi_pread(caddr_t, size_t, uint64_t, size_t *); +extern int kdi_pwrite(caddr_t, size_t, uint64_t, size_t *); +extern size_t kdi_range_is_nontoxic(uintptr_t, size_t, int); +extern void kdi_flush_caches(void); +extern kdi_dtrace_state_t kdi_dtrace_get_state(void); +extern int kdi_vtop(uintptr_t, uint64_t *); + +extern void cpu_kdi_init(kdi_t *); +extern void mach_kdi_init(kdi_t *); +extern void plat_kdi_init(kdi_t *); + +extern void *boot_kdi_tmpinit(void); +extern void boot_kdi_tmpfini(void *); + +#ifdef __cplusplus +} +#endif + +#endif /* _KDI_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/kdi_machimpl.h b/illumos-x86_64/usr/include/sys/kdi_machimpl.h new file mode 100644 index 00000000..f4d92702 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kdi_machimpl.h @@ -0,0 +1,126 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _SYS_KDI_MACHIMPL_H +#define _SYS_KDI_MACHIMPL_H + +/* + * The Kernel/Debugger interface. The operations provided by the kdi_t, + * defined below, comprise the Debugger -> Kernel portion of the interface, + * and are to be used only when the system has been stopped. + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*kdi_main_t)(kdi_cpusave_t *); + +typedef struct kdi_memrange { + caddr_t mr_base; + caddr_t mr_lim; +} kdi_memrange_t; + +#define KDI_MEMRANGES_MAX 2 + +typedef struct kdi_mach { + void (*mkdi_activate)(kdi_main_t, kdi_cpusave_t *, uint_t); + void (*mkdi_deactivate)(void); + + void (*mkdi_idt_switch)(kdi_cpusave_t *); + + void (*mkdi_update_drreg)(kdi_drreg_t *); + + uintptr_t (*mkdi_get_userlimit)(void); + + int (*mkdi_get_cpuinfo)(uint_t *, uint_t *, uint_t *); + + void (*mkdi_stop_slaves)(int, int); + + void (*mkdi_start_slaves)(void); + + void (*mkdi_slave_wait)(void); + + void (*mkdi_memrange_add)(caddr_t, size_t); + + void (*mkdi_reboot)(void); +} kdi_mach_t; + +#define mkdi_activate kdi_mach.mkdi_activate +#define mkdi_deactivate kdi_mach.mkdi_deactivate +#define mkdi_idt_switch kdi_mach.mkdi_idt_switch +#define mkdi_update_drreg kdi_mach.mkdi_update_drreg +#define mkdi_get_userlimit kdi_mach.mkdi_get_userlimit +#define mkdi_get_cpuinfo kdi_mach.mkdi_get_cpuinfo +#define mkdi_stop_slaves kdi_mach.mkdi_stop_slaves +#define mkdi_start_slaves kdi_mach.mkdi_start_slaves +#define mkdi_slave_wait kdi_mach.mkdi_slave_wait +#define mkdi_memrange_add kdi_mach.mkdi_memrange_add +#define mkdi_reboot kdi_mach.mkdi_reboot + +extern void hat_kdi_init(void); + +extern ulong_t kdi_getdr0(void), kdi_getdr1(void), kdi_getdr2(void); +extern ulong_t kdi_getdr3(void), kdi_getdr6(void), kdi_getdr7(void); +extern void kdi_setdr0(ulong_t), kdi_setdr1(ulong_t), kdi_setdr2(ulong_t); +extern void kdi_setdr3(ulong_t), kdi_setdr6(ulong_t), kdi_setdr7(ulong_t); +extern ulong_t kdi_dreg_get(int); +extern void kdi_dreg_set(int, ulong_t); +extern void kdi_update_drreg(kdi_drreg_t *); +extern void kdi_cpu_debug_init(kdi_cpusave_t *); + +extern void kdi_cpu_init(void); +extern void kdi_xc_others(int, void (*)(void)); +extern void kdi_start_slaves(void); +extern void kdi_slave_wait(void); + +extern void kdi_idtr_set(gate_desc_t *, size_t); +extern void kdi_idt_write(struct gate_desc *, uint_t); +extern void kdi_idt_sync(void); +extern void kdi_idt_switch(kdi_cpusave_t *); +#ifdef __xpv +extern void kdi_idtr_write(desctbr_t *); +#else +#define kdi_idtr_write(idtr) wr_idtr(idtr) +#endif + +extern void kdi_activate(kdi_main_t, kdi_cpusave_t *, uint_t); +extern void kdi_deactivate(void); +extern void kdi_stop_slaves(int, int); +extern void kdi_memrange_add(caddr_t, size_t); +extern void kdi_reboot(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KDI_MACHIMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/kdi_regs.h b/illumos-x86_64/usr/include/sys/kdi_regs.h new file mode 100644 index 00000000..f5d264c2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kdi_regs.h @@ -0,0 +1,113 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _SYS_KDI_REGS_H +#define _SYS_KDI_REGS_H + +#ifndef _ASM +#include +#include +#include +#include +#endif + +#if defined(__amd64) +#include +#elif defined(__i386) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define KDI_NCRUMBS 5 + +#define KDI_CPU_STATE_NONE 0 +#define KDI_CPU_STATE_MASTER 1 +#define KDI_CPU_STATE_SLAVE 2 + +#define KDIREG_DRCTL_WPALLEN_MASK 0x000000ff +#define KDIREG_DRSTAT_RESERVED 0xffff0ff0 +#define KDIREG_DRCTL_RESERVED 0x00000700 + +#ifndef _ASM + +/* + * We maintain a ring buffer of bread crumbs for debugging purposes. The + * current buffer pointer is advanced along the ring with each intercepted + * trap (debugger entry, invalid memory access, fault during step, etc). + */ +typedef struct kdi_crumb { + greg_t krm_cpu_state; /* This CPU's state at last entry */ + greg_t krm_pc; /* Instruction pointer at trap */ + greg_t krm_sp; /* Stack pointer at trap */ + greg_t krm_trapno; /* The last trap number */ + greg_t krm_flag; /* KAIF_CRUMB_F_* */ +} kdi_crumb_t; + +#define KDI_MAXWPIDX 3 + +/* + * Storage for %dr0-3, %dr6, and %dr7. + */ +typedef struct kdi_drreg { + greg_t dr_ctl; + greg_t dr_stat; + greg_t dr_addr[KDI_MAXWPIDX + 1]; +} kdi_drreg_t; + +/* + * Data structure used to hold all of the state for a given CPU. + */ +typedef struct kdi_cpusave { + greg_t *krs_gregs; /* saved registers */ + + kdi_drreg_t krs_dr; /* saved debug registers */ + + user_desc_t *krs_gdt; /* GDT address */ + gate_desc_t *krs_idt; /* IDT address */ + + greg_t krs_cr0; /* saved %cr0 */ + + uint_t krs_cpu_state; /* KDI_CPU_STATE_* mstr/slv */ + uint_t krs_cpu_flushed; /* Have caches been flushed? */ + uint_t krs_cpu_id; /* this CPU's ID */ + + /* Bread crumb ring buffer */ + ulong_t krs_curcrumbidx; /* Current krs_crumbs idx */ + kdi_crumb_t *krs_curcrumb; /* Pointer to current crumb */ + kdi_crumb_t krs_crumbs[KDI_NCRUMBS]; /* Crumbs */ +} kdi_cpusave_t; + +#endif /* !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KDI_REGS_H */ diff --git a/illumos-x86_64/usr/include/sys/kiconv.h b/illumos-x86_64/usr/include/sys/kiconv.h new file mode 100644 index 00000000..46dcb446 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kiconv.h @@ -0,0 +1,165 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_KICONV_H +#define _SYS_KICONV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef _KERNEL + +/* + * Supported fromcode/tocode values are saved in the following component type + * of (name, id) pair. The id values of fromcode and tocode are used to + * find out the corresponding code conversions. + */ +typedef struct { + char *name; + size_t id; +} kiconv_code_list_t; + +/* + * Each unique kiconv code conversion identified by tocode and fromcode ids + * have corresponding module id and internal function pointers to open(), + * kiconv(), close(), and kiconvstr(). + */ +typedef struct { + uint16_t tid; /* tocode id. */ + uint16_t fid; /* fromcode id. */ + uint16_t mid; /* module id. */ + void *(*open)(void); + size_t (*kiconv)(void *, char **, size_t *, char **, size_t *, + int *); + int (*close)(void *); + size_t (*kiconvstr)(char *, size_t *, char *, size_t *, int, + int *); +} kiconv_conv_list_t; + +/* + * Each module id has a corresponding module name that is used to load + * the module as needed and a reference counter. + */ +typedef struct { + char *name; + uint_t refcount; +} kiconv_mod_list_t; + +/* + * The following two data structures are being used to transfer information + * on the supported kiconv code conversions from a module to the framework. + * + * Details can be found from kiconv_ops(9S) and kiconv_module_info(9S) + * man pages at PSARC/2007/173. + */ +typedef struct { + char *tocode; + char *fromcode; + void *(*kiconv_open)(void); + size_t (*kiconv)(void *, char **, size_t *, char **, size_t *, + int *); + int (*kiconv_close)(void *); + size_t (*kiconvstr)(char *, size_t *, char *, size_t *, int, + int *); +} kiconv_ops_t; + +typedef struct kiconv_mod_info { + char *module_name; + size_t kiconv_num_convs; + kiconv_ops_t *kiconv_ops_tbl; + size_t kiconv_num_aliases; + char **aliases; + char **canonicals; + int nowait; +} kiconv_module_info_t; + +/* The kiconv code conversion descriptor data structure. */ +typedef struct { + void *handle; /* Handle from the actual open(). */ + size_t id; /* Index to the conv_list[]. */ +} kiconv_data_t, *kiconv_t; + +/* Common conversion state data structure. */ +typedef struct { + uint8_t id; + uint8_t bom_processed; +} kiconv_state_data_t, *kiconv_state_t; + +/* Common component types for possible code conversion mapping tables. */ +typedef struct { + uchar_t u8[3]; +} kiconv_to_utf8_tbl_comp_t; + +typedef struct { + uint32_t u8:24; + uint32_t sb:8; +} kiconv_to_sb_tbl_comp_t; + +/* + * The maximum name length for any given codeset or alias names; the following + * should be plenty big enough. + */ +#define KICONV_MAX_CODENAME_LEN 63 + +/* The following characters do not exist in the normalized code names. */ +#define KICONV_SKIPPABLE_CHAR(c) \ + ((c) == '-' || (c) == '_' || (c) == '.' || (c) == '@') + +/* + * When we encounter non-identical characters, as like iconv(3C) we have, + * map them into either one of the replacement characters based on what is + * the current target tocde. + * + * The 0xefbfdb in UTF-8 is U+FFFD in Unicode scalar value. + */ +#define KICONV_ASCII_REPLACEMENT_CHAR ('?') +#define KICONV_UTF8_REPLACEMENT_CHAR (0xefbfbd) + +/* Numeric ids for kiconv modules. */ +#define KICONV_EMBEDDED (0) +#define KICONV_MODULE_ID_JA (1) +#define KICONV_MODULE_ID_SC (2) +#define KICONV_MODULE_ID_KO (3) +#define KICONV_MODULE_ID_TC (4) +#define KICONV_MODULE_ID_EMEA (5) + +#define KICONV_MAX_MODULE_ID KICONV_MODULE_ID_EMEA + +/* Functions used in kiconv conversion and module management. */ +extern void kiconv_init(); +extern int kiconv_register_module(kiconv_module_info_t *); +extern int kiconv_unregister_module(kiconv_module_info_t *); +extern size_t kiconv_module_ref_count(size_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KICONV_H */ diff --git a/illumos-x86_64/usr/include/sys/kidmap.h b/illumos-x86_64/usr/include/sys/kidmap.h new file mode 100644 index 00000000..50308330 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kidmap.h @@ -0,0 +1,165 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Windows to Solaris Identity Mapping kernel API + * This header defines an API to map Windows SIDs to + * Solaris UID and GIDs and versa visa. + */ + +#ifndef _SYS_KIDMAP_H +#define _SYS_KIDMAP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Opaque get handle */ +typedef struct idmap_get_handle idmap_get_handle_t; + +/* Return status */ +typedef int32_t idmap_stat; + +/* + * In all the routines a Windows SID is handled as a + * string SID prefix plus a RID. For example + * + * S-1-5-5-12-34-568 will be passed as SID prefix + * S-1-5-5-12-34 and RID 568 + * + * Certain routines returns pointers to a SID prefix string. + * These strings are stored internally and should not be modified + * or freed. + */ + + +/* + * The following routines are simple get ID mapping routines. + */ + + +idmap_stat +kidmap_getuidbysid(zone_t *zone, const char *sid_prefix, uint32_t rid, + uid_t *uid); + +idmap_stat +kidmap_getgidbysid(zone_t *zone, const char *sid_prefix, uint32_t rid, + gid_t *gid); + +idmap_stat +kidmap_getpidbysid(zone_t *zone, const char *sid_prefix, uint32_t rid, + uid_t *pid, int *is_user); + +idmap_stat +kidmap_getsidbyuid(zone_t *zone, uid_t uid, const char **sid_prefix, + uint32_t *rid); + +idmap_stat +kidmap_getsidbygid(zone_t *zone, gid_t gid, const char **sid_prefix, + uint32_t *rid); + + + +/* + * The following routines provide a batch interface for mapping IDs. + */ + +/* + * Create a batch "get mapping" handle for batch mappings. + */ +idmap_get_handle_t * +kidmap_get_create(zone_t *zone); + +/* + * These routines queue the request to the "get mapping" handle + */ + +idmap_stat +kidmap_batch_getuidbysid(idmap_get_handle_t *get_handle, + const char *sid_prefix, uint32_t rid, + uid_t *uid, idmap_stat *stat); + +idmap_stat +kidmap_batch_getgidbysid(idmap_get_handle_t *get_handle, + const char *sid_prefix, uint32_t rid, + gid_t *gid, idmap_stat *stat); + +idmap_stat +kidmap_batch_getpidbysid(idmap_get_handle_t *get_handle, + const char *sid_prefix, uint32_t rid, + uid_t *pid, int *is_user, idmap_stat *stat); + +idmap_stat +kidmap_batch_getsidbyuid(idmap_get_handle_t *get_handle, uid_t uid, + const char **sid_prefix, uint32_t *rid, idmap_stat *stat); + +idmap_stat +kidmap_batch_getsidbygid(idmap_get_handle_t *get_handle, gid_t gid, + const char **sid_prefix, uint32_t *rid, idmap_stat *stat); + +/* + * Process the queued "get mapping" requests. The results (i.e. + * status and identity) will be available in the data areas + * provided by individual requests. + */ +idmap_stat +kidmap_get_mappings(idmap_get_handle_t *get_handle); + +/* + * Destroy the "get mapping" handle + */ +void +kidmap_get_destroy(idmap_get_handle_t *get_handle); + +/* + * Functions that do the hard part of door registration/unregistration + * for the idmap_reg()/idmap_unreg() syscalls + */ +int idmap_reg_dh(zone_t *zone, door_handle_t dh); +int idmap_unreg_dh(zone_t *zone, door_handle_t dh); + +/* + * Function needed by allocids() to ensure only the daemon that owns + * the door gets ephemeral IDS + */ +door_handle_t idmap_get_door(zone_t *zone); + +/* + * Function used by system call allocids() to purge the + * ID mapping cache + */ +void idmap_purge_cache(zone_t *zone); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KIDMAP_H */ diff --git a/illumos-x86_64/usr/include/sys/klpd.h b/illumos-x86_64/usr/include/sys/klpd.h new file mode 100644 index 00000000..32769f43 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/klpd.h @@ -0,0 +1,148 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_KLPD_H +#define _SYS_KLPD_H + +#include +#include +#include + +#ifdef _KERNEL +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define KLPDCALL_VERS 1 + +#define KLPDARG_NOMORE 0 /* End of argument List */ +#define KLPDARG_NONE 0 /* No argument */ +#define KLPDARG_VNODE 1 /* vnode_t * */ +#define KLPDARG_INT 2 /* int */ +#define KLPDARG_PORT 3 /* int, port number */ +#define KLPDARG_TCPPORT 4 /* int, tcp port number */ +#define KLPDARG_UDPPORT 5 /* int, udp port number */ +#define KLPDARG_SCTPPORT 6 /* int, sctp port number */ +#define KLPDARG_SDPPORT 7 /* int, sdp port number */ + +#ifdef _KERNEL + +struct klpd_reg; +struct credklpd; + +int klpd_reg(int, idtype_t, id_t, priv_set_t *); +int klpd_unreg(int, idtype_t, id_t); +void klpd_freelist(struct klpd_reg **); +void klpd_rele(struct klpd_reg *); +int klpd_call(const cred_t *, const priv_set_t *, va_list); +void crklpd_hold(struct credklpd *); +void crklpd_rele(struct credklpd *); +int pfexec_reg(int); +int pfexec_unreg(int); +int pfexec_call(const cred_t *, struct pathname *, cred_t **, boolean_t *); +int get_forced_privs(const cred_t *, const char *, priv_set_t *); +int check_user_privs(const cred_t *, const priv_set_t *); + +#endif /* _KERNEL */ + +typedef struct klpd_head { + uint32_t klh_vers; /* Version */ + uint32_t klh_len; /* Length of full packet */ + uint32_t klh_argoff; /* Offset of argument */ + uint32_t klh_privoff; /* Offset of privilege set */ +} klpd_head_t; + +#define KLH_PRIVSET(kh) ((priv_set_t *)(((kh)->klh_privoff == 0 ? NULL : \ + (char *)(kh) + (kh)->klh_privoff))) +#define KLH_ARG(kh) ((void *)((kh)->klh_argoff != 0 ? \ + (char *)(kh) + (kh)->klh_argoff : NULL)) + +typedef struct klpd_arg { + uint_t kla_type; + uint_t kla_dlen; + union { + char __cdata[1]; + int __idata; + uint_t __uidata; + } kla_data; +} klpd_arg_t; + +#define kla_str kla_data.__cdata +#define kla_int kla_data.__idata +#define kla_uint kla_data.__uidata + +#define PFEXEC_ARG_VERS 0x1 +#define PFEXEC_EXEC_ATTRS 0x1 /* pfexec_reply_t */ +#define PFEXEC_FORCED_PRIVS 0x2 /* priv_set_t */ +#define PFEXEC_USER_PRIVS 0x3 /* uint32_t */ + +#define PFEXEC_ARG_SIZE(bufsize) \ + (offsetof(pfexec_arg_t, pfa_data) + (bufsize)) + +typedef struct pfexec_arg { + uint_t pfa_vers; /* Caller version */ + uint_t pfa_call; /* Call type */ + uint_t pfa_len; /* Length of data */ + uid_t pfa_uid; /* Real uid of subject */ + union { + char __pfa_path[1]; + uint32_t __pfa_buf[1]; + } pfa_data; +} pfexec_arg_t; + +#define pfa_path pfa_data.__pfa_path +#define pfa_buf pfa_data.__pfa_buf + +#define PFEXEC_NOTSET ((uid_t)-1) + +typedef struct pfexec_reply { + uint_t pfr_vers; + uint_t pfr_len; + uid_t pfr_ruid, pfr_euid; + gid_t pfr_rgid, pfr_egid; + boolean_t pfr_setcred; + boolean_t pfr_scrubenv; + boolean_t pfr_clearflag; + boolean_t pfr_allowed; + uint_t pfr_ioff; + uint_t pfr_loff; +} pfexec_reply_t; + +#define PFEXEC_REPLY_IPRIV(pfr) \ + ((pfr)->pfr_ioff ? (priv_set_t *)((char *)(pfr) + (pfr)->pfr_ioff) \ + : (priv_set_t *)0) +#define PFEXEC_REPLY_LPRIV(pfr) \ + ((pfr)->pfr_loff ? (priv_set_t *)((char *)(pfr) + (pfr)->pfr_loff) \ + : (priv_set_t *)0) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KLPD_H */ diff --git a/illumos-x86_64/usr/include/sys/klwp.h b/illumos-x86_64/usr/include/sys/klwp.h new file mode 100644 index 00000000..0ea1a396 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/klwp.h @@ -0,0 +1,228 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _SYS_KLWP_H +#define _SYS_KLWP_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The light-weight process object and the methods by which it + * is accessed. + */ + +#define MAXSYSARGS 8 /* Maximum # of arguments passed to a syscall */ + +/* lwp_eosys values */ +#define NORMALRETURN 0 /* normal return; adjusts PC, registers */ +#define JUSTRETURN 1 /* just return, leave registers alone */ + +/* + * Resource usage, per-lwp plus per-process (sum over defunct lwps). + */ +struct lrusage { + u_longlong_t minflt; /* minor page faults */ + u_longlong_t majflt; /* major page faults */ + u_longlong_t nswap; /* swaps */ + u_longlong_t inblock; /* input blocks */ + u_longlong_t oublock; /* output blocks */ + u_longlong_t msgsnd; /* messages sent */ + u_longlong_t msgrcv; /* messages received */ + u_longlong_t nsignals; /* signals received */ + u_longlong_t nvcsw; /* voluntary context switches */ + u_longlong_t nivcsw; /* involuntary context switches */ + u_longlong_t sysc; /* system calls */ + u_longlong_t ioch; /* chars read and written */ +}; + +typedef struct _klwp *klwp_id_t; + +typedef struct _klwp { + /* + * user-mode context + */ + struct pcb lwp_pcb; /* user regs save pcb */ + uintptr_t lwp_oldcontext; /* previous user context */ + + /* + * system-call interface + */ + long *lwp_ap; /* pointer to arglist */ + int lwp_errno; /* error for current syscall (private) */ + /* + * support for I/O + */ + char lwp_error; /* return error code */ + char lwp_eosys; /* special action on end of syscall */ + char lwp_argsaved; /* are all args in lwp_arg */ + char lwp_watchtrap; /* lwp undergoing watchpoint single-step */ + long lwp_arg[MAXSYSARGS]; /* args to current syscall */ + void *lwp_regs; /* pointer to saved regs on stack */ + void *lwp_fpu; /* pointer to fpu regs */ + label_t lwp_qsav; /* longjmp label for quits and interrupts */ + + /* + * signal handling and debugger (/proc) interface + */ + uchar_t lwp_cursig; /* current signal */ + uchar_t lwp_curflt; /* current fault */ + uchar_t lwp_sysabort; /* if set, abort syscall */ + uchar_t lwp_asleep; /* lwp asleep in syscall */ + uchar_t lwp_extsig; /* cursig sent from another contract */ + stack_t lwp_sigaltstack; /* alternate signal stack */ + struct sigqueue *lwp_curinfo; /* siginfo for current signal */ + k_siginfo_t lwp_siginfo; /* siginfo for stop-on-fault */ + k_sigset_t lwp_sigoldmask; /* for sigsuspend */ + struct lwp_watch { /* used in watchpoint single-stepping */ + caddr_t wpaddr; + size_t wpsize; + int wpcode; + int wpmapped; + greg_t wppc; + } lwp_watch[4]; /* one for each of exec/write/read/read */ + + uint32_t lwp_oweupc; /* profil(2) ticks owed to this lwp */ + + /* + * Microstate accounting. Timestamps are made at the start and the + * end of each microstate (see for state definitions) + * and the corresponding accounting info is updated. The current + * microstate is kept in the thread struct, since there are cases + * when one thread must update another thread's state (a no-no + * for an lwp since it may be swapped/paged out). The rest of the + * microstate stuff is kept here to avoid wasting space on things + * like kernel threads that don't have an associated lwp. + */ + struct mstate { + int ms_prev; /* previous running mstate */ + hrtime_t ms_start; /* lwp creation time */ + hrtime_t ms_term; /* lwp termination time */ + hrtime_t ms_state_start; /* start time of this mstate */ + hrtime_t ms_acct[NMSTATES]; /* per mstate accounting */ + } lwp_mstate; + + /* + * Per-lwp resource usage. + */ + struct lrusage lwp_ru; + + /* + * Things to keep for real-time (SIGPROF) profiling. + */ + int lwp_lastfault; + caddr_t lwp_lastfaddr; + + /* + * timers. Protected by lwp->procp->p_lock + */ + struct itimerval lwp_timer[3]; + + /* + * used to stop/alert lwps + */ + char lwp_unused; + char lwp_state; /* Running in User/Kernel mode (no lock req) */ + ushort_t lwp_nostop; /* Don't stop this lwp (no lock required) */ + ushort_t lwp_pad; /* Reserved for future use */ + + /* + * Last failed privilege. + */ + short lwp_badpriv; + + /* + * linkage + */ + struct _kthread *lwp_thread; + struct proc *lwp_procp; + + size_t lwp_childstksz; /* kernel stksize for this lwp's descendants */ + + uintptr_t lwp_ustack; /* current stack bounds */ + size_t lwp_old_stk_ctl; /* old stack limit */ + + /* + * Contracts + */ + struct ct_template *lwp_ct_active[CTT_MAXTYPE]; /* active templates */ + struct contract *lwp_ct_latest[CTT_MAXTYPE]; /* last created contract */ + + /* + * Branding: + * lwp_brand - per-lwp brand data + * lwp_brand_syscall - brand syscall interposer + */ + void *lwp_brand; + int (*lwp_brand_syscall)(void); + + struct psinfo *lwp_spymaster; /* if an agent LWP, our spymaster */ +} klwp_t; + +/* lwp states */ +#define LWP_USER 0x01 /* Running in user mode */ +#define LWP_SYS 0x02 /* Running in kernel mode */ + +#if defined(_KERNEL) +extern int lwp_default_stksize; +extern int lwp_reapcnt; + +extern struct _kthread *lwp_deathrow; +extern kmutex_t reaplock; +extern struct kmem_cache *lwp_cache; +extern void *segkp_lwp; +extern klwp_t lwp0; + +/* where newly-created lwps normally start */ +extern void lwp_rtt(void); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KLWP_H */ diff --git a/illumos-x86_64/usr/include/sys/kmem.h b/illumos-x86_64/usr/include/sys/kmem.h new file mode 100644 index 00000000..ee51463c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kmem.h @@ -0,0 +1,144 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2022 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_KMEM_H +#define _SYS_KMEM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Kernel memory allocator: DDI interfaces. + * See kmem_alloc(9F) for details. + */ + +#define KM_SLEEP 0x0000 /* can block for memory; success guaranteed */ +#define KM_NOSLEEP 0x0001 /* cannot block for memory; may fail */ +#define KM_PANIC 0x0002 /* if memory cannot be allocated, panic */ +#define KM_PUSHPAGE 0x0004 /* can block for memory; may use reserve */ +#define KM_NORMALPRI 0x0008 /* with KM_NOSLEEP, lower priority allocation */ +#define KM_NOSLEEP_LAZY (KM_NOSLEEP | KM_NORMALPRI) /* Syntactic sugar. */ +#define KM_VMFLAGS 0x00ff /* flags that must match VM_* flags */ + +#define KM_FLAGS 0xffff /* all settable kmem flags */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern void *kmem_alloc(size_t size, int kmflags); +extern void *kmem_zalloc(size_t size, int kmflags); +extern void kmem_free(void *buf, size_t size); +extern void *kmem_alloc_tryhard(size_t size, size_t *alloc_size, int kmflags); +extern void kmem_dump_init(size_t); +extern void kmem_dump_begin(void); +extern size_t kmem_dump_finish(char *buf, size_t size); +extern void *kmem_rezalloc(void *, size_t, size_t, int); + +#endif /* _KERNEL */ + +/* + * Kernel memory allocator: private interfaces. + * These interfaces are still evolving. + * Do not use them in unbundled drivers. + */ + +/* + * Flags for kmem_cache_create() + */ +#define KMC_NOTOUCH 0x00010000 +#define KMC_NODEBUG 0x00020000 +#define KMC_NOMAGAZINE 0x00040000 +#define KMC_NOHASH 0x00080000 +#define KMC_QCACHE 0x00100000 +#define KMC_KMEM_ALLOC 0x00200000 /* internal use only */ +#define KMC_IDENTIFIER 0x00400000 /* internal use only */ +#define KMC_PREFILL 0x00800000 + +struct kmem_cache; /* cache structure is opaque to kmem clients */ + +typedef struct kmem_cache kmem_cache_t; + +/* Client response to kmem move callback */ +typedef enum kmem_cbrc { + KMEM_CBRC_YES, + KMEM_CBRC_NO, + KMEM_CBRC_LATER, + KMEM_CBRC_DONT_NEED, + KMEM_CBRC_DONT_KNOW +} kmem_cbrc_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * Helps clients implementing the move() callback to recognize known objects by + * testing a client-designated pointer member. Takes advantage of the fact that + * any scribbling to freed memory done by kmem is guaranteed to set one of the + * two low order bits. + */ +#define POINTER_IS_VALID(p) (!((uintptr_t)(p) & 0x3)) +#define POINTER_INVALIDATE(pp) (*(pp) = (void *)((uintptr_t)(*(pp)) | 0x1)) + +extern int kmem_ready; +extern pgcnt_t kmem_reapahead; +extern size_t kmem_max_cached; + +extern void kmem_init(void); +extern void kmem_thread_init(void); +extern void kmem_mp_init(void); +extern void kmem_reap(void); +extern void kmem_reap_idspace(void); +extern int kmem_debugging(void); +extern size_t kmem_avail(void); +extern size_t kmem_maxavail(void); + +extern kmem_cache_t *kmem_cache_create(char *, size_t, size_t, + int (*)(void *, void *, int), void (*)(void *, void *), + void (*)(void *), void *, vmem_t *, int); +extern void kmem_cache_set_move(kmem_cache_t *, + kmem_cbrc_t (*)(void *, void *, size_t, void *)); +extern void kmem_cache_destroy(kmem_cache_t *); +extern void *kmem_cache_alloc(kmem_cache_t *, int); +extern void kmem_cache_free(kmem_cache_t *, void *); +extern uint64_t kmem_cache_stat(kmem_cache_t *, char *); +extern boolean_t kmem_cache_reap_active(void); +extern void kmem_cache_reap_soon(kmem_cache_t *); +extern void kmem_cache_move_notify(kmem_cache_t *, void *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KMEM_H */ diff --git a/illumos-x86_64/usr/include/sys/kmem_impl.h b/illumos-x86_64/usr/include/sys/kmem_impl.h new file mode 100644 index 00000000..6a6dc3d9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kmem_impl.h @@ -0,0 +1,462 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _SYS_KMEM_IMPL_H +#define _SYS_KMEM_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * kernel memory allocator: implementation-private data structures + * + * Lock order: + * 1. cache_lock + * 2. cc_lock in order by CPU ID + * 3. cache_depot_lock + * + * Do not call kmem_cache_alloc() or taskq_dispatch() while holding any of the + * above locks. + */ + +#define KMF_AUDIT 0x00000001 /* transaction auditing */ +#define KMF_DEADBEEF 0x00000002 /* deadbeef checking */ +#define KMF_REDZONE 0x00000004 /* redzone checking */ +#define KMF_CONTENTS 0x00000008 /* freed-buffer content logging */ +#define KMF_STICKY 0x00000010 /* if set, override /etc/system */ +#define KMF_NOMAGAZINE 0x00000020 /* disable per-cpu magazines */ +#define KMF_FIREWALL 0x00000040 /* put all bufs before unmapped pages */ +#define KMF_LITE 0x00000100 /* lightweight debugging */ + +#define KMF_HASH 0x00000200 /* cache has hash table */ +#define KMF_RANDOMIZE 0x00000400 /* randomize other kmem_flags */ + +#define KMF_DUMPDIVERT 0x00001000 /* use alternate memory at dump time */ +#define KMF_DUMPUNSAFE 0x00002000 /* flag caches used at dump time */ +#define KMF_PREFILL 0x00004000 /* Prefill the slab when created. */ + +#define KMF_BUFTAG (KMF_DEADBEEF | KMF_REDZONE) +#define KMF_TOUCH (KMF_BUFTAG | KMF_LITE | KMF_CONTENTS) +#define KMF_RANDOM (KMF_TOUCH | KMF_AUDIT | KMF_NOMAGAZINE) +#define KMF_DEBUG (KMF_RANDOM | KMF_FIREWALL) + +#define KMEM_STACK_DEPTH 15 + +#define KMEM_FREE_PATTERN 0xdeadbeefdeadbeefULL +#define KMEM_UNINITIALIZED_PATTERN 0xbaddcafebaddcafeULL +#define KMEM_REDZONE_PATTERN 0xfeedfacefeedfaceULL +#define KMEM_REDZONE_BYTE 0xbb + +/* + * Redzone size encodings for kmem_alloc() / kmem_free(). We encode the + * allocation size, rather than storing it directly, so that kmem_free() + * can distinguish frees of the wrong size from redzone violations. + * + * A size of zero is never valid. + */ +#define KMEM_SIZE_ENCODE(x) (251 * (x) + 1) +#define KMEM_SIZE_DECODE(x) ((x) / 251) +#define KMEM_SIZE_VALID(x) ((x) % 251 == 1 && (x) != 1) + + +#define KMEM_ALIGN 8 /* min guaranteed alignment */ +#define KMEM_ALIGN_SHIFT 3 /* log2(KMEM_ALIGN) */ +#define KMEM_VOID_FRACTION 8 /* never waste more than 1/8 of slab */ + +#define KMEM_SLAB_IS_PARTIAL(sp) \ + ((sp)->slab_refcnt > 0 && (sp)->slab_refcnt < (sp)->slab_chunks) +#define KMEM_SLAB_IS_ALL_USED(sp) \ + ((sp)->slab_refcnt == (sp)->slab_chunks) + +/* + * The bufctl (buffer control) structure keeps some minimal information + * about each buffer: its address, its slab, and its current linkage, + * which is either on the slab's freelist (if the buffer is free), or + * on the cache's buf-to-bufctl hash table (if the buffer is allocated). + * In the case of non-hashed, or "raw", caches (the common case), only + * the freelist linkage is necessary: the buffer address is at a fixed + * offset from the bufctl address, and the slab is at the end of the page. + * + * NOTE: bc_next must be the first field; raw buffers have linkage only. + */ +typedef struct kmem_bufctl { + struct kmem_bufctl *bc_next; /* next bufctl struct */ + void *bc_addr; /* address of buffer */ + struct kmem_slab *bc_slab; /* controlling slab */ +} kmem_bufctl_t; + +/* + * The KMF_AUDIT version of the bufctl structure. The beginning of this + * structure must be identical to the normal bufctl structure so that + * pointers are interchangeable. + */ +typedef struct kmem_bufctl_audit { + struct kmem_bufctl *bc_next; /* next bufctl struct */ + void *bc_addr; /* address of buffer */ + struct kmem_slab *bc_slab; /* controlling slab */ + kmem_cache_t *bc_cache; /* controlling cache */ + hrtime_t bc_timestamp; /* transaction time */ + kthread_t *bc_thread; /* thread doing transaction */ + struct kmem_bufctl *bc_lastlog; /* last log entry */ + void *bc_contents; /* contents at last free */ + int bc_depth; /* stack depth */ + pc_t bc_stack[KMEM_STACK_DEPTH]; /* pc stack */ +} kmem_bufctl_audit_t; + +/* + * A kmem_buftag structure is appended to each buffer whenever any of the + * KMF_BUFTAG flags (KMF_DEADBEEF, KMF_REDZONE, KMF_VERIFY) are set. + */ +typedef struct kmem_buftag { + uint64_t bt_redzone; /* 64-bit redzone pattern */ + kmem_bufctl_t *bt_bufctl; /* bufctl */ + intptr_t bt_bxstat; /* bufctl ^ (alloc/free) */ +} kmem_buftag_t; + +/* + * A variant of the kmem_buftag structure used for KMF_LITE caches. + * Previous callers are stored in reverse chronological order. (i.e. most + * recent first) + */ +typedef struct kmem_buftag_lite { + kmem_buftag_t bt_buftag; /* a normal buftag */ + pc_t bt_history[1]; /* zero or more callers */ +} kmem_buftag_lite_t; + +#define KMEM_BUFTAG_LITE_SIZE(f) \ + (offsetof(kmem_buftag_lite_t, bt_history[f])) + +#define KMEM_BUFTAG(cp, buf) \ + ((kmem_buftag_t *)((char *)(buf) + (cp)->cache_buftag)) + +#define KMEM_BUFCTL(cp, buf) \ + ((kmem_bufctl_t *)((char *)(buf) + (cp)->cache_bufctl)) + +#define KMEM_BUF(cp, bcp) \ + ((void *)((char *)(bcp) - (cp)->cache_bufctl)) + +#define KMEM_SLAB(cp, buf) \ + ((kmem_slab_t *)P2END((uintptr_t)(buf), (cp)->cache_slabsize) - 1) + +/* + * Test for using alternate memory at dump time. + */ +#define KMEM_DUMP(cp) ((cp)->cache_flags & KMF_DUMPDIVERT) +#define KMEM_DUMPCC(ccp) ((ccp)->cc_flags & KMF_DUMPDIVERT) + +/* + * The "CPU" macro loads a cpu_t that refers to the cpu that the current + * thread is running on at the time the macro is executed. A context switch + * may occur immediately after loading this data structure, leaving this + * thread pointing at the cpu_t for the previous cpu. This is not a problem; + * we'd just end up checking the previous cpu's per-cpu cache, and then check + * the other layers of the kmem cache if need be. + * + * It's not even a problem if the old cpu gets DR'ed out during the context + * switch. The cpu-remove DR operation bzero()s the cpu_t, but doesn't free + * it. So the cpu_t's cpu_cache_offset would read as 0, causing us to use + * cpu 0's per-cpu cache. + * + * So, there is no need to disable kernel preemption while using the CPU macro + * below since if we have been context switched, there will not be any + * correctness problem, just a momentary use of a different per-cpu cache. + */ + +#define KMEM_CPU_CACHE(cp) \ + ((kmem_cpu_cache_t *)((char *)(&cp->cache_cpu) + CPU->cpu_cache_offset)) + +#define KMEM_MAGAZINE_VALID(cp, mp) \ + (((kmem_slab_t *)P2END((uintptr_t)(mp), PAGESIZE) - 1)->slab_cache == \ + (cp)->cache_magtype->mt_cache) + +#define KMEM_SLAB_OFFSET(sp, buf) \ + ((size_t)((uintptr_t)(buf) - (uintptr_t)((sp)->slab_base))) + +#define KMEM_SLAB_MEMBER(sp, buf) \ + (KMEM_SLAB_OFFSET(sp, buf) < (sp)->slab_cache->cache_slabsize) + +#define KMEM_BUFTAG_ALLOC 0xa110c8edUL +#define KMEM_BUFTAG_FREE 0xf4eef4eeUL + +/* slab_later_count thresholds */ +#define KMEM_DISBELIEF 3 + +/* slab_flags */ +#define KMEM_SLAB_NOMOVE 0x1 +#define KMEM_SLAB_MOVE_PENDING 0x2 + +typedef struct kmem_slab { + struct kmem_cache *slab_cache; /* controlling cache */ + void *slab_base; /* base of allocated memory */ + avl_node_t slab_link; /* slab linkage */ + struct kmem_bufctl *slab_head; /* first free buffer */ + long slab_refcnt; /* outstanding allocations */ + long slab_chunks; /* chunks (bufs) in this slab */ + uint32_t slab_stuck_offset; /* unmoved buffer offset */ + uint16_t slab_later_count; /* cf KMEM_CBRC_LATER */ + uint16_t slab_flags; /* bits to mark the slab */ +} kmem_slab_t; + +#define KMEM_HASH_INITIAL 64 + +#define KMEM_HASH(cp, buf) \ + ((cp)->cache_hash_table + \ + (((uintptr_t)(buf) >> (cp)->cache_hash_shift) & (cp)->cache_hash_mask)) + +typedef struct kmem_magazine { + void *mag_next; + void *mag_round[1]; /* one or more rounds */ +} kmem_magazine_t; + +/* + * The magazine types for fast per-cpu allocation + */ +typedef struct kmem_magtype { + short mt_magsize; /* magazine size (number of rounds) */ + int mt_align; /* magazine alignment */ + size_t mt_minbuf; /* all smaller buffers qualify */ + size_t mt_maxbuf; /* no larger buffers qualify */ + kmem_cache_t *mt_cache; /* magazine cache */ +} kmem_magtype_t; + +#define KMEM_CPU_CACHE_SIZE 64 /* must be power of 2 */ +#define KMEM_CPU_PAD (KMEM_CPU_CACHE_SIZE - sizeof (kmutex_t) - \ + 2 * sizeof (uint64_t) - 2 * sizeof (void *) - sizeof (int) - \ + 5 * sizeof (short)) +#define KMEM_CACHE_SIZE(ncpus) \ + ((size_t)(&((kmem_cache_t *)0)->cache_cpu[ncpus])) + +/* Offset from kmem_cache->cache_cpu for per cpu caches */ +#define KMEM_CPU_CACHE_OFFSET(cpuid) \ + ((size_t)(&((kmem_cache_t *)0)->cache_cpu[cpuid]) - \ + (size_t)(&((kmem_cache_t *)0)->cache_cpu)) + +typedef struct kmem_cpu_cache { + kmutex_t cc_lock; /* protects this cpu's local cache */ + uint64_t cc_alloc; /* allocations from this cpu */ + uint64_t cc_free; /* frees to this cpu */ + kmem_magazine_t *cc_loaded; /* the currently loaded magazine */ + kmem_magazine_t *cc_ploaded; /* the previously loaded magazine */ + int cc_flags; /* CPU-local copy of cache_flags */ + short cc_rounds; /* number of objects in loaded mag */ + short cc_prounds; /* number of objects in previous mag */ + short cc_magsize; /* number of rounds in a full mag */ + short cc_dump_rounds; /* dump time copy of cc_rounds */ + short cc_dump_prounds; /* dump time copy of cc_prounds */ + char cc_pad[KMEM_CPU_PAD]; /* for nice alignment */ +} kmem_cpu_cache_t; + +/* + * The magazine lists used in the depot. + */ +typedef struct kmem_maglist { + kmem_magazine_t *ml_list; /* magazine list */ + long ml_total; /* number of magazines */ + long ml_min; /* min since last update */ + long ml_reaplimit; /* max reapable magazines */ + uint64_t ml_alloc; /* allocations from this list */ +} kmem_maglist_t; + +typedef struct kmem_defrag { + /* + * Statistics + */ + uint64_t kmd_callbacks; /* move callbacks */ + uint64_t kmd_yes; /* KMEM_CBRC_YES responses */ + uint64_t kmd_no; /* NO responses */ + uint64_t kmd_later; /* LATER responses */ + uint64_t kmd_dont_need; /* DONT_NEED responses */ + uint64_t kmd_dont_know; /* DONT_KNOW responses */ + uint64_t kmd_slabs_freed; /* slabs freed by moves */ + uint64_t kmd_defrags; /* kmem_cache_defrag() */ + uint64_t kmd_scans; /* kmem_cache_scan() */ + + /* + * Consolidator fields + */ + avl_tree_t kmd_moves_pending; /* buffer moves pending */ + list_t kmd_deadlist; /* deferred slab frees */ + size_t kmd_deadcount; /* # of slabs in kmd_deadlist */ + uint8_t kmd_reclaim_numer; /* slab usage threshold */ + uint8_t kmd_pad1; /* compiler padding */ + uint16_t kmd_consolidate; /* triggers consolidator */ + uint32_t kmd_pad2; /* compiler padding */ + size_t kmd_slabs_sought; /* reclaimable slabs sought */ + size_t kmd_slabs_found; /* reclaimable slabs found */ + size_t kmd_tries; /* nth scan interval counter */ + /* + * Fields used to ASSERT that the client does not kmem_cache_free() + * objects passed to the move callback. + */ + void *kmd_from_buf; /* object to move */ + void *kmd_to_buf; /* move destination */ + kthread_t *kmd_thread; /* thread calling move */ +} kmem_defrag_t; + +typedef struct kmem_dump { + void *kd_freelist; /* heap during crash dump */ + uint_t kd_alloc_fails; /* # of allocation failures */ + uint_t kd_unsafe; /* cache was used, but unsafe */ +} kmem_dump_t; + +#define KMEM_CACHE_NAMELEN 31 + +struct kmem_cache { + /* + * Statistics + */ + uint64_t cache_slab_create; /* slab creates */ + uint64_t cache_slab_destroy; /* slab destroys */ + uint64_t cache_slab_alloc; /* slab layer allocations */ + uint64_t cache_slab_free; /* slab layer frees */ + uint64_t cache_alloc_fail; /* total failed allocations */ + uint64_t cache_buftotal; /* total buffers */ + uint64_t cache_bufmax; /* max buffers ever */ + uint64_t cache_bufslab; /* buffers free in slab layer */ + uint64_t cache_reap; /* cache reaps */ + uint64_t cache_rescale; /* hash table rescales */ + uint64_t cache_lookup_depth; /* hash lookup depth */ + uint64_t cache_depot_contention; /* mutex contention count */ + uint64_t cache_depot_contention_prev; /* previous snapshot */ + + /* + * Cache properties + */ + char cache_name[KMEM_CACHE_NAMELEN + 1]; + size_t cache_bufsize; /* object size */ + size_t cache_align; /* object alignment */ + int (*cache_constructor)(void *, void *, int); + void (*cache_destructor)(void *, void *); + void (*cache_reclaim)(void *); + kmem_cbrc_t (*cache_move)(void *, void *, size_t, void *); + void *cache_private; /* opaque arg to callbacks */ + vmem_t *cache_arena; /* vmem source for slabs */ + int cache_cflags; /* cache creation flags */ + int cache_flags; /* various cache state info */ + uint32_t cache_mtbf; /* induced alloc failure rate */ + uint32_t cache_pad1; /* compiler padding */ + kstat_t *cache_kstat; /* exported statistics */ + list_node_t cache_link; /* cache linkage */ + + /* + * Slab layer + */ + kmutex_t cache_lock; /* protects slab layer */ + size_t cache_chunksize; /* buf + alignment [+ debug] */ + size_t cache_slabsize; /* size of a slab */ + size_t cache_maxchunks; /* max buffers per slab */ + size_t cache_bufctl; /* buf-to-bufctl distance */ + size_t cache_buftag; /* buf-to-buftag distance */ + size_t cache_verify; /* bytes to verify */ + size_t cache_contents; /* bytes of saved content */ + size_t cache_color; /* next slab color */ + size_t cache_mincolor; /* maximum slab color */ + size_t cache_maxcolor; /* maximum slab color */ + size_t cache_hash_shift; /* get to interesting bits */ + size_t cache_hash_mask; /* hash table mask */ + list_t cache_complete_slabs; /* completely allocated slabs */ + size_t cache_complete_slab_count; + avl_tree_t cache_partial_slabs; /* partial slab freelist */ + size_t cache_partial_binshift; /* for AVL sort bins */ + kmem_cache_t *cache_bufctl_cache; /* source of bufctls */ + kmem_bufctl_t **cache_hash_table; /* hash table base */ + kmem_defrag_t *cache_defrag; /* slab consolidator fields */ + + /* + * Depot layer + */ + kmutex_t cache_depot_lock; /* protects depot */ + kmem_magtype_t *cache_magtype; /* magazine type */ + kmem_maglist_t cache_full; /* full magazines */ + kmem_maglist_t cache_empty; /* empty magazines */ + kmem_dump_t cache_dump; /* used during crash dump */ + + /* + * Per-CPU layer + */ + kmem_cpu_cache_t cache_cpu[1]; /* max_ncpus actual elements */ +}; + +typedef struct kmem_cpu_log_header { + kmutex_t clh_lock; + char *clh_current; + size_t clh_avail; + int clh_chunk; + int clh_hits; + char clh_pad[64 - sizeof (kmutex_t) - sizeof (char *) - + sizeof (size_t) - 2 * sizeof (int)]; +} kmem_cpu_log_header_t; + +typedef struct kmem_log_header { + kmutex_t lh_lock; + char *lh_base; + int *lh_free; + size_t lh_chunksize; + int lh_nchunks; + int lh_head; + int lh_tail; + int lh_hits; + kmem_cpu_log_header_t lh_cpu[1]; /* ncpus actually allocated */ +} kmem_log_header_t; + +/* kmem_move kmm_flags */ +#define KMM_DESPERATE 0x1 +#define KMM_NOTIFY 0x2 +#define KMM_DEBUG 0x4 + +typedef struct kmem_move { + kmem_slab_t *kmm_from_slab; + void *kmm_from_buf; + void *kmm_to_buf; + avl_node_t kmm_entry; + int kmm_flags; +} kmem_move_t; + +/* + * In order to consolidate partial slabs, it must be possible for the cache to + * have partial slabs. + */ +#define KMEM_IS_MOVABLE(cp) \ + (((cp)->cache_chunksize * 2) <= (cp)->cache_slabsize) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KMEM_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/kobj.h b/illumos-x86_64/usr/include/sys/kobj.h new file mode 100644 index 00000000..1c3e6b2c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kobj.h @@ -0,0 +1,228 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2017 RackTop Systems. + * Copyright (c) 2017 Joyent, Inc. + * Copyright 2025 MNX Cloud, Inc. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_KOBJ_H +#define _SYS_KOBJ_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * List of modules maintained by kobj.c + */ +struct module_list { + struct module_list *next; + struct module *mp; +}; + +typedef struct hotinline_desc { + char *hid_symname; /* symbol name */ + uintptr_t hid_instr_offset; /* offset of call in text */ + struct hotinline_desc *hid_next; /* next hotinline */ +} hotinline_desc_t; + +typedef uint32_t symid_t; /* symbol table index */ +typedef unsigned char *reloc_dest_t; + +typedef void module_mach; + +struct module { + int total_allocated; + + Ehdr hdr; + Elf64_Word shnum; + Elf64_Word phnum; + Elf64_Word shstrndx; + char *shdrs; + Shdr *symhdr, *strhdr; + + char *depends_on; + + size_t symsize; + char *symspace; /* symbols + strings + hashtbl, or NULL */ + int flags; + + size_t text_size; + size_t data_size; + char *text; + char *data; + + unsigned int symtbl_section; + /* pointers into symspace, or NULL */ + char *symtbl; + char *strings; + + unsigned int hashsize; + symid_t *buckets; + symid_t *chains; + + unsigned int nsyms; + + unsigned int bss_align; + size_t bss_size; + uintptr_t bss; + + char *filename; + + struct module_list *head, *tail; + reloc_dest_t destination; + module_mach * machdata; + char *ctfdata; + size_t ctfsize; + + char *fbt_tab; + size_t fbt_size; + size_t fbt_nentries; + caddr_t textwin; + caddr_t textwin_base; + + hotinline_desc_t *hi_calls; + + sdt_probedesc_t *sdt_probes; + size_t sdt_nprobes; + char *sdt_tab; + size_t sdt_size; + + char *sigdata; + size_t sigsize; +}; + +struct kobj_mem { + struct kobj_mem *km_next; + struct kobj_mem *km_prev; + uintptr_t km_addr; + size_t km_size; + uintptr_t km_alloc_addr; + size_t km_alloc_size; +}; + +struct _buf { + intptr_t _fd; + char *_ptr; + char *_base; + char *_name; + char *_dbuf; + int _size; + int _cnt; + int _off; + int _ln; + int _bsize; + int _iscmp; + int _dsize; +}; + + +/* + * Statistical info. + */ +typedef struct { + int nalloc; + int nfree; + int nalloc_calls; + int nfree_calls; +} kobj_stat_t; + +#define kobj_filename(p) ((p)->_name) +#define kobj_linenum(p) ((p)->_ln) +#define kobj_newline(p) ((p)->_ln++) +#define kobj_getc(p) (--(p)->_cnt >= 0 ? ((int)*(p)->_ptr++):kobj_filbuf(p)) +#define kobj_ungetc(p) (++(p)->_cnt > (p)->_size ? -1 : ((int)*(--(p)->_ptr))) +#define kobj_comphdr(p) ((struct comphdr *)(p)->_dbuf) + +/* Offset into buffer */ +#define B_OFFSET(file, off) (off % (file)->_bsize) + +/* Start of page */ +#define F_PAGE(file, off) (off - B_OFFSET(file, off)) + +#define F_BLKS(file, size) ((size / (file)->_bsize) * (file)->_bsize) + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern int kobj_load_module(struct modctl *, int); +extern void kobj_unload_module(struct modctl *); +extern uintptr_t kobj_lookup(struct module *, const char *); +extern Sym *kobj_lookup_all(struct module *, char *, int); +extern int kobj_addrcheck(void *, caddr_t); +extern int kobj_module_to_id(void *); +extern void kobj_getmodinfo(void *, struct modinfo *); +extern int kobj_get_needed(void *, short *, int); +extern uintptr_t kobj_getsymvalue(char *, int); +extern char *kobj_getsymname(uintptr_t, ulong_t *); +extern char *kobj_searchsym(struct module *, uintptr_t, ulong_t *); + +extern int kobj_fstat(intptr_t, struct bootstat *); +extern intptr_t kobj_open(char *); +extern int kobj_path_exists(char *, int); +extern struct _buf *kobj_open_path(char *, int, int); +extern int kobj_read(intptr_t, char *, unsigned int, unsigned int); +extern void kobj_close(intptr_t); +extern void *kobj_alloc(size_t, int); +extern void *kobj_zalloc(size_t, int); +extern void kobj_free(void *, size_t); +extern struct _buf *kobj_open_file(char *); +extern void kobj_close_file(struct _buf *); +extern int kobj_read_file(struct _buf *, char *, unsigned, unsigned); +extern int kobj_get_filesize(struct _buf *, uint64_t *size); +extern uintptr_t kobj_getelfsym(char *, void *, int *); +extern void kobj_set_ctf(struct module *, caddr_t data, size_t size); +extern void do_hotinlines(struct module *); + +extern int kobj_filbuf(struct _buf *); +extern void kobj_sync(void); +#if defined(__i386) || defined(__sparc) || defined(__amd64) +extern void kobj_vmem_init(vmem_t **, vmem_t **); +#else +#error "ISA not supported" +#endif +extern caddr_t kobj_text_alloc(vmem_t *, size_t); +extern caddr_t kobj_texthole_alloc(caddr_t, size_t); +extern void kobj_texthole_free(caddr_t, size_t); +extern void kobj_stat_get(kobj_stat_t *); +extern void kobj_textwin_alloc(struct module *); +extern void kobj_textwin_free(struct module *); +extern void kobj_printf(char *, ...) __KPRINTFLIKE(1); + +#endif /* defined(_KERNEL) || defined(_FAKE_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_KOBJ_H */ diff --git a/illumos-x86_64/usr/include/sys/kobj_impl.h b/illumos-x86_64/usr/include/sys/kobj_impl.h new file mode 100644 index 00000000..10b0724b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kobj_impl.h @@ -0,0 +1,207 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2020 Joyent, Inc. + */ + +/* + * Kernel Run-Time Linker/Loader private interfaces. + */ + +#ifndef _SYS_KOBJ_IMPL_H +#define _SYS_KOBJ_IMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Boot/aux vector attributes. + */ + +#define BA_DYNAMIC 0 +#define BA_PHDR 1 +#define BA_PHNUM 2 +#define BA_PHENT 3 +#define BA_ENTRY 4 +#define BA_PAGESZ 5 +#define BA_LPAGESZ 6 +#define BA_LDELF 7 +#define BA_LDSHDR 8 +#define BA_LDNAME 9 +#define BA_BSS 10 +#define BA_IFLUSH 11 +#define BA_CPU 12 +#define BA_MMU 13 +#define BA_GOTADDR 14 +#define BA_NEXTGOT 15 +#define BA_NUM 16 + +typedef union { + unsigned long ba_val; + void *ba_ptr; +} val_t; + +/* + * Segment info. + */ +struct proginfo { + uint_t size; + uint_t align; +}; + +/* + * Implementation-specific flags. + */ +#define KOBJ_EXEC 0x0004 /* executable (unix module) */ +#define KOBJ_INTERP 0x0008 /* the interpreter module */ +#define KOBJ_PRIM 0x0010 /* a primary kernel module */ +#define KOBJ_RESOLVED 0x0020 /* fully resolved */ +/* 0x0040 unused. */ +#define KOBJ_RELOCATED 0x0080 /* relocation completed */ +#define KOBJ_NOPARENTS 0x0200 /* nothing can depend on this module */ +#define KOBJ_IGNMULDEF 0x0400 /* ignore dups during sym resolution */ +#define KOBJ_NOKSYMS 0x0800 /* module's symbols don't go into ksyms */ +#define KOBJ_EXPORTED 0x1000 /* ctf, syms copied to vmem */ + +/* + * kobj_notify_add() data notification structure + */ +typedef void kobj_notify_f(uint_t, struct modctl *); + +typedef struct kobj_notify_list { + kobj_notify_f *kn_func; /* notification func */ + uint_t kn_type; /* notification type */ + struct kobj_notify_list *kn_prev; + struct kobj_notify_list *kn_next; +} kobj_notify_list_t; + +/* + * krtld can provide notification to external clients on the + * following events. + */ +#define KOBJ_NOTIFY_MODLOADING 1 /* very early in module load */ +#define KOBJ_NOTIFY_MODUNLOADING 2 /* before module unload */ +#define KOBJ_NOTIFY_MODLOADED 3 /* after module load */ +#define KOBJ_NOTIFY_MODUNLOADED 4 /* after module unload */ +#define KOBJ_NOTIFY_MAX 4 + +#define ALIGN(x, a) ((a) == 0 ? (uintptr_t)(x) : \ + (((uintptr_t)(x) + (uintptr_t)(a) - 1l) & ~((uintptr_t)(a) - 1l))) + +#ifdef DEBUG +#define KOBJ_DEBUG +#endif + +#ifdef KOBJ_DEBUG +/* + * Debugging flags. + */ +#define D_DEBUG 0x001 /* general debugging */ +#define D_SYMBOLS 0x002 /* debug symbols */ +#define D_RELOCATIONS 0x004 /* debug relocations */ +#define D_LOADING 0x008 /* section loading */ + +extern int kobj_debug; /* different than moddebug */ +#endif + +/* + * Flags for kobj memory allocation. + */ +#define KM_WAIT 0x0 /* wait for it */ +#define KM_NOWAIT 0x1 /* return immediately */ + +#define KM_TMP 0x1000 /* freed before kobj_init returns */ +#define KM_SCRATCH 0x2000 /* not freed until kobj_sync */ + +#ifdef KOBJ_OVERRIDES +/* + * Until the kernel is fully linked, all code running in the + * context of krtld/kobj using bcopy or bzero must be directed + * to the kobj equivalents. All (ok, most) references to bcopy + * or bzero are thus so vectored. + */ +#define bcopy(s, d, n) kobj_bcopy((s), (d), (n)) +#define bzero(p, n) kobj_bzero((p), (n)) +#define strlcat(s, d, n) kobj_strlcat((s), (d), (n)) +#endif + +extern kdi_t kobj_kdi; + +struct bootops; + +extern struct modctl_list *kobj_linkmaps[]; + +extern char *kobj_kmdb_argv[]; + +extern int kobj_mmu_pagesize; + +extern void kobj_init(void *romvec, void *dvec, + struct bootops *bootvec, val_t *bootaux); +extern int kobj_notify_add(kobj_notify_list_t *); +extern int kobj_notify_remove(kobj_notify_list_t *); +extern int do_relocations(struct module *); +extern int do_relocate(struct module *, char *, int, int, Addr); +extern struct bootops *ops; +extern void exitto(caddr_t); +extern void kobj_sync_instruction_memory(caddr_t, size_t); +extern uint_t kobj_gethashsize(uint_t); +extern void * kobj_mod_alloc(struct module *, size_t, int, reloc_dest_t *); +extern void mach_alloc_funcdesc(struct module *); +extern uint_t kobj_hash_name(const char *); +extern caddr_t kobj_segbrk(caddr_t *, size_t, size_t, caddr_t); +extern int get_progbits_size(struct module *, struct proginfo *, + struct proginfo *, struct proginfo *); +extern Sym *kobj_lookup_kernel(const char *); +extern struct modctl *kobj_boot_mod_lookup(const char *); +extern void kobj_export_module(struct module *); +extern int kobj_load_primary_module(struct modctl *); +extern int boot_compinfo(int, struct compinfo *); +extern void mach_modpath(char *, const char *); + +extern void kobj_setup_standalone_vectors(void); +extern void kobj_restore_vectors(void); +extern void (*_kobj_printf)(void *, const char *fmt, ...) __KPRINTFLIKE(2); +extern void (*_vkobj_printf)(void *, const char *fmt, va_list) + __KVPRINTFLIKE(2); +extern void (*kobj_bcopy)(const void *, void *, size_t); +extern void (*kobj_bzero)(void *, size_t); +extern size_t (*kobj_strlcat)(char *, const char *, size_t); + +#define KOBJ_LM_PRIMARY 0x0 +#define KOBJ_LM_DEBUGGER 0x1 + +extern void kobj_lm_append(int, struct modctl *modp); +extern struct modctl_list *kobj_lm_lookup(int); +extern void kobj_lm_dump(int); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KOBJ_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/ksocket.h b/illumos-x86_64/usr/include/sys/ksocket.h new file mode 100644 index 00000000..165731ed --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ksocket.h @@ -0,0 +1,156 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015, Joyent, Inc. + */ + +#ifndef _SYS_KSOCKET_H_ +#define _SYS_KSOCKET_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Opaque kernel socket type */ +typedef struct __ksocket *ksocket_t; +struct nmsghdr; +struct msgb; /* avoiding sys/stream.h here */ + +/* flag bit for each Callback Event */ +#define KSOCKET_CB_CONNECTED 0x00000001 +#define KSOCKET_CB_CONNECTFAILED 0x00000002 +#define KSOCKET_CB_DISCONNECTED 0x00000004 +#define KSOCKET_CB_NEWDATA 0x00000008 +#define KSOCKET_CB_NEWCONN 0x00000010 +#define KSOCKET_CB_CANSEND 0x00000020 +#define KSOCKET_CB_OOBDATA 0x00000040 +#define KSOCKET_CB_CANTSENDMORE 0x00000080 +#define KSOCKET_CB_CANTRECVMORE 0x00000100 +#define KSOCKET_CB_ERROR 0x00000200 + +/* + * Kernel Socket Callback Events + */ +typedef enum ksocket_event { + KSOCKET_EV_CONNECTED, + KSOCKET_EV_CONNECTFAILED, + KSOCKET_EV_DISCONNECTED, + KSOCKET_EV_OOBDATA, + KSOCKET_EV_NEWDATA, + KSOCKET_EV_NEWCONN, + KSOCKET_EV_CANSEND, + KSOCKET_EV_CANTSENDMORE, + KSOCKET_EV_CANTRECVMORE, + KSOCKET_EV_ERROR +} ksocket_callback_event_t; + +typedef void (*ksocket_callback_t)(ksocket_t, ksocket_callback_event_t, + void *, uintptr_t); + +typedef struct ksocket_callbacks { + uint32_t ksock_cb_flags; + ksocket_callback_t ksock_cb_connected; + ksocket_callback_t ksock_cb_connectfailed; + ksocket_callback_t ksock_cb_disconnected; + ksocket_callback_t ksock_cb_newdata; + ksocket_callback_t ksock_cb_newconn; + ksocket_callback_t ksock_cb_cansend; + ksocket_callback_t ksock_cb_oobdata; + ksocket_callback_t ksock_cb_cantsendmore; + ksocket_callback_t ksock_cb_cantrecvmore; + ksocket_callback_t ksock_cb_error; +} ksocket_callbacks_t; + +#define KSOCKET_SLEEP SOCKET_SLEEP +#define KSOCKET_NOSLEEP SOCKET_NOSLEEP + +extern int ksocket_socket(ksocket_t *, int, int, int, int, struct cred *); +extern int ksocket_bind(ksocket_t, struct sockaddr *, socklen_t, + struct cred *); +extern int ksocket_listen(ksocket_t, int, struct cred *); +extern int ksocket_accept(ksocket_t, struct sockaddr *, socklen_t *, + ksocket_t *, struct cred *); +extern int ksocket_connect(ksocket_t, struct sockaddr *, socklen_t, + struct cred *); +extern int ksocket_send(ksocket_t, void *, size_t, int, size_t *, + struct cred *); +extern int ksocket_sendto(ksocket_t, void *, size_t, int, + struct sockaddr *, socklen_t, size_t *, struct cred *); +extern int ksocket_sendmsg(ksocket_t, struct nmsghdr *, int, size_t *, + struct cred *); +extern int ksocket_sendmblk(ksocket_t, struct nmsghdr *, int, + struct msgb **, struct cred *); +extern int ksocket_recv(ksocket_t, void *, size_t, int, size_t *, + struct cred *); +extern int ksocket_recvfrom(ksocket_t, void *, size_t, int, + struct sockaddr *, socklen_t *, size_t *, struct cred *); +extern int ksocket_recvmsg(ksocket_t, struct nmsghdr *, int, size_t *, + struct cred *); +extern int ksocket_shutdown(ksocket_t, int, struct cred *); +extern int ksocket_setsockopt(ksocket_t, int, int, const void *, int, + struct cred *); +extern int ksocket_getsockopt(ksocket_t, int, int, void *, int *, + struct cred *); +extern int ksocket_getpeername(ksocket_t, struct sockaddr *, socklen_t *, + struct cred *); +extern int ksocket_getsockname(ksocket_t, struct sockaddr *, socklen_t *, + struct cred *); +extern int ksocket_ioctl(ksocket_t, int, intptr_t, int *, struct cred *); +extern int ksocket_spoll(ksocket_t, int, short, short *, struct cred *); +extern int ksocket_setcallbacks(ksocket_t, ksocket_callbacks_t *, void *, + struct cred *); +extern int ksocket_close(ksocket_t, struct cred *); +extern void ksocket_hold(ksocket_t); +extern void ksocket_rele(ksocket_t); + +/* + * These functions allow an alternative way for a ksocket to directly + * receive data when it arrives in sockfs rather than having it queued + * in a socket buffer that it must separately poll. The use of this + * results in no data being queued in sockfs. + * + * When the receive function receives data, it is responsible for always + * consuming all of the data. The return value of the callback function + * is used to indicate flow control and backpressure (similar to + * mc_tx(9E)). If, after processing the data, additional data can be + * received and processed, then the callback function should return + * B_TRUE. Otherwise it should return B_FALSE. This will result in the + * lower level socket interfaces (e.g. TCP) understanding that + * backpressure has been asserted (as though the sockfs buffer is full). + * + * Once whatever conditions that caused the callback function to assert + * that it needed to assert flow control are done, then it must call + * ksocket_krecv_unblock() to allow the flow to continue. If the receive + * callback ever returns B_FALSE there will generally be no additional + * data received until this is called. + */ +typedef boolean_t (*ksocket_krecv_f)(ksocket_t, struct msgb *, size_t, int, + void *); +extern int ksocket_krecv_set(ksocket_t, ksocket_krecv_f, void *); +extern void ksocket_krecv_unblock(ksocket_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KSOCKET_H_ */ diff --git a/illumos-x86_64/usr/include/sys/kstat.h b/illumos-x86_64/usr/include/sys/kstat.h new file mode 100644 index 00000000..678021a1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kstat.h @@ -0,0 +1,828 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_KSTAT_H +#define _SYS_KSTAT_H + +/* + * Definition of general kernel statistics structures and /dev/kstat ioctls + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int kid_t; /* unique kstat id */ + +/* + * Kernel statistics driver (/dev/kstat) ioctls + */ + +#define KSTAT_IOC_BASE ('K' << 8) + +#define KSTAT_IOC_CHAIN_ID KSTAT_IOC_BASE | 0x01 +#define KSTAT_IOC_READ KSTAT_IOC_BASE | 0x02 +#define KSTAT_IOC_WRITE KSTAT_IOC_BASE | 0x03 + +/* + * /dev/kstat ioctl usage (kd denotes /dev/kstat descriptor): + * + * kcid = ioctl(kd, KSTAT_IOC_CHAIN_ID, NULL); + * kcid = ioctl(kd, KSTAT_IOC_READ, kstat_t *); + * kcid = ioctl(kd, KSTAT_IOC_WRITE, kstat_t *); + */ + +#define KSTAT_STRLEN 31 /* 30 chars + NULL; must be 16 * n - 1 */ + +/* + * The generic kstat header + */ + +typedef struct kstat { + /* + * Fields relevant to both kernel and user + */ + hrtime_t ks_crtime; /* creation time (from gethrtime()) */ + struct kstat *ks_next; /* kstat chain linkage */ + kid_t ks_kid; /* unique kstat ID */ + char ks_module[KSTAT_STRLEN]; /* provider module name */ + uchar_t ks_resv; /* reserved, currently just padding */ + int ks_instance; /* provider module's instance */ + char ks_name[KSTAT_STRLEN]; /* kstat name */ + uchar_t ks_type; /* kstat data type */ + char ks_class[KSTAT_STRLEN]; /* kstat class */ + uchar_t ks_flags; /* kstat flags */ + void *ks_data; /* kstat type-specific data */ + uint_t ks_ndata; /* # of type-specific data records */ + size_t ks_data_size; /* total size of kstat data section */ + hrtime_t ks_snaptime; /* time of last data shapshot */ + /* + * Fields relevant to kernel only + */ + int (*ks_update)(struct kstat *, int); /* dynamic update */ + void *ks_private; /* arbitrary provider-private data */ + int (*ks_snapshot)(struct kstat *, void *, int); + void *ks_lock; /* protects this kstat's data */ +} kstat_t; + +#ifdef _SYSCALL32 + +typedef int32_t kid32_t; + +typedef struct kstat32 { + /* + * Fields relevant to both kernel and user + */ + hrtime_t ks_crtime; + caddr32_t ks_next; /* struct kstat pointer */ + kid32_t ks_kid; + char ks_module[KSTAT_STRLEN]; + uint8_t ks_resv; + int32_t ks_instance; + char ks_name[KSTAT_STRLEN]; + uint8_t ks_type; + char ks_class[KSTAT_STRLEN]; + uint8_t ks_flags; + caddr32_t ks_data; /* type-specific data */ + uint32_t ks_ndata; + size32_t ks_data_size; + hrtime_t ks_snaptime; + /* + * Fields relevant to kernel only (only needed here for padding) + */ + int32_t _ks_update; + caddr32_t _ks_private; + int32_t _ks_snapshot; + caddr32_t _ks_lock; +} kstat32_t; + +#endif /* _SYSCALL32 */ + +/* + * kstat structure and locking strategy + * + * Each kstat consists of a header section (a kstat_t) and a data section. + * The system maintains a set of kstats, protected by kstat_chain_lock. + * kstat_chain_lock protects all additions to/deletions from this set, + * as well as all changes to kstat headers. kstat data sections are + * *optionally* protected by the per-kstat ks_lock. If ks_lock is non-NULL, + * kstat clients (e.g. /dev/kstat) will acquire this lock for all of their + * operations on that kstat. It is up to the kstat provider to decide whether + * guaranteeing consistent data to kstat clients is sufficiently important + * to justify the locking cost. Note, however, that most statistic updates + * already occur under one of the provider's mutexes, so if the provider sets + * ks_lock to point to that mutex, then kstat data locking is free. + * + * NOTE: variable-size kstats MUST employ kstat data locking, to prevent + * data-size races with kstat clients. + * + * NOTE: ks_lock is really of type (kmutex_t *); it is declared as (void *) + * in the kstat header so that users don't have to be exposed to all of the + * kernel's lock-related data structures. + */ + +#if defined(_KERNEL) + +#define KSTAT_ENTER(k) \ + { kmutex_t *lp = (k)->ks_lock; if (lp) mutex_enter(lp); } + +#define KSTAT_EXIT(k) \ + { kmutex_t *lp = (k)->ks_lock; if (lp) mutex_exit(lp); } + +#define KSTAT_UPDATE(k, rw) (*(k)->ks_update)((k), (rw)) + +#define KSTAT_SNAPSHOT(k, buf, rw) (*(k)->ks_snapshot)((k), (buf), (rw)) + +#endif /* defined(_KERNEL) */ + +/* + * kstat time + * + * All times associated with kstats (e.g. creation time, snapshot time, + * kstat_timer_t and kstat_io_t timestamps, etc.) are 64-bit nanosecond values, + * as returned by gethrtime(). The accuracy of these timestamps is machine + * dependent, but the precision (units) is the same across all platforms. + */ + +/* + * kstat identity (KID) + * + * Each kstat is assigned a unique KID (kstat ID) when it is added to the + * global kstat chain. The KID is used as a cookie by /dev/kstat to + * request information about the corresponding kstat. There is also + * an identity associated with the entire kstat chain, kstat_chain_id, + * which is bumped each time a kstat is added or deleted. /dev/kstat uses + * the chain ID to detect changes in the kstat chain (e.g., a new disk + * coming online) between ioctl()s. + */ + +/* + * kstat module, kstat instance + * + * ks_module and ks_instance contain the name and instance of the module + * that created the kstat. In cases where there can only be one instance, + * ks_instance is 0. The kernel proper (/kernel/unix) uses "unix" as its + * module name. + */ + +/* + * kstat name + * + * ks_name gives a meaningful name to a kstat. The full kstat namespace + * is module.instance.name, so the name only need be unique within a + * module. kstat_create() will fail if you try to create a kstat with + * an already-used (ks_module, ks_instance, ks_name) triplet. Spaces are + * allowed in kstat names, but strongly discouraged, since they hinder + * awk-style processing at user level. + */ + +/* + * kstat type + * + * The kstat mechanism provides several flavors of kstat data, defined + * below. The "raw" kstat type is just treated as an array of bytes; you + * can use this to export any kind of data you want. + * + * Some kstat types allow multiple data structures per kstat, e.g. + * KSTAT_TYPE_NAMED; others do not. This is part of the spec for each + * kstat data type. + * + * User-level tools should *not* rely on the #define KSTAT_NUM_TYPES. To + * get this information, read out the standard system kstat "kstat_types". + */ + +#define KSTAT_TYPE_RAW 0 /* can be anything */ + /* ks_ndata >= 1 */ +#define KSTAT_TYPE_NAMED 1 /* name/value pair */ + /* ks_ndata >= 1 */ +#define KSTAT_TYPE_INTR 2 /* interrupt statistics */ + /* ks_ndata == 1 */ +#define KSTAT_TYPE_IO 3 /* I/O statistics */ + /* ks_ndata == 1 */ +#define KSTAT_TYPE_TIMER 4 /* event timer */ + /* ks_ndata >= 1 */ + +#define KSTAT_NUM_TYPES 5 + +/* + * kstat class + * + * Each kstat can be characterized as belonging to some broad class + * of statistics, e.g. disk, tape, net, vm, streams, etc. This field + * can be used as a filter to extract related kstats. The following + * values are currently in use: disk, tape, net, controller, vm, kvm, + * hat, streams, kstat, and misc. (The kstat class encompasses things + * like kstat_types.) + */ + +/* + * kstat flags + * + * Any of the following flags may be passed to kstat_create(). They are + * all zero by default. + * + * KSTAT_FLAG_VIRTUAL: + * + * Tells kstat_create() not to allocate memory for the + * kstat data section; instead, you will set the ks_data + * field to point to the data you wish to export. This + * provides a convenient way to export existing data + * structures. + * + * KSTAT_FLAG_VAR_SIZE: + * + * The size of the kstat you are creating will vary over time. + * For example, you may want to use the kstat mechanism to + * export a linked list. NOTE: The kstat framework does not + * manage the data section, so all variable-size kstats must be + * virtual kstats. Moreover, variable-size kstats MUST employ + * kstat data locking to prevent data-size races with kstat + * clients. See the section on "kstat snapshot" for details. + * + * KSTAT_FLAG_WRITABLE: + * + * Makes the kstat's data section writable by root. + * The ks_snapshot routine (see below) does not need to check for + * this; permission checking is handled in the kstat driver. + * + * KSTAT_FLAG_PERSISTENT: + * + * Indicates that this kstat is to be persistent over time. + * For persistent kstats, kstat_delete() simply marks the + * kstat as dormant; a subsequent kstat_create() reactivates + * the kstat. This feature is provided so that statistics + * are not lost across driver close/open (e.g., raw disk I/O + * on a disk with no mounted partitions.) + * NOTE: Persistent kstats cannot be virtual, since ks_data + * points to garbage as soon as the driver goes away. + * + * The following flags are maintained by the kstat framework: + * + * KSTAT_FLAG_DORMANT: + * + * For persistent kstats, indicates that the kstat is in the + * dormant state (e.g., the corresponding device is closed). + * + * KSTAT_FLAG_INVALID: + * + * This flag is set when a kstat is in a transitional state, + * e.g. between kstat_create() and kstat_install(). + * kstat clients must not attempt to access the kstat's data + * if this flag is set. + * + * KSTAT_FLAG_LONGSTRINGS: + * + * Indicates that this kstat contains long strings (which + * are stored outside of the kstat data section). When copied + * out to user space the string data will be held in the data + * section provided by the user. + */ + +#define KSTAT_FLAG_VIRTUAL 0x01 +#define KSTAT_FLAG_VAR_SIZE 0x02 +#define KSTAT_FLAG_WRITABLE 0x04 +#define KSTAT_FLAG_PERSISTENT 0x08 +#define KSTAT_FLAG_DORMANT 0x10 +#define KSTAT_FLAG_INVALID 0x20 +#define KSTAT_FLAG_LONGSTRINGS 0x40 + +/* + * Dynamic update support + * + * The kstat mechanism allows for an optional ks_update function to update + * kstat data. This is useful for drivers where the underlying device + * keeps cheap hardware stats, but extraction is expensive. Instead of + * constantly keeping the kstat data section up to date, you can supply a + * ks_update function which updates the kstat's data section on demand. + * To take advantage of this feature, simply set the ks_update field before + * calling kstat_install(). + * + * The ks_update function, if supplied, must have the following structure: + * + * int + * foo_kstat_update(kstat_t *ksp, int rw) + * { + * if (rw == KSTAT_WRITE) { + * ... update the native stats from ksp->ks_data; + * return EACCES if you don't support this + * } else { + * ... update ksp->ks_data from the native stats + * } + * } + * + * The ks_update return codes are: 0 for success, EACCES if you don't allow + * KSTAT_WRITE, and EIO for any other type of error. + * + * In general, the ks_update function may need to refer to provider-private + * data; for example, it may need a pointer to the provider's raw statistics. + * The ks_private field is available for this purpose. Its use is entirely + * at the provider's discretion. + * + * All variable-size kstats MUST supply a ks_update routine, which computes + * and sets ks_data_size (and ks_ndata if that is meaningful), since these + * are needed to perform kstat snapshots (see below). + * + * No kstat locking should be done inside the ks_update routine. The caller + * will already be holding the kstat's ks_lock (to ensure consistent data). + */ + +#define KSTAT_READ 0 +#define KSTAT_WRITE 1 + +/* + * Kstat snapshot + * + * In order to get a consistent view of a kstat's data, clients must obey + * the kstat's locking strategy. However, these clients may need to perform + * operations on the data which could cause a fault (e.g. copyout()), or + * operations which are simply expensive. Doing so could cause deadlock + * (e.g. if you're holding a disk's kstat lock which is ultimately required + * to resolve a copyout() fault), performance degradation (since the providers' + * activity is serialized at the kstat lock), device timing problems, etc. + * + * To avoid these problems, kstat data is provided via snapshots. Taking + * a snapshot is a simple process: allocate a wired-down kernel buffer, + * acquire the kstat's data lock, copy the data into the buffer ("take the + * snapshot"), and release the lock. This ensures that the kstat's data lock + * will be held as briefly as possible, and that no faults will occur while + * the lock is held. + * + * Normally, the snapshot is taken by default_kstat_snapshot(), which + * timestamps the data (sets ks_snaptime), copies it, and does a little + * massaging to deal with incomplete transactions on i/o kstats. However, + * this routine only works for kstats with contiguous data (the typical case). + * If you create a kstat whose data is, say, a linked list, you must provide + * your own ks_snapshot routine. The routine you supply must have the + * following prototype (replace "foo" with something appropriate): + * + * int foo_kstat_snapshot(kstat_t *ksp, void *buf, int rw); + * + * The minimal snapshot routine -- one which copies contiguous data that + * doesn't need any massaging -- would be this: + * + * ksp->ks_snaptime = gethrtime(); + * if (rw == KSTAT_WRITE) + * bcopy(buf, ksp->ks_data, ksp->ks_data_size); + * else + * bcopy(ksp->ks_data, buf, ksp->ks_data_size); + * return (0); + * + * A more illuminating example is taking a snapshot of a linked list: + * + * ksp->ks_snaptime = gethrtime(); + * if (rw == KSTAT_WRITE) + * return (EACCES); ... See below ... + * for (foo = first_foo; foo; foo = foo->next) { + * bcopy((char *) foo, (char *) buf, sizeof (struct foo)); + * buf = ((struct foo *) buf) + 1; + * } + * return (0); + * + * In the example above, we have decided that we don't want to allow + * KSTAT_WRITE access, so we return EACCES if this is attempted. + * + * The key points are: + * + * (1) ks_snaptime must be set (via gethrtime()) to timestamp the data. + * (2) Data gets copied from the kstat to the buffer on KSTAT_READ, + * and from the buffer to the kstat on KSTAT_WRITE. + * (3) ks_snapshot return values are: 0 for success, EACCES if you + * don't allow KSTAT_WRITE, and EIO for any other type of error. + * + * Named kstats (see section on "Named statistics" below) containing long + * strings (KSTAT_DATA_STRING) need special handling. The kstat driver + * assumes that all strings are copied into the buffer after the array of + * named kstats, and the pointers (KSTAT_NAMED_STR_PTR()) are updated to point + * into the copy within the buffer. The default snapshot routine does this, + * but overriding routines should contain at least the following: + * + * if (rw == KSTAT_READ) { + * kstat_named_t *knp = buf; + * char *end = knp + ksp->ks_ndata; + * uint_t i; + * + * ... Do the regular copy ... + * bcopy(ksp->ks_data, buf, sizeof (kstat_named_t) * ksp->ks_ndata); + * + * for (i = 0; i < ksp->ks_ndata; i++, knp++) { + * if (knp[i].data_type == KSTAT_DATA_STRING && + * KSTAT_NAMED_STR_PTR(knp) != NULL) { + * bcopy(KSTAT_NAMED_STR_PTR(knp), end, + * KSTAT_NAMED_STR_BUFLEN(knp)); + * KSTAT_NAMED_STR_PTR(knp) = end; + * end += KSTAT_NAMED_STR_BUFLEN(knp); + * } + * } + */ + +/* + * Named statistics. + * + * List of arbitrary name=value statistics. + */ + +typedef struct kstat_named { + char name[KSTAT_STRLEN]; /* name of counter */ + uchar_t data_type; /* data type */ + union { + char c[16]; /* enough for 128-bit ints */ + int32_t i32; + uint32_t ui32; + struct { + union { + char *ptr; /* NULL-term string */ +#if defined(_KERNEL) && defined(_MULTI_DATAMODEL) + caddr32_t ptr32; +#endif + char __pad[8]; /* 64-bit padding */ + } addr; + uint32_t len; /* # bytes for strlen + '\0' */ + } str; +/* + * The int64_t and uint64_t types are not valid for a maximally conformant + * 32-bit compilation environment (cc -Xc) using compilers prior to the + * introduction of C99 conforming compiler (reference ISO/IEC 9899:1990). + * In these cases, the visibility of i64 and ui64 is only permitted for + * 64-bit compilation environments or 32-bit non-maximally conformant + * C89 or C90 ANSI C compilation environments (cc -Xt and cc -Xa). In the + * C99 ANSI C compilation environment, the long long type is supported. + * The _INT64_TYPE is defined by the implementation (see sys/int_types.h). + */ +#if defined(_INT64_TYPE) + int64_t i64; + uint64_t ui64; +#endif + long l; + ulong_t ul; + + /* These structure members are obsolete */ + + longlong_t ll; + u_longlong_t ull; + float f; + double d; + } value; /* value of counter */ +} kstat_named_t; + +#define KSTAT_DATA_CHAR 0 +#define KSTAT_DATA_INT32 1 +#define KSTAT_DATA_UINT32 2 +#define KSTAT_DATA_INT64 3 +#define KSTAT_DATA_UINT64 4 + +#if !defined(_LP64) +#define KSTAT_DATA_LONG KSTAT_DATA_INT32 +#define KSTAT_DATA_ULONG KSTAT_DATA_UINT32 +#else +#if !defined(_KERNEL) +#define KSTAT_DATA_LONG KSTAT_DATA_INT64 +#define KSTAT_DATA_ULONG KSTAT_DATA_UINT64 +#else +#define KSTAT_DATA_LONG 7 /* only visible to the kernel */ +#define KSTAT_DATA_ULONG 8 /* only visible to the kernel */ +#endif /* !_KERNEL */ +#endif /* !_LP64 */ + +/* + * Statistics exporting named kstats with long strings (KSTAT_DATA_STRING) + * may not make the assumption that ks_data_size is equal to (ks_ndata * sizeof + * (kstat_named_t)). ks_data_size in these cases is equal to the sum of the + * amount of space required to store the strings (ie, the sum of + * KSTAT_NAMED_STR_BUFLEN() for all KSTAT_DATA_STRING statistics) plus the + * space required to store the kstat_named_t's. + * + * The default update routine will update ks_data_size automatically for + * variable-length kstats containing long strings (using the default update + * routine only makes sense if the string is the only thing that is changing + * in size, and ks_ndata is constant). Fixed-length kstats containing long + * strings must explicitly change ks_data_size (after creation but before + * initialization) to reflect the correct amount of space required for the + * long strings and the kstat_named_t's. + */ +#define KSTAT_DATA_STRING 9 + +/* These types are obsolete */ + +#define KSTAT_DATA_LONGLONG KSTAT_DATA_INT64 +#define KSTAT_DATA_ULONGLONG KSTAT_DATA_UINT64 +#define KSTAT_DATA_FLOAT 5 +#define KSTAT_DATA_DOUBLE 6 + +#define KSTAT_NAMED_PTR(kptr) ((kstat_named_t *)(kptr)->ks_data) + +/* + * Retrieve the pointer of the string contained in the given named kstat. + */ +#define KSTAT_NAMED_STR_PTR(knptr) ((knptr)->value.str.addr.ptr) + +/* + * Retrieve the length of the buffer required to store the string in the given + * named kstat. + */ +#define KSTAT_NAMED_STR_BUFLEN(knptr) ((knptr)->value.str.len) + +/* + * Interrupt statistics. + * + * An interrupt is a hard interrupt (sourced from the hardware device + * itself), a soft interrupt (induced by the system via the use of + * some system interrupt source), a watchdog interrupt (induced by + * a periodic timer call), spurious (an interrupt entry point was + * entered but there was no interrupt condition to service), + * or multiple service (an interrupt condition was detected and + * serviced just prior to returning from any of the other types). + * + * Measurement of the spurious class of interrupts is useful for + * autovectored devices in order to pinpoint any interrupt latency + * problems in a particular system configuration. + * + * Devices that have more than one interrupt of the same + * type should use multiple structures. + */ + +#define KSTAT_INTR_HARD 0 +#define KSTAT_INTR_SOFT 1 +#define KSTAT_INTR_WATCHDOG 2 +#define KSTAT_INTR_SPURIOUS 3 +#define KSTAT_INTR_MULTSVC 4 + +#define KSTAT_NUM_INTRS 5 + +typedef struct kstat_intr { + uint_t intrs[KSTAT_NUM_INTRS]; /* interrupt counters */ +} kstat_intr_t; + +#define KSTAT_INTR_PTR(kptr) ((kstat_intr_t *)(kptr)->ks_data) + +/* + * I/O statistics. + */ + +typedef struct kstat_io { + + /* + * Basic counters. + * + * The counters should be updated at the end of service + * (e.g., just prior to calling biodone()). + */ + + u_longlong_t nread; /* number of bytes read */ + u_longlong_t nwritten; /* number of bytes written */ + uint_t reads; /* number of read operations */ + uint_t writes; /* number of write operations */ + + /* + * Accumulated time and queue length statistics. + * + * Accumulated time statistics are kept as a running sum + * of "active" time. Queue length statistics are kept as a + * running sum of the product of queue length and elapsed time + * at that length -- i.e., a Riemann sum for queue length + * integrated against time. (You can also think of the active time + * as a Riemann sum, for the boolean function (queue_length > 0) + * integrated against time, or you can think of it as the + * Lebesgue measure of the set on which queue_length > 0.) + * + * ^ + * | _________ + * 8 | i4 | + * | | | + * Queue 6 | | + * Length | _________ | | + * 4 | i2 |_______| | + * | | i3 | + * 2_______| | + * | i1 | + * |_______________________________| + * Time-> t1 t2 t3 t4 + * + * At each change of state (entry or exit from the queue), + * we add the elapsed time (since the previous state change) + * to the active time if the queue length was non-zero during + * that interval; and we add the product of the elapsed time + * times the queue length to the running length*time sum. + * + * This method is generalizable to measuring residency + * in any defined system: instead of queue lengths, think + * of "outstanding RPC calls to server X". + * + * A large number of I/O subsystems have at least two basic + * "lists" of transactions they manage: one for transactions + * that have been accepted for processing but for which processing + * has yet to begin, and one for transactions which are actively + * being processed (but not done). For this reason, two cumulative + * time statistics are defined here: wait (pre-service) time, + * and run (service) time. + * + * All times are 64-bit nanoseconds (hrtime_t), as returned by + * gethrtime(). + * + * The units of cumulative busy time are accumulated nanoseconds. + * The units of cumulative length*time products are elapsed time + * times queue length. + * + * Updates to the fields below are performed implicitly by calls to + * these five functions: + * + * kstat_waitq_enter() + * kstat_waitq_exit() + * kstat_runq_enter() + * kstat_runq_exit() + * + * kstat_waitq_to_runq() (see below) + * kstat_runq_back_to_waitq() (see below) + * + * Since kstat_waitq_exit() is typically followed immediately + * by kstat_runq_enter(), there is a single kstat_waitq_to_runq() + * function which performs both operations. This is a performance + * win since only one timestamp is required. + * + * In some instances, it may be necessary to move a request from + * the run queue back to the wait queue, e.g. for write throttling. + * For these situations, call kstat_runq_back_to_waitq(). + * + * These fields should never be updated by any other means. + */ + + hrtime_t wtime; /* cumulative wait (pre-service) time */ + hrtime_t wlentime; /* cumulative wait length*time product */ + hrtime_t wlastupdate; /* last time wait queue changed */ + hrtime_t rtime; /* cumulative run (service) time */ + hrtime_t rlentime; /* cumulative run length*time product */ + hrtime_t rlastupdate; /* last time run queue changed */ + + uint_t wcnt; /* count of elements in wait state */ + uint_t rcnt; /* count of elements in run state */ + +} kstat_io_t; + +#define KSTAT_IO_PTR(kptr) ((kstat_io_t *)(kptr)->ks_data) + +/* + * Event timer statistics - cumulative elapsed time and number of events. + * + * Updates to these fields are performed implicitly by calls to + * kstat_timer_start() and kstat_timer_stop(). + */ + +typedef struct kstat_timer { + char name[KSTAT_STRLEN]; /* event name */ + uchar_t resv; /* reserved */ + u_longlong_t num_events; /* number of events */ + hrtime_t elapsed_time; /* cumulative elapsed time */ + hrtime_t min_time; /* shortest event duration */ + hrtime_t max_time; /* longest event duration */ + hrtime_t start_time; /* previous event start time */ + hrtime_t stop_time; /* previous event stop time */ +} kstat_timer_t; + +#define KSTAT_TIMER_PTR(kptr) ((kstat_timer_t *)(kptr)->ks_data) + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +#include + +extern kid_t kstat_chain_id; /* bumped at each state change */ +extern void kstat_init(void); /* initialize kstat framework */ + +/* + * Adding and deleting kstats. + * + * The typical sequence to add a kstat is: + * + * ksp = kstat_create(module, instance, name, class, type, ndata, flags); + * if (ksp) { + * ... provider initialization, if necessary + * kstat_install(ksp); + * } + * + * There are three logically distinct steps here: + * + * Step 1: System Initialization (kstat_create) + * + * kstat_create() performs system initialization. kstat_create() + * allocates memory for the entire kstat (header plus data), initializes + * all header fields, initializes the data section to all zeroes, assigns + * a unique KID, and puts the kstat onto the system's kstat chain. + * The returned kstat is marked invalid (KSTAT_FLAG_INVALID is set), + * because the provider (caller) has not yet had a chance to initialize + * the data section. + * + * By default, kstats are exported to all zones on the system. A kstat may be + * created via kstat_create_zone() to specify a zone to which the statistics + * should be exported. kstat_zone_add() may be used to specify additional + * zones to which the statistics are to be exported. + * + * Step 2: Provider Initialization + * + * The provider performs any necessary initialization of the data section, + * e.g. setting the name fields in a KSTAT_TYPE_NAMED. Virtual kstats set + * the ks_data field at this time. The provider may also set the ks_update, + * ks_snapshot, ks_private, and ks_lock fields if necessary. + * + * Step 3: Installation (kstat_install) + * + * Once the kstat is completely initialized, kstat_install() clears the + * INVALID flag, thus making the kstat accessible to the outside world. + * kstat_install() also clears the DORMANT flag for persistent kstats. + * + * Removing a kstat from the system + * + * kstat_delete(ksp) removes ksp from the kstat chain and frees all + * associated system resources. NOTE: When you call kstat_delete(), + * you must NOT be holding that kstat's ks_lock. Otherwise, you may + * deadlock with a kstat reader. + * + * Persistent kstats + * + * From the provider's point of view, persistence is transparent. The only + * difference between ephemeral (normal) kstats and persistent kstats + * is that you pass KSTAT_FLAG_PERSISTENT to kstat_create(). Magically, + * this has the effect of making your data visible even when you're + * not home. Persistence is important to tools like iostat, which want + * to get a meaningful picture of disk activity. Without persistence, + * raw disk i/o statistics could never accumulate: they would come and + * go with each open/close of the raw device. + * + * The magic of persistence works by slightly altering the behavior of + * kstat_create() and kstat_delete(). The first call to kstat_create() + * creates a new kstat, as usual. However, kstat_delete() does not + * actually delete the kstat: it performs one final update of the data + * (i.e., calls the ks_update routine), marks the kstat as dormant, and + * sets the ks_lock, ks_update, ks_private, and ks_snapshot fields back + * to their default values (since they might otherwise point to garbage, + * e.g. if the provider is going away). kstat clients can still access + * the dormant kstat just like a live kstat; they just continue to see + * the final data values as long as the kstat remains dormant. + * All subsequent kstat_create() calls simply find the already-existing, + * dormant kstat and return a pointer to it, without altering any fields. + * The provider then performs its usual initialization sequence, and + * calls kstat_install(). kstat_install() uses the old data values to + * initialize the native data (i.e., ks_update is called with KSTAT_WRITE), + * thus making it seem like you were never gone. + */ + +extern kstat_t *kstat_create(const char *, int, const char *, const char *, + uchar_t, uint_t, uchar_t); +extern kstat_t *kstat_create_zone(const char *, int, const char *, + const char *, uchar_t, uint_t, uchar_t, zoneid_t); +extern void kstat_install(kstat_t *); +extern void kstat_delete(kstat_t *); +extern void kstat_named_setstr(kstat_named_t *knp, const char *src); +extern void kstat_set_string(char *, const char *); +extern void kstat_delete_byname(const char *, int, const char *); +extern void kstat_delete_byname_zone(const char *, int, const char *, zoneid_t); +extern void kstat_named_init(kstat_named_t *, const char *, uchar_t); +extern void kstat_timer_init(kstat_timer_t *, const char *); +extern void kstat_waitq_enter(kstat_io_t *); +extern void kstat_waitq_exit(kstat_io_t *); +extern void kstat_runq_enter(kstat_io_t *); +extern void kstat_runq_exit(kstat_io_t *); +extern void kstat_waitq_to_runq(kstat_io_t *); +extern void kstat_runq_back_to_waitq(kstat_io_t *); +extern void kstat_timer_start(kstat_timer_t *); +extern void kstat_timer_stop(kstat_timer_t *); + +extern void kstat_zone_add(kstat_t *, zoneid_t); +extern void kstat_zone_remove(kstat_t *, zoneid_t); +extern int kstat_zone_find(kstat_t *, zoneid_t); + +extern kstat_t *kstat_hold_bykid(kid_t kid, zoneid_t); +extern kstat_t *kstat_hold_byname(const char *, int, const char *, zoneid_t); +extern void kstat_rele(kstat_t *); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KSTAT_H */ diff --git a/illumos-x86_64/usr/include/sys/kstr.h b/illumos-x86_64/usr/include/sys/kstr.h new file mode 100644 index 00000000..e7889a6a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/kstr.h @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991-1997, 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_KSTR_H +#define _SYS_KSTR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Autopush operation numbers. + */ +#define SET_AUTOPUSH 0 +#define GET_AUTOPUSH 1 +#define CLR_AUTOPUSH 2 + +extern int kstr_open(major_t, minor_t, vnode_t **, int *); +extern int kstr_plink(vnode_t *, int, int *); +extern int kstr_unplink(vnode_t *, int); +extern int kstr_push(vnode_t *, char *); +extern int kstr_pop(vnode_t *); +extern int kstr_close(vnode_t *, int); +extern int kstr_ioctl(vnode_t *, int, intptr_t); +extern int kstr_msg(vnode_t *, mblk_t *, mblk_t **, timestruc_t *); +extern int kstr_autopush(int, major_t *, minor_t *, minor_t *, uint_t *, + char *[]); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KSTR_H */ diff --git a/illumos-x86_64/usr/include/sys/ksyms.h b/illumos-x86_64/usr/include/sys/ksyms.h new file mode 100644 index 00000000..254d21c1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ksyms.h @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998-1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_KSYMS_H +#define _SYS_KSYMS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +extern krwlock_t ksyms_lock; +extern vmem_t *ksyms_arena; + +extern size_t ksyms_snapshot(void (*)(const void *, void *, size_t), + void *, size_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KSYMS_H */ diff --git a/illumos-x86_64/usr/include/sys/ksynch.h b/illumos-x86_64/usr/include/sys/ksynch.h new file mode 100644 index 00000000..3b627b6f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ksynch.h @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, Sun Microsystems, Inc. + */ + +/* + * DKI/DDI MT synchronization primitives. + */ + +#ifndef _SYS_KSYNCH_H +#define _SYS_KSYNCH_H + +/* + * The presence of this file is specified by the DKI/DDI. + */ + +#include + +#endif /* _SYS_KSYNCH_H */ diff --git a/illumos-x86_64/usr/include/sys/ldterm.h b/illumos-x86_64/usr/include/sys/ldterm.h new file mode 100644 index 00000000..2db9c6ac --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ldterm.h @@ -0,0 +1,286 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_LDTERM_H +#define _SYS_LDTERM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define IBSIZE 16 /* "standard" input data block size */ +#define OBSIZE 64 /* "standard" output data block size */ +#define EBSIZE 16 /* "standard" echo data block size */ + +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#define V_MIN tp->t_modes.c_cc[VMIN] +#define V_TIME tp->t_modes.c_cc[VTIME] +#define RAW_MODE !(tp->t_modes.c_lflag & ICANON) +#define CANON_MODE (tp->t_modes.c_lflag & ICANON) + +/* flow control defines */ +#define TTXOLO 132 +#define TTXOHI 180 +#define HIWAT 1024 +#define LOWAT 200 +#define LDCHUNK 512 + + +/* + * The following for EUC and also other types of codesets. + */ + +#define EUCSIZE sizeof (struct eucioc) +#define EUCIN 0 /* copying eucioc_t IN from ioctl */ +#define EUCOUT 1 /* copying it OUT to user format */ + +/* + * One assumption made throughout this module is: EUC characters have + * a display width less than 255. Also, assumed around, is that they + * consist of < 256 bytes, but we don't worry much about that. + */ + +#define EUC_TWIDTH 255 /* Width of a TAB, as returned by */ + /* "ldterm_dispwidth" */ +#define EUC_BSWIDTH 254 /* Width of a backspace as returned */ +#define EUC_NLWIDTH 253 /* newline & cr */ +#define EUC_CRWIDTH 252 + +#define UNKNOWN_WIDTH 251 + +#define EUC_MAXW 4 /* max display width and memory width, both */ +#define EUC_WARNCNT 20 /* # bad EUC erase attempts before hollering */ + +/* The next version will be the current LDTERM_DATA_VERSION + 1. */ +#define LDTERM_DATA_VERSION 1 + +/* + * Supported codeset types: + * When you are adding a new codeset type, do not add any new codeset type + * value that is smaller than LDTERM_CS_TYPE_MIN. You will also need to + * add the new codeset type sequentially and also increase LDTERM_CS_TYPE_MAX + * so that the LDTERM_CS_TYPE_MAX will be always equal to the last, new + * codeset type value. + * + * Whenever you increase the LDTERM_CS_TYPE_MAX, you will also need to + * increase the LDTERM_DATA_VERSION and also update the ldterm.c so that + * ldterm will have proper version control. + */ +#define LDTERM_CS_TYPE_MIN 1 + +#define LDTERM_CS_TYPE_EUC 1 +#define LDTERM_CS_TYPE_PCCS 2 +#define LDTERM_CS_TYPE_UTF8 3 + +#define LDTERM_CS_TYPE_MAX 3 + +/* + * The maximum number of bytes in a character of the codeset that + * can be handled by ldterm. + */ +#define LDTERM_CS_MAX_BYTE_LENGTH 8 + +/* + * The maximum number of sub-codesets in a codeset that can be + * handled by ldterm. + */ +#define LDTERM_CS_MAX_CODESETS 10 + +/* The maximum and minimum sub-codeset numbers possible in EUC codeset. */ +#define LDTERM_CS_TYPE_EUC_MIN_SUBCS 0 +#define LDTERM_CS_TYPE_EUC_MAX_SUBCS 3 + +/* The maximum and minimum sub-codeset numbers possible in PCCS codeset. */ +#define LDTERM_CS_TYPE_PCCS_MIN_SUBCS 1 +#define LDTERM_CS_TYPE_PCCS_MAX_SUBCS LDTERM_CS_MAX_CODESETS + +/* Some UTF-8 related values: */ +/* The maximum and minimum UTF-8 character subsequent byte values. */ +#define LDTERM_CS_TYPE_UTF8_MIN_BYTE 0x80 +#define LDTERM_CS_TYPE_UTF8_MAX_BYTE 0xbf + +/* Some maximum and minimum character values in UTF-32. */ +#define LDTERM_CS_TYPE_UTF8_MAX_P00 0x00ffff +#define LDTERM_CS_TYPE_UTF8_MAX_P01 0x01ffff +#define LDTERM_CS_TYPE_UTF8_MIN_CJKEXTB 0x020000 +#define LDTERM_CS_TYPE_UTF8_MAX_CJKEXTB 0x02a6d6 +#define LDTERM_CS_TYPE_UTF8_MIN_CJKCOMP 0x02f800 +#define LDTERM_CS_TYPE_UTF8_MAX_CJKCOMP 0x02fa1d +#define LDTERM_CS_TYPE_UTF8_MIN_P14 0x0e0000 +#define LDTERM_CS_TYPE_UTF8_MAX_P14 0x0e007f +#define LDTERM_CS_TYPE_UTF8_MIN_VARSEL 0x0e0100 +#define LDTERM_CS_TYPE_UTF8_MAX_VARSEL 0x0e01ef +#define LDTERM_CS_TYPE_UTF8_MIN_P15 0x0f0000 +#define LDTERM_CS_TYPE_UTF8_MAX_P15 0x0ffffd +#define LDTERM_CS_TYPE_UTF8_MIN_P16 0x100000 +#define LDTERM_CS_TYPE_UTF8_MAX_P16 0x10fffd + +/* Bit shift number and mask values for conversion from UTF-8 to UCS-4. */ +#define LDTERM_CS_TYPE_UTF8_SHIFT_BITS 6 +#define LDTERM_CS_TYPE_UTF8_BIT_MASK 0x3f + +/* + * The following data structure is to provide codeset-specific + * information for EUC and PC originated codesets (ldterm_eucpc_data_t) + */ +struct _ldterm_eucpc_data { + uchar_t byte_length; + uchar_t screen_width; + uchar_t msb_start; + uchar_t msb_end; +}; +typedef struct _ldterm_eucpc_data ldterm_eucpc_data_t; + +/* ldterm codeset data information for user side. */ +struct _ldterm_cs_data_user { + uchar_t version; /* version: 1 ~ 255 */ + uchar_t codeset_type; + uchar_t csinfo_num; /* the # of codesets */ + uchar_t pad; + char locale_name[MAXNAMELEN]; + ldterm_eucpc_data_t eucpc_data[LDTERM_CS_MAX_CODESETS]; + /* width data */ +}; +typedef struct _ldterm_cs_data_user ldterm_cs_data_user_t; + +/* ldterm codeset data information for ldterm. */ +struct _ldterm_cs_data { + uchar_t version; /* version: 1 ~ 255 */ + uchar_t codeset_type; + uchar_t csinfo_num; /* the # of codesets */ + uchar_t pad; + char *locale_name; + ldterm_eucpc_data_t eucpc_data[LDTERM_CS_MAX_CODESETS]; + /* width data */ +}; +typedef struct _ldterm_cs_data ldterm_cs_data_t; + +/* + * The following data structure is to handle Unicode codeset. + * To represent a single Unicode plane, it requires to have 16384 + * 'ldterm_unicode_data_cell_t' elements. + */ +struct _ldterm_unicode_data_cell { + uchar_t u0:2; + uchar_t u1:2; + uchar_t u2:2; + uchar_t u3:2; +}; +typedef struct _ldterm_unicode_data_cell ldterm_unicode_data_cell_t; + +/* The following function pointers point the current codeset methods. */ +typedef struct _ldterm_cs_methods { + int (*ldterm_dispwidth)(uchar_t, void *, int); + int (*ldterm_memwidth)(uchar_t, void *); +} ldterm_cs_methods_t; + +typedef struct ldterm_mod { + struct termios t_modes; /* Effective modes set by the provider below */ + struct termios t_amodes; /* Apparent modes for user programs */ + struct termios t_dmodes; /* Modes that driver wishes to process */ + unsigned int t_state; /* internal state of ldterm module */ + int t_line; /* output line of tty */ + int t_col; /* output column of tty */ + int t_rocount; /* number of chars echoed since last output */ + int t_rocol; /* column in which first such char appeared */ + mblk_t *t_message; /* pointer to first mblk in message being */ + /* built */ + mblk_t *t_endmsg; /* pointer to last mblk in that message */ + size_t t_msglen; /* number of characters in that message */ + mblk_t *t_echomp; /* echoed output being assembled */ + int t_rd_request; /* Number of bytes requested by M_READ */ + /* during vmin/vtime read */ + int t_iocid; /* ID of ioctl reply being awaited */ + bufcall_id_t t_wbufcid; /* ID of pending write-side bufcall */ + timeout_id_t t_vtid; /* vtime timer id */ + + /* + * The following are for EUC and also other types of codeset + * processing. Please read 'euc' as 'multi-byte codeset' instead. + */ + uchar_t t_codeset; /* current code set indicator (read side) */ + uchar_t t_eucleft; /* bytes left to get in current char (read) */ + uchar_t t_eucign; /* bytes left to ignore (output post proc) */ + uchar_t t_eucpad; /* padding ... for eucwioc */ + eucioc_t eucwioc; /* eucioc structure (have to use bcopy) */ + uchar_t *t_eucp; /* ptr to parallel array of column widths */ + mblk_t *t_eucp_mp; /* the m_blk that holds parallel array */ + uchar_t t_maxeuc; /* the max length in memory bytes of an EUC */ + int t_eucwarn; /* bad EUC counter */ + + /* + * The t_csdata, t_csmethods, t_scratch, and, t_scratch_len data + * fields are to support various non-EUC codesets. + */ + ldterm_cs_data_t t_csdata; + struct _ldterm_cs_methods t_csmethods; + uchar_t t_scratch[LDTERM_CS_MAX_BYTE_LENGTH]; + uchar_t t_scratch_len; + + mblk_t *t_closeopts; /* preallocated stroptions for close */ + mblk_t *t_drainmsg; /* preallocated TCSBRK drain message */ +} ldtermstd_state_t; + +/* + * Internal state bits. + */ +#define TS_XCLUDE 0x00000001 /* exclusive-use flag against open */ +#define TS_TTSTOP 0x00000002 /* output stopped by ^S */ +#define TS_TBLOCK 0x00000004 /* input stopped by IXOFF mode */ +#define TS_QUOT 0x00000008 /* last character input was \ */ +#define TS_ERASE 0x00000010 /* within a \.../ for PRTRUB */ +#define TS_SLNCH 0x00000020 /* next character service routine */ + /* sees is literal */ +#define TS_PLNCH 0x00000040 /* next character put routine sees */ + /* is literal */ + +#define TS_TTCR 0x00000080 /* mapping NL to CR-NL */ +#define TS_NOCANON 0x00000100 /* canonicalization done by somebody */ + /* below us */ +#define TS_RESCAN 0x00000400 /* canonicalization mode changed, */ + /* rescan input queue */ +#define TS_MREAD 0x00000800 /* timer started for vmin/vtime */ +#define TS_FLUSHWAIT 0x00001000 /* waiting for flush on write side */ +#define TS_MEUC 0x00010000 /* TRUE if multi-byte codesets used */ +#define TS_WARNED 0x00020000 /* already warned on console */ +#define TS_CLOSE 0x00040000 /* close in progress */ +#define TS_IOCWAIT 0x00080000 /* waiting for reply to ioctl message */ +#define TS_IFBLOCK 0x00100000 /* input flow blocked */ +#define TS_OFBLOCK 0x00200000 /* output flow blocked */ +#define TS_ISPTSTTY 0x00400000 /* is x/open terminal */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LDTERM_H */ diff --git a/illumos-x86_64/usr/include/sys/lgrp.h b/illumos-x86_64/usr/include/sys/lgrp.h new file mode 100644 index 00000000..447c9e03 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lgrp.h @@ -0,0 +1,642 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2017 RackTop Systems. + */ + +#ifndef _LGRP_H +#define _LGRP_H + +/* + * locality group definitions for kernel + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define LGRP_NONE (-1) /* non-existent lgroup ID */ + +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) && !defined(_KMEMUSER) +typedef struct lgrp_mem_policy_info { int opaque[2]; } lgrp_mem_policy_info_t; +#endif /* !_KERNEL && !_FAKE_KERNEL && !_KMEMUSER */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) || defined(_KMEMUSER) +#include +#include +#include +#include +#include +#include +#include + +typedef uint32_t lgrp_load_t; /* lgrp_loadavg type */ +typedef uintptr_t lgrp_handle_t; /* lgrp handle */ + +#define LGRP_NONE_SUCH LGRP_NONE /* non-existent lgroup ID */ +/* null platform handle */ +#define LGRP_NULL_HANDLE ((lgrp_handle_t)0xbadbad) +#define LGRP_DEFAULT_HANDLE ((lgrp_handle_t)0xbabecafe) /* uma handle */ +#define LGRP_ROOTID (0) /* root lgroup ID */ + +/* + * Maximum number of lgrps a platform may define. + */ +#define NLGRPS_MAX 64 +#define LGRP_LOADAVG_MAX UINT32_MAX + +/* + * The load-average we expect for one cpu-bound thread's worth of load + */ +#define LGRP_LOADAVG_THREAD_MAX 65516 + +/* + * The input to the load-average generating function for one cpu-bound thread's + * worth of load + */ + +#define LGRP_LOADAVG_IN_THREAD_MAX 128 + +/* + * LPL actions + */ + +typedef enum { + LPL_INCREMENT, + LPL_DECREMENT +} lpl_act_t; + +/* + * lgroup statistics. Most of these are counters that are updated + * dynamically so they are hashed to CPU buckets to reduce cache + * interference. The remaining statistics are snapshots of kernel + * data, so they aren't stored in the array of counter stats. + * + * For the hashed stats to make sense, you have to sum all the buckets for + * that stat, hence macros are provided to read the stats. + */ + +#define LGRP_NUM_CPU_BUCKETS 8 /* must be power of 2 */ +#define LGRP_CPU_BUCKET_MASK (LGRP_NUM_CPU_BUCKETS - 1) + +/* + * Flags for what to do with lgroup memory policy + * Used for heap and stack where policy is extended to new segments added to + * the end + */ +#define LGRP_MP_FLAG_EXTEND_UP 0x1 /* policy should extend up */ +#define LGRP_MP_FLAG_EXTEND_DOWN 0x2 /* policy should extend down */ + +#define LGRP_STAT(stats, bucket, whichstat) \ + ((stats)->ls_data[bucket][whichstat]) + +/* Return a pointer suitable for an atomic 64-bit op on the bucket */ +#define LGRP_STAT_WRITE_PTR(stats, whichstat) \ + (&LGRP_STAT(stats, (CPU->cpu_id) & LGRP_CPU_BUCKET_MASK, \ + whichstat)) + +/* Sum up all the buckets and return the value in 'val' */ +#define LGRP_STAT_READ(stats, whichstat, val) { \ + int bkt; \ + for (val = 0, bkt = 0; bkt < LGRP_NUM_CPU_BUCKETS; bkt++) \ + val += LGRP_STAT(stats, bkt, whichstat); \ +} + +/* Reset all buckets for the stat to 0 */ +#define LGRP_STAT_RESET(stats, stat) { \ + int i; \ + for (i = 0; i < LGRP_NUM_CPU_BUCKETS; i++) \ + LGRP_STAT(stats, i, stat) = 0; \ +} + +/* + * Define all of the statistics that are kept for lgrp kstats, + * and their corresponding text names. + */ + +typedef enum lgrp_stat_types { + LGRP_NUM_MIGR, /* # migrations away from this lgrp */ + LGRP_NUM_ALLOC_FAIL, /* # times alloc fails for chosen lgrp */ + LGRP_PM_SRC_PGS, /* # pages migrated from this lgrp */ + LGRP_PM_DEST_PGS, /* # pages migrated to this lgrp */ + LGRP_PM_FAIL_ALLOC_PGS, /* # pages failed to migrate to this lgrp */ + LGRP_PM_FAIL_LOCK_PGS, /* # pages failed to migrate from this lgrp */ + LGRP_PMM_PGS, /* # pages marked to migrate from this lgrp */ + LGRP_PMM_FAIL_PGS, /* # pages marked to migrate from this lgrp */ + LGRP_NUM_DEFAULT, /* # of times default policy applied */ + LGRP_NUM_NEXT, /* # of times next touch policy applied */ + LGRP_NUM_RANDOM, /* # of times random policy applied */ + LGRP_NUM_RANDOM_PROC, /* # of times random proc policy applied */ + LGRP_NUM_RANDOM_PSET, /* # of times random pset policy applied */ + LGRP_NUM_ROUNDROBIN, /* # of times round robin policy applied */ + LGRP_NUM_NEXT_SEG, /* # of times next to seg policy applied */ + LGRP_NUM_COUNTER_STATS, /* always last */ + LGRP_CTR_STATS_ALLOC = 16 /* cache-align pad - multiple of 8 */ + /* always keep >= LGRP_NUM_COUNTER_STATS */ +} lgrp_stat_t; + +typedef enum lgrp_snap_stat_types { + LGRP_NUM_CPUS, /* number of CPUs */ + LGRP_NUM_PG_FREE, /* # of free pages */ + LGRP_NUM_PG_AVAIL, /* # of allocatable physical pages */ + LGRP_NUM_PG_INSTALL, /* # of installed physical pages */ + LGRP_LOADAVG, /* unscaled load average of this lgrp */ + LGRP_LOADAVG_SCALE, /* load unit of one CPU bound thread */ + LGRP_NUM_SNAPSHOT_STATS /* always last */ +} lgrp_snap_stat_t; + +#define LGRP_KSTAT_NAMES \ +static char *lgrp_kstat_names[] = { \ + \ + /* Counter stats */ \ + "lwp migrations", \ + "alloc fail", \ + "pages migrated from", \ + "pages migrated to", \ + "pages failed to migrate to", \ + "pages failed to migrate from", \ + "pages marked for migration", \ + "pages failed to mark", \ + "default policy", \ + "next-touch policy", \ + "random policy", \ + "span process policy", \ + "span psrset policy", \ + "round robin policy", \ + "next-seg policy", \ + \ + /* Snapshot stats */ \ + "cpus", \ + "pages free", \ + "pages avail", \ + "pages installed", \ + "load average", \ + "loadscale" \ +} + +#define LGRP_NUM_STATS ((int)LGRP_NUM_COUNTER_STATS + \ + (int)LGRP_NUM_SNAPSHOT_STATS) + +/* + * The contents of this structure are opaque and should only be + * accessed through the LGRP_STAT macro. + */ +struct lgrp_stats { + int64_t ls_data[LGRP_NUM_CPU_BUCKETS][LGRP_CTR_STATS_ALLOC]; +}; + +/* The kernel's version of a bitmap of lgroups */ +typedef uint64_t klgrpset_t; + +/* + * This really belongs in memnode.h, but it must be defined here to avoid + * recursive inclusion problems. Note that memnode.h includes this header. + */ +typedef uint64_t mnodeset_t; + +/* + * lgroup structure + * + * Visible to generic code and contains the lgroup ID, CPUs in this lgroup, + * and a platform handle used to identify this lgroup to the lgroup platform + * support code + */ +typedef struct lgrp { + + lgrp_id_t lgrp_id; /* which lgroup */ + int lgrp_latency; + lgrp_handle_t lgrp_plathand; /* handle for platform calls */ + struct lgrp *lgrp_parent; /* parent lgroup */ + uint_t lgrp_reserved1; /* filler */ + uint_t lgrp_childcnt; /* number of children lgroups */ + klgrpset_t lgrp_children; /* children lgroups */ + klgrpset_t lgrp_leaves; /* (direct decendant) leaf lgroups */ + + /* + * set of lgroups containing a given type of resource + * at this level of locality + */ + klgrpset_t lgrp_set[LGRP_RSRC_COUNT]; + + mnodeset_t lgrp_mnodes; /* set of memory nodes in this lgroup */ + uint_t lgrp_nmnodes; /* number of memnodes */ + uint_t lgrp_reserved2; /* filler */ + + struct cpu *lgrp_cpu; /* pointer to a cpu may be null */ + uint_t lgrp_cpucnt; /* number of cpus in this lgrp */ + kstat_t *lgrp_kstat; /* per-lgrp kstats */ +} lgrp_t; + +/* + * lgroup load average structure + */ + +typedef struct lgrp_ld { + lgrp_load_t lpl_loadavg; /* load average */ + uint_t lpl_ncpu; /* how many cpus */ + lgrp_id_t lpl_lgrpid; /* which group this lpl part of */ + lgrp_t *lpl_lgrp; /* ptr to lpl's lgrp */ + struct lgrp_ld *lpl_parent; /* lpl of parent lgrp */ + struct cpu *lpl_cpus; /* list of cpus in lpl */ + /* NULL for non-leaf lgrps */ + uint_t lpl_nrset; /* no. of leaf lpls for lgrp */ + hrtime_t lpl_homed_time; /* time of last homing to this lpl */ + uint_t lpl_rset_sz; /* Resource set capacity */ + struct lgrp_ld **lpl_rset; /* leaf lpls for lgrp */ + /* contains ptr to self for leaf lgrp */ + int *lpl_id2rset; /* mapping of lgrpid to rset index */ +} lpl_t; + +/* + * 1 << LGRP_MAX_EFFECT_SHFT == lgrp_loadavg_max_effect + */ +#define LGRP_MAX_EFFECT_SHFT 16 + +/* + * Operations handled by lgrp_config() + */ +typedef enum lgrp_config_flag { + LGRP_CONFIG_NOP, + LGRP_CONFIG_CPU_ADD, + LGRP_CONFIG_CPU_DEL, + LGRP_CONFIG_CPU_ONLINE, + LGRP_CONFIG_CPU_OFFLINE, + LGRP_CONFIG_CPUPART_ADD, + LGRP_CONFIG_CPUPART_DEL, + LGRP_CONFIG_MEM_ADD, + LGRP_CONFIG_MEM_DEL, + LGRP_CONFIG_MEM_RENAME, + LGRP_CONFIG_GEN_UPDATE, + LGRP_CONFIG_FLATTEN, + LGRP_CONFIG_LAT_CHANGE_ALL, + LGRP_CONFIG_LAT_CHANGE +} lgrp_config_flag_t; + +/* + * Stages of lgroup framework initialization (done through lgrp_init()): + * + * 1) Initialize common and platform specific code (called in mlsetup()) + * + * 2) Setup root lgroup and add CPU 0 to lgroup(s) (called near beginning of + * main() before startup()) + * + * 3) Probe from CPU 0 and copy and release any BOP_ALLOC-ed memory temporarily + * allocated before kernel memory allocator is setup (called in main() + * after startup(), gethrtime() is setup, and before interrupts enabled) + * + * 4) Check for null proc LPA on Starcat, collapse lgroup topology (if + * necessary), setup lgroup kstats, etc. (called before start_other_cpus()) + * + * 5) Finish any lgroup initialization needed including updating lgroup + * topology after all CPUs started (called after start_other_cpus()) + */ +typedef enum lgrp_init_stages { + LGRP_INIT_STAGE1, + LGRP_INIT_STAGE2, + LGRP_INIT_STAGE3, + LGRP_INIT_STAGE4, + LGRP_INIT_STAGE5 +} lgrp_init_stages_t; + +/* + * Memory allocation policies + */ +typedef enum lgrp_mem_policy { + LGRP_MEM_POLICY_DEFAULT, + LGRP_MEM_POLICY_NEXT, /* near LWP to next touch */ + LGRP_MEM_POLICY_RANDOM_PROC, /* randomly across process */ + LGRP_MEM_POLICY_RANDOM_PSET, /* randomly across processor set */ + LGRP_MEM_POLICY_RANDOM, /* randomly across all lgroups */ + LGRP_MEM_POLICY_ROUNDROBIN, /* round robin across all lgroups */ + LGRP_MEM_POLICY_NEXT_CPU, /* Near next CPU to touch memory */ + LGRP_MEM_POLICY_NEXT_SEG, /* lgrp specified directly by seg */ + LGRP_NUM_MEM_POLICIES +} lgrp_mem_policy_t; + +/* + * Search scopes for finding resouces + */ +typedef enum lgrp_res_ss { + LGRP_SRCH_LOCAL, /* Search local lgroup only */ + LGRP_SRCH_HIER /* Search entire hierarchy */ +} lgrp_res_ss_t; + +/* + * Cookie used for lgrp mnode selection + */ +typedef struct lgrp_mnode_cookie { + lgrp_t *lmc_lgrp; /* lgrp under consideration */ + mnodeset_t lmc_nodes; /* nodes not yet tried in lgrp */ + int lmc_cnt; /* how many nodes in untried set */ + mnodeset_t lmc_tried; /* nodes already tried */ + int lmc_ntried; /* how many nodes in tried set */ + lgrp_res_ss_t lmc_scope; /* consider non-local nodes? */ + ushort_t lmc_rand; /* a "random" number */ +} lgrp_mnode_cookie_t; + +/* + * Information needed to implement memory allocation policy + */ +typedef struct lgrp_mem_policy_info { + int mem_policy; /* memory allocation policy */ + lgrp_id_t mem_lgrpid; /* lgroup id */ +} lgrp_mem_policy_info_t; + +/* + * Shared memory policy segment + */ +typedef struct lgrp_shm_policy_seg { + u_offset_t shm_off; /* offset into shared object */ + size_t shm_size; /* size of segment */ + lgrp_mem_policy_info_t shm_policy; /* memory allocation policy */ + avl_node_t shm_tree; /* AVL tree */ +} lgrp_shm_policy_seg_t; + +/* + * Shared memory locality info + */ +typedef struct lgrp_shm_locality { + size_t loc_count; /* reference count */ + avl_tree_t *loc_tree; /* policy segment tree */ + krwlock_t loc_lock; /* protects tree */ +} lgrp_shm_locality_t; + +/* + * Queries that may be made to determine lgroup memory size + */ +typedef enum { + LGRP_MEM_SIZE_FREE, /* number of free pages */ + LGRP_MEM_SIZE_AVAIL, /* number of pages in phys_avail */ + LGRP_MEM_SIZE_INSTALL /* number of pages in phys_install */ +} lgrp_mem_query_t; + +/* + * Argument for the memory copy-rename operation, contains the source and the + * destination platform handles. + */ +typedef struct lgrp_config_mem_rename { + lgrp_handle_t lmem_rename_from; + lgrp_handle_t lmem_rename_to; +} lgrp_config_mem_rename_t; + +/* Macro to clear an lgroup bitmap */ +#define klgrpset_clear(klgrpset) \ + (klgrpset) = (klgrpset_t)0 + +/* Macro to fill an lgroup bitmap */ +#define klgrpset_fill(klgrpset) \ + (klgrpset) = (klgrpset_t)(-1) + +/* Macro to add an lgroup to an lgroup bitmap */ +#define klgrpset_add(klgrpset, lgrpid) \ + (klgrpset) |= ((klgrpset_t)1 << (lgrpid)) + +/* Macro to delete an lgroup from an lgroup bitmap */ +#define klgrpset_del(klgrpset, lgrpid) \ + (klgrpset) &= ~((klgrpset_t)1 << (lgrpid)) + +/* Macro to copy a klgrpset into another klgrpset */ +#define klgrpset_copy(klgrpset_to, klgrpset_from) \ + (klgrpset_to) = (klgrpset_from) + +/* Macro to perform an 'and' operation on a pair of lgroup bitmaps */ +#define klgrpset_and(klgrpset_rslt, klgrpset_arg) \ + (klgrpset_rslt) &= (klgrpset_arg) + +/* Macro to perform an 'or' operation on a pair of lgroup bitmaps */ +#define klgrpset_or(klgrpset_rslt, klgrpset_arg) \ + (klgrpset_rslt) |= (klgrpset_arg) + +/* Macro to perform a 'diff' operation on a pair of lgroup bitmaps */ +#define klgrpset_diff(klgrpset_rslt, klgrpset_arg) \ + (klgrpset_rslt) &= ~(klgrpset_arg) + +/* Macro to check if an lgroup is a member of an lgrpset */ +#define klgrpset_ismember(klgrpset, lgrpid) \ + ((klgrpset) & ((klgrpset_t)1 << (lgrpid))) + +/* Macro to check if an lgroup bitmap is empty */ +#define klgrpset_isempty(klgrpset) \ + ((klgrpset) == (klgrpset_t)0) + +/* Macro to check if two lgrpsets intersect */ +#define klgrpset_intersects(klgrpset1, klgrpset2) \ + ((klgrpset1) & (klgrpset2)) + +/* Macro to count the number of members in an lgrpset */ +#define klgrpset_nlgrps(klgrpset, count) \ +{ \ + lgrp_id_t lgrpid; \ + for (lgrpid = 0, count = 0; lgrpid <= lgrp_alloc_max; lgrpid++) {\ + if (klgrpset_ismember(klgrpset, lgrpid)) \ + count++; \ + } \ +} + +/* Macro to get total memory size (in bytes) of a given set of lgroups */ +#define klgrpset_totalsize(klgrpset, size) \ +{ \ + lgrp_handle_t hand; \ + lgrp_id_t lgrpid; \ + \ + for (lgrpid = 0, size = 0; lgrpid <= lgrp_alloc_max; lgrpid++) {\ + if (klgrpset_ismember(klgrpset, lgrpid) && \ + lgrp_table[lgrpid]) { \ + hand = lgrp_table[lgrpid]->lgrp_plathand; \ + size += lgrp_plat_mem_size(hand, \ + LGRP_MEM_SIZE_AVAIL) * PAGESIZE; \ + } \ + } \ +} + +/* + * Does this lgroup exist? + */ +#define LGRP_EXISTS(lgrp) \ + (lgrp != NULL && lgrp->lgrp_id != LGRP_NONE) + +/* + * Macro for testing if a CPU is contained in an lgrp. + */ +#define LGRP_CONTAINS_CPU(lgrp, cpu) \ + (klgrpset_ismember(lgrp->lgrp_set[LGRP_RSRC_CPU], \ + cpu->cpu_lpl->lpl_lgrpid)) + +/* + * Initialize an lgrp_mnode_cookie + */ +#define LGRP_MNODE_COOKIE_INIT(c, lgrp, scope) \ +{ \ + bzero(&(c), sizeof (lgrp_mnode_cookie_t)); \ + (&(c))->lmc_lgrp = lgrp; \ + (&(c))->lmc_nodes = lgrp->lgrp_mnodes; \ + (&(c))->lmc_cnt = lgrp->lgrp_nmnodes; \ + (&(c))->lmc_scope = scope; \ + (&(c))->lmc_rand = (ushort_t)gethrtime_unscaled() >> 4; \ +} + +/* + * Upgrade cookie scope from LGRP_SRCH_LOCAL to LGRP_SRCH_HIER. + */ +#define LGRP_MNODE_COOKIE_UPGRADE(c) \ +{ \ + ASSERT((&(c))->lmc_scope == LGRP_SRCH_LOCAL); \ + (&(c))->lmc_scope = LGRP_SRCH_HIER; \ +} + +/* + * Macro to see whether memory allocation policy can be reapplied + */ +#define LGRP_MEM_POLICY_REAPPLICABLE(p) \ + (p == LGRP_MEM_POLICY_NEXT) + +/* + * Return true if lgrp has CPU resources in the cpupart + */ +#define LGRP_CPUS_IN_PART(lgrpid, cpupart) \ + (cpupart->cp_lgrploads[lgrpid].lpl_ncpu > 0) + +extern int lgrp_alloc_max; +extern lgrp_t *lgrp_table[NLGRPS_MAX]; /* indexed by lgrp_id */ +extern int nlgrps; /* number of lgroups in machine */ +extern int nlgrpsmax; /* max number of lgroups on platform */ +extern lgrp_gen_t lgrp_gen; /* generation of lgroup hierarchy */ +extern int lgrp_initialized; /* single-CPU initialization done */ +extern int lgrp_topo_initialized; /* lgrp topology constructed */ +extern lgrp_t *lgrp_root; /* root lgroup */ +extern unsigned int lgrp_topo_levels; +extern lpl_t *lpl_bootstrap; /* bootstrap lpl for non-active CPUs */ + + +/* generic interfaces */ + +/* + * lgroup management + */ +int lgrp_optimizations(void); +void lgrp_init(lgrp_init_stages_t); +lgrp_t *lgrp_create(void); +void lgrp_destroy(lgrp_t *); +void lgrp_config(lgrp_config_flag_t, uintptr_t, uintptr_t); +lgrp_t *lgrp_hand_to_lgrp(lgrp_handle_t); + +/* + * lgroup stats + */ +void lgrp_kstat_create(struct cpu *); +void lgrp_kstat_destroy(struct cpu *); +void lgrp_stat_add(lgrp_id_t, lgrp_stat_t, int64_t); +int64_t lgrp_stat_read(lgrp_id_t, lgrp_stat_t); + +/* + * lgroup memory + */ +lgrp_mem_policy_t lgrp_madv_to_policy(uchar_t, size_t, int); +pgcnt_t lgrp_mem_size(lgrp_id_t, lgrp_mem_query_t); +lgrp_t *lgrp_mem_choose(struct seg *, caddr_t, size_t); +int lgrp_memnode_choose(lgrp_mnode_cookie_t *); +lgrp_mem_policy_t lgrp_mem_policy_default(size_t, int); +int lgrp_mnode_update(klgrpset_t, klgrpset_t *); +lgrp_t *lgrp_pfn_to_lgrp(pfn_t); +lgrp_t *lgrp_phys_to_lgrp(u_longlong_t); /* used by numat driver */ +int lgrp_privm_policy_set(lgrp_mem_policy_t, lgrp_mem_policy_info_t *, + size_t); +void lgrp_shm_policy_init(struct anon_map *, vnode_t *); +void lgrp_shm_policy_fini(struct anon_map *, vnode_t *); +lgrp_mem_policy_info_t *lgrp_shm_policy_get(struct anon_map *, ulong_t, + vnode_t *, u_offset_t); +int lgrp_shm_policy_set(lgrp_mem_policy_t, struct anon_map *, ulong_t, + vnode_t *, u_offset_t, size_t); + +/* + * Used by numat driver + */ +int lgrp_query_cpu(processorid_t, lgrp_id_t *); +int lgrp_query_load(processorid_t, lgrp_load_t *); + +/* + * lgroup thread placement + */ +lpl_t *lgrp_affinity_best(kthread_t *, struct cpupart *, lgrp_id_t, + boolean_t); +void lgrp_affinity_init(lgrp_affinity_t **); +void lgrp_affinity_free(lgrp_affinity_t **); +lpl_t *lgrp_choose(kthread_t *t, struct cpupart *); +lgrp_t *lgrp_home_lgrp(void); +lgrp_id_t lgrp_home_id(kthread_t *); +void lgrp_loadavg(lpl_t *, uint_t, int); +void lgrp_move_thread(kthread_t *, lpl_t *, int); +uint64_t lgrp_get_trthr_migrations(void); +void lgrp_update_trthr_migrations(uint64_t); + +/* + * lgroup topology + */ +int lgrp_leaf_add(lgrp_t *, lgrp_t **, int, klgrpset_t *); +int lgrp_leaf_delete(lgrp_t *, lgrp_t **, int, klgrpset_t *); +int lgrp_rsets_empty(klgrpset_t *); +int lgrp_rsets_member(klgrpset_t *, lgrp_id_t); +int lgrp_topo_flatten(int, lgrp_t **, int, klgrpset_t *); +int lgrp_topo_ht_limit(void); +int lgrp_topo_ht_limit_default(void); +int lgrp_topo_ht_limit_set(int); +int lgrp_topo_update(lgrp_t **, int, klgrpset_t *); + +/* + * lpl topology + */ +void lpl_topo_bootstrap(lpl_t *, int); +int lpl_topo_flatten(int); +int lpl_topo_verify(struct cpupart *); + + +/* platform interfaces */ +void lgrp_plat_init(lgrp_init_stages_t); +lgrp_t *lgrp_plat_alloc(lgrp_id_t lgrpid); +void lgrp_plat_config(lgrp_config_flag_t, uintptr_t); +lgrp_handle_t lgrp_plat_cpu_to_hand(processorid_t); +lgrp_handle_t lgrp_plat_pfn_to_hand(pfn_t); +int lgrp_plat_max_lgrps(void); +pgcnt_t lgrp_plat_mem_size(lgrp_handle_t, lgrp_mem_query_t); +int lgrp_plat_latency(lgrp_handle_t, lgrp_handle_t); +lgrp_handle_t lgrp_plat_root_hand(void); + +extern uint32_t lgrp_expand_proc_thresh; +extern uint32_t lgrp_expand_proc_diff; +extern pgcnt_t lgrp_mem_free_thresh; +extern uint32_t lgrp_loadavg_tolerance; +extern uint32_t lgrp_loadavg_max_effect; +extern uint32_t lgrp_load_thresh; +extern lgrp_mem_policy_t lgrp_mem_policy_root; + +#endif /* _KERNEL || _FAKE_KERNEL || _KMEMUSER */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LGRP_H */ diff --git a/illumos-x86_64/usr/include/sys/lgrp_user.h b/illumos-x86_64/usr/include/sys/lgrp_user.h new file mode 100644 index 00000000..13d54c7c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lgrp_user.h @@ -0,0 +1,295 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2017 RackTop Systems. + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LGRP_USER_H +#define _LGRP_USER_H + +/* + * latency group definitions for user + */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include +#include +#include +#include +#include +#include + + +/* + * lgroup interface version + */ +#define LGRP_VER_NONE 0 /* no lgroup interface version */ +#define LGRP_VER_CURRENT 2 /* current lgroup interface version */ + + +/* + * lgroup system call subcodes + */ +#define LGRP_SYS_MEMINFO 0 /* meminfo(2) aka MISYS_MEMINFO */ +#define LGRP_SYS_GENERATION 1 /* lgrp_generation() */ +#define LGRP_SYS_VERSION 2 /* lgrp_version() */ +#define LGRP_SYS_SNAPSHOT 3 /* lgrp_snapshot() */ +#define LGRP_SYS_AFFINITY_GET 4 /* lgrp_affinity_set() */ +#define LGRP_SYS_AFFINITY_SET 5 /* lgrp_affinity_get() */ +#define LGRP_SYS_LATENCY 6 /* lgrp_latency() */ +#define LGRP_SYS_HOME 7 /* lgrp_home() */ + + +/* + * lgroup resources + */ +#define LGRP_RSRC_COUNT 2 /* no. of resource types in lgroup */ +#define LGRP_RSRC_CPU 0 /* CPU resources */ +#define LGRP_RSRC_MEM 1 /* memory resources */ + +typedef int lgrp_rsrc_t; + + + +/* + * lgroup affinity + */ +#define LGRP_AFF_NONE 0x0 /* no affinity */ +#define LGRP_AFF_WEAK 0x10 /* weak affinity */ +#define LGRP_AFF_STRONG 0x100 /* strong affinity */ + +typedef int lgrp_affinity_t; + +/* + * Arguments to lgrp_affinity_{get,set}() + */ +typedef struct lgrp_affinity_args { + idtype_t idtype; /* ID type */ + id_t id; /* ID */ + lgrp_id_t lgrp; /* lgroup */ + lgrp_affinity_t aff; /* affinity */ +} lgrp_affinity_args_t; + + +/* + * Flags to specify contents of lgroups desired + */ +typedef enum lgrp_content { + LGRP_CONTENT_ALL, /* everything in lgroup */ + /* everything in lgroup's hierarchy (for compatability) */ + LGRP_CONTENT_HIERARCHY = LGRP_CONTENT_ALL, + LGRP_CONTENT_DIRECT /* what's directly contained in lgroup */ +} lgrp_content_t; + + +/* + * Flags for lgrp_latency_cookie() specifying what hardware resources to get + * latency between + */ +typedef enum lgrp_lat_between { + LGRP_LAT_CPU_TO_MEM /* latency between CPU and memory */ +} lgrp_lat_between_t; + + +/* + * lgroup memory size type + */ +typedef longlong_t lgrp_mem_size_t; + + +/* + * lgroup memory size flags + */ +typedef enum lgrp_mem_size_flag { + LGRP_MEM_SZ_FREE, /* free memory */ + LGRP_MEM_SZ_INSTALLED /* installed memory */ +} lgrp_mem_size_flag_t; + + +/* + * View of lgroups + */ +typedef enum lgrp_view { + LGRP_VIEW_CALLER, /* what's available to the caller */ + LGRP_VIEW_OS /* what's available to operating system */ +} lgrp_view_t; + + +/* + * lgroup information needed by user + */ +typedef struct lgrp_info { + lgrp_id_t info_lgrpid; /* lgroup ID */ + int info_latency; /* latency */ + ulong_t *info_parents; /* parent lgroups */ + ulong_t *info_children; /* children lgroups */ + ulong_t *info_rset; /* lgroup resources */ + pgcnt_t info_mem_free; /* free memory */ + pgcnt_t info_mem_install; /* installed memory */ + processorid_t *info_cpuids; /* CPU IDs */ + int info_ncpus; /* number of CPUs */ +} lgrp_info_t; + + +/* + * Type of lgroup cookie to use with interface routines + */ +typedef uintptr_t lgrp_cookie_t; + +#define LGRP_COOKIE_NONE 0 /* no cookie */ + + +/* + * Type of lgroup generation number + */ +typedef uint_t lgrp_gen_t; + + +/* + * Format of lgroup hierarchy snapshot + */ +typedef struct lgrp_snapshot_header { + int ss_version; /* lgroup interface version */ + int ss_levels; /* levels of hierarchy */ + int ss_nlgrps; /* number of lgroups */ + int ss_nlgrps_os; /* number of lgroups (OS view) */ + int ss_nlgrps_max; /* maximum number of lgroups */ + int ss_root; /* root lgroup */ + int ss_ncpus; /* total number of CPUs */ + lgrp_view_t ss_view; /* view of lgroup hierarchy */ + psetid_t ss_pset; /* caller's pset ID */ + lgrp_gen_t ss_gen; /* snapshot generation ID */ + size_t ss_size; /* total size of snapshot */ + uintptr_t ss_magic; /* snapshot magic number */ + lgrp_info_t *ss_info; /* lgroup info array */ + processorid_t *ss_cpuids; /* lgroup CPU ID array */ + ulong_t *ss_lgrpset; /* bit mask of available lgroups */ + ulong_t *ss_parents; /* lgroup parent bit masks */ + ulong_t *ss_children; /* lgroup children bit masks */ + ulong_t *ss_rsets; /* lgroup resource set bit masks */ + int **ss_latencies; /* latencies between lgroups */ +} lgrp_snapshot_header_t; + + +#ifdef _SYSCALL32 +/* + * lgroup information needed by 32-bit user + */ +typedef struct lgrp_info32 { + int info_lgrpid; /* lgroup ID */ + int info_latency; /* latency */ + caddr32_t info_parents; /* parent lgroups */ + caddr32_t info_children; /* children lgroups */ + caddr32_t info_rset; /* lgroup resources */ + uint32_t info_mem_free; /* free memory */ + uint32_t info_mem_install; /* installed memory */ + caddr32_t info_cpuids; /* CPU IDs */ + int info_ncpus; /* number of CPUs */ +} lgrp_info32_t; + + +/* + * Format of lgroup hierarchy snapshot for 32-bit programs + */ +typedef struct lgrp_snapshot_header32 { + int ss_version; /* lgroup interface version */ + int ss_levels; /* levels of hierarchy */ + int ss_nlgrps; /* number of lgroups */ + int ss_nlgrps_os; /* number of lgroups (OS view) */ + int ss_nlgrps_max; /* maximum number of lgroups */ + int ss_root; /* root lgroup */ + int ss_ncpus; /* total number of CPUs */ + int ss_view; /* view of lgroup hierarchy */ + int ss_pset; /* caller's pset ID */ + uint_t ss_gen; /* snapshot generation ID */ + size32_t ss_size; /* total size of snapshot */ + uint32_t ss_magic; /* snapshot magic number */ + caddr32_t ss_info; /* lgroup info array */ + caddr32_t ss_cpuids; /* lgroup CPU ID array */ + caddr32_t ss_lgrpset; /* bit mask of available lgroups */ + caddr32_t ss_parents; /* lgroup parent bit masks */ + caddr32_t ss_children; /* lgroup children bit masks */ + caddr32_t ss_rsets; /* lgroup resource set bit masks */ + caddr32_t ss_latencies; /* latencies between lgroups */ +} lgrp_snapshot_header32_t; + +#endif /* _SYSCALL32 */ + + +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) && !defined(_KMEMUSER) + +lgrp_affinity_t lgrp_affinity_get(idtype_t idtype, id_t id, lgrp_id_t lgrp); + +int lgrp_affinity_set(idtype_t idtype, id_t id, lgrp_id_t lgrp, + lgrp_affinity_t aff); + +int lgrp_children(lgrp_cookie_t cookie, lgrp_id_t lgrp, + lgrp_id_t *children, uint_t count); + +int lgrp_cookie_stale(lgrp_cookie_t cookie); + +int lgrp_cpus(lgrp_cookie_t cookie, lgrp_id_t lgrp, + processorid_t *cpuids, uint_t count, lgrp_content_t content); + +int lgrp_fini(lgrp_cookie_t cookie); + +int lgrp_latency(lgrp_id_t from, lgrp_id_t to); + +int lgrp_latency_cookie(lgrp_cookie_t cookie, lgrp_id_t from, + lgrp_id_t to, lgrp_lat_between_t between); + +lgrp_id_t lgrp_home(idtype_t idtype, id_t id); + +lgrp_cookie_t lgrp_init(lgrp_view_t view); + +lgrp_mem_size_t lgrp_mem_size(lgrp_cookie_t cookie, lgrp_id_t lgrp, + lgrp_mem_size_flag_t type, lgrp_content_t content); + +int lgrp_nlgrps(lgrp_cookie_t cookie); + +int lgrp_parents(lgrp_cookie_t cookie, lgrp_id_t lgrp, + lgrp_id_t *parents, uint_t count); + +int lgrp_resources(lgrp_cookie_t cookie, lgrp_id_t lgrp, + lgrp_id_t *lgrps, uint_t count, lgrp_rsrc_t type); + +lgrp_id_t lgrp_root(lgrp_cookie_t cookie); + +int lgrp_version(int version); + +lgrp_view_t lgrp_view(lgrp_cookie_t cookie); + +#endif /* !_KERNEL && !_FAKE_KERNEL && !_KMEMUSER */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LGRP_USER_H */ diff --git a/illumos-x86_64/usr/include/sys/limits.h b/illumos-x86_64/usr/include/sys/limits.h new file mode 100644 index 00000000..88625d18 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/limits.h @@ -0,0 +1,32 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ +/* + * Copyright 2015 Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_LIMITS_H +#define _SYS_LIMITS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define IOV_MAX 1024 + +#ifdef _KERNEL +#define IOV_MAX_STACK 16 /* max. IOV on-stack allocation */ +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LIMITS_H */ diff --git a/illumos-x86_64/usr/include/sys/link.h b/illumos-x86_64/usr/include/sys/link.h new file mode 100644 index 00000000..78a679f8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/link.h @@ -0,0 +1,642 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1988 AT&T + * All Rights Reserved + * + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_LINK_H +#define _SYS_LINK_H + +#ifndef _ASM +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Communication structures for the runtime linker. + */ + +/* + * The following data structure provides a self-identifying union consisting + * of a tag from a known list and a value. + */ +#ifndef _ASM +typedef struct { + Elf32_Sword d_tag; /* how to interpret value */ + union { + Elf32_Word d_val; + Elf32_Addr d_ptr; + Elf32_Off d_off; + } d_un; +} Elf32_Dyn; + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Xword d_tag; /* how to interpret value */ + union { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } d_un; +} Elf64_Dyn; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ +#endif /* _ASM */ + +/* + * Tag values + */ +#define DT_NULL 0 /* last entry in list */ +#define DT_NEEDED 1 /* a needed object */ +#define DT_PLTRELSZ 2 /* size of relocations for the PLT */ +#define DT_PLTGOT 3 /* addresses used by procedure linkage table */ +#define DT_HASH 4 /* hash table */ +#define DT_STRTAB 5 /* string table */ +#define DT_SYMTAB 6 /* symbol table */ +#define DT_RELA 7 /* addr of relocation entries */ +#define DT_RELASZ 8 /* size of relocation table */ +#define DT_RELAENT 9 /* base size of relocation entry */ +#define DT_STRSZ 10 /* size of string table */ +#define DT_SYMENT 11 /* size of symbol table entry */ +#define DT_INIT 12 /* _init addr */ +#define DT_FINI 13 /* _fini addr */ +#define DT_SONAME 14 /* name of this shared object */ +#define DT_RPATH 15 /* run-time search path */ +#define DT_SYMBOLIC 16 /* shared object linked -Bsymbolic */ +#define DT_REL 17 /* addr of relocation entries */ +#define DT_RELSZ 18 /* size of relocation table */ +#define DT_RELENT 19 /* base size of relocation entry */ +#define DT_PLTREL 20 /* relocation type for PLT entry */ +#define DT_DEBUG 21 /* pointer to r_debug structure */ +#define DT_TEXTREL 22 /* text relocations remain for this object */ +#define DT_JMPREL 23 /* pointer to the PLT relocation entries */ +#define DT_BIND_NOW 24 /* perform all relocations at load of object */ +#define DT_INIT_ARRAY 25 /* pointer to .init_array */ +#define DT_FINI_ARRAY 26 /* pointer to .fini_array */ +#define DT_INIT_ARRAYSZ 27 /* size of .init_array */ +#define DT_FINI_ARRAYSZ 28 /* size of .fini_array */ +#define DT_RUNPATH 29 /* run-time search path */ +#define DT_FLAGS 30 /* state flags - see DF_* */ + +/* + * DT_* encoding rules: The value of each dynamic tag determines the + * interpretation of the d_un union. This convention provides for simpler + * interpretation of dynamic tags by external tools. A tag whose value + * is an even number indicates a dynamic section entry that uses d_ptr. + * A tag whose value is an odd number indicates a dynamic section entry + * that uses d_val, or that uses neither d_ptr nor d_val. + * + * There are exceptions to the above rule: + * - Tags with values that are less than DT_ENCODING. + * - Tags with values that fall between DT_LOOS and DT_SUNW_ENCODING + * - Tags with values that fall between DT_HIOS and DT_LOPROC + * + * Third party tools must handle these exception ranges explicitly + * on an item by item basis. + */ +#define DT_ENCODING 32 /* positive tag DT_* encoding rules */ + /* start after this */ +#define DT_PREINIT_ARRAY 32 /* pointer to .preinit_array */ +#define DT_PREINIT_ARRAYSZ 33 /* size of .preinit_array */ + +#define DT_MAXPOSTAGS 34 /* number of positive tags */ + +/* + * DT_* encoding rules do not apply between DT_LOOS and DT_SUNW_ENCODING + */ +#define DT_LOOS 0x6000000d /* OS specific range */ +#define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */ +#define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */ +#define DT_SUNW_FILTER 0x6000000f /* symbol filter name */ +#define DT_SUNW_CAP 0x60000010 /* hardware/software */ + /* capabilities */ +#define DT_SUNW_SYMTAB 0x60000011 /* symtab with local fcn */ + /* symbols immediately */ + /* preceding DT_SYMTAB */ +#define DT_SUNW_SYMSZ 0x60000012 /* Size of SUNW_SYMTAB table */ + +/* + * DT_* encoding rules apply between DT_SUNW_ENCODING and DT_HIOS + */ +#define DT_SUNW_ENCODING 0x60000013 /* DT_* encoding rules resume */ + /* after this */ +#define DT_SUNW_SORTENT 0x60000013 /* sizeof [SYM|TLS]SORT entry */ +#define DT_SUNW_SYMSORT 0x60000014 /* sym indices sorted by addr */ +#define DT_SUNW_SYMSORTSZ 0x60000015 /* size of SUNW_SYMSORT */ +#define DT_SUNW_TLSSORT 0x60000016 /* tls sym ndx sort by offset */ +#define DT_SUNW_TLSSORTSZ 0x60000017 /* size of SUNW_TLSSORT */ +#define DT_SUNW_CAPINFO 0x60000018 /* capabilities symbols */ +#define DT_SUNW_STRPAD 0x60000019 /* # of unused bytes at the */ + /* end of dynstr */ +#define DT_SUNW_CAPCHAIN 0x6000001a /* capabilities chain info */ +#define DT_SUNW_LDMACH 0x6000001b /* EM_ machine code of linker */ + /* that produced object */ +#define DT_SUNW_CAPCHAINENT 0x6000001d /* capabilities chain entry */ +#define DT_SUNW_CAPCHAINSZ 0x6000001f /* capabilities chain size */ +/* 0x60000021 would be DT_SUNW_PARENT */ +#define DT_SUNW_ASLR 0x60000023 /* executable ASLR desire */ +#define DT_SUNW_KMOD 0x60000027 /* object is a kernel module */ + +/* + * DT_* encoding rules do not apply between DT_HIOS and DT_LOPROC + */ +#define DT_HIOS 0x6ffff000 + +/* + * The following values have been deprecated and remain here to allow + * compatibility with older binaries. + */ +#define DT_DEPRECATED_SPARC_REGISTER 0x7000001 + +/* + * DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + * Dyn.d_un.d_val field of the Elf*_Dyn structure. + */ +#define DT_VALRNGLO 0x6ffffd00 + +#define DT_GNU_PRELINKED 0x6ffffdf5 /* prelinking timestamp (unused) */ +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* size of conflict section (unused) */ +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* size of library list (unused) */ +#define DT_CHECKSUM 0x6ffffdf8 /* elf checksum */ +#define DT_PLTPADSZ 0x6ffffdf9 /* pltpadding size */ +#define DT_MOVEENT 0x6ffffdfa /* move table entry size */ +#define DT_MOVESZ 0x6ffffdfb /* move table size */ +#define DT_FEATURE_1 0x6ffffdfc /* feature holder (unused) */ +#define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */ + /* the following DT_* entry. */ + /* See DF_P1_* definitions */ +#define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */ +#define DT_VALRNGHI 0x6ffffdff + +/* + * DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + * + * If any adjustment is made to the ELF object after it has been + * built, these entries will need to be adjusted. + */ +#define DT_ADDRRNGLO 0x6ffffe00 + +#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table (unused) */ +#define DT_TLSDESC_PLT 0x6ffffef6 /* GNU (unused) */ +#define DT_TLSDESC_GOT 0x6ffffef7 /* GNU (unused) */ +#define DT_GNU_CONFLICT 0x6ffffef8 /* start of conflict section (unused) */ +#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list (unused) */ + +#define DT_CONFIG 0x6ffffefa /* configuration information */ +#define DT_DEPAUDIT 0x6ffffefb /* dependency auditing */ +#define DT_AUDIT 0x6ffffefc /* object auditing */ +#define DT_PLTPAD 0x6ffffefd /* pltpadding (sparcv9) */ +#define DT_MOVETAB 0x6ffffefe /* move table */ +#define DT_SYMINFO 0x6ffffeff /* syminfo table */ +#define DT_ADDRRNGHI 0x6ffffeff + +/* + * The following DT_* entries should have been assigned within one of the + * DT_* ranges, but existed before such ranges had been established. + */ +#define DT_VERSYM 0x6ffffff0 /* version symbol table - unused by */ + /* Solaris (see libld/update.c) */ + +#define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */ +#define DT_RELCOUNT 0x6ffffffa /* number of RELATIVE relocations */ +#define DT_FLAGS_1 0x6ffffffb /* state flags - see DF_1_* defs */ +#define DT_VERDEF 0x6ffffffc /* version definition table and */ +#define DT_VERDEFNUM 0x6ffffffd /* associated no. of entries */ +#define DT_VERNEED 0x6ffffffe /* version needed table and */ +#define DT_VERNEEDNUM 0x6fffffff /* associated no. of entries */ + +/* + * DT_* entries between DT_HIPROC and DT_LOPROC are reserved for processor + * specific semantics. + * + * DT_* encoding rules apply to all tag values larger than DT_LOPROC. + */ +#define DT_LOPROC 0x70000000 /* processor specific range */ +#define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */ +#define DT_USED 0x7ffffffe /* ignored - same as needed */ +#define DT_FILTER 0x7fffffff /* shared library filter name */ +#define DT_HIPROC 0x7fffffff + + +/* + * Values for DT_FLAGS + */ +#define DF_ORIGIN 0x00000001 /* ORIGIN processing required */ +#define DF_SYMBOLIC 0x00000002 /* symbolic bindings in effect */ +#define DF_TEXTREL 0x00000004 /* text relocations remain */ +#define DF_BIND_NOW 0x00000008 /* process all relocations */ +#define DF_STATIC_TLS 0x00000010 /* obj. contains static TLS refs */ + +/* + * Values for the DT_POSFLAG_1 .dynamic entry. + * These values only affect the following DT_* entry. + */ +#define DF_P1_LAZYLOAD 0x00000001 /* following object is to be */ + /* lazy loaded */ +#define DF_P1_GROUPPERM 0x00000002 /* following object's symbols are */ + /* not available for general */ + /* symbol bindings. */ +#define DF_P1_DEFERRED 0x00000004 /* following object is deferred */ + +/* + * Values for the DT_FLAGS_1 .dynamic entry. + */ +#define DF_1_NOW 0x00000001 /* set RTLD_NOW for this object */ +#define DF_1_GLOBAL 0x00000002 /* set RTLD_GLOBAL for this object */ +#define DF_1_GROUP 0x00000004 /* set RTLD_GROUP for this object */ +#define DF_1_NODELETE 0x00000008 /* set RTLD_NODELETE for this object */ +#define DF_1_LOADFLTR 0x00000010 /* trigger filtee loading at runtime */ +#define DF_1_INITFIRST 0x00000020 /* set RTLD_INITFIRST for this object */ +#define DF_1_NOOPEN 0x00000040 /* set RTLD_NOOPEN for this object */ +#define DF_1_ORIGIN 0x00000080 /* ORIGIN processing required */ +#define DF_1_DIRECT 0x00000100 /* direct binding enabled */ +#define DF_1_TRANS 0x00000200 /* unused obsolete name */ +#define DF_1_INTERPOSE 0x00000400 /* object is an interposer */ +#define DF_1_NODEFLIB 0x00000800 /* ignore default library search path */ +#define DF_1_NODUMP 0x00001000 /* object can't be dldump(3x)'ed */ +#define DF_1_CONFALT 0x00002000 /* configuration alternative created */ +#define DF_1_ENDFILTEE 0x00004000 /* filtee terminates filters search */ +#define DF_1_DISPRELDNE 0x00008000 /* disp reloc applied at build time */ +#define DF_1_DISPRELPND 0x00010000 /* disp reloc applied at run-time */ +#define DF_1_NODIRECT 0x00020000 /* object contains symbols that */ + /* cannot be directly bound to */ +#define DF_1_IGNMULDEF 0x00040000 /* internal: krtld ignore muldefs */ +#define DF_1_NOKSYMS 0x00080000 /* internal: don't export object's */ + /* symbols via /dev/ksyms */ +#define DF_1_NOHDR 0x00100000 /* mapfile: 1st segment mapping */ + /* omits ELF & program headers */ +#define DF_1_EDITED 0x00200000 /* object has been modified since */ + /* being built by 'ld' */ +#define DF_1_NORELOC 0x00400000 /* internal: unrelocated object */ +#define DF_1_SYMINTPOSE 0x00800000 /* individual symbol interposers */ + /* exist */ +#define DF_1_GLOBAUDIT 0x01000000 /* establish global auditing */ +#define DF_1_SINGLETON 0x02000000 /* singleton symbols exist */ + +/* + * Values set to DT_FEATURE_1 tag's d_val (unused obsolete tag) + */ +#define DTF_1_PARINIT 0x00000001 /* partially initialization feature */ +#define DTF_1_CONFEXP 0x00000002 /* configuration file expected */ + + +/* + * Version structures. There are three types of version structure: + * + * o A definition of the versions within the image itself. + * Each version definition is assigned a unique index (starting from + * VER_NDX_BGNDEF) which is used to cross-reference symbols associated to + * the version. Each version can have one or more dependencies on other + * version definitions within the image. The version name, and any + * dependency names, are specified in the version definition auxiliary + * array. Version definition entries require a version symbol index table. + * + * o A version requirement on a needed dependency. Each needed entry + * specifies the shared object dependency (as specified in DT_NEEDED). + * One or more versions required from this dependency are specified in the + * version needed auxiliary array. + * + * o A version symbol index table. Each symbol indexes into this array + * to determine its version index. Index values of VER_NDX_BGNDEF or + * greater indicate the version definition to which a symbol is associated. + * (the size of a symbol index entry is recorded in the sh_info field). + */ +#ifndef _ASM + +typedef struct { /* Version Definition Structure. */ + Elf32_Half vd_version; /* this structures version revision */ + Elf32_Half vd_flags; /* version information */ + Elf32_Half vd_ndx; /* version index */ + Elf32_Half vd_cnt; /* no. of associated aux entries */ + Elf32_Word vd_hash; /* version name hash value */ + Elf32_Word vd_aux; /* no. of bytes from start of this */ + /* verdef to verdaux array */ + Elf32_Word vd_next; /* no. of bytes from start of this */ +} Elf32_Verdef; /* verdef to next verdef entry */ + +typedef struct { /* Verdef Auxiliary Structure. */ + Elf32_Word vda_name; /* first element defines the version */ + /* name. Additional entries */ + /* define dependency names. */ + Elf32_Word vda_next; /* no. of bytes from start of this */ +} Elf32_Verdaux; /* verdaux to next verdaux entry */ + + +typedef struct { /* Version Requirement Structure. */ + Elf32_Half vn_version; /* this structures version revision */ + Elf32_Half vn_cnt; /* no. of associated aux entries */ + Elf32_Word vn_file; /* name of needed dependency (file) */ + Elf32_Word vn_aux; /* no. of bytes from start of this */ + /* verneed to vernaux array */ + Elf32_Word vn_next; /* no. of bytes from start of this */ +} Elf32_Verneed; /* verneed to next verneed entry */ + +typedef struct { /* Verneed Auxiliary Structure. */ + Elf32_Word vna_hash; /* version name hash value */ + Elf32_Half vna_flags; /* version information */ + Elf32_Half vna_other; + Elf32_Word vna_name; /* version name */ + Elf32_Word vna_next; /* no. of bytes from start of this */ +} Elf32_Vernaux; /* vernaux to next vernaux entry */ + +typedef Elf32_Half Elf32_Versym; /* Version symbol index array */ + +typedef struct { + Elf32_Half si_boundto; /* direct bindings - symbol bound to */ + Elf32_Half si_flags; /* per symbol flags */ +} Elf32_Syminfo; + + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Half vd_version; /* this structures version revision */ + Elf64_Half vd_flags; /* version information */ + Elf64_Half vd_ndx; /* version index */ + Elf64_Half vd_cnt; /* no. of associated aux entries */ + Elf64_Word vd_hash; /* version name hash value */ + Elf64_Word vd_aux; /* no. of bytes from start of this */ + /* verdef to verdaux array */ + Elf64_Word vd_next; /* no. of bytes from start of this */ +} Elf64_Verdef; /* verdef to next verdef entry */ + +typedef struct { + Elf64_Word vda_name; /* first element defines the version */ + /* name. Additional entries */ + /* define dependency names. */ + Elf64_Word vda_next; /* no. of bytes from start of this */ +} Elf64_Verdaux; /* verdaux to next verdaux entry */ + +typedef struct { + Elf64_Half vn_version; /* this structures version revision */ + Elf64_Half vn_cnt; /* no. of associated aux entries */ + Elf64_Word vn_file; /* name of needed dependency (file) */ + Elf64_Word vn_aux; /* no. of bytes from start of this */ + /* verneed to vernaux array */ + Elf64_Word vn_next; /* no. of bytes from start of this */ +} Elf64_Verneed; /* verneed to next verneed entry */ + +typedef struct { + Elf64_Word vna_hash; /* version name hash value */ + Elf64_Half vna_flags; /* version information */ + Elf64_Half vna_other; + Elf64_Word vna_name; /* version name */ + Elf64_Word vna_next; /* no. of bytes from start of this */ +} Elf64_Vernaux; /* vernaux to next vernaux entry */ + +typedef Elf64_Half Elf64_Versym; + +typedef struct { + Elf64_Half si_boundto; /* direct bindings - symbol bound to */ + Elf64_Half si_flags; /* per symbol flags */ +} Elf64_Syminfo; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ + +#endif /* _ASM */ + +/* + * Versym symbol index values. Values greater than VER_NDX_GLOBAL + * and less then VER_NDX_LORESERVE associate symbols with user + * specified version descriptors. + */ +#define VER_NDX_LOCAL 0 /* symbol is local */ +#define VER_NDX_GLOBAL 1 /* symbol is global and assigned to */ + /* the base version */ +#define VER_NDX_LORESERVE 0xff00 /* beginning of RESERVED entries */ +#define VER_NDX_ELIMINATE 0xff01 /* symbol is to be eliminated */ + +/* + * Verdef (vd_flags) and Vernaux (vna_flags) flags values. + */ +#define VER_FLG_BASE 0x1 /* version definition of file itself */ + /* (Verdef only) */ +#define VER_FLG_WEAK 0x2 /* weak version identifier */ +#define VER_FLG_INFO 0x4 /* version is recorded in object for */ + /* informational purposes */ + /* (Versym reference) only. No */ + /* runtime verification is */ + /* required. (Vernaux only) */ + +/* + * Verdef version values. + */ +#define VER_DEF_NONE 0 /* Ver_def version */ +#define VER_DEF_CURRENT 1 +#define VER_DEF_NUM 2 + +/* + * Verneed version values. + */ +#define VER_NEED_NONE 0 /* Ver_need version */ +#define VER_NEED_CURRENT 1 +#define VER_NEED_NUM 2 + + +/* + * Syminfo flag values + */ +#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */ + /* to object containing defn. */ +#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ + /* standard filter */ +#define SYMINFO_FLG_PASSTHRU SYMINFO_FLG_FILTER /* unused obsolete name */ +#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn. should be */ + /* lazily-loaded */ +#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */ + /* object containing defn. */ +#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */ + /* directly bind to this symbol */ +#define SYMINFO_FLG_AUXILIARY 0x0040 /* symbol ref is associated to a */ + /* auxiliary filter */ +#define SYMINFO_FLG_INTERPOSE 0x0080 /* symbol defines an interposer */ +#define SYMINFO_FLG_CAP 0x0100 /* symbol is capabilities specific */ +#define SYMINFO_FLG_DEFERRED 0x0200 /* symbol should not be included in */ + /* BIND_NOW relocations */ + +/* + * Syminfo.si_boundto values. + */ +#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ +#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ +#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ + +/* + * Syminfo version values. + */ +#define SYMINFO_NONE 0 /* Syminfo version */ +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + + +/* + * Public structure defined and maintained within the runtime linker + */ +#ifndef _ASM + +typedef struct link_map Link_map; + +struct link_map { + unsigned long l_addr; /* address at which object is mapped */ + char *l_name; /* full name of loaded object */ +#ifdef _LP64 + Elf64_Dyn *l_ld; /* dynamic structure of object */ +#else + Elf32_Dyn *l_ld; /* dynamic structure of object */ +#endif + Link_map *l_next; /* next link object */ + Link_map *l_prev; /* previous link object */ + char *l_refname; /* filters reference name */ +}; + +#ifdef _SYSCALL32 +typedef struct link_map32 Link_map32; + +struct link_map32 { + Elf32_Word l_addr; + Elf32_Addr l_name; + Elf32_Addr l_ld; + Elf32_Addr l_next; + Elf32_Addr l_prev; + Elf32_Addr l_refname; +}; +#endif + +typedef enum { + RT_CONSISTENT, + RT_ADD, + RT_DELETE +} r_state_e; + +typedef enum { + RD_FL_NONE = 0, /* no flags */ + RD_FL_ODBG = (1<<0), /* old style debugger present */ + RD_FL_DBG = (1<<1) /* debugging enabled */ +} rd_flags_e; + + + +/* + * Debugging events enabled inside of the runtime linker. To + * access these events see the librtld_db interface. + */ +typedef enum { + RD_NONE = 0, /* no event */ + RD_PREINIT, /* the Initial rendezvous before .init */ + RD_POSTINIT, /* the Second rendezvous after .init */ + RD_DLACTIVITY /* a dlopen or dlclose has happened */ +} rd_event_e; + +struct r_debug { + int r_version; /* debugging info version no. */ + Link_map *r_map; /* address of link_map */ + unsigned long r_brk; /* address of update routine */ + r_state_e r_state; + unsigned long r_ldbase; /* base addr of ld.so */ + Link_map *r_ldsomap; /* address of ld.so.1's link map */ + rd_event_e r_rdevent; /* debug event */ + rd_flags_e r_flags; /* misc flags. */ +}; + +#ifdef _SYSCALL32 +struct r_debug32 { + Elf32_Word r_version; /* debugging info version no. */ + Elf32_Addr r_map; /* address of link_map */ + Elf32_Word r_brk; /* address of update routine */ + r_state_e r_state; + Elf32_Word r_ldbase; /* base addr of ld.so */ + Elf32_Addr r_ldsomap; /* address of ld.so.1's link map */ + rd_event_e r_rdevent; /* debug event */ + rd_flags_e r_flags; /* misc flags. */ +}; +#endif + + +#define R_DEBUG_VERSION 2 /* current r_debug version */ +#endif /* _ASM */ + +/* + * Attribute/value structures used to bootstrap ELF-based dynamic linker. + */ +#ifndef _ASM +typedef struct { + Elf32_Sword eb_tag; /* what this one is */ + union { /* possible values */ + Elf32_Word eb_val; + Elf32_Addr eb_ptr; + Elf32_Off eb_off; + } eb_un; +} Elf32_Boot; + +#if defined(_LP64) || defined(_LONGLONG_TYPE) +typedef struct { + Elf64_Xword eb_tag; /* what this one is */ + union { /* possible values */ + Elf64_Xword eb_val; + Elf64_Addr eb_ptr; + Elf64_Off eb_off; + } eb_un; +} Elf64_Boot; +#endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ +#endif /* _ASM */ + +/* + * Attributes + */ +#define EB_NULL 0 /* (void) last entry */ +#define EB_DYNAMIC 1 /* (*) dynamic structure of subject */ +#define EB_LDSO_BASE 2 /* (caddr_t) base address of ld.so */ +#define EB_ARGV 3 /* (caddr_t) argument vector */ +#define EB_ENVP 4 /* (char **) environment strings */ +#define EB_AUXV 5 /* (auxv_t *) auxiliary vector */ +#define EB_DEVZERO 6 /* (int) fd for /dev/zero */ +#define EB_PAGESIZE 7 /* (int) page size */ +#define EB_MAX 8 /* number of "EBs" */ +#define EB_MAX_SIZE32 64 /* size in bytes, _ILP32 */ +#define EB_MAX_SIZE64 128 /* size in bytes, _LP64 */ + + +#ifndef _ASM + +/* + * Concurrency communication structure for libc callbacks. + */ +extern void _ld_libc(void *); + +#pragma unknown_control_flow(_ld_libc) +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LINK_H */ diff --git a/illumos-x86_64/usr/include/sys/linker_set.h b/illumos-x86_64/usr/include/sys/linker_set.h new file mode 100644 index 00000000..872e560c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/linker_set.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999 John D. Polstra + * Copyright (c) 1999,2001 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS_LINKER_SET_H_ +#define _SYS_LINKER_SET_H_ + +#include + +/* + * The following macros are used to declare global sets of objects, which + * are collected by the linker into a `linker_set' as defined below. + * For ELF, this is done by constructing a separate segment for each set. + */ + +#define __MAKE_SET_CONST const + +#define __CONCAT1(x, y) x ## y +#define __CONCAT(x, y) __CONCAT1(x, y) + +#define __STRING(x) #x /* stringify without expanding x */ +#define __XSTRING(x) __STRING(x) /* expand x, then stringify */ + +#define __GLOBL(sym) __asm__(".globl " __XSTRING(sym)) +#define __WEAK(sym) __asm__(".weak " __XSTRING(sym)) +/* + * Private macros, not to be used outside this header file. + */ +#define __MAKE_SET(set, sym) \ + __WEAK(__CONCAT(__start_set_, set)); \ + __WEAK(__CONCAT(__stop_set_, set)); \ + static void const * __MAKE_SET_CONST \ + __set_##set##_sym_##sym __section("set_" #set) \ + __used = &(sym) + +/* + * Public macros. + */ +#define TEXT_SET(set, sym) __MAKE_SET(set, sym) +#define DATA_SET(set, sym) __MAKE_SET(set, sym) +#define BSS_SET(set, sym) __MAKE_SET(set, sym) +#define ABS_SET(set, sym) __MAKE_SET(set, sym) +#define SET_ENTRY(set, sym) __MAKE_SET(set, sym) + +/* + * Initialize before referring to a given linker set. + */ +#define SET_DECLARE(set, ptype) \ + extern ptype __weak_symbol *__CONCAT(__start_set_, set); \ + extern ptype __weak_symbol *__CONCAT(__stop_set_, set) + +#define SET_BEGIN(set) \ + (&__CONCAT(__start_set_, set)) +#define SET_LIMIT(set) \ + (&__CONCAT(__stop_set_, set)) + +/* + * Iterate over all the elements of a set. + * + * Sets always contain addresses of things, and "pvar" points to words + * containing those addresses. Thus is must be declared as "type **pvar", + * and the address of each set item is obtained inside the loop by "*pvar". + */ +#define SET_FOREACH(pvar, set) \ + for (pvar = SET_BEGIN(set); pvar < SET_LIMIT(set); pvar++) + +#define SET_ITEM(set, i) \ + ((SET_BEGIN(set))[i]) + +/* + * Provide a count of the items in a set. + */ +#define SET_COUNT(set) \ + (SET_LIMIT(set) - SET_BEGIN(set)) + +#endif /* _SYS_LINKER_SET_H_ */ diff --git a/illumos-x86_64/usr/include/sys/list.h b/illumos-x86_64/usr/include/sys/list.h new file mode 100644 index 00000000..6db92ed4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/list.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_LIST_H +#define _SYS_LIST_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct list_node list_node_t; +typedef struct list list_t; + +void list_create(list_t *, size_t, size_t); +void list_destroy(list_t *); + +void list_insert_after(list_t *, void *, void *); +void list_insert_before(list_t *, void *, void *); +void list_insert_head(list_t *, void *); +void list_insert_tail(list_t *, void *); +void list_remove(list_t *, void *); +void *list_remove_head(list_t *); +void *list_remove_tail(list_t *); +void list_move_tail(list_t *, list_t *); + +void *list_head(list_t *); +void *list_tail(list_t *); +void *list_next(list_t *, void *); +void *list_prev(list_t *, void *); +int list_is_empty(list_t *); + +void list_link_init(list_node_t *); +void list_link_replace(list_node_t *, list_node_t *); + +int list_link_active(list_node_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LIST_H */ diff --git a/illumos-x86_64/usr/include/sys/list_impl.h b/illumos-x86_64/usr/include/sys/list_impl.h new file mode 100644 index 00000000..a6614f9a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/list_impl.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_LIST_IMPL_H +#define _SYS_LIST_IMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct list_node { + struct list_node *list_next; + struct list_node *list_prev; +}; + +struct list { + size_t list_size; + size_t list_offset; + struct list_node list_head; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LIST_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/llc1.h b/illumos-x86_64/usr/include/sys/llc1.h new file mode 100644 index 00000000..6cca07de --- /dev/null +++ b/illumos-x86_64/usr/include/sys/llc1.h @@ -0,0 +1,278 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * llc1 - an LLC Class 1 MUX compatible with SunConnect LLC2 uses DLPI + * interface. + * + * Copyrighted as an unpublished work. + * Copyright 1992-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_LLC1_H +#define _SYS_LLC1_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct llc_stats { + long llcs_nobuffer; + long llcs_multixmt; + long llcs_multircv; /* multicast but note broadcast */ + long llcs_brdcstxmt; + long llcs_brdcstrcv; + long llcs_blocked; /* discard due to upstream being flow */ + /* controlled */ + long llcs_pktxmt; + long llcs_pktrcv; + long llcs_bytexmt; + long llcs_bytercv; + long llcs_xidxmt; + long llcs_xidrcv; + long llcs_testxmt; + long llcs_testrcv; + long llcs_ierrors; + long llcs_oerrors; +}; + +#define LLCS_NOBUFFER 0 +#define LLCS_MULTIXMT 1 +#define LLCS_MULTIRCV 2 +#define LLCS_BRDCSTXMT 3 +#define LLCS_BRDCSTRCV 4 +#define LLCS_BLOCKED 5 +#define LLCS_PKTXMT 6 +#define LLCS_PKTRCV 7 +#define LLCS_BYTEXMT 8 +#define LLCS_BYTERCV 9 +#define LLCS_XIDXMT 10 +#define LLCS_XIDRCV 11 +#define LLCS_TESTXMT 12 +#define LLCS_TESTRCV 13 +#define LLCS_IERRORS 14 +#define LLCS_OERRORS 15 + +/* multicast structures */ +typedef struct llc1_multicast_addr { + int llcm_refcnt; /* number of streams referring to */ + /* entry */ + unsigned char llcm_addr[ETHERADDRL]; +} llc_mcast_t; +#define LLC1_MAX_MULTICAST 16 /* default max multicast table size */ + +typedef +struct llc_mac_info { + struct llc_mac_info *llcp_next, *llcp_prev; + long llcp_flags; + long llcp_maxpkt; + long llcp_minpkt; + long llcp_type; + long llcp_addrlen; /* usually 6 but could be 2 */ + unsigned char llcp_macaddr[ETHERADDRL]; + unsigned char llcp_broadcast[ETHERADDRL]; + queue_t *llcp_queue; /* queue to MAC device */ + long llcp_lindex; /* link index for unlink */ + long llcp_ppa; /* the PPA number */ + long llcp_sap; /* when doing auto bind on lower */ + /* stream */ + mblk_t *llcp_data; /* temporarily hold data */ + queue_t *llcp_lqtop; /* queue for ioctls */ + mblk_t *llcp_mb; + long llcp_nstreams; + llc_mcast_t *llcp_mcast; /* per device multicast table */ + struct llc_stats llcp_stats; + kstat_t *llcp_kstatp; + uint_t llcp_iocid; /* outstanding ioc_id */ +} llc_mac_info_t; + +/* flags for mac info (link) status */ +#define LLC1_LINKED 0x0001 /* there is a stream linked but not ready */ +#define LLC1_AVAILABLE 0x0002 /* linked stream is now ready */ +#define LLC1_INFO_WAIT 0x0004 /* waiting on info_ack */ +#define LLC1_DEF_PPA 0x0008 /* default (system assigned PPA) */ +#define LLC1_RAW_WAIT 0x0010 /* waiting for DLIOCRAW to happen */ +#define LLC1_USING_RAW 0x0020 /* lower driver is using DLIOCRAW mode */ +#define LLC1_AUTO_XID 0x0040 /* automatically respond to XID */ +#define LLC1_AUTO_TEST 0x0080 /* automatically respond to TEST */ +#define LLC1_BINDING 0x0100 /* autmatically binding the lower stream */ + +typedef struct llc1 { + struct llc1 *llc_next, *llc_prev; + mblk_t *llc_mb; + long llc_state; + long llc_style; + long llc_minor; + long llc_type; + long llc_sap; + uchar_t llc_snap[5]; /* SNAP header */ + long llc_waiting_for; /* DL request to lower layer */ + long llc_flags; /* flags used for controlling things */ + long llc_multicnt; /* number of multicast addresses for */ + /* stream */ + llc_mcast_t **llc_mcast; /* multicast table if multicast is */ + /* enabled */ + queue_t *llc_qptr; + kmutex_t llc_lock; + struct llc_mac_info *llc_mac_info; + struct llc_stats *llc_stats; +} llc1_t; + +/* llc_flag bits */ +#define LLC_RAW 0x0001 /* lower stream is in RAW mode */ +#define LLC_FAST 0x0002 /* use "fast" path */ +#define LLC_PROM 0x0004 /* stream is in physical promiscuous mode */ +#define LLC_SNAP 0x0008 /* stream is using SNAP header */ +#define LLC_SNAP_OID 0x0010 /* stream is SNAP, OID is defined */ + + +typedef struct llc1device { + long llc1_status; + krwlock_t llc1_rwlock; /* used to serialize read/write locks */ + int llc1_minors; + int llc1_multisize; + llc_mac_info_t *llc1_mac_next, *llc1_mac_prev; /* the various mac */ + /* layers */ + int llc1_ndevice; /* number of devices linked */ + int llc1_nextppa; /* number to use for next PPA default */ + llc1_t *llc1_str_next, *llc1_str_prev; /* open streams */ +} llc1dev_t; + +#define LLC1_ATTACHED 0x0001 /* board is attached so mutexes are */ + /* initialized */ + + +/* + * definitions for debug tracing + */ +#define LLCTRACE 0x0001 /* basic procedure level tracing */ +#define LLCERRS 0x0002 /* trace errors */ +#define LLCRECV 0x0004 /* trace receive path */ +#define LLCSEND 0x0008 /* trace send path */ +#define LLCPROT 0x0010 /* trace DLPI protocol */ + +/* + * other definitions + */ +#define LLCE_OK -1 /* internal procedure status is OK */ +#define LLCE_NOBUFFER 0x1001 /* couldn't allocate a buffer */ + + +/* + * definitions for module_info + */ +#define LLC1IDNUM 0x8022 +#define LLC1_HIWATER 32000 /* high water mark for flow control */ +#define LLC1_LOWATER 4096 /* low water mark for flow control */ +#define LLC1_DEFMAX 4096 /* default max packet size */ + +/* address format for unitdata */ + +struct llcaddr { + unsigned char llca_addr[ETHERADDRL]; + unsigned char llca_sap; +}; +#define LLCADDR(p, offset) ((struct llcaddr *)(((caddr_t)(p))+(offset))) + +struct llcsaddr { + unsigned char llca_saddr[ETHERADDRL]; + unsigned short llca_ssap; +}; +#define LLCSADDR(p, offset) ((struct llcsaddr *)(((caddr_t)(p))+(offset))) + +/* + * 802.2 specific declarations + */ +struct llchdr { + unsigned char llc_dsap; + unsigned char llc_ssap; + unsigned char llc_ctl; +}; +struct llchdr_xid { + unsigned char llcx_format; + unsigned char llcx_class; + unsigned char llcx_window; +}; +struct snaphdr { + uchar_t snap_oid[3]; + uchar_t snap_type[2]; +}; + +#define LLC_UI 0x3 +#define LLC_XID 0xAF +#define LLC_TEST 0xE3 +#define LLC_P 0x10 /* P bit for use with XID/TEST */ +#define LLC_XID_FMTID 0x81 /* XID format identifier */ +#define LLC_SERVICES 0x01 /* Services supported */ +#define LLC_GLOBAL_SAP 0XFF /* Global SAP address */ +#define LLC_NULL_SAP 0x00 +#define LLC_SNAP_SAP 0xAA /* SNAP SAP */ +#define LLC_GROUP_ADDR 0x01 /* indication in DSAP of a group address */ +#define LLC_RESPONSE 0x01 /* indication in SSAP of a response */ +#define LLC_NOVELL_SAP -1 /* indicator that Novell 802.3 mode is used */ + +#define LLC_XID_INFO_SIZE 3 /* length of the INFO field */ +#define LLC_XID_CLASS_I (0x01) /* Class I */ +#define LLC_XID_CLASS_II (0x03) /* Class II */ +#define LLC_XID_CLASS_III (0x05) /* Class III */ +#define LLC_XID_CLASS_IV (0x07) /* Class IV */ + +/* Types can be or'd together */ +#define LLC_XID_TYPE_1 (0x01) /* Type 1 */ +#define LLC_XID_TYPE_2 (0x02) /* Type 2 */ +#define LLC_XID_TYPE_3 (0x04) /* Type 3 */ + +#define LLC1_CSMACD_HDR_SIZE (2*ETHERADDRL+2) + +#define ismulticast(cp) ((*(caddr_t)(cp)) & 0x01) + +/* + * special ioctl calls for SunSelect LLC2 conformance + */ +#define L_GETPPA (('L'<<8)|1) +#define L_SETPPA (('L'<<8)|2) +#define L_GETSTATS (('L'<<8)|5) +#define L_ZEROSTATS (('L'<<8)|6) + +#define LI_SPPA 0x02 /* type of snioc structure */ + +struct ll_snioc { + uchar_t lli_type; + uchar_t lli_spare[3]; + int lli_ppa; + int lli_index; +}; + +/* + * version of insque/remque for use by this driver + */ +struct qelem { + struct qelem *q_forw; + struct qelem *q_back; + /* rest of structure */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LLC1_H */ diff --git a/illumos-x86_64/usr/include/sys/loadavg.h b/illumos-x86_64/usr/include/sys/loadavg.h new file mode 100644 index 00000000..b7ffc11b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/loadavg.h @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2014 Igor Kozhukhov . + * Use is subject to license terms. + */ + +#ifndef _SYS_LOADAVG_H +#define _SYS_LOADAVG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LOADAVG_1MIN 0 +#define LOADAVG_5MIN 1 +#define LOADAVG_15MIN 2 + +#define LOADAVG_NSTATS 3 + +#define S_LOADAVG_SZ 11 +#define S_MOVAVG_SZ 10 + +struct loadavg_s { + int lg_cur; /* current loadavg entry */ + unsigned int lg_len; /* number entries recorded */ + hrtime_t lg_total; /* used to temporarily hold load totals */ + hrtime_t lg_loads[S_LOADAVG_SZ]; /* table of recorded entries */ +}; + +#ifdef _KERNEL + +extern int getloadavg(int *, int); + +#else /* _KERNEL */ + +/* + * This is the user API + */ +extern int getloadavg(double [], int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LOADAVG_H */ diff --git a/illumos-x86_64/usr/include/sys/lock.h b/illumos-x86_64/usr/include/sys/lock.h new file mode 100644 index 00000000..899364db --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lock.h @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_LOCK_H +#define _SYS_LOCK_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * flags for locking procs and texts + */ +#define UNLOCK 0 +#define PROCLOCK 1 +#define TXTLOCK 2 +#define DATLOCK 4 + +#ifdef _KERNEL + +#define MEMLOCK 8 + +int punlock(void); + +#else + +int plock(int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LOCK_H */ diff --git a/illumos-x86_64/usr/include/sys/lockfs.h b/illumos-x86_64/usr/include/sys/lockfs.h new file mode 100644 index 00000000..5d5b2f2c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lockfs.h @@ -0,0 +1,101 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_LOCKFS_H +#define _SYS_LOCKFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _SYSCALL32 +/* + * ILP32 version of lockfs, used in ufs_ioctl() to support 32-bit app in + * LP64 kernel + */ +struct lockfs32 { + uint32_t lf_lock; /* desired lock */ + uint32_t lf_flags; /* misc flags */ + uint32_t lf_key; /* lock key */ + uint32_t lf_comlen; /* length of comment */ + uint32_t lf_comment; /* address of comment */ +}; +#endif /* _SYSCALL32 */ + +struct lockfs { + ulong_t lf_lock; /* desired lock */ + ulong_t lf_flags; /* misc flags */ + ulong_t lf_key; /* lock key */ + ulong_t lf_comlen; /* length of comment */ + caddr_t lf_comment; /* address of comment */ +}; + +/* + * lf_lock and lf_locking + */ +#define LOCKFS_ULOCK 0 /* unlock */ +#define LOCKFS_WLOCK 1 /* write lock */ +#define LOCKFS_NLOCK 2 /* name lock */ +#define LOCKFS_DLOCK 3 /* delete lock */ +#define LOCKFS_HLOCK 4 /* hard lock */ +#define LOCKFS_ELOCK 5 /* error lock */ +#define LOCKFS_ROELOCK 6 /* error lock (read-only) - unimplemented */ +#define LOCKFS_MAXLOCK 6 /* maximum lock number */ + +/* + * lf_flags + */ +#define LOCKFS_BUSY 0x00000001 /* lock is being set */ +#define LOCKFS_MOD 0x00000002 /* file system modified */ + +#define LOCKFS_MAXCOMMENTLEN 1024 /* maximum comment length */ + +/* + * some nice checking macros + */ + +#define LOCKFS_IS_BUSY(LF) ((LF)->lf_flags & LOCKFS_BUSY) +#define LOCKFS_IS_MOD(LF) ((LF)->lf_flags & LOCKFS_MOD) + +#define LOCKFS_CLR_BUSY(LF) ((LF)->lf_flags &= ~LOCKFS_BUSY) +#define LOCKFS_CLR_MOD(LF) ((LF)->lf_flags &= ~LOCKFS_MOD) + +#define LOCKFS_SET_MOD(LF) ((LF)->lf_flags |= LOCKFS_MOD) +#define LOCKFS_SET_BUSY(LF) ((LF)->lf_flags |= LOCKFS_BUSY) + +#define LOCKFS_IS_WLOCK(LF) ((LF)->lf_lock == LOCKFS_WLOCK) +#define LOCKFS_IS_HLOCK(LF) ((LF)->lf_lock == LOCKFS_HLOCK) +#define LOCKFS_IS_ROELOCK(LF) ((LF)->lf_lock == LOCKFS_ROELOCK) +#define LOCKFS_IS_ELOCK(LF) ((LF)->lf_lock == LOCKFS_ELOCK) +#define LOCKFS_IS_ULOCK(LF) ((LF)->lf_lock == LOCKFS_ULOCK) +#define LOCKFS_IS_NLOCK(LF) ((LF)->lf_lock == LOCKFS_NLOCK) +#define LOCKFS_IS_DLOCK(LF) ((LF)->lf_lock == LOCKFS_DLOCK) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LOCKFS_H */ diff --git a/illumos-x86_64/usr/include/sys/lockstat.h b/illumos-x86_64/usr/include/sys/lockstat.h new file mode 100644 index 00000000..f2a10dcc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lockstat.h @@ -0,0 +1,192 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_LOCKSTAT_H +#define _SYS_LOCKSTAT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define LS_MUTEX_ENTER_ACQUIRE 0 +#define LS_MUTEX_ENTER_BLOCK 1 +#define LS_MUTEX_ENTER_SPIN 2 +#define LS_MUTEX_EXIT_RELEASE 3 +#define LS_MUTEX_DESTROY_RELEASE 4 +#define LS_MUTEX_TRYENTER_ACQUIRE 5 +#define LS_LOCK_SET_ACQUIRE 6 +#define LS_LOCK_SET_SPIN 7 +#define LS_LOCK_SET_SPL_ACQUIRE 8 +#define LS_LOCK_SET_SPL_SPIN 9 +#define LS_LOCK_TRY_ACQUIRE 10 +#define LS_LOCK_CLEAR_RELEASE 11 +#define LS_LOCK_CLEAR_SPLX_RELEASE 12 +#define LS_CLOCK_UNLOCK_RELEASE 13 +#define LS_RW_ENTER_ACQUIRE 14 +#define LS_RW_ENTER_BLOCK 15 +#define LS_RW_EXIT_RELEASE 16 +#define LS_RW_TRYENTER_ACQUIRE 17 +#define LS_RW_TRYUPGRADE_UPGRADE 18 +#define LS_RW_DOWNGRADE_DOWNGRADE 19 +#define LS_THREAD_LOCK_ACQUIRE 20 +#define LS_THREAD_LOCK_SPIN 21 +#define LS_THREAD_LOCK_HIGH_ACQUIRE 22 +#define LS_THREAD_LOCK_HIGH_SPIN 23 +#define LS_TURNSTILE_INTERLOCK_SPIN 24 +#define LS_NPROBES 25 + +#define LS_MUTEX_ENTER "mutex_enter" +#define LS_MUTEX_EXIT "mutex_exit" +#define LS_MUTEX_DESTROY "mutex_destroy" +#define LS_MUTEX_TRYENTER "mutex_tryenter" +#define LS_LOCK_SET "lock_set" +#define LS_LOCK_SET_SPL "lock_set_spl" +#define LS_LOCK_TRY "lock_try" +#define LS_LOCK_CLEAR "lock_clear" +#define LS_LOCK_CLEAR_SPLX "lock_clear_splx" +#define LS_CLOCK_UNLOCK "CLOCK_UNLOCK" +#define LS_RW_ENTER "rw_enter" +#define LS_RW_EXIT "rw_exit" +#define LS_RW_TRYENTER "rw_tryenter" +#define LS_RW_TRYUPGRADE "rw_tryupgrade" +#define LS_RW_DOWNGRADE "rw_downgrade" +#define LS_THREAD_LOCK "thread_lock" +#define LS_THREAD_LOCK_HIGH "thread_lock_high" + +#define LS_ACQUIRE "acquire" +#define LS_RELEASE "release" +#define LS_SPIN "spin" +#define LS_BLOCK "block" +#define LS_UPGRADE "upgrade" +#define LS_DOWNGRADE "downgrade" + +#define LS_TYPE_ADAPTIVE "adaptive" +#define LS_TYPE_SPIN "spin" +#define LS_TYPE_THREAD "thread" +#define LS_TYPE_RW "rw" + +#define LSA_ACQUIRE (LS_TYPE_ADAPTIVE "-" LS_ACQUIRE) +#define LSA_RELEASE (LS_TYPE_ADAPTIVE "-" LS_RELEASE) +#define LSA_SPIN (LS_TYPE_ADAPTIVE "-" LS_SPIN) +#define LSA_BLOCK (LS_TYPE_ADAPTIVE "-" LS_BLOCK) +#define LSS_ACQUIRE (LS_TYPE_SPIN "-" LS_ACQUIRE) +#define LSS_RELEASE (LS_TYPE_SPIN "-" LS_RELEASE) +#define LSS_SPIN (LS_TYPE_SPIN "-" LS_SPIN) +#define LSR_ACQUIRE (LS_TYPE_RW "-" LS_ACQUIRE) +#define LSR_RELEASE (LS_TYPE_RW "-" LS_RELEASE) +#define LSR_BLOCK (LS_TYPE_RW "-" LS_BLOCK) +#define LSR_UPGRADE (LS_TYPE_RW "-" LS_UPGRADE) +#define LSR_DOWNGRADE (LS_TYPE_RW "-" LS_DOWNGRADE) +#define LST_SPIN (LS_TYPE_THREAD "-" LS_SPIN) + +#ifndef _ASM + +#include +#include +#include +#include + +#ifdef _KERNEL + +/* + * Platform-independent kernel support for the lockstat driver. + */ +extern dtrace_id_t lockstat_probemap[LS_NPROBES]; +extern void (*lockstat_probe)(dtrace_id_t, uintptr_t, uintptr_t, + uintptr_t, uintptr_t, uintptr_t); + +extern int lockstat_active_threads(void); +extern int lockstat_depth(void); +extern void lockstat_hotpatch_probe(int); + +/* + * Macros to record lockstat probes. + */ + +/* used for 32 bit systems to avoid overflow */ +#if defined(_ILP32) +#define CLAMP32(x) ((x) > UINT_MAX ? UINT_MAX : (x)) +#else +#define CLAMP32(x) (x) +#endif + +#define LOCKSTAT_RECORD4(probe, lp, arg0, arg1, arg2, arg3) \ + if (lockstat_probemap[(probe)]) { \ + dtrace_id_t id; \ + curthread->t_lockstat++; \ + membar_enter(); \ + if ((id = lockstat_probemap[(probe)]) != 0) \ + (*lockstat_probe)(id, (uintptr_t)(lp), (arg0), \ + (arg1), (arg2), (arg3)); \ + curthread->t_lockstat--; \ + } + +#define LOCKSTAT_RECORD(probe, lp, arg) \ + LOCKSTAT_RECORD4(probe, lp, arg, 0, 0, 0) + +#define LOCKSTAT_RECORD0(probe, lp) \ + LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0) + +/* + * Return timestamp for start of busy-waiting (for spin probes) + */ +#define LOCKSTAT_START_TIME(probe) ( \ + lockstat_probemap[(probe)] ? gethrtime_waitfree() : 0 \ +) + +/* + * Record elapsed time since LOCKSTAT_START_TIME was called if the + * probe is enabled at start and end, else return 0. t_start must + * be the value returned by LOCKSTAT_START_TIME. + */ +#define LOCKSTAT_RECORD_TIME(probe, lp, t_start) \ + if (lockstat_probemap[(probe)]) { \ + dtrace_id_t id; \ + hrtime_t t_spin = (t_start); \ + curthread->t_lockstat++; \ + membar_enter(); \ + if ((id = lockstat_probemap[(probe)]) != 0) { \ + if (t_spin) { \ + t_spin = gethrtime_waitfree() - t_spin; \ + t_spin = CLAMP32(t_spin); \ + } \ + (*lockstat_probe)(id, (uintptr_t)(lp), t_spin, \ + 0, 0, 0); \ + } \ + curthread->t_lockstat--; \ + } + + +#endif /* _KERNEL */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LOCKSTAT_H */ diff --git a/illumos-x86_64/usr/include/sys/lofi.h b/illumos-x86_64/usr/include/sys/lofi.h new file mode 100644 index 00000000..03681b8e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lofi.h @@ -0,0 +1,342 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2016 Andrey Sokolov + * Copyright 2016 Toomas Soome + */ + +#ifndef _SYS_LOFI_H +#define _SYS_LOFI_H + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef _KERNEL +#include +#include +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * /dev names: + * /dev/lofictl - master control device + * /dev/lofi - block devices, named by minor number + * /dev/rlofi - character devices, named by minor number + */ +#define LOFI_DRIVER_NAME "lofi" +#define LOFI_CTL_NODE "ctl" +#define LOFI_CTL_NAME LOFI_DRIVER_NAME LOFI_CTL_NODE +#define LOFI_BLOCK_NODE "disk" +#define LOFI_CHAR_NODE LOFI_BLOCK_NODE ",raw" +#define LOFI_BLOCK_NAME LOFI_DRIVER_NAME +#define LOFI_CHAR_NAME "r" LOFI_DRIVER_NAME + +#define SEGHDR 1 +#define COMPRESSED 1 +#define UNCOMPRESSED 0 +#define MAXALGLEN 36 + +#define LOFI_CMLB_SHIFT CMLBUNIT_FORCE_P0_SHIFT +#define LOFI_PART_MASK ((1 << LOFI_CMLB_SHIFT) - 1) +#define LOFI_PART_MAX (1 << LOFI_CMLB_SHIFT) +#define LOFI_PART(x) ((x) & LOFI_PART_MASK) + +/* + * The cmlb is using its own range of minor numbers for partitions, for + * unlabeled lofi devices, we need to use another range. + */ +/* unlabeled lofi device id to minor number. */ +#define LOFI_ID2MINOR(x) ((x) << LOFI_CMLB_SHIFT) +/* lofi id from minor number. */ +#define LOFI_MINOR2ID(x) ((x) >> LOFI_CMLB_SHIFT) + +/* + * + * Use is: + * ld = open("/dev/lofictl", O_RDWR | O_EXCL); + * + * lofi must be opened exclusively. Access is controlled by permissions on + * the device, which is 644 by default. Write-access is required for ioctls + * that change state, but only read-access is required for the ioctls that + * return information. Basically, only root can add and remove files, but + * non-root can look at the current lists. + * + * ioctl usage: + * + * kernel ioctls + * + * strcpy(li.li_filename, "somefilename"); + * ioctl(ld, LOFI_MAP_FILE, &li); + * newminor = li.li_minor; + * + * strcpy(li.li_filename, "somefilename"); + * ioctl(ld, LOFI_UNMAP_FILE, &li); + * + * strcpy(li.li_filename, "somefilename"); + * li.li_minor = minor_number; + * ioctl(ld, LOFI_MAP_FILE_MINOR, &li); + * + * li.li_minor = minor_number; + * ioctl(ld, LOFI_UNMAP_FILE_MINOR, &li); + * + * li.li_minor = minor_number; + * ioctl(ld, LOFI_GET_FILENAME, &li); + * filename = li.li_filename; + * encrypted = li.li_crypto_enabled; + * + * strcpy(li.li_filename, "somefilename"); + * ioctl(ld, LOFI_GET_MINOR, &li); + * minor = li.li_minor; + * + * li.li_minor = 0; + * ioctl(ld, LOFI_GET_MAXMINOR, &li); + * maxminor = li.li_minor; + * + * strcpy(li.li_filename, "somefilename"); + * li.li_minor = 0; + * ioctl(ld, LOFI_CHECK_COMPRESSED, &li); + * + * If the 'li_force' flag is set for any of the LOFI_UNMAP_* commands, then if + * the device is busy, the underlying vnode will be closed, and any subsequent + * operations will fail. It will behave as if the device had been forcibly + * removed, so the DKIOCSTATE ioctl will return DKIO_DEV_GONE. When the device + * is last closed, it will be torn down. + * + * If the 'li_cleanup' flag is set for any of the LOFI_UNMAP_* commands, then + * if the device is busy, it is marked for removal at the next time it is + * no longer held open by anybody. When the device is last closed, it will be + * torn down. + * + * Oh, and last but not least: these ioctls are totally private and only + * for use by lofiadm(8). + * + */ + +typedef enum iv_method { + IVM_NONE, /* no iv needed, iv is null */ + IVM_ENC_BLKNO /* iv is logical block no. encrypted */ +} iv_method_t; + +struct lofi_ioctl { + uint32_t li_id; /* lofi ID */ + boolean_t li_force; + boolean_t li_cleanup; + boolean_t li_readonly; + boolean_t li_labeled; + char li_filename[MAXPATHLEN]; + char li_devpath[MAXPATHLEN]; + + /* the following fields are required for compression support */ + char li_algorithm[MAXALGLEN]; + + /* the following fields are required for encryption support */ + boolean_t li_crypto_enabled; + crypto_mech_name_t li_cipher; /* for data */ + uint32_t li_key_len; /* for data */ + char li_key[56]; /* for data: max 448-bit Blowfish key */ + crypto_mech_name_t li_iv_cipher; /* for iv derivation */ + uint32_t li_iv_len; /* for iv derivation */ + iv_method_t li_iv_type; /* for iv derivation */ +}; + +#define LOFI_IOC_BASE (('L' << 16) | ('F' << 8)) + +#define LOFI_MAP_FILE (LOFI_IOC_BASE | 0x01) +#define LOFI_MAP_FILE_MINOR (LOFI_IOC_BASE | 0x02) +#define LOFI_UNMAP_FILE (LOFI_IOC_BASE | 0x03) +#define LOFI_UNMAP_FILE_MINOR (LOFI_IOC_BASE | 0x04) +#define LOFI_GET_FILENAME (LOFI_IOC_BASE | 0x05) +#define LOFI_GET_MINOR (LOFI_IOC_BASE | 0x06) +#define LOFI_GET_MAXMINOR (LOFI_IOC_BASE | 0x07) +#define LOFI_CHECK_COMPRESSED (LOFI_IOC_BASE | 0x08) + +/* + * file types that might be usable with lofi, maybe. Only regular + * files are documented though. + */ +#define S_ISLOFIABLE(mode) \ + (S_ISREG(mode) || S_ISBLK(mode) || S_ISCHR(mode)) + +/* + * The basis for CRYOFF is derived from usr/src/uts/common/sys/fs/ufs_fs.h. + * Crypto metadata, if it exists, is located at the end of the boot block + * (BBOFF + BBSIZE, which is SBOFF). The super block and everything after + * is offset by the size of the crypto metadata which is handled by + * lsp->ls_crypto_offset. + */ +#define CRYOFF ((off_t)8192) + +#define LOFI_CRYPTO_MAGIC { 'C', 'F', 'L', 'O', 'F', 'I' } + +#if defined(_KERNEL) + + +/* + * Cache decompressed data segments for the compressed lofi images. + * + * To avoid that we have to decompress data of a compressed + * segment multiple times when accessing parts of the segment's + * data we cache the uncompressed data, using a simple linked list. + */ +struct lofi_comp_cache { + list_node_t lc_list; /* linked list */ + uchar_t *lc_data; /* decompressed segment data */ + uint64_t lc_index; /* segment index */ +}; + +#define V_ISLOFIABLE(vtype) \ + ((vtype == VREG) || (vtype == VBLK) || (vtype == VCHR)) + +/* + * Pre-allocated memory buffers for the purpose of compression + */ +struct compbuf { + void *buf; + uint32_t bufsize; + int inuse; +}; + +/* + * Need exactly 6 bytes to identify encrypted lofi image + */ +extern const char lofi_crypto_magic[6]; +#define LOFI_CRYPTO_VERSION ((uint16_t)0) +#define LOFI_CRYPTO_DATA_SECTOR ((uint32_t)16) /* for version 0 */ + +/* + * Crypto metadata for encrypted lofi images + * The fields here only satisfy initial implementation requirements. + */ +struct crypto_meta { + char magic[6]; /* LOFI_CRYPTO_MAGIC */ + uint16_t version; /* version of encrypted lofi */ + char reserved1[96]; /* future use */ + uint32_t data_sector; /* start of data area */ + char pad[404]; /* end on DEV_BSIZE bdry */ + /* second header block is not defined at this time */ +}; + +struct lofi_state { + vnode_t *ls_vp; /* open real vnode */ + vnode_t *ls_stacked_vp; /* open vnode */ + kmutex_t ls_vp_lock; /* protects ls_vp */ + kcondvar_t ls_vp_cv; /* signal changes to ls_vp */ + uint32_t ls_vp_iocount; /* # pending I/O requests */ + boolean_t ls_vp_closereq; /* force close requested */ + boolean_t ls_vp_ready; /* is vp ready for use? */ + u_offset_t ls_vp_size; + uint32_t ls_open_lyr[LOFI_PART_MAX]; /* open count */ + uint64_t ls_open_reg[OTYPCNT]; /* bitmask */ + uint64_t ls_open_excl; /* bitmask */ + int ls_openflag; + boolean_t ls_cleanup; /* cleanup on close */ + boolean_t ls_readonly; + boolean_t ls_canfree; /* supports DKIOCFREE */ + taskq_t *ls_taskq; + kstat_t *ls_kstat; + kmutex_t ls_kstat_lock; + struct dk_geom ls_dkg; + zone_ref_t ls_zone; + list_node_t ls_list; /* all lofis */ + dev_info_t *ls_dip; + dev_t ls_dev; /* this node's dev_t */ + + cmlb_handle_t ls_cmlbhandle; + uint32_t ls_lbshift; /* logical block shift */ + uint32_t ls_pbshift; /* physical block shift */ + + /* the following fields are required for compression support */ + int ls_comp_algorithm_index; /* idx into compress_table */ + char ls_comp_algorithm[MAXALGLEN]; + uint32_t ls_uncomp_seg_sz; /* sz of uncompressed segment */ + uint32_t ls_comp_index_sz; /* number of index entries */ + uint32_t ls_comp_seg_shift; /* exponent for byte shift */ + uint32_t ls_uncomp_last_seg_sz; /* sz of last uncomp segment */ + uint64_t ls_comp_offbase; /* offset of actual compressed data */ + uint64_t *ls_comp_seg_index; /* array of index entries */ + caddr_t ls_comp_index_data; /* index pages loaded from file */ + uint32_t ls_comp_index_data_sz; + u_offset_t ls_vp_comp_size; /* actual compressed file size */ + + /* pre-allocated list of buffers for compressed segment data */ + kmutex_t ls_comp_bufs_lock; + struct compbuf *ls_comp_bufs; + + /* lock and anchor for compressed segment caching */ + kmutex_t ls_comp_cache_lock; /* protects ls_comp_cache */ + list_t ls_comp_cache; /* cached decompressed segs */ + uint32_t ls_comp_cache_count; + + /* the following fields are required for encryption support */ + boolean_t ls_crypto_enabled; + u_offset_t ls_crypto_offset; /* crypto meta size */ + struct crypto_meta ls_crypto; + crypto_mechanism_t ls_mech; /* for data encr/decr */ + crypto_key_t ls_key; /* for data encr/decr */ + crypto_mechanism_t ls_iv_mech; /* for iv derivation */ + size_t ls_iv_len; /* for iv derivation */ + iv_method_t ls_iv_type; /* for iv derivation */ + kmutex_t ls_crypto_lock; + crypto_ctx_template_t ls_ctx_tmpl; +}; + +#endif /* _KERNEL */ + +/* + * Common signature for all lofi compress functions + */ +typedef int lofi_compress_func_t(void *src, size_t srclen, void *dst, + size_t *destlen, int level); + +/* + * Information about each compression function + */ +typedef struct lofi_compress_info { + lofi_compress_func_t *l_decompress; + lofi_compress_func_t *l_compress; + int l_level; + char *l_name; /* algorithm name */ +} lofi_compress_info_t; + +enum lofi_compress { + LOFI_COMPRESS_GZIP = 0, + LOFI_COMPRESS_GZIP_6 = 1, + LOFI_COMPRESS_GZIP_9 = 2, + LOFI_COMPRESS_LZMA = 3, + LOFI_COMPRESS_FUNCTIONS +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LOFI_H */ diff --git a/illumos-x86_64/usr/include/sys/log.h b/illumos-x86_64/usr/include/sys/log.h new file mode 100644 index 00000000..934b4111 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/log.h @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_LOG_H +#define _SYS_LOG_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define LOG_CONSMIN 0 /* /dev/conslog minor */ +#define LOG_LOGMIN 5 /* /dev/log minor */ +#define LOG_BACKLOG LOG_LOGMIN /* console backlog queue */ + +#define LOG_LOGMINIDX 0 /* index of smallest /dev/log clone */ +#define LOG_LOGMAXIDX 15 /* up to 16 /dev/log clones */ +#define LOG_NUMCLONES (LOG_LOGMAXIDX - LOG_LOGMINIDX + 1) + +#define LOG_MID 44 /* module ID */ +#define LOG_MINPS 0 /* min packet size */ +#define LOG_MAXPS 1024 /* max packet size */ +#define LOG_LOWAT 2048 /* threshold for backenable */ +#define LOG_HIWAT 1048576 /* threshold for tossing messages */ + +#define LOG_MAGIC 0xf00d4109U /* "food for log" - unsent msg magic */ +#define LOG_RECENTSIZE 65536 /* queue of most recent messages */ +#define LOG_MINFREE 4096 /* message cache low water mark */ +#define LOG_MAXFREE 8192 /* message cache high water mark */ + +typedef struct log log_t; +typedef int (log_filter_t)(log_t *, log_ctl_t *); + +struct log { + queue_t *log_q; /* message queue */ + log_filter_t *log_wanted; /* message filter */ + mblk_t *log_data; /* parameters for filter */ + uint16_t log_flags; /* message type (e.g. SL_CONSOLE) */ + short log_inuse; /* is this log device open? */ + int log_overflow; /* messages lost due to QFULL */ + zoneid_t log_zoneid; /* zone id of log */ + major_t log_major; /* device type */ + minor_t log_minor; /* minor number of associated device */ +}; + +/* Array of /dev/log minor devices */ +typedef struct log_zone { + log_t lz_clones[LOG_NUMCLONES]; + uint16_t lz_active; /* active types (OR of all log_flags fields) */ +} log_zone_t; + +#define LOG_MSGSIZE 200 + +typedef struct log_dump { + uint32_t ld_magic; /* LOG_MAGIC */ + uint32_t ld_msgsize; /* MBLKL(mp->b_cont) */ + uint32_t ld_csum; /* checksum32(log_ctl) */ + uint32_t ld_msum; /* checksum32(message text) */ + /* + * log_ctl and message text follow here -- see dump_messages() + */ +} log_dump_t; + +#ifdef _KERNEL + +/* global zone variables */ +extern log_zone_t log_global; +extern queue_t *log_consq; /* primary console reader queue */ +extern queue_t *log_backlogq; /* console backlog queue */ +extern queue_t *log_intrq; /* pending high-level interrupt message queue */ + +extern log_filter_t log_error; +extern log_filter_t log_trace; +extern log_filter_t log_console; + +extern void log_init(void); +extern void log_enter(void); +extern void log_exit(void); +extern void log_update(log_t *, queue_t *, short, log_filter_t); +extern mblk_t *log_makemsg(int, int, int, int, int, void *, size_t, int); +extern void log_freemsg(mblk_t *); +extern void log_sendmsg(mblk_t *, zoneid_t); +extern void log_flushq(queue_t *); +extern void log_printq(queue_t *); +extern log_t *log_alloc(minor_t); +extern void log_free(log_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LOG_H */ diff --git a/illumos-x86_64/usr/include/sys/logindmux.h b/illumos-x86_64/usr/include/sys/logindmux.h new file mode 100644 index 00000000..cecc6b81 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/logindmux.h @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_LOGINDMUX_H +#define _SYS_LOGINDMUX_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct protocol_arg { + dev_t dev; + int flag; +}; + +#ifdef _SYSCALL32 +struct protocol_arg32 { + dev32_t dev; + int32_t flag; +}; +#endif + +/* + * Telnet magic cookie + */ +#define M_CTL_MAGIC_NUMBER 70 + +/* + * Ioctl to establish linkage between a pty master stream and a + * network stream. + */ +#ifndef TELIOC +#define TELIOC ('n' << 8) /* XXX.sparker fixme */ +#endif +#define LOGDMX_IOC_QEXCHANGE (TELIOC|1) /* ioctl for Q pair exchange */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LOGINDMUX_H */ diff --git a/illumos-x86_64/usr/include/sys/lpif.h b/illumos-x86_64/usr/include/sys/lpif.h new file mode 100644 index 00000000..168916f0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lpif.h @@ -0,0 +1,146 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + */ +#ifndef _LPIF_H +#define _LPIF_H + +/* + * Definitions for stmf LUs and lu providers. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define LPIF_REV_1 0x00010000 +#define LPIF_REV_2 0x00020000 + +typedef struct stmf_lu { + void *lu_stmf_private; + void *lu_provider_private; + + struct scsi_devid_desc *lu_id; + char *lu_alias; /* optional */ + struct stmf_lu_provider *lu_lp; + uint32_t lu_abort_timeout; /* In seconds */ + + /* SAM Device Server Class */ + stmf_status_t (*lu_task_alloc)(struct scsi_task *task); + void (*lu_new_task)(struct scsi_task *task, + struct stmf_data_buf *initial_dbuf); + void (*lu_dbuf_xfer_done)(struct scsi_task *task, + struct stmf_data_buf *dbuf); + /* + * If completion confirmation is not requested, status xfer done + * is called after the transport has confirmed that status has been + * sent. If completion confirmation is requested then the HBA will + * request a completion confirmation from the host and upon receiving + * the same, this entry point will be called. + */ + void (*lu_send_status_done)(struct scsi_task *task); + void (*lu_task_free)(struct scsi_task *task); + stmf_status_t (*lu_abort)(struct stmf_lu *lu, + int abort_cmd, void *arg, uint32_t flags); + void (*lu_task_poll)(struct scsi_task *task); + void (*lu_ctl)(struct stmf_lu *lu, int cmd, + void *arg); + stmf_status_t (*lu_info)(uint32_t cmd, struct stmf_lu *lu, + void *arg, uint8_t *buf, uint32_t *bufsizep); + void (*lu_event_handler)(struct stmf_lu *lu, + int eventid, void *arg, uint32_t flags); + void *lu_proxy_reg_arg; + uint32_t lu_proxy_reg_arg_len; + void (*lu_dbuf_free)(struct scsi_task *task, + struct stmf_data_buf *dbuf); + void (*lu_task_done)(struct scsi_task *task); +} stmf_lu_t; + +/* + * Abort cmd + */ +#define STMF_LU_ABORT_TASK 1 +#define STMF_LU_RESET_STATE 2 +#define STMF_LU_ITL_HANDLE_REMOVED 3 +#define STMF_LU_SET_ABORT 4 + +/* + * Asymmetric access state + */ +#define STMF_LU_ACTIVE 0 +#define STMF_LU_STANDBY 1 + +/* + * proxy register msg types + */ +#define STMF_MSG_LU_REGISTER 0 +#define STMF_MSG_LU_ACTIVE 1 +#define STMF_MSG_LU_DEREGISTER 2 + + +#define STMF_PROXY_READ 1 +#define STMF_PROXY_WRITE 2 + +/* + * Reasons for itl handle removal. Passed in flags. + */ +#define STMF_ITL_REASON_MASK 0x0f +#define STMF_ITL_REASON_UNKNOWN 0x0 +#define STMF_ITL_REASON_DEREG_REQUEST 0x1 +#define STMF_ITL_REASON_USER_REQUEST 0x2 +#define STMF_ITL_REASON_IT_NEXUS_LOSS 0x3 + +typedef struct stmf_lu_provider { + void *lp_stmf_private; + void *lp_private; + + uint32_t lp_lpif_rev; /* Currently LPIF_REV_2 */ + int lp_instance; + char *lp_name; + void (*lp_cb)(struct stmf_lu_provider *lp, + int cmd, void *arg, uint32_t flags); + uint8_t lp_alua_support; + stmf_status_t (*lp_proxy_msg)(uint8_t *luid, + void *proxy_reg_arg, uint32_t proxy_reg_arg_len, uint32_t type); +} stmf_lu_provider_t; + +stmf_status_t stmf_deregister_lu_provider(stmf_lu_provider_t *lp); +stmf_status_t stmf_register_lu_provider(stmf_lu_provider_t *lp); +stmf_status_t stmf_register_lu(stmf_lu_t *lup); +stmf_status_t stmf_deregister_lu(stmf_lu_t *lup); +stmf_status_t stmf_set_lu_access(stmf_lu_t *lup, uint8_t access_state); +stmf_status_t stmf_proxy_scsi_cmd(scsi_task_t *, stmf_data_buf_t *dbuf); +int stmf_is_standby_port(scsi_task_t *); +void stmf_lu_xfer_done(struct scsi_task *task, boolean_t read, + hrtime_t elapsed_time); +boolean_t stmf_is_pgr_aptpl_always(); + +#ifdef __cplusplus +} +#endif + +#endif /* _LPIF_H */ diff --git a/illumos-x86_64/usr/include/sys/lwp.h b/illumos-x86_64/usr/include/sys/lwp.h new file mode 100644 index 00000000..03081022 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lwp.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 2013 by Delphix. All rights reserved. + */ + +#ifndef _SYS_LWP_H +#define _SYS_LWP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * lwp create flags + */ +#define LWP_DAEMON 0x00000020 +#define LWP_DETACHED 0x00000040 +#define LWP_SUSPENDED 0x00000080 + +/* + * Definitions for user programs calling into the _lwp interface. + */ +struct lwpinfo { + timestruc_t lwp_utime; + timestruc_t lwp_stime; + long lwpinfo_pad[64]; +}; + +#if defined(_SYSCALL32) + +/* Kernel's view of user ILP32 lwpinfo structure */ + +struct lwpinfo32 { + timestruc32_t lwp_utime; + timestruc32_t lwp_stime; + int32_t lwpinfo_pad[64]; +}; + +#endif /* _SYSCALL32 */ + +typedef uint_t lwpid_t; + +#define _LWP_FSBASE 0 +#define _LWP_GSBASE 1 + +#define _LWP_SETPRIVATE 0 +#define _LWP_GETPRIVATE 1 + +#ifndef _KERNEL + +int _lwp_kill(lwpid_t, int); +int _lwp_info(struct lwpinfo *); +lwpid_t _lwp_self(void); +int _lwp_suspend(lwpid_t); +int _lwp_continue(lwpid_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LWP_H */ diff --git a/illumos-x86_64/usr/include/sys/lwp_timer_impl.h b/illumos-x86_64/usr/include/sys/lwp_timer_impl.h new file mode 100644 index 00000000..841ae37a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lwp_timer_impl.h @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_LWP_TIMER_IMPL_H +#define _SYS_LWP_TIMER_IMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + kthread_t *lwpt_thread; + timespec_t *lwpt_tsp; + timespec_t lwpt_rqtime; + int lwpt_timecheck; + uint_t lwpt_imm_timeout; + int lwpt_time_error; + callout_id_t lwpt_id; +} lwp_timer_t; + +#ifdef _KERNEL +extern int lwp_timer_copyin(lwp_timer_t *, timespec_t *); +extern int lwp_timer_enqueue(lwp_timer_t *); +extern clock_t lwp_timer_dequeue(lwp_timer_t *); +extern int lwp_timer_copyout(lwp_timer_t *, int); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LWP_TIMER_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/lwp_upimutex_impl.h b/illumos-x86_64/usr/include/sys/lwp_upimutex_impl.h new file mode 100644 index 00000000..53d0588f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/lwp_upimutex_impl.h @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_LWP_UPIMUTEX_IMPL_H +#define _SYS_LWP_UPIMUTEX_IMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct upimutex upimutex_t; +typedef struct upib upib_t; + +struct upib { + kmutex_t upib_lock; + upimutex_t *upib_first; +}; + +struct upimutex { + struct _kthread *upi_owner; /* owner */ + int upi_waiter; /* wait bit */ + upib_t *upi_upibp; /* point back to upib bucket in hash chain */ + lwp_mutex_t *upi_vaddr; /* virtual address, i.e. user lock ptr */ + lwpchan_t upi_lwpchan; /* lwpchan of virtual address */ + upimutex_t *upi_nextchain; /* next in hash chain */ + upimutex_t *upi_nextowned; /* list of mutexes owned by lwp */ +}; + +#define UPILWPCHAN_BITS 9 +#define UPILWPCHAN_TABSIZ (1 << UPILWPCHAN_BITS) +#define UPIMUTEX_TABSIZE UPILWPCHAN_TABSIZ +#define UPILWPCHAN_HASH(lwpchan) \ + (((uintptr_t)((lwpchan).lc_wchan0)^(uintptr_t)((lwpchan).lc_wchan)) ^ \ + (((uintptr_t)((lwpchan).lc_wchan0)^(uintptr_t)((lwpchan).lc_wchan)) >> \ + UPILWPCHAN_BITS)) & (UPIMUTEX_TABSIZE - 1) +#define UPI_CHAIN(lwpchan) upimutextab[UPILWPCHAN_HASH((lwpchan))] + +#define UPIMUTEX_TRY 1 +#define UPIMUTEX_BLOCK 0 + +#ifdef _KERNEL +extern void upimutex_cleanup(); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_LWP_UPIMUTEX_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/mac.h b/illumos-x86_64/usr/include/sys/mac.h new file mode 100644 index 00000000..d79d625f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mac.h @@ -0,0 +1,752 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2018 Joyent, Inc. + * Copyright (c) 2015 Garrett D'Amore + * Copyright 2020 RackTop Systems, Inc. + */ + +#ifndef _SYS_MAC_H +#define _SYS_MAC_H + +#include +#ifdef _KERNEL +#include +#endif + +/* + * MAC Services Module + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * MAC Information (text emitted by modinfo(8)) + */ +#define MAC_INFO "MAC Services" + +/* + * MAC-Type version identifier. This is used by mactype_alloc() and + * mactype_register() to verify that incompatible MAC-Type plugins don't + * register. + */ +#define MACTYPE_VERSION 0x1 + +/* + * Opaque handle types + */ +typedef struct __mac_handle *mac_handle_t; +typedef struct __mac_resource_handle *mac_resource_handle_t; +typedef struct __mac_notify_handle *mac_notify_handle_t; +typedef struct __mac_tx_notify_handle *mac_tx_notify_handle_t; +typedef struct __mac_intr_handle *mac_intr_handle_t; +typedef struct __mac_ring_handle *mac_ring_handle_t; +typedef struct __mac_group_handle *mac_group_handle_t; + +#define DATALINK_INVALID_LINKID 0 +#define DATALINK_ALL_LINKID 0 +#define DATALINK_MAX_LINKID 0xffffffff + +typedef enum { + LINK_STATE_UNKNOWN = -1, + LINK_STATE_DOWN, + LINK_STATE_UP +} link_state_t; + +typedef enum { + LINK_DUPLEX_UNKNOWN = 0, + LINK_DUPLEX_HALF, + LINK_DUPLEX_FULL +} link_duplex_t; + +typedef enum { + LINK_FLOWCTRL_NONE = 0, + LINK_FLOWCTRL_RX, + LINK_FLOWCTRL_TX, + LINK_FLOWCTRL_BI +} link_flowctrl_t; + +typedef enum { + LINK_FEC_NONE = 1 << 0, + LINK_FEC_AUTO = 1 << 1, + LINK_FEC_RS = 1 << 2, + LINK_FEC_BASE_R = 1 << 3 +} link_fec_t; + +typedef enum { + LINK_TAGMODE_VLANONLY = 0, + LINK_TAGMODE_NORMAL +} link_tagmode_t; + +/* + * Defines range of uint32_t values + */ +typedef struct mac_propval_uint32_range_s { + uint32_t mpur_min; + uint32_t mpur_max; +} mac_propval_uint32_range_t; + +/* + * Defines ranges which are a series of C style strings. + */ +typedef struct mac_propval_str_range_s { + uint32_t mpur_nextbyte; + char mpur_data[]; +} mac_propval_str_range_t; + +/* + * Data type of property values. + */ +typedef enum { + MAC_PROPVAL_UINT8, + MAC_PROPVAL_UINT32, + MAC_PROPVAL_STR +} mac_propval_type_t; + +/* + * Captures possible values for a given property. A property can have + * range of values (int32, int64, uint32, uint64, et al) or collection/ + * enumeration of values (strings). + * Can be used as a value-result parameter. + */ +typedef struct mac_propval_range_s { + uint_t mpr_count; /* count of ranges */ + mac_propval_type_t mpr_type; /* type of value */ + union { + mac_propval_uint32_range_t mpr_uint32[1]; + mac_propval_str_range_t mpr_str; + } u; +} mac_propval_range_t; + +#define mpr_range_uint32 u.mpr_uint32 + +/* + * Maximum MAC address length + */ +#define MAXMACADDRLEN 20 + +#define MPT_MAXMACADDR 32 + +typedef struct mac_secondary_addr_s { + uint32_t ms_addrcnt; + uint8_t ms_addrs[MPT_MAXMACADDR][MAXMACADDRLEN]; +} mac_secondary_addr_t; + +typedef enum { + MAC_LOGTYPE_LINK = 1, + MAC_LOGTYPE_FLOW +} mac_logtype_t; + +#define MAXLINKPROPNAME 256 /* max property name len */ + +/* + * Public properties. + * + * Note that there are 2 sets of parameters: the *_EN_* values are + * those that the Administrator configures for autonegotiation. The + * _ADV_* values are those that are currently exposed over the wire. + * + * Please append properties to the end of this list. Do not reorder the list. + */ +typedef enum { + MAC_PROP_PRIVATE = -1, + MAC_PROP_DUPLEX = 0x00000001, + MAC_PROP_SPEED, + MAC_PROP_STATUS, + MAC_PROP_AUTONEG, + MAC_PROP_EN_AUTONEG, + MAC_PROP_MTU, + MAC_PROP_ZONE, + MAC_PROP_AUTOPUSH, + MAC_PROP_FLOWCTRL, + MAC_PROP_ADV_1000FDX_CAP, + MAC_PROP_EN_1000FDX_CAP, + MAC_PROP_ADV_1000HDX_CAP, + MAC_PROP_EN_1000HDX_CAP, + MAC_PROP_ADV_100FDX_CAP, + MAC_PROP_EN_100FDX_CAP, + MAC_PROP_ADV_100HDX_CAP, + MAC_PROP_EN_100HDX_CAP, + MAC_PROP_ADV_10FDX_CAP, + MAC_PROP_EN_10FDX_CAP, + MAC_PROP_ADV_10HDX_CAP, + MAC_PROP_EN_10HDX_CAP, + MAC_PROP_ADV_100T4_CAP, + MAC_PROP_EN_100T4_CAP, + MAC_PROP_IPTUN_HOPLIMIT, + MAC_PROP_IPTUN_ENCAPLIMIT, + MAC_PROP_WL_ESSID, + MAC_PROP_WL_BSSID, + MAC_PROP_WL_BSSTYPE, + MAC_PROP_WL_LINKSTATUS, + MAC_PROP_WL_DESIRED_RATES, + MAC_PROP_WL_SUPPORTED_RATES, + MAC_PROP_WL_AUTH_MODE, + MAC_PROP_WL_ENCRYPTION, + MAC_PROP_WL_RSSI, + MAC_PROP_WL_PHY_CONFIG, + MAC_PROP_WL_CAPABILITY, + MAC_PROP_WL_WPA, + MAC_PROP_WL_SCANRESULTS, + MAC_PROP_WL_POWER_MODE, + MAC_PROP_WL_RADIO, + MAC_PROP_WL_ESS_LIST, + MAC_PROP_WL_KEY_TAB, + MAC_PROP_WL_CREATE_IBSS, + MAC_PROP_WL_SETOPTIE, + MAC_PROP_WL_DELKEY, + MAC_PROP_WL_KEY, + MAC_PROP_WL_MLME, + MAC_PROP_TAGMODE, + MAC_PROP_ADV_10GFDX_CAP, + MAC_PROP_EN_10GFDX_CAP, + MAC_PROP_PVID, + MAC_PROP_LLIMIT, + MAC_PROP_LDECAY, + MAC_PROP_RESOURCE, + MAC_PROP_RESOURCE_EFF, + MAC_PROP_RXRINGSRANGE, + MAC_PROP_TXRINGSRANGE, + MAC_PROP_MAX_TX_RINGS_AVAIL, + MAC_PROP_MAX_RX_RINGS_AVAIL, + MAC_PROP_MAX_RXHWCLNT_AVAIL, + MAC_PROP_MAX_TXHWCLNT_AVAIL, + MAC_PROP_IB_LINKMODE, + MAC_PROP_VN_PROMISC_FILTERED, + MAC_PROP_SECONDARY_ADDRS, + MAC_PROP_ADV_40GFDX_CAP, + MAC_PROP_EN_40GFDX_CAP, + MAC_PROP_ADV_100GFDX_CAP, + MAC_PROP_EN_100GFDX_CAP, + MAC_PROP_ADV_2500FDX_CAP, + MAC_PROP_EN_2500FDX_CAP, + MAC_PROP_ADV_5000FDX_CAP, + MAC_PROP_EN_5000FDX_CAP, + MAC_PROP_ADV_25GFDX_CAP, + MAC_PROP_EN_25GFDX_CAP, + MAC_PROP_ADV_50GFDX_CAP, + MAC_PROP_EN_50GFDX_CAP, + MAC_PROP_EN_FEC_CAP, + MAC_PROP_ADV_FEC_CAP, + MAC_PROP_MEDIA, + MAC_PROP_ADV_200GFDX_CAP, + MAC_PROP_EN_200GFDX_CAP, + MAC_PROP_ADV_400GFDX_CAP, + MAC_PROP_EN_400GFDX_CAP, +} mac_prop_id_t; + +/* + * Flags to figure out r/w status of legacy ndd props. + */ +#define MAC_PROP_PERM_READ 0x0001 +#define MAC_PROP_PERM_WRITE 0x0010 +#define MAC_PROP_MAP_KSTAT 0x0100 +#define MAC_PROP_PERM_RW (MAC_PROP_PERM_READ|MAC_PROP_PERM_WRITE) +#define MAC_PROP_FLAGS_RK (MAC_PROP_PERM_READ|MAC_PROP_MAP_KSTAT) + +/* + * Valid LED mode bits + */ +typedef enum mac_led_mode { + MAC_LED_DEFAULT = (1 << 0), + MAC_LED_OFF = (1 << 1), + MAC_LED_IDENT = (1 << 2), + MAC_LED_ON = (1 << 3) +} mac_led_mode_t; + + +#ifdef _KERNEL + +/* + * There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are + * interface statistics maintained by the mac module. MAC_STAT_MIN to 1 - + * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and + * maintained by each driver. MACTYPE_STAT_MIN and above are statistics + * defined by MAC-Type plugins and maintained by each driver. + */ +#define MAC_STAT_MIN 1000 +#define MACTYPE_STAT_MIN 2000 + +#define IS_MAC_STAT(stat) \ + (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN) +#define IS_MACTYPE_STAT(stat) (stat >= MACTYPE_STAT_MIN) + +/* + * Statistics maintained by the mac module, and possibly populated as link + * statistics. + */ +enum mac_mod_stat { + MAC_STAT_LINK_STATE, + MAC_STAT_LINK_UP, + MAC_STAT_PROMISC, + MAC_STAT_LOWLINK_STATE, + MAC_STAT_HDROPS +}; + +/* + * Do not reorder, and add only to the end of this list. + */ +enum mac_driver_stat { + /* MIB-II stats (RFC 1213 and RFC 1573) */ + MAC_STAT_IFSPEED = MAC_STAT_MIN, + MAC_STAT_MULTIRCV, + MAC_STAT_BRDCSTRCV, + MAC_STAT_MULTIXMT, + MAC_STAT_BRDCSTXMT, + MAC_STAT_NORCVBUF, + MAC_STAT_IERRORS, + MAC_STAT_UNKNOWNS, + MAC_STAT_NOXMTBUF, + MAC_STAT_OERRORS, + MAC_STAT_COLLISIONS, + MAC_STAT_RBYTES, + MAC_STAT_IPACKETS, + MAC_STAT_OBYTES, + MAC_STAT_OPACKETS, + MAC_STAT_UNDERFLOWS, + MAC_STAT_OVERFLOWS +}; + +#define MAC_NSTAT (MAC_STAT_OVERFLOWS - MAC_STAT_IFSPEED + 1) + +#define MAC_STAT_ISACOUNTER(_stat) ( \ + (_stat) == MAC_STAT_MULTIRCV || \ + (_stat) == MAC_STAT_BRDCSTRCV || \ + (_stat) == MAC_STAT_MULTIXMT || \ + (_stat) == MAC_STAT_BRDCSTXMT || \ + (_stat) == MAC_STAT_NORCVBUF || \ + (_stat) == MAC_STAT_IERRORS || \ + (_stat) == MAC_STAT_UNKNOWNS || \ + (_stat) == MAC_STAT_NOXMTBUF || \ + (_stat) == MAC_STAT_OERRORS || \ + (_stat) == MAC_STAT_COLLISIONS || \ + (_stat) == MAC_STAT_RBYTES || \ + (_stat) == MAC_STAT_IPACKETS || \ + (_stat) == MAC_STAT_OBYTES || \ + (_stat) == MAC_STAT_OPACKETS || \ + (_stat) == MAC_STAT_UNDERFLOWS || \ + (_stat) == MAC_STAT_OVERFLOWS) + +/* + * Immutable information. (This may not be modified after registration). + */ +typedef struct mac_info_s { + uint_t mi_media; + uint_t mi_nativemedia; + uint_t mi_addr_length; + uint8_t *mi_unicst_addr; + uint8_t *mi_brdcst_addr; +} mac_info_t; + +/* + * When VNICs are created on top of the NIC, there are two levels + * of MAC layer, a lower MAC, which is the MAC layer at the level of the + * physical NIC, and an upper MAC, which is the MAC layer at the level + * of the VNIC. Each VNIC maps to a MAC client at the lower MAC, and + * the SRS and classification is done at the lower MAC level. The upper + * MAC is therefore for the most part pass-through, and therefore + * special processing needs to be done at the upper MAC layer when + * dealing with a VNIC. + * + * This capability allows the MAC layer to detect when a VNIC is being + * access, and implement the required shortcuts. + * + * In addition, this capability is used to keep the VNIC's secondary + * mac_clients in sync when the primary MAC is updated. + */ + +typedef void *(*mac_client_handle_fn_t)(void *); +typedef void (*mac_client_update_fn_t)(void *); + +typedef struct mac_capab_vnic_s { + void *mcv_arg; + mac_client_handle_fn_t mcv_mac_client_handle; + mac_client_update_fn_t mcv_mac_secondary_update; +} mac_capab_vnic_t; + +typedef void (*mac_rename_fn_t)(const char *, void *); +typedef mblk_t *(*mac_tx_ring_fn_t)(void *, mblk_t *, uintptr_t, + mac_ring_handle_t *); +typedef struct mac_capab_aggr_s { + mac_rename_fn_t mca_rename_fn; + int (*mca_unicst)(void *, const uint8_t *); + mac_tx_ring_fn_t mca_find_tx_ring_fn; + void *mca_arg; +} mac_capab_aggr_t; + +/* Bridge transmit and receive function signatures */ +typedef mblk_t *(*mac_bridge_tx_t)(mac_handle_t, mac_ring_handle_t, mblk_t *); +typedef void (*mac_bridge_rx_t)(mac_handle_t, mac_resource_handle_t, mblk_t *); +typedef void (*mac_bridge_ref_t)(mac_handle_t, boolean_t); +typedef link_state_t (*mac_bridge_ls_t)(mac_handle_t, link_state_t); + +/* must change mac_notify_cb_list[] in mac_provider.c if this is changed */ +typedef enum { + MAC_NOTE_LINK, + MAC_NOTE_UNICST, + MAC_NOTE_TX, + MAC_NOTE_DEVPROMISC, + MAC_NOTE_FASTPATH_FLUSH, + MAC_NOTE_SDU_SIZE, + MAC_NOTE_DEST, + MAC_NOTE_MARGIN, + MAC_NOTE_CAPAB_CHG, + MAC_NOTE_LOWLINK, + MAC_NOTE_ALLOWED_IPS, + MAC_NNOTE /* must be the last entry */ +} mac_notify_type_t; + +typedef void (*mac_notify_t)(void *, mac_notify_type_t); +typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *, + boolean_t); +typedef mblk_t *(*mac_receive_t)(void *, size_t); + +/* + * MAC resource types + */ +typedef enum { + MAC_RX_FIFO = 1 +} mac_resource_type_t; + +typedef int (*mac_intr_enable_t)(mac_intr_handle_t); +typedef int (*mac_intr_disable_t)(mac_intr_handle_t); + +typedef struct mac_intr_s { + mac_intr_handle_t mi_handle; + mac_intr_enable_t mi_enable; + mac_intr_disable_t mi_disable; + ddi_intr_handle_t mi_ddi_handle; + boolean_t mi_ddi_shared; +} mac_intr_t; + +typedef struct mac_rx_fifo_s { + mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ + mac_intr_t mrf_intr; + mac_receive_t mrf_receive; + void *mrf_rx_arg; + uint32_t mrf_flow_priority; + /* + * The CPU this flow is to be processed on. With intrd and future + * things, we should know which CPU the flow needs to be processed + * and get a squeue assigned on that CPU. + */ + uint_t mrf_cpu_id; +} mac_rx_fifo_t; + +#define mrf_intr_handle mrf_intr.mi_handle +#define mrf_intr_enable mrf_intr.mi_enable +#define mrf_intr_disable mrf_intr.mi_disable + +typedef union mac_resource_u { + mac_resource_type_t mr_type; + mac_rx_fifo_t mr_fifo; +} mac_resource_t; + +typedef enum { + MAC_ADDRTYPE_UNICAST, + MAC_ADDRTYPE_MULTICAST, + MAC_ADDRTYPE_BROADCAST +} mac_addrtype_t; + +typedef struct mac_header_info_s { + size_t mhi_hdrsize; + size_t mhi_pktsize; + const uint8_t *mhi_daddr; + const uint8_t *mhi_saddr; + uint32_t mhi_origsap; + uint32_t mhi_bindsap; + mac_addrtype_t mhi_dsttype; + uint16_t mhi_tci; + boolean_t mhi_istagged; + boolean_t mhi_ispvid; +} mac_header_info_t; + +/* + * Function pointer to match dls client signature. Should be same as + * dls_rx_t to allow a soft ring to bypass DLS layer and call a DLS + * client directly. + */ +typedef void (*mac_direct_rx_t)(void *, mac_resource_handle_t, + mblk_t *, mac_header_info_t *); + +typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); +typedef int (*mac_resource_bind_t)(void *, + mac_resource_handle_t, processorid_t); +typedef void (*mac_resource_remove_t)(void *, void *); +typedef void (*mac_resource_quiesce_t)(void *, void *); +typedef void (*mac_resource_restart_t)(void *, void *); +typedef int (*mac_resource_modify_t)(void *, void *, + mac_resource_t *); +typedef void (*mac_change_upcall_t)(void *, mac_direct_rx_t, + void *); + +/* + * MAC-Type plugin interfaces + */ + +typedef int (*mtops_addr_verify_t)(const void *, void *); +typedef boolean_t (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *); +typedef mblk_t *(*mtops_header_t)(const void *, const void *, + uint32_t, void *, mblk_t *, size_t); +typedef int (*mtops_header_info_t)(mblk_t *, void *, + mac_header_info_t *); +typedef boolean_t (*mtops_pdata_verify_t)(void *, size_t); +typedef mblk_t *(*mtops_header_modify_t)(mblk_t *, void *); +typedef void (*mtops_link_details_t)(char *, size_t, mac_handle_t, + void *); + +typedef struct mactype_ops_s { + uint_t mtops_ops; + /* + * mtops_unicst_verify() returns 0 if the given address is a valid + * unicast address, or a non-zero errno otherwise. + */ + mtops_addr_verify_t mtops_unicst_verify; + /* + * mtops_multicst_verify() returns 0 if the given address is a + * valid multicast address, or a non-zero errno otherwise. If the + * media doesn't support multicast, ENOTSUP should be returned (for + * example). + */ + mtops_addr_verify_t mtops_multicst_verify; + /* + * mtops_sap_verify() returns B_TRUE if the given SAP is a valid + * SAP value, or B_FALSE otherwise. + */ + mtops_sap_verify_t mtops_sap_verify; + /* + * mtops_header() is used to allocate and construct a MAC header. + */ + mtops_header_t mtops_header; + /* + * mtops_header_info() is used to gather information on a given MAC + * header. + */ + mtops_header_info_t mtops_header_info; + /* + * mtops_pdata_verify() is used to verify the validity of MAC + * plugin data. It is called by mac_register() if the driver has + * supplied MAC plugin data, and also by mac_pdata_update() when + * drivers update the data. + */ + mtops_pdata_verify_t mtops_pdata_verify; + /* + * mtops_header_cook() is an optional callback that converts (or + * "cooks") the given raw header (as sent by a raw DLPI consumer) + * into one that is appropriate to send down to the MAC driver. + * Following the example above, an Ethernet header sent down by a + * DLPI consumer would be converted to whatever header the MAC + * driver expects. + */ + mtops_header_modify_t mtops_header_cook; + /* + * mtops_header_uncook() is an optional callback that does the + * opposite of mtops_header_cook(). It "uncooks" a given MAC + * header (as received from the driver) for consumption by raw DLPI + * consumers. For example, for a non-Ethernet plugin that wants + * raw DLPI consumers to be fooled into thinking that the device + * provides Ethernet access, this callback would modify the given + * mblk_t such that the MAC header is converted to an Ethernet + * header. + */ + mtops_header_modify_t mtops_header_uncook; + /* + * mtops_link_details() is an optional callback that provides + * extended information about the link state. Its primary purpose + * is to provide type-specific support for syslog contents on + * link up events. If no implementation is provided, then a default + * implementation will be used. + */ + mtops_link_details_t mtops_link_details; +} mactype_ops_t; + +/* + * mtops_ops exists for the plugin to enumerate the optional callback + * entrypoints it has defined. This allows the mac module to define + * additional plugin entrypoints in mactype_ops_t without breaking backward + * compatibility with old plugins. + */ +#define MTOPS_PDATA_VERIFY 0x001 +#define MTOPS_HEADER_COOK 0x002 +#define MTOPS_HEADER_UNCOOK 0x004 +#define MTOPS_LINK_DETAILS 0x008 + +/* + * Provide mapping for legacy ndd ioctls relevant to that mactype. + * Note that the ndd ioctls are obsolete, and may be removed in a future + * release of Solaris. The ndd ioctls are not typically used in legacy + * ethernet drivers. New datalink drivers of all link-types should use + * dladm(8) interfaces for administering tunables and not have to provide + * a mapping. + */ +typedef struct mac_ndd_mapping_s { + char *mp_name; + union { + mac_prop_id_t u_id; + uint_t u_kstat; + } u_mp_id; + long mp_minval; + long mp_maxval; + size_t mp_valsize; + int mp_flags; +} mac_ndd_mapping_t; + +#define mp_prop_id u_mp_id.u_id +#define mp_kstat u_mp_id.u_kstat + +typedef struct mac_stat_info_s { + uint_t msi_stat; + char *msi_name; + uint_t msi_type; /* as defined in kstat_named_init(9F) */ + uint64_t msi_default; +} mac_stat_info_t; + +typedef struct mactype_register_s { + uint_t mtr_version; /* set by mactype_alloc() */ + const char *mtr_ident; + mactype_ops_t *mtr_ops; + uint_t mtr_mactype; + uint_t mtr_nativetype; + uint_t mtr_addrlen; + uint8_t *mtr_brdcst_addr; + mac_stat_info_t *mtr_stats; + size_t mtr_statcount; + mac_ndd_mapping_t *mtr_mapping; + size_t mtr_mappingcount; +} mactype_register_t; + +/* + * Flags to describe the hardware emulation desired from a client when + * calling mac_hw_emul(). + * + * MAC_HWCKSUM_EMUL + * + * If an mblk is marked with HCK_* flags, then calculate those + * checksums and update the checksum flags. + * + * MAC_IPCKSUM_EMUL + * + * Like MAC_HWCKSUM_EMUL, except only calculate the IPv4 header + * checksum. We still update both the IPv4 and ULP checksum + * flags. + * + * MAC_LSO_EMUL + * + * If an mblk is marked with HW_LSO, then segment the LSO mblk + * into a new chain of mblks which reference the original data + * block. This flag DOES NOT imply MAC_HWCKSUM_EMUL. If the + * caller needs both then it must set both. + */ +typedef enum mac_emul { + MAC_HWCKSUM_EMUL = (1 << 0), + MAC_IPCKSUM_EMUL = (1 << 1), + MAC_LSO_EMUL = (1 << 2) +} mac_emul_t; + +#define MAC_HWCKSUM_EMULS (MAC_HWCKSUM_EMUL | MAC_IPCKSUM_EMUL) +#define MAC_ALL_EMULS (MAC_HWCKSUM_EMUL | MAC_IPCKSUM_EMUL | \ + MAC_LSO_EMUL) + +/* + * Driver interface functions. + */ +extern int mac_open_by_linkid(datalink_id_t, + mac_handle_t *); +extern int mac_open_by_linkname(const char *, + mac_handle_t *); +extern const char *mac_name(mac_handle_t); +extern minor_t mac_minor(mac_handle_t); +extern minor_t mac_minor_hold(boolean_t); +extern void mac_minor_rele(minor_t); +extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *); +extern void mac_sdu_get2(mac_handle_t, uint_t *, uint_t *, + uint_t *); +extern int mac_maxsdu_update(mac_handle_t, uint_t); +extern int mac_maxsdu_update2(mac_handle_t, uint_t, + uint_t); +extern uint_t mac_addr_len(mac_handle_t); +extern int mac_type(mac_handle_t); +extern int mac_nativetype(mac_handle_t); + +extern void mac_unicst_update(mac_handle_t, + const uint8_t *); +extern void mac_capab_update(mac_handle_t); +extern int mac_pdata_update(mac_handle_t, void *, + size_t); +extern boolean_t mac_margin_update(mac_handle_t, uint32_t); +extern void mac_margin_get(mac_handle_t, uint32_t *); +extern int mac_margin_remove(mac_handle_t, uint32_t); +extern int mac_margin_add(mac_handle_t, uint32_t *, + boolean_t); +extern int mac_mtu_add(mac_handle_t, uint32_t *, + boolean_t); +extern int mac_mtu_remove(mac_handle_t, uint32_t); +extern int mac_fastpath_disable(mac_handle_t); +extern void mac_fastpath_enable(mac_handle_t); +extern void mac_no_active(mac_handle_t); + +extern mactype_register_t *mactype_alloc(uint_t); +extern void mactype_free(mactype_register_t *); +extern int mactype_register(mactype_register_t *); +extern int mactype_unregister(const char *); + +extern int mac_start_logusage(mac_logtype_t, uint_t); +extern void mac_stop_logusage(mac_logtype_t); + +extern mac_handle_t mac_get_lower_mac_handle(mac_handle_t); +extern boolean_t mac_is_vnic_primary(mac_handle_t); + +/* + * Packet hashing for distribution to multiple ports and rings. + */ + +#define MAC_PKT_HASH_L2 0x01 +#define MAC_PKT_HASH_L3 0x02 +#define MAC_PKT_HASH_L4 0x04 + +extern uint64_t mac_pkt_hash(uint_t, mblk_t *, uint8_t, + boolean_t); + +/* + * Bridging linkage + */ +extern void mac_rx_common(mac_handle_t, + mac_resource_handle_t, mblk_t *); +extern int mac_bridge_set(mac_handle_t, mac_handle_t); +extern void mac_bridge_clear(mac_handle_t, mac_handle_t); +extern void mac_bridge_vectors(mac_bridge_tx_t, + mac_bridge_rx_t, mac_bridge_ref_t, + mac_bridge_ls_t); + +/* special case function for TRILL observability */ +extern void mac_trill_snoop(mac_handle_t, mblk_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MAC_H */ diff --git a/illumos-x86_64/usr/include/sys/mac_ether.h b/illumos-x86_64/usr/include/sys/mac_ether.h new file mode 100644 index 00000000..f89c909f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mac_ether.h @@ -0,0 +1,370 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2015 Garrett D'Amore + * Copyright 2016 Joyent, Inc. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_MAC_ETHER_H +#define _SYS_MAC_ETHER_H + +/* + * Ethernet MAC Plugin + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Ethernet-specific media types for use with MAC_PROP_MEDIA and + * ETHER_STAT_XCVR_INUSE. See mac(9E) for more information. + */ +typedef enum { + ETHER_MEDIA_UNKNOWN = 0, + ETHER_MEDIA_NONE, + ETHER_MEDIA_10BASE_T, + ETHER_MEDIA_100BASE_T4, + /* + * 100BASE-X is a catchall term defined in 802.3. In 802.3 section + * 24.1.1 100BASE-X is used to cover the more specific 100BASE-TX and + * 100BASE-FX realized in copper and fiber. The PCS is shared between + * the two, but the PMD is different. Use this if you can't determine TX + * vs. FX. + */ + ETHER_MEDIA_100BASE_X, + /* + * Note, previously there was never a 100BASE-TX value so some drivers + * would have returned this for 100BASE-TX. + */ + ETHER_MEDIA_100BASE_T2, + /* + * 1000BASE-X is a fiber catch all. This is for compatibility with the + * traditional ETHER_STAT_XCVR_INUSE 1000BASE-X value. More specific + * variants are listed below. USe this if nothing more specific is + * feasible. + */ + ETHER_MEDIA_1000BASE_X, + ETHER_MEDIA_1000BASE_T, + ETHER_MEDIA_1000BASE_KX, + ETHER_MEDIA_1000BASE_T1, + ETHER_MEDIA_1000BASE_CX, + ETHER_MEDIA_1000BASE_SX, + ETHER_MEDIA_1000BASE_LX, + ETHER_MEDIA_1000BASE_BX, + ETHER_MEDIA_1000_SGMII, + + /* + * Additional more recent or erroneously skipped 10/100 modes. + */ + ETHER_MEDIA_100BASE_TX, + ETHER_MEDIA_100BASE_FX, + ETHER_MEDIA_100_SGMII, + ETHER_MEDIA_10BASE_T1, + ETHER_MEDIA_100BASE_T1, + + /* + * 2.5 GbE, 5.0 GbE, single lane. + */ + ETHER_MEDIA_2500BASE_T, + ETHER_MEDIA_2500BASE_KX, + ETHER_MEDIA_2500BASE_X, + ETHER_MEDIA_5000BASE_T, + ETHER_MEDIA_5000BASE_KR, + + /* + * 10 GbE, all lane configurations. + */ + ETHER_MEDIA_10GBASE_T, + ETHER_MEDIA_10GBASE_SR, + ETHER_MEDIA_10GBASE_LR, + ETHER_MEDIA_10GBASE_LRM, + ETHER_MEDIA_10GBASE_KR, + ETHER_MEDIA_10GBASE_CX4, + ETHER_MEDIA_10GBASE_KX4, + ETHER_MEDIA_10G_XAUI, + ETHER_MEDIA_10GBASE_AOC, + ETHER_MEDIA_10GBASE_ACC, + ETHER_MEDIA_10GBASE_CR, + ETHER_MEDIA_10GBASE_ER, + ETHER_MEDIA_10G_SFI, + ETHER_MEDIA_10G_XFI, + + /* + * 25 GbE, single lane. + */ + ETHER_MEDIA_25GBASE_T, + ETHER_MEDIA_25GBASE_SR, + ETHER_MEDIA_25GBASE_LR, + ETHER_MEDIA_25GBASE_ER, + ETHER_MEDIA_25GBASE_KR, + ETHER_MEDIA_25GBASE_CR, + ETHER_MEDIA_25GBASE_AOC, + ETHER_MEDIA_25GBASE_ACC, + ETHER_MEDIA_25G_AUI, + + /* + * 40 GbE based on 10 GbE + */ + ETHER_MEDIA_40GBASE_T, + ETHER_MEDIA_40GBASE_CR4, + ETHER_MEDIA_40GBASE_KR4, + ETHER_MEDIA_40GBASE_LR4, + ETHER_MEDIA_40GBASE_SR4, + ETHER_MEDIA_40GBASE_ER4, + ETHER_MEDIA_40GBASE_LM4, + ETHER_MEDIA_40GBASE_AOC4, + ETHER_MEDIA_40GBASE_ACC4, + ETHER_MEDIA_40G_XLAUI, + ETHER_MEDIA_40G_XLPPI, + + /* + * 50 GbE based on 25 GbE + */ + ETHER_MEDIA_50GBASE_KR2, + ETHER_MEDIA_50GBASE_CR2, + ETHER_MEDIA_50GBASE_SR2, + ETHER_MEDIA_50GBASE_LR2, + ETHER_MEDIA_50GBASE_AOC2, + ETHER_MEDIA_50GBASE_ACC2, + + /* + * 50 GbE based on 50 GbE PAM4 + */ + ETHER_MEDIA_50GBASE_KR, + ETHER_MEDIA_50GBASE_CR, + ETHER_MEDIA_50GBASE_SR, + ETHER_MEDIA_50GBASE_LR, + ETHER_MEDIA_50GBASE_FR, + ETHER_MEDIA_50GBASE_ER, + ETHER_MEDIA_50GBASE_AOC, + ETHER_MEDIA_50GBASE_ACC, + + /* + * 100 GbE based on 10 GbE + */ + ETHER_MEDIA_100GBASE_CR10, + ETHER_MEDIA_100GBASE_SR10, + + /* + * 100 GbE based on 25 GbE + */ + ETHER_MEDIA_100GBASE_SR4, + ETHER_MEDIA_100GBASE_LR4, + ETHER_MEDIA_100GBASE_ER4, + ETHER_MEDIA_100GBASE_KR4, + ETHER_MEDIA_100GBASE_CR4, + ETHER_MEDIA_100GBASE_CAUI4, + ETHER_MEDIA_100GBASE_AOC4, + ETHER_MEDIA_100GBASE_ACC4, + + /* + * 100 GbE based on 50 GbE + */ + ETHER_MEDIA_100GBASE_KR2, + ETHER_MEDIA_100GBASE_CR2, + ETHER_MEDIA_100GBASE_SR2, + + /* + * 100 GbE based on 100 GbE + */ + ETHER_MEDIA_100GBASE_KR, + ETHER_MEDIA_100GBASE_CR, + ETHER_MEDIA_100GBASE_SR, + ETHER_MEDIA_100GBASE_DR, + ETHER_MEDIA_100GBASE_LR, + ETHER_MEDIA_100GBASE_FR, + + /* + * 200G Ethernet based on 50 GbE + */ + ETHER_MEDIA_200GAUI_4, + ETHER_MEDIA_200GBASE_CR4, + ETHER_MEDIA_200GBASE_KR4, + ETHER_MEDIA_200GBASE_SR4, + ETHER_MEDIA_200GBASE_DR4, + ETHER_MEDIA_200GBASE_FR4, + ETHER_MEDIA_200GBASE_LR4, + ETHER_MEDIA_200GBASE_ER4, + + /* + * 200G Ethernet based on 100 GbE + */ + ETHER_MEDIA_200GAUI_2, + ETHER_MEDIA_200GBASE_KR2, + ETHER_MEDIA_200GBASE_CR2, + ETHER_MEDIA_200GBASE_SR2, + + /* + * 400G based on 50 GbE + */ + ETHER_MEDIA_400GAUI_8, + ETHER_MEDIA_400GBASE_KR8, + ETHER_MEDIA_400GBASE_FR8, + ETHER_MEDIA_400GBASE_LR8, + ETHER_MEDIA_400GBASE_ER8, + + /* + * 400G based on 100 GbE + */ + ETHER_MEDIA_400GAUI_4, + ETHER_MEDIA_400GBASE_KR4, + ETHER_MEDIA_400GBASE_CR4, + ETHER_MEDIA_400GBASE_SR4, + ETHER_MEDIA_400GBASE_DR4, + ETHER_MEDIA_400GBASE_FR4 +} mac_ether_media_t; + +#ifdef _KERNEL + +#define MAC_PLUGIN_IDENT_ETHER "mac_ether" + +/* + * Do not reorder, and add only to the end of this list. + */ +enum ether_stat { + /* RFC 1643 stats */ + ETHER_STAT_ALIGN_ERRORS = MACTYPE_STAT_MIN, + ETHER_STAT_FCS_ERRORS, + ETHER_STAT_FIRST_COLLISIONS, + ETHER_STAT_MULTI_COLLISIONS, + ETHER_STAT_SQE_ERRORS, + ETHER_STAT_DEFER_XMTS, + ETHER_STAT_TX_LATE_COLLISIONS, + ETHER_STAT_EX_COLLISIONS, + ETHER_STAT_MACXMT_ERRORS, + ETHER_STAT_CARRIER_ERRORS, + ETHER_STAT_TOOLONG_ERRORS, + ETHER_STAT_MACRCV_ERRORS, + + /* MII/GMII stats */ + ETHER_STAT_XCVR_ADDR, + ETHER_STAT_XCVR_ID, + ETHER_STAT_XCVR_INUSE, + ETHER_STAT_CAP_1000FDX, + ETHER_STAT_CAP_1000HDX, + ETHER_STAT_CAP_100FDX, + ETHER_STAT_CAP_100HDX, + ETHER_STAT_CAP_10FDX, + ETHER_STAT_CAP_10HDX, + ETHER_STAT_CAP_ASMPAUSE, + ETHER_STAT_CAP_PAUSE, + ETHER_STAT_CAP_AUTONEG, + ETHER_STAT_ADV_CAP_1000FDX, + ETHER_STAT_ADV_CAP_1000HDX, + ETHER_STAT_ADV_CAP_100FDX, + ETHER_STAT_ADV_CAP_100HDX, + ETHER_STAT_ADV_CAP_10FDX, + ETHER_STAT_ADV_CAP_10HDX, + ETHER_STAT_ADV_CAP_ASMPAUSE, + ETHER_STAT_ADV_CAP_PAUSE, + ETHER_STAT_ADV_CAP_AUTONEG, + ETHER_STAT_LP_CAP_1000FDX, + ETHER_STAT_LP_CAP_1000HDX, + ETHER_STAT_LP_CAP_100FDX, + ETHER_STAT_LP_CAP_100HDX, + ETHER_STAT_LP_CAP_10FDX, + ETHER_STAT_LP_CAP_10HDX, + ETHER_STAT_LP_CAP_ASMPAUSE, + ETHER_STAT_LP_CAP_PAUSE, + ETHER_STAT_LP_CAP_AUTONEG, + ETHER_STAT_LINK_ASMPAUSE, + ETHER_STAT_LINK_PAUSE, + ETHER_STAT_LINK_AUTONEG, + ETHER_STAT_LINK_DUPLEX, + + ETHER_STAT_TOOSHORT_ERRORS, + ETHER_STAT_CAP_REMFAULT, + ETHER_STAT_ADV_REMFAULT, + ETHER_STAT_LP_REMFAULT, + + ETHER_STAT_JABBER_ERRORS, + ETHER_STAT_CAP_100T4, + ETHER_STAT_ADV_CAP_100T4, + ETHER_STAT_LP_CAP_100T4, + + ETHER_STAT_CAP_10GFDX, + ETHER_STAT_ADV_CAP_10GFDX, + ETHER_STAT_LP_CAP_10GFDX, + + ETHER_STAT_CAP_40GFDX, + ETHER_STAT_ADV_CAP_40GFDX, + ETHER_STAT_LP_CAP_40GFDX, + + ETHER_STAT_CAP_100GFDX, + ETHER_STAT_ADV_CAP_100GFDX, + ETHER_STAT_LP_CAP_100GFDX, + + ETHER_STAT_CAP_2500FDX, + ETHER_STAT_ADV_CAP_2500FDX, + ETHER_STAT_LP_CAP_2500FDX, + + ETHER_STAT_CAP_5000FDX, + ETHER_STAT_ADV_CAP_5000FDX, + ETHER_STAT_LP_CAP_5000FDX, + + ETHER_STAT_CAP_25GFDX, + ETHER_STAT_ADV_CAP_25GFDX, + ETHER_STAT_LP_CAP_25GFDX, + + ETHER_STAT_CAP_50GFDX, + ETHER_STAT_ADV_CAP_50GFDX, + ETHER_STAT_LP_CAP_50GFDX, + + ETHER_STAT_CAP_200GFDX, + ETHER_STAT_ADV_CAP_200GFDX, + ETHER_STAT_LP_CAP_200GFDX, + + ETHER_STAT_CAP_400GFDX, + ETHER_STAT_ADV_CAP_400GFDX, + ETHER_STAT_LP_CAP_400GFDX, +}; + +#define ETHER_NSTAT \ + (ETHER_STAT_LP_CAP_400GFDX - ETHER_STAT_ALIGN_ERRORS + 1) + +#define ETHER_STAT_ISACOUNTER(_ether_stat) \ + ((_ether_stat) == ETHER_STAT_ALIGN_ERRORS || \ + (_ether_stat) == ETHER_STAT_FCS_ERRORS || \ + (_ether_stat) == ETHER_STAT_FIRST_COLLISIONS || \ + (_ether_stat) == ETHER_STAT_MULTI_COLLISIONS || \ + (_ether_stat) == ETHER_STAT_SQE_ERRORS || \ + (_ether_stat) == ETHER_STAT_DEFER_XMTS || \ + (_ether_stat) == ETHER_STAT_TX_LATE_COLLISIONS || \ + (_ether_stat) == ETHER_STAT_EX_COLLISIONS || \ + (_ether_stat) == ETHER_STAT_MACXMT_ERRORS || \ + (_ether_stat) == ETHER_STAT_CARRIER_ERRORS || \ + (_ether_stat) == ETHER_STAT_TOOLONG_ERRORS || \ + (_ether_stat) == ETHER_STAT_TOOSHORT_ERRORS || \ + (_ether_stat) == ETHER_STAT_JABBER_ERRORS || \ + (_ether_stat) == ETHER_STAT_MACRCV_ERRORS) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MAC_ETHER_H */ diff --git a/illumos-x86_64/usr/include/sys/mac_flow.h b/illumos-x86_64/usr/include/sys/mac_flow.h new file mode 100644 index 00000000..04aa8be3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mac_flow.h @@ -0,0 +1,266 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2013 Joyent, Inc. All rights reserved. + * Copyright 2020 RackTop Systems, Inc. + */ + +#ifndef _MAC_FLOW_H +#define _MAC_FLOW_H + +/* + * Main structure describing a flow of packets, for classification use + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include /* for MAXPATHLEN */ +#include /* for IPPROTO_* constants */ +#include + +#define MAX_RINGS_PER_GROUP 128 + +/* + * MAXFLOWNAMELEN defines the longest possible permitted flow name, + * including the terminating NUL. + */ +#define MAXFLOWNAMELEN 128 + +/* need to use MAXMACADDRLEN from dld.h instead of this one */ +#define MAXMACADDR 20 + +/* Bit-mask for the selectors carried in the flow descriptor */ +typedef uint64_t flow_mask_t; + +#define FLOW_LINK_DST 0x00000001 /* Destination MAC addr */ +#define FLOW_LINK_SRC 0x00000002 /* Source MAC address */ +#define FLOW_LINK_VID 0x00000004 /* VLAN ID */ +#define FLOW_LINK_SAP 0x00000008 /* SAP value */ + +#define FLOW_IP_VERSION 0x00000010 /* V4 or V6 */ +#define FLOW_IP_PROTOCOL 0x00000020 /* Protocol type */ +#define FLOW_IP_LOCAL 0x00000040 /* Local address */ +#define FLOW_IP_REMOTE 0x00000080 /* Remote address */ +#define FLOW_IP_DSFIELD 0x00000100 /* DSfield value */ + +#define FLOW_ULP_PORT_LOCAL 0x00001000 /* ULP local port */ +#define FLOW_ULP_PORT_REMOTE 0x00002000 /* ULP remote port */ + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct flow_desc_s { + flow_mask_t fd_mask; + uint32_t fd_mac_len; + uint8_t fd_dst_mac[MAXMACADDR]; + uint8_t fd_src_mac[MAXMACADDR]; + uint16_t fd_vid; + uint32_t fd_sap; + uint8_t fd_ipversion; + uint8_t fd_protocol; + in6_addr_t fd_local_addr; + in6_addr_t fd_local_netmask; + in6_addr_t fd_remote_addr; + in6_addr_t fd_remote_netmask; + in_port_t fd_local_port; + in_port_t fd_remote_port; + uint8_t fd_dsfield; + uint8_t fd_dsfield_mask; +} flow_desc_t; + +#define MRP_NCPUS 256 + +/* + * In MCM_CPUS mode, cpu bindings is user specified. In MCM_FANOUT mode, + * user only specifies a fanout count. + * mc_rx_fanout_cnt gives the number of CPUs used for fanout soft rings. + * mc_rx_fanout_cpus[] array stores the CPUs used for fanout soft rings. + */ +typedef enum { + MCM_FANOUT = 1, + MCM_CPUS +} mac_cpu_mode_t; + +/* + * Structure to store the value of the CPUs to be used to re-target + * Tx interrupt. + */ +typedef struct mac_tx_intr_cpus_s { + /* cpu value to re-target intr to */ + int32_t mtc_intr_cpu[MRP_NCPUS]; + /* re-targeted CPU or -1 if failed */ + int32_t mtc_retargeted_cpu[MRP_NCPUS]; +} mac_tx_intr_cpu_t; + +typedef struct mac_cpus_props_s { + uint32_t mc_ncpus; /* num of cpus */ + uint32_t mc_cpus[MRP_NCPUS]; /* cpu list */ + uint32_t mc_rx_fanout_cnt; /* soft ring cpu cnt */ + uint32_t mc_rx_fanout_cpus[MRP_NCPUS]; /* SR cpu list */ + uint32_t mc_rx_pollid; /* poll thr binding */ + uint32_t mc_rx_workerid; /* worker thr binding */ + /* + * interrupt cpu: mrp_intr_cpu less than 0 implies platform limitation + * in retargetting the interrupt assignment. + */ + int32_t mc_rx_intr_cpu; + int32_t mc_tx_fanout_cpus[MRP_NCPUS]; + mac_tx_intr_cpu_t mc_tx_intr_cpus; + mac_cpu_mode_t mc_fanout_mode; /* fanout mode */ +} mac_cpus_t; + +#define mc_tx_intr_cpu mc_tx_intr_cpus.mtc_intr_cpu +#define mc_tx_retargeted_cpu mc_tx_intr_cpus.mtc_retargeted_cpu + +/* Priority values */ +typedef enum { + MPL_LOW, + MPL_MEDIUM, + MPL_HIGH, + MPL_RESET +} mac_priority_level_t; + +/* Protection types */ +#define MPT_MACNOSPOOF 0x00000001 +#define MPT_RESTRICTED 0x00000002 +#define MPT_IPNOSPOOF 0x00000004 +#define MPT_DHCPNOSPOOF 0x00000008 +#define MPT_ALL 0x0000000f +#define MPT_RESET 0xffffffff +#define MPT_MAXCNT 32 +#define MPT_MAXIPADDR MPT_MAXCNT +#define MPT_MAXCID MPT_MAXCNT +#define MPT_MAXCIDLEN 256 + +typedef struct mac_ipaddr_s { + uint32_t ip_version; + in6_addr_t ip_addr; + uint8_t ip_netmask; +} mac_ipaddr_t; + +typedef enum { + CIDFORM_TYPED = 1, + CIDFORM_HEX, + CIDFORM_STR +} mac_dhcpcid_form_t; + +typedef struct mac_dhcpcid_s { + uchar_t dc_id[MPT_MAXCIDLEN]; + uint32_t dc_len; + mac_dhcpcid_form_t dc_form; +} mac_dhcpcid_t; + +typedef struct mac_protect_s { + uint32_t mp_types; + uint32_t mp_ipaddrcnt; + mac_ipaddr_t mp_ipaddrs[MPT_MAXIPADDR]; + uint32_t mp_cidcnt; + mac_dhcpcid_t mp_cids[MPT_MAXCID]; +} mac_protect_t; + +/* The default priority for links */ +#define MPL_LINK_DEFAULT MPL_HIGH + +/* The default priority for flows */ +#define MPL_SUBFLOW_DEFAULT MPL_MEDIUM + +#define MRP_MAXBW 0x00000001 /* Limit set */ +#define MRP_CPUS 0x00000002 /* CPU/fanout set */ +#define MRP_CPUS_USERSPEC 0x00000004 /* CPU/fanout from user */ +#define MRP_PRIORITY 0x00000008 /* Priority set */ +#define MRP_PROTECT 0x00000010 /* Protection set */ +#define MRP_RX_RINGS 0x00000020 /* Rx rings */ +#define MRP_TX_RINGS 0x00000040 /* Tx rings */ +#define MRP_RXRINGS_UNSPEC 0x00000080 /* unspecified rings */ +#define MRP_TXRINGS_UNSPEC 0x00000100 /* unspecified rings */ +#define MRP_RINGS_RESET 0x00000200 /* resetting rings */ +#define MRP_POOL 0x00000400 /* CPU pool */ + +#define MRP_THROTTLE MRP_MAXBW + +/* 3 levels - low, medium, high */ +#define MRP_PRIORITY_LEVELS 3 + +/* Special value denoting no bandwidth control */ +#define MRP_MAXBW_RESETVAL -1ULL + +/* + * Until sub-megabit limit is implemented, + * reject values lower than 1 MTU per tick or 1.2Mbps + */ +#define MRP_MAXBW_MINVAL 1200000 + +typedef struct mac_resource_props_s { + /* + * Bit-mask for the network resource control types types + */ + uint32_t mrp_mask; + uint64_t mrp_maxbw; /* bandwidth limit in bps */ + mac_priority_level_t mrp_priority; /* relative flow priority */ + mac_cpus_t mrp_cpus; + mac_protect_t mrp_protect; + uint32_t mrp_nrxrings; + uint32_t mrp_ntxrings; + char mrp_pool[MAXPATHLEN]; /* CPU pool */ +} mac_resource_props_t; + +#define mrp_ncpus mrp_cpus.mc_ncpus +#define mrp_cpu mrp_cpus.mc_cpus +#define mrp_rx_fanout_cnt mrp_cpus.mc_rx_fanout_cnt +#define mrp_rx_pollid mrp_cpus.mc_rx_pollid +#define mrp_rx_workerid mrp_cpus.mc_rx_workerid +#define mrp_rx_intr_cpu mrp_cpus.mc_rx_intr_cpu +#define mrp_fanout_mode mrp_cpus.mc_fanout_mode + +#define MAC_COPY_CPUS(mrp, fmrp) { \ + int ncpus; \ + (fmrp)->mrp_ncpus = (mrp)->mrp_ncpus; \ + (fmrp)->mrp_rx_fanout_cnt = (mrp)->mrp_rx_fanout_cnt; \ + (fmrp)->mrp_rx_intr_cpu = (mrp)->mrp_rx_intr_cpu; \ + (fmrp)->mrp_fanout_mode = (mrp)->mrp_fanout_mode; \ + if ((mrp)->mrp_ncpus == 0) { \ + (fmrp)->mrp_mask &= ~MRP_CPUS; \ + (fmrp)->mrp_mask &= ~MRP_CPUS_USERSPEC; \ + } else { \ + for (ncpus = 0; ncpus < (fmrp)->mrp_ncpus; ncpus++) \ + (fmrp)->mrp_cpu[ncpus] = (mrp)->mrp_cpu[ncpus];\ + (fmrp)->mrp_mask |= MRP_CPUS; \ + if ((mrp)->mrp_mask & MRP_CPUS_USERSPEC) \ + (fmrp)->mrp_mask |= MRP_CPUS_USERSPEC; \ + } \ +} + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _MAC_FLOW_H */ diff --git a/illumos-x86_64/usr/include/sys/mac_provider.h b/illumos-x86_64/usr/include/sys/mac_provider.h new file mode 100644 index 00000000..3b29d045 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mac_provider.h @@ -0,0 +1,710 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2020 RackTop Systems, Inc. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_MAC_PROVIDER_H +#define _SYS_MAC_PROVIDER_H + +#include +#include +#include +#include +#include +#include +#include + +/* + * MAC Provider Interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * MAC version identifiers. Drivers compiled against the stable V1 version + * of the API should register with MAC_VERSION_V1. ON drivers should use + * MAC_VERSION. This is used by mac_alloc() mac_register() to + * verify that incompatible drivers don't register. + */ +#define MAC_VERSION_V1 0x1 +#define MAC_VERSION MAC_VERSION_V1 + +/* + * Possible values for ETHER_STAT_XCVR_INUSE statistic. + */ + +#define XCVR_UNDEFINED 0 +#define XCVR_NONE 1 +#define XCVR_10 2 +#define XCVR_100T4 3 +#define XCVR_100X 4 +#define XCVR_100T2 5 +#define XCVR_1000X 6 +#define XCVR_1000T 7 + +#ifdef _KERNEL + +/* + * Definitions for MAC Drivers Capabilities + */ +/* + * MAC layer capabilities. These capabilities are handled by the drivers' + * mc_capab_get() callbacks. Some capabilities require the driver to fill + * in a given data structure, and others are simply boolean capabilities. + * Note that capability values must be powers of 2 so that consumers and + * providers of this interface can keep track of which capabilities they + * care about by keeping a bitfield of these things around somewhere. + */ +typedef enum { + /* + * Public Capabilities (MAC_VERSION_V1) + */ + MAC_CAPAB_HCKSUM = 0x00000001, /* data is a uint32_t */ + MAC_CAPAB_LSO = 0x00000008, /* data is mac_capab_lso_t */ + + /* + * Reserved capabilities, do not use + */ + MAC_CAPAB_RESERVED1 = 0x00000002, + MAC_CAPAB_RESERVED2 = 0x00000004, + + /* + * Private driver capabilities + */ + MAC_CAPAB_RINGS = 0x00000010, /* data is mac_capab_rings_t */ + MAC_CAPAB_SHARES = 0x00000020, /* data is mac_capab_share_t */ + MAC_CAPAB_MULTIFACTADDR = 0x00000040, /* mac_data_multifactaddr_t */ + + /* + * Private driver capabilities for use by the GLDv3 framework only + */ + MAC_CAPAB_VNIC = 0x00010000, /* data is mac_capab_vnic_t */ + MAC_CAPAB_ANCHOR_VNIC = 0x00020000, /* boolean only, no data */ + MAC_CAPAB_AGGR = 0x00040000, /* data is mac_capab_aggr_t */ + MAC_CAPAB_NO_NATIVEVLAN = 0x00080000, /* boolean only, no data */ + MAC_CAPAB_NO_ZCOPY = 0x00100000, /* boolean only, no data */ + MAC_CAPAB_LEGACY = 0x00200000, /* data is mac_capab_legacy_t */ + MAC_CAPAB_VRRP = 0x00400000, /* data is mac_capab_vrrp_t */ + MAC_CAPAB_OVERLAY = 0x00800000, /* boolean only, no data */ + MAC_CAPAB_TRANSCEIVER = 0x01000000, /* mac_capab_transceiver_t */ + MAC_CAPAB_LED = 0x02000000 /* data is mac_capab_led_t */ +} mac_capab_t; + +/* + * LSO capability + */ +typedef struct lso_basic_tcp_ipv4_s { + t_uscalar_t lso_max; /* maximum payload */ +} lso_basic_tcp_ipv4_t; + +typedef struct lso_basic_tcp_ipv6_s { + t_uscalar_t lso_max; /* maximum payload */ +} lso_basic_tcp_ipv6_t; + +/* + * Currently supported flags for LSO. + */ +#define LSO_TX_BASIC_TCP_IPV4 0x01 /* TCPv4 LSO capability */ +#define LSO_TX_BASIC_TCP_IPV6 0x02 /* TCPv6 LSO capability */ + +/* + * Future LSO capabilities can be added at the end of the mac_capab_lso_t. + * When such capability is added to the GLDv3 framework, the size of the + * mac_capab_lso_t it allocates and passes to the drivers increases. Older + * drivers wil access only the (upper) sections of that structure, that is the + * sections carrying the capabilities they understand. This ensures the + * interface can be safely extended in a binary compatible way. + */ +typedef struct mac_capab_lso_s { + t_uscalar_t lso_flags; + lso_basic_tcp_ipv4_t lso_basic_tcp_ipv4; + lso_basic_tcp_ipv6_t lso_basic_tcp_ipv6; + /* Add future lso capabilities here */ +} mac_capab_lso_t; + +/* + * Multiple Factory MAC Addresses Capability + */ +typedef struct mac_capab_multifactaddr_s { + /* + * Number of factory addresses + */ + uint_t mcm_naddr; + + /* + * Callbacks to query all the factory addresses. + */ + void (*mcm_getaddr)(void *, uint_t, uint8_t *); +} mac_capab_multifactaddr_t; + +/* + * Info and callbacks of legacy devices. + */ +typedef struct mac_capab_legacy_s { + /* + * Notifications that the legacy device does not support. + */ + uint32_t ml_unsup_note; + /* + * dev_t of the legacy device; can be held to force attach. + */ + dev_t ml_dev; + boolean_t (*ml_active_set)(void *); + void (*ml_active_clear)(void *); + int (*ml_fastpath_disable)(void *); + void (*ml_fastpath_enable)(void *); +} mac_capab_legacy_t; + +typedef struct __mac_prop_info_handle *mac_prop_info_handle_t; + +/* + * MAC driver entry point types. + */ +typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *); +typedef int (*mac_start_t)(void *); +typedef void (*mac_stop_t)(void *); +typedef int (*mac_setpromisc_t)(void *, boolean_t); +typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); +typedef int (*mac_unicst_t)(void *, const uint8_t *); +typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); +typedef void (*mac_resources_t)(void *); +typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); +typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *); +typedef int (*mac_open_t)(void *); +typedef void (*mac_close_t)(void *); +typedef int (*mac_set_prop_t)(void *, const char *, mac_prop_id_t, + uint_t, const void *); +typedef int (*mac_get_prop_t)(void *, const char *, mac_prop_id_t, + uint_t, void *); +typedef void (*mac_prop_info_t)(void *, const char *, mac_prop_id_t, + mac_prop_info_handle_t); + +/* + * Driver callbacks. The following capabilities are optional, and if + * implemented by the driver, must have a corresponding MC_ flag set + * in the mc_callbacks field. + * + * Any future additions to this list must also be accompanied by an + * associated mc_callbacks flag so that the framework can grow without + * affecting the binary compatibility of the interface. + */ +typedef struct mac_callbacks_s { + uint_t mc_callbacks; /* Denotes which callbacks are set */ + mac_getstat_t mc_getstat; /* Get the value of a statistic */ + mac_start_t mc_start; /* Start the device */ + mac_stop_t mc_stop; /* Stop the device */ + mac_setpromisc_t mc_setpromisc; /* Enable or disable promiscuous mode */ + mac_multicst_t mc_multicst; /* Enable or disable a multicast addr */ + mac_unicst_t mc_unicst; /* Set the unicast MAC address */ + mac_tx_t mc_tx; /* Transmit a packet */ + void *mc_reserved; /* Reserved, do not use */ + mac_ioctl_t mc_ioctl; /* Process an unknown ioctl */ + mac_getcapab_t mc_getcapab; /* Get capability information */ + mac_open_t mc_open; /* Open the device */ + mac_close_t mc_close; /* Close the device */ + mac_set_prop_t mc_setprop; + mac_get_prop_t mc_getprop; + mac_prop_info_t mc_propinfo; +} mac_callbacks_t; + +/* + * Flags for mc_callbacks. Requiring drivers to set the flags associated + * with optional callbacks initialized in the structure allows the mac + * module to add optional callbacks in the future without requiring drivers + * to recompile. + */ +#define MC_RESERVED 0x0001 +#define MC_IOCTL 0x0002 +#define MC_GETCAPAB 0x0004 +#define MC_OPEN 0x0008 +#define MC_CLOSE 0x0010 +#define MC_SETPROP 0x0020 +#define MC_GETPROP 0x0040 +#define MC_PROPINFO 0x0080 +#define MC_PROPERTIES (MC_SETPROP | MC_GETPROP | MC_PROPINFO) + +/* + * Virtualization Capabilities + */ + +/* + * The type of ring classification. This is used by MAC to determine + * what, if any, processing it has to do upon receiving traffic on a + * particular Rx ring. + * + * MAC_NO_CLASSIFIER + * + * No classification has been set. No traffic should cross an Rx + * ring in this state. + * + * MAC_SW_CLASSIFIER + * + * The driver delivers traffic for multiple clients to this ring. + * All traffic must be software classified by MAC to guarantee + * delivery to the correct client. This classification type may + * be chosen for several reasons. + * + * o The driver provides only one group and there are multiple + * clients using the MAC. + * + * o The driver provides some hardware filtering but not enough + * to fully classify the traffic. E.g., a VLAN VNIC requires L2 + * unicast address filtering as well as VLAN filtering, but + * some drivers may only support the former. + * + * o The ring belongs to the default group. The default group + * acts as a spillover for all clients that can't reserve an + * exclusive group. It also handles multicast traffic for all + * clients. For these reasons, the default group's rings are + * always software classified. + * + * MAC_HW_CLASSIFIER + * + * The driver delivers traffic for a single MAC client across + * this ring. With this guarantee, MAC can simply pass the + * traffic up the stack or even allow polling of the ring. + * + * MAC_PASSTHRU_CLASSIFIER + * + * The ring is in "passthru" mode. In this mode we bypass all of + * the typical MAC processing and pass the traffic directly to + * the mr_pt_fn callback, see mac_rx_common(). This is used in + * cases where there is another module acting as MAC provider on + * behalf of the driver. E.g., link aggregations use this mode to + * take full control of the port's rings; allowing it to enforce + * LACP protocols and aggregate rings across discrete drivers. + */ +typedef enum { + MAC_NO_CLASSIFIER = 0, + MAC_SW_CLASSIFIER, + MAC_HW_CLASSIFIER, + MAC_PASSTHRU_CLASSIFIER +} mac_classify_type_t; + +typedef void (*mac_rx_func_t)(void *, mac_resource_handle_t, mblk_t *, + boolean_t); + +/* + * The virtualization level conveys the extent of the NIC hardware assistance + * for traffic steering employed for virtualization: + * + * MAC_VIRT_NONE: No assist for v12n. + * + * MAC_VIRT_LEVEL1: Multiple Rx rings with MAC address level + * classification between groups of rings. + * Requires the support of the MAC_CAPAB_RINGS + * capability. + * + * MAC_VIRT_HIO: Hybrid I/O capable MAC. Require the support + * of the MAC_CAPAB_SHARES capability. + */ +#define MAC_VIRT_NONE 0x0 +#define MAC_VIRT_LEVEL1 0x1 +#define MAC_VIRT_HIO 0x2 + +typedef enum { + MAC_RING_TYPE_RX = 1, /* Receive ring */ + MAC_RING_TYPE_TX /* Transmit ring */ +} mac_ring_type_t; + +/* + * The value VLAN_ID_NONE (VID 0) means a client does not have + * membership to any VLAN. However, this statement is true for both + * untagged packets and priority tagged packets leading to confusion + * over what semantic is intended. To the provider, VID 0 is a valid + * VID when priority tagging is in play. To MAC and everything above + * VLAN_ID_NONE almost universally implies untagged traffic. Thus, we + * convert VLAN_ID_NONE to a sentinel value (MAC_VLAN_UNTAGGED) at the + * border between MAC and MAC provider. This informs the provider that + * the client is interested in untagged traffic and the provider + * should set any relevant bits to receive such traffic. + * + * Currently, the API between MAC and the provider passes the VID as a + * unit16_t. In the future this could actually be the entire TCI mask + * (PCP, DEI, and VID). This current scheme is safe in that potential + * future world as well; as 0xFFFF is not a valid TCI (the 0xFFF VID + * is reserved and never transmitted across networks). + */ +#define MAC_VLAN_UNTAGGED UINT16_MAX +#define MAC_VLAN_UNTAGGED_VID(vid) \ + (((vid) == VLAN_ID_NONE) ? MAC_VLAN_UNTAGGED : (vid)) + +/* + * Grouping type of a ring group + * + * MAC_GROUP_TYPE_STATIC: The ring group can not be re-grouped. + * MAC_GROUP_TYPE_DYNAMIC: The ring group support dynamic re-grouping + */ +typedef enum { + MAC_GROUP_TYPE_STATIC = 1, /* Static ring group */ + MAC_GROUP_TYPE_DYNAMIC /* Dynamic ring group */ +} mac_group_type_t; + +typedef struct __mac_ring_driver *mac_ring_driver_t; +typedef struct __mac_group_driver *mac_group_driver_t; + +typedef struct mac_ring_info_s mac_ring_info_t; +typedef struct mac_group_info_s mac_group_info_t; + +typedef void (*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int, + mac_ring_info_t *, mac_ring_handle_t); +typedef void (*mac_get_group_t)(void *, mac_ring_type_t, const int, + mac_group_info_t *, mac_group_handle_t); + +typedef void (*mac_group_add_ring_t)(mac_group_driver_t, + mac_ring_driver_t, mac_ring_type_t); +typedef void (*mac_group_rem_ring_t)(mac_group_driver_t, + mac_ring_driver_t, mac_ring_type_t); + +/* + * Multiple Rings Capability + */ +typedef struct mac_capab_rings_s { + mac_ring_type_t mr_type; /* Ring type: Rx vs Tx */ + mac_group_type_t mr_group_type; /* Dynamic vs static grouping */ + uint_t mr_rnum; /* Number of rings */ + uint_t mr_gnum; /* Number of ring groups */ + mac_get_ring_t mr_rget; /* Get ring from driver */ + mac_get_group_t mr_gget; /* Get ring group from driver */ + mac_group_add_ring_t mr_gaddring; /* Add ring into a group */ + mac_group_rem_ring_t mr_gremring; /* Remove ring from a group */ +} mac_capab_rings_t; + +/* + * Common ring functions and driver interfaces + */ +typedef int (*mac_ring_start_t)(mac_ring_driver_t, uint64_t); +typedef void (*mac_ring_stop_t)(mac_ring_driver_t); + +typedef mblk_t *(*mac_ring_send_t)(void *, mblk_t *); +typedef mblk_t *(*mac_ring_poll_t)(void *, int); + +typedef int (*mac_ring_stat_t)(mac_ring_driver_t, uint_t, uint64_t *); + +typedef struct mac_ring_info_s { + mac_ring_driver_t mri_driver; + mac_ring_start_t mri_start; + mac_ring_stop_t mri_stop; + mac_intr_t mri_intr; + union { + mac_ring_send_t send; + mac_ring_poll_t poll; + } mrfunion; + mac_ring_stat_t mri_stat; + + /* + * mri_flags will have some bits set to indicate some special + * property/feature of a ring like serialization needed for a + * Tx ring or packets should always need enqueuing on Rx side, + * etc. + */ + uint_t mri_flags; +} mac_ring_info_s; + +#define mri_tx mrfunion.send +#define mri_poll mrfunion.poll + +/* + * #defines for mri_flags. The flags are temporary flags that are provided + * only to workaround issues in specific drivers, and they will be + * removed in the future. + * + * These are consumed only by sun4v and neptune (nxge). + */ +#define MAC_RING_TX_SERIALIZE 0x1 +#define MAC_RING_RX_ENQUEUE 0x2 + +typedef int (*mac_group_start_t)(mac_group_driver_t); +typedef void (*mac_group_stop_t)(mac_group_driver_t); +typedef int (*mac_add_mac_addr_t)(void *, const uint8_t *); +typedef int (*mac_rem_mac_addr_t)(void *, const uint8_t *); +typedef int (*mac_add_vlan_filter_t)(mac_group_driver_t, uint16_t); +typedef int (*mac_rem_vlan_filter_t)(mac_group_driver_t, uint16_t); + +struct mac_group_info_s { + mac_group_driver_t mgi_driver; /* Driver reference */ + mac_group_start_t mgi_start; /* Start the group */ + mac_group_stop_t mgi_stop; /* Stop the group */ + uint_t mgi_count; /* Count of rings */ + mac_intr_t mgi_intr; /* Optional per-group intr */ + + /* Only used for Rx groups */ + mac_add_mac_addr_t mgi_addmac; /* Add a MAC address */ + mac_rem_mac_addr_t mgi_remmac; /* Remove a MAC address */ + mac_add_vlan_filter_t mgi_addvlan; /* Add a VLAN filter */ + mac_rem_vlan_filter_t mgi_remvlan; /* Remove a VLAN filter */ +}; + +/* + * Share management functions. + */ +typedef uint64_t mac_share_handle_t; + +/* + * Allocate and free a share. Returns ENOSPC if all shares have been + * previously allocated. + */ +typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *); +typedef void (*mac_free_share_t)(mac_share_handle_t); + +/* + * Bind and unbind a share. Binding a share allows a domain + * to have direct access to the groups and rings associated with + * that share. + */ +typedef int (*mac_bind_share_t)(mac_share_handle_t, uint64_t, uint64_t *); +typedef void (*mac_unbind_share_t)(mac_share_handle_t); + +/* + * Return information on about a share. + */ +typedef void (*mac_share_query_t)(mac_share_handle_t, mac_ring_type_t, + mac_ring_handle_t *, uint_t *); + +/* + * Basic idea, bind previously created ring groups to shares + * for them to be exported (or shared) by another domain. + * These interfaces bind/unbind the ring group to a share. + * The groups and their rings will be shared with the guest + * as soon as the share is bound. + */ +typedef int (*mac_share_add_group_t)(mac_share_handle_t, + mac_group_driver_t); +typedef int (*mac_share_rem_group_t)(mac_share_handle_t, + mac_group_driver_t); + +typedef struct mac_capab_share_s { + uint_t ms_snum; /* Number of shares (vr's) */ + void *ms_handle; /* Handle to driver. */ + mac_alloc_share_t ms_salloc; /* Get a share from driver. */ + mac_free_share_t ms_sfree; /* Return a share to driver. */ + mac_share_add_group_t ms_sadd; /* Add a group to the share. */ + mac_share_rem_group_t ms_sremove; /* Remove group from share. */ + mac_share_query_t ms_squery; /* Query share constraints */ + mac_bind_share_t ms_sbind; /* Bind a share */ + mac_unbind_share_t ms_sunbind; /* Unbind a share */ +} mac_capab_share_t; + +typedef struct mac_capab_vrrp_s { + /* IPv6 or IPv4? */ + int mcv_af; +} mac_capab_vrrp_t; + +/* + * Transceiver capability + */ +typedef struct mac_transceiver_info mac_transceiver_info_t; + +typedef struct mac_capab_transceiver { + uint_t mct_flags; + uint_t mct_ntransceivers; + int (*mct_info)(void *, uint_t, mac_transceiver_info_t *); + int (*mct_read)(void *, uint_t, uint_t, void *, size_t, off_t, + size_t *); +} mac_capab_transceiver_t; + +/* + * LED capability + */ +typedef struct mac_capab_led { + uint_t mcl_flags; + mac_led_mode_t mcl_modes; + int (*mcl_set)(void *, mac_led_mode_t, uint_t); +} mac_capab_led_t; + +/* + * MAC registration interface + */ +typedef struct mac_register_s { + uint_t m_version; /* set by mac_alloc() */ + const char *m_type_ident; + void *m_driver; /* Driver private data */ + dev_info_t *m_dip; + uint_t m_instance; + uint8_t *m_src_addr; + uint8_t *m_dst_addr; + mac_callbacks_t *m_callbacks; + uint_t m_min_sdu; + uint_t m_max_sdu; + void *m_pdata; + size_t m_pdata_size; + char **m_priv_props; + uint32_t m_margin; + uint32_t m_v12n; /* Virtualization level */ + uint_t m_multicast_sdu; +} mac_register_t; + +/* + * Driver interface functions. + */ +extern mac_protect_t *mac_protect_get(mac_handle_t); +extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *); +extern void mac_sdu_get2(mac_handle_t, uint_t *, uint_t *, + uint_t *); +extern int mac_maxsdu_update(mac_handle_t, uint_t); +extern int mac_maxsdu_update2(mac_handle_t, uint_t, + uint_t); + +extern mac_register_t *mac_alloc(uint_t); +extern void mac_free(mac_register_t *); +extern int mac_register(mac_register_t *, mac_handle_t *); +extern int mac_disable_nowait(mac_handle_t); +extern int mac_disable(mac_handle_t); +extern int mac_unregister(mac_handle_t); +extern void mac_rx(mac_handle_t, mac_resource_handle_t, + mblk_t *); +extern void mac_rx_ring(mac_handle_t, mac_ring_handle_t, + mblk_t *, uint64_t); +extern void mac_link_update(mac_handle_t, link_state_t); +extern void mac_link_redo(mac_handle_t, link_state_t); +extern void mac_unicst_update(mac_handle_t, + const uint8_t *); +extern void mac_dst_update(mac_handle_t, const uint8_t *); +extern void mac_tx_update(mac_handle_t); +extern void mac_tx_ring_update(mac_handle_t, + mac_ring_handle_t); +extern void mac_capab_update(mac_handle_t); +extern int mac_pdata_update(mac_handle_t, void *, + size_t); +extern void mac_multicast_refresh(mac_handle_t, + mac_multicst_t, void *, boolean_t); +extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t, + void *); +extern void mac_promisc_refresh(mac_handle_t, + mac_setpromisc_t, void *); +extern boolean_t mac_margin_update(mac_handle_t, uint32_t); +extern void mac_margin_get(mac_handle_t, uint32_t *); +extern int mac_margin_remove(mac_handle_t, uint32_t); +extern int mac_margin_add(mac_handle_t, uint32_t *, + boolean_t); +extern void mac_init_ops(struct dev_ops *, const char *); +extern void mac_fini_ops(struct dev_ops *); +extern int mac_devt_to_instance(dev_t); +extern int mac_getinfo(dev_info_t *, ddi_info_cmd_t, + void *, void **); +extern minor_t mac_private_minor(void); +extern void mac_ring_intr_set(mac_ring_handle_t, + ddi_intr_handle_t); + + +extern mactype_register_t *mactype_alloc(uint_t); +extern void mactype_free(mactype_register_t *); +extern int mactype_register(mactype_register_t *); +extern int mactype_unregister(const char *); + +extern boolean_t mac_unicst_verify(mac_handle_t, + const uint8_t *, uint_t); + +extern int mac_group_add_ring(mac_group_handle_t, int); +extern void mac_group_rem_ring(mac_group_handle_t, + mac_ring_handle_t); +extern mac_ring_handle_t mac_find_ring(mac_group_handle_t, int); + +extern void mac_prop_info_set_default_uint8( + mac_prop_info_handle_t, uint8_t); +extern void mac_prop_info_set_default_str( + mac_prop_info_handle_t, const char *); +extern void mac_prop_info_set_default_uint64( + mac_prop_info_handle_t, uint64_t); +extern void mac_prop_info_set_default_uint32( + mac_prop_info_handle_t, uint32_t); +extern void mac_prop_info_set_default_link_flowctrl( + mac_prop_info_handle_t, link_flowctrl_t); +extern void mac_prop_info_set_default_fec( + mac_prop_info_handle_t, link_fec_t); +extern void mac_prop_info_set_range_uint32( + mac_prop_info_handle_t, + uint32_t, uint32_t); +extern void mac_prop_info_set_perm(mac_prop_info_handle_t, + uint8_t); + +extern void mac_hcksum_get(const mblk_t *, uint32_t *, + uint32_t *, uint32_t *, uint32_t *, + uint32_t *); +extern void mac_hcksum_set(mblk_t *, uint32_t, uint32_t, + uint32_t, uint32_t, uint32_t); +extern void mac_hcksum_clone(const mblk_t *, mblk_t *); + +extern void mac_lso_get(mblk_t *, uint32_t *, uint32_t *); + +extern void mac_transceiver_info_set_present( + mac_transceiver_info_t *, + boolean_t); +extern void mac_transceiver_info_set_usable( + mac_transceiver_info_t *, + boolean_t); + +/* + * This represents a provisional set of currently illumos-private APIs to get + * information about a mblk_t chain's type. This is an evolving interface. + * + * These flags and mac_ether_offload_info struct below are currently duplicated + * by the userspace mac_test program, which should be kept in sync if changes to + * either are made here. + */ +typedef enum mac_ether_offload_flags { + MEOI_L2INFO_SET = 1 << 0, + MEOI_L3INFO_SET = 1 << 1, + MEOI_L4INFO_SET = 1 << 2, + MEOI_VLAN_TAGGED = 1 << 3, + MEOI_L3_FRAG_MORE = 1 << 4, + MEOI_L3_FRAG_OFFSET = 1 << 5 +} mac_ether_offload_flags_t; + +typedef struct mac_ether_offload_info { + mac_ether_offload_flags_t meoi_flags; /* What's valid? */ + size_t meoi_len; /* Total message length */ + uint8_t meoi_l2hlen; /* How long is the Ethernet header? */ + uint16_t meoi_l3proto; /* What's the Ethertype */ + uint16_t meoi_l3hlen; /* How long is the header? */ + uint8_t meoi_l4proto; /* What is the payload type? */ + uint8_t meoi_l4hlen; /* How long is the L4 header */ +} mac_ether_offload_info_t; + +/* + * When querying the VLAN TCI from packet headers via mac_ether_l2_info(), or + * as part of the internal logic in mac_ether_offload_info(), a value of + * MEOI_VLAN_TCI_INVALID indicates that the packet does not bear a VLAN header + * as indicated by the ethertype. This is to disambiguate it from any of the + * 16-bit contents (valid or invalid) which the TCI may hold. + */ +#define MEOI_VLAN_TCI_INVALID UINT32_MAX + +extern boolean_t mac_ether_l2_info(mblk_t *, uint8_t *, uint32_t *); +extern void mac_ether_offload_info(mblk_t *, mac_ether_offload_info_t *); +extern void mac_partial_offload_info(mblk_t *, size_t, + mac_ether_offload_info_t *); + + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MAC_PROVIDER_H */ diff --git a/illumos-x86_64/usr/include/sys/machelf.h b/illumos-x86_64/usr/include/sys/machelf.h new file mode 100644 index 00000000..dea6d108 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/machelf.h @@ -0,0 +1,184 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MACHELF_H +#define _SYS_MACHELF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__amd64) || (defined(__i386) && defined(_ELF64)) +#include +#elif defined(__i386) +#include +#elif defined(__sparc) +#include +#endif +#ifndef _ASM +#include +#include +#include /* for Elf*_Dyn */ +#endif /* _ASM */ + +/* + * Make machine class dependent data types transparent to the common code + */ +#if defined(_ELF64) && !defined(_ELF32_COMPAT) + +#ifndef _ASM +typedef Elf64_Xword Xword; +typedef Elf64_Lword Lword; +typedef Elf64_Sxword Sxword; +typedef Elf64_Word Word; +typedef Elf64_Sword Sword; +typedef Elf64_Half Half; +typedef Elf64_Addr Addr; +typedef Elf64_Off Off; +typedef uchar_t Byte; +#endif /* _ASM */ + +#if defined(_KERNEL) +#define ELF_R_TYPE ELF64_R_TYPE +#define ELF_R_SYM ELF64_R_SYM +#define ELF_R_TYPE_DATA ELF64_R_TYPE_DATA +#define ELF_R_INFO ELF64_R_INFO +#define ELF_ST_BIND ELF64_ST_BIND +#define ELF_ST_TYPE ELF64_ST_TYPE +#define ELF_M_SYM ELF64_M_SYM +#define ELF_M_SIZE ELF64_M_SIZE +#endif + +#ifndef _ASM +typedef Elf64_Ehdr Ehdr; +typedef Elf64_Shdr Shdr; +typedef Elf64_Sym Sym; +typedef Elf64_Syminfo Syminfo; +typedef Elf64_Rela Rela; +typedef Elf64_Rel Rel; +typedef Elf64_Nhdr Nhdr; +typedef Elf64_Phdr Phdr; +typedef Elf64_Dyn Dyn; +typedef Elf64_Boot Boot; +typedef Elf64_Verdef Verdef; +typedef Elf64_Verdaux Verdaux; +typedef Elf64_Verneed Verneed; +typedef Elf64_Vernaux Vernaux; +typedef Elf64_Versym Versym; +typedef Elf64_Move Move; +typedef Elf64_Cap Cap; +typedef Elf64_Capinfo Capinfo; +typedef Elf64_Capchain Capchain; +#endif /* _ASM */ + +#else /* _ILP32 */ + +#ifndef _ASM +typedef Elf32_Word Xword; /* Xword/Sxword are 32-bits in Elf32 */ +typedef Elf32_Lword Lword; +typedef Elf32_Sword Sxword; +typedef Elf32_Word Word; +typedef Elf32_Sword Sword; +typedef Elf32_Half Half; +typedef Elf32_Addr Addr; +typedef Elf32_Off Off; +typedef uchar_t Byte; +#endif /* _ASM */ + +#if defined(_KERNEL) +#define ELF_R_TYPE ELF32_R_TYPE +#define ELF_R_SYM ELF32_R_SYM +#define ELF_R_TYPE_DATA(x) (0) +#define ELF_R_INFO ELF32_R_INFO +#define ELF_ST_BIND ELF32_ST_BIND +#define ELF_ST_TYPE ELF32_ST_TYPE +#define ELF_M_SYM ELF32_M_SYM +#define ELF_M_SIZE ELF32_M_SIZE +#endif + +#ifndef _ASM +typedef Elf32_Ehdr Ehdr; +typedef Elf32_Shdr Shdr; +typedef Elf32_Sym Sym; +typedef Elf32_Syminfo Syminfo; +typedef Elf32_Rela Rela; +typedef Elf32_Rel Rel; +typedef Elf32_Nhdr Nhdr; +typedef Elf32_Phdr Phdr; +typedef Elf32_Dyn Dyn; +typedef Elf32_Boot Boot; +typedef Elf32_Verdef Verdef; +typedef Elf32_Verdaux Verdaux; +typedef Elf32_Verneed Verneed; +typedef Elf32_Vernaux Vernaux; +typedef Elf32_Versym Versym; +typedef Elf32_Move Move; +typedef Elf32_Cap Cap; +typedef Elf32_Capinfo Capinfo; +typedef Elf32_Capchain Capchain; +#endif /* _ASM */ + +#endif /* _ILP32 */ + +/* + * Elf `printf' type-cast macros. These force arguments to be a fixed size + * so that Elf32 and Elf64 can share common format strings. + */ +#ifndef __lint +#define EC_ADDR(a) ((Elf64_Addr)(a)) /* "ull" */ +#define EC_OFF(a) ((Elf64_Off)(a)) /* "ull" */ +#define EC_HALF(a) ((Elf64_Half)(a)) /* "d" */ +#define EC_WORD(a) ((Elf64_Word)(a)) /* "u" */ +#define EC_SWORD(a) ((Elf64_Sword)(a)) /* "d" */ +#define EC_XWORD(a) ((Elf64_Xword)(a)) /* "ull" */ +#define EC_SXWORD(a) ((Elf64_Sxword)(a)) /* "ll" */ +#define EC_LWORD(a) ((Elf64_Lword)(a)) /* "ull" */ + +/* + * A native pointer is special. Although it can be convenient to display + * these from a common format (ull), compilers may flag the cast of a pointer + * to an integer as illegal. Casting these pointers to the native pointer + * size, suppresses any compiler errors. + */ +#define EC_NATPTR(a) ((Elf64_Xword)(uintptr_t)(a)) /* "ull" */ +#else +#define EC_ADDR(a) ((u_longlong_t)(a)) +#define EC_OFF(a) ((u_longlong_t)(a)) +#define EC_HALF(a) ((ushort_t)(a)) +#define EC_WORD(a) ((uint_t)(a)) +#define EC_SWORD(a) ((int)(a)) +#define EC_XWORD(a) ((u_longlong_t)(a)) +#define EC_SXWORD(a) ((longlong_t)(a)) +#define EC_LWORD(a) ((u_longlong_t)(a)) + +#define EC_NATPTR(a) ((u_longlong_t)(a)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MACHELF_H */ diff --git a/illumos-x86_64/usr/include/sys/machlock.h b/illumos-x86_64/usr/include/sys/machlock.h new file mode 100644 index 00000000..e362ca9a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/machlock.h @@ -0,0 +1,140 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _SYS_MACHLOCK_H +#define _SYS_MACHLOCK_H + +#ifndef _ASM +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +#ifdef _KERNEL + +extern void lock_set(lock_t *lp); +extern int lock_try(lock_t *lp); +extern int lock_spin_try(lock_t *lp); +extern int ulock_try(lock_t *lp); +extern void lock_clear(lock_t *lp); +extern void ulock_clear(lock_t *lp); +extern void lock_set_spl(lock_t *lp, int new_pil, ushort_t *old_pil); +extern void lock_clear_splx(lock_t *lp, int s); + +#endif /* _KERNEL */ + +#define LOCK_HELD_VALUE 0xff +#define LOCK_INIT_CLEAR(lp) (*(lp) = 0) +#define LOCK_INIT_HELD(lp) (*(lp) = LOCK_HELD_VALUE) +#define LOCK_HELD(lp) (*(volatile lock_t *)(lp) != 0) + +typedef lock_t disp_lock_t; /* dispatcher lock type */ + +/* + * SPIN_LOCK() macro indicates whether lock is implemented as a spin lock or + * an adaptive mutex, depending on what interrupt levels use it. + */ +#define SPIN_LOCK(pl) ((pl) > ipltospl(LOCK_LEVEL)) + +/* + * Macro to control loops which spin on a lock and then check state + * periodically. Its passed an integer, and returns a boolean value + * that if true indicates its a good time to get the scheduler lock and + * check the state of the current owner of the lock. + */ +#define LOCK_SAMPLE_INTERVAL(i) (((i) & 0xff) == 0) + +/* + * Externs for CLOCK_LOCK and clock resolution + */ +extern volatile uint32_t hres_lock; +extern hrtime_t hrtime_base; +extern int clock_res; + +#endif /* _ASM */ + +/* + * The definitions of the symbolic interrupt levels: + * + * CLOCK_LEVEL => The level at which one must be to block the clock. + * + * LOCK_LEVEL => The highest level at which one may block (and thus the + * highest level at which one may acquire adaptive locks) + * Also the highest level at which one may be preempted. + * + * DISP_LEVEL => The level at which one must be to perform dispatcher + * operations. + * + * The constraints on the platform: + * + * - CLOCK_LEVEL must be less than or equal to LOCK_LEVEL + * - LOCK_LEVEL must be less than DISP_LEVEL + * - DISP_LEVEL should be as close to LOCK_LEVEL as possible + * + * Note that LOCK_LEVEL and CLOCK_LEVEL have historically always been equal; + * changing this relationship is probably possible but not advised. + * + */ + +#define PIL_MAX 15 + +#define CLOCK_LEVEL 10 +#define LOCK_LEVEL 10 +#define DISP_LEVEL (LOCK_LEVEL + 1) + +#define HIGH_LEVELS (PIL_MAX - LOCK_LEVEL) + +/* + * The following mask is for the cpu_intr_actv bits corresponding to + * high-level PILs. It should equal: + * ((((1 << PIL_MAX + 1) - 1) >> LOCK_LEVEL + 1) << LOCK_LEVEL + 1) + */ +#define CPU_INTR_ACTV_HIGH_LEVEL_MASK 0xF800 + +/* + * The semaphore code depends on being able to represent a lock plus + * owner in a single 32-bit word. (Mutexes used to have a similar + * dependency, but no longer.) Thus the owner must contain at most + * 24 significant bits. At present only threads and semaphores + * must be aware of this vile constraint. Different ISAs may handle this + * differently depending on their capabilities (e.g. compare-and-swap) + * and limitations (e.g. constraints on alignment and/or KERNELBASE). + */ +#define PTR24_LSB 5 /* lower bits all zero */ +#define PTR24_MSB (PTR24_LSB + 24) /* upper bits all one */ +#define PTR24_ALIGN 32 /* minimum alignment (1 << lsb) */ +#define PTR24_BASE 0xe0000000 /* minimum ptr value (-1 >> (32-msb)) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MACHLOCK_H */ diff --git a/illumos-x86_64/usr/include/sys/machsig.h b/illumos-x86_64/usr/include/sys/machsig.h new file mode 100644 index 00000000..52696a09 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/machsig.h @@ -0,0 +1,124 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_MACHSIG_H +#define _SYS_MACHSIG_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * machsig.h is the machine dependent portion of siginfo.h (and is + * included by siginfo.h). A version of machsig.h should exist for + * each architecture. The codes for SIGILL, SIGFPU, SIGSEGV and SIGBUS + * are in this file. The codes for SIGTRAP, SIGCLD(SIGCHLD), and + * SIGPOLL are architecture independent and may be found in siginfo.h. + */ + +#if !defined(_POSIX_C_SOURCE) || defined(_XPG4_2) || defined(__EXTENSIONS__) + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include +#endif + +/* + * SIGILL signal codes + */ +#define ILL_ILLOPC 1 /* illegal opcode */ +#define ILL_ILLOPN 2 /* illegal operand */ +#define ILL_ILLADR 3 /* illegal addressing mode */ +#define ILL_ILLTRP 4 /* illegal trap */ +#define ILL_PRVOPC 5 /* privileged opcode */ +#define ILL_PRVREG 6 /* privileged register */ +#define ILL_COPROC 7 /* co-processor */ +#define ILL_BADSTK 8 /* bad stack */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define NSIGILL 8 +#endif + +/* + * SIGEMT signal codes + */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define EMT_CPCOVF 1 /* CPU performance counter overflow */ +#define NSIGEMT 1 +#endif + +/* + * SIGFPE signal codes + */ + +#define FPE_INTDIV 1 /* integer divide by zero */ +#define FPE_INTOVF 2 /* integer overflow */ +#define FPE_FLTDIV 3 /* floating point divide by zero */ +#define FPE_FLTOVF 4 /* floating point overflow */ +#define FPE_FLTUND 5 /* floating point underflow */ +#define FPE_FLTRES 6 /* floating point inexact result */ +#define FPE_FLTINV 7 /* invalid floating point operation */ +#define FPE_FLTSUB 8 /* subscript out of range */ +#define FPE_FLTDEN 9 /* floating point denormalize */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define NSIGFPE 9 +#endif + +/* + * SIGSEGV signal codes + */ + +#define SEGV_MAPERR 1 /* address not mapped to object */ +#define SEGV_ACCERR 2 /* invalid permissions */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define NSIGSEGV 2 +#endif + +/* + * SIGBUS signal codes + */ + +#define BUS_ADRALN 1 /* invalid address alignment */ +#define BUS_ADRERR 2 /* non-existent physical address */ +#ifndef BUS_OBJERR /* also defined in ucbinclude/sys/signal.h */ +#define BUS_OBJERR 3 /* object specific hardware error */ +#endif +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define NSIGBUS 3 +#endif + +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XPG4_2) ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MACHSIG_H */ diff --git a/illumos-x86_64/usr/include/sys/machtypes.h b/illumos-x86_64/usr/include/sys/machtypes.h new file mode 100644 index 00000000..a7b618be --- /dev/null +++ b/illumos-x86_64/usr/include/sys/machtypes.h @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MACHTYPES_H +#define _SYS_MACHTYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Machine dependent types: + * + * intel ia32 Version + */ + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \ + defined(__EXTENSIONS__) + +#define REG_LABEL_PC 0 +#define REG_LABEL_SP 1 +#define REG_LABEL_BP 2 +#if defined(__amd64) +#define REG_LABEL_RBX 3 +#define REG_LABEL_R12 4 +#define REG_LABEL_R13 5 +#define REG_LABEL_R14 6 +#define REG_LABEL_R15 7 +#define REG_LABEL_MAX 8 +#else /* __amd64 */ +#define REG_LABEL_EBX 3 +#define REG_LABEL_ESI 4 +#define REG_LABEL_EDI 5 +#define REG_LABEL_MAX 6 +#endif /* __amd64 */ + +typedef struct _label_t { long val[REG_LABEL_MAX]; } label_t; + +#endif /* !defined(_POSIX_C_SOURCE)... */ + +typedef unsigned char lock_t; /* lock work for busy wait */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MACHTYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/map.h b/illumos-x86_64/usr/include/sys/map.h new file mode 100644 index 00000000..7074a8e9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/map.h @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_MAP_H +#define _SYS_MAP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct map; + +#ifdef _KERNEL + +extern void *rmallocmap(size_t); +extern void *rmallocmap_wait(size_t); +extern void rmfreemap(void *); + +extern ulong_t rmalloc(void *, size_t); +extern ulong_t rmalloc_wait(void *, size_t); +extern void rmfree(void *, size_t, ulong_t); + +#endif /* KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MAP_H */ diff --git a/illumos-x86_64/usr/include/sys/mc.h b/illumos-x86_64/usr/include/sys/mc.h new file mode 100644 index 00000000..6bba18ad --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mc.h @@ -0,0 +1,153 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2019 Joyent, Inc. + * Copyright 2022 Oxide Computer Company + */ + +#ifndef _SYS_MC_H +#define _SYS_MC_H + +/* + * Public interfaces exposed by the memory controller driver + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MC_UNUM_NAMLEN 192 +#define MC_UNUM_NDIMM 2 + +typedef struct mc_unum { + int unum_board; /* system board */ + int unum_chip; /* chip/socket */ + int unum_mc; /* memory-controller or branch */ + int unum_chan; /* DRAM channel */ + int unum_cs; /* chip-select */ + int unum_rank; /* rank */ + uint64_t unum_offset; /* row, column, bank-select etc */ + int unum_dimms[MC_UNUM_NDIMM]; +} mc_unum_t; + +/* + * Invalid marker used in some numeric properties + */ +#define MC_INVALNUM ((uint32_t)-1) + +/* + * /dev/mc/mc* ioctl cmds + */ +#define MC_IOC (0x4d43 << 16) +#define MC_IOC_SNAPSHOT_INFO (MC_IOC | 1) +#define MC_IOC_SNAPSHOT (MC_IOC | 2) +#define MC_IOC_ONLINESPARE_EN (MC_IOC | 4) +#define MC_IOC_DECODE_PA (MC_IOC | 5) +#define MC_IOC_DECODE_SNAPSHOT_INFO (MC_IOC | 6) +#define MC_IOC_DECODE_SNAPSHOT (MC_IOC | 7) + +/* + * Prior to requesting a copy of the snapshot, consumers are advised to request + * information regarding the snapshot. An mc_snapshot_info_t will be returned, + * containing the snapshot size as well as the snapshot generation number. Note + * that, due to the potentially dynamic nature of the system, the snapshot may + * change at any time. As such, the information in the mc_snapshot_info_t may + * be out of date by the time it is used. The generation number is used to + * track snapshot changes. That is, the generation number will be updated each + * time the source data for the snapshot is updated. The consumer should not + * attach any meaning to the magnitude of a generation number change, and pay + * attention only to the fact that the number has changed. + */ +typedef struct mc_snapshot_info { + uint32_t mcs_size; /* snapshot size */ + uint_t mcs_gen; /* snapshot generation number */ +} mc_snapshot_info_t; + +/* + * Data used to simulate encoding or decoding of a physical / DIMM address. + * These are used in different ways between AMD and Intel, so this is a bit of a + * smorgasbord. Details about each field are listed below. + */ +typedef struct mc_encode_ioc { + /* + * The first three values here are different addresses. We have a + * physical / system address. A DRAM-channel relative address, and + * finally a rank-relative address. Where a platform does not support + * one of these, UINT64_MAX is used. + */ + uint64_t mcei_pa; + uint64_t mcei_chan_addr; + uint64_t mcei_rank_addr; + /* + * These next two provide a way for the memory controller software + * driver to provide additional information. The mcei_err generally + * corresponds to an enum that the driver has and the errdata is + * error-specific data that can be useful. + */ + uint64_t mcei_errdata; + uint32_t mcei_err; + /* + * This next set is used to identify information about where to find a + * DIMM in question. The board and chip are used to uniquely identify a + * socket. Generally on x86, there is only one board, so it would be + * zero. The chip should correspond to the socket ID. The die refers to + * a particular internal die if on a chiplet or MCP. The memory + * controller and channel refer to a unique instance of both within a + * given die. On platforms where the memory controller and channel are + * 1:1 (that is each memory controller has only a single channel or + * doesn't have a specific distinction between the two), set chan to 0 + * and set the mc to the logical channel value. The DIMM is a relative + * DIMM in the channel, meaning it's usually going to be 0, 1, or 2. + */ + uint32_t mcei_board; + uint32_t mcei_chip; + uint32_t mcei_die; + uint32_t mcei_mc; + uint32_t mcei_chan; + uint32_t mcei_dimm; + /* + * These values all refer to information on the DIMM itself and identify + * how to find the address. mcei_rank is meant to be a logical rank; + * however, some systems phrase things that way while others phrase + * things in terms of a chip select and rank multiplication. For unknown + * entries use UINT8_MAX. + */ + uint32_t mcei_row; + uint32_t mcei_column; + uint8_t mcei_rank; + uint8_t mcei_cs; + uint8_t mcei_rm; + uint8_t mcei_bank; + uint8_t mcei_bank_group; + uint8_t mcei_subchan; + uint8_t mcei_pad[6]; +} mc_encode_ioc_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MC_H */ diff --git a/illumos-x86_64/usr/include/sys/mc_amd.h b/illumos-x86_64/usr/include/sys/mc_amd.h new file mode 100644 index 00000000..e95d06a1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mc_amd.h @@ -0,0 +1,922 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2022 Oxide Computer Co. + */ + +#ifndef _MC_AMD_H +#define _MC_AMD_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions, register offsets, register structure etc pertaining to + * the memory controller on AMD64 systems. These are used by both the + * AMD cpu module and the mc-amd driver. + */ + +/* + * The mc-amd driver exports an nvlist to userland, where the primary + * consumer is the "chip" topology enumerator for this platform type which + * builds a full topology subtree from this information. Others can use + * it, too, but don't depend on it not changing without an ARC contract + * (and the contract should probably concern the topology, not this nvlist). + * + * In the initial mc-amd implementation this nvlist was not versioned; + * we'll think of that as version 0 and it may be recognised by the absence + * of a "mcamd-nvlist-version member. + * + * Version 1 is defined as follows. A name in square brackets indicates + * that member is optional (only present if the actual value is valid). + * + * Name Type Description + * -------------------- --------------- --------------------------------------- + * mcamd-nvlist-version uint8 Exported nvlist version number + * num uint64 Chip id of this memory controller + * revision uint64 cpuid_getchiprev() result + * revname string cpuid_getchiprevstr() result + * socket string "Socket 755|939|940|AM2|F(1207)|S1g1" + * ecc-type string "ChipKill 128/16" or "Normal 64/8" + * base-addr uint64 Node base address + * lim-addr uint64 Node limit address + * node-ilen uint64 0|1|3|7 for 0/2/4/8 way node interleave + * node-ilsel uint64 Node interleave position of this node + * cs-intlv-factor uint64 chip-select interleave: 1/2/4/8 + * dram-hole-size uint64 size in bytes from dram hole addr reg + * access-width uint64 MC mode, 64 or 128 bit + * bank-mapping uint64 Raw DRAM Bank Address Mapping Register + * bankswizzle uint64 1 if bank swizzling enabled; else 0 + * mismatched-dimm-support uint64 1 if active; else 0 + * [spare-csnum] uint64 Chip-select pair number of any spare + * [bad-csnum] uint64 Chip-select pair number of swapped cs + * cslist nvlist array See below; may have 0 members + * dimmlist nvlist array See below; may have 0 members + * + * cslist is an array of nvlist, each as follows: + * + * Name Type Description + * -------------------- --------------- --------------------------------------- + * num uint64 Chip-select base/mask pair number + * base-addr uint64 Chip-select base address (rel to node) + * mask uint64 Chip-select mask + * size uint64 Chip-select size in bytes + * dimm1-num uint64 First dimm (lodimm if a pair) + * dimm1-csname string Socket cs# line name for 1st dimm rank + * [dimm2-num] uint64 Second dimm if applicable (updimm) + * [dimm2-csname] string Socket cs# line name for 2nd dimm rank + * + * dimmlist is an array of nvlist, each as follows: + * + * Name Type Description + * -------------------- --------------- --------------------------------------- + * num uint64 DIMM instance number + * size uint64 DIMM size in bytes + * csnums uint64 array CS base/mask pair(s) on this DIMM + * csnames string array Socket cs# line name(s) on this DIMM + * + * The n'th csnums entry corresponds to the n'th csnames entry + */ +#define MC_NVLIST_VERSTR "mcamd-nvlist-version" +#define MC_NVLIST_VERS0 0 +#define MC_NVLIST_VERS1 1 +#define MC_NVLIST_VERS MC_NVLIST_VERS1 + +/* + * Constants and feature/revision test macros that are not expected to vary + * among different AMD family 0xf processor revisions. + */ + +/* + * Configuration constants + */ +#define MC_CHIP_MAXNODES 8 /* max number of MCs in system */ +#define MC_CHIP_NDIMM 8 /* max dimms per MC */ +#define MC_CHIP_NCS 8 /* number of chip-selects per MC */ +#define MC_CHIP_NDRAMCHAN 2 /* maximum number of dram channels */ +#define MC_CHIP_DIMMRANKMAX 4 /* largest number of ranks per dimm */ +#define MC_CHIP_DIMMPERCS 2 /* max number of dimms per cs */ +#define MC_CHIP_DIMMPAIR(csnum) (csnum / MC_CHIP_DIMMPERCS) + +/* + * Memory controller registers are read via PCI config space accesses on + * bus 0, device 0x18 + NodeId, and function as follows: + * + * Function 0: HyperTransport Technology Configuration + * Function 1: Address Map + * Function 2: DRAM Controller & HyperTransport Technology Trace Mode + * Function 3: Miscellaneous Control + */ + +#define MC_AMD_DEV_OFFSET 0x18 /* node ID + offset == PCI dev num */ + +enum mc_funcnum { + MC_FUNC_HTCONFIG = 0, + MC_FUNC_ADDRMAP = 1, + MC_FUNC_DRAMCTL = 2, + MC_FUNC_MISCCTL = 3 +}; + +/* + * For a given (bus, device, function) a particular offset selects the + * desired register. All registers are 32-bits wide. + * + * Different family 0xf processor revisions vary slightly in the content + * of these configuration registers. The biggest change is with rev F + * where DDR2 support has been introduced along with some hardware-controlled + * correctable memory error thresholding. Fortunately most of the config info + * required by the mc-amd driver is similar across revisions. + * + * We will try to insulate most of the driver code from config register + * details by reading all memory-controller PCI config registers that we + * will need at driver attach time for each of functions 0 through 3, and + * storing them in a "cooked" form as memory controller properties. + * These are to be accessed directly where we have an mc_t to hand, otherwise + * through mcamd_get_numprop. As such we expect most/all use of the + * structures and macros defined below to be in those attach codepaths. + */ + +/* + * Function 0 (HT Config) offsets + */ +#define MC_HT_REG_RTBL_NODE_0 0x40 +#define MC_HT_REG_RTBL_INCR 4 +#define MC_HT_REG_NODEID 0x60 +#define MC_HT_REG_UNITID 0x64 + +/* + * Function 1 (address map) offsets for DRAM base, DRAM limit, DRAM hole + * registers. + */ +#define MC_AM_REG_DRAMBASE_0 0x40 /* Offset for DRAM Base 0 */ +#define MC_AM_REG_DRAMLIM_0 0x44 /* Offset for DRAM Limit 0 */ +#define MC_AM_REG_DRAM_INCR 8 /* incr between base/limit pairs */ +#define MC_AM_REG_HOLEADDR 0xf0 /* DRAM Hole Address Register */ + +/* + * Function 2 (dram controller) offsets for chip-select base, chip-select mask, + * DRAM bank address mapping, DRAM configuration registers. + */ +#define MC_DC_REG_CS_INCR 4 /* incr for CS base and mask */ +#define MC_DC_REG_CSBASE_0 0x40 /* 0x40 - 0x5c */ +#define MC_DC_REG_CSMASK_0 0x60 /* 0x60 - 0x7c */ +#define MC_DC_REG_BANKADDRMAP 0x80 /* DRAM Bank Address Mapping */ +#define MC_DC_REG_DRAMCFGLO 0x90 /* DRAM Configuration Low */ +#define MC_DC_REG_DRAMCFGHI 0x94 /* DRAM Configuration High */ +#define MC_DC_REG_DRAMMISC 0xa0 /* DRAM Miscellaneous */ + +/* + * Function 3 (misc control) offset for NB MCA config, scrubber control, + * online spare control and NB capabilities. + */ +#define MC_CTL_REG_NBCFG 0x44 /* MCA NB configuration register */ +#define MC_CTL_REG_SCRUBCTL 0x58 /* Scrub control register */ +#define MC_CTL_REG_SCRUBADDR_LO 0x5c /* DRAM Scrub Address Low */ +#define MC_CTL_REG_SCRUBADDR_HI 0x60 /* DRAM Scrub Address High */ +#define MC_CTL_REG_SPARECTL 0xb0 /* On-line spare control register */ +#define MC_CTL_REG_NBCAP 0xe8 /* NB Capabilities */ +#define MC_CTL_REG_EXTNBCFG 0x180 /* Ext. MCA NB configuration register */ + +#define MC_NBCAP_L3CAPABLE (1U << 25) +#define MC_NBCAP_MULTINODECPU (1U << 29) +#define MC_EXTNBCFG_ECCSYMSZ (1U << 25) + +/* + * MC4_MISC MSR and MC4_MISCj MSRs + */ +#define MC_MSR_NB_MISC0 0x413 +#define MC_MSR_NB_MISC1 0xc0000408 +#define MC_MSR_NB_MISC2 0xc0000409 +#define MC_MSR_NB_MISC3 0xc000040a +#define MC_MSR_NB_MISC(j) \ + ((j) == 0 ? MC_MSR_NB_MISC0 : MC_MSR_NB_MISC1 + (j) - 1) + +/* + * PCI registers will be represented as unions, with one fixed-width unsigned + * integer member providing access to the raw register value and one or more + * structs breaking the register out into bitfields (more than one struct if + * the register definitions varies across processor revisions). + * + * The "raw" union member will always be '_val32'. Use MCREG_VAL32 to + * access this member. + * + * The bitfield structs are all named _fmt_xxx where xxx identifies the + * processor revision to which it applies. At this point the only xxx + * values in use are: + * 'cmn' - applies to all revisions + * 'f_preF' - applies to revisions E and earlier + * 'f_revFG' - applies to revisions F and G + * + * Variants such as 'preD', 'revDE', 'postCG' etc should be introduced + * as requirements arise. The MC_REV_* and MC_REV_MATCH etc macros + * will also need to grow to match. Use MCREG_FIELD_* to access the + * individual bitfields of a register, perhaps using MC_REV_* and MC_REV_MATCH + * to decide which revision suffix to provide. Where a bitfield appears + * in different revisions but has the same use it should be named identically + * (even if the BKDG varies a little) so that the MC_REG_FIELD_* macros + * can lookup that member based on revision only. + */ + +#define MC_REV_UNKNOWN X86_CHIPREV_UNKNOWN + +#define MC_F_REV_B X86_CHIPREV_AMD_LEGACY_F_REV_B +#define MC_F_REV_C (X86_CHIPREV_AMD_LEGACY_F_REV_C0 | \ + X86_CHIPREV_AMD_LEGACY_F_REV_CG) +#define MC_F_REV_D X86_CHIPREV_AMD_LEGACY_F_REV_D +#define MC_F_REV_E X86_CHIPREV_AMD_LEGACY_F_REV_E +#define MC_F_REV_F X86_CHIPREV_AMD_LEGACY_F_REV_F +#define MC_F_REV_G X86_CHIPREV_AMD_LEGACY_F_REV_G + +#define MC_10_REV_A X86_CHIPREV_AMD_LEGACY_10_REV_A +#define MC_10_REV_B X86_CHIPREV_AMD_LEGACY_10_REV_B + +/* + * The most common groupings for memory controller features. + */ +#define MC_F_REVS_BC (MC_F_REV_B | MC_F_REV_C) +#define MC_F_REVS_DE (MC_F_REV_D | MC_F_REV_E) +#define MC_F_REVS_BCDE (MC_F_REVS_BC | MC_F_REVS_DE) +#define MC_F_REVS_FG (MC_F_REV_F | MC_F_REV_G) + +#define MC_10_REVS_AB (MC_10_REV_A | MC_10_REV_B) + +/* + * Is 'rev' included in the 'revmask' bitmask? + */ +#define MC_REV_MATCH(rev, revmask) chiprev_matches(rev, revmask) + +/* + * Is 'rev' at least revision 'revmin' or greater + */ +#define MC_REV_ATLEAST(rev, minrev) chiprev_at_least(rev, minrev) + +#define _MCREG_FIELD(up, revsuffix, field) ((up)->_fmt_##revsuffix.field) + +#define MCREG_VAL32(up) ((up)->_val32) + +/* + * Access a field that has the same structure in all families and revisions + */ +#define MCREG_FIELD_CMN(up, field) _MCREG_FIELD(up, cmn, field) + +/* + * Access a field as defined for family 0xf prior to revision F + */ +#define MCREG_FIELD_F_preF(up, field) _MCREG_FIELD(up, f_preF, field) + +/* + * Access a field as defined for family 0xf revisions F and G + */ +#define MCREG_FIELD_F_revFG(up, field) _MCREG_FIELD(up, f_revFG, field) + +/* + * Access a field as defined for family 0x10 revisions A and + */ +#define MCREG_FIELD_10_revAB(up, field) _MCREG_FIELD(up, 10_revAB, field) + +/* + * We will only define the register bitfields for little-endian order + */ +#ifdef _BIT_FIELDS_LTOH + +/* + * Function 0 - HT Configuration: Routing Table Node Register + */ +union mcreg_htroute { + uint32_t _val32; + struct { + uint32_t RQRte:4; /* 3:0 */ + uint32_t reserved1:4; /* 7:4 */ + uint32_t RPRte:4; /* 11:8 */ + uint32_t reserved2:4; /* 15:12 */ + uint32_t BCRte:4; /* 19:16 */ + uint32_t reserved3:12; /* 31:20 */ + } _fmt_cmn; +}; + +/* + * Function 0 - HT Configuration: Node ID Register + */ +union mcreg_nodeid { + uint32_t _val32; + struct { + uint32_t NodeId:3; /* 2:0 */ + uint32_t reserved1:1; /* 3:3 */ + uint32_t NodeCnt:3; /* 6:4 */ + uint32_t reserved2:1; /* 7:7 */ + uint32_t SbNode:3; /* 10:8 */ + uint32_t reserved3:1; /* 11:11 */ + uint32_t LkNode:3; /* 14:12 */ + uint32_t reserved4:1; /* 15:15 */ + uint32_t CpuCnt:4; /* 19:16 */ + uint32_t reserved:12; /* 31:20 */ + } _fmt_cmn; +}; + +#define HT_COHERENTNODES(up) (MCREG_FIELD_CMN(up, NodeCnt) + 1) +#define HT_SYSTEMCORECOUNT(up) (MCREG_FIELD_CMN(up, CpuCnt) + 1) + +/* + * Function 0 - HT Configuration: Unit ID Register + */ +union mcreg_unitid { + uint32_t _val32; + struct { + uint32_t C0Unit:2; /* 1:0 */ + uint32_t C1Unit:2; /* 3:2 */ + uint32_t McUnit:2; /* 5:4 */ + uint32_t HbUnit:2; /* 7:6 */ + uint32_t SbLink:2; /* 9:8 */ + uint32_t reserved:22; /* 31:10 */ + } _fmt_cmn; +}; + +/* + * Function 1 - DRAM Address Map: DRAM Base i Registers + * + */ + +union mcreg_drambase { + uint32_t _val32; + struct { + uint32_t RE:1; /* 0:0 - Read Enable */ + uint32_t WE:1; /* 1:1 - Write Enable */ + uint32_t reserved1:6; /* 7:2 */ + uint32_t IntlvEn:3; /* 10:8 - Interleave Enable */ + uint32_t reserved2:5; /* 15:11 */ + uint32_t DRAMBasei:16; /* 31:16 - Base Addr 39:24 */ + } _fmt_cmn; +}; + +#define MC_DRAMBASE(up) ((uint64_t)MCREG_FIELD_CMN(up, DRAMBasei) << 24) + +/* + * Function 1 - DRAM Address Map: DRAM Limit i Registers + * + */ + +union mcreg_dramlimit { + uint32_t _val32; + struct { + uint32_t DstNode:3; /* 2:0 - Destination Node */ + uint32_t reserved1:5; /* 7:3 */ + uint32_t IntlvSel:3; /* 10:8 - Interleave Select */ + uint32_t reserved2:5; /* 15:11 */ + uint32_t DRAMLimiti:16; /* 31:16 - Limit Addr 39:24 */ + } _fmt_cmn; +}; + +#define MC_DRAMLIM(up) \ + ((uint64_t)MCREG_FIELD_CMN(up, DRAMLimiti) << 24 | \ + (MCREG_FIELD_CMN(up, DRAMLimiti) ? ((1 << 24) - 1) : 0)) + +/* + * Function 1 - DRAM Address Map: DRAM Hole Address Register + */ + +union mcreg_dramhole { + uint32_t _val32; + struct { + uint32_t DramHoleValid:1; /* 0:0 */ + uint32_t reserved1:7; /* 7:1 */ + uint32_t DramHoleOffset:8; /* 15:8 */ + uint32_t reserved2:8; /* 23:16 */ + uint32_t DramHoleBase:8; /* 31:24 */ + } _fmt_cmn; +}; + +#define MC_DRAMHOLE_SIZE(up) (MCREG_FIELD_CMN(up, DramHoleOffset) << 24) + +/* + * Function 2 - DRAM Controller: DRAM CS Base Address Registers + */ + +union mcreg_csbase { + uint32_t _val32; + /* + * Register format in family 0xf revisions E and earlier + */ + struct { + uint32_t CSEnable:1; /* 0:0 - CS Bank Enable */ + uint32_t reserved1:8; /* 8:1 */ + uint32_t BaseAddrLo:7; /* 15:9 - Base Addr 19:13 */ + uint32_t reserved2:5; /* 20:16 */ + uint32_t BaseAddrHi:11; /* 31:21 - Base Addr 35:25 */ + } _fmt_f_preF; + /* + * Register format in family 0xf revisions F and G + */ + struct { + uint32_t CSEnable:1; /* 0:0 - CS Bank Enable */ + uint32_t Spare:1; /* 1:1 - Spare Rank */ + uint32_t TestFail:1; /* 2:2 - Memory Test Failed */ + uint32_t reserved1:2; /* 4:3 */ + uint32_t BaseAddrLo:9; /* 13:5 - Base Addr 21:13 */ + uint32_t reserved2:5; /* 18:14 */ + uint32_t BaseAddrHi:10; /* 28:19 - Base Addr 36:27 */ + uint32_t reserved3:3; /* 31:39 */ + } _fmt_f_revFG; +}; + +#define MC_CSBASE(up, rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? \ + (uint64_t)MCREG_FIELD_F_revFG(up, BaseAddrHi) << 27 | \ + (uint64_t)MCREG_FIELD_F_revFG(up, BaseAddrLo) << 13 : \ + (uint64_t)MCREG_FIELD_F_preF(up, BaseAddrHi) << 25 | \ + (uint64_t)MCREG_FIELD_F_preF(up, BaseAddrLo) << 13) + +/* + * Function 2 - DRAM Controller: DRAM CS Mask Registers + */ + +union mcreg_csmask { + uint32_t _val32; + /* + * Register format in family 0xf revisions E and earlier + */ + struct { + uint32_t reserved1:9; /* 8:0 */ + uint32_t AddrMaskLo:7; /* 15:9 - Addr Mask 19:13 */ + uint32_t reserved2:5; /* 20:16 */ + uint32_t AddrMaskHi:9; /* 29:21 - Addr Mask 33:25 */ + uint32_t reserved3:2; /* 31:30 */ + } _fmt_f_preF; + /* + * Register format in family 0xf revisions F and G + */ + struct { + uint32_t reserved1:5; /* 4:0 */ + uint32_t AddrMaskLo:9; /* 13:5 - Addr Mask 21:13 */ + uint32_t reserved2:5; /* 18:14 */ + uint32_t AddrMaskHi:10; /* 28:19 - Addr Mask 36:27 */ + uint32_t reserved3:3; /* 31:29 */ + } _fmt_f_revFG; +}; + +#define MC_CSMASKLO_LOBIT(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 13 : 13) +#define MC_CSMASKLO_HIBIT(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 21 : 19) + +#define MC_CSMASKHI_LOBIT(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 27 : 25) +#define MC_CSMASKHI_HIBIT(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 36 : 33) + +#define MC_CSMASK_UNMASKABLE(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 0 : 2) + +#define MC_CSMASK(up, rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? \ + (uint64_t)MCREG_FIELD_F_revFG(up, AddrMaskHi) << 27 | \ + (uint64_t)MCREG_FIELD_F_revFG(up, AddrMaskLo) << 13 | 0x7c01fff : \ + (uint64_t)MCREG_FIELD_F_preF(up, AddrMaskHi) << 25 | \ + (uint64_t)MCREG_FIELD_F_preF(up, AddrMaskLo) << 13 | 0x1f01fff) + +/* + * Function 2 - DRAM Controller: DRAM Bank Address Mapping Registers + */ + +union mcreg_bankaddrmap { + uint32_t _val32; + /* + * Register format in family 0xf revisions E and earlier + */ + struct { + uint32_t cs10:4; /* 3:0 - CS1/0 */ + uint32_t cs32:4; /* 7:4 - CS3/2 */ + uint32_t cs54:4; /* 11:8 - CS5/4 */ + uint32_t cs76:4; /* 15:12 - CS7/6 */ + uint32_t reserved1:14; /* 29:16 */ + uint32_t BankSwizzleMode:1; /* 30:30 */ + uint32_t reserved2:1; /* 31:31 */ + } _fmt_f_preF; + /* + * Register format in family 0xf revisions F and G + */ + struct { + uint32_t cs10:4; /* 3:0 - CS1/0 */ + uint32_t cs32:4; /* 7:4 - CS3/2 */ + uint32_t cs54:4; /* 11:8 - CS5/4 */ + uint32_t cs76:4; /* 15:12 - CS7/6 */ + uint32_t reserved1:16; /* 31:16 */ + } _fmt_f_revFG; + /* + * Accessing all mode encodings as one uint16 + */ + struct { + uint32_t allcsmodes:16; /* 15:0 */ + uint32_t pad:16; /* 31:16 */ + } _fmt_bankmodes; +}; + +#define MC_DC_BAM_CSBANK_MASK 0x0000000f +#define MC_DC_BAM_CSBANK_SHIFT 4 + +#define MC_CSBANKMODE(up, csnum) ((up)->_fmt_bankmodes.allcsmodes >> \ + MC_DC_BAM_CSBANK_SHIFT * MC_CHIP_DIMMPAIR(csnum) & MC_DC_BAM_CSBANK_MASK) + +/* + * Function 2 - DRAM Controller: DRAM Configuration Low and High + */ + +union mcreg_dramcfg_lo { + uint32_t _val32; + /* + * Register format in family 0xf revisions E and earlier. + * Bit 7 is a BIOS ScratchBit in revs D and earlier, + * PwrDwnTriEn in revision E; we don't use it so + * we'll call it ambig1. + */ + struct { + uint32_t DLL_Dis:1; /* 0 */ + uint32_t D_DRV:1; /* 1 */ + uint32_t QFC_EN:1; /* 2 */ + uint32_t DisDqsHys:1; /* 3 */ + uint32_t reserved1:1; /* 4 */ + uint32_t Burst2Opt:1; /* 5 */ + uint32_t Mod64BitMux:1; /* 6 */ + uint32_t ambig1:1; /* 7 */ + uint32_t DramInit:1; /* 8 */ + uint32_t DualDimmEn:1; /* 9 */ + uint32_t DramEnable:1; /* 10 */ + uint32_t MemClrStatus:1; /* 11 */ + uint32_t ESR:1; /* 12 */ + uint32_t SR_S:1; /* 13 */ + uint32_t RdWrQByp:2; /* 15:14 */ + uint32_t Width128:1; /* 16 */ + uint32_t DimmEcEn:1; /* 17 */ + uint32_t UnBufDimm:1; /* 18 */ + uint32_t ByteEn32:1; /* 19 */ + uint32_t x4DIMMs:4; /* 23:20 */ + uint32_t DisInRcvrs:1; /* 24 */ + uint32_t BypMax:3; /* 27:25 */ + uint32_t En2T:1; /* 28 */ + uint32_t UpperCSMap:1; /* 29 */ + uint32_t PwrDownCtl:2; /* 31:30 */ + } _fmt_f_preF; + /* + * Register format in family 0xf revisions F and G + */ + struct { + uint32_t InitDram:1; /* 0 */ + uint32_t ExitSelfRef:1; /* 1 */ + uint32_t reserved1:2; /* 3:2 */ + uint32_t DramTerm:2; /* 5:4 */ + uint32_t reserved2:1; /* 6 */ + uint32_t DramDrvWeak:1; /* 7 */ + uint32_t ParEn:1; /* 8 */ + uint32_t SelRefRateEn:1; /* 9 */ + uint32_t BurstLength32:1; /* 10 */ + uint32_t Width128:1; /* 11 */ + uint32_t x4DIMMs:4; /* 15:12 */ + uint32_t UnBuffDimm:1; /* 16 */ + uint32_t reserved3:2; /* 18:17 */ + uint32_t DimmEccEn:1; /* 19 */ + uint32_t reserved4:12; /* 31:20 */ + } _fmt_f_revFG; +}; + +/* + * Function 2 - DRAM Controller: DRAM Controller Miscellaneous Data + */ + +union mcreg_drammisc { + uint32_t _val32; + /* + * Register format in family 0xf revisions F and G + */ + struct { + uint32_t reserved2:1; /* 0 */ + uint32_t DisableJitter:1; /* 1 */ + uint32_t RdWrQByp:2; /* 3:2 */ + uint32_t Mod64Mux:1; /* 4 */ + uint32_t DCC_EN:1; /* 5 */ + uint32_t ILD_lmt:3; /* 8:6 */ + uint32_t DramEnabled:1; /* 9 */ + uint32_t PwrSavingsEn:1; /* 10 */ + uint32_t reserved1:13; /* 23:11 */ + uint32_t MemClkDis:8; /* 31:24 */ + } _fmt_f_revFG; +}; + +union mcreg_dramcfg_hi { + uint32_t _val32; + /* + * Register format in family 0xf revisions E and earlier. + */ + struct { + uint32_t AsyncLat:4; /* 3:0 */ + uint32_t reserved1:4; /* 7:4 */ + uint32_t RdPreamble:4; /* 11:8 */ + uint32_t reserved2:1; /* 12 */ + uint32_t MemDQDrvStren:2; /* 14:13 */ + uint32_t DisableJitter:1; /* 15 */ + uint32_t ILD_lmt:3; /* 18:16 */ + uint32_t DCC_EN:1; /* 19 */ + uint32_t MemClk:3; /* 22:20 */ + uint32_t reserved3:2; /* 24:23 */ + uint32_t MCR:1; /* 25 */ + uint32_t MC0_EN:1; /* 26 */ + uint32_t MC1_EN:1; /* 27 */ + uint32_t MC2_EN:1; /* 28 */ + uint32_t MC3_EN:1; /* 29 */ + uint32_t reserved4:1; /* 30 */ + uint32_t OddDivisorCorrect:1; /* 31 */ + } _fmt_f_preF; + /* + * Register format in family 0xf revisions F and G + */ + struct { + uint32_t MemClkFreq:3; /* 2:0 */ + uint32_t MemClkFreqVal:1; /* 3 */ + uint32_t MaxAsyncLat:4; /* 7:4 */ + uint32_t reserved1:4; /* 11:8 */ + uint32_t RDqsEn:1; /* 12 */ + uint32_t reserved2:1; /* 13 */ + uint32_t DisDramInterface:1; /* 14 */ + uint32_t PowerDownEn:1; /* 15 */ + uint32_t PowerDownMode:1; /* 16 */ + uint32_t FourRankSODimm:1; /* 17 */ + uint32_t FourRankRDimm:1; /* 18 */ + uint32_t reserved3:1; /* 19 */ + uint32_t SlowAccessMode:1; /* 20 */ + uint32_t reserved4:1; /* 21 */ + uint32_t BankSwizzleMode:1; /* 22 */ + uint32_t undocumented1:1; /* 23 */ + uint32_t DcqBypassMax:4; /* 27:24 */ + uint32_t FourActWindow:4; /* 31:28 */ + } _fmt_f_revFG; +}; + +/* + * Function 3 - Miscellaneous Control: Scrub Control Register + */ + +union mcreg_scrubctl { + uint32_t _val32; + struct { + uint32_t DramScrub:5; /* 4:0 */ + uint32_t reserved3:3; /* 7:5 */ + uint32_t L2Scrub:5; /* 12:8 */ + uint32_t reserved2:3; /* 15:13 */ + uint32_t DcacheScrub:5; /* 20:16 */ + uint32_t reserved1:11; /* 31:21 */ + } _fmt_cmn; +}; + +union mcreg_dramscrublo { + uint32_t _val32; + struct { + uint32_t ScrubReDirEn:1; /* 0 */ + uint32_t reserved:5; /* 5:1 */ + uint32_t ScrubAddrLo:26; /* 31:6 */ + } _fmt_cmn; +}; + +union mcreg_dramscrubhi { + uint32_t _val32; + struct { + uint32_t ScrubAddrHi:8; /* 7:0 */ + uint32_t reserved:24; /* 31:8 */ + } _fmt_cmn; +}; + +/* + * Function 3 - Miscellaneous Control: On-Line Spare Control Register + */ + +union mcreg_nbcfg { + uint32_t _val32; + /* + * Register format in family 0xf revisions E and earlier. + */ + struct { + uint32_t CpuEccErrEn:1; /* 0 */ + uint32_t CpuRdDatErrEn:1; /* 1 */ + uint32_t SyncOnUcEccEn:1; /* 2 */ + uint32_t SyncPktGenDis:1; /* 3 */ + uint32_t SyncPktPropDis:1; /* 4 */ + uint32_t IoMstAbortDis:1; /* 5 */ + uint32_t CpuErrDis:1; /* 6 */ + uint32_t IoErrDis:1; /* 7 */ + uint32_t WdogTmrDis:1; /* 8 */ + uint32_t WdogTmrCntSel:3; /* 11:9 */ + uint32_t WdogTmrBaseSel:2; /* 13:12 */ + uint32_t LdtLinkSel:2; /* 15:14 */ + uint32_t GenCrcErrByte0:1; /* 16 */ + uint32_t GenCrcErrByte1:1; /* 17 */ + uint32_t reserved1:2; /* 19:18 */ + uint32_t SyncOnWdogEn:1; /* 20 */ + uint32_t SyncOnAnyErrEn:1; /* 21 */ + uint32_t EccEn:1; /* 22 */ + uint32_t ChipKillEccEn:1; /* 23 */ + uint32_t IoRdDatErrEn:1; /* 24 */ + uint32_t DisPciCfgCpuErrRsp:1; /* 25 */ + uint32_t reserved2:1; /* 26 */ + uint32_t NbMcaToMstCpuEn:1; /* 27 */ + uint32_t reserved3:4; /* 31:28 */ + } _fmt_f_preF; + /* + * Register format in family 0xf revisions F and G + */ + struct { + uint32_t CpuEccErrEn:1; /* 0 */ + uint32_t CpuRdDatErrEn:1; /* 1 */ + uint32_t SyncOnUcEccEn:1; /* 2 */ + uint32_t SyncPktGenDis:1; /* 3 */ + uint32_t SyncPktPropDis:1; /* 4 */ + uint32_t IoMstAbortDis:1; /* 5 */ + uint32_t CpuErrDis:1; /* 6 */ + uint32_t IoErrDis:1; /* 7 */ + uint32_t WdogTmrDis:1; /* 8 */ + uint32_t WdogTmrCntSel:3; /* 11:9 */ + uint32_t WdogTmrBaseSel:2; /* 13:12 */ + uint32_t LdtLinkSel:2; /* 15:14 */ + uint32_t GenCrcErrByte0:1; /* 16 */ + uint32_t GenCrcErrByte1:1; /* 17 */ + uint32_t reserved1:2; /* 19:18 */ + uint32_t SyncOnWdogEn:1; /* 20 */ + uint32_t SyncOnAnyErrEn:1; /* 21 */ + uint32_t EccEn:1; /* 22 */ + uint32_t ChipKillEccEn:1; /* 23 */ + uint32_t IoRdDatErrEn:1; /* 24 */ + uint32_t DisPciCfgCpuErrRsp:1; /* 25 */ + uint32_t reserved2:1; /* 26 */ + uint32_t NbMcaToMstCpuEn:1; /* 27 */ + uint32_t DisTgtAbtCpuErrRsp:1; /* 28 */ + uint32_t DisMstAbtCpuErrRsp:1; /* 29 */ + uint32_t SyncOnDramAdrParErrEn:1; /* 30 */ + uint32_t reserved3:1; /* 31 */ + + } _fmt_f_revFG; +}; + +/* + * Function 3 - Miscellaneous Control: On-Line Spare Control Register + */ + +union mcreg_sparectl { + uint32_t _val32; + /* + * Register format in family 0xf revisions F and G + */ + struct { + uint32_t SwapEn:1; /* 0 */ + uint32_t SwapDone:1; /* 1 */ + uint32_t reserved1:2; /* 3:2 */ + uint32_t BadDramCs:3; /* 6:4 */ + uint32_t reserved2:5; /* 11:7 */ + uint32_t SwapDoneInt:2; /* 13:12 */ + uint32_t EccErrInt:2; /* 15:14 */ + uint32_t EccErrCntDramCs:3; /* 18:16 */ + uint32_t reserved3:1; /* 19 */ + uint32_t EccErrCntDramChan:1; /* 20 */ + uint32_t reserved4:2; /* 22:21 */ + uint32_t EccErrCntWrEn:1; /* 23 */ + uint32_t EccErrCnt:4; /* 27:24 */ + uint32_t reserved5:4; /* 31:28 */ + } _fmt_f_revFG; + /* + * Regiser format in family 0x10 revisions A and B + */ + struct { + uint32_t SwapEn0:1; /* 0 */ + uint32_t SwapDone0:1; /* 1 */ + uint32_t SwapEn1:1; /* 2 */ + uint32_t SwapDone1:1; /* 3 */ + uint32_t BadDramCs0:3; /* 6:4 */ + uint32_t reserved1:1; /* 7 */ + uint32_t BadDramCs1:3; /* 10:8 */ + uint32_t reserved2:1; /* 11 */ + uint32_t SwapDoneInt:2; /* 13:12 */ + uint32_t EccErrInt:2; /* 15:14 */ + uint32_t EccErrCntDramCs:4; /* 19:16 */ + uint32_t EccErrCntDramChan:2; /* 21:20 */ + uint32_t reserved4:1; /* 22 */ + uint32_t EccErrCntWrEn:1; /* 23 */ + uint32_t EccErrCnt:4; /* 27:24 */ + uint32_t LvtOffset:4; /* 31:28 */ + } _fmt_10_revAB; +}; + +/* + * Since the NB is on-chip some registers are also accessible as MSRs. + * We will represent such registers as bitfields as in the 32-bit PCI + * registers above, with the restriction that we must compile for 32-bit + * kernels and so 64-bit bitfields cannot be used. + */ + +#define _MCMSR_FIELD(up, revsuffix, field) ((up)->_fmt_##revsuffix.field) + +#define MCMSR_VAL(up) ((up)->_val64) + +#define MCMSR_FIELD_CMN(up, field) _MCMSR_FIELD(up, cmn, field) +#define MCMSR_FIELD_F_preF(up, field) _MCMSR_FIELD(up, f_preF, field) +#define MCMSR_FIELD_F_revFG(up, field) _MCMSR_FIELD(up, f_revFG, field) +#define MCMSR_FIELD_10_revAB(up, field) _MCMSR_FIELD(up, 10_revAB, field) + +/* + * The NB MISC registers. On family 0xf rev F this was introduced with + * a 12-bit ECC error count of all ECC errors observed on this memory- + * controller (regardless of channel or chip-select) and the ability to + * raise an interrupt or SMI on overflow. In family 0x10 it has a similar + * purpose, but the register is is split into 4 misc registers + * MC4_MISC{0,1,2,3} accessible via both MSRs and PCI config space; + * they perform thresholding for dram, l3, HT errors. + */ + +union mcmsr_nbmisc { + uint64_t _val64; + /* + * MSR format in family 0xf revision F and later + */ + struct { + /* + * Lower 32 bits + */ + struct { + uint32_t _reserved; /* 31:0 */ + } _mcimisc_lo; + /* + * Upper 32 bits + */ + struct { + uint32_t _ErrCount:12; /* 43:32 */ + uint32_t _reserved1:4; /* 47:44 */ + uint32_t _Ovrflw:1; /* 48 */ + uint32_t _IntType:2; /* 50:49 */ + uint32_t _CntEn:1; /* 51 */ + uint32_t _LvtOff:4; /* 55:52 */ + uint32_t _reserved2:5; /* 60:56 */ + uint32_t _Locked:1; /* 61 */ + uint32_t _CntP:1; /* 62 */ + uint32_t _Valid:1; /* 63 */ + } _mcimisc_hi; + } _fmt_f_revFG; + /* + * MSR format in family 0x10 revisions A and B + */ + struct { + /* + * Lower 32 bits + */ + struct { + uint32_t _reserved:24; /* 23:0 */ + uint32_t _BlkPtr:8; /* 31:24 */ + } _mcimisc_lo; + /* + * Upper 32 bits + */ + struct { + uint32_t _ErrCnt:12; /* 43:32 */ + uint32_t _reserved1:4; /* 47:44 */ + uint32_t _Ovrflw:1; /* 48 */ + uint32_t _IntType:2; /* 50:49 */ + uint32_t _CntEn:1; /* 51 */ + uint32_t _LvtOff:4; /* 55:52 */ + uint32_t _reserved2:5; /* 60:56 */ + uint32_t _Locked:1; /* 61 */ + uint32_t _CntP:1; /* 62 */ + uint32_t _Valid:1; /* 63 */ + + } _mcimisc_hi; + } _fmt_10_revAB; +}; + +#define mcmisc_BlkPtr _mcimisc_lo._BlkPtr +#define mcmisc_ErrCount _mcimisc_hi._ErrCount +#define mcmisc_Ovrflw _mcimisc_hi._Ovrflw +#define mcmisc_IntType _mcimisc_hi._IntType +#define mcmisc_CntEn _mcimisc_hi._CntEn +#define mcmisc_LvtOff _mcimisc_hi._LvtOff +#define mcmisc_Locked _mcimisc_hi._Locked +#define mcmisc_CntP _mcimisc_hi._CntP +#define mcmisc_Valid _mcimisc_hi._Valid + +#endif /* _BIT_FIELDS_LTOH */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MC_AMD_H */ diff --git a/illumos-x86_64/usr/include/sys/mc_intel.h b/illumos-x86_64/usr/include/sys/mc_intel.h new file mode 100644 index 00000000..4c43d3d6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mc_intel.h @@ -0,0 +1,374 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _MC_INTEL_H +#define _MC_INTEL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define FM_EREPORT_CPU_INTEL "intel" + +#define MCINTEL_NVLIST_VERSTR "mcintel-nvlist-version" +#define MCINTEL_NVLIST_VERS0 0 +#define MCINTEL_NVLIST_VERS1 1 + +#define MCINTEL_NVLIST_VERS MCINTEL_NVLIST_VERS0 + +#define MCINTEL_NVLIST_MEM "memory-controller" +#define MCINTEL_NVLIST_NMEM "memory-controllers" +#define MCINTEL_NVLIST_MC "memory-channels" +#define MCINTEL_NVLIST_DIMMS "memory-dimms" +#define MCINTEL_NVLIST_DIMMSZ "memory-dimm-size" +#define MCINTEL_NVLIST_NRANKS "dimm-max-ranks" +#define MCINTEL_NVLIST_NDIMMS "dimm-max-dimms" +#define MCINTEL_NVLIST_RANKS "dimm-ranks" +#define MCINTEL_NVLIST_1ST_RANK "dimm-start-rank" +#define MCINTEL_NVLIST_DIMM_NUM "dimm-number" +#define MCINTEL_NVLIST_ROWS "dimm-rows" +#define MCINTEL_NVLIST_COL "dimm-column" +#define MCINTEL_NVLIST_BANK "dimm-banks" +#define MCINTEL_NVLIST_WIDTH "dimm-width" +#define MCINTEL_NVLIST_MID "dimm-manufacture-id" +#define MCINTEL_NVLIST_MLOC "dimm-manufacture-location" +#define MCINTEL_NVLIST_MWEEK "dimm-manufacture-week" +#define MCINTEL_NVLIST_MYEAR "dimm-manufacture-year" +#define MCINTEL_NVLIST_SERIALNO "dimm-serial-number" +#define MCINTEL_NVLIST_PARTNO "dimm-part-number" +#define MCINTEL_NVLIST_REV "dimm-part-rev" + +/* + * Version 1 payload. Whereas the version 0 payload uses a flat name space, we + * instead opt to use a hierarchical name space. This means that we can know how + * many devices there are at any level, as each level has this. Effectively, + * this means that we have an nvlist structure, for a socket that looks like: + * + * socket + * string version + * uint8_t num-memory-controllers + * nvlist array memory-controller[] + * uint8_t num-channels + * boolean ecc + * string page policy + * string lockstep || independent + * nvlist array channel[] + * uint8_t dpc + * nvlist array dimm[] + * boolean_t present; + * uint32_t ncolumns + * uint32_t nrows + * uint64_t density (in bytes) + * uint32_t width + * uint32_t ranks + * uint32_t banks + * boolean_t array ranks_disabled + * boolean_t hdrl-enabled + * boolean_t hdrl-parity + * uint32_t 3dnumranks + */ + +#define MCINTEL_NVLIST_V1_NMC "num-memory-controllers" +#define MCINTEL_NVLIST_V1_MCS "memory-controllers" +#define MCINTEL_NVLIST_V1_MC_NCHAN "num-memory-channels" +#define MCINTEL_NVLIST_V1_MC_CHANNELS "memory-controller-channels" +#define MCINTEL_NVLIST_V1_MC_ECC "memory-controller-ecc" +#define MCINTEL_NVLIST_V1_MC_POLICY "memory-controller-page-policy" +#define MCINTEL_NVLIST_V1_MC_POLICY_OPEN "open-page" +#define MCINTEL_NVLIST_V1_MC_POLICY_CLOSED "closed-page" +#define MCINTEL_NVLIST_V1_MC_CHAN_MODE "memory-controller-channel-mode" +#define MCINTEL_NVLIST_V1_MC_CHAN_MODE_LOCK "lockstep" +#define MCINTEL_NVLIST_V1_MC_CHAN_MODE_INDEP "independent" +#define MCINTEL_NVLIST_V1_CHAN_NDPC "memory-channel-dimms-per-channel" +#define MCINTEL_NVLIST_V1_CHAN_DIMMS "memory-channel-dimms" +#define MCINTEL_NVLIST_V1_DIMM_PRESENT "dimm-present" +#define MCINTEL_NVLIST_V1_DIMM_SIZE "dimm-size" +#define MCINTEL_NVLIST_V1_DIMM_NCOLS "dimm-num-columns" +#define MCINTEL_NVLIST_V1_DIMM_NROWS "dimm-num-rows" +#define MCINTEL_NVLIST_V1_DIMM_DENSITY "dimm-density" +#define MCINTEL_NVLIST_V1_DIMM_WIDTH "dimm-width" +#define MCINTEL_NVLIST_V1_DIMM_RANKS "dimm-ranks" +#define MCINTEL_NVLIST_V1_DIMM_BANKS "dimm-banks" +#define MCINTEL_NVLIST_V1_DIMM_RDIS "dimm-ranks-disabled" +#define MCINTEL_NVLIST_V1_DIMM_HDRL "dimm-hdrl-enabled" +#define MCINTEL_NVLIST_V1_DIMM_HDRLP "dimm-hdrl-parity-enabled" +#define MCINTEL_NVLIST_V1_DIMM_3DRANK "dimm-3dranks" + +#define FM_EREPORT_PAYLOAD_NAME_FERR_GLOBAL "ferr_global" +#define FM_EREPORT_PAYLOAD_NAME_NERR_GLOBAL "nerr_global" +#define FM_EREPORT_PAYLOAD_NAME_FSB "fsb" +#define FM_EREPORT_PAYLOAD_NAME_FERR_FAT_FSB "ferr_fat_fsb" +#define FM_EREPORT_PAYLOAD_NAME_NERR_FAT_FSB "nerr_fat_fsb" +#define FM_EREPORT_PAYLOAD_NAME_FERR_NF_FSB "ferr_nf_fsb" +#define FM_EREPORT_PAYLOAD_NAME_NERR_NF_FSB "nerr_nf_fsb" +#define FM_EREPORT_PAYLOAD_NAME_NRECFSB "nrecfsb" +#define FM_EREPORT_PAYLOAD_NAME_NRECFSB_ADDR "nrecfsb_addr" +#define FM_EREPORT_PAYLOAD_NAME_RECFSB "recfsb" +#define FM_EREPORT_PAYLOAD_NAME_PEX "pex" +#define FM_EREPORT_PAYLOAD_NAME_PEX_FAT_FERR "pex_fat_ferr" +#define FM_EREPORT_PAYLOAD_NAME_PEX_FAT_NERR "pex_fat_nerr" +#define FM_EREPORT_PAYLOAD_NAME_PEX_NF_CORR_FERR "pex_nf_corr_ferr" +#define FM_EREPORT_PAYLOAD_NAME_PEX_NF_CORR_NERR "pex_nf_corr_nerr" +#define FM_EREPORT_PAYLOAD_NAME_UNCERRSEV "uncerrsev" +#define FM_EREPORT_PAYLOAD_NAME_RPERRSTS "rperrsts" +#define FM_EREPORT_PAYLOAD_NAME_RPERRSID "rperrsid" +#define FM_EREPORT_PAYLOAD_NAME_UNCERRSTS "uncerrsts" +#define FM_EREPORT_PAYLOAD_NAME_AERRCAPCTRL "aerrcapctrl" +#define FM_EREPORT_PAYLOAD_NAME_CORERRSTS "corerrsts" +#define FM_EREPORT_PAYLOAD_NAME_PEXDEVSTS "pexdevsts" +#define FM_EREPORT_PAYLOAD_NAME_FERR_FAT_INT "ferr_fat_int" +#define FM_EREPORT_PAYLOAD_NAME_FERR_NF_INT "ferr_nf_int" +#define FM_EREPORT_PAYLOAD_NAME_NERR_FAT_INT "nerr_fat_int" +#define FM_EREPORT_PAYLOAD_NAME_NERR_NF_INT "nerr_nf_int" +#define FM_EREPORT_PAYLOAD_NAME_NRECINT "nrecint" +#define FM_EREPORT_PAYLOAD_NAME_RECINT "recint" +#define FM_EREPORT_PAYLOAD_NAME_NRECSF "nrecsf" +#define FM_EREPORT_PAYLOAD_NAME_RECSF "recsf" +#define FM_EREPORT_PAYLOAD_NAME_RANK "rank" +#define FM_EREPORT_PAYLOAD_NAME_BANK "bank" +#define FM_EREPORT_PAYLOAD_NAME_CAS "cas" +#define FM_EREPORT_PAYLOAD_NAME_RAS "ras" +#define FM_EREPORT_PAYLOAD_NAME_FERR_FAT_FBD "ferr_fat_fbd" +#define FM_EREPORT_PAYLOAD_NAME_NERR_FAT_FBD "nerr_fat_fbd" +#define FM_EREPORT_PAYLOAD_NAME_VALIDLOG "validlog" +#define FM_EREPORT_PAYLOAD_NAME_NRECMEMA "nrecmema" +#define FM_EREPORT_PAYLOAD_NAME_NRECMEMB "nrecmemb" +#define FM_EREPORT_PAYLOAD_NAME_NRECFGLOG "nrecfglog" +#define FM_EREPORT_PAYLOAD_NAME_NRECFBDA "nrecfbda" +#define FM_EREPORT_PAYLOAD_NAME_NRECFBDB "nrecfbdb" +#define FM_EREPORT_PAYLOAD_NAME_NRECFBDC "nrecfbdc" +#define FM_EREPORT_PAYLOAD_NAME_NRECFBDD "nrecfbdd" +#define FM_EREPORT_PAYLOAD_NAME_NRECFBDE "nrecfbde" +#define FM_EREPORT_PAYLOAD_NAME_NRECFBDF "nrecfbdf" +#define FM_EREPORT_PAYLOAD_NAME_SPCPC "spcpc" +#define FM_EREPORT_PAYLOAD_NAME_SPCPS "spcps" +#define FM_EREPORT_PAYLOAD_NAME_UERRCNT "uerrcnt" +#define FM_EREPORT_PAYLOAD_NAME_UERRCNT_LAST "uerrcnt_last" +#define FM_EREPORT_PAYLOAD_NAME_BADRAM "badram" +#define FM_EREPORT_PAYLOAD_NAME_BADRAMA "badrama" +#define FM_EREPORT_PAYLOAD_NAME_BADRAMB "badramb" +#define FM_EREPORT_PAYLOAD_NAME_BADCNT "badcnt" +#define FM_EREPORT_PAYLOAD_NAME_MC "mc" +#define FM_EREPORT_PAYLOAD_NAME_MCA "mca" +#define FM_EREPORT_PAYLOAD_NAME_TOLM "tolm" +#define FM_EREPORT_PAYLOAD_NAME_MIR "mir" +#define FM_EREPORT_PAYLOAD_NAME_MTR "mtr" +#define FM_EREPORT_PAYLOAD_NAME_DMIR "dmir" +#define FM_EREPORT_PAYLOAD_NAME_FERR_NF_FBD "ferr_nf_fbd" +#define FM_EREPORT_PAYLOAD_NAME_NERR_NF_FBD "nerr_nf_fbd" +#define FM_EREPORT_PAYLOAD_NAME_FERR_NF_MEM "ferr_nf_mem" +#define FM_EREPORT_PAYLOAD_NAME_NERR_NF_MEM "nerr_nf_mem" +#define FM_EREPORT_PAYLOAD_NAME_RECMEMA "recmema" +#define FM_EREPORT_PAYLOAD_NAME_RECMEMB "recmemb" +#define FM_EREPORT_PAYLOAD_NAME_REDMEMA "redmema" +#define FM_EREPORT_PAYLOAD_NAME_REDMEMB "redmemb" +#define FM_EREPORT_PAYLOAD_NAME_RECFGLOG "recfglog" +#define FM_EREPORT_PAYLOAD_NAME_RECFBDA "recfbda" +#define FM_EREPORT_PAYLOAD_NAME_RECFBDB "recfbdb" +#define FM_EREPORT_PAYLOAD_NAME_RECFBDC "recfbdc" +#define FM_EREPORT_PAYLOAD_NAME_RECFBDD "recfbdd" +#define FM_EREPORT_PAYLOAD_NAME_RECFBDE "recfbde" +#define FM_EREPORT_PAYLOAD_NAME_RECFBDF "recfbdf" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNT "cerrcnt" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNT_LAST "cerrcnt_last" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNT_EXT "cerrcnt_ext" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNT_EXT_LAST "cerrcnt_ext_last" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNTA "cerrcnta" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNTB "cerrcntb" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNTC "cerrcntc" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNTD "cerrcntd" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNTA_LAST "cerrcnta_last" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNTB_LAST "cerrcntb_last" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNTC_LAST "cerrcntc_last" +#define FM_EREPORT_PAYLOAD_NAME_CERRCNTD_LAST "cerrcntd_last" +#define FM_EREPORT_PAYLOAD_NAME_PCISTS "pcists" +#define FM_EREPORT_PAYLOAD_NAME_PEXDEVSTS "pexdevsts" +#define FM_EREPORT_PAYLOAD_NAME_ERROR_NO "intel-error-list" + +#define FM_EREPORT_PAYLOAD_NAME_CTSTS "ctsts" +#define FM_EREPORT_PAYLOAD_NAME_THRTSTS "thrtsts" +#define FM_EREPORT_PAYLOAD_NAME_FERR_FAT_THR "ferr_fat_thr" +#define FM_EREPORT_PAYLOAD_NAME_NERR_FAT_THR "nerr_fat_thr" +#define FM_EREPORT_PAYLOAD_NAME_FERR_NF_THR "ferr_nf_thr" +#define FM_EREPORT_PAYLOAD_NAME_NERR_NF_THR "nerr_nf_thr" + +#define FM_EREPORT_PAYLOAD_NAME_ADDR "addr" +#define FM_EREPORT_PAYLOAD_NAME_BANK_NUM "bank-number" +#define FM_EREPORT_PAYLOAD_NAME_BANK_MISC "bank-misc" +#define FM_EREPORT_PAYLOAD_NAME_BANK_STAT "bank-status" +#define FM_EREPORT_PAYLOAD_NAME_BANK_OFFSET "bank-offset" +#define FM_EREPORT_PAYLOAD_NAME_MC_TYPE "mc-type" +#define FM_EREPORT_PAYLOAD_CPUID "cpuid" + +#define FM_EREPORT_PAYLOAD_BQR "Bus-queue-request" +#define FM_EREPORT_PAYLOAD_BQET "Bus-queue-error-type" +#define FM_EREPORT_PAYLOAD_FRC "FRC-error" +#define FM_EREPORT_PAYLOAD_BERR "BERR" +#define FM_EREPORT_PAYLOAD_INT_BINT "Internal-BINT" +#define FM_EREPORT_PAYLOAD_EXT_BINT "External-BINT" +#define FM_EREPORT_PAYLOAD_BUS_BINT "Bus-BINT" +#define FM_EREPORT_PAYLOAD_TO_BINT "Timeout-BINT" +#define FM_EREPORT_PAYLOAD_HARD "Hard-error" +#define FM_EREPORT_PAYLOAD_IERR "IERR" +#define FM_EREPORT_PAYLOAD_AERR "AERR" +#define FM_EREPORT_PAYLOAD_UERR "UERR" +#define FM_EREPORT_PAYLOAD_CECC "CECC" +#define FM_EREPORT_PAYLOAD_UECC "UECC" +#define FM_EREPORT_PAYLOAD_ECC_SYND "ECC-syndrome" + +#define FM_EREPORT_PAYLOAD_FSB_PARITY "fsb-address-parity" +#define FM_EREPORT_PAYLOAD_RESP_HF "response-hard-fail" +#define FM_EREPORT_PAYLOAD_RESP_PARITY "response-parity" +#define FM_EREPORT_PAYLOAD_DATA_PARITY "bus-data-parity" +#define FM_EREPORT_PAYLOAD_INV_PIC "invalid-pic-request" +#define FM_EREPORT_PAYLOAD_PAD_SM "pad-state-machine" +#define FM_EREPORT_PAYLOAD_PAD_SG "pad-strobe-glitch" + +#define FM_EREPORT_PAYLOAD_TAG "tag-error" +#define FM_EREPORT_PAYLOAD_TAG_CLEAN "clean" +#define FM_EREPORT_PAYLOAD_TAG_HIT "hit" +#define FM_EREPORT_PAYLOAD_TAG_MISS "miss" +#define FM_EREPORT_PAYLOAD_DATA "data-error" +#define FM_EREPORT_PAYLOAD_DATA_SINGLE "single-bit" +#define FM_EREPORT_PAYLOAD_DATA_DBL_CLEAN "double-bit-clean" +#define FM_EREPORT_PAYLOAD_DATA_DBL_MOD "double-bit-modified" +#define FM_EREPORT_PAYLOAD_L3 "l3-cache" +#define FM_EREPORT_PAYLOAD_INV_PIC "invalid-pic-request" +#define FM_EREPORT_PAYLOAD_CACHE_NERRORS "cache-error-count" + +#define FM_EREPORT_PAYLOAD_NAME_RESOURCE "resource" +#define FM_EREPORT_PAYLOAD_MEM_ECC_COUNTER_THIS "mem_cor_ecc_counter" +#define FM_EREPORT_PAYLOAD_MEM_ECC_COUNTER_LAST "mem_cor_ecc_counter_last" + +#define INTEL_NB_5000P 0x25d88086 +#define INTEL_NB_5000V 0x25d48086 +#define INTEL_NB_5000X 0x25c08086 +#define INTEL_NB_5000Z 0x25d08086 +#define INTEL_NB_5100 0x65c08086 +#define INTEL_NB_5400 0x40008086 +#define INTEL_NB_5400A 0x40018086 +#define INTEL_NB_5400B 0x40038086 +#define INTEL_NB_7300 0x36008086 + +#define INTEL_NHM 0x2c408086 +#define INTEL_QP_IO 0x34008086 +#define INTEL_QP_36D 0x34068086 +#define INTEL_QP_24D 0x34038086 +#define INTEL_QP_WP 0x34058086 +#define INTEL_QP_U1 0x34018086 +#define INTEL_QP_U2 0x34028086 +#define INTEL_QP_U3 0x34048086 +#define INTEL_QP_U4 0x34078086 +#define INTEL_QP_JF 0x37208086 +#define INTEL_QP_JF0 0x37008086 +#define INTEL_QP_JF1 0x37018086 +#define INTEL_QP_JF2 0x37028086 +#define INTEL_QP_JF3 0x37038086 +#define INTEL_QP_JF4 0x37048086 +#define INTEL_QP_JF5 0x37058086 +#define INTEL_QP_JF6 0x37068086 +#define INTEL_QP_JF7 0x37078086 +#define INTEL_QP_JF8 0x37088086 +#define INTEL_QP_JF9 0x37098086 +#define INTEL_QP_JFa 0x370a8086 +#define INTEL_QP_JFb 0x370b8086 +#define INTEL_QP_JFc 0x370c8086 +#define INTEL_QP_JFd 0x370d8086 +#define INTEL_QP_JFe 0x370e8086 +#define INTEL_QP_JFf 0x370f8086 + +/* Intel QuickPath Bus Interconnect Errors */ + +#define MSR_MC_STATUS_QP_HEADER_PARITY (1 << 16) +#define MSR_MC_STATUS_QP_DATA_PARITY (1 << 17) +#define MSR_MC_STATUS_QP_RETRIES_EXCEEDED (1 << 18) +#define MSR_MC_STATUS_QP_POISON (1 << 19) + +#define MSR_MC_STATUS_QP_UNSUPPORTED_MSG (1 << 22) +#define MSR_MC_STATUS_QP_UNSUPPORTED_CREDIT (1 << 23) +#define MSR_MC_STATUS_QP_FLIT_BUF_OVER (1 << 24) +#define MSR_MC_STATUS_QP_FAILED_RESPONSE (1 << 25) +#define MSR_MC_STATUS_QP_CLOCK_JITTER (1 << 26) + +#define MSR_MC_MISC_QP_CLASS 0x000000ff +#define MSR_MC_MISC_QP_RTID 0x00003f00 +#define MSR_MC_MISC_QP_RHNID 0x00070000 +#define MSR_MC_MISC_QP_IIB 0x01000000 + +/* Intel QuickPath Memory Errors */ + +#define MCAX86_COMPOUND_BUS_MEMORY 0x0080 +#define MCAX86_COMPOUND_BUS_MEMORY_MASK 0xff80 +#define MCAX86_COMPOUND_BUS_MEMORY_TRANSACTION 0x0070 +#define MCAX86_COMPOUND_BUS_MEMORY_READ 0x0010 +#define MCAX86_COMPOUND_BUS_MEMORY_WRITE 0x0020 +#define MCAX86_COMPOUND_BUS_MEMORY_CMD 0x0030 +#define MCAX86_COMPOUND_BUS_MEMORY_CHANNEL 0x000f + +#define MSR_MC_STATUS_MEM_ECC_READ (1 << 16) +#define MSR_MC_STATUS_MEM_ECC_SCRUB (1 << 17) +#define MSR_MC_STATUS_MEM_PARITY (1 << 18) +#define MSR_MC_STATUS_MEM_REDUNDANT_MEM (1 << 19) +#define MSR_MC_STATUS_MEM_SPARE_MEM (1 << 20) +#define MSR_MC_STATUS_MEM_ILLEGAL_ADDR (1 << 21) +#define MSR_MC_STATUS_MEM_BAD_ID (1 << 22) +#define MSR_MC_STATUS_MEM_ADDR_PARITY (1 << 23) +#define MSR_MC_STATUS_MEM_BYTE_PARITY (1 << 24) + +#define MSR_MC_MISC_MEM_RTID 0x00000000000000ffULL +#define MSR_MC_MISC_MEM_DIMM 0x0000000000030000ULL +#define MSR_MC_MISC_MEM_DIMM_SHIFT 16 +#define MSR_MC_MISC_MEM_CHANNEL 0x00000000000c0000ULL +#define MSR_MC_MISC_MEM_CHANNEL_SHIFT 18 +#define MSR_MC_MISC_MEM_SYNDROME 0xffffffff00000000ULL +#define MSR_MC_MISC_MEM_SYNDROME_SHIFT 32 + +#define OFFSET_ROW_BANK_COL 0x8000000000000000ULL +#define OFFSET_RANK_SHIFT 52 +#define OFFSET_RAS_SHIFT 32 +#define OFFSET_BANK_SHIFT 24 +#define TCODE_OFFSET(rank, bank, ras, cas) (OFFSET_ROW_BANK_COL | \ + ((uint64_t)(rank) << OFFSET_RANK_SHIFT) | \ + ((uint64_t)(ras) << OFFSET_RAS_SHIFT) | \ + ((uint64_t)(bank) << OFFSET_BANK_SHIFT) | (cas)) + +#define MAX_CAS_MASK 0xFFFFFF +#define MAX_BANK_MASK 0xFF +#define MAX_RAS_MASK 0xFFFFF +#define MAX_RANK_MASK 0x7FF +#define TCODE_OFFSET_RANK(tcode) \ + (((tcode) >> OFFSET_RANK_SHIFT) & MAX_RANK_MASK) +#define TCODE_OFFSET_RAS(tcode) (((tcode) >> OFFSET_RAS_SHIFT) & MAX_RAS_MASK) +#define TCODE_OFFSET_BANK(tcode) \ + (((tcode) >> OFFSET_BANK_SHIFT) & MAX_BANK_MASK) +#define TCODE_OFFSET_CAS(tcode) ((tcode) & MAX_CAS_MASK) + +#ifdef __cplusplus +} +#endif + +#endif /* _MC_INTEL_H */ diff --git a/illumos-x86_64/usr/include/sys/mca_amd.h b/illumos-x86_64/usr/include/sys/mca_amd.h new file mode 100644 index 00000000..4b6d2ba7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mca_amd.h @@ -0,0 +1,402 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MCA_AMD_H +#define _SYS_MCA_AMD_H + +#include + +/* + * Constants for the Machine Check Architecture as implemented on AMD CPUs. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define AMD_MSR_MCG_CAP 0x179 +#define AMD_MSR_MCG_STATUS 0x17a +#define AMD_MSR_MCG_CTL 0x17b + +#define AMD_MCA_BANK_DC 0 /* Data Cache */ +#define AMD_MCA_BANK_IC 1 /* Instruction Cache */ +#define AMD_MCA_BANK_BU 2 /* Bus Unit */ +#define AMD_MCA_BANK_LS 3 /* Load/Store Unit */ +#define AMD_MCA_BANK_NB 4 /* Northbridge */ +#define AMD_MCA_BANK_COUNT 5 + +#define AMD_MSR_DC_CTL 0x400 +#define AMD_MSR_DC_MASK 0xc0010044 +#define AMD_MSR_DC_STATUS 0x401 +#define AMD_MSR_DC_ADDR 0x402 +#define AMD_MSR_DC_MISC 0x403 + +#define AMD_MSR_IC_CTL 0x404 +#define AMD_MSR_IC_MASK 0xc0010045 +#define AMD_MSR_IC_STATUS 0x405 +#define AMD_MSR_IC_ADDR 0x406 +#define AMD_MSR_IC_MISC 0x407 + +#define AMD_MSR_BU_CTL 0x408 +#define AMD_MSR_BU_MASK 0xc0010046 +#define AMD_MSR_BU_STATUS 0x409 +#define AMD_MSR_BU_ADDR 0x40a +#define AMD_MSR_BU_MISC 0x40b + +#define AMD_MSR_LS_CTL 0x40c +#define AMD_MSR_LS_MASK 0xc0010047 +#define AMD_MSR_LS_STATUS 0x40d +#define AMD_MSR_LS_ADDR 0x40e +#define AMD_MSR_LS_MISC 0x40f + +#define AMD_MSR_NB_CTL 0x410 +#define AMD_MSR_NB_MASK 0xc0010048 +#define AMD_MSR_NB_STATUS 0x411 +#define AMD_MSR_NB_ADDR 0x412 +#define AMD_MSR_NB_MISC 0x413 + +#define AMD_MCG_EN_DC 0x01 +#define AMD_MCG_EN_IC 0x02 +#define AMD_MCG_EN_BU 0x04 +#define AMD_MCG_EN_LS 0x08 +#define AMD_MCG_EN_NB 0x10 + +/* + * Data Cache (DC) bank error-detection enabling bits and CTL register + * initializer value. + */ + +#define AMD_DC_EN_ECCI 0x00000001ULL +#define AMD_DC_EN_ECCM 0x00000002ULL +#define AMD_DC_EN_DECC 0x00000004ULL +#define AMD_DC_EN_DMTP 0x00000008ULL +#define AMD_DC_EN_DSTP 0x00000010ULL +#define AMD_DC_EN_L1TP 0x00000020ULL +#define AMD_DC_EN_L2TP 0x00000040ULL + +#define AMD_DC_CTL_INIT_CMN \ + (AMD_DC_EN_ECCI | AMD_DC_EN_ECCM | AMD_DC_EN_DECC | AMD_DC_EN_DMTP | \ + AMD_DC_EN_DSTP | AMD_DC_EN_L1TP | AMD_DC_EN_L2TP) + +/* + * Instruction Cache (IC) bank error-detection enabling bits and CTL register + * initializer value. + * + * The Northbridge will handle Read Data errors. Our initializer will enable + * all but the RDDE detector. + */ + +#define AMD_IC_EN_ECCI 0x00000001ULL +#define AMD_IC_EN_ECCM 0x00000002ULL +#define AMD_IC_EN_IDP 0x00000004ULL +#define AMD_IC_EN_IMTP 0x00000008ULL +#define AMD_IC_EN_ISTP 0x00000010ULL +#define AMD_IC_EN_L1TP 0x00000020ULL +#define AMD_IC_EN_L2TP 0x00000040ULL +#define AMD_IC_EN_RDDE 0x00000200ULL + +#define AMD_IC_CTL_INIT_CMN \ + (AMD_IC_EN_ECCI | AMD_IC_EN_ECCM | AMD_IC_EN_IDP | AMD_IC_EN_IMTP | \ + AMD_IC_EN_ISTP | AMD_IC_EN_L1TP | AMD_IC_EN_L2TP) + +/* + * Bus Unit (BU) bank error-detection enabling bits and CTL register + * initializer value. + * + * The Northbridge will handle Read Data errors. Our initializer will enable + * all but the S_RDE_* detectors. + */ + +#define AMD_BU_EN_S_RDE_HP 0x00000001ULL +#define AMD_BU_EN_S_RDE_TLB 0x00000002ULL +#define AMD_BU_EN_S_RDE_ALL 0x00000004ULL +#define AMD_BU_EN_S_ECC1_TLB 0x00000008ULL +#define AMD_BU_EN_S_ECC1_HP 0x00000010ULL +#define AMD_BU_EN_S_ECCM_TLB 0x00000020ULL +#define AMD_BU_EN_S_ECCM_HP 0x00000040ULL +#define AMD_BU_EN_L2T_PAR_ICDC 0x00000080ULL +#define AMD_BU_EN_L2T_PAR_TLB 0x00000100ULL +#define AMD_BU_EN_L2T_PAR_SNP 0x00000200ULL +#define AMD_BU_EN_L2T_PAR_CPB 0x00000400ULL +#define AMD_BU_EN_L2T_PAR_SCR 0x00000800ULL +#define AMD_BU_EN_L2D_ECC1_TLB 0x00001000ULL +#define AMD_BU_EN_L2D_ECC1_SNP 0x00002000ULL +#define AMD_BU_EN_L2D_ECC1_CPB 0x00004000ULL +#define AMD_BU_EN_L2D_ECCM_TLB 0x00008000ULL +#define AMD_BU_EN_L2D_ECCM_SNP 0x00010000ULL +#define AMD_BU_EN_L2D_ECCM_CPB 0x00020000ULL +#define AMD_BU_EN_L2T_ECC1_SCR 0x00040000ULL +#define AMD_BU_EN_L2T_ECCM_SCR 0x00080000ULL + +#define AMD_BU_CTL_INIT_CMN \ + (AMD_BU_EN_S_ECC1_TLB | AMD_BU_EN_S_ECC1_HP | \ + AMD_BU_EN_S_ECCM_TLB | AMD_BU_EN_S_ECCM_HP | \ + AMD_BU_EN_L2T_PAR_ICDC | AMD_BU_EN_L2T_PAR_TLB | \ + AMD_BU_EN_L2T_PAR_SNP | AMD_BU_EN_L2T_PAR_CPB | \ + AMD_BU_EN_L2T_PAR_SCR | AMD_BU_EN_L2D_ECC1_TLB | \ + AMD_BU_EN_L2D_ECC1_SNP | AMD_BU_EN_L2D_ECC1_CPB | \ + AMD_BU_EN_L2D_ECCM_TLB | AMD_BU_EN_L2D_ECCM_SNP | \ + AMD_BU_EN_L2D_ECCM_CPB | AMD_BU_EN_L2T_ECC1_SCR | \ + AMD_BU_EN_L2T_ECCM_SCR) + +/* + * Load/Store (LS) bank error-detection enabling bits and CTL register + * initializer value. + * + * The Northbridge will handle Read Data errors. That's the only type of + * error the LS unit can detect at present, so we won't be enabling any + * LS detectors. + */ + +#define AMD_LS_EN_S_RDE_S 0x00000001ULL +#define AMD_LS_EN_S_RDE_L 0x00000002ULL + +#define AMD_LS_CTL_INIT_CMN 0ULL + +/* + * NorthBridge (NB) MCi_MISC - DRAM Errors Threshold Register. + */ +#define AMD_NB_MISC_VALID (0x1ULL << 63) +#define AMD_NB_MISC_CTRP (0x1ULL << 62) +#define AMD_NB_MISC_LOCKED (0x1ULL << 61) +#define AMD_NB_MISC_CNTEN (0x1ULL << 51) +#define AMD_NB_MISC_INTTYPE (0x1ULL << 49) +#define AMD_NB_MISC_INTTYPE_MASK (0x3ULL << 49) +#define AMD_NB_MISC_OVRFLW (0x1ULL << 48) +#define AMD_NB_MISC_ERRCOUNT_MASK (0xfffULL << 32) + +/* + * The Northbridge (NB) is configured using both the standard MCA CTL register + * and a NB-specific configuration register (NB CFG). The AMD_NB_EN_* macros + * are the detector enabling bits for the NB MCA CTL register. The + * AMD_NB_CFG_* bits are for the NB CFG register. + * + * The CTL register can be initialized statically, but portions of the NB CFG + * register must be initialized based on the current machine's configuration. + * + * The MCA NB Control Register maps to MC4_CTL[31:0], but we initialize it + * via and MSR write of 64 bits so define all as ULL. + * + */ +#define AMD_NB_EN_CORRECC 0x00000001ULL +#define AMD_NB_EN_UNCORRECC 0x00000002ULL +#define AMD_NB_EN_CRCERR0 0x00000004ULL +#define AMD_NB_EN_CRCERR1 0x00000008ULL +#define AMD_NB_EN_CRCERR2 0x00000010ULL +#define AMD_NB_EN_SYNCPKT0 0x00000020ULL +#define AMD_NB_EN_SYNCPKT1 0x00000040ULL +#define AMD_NB_EN_SYNCPKT2 0x00000080ULL +#define AMD_NB_EN_MSTRABRT 0x00000100ULL +#define AMD_NB_EN_TGTABRT 0x00000200ULL +#define AMD_NB_EN_GARTTBLWK 0x00000400ULL +#define AMD_NB_EN_ATOMICRMW 0x00000800ULL +#define AMD_NB_EN_WCHDOGTMR 0x00001000ULL +#define AMD_NB_EN_DRAMPAR 0x00040000ULL /* revs F and G */ + +#define AMD_NB_CTL_INIT_CMN /* Revs B to G; All but GARTTBLWK */ \ + (AMD_NB_EN_CORRECC | AMD_NB_EN_UNCORRECC | \ + AMD_NB_EN_CRCERR0 | AMD_NB_EN_CRCERR1 | AMD_NB_EN_CRCERR2 | \ + AMD_NB_EN_SYNCPKT0 | AMD_NB_EN_SYNCPKT1 | AMD_NB_EN_SYNCPKT2 | \ + AMD_NB_EN_MSTRABRT | AMD_NB_EN_TGTABRT | \ + AMD_NB_EN_ATOMICRMW | AMD_NB_EN_WCHDOGTMR) + +#define AMD_NB_CTL_INIT_REV_FG /* Additional bits for revs F and G */ \ + AMD_NB_EN_DRAMPAR + +/* + * NB MCA Configuration register + */ +#define AMD_NB_CFG_CPUECCERREN 0x00000001 +#define AMD_NB_CFG_CPURDDATERREN 0x00000002 +#define AMD_NB_CFG_SYNCONUCECCEN 0x00000004 +#define AMD_NB_CFG_SYNCPKTGENDIS 0x00000008 +#define AMD_NB_CFG_SYNCPKTPROPDIS 0x00000010 +#define AMD_NB_CFG_IOMSTABORTDIS 0x00000020 +#define AMD_NB_CFG_CPUERRDIS 0x00000040 +#define AMD_NB_CFG_IOERRDIS 0x00000080 +#define AMD_NB_CFG_WDOGTMRDIS 0x00000100 +#define AMD_NB_CFG_SYNCONWDOGEN 0x00100000 +#define AMD_NB_CFG_SYNCONANYERREN 0x00200000 +#define AMD_NB_CFG_ECCEN 0x00400000 +#define AMD_NB_CFG_CHIPKILLECCEN 0x00800000 +#define AMD_NB_CFG_IORDDATERREN 0x01000000 +#define AMD_NB_CFG_DISPCICFGCPUERRRSP 0x02000000 +#define AMD_NB_CFG_NBMCATOMSTCPUEN 0x08000000 +#define AMD_NB_CFG_DISTGTABTCPUERRRSP 0x10000000 +#define AMD_NB_CFG_DISMSTABTCPUERRRSP 0x20000000 +#define AMD_NB_CFG_SYNCONDRAMADRPARERREN 0x40000000 /* Revs F & G */ + +/* + * We do not initialize the NB config with an absolute value; instead we + * selectively add some bits and remove others. Note that + * AMD_NB_CFG_{ADD,REMOVE}_{CMN,REV_FG} below are not the whole + * story here - additional config is performed regarding the watchdog (see + * ao_mca.c for details). + */ +#define AMD_NB_CFG_ADD_CMN /* Revs B to G */ \ + (AMD_NB_CFG_DISPCICFGCPUERRRSP | AMD_NB_CFG_SYNCONUCECCEN | \ + AMD_NB_CFG_CPUECCERREN) + +#define AMD_NB_CFG_REMOVE_CMN /* Revs B to G */ \ + (AMD_NB_CFG_NBMCATOMSTCPUEN | \ + AMD_NB_CFG_IORDDATERREN | AMD_NB_CFG_SYNCONANYERREN | \ + AMD_NB_CFG_SYNCONWDOGEN | AMD_NB_CFG_IOERRDIS | \ + AMD_NB_CFG_IOMSTABORTDIS | AMD_NB_CFG_SYNCPKTPROPDIS | \ + AMD_NB_CFG_SYNCPKTGENDIS) + +#define AMD_NB_CFG_ADD_REV_FG /* Revs F and G */ \ + AMD_NB_CFG_SYNCONDRAMADRPARERREN + +#define AMD_NB_CFG_REMOVE_REV_FG 0x0 /* Revs F and G */ + +#define AMD_NB_CFG_WDOGTMRCNTSEL_4095 0x00000000 +#define AMD_NB_CFG_WDOGTMRCNTSEL_2047 0x00000200 +#define AMD_NB_CFG_WDOGTMRCNTSEL_1023 0x00000400 +#define AMD_NB_CFG_WDOGTMRCNTSEL_511 0x00000600 +#define AMD_NB_CFG_WDOGTMRCNTSEL_255 0x00000800 +#define AMD_NB_CFG_WDOGTMRCNTSEL_127 0x00000a00 +#define AMD_NB_CFG_WDOGTMRCNTSEL_63 0x00000c00 +#define AMD_NB_CFG_WDOGTMRCNTSEL_31 0x00000e00 +#define AMD_NB_CFG_WDOGTMRCNTSEL_MASK 0x00000e00 +#define AMD_NB_CFG_WDOGTMRCNTSEL_SHIFT 9 + +#define AMD_NB_CFG_WDOGTMRBASESEL_1MS 0x00000000 +#define AMD_NB_CFG_WDOGTMRBASESEL_1US 0x00001000 +#define AMD_NB_CFG_WDOGTMRBASESEL_5NS 0x00002000 +#define AMD_NB_CFG_WDOGTMRBASESEL_MASK 0x00003000 +#define AMD_NB_CFG_WDOGTMRBASESEL_SHIFT 12 + +#define AMD_NB_CFG_LDTLINKSEL_MASK 0x0000c000 +#define AMD_NB_CFG_LDTLINKSEL_SHIFT 14 + +#define AMD_NB_CFG_GENCRCERRBYTE0 0x00010000 +#define AMD_NB_CFG_GENCRCERRBYTE1 0x00020000 + +/* + * The AMD extended error code is just one nibble of the upper 16 bits + * of the bank status (the resy being used for syndrome etc). So we use + * AMD_EXT_ERRCODE to retrieve that extended error code, not the generic + * MCAX86_MSERRCODE. + */ +#define _AMD_ERREXT_MASK 0x00000000000f0000ULL +#define _AMD_ERREXT_SHIFT 16 +#define AMD_EXT_ERRCODE(stat) \ + (((stat) & _AMD_ERREXT_MASK) >> _AMD_ERREXT_SHIFT) +#define AMD_EXT_MKERRCODE(errcode) \ + (((errcode) << _AMD_ERREXT_SHIFT) & _AMD_ERREXT_MASK) + +#define AMD_BANK_STAT_CECC 0x0000400000000000ULL +#define AMD_BANK_STAT_UECC 0x0000200000000000ULL +#define AMD_BANK_STAT_SCRUB 0x0000010000000000ULL + + /* syndrome[7:0] */ +#define AMD_BANK_STAT_SYND_MASK 0x007f800000000000ULL +#define AMD_BANK_STAT_SYND_SHIFT 47 + +#define AMD_BANK_SYND(stat) \ + (((stat) & AMD_BANK_STAT_SYND_MASK) >> AMD_BANK_STAT_SYND_SHIFT) +#define AMD_BANK_MKSYND(synd) \ + (((uint64_t)(synd) << AMD_BANK_STAT_SYND_SHIFT) & \ + AMD_BANK_STAT_SYND_MASK) + +#define AMD_NB_STAT_DRAMCHANNEL 0x0000020000000000ULL +#define AMD_NB_STAT_LDTLINK_MASK 0x0000007000000000ULL +#define AMD_NB_STAT_LDTLINK_SHIFT 4 +#define AMD_NB_STAT_ERRCPU1 0x0000000200000000ULL +#define AMD_NB_STAT_ERRCPU0 0x0000000100000000ULL + +#define AMD_NB_STAT_CKSYND_MASK 0x00000000ff000000 /* syndrome[15:8] */ +#define AMD_NB_STAT_CKSYND_SHIFT (24 - 8) /* shift [31:24] to [15:8] */ + +#define AMD_NB_STAT_CKSYND(stat) \ + ((((stat) & AMD_NB_STAT_CKSYND_MASK) >> AMD_NB_STAT_CKSYND_SHIFT) | \ + AMD_BANK_SYND((stat))) + +#define AMD_NB_STAT_MKCKSYND(synd) \ + ((((uint64_t)(synd) << AMD_NB_STAT_CKSYND_SHIFT) & \ + AMD_NB_STAT_CKSYND_MASK) | AMD_BANK_MKSYND(synd)) + +#define AMD_ERREXT_MASK 0x00000000000f0000ULL +#define AMD_ERREXT_SHIFT 16 + +#define AMD_ERRCODE_TLB_BIT 4 +#define AMD_ERRCODE_MEM_BIT 8 +#define AMD_ERRCODE_BUS_BIT 11 + +#define AMD_ERRCODE_TLB_MASK 0xfff0 +#define AMD_ERRCODE_MEM_MASK 0xff00 +#define AMD_ERRCODE_BUS_MASK 0xf800 + +#define AMD_ERRCODE_MKTLB(tt, ll) MCAX86_MKERRCODE_TLB(tt, ll) +#define AMD_ERRCODE_ISTLB(code) MCAX86_ERRCODE_ISTLB(code) + +#define AMD_ERRCODE_MKMEM(r4, tt, ll) MCAX86_MKERRCODE_MEMHIER(r4, tt, ll) +#define AMD_ERRCODE_ISMEM(code) MCAX86_ERRCODE_ISMEMHIER(code) + +#define AMD_ERRCODE_MKBUS(pp, t, r4, ii, ll) \ + MCAX86_MKERRCODE_BUS_INTERCONNECT(pp, t, r4, ii, ll) +#define AMD_ERRCODE_ISBUS(code) MCAX86_ERRCODE_ISBUS_INTERCONNECT(code) + +#define AMD_NB_ADDRLO_MASK 0xfffffff8 +#define AMD_NB_ADDRHI_MASK 0x000000ff + +#define AMD_SYNDTYPE_ECC 0 +#define AMD_SYNDTYPE_CHIPKILL 1 + +#define AMD_NB_SCRUBCTL_DRAM_MASK 0x0000001f +#define AMD_NB_SCRUBCTL_DRAM_SHIFT 0 +#define AMD_NB_SCRUBCTL_L2_MASK 0x00001f00 +#define AMD_NB_SCRUBCTL_L2_SHIFT 8 +#define AMD_NB_SCRUBCTL_DC_MASK 0x001f0000 +#define AMD_NB_SCRUBCTL_DC_SHIFT 16 +#define AMD_NB_SCRUBCTL_L3_MASK 0x1f000000 +#define AMD_NB_SCRUBCTL_L3_SHIFT 24 + +#define AMD_NB_SCRUBCTL_RATE_NONE 0 +#define AMD_NB_SCRUBCTL_RATE_MAX 0x16 + +#define AMD_NB_SCRUBADDR_LO_MASK 0xffffffc0 +#define AMD_NB_SCRUBADDR_LO_SHIFT 6 +#define AMD_NB_SCRUBADDR_LO_SCRUBREDIREN 0x1 +#define AMD_NB_SCRUBADDR_HI_MASK 0x000000ff + +#define AMD_NB_SCRUBADDR_MKLO(addr) \ + (((addr) & AMD_NB_SCRUBADDR_LO_MASK) >> AMD_NB_SCRUBADDR_LO_SHIFT) + +#define AMD_NB_SCRUBADDR_MKHI(addr) \ + (((addr) >> 32) & AMD_NB_SCRUBADDR_HI_MASK) + +#define AMD_NB_MKSCRUBCTL(l3, dc, l2, dr) ( \ + (((l3) << AMD_NB_SCRUBCTL_L3_SHIFT) & AMD_NB_SCRUBCTL_L3_MASK) | \ + (((dc) << AMD_NB_SCRUBCTL_DC_SHIFT) & AMD_NB_SCRUBCTL_DC_MASK) | \ + (((l2) << AMD_NB_SCRUBCTL_L2_SHIFT) & AMD_NB_SCRUBCTL_L2_MASK) | \ + (((dr) << AMD_NB_SCRUBCTL_DRAM_SHIFT) & AMD_NB_SCRUBCTL_DRAM_MASK)) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MCA_AMD_H */ diff --git a/illumos-x86_64/usr/include/sys/mca_x86.h b/illumos-x86_64/usr/include/sys/mca_x86.h new file mode 100644 index 00000000..b0e05ea3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mca_x86.h @@ -0,0 +1,438 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MCA_X86_H +#define _SYS_MCA_X86_H + +/* + * Constants for the Memory Check Architecture as implemented on generic x86 + * CPUs. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Architectural MSRs from the IA-32 Software Developer's Manual - IA32_MSR_* + */ +#define IA32_MSR_MCG_CAP 0x179 +#define IA32_MSR_MCG_STATUS 0x17a +#define IA32_MSR_MCG_CTL 0x17b + +#define MCG_CAP_CTL_P 0x00000100ULL +#define MCG_CAP_EXT_P 0x00000200ULL +#define MCG_CAP_TES_P 0x00000800ULL +#define MCG_CAP_CTL2_P 0x00000400ULL + +#define MCG_CAP_COUNT_MASK 0x000000ffULL +#define MCG_CAP_COUNT(cap) ((cap) & MCG_CAP_COUNT_MASK) + +#define MCG_CAP_EXT_CNT_MASK 0x00ff0000ULL +#define MCG_CAP_EXT_CNT_SHIFT 16 +#define MCG_CAP_EXT_CNT(cap) \ + (((cap) & MCG_CAP_EXT_CNT_MASK) >> MCG_CAP_EXT_CNT_SHIFT) + +#define MCG_STATUS_RIPV 0x01 +#define MCG_STATUS_EIPV 0x02 +#define MCG_STATUS_MCIP 0x04 + +/* + * There are as many error detector "banks" as indicated by + * IA32_MSR_MCG_CAP.COUNT. Each bank has a minimum of 3 associated + * registers (MCi_CTL, MCi_STATUS, and MCi_ADDR) and some banks + * may implement a fourth (MCi_MISC) which should only be read + * when MCi_STATUS.MISCV indicates that it exists and has valid data. + * + * The first bank features at MSR offsets 0x400 to 0x403, the next at + * 0x404 to 0x407, and so on. Current processors implement up to 6 + * banks (sixth one at 0x414 to 0x417). + * + * It is, sadly, not the case that the i'th set of 4 registers starting + * at 0x400 corresponds to MCi_{CTL,STATUS,ADDR,MISC} - for some Intel + * processors, for example, the order is 0/1/2/4/3. Nonetheless, we can + * still iterate through the banks and read all telemetry - there'll just + * be some potential confusion as to which processor unit a bank is + * associated with. Error reports should seek to disambiguate. + * + * IA32_MSR_MC(i, which) calculates the MSR address for th i'th bank + * of registers (not for MCi_*, as above) and one of CTL, STATUS, ADDR, MISC + */ + +#define _IA32_MSR_MC0_CTL 0x400ULL /* first/base reg */ +#define _IA32_MSR_OFFSET_CTL 0x0 /* offset within a bank */ +#define _IA32_MSR_OFFSET_STATUS 0x1 /* offset within a bank */ +#define _IA32_MSR_OFFSET_ADDR 0x2 /* offset within a bank */ +#define _IA32_MSR_OFFSET_MISC 0x3 /* offset within a bank */ + +#define _IA32_MSR_MC0_CTL2 0x280ULL /* first MCi_CTL2 reg */ + +#define IA32_MSR_MC(i, which) \ + (_IA32_MSR_MC0_CTL + (i) * 4 + _IA32_MSR_OFFSET_##which) + +#define IA32_MSR_MC_CTL2(i) (_IA32_MSR_MC0_CTL2 + (i)) + +/* + * IA32_MSR_MCG_CAP.MCG_EXT_P indicates that a processor implements + * a set of extended machine-check registers starting at MSR 0x180; + * when that is set, IA32_MSR_MCG_CAP.MCG_EXT_CNT indicates how + * many of these extended registers (addresses 0x180, 0x181, ...) + * are present. Which registers are present depends on whether support + * for 64-bit architecture is present. + */ + +#define _IA32_MCG_RAX 0x180ULL /* first/base extended reg */ + +#define IA32_MSR_EXT(i) (_IA32_MCG_RAX + (i)) + +#ifdef _BIT_FIELDS_LTOH +typedef union mca_x86_mcistatus { + uint64_t _val64; + struct { + /* + * Lower 32 bits of MCi_STATUS + */ + struct { + uint32_t _errcode:16; /* <15:0> */ + uint32_t _ms_errcode:16; /* <31:16> */ + } _mcis_lo; + /* + * Upper 32 bits of MCi_STATUS + */ + union { + /* + * If IA32_MCG_CAP.MCG_TES_P is set then <54:53> + * and <56:55> are architectural. + */ + struct { + uint32_t _otherinfo:21; /* <52:32> */ + uint32_t _tbes:2; /* <54:53> */ + uint32_t _reserved:2; /* <56:55> */ + uint32_t _pcc:1; /* <57> */ + uint32_t _addrv:1; /* <58> */ + uint32_t _miscv:1; /* <59> */ + uint32_t _en:1; /* <60> */ + uint32_t _uc:1; /* <61> */ + uint32_t _over:1; /* <62> */ + uint32_t _val:1; /* <63> */ + } _mcis_hi_tes_p; + /* + * If IA32_MCG_CAP.MCG_TES_P is clear then <56:53> + * are model-specific. + */ + struct { + uint32_t _otherinfo:25; /* <56:32> */ + uint32_t _pcc:1; /* <57> */ + uint32_t _addrv:1; /* <58> */ + uint32_t _miscv:1; /* <59> */ + uint32_t _en:1; /* <60> */ + uint32_t _uc:1; /* <61> */ + uint32_t _over:1; /* <62> */ + uint32_t _val:1; /* <63> */ + } _mcis_hi_tes_np; + } _mcis_hi; + } _mcis_hilo; +} mca_x86_mcistatus_t; + +#define mcistatus_errcode _mcis_hilo._mcis_lo._errcode +#define mcistatus_mserrcode _mcis_hilo._mcis_lo._ms_errcode +#define mcistatus_pcc _mcis_hilo._mcis_hi._mcis_hi_tes_np._pcc +#define mcistatus_addrv _mcis_hilo._mcis_hi._mcis_hi_tes_np._addrv +#define mcistatus_miscv _mcis_hilo._mcis_hi._mcis_hi_tes_np._miscv +#define mcistatus_en _mcis_hilo._mcis_hi._mcis_hi_tes_np._en +#define mcistatus_uc _mcis_hilo._mcis_hi._mcis_hi_tes_np._uc +#define mcistatus_over _mcis_hilo._mcis_hi._mcis_hi_tes_np._over +#define mcistatus_val _mcis_hilo._mcis_hi._mcis_hi_tes_np._val + +/* + * The consumer must check for TES_P before using these. + */ +#define mcistatus_tbes _mcis_hilo._mcis_hi._mcis_hi_tes_p._tbes +#define mcistatus_reserved \ + _mcis_hilo._mcis_hi._mcis_hi_tes_p._reserved +#define mcistatus_otherinfo_tes_p \ + _mcis_hilo._mcis_hi._mcis_hi_tes_p._otherinfo +#define mcistatus_otherinfo_tes_np \ + _mcis_hilo._mcis_hi._mcis_hi_tes_np._otherinfo + +#endif /* _BIT_FIELDS_LTOH */ + +#define MSR_MC_STATUS_VAL 0x8000000000000000ULL +#define MSR_MC_STATUS_OVER 0x4000000000000000ULL +#define MSR_MC_STATUS_UC 0x2000000000000000ULL +#define MSR_MC_STATUS_EN 0x1000000000000000ULL +#define MSR_MC_STATUS_MISCV 0x0800000000000000ULL +#define MSR_MC_STATUS_ADDRV 0x0400000000000000ULL +#define MSR_MC_STATUS_PCC 0x0200000000000000ULL +#define MSR_MC_STATUS_RESERVED_MASK 0x0180000000000000ULL +#define MSR_MC_STATUS_TBES_MASK 0x0060000000000000ULL +#define MSR_MC_STATUS_TBES_SHIFT 53 +#define MSR_MC_STATUS_CEC_MASK 0x001fffc000000000ULL +#define MSR_MC_STATUS_CEC_SHIFT 38 +#define MSR_MC_STATUS_MSERR_MASK 0x00000000ffff0000ULL +#define MSR_MC_STATUS_MSERR_SHIFT 16 +#define MSR_MC_STATUS_MCAERR_MASK 0x000000000000ffffULL + +#define MSR_MC_CTL2_EN 0x0000000040000000ULL +#define MSR_MC_CTL2_THRESHOLD_MASK 0x0000000000007fffULL +#define MSR_MC_CTL2_THRESHOLD_OVERFLOW 0x0000000000004000ULL + +/* + * Macros to extract error code and model-specific error code. + */ +#define MCAX86_ERRCODE(stat) ((stat) & MSR_MC_STATUS_MCAERR_MASK) +#define MCAX86_MSERRCODE(stat) \ + (((stat) & MSR_MC_STATUS_MSERR_MASK) >> MSR_MC_STATUS_MSERR_SHIFT) + +/* + * Macro to extract threshold based error state (if MCG_CAP.TES_P) + */ +#define MCAX86_TBES_VALUE(stat) \ + (((stat) & MSR_MC_STATUS_TBES_MASK) >> MSR_MC_STATUS_TBES_SHIFT) + +/* + * Bit definitions for the architectural error code. + */ + +#define MCAX86_ERRCODE_TT_MASK 0x000c +#define MCAX86_ERRCODE_TT_SHIFT 2 +#define MCAX86_ERRCODE_TT_INSTR 0x0 +#define MCAX86_ERRCODE_TT_DATA 0x1 +#define MCAX86_ERRCODE_TT_GEN 0x2 +#define MCAX86_ERRCODE_TT(code) \ + (((code) & MCAX86_ERRCODE_TT_MASK) >> MCAX86_ERRCODE_TT_SHIFT) + +#define MCAX86_ERRCODE_LL_MASK 0x0003 +#define MCAX86_ERRCODE_LL_SHIFT 0 +#define MCAX86_ERRCODE_LL_L0 0x0 +#define MCAX86_ERRCODE_LL_L1 0x1 +#define MCAX86_ERRCODE_LL_L2 0x2 +#define MCAX86_ERRCODE_LL_LG 0x3 +#define MCAX86_ERRCODE_LL(code) \ + ((code) & MCAX86_ERRCODE_LL_MASK) + +#define MCAX86_ERRCODE_RRRR_MASK 0x00f0 +#define MCAX86_ERRCODE_RRRR_SHIFT 4 +#define MCAX86_ERRCODE_RRRR_ERR 0x0 +#define MCAX86_ERRCODE_RRRR_RD 0x1 +#define MCAX86_ERRCODE_RRRR_WR 0x2 +#define MCAX86_ERRCODE_RRRR_DRD 0x3 +#define MCAX86_ERRCODE_RRRR_DWR 0x4 +#define MCAX86_ERRCODE_RRRR_IRD 0x5 +#define MCAX86_ERRCODE_RRRR_PREFETCH 0x6 +#define MCAX86_ERRCODE_RRRR_EVICT 0x7 +#define MCAX86_ERRCODE_RRRR_SNOOP 0x8 +#define MCAX86_ERRCODE_RRRR(code) \ + (((code) & MCAX86_ERRCODE_RRRR_MASK) >> MCAX86_ERRCODE_RRRR_SHIFT) + +#define MCAX86_ERRCODE_PP_MASK 0x0600 +#define MCAX86_ERRCODE_PP_SHIFT 9 +#define MCAX86_ERRCODE_PP_SRC 0x0 +#define MCAX86_ERRCODE_PP_RES 0x1 +#define MCAX86_ERRCODE_PP_OBS 0x2 +#define MCAX86_ERRCODE_PP_GEN 0x3 +#define MCAX86_ERRCODE_PP(code) \ + (((code) & MCAX86_ERRCODE_PP_MASK) >> MCAX86_ERRCODE_PP_SHIFT) + +#define MCAX86_ERRCODE_II_MASK 0x000c +#define MCAX86_ERRCODE_II_SHIFT 2 +#define MCAX86_ERRCODE_II_MEM 0x0 +#define MCAX86_ERRCODE_II_IO 0x2 +#define MCAX86_ERRCODE_II_GEN 0x3 +#define MCAX86_ERRCODE_II(code) \ + (((code) & MCAX86_ERRCODE_II_MASK) >> MCAX86_ERRCODE_II_SHIFT) + +#define MCAX86_ERRCODE_T_MASK 0x0100 +#define MCAX86_ERRCODE_T_SHIFT 8 +#define MCAX86_ERRCODE_T_NONE 0x0 +#define MCAX86_ERRCODE_T_TIMEOUT 0x1 +#define MCAX86_ERRCODE_T(code) \ + (((code) & MCAX86_ERRCODE_T_MASK) >> MCAX86_ERRCODE_T_SHIFT) + +#define MCAX86_ERRCODE_MMM_MASK 0x0070 +#define MCAX86_ERRCODE_MMM_SHIFT 4 +#define MCAX86_ERRCODE_MMM_GEN 0x0 +#define MCAX86_ERRCODE_MMM_RD 0x1 +#define MCAX86_ERRCODE_MMM_WR 0x2 +#define MCAX86_ERRCODE_MMM_ADRCMD 0x3 +#define MCAX86_ERRCODE_MMM(code) \ + (((code) & MCAX86_ERRCODE_MMM_MASK) >> MCAX86_ERRCODE_MMM_SHIFT) + +#define MCAX86_ERRCODE_CCCC_MASK 0x000f +#define MCAX86_ERRCODE_CCCC_SHIFT 0 +#define MCAX86_ERRCODE_CCCC_CH0 0x0 +#define MCAX86_ERRCODE_CCCC_CH1 0x1 +#define MCAX86_ERRCODE_CCCC_CH2 0x2 +#define MCAX86_ERRCODE_CCCC_CH3 0x3 +#define MCAX86_ERRCODE_CCCC_CH4 0x4 +#define MCAX86_ERRCODE_CCCC_CH5 0x5 +#define MCAX86_ERRCODE_CCCC_CH6 0x6 +#define MCAX86_ERRCODE_CCCC_CH7 0x7 +#define MCAX86_ERRCODE_CCCC_CH8 0x8 +#define MCAX86_ERRCODE_CCCC_CH9 0x9 +#define MCAX86_ERRCODE_CCCC_CH10 0xa +#define MCAX86_ERRCODE_CCCC_CH11 0xb +#define MCAX86_ERRCODE_CCCC_CH12 0xc +#define MCAX86_ERRCODE_CCCC_CH13 0xd +#define MCAX86_ERRCODE_CCCC_CH14 0xe +#define MCAX86_ERRCODE_CCCC_GEN 0xf +#define MCAX86_ERRCODE_CCCC(code) \ + (((code) & MCAX86_ERRCODE_CCCC_MASK) >> MCAX86_ERRCODE_CCCC_SHIFT) + +/* + * Simple error encoding. MASKON are bits that must be set for a match + * at the same time bits indicated by MASKOFF are clear. + */ +#define MCAX86_SIMPLE_UNCLASSIFIED_MASKON 0x0001 +#define MCAX86_SIMPLE_UNCLASSIFIED_MASKOFF 0xfffe + +#define MCAX86_SIMPLE_MC_CODE_PARITY_MASKON 0x0002 +#define MCAX86_SIMPLE_MC_CODE_PARITY_MASKOFF 0xfffd + +#define MCAX86_SIMPLE_EXTERNAL_MASKON 0x0003 +#define MCAX86_SIMPLE_EXTERNAL_MASKOFF 0xfffc + +#define MCAX86_SIMPLE_FRC_MASKON 0x0004 +#define MCAX86_SIMPLE_FRC_MASKOFF 0xfffb + +#define MCAX86_SIMPLE_INTERNAL_PARITY_MASKON 0x0005 +#define MCAX86_SIMPLE_INTERNAL_PARITY_MASKOFF 0xfffa + +#define MCAX86_SIMPLE_INTERNAL_TIMER_MASKON 0x0400 +#define MCAX86_SIMPLE_INTERNAL_TIMER_MASKOFF 0xfbff + +#define MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKON 0x0400 +#define MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKOFF 0xf800 +#define MCAX86_SIMPLE_INTERNAL_UNCLASS_VALUE_MASK 0x03ff + +/* + * Macros to make an internal unclassified error code, and to test if + * a given code is internal unclassified. + */ +#define MCAX86_MKERRCODE_INTERNAL_UNCLASS(val) \ + (MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKON | \ + ((val) & MCAX86_SIMPLE_INTERNAL_UNCLASS_VALUE_MASK)) +#define MCAX86_ERRCODE_ISSIMPLE_INTERNAL_UNCLASS(code) \ + (((code) & MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKON) == \ + MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKON && \ + ((code) & MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKOFF) == 0 && \ + ((code) & MCAX86_SIMPLE_INTERNAL_UNCLASS_VALUE_MASK) != 0) + +/* + * Is the given error code a simple error encoding? + */ +#define MCAX86_ERRCODE_ISSIMPLE(code) \ + ((code) >= MCAX86_SIMPLE_UNCLASSIFIED_MASKON && \ + (code) <= MCAX86_SIMPLE_INTERNAL_PARITY_MASKON || \ + (code) == MCAX86_SIMPLE_INTERNAL_TIMER_MASKON || \ + MCAX86_ERRCODE_ISSIMPLE_INTERNAL_UNCLASS(code)) + +/* + * Compound error encoding. We always ignore the 'F' bit (which indicates + * "correction report filtering") in classifying the error type. + */ +#define MCAX86_COMPOUND_GENERIC_MEMHIER_MASKON 0x000c +#define MCAX86_COMPOUND_GENERIC_MEMHIER_MASKOFF 0xeff0 + +#define MCAX86_COMPOUND_TLB_MASKON 0x0010 +#define MCAX86_COMPOUND_TLB_MASKOFF 0xefe0 + +#define MCAX86_COMPOUND_MEMHIER_MASKON 0x0100 +#define MCAX86_COMPOUND_MEMHIER_MASKOFF 0xee00 + +#define MCAX86_COMPOUND_BUS_INTERCONNECT_MASKON 0x0800 +#define MCAX86_COMPOUND_BUS_INTERCONNECT_MASKOFF 0xe000 + +#define MCAX86_COMPOUND_MEMORY_CONTROLLER_MASKON 0x0080 +#define MCAX86_COMPOUND_MEMORY_CONTROLLER_MASKOFF 0xff00 + +/* + * Macros to make compound error codes and to test for each type. + */ +#define MCAX86_MKERRCODE_GENERIC_MEMHIER(ll) \ + (MCAX86_COMPOUND_GENERIC_MEMHIER_MASKON | \ + ((ll) & MCAX86_ERRCODE_LL_MASK)) +#define MCAX86_ERRCODE_ISGENERIC_MEMHIER(code) \ + (((code) & MCAX86_COMPOUND_GENERIC_MEMHIER_MASKON) == \ + MCAX86_COMPOUND_GENERIC_MEMHIER_MASKON && \ + ((code) & MCAX86_COMPOUND_GENERIC_MEMHIER_MASKOFF) == 0) + +#define MCAX86_MKERRCODE_TLB(tt, ll) \ + (MCAX86_COMPOUND_TLB_MASKON | \ + ((tt) << MCAX86_ERRCODE_TT_SHIFT & MCAX86_ERRCODE_TT_MASK) | \ + ((ll) & MCAX86_ERRCODE_LL_MASK)) +#define MCAX86_ERRCODE_ISTLB(code) \ + (((code) & MCAX86_COMPOUND_TLB_MASKON) == \ + MCAX86_COMPOUND_TLB_MASKON && \ + ((code) & MCAX86_COMPOUND_TLB_MASKOFF) == 0) + +#define MCAX86_MKERRCODE_MEMHIER(rrrr, tt, ll) \ + (MCAX86_COMPOUND_MEMHIER_MASKON | \ + ((rrrr) << MCAX86_ERRCODE_RRRR_SHIFT & MCAX86_ERRCODE_RRRR_MASK) | \ + ((tt) << MCAX86_ERRCODE_TT_SHIFT & MCAX86_ERRCODE_TT_MASK) | \ + ((ll) & MCAX86_ERRCODE_LL_MASK)) +#define MCAX86_ERRCODE_ISMEMHIER(code) \ + (((code) & MCAX86_COMPOUND_MEMHIER_MASKON) == \ + MCAX86_COMPOUND_MEMHIER_MASKON && \ + ((code) & MCAX86_COMPOUND_MEMHIER_MASKOFF) == 0) + +#define MCAX86_MKERRCODE_BUS_INTERCONNECT(pp, t, rrrr, ii, ll) \ + (MCAX86_COMPOUND_BUS_INTERCONNECT_MASKON | \ + ((pp) << MCAX86_ERRCODE_PP_SHIFT & MCAX86_ERRCODE_PP_MASK) | \ + ((t) << MCAX86_ERRCODE_T_SHIFT & MCAX86_ERRCODE_T_MASK) | \ + ((rrrr) << MCAX86_ERRCODE_RRRR_SHIFT & MCAX86_ERRCODE_RRRR_MASK) | \ + ((ii) << MCAX86_ERRCODE_II_SHIFT & MCAX86_ERRCODE_II_MASK) | \ + ((ll) & MCAX86_ERRCODE_LL_MASK)) +#define MCAX86_ERRCODE_ISBUS_INTERCONNECT(code) \ + (((code) & MCAX86_COMPOUND_BUS_INTERCONNECT_MASKON) == \ + MCAX86_COMPOUND_BUS_INTERCONNECT_MASKON && \ + ((code) & MCAX86_COMPOUND_BUS_INTERCONNECT_MASKOFF) == 0) + +#define MCAX86_MKERRCODE_MEMORY_CONTROLLER (mmm, cccc) \ + (MCAX86_COMPOUNT_MEMORY_CONTROLLER_MASKON | \ + ((mmm) << MCAX86_ERRCODE_MMM_SHIFT & MCAX86_ERRCODE_MMM_MASK) | \ + ((cccc) << MCAX86_ERRCODE_CCCC_SHIFT & MCAX86_ERRCODE_CCCC_MASK)) +#define MCAX86_ERRCODE_ISMEMORY_CONTROLLER(code) \ + (((code) & MCAX86_COMPOUND_MEMORY_CONTROLLER_MASKON) == \ + MCAX86_COMPOUND_MEMORY_CONTROLLER_MASKON && \ + ((code) & MCAX86_COMPOUND_MEMORY_CONTROLLER_MASKOFF) == 0) + +#define MCAX86_ERRCODE_ISCOMPOUND(code) \ + (MCAX86_ERRCODE_ISGENERIC_MEMHIER(code) || \ + MCAX86_ERRCODE_ISTLB(code) || \ + MCAX86_ERRCODE_ISMEMHIER(code) || \ + MCAX86_ERRCODE_ISBUS_INTERCONNECT(code) || \ + MCAX86_ERRCODE_ISMEMORY_CONTROLLER(code)) + +#define MCAX86_ERRCODE_UNKNOWN(code) \ + (!MCAX86_ERRCODE_ISSIMPLE(code) && !MCAX86_ERRCODE_ISCOMPOUND(code)) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MCA_X86_H */ diff --git a/illumos-x86_64/usr/include/sys/mcontext.h b/illumos-x86_64/usr/include/sys/mcontext.h new file mode 100644 index 00000000..ae861133 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mcontext.h @@ -0,0 +1,191 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Essential struct definitions for mcontext_t needed by ucontext.h + * These were formerly in regset.h, which now includes this file. + */ + +#ifndef _SYS_MCONTEXT_H +#define _SYS_MCONTEXT_H + +#include + +#if !defined(_ASM) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A gregset_t is defined as an array type for compatibility with the reference + * source. This is important due to differences in the way the C language + * treats arrays and structures as parameters. + */ +#if defined(__amd64) +#define _NGREG 28 +#else +#define _NGREG 19 +#endif + +#if !defined(_ASM) + +#if defined(_LP64) +typedef long greg_t; +#else +typedef int greg_t; +#endif + +#if defined(_SYSCALL32) + +typedef int32_t greg32_t; +typedef int64_t greg64_t; + +#endif /* _SYSCALL32 */ + +typedef greg_t gregset_t[_NGREG]; + +#if defined(_SYSCALL32) + +#define _NGREG32 19 +#define _NGREG64 28 + +typedef greg32_t gregset32_t[_NGREG32]; +typedef greg64_t gregset64_t[_NGREG64]; + +#endif /* _SYSCALL32 */ + +/* + * Floating point definitions. + */ + +#if defined(__amd64) + +typedef struct _fpu { + union { + struct _fpchip_state { + uint16_t cw; + uint16_t sw; + uint8_t fctw; + uint8_t __fx_rsvd; + uint16_t fop; + uint64_t rip; + uint64_t rdp; + uint32_t mxcsr; + uint32_t mxcsr_mask; + union { + uint16_t fpr_16[5]; + upad128_t __fpr_pad; + } st[8]; + upad128_t xmm[16]; + upad128_t __fx_ign2[6]; + uint32_t status; /* sw at exception */ + uint32_t xstatus; /* mxcsr at exception */ + } fpchip_state; + uint32_t f_fpregs[130]; + } fp_reg_set; +} fpregset_t; + +#else /* __i386 */ + +/* + * This definition of the floating point structure is binary + * compatible with the Intel386 psABI definition, and source + * compatible with that specification for x87-style floating point. + * It also allows SSE/SSE2 state to be accessed on machines that + * possess such hardware capabilities. + */ +typedef struct _fpu { + union { + struct _fpchip_state { + uint32_t state[27]; /* 287/387 saved state */ + uint32_t status; /* saved at exception */ + uint32_t mxcsr; /* SSE control and status */ + uint32_t xstatus; /* SSE mxcsr at exception */ + uint32_t __pad[2]; /* align to 128-bits */ + upad128_t xmm[8]; /* %xmm0-%xmm7 */ + } fpchip_state; + struct _fp_emul_space { /* for emulator(s) */ + uint8_t fp_emul[246]; + uint8_t fp_epad[2]; + } fp_emul_space; + uint32_t f_fpregs[95]; /* union of the above */ + } fp_reg_set; +} fpregset_t; + +#endif /* __i386 */ + +#if defined(_SYSCALL32) + +/* Kernel view of user i386 fpu structure */ + +typedef struct fpu32 { + union { + struct fpchip32_state { + uint32_t state[27]; /* 287/387 saved state */ + uint32_t status; /* saved at exception */ + uint32_t mxcsr; /* SSE control and status */ + uint32_t xstatus; /* SSE mxcsr at exception */ + uint32_t __pad[2]; /* align to 128-bits */ + uint32_t xmm[8][4]; /* %xmm0-%xmm7 */ + } fpchip_state; + uint32_t f_fpregs[95]; /* union of the above */ + } fp_reg_set; +} fpregset32_t; + +#endif /* _SYSCALL32 */ + +/* + * Structure mcontext defines the complete hardware machine state. + * (This structure is specified in the i386 ABI suppl.) + */ +typedef struct { + gregset_t gregs; /* general register set */ + fpregset_t fpregs; /* floating point register set */ +} mcontext_t; + +#if defined(_SYSCALL32) + +typedef struct { + gregset32_t gregs; /* general register set */ + fpregset32_t fpregs; /* floating point register set */ +} mcontext32_t; + +#endif /* _SYSCALL32 */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MCONTEXT_H */ diff --git a/illumos-x86_64/usr/include/sys/md4.h b/illumos-x86_64/usr/include/sys/md4.h new file mode 100644 index 00000000..1694157b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/md4.h @@ -0,0 +1,58 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef __MD4_H +#define __MD4_H + +/* + * MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm + */ + +/* + * Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD4 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD4 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define MD4_DIGEST_LENGTH 16 + +/* MD4 context. */ +typedef struct { + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD4_CTX; + +void MD4Init(MD4_CTX *); +void MD4Update(MD4_CTX *, const void *_RESTRICT_KYWD, size_t); +void MD4Final(void *, MD4_CTX *); + +#ifdef __cplusplus +} +#endif + +#endif /* __MD4_H */ diff --git a/illumos-x86_64/usr/include/sys/md5.h b/illumos-x86_64/usr/include/sys/md5.h new file mode 100644 index 00000000..1781654c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/md5.h @@ -0,0 +1,70 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Cleaned up version of the md5.h header file from RFC 1321. + */ + +/* + * MD5.H - header file for MD5C.C + */ + +/* + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD5 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD5 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#ifndef _SYS_MD5_H +#define _SYS_MD5_H + +#include /* for uint_* */ + +/* + * Definitions for MD5 hashing functions, conformant to RFC 1321 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MD5_DIGEST_LENGTH 16 + +/* MD5 context. */ +typedef struct { + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + union { + uint8_t buf8[64]; /* undigested input */ + uint32_t buf32[16]; /* realigned input */ + } buf_un; +} MD5_CTX; + +void MD5Init(MD5_CTX *); +void MD5Update(MD5_CTX *, const void *, unsigned int); +void MD5Final(void *, MD5_CTX *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MD5_H */ diff --git a/illumos-x86_64/usr/include/sys/md5_consts.h b/illumos-x86_64/usr/include/sys/md5_consts.h new file mode 100644 index 00000000..5c41a314 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/md5_consts.h @@ -0,0 +1,131 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) by 1998 Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_MD5_CONSTS_H +#define _SYS_MD5_CONSTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* constants, as provided in RFC 1321 */ + +#define MD5_CONST_0 (uint32_t)0xd76aa478 +#define MD5_CONST_1 (uint32_t)0xe8c7b756 +#define MD5_CONST_2 (uint32_t)0x242070db +#define MD5_CONST_3 (uint32_t)0xc1bdceee +#define MD5_CONST_4 (uint32_t)0xf57c0faf +#define MD5_CONST_5 (uint32_t)0x4787c62a +#define MD5_CONST_6 (uint32_t)0xa8304613 +#define MD5_CONST_7 (uint32_t)0xfd469501 +#define MD5_CONST_8 (uint32_t)0x698098d8 +#define MD5_CONST_9 (uint32_t)0x8b44f7af +#define MD5_CONST_10 (uint32_t)0xffff5bb1 +#define MD5_CONST_11 (uint32_t)0x895cd7be +#define MD5_CONST_12 (uint32_t)0x6b901122 +#define MD5_CONST_13 (uint32_t)0xfd987193 +#define MD5_CONST_14 (uint32_t)0xa679438e +#define MD5_CONST_15 (uint32_t)0x49b40821 +#define MD5_CONST_16 (uint32_t)0xf61e2562 +#define MD5_CONST_17 (uint32_t)0xc040b340 +#define MD5_CONST_18 (uint32_t)0x265e5a51 +#define MD5_CONST_19 (uint32_t)0xe9b6c7aa +#define MD5_CONST_20 (uint32_t)0xd62f105d +#define MD5_CONST_21 (uint32_t)0x2441453 +#define MD5_CONST_22 (uint32_t)0xd8a1e681 +#define MD5_CONST_23 (uint32_t)0xe7d3fbc8 +#define MD5_CONST_24 (uint32_t)0x21e1cde6 +#define MD5_CONST_25 (uint32_t)0xc33707d6 +#define MD5_CONST_26 (uint32_t)0xf4d50d87 +#define MD5_CONST_27 (uint32_t)0x455a14ed +#define MD5_CONST_28 (uint32_t)0xa9e3e905 +#define MD5_CONST_29 (uint32_t)0xfcefa3f8 +#define MD5_CONST_30 (uint32_t)0x676f02d9 +#define MD5_CONST_31 (uint32_t)0x8d2a4c8a +#define MD5_CONST_32 (uint32_t)0xfffa3942 +#define MD5_CONST_33 (uint32_t)0x8771f681 +#define MD5_CONST_34 (uint32_t)0x6d9d6122 +#define MD5_CONST_35 (uint32_t)0xfde5380c +#define MD5_CONST_36 (uint32_t)0xa4beea44 +#define MD5_CONST_37 (uint32_t)0x4bdecfa9 +#define MD5_CONST_38 (uint32_t)0xf6bb4b60 +#define MD5_CONST_39 (uint32_t)0xbebfbc70 +#define MD5_CONST_40 (uint32_t)0x289b7ec6 +#define MD5_CONST_41 (uint32_t)0xeaa127fa +#define MD5_CONST_42 (uint32_t)0xd4ef3085 +#define MD5_CONST_43 (uint32_t)0x4881d05 +#define MD5_CONST_44 (uint32_t)0xd9d4d039 +#define MD5_CONST_45 (uint32_t)0xe6db99e5 +#define MD5_CONST_46 (uint32_t)0x1fa27cf8 +#define MD5_CONST_47 (uint32_t)0xc4ac5665 +#define MD5_CONST_48 (uint32_t)0xf4292244 +#define MD5_CONST_49 (uint32_t)0x432aff97 +#define MD5_CONST_50 (uint32_t)0xab9423a7 +#define MD5_CONST_51 (uint32_t)0xfc93a039 +#define MD5_CONST_52 (uint32_t)0x655b59c3 +#define MD5_CONST_53 (uint32_t)0x8f0ccc92 +#define MD5_CONST_54 (uint32_t)0xffeff47d +#define MD5_CONST_55 (uint32_t)0x85845dd1 +#define MD5_CONST_56 (uint32_t)0x6fa87e4f +#define MD5_CONST_57 (uint32_t)0xfe2ce6e0 +#define MD5_CONST_58 (uint32_t)0xa3014314 +#define MD5_CONST_59 (uint32_t)0x4e0811a1 +#define MD5_CONST_60 (uint32_t)0xf7537e82 +#define MD5_CONST_61 (uint32_t)0xbd3af235 +#define MD5_CONST_62 (uint32_t)0x2ad7d2bb +#define MD5_CONST_63 (uint32_t)0xeb86d391 + +/* initialization constants, as given in RFC 1321. used in MD5Init */ + +#define MD5_INIT_CONST_1 (uint32_t)0x67452301 +#define MD5_INIT_CONST_2 (uint32_t)0xefcdab89 +#define MD5_INIT_CONST_3 (uint32_t)0x98badcfe +#define MD5_INIT_CONST_4 (uint32_t)0x10325476 + +/* shift constants, as given in RFC 1321. used in MD5Transform */ + +#define MD5_SHIFT_11 7 +#define MD5_SHIFT_12 12 +#define MD5_SHIFT_13 17 +#define MD5_SHIFT_14 22 +#define MD5_SHIFT_21 5 +#define MD5_SHIFT_22 9 +#define MD5_SHIFT_23 14 +#define MD5_SHIFT_24 20 +#define MD5_SHIFT_31 4 +#define MD5_SHIFT_32 11 +#define MD5_SHIFT_33 16 +#define MD5_SHIFT_34 23 +#define MD5_SHIFT_41 6 +#define MD5_SHIFT_42 10 +#define MD5_SHIFT_43 15 +#define MD5_SHIFT_44 21 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MD5_CONSTS_H */ diff --git a/illumos-x86_64/usr/include/sys/mdb_modapi.h b/illumos-x86_64/usr/include/sys/mdb_modapi.h new file mode 100644 index 00000000..321b287b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mdb_modapi.h @@ -0,0 +1,463 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2019 Joyent, Inc. + * Copyright 2023 RackTop Systems, Inc. + * Copyright 2023 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _MDB_MODAPI_H +#define _MDB_MODAPI_H + +/* + * MDB Module API + * + * The debugger provides a set of interfaces for use in writing loadable + * debugger modules. Modules that call functions not listed in this header + * file may not be compatible with future versions of the debugger. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Make sure that TRUE, FALSE, MIN, and MAX have the usual definitions + * so module writers can depend on these macros and defines. + * Make sure NULL is available to module writers by including . + */ + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef MIN +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#endif + +#ifndef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#endif + +#define MDB_API_VERSION 5 /* Current API version number */ + +/* + * Debugger command function flags: + */ +#define DCMD_ADDRSPEC 0x01 /* Dcmd invoked with explicit address */ +#define DCMD_LOOP 0x02 /* Dcmd invoked in loop with ,cnt syntax */ +#define DCMD_LOOPFIRST 0x04 /* Dcmd invoked as first iteration of LOOP */ +#define DCMD_PIPE 0x08 /* Dcmd invoked with input from pipe */ +#define DCMD_PIPE_OUT 0x10 /* Dcmd invoked with output set to pipe */ + +#define DCMD_HDRSPEC(fl) (((fl) & DCMD_LOOPFIRST) || !((fl) & DCMD_LOOP)) + +/* + * Debugger tab command function flags + */ +#define DCMD_TAB_SPACE 0x01 /* Tab cb invoked with trailing space */ + +/* + * Debugger command function return values: + */ +#define DCMD_OK 0 /* Dcmd completed successfully */ +#define DCMD_ERR 1 /* Dcmd failed due to an error */ +#define DCMD_USAGE 2 /* Dcmd usage error; abort and print usage */ +#define DCMD_NEXT 3 /* Invoke next dcmd in precedence list */ +#define DCMD_ABORT 4 /* Dcmd failed; abort current loop or pipe */ + +#define OFFSETOF(s, m) (size_t)(&(((s *)0)->m)) + +extern int mdb_prop_postmortem; /* Are we looking at a static dump? */ +extern int mdb_prop_kernel; /* Are we looking at a kernel? */ + +typedef enum { + MDB_TYPE_STRING, /* a_un.a_str is valid */ + MDB_TYPE_IMMEDIATE, /* a_un.a_val is valid */ + MDB_TYPE_CHAR /* a_un.a_char is valid */ +} mdb_type_t; + +typedef struct mdb_arg { + mdb_type_t a_type; + union { + const char *a_str; + uintmax_t a_val; + char a_char; + } a_un; +} mdb_arg_t; + +typedef struct mdb_tab_cookie mdb_tab_cookie_t; +typedef int mdb_dcmd_f(uintptr_t, uint_t, int, const mdb_arg_t *); +typedef int mdb_dcmd_tab_f(mdb_tab_cookie_t *, uint_t, int, + const mdb_arg_t *); + +typedef struct mdb_dcmd { + const char *dc_name; /* Command name */ + const char *dc_usage; /* Usage message (optional) */ + const char *dc_descr; /* Description */ + mdb_dcmd_f *dc_funcp; /* Command function */ + void (*dc_help)(void); /* Command help function (or NULL) */ + mdb_dcmd_tab_f *dc_tabp; /* Tab completion function */ +} mdb_dcmd_t; + +#define WALK_ERR -1 /* Walk fatal error (terminate walk) */ +#define WALK_NEXT 0 /* Walk should continue to next step */ +#define WALK_DONE 1 /* Walk is complete (no errors) */ + +typedef int (*mdb_walk_cb_t)(uintptr_t, const void *, void *); + +typedef struct mdb_walk_state { + mdb_walk_cb_t walk_callback; /* Callback to issue */ + void *walk_cbdata; /* Callback private data */ + uintptr_t walk_addr; /* Current address */ + void *walk_data; /* Walk private data */ + void *walk_arg; /* Walk private argument */ + const void *walk_layer; /* Data from underlying layer */ +} mdb_walk_state_t; + +typedef struct mdb_walker { + const char *walk_name; /* Walk type name */ + const char *walk_descr; /* Walk description */ + int (*walk_init)(mdb_walk_state_t *); /* Walk constructor */ + int (*walk_step)(mdb_walk_state_t *); /* Walk iterator */ + void (*walk_fini)(mdb_walk_state_t *); /* Walk destructor */ + void *walk_init_arg; /* Walk constructor argument */ +} mdb_walker_t; + +typedef struct mdb_modinfo { + ushort_t mi_dvers; /* Debugger version number */ + const mdb_dcmd_t *mi_dcmds; /* NULL-terminated list of dcmds */ + const mdb_walker_t *mi_walkers; /* NULL-terminated list of walks */ +} mdb_modinfo_t; + +typedef struct mdb_bitmask { + const char *bm_name; /* String name to print */ + u_longlong_t bm_mask; /* Mask for bits */ + u_longlong_t bm_bits; /* Result required for value & mask */ +} mdb_bitmask_t; + +typedef struct mdb_pipe { + uintptr_t *pipe_data; /* Array of pipe values */ + size_t pipe_len; /* Array length */ +} mdb_pipe_t; + +typedef struct mdb_object { + const char *obj_name; /* name of object */ + const char *obj_fullname; /* full name of object */ + uintptr_t obj_base; /* base address of object */ + uintptr_t obj_size; /* in memory size of object in bytes */ +} mdb_object_t; + +typedef struct mdb_symbol { + const char *sym_name; /* name of symbol */ + const char *sym_object; /* name of containing object */ + const GElf_Sym *sym_sym; /* ELF symbol information */ + uint_t sym_table; /* symbol table id */ + uint_t sym_id; /* symbol identifier */ +} mdb_symbol_t; + +extern int mdb_pwalk(const char *, mdb_walk_cb_t, void *, uintptr_t); +extern int mdb_walk(const char *, mdb_walk_cb_t, void *); + +extern int mdb_pwalk_dcmd(const char *, const char *, + int, const mdb_arg_t *, uintptr_t); +extern int mdb_fpwalk_dcmd(const char *, const char *, + int, const mdb_arg_t *, uintptr_t, uint_t); + +extern int mdb_walk_dcmd(const char *, const char *, int, const mdb_arg_t *); + +extern int mdb_layered_walk(const char *, mdb_walk_state_t *); + +extern int mdb_call_dcmd(const char *, uintptr_t, + uint_t, int, const mdb_arg_t *); + +extern int mdb_add_walker(const mdb_walker_t *); +extern int mdb_remove_walker(const char *); + +extern ssize_t mdb_vread(void *, size_t, uintptr_t); +extern ssize_t mdb_vwrite(const void *, size_t, uintptr_t); + +extern ssize_t mdb_aread(void *, size_t, uintptr_t, void *); +extern ssize_t mdb_awrite(const void *, size_t, uintptr_t, void *); + +extern ssize_t mdb_fread(void *, size_t, uintptr_t); +extern ssize_t mdb_fwrite(const void *, size_t, uintptr_t); + +extern ssize_t mdb_pread(void *, size_t, uint64_t); +extern ssize_t mdb_pwrite(const void *, size_t, uint64_t); + +extern ssize_t mdb_readstr(char *, size_t, uintptr_t); +extern ssize_t mdb_writestr(const char *, uintptr_t); + +extern ssize_t mdb_readsym(void *, size_t, const char *); +extern ssize_t mdb_writesym(const void *, size_t, const char *); + +extern ssize_t mdb_readvar(void *, const char *); +extern ssize_t mdb_writevar(const void *, const char *); + +#define MDB_SYM_NAMLEN 1024 /* Recommended max name len */ + +#define MDB_SYM_FUZZY 0 /* Match closest address */ +#define MDB_SYM_EXACT 1 /* Match exact address only */ + +#define MDB_OBJ_EXEC ((const char *)0L) /* Primary executable file */ +#define MDB_OBJ_RTLD ((const char *)1L) /* Run-time link-editor */ +#define MDB_OBJ_EVERY ((const char *)-1L) /* All known symbols */ + +extern int mdb_lookup_by_name(const char *, GElf_Sym *); +extern int mdb_lookup_by_obj(const char *, const char *, GElf_Sym *); +extern int mdb_lookup_by_addr(uintptr_t, uint_t, char *, size_t, GElf_Sym *); + +typedef uintptr_t mdb_tid_t; +typedef uint64_t mdb_reg_t; + +extern int mdb_getareg(mdb_tid_t, const char *, mdb_reg_t *); +extern int mdb_thread_name(mdb_tid_t, char *, size_t); + +#define MDB_OPT_SETBITS 1 /* Set specified flag bits */ +#define MDB_OPT_CLRBITS 2 /* Clear specified flag bits */ +#define MDB_OPT_STR 3 /* const char * argument */ +#define MDB_OPT_UINTPTR 4 /* uintptr_t argument */ +#define MDB_OPT_UINT64 5 /* uint64_t argument */ +#define MDB_OPT_UINTPTR_SET 6 /* boolean_t+uintptr_t args */ + +extern int mdb_getopts(int, const mdb_arg_t *, ...) __sentinel(0); + +extern u_longlong_t mdb_strtoull(const char *); +extern u_longlong_t mdb_argtoull(const mdb_arg_t *); + +#define UM_NOSLEEP 0x0 /* Do not call failure handler; may fail */ +#define UM_SLEEP 0x1 /* Can block for memory; will always succeed */ +#define UM_GC 0x2 /* Garbage-collect this block automatically */ + +extern void *mdb_alloc(size_t, uint_t); +extern void *mdb_zalloc(size_t, uint_t); +extern void mdb_free(void *, size_t); + +#define MDB_NICENUM_BUFLEN 6 + +extern int mdb_snprintfrac(char *, int, uint64_t, uint64_t, int); +extern void mdb_nicenum(uint64_t, char *); +extern void mdb_nicetime(int64_t, char *, size_t); + +extern size_t mdb_snprintf(char *, size_t, const char *, ...); +extern void mdb_printf(const char *, ...); +extern void mdb_warn(const char *, ...); +extern void mdb_flush(void); + +extern int mdb_ffs(uintmax_t); + +extern void mdb_nhconvert(void *, const void *, size_t); + +#define MDB_DUMP_RELATIVE 0x0001 /* Start numbering at 0 */ +#define MDB_DUMP_ALIGN 0x0002 /* Enforce paragraph alignment */ +#define MDB_DUMP_PEDANT 0x0004 /* Full-width addresses */ +#define MDB_DUMP_ASCII 0x0008 /* Display ASCII values */ +#define MDB_DUMP_HEADER 0x0010 /* Display a header */ +#define MDB_DUMP_TRIM 0x0020 /* Trim at boundaries */ +#define MDB_DUMP_SQUISH 0x0040 /* Eliminate redundant lines */ +#define MDB_DUMP_NEWDOT 0x0080 /* Update dot when done */ +#define MDB_DUMP_ENDIAN 0x0100 /* Adjust for endianness */ +#define MDB_DUMP_WIDTH(x) ((((x) - 1) & 0xf) << 16) /* paragraphs/line */ +#define MDB_DUMP_GROUP(x) ((((x) - 1) & 0xff) << 20) /* bytes/group */ + +typedef ssize_t (*mdb_dumpptr_cb_t)(void *, size_t, uintptr_t, void *); +typedef ssize_t (*mdb_dump64_cb_t)(void *, size_t, uint64_t, void *); + +extern int mdb_dumpptr(uintptr_t, size_t, uint_t, mdb_dumpptr_cb_t, void *); +extern int mdb_dump64(uint64_t, uint64_t, uint_t, mdb_dump64_cb_t, void *); + +extern const char *mdb_one_bit(int, int, int); +extern const char *mdb_inval_bits(int, int, int); + +extern ulong_t mdb_inc_indent(ulong_t); +extern ulong_t mdb_dec_indent(ulong_t); + +extern int mdb_eval(const char *); +extern void mdb_set_dot(uintmax_t); +extern uintmax_t mdb_get_dot(void); + +extern void mdb_get_pipe(mdb_pipe_t *); +extern void mdb_set_pipe(const mdb_pipe_t *); + +extern ssize_t mdb_get_xdata(const char *, void *, size_t); + +typedef int (*mdb_object_cb_t)(mdb_object_t *, void *); +extern int mdb_object_iter(mdb_object_cb_t, void *); + +#define MDB_SYMTAB 1 /* Normal symbol table (.symtab) */ +#define MDB_DYNSYM 2 /* Dynamic symbol table (.dynsym) */ + +#define MDB_BIND_LOCAL 0x0001 /* Local (static-scope) symbols */ +#define MDB_BIND_GLOBAL 0x0002 /* Global symbols */ +#define MDB_BIND_WEAK 0x0004 /* Weak binding symbols */ +#define MDB_BIND_ANY 0x0007 /* Any of the above */ + +#define MDB_TYPE_NOTYPE 0x0100 /* Symbol has no type */ +#define MDB_TYPE_OBJECT 0x0200 /* Symbol refers to data */ +#define MDB_TYPE_FUNC 0x0400 /* Symbol refers to text */ +#define MDB_TYPE_SECT 0x0800 /* Symbol refers to a section */ +#define MDB_TYPE_FILE 0x1000 /* Symbol refers to a source file */ +#define MDB_TYPE_COMMON 0x2000 /* Symbol refers to a common block */ +#define MDB_TYPE_TLS 0x4000 /* Symbol refers to TLS */ + +#define MDB_TYPE_ANY 0x7f00 /* Any of the above */ + +typedef int (*mdb_symbol_cb_t)(mdb_symbol_t *, void *); +extern int mdb_symbol_iter(const char *, uint_t, uint_t, mdb_symbol_cb_t, + void *); + +#define MDB_STATE_IDLE 0 /* Target is idle (not running yet) */ +#define MDB_STATE_RUNNING 1 /* Target is currently executing */ +#define MDB_STATE_STOPPED 2 /* Target is stopped */ +#define MDB_STATE_UNDEAD 3 /* Target is undead (zombie) */ +#define MDB_STATE_DEAD 4 /* Target is dead (core dump) */ +#define MDB_STATE_LOST 5 /* Target lost by debugger */ + +extern int mdb_get_state(void); + +#define MDB_CALLBACK_STCHG 1 +#define MDB_CALLBACK_PROMPT 2 + +typedef void (*mdb_callback_f)(void *); + +extern void *mdb_callback_add(int, mdb_callback_f, void *); +extern void mdb_callback_remove(void *); + +#define MDB_TABC_ALL_TYPES 0x1 /* Include array types in type output */ +#define MDB_TABC_MEMBERS 0x2 /* Tab comp. types with members */ +#define MDB_TABC_NOPOINT 0x4 /* Tab comp. everything but pointers */ +#define MDB_TABC_NOARRAY 0x8 /* Don't include array data in output */ + +/* + * Module's interaction path + */ +extern void mdb_tab_insert(mdb_tab_cookie_t *, const char *); +extern void mdb_tab_setmbase(mdb_tab_cookie_t *, const char *); + +/* + * Tab completion utility functions for modules. + */ +extern int mdb_tab_complete_type(mdb_tab_cookie_t *, const char *, uint_t); +extern int mdb_tab_complete_member(mdb_tab_cookie_t *, const char *, + const char *); +extern int mdb_tab_typename(int *, const mdb_arg_t **, char *buf, size_t len); + +/* + * Tab completion functions for common signatures. + */ +extern int mdb_tab_complete_mt(mdb_tab_cookie_t *, uint_t, int, + const mdb_arg_t *); + +extern size_t strlcat(char *, const char *, size_t); +extern char *strcat(char *, const char *); +extern char *strcpy(char *, const char *); +extern char *strncpy(char *, const char *, size_t); + +/* Need to be consistent with C++ definitions */ +#if __cplusplus >= 199711L +extern const char *strchr(const char *, int); +#ifndef _STRCHR_INLINE +#define _STRCHR_INLINE +extern "C++" { + inline char *strchr(char *__s, int __c) { + return (char *)strchr((const char *)__s, __c); + } +} +#endif /* _STRCHR_INLINE */ +extern const char *strrchr(const char *, int); +#ifndef _STRRCHR_INLINE +#define _STRRCHR_INLINE +extern "C++" { + inline char *strrchr(char *__s, int __c) { + return (char *)strrchr((const char *)__s, __c); + } +} +#endif /* _STRRCHR_INLINE */ +extern const char *strstr(const char *, const char *); +#ifndef _STRSTR_INLINE +#define _STRSTR_INLINE +extern "C++" { + inline char *strstr(char *__s1, const char *__s2) { + return (char *)strstr((const char *)__s1, __s2); + } +} +#endif /* _STRSTR_INLINE */ +#else +extern char *strchr(const char *, int); +extern char *strrchr(const char *, int); +extern char *strstr(const char *, const char *); +#endif /* __cplusplus >= 199711L */ + +extern int strcmp(const char *, const char *); +extern int strncmp(const char *, const char *, size_t); +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, size_t); + +extern size_t strlen(const char *); + +extern int bcmp(const void *, const void *, size_t); +extern void bcopy(const void *, void *, size_t); +extern void bzero(void *, size_t); + +extern void *memcpy(void *, const void *, size_t); +extern void *memmove(void *, const void *, size_t); +extern int memcmp(const void *, const void *, size_t); +/* Need to be consistent with C++ definitions */ +#if __cplusplus >= 199711L +extern const void *memchr(const void *, int, size_t); +#ifndef _MEMCHR_INLINE +#define _MEMCHR_INLINE +extern "C++" { + inline void *memchr(void * __s, int __c, size_t __n) { + return (void *)memchr((const void *)__s, __c, __n); + } +} +#endif /* _MEMCHR_INLINE */ +#else +extern void *memchr(const void *, int, size_t); +#endif /* __cplusplus >= 199711L */ +extern void *memset(void *, int, size_t); +extern void *memccpy(void *, const void *, int, size_t); + +extern void *bsearch(const void *, const void *, size_t, size_t, + int (*)(const void *, const void *)); + +extern void qsort(void *, size_t, size_t, + int (*)(const void *, const void *)); + +#ifdef __cplusplus +} +#endif + +#endif /* _MDB_MODAPI_H */ diff --git a/illumos-x86_64/usr/include/sys/mdi_impldefs.h b/illumos-x86_64/usr/include/sys/mdi_impldefs.h new file mode 100644 index 00000000..563c62af --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mdi_impldefs.h @@ -0,0 +1,1270 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MDI_IMPLDEFS_H +#define _SYS_MDI_IMPLDEFS_H + + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Multipath Driver Interfaces + * + * The multipathing framework is provided in two modules. The 'mpxio' misc. + * module provides the core multipath framework and the 'scsi_vhci' nexus + * driver provides the SCSI-III command set driver functionality for + * managing Fibre-Channel storage devices. + * + * As in any multipathing solution there are three major problems to solve: + * + * 1) Identification and enumeration of multipath client devices. + * 2) Optimal path selection when routing I/O requests. + * 3) Observability interfaces to snapshot the multipath configuration, + * and infrastructure to provide performance and error statistics. + * + * The mpxio framework consists of several major components: + * + * 1) The MDI is the Multiplexed Device Interface; this is the core glue which + * holds the following components together. + * 2) vHCI (Virtual Host Controller Interconnect) drivers provide multipathing + * services for a given bus technology (example: 'scsi_vhci' provides + * multipathing support for SCSI-III fibre-channel devices). + * 3) pHCI (Physical Host Controller Interconnect) drivers provide transport + * services for a given host controller (example: 'fcp' provides transport + * for fibre-channel devices). + * 4) Client Devices are standard Solaris target (or leaf) drivers + * (example: 'ssd' is the standard disk driver for fibre-channel arrays). + * 5) Multipath information nodes ('pathinfo' nodes) connect client device + * nodes and pHCI device nodes in the device tree. + * + * With the scsi_vhci, a QLC card, and mpxio enabled, the device tree might + * look like this: + * + * /\ + * / ............ + * :/ \ + * +-----------+ +-----------+ + * | scsi_vhci | | pci@1f,0 | + * +-----------+ +-----------+ + * / \ \ + * : / \ : \ :parent(pHCI) + * +----------+ +-----------+ +-------------+ + * | ssd 1 | | ssd 2 | | qlc@0,0 | + * +----------+ +-----------+ +-------------+ + * | | / \ + * | | : / \ : + * | | +-------------+ +-------------+ + * | | | pHCI 1 (fp) | | pHCI 2 (fp) | + * | | +-------------+ +-------------+ + * | | / | / | + * | | +------+ | +------+ | + * | | | ssd 3| | | ssd | | + * | | |!mpxio| | | (OBP)| | + * | | +------+ | +------+ | + * | | | | + * | | : | | + * | | +-------+ +--------+ + * | +-------------->| path |-------->| path | + * | | info | | info | + * | | node 1| | node 3 | + * | +-------+ +--------+ + * | | | + * | | +~~~~~~~~+ + * | +-------+ :+--------+ + * +--------------------------->| path |-------->| path | + * | info | :| info | + * | node 2| +| node 4 | + * +-------+ +--------+ + * + * The multipath information nodes (mdi_pathinfo nodes) establish the + * relationship between the pseudo client driver instance nodes (children + * of the vHCI) and the physical host controller interconnect (pHCI + * drivers) forming a matrix structure. + * + * The mpxio module implements locking at multiple granularity levels to + * support the needs of various consumers. The multipath matrix can be + * column locked, or row locked depending on the consumer. The intention + * is to balance simplicity and performance. + * + * Locking: + * + * The devinfo locking still applies: + * + * 1) An ndi_devi_enter of a parent protects linkage/state of children. + * 2) state >= DS_INITIALIZED adds devi_ref of parent + * 3) devi_ref at state >= DS_ATTACHED prevents detach(9E). + * + * The ordering of 1) is (vHCI, pHCI). For a DEBUG kernel this ordering + * is asserted by the ndi_devi_enter() implementation. There is also an + * ndi_devi_enter(Client), which is atypical since the client is a leaf. + * This is done to synchronize pathinfo nodes during devinfo snapshot (see + * di_register_pip) by pretending that the pathinfo nodes are children + * of the client. + * + * In addition to devinfo locking the current implementation utilizes + * the following locks: + * + * mdi_mutex: protects the global list of vHCIs. + * + * vh_phci_mutex: per-vHCI (mutex) lock: protects list of pHCIs registered + * with vHCI. + * + * vh_client_mutex: per-vHCI (mutex) lock: protects list/hash of Clients + * associated with vHCI. + * + * ph_mutex: per-pHCI (mutex) lock: protects the column (pHCI-mdi_pathinfo + * node list) and per-pHCI structure fields. mdi_pathinfo node creation, + * deletion and child mdi_pathinfo node state changes are serialized on per + * pHCI basis (Protection against DR). + * + * ct_mutex: per-client (mutex) lock: protects the row (client-mdi_pathinfo + * node list) and per-client structure fields. The client-mdi_pathinfo node + * list is typically walked to select an optimal path when routing I/O + * requests. + * + * pi_mutex: per-mdi_pathinfo (mutex) lock: protects the mdi_pathinfo node + * structure fields. + * + * Note that per-Client structure and per-pHCI fields are freely readable when + * corresponding mdi_pathinfo locks are held, since holding an mdi_pathinfo + * node guarantees that its corresponding client and pHCI devices will not be + * freed. + */ + +/* + * MDI Client global unique identifier property name string definition + */ +extern const char *mdi_client_guid_prop; +#define MDI_CLIENT_GUID_PROP (char *)mdi_client_guid_prop + +/* + * MDI Client load balancing policy definitions + * + * Load balancing policies are determined on a per-vHCI basis and are + * configurable via the vHCI's driver.conf file. + */ +typedef enum { + LOAD_BALANCE_NONE, /* Alternate pathing */ + LOAD_BALANCE_RR, /* Round Robin */ + LOAD_BALANCE_LBA /* Logical Block Addressing */ +} client_lb_t; + +typedef struct { + int region_size; +}client_lb_args_t; + +/* + * MDI client load balancing property name/value string definitions + */ +extern const char *mdi_load_balance; +extern const char *mdi_load_balance_none; +extern const char *mdi_load_balance_ap; +extern const char *mdi_load_balance_rr; +extern const char *mdi_load_balance_lba; + +#define LOAD_BALANCE_PROP (char *)mdi_load_balance +#define LOAD_BALANCE_PROP_NONE (char *)mdi_load_balance_none +#define LOAD_BALANCE_PROP_AP (char *)mdi_load_balance_ap +#define LOAD_BALANCE_PROP_RR (char *)mdi_load_balance_rr +#define LOAD_BALANCE_PROP_LBA (char *)mdi_load_balance_lba + +/* default for region size */ +#define LOAD_BALANCE_DEFAULT_REGION_SIZE 18 + +/* + * vHCI drivers: + * + * vHCI drivers are pseudo nexus drivers which implement multipath services + * for a specific command set or bus architecture ('class'). There is a + * single instance of the vHCI driver for each command set which supports + * multipath devices. + * + * Each vHCI driver registers the following callbacks from attach(9e). + */ +#define MDI_VHCI_OPS_REV_1 1 +#define MDI_VHCI_OPS_REV MDI_VHCI_OPS_REV_1 + +typedef struct mdi_vhci_ops { + /* revision management */ + int vo_revision; + + /* mdi_pathinfo node init callback */ + int (*vo_pi_init)(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags); + + /* mdi_pathinfo node uninit callback */ + int (*vo_pi_uninit)(dev_info_t *vdip, mdi_pathinfo_t *pip, + int flags); + + /* mdi_pathinfo node state change callback */ + int (*vo_pi_state_change)(dev_info_t *vdip, mdi_pathinfo_t *pip, + mdi_pathinfo_state_t state, uint32_t, int flags); + + /* Client path failover callback */ + int (*vo_failover)(dev_info_t *vdip, dev_info_t *cdip, int flags); + + /* Client attached callback */ + void (*vo_client_attached)(dev_info_t *cdip); + + /* Ask vHCI if 'cinfo' device is support as a client */ + int (*vo_is_dev_supported)(dev_info_t *vdip, dev_info_t *pdip, + void *cinfo); +} mdi_vhci_ops_t; + +/* + * An mdi_vhci structure is created and bound to the devinfo node of every + * registered vHCI class driver; this happens when a vHCI registers itself from + * attach(9e). This structure is unbound and freed when the vHCI unregisters + * at detach(9e) time; + * + * Each vHCI driver is associated with a vHCI class name; this is the handle + * used to register and unregister pHCI drivers for a given transport. + * + * Locking: Different parts of this structure are guarded by different + * locks: global threading of multiple vHCIs and initialization is protected + * by mdi_mutex, the list of pHCIs associated with a vHCI is protected by + * vh_phci_mutex, and Clients are protected by vh_client_mutex. + * + * XXX Depending on the context, some of the fields can be freely read without + * holding any locks (ex. holding vh_client_mutex lock also guarantees that + * the vHCI (parent) cannot be unexpectedly freed). + */ +typedef struct mdi_vhci { + /* protected by mdi_mutex... */ + struct mdi_vhci *vh_next; /* next vHCI link */ + struct mdi_vhci *vh_prev; /* prev vHCI link */ + char *vh_class; /* vHCI class name */ + dev_info_t *vh_dip; /* vHCI devi handle */ + int vh_refcnt; /* vHCI reference count */ + struct mdi_vhci_config *vh_config; /* vHCI config */ + client_lb_t vh_lb; /* vHCI load-balancing */ + struct mdi_vhci_ops *vh_ops; /* vHCI callback vectors */ + + /* protected by MDI_VHCI_PHCI_LOCK vh_phci_mutex... */ + kmutex_t vh_phci_mutex; /* pHCI mutex */ + int vh_phci_count; /* pHCI device count */ + struct mdi_phci *vh_phci_head; /* pHCI list head */ + struct mdi_phci *vh_phci_tail; /* pHCI list tail */ + + /* protected by MDI_VHCI_CLIENT_LOCK vh_client_mutex... */ + kmutex_t vh_client_mutex; /* Client mutex */ + int vh_client_count; /* Client count */ + struct client_hash *vh_client_table; /* Client hash */ +} mdi_vhci_t; + +/* + * per-vHCI lock macros + */ +#define MDI_VHCI_PHCI_LOCK(vh) mutex_enter(&(vh)->vh_phci_mutex) +#define MDI_VHCI_PHCI_TRYLOCK(vh) mutex_tryenter(&(vh)->vh_phci_mutex) +#define MDI_VHCI_PHCI_UNLOCK(vh) mutex_exit(&(vh)->vh_phci_mutex) +#ifdef DEBUG +#define MDI_VHCI_PCHI_LOCKED(vh) MUTEX_HELD(&(vh)->vh_phci_mutex) +#endif /* DEBUG */ +#define MDI_VHCI_CLIENT_LOCK(vh) mutex_enter(&(vh)->vh_client_mutex) +#define MDI_VHCI_CLIENT_TRYLOCK(vh) mutex_tryenter(&(vh)->vh_client_mutex) +#define MDI_VHCI_CLIENT_UNLOCK(vh) mutex_exit(&(vh)->vh_client_mutex) +#ifdef DEBUG +#define MDI_VHCI_CLIENT_LOCKED(vh) MUTEX_HELD(&(vh)->vh_client_mutex) +#endif /* DEBUG */ + + +/* + * GUID Hash definitions + * + * Since all the mpxio managed devices for a given class are enumerated under + * the single vHCI instance for that class, sequentially walking through the + * client device link to find a client would be prohibitively slow. + */ + +#define CLIENT_HASH_TABLE_SIZE (32) /* GUID hash */ + +/* + * Client hash table structure + */ +struct client_hash { + struct mdi_client *ct_hash_head; /* Client hash head */ + int ct_hash_count; /* Client hash count */ +}; + + +/* + * pHCI Drivers: + * + * Physical HBA drivers provide transport services for mpxio-managed devices. + * As each pHCI instance is attached, it must register itself with the mpxio + * framework using mdi_phci_register(). When the pHCI is detached it must + * similarly call mdi_phci_unregister(). + * + * The framework maintains a list of registered pHCI device instances for each + * vHCI. This list involves (vh_phci_count, vh_phci_head, vh_phci_tail) and + * (ph_next, ph_prev, ph_vhci) and is protected by vh_phci_mutex. + * + * Locking order: + * + * _NOTE(LOCK_ORDER(mdi_mutex, mdi_phci::ph_mutex)) XXX + * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex devinfo_tree_lock)) XXX + */ +typedef struct mdi_phci { + /* protected by MDI_VHCI_PHCI_LOCK vh_phci_mutex... */ + struct mdi_phci *ph_next; /* next pHCI link */ + struct mdi_phci *ph_prev; /* prev pHCI link */ + dev_info_t *ph_dip; /* pHCI devi handle */ + struct mdi_vhci *ph_vhci; /* pHCI back ref. to vHCI */ + + /* protected by MDI_PHCI_LOCK ph_mutex... */ + kmutex_t ph_mutex; /* per-pHCI mutex */ + int ph_path_count; /* pi count */ + mdi_pathinfo_t *ph_path_head; /* pi list head */ + mdi_pathinfo_t *ph_path_tail; /* pi list tail */ + int ph_flags; /* pHCI operation flags */ + int ph_unstable; /* Paths in transient state */ + kcondvar_t ph_unstable_cv; /* Paths in transient state */ + + /* protected by mdi_phci_[gs]et_vhci_private caller... */ + void *ph_vprivate; /* vHCI driver private */ +} mdi_phci_t; + +/* + * A pHCI device is 'unstable' while one or more paths are in a transitional + * state. Hotplugging is prevented during this state. + */ +#define MDI_PHCI_UNSTABLE(ph) (ph)->ph_unstable++; +#define MDI_PHCI_STABLE(ph) { \ + (ph)->ph_unstable--; \ + if ((ph)->ph_unstable == 0) { \ + cv_broadcast(&(ph)->ph_unstable_cv); \ + } \ +} + +/* + * per-pHCI lock macros + */ +#define MDI_PHCI_LOCK(ph) mutex_enter(&(ph)->ph_mutex) +#define MDI_PHCI_TRYLOCK(ph) mutex_tryenter(&(ph)->ph_mutex) +#define MDI_PHCI_UNLOCK(ph) mutex_exit(&(ph)->ph_mutex) +#ifdef DEBUG +#define MDI_PHCI_LOCKED(vh) MUTEX_HELD(&(ph)->ph_mutex) +#endif /* DEBUG */ + +/* + * pHCI state definitions and macros to track the pHCI driver instance state + */ +#define MDI_PHCI_FLAGS_OFFLINE 0x1 /* pHCI is offline */ +#define MDI_PHCI_FLAGS_SUSPEND 0x2 /* pHCI is suspended */ +#define MDI_PHCI_FLAGS_POWER_DOWN 0x4 /* pHCI is power down */ +#define MDI_PHCI_FLAGS_DETACH 0x8 /* pHCI is detached */ +#define MDI_PHCI_FLAGS_USER_DISABLE 0x10 /* pHCI is disabled,user */ +#define MDI_PHCI_FLAGS_D_DISABLE 0x20 /* pHCI is disabled,driver */ +#define MDI_PHCI_FLAGS_D_DISABLE_TRANS 0x40 /* pHCI is disabled,transient */ +#define MDI_PHCI_FLAGS_POWER_TRANSITION 0x80 /* pHCI is power transition */ + +#define MDI_PHCI_DISABLE_MASK \ + (MDI_PHCI_FLAGS_USER_DISABLE | MDI_PHCI_FLAGS_D_DISABLE | \ + MDI_PHCI_FLAGS_D_DISABLE_TRANS) + +#define MDI_PHCI_IS_READY(ph) \ + (((ph)->ph_flags & MDI_PHCI_DISABLE_MASK) == 0) + +#define MDI_PHCI_SET_OFFLINE(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags |= MDI_PHCI_FLAGS_OFFLINE; } +#define MDI_PHCI_SET_ONLINE(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags &= ~MDI_PHCI_FLAGS_OFFLINE; } +#define MDI_PHCI_IS_OFFLINE(ph) \ + ((ph)->ph_flags & MDI_PHCI_FLAGS_OFFLINE) + +#define MDI_PHCI_SET_SUSPEND(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags |= MDI_PHCI_FLAGS_SUSPEND; } +#define MDI_PHCI_SET_RESUME(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags &= ~MDI_PHCI_FLAGS_SUSPEND; } +#define MDI_PHCI_IS_SUSPENDED(ph) \ + ((ph)->ph_flags & MDI_PHCI_FLAGS_SUSPEND) + +#define MDI_PHCI_SET_DETACH(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags |= MDI_PHCI_FLAGS_DETACH; } +#define MDI_PHCI_SET_ATTACH(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags &= ~MDI_PHCI_FLAGS_DETACH; } + +#define MDI_PHCI_SET_POWER_DOWN(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags |= MDI_PHCI_FLAGS_POWER_DOWN; } +#define MDI_PHCI_SET_POWER_UP(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags &= ~MDI_PHCI_FLAGS_POWER_DOWN; } +#define MDI_PHCI_IS_POWERED_DOWN(ph) \ + ((ph)->ph_flags & MDI_PHCI_FLAGS_POWER_DOWN) + +#define MDI_PHCI_SET_USER_ENABLE(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags &= ~MDI_PHCI_FLAGS_USER_DISABLE; } +#define MDI_PHCI_SET_USER_DISABLE(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags |= MDI_PHCI_FLAGS_USER_DISABLE; } +#define MDI_PHCI_IS_USER_DISABLED(ph) \ + ((ph)->ph_flags & MDI_PHCI_FLAGS_USER_DISABLE) + +#define MDI_PHCI_SET_DRV_ENABLE(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags &= ~MDI_PHCI_FLAGS_D_DISABLE; } +#define MDI_PHCI_SET_DRV_DISABLE(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags |= MDI_PHCI_FLAGS_D_DISABLE; } +#define MDI_PHCI_IS_DRV_DISABLED(ph) \ + ((ph)->ph_flags & MDI_PHCI_FLAGS_D_DISABLE) + +#define MDI_PHCI_SET_DRV_ENABLE_TRANSIENT(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags &= ~MDI_PHCI_FLAGS_D_DISABLE_TRANS; } +#define MDI_PHCI_SET_DRV_DISABLE_TRANSIENT(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags |= MDI_PHCI_FLAGS_D_DISABLE_TRANS; } +#define MDI_PHCI_IS_DRV_DISABLED_TRANSIENT(ph) \ + ((ph)->ph_flags & MDI_PHCI_FLAGS_D_DISABLE_TRANS) + +#define MDI_PHCI_SET_POWER_TRANSITION(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags |= MDI_PHCI_FLAGS_POWER_TRANSITION; } +#define MDI_PHCI_CLEAR_POWER_TRANSITION(ph) {\ + ASSERT(MDI_PHCI_LOCKED(ph)); \ + (ph)->ph_flags &= ~MDI_PHCI_FLAGS_POWER_TRANSITION; } +#define MDI_PHCI_IS_POWER_TRANSITION(ph) \ + ((ph)->ph_flags & MDI_PHCI_FLAGS_POWER_TRANSITION) + +/* + * mpxio Managed Clients: + * + * This framework creates a struct mdi_client for every client device created + * by the framework as a result of self-enumeration of target devices by the + * registered pHCI devices. This structure is bound to client device dev_info + * node at the time of client device allocation (ndi_devi_alloc(9e)). This + * structure is unbound from the dev_info node when mpxio framework removes a + * client device node from the system. + * + * This structure is created when a first path is enumerated and removed when + * last path is de-enumerated from the system. + * + * Multipath client devices are instantiated as children of corresponding vHCI + * driver instance. Each client device is uniquely identified by a GUID + * provided by target device itself. The parent vHCI device also maintains a + * hashed list of client devices, protected by vh_client_mutex. + * + * Typically pHCI devices self-enumerate their child devices using taskq, + * resulting in multiple paths to the same client device to be enumerated by + * competing threads. + * + * Currently this framework supports two kinds of load-balancing policy + * configurable through the vHCI driver configuration files. + * + * NONE - Legacy AP mode + * Round Robin - Balance the pHCI load in a Round Robin fashion. + * + * This framework identifies the client device in three distinct states: + * + * OPTIMAL - Client device has at least one redundant path. + * DEGRADED - No redundant paths (critical). Failure in the current active + * path would result in data access failures. + * FAILED - No paths are available to access this device. + * + * Locking order: + * + * _NOTE(LOCK_ORDER(mdi_mutex, mdi_client::ct_mutex)) XXX + * _NOTE(LOCK_ORDER(mdi_client::ct_mutex devinfo_tree_lock)) XXX + */ +typedef struct mdi_client { + /* protected by MDI_VHCI_CLIENT_LOCK vh_client_mutex... */ + struct mdi_client *ct_hnext; /* next client */ + struct mdi_client *ct_hprev; /* prev client */ + dev_info_t *ct_dip; /* client devi handle */ + struct mdi_vhci *ct_vhci; /* vHCI back ref */ + char *ct_drvname; /* client driver name */ + char *ct_guid; /* client guid */ + client_lb_t ct_lb; /* load balancing scheme */ + client_lb_args_t *ct_lb_args; /* load balancing args */ + + + /* protected by MDI_CLIENT_LOCK ct_mutex... */ + kmutex_t ct_mutex; /* per-client mutex */ + int ct_path_count; /* multi path count */ + mdi_pathinfo_t *ct_path_head; /* multi path list head */ + mdi_pathinfo_t *ct_path_tail; /* multi path list tail */ + mdi_pathinfo_t *ct_path_last; /* last path used for i/o */ + int ct_state; /* state information */ + int ct_flags; /* Driver op. flags */ + int ct_failover_flags; /* Failover args */ + int ct_failover_status; /* last fo status */ + kcondvar_t ct_failover_cv; /* Failover status cv */ + int ct_unstable; /* Paths in transient state */ + kcondvar_t ct_unstable_cv; /* Paths in transient state */ + + int ct_power_cnt; /* Hold count on parent power */ + kcondvar_t ct_powerchange_cv; + /* Paths in power transient state */ + short ct_powercnt_config; + /* held in pre/post config */ + short ct_powercnt_unconfig; + /* held in pre/post unconfig */ + int ct_powercnt_reset; + /* ct_power_cnt was reset */ + + void *ct_cprivate; /* client driver private */ + void *ct_vprivate; /* vHCI driver private */ +} mdi_client_t; + +/* + * per-Client device locking definitions + */ +#define MDI_CLIENT_LOCK(ct) mutex_enter(&(ct)->ct_mutex) +#define MDI_CLIENT_TRYLOCK(ct) mutex_tryenter(&(ct)->ct_mutex) +#define MDI_CLIENT_UNLOCK(ct) mutex_exit(&(ct)->ct_mutex) +#ifdef DEBUG +#define MDI_CLIENT_LOCKED(ct) MUTEX_HELD(&(ct)->ct_mutex) +#endif /* DEBUG */ + +/* + * A Client device is in unstable while one or more paths are in transitional + * state. We do not allow failover to take place while paths are in transient + * state. Similarly we do not allow state transition while client device + * failover is in progress. + */ +#define MDI_CLIENT_UNSTABLE(ct) (ct)->ct_unstable++; +#define MDI_CLIENT_STABLE(ct) { \ + (ct)->ct_unstable--; \ + if ((ct)->ct_unstable == 0) { \ + cv_broadcast(&(ct)->ct_unstable_cv); \ + } \ +} + +/* + * Client driver instance state definitions: + */ +#define MDI_CLIENT_FLAGS_OFFLINE 0x00000001 +#define MDI_CLIENT_FLAGS_SUSPEND 0x00000002 +#define MDI_CLIENT_FLAGS_POWER_DOWN 0x00000004 +#define MDI_CLIENT_FLAGS_DETACH 0x00000008 +#define MDI_CLIENT_FLAGS_FAILOVER 0x00000010 +#define MDI_CLIENT_FLAGS_REPORT_DEV 0x00000020 +#define MDI_CLIENT_FLAGS_PATH_FREE_IN_PROGRESS 0x00000040 +#define MDI_CLIENT_FLAGS_ASYNC_FREE 0x00000080 +#define MDI_CLIENT_FLAGS_DEV_NOT_SUPPORTED 0x00000100 +#define MDI_CLIENT_FLAGS_POWER_TRANSITION 0x00000200 + +#define MDI_CLIENT_SET_OFFLINE(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_OFFLINE; } +#define MDI_CLIENT_SET_ONLINE(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags &= ~MDI_CLIENT_FLAGS_OFFLINE; } +#define MDI_CLIENT_IS_OFFLINE(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_OFFLINE) + +#define MDI_CLIENT_SET_SUSPEND(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_SUSPEND; } +#define MDI_CLIENT_SET_RESUME(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags &= ~MDI_CLIENT_FLAGS_SUSPEND; } +#define MDI_CLIENT_IS_SUSPENDED(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_SUSPEND) + +#define MDI_CLIENT_SET_POWER_DOWN(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_POWER_DOWN; } +#define MDI_CLIENT_SET_POWER_UP(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags &= ~MDI_CLIENT_FLAGS_POWER_DOWN; } +#define MDI_CLIENT_IS_POWERED_DOWN(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_POWER_DOWN) + +#define MDI_CLIENT_SET_POWER_TRANSITION(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_POWER_TRANSITION; } +#define MDI_CLIENT_CLEAR_POWER_TRANSITION(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags &= ~MDI_CLIENT_FLAGS_POWER_TRANSITION; } +#define MDI_CLIENT_IS_POWER_TRANSITION(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_POWER_TRANSITION) + +#define MDI_CLIENT_SET_DETACH(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_DETACH; } +#define MDI_CLIENT_SET_ATTACH(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags &= ~MDI_CLIENT_FLAGS_DETACH; } +#define MDI_CLIENT_IS_DETACHED(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_DETACH) + +#define MDI_CLIENT_SET_FAILOVER_IN_PROGRESS(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_FAILOVER; } +#define MDI_CLIENT_CLEAR_FAILOVER_IN_PROGRESS(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags &= ~MDI_CLIENT_FLAGS_FAILOVER; } +#define MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_FAILOVER) + +#define MDI_CLIENT_SET_REPORT_DEV_NEEDED(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_REPORT_DEV; } +#define MDI_CLIENT_CLEAR_REPORT_DEV_NEEDED(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags &= ~MDI_CLIENT_FLAGS_REPORT_DEV; } +#define MDI_CLIENT_IS_REPORT_DEV_NEEDED(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_REPORT_DEV) + +#define MDI_CLIENT_SET_PATH_FREE_IN_PROGRESS(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_PATH_FREE_IN_PROGRESS; } +#define MDI_CLIENT_CLEAR_PATH_FREE_IN_PROGRESS(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags &= ~MDI_CLIENT_FLAGS_PATH_FREE_IN_PROGRESS; } +#define MDI_CLIENT_IS_PATH_FREE_IN_PROGRESS(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_PATH_FREE_IN_PROGRESS) + +#define MDI_CLIENT_SET_DEV_NOT_SUPPORTED(ct) {\ + ASSERT(MDI_CLIENT_LOCKED(ct)); \ + (ct)->ct_flags |= MDI_CLIENT_FLAGS_DEV_NOT_SUPPORTED; } +#define MDI_CLIENT_IS_DEV_NOT_SUPPORTED(ct) \ + ((ct)->ct_flags & MDI_CLIENT_FLAGS_DEV_NOT_SUPPORTED) + +/* + * Client operating states. + */ +#define MDI_CLIENT_STATE_OPTIMAL 1 +#define MDI_CLIENT_STATE_DEGRADED 2 +#define MDI_CLIENT_STATE_FAILED 3 + +#define MDI_CLIENT_STATE(ct) ((ct)->ct_state) +#define MDI_CLIENT_SET_STATE(ct, state) ((ct)->ct_state = state) + +#define MDI_CLIENT_IS_FAILED(ct) \ + ((ct)->ct_state == MDI_CLIENT_STATE_FAILED) + +/* + * mdi_pathinfo nodes: + * + * From this framework's perspective, a 'path' is a tuple consisting of a + * client or end device, a host controller which provides device + * identification and transport services (pHCI), and bus specific unit + * addressing information. A path may be decorated with properties which + * describe the capabilities of the path; such properties are analogous to + * device node and minor node properties. + * + * The framework maintains link list of mdi_pathinfo nodes created by every + * pHCI driver instance via the pi_phci_link linkage; this is used (for example) + * to make sure that all relevant pathinfo nodes are freed before the pHCI + * is unregistered. + * + * Locking order: + * + * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex mdi_pathinfo::pi_mutex)) XXX + * _NOTE(LOCK_ORDER(mdi_client::ct_mutex mdi_pathinfo::pi_mutex)) XXX + * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex mdi_client::ct_mutex)) XXX + * _NOTE(LOCK_ORDER(devinfo_tree_lock mdi_pathinfo::pi_mutex)) XXX + * + * mdi_pathinfo node structure definition + */ +struct mdi_pathinfo { + /* protected by MDI_PHCI_LOCK ph_mutex... */ + struct mdi_pathinfo *pi_phci_link; /* next path in phci list */ + mdi_phci_t *pi_phci; /* pHCI dev_info node */ + + /* protected by MDI_CLIENT_LOCK ct_mutex... */ + struct mdi_pathinfo *pi_client_link; /* next path in client list */ + mdi_client_t *pi_client; /* client */ + + /* protected by MDI_VHCI_CLIENT_LOCK vh_client_mutex... */ + char *pi_addr; /* path unit address */ + int pi_path_instance; /* path instance */ + + /* protected by MDI_PI_LOCK pi_mutex... */ + kmutex_t pi_mutex; /* per path mutex */ + mdi_pathinfo_state_t pi_state; /* path state */ + mdi_pathinfo_state_t pi_old_state; /* path state */ + kcondvar_t pi_state_cv; /* path state condvar */ + nvlist_t *pi_prop; /* Properties */ + void *pi_cprivate; /* client private info */ + void *pi_pprivate; /* phci private info */ + int pi_ref_cnt; /* pi reference count */ + kcondvar_t pi_ref_cv; /* condition variable */ + struct mdi_pi_kstats *pi_kstats; /* aggregate kstats */ + int pi_pm_held; /* phci's kidsup incremented */ + int pi_preferred; /* Preferred path */ + void *pi_vprivate; /* vhci private info */ + uint_t pi_flags; /* path flags */ +}; + +/* + * pathinfo statistics: + * + * The mpxio architecture allows for multiple pathinfo nodes for each + * client-pHCI combination. For statistics purposes, these statistics are + * aggregated into a single client-pHCI set of kstats. + */ +struct mdi_pi_kstats { + int pi_kstat_ref; /* # paths aggregated, also a ref cnt */ + kstat_t *pi_kstat_iostats; /* mdi:iopath statistic set */ + kstat_t *pi_kstat_errstats; /* error statistics */ +}; + +/* + * pathinfo error kstat + */ +struct pi_errs { + struct kstat_named pi_softerrs; /* "Soft" Error */ + struct kstat_named pi_harderrs; /* "Hard" Error */ + struct kstat_named pi_transerrs; /* Transport Errors */ + struct kstat_named pi_icnt_busy; /* Interconnect Busy */ + struct kstat_named pi_icnt_errors; /* Interconnect Errors */ + struct kstat_named pi_phci_rsrc; /* pHCI No Resources */ + struct kstat_named pi_phci_localerr; /* pHCI Local Errors */ + struct kstat_named pi_phci_invstate; /* pHCI Invalid State */ + struct kstat_named pi_failedfrom; /* Failover: Failed From */ + struct kstat_named pi_failedto; /* Failover: Failed To */ +}; + +/* + * increment an error counter + */ +#define MDI_PI_ERRSTAT(pip, x) { \ + if (MDI_PI((pip))->pi_kstats != NULL) { \ + struct pi_errs *pep; \ + pep = MDI_PI(pip)->pi_kstats->pi_kstat_errstats->ks_data; \ + pep->x.value.ui32++; \ + } \ +} + +/* + * error codes which can be passed to MDI_PI_ERRSTAT + */ +#define MDI_PI_SOFTERR pi_softerrs +#define MDI_PI_HARDERR pi_harderrs +#define MDI_PI_TRANSERR pi_transerrs +#define MDI_PI_ICNTBUSY pi_icnt_busy +#define MDI_PI_ICNTERR pi_icnt_errors +#define MDI_PI_PHCIRSRC pi_phci_rsrc +#define MDI_PI_PHCILOCL pi_phci_localerr +#define MDI_PI_PHCIINVS pi_phci_invstate +#define MDI_PI_FAILFROM pi_failedfrom +#define MDI_PI_FAILTO pi_failedto + +#define MDI_PI(type) ((struct mdi_pathinfo *)(type)) + +#define MDI_PI_LOCK(pip) mutex_enter(&MDI_PI(pip)->pi_mutex) +#define MDI_PI_TRYLOCK(pip) mutex_tryenter(&MDI_PI(pip)->pi_mutex) +#define MDI_PI_UNLOCK(pip) mutex_exit(&MDI_PI(pip)->pi_mutex) +#ifdef DEBUG +#define MDI_PI_LOCKED(pip) MUTEX_HELD(&MDI_PI(pip)->pi_mutex) +#endif /* DEBUG */ + +#define MDI_PI_HOLD(pip) (++MDI_PI(pip)->pi_ref_cnt) +#define MDI_PI_RELE(pip) (--MDI_PI(pip)->pi_ref_cnt) + +#define MDI_EXT_STATE_CHANGE 0x10000000 + + +#define MDI_DISABLE_OP 0x1 +#define MDI_ENABLE_OP 0x2 +#define MDI_BEFORE_STATE_CHANGE 0x4 +#define MDI_AFTER_STATE_CHANGE 0x8 +#define MDI_SYNC_FLAG 0x10 + +#define MDI_PI_STATE(pip) \ + (MDI_PI((pip))->pi_state & MDI_PATHINFO_STATE_MASK) +#define MDI_PI_OLD_STATE(pip) \ + (MDI_PI((pip))->pi_old_state & MDI_PATHINFO_STATE_MASK) + +#define MDI_PI_EXT_STATE(pip) \ + (MDI_PI((pip))->pi_state & MDI_PATHINFO_EXT_STATE_MASK) +#define MDI_PI_OLD_EXT_STATE(pip) \ + (MDI_PI((pip))->pi_old_state & MDI_PATHINFO_EXT_STATE_MASK) + +#define MDI_PI_SET_TRANSIENT(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state |= MDI_PATHINFO_STATE_TRANSIENT; } +#define MDI_PI_CLEAR_TRANSIENT(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state &= ~MDI_PATHINFO_STATE_TRANSIENT; } +#define MDI_PI_IS_TRANSIENT(pip) \ + (MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_TRANSIENT) + +#define MDI_PI_SET_USER_DISABLE(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state |= MDI_PATHINFO_STATE_USER_DISABLE; } +#define MDI_PI_SET_DRV_DISABLE(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state |= MDI_PATHINFO_STATE_DRV_DISABLE; } +#define MDI_PI_SET_DRV_DISABLE_TRANS(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state |= MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT; } + +#define MDI_PI_SET_USER_ENABLE(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state &= ~MDI_PATHINFO_STATE_USER_DISABLE; } +#define MDI_PI_SET_DRV_ENABLE(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state &= ~MDI_PATHINFO_STATE_DRV_DISABLE; } +#define MDI_PI_SET_DRV_ENABLE_TRANS(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state &= ~MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT; } + +#define MDI_PI_IS_USER_DISABLE(pip) \ + (MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_USER_DISABLE) +#define MDI_PI_IS_DRV_DISABLE(pip) \ + (MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_DRV_DISABLE) +#define MDI_PI_IS_DRV_DISABLE_TRANSIENT(pip) \ + (MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT) + +#define MDI_PI_IS_DISABLE(pip) \ + (MDI_PI_IS_USER_DISABLE(pip) || \ + MDI_PI_IS_DRV_DISABLE(pip) || \ + MDI_PI_IS_DRV_DISABLE_TRANSIENT(pip)) + +#define MDI_PI_IS_INIT(pip) \ + ((MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_MASK) == \ + MDI_PATHINFO_STATE_INIT) + +#define MDI_PI_IS_INITING(pip) \ + ((MDI_PI(pip)->pi_state & ~MDI_PATHINFO_EXT_STATE_MASK) == \ + (MDI_PATHINFO_STATE_INIT | MDI_PATHINFO_STATE_TRANSIENT)) + +#define MDI_PI_SET_INIT(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_state = MDI_PATHINFO_STATE_INIT; } + +#define MDI_PI_SET_ONLINING(pip) {\ + uint32_t ext_state; \ + ASSERT(MDI_PI_LOCKED(pip)); \ + ext_state = MDI_PI(pip)->pi_state & MDI_PATHINFO_EXT_STATE_MASK; \ + MDI_PI(pip)->pi_old_state = MDI_PI_STATE(pip); \ + MDI_PI(pip)->pi_state = \ + (MDI_PATHINFO_STATE_ONLINE | MDI_PATHINFO_STATE_TRANSIENT); \ + MDI_PI(pip)->pi_state |= ext_state; } + +#define MDI_PI_IS_ONLINING(pip) \ + ((MDI_PI(pip)->pi_state & ~MDI_PATHINFO_EXT_STATE_MASK) == \ + (MDI_PATHINFO_STATE_ONLINE | MDI_PATHINFO_STATE_TRANSIENT)) + +#define MDI_PI_SET_ONLINE(pip) {\ + uint32_t ext_state; \ + ASSERT(MDI_PI_LOCKED(pip)); \ + ext_state = MDI_PI(pip)->pi_state & MDI_PATHINFO_EXT_STATE_MASK; \ + MDI_PI(pip)->pi_state = MDI_PATHINFO_STATE_ONLINE; \ + MDI_PI(pip)->pi_state |= ext_state; } + +#define MDI_PI_IS_ONLINE(pip) \ + ((MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_MASK) == \ + MDI_PATHINFO_STATE_ONLINE) + +#define MDI_PI_SET_OFFLINING(pip) {\ + uint32_t ext_state; \ + ASSERT(MDI_PI_LOCKED(pip)); \ + ext_state = MDI_PI(pip)->pi_state & MDI_PATHINFO_EXT_STATE_MASK; \ + MDI_PI(pip)->pi_old_state = MDI_PI_STATE(pip); \ + MDI_PI(pip)->pi_state = \ + (MDI_PATHINFO_STATE_OFFLINE | MDI_PATHINFO_STATE_TRANSIENT); \ + MDI_PI(pip)->pi_state |= ext_state; } + +#define MDI_PI_IS_OFFLINING(pip) \ + ((MDI_PI(pip)->pi_state & ~MDI_PATHINFO_EXT_STATE_MASK) == \ + (MDI_PATHINFO_STATE_OFFLINE | MDI_PATHINFO_STATE_TRANSIENT)) + +#define MDI_PI_SET_OFFLINE(pip) {\ + uint32_t ext_state; \ + ASSERT(MDI_PI_LOCKED(pip)); \ + ext_state = MDI_PI(pip)->pi_state & MDI_PATHINFO_EXT_STATE_MASK; \ + MDI_PI(pip)->pi_state = MDI_PATHINFO_STATE_OFFLINE; \ + MDI_PI(pip)->pi_state |= ext_state; } + +#define MDI_PI_IS_OFFLINE(pip) \ + ((MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_MASK) == \ + MDI_PATHINFO_STATE_OFFLINE) + +#define MDI_PI_SET_STANDBYING(pip) {\ + uint32_t ext_state; \ + ASSERT(MDI_PI_LOCKED(pip)); \ + ext_state = MDI_PI(pip)->pi_state & MDI_PATHINFO_EXT_STATE_MASK; \ + MDI_PI(pip)->pi_old_state = MDI_PI_STATE(pip); \ + MDI_PI(pip)->pi_state = \ + (MDI_PATHINFO_STATE_STANDBY | MDI_PATHINFO_STATE_TRANSIENT); \ + MDI_PI(pip)->pi_state |= ext_state; } + +#define MDI_PI_SET_STANDBY(pip) {\ + uint32_t ext_state; \ + ASSERT(MDI_PI_LOCKED(pip)); \ + ext_state = MDI_PI(pip)->pi_state & MDI_PATHINFO_EXT_STATE_MASK; \ + MDI_PI(pip)->pi_state = MDI_PATHINFO_STATE_STANDBY; \ + MDI_PI(pip)->pi_state |= ext_state; } + +#define MDI_PI_IS_STANDBY(pip) \ + ((MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_MASK) == \ + MDI_PATHINFO_STATE_STANDBY) + +#define MDI_PI_SET_FAULTING(pip) {\ + uint32_t ext_state; \ + ASSERT(MDI_PI_LOCKED(pip)); \ + ext_state = MDI_PI(pip)->pi_state & MDI_PATHINFO_EXT_STATE_MASK; \ + MDI_PI(pip)->pi_old_state = MDI_PI_STATE(pip); \ + MDI_PI(pip)->pi_state = \ + (MDI_PATHINFO_STATE_FAULT | MDI_PATHINFO_STATE_TRANSIENT); \ + MDI_PI(pip)->pi_state |= ext_state; } + +#define MDI_PI_SET_FAULT(pip) {\ + uint32_t ext_state; \ + ASSERT(MDI_PI_LOCKED(pip)); \ + ext_state = MDI_PI(pip)->pi_state & MDI_PATHINFO_EXT_STATE_MASK; \ + MDI_PI(pip)->pi_state = MDI_PATHINFO_STATE_FAULT; \ + MDI_PI(pip)->pi_state |= ext_state; } + +#define MDI_PI_IS_FAULT(pip) \ + ((MDI_PI(pip)->pi_state & MDI_PATHINFO_STATE_MASK) == \ + MDI_PATHINFO_STATE_FAULT) + +#define MDI_PI_IS_SUSPENDED(pip) \ + ((MDI_PI(pip))->pi_phci->ph_flags & MDI_PHCI_FLAGS_SUSPEND) + +#define MDI_PI_FLAGS_SET_HIDDEN(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_flags |= MDI_PATHINFO_FLAGS_HIDDEN; } +#define MDI_PI_FLAGS_CLR_HIDDEN(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_flags &= ~MDI_PATHINFO_FLAGS_HIDDEN; } +#define MDI_PI_FLAGS_IS_HIDDEN(pip) \ + ((MDI_PI(pip)->pi_flags & MDI_PATHINFO_FLAGS_HIDDEN) == \ + MDI_PATHINFO_FLAGS_HIDDEN) + +#define MDI_PI_FLAGS_SET_DEVICE_REMOVED(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_flags |= MDI_PATHINFO_FLAGS_DEVICE_REMOVED; } +#define MDI_PI_FLAGS_CLR_DEVICE_REMOVED(pip) {\ + ASSERT(MDI_PI_LOCKED(pip)); \ + MDI_PI(pip)->pi_flags &= ~MDI_PATHINFO_FLAGS_DEVICE_REMOVED; } +#define MDI_PI_FLAGS_IS_DEVICE_REMOVED(pip) \ + ((MDI_PI(pip)->pi_flags & MDI_PATHINFO_FLAGS_DEVICE_REMOVED) == \ + MDI_PATHINFO_FLAGS_DEVICE_REMOVED) + +/* + * mdi_vhcache_client, mdi_vhcache_pathinfo, and mdi_vhcache_phci structures + * hold the vhci to phci client mappings of the on-disk vhci busconfig cache. + */ + +/* phci structure of vhci cache */ +typedef struct mdi_vhcache_phci { + char *cphci_path; /* phci path name */ + uint32_t cphci_id; /* used when building nvlist */ + mdi_phci_t *cphci_phci; /* pointer to actual phci */ + struct mdi_vhcache_phci *cphci_next; /* next in vhci phci list */ +} mdi_vhcache_phci_t; + +/* pathinfo structure of vhci cache */ +typedef struct mdi_vhcache_pathinfo { + char *cpi_addr; /* path address */ + mdi_vhcache_phci_t *cpi_cphci; /* phci the path belongs to */ + struct mdi_pathinfo *cpi_pip; /* ptr to actual pathinfo */ + uint32_t cpi_flags; /* see below */ + struct mdi_vhcache_pathinfo *cpi_next; /* next path for the client */ +} mdi_vhcache_pathinfo_t; + +/* + * cpi_flags + * + * MDI_CPI_HINT_PATH_DOES_NOT_EXIST - set when configuration of the path has + * failed. + */ +#define MDI_CPI_HINT_PATH_DOES_NOT_EXIST 0x0001 + +/* client structure of vhci cache */ +typedef struct mdi_vhcache_client { + char *cct_name_addr; /* client address */ + mdi_vhcache_pathinfo_t *cct_cpi_head; /* client's path list head */ + mdi_vhcache_pathinfo_t *cct_cpi_tail; /* client's path list tail */ + struct mdi_vhcache_client *cct_next; /* next in vhci client list */ +} mdi_vhcache_client_t; + +/* vhci cache structure - one for vhci instance */ +typedef struct mdi_vhci_cache { + mdi_vhcache_phci_t *vhcache_phci_head; /* phci list head */ + mdi_vhcache_phci_t *vhcache_phci_tail; /* phci list tail */ + mdi_vhcache_client_t *vhcache_client_head; /* client list head */ + mdi_vhcache_client_t *vhcache_client_tail; /* client list tail */ + mod_hash_t *vhcache_client_hash; /* client hash */ + int vhcache_flags; /* see below */ + int64_t vhcache_clean_time; /* last clean time */ + krwlock_t vhcache_lock; /* cache lock */ +} mdi_vhci_cache_t; + +/* vhcache_flags */ +#define MDI_VHCI_CACHE_SETUP_DONE 0x0001 /* cache setup completed */ + +/* vhci bus config structure - one for vhci instance */ +typedef struct mdi_vhci_config { + char *vhc_vhcache_filename; /* on-disk file name */ + mdi_vhci_cache_t vhc_vhcache; /* vhci cache */ + kmutex_t vhc_lock; /* vhci config lock */ + kcondvar_t vhc_cv; + int vhc_flags; /* see below */ + + /* flush vhci cache when lbolt reaches vhc_flush_at_ticks */ + clock_t vhc_flush_at_ticks; + + /* + * Head and tail of the client list whose paths are being configured + * asynchronously. vhc_acc_count is the number of clients on this list. + * vhc_acc_thrcount is the number threads running to configure + * the paths for these clients. + */ + struct mdi_async_client_config *vhc_acc_list_head; + struct mdi_async_client_config *vhc_acc_list_tail; + int vhc_acc_count; + int vhc_acc_thrcount; + + /* callback id - for flushing the cache during system shutdown */ + callb_id_t vhc_cbid; + + /* + * vhc_path_discovery_boot - number of times path discovery will be + * attempted during early boot. + * vhc_path_discovery_postboot number of times path discovery will be + * attempted during late boot. + * vhc_path_discovery_cutoff_time - time at which paths were last + * discovered + some timeout + */ + int vhc_path_discovery_boot; + int vhc_path_discovery_postboot; + int64_t vhc_path_discovery_cutoff_time; +} mdi_vhci_config_t; + +/* vhc_flags */ +#define MDI_VHC_SINGLE_THREADED 0x0001 /* config single threaded */ +#define MDI_VHC_EXIT 0x0002 /* exit all config activity */ +#define MDI_VHC_VHCACHE_DIRTY 0x0004 /* cache dirty */ +#define MDI_VHC_VHCACHE_FLUSH_THREAD 0x0008 /* cache flush thead running */ +#define MDI_VHC_VHCACHE_FLUSH_ERROR 0x0010 /* failed to flush cache */ +#define MDI_VHC_READONLY_FS 0x0020 /* filesys is readonly */ + +typedef struct mdi_phys_path { + char *phys_path; + struct mdi_phys_path *phys_path_next; +} mdi_phys_path_t; + +/* + * Lookup tokens are used to cache the result of the vhci cache client lookup + * operations (to reduce the number of real lookup operations). + */ +typedef struct mdi_vhcache_lookup_token { + mdi_vhcache_client_t *lt_cct; /* vhcache client */ + int64_t lt_cct_lookup_time; /* last lookup time */ +} mdi_vhcache_lookup_token_t; + +/* asynchronous configuration of client paths */ +typedef struct mdi_async_client_config { + char *acc_ct_name; /* client name */ + char *acc_ct_addr; /* client address */ + mdi_phys_path_t *acc_phclient_path_list_head; /* path head */ + mdi_vhcache_lookup_token_t acc_token; /* lookup token */ + struct mdi_async_client_config *acc_next; /* next in vhci acc list */ +} mdi_async_client_config_t; + +/* + * vHCI driver instance registration/unregistration + * + * mdi_vhci_register() is called by a vHCI driver to register itself as the + * manager of devices from a particular 'class'. This should be called from + * attach(9e). + * + * mdi_vhci_unregister() is called from detach(9E) to unregister a vHCI + * instance from the framework. + */ +int mdi_vhci_register(char *, dev_info_t *, mdi_vhci_ops_t *, int); +int mdi_vhci_unregister(dev_info_t *, int); + +/* + * Utility functions + */ +int mdi_phci_get_path_count(dev_info_t *); +dev_info_t *mdi_phci_path2devinfo(dev_info_t *, caddr_t); + + +/* + * Path Selection Functions: + * + * mdi_select_path() is called by a vHCI driver to select to which path an + * I/O request should be routed. The caller passes the 'buf' structure as + * one of the parameters. The mpxio framework uses the buf's contents to + * maintain per path statistics (total I/O size / count pending). If more + * than one online path is available, the framework automatically selects + * a suitable one. If a failover operation is active for this client device + * the call fails, returning MDI_BUSY. + * + * By default this function returns a suitable path in the 'online' state, + * based on the current load balancing policy. Currently we support + * LOAD_BALANCE_NONE (Previously selected online path will continue to be + * used as long as the path is usable) and LOAD_BALANCE_RR (Online paths + * will be selected in a round robin fashion). The load balancing scheme + * can be configured in the vHCI driver's configuration file (driver.conf). + * + * vHCI drivers may override this default behavior by specifying appropriate + * flags. If start_pip is specified (non NULL), it is used as the routine's + * starting point; it starts walking from there to find the next appropriate + * path. + * + * The following values for 'flags' are currently defined, the third argument + * to mdi_select_path depends on the flags used. + * + * : default, arg is pip + * MDI_SELECT_ONLINE_PATH: select an ONLINE path preferred-first, + * arg is pip + * MDI_SELECT_STANDBY_PATH: select a STANDBY path, arg is pip + * MDI_SELECT_USER_DISABLE_PATH: select user disable for failover and + * auto_failback + * MDI_SELECT_PATH_INSTANCE: select a specific path, arg is + * path instance + * MDI_SELECT_NO_PREFERRED: select path without preferred-first + * + * The selected paths are returned in an mdi_hold_path() state (pi_ref_cnt), + * caller should release the hold by calling mdi_rele_path() at the end of + * operation. + */ +int mdi_select_path(dev_info_t *, struct buf *, int, + void *, mdi_pathinfo_t **); +int mdi_set_lb_policy(dev_info_t *, client_lb_t); +int mdi_set_lb_region_size(dev_info_t *, int); +client_lb_t mdi_get_lb_policy(dev_info_t *); + +/* + * flags for mdi_select_path() routine + */ +#define MDI_SELECT_ONLINE_PATH 0x0001 +#define MDI_SELECT_STANDBY_PATH 0x0002 +#define MDI_SELECT_USER_DISABLE_PATH 0x0004 +#define MDI_SELECT_PATH_INSTANCE 0x0008 +#define MDI_SELECT_NO_PREFERRED 0x0010 + +/* + * MDI client device utility functions + */ +int mdi_client_get_path_count(dev_info_t *); +dev_info_t *mdi_client_path2devinfo(dev_info_t *, caddr_t); + +/* + * Failover: + * + * The vHCI driver calls mdi_failover() to initiate a failover operation. + * mdi_failover() calls back into the vHCI driver's vo_failover() + * entry point to perform the actual failover operation. The reason + * for requiring the vHCI driver to initiate failover by calling + * mdi_failover(), instead of directly executing vo_failover() itself, + * is to ensure that the mdi framework can keep track of the client + * state properly. Additionally, mdi_failover() provides as a + * convenience the option of performing the failover operation + * synchronously or asynchronously + * + * Upon successful completion of the failover operation, the paths that were + * previously ONLINE will be in the STANDBY state, and the newly activated + * paths will be in the ONLINE state. + * + * The flags modifier determines whether the activation is done synchronously + */ +int mdi_failover(dev_info_t *, dev_info_t *, int); + +/* + * Client device failover mode of operation + */ +#define MDI_FAILOVER_SYNC 1 /* Synchronous Failover */ +#define MDI_FAILOVER_ASYNC 2 /* Asynchronous Failover */ + +/* + * mdi_is_dev_supported: The pHCI driver bus_config implementation calls + * mdi_is_dev_supported to determine if a child device should is supported as + * a vHCI child (i.e. as a client). The method used to specify the child + * device, via the cinfo argument, is by agreement between the pHCI and the + * vHCI. In the case of SCSA and scsi_vhci cinfo is a pointer to the pHCI + * probe dev_info node, which is decorated with the device idenity information + * necessary to determine scsi_vhci support. + */ +int mdi_is_dev_supported(char *class, dev_info_t *pdip, void *cinfo); + +/* + * mdi_pathinfo node kstat functions. + */ +int mdi_pi_kstat_exists(mdi_pathinfo_t *); +int mdi_pi_kstat_create(mdi_pathinfo_t *pip, char *ks_name); +void mdi_pi_kstat_iosupdate(mdi_pathinfo_t *, struct buf *); + +/* + * mdi_pathinfo node extended state change functions. + */ +int mdi_pi_get_state2(mdi_pathinfo_t *, mdi_pathinfo_state_t *, uint32_t *); +int mdi_pi_get_preferred(mdi_pathinfo_t *); + +/* + * mdi_pathinfo node member functions + */ +void *mdi_pi_get_client_private(mdi_pathinfo_t *); +void mdi_pi_set_client_private(mdi_pathinfo_t *, void *); +void mdi_pi_set_state(mdi_pathinfo_t *, mdi_pathinfo_state_t); +void mdi_pi_set_preferred(mdi_pathinfo_t *, int); + +/* get/set vhci private data */ +void *mdi_client_get_vhci_private(dev_info_t *); +void mdi_client_set_vhci_private(dev_info_t *, void *); +void *mdi_phci_get_vhci_private(dev_info_t *); +void mdi_phci_set_vhci_private(dev_info_t *, void *); +void *mdi_pi_get_vhci_private(mdi_pathinfo_t *); +void mdi_pi_set_vhci_private(mdi_pathinfo_t *, void *); +int mdi_dc_return_dev_state(mdi_pathinfo_t *pip, struct devctl_iocdata *dcp); + +/* + * mdi_pathinfo Property utilities + */ +int mdi_prop_size(mdi_pathinfo_t *, size_t *); +int mdi_prop_pack(mdi_pathinfo_t *, char **, uint_t); + +/* obsolete interface, to be removed */ +void mdi_get_next_path(dev_info_t *, mdi_pathinfo_t *, mdi_pathinfo_t **); +int mdi_get_component_type(dev_info_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MDI_IMPLDEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/mem.h b/illumos-x86_64/usr/include/sys/mem.h new file mode 100644 index 00000000..ff265b18 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mem.h @@ -0,0 +1,152 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + * Copyright (c) 2017 James S Blachly, MD + */ + +#ifndef _SYS_MEM_H +#define _SYS_MEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Memory Device Minor Numbers + */ +#define M_MEM 0 /* /dev/mem - physical main memory */ +#define M_KMEM 1 /* /dev/kmem - virtual kernel memory */ +#define M_NULL 2 /* /dev/null - EOF & Rathole */ +#define M_ALLKMEM 3 /* /dev/allkmem - virtual kernel memory & I/O */ +#define M_ZERO 12 /* /dev/zero - source of private memory */ +#define M_FULL 13 /* /dev/full - write always ret ENOSPC */ + +/* + * Private ioctl for libkvm: translate virtual address to physical address. + */ +#define MEM_VTOP (('M' << 8) | 0x01) + +typedef struct mem_vtop { + struct as *m_as; + void *m_va; + pfn_t m_pfn; +} mem_vtop_t; + +#if defined(_SYSCALL32) +typedef struct mem_vtop32 { + uint32_t m_as; + uint32_t m_va; + uint32_t m_pfn; +} mem_vtop32_t; +#endif + +/* + * Private ioctls for fmd(8). These interfaces are Sun Private. Applications + * and drivers should not make use of these interfaces: they can change without + * notice and programs that consume them will fail to run on future releases. + */ +#define MEM_NAME (('M' << 8) | 0x04) +#define MEM_INFO (('M' << 8) | 0x05) + +#define MEM_PAGE_RETIRE (('M' << 8) | 0x02) +#define MEM_PAGE_ISRETIRED (('M' << 8) | 0x03) +#define MEM_PAGE_UNRETIRE (('M' << 8) | 0x06) +#define MEM_PAGE_GETERRORS (('M' << 8) | 0x07) +#define MEM_PAGE_RETIRE_MCE (('M' << 8) | 0x08) +#define MEM_PAGE_RETIRE_UE (('M' << 8) | 0x09) +#define MEM_PAGE_RETIRE_TEST (('M' << 8) | 0x0A) + +#define MEM_SID (('M' << 8) | 0x0B) + +/* + * Bits returned from MEM_PAGE_GETERRORS ioctl for use by fmd(8). + */ +#define MEM_PAGE_ERR_NONE 0x0 +#define MEM_PAGE_ERR_MULTI_CE 0x1 +#define MEM_PAGE_ERR_UE 0x2 +#define MEM_PAGE_ERR_FMA_REQ 0x8 + +#define MEM_FMRI_MAX_BUFSIZE 8192 /* maximum allowed packed FMRI size */ + +typedef struct mem_name { + uint64_t m_addr; /* memory address */ + uint64_t m_synd; /* architecture-specific syndrome */ + uint64_t m_type[2]; /* architecture-specific type */ + caddr_t m_name; /* memory name buffer */ + size_t m_namelen; /* memory name buffer length */ + caddr_t m_sid; /* memory serial id buffer */ + size_t m_sidlen; /* memory serial id buffer length */ +} mem_name_t; + +#if defined(_SYSCALL32) +typedef struct mem_name32 { + uint64_t m_addr; + uint64_t m_synd; + uint64_t m_type[2]; + caddr32_t m_name; + size32_t m_namelen; + caddr32_t m_sid; + size32_t m_sidlen; +} mem_name32_t; +#endif /* _SYSCALL32 */ + +typedef struct mem_info { + uint64_t m_addr; /* memory address */ + uint64_t m_synd; /* architecture-specific syndrome */ + uint64_t m_mem_size; /* total memory size */ + uint64_t m_seg_size; /* segment size */ + uint64_t m_bank_size; /* bank size */ + int m_segments; /* # of segments */ + int m_banks; /* # of banks in segment */ + int m_mcid; /* associated memory controller id */ +} mem_info_t; + +#ifdef _KERNEL + +extern pfn_t impl_obmem_pfnum(pfn_t); + +extern int plat_mem_do_mmio(struct uio *, enum uio_rw); + +typedef struct mm_logentry { + uintptr_t mle_vaddr; /* vaddr being written to */ + size_t mle_len; /* length of write */ + timespec_t mle_hrestime; /* hrestime at time of write */ + hrtime_t mle_hrtime; /* hrtime at time of write */ + pid_t mle_pid; /* pid of writing process */ + char mle_psargs[80]; /* psargs of writing process */ +} mm_logentry_t; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MEM_H */ diff --git a/illumos-x86_64/usr/include/sys/mem_config.h b/illumos-x86_64/usr/include/sys/mem_config.h new file mode 100644 index 00000000..716d2f18 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mem_config.h @@ -0,0 +1,150 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MEM_CONFIG_H +#define _SYS_MEM_CONFIG_H + +/* + * Memory add/delete interfaces. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Memory add/delete client interface. + */ + +extern int kphysm_add_memory_dynamic(pfn_t base, pgcnt_t npgs); + +typedef void *memhandle_t; + +/* + * Managed pages have associated page structures ('page_t's). + * The difference between phys_pages and managed is accounted for by + * boot time memory allocation for the kernel text and data, and also + * for page structures. + */ +typedef struct { + pgcnt_t phys_pages; /* total physical pages */ + pgcnt_t managed; /* providing this many managed pages */ + pgcnt_t nonrelocatable; /* of which this many non-relocatable */ + pfn_t first_nonrelocatable; + pfn_t last_nonrelocatable; +} memquery_t; + +typedef struct { + pgcnt_t phys_pages; /* total physical pages */ + pgcnt_t managed; /* providing this many managed pages */ + pgcnt_t collected; /* done when == managed */ +} memdelstat_t; + +extern int kphysm_del_gethandle(memhandle_t *); + +extern int kphysm_del_span(memhandle_t, pfn_t base, pgcnt_t npgs); + +extern int kphysm_del_span_query(pfn_t base, pgcnt_t npgs, memquery_t *); + +extern int kphysm_del_start(memhandle_t, + void (*complete)(void *, int error), void *arg); + +extern int kphysm_del_release(memhandle_t); + +extern int kphysm_del_cancel(memhandle_t); + +extern int kphysm_del_status(memhandle_t, memdelstat_t *); + +/* + * Error returns. + */ + +#define KPHYSM_OK 0 /* Success */ +#define KPHYSM_ESPAN 1 /* Memory already in use (add) */ +#define KPHYSM_EFAULT 2 /* Memory access test failed (add) */ +#define KPHYSM_ERESOURCE 3 /* Some resource was not available */ +#define KPHYSM_ENOTSUP 4 /* Operation not supported */ +#define KPHYSM_ENOHANDLES 5 /* Cannot allocate any more handles */ +#define KPHYSM_ENONRELOC 6 /* Non-relocatable pages in span */ +#define KPHYSM_EHANDLE 7 /* Bad handle supplied */ +#define KPHYSM_EBUSY 8 /* Memory in span is being deleted */ +#define KPHYSM_ENOTVIABLE 9 /* VM viability test failed */ +#define KPHYSM_ESEQUENCE 10 /* Function called out of sequence */ +#define KPHYSM_ENOWORK 11 /* No pages to delete */ +#define KPHYSM_ECANCELLED 12 /* kphysm_del_cancel (for complete) */ +#define KPHYSM_EREFUSED 13 /* kphysm_pre_del fail (for complete) */ +#define KPHYSM_ENOTFINISHED 14 /* Thread not finished */ +#define KPHYSM_ENOTRUNNING 15 /* Thread not running */ +#define KPHYSM_EDUP 16 /* Memory span duplicate (delete) */ + +/* + * Memory system change call-back interface. + */ + +#define KPHYSM_SETUP_VECTOR_VERSION 1 +typedef struct { + uint_t version; + void (*post_add)(void *arg, pgcnt_t delta_pages); + int (*pre_del)(void *arg, pgcnt_t delta_pages); + void (*post_del)(void *arg, pgcnt_t delta_pages, + int cancelled); +} kphysm_setup_vector_t; + +/* + * The register function returns 0 if the vector/arg pair is recorded + * successfully. + * The error returns are: + * EEXIST if the vector/arg pair is already registered. + * EINVAL if the vector version is not supported. + * ENOMEM if the registration could not be stored. + * + * A return of EEXIST should be considered a program logic error by + * the caller. + */ +extern int kphysm_setup_func_register(kphysm_setup_vector_t *, void *arg); + +extern void kphysm_setup_func_unregister(kphysm_setup_vector_t *, void *arg); + + +/* + * Memory add/delete architecture (lower) interfaces. + * These interfaces should not be used by drivers. + */ + +extern int arch_kphysm_del_span_ok(pfn_t, pgcnt_t); +extern int arch_kphysm_relocate(pfn_t, pgcnt_t); +extern int arch_kphysm_del_supported(void); + +extern int pfn_is_being_deleted(pfn_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MEM_CONFIG_H */ diff --git a/illumos-x86_64/usr/include/sys/memlist.h b/illumos-x86_64/usr/include/sys/memlist.h new file mode 100644 index 00000000..1664c42f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/memlist.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MEMLIST_H +#define _SYS_MEMLIST_H + +/* + * Common memlist format, exported by boot. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Boot programs of version 4 and greater pass a linked list + * of struct memlist to the kernel. + */ +typedef struct memlist { + uint64_t ml_address; /* starting address of memory segment */ + uint64_t ml_size; /* size of same */ + struct memlist *ml_next; /* link to next list element */ + struct memlist *ml_prev; /* link to previous list element */ +} memlist_t; + +extern int address_in_memlist(struct memlist *, uint64_t, size_t); + +/* + * phys_install is the pointer to the physical installed memory list + * which may change when memory is added or deleted. The functions + * memlist_read_lock() and memlist_read_unlock() should be used + * to protect reading this list. + */ +extern struct memlist *phys_install; + +#if defined(__x86) +/* + * bios reserved memory + */ +extern struct memlist *bios_rsvd; +#endif + +extern pgcnt_t num_phys_pages(); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MEMLIST_H */ diff --git a/illumos-x86_64/usr/include/sys/mhd.h b/illumos-x86_64/usr/include/sys/mhd.h new file mode 100644 index 00000000..3d7e0d5d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mhd.h @@ -0,0 +1,159 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MHD_H +#define _SYS_MHD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for multi-host device I/O control commands + */ +#define MHIOC ('M'<<8) +#define MHIOCENFAILFAST (MHIOC|1) +#define MHIOCTKOWN (MHIOC|2) +#define MHIOCRELEASE (MHIOC|3) +#define MHIOCSTATUS (MHIOC|4) +#define MHIOCGRP_INKEYS (MHIOC|5) +#define MHIOCGRP_INRESV (MHIOC|6) +#define MHIOCGRP_REGISTER (MHIOC|7) +#define MHIOCGRP_RESERVE (MHIOC|8) +#define MHIOCGRP_PREEMPTANDABORT (MHIOC|9) +#define MHIOCGRP_PREEMPT (MHIOC|10) +#define MHIOCGRP_CLEAR (MHIOC|11) +#define MHIOCGRP_REGISTERANDIGNOREKEY (MHIOC|14) +#define MHIOCQRESERVE (MHIOC|12) +#define MHIOCREREGISTERDEVID (MHIOC|13) + +/* + * Following is the structure to specify the delay parameters in + * milliseconds, via the MHIOCTKOWN ioctl. + */ +struct mhioctkown { + int reinstate_resv_delay; + int min_ownership_delay; + int max_ownership_delay; +}; + +#define MHIOC_RESV_KEY_SIZE 8 +typedef struct mhioc_resv_key { + uchar_t key[MHIOC_RESV_KEY_SIZE]; +} mhioc_resv_key_t; + +typedef struct mhioc_key_list { + uint32_t listsize; + uint32_t listlen; + mhioc_resv_key_t *list; +} mhioc_key_list_t; + +typedef struct mhioc_inkeys { + uint32_t generation; + mhioc_key_list_t *li; +} mhioc_inkeys_t; + +#if defined(_SYSCALL32) +typedef struct mhioc_key_list32 { + uint32_t listsize; + uint32_t listlen; + caddr32_t list; +} mhioc_key_list32_t; + +typedef struct mhioc_inkeys32 { + uint32_t generation; + caddr32_t li; +} mhioc_inkeys32_t; +#endif + +typedef struct mhioc_resv_desc { + mhioc_resv_key_t key; + uint8_t type; + uint8_t scope; + uint32_t scope_specific_addr; +} mhioc_resv_desc_t; + +typedef struct mhioc_resv_desc_list { + uint32_t listsize; + uint32_t listlen; + mhioc_resv_desc_t *list; +} mhioc_resv_desc_list_t; + +typedef struct mhioc_inresvs { + uint32_t generation; + mhioc_resv_desc_list_t *li; +} mhioc_inresvs_t; + +#if defined(_SYSCALL32) +typedef struct mhioc_resv_desc_list32 { + uint32_t listsize; + uint32_t listlen; + caddr32_t list; +} mhioc_resv_desc_list32_t; + +typedef struct mhioc_inresvs32 { + uint32_t generation; + caddr32_t li; +} mhioc_inresvs32_t; +#endif + +typedef struct mhioc_register { + mhioc_resv_key_t oldkey; + mhioc_resv_key_t newkey; + boolean_t aptpl; /* True if persistent across power failures */ +} mhioc_register_t; + +typedef struct mhioc_preemptandabort { + mhioc_resv_desc_t resvdesc; + mhioc_resv_key_t victim_key; +} mhioc_preemptandabort_t; + +typedef struct mhioc_registerandignorekey { + mhioc_resv_key_t newkey; + boolean_t aptpl; /* True if persistent across power failures */ +} mhioc_registerandignorekey_t; + +/* + * SCSI-3 PGR Reservation Type Codes. Codes with the _OBSOLETE suffix + * have been removed from the SCSI3 PGR standard. + */ +#define SCSI3_RESV_READSHARED_OBSOLETE 0 +#define SCSI3_RESV_WRITEEXCLUSIVE 1 +#define SCSI3_RESV_READEXCLUSIVE_OBSOLETE 2 +#define SCSI3_RESV_EXCLUSIVEACCESS 3 +#define SCSI3_RESV_SHAREDACCESS_OBSOLETE 4 +#define SCSI3_RESV_WRITEEXCLUSIVEREGISTRANTSONLY 5 +#define SCSI3_RESV_EXCLUSIVEACCESSREGISTRANTSONLY 6 + +#define SCSI3_SCOPE_LOGICALUNIT 0 +#define SCSI3_SCOPE_EXTENT_OBSOLETE 1 +#define SCSI3_SCOPE_ELEMENT 2 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MHD_H */ diff --git a/illumos-x86_64/usr/include/sys/mii.h b/illumos-x86_64/usr/include/sys/mii.h new file mode 100644 index 00000000..c3941aff --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mii.h @@ -0,0 +1,517 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * mii.h + * Generic MII/PHY Support for MAC drivers. + */ + +#ifndef _SYS_MII_H +#define _SYS_MII_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NOTES + * + * The device driver is required to protect its own registers. The + * MII common code will call MII entry points asynchronously, from a + * taskq, and holds an internal lock across such calls (except the + * notify entry point). Therefore, device drivers MUST NOT hold any + * locks across calls into the MII framework. + * + * If a device must be suspended (e.g. due to DDI_SUSPEND) the MII + * layer can be suspended by calling mii_stop(). After this point, + * the monitoring task will be suspended and the driver can be assured + * that MII will not interfere until restarted with mii_start(). + * + * Note that monitoring is not started until mii_start() is called. + * The mii_start() function may be called multiple times. It performs + * an implicit reset of the MII bus and PHY. + * + * Once started, if not already done, a probe of the MII bus is done to + * find a suitable PHY. If no PHY is found, then you won't have any + * link! Once a suitable PHY is selected, any other PHYs are isolated and + * powered down. The device driver can cause MII to re-probe the bus for + * changes to the available PHYs by calling mii_probe(). Note that this + * will also cause a full reset of all PHYs. + * + * The mii_reset entry point, which is optional, is used to notify the + * driver when the MII layer has reset the device. This can allow + * certain drivers the opportunity to "fix up" things after reset. + * Note however, that when possible, it is better if the logic is + * encoded into a vendor specific PHY module. + */ + +#ifdef _KERNEL + +typedef struct mii_handle *mii_handle_t; +typedef struct mii_ops mii_ops_t; + +struct mii_ops { + int mii_version; + uint16_t (*mii_read)(void *, uint8_t, uint8_t); + void (*mii_write)(void *, uint8_t, uint8_t, uint16_t); + void (*mii_notify)(void *, link_state_t); + void (*mii_reset)(void *); +}; +#define MII_OPS_VERSION 0 + +/* + * Support routines. + */ + +/* + * mii_alloc + * + * Allocate an MII handle. Called during driver's attach(9e) + * handling, this routine is valid in kernel context only. + * + * Arguments + * + * private A private state structure, provided back to + * entry points. + * dip The dev_info node for the MAC driver. + * ops Entry points into the MAC driver. + * + * Returns + * Handle to MII bus on success, NULL on failure. + */ +mii_handle_t mii_alloc(void *private, dev_info_t *dip, mii_ops_t *ops); + +/* + * mii_alloc + * + * Allocate an MII handle. Called during driver's attach(9e) + * handling, this routine is valid in kernel context only. This + * routine is an alternative to mii_alloc() for use when the + * instance number (PPA) is not the same as the devinfo instance + * number, and hence needs to be overridden. + * + * Arguments + * + * private A private state structure, provided back to + * entry points. + * dip The dev_info node for the MAC driver. + * instance The instance (PPA) of the interface. + * ops Entry points into the MAC driver. + * + * Returns + * Handle to MII bus on success, NULL on failure. + */ +mii_handle_t mii_alloc_instance(void *private, dev_info_t *dip, int instance, + mii_ops_t *ops); + +/* + * mii_free + * + * Free an MII handle and associated resources. Call from + * detach(9e) handling, this routine is valid in kernel context + * only. + */ +void mii_free(mii_handle_t mii); + +/* + * mii_set_pauseable + * + * Lets the MII know if the MAC layer can support pause or + * asymetric pause capabilities. The MII layer will use this to + * determine what capabilities should be negotiated for (along + * with user preferences, of course.) If not called, the MII + * will assume the device has no support for flow control. + * + * Arguments + * + * mii MII handle. + * cap B_TRUE if the device supports symmetric of pause. + * asym B_TRUE if the device supports asymmetric pause. + */ +void mii_set_pauseable(mii_handle_t mii, boolean_t cap, boolean_t asym); + +/* + * mii_reset + * + * Schedules a reset of the MII bus. Normally not needed, but + * can be used to perform a full master reset, including + * rescanning for PHYs. This function may be called in any + * context except high level interrupt context, but must be + * called without any locks held. The reset will probably not + * be complete until sometime after the call returns. + * + * Note that if mii_start has not been called, then the reset + * will not be performed until _after_ the MII is started. + */ +void mii_reset(mii_handle_t mii); + + +/* + * mii_start + * + * Starts monitoring of the MII bus. Normally this is called as + * a result of a driver's mac_start() entry point, but it may also + * be called when a PHY needs to be reset or during handling of + * DDI_RESUME. This function may be called in any context except + * high level interrupt context, but + * must be called without any locks held. + */ +void mii_start(mii_handle_t mii); + +/* + * mii_stop + * + * Stops monitoring of the MII bus. Normally this is called as a + * result of a driver's mac_stop() entry point. As a side + * effect, also isolates and powers down any active PHY. On + * return, the MII layer is guaranteed not to be executing any + * code in the MII entry points. This function may be called in + * any context except high level interrupt context, but must be + * called without any locks held. + */ +void mii_stop(mii_handle_t mii); + +/* + * mii_resume + * + * Starts monitoring of the MII bus. Normally this is called as + * a part of a driver's DDI_RESUME handling. This function may + * be called in any context except high level interrupt context, + * but must be called without any locks held. + */ +void mii_resume(mii_handle_t mii); + +/* + * mii_suspend + * + * Suspends monitoring of the MII bus. Normally this is called + * as a part of a driver's DDI_SUSPEND handling. On return, the + * MII layer is guaranteed not to be executing any code in the + * MII entry points. This function may be called in any context + * except high level interrupt context, but must be called + * without any locks held. + */ +void mii_suspend(mii_handle_t mii); + +/* + * mii_probe + * + * Used to reset the entire MII bus and probe for PHYs. This + * routine should be called if the driver has reason to believe that + * PHYs have changed. This is implicitly executed the first time + * monitoring is started on the MII bus, and normally need not be + * explicitly called. This function may be called in any context + * except high level interrupt context, but must be called + * without any locks held. + */ +void mii_probe(mii_handle_t mii); + +/* + * mii_check + * + * Used to alert the MII layer that it should check for changes. + * This can be called by drivers in response to link status + * interrupts, for example, giving a quicker response to link + * status changes without waiting for the MII timer to expire. + * This function may be called in any context except high level + * interrupt context, but must be called without any locks held. + */ +void mii_check(mii_handle_t mii); + +/* + * mii_get_addr + * + * Used to get the PHY address that is currently active for the MII + * bus. This function may be called in any context. + * + * Returns + * + * The PHY address (0-31) if a PHY is active on the MII bus. If + * no PHY is active, -1 is returned. + */ +int mii_get_addr(mii_handle_t mii); + +/* + * mii_get_id + * + * Used to get the identifier of the active PHY. This function + * may be called in any context. + * + * Returns + * + * The PHY identifier register contents, encoded with the high + * order (PHYIDH) bits in the upper word and the low order bits + * in the lower word. If no PHY is active, the value -1 will be + * returned. + */ +uint32_t mii_get_id(mii_handle_t mii); + +/* + * mii_get_speed + * + * Used to get the speed of the active PHY. This function may be + * called in any context. + * + * Returns + * + * The speed, in Mbps, if the active PHY has link (10, 100, or 1000), + * otherwise 0. + */ +int mii_get_speed(mii_handle_t mii); + +/* + * mii_get_duplex + * + * Used to get the duplex of the active PHY. This function may + * be called in any context. + * + * Returns + * + * The duplex, if the active PHY has link (LINK_DUPLEX_FULL or + * LINK_DUPLEX_HALF), otherwise LINK_DUPLEX_UNKNOWN. + */ +link_duplex_t mii_get_duplex(mii_handle_t mii); + +/* + * mii_get_state + * + * Used to get the state of the link on the active PHY. This + * function may be called in any context. + * + * Returns + * + * The link state (LINK_STATE_UP or LINK_STATE_DOWN), if known, + * otherwise LINK_STATE_UNKNOWN. + */ +link_state_t mii_get_state(mii_handle_t mii); + +/* + * mii_get_flowctrl + * + * Used to get the state of the negotiated flow control on the + * active PHY. This function may be called in any context. + * + * Returns + * + * The flowctrl state (LINK_FLOWCTRL_NONE, LINK_FLOWCTRL_RX, + * LINK_FLOWCTRL_TX, or LINK_FLOWCTRL_BI. + */ +link_flowctrl_t mii_get_flowctrl(mii_handle_t mii); + +/* + * mii_get_loopmodes + * + * This function is used to support the LB_GET_INFO_SIZE and + * LB_GET_INFO ioctls. It probably should not be used outside of + * that context. The modes supplied are supported by the MII/PHY. + * Drivers may wish to add modes for MAC internal loopbacks as well. + * See for more information. + * + * Note that the first item in the modes array will always be the + * mode to disable the MII/PHY loopback, and will have the value + * MII_LOOPBACK_NONE. + * + * Arguments + * + * mii MII handle. + * modes Location to receive an array of loopback modes. + * Drivers should ensure that enough room is available. + * There will never be more than MII_LOOPBACK_MAX modes + * returned. May be NULL, in which case no data will + * be returned to the caller. + * + * Returns + * + * Count of number of modes available, in no case larger than + * MII_LOOPBACK_MAX. + */ +int mii_get_loopmodes(mii_handle_t mii, lb_property_t *modes); + +#define MII_LOOPBACK_MAX 16 +#define MII_LOOPBACK_NONE 0 + +/* + * mii_set_loopback + * + * Sets the loopback mode, intended for use in support of the + * LB_SET_MODE ioctl. The mode value will be one of the values + * returned in the modes array (see mii_get_loopmodes), or the + * special value MII_LOOPBACK_NONE to return to normal operation. + * + * Arguments + * + * mii MII handle. + * mode New loopback mode number; MII_LOOPBACK_NONE indicates + * a return to normal operation. + * + * Returns + * + * Zero on success, or EINVAL if the mode is invalid or unsupported. + */ +int mii_set_loopback(mii_handle_t mii, uint32_t mode); + +/* + * mii_get_loopback + * + * Queries the loopback mode, intended for use in support of the + * LB_GET_MODE ioctl, but may be useful in programming device + * settings that are sensitive to loopback setting. + * + * Returns + * + * The current mode number (one of the reported by + * mii_get_loopmodes), or the special value MII_LOOPBACK_NONE + * indicating that loopback is not in use. + */ +uint32_t mii_get_loopback(mii_handle_t mii); + +/* + * mii_m_loop_ioctl + * + * Used to support the driver's mc_ioctl() for loopback ioctls. + * If the driver is going to use the loopback optons from the + * PHY, and isn't adding any MAC level loopback, then this function + * can handle the entire set of ioctls, removing yet more code from + * the driver. Ultimately, this is a very reasonable thing to do, + * since the PHY level loopback should exercise all of the same + * MAC level circuitry that a MAC internal loopback would do. + * + * Arguments + * + * mii MII handle. + * wq The write queue supplied to mc_ioctl(). + * msg The mblk from the mc_ioctl (contains an iocblk). + * + * Returns + * + * B_TRUE if the ioctl was handled by the driver. + * B_FALSE if the ioctl was not handled, and may need to be + * handled by the driver. + */ +boolean_t mii_m_loop_ioctl(mii_handle_t mii, queue_t *wq, mblk_t *msg); + +/* + * mii_m_getprop + * + * Used to support the driver's mc_getprop() mac callback, + * and only to be called from that function (and without any + * locks held). This routine will process all of the properties + * that are relevant to MII on behalf of the driver. + * + * Arguments + * + * mii MII handle. + * name Property name. + * id Property ID. + * sz Size of property in bytes. + * val Location to receive property value. + * + * Returns + * + * 0 on successful handling of property. + * EINVAL if invalid arguments (e.g. a bad size) are supplied. + * ENOTSUP if the prooperty is not supported by MII or the PHY. + */ +int mii_m_getprop(mii_handle_t mii, const char *name, mac_prop_id_t id, + uint_t sz, void *val); + +/* + * mii_m_setprop + * + * Used to support the driver's mc_setprop() mac callback, + * and only to be called from that function (and without any + * locks held). This routine will process all of the properties + * that are relevant to MII on behalf of the driver. This will + * often result in the PHY being reset. + * + * Arguments + * + * mii MII handle. + * name Property name. + * id Property ID. + * sz Size of property in bytes. + * val Location of property value. + * + * Returns + * + * 0 on successful handling of property. + * EINVAL if invalid arguments (e.g. a bad size) are supplied. + * ENOTSUP if the prooperty is not supported by MII or the PHY, + * or if the property is read-only. + */ +int mii_m_setprop(mii_handle_t mii, const char *name, mac_prop_id_t id, + uint_t sz, const void *val); + +/* + * mii_m_propinfo + * + * Used to support the driver's mc_setprop() mac callback, + * and only to be called from that function (and without any + * locks held). + * + * Arguments + * + * mii MII handle. + * name Property name. + * id Property ID. + * prh Property info handle. + * + */ +void mii_m_propinfo(mii_handle_t mii, const char *name, mac_prop_id_t id, + mac_prop_info_handle_t prh); + + +/* + * mii_m_getstat + * + * Used to support the driver's mc_getstat() mac callback for + * statistic collection, and only to be called from that function + * (without any locks held). This routine will process all of + * the statistics that are relevant to MII on behalf of the + * driver. + * + * Arguments + * + * mii MII handle. + * stat Statistic number. + * val Location to receive statistic value. + * + * Returns + * + * 0 on successful handling of statistic. + * ENOTSUP if the statistic is not supported by MII. + */ +int mii_m_getstat(mii_handle_t mii, uint_t stat, uint64_t *val); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MII_H */ diff --git a/illumos-x86_64/usr/include/sys/miiregs.h b/illumos-x86_64/usr/include/sys/miiregs.h new file mode 100644 index 00000000..d93aa861 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/miiregs.h @@ -0,0 +1,233 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Definitions for MII registers from 802.3u and vendor documentation + */ + +#ifndef _SYS_MIIREGS_H +#define _SYS_MIIREGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Register addresses: Section 22.2.4 */ +#define MII_CONTROL 0 +#define MII_STATUS 1 +#define MII_PHYIDH 2 +#define MII_PHYIDL 3 +#define MII_AN_ADVERT 4 /* Auto negotiation advertisement. */ +#define MII_AN_LPABLE 5 /* Auto neg. Link Partner Ability */ +#define MII_AN_EXPANSION 6 /* Auto neg. Expansion. */ +#define MII_AN_NXTPGXMIT 7 /* Auto neg. Next Page Transmit */ +#define MII_AN_NXTPGLP 8 /* Link Part. Augo neg. Next Page */ +#define MII_MSCONTROL 9 /* 100Base-T2 and 1000 BaseT Ctrl. */ +#define MII_MSSTATUS 10 /* 100Base-T2 and 1000 BaseT Stat. */ +#define MII_EXTSTATUS 15 /* Extended status registers */ +#define MII_VENDOR(x) (16+(x)) /* Vendor specific */ + +/* Control register: 22.2.4.1, 28.2.4.1.1 */ +#define MII_CONTROL_RESET (1<<15) +#define MII_CONTROL_LOOPBACK (1<<14) +#define MII_CONTROL_100MB (1<<13) +#define MII_CONTROL_ANE (1<<12) +#define MII_CONTROL_PWRDN (1<<11) +#define MII_CONTROL_ISOLATE (1<<10) +#define MII_CONTROL_RSAN (1<<9) +#define MII_CONTROL_FDUPLEX (1<<8) +#define MII_CONTROL_COLTST (1<<7) +#define MII_CONTROL_1GB (1<<6) +#define MII_CONTROL_UNIDIR (1<<5) + +/* Status register: 22.2.4.2, 28.2.4.1.2 */ +#define MII_STATUS_100_BASE_T4 (1<<15) +#define MII_STATUS_100_BASEX_FD (1<<14) +#define MII_STATUS_100_BASEX (1<<13) +#define MII_STATUS_10_FD (1<<12) +#define MII_STATUS_10 (1<<11) +#define MII_STATUS_100T2_FD (1<<10) +#define MII_STATUS_100T2 (1<<9) +#define MII_STATUS_EXTSTAT (1<<8) +#define MII_STATUS_UNIDIR (1<<7) +#define MII_STATUS_MFPRMBLSUPR (1<<6) +#define MII_STATUS_ANDONE (1<<5) +#define MII_STATUS_REMFAULT (1<<4) +#define MII_STATUS_CANAUTONEG (1<<3) +#define MII_STATUS_LINKUP (1<<2) +#define MII_STATUS_JABBERING (1<<1) +#define MII_STATUS_EXTENDED (1<<0) + +/* Advertisement/Partner ability registers: 28.2.4.1.3/4 */ +#define MII_AN_ADVERT_NP (1<<15) +#define MII_AN_ADVERT_ACK (1<<14) +#define MII_AN_ADVERT_REMFAULT (1<<13) +#define MII_AN_ADVERT_EXTNP (1<<12) +#define MII_AN_ADVERT_TECHABLE (0x7f<<5) +#define MII_AN_ADVERT_SELECTOR (0x1f) +#define MII_AN_SELECTOR_8023 0x0001 + +/* Technology field bits (above). From Annex 28B */ +#define MII_ABILITY_10BASE_T (1<<5) +#define MII_ABILITY_10BASE_T_FD (1<<6) +#define MII_ABILITY_100BASE_TX (1<<7) +#define MII_ABILITY_100BASE_TX_FD (1<<8) +#define MII_ABILITY_100BASE_T4 (1<<9) +#define MII_ABILITY_PAUSE (1<<10) +#define MII_ABILITY_ASMPAUSE (1<<11) +/* Override fields for 1000 Base-X: 37.2.5.1.3 */ +#define MII_ABILITY_X_FD (1<<5) +#define MII_ABILITY_X_HD (1<<6) +#define MII_ABILITY_X_PAUSE (1<<7) +#define MII_ABILITY_X_ASMPAUSE (1<<8) +/* Override fields for 100 Base T2: 32.5.4.2 */ +#define MII_ABILITY_T2_FD (1<<11) +#define MII_ABILITY_T2_HD (1<<10) + +/* Expansion register 28.2.4.1.5 */ +#define MII_AN_EXP_PARFAULT (1<<4) /* fault detected */ +#define MII_AN_EXP_LPCANNXTP (1<<3) /* Link partner is Next Page able */ +#define MII_AN_EXP_CANNXTPP (1<<2) /* Local is next page able */ +#define MII_AN_EXP_PAGERCVD (1<<1) /* A new page has been recvd. */ +#define MII_AN_EXP_LPCANAN (1<<0) /* LP can auto-negotiate */ + +/* Master/Slave control: 40.5.1.1 */ +#define MII_MSCONTROL_TEST_MASK (3<<13) +#define MII_MSCONTROL_MANUAL (1<<12) /* manual master/slave control */ +#define MII_MSCONTROL_MASTER (1<<11) +#define MII_MSCONTROL_MULTIPORT (1<<10) /* DCE, default 0 for NICs */ +#define MII_MSCONTROL_1000T_FD (1<<9) +#define MII_MSCONTROL_1000T (1<<8) + +/* Master/Slave status: 40.5.1.1 */ +#define MII_MSSTATUS_FAULT (1<<15) /* Master/slave config fault */ +#define MII_MSSTATUS_MASTER (1<<14) /* Master/slave config result */ +#define MII_MSSTATUS_RXSTAT (1<<13) +#define MII_MSSTATUS_REMRXSTAT (1<<12) +#define MII_MSSTATUS_LP1000T_FD (1<<11) +#define MII_MSSTATUS_LP1000T (1<<10) +#define MII_MSSTATUS_IDLE_ERR (0xff) + +/* Extended status: 22.2.4.4 */ +#define MII_EXTSTATUS_1000X_FD (1<<15) +#define MII_EXTSTATUS_1000X (1<<14) +#define MII_EXTSTATUS_1000T_FD (1<<13) +#define MII_EXTSTATUS_1000T (1<<12) + +/* + * Truncated OUIs as found in the PHY Identifier ( 22.2.4.3.1 ), + * and known models (and their registers) from those manufacturers + */ + +#define MII_PHY_MFG(x) (((x) >> 10) & 0x3fffff) /* 22 bits, 10-31 */ +#define MII_PHY_MODEL(x) (((x) >> 4) & 0x3f) /* 6 bits,4-9 */ +#define MII_PHY_REV(x) ((x) & 0xf) /* 4 bits, 0-3 */ + +/* + * PHY manufacturer OUIs + */ +#define MII_OUI_ALTIMA 0x000895 +#define MII_OUI_AMD 0x00001a +#define MII_OUI_AMD_2 0x000058 +#define MII_OUI_ATTANSIC 0x001374 +#define MII_OUI_BROADCOM 0x001018 +#define MII_OUI_BROADCOM_2 0x000818 +#define MII_OUI_CICADA 0x0003f1 +#define MII_OUI_CICADA_2 0x00c08f +#define MII_OUI_DAVICOM 0x00606e +#define MII_OUI_DAVICOM_2 0x000676 +#define MII_OUI_ICS 0x00057d +#define MII_OUI_ICPLUS 0x0090c3 +#define MII_OUI_INTEL 0x00aa00 +#define MII_OUI_INTEL_2 0x001f00 +#define MII_OUI_LUCENT 0x00601d +#define MII_OUI_MARVELL 0x005043 +#define MII_OUI_NATIONAL_SEMI 0x080017 +#define MII_OUI_NATIONAL_SEMI_2 0x1000e8 +#define MII_OUI_QUALITY_SEMI 0x006051 +#define MII_OUI_QUALITY_SEMI_2 0x00608a + +/* + * PHY models + */ +#define MII_MODEL_ALTIMA_AC101 0x21 /* also Am79C874 */ +#define MII_MODEL_ALTIMA_AC101L 0x12 +#define MII_MODEL_ALTIMA_AM79C875 0x14 + +#define MII_MODEL_AMD_AM79C901 0x37 +#define MII_MODEL_AMD_AM79C972 0x01 +#define MII_MODEL_AMD_AM79C973 0x36 + +#define MII_MODEL_CICADA_CS8201 0x01 +#define MII_MODEL_CICADA_CS8201A 0x20 +#define MII_MODEL_CICADA_CS8201B 0x21 + +#define MII_MODEL_DAVICOM_DM9101 0x00 +#define MII_MODEL_DAVICOM_DM9102 0x04 +#define MII_MODEL_DAVICOM_DM9161 0x08 + +#define MII_MODEL_ICPLUS_IP101 0x05 + +#define MII_MODEL_ICS_ICS1889 0x01 +#define MII_MODEL_ICS_ICS1890 0x02 +#define MII_MODEL_ICS_ICS1892 0x03 +#define MII_MODEL_ICS_ICS1893 0x04 + +#define MII_MODEL_INTEL_82553_CSTEP 0x35 +#define MII_MODEL_INTEL_82555 0x15 +#define MII_MODEL_INTEL_82562_EH 0x33 +#define MII_MODEL_INTEL_82562_EM 0x31 +#define MII_MODEL_INTEL_82562_ET 0x32 + +#define MII_MODEL_LUCENT_LU6612 0x0c + +#define MII_MODEL_MARVELL_88E1000 0x00 +#define MII_MODEL_MARVELL_88E1011 0x02 +#define MII_MODEL_MARVELL_88E1000_2 0x03 +#define MII_MODEL_MARVELL_88E1000S 0x04 +#define MII_MODEL_MARVELL_88E1000_3 0x05 +#define MII_MODEL_MARVELL_88E3082 0x08 /* 10/100 */ +#define MII_MODEL_MARVELL_88E1112 0x09 +#define MII_MODEL_MARVELL_88E1149 0x0b +#define MII_MODEL_MARVELL_88E1111 0x0c +#define MII_MODEL_MARVELL_88E1116 0x21 +#define MII_MODEL_MARVELL_88E1118 0x22 +#define MII_MODEL_MARVELL_88E1116R 0x24 +#define MII_MODEL_MARVELL_88E3016 0x26 /* 10/100 */ + +#define MII_MODEL_NATIONAL_SEMI_DP83840 0x00 +#define MII_MODEL_NATIONAL_SEMI_DP83843 0x01 +#define MII_MODEL_NATIONAL_SEMI_DP83815 0x02 +#define MII_MODEL_NATIONAL_SEMI_DP83847 0x03 +#define MII_MODEL_NATIONAL_SEMI_DP83891 0x05 +#define MII_MODEL_NATIONAL_SEMI_DP83861 0x06 + +#define MII_MODEL_QUALITY_SEMI_QS6612 0x00 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MIIREGS_H */ diff --git a/illumos-x86_64/usr/include/sys/mkdev.h b/illumos-x86_64/usr/include/sys/mkdev.h new file mode 100644 index 00000000..d02fcad2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mkdev.h @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_MKDEV_H +#define _SYS_MKDEV_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SVR3/Pre-EFT device number constants. + */ +#define ONBITSMAJOR 7 /* # of SVR3 major device bits */ +#define ONBITSMINOR 8 /* # of SVR3 minor device bits */ +#define OMAXMAJ 0x7f /* SVR3 max major value */ +#define OMAXMIN 0xff /* SVR3 max major value */ + +/* + * 32-bit Solaris device major/minor sizes. + */ +#define NBITSMAJOR32 14 +#define NBITSMINOR32 18 +#define MAXMAJ32 0x3ffful /* SVR4 max major value */ +#define MAXMIN32 0x3fffful /* SVR4 max minor value */ + +#define NBITSMAJOR64 32 /* # of major device bits in 64-bit Solaris */ +#define NBITSMINOR64 32 /* # of minor device bits in 64-bit Solaris */ + +#ifdef _LP64 + +#define MAXMAJ64 0xfffffffful /* max major value */ +#define MAXMIN64 0xfffffffful /* max minor value */ + +#define NBITSMAJOR NBITSMAJOR64 +#define NBITSMINOR NBITSMINOR64 +#define MAXMAJ MAXMAJ64 +#define MAXMIN MAXMIN64 + +#else /* !_LP64 */ + +#define NBITSMAJOR NBITSMAJOR32 +#define NBITSMINOR NBITSMINOR32 +#define MAXMAJ MAXMAJ32 +#define MAXMIN MAXMIN32 + +#endif /* !_LP64 */ + +#if !defined(_KERNEL) + +/* + * Undefine sysmacros.h device macros. + */ +#undef makedev +#undef major +#undef minor + +extern dev_t makedev(const major_t, const minor_t); +extern major_t major(const dev_t); +extern minor_t minor(const dev_t); +extern dev_t __makedev(const int, const major_t, const minor_t); +extern major_t __major(const int, const dev_t); +extern minor_t __minor(const int, const dev_t); + +#define OLDDEV 0 /* old device format */ +#define NEWDEV 1 /* new device format */ +#define COMPATDEV 2 /* 32-bit compat format */ + +#define makedev(maj, min) (__makedev(NEWDEV, maj, min)) +#define major(dev) (__major(NEWDEV, dev)) +#define minor(dev) (__minor(NEWDEV, dev)) + +#endif /* !defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MKDEV_H */ diff --git a/illumos-x86_64/usr/include/sys/mman.h b/illumos-x86_64/usr/include/sys/mman.h new file mode 100644 index 00000000..6906cb3d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mman.h @@ -0,0 +1,442 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved. */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. All rights reserved. + * Copyright 2022 Oxide Computer Company + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_MMAN_H +#define _SYS_MMAN_H + +#include + +/* + * has had a bit of a tortured symbol visibility history. In + * particular, when things were honored under __EXTENSIONS__ or not in the past + * wasn't very consistent. As this was not a header that was part of ISO-C it + * traditionally just checked around XOPEN/POSIX related feature tests. This + * makes the use of the standard _STRICT_POSIX something that actually is more + * restrictive than previously was used. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_ASM) && !defined(_KERNEL) +#include +#endif /* !_ASM && !_KERNEL */ + +/* + * Protections are chosen from these bits, or-ed together. + * Note - not all implementations literally provide all possible + * combinations. PROT_WRITE is often implemented as (PROT_READ | + * PROT_WRITE) and (PROT_EXECUTE as PROT_READ | PROT_EXECUTE). + * However, no implementation will permit a write to succeed + * where PROT_WRITE has not been set. Also, no implementation will + * allow any access to succeed where prot is specified as PROT_NONE. + */ +#define PROT_READ 0x1 /* pages can be read */ +#define PROT_WRITE 0x2 /* pages can be written */ +#define PROT_EXEC 0x4 /* pages can be executed */ + +#ifdef _KERNEL +#define PROT_USER 0x8 /* pages are user accessible */ +#define PROT_ZFOD (PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER) +#define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER) +#endif /* _KERNEL */ + +#define PROT_NONE 0x0 /* pages cannot be accessed */ + +/* sharing types: must choose either SHARED or PRIVATE */ +#define MAP_SHARED 1 /* share changes */ +#define MAP_PRIVATE 2 /* changes are private */ +#define MAP_TYPE 0xf /* mask for share type */ + +/* other flags to mmap (or-ed in to MAP_SHARED or MAP_PRIVATE) */ +#define MAP_FILE 0 /* map from file (default) */ +#define MAP_FIXED 0x10 /* user assigns address */ +/* Not implemented */ +#define MAP_RENAME 0x20 /* rename private pages to file */ +#define MAP_NORESERVE 0x40 /* don't reserve needed swap area */ +/* Note that 0x80 is _MAP_LOW32, defined below */ +#define MAP_ANON 0x100 /* map anonymous pages directly */ +#define MAP_ANONYMOUS MAP_ANON /* (source compatibility) */ +#define MAP_ALIGN 0x200 /* addr specifies alignment */ +#define MAP_TEXT 0x400 /* map code segment */ +#define MAP_INITDATA 0x800 /* map data segment */ + +/* + * Internal to the kernel, extensions to mmap flags. + */ +#ifdef _KERNEL +#define _MAP_TEXTREPL 0x1000 +#define _MAP_RANDOMIZE 0x2000 +#endif /* _KERNEL */ + +/* + * Extensions to mmap flags. These are available in the default compilation + * environment, but not in a strict environment. + */ +#if !defined(_STRICT_POSIX) +#define _MAP_LOW32 0x80 /* force mapping in lower 4G of address space */ +#define MAP_32BIT _MAP_LOW32 + +/* + * For the sake of backward object compatibility, we use the _MAP_NEW flag. + * This flag will be automatically or'ed in by the C library for all + * new mmap calls. Previous binaries with old mmap calls will continue + * to get 0 or -1 for return values. New mmap calls will get the mapped + * address as the return value if successful and -1 on errors. By default, + * new mmap calls automatically have the kernel assign the map address + * unless the MAP_FIXED flag is given. + */ +#define _MAP_NEW 0x80000000 /* users should not need to use this */ +#endif /* !defined(_STRICT_POSIX) */ + +#if !defined(_STRICT_POSIX) +/* External flags for mmapobj syscall (Exclusive of MAP_* flags above) */ +#define MMOBJ_PADDING 0x10000 +#define MMOBJ_INTERPRET 0x20000 + +#define MMOBJ_ALL_FLAGS (MMOBJ_PADDING | MMOBJ_INTERPRET) + +/* + * Values for mr_flags field of mmapobj_result_t below. + * The bottom 16 bits are mutually exclusive and thus only one + * of them can be set at a time. Use MR_GET_TYPE below to check this value. + * The top 16 bits are used for flags which are not mutually exclusive and + * thus more than one of these flags can be set for a given mmapobj_result_t. + * + * MR_PADDING being set indicates that this memory range represents the user + * requested padding. + * + * MR_HDR_ELF being set indicates that the ELF header of the mapped object + * is mapped at mr_addr + mr_offset. + */ + +/* + * External flags for mr_flags field below. + */ +#define MR_PADDING 0x1 +#define MR_HDR_ELF 0x2 + +/* + * Internal flags for mr_flags field below. + */ +#ifdef _KERNEL +#define MR_RESV 0x80000000 /* overmapped /dev/null */ +#endif /* _KERNEL */ + +#define MR_TYPE_MASK 0x0000ffff +#define MR_GET_TYPE(val) ((val) & MR_TYPE_MASK) + +#if !defined(_ASM) +typedef struct mmapobj_result { + caddr_t mr_addr; /* mapping address */ + size_t mr_msize; /* mapping size */ + size_t mr_fsize; /* file size */ + size_t mr_offset; /* offset into file */ + uint_t mr_prot; /* the protections provided */ + uint_t mr_flags; /* info on the mapping */ +} mmapobj_result_t; + +#if defined(_KERNEL) || defined(_SYSCALL32) +typedef struct mmapobj_result32 { + caddr32_t mr_addr; /* mapping address */ + size32_t mr_msize; /* mapping size */ + size32_t mr_fsize; /* file size */ + size32_t mr_offset; /* offset into file */ + uint_t mr_prot; /* the protections provided */ + uint_t mr_flags; /* info on the mapping */ +} mmapobj_result32_t; +#endif /* defined(_KERNEL) || defined(_SYSCALL32) */ +#endif /* !defined(_ASM) */ +#endif /* !defined(_STRICT_POSIX) */ + +#if !defined(_ASM) && !defined(_KERNEL) +/* + * large file compilation environment setup + * + * In the LP64 compilation environment, map large file interfaces + * back to native versions where possible. + */ + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname mmap mmap64 +#else +#define mmap mmap64 +#endif +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname mmap64 mmap +#else +#define mmap64 mmap +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getpagesizes getpagesizes2 +#else +#define getpagesizes getpagesizes2 +#endif + +/* + * Except for old binaries mmap() will return the resultant address of mapping + * on success and (void *)-1 on error. illumos traditionally used a 'caddr_t' + * instead of a void * and did not require certain addresses to be const. + * + * Note, the following group of symbols are always visible since we have always + * exposed them and they appear to have been defined in most relevant versions + * of the specifications. While these are not strictly defined in ISO C, this + * header isn't a part of it and it isn't our job to guard against that. + */ +extern void *mmap(void *, size_t, int, int, int, off_t); +extern int munmap(void *, size_t); +extern int mprotect(void *, size_t, int); +extern int msync(void *, size_t, int); + +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern void *mmap64(void *, size_t, int, int, int, off64_t); +#endif /* _LARGEFILE64_SOURCE... */ + +/* + * These functions were all part of the older POSIX realtime suite and didn't + * make it into XPG until v5. + */ + +#if !defined(_STRICT_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG5) +extern int mlock(const void *, size_t); +extern int munlock(const void *, size_t); +extern int mlockall(int); +extern int munlockall(void); +extern int shm_open(const char *, int, mode_t); +extern int shm_unlink(const char *); +#endif /* !_STRICT_POSIX || _POSIX_C_SOURCE > 2 || _XPG5 */ + +#if !defined(_STRICT_POSIX) || defined(_XPG6) +extern int posix_madvise(void *, size_t, int); +#endif + +/* + * The following are extensions that we have added. + */ +#if !defined(_STRICT_POSIX) +extern int mincore(caddr_t, size_t, char *); +extern int memcntl(void *, size_t, int, void *, int, int); +extern int madvise(void *, size_t, int); +extern int getpagesizes(size_t *, int); +extern int getpagesizes2(size_t *, int); +extern int mmapobj(int, uint_t, mmapobj_result_t *, uint_t *, void *); +/* guard visibility of uint64_t */ +#if defined(_INT64_TYPE) +extern int meminfo(const uint64_t *, int, const uint_t *, int, uint64_t *, + uint_t *); +#endif /* defined(_INT64_TYPE) */ +#endif /* !defined(_STRICT_POSIX) */ + + +/* mmap failure value */ +#define MAP_FAILED ((void *) -1) + +#endif /* !_ASM && !_KERNEL */ + +#if !defined(_STRICT_POSIX) +#if !defined(_ASM) +/* + * structure for memcntl hat advise operations. + */ +struct memcntl_mha { + uint_t mha_cmd; /* command(s) */ + uint_t mha_flags; + size_t mha_pagesize; +}; + +#if defined(_SYSCALL32) +struct memcntl_mha32 { + uint_t mha_cmd; /* command(s) */ + uint_t mha_flags; + size32_t mha_pagesize; +}; +#endif /* _SYSCALL32 */ +#endif /* !defined(_ASM) */ + +/* + * advice to madvise + * + * Note, if more than 4 bits worth of advice (eg. 16) are specified then + * changes will be necessary to the struct vpage. + */ +#define MADV_NORMAL 0 /* no further special treatment */ +#define MADV_RANDOM 1 /* expect random page references */ +#define MADV_SEQUENTIAL 2 /* expect sequential page references */ +#define MADV_WILLNEED 3 /* will need these pages */ +#define MADV_DONTNEED 4 /* don't need these pages */ +#define MADV_FREE 5 /* contents can be freed */ +#define MADV_ACCESS_DEFAULT 6 /* default access */ +#define MADV_ACCESS_LWP 7 /* next LWP to access heavily */ +#define MADV_ACCESS_MANY 8 /* many processes to access heavily */ +#define MADV_PURGE 9 /* contents will be purged */ + +#endif /* !defined(_STRICT_POSIX) */ + +#if !defined(_STRICT_POSIX) || defined(_XPG6) +/* advice to posix_madvise */ +/* these values must be kept in sync with the MADV_* values, above */ +#define POSIX_MADV_NORMAL 0 /* MADV_NORMAL */ +#define POSIX_MADV_RANDOM 1 /* MADV_RANDOM */ +#define POSIX_MADV_SEQUENTIAL 2 /* MADV_SEQUENTIAL */ +#define POSIX_MADV_WILLNEED 3 /* MADV_WILLNEED */ +#define POSIX_MADV_DONTNEED 4 /* MADV_DONTNEED */ +#endif + +/* flags to msync, always visible to match the function */ +#define MS_OLDSYNC 0x0 /* old value of MS_SYNC */ + /* modified for UNIX98 compliance */ +#define MS_SYNC 0x4 /* wait for msync */ +#define MS_ASYNC 0x1 /* return immediately */ +#define MS_INVALIDATE 0x2 /* invalidate caches */ +#define MS_INVALCURPROC 0x8 /* invalidate cache for curproc only */ + +#if !defined(_STRICT_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG5) +/* flags to mlockall */ +#define MCL_CURRENT 0x1 /* lock current mappings */ +#define MCL_FUTURE 0x2 /* lock future mappings */ +#endif /* !_STRICT_POSIX || _POSIX_C_SOURCE > 2 || _XPG5 */ + +/* + * The following flags are older variants used by memcntl that if more generally + * visible under more generous rules basically conflict all over the place due + * to the use of common words. As such, these retain their original feature + * guards, as weird as they may be. + */ +#if (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) +#define SHARED 0x10 /* Use MEMCNTL_SHARED */ +#define PRIVATE 0x20 /* Use MEMCNTL_PRIVATE */ +#define VALID_ATTR (PROT_READ|PROT_WRITE|PROT_EXEC|SHARED|PRIVATE) +#endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) */ + +#if !defined(_STRICT_POSIX) +/* these flags are used by memcntl */ +#define PROC_TEXT (PROT_EXEC | PROT_READ) +#define PROC_DATA (PROT_READ | PROT_WRITE | PROT_EXEC) +#define MEMCNTL_SHARED 0x10 +#define MENCNTL_PRIVATE 0x20 +#define MEMCNTL_VALID_ATTR (PROT_READ |PROT_WRITE |PROT_EXEC | \ + MEMCNTL_SHARED | MEMCNTL_PRIVATE) + +/* functions to memcntl */ +#define MC_SYNC 1 /* sync with backing store */ +#define MC_LOCK 2 /* lock pages in memory */ +#define MC_UNLOCK 3 /* unlock pages from memory */ +#define MC_ADVISE 4 /* give advice to management */ +#define MC_LOCKAS 5 /* lock address space in memory */ +#define MC_UNLOCKAS 6 /* unlock address space from memory */ +#define MC_HAT_ADVISE 7 /* advise hat map size */ +#define MC_INHERIT_ZERO 8 /* zero out regions on fork() */ + +/* sub-commands for MC_HAT_ADVISE */ +#define MHA_MAPSIZE_VA 0x1 /* set preferred page size */ +#define MHA_MAPSIZE_BSSBRK 0x2 /* set preferred page size */ + /* for last bss adjacent to */ + /* brk area and brk area itself */ +#define MHA_MAPSIZE_STACK 0x4 /* set preferred page size */ + /* processes main stack */ +/* definitions for meminfosys syscall */ +#define MISYS_MEMINFO 0x0 + +#if !defined(_ASM) + +#if defined(_INT64_TYPE) +/* private structure for meminfo */ +typedef struct meminfo { + const uint64_t *mi_inaddr; /* array of input addresses */ + const uint_t *mi_info_req; /* array of types of info requested */ + uint64_t *mi_outdata; /* array of results are placed */ + uint_t *mi_validity; /* array of bitwise result codes */ + int mi_info_count; /* number of pieces of info requested */ +} meminfo_t; +#endif /* defined(_INT64_TYPE) */ + +#if defined(_SYSCALL32) +typedef struct meminfo32 { + caddr32_t mi_inaddr; /* array of input addresses */ + caddr32_t mi_info_req; /* array of types of information requested */ + caddr32_t mi_outdata; /* array of results are placed */ + caddr32_t mi_validity; /* array of bitwise result codes */ + int32_t mi_info_count; /* number of pieces of information requested */ +} meminfo32_t; +#endif /* defined(_SYSCALL32) */ + +#endif /* !defined(_ASM) */ + +/* + * info_req request type definitions for meminfo + * request types starting with MEMINFO_V are used for Virtual addresses + * and should not be mixed with MEMINFO_PLGRP which is targeted for Physical + * addresses + */ +#define MEMINFO_SHIFT 16 +#define MEMINFO_MASK (0xFF << MEMINFO_SHIFT) +#define MEMINFO_VPHYSICAL (0x01 << MEMINFO_SHIFT) /* get physical addr */ +#define MEMINFO_VLGRP (0x02 << MEMINFO_SHIFT) /* get lgroup */ +#define MEMINFO_VPAGESIZE (0x03 << MEMINFO_SHIFT) /* size of phys page */ +#define MEMINFO_VREPLCNT (0x04 << MEMINFO_SHIFT) /* no. of replica */ +#define MEMINFO_VREPL (0x05 << MEMINFO_SHIFT) /* physical replica */ +#define MEMINFO_VREPL_LGRP (0x06 << MEMINFO_SHIFT) /* lgrp of replica */ +#define MEMINFO_PLGRP (0x07 << MEMINFO_SHIFT) /* lgroup for paddr */ + +/* maximum number of addresses meminfo() can process at a time */ +#define MAX_MEMINFO_CNT 256 + +/* maximum number of request types */ +#define MAX_MEMINFO_REQ 31 + +#endif /* !defined(_STRICT_POSIX) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MMAN_H */ diff --git a/illumos-x86_64/usr/include/sys/mmapobj.h b/illumos-x86_64/usr/include/sys/mmapobj.h new file mode 100644 index 00000000..9c19127d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mmapobj.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MMAPOBJ_H +#define _SYS_MMAPOBJ_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Number of mmapobj_result_t structures created on stack for quick allocation. + * More will be manually kmem_alloc'ed if needed. + * Should be enough for most ELF objects. + */ +#define LIBVA_CACHED_SEGS 3 + +#ifdef _KERNEL +extern void mmapobj_unmap(mmapobj_result_t *, int, int, ushort_t); +#endif + +extern int mmapobj(vnode_t *, uint_t, mmapobj_result_t *, uint_t *, size_t, + cred_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MMAPOBJ_H */ diff --git a/illumos-x86_64/usr/include/sys/mntent.h b/illumos-x86_64/usr/include/sys/mntent.h new file mode 100644 index 00000000..88c98dc5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mntent.h @@ -0,0 +1,141 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * + * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + */ + +#ifndef _SYS_MNTENT_H +#define _SYS_MNTENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MNTTAB "/etc/mnttab" +#define VFSTAB "/etc/vfstab" +#define MNTMAXSTR 128 + +#define MNTTYPE_ZFS "zfs" /* ZFS file system */ +#define MNTTYPE_UFS "ufs" /* Unix file system */ +#define MNTTYPE_SMBFS "smbfs" /* SMBFS file system */ +#define MNTTYPE_NFS "nfs" /* NFS file system */ +#define MNTTYPE_NFS3 "nfs3" /* NFS Version 3 file system */ +#define MNTTYPE_NFS4 "nfs4" /* NFS Version 4 file system */ +#define MNTTYPE_PCFS "pcfs" /* PC (MSDOS) file system */ +#define MNTTYPE_PC MNTTYPE_PCFS /* Deprecated name; use MNTTYPE_PCFS */ +#define MNTTYPE_LOFS "lofs" /* Loop back file system */ +#define MNTTYPE_LO MNTTYPE_LOFS /* Deprecated name; use MNTTYPE_LOFS */ +#define MNTTYPE_HSFS "hsfs" /* High Sierra (9660) file system */ +#define MNTTYPE_SWAP "swap" /* Swap file system */ +#define MNTTYPE_TMPFS "tmpfs" /* Tmp volatile file system */ +#define MNTTYPE_AUTOFS "autofs" /* Automounter ``file'' system */ +#define MNTTYPE_MNTFS "mntfs" /* In-kernel mnttab */ +#define MNTTYPE_DEV "dev" /* /dev file system */ +#define MNTTYPE_CTFS "ctfs" /* Contract file system */ +#define MNTTYPE_OBJFS "objfs" /* Kernel object file system */ +#define MNTTYPE_SHAREFS "sharefs" /* Kernel sharetab file system */ + + +#define MNTOPT_RO "ro" /* Read only */ +#define MNTOPT_RW "rw" /* Read/write */ +#define MNTOPT_RQ "rq" /* Read/write with quotas */ +#define MNTOPT_QUOTA "quota" /* Check quotas */ +#define MNTOPT_NOQUOTA "noquota" /* Don't check quotas */ +#define MNTOPT_ONERROR "onerror" /* action to taken on error */ +#define MNTOPT_SOFT "soft" /* Soft mount */ +#define MNTOPT_SEMISOFT "semisoft" /* partial soft, uncommited interface */ +#define MNTOPT_HARD "hard" /* Hard mount */ +#define MNTOPT_SUID "suid" /* Both setuid and devices allowed */ +#define MNTOPT_NOSUID "nosuid" /* Neither setuid nor devices allowed */ +#define MNTOPT_DEVICES "devices" /* Device-special allowed */ +#define MNTOPT_NODEVICES "nodevices" /* Device-special disallowed */ +#define MNTOPT_SETUID "setuid" /* Set uid allowed */ +#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */ +#define MNTOPT_GRPID "grpid" /* SysV-compatible gid on create */ +#define MNTOPT_REMOUNT "remount" /* Change mount options */ +#define MNTOPT_NOSUB "nosub" /* Disallow mounts on subdirs */ +#define MNTOPT_MULTI "multi" /* Do multi-component lookup */ +#define MNTOPT_INTR "intr" /* Allow NFS ops to be interrupted */ +#define MNTOPT_NOINTR "nointr" /* Don't allow interrupted ops */ +#define MNTOPT_PORT "port" /* NFS server IP port number */ +#define MNTOPT_SECURE "secure" /* Secure (AUTH_DES) mounting */ +#define MNTOPT_RSIZE "rsize" /* Max NFS read size (bytes) */ +#define MNTOPT_WSIZE "wsize" /* Max NFS write size (bytes) */ +#define MNTOPT_TIMEO "timeo" /* NFS timeout (1/10 sec) */ +#define MNTOPT_RETRANS "retrans" /* Max retransmissions (soft mnts) */ +#define MNTOPT_ACTIMEO "actimeo" /* Attr cache timeout (sec) */ +#define MNTOPT_ACREGMIN "acregmin" /* Min attr cache timeout (files) */ +#define MNTOPT_ACREGMAX "acregmax" /* Max attr cache timeout (files) */ +#define MNTOPT_ACDIRMIN "acdirmin" /* Min attr cache timeout (dirs) */ +#define MNTOPT_ACDIRMAX "acdirmax" /* Max attr cache timeout (dirs) */ +#define MNTOPT_NOAC "noac" /* Don't cache attributes at all */ +#define MNTOPT_NOCTO "nocto" /* No close-to-open consistency */ +#define MNTOPT_BG "bg" /* Do mount retries in background */ +#define MNTOPT_FG "fg" /* Do mount retries in foreground */ +#define MNTOPT_RETRY "retry" /* Number of mount retries */ +#define MNTOPT_DEV "dev" /* Device id of mounted fs */ +#define MNTOPT_POSIX "posix" /* Get static pathconf for mount */ +#define MNTOPT_MAP "map" /* Automount map */ +#define MNTOPT_DIRECT "direct" /* Automount direct map mount */ +#define MNTOPT_INDIRECT "indirect" /* Automount indirect map mount */ +#define MNTOPT_LLOCK "llock" /* Local locking (no lock manager) */ +#define MNTOPT_IGNORE "ignore" /* Ignore this entry */ +#define MNTOPT_VERS "vers" /* protocol version number indicator */ +#define MNTOPT_PROTO "proto" /* protocol network_id indicator */ +#define MNTOPT_SEC "sec" /* Security flavor indicator */ +#define MNTOPT_SYNCDIR "syncdir" /* Synchronous local directory ops */ +#define MNTOPT_NOSETSEC "nosec" /* Do no allow setting sec attrs */ +#define MNTOPT_NOPRINT "noprint" /* Do not print messages */ +#define MNTOPT_LARGEFILES "largefiles" /* allow large files */ +#define MNTOPT_NOLARGEFILES "nolargefiles" /* don't allow large files */ +#define MNTOPT_FORCEDIRECTIO "forcedirectio" /* Force DirectIO on all files */ +#define MNTOPT_NOFORCEDIRECTIO "noforcedirectio" /* No Force DirectIO */ +#define MNTOPT_DISABLEDIRECTIO "disabledirectio" /* Disable DirectIO ioctls */ +#define MNTOPT_PUBLIC "public" /* Use NFS public file handlee */ +#define MNTOPT_LOGGING "logging" /* enable logging */ +#define MNTOPT_NOLOGGING "nologging" /* disable logging */ +#define MNTOPT_ATIME "atime" /* update atime for files */ +#define MNTOPT_NOATIME "noatime" /* do not update atime for files */ +#define MNTOPT_GLOBAL "global" /* Cluster-wide global mount */ +#define MNTOPT_NOGLOBAL "noglobal" /* Mount local to single node */ +#define MNTOPT_DFRATIME "dfratime" /* Deferred access time updates */ +#define MNTOPT_NODFRATIME "nodfratime" /* No Deferred access time updates */ +#define MNTOPT_NBMAND "nbmand" /* allow non-blocking mandatory locks */ +#define MNTOPT_NONBMAND "nonbmand" /* deny non-blocking mandatory locks */ +#define MNTOPT_XATTR "xattr" /* enable extended attributes */ +#define MNTOPT_NOXATTR "noxattr" /* disable extended attributes */ +#define MNTOPT_EXEC "exec" /* enable executables */ +#define MNTOPT_NOEXEC "noexec" /* disable executables */ +#define MNTOPT_RESTRICT "restrict" /* restricted autofs mount */ +#define MNTOPT_BROWSE "browse" /* browsable autofs mount */ +#define MNTOPT_NOBROWSE "nobrowse" /* non-browsable autofs mount */ +#define MNTOPT_ZONE "zone" /* zone name - set only for non global zones */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MNTENT_H */ diff --git a/illumos-x86_64/usr/include/sys/mntio.h b/illumos-x86_64/usr/include/sys/mntio.h new file mode 100644 index 00000000..dc294766 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mntio.h @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MNTIO_H +#define _SYS_MNTIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Mntfs io control commands + */ +#define MNTIOC ('m' << 8) +#define MNTIOC_NMNTS (MNTIOC|1) /* Get # of mounted resources */ +#define MNTIOC_GETDEVLIST (MNTIOC|2) /* Get mounted dev no.'s */ +#define MNTIOC_SETTAG (MNTIOC|3) /* Set a tag on a mounted fs */ +#define MNTIOC_CLRTAG (MNTIOC|4) /* Clear a tag from a fs */ +#define MNTIOC_SHOWHIDDEN (MNTIOC|6) /* private */ +#define MNTIOC_GETMNTENT (MNTIOC|7) /* private */ +#define MNTIOC_GETEXTMNTENT (MNTIOC|8) /* private */ +#define MNTIOC_GETMNTANY (MNTIOC|9) /* private */ + +/* + * Private mntfs return codes + */ +#define MNTFS_EOF 1 +#define MNTFS_TOOLONG 2 + + +#define MAX_MNTOPT_TAG 64 /* Maximum size for a mounted file system tag */ + +struct mnttagdesc { + uint_t mtd_major; /* major number of mounted resource */ + uint_t mtd_minor; /* minor number of mounted resource */ + char *mtd_mntpt; /* mount point for mounted resource */ + char *mtd_tag; /* tag to set/clear */ +}; + +#ifdef _SYSCALL32 +struct mnttagdesc32 { + uint32_t mtd_major; /* major number of mounted resource */ + uint32_t mtd_minor; /* minor number of mounted resource */ + caddr32_t mtd_mntpt; /* mount point for mounted resource */ + caddr32_t mtd_tag; /* tag to set/clear */ +}; +#endif /* _SYSCALL32 */ + + +struct mntlookup { + size_t mtl_mntpt_off; + char *mtl_mntpt; + major_t mtl_major; + minor_t mtl_minor; + ino64_t mtl_ino; + char mtl_fstype[_ST_FSTYPSZ]; +}; + +#ifdef _SYSCALL32 +struct mntlookup32 { + size32_t mtl_mntpt_off; + caddr32_t mtl_mntpt; + major32_t mtl_major; + minor32_t mtl_minor; + ino64_t mtl_ino; + char mtl_fstype[_ST_FSTYPSZ]; +}; +#endif /* _SYSCALL32 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MNTIO_H */ diff --git a/illumos-x86_64/usr/include/sys/mnttab.h b/illumos-x86_64/usr/include/sys/mnttab.h new file mode 100644 index 00000000..81088869 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mnttab.h @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MNTTAB_H +#define _SYS_MNTTAB_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MNTTAB "/etc/mnttab" +#define MNT_LINE_MAX 1024 + +#define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */ +#define MNT_TOOMANY 2 /* too many fields in line */ +#define MNT_TOOFEW 3 /* too few fields in line */ + +#define mntnull(mp)\ + ((mp)->mnt_special = (mp)->mnt_mountp = \ + (mp)->mnt_fstype = (mp)->mnt_mntopts = \ + (mp)->mnt_time = NULL) + +#define putmntent(fd, mp) (-1) + +/* + * The fields in struct extmnttab should match those in struct mnttab until new + * fields are encountered. This allows hasmntopt(), getmntent_common() and + * mntioctl() to cast one type to the other safely. + * + * The fields in struct mnttab, struct extmnttab and struct mntentbuf must all + * match those in the corresponding 32-bit versions defined in mntvnops.c. + */ +struct mnttab { + char *mnt_special; + char *mnt_mountp; + char *mnt_fstype; + char *mnt_mntopts; + char *mnt_time; +}; + +struct extmnttab { + char *mnt_special; + char *mnt_mountp; + char *mnt_fstype; + char *mnt_mntopts; + char *mnt_time; + uint_t mnt_major; + uint_t mnt_minor; +}; + +struct mntentbuf { + struct extmnttab *mbuf_emp; + size_t mbuf_bufsize; + char *mbuf_buf; +}; + +#if !defined(_KERNEL) +extern void resetmnttab(FILE *); +extern int getmntent(FILE *, struct mnttab *); +extern int getextmntent(FILE *, struct extmnttab *, size_t); +extern int getmntany(FILE *, struct mnttab *, struct mnttab *); +extern char *hasmntopt(struct mnttab *, char *); +extern char *mntopt(char **); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MNTTAB_H */ diff --git a/illumos-x86_64/usr/include/sys/modctl.h b/illumos-x86_64/usr/include/sys/modctl.h new file mode 100644 index 00000000..ccd30a23 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/modctl.h @@ -0,0 +1,707 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_MODCTL_H +#define _SYS_MODCTL_H + +/* + * loadable module support. + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following structure defines the operations used by modctl + * to load and unload modules. Each supported loadable module type + * requires a set of mod_ops. + */ +struct mod_ops { + int (*modm_install)(); /* install module in kernel */ + int (*modm_remove)(); /* remove from kernel */ + int (*modm_info)(); /* module info */ +}; + +#ifdef _KERNEL + +/* + * The defined set of mod_ops structures for each loadable module type + * Defined in modctl.c + */ +extern struct mod_ops mod_brandops; +#if defined(__i386) || defined(__amd64) +extern struct mod_ops mod_cpuops; +#endif +extern struct mod_ops mod_cryptoops; +extern struct mod_ops mod_driverops; +extern struct mod_ops mod_execops; +extern struct mod_ops mod_fsops; +extern struct mod_ops mod_miscops; +extern struct mod_ops mod_schedops; +extern struct mod_ops mod_strmodops; +extern struct mod_ops mod_syscallops; +extern struct mod_ops mod_sockmodops; +#ifdef _SYSCALL32_IMPL +extern struct mod_ops mod_syscallops32; +#endif +extern struct mod_ops mod_dacfops; +extern struct mod_ops mod_ippops; +extern struct mod_ops mod_pcbeops; +extern struct mod_ops mod_kiconvops; + +#endif /* _KERNEL */ + +/* + * Definitions for the module specific linkage structures. + * The first two fields are the same in all of the structures. + * The linkinfo is for informational purposes only and is returned by + * modctl with the MODINFO cmd. + */ + +/* For drivers */ +struct modldrv { + struct mod_ops *drv_modops; + char *drv_linkinfo; + struct dev_ops *drv_dev_ops; +}; + +/* For system calls */ +struct modlsys { + struct mod_ops *sys_modops; + char *sys_linkinfo; + struct sysent *sys_sysent; +}; + +/* For filesystems */ +struct modlfs { + struct mod_ops *fs_modops; + char *fs_linkinfo; + struct vfsdef_v5 *fs_vfsdef; /* version may actually vary */ +}; + +#if defined(__i386) || defined(__amd64) +struct cmi_ops; + +/* For CPU modules */ +struct modlcpu { + struct mod_ops *cpu_modops; + char *cpu_linkinfo; + struct cmi_ops *cpu_cmiops; +}; +#endif + +/* For cryptographic providers */ +struct modlcrypto { + struct mod_ops *crypto_modops; + char *crypto_linkinfo; +}; + +/* For misc */ +struct modlmisc { + struct mod_ops *misc_modops; + char *misc_linkinfo; +}; + +/* For IP Modules */ +struct modlipp { + struct mod_ops *ipp_modops; + char *ipp_linkinfo; + struct ipp_ops *ipp_ops; +}; + +/* For Streams Modules. */ +struct modlstrmod { + struct mod_ops *strmod_modops; + char *strmod_linkinfo; + struct fmodsw *strmod_fmodsw; +}; + +/* For Scheduling classes */ +struct modlsched { + struct mod_ops *sched_modops; + char *sched_linkinfo; + struct sclass *sched_class; +}; + +/* For Exec file type (like ELF, ...) */ +struct modlexec { + struct mod_ops *exec_modops; + char *exec_linkinfo; + struct execsw *exec_execsw; +}; + +/* For dacf modules */ +struct modldacf { + struct mod_ops *dacf_modops; + char *dacf_linkinfo; + struct dacfsw *dacf_dacfsw; +}; + +/* For PCBE modules */ +struct modlpcbe { + struct mod_ops *pcbe_modops; + char *pcbe_linkinfo; + struct __pcbe_ops *pcbe_ops; +}; + +/* For Brand modules */ +struct modlbrand { + struct mod_ops *brand_modops; + char *brand_linkinfo; + struct brand *brand_branddef; +}; + +/* For socket Modules. */ +struct modlsockmod { + struct mod_ops *sockmod_modops; + char *sockmod_linkinfo; + struct smod_reg_s *sockmod_reg_info; +}; + +/* For kiconv modules */ +struct modlkiconv { + struct mod_ops *kiconv_modops; + char *kiconv_linkinfo; + struct kiconv_mod_info *kiconv_moddef; +}; + +/* + * Revision number of loadable modules support. This is the value + * that must be used in the modlinkage structure. + */ +#define MODREV_1 1 + +/* + * The modlinkage structure is the structure that the module writer + * provides to the routines to install, remove, and stat a module. + * The ml_linkage element is an array of pointers to linkage structures. + * For most modules there is only one linkage structure. We allocate + * enough space for 3 linkage structures which happens to be the most + * we have in any sun supplied module. For those modules with more + * than 3 linkage structures (which is very unlikely), a modlinkage + * structure must be kmem_alloc'd in the module wrapper to be big enough + * for all of the linkage structures. + */ +struct modlinkage { + int ml_rev; /* rev of loadable modules system */ +#ifdef _LP64 + void *ml_linkage[7]; /* more space in 64-bit OS */ +#else + void *ml_linkage[4]; /* NULL terminated list of */ + /* linkage structures */ +#endif +}; + +/* + * commands. These are the commands supported by the modctl system call. + */ +#define MODLOAD 0 +#define MODUNLOAD 1 +#define MODINFO 2 +#define MODRESERVED 3 +#define MODSETMINIROOT 4 +#define MODADDMAJBIND 5 +#define MODGETPATH 6 +#define MODREADSYSBIND 7 +#define MODGETMAJBIND 8 +#define MODGETNAME 9 +#define MODSIZEOF_DEVID 10 +#define MODGETDEVID 11 +#define MODSIZEOF_MINORNAME 12 +#define MODGETMINORNAME 13 +#define MODGETPATHLEN 14 +#define MODEVENTS 15 +#define MODGETFBNAME 16 +#define MODREREADDACF 17 +#define MODLOADDRVCONF 18 +#define MODUNLOADDRVCONF 19 +#define MODREMMAJBIND 20 +#define MODDEVT2INSTANCE 21 +#define MODGETDEVFSPATH_LEN 22 +#define MODGETDEVFSPATH 23 +#define MODDEVID2PATHS 24 +#define MODSETDEVPOLICY 26 +#define MODGETDEVPOLICY 27 +#define MODALLOCPRIV 28 +#define MODGETDEVPOLICYBYNAME 29 +#define MODLOADMINORPERM 31 +#define MODADDMINORPERM 32 +#define MODREMMINORPERM 33 +#define MODREMDRVCLEANUP 34 +#define MODDEVEXISTS 35 +#define MODDEVREADDIR 36 +#define MODDEVNAME 37 +#define MODGETDEVFSPATH_MI_LEN 38 +#define MODGETDEVFSPATH_MI 39 +#define MODRETIRE 40 +#define MODUNRETIRE 41 +#define MODISRETIRED 42 +#define MODDEVEMPTYDIR 43 +#define MODREMDRVALIAS 44 +#define MODHPOPS 45 + +/* + * sub cmds for MODEVENTS + */ +#define MODEVENTS_FLUSH 0 +#define MODEVENTS_FLUSH_DUMP 1 +#define MODEVENTS_SET_DOOR_UPCALL_FILENAME 2 +#define MODEVENTS_GETDATA 3 +#define MODEVENTS_FREEDATA 4 +#define MODEVENTS_POST_EVENT 5 +#define MODEVENTS_REGISTER_EVENT 6 + +/* + * devname subcmds for MODDEVNAME + */ +#define MODDEVNAME_LOOKUPDOOR 0 +#define MODDEVNAME_PROFILE 3 +#define MODDEVNAME_RECONFIG 4 +#define MODDEVNAME_SYSAVAIL 5 + +/* + * subcmds for MODHPOPS + */ +#define MODHPOPS_CHANGE_STATE 0 +#define MODHPOPS_CREATE_PORT 1 +#define MODHPOPS_REMOVE_PORT 2 +#define MODHPOPS_BUS_GET 3 +#define MODHPOPS_BUS_SET 4 + + +/* + * Data structure passed to modconfig command in kernel to build devfs tree + */ + +struct aliases { + struct aliases *a_next; + char *a_name; + int a_len; +}; + +#define MAXMODCONFNAME 256 + +struct modconfig { + char drvname[MAXMODCONFNAME]; + char drvclass[MAXMODCONFNAME]; + int major; + int flags; + int num_aliases; + struct aliases *ap; +}; + +#if defined(_SYSCALL32) + +struct aliases32 { + caddr32_t a_next; + caddr32_t a_name; + int32_t a_len; +}; + +struct modconfig32 { + char drvname[MAXMODCONFNAME]; + char drvclass[MAXMODCONFNAME]; + int32_t major; + int32_t flags; + int32_t num_aliases; + caddr32_t ap; +}; + +#endif /* _SYSCALL32 */ + +/* flags for modconfig */ +#define MOD_UNBIND_OVERRIDE 0x01 /* fail unbind if in use */ +#define MOD_ADDMAJBIND_UPDATE 0x02 /* update only, do not load */ + +/* flags for MODLOADDRVCONF - modctl_load_drvconf() */ +#define MOD_LOADDRVCONF_RECONF 0x01 /* complete configuration */ + /* after update-only */ + +/* + * Max module path length + */ +#define MOD_MAXPATH 256 + +/* + * Default search path for modules ADDITIONAL to the directory + * where the kernel components we booted from are. + * + * Most often, this will be "/platform/{platform}/kernel /kernel /usr/kernel", + * but we don't wire it down here. + */ +#define MOD_DEFPATH "/kernel /usr/kernel" + +/* + * Default file name extension for autoloading modules. + */ +#define MOD_DEFEXT "" + +/* + * Parameters for modinfo + * + * Maximum string lengths include terminating NUL + */ +#define MODMAXNAMELEN 32 /* max module name length */ +#define MODMAXLINKINFOLEN 32 /* max link info length */ + +/* + * Module specific information. + */ +struct modspecific_info { + char msi_linkinfo[MODMAXLINKINFOLEN]; /* name in linkage struct */ + int msi_p0; /* module specific information */ +}; + +/* + * Structure returned by modctl with MODINFO command. + */ +#define MODMAXLINK 10 /* max linkages modinfo can handle */ + +struct modinfo { + int mi_info; /* Flags for info wanted */ + int mi_state; /* Flags for module state */ + int mi_id; /* id of this loaded module */ + int mi_nextid; /* id of next module or -1 */ + caddr_t mi_base; /* virtual addr of text */ + size_t mi_size; /* size of module in bytes */ + int mi_rev; /* loadable modules rev */ + int mi_loadcnt; /* # of times loaded */ + char mi_name[MODMAXNAMELEN]; /* name of module */ + struct modspecific_info mi_msinfo[MODMAXLINK]; + /* mod specific info */ +}; + + +#if defined(_SYSCALL32) + +#define MODMAXNAMELEN32 32 /* max module name length */ +#define MODMAXLINKINFOLEN32 32 /* max link info length */ +#define MODMAXLINK32 10 /* max linkages modinfo can handle */ + +struct modspecific_info32 { + char msi_linkinfo[MODMAXLINKINFOLEN32]; /* name in linkage struct */ + int32_t msi_p0; /* module specific information */ +}; + +struct modinfo32 { + int32_t mi_info; /* Flags for info wanted */ + int32_t mi_state; /* Flags for module state */ + int32_t mi_id; /* id of this loaded module */ + int32_t mi_nextid; /* id of next module or -1 */ + caddr32_t mi_base; /* virtual addr of text */ + uint32_t mi_size; /* size of module in bytes */ + int32_t mi_rev; /* loadable modules rev */ + int32_t mi_loadcnt; /* # of times loaded */ + char mi_name[MODMAXNAMELEN32]; /* name of module */ + struct modspecific_info32 mi_msinfo[MODMAXLINK32]; + /* mod specific info */ +}; + +#endif /* _SYSCALL32 */ + +/* Values for mi_info flags */ +#define MI_INFO_ONE (1 << 0) +#define MI_INFO_ALL (1 << 1) +#define MI_INFO_CNT (1 << 2) +#ifdef _KERNEL +/* used internally to extract modlinkage */ +#define MI_INFO_LINKAGE (1 << 3) +#endif +/* + * MI_INFO_NOBASE indicates caller does not need mi_base. Failure to use this + * flag may lead 32-bit apps to receive an EOVERFLOW error from modctl(MODINFO) + * when used with a 64-bit kernel. + */ +#define MI_INFO_NOBASE (1 << 4) +/* Query by-name, rather than by-id, when used with MI_INFO_ONE */ +#define MI_INFO_BY_NAME (1 << 5) + +/* Values for mi_state */ +#define MI_LOADED 1 +#define MI_INSTALLED 2 + +/* + * Macros to vector to the appropriate module specific routine. + */ +#define MODL_INSTALL(MODL, MODLP) \ + (*(MODL)->misc_modops->modm_install)(MODL, MODLP) +#define MODL_REMOVE(MODL, MODLP) \ + (*(MODL)->misc_modops->modm_remove)(MODL, MODLP) +#define MODL_INFO(MODL, MODLP, P0) \ + (*(MODL)->misc_modops->modm_info)(MODL, MODLP, P0) + +/* + * Definitions for stubs + */ +struct mod_stub_info { + uintptr_t mods_func_adr; + struct mod_modinfo *mods_modinfo; + uintptr_t mods_stub_adr; + int (*mods_errfcn)(); + int mods_flag; /* flags defined below */ +}; + +/* + * Definitions for mods_flag. + */ +#define MODS_WEAK 0x01 /* weak stub (not loaded if called) */ +#define MODS_NOUNLOAD 0x02 /* module not unloadable (no _fini()) */ +#define MODS_INSTALLED 0x10 /* module installed */ + +struct mod_modinfo { + char *modm_module_name; + struct modctl *mp; + struct mod_stub_info modm_stubs[1]; +}; + +struct modctl_list { + struct modctl_list *modl_next; + struct modctl *modl_modp; +}; + +/* + * Structure to manage a loadable module. + * Note: the module (mod_mp) structure's "text" and "text_size" information + * are replicated in the modctl structure so that mod_containing_pc() + * doesn't have to grab any locks (modctls are persistent; modules are not.) + */ +typedef struct modctl { + struct modctl *mod_next; /* &modules based list */ + struct modctl *mod_prev; + int mod_id; + void *mod_mp; + kthread_t *mod_inprogress_thread; + struct mod_modinfo *mod_modinfo; + struct modlinkage *mod_linkage; + char *mod_filename; + char *mod_modname; + + char mod_busy; /* inprogress_thread has locked */ + char mod_want; /* someone waiting for unlock */ + char mod_prim; /* primary module */ + + int mod_ref; /* ref count - from dependent or stub */ + + char mod_loaded; /* module in memory */ + char mod_installed; /* post _init pre _fini */ + char mod_loadflags; + char mod_delay_unload; /* deferred unload */ + + struct modctl_list *mod_requisites; /* mods this one depends on. */ + void *mod_unused; /* NOTE: reuse (same size) is OK, */ + /* deletion causes mdb.vs.core issues */ + int mod_loadcnt; /* number of times mod was loaded */ + int mod_nenabled; /* # of enabled DTrace probes in mod */ + char *mod_text; + size_t mod_text_size; + + int mod_gencount; /* # times loaded/unloaded */ + struct modctl *mod_requisite_loading; /* mod circular dependency */ +} modctl_t; + +/* + * mod_loadflags + */ + +#define MOD_NOAUTOUNLOAD 0x1 /* Auto mod-unloader skips this mod */ +#define MOD_NONOTIFY 0x2 /* No krtld notifications on (un)load */ +#define MOD_NOUNLOAD 0x4 /* Assume EBUSY for all _fini's */ + + +#ifdef _KERNEL + +#define MOD_BIND_HASHSIZE 64 +#define MOD_BIND_HASHMASK (MOD_BIND_HASHSIZE-1) + +typedef int modid_t; + +/* + * global function and data declarations + */ +extern kmutex_t mod_lock; + +extern char *systemfile; +extern char *self_assembly; +extern char **syscallnames; +extern int moddebug; + +/* + * this is the head of a doubly linked list. Only the next and prev + * pointers are used + */ +extern modctl_t modules; + +extern int modload_qualified(const char *, + const char *, const char *, const char *, uint_t[], int, int *); + +extern void mod_setup(void); +extern int modload(const char *, const char *); +extern int modloadonly(const char *, const char *); +extern int modunload(int); +extern int mod_hold_stub(struct mod_stub_info *); +extern void modunload_disable(void); +extern void modunload_enable(void); +extern void modunload_begin(void); +extern void modunload_end(void); +extern int mod_remove_by_name(char *); +extern int mod_sysvar(const char *, const char *, u_longlong_t *); +extern int mod_sysctl(int, void *); +struct sysparam; +extern int mod_hold_by_modctl(modctl_t *, int); +#define MOD_WAIT_ONCE 0x01 +#define MOD_WAIT_FOREVER 0x02 +#define MOD_LOCK_HELD 0x04 +#define MOD_LOCK_NOT_HELD 0x08 +extern int mod_sysctl_type(int, int (*)(struct sysparam *, void *), + void *); +extern void mod_read_system_file(int); +extern void mod_release_stub(struct mod_stub_info *); +extern void mod_askparams(void); +extern void mod_uninstall_daemon(void); +extern void modreap(void); +extern modctl_t *mod_hold_by_id(modid_t); +extern modctl_t *mod_hold_by_name(const char *); +extern void mod_release_mod(modctl_t *); +extern uintptr_t modlookup(const char *, const char *); +extern uintptr_t modlookup_by_modctl(modctl_t *, const char *); +extern char *modgetsymname(uintptr_t, unsigned long *); +extern void mod_release_requisites(modctl_t *); +extern modctl_t *mod_load_requisite(modctl_t *, char *); +extern modctl_t *mod_find_by_filename(char *, char *); +extern uintptr_t modgetsymvalue(char *, int); + +extern int major_valid(major_t); +extern int driver_installed(major_t); +extern int driver_active(major_t); + +extern void mod_rele_dev_by_major(major_t); +extern struct dev_ops *mod_hold_dev_by_major(major_t); +extern struct dev_ops *mod_hold_dev_by_devi(dev_info_t *); +extern void mod_rele_dev_by_devi(dev_info_t *); + +extern int make_devname(const char *, major_t, int); +extern int gmatch(const char *, const char *); + +extern void make_aliases(struct bind **); +extern int read_binding_file(char *, struct bind **, + int (*line_parser)(char *, int, char *, struct bind **)); +extern void clear_binding_hash(struct bind **); + +extern void read_class_file(void); +extern void setbootpath(char *); +extern void setbootfstype(char *); + +extern int install_stubs_by_name(modctl_t *, const char *); +extern void install_stubs(modctl_t *); +extern void uninstall_stubs(modctl_t *); +extern void reset_stubs(modctl_t *); +extern modctl_t *mod_getctl(struct modlinkage *); +extern major_t mod_name_to_major(const char *); +extern modid_t mod_name_to_modid(const char *); +extern char *mod_major_to_name(major_t); +extern void init_devnamesp(int); +extern void init_syscallnames(int); + +extern char *mod_getsysname(int); +extern int mod_getsysnum(const char *); + +extern char *mod_containing_pc(caddr_t); +extern int mod_in_autounload(void); +extern const char *mod_modname(struct modlinkage *); + +extern int dev_minorperm(dev_info_t *, char *, mperm_t *); +extern void dev_devices_cleanup(void); + +/* + * Declarations used for dynamic linking support routines. Interfaces + * are marked with the pragma "unknown_control_flow" to prevent tail call + * optimization, so that implementations can reliably use caller() to + * determine initiating module. + */ +#define KRTLD_MODE_FIRST 0x0001 +typedef struct __ddi_modhandle *ddi_modhandle_t; +extern ddi_modhandle_t ddi_modopen(const char *, + int, int *); +extern void *ddi_modsym(ddi_modhandle_t, + const char *, int *); +extern int ddi_modclose(ddi_modhandle_t); +#pragma unknown_control_flow(ddi_modopen, ddi_modsym, ddi_modclose) + +/* + * Only the following are part of the DDI/DKI + */ +extern int _init(void); +extern int _fini(void); +extern int _info(struct modinfo *); +extern int mod_install(struct modlinkage *); +extern int mod_remove(struct modlinkage *); +extern int mod_info(struct modlinkage *, struct modinfo *); + +#else /* _KERNEL */ + +extern int modctl(int, ...); + +#endif /* _KERNEL */ + +/* + * bit definitions for moddebug. + */ +#define MODDEBUG_LOADMSG 0x80000000 /* print "[un]loading..." msg */ +#define MODDEBUG_ERRMSG 0x40000000 /* print detailed error msgs */ +#define MODDEBUG_LOADMSG2 0x20000000 /* print 2nd level msgs */ +#define MODDEBUG_RETIRE 0x10000000 /* print retire msgs */ +#define MODDEBUG_BINDING 0x00040000 /* driver/alias binding */ +#define MODDEBUG_FINI_EBUSY 0x00020000 /* pretend fini returns EBUSY */ +#define MODDEBUG_NOAUL_IPP 0x00010000 /* no Autounloading ipp mods */ +#define MODDEBUG_NOAUL_DACF 0x00008000 /* no Autounloading dacf mods */ +#define MODDEBUG_KEEPTEXT 0x00004000 /* keep text after unloading */ +#define MODDEBUG_NOAUL_DRV 0x00001000 /* no Autounloading Drivers */ +#define MODDEBUG_NOAUL_EXEC 0x00000800 /* no Autounloading Execs */ +#define MODDEBUG_NOAUL_FS 0x00000400 /* no Autounloading File sys */ +#define MODDEBUG_NOAUL_MISC 0x00000200 /* no Autounloading misc */ +#define MODDEBUG_NOAUL_SCHED 0x00000100 /* no Autounloading scheds */ +#define MODDEBUG_NOAUL_STR 0x00000080 /* no Autounloading streams */ +#define MODDEBUG_NOAUL_SYS 0x00000040 /* no Autounloading syscalls */ +#define MODDEBUG_NOCTF 0x00000020 /* do not load CTF debug data */ +#define MODDEBUG_NOAUTOUNLOAD 0x00000010 /* no autounloading at all */ +#define MODDEBUG_DDI_MOD 0x00000008 /* ddi_mod{open,sym,close} */ +#define MODDEBUG_MP_MATCH 0x00000004 /* dev_minorperm */ +#define MODDEBUG_MINORPERM 0x00000002 /* minor perm modctls */ +#define MODDEBUG_USERDEBUG 0x00000001 /* bpt after init_module() */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MODCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/mode.h b/illumos-x86_64/usr/include/sys/mode.h new file mode 100644 index 00000000..f6291213 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mode.h @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_MODE_H +#define _SYS_MODE_H + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Conversion between vnode types/modes and encoded type/mode as + * seen by stat(2) and mknod(2). + */ +extern enum vtype iftovt_tab[]; +extern ushort_t vttoif_tab[]; +#define IFTOVT(M) (iftovt_tab[((M) & S_IFMT) >> 12]) +#define VTTOIF(T) (vttoif_tab[(int)(T)]) +#define MAKEIMODE(T, M) (VTTOIF(T) | ((M) & ~S_IFMT)) + +#ifdef __cplusplus +} +#endif + +#endif /* _KERNEL */ + +#endif /* _SYS_MODE_H */ diff --git a/illumos-x86_64/usr/include/sys/model.h b/illumos-x86_64/usr/include/sys/model.h new file mode 100644 index 00000000..0569c086 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/model.h @@ -0,0 +1,220 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MODEL_H +#define _SYS_MODEL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) && !defined(_ASM) +#include +#endif /* _KERNEL && !_ASM */ + +#include + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) || defined(_KMEMUSER) + +/* + * These bits are used in various places to specify the data model + * of the originator (and/or consumer) of data items. See + * , and . + * + * This state should only be known to the kernel implementation. + */ +#define DATAMODEL_MASK 0x0FF00000 + +#define DATAMODEL_ILP32 0x00100000 +#define DATAMODEL_LP64 0x00200000 + +#define DATAMODEL_NONE 0 + +#if defined(_LP64) +#define DATAMODEL_NATIVE DATAMODEL_LP64 +#elif defined(_ILP32) +#define DATAMODEL_NATIVE DATAMODEL_ILP32 +#else +#error "No DATAMODEL_NATIVE specified" +#endif /* _LP64 || _ILP32 */ + +#endif /* _KERNEL || _KMEMUSER */ + +#ifndef _ASM +/* + * XXX Ick. This type needs to be visible outside the above guard because + * the proc structure is visible outside the _KERNEL | _KMEMUSER guard. + * If we can make proc internals less visible, (which we obviously should) + * then this can be invisible too. + */ +typedef unsigned int model_t; + +#endif /* _ASM */ + +#if defined(_KERNEL) && !defined(_ASM) +/* + * These macros allow two views of the same piece of memory depending + * on the originating user-mode program's data model. See the STRUCT_DECL(9F) + * man page. + */ +#if defined(_LP64) + +#define STRUCT_HANDLE(struct_type, handle) \ + struct { \ + union { \ + struct struct_type##32 *m32; \ + struct struct_type *m64; \ + } ptr; \ + model_t model; \ + } handle = { NULL, DATAMODEL_ILP32 } + +#define STRUCT_DECL(struct_type, handle) \ + struct struct_type __##handle##_buf; \ + STRUCT_HANDLE(struct_type, handle) + +#define STRUCT_SET_HANDLE(handle, umodel, addr) \ + (handle).model = (model_t)(umodel) & DATAMODEL_MASK; \ + ASSERT(((umodel) & DATAMODEL_MASK) != DATAMODEL_NONE); \ + ((handle).ptr.m64) = (addr) + +#define STRUCT_INIT(handle, umodel) \ + STRUCT_SET_HANDLE(handle, umodel, &__##handle##_buf) + +#define STRUCT_SIZE(handle) \ + ((handle).model == DATAMODEL_ILP32 ? \ + sizeof (*(handle).ptr.m32) : \ + sizeof (*(handle).ptr.m64)) + +/* + * In STRUCT_FADDR and STRUCT_FGETP a sleight of hand is employed to make + * the compiler cope with having two different pointer types within ?:. + * The (void *) case on the ILP32 case makes it a pointer which can be + * converted to the pointer on the LP64 case, thus quieting the compiler. + */ +#define STRUCT_FADDR(handle, field) \ + ((handle).model == DATAMODEL_ILP32 ? \ + (void *)&(handle).ptr.m32->field : \ + &(handle).ptr.m64->field) + +#define STRUCT_FGET(handle, field) \ + (((handle).model == DATAMODEL_ILP32) ? \ + (handle).ptr.m32->field : \ + (handle).ptr.m64->field) + +#define STRUCT_FGETP(handle, field) \ + ((handle).model == DATAMODEL_ILP32 ? \ + (void *)(uintptr_t)(handle).ptr.m32->field : \ + (handle).ptr.m64->field) + +#define STRUCT_FSET(handle, field, val) \ + ((handle).model == DATAMODEL_ILP32 ? \ + ((handle).ptr.m32->field = (val)) : \ + ((handle).ptr.m64->field = (val))) + +#define STRUCT_FSETP(handle, field, val) \ + ((handle).model == DATAMODEL_ILP32 ? \ + (void) ((handle).ptr.m32->field = (caddr32_t)(uintptr_t)(val)) : \ + (void) ((handle).ptr.m64->field = (val))) + +#define STRUCT_BUF(handle) ((handle).ptr.m64) + +#define SIZEOF_PTR(umodel) \ + (((umodel) & DATAMODEL_MASK) == DATAMODEL_ILP32 ? \ + sizeof (caddr32_t) : \ + sizeof (caddr_t)) + +#define SIZEOF_STRUCT(struct_type, umodel) \ + (((umodel) & DATAMODEL_MASK) == DATAMODEL_ILP32 ? \ + sizeof (struct struct_type##32) : \ + sizeof (struct struct_type)) + +#else /* _LP64 */ + +#define STRUCT_HANDLE(struct_type, handle) \ + struct { \ + struct struct_type *ptr; \ + model_t model; \ + } handle = { NULL, DATAMODEL_ILP32 } + +#define STRUCT_DECL(struct_type, handle) \ + struct struct_type __##handle##_buf; \ + STRUCT_HANDLE(struct_type, handle) + +#define STRUCT_SET_HANDLE(handle, umodel, addr) \ + (handle).model = (model_t)(umodel) & DATAMODEL_MASK; \ + ASSERT(((umodel) & DATAMODEL_MASK) == DATAMODEL_ILP32); \ + (handle).ptr = (addr) + +#define STRUCT_INIT(handle, umodel) \ + STRUCT_SET_HANDLE(handle, umodel, &__##handle##_buf) + +#define STRUCT_SIZE(handle) (sizeof (*(handle).ptr)) + +#define STRUCT_FADDR(handle, field) (&(handle).ptr->field) + +#define STRUCT_FGET(handle, field) ((handle).ptr->field) + +#define STRUCT_FGETP STRUCT_FGET + +#define STRUCT_FSET(handle, field, val) ((handle).ptr->field = (val)) + +#define STRUCT_FSETP STRUCT_FSET + +#define STRUCT_BUF(handle) ((handle).ptr) + +#define SIZEOF_PTR(umodel) sizeof (caddr_t) + +#define SIZEOF_STRUCT(struct_type, umodel) sizeof (struct struct_type) + +#endif /* _LP64 */ + +#if defined(_LP64) || defined(__lint) + +struct _klwp; + +extern model_t lwp_getdatamodel(struct _klwp *); +extern model_t get_udatamodel(void); + +#else + +/* + * If we're the 32-bit kernel, the result of these function + * calls is completely predictable, so let's just cheat. A + * good compiler should be able to elide all the unreachable code + * that results. Optimism about optimization reigns supreme ;-) + */ +#define lwp_getdatamodel(t) DATAMODEL_ILP32 +#define get_udatamodel() DATAMODEL_ILP32 + +#endif /* _LP64 || __lint */ + +#endif /* _KERNEL && !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MODEL_H */ diff --git a/illumos-x86_64/usr/include/sys/modhash.h b/illumos-x86_64/usr/include/sys/modhash.h new file mode 100644 index 00000000..7f7103ec --- /dev/null +++ b/illumos-x86_64/usr/include/sys/modhash.h @@ -0,0 +1,149 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MODHASH_H +#define _SYS_MODHASH_H + +/* + * Generic hash implementation for the kernel. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +#include + +/* + * Opaque data types for storing keys and values + */ +typedef void *mod_hash_val_t; +typedef void *mod_hash_key_t; + +/* + * Opaque data type for reservation + */ +typedef void *mod_hash_hndl_t; + +/* + * Opaque type for hash itself. + */ +struct mod_hash; +typedef struct mod_hash mod_hash_t; + +/* + * String hash table + */ +mod_hash_t *mod_hash_create_strhash(char *, size_t, void (*)(mod_hash_val_t)); +void mod_hash_destroy_strhash(mod_hash_t *); +int mod_hash_strkey_cmp(mod_hash_key_t, mod_hash_key_t); +void mod_hash_strkey_dtor(mod_hash_key_t); +void mod_hash_strval_dtor(mod_hash_val_t); +uint_t mod_hash_bystr(void *, mod_hash_key_t); + +/* + * Pointer hash table + */ +mod_hash_t *mod_hash_create_ptrhash(char *, size_t, void (*)(mod_hash_val_t), + size_t); +void mod_hash_destroy_ptrhash(mod_hash_t *); +int mod_hash_ptrkey_cmp(mod_hash_key_t, mod_hash_key_t); +uint_t mod_hash_byptr(void *, mod_hash_key_t); + +/* + * ID hash table + */ +mod_hash_t *mod_hash_create_idhash(char *, size_t, void (*)(mod_hash_val_t)); +void mod_hash_destroy_idhash(mod_hash_t *); +int mod_hash_idkey_cmp(mod_hash_key_t, mod_hash_key_t); +uint_t mod_hash_byid(void *, mod_hash_key_t); +uint_t mod_hash_iddata_gen(size_t); + +/* + * Hash management functions + */ +mod_hash_t *mod_hash_create_extended(char *, size_t, void (*)(mod_hash_key_t), + void (*)(mod_hash_val_t), uint_t (*)(void *, mod_hash_key_t), void *, + int (*)(mod_hash_key_t, mod_hash_key_t), int); + +void mod_hash_destroy_hash(mod_hash_t *); +void mod_hash_clear(mod_hash_t *); + +/* + * Null key and value destructors + */ +void mod_hash_null_keydtor(mod_hash_key_t); +void mod_hash_null_valdtor(mod_hash_val_t); + +/* + * Basic hash operations + */ + +/* + * Error codes for insert, remove, find, destroy. + */ +#define MH_ERR_NOMEM -1 +#define MH_ERR_DUPLICATE -2 +#define MH_ERR_NOTFOUND -3 + +/* + * Return codes for hash walkers + */ +#define MH_WALK_CONTINUE 0 +#define MH_WALK_TERMINATE 1 + +/* + * Basic hash operations + */ +int mod_hash_insert(mod_hash_t *, mod_hash_key_t, mod_hash_val_t); +int mod_hash_replace(mod_hash_t *, mod_hash_key_t, mod_hash_val_t); +int mod_hash_remove(mod_hash_t *, mod_hash_key_t, mod_hash_val_t *); +int mod_hash_destroy(mod_hash_t *, mod_hash_key_t); +int mod_hash_find(mod_hash_t *, mod_hash_key_t, mod_hash_val_t *); +int mod_hash_find_cb(mod_hash_t *, mod_hash_key_t, mod_hash_val_t *, + void (*)(mod_hash_key_t, mod_hash_val_t)); +int mod_hash_find_cb_rval(mod_hash_t *, mod_hash_key_t, mod_hash_val_t *, + int (*)(mod_hash_key_t, mod_hash_val_t), int *); +void mod_hash_walk(mod_hash_t *, + uint_t (*)(mod_hash_key_t, mod_hash_val_t *, void *), void *); + +/* + * Reserving hash operations + */ +int mod_hash_reserve(mod_hash_t *, mod_hash_hndl_t *); +int mod_hash_reserve_nosleep(mod_hash_t *, mod_hash_hndl_t *); +void mod_hash_cancel(mod_hash_t *, mod_hash_hndl_t *); +int mod_hash_insert_reserve(mod_hash_t *, mod_hash_key_t, mod_hash_val_t, + mod_hash_hndl_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MODHASH_H */ diff --git a/illumos-x86_64/usr/include/sys/modhash_impl.h b/illumos-x86_64/usr/include/sys/modhash_impl.h new file mode 100644 index 00000000..0b688ec2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/modhash_impl.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MODHASH_IMPL_H +#define _SYS_MODHASH_IMPL_H + +/* + * Internal details for the kernel's generic hash implementation. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include +#include + +struct mod_hash_entry { + mod_hash_key_t mhe_key; /* stored hash key */ + mod_hash_val_t mhe_val; /* stored hash value */ + struct mod_hash_entry *mhe_next; /* next item in chain */ +}; + +struct mod_hash_stat { + ulong_t mhs_hit; /* tried a 'find' and it succeeded */ + ulong_t mhs_miss; /* tried a 'find' but it failed */ + ulong_t mhs_coll; /* occur when insert fails because of dup's */ + ulong_t mhs_nelems; /* total number of stored key/value pairs */ + ulong_t mhs_nomem; /* number of times kmem_alloc failed */ +}; + +struct mod_hash { + krwlock_t mh_contents; /* lock protecting contents */ + char *mh_name; /* hash name */ + int mh_sleep; /* kmem_alloc flag */ + size_t mh_nchains; /* # of elements in mh_entries */ + + /* key and val destructor */ + void (*mh_kdtor)(mod_hash_key_t); + void (*mh_vdtor)(mod_hash_val_t); + + /* key comparator */ + int (*mh_keycmp)(mod_hash_key_t, mod_hash_key_t); + + /* hash algorithm, and algorithm-private data */ + uint_t (*mh_hashalg)(void *, mod_hash_key_t); + void *mh_hashalg_data; + + struct mod_hash *mh_next; /* next hash in list */ + + struct mod_hash_stat mh_stat; + + struct mod_hash_entry *mh_entries[1]; +}; + +/* + * MH_SIZE() + * Compute the size of a mod_hash_t, in bytes, given the number of + * elements it contains. + */ +#define MH_SIZE(n) \ + (sizeof (mod_hash_t) + ((n) - 1) * (sizeof (struct mod_hash_entry *))) + +/* + * Module initialization; called once. + */ +void mod_hash_init(void); + +/* + * Internal routines. Use directly with care. + */ +uint_t i_mod_hash(mod_hash_t *, mod_hash_key_t); +int i_mod_hash_insert_nosync(mod_hash_t *, mod_hash_key_t, mod_hash_val_t, + mod_hash_hndl_t); +int i_mod_hash_remove_nosync(mod_hash_t *, mod_hash_key_t, mod_hash_val_t *); +int i_mod_hash_find_nosync(mod_hash_t *, mod_hash_key_t, mod_hash_val_t *); +void i_mod_hash_walk_nosync(mod_hash_t *, uint_t (*)(mod_hash_key_t, + mod_hash_val_t *, void *), void *); +void i_mod_hash_clear_nosync(mod_hash_t *hash); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MODHASH_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/mount.h b/illumos-x86_64/usr/include/sys/mount.h new file mode 100644 index 00000000..b8f67a8e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mount.h @@ -0,0 +1,95 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1996, 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_MOUNT_H +#define _SYS_MOUNT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flag bits passed to mount(2). + */ +#define MS_RDONLY 0x0001 /* Read-only */ +#define MS_FSS 0x0002 /* Old (4-argument) mount (compatibility) */ +#define MS_DATA 0x0004 /* 6-argument mount */ +#define MS_NOSUID 0x0010 /* Setuid programs disallowed */ +#define MS_REMOUNT 0x0020 /* Remount */ +#define MS_NOTRUNC 0x0040 /* Return ENAMETOOLONG for long filenames */ +#define MS_OVERLAY 0x0080 /* Allow overlay mounts */ +#define MS_OPTIONSTR 0x0100 /* Data is a an in/out option string */ +#define MS_GLOBAL 0x0200 /* Clustering: Mount into global name space */ +#define MS_FORCE 0x0400 /* Forced unmount */ +#define MS_NOMNTTAB 0x0800 /* Don't show mount in mnttab */ +/* + * Additional flag bits that domount() is prepared to interpret, but that + * can't be passed through mount(2). + */ +#define MS_SYSSPACE 0x0008 /* Mounta already in kernel space */ +#define MS_NOSPLICE 0x1000 /* Don't splice fs instance into name space */ +#define MS_NOCHECK 0x2000 /* Clustering: suppress mount busy checks */ +/* + * MS_CRYPT indicates that encryption keys should be loaded if they are not + * already available. This is not defined in glibc, but it is never seen by + * the kernel so it will not cause any problems. + */ +#define MS_CRYPT 0x4000 +/* + * Mask to sift out flag bits allowable from mount(2). + */ +#define MS_MASK \ + (MS_RDONLY|MS_FSS|MS_DATA|MS_NOSUID|MS_REMOUNT|MS_NOTRUNC|MS_OVERLAY|\ + MS_OPTIONSTR|MS_GLOBAL|MS_NOMNTTAB) + +/* + * Mask to sift out flag bits allowable from umount2(2). + */ + +#define MS_UMOUNT_MASK (MS_FORCE) + +/* + * Maximum option string length accepted or returned by mount(2). + */ +#define MAX_MNTOPT_STR 1024 /* max length of mount options string */ + +#if !defined(_KERNEL) +int mount(const char *, const char *, int, ...); +int umount(const char *); +int umount2(const char *, int); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MOUNT_H */ diff --git a/illumos-x86_64/usr/include/sys/mouse.h b/illumos-x86_64/usr/include/sys/mouse.h new file mode 100644 index 00000000..6f50f570 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mouse.h @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_MOUSE_H +#define _SYS_MOUSE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * AT&T 320 (PS/2 style) Mouse Commands + */ +#define MSERESET 0xff /* reset mouse */ +#define MSERESEND 0xfe /* resend last data stream */ +#define MSEERROR 0xfc /* error */ +#define MSESETDEF 0xf6 /* set default status */ +#define MSEOFF 0xf5 /* disable mouse */ +#define MSEON 0xf4 /* enable mouse */ +#define MSECHGMOD 0xf3 /* set sampling rate and/or button mode */ +#define MSEGETDEV 0xf2 /* read device type */ +#define MSESPROMPT 0xf0 /* set prompt mode (resets stream mode) */ +#define MSEECHON 0xee /* set echo mode */ +#define MSEECHOFF 0xec /* reset echo mode */ +#define MSEREPORT 0xeb /* read mouse report */ +#define MSESTREAM 0xea /* set Incremental Stream Mode */ +#define MSESTATREQ 0xe9 /* status request */ +#define MSESETRES 0xe8 /* set counts per mm. resolution */ +#define MSESCALE2 0xe7 /* set 2:1 scaling */ +#define MSESCALE1 0xe6 /* set 1:1 scaling */ + +#define MSE_ACK 0xFA /* Acknowledgement byte from 8042 */ + +/* Post-reset return values */ +#define MSE_AA 0xaa +#define MSE_00 0x00 + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MOUSE_H */ diff --git a/illumos-x86_64/usr/include/sys/msacct.h b/illumos-x86_64/usr/include/sys/msacct.h new file mode 100644 index 00000000..426f359b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/msacct.h @@ -0,0 +1,79 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MSACCT_H +#define _SYS_MSACCT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* LWP microstates */ +#define LMS_USER 0 /* running in user mode */ +#define LMS_SYSTEM 1 /* running in sys call or page fault */ +#define LMS_TRAP 2 /* running in other trap */ +#define LMS_TFAULT 3 /* asleep in user text page fault */ +#define LMS_DFAULT 4 /* asleep in user data page fault */ +#define LMS_KFAULT 5 /* asleep in kernel page fault */ +#define LMS_USER_LOCK 6 /* asleep waiting for user-mode lock */ +#define LMS_SLEEP 7 /* asleep for any other reason */ +#define LMS_WAIT_CPU 8 /* waiting for CPU (latency) */ +#define LMS_STOPPED 9 /* stopped (/proc, jobcontrol, lwp_suspend) */ + +/* + * NMSTATES must never exceed 17 because of the size restriction + * of 128 bytes imposed on struct siginfo (see ). + */ +#define NMSTATES 10 /* number of microstates */ + +/* + * CPU Microstates + * + * The following define the implemented CPU microstates + */ + +#define CMS_USER 0 +#define CMS_SYSTEM 1 +#define CMS_IDLE 2 +#define CMS_DISABLED 3 + +/* + * NCMSTATES is set to NMSTATES - 1, because CMS_DISABLED is not a state for + * which accounting information is kept. CPUs that are offline but remain in + * the system are kept in the CMS_IDLE state until they are brought back online, + * or unconfigured and deleted from the system. Only when a cpu is unconfigured + * and about to be deleted is the CMS_DISABLED state entered. It is a + * placeholder state to ensure that our behavior is sane. ASSERT()s exist to + * verify this. + */ + +#define NCMSTATES 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MSACCT_H */ diff --git a/illumos-x86_64/usr/include/sys/msg.h b/illumos-x86_64/usr/include/sys/msg.h new file mode 100644 index 00000000..5c539490 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/msg.h @@ -0,0 +1,141 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_MSG_H +#define _SYS_MSG_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * IPC Message Facility. + */ + +/* + * Implementation Constants. + */ + +/* + * Permission Definitions. + */ +#define MSG_R 0400 /* read permission */ +#define MSG_W 0200 /* write permission */ + +/* + * ipc_perm Mode Definitions. + */ +#define MSG_RWAIT 01000 /* a reader is waiting for a message */ +#define MSG_WWAIT 02000 /* a writer is waiting to send */ + +/* + * Message Operation Flags. + */ +#define MSG_NOERROR 010000 /* no error if big message */ + +typedef unsigned long msgqnum_t; +typedef unsigned long msglen_t; + +struct msg; +struct msqid_ds { + struct ipc_perm msg_perm; /* operation permission struct */ + struct msg *msg_first; /* ptr to first message on q */ + struct msg *msg_last; /* ptr to last message on q */ + msglen_t msg_cbytes; /* current # bytes on q */ + msgqnum_t msg_qnum; /* # of messages on q */ + msglen_t msg_qbytes; /* max # of bytes on q */ + pid_t msg_lspid; /* pid of last msgsnd */ + pid_t msg_lrpid; /* pid of last msgrcv */ +#if defined(_LP64) + time_t msg_stime; /* last msgsnd time */ + time_t msg_rtime; /* last msgrcv time */ + time_t msg_ctime; /* last change time */ +#else + time_t msg_stime; /* last msgsnd time */ + int32_t msg_pad1; /* reserved for time_t expansion */ + time_t msg_rtime; /* last msgrcv time */ + int32_t msg_pad2; /* time_t expansion */ + time_t msg_ctime; /* last change time */ + int32_t msg_pad3; /* time_t expansion */ +#endif + short msg_cv; + short msg_qnum_cv; + long msg_pad4[3]; /* reserve area */ +}; + +/* + * User message buffer template for msgsnd and msgrecv system calls. + */ + +#ifdef _KERNEL +struct ipcmsgbuf { +#else +struct msgbuf { +#endif /* _KERNEL */ +#if defined(_XOPEN_SOURCE) + long _mtype; /* message type */ + char _mtext[1]; /* message text */ +#else + long mtype; /* message type */ + char mtext[1]; /* message text */ +#endif +}; + +/* + * Header and message header structures for msgsnap() system call. + */ +struct msgsnap_head { + size_t msgsnap_size; /* bytes consumed/required in the buffer */ + size_t msgsnap_nmsg; /* number of messages in the buffer */ +}; + +struct msgsnap_mhead { + size_t msgsnap_mlen; /* number of bytes in message that follows */ + long msgsnap_mtype; /* message type */ +}; + +#if !defined(_KERNEL) +int msgctl(int, int, struct msqid_ds *); +int msgget(key_t, int); +int msgids(int *, uint_t, uint_t *); +int msgsnap(int, void *, size_t, long); +ssize_t msgrcv(int, void *, size_t, long, int); +int msgsnd(int, const void *, size_t, int); +#endif /* ! _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MSG_H */ diff --git a/illumos-x86_64/usr/include/sys/msg_impl.h b/illumos-x86_64/usr/include/sys/msg_impl.h new file mode 100644 index 00000000..c11fb81a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/msg_impl.h @@ -0,0 +1,199 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MSG_IMPL_H +#define _SYS_MSG_IMPL_H + +#include +#if defined(_KERNEL) || defined(_KMEMUSER) +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Argument vectors for the various flavors of msgsys(). + */ + +#define MSGGET 0 +#define MSGCTL 1 +#define MSGRCV 2 +#define MSGSND 3 +#define MSGIDS 4 +#define MSGSNAP 5 + +#if defined(_KERNEL) || defined(_KMEMUSER) + +typedef struct msgq_wakeup { + list_node_t msgw_list; + long msgw_type; /* Message type request. */ + long msgw_snd_wake; /* Type of msg from msgsnd */ + size_t msgw_snd_size; /* Designates size of the msg sending */ + kthread_t *msgw_thrd; /* Thread waiting */ + kcondvar_t msgw_wake_cv; /* waiting on this */ +} msgq_wakeup_t; + + +typedef struct msg_select { + msgq_wakeup_t *(*selection)(); + struct msg_select *next_selection; +} msg_select_t; + +/* + * There is one msg structure for each message in the system. + */ +struct msg { + list_node_t msg_node; /* message list node */ + long msg_type; /* message type */ + size_t msg_size; /* message text size */ + void *msg_addr; /* message text address */ + long msg_flags; /* message flags */ + long msg_copycnt; /* current # of copyouts on message */ +}; + +/* + * Per message flags + */ +#define MSG_RCVCOPY 00001 /* msgrcv is copying out this message */ +#define MSG_UNLINKED 00002 /* msg has been unlinked from queue */ + +/* + * msg_rcv_cv is now an array of kcondvar_t for performance reason. + * We use multiple condition variables (kcondvar_t) to avoid needing + * to wake all readers when sending a single message. + */ + +#define MSG_NEG_INTERVAL 8 +#define MSG_MAX_QNUM 64 +#define MSG_MAX_QNUM_CV 65 + +typedef struct kmsqid { + kipc_perm_t msg_perm; /* operation permission struct */ + list_t msg_list; /* list of messages on q */ + msglen_t msg_cbytes; /* current # bytes on q */ + msgqnum_t msg_qnum; /* # of messages on q */ + msgqnum_t msg_qmax; /* max # of messages on q */ + msglen_t msg_qbytes; /* max # of bytes on q */ + pid_t msg_lspid; /* pid of last msgsnd */ + pid_t msg_lrpid; /* pid of last msgrcv */ + time_t msg_stime; /* last msgsnd time */ + time_t msg_rtime; /* last msgrcv time */ + time_t msg_ctime; /* last change time */ + uint_t msg_snd_cnt; /* # of waiting senders */ + uint_t msg_rcv_cnt; /* # of waiting receivers */ + uint64_t msg_lowest_type; /* Smallest type on queue */ + /* + * linked list of routines used to determine what to wake up next. + * msg_fnd_sndr: Routines for waking up readers waiting + * for a message from the sender. + * msg_fnd_rdr: Routines for waking up readers waiting + * for a copyout to finish. + */ + msg_select_t *msg_fnd_sndr; + msg_select_t *msg_fnd_rdr; + /* + * Various counts and queues for controlling the sleeping + * and waking up of processes that are waiting for various + * message queue events. + * + * msg_cpy_block: List of receiving threads that are blocked because + * the message of choice is being copied out. + * msg_wait_snd: List of receiving threads whose type specifier + * is positive or 0 but are blocked because there + * are no matches. + * msg_wait_snd_ngt: + * List of receiving threads whose type specifier is + * negative message type but are blocked because + * there are no types that qualify. + * msg_wait_rcv: List of sending threads that are blocked because + * there is no room left on the message queue. + */ + kcondvar_t msg_snd_cv; + list_t msg_cpy_block; + list_t msg_wait_snd[MSG_MAX_QNUM_CV]; + list_t msg_wait_snd_ngt[MSG_MAX_QNUM_CV]; + list_t msg_wait_rcv; + size_t msg_snd_smallest; /* Smallest msg on send wait list */ + int msg_ngt_cnt; /* # of negative receivers blocked */ + char msg_neg_copy; /* Neg type copy underway */ +} kmsqid_t; + +#endif /* _KERNEL */ + +#if defined(_SYSCALL32) +/* + * LP64 view of the ILP32 msgbuf structure + */ +struct ipcmsgbuf32 { + int32_t mtype; /* message type */ + char mtext[1]; /* message text */ +}; + +/* + * LP64 view of the ILP32 msgsnap_head and msgsnap_mhead structures + */ +struct msgsnap_head32 { + size32_t msgsnap_size; /* bytes consumed/required in the buffer */ + size32_t msgsnap_nmsg; /* number of messages in the buffer */ +}; + +struct msgsnap_mhead32 { + size32_t msgsnap_mlen; /* number of bytes in message that follows */ + int32_t msgsnap_mtype; /* message type */ +}; + +/* + * LP64 view of the ILP32 msqid_ds structure + */ +struct msqid_ds32 { + struct ipc_perm32 msg_perm; /* operation permission struct */ + caddr32_t msg_first; /* ptr to first message on q */ + caddr32_t msg_last; /* ptr to last message on q */ + uint32_t msg_cbytes; /* current # bytes on q */ + uint32_t msg_qnum; /* # of messages on q */ + uint32_t msg_qbytes; /* max # of bytes on q */ + pid32_t msg_lspid; /* pid of last msgsnd */ + pid32_t msg_lrpid; /* pid of last msgrcv */ + time32_t msg_stime; /* last msgsnd time */ + int32_t msg_pad1; /* reserved for time_t expansion */ + time32_t msg_rtime; /* last msgrcv time */ + int32_t msg_pad2; /* time_t expansion */ + time32_t msg_ctime; /* last change time */ + int32_t msg_pad3; /* time expansion */ + int16_t msg_cv; + int16_t msg_qnum_cv; + int32_t msg_pad4[3]; /* reserve area */ +}; +#endif /* _SYSCALL32 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MSG_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/msio.h b/illumos-x86_64/usr/include/sys/msio.h new file mode 100644 index 00000000..1cd8dad6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/msio.h @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MSIO_H +#define _SYS_MSIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Mouse related ioctls + */ +typedef struct { + int jitter_thresh; + int speed_law; + int speed_limit; +} Ms_parms; + +typedef struct { + int height; /* height of the screen */ + int width; /* width of the screen */ +}Ms_screen_resolution; + +#define MSIOC ('m'<<8) /* same as mtio.h - change ? */ +#define MSIOGETPARMS (MSIOC|1) /* get / set jitter, speed */ +#define MSIOSETPARMS (MSIOC|2) /* law, or speed limit */ +#define MSIOBUTTONS (MSIOC|3) /* get number of buttons */ +#define MSIOSRESOLUTION (MSIOC|4) /* Set screen resolution for mouse */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MSIO_H */ diff --git a/illumos-x86_64/usr/include/sys/msreg.h b/illumos-x86_64/usr/include/sys/msreg.h new file mode 100644 index 00000000..b417d362 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/msreg.h @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Software mouse registers + */ + +#ifndef _SYS_MSREG_H +#define _SYS_MSREG_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Mouse sample. + */ +struct mouseinfo { + char mi_x; /* current X coordinate */ + char mi_y; /* current Y coordinate */ + char mi_z; /* current wheel */ + char mi_buttons; /* set of buttons that are currently down */ +#define MS_HW_BUT1 0x4 /* left button position */ +#define MS_HW_BUT2 0x2 /* middle button position */ +#define MS_HW_BUT3 0x1 /* right button position */ + struct timeval32 mi_time; /* timestamp */ +}; + +/* + * Circular buffer storing mouse events. + */ +struct mousebuf { + short mb_size; /* size (in mouseinfo units) of buf */ + short mb_off; /* current offset in buffer */ + struct mouseinfo mb_info[1]; /* however many samples */ +}; + +struct ms_softc { + struct mousebuf *ms_buf; /* pointer to mouse buffer */ + short ms_bufbytes; /* buffer size (in bytes) */ + short ms_flags; /* currently unused */ + short ms_oldoff; /* index into mousebuf */ + short ms_eventstate; /* current event being generated */ + short ms_readformat; /* format of read stream */ +#define MS_3BYTE_FORMAT VUID_NATIVE /* 3 byte format (buts/x/y) */ +#define MS_VUID_FORMAT VUID_FIRM_EVENT /* vuid Firm_event format */ + short ms_vuidaddr; /* vuid addr for MS_VUID_FORMAT */ + char ms_prevbuttons; /* button state as of last message */ + /* sent upstream */ +}; + +#define EVENT_X 0 /* generating delta-X event */ +#define EVENT_Y 1 /* generating delta-Y event */ +#define EVENT_BUT1 2 /* generating button 1 event */ +#define EVENT_BUT2 3 /* generating button 2 event */ +#define EVENT_BUT3 4 /* generating button 3 event */ +#define EVENT_BUT4 5 /* generating button 4 event */ +#define EVENT_BUT5 6 /* generating button 5 event */ +#define EVENT_BUT6 7 /* generating button 6 event */ +#define EVENT_BUT7 8 /* generating button 7 event */ +#define EVENT_BUT8 9 /* generating button 8 event */ +#define EVENT_BUT9 10 /* generating button 9 event */ +#define EVENT_BUT10 11 /* generating button 10 event */ +#define EVENT_WHEEL 12 /* generating wheel event */ + +#define EVENT_BUT(i) (i + 1) + +#ifdef _KERNEL +#define MSIOGETBUF _IOWR('m', 1, int) /* MSIOGETBUF is OBSOLETE */ + /* Get mouse buffer ptr so (window system in particular) can chase */ + /* around buffer to get events. */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MSREG_H */ diff --git a/illumos-x86_64/usr/include/sys/mtio.h b/illumos-x86_64/usr/include/sys/mtio.h new file mode 100644 index 00000000..ef8692e9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mtio.h @@ -0,0 +1,353 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1983-1989 by AT&T. + * All rights reserved. + */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_MTIO_H +#define _SYS_MTIO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structures and definitions for mag tape io control commands + */ + +/* + * structure for MTIOCTOP - mag tape op command + */ +struct mtop { + short mt_op; /* operations defined below */ + daddr_t mt_count; /* how many of them */ +}; + +#if defined(_SYSCALL32) +struct mtop32 { + short mt_op; /* operations defined below */ + daddr32_t mt_count; /* how many of them */ +}; +#endif /* _SYSCALL32 */ + +/* + * structure for MTIOCLTOP - mag tape op command + */ +struct mtlop { + short mt_op; + short pad[3]; + int64_t mt_count; +}; + +/* + * values for mt_op + */ +#define MTWEOF 0 /* write an end-of-file record */ +#define MTFSF 1 /* forward space over file mark */ +#define MTBSF 2 /* backward space over file mark (1/2" only ) */ +#define MTFSR 3 /* forward space to inter-record gap */ +#define MTBSR 4 /* backward space to inter-record gap */ +#define MTREW 5 /* rewind */ +#define MTOFFL 6 /* rewind and put the drive offline */ +#define MTNOP 7 /* no operation, sets status only */ +#define MTRETEN 8 /* retension the tape (cartridge tape only) */ +#define MTERASE 9 /* erase the entire tape */ +#define MTEOM 10 /* position to end of media */ +#define MTNBSF 11 /* backward space file to BOF */ +#define MTSRSZ 12 /* set record size */ +#define MTGRSZ 13 /* get record size */ +#define MTLOAD 14 /* for loading a tape (use o_delay to open */ + /* the tape device) */ +#define MTBSSF 15 /* Backward space to x sequential filemarks */ +#define MTFSSF 16 /* Forward space to x sequential filemarks */ +#define MTTELL 17 /* get current logical block position */ +#define MTSEEK 18 /* position to logical block position */ +#define MTLOCK 19 /* lock media */ +#define MTUNLOCK 20 /* unlock media */ + +/* + * structure for MTIOCGET - mag tape get status command + */ +struct mtget { + short mt_type; /* type of magtape device */ + /* the following two registers are grossly device dependent */ + short mt_dsreg; /* ``drive status'' register */ + short mt_erreg; /* ``error'' register */ + /* optional error info. */ + daddr_t mt_resid; /* residual count */ + daddr_t mt_fileno; /* file number of current position */ + daddr_t mt_blkno; /* block number of current position */ + ushort_t mt_flags; + short mt_bf; /* optimum blocking factor */ +}; + +#if defined(_SYSCALL32) +struct mtget32 { + short mt_type; /* type of magtape device */ + /* the following two registers are grossly device dependent */ + short mt_dsreg; /* ``drive status'' register */ + short mt_erreg; /* ``error'' register */ + /* optional error info. */ + daddr32_t mt_resid; /* residual count */ + daddr32_t mt_fileno; /* file number of current position */ + daddr32_t mt_blkno; /* block number of current position */ + ushort_t mt_flags; + short mt_bf; /* optimum blocking factor */ +}; +#endif /* _SYSCALL32 */ + +#define MT_NDENSITIES 4 +#define MT_NSPEEDS 4 + +/* + * struct for MTIOCGETDRIVETYPE - get tape config data + */ +struct mtdrivetype { + char name[64]; /* Name, for debug */ + char vid[25]; /* Vendor id and model (product) id */ + char type; /* Drive type for driver */ + int bsize; /* Block size */ + int options; /* Drive options */ + int max_rretries; /* Max read retries */ + int max_wretries; /* Max write retries */ + uchar_t densities[MT_NDENSITIES]; /* density codes, low->hi */ + uchar_t default_density; /* Default density chosen */ + uchar_t speeds[MT_NSPEEDS]; /* speed codes, low->hi */ + ushort_t non_motion_timeout; /* Inquiry type commands */ + ushort_t io_timeout; /* io timeout. seconds */ + ushort_t rewind_timeout; /* rewind timeout. seconds */ + ushort_t space_timeout; /* space cmd timeout. seconds */ + ushort_t load_timeout; /* load tape time in seconds */ + ushort_t unload_timeout; /* Unload tape time in scounds */ + ushort_t erase_timeout; /* erase timeout. seconds */ +}; + +/* + * struct for MTIOCGETERROR - get recent error entry command + */ +struct mterror_entry { + size_t mtee_cdb_len; /* CDB length */ + uchar_t *mtee_cdb_buf; /* CDB sent to the device */ + size_t mtee_arq_status_len; /* length of scsi arq status */ + struct scsi_arq_status *mtee_arq_status; + /* scsi arq status buffer */ +}; + +#define MTERROR_ENTRY_SIZE_64 (sizeof (struct mterror_entry)) + +#if defined(_SYSCALL32) +struct mterror_entry32 { + size32_t mtee_cdb_len; /* CDB length */ + caddr32_t mtee_cdb_buf; /* CDB sent to the device */ + size32_t mtee_arq_status_len; /* length of scsi arq status */ + caddr32_t mtee_arq_status; + /* scsi arq status buffer */ +}; + +#define MTERROR_ENTRY_SIZE_32 (sizeof (struct mterror_entry32)) + +#endif /* _SYSCALL32 */ + +/* + * error entry stack + */ +struct mterror_entry_stack { + struct mterror_entry mtees_entry; + struct mterror_entry_stack *mtees_nextp; +}; + +#define MTERROR_LINK_ENTRY_SIZE (sizeof (struct mterror_entry_stack)) + +struct mtdrivetype_request { + int size; + struct mtdrivetype *mtdtp; +}; + +#if defined(_SYSCALL32) +struct mtdrivetype_request32 { + int size; + caddr32_t mtdtp; +}; +#endif /* _SYSCALL32 */ + + +/* + * values for mt_flags + */ +#define MTF_SCSI 0x01 +#define MTF_REEL 0x02 +#define MTF_ASF 0x04 + +#define MTF_TAPE_HEAD_DIRTY 0x08 +#define MTF_TAPE_CLN_SUPPORTED 0x10 +#define MTF_WORM_MEDIA 0x20 +#define MTF_LOGICAL_BLOCK 0x40 + +/* + * Constants for mt_type byte (these are somewhat obsolete) + */ +#define MT_ISTS 0x01 /* vax: unibus ts-11 */ +#define MT_ISHT 0x02 /* vax: massbus tu77, etc */ +#define MT_ISTM 0x03 /* vax: unibus tm-11 */ +#define MT_ISMT 0x04 /* vax: massbus tu78 */ +#define MT_ISUT 0x05 /* vax: unibus gcr */ +#define MT_ISCPC 0x06 /* sun: multibus cpc */ +#define MT_ISAR 0x07 /* sun: multibus archive */ +#define MT_ISSC 0x08 /* sun: SCSI archive */ +#define MT_ISSYSGEN11 0x10 /* sun: SCSI Sysgen, QIC-11 only */ +#define MT_ISSYSGEN 0x11 /* sun: SCSI Sysgen QIC-24/11 */ +#define MT_ISDEFAULT 0x12 /* sun: SCSI default CCS */ +#define MT_ISCCS3 0x13 /* sun: SCSI generic (unknown) CCS */ +#define MT_ISMT02 0x14 /* sun: SCSI Emulex MT02 */ +#define MT_ISVIPER1 0x15 /* sun: SCSI Archive QIC-150 Viper */ +#define MT_ISWANGTEK1 0x16 /* sun: SCSI Wangtek QIC-150 */ +#define MT_ISCCS7 0x17 /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS8 0x18 /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS9 0x19 /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS11 0x1a /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS12 0x1b /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS13 0x1c /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS14 0x1d /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS15 0x1e /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS16 0x1f /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCDC 0x20 /* sun: SCSI CDC 1/2" cartridge */ +#define MT_ISFUJI 0x21 /* sun: SCSI Fujitsu 1/2" cartridge */ +#define MT_ISKENNEDY 0x22 /* sun: SCSI Kennedy 1/2" reel */ +#define MT_ISHP 0x23 /* sun: SCSI HP 1/2" reel */ +#define MT_ISSTC 0x24 /* sun: SCSI IBM STC 3490 */ +#define MT_ISANRITSU 0x25 /* nihon sun: Anritsu 1/2" reel */ +#define MT_ISCCS23 0x26 /* sun: SCSI generic 1/2" */ +#define MT_ISCCS24 0x27 /* sun: SCSI generic 1/2" */ +#define MT_ISEXABYTE 0x28 /* sun: SCSI Exabyte 8mm cartridge */ +#define MT_ISEXB8500 0x29 /* sun: SCSI Exabyte 8500 8mm cart */ +#define MT_ISWANGTHS 0x2a /* sun: SCSI Wangtek 6130HS RDAT */ +#define MT_ISWANGDAT 0x2b /* sun: SCSI WangDAT */ +#define MT_ISPYTHON 0x2c /* sun: SCSI Archive Python DAT */ +#define MT_ISCCS28 0x2d /* sun: SCSI generic DAT CCS */ +#define MT_ISCCS29 0x2e /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS30 0x2f /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS31 0x30 /* sun: SCSI generic (unknown) CCS */ +#define MT_ISCCS32 0x31 /* sun: SCSI generic (unknown) CCS */ + + +/* + * these are recommended + */ +#define MT_ISQIC 0x32 /* generic QIC tape drive */ +#define MT_ISREEL 0x33 /* generic reel tape drive */ +#define MT_ISDAT 0x34 /* generic DAT tape drive */ +#define MT_IS8MM 0x35 /* generic 8mm tape drive */ +#define MT_ISOTHER 0x36 /* generic other type of tape drive */ + +/* more Sun devices */ +#define MT_ISTAND25G 0x37 /* sun: SCSI Tandberg 2.5 Gig QIC */ +#define MT_ISDLT 0x38 /* sun: SCSI DLT tape drive */ +#define MT_ISSTK9840 0x39 /* sun: STK 9840, 9940, 9840B */ +#define MT_ISBMDLT1 0x3a /* sun: Benchmark DLT1 */ +#define MT_LTO 0x3b /* sun: LTO,s by Hp, Seagate, IBM .. */ +#define MT_ISAIT 0x3c /* Sony: AIT I II III and SAIT */ + +/* + * Device table structure and data for looking tape name from + * tape id number. Used by mt.c. + */ +struct mt_tape_info { + short t_type; /* type of magtape device */ + char *t_name; /* printing name */ + char *t_dsbits; /* "drive status" register */ + char *t_erbits; /* "error" register */ +}; + + +/* mag tape io control commands */ +#define MTIOC ('m'<<8) +#define MTIOCTOP (MTIOC|1) /* do a mag tape op */ +#define MTIOCGET (MTIOC|2) /* get tape status */ +#define MTIOCGETDRIVETYPE (MTIOC|3) /* get tape config data */ +#define MTIOCPERSISTENT (MTIOC|4) /* turn on persistent errors */ +#define MTIOCPERSISTENTSTATUS (MTIOC|5) /* query persis. err status */ +#define MTIOCLRERR (MTIOC|6) /* clear a persitent error */ +#define MTIOCGUARANTEEDORDER (MTIOC|7) /* check for guaranteed order */ +#define MTIOCRESERVE (MTIOC|8) /* preserve reserve */ +#define MTIOCRELEASE (MTIOC|9) /* turnoff preserve reserve */ +#define MTIOCFORCERESERVE (MTIOC|10) /* break reservation drive */ +#define MTIOCGETERROR (MTIOC|11) /* Get recently error record */ +#define MTIOCSTATE (MTIOC|13) /* Inquire insert/eject state */ + +#define MTIOCREADIGNOREILI (MTIOC|14) /* Enable/Disable ILI */ +#define MTIOCREADIGNOREEOFS (MTIOC|15) /* Enable/Disable Ignore EOF */ +#define MTIOCSHORTFMK (MTIOC|16) /* Enable/Disable Short FMK */ +#define MTIOCGETPOS (MTIOC|17) /* Get drive position */ +#define MTIOCRESTPOS (MTIOC|18) /* Go back to position */ +#define MTIOCLTOP (MTIOC|19) /* do a mag tape op */ + +/* + * This state enum is the argument passed to the MTIOCSTATE ioctl. + */ +enum mtio_state { MTIO_NONE, MTIO_EJECTED, MTIO_INSERTED }; + +#ifndef KERNEL +/* + * don't use DEFTAPE. + */ +#define DEFTAPE "/dev/rmt/0" +#endif + +/* + * Layout of minor device byte + * 15 - 8 7 6 5 4 3 2 1 0 + * -------------------------------------------- + * | | | | | | | | |----| Unit #. lower 2 bits + * | | | | | | | |---------- No rewind on close bit.... + * | | | | | |----|--------------- Density Select + * | | | | |------------------------- Resrvd.(add. campus dens. bit) + * | | | |------------------------------ BSD behavior + * |----|----|----------------------------------- Unit # bit 2-10 + */ + +#define MTUNIT(dev) (((getminor(dev) & 0xff80) >> 5) + \ + (getminor(dev) & 0x3)) +#define MT_NOREWIND (1 <<2) +#define MT_DENSITY_MASK (3 <<3) +#define MT_DENSITY1 (0 <<3) /* Lowest density/format */ +#define MT_DENSITY2 (1 <<3) +#define MT_DENSITY3 (2 <<3) +#define MT_DENSITY4 (3 <<3) /* Highest density/format */ +#define MTMINOR(unit) ((((unit) & 0x7fc) << 5) + ((unit) & 0x3)) +#define MT_BSD (1 <<6) /* BSD behavior on close */ +#define MT_DENSITY(dev) ((getminor(dev) & MT_DENSITY_MASK) >> 3) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MTIO_H */ diff --git a/illumos-x86_64/usr/include/sys/mutex.h b/illumos-x86_64/usr/include/sys/mutex.h new file mode 100644 index 00000000..7f6dc8ae --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mutex.h @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_MUTEX_H +#define _SYS_MUTEX_H + +#ifndef _ASM +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* + * Public interface to mutual exclusion locks. See mutex(9F) for details. + * + * The basic mutex type is MUTEX_ADAPTIVE, which is expected to be used + * in almost all of the kernel. MUTEX_SPIN provides interrupt blocking + * and must be used in interrupt handlers above LOCK_LEVEL. The iblock + * cookie argument to mutex_init() encodes the interrupt level to block. + * The iblock cookie must be NULL for adaptive locks. + * + * MUTEX_DEFAULT is the type usually specified (except in drivers) to + * mutex_init(). It is identical to MUTEX_ADAPTIVE. + * + * MUTEX_DRIVER is always used by drivers. mutex_init() converts this to + * either MUTEX_ADAPTIVE or MUTEX_SPIN depending on the iblock cookie. + * + * Mutex statistics can be gathered on the fly, without rebooting or + * recompiling the kernel, via the lockstat driver (lockstat(4D)). + */ +typedef enum { + MUTEX_ADAPTIVE = 0, /* spin if owner is running, otherwise block */ + MUTEX_SPIN = 1, /* block interrupts and spin */ + MUTEX_DRIVER = 4, /* driver (DDI) mutex */ + MUTEX_DEFAULT = 6 /* kernel default mutex */ +} kmutex_type_t; + +typedef struct mutex { +#ifdef _LP64 + void *_opaque[1]; +#else + void *_opaque[2]; +#endif +} kmutex_t; + +#ifdef _KERNEL + +/* + * A padded mutex, one per 64 byte cache line. Use when false sharing is + * an issue but beware of the extra memory it uses. Consumers may want to + * consider aligning their pad_mutex_t's to a cache line boundary as well. + */ +typedef struct pad_mutex { + kmutex_t pad_mutex; +#ifdef _LP64 + char pad_pad[64 - sizeof (kmutex_t)]; +#endif +} pad_mutex_t; + +#define MUTEX_HELD(x) (mutex_owned(x)) +#define MUTEX_NOT_HELD(x) (!mutex_owned(x) || panicstr || quiesce_active) + +extern void mutex_init(kmutex_t *, char *, kmutex_type_t, void *); +extern void mutex_destroy(kmutex_t *); +extern void mutex_enter(kmutex_t *); +extern int mutex_tryenter(kmutex_t *); +extern void mutex_exit(kmutex_t *); +extern int mutex_owned(const kmutex_t *); +extern struct _kthread *mutex_owner(const kmutex_t *); + +extern ushort_t mutex_backoff_base; +extern uint_t mutex_backoff_cap; +extern ushort_t mutex_cap_factor; +extern uchar_t mutex_backoff_shift; +extern void (*mutex_lock_delay)(uint_t); +extern uint_t (*mutex_lock_backoff)(uint_t); +extern void (*mutex_delay)(void); +extern void mutex_delay_default(void); +extern void mutex_sync(void); + +extern void default_lock_delay(uint_t); +extern uint_t default_lock_backoff(uint_t); + +#endif /* _KERNEL */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MUTEX_H */ diff --git a/illumos-x86_64/usr/include/sys/mutex_impl.h b/illumos-x86_64/usr/include/sys/mutex_impl.h new file mode 100644 index 00000000..ae61ac0a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/mutex_impl.h @@ -0,0 +1,133 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MUTEX_IMPL_H +#define _SYS_MUTEX_IMPL_H + +#ifndef _ASM +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* + * mutex_enter() assumes that the mutex is adaptive and tries to grab the + * lock by doing a atomic compare and exchange on the first word of the mutex. + * If the compare and exchange fails, it means that either (1) the lock is a + * spin lock, or (2) the lock is adaptive but already held. + * mutex_vector_enter() distinguishes these cases by looking at the mutex + * type, which is encoded in the low-order bits of the owner field. + */ +typedef union mutex_impl { + /* + * Adaptive mutex. + */ + struct adaptive_mutex { + uintptr_t _m_owner; /* 0-3/0-7 owner and waiters bit */ +#ifndef _LP64 + uintptr_t _m_filler; /* 4-7 unused */ +#endif + } m_adaptive; + + /* + * Spin Mutex. + */ + struct spin_mutex { + lock_t m_dummylock; /* 0 dummy lock (always set) */ + lock_t m_spinlock; /* 1 real lock */ + ushort_t m_filler; /* 2-3 unused */ + ushort_t m_oldspl; /* 4-5 old pil value */ + ushort_t m_minspl; /* 6-7 min pil val if lock held */ + } m_spin; + +} mutex_impl_t; + +#define m_owner m_adaptive._m_owner + +#define MUTEX_ALIGN _LONG_ALIGNMENT +#define MUTEX_ALIGN_WARNINGS 10 /* num of warnings to issue */ + +#define MUTEX_WAITERS 0x1 +#define MUTEX_DEAD 0x6 +#define MUTEX_THREAD (-0x8) + +#define MUTEX_OWNER(lp) ((kthread_id_t)((lp)->m_owner & MUTEX_THREAD)) +#define MUTEX_NO_OWNER ((kthread_id_t)NULL) + +#define MUTEX_SET_WAITERS(lp) \ +{ \ + uintptr_t old; \ + while ((old = (lp)->m_owner) != 0 && \ + casip(&(lp)->m_owner, old, old | MUTEX_WAITERS) != old) \ + continue; \ +} + +#define MUTEX_HAS_WAITERS(lp) ((lp)->m_owner & MUTEX_WAITERS) +#define MUTEX_CLEAR_LOCK_AND_WAITERS(lp) (lp)->m_owner = 0 + +#define MUTEX_SET_TYPE(lp, type) +#define MUTEX_TYPE_ADAPTIVE(lp) (((lp)->m_owner & MUTEX_DEAD) == 0) +#define MUTEX_TYPE_SPIN(lp) ((lp)->m_spin.m_dummylock == LOCK_HELD_VALUE) + +#define MUTEX_DESTROY(lp) \ + (lp)->m_owner = ((uintptr_t)curthread | MUTEX_DEAD) +/* mutex backoff delay macro and constants */ +#define MUTEX_BACKOFF_BASE 1 +#define MUTEX_BACKOFF_SHIFT 2 +#define MUTEX_CAP_FACTOR 64 +#define MUTEX_DELAY() { \ + mutex_delay(); \ + SMT_PAUSE(); \ + } + +/* low overhead clock read */ +#define MUTEX_GETTICK() tsc_read() +extern void null_xcall(void); +#define MUTEX_SYNC() { \ + cpuset_t set; \ + CPUSET_ALL(set); \ + xc_call(0, 0, 0, CPUSET2BV(set), \ + (xc_func_t)null_xcall); \ + } + +extern int mutex_adaptive_tryenter(mutex_impl_t *); +extern void *mutex_owner_running(mutex_impl_t *); + +#else /* _ASM */ + +#define MUTEX_THREAD -0x8 + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MUTEX_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/nbmlock.h b/illumos-x86_64/usr/include/sys/nbmlock.h new file mode 100644 index 00000000..6c9d5b8e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nbmlock.h @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NBMLOCK_H +#define _NBMLOCK_H + +/* + * Non-blocking mandatory locking support. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * Type of operation; used when checking for lock/share conflict. + * NBL_READWRITE is used for checking for a conflict with an exclusive lock + * (F_WRLCK) or a read-write mmap request. For checking an actual I/O + * request, use NBL_READ or NBL_WRITE. + */ +typedef enum {NBL_READ, NBL_WRITE, NBL_RENAME, NBL_REMOVE, + NBL_READWRITE} nbl_op_t; + +/* critical region primitives */ +extern void nbl_start_crit(vnode_t *, krw_t); +extern void nbl_end_crit(vnode_t *); +extern int nbl_in_crit(vnode_t *); + +/* conflict checking */ +extern int nbl_need_check(vnode_t *); +extern int nbl_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int, + caller_context_t *); +extern int nbl_share_conflict(vnode_t *, nbl_op_t, caller_context_t *); +extern int nbl_lock_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int, + caller_context_t *); +extern int nbl_svmand(vnode_t *, cred_t *, int *); + + +#ifdef __cplusplus +} +#endif + +#endif /* _NBMLOCK_H */ diff --git a/illumos-x86_64/usr/include/sys/ndi_impldefs.h b/illumos-x86_64/usr/include/sys/ndi_impldefs.h new file mode 100644 index 00000000..d5adf5d2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ndi_impldefs.h @@ -0,0 +1,136 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_NDI_IMPLDEFS_H +#define _SYS_NDI_IMPLDEFS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* event handle for callback management */ +struct ndi_event_hdl { + dev_info_t *ndi_evthdl_dip; + + /* + * mutex that protect the handle and event defs + */ + kmutex_t ndi_evthdl_mutex; + + /* + * mutex that just protects the callback list + */ + kmutex_t ndi_evthdl_cb_mutex; + + ddi_iblock_cookie_t ndi_evthdl_iblock_cookie; + + uint_t ndi_evthdl_high_plevels; + uint_t ndi_evthdl_other_plevels; + + uint_t ndi_evthdl_n_events; + ndi_event_cookie_t *ndi_evthdl_cookie_list; + ndi_event_hdl_t ndi_next_hdl; +}; + +/* prototypes needed by sunndi.c */ +int ddi_prop_fm_encode_bytes(prop_handle_t *, void *data, uint_t); + +int ddi_prop_fm_encode_ints(prop_handle_t *, void *data, uint_t); + +int ddi_prop_fm_encode_int64(prop_handle_t *, void *data, uint_t); + +int ddi_prop_int64_op(prop_handle_t *, uint_t, int64_t *); + +int ddi_prop_update_common(dev_t, dev_info_t *, int, char *, void *, uint_t, + int (*)(prop_handle_t *, void *, uint_t)); + +int ddi_prop_lookup_common(dev_t, dev_info_t *, uint_t, char *, void *, + uint_t *, int (*)(prop_handle_t *, void *, uint_t *)); + +int ddi_prop_remove_common(dev_t, dev_info_t *, char *, int); +void ddi_prop_remove_all_common(dev_info_t *, int); + +int ddi_prop_fm_encode_string(prop_handle_t *, void *, uint_t); + +int ddi_prop_fm_encode_strings(prop_handle_t *, void *, uint_t); +int ddi_prop_fm_decode_strings(prop_handle_t *, void *, uint_t *); + +/* + * Internal configuration routines + */ +int i_ndi_config_node(dev_info_t *, ddi_node_state_t, uint_t); +int i_ndi_unconfig_node(dev_info_t *, ddi_node_state_t, uint_t); + +/* + * Obsolete interface, no longer used, to be removed. + * Retained only for driver compatibility. + */ +void i_ndi_block_device_tree_changes(uint_t *); /* obsolete */ +void i_ndi_allow_device_tree_changes(uint_t); /* obsolete */ + +/* + * ndi_dev_is_auto_assigned_node: Return non-zero if the nodeid in dev + * has been auto-assigned by the framework and should be auto-freed. + * (Intended for use by the framework only.) + */ +int i_ndi_dev_is_auto_assigned_node(dev_info_t *); + +/* + * Get and set nodeclass and node attributes. + * (Intended for ddi framework use only.) + */ +ddi_node_class_t i_ndi_get_node_class(dev_info_t *); +void i_ndi_set_node_class(dev_info_t *, ddi_node_class_t); + +int i_ndi_get_node_attributes(dev_info_t *); +void i_ndi_set_node_attributes(dev_info_t *, int); + +/* + * Set nodeid .. not generally advisable. + * (Intended for the ddi framework use only.) + */ +void i_ndi_set_nodeid(dev_info_t *, int); + +/* + * Make driver.conf children. + * (Intended for the ddi framework use only.) + */ +int i_ndi_make_spec_children(dev_info_t *, uint_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NDI_IMPLDEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/ndifm.h b/illumos-x86_64/usr/include/sys/ndifm.h new file mode 100644 index 00000000..962fee08 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ndifm.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_NDIFM_H +#define _SYS_NDIFM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* FM handle cache support */ +#define DMA_HANDLE 0 +#define ACC_HANDLE 1 +#define DEFAULT_DMACACHE_SZ 100 +#define DEFAULT_ACCCACHE_SZ 10 + +extern int default_dmacache_sz; +extern int default_acccache_sz; + +/* Forward declarations for FM NDI */ + +typedef struct i_ddi_fmc ndi_fmc_t; +typedef struct i_ddi_fmc_entry ndi_fmcentry_t; + +/* Per-handle NDI error status */ +typedef struct i_ndi_err { + uint64_t err_ena; /* ENA for this error */ + int err_status; /* error status */ + int err_expected; /* was this error expected? */ + void *err_ontrap; /* ontrap protection, if any */ + struct i_ddi_fmc_entry *err_fep; /* FM cache link */ + int (*err_cf)(); /* compare function */ +} ndi_err_t; + +#ifdef _KERNEL + +extern void ndi_fmc_insert(dev_info_t *, int, void *, void *); +extern void ndi_fmc_remove(dev_info_t *, int, const void *); +extern int ndi_fmc_error(dev_info_t *, dev_info_t *, int, uint64_t, + const void *); +extern int ndi_fmc_entry_error(dev_info_t *, int, ddi_fm_error_t *, + const void *); +extern int ndi_fmc_entry_error_all(dev_info_t *, int, ddi_fm_error_t *); + +extern int ndi_fm_handler_dispatch(dev_info_t *, dev_info_t *, + const ddi_fm_error_t *); +extern int i_ddi_fm_handler_dispatch(dev_info_t *, const ddi_fm_error_t *); + +extern void ndi_fm_acc_err_set(ddi_acc_handle_t, ddi_fm_error_t *); +extern void ndi_fm_dma_err_set(ddi_dma_handle_t, ddi_fm_error_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NDIFM_H */ diff --git a/illumos-x86_64/usr/include/sys/netconfig.h b/illumos-x86_64/usr/include/sys/netconfig.h new file mode 100644 index 00000000..658f9f3f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/netconfig.h @@ -0,0 +1,156 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. + */ + +#ifndef _SYS_NETCONFIG_H +#define _SYS_NETCONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define NETCONFIG "/etc/netconfig" +#define NETPATH "NETPATH" + +struct netconfig { + char *nc_netid; /* network identifier */ + unsigned int nc_semantics; /* defined below */ + unsigned int nc_flag; /* defined below */ + char *nc_protofmly; /* protocol family name */ + char *nc_proto; /* protocol name */ + char *nc_device; /* device name for network id */ + unsigned int nc_nlookups; /* # of entries in nc_lookups */ + char **nc_lookups; /* list of lookup directories */ + unsigned int nc_unused[8]; /* borrowed for lockd etc. */ +}; + +typedef struct { + struct netconfig **nc_head; + struct netconfig **nc_curr; +} NCONF_HANDLE; + +/* + * Values of nc_semantics + */ + +#define NC_TPI_CLTS 1 +#define NC_TPI_COTS 2 +#define NC_TPI_COTS_ORD 3 +#define NC_TPI_RAW 4 +/* + * NOT FOR PUBLIC USE, Solaris internal only. + * This value of nc_semantics is strictly for use of Remote Direct + * Memory Access provider interfaces in Solaris only and not for + * general use. Do not use this value for general purpose user or + * kernel programming. If used the behavior is undefined. + * This is a PRIVATE interface to be used by Solaris kRPC only. + */ +#define NC_TPI_RDMA 5 + +/* + * Values of nc_flag + */ + +#define NC_NOFLAG 00 +#define NC_VISIBLE 01 +#define NC_BROADCAST 02 + +/* + * Values of nc_protofmly + */ + +#define NC_NOPROTOFMLY "-" +#define NC_LOOPBACK "loopback" +#define NC_INET "inet" +#define NC_INET6 "inet6" +#define NC_IMPLINK "implink" +#define NC_PUP "pup" +#define NC_CHAOS "chaos" +#define NC_NS "ns" +#define NC_NBS "nbs" +#define NC_ECMA "ecma" +#define NC_DATAKIT "datakit" +#define NC_CCITT "ccitt" +#define NC_SNA "sna" +#define NC_DECNET "decnet" +#define NC_DLI "dli" +#define NC_LAT "lat" +#define NC_HYLINK "hylink" +#define NC_APPLETALK "appletalk" +#define NC_NIT "nit" +#define NC_IEEE802 "ieee802" +#define NC_OSI "osi" +#define NC_X25 "x25" +#define NC_OSINET "osinet" +#define NC_GOSIP "gosip" +/* + * NOT FOR PUBLIC USE, Solaris internal only. + * This value of nc_semantics is strictly for use of Remote Direct + * Memory Access provider interfaces in Solaris only and not for + * general use. Do not use this value for general purpose user or + * kernel programming. If used the behavior is undefined. + * This is a PRIVATE interface to be used by Solaris kRPC only. + */ +#define NC_RDMA "rdma" + +/* + * Values for nc_proto + */ + +#define NC_NOPROTO "-" +#define NC_TCP "tcp" +#define NC_UDP "udp" +#define NC_ICMP "icmp" + +/* + * Values for nc_proto for "rdma" protofmly + */ +#define NC_KVIPL "kvipl" +#define NC_IBTF "ibtf" +#define NC_KDAPL "kdapl" + +extern void *setnetconfig(void); +extern int endnetconfig(void *); +extern struct netconfig *getnetconfig(void *); +extern struct netconfig *getnetconfigent(const char *); +extern void freenetconfigent(struct netconfig *); +extern void *setnetpath(void); +extern int endnetpath(void *); +extern struct netconfig *getnetpath(void *); +extern void nc_perror(const char *); +extern char *nc_sperror(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NETCONFIG_H */ diff --git a/illumos-x86_64/usr/include/sys/neti.h b/illumos-x86_64/usr/include/sys/neti.h new file mode 100644 index 00000000..e7027f8e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/neti.h @@ -0,0 +1,301 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018, Joyent, Inc. + */ + +#ifndef _SYS_NETI_H +#define _SYS_NETI_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct msgb; /* avoiding sys/stream.h here */ + +#define NETINFO_VERSION 1 + +/* + * Network hooks framework stack protocol name + */ +#define NHF_INET "NHF_INET" +#define NHF_INET6 "NHF_INET6" +#define NHF_ARP "NHF_ARP" +#define NHF_VIONA "NHF_VIONA" + +/* + * Event identification + */ +#define NH_PHYSICAL_IN "PHYSICAL_IN" +#define NH_PHYSICAL_OUT "PHYSICAL_OUT" +#define NH_FORWARDING "FORWARDING" +#define NH_LOOPBACK_IN "LOOPBACK_IN" +#define NH_LOOPBACK_OUT "LOOPBACK_OUT" +#define NH_NIC_EVENTS "NIC_EVENTS" +#define NH_OBSERVE "OBSERVING" + +/* + * Network NIC hardware checksum capability + */ +#define NET_HCK_NONE 0x00 +#define NET_HCK_L3_FULL 0x01 +#define NET_HCK_L3_PART 0x02 +#define NET_HCK_L4_FULL 0x10 +#define NET_HCK_L4_PART 0x20 + +#define NET_IS_HCK_L3_FULL(n, x) \ + ((net_ispartialchecksum(n, x) & NET_HCK_L3_FULL) == NET_HCK_L3_FULL) +#define NET_IS_HCK_L3_PART(n, x) \ + ((net_ispartialchecksum(n, x) & NET_HCK_L3_PART) == NET_HCK_L3_PART) +#define NET_IS_HCK_L4_FULL(n, x) \ + ((net_ispartialchecksum(n, x) & NET_HCK_L4_FULL) == NET_HCK_L4_FULL) +#define NET_IS_HCK_L4_PART(n, x) \ + ((net_ispartialchecksum(n, x) & NET_HCK_L4_PART) == NET_HCK_L4_PART) +#define NET_IS_HCK_L34_FULL(n, x) \ + ((net_ispartialchecksum(n, x) & (NET_HCK_L3_FULL|NET_HCK_L4_FULL)) \ + == (NET_HCK_L3_FULL | NET_HCK_L4_FULL)) + +typedef uintptr_t phy_if_t; +typedef intptr_t lif_if_t; +typedef uintptr_t net_ifdata_t; +typedef id_t netid_t; + +/* + * Netinfo interface specification + * + * Netinfo provides an extensible and easy to use interface for + * accessing data and functionality already embedded within network + * code that exists within the kernel. + */ +typedef enum net_ifaddr { + NA_ADDRESS = 1, + NA_PEER, + NA_BROADCAST, + NA_NETMASK +} net_ifaddr_t; + + +typedef enum inject { + NI_QUEUE_IN = 1, + NI_QUEUE_OUT, + NI_DIRECT_OUT +} inject_t; + +/* + * net_inject - public interface + */ +typedef struct net_inject { + int ni_version; + netid_t ni_netid; + struct msgb *ni_packet; + struct sockaddr_storage ni_addr; + phy_if_t ni_physical; +} net_inject_t; + +typedef struct net_data *net_handle_t; + +/* + * net_protocol_t private interface + */ +struct net_protocol_s { + int netp_version; + char *netp_name; + int (*netp_getifname)(net_handle_t, phy_if_t, char *, + const size_t); + int (*netp_getmtu)(net_handle_t, phy_if_t, lif_if_t); + int (*netp_getpmtuenabled)(net_handle_t); + int (*netp_getlifaddr)(net_handle_t, phy_if_t, lif_if_t, + size_t, net_ifaddr_t [], void *); + int (*neti_getlifzone)(net_handle_t, phy_if_t, lif_if_t, + zoneid_t *); + int (*neti_getlifflags)(net_handle_t, phy_if_t, lif_if_t, + uint64_t *); + phy_if_t (*netp_phygetnext)(net_handle_t, phy_if_t); + phy_if_t (*netp_phylookup)(net_handle_t, const char *); + lif_if_t (*netp_lifgetnext)(net_handle_t, phy_if_t, lif_if_t); + int (*netp_inject)(net_handle_t, inject_t, net_inject_t *); + phy_if_t (*netp_routeto)(net_handle_t, struct sockaddr *, + struct sockaddr *); + int (*netp_ispartialchecksum)(net_handle_t, struct msgb *); + int (*netp_isvalidchecksum)(net_handle_t, struct msgb *); +}; +typedef struct net_protocol_s net_protocol_t; + + +/* + * Private data structures + */ +struct net_data { + LIST_ENTRY(net_data) netd_list; + net_protocol_t netd_info; + int netd_refcnt; + hook_family_int_t *netd_hooks; + struct neti_stack_s *netd_stack; + int netd_condemned; +}; + + +typedef struct injection_s { + net_inject_t inj_data; + boolean_t inj_isv6; + void * inj_ptr; +} injection_t; + +/* + * The ipif_id space is [0,MAX) but this interface wants to return [1,MAX] as + * a valid range of logical interface numbers so that it can return 0 to mean + * "end of list" with net_lifgetnext. Changing ipif_id's to use the [1,MAX] + * space is something to be considered for the future, if it is worthwhile. + */ +#define MAP_IPIF_ID(x) ((x) + 1) +#define UNMAP_IPIF_ID(x) (((x) > 0) ? (x) - 1 : (x)) + +struct net_instance_s { + int nin_version; + char *nin_name; + void *(*nin_create)(const netid_t); + void (*nin_destroy)(const netid_t, void *); + void (*nin_shutdown)(const netid_t, void *); +}; +typedef struct net_instance_s net_instance_t; + +struct net_instance_int_s { + LIST_ENTRY(net_instance_int_s) nini_next; + uint_t nini_ref; + void *nini_created; + struct net_instance_int_s *nini_parent; + net_instance_t *nini_instance; + hook_notify_t nini_notify; + uint32_t nini_flags; + kcondvar_t nini_cv; + boolean_t nini_condemned; +}; +typedef struct net_instance_int_s net_instance_int_t; +LIST_HEAD(nini_head_s, net_instance_int_s); +typedef struct nini_head_s nini_head_t; + +#define nini_version nini_instance->nin_version +#define nini_name nini_instance->nin_name +#define nini_create nini_instance->nin_create +#define nini_destroy nini_instance->nin_destroy +#define nini_shutdown nini_instance->nin_shutdown + +/* + * netinfo stack instances + */ +struct neti_stack_s { + kmutex_t nts_lock; + LIST_ENTRY(neti_stack_s) nts_next; + netid_t nts_id; + zoneid_t nts_zoneid; + netstackid_t nts_stackid; + netstack_t *nts_netstack; + nini_head_t nts_instances; + uint32_t nts_flags; + kcondvar_t nts_cv; + /* list of net_handle_t */ + LIST_HEAD(netd_listhead, net_data) nts_netd_head; +}; +typedef struct neti_stack_s neti_stack_t; +LIST_HEAD(neti_stack_head_s, neti_stack_s); +typedef struct neti_stack_head_s neti_stack_head_t; + +/* + * Internal functions that need to be exported within the module. + */ +extern void neti_init(void); +extern void neti_fini(void); +extern neti_stack_t *net_getnetistackbyid(netid_t); +extern netstackid_t net_getnetstackidbynetid(netid_t); +extern netid_t net_getnetidbynetstackid(netstackid_t); +extern netid_t net_zoneidtonetid(zoneid_t); +extern zoneid_t net_getzoneidbynetid(netid_t); + +/* + * Functions available for public use. + */ +extern hook_event_token_t net_event_register(net_handle_t, hook_event_t *); +extern int net_event_shutdown(net_handle_t, hook_event_t *); +extern int net_event_unregister(net_handle_t, hook_event_t *); +extern int net_event_notify_register(net_handle_t, char *, + hook_notify_fn_t, void *); +extern int net_event_notify_unregister(net_handle_t, char *, hook_notify_fn_t); + +extern int net_family_register(net_handle_t, hook_family_t *); +extern int net_family_shutdown(net_handle_t, hook_family_t *); +extern int net_family_unregister(net_handle_t, hook_family_t *); + +extern int net_hook_register(net_handle_t, char *, hook_t *); +extern int net_hook_unregister(net_handle_t, char *, hook_t *); + +extern int net_inject(net_handle_t, inject_t, net_inject_t *); +extern net_inject_t *net_inject_alloc(const int); +extern void net_inject_free(net_inject_t *); + +extern net_instance_t *net_instance_alloc(const int version); +extern void net_instance_free(net_instance_t *); +extern int net_instance_register(net_instance_t *); +extern int net_instance_unregister(net_instance_t *); +extern int net_instance_notify_register(netid_t, hook_notify_fn_t, void *); +extern int net_instance_notify_unregister(netid_t netid, hook_notify_fn_t); + +extern kstat_t *net_kstat_create(netid_t, char *, int, char *, char *, + uchar_t, ulong_t, uchar_t); +extern void net_kstat_delete(netid_t, kstat_t *); + +extern net_handle_t net_protocol_lookup(netid_t, const char *); +extern net_handle_t net_protocol_register(netid_t, const net_protocol_t *); +extern int net_protocol_release(net_handle_t); +extern int net_protocol_unregister(net_handle_t); +extern net_handle_t net_protocol_walk(netid_t, net_handle_t); +extern int net_protocol_notify_register(net_handle_t, hook_notify_fn_t, void *); +extern int net_protocol_notify_unregister(net_handle_t, hook_notify_fn_t); + + +extern int net_getifname(net_handle_t, phy_if_t, char *, const size_t); +extern int net_getmtu(net_handle_t, phy_if_t, lif_if_t); +extern int net_getpmtuenabled(net_handle_t); +extern int net_getlifaddr(net_handle_t, phy_if_t, lif_if_t, + int, net_ifaddr_t [], void *); +extern zoneid_t net_getlifzone(net_handle_t, phy_if_t, lif_if_t, zoneid_t *); +extern int net_getlifflags(net_handle_t, phy_if_t, lif_if_t, uint64_t *); +extern phy_if_t net_phygetnext(net_handle_t, phy_if_t); +extern phy_if_t net_phylookup(net_handle_t, const char *); +extern lif_if_t net_lifgetnext(net_handle_t, phy_if_t, lif_if_t); +extern phy_if_t net_routeto(net_handle_t, struct sockaddr *, + struct sockaddr *); +extern int net_ispartialchecksum(net_handle_t, struct msgb *); +extern int net_isvalidchecksum(net_handle_t, struct msgb *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NETI_H */ diff --git a/illumos-x86_64/usr/include/sys/netstack.h b/illumos-x86_64/usr/include/sys/netstack.h new file mode 100644 index 00000000..7ee33318 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/netstack.h @@ -0,0 +1,286 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2017, Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_NETSTACK_H +#define _SYS_NETSTACK_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This allows various pieces in and around IP to have a separate instance + * for each instance of IP. This is used to support zones that have an + * exclusive stack. + * Pieces of software far removed from IP (e.g., kernel software + * sitting on top of TCP or UDP) probably should not use the netstack + * support; if such software wants to support separate zones it + * can do that using the zones framework (zone_key_create() etc) + * whether there is a shared IP stack or and exclusive IP stack underneath. + */ + +/* + * Each netstack has an identifier. We reuse the zoneid allocation for + * this but have a separate typedef. Thus the shared stack (used by + * the global zone and other shared stack zones) have a zero ID, and + * the exclusive stacks have a netstackid that is the same as their zoneid. + */ +typedef id_t netstackid_t; + +#define GLOBAL_NETSTACKID 0 + +/* + * One for each module which uses netstack support. + * Used in netstack_register(). + * + * The order of these is important for some modules both for + * the creation (which done in ascending order) and destruction (which is + * done in in decending order). + */ +#define NS_ALL -1 /* Match all */ +#define NS_DLS 0 +#define NS_IPTUN 1 +#define NS_STR 2 /* autopush list etc */ +#define NS_HOOK 3 +#define NS_NETI 4 +#define NS_ARP 5 +#define NS_IP 6 +#define NS_ICMP 7 +#define NS_UDP 8 +#define NS_TCP 9 +#define NS_SCTP 10 +#define NS_RTS 11 +#define NS_IPSEC 12 +#define NS_KEYSOCK 13 +#define NS_SPDSOCK 14 +#define NS_IPSECAH 15 +#define NS_IPSECESP 16 +#define NS_IPNET 17 +#define NS_ILB 18 +#define NS_MAX (NS_ILB+1) + +/* + * State maintained for each module which tracks the state of + * the create, shutdown and destroy callbacks. + * + * Keeps track of pending actions to avoid holding locks when + * calling into the create/shutdown/destroy functions in the module. + */ +#ifdef _KERNEL +typedef struct { + uint16_t nms_flags; + kcondvar_t nms_cv; +} nm_state_t; + +/* + * nms_flags + */ +#define NSS_CREATE_NEEDED 0x0001 +#define NSS_CREATE_INPROGRESS 0x0002 +#define NSS_CREATE_COMPLETED 0x0004 +#define NSS_SHUTDOWN_NEEDED 0x0010 +#define NSS_SHUTDOWN_INPROGRESS 0x0020 +#define NSS_SHUTDOWN_COMPLETED 0x0040 +#define NSS_DESTROY_NEEDED 0x0100 +#define NSS_DESTROY_INPROGRESS 0x0200 +#define NSS_DESTROY_COMPLETED 0x0400 + +#define NSS_CREATE_ALL \ + (NSS_CREATE_NEEDED|NSS_CREATE_INPROGRESS|NSS_CREATE_COMPLETED) +#define NSS_SHUTDOWN_ALL \ + (NSS_SHUTDOWN_NEEDED|NSS_SHUTDOWN_INPROGRESS|NSS_SHUTDOWN_COMPLETED) +#define NSS_DESTROY_ALL \ + (NSS_DESTROY_NEEDED|NSS_DESTROY_INPROGRESS|NSS_DESTROY_COMPLETED) + +#define NSS_ALL_INPROGRESS \ + (NSS_CREATE_INPROGRESS|NSS_SHUTDOWN_INPROGRESS|NSS_DESTROY_INPROGRESS) +#else +/* User-level compile like IP Filter needs a netstack_t. Dummy */ +typedef uint_t nm_state_t; +#endif /* _KERNEL */ + +/* + * One for every netstack in the system. + * We use a union so that the compilar and lint can provide type checking - + * in principle we could have + * #define netstack_arp netstack_modules[NS_ARP] + * etc, but that would imply void * types hence no type checking by the + * compiler. + * + * All the fields in netstack_t except netstack_next are protected by + * netstack_lock. netstack_next is protected by netstack_g_lock. + */ +struct netstack { + union { + void *nu_modules[NS_MAX]; + struct { + struct dls_stack *nu_dls; + struct iptun_stack *nu_iptun; + struct str_stack *nu_str; + struct hook_stack *nu_hook; + struct neti_stack *nu_neti; + struct arp_stack *nu_arp; + struct ip_stack *nu_ip; + struct icmp_stack *nu_icmp; + struct udp_stack *nu_udp; + struct tcp_stack *nu_tcp; + struct sctp_stack *nu_sctp; + struct rts_stack *nu_rts; + struct ipsec_stack *nu_ipsec; + struct keysock_stack *nu_keysock; + struct spd_stack *nu_spdsock; + struct ipsecah_stack *nu_ipsecah; + struct ipsecesp_stack *nu_ipsecesp; + struct ipnet_stack *nu_ipnet; + struct ilb_stack *nu_ilb; + } nu_s; + } netstack_u; +#define netstack_modules netstack_u.nu_modules +#define netstack_dls netstack_u.nu_s.nu_dls +#define netstack_iptun netstack_u.nu_s.nu_iptun +#define netstack_str netstack_u.nu_s.nu_str +#define netstack_hook netstack_u.nu_s.nu_hook +#define netstack_neti netstack_u.nu_s.nu_neti +#define netstack_arp netstack_u.nu_s.nu_arp +#define netstack_ip netstack_u.nu_s.nu_ip +#define netstack_icmp netstack_u.nu_s.nu_icmp +#define netstack_udp netstack_u.nu_s.nu_udp +#define netstack_tcp netstack_u.nu_s.nu_tcp +#define netstack_sctp netstack_u.nu_s.nu_sctp +#define netstack_rts netstack_u.nu_s.nu_rts +#define netstack_ipsec netstack_u.nu_s.nu_ipsec +#define netstack_keysock netstack_u.nu_s.nu_keysock +#define netstack_spdsock netstack_u.nu_s.nu_spdsock +#define netstack_ipsecah netstack_u.nu_s.nu_ipsecah +#define netstack_ipsecesp netstack_u.nu_s.nu_ipsecesp +#define netstack_ipnet netstack_u.nu_s.nu_ipnet +#define netstack_ilb netstack_u.nu_s.nu_ilb + + nm_state_t netstack_m_state[NS_MAX]; /* module state */ + + kmutex_t netstack_lock; + struct netstack *netstack_next; + netstackid_t netstack_stackid; + int netstack_numzones; /* Number of zones using this */ + int netstack_refcnt; /* Number of hold-rele */ + int netstack_flags; /* See below */ + +#ifdef _KERNEL + /* Needed to ensure that we run the callback functions in order */ + kcondvar_t netstack_cv; +#endif +}; +typedef struct netstack netstack_t; + +/* netstack_flags values */ +#define NSF_UNINIT 0x01 /* Not initialized */ +#define NSF_CLOSING 0x02 /* Going away */ +#define NSF_ZONE_CREATE 0x04 /* create callbacks inprog */ +#define NSF_ZONE_SHUTDOWN 0x08 /* shutdown callbacks */ +#define NSF_ZONE_DESTROY 0x10 /* destroy callbacks */ + +#define NSF_ZONE_INPROGRESS \ + (NSF_ZONE_CREATE|NSF_ZONE_SHUTDOWN|NSF_ZONE_DESTROY) + +/* + * One for each of the NS_* values. + */ +struct netstack_registry { + int nr_flags; /* 0 if nothing registered */ + void *(*nr_create)(netstackid_t, netstack_t *); + void (*nr_shutdown)(netstackid_t, void *); + void (*nr_destroy)(netstackid_t, void *); +}; + +/* nr_flags values */ +#define NRF_REGISTERED 0x01 +#define NRF_DYING 0x02 /* No new creates */ + +/* + * To support kstat_create_netstack() using kstat_add_zone we need + * to track both + * - all zoneids that use the global/shared stack + * - all kstats that have been added for the shared stack + */ + +extern void netstack_init(void); +extern void netstack_hold(netstack_t *); +extern netstack_t *netstack_hold_if_active(netstack_t *); +extern void netstack_rele(netstack_t *); +extern netstack_t *netstack_find_by_cred(const cred_t *); +extern netstack_t *netstack_find_by_stackid(netstackid_t); +extern netstack_t *netstack_find_by_zoneid(zoneid_t); +extern boolean_t netstack_inuse_by_stackid(netstackid_t stackid); + +extern zoneid_t netstackid_to_zoneid(netstackid_t); +extern zoneid_t netstack_get_zoneid(netstack_t *); +extern netstackid_t zoneid_to_netstackid(zoneid_t); + +extern netstack_t *netstack_get_current(void); + +/* + * Register interest in changes to the set of netstacks. + * The createfn and destroyfn are required, but the shutdownfn can be + * NULL. + * Note that due to the current zsd implementation, when the create + * function is called the zone isn't fully present, thus functions + * like zone_find_by_* will fail, hence the create function can not + * use many zones kernel functions including zcmn_err(). + */ +extern void netstack_register(int, + void *(*)(netstackid_t, netstack_t *), + void (*)(netstackid_t, void *), + void (*)(netstackid_t, void *)); +extern void netstack_unregister(int); +extern kstat_t *kstat_create_netstack(char *, int, char *, char *, uchar_t, + uint_t, uchar_t, netstackid_t); +extern void kstat_delete_netstack(kstat_t *, netstackid_t); + +/* + * Simple support for walking all the netstacks. + * The caller of netstack_next() needs to call netstack_rele() when + * done with a netstack. + */ +typedef int netstack_handle_t; + +extern void netstack_next_init(netstack_handle_t *); +extern void netstack_next_fini(netstack_handle_t *); +extern netstack_t *netstack_next(netstack_handle_t *); + +#ifdef __cplusplus +} +#endif + + +#endif /* _SYS_NETSTACK_H */ diff --git a/illumos-x86_64/usr/include/sys/nexusdefs.h b/illumos-x86_64/usr/include/sys/nexusdefs.h new file mode 100644 index 00000000..fb0f41a2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nexusdefs.h @@ -0,0 +1,107 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_NEXUSDEFS_H +#define _SYS_NEXUSDEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Bus Nexus Control Operations + */ + +typedef enum { + DDI_CTLOPS_DMAPMAPC, + DDI_CTLOPS_INITCHILD, + DDI_CTLOPS_UNINITCHILD, + DDI_CTLOPS_REPORTDEV, + DDI_CTLOPS_REPORTINT, + DDI_CTLOPS_REGSIZE, + DDI_CTLOPS_NREGS, + DDI_CTLOPS_RESERVED0, /* Originally DDI_CTLOPS_NINTRS, obsolete */ + DDI_CTLOPS_SIDDEV, + DDI_CTLOPS_SLAVEONLY, + DDI_CTLOPS_AFFINITY, + DDI_CTLOPS_IOMIN, + DDI_CTLOPS_PTOB, + DDI_CTLOPS_BTOP, + DDI_CTLOPS_BTOPR, + DDI_CTLOPS_RESERVED1, /* Originally DDI_CTLOPS_POKE_INIT, obsolete */ + DDI_CTLOPS_RESERVED2, /* Originally DDI_CTLOPS_POKE_FLUSH, obsolete */ + DDI_CTLOPS_RESERVED3, /* Originally DDI_CTLOPS_POKE_FINI, obsolete */ + DDI_CTLOPS_RESERVED4, /* Originally DDI_CTLOPS_INTR_HILEVEL, obsolete */ + DDI_CTLOPS_RESERVED5, /* Originally DDI_CTLOPS_XLATE_INTRS, obsolete */ + DDI_CTLOPS_DVMAPAGESIZE, + DDI_CTLOPS_POWER, + DDI_CTLOPS_ATTACH, + DDI_CTLOPS_DETACH, + DDI_CTLOPS_QUIESCE, + DDI_CTLOPS_UNQUIESCE, + DDI_CTLOPS_PEEK, + DDI_CTLOPS_POKE +} ddi_ctl_enum_t; + +/* + * For source compatibility, we define the following obsolete code: + * Do NOT use this, use the real constant name. + */ +#define DDI_CTLOPS_REMOVECHILD DDI_CTLOPS_UNINITCHILD + +/* + * Bus config ops + */ +typedef enum { + BUS_ENUMERATE = 0, + BUS_CONFIG_ONE, + BUS_CONFIG_ALL, + BUS_CONFIG_AP, + BUS_CONFIG_DRIVER, + BUS_UNCONFIG_ONE, + BUS_UNCONFIG_DRIVER, + BUS_UNCONFIG_ALL, + BUS_UNCONFIG_AP, + BUS_CONFIG_OBP_ARGS +} ddi_bus_config_op_t; + +/* + * Bus Power Operations + */ +typedef enum { + BUS_POWER_CHILD_PWRCHG = 0, + BUS_POWER_NEXUS_PWRUP, + BUS_POWER_PRE_NOTIFICATION, + BUS_POWER_POST_NOTIFICATION, + BUS_POWER_HAS_CHANGED, + BUS_POWER_NOINVOL +} pm_bus_power_op_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NEXUSDEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/note.h b/illumos-x86_64/usr/include/sys/note.h new file mode 100644 index 00000000..6625b68d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/note.h @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1994 by Sun Microsystems, Inc. + */ + +/* + * sys/note.h: interface for annotating source with info for tools + * + * This is the underlying interface; NOTE (/usr/include/note.h) is the + * preferred interface, but all exported header files should include this + * file directly and use _NOTE so as not to take "NOTE" from the user's + * namespace. For consistency, *all* kernel source should use _NOTE. + * + * By default, annotations expand to nothing. This file implements + * that. Tools using annotations will interpose a different version + * of this file that will expand annotations as needed. + */ + +#ifndef _SYS_NOTE_H +#define _SYS_NOTE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _NOTE +#define _NOTE(s) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NOTE_H */ diff --git a/illumos-x86_64/usr/include/sys/null.h b/illumos-x86_64/usr/include/sys/null.h new file mode 100644 index 00000000..4009d3ea --- /dev/null +++ b/illumos-x86_64/usr/include/sys/null.h @@ -0,0 +1,50 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2014-2016 PALO, Richard. + */ + +#ifndef _SYS_NULL_H +#define _SYS_NULL_H + +#include + +#ifndef NULL + +/* + * POSIX.1-2008 requires that the NULL macro be cast to type void *. + */ + +#if !defined(__cplusplus) +#define NULL ((void *)0) +#else + +/* + * ISO C++ requires that the NULL macro be a constant integral type evaluating + * to zero until C++11, and an integer or pointer literal with value zero from + * C++11 onwards. + */ + +#if __cplusplus >= 201103L +#define NULL nullptr +#else +#if defined(_LP64) +#define NULL 0L +#else +#define NULL 0 +#endif /* _LP64 */ +#endif /* C++11 */ +#endif /* !__cplusplus */ + +#endif /* NULL */ + +#endif /* _SYS_NULL_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/discovery.h b/illumos-x86_64/usr/include/sys/nvme/discovery.h new file mode 100644 index 00000000..991131aa --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/discovery.h @@ -0,0 +1,209 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_DISCOVERY_H +#define _SYS_NVME_DISCOVERY_H + +/* + * This defines common types that are used for discovering features of NVMe + * devices. The primary way for users to consume these types is through the + * libnvme discovery APIs. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + NVME_LOG_ID_MANDATORY, + NVME_LOG_ID_OPTIONAL, + NVME_LOG_ID_VENDOR_SPECIFIC +} nvme_log_disc_kind_t; + +/* + * Different logs cover different aspects of a device. These are listed below + * referring to the NVMe controller, the NVM subsystem itself, and then + * particular namespaces. NVMe 2.x adds the notion of a domain. From a + * specification perspective, the NVM subsystem is instead sometimes referred to + * as a domain. A controller can only access a single domain so while the 2.x + * specifications suggest the scope is slightly different for the NVM subsystem + * below, they're basically the same for our purposes. + */ +typedef enum { + NVME_LOG_SCOPE_CTRL = 1 << 0, + NVME_LOG_SCOPE_NVM = 1 << 1, + NVME_LOG_SCOPE_NS = 1 << 2 +} nvme_log_disc_scope_t; + +typedef enum { + /* + * This indicates that the implementation information is based on + * knowledge from a base spec. + */ + NVME_LOG_DISC_S_SPEC = 1 << 0, + /* + * This indicates that the knowledge is from the identify controller + * data structure. + */ + NVME_LOG_DISC_S_ID_CTRL = 1 << 1, + /* + * This indicates that we have used our internal information database + * about devices from a vendor's datasheets to determine that something + * is supported. + */ + NVME_LOG_DISC_S_DB = 1 << 2, + /* + * This indicates that we have used a command (whether vendor-specific + * or the NVMe 2.x Supported Log Pages) to get additional information + * about this. + */ + NVME_LOG_DISC_S_CMD = 1 << 3 +} nvme_log_disc_source_t; + +typedef enum { + /* + * These next three flags indicate that the log page requires additional + * information for it to complete successfully. These are specifically + * the log specific parameter or a log specific indicator (e.g. an + * endurance group, NVM set, domain, etc.). RAE was introduced in NVMe + * 1.3 and applied to logs that already existed. It will not be possible + * to set RAE on a log request that operates on a controller prior to + * NVMe 1.3. + */ + NVME_LOG_DISC_F_NEED_LSP = 1 << 0, + NVME_LOG_DISC_F_NEED_LSI = 1 << 1, + NVME_LOG_DISC_F_NEED_RAE = 1 << 2, + /* + * Log pages whose only scope is a namespace are required to specify a + * namespace. Otherwise, when the scope includes a controller or NVM + * subsystem then it is assumed that the default is to target the + * controller (e.g. the health log page). + */ + NVME_LOG_DISC_F_NEED_NSID = 1 << 3 +} nvme_log_disc_fields_t; + + +typedef enum { + NVME_FEAT_SCOPE_CTRL = 1 << 0, + NVME_FEAT_SCOPE_NS = 1 << 1 +} nvme_feat_scope_t; + +typedef enum { + /* + * Indicates that this feature requires an argument to select some part + * of the feature in cdw11. + */ + NVME_GET_FEAT_F_CDW11 = 1 << 0, + /* + * Indicates that this feature will output data to a specific buffer and + * therefore a data argument is required for this feature. + */ + NVME_GET_FEAT_F_DATA = 1 << 1, + /* + * Indicates that this feature requires a namespace ID to be specified + * when getting this feature. In general, while one can usually set a + * feature to target the broadcast namespace, the same is not true of + * getting a feature. + */ + NVME_GET_FEAT_F_NSID = 1 << 2, +} nvme_get_feat_fields_t; + +typedef enum { + /* + * These indicate that the feature requires fields set in the various + * control words to set the feature. + */ + NVME_SET_FEAT_F_CDW11 = 1 << 0, + NVME_SET_FEAT_F_CDW12 = 1 << 1, + NVME_SET_FEAT_F_CDW13 = 1 << 2, + NVME_SET_FEAT_F_CDW14 = 1 << 3, + NVME_SET_FEAT_F_CDW15 = 1 << 4, + /* + * Indicates that there is a data payload component to this feature that + * must be set. + */ + NVME_SET_FEAT_F_DATA = 1 << 5, + /* + * Indicates that this feature requires a namespace ID. Broadcast IDs + * are more often allowed than with getting a feature, but it still + * depends. + */ + NVME_SET_FEAT_F_NSID = 1 << 6 +} nvme_set_feat_fields_t; + +typedef enum { + /* + * Indicates that getting the feature outputs data in cdw0 for + * consumption. This is the most common form of data output for getting + * features. Setting features usually doesn't output data in cdw0; + * however, a few are defined to. + */ + NVME_FEAT_OUTPUT_CDW0 = 1 << 0, + /* + * Indicates that data is output in the data buffer that was passed in. + * This is only ever used for get features. + */ + NVME_FEAT_OUTPUT_DATA = 1 << 1 +} nvme_feat_output_t; + +typedef enum { + /* + * Indicates that when getting or setting this feature that requires a + * namespace ID, the broadcast namespace is allowed. + */ + NVME_FEAT_F_GET_BCAST_NSID = 1 << 0, + NVME_FEAT_F_SET_BCAST_NSID = 1 << 1 +} nvme_feat_flags_t; + +typedef enum { + NVME_FEAT_MANDATORY = 0, + NVME_FEAT_OPTIONAL, + NVME_FEAT_VENDOR_SPECIFIC +} nvme_feat_kind_t; + +/* + * This enumeration indicates whether or not a given feature is specific to a + * command set, and if so what one. The default is that most features are + * present for all command sets, which uses the NVME_FEAT_CSI_NONE value. + * Otherwise, it uses a bit-field to indicate what it is present in. + */ +typedef enum { + NVME_FEAT_CSI_NONE = 0, + NVME_FEAT_CSI_NVM = 1 << 0, +} nvme_feat_csi_t; + +/* + * Prior to NVMe 2.x, there was no standard way to determine if a given log page + * was actually implemented or not. While several features had bits in the + * identify controller namespace, some (e.g. LBA Range Type) are optional, + * command-set specific, and have no such way of knowing if they're supported + * short of saying so. If we cannot determine this from the controller's + * version, type, and identify controller information, then we will indicate + * that we don't know. When we have full support for leveraging the NVMe 2.x + * Feature Identifiers Supported and Effects log pages and someone is + * interrogating an NVMe 2.x controller, then ideally one should not see + * unknown. + */ +typedef enum { + NVME_FEAT_IMPL_UNKNOWN = 0, + NVME_FEAT_IMPL_UNSUPPORTED, + NVME_FEAT_IMPL_SUPPORTED +} nvme_feat_impl_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_DISCOVERY_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/kioxia.h b/illumos-x86_64/usr/include/sys/nvme/kioxia.h new file mode 100644 index 00000000..15b9f77b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/kioxia.h @@ -0,0 +1,40 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_KIOXIA_H +#define _SYS_NVME_KIOXIA_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This header contains all of the current vendor-specific entries for known + * Kioxia devices as well as common structures and definitions that are shared + * across multiple device families. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define KIOXIA_PCI_VID 0x1e0f + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_KIOXIA_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/kioxia_cd8.h b/illumos-x86_64/usr/include/sys/nvme/kioxia_cd8.h new file mode 100644 index 00000000..822c72b0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/kioxia_cd8.h @@ -0,0 +1,110 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_KIOXIA_CD8_H +#define _SYS_NVME_KIOXIA_CD8_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * Vendor-specific definitions for the Kioxia CD8 and CD8P. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define KIOXIA_CD8_DID 0x1f +#define KIOXIA_CD8P_DID 0x2b + +typedef enum { + KIOXIA_CD8_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + KIOXIA_CD8_LOG_OCP_ERRREC = OCP_LOG_DSSD_ERROR_REC, + KIOXIA_CD8_LOG_OCP_FWACT = OCP_LOG_DSSD_FWACT, + KIOXIA_CD8_LOG_OCP_LATENCY = OCP_LOG_DSSD_LATENCY, + KIOXIA_CD8_LOG_OCP_DEV_CAP = OCP_LOG_DSSD_DEV_CAP, + KIOXIA_CD8_LOG_OCP_UNSUP = OCP_LOG_DSSD_UNSUP_REQ, + /* + * Uses the kioxia_vul_cd8_extsmart_t. + */ + KIOXIA_CD8_LOG_EXTSMART = 0xca +} kioxia_cd8_vul_t; + +/* + * All data structures must be packed to account for the layout from the various + * programmer's manuals. + */ +#pragma pack(1) +typedef struct { + uint8_t kes_id; + uint8_t kes_rsvd1[2]; + uint8_t kse_norm; + uint8_t kes_rsvd4; + uint8_t kse_raw[6]; + uint8_t kse_rsvd11; +} kioxia_extsmart_ent_t; + +/* + * These are the different type keys that exist for the kioxia_extsmart_ent_t + * above. Note, entries in the latter part of the log just use zero keys. + */ +typedef enum { + KIOXIA_SMART_TYPE_PROGRAM_FAIL = 0xab, + KIOXIA_SMART_TYPE_ERASE_FAIL = 0xac, + KIOXIA_SMART_TYPE_WEAR_LEVEL = 0xad, + KIOXIA_SMART_TYPE_E2E_ERROR_DET = 0xb8, + KIOXIA_SMART_TYPE_CRC_ERROR = 0xc7, + KIOXIA_SMART_TYPE_NAND_WRITE = 0xf4, + KIOXIA_SMART_TYPE_HOST_WRITE = 0xf5 +} kioxia_smart_type_t; + + +typedef struct { + kioxia_extsmart_ent_t cds_prog_fail; + kioxia_extsmart_ent_t cds_erase_fail; + kioxia_extsmart_ent_t cds_wear_level; + kioxia_extsmart_ent_t cds_e2e_det; + kioxia_extsmart_ent_t cds_crc_error; + uint8_t cds_rvsd60[132 - 60]; + kioxia_extsmart_ent_t cds_nand_write; + kioxia_extsmart_ent_t cds_host_write; + uint8_t cds_rsvd156[256 - 156]; + kioxia_extsmart_ent_t cds_crit_warn; + kioxia_extsmart_ent_t cds_host_read; + kioxia_extsmart_ent_t cds_comp_temp; + kioxia_extsmart_ent_t cds_life_used; + kioxia_extsmart_ent_t cds_power_cycles; + kioxia_extsmart_ent_t cds_power_hours; + kioxia_extsmart_ent_t cds_unsafe_shut; + uint8_t cds_rsvd340[512 - 340]; +} kioxia_vul_cd8_smart_t; +#pragma pack() /* pack(1) */ +/* + * Our current version of smatch cannot handle packed structures. + */ +#ifndef __CHECKER__ +CTASSERT(sizeof (kioxia_extsmart_ent_t) == 12); +CTASSERT(sizeof (kioxia_vul_cd8_smart_t) == 512); +#endif /* __CHECKER__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_KIOXIA_CD8_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/micron.h b/illumos-x86_64/usr/include/sys/nvme/micron.h new file mode 100644 index 00000000..4a40f342 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/micron.h @@ -0,0 +1,110 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_NVME_MICRON_H +#define _SYS_NVME_MICRON_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This header contains all of the current vendor-specific entries for known + * Micron devices as well as common structures and definitions that are shared + * across multiple device families. + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MICRON_PCI_VID 0x1344 + +/* + * All data structures must be packed to account for the layout from the various + * programmer's manuals. + */ +#pragma pack(1) + +/* + * Micron has a common extended SMART log that is used between multiple device + * families. Some fields have been added in newer device generations and they + * are reserved otherwise. Starting in the 6500/7500+ generation, the structure + * was extended in size and is defined in its device-specific section. + */ +typedef struct { + uint8_t mes_rsvd0[12]; + uint32_t mes_gbb; + uint32_t mes_max_erase; + uint32_t mes_power_on; + uint8_t mes_rsvd24[24]; + uint32_t mes_wp_reason; + uint8_t mes_rsvd52[12]; + uint64_t mes_cap; + uint8_t mes_rsvd72[8]; + uint64_t mes_erase_count; + uint64_t mes_use_rate; + /* + * Begin 7400+ specific fields. + */ + uint64_t mes_erase_fail; + uint8_t mes_rsvd104[8]; + uint64_t mes_uecc; + uint8_t mes_rsvd120[24]; + uint8_t mes_prog_fail[16]; + uint8_t mes_read_bytes[16]; + uint8_t mes_write_bytes[16]; + uint8_t mes_rsvd192[16]; + /* + * End 7400+ specific fields. + */ + uint32_t mes_trans_size; + uint32_t mes_bs_total; + uint32_t mes_bs_free; + uint64_t mes_bs_cap; + uint8_t mes_rsvd228[16]; + uint32_t mes_user_erase_min; + uint32_t mes_user_erase_avg; + uint32_t mes_user_erase_max; +} micron_vul_ext_smart_t; + +typedef enum { + MICRON_VUL_WP_R_DRAM_DOUBLE_BIT = 1 << 0, + MICRON_VUL_WP_R_LOW_SPARE_BLOCKS = 1 << 1, + MICRON_VUL_WP_R_CAP_FAILURE = 1 << 2, + MICRON_VUL_WP_R_NVRAM_CKSUM = 1 << 3, + MICRON_VUL_WP_R_DRAM_RANGE = 1 << 4, + MICRON_VUL_WP_R_OVERTEMP = 1 << 5 +} micron_vul_wp_reason_t; + +/* + * Smatch can't handle packed structure sizeof calculations correctly, + * unfortunately. + */ +#ifndef __CHECKER__ +CTASSERT(sizeof (micron_vul_ext_smart_t) == 0x100); +#endif + +#pragma pack() /* pack(1) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_MICRON_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/micron_7300.h b/illumos-x86_64/usr/include/sys/nvme/micron_7300.h new file mode 100644 index 00000000..994c04cc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/micron_7300.h @@ -0,0 +1,86 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_NVME_MICRON_7300_H +#define _SYS_NVME_MICRON_7300_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This header contains all of the current vendor-specific entries for known + * Micron devices as well as common structures and definitions that are shared + * across multiple device families. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MICRON_7300_PRO_DID 0x51a2 +#define MICRON_7300_MAX_DID 0x51a3 + +typedef enum { + /* + * This log is supported by the [79]300, though when supported, the + * extended SMART log is preferred. + */ + MICRON_7300_LOG_SMART = 0xca, + /* + * This log is the micron_vul_ext_smart_t. + */ + MICRON_7300_LOG_EXT_SMART = 0xd0 +} micron_7300_vul_t; + +/* + * All data structures must be packed to account for the layout from the various + * programmer's manuals. + */ +#pragma pack(1) + +/* + * The Micron vendor-unique SMART log (0xca) is formed in terms of these data + * entities that all have a fixed size. The type value tells you what it is + * supposed to be (though the log has a fixed layout). The data payload + * interpretation varies based on the type. + */ +typedef struct { + uint8_t vse_type; + uint8_t vse_rsvd[4]; + uint8_t vse_data[7]; +} micron_vul_smart_ent_t; + +typedef struct { + micron_vul_smart_ent_t ms_writes; + micron_vul_smart_ent_t ms_reads; + micron_vul_smart_ent_t ms_throttle; + micron_vul_smart_ent_t ms_life_temp; + micron_vul_smart_ent_t ms_power; + micron_vul_smart_ent_t ms_poweron_temp; +} micron_vul_smart_t; + +CTASSERT(sizeof (micron_vul_smart_t) == 0x48); + +#pragma pack() /* pack(1) */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_MICRON_7300_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/micron_74x0.h b/illumos-x86_64/usr/include/sys/nvme/micron_74x0.h new file mode 100644 index 00000000..4442aba8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/micron_74x0.h @@ -0,0 +1,45 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_MICRON_74X0_H +#define _SYS_NVME_MICRON_74X0_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This header contains all of the current vendor-specific entries for known + * Micron devices as well as common structures and definitions that are shared + * across multiple device families. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MICRON_7400_PRO_DID 0x51c0 +#define MICRON_7400_MAX_DID 0x51c1 +#define MICRON_7450_PRO_DID 0x51c3 +#define MICRON_7450_MAX_DID 0x51c4 + +typedef enum { + MICRON_74x0_LOG_EXT_SMART = 0xe1 +} micron_74x0_vul_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_MICRON_74X0_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/micron_9550.h b/illumos-x86_64/usr/include/sys/nvme/micron_9550.h new file mode 100644 index 00000000..dd80e597 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/micron_9550.h @@ -0,0 +1,47 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_NVME_MICRON_9550_H +#define _SYS_NVME_MICRON_9550_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This covers the Micron 9550 series devices. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MICRON_9550_PRO_DID 0x51bb +#define MICRON_9550_MAX_DID 0x51bd + +typedef enum { + MICRON_9550_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + MICRON_9550_LOG_OCP_ERRREC = OCP_LOG_DSSD_ERROR_REC, + MICRON_9550_LOG_OCP_FWACT = OCP_LOG_DSSD_FWACT, + MICRON_9550_LOG_OCP_LATENCY = OCP_LOG_DSSD_LATENCY, + MICRON_9550_LOG_OCP_DEV_CAP = OCP_LOG_DSSD_DEV_CAP, + MICRON_9550_LOG_OCP_UNSUP = OCP_LOG_DSSD_UNSUP_REQ, + MICRON_9550_LOG_OCP_TELEMETRY = OCP_LOG_DSSD_TELEMETRY, +} micron_9500_vul_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_MICRON_9550_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/micron_x500.h b/illumos-x86_64/usr/include/sys/nvme/micron_x500.h new file mode 100644 index 00000000..7e43c963 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/micron_x500.h @@ -0,0 +1,49 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_MICRON_X500_H +#define _SYS_NVME_MICRON_X500_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This covers the Micron 6500 and 7500 series devices. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MICRON_6500_ION_DID 0x51b9 +#define MICRON_7500_PRO_DID 0x51b7 +#define MICRON_7500_MAX_DID 0x51b8 + +typedef enum { + MICRON_x500_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + MICRON_x500_LOG_OCP_ERRREC = OCP_LOG_DSSD_ERROR_REC, + MICRON_x500_LOG_OCP_FWACT = OCP_LOG_DSSD_FWACT, + MICRON_x500_LOG_OCP_LATENCY = OCP_LOG_DSSD_LATENCY, + MICRON_x500_LOG_OCP_DEV_CAP = OCP_LOG_DSSD_DEV_CAP, + MICRON_x500_LOG_OCP_UNSUP = OCP_LOG_DSSD_UNSUP_REQ, +} micron_x500_vul_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_MICRON_X500_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/ocp.h b/illumos-x86_64/usr/include/sys/nvme/ocp.h new file mode 100644 index 00000000..b44060d2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/ocp.h @@ -0,0 +1,777 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_NVME_OCP_H +#define _SYS_NVME_OCP_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This covers the OCP Datacenter NVMe SSD Specification versions 2.0 and 2.5. + * Version 1.0 of this specification was previously called the OCP NVMe Cloud + * SSD Specification. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + /* + * This is the OCP variant of SMART information. Present since v1.0. + * Scoped to the NVM subsystem. Tracked by the ocp_vul_smart_t. + */ + OCP_LOG_DSSD_SMART = 0xc0, + /* + * Error recovery information. Present since v1.0. Scoped to the NVM + * subsystem. + */ + OCP_LOG_DSSD_ERROR_REC = 0xc1, + /* + * This log page covers firmware activation history. It was added in + * v1.0 of the specification, but v2.5 removed this as obsolete. Scoped + * to the NVM subsystem. + */ + OCP_LOG_DSSD_FWACT = 0xc2, + /* + * This is the latency monitor log page that has information in tandem + * with the Latency monitor feature (0xc5). Added in v2.0. Scoped to the + * controller. + */ + OCP_LOG_DSSD_LATENCY = 0xc3, + /* + * This log page indicates various device capabilities. Added in v2.0. + * Scoped to the NVM subsystem. + */ + OCP_LOG_DSSD_DEV_CAP = 0xc4, + /* + * This log page indicates which requirements aren't actually + * implemented by a device. Added in v2.0. Scoped to the NVM subsystem. + */ + OCP_LOG_DSSD_UNSUP_REQ = 0xc5, + /* + * This log page covers various trusted computing group configuration. + * Added in v2.5. Scoped to the NVM subsystem. + */ + OCP_LOG_DSSD_TCG = 0xc7, + /* + * This is the telemetry string log. Added in v2.5. Scoped to the NVM + * subsystem. See the ocp_vul_telstr_t. + */ + OCP_LOG_DSSD_TELEMETRY = 0xc9 +} ocp_vul_t; + +typedef enum { + /* + * Error injection feature. Added in v1.0. Scoped to the NVM subsystem. + */ + OCP_FEAT_DSSD_ERR_INJ = 0xc0, + /* + * Clear the firmware activation and update history log. Added in v1.0, + * but marked obsolete in v2.5. Scoped to the NVM subsystem. + */ + OCP_FEAT_DSSD_CLEAR_FWACT = 0xc1, + /* + * Controls the failure mode on device EOL or power loss protection + * (PLP) failure. Added in v1.0. Scoped to the NVM subsystem. + */ + OCP_FEAT_DSSD_EOLPLP = 0xc2, + /* + * Clears the PCIe correctable error counters. Added in v1.0. Scoped to + * the controller. + */ + OCP_FEAT_DSSD_CLEAR_PCIE_ERRCOR = 0xc3, + /* + * Manipulates the IEEE1667 silo which ties into the OPAL security + * feature set. Added in v1.0. Scoped to the NVM subsystem. + */ + OCP_FEAT_DSSD_IEEE1667 = 0xc4, + /* + * Controls the latency monitor feature. Added in v2.0. Scoped to the + * controller. + */ + OCP_FEAT_DSSD_LATENCY = 0xc5, + /* + * Controls the PLP health check interval. Added in v2.0. Scoped to the + * NVM subsystem. + */ + OCP_FEAT_DSSD_PLP_HEALTH = 0xc6, + /* + * Controls the power state that the device is in. Added in v2.0. Scoped + * to the NVM subsystem. + */ + OCP_FEAT_DSSD_POWER_STATE = 0xc7, + /* + * Controls the OCP DSSD telemetry profile that should be active. Added + * in v2.5. Scoped to the NVM subsystem. + */ + OCP_FEAT_DSSD_TEL_PROFILE = 0xc8, + /* + * Controls whether additional spec-specific events should be sent with + * the asynchronous event commands. + */ + OCP_FEAT_DSSD_ASYNC_EVENT = 0xc9 +} ocp_vuf_t; + +/* + * All data structures must be packed to account for the layout from the various + * specifications. All fields are required to be in little endian. + */ +#pragma pack(1) + +/* + * OCP SMART / Health log page. A number in parentheses like (2.0) indicates the + * version something was added in if it was not v1.0. + */ +typedef struct { + /* + * Physical media units read and written. + */ + uint8_t osh_pmed_write[16]; + uint8_t osh_pmed_read[16]; + /* + * Bad user and system NAND blocks. Both a raw count and normalized + * value (percentage remaining). + */ + uint8_t osh_bunb_raw[6]; + uint16_t osh_bunb_norm; + uint8_t osh_bsnb_raw[6]; + uint16_t osh_bsnb_norm; + /* + * Various error and recovery metrics: + * - XOR + * - Uncorrectable reads + * - Soft ECC errors + * - End to end errors detected and corrected + */ + uint64_t osh_xor_rec; + uint64_t osh_read_unrec; + uint64_t osh_soft_ecc_err; + uint32_t osh_e2e_det; + uint32_t osh_e2e_corr; + /* + * Tracks the normalized percent used of the device by estimated erase + * cycles per block. + */ + uint8_t osh_sys_used; + /* + * This is the count of blocks that have been refreshed. + */ + uint8_t osh_refresh[7]; + /* + * Tracks the maximum and minimum erase count across NAND reserved for + * the user. + */ + uint32_t osh_udec_max; + uint32_t osh_udec_min; + /* + * The number of events and the current level of throttling. + */ + uint8_t osh_therm_event; + uint8_t osh_throt_level; + /* + * DSSD versioning for the device. (2.0). + */ + uint8_t osh_vers_errata; + uint16_t osh_vers_point; + uint16_t osh_vers_minor; + uint8_t osh_vers_major; + /* + * PCIe Correctable error count. + */ + uint64_t osh_pcie_errcor; + /* + * Incomplete shutdowns. + */ + uint32_t osh_inc_shut; + uint8_t osh_rsvd116[4]; + /* + * Normalized free percentage. + */ + uint8_t osh_free; + uint8_t osh_rsvd121[7]; + /* + * Capacitor health as a percentage. + */ + uint16_t osh_cap_health; + /* + * NVMe base spec errata version (2.0). + * NVMe cmd spec errata version (2.5). + */ + uint8_t osh_nvme_base_errata; + uint8_t osh_nvme_cmd_errata; + uint8_t osh_rsvd132[4]; + /* + * Quantity of unaligned I/O + */ + uint64_t osh_unaligned; + /* + * An incrementing integer representing a security version that + * shouldn't be rolled back across. + */ + uint64_t osh_sec_vers; + /* + * Namespace utilization. + */ + uint64_t osh_nuse; + /* + * Count of events where PLP kicked in. + */ + uint8_t osh_plp_start[16]; + /* + * Estimation of total data that can be written to the device in bytes. + */ + uint8_t osh_endurnace[16]; + /* + * Count of PCIe retraining events (2.0). + */ + uint64_t osh_pcie_retrain; + /* + * Count of power state changes, regardless of initiator. (2.0). + */ + uint64_t osh_ps_change; + /* + * Minimum permitted firmware version for rollback purposes. + */ + uint64_t osh_min_fwrev; + uint8_t osh_rsvd216[278]; + /* + * v1.0: 2, v2.0: 3, v2.5: 4 + */ + uint16_t osh_vers; + /* + * Log page GUID: AFD514C97C6F4F9CA4f2BFEA2810AFC5h. + */ + uint8_t osh_guid[16]; +} ocp_vul_smart_t; + +/* + * OCP Error Recovery log. + */ +typedef struct { + /* + * Time in ms to wait for a reset to complete. + */ + uint16_t oer_prwt; + /* + * List of reset actions we should consider taking. See ocp_errrec_pra_t + * for bit meanings. + */ + uint8_t oer_pra; + /* + * List of steps to take to handle the device's recovery from a given + * situation. See ocp_errrec_dra_t for bit meanings. + */ + uint8_t oer_dra; + uint64_t oer_panic_id; + /* + * See ocp_errrec_devcap_t for more information. + */ + uint32_t oer_devcap; + /* + * Information for how to send the vendor specific recovery command. The + * timout was added in 2.0. + */ + uint8_t oer_vsr_opcode; + uint8_t oer_rsvd17[3]; + uint32_t oer_vsr_cdw12; + uint32_t oer_vsr_cdw13; + uint8_t oer_vsr_to; + /* + * Secondary recovery actions post-reset (2.5). Uses the same bits as + * ocp_errrec_dra_t. + */ + uint8_t oer_dra2; + uint8_t oer_dra2_to; + uint8_t oer_npanic; + uint64_t oer_old_panics[4]; + uint8_t oer_rsvd54[430]; + /* + * V1.0: 1, V2.0: 2, V2.5: 3 + */ + uint16_t oer_vers; + /* + * Log page GUID: 5A1983BA3DFD4DABAE3430FE2131D944h. + */ + uint8_t oer_guid[16]; +} ocp_vul_errrec_t; + +/* + * List of panic reset actions that should be taken to recover. + */ +typedef enum { + /* NVMe Controller Reset */ + OCP_LOG_ERRREC_F_PRA_CTRL = 1 << 0, + /* NVM Subsystem Reset */ + OCP_LOG_ERRREC_F_PRA_SUBSYS = 1 << 1, + /* PCIe Function Level Reset */ + OCP_LOG_ERRREC_F_PRA_FLR = 1 << 2, + /* ASSERT #PERST (PCIe Fundamental Reset) */ + OCP_LOG_ERRREC_F_PRA_PERST = 1 << 3, + /* Power cycle the device */ + OCP_LOG_ERRREC_F_PRA_POWER = 1 << 4, + /* PCIe conventional hot reset */ + OCP_LOG_ERRREC_F_PRA_HOT = 1 << 5 +} ocp_errrec_pra_t; + +typedef enum { + /* Do nothing */ + OCP_LOG_ERRREC_F_DRA_NONE = 1 << 0, + /* Format required */ + OCP_LOG_ERRREC_F_DRA_FMT = 1 << 1, + /* Vendor specific commad */ + OCP_LOG_ERRREC_F_DRA_VSC = 1 << 2, + /* Vendor analysis required */ + OCP_LOG_ERRREC_F_DRA_VAR = 1 << 3, + /* Replace the device */ + OCP_LOG_ERRREC_F_DRA_REPLACE = 1 << 4, + /* Sanitize required */ + OCP_LOG_ERRREC_F_DRA_SANITIZE = 1 << 5, + /* + * Indicates that there is permanent data loss in some LBAs. The LBAs + * are identified by the LBA Status log 0xe. + */ + OCP_LOG_ERRREC_F_DRA_DATALOSS = 1 << 6, +} ocp_errrec_dra_t; + +/* + * Device capabilities. Used to indicate how a message about a panic can be sent + * today. + */ +typedef enum { + OCP_LOG_ERRREC_F_DEVCAP_AEN = 1 << 0, + OCP_LOG_ERRREC_F_DEVCAP_CFS = 1 << 1 +} ocp_errrec_devcap_t; + +/* + * OCP Firmware Activation. Present in 1.0 and 2.0. Removed in 2.5. + */ +typedef struct { + uint8_t ofe_vers; + uint8_t ofe_len; + uint8_t ofe_rsvd2[2]; + uint16_t ofe_count; + uint64_t ofe_ts; + uint8_t ofe_rsvd14[8]; + uint64_t ofe_pcc; + uint64_t ofe_prev_fw; + uint64_t ofe_new_fw; + uint8_t ofe_slot; + uint8_t ofe_ctype; + uint16_t ofe_res; + uint8_t ofe_rsvd50[14]; +} ocp_fwact_entry_t; + +typedef struct { + uint8_t ofw_lid; + uint8_t ofw_rsvd1[3]; + uint32_t ofw_nents; + ocp_fwact_entry_t ofw_hist[20]; + uint8_t ofw_rsvd1288[2790]; + /* + * V1.0: 1, V2.0: 1 + */ + uint16_t ofw_vers; + /* + * Log Page GUID: 3AC8AB24DE2A3F6DAB4769A796Dh. + */ + uint8_t ofw_guid[16]; +} ocp_vul_fwact_t; + +/* + * Latency Monitor log. Added in V2.0. + */ +typedef struct { + uint32_t obc_read; + uint32_t obc_write; + uint32_t obc_dealloc; + uint32_t obc_rsvd; +} ocp_lat_bkt_ctr_t; + +typedef struct { + uint64_t ola_read; + uint64_t ola_write; + uint64_t ola_dealloc; +} ocp_lat_alts_t; + +typedef struct { + uint16_t olm_read; + uint16_t olm_write; + uint16_t olm_dealloc; +} ocp_lat_aml_t; + +typedef struct { + /* + * Latency monitor features. See ocp_lat_lmfs_t. + */ + uint8_t ol_lmfs; + uint8_t ol_rsvd1[1]; + /* + * Active bucket timer, its threshold, and general thresholds. + */ + uint16_t ol_abt; + uint16_t ol_abt_thresh; + uint8_t ol_thresh_a; + uint8_t ol_thresh_b; + uint8_t ol_thresh_c; + uint8_t ol_thresh_d; + /* + * Active latency configuration. See ocp_lat_alc_t. + */ + uint16_t ol_alc; + uint8_t ol_alw_min; + uint8_t ol_rsvd13[19]; + /* + * Active bucket counters. + */ + ocp_lat_bkt_ctr_t ol_ctr0; + ocp_lat_bkt_ctr_t ol_ctr1; + ocp_lat_bkt_ctr_t ol_ctr2; + ocp_lat_bkt_ctr_t ol_ctr3; + /* + * Active Latency Stamps. These contain 64-bit timestamps for when + * events occurred. Grouped by bucket. + */ + ocp_lat_alts_t ol_ts0; + ocp_lat_alts_t ol_ts1; + ocp_lat_alts_t ol_ts2; + ocp_lat_alts_t ol_ts3; + /* + * Active Measured Latency. Grouped by bucket. + */ + ocp_lat_aml_t ol_aml0; + ocp_lat_aml_t ol_aml1; + ocp_lat_aml_t ol_aml2; + ocp_lat_aml_t ol_aml3; + uint16_t ol_als_units; + uint8_t ol_rsvd218[22]; + /* + * Static versions of everything above. + */ + ocp_lat_bkt_ctr_t ol_sb0; + ocp_lat_bkt_ctr_t ol_sb1; + ocp_lat_bkt_ctr_t ol_sb2; + ocp_lat_bkt_ctr_t ol_sb3; + ocp_lat_alts_t ol_sts0; + ocp_lat_alts_t ol_sts1; + ocp_lat_alts_t ol_sts2; + ocp_lat_alts_t ol_sts3; + ocp_lat_aml_t ol_saml0; + ocp_lat_aml_t ol_saml1; + ocp_lat_aml_t ol_saml2; + ocp_lat_aml_t ol_saml3; + uint16_t ol_als_sunits; + uint8_t ol_rsvd426[10]; + /* + * Debug log related fields. The number of dword fields is specific to + * v2.5. + */ + uint8_t ol_dbg_ndw[12]; + uint16_t ol_dbg_trig; + uint16_t ol_dbg_ml; + uint64_t ol_dbg_ts; + uint16_t ol_dbg_ptr; + uint16_t ol_dbg_src; + uint8_t ol_dbg_units; + uint8_t ol_rsvd465[29]; + /* + * V2.0: 1, V2.5: 4 + */ + uint16_t ol_vers; + /* + * Log page GUID: 85D45E58D4E643709C6C84D08CC07A92h. + */ + uint8_t ol_guid[16]; +} ocp_vul_lat_t; + +typedef enum { + OPC_LOG_LAT_F_LFMS_EN = 1 << 0, + OPC_LOG_LAT_F_LFMS_ALC_SUP = 1 << 1, + OPC_LOG_LAT_F_LFMS_AML_SUP = 1 << 2, +} ocp_lat_lmfs_t; + +typedef enum { + OCP_LOG_LAT_F_ALC_B0_READ = 1 << 0, + OCP_LOG_LAT_F_ALC_B0_WRITE = 1 << 1, + OCP_LOG_LAT_F_ALC_B0_DEALLOC = 1 << 2, + OCP_LOG_LAT_F_ALC_B1_READ = 1 << 3, + OCP_LOG_LAT_F_ALC_B1_WRITE = 1 << 4, + OCP_LOG_LAT_F_ALC_B1_DEALLOC = 1 << 5, + OCP_LOG_LAT_F_ALC_B2_READ = 1 << 6, + OCP_LOG_LAT_F_ALC_B2_WRITE = 1 << 7, + OCP_LOG_LAT_F_ALC_B2_DEALLOC = 1 << 8, + OCP_LOG_LAT_F_ALC_B3_READ = 1 << 9, + OCP_LOG_LAT_F_ALC_B3_WRITE = 1 << 10, + OCP_LOG_LAT_F_ALC_B3_DEALLOC = 1 << 11 +} ocp_lat_alc_t; + +/* + * Device Capabilities Log. Introduced in v2.0. + */ +typedef struct { +#ifdef _BIT_FIELDS_LTOH + uint8_t odp_nps:5; + uint8_t odp_rsvd5:2; + uint8_t odp_valid:1; +#else + uint8_t odp_valid:1; + uint8_t odp_rsvd5:2; + uint8_t odp_nps:5; +#endif /* _BIT_FIELDS_LTOH */ +} ocp_dssd_ps_t; + +typedef struct { + uint16_t odc_nports; + uint16_t odc_oob_sup; + uint16_t odc_wz_sup; + uint16_t odc_san_sup; + uint16_t odc_dsmgmt_sup; + uint16_t odc_wunc_sup; + uint16_t odc_fuse_sup; + uint16_t odc_dssd_min_valid; + ocp_dssd_ps_t odc_dssd[128]; + uint8_t odc_rsvd144[3934]; + /* + * V2.0: 1, V2.5: 1 + */ + uint16_t odc_vers; + /* + * Log page GUID: B7053C914B58495D98C9E1D10D054297h + */ + uint8_t odc_guid[16]; +} ocp_vul_devcap_t; + +typedef enum { + /* PCIe VDM Supported */ + OCP_LOG_DEVCAP_F_OOB_VDM = 1 << 0, + /* NVMe Basic Management Command supported */ + OCP_LOG_DEVCAP_F_OOB_BMC = 1 << 1, + /* Passed compliance testing */ + OCP_LOG_DEVCAP_F_OOB_COMPLY = 1 << 15, +} ocp_devcap_oob_t; + +typedef enum { + /* Write Zeros command supported */ + OCP_LOG_DEVCAP_F_WZ_SUP = 1 << 0, + /* Write Zeros deallocate bit */ + OCP_LOG_DEVCAP_F_WZ_DEAC = 1 << 1, + /* Write Zeros force unit access */ + OCP_LOG_DEVCAP_F_WZ_FUA = 1 << 2, + /* Adheres to spec req NVME-IO-5 */ + OCP_LOG_DEVCAP_F_WZ_IO5 = 1 << 3, + /* Adheres to spec req NVME-IO-6 */ + OCP_LOG_DEVCAP_F_WZ_IO6 = 1 << 4, + /* Passed compliance testing */ + OCP_LOG_DEVCAP_F_WZ_COMPLY = 1 << 15 +} ocp_devcap_wz_t; + +typedef enum { + /* Dataset Management command supported */ + OCP_LOG_DEVCAP_F_DSMGMT_SUP = 1 << 0, + /* Attribute deallocate supported */ + OCP_LOG_DEVCAP_F_DSMGMT_AD = 1 << 1, + /* Passed compliance testing */ + OCP_LOG_DEVCAP_F_DSMGMT_COMPLY = 1 << 15 +} ocp_devcap_dsmgmt_t; + +typedef enum { + /* Write uncorrectable supported */ + OCP_LOG_DEVCAP_F_WUNC_SUP = 1 << 0, + /* Works with a single LBA */ + OCP_LOG_DEVCAP_F_WUNC_ONE = 1 << 1, + /* Works with max LBAs per NVMe spec */ + OCP_LOG_DEVCAP_F_WUNC_MAX = 1 << 2, + /* Adheres to spec req NVME-IO-14 */ + OCP_LOG_DEVCAP_F_WUNC_IO14 = 1 << 3, + /* Passed compliance testing */ + OCP_LOG_DEVCAP_F_WUNC_COMPLY = 1 << 15 +} ocp_devcap_wunc_t; + +typedef enum { + /* Fused operation supported */ + OCP_LOG_DEVCAP_F_FUSE_SUP = 1 << 0, + /* Passed compliance testing */ + OCP_LOG_DEVCAP_F_FUSE_COMPLY = 1 << 15 +} ocp_devcap_fuse_t; + +/* + * Unsupported Requirements log. This log is structured such that each + * unimplemented requirement must fit into a single 16 byte array which should + * be padded with zeros (but nothing in the spec suggests it guarantees + * termination). We keep the requirements string as a uint8_t as opposed to a + * char to indicate that this should not be trusted and must be parsed. + */ +typedef struct { + uint8_t ors_str[16]; +} ocp_req_str_t; + +typedef struct { + uint16_t our_nunsup; + uint8_t our_rsvd2[14]; + ocp_req_str_t ors_reqs[253]; + uint8_t our_rsvd4064[14]; + /* + * V2.0: 1, V2.5: 1 + */ + uint16_t our_vers; + /* + * Log page GUID: C7BB98B7D0324863BB2C23990E9C722Fh + */ + uint8_t our_guid[16]; +} ocp_vul_unsup_req_t; + +/* + * Telemetry String Log. This log, added in OCP v2.5 is structured with a header + * of fixed tables followed by variable information based upon the header + * information. + */ +typedef struct { + /* + * v2.5: 1 + */ + uint8_t ots_vers[1]; + uint8_t ots_rsvd1[15]; + /* + * Log Page GUID: B13A83691A8F408B9EA495940057AA44h + */ + uint8_t ots_guid[16]; + /* + * These members generally indicate different parts of the table size. + * Each of them is a number of uint32_t's long (aka dwords). + */ + uint64_t ots_sls_ndw; + uint8_t ots_rsvd40[24]; + uint64_t ots_sit_off_ndw; + uint64_t ots_sit_len_ndw; + uint64_t ots_est_off_ndw; + uint64_t ots_est_len_ndw; + uint64_t ots_vuest_off_ndw; + uint64_t ots_vuest_len_ndw; + uint64_t ots_asct_off_ndw; + uint64_t ots_asct_len_ndw; + /* + * These are nominally ASCII strings that are supposed to cover various + * FIFOs. + */ + uint8_t ots_fifo0[16]; + uint8_t ots_fifo1[16]; + uint8_t ots_fifo2[16]; + uint8_t ots_fifo3[16]; + uint8_t ots_fifo4[16]; + uint8_t ots_fifo5[16]; + uint8_t ots_fifo6[16]; + uint8_t ots_fifo7[16]; + uint8_t ots_fifo8[16]; + uint8_t ots_fifo9[16]; + uint8_t ots_fifo10[16]; + uint8_t ots_fifo11[16]; + uint8_t ots_fifo12[16]; + uint8_t ots_fifo13[16]; + uint8_t ots_fifo14[16]; + uint8_t ots_fifo15[16]; + uint8_t ots_rsvd384[48]; + /* + * After this we have the various tables. While in theory they are + * supposed to be ordered such that its SITS, ESTS, VUEST, ASCTS, in + * theory these could be at any offset. The individual structures which + * this could be are defined below. + */ + uint8_t ots_data[]; +} ocp_vul_telstr_t; + +/* + * These three structures all have the same general form. They contain a 0s + * based length and then an offset from the start of the ASCII string table. The + * actual string table is spaced in uint32_t increments and padded with spaces. + * There is no NULL terminator in it. + */ +typedef struct { + uint16_t ocp_sit_id; + uint8_t ocp_sit_rsvd2[1]; + /* + * Zeros based length, so add one. + */ + uint8_t ocp_sit_len; + /* + * Offset from the start of the ASCII table for this entry. + */ + uint64_t ocp_sit_off; + uint8_t ocp_sit_rsvd12[4]; +} ocp_vul_telstr_sit_t; + +typedef struct { + uint8_t ocp_est_class; + uint16_t ocp_est_eid; + uint8_t ocp_est_len; + uint64_t ocp_est_off; + uint8_t ocp_est_rsvd12[4]; +} ocp_vul_telstr_est_t; + +typedef struct { + uint8_t ocp_vuest_class; + uint16_t ocp_vuest_eid; + uint8_t ocp_vuest_len; + uint64_t ocp_vuest_off; + uint8_t ocp_vuest_rsvd12[4]; +} ocp_vul_telstr_vuest_t; + + + +/* + * Our current version of smatch cannot handle packed structures. + */ +#ifndef __CHECKER__ +CTASSERT(sizeof (ocp_vul_smart_t) == 512); +CTASSERT(offsetof(ocp_vul_smart_t, osh_therm_event) == 96); +CTASSERT(offsetof(ocp_vul_smart_t, osh_vers) == 494); +CTASSERT(sizeof (ocp_vul_errrec_t) == 512); +CTASSERT(offsetof(ocp_vul_errrec_t, oer_npanic) == 31); +CTASSERT(offsetof(ocp_vul_errrec_t, oer_npanic) == 31); +CTASSERT(sizeof (ocp_fwact_entry_t) == 64); +CTASSERT(offsetof(ocp_fwact_entry_t, ofe_rsvd50) == 50); +CTASSERT(sizeof (ocp_vul_fwact_t) == 4096); +CTASSERT(offsetof(ocp_vul_fwact_t, ofw_rsvd1288) == 1288); +CTASSERT(offsetof(ocp_vul_fwact_t, ofw_vers) == 4078); +CTASSERT(sizeof (ocp_lat_bkt_ctr_t) == 16); +CTASSERT(sizeof (ocp_lat_alts_t) == 24); +CTASSERT(sizeof (ocp_lat_aml_t) == 6); +CTASSERT(offsetof(ocp_vul_lat_t, ol_aml0) == 192); +CTASSERT(offsetof(ocp_vul_lat_t, ol_rsvd218) == 218); +CTASSERT(offsetof(ocp_vul_lat_t, ol_als_sunits) == 424); +CTASSERT(sizeof (ocp_vul_lat_t) == 512); +CTASSERT(sizeof (ocp_vul_devcap_t) == 4096); +CTASSERT(offsetof(ocp_vul_devcap_t, odc_rsvd144) == 144); +CTASSERT(sizeof (ocp_req_str_t) == 16); +CTASSERT(sizeof (ocp_vul_unsup_req_t) == 4096); +CTASSERT(sizeof (ocp_vul_telstr_t) == 432); +CTASSERT(offsetof(ocp_vul_telstr_t, ots_fifo0) == 128); +CTASSERT(offsetof(ocp_vul_telstr_t, ots_rsvd384) == 384); +CTASSERT(sizeof (ocp_vul_telstr_sit_t) == 16); +CTASSERT(sizeof (ocp_vul_telstr_est_t) == 16); +CTASSERT(sizeof (ocp_vul_telstr_vuest_t) == 16); +#endif + +#pragma pack() /* pack(1) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_OCP_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/phison.h b/illumos-x86_64/usr/include/sys/nvme/phison.h new file mode 100644 index 00000000..6ff16595 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/phison.h @@ -0,0 +1,50 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_NVME_PHISON_H +#define _SYS_NVME_PHISON_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This header contains all of the current vendor-specific entries for known + * Phison devices as well as common structures and definitions that are shared + * across multiple device families. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PHISON_PCI_VID 0x1987 +#define PHISON_X200_DID 0x5302 + +typedef enum { + PHISON_X200_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + PHISON_X200_LOG_OCP_ERRREC = OCP_LOG_DSSD_ERROR_REC, + PHISON_X200_LOG_OCP_FWACT = OCP_LOG_DSSD_FWACT, + PHISON_X200_LOG_OCP_LATENCY = OCP_LOG_DSSD_LATENCY, + PHISON_X200_LOG_OCP_DEV_CAP = OCP_LOG_DSSD_DEV_CAP, + PHISON_X200_LOG_OCP_UNSUP = OCP_LOG_DSSD_UNSUP_REQ +} phison_x200_vul_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_PHISON_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/samsung.h b/illumos-x86_64/usr/include/sys/nvme/samsung.h new file mode 100644 index 00000000..e6105a1a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/samsung.h @@ -0,0 +1,52 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_NVME_SAMSUNG_H +#define _SYS_NVME_SAMSUNG_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This header contains all of the current vendor-specific entries for known + * Phison devices as well as common structures and definitions that are shared + * across multiple device families. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SAMSUNG_PCI_VID 0x144d +#define SAMSUNG_PM9D3_DID 0xa900 + +typedef enum { + SAMSUNG_PM9D3_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + SAMSUNG_PM9D3_LOG_OCP_ERRREC = OCP_LOG_DSSD_ERROR_REC, + SAMSUNG_PM9D3_LOG_OCP_FWACT = OCP_LOG_DSSD_FWACT, + SAMSUNG_PM9D3_LOG_OCP_LATENCY = OCP_LOG_DSSD_LATENCY, + SAMSUNG_PM9D3_LOG_OCP_DEV_CAP = OCP_LOG_DSSD_DEV_CAP, + SAMSUNG_PM9D3_LOG_OCP_UNSUP = OCP_LOG_DSSD_UNSUP_REQ, + SAMSUNG_PM9D3_LOG_OCP_TCG = OCP_LOG_DSSD_TCG, + SAMSUNG_PM9D3_LOG_OCP_TELEMETRY = OCP_LOG_DSSD_TELEMETRY, +} samsung_pm9d3_vul_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_SAMSUNG_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/solidigm.h b/illumos-x86_64/usr/include/sys/nvme/solidigm.h new file mode 100644 index 00000000..50857fa7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/solidigm.h @@ -0,0 +1,131 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer company + */ + +#ifndef _SYS_NVME_SOLIDIGM_H +#define _SYS_NVME_SOLIDIGM_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This header contains all of the current vendor-specific entries for supported + * Solidigm devices as well as common structures and definitions that are shared + * across multiple device families. This also contains the Intel variants as + * these devices have been rebranded over time and therefore works as a + * reasonable consolidation point for the Intel branded devices too. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define INTEL_PCI_VID 0x8086 +#define SOLIDIGM_PCI_VID 0x25e + +/* + * All data structures must be packed to account for the layout from the various + * programmer's manuals. + */ +#pragma pack(1) + +/* + * This represents a single entry which is used as part of the device-specific + * SMART log (generally opcode 0xca). + */ +typedef struct { + uint8_t sse_type; + uint8_t sse_rsvd2[2]; + uint8_t sse_norm; + uint8_t sse_rsvd4; + uint8_t sse_raw[6]; + uint8_t sse_rsvd11; +} solidigm_smart_ent_t; + +/* + * These are the different type keys that exist for the solidigm_smart_ent_t + * above. These will show up in an arbitrary order in the device log. + */ +typedef enum { + SOLIDIGM_SMART_TYPE_PROGRAM_FAIL = 0xab, + SOLIDIGM_SMART_TYPE_ERASE_FAIL = 0xac, + SOLIDIGM_SMART_TYPE_WEAR_LEVEL = 0xad, + SOLIDIGM_SMART_TYPE_E2E_ERROR_DET = 0xb8, + SOLIDIGM_SMART_TYPE_CRC_ERROR = 0xc7, + SOLIDIGM_SMART_TYPE_TIMED_MEDIA_WEAR = 0xe2, + SOLIDIGM_SMART_TYPE_TIMED_HOST_READ = 0xe3, + SOLIDIGM_SMART_TYPE_TIMED_TIMER = 0xe4, + SOLIDIGM_SMART_TYPE_IN_FLIGHT_READ = 0xe5, + SOLIDIGM_SMART_TYPE_IN_FLIGHT_WRITE = 0xe6, + SOLIDIGM_SMART_TYPE_THERM_THROTTLE = 0xea, + SOLIDIGM_SMART_TYPE_RESKU = 0xee, + SOLIDIGM_SMART_TYPE_RETRY_BUF_OVRFLW = 0xf0, + SOLIDIGM_SMART_TYPE_PLL_LOSS = 0xf3, + SOLIDIGM_SMART_TYPE_NAND_WRITE = 0xf4, + SOLIDIGM_SMART_TYPE_HOST_WRITE = 0xf5, + SOLIDIGM_SMART_TYPE_SYS_LIFE = 0xf6, + SOLIDIGM_SMART_TYPE_NAND_READ = 0xf8, + SOLIDIGM_SMART_TYPE_AVAIL_FW_DOWN = 0xf9, + SOLIDIGM_SMART_TYPE_READ_COLL = 0xfa, + SOLIDIGM_SMART_TYPE_WRITE_COLL = 0xfb, + SOLIDIGM_SMART_TYPE_XOR_PASS = 0xfc, + SOLIDIGM_SMART_TYPE_XOR_FAIL = 0xfd, + SOLIDIGM_SMART_TYPE_XOR_INVOKE = 0xfe, +} solidigm_smart_type_t; + +/* + * We size this based on the number of items that'll fit into a single 512 byte + * log page. + */ +typedef struct { + solidigm_smart_ent_t vsl_data[512 / sizeof (solidigm_smart_ent_t)]; +} solidigm_vul_smart_log_t; + +/* + * Common temperature structure across different device generations. + * Temperatures are all measured in units of degrees C. + */ +typedef struct { + uint64_t temp_cur; + uint64_t temp_over_last; + uint64_t temp_over_life; + uint64_t temp_comp_life_high; + uint64_t temp_comp_life_low; + uint8_t temp_rsvd40[40]; + uint64_t temp_norm_max_warn; + uint8_t temp_rsvd88[8]; + uint64_t temp_spec_min_op; + uint64_t temp_est_off; +} solidigm_vul_temp_t; + +#pragma pack() /* pack(1) */ + +/* + * Our current version of smatch cannot handle packed structures. + */ +#ifndef __CHECKER__ +CTASSERT(sizeof (solidigm_smart_ent_t) == 12); +CTASSERT(sizeof (solidigm_vul_smart_log_t) <= 512); +CTASSERT(sizeof (solidigm_vul_smart_log_t) > 500); +CTASSERT(sizeof (solidigm_vul_temp_t) == 112); +#endif /* __CHECKER__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_SOLIDIGM_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/solidigm_p5xxx.h b/illumos-x86_64/usr/include/sys/nvme/solidigm_p5xxx.h new file mode 100644 index 00000000..c238ee11 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/solidigm_p5xxx.h @@ -0,0 +1,241 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_SOLIDIGM_P5XXX_H +#define _SYS_NVME_SOLIDIGM_P5XXX_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * Vendor-specific definitions for the Intel/Solidigm 5000 series devices + * including the P5510, P5520, and P5620. Note, these device all share a PCI ID + * and must be disambiguated by their subsystem IDs. Logs fall into three + * buckets: + * + * 1) Those unique to the P5510. These are prefixed with INTEL_P5510. + * 2) Those that are shared between the P5510 and the P5[56]20. These are + * prefixed with SOLIDIGM_P5XXX. All logs in this case use the same data + * structure. Some logs have data structures shared across all devices and + * are in the top-level header. + * 3) Logs which are only supported by the P5520/P5620. These are prefixed with + * SOLIDIGM_P5X20. + */ + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The device ID isn't enough to distinguish these different devices and + * therefore we need to use the subsystem IDs as well. The 5510 only shows up + * with an Intel vendor ID; however, the 5520 and 5620 show up with both a + * Solidigm and Intel device ID. + */ +#define SOLIDIGM_P5XXX_DID 0xb60 +#define SOLIDIGM_P5510_U2_SDID 0x8008 +#define SOLIDIGM_P5520_U2_SDID 0x9008 +#define SOLIDIGM_P5520_E1S_9P5MM_SDID 0x900c +#define SOLIDIGM_P5520_E1S_15MM_SDID 0x900d +#define SOLIDIGM_P5520_E1L_SDID 0x901c +#define SOLIDIGM_P5620_U2_SDID 0x9108 + +typedef enum { + /* + * This is a log specific to the P5510 which contains a directory of the + * other log pages that are present. This is a 512 byte log page with a + * leading version and then information about vendor specific logs + * support at an offset of 2x log page. This is here for completeness + * sake. + */ + INTEL_P5510_LOG_DIR = 0xc0, + /* + * The P5520 and P5620 use 0xc0 as the OCP SMART log, which is different + * from the P5510. + */ + SOLIDIGM_P5X20_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + /* + * The next two logs are used to contain read and write command latency + * statistics. For these to have useful content, the device must be + * explicitly told to perform tracking with a vendor-specific feature. + * Uses the solidigm_vul_p5xxx_lat_t structure. + */ + SOLIDIGM_P5XXX_LOG_READ_LAT = 0xc1, + SOLIDIGM_P5XXX_LOG_WRITE_LAT = 0xc2, + /* + * Uses the solidigm_vul_temp_t. + */ + SOLIDIGM_P5XXX_LOG_TEMP = 0xc5, + /* + * Uses the solidigm_vul_smart_log_t. The maximum number of entires is + * always grabbed, but there may be holes. + */ + SOLIDIGM_P5XXX_LOG_SMART = 0xca, + /* + * Uses the solidigm_vul_p5xxx_ioq_t. + */ + SOLIDIGM_P5XXX_LOG_IO_QUEUE = 0xcb, + /* + * This should be treated as a 512 byte log with an ASCII string encoded + * in it. However, don't assume hardware only outputs ASCII. + */ + SOLIDIGM_P5XXX_LOG_MARK_DESC = 0xdd, + /* + * Uses the solidigm_vul_temp_t. + */ + SOLIDIGM_P5X20_LOG_POWER = 0xf2, + /* + * Uses solidigm_vul_p5xxx_gc_t. + */ + SOLIDIGM_P5XXX_LOG_GC = 0xfd, + /* + * Uses solidigm_vul_p5xxx_lat_outlier_t. + */ + SOLIDIGM_P5XXX_LOG_OUTLIER = 0xfe, +} solidigm_p5xxx_vul_t; + +/* + * All data structures must be packed to account for the layout from the various + * programmer's manuals. + */ +#pragma pack(1) + +/* + * This log page is used for the read and write latency commands. These are + * organized into groups of 4 byte buckets. Each bucket has a range and a given + * step. For example, lat_63_127us_1us is latency in the range [63us, 127us) + * with the bucket width as the last parameter. + */ +typedef struct { + uint16_t lat_maj; + uint16_t lat_minor; + uint32_t lat_0_63us_1us[64]; + uint32_t lat_63_127us_1us[64]; + uint32_t lat_127_255us_2us[64]; + uint32_t lat_255_510us_4us[64]; + uint32_t lat_510_1p02ms_8us[64]; + uint32_t lat_1p02_2p04ms_16us[64]; + uint32_t lat_2p04_4p08ms_32us[64]; + uint32_t lat_4p08_8p16ms_64us[64]; + uint32_t lat_8p16_16p32ms_128us[64]; + uint32_t lat_16p32_32p64ms_256us[64]; + uint32_t lat_32p64_65p28ms_512us[64]; + uint32_t lat_65p28_130p56ms_1p024ms[64]; + uint32_t lat_130p56_256p12ms_2p048ms[64]; + uint32_t lat_251p12_522p25ms_4p096ms[64]; + uint32_t lat_522p24ms_1p04s_8p192ms[64]; + uint32_t lat_1p04_2p09s_16p384ms[64]; + uint32_t lat_2p09_4p18s_32p768ms[64]; + uint32_t lat_4p18_8p36s_65p536ms[64]; + uint32_t lat_8p36_16p72s_131p072ms[64]; + uint8_t lat_avg[8]; +} solidigm_vul_p5xxx_lat_t; + +typedef struct { + uint16_t iosq_id; + uint16_t iosq_iocq_id; + uint16_t iosq_head; + uint16_t iosq_tail; + uint16_t iosq_out; + uint16_t iosq_max_qdepth; +} solidigm_vul_iosq_t; + +typedef struct { + uint16_t iocq_id; + uint16_t iocq_head; + uint8_t iocq_rsvd4[6]; +} solidigm_vul_iocq_t; + +#define SOLIDIGM_VUL_MAX_QUEUES 32 + +typedef struct { + uint16_t ioq_vers; + uint16_t ioq_niosq; + uint16_t ioq_niocq; + solidigm_vul_iosq_t ioq_iosq[SOLIDIGM_VUL_MAX_QUEUES]; + solidigm_vul_iocq_t ioq_iocq[SOLIDIGM_VUL_MAX_QUEUES]; + uint8_t ioq_rsvd710[314]; +} solidigm_vul_p5xxx_ioq_t; + +/* + * All values are in in the power measurement log are in uW. + */ +typedef struct { + uint32_t pow_vin1; + uint32_t pow_vin2; +} solidigm_vul_p5x2x_power_t; + +/* + * This is the size we recommend one obtain while reading the marketing name log + * page. + */ +#define SOLIDIGM_VUC_MARK_NAME_LEN 512 + +typedef struct { + uint32_t gce_type; + uint64_t gce_ts; +} solidigm_vul_gc_ent_t; + +#define SOLIDIGM_VUC_MAX_GC 100 + +typedef struct { + uint16_t gc_major; + uint16_t gc_minor; + solidigm_vul_gc_ent_t gc_ents[SOLIDIGM_VUC_MAX_GC]; +} solidigm_vul_p5xxx_gc_t; + +typedef struct { + uint64_t le_ts; + uint32_t le_cmd; + uint32_t le_lat_us; + uint64_t le_lba; +} soligm_vul_lat_ent_t; + +typedef struct { + uint16_t lao_major; + uint16_t lao_minor; + uint8_t lao_rsvd[4]; + uint64_t lao_nents; + soligm_vul_lat_ent_t lao_ents[]; +} solidigm_vul_p5xxx_lat_outlier_t; + +#pragma pack() /* pack(1) */ + +/* + * Our current version of smatch cannot handle packed structures. + */ +#ifndef __CHECKER__ +CTASSERT(sizeof (solidigm_vul_p5xxx_lat_t) == 4876); +CTASSERT(offsetof(solidigm_vul_p5xxx_lat_t, lat_4p18_8p36s_65p536ms) == 4356); +CTASSERT(sizeof (solidigm_vul_iosq_t) == 12); +CTASSERT(sizeof (solidigm_vul_iocq_t) == 10); +CTASSERT(offsetof(solidigm_vul_p5xxx_ioq_t, ioq_iocq) == 390); +CTASSERT(offsetof(solidigm_vul_p5xxx_ioq_t, ioq_rsvd710) == 710); +CTASSERT(sizeof (solidigm_vul_p5xxx_ioq_t) == 1024); +CTASSERT(sizeof (solidigm_vul_p5x2x_power_t) == 8); +CTASSERT(sizeof (solidigm_vul_gc_ent_t) == 12); +CTASSERT(sizeof (solidigm_vul_p5xxx_gc_t) == 1204); +#endif /* __CHECKER__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_SOLIDIGM_P5XXX_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/solidigm_ps10x0.h b/illumos-x86_64/usr/include/sys/nvme/solidigm_ps10x0.h new file mode 100644 index 00000000..2610e0f9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/solidigm_ps10x0.h @@ -0,0 +1,58 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_SOLIDIGM_PS10X0_H +#define _SYS_NVME_SOLIDIGM_PS10X0_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * Vendor-specific definitions for the Solidigm (nee Intel) PS1010 and PS1030. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SOLIDIGM_PS10X0_DID 0x2B59 +#define SOLIDIGM_PS1010_U2_SDID 0x0008 +#define SOLIDIGM_PS1010_E3_SDID 0x0019 +#define SOLIDIGM_PS1030_U2_SDID 0x0108 +#define SOLIDIGM_PS1030_E3_SDID 0x0119 + +typedef enum { + SOLIDIGM_PS10x0_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + SOLIDIGM_PS10x0_LOG_OCP_ERRREC = OCP_LOG_DSSD_ERROR_REC, + SOLIDIGM_PS10x0_LOG_OCP_FWACT = OCP_LOG_DSSD_FWACT, + SOLIDIGM_PS10x0_LOG_OCP_LATENCY = OCP_LOG_DSSD_LATENCY, + SOLIDIGM_PS10x0_LOG_OCP_DEV_CAP = OCP_LOG_DSSD_DEV_CAP, + SOLIDIGM_PS10x0_LOG_OCP_UNSUP = OCP_LOG_DSSD_UNSUP_REQ, + /* + * Uses the solidigm_vul_smart_log_t. The maximum number of entries is + * always grabbed, but there may be holes. + */ + SOLIDIGM_PS10x0_LOG_SMART = 0xca, + /* + * Uses the solidigm_vul_temp_t. + */ + SOLIDIGM_PS10x0_LOG_TEMP = 0xd5 +} solidigm_ps10x0_vul_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_SOLIDIGM_PS10X0_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/wdc.h b/illumos-x86_64/usr/include/sys/nvme/wdc.h new file mode 100644 index 00000000..ab7ccb90 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/wdc.h @@ -0,0 +1,147 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_NVME_WDC_H +#define _SYS_NVME_WDC_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * This header contains all of the current vendor-specific entries for known WDC + * devices as well as common structures and definitions that are shared across + * multiple device families. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define WDC_PCI_VID 0x1b96 + +/* + * All data structures must be packed to account for the layout from the various + * programmer's manuals. + */ +#pragma pack(1) + +/* + * WDC common device power samples log page data structure. All power samples + * are in mW. + */ +typedef struct { + uint32_t pow_nsamples; + uint32_t pow_samples[]; +} wdc_vul_power_t; + +/* + * This is a device generation agnostic structure that defines temperature + * samples log page. The temperature is in degrees Celsius, but we do not + * currently know the exact format of the data. Each device has a specific + * enumeration that describes what each array entry is supposed to mean. + */ +typedef struct { + uint32_t temp_nsamples; + uint32_t temp_samples[]; +} wdc_vul_temp_t; + +/* + * The device manageability log page consists of a series of variable length + * entries which are guaranteed to always be 4-byte aligned. The length includes + * the length of the header itself. This header is used to start the log itself + * and in that case the id is the version. + */ +typedef struct { + uint32_t vsd_len; + uint32_t vsd_id; + uint8_t vsd_data[]; +} wdc_vsd_t; + +/* + * This is the WDC 'Counted ByteString'. This is not a null-terminated string! + * The length of data in bytes is stored in cbs_len (defined as little endian). + * There may be additional padding following csd_data to make up the fact that + * the device manageability log is units of four bytes. + */ +typedef struct { + uint32_t cbs_len; + uint8_t csd_data[]; +} wdc_cbs_t; + +/* + * Vendor Unique Commands that span multiple devices. + */ + +/* + * The e6 command is a diagnostic dump that can be initiated that traces its + * lineage back to the HDD world. The dump is variable sized and starts with an + * 8 byte header (the wdc_e6_header_t) which indicates the total size of the + * dump. + * + * The command accepts a number of dwords to read and uses cdw12 to indicate the + * dword offset to start to read out. + */ +#define WDC_VUC_E6_DUMP_OPC 0xe6 + +/* + * The following is the WDC e6 dump diagnostic header. This is used to determine + * the size of the full payload. The first member is a uint32_t. The second + * member determines the size of the log. e6_size[0] is the upper 24 bits, + * e6_size[1], bits 16-23, etc. This is a size in bytes, it cannot be passed to + * commands directly which are in units of uint32_t's. + */ +typedef struct { + uint32_t e6_head; + uint32_t e6_size_be; +} wdc_e6_header_t; + +CTASSERT((sizeof (wdc_e6_header_t) % 4) == 0); +CTASSERT(sizeof (wdc_e6_header_t) == 8); + +/* + * The drive diagnostic resize command allows certain devices to resize their + * capacity. This is a fully destructive operation. It is known to be supported + * by the SN840 and SN65x families. It utilizes a mode argument in cdw12 which + * indicates whether to get, set, or query progress. That argument is in + * bits[15:8]. To indicate that we are doing the resize operation of the opcode + * we must set bits[7:0] to 3. The target size is specified in cdw13. + */ +#define WDC_VUC_RESIZE_OPC 0xcc +#define WDC_VUC_RESIZE_CMD 0x3 +#define WDC_VUC_RESIZE_SUB_GET 0x0 +#define WDC_VUC_RESIZE_SUB_SET 0x1 +#define WDC_VUC_RESIZE_SUB_PHASE 0x2 + +/* + * Several WDC devices have a notion of an assert that is visible in the device + * manageability log. As part of recovering devices, that assert must be cleared + * through a vendor-specific command. + */ +#define WDC_VUC_ASSERT_OPC 0xd8 +#define WDC_VUC_ASSERT_CMD 0x3 +#define WDC_VUC_ASSERT_SUB_CLEAR 0x5 +#define WDC_VUC_ASSERT_SUB_INJECT 0x6 + +#pragma pack() /* pack(1) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_WDC_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/wdc_sn65x.h b/illumos-x86_64/usr/include/sys/nvme/wdc_sn65x.h new file mode 100644 index 00000000..79238709 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/wdc_sn65x.h @@ -0,0 +1,132 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_WDC_SN65X_H +#define _SYS_NVME_WDC_SN65X_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * Vendor-specific definitions for the WDC SN650 and SN655 NVMe devices. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define WDC_SN650_DID 0x2720 +#define WDC_SN655_DID 0x2722 + +typedef enum { + /* + * This is the same as the OCP SMART log. + */ + WDC_SN65X_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + /* + * This uses the common wdc_vul_power_t structure. + */ + WDC_SN65X_LOG_POWER = 0xc5, + /* + * This uses the common wdc_vul_temp_t structure. The specific + * measurements are recorded in the wdc_log_sn65x_temp_t. + */ + WDC_SN65X_LOG_TEMP = 0xc6, + WDC_SN65X_LOG_UNIQUE_SMART = 0xca +} wdc_sn65x_vul_t; + +typedef enum { + WDC_SN65X_TEMP_BOARD1 = 0, + WDC_SN65X_TEMP_BOARD2, + WDC_SN65X_TEMP_BOARD3, + WDC_SN65X_TEMP_INLET_LED, + WDC_SN65X_TEMP_OUTLET_HOST, + WDC_SN65X_TEMP_NAND, + WDC_SN65X_TEMP_FE, + WDC_SN65X_TEMP_FM0, + WDC_SN65X_TEMP_FM1, + WDC_SN65X_TEMP_THERMR, + WDC_SN65X_TEMP_AVG_THERMR, + WDC_SN65X_TEMP_AVG_NAND, + WDC_SN65X_TEMP_AVG_FE, + WDC_SN65X_TEMP_NSAMPLES +} wdc_sn65x_temp_sample_t; + +/* + * All data structures must be packed to account for the layout from the various + * programmer's manuals. + */ +#pragma pack(1) + +/* + * This structure represents an individual entry in the WDC Customer Unique + * SMART log page. + */ +typedef struct { + uint8_t vulp_id; + uint8_t vulp_rsvd0[2]; + uint8_t vulp_norm; + uint8_t vulp_rsvd1[1]; + uint8_t vulp_data[4]; + uint8_t vulp_pad[3]; +} wdc_vul_sn65x_smart_ent_t; + +/* + * This structure represents the layout of the 0xca log page. Each entry has an + * id that corresponds to it and should be validated when reading this. + */ +typedef struct { + wdc_vul_sn65x_smart_ent_t sm_prog_fail; + wdc_vul_sn65x_smart_ent_t sm_erase_fail; + wdc_vul_sn65x_smart_ent_t sm_wear_level; + wdc_vul_sn65x_smart_ent_t sm_etoe_edet; + wdc_vul_sn65x_smart_ent_t sm_crc_err; + wdc_vul_sn65x_smart_ent_t sm_timed_wear; + wdc_vul_sn65x_smart_ent_t sm_timed_read; + wdc_vul_sn65x_smart_ent_t sm_timed_timer; + wdc_vul_sn65x_smart_ent_t sm_therm_throt; + wdc_vul_sn65x_smart_ent_t sm_retry_buf_over; + wdc_vul_sn65x_smart_ent_t sm_pll_lock_loss; + wdc_vul_sn65x_smart_ent_t sm_nand_write; + wdc_vul_sn65x_smart_ent_t sm_host_write; +} wdc_vul_sn65x_smart_t; + +typedef enum { + WDC_SN65X_SMART_ENT_ID_PROG_FAIL = 0, + WDC_SN65X_SMART_END_ID_ERASE_FAIL, + WDC_SN65X_SMART_ENT_ID_WEAR_LEVEL, + WDC_SN65X_SMART_ENT_ID_ETOE_ERROR_DET, + WDC_SN65X_SMART_ENT_ID_CRC_ERROR, + WDC_SN65X_SMART_ENT_ID_TIMED_MEDIA_WEAR, + WDC_SN65X_SMART_ENT_ID_TIMED_READS, + WDC_SN65X_SMART_ENT_ID_TIMED_TIMER, + WDC_SN65X_SMART_ENT_ID_THERMAL_THROTLE, + WDC_SN65X_SMART_ENT_ID_RETRY_BUF_OVERFLOW, + WDC_SN65X_SMART_ENT_ID_PLL_LOCK_LOSS, + WDC_SN65X_SMART_ENT_ID_NAND_WRITTEN, + WDC_SN65X_SMART_ENT_ID_HOST_WRITTEN +} wdc_sn65x_smart_ent_id_t; + +#pragma pack() /* pack(1) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_WDC_SN65X_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/wdc_sn840.h b/illumos-x86_64/usr/include/sys/nvme/wdc_sn840.h new file mode 100644 index 00000000..300df072 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/wdc_sn840.h @@ -0,0 +1,214 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_NVME_WDC_SN840_H +#define _SYS_NVME_WDC_SN840_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * Vendor-specific definitions for the WDC SN840 NVMe device. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define WDC_SN840_DID 0x2500 + +typedef enum { + /* + * This log is the fixed wdc_vul_sn840_eol_t structure. + */ + WDC_SN840_LOG_EOL = 0xc0, + /* + * This log uses the wdc_log_vsd_t with a series of different entry + * types. + */ + WDC_SN840_LOG_DEV_MANAGE = 0xc2, + /* + * While this log exists, we do not know the data format of it. + */ + WDC_SN840_LOG_PCIE_SI = 0xc4, + /* + * This uses the common wdc_vul_power_t structure. + */ + WDC_SN840_LOG_POWER = 0xc5, + /* + * This uses the common wdc_vul_temp_t structure. The specific + * measurements are recorded in the wdc_log_sn840_temp_t. + */ + WDC_SN840_LOG_TEMP = 0xc6, + /* + * The firmware activation log uses the wdc_sn840_fw_act_hdr_t stucture + * as a header and then is followed by one or more + * wdc_vul_sn840_fw_act_ent_t structures that have entry information. + */ + WDC_SN840_LOG_FW_ACT = 0xcb, + /* + * This log uses the wdc_vul_sn840_ccds_info_t structure. + */ + WDC_SN840_LOG_CCDS = 0xfa +} wdc_sn840_vul_t; + +/* + * All data structures must be packed to account for the layout from the various + * programmer's manuals. + */ +#pragma pack(1) + +/* + * Device EOL Log Page + */ +typedef struct { + uint8_t eol_rsvd0[76]; + uint32_t eol_rbc; + uint8_t eol_rsvd1[4]; + uint32_t eol_waf; + uint32_t eol_plr; + uint8_t eol_rsvd2[4]; + uint32_t eol_pfc; + uint32_t eol_efc; + uint8_t eol_rss3[4]; + uint32_t eol_vendor; + uint16_t eol_cust_sts; + uint16_t eol_sys_sts; + uint8_t eol_cust_state; + uint8_t eol_sys_state; +} wdc_vul_sn840_eol_t; + +/* + * Smatch can't handle packed structure sizeof calculations correctly, + * unfortunately. + */ +#ifndef __CHECKER__ +CTASSERT(sizeof (wdc_vul_sn840_eol_t) == 118); +#endif + +typedef enum { + WDC_SN840_VSD_ID = 0x01, /* uint32_t */ + WDC_SN840_VSD_UEFI_VER = 0x02, /* CBS */ + WDC_SN840_VSD_SBL_VER = 0x03, /* CBS */ + WDC_SN840_VSD_DEF_USER_CAP = 0x04, /* uint64_t */ + WDC_SN840_VSD_MAX_USER_CAP = 0x05, /* uint64_t */ + WDC_SN840_VSD_MIN_USER_CAP = 0x06, /* uint64_t */ + WDC_SN840_VSD_NAME = 0x07, /* CBS */ + WDC_SN840_VSD_LOG_SUP = 0x08, /* CBS */ + WDC_SN840_VSD_FEAT_SUP = 0x09, /* CBS */ + WDC_SN840_VSD_FORM_FACTOR = 0x0a, /* uint32_t */ + WDC_SN840_VSD_RESIZE_GRAN = 0x0b, /* uint64_t */ + WDC_SN840_VSD_NS_ALLOC_SIZE = 0x0c, /* uint64_t */ + WDC_SN840_VSD_NS_REG_AVAIL = 0x0d, /* uint64_t */ + WDC_SN840_VSD_RAW_NVM = 0x0e, /* uint64_t */ + WDC_SN840_VSD_PORT_CFG_STS = 0x0f, /* uint32_t */ + WDC_SN840_VSD_MPN = 0x10, /* CBS */ + WDC_SN840_VSD_SN = 0x11, /* CBS */ + WDC_SN840_VSD_DEF_NS_ATTRS = 0x12, /* uint32_t */ + WDC_SN840_VSD_GIT_DESCR = 0x13, /* CBS */ + WDC_SN840_VSD_SMB_BL = 0x14, /* CBS */ + WDC_SN840_VSD_CUST_ID = 0x15, /* uint32_t */ + WDC_SN840_VSD_PROD_DESC = 0x16, /* CBS */ + WDC_SN840_VSD_TMM_VER = 0x17, /* CBS */ + WDC_SN840_VSD_THERM_THROT_STS = 0x18, /* uint32_t */ + WDC_SN840_VSD_ASSERT_DUMP = 0x19, /* uint32_t */ + WDC_SN840_VSD_CUST_EOL_STS = 0x1a, /* uint32_t */ + WDC_SN840_VSD_IFS_EOL_STS = 0x1b, /* uint32_t */ + WDC_SN840_VSD_CUST_EOL_STATE = 0x1c, /* uint32_t */ + WDC_SN840_VSD_IFS_EOL_STATE = 0x1d, /* uint32_t */ + WDC_SN840_VSD_FCR = 0x1e, /* uint32_t */ + WDC_SN840_VSD_VCA_BPC_REV = 0x1f, /* uint32_t */ + WDC_SN840_VSD_VCA_BPC_MIN_REV = 0x20, /* uint32_t */ + WDC_SN840_VSD_VCA_BPC_RST_SEQ = 0x21, /* uint32_t */ + WDC_SN840_VSD_VCA_TPC_RST_SEQ = 0x22, /* uint32_t */ + WDC_SN840_VSD_VCA_TPC_FSS_SEQ = 0x23 /* uint32_t */ +} wdc_sn840_vsd_id_t; + +typedef enum { + WDC_SN840_VSD_NS_LIDS = 0x08, /* CBS */ + WDC_SN840_VSD_NS_FIDS = 0x09 /* CBS */ +} wdc_sn840_vsd_ns_id_t; + +typedef enum { + WDC_SN840_TEMP_NAND = 0, + WDC_SN840_TEMP_BOARD, + WDC_SN840_TEMP_FE, + WDC_SN840_TEMP_FM0, + WDC_SN840_TEMP_FM1, + WDC_SN840_TEMP_AVG_NAND, + WDC_SN840_TEMP_AVG_FE, + WDC_SN840_TEMP_MAX_ASIC, + WDC_SN840_TEMP_TOUCH, + WDC_SN840_TEMP_COMP, + WDC_SN840_TEMP_NSMAPLES +} wdc_sn840_temp_sample_t; + +/* + * These are structures for the firmware activation log. The first structure is + * an individual entry. The second is the header which points to these. The data + * is versioned and the entries have a specific size, but right now we only know + * of the one. + */ +typedef struct { + uint32_t fah_ent_no; + uint32_t fah_pow_cyc; + uint64_t fah_pow_sec; + uint64_t fah_cur_fw_ver; + uint64_t fah_new_fw_ver; + uint8_t fah_slot_no; + uint8_t fah_commit_type; + uint16_t fah_result; + uint8_t fah_rsvd[12]; +} wdc_vul_sn840_fw_act_ent_t; + +CTASSERT(sizeof (wdc_vul_sn840_fw_act_ent_t) == 48); + +typedef struct { + uint8_t fah_hdr[4]; + uint8_t fah_vers; + uint8_t fah_rsvd0; + uint8_t fah_nent; + uint8_t fah_rsvd1; + uint32_t fah_entlen; + uint32_t fah_rsvd; +} wdc_vul_sn840_fw_act_hdr_t; + +CTASSERT(sizeof (wdc_vul_sn840_fw_act_hdr_t) == 16); + +typedef struct { + uint8_t cbi_hdr[8]; + uint32_t cbi_cust_id; + uint16_t cbi_vers_id; + uint16_t cbi_rev_id; + uint32_t cbi_build_id; + uint8_t cbi_nand_head[8]; + uint32_t cbi_cust_nand_id; + uint16_t cbi_nand_vers_id; + uint16_t cbi_nand_rev_id; +} wdc_vul_sn840_ccds_info_t; + +CTASSERT(sizeof (wdc_vul_sn840_ccds_info_t) == 36); + +#pragma pack() /* pack(1) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_WDC_SN840_H */ diff --git a/illumos-x86_64/usr/include/sys/nvme/wdc_sn861.h b/illumos-x86_64/usr/include/sys/nvme/wdc_sn861.h new file mode 100644 index 00000000..495756a9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvme/wdc_sn861.h @@ -0,0 +1,49 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_NVME_WDC_SN861_H +#define _SYS_NVME_WDC_SN861_H + +/* + * This header defines vendor-specific NVMe interfaces and is not a committed + * interface. Its contents and existence are subject to change. + * + * Vendor-specific definitions for the WDC SN861 NVMe device. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define WDC_SN861_DID 0x2751 + +typedef enum { + WDC_SN861_LOG_OCP_SMART = OCP_LOG_DSSD_SMART, + WDC_SN861_LOG_OCP_ERRREC = OCP_LOG_DSSD_ERROR_REC, + WDC_SN861_LOG_OCP_FWACT = OCP_LOG_DSSD_FWACT, + WDC_SN861_LOG_OCP_LATENCY = OCP_LOG_DSSD_LATENCY, + WDC_SN861_LOG_OCP_DEV_CAP = OCP_LOG_DSSD_DEV_CAP, + WDC_SN861_LOG_OCP_UNSUP = OCP_LOG_DSSD_UNSUP_REQ +} wdc_sn861_vul_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVME_WDC_SN861_H */ diff --git a/illumos-x86_64/usr/include/sys/nvpair.h b/illumos-x86_64/usr/include/sys/nvpair.h new file mode 100644 index 00000000..2d8e27fb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvpair.h @@ -0,0 +1,352 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017 by Delphix. All rights reserved. + */ + +#ifndef _SYS_NVPAIR_H +#define _SYS_NVPAIR_H + +#include +#include +#include +#include + +#if defined(_KERNEL) && !defined(_BOOT) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + DATA_TYPE_DONTCARE = -1, + DATA_TYPE_UNKNOWN = 0, + DATA_TYPE_BOOLEAN, + DATA_TYPE_BYTE, + DATA_TYPE_INT16, + DATA_TYPE_UINT16, + DATA_TYPE_INT32, + DATA_TYPE_UINT32, + DATA_TYPE_INT64, + DATA_TYPE_UINT64, + DATA_TYPE_STRING, + DATA_TYPE_BYTE_ARRAY, + DATA_TYPE_INT16_ARRAY, + DATA_TYPE_UINT16_ARRAY, + DATA_TYPE_INT32_ARRAY, + DATA_TYPE_UINT32_ARRAY, + DATA_TYPE_INT64_ARRAY, + DATA_TYPE_UINT64_ARRAY, + DATA_TYPE_STRING_ARRAY, + DATA_TYPE_HRTIME, + DATA_TYPE_NVLIST, + DATA_TYPE_NVLIST_ARRAY, + DATA_TYPE_BOOLEAN_VALUE, + DATA_TYPE_INT8, + DATA_TYPE_UINT8, + DATA_TYPE_BOOLEAN_ARRAY, + DATA_TYPE_INT8_ARRAY, +#if !defined(_KERNEL) + DATA_TYPE_UINT8_ARRAY, + DATA_TYPE_DOUBLE +#else + DATA_TYPE_UINT8_ARRAY +#endif +} data_type_t; + +typedef struct nvpair { + int32_t nvp_size; /* size of this nvpair */ + int16_t nvp_name_sz; /* length of name string */ + int16_t nvp_reserve; /* not used */ + int32_t nvp_value_elem; /* number of elements for array types */ + data_type_t nvp_type; /* type of value */ + /* name string */ + /* aligned ptr array for string arrays */ + /* aligned array of data for value */ +} nvpair_t; + +/* nvlist header */ +typedef struct nvlist { + int32_t nvl_version; + uint32_t nvl_nvflag; /* persistent flags */ + uint64_t nvl_priv; /* ptr to private data if not packed */ + uint32_t nvl_flag; + int32_t nvl_pad; /* currently not used, for alignment */ +} nvlist_t; + +/* nvp implementation version */ +#define NV_VERSION 0 + +/* nvlist pack encoding */ +#define NV_ENCODE_NATIVE 0 +#define NV_ENCODE_XDR 1 + +/* nvlist persistent unique name flags, stored in nvl_nvflags */ +#define NV_UNIQUE_NAME 0x1 +#define NV_UNIQUE_NAME_TYPE 0x2 + +/* nvlist lookup pairs related flags */ +#define NV_FLAG_NOENTOK 0x1 + +/* convenience macros */ +#define NV_ALIGN(x) (((ulong_t)(x) + 7ul) & ~7ul) +#define NV_ALIGN4(x) (((x) + 3) & ~3) + +#define NVP_SIZE(nvp) ((nvp)->nvp_size) +#define NVP_NAME(nvp) ((char *)(nvp) + sizeof (nvpair_t)) +#define NVP_TYPE(nvp) ((nvp)->nvp_type) +#define NVP_NELEM(nvp) ((nvp)->nvp_value_elem) +#define NVP_VALUE(nvp) ((char *)(nvp) + NV_ALIGN(sizeof (nvpair_t) \ + + (nvp)->nvp_name_sz)) + +#define NVL_VERSION(nvl) ((nvl)->nvl_version) +#define NVL_SIZE(nvl) ((nvl)->nvl_size) +#define NVL_FLAG(nvl) ((nvl)->nvl_flag) + +/* NV allocator framework */ +typedef struct nv_alloc_ops nv_alloc_ops_t; + +typedef struct nv_alloc { + const nv_alloc_ops_t *nva_ops; + void *nva_arg; +} nv_alloc_t; + +struct nv_alloc_ops { + int (*nv_ao_init)(nv_alloc_t *, __va_list); + void (*nv_ao_fini)(nv_alloc_t *); + void *(*nv_ao_alloc)(nv_alloc_t *, size_t); + void (*nv_ao_free)(nv_alloc_t *, void *, size_t); + void (*nv_ao_reset)(nv_alloc_t *); +}; + +extern const nv_alloc_ops_t *nv_fixed_ops; +extern nv_alloc_t *nv_alloc_nosleep; + +#if defined(_KERNEL) && !defined(_BOOT) +extern nv_alloc_t *nv_alloc_sleep; +#endif + +int nv_alloc_init(nv_alloc_t *, const nv_alloc_ops_t *, /* args */ ...); +void nv_alloc_reset(nv_alloc_t *); +void nv_alloc_fini(nv_alloc_t *); + +/* list management */ +int nvlist_alloc(nvlist_t **, uint_t, int); +void nvlist_free(nvlist_t *); +int nvlist_size(nvlist_t *, size_t *, int); +int nvlist_pack(nvlist_t *, char **, size_t *, int, int); +int nvlist_unpack(char *, size_t, nvlist_t **, int); +int nvlist_dup(nvlist_t *, nvlist_t **, int); +int nvlist_merge(nvlist_t *, nvlist_t *, int); + +uint_t nvlist_nvflag(nvlist_t *); + +int nvlist_xalloc(nvlist_t **, uint_t, nv_alloc_t *); +int nvlist_xpack(nvlist_t *, char **, size_t *, int, nv_alloc_t *); +int nvlist_xunpack(char *, size_t, nvlist_t **, nv_alloc_t *); +int nvlist_xdup(nvlist_t *, nvlist_t **, nv_alloc_t *); +nv_alloc_t *nvlist_lookup_nv_alloc(nvlist_t *); + +int nvlist_add_nvpair(nvlist_t *, nvpair_t *); +int nvlist_add_boolean(nvlist_t *, const char *); +int nvlist_add_boolean_value(nvlist_t *, const char *, boolean_t); +int nvlist_add_byte(nvlist_t *, const char *, uchar_t); +int nvlist_add_int8(nvlist_t *, const char *, int8_t); +int nvlist_add_uint8(nvlist_t *, const char *, uint8_t); +int nvlist_add_int16(nvlist_t *, const char *, int16_t); +int nvlist_add_uint16(nvlist_t *, const char *, uint16_t); +int nvlist_add_int32(nvlist_t *, const char *, int32_t); +int nvlist_add_uint32(nvlist_t *, const char *, uint32_t); +int nvlist_add_int64(nvlist_t *, const char *, int64_t); +int nvlist_add_uint64(nvlist_t *, const char *, uint64_t); +int nvlist_add_string(nvlist_t *, const char *, const char *); +int nvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *); +int nvlist_add_boolean_array(nvlist_t *, const char *, boolean_t *, uint_t); +int nvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, uint_t); +int nvlist_add_int8_array(nvlist_t *, const char *, int8_t *, uint_t); +int nvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, uint_t); +int nvlist_add_int16_array(nvlist_t *, const char *, int16_t *, uint_t); +int nvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *, uint_t); +int nvlist_add_int32_array(nvlist_t *, const char *, int32_t *, uint_t); +int nvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *, uint_t); +int nvlist_add_int64_array(nvlist_t *, const char *, int64_t *, uint_t); +int nvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, uint_t); +int nvlist_add_string_array(nvlist_t *, const char *, char *const *, uint_t); +int nvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t); +int nvlist_add_hrtime(nvlist_t *, const char *, hrtime_t); +#if !defined(_KERNEL) +int nvlist_add_double(nvlist_t *, const char *, double); +#endif + +int nvlist_remove(nvlist_t *, const char *, data_type_t); +int nvlist_remove_all(nvlist_t *, const char *); +int nvlist_remove_nvpair(nvlist_t *, nvpair_t *); + +int nvlist_lookup_boolean(nvlist_t *, const char *); +int nvlist_lookup_boolean_value(nvlist_t *, const char *, boolean_t *); +int nvlist_lookup_byte(nvlist_t *, const char *, uchar_t *); +int nvlist_lookup_int8(nvlist_t *, const char *, int8_t *); +int nvlist_lookup_uint8(nvlist_t *, const char *, uint8_t *); +int nvlist_lookup_int16(nvlist_t *, const char *, int16_t *); +int nvlist_lookup_uint16(nvlist_t *, const char *, uint16_t *); +int nvlist_lookup_int32(nvlist_t *, const char *, int32_t *); +int nvlist_lookup_uint32(nvlist_t *, const char *, uint32_t *); +int nvlist_lookup_int64(nvlist_t *, const char *, int64_t *); +int nvlist_lookup_uint64(nvlist_t *, const char *, uint64_t *); +int nvlist_lookup_string(nvlist_t *, const char *, char **); +int nvlist_lookup_nvlist(nvlist_t *, const char *, nvlist_t **); +int nvlist_lookup_boolean_array(nvlist_t *, const char *, + boolean_t **, uint_t *); +int nvlist_lookup_byte_array(nvlist_t *, const char *, uchar_t **, uint_t *); +int nvlist_lookup_int8_array(nvlist_t *, const char *, int8_t **, uint_t *); +int nvlist_lookup_uint8_array(nvlist_t *, const char *, uint8_t **, uint_t *); +int nvlist_lookup_int16_array(nvlist_t *, const char *, int16_t **, uint_t *); +int nvlist_lookup_uint16_array(nvlist_t *, const char *, uint16_t **, uint_t *); +int nvlist_lookup_int32_array(nvlist_t *, const char *, int32_t **, uint_t *); +int nvlist_lookup_uint32_array(nvlist_t *, const char *, uint32_t **, uint_t *); +int nvlist_lookup_int64_array(nvlist_t *, const char *, int64_t **, uint_t *); +int nvlist_lookup_uint64_array(nvlist_t *, const char *, uint64_t **, uint_t *); +int nvlist_lookup_string_array(nvlist_t *, const char *, char ***, uint_t *); +int nvlist_lookup_nvlist_array(nvlist_t *, const char *, + nvlist_t ***, uint_t *); +int nvlist_lookup_hrtime(nvlist_t *, const char *, hrtime_t *); +int nvlist_lookup_pairs(nvlist_t *, int, ...); +#if !defined(_KERNEL) +int nvlist_lookup_double(nvlist_t *, const char *, double *); +#endif + +int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **); +int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *, nvpair_t **, + int *, char **); +boolean_t nvlist_exists(nvlist_t *, const char *); +boolean_t nvlist_empty(nvlist_t *); + +/* processing nvpair */ +nvpair_t *nvlist_next_nvpair(nvlist_t *, nvpair_t *); +nvpair_t *nvlist_prev_nvpair(nvlist_t *, nvpair_t *); +char *nvpair_name(nvpair_t *); +data_type_t nvpair_type(nvpair_t *); +int nvpair_type_is_array(nvpair_t *); +int nvpair_value_boolean_value(nvpair_t *, boolean_t *); +int nvpair_value_byte(nvpair_t *, uchar_t *); +int nvpair_value_int8(nvpair_t *, int8_t *); +int nvpair_value_uint8(nvpair_t *, uint8_t *); +int nvpair_value_int16(nvpair_t *, int16_t *); +int nvpair_value_uint16(nvpair_t *, uint16_t *); +int nvpair_value_int32(nvpair_t *, int32_t *); +int nvpair_value_uint32(nvpair_t *, uint32_t *); +int nvpair_value_int64(nvpair_t *, int64_t *); +int nvpair_value_uint64(nvpair_t *, uint64_t *); +int nvpair_value_string(nvpair_t *, char **); +int nvpair_value_nvlist(nvpair_t *, nvlist_t **); +int nvpair_value_boolean_array(nvpair_t *, boolean_t **, uint_t *); +int nvpair_value_byte_array(nvpair_t *, uchar_t **, uint_t *); +int nvpair_value_int8_array(nvpair_t *, int8_t **, uint_t *); +int nvpair_value_uint8_array(nvpair_t *, uint8_t **, uint_t *); +int nvpair_value_int16_array(nvpair_t *, int16_t **, uint_t *); +int nvpair_value_uint16_array(nvpair_t *, uint16_t **, uint_t *); +int nvpair_value_int32_array(nvpair_t *, int32_t **, uint_t *); +int nvpair_value_uint32_array(nvpair_t *, uint32_t **, uint_t *); +int nvpair_value_int64_array(nvpair_t *, int64_t **, uint_t *); +int nvpair_value_uint64_array(nvpair_t *, uint64_t **, uint_t *); +int nvpair_value_string_array(nvpair_t *, char ***, uint_t *); +int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *); +int nvpair_value_hrtime(nvpair_t *, hrtime_t *); +#if !defined(_KERNEL) +int nvpair_value_double(nvpair_t *, double *); +#endif + +nvlist_t *fnvlist_alloc(void); +void fnvlist_free(nvlist_t *); +size_t fnvlist_size(nvlist_t *); +char *fnvlist_pack(nvlist_t *, size_t *); +void fnvlist_pack_free(char *, size_t); +nvlist_t *fnvlist_unpack(char *, size_t); +nvlist_t *fnvlist_dup(nvlist_t *); +void fnvlist_merge(nvlist_t *, nvlist_t *); +size_t fnvlist_num_pairs(nvlist_t *); + +void fnvlist_add_boolean(nvlist_t *, const char *); +void fnvlist_add_boolean_value(nvlist_t *, const char *, boolean_t); +void fnvlist_add_byte(nvlist_t *, const char *, uchar_t); +void fnvlist_add_int8(nvlist_t *, const char *, int8_t); +void fnvlist_add_uint8(nvlist_t *, const char *, uint8_t); +void fnvlist_add_int16(nvlist_t *, const char *, int16_t); +void fnvlist_add_uint16(nvlist_t *, const char *, uint16_t); +void fnvlist_add_int32(nvlist_t *, const char *, int32_t); +void fnvlist_add_uint32(nvlist_t *, const char *, uint32_t); +void fnvlist_add_int64(nvlist_t *, const char *, int64_t); +void fnvlist_add_uint64(nvlist_t *, const char *, uint64_t); +void fnvlist_add_string(nvlist_t *, const char *, const char *); +void fnvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *); +void fnvlist_add_nvpair(nvlist_t *, nvpair_t *); +void fnvlist_add_boolean_array(nvlist_t *, const char *, boolean_t *, uint_t); +void fnvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, uint_t); +void fnvlist_add_int8_array(nvlist_t *, const char *, int8_t *, uint_t); +void fnvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, uint_t); +void fnvlist_add_int16_array(nvlist_t *, const char *, int16_t *, uint_t); +void fnvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *, uint_t); +void fnvlist_add_int32_array(nvlist_t *, const char *, int32_t *, uint_t); +void fnvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *, uint_t); +void fnvlist_add_int64_array(nvlist_t *, const char *, int64_t *, uint_t); +void fnvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, uint_t); +void fnvlist_add_string_array(nvlist_t *, const char *, char * const *, uint_t); +void fnvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t); + +void fnvlist_remove(nvlist_t *, const char *); +void fnvlist_remove_nvpair(nvlist_t *, nvpair_t *); + +nvpair_t *fnvlist_lookup_nvpair(nvlist_t *nvl, const char *name); +boolean_t fnvlist_lookup_boolean(nvlist_t *nvl, const char *name); +boolean_t fnvlist_lookup_boolean_value(nvlist_t *nvl, const char *name); +uchar_t fnvlist_lookup_byte(nvlist_t *nvl, const char *name); +int8_t fnvlist_lookup_int8(nvlist_t *nvl, const char *name); +int16_t fnvlist_lookup_int16(nvlist_t *nvl, const char *name); +int32_t fnvlist_lookup_int32(nvlist_t *nvl, const char *name); +int64_t fnvlist_lookup_int64(nvlist_t *nvl, const char *name); +uint8_t fnvlist_lookup_uint8(nvlist_t *nvl, const char *name); +uint16_t fnvlist_lookup_uint16(nvlist_t *nvl, const char *name); +uint32_t fnvlist_lookup_uint32(nvlist_t *nvl, const char *name); +uint64_t fnvlist_lookup_uint64(nvlist_t *nvl, const char *name); +char *fnvlist_lookup_string(nvlist_t *nvl, const char *name); +nvlist_t *fnvlist_lookup_nvlist(nvlist_t *nvl, const char *name); + +boolean_t fnvpair_value_boolean_value(nvpair_t *nvp); +uchar_t fnvpair_value_byte(nvpair_t *nvp); +int8_t fnvpair_value_int8(nvpair_t *nvp); +int16_t fnvpair_value_int16(nvpair_t *nvp); +int32_t fnvpair_value_int32(nvpair_t *nvp); +int64_t fnvpair_value_int64(nvpair_t *nvp); +uint8_t fnvpair_value_uint8(nvpair_t *nvp); +uint16_t fnvpair_value_uint16(nvpair_t *nvp); +uint32_t fnvpair_value_uint32(nvpair_t *nvp); +uint64_t fnvpair_value_uint64(nvpair_t *nvp); +char *fnvpair_value_string(nvpair_t *nvp); +nvlist_t *fnvpair_value_nvlist(nvpair_t *nvp); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NVPAIR_H */ diff --git a/illumos-x86_64/usr/include/sys/nvpair_impl.h b/illumos-x86_64/usr/include/sys/nvpair_impl.h new file mode 100644 index 00000000..c9874b3e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/nvpair_impl.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ + +#ifndef _NVPAIR_IMPL_H +#define _NVPAIR_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * The structures here provided for information and debugging purposes only + * may be changed in the future. + */ + +/* + * implementation linked list for pre-packed data + */ +typedef struct i_nvp i_nvp_t; + +struct i_nvp { + union { + /* ensure alignment */ + uint64_t _nvi_align; + + struct { + /* pointer to next nvpair */ + i_nvp_t *_nvi_next; + + /* pointer to prev nvpair */ + i_nvp_t *_nvi_prev; + + /* next pair in table bucket */ + i_nvp_t *_nvi_hashtable_next; + } _nvi; + } _nvi_un; + + /* nvpair */ + nvpair_t nvi_nvp; +}; +#define nvi_next _nvi_un._nvi._nvi_next +#define nvi_prev _nvi_un._nvi._nvi_prev +#define nvi_hashtable_next _nvi_un._nvi._nvi_hashtable_next + +typedef struct { + i_nvp_t *nvp_list; /* linked list of nvpairs */ + i_nvp_t *nvp_last; /* last nvpair */ + i_nvp_t *nvp_curr; /* current walker nvpair */ + nv_alloc_t *nvp_nva; /* pluggable allocator */ + uint32_t nvp_stat; /* internal state */ + + i_nvp_t **nvp_hashtable; /* table of entries used for lookup */ + uint32_t nvp_nbuckets; /* # of buckets in hash table */ + uint32_t nvp_nentries; /* # of entries in hash table */ +} nvpriv_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _NVPAIR_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/objfs.h b/illumos-x86_64/usr/include/sys/objfs.h new file mode 100644 index 00000000..51686ef3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/objfs.h @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _OBJFS_H +#define _OBJFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Root directory of the object filesystem + */ +#define OBJFS_ROOT "/system/object" + +/* + * Given an inode number, return the module ID for the given node. When given + * the root inode, the results are undefined. + */ +#define OBJFS_MODID(ino) \ + ((ino) & 0xffffffff) + +/* + * Private data structure found in '.info' section + */ +typedef struct objfs_info { + int objfs_info_primary; +} objfs_info_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _OBJFS_H */ diff --git a/illumos-x86_64/usr/include/sys/objfs_impl.h b/illumos-x86_64/usr/include/sys/objfs_impl.h new file mode 100644 index 00000000..4bfc7fa3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/objfs_impl.h @@ -0,0 +1,132 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _OBJFS_IMPL_H +#define _OBJFS_IMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * VFS data object + */ +typedef struct objfs_vfs { + vnode_t *objfs_vfs_root; +} objfs_vfs_t; + +/* + * Common vop_ entry points + */ +extern int objfs_dir_open(vnode_t **, int, cred_t *, caller_context_t *); +extern int objfs_dir_access(vnode_t *, int, int, cred_t *, + caller_context_t *); +extern int objfs_common_close(vnode_t *, int, int, offset_t, cred_t *, + caller_context_t *); + +/* + * Common vop_ support functions + */ +extern int objfs_common_getattr(vnode_t *, vattr_t *); + +/* + * Miscellaneous support functions + */ +extern int objfs_nobjs(void); + +#define OBJFS_NAME_MAX MAXNAMELEN + +/* + * The root vnode has an inode number of 0xffffffff. All other vnodes have an + * inode that is an OR of the module id with the type of vnode. + * + * ---------------------------------------- + * | type | mod_id | + * ---------------------------------------- + * 63 31 0 + * + * This way, module directories will have an inode value equal to their module + * id. + */ + +#define OBJFS_INO(modid, type) \ + (((uint64_t)(type) << 32) | (modid)) + +/* + * Root directory + */ +typedef gfs_dir_t objfs_rootnode_t; + +#define OBJFS_INO_ROOT 0xffffffff + +extern const fs_operation_def_t objfs_tops_root[]; +extern vnodeops_t *objfs_ops_root; + +extern vnode_t *objfs_create_root(vfs_t *); + +/* + * Object directory + */ + +typedef struct objfs_odirnode { + gfs_dir_t objfs_odir_dir; /* gfs dir */ + struct modctl *objfs_odir_modctl; /* modctl pointer */ +} objfs_odirnode_t; + +#define OBJFS_INO_ODIR(modid) OBJFS_INO(modid, 0) + +extern const fs_operation_def_t objfs_tops_odir[]; +extern vnodeops_t *objfs_ops_odir; + +extern vnode_t *objfs_create_odirnode(vnode_t *, struct modctl *); + +/* + * Data file + */ +typedef struct objfs_datanode { + gfs_file_t objfs_data_file; /* gfs file */ + objfs_info_t objfs_data_info; + int objfs_data_gencount; /* gen when opened */ +} objfs_datanode_t; + +#define OBJFS_INO_DATA(modid) OBJFS_INO(modid, 1) + +extern const fs_operation_def_t objfs_tops_data[]; +extern vnodeops_t *objfs_ops_data; + +extern void objfs_data_init(void); +extern vnode_t *objfs_create_data(vnode_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _OBJFS_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/obpdefs.h b/illumos-x86_64/usr/include/sys/obpdefs.h new file mode 100644 index 00000000..67fce65e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/obpdefs.h @@ -0,0 +1,110 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_OBPDEFS_H +#define _SYS_OBPDEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file is intended as standalone inclusion by non-prom library + * functions that need it. + */ + +typedef int ihandle_t; /* 1275 device instance number */ +typedef int phandle_t; /* 1275 device tree node ptr */ +typedef phandle_t pnode_t; + +/* + * Device type matching + */ + +#define OBP_NONODE ((pnode_t)0) +#define OBP_BADNODE ((pnode_t)-1) + +/* + * Property Defines + */ + +#define OBP_NAME "name" +#define OBP_REG "reg" +#define OBP_INTR "intr" +#define OBP_RANGES "ranges" +#define OBP_INTERRUPTS "interrupts" +#define OBP_COMPATIBLE "compatible" +#define OBP_STATUS "status" +#define OBP_BOARDNUM "board#" + +#define OBP_MAC_ADDR "mac-address" +#define OBP_STDINPATH "stdin-path" +#define OBP_STDOUTPATH "stdout-path" +#define OBP_IDPROM "idprom" + +#define OBP_DEVICETYPE "device_type" +#define OBP_DISPLAY "display" +#define OBP_NETWORK "network" +#define OBP_BYTE "byte" +#define OBP_BLOCK "block" +#define OBP_SERIAL "serial" +#define OBP_HIERARCHICAL "hierarchical" +#define OBP_CPU "cpu" +#define OBP_ADDRESS "address" + +/* + * OBP status values defines + */ +#define OBP_ST_OKAY "okay" +#define OBP_ST_DISABLED "disabled" +#define OBP_ST_FAIL "fail" + +/* + * Max size of a path component and a property name (not value) + * These are standard definitions. + */ +#define OBP_MAXDRVNAME 32 /* defined in P1275 */ +#define OBP_MAXPROPNAME 32 /* defined in P1275 */ + +/* + * + * NB: Max pathname length is a platform-dependent parameter. + */ +#define OBP_MAXPATHLEN 256 /* Platform dependent */ + +/* + * Every OBP node must have a `/' followed by at least 2 chars, + * so we can deduce the maxdepth of any OBP tree to be + * OBP_MAXPATHNAME/3. This is a good first swag. + */ + +#define OBP_STACKDEPTH (OBP_MAXPATHLEN/3) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_OBPDEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/old_procfs.h b/illumos-x86_64/usr/include/sys/old_procfs.h new file mode 100644 index 00000000..bec3fa07 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/old_procfs.h @@ -0,0 +1,633 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_OLD_PROCFS_H +#define _SYS_OLD_PROCFS_H + +/* + * This file contains the definitions for the old ioctl()-based + * version of the process file system. It is obsolete but will + * continue to be supported in SunOS until the next major release. + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#error "Cannot use procfs in the large file compilation environment" +#endif + +#if _STRUCTURED_PROC == 0 + +/* + * The old (ioctl-based) and new (structured) /proc interfaces define + * related structures of the same name, but slightly diferent contents: + * prmap_t + * prcred_t + * This doesn't hurt because you can't include both of these + * in the same compilation unit: + * + * + * unless _STRUCTURED_PROC is first defined to be 1. + * (Including defines it to be 1.) + * + * However, the latest version of lint goes overboard in hunting + * down and reporting differences in functions and data of the + * same name across multiple compilation units, even though there + * is no real problem. To mitigate this, we redefine the old procfs + * names when performing lint. + */ +#if defined(__lint) +#define prmap Prmap +#define prmap_t Prmap_t +#define prcred Prcred +#define prcred_t Prcred_t +#endif /* __lint */ + +/* + * ioctl codes and system call interfaces for /proc. + */ + +#define PIOC ('q'<<8) +#define PIOCSTATUS (PIOC|1) /* get process status */ +#define PIOCSTOP (PIOC|2) /* post STOP request and... */ +#define PIOCWSTOP (PIOC|3) /* wait for process to STOP */ +#define PIOCRUN (PIOC|4) /* make process runnable */ +#define PIOCGTRACE (PIOC|5) /* get traced signal set */ +#define PIOCSTRACE (PIOC|6) /* set traced signal set */ +#define PIOCSSIG (PIOC|7) /* set current signal */ +#define PIOCKILL (PIOC|8) /* send signal */ +#define PIOCUNKILL (PIOC|9) /* delete a signal */ +#define PIOCGHOLD (PIOC|10) /* get held signal set */ +#define PIOCSHOLD (PIOC|11) /* set held signal set */ +#define PIOCMAXSIG (PIOC|12) /* get max signal number */ +#define PIOCACTION (PIOC|13) /* get signal action structs */ +#define PIOCGFAULT (PIOC|14) /* get traced fault set */ +#define PIOCSFAULT (PIOC|15) /* set traced fault set */ +#define PIOCCFAULT (PIOC|16) /* clear current fault */ +#define PIOCGENTRY (PIOC|17) /* get syscall entry set */ +#define PIOCSENTRY (PIOC|18) /* set syscall entry set */ +#define PIOCGEXIT (PIOC|19) /* get syscall exit set */ +#define PIOCSEXIT (PIOC|20) /* set syscall exit set */ + +/* + * These four are obsolete (replaced by PIOCSET/PIOCRESET). + */ +#define PIOCSFORK (PIOC|21) /* set inherit-on-fork flag */ +#define PIOCRFORK (PIOC|22) /* reset inherit-on-fork flag */ +#define PIOCSRLC (PIOC|23) /* set run-on-last-close flag */ +#define PIOCRRLC (PIOC|24) /* reset run-on-last-close flag */ + +#define PIOCGREG (PIOC|25) /* get general registers */ +#define PIOCSREG (PIOC|26) /* set general registers */ +#define PIOCGFPREG (PIOC|27) /* get floating-point registers */ +#define PIOCSFPREG (PIOC|28) /* set floating-point registers */ +#define PIOCNICE (PIOC|29) /* set nice priority */ +#define PIOCPSINFO (PIOC|30) /* get ps(1) information */ +#define PIOCNMAP (PIOC|31) /* get number of memory mappings */ +#define PIOCMAP (PIOC|32) /* get memory map information */ +#define PIOCOPENM (PIOC|33) /* open mapped object for reading */ +#define PIOCCRED (PIOC|34) /* get process credentials */ +#define PIOCGROUPS (PIOC|35) /* get supplementary groups */ +#define PIOCGETPR (PIOC|36) /* read struct proc */ +#define PIOCGETU (PIOC|37) /* read user area */ + +/* + * These are new with SunOS5.0. + */ +#define PIOCSET (PIOC|38) /* set process flags */ +#define PIOCRESET (PIOC|39) /* reset process flags */ +#define PIOCUSAGE (PIOC|43) /* get resource usage */ +#define PIOCOPENPD (PIOC|44) /* get page data file descriptor */ + +/* + * Lightweight process interfaces. + */ +#define PIOCLWPIDS (PIOC|45) /* get lwp identifiers */ +#define PIOCOPENLWP (PIOC|46) /* get lwp file descriptor */ +#define PIOCLSTATUS (PIOC|47) /* get status of all lwps */ +#define PIOCLUSAGE (PIOC|48) /* get resource usage of all lwps */ + +/* + * SVR4 run-time loader interfaces. + */ +#define PIOCNAUXV (PIOC|49) /* get number of aux vector entries */ +#define PIOCAUXV (PIOC|50) /* get aux vector (see sys/auxv.h) */ + +/* + * extra register state interfaces + */ +#define PIOCGXREGSIZE (PIOC|51) /* get extra register state size */ +#define PIOCGXREG (PIOC|52) /* get extra register state */ +#define PIOCSXREG (PIOC|53) /* set extra register state */ + +/* + * Intel-specific interfaces. + */ +#define PIOCNLDT (PIOC|103) /* get number of LDT entries */ +#define PIOCLDT (PIOC|104) /* get LDT (see sys/sysi86.h) */ + +/* Process/lwp status structure */ + +#define PRCLSZ 8 /* maximum size of scheduling class name */ +#define PRSYSARGS 8 /* maximum number of syscall arguments */ + +#endif /* _STRUCTURED_PROC == 0 */ + +typedef struct prstatus { + int pr_flags; /* Flags (see below) */ + short pr_why; /* Reason for process stop (if stopped) */ + short pr_what; /* More detailed reason */ + siginfo_t pr_info; /* Info associated with signal or fault */ + short pr_cursig; /* Current signal */ + ushort_t pr_nlwp; /* Number of lwps in the process */ + sigset_t pr_sigpend; /* Set of signals pending to the process */ + sigset_t pr_sighold; /* Set of signals held (blocked) by the lwp */ + struct sigaltstack pr_altstack; /* Alternate signal stack info */ + struct sigaction pr_action; /* Signal action for current signal */ + pid_t pr_pid; /* Process id */ + pid_t pr_ppid; /* Parent process id */ + pid_t pr_pgrp; /* Process group id */ + pid_t pr_sid; /* Session id */ + timestruc_t pr_utime; /* Process user cpu time */ + timestruc_t pr_stime; /* Process system cpu time */ + timestruc_t pr_cutime; /* Sum of children's user times */ + timestruc_t pr_cstime; /* Sum of children's system times */ + char pr_clname[PRCLSZ]; /* Scheduling class name */ + short pr_syscall; /* System call number (if in syscall) */ + short pr_nsysarg; /* Number of arguments to this syscall */ + long pr_sysarg[PRSYSARGS]; /* Arguments to this syscall */ + id_t pr_who; /* Specific lwp identifier */ + sigset_t pr_lwppend; /* Set of signals pending to the lwp */ + struct ucontext *pr_oldcontext; /* Address of previous ucontext */ + caddr_t pr_brkbase; /* Address of the process heap */ + size_t pr_brksize; /* Size of the process heap, in bytes */ + caddr_t pr_stkbase; /* Address of the process stack */ + size_t pr_stksize; /* Size of the process stack, in bytes */ + short pr_processor; /* processor which last ran this LWP */ + short pr_bind; /* processor LWP bound to or PBIND_NONE */ + long pr_instr; /* Current instruction */ + prgregset_t pr_reg; /* General registers */ +} prstatus_t; + +#if _STRUCTURED_PROC == 0 + +/* pr_flags */ + +#define PR_STOPPED 0x0001 /* lwp is stopped */ +#define PR_ISTOP 0x0002 /* lwp is stopped on an event of interest */ +#define PR_DSTOP 0x0004 /* lwp has a stop directive in effect */ +#define PR_ASLEEP 0x0008 /* lwp is sleeping in a system call */ +#define PR_FORK 0x0010 /* inherit-on-fork is in effect */ +#define PR_RLC 0x0020 /* run-on-last-close is in effect */ +#define PR_PTRACE 0x0040 /* obsolete, never set in SunOS5.0 */ +#define PR_PCINVAL 0x0080 /* contents of pr_instr undefined */ +#define PR_ISSYS 0x0100 /* system process */ +#define PR_STEP 0x0200 /* lwp has a single-step directive in effect */ +#define PR_KLC 0x0400 /* kill-on-last-close is in effect */ +#define PR_ASYNC 0x0800 /* asynchronous-stop is in effect */ +#define PR_PCOMPAT 0x1000 /* ptrace-compatibility mode is in effect */ +#define PR_MSACCT 0x2000 /* micro-state usage accounting is in effect */ +#define PR_BPTADJ 0x4000 /* breakpoint trap pc adjustment is in effect */ +#define PR_ASLWP 0x8000 /* obsolete flag; never set */ + +/* Reasons for stopping */ + +#define PR_REQUESTED 1 +#define PR_SIGNALLED 2 +#define PR_SYSENTRY 3 +#define PR_SYSEXIT 4 +#define PR_JOBCONTROL 5 +#define PR_FAULTED 6 +#define PR_SUSPENDED 7 +#define PR_CHECKPOINT 8 + +/* Information for the ps(1) command */ + +#define PRFNSZ 16 /* max size of execed filename */ +#define PRARGSZ 80 /* Number of chars of arguments */ + +#endif /* _STRUCTURED_PROC == 0 */ + +typedef struct prpsinfo { + char pr_state; /* numeric process state (see pr_sname) */ + char pr_sname; /* printable character representing pr_state */ + char pr_zomb; /* !=0: process terminated but not waited for */ + char pr_nice; /* nice for cpu usage */ + uint_t pr_flag; /* process flags */ + uid_t pr_uid; /* real user id */ + gid_t pr_gid; /* real group id */ + pid_t pr_pid; /* unique process id */ + pid_t pr_ppid; /* process id of parent */ + pid_t pr_pgrp; /* pid of process group leader */ + pid_t pr_sid; /* session id */ + caddr_t pr_addr; /* physical address of process */ + size_t pr_size; /* size of process image in pages */ + size_t pr_rssize; /* resident set size in pages */ + caddr_t pr_wchan; /* wait addr for sleeping process */ + timestruc_t pr_start; /* process start time, sec+nsec since epoch */ + timestruc_t pr_time; /* usr+sys cpu time for this process */ + int pr_pri; /* priority, high value is high priority */ + char pr_oldpri; /* pre-SVR4, low value is high priority */ + char pr_cpu; /* pre-SVR4, cpu usage for scheduling */ + o_dev_t pr_ottydev; /* short tty device number */ + dev_t pr_lttydev; /* controlling tty device (PRNODEV if none) */ + char pr_clname[PRCLSZ]; /* scheduling class name */ + char pr_fname[PRFNSZ]; /* last component of execed pathname */ + char pr_psargs[PRARGSZ]; /* initial characters of arg list */ + short pr_syscall; /* system call number (if in syscall) */ + short pr_fill; + timestruc_t pr_ctime; /* usr+sys cpu time for reaped children */ + size_t pr_bysize; /* size of process image in bytes */ + size_t pr_byrssize; /* resident set size in bytes */ + int pr_argc; /* initial argument count */ + char **pr_argv; /* initial argument vector */ + char **pr_envp; /* initial environment vector */ + int pr_wstat; /* if zombie, the wait() status */ + /* The following percent numbers are 16-bit binary */ + /* fractions [0 .. 1] with the binary point to the */ + /* right of the high-order bit (one == 0x8000) */ + ushort_t pr_pctcpu; /* % of recent cpu time, one or all lwps */ + ushort_t pr_pctmem; /* % of of system memory used by the process */ + uid_t pr_euid; /* effective user id */ + gid_t pr_egid; /* effective group id */ + id_t pr_aslwpid; /* historical; now always zero */ + char pr_dmodel; /* data model of the process */ + char pr_pad[3]; + int pr_filler[6]; /* for future expansion */ +} prpsinfo_t; + +#if _STRUCTURED_PROC == 0 + +#if !defined(_STYPES) +#define pr_ttydev pr_lttydev +#else +#define pr_ttydev pr_ottydev +#endif + +#define PRNODEV (dev_t)(-1l) /* non-existent device */ + +/* + * See for possible values of pr_dmodel. + */ + +/* Optional actions to take when process continues */ + +typedef struct prrun { + int pr_flags; /* Flags */ + sigset_t pr_trace; /* Set of signals to be traced */ + sigset_t pr_sighold; /* Set of signals to be held */ + fltset_t pr_fault; /* Set of faults to be traced */ + caddr_t pr_vaddr; /* Virtual address at which to resume */ + int pr_filler[8]; /* Filler area for future expansion */ +} prrun_t; + +#define PRCSIG 0x001 /* Clear current signal */ +#define PRCFAULT 0x002 /* Clear current fault */ +#define PRSTRACE 0x004 /* Use traced-signal set in pr_trace */ +#define PRSHOLD 0x008 /* Use held-signal set in pr_sighold */ +#define PRSFAULT 0x010 /* Use traced-fault set in pr_fault */ +#define PRSVADDR 0x020 /* Resume at virtual address in pr_vaddr */ +#define PRSTEP 0x040 /* Direct the lwp to single-step */ +#define PRSABORT 0x080 /* Abort syscall */ +#define PRSTOP 0x100 /* Set directed stop request */ + +/* Memory-management interface */ + +typedef struct prmap { + caddr_t pr_vaddr; /* Virtual address */ + size_t pr_size; /* Size of mapping in bytes */ + off_t pr_off; /* Offset into mapped object, if any */ + uint_t pr_mflags; /* Protection and attribute flags */ + uint_t pr_pagesize; /* pagesize (bytes) for this mapping */ + long pr_filler[3]; /* Filler for future expansion */ +} prmap_t; + +/* Protection and attribute flags */ + +#define MA_READ 0x04 /* Readable by the traced process */ +#define MA_WRITE 0x02 /* Writable by the traced process */ +#define MA_EXEC 0x01 /* Executable by the traced process */ +#define MA_SHARED 0x08 /* Changes are shared by mapped object */ +/* + * These are obsolete and unreliable. + * They are included here only for historical compatibility. + */ +#define MA_BREAK 0x10 /* Grown by brk(2) */ +#define MA_STACK 0x20 /* Grown automatically on stack faults */ + +/* Process credentials */ + +typedef struct prcred { + uid_t pr_euid; /* Effective user id */ + uid_t pr_ruid; /* Real user id */ + uid_t pr_suid; /* Saved user id (from exec) */ + gid_t pr_egid; /* Effective group id */ + gid_t pr_rgid; /* Real group id */ + gid_t pr_sgid; /* Saved group id (from exec) */ + uint_t pr_ngroups; /* Number of supplementary groups */ +} prcred_t; + +/* Resource usage */ + +typedef struct prusage { + id_t pr_lwpid; /* lwp id. 0: process or defunct */ + int pr_count; /* number of contributing lwps */ + timestruc_t pr_tstamp; /* current time stamp */ + timestruc_t pr_create; /* process/lwp creation time stamp */ + timestruc_t pr_term; /* process/lwp termination time stamp */ + timestruc_t pr_rtime; /* total lwp real (elapsed) time */ + timestruc_t pr_utime; /* user level CPU time */ + timestruc_t pr_stime; /* system call CPU time */ + timestruc_t pr_ttime; /* other system trap CPU time */ + timestruc_t pr_tftime; /* text page fault sleep time */ + timestruc_t pr_dftime; /* data page fault sleep time */ + timestruc_t pr_kftime; /* kernel page fault sleep time */ + timestruc_t pr_ltime; /* user lock wait sleep time */ + timestruc_t pr_slptime; /* all other sleep time */ + timestruc_t pr_wtime; /* wait-cpu (latency) time */ + timestruc_t pr_stoptime; /* stopped time */ + timestruc_t filltime[6]; /* filler for future expansion */ + ulong_t pr_minf; /* minor page faults */ + ulong_t pr_majf; /* major page faults */ + ulong_t pr_nswap; /* swaps */ + ulong_t pr_inblk; /* input blocks */ + ulong_t pr_oublk; /* output blocks */ + ulong_t pr_msnd; /* messages sent */ + ulong_t pr_mrcv; /* messages received */ + ulong_t pr_sigs; /* signals received */ + ulong_t pr_vctx; /* voluntary context switches */ + ulong_t pr_ictx; /* involuntary context switches */ + ulong_t pr_sysc; /* system calls */ + ulong_t pr_ioch; /* chars read and written */ + ulong_t filler[10]; /* filler for future expansion */ +} prusage_t; + +/* Page data */ + +/* page data file header */ +typedef struct prpageheader { + timestruc_t pr_tstamp; /* real time stamp */ + ulong_t pr_nmap; /* number of address space mappings */ + ulong_t pr_npage; /* total number of pages */ +} prpageheader_t; + +/* page data mapping header */ +typedef struct prasmap { + caddr_t pr_vaddr; /* virtual address */ + size_t pr_npage; /* number of pages in mapping */ + off_t pr_off; /* offset into mapped object, if any */ + uint_t pr_mflags; /* protection and attribute flags */ + uint_t pr_pagesize; /* pagesize (bytes) for this mapping */ + long pr_filler[3]; /* filler for future expansion */ +} prasmap_t; + +/* + * npage bytes (rounded up to a sizeof (long)-byte boundary) follow + * each mapping header, containing zero or more of these flags. + */ +#define PG_REFERENCED 0x02 /* page referenced since last read */ +#define PG_MODIFIED 0x01 /* page modified since last read */ +#define PG_HWMAPPED 0x04 /* page is present and mapped */ + +/* + * Macros for manipulating sets of flags. + * sp must be a pointer to one of sigset_t, fltset_t, or sysset_t. + * flag must be a member of the enumeration corresponding to *sp. + */ + +/* turn on all flags in set */ +#define prfillset(sp) \ + { register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \ + while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0xFFFFFFFF; } + +/* turn off all flags in set */ +#define premptyset(sp) \ + { register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \ + while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0; } + +/* turn on specified flag in set */ +#define praddset(sp, flag) \ + ((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \ + (((uint32_t *)(sp))[((flag)-1)/32] |= (1UL<<(((flag)-1)%32))) : 0)) + +/* turn off specified flag in set */ +#define prdelset(sp, flag) \ + ((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \ + (((uint32_t *)(sp))[((flag)-1)/32] &= ~(1UL<<(((flag)-1)%32))) : 0)) + +/* query: != 0 iff flag is turned on in set */ +#define prismember(sp, flag) \ + (((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) && \ + (((uint32_t *)(sp))[((flag)-1)/32] & (1UL<<(((flag)-1)%32)))) + +#endif /* _STRUCTURED_PROC == 0 */ + +#ifdef _SYSCALL32 + +#if _STRUCTURED_PROC == 0 + +/* + * dev32_t version of PRNODEV + */ +#define PRNODEV32 (dev32_t)(-1) + +/* + * Kernel view of structures used by _ILP32 programs. + */ + +#endif /* _STRUCTURED_PROC == 0 */ + +typedef struct prstatus32 { + int32_t pr_flags; /* Flags */ + short pr_why; /* Reason for process stop (if stopped) */ + short pr_what; /* More detailed reason */ + siginfo32_t pr_info; /* Info associated with signal or fault */ + short pr_cursig; /* Current signal */ + ushort_t pr_nlwp; /* Number of lwps in the process */ + sigset_t pr_sigpend; /* Set of signals pending to the process */ + sigset_t pr_sighold; /* Set of signals held (blocked) by the lwp */ + struct sigaltstack32 pr_altstack; /* Alternate signal stack info */ + struct sigaction32 pr_action; /* Signal action for current signal */ + pid32_t pr_pid; /* Process id */ + pid32_t pr_ppid; /* Parent process id */ + pid32_t pr_pgrp; /* Process group id */ + pid32_t pr_sid; /* Session id */ + timestruc32_t pr_utime; /* Process user cpu time */ + timestruc32_t pr_stime; /* Process system cpu time */ + timestruc32_t pr_cutime; /* Sum of children's user times */ + timestruc32_t pr_cstime; /* Sum of children's system times */ + char pr_clname[PRCLSZ]; /* Scheduling class name */ + short pr_syscall; /* System call number (if in syscall) */ + short pr_nsysarg; /* Number of arguments to this syscall */ + int32_t pr_sysarg[PRSYSARGS]; /* Arguments to this syscall */ + id32_t pr_who; /* Specific lwp identifier */ + sigset_t pr_lwppend; /* Set of signals pending to the lwp */ + caddr32_t pr_oldcontext; /* Address of previous ucontext */ + caddr32_t pr_brkbase; /* Address of the process heap */ + size32_t pr_brksize; /* Size of the process heap, in bytes */ + caddr32_t pr_stkbase; /* Address of the process stack */ + size32_t pr_stksize; /* Size of the process stack, in bytes */ + short pr_processor; /* processor which last ran this LWP */ + short pr_bind; /* processor LWP bound to or PBIND_NONE */ + int32_t pr_instr; /* Current instruction */ + prgregset32_t pr_reg; /* General registers */ +} prstatus32_t; + +typedef struct prpsinfo32 { + char pr_state; /* numeric process state (see pr_sname) */ + char pr_sname; /* printable character representing pr_state */ + char pr_zomb; /* !=0: process terminated but not waited for */ + char pr_nice; /* nice for cpu usage */ + uint32_t pr_flag; /* process flags */ + uid32_t pr_uid; /* real user id */ + gid32_t pr_gid; /* real group id */ + pid32_t pr_pid; /* unique process id */ + pid32_t pr_ppid; /* process id of parent */ + pid32_t pr_pgrp; /* pid of process group leader */ + pid32_t pr_sid; /* session id */ + caddr32_t pr_addr; /* physical address of process */ + size32_t pr_size; /* size of process image in pages */ + size32_t pr_rssize; /* resident set size in pages */ + caddr32_t pr_wchan; /* wait addr for sleeping process */ + timestruc32_t pr_start; /* process start time, sec+nsec since epoch */ + timestruc32_t pr_time; /* usr+sys cpu time for this process */ + int32_t pr_pri; /* priority, high value is high priority */ + char pr_oldpri; /* pre-SVR4, low value is high priority */ + char pr_cpu; /* pre-SVR4, cpu usage for scheduling */ + o_dev_t pr_ottydev; /* short tty device number */ + dev32_t pr_lttydev; /* controlling tty device (PRNODEV if none) */ + char pr_clname[PRCLSZ]; /* scheduling class name */ + char pr_fname[PRFNSZ]; /* last component of execed pathname */ + char pr_psargs[PRARGSZ]; /* initial characters of arg list */ + short pr_syscall; /* system call number (if in syscall) */ + short pr_fill; + timestruc32_t pr_ctime; /* usr+sys cpu time for reaped children */ + size32_t pr_bysize; /* size of process image in bytes */ + size32_t pr_byrssize; /* resident set size in bytes */ + int pr_argc; /* initial argument count */ + caddr32_t pr_argv; /* initial argument vector */ + caddr32_t pr_envp; /* initial environment vector */ + int pr_wstat; /* if zombie, the wait() status */ + ushort_t pr_pctcpu; /* % of recent cpu time, one or all lwps */ + ushort_t pr_pctmem; /* % of of system memory used by the process */ + uid32_t pr_euid; /* effective user id */ + gid32_t pr_egid; /* effective group id */ + id32_t pr_aslwpid; /* historical; now always zero */ + char pr_dmodel; /* data model of the process */ + char pr_pad[3]; + int32_t pr_filler[6]; /* for future expansion */ +} prpsinfo32_t; + +#if _STRUCTURED_PROC == 0 + +typedef struct prrun32 { + int32_t pr_flags; /* Flags */ + sigset_t pr_trace; /* Set of signals to be traced */ + sigset_t pr_sighold; /* Set of signals to be held */ + fltset_t pr_fault; /* Set of faults to be traced */ + caddr32_t pr_vaddr; /* Virtual address at which to resume */ + int32_t pr_filler[8]; /* Filler area for future expansion */ +} prrun32_t; + +typedef struct ioc_prmap32 { + caddr32_t pr_vaddr; /* Virtual address */ + size32_t pr_size; /* Size of mapping in bytes */ + off32_t pr_off; /* Offset into mapped object, if any */ + uint32_t pr_mflags; /* Protection and attribute flags */ + uint32_t pr_pagesize; /* pagesize (bytes) for this mapping */ + int32_t pr_filler[3]; /* Filler for future expansion */ +} ioc_prmap32_t; + +typedef struct prusage32 { + id32_t pr_lwpid; /* lwp id. 0: process or defunct */ + int32_t pr_count; /* number of contributing lwps */ + timestruc32_t pr_tstamp; /* current time stamp */ + timestruc32_t pr_create; /* process/lwp creation time stamp */ + timestruc32_t pr_term; /* process/lwp termination time stamp */ + timestruc32_t pr_rtime; /* total lwp real (elapsed) time */ + timestruc32_t pr_utime; /* user level cpu time */ + timestruc32_t pr_stime; /* system call cpu time */ + timestruc32_t pr_ttime; /* other system trap cpu time */ + timestruc32_t pr_tftime; /* text page fault sleep time */ + timestruc32_t pr_dftime; /* data page fault sleep time */ + timestruc32_t pr_kftime; /* kernel page fault sleep time */ + timestruc32_t pr_ltime; /* user lock wait sleep time */ + timestruc32_t pr_slptime; /* all other sleep time */ + timestruc32_t pr_wtime; /* wait-cpu (latency) time */ + timestruc32_t pr_stoptime; /* stopped time */ + timestruc32_t filltime[6]; /* filler for future expansion */ + uint32_t pr_minf; /* minor page faults */ + uint32_t pr_majf; /* major page faults */ + uint32_t pr_nswap; /* swaps */ + uint32_t pr_inblk; /* input blocks */ + uint32_t pr_oublk; /* output blocks */ + uint32_t pr_msnd; /* messages sent */ + uint32_t pr_mrcv; /* messages received */ + uint32_t pr_sigs; /* signals received */ + uint32_t pr_vctx; /* voluntary context switches */ + uint32_t pr_ictx; /* involuntary context switches */ + uint32_t pr_sysc; /* system calls */ + uint32_t pr_ioch; /* chars read and written */ + uint32_t filler[10]; /* filler for future expansion */ +} prusage32_t; + +typedef struct ioc_prpageheader32 { + timestruc32_t pr_tstamp; /* real time stamp */ + uint32_t pr_nmap; /* number of address space mappings */ + uint32_t pr_npage; /* total number of pages */ +} ioc_prpageheader32_t; + +typedef struct ioc_prasmap32 { + caddr32_t pr_vaddr; /* virtual address */ + size32_t pr_npage; /* number of pages in mapping */ + off32_t pr_off; /* offset into mapped object, if any */ + uint32_t pr_mflags; /* protection and attribute flags */ + uint32_t pr_pagesize; /* pagesize (bytes) for this mapping */ + int32_t pr_filler[3]; /* filler for future expansion */ +} ioc_prasmap32_t; + +#endif /* _STRUCTURED_PROC == 0 */ + +#endif /* _SYSCALL32 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_OLD_PROCFS_H */ diff --git a/illumos-x86_64/usr/include/sys/open.h b/illumos-x86_64/usr/include/sys/open.h new file mode 100644 index 00000000..68c5290a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/open.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_OPEN_H +#define _SYS_OPEN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Some drivers need to be able to keep accurate records of open/close + * calls to determine whether a device is still in use. To allow this + * open/close calls have been typed and the type is passed as a third + * argument in open/close calls, as in: + * (*cdevsw[getmajor(dev)].d_open)(getminor(dev), flag, OTYP_CHR); + * or + * (*cdevsw[getmajor(dev)].d_close)(getminor(dev), flag, OTYP_CHR); + * Five types of open/close calls have been defined: + * OTYP_BLK: open/close of a block special file + * OTYP_MNT: open/close for mounting/unmounting a file system + * OTYP_CHR: open/close of a character special file + * OTYP_SWP: open/close of a swapping device. + * OTYP_LYR: open/close calls from a driver to another driver, + * without a file being open for the dev of the lower driver. + * + * The first four types of open/close calls obey the protocol rule + * that many more opens may occur for a given minor(dev) for that type of open, + * but a close call happens only on the last close of that dev. + * This protocol allows a flag to be used (set by opens, cleared by closes) + * to keep track of the state for a given minor device value. + * + * Calls of the fifth type (OTYP_LYR) must obey the protocol rule + * that open and close call calls are always paired. This protocol + * permits several drivers to be layers above the same device driver. + * A counter can be used for this protocol. + * + * The value OTYPCNT is defined for the purpose of declaring arrays + * in drivers and for performing range checks (0 <= otyp < OTYPCNT) + * on values passed. + */ + +#define OTYPCNT 5 +#define OTYP_BLK 0 +#define OTYP_MNT 1 +#define OTYP_CHR 2 +#define OTYP_SWP 3 +#define OTYP_LYR 4 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_OPEN_H */ diff --git a/illumos-x86_64/usr/include/sys/openpromio.h b/illumos-x86_64/usr/include/sys/openpromio.h new file mode 100644 index 00000000..09b146d1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/openpromio.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2019 Peter Tribble. + */ + +#ifndef _SYS_OPENPROMIO_H +#define _SYS_OPENPROMIO_H + +/* From SunOS 4.1.1 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * XXX HACK ALERT + * + * You might think that this interface could support setting non-ASCII + * property values. Unfortunately the 4.0.3c openprom driver SETOPT + * code ignores oprom_size and uses strlen() to compute the length of + * the value. The 4.0.3c openprom eeprom command makes its contribution + * by not setting oprom_size to anything meaningful. So, if we want the + * driver to trust oprom_size we have to use SETOPT2. XXX. + */ +struct openpromio { + uint_t oprom_size; /* real size of following array */ + union { + char b[1]; /* For property names and values */ + /* NB: Adjacent, Null terminated */ + int i; + } opio_u; +}; + +#define oprom_array opio_u.b +#define oprom_node opio_u.i +#define oprom_len opio_u.i + +/* + * OPROMMAXPARAM is used as a limit by the driver, and it has been + * increased to be 4 times the largest possible size of a property, + * which is 8K (nvramrc property). + */ +#define OPROMMAXPARAM 32768 /* max size of array */ + +/* + * Note that all OPROM ioctl codes are type void. Since the amount + * of data copied in/out may (and does) vary, the openprom driver + * handles the copyin/copyout itself. + */ +#define OIOC ('O'<<8) +#define OPROMGETOPT (OIOC | 1) +#define OPROMSETOPT (OIOC | 2) +#define OPROMNXTOPT (OIOC | 3) +#define OPROMSETOPT2 (OIOC | 4) /* working OPROMSETOPT */ +#define OPROMNEXT (OIOC | 5) /* interface to raw config_ops */ +#define OPROMCHILD (OIOC | 6) /* interface to raw config_ops */ +#define OPROMGETPROP (OIOC | 7) /* interface to raw config_ops */ +#define OPROMNXTPROP (OIOC | 8) /* interface to raw config_ops */ +#define OPROMU2P (OIOC | 9) /* NOT SUPPORTED after 4.x */ +#define OPROMGETCONS (OIOC | 10) /* enquire which console device */ +#define OPROMGETFBNAME (OIOC | 11) /* Frame buffer OBP pathname */ +#define OPROMGETBOOTARGS (OIOC | 12) /* Get boot arguments */ +#define OPROMGETVERSION (OIOC | 13) /* Get OpenProm Version string */ +#define OPROMPATH2DRV (OIOC | 14) /* Convert prom path to driver name */ +#define OPROMDEV2PROMNAME (OIOC | 15) /* Convert devfs path to prom path */ +#define OPROMPROM2DEVNAME (OIOC | 16) /* Convert devfs path to prom path */ +#define OPROMGETPROPLEN (OIOC | 17) /* interface to raw config_ops */ +#define OPROMREADY64 (OIOC | 18) /* DEPRECATED is prom 64-bit ready? */ +#define OPROMSETNODEID (OIOC | 19) /* set current node_id */ +#define OPROMSNAPSHOT (OIOC | 20) /* create a snapshot */ +#define OPROMCOPYOUT (OIOC | 21) /* copyout and free snapshot */ +#define OPROMLISTKEYS (OIOC | 22) /* asr-list-keys */ +#define OPROMLISTKEYSLEN (OIOC | 23) /* asr-list-keys-len */ +#define OPROMEXPORT (OIOC | 24) /* asr-export */ +#define OPROMEXPORTLEN (OIOC | 25) /* asr-export-len */ +#define OPROMGETBOOTPATH (OIOC | 26) /* Get bootpath */ + +/* + * Return values from OPROMGETCONS: + */ + +#define OPROMCONS_NOT_WSCONS 0 +#define OPROMCONS_STDIN_IS_KBD 0x1 /* stdin device is kbd */ +#define OPROMCONS_STDOUT_IS_FB 0x2 /* stdout is a framebuffer */ +#define OPROMCONS_OPENPROM 0x4 /* supports openboot */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_OPENPROMIO_H */ diff --git a/illumos-x86_64/usr/include/sys/panic.h b/illumos-x86_64/usr/include/sys/panic.h new file mode 100644 index 00000000..4d7bdf7c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/panic.h @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016 by Delphix. All rights reserved. + */ + +#ifndef _SYS_PANIC_H +#define _SYS_PANIC_H + +#if !defined(_ASM) +#include +#include +#include +#include +#endif /* !_ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _LP64 +#define PANICSTKSIZE 16384 +#else +#define PANICSTKSIZE 8192 +#endif + +#define PANICBUFSIZE 8192 +#define PANICBUFVERS 2 + +#define PANICNVNAMELEN 16 + +#define STACK_BUF_SIZE 2048 +#define SUMMARY_MAGIC 0xdead0d8a + +/* + * Panicbuf Format: + * + * The kernel records the formatted panic message and an optional array of + * name/value pairs into panicbuf[], a fixed-size buffer which is saved in + * the crash dump and, on some platforms, is persistent across reboots. + * The initial part of the buffer is a struct of type panic_data_t, which + * includes a version number for identifying the format of subsequent data. + * + * The pd_msgoff word identifies the byte offset into panicbuf[] at which the + * null-terminated panic message is located. This is followed by an optional + * variable-sized array of panic_nv_t items, which are used to record CPU + * register values. The number of items in pd_nvdata is computed as follows: + * + * (pd_msgoff - (sizeof (panic_data_t) - sizeof (panic_nv_t))) / + * sizeof (panic_nv_t); + * + * In addition to panicbuf, debuggers can access the panic_* variables shown + * below to determine more information about the initiator of the panic. + */ + +#if !defined(_ASM) + +typedef struct panic_nv { + char pnv_name[PANICNVNAMELEN]; /* String name */ + uint64_t pnv_value; /* Value */ +} panic_nv_t; + +typedef struct panic_data { + uint32_t pd_version; /* Version number of panic_data_t */ + uint32_t pd_msgoff; /* Message byte offset in panicbuf */ + char pd_uuid[36 + 1]; /* image uuid */ + panic_nv_t pd_nvdata[1]; /* Array of named data */ +} panic_data_t; + +typedef struct summary_dump { + uint32_t sd_magic; /* magic number */ + uint32_t sd_ssum; /* checsksum32(stack buffer) */ + /* + * stack buffer and other summary data follow here -- see + * dump_summary() + */ +} summary_dump_t; + +#if defined(_KERNEL) + +/* + * Kernel macros for adding information to pd_nvdata[]. PANICNVGET() returns + * a panic_nv_t pointer (pnv) after the end of the existing data, PANICNVADD() + * modifies the current item and increments pnv, and PANICNVSET() rewrites + * pd_msgoff to indicate the end of pd_nvdata[]. + */ +#define PANICNVGET(pdp) \ + ((pdp)->pd_nvdata + (((pdp)->pd_msgoff - \ + (sizeof (panic_data_t) - sizeof (panic_nv_t))) / sizeof (panic_nv_t))) + +#define PANICNVADD(pnv, n, v) \ + { \ + (void) strncpy((pnv)->pnv_name, (n), PANICNVNAMELEN); \ + (pnv)->pnv_value = (uint64_t)(v); (pnv)++; \ + } + +#define PANICNVSET(pdp, pnv) \ + (pdp)->pd_msgoff = (uint32_t)((char *)(pnv) - (char *)(pdp)); + +/* + * Kernel panic data; preserved in crash dump for debuggers. + */ +#pragma align 8(panicbuf) +extern char panicbuf[PANICBUFSIZE]; +extern kthread_t *panic_thread; +extern cpu_t panic_cpu; +extern hrtime_t panic_hrtime; +extern timespec_t panic_hrestime; + +/* + * Forward declarations for types: + */ +struct panic_trap_info; +struct regs; + +/* + * Miscellaneous state variables defined in or used by the panic code: + */ +extern char *panic_bootstr; +extern int panic_bootfcn; +extern int panic_forced; +extern int halt_on_panic; +extern int nopanicdebug; +extern int do_polled_io; +extern int obpdebug; +extern int in_sync; +extern int panic_quiesce; +extern int panic_dump; +extern int64_t panic_lbolt64; +extern label_t panic_regs; +extern struct regs *panic_reg; +extern dev_info_t *panic_dip; + +/* + * Panic functions called from the common panic code which must be + * implemented by architecture or platform-specific code: + */ +extern void panic_saveregs(panic_data_t *, struct regs *); +extern void panic_savetrap(panic_data_t *, struct panic_trap_info *); +extern void panic_showtrap(struct panic_trap_info *); +extern void panic_stopcpus(cpu_t *, kthread_t *, int); +extern void panic_enter_hw(int); +extern void panic_quiesce_hw(panic_data_t *); +extern void panic_dump_hw(int); +extern int panic_trigger(int *); + +#endif /* _KERNEL */ +#endif /* !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PANIC_H */ diff --git a/illumos-x86_64/usr/include/sys/param.h b/illumos-x86_64/usr/include/sys/param.h new file mode 100644 index 00000000..282d84b9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/param.h @@ -0,0 +1,515 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_PARAM_H +#define _SYS_PARAM_H + +#ifndef _ASM /* Avoid typedef headaches for assembly files */ +#include +#include +#endif /* _ASM */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Fundamental variables; don't change too often. + */ + +/* + * _POSIX_VDISABLE has historically been defined in since + * an early merge with AT&T source. It has also historically been defined + * in . The POSIX standard, IEEE Std. 1003.1-1988 initially + * required the existence of _POSIX_VDISABLE in . + * Subsequent versions of the IEEE Standard as well as the X/Open + * specifications required that _POSIX_VDISABLE be defined in + * while still allowing for it's existence in other headers. With the + * introduction of XPG6, _POSIX_VDISABLE can only be defined in . + */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE 0 /* Disable special character functions */ +#endif +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ + +/* The actual size of the TTY input queue */ +#define _TTY_BUFSIZ 2048 + +/* + * These defines all have their historical value. The actual size of the tty + * buffer both for the line-editor in ldterm, and in general, is above as + * _TTY_BUFSIZ. + * + * We leave these defines at their historical value to match the behaviour of + * BSD and Linux. + */ +#ifndef MAX_INPUT +#define MAX_INPUT 512 /* Maximum bytes stored in the input queue */ +#endif +#ifndef MAX_CANON +#define MAX_CANON 256 /* Maximum bytes for canonical processing */ +#endif +#define CANBSIZ 256 /* max size of typewriter line */ + + +#define UID_NOBODY 60001 /* user ID no body */ +#define GID_NOBODY UID_NOBODY +#define UID_UNKNOWN 96 +#define GID_UNKNOWN UID_UNKNOWN +#define UID_DLADM 15 +#define UID_NETADM 16 +#define GID_NETADM 65 +#define UID_NOACCESS 60002 /* user ID no access */ + +#ifdef _KERNEL +#define MAX_TASKID 999999 +#define MAX_MAXPID 999999 +#define MAXEPHUID 0xfffffffcu /* max ephemeral user id */ + +#define FAMOUS_PID_SCHED 0 +#define FAMOUS_PID_INIT 1 +#define FAMOUS_PID_PAGEOUT 2 +#define FAMOUS_PID_FSFLUSH 3 +#define FAMOUS_PIDS 4 +#endif + +#ifdef DEBUG +#define DEFAULT_MAXPID 999999 +#define DEFAULT_JUMPPID 100000 +#else +#define DEFAULT_MAXPID 30000 +#define DEFAULT_JUMPPID 0 +#endif + +#define MAXUID 2147483647 /* max user id */ + +#define MAXPROJID MAXUID /* max project id */ +#define MAXLINK 32767 /* max links */ + +#define MINEPHUID 0x80000000u /* min ephemeral user id */ + +#define NMOUNT 40 /* est. of # mountable fs for quota calc */ + +#define NOFILE 20 /* this define is here for */ + /* compatibility purposes only */ + /* and will be removed in a */ + /* later release */ + +/* + * These define the maximum and minimum allowable values of the + * configurable parameter NGROUPS_MAX. + */ +#define NGROUPS_UMIN 0 +#define NGROUPS_UMAX 1024 +#define NGROUPS_OLDMAX 32 + +/* + * NGROUPS_MAX_DEFAULT: *MUST* match NGROUPS_MAX value in limits.h. + */ +#define NGROUPS_MAX_DEFAULT 16 + +/* + * Default process priority. Keep it in sync with limits.h. + */ +#define NZERO 20 + +/* + * Fundamental constants of the implementation--cannot be changed easily. + */ + +#if !defined(_ASM) +#define NBPW sizeof (int) /* number of bytes in an integer */ +#endif /* _ASM */ + +#define CMASK 022 /* default mask for file creation */ +#define CDLIMIT (1L<<11) /* default max write address */ +#define NBPS 0x20000 /* Number of bytes per segment */ +#define NBPSCTR 512 /* Bytes per disk sector. */ +#define UBSIZE 512 /* unix block size. */ +#define SCTRSHFT 9 /* Shift for BPSECT. */ + +#ifdef _LITTLE_ENDIAN +#define lobyte(X) (((unsigned char *)&(X))[0]) +#define hibyte(X) (((unsigned char *)&(X))[1]) +#define loword(X) (((ushort_t *)&(X))[0]) +#define hiword(X) (((ushort_t *)&(X))[1]) +#endif +#ifdef _BIG_ENDIAN +#define lobyte(X) (((unsigned char *)&(X))[1]) +#define hibyte(X) (((unsigned char *)&(X))[0]) +#define loword(X) (((ushort_t *)&(X))[1]) +#define hiword(X) (((ushort_t *)&(X))[0]) +#endif + +/* REMOTE -- whether machine is primary, secondary, or regular */ +#define SYSNAME 9 /* # chars in system name */ +#define PREMOTE 39 + +/* + * MAXPATHLEN defines the longest permissible path length, + * including the terminating null, after expanding symbolic links. + * TYPICALMAXPATHLEN is used in a few places as an optimization + * with a local buffer on the stack to avoid kmem_alloc(). + * MAXSYMLINKS defines the maximum number of symbolic links + * that may be expanded in a path name. It should be set high + * enough to allow all legitimate uses, but halt infinite loops + * reasonably quickly. + * MAXNAMELEN is the length (including the terminating null) of + * the longest permissible file (component) name. + */ +#define MAXPATHLEN 1024 +#define TYPICALMAXPATHLEN 64 +#define MAXSYMLINKS 20 +#define MAXNAMELEN 256 + +/* + * MAXLINKNAMELEN defines the longest possible permitted datalink name, + * including the terminating NUL. Note that this must not be larger + * than related networking constants such as LIFNAMSIZ. + */ +#define MAXLINKNAMELEN 32 + +#ifndef NADDR +#define NADDR 13 +#endif + +/* + * The following are defined to be the same as + * defined in /usr/include/limits.h. They are + * needed for pipe and FIFO compatibility. + */ +#ifndef PIPE_BUF /* max # bytes atomic in write to a pipe */ +#define PIPE_BUF 5120 +#endif /* PIPE_BUF */ + +#ifndef PIPE_MAX /* max # bytes written to a pipe in a write */ +#define PIPE_MAX 5120 +#endif /* PIPE_MAX */ + +#ifndef NBBY +#define NBBY 8 /* number of bits per byte */ +#endif + +/* macros replacing interleaving functions */ +#define dkblock(bp) ((bp)->b_blkno) +#define dkunit(bp) (minor((bp)->b_dev) >> 3) + +/* + * File system parameters and macros. + * + * The file system is made out of blocks of at most MAXBSIZE units, + * with smaller units (fragments) only in the last direct block. + * MAXBSIZE primarily determines the size of buffers in the buffer + * pool. It may be made larger without any effect on existing + * file systems; however making it smaller make make some file + * systems unmountable. + * + * Note that the blocked devices are assumed to have DEV_BSIZE + * "sectors" and that fragments must be some multiple of this size. + */ +#define MAXBSIZE 8192 +#define DEV_BSIZE 512 +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define MAXFRAG 8 +#ifdef _SYSCALL32 +#define MAXOFF32_T 0x7fffffff +#endif +#ifdef _LP64 +#define MAXOFF_T 0x7fffffffffffffffl +#define MAXOFFSET_T 0x7fffffffffffffffl +#else +#define MAXOFF_T 0x7fffffffl +#ifdef _LONGLONG_TYPE +#define MAXOFFSET_T 0x7fffffffffffffffLL +#else +#define MAXOFFSET_T 0x7fffffff +#endif +#endif /* _LP64 */ + +#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + ((unsigned long)(bytes) >> DEV_BSHIFT) +#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((unsigned long)(db) << DEV_BSHIFT) + +/* 64 bit versions of btodb and dbtob */ +#define lbtodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + ((u_offset_t)(bytes) >> DEV_BSHIFT) +#define ldbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((u_offset_t)(db) << DEV_BSHIFT) + +#ifndef _ASM /* Avoid typedef headaches for assembly files */ +#ifndef NODEV +#define NODEV (dev_t)(-1l) +#ifdef _SYSCALL32 +#define NODEV32 (dev32_t)(-1) +#endif /* _SYSCALL32 */ +#endif /* NODEV */ +#endif /* _ASM */ + +/* + * Size of arg list passed in by user. + */ +#define NCARGS32 0x100000 +#define NCARGS64 0x200000 +#ifdef _LP64 +#define NCARGS NCARGS64 +#else /* _LP64 */ +#define NCARGS NCARGS32 +#endif /* _LP64 */ + +/* + * Scale factor for scaled integers used to count + * %cpu time and load averages. + */ +#define FSHIFT 8 /* bits to right of fixed binary point */ +#define FSCALE (1< 0) { \ + if (c) \ + break; \ + drv_usecwait(1); \ + } \ +} +#endif /* defined(_KERNEL) && !defined(_ASM) */ + +#ifdef __cplusplus +} +#endif + +/* + * The following is to free utilities from machine dependencies within + * an architecture. Must be included after definition of DEV_BSIZE. + */ + +#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT) + +#if defined(_MACHDEP) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) && !defined(_ASM) +extern int cpu_decay_factor; +extern pid_t maxpid; +extern pid_t jump_pid; + +extern uintptr_t _kernelbase; +extern uintptr_t _userlimit; +extern uintptr_t _userlimit32; +#endif /* defined(_KERNEL) && !defined(_ASM) */ + +/* + * These three variables have been added within the #if defined(lint) + * below to ensure visibility to lint. This is a short term workaround + * to handle poor interaction between SS12 lint and these variables. + * CR 6742611 has been logged to address these issues. + */ +#if defined(lint) +extern int snooping; +extern uint_t snoop_interval; +extern const unsigned int _pageshift; +#endif /* lint */ + +#if !defined(_MACHDEP) + +/* + * Implementation architecture independent sections of the kernel use + * this section. + */ +#if defined(_KERNEL) && !defined(_ASM) +extern int hz; +extern int snooping; +extern uint_t snoop_interval; +extern const unsigned long _pagesize; +extern const unsigned int _pageshift; +extern const unsigned long _pageoffset; +extern const unsigned long long _pagemask; +extern const unsigned long _mmu_pagesize; +extern const unsigned int _mmu_pageshift; +extern const unsigned long _mmu_pageoffset; +extern const unsigned long _mmu_pagemask; +extern const uintptr_t _argsbase; +extern const unsigned long _defaultstksz; +extern const unsigned int _nbpg; +extern const int _ncpu; +extern const int _ncpu_log2; +extern const int _ncpu_p2; +extern const int _clsize; +#endif /* defined(_KERNEL) && !defined(_ASM) */ + +/* Any additions to these #defines must be reflected in mdb_param.h+mdb_ks.c */ +#define PAGESIZE _pagesize +#define PAGESHIFT _pageshift +#define PAGEOFFSET _pageoffset +#define PAGEMASK _pagemask +#define MMU_PAGESIZE _mmu_pagesize +#define MMU_PAGESHIFT _mmu_pageshift +#define MMU_PAGEOFFSET _mmu_pageoffset +#define MMU_PAGEMASK _mmu_pagemask + +#define KERNELBASE _kernelbase +#define USERLIMIT _userlimit +#define USERLIMIT32 _userlimit32 +#define ARGSBASE _argsbase +#define DEFAULTSTKSZ _defaultstksz +#define NCPU _ncpu +#define NCPU_LOG2 _ncpu_log2 +#define NCPU_P2 _ncpu_p2 + +#endif /* defined(_MACHDEP) */ + +/* + * Some random macros for units conversion. + * + * These are machine independent but contain constants (*PAGESHIFT) which + * are only defined in the machine dependent file. + */ + +/* + * MMU pages to bytes, and back (with and without rounding) + */ +#define mmu_ptob(x) ((x) << MMU_PAGESHIFT) +#define mmu_btop(x) (((x)) >> MMU_PAGESHIFT) +#define mmu_btopr(x) ((((x) + MMU_PAGEOFFSET) >> MMU_PAGESHIFT)) + +/* + * 2 versions of pages to disk blocks + */ +#define mmu_ptod(x) ((x) << (MMU_PAGESHIFT - DEV_BSHIFT)) +#define ptod(x) ((x) << (PAGESHIFT - DEV_BSHIFT)) + +/* + * pages to bytes, and back (with and without rounding) + * Large Files: The explicit cast of x to unsigned int is deliberately + * removed as part of large files work. We pass longlong values to + * theses macros. + * + * Cast the input to ptob() to be a page count. This enforces 64-bit + * math on 64-bit kernels. For 32-bit kernels, callers must explicitly + * cast the input to be a 64-bit type if values greater than 4GB/PAGESIZE + * are possible. + */ + +#ifdef _LP64 +#define ptob(x) (((pgcnt_t)(x)) << PAGESHIFT) +#else +#define ptob(x) ((x) << PAGESHIFT) +#endif /* _LP64 */ +#define btop(x) (((x) >> PAGESHIFT)) +#define btopr(x) ((((x) + PAGEOFFSET) >> PAGESHIFT)) + +/* + * disk blocks to pages, rounded and truncated + */ +#define NDPP (PAGESIZE/DEV_BSIZE) /* # of disk blocks per page */ +#define dtop(DD) (((DD) + NDPP - 1) >> (PAGESHIFT - DEV_BSHIFT)) +#define dtopt(DD) ((DD) >> (PAGESHIFT - DEV_BSHIFT)) + +/* + * kB to pages and back + */ +#define kbtop(x) ((x) >> (PAGESHIFT - 10)) +#define ptokb(x) ((x) << (PAGESHIFT - 10)) + +/* + * POSIX.4 related configuration parameters + */ +#define _AIO_LISTIO_MAX (4096) +#define _AIO_MAX (-1) +#define _MQ_OPEN_MAX (-1) +#define _MQ_PRIO_MAX (32) +#define _SEM_NSEMS_MAX INT_MAX +#define _SEM_VALUE_MAX INT_MAX + +#ifdef __cplusplus +} +#endif + +#else /* defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT) */ + +/* + * The following are assorted machine dependent values which can be + * obtained in a machine independent manner through sysconf(2) or + * sysinfo(2). In order to guarantee that these provide the expected + * value at all times, the System Private interface (leading underscore) + * is used. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_ASM) +extern long _sysconf(int); /* System Private interface to sysconf() */ +#endif /* !defined(_ASM) */ + +#define HZ ((clock_t)_sysconf(_SC_CLK_TCK)) +#define TICK (1000000000/((clock_t)_sysconf(_SC_CLK_TCK))) +#define PAGESIZE (_sysconf(_SC_PAGESIZE)) +#define PAGEOFFSET (PAGESIZE - 1) +#define PAGEMASK (~PAGEOFFSET) +#define MAXPID ((pid_t)_sysconf(_SC_MAXPID)) +#define MAXEPHUID ((uid_t)_sysconf(_SC_EPHID_MAX)) + +#ifdef __cplusplus +} +#endif + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT) */ + +#endif /* _SYS_PARAM_H */ diff --git a/illumos-x86_64/usr/include/sys/pathconf.h b/illumos-x86_64/usr/include/sys/pathconf.h new file mode 100644 index 00000000..2f6ddcee --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pathconf.h @@ -0,0 +1,127 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PATHCONF_H +#define _SYS_PATHCONF_H + +/* pathconf.h 1.9 89/06/26 SMI */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * POSIX pathconf information + * + * static pathconf kludge notes: + * For NFSv2 servers, we've added a vop (vop_cntl) to dig out pathconf + * information. The mount program asked for the information from + * a remote mountd daemon. If it gets it, it passes the info + * down in a new args field. The info is passed in the struct below + * in nfsargs.pathconf. There's a new NFS mount flag so that you know + * this is happening. NFS stores the information locally; when a + * pathconf request is made, the request is intercepted at the client + * and the information is retrieved from the struct passed down by + * mount. It's a kludge that will go away as soon + * as we can ask the nfs protocol these sorts of questions (NFSr3). + * All code is noted by "static pathconf kludge" comments and is + * restricted to nfs code in the kernel. + */ + +#define _BITS (8 * sizeof (short)) +#define _PC_N ((_PC_LAST + _BITS - 1) / _BITS) +#define _PC_ISSET(n, a) (a[(n) / _BITS] & (1 << ((n) % _BITS))) +#define _PC_SET(n, a) (a[(n) / _BITS] |= (1 << ((n) % _BITS))) +#define _PC_ERROR 0 + +struct pathcnf { + /* + * pathconf() information + */ + int pc_link_max; /* max links allowed */ + short pc_max_canon; /* max line len for a tty */ + short pc_max_input; /* input a tty can eat all once */ + short pc_name_max; /* max file name length (dir entry) */ + short pc_path_max; /* path name len (/x/y/z/...) */ + short pc_pipe_buf; /* size of a pipe (bytes) */ + uchar_t pc_vdisable; /* safe char to turn off c_cc[i] */ + char pc_xxx; /* alignment padding; cc_t == char */ + short pc_mask[_PC_N]; /* see below */ +#ifdef _KERNEL + short pc_refcnt; /* number of mounts that use this */ + struct pathcnf *pc_next; /* linked list */ +#endif +}; + +#ifdef _SYSCALL32 +struct pathcnf32 { + /* + * pathconf() information + */ + int32_t pc_link_max; /* max links allowed */ + int16_t pc_max_canon; /* max line len for a tty */ + int16_t pc_max_input; /* input a tty can eat all once */ + int16_t pc_name_max; /* max file name length (dir entry) */ + int16_t pc_path_max; /* path name len (/x/y/z/...) */ + int16_t pc_pipe_buf; /* size of a pipe (bytes) */ + uint8_t pc_vdisable; /* safe char to turn off c_cc[i] */ + int8_t pc_xxx; /* alignment padding; cc_t == char */ + int16_t pc_mask[_PC_N]; /* see below */ +#ifdef _KERNEL + int16_t pc_refcnt; /* number of mounts that use this */ + caddr32_t pc_next; /* linked list */ +#endif +}; +#endif /* _SYSCALL32 */ + +/* + * pc_mask is used to encode either + * a) boolean values (for chown_restricted and no_trunc) + * b) errno on/off (for link, canon, input, name, path, and pipe) + * The _PC_XXX values are defined in unistd.h; they start at 1 and go up + * sequentially. + * _PC_ERROR is used as the first bit to indicate total failure + * (all info invalid). + * To check for an error something like + * _PC_ISSET(_PC_PATHMAX, foo.pc_mask) != 0 + * is used. + */ + +/* + * The size of the non-kernel part of the struct. + */ +#ifdef _KERNEL +#define PCSIZ ((size_t)(&(((struct pathcnf *)0)->pc_refcnt))) +#define PCCMP(p1, p2) bcmp((char *)p1, (char *)p2, PCSIZ) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PATHCONF_H */ diff --git a/illumos-x86_64/usr/include/sys/pathname.h b/illumos-x86_64/usr/include/sys/pathname.h new file mode 100644 index 00000000..73cb0525 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pathname.h @@ -0,0 +1,110 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_PATHNAME_H +#define _SYS_PATHNAME_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Pathname structure. + * System calls that operate on path names gather the path name + * from the system call into this structure and reduce it by + * peeling off translated components. If a symbolic link is + * encountered the new path name to be translated is also + * assembled in this structure. + * + * By convention pn_buf is not changed once it's been set to point + * to the underlying storage; routines which manipulate the pathname + * do so by changing pn_path and pn_pathlen. pn_pathlen is redundant + * since the path name is null-terminated, but is provided to make + * some computations faster. + */ +typedef struct pathname { + char *pn_buf; /* underlying storage */ + char *pn_path; /* remaining pathname */ + size_t pn_pathlen; /* remaining length */ + size_t pn_bufsize; /* total size of pn_buf */ +} pathname_t; + +#define pn_pathleft(pnp) ((pnp)->pn_pathlen) + +extern void pn_alloc(struct pathname *); +extern void pn_alloc_sz(struct pathname *, size_t); +extern int pn_get(const char *, enum uio_seg, struct pathname *); +extern int pn_get_buf(const char *, enum uio_seg, struct pathname *, + void *, size_t); +extern int pn_set(struct pathname *, const char *); +extern int pn_insert(struct pathname *, struct pathname *, size_t); +extern int pn_getsymlink(vnode_t *, struct pathname *, cred_t *); +extern int pn_getcomponent(struct pathname *, char *); +extern void pn_setlast(struct pathname *); +extern void pn_skipslash(struct pathname *); +extern int pn_fixslash(struct pathname *); +extern int pn_addslash(struct pathname *); +extern void pn_free(struct pathname *); + +extern int lookupname(const char *, enum uio_seg, int follow, + vnode_t **, vnode_t **); +extern int lookupnameat(const char *, enum uio_seg, int follow, + vnode_t **, vnode_t **, vnode_t *); +extern int lookupnameatcred(const char *, enum uio_seg, int follow, + vnode_t **, vnode_t **, vnode_t *, cred_t *); +extern int lookuppn(struct pathname *, struct pathname *, int follow, + vnode_t **, vnode_t **); +extern int lookuppnat(struct pathname *, struct pathname *, int follow, + vnode_t **, vnode_t **, vnode_t *); +extern int lookuppnatcred(struct pathname *, struct pathname *, int follow, + vnode_t **, vnode_t **, vnode_t *, cred_t *); + +extern int lookuppnvp(struct pathname *, struct pathname *, int follow, + vnode_t **, vnode_t **, vnode_t *, vnode_t *, cred_t *); +extern int traverse(vnode_t **); + +extern int vnodetopath(vnode_t *, vnode_t *, char *, size_t, cred_t *); +extern int dogetcwd(char *, size_t); +extern int dirfindvp(vnode_t *, vnode_t *, vnode_t *, cred_t *, char *, + size_t, dirent64_t **); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PATHNAME_H */ diff --git a/illumos-x86_64/usr/include/sys/pattr.h b/illumos-x86_64/usr/include/sys/pattr.h new file mode 100644 index 00000000..a1fb21ad --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pattr.h @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_PATTR_H +#define _SYS_PATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Attribute types and structures. + */ +#define PATTR_DSTADDRSAP 0x1 /* destination physical address+SAP */ +#define PATTR_SRCADDRSAP 0x2 /* source physical address+SAP */ +#define PATTR_HCKSUM 0x3 /* hardware checksum attribute */ +#define PATTR_ZCOPY 0x4 /* zerocopy attribute */ + +/* + * Structure shared by {source,destination} physical address+SAP attributes. + */ +typedef struct pattr_addr_s { + uint8_t addr_is_group; /* address is broadcast or multicast */ + uint8_t addr_len; /* length of address */ + uint8_t addr[1]; /* address */ +} pattr_addr_t; + +/* + * Structure used for Hardware Checksum attribute. + */ + +typedef struct pattr_hcksum_s { + uint32_t hcksum_start_offset; + uint32_t hcksum_stuff_offset; + uint32_t hcksum_end_offset; + union { + uint64_t value; + uint16_t inet_cksum; /* to store H/W computed cksum value */ + } hcksum_cksum_val; + uint32_t hcksum_flags; +} pattr_hcksum_t; + +/* + * Values for hcksum_flags + */ +#define HCK_IPV4_HDRCKSUM 0x01 /* On Transmit: Compute IP header */ + /* checksum in hardware. */ + +#define HCK_IPV4_HDRCKSUM_OK 0x01 /* On Receive: IP header checksum */ + /* was verified by h/w and is */ + /* correct. */ + +#define HCK_PARTIALCKSUM 0x02 /* On Transmit: Compute partial 1's */ + /* complement checksum based on */ + /* start, stuff and end offsets. */ + /* On Receive : Partial checksum */ + /* computed and attached. */ + +#define HCK_FULLCKSUM 0x04 /* On Transmit: Compute full(in case */ + /* of TCP/UDP, full is pseudo-header */ + /* + header + payload) checksum for */ + /* this packet. */ + /* On Receive : Full checksum */ + /* computed in h/w and is attached */ + +#define HCK_FULLCKSUM_OK 0x08 /* On Transmit: N/A */ + /* On Receive: Full checksum status */ + /* If set, implies full checksum */ + /* computation was successful */ + /* i.e. checksum was correct. */ + /* If it is not set, IP will also */ + /* check the attached h/w computed */ + /* checksum value to determine if */ + /* checksum was bad */ + +#define HCK_FLAGS (HCK_IPV4_HDRCKSUM | HCK_PARTIALCKSUM | \ + HCK_FULLCKSUM | HCK_FULLCKSUM_OK) +#define HCK_TX_FLAGS (HCK_IPV4_HDRCKSUM | HCK_PARTIALCKSUM | \ + HCK_FULLCKSUM) +/* + * Extended hardware offloading flags that also use hcksum_flags + */ +#define HW_LSO 0x10 /* On Transmit: hardware does LSO */ + /* On Receive: N/A */ + +#define HW_LSO_FLAGS HW_LSO /* All LSO flags, currently only one */ + +/* + * Structure used for zerocopy attribute. + */ +typedef struct pattr_zcopy_s { + uint_t zcopy_flags; +} pattr_zcopy_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PATTR_H */ diff --git a/illumos-x86_64/usr/include/sys/pbio.h b/illumos-x86_64/usr/include/sys/pbio.h new file mode 100644 index 00000000..764fbdbd --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pbio.h @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_PBIO_H +#define _SYS_PBIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Supported ioctls + */ +#define PBIOC ('p' << 8) +#define PB_BEGIN_MONITOR (PBIOC | 1) +#define PB_END_MONITOR (PBIOC | 2) +#define PB_CREATE_BUTTON_EVENT (PBIOC | 3) /* used by test suite */ +#define PB_GET_EVENTS (PBIOC | 4) + +/* + * Supported events + */ +#define PB_BUTTON_PRESS 0x1 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PBIO_H */ diff --git a/illumos-x86_64/usr/include/sys/pcb.h b/illumos-x86_64/usr/include/sys/pcb.h new file mode 100644 index 00000000..2fe5ad8f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pcb.h @@ -0,0 +1,106 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_PCB_H +#define _SYS_PCB_H + +#include +#include +#ifndef _ASM +#include /* kfpu_t */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM +typedef struct fpu_ctx { + kfpu_t fpu_regs; /* kernel save area for FPU */ + uint64_t fpu_xsave_mask; /* xsave mask for FPU/SSE/AVX */ + uint_t fpu_flags; /* FPU state flags */ + void *fpu_signal; /* copyin area for signal handling */ +} fpu_ctx_t; + +typedef struct pcb { + fpu_ctx_t pcb_fpu; /* fpu state */ + uint_t pcb_flags; /* state flags; cleared on fork */ + greg_t pcb_drstat; /* status debug register (%dr6) */ + unsigned char pcb_instr; /* /proc: instruction at stop */ + unsigned char pcb_rupdate; /* new register values in pcb -> regs */ + uintptr_t pcb_fsbase; + uintptr_t pcb_gsbase; + selector_t pcb_ds; + selector_t pcb_es; + selector_t pcb_fs; + selector_t pcb_gs; + user_desc_t pcb_fsdesc; /* private per-lwp %fs descriptors */ + user_desc_t pcb_gsdesc; /* private per-lwp %gs descriptors */ +} pcb_t; + +#endif /* ! _ASM */ + +/* pcb_flags */ +#define DEBUG_PENDING 0x02 /* single-step of lcall for a sys call */ +#define PRSTOP_CALLED 0x04 /* prstop() has been called for this lwp */ +#define INSTR_VALID 0x08 /* value in pcb_instr is valid (/proc) */ +#define NORMAL_STEP 0x10 /* normal debugger-requested single-step */ +#define WATCH_STEP 0x20 /* single-stepping in watchpoint emulation */ +#define CPC_OVERFLOW 0x40 /* performance counters overflowed */ +#define REQUEST_STEP 0x100 /* request pending to single-step this lwp */ +#define REQUEST_NOSTEP 0x200 /* request pending to disable single-step */ +#define ASYNC_HWERR 0x400 /* hardware error has corrupted context */ + +/* pcb_rupdate values */ +#define PCB_UPDATE_SEGS 0x01 /* Update segment registers */ +#define PCB_UPDATE_FPU 0x02 /* Update FPU registers */ + +#define PCB_SET_UPDATE_SEGS(pcb) ((pcb)->pcb_rupdate |= PCB_UPDATE_SEGS) +#define PCB_SET_UPDATE_FPU(pcb) ((pcb)->pcb_rupdate |= PCB_UPDATE_FPU) +#define PCB_NEED_UPDATE_SEGS(pcb) \ + (((pcb)->pcb_rupdate & PCB_UPDATE_SEGS) != 0) +#define PCB_NEED_UPDATE_FPU(pcb) \ + (((pcb)->pcb_rupdate & PCB_UPDATE_FPU) != 0) +#define PCB_NEED_UPDATE(pcb) \ + (PCB_NEED_UPDATE_FPU(pcb) || PCB_NEED_UPDATE_SEGS(pcb)) +#define PCB_CLEAR_UPDATE_SEGS(pcb) ((pcb)->pcb_rupdate &= ~PCB_UPDATE_SEGS) +#define PCB_CLEAR_UPDATE_FPU(pcb) ((pcb)->pcb_rupdate &= ~PCB_UPDATE_FPU) + +/* fpu_flags */ +#define FPU_EN 0x01 /* FPU in use (user or kernel) */ +#define FPU_VALID 0x02 /* fpu_regs has valid fpu state */ +#define FPU_MODIFIED 0x04 /* fpu_regs is modified (/proc) */ +#define FPU_KERNEL 0x08 /* Kernel is using the FPU */ + +#define FPU_INVALID 0x0 /* fpu context is not in use */ + +/* fpu_flags */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PCB_H */ diff --git a/illumos-x86_64/usr/include/sys/pccard.h b/illumos-x86_64/usr/include/sys/pccard.h new file mode 100644 index 00000000..111b160a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pccard.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * PCMCIA PC Card client driver master header file + * + * All PC Card client drivers must include this header file + */ + +#ifndef _PCCARD_H +#define _PCCARD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#ifdef _KERNEL +#include +#include +#include +#include +#include +#endif /* _KERNEL */ + +#include +#include + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +} +#endif + +#endif /* _PCCARD_H */ diff --git a/illumos-x86_64/usr/include/sys/pci.h b/illumos-x86_64/usr/include/sys/pci.h new file mode 100644 index 00000000..2903a669 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pci.h @@ -0,0 +1,1281 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2019, Joyent, Inc. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_PCI_H +#define _SYS_PCI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * PCI Configuration Header offsets + */ +#define PCI_CONF_VENID 0x0 /* vendor id, 2 bytes */ +#define PCI_CONF_DEVID 0x2 /* device id, 2 bytes */ +#define PCI_CONF_COMM 0x4 /* command register, 2 bytes */ +#define PCI_CONF_STAT 0x6 /* status register, 2 bytes */ +#define PCI_CONF_REVID 0x8 /* revision id, 1 byte */ +#define PCI_CONF_PROGCLASS 0x9 /* programming class code, 1 byte */ +#define PCI_CONF_SUBCLASS 0xA /* sub-class code, 1 byte */ +#define PCI_CONF_BASCLASS 0xB /* basic class code, 1 byte */ +#define PCI_CONF_CACHE_LINESZ 0xC /* cache line size, 1 byte */ +#define PCI_CONF_LATENCY_TIMER 0xD /* latency timer, 1 byte */ +#define PCI_CONF_HEADER 0xE /* header type, 1 byte */ +#define PCI_CONF_BIST 0xF /* builtin self test, 1 byte */ + +/* + * Header type 0 offsets + */ +#define PCI_CONF_BASE0 0x10 /* base register 0, 4 bytes */ +#define PCI_CONF_BASE1 0x14 /* base register 1, 4 bytes */ +#define PCI_CONF_BASE2 0x18 /* base register 2, 4 bytes */ +#define PCI_CONF_BASE3 0x1c /* base register 3, 4 bytes */ +#define PCI_CONF_BASE4 0x20 /* base register 4, 4 bytes */ +#define PCI_CONF_BASE5 0x24 /* base register 5, 4 bytes */ +#define PCI_CONF_CIS 0x28 /* Cardbus CIS Pointer */ +#define PCI_CONF_SUBVENID 0x2c /* Subsystem Vendor ID */ +#define PCI_CONF_SUBSYSID 0x2e /* Subsystem ID */ +#define PCI_CONF_ROM 0x30 /* ROM base register, 4 bytes */ +#define PCI_CONF_CAP_PTR 0x34 /* capabilities pointer, 1 byte */ +#define PCI_CONF_ILINE 0x3c /* interrupt line, 1 byte */ +#define PCI_CONF_IPIN 0x3d /* interrupt pin, 1 byte */ +#define PCI_CONF_MIN_G 0x3e /* minimum grant, 1 byte */ +#define PCI_CONF_MAX_L 0x3f /* maximum grant, 1 byte */ + +/* + * PCI to PCI bridge configuration space header format + */ +#define PCI_BCNF_PRIBUS 0x18 /* primary bus number */ +#define PCI_BCNF_SECBUS 0x19 /* secondary bus number */ +#define PCI_BCNF_SUBBUS 0x1a /* subordinate bus number */ +#define PCI_BCNF_LATENCY_TIMER 0x1b +#define PCI_BCNF_IO_BASE_LOW 0x1c +#define PCI_BCNF_IO_LIMIT_LOW 0x1d +#define PCI_BCNF_SEC_STATUS 0x1e +#define PCI_BCNF_MEM_BASE 0x20 +#define PCI_BCNF_MEM_LIMIT 0x22 +#define PCI_BCNF_PF_BASE_LOW 0x24 +#define PCI_BCNF_PF_LIMIT_LOW 0x26 +#define PCI_BCNF_PF_BASE_HIGH 0x28 +#define PCI_BCNF_PF_LIMIT_HIGH 0x2c +#define PCI_BCNF_IO_BASE_HI 0x30 +#define PCI_BCNF_IO_LIMIT_HI 0x32 +#define PCI_BCNF_CAP_PTR 0x34 +#define PCI_BCNF_ROM 0x38 +#define PCI_BCNF_ILINE 0x3c +#define PCI_BCNF_IPIN 0x3d +#define PCI_BCNF_BCNTRL 0x3e + +#define PCI_BCNF_BASE_NUM 0x2 + +/* + * PCI to PCI bridge control register (0x3e) format + */ +#define PCI_BCNF_BCNTRL_PARITY_ENABLE 0x1 +#define PCI_BCNF_BCNTRL_SERR_ENABLE 0x2 +#define PCI_BCNF_BCNTRL_ISA_ENABLE 0x4 +#define PCI_BCNF_BCNTRL_VGA_ENABLE 0x8 +#define PCI_BCNF_BCNTRL_MAST_AB_MODE 0x20 +#define PCI_BCNF_BCNTRL_DTO_STAT 0x400 + +#define PCI_BCNF_BCNTRL_RESET 0x0040 +#define PCI_BCNF_BCNTRL_B2B_ENAB 0x0080 + +#define PCI_BCNF_IO_MASK 0xf0 +#define PCI_BCNF_IO_SHIFT 8 +#define PCI_BCNF_IO_LIMIT_BITS 0xfff +#define PCI_BCNF_MEM_MASK 0xfff0 +#define PCI_BCNF_MEM_SHIFT 16 +#define PCI_BCNF_MEM_LIMIT_BITS 0xfffff +#define PCI_BCNF_ADDR_MASK 0x000f + +#define PCI_BCNF_IO_32BIT 0x01 +#define PCI_BCNF_PF_MEM_64BIT 0x01 + +/* + * Header type 2 (Cardbus) offsets + */ +#define PCI_CBUS_SOCK_REG 0x10 /* Cardbus socket regs, 4 bytes */ +#define PCI_CBUS_CAP_PTR 0x14 /* Capability ptr, 1 byte */ +#define PCI_CBUS_RESERVED1 0x15 /* Reserved, 1 byte */ +#define PCI_CBUS_SEC_STATUS 0x16 /* Secondary status, 2 bytes */ +#define PCI_CBUS_PCI_BUS_NO 0x18 /* PCI bus number, 1 byte */ +#define PCI_CBUS_CBUS_NO 0x19 /* Cardbus bus number, 1 byte */ +#define PCI_CBUS_SUB_BUS_NO 0x1a /* Subordinate bus number, 1 byte */ +#define PCI_CBUS_LATENCY_TIMER 0x1b /* Cardbus latency timer, 1 byte */ +#define PCI_CBUS_MEM_BASE0 0x1c /* Memory base reg 0, 4 bytes */ +#define PCI_CBUS_MEM_LIMIT0 0x20 /* Memory limit reg 0, 4 bytes */ +#define PCI_CBUS_MEM_BASE1 0x24 /* Memory base reg 1, 4 bytes */ +#define PCI_CBUS_MEM_LIMIT1 0x28 /* Memory limit reg 1, 4 bytes */ +#define PCI_CBUS_IO_BASE0 0x2c /* IO base reg 0, 4 bytes */ +#define PCI_CBUS_IO_LIMIT0 0x30 /* IO limit reg 0, 4 bytes */ +#define PCI_CBUS_IO_BASE1 0x34 /* IO base reg 1, 4 bytes */ +#define PCI_CBUS_IO_LIMIT1 0x38 /* IO limit reg 1, 4 bytes */ +#define PCI_CBUS_ILINE 0x3c /* interrupt line, 1 byte */ +#define PCI_CBUS_IPIN 0x3d /* interrupt pin, 1 byte */ +#define PCI_CBUS_BRIDGE_CTRL 0x3e /* Bridge control, 2 bytes */ +#define PCI_CBUS_SUBVENID 0x40 /* Subsystem Vendor ID, 2 bytes */ +#define PCI_CBUS_SUBSYSID 0x42 /* Subsystem ID, 2 bytes */ +#define PCI_CBUS_LEG_MODE_ADDR 0x44 /* PCCard 16bit IF legacy mode addr */ + +#define PCI_CBUS_BASE_NUM 0x1 /* number of base registers */ + +/* + * PCI command register bits + */ +#define PCI_COMM_IO 0x1 /* I/O access enable */ +#define PCI_COMM_MAE 0x2 /* memory access enable */ +#define PCI_COMM_ME 0x4 /* master enable */ +#define PCI_COMM_SPEC_CYC 0x8 +#define PCI_COMM_MEMWR_INVAL 0x10 +#define PCI_COMM_PALETTE_SNOOP 0x20 +#define PCI_COMM_PARITY_DETECT 0x40 +#define PCI_COMM_WAIT_CYC_ENAB 0x80 +#define PCI_COMM_SERR_ENABLE 0x100 +#define PCI_COMM_BACK2BACK_ENAB 0x200 +#define PCI_COMM_INTX_DISABLE 0x400 /* INTx emulation disable */ + +/* + * PCI Interrupt pin value + */ +#define PCI_INTA 1 +#define PCI_INTB 2 +#define PCI_INTC 3 +#define PCI_INTD 4 + +/* + * PCI status register bits + */ +#define PCI_STAT_READY 0x1 /* Immediate Readiness */ +#define PCI_STAT_INTR 0x8 /* Interrupt state */ +#define PCI_STAT_CAP 0x10 /* Implements Capabilities */ +#define PCI_STAT_66MHZ 0x20 /* 66 MHz capable */ +#define PCI_STAT_UDF 0x40 /* UDF supported */ +#define PCI_STAT_FBBC 0x80 /* Fast Back-to-Back Capable */ +#define PCI_STAT_S_PERROR 0x100 /* Data Parity Reported */ +#define PCI_STAT_DEVSELT 0x600 /* Device select timing */ +#define PCI_STAT_S_TARG_AB 0x800 /* Signaled Target Abort */ +#define PCI_STAT_R_TARG_AB 0x1000 /* Received Target Abort */ +#define PCI_STAT_R_MAST_AB 0x2000 /* Received Master Abort */ +#define PCI_STAT_S_SYSERR 0x4000 /* Signaled System Error */ +#define PCI_STAT_PERROR 0x8000 /* Detected Parity Error */ + +/* + * DEVSEL timing values + */ +#define PCI_STAT_DEVSELT_FAST 0x0000 +#define PCI_STAT_DEVSELT_MEDIUM 0x0200 +#define PCI_STAT_DEVSELT_SLOW 0x0400 + +/* + * BIST values + */ +#define PCI_BIST_SUPPORTED 0x80 +#define PCI_BIST_GO 0x40 +#define PCI_BIST_RESULT_M 0x0f +#define PCI_BIST_RESULT_OK 0x00 + +/* + * PCI class codes + */ +#define PCI_CLASS_NONE 0x0 /* class code for pre-2.0 devices */ +#define PCI_CLASS_MASS 0x1 /* Mass storage Controller class */ +#define PCI_CLASS_NET 0x2 /* Network Controller class */ +#define PCI_CLASS_DISPLAY 0x3 /* Display Controller class */ +#define PCI_CLASS_MM 0x4 /* Multimedia Controller class */ +#define PCI_CLASS_MEM 0x5 /* Memory Controller class */ +#define PCI_CLASS_BRIDGE 0x6 /* Bridge Controller class */ +#define PCI_CLASS_COMM 0x7 /* Communications Controller class */ +#define PCI_CLASS_PERIPH 0x8 /* Peripheral Controller class */ +#define PCI_CLASS_INPUT 0x9 /* Input Device class */ +#define PCI_CLASS_DOCK 0xa /* Docking Station class */ +#define PCI_CLASS_PROCESSOR 0xb /* Processor class */ +#define PCI_CLASS_SERIALBUS 0xc /* Serial Bus class */ +#define PCI_CLASS_WIRELESS 0xd /* Wireless Controller class */ +#define PCI_CLASS_INTIO 0xe /* Intelligent IO Controller class */ +#define PCI_CLASS_SATELLITE 0xf /* Satellite Communication class */ +#define PCI_CLASS_CRYPT 0x10 /* Encrytion/Decryption class */ +#define PCI_CLASS_SIGNAL 0x11 /* Signal Processing class */ + +/* + * PCI Sub-class codes - base class 0x0 (no new devices should use this code). + */ +#define PCI_NONE_NOTVGA 0x0 /* All devices except VGA compatible */ +#define PCI_NONE_VGA 0x1 /* VGA compatible */ + +/* + * PCI Sub-class codes - base class 0x1 (mass storage controllers) + */ +#define PCI_MASS_SCSI 0x0 /* SCSI bus Controller */ +#define PCI_MASS_IDE 0x1 /* IDE Controller */ +#define PCI_MASS_FD 0x2 /* Floppy disk Controller */ +#define PCI_MASS_IPI 0x3 /* IPI bus Controller */ +#define PCI_MASS_RAID 0x4 /* RAID Controller */ +#define PCI_MASS_ATA 0x5 /* ATA Controller */ +#define PCI_MASS_SATA 0x6 /* Serial ATA */ +#define PCI_MASS_SAS 0x7 /* Serial Attached SCSI (SAS) Cntrlr */ +#define PCI_MASS_NVME 0x8 /* Non-Volatile memory controller */ +#define PCI_MASS_OTHER 0x80 /* Other Mass Storage Controller */ + +/* + * programming interface for IDE (subclass 1) + */ +#define PCI_IDE_IF_NATIVE_PRI 0x1 /* primary channel is native */ +#define PCI_IDE_IF_PROG_PRI 0x2 /* primary can operate in either mode */ +#define PCI_IDE_IF_NATIVE_SEC 0x4 /* secondary channel is native */ +#define PCI_IDE_IF_PROG_SEC 0x8 /* sec. can operate in either mode */ +#define PCI_IDE_IF_MASK 0xf /* programming interface mask */ + + +/* + * programming interface for ATA (subclass 5) + */ +#define PCI_ATA_IF_SINGLE_DMA 0x20 /* ATA controller with single DMA */ +#define PCI_ATA_IF_CHAINED_DMA 0x30 /* ATA controller with chained DMA */ + +/* + * programming interface for ATA (subclass 6) for SATA + */ +#define PCI_SATA_VS_INTERFACE 0x0 /* SATA Ctlr Vendor Specific Intfc */ +#define PCI_SATA_AHCI_INTERFACE 0x1 /* SATA Ctlr AHCI 1.0 Interface */ +#define PCI_SATA_SSB_INTERFACE 0x2 /* Serial Storage Bus Interface */ + +/* + * programming interface for ATA (subclass 7) for SAS + */ +#define PCI_SAS_CONTROLLER 0x0 /* SAS Controller */ +#define PCI_SAS_BUS_INTERFACE 0x1 /* Serial Storage Bus Interface */ + +/* + * PCI Sub-class codes - base class 0x2 (Network controllers) + */ +#define PCI_NET_ENET 0x0 /* Ethernet Controller */ +#define PCI_NET_TOKEN 0x1 /* Token Ring Controller */ +#define PCI_NET_FDDI 0x2 /* FDDI Controller */ +#define PCI_NET_ATM 0x3 /* ATM Controller */ +#define PCI_NET_ISDN 0x4 /* ISDN Controller */ +#define PCI_NET_WFIP 0x5 /* WorldFip Controller */ +#define PCI_NET_PICMG 0x6 /* PICMG 2.14 Multi Computing */ +#define PCI_NET_OTHER 0x80 /* Other Network Controller */ + +/* + * PCI Sub-class codes - base class 03 (display controllers) + */ +#define PCI_DISPLAY_VGA 0x0 /* VGA device */ +#define PCI_DISPLAY_XGA 0x1 /* XGA device */ +#define PCI_DISPLAY_3D 0x2 /* 3D controller */ +#define PCI_DISPLAY_OTHER 0x80 /* Other Display Device */ + +/* + * programming interface for display for display class (subclass 0) VGA ctrlrs + */ +#define PCI_DISPLAY_IF_VGA 0x0 /* VGA compatible */ +#define PCI_DISPLAY_IF_8514 0x1 /* 8514 compatible */ + +/* + * PCI Sub-class codes - base class 0x4 (multi-media devices) + */ +#define PCI_MM_VIDEO 0x0 /* Video device */ +#define PCI_MM_AUDIO 0x1 /* Audio device */ +#define PCI_MM_TELEPHONY 0x2 /* Computer Telephony device */ +#define PCI_MM_MIXED_MODE 0x3 /* Mixed Mode device */ +#define PCI_MM_OTHER 0x80 /* Other Multimedia Device */ + +/* + * PCI Sub-class codes - base class 0x5 (memory controllers) + */ +#define PCI_MEM_RAM 0x0 /* RAM device */ +#define PCI_MEM_FLASH 0x1 /* FLASH device */ +#define PCI_MEM_OTHER 0x80 /* Other Memory Controller */ + +/* + * PCI Sub-class codes - base class 0x6 (Bridge devices) + */ +#define PCI_BRIDGE_HOST 0x0 /* Host/PCI Bridge */ +#define PCI_BRIDGE_ISA 0x1 /* PCI/ISA Bridge */ +#define PCI_BRIDGE_EISA 0x2 /* PCI/EISA Bridge */ +#define PCI_BRIDGE_MC 0x3 /* PCI/MC Bridge */ +#define PCI_BRIDGE_PCI 0x4 /* PCI/PCI Bridge */ +#define PCI_BRIDGE_PCMCIA 0x5 /* PCI/PCMCIA Bridge */ +#define PCI_BRIDGE_NUBUS 0x6 /* PCI/NUBUS Bridge */ +#define PCI_BRIDGE_CARDBUS 0x7 /* PCI/CARDBUS Bridge */ +#define PCI_BRIDGE_RACE 0x8 /* RACE-way Bridge */ +#define PCI_BRIDGE_STPCI 0x9 /* Semi-transparent PCI/PCI Bridge */ +#define PCI_BRIDGE_IB 0xA /* InfiniBand/PCI host Bridge */ +#define PCI_BRIDGE_AS 0xB /* AS/PCI host Bridge */ +#define PCI_BRIDGE_OTHER 0x80 /* PCI/Other Bridge Device */ + +/* + * programming interface for Bridges class 0x6 (subclass 4) PCI-PCI bridge + */ +#define PCI_BRIDGE_PCI_IF_PCI2PCI 0x0 /* PCI-PCI bridge */ +#define PCI_BRIDGE_PCI_IF_SUBDECODE 0x1 /* Subtractive Decode */ + /* PCI/PCI bridge */ + +/* + * programming interface for Bridges class 0x6 (subclass 08) RACEway bridge + */ +#define PCI_BRIDGE_RACE_IF_TRANSPARENT 0x0 /* Transport mode */ +#define PCI_BRIDGE_RACE_IF_ENDPOINT 0x1 /* Endpoint mode */ + +/* + * programming interface for Bridges class 0x6 (subclass 09) + * Semi-transparent PCI-to-PCI bridge + */ +#define PCI_BRIDGE_STPCI_IF_PRIMARY 0x40 /* primary PCI side bus */ + /* facing system processor */ +#define PCI_BRIDGE_STPCI_IF_SECONDARY 0x80 /* secondary PCI side bus */ + /* facing system processor */ + +/* + * programming interface for Bridges class 0x6 (subclass 0B) AS bridge + */ +#define PCI_BRIDGE_AS_CUSTOM_INTFC 0x0 /* Custom interface */ +#define PCI_BRIDGE_AS_PORTAL_INTFC 0x1 /* ASI-SIG Portal Interface */ + +/* + * PCI Sub-class codes - base class 0x7 (communication devices) + */ +#define PCI_COMM_GENERIC_XT 0x0 /* XT Compatible Serial Controller */ +#define PCI_COMM_PARALLEL 0x1 /* Parallel Port Controller */ +#define PCI_COMM_MSC 0x2 /* Multiport Serial Controller */ +#define PCI_COMM_MODEM 0x3 /* Modem Controller */ +#define PCI_COMM_GPIB 0x4 /* GPIB Controller */ +#define PCI_COMM_SMARTCARD 0x5 /* Smart Card Controller */ +#define PCI_COMM_OTHER 0x80 /* Other Communications Controller */ + +/* + * Programming interfaces for class 0x7 / subclass 0x0 (Serial) + */ +#define PCI_COMM_SERIAL_IF_GENERIC 0x0 /* Generic XT-compat serial */ +#define PCI_COMM_SERIAL_IF_16450 0x1 /* 16450-compat serial ctrlr */ +#define PCI_COMM_SERIAL_IF_16550 0x2 /* 16550-compat serial ctrlr */ +#define PCI_COMM_SERIAL_IF_16650 0x3 /* 16650-compat serial ctrlr */ +#define PCI_COMM_SERIAL_IF_16750 0x4 /* 16750-compat serial ctrlr */ +#define PCI_COMM_SERIAL_IF_16850 0x5 /* 16850-compat serial ctrlr */ +#define PCI_COMM_SERIAL_IF_16950 0x6 /* 16950-compat serial ctrlr */ + +/* + * Programming interfaces for class 0x7 / subclass 0x1 (Parallel) + */ +#define PCI_COMM_PARALLEL_IF_GENERIC 0x0 /* Generic Parallel port */ +#define PCI_COMM_PARALLEL_IF_BIDIRECT 0x1 /* Bi-directional Parallel */ +#define PCI_COMM_PARALLEL_IF_ECP 0x2 /* ECP 1.X Parallel port */ +#define PCI_COMM_PARALLEL_IF_1284 0x3 /* IEEE 1284 Parallel port */ +#define PCI_COMM_PARALLEL_IF_1284_TARG 0xFE /* IEEE 1284 target device */ + +/* + * Programming interfaces for class 0x7 / subclass 0x3 (Modem) + */ +#define PCI_COMM_MODEM_IF_GENERIC 0x0 /* Generic Modem */ +#define PCI_COMM_MODEM_IF_HAYES_16450 0x1 /* Hayes 16450-compat Modem */ +#define PCI_COMM_MODEM_IF_HAYES_16550 0x2 /* Hayes 16550-compat Modem */ +#define PCI_COMM_MODEM_IF_HAYES_16650 0x3 /* Hayes 16650-compat Modem */ +#define PCI_COMM_MODEM_IF_HAYES_16750 0x4 /* Hayes 16750-compat Modem */ + +/* + * PCI Sub-class codes - base class 0x8 + */ +#define PCI_PERIPH_PIC 0x0 /* Generic PIC */ +#define PCI_PERIPH_DMA 0x1 /* Generic DMA Controller */ +#define PCI_PERIPH_TIMER 0x2 /* Generic System Timer Controller */ +#define PCI_PERIPH_RTC 0x3 /* Generic RTC Controller */ +#define PCI_PERIPH_HPC 0x4 /* Generic PCI Hot-Plug Controller */ +#define PCI_PERIPH_SD_HC 0x5 /* SD Host Controller */ +#define PCI_PERIPH_IOMMU 0x6 /* IOMMU */ +#define PCI_PERIPH_OTHER 0x80 /* Other System Peripheral */ + +/* + * Programming interfaces for class 0x8 / subclass 0x0 (interrupt controller) + */ +#define PCI_PERIPH_PIC_IF_GENERIC 0x0 /* Generic 8259 APIC */ +#define PCI_PERIPH_PIC_IF_ISA 0x1 /* ISA PIC */ +#define PCI_PERIPH_PIC_IF_EISA 0x2 /* EISA PIC */ +#define PCI_PERIPH_PIC_IF_IO_APIC 0x10 /* I/O APIC interrupt ctrlr */ +#define PCI_PERIPH_PIC_IF_IOX_APIC 0x20 /* I/O(x) APIC intr ctrlr */ + +/* + * Programming interfaces for class 0x8 / subclass 0x1 (DMA controller) + */ +#define PCI_PERIPH_DMA_IF_GENERIC 0x0 /* Generic 8237 DMA ctrlr */ +#define PCI_PERIPH_DMA_IF_ISA 0x1 /* ISA DMA ctrlr */ +#define PCI_PERIPH_DMA_IF_EISA 0x2 /* EISA DMA ctrlr */ + +/* + * Programming interfaces for class 0x8 / subclass 0x2 (timer) + */ +#define PCI_PERIPH_TIMER_IF_GENERIC 0x0 /* Generic 8254 system timer */ +#define PCI_PERIPH_TIMER_IF_ISA 0x1 /* ISA system timers */ +#define PCI_PERIPH_TIMER_IF_EISA 0x2 /* EISA system timers (two) */ +#define PCI_PERIPH_TIMER_IF_HPET 0x3 /* High Perf Event timer */ + +/* + * Programming interfaces for class 0x8 / subclass 0x3 (realtime clock) + */ +#define PCI_PERIPH_RTC_IF_GENERIC 0x0 /* Generic RTC controller */ +#define PCI_PERIPH_RTC_IF_ISA 0x1 /* ISA RTC controller */ + +/* + * PCI Sub-class codes - base class 0x9 + */ +#define PCI_INPUT_KEYBOARD 0x0 /* Keyboard Controller */ +#define PCI_INPUT_DIGITIZ 0x1 /* Digitizer (Pen) */ +#define PCI_INPUT_MOUSE 0x2 /* Mouse Controller */ +#define PCI_INPUT_SCANNER 0x3 /* Scanner Controller */ +#define PCI_INPUT_GAMEPORT 0x4 /* Gameport Controller */ +#define PCI_INPUT_OTHER 0x80 /* Other Input Controller */ + +/* + * Programming interfaces for class 0x9 / subclass 0x4 (Gameport controller) + */ +#define PCI_INPUT_GAMEPORT_IF_GENERIC 0x00 /* Generic controller */ +#define PCI_INPUT_GAMEPORT_IF_LEGACY 0x10 /* Legacy controller */ + +/* + * PCI Sub-class codes - base class 0xA + */ +#define PCI_DOCK_GENERIC 0x00 /* Generic Docking Station */ +#define PCI_DOCK_OTHER 0x80 /* Other Type of Docking Station */ + +/* + * PCI Sub-class codes - base class 0xB + */ +#define PCI_PROCESSOR_386 0x0 /* 386 */ +#define PCI_PROCESSOR_486 0x1 /* 486 */ +#define PCI_PROCESSOR_PENT 0x2 /* Pentium */ +#define PCI_PROCESSOR_ALPHA 0x10 /* Alpha */ +#define PCI_PROCESSOR_POWERPC 0x20 /* PowerPC */ +#define PCI_PROCESSOR_MIPS 0x30 /* MIPS */ +#define PCI_PROCESSOR_COPROC 0x40 /* Co-processor */ +#define PCI_PROCESSOR_OTHER 0x80 /* Other processors */ + +/* + * PCI Sub-class codes - base class 0xC (Serial Controllers) + */ +#define PCI_SERIAL_FIRE 0x0 /* FireWire (IEEE 1394) */ +#define PCI_SERIAL_ACCESS 0x1 /* ACCESS.bus */ +#define PCI_SERIAL_SSA 0x2 /* SSA */ +#define PCI_SERIAL_USB 0x3 /* Universal Serial Bus */ +#define PCI_SERIAL_FIBRE 0x4 /* Fibre Channel */ +#define PCI_SERIAL_SMBUS 0x5 /* System Management Bus */ +#define PCI_SERIAL_IB 0x6 /* InfiniBand */ +#define PCI_SERIAL_IPMI 0x7 /* IPMI */ +#define PCI_SERIAL_SERCOS 0x8 /* SERCOS Interface Std (IEC 61491) */ +#define PCI_SERIAL_CANBUS 0x9 /* CANbus */ +#define PCI_SERIAL_OTHER 0x80 /* Other Serial Bus Controllers */ + +/* + * Programming interfaces for class 0xC / subclass 0x0 (Firewire) + */ +#define PCI_SERIAL_FIRE_WIRE 0x00 /* IEEE 1394 (Firewire) */ +#define PCI_SERIAL_FIRE_1394_HCI 0x10 /* 1394 OpenHCI Host Cntrlr */ + +/* + * Programming interfaces for class 0xC / subclass 0x3 (USB controller) + */ +#define PCI_SERIAL_USB_IF_UHCI 0x00 /* UHCI Compliant */ +#define PCI_SERIAL_USB_IF_OHCI 0x10 /* OHCI Compliant */ +#define PCI_SERIAL_USB_IF_EHCI 0x20 /* EHCI Compliant */ +#define PCI_SERIAL_USB_IF_GENERIC 0x80 /* no specific HCD */ +#define PCI_SERIAL_USB_IF_DEVICE 0xFE /* not a HCD */ + +/* + * Programming interfaces for class 0xC / subclass 0x7 (IPMI controller) + */ +#define PCI_SERIAL_IPMI_IF_SMIC 0x0 /* SMIC Interface */ +#define PCI_SERIAL_IPMI_IF_KBD 0x1 /* Keyboard Ctrl Style Intfc */ +#define PCI_SERIAL_IPMI_IF_BTI 0x2 /* Block Transfer Interface */ + +/* + * PCI Sub-class codes - base class 0xD (Wireless controllers) + */ +#define PCI_WIRELESS_IRDA 0x0 /* iRDA Compatible Controller */ +#define PCI_WIRELESS_IR 0x1 /* Consumer IR Controller */ +#define PCI_WIRELESS_RF 0x10 /* RF Controller */ +#define PCI_WIRELESS_BLUETOOTH 0x11 /* Bluetooth Controller */ +#define PCI_WIRELESS_BROADBAND 0x12 /* Broadband Controller */ +#define PCI_WIRELESS_80211A 0x20 /* Ethernet 802.11a 5 GHz */ +#define PCI_WIRELESS_80211B 0x21 /* Ethernet 802.11b 2.4 GHz */ +#define PCI_WIRELESS_OTHER 0x80 /* Other Wireless Controllers */ + +/* + * Programming interfaces for class 0xD / subclass 0x1 (Consumer IR controller) + */ +#define PCI_WIRELESS_IR_CONSUMER 0x00 /* Consumer IR Controller */ +#define PCI_WIRELESS_IR_UWB_RC 0x10 /* UWB Radio Controller */ + +/* + * PCI Sub-class codes - base class 0xE (Intelligent I/O controllers) + */ +#define PCI_INTIO_MSG_FIFO 0x0 /* Message FIFO at off 40h */ +#define PCI_INTIO_I20 0x1 /* I20 Arch Spec 1.0 */ + +/* + * PCI Sub-class codes - base class 0xF (Satellite Communication controllers) + */ +#define PCI_SATELLITE_COMM_TV 0x01 /* TV */ +#define PCI_SATELLITE_COMM_AUDIO 0x02 /* Audio */ +#define PCI_SATELLITE_COMM_VOICE 0x03 /* Voice */ +#define PCI_SATELLITE_COMM_DATA 0x04 /* DATA */ +#define PCI_SATELLITE_COMM_OTHER 0x80 /* Other Satelite Comm Cntrlr */ + +/* + * PCI Sub-class codes - base class 0x10 (Encryption/Decryption controllers) + */ +#define PCI_CRYPT_NETWORK 0x00 /* Network and Computing */ +#define PCI_CRYPT_ENTERTAINMENT 0x10 /* Entertainment en/decrypt */ +#define PCI_CRYPT_OTHER 0x80 /* Other en/decryption ctrlrs */ + +/* + * PCI Sub-class codes - base class 0x11 (Signal Processing controllers) + */ +#define PCI_SIGNAL_DPIO 0x00 /* DPIO modules */ +#define PCI_SIGNAL_PERF_COUNTERS 0x01 /* Performance counters */ +#define PCI_SIGNAL_COMM_SYNC 0x10 /* Comm. synchronization plus */ + /* time and freq test ctrlr */ +#define PCI_SIGNAL_MANAGEMENT 0x20 /* Management card */ +#define PCI_SIGNAL_OTHER 0x80 /* DSP/DAP controller */ + +/* PCI header decode */ +#define PCI_HEADER_MULTI 0x80 /* multi-function device */ +#define PCI_HEADER_ZERO 0x00 /* type zero PCI header */ +#define PCI_HEADER_ONE 0x01 /* type one PCI header */ +#define PCI_HEADER_TWO 0x02 /* type two PCI header */ +#define PCI_HEADER_PPB PCI_HEADER_ONE /* type one PCI to PCI Bridge */ +#define PCI_HEADER_CARDBUS PCI_HEADER_TWO /* type one PCI header */ + +#define PCI_HEADER_TYPE_M 0x7f /* type mask for header */ + +/* + * Base register bit definitions. + */ +#define PCI_BASE_SPACE_M 0x1 /* memory space indicator */ +#define PCI_BASE_SPACE_IO 0x1 /* IO space */ +#define PCI_BASE_SPACE_MEM 0x0 /* memory space */ + +#define PCI_BASE_TYPE_MEM 0x0 /* 32-bit memory address */ +#define PCI_BASE_TYPE_LOW 0x2 /* less than 1Mb address */ +#define PCI_BASE_TYPE_ALL 0x4 /* 64-bit memory address */ +#define PCI_BASE_TYPE_RES 0x6 /* reserved */ + +#define PCI_BASE_TYPE_M 0x00000006 /* type indicator mask */ +#define PCI_BASE_PREF_M 0x00000008 /* prefetch mask */ +#define PCI_BASE_M_ADDR_M 0xfffffff0 /* memory address mask */ +#define PCI_BASE_M_ADDR64_M 0xfffffffffffffff0ULL /* 64bit mem addr mask */ +#define PCI_BASE_IO_ADDR_M 0xfffffffe /* I/O address mask */ + +#define PCI_BASE_ROM_ADDR_M 0xfffff800 /* ROM address mask */ +#define PCI_BASE_ROM_ENABLE 0x00000001 /* ROM decoder enable */ + +/* + * Capabilities linked list entry offsets + */ +#define PCI_CAP_ID 0x0 /* capability identifier, 1 byte */ +#define PCI_CAP_NEXT_PTR 0x1 /* next entry pointer, 1 byte */ +#define PCI_CAP_ID_REGS_OFF 0x2 /* cap id register offset */ +#define PCI_CAP_MAX_PTR 0x30 /* maximum number of cap pointers */ +#define PCI_CAP_PTR_OFF 0x40 /* minimum cap pointer offset */ +#define PCI_CAP_PTR_MASK 0xFC /* mask for capability pointer */ + +/* + * Capability identifier values + */ +#define PCI_CAP_ID_PM 0x1 /* power management entry */ +#define PCI_CAP_ID_AGP 0x2 /* AGP supported */ +#define PCI_CAP_ID_VPD 0x3 /* VPD supported */ +#define PCI_CAP_ID_SLOT_ID 0x4 /* Slot Identification supported */ +#define PCI_CAP_ID_MSI 0x5 /* MSI supported */ +#define PCI_CAP_ID_cPCI_HS 0x6 /* CompactPCI Host Swap supported */ +#define PCI_CAP_ID_PCIX 0x7 /* PCI-X supported */ +#define PCI_CAP_ID_HT 0x8 /* HyperTransport supported */ +#define PCI_CAP_ID_VS 0x9 /* Vendor Specific */ +#define PCI_CAP_ID_DEBUG_PORT 0xA /* Debug Port supported */ +#define PCI_CAP_ID_cPCI_CRC 0xB /* CompactPCI central resource ctrl */ +#define PCI_CAP_ID_PCI_HOTPLUG 0xC /* PCI Hot Plug (SHPC) supported */ +#define PCI_CAP_ID_P2P_SUBSYS 0xD /* PCI bridge Sub-system ID */ +#define PCI_CAP_ID_AGP_8X 0xE /* AGP 8X supported */ +#define PCI_CAP_ID_SECURE_DEV 0xF /* Secure Device supported */ +#define PCI_CAP_ID_PCI_E 0x10 /* PCI Express supported */ +#define PCI_CAP_ID_MSI_X 0x11 /* MSI-X supported */ +#define PCI_CAP_ID_SATA 0x12 /* SATA Data/Index Config supported */ +#define PCI_CAP_ID_FLR 0x13 /* Function Level Reset supported */ +#define PCI_CAP_ID_EA 0x14 /* Enhanced Allocation */ +#define PCI_CAP_ID_FPB 0x15 /* Flattening Portal Bridge */ + +/* + * Capability next entry pointer values + */ +#define PCI_CAP_NEXT_PTR_NULL 0x0 /* no more entries in the list */ + +/* + * PCI power management (PM) capability entry offsets + */ +#define PCI_PMCAP 0x2 /* PM capabilities, 2 bytes */ +#define PCI_PMCSR 0x4 /* PM control/status reg, 2 bytes */ +#define PCI_PMCSR_BSE 0x6 /* PCI-PCI bridge extensions, 1 byte */ +#define PCI_PMDATA 0x7 /* PM data, 1 byte */ + +/* + * PM capabilities values - 2 bytes + */ +#define PCI_PMCAP_VER_1_0 0x1 /* PCI PM spec 1.0 */ +#define PCI_PMCAP_VER_1_1 0x2 /* PCI PM spec 1.1 */ +#define PCI_PMCAP_VER_MASK 0x7 /* version mask */ +#define PCI_PMCAP_PME_CLOCK 0x8 /* needs PCI clock for PME */ +#define PCI_PMCAP_DSI 0x20 /* needs device specific init */ +#define PCI_PMCAP_AUX_CUR_SELF 0x0 /* 0 aux current - self powered */ +#define PCI_PMCAP_AUX_CUR_55mA 0x40 /* 55 mA aux current */ +#define PCI_PMCAP_AUX_CUR_100mA 0x80 /* 100 mA aux current */ +#define PCI_PMCAP_AUX_CUR_160mA 0xc0 /* 160 mA aux current */ +#define PCI_PMCAP_AUX_CUR_220mA 0x100 /* 220 mA aux current */ +#define PCI_PMCAP_AUX_CUR_270mA 0x140 /* 270 mA aux current */ +#define PCI_PMCAP_AUX_CUR_320mA 0x180 /* 320 mA aux current */ +#define PCI_PMCAP_AUX_CUR_375mA 0x1c0 /* 375 mA aux current */ +#define PCI_PMCAP_AUX_CUR_MASK 0x1c0 /* 3.3Vaux aux current needs */ +#define PCI_PMCAP_D1 0x200 /* D1 state supported */ +#define PCI_PMCAP_D2 0x400 /* D2 state supported */ +#define PCI_PMCAP_D0_PME 0x800 /* PME from D0 */ +#define PCI_PMCAP_D1_PME 0x1000 /* PME from D1 */ +#define PCI_PMCAP_D2_PME 0x2000 /* PME from D2 */ +#define PCI_PMCAP_D3HOT_PME 0x4000 /* PME from D3hot */ +#define PCI_PMCAP_D3COLD_PME 0x8000 /* PME from D3cold */ +#define PCI_PMCAP_PME_MASK 0xf800 /* PME support mask */ + +/* + * PM control/status values - 2 bytes + */ +#define PCI_PMCSR_D0 0x0 /* power state D0 */ +#define PCI_PMCSR_D1 0x1 /* power state D1 */ +#define PCI_PMCSR_D2 0x2 /* power state D2 */ +#define PCI_PMCSR_D3HOT 0x3 /* power state D3hot */ +#define PCI_PMCSR_STATE_MASK 0x3 /* power state mask */ +#define PCI_PMCSR_PME_EN 0x100 /* enable PME assertion */ +#define PCI_PMCSR_DSEL_D0_PWR_C 0x0 /* D0 power consumed */ +#define PCI_PMCSR_DSEL_D1_PWR_C 0x200 /* D1 power consumed */ +#define PCI_PMCSR_DSEL_D2_PWR_C 0x400 /* D2 power consumed */ +#define PCI_PMCSR_DSEL_D3_PWR_C 0x600 /* D3 power consumed */ +#define PCI_PMCSR_DSEL_D0_PWR_D 0x800 /* D0 power dissipated */ +#define PCI_PMCSR_DSEL_D1_PWR_D 0xa00 /* D1 power dissipated */ +#define PCI_PMCSR_DSEL_D2_PWR_D 0xc00 /* D2 power dissipated */ +#define PCI_PMCSR_DSEL_D3_PWR_D 0xe00 /* D3 power dissipated */ +#define PCI_PMCSR_DSEL_COM_C 0x1000 /* common power consumption */ +#define PCI_PMCSR_DSEL_MASK 0x1e00 /* data select mask */ +#define PCI_PMCSR_DSCL_UNKNOWN 0x0 /* data scale unknown */ +#define PCI_PMCSR_DSCL_1_BY_10 0x2000 /* data scale 0.1x */ +#define PCI_PMCSR_DSCL_1_BY_100 0x4000 /* data scale 0.01x */ +#define PCI_PMCSR_DSCL_1_BY_1000 0x6000 /* data scale 0.001x */ +#define PCI_PMCSR_DSCL_MASK 0x6000 /* data scale mask */ +#define PCI_PMCSR_PME_STAT 0x8000 /* PME status */ + +/* + * PM PMCSR PCI to PCI bridge support extension values - 1 byte + */ +#define PCI_PMCSR_BSE_B2_B3 0x40 /* bridge D3hot -> secondary B2 */ +#define PCI_PMCSR_BSE_BPCC_EN 0x80 /* bus power/clock control enabled */ + +/* + * PCI-X capability related definitions + */ +#define PCI_PCIX_COMMAND 0x2 /* Command register offset */ +#define PCI_PCIX_STATUS 0x4 /* Status register offset */ +#define PCI_PCIX_ECC_STATUS 0x8 /* ECC Status register offset */ +#define PCI_PCIX_ECC_FST_AD 0xC /* ECC First address register offset */ +#define PCI_PCIX_ECC_SEC_AD 0x10 /* ECC Second address register offset */ +#define PCI_PCIX_ECC_ATTR 0x14 /* ECC Attribute register offset */ + +/* + * PCI-X bridge capability related definitions + */ +#define PCI_PCIX_SEC_STATUS 0x2 /* Secondary Status offset */ +#define PCI_PCIX_SEC_STATUS_SCD 0x4 /* Split Completion Discarded */ +#define PCI_PCIX_SEC_STATUS_USC 0x8 /* Unexpected Split Complete */ +#define PCI_PCIX_SEC_STATUS_SCO 0x10 /* Split Completion Overrun */ +#define PCI_PCIX_SEC_STATUS_SRD 0x20 /* Split Completion Delayed */ +#define PCI_PCIX_SEC_STATUS_ERR_MASK 0x3C + +#define PCI_PCIX_BDG_STATUS 0x4 /* Bridge Status offset */ +#define PCI_PCIX_BDG_STATUS_USC 0x80000 +#define PCI_PCIX_BDG_STATUS_SCO 0x100000 +#define PCI_PCIX_BDG_STATUS_SRD 0x200000 +#define PCI_PCIX_BDG_STATUS_ERR_MASK 0x380000 + +#define PCI_PCIX_UP_SPL_CTL 0x8 /* Upstream split ctrl reg offset */ +#define PCI_PCIX_DOWN_SPL_CTL 0xC /* Downstream split ctrl reg offset */ +#define PCI_PCIX_BDG_ECC_STATUS 0x10 /* ECC Status register offset */ +#define PCI_PCIX_BDG_ECC_FST_AD 0x14 /* ECC First address register offset */ +#define PCI_PCIX_BDG_ECC_SEC_AD 0x18 /* ECC Second address register offset */ +#define PCI_PCIX_BDG_ECC_ATTR 0x1C /* ECC Attribute register offset */ + +/* + * PCIX capabilities values + */ +#define PCI_PCIX_VER_MASK 0x3000 /* Bits 12 and 13 */ +#define PCI_PCIX_VER_0 0x0000 /* PCIX cap list item version 0 */ +#define PCI_PCIX_VER_1 0x1000 /* PCIX cap list item version 1 */ +#define PCI_PCIX_VER_2 0x2000 /* PCIX cap list item version 2 */ + +#define PCI_PCIX_SPL_DSCD 0x40000 /* Split Completion Discarded */ +#define PCI_PCIX_UNEX_SPL 0x80000 /* Unexpected Split Completion */ +#define PCI_PCIX_RX_SPL_MSG 0x20000000 /* Recieved Spl Comp Error Message */ + +#define PCI_PCIX_ECC_SEL 0x1 /* Secondary ECC register select */ +#define PCI_PCIX_ECC_EP 0x2 /* Error Present on other side */ +#define PCI_PCIX_ECC_S_CE 0x4 /* Addl Correctable ECC Error */ +#define PCI_PCIX_ECC_S_UE 0x8 /* Addl Uncorrectable ECC Error */ +#define PCI_PCIX_ECC_PHASE 0x70 /* ECC Error Phase */ +#define PCI_PCIX_ECC_CORR 0x80 /* ECC Error Corrected */ +#define PCI_PCIX_ECC_SYN 0xff00 /* ECC Error Syndrome */ +#define PCI_PCIX_ECC_FST_CMD 0xf0000 /* ECC Error First Command */ +#define PCI_PCIX_ECC_SEC_CMD 0xf00000 /* ECC Error Second Command */ +#define PCI_PCIX_ECC_UP_ATTR 0xf000000 /* ECC Error Upper Attributes */ + +/* + * PCIX ECC Phase Values + */ +#define PCI_PCIX_ECC_PHASE_NOERR 0x0 +#define PCI_PCIX_ECC_PHASE_FADDR 0x1 +#define PCI_PCIX_ECC_PHASE_SADDR 0x2 +#define PCI_PCIX_ECC_PHASE_ATTR 0x3 +#define PCI_PCIX_ECC_PHASE_DATA32 0x4 +#define PCI_PCIX_ECC_PHASE_DATA64 0x5 + +/* + * PCI-X Command Encoding + */ +#define PCI_PCIX_CMD_INTR 0x0 +#define PCI_PCIX_CMD_SPEC 0x1 +#define PCI_PCIX_CMD_IORD 0x2 +#define PCI_PCIX_CMD_IOWR 0x3 +#define PCI_PCIX_CMD_DEVID 0x5 +#define PCI_PCIX_CMD_MEMRD_DW 0x6 +#define PCI_PCIX_CMD_MEMWR 0x7 +#define PCI_PCIX_CMD_MEMRD_BL 0x8 +#define PCI_PCIX_CMD_MEMWR_BL 0x9 +#define PCI_PCIX_CMD_CFRD 0xA +#define PCI_PCIX_CMD_CFWR 0xB +#define PCI_PCIX_CMD_SPL 0xC +#define PCI_PCIX_CMD_DADR 0xD +#define PCI_PCIX_CMD_MEMRDBL 0xE +#define PCI_PCIX_CMD_MEMWRBL 0xF + +#if defined(_BIT_FIELDS_LTOH) +typedef struct pcix_attr { + uint32_t lbc :8, + rid :16, + tag :5, + ro :1, + ns :1, + r :1; +} pcix_attr_t; +#elif defined(_BIT_FIELDS_HTOL) +typedef struct pcix_attr { + uint32_t r :1, + ns :1, + ro :1, + tag :5, + rid :16, + lbc :8; +} pcix_attr_t; +#else +#error "bit field not defined" +#endif + +#define PCI_PCIX_BSS_SPL_DSCD 0x4 /* Secondary split comp discarded */ +#define PCI_PCIX_BSS_UNEX_SPL 0x8 /* Secondary unexpected split comp */ +#define PCI_PCIX_BSS_SPL_OR 0x10 /* Secondary split comp overrun */ +#define PCI_PCIX_BSS_SPL_DLY 0x20 /* Secondary split comp delayed */ + +/* + * PCI Hotplug capability entry offsets + * + * SHPC based PCI hotplug controller registers accessed via the DWORD + * select and DATA registers in PCI configuration space relative to the + * PCI HP capibility pointer. + */ +#define PCI_HP_DWORD_SELECT_OFF 0x2 +#define PCI_HP_DWORD_DATA_OFF 0x4 + +#define PCI_HP_BASE_OFFSET_REG 0x00 +#define PCI_HP_SLOTS_AVAIL_I_REG 0x01 +#define PCI_HP_SLOTS_AVAIL_II_REG 0x02 +#define PCI_HP_SLOT_CONFIGURATION_REG 0x03 +#define PCI_HP_PROF_IF_SBCR_REG 0x04 +#define PCI_HP_COMMAND_STATUS_REG 0x05 +#define PCI_HP_IRQ_LOCATOR_REG 0x06 +#define PCI_HP_SERR_LOCATOR_REG 0x07 +#define PCI_HP_CTRL_SERR_INT_REG 0x08 +#define PCI_HP_LOGICAL_SLOT_REGS 0x09 +#define PCI_HP_VENDOR_SPECIFIC 0x28 + +/* Definitions used with the PCI_HP_SLOTS_AVAIL_I_REG register */ +#define PCI_HP_AVAIL_33MHZ_CONV_SPEED_SHIFT 0 +#define PCI_HP_AVAIL_66MHZ_PCIX_SPEED_SHIFT 8 +#define PCI_HP_AVAIL_100MHZ_PCIX_SPEED_SHIFT 16 +#define PCI_HP_AVAIL_133MHZ_PCIX_SPEED_SHIFT 24 +#define PCI_HP_AVAIL_SPEED_MASK 0x1F + +/* Definitions used with the PCI_HP_SLOTS_AVAIL_II_REG register */ +#define PCI_HP_AVAIL_66MHZ_CONV_SPEED_SHIFT 0 + +/* Register bits used with the PCI_HP_PROF_IF_SBCR_REG register */ +#define PCI_HP_SBCR_33MHZ_CONV_SPEED 0x0 +#define PCI_HP_SBCR_66MHZ_CONV_SPEED 0x1 +#define PCI_HP_SBCR_66MHZ_PCIX_SPEED 0x2 +#define PCI_HP_SBCR_100MHZ_PCIX_SPEED 0x3 +#define PCI_HP_SBCR_133MHZ_PCIX_SPEED 0x4 +#define PCI_HP_SBCR_SPEED_MASK 0x7 + +/* Register bits used with the PCI_HP_COMMAND_STATUS_REG register */ +#define PCI_HP_COMM_STS_ERR_INVALID_SPEED 0x80000 +#define PCI_HP_COMM_STS_ERR_INVALID_COMMAND 0x40000 +#define PCI_HP_COMM_STS_ERR_MRL_OPEN 0x20000 +#define PCI_HP_COMM_STS_ERR_MASK 0xe0000 +#define PCI_HP_COMM_STS_CTRL_BUSY 0x10000 +#define PCI_HP_COMM_STS_SET_SPEED 0x40 + +/* Register bits used with the PCI_HP_CTRL_SERR_INT_REG register */ +#define PCI_HP_SERR_INT_GLOBAL_IRQ_MASK 0x1 +#define PCI_HP_SERR_INT_GLOBAL_SERR_MASK 0x2 +#define PCI_HP_SERR_INT_CMD_COMPLETE_MASK 0x4 +#define PCI_HP_SERR_INT_ARBITER_SERR_MASK 0x8 +#define PCI_HP_SERR_INT_CMD_COMPLETE_IRQ 0x10000 +#define PCI_HP_SERR_INT_ARBITER_IRQ 0x20000 +#define PCI_HP_SERR_INT_MASK_ALL 0xf + +/* Register bits used with the PCI_HP_LOGICAL_SLOT_REGS register */ +#define PCI_HP_SLOT_POWER_ONLY 0x1 +#define PCI_HP_SLOT_ENABLED 0x2 +#define PCI_HP_SLOT_DISABLED 0x3 +#define PCI_HP_SLOT_STATE_MASK 0x3 +#define PCI_HP_SLOT_MRL_STATE_MASK 0x100 +#define PCI_HP_SLOT_66MHZ_CONV_CAPABLE 0x200 +#define PCI_HP_SLOT_CARD_EMPTY_MASK 0xc00 +#define PCI_HP_SLOT_66MHZ_PCIX_CAPABLE 0x1000 +#define PCI_HP_SLOT_100MHZ_PCIX_CAPABLE 0x2000 +#define PCI_HP_SLOT_133MHZ_PCIX_CAPABLE 0x3000 +#define PCI_HP_SLOT_PCIX_CAPABLE_MASK 0x3000 +#define PCI_HP_SLOT_PCIX_CAPABLE_SHIFT 12 +#define PCI_HP_SLOT_PRESENCE_DETECTED 0x10000 +#define PCI_HP_SLOT_ISO_PWR_DETECTED 0x20000 +#define PCI_HP_SLOT_ATTN_DETECTED 0x40000 +#define PCI_HP_SLOT_MRL_DETECTED 0x80000 +#define PCI_HP_SLOT_POWER_DETECTED 0x100000 +#define PCI_HP_SLOT_PRESENCE_MASK 0x1000000 +#define PCI_HP_SLOT_ISO_PWR_MASK 0x2000000 +#define PCI_HP_SLOT_ATTN_MASK 0x4000000 +#define PCI_HP_SLOT_MRL_MASK 0x8000000 +#define PCI_HP_SLOT_POWER_MASK 0x10000000 +#define PCI_HP_SLOT_MRL_SERR_MASK 0x20000000 +#define PCI_HP_SLOT_POWER_SERR_MASK 0x40000000 +#define PCI_HP_SLOT_MASK_ALL 0x5f000000 + +/* Register bits used with the PCI_HP_IRQ_LOCATOR_REG register */ +#define PCI_HP_IRQ_CMD_COMPLETE 0x1 +#define PCI_HP_IRQ_SLOT_N_PENDING 0x2 + +/* Register bits used with the PCI_HP_SERR_LOCATOR_REG register */ +#define PCI_HP_IRQ_SERR_ARBITER_PENDING 0x1 +#define PCI_HP_IRQ_SERR_SLOT_N_PENDING 0x2 + +/* Register bits used with the PCI_HP_SLOT_CONFIGURATION_REG register */ +#define PCI_HP_SLOT_CONFIG_MRL_SENSOR 0x40000000 +#define PCI_HP_SLOT_CONFIG_ATTN_BUTTON 0x80000000 +#define PCI_HP_SLOT_CONFIG_PHY_SLOT_NUM_SHIFT 16 +#define PCI_HP_SLOT_CONFIG_PHY_SLOT_NUM_MASK 0x3FF + +/* + * PCI Message Signalled Interrupts (MSI) capability entry offsets for 32-bit + */ +#define PCI_MSI_CTRL 0x02 /* MSI control register, 2 bytes */ +#define PCI_MSI_ADDR_OFFSET 0x04 /* MSI 32-bit msg address, 4 bytes */ +#define PCI_MSI_32BIT_DATA 0x08 /* MSI 32-bit msg data, 2 bytes */ +#define PCI_MSI_32BIT_EXTDATA 0x0A /* MSI 32-bit msg ext data, 2 bytes */ +#define PCI_MSI_32BIT_MASK 0x0C /* MSI 32-bit mask bits, 4 bytes */ +#define PCI_MSI_32BIT_PENDING 0x10 /* MSI 32-bit pending bits, 4 bytes */ + +/* + * PCI Message Signalled Interrupts (MSI) capability entry offsets for 64-bit + */ +#define PCI_MSI_64BIT_ADDR 0x08 /* MSI 64-bit upper address, 4 bytes */ +#define PCI_MSI_64BIT_DATA 0x0C /* MSI 64-bit msg data, 2 bytes */ +#define PCI_MSI_64BIT_EXTDATA 0x0E /* MSI 64-bit msg ext data, 2 bytes */ +#define PCI_MSI_64BIT_MASKBITS 0x10 /* MSI 64-bit mask bits, 4 bytes */ +#define PCI_MSI_64BIT_PENDING 0x14 /* MSI 64-bit pending bits, 4 bytes */ + +/* + * PCI Message Signalled Interrupts (MSI) capability masks and shifts + */ +#define PCI_MSI_ENABLE_BIT 0x0001 /* MSI enable mask in MSI ctrl reg */ +#define PCI_MSI_MMC_MASK 0x000E /* MMC mask in MSI ctrl reg */ +#define PCI_MSI_MMC_SHIFT 0x1 /* Shift for MMC bits */ +#define PCI_MSI_MME_MASK 0x0070 /* MME mask in MSI ctrl reg */ +#define PCI_MSI_MME_SHIFT 0x4 /* Shift for MME bits */ +#define PCI_MSI_64BIT_MASK 0x0080 /* 64bit support mask in MSI ctrl reg */ +#define PCI_MSI_PVM_MASK 0x0100 /* PVM support mask in MSI ctrl reg */ +#define PCI_MSI_EMD_MASK 0x0200 /* EMD Capable Mask */ +#define PCI_MSI_EMD_ENABLE 0x0400 /* EMD Enable bit */ + +/* + * PCI Extended Message Signalled Interrupts (MSI-X) capability entry offsets + */ +#define PCI_MSIX_CTRL 0x02 /* MSI-X control register, 2 bytes */ +#define PCI_MSIX_TBL_OFFSET 0x04 /* MSI-X table offset, 4 bytes */ +#define PCI_MSIX_TBL_BIR_MASK 0x0007 /* MSI-X table BIR mask */ +#define PCI_MSIX_PBA_OFFSET 0x08 /* MSI-X pending bit array, 4 bytes */ +#define PCI_MSIX_PBA_BIR_MASK 0x0007 /* MSI-X PBA BIR mask */ + +#define PCI_MSIX_TBL_SIZE_MASK 0x07FF /* table size mask in MSI-X ctrl reg */ +#define PCI_MSIX_FUNCTION_MASK 0x4000 /* function mask in MSI-X ctrl reg */ +#define PCI_MSIX_ENABLE_BIT 0x8000 /* MSI-X enable mask in MSI-X ctl reg */ + +#define PCI_MSIX_LOWER_ADDR_OFFSET 0 /* MSI-X lower addr offset */ +#define PCI_MSIX_UPPER_ADDR_OFFSET 4 /* MSI-X upper addr offset */ +#define PCI_MSIX_DATA_OFFSET 8 /* MSI-X data offset */ +#define PCI_MSIX_VECTOR_CTRL_OFFSET 12 /* MSI-X vector ctrl offset */ +#define PCI_MSIX_VECTOR_SIZE 16 /* MSI-X size of each vector */ + +/* + * PCI Message Signalled Interrupts: other interesting constants + */ +#define PCI_MSI_MAX_INTRS 32 /* maximum MSI interrupts supported */ +#define PCI_MSIX_MAX_INTRS 2048 /* maximum MSI-X interrupts supported */ + +/* + * PCI Slot Id Capabilities, 2 bytes + */ +/* Byte 1: Expansion Slot Register (ESR), Byte 2: Chassis Number Register */ +#define PCI_CAPSLOT_ESR_NSLOTS_MASK 0x1F /* Number of slots mask */ +#define PCI_CAPSLOT_ESR_FIC 0x20 /* First In Chassis bit */ +#define PCI_CAPSLOT_ESR_FIC_MASK 0x01 /* First In Chassis mask */ +#define PCI_CAPSLOT_ESR_FIC_SHIFT 5 /* First In Chassis shift */ +#define PCI_CAPSLOT_FIC(esr_reg) ((esr_reg) & PCI_CAPSLOT_ESR_FIC) +#define PCI_CAPSLOT_NSLOTS(esr_reg) ((esr_reg) & \ + PCI_CAPSLOT_ESR_NSLOTS_MASK) + +/* + * HyperTransport Capabilities; each HT cap uses the same PCI cap id of + * PCI_CAP_ID_HT. The header's upper 16-bits (command reg) contains an HT + * cap type reg at bits [15:11]. For Slave/Pri Interface and Host/Sec + * Interface types, only bits [15:13] are used. + */ +#define PCI_HTCAP_TYPE_MASK 0xF800 +#define PCI_HTCAP_TYPE_SLHOST_MASK 0xE000 /* SLPRI and HOSTSEC types */ +#define PCI_HTCAP_TYPE_SHIFT 11 + +#define PCI_HTCAP_SLPRI_ID 0x00 +#define PCI_HTCAP_HOSTSEC_ID 0x04 +#define PCI_HTCAP_SWITCH_ID 0x08 +#define PCI_HTCAP_INTCONF_ID 0x10 +#define PCI_HTCAP_REVID_ID 0x11 +#define PCI_HTCAP_UNITID_CLUMP_ID 0x12 +#define PCI_HTCAP_ECFG_ID 0x13 +#define PCI_HTCAP_ADDRMAP_ID 0x14 +#define PCI_HTCAP_MSIMAP_ID 0x15 +#define PCI_HTCAP_DIRROUTE_ID 0x16 +#define PCI_HTCAP_VCSET_ID 0x17 +#define PCI_HTCAP_RETRYMODE_ID 0x18 +#define PCI_HTCAP_X86ENC_ID 0x19 +#define PCI_HTCAP_GEN3_ID 0x1A +#define PCI_HTCAP_FUNCEXT_ID 0x1B +#define PCI_HTCAP_PM_ID 0x1C + +#define PCI_HTCAP_SLPRI_TYPE /* 0x0000 */ \ + (PCI_HTCAP_SLPRI_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_HOSTSEC_TYPE /* 0x2000 */ \ + (PCI_HTCAP_HOSTSEC_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_SWITCH_TYPE /* 0x4000 */ \ + (PCI_HTCAP_SWITCH_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_INTCONF_TYPE /* 0x8000 */ \ + (PCI_HTCAP_INTCONF_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_REVID_TYPE /* 0x8800 */ \ + (PCI_HTCAP_REVID_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_UNITID_CLUMP_TYPE /* 0x9000 */ \ + (PCI_HTCAP_UNITID_CLUMP_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_ECFG_TYPE /* 0x9800 */ \ + (PCI_HTCAP_ECFG_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_ADDRMAP_TYPE /* 0xA000 */ \ + (PCI_HTCAP_ADDRMAP_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_MSIMAP_TYPE /* 0xA800 */ \ + (PCI_HTCAP_MSIMAP_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_DIRROUTE_TYPE /* 0xB000 */ \ + (PCI_HTCAP_DIRROUTE_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_VCSET_TYPE /* 0xB800 */ \ + (PCI_HTCAP_VCSET_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_RETRYMODE_TYPE /* 0xC000 */ \ + (PCI_HTCAP_RETRYMODE_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_X86ENC_TYPE /* 0xC800 */ \ + (PCI_HTCAP_X86ENC_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_GEN3_TYPE /* 0xD000 */ \ + (PCI_HTCAP_GEN3_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_FUNCEXT_TYPE /* 0xD800 */ \ + (PCI_HTCAP_FUNCEXT_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_PM_TYPE /* 0xE000 */ \ + (PCI_HTCAP_PM_ID << PCI_HTCAP_TYPE_SHIFT) + +#define PCI_HTCAP_MSIMAP_ENABLE 0x0001 +#define PCI_HTCAP_MSIMAP_ENABLE_MASK 0x0001 + +#define PCI_HTCAP_ADDRMAP_MAPTYPE_MASK 0x600 +#define PCI_HTCAP_ADDRMAP_MAPTYPE_SHIFT 9 +#define PCI_HTCAP_ADDRMAP_NUMMAP_MASK 0xF +#define PCI_HTCAP_ADDRMAP_40BIT_ID 0x0 +#define PCI_HTCAP_ADDRMAP_64BIT_ID 0x1 + +#define PCI_HTCAP_FUNCEXT_LEN_MASK 0xFF + +/* + * PCI Bridge Subsystem Capability (PCI_CAP_ID_P2P_SUBSYS) + */ +#define PCI_SUBSYSCAP_SUBVID 0x4 +#define PCI_SUBSYSCAP_SUBSYS 0x6 + +/* + * other interesting PCI constants + */ +#define PCI_BASE_NUM 6 /* num of base regs in configuration header */ +#define PCI_BAR_SZ_32 4 /* size of 32 bit base addr reg in bytes */ +#define PCI_BAR_SZ_64 8 /* size of 64 bit base addr reg in bytes */ +#define PCI_BASE_SIZE 4 /* size of base reg in bytes */ +#define PCI_CONF_HDR_SIZE 256 /* configuration header size */ +#define PCI_MAX_BUS_NUM 256 /* Maximum PCI buses allowed */ +#define PCI_MAX_DEVICES 32 /* Max PCI devices allowed */ +#define PCI_MAX_FUNCTIONS 8 /* Max PCI functions allowed */ +#define PCI_MAX_CHILDREN PCI_MAX_DEVICES * PCI_MAX_FUNCTIONS +#define PCI_CLK_33MHZ (33 * 1000 * 1000) /* 33MHz clock speed */ +#define PCI_CLK_66MHZ (66 * 1000 * 1000) /* 66MHz clock speed */ +#define PCI_CLK_133MHZ (133 * 1000 * 1000) /* 133MHz clock speed */ + +/* + * pci bus range definition + */ +typedef struct pci_bus_range { + uint32_t lo; + uint32_t hi; +} pci_bus_range_t; + +/* + * The following typedef is used to represent an entry in the "ranges" + * property of a pci hostbridge device node. + */ +typedef struct pci_ranges { + uint32_t child_high; + uint32_t child_mid; + uint32_t child_low; + uint32_t parent_high; + uint32_t parent_low; + uint32_t size_high; + uint32_t size_low; +} pci_ranges_t; + +/* + * The following typedef is used to represent an entry in the "ranges" + * property of a pci-pci bridge device node. + */ +typedef struct { + uint32_t child_high; + uint32_t child_mid; + uint32_t child_low; + uint32_t parent_high; + uint32_t parent_mid; + uint32_t parent_low; + uint32_t size_high; + uint32_t size_low; +} ppb_ranges_t; + +/* + * This structure represents one entry of the 1275 "reg" property and + * "assigned-addresses" property for a PCI node. For the "reg" property, it + * may be one of an arbitrary length array for devices with multiple address + * windows. For the "assigned-addresses" property, it denotes an assigned + * physical address on the PCI bus. It may be one entry of the six entries + * for devices with multiple base registers. + * + * The physical address format is: + * + * Bit#: 33222222 22221111 11111100 00000000 + * 10987654 32109876 54321098 76543210 + * + * pci_phys_hi cell: npt000ss bbbbbbbb dddddfff rrrrrrrr + * pci_phys_mid cell: hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh + * pci_phys_low cell: llllllll llllllll llllllll llllllll + * + * n is 0 if the address is relocatable, 1 otherwise + * p is 1 if the addressable region is "prefetchable", 0 otherwise + * t is 1 if the address is aliased (for non-relocatable I/O), below + * 1MB (for mem), or below 64 KB (for relocatable I/O). + * ss is the type code, denoting which address space + * bbbbbbbb is the 8-bit bus number + * ddddd is the 5-bit device number + * fff is the 3-bit function number + * rrrrrrrr is the 8-bit register number + * should be zero for non-relocatable, when ss is 01, or 10 + * hh...hhh is the 32-bit unsigned number + * ll...lll is the 32-bit unsigned number + * + * The physical size format is: + * + * pci_size_hi cell: hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh + * pci_size_low cell: llllllll llllllll llllllll llllllll + * + * hh...hhh is the 32-bit unsigned number + * ll...lll is the 32-bit unsigned number + */ +struct pci_phys_spec { + uint_t pci_phys_hi; /* child's address, hi word */ + uint_t pci_phys_mid; /* child's address, middle word */ + uint_t pci_phys_low; /* child's address, low word */ + uint_t pci_size_hi; /* high word of size field */ + uint_t pci_size_low; /* low word of size field */ +}; + +typedef struct pci_phys_spec pci_regspec_t; + +/* + * PCI masks for pci_phy_hi of PCI 1275 address cell. + */ +#define PCI_REG_REG_M 0xff /* register mask */ +#define PCI_REG_FUNC_M 0x700 /* function mask */ +#define PCI_REG_DEV_M 0xf800 /* device mask */ +#define PCI_REG_BUS_M 0xff0000 /* bus number mask */ +#define PCI_REG_ADDR_M 0x3000000 /* address space mask */ +#define PCI_REG_ALIAS_M 0x20000000 /* aliased bit mask */ +#define PCI_REG_PF_M 0x40000000 /* prefetch bit mask */ +#define PCI_REG_REL_M 0x80000000 /* relocation bit mask */ +#define PCI_REG_BDFR_M 0xffffff /* bus, dev, func, reg mask */ +#define PCI_REG_EXTREG_M 0xF0000000 /* extended config bits mask */ + +#define PCI_REG_FUNC_SHIFT 8 /* Offset of function bits */ +#define PCI_REG_DEV_SHIFT 11 /* Offset of device bits */ +#define PCI_REG_BUS_SHIFT 16 /* Offset of bus bits */ +#define PCI_REG_ADDR_SHIFT 24 /* Offset of address bits */ +#define PCI_REG_EXTREG_SHIFT 28 /* Offset of ext. config bits */ + +#define PCI_REG_REG_G(x) ((x) & PCI_REG_REG_M) +#define PCI_REG_FUNC_G(x) (((x) & PCI_REG_FUNC_M) >> PCI_REG_FUNC_SHIFT) +#define PCI_REG_DEV_G(x) (((x) & PCI_REG_DEV_M) >> PCI_REG_DEV_SHIFT) +#define PCI_REG_BUS_G(x) (((x) & PCI_REG_BUS_M) >> PCI_REG_BUS_SHIFT) +#define PCI_REG_ADDR_G(x) (((x) & PCI_REG_ADDR_M) >> PCI_REG_ADDR_SHIFT) +#define PCI_REG_BDFR_G(x) ((x) & PCI_REG_BDFR_M) + +#define PCI_REG_MAKE_BDFR(b, d, f, r) ( \ + (uint_t)(b) << PCI_REG_BUS_SHIFT | \ + (uint_t)(d) << PCI_REG_DEV_SHIFT | \ + (uint_t)(f) << PCI_REG_FUNC_SHIFT | (r)) + +/* + * PCI bit encodings of pci_phys_hi of PCI 1275 address cell. + */ +#define PCI_ADDR_MASK PCI_REG_ADDR_M +#define PCI_ADDR_CONFIG 0x00000000 /* configuration address */ +#define PCI_ADDR_IO 0x01000000 /* I/O address */ +#define PCI_ADDR_MEM32 0x02000000 /* 32-bit memory address */ +#define PCI_ADDR_MEM64 0x03000000 /* 64-bit memory address */ +#define PCI_ALIAS_B PCI_REG_ALIAS_M /* aliased bit */ +#define PCI_PREFETCH_B PCI_REG_PF_M /* prefetch bit */ +#define PCI_RELOCAT_B PCI_REG_REL_M /* non-relocatable bit */ +#define PCI_CONF_ADDR_MASK 0x00ffffff /* mask for config address */ + +#define PCI_HARDDEC_8514 2 /* number of reg entries for 8514 hard-decode */ +#define PCI_HARDDEC_VGA 3 /* number of reg entries for VGA hard-decode */ +#define PCI_HARDDEC_IDE 4 /* number of reg entries for IDE hard-decode */ +#define PCI_HARDDEC_IDE_PRI 2 /* number of reg entries for IDE primary */ +#define PCI_HARDDEC_IDE_SEC 2 /* number of reg entries for IDE secondary */ + +/* + * PCI Expansion ROM Header Format + */ +#define PCI_ROM_SIGNATURE 0x0 /* ROM Signature 0xaa55 */ +#define PCI_ROM_ARCH_UNIQUE_START 0x2 /* Start of processor unique */ +#define PCI_ROM_PCI_DATA_STRUCT_PTR 0x18 /* Ptr to PCI Data Structure */ + +/* + * PCI Data Structure + * + * The PCI Data Structure is located within the first 64KB + * of the ROM image and must be DWORD aligned. + */ +#define PCI_PDS_SIGNATURE 0x0 /* Signature, the string 'PCIR' */ +#define PCI_PDS_VENDOR_ID 0x4 /* Vendor Identification */ +#define PCI_PDS_DEVICE_ID 0x6 /* Device Identification */ +#define PCI_PDS_VPD_PTR 0x8 /* Pointer to Vital Product Data */ +#define PCI_PDS_PDS_LENGTH 0xa /* PCI Data Structure Length */ +#define PCI_PDS_PDS_REVISION 0xc /* PCI Data Structure Revision */ +#define PCI_PDS_CLASS_CODE 0xd /* Class Code */ +#define PCI_PDS_IMAGE_LENGTH 0x10 /* Image Length in 512 byte units */ +#define PCI_PDS_CODE_REVISON 0x12 /* Revision Level of Code/Data */ +#define PCI_PDS_CODE_TYPE 0x14 /* Code Type */ +#define PCI_PDS_INDICATOR 0x15 /* Indicates if image is last in ROM */ + +#define PCI_PDS_CODE_TYPE_PCAT 0x0 /* Intel x86/PC-AT Type */ +#define PCI_PDS_CODE_TYPE_OPEN_FW 0x1 /* Open Firmware */ + +/* + * we recognize the non transparent bridge child nodes with the + * following property. This is specific to an implementation only. + * This property is specific to AP nodes only. + */ +#define PCI_DEV_CONF_MAP_PROP "pci-parent-indirect" + +/* + * If a bridge device provides its own config space access services, + * and supports a hotplug/hotswap bus below at any level, then + * the following property must be defined for the node either by + * the driver or the OBP. + */ +#define PCI_BUS_CONF_MAP_PROP "pci-conf-indirect" + +/* + * PCI returns all 1s for an invalid read. + */ +#define PCI_EINVAL8 0xff +#define PCI_EINVAL16 0xffff +#define PCI_EINVAL32 0xffffffff + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PCI_H */ diff --git a/illumos-x86_64/usr/include/sys/pcic_reg.h b/illumos-x86_64/usr/include/sys/pcic_reg.h new file mode 100644 index 00000000..5d080312 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pcic_reg.h @@ -0,0 +1,629 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Intel 82365SL device and register definitions + */ + +#ifndef _PCIC_REG_H +#define _PCIC_REG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * global information + */ +#define PCIC_MAX_CONTROLLERS 4 /* maximum of 4 chips in system */ + +/* + * per socket information + */ + +#define PCIC_SOCKETS 2 /* number of sockets per PCIC chip */ +#define PCIC_MEMWINDOWS 5 /* number of memory windows per socket */ +#define PCIC_IOWINDOWS 2 /* number of I/O address windows per socket */ +/* number of windows per chip */ +#define PCIC_NUMWINDOWS ((PCIC_MEMWINDOWS + PCIC_IOWINDOWS) * PCIC_SOCKETS) +/* number of windows per socket */ +#define PCIC_NUMWINSOCK (PCIC_MEMWINDOWS+PCIC_IOWINDOWS) + +/* + * socket selection registers + * + * the PCIC allows up to 8 sockets per system + * this is done by having two sockets per chip and up to 4 chips per + * system. There can be up to 4 sockets (2 PCIC chips) per I/O address. + * There are two possible I/O address (index register) values. + * socket# I/O address value to write to index register + * 0 INDEX_REG0 BASE0 + SOCKET_0 + register offset + * 1 INDEX_REG0 BASE0 + SOCKET_1 + register offset + * 2 INDEX_REG0 BASE1 + SOCKET_0 + register offset + * 3 INDEX_REG0 BASE1 + SOCKET_1 + register offset + * next 4 are based off of INDEX_REG1 + */ + +#define PCIC_INDEX_REG0 0x3e0 /* first possible index register */ +#define PCIC_INDEX_REG1 0x3e2 /* second possible index register */ + +#define PCIC_BASE0 0x00 /* first set of sockets */ +#define PCIC_BASE1 0x80 /* second set of sockets */ + +#define PCIC_SOCKET_0 0x00 /* first socket */ +#define PCIC_SOCKET_1 0x40 /* second socket */ + +#define PCIC_DATA_REG0 (PCIC_INDEX_REG0+1) +#define PCIC_DATA_REG1 (PCIC_INDEX_REG1+1) + +/* + * per socket register + * these are accessed by writing the offset value into the + * index register and adding the appropriate base offset and socket offset + * the register is then present in the data register. + */ + +/* General Registers */ + +#define PCIC_CHIP_REVISION 0x00 /* identification and revision */ +#define PCIC_INTERFACE_STATUS 0x01 /* Interface status */ +#define PCIC_POWER_CONTROL 0x02 /* Power and RESETDRV control */ +#define PCIC_CARD_STATUS_CHANGE 0x04 /* card status change */ +#define PCIC_MAPPING_ENABLE 0x06 /* address window mapping enable */ +#define PCIC_CARD_DETECT 0x16 /* card detect&general control register */ +#define PCIC_MISC_CTL_1 0x16 /* CL version */ +#define PCIC_GLOBAL_CONTROL 0x1e /* global control register */ +#define PCIC_MISC_CTL_2 0x1e /* CL version */ +#define PCIC_CHIP_INFO 0x1f /* Cirrus Logic chip info register */ + +/* Interrupt Registers */ + +#define PCIC_INTERRUPT 0x03 /* interrupt & general control register */ +#define PCIC_MANAGEMENT_INT 0x05 /* card status change interrupt register */ + +/* I/O Registers */ + +#define PCIC_IO_CONTROL 0x07 /* I/O Control register */ +#define PCIC_IO_ADDR_0_STARTLOW 0x08 /* I/O address map 0 start low byte */ +#define PCIC_IO_ADDR_0_STARTHI 0x09 /* I/O address map 0 start high byte */ +#define PCIC_IO_ADDR_0_STOPLOW 0x0a /* I/O address map 0 stop low byte */ +#define PCIC_IO_ADDR_0_STOPHI 0x0b /* I/O address map 0 stop high byte */ +#define PCIC_IO_OFFSET_LOW 0x36 /* I/O Offset for CL */ +#define PCIC_IO_OFFSET_HI 0x37 +#define PCIC_IO_OFFSET_OFFSET 2 + +#define PCIC_IO_ADDR_1_OFFSET 5 /* offset to second I/O map register set */ +#define PCIC_IO_WIN_MASK 0xf + +/* Memory Registers */ + /* window 0 */ +#define PCIC_SYSMEM_0_STARTLOW 0x10 /* system memory map 0 start low byte */ +#define PCIC_SYSMEM_0_STARTHI 0x11 /* system memory map 0 start high byte */ +#define PCIC_SYSMEM_0_STOPLOW 0x12 /* system memory map 0 stop low byte */ +#define PCIC_SYSMEM_0_STOPHI 0x13 /* system memory map 0 stop high byte */ +#define PCIC_CARDMEM_0_LOW 0x14 /* card memory offset 0 low byte */ +#define PCIC_CARDMEM_0_HI 0x15 /* card memory offset 0 high byte */ + + /* window 1 */ +#define PCIC_SYSMEM_1_STARTLOW 0x18 /* system memory map 0 start low byte */ +#define PCIC_SYSMEM_1_STARTHI 0x19 /* system memory map 0 start high byte */ +#define PCIC_SYSMEM_1_STOPLOW 0x1a /* system memory map 0 stop low byte */ +#define PCIC_SYSMEM_1_STOPHI 0x1b /* system memory map 0 stop high byte */ +#define PCIC_CARDMEM_1_LOW 0x1c /* card memory offset 0 low byte */ +#define PCIC_CARDMEM_1_HI 0x1d /* card memory offset 0 high byte */ + +#define PCIC_MEM_1_OFFSET 8 /* offset to second memory map register set */ +#define PCIC_MEM_2_OFFSET 16 +#define PCIC_MEM_3_OFFSET 24 +#define PCIC_MEM_4_OFFSET 32 + +#define PCIC_IO_OFFSET 4 /* offset to next set of I/O map registers */ + +/* Cirrus Logic specific registers */ +#define PCIC_TIME_SETUP_0 0x3A +#define PCIC_TIME_SETUP_1 0x3D +#define PCIC_TIME_COMMAND_0 0x3B +#define PCIC_TIME_COMMAND_1 0x3E +#define PCIC_TIME_RECOVER_0 0x3C +#define PCIC_TIME_RECOVER_1 0x3F +#define PCIC_ATA_CONTROL 0x26 +#define PCIC_FIFO_CONTROL 0x17 +#define PCIC_CL_EXINDEX 0x2e +#define PCIC_CL_EXDATA 0x2f + +/* + * Cirrus Logic PCI-PCMCIA adapters extension register indicies + */ +#define PCIC_CLEXT_SCRATCH 0x00 +#define PCIC_CLEXT_DMASK_0 0x01 +#define PCIC_CLEXT_EXT_CTL_1 0x03 +#define PCIC_CLEXT_MMAP0_UA 0x05 +#define PCIC_CLEXT_MMAP1_UA 0x06 +#define PCIC_CLEXT_MMAP2_UA 0x07 +#define PCIC_CLEXT_MMAP3_UA 0x08 +#define PCIC_CLEXT_MMAP4_UA 0x09 +#define PCIC_CLEXT_EXDATA 0x0a +#define PCIC_CLEXT_EXT_CTL_2 0x0b /* 6729 */ +#define PCIC_CLEXT_MISC_CTL_3 0x25 /* 6730 */ +#define PCIC_CLEXT_SMB_CTL 0x26 /* 6730 */ + +/* the 6832 is mapped into different offsets for extension regs */ + +#define PCIC_CBCLEXT_MMAP0_UA 0x40 /* minus the 0x800 */ +#define PCIC_CBCLEXT_MMAP1_UA 0x41 +#define PCIC_CBCLEXT_MMAP2_UA 0x42 +#define PCIC_CBCLEXT_MMAP3_UA 0x43 +#define PCIC_CBCLEXT_MMAP4_UA 0x44 +#define PCIC_CBCLEXT_MMAP5_UA 0x45 + +#define PCIC_CLEXT_MISC_CTL_3_REV_MASK 0xf0 + +/* + * Cirrus Logic PCI-PCMCIA PCIC_CLEXT_EXT_CTL_1 reg bit definitions + */ +#define PCIC_CLEXT_IRQ_LVL_MODE 0x08 +#define PCIC_CLEXT_SMI_LVL_MODE 0x00 /* see errata 1.0 */ + +/* + * Cirrus Logic PCI-PCMCIA PCIC_MISC_CTL_2 reg bit definitions + */ +#define PCIC_CL_LP_DYN_MODE 0x02 /* low-power dynamic mode */ +#define PCIC_CL_TIMER_CLK_DIV 0x10 /* PCI clock divide */ + +/* + * Cirrus Logic PCI-PCMCIA PCIC_CLEXT_MISC_CTL_3 reg bit definitions + */ +#define PCIC_CLEXT_INT_PC_PCI 0x00 +#define PCIC_CLEXT_INT_EXT_HW 0x01 +#define PCIC_CLEXT_INT_PCI_WAY 0x10 +#define PCIC_CLEXT_INT_PCI 0x03 /* see errata 1.0 */ +#define PCIC_CLEXT_PWR_EXT_HW 0x00 +#define PCIC_CLEXT_PWR_RESERVED 0x04 +#define PCIC_CLEXT_PWR_TI 0x80 +#define PCIC_CLEXT_PWR_SMB 0xc0 + +/* + * Intel 82092-AA reg and bit definitions + */ +#define PCIC_82092_PCICON 0x40 /* PCI configuration control */ +#define PCIC_82092_PCICLK_25MHZ 0x01 /* 25MHz PCI clock */ +#define PCIC_82092_SLOT_CONFIG 0x06 /* config mask */ +#define PCIC_82092_2_SOCKETS 0x00 /* 2 sockets */ +#define PCIC_82092_1_SOCKET 0x02 /* 1 socket + IDE */ +#define PCIC_82092_4_SOCKETS 0x04 /* 4 sockets + IDE */ +#define PCIC_82092_EN_TIMING 0x20 /* enhanced memory window timing */ +#define PCIC_82092_PWB 0x08 /* Post Write Buffering */ +#define PCIC_82092_RPFB 0x10 /* Read Prefetch Buffering */ +#define PCIC_82092_PPIRR 0x50 /* interrupt routing register */ +#define PCIC_82092_SMI_CTL(sock, state) (state << (sock * 2)) +#define PCIC_82092_IRQ_CTL(sock, state) (state << ((sock * 2) + 1)) +#define PCIC_82092_CTL_SMI 0x01 +#define PCIC_82092_CTL_IRQ 0x02 +#define PCIC_82092_INT_DISABLE 0x00 +#define PCIC_82092_INT_ENABLE 0x01 +#define PCIC_82092_CPAGE 0x26 /* CPAGE register */ + +/* + * identification and revision register + */ +#define PCIC_REV_ID_MASK 0xc0 +#define PCIC_REV_ID_IO 0x00 +#define PCIC_REV_ID_MEM 0x40 +#define PCIC_REV_ID_BOTH 0x80 + +/* + * interface status register bit definitions + */ +#define PCIC_ISTAT_CD_MASK 0xC /* card detect mask */ +#define PCIC_CD_PRESENT_OK 0xC /* card is present and fully seated */ +#define PCIC_CD_NOTPRESENT 0x0 /* card not present */ +#define PCIC_CD_NOTSEATED_1 0x8 /* card not fully seated */ +#define PCIC_CD1 0x8 +#define PCIC_CD_NOTSEATED_2 0x4 /* card not fully seated */ +#define PCIC_CD2 0x4 +#define PCIC_WRITE_PROTECT 0x10 +#define PCIC_READY 0x20 +#define PCIC_POWER_ON 0x40 +#define PCIC_VPP_VALID 0x80 +#define PCIC_BVD1 0x1 +#define PCIC_BVD2 0x2 + +/* + * memory register definitions + */ +#define SYSMEM_LOW(x) (((uint32_t)(x)>>12)&0xFF) +#define SYSMEM_HIGH(x) (((uint32_t)(x)>>20)&0xF) +#define SYSMEM_EXT(x) (((uint32_t)(x)>>24)&0xFF) +#define SYSMEM_WINDOW(x) (1<<(x)) +#define SYSMEM_ZERO_WAIT 0x40 /* zero wait state bit */ +#define SYSMEM_DATA_16 0x80 /* 16 bit memory bit */ +#define SYSMEM_MEM16 0x20 /* 16 bit memory in window enable */ +#define SYSMEM_CLTIMER_SET_0 0x00 +#define SYSMEM_CLTIMER_SET_1 0x80 + +#define SYSMEM_82092_600NS 0x0110 +#define SYSMEM_82092_250NS 0x0101 +#define SYSMEM_82092_200NS 0x0100 +#define SYSMEM_82092_150NS 0x0011 +#define SYSMEM_82092_100NS 0x0010 +#define SYSMEM_82092_80NS 0x0001 + +#define DEFAULT_AM_ADDR 0xd0000 + +#define CARDMEM_REG_ACTIVE 0x40 +#define CARDMEM_WRITE_PROTECT 0x80 + +#define CARDMEM_LOW(x) (((uint32_t)((x))>>12)&0xFF) +#define CARDMEM_HIGH(x) (((uint32_t)((x))>>20)&0x3F) + +#define POWER_CARD_ENABLE 0x10 +#define POWER_3VCARD_ENABLE 0x18 +#define POWER_OUTPUT_ENABLE 0x80 +#define POWER_VPP_VCC_ENABLE 0x01 +#define POWER_VPP_12V_ENABLE 0x02 + +/* interrupt register definitions */ +#define PCIC_INTR_ENABLE 0x10 +#define PCIC_IO_CARD 0x20 +#define PCIC_RESET 0x40 +#define PCIC_INTR_MASK 0x0f + +/* card status change register definitions */ +#define PCIC_CD_DETECT 0x08 +#define PCIC_RD_DETECT 0x04 +#define PCIC_BW_DETECT 0x02 +#define PCIC_BD_DETECT 0x01 +#define PCIC_CHANGE_MASK 0x0f + +/* card status change interrupt register definitions */ +#define PCIC_CD_ENABLE 0x08 /* card detect enable */ +#define PCIC_RD_ENABLE 0x04 /* ready change enable */ +#define PCIC_BW_ENABLE 0x02 /* battery warning enable */ +#define PCIC_BD_ENABLE 0x01 /* battery deat enable */ +#define PCIC_GPI_CHANGE 0x10 /* general purpose interrupt */ +#define PCIC_CHANGE_DEFAULT (PCIC_CD_ENABLE|PCIC_RD_ENABLE|\ + PCIC_BW_ENABLE|PCIC_BD_ENABLE) + +/* card detect change register */ +#define PCIC_GPI_ENABLE 0x04 +#define PCIC_GPI_TRANSITION 0x08 +#define PCIC_16MDI 0x01 +#define PCIC_SOFT_CD_INTR 0x20 + +/* misc control 1 */ +#define PCIC_MC_5VDETECT 0x01 +#define PCIC_MC_3VCC 0x02 +#define PCIC_MC_PULSE_SMI 0x04 +#define PCIC_MC_PULSE_IRQ 0x08 +#define PCIC_MC_SPEAKER_ENB 0x10 +#define PCIC_MC_INPACK_ENB 0x80 + +/* global control registers definitions */ +#define PCIC_GC_POWERDOWN 0x01 +#define PCIC_GC_LEVELMODE 0x02 +#define PCIC_GC_CSC_WRITE 0x04 +#define PCIC_GC_IRQ1_PULSE 0x08 + +/* misc control 2 */ +#define PCIC_MC_BYPASS_FS 0x01 +#define PCIC_MC_LOWPOWER 0x02 +#define PCIC_MC_SUSPEND 0x04 +#define PCIC_5V_CORE 0x08 +#define PCIC_LED_ENABLE 0x10 +#define PCIC_THREESTATE 0x20 +#define PCIC_CL_DMA 0x40 +#define PCIC_IRQ15_RI_OUT 0x80 + +/* chip info register (Cirrus) definitions */ +#define PCIC_CI_ID 0xc0 +#define PCIC_CI_SLOTS 0x20 + +/* Vadem unique registers */ +#define PCIC_VADEM_P1 0x0E +#define PCIC_VADEM_P2 0x37 + +#define PCIC_VG_VSENSE 0x1f +#define PCIC_VG_VSELECT 0x2f +#define PCIC_VG_CONTROL 0x38 +#define PCIC_VG_TIMER 0x39 +#define PCIC_VG_DMA 0x3A +#define PCIC_VG_EXT_A 0x3C +#define PCIC_VG_STATUS 0x3E + +/* Vadem DMA Register */ +#define PCIC_V_DMAWSB 0x04 +#define PCIC_V_VADEMREV 0x40 +#define PCIC_V_UNLOCK 0x80 + +/* Vadem identification register */ +#define PCIC_VADEM_D3 0x8 +#define PCIC_VADEM_365 0x9 +#define PCIC_VADEM_465 0x8 +#define PCIC_VADEM_468 0xB +#define PCIC_VADEM_469 0xC + +/* Vadem Voltage Select */ +#define PCIC_VSEL_EXTENDED 0x10 /* extended mode */ +#define PCIC_VSEL_BUSSEL 0x20 /* extended buffers on ISA */ + +/* Vadem Control Register */ +#define PCIC_VC_DELAYENABLE 0x10 + +/* Vadem Extended Mode Register A */ +#define PCIC_VEXT_CABLEMODE 0x08 /* enable external cable */ + +#define PCIC_YENTA_MEM_PAGE 0x40 /* yenta defined extended address byte */ + +/* Ricoh Specific Registers */ +#define PCIC_RF_CHIP_IDENT 0x3A +#define PCIC_RF_296 0x32 +#define PCIC_RF_396 0xB2 +#define PCIC_RF_MEM_PAGE PCIC_YENTA_MEM_PAGE + +/* O2 Micro Specific registers */ +#define PCIC_CENTDMA 0x3C +#define PCIC_MULTIFUNC 0x8C +#define PCIC_O2_CTRL1 0xD0 +#define PCIC_O2_CTRL2 0xD4 + +/* Texas Instruments specific Registers */ +#define PCIC_INTLINE_REG 0x3C +#define PCIC_INTPIN_REG 0x3D +#define PCIC_BRIDGE_CTL_REG 0x3e +#define PCIC_FUN_INT_MOD_ISA 0x80 + +/* for PCI1420 chip */ +#define PCIC_BRDGCTL_INTR_MASK 0x80 +#define PCIC_GPIO0_REG 0x88 +#define PCIC_GPIO1_REG 0x89 +#define PCIC_GPIO2_REG 0x8A +#define PCIC_GPIO3_REG 0x8B + +#define PCIC_MFROUTE_REG 0x8c +#define PCIC_MFUNC0_MASK 0xF +#define PCIC_MFUNC0_INTA 0x2 + +#define PCIC_DIAG_REG 0x93 +#define PCIC_GPIO_FMASK 0xC0 +#define PCIC_GPIO_INTENBL 0x10 +#define PCIC_GPIO_DELTA 0x08 +#define PCIC_GPIO_DOUT 0x02 +#define PCIC_GPIO_DIN 0x01 +#define PCIC_GPIO_FOUTPUT 0xC0 +#define PCIC_GPIO_FINPUT 0x80 +#define PCIC_GPIO2_IS_PCILOCK 0x00 +#define PCIC_GPIO3_IS_INTA 0x00 +#define PCIC_TI_WINDOW_PAGE 0x3C /* legacy */ +#define PCIC_TI_WINDOW_PAGE_PCI 0x40 + +#define PCIC_DIAG_REG 0x93 /* Diagnostic Register */ +/* for PCI1225 chip */ +#define PCIC_DIAG_CSC 0x20 /* CSC Interrupt Routing Control */ +/* for PCI1221 and PCI1225 chips */ +#define PCIC_DIAG_ASYNC 0x01 /* Async. interrupt enable */ + +#define PCIC_DEVCTL_REG 0x92 /* Device Control Register */ +#define PCIC_DEVCTL_INTR_MASK 0x06 /* to mask out mode */ +#define PCIC_DEVCTL_INTR_PCI 0x00 /* PCI style interrupts */ +#define PCIC_DEVCTL_INTR_ISA 0x02 /* ISA style interrupts */ +#define PCIC_DEVCTL_INTR_SER 0x04 /* serialize IRQ scheme */ +#define PCIC_DEVCTL_INTR_RSVD 0x06 /* reserved */ +/* for PCI1221 and PCI1225 chips */ +#define PCIC_DEVCTL_3VCAPABLE 0x40 /* 3V socket capable force */ +#define PCIC_DEVCTL_INTR_DFLT 0x06 /* default interrupt mode */ + +#define PCIC_CRDCTL_REG 0x91 /* Card Control Register */ +#define PCIC_CRDCTL_RIENABLE 0x80 /* Ring indicate enable on TI1250a */ +#define PCIC_CRDCTL_ZVENABLE 0x40 /* Z buffer enable on TI1250a */ +#define PCIC_CRDCTL_PCIINTR 0x20 /* use PCI INT A/B */ +#define PCIC_CRDCTL_PCICSC 0x10 /* PCI intr for status */ +#define PCIC_CRDCTL_PCIFUNC 0x08 /* use PCI intr for cards */ +#define PCIC_CRDCTL_SPKR_ENBL 0x02 /* Enable speaker plumbing */ +#define PCIC_CRDCTL_IFG 0x01 /* card interrupt flag */ + +#define PCIC_SYSCTL_REG 0x80 /* System Control Register */ +#define PCIC_SYSCTL_INTRTIE 0x20 /* tie INTA and INTB */ + +/* for Toshiba chips */ +#define PCIC_TOSHIBA_SLOT_CTL_REG 0xa0 /* slot control register */ +#define PCIC_TOSHIBA_SCR_SLOTON 0x80 +#define PCIC_TOSHIBA_SCR_SLOTEN 0x40 +#define PCIC_TOSHIBA_SCR_PRT_MASK 0xc +#define PCIC_TOSHIBA_SCR_PRT_3E0 0x0 +#define PCIC_TOSHIBA_SCR_PRT_3E2 0x4 +#define PCIC_TOSHIBA_SCR_PRT_3E4 0x8 +#define PCIC_TOSHIBA_SCR_PRT_3E6 0xc +#define PCIC_TOSHIBA_INTR_CTL_REG 0xa1 /* interrupt control register */ +#define PCIC_TOSHIBA_ICR_PIN_MASK 0x30 +#define PCIC_TOSHIBA_ICR_PIN_DISEN 0x0 +#define PCIC_TOSHIBA_ICR_PIN_INTA 0x10 +#define PCIC_TOSHIBA_ICR_PIN_INTB 0x20 +#define PCIC_TOSHIBA_ICR_MOD_CSC 0x4 /* CSC interrupt mode */ +#define PCIC_TOSHIBA_ICR_MOD_FUN 0x2 /* Funtional interrupt mode */ +#define PCIC_TOSHIBA_ICR_SRC 0x1 /* INTA or IRQ */ + +/* for Ricoh chips */ +#define PCIC_RICOH_MISC_CTL 0x82 +#define PCIC_RICOH_SIRQ_EN 0x80 /* serialized IRQ */ +#define PCIC_RICOH_MISC_CTL_2 0xa0 /* ricoh */ +#define PCIC_RICOH_CSC_INT_MOD 0x80 /* csc to ISA */ +#define PCIC_RICOH_FUN_INT_MOD 0x40 /* cint to ISA */ + +/* for o2micro */ +#define PCIC_O2MICRO_MISC_CTL 0x28 +#define PCIC_O2MICRO_INT_MOD_MASK 0x300 +#define PCIC_O2MICRO_INT_MOD_PCI 0x300 +#define PCIC_O2MICRO_ISA_LEGACY 0x800 +/* */ + +/* SMC 34C90 specific registers */ +#define PCIC_SMC_MEM_PAGE 0x40 + +/* available interrupts and interrupt mask */ +#define PCIC_IRQ(irq) (1 << (irq)) +#define PCIC_IRQ03 PCIC_IRQ(3) +#define PCIC_IRQ04 PCIC_IRQ(4) +#define PCIC_IRQ05 PCIC_IRQ(5) +#define PCIC_IRQ07 PCIC_IRQ(7) +#define PCIC_IRQ09 PCIC_IRQ(9) +#define PCIC_IRQ10 PCIC_IRQ(10) +#define PCIC_IRQ11 PCIC_IRQ(11) +#define PCIC_IRQ12 PCIC_IRQ(12) +#define PCIC_IRQ14 PCIC_IRQ(14) +#define PCIC_IRQ15 PCIC_IRQ(15) + +#define PCIC_AVAIL_IRQS (PCIC_IRQ03|PCIC_IRQ04|PCIC_IRQ05|PCIC_IRQ07|\ + PCIC_IRQ09|PCIC_IRQ10|PCIC_IRQ11|PCIC_IRQ12|\ + PCIC_IRQ14|PCIC_IRQ15) + +/* page size used for window mapping and memory resource page size */ +#define PCIC_PAGE 4096 + +/* used in I/O window mapping */ +#define HIGH_BYTE(x) (uchar_t)((((ushort_t)(x)) >> 8) & 0xFF) +#define LOW_BYTE(x) (uchar_t)(((ushort_t)(x)) & 0xFF) +#define PCIC_IO_0_MASK 0x0f +#define PCIC_IO_1_MASK 0xf0 +#define IOMEM_WINDOW(x) (1<<((x)+6)) + +#define IOMEM_16BIT 0x01 +#define IOMEM_IOCS16 0x02 +#define IOMEM_ZERO_WAIT 0x04 +#define IOMEM_CLTIMER_SET_0 0x00 /* CL timer set selection */ +#define IOMEM_CLTIMER_SET_1 0x08 /* CL timer set selection */ +#define IOMEM_WAIT16 0x08 +#define IOMEM_SETWIN(w, x) ((x) << ((w)*4)) + +#define IOMEM_FIRST 0 /* First I/O address */ +#define IOMEM_LAST 0xFFFF /* Last I/O address */ +#define IOMEM_MIN 1 /* minimum I/O window size */ +#define IOMEM_MAX 0x10000 /* maximum I/O window size */ +#define IOMEM_GRAN 1 /* granularity of request */ +#define IOMEM_DECODE 16 /* number of address lines decoded */ + +#define MEM_FIRST 0x10000 /* first memory address */ +#define MEM_LAST 0xFFFFF /* last memory address */ +#define MEM_MIN PCIC_PAGE /* minimum window size */ +#define MEM_MAX 0x10000 /* maximum window size */ +#define PAGE_SHIFT 12 /* bits to shift */ + +#define SYSCLK 120 /* sysclk min time (ns) */ +#define MEM_SPEED_MIN (SYSCLK*2) +#define MEM_SPEED_MAX (SYSCLK*6) + +/* CardBus (Yenta) specific values */ +#define CB_R2_OFFSET 0x800 /* R2 is always at offset 0x800 */ +#define CB_CLEXT_OFFSET 0x900 /* Cirrus Logic extended at offset 0x900 */ +#define CB_CB_OFFSET 0x00 /* Cardbus registers at offset 0 */ + +/* Cardbus registers in TI 1250A/Cirrus 6832 and probably others. */ +/* Register offsets (these are 32 bit registers). */ +#define CB_STATUS_EVENT 0x00 +#define CB_STATUS_MASK 0x04 +#define CB_PRESENT_STATE 0x08 +#define CB_EVENT_FORCE 0x0c +#define CB_CONTROL 0x10 + +/* TI1420 */ +#define CB_SOCKET_POWER 0x20 + +/* Cardbus registers in 02 0Z6912. */ +#define CB_SZVCTRL 0x20 +#define CB_SIMDCTRL 0x24 +#define CB_MISCCTRL 0x28 + +/* Register bit definitions. */ +#define BYTE_3(x) ((x)<<24) +#define BYTE_2(x) ((x)<<16) +#define BYTE_1(x) ((x)<<8) +#define BYTE_0(x) (x) + +#define CB_SE_POWER_CYCLE BYTE_0(0x08) +#define CB_SE_CCDMASK BYTE_0(0x06) +#define CB_SE_CCD2 BYTE_0(0x04) +#define CB_SE_CCD1 BYTE_0(0x02) +#define CB_SE_CSTSCHG BYTE_0(0x01) + +#define CB_SM_POWER_CYCLE BYTE_0(0x08) +#define CB_SM_CCDMASK BYTE_0(0x06) +#define CB_SM_CCD2 BYTE_0(0x04) +#define CB_SM_CCD1 BYTE_0(0x02) +#define CB_SM_CSTSCHG BYTE_0(0x01) + +#define CB_PS_CSTSCHG BYTE_0(0x01) +#define CB_PS_CCDMASK BYTE_0(0x06) +#define CB_PS_NCCD1 BYTE_0(0x02) +#define CB_PS_NCCD2 BYTE_0(0x04) +#define CB_PS_POWER_CYCLE BYTE_0(0x08) +#define CB_PS_16BITCARD BYTE_0(0x10) +#define CB_PS_CBCARD BYTE_0(0x20) +#define CB_PS_INTERRUPT BYTE_0(0x40) +#define CB_PS_NOTACARD BYTE_0(0x80) + +#define CB_PS_DATALOST BYTE_1(0x01) +#define CB_PS_BADVCC BYTE_1(0x02) +#define CB_PS_50VCARD BYTE_1(0x04) +#define CB_PS_33VCARD BYTE_1(0x08) +#define CB_PS_XVCARD BYTE_1(0x10) +#define CB_PS_YVCARD BYTE_1(0x20) + +#define CB_PS_50VSOCKET BYTE_3(0x10) +#define CB_PS_33VSOCKET BYTE_3(0x20) +#define CB_PS_XVSOCKET BYTE_3(0x40) +#define CB_PS_YVSOCKET BYTE_3(0x80) + +#define CB_EF_CSTSCHG BYTE_0(0x01) +#define CB_EF_CCD1 BYTE_0(0x02) +#define CB_EF_CCD2 BYTE_0(0x04) +#define CB_EF_POWER_CYCLE BYTE_0(0x08) +#define CB_EF_16BITCARD BYTE_0(0x10) +#define CB_EF_CBCARD BYTE_0(0x20) +#define CB_EF_NOTACARD BYTE_0(0x80) + +#define CB_EF_DATALOST BYTE_1(0x01) +#define CB_EF_BADVCC BYTE_1(0x02) +#define CB_EF_50V BYTE_1(0x04) +#define CB_EF_33V BYTE_1(0x08) +#define CB_EF_XV BYTE_1(0x10) +#define CB_EF_YV BYTE_1(0x20) +#define CB_EF_CVTEST BYTE_1(0x40) + +#define CB_C_VPPMASK BYTE_0(0x07) +#define CB_C_VCCMASK BYTE_0(0x70) + +#define CB_C_VPP0V BYTE_0(0x00) +#define CB_C_VPP12V BYTE_0(0x01) +#define CB_C_VPPVCC BYTE_0(0x03) + +#define CB_C_VCC0V BYTE_0(0x00) +#define CB_C_VCC50V BYTE_0(0x20) +#define CB_C_VCC33V BYTE_0(0x30) + +#ifdef __cplusplus +} +#endif + +#endif /* _PCIC_REG_H */ diff --git a/illumos-x86_64/usr/include/sys/pcic_var.h b/illumos-x86_64/usr/include/sys/pcic_var.h new file mode 100644 index 00000000..d48e6163 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pcic_var.h @@ -0,0 +1,616 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * PCIC driver specific data structures + */ + +#ifndef _PCIC_VAR_H +#define _PCIC_VAR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * defines and default values for power management simulation + */ +#define PCIC_PM_TIME 3 /* PM timer timeout time in secs */ +#define PCIC_PM_DETWIN 6 /* detection window in secs */ +#define PCIC_PM_METHOD_TIME 0x0001 /* use time check */ +#define PCIC_PM_METHOD_REG 0x0002 /* use reg check */ +#define PCIC_PM_DEF_METHOD 0 /* use no methods as default */ + +#define PCIC_PM_INIT 0x0001 /* init PM handler */ +#define PCIC_PM_RUN 0x0002 /* normal PM handler operation */ + +typedef struct pcic_pm_t { + int state; /* state */ + uint32_t ptime; /* previous time check */ + dev_info_t *dip; /* dip to pass */ +} pcic_pm_t; + +/* + * Card insertion/removal processing debounce parameters + */ +#define PCIC_REM_DEBOUNCE_CNT 40 +#define PCIC_REM_DEBOUNCE_TIME 0x1000 /* in uS */ +#define PCIC_DEBOUNCE_OK_CNT 10 + +/* + * Loop control in pcic_ready_wait + * + * Multiplying PCIC_READY_WAIT_LOOPS * PCIC_READY_WAIT_TIME gives + * total loop time in mS + */ +#define PCIC_READY_WAIT_LOOPS 205 /* count */ +#define PCIC_READY_WAIT_TIME 20 /* mS */ + +typedef struct pcs_memwin { + int pcw_status; + uint32_t pcw_base; + int pcw_len; + uint32_t pcw_speed; + volatile caddr_t pcw_hostmem; + off_t pcw_offset; + ddi_acc_handle_t pcw_handle; + dev_info_t *res_dip; /* dip from which mem is allocated */ +} pcs_memwin_t; + +typedef struct pci_iowin { + int pcw_status; + uint32_t pcw_base; + int pcw_len; + uint32_t pcw_speed; + volatile caddr_t pcw_hostmem; + /* Cirrus Logic specific offset info */ + int pcw_offset; + ddi_acc_handle_t pcw_handle; + dev_info_t *res_dip; /* dip from which io is allocated */ +} pcs_iowin_t; + +#define PCW_MAPPED 0x0001 /* window is mapped */ +#define PCW_ENABLED 0x0002 /* window is enabled */ +#define PCW_ATTRIBUTE 0x0004 /* window is in attribute memory */ +#define PCW_WP 0x0008 /* window is write protected */ +#define PCW_OFFSET 0x0010 /* window uses CL style offset */ + +typedef +struct pcic_socket { + int pcs_flags; + uchar_t *pcs_io; /* I/O address of PCIC controller */ + int pcs_socket; /* socket to determine register set */ + char pcs_cd_softint_flg; + timeout_id_t pcs_debounce_id; /* timeout for CD debounce */ + ddi_softint_handle_t pcs_cd_softint_hdl; /* Debounce softint id */ + struct pcicdev_t *pcs_pcic; + caddr_t pcs_phys; + int pcs_iobase; + int pcs_iolen; + caddr_t pcs_confbase; + int pcs_conflen; + int pcs_conf_index; /* used to select which cftable entry to use */ + int pcs_irq; + int pcs_smi; + int pcs_state; + int pcs_status; + int pcs_intmask; + uint32_t pcs_vcc; + uint32_t pcs_vpp1; + uint32_t pcs_vpp2; + union pcic_window { + pcs_memwin_t mem; + pcs_iowin_t io; + } pcs_windows[PCIC_IOWINDOWS + PCIC_MEMWINDOWS]; +} pcic_socket_t; + +#define PCS_CARD_PRESENT 0x0001 /* card inserted in socket */ +#define PCS_CARD_IDENTIFIED 0x0002 /* card has been identified */ +#define PCS_CARD_ENABLED 0x0004 /* card and socket enabled */ +#define PCS_CARD_WPS 0x0008 /* write protect ignored */ +#define PCS_IRQ_ENABLED 0x0010 /* irq is a mask of values */ +#define PCS_CARD_RAM 0x0020 /* ram needs to be mapped */ +#define PCS_CARD_IO 0x0040 /* card is I/O type */ +#define PCS_CARD_16BIT 0x0080 /* set in 16-bit mode */ +#define PCS_SOCKET_IO 0x0100 /* socket is I/O type */ +#define PCS_READY 0x0200 /* socket just came ready */ +#define PCS_WAITING 0x0400 /* Doing a wait on this socket */ +#define PCS_STARTING 0x0800 /* Starting up flag */ +#define PCS_CARD_ISCARDBUS 0x1000 /* NJH - 32 bit (CARDBUS) card */ +#define PCS_CARD_IS16BIT 0x2000 /* So we can tell if it's OK */ +#define PCS_CARD_REMOVED 0x4000 /* Removed but still work to do */ +#define PCS_CARD_CBREM 0x8000 /* Cardbus specific work to do */ +#define PCS_DEBOUNCING 0x10000 /* Socket in debouncing state */ + +#define PCIC_MAX_SOCKETS 4 /* 2 per chip up to 2 chips per IO addr */ + +typedef struct pcic_debounce_state { + int insert_cnt; + int remove_cnt; + int uncertain_cnt; + int prev_status; + int debounce_cnt; + timeout_id_t timeout_id; +} pcic_debounce_state_t; + +typedef struct pcicdev_t { + uint32_t pc_flags; + uint32_t pc_type; + char *pc_chipname; + uint32_t pc_irqs; /* the possible IRQ levels */ + uint32_t pc_smi; /* SMI IRQ */ + uint32_t pc_irq; /* IO IRQ */ + int pc_io_type; + int pc_intr_mode; /* which interrupt method */ + dev_info_t *dip; + ddi_idevice_cookie_t pc_dcookie; /* Stay compatible w/ PCMCIA */ + inthandler_t *sirq[14]; /* List for each level */ + uint16_t si_actflg; /* Bit for each active level */ + inthandler_t *irq_top; + inthandler_t *irq_current; + ddi_intr_handle_t *pc_pci_intr_hdlp; /* For PCI based adapters */ + ddi_iblock_cookie_t pc_pri; /* Priority saved for mutexes */ + ddi_intr_handle_t *pc_intr_htblp; /* ISA: interrupt handles */ + ddi_softint_handle_t pc_softint_hdl; /* Softinterrupt handle */ + kmutex_t pc_lock; /* general register lock */ + kmutex_t intr_lock; /* protects fields modified */ + /* in pcic_intr() */ + int pc_numsockets; + /* used to inform nexus of events */ + int (*pc_callback)(); + int pc_cb_arg; + int (*pc_ss_bios)(); + struct pcic_socket pc_sockets[PCIC_MAX_SOCKETS]; + int pc_numpower; + struct power_entry *pc_power; + timeout_id_t pc_pmtimer; /* timeout for simulating PM */ + pcic_pm_t pmt; /* PM handler structure */ + kcondvar_t pm_cv; /* CV for suspend/resume sync */ + ddi_acc_handle_t handle; /* PCIC register handle */ + ddi_acc_handle_t cfg_handle; /* PCIC config space handle */ + uchar_t *cfgaddr; /* config address */ + uchar_t *ioaddr; /* PCIC register IO base */ + int mem_reg_num; /* memory space reg number */ + offset_t mem_reg_offset; + int io_reg_num; /* IO space reg number */ + offset_t io_reg_offset; + int bus_speed; /* parent bus speed */ + uint32_t pc_timestamp; /* last time touched */ + inthandler_t *pc_handlers; + int pc_lastreg; + uint32_t pc_base; /* first possible mem-addr */ + uint32_t pc_bound; /* bound length */ + uint32_t pc_iobase; /* first io addr */ + uint32_t pc_iobound; + pcic_debounce_state_t deb_state[PCIC_MAX_SOCKETS]; + int pc_softintr_req[PCIC_MAX_SOCKETS]; + struct pcic_cd_change_param { + struct pcicdev_t *pcic; + pcic_socket_t *sockp; + int sn; + } pcic_cd_change_param[PCIC_MAX_SOCKETS]; +} pcicdev_t; + + + +#define PCF_ATTACHED 0x00000001 +#define PCF_CALLBACK 0x00000002 /* callback handler registered */ +#define PCF_GPI_EJECT 0x00000004 /* GPI signal is eject/insert */ +#define PCF_INTRENAB 0x00000008 +#define PCF_USE_SMI 0x00000010 /* use the SMI enable */ +#define PCF_AUDIO 0x00000020 /* use audio if available */ +#define PCF_SUSPENDED 0x00000040 /* driver attached but suspended */ +#define PCF_EXTEND_INTR 0x00000080 /* Use Vadem interrupt sharing */ +#define PCF_1SOCKET 0x00000100 /* Chip only has one socket */ +#define PCF_33VCAP 0x00000200 /* 3.3 Volt capable and coded */ +#define PCF_CBPWRCTL 0x00000400 /* Use cardbus regs for power ctl */ +#define PCF_DEBOUNCE 0x00002000 /* Chip has hardware debounce enabled */ +#define PCF_VPPX 0x00004000 /* Vpp1 and Vpp2 tied together */ +#define PCF_EXTBUFF 0x00008000 /* Chip strapped for external buffers */ +#define PCF_PCIBUS 0x00010000 /* this instance on a PCI bus */ +#define PCF_NOIO_OFF 0x00020000 /* 0 offset for IO mapping */ +#define PCF_MULT_IRQ 0x00040000 +#define PCF_IO_REMAP 0x00080000 /* adapter can remap I/O */ +#define PCF_CARDBUS 0x00100000 /* Yenta CardBus */ +#define PCF_MEM_PAGE 0x00200000 /* all windows same 16M page */ + +/* newer features */ +#define PCF_DMA 0x00400000 /* supports DMA */ +#define PCF_ZV 0x00800000 /* supports Zoom Video */ + +#define PCF_ISA6729 0x01000000 /* 6729 */ + +/* + * misc flags + */ +#define PCIC_FOUND_ADAPTER 0x00000001 +#define PCIC_ENABLE_IO 0x00000002 +#define PCIC_ENABLE_MEM 0x00000004 + +#define PCIC_SOFTINT_PRI_VAL 0x04 /* value used while adding softint */ + +/* + * interrupt modes + * the pcic variants provide a number of interrupt modes. + * e.g. on PCI, we can either use PCI interrupts or ISA interrupts + * but the SPARC version must use PCI interrupts and x86 "depends" + */ + +#define PCIC_INTR_MODE_ISA 00 /* default- use ISA mode */ +#define PCIC_INTR_MODE_PCI 01 /* use pure PCI */ +#define PCIC_INTR_MODE_PCI_1 02 /* use pure PCI but share */ +#define PCIC_INTR_MODE_PCI_S 03 /* serial PCI interrupts */ + +#define PCIC_INTR_DEF_PRI 11 /* default IPL level */ + +/* + * I/O access types + */ +#define PCIC_IO_TYPE_82365SL 0 /* uses index/data reg model */ +#define PCIC_IO_TYPE_YENTA 1 /* uses the Yenta spec memory model */ + +/* + * On some PCI busses, the IO and memory resources available to us are + * available via the last two tuples in the reg property. The + * following defines are the reg numbers from the end of the reg + * property, and NOT the reg number itself. + */ +#define PCIC_PCI_MEM_REG_OFFSET 2 +#define PCIC_PCI_IO_REG_OFFSET 3 + +/* I/O type 82365SL is default, Yenta is alternative */ +#define PCIC_IOTYPE_82365SL 0 +#define PCIC_IOTYPE_YENTA 1 /* CardBus memory mode */ + +/* + * On Yenta cards, the PCI configuration space bridge control register + * must match the interrupt * type we have selected. + */ + +#define PCIC_CB_BRIDGE_CTL 0x3E +#define PCIC_BCTL_IREQ_ISA 0x80 + +/* + * On all PCI busses, we get at least two tuples in the reg property. One + * of the tuples is the config space tuple and the other is the PCIC + * IO control register space tuple. + */ + +#define PCIC_PCI_CONFIG_REG_NUM 0 +#define PCIC_PCI_CONFIG_REG_OFFSET 0 +#define PCIC_PCI_CONFIG_REG_LENGTH 0x100 + +#define PCIC_PCI_CONTROL_REG_NUM 1 +#define PCIC_PCI_CONTROL_REG_OFFSET 0 +#define PCIC_PCI_CONTROL_REG_LENGTH 4 +#define PCIC_CB_CONTROL_REG_LENGTH 4096 /* CardBus is 4K mem page */ + +/* + * On ISA/EISA/MCA our reg property must look like this: + * + * IOreg,0x0,0x8, 0x0,0x0,0x100000, 0x1,0x0,0x1000 + * ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ + * adapter regs general memory general IO + * + * where IOreg specifies the adapter's control registers in + * IO space. + * The value of PCIC_ISA_IO_REG_OFFSET must be the first + * component of the third (general IO) register spec. + */ +#define PCIC_ISA_IO_REG_OFFSET 1 +#define PCIC_ISA_CONTROL_REG_NUM 0 +#define PCIC_ISA_CONTROL_REG_OFFSET 0 /* XXX MUST be 0! */ +#define PCIC_ISA_CONTROL_REG_LENGTH 2 + +#define PCIC_ISA_MEM_REG_NUM 1 +#define PCIC_ISA_IO_REG_NUM 2 + +/* + * there are several variants of the 82365 chip from different "clone" + * vendors. Each has a few differences which may or may not have to be + * handled. The following defines are used to identify the chip being + * used. If it can't be determined, then 82365SL is assumed. + * + * The following are ISA/EISA/MCA-R2 adapters + */ +#define PCIC_I82365SL 0x00 /* Intel 82365SL */ +#define PCIC_TYPE_I82365SL "i82365SL" +#define PCIC_CL_PD6710 0x01 /* Cirrus Logic CL-PD6710/6720 */ +#define PCIC_CL_PD6722 0x05 /* Cirrus Logic CL-PD6722 */ +#define PCIC_TYPE_PD6710 "PD6710" +#define PCIC_TYPE_PD6720 "PD6720" +#define PCIC_TYPE_PD6722 "PD6722" +#define PCIC_VADEM 0x02 /* Vadem VG465/365 */ +#define PCIC_VADEM_VG469 0x03 /* Vadem VG469 - P&P, etc. */ +#define PCIC_VG_465 "VG465" +#define PCIC_VG_365 "VG365" +#define PCIC_VG_468 "VG468" +#define PCIC_VG_469 "VG469" +#define PCIC_RICOH 0x04 +#define PCIC_TYPE_RF5C296 "RF5C296" +#define PCIC_TYPE_RF5C396 "RF5C396" + +/* PCI adapters are known by 32-bit value of vendor+device id */ +#define PCI_ID(vend, dev) ((uint32_t)(((uint32_t)(vend) << 16) | (dev))) + +/* + * The following are PCI-R2 adapters + * The Cirrus Logic PCI adapters typically have their IRQ3 line + * routed to the PCI INT A# line. + */ +#define PCIC_CL_VENDORID 0x1013 +#define PCIC_PD6729_DEVID 0x1100 +#define PCIC_TYPE_PD6729 "PD6729" +#define PCIC_CL_PD6729 PCI_ID(PCIC_CL_VENDORID, PCIC_PD6729_DEVID) +#define PCIC_PD6729_INTA_ROUTE 0x03 + +#define PCIC_TYPE_PD6730 "PD6730" +#define PCIC_PD6730_DEVID 0x1101 +#define PCIC_CL_PD6730 PCI_ID(PCIC_CL_VENDORID, PCIC_PD6730_DEVID) +#define PCIC_PD6730_INTA_ROUTE 0x09 + +#define PCIC_TYPE_PD6832 "PD6832" +#define PCIC_PD6832_DEVID 0x1110 +#define PCIC_CL_PD6832 PCI_ID(PCIC_CL_VENDORID, PCIC_PD6832_DEVID) + +/* Intel i82092AA controller */ + +#define PCIC_INTEL_VENDORID 0x8086 +#define PCIC_TYPE_i82092 "i82092" +#define PCIC_i82092_DEVID 0x1221 +#define PCIC_INTEL_i82092 PCI_ID(PCIC_INTEL_VENDORID, \ + PCIC_i82092_DEVID) +#define PCIC_i82092_INTA_ROUTE 0x0 /* XXX ? what is it really ? XXX */ + +/* Texas Instruments */ + +#define PCIC_TI_VENDORID 0x104C +#define PCIC_PCI1050_DEVID 0xAC10 +#define PCIC_PCI1130_DEVID 0xAC12 +#define PCIC_PCI1031_DEVID 0xAC13 /* R2 only with Yenta IF */ +#define PCIC_PCI1131_DEVID 0xAC15 +#define PCIC_PCI1250_DEVID 0xAC16 +#define PCIC_PCI1221_DEVID 0xAC19 +#define PCIC_PCI1225_DEVID 0xAC1C +#define PCIC_PCI1220_DEVID 0xAC17 +#define PCIC_PCI1260_DEVID 0xAC18 +#define PCIC_PCI1210_DEVID 0xAC1A +#define PCIC_PCI1450_DEVID 0xAC1B +#define PCIC_PCI1251_DEVID 0xAC1D +#define PCIC_PCI1211_DEVID 0xAC1E +#define PCIC_PCI1251B_DEVID 0xAC1F +#define PCIC_PCI1260B_DEVID 0xAC30 +#define PCIC_PCI4450_DEVID 0xAC40 +#define PCIC_PCI4410_DEVID 0xAC41 +#define PCIC_PCI4451_DEVID 0xAC42 +#define PCIC_PCI4510_DEVID 0xAC44 +#define PCIC_PCI1410_DEVID 0xAC50 +#define PCIC_PCI1420_DEVID 0xAC51 +#define PCIC_PCI1451_DEVID 0xAC52 +#define PCIC_PCI1421_DEVID 0xAC53 +#define PCIC_PCI1520_DEVID 0xAC55 +#define PCIC_PCI1510_DEVID 0xAC56 + +#define PCIC_TI_PCI1130 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1130_DEVID) +#define PCIC_TYPE_PCI1130 "PCI1130" +#define PCIC_TI_PCI1031 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1031_DEVID) +#define PCIC_TYPE_PCI1031 "PCI1031" +#define PCIC_TI_PCI1131 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1131_DEVID) +#define PCIC_TYPE_PCI1131 "PCI1131" +#define PCIC_TI_PCI1250 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1250_DEVID) +#define PCIC_TYPE_PCI1250 "PCI1250" +#define PCIC_TI_PCI1050 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1050_DEVID) +#define PCIC_TYPE_PCI1050 "PCI1050" +#define PCIC_TI_PCI1221 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1221_DEVID) +#define PCIC_TYPE_PCI1221 "PCI1221" +#define PCIC_TI_PCI1225 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1225_DEVID) +#define PCIC_TYPE_PCI1225 "PCI1225" +#define PCIC_TI_PCI1220 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1220_DEVID) +#define PCIC_TYPE_PCI1220 "PCI1220" +#define PCIC_TI_PCI1260 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1260_DEVID) +#define PCIC_TYPE_PCI1260 "PCI1260" +#define PCIC_TI_PCI1210 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1210_DEVID) +#define PCIC_TYPE_PCI1210 "PCI1210" +#define PCIC_TI_PCI1450 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1450_DEVID) +#define PCIC_TYPE_PCI1450 "PCI1450" +#define PCIC_TI_PCI1251 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1251_DEVID) +#define PCIC_TYPE_PCI1251 "PCI1251" +#define PCIC_TI_PCI1211 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1211_DEVID) +#define PCIC_TYPE_PCI1211 "PCI1211" +#define PCIC_TI_PCI1251B PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1251B_DEVID) +#define PCIC_TYPE_PCI1251B "PCI1251B" +#define PCIC_TI_PCI1260B PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1260B_DEVID) +#define PCIC_TYPE_PCI1260B "PCI1260B" +#define PCIC_TI_PCI4450 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI4450_DEVID) +#define PCIC_TYPE_PCI4450 "PCI4450" +#define PCIC_TI_PCI4410 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI4410_DEVID) +#define PCIC_TYPE_PCI4410 "PCI4410" +#define PCIC_TI_PCI4451 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI4451_DEVID) +#define PCIC_TYPE_PCI4451 "PCI4451" +#define PCIC_TI_PCI4510 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI4510_DEVID) +#define PCIC_TYPE_PCI4510 "PCI4510" +#define PCIC_TI_PCI1410 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1410_DEVID) +#define PCIC_TYPE_PCI1410 "PCI1410" +#define PCIC_TI_PCI1420 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1420_DEVID) +#define PCIC_TYPE_PCI1420 "PCI1420" +#define PCIC_TI_PCI1451 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1451_DEVID) +#define PCIC_TYPE_PCI1451 "PCI1451" +#define PCIC_TI_PCI1421 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1421_DEVID) +#define PCIC_TYPE_PCI1421 "PCI1421" +#define PCIC_TI_PCI1510 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1510_DEVID) +#define PCIC_TYPE_PCI1510 "PCI1510" +#define PCIC_TI_PCI1520 PCI_ID(PCIC_TI_VENDORID, PCIC_PCI1520_DEVID) +#define PCIC_TYPE_PCI1520 "PCI1520" +#define PCIC_TI_VENDOR PCI_ID(PCIC_TI_VENDORID, 0x0000) +#define PCIC_TYPE_TI "PCIC_TI" + +/* O2 Micro */ +#define PCIC_O2_VENDORID 0x1217 +#define PCIC_OZ6912_DEVID 0x6972 +#define PCIC_O2_OZ6912 PCI_ID(PCIC_O2_VENDORID, PCIC_OZ6912_DEVID) +#define PCIC_TYPE_OZ6912 "OZ6912" +#define PCIC_O2MICRO_VENDOR PCI_ID(PCIC_O2_VENDORID, 0x0000) +#define PCIC_TYPE_O2MICRO "O2Micro" + +/* ENE */ +#define PCIC_ENE_VENDORID 0x1524 +#define PCIC_ENE1410_DEVID 0x1410 +#define PCIC_ENE_1410 PCI_ID(PCIC_ENE_VENDORID, PCIC_ENE1410_DEVID) +#define PCIC_TYPE_1410 "ENE1410" +#define PCIC_ENE1420_DEVID 0x1420 +#define PCIC_ENE_1420 PCI_ID(PCIC_ENE_VENDORID, PCIC_ENE1420_DEVID) +#define PCIC_TYPE_1420 "ENE1420" + +/* SMC 34C90 */ +#define PCIC_SMC_VENDORID 0x10B3 +#define PCIC_SMC34C90_DEVID 0xB106 +#define PCIC_SMC_34C90 PCI_ID(PCIC_SMC_VENDORID, PCIC_SMC34C90_DEVID) +#define PCIC_TYPE_34C90 "SMC34c90" + +/* Ricoh RL5CXXX */ +#define PCIC_RICOH_VENDORID 0x1180 +#define PCIC_RL5C466_DEVID 0x0466 +#define PCIC_RL5C475_DEVID 0x0475 +#define PCIC_RL5C476_DEVID 0x0476 +#define PCIC_RL5C477_DEVID 0x0477 +#define PCIC_RL5C478_DEVID 0x0478 +#define PCIC_RICOH_RL5C466 PCI_ID(PCIC_RICOH_VENDORID, PCIC_RL5C466_DEVID) +#define PCIC_RICOH_RL5C475 PCI_ID(PCIC_RICOH_VENDORID, PCIC_RL5C475_DEVID) +#define PCIC_RICOH_RL5C476 PCI_ID(PCIC_RICOH_VENDORID, PCIC_RL5C476_DEVID) +#define PCIC_RICOH_RL5C477 PCI_ID(PCIC_RICOH_VENDORID, PCIC_RL5C477_DEVID) +#define PCIC_RICOH_RL5C478 PCI_ID(PCIC_RICOH_VENDORID, PCIC_RL5C478_DEVID) +#define PCIC_TYPE_RL5C466 "RL5C466" +#define PCIC_TYPE_RL5C475 "RL5C475" +#define PCIC_TYPE_RL5C476 "RL5C476" +#define PCIC_TYPE_RL5C477 "RL5C477" +#define PCIC_TYPE_RL5C478 "RL5C478" +#define PCIC_RICOH_VENDOR PCI_ID(PCIC_RICOH_VENDORID, 0x0000) +#define PCIC_TYPE_RICOH "Ricoh" + +/* Toshiba */ +#define PCIC_TOSHIBA_VENDORID 0x1179 +#define PCIC_TOPIC95_DEVID 0x0603 +#define PCIC_TOSHIBA_TOPIC95 PCI_ID(PCIC_TOSHIBA_VENDORID, \ + PCIC_TOPIC95_DEVID) +#define PCIC_TYPE_TOPIC95 "ToPIC95" +#define PCIC_TOPIC100_DEVID 0x0617 +#define PCIC_TOSHIBA_TOPIC100 PCI_ID(PCIC_TOSHIBA_VENDORID, \ + PCIC_TOPIC100_DEVID) +#define PCIC_TYPE_TOPIC100 "ToPIC100" +#define PCIC_TOSHIBA_VENDOR PCI_ID(PCIC_TOSHIBA_VENDORID, 0x0000) +#define PCIC_TYPE_TOSHIBA "Toshiba" + +/* Generic Yenta compliant chip */ +#define PCIC_TYPE_YENTA "Yenta" + +/* Yenta-compliant vcc register, bits */ +#define PCIC_PRESENT_STATE_REG 0x8 +#define PCIC_VCC_MASK 0xc00 +#define PCIC_VCC_3VCARD 0x800 +#define PCIC_VCC_5VCARD 0x400 + +#define PCIC_16BIT_CARD 0x010 /* 16 bit card */ +#define PCIC_CB_CARD 0x020 /* cardbus card */ +#define PCIC_CINT_IREQ 0x040 /* Interrupt present */ +#define PCIC_NOT_A_CARD 0x080 /* Not a card */ +#define PCIC_DATA_LOST 0x100 /* Data lost */ +#define PCIC_BAD_VCC_REQ 0x200 /* Bad Vcc request */ + + +/* TI Multi Function Terminal selection (MFUNC0 selected as INTA) */ +#define PCIC_TI_MFUNC_SEL 0x22 + +#define PCICPROP_CTL "controller" + +#define PCIC_REV_LEVEL_LOW 0x02 +#define PCIC_REV_LEVEL_HI 0x04 +#define PCIC_REV_C 0x04 +#define PCIC_REV_MASK 0x0f + +#define PCIC_ID_NAME "pcic" +#define PCIC_DEV_NAME "pcic" + +#ifndef DEVI_PCI_NEXNAME +#define DEVI_PCI_NEXNAME "pci" +#endif + +#ifndef DEVI_PCIEX_NEXNAME +#define DEVI_PCIEX_NEXNAME "pciex" +#endif + +/* PCI Class Code stuff */ +#define PCIC_PCI_CLASS(cls, subclass) (((cls) << 16) | ((subclass) << 8)) +#define PCIC_PCI_PCMCIA PCIC_PCI_CLASS(PCI_CLASS_BRIDGE, PCI_BRIDGE_PCMCIA) +#define PCIC_PCI_CARDBUS PCIC_PCI_CLASS(PCI_CLASS_BRIDGE, PCI_BRIDGE_CARDBUS) + +#define PCIC_MEM_AM 0 /* Attribute Memory */ +#define PCIC_MEM_CM 1 /* Common Memory */ + +#define PCS_SUBTYPE_UNKNOWN 0x00 /* haven't processed this yet */ +#define PCS_SUBTYPE_MEMORY 0x01 /* normal memory access */ +#define PCS_SUBTYPE_FAT 0x02 /* DOS floppy (FAT) file system */ + +/* + * For speed calculation, assume a SYSCLK rate of 8.33MHz + * unless our parent tells us otherwise. 8.33MHz is a + * reasonable default for an ISA bus. + */ +#define PCIC_ISA_DEF_SYSCLK 8 /* MHZ */ +#define PCIC_PCI_DEF_SYSCLK 33 /* MHZ */ +#define PCIC_PCI_25MHZ 25 +#define mhztons(c) (1000000 / (uint32_t)((c) * 1000)) +#define PCIC_SYSCLK_25MHZ 25 * 1000 * 1000 +#define PCIC_SYSCLK_33MHZ 33 * 1000 * 1000 + +/* simplify the callback so it looks like straight function call */ +#define PC_CALLBACK (*pcic->pc_callback) + +/* hardware event capabilities -- needs sservice.h */ +#define PCIC_DEFAULT_INT_CAPS (SBM_BVD1|SBM_BVD2|SBM_RDYBSY|SBM_CD) +#define PCIC_DEFAULT_RPT_CAPS (PCIC_DEFAULT_INT_CAPS|SBM_WP) +/* note that we don't support indicators via the PCIC */ +#define PCIC_DEFAULT_CTL_CAPS (0) + +/* format of pcic "ranges" property */ +typedef struct pcic_ranges { + uint32_t pcic_range_caddrhi; + uint32_t pcic_range_caddrlo; + uint32_t pcic_range_paddrhi; + uint32_t pcic_range_paddrmid; + uint32_t pcic_range_paddrlo; + uint32_t pcic_range_size; +} pcic_ranges_t; + +/* debug stuff */ +#if defined(DEBUG) +#define PCIC_DEBUG +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _PCIC_VAR_H */ diff --git a/illumos-x86_64/usr/include/sys/pcie.h b/illumos-x86_64/usr/include/sys/pcie.h new file mode 100644 index 00000000..0cb8c72c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pcie.h @@ -0,0 +1,1097 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2019 Joyent, Inc. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_PCIE_H +#define _SYS_PCIE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * PCI Express capability registers in PCI configuration space relative to + * the PCI Express Capability structure. + */ +#define PCIE_CAP_ID PCI_CAP_ID +#define PCIE_CAP_NEXT_PTR PCI_CAP_NEXT_PTR +#define PCIE_PCIECAP 0x02 /* PCI-e Capability Reg */ +#define PCIE_DEVCAP 0x04 /* Device Capability */ +#define PCIE_DEVCTL 0x08 /* Device Control */ +#define PCIE_DEVSTS 0x0A /* Device Status */ +#define PCIE_LINKCAP 0x0C /* Link Capability */ +#define PCIE_LINKCTL 0x10 /* Link Control */ +#define PCIE_LINKSTS 0x12 /* Link Status */ +#define PCIE_SLOTCAP 0x14 /* Slot Capability */ +#define PCIE_SLOTCTL 0x18 /* Slot Control */ +#define PCIE_SLOTSTS 0x1A /* Slot Status */ +#define PCIE_ROOTCTL 0x1C /* Root Control */ +#define PCIE_ROOTCAP 0x1E /* Root Capabilities */ +#define PCIE_ROOTSTS 0x20 /* Root Status */ +#define PCIE_DEVCAP2 0x24 /* Device Capability 2 */ +#define PCIE_DEVCTL2 0x28 /* Device Control 2 */ +#define PCIE_DEVSTS2 0x2A /* Device Status 2 */ +#define PCIE_LINKCAP2 0x2C /* Link Capability 2 */ +#define PCIE_LINKCTL2 0x30 /* Link Control 2 */ +#define PCIE_LINKSTS2 0x32 /* Link Status 2 */ +#define PCIE_SLOTCAP2 0x34 /* Slot Capability 2 */ +#define PCIE_SLOTCTL2 0x38 /* Slot Control 2 */ +#define PCIE_SLOTSTS2 0x3A /* Slot Status 2 */ + +/* + * PCI-Express Config Space size + */ +#define PCIE_CONF_HDR_SIZE 4096 /* PCIe configuration header size */ + +/* + * PCI-Express Capabilities Register (2 bytes) + */ +#define PCIE_PCIECAP_VER_1_0 0x1 /* PCI-E spec 1.0 */ +#define PCIE_PCIECAP_VER_2_0 0x2 /* PCI-E spec 2.0 */ +#define PCIE_PCIECAP_VER_MASK 0xF /* Version Mask */ +#define PCIE_PCIECAP_DEV_TYPE_PCIE_DEV 0x00 /* PCI-E Endpont Device */ +#define PCIE_PCIECAP_DEV_TYPE_PCI_DEV 0x10 /* "Leg PCI" Endpont Device */ +#define PCIE_PCIECAP_DEV_TYPE_ROOT 0x40 /* Root Port of Root Complex */ +#define PCIE_PCIECAP_DEV_TYPE_UP 0x50 /* Upstream Port of Switch */ +#define PCIE_PCIECAP_DEV_TYPE_DOWN 0x60 /* Downstream Port of Switch */ +#define PCIE_PCIECAP_DEV_TYPE_PCIE2PCI 0x70 /* PCI-E to PCI Bridge */ +#define PCIE_PCIECAP_DEV_TYPE_PCI2PCIE 0x80 /* PCI to PCI-E Bridge */ +#define PCIE_PCIECAP_DEV_TYPE_RC_IEP 0x90 /* RootComplex Integrated Dev */ +#define PCIE_PCIECAP_DEV_TYPE_RC_EC 0xA0 /* RootComplex Evt Collector */ +#define PCIE_PCIECAP_DEV_TYPE_MASK 0xF0 /* Device/Port Type Mask */ +#define PCIE_PCIECAP_SLOT_IMPL 0x100 /* Slot Impl vs Integrated */ +#define PCIE_PCIECAP_INT_MSG_NUM 0x3E00 /* Interrupt Message Number */ + +/* + * Device Capabilities Register (4 bytes) + */ +#define PCIE_DEVCAP_MAX_PAYLOAD_128 0x0 +#define PCIE_DEVCAP_MAX_PAYLOAD_256 0x1 +#define PCIE_DEVCAP_MAX_PAYLOAD_512 0x2 +#define PCIE_DEVCAP_MAX_PAYLOAD_1024 0x3 +#define PCIE_DEVCAP_MAX_PAYLOAD_2048 0x4 +#define PCIE_DEVCAP_MAX_PAYLOAD_4096 0x5 +#define PCIE_DEVCAP_MAX_PAYLOAD_MASK 0x7 /* Max Payload Size Supported */ + +#define PCIE_DEVCAP_PHTM_FUNC_NONE 0x00 /* No Function # bits used */ +#define PCIE_DEVCAP_PHTM_FUNC_ONE 0x08 /* First most sig. bit used */ +#define PCIE_DEVCAP_PHTM_FUNC_TWO 0x10 /* First 2 most sig bit used */ +#define PCIE_DEVCAP_PHTM_FUNC_THREE 0x18 /* All 3 bits used */ +#define PCIE_DEVCAP_PHTM_FUNC_MASK 0x18 /* Phantom Func Supported */ + +#define PCIE_DEVCAP_EXT_TAG_5BIT 0x00 /* 5-Bit Tag Field Supported */ +#define PCIE_DEVCAP_EXT_TAG_8BIT 0x20 /* 8-Bit Tag Field Supported */ +#define PCIE_DEVCAP_EXT_TAG_MASK 0x20 /* Ext. Tag Field Supported */ + +#define PCIE_DEVCAP_EP_L0S_LAT_MIN 0x000 /* < 64 ns */ +#define PCIE_DEVCAP_EP_L0S_LAT_64ns 0x040 /* 64 ns - 128 ns */ +#define PCIE_DEVCAP_EP_L0S_LAT_128ns 0x080 /* 128 ns - 256 ns */ +#define PCIE_DEVCAP_EP_L0S_LAT_256ns 0x0C0 /* 256 ns - 512 ns */ +#define PCIE_DEVCAP_EP_L0S_LAT_512ns 0x100 /* 512 ns - 1 us */ +#define PCIE_DEVCAP_EP_L0S_LAT_1us 0x140 /* 1 us - 2 us */ +#define PCIE_DEVCAP_EP_L0S_LAT_2us 0x180 /* 2 us - 4 us */ +#define PCIE_DEVCAP_EP_L0S_LAT_MAX 0x1C0 /* > 4 us */ +#define PCIE_DEVCAP_EP_L0S_LAT_MASK 0x1C0 /* EP L0s Accetable Latency */ + +#define PCIE_DEVCAP_EP_L1_LAT_MIN 0x000 /* < 1 us */ +#define PCIE_DEVCAP_EP_L1_LAT_1us 0x140 /* 1 us - 2 us */ +#define PCIE_DEVCAP_EP_L1_LAT_2us 0x180 /* 2 us - 4 us */ +#define PCIE_DEVCAP_EP_L1_LAT_4us 0x140 /* 4 us - 8 us */ +#define PCIE_DEVCAP_EP_L1_LAT_8us 0x180 /* 8 us - 16 us */ +#define PCIE_DEVCAP_EP_L1_LAT_16us 0x140 /* 16 us - 32 us */ +#define PCIE_DEVCAP_EP_L1_LAT_32us 0x180 /* 32 us - 64 us */ +#define PCIE_DEVCAP_EP_L1_LAT_MAX 0x1C0 /* > 64 us */ +#define PCIE_DEVCAP_EP_L1_LAT_MASK 0x700 /* EP L1 Accetable Latency */ + +/* + * As of PCIe 2.x these three bits are now undefined. + */ +#define PCIE_DEVCAP_ATTN_BUTTON 0x1000 /* Attention Button Present */ +#define PCIE_DEVCAP_ATTN_INDICATOR 0x2000 /* Attn Indicator Present */ +#define PCIE_DEVCAP_PWR_INDICATOR 0x4000 /* Power Indicator Present */ + +#define PCIE_DEVCAP_ROLE_BASED_ERR_REP 0x8000 /* Role Based Error Reporting */ + +#define PCIE_DEVCAP_PLMT_VAL_SHIFT 18 /* Power Limit Value Shift */ +#define PCIE_DEVCAP_PLMT_VAL_MASK 0xFF /* Power Limit Value Mask */ + +#define PCIE_DEVCAP_PLMT_SCL_1_BY_1 0x0000000 /* 1x Scale */ +#define PCIE_DEVCAP_PLMT_SCL_1_BY_10 0x4000000 /* 0.1x Scale */ +#define PCIE_DEVCAP_PLMT_SCL_1_BY_100 0x8000000 /* 0.01x Scale */ +#define PCIE_DEVCAP_PLMT_SCL_1_BY_1000 0xC000000 /* 0.001x Scale */ +#define PCIE_DEVCAP_PLMT_SCL_MASK 0xC000000 /* Power Limit Scale */ + +#define PCIE_DEVCAP_FLR 0x10000000 /* Function Level Reset */ + +/* + * Device Control Register (2 bytes) + */ +#define PCIE_DEVCTL_CE_REPORTING_EN 0x1 /* Correctable Error Enable */ +#define PCIE_DEVCTL_NFE_REPORTING_EN 0x2 /* Non-Fatal Error Enable */ +#define PCIE_DEVCTL_FE_REPORTING_EN 0x4 /* Fatal Error Enable */ +#define PCIE_DEVCTL_UR_REPORTING_EN 0x8 /* Unsupported Request Enable */ +#define PCIE_DEVCTL_ERR_MASK 0xF /* All of the above bits */ + +#define PCIE_DEVCTL_RO_EN 0x10 /* Enable Relaxed Ordering */ + +#define PCIE_DEVCTL_MAX_PAYLOAD_128 0x00 +#define PCIE_DEVCTL_MAX_PAYLOAD_256 0x20 +#define PCIE_DEVCTL_MAX_PAYLOAD_512 0x40 +#define PCIE_DEVCTL_MAX_PAYLOAD_1024 0x60 +#define PCIE_DEVCTL_MAX_PAYLOAD_2048 0x80 +#define PCIE_DEVCTL_MAX_PAYLOAD_4096 0xA0 +#define PCIE_DEVCTL_MAX_PAYLOAD_MASK 0xE0 /* Max_Payload_Size */ +#define PCIE_DEVCTL_MAX_PAYLOAD_SHIFT 0x5 + +#define PCIE_DEVCTL_EXT_TAG_FIELD_EN 0x100 /* Extended Tag Field Enable */ +#define PCIE_DEVCTL_PHTM_FUNC_EN 0x200 /* Phantom Functions Enable */ +#define PCIE_DEVCTL_AUX_POWER_PM_EN 0x400 /* Auxiliary Power PM Enable */ +#define PCIE_DEVCTL_ENABLE_NO_SNOOP 0x800 /* Enable No Snoop */ + +#define PCIE_DEVCTL_MAX_READ_REQ_128 0x0000 +#define PCIE_DEVCTL_MAX_READ_REQ_256 0x1000 +#define PCIE_DEVCTL_MAX_READ_REQ_512 0x2000 +#define PCIE_DEVCTL_MAX_READ_REQ_1024 0x3000 +#define PCIE_DEVCTL_MAX_READ_REQ_2048 0x4000 +#define PCIE_DEVCTL_MAX_READ_REQ_4096 0x5000 +#define PCIE_DEVCTL_MAX_READ_REQ_MASK 0x7000 /* Max_Read_Request_Size */ +#define PCIE_DEVCTL_MAX_READ_REQ_SHIFT 0xC + +#define PCIE_DEVCTL_BRIDGE_RETRY 0x8000 /* Bridge can return CRS */ +#define PCIE_DEVCTL_INITIATE_FLR 0x8000 /* Start Function Level Reset */ + +/* + * Device Status Register (2 bytes) + */ +#define PCIE_DEVSTS_CE_DETECTED 0x1 /* Correctable Error Detected */ +#define PCIE_DEVSTS_NFE_DETECTED 0x2 /* Non Fatal Error Detected */ +#define PCIE_DEVSTS_FE_DETECTED 0x4 /* Fatal Error Detected */ +#define PCIE_DEVSTS_UR_DETECTED 0x8 /* Unsupported Req Detected */ +#define PCIE_DEVSTS_AUX_POWER 0x10 /* AUX Power Detected */ +#define PCIE_DEVSTS_TRANS_PENDING 0x20 /* Transactions Pending */ +#define PCIE_DEVSTS_EPR_DETECTED 0x40 /* Emergency Power Reduction */ + +/* + * Link Capability Register (4 bytes) + */ +#define PCIE_LINKCAP_MAX_SPEED_2_5 0x1 /* 2.5 GT/s Speed */ +/* + * In version 2 of PCI express, this indicated that both 5.0 GT/s and 2.5 GT/s + * speeds were supported. The use of this as the maximum link speed was added + * with PCIe v3. + */ +#define PCIE_LINKCAP_MAX_SPEED_5 0x2 /* 5.0 GT/s Speed */ +#define PCIE_LINKCAP_MAX_SPEED_8 0x3 /* 8.0 GT/s Speed */ +#define PCIE_LINKCAP_MAX_SPEED_16 0x4 /* 16.0 GT/s Speed */ +#define PCIE_LINKCAP_MAX_SPEED_32 0x5 /* 32.0 GT/s Speed */ +#define PCIE_LINKCAP_MAX_SPEED_64 0x6 /* 64.0 GT/s Speed */ +#define PCIE_LINKCAP_MAX_SPEED_MASK 0xF /* Maximum Link Speed */ +#define PCIE_LINKCAP_MAX_WIDTH_X1 0x010 +#define PCIE_LINKCAP_MAX_WIDTH_X2 0x020 +#define PCIE_LINKCAP_MAX_WIDTH_X4 0x040 +#define PCIE_LINKCAP_MAX_WIDTH_X8 0x080 +#define PCIE_LINKCAP_MAX_WIDTH_X12 0x0C0 +#define PCIE_LINKCAP_MAX_WIDTH_X16 0x100 +#define PCIE_LINKCAP_MAX_WIDTH_X32 0x200 +#define PCIE_LINKCAP_MAX_WIDTH_MASK 0x3f0 /* Maximum Link Width */ + +#define PCIE_LINKCAP_ASPM_SUP_L0S 0x400 /* L0s Entry Supported */ +#define PCIE_LINKCAP_ASPM_SUP_L1 0x800 /* L1 Entry Supported */ +#define PCIE_LINKCAP_ASPM_SUP_L0S_L1 0xC00 /* L0s abd L1 Supported */ +#define PCIE_LINKCAP_ASPM_SUP_MASK 0xC00 /* ASPM Support */ + +#define PCIE_LINKCAP_L0S_EXIT_LAT_MIN 0x0000 /* < 64 ns */ +#define PCIE_LINKCAP_L0S_EXIT_LAT_64ns 0x1000 /* 64 ns - 128 ns */ +#define PCIE_LINKCAP_L0S_EXIT_LAT_128ns 0x2000 /* 128 ns - 256 ns */ +#define PCIE_LINKCAP_L0S_EXIT_LAT_256ns 0x3000 /* 256 ns - 512 ns */ +#define PCIE_LINKCAP_L0S_EXIT_LAT_512ns 0x4000 /* 512 ns - 1 us */ +#define PCIE_LINKCAP_L0S_EXIT_LAT_1us 0x5000 /* 1 us - 2 us */ +#define PCIE_LINKCAP_L0S_EXIT_LAT_2us 0x6000 /* 2 us - 4 us */ +#define PCIE_LINKCAP_L0S_EXIT_LAT_MAX 0x7000 /* > 4 us */ +#define PCIE_LINKCAP_L0S_EXIT_LAT_MASK 0x7000 /* L0s Exit Latency */ + +#define PCIE_LINKCAP_L1_EXIT_LAT_MIN 0x00000 /* < 1 us */ +#define PCIE_LINKCAP_L1_EXIT_LAT_1us 0x08000 /* 1 us - 2 us */ +#define PCIE_LINKCAP_L1_EXIT_LAT_2us 0x10000 /* 2 us - 4 us */ +#define PCIE_LINKCAP_L1_EXIT_LAT_4us 0x18000 /* 4 us - 8 us */ +#define PCIE_LINKCAP_L1_EXIT_LAT_8us 0x20000 /* 8 us - 16 us */ +#define PCIE_LINKCAP_L1_EXIT_LAT_16us 0x28000 /* 16 us - 32 us */ +#define PCIE_LINKCAP_L1_EXIT_LAT_32us 0x30000 /* 32 us - 64 us */ +#define PCIE_LINKCAP_L1_EXIT_LAT_MAX 0x38000 /* > 64 us */ +#define PCIE_LINKCAP_L1_EXIT_LAT_MASK 0x38000 /* L1 Exit Latency */ + +#define PCIE_LINKCAP_CLOCK_POWER_MGMT 0x40000 /* Clock Power Management */ +#define PCIE_LINKCAP_SDER_CAP 0x80000 /* Surprise Down Err report */ +#define PCIE_LINKCAP_DLL_ACTIVE_REP_CAPABLE 0x100000 /* DLL Active */ + /* Capable bit */ +#define PCIE_LINKCAP_LINK_BW_NOTIFY_CAP 0x200000 /* Link Bandwidth Notify Cap */ +#define PCIE_LINKCAP_ASPM_OPTIONAL 0x400000 /* ASPM Opt. Comp. */ + +#define PCIE_LINKCAP_PORT_NUMBER 0xFF000000 /* Port Number */ +#define PCIE_LINKCAP_PORT_NUMBER_SHIFT 24 /* Port Number Shift */ +#define PCIE_LINKCAP_PORT_NUMBER_MASK 0xFF /* Port Number Mask */ + +/* + * Link Control Register (2 bytes) + */ +#define PCIE_LINKCTL_ASPM_CTL_DIS 0x0 /* ASPM Disable */ +#define PCIE_LINKCTL_ASPM_CTL_L0S 0x1 /* ASPM L0s only */ +#define PCIE_LINKCTL_ASPM_CTL_L1 0x2 /* ASPM L1 only */ +#define PCIE_LINKCTL_ASPM_CTL_L0S_L1 0x3 /* ASPM L0s and L1 only */ +#define PCIE_LINKCTL_ASPM_CTL_MASK 0x3 /* ASPM Control */ + +#define PCIE_LINKCTL_RCB_64_BYTE 0x0 /* 64 Byte */ +#define PCIE_LINKCTL_RCB_128_BYTE 0x8 /* 128 Byte */ +#define PCIE_LINKCTL_RCB_MASK 0x8 /* Read Completion Boundary */ + +#define PCIE_LINKCTL_LINK_DISABLE 0x10 /* Link Disable */ +#define PCIE_LINKCTL_RETRAIN_LINK 0x20 /* Retrain Link */ +#define PCIE_LINKCTL_COMMON_CLK_CFG 0x40 /* Common Clock Configuration */ +#define PCIE_LINKCTL_EXT_SYNCH 0x80 /* Extended Synch */ +#define PCIE_LINKCTL_CLOCK_POWER_MGMT 0x100 /* Enable Clock Power Mgmt. */ +#define PCIE_LINKCTL_HW_WIDTH_DISABLE 0x200 /* hw auto width disable */ +#define PCIE_LINKCTL_LINK_BW_INTR_EN 0x400 /* Link bw mgmt intr */ +#define PCIE_LINKCTL_LINK_AUTO_BW_INTR_EN 0x800 /* Auto bw intr */ + +#define PCI_LINKCTRL_DRS_SIG_CTRL_NO_REP 0x00 +#define PCI_LINKCTRL_DRS_SIG_CTRL_IE 0x4000 +#define PCI_LINKCTRL_DRS_SIG_CTRL_DRS_FRS 0x8000 +#define PCIE_LINKCTL_DRS_SIG_CTRL_MASK 0xC000 /* DRS Signaling Control */ + +/* + * Link Status Register (2 bytes) + */ +#define PCIE_LINKSTS_SPEED_2_5 0x1 /* 2.5 GT/s Link Speed */ +#define PCIE_LINKSTS_SPEED_5 0x2 /* 5.0 GT/s Link Speed */ +#define PCIE_LINKSTS_SPEED_8 0x3 /* 8.0 GT/s Link Speed */ +#define PCIE_LINKSTS_SPEED_16 0x4 /* 16.0 GT/s Link Speed */ +#define PCIE_LINKSTS_SPEED_32 0x5 /* 32.0 GT/s Link Speed */ +#define PCIE_LINKSTS_SPEED_64 0x6 /* 64.0 GT/s Link Speed */ +#define PCIE_LINKSTS_SPEED_MASK 0xF /* Link Speed */ + +#define PCIE_LINKSTS_NEG_WIDTH_X1 0x010 +#define PCIE_LINKSTS_NEG_WIDTH_X2 0x020 +#define PCIE_LINKSTS_NEG_WIDTH_X4 0x040 +#define PCIE_LINKSTS_NEG_WIDTH_X8 0x080 +#define PCIE_LINKSTS_NEG_WIDTH_X12 0x0C0 +#define PCIE_LINKSTS_NEG_WIDTH_X16 0x100 +#define PCIE_LINKSTS_NEG_WIDTH_X32 0x200 +#define PCIE_LINKSTS_NEG_WIDTH_MASK 0x3F0 /* Negotiated Link Width */ + +/* This bit is undefined as of PCIe 2.x */ +#define PCIE_LINKSTS_TRAINING_ERROR 0x400 /* Training Error */ +#define PCIE_LINKSTS_LINK_TRAINING 0x800 /* Link Training */ +#define PCIE_LINKSTS_SLOT_CLK_CFG 0x1000 /* Slot Clock Configuration */ +#define PCIE_LINKSTS_DLL_LINK_ACTIVE 0x2000 /* DLL Link Active */ +#define PCIE_LINKSTS_LINK_BW_MGMT 0x4000 /* Link bw mgmt status */ +#define PCIE_LINKSTS_AUTO_BW 0x8000 /* Link auto BW status */ + +/* + * Slot Capability Register (4 bytes) + */ +#define PCIE_SLOTCAP_ATTN_BUTTON 0x1 /* Attention Button Present */ +#define PCIE_SLOTCAP_POWER_CONTROLLER 0x2 /* Power Controller Present */ +#define PCIE_SLOTCAP_MRL_SENSOR 0x4 /* MRL Sensor Present */ +#define PCIE_SLOTCAP_ATTN_INDICATOR 0x8 /* Attn Indicator Present */ +#define PCIE_SLOTCAP_PWR_INDICATOR 0x10 /* Power Indicator Present */ +#define PCIE_SLOTCAP_HP_SURPRISE 0x20 /* Hot-Plug Surprise */ +#define PCIE_SLOTCAP_HP_CAPABLE 0x40 /* Hot-Plug Capable */ + +#define PCIE_SLOTCAP_PLMT_VAL_SHIFT 7 /* Slot Pwr Limit Value Shift */ +#define PCIE_SLOTCAP_PLMT_VAL_MASK 0xFF /* Slot Pwr Limit Value */ + +#define PCIE_SLOTCAP_PLMT_SCL_1_BY_1 0x00000 /* 1x Scale */ +#define PCIE_SLOTCAP_PLMT_SCL_1_BY_10 0x08000 /* 0.1x Scale */ +#define PCIE_SLOTCAP_PLMT_SCL_1_BY_100 0x10000 /* 0.01x Scale */ +#define PCIE_SLOTCAP_PLMT_SCL_1_BY_1000 0x18000 /* 0.001x Scale */ +#define PCIE_SLOTCAP_PLMT_SCL_MASK 0x18000 /* Slot Power Limit Scale */ +#define PCIE_SLOTCAP_EMI_LOCK_PRESENT 0x20000 /* EMI Lock Present */ +#define PCIE_SLOTCAP_NO_CMD_COMP_SUPP 0x40000 /* No Command Comp. Supported */ + +#define PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT 19 /* Physical Slot Num Shift */ +#define PCIE_SLOTCAP_PHY_SLOT_NUM_MASK 0x1FFF /* Physical Slot Num Mask */ + +#define PCIE_SLOTCAP_PHY_SLOT_NUM(reg) \ + (((reg) >> PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT) & \ + PCIE_SLOTCAP_PHY_SLOT_NUM_MASK) + +/* + * Slot Control Register (2 bytes) + */ +#define PCIE_SLOTCTL_ATTN_BTN_EN 0x1 /* Attn Button Pressed Enable */ +#define PCIE_SLOTCTL_PWR_FAULT_EN 0x2 /* Pwr Fault Detected Enable */ +#define PCIE_SLOTCTL_MRL_SENSOR_EN 0x4 /* MRL Sensor Changed Enable */ +#define PCIE_SLOTCTL_PRESENCE_CHANGE_EN 0x8 /* Presence Detect Changed En */ +#define PCIE_SLOTCTL_CMD_INTR_EN 0x10 /* CMD Completed Interrupt En */ +#define PCIE_SLOTCTL_HP_INTR_EN 0x20 /* Hot-Plug Interrupt Enable */ +#define PCIE_SLOTCTL_PWR_CONTROL 0x0400 /* Power controller Control */ +#define PCIE_SLOTCTL_EMI_LOCK_CONTROL 0x0800 /* EMI Lock control */ +#define PCIE_SLOTCTL_DLL_STATE_EN 0x1000 /* DLL State Changed En */ +#define PCIE_SLOTCTL_AUTO_SLOT_PL_DIS 0x2000 /* Auto Slot Power Limit Dis */ +#define PCIE_SLOTCTL_INB_PRES_DET_DIS 0x4000 /* Inband Presence Detect Dis */ +#define PCIE_SLOTCTL_ATTN_INDICATOR_MASK 0x00C0 /* Attn Indicator mask */ +#define PCIE_SLOTCTL_PWR_INDICATOR_MASK 0x0300 /* Power Indicator mask */ +#define PCIE_SLOTCTL_INTR_MASK 0x103f /* Supported intr mask */ + +/* State values for the Power and Attention Indicators */ +#define PCIE_SLOTCTL_INDICATOR_STATE_ON 0x1 /* indicator ON */ +#define PCIE_SLOTCTL_INDICATOR_STATE_BLINK 0x2 /* indicator BLINK */ +#define PCIE_SLOTCTL_INDICATOR_STATE_OFF 0x3 /* indicator OFF */ + +/* + * Macros to set/get the state of Power and Attention Indicators + * in the PCI Express Slot Control Register. + */ +#define pcie_slotctl_pwr_indicator_get(reg) \ + (((reg) & PCIE_SLOTCTL_PWR_INDICATOR_MASK) >> 8) +#define pcie_slotctl_attn_indicator_get(ctrl) \ + (((ctrl) & PCIE_SLOTCTL_ATTN_INDICATOR_MASK) >> 6) +#define pcie_slotctl_attn_indicator_set(ctrl, v)\ + (((ctrl) & ~PCIE_SLOTCTL_ATTN_INDICATOR_MASK) | ((v) << 6)) +#define pcie_slotctl_pwr_indicator_set(ctrl, v)\ + (((ctrl) & ~PCIE_SLOTCTL_PWR_INDICATOR_MASK) | ((v) << 8)) + +/* + * Slot Status register (2 bytes) + */ +#define PCIE_SLOTSTS_ATTN_BTN_PRESSED 0x1 /* Attention Button Pressed */ +#define PCIE_SLOTSTS_PWR_FAULT_DETECTED 0x2 /* Power Fault Detected */ +#define PCIE_SLOTSTS_MRL_SENSOR_CHANGED 0x4 /* MRL Sensor Changed */ +#define PCIE_SLOTSTS_PRESENCE_CHANGED 0x8 /* Presence Detect Changed */ +#define PCIE_SLOTSTS_COMMAND_COMPLETED 0x10 /* Command Completed */ +#define PCIE_SLOTSTS_MRL_SENSOR_OPEN 0x20 /* MRL Sensor Open */ +#define PCIE_SLOTSTS_PRESENCE_DETECTED 0x40 /* Card Present in slot */ +#define PCIE_SLOTSTS_EMI_LOCK_SET 0x0080 /* EMI Lock set */ +#define PCIE_SLOTSTS_DLL_STATE_CHANGED 0x0100 /* DLL State Changed */ +#define PCIE_SLOTSTS_STATUS_EVENTS 0x11f /* Supported events */ + +/* + * Root Control Register (2 bytes) + */ +#define PCIE_ROOTCTL_SYS_ERR_ON_CE_EN 0x1 /* Sys Err on Cor Err Enable */ +#define PCIE_ROOTCTL_SYS_ERR_ON_NFE_EN 0x2 /* Sys Err on NF Err Enable */ +#define PCIE_ROOTCTL_SYS_ERR_ON_FE_EN 0x4 /* Sys Err on Fatal Err En */ +#define PCIE_ROOTCTL_PME_INTERRUPT_EN 0x8 /* PME Interrupt Enable */ +#define PCIE_ROOTCTL_CRS_SW_VIS_EN 0x10 /* CRS SW Visibility EN */ + +/* + * Root Capabilities register (2 bytes) + */ +#define PCIE_ROOTCAP_CRS_SW_VIS 0x01 /* CRS SW Visible */ + +/* + * Root Status Register (4 bytes) + */ +#define PCIE_ROOTSTS_PME_REQ_ID_SHIFT 0 /* PME Requestor ID */ +#define PCIE_ROOTSTS_PME_REQ_ID_MASK 0xFFFF /* PME Requestor ID */ + +#define PCIE_ROOTSTS_PME_STATUS 0x10000 /* PME Status */ +#define PCIE_ROOTSTS_PME_PENDING 0x20000 /* PME Pending */ + +/* + * Device Capabilities 2 Register (4 bytes) + */ +#define PCIE_DEVCAP2_COM_TO_RANGE_MASK 0xF +#define PCIE_DEVCAP2_COM_TO_DISABLE 0x10 +#define PCIE_DEVCAP2_ARI_FORWARD 0x20 +#define PCIE_DEVCAP2_ATOMICOP_ROUTING 0x40 +#define PCIE_DEVCAP2_32_ATOMICOP_COMPL 0x80 +#define PCIE_DEVCAP2_64_ATOMICOP_COMPL 0x100 +#define PCIE_DEVCAP2_128_CAS_COMPL 0x200 +#define PCIE_DEVCAP2_NO_RO_PR_PR_PASS 0x400 +#define PCIE_DEVCAP2_LTR_MECH 0x800 +#define PCIE_DEVCAP2_TPH_COMP_SHIFT 12 +#define PCIE_DEVCAP2_TPH_COMP_MASK 0x3 +#define PCIE_DEVCAP2_LNSYS_CLS_SHIFT 14 +#define PCIE_DEVCAP2_LNSYS_CLS_MASK 0x3 +#define PCIE_DEVCAP2_10B_TAG_COMP_SUP 0x10000 +#define PCIE_DEVCAP2_10B_TAG_REQ_SUP 0x20000 +#define PCIE_DEVCAP2_OBFF_SHIFT 18 +#define PCIE_DEVCAP2_OBFF_MASK 0x3 +#define PCIE_DEVCAP2_EXT_FMT_FIELD 0x100000 +#define PCIE_DEVCAP2_END_END_TLP_PREFIX 0x200000 +#define PCIE_DEVCAP2_MAX_END_END_SHIFT 22 +#define PCIE_DEVCAP2_MAX_END_END_MASK 0x3 +#define PCIE_DEVCAP2_EPR_SUP_SHIFT 24 +#define PCIE_DEVCAP2_EPR_SUP_MASK 0x3 +#define PCIE_DEVCAP2_EPR_INIT_REQ 0x4000000 +#define PCIE_DEVCAP2_FRS_SUP 0x80000000 + +/* + * Device Control 2 Register (2 bytes) + */ +#define PCIE_DEVCTL2_COM_TO_RANGE_MASK 0xf +#define PCIE_DEVCTL2_COM_TO_RANGE_0 0x0 +#define PCIE_DEVCTL2_COM_TO_RANGE_1 0x1 +#define PCIE_DEVCTL2_COM_TO_RANGE_2 0x2 +#define PCIE_DEVCTL2_COM_TO_RANGE_3 0x5 +#define PCIE_DEVCTL2_COM_TO_RANGE_4 0x6 +#define PCIE_DEVCTL2_COM_TO_RANGE_5 0x9 +#define PCIE_DEVCTL2_COM_TO_RANGE_6 0xa +#define PCIE_DEVCTL2_COM_TO_RANGE_7 0xd +#define PCIE_DEVCTL2_COM_TO_RANGE_8 0xe +#define PCIE_DEVCTL2_COM_TO_DISABLE 0x10 +#define PCIE_DEVCTL2_ARI_FORWARD_EN 0x20 +#define PCIE_DEVCTL2_ATOMICOP_REQ_EN 0x40 +#define PCIE_DEVCTL2_ATOMICOP_EGRS_BLK 0x80 +#define PCIE_DEVCTL2_IDO_REQ_EN 0x100 +#define PCIE_DEVCTL2_IDO_COMPL_EN 0x200 +#define PCIE_DEVCTL2_LTR_MECH_EN 0x400 +#define PCIE_DEVCTL2_EPR_REQ 0x800 +#define PCIE_DEVCTL2_10B_TAG_REQ_EN 0x1000 +#define PCIE_DEVCTL2_OBFF_MASK 0x6000 +#define PCIE_DEVCTL2_OBFF_DISABLE 0x0000 +#define PCIE_DEVCTL2_OBFF_EN_VARA 0x2000 +#define PCIE_DEVCTL2_OBFF_EN_VARB 0x4000 +#define PCIE_DEVCTL2_OBFF_EN_WAKE 0x6000 +#define PCIE_DEVCTL2_END_END_TLP_PREFIX 0x8000 + + +/* + * Link Capabilities 2 Register (4 bytes) + */ +#define PCIE_LINKCAP2_SPEED_2_5 0x02 +#define PCIE_LINKCAP2_SPEED_5 0x04 +#define PCIE_LINKCAP2_SPEED_8 0x08 +#define PCIE_LINKCAP2_SPEED_16 0x10 +#define PCIE_LINKCAP2_SPEED_32 0x20 +#define PCIE_LINKCAP2_SPEED_64 0x40 +#define PCIE_LINKCAP2_SPEED_MASK 0xfe +#define PCIE_LINKCAP2_CROSSLINK 0x100 +#define PCIE_LINKCAP2_LSKP_OSGSS_MASK 0xfe00 +#define PCIE_LINKCAP2_LKSP_OSGSS_2_5 0x0200 +#define PCIE_LINKCAP2_LKSP_OSGSS_5 0x0400 +#define PCIE_LINKCAP2_LKSP_OSGSS_8 0x0800 +#define PCIE_LINKCAP2_LKSP_OSGSS_16 0x1000 +#define PCIE_LINKCAP2_LKSP_OSGSS_32 0x2000 +#define PCIE_LINKCAP2_LKSP_OSGSS_64 0x4000 +#define PCIE_LINKCAP2_LKSP_OSRSS_MASK 0x7f0000 +#define PCIE_LINKCAP2_LKSP_OSRSS_2_5 0x010000 +#define PCIE_LINKCAP2_LKSP_OSRSS_5 0x020000 +#define PCIE_LINKCAP2_LKSP_OSRSS_8 0x040000 +#define PCIE_LINKCAP2_LKSP_OSRSS_16 0x080000 +#define PCIE_LINKCAP2_LKSP_OSRSS_32 0x100000 +#define PCIE_LINKCAP2_LKSP_OSRSS_64 0x200000 +#define PCIE_LINKCAP2_RTPD_SUP 0x800000 +#define PCIE_LINKCAP2_TRTPD_SUP 0x01000000 +#define PCIE_LINKCAP2_DRS 0x80000000 + +/* + * Link Control 2 Register (2 bytes) + */ + +#define PCIE_LINKCTL2_TARGET_SPEED_2_5 0x1 /* 2.5 GT/s Speed */ +#define PCIE_LINKCTL2_TARGET_SPEED_5 0x2 /* 5.0 GT/s Speed */ +#define PCIE_LINKCTL2_TARGET_SPEED_8 0x3 /* 8.0 GT/s Speed */ +#define PCIE_LINKCTL2_TARGET_SPEED_16 0x4 /* 16.0 GT/s Speed */ +#define PCIE_LINKCTL2_TARGET_SPEED_32 0x5 /* 32.0 GT/s Speed */ +#define PCIE_LINKCTL2_TARGET_SPEED_64 0x6 /* 64.0 GT/s Speed */ +#define PCIE_LINKCTL2_TARGET_SPEED_MASK 0x000f +#define PICE_LINKCTL2_ENTER_COMPLIANCE 0x0010 +#define PCIE_LINKCTL2_HW_AUTO_SPEED_DIS 0x0020 +#define PCIE_LINKCTL2_SELECT_DEEMPH 0x0040 +#define PCIE_LINKCTL2_TX_MARGIN_MASK 0x0380 +#define PCIE_LINKCTL2_ENTER_MOD_COMP 0x0400 +#define PCIE_LINKCTL2_COMP_SOS 0x0800 +#define PCIE_LINKCTL2_COMP_DEEMPM_MASK 0xf000 + +/* + * Link Status 2 Register (2 bytes) + */ +#define PCIE_LINKSTS2_CUR_DEEMPH 0x0001 +#define PCIE_LINKSTS2_EQ8GT_COMP 0x0002 +#define PCIE_LINKSTS2_EQ8GT_P1_SUC 0x0004 +#define PCIE_LINKSTS2_EQ8GT_P2_SUC 0x0008 +#define PCIE_LINKSTS2_EQ8GT_P3_SUC 0x0010 +#define PCIE_LINKSTS2_LINK_EQ_REQ 0x0020 +#define PCIE_LINKSTS2_RETIMER_PRES_DET 0x0040 +#define PCIE_LINKSTS2_2RETIMER_PRES_DET 0x0080 +#define PCIE_LINKSTS2_XLINK_RES 0x0300 +#define PCIE_LINKSTS2_DS_COMP_PRES_MASK 0x7000 +#define PCIE_LINKSTS2_DRS_MSG_RX 0x8000 + +/* + * Slot Capabilities 2 Register (4 bytes) + */ +#define PCIE_SLOTCAP2_INB_PRES_DET_DIS_SUP 0x1 + +/* + * PCI-Express Enhanced Capabilities Link Entry Bit Offsets + */ +#define PCIE_EXT_CAP 0x100 /* Base Address of Ext Cap */ + +#define PCIE_EXT_CAP_ID_SHIFT 0 /* PCI-e Ext Cap ID */ +#define PCIE_EXT_CAP_ID_MASK 0xFFFF +#define PCIE_EXT_CAP_VER_SHIFT 16 /* PCI-e Ext Cap Ver */ +#define PCIE_EXT_CAP_VER_MASK 0xF +#define PCIE_EXT_CAP_NEXT_PTR_SHIFT 20 /* PCI-e Ext Cap Next Ptr */ +#define PCIE_EXT_CAP_NEXT_PTR_MASK 0xFFF + +#define PCIE_EXT_CAP_NEXT_PTR_NULL 0x0 +#define PCIE_EXT_CAP_MAX_PTR 0x3c0 /* max. number of caps */ + +/* + * PCI-Express Enhanced Capability Identifier Values + */ +#define PCIE_EXT_CAP_ID_AER 0x1 /* Advanced Error Handling */ +#define PCIE_EXT_CAP_ID_VC 0x2 /* Virtual Channel, no MFVC */ +#define PCIE_EXT_CAP_ID_SER 0x3 /* Serial Number */ +#define PCIE_EXT_CAP_ID_PWR_BUDGET 0x4 /* Power Budgeting */ +#define PCIE_EXT_CAP_ID_RC_LINK_DECL 0x5 /* RC Link Declaration */ +#define PCIE_EXT_CAP_ID_RC_INT_LINKCTRL 0x6 /* RC Internal Link Control */ +#define PCIE_EXT_CAP_ID_RC_EVNT_CEA 0x7 /* RC Event Collector */ + /* Endpoint Association */ +#define PCIE_EXT_CAP_ID_MFVC 0x8 /* Multi-func Virtual Channel */ +#define PCIE_EXT_CAP_ID_VC_WITH_MFVC 0x9 /* Virtual Channel w/ MFVC */ +#define PCIE_EXT_CAP_ID_RCRB 0xA /* Root Complex Register Blck */ +#define PCIE_EXT_CAP_ID_VS 0xB /* Vendor Spec Extended Cap */ +#define PCIE_EXT_CAP_ID_CAC 0xC /* Config Access Correlation */ +#define PCIE_EXT_CAP_ID_ACS 0xD /* Access Control Services */ +#define PCIE_EXT_CAP_ID_ARI 0xE /* Alternative Routing ID */ +#define PCIE_EXT_CAP_ID_ATS 0xF /* Address Translation Svcs */ +#define PCIE_EXT_CAP_ID_SRIOV 0x10 /* Single Root I/O Virt. */ +#define PCIE_EXT_CAP_ID_MRIOV 0x11 /* Multi Root I/O Virt. */ +#define PCIE_EXT_CAP_ID_MULTICAST 0x12 /* Multicast Services */ +#define PCIE_EXT_CAP_ID_PGREQ 0x13 /* Page Request */ +#define PCIE_EXT_CAP_ID_EA 0x14 /* Enhanced Allocation */ +#define PCIE_EXT_CAP_ID_RESIZE_BAR 0x15 /* Resizable BAR */ +#define PCIE_EXT_CAP_ID_DPA 0x16 /* Dynamic Power Allocation */ +#define PCIE_EXT_CAP_ID_TPH_REQ 0x17 /* TPH Requester */ +#define PCIE_EXT_CAP_ID_LTR 0x18 /* Latency Tolerance Report */ +#define PCIE_EXT_CAP_ID_PCIE2 0x19 /* PCI Express Capability 2 */ +#define PCIE_EXT_CAP_ID_PASID 0x1B /* PASID */ +#define PCIE_EXT_CAP_ID_LNR 0x1C /* LNR */ +#define PCIE_EXT_CAP_ID_DPC 0x1D /* DPC */ +#define PCIE_EXT_CAP_ID_L1PM 0x1E /* L1 PM Substrates */ +#define PCIE_EXT_CAP_ID_PTM 0x1F /* Precision Time Management */ +#define PCIE_EXT_CAP_ID_FRS 0x21 /* Function Ready Stat. Queue */ +#define PCIE_EXT_CAP_ID_RTR 0x22 /* Readiness Time Reporting */ +#define PCIE_EXT_CAP_ID_DVS 0x23 /* Designated Vendor-Specific */ +#define PCIE_EXT_CAP_ID_VFRBAR 0x24 /* VF Resizable BAR */ +#define PCIE_EXT_CAP_ID_DLF 0x25 /* Data Link Feature */ +#define PCIE_EXT_CAP_ID_PL16GT 0x26 /* Physical Layer 16.0 GT/s */ +#define PCIE_EXT_CAP_ID_LANE_MARGIN 0x27 /* Lane Margining */ +#define PCIE_EXT_CAP_ID_HIEARCHY_ID 0x28 /* Hierarchy ID */ +#define PCIE_EXT_CAP_ID_NPEM 0x29 /* Native PCIe Enclosure Mgmt */ +#define PCIE_EXT_CAP_ID_PL32GT 0x2A /* Physical Layer 32.0 GT/s */ +#define PCIE_EXT_CAP_ID_AP 0x2B /* Alternate Protocol */ +#define PCIE_EXT_CAP_ID_SFI 0x2C /* Sys. Firmware Intermediary */ +#define PCIE_EXT_CAP_ID_SHDW_FUNC 0x2D /* Shadow Functions */ +#define PCIE_EXT_CAP_ID_DOE 0x2E /* Data Object Exchange */ +#define PCIE_EXT_CAP_ID_DEV3 0x2F /* Device 3 */ +#define PCIE_EXT_CAP_ID_IDE 0x30 /* Integrity and Data Encr. */ +#define PCIE_EXT_CAP_ID_PL64GT 0x31 /* Physical Layer 64.0 GT/s */ +#define PCIE_EXT_CAP_ID_FLIT_LOG 0x32 /* Flit Logging */ +#define PCIE_EXT_CAP_ID_FLIT_PERF 0x33 /* Flit Perf. Measurement */ +#define PCIE_EXT_CAP_ID_FLIT_ERR 0x34 /* Flit Error Injection */ +#define PCIE_EXT_CAP_ID_SVC 0x35 /* Streamlined Virtual Chan. */ +#define PCIE_EXT_CAP_ID_MMIO_RBL 0x36 /* MMIO Register Block Loc. */ +#define PCIE_EXT_CAP_ID_NOP_FLIT 0x37 /* NOP Flit */ +#define PCIE_EXT_CAP_ID_SIOV 0x38 /* Scalable I/O Virt. */ +#define PCIE_EXT_CAP_ID_PL128GT 0x39 /* Physical Layer 128.0 GT/s */ +#define PCIE_EXT_CAP_ID_CAP_DATA 0x3a /* Captured Data */ + +/* + * PCI-Express Advanced Error Reporting Extended Capability Offsets + */ +#define PCIE_AER_CAP 0x0 /* Enhanced Capability Header */ +#define PCIE_AER_UCE_STS 0x4 /* Uncorrectable Error Status */ +#define PCIE_AER_UCE_MASK 0x8 /* Uncorrectable Error Mask */ +#define PCIE_AER_UCE_SERV 0xc /* Uncor Error Severity */ +#define PCIE_AER_CE_STS 0x10 /* Correctable Error Status */ +#define PCIE_AER_CE_MASK 0x14 /* Correctable Error Mask */ +#define PCIE_AER_CTL 0x18 /* AER Capability & Control */ +#define PCIE_AER_HDR_LOG 0x1c /* Header Log */ + +/* Root Ports Only */ +#define PCIE_AER_RE_CMD 0x2c /* Root Error Command */ +#define PCIE_AER_RE_STS 0x30 /* Root Error Status */ +#define PCIE_AER_CE_SRC_ID 0x34 /* Error Source ID */ +#define PCIE_AER_ERR_SRC_ID 0x36 /* Error Source ID */ +#define PCIE_AER_TLP_PRE_LOG 0x38 /* TLP Prefix Log */ + +/* Bridges Only */ +#define PCIE_AER_SUCE_STS 0x2c /* Secondary UCE Status */ +#define PCIE_AER_SUCE_MASK 0x30 /* Secondary UCE Mask */ +#define PCIE_AER_SUCE_SERV 0x34 /* Secondary UCE Severity */ +#define PCIE_AER_SCTL 0x38 /* Secondary Cap & Ctl */ +#define PCIE_AER_SHDR_LOG 0x3c /* Secondary Header Log */ + +/* + * AER Uncorrectable Error Status/Mask/Severity Register + */ +#define PCIE_AER_UCE_TRAINING 0x1 /* Training Error Status */ +#define PCIE_AER_UCE_DLP 0x10 /* Data Link Protocol Error */ +#define PCIE_AER_UCE_SD 0x20 /* Link Surprise down */ +#define PCIE_AER_UCE_PTLP 0x1000 /* Poisoned TLP Status */ +#define PCIE_AER_UCE_FCP 0x2000 /* Flow Control Protocol Sts */ +#define PCIE_AER_UCE_TO 0x4000 /* Completion Timeout Status */ +#define PCIE_AER_UCE_CA 0x8000 /* Completer Abort Status */ +#define PCIE_AER_UCE_UC 0x10000 /* Unexpected Completion Sts */ +#define PCIE_AER_UCE_RO 0x20000 /* Receiver Overflow Status */ +#define PCIE_AER_UCE_MTLP 0x40000 /* Malformed TLP Status */ +#define PCIE_AER_UCE_ECRC 0x80000 /* ECRC Error Status */ +#define PCIE_AER_UCE_UR 0x100000 /* Unsupported Req */ +#define PCIE_AER_UCE_BITS (PCIE_AER_UCE_TRAINING | \ + PCIE_AER_UCE_DLP | PCIE_AER_UCE_SD | PCIE_AER_UCE_PTLP | \ + PCIE_AER_UCE_FCP | PCIE_AER_UCE_TO | PCIE_AER_UCE_CA | \ + PCIE_AER_UCE_UC | PCIE_AER_UCE_RO | PCIE_AER_UCE_MTLP | \ + PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR) +#define PCIE_AER_UCE_LOG_BITS (PCIE_AER_UCE_PTLP | PCIE_AER_UCE_CA | \ + PCIE_AER_UCE_UC | PCIE_AER_UCE_MTLP | PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR) + +/* + * AER Correctable Error Status/Mask Register + */ +#define PCIE_AER_CE_RECEIVER_ERR 0x1 /* Receiver Error Status */ +#define PCIE_AER_CE_BAD_TLP 0x40 /* Bad TLP Status */ +#define PCIE_AER_CE_BAD_DLLP 0x80 /* Bad DLLP Status */ +#define PCIE_AER_CE_REPLAY_ROLLOVER 0x100 /* REPLAY_NUM Rollover Status */ +#define PCIE_AER_CE_REPLAY_TO 0x1000 /* Replay Timer Timeout Sts */ +#define PCIE_AER_CE_AD_NFE 0x2000 /* Advisory Non-Fatal Status */ +#define PCIE_AER_CE_BITS (PCIE_AER_CE_RECEIVER_ERR | \ + PCIE_AER_CE_BAD_TLP | PCIE_AER_CE_BAD_DLLP | PCIE_AER_CE_REPLAY_ROLLOVER | \ + PCIE_AER_CE_REPLAY_TO) + +/* + * AER Capability & Control + */ +#define PCIE_AER_CTL_FST_ERR_PTR_MASK 0x1F /* First Error Pointer */ +#define PCIE_AER_CTL_ECRC_GEN_CAP 0x20 /* ECRC Generation Capable */ +#define PCIE_AER_CTL_ECRC_GEN_ENA 0x40 /* ECRC Generation Enable */ +#define PCIE_AER_CTL_ECRC_CHECK_CAP 0x80 /* ECRC Check Capable */ +#define PCIE_AER_CTL_ECRC_CHECK_ENA 0x100 /* ECRC Check Enable */ + +/* + * AER Root Command Register + */ +#define PCIE_AER_RE_CMD_CE_REP_EN 0x1 /* Correctable Error Enable */ +#define PCIE_AER_RE_CMD_NFE_REP_EN 0x2 /* Non-Fatal Error Enable */ +#define PCIE_AER_RE_CMD_FE_REP_EN 0x4 /* Fatal Error Enable */ + +/* + * AER Root Error Status Register + */ +#define PCIE_AER_RE_STS_CE_RCVD 0x1 /* ERR_COR Received */ +#define PCIE_AER_RE_STS_MUL_CE_RCVD 0x2 /* Multiple ERR_COR Received */ +#define PCIE_AER_RE_STS_FE_NFE_RCVD 0x4 /* FATAL/NON-FATAL Received */ +#define PCIE_AER_RE_STS_MUL_FE_NFE_RCVD 0x8 /* Multiple ERR_F/NF Received */ +#define PCIE_AER_RE_STS_FIRST_UC_FATAL 0x10 /* First Uncorrectable Fatal */ +#define PCIE_AER_RE_STS_NFE_MSGS_RCVD 0x20 /* Non-Fatal Error Msgs Rcvd */ +#define PCIE_AER_RE_STS_FE_MSGS_RCVD 0x40 /* Fatal Error Messages Rcvd */ + +#define PCIE_AER_RE_STS_MSG_NUM_SHIFT 27 /* Offset of Intr Msg Number */ +#define PCIE_AER_RE_STS_MSG_NUM_MASK 0x1F /* Intr Msg Number Mask */ + +/* + * AER Error Source Identification Register + */ +#define PCIE_AER_ERR_SRC_ID_CE_SHIFT 0 /* ERR_COR Source ID */ +#define PCIE_AER_ERR_SRC_ID_CE_MASK 0xFFFF +#define PCIE_AER_ERR_SRC_ID_UE_SHIFT 16 /* ERR_FATAL/NONFATAL Src ID */ +#define PCIE_AER_ERR_SRC_ID_UE_MASK 0xFFFF + +/* + * AER Secondary Uncorrectable Error Register + */ +#define PCIE_AER_SUCE_TA_ON_SC 0x1 /* Target Abort on Split Comp */ +#define PCIE_AER_SUCE_MA_ON_SC 0x2 /* Master Abort on Split Comp */ +#define PCIE_AER_SUCE_RCVD_TA 0x4 /* Received Target Abort */ +#define PCIE_AER_SUCE_RCVD_MA 0x8 /* Received Master Abort */ +#define PCIE_AER_SUCE_USC_ERR 0x20 /* Unexpected Split Comp Err */ +#define PCIE_AER_SUCE_USC_MSG_DATA_ERR 0x40 /* USC Message Data Error */ +#define PCIE_AER_SUCE_UC_DATA_ERR 0x80 /* Uncorrectable Data Error */ +#define PCIE_AER_SUCE_UC_ATTR_ERR 0x100 /* UC Attribute Err */ +#define PCIE_AER_SUCE_UC_ADDR_ERR 0x200 /* Uncorrectable Address Err */ +#define PCIE_AER_SUCE_TIMER_EXPIRED 0x400 /* Delayed xtion discard */ +#define PCIE_AER_SUCE_PERR_ASSERT 0x800 /* PERR Assertion Detected */ +#define PCIE_AER_SUCE_SERR_ASSERT 0x1000 /* SERR Assertion Detected */ +#define PCIE_AER_SUCE_INTERNAL_ERR 0x2000 /* Internal Bridge Err Detect */ + +#define PCIE_AER_SUCE_HDR_CMD_LWR_MASK 0xF /* Lower Command Mask */ +#define PCIE_AER_SUCE_HDR_CMD_LWR_SHIFT 4 /* Lower Command Shift */ +#define PCIE_AER_SUCE_HDR_CMD_UP_MASK 0xF /* Upper Command Mask */ +#define PCIE_AER_SUCE_HDR_CMD_UP_SHIFT 8 /* Upper Command Shift */ +#define PCIE_AER_SUCE_HDR_ADDR_SHIFT 32 /* Upper Command Shift */ + +#define PCIE_AER_SUCE_BITS (PCIE_AER_SUCE_TA_ON_SC | \ + PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \ + PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \ + PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \ + PCIE_AER_SUCE_UC_ADDR_ERR | PCIE_AER_SUCE_TIMER_EXPIRED | \ + PCIE_AER_SUCE_PERR_ASSERT | PCIE_AER_SUCE_SERR_ASSERT | \ + PCIE_AER_SUCE_INTERNAL_ERR) +#define PCIE_AER_SUCE_LOG_BITS (PCIE_AER_SUCE_TA_ON_SC | \ + PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \ + PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \ + PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \ + PCIE_AER_SUCE_UC_ADDR_ERR | PCIE_AER_SUCE_PERR_ASSERT) + +/* + * AER Secondary Capability & Control + */ +#define PCIE_AER_SCTL_FST_ERR_PTR_MASK 0x1F /* First Error Pointer */ + +/* + * AER Secondary Headers + * The Secondary Header Logs is 4 DW long. + * The first 2 DW are split into 3 sections + * o Transaction Attribute + * o Transaction Command Lower + * o Transaction Command Higher + * The last 2 DW is the Transaction Address + */ +#define PCIE_AER_SHDR_LOG_ATTR_MASK 0xFFFFFFFFF +#define PCIE_AER_SHDR_LOG_CMD_LOW_MASK 0xF000000000 +#define PCIE_AER_SHDR_LOG_CMD_HIGH_MASK 0xF0000000000 +#define PCIE_AER_SHDR_LOG_ADDR_MASK 0xFFFFFFFFFFFFFFFF + +/* + * PCI-Express Device Serial Number Capability Offsets. + */ +#define PCIE_SER_CAP 0x0 /* Enhanced Capability Header */ +#define PCIE_SER_SID_LOWER_DW 0x4 /* Lower 32-bit Serial Number */ +#define PCIE_SER_SID_UPPER_DW 0x8 /* Upper 32-bit Serial Number */ + +/* + * ARI Capability Offsets + */ +#define PCIE_ARI_HDR 0x0 /* Enhanced Capability Header */ +#define PCIE_ARI_CAP 0x4 /* ARI Capability Register */ +#define PCIE_ARI_CTL 0x6 /* ARI Control Register */ + +#define PCIE_ARI_CAP_MFVC_FUNC_GRP 0x01 +#define PCIE_ARI_CAP_ASC_FUNC_GRP 0x02 + +#define PCIE_ARI_CAP_NEXT_FUNC_SHIFT 8 +#define PCIE_ARI_CAP_NEXT_FUNC_MASK 0xffff + +#define PCIE_ARI_CTRL_MFVC_FUNC_GRP 0x01 +#define PCIE_ARI_CTRL_ASC_FUNC_GRP 0x02 + +#define PCIE_ARI_CTRL_FUNC_GRP_SHIFT 4 +#define PCIE_ARI_CTRL_FUNC_GRP_MASK 0x7 + +/* + * PCIe Device 3 Extended Capability Header (PCIE_EXT_CAP_ID_DEV3) + */ +#define PCIE_DEVCAP3 0x04 +#define PCIE_DEVCAP3_DMWR_REQ_ROUTE 0x01 +#define PCIE_DEVCAP3_14B_TAG_COMP_SUP 0x02 +#define PCIE_DEVCAP3_14B_TAG_REQ_SUP 0x04 +#define PCIE_DEVCAP3_PORT_L0P_SUP 0x08 +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_MASK 0x070 +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_MIN 0x0 /* < 1us */ +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_1us 0x1 /* [ 1us, 2us ) */ +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_2us 0x2 /* [ 2us, 4us ) */ +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_4us 0x3 /* [ 4us, 8us ) */ +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_8us 0x4 /* [ 8us, 16us ) */ +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_16us 0x5 /* [ 16us, 32us ) */ +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_32us 0x6 /* [ 32us, 64us ] */ +#define PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_MAX 0x7 /* > 64us */ +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_MASK 0x380 +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_MIN 0x0 /* < 1us */ +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_1us 0x1 /* [ 1us, 2us ) */ +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_2us 0x2 /* [ 2us, 4us ) */ +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_4us 0x3 /* [ 4us, 8us ) */ +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_8us 0x4 /* [ 8us, 16us ) */ +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_16us 0x5 /* [ 16us, 32us ) */ +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_32us 0x6 /* [ 32us, 64us ] */ +#define PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_MAX 0x7 /* > 64us */ + +#define PCIE_DEVCTL3 0x08 +#define PCIE_DEVCTL3_DMWR_REQ_EN 0x01 +#define PCIE_DEVCTL3_DMWR_EG_BLOCK 0x02 +#define PCIE_DEVCTL3_14B_TAG_REQ_EN 0x04 +#define PCIE_DEVCTL3_L0P_EN 0x08 +#define PCIE_DEVCTL3_TARGET_WIDTH_MASK 0x70 +#define PCIE_DEVCTL3_TARGET_WIDTH_X1 0x00 +#define PCIE_DEVCTL3_TARGET_WIDTH_X2 0x10 +#define PCIE_DEVCTL3_TARGET_WIDTH_X4 0x20 +#define PCIE_DEVCTL3_TARGET_WIDTH_X8 0x30 +#define PCIE_DEVCTL3_TARGET_WIDTH_X16 0x40 +#define PCIE_DEVCTL3_TARGET_WIDTH_DYN 0x70 + +#define PCIE_DEVSTS3 0x0c +#define PCIE_DEVSTS3_INIT_WIDTH_MASK 0x07 +#define PCIE_DEVSTS3_INIT_WIDTH_X1 0x00 +#define PCIE_DEVSTS3_INIT_WIDTH_X2 0x01 +#define PCIE_DEVSTS3_INIT_WIDTH_X4 0x02 +#define PCIE_DEVSTS3_INIT_WIDTH_X8 0x03 +#define PCIE_DEVSTS3_INIT_WIDTH_X16 0x04 +#define PCIE_DEVSTS3_SEG_CAP 0x08 +#define PCIE_DEVSTS3_REM_L0P_SUP 0x10 + +/* + * PCI-E Common TLP Header Fields + */ +#define PCIE_TLP_FMT_3DW 0x00 +#define PCIE_TLP_FMT_4DW 0x20 +#define PCIE_TLP_FMT_3DW_DATA 0x40 +#define PCIE_TLP_FMT_4DW_DATA 0x60 + +#define PCIE_TLP_TYPE_MEM 0x0 +#define PCIE_TLP_TYPE_MEMLK 0x1 +#define PCIE_TLP_TYPE_IO 0x2 +#define PCIE_TLP_TYPE_CFG0 0x4 +#define PCIE_TLP_TYPE_CFG1 0x5 +#define PCIE_TLP_TYPE_MSG 0x10 +#define PCIE_TLP_TYPE_CPL 0xA +#define PCIE_TLP_TYPE_CPLLK 0xB +#define PCIE_TLP_TYPE_MSI 0x18 + +#define PCIE_TLP_MRD3 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEM) +#define PCIE_TLP_MRD4 (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEM) +#define PCIE_TLP_MRDLK3 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEMLK) +#define PCIE_TLP_MRDLK4 (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEMLK) +#define PCIE_TLP_MRDWR3 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MEM) +#define PCIE_TLP_MRDWR4 (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MEM) +#define PCIE_TLP_IORD (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_IO) +#define PCIE_TLP_IOWR (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_IO) +#define PCIE_TLP_CFGRD0 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG0) +#define PCIE_TLP_CFGWR0 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG0) +#define PCIE_TLP_CFGRD1 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG1) +#define PCIE_TLP_CFGWR1 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG1) +#define PCIE_TLP_MSG (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MSG) +#define PCIE_TLP_MSGD (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSG) +#define PCIE_TLP_CPL (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPL) +#define PCIE_TLP_CPLD (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPL) +#define PCIE_TLP_CPLLK (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPLLK) +#define PCIE_TLP_CPLDLK (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPLLK) +#define PCIE_TLP_MSI32 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MSI) +#define PCIE_TLP_MSI64 (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSI) + +typedef uint16_t pcie_req_id_t; + +#define PCIE_REQ_ID_BUS_SHIFT 8 +#define PCIE_REQ_ID_BUS_MASK 0xFF00 +#define PCIE_REQ_ID_DEV_SHIFT 3 +#define PCIE_REQ_ID_DEV_MASK 0x00F8 +#define PCIE_REQ_ID_FUNC_SHIFT 0 +#define PCIE_REQ_ID_FUNC_MASK 0x0007 +#define PCIE_REQ_ID_ARI_FUNC_MASK 0x00FF + +#define PCIE_CPL_STS_SUCCESS 0 +#define PCIE_CPL_STS_UR 1 +#define PCIE_CPL_STS_CRS 2 +#define PCIE_CPL_STS_CA 4 + +#if defined(_BIT_FIELDS_LTOH) +/* + * PCI Express little-endian common TLP header format + */ +typedef struct pcie_tlp_hdr { + uint32_t len :10, + rsvd3 :2, + attr :2, + ep :1, + td :1, + rsvd2 :4, + tc :3, + rsvd1 :1, + type :5, + fmt :2, + rsvd0 :1; +} pcie_tlp_hdr_t; + +typedef struct pcie_mem64 { + uint32_t fbe :4, + lbe :4, + tag :8, + rid :16; + uint32_t addr1; + uint32_t rsvd0 :2, + addr0 :30; +} pcie_mem64_t; + +typedef struct pcie_memio32 { + uint32_t fbe :4, + lbe :4, + tag :8, + rid :16; + uint32_t rsvd0 :2, + addr0 :30; +} pcie_memio32_t; + +typedef struct pcie_cfg { + uint32_t fbe :4, + lbe :4, + tag :8, + rid :16; + uint32_t rsvd1 :2, + reg :6, + extreg :4, + rsvd0 :4, + func :3, + dev :5, + bus :8; +} pcie_cfg_t; + +typedef struct pcie_cpl { + uint32_t bc :12, + bcm :1, + status :3, + cid :16; + uint32_t laddr :7, + rsvd0 :1, + tag :8, + rid :16; +} pcie_cpl_t; + +/* + * PCI-Express Message Request Header + */ +typedef struct pcie_msg { + uint32_t msg_code:8, /* DW1 */ + tag :8, + rid :16; + uint32_t unused[2]; /* DW 2 & 3 */ +} pcie_msg_t; + +#elif defined(_BIT_FIELDS_HTOL) +/* + * PCI Express big-endian common TLP header format + */ +typedef struct pcie_tlp_hdr { + uint32_t rsvd0 :1, + fmt :2, + type :5, + rsvd1 :1, + tc :3, + rsvd2 :4, + td :1, + ep :1, + attr :2, + rsvd3 :2, + len :10; +} pcie_tlp_hdr_t; + +typedef struct pcie_mem64 { + uint32_t rid :16, + tag :8, + lbe :4, + fbe :4; + uint32_t addr1; + uint32_t addr0 :30, + rsvd0 :2; +} pcie_mem64_t; + +typedef struct pcie_memio32 { + uint32_t rid :16, + tag :8, + lbe :4, + fbe :4; + uint32_t addr0 :30, + rsvd0 :2; +} pcie_memio32_t; + +typedef struct pcie_cfg { + uint32_t rid :16, + tag :8, + lbe :4, + fbe :4; + uint32_t bus :8, + dev :5, + func :3, + rsvd0 :4, + extreg :4, + reg :6, + rsvd1 :2; +} pcie_cfg_t; + +typedef struct pcie_cpl { + uint32_t cid :16, + status :3, + bcm :1, + bc :12; + uint32_t rid :16, + tag :8, + rsvd0 :1, + laddr :7; +} pcie_cpl_t; + +/* + * PCI-Express Message Request Header + */ +typedef struct pcie_msg { + uint32_t rid :16, /* DW1 */ + tag :8, + msg_code:8; + uint32_t unused[2]; /* DW 2 & 3 */ +} pcie_msg_t; +#else +#error "bit field not defined" +#endif + +#define PCIE_MSG_CODE_ERR_COR 0x30 +#define PCIE_MSG_CODE_ERR_NONFATAL 0x31 +#define PCIE_MSG_CODE_ERR_FATAL 0x33 + +/* + * Receiver preset hint encodings for PCIe Gen 3 (8 GT/s) receivers. These match + * the PCIe Base 3/4/5 specification, section 4.2.3.2. These are used in the + * Lane Equalization Control Register in the Secondary PCI Express Extended + * Capability. + */ +#define PCIE_GEN3_RX_PRESET_6DB 0 +#define PCIE_GEN3_RX_PRESET_7DB 1 +#define PCIE_GEN3_RX_PRESET_8DB 2 +#define PCIE_GEN3_RX_PRESET_9DB 3 +#define PCIE_GEN3_RX_PRESET_10DB 4 +#define PCIE_GEN3_RX_PRESET_11DB 5 +#define PCIE_GEN3_RX_PRESET_12DB 6 +#define PCIE_GEN3_RX_PRESET_RSVD 7 + +/* + * The following are used for transmitter preset hints and are shared in all + * PCIe versions from PCIe Gen 3+. Table 4.2.3.2 (PCIe 3/4/5) describes the + * meaning of the transmitter hints. These basically correspond to 10 values + * labeled P0-P10. Section 8.3.3.3 (PCIe 4/5) translates these into the + * corresponding values in Table 8-1 Tx Preset Ratios and Corresponding + * Coefficient Values. + */ +#define PCIE_TX_PRESET_0 0 +#define PCIE_TX_PRESET_1 1 +#define PCIE_TX_PRESET_2 2 +#define PCIE_TX_PRESET_3 3 +#define PCIE_TX_PRESET_4 4 +#define PCIE_TX_PRESET_5 5 +#define PCIE_TX_PRESET_6 6 +#define PCIE_TX_PRESET_7 7 +#define PCIE_TX_PRESET_8 8 +#define PCIE_TX_PRESET_9 9 +#define PCIE_TX_PRESET_10 10 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PCIE_H */ diff --git a/illumos-x86_64/usr/include/sys/pcmcia.h b/illumos-x86_64/usr/include/sys/pcmcia.h new file mode 100644 index 00000000..d313eb1e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pcmcia.h @@ -0,0 +1,499 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * PCMCIA nexus + */ + +#ifndef _PCMCIA_H +#define _PCMCIA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(DEBUG) +#define PCMCIA_DEBUG +#endif + +#include + +#define PCMCIA_MAX_ADAPTERS 8 /* maximum distinct adapters */ +#define PCMCIA_MAX_SOCKETS 64 /* maximum distinct sockets */ +#define PCMCIA_MAX_WIN_ADAPT 40 +#define PCMCIA_MAX_WINDOWS (PCMCIA_MAX_ADAPTERS*PCMCIA_MAX_WIN_ADAPT) +#define PCMCIA_MAX_POWER 16 /* maximum power table entries */ + +#define _VERSION(major, minor) ((major)<<16|(minor)) + +/* + * DDI/Nexus stuff + */ + +#define PCMCIA_NEXUS_NAME "pcmcia" +#define PCMCIA_ADAPTER_NODE "ddi_pcmcia:adapter" +#define PCMCIA_SOCKET_NODE "ddi_pcmcia:socket" +#define PCMCIA_PCCARD_NODE "ddi_pcmcia:pccard" + +/* + * private interface between nexus and adapter specific driver + * This is only an "ops" type structure + */ + +typedef struct pcmcia_if { + uint32_t pcif_magic; /* magic number to verify correct scructure */ + uint32_t pcif_version; + int (*pcif_set_callback)(); + int (*pcif_get_adapter)(); + int (*pcif_get_page)(); + int (*pcif_get_socket)(); + int (*pcif_get_status)(); + int (*pcif_get_window)(); + int (*pcif_inquire_adapter)(); + int (*pcif_inquire_socket)(); + int (*pcif_inquire_window)(); + int (*pcif_reset_socket)(); + int (*pcif_set_page)(); + int (*pcif_set_window)(); + int (*pcif_set_socket)(); + int (*pcif_set_interrupt)(); + int (*pcif_clr_interrupt)(); + int (*pcic_init_dev)(); + uint32_t (*pcic_get_tstamp)(); +} pcmcia_if_t; + +/* + * magic number and version information to identify + * variant of the PCMCIA nexus. + */ +#define PCIF_MAGIC 0x50434946 +#define PCIF_VERSION _VERSION(0, 1) +#define PCIF_MIN_VERSION _VERSION(0, 1) +#define DEFAULT_CS_NAME "cs" + +/* + * all adapter drivers use a commonly defined structure for + * their private data. This structure must be filled in + * and set. The an_private member is for the driver writer's + * use and is not looked at by the nexus. + */ +struct pcmcia_adapter_nexus_private { + dev_info_t *an_dip; + pcmcia_if_t *an_if; + void *an_private; + ddi_iblock_cookie_t *an_iblock; /* high priority handler cookies */ + ddi_idevice_cookie_t *an_idev; + uint32_t an_ipl; +}; + +typedef struct pcmcia_adapter_nexus_private anp_t; + +struct pcm_regs { + uint32_t phys_hi; + uint32_t phys_lo; + uint32_t phys_len; +}; + +/* + * shared interrupts are handled by the + * nexus going through the list + */ +typedef struct inthandler { + struct inthandler *next; + struct inthandler *prev; + int flags; + uint32_t (*intr)(caddr_t, caddr_t); + unsigned handler_id; + void *arg1; + void *arg2; + unsigned socket; + unsigned irq; + unsigned priority; + ddi_softintr_t softid; + ddi_iblock_cookie_t iblk_cookie; + ddi_idevice_cookie_t idev_cookie; +} inthandler_t; + +/* + * parent private data area + * not using the old style but will adapt on request + * this allows better framework handling and 1275 compliance + */ + +struct pcmcia_parent_private { + int ppd_nreg; /* number of regs */ + struct pcm_regs *ppd_reg; /* array of regs in parsed form */ + int ppd_intr; /* number intrspecs (always 0 or 1) */ + struct intrspec *ppd_intrspec; + void *pcm_dummy[3]; /* fill for prtconf -v */ + struct pcm_regs *ppd_assigned; /* array of regs in parsed form */ + short ppd_socket; /* socket number of this instance */ + short ppd_function; /* function number */ + int ppd_active; /* is PC Card in a socket and active */ + uint32_t ppd_flags; + void *ppd_handle; /* client handle */ +}; + +#define PPD_CARD_MULTI 0x0001 /* card is multifunction card */ +#define PPD_CARD_CARDBUS 0x0002 /* card is CardBus type */ +#define PPD_CB_BUSMASTER 0x0004 /* card bus card is busmaster */ +#define PPD_SUSPENDED 0x0008 /* this device was pm suspended */ + +/* + * macros to make indirect functions easier + * and shorter (makes cstyle happier) + */ + +#define GET_SOCKET_STATUS(f, dip, sock, stat)\ + (*(f)->pcif_get_socket_status)(dip, sock, stat) +#define SET_CALLBACK(f, dip, callback, sock)\ + (*(f)->pcif_set_callback)(dip, callback, sock) + +#define GET_ADAPTER(f, dip, conf) (*(f)->pcif_get_adapter) (dip, conf) +#define GET_SOCKET(f, dip, sock) (*(f)->pcif_get_socket)(dip, sock) +#define GET_STATUS(f, dip, status) (*(f)->pcif_get_status)(dip, status) +#define GET_WINDOW(f, dip, window) (*(f)->pcif_get_window)(dip, window) +#define INQUIRE_ADAPTER(f, dip, inquire) (*(f)->pcif_inquire_adapter)(dip,\ + inquire) +#define GET_CONFIG(f, dip, conf) INQUIRE_ADAPTER(f, dip, conf) +#define INQUIRE_SOCKET(f, dip, sock) (*(f)->pcif_inquire_socket)(dip, \ + sock) +#define GET_PAGE(f, dip, page) (*(f)->pcif_get_page)(dip, page) +#define INQUIRE_WINDOW(f, dip, window) (*(f)->pcif_inquire_window)(dip, window) +#define RESET_SOCKET(f, dip, socket, mode) \ + (*(f)->pcif_reset_socket)(dip, socket, mode) +#define SET_PAGE(f, dip, page) (*(f)->pcif_set_page)(dip, page) +#define SET_WINDOW(f, dip, window) (*(f)->pcif_set_window)(dip, window) +#define SET_SOCKET(f, dip, socket) (*(f)->pcif_set_socket)(dip, socket) +#define SET_IRQ(f, dip, handler) (*(f)->pcif_set_interrupt)(dip, handler) +#define CLEAR_IRQ(f, dip, handler) (*(f)->pcif_clr_interrupt)(dip, handler) + +typedef struct pcmcia_cs { + uint32_t pccs_magic; /* magic number of verify correct structure */ + uint32_t pccs_version; + int (*pccs_callback)(); + int (*pccs_getconfig)(); +} pcmcia_cs_t; + +#define PCCS_MAGIC 0x50434353 +#define PCCS_VERSION _VERSION(2, 1) + +/* properties used by the nexus for setup */ +#define ADAPT_PROP "adapters" /* property used to find adapter list */ +#define CS_PROP "card-services" /* property specifying Card Services */ +#define DEF_DRV_PROP "default-driver" /* default driver to load if no CIS */ + +/* + * per adapter structure + * this structure defines everything necessary for the + * the nexus to interact with the adapter specific driver + */ + +struct pcmcia_adapter { + int pca_module; /* adapter major number */ + int pca_unit; /* adapter minor number */ + int pca_number; /* canonical adapter number */ + struct dev_ops *pca_ops; + dev_info_t *pca_dip; + pcmcia_if_t *pca_if; + void *pca_power; + ddi_iblock_cookie_t *pca_iblock; + ddi_idevice_cookie_t *pca_idev; + kmutex_t *pca_mutex; + int pca_numpower; + int pca_numsockets; + int pca_first_socket; + uint32_t pca_flags; + char pca_name[MODMAXNAMELEN]; + uint32_t pca_avail_intr; + inthandler_t pca_int_handlers; +}; + +#define PCA_RES_NEED_IRQ 0x0001 /* needs IRQ allocation */ +#define PCA_RES_NEED_IO 0x0002 /* needs I/O allocation */ +#define PCA_RES_NEED_MEM 0x0004 /* needs memory allocation */ +#define PCA_RES_CONSTRAINT 0x0008 /* resource constraints defined */ +#define PCA_IRQ_SMI_SHARE 0x0010 /* SMI and child share */ +#define PCA_IRQ_SHAREABLE 0x0020 /* all interrupts sharable */ +#define PCA_IRQ_ISA 0x0040 /* ISA style (host) interrupts */ + +/* These flags are for open/close -- hot-plug support in future */ +#define PCMCIA_MAX_FUNCTIONS 8 +#define PCS_CARD_PRESENT 0x0001 /* card in socket */ +#define PCS_MULTI_FUNCTION 0x0002 /* indicates dip is multifunction */ +#define PCS_SOCKET_ADDED 0x0004 /* CS knows about the socket */ +#define PCS_COOKIES_VALID 0x0008 /* iblk and idev valid */ +#define PCS_IRQ_ENABLED 0x0010 /* IRQ has been enabled */ +#define PCS_SUSPENDED 0x0020 /* PM SUSPEND was done */ + +typedef struct pcmcia_logical_window { + int lw_window; /* window number */ + int lw_socket; /* logical socket number assigned */ + struct pcmcia_adapter *lw_adapter; + pcmcia_if_t *lw_if; + uint32_t lw_status; + baseaddr_t lw_base; + int lw_len; +} pcmcia_logical_window_t; + +#define PCS_ENABLED 0x0002 /* window is enabled */ + +/* + * management interface hook + */ +#define EM_EVENTSIZE 4 +struct pcmcia_mif { + struct pcmcia_mif *mif_next; + void (*mif_function)(); + uint32_t mif_id; + uchar_t mif_events[EM_EVENTSIZE]; /* events registered for */ +}; + +#define PR_WORDSIZE 8 /* bits in word */ +#define PR_MASK 0x7 +#define PR_GET(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] &\ + (1 << ((bit) & PR_MASK))) +#define PR_SET(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] |=\ + (1 << ((bit) & PR_MASK))) +#define PR_CLEAR(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] &=\ + ~(1 << ((bit) & PR_MASK))) +#define PR_ADDR(map, bit) (((uchar_t *)(map)) + ((bit)/PR_WORDSIZE)) +#define PR_ZERO(map) \ + bzero((caddr_t)map, PCMCIA_MAX_SOCKETS / PR_WORDSIZE) + +/* socket bit map */ +typedef uchar_t socket_enum_t[PCMCIA_MAX_SOCKETS/PR_WORDSIZE]; + +/* + * Max resoruce limits - all of these have to be power-of-2 aligned + * and the PR_MAX_IO_LEN and PR_MAX_MEM_LEN values must be at + * least 64 or the allocators will panic. + */ +#define PR_MAX_IO_LEN 1024 /* bytes of IO space */ +#define PR_MAX_IO_RANGES 4 +#define PR_MAX_MEM_LEN 1024 /* pages or 4M bytes */ +#define PR_MAX_MEM_RANGES 32 + +#define PR_MAX_IOADDR 0xffffffff +#define PR_MAX_MEMADDR 0xffffffff +#define PR_MAX_INTERRUPTS 0xff + + +/* + * structures and definitions used in the private interface + */ + +/* general values */ +#define PC_SUCCESS 1 +#define PC_FAILURE 0 + +/* set_mem() */ +#define PC_MEM_AM 0 +#define PC_MEM_CM 1 + +/* device classes */ +#define PCC_MULTI 0 +#define PCC_MEMORY 1 +#define PCC_SERIAL 2 +#define PCC_PARALLEL 3 +#define PCC_FIXED_DISK 4 +#define PCC_VIDEO 5 +#define PCC_LAN 6 + +/* + * device information structure information + * this is what is used for initial construction of a device node + */ + +struct pcm_device_info { + int pd_socket; + int pd_function; + int pd_type; + uint32_t pd_handle; + uint32_t pd_tuples; + uint32_t pd_flags; + char pd_bind_name[MODMAXNAMELEN]; + char pd_vers1_name[MODMAXNAMELEN*4]; + char pd_generic_name[MODMAXNAMELEN]; +}; + +#define PCM_GET_SOCKET(socknum) ((socknum) & 0x1F) +#define PCM_GET_FUNCTION(socknum) (((socknum) >> 5) & 0x7) + +#define PCM_DEFAULT_NODEID (-1) +#define PCM_DEV_MODEL "model" +#define PCM_DEV_ACTIVE "card-active" +#define PCM_DEV_SOCKET "socket" +#define PCM_DEV_R2TYPE "16bitcard" +#define PCM_DEV_CARDBUS "cardbus" + +typedef +struct init_dev { + int socket; +} init_dev_t; + +/* + * device descriptions + * used to determine what driver to associate with a PC Card + * so that automatic creation of device information trees can + * be supported. + */ + +typedef +struct pcm_device_node { + struct pcm_device_node *pd_next; + dev_info_t *pd_dip; /* proto device info */ + char pd_name[16]; + int pd_flags; + int pd_devtype; /* from device tuple */ + int pd_funcid; + int pd_manfid; + int pd_manmask; +} pcm_dev_node_t; + +#define PCMD_DEVTYPE 0x0001 /* match device type */ +#define PCMD_FUNCID 0x0002 /* match function ID */ +#define PCMD_MANFID 0x0004 /* match manufacturer ID */ +#define PCMD_FUNCE 0x0008 /* match function extension */ +#define PCMD_VERS1 0x0010 /* match VERSION_1 string(s) */ +#define PCMD_JEDEC 0x0020 /* JEDEC ID */ + +#define PCM_NAME_1275 0x0001 +#define PCM_NAME_VERS1 0x0002 +#define PCM_NAME_GENERIC 0x0004 +#define PCM_NO_CONFIG 0x0008 +#define PCM_OTHER_NOCIS 0x0100 +#define PCM_MULTI_FUNCTION 0x0200 + +#define PCM_MAX_R2_MEM 0x3ffffff + +#define PCMDEV_PREFIX "PC," +#define PCMDEV_NAMEPREF "pccard" + +/* property names */ +#define PCM_PROP_DEVICE "device" +#define PCM_PROP_FUNCID "funcid" + +/* 1275 specific properties */ +#define PCM_1275_NUMWIN "#windows" +#define PCM_1275_NUMSOCK "#sockets" +#define PCM_1275_SCIC "status-change-int_caps" + +/* basic device types */ + +#define PCM_TYPE_MULTI 0 +#define PCM_TYPE_MEMORY 1 +#define PCM_TYPE_SERIAL 2 +#define PCM_TYPE_PARALLEL 3 +#define PCM_TYPE_FIXED 4 +#define PCM_TYPE_VIDEO 5 +#define PCM_TYPE_LAN 6 + + +typedef +struct string_to_int { + char *sti_str; + uint32_t sti_int; +} str_int_t; + +/* + * PCMCIA nexus/adapter specific ioctl commands + */ + +#define PCIOC ('P' << 8) +/* SS is temporary until design done */ +#define PC_SS_CMD(cmd) (PCIOC|(cmd)) + +/* stuff that used to be in obpdefs.h but no longer */ +#define PCM_DEVICETYPE "device_type" + +/* + * new regspec and other 1275 stuff + */ +#define PC_REG_RELOC(x) ((((uint32_t)x) & 0x1) << 31) +#define PC_REG_PREFETCH(x) (((x) & 0x1) << 30) +#define PC_REG_TYPE(x) (((x) & 0x1) << 29) +#define PC_REG_SPACE(x) (((x) & 0x7) << 24) +#define PC_REG_SOCKET(x) (((x) & 0x1f) << 11) +#define PC_REG_FUNCTION(x) (((x) & 0x7) << 8) +#define PC_REG_BASEREG(x) ((x) & 0xff) +/* solaris internal only */ +#define PC_REG_REFCNT(x) (((x) & 0xFF) << 16) + +#define PC_GET_REG_RELOC(x) (((x) >> 31) & 1) +#define PC_GET_REG_PREFETCH(x) (((x) >> 30) & 1) +#define PC_GET_REG_TYPE(x) (((x) >> 29) & 1) +#define PC_GET_REG_SPACE(x) (((x) >> 24) & 7) +#define PC_GET_REG_SOCKET(x) (((x) >> 11) & 0x1f) +#define PC_GET_REG_FUNCTION(x) (((x) >> 8) & 0x7) +#define PC_GET_REG_BASEREG(x) ((x) & 0xff) +/* solaris internal only */ +#define PC_GET_REG_REFCNT(x) (((x) >> 16) & 0xFF) +#define PC_INCR_REFCNT(x) (((x) & 0xFF00FFFF) | \ + PC_REG_REFCNT(PC_GET_REG_REFCNT(x) + 1)) +#define PC_DECR_REFCNT(x) (((x) & 0xFF00FFFF) | \ + PC_REG_REFCNT(PC_GET_REG_REFCNT(x) - 1)) + +#define PC_REG_PHYS_HI(n, p, t, c, s, f, r) (uint32_t)( \ + PC_REG_RELOC(n) | \ + PC_REG_PREFETCH(p) | \ + PC_REG_TYPE(t) | \ + PC_REG_SPACE(c) | \ + PC_REG_SOCKET(s) | \ + PC_REG_FUNCTION(f) | \ + PC_REG_BASEREG(r)) + +#define PC_REG_TYPE_CARDBUS 0 +#define PC_REG_TYPE_16BIT 1 + +#define PC_REG_SPACE_CONFIG 0x0 +#define PC_REG_SPACE_IO 0x1 +#define PC_REG_SPACE_MEMORY 0x2 +#define PC_REG_SPACE_ATTRIBUTE 0x4 + +/* + * internal properties and other prop_op defines + */ + +#define PCMCIA_PROP_UNKNOWN 0x10000 /* pass to DDI decode */ +#define PCMCIA_PROP_CIS 0x20000 /* need to get the tuple */ + + /* specific known properties */ +#define PCMCIA_PROP_SOCKET 0 /* "socket" */ +#define PCMCIA_PROP_COMPAT 1 /* "compatible" */ +#define PCMCIA_PROP_DEFAULT_PM 2 /* power managment timestamp */ +#define PCMCIA_PROP_ACTIVE 3 /* card-active property */ +#define PCMCIA_PROP_R2TYPE 4 /* 16 bit card */ +#define PCMCIA_PROP_CARDBUS 5 /* card is cardbus */ +#define PCMCIA_PROP_OLDCS 6 /* old card services property */ +#define PCMCIA_PROP_REG 7 /* standard reg= property */ +#define PCMCIA_PROP_INTR 8 /* interrupts property */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PCMCIA_H */ diff --git a/illumos-x86_64/usr/include/sys/pctypes.h b/illumos-x86_64/usr/include/sys/pctypes.h new file mode 100644 index 00000000..689962ad --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pctypes.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PCTYPES_H +#define _PCTYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * PCMCIA General Types + */ + +typedef int irq_t; /* IRQ level */ +typedef unsigned char *baseaddr_t; /* memory base address */ +#if defined(__i386) || defined(__amd64) +typedef uint32_t ioaddr_t; +#elif defined(__sparc) +typedef caddr_t ioaddr_t; +#endif + +typedef uint32_t (*intrfunc_t)(void *); + +/* + * Data access handle definitions for common access functions + */ +typedef void * acc_handle_t; + +#if defined(_BIG_ENDIAN) +#define leshort(a) ((((a) & 0xFF) << 8) | (((a) >> 8) & 0xFF)) +#define lelong(a) (leshort((a) >> 16) | (leshort(a) << 16)) +#else +#define leshort(a) (a) +#define lelong(a) (a) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _PCTYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/pfmod.h b/illumos-x86_64/usr/include/sys/pfmod.h new file mode 100644 index 00000000..06424e98 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pfmod.h @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PFMOD_H +#define _SYS_PFMOD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Ioctls. + */ +#define PFIOC ('P' << 8) +#define PFIOCSETF (PFIOC|1) /* replace current packet filter */ + +#define ENMAXFILTERS 255 /* maximum filter short words */ +#define PF_MAXFILTERS 2047 /* max short words for newpacketfilt */ + +/* + * filter structure for SETF + */ +struct packetfilt { + uchar_t Pf_Priority; /* priority of filter */ + uchar_t Pf_FilterLen; /* length of filter cmd list */ + ushort_t Pf_Filter[ENMAXFILTERS]; /* filter command list */ +}; + +/* + * The extended packet filter structure + */ +struct Pf_ext_packetfilt { + uchar_t Pf_Priority; /* priority of filter */ + unsigned int Pf_FilterLen; /* length of filter cmd list */ + ushort_t Pf_Filter[PF_MAXFILTERS]; /* filter command list */ +}; + +/* + * We now allow specification of up to MAXFILTERS (short) words of a filter + * command list to be applied to incoming packets to determine if + * those packets should be given to a particular open ethernet file. + * Alternatively, PF_MAXFILTERS and Pf_ext_packetfilt structure can be + * used in case even bigger filter command list is needed. + * + * In this context, "word" means a short (16-bit) integer. + * + * The filter command list is specified using ioctl(). Each filter command + * list specifies a sequence of actions that leaves a boolean value on the + * top of an internal stack. There is also an offset register which is + * initialized to zero. Each word of the command list specifies an action + * from the set {PUSHLIT, PUSHZERO, PUSHWORD+N, LOAD_OFFSET, BRTR, BRFL, POP} + * (see #defines below for definitions), and a binary operator from the set + * {EQ, LT, LE, GT, GE, AND, OR, XOR} which operates on the top two elements + * of the stack and replaces them with its result. The special action NOPUSH + * and the special operator NOP can be used to only perform the binary + * operation or to only push a value on the stack. + * + * If the final value of the filter operation is true, then the packet is + * accepted for the open file which specified the filter. + */ + +/* these must sum to sizeof (ushort_t)! */ +#define ENF_NBPA 10 /* # bits / action */ +#define ENF_NBPO 6 /* # bits / operator */ + +/* binary operators */ +#define ENF_NOP (0 << ENF_NBPA) +#define ENF_EQ (1 << ENF_NBPA) +#define ENF_LT (2 << ENF_NBPA) +#define ENF_LE (3 << ENF_NBPA) +#define ENF_GT (4 << ENF_NBPA) +#define ENF_GE (5 << ENF_NBPA) +#define ENF_AND (6 << ENF_NBPA) +#define ENF_OR (7 << ENF_NBPA) +#define ENF_XOR (8 << ENF_NBPA) +#define ENF_COR (9 << ENF_NBPA) +#define ENF_CAND (10 << ENF_NBPA) +#define ENF_CNOR (11 << ENF_NBPA) +#define ENF_CNAND (12 << ENF_NBPA) +#define ENF_NEQ (13 << ENF_NBPA) + +/* stack actions */ +#define ENF_NOPUSH 0 +#define ENF_PUSHLIT 1 /* Push the next word on the stack */ +#define ENF_PUSHZERO 2 /* Push 0 on the stack */ +#define ENF_PUSHONE 3 /* Push 1 on the stack */ +#define ENF_PUSHFFFF 4 /* Push 0xffff on the stack */ +#define ENF_PUSHFF00 5 /* Push 0xff00 on the stack */ +#define ENF_PUSH00FF 6 /* Push 0x00ff on the stack */ +#define ENF_LOAD_OFFSET 7 /* Load the next word into the offset register */ +#define ENF_BRTR 8 /* Branch if the stack's top element is true */ +#define ENF_BRFL 9 /* Branch if the stack's top element is false */ +#define ENF_POP 10 /* Pop the top element from the stack */ +#define ENF_PUSHWORD 16 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PFMOD_H */ diff --git a/illumos-x86_64/usr/include/sys/pg.h b/illumos-x86_64/usr/include/sys/pg.h new file mode 100644 index 00000000..f2bd3df5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pg.h @@ -0,0 +1,206 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _PG_H +#define _PG_H + +/* + * Processor Groups + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined(_KERNEL) || defined(_KMEMUSER)) +#include +#include +#include +#include +#include +#include +#include + +typedef int pgid_t; /* processor group id */ +typedef uint_t pg_cid_t; /* processor group class id */ + +struct pg; + +/* + * Nature of CPU relationships + */ +typedef enum pg_relation { + PGR_LOGICAL, + PGR_PHYSICAL +} pg_relation_t; + +/* + * Processor Group callbacks ops vector + * These provide a mechanism allowing per PG routines to invoked + * in response to events. + */ +typedef struct pg_cb_ops { + void (*thread_swtch)(struct pg *, struct cpu *, hrtime_t, + kthread_t *, kthread_t *); + void (*thread_remain)(struct pg *, struct cpu *, + kthread_t *); +} pg_cb_ops_t; + +/* + * Processor group structure + */ +typedef struct pg { + pgid_t pg_id; /* seq id */ + pg_relation_t pg_relation; /* grouping relationship */ + struct pg_class *pg_class; /* pg class */ + struct group pg_cpus; /* group of CPUs */ + pg_cb_ops_t pg_cb; /* pg events ops vector */ +} pg_t; + +/* + * PG class callbacks + */ +struct pg_ops { + struct pg *(*alloc)(); + void (*free)(struct pg *); + void (*cpu_init)(struct cpu *, struct cpu_pg *); + void (*cpu_fini)(struct cpu *, struct cpu_pg *); + void (*cpu_active)(struct cpu *); + void (*cpu_inactive)(struct cpu *); + void (*cpupart_in)(struct cpu *, struct cpupart *); + void (*cpupart_out)(struct cpu *, struct cpupart *); + void (*cpupart_move)(struct cpu *, struct cpupart *, + struct cpupart *); + int (*cpu_belongs)(struct pg *, struct cpu *); + char *(*policy_name)(struct pg *); +}; + +#define PG_CLASS_NAME_MAX 32 + +/* + * PG class structure + */ +typedef struct pg_class { + pg_cid_t pgc_id; + char pgc_name[PG_CLASS_NAME_MAX]; + struct pg_ops *pgc_ops; + pg_relation_t pgc_relation; +} pg_class_t; + +/* + * Per CPU processor group data + */ +typedef struct cpu_pg { + struct group pgs; /* All the CPU's PGs */ + struct group cmt_pgs; /* CMT load balancing lineage */ + /* (Group hierarchy ordered) */ + struct pg *cmt_lineage; /* Ascending lineage chain */ +} cpu_pg_t; + +/* + * PG cpu iterator cookie + */ +typedef struct pg_cpu_itr { + pg_t *pg; + group_iter_t position; +} pg_cpu_itr_t; + +/* + * Initialize a PG CPU iterator cookie + */ +#define PG_CPU_ITR_INIT(pgrp, itr) \ +{ \ + group_iter_init(&(itr).position); \ + (itr).pg = ((pg_t *)pgrp); \ +} + +/* + * Return the first CPU in a PG + */ +#define PG_CPU_GET_FIRST(pgrp) \ + (GROUP_SIZE(&((pg_t *)pgrp)->pg_cpus) > 0 ? \ + GROUP_ACCESS(&((pg_t *)pgrp)->pg_cpus, 0) : NULL) + +/* + * Return the number of CPUs in a PG + */ +#define PG_NUM_CPUS(pgrp) \ + (GROUP_SIZE(&(pgrp)->pg_cpus)) + +/* + * Framework routines + */ +void pg_init(void); +pg_cid_t pg_class_register(char *, struct pg_ops *, pg_relation_t); + +/* + * PG CPU reconfiguration hooks + */ +void pg_cpu0_init(void); +cpu_pg_t *pg_cpu_init(cpu_t *, boolean_t deferred_init); +void pg_cpu_fini(cpu_t *, cpu_pg_t *cpu_pg_deferred); +void pg_cpu_active(cpu_t *); +void pg_cpu_inactive(cpu_t *); +void pg_cpu_startup(cpu_t *); +void pg_cpu_bootstrap(cpu_t *); +int pg_cpu_is_bootstrapped(cpu_t *); + +/* + * PG cpupart service hooks + */ +void pg_cpupart_in(cpu_t *, struct cpupart *); +void pg_cpupart_out(cpu_t *, struct cpupart *); +void pg_cpupart_move(cpu_t *, struct cpupart *, struct cpupart *); + +/* + * PG CPU utility routines + */ +pg_t *pg_create(pg_cid_t); +void pg_destroy(pg_t *); +void pg_cpu_add(pg_t *, cpu_t *, cpu_pg_t *); +void pg_cpu_delete(pg_t *, cpu_t *, cpu_pg_t *); +pg_t *pg_cpu_find_pg(cpu_t *, group_t *); +cpu_t *pg_cpu_next(pg_cpu_itr_t *); +boolean_t pg_cpu_find(pg_t *, cpu_t *); + +/* + * PG Event callbacks + */ +void pg_callback_set_defaults(pg_t *); +void pg_ev_thread_swtch(cpu_t *, hrtime_t, kthread_t *, kthread_t *); +void pg_ev_thread_remain(cpu_t *, kthread_t *); + +/* + * PG Observability interfaces + */ +char *pg_policy_name(pg_t *); + +#endif /* !_KERNEL && !_KMEMUSER */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PG_H */ diff --git a/illumos-x86_64/usr/include/sys/pghw.h b/illumos-x86_64/usr/include/sys/pghw.h new file mode 100644 index 00000000..f8567c6f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pghw.h @@ -0,0 +1,195 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _PGHW_H +#define _PGHW_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined(_KERNEL) || defined(_KMEMUSER)) +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Hardware that may be shared by a group of processors + */ +typedef enum pghw_type { + PGHW_START, + PGHW_IPIPE, /* Instruction Pipeline */ + PGHW_CACHE, /* Cache (generally last level) */ + PGHW_FPU, /* Floating Point Unit / Pipeline */ + PGHW_MPIPE, /* Pipe to Memory */ + PGHW_CHIP, /* Socket */ + PGHW_MEMORY, + PGHW_POW_ACTIVE, /* Active Power Management Domain */ + PGHW_POW_IDLE, /* Idle Power Management Domain */ + PGHW_NUM_COMPONENTS +} pghw_type_t; + +/* + * See comments in usr/src/uts/i86pc/os/cpuid.c + * for description of processor nodes + * + * From sharing point of view processor nodes are + * very similar to memory pipes, hence the #define below. + */ +#define PGHW_PROCNODE PGHW_MPIPE + +/* + * Returns true if the hardware is a type of power management domain + */ +#define PGHW_IS_PM_DOMAIN(hw) \ + (hw == PGHW_POW_ACTIVE || hw == PGHW_POW_IDLE) + +/* + * Anonymous instance id + */ +#define PGHW_INSTANCE_ANON ((id_t)0xdecafbad) + +/* + * Max length of PGHW kstat strings + */ +#define PGHW_KSTAT_STR_LEN_MAX 32 + + +/* + * Platform specific handle + */ +typedef uintptr_t pghw_handle_t; + +/* + * Representation of PG hardware utilization NOTE: All the sums listed below are + * the sums of running total of each item for each CPU in the PG (eg. + * sum(utilization) is sum of running total utilization of each CPU in PG) + */ +typedef struct pghw_util { + uint64_t pghw_util; /* sum(utilization) */ + uint64_t pghw_rate; /* Last observed utilization rate */ + uint64_t pghw_rate_max; /* Max observed rate (in units/sec) */ + hrtime_t pghw_time_stamp; /* Timestamp of last snapshot */ + /* + * sum(time utilization counters on) + */ + hrtime_t pghw_time_running; + /* + * sum(time utilization counters off) + */ + hrtime_t pghw_time_stopped; +} pghw_util_t; + + +/* + * Processor Group (physical sharing relationship) + */ +typedef struct pghw { + pg_t pghw_pg; /* processor group */ + pghw_type_t pghw_hw; /* HW sharing relationship */ + id_t pghw_instance; /* sharing instance identifier */ + pghw_handle_t pghw_handle; /* hw specific opaque handle */ + kstat_t *pghw_kstat; /* physical kstats exported */ + kstat_t *pghw_cu_kstat; /* for capacity and utilization */ + /* + * pghw_generation should be updated by superclasses whenever PG changes + * significanly (e.g. new CPUs join or leave PG). + */ + uint_t pghw_generation; /* generation number */ + + /* + * The following fields are used by PGHW cu kstats + */ + char *pghw_cpulist; /* list of CPUs */ + size_t pghw_cpulist_len; /* length of the list */ + /* + * Generation number at kstat update time + */ + uint_t pghw_kstat_gen; + pghw_util_t pghw_stats; /* Utilization data */ +} pghw_t; + +/* + * IDs associating a CPU with various physical hardware + */ +typedef struct cpu_physid { + id_t cpu_chipid; /* CPU's physical processor */ + id_t cpu_coreid; /* CPU's physical core */ + id_t cpu_cacheid; /* CPU's cache id */ +} cpu_physid_t; + +/* + * Physical PG initialization / CPU service hooks + */ +extern void pghw_init(pghw_t *, cpu_t *, pghw_type_t); +extern void pghw_fini(pghw_t *); +extern void pghw_cpu_add(pghw_t *, cpu_t *); +extern pghw_t *pghw_place_cpu(cpu_t *, pghw_type_t); +extern void pghw_cmt_fini(pghw_t *); + +/* + * Physical ID cache creation / destruction + */ +extern void pghw_physid_create(cpu_t *); +extern void pghw_physid_destroy(cpu_t *); + +/* + * CPU / PG hardware related seach operations + */ +extern pghw_t *pghw_find_pg(cpu_t *, pghw_type_t); +extern pghw_t *pghw_find_by_instance(id_t, pghw_type_t); +extern group_t *pghw_set_lookup(pghw_type_t); + +/* Hardware sharing relationship platform interfaces */ +extern int pg_plat_hw_shared(cpu_t *, pghw_type_t); +extern int pg_plat_cpus_share(cpu_t *, cpu_t *, pghw_type_t); +extern id_t pg_plat_hw_instance_id(cpu_t *, pghw_type_t); +extern pghw_type_t pg_plat_hw_rank(pghw_type_t, pghw_type_t); + +/* + * String representation of the hardware type + */ +extern char *pghw_type_string(pghw_type_t); + +/* + * What comprises a "core" may vary across processor implementations, + * and so the term itself is somewhat unstable. For this reason, there + * is no PGHW_CORE type, but we provide an interface here to allow platforms + * to express cpu <=> core mappings. + */ +extern id_t pg_plat_get_core_id(cpu_t *); + +#endif /* !_KERNEL && !_KMEMUSER */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PGHW_H */ diff --git a/illumos-x86_64/usr/include/sys/physmem.h b/illumos-x86_64/usr/include/sys/physmem.h new file mode 100644 index 00000000..f9f258cc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/physmem.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +#ifndef _PHYSMEM_H +#define _PHYSMEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ioctl values */ +#define PHYSMEM_SETUP 1 +#define PHYSMEM_MAP 2 +#define PHYSMEM_DESTROY 3 + +/* flags values */ +#define PHYSMEM_CAGE (1 << 0) +#define PHYSMEM_RETIRED (1 << 1) + +struct physmem_setup_param { + uint64_t req_paddr; /* requested physical address */ + uint64_t len; /* length of memory to be allocated */ + uint64_t user_va; /* VA to associate with req_paddr */ + uint64_t cookie; /* cookie returned for destroy function */ +}; + +struct physmem_map_param { + uint64_t req_paddr; /* requested physical address */ + uint64_t ret_va; /* VA which mapped req_paddr */ + uint32_t flags; /* flags for cage or retired pages */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _PHYSMEM_H */ diff --git a/illumos-x86_64/usr/include/sys/pic.h b/illumos-x86_64/usr/include/sys/pic.h new file mode 100644 index 00000000..0fda849c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pic.h @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_PIC_H +#define _SYS_PIC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Definitions for 8259 Programmable Interrupt Controller */ + +#define PIC_NEEDICW4 0x01 /* ICW4 needed */ +#define PIC_ICW1BASE 0x10 /* base for ICW1 */ +#define PIC_LTIM 0x08 /* level-triggered mode */ +#define PIC_86MODE 0x01 /* MCS 86 mode */ +#define PIC_AUTOEOI 0x02 /* do auto eoi's */ +#define PIC_SLAVEBUF 0x08 /* put slave in buffered mode */ +#define PIC_MASTERBUF 0x0C /* put master in buffered mode */ +#define PIC_SPFMODE 0x10 /* special fully nested mode */ +#define PIC_READISR 0x0B /* Read the ISR */ +#define PIC_READIRR 0x0A /* Read the IRR */ +#define PIC_NSEOI 0x20 /* Non-specific EOI command */ +#define PIC_SEOI 0x60 /* specific EOI command */ +#define PIC_SEOI_LVL7 (PIC_SEOI | 0x7) /* specific EOI for level 7 */ + +#if defined(__i386) || defined(__amd64) +#define PIC_VECTBASE 0x20 /* Vectors for external interrupts */ + /* start at 32. */ +#endif /* __i386 || __amd64 */ + +/* + * Interrupt configuration information specific to a particular computer. + * These constants are used to initialize tables in modules/pic/space.c. + * NOTE: The master pic must always be pic zero. + */ + +#define NPIC 2 /* 2 PICs */ +/* Port addresses */ +#define MCMD_PORT 0x20 /* master command port */ +#define MIMR_PORT 0x21 /* master intr mask register port */ +#define SCMD_PORT 0xA0 /* slave command port */ +#define SIMR_PORT 0xA1 /* slave intr mask register port */ +#define MASTERLINE 0x02 /* slave on IR2 of master PIC */ +#define SLAVEBASE 8 /* slave IR0 interrupt number */ +#define PICBUFFERED 0 /* PICs not in buffered mode */ + +struct standard_pic { + short c_npic; + uchar_t c_curmask[NPIC]; + uchar_t c_iplmask[MAXIPL*NPIC]; +}; + +#define CLOCK_VECTOR 0 /* line at which clock interrupt comes */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PIC_H */ diff --git a/illumos-x86_64/usr/include/sys/pit.h b/illumos-x86_64/usr/include/sys/pit.h new file mode 100644 index 00000000..8bb10c7f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pit.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PIT_H +#define _SYS_PIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Definitions for 8254 Programmable Interrupt Timer ports on AT 386 */ +#define PITCTR0_PORT 0x40 /* counter 0 port */ +#define PITCTR1_PORT 0x41 /* counter 1 port */ +#define PITCTR2_PORT 0x42 /* counter 2 port */ +#define PITCTL_PORT 0x43 /* PIT control port */ +#define PITAUX_PORT 0x61 /* PIT auxiliary port */ +#define SANITY_CTR0 0x48 /* sanity timer counter */ +#define SANITY_CTL 0x4B /* sanity control word */ +#define SANITY_CHECK 0x461 /* bit 7 set if sanity timer went off */ +#define FAILSAFE_NMI 0x80 /* to test if sanity timer went off */ +#define ENABLE_SANITY 0x04 /* Enables sanity clock NMI ints */ +#define RESET_SANITY 0x00 /* resets sanity NMI interrupt */ + +/* PIT Status Byte */ + +#define PITSTAT_OUTPUT 7 /* OUTPUT status bit */ +#define PITSTAT_NULLCNT 6 /* NULL COUNT status bit */ + +/* Definitions for 8254 commands */ + +#define PIT_READBACK 0xc0 /* read-back command */ +#define PIT_READBACKC0 0x02 /* enable read-back for counter 0 */ + +/* Following are used for Timer 0 */ +#define PIT_C0 0x00 /* select counter 0 */ +#define PIT_LOADMODE 0x30 /* load least significant byte */ + /* followed by most significant byte */ +#define PIT_NDIVMODE 0x04 /* divide by N counter */ +#define PIT_SQUAREMODE 0x06 /* square-wave mode */ +#define PIT_ENDSIGMODE 0x00 /* assert OUT at end-of-count mode */ + +/* Used for Timer 1. Used for delay calculations in countdown mode */ +#define PIT_C1 0x40 /* select counter 1 */ +#define PIT_READMODE 0x30 /* read or load least significant */ + /* byte followed by most significant */ +#define PIT_RATEMODE 0x06 /* square-wave mode for USART */ + +#define PIT_C2 0x80 /* select counter 2 */ + +#define SANITY_NUM 0xFFFF /* Sanity timer fires every .2 secs */ +/* bits used in auxiliary control port for timer 2 */ +#define PITAUX_GATE2 0x01 /* aux port, PIT gate 2 input */ +#define PITAUX_OUT2 0x02 /* aux port, PIT clock out 2 enable */ +#define PIT_HZ 1193182 /* 8254's cycles per second */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PIT_H */ diff --git a/illumos-x86_64/usr/include/sys/pkp_hash.h b/illumos-x86_64/usr/include/sys/pkp_hash.h new file mode 100644 index 00000000..e7602304 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pkp_hash.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _PKP_HASH_H_ +#define _PKP_HASH_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Pearson's string hash + * + * See: Communications of the ACM, June 1990 Vol 33 pp 677-680 + * http://portal.acm.org/citation.cfm?doid=78973.78978 + */ +#define PKP_HASH_SIZE 256 + +extern uint_t pkp_tab_hash(char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _PKP_HASH_H_ */ diff --git a/illumos-x86_64/usr/include/sys/pm.h b/illumos-x86_64/usr/include/sys/pm.h new file mode 100644 index 00000000..f98bb79f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pm.h @@ -0,0 +1,272 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PM_H +#define _SYS_PM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * The following ioctls may not exist or may have a different + * interpretation in a future release. + */ + +typedef enum { + PM_SCHEDULE, /* obsolete, not supported */ + PM_GET_IDLE_TIME, /* obsolete, not supported */ + PM_GET_NUM_CMPTS, /* obsolete, not supported */ + PM_GET_THRESHOLD, /* obsolete, not supported */ + PM_SET_THRESHOLD, /* obsolete */ + PM_GET_NORM_PWR, /* obsolete */ + PM_SET_CUR_PWR, /* obsolete */ + PM_GET_CUR_PWR, /* obsolete */ + PM_GET_NUM_DEPS, /* obsolete, not supported */ + PM_GET_DEP, /* obsolete, not supported */ + PM_ADD_DEP, /* obsolete */ + PM_REM_DEP, /* obsolete, not supported */ + PM_REM_DEVICE, /* obsolete, not supported */ + PM_REM_DEVICES, /* obsolete */ + PM_REPARSE_PM_PROPS, /* used only by ddivs pm tests */ + PM_DISABLE_AUTOPM, /* obsolete */ + PM_REENABLE_AUTOPM, /* obsolete */ + PM_SET_NORM_PWR, /* obsolete, not supported */ + PM_SET_DEVICE_THRESHOLD, + PM_GET_SYSTEM_THRESHOLD, + PM_SET_SYSTEM_THRESHOLD, + PM_START_PM, + PM_STOP_PM, + PM_RESET_PM, + PM_GET_STATS, + PM_GET_DEVICE_THRESHOLD, + PM_GET_POWER_NAME, + PM_GET_POWER_LEVELS, + PM_GET_NUM_COMPONENTS, + PM_GET_COMPONENT_NAME, + PM_GET_NUM_POWER_LEVELS, + PM_GET_STATE_CHANGE, + PM_GET_STATE_CHANGE_WAIT, + PM_DIRECT_PM, + PM_RELEASE_DIRECT_PM, + PM_DIRECT_NOTIFY, + PM_DIRECT_NOTIFY_WAIT, + PM_RESET_DEVICE_THRESHOLD, + PM_GET_PM_STATE, + PM_GET_DEVICE_TYPE, + PM_SET_COMPONENT_THRESHOLDS, + PM_GET_COMPONENT_THRESHOLDS, + PM_IDLE_DOWN, + PM_GET_DEVICE_THRESHOLD_BASIS, + PM_SET_CURRENT_POWER, /* replaces PM_SET_CUR_PWR */ + PM_GET_CURRENT_POWER, /* replaces PM_GET_CUR_PWR */ + PM_GET_FULL_POWER, /* replaces PM_GET_NORM_PWR */ + PM_ADD_DEPENDENT, /* replaces PM_ADD_DEP */ + PM_GET_TIME_IDLE, /* replaces PM_IDLE_TIME */ + PM_GET_DEFAULT_SYSTEM_THRESHOLD, + PM_ADD_DEPENDENT_PROPERTY, + PM_START_CPUPM, + PM_START_CPUPM_EV, + PM_START_CPUPM_POLL, + PM_STOP_CPUPM, + PM_GET_CPU_THRESHOLD, + PM_SET_CPU_THRESHOLD, + PM_GET_CPUPM_STATE, + PM_ENABLE_S3, /* allow pm to go to S3 state */ + PM_DISABLE_S3, /* do not allow pm to go to S3 state */ + PM_ENTER_S3, /* obsolete, not supported */ + PM_START_AUTOS3, + PM_STOP_AUTOS3, + PM_SEARCH_LIST, /* search S3 enable/disable list */ + PM_GET_AUTOS3_STATE, + PM_GET_S3_SUPPORT_STATE, + PM_GET_CMD_NAME, + PM_DISABLE_CPU_DEEP_IDLE, + PM_ENABLE_CPU_DEEP_IDLE, + PM_DEFAULT_CPU_DEEP_IDLE +} pm_cmds; + +/* + * Old name for these ioctls. + */ +#define PM_GET_POWER PM_GET_NORM_PWR +#define PM_SET_POWER PM_SET_CUR_PWR + +/* + * This structure is obsolete and will be removed in a later release + */ +typedef struct { + caddr_t who; /* Device to configure */ + int select; /* Selects the component or dependent */ + /* of the device */ + int level; /* Power or threshold level */ + caddr_t dependent; /* Buffer to hold name of dependent */ + int size; /* Size of dependent buffer */ +} pm_request; + +/* + * This is the new struct that replaces pm_request + */ +typedef struct pm_req { + char *physpath; /* physical path of device to configure */ + /* see libdevinfo(3) */ + int component; /* Selects the component of the device */ + int value; /* power level, threshold value, or count */ + void *data; /* command-dependent variable sized data */ + size_t datasize; /* Size of data buffer */ +} pm_req_t; + +/* + * PM_SEARCH_LIST requires a list name, manufacturer and product name + * Searches the named list for a matching tuple. + * NOTE: This structure may be removed in a later release. + */ +typedef struct pm_searchargs { + char *pms_listname; /* name of list to search */ + char *pms_manufacturer; /* 1st elment of tuple */ + char *pms_product; /* 2nd elment of tuple */ +} pm_searchargs_t; + +/* + * Use these for PM_ADD_DEPENDENT and PM_ADD_DEPENDENT_PROPERTY + */ +#define pmreq_keeper physpath /* keeper in the physpath field */ +#define pmreq_kept data /* kept in the data field */ + +/* + * Possible values for the event field of pm_state_change below + */ +typedef enum { + PSC_PENDING_CHANGE, /* device needs to change, is blocked */ + PSC_HAS_CHANGED /* device level has changed */ +} psc_events; + +#define PSC_EVENT_LOST 0x4000 /* buffer overrun */ +#define PSC_ALL_LOWEST 0x8000 /* all devices at lowest power */ + +/* + * Special value for power level fields in pm_state_change below + */ +#define PM_LEVEL_UNKNOWN -1 /* power level is unknown */ + +typedef struct pm_state_change { + caddr_t physpath; /* Device which has changed state */ + int component; /* which component changed state */ +#if defined(_BIG_ENDIAN) + ushort_t flags; /* PSC_EVENT_LOST, PSC_ALL_LOWEST */ + ushort_t event; /* type of event */ +#else + ushort_t event; /* type of event */ + ushort_t flags; /* PSC_EVENT_LOST, PSC_ALL_LOWEST */ +#endif + time_t timestamp; /* time of state change */ + int old_level; /* power level changing from */ + int new_level; /* power level changing to */ + size_t size; /* size of buffer physpath points to */ +} pm_state_change_t; + +#ifdef _SYSCALL32 + +/* Kernel's view of ILP32 structure version. */ + +/* + * This struct is obsolete and will be removed in a later release + */ +typedef struct { + caddr32_t who; /* Device to configure */ + int select; /* Selects the component or dependent */ + /* of the device */ + int level; /* Power or threshold level */ + caddr32_t dependent; /* Buffer to hold name of */ + /* dependent */ + size32_t size; /* Size of dependent buffer */ +} pm_request32; + +typedef struct pm_req32 { + caddr32_t physpath; /* physical path of device to configure */ + /* see libdevinfo(3) */ + int component; /* selects the component of the device */ + int value; /* power level, threshold value, or count */ + caddr32_t data; /* command-dependent variable sized data */ + size32_t datasize; /* Size of data buffer */ +} pm_req32_t; + +typedef struct pm_state_change32 { + caddr32_t physpath; /* Device which has changed state */ + int component; /* which component changed state */ +#if defined(_BIG_ENDIAN) + ushort_t flags; /* PSC_EVENT_LOST, PSC_ALL_LOWEST */ + ushort_t event; /* type of event */ +#else + ushort_t event; /* type of event */ + ushort_t flags; /* PSC_EVENT_LOST, PSC_ALL_LOWEST */ +#endif + time32_t timestamp; /* time of state change */ + int old_level; /* power level changing from */ + int new_level; /* power level changing to */ + size32_t size; /* size of buffer physpath points to */ +} pm_state_change32_t; + +typedef struct pm_searchargs32_t { + caddr32_t pms_listname; + caddr32_t pms_manufacturer; + caddr32_t pms_product; +} pm_searchargs32_t; + + +#endif + +/* + * Return values from ioctl commands that return pm state info. + */ + +typedef enum { + PM_SYSTEM_PM_ENABLED, + PM_SYSTEM_PM_DISABLED, + PM_NO_PM_COMPONENTS, + PM_CREATE_COMPONENTS, + PM_AUTOPM, + PM_DEFAULT_THRESHOLD, + PM_DEVICE_THRESHOLD, + PM_COMPONENT_THRESHOLD, + PM_OLD_THRESHOLD, + PM_DIRECTLY_MANAGED, + PM_CPU_THRESHOLD, + PM_CPU_PM_ENABLED, + PM_CPU_PM_DISABLED, + PM_CPU_PM_NOTSET, + PM_AUTOS3_ENABLED, + PM_AUTOS3_DISABLED, + PM_S3_SUPPORT_ENABLED, + PM_S3_SUPPORT_DISABLED +} pm_states; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PM_H */ diff --git a/illumos-x86_64/usr/include/sys/pmem.h b/illumos-x86_64/usr/include/sys/pmem.h new file mode 100644 index 00000000..3d23aec0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pmem.h @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PMEM_H +#define _SYS_PMEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * PMEM - Direct mapping physical memory pages to userland process + * + * Provide consolidation private functions used for directly (w/o occupying + * kernel virtual address space) allocating and exporting physical memory pages + * to userland. + */ + +/* + * Flags to pass to pmem_alloc + */ +#define PMEM_SLEEP 0x1 +#define PMEM_NOSLEEP 0x2 + +/* + * Called by driver devmap routine to pass physical memory mapping info to + * seg_dev framework, used only for physical memory allocated from + * devmap_pmem_alloc(). + */ +int devmap_pmem_setup(devmap_cookie_t, dev_info_t *dip, + struct devmap_callback_ctl *, devmap_pmem_cookie_t, offset_t, + size_t, uint_t, uint_t, const ddi_device_acc_attr_t *); + +/* + * Replace existing mapping using a new cookie, mainly gets called when doing + * fork(). Should be called in pertinent devmap_dup(9E). + */ +int devmap_pmem_remap(devmap_cookie_t, dev_info_t *dip, + devmap_pmem_cookie_t, offset_t, size_t, uint_t, uint_t, + const ddi_device_acc_attr_t *); + +/* + * Directly (i.e., without occupying kernel virtual address space) allocate + * 'npages' physical memory pages for exporting to user land. The allocated + * page_t pointer will be recorded in cookie. + */ +int devmap_pmem_alloc(size_t, uint_t, devmap_pmem_cookie_t *); + +void devmap_pmem_free(devmap_pmem_cookie_t); + +int devmap_pmem_getpfns(devmap_pmem_cookie_t, uint_t, pgcnt_t, pfn_t *); + +void pmem_init(); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PMEM_H */ diff --git a/illumos-x86_64/usr/include/sys/policy.h b/illumos-x86_64/usr/include/sys/policy.h new file mode 100644 index 00000000..b5d94800 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/policy.h @@ -0,0 +1,245 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015, Joyent, Inc. All rights reserved. + * Copyright 2023 RackTop Systems, Inc. + */ + +#ifndef _SYS_POLICY_H +#define _SYS_POLICY_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#ifndef _IN_PORT_T +#define _IN_PORT_T +typedef uint16_t in_port_t; +#endif + +/* + * Policy routines; in case we check privileges in-line. + * + * priv_policy + * privilege debugging + * audits success & failure + * returns 0 on success, error on failure + * + * priv_policy_choice + * determines extend of operation + * audit on success + * returns a boolean_t indicating success (B_TRUE) or failure. + * + * priv_policy_only + * when auditing is in appropriate (interrupt context) + * to determine context of operation + * returns a boolean_t indicating success (B_TRUE) or failure. + * + */ +int priv_policy(const cred_t *, int, boolean_t, int, const char *); +boolean_t priv_policy_only(const cred_t *, int, boolean_t); +boolean_t priv_policy_choice(const cred_t *, int, boolean_t); + +struct kipc_perm; +struct vfs; +struct proc; +struct priv_set; + +int secpolicy_acct(const cred_t *); +int secpolicy_require_privs(const cred_t *, const struct priv_set *); +int secpolicy_allow_setid(const cred_t *, uid_t, boolean_t); +int secpolicy_audit_config(const cred_t *); +int secpolicy_audit_getattr(const cred_t *, boolean_t); +int secpolicy_audit_modify(const cred_t *); +int secpolicy_blacklist(const cred_t *); +int secpolicy_chroot(const cred_t *); +int secpolicy_clock_highres(const cred_t *); +int secpolicy_console(const cred_t *); +int secpolicy_contract_identity(const cred_t *); +int secpolicy_contract_observer(const cred_t *, struct contract *); +boolean_t secpolicy_contract_observer_choice(const cred_t *); +int secpolicy_contract_event(const cred_t *); +boolean_t secpolicy_contract_event_choice(const cred_t *); +int secpolicy_coreadm(const cred_t *); +int secpolicy_cpc_cpu(const cred_t *); +int secpolicy_dispadm(const cred_t *); +int secpolicy_error_inject(const cred_t *); +int secpolicy_excl_open(const cred_t *); +int secpolicy_fs_allowed_mount(const char *); +int secpolicy_fs_config(const cred_t *, const struct vfs *); +int secpolicy_fs_linkdir(const cred_t *, const struct vfs *); +int secpolicy_fs_minfree(const cred_t *, const struct vfs *); +int secpolicy_fs_mount(cred_t *, vnode_t *, struct vfs *); +int secpolicy_fs_quota(const cred_t *, const struct vfs *); +int secpolicy_fs_unmount(cred_t *, struct vfs *); +int secpolicy_idmap(const cred_t *); +int secpolicy_ip(const cred_t *, int, boolean_t); +int secpolicy_ip_config(const cred_t *, boolean_t); +int secpolicy_dl_config(const cred_t *); +int secpolicy_iptun_config(const cred_t *); +int secpolicy_ipc_access(const cred_t *, const struct kipc_perm *, mode_t); +int secpolicy_ipc_config(const cred_t *); +int secpolicy_ipc_owner(const cred_t *, const struct kipc_perm *); +int secpolicy_kmdb(const cred_t *); +int secpolicy_lock_memory(const cred_t *); +int secpolicy_meminfo(const cred_t *); +int secpolicy_modctl(const cred_t *, int); +int secpolicy_net(const cred_t *, int, boolean_t); +int secpolicy_net_bindmlp(const cred_t *); +int secpolicy_net_config(const cred_t *, boolean_t); +int secpolicy_net_icmpaccess(const cred_t *); +int secpolicy_net_mac_aware(const cred_t *); +int secpolicy_net_mac_implicit(const cred_t *); +int secpolicy_net_observability(const cred_t *); +int secpolicy_net_privaddr(const cred_t *, in_port_t, int proto); +int secpolicy_net_rawaccess(const cred_t *); +boolean_t secpolicy_net_reply_equal(const cred_t *); +int secpolicy_newproc(const cred_t *); +int secpolicy_nfs(const cred_t *); +int secpolicy_pbind(const cred_t *); +int secpolicy_pcfs_modify_bootpartition(const cred_t *); +int secpolicy_pfexec_register(const cred_t *); +int secpolicy_ponline(const cred_t *); +int secpolicy_pool(const cred_t *); +int secpolicy_power_mgmt(const cred_t *); +int secpolicy_ppp_config(const cred_t *); +int secpolicy_proc_access(const cred_t *); +int secpolicy_proc_excl_open(const cred_t *); +int secpolicy_proc_owner(const cred_t *, const cred_t *, int); +int secpolicy_proc_zone(const cred_t *); +int secpolicy_psecflags(const cred_t *, struct proc *, struct proc *); +int secpolicy_pset(const cred_t *); +int secpolicy_rctlsys(const cred_t *, boolean_t); +int secpolicy_resource(const cred_t *); +int secpolicy_resource_anon_mem(const cred_t *); +int secpolicy_rpcmod_open(const cred_t *); +int secpolicy_rsm_access(const cred_t *, uid_t, mode_t); +int secpolicy_raisepriority(const cred_t *); +int secpolicy_setpriority(const cred_t *); +int secpolicy_settime(const cred_t *); +int secpolicy_smb(const cred_t *); +int secpolicy_smbfs_login(const cred_t *, uid_t); +int secpolicy_spec_open(const cred_t *, struct vnode *, int); +int secpolicy_sti(const cred_t *); +int secpolicy_swapctl(const cred_t *); +int secpolicy_sys_config(const cred_t *, boolean_t); +int secpolicy_zone_admin(const cred_t *, boolean_t); +int secpolicy_zone_config(const cred_t *); +int secpolicy_sys_devices(const cred_t *); +int secpolicy_systeminfo(const cred_t *); +int secpolicy_tasksys(const cred_t *); +int secpolicy_vnode_access(const cred_t *, vnode_t *, uid_t, mode_t); +int secpolicy_vnode_access2(const cred_t *, vnode_t *, uid_t, mode_t, mode_t); +int secpolicy_vnode_any_access(const cred_t *, vnode_t *, uid_t); +int secpolicy_vnode_chown(const cred_t *, uid_t); +int secpolicy_vnode_create_gid(const cred_t *); +int secpolicy_vnode_owner(const cred_t *, uid_t); +int secpolicy_vnode_remove(const cred_t *); +int secpolicy_vnode_setdac(const cred_t *, uid_t); +int secpolicy_vnode_setdac3(const cred_t *, uid_t, boolean_t); +int secpolicy_vnode_setid_retain(const cred_t *, boolean_t); +int secpolicy_vnode_setids_setgids(const cred_t *, gid_t); +int secpolicy_vnode_stky_modify(const cred_t *); +int secpolicy_vscan(const cred_t *); +int secpolicy_hwmanip(const cred_t *); +int secpolicy_zinject(const cred_t *); +int secpolicy_zfs(const cred_t *); +int secpolicy_ucode_update(const cred_t *); +int secpolicy_sadopen(const cred_t *); +void secpolicy_setid_clear(vattr_t *, cred_t *); +void secpolicy_fs_mount_clearopts(cred_t *, struct vfs *); +int secpolicy_setid_setsticky_clear(vnode_t *, vattr_t *, + const vattr_t *, cred_t *); +int secpolicy_xvattr(xvattr_t *, uid_t, cred_t *, vtype_t); +int secpolicy_xvm_control(const cred_t *); + +int secpolicy_basic_exec(const cred_t *, vnode_t *); +int secpolicy_basic_fork(const cred_t *); +int secpolicy_basic_link(const cred_t *); +int secpolicy_basic_file_read(const cred_t *, vnode_t *, const char *); +int secpolicy_basic_file_write(const cred_t *, vnode_t *, const char *); +int secpolicy_basic_net_access(const cred_t *); +int secpolicy_basic_proc(const cred_t *); +int secpolicy_basic_procinfo(const cred_t *, struct proc *, struct proc *); + +int secpolicy_gart_access(const cred_t *); +int secpolicy_gart_map(const cred_t *); +/* + * This function to be called from xxfs_setattr(). + * Must be called with the node's attributes read-write locked. + * + * cred_t * - acting credentials + * struct vnode * - vnode we're operating on + * struct vattr *va - new attributes, va_mask may be + * changed on return from a call + * struct vattr *oldva - old attributes, need include owner + * and mode only + * int flags - setattr flags + * int iaccess(void *node, int mode, cred_t *cr) + * - non-locking internal access function + * mode be checked + * w/ VREAD|VWRITE|VEXEC, not fs + * internal mode encoding. + * + * void *node - internal node (inode, tmpnode) to + * pass as arg to iaccess + */ +int secpolicy_vnode_setattr(cred_t *, struct vnode *, struct vattr *, + const struct vattr *, int, int (void *, int, cred_t *), void *); + +/* + * Test privilege. Audit success or failure, allow privilege debugging. + * Returns 0 for success, err for failure. + */ +#define PRIV_POLICY(cred, priv, all, err, reason) \ + priv_policy((cred), (priv), (all), (err), (reason)) + +/* + * Test privilege. Audit success only, no privilege debugging. + * Returns 1 for success, and 0 for failure. + */ +#define PRIV_POLICY_CHOICE(cred, priv, all) \ + priv_policy_choice((cred), (priv), (all)) + +/* + * Test privilege. No priv_debugging, no auditing. + * Returns 1 for success, and 0 for failure. + */ + +#define PRIV_POLICY_ONLY(cred, priv, all) \ + priv_policy_only((cred), (priv), (all)) + + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_POLICY_H */ diff --git a/illumos-x86_64/usr/include/sys/poll.h b/illumos-x86_64/usr/include/sys/poll.h new file mode 100644 index 00000000..558edbfb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/poll.h @@ -0,0 +1,159 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1995, 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright 2015, Joyent, Inc. + */ + +#ifndef _SYS_POLL_H +#define _SYS_POLL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structure of file descriptor/event pairs supplied in + * the poll arrays. + */ +typedef struct pollfd { + int fd; /* file desc to poll */ + short events; /* events of interest on fd */ + short revents; /* events that occurred on fd */ +} pollfd_t; + +typedef unsigned long nfds_t; + +/* + * Testable select events + */ +#define POLLIN 0x0001 /* fd is readable */ +#define POLLPRI 0x0002 /* high priority info at fd */ +#define POLLOUT 0x0004 /* fd is writeable (won't block) */ +#define POLLRDNORM 0x0040 /* normal data is readable */ +#define POLLWRNORM POLLOUT +#define POLLRDBAND 0x0080 /* out-of-band data is readable */ +#define POLLWRBAND 0x0100 /* out-of-band data is writeable */ +#define POLLRDHUP 0x4000 /* read-side hangup */ + +#define POLLNORM POLLRDNORM + +/* + * Non-testable poll events (may not be specified in events field, + * but may be returned in revents field). + */ +#define POLLERR 0x0008 /* fd has error condition */ +#define POLLHUP 0x0010 /* fd has been hung up on */ +#define POLLNVAL 0x0020 /* invalid pollfd entry */ + +/* + * These events will never be specified in revents, but may be specified in + * events to control /dev/poll behavior. + */ +#define POLLREMOVE 0x0800 /* remove cached /dev/poll fd */ +#define POLLONESHOT 0x1000 /* /dev/poll should one-shot this fd */ +#define POLLET 0x2000 /* edge-triggered /dev/poll fd */ + +#ifdef _KERNEL + +/* + * Additional private poll flags supported only by strpoll(). + * Must be bit-wise distinct from the above POLL flags. + */ +#define POLLRDDATA 0x0200 /* Wait for M_DATA; ignore M_PROTO only msgs */ +#define POLLNOERR 0x0400 /* Ignore POLLERR conditions */ + +#define POLLCLOSED 0x8000 /* a (cached) poll fd has been closed */ + +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) || defined(_KMEMUSER) + +#include + +/* + * XXX We are forced to use a forward reference here because including + * file.h here will break i386 build. The real solution is to fix the + * broken parts in usr/src/stand/lib/fs. + */ +struct fpollinfo; + +/* + * Poll list head structure. A pointer to this is passed to + * pollwakeup() from the caller indicating an event has occurred. + * Only the ph_list field is used, but for DDI compliance, we can't + * change the size of the structure. + */ +typedef struct pollhead { + struct polldat *ph_list; /* list of pollers */ + void *ph_pad1; /* unused -- see above */ + short ph_pad2; /* unused -- see above */ +} pollhead_t; + +#if defined(_KERNEL) + +/* + * Routine called to notify a process of the occurrence + * of an event. + */ +extern void pollwakeup(pollhead_t *, short); + +/* + * Internal routines. + */ +extern int polllock(pollhead_t *, kmutex_t *); +extern int pollunlock(int *); +extern void pollrelock(int); +extern void pollcleanup(void); +extern void pollblockexit(struct fpollinfo *); +extern void pollcacheclean(struct fpollinfo *, int); + +/* + * public poll head interface: + * + * pollhead_clean clean up all polldats on a pollhead list + */ +extern void pollhead_clean(pollhead_t *); + +#endif /* defined(_KERNEL) */ + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +#if !defined(_KERNEL) +int poll(struct pollfd *, nfds_t, int); +#endif /* !_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_POLL_H */ diff --git a/illumos-x86_64/usr/include/sys/poll_impl.h b/illumos-x86_64/usr/include/sys/poll_impl.h new file mode 100644 index 00000000..388849a1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/poll_impl.h @@ -0,0 +1,382 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2017 Joyent, Inc. + * Copyright 2022 Oxide Computer Company + */ + +#ifndef _SYS_POLL_IMPL_H +#define _SYS_POLL_IMPL_H + +/* + * Caching Poll Subsystem: + * + * Each kernel thread (1), if engaged in poll system call, has a reference to + * a pollstate_t (2), which contains relevant flags and locks. The pollstate_t + * contains a pointer to a pollcache_t (3), which caches the state of previous + * calls to poll. A bitmap (4) is stored inside the poll cache, where each + * bit represents a file descriptor. The bits are set if the corresponding + * device has a polled event pending. Only fds with their bit set will be + * examined on the next poll invocation. The pollstate_t also contains a list + * of fd sets (5), which are represented by the pollcacheset_t type. These + * structures keep track of the pollfd_t arrays (6) passed in from userland. + * Each polled file descriptor has a corresponding polldat_t which can be + * chained onto a device's pollhead, and these are kept in a hash table (7) + * inside the pollcache_t. The hash table allows efficient conversion of a + * given fd to its corresponding polldat_t. + * + * (1) (2) + * +-----------+ +-------------+ + * | kthread_t |--->| pollstate_t |-->+-------------+ (6) + * +-----------+ +-------------+(5)| pcacheset_t |->[_][_][_][_] pollfd_t + * | +-------------+ + * | | pcacheset_t |->[_][_][_][_] pollfd_t + * (1a) | +-------------+ + * +---------------+ | + * | /dev/poll tbl | | + * +-v-------------+ | + * | | + * +------------------+ | + * (7) (3) V v + * polldat hash +-------------+ (4) bitmap representing fd space + * [_][_][_][_]<----| |--->000010010010001010101010101010110 + * | | | | | pollcache_t | + * . v . . | | + * [polldat_t] +-------------+ + * | + * [polldat_t] + * | + * v + * NULL + * + * + * Both poll system call and /dev/poll use the pollcache_t structure + * definition and the routines managing the structure. But poll(2) and + * /dev/poll have their own copy of the structures. The /dev/poll driver + * table (1a) contains an array of pointers, each pointing at a pollcache_t + * struct (3). A device minor number is used as an device table index. + * + */ +#include + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Typedefs + */ +struct pollcache; +struct pollstate; +struct pcachelink; +struct polldat; + +typedef struct pollcache pollcache_t; +typedef struct pollstate pollstate_t; +typedef struct pcachelink pcachelink_t; +typedef struct polldat polldat_t; + +/* + * description of pollcacheset structure + */ +typedef struct pollcacheset { + uintptr_t pcs_usradr; /* usr pollfd array address */ + pollfd_t *pcs_pollfd; /* cached poll lists */ + size_t pcs_nfds; /* number of poll fd in cached list */ + ulong_t pcs_count; /* for LU replacement policy */ +} pollcacheset_t; + +#define POLLFDSETS 2 + +/* + * Maximum depth for recusive poll operations. + */ +#define POLLMAXDEPTH 5 + +/* + * State information kept by each polling thread + */ +struct pollstate { + pollfd_t *ps_pollfd; /* hold the current poll list */ + size_t ps_nfds; /* size of ps_pollfd */ + kmutex_t ps_lock; /* mutex for sleep/wakeup */ + pollcache_t *ps_pcache; /* cached poll fd set */ + pollcacheset_t *ps_pcacheset; /* cached poll lists */ + int ps_nsets; /* no. of cached poll sets */ + pollfd_t *ps_dpbuf; /* return pollfd buf used by devpoll */ + size_t ps_dpbufsize; /* size of ps_dpbuf */ + int ps_depth; /* epoll recursion depth */ + pollcache_t *ps_pc_stack[POLLMAXDEPTH]; /* epoll recursion state */ + pollcache_t *ps_contend_pc; /* pollcache waited on */ + pollstate_t *ps_contend_nextp; /* next in contender list */ + pollstate_t **ps_contend_pnextp; /* pointer-to-previous-next */ + int ps_flags; /* state flags */ + short ps_implicit_ev; /* implicit poll event interest */ +}; + +/* pollstate flags */ +#define POLLSTATE_STALEMATE 0x1 +#define POLLSTATE_ULFAIL 0x2 + +/* pollstate_enter results */ +#define PSE_SUCCESS 0 +#define PSE_FAIL_DEPTH 1 +#define PSE_FAIL_LOOP 2 +#define PSE_FAIL_DEADLOCK 3 +#define PSE_FAIL_POLLSTATE 4 + +/* + * poll cache size defines + */ +#define POLLCHUNKSHIFT 8 /* hash table increment size is 256 */ +#define POLLHASHCHUNKSZ (1 << POLLCHUNKSHIFT) +#define POLLHASHINC 2 /* poll hash table growth factor */ +#define POLLHASHTHRESHOLD 2 /* poll hash list length threshold */ +#define POLLHASH(x, y) ((y) % (x)) /* poll hash function */ + +/* + * poll.c assumes the POLLMAPCHUNK is power of 2 + */ +#define POLLMAPCHUNK 2048 /* bitmap inc -- each for 2K of polled fd's */ + +/* + * used to refrence from watched fd back to the fd position in cached + * poll list for quick revents update. + */ +typedef struct xref { + ssize_t xf_position; /* xref fd position in poll fd list */ + short xf_refcnt; /* ref cnt of same fd in poll list */ +} xref_t; + +#define POLLPOSINVAL (-1L) /* xf_position is invalid */ +#define POLLPOSTRANS (-2L) /* xf_position is transient state */ + + +typedef enum pclstate { + PCL_INIT = 0, /* just allocated/zeroed, prior */ + PCL_VALID, /* linked with both parent and child pollcaches */ + PCL_STALE, /* still linked but marked stale, pending refresh */ + PCL_INVALID, /* dissociated from one pollcache, awaiting cleanup */ + PCL_FREE /* only meant to indicate use-after-free */ +} pclstate_t; + +/* + * The pcachelink struct creates an association between parent and child + * pollcaches in a recursive /dev/poll operation. Fields are protected by + * pcl_lock although manipulation of pcl_child_next or pcl_parent_next also + * requires holding pc_lock in the respective pcl_parent_pc or pcl_child_pc + * pollcache. + */ +struct pcachelink { + kmutex_t pcl_lock; /* protects contents */ + pclstate_t pcl_state; /* status of link entry */ + int pcl_refcnt; /* ref cnt of linked pcaches */ + pollcache_t *pcl_child_pc; /* child pollcache */ + pollcache_t *pcl_parent_pc; /* parent pollcache */ + pcachelink_t *pcl_child_next; /* next in child list */ + pcachelink_t *pcl_parent_next; /* next in parents list */ +}; + + +/* + * polldat is an entry for a cached poll fd. A polldat struct can be in + * poll cache table as well as on pollhead ph_list, which is used by + * pollwakeup to wake up a sleeping poller. There should be one polldat + * per polled fd hanging off pollstate struct. + */ +struct polldat { + int pd_fd; /* cached poll fd */ + int pd_events; /* union of all polled events */ + file_t *pd_fp; /* used to detect fd reuse */ + pollhead_t *pd_php; /* used to undo poll registration */ + kthread_t *pd_thread; /* used for waking up a sleep thrd */ + pollcache_t *pd_pcache; /* a ptr to the pollcache of this fd */ + polldat_t *pd_next; /* next on pollhead's ph_list */ + polldat_t *pd_hashnext; /* next on pollhead's ph_list */ + int pd_count; /* total count from all ref'ed sets */ + int pd_nsets; /* num of xref sets, used by poll(2) */ + xref_t *pd_ref; /* ptr to xref info, 1 for each set */ + port_kevent_t *pd_portev; /* associated port event struct */ + uf_entry_gen_t pd_gen; /* fd generation at cache time */ + uint64_t pd_epolldata; /* epoll data, if any */ +}; + +/* + * One cache for each thread that polls. Points to a bitmap (used by pollwakeup) + * and a hash table of polldats. + * + * Because of the handling required in pollrelock(), portfs abuses the notion of + * an active pollcache (t_pollcache), providing its own struct port_fdcache_t. + * It has matching pc_lock and pc_flag members at the correct offsets, but none + * of its other fields can be accessed (through t_pollcache) safetly. + */ +struct pollcache { + kmutex_t pc_lock; /* lock to protect pollcache */ + ulong_t *pc_bitmap; /* point to poll fd bitmap */ + polldat_t **pc_hash; /* points to a hash table of ptrs */ + int pc_mapend; /* the largest fd encountered so far */ + int pc_mapsize; /* the size of current map */ + int pc_hashsize; /* the size of current hash table */ + int pc_fdcount; /* track how many fd's are hashed */ + int pc_flag; /* see pc_flag define below */ + int pc_busy; /* can only exit when its 0 */ + kmutex_t pc_no_exit; /* protects pc_busy*, can't be nested */ + kcondvar_t pc_busy_cv; /* cv to wait on if ps_busy != 0 */ + kcondvar_t pc_cv; /* cv to wait on if needed */ + pid_t pc_pid; /* for check acc rights, devpoll only */ + int pc_mapstart; /* where search start, devpoll only */ + pcachelink_t *pc_parents; /* linked list of epoll parents */ + pcachelink_t *pc_children; /* linked list of epoll children */ +}; + +/* pc_flag */ +#define PC_POLLWAKE 0x02 /* pollwakeup() occurred */ +#define PC_EPOLL 0x04 /* pollcache is epoll-enabled */ +/* + * PC_PORTFS is not a flag for "real" pollcaches, but rather an indicator for + * when portfs sets t_pollcache to a port_fdcache_t pointer. If, while + * debugging a system, one sees PC_PORTFS in pc_flag, they will know to + * disregard the other fields, as it is not a pollcache. + */ +#define PC_PORTFS 0x08 + +#if defined(_KERNEL) +/* + * Internal routines. + */ +extern void pollnotify(pollcache_t *, int); + +/* + * public poll head interfaces (see poll.h): + * + * pollhead_clean clean up all polldats on a pollhead list + */ +extern void pollhead_clean(pollhead_t *); + +/* + * private poll head interfaces: + * + * polldat_associate adds a polldat to a pollhead list + * polldat_disassociate remove polldat from its assoc'd pollhead list + */ +extern void polldat_associate(polldat_t *, pollhead_t *); +extern void polldat_disassociate(polldat_t *); + +/* + * poll state interfaces: + * + * pollstate_create initializes per-thread pollstate + * pollstate_destroy cleans up per-thread pollstate + * pollstate_enter safely lock pollcache for pollstate + * pollstate_exit unlock pollcache from pollstate + */ +extern pollstate_t *pollstate_create(void); +extern void pollstate_destroy(pollstate_t *); +extern int pollstate_enter(pollcache_t *); +extern void pollstate_exit(pollcache_t *); + +/* + * public pcache interfaces: + * + * pcache_alloc allocate a poll cache skeleton + * pcache_create creates all poll cache supporting data struct + * pcache_insert cache a poll fd, calls pcache_insert_fd + * pcache_lookup given an fd list, returns a cookie + * pcache_poll polls the cache for fd's having events on them + * pcache_clean clean up all the pollhead and fpollinfo reference + * pcache_destroy destroys the pcache + */ +extern pollcache_t *pcache_alloc(); +extern void pcache_create(pollcache_t *, nfds_t); +extern int pcache_insert(pollstate_t *, file_t *, pollfd_t *, int *, ssize_t, + int); +extern int pcache_poll(pollfd_t *, pollstate_t *, nfds_t, int *, int); +extern void pcache_clean(pollcache_t *); +extern void pcache_destroy(pollcache_t *); + +/* + * private pcache interfaces: + * + * pcache_lookup_fd lookup an fd, returns a polldat + * pcache_alloc_fd allocates and returns a polldat + * pcache_insert_fd insert an fd into pcache (called by pcache_insert) + * pcache_delete_fd insert an fd into pcache (called by pcacheset_delete_fd) + * pcache_grow_hashtbl grows the pollcache hash table and rehash + * pcache_grow_map grows the pollcache bitmap + * pcache_update_xref update cross ref (from polldat back to cacheset) info + * pcache_clean_entry cleanup an entry in pcache and more... + * pcache_wake_parents wake linked parent pollcaches + */ +extern polldat_t *pcache_lookup_fd(pollcache_t *, int); +extern polldat_t *pcache_alloc_fd(int); +extern void pcache_insert_fd(pollcache_t *, polldat_t *, nfds_t); +extern int pcache_delete_fd(pollstate_t *, int, size_t, int, uint_t); +extern void pcache_grow_hashtbl(pollcache_t *, nfds_t); +extern void pcache_grow_map(pollcache_t *, int); +extern void pcache_update_xref(pollcache_t *, int, ssize_t, int); +extern void pcache_clean_entry(pollstate_t *, int); +extern void pcache_wake_parents(pollcache_t *); + +/* + * pcacheset interfaces: + * + * pcacheset_create creates new pcachesets (easier for dynamic pcachesets) + * pcacheset_destroy destroys a pcacheset + * pcacheset_cache_list caches and polls a new poll list + * pcacheset_remove_list removes (usually a partial) cached poll list + * pcacheset_resolve resolves extant pcacheset and fd list + * pcacheset_cmp compares a pcacheset with an fd list + * pcacheset_invalidate invalidate entries in pcachesets + * pcacheset_reset_count resets the usage counter of pcachesets + * pcacheset_replace selects a poll cacheset for replacement + */ +extern pollcacheset_t *pcacheset_create(int); +extern void pcacheset_destroy(pollcacheset_t *, int); +extern int pcacheset_cache_list(pollstate_t *, pollfd_t *, int *, int); +extern void pcacheset_remove_list(pollstate_t *, pollfd_t *, int, int, int, + int); +extern int pcacheset_resolve(pollstate_t *, nfds_t, int *, int); +extern int pcacheset_cmp(pollfd_t *, pollfd_t *, pollfd_t *, int); +extern void pcacheset_invalidate(pollstate_t *, polldat_t *); +extern void pcacheset_reset_count(pollstate_t *, int); +extern int pcacheset_replace(pollstate_t *); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +#endif /* _SYS_POLL_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/pool.h b/illumos-x86_64/usr/include/sys/pool.h new file mode 100644 index 00000000..c4cc9fc2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pool.h @@ -0,0 +1,141 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_POOL_H +#define _SYS_POOL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define POOL_DEFAULT 0 /* default pool's ID */ +#define POOL_MAXID 999999 /* maximum possible pool ID */ +#define POOL_INVALID -1 + +/* pools states */ +#define POOL_DISABLED 0 /* pools enabled */ +#define POOL_ENABLED 1 /* pools disabled */ + +#ifdef _KERNEL + +struct pool_pset; + +typedef struct pool { + poolid_t pool_id; /* pool ID */ + uint32_t pool_ref; /* # of procs in this pool */ + list_node_t pool_link; /* links to next/prev pools */ + nvlist_t *pool_props; /* pool properties */ + struct pool_pset *pool_pset; /* pool's pset */ +} pool_t; + +/* + * Flags for pool_do_bind + */ +#define POOL_BIND_PSET 0x00000001 +#define POOL_BIND_ALL POOL_BIND_PSET + +/* + * Result codes for pool_get_class() + */ +#define POOL_CLASS_UNSET -1 /* no scheduling class set */ +#define POOL_CLASS_INVAL -2 /* class is invalid */ + +extern int pool_count; /* current number of pools */ +extern pool_t *pool_default; /* default pool pointer */ +extern int pool_state; /* pools state -- enabled/disabled */ +extern void *pool_buf; /* last state snapshot */ +extern size_t pool_bufsz; /* size of pool_buf */ + +/* + * Lookup routines + */ +extern pool_t *pool_lookup_pool_by_id(poolid_t); +extern pool_t *pool_lookup_pool_by_name(char *); +extern pool_t *pool_lookup_pool_by_pset(int); + +/* + * Configuration routines + */ +extern void pool_init(void); +extern int pool_status(int); +extern int pool_create(int, int, id_t *); +extern int pool_destroy(int, int, id_t); +extern int pool_transfer(int, id_t, id_t, uint64_t); +extern int pool_assoc(poolid_t, int, id_t); +extern int pool_dissoc(poolid_t, int); +extern int pool_bind(poolid_t, idtype_t, id_t); +extern id_t pool_get_class(pool_t *); +extern int pool_do_bind(pool_t *, idtype_t, id_t, int); +extern int pool_query_binding(idtype_t, id_t, id_t *); +extern int pool_xtransfer(int, id_t, id_t, uint_t, id_t *); +extern int pool_pack_conf(void *, size_t, size_t *); +extern int pool_propput(int, int, id_t, nvpair_t *); +extern int pool_proprm(int, int, id_t, char *); +extern int pool_propget(char *, int, int, id_t, nvlist_t **); +extern int pool_commit(int); +extern void pool_get_name(pool_t *, char **); + +/* + * Synchronization routines + */ +extern void pool_lock(void); +extern int pool_lock_intr(void); +extern int pool_lock_held(void); +extern void pool_unlock(void); +extern void pool_barrier_enter(void); +extern void pool_barrier_exit(void); + +typedef enum { + POOL_E_ENABLE, + POOL_E_DISABLE, + POOL_E_CHANGE, +} pool_event_t; + +typedef void pool_event_cb_func_t(pool_event_t, poolid_t, void *); + +typedef struct pool_event_cb { + pool_event_cb_func_t *pec_func; + void *pec_arg; + list_node_t pec_list; +} pool_event_cb_t; + +/* + * Routines used to register interest in changes in cpu pools. + */ +extern void pool_event_cb_register(pool_event_cb_t *); +extern void pool_event_cb_unregister(pool_event_cb_t *); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_POOL_H */ diff --git a/illumos-x86_64/usr/include/sys/pool_impl.h b/illumos-x86_64/usr/include/sys/pool_impl.h new file mode 100644 index 00000000..77d54d92 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pool_impl.h @@ -0,0 +1,301 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_POOL_IMPL_H +#define _SYS_POOL_IMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Pools driver ioctl interfaces + */ +#define POOL_STATUS 0 +#define POOL_STATUSQ 1 +#define POOL_CREATE 2 +#define POOL_DESTROY 3 +#define POOL_QUERY 4 +#define POOL_ASSOC 5 +#define POOL_DISSOC 6 +#define POOL_TRANSFER 7 +#define POOL_XTRANSFER 8 +#define POOL_PROPGET 9 +#define POOL_PROPPUT 10 +#define POOL_PROPRM 11 +#define POOL_BIND 12 +#define POOL_BINDQ 13 +#define POOL_COMMIT 14 + +/* + * Pools-related exacct catalog IDs + */ +#define EXD_GROUP_SYSTEM 0x000000 +#define EXD_SYSTEM_PROP 0x000001 +#define EXD_SYSTEM_TSTAMP 0x000002 + +#define EXD_GROUP_POOL 0x000100 +#define EXD_POOL_POOLID 0x000101 +#define EXD_POOL_PSETID 0x000102 +#define EXD_POOL_PROP 0x000104 +#define EXD_POOL_TSTAMP 0x000105 + +#define EXD_GROUP_PSET 0x000200 +#define EXD_PSET_PSETID 0x000201 +#define EXD_PSET_PROP 0x000202 +#define EXD_PSET_TSTAMP 0x000203 + +#define EXD_GROUP_CPU 0x000400 +#define EXD_CPU_CPUID 0x000401 +#define EXD_CPU_PROP 0x000402 +#define EXD_CPU_TSTAMP 0x000403 + +/* + * Element Types + */ +typedef enum pool_elem_class { + PEC_INVALID = 0, /* invalid class, for error reporting */ + PEC_SYSTEM, /* a system */ + PEC_POOL, /* a pool */ + PEC_RES_COMP, /* a set */ + PEC_RES_AGG, /* a set */ + PEC_COMP /* a resource component */ +} pool_elem_class_t; + +typedef enum pool_resource_elem_class { + PREC_INVALID = 0, + PREC_PSET /* processor set */ +} pool_resource_elem_class_t; + +typedef enum pool_component_elem_class { + PCEC_INVALID = 0, + PCEC_CPU /* CPU */ +} pool_component_elem_class_t; + +/* + * Constants used by devpool. + */ +#define POOL_IDLIST_SIZE 1024 +#define POOL_PROPNAME_SIZE 8192 +#define POOL_PROPBUF_SIZE 65535 + +typedef struct pool_status { + int ps_io_state; +} pool_status_t; + +typedef struct pool_create { + id_t pc_i_id; + int pc_o_type; + int pc_o_sub_type; +} pool_create_t; + +typedef struct pool_destroy { + int pd_o_type; + int pd_o_sub_type; + id_t pd_o_id; +} pool_destroy_t; + +typedef struct pool_query { + size_t pq_io_bufsize; + void *pq_io_buf; +} pool_query_t; + +#ifdef _SYSCALL32 +typedef struct pool_query32 { + size32_t pq_io_bufsize; + caddr32_t pq_io_buf; +} pool_query32_t; +#endif /* _SYSCALL32 */ + +typedef struct pool_assoc { + poolid_t pa_o_pool_id; + pool_resource_elem_class_t pa_o_id_type; + id_t pa_o_res_id; +} pool_assoc_t; + +typedef struct pool_dissoc { + poolid_t pd_o_pool_id; + pool_resource_elem_class_t pd_o_id_type; +} pool_dissoc_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct pool_transfer { + pool_resource_elem_class_t pt_o_id_type; + id_t pt_o_src_id; + id_t pt_o_tgt_id; + uint64_t pt_o_qty; +} pool_transfer_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +typedef struct pool_xtransfer { + pool_resource_elem_class_t px_o_id_type; + id_t px_o_src_id; + id_t px_o_tgt_id; + uint_t px_o_complist_size; + id_t *px_o_comp_list; +} pool_xtransfer_t; + +#ifdef _SYSCALL32 +typedef struct pool_xtransfer32 { + pool_resource_elem_class_t px_o_id_type; + id_t px_o_src_id; + id_t px_o_tgt_id; + uint_t px_o_complist_size; + caddr32_t px_o_comp_list; +} pool_xtransfer32_t; +#endif /* _SYSCALL32 */ + +typedef struct pool_propget { + size_t pp_i_bufsize; + char *pp_i_buf; + pool_elem_class_t pp_o_id_type; + pool_resource_elem_class_t pp_o_id_subtype; + id_t pp_o_id; + uint_t pp_o_prop_name_size; + char *pp_o_prop_name; +} pool_propget_t; + +#ifdef _SYSCALL32 +typedef struct pool_propget32 { + size32_t pp_i_bufsize; + caddr32_t pp_i_buf; + pool_elem_class_t pp_o_id_type; + pool_resource_elem_class_t pp_o_id_subtype; + id_t pp_o_id; + uint_t pp_o_prop_name_size; + caddr32_t pp_o_prop_name; +} pool_propget32_t; +#endif /* _SYSCALL32 */ + +typedef struct pool_propgetall { + size_t pp_i_proplist_size; + char *pp_i_prop_list; + pool_elem_class_t pp_o_id_type; + pool_resource_elem_class_t pp_o_id_sub_type; + id_t pp_o_id; +} pool_propgetall_t; + +#ifdef _SYSCALL32 +typedef struct pool_propgetall32 { + size32_t pp_i_proplist_size; + caddr32_t pp_i_prop_list; + pool_elem_class_t pp_o_id_type; + pool_resource_elem_class_t pp_o_id_sub_type; + id_t pp_o_id; +} pool_propgetall32_t; +#endif /* _SYSCALL32 */ + +typedef struct pool_propput { + pool_elem_class_t pp_o_id_type; + pool_resource_elem_class_t pp_o_id_sub_type; + id_t pp_o_id; + size_t pp_o_bufsize; + char *pp_o_buf; +} pool_propput_t; + +#ifdef _SYSCALL32 +typedef struct pool_propput32 { + pool_elem_class_t pp_o_id_type; + pool_resource_elem_class_t pp_o_id_sub_type; + id_t pp_o_id; + size32_t pp_o_bufsize; + caddr32_t pp_o_buf; +} pool_propput32_t; +#endif /* _SYSCALL32 */ + +typedef struct pool_proprm { + pool_elem_class_t pp_o_id_type; + pool_resource_elem_class_t pp_o_id_sub_type; + id_t pp_o_id; + size_t pp_o_prop_name_size; + char *pp_o_prop_name; +} pool_proprm_t; + +#ifdef _SYSCALL32 +typedef struct pool_proprm32 { + pool_elem_class_t pp_o_id_type; + pool_resource_elem_class_t pp_o_id_sub_type; + id_t pp_o_id; + size32_t pp_o_prop_name_size; + caddr32_t pp_o_prop_name; +} pool_proprm32_t; +#endif /* _SYSCALL32 */ + +typedef struct pool_bind { + idtype_t pb_o_id_type; + id_t pb_o_pool_id; + id_t pb_o_id; +} pool_bind_t; + +typedef struct pool_bindq { + idtype_t pb_o_id_type; + poolid_t pb_i_id; + id_t pb_o_id; +} pool_bindq_t; + +/* + * Values for pp_type below + */ +#define PP_READ 0x0001 +#define PP_WRITE 0x0002 +#define PP_RDWR 0x0003 +#define PP_OPTIONAL 0x0004 +#define PP_STORED 0x0008 +#define PP_INIT 0x0010 +#define PP_HIDDEN 0x0020 + +#ifdef _KERNEL + +/* + * For special properties + */ +typedef struct pool_property { + char *pp_name; /* name of the property */ + data_type_t pp_type; /* type of the property */ + int pp_perm; /* permissions */ +} pool_property_t; + +extern int pool_propput_common(nvlist_t *, nvpair_t *, pool_property_t *); +extern int pool_proprm_common(nvlist_t *, char *, pool_property_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_POOL_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/pool_pset.h b/illumos-x86_64/usr/include/sys/pool_pset.h new file mode 100644 index 00000000..c37a8413 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pool_pset.h @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_POOL_PSET_H +#define _SYS_POOL_PSET_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +struct zone; + +typedef struct pool_pset { + psetid_t pset_id; /* pset ID */ + uint_t pset_npools; /* # of pools we belong to */ + list_node_t pset_link; /* link to next/prev pset */ + nvlist_t *pset_props; /* pset properties */ +} pool_pset_t; + +extern pool_pset_t *pool_pset_default; /* default pset */ +extern hrtime_t pool_pset_mod; /* pset modification time */ +extern hrtime_t pool_cpu_mod; /* cpu modification time */ + +extern void pool_pset_init(void); +extern int pool_pset_enable(void); +extern int pool_pset_disable(void); +extern int pool_pset_create(psetid_t *); +extern int pool_pset_destroy(psetid_t); +extern int pool_pset_assoc(poolid_t, psetid_t); +extern void pool_pset_bind(proc_t *, psetid_t, void *, void *); +extern int pool_pset_xtransfer(id_t, id_t, size_t, id_t *); +extern int pool_pset_proprm(psetid_t, char *); +extern int pool_pset_propput(psetid_t, nvpair_t *); +extern int pool_pset_propget(psetid_t, char *, nvlist_t *); +extern int pool_cpu_proprm(processorid_t, char *); +extern int pool_cpu_propput(processorid_t, nvpair_t *); +extern int pool_cpu_propget(processorid_t, char *, nvlist_t *); +extern int pool_pset_pack(ea_object_t *); + +extern int pset_bind_start(struct proc **, struct pool *); +extern void pset_bind_abort(struct proc **, struct pool *); +extern void pset_bind_finish(void); + +extern boolean_t pool_pset_enabled(void); + +extern void pool_pset_visibility_add(psetid_t, struct zone *); +extern void pool_pset_visibility_remove(psetid_t, struct zone *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_POOL_PSET_H */ diff --git a/illumos-x86_64/usr/include/sys/port.h b/illumos-x86_64/usr/include/sys/port.h new file mode 100644 index 00000000..d4d74d55 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/port.h @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_PORT_H +#define _SYS_PORT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* port sources */ +#define PORT_SOURCE_AIO 1 +#define PORT_SOURCE_TIMER 2 +#define PORT_SOURCE_USER 3 +#define PORT_SOURCE_FD 4 +#define PORT_SOURCE_ALERT 5 +#define PORT_SOURCE_MQ 6 +#define PORT_SOURCE_FILE 7 + +typedef struct port_event { + int portev_events; /* event data is source specific */ + ushort_t portev_source; /* event source */ + ushort_t portev_pad; /* port internal use */ + uintptr_t portev_object; /* source specific object */ + void *portev_user; /* user cookie */ +} port_event_t; + +typedef struct port_notify { + int portnfy_port; /* bind request(s) to port */ + void *portnfy_user; /* user defined */ +} port_notify_t; + + +typedef struct file_obj { + timestruc_t fo_atime; /* Access time from stat(2) */ + timestruc_t fo_mtime; /* Modification time from stat(2) */ + timestruc_t fo_ctime; /* Change time from stat(2) */ + uintptr_t fo_pad[3]; /* For future expansion */ + char *fo_name; /* Null terminated file name */ +} file_obj_t; + +#if defined(_SYSCALL32) + +typedef struct file_obj32 { + timestruc32_t fo_atime; /* Access time got from stat(2) */ + timestruc32_t fo_mtime; /* Modification time from stat(2) */ + timestruc32_t fo_ctime; /* Change time from stat(2) */ + caddr32_t fo_pad[3]; /* For future expansion */ + caddr32_t fo_name; /* Null terminated file name */ +} file_obj32_t; + +typedef struct port_event32 { + int portev_events; /* events detected */ + ushort_t portev_source; /* user, timer, aio, etc */ + ushort_t portev_pad; /* reserved */ + caddr32_t portev_object; /* fd, timerid, ... */ + caddr32_t portev_user; /* user cookie */ +} port_event32_t; + +typedef struct port_notify32 { + int portnfy_port; /* bind request(s) to port */ + caddr32_t portnfy_user; /* user defined */ +} port_notify32_t; + +#endif /* _SYSCALL32 */ + +/* port_alert() flags */ +#define PORT_ALERT_SET 0x01 +#define PORT_ALERT_UPDATE 0x02 +#define PORT_ALERT_INVALID (PORT_ALERT_SET | PORT_ALERT_UPDATE) + +/* + * PORT_SOURCE_FILE - events + */ + +/* + * User watchable file events + */ +#define FILE_ACCESS 0x00000001 +#define FILE_MODIFIED 0x00000002 +#define FILE_ATTRIB 0x00000004 +#define FILE_TRUNC 0x00100000 +#define FILE_NOFOLLOW 0x10000000 + +/* + * exception file events + */ + +/* + * The watched file.. + */ +#define FILE_DELETE 0x00000010 +#define FILE_RENAME_TO 0x00000020 +#define FILE_RENAME_FROM 0x00000040 +/* + * The filesystem on which the watched file resides got + * unmounted. + */ +#define UNMOUNTED 0x20000000 +/* + * Some other file/filesystem got mounted over the + * watched file/directory. + */ +#define MOUNTEDOVER 0x40000000 + +/* + * Helper type + */ +#define FILE_EXCEPTION (UNMOUNTED|FILE_DELETE|FILE_RENAME_TO \ + |FILE_RENAME_FROM|MOUNTEDOVER) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PORT_H */ diff --git a/illumos-x86_64/usr/include/sys/port_impl.h b/illumos-x86_64/usr/include/sys/port_impl.h new file mode 100644 index 00000000..504fb9ec --- /dev/null +++ b/illumos-x86_64/usr/include/sys/port_impl.h @@ -0,0 +1,389 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_PORT_IMPL_H +#define _SYS_PORT_IMPL_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Note: + * The contents of this file are private to the implementation of the + * Solaris system and event ports subsystem and are subject to change + * at any time without notice. + */ + +#include +#include +#include +#include +#include + +/* + * port system call codes + */ +#define PORT_CREATE 0 /* create a port */ +#define PORT_ASSOCIATE 1 /* register object or object list */ +#define PORT_DISSOCIATE 2 /* remove object association */ +#define PORT_SEND 3 /* send user-defined event to a port */ +#define PORT_SENDN 4 /* send user-defined event to a list of ports */ +#define PORT_GET 5 /* receive object with events */ +#define PORT_GETN 6 /* receive list of objects with events */ +#define PORT_ALERT 7 /* set port in alert mode */ +#define PORT_DISPATCH 8 /* dispatch object with events */ + +#define PORT_SYS_NOPORT 0x100 /* system call without port-id */ +#define PORT_SYS_NOSHARE 0x200 /* non shareable event */ +#define PORT_CODE_MASK 0xff + +/* port_dispatch() flags */ +#define PORT_SHARE_EVENT 0x01 /* event can be shared between procs */ + +/* port limits */ +#define PORT_MAX_LIST 8192 /* max. # of list ent. per syscall */ + +#ifdef _KERNEL + +#define PORT_SCACHE_SIZE 16 /* start source cache size */ +#define PORT_SHASH(cookie) (cookie & (PORT_SCACHE_SIZE-1)) + +/* portkev_flags masks */ +#define PORT_CLEANUP_DONE (PORT_KEV_FREE|PORT_KEV_DONEQ) +#define PORT_KEV_CACHE (PORT_KEV_CACHED|PORT_KEV_SCACHED) +#define PORT_KEV_WIRED (PORT_KEV_PRIVATE|PORT_KEV_CACHE) + +#define PORT_FREE_EVENT(pev) (((pev)->portkev_flags & PORT_KEV_CACHE) == 0) + +typedef struct port_alert { + int portal_events; /* passed to alert event */ + pid_t portal_pid; /* owner of the alert mode */ + uintptr_t portal_object; /* passed to alert event */ + void *portal_user; /* passed to alert event */ +} port_alert_t; + +/* + * The port_queue_t structure is responsible for the management of all + * event activities within a port. + */ +typedef struct port_queue { + kmutex_t portq_mutex; + kcondvar_t portq_closecv; + kcondvar_t portq_block_cv; + int portq_flags; + uint_t portq_nent; /* number of events in the queue */ + uint_t portq_nget; /* events required for waiting thread */ + uint_t portq_tnent; /* number of events in the temp queue */ + int portq_thrcnt; /* # of threads waiting for events */ + int portq_getn; /* # of threads retrieving events */ + struct portget *portq_thread; /* queue of waiting threads */ + struct port_fdcache *portq_pcp; /* fd cache */ + list_t portq_list; /* port event list */ + list_t portq_get_list; /* port event list for port_get(n) */ + kmutex_t portq_source_mutex; + port_source_t **portq_scache; + port_alert_t portq_alert; /* alert event data */ +} port_queue_t; + +/* defines for portq_flags */ +#define PORTQ_ALERT 0x01 /* port in alert state */ +#define PORTQ_CLOSE 0x02 /* closing port */ +#define PORTQ_WAIT_EVENTS 0x04 /* waiting for new events */ +#define PORTQ_POLLIN 0x08 /* events available in the event queue */ +#define PORTQ_POLLOUT 0x10 /* space available for new events */ +#define PORTQ_BLOCKED 0x20 /* port is blocked by port_getn() */ +#define PORTQ_POLLWK_PEND 0x40 /* pollwakeup is pending, blocks port close */ + +#define VTOEP(v) ((struct port *)(v->v_data)) +#define EPTOV(ep) ((struct vnode *)(ep)->port_vnode) + + +typedef struct port { + vnode_t *port_vnode; + kmutex_t port_mutex; + kcondvar_t port_cv; /* resource control */ + uint_t port_flags; + pid_t port_pid; + int port_fd; + uint_t port_max_events; /* max. number of event per port */ + uint_t port_max_list; /* max. number of list structs */ + uint_t port_curr; /* current number of event structs */ + pollhead_t port_pollhd; + timespec_t port_ctime; + uid_t port_uid; + gid_t port_gid; + port_queue_t port_queue; /* global queue */ +} port_t; + +/* defines for port_flags */ +#define PORT_INIT 0x01 /* port initialized */ +#define PORT_CLOSED 0x02 /* owner closed the port */ +#define PORT_EVENTS 0x04 /* waiting for event resources */ + +/* + * global control structure of port framework + */ +typedef struct port_control { + kmutex_t pc_mutex; + uint_t pc_nents; /* ports currently allocated */ + struct kmem_cache *pc_cache; /* port event structures */ +} port_control_t; + + +/* + * Every thread waiting on an object will use this structure to store + * all dependencies (flags, counters, events) before it awakes with + * some events/transactions completed + */ +typedef struct portget { + int portget_state; + uint_t portget_nget; /* number of expected events */ + pid_t portget_pid; + kcondvar_t portget_cv; + port_alert_t portget_alert; + struct portget *portget_next; + struct portget *portget_prev; +} portget_t; + +/* defines for portget_state */ +#define PORTGET_ALERT 0x01 /* wake up and return alert event */ + +extern port_control_t port_control; +extern uint_t port_max_list; + +/* + * port_getn() needs this structure to manage inter-process event delivery. + */ +typedef struct port_gettimer { + ushort_t pgt_flags; + ushort_t pgt_loop; + int pgt_timecheck; + timespec_t pgt_rqtime; + timespec_t *pgt_rqtp; + struct timespec *pgt_timeout; +} port_gettimer_t; + +/* pgt_flags */ +#define PORTGET_ONE 0x01 /* return only 1 object */ +#define PORTGET_WAIT_EVENTS 0x02 /* thread is waiting for new events */ + +/* + * portfd_t is required to synchronize the association of fds with a port + * and the per-process list of open files. + * There is a pointer to a portfd structure in uf_entry_t. + * If a fd is closed then closeandsetf() is able to detect the association of + * the fd with a port or with a list of ports. closeandsetf() will dissociate + * the fd from the port(s). + */ +typedef struct portfd { + struct polldat pfd_pd; + struct portfd *pfd_next; + struct portfd *pfd_prev; + kthread_t *pfd_thread; +} portfd_t; + +#define PFTOD(pfd) (&(pfd)->pfd_pd) +#define PDTOF(pdp) ((struct portfd *)(pdp)) +#define PORT_FD_BUCKET(pcp, fd) \ + (&(pcp)->pc_hash[((fd) % (pcp)->pc_hashsize)]) + +/* + * PORT_SOURCE_FILE -- File Events Notification sources + */ +#define PORT_FOP_BUCKET(pcp, id) \ + (portfop_t **)(&(pcp)->pfc_hash[(((ulong_t)id >> 8) & \ + (PORTFOP_HASHSIZE - 1))]) + +/* + * This structure is used to register a file object to be watched. + * + * The pfop_flags are protected by the vnode's pvp_mutex lock. + * The pfop list (vnode's list) is protected by the pvp_mutex when it is on + * the vnode's list. + * + * All the rest of the fields are protected by the port's source cache lock + * pfcp_lock. + */ +typedef struct portfop { + int pfop_events; + int pfop_flags; /* above flags. */ + uintptr_t pfop_object; /* object address */ + vnode_t *pfop_vp; + vnode_t *pfop_dvp; + port_t *pfop_pp; + fem_t *pfop_fem; + list_node_t pfop_node; /* list of pfop's per vnode */ + struct portfop *pfop_hashnext; /* hash list */ + pid_t pfop_pid; /* owner of portfop */ + struct portfop_cache *pfop_pcache; + port_kevent_t *pfop_pev; /* event pointers */ + char *pfop_cname; /* file component name */ + int pfop_clen; + kthread_t *pfop_callrid; /* thread doing the associate */ +} portfop_t; + +/* + * pfop_flags + */ +#define PORT_FOP_ACTIVE 0x1 +#define PORT_FOP_REMOVING 0x2 +#define PORT_FOP_KEV_ONQ 0x4 + +typedef struct portfop_vfs { + vfs_t *pvfs; + int pvfs_unmount; /* 1 if unmount in progress */ + list_t pvfs_pvplist; /* list of vnodes from */ + fsem_t *pvfs_fsemp; + struct portfop_vfs *pvfs_next; /* hash list */ +} portfop_vfs_t; + +typedef struct portfop_vfs_hash { + kmutex_t pvfshash_mutex; + struct portfop_vfs *pvfshash_pvfsp; +} portfop_vfs_hash_t; + +typedef struct portfop_vp { + vnode_t *pvp_vp; + kmutex_t pvp_mutex; + int pvp_cnt; /* number of watches */ + list_t pvp_pfoplist; + list_node_t pvp_pvfsnode; + struct portfop *pvp_lpfop; /* oldest pfop */ + fem_t *pvp_femp; + struct portfop_vfs *pvp_pvfsp; +} portfop_vp_t; + +#define PORTFOP_PVFSHASH_SZ 256 +#define PORTFOP_PVFSHASH(vfsp) (((uintptr_t)(vfsp) >> 4) % PORTFOP_PVFSHASH_SZ) + +/* + * file operations flag. + */ + +/* + * PORT_SOURCE_FILE - vnode operations + */ + +#define FOP_FILE_OPEN 0x00000001 +#define FOP_FILE_READ 0x00000002 +#define FOP_FILE_WRITE 0x00000004 +#define FOP_FILE_MAP 0x00000008 +#define FOP_FILE_IOCTL 0x00000010 +#define FOP_FILE_CREATE 0x00000020 +#define FOP_FILE_MKDIR 0x00000040 +#define FOP_FILE_SYMLINK 0x00000080 +#define FOP_FILE_LINK 0x00000100 +#define FOP_FILE_RENAME 0x00000200 +#define FOP_FILE_REMOVE 0x00000400 +#define FOP_FILE_RMDIR 0x00000800 +#define FOP_FILE_READDIR 0x00001000 +#define FOP_FILE_RENAMESRC 0x00002000 +#define FOP_FILE_RENAMEDST 0x00004000 +#define FOP_FILE_REMOVEFILE 0x00008000 +#define FOP_FILE_REMOVEDIR 0x00010000 +#define FOP_FILE_SETSECATTR 0x00020000 +#define FOP_FILE_SETATTR_ATIME 0x00040000 +#define FOP_FILE_SETATTR_MTIME 0x00080000 +#define FOP_FILE_SETATTR_CTIME 0x00100000 +#define FOP_FILE_LINK_SRC 0x00200000 +#define FOP_FILE_TRUNC 0x00400000 + +/* + * File modification event. + */ +#define FOP_MODIFIED_MASK (FOP_FILE_WRITE|FOP_FILE_CREATE \ + |FOP_FILE_REMOVE|FOP_FILE_LINK \ + |FOP_FILE_RENAMESRC|FOP_FILE_RENAMEDST \ + |FOP_FILE_MKDIR|FOP_FILE_RMDIR \ + |FOP_FILE_SYMLINK|FOP_FILE_SETATTR_MTIME) + +/* + * File access event + */ +#define FOP_ACCESS_MASK (FOP_FILE_READ|FOP_FILE_READDIR \ + |FOP_FILE_MAP|FOP_FILE_SETATTR_ATIME) + +/* + * File attrib event + */ +#define FOP_ATTRIB_MASK (FOP_FILE_WRITE|FOP_FILE_CREATE \ + |FOP_FILE_REMOVE|FOP_FILE_LINK \ + |FOP_FILE_RENAMESRC|FOP_FILE_RENAMEDST \ + |FOP_FILE_MKDIR|FOP_FILE_RMDIR \ + |FOP_FILE_SYMLINK|FOP_FILE_SETATTR_CTIME \ + |FOP_FILE_LINK_SRC|FOP_FILE_SETSECATTR) + + +/* + * File trunc event + */ +#define FOP_TRUNC_MASK (FOP_FILE_TRUNC|FOP_FILE_CREATE) + +/* + * valid watchable events + */ +#define FILE_EVENTS_MASK (FILE_ACCESS|FILE_MODIFIED|FILE_ATTRIB \ + |FILE_NOFOLLOW|FILE_TRUNC) +/* --- End file events --- */ + +/* + * port_kstat_t contains the event port kernel values which are + * exported to kstat. + * Currently only the number of active ports is exported. + */ +typedef struct port_kstat { + kstat_named_t pks_ports; +} port_kstat_t; + +/* misc functions */ +int port_alloc_event_block(port_t *, int, int, struct port_kevent **); +void port_push_eventq(port_queue_t *); +int port_remove_done_event(struct port_kevent *); +struct port_kevent *port_get_kevent(list_t *, struct port_kevent *); +void port_block(port_queue_t *); +void port_unblock(port_queue_t *); + +/* PORT_SOURCE_FD cache management */ +void port_pcache_remove_fd(port_fdcache_t *, portfd_t *); +int port_remove_fd_object(portfd_t *, struct port *, port_fdcache_t *); + +/* file close management */ +extern void addfd_port(int, portfd_t *); +extern void delfd_port(int, portfd_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PORT_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/port_kernel.h b/illumos-x86_64/usr/include/sys/port_kernel.h new file mode 100644 index 00000000..daac6f49 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/port_kernel.h @@ -0,0 +1,184 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2022 Oxide Computer Company + */ + +#ifndef _SYS_PORT_KERNEL_H +#define _SYS_PORT_KERNEL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Note: + * The contents of this file are private to the implementation of the + * Solaris system and event ports subsystem and are subject to change + * at any time without notice. + */ + +#ifdef _KERNEL + +/* + * The port_kevent_t struct represents the kernel internal port event. + * Every event is associated to a port (portkev_port). + */ +typedef struct port_kevent { + kmutex_t portkev_lock; /* used by PORT_SOURCE_FD source */ + int portkev_source; /* event: source */ + int portkev_events; /* event: data */ + int portkev_flags; /* internal flags */ + pid_t portkev_pid; /* pid of process using this struct */ + long portkev_object; /* event: object */ + void *portkev_user; /* event: user-defined value */ + int (*portkev_callback)(void *, int *, pid_t, int, void *); + void *portkev_arg; /* event source callback arg */ + struct port *portkev_port; /* associated port */ + list_node_t portkev_node; /* pointer to neighbor events */ +} port_kevent_t; + +/* portkev_flags */ +#define PORT_KEV_PRIVATE 0x01 /* subsystem private, don't free */ +#define PORT_KEV_CACHED 0x02 /* port local cached, don't free */ +#define PORT_KEV_SCACHED 0x04 /* source local cached, don't free */ +#define PORT_KEV_VALID 0x08 /* event associated and enabled */ +#define PORT_KEV_DONEQ 0x10 /* event is in done queue */ +#define PORT_KEV_FREE 0x20 /* free event and don't copyout it */ +#define PORT_KEV_NOSHARE 0x40 /* non-shareable across processes */ + +/* flags : port_alloc_event() */ +#define PORT_ALLOC_DEFAULT 0 +#define PORT_ALLOC_PRIVATE PORT_KEV_PRIVATE +#define PORT_ALLOC_CACHED PORT_KEV_CACHED +#define PORT_ALLOC_SCACHED PORT_KEV_SCACHED + +/* flags : callback function */ +#define PORT_CALLBACK_DEFAULT 0 /* free resources, event delivery */ +#define PORT_CALLBACK_CLOSE 1 /* free resources, don't copyout */ +#define PORT_CALLBACK_DISSOCIATE 2 /* dissociate object */ + +#define PORT_DEFAULT_PORTS 0x02000 +#define PORT_MAX_PORTS 0x10000 +#define PORT_DEFAULT_EVENTS 0x10000 /* default # of events per port */ +#define PORT_MAX_EVENTS UINT_MAX/2 /* max. # of events per port */ + +/* + * port_source_t represents a source associated with a port. + * The portsrc_close() function is required to notify the source when + * a port is closed. + */ +typedef struct port_source { + int portsrc_source; + int portsrc_cnt; /* # of associations */ + void (*portsrc_close)(void *, int, pid_t, int); + void *portsrc_closearg; /* callback arg */ + void *portsrc_data; /* Private data of source */ + struct port_source *portsrc_next; + struct port_source *portsrc_prev; +} port_source_t; + + +/* + * PORT_SOURCE_FILE cache structure. + */ +#define PORTFOP_HASHSIZE 256 /* cache space for fop events */ + +/* + * One cache for each port that uses PORT_SOURCE_FILE. + */ +typedef struct portfop_cache { + kmutex_t pfc_lock; /* lock to protect cache */ + kcondvar_t pfc_lclosecv; /* last close cv */ + int pfc_objcount; /* track how many file obj are hashed */ + struct portfop *pfc_hash[PORTFOP_HASHSIZE]; /* hash table */ +} portfop_cache_t; + +/* + * PORT_SOURCE_FD cache per port. + * One cache for each port that uses PORT_SOURCE_FD. + * + * The types and offsets of pc_lock and pc_flag must exactly match their sibling + * fields in pollcache_t, as they are accessed as if the port_fdcache_t _was_ a + * pollcache via t_pollcache. (See: pollrelock() and fs_reject_epoll()) + */ +typedef struct port_fdcache { + kmutex_t pc_lock; /* lock to protect portcache */ + kcondvar_t pc_lclosecv; + struct portfd **pc_hash; /* points to a hash table of ptrs */ + int pc_hashsize; /* the size of current hash table */ + int pc_fdcount; /* track how many fd's are hashed */ + uintptr_t _pc_pad; /* pad to properly offset pc_flag */ + int pc_flag; /* pollcache flags (compat) */ +} port_fdcache_t; + +/* + * Structure of port_ksource_tab[] table. + * The port_ksource_tab[] is required to allow kernel sources to become + * associated with a port at the time of port creation. This feature is + * required to avoid performance degradation in sub-systems, specially when + * they should need to check the association on every event activity. + */ +typedef struct port_ksource { + int pks_source; + void (*pks_close)(void *, int, pid_t, int); + void *pks_closearg; + void *pks_portsrc; +} port_ksource_t; + +/* event port and source management */ +int port_associate_ksource(int, int, struct port_source **, + void (*)(void *, int, pid_t, int), void *arg, + int (*)(port_kevent_t *, int, int, uintptr_t, void *)); +int port_dissociate_ksource(int, int, struct port_source *); + +/* event management */ +int port_alloc_event(int, int, int, port_kevent_t **); +int port_pollwkup(struct port *); +void port_pollwkdone(struct port *); +void port_send_event(port_kevent_t *); +void port_free_event(port_kevent_t *); +void port_init_event(port_kevent_t *, uintptr_t, void *, + int (*)(void *, int *, pid_t, int, void *), void *); +int port_dup_event(port_kevent_t *, port_kevent_t **, int); +int port_associate_fd(struct port *, int, uintptr_t, int, void *); +int port_dissociate_fd(struct port *, uintptr_t); +int port_associate_fop(struct port *, int, uintptr_t, int, void *); +int port_dissociate_fop(struct port *, uintptr_t); + +/* misc functions */ +void port_free_event_local(port_kevent_t *, int counter); +int port_alloc_event_local(struct port *, int, int, port_kevent_t **); +void port_close_pfd(struct portfd *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PORT_KERNEL_H */ diff --git a/illumos-x86_64/usr/include/sys/portif.h b/illumos-x86_64/usr/include/sys/portif.h new file mode 100644 index 00000000..792abd94 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/portif.h @@ -0,0 +1,154 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ +#ifndef _PORTIF_H +#define _PORTIF_H + +/* + * Definitions for stmf local ports and port providers. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct stmf_dbuf_store { + void *ds_stmf_private; + void *ds_port_private; + + stmf_data_buf_t *(*ds_alloc_data_buf)(struct scsi_task *task, + uint32_t size, uint32_t *pminsize, uint32_t flags); + + void (*ds_free_data_buf)( + struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf); + + stmf_status_t (*ds_setup_dbuf)(struct scsi_task *task, + stmf_data_buf_t *dbuf, uint32_t flags); + + void (*ds_teardown_dbuf)( + struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf); +} stmf_dbuf_store_t; + +#define PORTIF_REV_1 0x00010000 + +typedef struct stmf_local_port { + void *lport_stmf_private; + void *lport_port_private; + + uint32_t lport_abort_timeout; + + struct scsi_devid_desc *lport_id; + char *lport_alias; + struct stmf_port_provider *lport_pp; + struct stmf_dbuf_store *lport_ds; + /* lport ops */ + stmf_status_t (*lport_xfer_data)(struct scsi_task *task, + struct stmf_data_buf *dbuf, uint32_t ioflags); + stmf_status_t (*lport_send_status)(struct scsi_task *task, + uint32_t ioflags); + void (*lport_task_free)(struct scsi_task *task); + stmf_status_t (*lport_abort)(struct stmf_local_port *lport, + int abort_cmd, void *arg, uint32_t flags); + void (*lport_task_poll)(struct scsi_task *task); + void (*lport_ctl)(struct stmf_local_port *lport, + int cmd, void *arg); + stmf_status_t (*lport_info)(uint32_t cmd, + struct stmf_local_port *lport, void *arg, uint8_t *buf, + uint32_t *bufsizep); + void (*lport_event_handler)( + struct stmf_local_port *lport, int eventid, void *arg, + uint32_t flags); +} stmf_local_port_t; + +typedef struct stmf_remote_port { + struct scsi_transport_id *rport_tptid; + uint16_t rport_tptid_sz; +} stmf_remote_port_t; + +typedef struct stmf_dflt_scsi_tptid { +#if defined(_BIT_FIELDS_LTOH) + uint8_t protocol_id : 4, + resbits : 2, + format_code : 2; +#elif defined(_BIT_FIELDS_HTOL) + uint8_t format_code : 2, + resbits : 2, + protocol_id : 4; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uint8_t rsvbyte1; + uint8_t ident_len[2]; + char ident[1]; +} stmf_dflt_scsi_tptid_t; +/* + * abort cmd + */ +#define STMF_LPORT_ABORT_TASK 0x40 + +typedef struct stmf_port_provider { + void *pp_stmf_private; + void *pp_provider_private; + + uint32_t pp_portif_rev; /* Currently PORTIF_REV_1 */ + int pp_instance; + char *pp_name; + void (*pp_cb)(struct stmf_port_provider *pp, + int cmd, void *arg, uint32_t flags); +} stmf_port_provider_t; + +#define STMF_SESSION_ID_NONE ((uint64_t)0) + +typedef struct stmf_scsi_session { + void *ss_stmf_private; + void *ss_port_private; + + struct scsi_devid_desc *ss_rport_id; + char *ss_rport_alias; + struct stmf_local_port *ss_lport; + uint64_t ss_session_id; + struct stmf_remote_port *ss_rport; +} stmf_scsi_session_t; + +stmf_status_t stmf_register_port_provider(stmf_port_provider_t *pp); +stmf_status_t stmf_deregister_port_provider(stmf_port_provider_t *pp); +stmf_status_t stmf_register_local_port(stmf_local_port_t *lportp); +stmf_status_t stmf_deregister_local_port(stmf_local_port_t *lport); +stmf_status_t stmf_register_scsi_session(stmf_local_port_t *lport, + stmf_scsi_session_t *ss); +stmf_status_t stmf_add_rport_info(stmf_scsi_session_t *ss, + const char *prop_name, const char *prop_value); +void stmf_remove_rport_info(stmf_scsi_session_t *ss, + const char *prop_name); +void stmf_deregister_scsi_session(stmf_local_port_t *lport, + stmf_scsi_session_t *ss); +void stmf_set_port_standby(stmf_local_port_t *lport, uint16_t rtpid); +void stmf_set_port_alua(stmf_local_port_t *lport); + +#ifdef __cplusplus +} +#endif + +#endif /* _PORTIF_H */ diff --git a/illumos-x86_64/usr/include/sys/ppmio.h b/illumos-x86_64/usr/include/sys/ppmio.h new file mode 100644 index 00000000..b25edce9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ppmio.h @@ -0,0 +1,143 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PPMIO_H +#define _SYS_PPMIO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PPMIOC ('p' << 8) +#define PPMIOCSET (PPMIOC | 1) +#define PPMIOCGET (PPMIOC | 2) +#define PPMGET_DPWR (PPMIOC | 3) +#define PPMGET_DOMBYDEV (PPMIOC | 4) +#define PPMGET_DEVBYDOM (PPMIOC | 5) +/* + * The following two ioctls are used for testing purposes only. + */ +#if defined(__x86) +#define PPMGET_NORMAL (PPMIOC | 6) +#define PPMSET_NORMAL (PPMIOC | 7) +#endif + +/* + * PPMIOCGET + * Note: this ioctl command is available for Excalibur and Grover + * only, but will be removed in future, replacing with PPMGET_DPWR + */ +typedef struct ppmreq { + int ppmdev; + union ppmop { + struct idev_power { + int level; + } idev_power; + } ppmop; +} ppmreq_t; + +/* definition for ppmdev */ +#define PPM_INTERNAL_DEVICE_POWER 1 + +/* + * PPMGET_DPWR + */ +struct ppm_dpwr { + char *domain; /* domain name */ + int level; /* domain power level */ +}; + +/* + * PPMGET_DOMBYDEV + */ +struct ppm_bydev { + char *path; /* device prom path */ + char *domlist; /* domain names */ + size_t size; /* size of domlist buffer */ +}; + +/* + * PPMGET_DEVBYDOM + */ +struct ppm_bydom { + char *domain; /* domain name */ + char *devlist; /* domain device list */ + size_t size; /* size of devlist buffer */ +}; + +/* + * PPM[GS]ET_NORM + */ +struct ppm_norm { + char *path; /* device prom path */ + int norm; /* normal level */ +}; + +#ifdef _SYSCALL32 +/* + * kernel view of ILP32 data structure + */ +struct ppm_dpwr32 { + caddr32_t domain; /* domain name */ + int32_t level; /* domain power level */ +}; + +struct ppm_bydev32 { + caddr32_t path; /* device prom path */ + caddr32_t domlist; /* domain names */ + size32_t size; /* size of domlist buffer */ +}; + +struct ppm_bydom32 { + caddr32_t domain; /* domain name */ + caddr32_t devlist; /* domain device list */ + size32_t size; /* size of devlist buffer */ +}; + +struct ppm_norm32 { + caddr32_t path; /* device prom path */ + int32_t norm; /* normal level */ +}; +#endif /* _SYSCALL32 */ + +/* + * .level may be the following + */ +#define PPMIO_POWER_OFF 0 +#define PPMIO_POWER_ON 1 +#define PPMIO_LED_BLINKING 2 +#define PPMIO_LED_SOLIDON 3 +/* (s10) */ +#define PPM_IDEV_POWER_OFF PPMIO_POWER_OFF +#define PPM_IDEV_POWER_ON PPMIO_POWER_ON + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PPMIO_H */ diff --git a/illumos-x86_64/usr/include/sys/priocntl.h b/illumos-x86_64/usr/include/sys/priocntl.h new file mode 100644 index 00000000..396672a3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/priocntl.h @@ -0,0 +1,176 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_PRIOCNTL_H +#define _SYS_PRIOCNTL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PC_VERSION 1 /* First version of priocntl */ + +extern long priocntl(idtype_t, id_t, int, ...); +extern long priocntlset(procset_t *, int, ...); + +/* + * The following are the possible values of the command + * argument for the priocntl system call. + */ + +#define PC_GETCID 0 /* Get class ID */ +#define PC_GETCLINFO 1 /* Get info about a configured class */ +#define PC_SETPARMS 2 /* Set scheduling parameters */ +#define PC_GETPARMS 3 /* Get scheduling parameters */ +#define PC_ADMIN 4 /* Scheduler administration (used by */ + /* dispadmin(8), not for general use) */ +#define PC_GETPRIRANGE 5 /* Get priority range for a class */ + /* posix.4 scheduling, not for general use */ +#define PC_DONICE 6 /* Set or get nice value */ +#define PC_SETXPARMS 7 /* Set extended scheduling parameters */ +#define PC_GETXPARMS 8 /* Get extended scheduling parameters */ +#define PC_SETDFLCL 9 /* Set default class, not for general use */ +#define PC_GETDFLCL 10 /* Get default class, not for general use */ +#define PC_DOPRIO 11 /* Set or get priority, not for general use */ + +#define PC_CLNULL -1 + +#define PC_CLNMSZ 16 +#define PC_CLINFOSZ (32 / sizeof (int)) +#define PC_CLPARMSZ (32 / sizeof (int)) + +#define PC_GETNICE 0 +#define PC_SETNICE 1 + +#define PC_GETPRIO 0 +#define PC_SETPRIO 1 + +typedef struct pcinfo { + id_t pc_cid; /* class id */ + char pc_clname[PC_CLNMSZ]; /* class name */ + int pc_clinfo[PC_CLINFOSZ]; /* class information */ +} pcinfo_t; + +typedef struct pcparms { + id_t pc_cid; /* process class */ + int pc_clparms[PC_CLPARMSZ]; /* class specific parameters */ +} pcparms_t; + +typedef struct pcnice { + int pc_val; /* nice value */ + int pc_op; /* type of operation, set or get */ +} pcnice_t; + +typedef struct pcprio { + int pc_op; /* type of operation, set or get */ + id_t pc_cid; /* class id */ + int pc_val; /* priority value */ +} pcprio_t; + +/* + * The following is used by the priocntl(2) varargs interface (command + * codes: PC_SETXPARMS and PC_GETXPARMS). + */ + +#define PC_VAPARMCNT 8 /* maximal number of (key, value) pairs */ +#define PC_KY_NULL 0 /* terminates the (key, value) pair chain */ +#define PC_KY_CLNAME 1 /* get the class name of a process or LWP. */ + +typedef struct pc_vaparm { + int pc_key; /* describing key */ + u_longlong_t pc_parm; /* associated parameter */ +} pc_vaparm_t; + +typedef struct pc_vaparms { + uint_t pc_vaparmscnt; /* # of (key, value) pairs */ + pc_vaparm_t pc_parms[PC_VAPARMCNT]; /* parameter buffer */ +} pc_vaparms_t; + +#if defined(_SYSCALL32) && \ + _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 + +/* + * These structures are needed by the 64-bit kernel on certain architectures + * to translate pc_vaparms_t/pc_vaparm_t data structures from 32-bit userland. + */ +#pragma pack(4) + +typedef struct { + int32_t pc_key; /* describing key */ + uint64_t pc_parm; /* associated parameter */ +} pc_vaparm32_t; + +#pragma pack() + +typedef struct { + uint32_t pc_vaparmscnt; /* # of (key, value) pairs */ + pc_vaparm32_t pc_parms[PC_VAPARMCNT]; /* parameter buffer */ +} pc_vaparms32_t; + +#endif /* _SYSCALL32 && ... */ + +/* + * The following is used by libc for posix.4 + * scheduler interfaces and is not for general use. + */ + +typedef struct pcpri { + id_t pc_cid; /* process class */ + pri_t pc_clpmax; /* class priority max */ + pri_t pc_clpmin; /* class priority min */ +} pcpri_t; + +/* + * The following is used by the dispadmin(8) command for + * scheduler administration and is not for general use. + */ + +#ifdef _SYSCALL32 +/* Data structure for ILP32 clients */ +typedef struct pcadmin32 { + id32_t pc_cid; + caddr32_t pc_cladmin; +} pcadmin32_t; +#endif /* _SYSCALL32 */ + +typedef struct pcadmin { + id_t pc_cid; + caddr_t pc_cladmin; +} pcadmin_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PRIOCNTL_H */ diff --git a/illumos-x86_64/usr/include/sys/priv.h b/illumos-x86_64/usr/include/sys/priv.h new file mode 100644 index 00000000..9ec31274 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/priv.h @@ -0,0 +1,251 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_PRIV_H +#define _SYS_PRIV_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint32_t priv_chunk_t; +typedef struct priv_set priv_set_t; + +#ifdef _KERNEL + +/* + * Kernel type definitions. + */ +typedef int priv_ptype_t; +typedef int priv_t; + +#else /* _KERNEL */ + +/* + * Userland type definitions. + */ + +typedef const char *priv_ptype_t; +typedef const char *priv_t; + +#endif /* _KERNEL */ + +/* + * priv_op_t indicates a privilege operation type + */ +typedef enum priv_op { + PRIV_ON, + PRIV_OFF, + PRIV_SET +} priv_op_t; + +/* + * Privilege system call subcodes. + */ + +#define PRIVSYS_SETPPRIV 0 +#define PRIVSYS_GETPPRIV 1 +#define PRIVSYS_GETIMPLINFO 2 +#define PRIVSYS_SETPFLAGS 3 +#define PRIVSYS_GETPFLAGS 4 +#define PRIVSYS_ISSETUGID 5 +#define PRIVSYS_KLPD_REG 6 +#define PRIVSYS_KLPD_UNREG 7 +#define PRIVSYS_PFEXEC_REG 8 +#define PRIVSYS_PFEXEC_UNREG 9 + + +/* + * Maximum length of a user defined privilege name. + */ +#define PRIVNAME_MAX 32 + +/* + * Privilege interface functions for those parts of the kernel that + * know nothing of the privilege internals. + * + * A privilege implementation can have a varying number of sets; sets + * consist of a number of priv_chunk_t's and the size is expressed as such. + * The privileges can be represented as + * + * priv_chunk_t privs[info.priv_nsets][info.priv_setsize] + * ... priv_infosize of extra information ... + * + * Extra data contained in the privilege information consists of chunks + * of data with specified size and type all headed by a priv_info_t header + * which defines both the type of information as well as the size of the + * information. ((char*)&info)+info->priv_info_size should be rounded up + * to point to the next piece of information. + */ + +typedef struct priv_impl_info { + uint32_t priv_headersize; /* sizeof (priv_impl_info) */ + uint32_t priv_flags; /* additional flags */ + uint32_t priv_nsets; /* number of priv sets */ + uint32_t priv_setsize; /* size in priv_chunk_t */ + uint32_t priv_max; /* highest actual valid priv */ + uint32_t priv_infosize; /* Per proc. additional info */ + uint32_t priv_globalinfosize; /* Per system info */ +} priv_impl_info_t; + +#define PRIV_IMPL_INFO_SIZE(p) \ + ((p)->priv_headersize + (p)->priv_globalinfosize) + +#define PRIV_PRPRIV_INFO_OFFSET(p) \ + (sizeof (*(p)) + \ + ((p)->pr_nsets * (p)->pr_setsize - 1) * sizeof (priv_chunk_t)) + +#define PRIV_PRPRIV_SIZE(p) \ + (PRIV_PRPRIV_INFO_OFFSET(p) + (p)->pr_infosize) + +/* + * Per credential flags. + */ +#define PRIV_DEBUG 0x0001 /* User debugging */ +#define PRIV_AWARE 0x0002 /* Is privilege aware */ +#define PRIV_AWARE_INHERIT 0x0004 /* Inherit awareness */ +#define __PROC_PROTECT 0x0008 /* Private */ +#define NET_MAC_AWARE 0x0010 /* Is MAC aware */ +#define NET_MAC_AWARE_INHERIT 0x0020 /* Inherit MAC aware */ +#define PRIV_AWARE_RESET 0x0040 /* Reset on setuid() */ +#define PRIV_XPOLICY 0x0080 /* Extended policy */ +#define PRIV_PFEXEC 0x0100 /* As if pfexec'ed */ + +/* user-settable flags: */ +#define PRIV_USER (PRIV_DEBUG | NET_MAC_AWARE | NET_MAC_AWARE_INHERIT |\ + PRIV_XPOLICY | PRIV_AWARE_RESET | PRIV_PFEXEC) + +/* + * Header of the privilege info data structure; multiple structures can + * follow the privilege sets and priv_impl_info structures. + */ +typedef struct priv_info { + uint32_t priv_info_type; + uint32_t priv_info_size; +} priv_info_t; + +typedef struct priv_info_uint { + priv_info_t info; + uint_t val; +} priv_info_uint_t; + +/* + * Global privilege set information item; the actual size of the array is + * {priv_setsize}. + */ +typedef struct priv_info_set { + priv_info_t info; + priv_chunk_t set[1]; +} priv_info_set_t; + +/* + * names[1] is a place holder which can contain multiple NUL terminated, + * non-empty strings. + */ + +typedef struct priv_info_names { + priv_info_t info; + int cnt; /* number of strings */ + char names[1]; /* "string1\0string2\0 ..stringN\0" */ +} priv_info_names_t; + +/* + * Privilege information types. + */ +#define PRIV_INFO_SETNAMES 0x0001 +#define PRIV_INFO_PRIVNAMES 0x0002 +#define PRIV_INFO_BASICPRIVS 0x0003 +#define PRIV_INFO_FLAGS 0x0004 + +/* + * Special "privileges" used to indicate special conditions in privilege + * debugging/tracing code. + */ +#define PRIV_ALL (-1) /* All privileges required */ +#define PRIV_MULTIPLE (-2) /* More than one */ +#define PRIV_NONE (-3) /* No value */ +#define PRIV_ALLZONE (-4) /* All privileges in zone */ +#define PRIV_GLOBAL (-5) /* Must be in global zone */ + +#ifdef _KERNEL + +#define PRIV_ALLOC 0x1 + +extern int priv_debug; +extern int priv_basic_test; + +struct proc; +struct prpriv; +struct cred; + +extern int priv_prgetprivsize(const struct prpriv *); +extern void cred2prpriv(const struct cred *, struct prpriv *); +extern int priv_pr_spriv(struct proc *, struct prpriv *, const struct cred *); + +extern priv_impl_info_t *priv_hold_implinfo(void); +extern void priv_release_implinfo(void); +extern size_t priv_get_implinfo_size(void); +extern const priv_set_t *priv_getset(const struct cred *, int); +extern void priv_getinfo(const struct cred *, void *); +extern int priv_getbyname(const char *, uint_t); +extern int priv_getsetbyname(const char *, int); +extern const char *priv_getbynum(int); +extern const char *priv_getsetbynum(int); + +extern void priv_emptyset(priv_set_t *); +extern void priv_fillset(priv_set_t *); +extern void priv_addset(priv_set_t *, int); +extern void priv_delset(priv_set_t *, int); +extern boolean_t priv_ismember(const priv_set_t *, int); +extern boolean_t priv_isemptyset(const priv_set_t *); +extern boolean_t priv_isfullset(const priv_set_t *); +extern boolean_t priv_isequalset(const priv_set_t *, const priv_set_t *); +extern boolean_t priv_issubset(const priv_set_t *, const priv_set_t *); +extern int priv_proc_cred_perm(const struct cred *, struct proc *, + struct cred **, int); +extern void priv_intersect(const priv_set_t *, priv_set_t *); +extern void priv_union(const priv_set_t *, priv_set_t *); +extern void priv_inverse(priv_set_t *); + +extern void priv_set_PA(cred_t *); +extern void priv_adjust_PA(cred_t *); +extern void priv_reset_PA(cred_t *, boolean_t); +extern boolean_t priv_can_clear_PA(const cred_t *); + +extern int setpflags(uint_t, uint_t, cred_t *); +extern uint_t getpflags(uint_t, const cred_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PRIV_H */ diff --git a/illumos-x86_64/usr/include/sys/priv_const.h b/illumos-x86_64/usr/include/sys/priv_const.h new file mode 100644 index 00000000..d080a216 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/priv_const.h @@ -0,0 +1,185 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015, Joyent, Inc. All rights reserved. + * + * Privilege constant definitions; these constants are subject to + * change, including renumbering, without notice and should not be + * used in any code. Privilege names must be used instead. + * Privileges and privilege sets must not be stored in binary + * form; privileges and privileges sets must be converted to + * textual representation before being committed to persistent store. + * + * THIS FILE WAS GENERATED; DO NOT EDIT + */ + + +#ifndef _SYS_PRIV_CONST_H +#define _SYS_PRIV_CONST_H + + + + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +#define PRIV_NSET 4 +#define PRIV_SETSIZE 3 +#endif + +#ifdef _KERNEL +#define __PRIV_CONST_IMPL + +extern const char *priv_names[]; +extern const char *priv_setnames[]; +extern int nprivs; +extern int privbytes; +extern int maxprivbytes; +extern size_t privinfosize; +extern char *priv_str; +extern struct priv_set *priv_basic; +extern struct priv_impl_info *priv_info; +extern struct priv_info_names *priv_ninfo; + +/* Privileges */ +#define PRIV_CONTRACT_EVENT 0 +#define PRIV_CONTRACT_IDENTITY 1 +#define PRIV_CONTRACT_OBSERVER 2 +#define PRIV_CPC_CPU 3 +#define PRIV_DTRACE_KERNEL 4 +#define PRIV_DTRACE_PROC 5 +#define PRIV_DTRACE_USER 6 +#define PRIV_FILE_CHOWN 7 +#define PRIV_FILE_CHOWN_SELF 8 +#define PRIV_FILE_DAC_EXECUTE 9 +#define PRIV_FILE_DAC_READ 10 +#define PRIV_FILE_DAC_SEARCH 11 +#define PRIV_FILE_DAC_WRITE 12 +#define PRIV_FILE_DOWNGRADE_SL 13 +#define PRIV_FILE_FLAG_SET 14 +#define PRIV_FILE_LINK_ANY 15 +#define PRIV_FILE_OWNER 16 +#define PRIV_FILE_READ 17 +#define PRIV_FILE_SETID 18 +#define PRIV_FILE_UPGRADE_SL 19 +#define PRIV_FILE_WRITE 20 +#define PRIV_GRAPHICS_ACCESS 21 +#define PRIV_GRAPHICS_MAP 22 +#define PRIV_IPC_DAC_READ 23 +#define PRIV_IPC_DAC_WRITE 24 +#define PRIV_IPC_OWNER 25 +#define PRIV_NET_ACCESS 26 +#define PRIV_NET_BINDMLP 27 +#define PRIV_NET_ICMPACCESS 28 +#define PRIV_NET_MAC_AWARE 29 +#define PRIV_NET_MAC_IMPLICIT 30 +#define PRIV_NET_OBSERVABILITY 31 +#define PRIV_NET_PRIVADDR 32 +#define PRIV_NET_RAWACCESS 33 +#define PRIV_PROC_AUDIT 34 +#define PRIV_PROC_CHROOT 35 +#define PRIV_PROC_CLOCK_HIGHRES 36 +#define PRIV_PROC_EXEC 37 +#define PRIV_PROC_FORK 38 +#define PRIV_PROC_INFO 39 +#define PRIV_PROC_LOCK_MEMORY 40 +#define PRIV_PROC_MEMINFO 41 +#define PRIV_PROC_OWNER 42 +#define PRIV_PROC_PRIOUP 43 +#define PRIV_PROC_PRIOCNTL 44 +#define PRIV_PROC_SECFLAGS 45 +#define PRIV_PROC_SESSION 46 +#define PRIV_PROC_SETID 47 +#define PRIV_PROC_TASKID 48 +#define PRIV_PROC_ZONE 49 +#define PRIV_SYS_ACCT 50 +#define PRIV_SYS_ADMIN 51 +#define PRIV_SYS_AUDIT 52 +#define PRIV_SYS_CONFIG 53 +#define PRIV_SYS_DEVICES 54 +#define PRIV_SYS_IPC_CONFIG 55 +#define PRIV_SYS_LINKDIR 56 +#define PRIV_SYS_MOUNT 57 +#define PRIV_SYS_IPTUN_CONFIG 58 +#define PRIV_SYS_DL_CONFIG 59 +#define PRIV_SYS_IP_CONFIG 60 +#define PRIV_SYS_NET_CONFIG 61 +#define PRIV_SYS_NFS 62 +#define PRIV_SYS_PPP_CONFIG 63 +#define PRIV_SYS_RES_BIND 64 +#define PRIV_SYS_RES_CONFIG 65 +#define PRIV_SYS_RESOURCE 66 +#define PRIV_SYS_SMB 67 +#define PRIV_SYS_SUSER_COMPAT 68 +#define PRIV_SYS_TIME 69 +#define PRIV_SYS_TRANS_LABEL 70 +#define PRIV_VIRT_MANAGE 71 +#define PRIV_WIN_COLORMAP 72 +#define PRIV_WIN_CONFIG 73 +#define PRIV_WIN_DAC_READ 74 +#define PRIV_WIN_DAC_WRITE 75 +#define PRIV_WIN_DEVICES 76 +#define PRIV_WIN_DGA 77 +#define PRIV_WIN_DOWNGRADE_SL 78 +#define PRIV_WIN_FONTPATH 79 +#define PRIV_WIN_MAC_READ 80 +#define PRIV_WIN_MAC_WRITE 81 +#define PRIV_WIN_SELECTION 82 +#define PRIV_WIN_UPGRADE_SL 83 +#define PRIV_XVM_CONTROL 84 + +/* Privilege sets */ +#define PRIV_EFFECTIVE 0 +#define PRIV_INHERITABLE 1 +#define PRIV_PERMITTED 2 +#define PRIV_LIMIT 3 + +#define MAX_PRIVILEGE 96 + +#define PRIV_UNSAFE_ASSERT(set)\ + PRIV_ASSERT((set), PRIV_PROC_AUDIT);\ + PRIV_ASSERT((set), PRIV_PROC_SETID);\ + PRIV_ASSERT((set), PRIV_SYS_RESOURCE) + +#define PRIV_BASIC_ASSERT(set)\ + PRIV_ASSERT((set), PRIV_FILE_LINK_ANY);\ + PRIV_ASSERT((set), PRIV_FILE_READ);\ + PRIV_ASSERT((set), PRIV_FILE_WRITE);\ + PRIV_ASSERT((set), PRIV_NET_ACCESS);\ + PRIV_ASSERT((set), PRIV_PROC_EXEC);\ + PRIV_ASSERT((set), PRIV_PROC_FORK);\ + PRIV_ASSERT((set), PRIV_PROC_INFO);\ + PRIV_ASSERT((set), PRIV_PROC_SECFLAGS);\ + PRIV_ASSERT((set), PRIV_PROC_SESSION) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PRIV_CONST_H */ diff --git a/illumos-x86_64/usr/include/sys/priv_impl.h b/illumos-x86_64/usr/include/sys/priv_impl.h new file mode 100644 index 00000000..b9ef58aa --- /dev/null +++ b/illumos-x86_64/usr/include/sys/priv_impl.h @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PRIV_IMPL_H +#define _SYS_PRIV_IMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) +/* + * priv_set_t is a structure holding a set of privileges + */ + +struct priv_set { + priv_chunk_t pbits[PRIV_SETSIZE]; +}; + +typedef struct cred_priv_s { + priv_set_t crprivs[PRIV_NSET]; /* Priv sets */ + uint_t crpriv_flags; /* Privilege flags */ +} cred_priv_t; + +#endif + +#ifdef _KERNEL + +extern priv_set_t *priv_basic; +extern priv_set_t priv_unsafe; +extern priv_set_t priv_fullset; +extern void priv_init(void); + +/* The CR_PRIVS macro is defined in */ +#define CR_EPRIV(c) (CR_PRIVS(c)->crprivs[PRIV_EFFECTIVE]) +#define CR_IPRIV(c) (CR_PRIVS(c)->crprivs[PRIV_INHERITABLE]) +#define CR_PPRIV(c) (CR_PRIVS(c)->crprivs[PRIV_PERMITTED]) +#define CR_LPRIV(c) (CR_PRIVS(c)->crprivs[PRIV_LIMIT]) + +#define CR_FLAGS(c) (CR_PRIVS(c)->crpriv_flags) + +#define PRIV_SETBYTES (PRIV_NSET * PRIV_SETSIZE * sizeof (priv_chunk_t)) + +#define PRIV_EISAWARE(c) ((CR_FLAGS(c) & PRIV_AWARE) || (c)->cr_uid != 0) +#define PRIV_PISAWARE(c) ((CR_FLAGS(c) & PRIV_AWARE) || \ + ((c)->cr_uid != 0 && (c)->cr_suid != 0 && \ + (c)->cr_ruid != 0)) + +#define CR_OEPRIV(c) (*(PRIV_EISAWARE(c) ? &CR_EPRIV(c) : &CR_LPRIV(c))) +#define CR_OPPRIV(c) (*(PRIV_PISAWARE(c) ? &CR_PPRIV(c) : &CR_LPRIV(c))) + +#define PRIV_VALIDSET(s) ((s) >= 0 && (s) < PRIV_NSET) +#define PRIV_VALIDOP(op) ((op) >= PRIV_ON && (op) <= PRIV_SET) + +#define PRIV_FULLSET &priv_fullset /* Require full set */ + +/* + * Privilege macros bits manipulation macros; DEBUG kernels will + * ASSERT() that privileges are not out of range. + */ +#ifndef NBBY +#define NBBY 8 +#endif + +#define __NBWRD (NBBY * sizeof (priv_chunk_t)) + +#define privmask(n) (1U << ((__NBWRD - 1) - ((n) % __NBWRD))) +#define privword(n) ((n)/__NBWRD) + +/* + * PRIV_ASSERT(a, b) sets privilege "b" in privilege set "a". + * PRIV_CLEAR(a,b) clears privilege "b" in privilege set "a". + * PRIV_ISASSERT tests if privilege 'b' is asserted in privilege set 'a'. + */ + +#define __PRIV_ASSERT(a, b) ((a)->pbits[privword(b)] |= privmask(b)) +#define __PRIV_CLEAR(a, b) ((a)->pbits[privword(b)] &= ~privmask(b)) +#define __PRIV_ISASSERT(a, b) ((a)->pbits[privword(b)] & privmask(b)) + +#ifdef DEBUG +#define PRIV_CLEAR(a, b) priv_delset((a), (b)) +#define PRIV_ASSERT(a, b) priv_addset((a), (b)) +#define PRIV_ISASSERT(a, b) priv_ismember((a), (b)) +#else +#define PRIV_CLEAR(a, b) __PRIV_CLEAR((a), (b)) +#define PRIV_ASSERT(a, b) __PRIV_ASSERT((a), (b)) +#define PRIV_ISASSERT(a, b) __PRIV_ISASSERT((a), (b)) +#endif + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PRIV_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/priv_names.h b/illumos-x86_64/usr/include/sys/priv_names.h new file mode 100644 index 00000000..639db365 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/priv_names.h @@ -0,0 +1,740 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015, Joyent, Inc. All rights reserved. + * + * Privilege constant definitions. Privileges and privilege sets + * are only known by name and should be mapped at runtime. + * + * THIS FILE WAS GENERATED; DO NOT EDIT + */ + + +#ifndef _SYS_PRIV_NAMES_H +#define _SYS_PRIV_NAMES_H + + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __PRIV_CONST_IMPL +/* + * Privilege names + */ +/* + * Allows a process to request critical events without limitation. + * Allows a process to request reliable delivery of all events on + * any event queue. + */ +#define PRIV_CONTRACT_EVENT ((const char *)"contract_event") + +/* + * Allows a process to set the service FMRI value of a process + * contract template. + */ +#define PRIV_CONTRACT_IDENTITY ((const char *)"contract_identity") + +/* + * Allows a process to observe contract events generated by + * contracts created and owned by users other than the process's + * effective user ID. + * Allows a process to open contract event endpoints belonging to + * contracts created and owned by users other than the process's + * effective user ID. + */ +#define PRIV_CONTRACT_OBSERVER ((const char *)"contract_observer") + +/* + * Allow a process to access per-CPU hardware performance counters. + */ +#define PRIV_CPC_CPU ((const char *)"cpc_cpu") + +/* + * Allows DTrace kernel-level tracing. + */ +#define PRIV_DTRACE_KERNEL ((const char *)"dtrace_kernel") + +/* + * Allows DTrace process-level tracing. + * Allows process-level tracing probes to be placed and enabled in + * processes to which the user has permissions. + */ +#define PRIV_DTRACE_PROC ((const char *)"dtrace_proc") + +/* + * Allows DTrace user-level tracing. + * Allows use of the syscall and profile DTrace providers to + * examine processes to which the user has permissions. + */ +#define PRIV_DTRACE_USER ((const char *)"dtrace_user") + +/* + * Allows a process to change a file's owner user ID. + * Allows a process to change a file's group ID to one other than + * the process' effective group ID or one of the process' + * supplemental group IDs. + */ +#define PRIV_FILE_CHOWN ((const char *)"file_chown") + +/* + * Allows a process to give away its files; a process with this + * privilege will run as if {_POSIX_CHOWN_RESTRICTED} is not + * in effect. + */ +#define PRIV_FILE_CHOWN_SELF ((const char *)"file_chown_self") + +/* + * Allows a process to execute an executable file whose permission + * bits or ACL do not allow the process execute permission. + */ +#define PRIV_FILE_DAC_EXECUTE ((const char *)"file_dac_execute") + +/* + * Allows a process to read a file or directory whose permission + * bits or ACL do not allow the process read permission. + */ +#define PRIV_FILE_DAC_READ ((const char *)"file_dac_read") + +/* + * Allows a process to search a directory whose permission bits or + * ACL do not allow the process search permission. + */ +#define PRIV_FILE_DAC_SEARCH ((const char *)"file_dac_search") + +/* + * Allows a process to write a file or directory whose permission + * bits or ACL do not allow the process write permission. + * In order to write files owned by uid 0 in the absence of an + * effective uid of 0 ALL privileges are required. + */ +#define PRIV_FILE_DAC_WRITE ((const char *)"file_dac_write") + +/* + * Allows a process to set the sensitivity label of a file or + * directory to a sensitivity label that does not dominate the + * existing sensitivity label. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_FILE_DOWNGRADE_SL ((const char *)"file_downgrade_sl") + +/* + * Allows a process to set immutable, nounlink or appendonly + * file attributes. + */ +#define PRIV_FILE_FLAG_SET ((const char *)"file_flag_set") + +/* + * Allows a process to create hardlinks to files owned by a uid + * different from the process' effective uid. + */ +#define PRIV_FILE_LINK_ANY ((const char *)"file_link_any") + +/* + * Allows a process which is not the owner of a file or directory + * to perform the following operations that are normally permitted + * only for the file owner: modify that file's access and + * modification times; remove or rename a file or directory whose + * parent directory has the ``save text image after execution'' + * (sticky) bit set; mount a ``namefs'' upon a file; modify + * permission bits or ACL except for the set-uid and set-gid + * bits. + */ +#define PRIV_FILE_OWNER ((const char *)"file_owner") + +/* + * Allows a process to read objects in the filesystem. + */ +#define PRIV_FILE_READ ((const char *)"file_read") + +/* + * Allows a process to change the ownership of a file or write to + * a file without the set-user-ID and set-group-ID bits being + * cleared. + * Allows a process to set the set-group-ID bit on a file or + * directory whose group is not the process' effective group or + * one of the process' supplemental groups. + * Allows a process to set the set-user-ID bit on a file with + * different ownership in the presence of PRIV_FILE_OWNER. + * Additional restrictions apply when creating or modifying a + * set-uid 0 file. + */ +#define PRIV_FILE_SETID ((const char *)"file_setid") + +/* + * Allows a process to set the sensitivity label of a file or + * directory to a sensitivity label that dominates the existing + * sensitivity label. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_FILE_UPGRADE_SL ((const char *)"file_upgrade_sl") + +/* + * Allows a process to modify objects in the filesystem. + */ +#define PRIV_FILE_WRITE ((const char *)"file_write") + +/* + * Allows a process to make privileged ioctls to graphics devices. + * Typically only xserver process needs to have this privilege. + * A process with this privilege is also allowed to perform + * privileged graphics device mappings. + */ +#define PRIV_GRAPHICS_ACCESS ((const char *)"graphics_access") + +/* + * Allows a process to perform privileged mappings through a + * graphics device. + */ +#define PRIV_GRAPHICS_MAP ((const char *)"graphics_map") + +/* + * Allows a process to read a System V IPC + * Message Queue, Semaphore Set, or Shared Memory Segment whose + * permission bits do not allow the process read permission. + * Allows a process to read remote shared memory whose + * permission bits do not allow the process read permission. + */ +#define PRIV_IPC_DAC_READ ((const char *)"ipc_dac_read") + +/* + * Allows a process to write a System V IPC + * Message Queue, Semaphore Set, or Shared Memory Segment whose + * permission bits do not allow the process write permission. + * Allows a process to read remote shared memory whose + * permission bits do not allow the process write permission. + * Additional restrictions apply if the owner of the object has uid 0 + * and the effective uid of the current process is not 0. + */ +#define PRIV_IPC_DAC_WRITE ((const char *)"ipc_dac_write") + +/* + * Allows a process which is not the owner of a System + * V IPC Message Queue, Semaphore Set, or Shared Memory Segment to + * remove, change ownership of, or change permission bits of the + * Message Queue, Semaphore Set, or Shared Memory Segment. + * Additional restrictions apply if the owner of the object has uid 0 + * and the effective uid of the current process is not 0. + */ +#define PRIV_IPC_OWNER ((const char *)"ipc_owner") + +/* + * Allows a process to open a TCP, UDP, SDP or SCTP network endpoint. + */ +#define PRIV_NET_ACCESS ((const char *)"net_access") + +/* + * Allow a process to bind to a port that is configured as a + * multi-level port(MLP) for the process's zone. This privilege + * applies to both shared address and zone-specific address MLPs. + * See tnzonecfg(5) from the Trusted Extensions manual pages for + * information on configuring MLP ports. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_NET_BINDMLP ((const char *)"net_bindmlp") + +/* + * Allows a process to send and receive ICMP packets. + */ +#define PRIV_NET_ICMPACCESS ((const char *)"net_icmpaccess") + +/* + * Allows a process to set NET_MAC_AWARE process flag by using + * setpflags(2). This privilege also allows a process to set + * SO_MAC_EXEMPT socket option by using setsockopt(3SOCKET). + * The NET_MAC_AWARE process flag and the SO_MAC_EXEMPT socket + * option both allow a local process to communicate with an + * unlabeled peer if the local process' label dominates the + * peer's default label, or if the local process runs in the + * global zone. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_NET_MAC_AWARE ((const char *)"net_mac_aware") + +/* + * Allows a process to set SO_MAC_IMPLICIT option by using + * setsockopt(3SOCKET). This allows a privileged process to + * transmit implicitly-labeled packets to a peer. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_NET_MAC_IMPLICIT ((const char *)"net_mac_implicit") + +/* + * Allows a process to access /dev/lo0 and the devices in /dev/ipnet/ + * while not requiring them to need PRIV_NET_RAWACCESS. + */ +#define PRIV_NET_OBSERVABILITY ((const char *)"net_observability") + +/* + * Allows a process to bind to a privileged port + * number. The privilege port numbers are 1-1023 (the traditional + * UNIX privileged ports) as well as those ports marked as + * "udp/tcp_extra_priv_ports" with the exception of the ports + * reserved for use by NFS. + */ +#define PRIV_NET_PRIVADDR ((const char *)"net_privaddr") + +/* + * Allows a process to have direct access to the network layer. + */ +#define PRIV_NET_RAWACCESS ((const char *)"net_rawaccess") + +/* + * Allows a process to generate audit records. + * Allows a process to get its own audit pre-selection information. + */ +#define PRIV_PROC_AUDIT ((const char *)"proc_audit") + +/* + * Allows a process to change its root directory. + */ +#define PRIV_PROC_CHROOT ((const char *)"proc_chroot") + +/* + * Allows a process to use high resolution timers. + */ +#define PRIV_PROC_CLOCK_HIGHRES ((const char *)"proc_clock_highres") + +/* + * Allows a process to call execve(). + */ +#define PRIV_PROC_EXEC ((const char *)"proc_exec") + +/* + * Allows a process to call fork1()/forkall()/vfork() + */ +#define PRIV_PROC_FORK ((const char *)"proc_fork") + +/* + * Allows a process to examine the status of processes other + * than those it can send signals to. Processes which cannot + * be examined cannot be seen in /proc and appear not to exist. + */ +#define PRIV_PROC_INFO ((const char *)"proc_info") + +/* + * Allows a process to lock pages in physical memory. + */ +#define PRIV_PROC_LOCK_MEMORY ((const char *)"proc_lock_memory") + +/* + * Allows a process to access physical memory information. + */ +#define PRIV_PROC_MEMINFO ((const char *)"proc_meminfo") + +/* + * Allows a process to send signals to other processes, inspect + * and modify process state to other processes regardless of + * ownership. When modifying another process, additional + * restrictions apply: the effective privilege set of the + * attaching process must be a superset of the target process' + * effective, permitted and inheritable sets; the limit set must + * be a superset of the target's limit set; if the target process + * has any uid set to 0 all privilege must be asserted unless the + * effective uid is 0. + * Allows a process to bind arbitrary processes to CPUs. + */ +#define PRIV_PROC_OWNER ((const char *)"proc_owner") + +/* + * Allows a process to elevate its priority above its current level. + */ +#define PRIV_PROC_PRIOUP ((const char *)"proc_prioup") + +/* + * Allows all that PRIV_PROC_PRIOUP allows. + * Allows a process to change its scheduling class to any scheduling class, + * including the RT class. + */ +#define PRIV_PROC_PRIOCNTL ((const char *)"proc_priocntl") + +/* + * Allows a process to manipulate the secflags of processes (subject to, + * additionally, the ability to signal that process) + */ +#define PRIV_PROC_SECFLAGS ((const char *)"proc_secflags") + +/* + * Allows a process to send signals or trace processes outside its + * session. + */ +#define PRIV_PROC_SESSION ((const char *)"proc_session") + +/* + * Allows a process to set its uids at will. + * Assuming uid 0 requires all privileges to be asserted. + */ +#define PRIV_PROC_SETID ((const char *)"proc_setid") + +/* + * Allows a process to assign a new task ID to the calling process. + */ +#define PRIV_PROC_TASKID ((const char *)"proc_taskid") + +/* + * Allows a process to trace or send signals to processes in + * other zones. + */ +#define PRIV_PROC_ZONE ((const char *)"proc_zone") + +/* + * Allows a process to enable and disable and manage accounting through + * acct(2), getacct(2), putacct(2) and wracct(2). + */ +#define PRIV_SYS_ACCT ((const char *)"sys_acct") + +/* + * Allows a process to perform system administration tasks such + * as setting node and domain name and specifying nscd and coreadm + * settings. + */ +#define PRIV_SYS_ADMIN ((const char *)"sys_admin") + +/* + * Allows a process to start the (kernel) audit daemon. + * Allows a process to view and set audit state (audit user ID, + * audit terminal ID, audit sessions ID, audit pre-selection mask). + * Allows a process to turn off and on auditing. + * Allows a process to configure the audit parameters (cache and + * queue sizes, event to class mappings, policy options). + */ +#define PRIV_SYS_AUDIT ((const char *)"sys_audit") + +/* + * Allows a process to perform various system configuration tasks. + * Allows a process to add and remove swap devices; when adding a swap + * device, a process must also have sufficient privileges to read from + * and write to the swap device. + */ +#define PRIV_SYS_CONFIG ((const char *)"sys_config") + +/* + * Allows a process to successfully call a kernel module that + * calls the kernel drv_priv(9F) function to check for allowed + * access. + * Allows a process to open the real console device directly. + * Allows a process to open devices that have been exclusively opened. + */ +#define PRIV_SYS_DEVICES ((const char *)"sys_devices") + +/* + * Allows a process to increase the size of a System V IPC Message + * Queue buffer. + */ +#define PRIV_SYS_IPC_CONFIG ((const char *)"sys_ipc_config") + +/* + * Allows a process to unlink and link directories. + */ +#define PRIV_SYS_LINKDIR ((const char *)"sys_linkdir") + +/* + * Allows filesystem specific administrative procedures, such as + * filesystem configuration ioctls, quota calls and creation/deletion + * of snapshots. + * Allows a process to mount and unmount filesystems which would + * otherwise be restricted (i.e., most filesystems except + * namefs). + * A process performing a mount operation needs to have + * appropriate access to the device being mounted (read-write for + * "rw" mounts, read for "ro" mounts). + * A process performing any of the aforementioned + * filesystem operations needs to have read/write/owner + * access to the mount point. + * Only regular files and directories can serve as mount points + * for processes which do not have all zone privileges asserted. + * Unless a process has all zone privileges, the mount(2) + * system call will force the "nosuid" and "restrict" options, the + * latter only for autofs mountpoints. + * Regardless of privileges, a process running in a non-global zone may + * only control mounts performed from within said zone. + * Outside the global zone, the "nodevices" option is always forced. + */ +#define PRIV_SYS_MOUNT ((const char *)"sys_mount") + +/* + * Allows a process to configure IP tunnel links. + */ +#define PRIV_SYS_IPTUN_CONFIG ((const char *)"sys_iptun_config") + +/* + * Allows a process to configure all classes of datalinks, including + * configuration allowed by PRIV_SYS_IPTUN_CONFIG. + */ +#define PRIV_SYS_DL_CONFIG ((const char *)"sys_dl_config") + +/* + * Allows a process to configure a system's IP interfaces and routes. + * Allows a process to configure network parameters using ndd. + * Allows a process access to otherwise restricted information using ndd. + * Allows a process to configure IPsec. + * Allows a process to pop anchored STREAMs modules with matching zoneid. + */ +#define PRIV_SYS_IP_CONFIG ((const char *)"sys_ip_config") + +/* + * Allows all that PRIV_SYS_IP_CONFIG, PRIV_SYS_DL_CONFIG, and + * PRIV_SYS_PPP_CONFIG allow. + * Allows a process to push the rpcmod STREAMs module. + * Allows a process to INSERT/REMOVE STREAMs modules on locations other + * than the top of the module stack. + */ +#define PRIV_SYS_NET_CONFIG ((const char *)"sys_net_config") + +/* + * Allows a process to perform Sun private NFS specific system calls. + * Allows a process to bind to ports reserved by NFS: ports 2049 (nfs) + * and port 4045 (lockd). + */ +#define PRIV_SYS_NFS ((const char *)"sys_nfs") + +/* + * Allows a process to create and destroy PPP (sppp) interfaces. + * Allows a process to configure PPP tunnels (sppptun). + */ +#define PRIV_SYS_PPP_CONFIG ((const char *)"sys_ppp_config") + +/* + * Allows a process to bind processes to processor sets. + */ +#define PRIV_SYS_RES_BIND ((const char *)"sys_res_bind") + +/* + * Allows all that PRIV_SYS_RES_BIND allows. + * Allows a process to create and delete processor sets, assign + * CPUs to processor sets and override the PSET_NOESCAPE property. + * Allows a process to change the operational status of CPUs in + * the system using p_online(2). + * Allows a process to configure resource pools and to bind + * processes to pools + */ +#define PRIV_SYS_RES_CONFIG ((const char *)"sys_res_config") + +/* + * Allows a process to modify the resource limits specified + * by setrlimit(2) and setrctl(2) without restriction. + * Allows a process to exceed the per-user maximum number of + * processes. + * Allows a process to extend or create files on a filesystem that + * has less than minfree space in reserve. + */ +#define PRIV_SYS_RESOURCE ((const char *)"sys_resource") + +/* + * Allows a process to access the Sun private SMB kernel module. + * Allows a process to bind to ports reserved by NetBIOS and SMB: + * ports 137 (NBNS), 138 (NetBIOS Datagram Service), 139 (NetBIOS + * Session Service and SMB-over-NBT) and 445 (SMB-over-TCP). + */ +#define PRIV_SYS_SMB ((const char *)"sys_smb") + +/* + * Allows a process to successfully call a third party loadable module + * that calls the kernel suser() function to check for allowed access. + * This privilege exists only for third party loadable module + * compatibility and is not used by Solaris proper. + */ +#define PRIV_SYS_SUSER_COMPAT ((const char *)"sys_suser_compat") + +/* + * Allows a process to manipulate system time using any of the + * appropriate system calls: stime, adjtime, ntp_adjtime and + * the IA specific RTC calls. + */ +#define PRIV_SYS_TIME ((const char *)"sys_time") + +/* + * Allows a process to translate labels that are not dominated + * by the process' sensitivity label to and from an external + * string form. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_SYS_TRANS_LABEL ((const char *)"sys_trans_label") + +/* + * Allows a process to manage virtualized environments such as + * xVM(7). + */ +#define PRIV_VIRT_MANAGE ((const char *)"virt_manage") + +/* + * Allows a process to override colormap restrictions. + * Allows a process to install or remove colormaps. + * Allows a process to retrieve colormap cell entries allocated + * by other processes. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_COLORMAP ((const char *)"win_colormap") + +/* + * Allows a process to configure or destroy resources that are + * permanently retained by the X server. + * Allows a process to use SetScreenSaver to set the screen + * saver timeout value. + * Allows a process to use ChangeHosts to modify the display + * access control list. + * Allows a process to use GrabServer. + * Allows a process to use the SetCloseDownMode request which + * may retain window, pixmap, colormap, property, cursor, font, + * or graphic context resources. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_CONFIG ((const char *)"win_config") + +/* + * Allows a process to read from a window resource that it does + * not own (has a different user ID). + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_DAC_READ ((const char *)"win_dac_read") + +/* + * Allows a process to write to or create a window resource that + * it does not own (has a different user ID). A newly created + * window property is created with the window's user ID. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_DAC_WRITE ((const char *)"win_dac_write") + +/* + * Allows a process to perform operations on window input devices. + * Allows a process to get and set keyboard and pointer controls. + * Allows a process to modify pointer button and key mappings. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_DEVICES ((const char *)"win_devices") + +/* + * Allows a process to use the direct graphics access (DGA) X protocol + * extensions. Direct process access to the frame buffer is still + * required. Thus the process must have MAC and DAC privileges that + * allow access to the frame buffer, or the frame buffer must be + * allocated to the process. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_DGA ((const char *)"win_dga") + +/* + * Allows a process to set the sensitivity label of a window resource + * to a sensitivity label that does not dominate the existing + * sensitivity label. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_DOWNGRADE_SL ((const char *)"win_downgrade_sl") + +/* + * Allows a process to set a font path. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_FONTPATH ((const char *)"win_fontpath") + +/* + * Allows a process to read from a window resource whose sensitivity + * label is not equal to the process sensitivity label. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_MAC_READ ((const char *)"win_mac_read") + +/* + * Allows a process to create a window resource whose sensitivity + * label is not equal to the process sensitivity label. + * A newly created window property is created with the window's + * sensitivity label. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_MAC_WRITE ((const char *)"win_mac_write") + +/* + * Allows a process to request inter-window data moves without the + * intervention of the selection confirmer. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_SELECTION ((const char *)"win_selection") + +/* + * Allows a process to set the sensitivity label of a window + * resource to a sensitivity label that dominates the existing + * sensitivity label. + * This privilege is interpreted only if the system is configured + * with Trusted Extensions. + */ +#define PRIV_WIN_UPGRADE_SL ((const char *)"win_upgrade_sl") + +/* + * Allows a process access to the xVM(7) control devices for + * managing guest domains and the hypervisor. This privilege is + * used only if booted into xVM on x86 platforms. + */ +#define PRIV_XVM_CONTROL ((const char *)"xvm_control") + + +/* + * Privilege set names + */ +/* + * Set of privileges currently in effect. + */ +#define PRIV_EFFECTIVE ((const char *)"Effective") + +/* + * Set of privileges that comes into effect on exec. + */ +#define PRIV_INHERITABLE ((const char *)"Inheritable") + +/* + * Set of privileges that can be put into the effective set without + * restriction. + */ +#define PRIV_PERMITTED ((const char *)"Permitted") + +/* + * Set of privileges that determines the absolute upper bound of + * privileges this process and its off-spring can obtain. + */ +#define PRIV_LIMIT ((const char *)"Limit") + + +#endif /* __PRIV_CONST_IMPL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PRIV_NAMES_H */ diff --git a/illumos-x86_64/usr/include/sys/privmregs.h b/illumos-x86_64/usr/include/sys/privmregs.h new file mode 100644 index 00000000..e3062691 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/privmregs.h @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PRIVMREGS_H +#define _SYS_PRIVMREGS_H + +#include + +#if defined(__amd64) + +#include + +#elif defined(__i386) + +#include + +#endif + +#endif /* _SYS_PRIVMREGS_H */ diff --git a/illumos-x86_64/usr/include/sys/privregs.h b/illumos-x86_64/usr/include/sys/privregs.h new file mode 100644 index 00000000..c428e81b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/privregs.h @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PRIVREGS_H +#define _SYS_PRIVREGS_H + +#if defined(__amd64) + +#include + +#elif defined(__i386) + +#include + +#endif + +#endif /* _SYS_PRIVREGS_H */ diff --git a/illumos-x86_64/usr/include/sys/prnio.h b/illumos-x86_64/usr/include/sys/prnio.h new file mode 100644 index 00000000..85033caf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/prnio.h @@ -0,0 +1,139 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_PRNIO_H +#define _SYS_PRNIO_H + +/* + * Printing system I/O interface + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PRNIOC 'p' +#define PRNIOC_GET_IFCAP _IOR(PRNIOC, 90, uint_t) +#define PRNIOC_SET_IFCAP _IOR(PRNIOC, 91, uint_t) +#define PRNIOC_GET_IFINFO _IOWR(PRNIOC, 92, struct prn_interface_info) +#define PRNIOC_GET_STATUS _IOR(PRNIOC, 93, uint_t) +#define PRNIOC_GET_1284_DEVID _IOWR(PRNIOC, 94, struct prn_1284_device_id) +#define PRNIOC_GET_1284_STATUS _IOR(PRNIOC, 95, uchar_t) +#define PRNIOC_GET_TIMEOUTS _IOR(PRNIOC, 96, struct prn_timeouts) +#define PRNIOC_SET_TIMEOUTS _IOW(PRNIOC, 97, struct prn_timeouts) +#define PRNIOC_RESET _IO(PRNIOC, 98) + +/* + * interface capabilities + */ +#define PRN_BIDI 0x0001 /* bi-directional operation is supported */ +#define PRN_HOTPLUG 0x0002 /* interface allows device hotplugging */ +#define PRN_1284_DEVID 0x0004 /* device can return 1284 device ID */ +#define PRN_1284_STATUS 0x0008 /* device can return status lines state */ +#define PRN_TIMEOUTS 0x0010 /* timeouts are supported */ +#define PRN_STREAMS 0x0020 /* special flush semantics */ + +/* + * printer interface info + */ +struct prn_interface_info { + uint_t if_len; /* length of buffer */ + uint_t if_rlen; /* actual length of info string */ + char *if_data; /* buffer address */ +#ifndef _LP64 + int if_filler; /* preserve struct size in 32 bit */ +#endif +}; + +/* + * printer interface info string (recommended values) + */ +#define PRN_PARALLEL "parallel" /* parallel port (Centronics or 1284) */ +#define PRN_SERIAL "serial" /* serial port (EIA-232, EIA-485) */ +#define PRN_USB "USB" /* USB */ +#define PRN_1394 "1394" /* IEEE 1394 (Firewire) */ + +/* + * status bits for PRNIOC_GET_STATUS + */ +#define PRN_ONLINE 0x01 /* device is connected */ +#define PRN_READY 0x02 /* device is ready to communicate */ + +/* + * 1284 pins status bits + */ +#define PRN_1284_NOFAULT 0x08 /* device is not in error state */ +#define PRN_1284_SELECT 0x10 /* device selected */ +#define PRN_1284_PE 0x20 /* paper error */ +#define PRN_1284_BUSY 0x80 /* device busy */ + +/* + * IEEE 1284 device ID + */ +struct prn_1284_device_id { + uint_t id_len; /* length of buffer */ + uint_t id_rlen; /* actual length of device ID string */ + char *id_data; /* buffer address */ +#ifndef _LP64 + int id_filler; /* preserve struct size in 32 bit */ +#endif +}; + +/* + * printer driver timeouts + */ +struct prn_timeouts { + uint_t tmo_forward; /* forward transfer timeout */ + uint_t tmo_reverse; /* reverse transfer timeout */ +}; + +/* + * driver support for 32-bit applications + */ +#ifdef _KERNEL + +struct prn_interface_info32 { + uint_t if_len; /* length of buffer */ + uint_t if_rlen; /* actual length of info string */ + caddr32_t if_data; /* buffer address */ +}; + +struct prn_1284_device_id32 { + uint_t id_len; /* length of buffer */ + uint_t id_rlen; /* actual length of device id string */ + caddr32_t id_data; /* buffer address */ +}; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PRNIO_H */ diff --git a/illumos-x86_64/usr/include/sys/proc.h b/illumos-x86_64/usr/include/sys/proc.h new file mode 100644 index 00000000..6902f2ff --- /dev/null +++ b/illumos-x86_64/usr/include/sys/proc.h @@ -0,0 +1,862 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2021 Joyent, Inc. + * Copyright 2025 Oxide Computer Company + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_PROC_H +#define _SYS_PROC_H + +#include +#include +#include +#include +#include +#include +#if defined(__x86) +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Profile arguments. + */ +struct prof { + void *pr_base; /* buffer base */ + uintptr_t pr_off; /* pc offset */ + size_t pr_size; /* buffer size */ + uint32_t pr_scale; /* pc scaling */ + long pr_samples; /* sample count */ +}; + +/* + * An lwp directory entry. + * If le_thread != NULL, this is an active lwp. + * If le_thread == NULL, this is an unreaped zombie lwp. + */ +typedef struct lwpent { + kthread_t *le_thread; /* the active lwp, NULL if zombie */ + id_t le_lwpid; /* its lwpid (t->t_tid) */ + uint16_t le_waiters; /* total number of lwp_wait()ers */ + uint16_t le_dwaiters; /* number that are daemons */ + clock_t le_start; /* start time of this lwp */ + struct vnode *le_trace; /* pointer to /proc lwp vnode */ +} lwpent_t; + +typedef struct pctxop { + void (*save_op)(void *); /* function to invoke to save ctx */ + void (*restore_op)(void *); /* function to invoke to restore ctx */ + void (*fork_op)(void *, void *); /* invoke to fork context */ + void (*exit_op)(void *); /* invoked during process exit */ + void (*free_op)(void *, int); /* function which frees the context */ + void *arg; /* argument to above functions */ + struct pctxop *next; /* next pcontext ops */ +} pctxop_t; + +/* + * Elements of the lwp directory, p->p_lwpdir[]. + * + * We allocate lwp directory entries separately from lwp directory + * elements because the lwp directory must be allocated as an array. + * The number of lwps can grow quite large and we want to keep the + * size of the kmem_alloc()d directory as small as possible. + * + * If ld_entry == NULL, the entry is free and is on the free list, + * p->p_lwpfree, linked through ld_next. If ld_entry != NULL, the + * entry is used and ld_next is the thread-id hash link pointer. + */ +typedef struct lwpdir { + struct lwpdir *ld_next; /* hash chain or free list */ + struct lwpent *ld_entry; /* lwp directory entry */ +} lwpdir_t; + +/* + * Element of the p_tidhash thread-id (lwpid) hash table. + */ +typedef struct tidhash { + kmutex_t th_lock; + lwpdir_t *th_list; +} tidhash_t; + +/* + * Retired tidhash hash tables. + */ +typedef struct ret_tidhash { + struct ret_tidhash *rth_next; + tidhash_t *rth_tidhash; + uint_t rth_tidhash_sz; +} ret_tidhash_t; + +struct pool; +struct task; +struct zone; +struct brand; +struct corectl_path; +struct corectl_content; + +/* + * One structure allocated per active process. It contains all + * data needed about the process while the process may be swapped + * out. Other per-process data (user.h) is also inside the proc structure. + * Lightweight-process data (lwp.h) and the kernel stack may be swapped out. + */ +typedef struct proc { + /* + * Fields requiring no explicit locking + */ + struct vnode *p_exec; /* pointer to a.out vnode */ + struct as *p_as; /* process address space pointer */ + struct plock *p_lockp; /* ptr to proc struct's mutex lock */ + kmutex_t p_crlock; /* lock for p_cred */ + struct cred *p_cred; /* process credentials */ + /* + * Fields protected by pidlock + */ + int p_swapcnt; /* number of swapped out lwps */ + char p_stat; /* status of process */ + char p_wcode; /* current wait code */ + ushort_t p_pidflag; /* flags protected only by pidlock */ + int p_wdata; /* current wait return value */ + pid_t p_ppid; /* process id of parent */ + struct proc *p_link; /* forward link */ + struct proc *p_parent; /* ptr to parent process */ + struct proc *p_child; /* ptr to first child process */ + struct proc *p_sibling; /* ptr to next sibling proc on chain */ + struct proc *p_psibling; /* ptr to prev sibling proc on chain */ + struct proc *p_sibling_ns; /* prt to siblings with new state */ + struct proc *p_child_ns; /* prt to children with new state */ + struct proc *p_next; /* active chain link next */ + struct proc *p_prev; /* active chain link prev */ + struct proc *p_nextofkin; /* gets accounting info at exit */ + struct proc *p_orphan; + struct proc *p_nextorph; + struct proc *p_pglink; /* process group hash chain link next */ + struct proc *p_ppglink; /* process group hash chain link prev */ + struct sess *p_sessp; /* session information */ + struct pid *p_pidp; /* process ID info */ + struct pid *p_pgidp; /* process group ID info */ + /* + * Fields protected by p_lock + */ + kcondvar_t p_cv; /* proc struct's condition variable */ + kcondvar_t p_flag_cv; + kcondvar_t p_lwpexit; /* waiting for some lwp to exit */ + kcondvar_t p_holdlwps; /* process is waiting for its lwps */ + /* to to be held. */ + uint_t p_proc_flag; /* /proc-related flags */ + uint_t p_flag; /* protected while set. */ + /* flags defined below */ + clock_t p_utime; /* user time, this process */ + clock_t p_stime; /* system time, this process */ + clock_t p_cutime; /* sum of children's user time */ + clock_t p_cstime; /* sum of children's system time */ + avl_tree_t *p_segacct; /* System V shared segment list */ + avl_tree_t *p_semacct; /* System V semaphore undo list */ + caddr_t p_bssbase; /* base addr of last bss below heap */ + caddr_t p_brkbase; /* base addr of heap */ + size_t p_brksize; /* heap size in bytes */ + uint_t p_brkpageszc; /* preferred heap max page size code */ + /* + * Per process signal stuff. + */ + k_sigset_t p_sig; /* signals pending to this process */ + k_sigset_t p_extsig; /* signals sent from another contract */ + k_sigset_t p_ignore; /* ignore when generated */ + k_sigset_t p_siginfo; /* gets signal info with signal */ + void *p_sigfd; /* signalfd support state */ + struct sigqueue *p_sigqueue; /* queued siginfo structures */ + struct sigqhdr *p_sigqhdr; /* hdr to sigqueue structure pool */ + struct sigqhdr *p_signhdr; /* hdr to signotify structure pool */ + uchar_t p_stopsig; /* jobcontrol stop signal */ + + /* + * Special per-process flag when set will fix misaligned memory + * references. + */ + char p_fixalignment; + + /* + * Per process lwp and kernel thread stuff + */ + id_t p_lwpid; /* most recently allocated lwpid */ + int p_lwpcnt; /* number of lwps in this process */ + int p_lwprcnt; /* number of not stopped lwps */ + int p_lwpdaemon; /* number of TP_DAEMON lwps */ + int p_lwpwait; /* number of lwps in lwp_wait() */ + int p_lwpdwait; /* number of daemons in lwp_wait() */ + int p_zombcnt; /* number of zombie lwps */ + kthread_t *p_tlist; /* circular list of threads */ + lwpdir_t *p_lwpdir; /* thread (lwp) directory */ + lwpdir_t *p_lwpfree; /* p_lwpdir free list */ + tidhash_t *p_tidhash; /* tid (lwpid) lookup hash table */ + uint_t p_lwpdir_sz; /* number of p_lwpdir[] entries */ + uint_t p_tidhash_sz; /* number of p_tidhash[] entries */ + ret_tidhash_t *p_ret_tidhash; /* retired tidhash hash tables */ + uint64_t p_lgrpset; /* unprotected hint of set of lgrps */ + /* on which process has threads */ + volatile lgrp_id_t p_t1_lgrpid; /* main's thread lgroup id */ + volatile lgrp_id_t p_tr_lgrpid; /* text replica's lgroup id */ +#if defined(_LP64) + uintptr_t p_lgrpres2; /* reserved for lgrp migration */ +#endif + /* + * /proc (process filesystem) debugger interface stuff. + */ + k_sigset_t p_sigmask; /* mask of traced signals (/proc) */ + k_fltset_t p_fltmask; /* mask of traced faults (/proc) */ + struct vnode *p_trace; /* pointer to primary /proc vnode */ + struct vnode *p_plist; /* list of /proc vnodes for process */ + kthread_t *p_agenttp; /* thread ptr for /proc agent lwp */ + avl_tree_t p_warea; /* list of watched areas */ + avl_tree_t p_wpage; /* remembered watched pages (vfork) */ + watched_page_t *p_wprot; /* pages that need to have prot set */ + int p_mapcnt; /* number of active pr_mappage()s */ + kmutex_t p_maplock; /* lock for pr_mappage() */ + struct proc *p_rlink; /* linked list for server */ + kcondvar_t p_srwchan_cv; + + /* + * Stack sizing and guard information. + * Generally protected by as_rangelock() + */ + size_t p_stksize; /* process stack size in bytes */ + uint_t p_stkpageszc; /* preferred stack max page size code */ + uintptr_t p_stkg_start; /* start of stack guard */ + uintptr_t p_stkg_end; /* end of stack guard */ + + /* + * Microstate accounting, resource usage, and real-time profiling + */ + hrtime_t p_mstart; /* hi-res process start time */ + hrtime_t p_mterm; /* hi-res process termination time */ + hrtime_t p_mlreal; /* elapsed time sum over defunct lwps */ + hrtime_t p_acct[NMSTATES]; /* microstate sum over defunct lwps */ + hrtime_t p_cacct[NMSTATES]; /* microstate sum over child procs */ + struct lrusage p_ru; /* lrusage sum over defunct lwps */ + struct lrusage p_cru; /* lrusage sum over child procs */ + struct itimerval p_rprof_timer; /* ITIMER_REALPROF interval timer */ + uintptr_t p_rprof_cyclic; /* ITIMER_REALPROF cyclic */ + uint_t p_defunct; /* number of defunct lwps */ + /* + * profiling. A lock is used in the event of multiple lwp's + * using the same profiling base/size. + */ + kmutex_t p_pflock; /* protects user profile arguments */ + struct prof p_prof; /* profile arguments */ + + /* + * Doors. + */ + door_pool_t p_server_threads; /* common thread pool */ + struct door_node *p_door_list; /* active doors */ + struct door_node *p_unref_list; + kcondvar_t p_unref_cv; + char p_unref_thread; /* unref thread created */ + + /* + * Solaris Audit + */ + struct p_audit_data *p_audit_data; /* per process audit structure */ + + pctxop_t *p_pctx; + +#if defined(__x86) + /* + * LDT support. + */ + kmutex_t p_ldtlock; /* protects the following fields */ + user_desc_t *p_ldt; /* Pointer to private LDT */ + uint64_t p_unused1; /* no longer used */ + uint64_t p_unused2; /* no longer used */ + ushort_t p_ldtlimit; /* highest selector used */ +#endif + size_t p_swrss; /* resident set size before last swap */ + struct aio *p_aio; /* pointer to async I/O struct */ + struct itimer **p_itimer; /* interval timers */ + uint_t p_itimer_sz; /* max allocated interval timers */ + timeout_id_t p_alarmid; /* alarm's timeout id */ + caddr_t p_usrstack; /* top of the process stack */ + uint_t p_stkprot; /* stack memory protection */ + uint_t p_datprot; /* data memory protection */ + model_t p_model; /* data model determined at exec time */ + struct lwpchan_data *p_lcp; /* lwpchan cache */ + kmutex_t p_lcp_lock; /* protects assignments to p_lcp */ + utrap_handler_t *p_utraps; /* pointer to user trap handlers */ + struct corectl_path *p_corefile; /* pattern for core file */ + struct task *p_task; /* our containing task */ + struct proc *p_taskprev; /* ptr to previous process in task */ + struct proc *p_tasknext; /* ptr to next process in task */ + kmutex_t p_sc_lock; /* protects p_pagep */ + struct sc_page_ctl *p_pagep; /* list of process's shared pages */ + struct rctl_set *p_rctls; /* resource controls for this process */ + rlim64_t p_stk_ctl; /* currently enforced stack size */ + rlim64_t p_fsz_ctl; /* currently enforced file size */ + rlim64_t p_vmem_ctl; /* currently enforced addr-space size */ + rlim64_t p_fno_ctl; /* currently enforced file-desc limit */ + pid_t p_ancpid; /* ancestor pid, used by exacct */ + struct itimerval p_realitimer; /* real interval timer */ + timeout_id_t p_itimerid; /* real interval timer's timeout id */ + struct corectl_content *p_content; /* content of core file */ + + avl_tree_t p_ct_held; /* held contracts */ + struct ct_equeue **p_ct_equeue; /* process-type event queues */ + + struct cont_process *p_ct_process; /* process contract */ + list_node_t p_ct_member; /* process contract membership */ + sigqueue_t *p_killsqp; /* sigqueue pointer for SIGKILL */ + + int p_dtrace_probes; /* are there probes for this proc? */ + uint64_t p_dtrace_count; /* number of DTrace tracepoints */ + /* (protected by P_PR_LOCK) */ + void *p_dtrace_helpers; /* DTrace helpers, if any */ + struct pool *p_pool; /* pointer to containing pool */ + kcondvar_t p_poolcv; /* synchronization with pools */ + uint_t p_poolcnt; /* # threads inside pool barrier */ + uint_t p_poolflag; /* pool-related flags (see below) */ + uint_t p_upanicflag; /* upanic-related flags (see below) */ + void *p_upanic; /* optional upanic data */ + uintptr_t p_portcnt; /* event ports counter */ + struct zone *p_zone; /* zone in which process lives */ + struct vnode *p_execdir; /* directory that p_exec came from */ + struct brand *p_brand; /* process's brand */ + + /* per-process brand state */ + void *p_brand_data; + psecflags_t p_secflags; /* per-process security flags */ + + /* additional lock to protect p_sessp (but not its contents) */ + kmutex_t p_splock; + rctl_qty_t p_locked_mem; /* locked memory charged to proc */ + /* protected by p_lock */ + rctl_qty_t p_crypto_mem; /* /dev/crypto memory charged to proc */ + /* protected by p_lock */ + clock_t p_ttime; /* buffered task time */ + + /* + * The user structure + */ + struct user p_user; /* (see sys/user.h) */ +} proc_t; +#define PROC_T /* headers relying on proc_t are OK */ + +#ifdef _KERNEL + +/* active process chain */ + +extern proc_t *practive; + +/* Well known processes */ + +extern proc_t *proc_sched; /* memory scheduler */ +extern proc_t *proc_init; /* init */ +extern proc_t *proc_pageout; /* pageout daemon */ +extern proc_t *proc_fsflush; /* filesystem sync-er */ + +#endif /* _KERNEL */ + +/* + * Stuff to keep track of the number of processes each uid has. + * It is tracked on a per-zone basis; that is, if users in different + * zones have the same uid, they are tracked separately. + * + * A structure is allocated when a new pair shows up + * There is a hash to find each structure. + */ +struct upcount { + struct upcount *up_next; + uid_t up_uid; + zoneid_t up_zoneid; + uint_t up_count; +}; + +/* process ID info */ + +struct pid { + unsigned int pid_prinactive :1; + unsigned int pid_pgorphaned :1; + unsigned int pid_padding :6; /* used to be pid_ref, now an int */ + unsigned int pid_prslot :24; + pid_t pid_id; + struct proc *pid_pglink; + struct proc *pid_pgtail; + struct pid *pid_link; + uint_t pid_ref; +}; + +#define p_pgrp p_pgidp->pid_id +#define p_pid p_pidp->pid_id +#define p_slot p_pidp->pid_prslot +#define p_detached p_pgidp->pid_pgorphaned + +#define PID_HOLD(pidp) ASSERT(MUTEX_HELD(&pidlock)); \ + ++(pidp)->pid_ref; +#define PID_RELE(pidp) ASSERT(MUTEX_HELD(&pidlock)); \ + (pidp)->pid_ref > 1 ? \ + --(pidp)->pid_ref : pid_rele(pidp); + +/* + * Structure containing persistent process lock. The structure and + * macro allow "mutex_enter(&p->p_lock)" to continue working. + */ +struct plock { + kmutex_t pl_lock; +}; +#define p_lock p_lockp->pl_lock + +#ifdef _KERNEL +extern proc_t p0; /* process 0 */ +extern struct plock p0lock; /* p0's plock */ +extern struct pid pid0; /* p0's pid */ + +/* pid_allocate() flags */ +#define PID_ALLOC_PROC 0x0001 /* assign a /proc slot as well */ + +#endif /* _KERNEL */ + +/* stat codes */ + +#define SSLEEP 1 /* awaiting an event */ +#define SRUN 2 /* runnable */ +#define SZOMB 3 /* process terminated but not waited for */ +#define SSTOP 4 /* process stopped by debugger */ +#define SIDL 5 /* intermediate state in process creation */ +#define SONPROC 6 /* process is being run on a processor */ +#define SWAIT 7 /* process is waiting to become runnable */ + +/* p_pidflag codes */ +#define CLDPEND 0x0001 /* have yet to post a SIGCHLD to the parent */ +#define CLDCONT 0x0002 /* child has notified parent of CLD_CONTINUED */ +#define CLDNOSIGCHLD 0x0004 /* do not post SIGCHLD when child terminates */ +#define CLDWAITPID 0x0008 /* only waitid(P_PID, pid) can reap the child */ + +/* p_proc_flag codes -- these flags are mostly private to /proc */ +#define P_PR_TRACE 0x0001 /* signal, fault or syscall tracing via /proc */ +#define P_PR_PTRACE 0x0002 /* ptrace() compatibility mode */ +#define P_PR_FORK 0x0004 /* child inherits tracing flags */ +#define P_PR_LOCK 0x0008 /* process locked by /proc */ +#define P_PR_ASYNC 0x0010 /* asynchronous stopping via /proc */ +#define P_PR_EXEC 0x0020 /* process is in exec() */ +#define P_PR_BPTADJ 0x0040 /* adjust pc on breakpoint trap */ +#define P_PR_RUNLCL 0x0080 /* set process running on last /proc close */ +#define P_PR_KILLCL 0x0100 /* kill process on last /proc close */ + +/* + * p_flag codes + * + * note that two of these flags, SMSACCT and SSYS, are exported to /proc's + * psinfo_t.p_flag field. Historically, all were, but since they are + * implementation dependant, we only export the ones people have come to + * rely upon. Hence, the bit positions of SSYS and SMSACCT should not be + * altered. + */ +#define SSYS 0x00000001 /* system (resident) process */ +#define SEXITING 0x00000002 /* process is exiting */ +#define SITBUSY 0x00000004 /* setitimer(ITIMER_REAL) in progress */ +#define SFORKING 0x00000008 /* tells called functions that we're forking */ +#define SWATCHOK 0x00000010 /* proc in acceptable state for watchpoints */ +#define SKILLED 0x00000100 /* SIGKILL has been posted to the process */ +#define SSCONT 0x00000200 /* SIGCONT has been posted to the process */ +#define SZONETOP 0x00000400 /* process has no valid PPID in its zone */ +#define SEXTKILLED 0x00000800 /* SKILLED is from another contract */ +#define SUGID 0x00002000 /* process was result of set[ug]id exec */ +#define SEXECED 0x00004000 /* this process has execed */ +#define SJCTL 0x00010000 /* SIGCHLD sent when children stop/continue */ +#define SNOWAIT 0x00020000 /* children never become zombies */ +#define SVFORK 0x00040000 /* child of vfork that has not yet exec'd */ +#define SVFWAIT 0x00080000 /* parent of vfork waiting for child to exec */ +#define SEXITLWPS 0x00100000 /* have lwps exit within the process */ +#define SHOLDFORK 0x00200000 /* hold lwps where they're cloneable */ +#define SHOLDFORK1 0x00800000 /* hold lwps in place (not cloning) */ +#define SCOREDUMP 0x01000000 /* process is dumping core */ +#define SMSACCT 0x02000000 /* process is keeping micro-state accounting */ +#define SLWPWRAP 0x04000000 /* process has wrapped its lwp ids */ +#define SAUTOLPG 0x08000000 /* kernel controls page sizes */ +#define SNOCD 0x10000000 /* new creds from VSxID, do not coredump */ +#define SHOLDWATCH 0x20000000 /* hold lwps for watchpoint operation */ +#define SMSFORK 0x40000000 /* child inherits micro-state accounting */ +#define SDOCORE 0x80000000 /* process will attempt to dump core */ + +/* + * p_poolflag codes + * + * These flags are used to synchronize with the pool subsystem to allow + * re-binding of processes to new pools. + */ +#define PBWAIT 0x0001 /* process should wait outside fork/exec/exit */ +#define PEXITED 0x0002 /* process exited and about to become zombie */ + +/* + * p_upanicflag codes + */ +#define P_UPF_PANICKED 0x0001 +#define P_UPF_HAVEMSG 0x0002 +#define P_UPF_TRUNCMSG 0x0004 +#define P_UPF_INVALMSG 0x0008 + +/* Macro to convert proc pointer to a user block pointer */ +#define PTOU(p) (&(p)->p_user) + +#define tracing(p, sig) (sigismember(&(p)->p_sigmask, sig)) + +/* Macro to reduce unnecessary calls to issig() */ + +#define ISSIG(t, why) ISSIG_FAST(t, ttolwp(t), ttoproc(t), why) + +/* + * Fast version of ISSIG. + * 1. uses register pointers to lwp and proc instead of reloading them. + * 2. uses bit-wise OR of tests, since the usual case is that none of them + * are true, this saves orcc's and branches. + * 3. load the signal flags instead of using sigisempty() macro which does + * a branch to convert to boolean. + */ +#define ISSIG_FAST(t, lwp, p, why) \ + (ISSIG_PENDING(t, lwp, p) && issig(why)) + +#define ISSIG_PENDING(t, lwp, p) \ + ((lwp)->lwp_cursig | \ + sigcheck((p), (t)) | \ + (p)->p_stopsig | \ + (t)->t_dtrace_stop | \ + (t)->t_dtrace_sig | \ + ((t)->t_proc_flag & (TP_PRSTOP|TP_HOLDLWP|TP_CHKPT|TP_PAUSE)) | \ + ((p)->p_flag & (SEXITLWPS|SKILLED|SHOLDFORK1|SHOLDWATCH))) + +#define ISSTOP(sig) (u.u_signal[sig-1] == SIG_DFL && \ + sigismember(&stopdefault, sig)) + +#define ISHOLD(p) ((p)->p_flag & SHOLDFORK) + +#define MUSTRETURN(p, t) (ISHOLD(p) | (t)->t_activefd.a_stale) + +/* + * Determine if there are any watchpoints active in the process. + */ +#define pr_watch_active(p) (avl_numnodes(&(p)->p_warea) != 0) + +/* Reasons for calling issig() */ + +#define FORREAL 0 /* Usual side-effects */ +#define JUSTLOOKING 1 /* Don't stop the process */ + +/* 'what' values for stop(PR_SUSPENDED, what) */ +#define SUSPEND_NORMAL 0 +#define SUSPEND_PAUSE 1 + +/* pseudo-flag to lwp_create() */ +#define NOCLASS (-1) + +/* unused scheduling class ID */ +#define CLASS_UNUSED (-2) + +/* LWP stats updated via lwp_stats_update() */ +typedef enum { + LWP_STAT_INBLK, + LWP_STAT_OUBLK, + LWP_STAT_MSGRCV, + LWP_STAT_MSGSND +} lwp_stat_id_t; + +typedef struct prkillinfo { + int32_t prk_error; /* errno */ + int32_t prk_pad; /* pad */ + siginfo_t prk_info; /* siginfo of killing signal */ +} prkillinfo_t; + +#ifdef _KERNEL + +/* user profiling functions */ + +extern void profil_tick(uintptr_t); + +/* process management functions */ + +extern int newproc(void (*)(), caddr_t, id_t, int, struct contract **, pid_t); +extern void vfwait(pid_t); +extern void proc_detach(proc_t *); +extern void freeproc(proc_t *); +extern void setrun(kthread_t *); +extern void setrun_locked(kthread_t *); +extern void exit(int, int); +extern int proc_exit(int, int); +extern void proc_is_exiting(proc_t *); +extern void relvm(void); +extern void add_ns(proc_t *, proc_t *); +extern void delete_ns(proc_t *, proc_t *); +extern void upcount_inc(uid_t, zoneid_t); +extern void upcount_dec(uid_t, zoneid_t); +extern int upcount_get(uid_t, zoneid_t); +#if defined(__x86) +extern selector_t setup_thrptr(proc_t *, uintptr_t); +extern void deferred_singlestep_trap(caddr_t); +#endif + +extern void sigcld(proc_t *, sigqueue_t *); +extern void sigcld_delete(k_siginfo_t *); +extern void sigcld_repost(void); +extern int fsig(k_sigset_t *, kthread_t *); +extern void psig(void); +extern void stop(int, int); +extern int stop_on_fault(uint_t, k_siginfo_t *); +extern int issig(int); +extern int jobstopped(proc_t *); +extern void psignal(proc_t *, int); +extern void tsignal(kthread_t *, int); +extern void sigtoproc(proc_t *, kthread_t *, int); +extern void trapsig(k_siginfo_t *, int); +extern void realsigprof(int, int, int); +extern int eat_signal(kthread_t *, int); +extern int signal_is_blocked(kthread_t *, int); +extern int sigcheck(proc_t *, kthread_t *); +extern void sigdefault(proc_t *); + +extern struct pid *pid_find(pid_t pid); +extern void pid_setmin(void); +extern pid_t pid_allocate(proc_t *, pid_t, int); +extern int pid_rele(struct pid *); +extern void pid_exit(proc_t *, struct task *); +extern void proc_entry_free(struct pid *); +extern proc_t *prfind(pid_t); +extern proc_t *prfind_zone(pid_t, zoneid_t); +extern proc_t *pgfind(pid_t); +extern proc_t *pgfind_zone(pid_t, zoneid_t); +extern proc_t *sprlock(pid_t); +extern proc_t *sprlock_zone(pid_t, zoneid_t); +extern int sprtrylock_proc(proc_t *); +extern void sprwaitlock_proc(proc_t *); +extern void sprlock_proc(proc_t *); +extern void sprunlock(proc_t *); +extern void sprunprlock(proc_t *); +extern void pid_init(void); +extern proc_t *pid_entry(int); +extern int pid_slot(proc_t *); +extern void signal(pid_t, int); +extern void prsignal(struct pid *, int); +extern int uread(proc_t *, void *, size_t, uintptr_t); +extern int uwrite(proc_t *, void *, size_t, uintptr_t); + +extern void pgsignal(struct pid *, int); +extern void pgjoin(proc_t *, struct pid *); +extern void pgcreate(proc_t *); +extern void pgexit(proc_t *); +extern void pgdetach(proc_t *); +extern int pgmembers(pid_t); + +extern void init_mstate(kthread_t *, int); +extern int new_mstate(kthread_t *, int); +extern void restore_mstate(kthread_t *); +extern void term_mstate(kthread_t *); +extern void estimate_msacct(kthread_t *, hrtime_t); +extern void disable_msacct(proc_t *); +extern hrtime_t mstate_aggr_state(proc_t *, int); +extern hrtime_t mstate_thread_onproc_time(kthread_t *); +extern void mstate_systhread_times(kthread_t *, hrtime_t *, hrtime_t *); +extern void syscall_mstate(int, int); + +extern uint_t cpu_update_pct(kthread_t *, hrtime_t); + +extern void set_proc_pre_sys(proc_t *p); +extern void set_proc_post_sys(proc_t *p); +extern void set_proc_sys(proc_t *p); +extern void set_proc_ast(proc_t *p); +extern void set_all_proc_sys(void); +extern void set_all_zone_usr_proc_sys(zoneid_t); + +/* thread function prototypes */ + +extern kthread_t *thread_create( + caddr_t stk, + size_t stksize, + void (*proc)(), + void *arg, + size_t len, + proc_t *pp, + int state, + pri_t pri); +extern void thread_exit(void) __NORETURN; +extern void thread_free(kthread_t *); +extern void thread_rele(kthread_t *); +extern void thread_join(kt_did_t); +extern int reaper(void); + +#define CTXOP_TPL_REV 1 + +struct ctxop_template { + uint32_t ct_rev; + uint32_t ct_pad; + void (*ct_save)(void *); + void (*ct_restore)(void *); + void (*ct_fork)(void *, void *); + void (*ct_lwp_create)(void *, void *); + void (*ct_exit)(void *); + void (*ct_free)(void *, int); +}; + +extern struct ctxop *ctxop_allocate(const struct ctxop_template *, void *); +extern void ctxop_free(struct ctxop *); +extern void ctxop_attach(kthread_t *, struct ctxop *); +extern void ctxop_detach(kthread_t *, struct ctxop *); +extern void ctxop_install(kthread_t *, const struct ctxop_template *, void *); +extern int ctxop_remove(kthread_t *, const struct ctxop_template *, void *); + +extern void savectx(kthread_t *); +extern void restorectx(kthread_t *); +extern void forkctx(kthread_t *, kthread_t *); +extern void lwp_createctx(kthread_t *, kthread_t *); +extern void exitctx(kthread_t *); +extern void freectx(kthread_t *, int); +extern void installpctx(proc_t *, void *, void (*)(), void (*)(), + void (*)(), void (*)(), void (*)()); +extern int removepctx(proc_t *, void *, void (*)(), void (*)(), + void (*)(), void (*)(), void (*)()); +extern void savepctx(proc_t *); +extern void restorepctx(proc_t *); +extern void forkpctx(proc_t *, proc_t *); +extern void exitpctx(proc_t *); +extern void freepctx(proc_t *, int); +extern kthread_t *thread_unpin(void); +extern void thread_init(void); +extern void thread_load(kthread_t *, void (*)(), caddr_t, size_t); + +extern void tsd_create(uint_t *, void (*)(void *)); +extern void tsd_destroy(uint_t *); +extern void *tsd_getcreate(uint_t *, void (*)(void *), void *(*)(void)); +extern void *tsd_get(uint_t); +extern int tsd_set(uint_t, void *); +extern void tsd_exit(void); +extern void *tsd_agent_get(kthread_t *, uint_t); +extern int tsd_agent_set(kthread_t *, uint_t, void *); + +/* lwp function prototypes */ + +extern kthread_t *lwp_kernel_create(proc_t *, void (*)(), void *, int, pri_t); +extern klwp_t *lwp_create( + void (*proc)(), + caddr_t arg, + size_t len, + proc_t *p, + int state, + int pri, + const k_sigset_t *smask, + int cid, + id_t lwpid); +extern kthread_t *idtot(proc_t *, id_t); +extern void lwp_hash_in(proc_t *, lwpent_t *, tidhash_t *, uint_t, int); +extern void lwp_hash_out(proc_t *, id_t); +extern lwpdir_t *lwp_hash_lookup(proc_t *, id_t); +extern lwpdir_t *lwp_hash_lookup_and_lock(proc_t *, id_t, kmutex_t **); +extern void lwp_create_done(kthread_t *); +extern void lwp_exit(void); +extern void lwp_pcb_exit(void); +extern void lwp_cleanup(void); +extern int lwp_suspend(kthread_t *); +extern void lwp_continue(kthread_t *); +extern void holdlwp(void); +extern void stoplwp(void); +extern int holdlwps(int); +extern int holdwatch(void); +extern void pokelwps(proc_t *); +extern void runlwps(proc_t *, ushort_t); +extern void continuelwps(proc_t *); +extern int exitlwps(int); +extern void lwp_ctmpl_copy(klwp_t *, klwp_t *); +extern void lwp_ctmpl_clear(klwp_t *, boolean_t); +extern klwp_t *forklwp(klwp_t *, proc_t *, id_t); +extern void lwp_load(klwp_t *, gregset_t, uintptr_t); +extern void lwp_setrval(klwp_t *, int, int); +extern void lwp_forkregs(klwp_t *, klwp_t *); +extern void lwp_freeregs(klwp_t *, int); +extern caddr_t lwp_stk_init(klwp_t *, caddr_t); +extern void lwp_stk_cache_init(void); +extern void lwp_stk_fini(klwp_t *); +extern void lwp_fp_init(klwp_t *); +extern void lwp_installctx(klwp_t *); +extern void lwp_rtt(void); +extern void lwp_rtt_initial(void); +extern int lwp_setprivate(klwp_t *, int, uintptr_t); +extern void lwp_stat_update(lwp_stat_id_t, long); +extern void lwp_attach_brand_hdlrs(klwp_t *); +extern void lwp_detach_brand_hdlrs(klwp_t *); + +#if defined(__sparcv9) +extern void lwp_mmodel_newlwp(void); +extern void lwp_mmodel_shared_as(caddr_t, size_t); +#define LWP_MMODEL_NEWLWP() lwp_mmodel_newlwp() +#define LWP_MMODEL_SHARED_AS(addr, sz) lwp_mmodel_shared_as((addr), (sz)) +#else +#define LWP_MMODEL_NEWLWP() +#define LWP_MMODEL_SHARED_AS(addr, sz) +#endif + +/* + * Signal queue function prototypes. Must be here due to header ordering + * dependencies. + */ +extern void sigqfree(proc_t *); +extern void siginfofree(sigqueue_t *); +extern void sigdeq(proc_t *, kthread_t *, int, sigqueue_t **); +extern void sigdelq(proc_t *, kthread_t *, int); +extern void sigaddq(proc_t *, kthread_t *, k_siginfo_t *, int); +extern void sigaddqa(proc_t *, kthread_t *, sigqueue_t *); +extern void sigqsend(int, proc_t *, kthread_t *, sigqueue_t *); +extern void sigdupq(proc_t *, proc_t *); +extern int sigwillqueue(int, int); +extern sigqhdr_t *sigqhdralloc(size_t, uint_t); +extern sigqueue_t *sigqalloc(sigqhdr_t *); +extern void sigqhdrfree(sigqhdr_t *); +extern sigqueue_t *sigappend(k_sigset_t *, sigqueue_t *, + k_sigset_t *, sigqueue_t *); +extern sigqueue_t *sigprepend(k_sigset_t *, sigqueue_t *, + k_sigset_t *, sigqueue_t *); +extern void winfo(proc_t *, k_siginfo_t *, int); +extern int wstat(int, int); +extern int sendsig(int, k_siginfo_t *, void (*)()); +#if defined(_SYSCALL32_IMPL) +extern int sendsig32(int, k_siginfo_t *, void (*)()); +#endif + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROC_H */ diff --git a/illumos-x86_64/usr/include/sys/proc/prdata.h b/illumos-x86_64/usr/include/sys/proc/prdata.h new file mode 100644 index 00000000..590d3159 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/proc/prdata.h @@ -0,0 +1,502 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2019 Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_PROC_PRDATA_H +#define _SYS_PROC_PRDATA_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Test for thread being stopped, not on an event of interest, + * but with a directed stop in effect. + */ +#define DSTOPPED(t) \ + ((t)->t_state == TS_STOPPED && \ + ((t)->t_proc_flag & TP_PRSTOP)) + +#define round4(r) (((r) + 3) & (~3)) +#define round8(r) (((r) + 7) & (~7)) +#define round16(r) (((r) + 15) & (~15)) +#define roundlong(r) (((r) + sizeof (long) - 1) & (~(sizeof (long) - 1))) + +#define PNSIZ 10 /* max size of /proc name entries */ +#define PLNSIZ 10 /* max size of /proc lwp name entries */ + +/* + * Common file object to which all /proc vnodes for a specific process + * or lwp refer. One for the process, one for each lwp. + */ +typedef struct prcommon { + kmutex_t prc_mutex; /* to wait for the proc/lwp to stop */ + kcondvar_t prc_wait; /* to wait for the proc/lwp to stop */ + ushort_t prc_flags; /* flags */ + uint_t prc_writers; /* number of write opens of prnodes */ + uint_t prc_selfopens; /* number of write opens by self */ + pid_t prc_pid; /* process id */ + model_t prc_datamodel; /* data model of the process */ + proc_t *prc_proc; /* process being traced */ + kthread_t *prc_thread; /* thread (lwp) being traced */ + int prc_slot; /* procdir slot number */ + id_t prc_tid; /* thread (lwp) id */ + int prc_tslot; /* lwpdir slot number, -1 if reaped */ + int prc_refcnt; /* this structure's reference count */ + struct pollhead prc_pollhead; /* list of all pollers */ +} prcommon_t; + +/* prc_flags */ +#define PRC_DESTROY 0x01 /* process or lwp is being destroyed */ +#define PRC_LWP 0x02 /* structure refers to an lwp */ +#define PRC_SYS 0x04 /* process is a system process */ +#define PRC_POLL 0x08 /* poll() in progress on this process/lwp */ +#define PRC_EXCL 0x10 /* exclusive access granted (old /proc) */ + +/* + * Macros for mapping between i-numbers and pids. + */ +#define pmkino(tslot, pslot, nodetype) \ + (((((ino_t)(tslot) << nproc_highbit) | \ + (ino_t)(pslot)) << 6) | \ + (nodetype) + 2) + +/* for old /proc interface */ +#define PRBIAS 64 +#define ptoi(n) ((int)(((n) + PRBIAS))) /* pid to i-number */ + +/* + * Node types for /proc files (directories and files contained therein). + */ +typedef enum prnodetype { + PR_PROCDIR, /* /proc */ + PR_SELF, /* /proc/self */ + PR_PIDDIR, /* /proc/ */ + PR_AS, /* /proc//as */ + PR_CTL, /* /proc//ctl */ + PR_STATUS, /* /proc//status */ + PR_LSTATUS, /* /proc//lstatus */ + PR_PSINFO, /* /proc//psinfo */ + PR_LPSINFO, /* /proc//lpsinfo */ + PR_MAP, /* /proc//map */ + PR_RMAP, /* /proc//rmap */ + PR_XMAP, /* /proc//xmap */ + PR_CRED, /* /proc//cred */ + PR_SIGACT, /* /proc//sigact */ + PR_AUXV, /* /proc//auxv */ +#if defined(__i386) || defined(__amd64) + PR_LDT, /* /proc//ldt */ +#endif + PR_ARGV, /* /proc//argv */ + PR_CMDLINE, /* /proc//cmdline */ + PR_USAGE, /* /proc//usage */ + PR_LUSAGE, /* /proc//lusage */ + PR_PAGEDATA, /* /proc//pagedata */ + PR_WATCH, /* /proc//watch */ + PR_CURDIR, /* /proc//cwd */ + PR_ROOTDIR, /* /proc//root */ + PR_FDDIR, /* /proc//fd */ + PR_FD, /* /proc//fd/nn */ + PR_FDINFODIR, /* /proc//fdinfo */ + PR_FDINFO, /* /proc//fdinfo/nn */ + PR_OBJECTDIR, /* /proc//object */ + PR_OBJECT, /* /proc//object/xxx */ + PR_LWPDIR, /* /proc//lwp */ + PR_LWPIDDIR, /* /proc//lwp/ */ + PR_LWPCTL, /* /proc//lwp//lwpctl */ + PR_LWPNAME, /* /proc//lwp//lwpname */ + PR_LWPSTATUS, /* /proc//lwp//lwpstatus */ + PR_LWPSINFO, /* /proc//lwp//lwpsinfo */ + PR_LWPUSAGE, /* /proc//lwp//lwpusage */ + PR_XREGS, /* /proc//lwp//xregs */ + PR_TMPLDIR, /* /proc//lwp//templates */ + PR_TMPL, /* /proc//lwp//templates/ */ + PR_SPYMASTER, /* /proc//lwp//spymaster */ +#if defined(__sparc) + PR_GWINDOWS, /* /proc//lwp//gwindows */ + PR_ASRS, /* /proc//lwp//asrs */ +#endif + PR_PRIV, /* /proc//priv */ + PR_PATHDIR, /* /proc//path */ + PR_PATH, /* /proc//path/xxx */ + PR_CTDIR, /* /proc//contracts */ + PR_CT, /* /proc//contracts/ */ + PR_SECFLAGS, /* /proc//secflags */ + PR_PIDFILE, /* old process file */ + PR_LWPIDFILE, /* old lwp file */ + PR_OPAGEDATA, /* old page data file */ + PR_NFILES /* number of /proc node types */ +} prnodetype_t; + +typedef struct prnode { + vnode_t *pr_next; /* list of all vnodes for process */ + uint_t pr_flags; /* private flags */ + kmutex_t pr_mutex; /* locks pr_files and child pr_flags */ + prnodetype_t pr_type; /* node type */ + mode_t pr_mode; /* file mode */ + ino_t pr_ino; /* node id (for stat(2)) */ + uint_t pr_hatid; /* hat layer id for page data files */ + prcommon_t *pr_common; /* common data structure */ + prcommon_t *pr_pcommon; /* process common data structure */ + vnode_t *pr_parent; /* parent directory */ + vnode_t **pr_files; /* contained files array (directory) */ + uint_t pr_index; /* position within parent */ + vnode_t *pr_pidfile; /* substitute vnode for old /proc */ + vnode_t *pr_realvp; /* real vnode, file in object,fd dirs */ + proc_t *pr_owner; /* the process that created this node */ + vnode_t *pr_vnode; /* pointer to vnode */ + struct contract *pr_contract; /* contract pointer */ + int pr_cttype; /* active template type */ +} prnode_t; + +/* + * Values for pr_flags. + */ +#define PR_INVAL 0x01 /* vnode is invalidated */ +#define PR_ISSELF 0x02 /* vnode is a self-open */ +#define PR_AOUT 0x04 /* vnode is for an a.out path */ +#define PR_OFFMAX 0x08 /* vnode is a large file open */ + +/* + * Conversion macros. + */ +#define VTOP(vp) ((struct prnode *)(vp)->v_data) +#define PTOV(pnp) ((pnp)->pr_vnode) + +/* + * Flags to prlock(). + */ +#define ZNO 0 /* Fail on encountering a zombie process. */ +#define ZYES 1 /* Allow zombies. */ + +/* + * Assign one set to another (possible different sizes). + * + * Assigning to a smaller set causes members to be lost. + * Assigning to a larger set causes extra members to be cleared. + */ +#define prassignset(ap, sp) \ +{ \ + register int _i_ = sizeof (*(ap))/sizeof (uint32_t); \ + while (--_i_ >= 0) \ + ((uint32_t *)(ap))[_i_] = \ + (_i_ >= sizeof (*(sp))/sizeof (uint32_t)) ? \ + 0 : ((uint32_t *)(sp))[_i_]; \ +} + +/* + * Determine whether or not a set (of arbitrary size) is empty. + */ +#define prisempty(sp) \ + setisempty((uint32_t *)(sp), \ + (uint_t)(sizeof (*(sp)) / sizeof (uint32_t))) + +/* + * Resource usage with times as hrtime_t rather than timestruc_t. + * Each member exactly matches the corresponding member in prusage_t. + * This is for convenience of internal computation. + */ +typedef struct prhusage { + id_t pr_lwpid; /* lwp id. 0: process or defunct */ + int pr_count; /* number of contributing lwps */ + hrtime_t pr_tstamp; /* current time stamp */ + hrtime_t pr_create; /* process/lwp creation time stamp */ + hrtime_t pr_term; /* process/lwp termination time stamp */ + hrtime_t pr_rtime; /* total lwp real (elapsed) time */ + hrtime_t pr_utime; /* user level CPU time */ + hrtime_t pr_stime; /* system call CPU time */ + hrtime_t pr_ttime; /* other system trap CPU time */ + hrtime_t pr_tftime; /* text page fault sleep time */ + hrtime_t pr_dftime; /* data page fault sleep time */ + hrtime_t pr_kftime; /* kernel page fault sleep time */ + hrtime_t pr_ltime; /* user lock wait sleep time */ + hrtime_t pr_slptime; /* all other sleep time */ + hrtime_t pr_wtime; /* wait-cpu (latency) time */ + hrtime_t pr_stoptime; /* stopped time */ + hrtime_t filltime[6]; /* filler for future expansion */ + uint64_t pr_minf; /* minor page faults */ + uint64_t pr_majf; /* major page faults */ + uint64_t pr_nswap; /* swaps */ + uint64_t pr_inblk; /* input blocks */ + uint64_t pr_oublk; /* output blocks */ + uint64_t pr_msnd; /* messages sent */ + uint64_t pr_mrcv; /* messages received */ + uint64_t pr_sigs; /* signals received */ + uint64_t pr_vctx; /* voluntary context switches */ + uint64_t pr_ictx; /* involuntary context switches */ + uint64_t pr_sysc; /* system calls */ + uint64_t pr_ioch; /* chars read and written */ + uint64_t filler[10]; /* filler for future expansion */ +} prhusage_t; + +#if defined(_KERNEL) + +/* Exclude system processes from this test */ +#define PROCESS_NOT_32BIT(p) \ + (!((p)->p_flag & SSYS) && (p)->p_as != &kas && \ + (p)->p_model != DATAMODEL_ILP32) + +extern int prnwatch; /* number of supported watchpoints */ +extern int nproc_highbit; /* highbit(v.v_nproc) */ + +extern struct vnodeops *prvnodeops; + +/* + * Generic chained copyout buffers for procfs use. + * In order to prevent procfs from making huge oversize kmem_alloc calls, + * a list of smaller buffers can be concatenated and copied to userspace in + * sequence. + * + * The implementation is opaque. + * + * A user of this will perform the following steps: + * + * list_t listhead; + * struct my *mp; + * + * pr_iol_initlist(&listhead, sizeof (*mp), n); + * while (whatever) { + * mp = pr_iol_newbuf(&listhead, sizeof (*mp)); + * ... + * error = ... + * } + * + * When done, depending on whether copyout() or uiomove() is supposed to + * be used for transferring the buffered data to userspace, call either: + * + * error = pr_iol_copyout_and_free(&listhead, &cmaddr, error); + * + * or else: + * + * error = pr_iol_uiomove_and_free(&listhead, uiop, error); + * + * These two functions will in any case kmem_free() all list items, but + * if an error occurred before they will not perform the copyout/uiomove. + * If copyout/uiomove are done, the passed target address / uio_t + * are updated. The error returned will either be the one passed in, or + * the error that occurred during copyout/uiomove. + */ + +extern void pr_iol_initlist(list_t *head, size_t itemsize, int nitems); +extern void * pr_iol_newbuf(list_t *head, size_t itemsize); +extern int pr_iol_copyout_and_free(list_t *head, caddr_t *tgt, int errin); +extern int pr_iol_uiomove_and_free(list_t *head, uio_t *uiop, int errin); +extern void pr_iol_freelist(list_t *); + +#if defined(_SYSCALL32_IMPL) + +extern int prwritectl32(vnode_t *, struct uio *, cred_t *); +extern void prgetaction32(proc_t *, user_t *, uint_t, struct sigaction32 *); +extern void prcvtusage32(struct prhusage *, prusage32_t *); + +#endif /* _SYSCALL32_IMPL */ + +/* kludge to support old /proc interface */ +#if !defined(_SYS_OLD_PROCFS_H) +extern int prgetmap(proc_t *, int, list_t *); +extern int prgetxmap(proc_t *, list_t *); +#if defined(_SYSCALL32_IMPL) +extern int prgetmap32(proc_t *, int, list_t *); +extern int prgetxmap32(proc_t *, list_t *); +#endif /* _SYSCALL32_IMPL */ +#endif /* !_SYS_OLD_PROCFS_H */ + +extern proc_t *pr_p_lock(prnode_t *); +extern kthread_t *pr_thread(prnode_t *); +extern void pr_stop(prnode_t *); +extern int pr_wait_stop(prnode_t *, time_t); +extern int pr_setrun(prnode_t *, ulong_t); +extern int pr_wait(prcommon_t *, timestruc_t *, int); +extern void pr_wait_die(prnode_t *); +extern int pr_setsig(prnode_t *, siginfo_t *); +extern int pr_kill(prnode_t *, int, cred_t *); +extern int pr_unkill(prnode_t *, int); +extern int pr_nice(proc_t *, int, cred_t *); +extern void pr_setentryexit(proc_t *, sysset_t *, int); +extern int pr_set(proc_t *, long); +extern int pr_unset(proc_t *, long); +extern void pr_sethold(prnode_t *, sigset_t *); +extern file_t *pr_getf(proc_t *, uint_t, short *); +extern void pr_releasef(file_t *); +extern void pr_setfault(proc_t *, fltset_t *); +extern int prusrio(proc_t *, enum uio_rw, struct uio *, int); +extern int prreadargv(proc_t *, char *, size_t, size_t *); +extern int prreadcmdline(proc_t *, char *, size_t, size_t *); +extern int prreadenvv(proc_t *, char *, size_t, size_t *); +extern int prwritectl(vnode_t *, struct uio *, cred_t *); +extern int prlock(prnode_t *, int); +extern void prunmark(proc_t *); +extern void prunlock(prnode_t *); +extern size_t prpdsize(struct as *); +extern int prpdread(proc_t *, uint_t, struct uio *); +extern size_t oprpdsize(struct as *); +extern int oprpdread(struct as *, uint_t, struct uio *); +extern void prgetaction(proc_t *, user_t *, uint_t, struct sigaction *); +extern void prgetusage(kthread_t *, struct prhusage *); +extern void praddusage(kthread_t *, struct prhusage *); +extern void prcvtusage(struct prhusage *, prusage_t *); +extern void prscaleusage(prhusage_t *); +extern kthread_t *prchoose(proc_t *); +extern void allsetrun(proc_t *); +extern int setisempty(uint32_t *, uint_t); +extern int pr_u32tos(uint32_t, char *, int); +extern vnode_t *prlwpnode(prnode_t *, uint_t); +extern prnode_t *prgetnode(vnode_t *, prnodetype_t); +extern void prfreenode(prnode_t *); +extern void pr_object_name(char *, vnode_t *, struct vattr *); +extern int set_watched_area(proc_t *, struct watched_area *); +extern int clear_watched_area(proc_t *, struct watched_area *); +extern void pr_free_watchpoints(proc_t *); +extern proc_t *pr_cancel_watch(prnode_t *); +extern struct seg *break_seg(proc_t *); +extern void prgethold(kthread_t *, sigset_t *); + +/* + * Machine-dependent routines (defined in prmachdep.c). + */ +extern void prgetprregs(klwp_t *, prgregset_t); +extern void prsetprregs(klwp_t *, prgregset_t, int); + +#if defined(_SYSCALL32_IMPL) +extern void prgetprregs32(klwp_t *, prgregset32_t); +extern void prgregset_32ton(klwp_t *, prgregset32_t, prgregset_t); +extern void prgetprfpregs32(klwp_t *, prfpregset32_t *); +extern void prsetprfpregs32(klwp_t *, prfpregset32_t *); +extern size_t prpdsize32(struct as *); +extern int prpdread32(proc_t *, uint_t, struct uio *); +extern size_t oprpdsize32(struct as *); +extern int oprpdread32(struct as *, uint_t, struct uio *); +#endif /* _SYSCALL32_IMPL */ + +extern void prpokethread(kthread_t *t); +extern int prgetrvals(klwp_t *, long *, long *); +extern void prgetprfpregs(klwp_t *, prfpregset_t *); +extern void prsetprfpregs(klwp_t *, prfpregset_t *); +extern int prhasfp(void); +extern caddr_t prgetstackbase(proc_t *); +extern caddr_t prgetpsaddr(proc_t *); +extern int prisstep(klwp_t *); +extern void prsvaddr(klwp_t *, caddr_t); +extern int prfetchinstr(klwp_t *, ulong_t *); +extern ushort_t prgetpctcpu(uint64_t); + +/* + * This set of routines is used by platforms to implement support for the + * 'xregs' or extended registers in /proc. Unlike other registers which + * generally have a well-defined value determined by the ABI that never changes, + * we expect these to change. + * + * An important thing to note is that you'll see we have moved away from a + * traditional version of a fixed size, non-opaque definition of the + * prxregset_t. This is because the size varies and we don't want applications + * to incorrectly bake a real definition in and cause problems where extending + * it becomes very hard to do (ala the prgregset_t and prfregset_t). This is a + * little more work for everyone implementing it, but it does ensure that we are + * generally in better shape. + * + * Here are the semantics of what these are required to do and how the fit + * together: + * + * o prhasx Determine if the process in question supports the + * extended register sets. Note, this is may be a + * process-specific setting due to things like whether or + * not the FPU is enabled or other things. + * + * o prgetxregsize This returns the size of the actual xregs file for a + * given process. This may change between processes because + * not every process may have the same set of extended + * features enabled (e.g. AMX on x86). If xregs is not + * supported then this should return 0. If xregs are + * supported, then returning zero will lead other + * operations to fail. + * + * o prwriteminxreg This is used by the prwritectl() and related worlds to + * determine the minimum amount of data that much be + * present to determine if the actual size of a write is + * valid. If xregs is not supported, then this should + * return B_FALSE. If xregs is supported, this may return 0 + * if no additional information is required to determine + * the appropriate size to copy in. This would be the case + * if the xregs structure is a fixed size. + * + * o prwritesizexreg This is meant to indicate how much data is required to + * be copied in for a given xregs write. The base data will + * already be present from having called prwriteminxreg + * previously. If xregs are not supported this should + * return B_FALSE. + * + * There is a wrinkle in this which is not true of other + * callers. The data that we are given is not guaranteed to + * be aligned in the slightest due to the need to support + * both ILP32 and LP64! + * + * o prgetprxregs This is a request to fill in the xregs data. Right now + * the system guarantees that the buffer size is at least + * the result of the prgetprxregs() call for this process. + * Callers may assume that the process remains locked + * between the two so that the size doesn't change. This + * will not be called for processes where prhasx() return + * false. + * + * o prsetprxregs This is a request to set the xregs data. The only + * assumption that should be made is that the validation of + * the size in prwritesizexreg() has been performed. Users + * can and will potentially try to trick us with invalid + * values. Do not blindly apply the supplied xregs. + * + * If xregs are not supported this should return EINVAL. + * While yes other errnos may make more sense, that is what + * we have always returned in /proc for this case. + */ +extern int prhasx(proc_t *); +extern size_t prgetprxregsize(proc_t *); +extern void prgetprxregs(klwp_t *, prxregset_t *); +extern boolean_t prwriteminxreg(size_t *); +extern boolean_t prwritesizexreg(const void *, size_t *); +extern int prsetprxregs(klwp_t *, prxregset_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROC_PRDATA_H */ diff --git a/illumos-x86_64/usr/include/sys/processor.h b/illumos-x86_64/usr/include/sys/processor.h new file mode 100644 index 00000000..4264a89a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/processor.h @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + * + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2019 Joyent, Inc. + */ + +#ifndef _SYS_PROCESSOR_H +#define _SYS_PROCESSOR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for p_online, processor_info & lgrp system calls. + */ + +/* + * Type for an lgrpid + */ +typedef uint16_t lgrpid_t; + +/* + * Type for processor name (CPU number). + */ +typedef int processorid_t; +typedef int chipid_t; + +/* + * Flags and return values for p_online(2), and pi_state for processor_info(2). + * These flags are *not* for in-kernel examination of CPU states. + * See for appropriate informational functions. + */ +#define P_OFFLINE 0x0001 /* processor is offline, as quiet as possible */ +#define P_ONLINE 0x0002 /* processor is online */ +#define P_STATUS 0x0003 /* value passed to p_online to request status */ +#define P_FAULTED 0x0004 /* processor is offline, in faulted state */ +#define P_POWEROFF 0x0005 /* processor is powered off */ +#define P_NOINTR 0x0006 /* processor is online, but no I/O interrupts */ +#define P_SPARE 0x0007 /* processor is offline, can be reactivated */ +#define P_DISABLED 0x0008 /* processor is explicitly disabled for use */ +#define P_BAD P_FAULTED /* unused but defined by USL */ +#define P_FORCED 0x10000000 /* force processor offline */ + +/* + * String names for processor states defined above. + */ +#define PS_OFFLINE "off-line" +#define PS_ONLINE "on-line" +#define PS_FAULTED "faulted" +#define PS_POWEROFF "powered-off" +#define PS_NOINTR "no-intr" +#define PS_SPARE "spare" +#define PS_DISABLED "disabled" + +/* + * Structure filled in by processor_info(2). This structure + * SHOULD NOT BE MODIFIED. Changes to the structure would + * negate ABI compatibility. + * + * The string fields are guaranteed to contain a NULL. + * + * The pi_fputypes field contains a (possibly empty) comma-separated + * list of floating point identifier strings. + */ +#define PI_TYPELEN 16 /* max size of CPU type string */ +#define PI_FPUTYPE 32 /* max size of FPU types string */ + +typedef struct { + int pi_state; /* processor state, see above */ + char pi_processor_type[PI_TYPELEN]; /* ASCII CPU type */ + char pi_fputypes[PI_FPUTYPE]; /* ASCII FPU types */ + int pi_clock; /* CPU clock freq in MHz */ +} processor_info_t; + +/* + * Binding values for processor_bind(2) + */ +#define PBIND_NONE -1 /* LWP/thread is not bound */ +#define PBIND_QUERY -2 /* don't set, just return the binding */ +#define PBIND_HARD -3 /* prevents offlining CPU (default) */ +#define PBIND_SOFT -4 /* allows offlining CPU */ +#define PBIND_QUERY_TYPE -5 /* Return binding type */ + +/* + * Sentinel values for p_online(2) + */ +#define P_ALL_SIBLINGS (-1) + +/* + * User-level system call interface prototypes + */ +#ifndef _KERNEL + +extern int p_online(processorid_t processorid, int flag); +extern int processor_info(processorid_t processorid, + processor_info_t *infop); +extern int processor_bind(idtype_t idtype, id_t id, + processorid_t processorid, processorid_t *obind); +extern processorid_t getcpuid(void); +extern lgrpid_t gethomelgroup(void); + +#else /* _KERNEL */ + +/* + * Internal interface prototypes + */ +extern int p_online_internal(processorid_t, int, int *); +extern int p_online_internal_locked(processorid_t, int, int *); + +#endif /* !_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROCESSOR_H */ diff --git a/illumos-x86_64/usr/include/sys/procfs.h b/illumos-x86_64/usr/include/sys/procfs.h new file mode 100644 index 00000000..c893394a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/procfs.h @@ -0,0 +1,1005 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2012 DEY Storage Systems, Inc. All rights reserved. + * Copyright 2019 Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_PROCFS_H +#define _SYS_PROCFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This definition is temporary. Structured proc is the preferred API, + * and the older ioctl-based interface will be removed in a future version + * of Solaris. Until then, by default, including will + * provide the older ioctl-based /proc definitions. To get the structured + * /proc definitions, either include or define _STRUCTURED_PROC + * to be 1 before including . + */ +#ifndef _STRUCTURED_PROC +#define _STRUCTURED_PROC 0 +#endif + +#if !defined(_KERNEL) && _STRUCTURED_PROC == 0 + +#include + +#else /* !defined(_KERNEL) && _STRUCTURED_PROC == 0 */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * System call interfaces for /proc. + */ + +/* + * Control codes (long values) for messages written to ctl and lwpctl files. + */ +#define PCNULL 0L /* null request, advance to next message */ +#define PCSTOP 1L /* direct process or lwp to stop and wait for stop */ +#define PCDSTOP 2L /* direct process or lwp to stop */ +#define PCWSTOP 3L /* wait for process or lwp to stop, no timeout */ +#define PCTWSTOP 4L /* wait for stop, with long millisecond timeout arg */ +#define PCRUN 5L /* make process/lwp runnable, w/ long flags argument */ +#define PCCSIG 6L /* clear current signal from lwp */ +#define PCCFAULT 7L /* clear current fault from lwp */ +#define PCSSIG 8L /* set current signal from siginfo_t argument */ +#define PCKILL 9L /* post a signal to process/lwp, long argument */ +#define PCUNKILL 10L /* delete a pending signal from process/lwp, long arg */ +#define PCSHOLD 11L /* set lwp signal mask from sigset_t argument */ +#define PCSTRACE 12L /* set traced signal set from sigset_t argument */ +#define PCSFAULT 13L /* set traced fault set from fltset_t argument */ +#define PCSENTRY 14L /* set traced syscall entry set from sysset_t arg */ +#define PCSEXIT 15L /* set traced syscall exit set from sysset_t arg */ +#define PCSET 16L /* set modes from long argument */ +#define PCUNSET 17L /* unset modes from long argument */ +#define PCSREG 18L /* set lwp general registers from prgregset_t arg */ +#define PCSFPREG 19L /* set lwp floating-point registers from prfpregset_t */ +#define PCSXREG 20L /* set lwp extra registers from prxregset_t arg */ +#define PCNICE 21L /* set nice priority from long argument */ +#define PCSVADDR 22L /* set %pc virtual address from long argument */ +#define PCWATCH 23L /* set/unset watched memory area from prwatch_t arg */ +#define PCAGENT 24L /* create agent lwp with regs from prgregset_t arg */ +#define PCREAD 25L /* read from the address space via priovec_t arg */ +#define PCWRITE 26L /* write to the address space via priovec_t arg */ +#define PCSCRED 27L /* set process credentials from prcred_t argument */ +#define PCSASRS 28L /* set ancillary state registers from asrset_t arg */ +#define PCSPRIV 29L /* set process privileges from prpriv_t argument */ +#define PCSZONE 30L /* set zoneid from zoneid_t argument */ +#define PCSCREDX 31L /* as PCSCRED but with supplemental groups */ +/* + * PCRUN long operand flags. + */ +#define PRCSIG 0x01 /* clear current signal, if any */ +#define PRCFAULT 0x02 /* clear current fault, if any */ +#define PRSTEP 0x04 /* direct the lwp to single-step */ +#define PRSABORT 0x08 /* abort syscall, if in syscall */ +#define PRSTOP 0x10 /* set directed stop request */ + +/* + * lwp status file. /proc//lwp//lwpstatus + */ +#define PRCLSZ 8 /* maximum size of scheduling class name */ +#define PRSYSARGS 8 /* maximum number of syscall arguments */ +typedef struct lwpstatus { + int pr_flags; /* flags (see below) */ + id_t pr_lwpid; /* specific lwp identifier */ + short pr_why; /* reason for lwp stop, if stopped */ + short pr_what; /* more detailed reason */ + short pr_cursig; /* current signal, if any */ + short pr_pad1; + siginfo_t pr_info; /* info associated with signal or fault */ + sigset_t pr_lwppend; /* set of signals pending to the lwp */ + sigset_t pr_lwphold; /* set of signals blocked by the lwp */ + struct sigaction pr_action; /* signal action for current signal */ + stack_t pr_altstack; /* alternate signal stack info */ + uintptr_t pr_oldcontext; /* address of previous ucontext */ + short pr_syscall; /* system call number (if in syscall) */ + short pr_nsysarg; /* number of arguments to this syscall */ + int pr_errno; /* errno for failed syscall, 0 if successful */ + long pr_sysarg[PRSYSARGS]; /* arguments to this syscall */ + long pr_rval1; /* primary syscall return value */ + long pr_rval2; /* second syscall return value, if any */ + char pr_clname[PRCLSZ]; /* scheduling class name */ + timestruc_t pr_tstamp; /* real-time time stamp of stop */ + timestruc_t pr_utime; /* lwp user cpu time */ + timestruc_t pr_stime; /* lwp system cpu time */ + int pr_filler[11 - 2 * sizeof (timestruc_t) / sizeof (int)]; + int pr_errpriv; /* missing privilege */ + uintptr_t pr_ustack; /* address of stack boundary data (stack_t) */ + ulong_t pr_instr; /* current instruction */ + prgregset_t pr_reg; /* general registers */ + prfpregset_t pr_fpreg; /* floating-point registers */ +} lwpstatus_t; + +/* + * process status file. /proc//status + */ +typedef struct pstatus { + int pr_flags; /* flags (see below) */ + int pr_nlwp; /* number of active lwps in the process */ + pid_t pr_pid; /* process id */ + pid_t pr_ppid; /* parent process id */ + pid_t pr_pgid; /* process group id */ + pid_t pr_sid; /* session id */ + id_t pr_aslwpid; /* historical; now always zero */ + id_t pr_agentid; /* lwp id of the /proc agent lwp, if any */ + sigset_t pr_sigpend; /* set of process pending signals */ + uintptr_t pr_brkbase; /* address of the process heap */ + size_t pr_brksize; /* size of the process heap, in bytes */ + uintptr_t pr_stkbase; /* address of the process stack */ + size_t pr_stksize; /* size of the process stack, in bytes */ + timestruc_t pr_utime; /* process user cpu time */ + timestruc_t pr_stime; /* process system cpu time */ + timestruc_t pr_cutime; /* sum of children's user times */ + timestruc_t pr_cstime; /* sum of children's system times */ + sigset_t pr_sigtrace; /* set of traced signals */ + fltset_t pr_flttrace; /* set of traced faults */ + sysset_t pr_sysentry; /* set of system calls traced on entry */ + sysset_t pr_sysexit; /* set of system calls traced on exit */ + char pr_dmodel; /* data model of the process (see below) */ + char pr_pad[3]; + taskid_t pr_taskid; /* task id */ + projid_t pr_projid; /* project id */ + int pr_nzomb; /* number of zombie lwps in the process */ + zoneid_t pr_zoneid; /* zone id */ + int pr_filler[15]; /* reserved for future use */ + lwpstatus_t pr_lwp; /* status of the representative lwp */ +} pstatus_t; + +/* + * pr_flags (same values appear in both pstatus_t and lwpstatus_t pr_flags). + * + * These flags do *not* apply to psinfo_t.pr_flag or lwpsinfo_t.pr_flag + * (which are both deprecated). + */ +/* The following flags apply to the specific or representative lwp */ +#define PR_STOPPED 0x00000001 /* lwp is stopped */ +#define PR_ISTOP 0x00000002 /* lwp is stopped on an event of interest */ +#define PR_DSTOP 0x00000004 /* lwp has a stop directive in effect */ +#define PR_STEP 0x00000008 /* lwp has a single-step directive in effect */ +#define PR_ASLEEP 0x00000010 /* lwp is sleeping in a system call */ +#define PR_PCINVAL 0x00000020 /* contents of pr_instr undefined */ +#define PR_ASLWP 0x00000040 /* obsolete flag; never set */ +#define PR_AGENT 0x00000080 /* this lwp is the /proc agent lwp */ +#define PR_DETACH 0x00000100 /* this is a detached lwp */ +#define PR_DAEMON 0x00000200 /* this is a daemon lwp */ +#define PR_IDLE 0x00000400 /* lwp is a cpu's idle thread */ +/* The following flags apply to the process, not to an individual lwp */ +#define PR_ISSYS 0x00001000 /* this is a system process */ +#define PR_VFORKP 0x00002000 /* process is the parent of a vfork()d child */ +#define PR_ORPHAN 0x00004000 /* process's process group is orphaned */ +#define PR_NOSIGCHLD 0x00008000 /* process will not generate SIGCHLD on exit */ +#define PR_WAITPID 0x00010000 /* only waitid(P_PID, pid) can reap the child */ +/* The following process flags are modes settable by PCSET/PCUNSET */ +#define PR_FORK 0x00100000 /* inherit-on-fork is in effect */ +#define PR_RLC 0x00200000 /* run-on-last-close is in effect */ +#define PR_KLC 0x00400000 /* kill-on-last-close is in effect */ +#define PR_ASYNC 0x00800000 /* asynchronous-stop is in effect */ +#define PR_MSACCT 0x01000000 /* micro-state usage accounting is in effect */ +#define PR_BPTADJ 0x02000000 /* breakpoint trap pc adjustment is in effect */ +#define PR_PTRACE 0x04000000 /* ptrace-compatibility mode is in effect */ +#define PR_MSFORK 0x08000000 /* micro-state accounting inherited on fork */ + +/* + * See for possible values of pr_dmodel. + */ + +/* + * Reasons for stopping (pr_why). + */ +#define PR_REQUESTED 1 +#define PR_SIGNALLED 2 +#define PR_SYSENTRY 3 +#define PR_SYSEXIT 4 +#define PR_JOBCONTROL 5 +#define PR_FAULTED 6 +#define PR_SUSPENDED 7 +#define PR_CHECKPOINT 8 +#define PR_BRAND 9 + +/* + * lwp ps(1) information file. /proc//lwp//lwpsinfo + */ +#define PRFNSZ 16 /* Maximum size of execed filename */ +typedef struct lwpsinfo { + int pr_flag; /* lwp flags (DEPRECATED; do not use) */ + id_t pr_lwpid; /* lwp id */ + uintptr_t pr_addr; /* internal address of lwp */ + uintptr_t pr_wchan; /* wait addr for sleeping lwp */ + char pr_stype; /* synchronization event type */ + char pr_state; /* numeric lwp state */ + char pr_sname; /* printable character for pr_state */ + char pr_nice; /* nice for cpu usage */ + short pr_syscall; /* system call number (if in syscall) */ + char pr_oldpri; /* pre-SVR4, low value is high priority */ + char pr_cpu; /* pre-SVR4, cpu usage for scheduling */ + int pr_pri; /* priority, high value is high priority */ + /* The following percent number is a 16-bit binary */ + /* fraction [0 .. 1] with the binary point to the */ + /* right of the high-order bit (1.0 == 0x8000) */ + ushort_t pr_pctcpu; /* % of recent cpu time used by this lwp */ + ushort_t pr_pad; + timestruc_t pr_start; /* lwp start time, from the epoch */ + timestruc_t pr_time; /* usr+sys cpu time for this lwp */ + char pr_clname[PRCLSZ]; /* scheduling class name */ + char pr_name[PRFNSZ]; /* name of system lwp */ + processorid_t pr_onpro; /* processor which last ran this lwp */ + processorid_t pr_bindpro; /* processor to which lwp is bound */ + psetid_t pr_bindpset; /* processor set to which lwp is bound */ + int pr_lgrp; /* lwp home lgroup */ + int pr_filler[4]; /* reserved for future use */ +} lwpsinfo_t; + +#define PRARGSZ 80 /* number of chars of arguments */ +#define PRMAXARGVLEN 4096 /* max len of /proc/%s/argv */ + +/* + * process ps(1) information file. /proc//psinfo + */ +typedef struct psinfo { + int pr_flag; /* process flags (DEPRECATED; do not use) */ + int pr_nlwp; /* number of active lwps in the process */ + pid_t pr_pid; /* unique process id */ + pid_t pr_ppid; /* process id of parent */ + pid_t pr_pgid; /* pid of process group leader */ + pid_t pr_sid; /* session id */ + uid_t pr_uid; /* real user id */ + uid_t pr_euid; /* effective user id */ + gid_t pr_gid; /* real group id */ + gid_t pr_egid; /* effective group id */ + uintptr_t pr_addr; /* address of process */ + size_t pr_size; /* size of process image in Kbytes */ + size_t pr_rssize; /* resident set size in Kbytes */ + size_t pr_pad1; + dev_t pr_ttydev; /* controlling tty device (or PRNODEV) */ + /* The following percent numbers are 16-bit binary */ + /* fractions [0 .. 1] with the binary point to the */ + /* right of the high-order bit (1.0 == 0x8000) */ + ushort_t pr_pctcpu; /* % of recent cpu time used by all lwps */ + ushort_t pr_pctmem; /* % of system memory used by process */ + timestruc_t pr_start; /* process start time, from the epoch */ + timestruc_t pr_time; /* usr+sys cpu time for this process */ + timestruc_t pr_ctime; /* usr+sys cpu time for reaped children */ + char pr_fname[PRFNSZ]; /* name of execed file */ + char pr_psargs[PRARGSZ]; /* initial characters of arg list */ + int pr_wstat; /* if zombie, the wait() status */ + int pr_argc; /* initial argument count */ + uintptr_t pr_argv; /* address of initial argument vector */ + uintptr_t pr_envp; /* address of initial environment vector */ + char pr_dmodel; /* data model of the process */ + char pr_pad2[3]; + taskid_t pr_taskid; /* task id */ + projid_t pr_projid; /* project id */ + int pr_nzomb; /* number of zombie lwps in the process */ + poolid_t pr_poolid; /* pool id */ + zoneid_t pr_zoneid; /* zone id */ + id_t pr_contract; /* process contract */ + int pr_filler[1]; /* reserved for future use */ + lwpsinfo_t pr_lwp; /* information for representative lwp */ +} psinfo_t; + +#define PRNODEV (dev_t)(-1) /* non-existent device */ + +/* + * Memory-map interface. /proc//map /proc//rmap + */ +#define PRMAPSZ 64 +typedef struct prmap { + uintptr_t pr_vaddr; /* virtual address of mapping */ + size_t pr_size; /* size of mapping in bytes */ + char pr_mapname[PRMAPSZ]; /* name in /proc//object */ + offset_t pr_offset; /* offset into mapped object, if any */ + int pr_mflags; /* protection and attribute flags (see below) */ + int pr_pagesize; /* pagesize (bytes) for this mapping */ + int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */ + int pr_filler[1]; /* filler for future expansion */ +} prmap_t; + +/* + * HAT memory-map interface. /proc//xmap + */ +typedef struct prxmap { + uintptr_t pr_vaddr; /* virtual address of mapping */ + size_t pr_size; /* size of mapping in bytes */ + char pr_mapname[PRMAPSZ]; /* name in /proc//object */ + offset_t pr_offset; /* offset into mapped object, if any */ + int pr_mflags; /* protection and attribute flags (see below) */ + int pr_pagesize; /* pagesize (bytes) for this mapping */ + int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */ + dev_t pr_dev; /* st_dev from stat64() of mapped object, or PRNODEV */ + uint64_t pr_ino; /* st_ino from stat64() of mapped object, if any */ + size_t pr_rss; /* pages of resident memory */ + size_t pr_anon; /* pages of resident anonymous memory */ + size_t pr_locked; /* pages of locked memory */ + size_t pr_pad; /* currently unused */ + uint64_t pr_hatpagesize; /* pagesize of the hat mapping */ +#ifdef _ILP32 + ulong_t pr_filler[6]; /* filler for future expansion */ +#else + ulong_t pr_filler[7]; /* filler for future expansion */ +#endif +} prxmap_t; + + +/* Protection and attribute flags */ +#define MA_READ 0x04 /* readable by the traced process */ +#define MA_WRITE 0x02 /* writable by the traced process */ +#define MA_EXEC 0x01 /* executable by the traced process */ +#define MA_SHARED 0x08 /* changes are shared by mapped object */ +#define MA_ANON 0x40 /* anonymous memory (e.g. /dev/zero) */ +#define MA_ISM 0x80 /* intimate shared mem (shared MMU resources) */ +#define MA_NORESERVE 0x100 /* mapped with MAP_NORESERVE */ +#define MA_SHM 0x200 /* System V shared memory */ +#define MA_RESERVED1 0x400 /* reserved for future use */ + +/* + * These are obsolete and unreliable. + * They are included here only for historical compatibility. + */ +#define MA_BREAK 0x10 /* grown by brk(2) */ +#define MA_STACK 0x20 /* grown automatically on stack faults */ + +/* + * Process credentials. PCSCRED and /proc//cred + */ +typedef struct prcred { + uid_t pr_euid; /* effective user id */ + uid_t pr_ruid; /* real user id */ + uid_t pr_suid; /* saved user id (from exec) */ + gid_t pr_egid; /* effective group id */ + gid_t pr_rgid; /* real group id */ + gid_t pr_sgid; /* saved group id (from exec) */ + int pr_ngroups; /* number of supplementary groups */ + gid_t pr_groups[1]; /* array of supplementary groups */ +} prcred_t; + +/* + * Process privileges. PCSPRIV and /proc//priv + */ +typedef struct prpriv { + uint32_t pr_nsets; /* number of privilege set */ + uint32_t pr_setsize; /* size of privilege set */ + uint32_t pr_infosize; /* size of supplementary data */ + priv_chunk_t pr_sets[1]; /* array of sets */ +} prpriv_t; + +#define PRSECFLAGS_VERSION_1 1 +#define PRSECFLAGS_VERSION_CURRENT PRSECFLAGS_VERSION_1 +typedef struct prsecflags { + uint32_t pr_version; + char pr_pad[4]; + secflagset_t pr_effective; + secflagset_t pr_inherit; + secflagset_t pr_lower; + secflagset_t pr_upper; +} prsecflags_t; + +/* + * Watchpoint interface. PCWATCH and /proc//watch + */ +typedef struct prwatch { + uintptr_t pr_vaddr; /* virtual address of watched area */ + size_t pr_size; /* size of watched area in bytes */ + int pr_wflags; /* watch type flags */ + int pr_pad; +} prwatch_t; + +/* pr_wflags */ +#define WA_READ 0x04 /* trap on read access */ +#define WA_WRITE 0x02 /* trap on write access */ +#define WA_EXEC 0x01 /* trap on execute access */ +#define WA_TRAPAFTER 0x08 /* trap after instruction completes */ + +/* + * PCREAD/PCWRITE I/O interface. + */ +typedef struct priovec { + void *pio_base; /* buffer in controlling process */ + size_t pio_len; /* size of read/write request */ + off_t pio_offset; /* virtual address in target process */ +} priovec_t; + +/* + * Resource usage. /proc//usage /proc//lwp//lwpusage + */ +typedef struct prusage { + id_t pr_lwpid; /* lwp id. 0: process or defunct */ + int pr_count; /* number of contributing lwps */ + timestruc_t pr_tstamp; /* current time stamp */ + timestruc_t pr_create; /* process/lwp creation time stamp */ + timestruc_t pr_term; /* process/lwp termination time stamp */ + timestruc_t pr_rtime; /* total lwp real (elapsed) time */ + timestruc_t pr_utime; /* user level cpu time */ + timestruc_t pr_stime; /* system call cpu time */ + timestruc_t pr_ttime; /* other system trap cpu time */ + timestruc_t pr_tftime; /* text page fault sleep time */ + timestruc_t pr_dftime; /* data page fault sleep time */ + timestruc_t pr_kftime; /* kernel page fault sleep time */ + timestruc_t pr_ltime; /* user lock wait sleep time */ + timestruc_t pr_slptime; /* all other sleep time */ + timestruc_t pr_wtime; /* wait-cpu (latency) time */ + timestruc_t pr_stoptime; /* stopped time */ + timestruc_t filltime[6]; /* filler for future expansion */ + ulong_t pr_minf; /* minor page faults */ + ulong_t pr_majf; /* major page faults */ + ulong_t pr_nswap; /* swaps */ + ulong_t pr_inblk; /* input blocks */ + ulong_t pr_oublk; /* output blocks */ + ulong_t pr_msnd; /* messages sent */ + ulong_t pr_mrcv; /* messages received */ + ulong_t pr_sigs; /* signals received */ + ulong_t pr_vctx; /* voluntary context switches */ + ulong_t pr_ictx; /* involuntary context switches */ + ulong_t pr_sysc; /* system calls */ + ulong_t pr_ioch; /* chars read and written */ + ulong_t filler[10]; /* filler for future expansion */ +} prusage_t; + +/* + * Page data file. /proc//pagedata + */ + +/* page data file header */ +typedef struct prpageheader { + timestruc_t pr_tstamp; /* real time stamp */ + long pr_nmap; /* number of address space mappings */ + long pr_npage; /* total number of pages */ +} prpageheader_t; + +/* page data mapping header */ +typedef struct prasmap { + uintptr_t pr_vaddr; /* virtual address of mapping */ + size_t pr_npage; /* number of pages in mapping */ + char pr_mapname[PRMAPSZ]; /* name in /proc//object */ + offset_t pr_offset; /* offset into mapped object, if any */ + int pr_mflags; /* protection and attribute flags */ + int pr_pagesize; /* pagesize (bytes) for this mapping */ + int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */ + int pr_filler[1]; /* filler for future expansion */ +} prasmap_t; + +/* + * pr_npage bytes (plus 0-7 null bytes to round up to an 8-byte boundary) + * follow each mapping header, each containing zero or more of these flags. + */ +#define PG_REFERENCED 0x02 /* page referenced since last read */ +#define PG_MODIFIED 0x01 /* page modified since last read */ +#define PG_HWMAPPED 0x04 /* page is present and mapped */ + +/* + * Open file information; used in core files. Note that we'd like to use + * the stat or stat64 structure, but both of these structures are unfortunately + * not consistent between 32 and 64 bit modes. To keep our lives simpler, we + * just define our own structure with types that are not sensitive to this + * difference. Also, it turns out that pfiles omits a lot of info from the + * struct stat (e.g. times, device sizes, etc.) so we don't bother adding those + * here. + */ +typedef struct prfdinfo_core { + int pr_fd; + mode_t pr_mode; + + uid_t pr_uid; + gid_t pr_gid; + + major_t pr_major; /* think stat.st_dev */ + minor_t pr_minor; + + major_t pr_rmajor; /* think stat.st_rdev */ + minor_t pr_rminor; + + ino64_t pr_ino; + off64_t pr_offset; + off64_t pr_size; + + int pr_fileflags; /* fcntl(F_GETXFL), etc */ + int pr_fdflags; /* fcntl(F_GETFD), etc. */ + + char pr_path[MAXPATHLEN]; +} prfdinfo_core_t; + +/* + * Open file information; used in /proc//fdinfo/nn files. + * This differs from prfdinfo_core_t above as it exposes more information + * and is variable length, with the last element, pr_misc, pointing to an + * array of miscellaneous data items. + */ + +typedef struct prfdinfo { + int pr_fd; /* file descriptor number */ + mode_t pr_mode; /* (see st_mode in stat(2)) */ + ino64_t pr_ino; /* inode number */ + off64_t pr_size; /* file size */ + off64_t pr_offset; /* current offset of file descriptor */ + uid_t pr_uid; /* owner's user id */ + gid_t pr_gid; /* owner's group id */ + major_t pr_major; /* major number of device */ + minor_t pr_minor; /* minor number of device */ + major_t pr_rmajor; /* major number (if special file) */ + minor_t pr_rminor; /* minor number (if special file) */ + int pr_fileflags; /* (see F_GETXFL in fcntl(2)) */ + int pr_fdflags; /* (see F_GETFD in fcntl(2)) */ + short pr_locktype; /* (see F_GETLK in fcntl(2)) */ + pid_t pr_lockpid; /* process holding file lock */ + /* (see F_GETLK) */ + int pr_locksysid; /* sysid of locking process */ + /* (see F_GETLK) */ + pid_t pr_peerpid; /* peer process (socket, door) */ + int pr_filler[25]; /* reserved for future use */ + char pr_peername[PRFNSZ]; /* peer process name */ +#if __STDC_VERSION__ >= 199901L + uint8_t pr_misc[]; /* self describing structures */ +#else + uint8_t pr_misc[1]; /* self describing structures */ +#endif +} prfdinfo_t; + +/* pr_misc item size is rounded up to maintain alignment */ +#define PRFDINFO_ROUNDUP(num) P2ROUNDUP((num), 4) + +typedef struct pr_misc_header { + uint_t pr_misc_size; + uint_t pr_misc_type; +} pr_misc_header_t; + +/* + * The gaps in this enumeration are present to maintain compatibility with + * the values used in Solaris. Any future illumos-specific additions to this + * list should use the PR_ILLUMOS_ prefix, be placed after PR_MISC_TYPES_MAX + * and start from a number sufficiently large enough to leave space for any + * future additions in Solaris. + */ + +enum PR_MISC_TYPES { + PR_PATHNAME, + PR_SOCKETNAME, + PR_PEERSOCKNAME, + PR_SOCKOPTS_BOOL_OPTS, + PR_SOCKOPT_LINGER, + PR_SOCKOPT_SNDBUF, + PR_SOCKOPT_RCVBUF, + PR_SOCKOPT_IP_NEXTHOP, + PR_SOCKOPT_IPV6_NEXTHOP, + PR_SOCKOPT_TYPE, + PR_SOCKOPT_TCP_CONGESTION = 11, + PR_SOCKFILTERS_PRIV = 14, + PR_MISC_TYPES_MAX +}; + +typedef struct prsockopts_bool_opts { + unsigned int prsock_bool_opts; +} prsockopts_bool_opts_t; + +#define PR_SO_DEBUG (1 << 0) +#define PR_SO_REUSEADDR (1 << 1) +#define PR_SO_REUSEPORT (1 << 2) +#define PR_SO_KEEPALIVE (1 << 3) +#define PR_SO_DONTROUTE (1 << 4) +#define PR_SO_BROADCAST (1 << 5) +#define PR_SO_OOBINLINE (1 << 7) +#define PR_SO_DGRAM_ERRIND (1 << 8) +#define PR_SO_ALLZONES (1 << 9) +#define PR_SO_MAC_EXEMPT (1 << 10) +#define PR_SO_EXCLBIND (1 << 11) +#define PR_SO_PASSIVE_CONNECT (1 << 12) +#define PR_SO_ACCEPTCONN (1 << 13) +#define PR_UDP_NAT_T_ENDPOINT (1 << 14) +#define PR_SO_VRRP (1 << 15) +#define PR_SO_MAC_IMPLICIT (1 << 16) + +/* + * Representation of LWP name in core files. In /proc, we use a simple char + * array, but in core files we need to make it easy to correlate the note back + * to the right LWP. For simplicity, we'll use 32/64 consistent types. + */ +typedef struct prlwpname { + uint64_t pr_lwpid; + char pr_lwpname[THREAD_NAME_MAX]; +} prlwpname_t; + +/* + * Header for /proc//lstatus /proc//lpsinfo /proc//lusage + */ +typedef struct prheader { + long pr_nent; /* number of entries */ + long pr_entsize; /* size of each entry, in bytes */ +} prheader_t; + +/* + * Macros for manipulating sets of flags. + * sp must be a pointer to one of sigset_t, fltset_t, or sysset_t. + * flag must be a member of the enumeration corresponding to *sp. + */ + +/* turn on all flags in set */ +#define prfillset(sp) \ + { register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \ + while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0xFFFFFFFF; } + +/* turn off all flags in set */ +#define premptyset(sp) \ + { register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \ + while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0; } + +/* turn on specified flag in set */ +#define praddset(sp, flag) \ + ((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \ + (((uint32_t *)(sp))[((flag)-1)/32] |= (1U<<(((flag)-1)%32))) : 0)) + +/* turn off specified flag in set */ +#define prdelset(sp, flag) \ + ((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \ + (((uint32_t *)(sp))[((flag)-1)/32] &= ~(1U<<(((flag)-1)%32))) : 0)) + +/* query: != 0 iff flag is turned on in set */ +#define prismember(sp, flag) \ + (((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) && \ + (((uint32_t *)(sp))[((flag)-1)/32] & (1U<<(((flag)-1)%32)))) + +/* + * Core file upanic NT_UPANIC structure. + */ +#define PRUPANIC_VERSION_1 1 +#define PRUPANIC_VERSION_CURRENT PRUPANIC_VERSION_1 +#define PRUPANIC_FLAG_MSG_VALID 0x01 +#define PRUPANIC_FLAG_MSG_ERROR 0x02 +#define PRUPANIC_FLAG_MSG_TRUNC 0x04 +#define PRUPANIC_BUFLEN 1024 +typedef struct prupanic { + uint32_t pru_version; + uint32_t pru_flags; + uint8_t pru_data[PRUPANIC_BUFLEN]; +} prupanic_t; + +/* + * Core file NT_CWD structure. + */ +typedef struct { + uint64_t prcwd_fsid; + char prcwd_fsname[_ST_FSTYPSZ]; + char prcwd_mntpt[MAXPATHLEN]; + char prcwd_mntspec[MAXPATHLEN]; + char prcwd_cwd[MAXPATHLEN]; +} prcwd_t; + +#if defined(_SYSCALL32) + +/* + * dev32_t version of PRNODEV + */ +#define PRNODEV32 (dev32_t)(-1) + +/* + * Kernel view of /proc structures for _ILP32 programs. + */ + +/* + * _ILP32 lwp status file. /proc//lwp//lwpstatus + */ +typedef struct lwpstatus32 { + int pr_flags; /* flags */ + id32_t pr_lwpid; /* specific lwp identifier */ + short pr_why; /* reason for lwp stop, if stopped */ + short pr_what; /* more detailed reason */ + short pr_cursig; /* current signal, if any */ + short pr_pad1; + siginfo32_t pr_info; /* info associated with signal or fault */ + sigset_t pr_lwppend; /* set of signals pending to the lwp */ + sigset_t pr_lwphold; /* set of signals blocked by the lwp */ + struct sigaction32 pr_action; /* signal action for current signal */ + stack32_t pr_altstack; /* alternate signal stack info */ + caddr32_t pr_oldcontext; /* address of previous ucontext */ + short pr_syscall; /* system call number (if in syscall) */ + short pr_nsysarg; /* number of arguments to this syscall */ + int pr_errno; /* errno for failed syscall, 0 if successful */ + int32_t pr_sysarg[PRSYSARGS]; /* arguments to this syscall */ + int32_t pr_rval1; /* primary syscall return value */ + int32_t pr_rval2; /* second syscall return value, if any */ + char pr_clname[PRCLSZ]; /* scheduling class name */ + timestruc32_t pr_tstamp; /* real-time time stamp of stop */ + timestruc32_t pr_utime; /* lwp user cpu time */ + timestruc32_t pr_stime; /* lwp system cpu time */ + int pr_filler[11 - 2 * sizeof (timestruc32_t) / sizeof (int)]; + int pr_errpriv; /* missing privilege */ + caddr32_t pr_ustack; /* address of stack boundary data (stack32_t) */ + uint32_t pr_instr; /* current instruction */ + prgregset32_t pr_reg; /* general registers */ + prfpregset32_t pr_fpreg; /* floating-point registers */ +} lwpstatus32_t; + +/* + * _ILP32 process status file. /proc//status + */ +typedef struct pstatus32 { + int pr_flags; /* flags */ + int pr_nlwp; /* number of active lwps in the process */ + pid32_t pr_pid; /* process id */ + pid32_t pr_ppid; /* parent process id */ + pid32_t pr_pgid; /* process group id */ + pid32_t pr_sid; /* session id */ + id32_t pr_aslwpid; /* historical; now always zero */ + id32_t pr_agentid; /* lwp id of the /proc agent lwp, if any */ + sigset_t pr_sigpend; /* set of process pending signals */ + caddr32_t pr_brkbase; /* address of the process heap */ + size32_t pr_brksize; /* size of the process heap, in bytes */ + caddr32_t pr_stkbase; /* address of the process stack */ + size32_t pr_stksize; /* size of the process stack, in bytes */ + timestruc32_t pr_utime; /* process user cpu time */ + timestruc32_t pr_stime; /* process system cpu time */ + timestruc32_t pr_cutime; /* sum of children's user times */ + timestruc32_t pr_cstime; /* sum of children's system times */ + sigset_t pr_sigtrace; /* set of traced signals */ + fltset_t pr_flttrace; /* set of traced faults */ + sysset_t pr_sysentry; /* set of system calls traced on entry */ + sysset_t pr_sysexit; /* set of system calls traced on exit */ + char pr_dmodel; /* data model of the process */ + char pr_pad[3]; + id32_t pr_taskid; /* task id */ + id32_t pr_projid; /* project id */ + int pr_nzomb; /* number of zombie lwps in the process */ + id32_t pr_zoneid; /* zone id */ + int pr_filler[15]; /* reserved for future use */ + lwpstatus32_t pr_lwp; /* status of the representative lwp */ +} pstatus32_t; + +/* + * _ILP32 lwp ps(1) information file. /proc//lwp//lwpsinfo + */ +typedef struct lwpsinfo32 { + int pr_flag; /* lwp flags */ + id32_t pr_lwpid; /* lwp id */ + caddr32_t pr_addr; /* internal address of lwp */ + caddr32_t pr_wchan; /* wait addr for sleeping lwp */ + char pr_stype; /* synchronization event type */ + char pr_state; /* numeric lwp state */ + char pr_sname; /* printable character for pr_state */ + char pr_nice; /* nice for cpu usage */ + short pr_syscall; /* system call number (if in syscall) */ + char pr_oldpri; /* pre-SVR4, low value is high priority */ + char pr_cpu; /* pre-SVR4, cpu usage for scheduling */ + int pr_pri; /* priority, high value is high priority */ + /* The following percent number is a 16-bit binary */ + /* fraction [0 .. 1] with the binary point to the */ + /* right of the high-order bit (1.0 == 0x8000) */ + ushort_t pr_pctcpu; /* % of recent cpu time used by this lwp */ + ushort_t pr_pad; + timestruc32_t pr_start; /* lwp start time, from the epoch */ + timestruc32_t pr_time; /* usr+sys cpu time for this lwp */ + char pr_clname[PRCLSZ]; /* scheduling class name */ + char pr_name[PRFNSZ]; /* name of system lwp */ + processorid_t pr_onpro; /* processor which last ran this lwp */ + processorid_t pr_bindpro; /* processor to which lwp is bound */ + psetid_t pr_bindpset; /* processor set to which lwp is bound */ + int pr_lgrp; /* lwp home lgroup */ + int pr_filler[4]; /* reserved for future use */ +} lwpsinfo32_t; + +/* + * _ILP32 process ps(1) information file. /proc//psinfo + */ +typedef struct psinfo32 { + int pr_flag; /* process flags */ + int pr_nlwp; /* number of active lwps in the process */ + pid32_t pr_pid; /* unique process id */ + pid32_t pr_ppid; /* process id of parent */ + pid32_t pr_pgid; /* pid of process group leader */ + pid32_t pr_sid; /* session id */ + uid32_t pr_uid; /* real user id */ + uid32_t pr_euid; /* effective user id */ + gid32_t pr_gid; /* real group id */ + gid32_t pr_egid; /* effective group id */ + caddr32_t pr_addr; /* address of process */ + size32_t pr_size; /* size of process image in Kbytes */ + size32_t pr_rssize; /* resident set size in Kbytes */ + size32_t pr_pad1; + dev32_t pr_ttydev; /* controlling tty device (or PRNODEV) */ + ushort_t pr_pctcpu; /* % of recent cpu time used by all lwps */ + ushort_t pr_pctmem; /* % of system memory used by process */ + timestruc32_t pr_start; /* process start time, from the epoch */ + timestruc32_t pr_time; /* usr+sys cpu time for this process */ + timestruc32_t pr_ctime; /* usr+sys cpu time for reaped children */ + char pr_fname[PRFNSZ]; /* name of execed file */ + char pr_psargs[PRARGSZ]; /* initial characters of arg list */ + int pr_wstat; /* if zombie, the wait() status */ + int pr_argc; /* initial argument count */ + caddr32_t pr_argv; /* address of initial argument vector */ + caddr32_t pr_envp; /* address of initial environment vector */ + char pr_dmodel; /* data model of the process */ + char pr_pad2[3]; + id32_t pr_taskid; /* task id */ + id32_t pr_projid; /* project id */ + int pr_nzomb; /* number of zombie lwps in the process */ + id32_t pr_poolid; /* pool id */ + id32_t pr_zoneid; /* zone id */ + id32_t pr_contract; /* process contract */ + int pr_filler[1]; /* reserved for future use */ + lwpsinfo32_t pr_lwp; /* information for representative lwp */ +} psinfo32_t; + +/* + * _ILP32 Memory-management interface. /proc//map /proc//rmap + */ +typedef struct prmap32 { + caddr32_t pr_vaddr; /* virtual address of mapping */ + size32_t pr_size; /* size of mapping in bytes */ + char pr_mapname[64]; /* name in /proc//object */ + offset_t pr_offset; /* offset into mapped object, if any */ + int pr_mflags; /* protection and attribute flags */ + int pr_pagesize; /* pagesize (bytes) for this mapping */ + int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */ + int pr_filler[1]; /* filler for future expansion */ +} prmap32_t; + +/* + * _ILP32 HAT memory-map interface. /proc//xmap + */ +typedef struct prxmap32 { + caddr32_t pr_vaddr; /* virtual address of mapping */ + size32_t pr_size; /* size of mapping in bytes */ + char pr_mapname[PRMAPSZ]; /* name in /proc//object */ + offset_t pr_offset; /* offset into mapped object, if any */ + int pr_mflags; /* protection and attribute flags (see below) */ + int pr_pagesize; /* pagesize (bytes) for this mapping */ + int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */ + dev32_t pr_dev; /* st_dev from stat64() of mapped object, or PRNODEV */ + uint64_t pr_ino; /* st_ino from stat64() of mapped object, if any */ + uint32_t pr_rss; /* pages of resident memory */ + uint32_t pr_anon; /* pages of resident anonymous memory */ + uint32_t pr_locked; /* pages of locked memory */ + uint32_t pr_pad; /* currently unused */ + uint64_t pr_hatpagesize; /* pagesize of the hat mapping */ + uint32_t pr_filler[6]; /* filler for future expansion */ +} prxmap32_t; + +/* + * _ILP32 Process credentials. PCSCRED and /proc//cred + */ +typedef struct prcred32 { + uid32_t pr_euid; /* effective user id */ + uid32_t pr_ruid; /* real user id */ + uid32_t pr_suid; /* saved user id (from exec) */ + gid32_t pr_egid; /* effective group id */ + gid32_t pr_rgid; /* real group id */ + gid32_t pr_sgid; /* saved group id (from exec) */ + int pr_ngroups; /* number of supplementary groups */ + gid32_t pr_groups[1]; /* array of supplementary groups */ +} prcred32_t; + +/* + * _ILP32 Watchpoint interface. PCWATCH and /proc//watch + */ +typedef struct prwatch32 { + caddr32_t pr_vaddr; /* virtual address of watched area */ + size32_t pr_size; /* size of watched area in bytes */ + int pr_wflags; /* watch type flags */ + int pr_pad; +} prwatch32_t; + +/* + * _ILP32 PCREAD/PCWRITE I/O interface. + */ +typedef struct priovec32 { + caddr32_t pio_base; /* buffer in controlling process */ + size32_t pio_len; /* size of read/write request */ + off32_t pio_offset; /* virtual address in target process */ +} priovec32_t; + +/* + * _ILP32 Resource usage. /proc//usage /proc//lwp//lwpusage + */ +typedef struct prusage32 { + id32_t pr_lwpid; /* lwp id. 0: process or defunct */ + int32_t pr_count; /* number of contributing lwps */ + timestruc32_t pr_tstamp; /* current time stamp */ + timestruc32_t pr_create; /* process/lwp creation time stamp */ + timestruc32_t pr_term; /* process/lwp termination time stamp */ + timestruc32_t pr_rtime; /* total lwp real (elapsed) time */ + timestruc32_t pr_utime; /* user level cpu time */ + timestruc32_t pr_stime; /* system call cpu time */ + timestruc32_t pr_ttime; /* other system trap cpu time */ + timestruc32_t pr_tftime; /* text page fault sleep time */ + timestruc32_t pr_dftime; /* data page fault sleep time */ + timestruc32_t pr_kftime; /* kernel page fault sleep time */ + timestruc32_t pr_ltime; /* user lock wait sleep time */ + timestruc32_t pr_slptime; /* all other sleep time */ + timestruc32_t pr_wtime; /* wait-cpu (latency) time */ + timestruc32_t pr_stoptime; /* stopped time */ + timestruc32_t filltime[6]; /* filler for future expansion */ + uint32_t pr_minf; /* minor page faults */ + uint32_t pr_majf; /* major page faults */ + uint32_t pr_nswap; /* swaps */ + uint32_t pr_inblk; /* input blocks */ + uint32_t pr_oublk; /* output blocks */ + uint32_t pr_msnd; /* messages sent */ + uint32_t pr_mrcv; /* messages received */ + uint32_t pr_sigs; /* signals received */ + uint32_t pr_vctx; /* voluntary context switches */ + uint32_t pr_ictx; /* involuntary context switches */ + uint32_t pr_sysc; /* system calls */ + uint32_t pr_ioch; /* chars read and written */ + uint32_t filler[10]; /* filler for future expansion */ +} prusage32_t; + +/* + * _ILP32 Page data file. /proc//pagedata + */ + +/* _ILP32 page data file header */ +typedef struct prpageheader32 { + timestruc32_t pr_tstamp; /* real time stamp */ + int32_t pr_nmap; /* number of address space mappings */ + int32_t pr_npage; /* total number of pages */ +} prpageheader32_t; + +/* _ILP32 page data mapping header */ +typedef struct prasmap32 { + caddr32_t pr_vaddr; /* virtual address of mapping */ + size32_t pr_npage; /* number of pages in mapping */ + char pr_mapname[64]; /* name in /proc//object */ + offset_t pr_offset; /* offset into mapped object, if any */ + int pr_mflags; /* protection and attribute flags */ + int pr_pagesize; /* pagesize (bytes) for this mapping */ + int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */ + int pr_filler[1]; /* filler for future expansion */ +} prasmap32_t; + +/* + * _ILP32 Header for /proc//lstatus /proc//lpsinfo /proc//lusage + */ +typedef struct prheader32 { + int32_t pr_nent; /* number of entries */ + int32_t pr_entsize; /* size of each entry, in bytes */ +} prheader32_t; + +#endif /* _SYSCALL32 */ + +#endif /* !_KERNEL && _STRUCTURED_PROC == 0 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROCFS_H */ diff --git a/illumos-x86_64/usr/include/sys/procfs_isa.h b/illumos-x86_64/usr/include/sys/procfs_isa.h new file mode 100644 index 00000000..dc9d5caf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/procfs_isa.h @@ -0,0 +1,258 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_PROCFS_ISA_H +#define _SYS_PROCFS_ISA_H + +/* + * Instruction Set Architecture specific component of + * i386 version + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Possible values of pr_dmodel. + * This isn't isa-specific, but it needs to be defined here for other reasons. + */ +#define PR_MODEL_UNKNOWN 0 +#define PR_MODEL_ILP32 1 /* process data model is ILP32 */ +#define PR_MODEL_LP64 2 /* process data model is LP64 */ + +/* + * To determine whether application is running native. + */ +#if defined(_LP64) +#define PR_MODEL_NATIVE PR_MODEL_LP64 +#elif defined(_ILP32) +#define PR_MODEL_NATIVE PR_MODEL_ILP32 +#else +#error "No DATAMODEL_NATIVE specified" +#endif /* _LP64 || _ILP32 */ + +#if defined(__i386) || defined(__amd64) +/* + * Holds one i386 or amd64 instruction + */ +typedef uchar_t instr_t; +#endif + +#define NPRGREG _NGREG +#define prgreg_t greg_t +#define prgregset_t gregset_t +#define prfpregset _fpu +#define prfpregset_t fpregset_t + +#if defined(_SYSCALL32) +/* + * kernel view of the ia32 register set + */ +typedef uchar_t instr32_t; +#if defined(__amd64) +#define NPRGREG32 _NGREG32 +#define prgreg32_t greg32_t +#define prgregset32_t gregset32_t +#define prfpregset32 fpu32 +#define prfpregset32_t fpregset32_t +#else +#define NPRGREG32 _NGREG +#define prgreg32_t greg_t +#define prgregset32_t gregset_t +#define prfpregset32 _fpu +#define prfpregset32_t fpregset_t +#endif +#endif /* _SYSCALL32 */ + +#if defined(__amd64) +/* + * The following defines are for portability (see ). + */ +#define R_PC REG_RIP +#define R_PS REG_RFL +#define R_SP REG_RSP +#define R_FP REG_RBP +#define R_R0 REG_RAX +#define R_R1 REG_RDX +#elif defined(__i386) +/* + * The following defines are for portability (see ). + */ +#define R_PC EIP +#define R_PS EFL +#define R_SP UESP +#define R_FP EBP +#define R_R0 EAX +#define R_R1 EDX +#endif + +/* + * The x86 xregs structure is a blob of data that contains a header with several + * descriptors that describe the region of additional data that corresponds to + * it. Effectively this looks like: + * + * 0 +-----------------+ + * | prxregset_hdr_t | + * +-----------------+ + * | Info 0 (XCR) |-------+ + * +-----------------+ | + * | Info 1 (XSAVE) |----------+ + * +-----------------+ | | + * ... | | + * +-----------------+ | | + * | Info n (Hi ZMM) |-------------+ + * +-----------------+ | | | + * +-----------------+ | | | + * | prxregset_xcr_t |<------+ | | + * +-----------------+ | | + * +-------------------+ | | + * | prxregset_xsave_t |<-------+ | + * | | | + * | XMM + xsave | | + * +-------------------+ | + * ... | + * +---------------------+ | + * | prxregset_hi_zmm_t |<--------+ + * | | + * | 1 KiB %zmm16-%zmm31 | + * +---------------------+ + * + * The actual structure size will vary based on the CPU features present. For + * more information, see proc(5). When adding structures, please make sure all + * structures are multiples of 16 bytes (0x10) so as to ensure alignment. + */ +typedef struct prxregset prxregset_t; + +#define PRX_INFO_XCR 0x01 +#define PRX_INFO_XSAVE 0x02 +#define PRX_INFO_YMM 0x03 +#define PRX_INFO_OPMASK 0x04 +#define PRX_INFO_ZMM 0x05 +#define PRX_INFO_HI_ZMM 0x06 + +typedef struct prxregset_info { + uint32_t pri_type; + uint32_t pri_flags; + uint32_t pri_size; + uint32_t pri_offset; +} prxregset_info_t; + +#define PR_TYPE_XSAVE 0x01 + +typedef struct prxregset_hdr { + uint32_t pr_type; + uint32_t pr_size; + uint32_t pr_flags; + uint32_t pr_pad[4]; + uint32_t pr_ninfo; +#if defined(_STDC_C99) || defined(__C99FEATURES__) + prxregset_info_t pr_info[]; +#endif +} prxregset_hdr_t; + +typedef struct prxregset_xcr { + uint64_t prx_xcr_xcr0; + uint64_t prx_xcr_xfd; + uint64_t prx_xcr_pad[2]; +} prxregset_xcr_t; + +typedef struct prxregset_xsave { + uint16_t prx_fx_fcw; + uint16_t prx_fx_fsw; + uint16_t prx_fx_fctw; /* compressed tag word */ + uint16_t prx_fx_fop; +#if defined(__amd64) + uint64_t prx_fx_rip; + uint64_t prx_fx_rdp; +#else + uint32_t prx_fx_eip; + uint16_t prx_fx_cs; + uint16_t __prx_fx_ign0; + uint32_t prx_fx_dp; + uint16_t prx_fx_ds; + uint16_t __prx_fx_ign1; +#endif + uint32_t prx_fx_mxcsr; + uint32_t prx_fx_mxcsr_mask; + union { + uint16_t prx_fpr_16[5]; /* 80-bits of x87 state */ + u_longlong_t prx_fpr_mmx; /* 64-bit mmx register */ + uint32_t _prx__fpr_pad[4]; /* (pad out to 128-bits) */ + } fx_st[8]; +#if defined(__amd64) + upad128_t prx_fx_xmm[16]; /* 128-bit registers */ + upad128_t __prx_fx_ign2[6]; +#else + upad128_t prx_fx_xmm[8]; /* 128-bit registers */ + upad128_t __prx_fx_ign2[14]; +#endif + uint64_t prx_xsh_xstate_bv; + uint64_t prx_xsh_xcomp_bv; + uint64_t prx_xsh_reserved[6]; +} prxregset_xsave_t; + +typedef struct prxregset_ymm { +#if defined(__amd64) + upad128_t prx_ymm[16]; +#else + upad128_t prx_ymm[8]; + upad128_t prx_rsvd[8]; +#endif +} prxregset_ymm_t; + +typedef struct prxregset_opmask { + uint64_t prx_opmask[8]; +} prxregset_opmask_t; + +typedef struct prxregset_zmm { +#if defined(__amd64) + upad256_t prx_zmm[16]; +#else + upad256_t prx_zmm[8]; + upad256_t prx_rsvd[8]; +#endif +} prxregset_zmm_t; + +typedef struct prxregset_hi_zmm { +#if defined(__amd64) + upad512_t prx_hi_zmm[16]; +#else + upad512_t prx_rsvd[16]; +#endif +} prxregset_hi_zmm_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROCFS_ISA_H */ diff --git a/illumos-x86_64/usr/include/sys/procset.h b/illumos-x86_64/usr/include/sys/procset.h new file mode 100644 index 00000000..faf23339 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/procset.h @@ -0,0 +1,158 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_PROCSET_H +#define _SYS_PROCSET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * This file defines the data needed to specify a set of + * processes. These types are used by the sigsend, sigsendset, + * priocntl, priocntlset, waitid, evexit, and evexitset system + * calls. + */ +#define P_INITPID 1 +#define P_INITUID 0 +#define P_INITPGID 0 + + +/* + * The following defines the values for an identifier type. It + * specifies the interpretation of an id value. An idtype and + * id together define a simple set of processes. + */ +typedef enum +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + idtype /* pollutes XPG4.2 namespace */ +#endif + { + P_PID, /* A process identifier. */ + P_PPID, /* A parent process identifier. */ + P_PGID, /* A process group (job control group) */ + /* identifier. */ + P_SID, /* A session identifier. */ + P_CID, /* A scheduling class identifier. */ + P_UID, /* A user identifier. */ + P_GID, /* A group identifier. */ + P_ALL, /* All processes. */ + P_LWPID, /* An LWP identifier. */ + P_TASKID, /* A task identifier. */ + P_PROJID, /* A project identifier. */ + P_POOLID, /* A pool identifier. */ + P_ZONEID, /* A zone identifier. */ + P_CTID, /* A (process) contract identifier. */ + P_CPUID, /* CPU identifier. */ + P_PSETID /* Processor set identifier */ +} idtype_t; + + +/* + * The following defines the operations which can be performed to + * combine two simple sets of processes to form another set of + * processes. + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +typedef enum idop { + POP_DIFF, /* Set difference. The processes which */ + /* are in the left operand set and not */ + /* in the right operand set. */ + POP_AND, /* Set disjunction. The processes */ + /* which are in both the left and right */ + /* operand sets. */ + POP_OR, /* Set conjunction. The processes */ + /* which are in either the left or the */ + /* right operand sets (or both). */ + POP_XOR /* Set exclusive or. The processes */ + /* which are in either the left or */ + /* right operand sets but not in both. */ +} idop_t; + + +/* + * The following structure is used to define a set of processes. + * The set is defined in terms of two simple sets of processes + * and an operator which operates on these two operand sets. + */ +typedef struct procset { + idop_t p_op; /* The operator connection the */ + /* following two operands each */ + /* of which is a simple set of */ + /* processes. */ + + idtype_t p_lidtype; + /* The type of the left operand */ + /* simple set. */ + id_t p_lid; /* The id of the left operand. */ + + idtype_t p_ridtype; + /* The type of the right */ + /* operand simple set. */ + id_t p_rid; /* The id of the right operand. */ +} procset_t; + +/* + * The following macro can be used to initialize a procset_t + * structure. + */ +#define setprocset(psp, op, ltype, lid, rtype, rid) \ + (psp)->p_op = (op); \ + (psp)->p_lidtype = (ltype); \ + (psp)->p_lid = (lid); \ + (psp)->p_ridtype = (rtype); \ + (psp)->p_rid = (rid); + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef _KERNEL + +struct proc; + +extern int dotoprocs(procset_t *, int (*)(), char *); +extern int dotolwp(procset_t *, int (*)(), char *); +extern int procinset(struct proc *, procset_t *); +extern int sigsendproc(struct proc *, sigsend_t *); +extern int sigsendset(procset_t *, sigsend_t *); +extern boolean_t cur_inset_only(procset_t *); +extern id_t getmyid(idtype_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROCSET_H */ diff --git a/illumos-x86_64/usr/include/sys/project.h b/illumos-x86_64/usr/include/sys/project.h new file mode 100644 index 00000000..308c0504 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/project.h @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_PROJECT_H +#define _SYS_PROJECT_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include +#include +#include +#include +#include +#include + +typedef struct kproject_kstat { + kstat_named_t kpk_zonename; + kstat_named_t kpk_usage; + kstat_named_t kpk_value; +} kproject_kstat_t; + +typedef struct kproject_data { /* Datum protected by: */ + rctl_qty_t kpd_shmmax; /* shm's ipcs_lock */ + ipc_rqty_t kpd_ipc; /* shm|sem|msg's ipcs lock */ + rctl_qty_t kpd_locked_mem; /* zone_rctl_lock */ + rctl_qty_t kpd_locked_mem_ctl; /* kpj_rctls->rcs_lock */ + rctl_qty_t kpd_contract; /* contract_lock */ + kmutex_t kpd_crypto_lock; + rctl_qty_t kpd_crypto_mem; /* kpd_crypto_lock above */ + rctl_qty_t kpd_crypto_mem_ctl; /* kpj_rctls->rcs_lock */ + kstat_t *kpd_lockedmem_kstat; /* locked memory kstat */ + kstat_t *kpd_nprocs_kstat; +} kproject_data_t; + +struct cpucap; + +/* + * The first two fields of this structure must not be reordered. + */ +typedef struct kproject { + projid_t kpj_id; /* project ID */ + zoneid_t kpj_zoneid; /* zone ID */ + struct zone *kpj_zone; /* zone pointer */ + uint_t kpj_count; /* reference counter */ + uint32_t kpj_shares; /* number of shares */ + rctl_set_t *kpj_rctls; /* resource control set */ + struct kproject *kpj_prev; /* previous project */ + struct kproject *kpj_next; /* next project */ + kproject_data_t kpj_data; /* subsystem-specfic data */ + kmutex_t kpj_poolbind; /* synchronization with pools */ + rctl_qty_t kpj_nlwps; /* protected by project's zone's */ + /* zone_nlwps_lock */ + rctl_qty_t kpj_nlwps_ctl; /* protected by kpj_rctls->rcs_lock */ + rctl_qty_t kpj_ntasks; /* protected by project's zone's */ + /* zone_nlwps_lock */ + rctl_qty_t kpj_ntasks_ctl; /* protected by kpj_rctls->rcs_lock */ + struct cpucap *kpj_cpucap; /* CPU cap data */ + struct klpd_reg *kpj_klpd; /* our extended policy */ + /* protected by klpd_mutex */ + rctl_qty_t kpj_nprocs; /* protected by project's zone's */ + /* zone_nlwps_lock */ + rctl_qty_t kpj_nprocs_ctl; /* protected by kpj_rctls->rcs_lock */ +} kproject_t; + +#ifdef _KERNEL + +/* + * Flags for project_hold_by_id() + */ +#define PROJECT_HOLD_FIND 1 +#define PROJECT_HOLD_INSERT 2 + +void project_init(void); +kproject_t *project_hold(kproject_t *); +kproject_t *project_hold_by_id(projid_t, struct zone *, int); +void project_rele(kproject_t *); +int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *); +projid_t curprojid(void); + +extern kproject_t *proj0p; +extern rctl_hndl_t rc_project_nlwps; +extern rctl_hndl_t rc_project_nprocs; +extern rctl_hndl_t rc_project_ntasks; +extern rctl_hndl_t rc_project_locked_mem; +extern rctl_hndl_t rc_project_crypto_mem; +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROJECT_H */ diff --git a/illumos-x86_64/usr/include/sys/prom_emul.h b/illumos-x86_64/usr/include/sys/prom_emul.h new file mode 100644 index 00000000..691f70a2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/prom_emul.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PROM_EMUL_H +#define _SYS_PROM_EMUL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following structure describes a property attached to a node + * in the in-kernel copy of the PROM device tree. + */ +struct prom_prop { + struct prom_prop *pp_next; + char *pp_name; + int pp_len; + void *pp_val; +}; + +/* + * The following structure describes a node in the in-kernel copy + * of the PROM device tree. + */ +struct prom_node { + pnode_t pn_nodeid; + struct prom_prop *pn_propp; + struct prom_node *pn_child; + struct prom_node *pn_sibling; +}; + +typedef struct prom_node prom_node_t; + +/* + * These are promif emulation functions, intended only for promif use + */ +extern void promif_create_device_tree(void); + +extern pnode_t promif_findnode_byname(pnode_t n, char *name); +extern pnode_t promif_nextnode(pnode_t n); +extern pnode_t promif_childnode(pnode_t n); + +extern int promif_getproplen(pnode_t n, char *name); +extern int promif_getprop(pnode_t n, char *name, void *value); +extern int promif_bounded_getprop(pnode_t, char *name, void *value, int len); +char *promif_nextprop(pnode_t n, char *previous, char *next); + +/* + * XXX: The following functions are unsafe and unecessary, and should be + * XXX: removed. OS created nodes belong in the OS copy of the device tree. + * XXX: The OS should not be creating nodes in the prom's device tree! + */ +extern pnode_t promif_add_child(pnode_t parent, pnode_t child, char *name); +extern void promif_create_prop_external(pnode_t, char *name, void *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROM_EMUL_H */ diff --git a/illumos-x86_64/usr/include/sys/prom_isa.h b/illumos-x86_64/usr/include/sys/prom_isa.h new file mode 100644 index 00000000..421213d2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/prom_isa.h @@ -0,0 +1,35 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1994,1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_PROM_ISA_H +#define _SYS_PROM_ISA_H + +/* + * This file contains external ISA-specific promif interface definitions. + * There may be none. This file is included by reference in + */ + +#endif /* _SYS_PROM_ISA_H */ diff --git a/illumos-x86_64/usr/include/sys/prom_plat.h b/illumos-x86_64/usr/include/sys/prom_plat.h new file mode 100644 index 00000000..ea780321 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/prom_plat.h @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1994-1996,1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_PROM_PLAT_H +#define _SYS_PROM_PLAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains external platform-specific promif interface definitions + * for i386 platforms. Mostly, this should be empty. + */ + +extern int prom_getmacaddr(int hd, caddr_t ea); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROM_PLAT_H */ diff --git a/illumos-x86_64/usr/include/sys/promif.h b/illumos-x86_64/usr/include/sys/promif.h new file mode 100644 index 00000000..ae286968 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/promif.h @@ -0,0 +1,233 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PROMIF_H +#define _SYS_PROMIF_H + +#include +#include + +#if defined(_KERNEL) || defined(_KMDB) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These are for V0 ops only. We sometimes have to specify + * to promif which type of operation we need to perform + * and since we can't get such a property from a V0 prom, we + * sometimes just assume it. V2 and later proms do the right thing. + */ +#define BLOCK 0 +#define NETWORK 1 +#define BYTE 2 + +#if defined(_KERNEL) || defined(_KMDB) + +extern caddr_t prom_map(caddr_t virthint, uint_t space, + uint_t phys, uint_t size); + +/* + * resource allocation group: OBP and IEEE 1275-1994. + * prom_alloc is platform dependent on SPARC. + */ +extern caddr_t prom_alloc(caddr_t virthint, uint_t size, int align); +extern void prom_free(caddr_t virt, uint_t size); + +/* + * Device tree and property group: OBP and IEEE 1275-1994. + */ +extern pnode_t prom_childnode(pnode_t nodeid); +extern pnode_t prom_nextnode(pnode_t nodeid); +extern pnode_t prom_optionsnode(void); +extern pnode_t prom_alias_node(void); +extern pnode_t prom_rootnode(void); + +extern int prom_getproplen(pnode_t nodeid, caddr_t name); +extern int prom_getprop(pnode_t nodeid, caddr_t name, + caddr_t value); +extern caddr_t prom_nextprop(pnode_t nodeid, caddr_t previous, + caddr_t next); + +extern char *prom_decode_composite_string(void *buf, + size_t buflen, char *prev); + +/* + * Device tree and property group: IEEE 1275-1994 Only. + */ +extern pnode_t prom_finddevice(char *path); + +extern int prom_bounded_getprop(pnode_t nodeid, + caddr_t name, caddr_t buffer, int buflen); + +/* + * Device pathnames and pathname conversion: OBP and IEEE 1275-1994. + */ +extern int prom_devname_from_pathname(char *path, char *buffer); +extern char *prom_path_gettoken(char *from, char *to); + +/* + * Device pathnames and pathname conversion: IEEE 1275-1994 only. + */ + +/* + * Special device nodes: OBP and IEEE 1275-1994. + */ +extern int prom_stdin_is_keyboard(void); +extern int prom_stdout_is_framebuffer(void); +extern void prom_framebuffer_getpos(int *row, int *col); +extern void prom_framebuffer_getcolors(int *fg, int *bg); +extern char *prom_stdinpath(void); +extern char *prom_stdoutpath(void); +extern void prom_strip_options(char *from, char *to); +extern void prom_pathname(char *); + +/* + * Special device nodes: IEEE 1275-1994 only. + */ + +/* + * Administrative group: OBP and IEEE 1275-1994. + */ +extern void prom_enter_mon(void); +extern void prom_exit_to_mon(void) + __NORETURN; +extern void prom_reboot(char *bootstr) + __NORETURN; +extern void prom_panic(char *string) + __NORETURN; + +extern int prom_is_openprom(void); +extern int prom_is_p1275(void); +extern int prom_version_name(char *buf, int buflen); +extern int prom_version_boot_syscalls(void); + +extern uint_t prom_gettime(void); + +extern char *prom_bootpath(void); +extern char *prom_bootargs(void); + +/* + * Administrative group: OBP only. + */ + +/* + * Administrative group: IEEE 1275-1994 only. + */ + +/* + * Administrative group: IEEE 1275 only. + */ + +/* + * Promif support group: Generic. + */ +extern void prom_init(char *progname, void *prom_cookie); + +typedef uint_t prom_generation_cookie_t; + +#define prom_tree_access(CALLBACK, ARG, GENP) (CALLBACK)((ARG), 0) + +/* + * I/O Group: OBP and IEEE 1275. + */ +extern uchar_t prom_getchar(void); +extern void prom_putchar(char c); +extern int prom_mayget(void); +extern int prom_mayput(char c); + +extern int prom_open(char *name); +extern int prom_close(int fd); +extern int prom_read(int fd, caddr_t buf, uint_t len, + uint_t startblk, char type); +extern int prom_write(int fd, caddr_t buf, uint_t len, + uint_t startblk, char devtype); +extern int prom_seek(int fd, unsigned long long offset); + +extern void prom_writestr(const char *buf, size_t bufsize); + +extern void prom_printf(const char *fmt, ...) + __KPRINTFLIKE(1); +#pragma rarely_called(prom_printf) +extern void prom_vprintf(const char *fmt, __va_list adx) + __KVPRINTFLIKE(1); +#pragma rarely_called(prom_vprintf) + +extern char *prom_sprintf(char *s, const char *fmt, ...) + __KPRINTFLIKE(2); +extern char *prom_vsprintf(char *s, const char *fmt, __va_list adx) + __KVPRINTFLIKE(2); + +/* + * promif tree searching routines ... OBP and IEEE 1275-1994. + */ + +extern pnode_t prom_findnode_byname(pnode_t id, char *name); +extern char *prom_get_extend_name(void); + +extern int prom_devreset(int); +extern int OpenCount; +extern struct ihandle *open_devices[]; + +#define PROM_STOP { \ + prom_printf("File %s line %d\n", __FILE__, __LINE__); \ + prom_enter_mon(); \ +} + +#endif /* _KERNEL || _KMDB */ + +#ifdef _KERNEL + +/* + * Used by wrappers which bring up console frame buffer before prom_printf() + * and other prom calls that may output to the console. Struct is filled in + * in prom_env.c and in sunpm.c + */ + +typedef struct promif_owrap { + void (*preout)(void); + void (*postout)(void); +} promif_owrap_t; + +extern void prom_suspend_prepost(void); +extern void prom_resume_prepost(void); + +/* + * WAN boot key storage interface + */ +int prom_set_security_key(char *keyname, caddr_t buf, int buflen, int *reslen, + int *status); +int prom_get_security_key(char *keyname, caddr_t buf, int buflen, int *keylen, + int *status); + +#endif /* _KERNEL */ +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROMIF_H */ diff --git a/illumos-x86_64/usr/include/sys/promimpl.h b/illumos-x86_64/usr/include/sys/promimpl.h new file mode 100644 index 00000000..d124f2e9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/promimpl.h @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PROMIMPL_H +#define _SYS_PROMIMPL_H + +/* + * Promif implementation functions and variables. + * + * These interfaces are not 'exported' in the same sense that + * those described in promif.h + * + * Used so that the kernel and other stand-alones (eg boot) + * don't have to directly reference the prom (of which there + * are now several completely different variants). + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Debugging macros for the promif functions. + */ + +#define PROMIF_DMSG_VERBOSE 2 +#define PROMIF_DMSG_NORMAL 1 + +extern int promif_debug; /* externally patchable */ + +#define PROMIF_DEBUG /* define this to enable debugging */ + +#ifdef PROMIF_DEBUG +#define PROMIF_DPRINTF(args) \ + if (promif_debug) { \ + if (promif_debug == PROMIF_DMSG_VERBOSE) \ + prom_printf("file %s line %d: ", __FILE__, __LINE__); \ + prom_printf args; \ + } +#else +#define PROMIF_DPRINTF(args) +#endif /* PROMIF_DEBUG */ + +/* + * minimum alignment required by prom + */ +#define PROMIF_MIN_ALIGN 1 + +/* + * Private utility routines (not exported as part of the interface) + */ + +extern char *prom_strcpy(char *s1, char *s2); +extern char *prom_strncpy(char *s1, char *s2, size_t n); +extern int prom_strcmp(char *s1, char *s2); +extern int prom_strncmp(char *s1, char *s2, size_t n); +extern int prom_strlen(char *s); +extern char *prom_strrchr(char *s1, char c); +extern char *prom_strcat(char *s1, char *s2); + +/* + * Used to print a common before-reboot message. + */ +extern void prom_reboot_prompt(void); + +/* + * Some calls into the prom (those expected to generate output on the console) + * are wrappered with these calls so that the caller can ensure that + * the console framebuffer will be brought to full power before entering the + * firmware. + */ +extern promif_owrap_t *promif_preout(void); +extern void promif_postout(promif_owrap_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_PROMIMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/protosw.h b/illumos-x86_64/usr/include/sys/protosw.h new file mode 100644 index 00000000..ff1a899d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/protosw.h @@ -0,0 +1,229 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1991 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_PROTOSW_H +#define _SYS_PROTOSW_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Protocol switch table. + * + * Each protocol has a handle initializing one of these structures, + * which is used for protocol-protocol and system-protocol communication. + * + * A protocol is called through the pr_init entry before any other. + * Thereafter it is called every 200ms through the pr_fasttimo entry and + * every 500ms through the pr_slowtimo for timer based actions. + * The system will call the pr_drain entry if it is low on space and + * this should throw away any non-critical data. + * + * Protocols pass data between themselves as chains of mbufs using + * the pr_input and pr_output hooks. Pr_input passes data up (towards + * UNIX) and pr_output passes it down (towards the imps); control + * information passes up and down on pr_ctlinput and pr_ctloutput. + * The protocol is responsible for the space occupied by any the + * arguments to these entries and must dispose it. + * + * The userreq routine interfaces protocols to the system and is + * described below. + */ +struct protosw { + short pr_type; /* socket type used for */ + struct domain *pr_domain; /* domain protocol a member of */ + short pr_protocol; /* protocol number */ + short pr_flags; /* see below */ +/* protocol-protocol hooks */ + int (*pr_input)(); /* input to protocol (from below) */ + int (*pr_output)(); /* output to protocol (from above) */ + int (*pr_ctlinput)(); /* control input (from below) */ + int (*pr_ctloutput)(); /* control output (from above) */ +/* user-protocol hook */ + int (*pr_usrreq)(); /* user request: see list below */ +/* utility hooks */ + int (*pr_init)(); /* initialization hook */ + int (*pr_fasttimo)(); /* fast timeout (200ms) */ + int (*pr_slowtimo)(); /* slow timeout (500ms) */ + int (*pr_drain)(); /* flush any excess space possible */ +}; + +#define PR_SLOWHZ 2 /* 2 slow timeouts per second */ +#define PR_FASTHZ 5 /* 5 fast timeouts per second */ + +/* + * Values for pr_flags + */ +#define PR_ATOMIC 0x01 /* exchange atomic messages only */ +#define PR_ADDR 0x02 /* addresses given with messages */ +/* in the current implementation, PR_ADDR needs PR_ATOMIC to work */ +#define PR_CONNREQUIRED 0x04 /* connection required by protocol */ +#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */ +#define PR_RIGHTS 0x10 /* passes capabilities */ +#define PR_OOB_ADDR 0x20 /* addresses given with OOB data */ + +/* + * The arguments to usrreq are: + * (*protosw[].pr_usrreq)(up, req, m, nam, opt); + * where up is a (struct socket *), req is one of these requests, + * m is a optional mbuf chain containing a message, + * nam is an optional mbuf chain containing an address, + * and opt is a pointer to a socketopt structure or nil. + * The protocol is responsible for disposal of the mbuf chain m, + * the caller is responsible for any space held by nam and opt. + * A non-zero return from usrreq gives an + * UNIX error number which should be passed to higher level software. + */ +#define PRU_ATTACH 0 /* attach protocol to up */ +#define PRU_DETACH 1 /* detach protocol from up */ +#define PRU_BIND 2 /* bind socket to address */ +#define PRU_LISTEN 3 /* listen for connection */ +#define PRU_CONNECT 4 /* establish connection to peer */ +#define PRU_ACCEPT 5 /* accept connection from peer */ +#define PRU_DISCONNECT 6 /* disconnect from peer */ +#define PRU_SHUTDOWN 7 /* won't send any more data */ +#define PRU_RCVD 8 /* have taken data; more room now */ +#define PRU_SEND 9 /* send this data */ +#define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */ +#define PRU_CONTROL 11 /* control operations on protocol */ +#define PRU_SENSE 12 /* return status into m */ +#define PRU_RCVOOB 13 /* retrieve out of band data */ +#define PRU_SENDOOB 14 /* send out of band data */ +#define PRU_SOCKADDR 15 /* fetch socket's address */ +#define PRU_PEERADDR 16 /* fetch peer's address */ +#define PRU_CONNECT2 17 /* connect two sockets */ +/* begin for protocols internal use */ +#define PRU_FASTTIMO 18 /* 200ms timeout */ +#define PRU_SLOWTIMO 19 /* 500ms timeout */ +#define PRU_PROTORCV 20 /* receive from below */ +#define PRU_PROTOSEND 21 /* send to below */ + +#define PRU_NREQ 21 + +#ifdef PRUREQUESTS +char *prurequests[] = { + "ATTACH", "DETACH", "BIND", "LISTEN", + "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN", + "RCVD", "SEND", "ABORT", "CONTROL", + "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR", + "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO", + "PROTORCV", "PROTOSEND", +}; +#endif + +/* + * The arguments to the ctlinput routine are + * (*protosw[].pr_ctlinput)(cmd, arg); + * where cmd is one of the commands below, and arg is + * an optional argument (caddr_t). + * + * N.B. The IMP code, in particular, pressumes the values + * of some of the commands; change with extreme care. + * TODO: + * spread out codes so new ICMP codes can be + * accomodated more easily + */ +#define PRC_IFDOWN 0 /* interface transition */ +#define PRC_ROUTEDEAD 1 /* select new route if possible */ +#define PRC_QUENCH 4 /* some said to slow down */ +#define PRC_MSGSIZE 5 /* message size forced drop */ +#define PRC_HOSTDEAD 6 /* normally from IMP */ +#define PRC_HOSTUNREACH 7 /* ditto */ +#define PRC_UNREACH_NET 8 /* no route to network */ +#define PRC_UNREACH_HOST 9 /* no route to host */ +#define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */ +#define PRC_UNREACH_PORT 11 /* bad port # */ +#define PRC_UNREACH_NEEDFRAG 12 /* IP_DF caused drop */ +#define PRC_UNREACH_SRCFAIL 13 /* source route failed */ +#define PRC_REDIRECT_NET 14 /* net routing redirect */ +#define PRC_REDIRECT_HOST 15 /* host routing redirect */ +#define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */ +#define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */ +#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */ +#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */ +#define PRC_PARAMPROB 20 /* header incorrect */ +#define PRC_GWDOWN 21 /* gateway down */ + +#define PRC_NCMDS 22 + +#ifdef PRCREQUESTS +char *prcrequests[] = { + "IFDOWN", "ROUTEDEAD", "#2", "#3", + "QUENCH", "MSGSIZE", "HOSTDEAD", "HOSTUNREACH", + "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH", + "FRAG-UNREACH", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT", + "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS", + "PARAMPROB" +}; +#endif + +/* + * The arguments to ctloutput are: + * (*protosw[].pr_ctloutput)(req, so, level, optname, optval); + * req is one of the actions listed below, so is a (struct socket *), + * level is an indication of which protocol layer the option is intended. + * optname is a protocol dependent socket option request, + * optval is a pointer to a mbuf-chain pointer, for value-return results. + * The protocol is responsible for disposal of the mbuf chain *optval + * if supplied, + * the caller is responsible for any space held by *optval, when returned. + * A non-zero return from usrreq gives an + * UNIX error number which should be passed to higher level software. + */ +#define PRCO_GETOPT 0 +#define PRCO_SETOPT 1 + +#define PRCO_NCMDS 2 + +#ifdef PRCOREQUESTS +char *prcorequests[] = { + "GETOPT", "SETOPT", +}; +#endif + +#ifdef _KERNEL +extern struct protosw *pffindproto(), *pffindtype(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PROTOSW_H */ diff --git a/illumos-x86_64/usr/include/sys/prsystm.h b/illumos-x86_64/usr/include/sys/prsystm.h new file mode 100644 index 00000000..0ae76cdf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/prsystm.h @@ -0,0 +1,153 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2019 Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _SYS_PRSYSTM_H +#define _SYS_PRSYSTM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) + +extern kmutex_t pr_pidlock; +extern kcondvar_t *pr_pid_cv; + +struct prfpregset; +struct pstatus; +struct lwpstatus; +struct psinfo; +struct lwpsinfo; +struct prcred; +struct prpriv; +struct prsecflags; +struct prfdinfo; +struct prxregset; + +struct seg; +struct regs; +struct watched_page; + +/* + * These are functions in the procfs module that are + * called from the kernel proper and from other modules. + */ +extern uint_t pr_getprot(struct seg *, int, void **, + caddr_t *, caddr_t *, caddr_t); +extern void pr_getprot_done(void **); +extern size_t pr_getsegsize(struct seg *, int); +extern int pr_isobject(struct vnode *); +extern int pr_isself(struct vnode *); +extern void prinvalidate(struct user *); +extern void prgetstatus(proc_t *, struct pstatus *, zone_t *); +extern void prgetlwpstatus(kthread_t *, struct lwpstatus *, zone_t *); +extern void prgetpsinfo(proc_t *, struct psinfo *); +extern void prgetlwpsinfo(kthread_t *, struct lwpsinfo *); +extern void prgetprfpregs(klwp_t *, struct prfpregset *); +extern void prgetprxregs(klwp_t *, struct prxregset *); +extern size_t prgetprxregsize(proc_t *); +extern void prgetcred(proc_t *, struct prcred *); +extern void prgetpriv(proc_t *, struct prpriv *); +extern size_t prgetprivsize(void); +extern void prgetsecflags(proc_t *, struct prsecflags *); +extern uint_t prnsegs(struct as *, int); +extern u_offset_t prgetfdinfosize(proc_t *, vnode_t *, cred_t *); +extern int prgetfdinfo(proc_t *, vnode_t *, struct prfdinfo *, cred_t *, + cred_t *, list_t *); +extern void prexit(proc_t *); +extern void prfree(proc_t *); +extern void prlwpexit(kthread_t *); +extern void prlwpfree(proc_t *, lwpent_t *); +extern void prexecstart(void); +extern void prexecend(void); +extern void prrelvm(void); +extern void prbarrier(proc_t *); +extern void prstop(int, int); +extern void prunstop(void); +extern void prnotify(struct vnode *); +extern void prstep(klwp_t *, int); +extern void prnostep(klwp_t *); +extern void prdostep(void); +extern int prundostep(void); +extern int prhasfp(void); +extern int prhasx(proc_t *); +extern caddr_t prmapin(struct as *, caddr_t, int); +extern void prmapout(struct as *, caddr_t, caddr_t, int); +extern int pr_watch_emul(struct regs *, caddr_t, enum seg_rw); +extern void pr_free_watched_pages(proc_t *); +extern int pr_allstopped(proc_t *, int); +#if defined(__sparc) +struct _gwindows; +extern int prnwindows(klwp_t *); +extern void prgetwindows(klwp_t *, struct _gwindows *); +#if defined(__sparcv9) /* 32-bit adb macros should not see these defs */ +extern void prgetasregs(klwp_t *, asrset_t); +extern void prsetasregs(klwp_t *, asrset_t); +#endif /* __sparcv9 */ +#endif /* __sparc */ +#if defined(__x86) +struct ssd; +extern int prnldt(proc_t *); +extern void prgetldt(proc_t *, struct ssd *); +#endif /* __x86 */ + +#ifdef _SYSCALL32_IMPL +struct prfpregset32; +struct pstatus32; +struct lwpstatus32; +struct psinfo32; +struct lwpsinfo32; +extern void prgetstatus32(proc_t *, struct pstatus32 *, zone_t *); +extern void prgetlwpstatus32(kthread_t *, struct lwpstatus32 *, zone_t *); +extern void prgetpsinfo32(proc_t *, struct psinfo32 *); +extern void prgetlwpsinfo32(kthread_t *, struct lwpsinfo32 *); +extern void lwpsinfo_kto32(const struct lwpsinfo *src, struct lwpsinfo32 *dest); +extern void psinfo_kto32(const struct psinfo *src, struct psinfo32 *dest); +extern void prgetprfpregs32(klwp_t *, struct prfpregset32 *); +#if defined(__sparc) +struct gwindows32; +void prgetwindows32(klwp_t *, struct gwindows32 *); +#endif /* __sparc */ +#endif /* _SYSCALL32_IMPL */ + +#endif /* defined (_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PRSYSTM_H */ diff --git a/illumos-x86_64/usr/include/sys/pset.h b/illumos-x86_64/usr/include/sys/pset.h new file mode 100644 index 00000000..355c095d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pset.h @@ -0,0 +1,92 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PSET_H +#define _SYS_PSET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_ASM) + +#include +#include +#include + +typedef int psetid_t; + +/* special processor set id's */ +#define PS_NONE -1 +#define PS_QUERY -2 +#define PS_MYID -3 +#define PS_SOFT -4 +#define PS_HARD -5 +#define PS_QUERY_TYPE -6 + +/* types of processor sets */ +#define PS_SYSTEM 1 +#define PS_PRIVATE 2 + +#ifndef _KERNEL + +extern int pset_create(psetid_t *); +extern int pset_destroy(psetid_t); +extern int pset_assign(psetid_t, processorid_t, psetid_t *); +extern int pset_info(psetid_t, int *, uint_t *, processorid_t *); +extern int pset_bind(psetid_t, idtype_t, id_t, psetid_t *); +extern int pset_bind_lwp(psetid_t, id_t, pid_t, psetid_t *); +extern int pset_getloadavg(psetid_t, double [], int); +extern int pset_list(psetid_t *, uint_t *); +extern int pset_setattr(psetid_t, uint_t); +extern int pset_getattr(psetid_t, uint_t *); + +#endif /* ! _KERNEL */ + +#endif /* !defined(_ASM) */ + +/* system call subcodes */ +#define PSET_CREATE 0 +#define PSET_DESTROY 1 +#define PSET_ASSIGN 2 +#define PSET_INFO 3 +#define PSET_BIND 4 +#define PSET_GETLOADAVG 5 +#define PSET_LIST 6 +#define PSET_SETATTR 7 +#define PSET_GETATTR 8 +#define PSET_ASSIGN_FORCED 9 +#define PSET_BIND_LWP 10 + +/* attribute bits */ +#define PSET_NOESCAPE 0x0001 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PSET_H */ diff --git a/illumos-x86_64/usr/include/sys/psw.h b/illumos-x86_64/usr/include/sys/psw.h new file mode 100644 index 00000000..6201a1c7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/psw.h @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PSW_H +#define _SYS_PSW_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* Flags Register */ + +typedef struct flags { + uint_t fl_cf : 1, /* carry/borrow */ + : 1, /* reserved */ + fl_pf : 1, /* parity */ + : 1, /* reserved */ + fl_af : 1, /* carry/borrow */ + : 1, /* reserved */ + fl_zf : 1, /* zero */ + fl_sf : 1, /* sign */ + fl_tf : 1, /* trace */ + fl_if : 1, /* interrupt enable */ + fl_df : 1, /* direction */ + fl_of : 1, /* overflow */ + fl_iopl : 2, /* I/O privilege level */ + fl_nt : 1, /* nested task */ + : 1, /* reserved */ + fl_rf : 1, /* reset */ + fl_vm : 1, /* virtual 86 mode */ + fl_res : 14; /* reserved */ +} flags_t; + +#endif /* !_ASM */ + +#define PS_C 0x0001 /* carry bit */ +#define PS_MB1 0x0002 /* unused; must be 1. */ +#define PS_P 0x0004 /* parity bit */ +#define PS_AC 0x0010 /* auxiliary carry bit */ +#define PS_Z 0x0040 /* zero bit */ +#define PS_N 0x0080 /* negative bit */ +#define PS_T 0x0100 /* trace enable bit */ +#define PS_IE 0x0200 /* interrupt enable bit */ +#define PS_D 0x0400 /* direction bit */ +#define PS_V 0x0800 /* overflow bit */ +#define PS_IOPL 0x3000 /* I/O privilege level */ +#define PS_NT 0x4000 /* nested task flag */ +#define PS_RF 0x10000 /* restore flag */ +#define PS_VM 0x20000 /* virtual 86 mode flag */ +#define PS_ACHK 0x40000 /* alignment check enable (486) */ +#define PS_VINT 0x80000 /* virtual interrupt flag */ +#define PS_VINTP 0x100000 /* virtual interrupt pending */ +#define PS_ID 0x200000 /* ID flag */ + +#define PS_ICC (PS_C|PS_AC|PS_Z|PS_N) /* integer condition codes */ + +#define FMT_FLAGS_REG \ + "\20\26id\25vip\24vif\23ac\22vm\21rf" \ + "\17nt\14of\13df\12if\11tf\10sf\7zf\5af\3pf\1cf" + +#define PSL_USER 0x202 /* initial user FLAGS */ + +/* user variable PS bits */ +#define PSL_USERMASK (PS_ICC|PS_D|PS_T|PS_V|PS_P|PS_ACHK|PS_NT) + +/* PS bits changeable by the sahf instruction */ +#define PSL_LSAHFMASK (PS_ICC|PS_P) + +/* + * kernel flags settings + * + * Note that the kernel's SMAP protection relies on PS_ACHK not being present in + * the following two definitions. See uts/intel/ml/copy.s for more + * information on SMAP. + */ +#define F_OFF 0x2 /* interrupts off */ +#define F_ON 0x202 /* interrupts on */ + +#ifndef _ASM +typedef int psw_t; +#endif + +#include +#include /* selector definitions */ + +#define USERMODE(cs) ((uint16_t)(cs) != KCS_SEL) + +#include + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PSW_H */ diff --git a/illumos-x86_64/usr/include/sys/pte.h b/illumos-x86_64/usr/include/sys/pte.h new file mode 100644 index 00000000..ff8d6bb5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/pte.h @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_PTE_H +#define _SYS_PTE_H + +#ifndef _ASM +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +#ifdef PTE36 /* PTE36 ---------------------------- */ + +typedef uint64_t pteval_t; +typedef pteval_t *pteptr_t; + +#define PRPTEx "llx" + +typedef struct pte32 { + uint32_t Present:1; + uint32_t AccessPermissions:2; + uint32_t WriteThru:1; + uint32_t NonCacheable:1; + uint32_t Referenced:1; + uint32_t Modified:1; + uint32_t MustBeZero:1; + uint32_t GlobalEnable:1; + uint32_t OSReserved:3; + uint32_t PhysicalPageNumber:20; +} pte32_t; + + +typedef struct pte { + uint32_t Present:1; + uint32_t AccessPermissions:2; + uint32_t WriteThru:1; + uint32_t NonCacheable:1; + uint32_t Referenced:1; + uint32_t Modified:1; + uint32_t MustBeZero:1; + uint32_t GlobalEnable:1; + uint32_t OSReserved:3; + uint32_t PhysicalPageNumberL:20; + uint32_t PhysicalPageNumberH; + /* + * An easy way to ensure that + * reserved bits are zero. + */ +} pte_t; + +struct pte64 { + uint32_t pte64_0_31; + uint32_t pte64_32_64; +}; + +#define NPTESHIFT 9 +#define NPTEPERPT 512 /* entries in page table */ +#define PTSIZE (NPTEPERPT * MMU_PAGESIZE) /* bytes mapped */ + + +#else /* PTE36 */ + /* PTE32 ---------------------------- */ + + +typedef uint32_t pteval_t; +typedef pteval_t *pteptr_t; + +#define PRPTEx "x" + +typedef struct pte { + uint_t Present:1; + uint_t AccessPermissions:2; + uint_t WriteThru:1; + uint_t NonCacheable:1; + uint_t Referenced:1; + uint_t Modified:1; + uint_t MustBeZero:1; + uint_t GlobalEnable:1; + uint_t OSReserved:3; + uint_t PhysicalPageNumber:20; +} pte_t; + +#define pte32_t pte_t + +#define NPTESHIFT 10 +#define NPTEPERPT 1024 /* entries in page table */ +#define PTSIZE (NPTEPERPT * MMU_PAGESIZE) /* bytes mapped */ + +#endif /* PTE36 */ + +#define PTE_VALID 0x01 +#define PTE_LARGEPAGE 0x80 +#define PTE_SRWX 0x02 + +#endif /* !_ASM */ + + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_PTE_H */ diff --git a/illumos-x86_64/usr/include/sys/ptem.h b/illumos-x86_64/usr/include/sys/ptem.h new file mode 100644 index 00000000..95a5d0d6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ptem.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_PTEM_H +#define _SYS_PTEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The ptem data structure used to define the global data + * for the psuedo terminal emulation streams module + */ +struct ptem { + tcflag_t cflags; /* copy of c_cflags */ + mblk_t *dack_ptr; /* preallocated mblk used to ACK disconnect */ + queue_t *q_ptr; /* ptem read queue */ + struct winsize wsz; /* struct to hold the windowing info. */ + unsigned short state; /* state of ptem entry: see below */ +}; + +/* + * state flags + */ +#define REMOTEMODE 0x1 /* Pty in remote mode */ +#define OFLOW_CTL 0x2 /* Outflow control on */ +#define IS_PTSTTY 0x4 /* is x/open terminal */ + +/* + * Constants used to distinguish between a common function invoked + * from the read or write side put procedures + */ +#define RDSIDE 1 +#define WRSIDE 2 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PTEM_H */ diff --git a/illumos-x86_64/usr/include/sys/ptms.h b/illumos-x86_64/usr/include/sys/ptms.h new file mode 100644 index 00000000..52d69b34 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ptms.h @@ -0,0 +1,186 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_PTMS_H +#define _SYS_PTMS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Structures and definitions supporting the pseudo-terminal drivers. This + * structure is private and should not be used by any applications. + */ +struct pt_ttys { + queue_t *ptm_rdq; /* manager's read queue pointer */ + queue_t *pts_rdq; /* subsidiary's read queue pointer */ + mblk_t *pt_nullmsg; /* 0-bytes message block for pts close */ + pid_t pt_pid; /* process id (for debugging) */ + minor_t pt_minor; /* Minor number of this pty */ + int pt_refcnt; /* reference count for ptm_rdq/pts_rdq uses */ + ushort_t pt_state; /* state of manager/subsidiary pair */ + kcondvar_t pt_cv; /* condition variable for exclusive access */ + kmutex_t pt_lock; /* Per-element lock */ + zoneid_t pt_zoneid; /* Zone membership for this pty */ + uid_t pt_ruid; /* Real owner of pty */ + gid_t pt_rgid; /* Real group owner of pty */ +}; + +/* + * pt_state values + */ +#define PTLOCK 0x01 /* manager/subsidiary pair is locked */ +#define PTMOPEN 0x02 /* manager side is open */ +#define PTSOPEN 0x04 /* subsidiary side is open */ +#define PTSTTY 0x08 /* subsidiary side is tty */ + +/* + * Multi-threading primitives. + * Values of pt_refcnt: -1 if a writer is accessing the struct + * 0 if no one is reading or writing + * > 0 equals to the number of readers accessing the struct + */ +#define PT_ENTER_READ(p) { \ + mutex_enter(&(p)->pt_lock); \ + while ((p)->pt_refcnt < 0) \ + cv_wait(&((p)->pt_cv), &(p)->pt_lock); \ + (p)->pt_refcnt++; \ + mutex_exit(&(p)->pt_lock); \ +} + +#define PT_ENTER_WRITE(p) { \ + mutex_enter(&(p)->pt_lock); \ + while ((p)->pt_refcnt != 0) \ + cv_wait(&((p)->pt_cv), &(p)->pt_lock); \ + (p)->pt_refcnt = -1; \ + mutex_exit(&(p)->pt_lock); \ +} + +#define PT_EXIT_READ(p) { \ + mutex_enter(&(p)->pt_lock); \ + ASSERT((p)->pt_refcnt > 0); \ + if ((--((p)->pt_refcnt)) == 0) \ + cv_broadcast(&(p)->pt_cv); \ + mutex_exit(&(p)->pt_lock); \ +} + +#define PT_EXIT_WRITE(p) { \ + mutex_enter(&(p)->pt_lock); \ + ASSERT((p)->pt_refcnt == -1); \ + (p)->pt_refcnt = 0; \ + cv_broadcast(&(p)->pt_cv); \ + mutex_exit(&(p)->pt_lock); \ +} + +/* + * ptms_lock and pt_cnt are defined in ptms_conf.c + */ +extern kmutex_t ptms_lock; +extern dev_info_t *pts_dip; /* private copy of devinfo ptr */ + +extern void ptms_init(void); +extern struct pt_ttys *pt_ttys_alloc(void); +extern void ptms_close(struct pt_ttys *, uint_t); +extern struct pt_ttys *ptms_minor2ptty(minor_t); +extern int ptms_attach_subsidiary(void); +extern int ptms_minor_valid(minor_t ptmin, uid_t *uid, gid_t *gid); +extern int ptms_minor_exists(minor_t ptmin); +extern void ptms_set_owner(minor_t ptmin, uid_t uid, gid_t gid); +extern major_t ptms_subsidiary_attached(void); + +#ifdef DEBUG +extern void ptms_log(char *, uint_t); +extern void ptms_logp(char *, uintptr_t); +#define DDBG(a, b) ptms_log(a, b) +#define DDBGP(a, b) ptms_logp(a, b) +#else +#define DDBG(a, b) +#define DDBGP(a, b) +#endif + +typedef struct __ptmptsopencb_arg *ptmptsopencb_arg_t; +typedef struct ptmptsopencb { + boolean_t (*ppocb_func)(ptmptsopencb_arg_t); + ptmptsopencb_arg_t ppocb_arg; +} ptmptsopencb_t; + +#endif /* _KERNEL */ + +typedef struct pt_own { + uid_t pto_ruid; + gid_t pto_rgid; +} pt_own_t; + +/* + * IOCTL COMMANDS + * + * ISPTM + * Determines whether the file descriptor is that of an open + * manager device. Return code of zero indicates that the file + * descriptor represents a manager device. + * + * UNLKPT + * Unlocks the manager and subsidiary devices. It returns 0 on + * success. On failure, the errno is set to EINVAL indicating + * that the manager device is not open. + * + * ZONEPT + * Sets the zoneid of the pair of manager and subsidiary devices. + * It returns 0 upon success. Used to force a pty 'into' a zone + * upon zone entry. + * + * PT_OWNER + * Sets uid and gid for subsidiary device. It returns 0 on + * success. + */ +#define ISPTM (('P'<<8)|1) /* query for manager */ +#define UNLKPT (('P'<<8)|2) /* unlock manager/subsidiary pair */ +#define PTSSTTY (('P'<<8)|3) /* set tty flag */ +#define ZONEPT (('P'<<8)|4) /* set zone of manager/subsidiary pair */ +#define OWNERPT (('P'<<8)|5) /* set owner/group for subsidiary */ + +#ifdef _KERNEL +/* + * kernel ioctl commands + * + * PTMPTSOPENCB: Returns a callback function pointer and opaque argument. + * The return value of the callback function when it's invoked + * with the opaque argument passed to it will indicate if the + * pts slave device is currently open. + */ +#define PTMPTSOPENCB (('P'<<8)|6) /* check if the slave is open */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PTMS_H */ diff --git a/illumos-x86_64/usr/include/sys/ptyvar.h b/illumos-x86_64/usr/include/sys/ptyvar.h new file mode 100644 index 00000000..ee00379f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ptyvar.h @@ -0,0 +1,155 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1989-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Pseudo-terminal driver data structures. + */ + +#ifndef _SYS_PTYVAR_H +#define _SYS_PTYVAR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct pty { + int pt_flags; /* flag bits */ + mblk_t *pt_stuffqfirst; /* head of queue for ioctls */ + mblk_t *pt_stuffqlast; /* tail of queue for ioctls */ + int pt_stuffqlen; /* number of bytes of queued ioctls */ + tty_common_t pt_ttycommon; /* data common to all tty drivers */ + bufcall_id_t pt_wbufcid; /* id of pending write-side bufcall */ + struct proc *pt_selr; /* proc selecting on controller read */ + struct proc *pt_selw; /* proc selecting on controller write */ + struct proc *pt_sele; /* proc selecting on exception */ + dev_t pt_sdev; /* XXX dev no for the subsidiary */ + struct vnode *pt_vnode; /* XXX vnode for the subsidiary */ + short pt_pgrp; /* controller side process group */ + uchar_t pt_send; /* pending message to controller */ + uchar_t pt_ucntl; /* pending iocontrol for controller */ + kmutex_t ptc_lock; /* per pty mutex lock */ + kcondvar_t pt_cv_flags; /* condition variable for flag state */ + kcondvar_t pt_cv_readq; /* condition variable for read state */ + kcondvar_t pt_cv_writeq; /* condition variable for write state */ +}; + +#define PF_RCOLL 0x00000001 /* > 1 process selecting for read */ +#define PF_WCOLL 0x00000002 /* > 1 process selecting for write */ +#define PF_ECOLL 0x00000004 /* > 1 process selecting for excep. */ +#define PF_NBIO 0x00000008 /* non-blocking I/O on controller */ +#define PF_ASYNC 0x00000010 /* asynchronous I/O on controller */ +#define PF_WOPEN 0x00000020 /* waiting for open to complete */ +#define PF_CARR_ON 0x00000040 /* "carrier" is on (cntlr. is open) */ +#define PF_SUBSIDGONE 0x00000080 /* subsidiary was open, now closed */ +#define PF_PKT 0x00000100 /* packet mode */ +#define PF_STOPPED 0x00000200 /* user told stopped */ +#define PF_REMOTE 0x00000400 /* remote and flow controlled input */ +#define PF_NOSTOP 0x00000800 /* subsidiary is doing XON/XOFF */ +#define PF_UCNTL 0x00001000 /* user control mode */ +#define PF_43UCNTL 0x00002000 /* real 4.3 user control mode */ +#define PF_IOCTL 0x00004000 /* ioctl call in progress */ +#define PF_WAIT 0x00008000 /* wait in close */ +#define PF_READ 0x00010000 /* serialise read */ +#define PF_WRITE 0x00020000 /* serialise write */ +#define PF_WREAD 0x00040000 /* want to read */ +#define PF_WWRITE 0x00080000 /* want to write */ + +/* + * M_CTL message types. + */ +#define MC_NOCANON 0 /* module below saying it will canonicalize */ +#define MC_DOCANON 1 /* module below saying it won't canonicalize */ +#define MC_CANONQUERY 2 /* module above asking whether module below */ + /* canonicalizes */ +#define MC_SERVICEIMM 3 /* tell the ZS driver to return input */ + /* immediately */ +#define MC_SERVICEDEF 4 /* tell the ZS driver it can wait */ +#define MC_NOIFLAG 5 /* module below saying don't do i flags */ +#define MC_NOOFLAG 6 /* module below saying don't do o flags */ +#define MC_NOLFLAG 7 /* module below saying don't do l flags */ + + +/* + * Thus stuff is from the 4.1 termios.h, but we don't want to + * put it in the real system, so we hide it here. + */ + +/* + * Sun version of winsize. + */ +struct ttysize { + int ts_lines; /* number of lines on terminal */ + int ts_cols; /* number of columns on terminal */ +}; + + +#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */ +#define TIOCPKT_DATA 0x00 /* data packet */ +#define TIOCPKT_FLUSHREAD 0x01 /* flush data not yet written */ + /* to controller */ +#define TIOCPKT_FLUSHWRITE 0x02 /* flush data read from */ + /* controller but not yet */ + /* processed */ +#define TIOCPKT_STOP 0x04 /* stop output */ +#define TIOCPKT_START 0x08 /* start output */ +#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ +#define TIOCPKT_DOSTOP 0x20 /* now do ^S, ^Q */ +#define TIOCPKT_IOCTL 0x40 /* "ioctl" packet */ + +#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ +#define TIOCTCNTL _IOW('t', 32, int) /* pty: set/clr intercept */ + /* ioctl mode */ +#define TIOCISPACE _IOR('t', 128, int) /* space left in input queue */ +#define TIOCISIZE _IOR('t', 129, int) /* size of input queue */ + +#define TIOCSSIZE _IOW('t', 37, struct ttysize) /* set tty size */ +#define TIOCGSIZE _IOR('t', 38, struct ttysize) /* get tty size */ + +#ifdef _KERNEL + +/* + * pty_softc, npty, ptcph, and pty_initspace are defined in tty_ptyconf.c + */ + +extern int npty; +extern struct pty *pty_softc; +extern struct pollhead ptcph; +extern void pty_initspace(void); + +/* + * define the Berkeley style naming convention + */ +#define PTY_BANKS "pqrstuvwxyz" +#define PTY_DIGITS "0123456789abcdef" +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PTYVAR_H */ diff --git a/illumos-x86_64/usr/include/sys/queue.h b/illumos-x86_64/usr/include/sys/queue.h new file mode 100644 index 00000000..7eb4e8bb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/queue.h @@ -0,0 +1,1027 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_QUEUE_H +#define _SYS_QUEUE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues, and circular queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * A circle queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the list. + * A circle queue may be traversed in either direction, but has a more + * complex end of list detection. + * + * For details on the use of these macros, see the queue.h(3HEAD) manual page. + */ + +#ifdef QUEUE_MACRO_DEBUG +#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH +#define QUEUE_MACRO_DEBUG_TRACE +#define QUEUE_MACRO_DEBUG_TRASH +#endif + +#ifdef QUEUE_MACRO_DEBUG_TRACE +/* Store the last 2 places the queue element or head was altered */ +struct qm_trace { + unsigned long lastline; + unsigned long prevline; + const char *lastfile; + const char *prevfile; +}; + +#define TRACEBUF struct qm_trace trace; +#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL }, + +#define QMD_TRACE_HEAD(head) do { \ + (head)->trace.prevline = (head)->trace.lastline; \ + (head)->trace.prevfile = (head)->trace.lastfile; \ + (head)->trace.lastline = __LINE__; \ + (head)->trace.lastfile = __FILE__; \ + _NOTE(CONSTCOND) \ +} while (0) + +#define QMD_TRACE_ELEM(elem) do { \ + (elem)->trace.prevline = (elem)->trace.lastline; \ + (elem)->trace.prevfile = (elem)->trace.lastfile; \ + (elem)->trace.lastline = __LINE__; \ + (elem)->trace.lastfile = __FILE__; \ + _NOTE(CONSTCOND) \ +} while (0) + +#else /* !QUEUE_MACRO_DEBUG_TRACE */ +#define QMD_TRACE_ELEM(elem) +#define QMD_TRACE_HEAD(head) +#define TRACEBUF +#define TRACEBUF_INITIALIZER +#endif /* QUEUE_MACRO_DEBUG_TRACE */ + +#ifdef QUEUE_MACRO_DEBUG_TRASH +#define TRASHIT(x) do {(x) = (void *)-1; } while (0) +#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1) +#else /* !QUEUE_MACRO_DEBUG_TRASH */ +#define TRASHIT(x) +#define QMD_IS_TRASHED(x) 0 +#endif /* QUEUE_MACRO_DEBUG_TRASH */ + +#if defined(QUEUE_MACRO_DEBUG_TRACE) || defined(QUEUE_MACRO_DEBUG_TRASH) +#define QMD_SAVELINK(name, link) void **name = (void *)&(link) +#else /* !QUEUE_MACRO_DEBUG_TRACE && !QUEUE_MACRO_DEBUG_TRASH */ +#define QMD_SAVELINK(name, link) +#endif /* QUEUE_MACRO_DEBUG_TRACE || QUEUE_MACRO_DEBUG_TRASH */ + +#ifdef __cplusplus +/* + * In C++ there can be structure lists and class lists: + */ +#define QUEUE_TYPEOF(type) type +#else +#define QUEUE_TYPEOF(type) struct type +#endif + +/* + * Singly-linked List definitions. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_CLASS_HEAD(name, type) \ +struct name { \ + class type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +#define SLIST_CLASS_ENTRY(type) \ +struct { \ + class type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List access methods. + */ +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_END(head) NULL +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) +#define SLIST_EMPTY(head) ((head)->slh_first == SLIST_END(head)) + +#define SLIST_FOREACH(var, head, field) \ + for ((var) = SLIST_FIRST((head)); \ + (var) != SLIST_END(head); \ + (var) = SLIST_NEXT((var), field)) + +#define SLIST_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) != SLIST_END(head) ? (var) : SLIST_FIRST((head))); \ + (var) != SLIST_END(head); \ + (var) = SLIST_NEXT((var), field)) + +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SLIST_FIRST((head)); \ + (var) != SLIST_END(head) && \ + ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) != SLIST_END(head) ? (var) : SLIST_FIRST((head))); \ + (var) != SLIST_END(head) && \ + ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked List functions. + */ +#define SLIST_INIT(head) do { \ + (head)->slh_first = SLIST_END(head); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SLIST_CONCAT(head1, head2, type, field) do { \ + QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \ + if (curelm == SLIST_END(head1)) { \ + if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != \ + SLIST_END(head1)) \ + SLIST_INIT(head2); \ + } else if (SLIST_FIRST(head2) != SLIST_END(head2)) { \ + while (SLIST_NEXT(curelm, field) != SLIST_END(head1)) \ + curelm = SLIST_NEXT(curelm, field); \ + SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \ + SLIST_INIT(head2); \ + } \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ + SLIST_NEXT((slistelm), field) = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ + SLIST_FIRST((head)) = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SLIST_REMOVE_AFTER(slistelm, field) do { \ + SLIST_NEXT((slistelm), field) = \ + SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SLIST_REMOVE(head, elm, type, field) do { \ + QMD_SAVELINK(oldnext, SLIST_NEXT((elm), field)); \ + if (SLIST_FIRST((head)) == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + QUEUE_TYPEOF(type) *curelm = SLIST_FIRST((head)); \ + while (SLIST_NEXT(curelm, field) != (elm)) \ + curelm = SLIST_NEXT(curelm, field); \ + SLIST_REMOVE_AFTER(curelm, field); \ + } \ + TRASHIT(*oldnext); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SLIST_SWAP(head1, head2, type) do { \ + QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \ + SLIST_FIRST(head1) = SLIST_FIRST(head2); \ + SLIST_FIRST(head2) = swap_first; \ +} while (0) + +/* + * Singly-linked Tail queue declarations. + */ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first; /* first element */ \ + struct type **stqh_last; /* addr of last next element */ \ +} + +#define STAILQ_CLASS_HEAD(name, type) \ +struct name { \ + class type *stqh_first; /* first element */ \ + class type **stqh_last; /* addr of last next element */ \ +} + +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +#define STAILQ_CLASS_ENTRY(type) \ +struct { \ + class type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue access methods. + */ +#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_END(head) NULL +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) +#define STAILQ_EMPTY(head) ((head)->stqh_first == STAILQ_END(head)) + +#define STAILQ_FOREACH(var, head, field) \ + for ((var) = STAILQ_FIRST(head); \ + (var) != STAILQ_END(head); \ + (var) = STAILQ_NEXT((var), field)) + +#define STAILQ_FOREACH_FROM(var, head, field) \ + for ((var) = \ + ((var) != STAILQ_END(head) ? (var) : STAILQ_FIRST((head))); \ + (var) != STAILQ_END(head); \ + (var) = STAILQ_NEXT((var), field)) + +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST(head); \ + (var) != STAILQ_END(head) && \ + ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = \ + ((var) != STAILQ_END(head) ? (var) : STAILQ_FIRST((head))); \ + (var) != STAILQ_END(head) && \ + ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked Tail queue functions. + */ +#define STAILQ_INIT(head) do { \ + STAILQ_FIRST(head) = STAILQ_END(head); \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define STAILQ_CONCAT(head1, head2) do { \ + if (!STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last = STAILQ_FIRST((head2)); \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_INIT((head2)); \ + } \ + _NOTE(CONSTCOND) \ +} while (0) + +#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ + if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + STAILQ_NEXT((tqelm), field) = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + STAILQ_FIRST((head)) = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + STAILQ_NEXT((elm), field) = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define STAILQ_LAST(head, type, field) \ + (STAILQ_EMPTY((head)) ? NULL : \ + __containerof((head)->stqh_last, \ + QUEUE_TYPEOF(type), field.stqe_next)) + +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if ((STAILQ_FIRST((head)) = \ + STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define STAILQ_REMOVE_AFTER(head, elm, field) do { \ + if ((STAILQ_NEXT(elm, field) = \ + STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define STAILQ_REMOVE(head, elm, type, field) do { \ + QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ + if (STAILQ_FIRST((head)) == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } else { \ + QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \ + while (STAILQ_NEXT(curelm, field) != (elm)) \ + curelm = STAILQ_NEXT(curelm, field); \ + STAILQ_REMOVE_AFTER(head, curelm, field); \ + } \ + TRASHIT(*oldnext); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define STAILQ_SWAP(head1, head2, type) do { \ + QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \ + QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \ + STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_FIRST(head2) = swap_first; \ + (head2)->stqh_last = swap_last; \ + if (STAILQ_EMPTY(head1)) \ + (head1)->stqh_last = &STAILQ_FIRST(head1); \ + if (STAILQ_EMPTY(head2)) \ + (head2)->stqh_last = &STAILQ_FIRST(head2); \ + _NOTE(CONSTCOND) \ +} while (0) + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_CLASS_HEAD(name, type) \ +struct name { \ + class type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +#define LIST_CLASS_ENTRY(type) \ +struct { \ + class type *le_next; /* next element */ \ + class type **le_prev; /* address of previous next element */ \ +} + +/* + * List access methods. + */ +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_END(head) NULL +#define LIST_EMPTY(head) ((head)->lh_first == LIST_END(head)) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) +#define LIST_PREV(elm, head, type, field) \ + ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ + __containerof((elm)->field.le_prev, type, field.le_next)) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = LIST_FIRST((head)); \ + (var) != LIST_END(head); \ + (var) = LIST_NEXT((var), field)) + +#define LIST_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) != LIST_END(head) ? (var) : LIST_FIRST((head));\ + (var) != LIST_END(head); \ + (var) = LIST_NEXT((var), field)) + +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)); \ + (var) != LIST_END(head) && \ + ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) != LIST_END(head) ? (var) : LIST_FIRST((head));\ + (var) != LIST_END(head) && \ + ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * List functions. + */ +#if defined(_KERNEL) && defined(QUEUEDEBUG) +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ + if ((head)->lh_first && \ + (head)->lh_first->field.le_prev != &(head)->lh_first) \ + panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_OP(elm, field) \ + if ((elm)->field.le_next && \ + (elm)->field.le_next->field.le_prev != \ + &(elm)->field.le_next) \ + panic("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__);\ + if (*(elm)->field.le_prev != (elm)) \ + panic("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ + (elm)->field.le_next = (void *)1L; \ + (elm)->field.le_prev = (void *)1L; +#else +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_LIST_OP(elm, field) +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) +#endif + +#define LIST_INIT(head) do { \ + LIST_FIRST((head)) = LIST_END(head); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ + LIST_NEXT((listelm), field)->field.le_prev = \ + &LIST_NEXT((elm), field); \ + LIST_NEXT((listelm), field) = (elm); \ + (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + LIST_NEXT((elm), field) = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ + if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ + LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ + LIST_FIRST((head)) = (elm); \ + (elm)->field.le_prev = &LIST_FIRST((head)); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define LIST_REMOVE(elm, field) do { \ + QUEUEDEBUG_LIST_OP((elm), field) \ + if (LIST_NEXT((elm), field) != NULL) \ + LIST_NEXT((elm), field)->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = LIST_NEXT((elm), field); \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ + _NOTE(CONSTCOND) \ +} while (0) + +#define LIST_SWAP(head1, head2, type, field) do { \ + QUEUE_TYPEOF(type) *swap_tmp = LIST_FIRST(head1); \ + LIST_FIRST((head1)) = LIST_FIRST((head2)); \ + LIST_FIRST((head2)) = swap_tmp; \ + if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ + swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ + if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ + swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ + _NOTE(CONSTCOND) \ +} while (0) + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_CLASS_HEAD(name, type) \ +struct name { \ + class type *sqh_first; /* first element */ \ + class type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +#define SIMPLEQ_CLASS_ENTRY(type) \ +struct { \ + class type *sqe_next; /* next element */ \ +} + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head)) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for ((var) = SIMPLEQ_FIRST((head)); \ + (var) != SIMPLEQ_END(head); \ + (var) = SIMPLEQ_NEXT((var), field)) + +#define SIMPLEQ_FOREACH_FROM(var, head, field) \ + for ((var) = \ + ((var) != SIMPLEQ_END(head) ? (var) : SIMPLEQ_FIRST((head)));\ + (var) != SIMPLEQ_END(head); \ + (var) = SIMPLEQ_NEXT((var), field)) + +#define SIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SIMPLEQ_FIRST((head)); \ + (var) != SIMPLEQ_END(head) && \ + ((tvar) = SIMPLEQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define SIMPLEQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = \ + ((var) != SIMPLEQ_END(head) ? (var) : SIMPLEQ_FIRST((head)));\ + (var) != SIMPLEQ_END(head) && \ + ((tvar) = SIMPLEQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + SIMPLEQ_FIRST((head)) = NULL; \ + (head)->sqh_last = &SIMPLEQ_FIRST((head)); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if ((SIMPLEQ_NEXT((elm), field) = SIMPLEQ_FIRST((head))) == NULL)\ + (head)->sqh_last = &SIMPLEQ_NEXT((elm), field); \ + SIMPLEQ_FIRST((head)) = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + SIMPLEQ_NEXT((elm), field) = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &SIMPLEQ_NEXT((elm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if ((SIMPLEQ_NEXT((elm), field) = SIMPLEQ_NEXT((listelm), field)) == \ + NULL) \ + (head)->sqh_last = &SIMPLEQ_NEXT((elm), field); \ + SIMPLEQ_NEXT((listelm), field) = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ + if ((SIMPLEQ_FIRST((head)) = \ + SIMPLEQ_NEXT(SIMPLEQ_FIRST((head)), field)) == NULL) \ + (head)->sqh_last = &SIMPLEQ_FIRST((head)); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ + if ((SIMPLEQ_NEXT((elm)) = \ + SIMPLEQ_NEXT(SIMPLEQ_NEXT((elm), field), field)) == NULL) \ + (head)->sqh_last = &SIMPLEQ_NEXT((elm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ + if (SIMPLEQ_FIRST((head)) == (elm)) { \ + SIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + QUEUE_TYPEOF(type) *curelm = SIMPLEQ_FIRST((head)); \ + while (SIMPLEQ_NEXT(curelm, field) != (elm)) \ + curelm = SIMPLEQ_NEXT(curelm, field); \ + SIMPLEQ_REMOVE_AFTER((head), curelm, field); \ + } \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SIMPLEQ_CONCAT(head1, head2) do { \ + if (!SIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + SIMPLEQ_INIT((head2)); \ + } \ + _NOTE(CONSTCOND) \ +} while (0) + +#define SIMPLEQ_LAST(head, type, field) \ + (SIMPLEQ_EMPTY((head)) ? \ + NULL : \ + ((QUEUE_TYPEOF(type) *)(void *) \ + ((char *)((head)->sqh_last) - offsetof(QUEUE_TYPEOF(type), field)))) + +/* + * Tail queue definitions. + */ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; /* first element */ \ + struct type **tqh_last; /* addr of last next element */ \ + TRACEBUF \ +} + +#define TAILQ_CLASS_HEAD(name, type) \ +struct name { \ + class type *tqh_first; /* first element */ \ + class type **tqh_last; /* addr of last next element */ \ + TRACEBUF \ +} + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ + TRACEBUF \ +} + +#define TAILQ_CLASS_ENTRY(type) \ +struct { \ + class type *tqe_next; /* next element */ \ + class type **tqe_prev; /* address of previous next element */ \ + TRACEBUF \ +} + +/* + * Tail queue access methods. + */ +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_END(head) NULL +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_EMPTY(head) ((head)->tqh_first == TAILQ_END(head)) + + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = TAILQ_FIRST((head)); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_NEXT((var), field)) + +#define TAILQ_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) != TAILQ_END((head)) ? \ + (var) : TAILQ_FIRST((head))); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_NEXT((var), field)) + +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST((head)); \ + (var) != TAILQ_END(head) && \ + ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) != TAILQ_END((head)) ? \ + (var) : TAILQ_FIRST((head))); \ + (var) != TAILQ_END(head) && \ + ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ + for ((var) = ((var) != TAILQ_END((head)) ? \ + (var) : TAILQ_LAST((head), headname)); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) != TAILQ_END(head) && \ + ((tvar) = TAILQ_PREV((var), headname, field), 1); \ + (var) = (tvar)) + +#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar)\ + for ((var) = ((var) != TAILQ_END((head)) ? \ + (var) : TAILQ_LAST((head), headname)); \ + (var) != TAILQ_END(head) && \ + ((tvar) = TAILQ_PREV((var), headname, field), 1); \ + (var) = (tvar)) + +/* + * Tail queue functions. + */ +#if defined(_KERNEL) && defined(QUEUEDEBUG) +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ + if ((head)->tqh_first && \ + (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ + panic("TAILQ_INSERT_HEAD %p %s:%d", (void *)(head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ + if (*(head)->tqh_last != NULL) \ + panic("TAILQ_INSERT_TAIL %p %s:%d", (void *)(head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_OP(elm, field) \ + if ((elm)->field.tqe_next && \ + (elm)->field.tqe_next->field.tqe_prev != \ + &(elm)->field.tqe_next) \ + panic("TAILQ_* forw %p %s:%d", (void *)(elm), \ + __FILE__, __LINE__);\ + if (*(elm)->field.tqe_prev != (elm)) \ + panic("TAILQ_* back %p %s:%d", (void *)(elm), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ + if ((elm)->field.tqe_next == NULL && \ + (head)->tqh_last != &(elm)->field.tqe_next) \ + panic("TAILQ_PREREMOVE head %p elm %p %s:%d", \ + (void *)(head), (void *)(elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ + (elm)->field.tqe_next = (void *)1L; \ + (elm)->field.tqe_prev = (void *)1L; +#else +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) +#define QUEUEDEBUG_TAILQ_OP(elm, field) +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) +#endif + +#define TAILQ_INIT(head) do { \ + TAILQ_FIRST((head)) = TAILQ_END((head)); \ + (head)->tqh_last = &TAILQ_FIRST((head)); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ + if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ + TAILQ_FIRST((head))->field.tqe_prev = \ + &TAILQ_NEXT((elm), field); \ + else \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + TAILQ_FIRST((head)) = (elm); \ + (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ + TAILQ_NEXT((elm), field) = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + &TAILQ_NEXT((elm), field); \ + else \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + TAILQ_NEXT((listelm), field) = (elm); \ + (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + TAILQ_NEXT((elm), field) = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ + QUEUEDEBUG_TAILQ_OP((elm), field) \ + if ((TAILQ_NEXT((elm), field)) != NULL) \ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define TAILQ_SWAP(head1, head2, type, field) do { \ + QUEUE_TYPEOF(type) *swap_first = TAILQ_FIRST((head1)); \ + QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \ + TAILQ_FIRST((head1)) = TAILQ_FIRST((head2)); \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_FIRST((head2)) = swap_first; \ + (head2)->tqh_last = swap_last; \ + if ((swap_first = TAILQ_FIRST((head1))) != NULL) \ + swap_first->field.tqe_prev = &TAILQ_FIRST((head1)); \ + else \ + (head1)->tqh_last = &TAILQ_FIRST((head1)); \ + if ((swap_first = TAILQ_FIRST((head2))) != NULL) \ + swap_first->field.tqe_prev = &TAILQ_FIRST((head2)); \ + else \ + (head2)->tqh_last = &TAILQ_FIRST((head2)); \ + _NOTE(CONSTCOND) \ +} while (0) + +/* + * Circular queue definitions. Do not use. We still keep the macros + * for compatibility but because of pointer aliasing issues their use + * is discouraged! + */ +#define CIRCLEQ_HEAD(name, type) \ +struct name { \ + struct type *cqh_first; /* first element */ \ + struct type *cqh_last; /* last element */ \ +} + +#define CIRCLEQ_HEAD_INITIALIZER(head) \ + { (void *)&head, (void *)&head } + +#define CIRCLEQ_ENTRY(type) \ +struct { \ + struct type *cqe_next; /* next element */ \ + struct type *cqe_prev; /* previous element */ \ +} + +/* + * Circular queue access methods. + */ +#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) +#define CIRCLEQ_FIRST(head) ((head)->cqh_first) +#define CIRCLEQ_LAST(head) ((head)->cqh_last) +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) + +#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ + (((elm)->field.cqe_next == (void *)(head)) \ + ? ((head)->cqh_first) \ + : (elm->field.cqe_next)) +#define CIRCLEQ_LOOP_PREV(head, elm, field) \ + (((elm)->field.cqe_prev == (void *)(head)) \ + ? ((head)->cqh_last) \ + : (elm->field.cqe_prev)) + +#define CIRCLEQ_FOREACH(var, head, field) \ + for ((var) = CIRCLEQ_FIRST((head)); \ + (var) != (void *)(head); \ + (var) = CIRCLEQ_NEXT((var), field)) + +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ + for ((var) = CIRCLEQ_LAST((head)); \ + (var) != (void *)(head); \ + (var) = CIRCLEQ_PREV((var), field)) + +/* + * Circular queue functions. + */ +#define CIRCLEQ_INIT(head) do { \ + (head)->cqh_first = (void *)(head); \ + (head)->cqh_last = (void *)(head); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + (elm)->field.cqe_next = (listelm)->field.cqe_next; \ + (elm)->field.cqe_prev = (listelm); \ + if ((listelm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (listelm)->field.cqe_next->field.cqe_prev = (elm); \ + (listelm)->field.cqe_next = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ + (elm)->field.cqe_next = (listelm); \ + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ + if ((listelm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (listelm)->field.cqe_prev->field.cqe_next = (elm); \ + (listelm)->field.cqe_prev = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.cqe_next = (head)->cqh_first; \ + (elm)->field.cqe_prev = (void *)(head); \ + if ((head)->cqh_last == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (head)->cqh_first->field.cqe_prev = (elm); \ + (head)->cqh_first = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.cqe_next = (void *)(head); \ + (elm)->field.cqe_prev = (head)->cqh_last; \ + if ((head)->cqh_first == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (head)->cqh_last->field.cqe_next = (elm); \ + (head)->cqh_last = (elm); \ + _NOTE(CONSTCOND) \ +} while (0) + +#define CIRCLEQ_REMOVE(head, elm, field) do { \ + if ((elm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm)->field.cqe_prev; \ + else \ + (elm)->field.cqe_next->field.cqe_prev = \ + (elm)->field.cqe_prev; \ + if ((elm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm)->field.cqe_next; \ + else \ + (elm)->field.cqe_prev->field.cqe_next = \ + (elm)->field.cqe_next; \ + _NOTE(CONSTCOND) \ +} while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_QUEUE_H */ diff --git a/illumos-x86_64/usr/include/sys/raidioctl.h b/illumos-x86_64/usr/include/sys/raidioctl.h new file mode 100644 index 00000000..6be3d067 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/raidioctl.h @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RAIDIOCTL_H +#define _SYS_RAIDIOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * map ioctls + */ +#define RAID_IOC (('R' << 16) | ('D' << 8)) +#define RAID_GETCONFIG (RAID_IOC|1) /* Get raid information */ +#define RAID_UPDATEFW (RAID_IOC|4) /* Update IOC firmware */ +#define RAID_NUMVOLUMES (RAID_IOC|6) /* Retrieve max RAID volumes */ + +/* + * define raid status flags + */ +#define RAID_FLAG_ENABLED 0x01 +#define RAID_FLAG_QUIESCED 0x02 +#define RAID_FLAG_RESYNCING 0x04 +#define RAID_STATE_OPTIMAL 0x00 +#define RAID_STATE_DEGRADED 0x01 +#define RAID_STATE_FAILED 0x02 + +/* + * define disk status flags + */ +#define RAID_DISKSTATUS_GOOD 0x0 +#define RAID_DISKSTATUS_FAILED 0x1 +#define RAID_DISKSTATUS_MISSING 0x2 + +/* + * maximum number of disks allowed in a raid volume + */ +#define RAID_MAXDISKS 32 + +typedef struct raid_config { + int targetid; + uint8_t state; + uint8_t flags; + int raid_level; + int ndisks; + int disk[RAID_MAXDISKS]; + int diskstatus[RAID_MAXDISKS]; + diskaddr_t raid_capacity; + int unitid; +} raid_config_t; + +/* + * Defines for type + */ +#define FW_TYPE_UCODE 0x1; +#define FW_TYPE_FCODE 0x2; + +typedef struct update_flash { + caddr_t ptrbuffer; + uint_t size; + uint8_t type; +} update_flash_t; + +#if defined(_SYSCALL32) +typedef struct update_flash_32 { + caddr32_t ptrbuffer; + uint32_t size; + uint8_t type; +} update_flash_32_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RAIDIOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/ramdisk.h b/illumos-x86_64/usr/include/sys/ramdisk.h new file mode 100644 index 00000000..202fff36 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ramdisk.h @@ -0,0 +1,234 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RAMDISK_H +#define _SYS_RAMDISK_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * /dev names: + * /dev/ramdiskctl - control device + * /dev/ramdisk/ - block devices + * /dev/rramdisk/ - character devices + */ +#define RD_DRIVER_NAME "ramdisk" +#define RD_BLOCK_NAME RD_DRIVER_NAME +#define RD_CHAR_NAME "r" RD_DRIVER_NAME + +#define RD_CTL_NODE "ctl" +#define RD_CTL_NAME RD_DRIVER_NAME RD_CTL_NODE + +/* + * Minor number 0 is reserved for the controlling device. All other ramdisks + * are assigned minor numbers 1..rd_max_disks. The minor number is used as + * an index into the 'rd_devstate' structures. + */ +#define RD_CTL_MINOR 0 + +/* + * Maximum number of ramdisks supported by this driver. + */ +#define RD_MAX_DISKS 1024 + +/* + * Properties exported by the driver. + */ +#define NBLOCKS_PROP_NAME "Nblocks" +#define SIZE_PROP_NAME "Size" + +/* + * Strip any "ramdisk-" prefix from the name of OBP-created ramdisks. + */ +#define RD_OBP_PFXSTR "ramdisk-" +#define RD_OBP_PFXLEN (sizeof (RD_OBP_PFXSTR) - 1) + +#define RD_STRIP_PREFIX(newname, oldname) \ + { \ + char *onm = oldname; \ + newname = strncmp(onm, RD_OBP_PFXSTR, RD_OBP_PFXLEN) == 0 ? \ + (onm + RD_OBP_PFXLEN) : onm; \ + } + +/* + * Strip any ",raw" suffix from the name of pseudo ramdisk devices. + */ +#define RD_STRIP_SUFFIX(name) \ + { \ + char *str = strstr((name), ",raw"); \ + if (str != NULL) \ + *str = '\0'; \ + } + +/* + * Interface between the ramdisk(4D) driver and ramdiskadm(8). Use is: + * + * fd = open("/dev/ramdiskctl", O_RDWR | O_EXCL); + * + * 'ramdiskctl' must be opened exclusively. Access is controlled by permissions + * on the device, which is 0644 by default. Write-access is required for the + * allocation and deletion of ramdisks, but only read-access is required for + * the remaining ioctls which simply return information. + * + * ioctl usage: + * + * struct rd_ioctl ri; + * + * strlcpy(ri.ri_name, "somediskname", sizeof (ri.ri_name)); + * ri.ri_size = somedisksize; + * ioctl(fd, RD_CREATE_DISK, &ri); + * + * strlcpy(ri.ri_name, "somediskname", sizeof (ri.ri_name)); + * ioctl(fd, RD_DELETE_DISK, &ri); + * + * (only ramdisks created using the RD_CREATE_DISK ioctl can be deleted + * by the RD_DELETE_DISK ioctl). + * + * Note that these ioctls are completely private, and only for the use of + * ramdiskadm(8). + */ +#define RD_IOC_BASE (('R' << 16) | ('D' << 8)) + +#define RD_CREATE_DISK (RD_IOC_BASE | 0x01) +#define RD_DELETE_DISK (RD_IOC_BASE | 0x02) + +#define RD_NAME_LEN 32 /* Max length of ramdisk name */ +#define RD_NAME_PAD 7 /* Pad ri_name to 8-bytes */ + +struct rd_ioctl { + char ri_name[RD_NAME_LEN + 1]; + char _ri_pad[RD_NAME_PAD]; + uint64_t ri_size; +}; + +#if defined(_KERNEL) + +/* + * We limit the maximum number of active ramdisk devices to 32, tuneable + * up to a maximum of 1023. Minor 0 is always reserved for the controlling + * device. You can change this by setting a value for 'max_disks' in + * ramdisk.conf. + */ +#define RD_DFLT_DISKS 32 + +/* + * The maximum amount of memory that can be consumed before starving the + * kernel depends loosely on the number of cpus, the speed of those cpus, + * and other hardware characteristics, and is thus highly machine-dependent. + * The default value of 'rd_percent_physmem' is 25% of physical memory, + * but this can be changed by setting a value for 'percent_physmem' in + * ramdisk.conf. + */ +#define RD_DEFAULT_PERCENT_PHYSMEM 25 + +/* + * Maximum size of a physical transfer? + */ +#define RD_DEFAULT_MAXPHYS (63 * 1024) /* '126b' */ + +/* + * A real OBP-created ramdisk consists of one or more physical address + * ranges; these are described by the 'existing' property, whose value + * is a (corresponding) number of {phys,size} pairs. + */ +#define OBP_EXISTING_PROP_NAME "existing" +#define OBP_ADDRESS_PROP_NAME "address" +#define OBP_SIZE_PROP_NAME "size" + +#define RD_EXISTING_PROP_NAME "existing" /* for x86 */ + +typedef struct { + uint64_t phys; /* Phys addr of range */ + uint64_t size; /* Size of range */ +} rd_existing_t; + + +#define RD_WINDOW_NOT_MAPPED 1 /* Valid window is on page boundary */ + +/* + * The entire state of each ramdisk device. The rd_dip field will reference + * the actual devinfo for real OBP-created ramdisks, or the generic devinfo + * 'rd_dip' for pseudo ramdisk devices. + */ +typedef struct rd_devstate { + kmutex_t rd_device_lock; /* Per device lock */ + char rd_name[RD_NAME_LEN + 1]; + dev_info_t *rd_dip; /* My devinfo handle */ + minor_t rd_minor; /* Full minor number */ + size_t rd_size; /* Size in bytes */ + /* + * {rd_nexisting, rd_existing} and {rd_npages, rd_ppa} are + * mutually exclusive; the former describe an OBP-created + * ramdisk, the latter a 'pseudo' ramdisk. + */ + uint_t rd_nexisting; /* # 'existing' structs */ + rd_existing_t *rd_existing; + pgcnt_t rd_npages; /* # physical pages */ + page_t **rd_ppa; + /* + * Fields describing a virtual window onto the physical ramdisk, + * giving the offset within the ramdisk of the window, its size, + * and its virtual address (in the kernel heap). + */ + uint_t rd_window_obp; /* using OBP's vaddr */ + offset_t rd_window_base; + uint64_t rd_window_size; + caddr_t rd_window_virt; + /* + * Fields to count opens/closes of the ramdisk. + */ + uint32_t rd_blk_open; + uint32_t rd_chr_open; + uint32_t rd_lyr_open_cnt; + /* + * Fields to maintain a faked geometry of the disk. + */ + struct dk_geom rd_dkg; + struct vtoc rd_vtoc; + struct dk_cinfo rd_ci; + /* + * Kstat stuff. + */ + kmutex_t rd_kstat_lock; + kstat_t *rd_kstat; +} rd_devstate_t; + +extern int is_pseudo_device(dev_info_t *); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RAMDISK_H */ diff --git a/illumos-x86_64/usr/include/sys/random.h b/illumos-x86_64/usr/include/sys/random.h new file mode 100644 index 00000000..7bee6dd0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/random.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_RANDOM_H +#define _SYS_RANDOM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* stats for the random number devices, /dev/random and /dev/urandom. */ +typedef struct rnd_stats { + uint64_t rs_rndOut; /* Bytes generated for /dev/random */ + uint64_t rs_rndcOut; /* Bytes read from /dev/random cache */ + uint64_t rs_urndOut; /* Bytes generated for /dev/urandom */ +} rnd_stats_t; + +/* stats for the kernel random number provider, swrand. */ +typedef struct swrand_stats { + uint32_t ss_entEst; /* Entropy estimate in bits */ + uint64_t ss_entIn; /* Entropy bits added to pool */ + uint64_t ss_entOut; /* Entropy bits extracted from pool */ + uint64_t ss_bytesIn; /* Total data bytes added to pool */ + uint64_t ss_bytesOut; /* Total data bytes extracted from */ + /* the pool */ +} swrand_stats_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +#define BUMP_CPU_RND_STATS(rm, x, v) (((rm)->rm_mag.rm_stats).x += (v)) +#define BUMP_RND_STATS(x, v) atomic_add_64(&(rnd_stats).x, (v)) +#define BUMP_SWRAND_STATS(x, v) atomic_add_64(&(swrand_stats).x, (v)) + +extern int random_add_entropy(uint8_t *, size_t, uint_t); +extern int random_get_bytes(uint8_t *, size_t); +extern int random_get_blocking_bytes(uint8_t *, size_t); +extern int random_get_pseudo_bytes(uint8_t *, size_t); + +#endif /* _KERNEL */ + +/* + * Flags for the getrandom(2) system call. + */ +#define GRND_NONBLOCK 0x0001 /* O_NONBLOCK equiv */ +#define GRND_RANDOM 0x0002 /* Use /dev/random, not /dev/urandom */ +extern ssize_t getrandom(void *, size_t, unsigned int); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RANDOM_H */ diff --git a/illumos-x86_64/usr/include/sys/rctl.h b/illumos-x86_64/usr/include/sys/rctl.h new file mode 100644 index 00000000..cbcdb87a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rctl.h @@ -0,0 +1,357 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_RCTL_H +#define _SYS_RCTL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Available local actions and flags. + */ +#define RCTL_LOCAL_NOACTION 0x00000000 +#define RCTL_LOCAL_SIGNAL 0x00000001 +#define RCTL_LOCAL_DENY 0x00000002 + +#define RCTL_LOCAL_MAXIMAL 0x80000000 +#define RCTL_LOCAL_PROJDB 0x40000000 + +#define RCTL_LOCAL_ACTION_MASK 0xffff0000 +#define RCTL_LOCAL_MASK 0xc0000003 + +/* + * Available global actions and flags. + */ +#define RCTL_GLOBAL_NOACTION 0x00000000 +#define RCTL_GLOBAL_SYSLOG 0x00000001 + +#define RCTL_GLOBAL_NOBASIC 0x80000000 +#define RCTL_GLOBAL_LOWERABLE 0x40000000 +#define RCTL_GLOBAL_DENY_ALWAYS 0x20000000 +#define RCTL_GLOBAL_DENY_NEVER 0x10000000 +#define RCTL_GLOBAL_FILE_SIZE 0x08000000 +#define RCTL_GLOBAL_CPU_TIME 0x04000000 +#define RCTL_GLOBAL_SIGNAL_NEVER 0x02000000 +#define RCTL_GLOBAL_NOLOCALACTION RCTL_GLOBAL_SIGNAL_NEVER +#define RCTL_GLOBAL_INFINITE 0x01000000 +#define RCTL_GLOBAL_UNOBSERVABLE 0x00800000 +#define RCTL_GLOBAL_SYSLOG_NEVER 0x00080000 + +#define RCTL_GLOBAL_BYTES 0x00400000 +#define RCTL_GLOBAL_SECONDS 0x00200000 +#define RCTL_GLOBAL_COUNT 0x00100000 + +#define RCTL_GLOBAL_ACTION_MASK 0xffff0000 +#define RCTL_GLOBAL_MASK 0xfff80001 + +/* + * getrctl(2) flag values + */ +#define RCTL_FIRST 0x00000000 +#define RCTL_NEXT 0x00000001 +#define RCTL_USAGE 0x00000002 + +/* + * setrctl(2) flag values + */ + +#define RCTL_INSERT 0x00000000 +#define RCTL_DELETE 0x00000001 +#define RCTL_REPLACE 0x00000002 + +#define RCTL_USE_RECIPIENT_PID 0x10000000 + +#define RCTLSYS_ACTION_MASK 0xffff0000 +#define RCTLSYS_MASK 0x10000003 + +/* + * rctl_priv_t: rctl privilege defined values + * A large amount of space has been deliberately left between these privileges + * to permit future enrichment of the control privilege value. + */ +#define RCPRIV_BASIC 0x01000000 +#define RCPRIV_PRIVILEGED 0x04000000 +#define RCPRIV_SYSTEM 0x07000000 + +typedef u_longlong_t rctl_qty_t; /* resource control numerical values */ +typedef int rctl_priv_t; + +typedef struct rctlblk rctlblk_t; + +extern int setrctl(const char *, rctlblk_t *, rctlblk_t *, int); +extern int getrctl(const char *, rctlblk_t *, rctlblk_t *, int); + +typedef enum { + RCENTITY_PROCESS, + RCENTITY_TASK, + RCENTITY_PROJECT, + RCENTITY_ZONE +} rctl_entity_t; +#define RC_MAX_ENTITY RCENTITY_ZONE + +#ifndef _KERNEL + +typedef struct rctl_set rctl_set_t; + +#else /* _KERNEL */ + +#include + +/* + * rctl_test return bitfield + */ +#define RCT_NONE 0x00000000 +#define RCT_DENY 0x00000001 +#define RCT_SIGNAL 0x00000002 +#define RCT_STRLOG 0x00000004 + +#define RCT_LK_ABANDONED 0x80000000 + +/* + * rctl_set_dup flags + */ +#define RCD_DUP 0x1 +#define RCD_CALLBACK 0x2 + +/* + * rctl_action/rctl_test action safety states + */ +#define RCA_SAFE 0x0 /* safe for signal and siginfo delivery */ +#define RCA_UNSAFE_SIGINFO 0x1 /* not safe to allocate for siginfo */ +#define RCA_UNSAFE_ALL 0x2 /* not safe to send signal */ + +typedef struct rctl_val { + struct rctl_val *rcv_prev; /* previous (lower) value */ + struct rctl_val *rcv_next; /* next (higher) value */ + rctl_priv_t rcv_privilege; /* appropriate RCPRIV_* cst */ + rctl_qty_t rcv_value; /* enforced value of control */ + uint_t rcv_flagaction; /* properties and actions */ + int rcv_action_signal; /* signal to send as action */ + struct proc *rcv_action_recipient; /* process to receive signal */ + id_t rcv_action_recip_pid; /* pid of that process */ + hrtime_t rcv_firing_time; /* time rctl_val last fired */ +} rctl_val_t; + +typedef int rctl_hndl_t; + +struct rctl; +struct proc; +struct task; +struct kproject; +struct zone; +struct kstat; + +typedef struct rctl_entity_p_struct { + rctl_entity_t rcep_t; + union { + struct proc *proc; + struct task *task; + struct kproject *proj; + struct zone *zone; + } rcep_p; +} rctl_entity_p_t; + +typedef struct rctl_ops { + void (*rco_action)(struct rctl *, struct proc *, + rctl_entity_p_t *); + rctl_qty_t (*rco_get_usage)(struct rctl *, struct proc *); + int (*rco_set)(struct rctl *, struct proc *, + rctl_entity_p_t *, rctl_qty_t); + int (*rco_test)(struct rctl *, struct proc *, + rctl_entity_p_t *, rctl_val_t *, rctl_qty_t, uint_t); +} rctl_ops_t; + +#define RCTLOP_ACTION(r, p, e) (r->rc_dict_entry->rcd_ops->rco_action(r, p, e)) +#define RCTLOP_GET_USAGE(r, p) (r->rc_dict_entry->rcd_ops->rco_get_usage(r, p)) +#define RCTLOP_SET(r, p, e, v) (r->rc_dict_entry->rcd_ops->rco_set(r, p, e, v)) +#define RCTLOP_TEST(r, p, e, v, i, f) \ + (r->rc_dict_entry->rcd_ops->rco_test(r, p, e, v, i, f)) + +/* + * Default resource control callback functions. + */ +void rcop_no_action(struct rctl *, struct proc *, rctl_entity_p_t *); +rctl_qty_t rcop_no_usage(struct rctl *, struct proc *); +int rcop_no_set(struct rctl *, struct proc *, rctl_entity_p_t *, rctl_qty_t); +int rcop_no_test(struct rctl *, struct proc *, rctl_entity_p_t *, + struct rctl_val *, rctl_qty_t, uint_t); +int rcop_absolute_test(struct rctl *, struct proc *, rctl_entity_p_t *, + struct rctl_val *, rctl_qty_t, uint_t); + +#define RCTLOP_NO_USAGE(r) \ + (r->rc_dict_entry->rcd_ops->rco_get_usage == rcop_no_usage) + +extern rctl_ops_t rctl_default_ops; +extern rctl_ops_t rctl_absolute_ops; + +typedef struct rctl { + struct rctl *rc_next; /* next in set hash chain */ + rctl_val_t *rc_values; /* list of enforced value */ + rctl_val_t *rc_cursor; /* currently enforced value */ + struct rctl_dict_entry *rc_dict_entry; /* global control properties */ + rctl_hndl_t rc_id; /* control handle (hash key) */ + rctl_val_t *rc_projdb; /* project database rctls */ +} rctl_t; + +/* + * The rctl_set is the collection of resource controls associated with an + * individual entity within the system. All of the controls are applicable to + * the same entity, which we call out explicitly in rcs_entity. + */ +typedef struct rctl_set { + kmutex_t rcs_lock; /* global set lock */ + rctl_entity_t rcs_entity; /* entity type */ + rctl_t **rcs_ctls; /* hash table of controls */ +} rctl_set_t; + +typedef struct rctl_dict_entry { + struct rctl_dict_entry *rcd_next; /* next in dict hash chain */ + char *rcd_name; /* resource control name */ + rctl_val_t *rcd_default_value; /* system control value */ + rctl_ops_t *rcd_ops; /* callback operations */ + rctl_hndl_t rcd_id; /* control handle */ + rctl_entity_t rcd_entity; /* entity type */ + int rcd_flagaction; /* global properties/actions */ + int rcd_syslog_level; /* event syslog level */ + int rcd_strlog_flags; /* derived from syslog level */ + rctl_qty_t rcd_max_native; /* native model "infinity" */ + rctl_qty_t rcd_max_ilp32; /* ILP32 model "infinity" */ +} rctl_dict_entry_t; + +typedef struct rctl_alloc_gp { + uint_t rcag_nctls; /* number of rctls needed/allocated */ + uint_t rcag_nvals; /* number of rctl values needed/allocated */ + rctl_t *rcag_ctls; /* list of allocated rctls */ + rctl_val_t *rcag_vals; /* list of allocated rctl values */ +} rctl_alloc_gp_t; + +extern kmem_cache_t *rctl_cache; /* kmem cache for rctl structures */ +extern kmem_cache_t *rctl_val_cache; /* kmem cache for rctl values */ + +extern rctl_hndl_t rctlproc_legacy[]; +extern uint_t rctlproc_flags[]; +extern int rctlproc_signals[]; + +void rctl_init(void); +void rctlproc_init(void); +void rctlproc_default_init(struct proc *, rctl_alloc_gp_t *); + +rctl_hndl_t rctl_register(const char *, rctl_entity_t, int, rctl_qty_t, + rctl_qty_t, rctl_ops_t *); + +rctl_hndl_t rctl_hndl_lookup(const char *); +rctl_dict_entry_t *rctl_dict_lookup(const char *); +rctl_dict_entry_t *rctl_dict_lookup_hndl(rctl_hndl_t); +void rctl_add_default_limit(const char *, rctl_qty_t, rctl_priv_t, uint_t); +void rctl_add_legacy_limit(const char *, const char *, const char *, + rctl_qty_t, rctl_qty_t); + +rctl_qty_t rctl_model_maximum(rctl_dict_entry_t *, struct proc *); +rctl_qty_t rctl_model_value(rctl_dict_entry_t *, struct proc *, rctl_qty_t); + +int rctl_invalid_value(rctl_dict_entry_t *, rctl_val_t *); +rctl_qty_t rctl_enforced_value(rctl_hndl_t, rctl_set_t *, struct proc *); + +int rctl_test(rctl_hndl_t, rctl_set_t *, struct proc *, rctl_qty_t, uint_t); +int rctl_action(rctl_hndl_t, rctl_set_t *, struct proc *, uint_t); + +int rctl_test_entity(rctl_hndl_t, rctl_set_t *, struct proc *, + rctl_entity_p_t *, rctl_qty_t, uint_t); +int rctl_action_entity(rctl_hndl_t, rctl_set_t *, struct proc *, + rctl_entity_p_t *, uint_t); + +int rctl_val_cmp(rctl_val_t *, rctl_val_t *, int); +int rctl_val_list_insert(rctl_val_t **, rctl_val_t *); + +rctl_set_t *rctl_set_create(void); +rctl_set_t *rctl_entity_obtain_rset(rctl_dict_entry_t *, struct proc *); +rctl_alloc_gp_t *rctl_set_init_prealloc(rctl_entity_t); +rctl_set_t *rctl_set_init(rctl_entity_t, struct proc *, rctl_entity_p_t *, + rctl_set_t *, rctl_alloc_gp_t *); +rctl_alloc_gp_t *rctl_set_dup_prealloc(rctl_set_t *); +int rctl_set_dup_ready(rctl_set_t *, rctl_alloc_gp_t *); +rctl_set_t *rctl_set_dup(rctl_set_t *, struct proc *, struct proc *, + rctl_entity_p_t *, rctl_set_t *, rctl_alloc_gp_t *, int); +void rctl_set_reset(rctl_set_t *, struct proc *, rctl_entity_p_t *); +void rctl_set_tearoff(rctl_set_t *, struct proc *); +int rctl_set_find(rctl_set_t *, rctl_hndl_t, rctl_t **); +void rctl_set_free(rctl_set_t *); + +void rctl_prealloc_destroy(rctl_alloc_gp_t *); + +size_t rctl_build_name_buf(char **); + +int rctl_global_get(const char *name, rctl_dict_entry_t *); +int rctl_global_set(const char *name, rctl_dict_entry_t *); + +int rctl_local_delete(rctl_hndl_t, rctl_val_t *, struct proc *p); +int rctl_local_insert(rctl_hndl_t, rctl_val_t *, struct proc *p); +int rctl_local_insert_all(rctl_hndl_t, rctl_val_t *, rctl_val_t *, + struct proc *p); +int rctl_local_replace_all(rctl_hndl_t, rctl_val_t *, rctl_val_t *, + struct proc *p); +int rctl_local_get(rctl_hndl_t, rctl_val_t *, rctl_val_t *, struct proc *p); +int rctl_local_replace(rctl_hndl_t, rctl_val_t *, rctl_val_t *, + struct proc *p); + +/* tag declaration to appease the compiler */ +struct cred; +rctl_alloc_gp_t *rctl_rlimit_set_prealloc(uint_t); +int rctl_rlimit_set(rctl_hndl_t, struct proc *, struct rlimit64 *, + rctl_alloc_gp_t *, int, int, const struct cred *); +int rctl_rlimit_get(rctl_hndl_t, struct proc *, struct rlimit64 *); + +/* specific rctl utility functions */ +int rctl_incr_locked_mem(struct proc *, struct kproject *, rctl_qty_t, + int); +void rctl_decr_locked_mem(struct proc *, struct kproject *, rctl_qty_t, + int); +int rctl_incr_swap(struct proc *, struct zone *, size_t); +void rctl_decr_swap(struct zone *, size_t); + +int rctl_incr_lofi(struct proc *, struct zone *, size_t); +void rctl_decr_lofi(struct zone *, size_t); + +struct kstat *rctl_kstat_create_zone(struct zone *, char *, uchar_t, uint_t, + uchar_t); + +struct kstat *rctl_kstat_create_project(struct kproject *, char *, uchar_t, + uint_t, uchar_t); + +struct kstat *rctl_kstat_create_task(struct task *, char *, uchar_t, + uint_t, uchar_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/rctl_impl.h b/illumos-x86_64/usr/include/sys/rctl_impl.h new file mode 100644 index 00000000..08f9a35e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rctl_impl.h @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RCTL_IMPL_H +#define _SYS_RCTL_IMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RCTLCTL_GET 0 +#define RCTLCTL_SET 1 + +#ifndef _KERNEL + +extern int rctlctl(const char *, rctlblk_t *, int); +extern size_t rctllist(char *, size_t); +extern int setprojrctl(const char *, rctlblk_t *, size_t, int); + +#endif /* _KERNEL */ + +typedef struct rctl_opaque { + rctl_qty_t rcq_value; + rctl_qty_t rcq_enforced_value; + rctl_priv_t rcq_privilege; + int rcq_global_flagaction; + int rcq_global_syslog_level; + int rcq_local_flagaction; + int rcq_local_signal; + id_t rcq_local_recipient_pid; + hrtime_t rcq_firing_time; +} rctl_opaque_t; + +extern uint_t rlim_fd_cur; +extern uint_t rlim_fd_max; + +/* Given an array of rctlblk_t calculate the address of the n'th element */ +#define RCTLBLK_INC(blk, n) (rctlblk_t *)(((char *)blk) \ + + (n * rctlblk_size())) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RCTL_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/rds.h b/illumos-x86_64/usr/include/sys/rds.h new file mode 100644 index 00000000..087c1257 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rds.h @@ -0,0 +1,391 @@ +/* + * This file contains definitions used in OFED defined user/kernel + * interfaces. These are imported from the OFED header . Oracle + * elects to have and use the contents of under and governed + * by the OpenIB.org BSD license (see below for full license text). However, + * the following notice accompanied the original version of this file: + */ +/* + * Copyright (c) 2008 Oracle. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +#ifndef _SYS_RDS_H +#define _SYS_RDS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if !(defined(__SVR4) && defined(__sun)) +#include +#else +#include +#include +#endif + +/* + * These sparse annotated types shouldn't be in any user + * visible header file. We should clean this up rather + * than kludging around them. + */ +#if !(defined(__SVR4) && defined(__sun)) +#ifndef __KERNEL__ +#define __be16 u_int16_t +#define __be32 u_int32_t +#define __be64 u_int64_t +#endif +#else +#define u_int8_t uint8_t +#define u_int16_t uint16_t +#define u_int32_t uint32_t +#define u_int64_t uint64_t +#endif + +#define RDS_IB_ABI_VERSION 0x301 + +#define AF_RDS AF_INET_OFFLOAD +#define PF_RDS AF_INET_OFFLOAD +#define SOL_RDS 272 + +/* + * setsockopt/getsockopt for SOL_RDS + */ +#define RDS_CANCEL_SENT_TO 1 +#define RDS_GET_MR 2 +#define RDS_FREE_MR 3 +/* deprecated: RDS_BARRIER 4 */ +#define RDS_RECVERR 5 +#define RDS_CONG_MONITOR 6 +#define RDS_GET_MR_FOR_DEST 7 + + +/* + * Control message types for SOL_RDS. + * + * CMSG_RDMA_ARGS (sendmsg) + * Request a RDMA transfer to/from the specified + * memory ranges. + * The cmsg_data is a struct rds_rdma_args. + * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg) + * Kernel informs application about intended + * source/destination of a RDMA transfer + * RDS_CMSG_RDMA_MAP (sendmsg) + * Application asks kernel to map the given + * memory range into a IB MR, and send the + * R_Key along in an RDS extension header. + * The cmsg_data is a struct rds_get_mr_args, + * the same as for the GET_MR setsockopt. + * RDS_CMSG_RDMA_STATUS (recvmsg) + * Returns the status of a completed RDMA operation. + */ +#define RDS_CMSG_RDMA_ARGS 1 +#define RDS_CMSG_RDMA_DEST 2 +#define RDS_CMSG_RDMA_MAP 3 +#define RDS_CMSG_RDMA_STATUS 4 +#define RDS_CMSG_CONG_UPDATE 5 + +#define RDS_INFO_FIRST 10000 +#define RDS_INFO_COUNTERS 10000 +#define RDS_INFO_CONNECTIONS 10001 +/* 10002 aka RDS_INFO_FLOWS is deprecated */ +#define RDS_INFO_SEND_MESSAGES 10003 +#define RDS_INFO_RETRANS_MESSAGES 10004 +#define RDS_INFO_RECV_MESSAGES 10005 +#define RDS_INFO_SOCKETS 10006 +#define RDS_INFO_TCP_SOCKETS 10007 +#define RDS_INFO_IB_CONNECTIONS 10008 +#define RDS_INFO_CONNECTION_STATS 10009 +#define RDS_INFO_IWARP_CONNECTIONS 10010 +#define RDS_INFO_LAST 10010 + +#if defined(__SVR4) && defined(__sun) +struct rds_info_arg { + uint64_t lenp; + uint64_t datap; +}; +#endif + +#ifndef __lock_lint +#pragma pack(1) +struct rds_info_counter { + u_int8_t name[32]; + u_int64_t value; +} __attribute__((packed)); +#pragma pack() +#else +struct rds_info_counter { + u_int8_t name[32]; + u_int64_t value; +}; +#endif + +#define RDS_INFO_CONNECTION_FLAG_SENDING 0x01 +#define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02 +#define RDS_INFO_CONNECTION_FLAG_CONNECTED 0x04 + +#define TRANSNAMSIZ 16 + +#ifndef __lock_lint +#pragma pack(1) +struct rds_info_connection { + u_int64_t next_tx_seq; + u_int64_t next_rx_seq; + u_int32_t laddr; + u_int32_t faddr; + u_int8_t transport[TRANSNAMSIZ]; /* null term ascii */ + u_int8_t flags; +} __attribute__((packed)); +#pragma pack() +#else +struct rds_info_connection { + u_int64_t next_tx_seq; + u_int64_t next_rx_seq; + u_int32_t laddr; + u_int32_t faddr; + u_int8_t transport[TRANSNAMSIZ]; /* null term ascii */ + u_int8_t flags; +}; +#endif + +#ifndef __lock_lint +#pragma pack(1) +struct rds_info_flow { + u_int32_t laddr; + u_int32_t faddr; + u_int32_t bytes; + u_int16_t lport; + u_int16_t fport; +} __attribute__((packed)); +#pragma pack() +#else +struct rds_info_flow { + u_int32_t laddr; + u_int32_t faddr; + u_int32_t bytes; + u_int16_t lport; + u_int16_t fport; +}; +#endif + +#define RDS_INFO_MESSAGE_FLAG_ACK 0x01 +#define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02 + +#ifndef __lock_lint +#pragma pack(1) +struct rds_info_message { + u_int64_t seq; + u_int32_t len; + u_int32_t laddr; + u_int32_t faddr; + u_int16_t lport; + u_int16_t fport; + u_int8_t flags; +} __attribute__((packed)); +#pragma pack() +#else +struct rds_info_message { + u_int64_t seq; + u_int32_t len; + u_int32_t laddr; + u_int32_t faddr; + u_int16_t lport; + u_int16_t fport; + u_int8_t flags; +}; +#endif + +#ifndef __lock_lint +#pragma pack(1) +struct rds_info_socket { + u_int32_t sndbuf; + u_int32_t bound_addr; + u_int32_t connected_addr; + u_int16_t bound_port; + u_int16_t connected_port; + u_int32_t rcvbuf; + u_int64_t inum; +} __attribute__((packed)); +#pragma pack() +#else +struct rds_info_socket { + u_int32_t sndbuf; + u_int32_t bound_addr; + u_int32_t connected_addr; + u_int16_t bound_port; + u_int16_t connected_port; + u_int32_t rcvbuf; + u_int64_t inum; +}; +#endif + +#ifndef __lock_lint +#pragma pack(1) +struct rds_info_tcp_socket { + u_int32_t local_addr; + u_int16_t local_port; + u_int32_t peer_addr; + u_int16_t peer_port; + u_int64_t hdr_rem; + u_int64_t data_rem; + u_int32_t last_sent_nxt; + u_int32_t last_expected_una; + u_int32_t last_seen_una; +} __attribute__((packed)); +#pragma pack() +#else +struct rds_info_tcp_socket { + u_int32_t local_addr; + u_int16_t local_port; + u_int32_t peer_addr; + u_int16_t peer_port; + u_int64_t hdr_rem; + u_int64_t data_rem; + u_int32_t last_sent_nxt; + u_int32_t last_expected_una; + u_int32_t last_seen_una; +} __attribute__((packed)); +}; +#endif + +#define RDS_IB_GID_LEN 16 +struct rds_info_rdma_connection { + u_int32_t src_addr; + u_int32_t dst_addr; + uint8_t src_gid[RDS_IB_GID_LEN]; + uint8_t dst_gid[RDS_IB_GID_LEN]; + + uint32_t max_send_wr; + uint32_t max_recv_wr; + uint32_t max_send_sge; + uint32_t rdma_mr_max; + uint32_t rdma_mr_size; +}; + +/* + * Congestion monitoring. + * Congestion control in RDS happens at the host connection + * level by exchanging a bitmap marking congested ports. + * By default, a process sleeping in poll() is always woken + * up when the congestion map is updated. + * With explicit monitoring, an application can have more + * fine-grained control. + * The application installs a 64bit mask value in the socket, + * where each bit corresponds to a group of ports. + * When a congestion update arrives, RDS checks the set of + * ports that are now uncongested against the list bit mask + * installed in the socket, and if they overlap, we queue a + * cong_notification on the socket. + * + * To install the congestion monitor bitmask, use RDS_CONG_MONITOR + * with the 64bit mask. + * Congestion updates are received via RDS_CMSG_CONG_UPDATE + * control messages. + * + * The correspondence between bits and ports is + * 1 << (portnum % 64) + */ +#define RDS_CONG_MONITOR_SIZE 64 +#define RDS_CONG_MONITOR_BIT(port) \ + (((unsigned int) port) % RDS_CONG_MONITOR_SIZE) +#define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port)) + +/* + * RDMA related types + */ + +/* + * This encapsulates a remote memory location. + * In the current implementation, it contains the R_Key + * of the remote memory region, and the offset into it + * (so that the application does not have to worry about + * alignment). + */ +typedef u_int64_t rds_rdma_cookie_t; + +struct rds_iovec { + u_int64_t addr; + u_int64_t bytes; +}; + +struct rds_get_mr_args { + struct rds_iovec vec; + u_int64_t cookie_addr; + uint64_t flags; +}; + +struct rds_get_mr_for_dest_args { + struct sockaddr_storage dest_addr; + struct rds_iovec vec; + u_int64_t cookie_addr; + uint64_t flags; +}; + + +struct rds_free_mr_args { + rds_rdma_cookie_t cookie; + u_int64_t flags; +}; + +struct rds_rdma_args { + rds_rdma_cookie_t cookie; + struct rds_iovec remote_vec; + u_int64_t local_vec_addr; + u_int64_t nr_local; + u_int64_t flags; + u_int64_t user_token; +}; + +struct rds_rdma_notify { + u_int64_t user_token; + int32_t status; +}; + +#define RDS_RDMA_SUCCESS 0 +#define RDS_RDMA_REMOTE_ERROR 1 +#define RDS_RDMA_CANCELED 2 +#define RDS_RDMA_DROPPED 3 +#define RDS_RDMA_OTHER_ERROR 4 + +/* + * Common set of flags for all RDMA related structs + */ +#define RDS_RDMA_READWRITE 0x0001 +#define RDS_RDMA_FENCE 0x0002 /* use FENCE for immediate send */ +#define RDS_RDMA_INVALIDATE 0x0004 /* invalidate R_Key after freeing MR */ +#define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */ +#define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */ +#define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RDS_H */ diff --git a/illumos-x86_64/usr/include/sys/reboot.h b/illumos-x86_64/usr/include/sys/reboot.h new file mode 100644 index 00000000..80dd7c76 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/reboot.h @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_REBOOT_H +#define _SYS_REBOOT_H + +#ifndef _ASM +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Boot flags and flags to "reboot" system call. + * + * Not all of these necessarily apply to all machines. + */ +#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */ + +#define RB_ASKNAME 0x00000001 /* prompt for boot file name */ +#define RB_SINGLE 0x00000002 /* reboot to single user only */ +#define RB_NOSYNC 0x00000004 /* dont sync before reboot */ +#define RB_HALT 0x00000008 /* don't reboot, just halt */ +#define RB_INITNAME 0x00000010 /* name given for /etc/init */ +#define RB_NOBOOTRC 0x00000020 /* don't run /etc/rc.boot */ +#define RB_DEBUG 0x00000040 /* being run under debugger */ +#define RB_DUMP 0x00000080 /* dump system core */ +#define RB_WRITABLE 0x00000100 /* mount root read/write */ +#define RB_STRING 0x00000200 /* pass boot args to prom monitor */ +#define RB_CONFIG 0x00000800 /* pass to init on a boot -c */ +#define RB_RECONFIG 0x00001000 /* pass to init on a boot -r */ +#define RB_VERBOSE 0x00002000 /* set for chatty boot */ +#define RB_FORTHDEBUG 0x00004000 /* load forthdebug module */ +#define RB_FORTHDEBUGDBP 0x00008000 /* load forthdebug, enable def bpt */ +#define RB_KMDB 0x00020000 /* load kmdb during boot */ +#define RB_NOBOOTCLUSTER 0x00040000 /* don't boot as a cluster */ +#define RB_DEBUGENTER 0x00080000 /* enter the debugger at boot */ + +#ifndef _ASM + +extern int reboot(int, char *); + +#if defined(_KERNEL) + +extern int boothowto; + +#if defined(_BOOT) +extern void bootflags(char *, size_t); +#else +struct bootops; +extern void bootflags(struct bootops *); +#endif /* _BOOT */ + +#endif /* _KERNEL */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_REBOOT_H */ diff --git a/illumos-x86_64/usr/include/sys/refstr.h b/illumos-x86_64/usr/include/sys/refstr.h new file mode 100644 index 00000000..a92dde06 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/refstr.h @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_REFSTR_H +#define _SYS_REFSTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Strings with reference counts. + * The 'struct refstr' definition is private to the refstr.c module. + */ + +typedef struct refstr refstr_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +refstr_t *refstr_alloc(const char *); +const char *refstr_value(refstr_t *); +void refstr_hold(refstr_t *); +void refstr_rele(refstr_t *); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_REFSTR_H */ diff --git a/illumos-x86_64/usr/include/sys/refstr_impl.h b/illumos-x86_64/usr/include/sys/refstr_impl.h new file mode 100644 index 00000000..40473045 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/refstr_impl.h @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_REFSTR_IMPL_H +#define _SYS_REFSTR_IMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Strings with reference counts. + * The refstr_t definition is private to the implementation. + * just declares it as a 'struct refstr'. + * We require there never to be an allocation larger than 4 Gbytes. + */ + +struct refstr { + uint32_t rs_size; /* allocation size */ + uint32_t rs_refcnt; /* reference count */ + char rs_string[1]; /* constant string */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_REFSTR_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/reg.h b/illumos-x86_64/usr/include/sys/reg.h new file mode 100644 index 00000000..bdfb0ad4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/reg.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_REG_H +#define _SYS_REG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file only exists for i386 backwards compatibility. + * Kernel code should not include it. + */ + +#ifdef _KERNEL +#error "kernel include of reg.h" +#else +#include +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_REG_H */ diff --git a/illumos-x86_64/usr/include/sys/regset.h b/illumos-x86_64/usr/include/sys/regset.h new file mode 100644 index 00000000..5e2fe2ac --- /dev/null +++ b/illumos-x86_64/usr/include/sys/regset.h @@ -0,0 +1,208 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_REGSET_H +#define _SYS_REGSET_H + +#include + +#if !defined(_ASM) +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The names and offsets defined here should be specified by the + * AMD64 ABI suppl. + * + * We make fsbase and gsbase part of the lwp context (since they're + * the only way to access the full 64-bit address range via the segment + * registers) and thus belong here too. However we treat them as + * read-only; if %fs or %gs are updated, the results of the descriptor + * table lookup that those updates implicitly cause will be reflected + * in the corresponding fsbase and/or gsbase values the next time the + * context can be inspected. However it is NOT possible to override + * the fsbase/gsbase settings via this interface. + * + * Direct modification of the base registers (thus overriding the + * descriptor table base address) can be achieved with _lwp_setprivate. + */ + +#define REG_GSBASE 27 +#define REG_FSBASE 26 +#define REG_DS 25 +#define REG_ES 24 + +#define REG_GS 23 +#define REG_FS 22 +#define REG_SS 21 +#define REG_RSP 20 +#define REG_RFL 19 +#define REG_CS 18 +#define REG_RIP 17 +#define REG_ERR 16 +#define REG_TRAPNO 15 +#define REG_RAX 14 +#define REG_RCX 13 +#define REG_RDX 12 +#define REG_RBX 11 +#define REG_RBP 10 +#define REG_RSI 9 +#define REG_RDI 8 +#define REG_R8 7 +#define REG_R9 6 +#define REG_R10 5 +#define REG_R11 4 +#define REG_R12 3 +#define REG_R13 2 +#define REG_R14 1 +#define REG_R15 0 + +/* + * The names and offsets defined here are specified by i386 ABI suppl. + */ + +#define SS 18 /* only stored on a privilege transition */ +#define UESP 17 /* only stored on a privilege transition */ +#define EFL 16 +#define CS 15 +#define EIP 14 +#define ERR 13 +#define TRAPNO 12 +#define EAX 11 +#define ECX 10 +#define EDX 9 +#define EBX 8 +#define ESP 7 +#define EBP 6 +#define ESI 5 +#define EDI 4 +#define DS 3 +#define ES 2 +#define FS 1 +#define GS 0 + +/* aliases for portability */ + +#if defined(__amd64) + +#define REG_PC REG_RIP +#define REG_FP REG_RBP +#define REG_SP REG_RSP +#define REG_PS REG_RFL +#define REG_R0 REG_RAX +#define REG_R1 REG_RDX + +#else /* __i386 */ + +#define REG_PC EIP +#define REG_FP EBP +#define REG_SP UESP +#define REG_PS EFL +#define REG_R0 EAX +#define REG_R1 EDX + +#endif /* __i386 */ + +#define NGREG _NGREG + +#if !defined(_ASM) + +#ifdef __i386 +/* + * (This structure definition is specified in the i386 ABI supplement) + * It's likely we can just get rid of the struct __old_fpu or maybe + * move it to $SRC/uts/intel/os/fpu.c which appears to be the + * only place that uses it. See: www.illumos.org/issues/6284 + */ +typedef struct __old_fpu { + union { + struct __old_fpchip_state /* fp extension state */ + { + int state[27]; /* 287/387 saved state */ + int status; /* status word saved at */ + /* exception */ + } fpchip_state; + struct __old_fp_emul_space /* for emulator(s) */ + { + char fp_emul[246]; + char fp_epad[2]; + } fp_emul_space; + int f_fpregs[62]; /* union of the above */ + } fp_reg_set; + long f_wregs[33]; /* saved weitek state */ +} __old_fpregset_t; +#endif /* __i386 */ + +#if defined(__amd64) +#define _NDEBUGREG 16 +#else +#define _NDEBUGREG 8 +#endif + +typedef struct dbregset { + unsigned long debugreg[_NDEBUGREG]; +} dbregset_t; + +#endif /* _ASM */ + +/* + * The version of privregs.h that is used on implementations that run on + * processors that support the AMD64 instruction set is deliberately not + * imported here. + * + * The amd64 'struct regs' definition may -not- compatible with either + * 32-bit or 64-bit core file contents, nor with the ucontext. As a result, + * the 'regs' structure cannot be used portably by applications, and should + * only be used by the kernel implementation. + * + * The inclusion of the i386 version of privregs.h allows for some limited + * source compatibility with 32-bit applications who expect to use + * 'struct regs' to match the context of a 32-bit core file, or a ucontext_t. + * + * Note that the ucontext_t actually describes the general register in terms + * of the gregset_t data type, as described in this file. Note also + * that the core file content is defined by core(5) in terms of data types + * defined by procfs -- see proc(5). + */ +#if defined(__i386) && \ + (!defined(_KERNEL) && !defined(_XPG4_2) || defined(__EXTENSIONS__)) +#include +#endif /* __i386 (!_KERNEL && !_XPG4_2 || __EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_REGSET_H */ diff --git a/illumos-x86_64/usr/include/sys/resource.h b/illumos-x86_64/usr/include/sys/resource.h new file mode 100644 index 00000000..d65ca00f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/resource.h @@ -0,0 +1,282 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Joyent, Inc. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_RESOURCE_H +#define _SYS_RESOURCE_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Process priority specifications + */ +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 +#define PRIO_GROUP 3 +#define PRIO_SESSION 4 +#define PRIO_LWP 5 +#define PRIO_TASK 6 +#define PRIO_PROJECT 7 +#define PRIO_ZONE 8 +#define PRIO_CONTRACT 9 + +/* + * Resource limits + */ +#define RLIMIT_CPU 0 /* cpu time in seconds */ +#define RLIMIT_FSIZE 1 /* maximum file size */ +#define RLIMIT_DATA 2 /* data size */ +#define RLIMIT_STACK 3 /* stack size */ +#define RLIMIT_CORE 4 /* core file size */ +#define RLIMIT_NOFILE 5 /* file descriptors */ +#define RLIMIT_VMEM 6 /* maximum mapped memory */ +#define RLIMIT_AS RLIMIT_VMEM + +#define RLIM_NLIMITS 7 /* number of resource limits */ + +#if defined(_LP64) + +typedef unsigned long rlim_t; + +#define RLIM_INFINITY ((rlim_t)-3) +#define RLIM_SAVED_MAX ((rlim_t)-2) +#define RLIM_SAVED_CUR ((rlim_t)-1) + +#else /* _LP64 */ + +/* + * The definitions of the following types and constants differ between the + * regular and large file compilation environments. + */ +#if _FILE_OFFSET_BITS == 32 + +typedef unsigned long rlim_t; + +#define RLIM_INFINITY 0x7fffffff +#define RLIM_SAVED_MAX 0x7ffffffe +#define RLIM_SAVED_CUR 0x7ffffffd + +#else /* _FILE_OFFSET_BITS == 32 */ + +typedef u_longlong_t rlim_t; + +#define RLIM_INFINITY ((rlim_t)-3) +#define RLIM_SAVED_MAX ((rlim_t)-2) +#define RLIM_SAVED_CUR ((rlim_t)-1) + +#endif /* _FILE_OFFSET_BITS == 32 */ + +#endif /* _LP64 */ + +#if defined(_SYSCALL32) + +/* Kernel's view of user ILP32 rlimits */ + +typedef uint32_t rlim32_t; + +#define RLIM32_INFINITY 0x7fffffff +#define RLIM32_SAVED_MAX 0x7ffffffe +#define RLIM32_SAVED_CUR 0x7ffffffd + +struct rlimit32 { + rlim32_t rlim_cur; /* current limit */ + rlim32_t rlim_max; /* maximum value for rlim_cur */ +}; + +#endif /* _SYSCALL32 */ + +struct rlimit { + rlim_t rlim_cur; /* current limit */ + rlim_t rlim_max; /* maximum value for rlim_cur */ +}; + +/* transitional large file interface versions */ +#ifdef _LARGEFILE64_SOURCE + +typedef u_longlong_t rlim64_t; + +#define RLIM64_INFINITY ((rlim64_t)-3) +#define RLIM64_SAVED_MAX ((rlim64_t)-2) +#define RLIM64_SAVED_CUR ((rlim64_t)-1) + +struct rlimit64 { + rlim64_t rlim_cur; /* current limit */ + rlim64_t rlim_max; /* maximum value for rlim_cur */ +}; + +#endif + +/* + * Although the saved rlimits were initially introduced by the large file API, + * they are now available for all resource limits on the 64-bit kernel and for + * cpu time and file size limits on the 32-bit kernel. + */ +#if defined(_LP64) + +#define RLIM_SAVED(x) (1) /* save all resource limits */ +#define RLIM_NSAVED RLIM_NLIMITS /* size of u_saved_rlimits[] */ + +#else /* _LP64 */ + +#define RLIM_SAVED(x) (x <= RLIMIT_FSIZE) /* cpu time and file size */ +#define RLIM_NSAVED (RLIMIT_FSIZE + 1) /* size of u_saved_rlimits[] */ + +#endif /* _LP64 */ + + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* */ + long ru_ixrss; /* */ + long ru_idrss; /* */ + long ru_isrss; /* */ + long ru_minflt; /* any page faults not requiring I/O */ + long ru_majflt; /* any page faults requiring I/O */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* streams messsages sent */ + long ru_msgrcv; /* streams messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +#define _RUSAGESYS_GETRUSAGE 0 /* rusage process */ +#define _RUSAGESYS_GETRUSAGE_CHLD 1 /* rusage child process */ +#define _RUSAGESYS_GETRUSAGE_LWP 2 /* rusage lwp */ +#define _RUSAGESYS_GETVMUSAGE 3 /* getvmusage */ + +#if defined(_SYSCALL32) + +struct rusage32 { + struct timeval32 ru_utime; /* user time used */ + struct timeval32 ru_stime; /* system time used */ + int ru_maxrss; /* */ + int ru_ixrss; /* */ + int ru_idrss; /* */ + int ru_isrss; /* */ + int ru_minflt; /* any page faults not requiring I/O */ + int ru_majflt; /* any page faults requiring I/O */ + int ru_nswap; /* swaps */ + int ru_inblock; /* block input operations */ + int ru_oublock; /* block output operations */ + int ru_msgsnd; /* streams messages sent */ + int ru_msgrcv; /* streams messages received */ + int ru_nsignals; /* signals received */ + int ru_nvcsw; /* voluntary context switches */ + int ru_nivcsw; /* involuntary " */ +}; + +#endif /* _SYSCALL32 */ + + +#ifdef _KERNEL + +#include + +struct proc; + +#else + +#define RUSAGE_SELF 0 +#define RUSAGE_LWP 1 +#define RUSAGE_CHILDREN -1 + + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +/* + * large file compilation environment setup + */ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname setrlimit setrlimit64 +#pragma redefine_extname getrlimit getrlimit64 +#else +#define setrlimit setrlimit64 +#define getrlimit getrlimit64 +#define rlimit rlimit64 +#endif +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +/* + * In the LP64 compilation environment, map large file interfaces + * back to native versions where possible. + */ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname setrlimit64 setrlimit +#pragma redefine_extname getrlimit64 getrlimit +#else +#define setrlimit64 setrlimit +#define getrlimit64 getrlimit +#define rlimit64 rlimit +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern int setrlimit(int, const struct rlimit *); +extern int getrlimit(int, struct rlimit *); + +/* transitional large file interfaces */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int setrlimit64(int, const struct rlimit64 *); +extern int getrlimit64(int, struct rlimit64 *); +#endif /* _LARGEFILE64_SOURCE... */ + +extern int getpriority(int, id_t); +extern int setpriority(int, id_t, int); +extern int getrusage(int, struct rusage *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RESOURCE_H */ diff --git a/illumos-x86_64/usr/include/sys/rlioctl.h b/illumos-x86_64/usr/include/sys/rlioctl.h new file mode 100644 index 00000000..6aef1b9f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rlioctl.h @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1994 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RLIOCTL_H +#define _SYS_RLIOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef TIOCPKT_WINDOW +#define TIOCPKT_WINDOW 0x80 +#endif + +#define TIOCPKT_FLUSHWRITE 0x02 /* flush unprocessed data */ +#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ +#define TIOCPKT_DOSTOP 0x20 /* now do ^S, ^Q */ + +/* + * Rlogin protocol requests begin with two bytes of "RLOGIN_MAGIC". + * See RFC-1282. + */ +#define RLOGIN_MAGIC 0xff + +/* + * RL_IOC_ENABLE starts the module, inserting any (optional) data passed to + * it at the head of the read side queue. + */ +#define RLIOC ('r' << 8) +#define RL_IOC_ENABLE (RLIOC|1) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RLIOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/rsm/rsm.h b/illumos-x86_64/usr/include/sys/rsm/rsm.h new file mode 100644 index 00000000..e99e2028 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rsm/rsm.h @@ -0,0 +1,375 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RSM_RSM_H +#define _SYS_RSM_RSM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define RSM_IOCTL_CONTROLLER 0x00 +#define RSM_IOCTL_EXPORT_SEG 0x10 +#define RSM_IOCTL_IMPORT_SEG 0x20 +#define RSM_IOCTL_QUEUE 0x30 +#define RSM_IOCTL_TOPOLOGY 0x40 +#define RSM_IOCTL_BAR 0x50 +#define RSM_IOCTL_ERRCNT 0x60 +#define RSM_IOCTL_BELL 0x70 +#define RSM_IOCTL_IOVEC 0x80 +#define RSM_IOCTL_MAP_ADDR 0x90 + +#define RSM_IOCTL_ATTR RSM_IOCTL_CONTROLLER + 0x0 /* get device attribute */ +#define RSM_IOCTL_BAR_INFO RSM_IOCTL_CONTROLLER + 0x1 /* get barrier info */ + +#define RSM_IOCTL_CREATE RSM_IOCTL_EXPORT_SEG + 0x1 +#define RSM_IOCTL_BIND RSM_IOCTL_EXPORT_SEG + 0x3 +#define RSM_IOCTL_REBIND RSM_IOCTL_EXPORT_SEG + 0x4 +#define RSM_IOCTL_UNBIND RSM_IOCTL_EXPORT_SEG + 0x5 +#define RSM_IOCTL_PUBLISH RSM_IOCTL_EXPORT_SEG + 0x6 +#define RSM_IOCTL_REPUBLISH RSM_IOCTL_EXPORT_SEG + 0x7 +#define RSM_IOCTL_UNPUBLISH RSM_IOCTL_EXPORT_SEG + 0x8 + +#define RSM_IOCTL_CONNECT RSM_IOCTL_IMPORT_SEG + 0x0 +#define RSM_IOCTL_DISCONNECT RSM_IOCTL_IMPORT_SEG + 0x1 + +#define RSM_IOCTL_TOPOLOGY_SIZE RSM_IOCTL_TOPOLOGY + 0x1 +#define RSM_IOCTL_TOPOLOGY_DATA RSM_IOCTL_TOPOLOGY + 0x2 + +#define RSM_IOCTL_GETV RSM_IOCTL_IOVEC + 0x1 +#define RSM_IOCTL_PUTV RSM_IOCTL_IOVEC + 0x2 + +#define RSM_IOCTL_BAR_OPEN RSM_IOCTL_BAR + 0x1 +#define RSM_IOCTL_BAR_ORDER RSM_IOCTL_BAR + 0x2 +#define RSM_IOCTL_BAR_CLOSE RSM_IOCTL_BAR + 0x3 +#define RSM_IOCTL_BAR_CHECK RSM_IOCTL_BAR + 0x4 + +#define RSM_IOCTL_RING_BELL RSM_IOCTL_BELL + 0x1 +#define RSM_IOCTL_CONSUMEEVENT RSM_IOCTL_BELL + 0x2 + +#define RSM_IOCTL_MAP_TO_ADDR RSM_IOCTL_MAP_ADDR + 0x1 +#define RSM_IOCTL_MAP_TO_NODEID RSM_IOCTL_MAP_ADDR + 0x2 + +#define RSM_IOCTL_CMDGRP(cmd) ((cmd) & 0xfffffff0) + +#define BETWEEN(x, lo, hi) (((x) >= (lo)) && ((x) <= (hi))) + +#define RSM_MAX_IOVLEN 4 +/* + * DEBUG message categories + * 0xABCD: A=module, B=functionality C=operation D=misc + * + */ +#define RSM_KERNEL_AGENT 0x1000 /* kernel agent messages */ +#define RSM_LIBRARY 0x2000 /* rsmapi library messages */ +#define RSM_OPS 0x4000 /* rsmops module messages */ +#define RSM_PATH_MANAGER 0x8000 /* path manager messages */ +#define RSM_MODULE_ALL 0xF000 + +#define RSM_IMPORT 0x0100 /* import operations */ +#define RSM_EXPORT 0x0200 /* export operations */ +#define RSM_LOOPBACK 0x0400 /* loopback mode */ +#define RSM_FUNC_ALL 0x0F00 + +#define RSM_DDI 0x0010 /* dev driver infrastructure */ +#define RSM_IO_ROUTINES 0x0020 /* put/get processing */ +#define RSM_IOCTL 0x0040 /* ioctl processing */ +#define RSM_INTR_CALLBACK 0x0080 /* interrupt processing */ +#define RSM_OPER_ALL 0x00F0 + +#define RSM_FLOWCONTROL 0x0001 /* flow control related */ + +#define RSM_KERNEL_ALL (RSM_KERNEL_AGENT | RSM_PATH_MANAGER | 0x0FFF) +#define RSM_ALL 0xFFFF /* All of the above */ + +/* + * DEBUG message levels + */ +#define RSM_DEBUG_VERBOSE 6 +#define RSM_DEBUG_LVL2 5 +#define RSM_DEBUG_LVL1 4 +#define RSM_DEBUG 3 +#define RSM_NOTICE 2 +#define RSM_WARNING 1 +#define RSM_ERR 0 + +#ifdef DEBUG +extern void dbg_printf(int category, int level, char *fmt, ...); +#define DBG_DEFINE(var, value) int var = (value) +#define DBG_DEFINE_STR(var, value) char *var = (value) +#define DBG_ADDCATEGORY(var, category) (var |= (category)) +#define DBG_PRINTF(message) dbg_printf message +#else +#define DBG_DEFINE(var, value) +#define DBG_DEFINE_STR(var, value) +#define DBG_ADDCATEGORY(var, category) +#define DBG_PRINTF(message) +#endif /* DEBUG */ + +typedef uint16_t rsm_gnum_t; + +/* + * data struct used between rsm base library and kernel agent for IOCTLS + */ +typedef struct { + /* following fields should be identical to rsmapi_controller_attr_t */ + uint_t attr_direct_access_sizes; + uint_t attr_atomic_sizes; + size_t attr_page_size; + size_t attr_max_export_segment_size; + size_t attr_tot_export_segment_size; + ulong_t attr_max_export_segments; + size_t attr_max_import_map_size; + size_t attr_tot_import_map_size; + ulong_t attr_max_import_segments; + /* following fields are for internal use */ + rsm_addr_t attr_controller_addr; +} rsmka_int_controller_attr_t; + +#ifdef _SYSCALL32 +typedef struct { + /* following fields should be identical to rsmapi_controller_attr_t */ + uint32_t attr_direct_access_sizes; + uint32_t attr_atomic_sizes; + uint32_t attr_page_size; + uint32_t attr_max_export_segment_size; + uint32_t attr_tot_export_segment_size; + uint32_t attr_max_export_segments; + uint32_t attr_max_import_map_size; + uint32_t attr_tot_import_map_size; + uint32_t attr_max_import_segments; + /* the following fields are for internal use */ + rsm_addr_t attr_controller_addr; +} rsmka_int_controller_attr32_t; +#endif + +/* kernel agent equivalents of rsm_iovec_t and rsm_scat_gath_t */ +typedef struct { + int io_type; + union { + rsm_localmemory_handle_t handle; + rsm_memseg_id_t segid; + caddr_t vaddr; + } local; + size_t local_offset; + size_t remote_offset; + size_t transfer_len; +} rsmka_iovec_t; + +#ifdef _SYSCALL32 +typedef struct { + int32_t io_type; + uint32_t local; + uint32_t local_offset; + uint32_t remote_offset; + uint32_t transfer_len; +} rsmka_iovec32_t; +#endif + +/* + * The following 2 structures represent the scatter-gather structures used + * within the kernel agent. Note that the io_residual_count and the flags fields + * fields must be contiguous within these structures due to this assumption + * made by the kernel agent when updating them in ddi_copyout. + */ +typedef struct { + rsm_node_id_t local_nodeid; + ulong_t io_request_count; + ulong_t io_residual_count; + uint_t flags; + rsm_memseg_import_handle_t remote_handle; + rsmka_iovec_t *iovec; +} rsmka_scat_gath_t; + +#ifdef _SYSCALL32 +typedef struct { + rsm_node_id_t local_nodeid; + uint32_t io_request_count; + uint32_t io_residual_count; + uint32_t flags; + caddr32_t remote_handle; + caddr32_t iovec; +} rsmka_scat_gath32_t; +#endif + +/* + * Define the number of pollfds upto which we don't allocate memory on heap + * + */ +#define RSM_MAX_POLLFDS 4 + +typedef struct { + minor_t rnum; /* segment's resource number */ + int fdsidx; /* index of the fd in the pollfd array */ + int revent; /* returned event */ +} rsm_poll_event_t; + +#ifdef _SYSCALL32 +typedef struct { + minor_t rnum; + int32_t fdsidx; + int32_t revent; +} rsm_poll_event32_t; +#endif + +typedef struct { + caddr_t seglist; /* array of rsm_poll_event_t */ + uint32_t numents; +} rsm_consume_event_msg_t; + +#ifdef _SYSCALL32 +typedef struct { + caddr32_t seglist; /* array of rsm_poll_event32_t */ + uint32_t numents; +} rsm_consume_event_msg32_t; +#endif + +typedef struct { + int cnum; + caddr_t cname; + int cname_len; + caddr_t arg; + int len; /* size as well */ + caddr_t vaddr; + int off; + rsm_memseg_id_t key; + int acl_len; + rsmapi_access_entry_t *acl; + rsm_node_id_t nodeid; + rsm_addr_t hwaddr; + rsm_permission_t perm; + rsm_barrier_t bar; + rsm_gnum_t gnum; /* segment generation number */ + minor_t rnum; /* segment resource number */ +} rsm_ioctlmsg_t; + +#ifdef _SYSCALL32 +typedef struct { + int32_t cnum; + caddr32_t cname; + int32_t cname_len; + caddr32_t arg; + int32_t len; /* size as well */ + caddr32_t vaddr; + int32_t off; + rsm_memseg_id_t key; + int32_t acl_len; + caddr32_t acl; + rsm_node_id_t nodeid; + rsm_addr_t hwaddr; + rsm_permission_t perm; + rsm_barrier_t bar; + rsm_gnum_t gnum; /* segment generation number */ + minor_t rnum; /* segment resource number */ +} rsm_ioctlmsg32_t; +#endif + +/* + * Remote messaging structures + */ + +/* cookie to exchange between sender and receiver */ +typedef union { + struct { + uint_t index : 8; /* slot number */ + uint_t sequence : 24; /* seq. number */ + } ic; + uint_t value; +}rsmipc_cookie_t; + +/* IPC msg types */ +#define RSMIPC_MSG_SEGCONNECT 0 /* connect seg */ +#define RSMIPC_MSG_DISCONNECT 1 /* disconnect seg */ +#define RSMIPC_MSG_IMPORTING 2 +#define RSMIPC_MSG_NOTIMPORTING 3 +#define RSMIPC_MSG_REPLY 4 /* reply msg */ +#define RSMIPC_MSG_BELL 5 /* post an event */ +#define RSMIPC_MSG_REPUBLISH 6 /* seg republished */ +#define RSMIPC_MSG_SUSPEND 7 /* tell importers to SUSPEND */ +#define RSMIPC_MSG_SUSPEND_DONE 8 /* tell exporters - SUSPEND done */ +#define RSMIPC_MSG_RESUME 9 /* tell importers to RESUME */ +#define RSMIPC_MSG_SQREADY 10 /* sendq ready = I am up */ +#define RSMIPC_MSG_SQREADY_ACK 11 /* sendq ready ack = I am up too */ +#define RSMIPC_MSG_CREDIT 12 /* credits to sender */ + +/* + * Dummy message header + */ +typedef struct rsmipc_msg { + int rsmipc_version; + rsm_node_id_t rsmipc_src; + int rsmipc_type; + rsmipc_cookie_t rsmipc_cookie; + int64_t rsmipc_incn; +}rsmipc_msghdr_t; + + +#define RSM_NO_REPLY 0 /* for rsmipc_send when no reply is expected */ + +/* + * Request message of connect operation + */ +typedef struct rsmipc_request { + rsmipc_msghdr_t rsmipc_hdr; + rsm_memseg_id_t rsmipc_key; /* user key or segid */ + rsm_permission_t rsmipc_perm; + rsm_addr_t rsmipc_adapter_hwaddr; + void *rsmipc_segment_cookie; +}rsmipc_request_t; + +/* + * Message format of the flow control messages + */ +typedef struct rsmipc_controlmsg { + rsmipc_msghdr_t rsmipc_hdr; + int64_t rsmipc_local_incn; + rsm_addr_t rsmipc_adapter_hwaddr; + int32_t rsmipc_credits; /* credits */ +}rsmipc_controlmsg_t; + +/* + * Reply message for connect operation + */ +typedef struct rsmipc_reply { + rsmipc_msghdr_t rsmipc_hdr; + short rsmipc_status; /* error code of remote call */ + uint16_t rsmipc_cnum; /* exported controller addr */ + rsm_memseg_id_t rsmipc_segid; /* segid from remote node */ + size_t rsmipc_seglen; /* exporter segment size */ + mode_t rsmipc_mode; + uid_t rsmipc_uid; + gid_t rsmipc_gid; +}rsmipc_reply_t; + +#ifdef __cplusplus +} +#endif + + +#endif /* _SYS_RSM_RSM_H */ diff --git a/illumos-x86_64/usr/include/sys/rsm/rsm_common.h b/illumos-x86_64/usr/include/sys/rsm/rsm_common.h new file mode 100644 index 00000000..79b4e0d6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rsm/rsm_common.h @@ -0,0 +1,213 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_RSM_RSM_COMMON_H +#define _SYS_RSM_RSM_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define RSM_VERSION 5 + +/* Return values for RSMAPI */ +#define RSM_SUCCESS 0 +#define RSMERR_BAD_LIBRARY_VERSION 1 +#define RSMERR_BAD_TOPOLOGY_PTR 2 +#define RSMERR_BAD_CTLR_HNDL 3 +#define RSMERR_CTLR_NOT_PRESENT 4 +#define RSMERR_BAD_SEG_HNDL 5 +#define RSMERR_SEG_ALREADY_PUBLISHED 6 +#define RSMERR_SEG_NOT_PUBLISHED 7 +#define RSMERR_SEG_NOT_PUBLISHED_TO_NODE 8 +#define RSMERR_SEG_ALREADY_MAPPED 9 +#define RSMERR_SEG_STILL_MAPPED 10 +#define RSMERR_SEG_NOT_MAPPED 11 +#define RSMERR_NOT_CREATOR 12 +#define RSMERR_BAD_BARRIER_PTR 13 +#define RSMERR_BAD_SGIO 14 +#define RSMERR_BAD_LOCALMEM_HNDL 15 +#define RSMERR_BAD_ADDR 16 +#define RSMERR_BAD_MEM_ALIGNMENT 17 +#define RSMERR_BAD_OFFSET 18 +#define RSMERR_MISALIGNED_OFFSET 19 +#define RSMERR_BAD_LENGTH 20 +#define RSMERR_BAD_ACL 21 +#define RSMERR_BAD_SEGID 22 +#define RSMERR_RESERVED_SEGID 23 +#define RSMERR_SEGID_IN_USE 24 +#define RSMERR_BAD_MODE 25 +#define RSMERR_BAD_PERMS 26 +#define RSMERR_PERM_DENIED 27 +#define RSMERR_LOCKS_NOT_SUPPORTED 28 +#define RSMERR_LOCKS_NOT_ENABLED 29 +#define RSMERR_REBIND_NOT_ALLOWED 30 +#define RSMERR_INSUFFICIENT_RESOURCES 31 +#define RSMERR_INSUFFICIENT_MEM 32 +#define RSMERR_MAP_FAILED 33 +#define RSMERR_POLLFD_IN_USE 34 +#define RSMERR_BARRIER_UNINITIALIZED 35 +#define RSMERR_BARRIER_OPEN_FAILED 36 +#define RSMERR_BARRIER_NOT_OPENED 37 +#define RSMERR_BARRIER_FAILURE 38 +#define RSMERR_REMOTE_NODE_UNREACHABLE 39 +#define RSMERR_CONN_ABORTED 40 +#define RSMERR_INTERRUPTED 41 +#define RSMERR_TIMEOUT 42 +#define RSMERR_BAD_APPID 43 +#define RSMERR_BAD_CONF 44 +#define RSMERR_SEG_NOT_CONNECTED 45 + +/* Additional return values for RSMPI */ +#define RSMERR_BAD_DRIVER_VERSION 101 +#define RSMERR_UNSUPPORTED_VERSION 102 +#define RSMERR_DRIVER_NAME_IN_USE 103 +#define RSMERR_DRIVER_NOT_REGISTERED 104 +#define RSMERR_DRIVER_THREAD_RUNNING 105 +#define RSMERR_NEED_THREAD_INIT 106 +#define RSMERR_THREAD_NOT_INITED 107 +#define RSMERR_CTLRS_REGISTERED 108 +#define RSMERR_CTLR_NOT_REGISTERED 109 +#define RSMERR_CTLR_ALREADY_REGISTERED 110 +#define RSMERR_CTLR_IN_USE 111 +#define RSMERR_NAME_TOO_LONG 112 +#define RSMERR_SEG_PUBLISHED 113 +#define RSMERR_SEG_NOT_PUBLISHED_TO_RSM_ADDR 114 +#define RSMERR_SEG_IN_USE 115 +#define RSMERR_BAD_SENDQ_HNDL 116 +#define RSMERR_BAD_ARGS_ERRORS 117 +#define RSMERR_BAD_MSTYPE 118 +#define RSMERR_NO_BACKING_MEM 119 +#define RSMERR_NOT_MEM 120 +#define RSMERR_MEM_ALREADY_BOUND 121 +#define RSMERR_MEM_NOT_BOUND 122 +#define RSMERR_HANDLER_NOT_REGISTERED 123 +#define RSMERR_NO_HANDLER 124 +#define RSMERR_UNBIND_REBIND_NOT_ALLOWED 125 +#define RSMERR_CALLBACKS_NOT_SUPPORTED 126 +#define RSMERR_UNSUPPORTED_OPERATION 127 +#define RSMERR_RSM_ADDR_UNREACHABLE 128 +#define RSMERR_UNKNOWN_RSM_ADDR 129 +#define RSMERR_BAD_BARRIER_HNDL 130 +#define RSMERR_COMM_ERR_MAYBE_DELIVERED 131 +#define RSMERR_COMM_ERR_NOT_DELIVERED 132 +#define RSMERR_QUEUE_FENCE_UP 133 +#define RSMERR_QUEUE_FULL 134 + +#define RSMERR_INTERNAL_ERROR 100 + +/* + * Partition segment id and service id space + * users should only create segments or register handlers + * using segment and service id's from the correct range below + * RSM_DRIVER_PRIVATE enforced in rsm_memseg_export_publish + * and rsm_memseg_import_connect + */ + +#define RSM_DRIVER_PRIVATE_ID_BASE 0 +#define RSM_DRIVER_PRIVATE_ID_END 0x0FFFFF + +#define RSM_CLUSTER_TRANSPORT_ID_BASE 0x100000 +#define RSM_CLUSTER_TRANSPORT_ID_END 0x1FFFFF +#define RSM_RSMLIB_ID_BASE 0x200000 +#define RSM_RSMLIB_ID_END 0x2FFFFF +#define RSM_DLPI_ID_BASE 0x300000 +#define RSM_DLPI_ID_END 0x3FFFFF +#define RSM_HPC_ID_BASE 0x400000 +#define RSM_HPC_ID_END 0x4FFFFF +#define RSM_OPS_ID_BASE 0x500000 +#define RSM_OPS_ID_END 0x5FFFFF + +#define RSM_USER_APP_ID_BASE 0x80000000 +#define RSM_USER_APP_ID_END 0xFFFFFFFF + +/* + * The following definitions and typedef are used to describe the + * permissions associated with all or part of a memory segment. + */ +#define RSM_PERM_NONE 0 +#define RSM_PERM_READ 0400 +#define RSM_PERM_WRITE 0200 +#define RSM_PERM_RDWR (RSM_PERM_READ|RSM_PERM_WRITE) + +/* Maximum io_request_count value in rsm_scat_gath_t */ +#define RSM_MAX_SGIOREQS 16 + +/* + * Direct access sizes bits + */ +typedef enum { + RSM_DAS8 = 1, + RSM_DAS16 = 2, + RSM_DAS32 = 4, + RSM_DAS64 = 8 +}rsm_access_size_t; + +typedef uint64_t rsm_addr_t; +typedef uint32_t rsm_node_id_t; +typedef uint32_t rsm_memseg_id_t; +typedef uint32_t rsm_permission_t; + +struct __rsm_memseg_import_handle; +typedef struct __rsm_memseg_import_handle *rsm_memseg_import_handle_t; + +struct __rsm_memseg_export_handle; +typedef struct __rsm_memseg_export_handle *rsm_memseg_export_handle_t; + +typedef enum { + RSM_BARRIER_SEGMENT = 0x01, + RSM_BARRIER_NODE = 0x02, + RSM_BARRIER_SEGMENT_THREAD = 0x11, + RSM_BARRIER_NODE_THREAD = 0x12 +}rsm_barrier_type_t; + +typedef union { + uint64_t u64; + int64_t i64; + uint32_t u32[2]; + int32_t i32[2]; + uint16_t u16[4]; + int16_t i16[4]; + uint8_t u8[8]; + int8_t i8[8]; + uchar_t uc[8]; + char c[8]; + void *vp; +} rsm_barrier_component_t; + +typedef struct { + rsm_barrier_component_t comp[4]; +} rsm_barrier_t; + +typedef enum { + RSM_BARRIER_MODE_EXPLICIT, RSM_BARRIER_MODE_IMPLICIT +} rsm_barrier_mode_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RSM_RSM_COMMON_H */ diff --git a/illumos-x86_64/usr/include/sys/rsm/rsmapi_common.h b/illumos-x86_64/usr/include/sys/rsm/rsmapi_common.h new file mode 100644 index 00000000..7c127618 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rsm/rsmapi_common.h @@ -0,0 +1,140 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1999-2001, 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RSM_RSMAPI_COMMON_H +#define _SYS_RSM_RSMAPI_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Applications must provide a handle for each region of local memory + * specified in the scatter/gather list used for an rsm_memseg_putv + * rsm_memseg_getv operation. + */ +struct __rsm_localmemory_handle; +typedef struct __rsm_localmemory_handle *rsm_localmemory_handle_t; + +struct __rsmapi_controller_handle; +typedef struct __rsmapi_controller_handle *rsmapi_controller_handle_t; + +typedef struct { + uint_t attr_direct_access_sizes; + uint_t attr_atomic_sizes; + size_t attr_page_size; + size_t attr_max_export_segment_size; + size_t attr_tot_export_segment_size; + ulong_t attr_max_export_segments; + size_t attr_max_import_map_size; + size_t attr_tot_import_map_size; + ulong_t attr_max_import_segments; +} rsmapi_controller_attr_t; + +typedef struct { + rsm_node_id_t ae_node; /* node id allowed access */ + rsm_permission_t ae_permission; /* permissions for node */ +} rsmapi_access_entry_t; + +typedef struct { + void *seg; + uint16_t gnum; + void *privdata; +}rsmapi_barrier_t; + +/* + * The scatter/gather list contains a pointer (iovec) to an io vector array. + * Each array element is of type rsm_io_vect_t + */ + +typedef struct { + int io_type; + union { + rsm_localmemory_handle_t handle; + caddr_t vaddr; + } local; + size_t local_offset; + size_t remote_offset; + size_t transfer_length; +} rsm_iovec_t; + +typedef struct { + rsm_node_id_t local_nodeid; + ulong_t io_request_count; + ulong_t io_residual_count; + uint_t flags; + rsm_memseg_import_handle_t remote_handle; + rsm_iovec_t *iovec; +} rsm_scat_gath_t; + +/* scatter/gather I/O types */ +#define RSM_HANDLE_TYPE 0x01 +#define RSM_VA_TYPE 0x02 + +/* + * The following macro can be used to indicate that rebind and unbind is + * allowed for an exported segment. This flag is used during the export + * segment creation. + */ +#define RSM_ALLOW_REBIND 0x01 + +/* + * This new flag will be used in rsm_memseg_export_create + * to control blocking/noblocking resource allocation + * from RSMAPI layer/interface + */ + +#define RSM_CREATE_SEG_DONTWAIT 0x02 + +/* + * The bits in the flags field in the scatter gather structure can be + * initialized using the following macros. An RSM_SIGPOST_NO_ACCUMULATE + * flag can be ored into the flags value to indicate that when an implicit + * signal post is being done, the events are not to be accumulated. + * This flag is defined below. + */ +#define RSM_IMPLICIT_SIGPOST 0x01 + +/* + * The following macro can be used as the flags argument in + * rsm_intr_signal_post to indicate that the events should not be + * accumulated and then serviced individually. The default value of the + * flags argument for the rsm_intr_signal_post is 0, which indicates that + * the events are accumulated and serviced individually. + * It is important to note here that the value of this macro is 0x02 and + * should not be changed without checking for consistency of use in the + * rsm_memseg_import_getv and rsm_memseg_import_putv calls for an implicit + * signal post. + */ +#define RSM_SIGPOST_NO_ACCUMULATE 0x02 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RSM_RSMAPI_COMMON_H */ diff --git a/illumos-x86_64/usr/include/sys/rsm/rsmka_path_int.h b/illumos-x86_64/usr/include/sys/rsm/rsmka_path_int.h new file mode 100644 index 00000000..09a26fe8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rsm/rsmka_path_int.h @@ -0,0 +1,414 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_RSM_RSMKA_PATH_INT_H +#define _SYS_RSM_RSMKA_PATH_INT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * Taskq setup + * Only one taskq thread is created and only one task is executed + * the task is executed as an infinite loop + */ +#define RSMKA_ONE_THREAD 1 +#define RSMKA_ONE_TASK 1 + +/* Path (path_t) States */ +#define RSMKA_PATH_DOWN 1 +#define RSMKA_PATH_UP 2 +#define RSMKA_PATH_ACTIVE 3 +#define RSMKA_PATH_GOING_DOWN 4 + +#define RSMKA_OPCODE_TYPES 2 + +/* + * Deferred Work Token Index + */ +#define RSMKA_IPC_DOWN_INDEX 0 +#define RSMKA_IPC_UP_INDEX 1 + +/* Deferred Work Opcodes */ +#define RSMKA_IPC_DOWN 1 +#define RSMKA_IPC_UP 2 + +/* Flags */ +#define RSMKA_NO_SLEEP 1 +#define RSMKA_USE_COOKIE 2 +#define RSMKA_NOHOLD 4 + + +/* + * A work token is enqueued on the workqueue (singly linked list) + * when pathup or pathdown processing is to be done by the deferred work + * thread. Token are enqueued at the end of the queue and processed + * from the front of the queue. + */ +typedef struct work_token { + struct work_token *next; /* pointer to next token */ + int opcode; /* opcode for work to do */ +} work_token_t; + +typedef struct workqueue { + work_token_t *head; /* start of work queue */ + work_token_t *tail; /* end of work queue */ + kmutex_t work_mutex; /* protects queue add/delete */ + kcondvar_t work_cv; /* synchronize deferred thread */ +} work_queue_t; + +/* + * a pointer to srv_handler_arg is registered along with the handler + * and is passed to the rsm_srv_func - the service handler when it + * is invoked. + */ +typedef struct srv_handler_arg { + char adapter_name[MAXNAMELEN]; + int adapter_instance; + rsm_addr_t adapter_hwaddr; +} srv_handler_arg_t; + +typedef struct msgbuf_elem { + boolean_t active; + rsmipc_request_t msg; +} msgbuf_elem_t; + +/* + * receive buffer object + * procmsg_cnt - receivers count of messages processed since sending credits + * msgbuf_queue - an array-based circular queue of messages received + * msgbuf_head - index pointing to the head of msgbuf_queue + * msgbuf_head - index pointing to the tail of msgbuf_queue + * msgbuf_cnt - number of valid entries in msgbuf_queue + */ +typedef struct recv_info { + int procmsg_cnt; + int rem_sendq_ready; + taskq_t *recv_taskq; + msgbuf_elem_t *msgbuf_queue; + int msgbuf_head; + int msgbuf_tail; + int msgbuf_cnt; +} recv_info_t; + +/* + * sendq_tokens are inserted in a circular list of the ipc_info descriptor + * when a path is added for a remote node. When the path is active the + * rsmpi_sendq_handle will be valid and the sendq token can be used for + * ipc. The sendq_tokens are used in a round robin fashion. + * + * msgbuf_avail - used by sender, number of avail slots in recvrs msgbuf_queue + */ +typedef struct sendq_token { + struct sendq_token *next; + rsm_send_q_handle_t rsmpi_sendq_handle; + int ref_cnt; + int msgbuf_avail; + kcondvar_t sendq_cv; +}sendq_token_t; + + + + +typedef struct path { + struct path *next_path; + rsm_node_id_t remote_node; + int remote_devinst; + rsm_addr_t remote_hwaddr; + int state; + int flags; +#define RSMKA_WAIT_FOR_SQACK 0x0001 /* waiting for SQREADY_ACK */ +#define RSMKA_SQCREATE_PENDING 0x0002 /* sendq_create is pending */ + kmutex_t mutex; + struct adapter *local_adapter; + sendq_token_t sendq_token; + work_token_t work_token[RSMKA_OPCODE_TYPES]; + recv_info_t recv_buffer; +#define procmsg_cnt recv_buffer.procmsg_cnt +#define rem_sendq_ready recv_buffer.rem_sendq_ready +#define msgbuf_queue recv_buffer.msgbuf_queue +#define msgbuf_head recv_buffer.msgbuf_head +#define msgbuf_tail recv_buffer.msgbuf_tail +#define msgbuf_cnt recv_buffer.msgbuf_cnt +#define recv_taskq recv_buffer.recv_taskq + int64_t local_incn; + int64_t remote_incn; +#define RSM_UNKNOWN_INCN 0 + int ref_cnt; + kcondvar_t hold_cv; +} path_t; + + +typedef struct adapter { + struct adapter *next; + struct adapter_listhead *listhead; + int ref_cnt; + kmutex_t mutex; + int instance; + dev_info_t *dip; + rsm_addr_t hwaddr; + path_t *next_path; + rsm_controller_handle_t rsmpi_handle; + rsm_controller_attr_t rsm_attr; + rsm_ops_t *rsmpi_ops; + srv_handler_arg_t *hdlr_argp; +} adapter_t; + + +/* + * typedef struct { + * adapter_t *next_chunk; + * int base; + * int next_index; + * int used_count; + * adapter_t *phys_adapters[MAX_CHUNK_INDEX]; + * } adapter_map_chunks_t; + */ + + +/* + * There is one adapter_listhead for each adapter devname. This + * adapter_listhead stores the number of adapters belonging to + * it. It also stores the number of paths for all the adapters + * belonging to it. + */ +typedef struct adapter_listhead { + struct adapter_listhead *next_listhead; + char adapter_devname[MAXNAMELEN]; + adapter_t *next_adapter; + int ref_cnt; + kmutex_t mutex; + int adapter_count; + int path_count; +} adapter_listhead_t; + + +struct adapter_listhead_list { + adapter_listhead_t *next; + kmutex_t listlock; +}; + + +/* + * One ipc_info descriptor for each remote node + */ +typedef struct ipc_info { + struct ipc_info *next; + rsm_node_id_t remote_node; + boolean_t node_is_alive; + sendq_token_t *token_list; + sendq_token_t *current_token; + kmutex_t token_list_mutex; + int ref_cnt; +} ipc_info_t; + + +#define SQ_TOKEN_TO_PATH(token) \ + ((path_t *)((char *)(token) - ((char *)(&((path_t *)0)->sendq_token)))) + + + +#define WORK_TOKEN_TO_PATH(token, index) \ + ((path_t *)((char *)(token) - \ + ((char *)(&((path_t *)0)->work_token[(index)])))) + + + + +/* + * Descriptor Reference Count macros + */ + +#define ADAPTER_HOLD(adapter) { \ + mutex_enter(&((adapter)->mutex)); \ + (adapter)->ref_cnt++; \ + ASSERT((adapter)->ref_cnt != 0); \ + mutex_exit(&((adapter)->mutex)); \ +} + +#define ADAPTER_RELE(adapter) { \ + mutex_enter(&((adapter)->mutex)); \ + (adapter)->ref_cnt--; \ + ASSERT((adapter)->ref_cnt >= 0); \ + mutex_exit(&((adapter)->mutex)); \ +} + +#define ADAPTER_RELE_NOLOCK(adapter) { \ + ASSERT(MUTEX_HELD(&(adapter)->mutex)); \ + (adapter)->ref_cnt--; \ + ASSERT((adapter)->ref_cnt >= 0); \ +} + +#define PATH_HOLD(path) { \ + mutex_enter(&(path)->mutex); \ + (path)->ref_cnt++; \ + ASSERT((path)->ref_cnt != 0); \ + mutex_exit(&(path)->mutex); \ +} + +#define PATH_HOLD_NOLOCK(path) { \ + ASSERT(MUTEX_HELD(&(path)->mutex)); \ + (path)->ref_cnt++; \ + ASSERT((path)->ref_cnt != 0); \ +} + +#define PATH_RELE(path) { \ + mutex_enter(&(path)->mutex); \ + (path)->ref_cnt--; \ + ASSERT((path)->ref_cnt >= 0); \ + if ((path)->ref_cnt == 0) \ + cv_signal(&(path)->hold_cv); \ + mutex_exit(&(path)->mutex); \ +} + +#define PATH_RELE_NOLOCK(path) { \ + ASSERT(MUTEX_HELD(&(path)->mutex)); \ + (path)->ref_cnt--; \ + ASSERT((path)->ref_cnt >= 0); \ + if ((path)->ref_cnt == 0) \ + cv_signal(&(path)->hold_cv); \ +} + +#define SENDQ_TOKEN_HOLD(path) { \ + (path)->sendq_token.ref_cnt++; \ + ASSERT((path)->sendq_token.ref_cnt != 0); \ +} + +#define SENDQ_TOKEN_RELE(path) { \ + (path)->sendq_token.ref_cnt--; \ + ASSERT((path)->sendq_token.ref_cnt >= 0); \ + if ((path)->sendq_token.ref_cnt == 0) \ + cv_signal(&(path)->sendq_token.sendq_cv); \ +} + +#define IPCINFO_HOLD(ipc_info) { \ + mutex_enter(&ipc_info_lock); \ + (ipc_info)->ref_cnt++; \ + ASSERT((ipc_info)->ref_cnt != 0); \ + mutex_exit(&ipc_info_lock); \ +} + +#define IPCINFO_HOLD_NOLOCK(ipc_info) { \ + ASSERT(MUTEX_HELD(&ipc_info_lock)); \ + (ipc_info)->ref_cnt++; \ + ASSERT((ipc_info)->ref_cnt != 0); \ +} + +#define IPCINFO_RELE(ipc_info) { \ + mutex_enter(&ipc_info_lock); \ + (ipc_info)->ref_cnt--; \ + ASSERT((ipc_info)->ref_cnt >= 0); \ + mutex_exit(&ipc_info_lock); \ +} + +#define IPCINFO_RELE_NOLOCK(ipc_info) { \ + ASSERT(MUTEX_HELD(&ipc_info_lock)); \ + (ipc_info)->ref_cnt--; \ + ASSERT((ipc_info)->ref_cnt >= 0); \ +} +/* + * Topology data structures - The primary structure is struct rsm_topology_t + * The key interconnect data required for segment operations includes the + * cluster nodeids and the controllers (name, hardware address); with + * the fundamental constraint that the controller specified for a segment + * import must have a physical connection with the contorller used in the + * export of the segment. To facilitate applications in the establishment + * of proper and efficient export and import policies, a delineation of the + * interconnect topology is provided by these data structures. + * + * A pointer to an instance of this structure type is returned by a call + * to rsm_get_interconnect_topology(). The application is responsible for + * calling rsm_free_interconnect_topology() to free the allocated memory. + * + * Note: the rsmka_connections_t structure should be always double-word + * aligned. + */ + + +#define RSM_CONNECTION_ACTIVE 3 + + +typedef struct { + rsm_node_id_t local_nodeid; + int local_cntlr_count; +} rsmka_topology_hdr_t; + +typedef struct { + char cntlr_name[MAXNAMELEN]; + rsm_addr_t local_hwaddr; + int remote_cntlr_count; +} rsmka_connections_hdr_t; + + +/* + * An application must not attempt to use a connection unless the + * the connection_state element of struct remote_cntlr_t is equal to + * RSM_CONNECTION_ACTIVE + */ +typedef struct { + rsm_node_id_t remote_nodeid; + char remote_cntlrname[MAXNAMELEN]; + rsm_addr_t remote_hwaddr; + uint_t connection_state; +} rsmka_remote_cntlr_t; + + +/* + * The actual size of the remote_cntlr array is equal to the remote_cntlr_count + * of the connections_hdr_t struct. + */ +typedef struct { + rsmka_connections_hdr_t hdr; + rsmka_remote_cntlr_t remote_cntlr[1]; +} rsmka_connections_t; + +/* + * A pointer to an instance of this structure type is returned by a call + * to rsm_get_interconnect_topology(). The actual size of the connections + * array is equal to the local_cntlr_count of the topology_hdr_t struct. + */ +typedef struct { + rsmka_topology_hdr_t topology_hdr; + caddr_t connections[1]; +} rsmka_topology_t; + +#ifdef _SYSCALL32 +typedef struct { + rsmka_topology_hdr_t topology_hdr; + caddr32_t connections[1]; +} rsmka_topology32_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RSM_RSMKA_PATH_INT_H */ diff --git a/illumos-x86_64/usr/include/sys/rsm/rsmndi.h b/illumos-x86_64/usr/include/sys/rsm/rsmndi.h new file mode 100644 index 00000000..ee609b62 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rsm/rsmndi.h @@ -0,0 +1,342 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RSM_RSMNDI_H +#define _SYS_RSM_RSMNDI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * This structure defines the functions implemented in rsmlib + * that the NDI library can call. + */ +typedef struct { + int version; +#define RSM_LIB_FUNCS_VERSION 1 + int (* rsm_get_hwaddr)( + rsmapi_controller_handle_t handle, + rsm_node_id_t nodeid, + rsm_addr_t *hwaddrp); + int (* rsm_get_nodeid)( + rsmapi_controller_handle_t handle, + rsm_addr_t hwaddr, + rsm_node_id_t *nodeidp); +} rsm_lib_funcs_t; + +/* Library attributes - set by specific NDI libraries */ +typedef struct { + boolean_t rsm_putget_map_reqd; /* put/get require mapping */ + boolean_t rsm_scatgath_map_reqd; /* putv/getv require mapping */ +} rsm_ndlib_attr_t; + +/* The opaque barrier handle used by the RSMNDI plugin for the barrier calls */ +typedef struct rsm_barrier *rsm_barrier_handle_t; + +typedef struct { + + /* + * structure revision number: + */ + int rsm_version; + + /* + * import side memory segment operations + */ + int (* rsm_memseg_import_connect) + (rsmapi_controller_handle_t controller, + rsm_node_id_t node_id, + rsm_memseg_id_t segment_id, + rsm_permission_t perm, + rsm_memseg_import_handle_t *im_memseg); + int (* rsm_memseg_import_disconnect) + (rsm_memseg_import_handle_t im_memseg); + + /* + * import side memory segment operations (read access functions): + */ + int (* rsm_memseg_import_get8) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint8_t *datap, + ulong_t rep_cnt, + boolean_t swap); + int (* rsm_memseg_import_get16) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint16_t *datap, + ulong_t rep_cnt, + boolean_t swap); + int (* rsm_memseg_import_get32) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint32_t *datap, + ulong_t rep_cnt, + boolean_t swap); + int (* rsm_memseg_import_get64) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint64_t *datap, + ulong_t rep_cnt, + boolean_t swap); + int (* rsm_memseg_import_get) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + void *dst_addr, + size_t length); + + /* + * import side memory segment operations (read access functions): + */ + int (* rsm_memseg_import_put8) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint8_t *datap, + ulong_t rep_cnt, + boolean_t swap); + int (* rsm_memseg_import_put16) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint16_t *datap, + ulong_t rep_cnt, + boolean_t swap); + int (* rsm_memseg_import_put32) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint32_t *datap, + ulong_t rep_cnt, + boolean_t swap); + int (* rsm_memseg_import_put64) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint64_t *datap, + ulong_t rep_cnt, + boolean_t swap); + int (* rsm_memseg_import_put) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + void *src_addr, + size_t length); + + /* + * import side memory segment operations (barriers): + */ + int (* rsm_memseg_import_init_barrier) + (rsm_memseg_import_handle_t im_memseg, + rsm_barrier_type_t type, + rsm_barrier_handle_t barrier); + + int (* rsm_memseg_import_open_barrier)(rsm_barrier_handle_t barrier); + + int (* rsm_memseg_import_order_barrier)(rsm_barrier_handle_t barrier); + + int (* rsm_memseg_import_close_barrier)(rsm_barrier_handle_t barrier); + + int (* rsm_memseg_import_destroy_barrier)(rsm_barrier_handle_t barrier); + + int (* rsm_memseg_import_get_mode) + (rsm_memseg_import_handle_t im_memseg, + rsm_barrier_mode_t *mode); + + int (* rsm_memseg_import_set_mode) + (rsm_memseg_import_handle_t im_memseg, + rsm_barrier_mode_t mode); + + + /* + * import side memory segment data transfer operations. + */ + int (* rsm_memseg_import_putv)(rsm_scat_gath_t *sg_io); + int (* rsm_memseg_import_getv)(rsm_scat_gath_t *sg_io); + + int (* rsm_create_localmemory_handle) + (rsmapi_controller_handle_t controller, + rsm_localmemory_handle_t *local_handle_p, + caddr_t local_vaddr, size_t len); + + int (* rsm_free_localmemory_handle) + (rsm_localmemory_handle_t local_handle); + + int (* rsm_register_lib_funcs) + (rsm_lib_funcs_t *libfuncs); + int (* rsm_get_lib_attr) + (rsm_ndlib_attr_t **libattr); + int (* rsm_closedevice) + (rsmapi_controller_handle_t controller); +} rsm_segops_t; + +#define RSM_LIB_VERSION 1 + +/* library internal controller attribute structure */ +typedef struct { + /* following fields should be identical to rsmapi_controller_attr_t */ + uint_t attr_direct_access_sizes; + uint_t attr_atomic_sizes; + size_t attr_page_size; + size_t attr_max_export_segment_size; + size_t attr_tot_export_segment_size; + ulong_t attr_max_export_segments; + size_t attr_max_import_map_size; + size_t attr_tot_import_map_size; + ulong_t attr_max_import_segments; + /* following fields are for internal use */ + rsm_addr_t attr_controller_addr; +} rsm_int_controller_attr_t; + +typedef struct rsm_controller { + void *cntr_privdata; + struct rsm_controller *cntr_next; + int cntr_fd; + int cntr_refcnt; + int cntr_unit; + char *cntr_name; /* generic type eg. sci */ + rsm_segops_t *cntr_segops; + struct rsmqueue *cntr_rqlist; /* list of receive queues */ + rsm_int_controller_attr_t cntr_attr; + rsm_ndlib_attr_t *cntr_lib_attr; + mutex_t cntr_lock; + cond_t cntr_cv; +} rsm_controller_t; + + +typedef enum { + EXPORT_CREATE = 0x1, + EXPORT_BIND, + EXPORT_PUBLISH, + IMPORT_CONNECT, + IMPORT_DISCONNECT, + IMPORT_MAP, + IMPORT_UNMAP +} rsm_seg_state_t; + +typedef struct { + void *rsmseg_privdata; + rsm_segops_t *rsmseg_ops; + rsm_seg_state_t rsmseg_state; + caddr_t rsmseg_vaddr; /* base address of segment */ + size_t rsmseg_size; /* size of segment */ + size_t rsmseg_maplen; /* length of mapped region */ + rsm_node_id_t rsmseg_nodeid; + rsm_memseg_id_t rsmseg_keyid; + int rsmseg_fd; + int rsmseg_pollfd_refcnt; + rsm_permission_t rsmseg_perm; + rsm_controller_t *rsmseg_controller; + rsm_barrier_mode_t rsmseg_barmode; + void *rsmseg_data; + uint16_t *rsmseg_bar; + uint16_t rsmseg_gnum; /* generation number */ + int rsmseg_type; + mutex_t rsmseg_lock; + rsmapi_barrier_t *rsmseg_barrier; /* used in put/get routines */ + offset_t rsmseg_mapoffset; /* seg offset where mmapped */ + uint32_t rsmseg_flags; + minor_t rsmseg_rnum; /* resource number of the segment */ +} rsmseg_handle_t; + +/* + * defines for rsmseg_flags + */ +#define RSM_IMPLICIT_MAP 0x00000001 /* segment mapped implicitly */ + +/* This is a template for all barrier implementations */ +typedef struct { + rsmseg_handle_t *rsmbar_seg; + uint16_t rsmbar_gen; /* generation number */ + void *rsmbar_privdata; +} rsmbar_handle_t; + +/* + * These macros set and get the private data pointer in the opaque barrier + * structure for Network plugins. + */ +#define RSMNDI_BARRIER_SETPRIV(HANDLE, ADDR) \ + ((rsmbar_handle_t *)HANDLE)->rsmbar_privdata = (void *)ADDR; + +#define RSMNDI_BARRIER_GETPRIV(HANDLE) \ + ((rsmbar_handle_t *)HANDLE)->rsmbar_privdata + +#define RSMNDI_BARRIER_GETSEG(HANDLE) \ + ((rsmbar_handle_t *)HANDLE)->rsmbar_seg + +#define RSMNDI_BARRIER_GETUNIT(HANDLE) \ + ((rsmbar_handle_t *)HANDLE)->rsmbar_seg->rsmseg_controller->cntr_unit + +/* + * These macros set and get the private data pointer in the opaque segment + * structure for Network plugins. + */ +#define RSMNDI_SEG_SETPRIV(HANDLE, ADDR) \ + ((rsmseg_handle_t *)HANDLE)->rsmseg_privdata = (void *)ADDR; + +#define RSMNDI_SEG_GETPRIV(HANDLE) \ + ((rsmseg_handle_t *)HANDLE)->rsmseg_privdata + +/* + * Get the controller unit number from a opaque segment structure. + */ + +#define RSMNDI_SEG_GETUNIT(HANDLE) \ + ((rsmseg_handle_t *)HANDLE)->rsmseg_controller->cntr_unit + +/* + * These macros set and get the private data pointer in the opaque controller + * structure for Network plugins. + */ +#define RSMNDI_CNTRLR_SETPRIV(HANDLE, ADDR) \ + ((rsm_controller_t *)HANDLE)->cntr_privdata = (void *)ADDR; + +#define RSMNDI_CNTRLR_GETPRIV(HANDLE) \ + ((rsm_controller_t *)HANDLE)->cntr_privdata + +/* + * Get the controller unit number from a opaque controller structure. + */ +#define RSMNDI_CNTRLR_GETUNIT(HANDLE) \ + ((rsm_controller_t *)HANDLE)->cntr_unit + +/* + * This macro returns an address inside a segment given the segment handle + * and a byte offset. + */ +#define RSMNDI_GET_MAPADDR(HANDLE, OFFSET) \ + (((rsmseg_handle_t *)HANDLE)->rsmseg_vaddr + OFFSET) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RSM_RSMNDI_H */ diff --git a/illumos-x86_64/usr/include/sys/rsm/rsmpi.h b/illumos-x86_64/usr/include/sys/rsm/rsmpi.h new file mode 100644 index 00000000..44d0c545 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rsm/rsmpi.h @@ -0,0 +1,707 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_RSM_RSMPI_H +#define _SYS_RSM_RSMPI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _KERNEL +typedef void * ddi_as_handle_t; +#endif + +#include +#include + +struct __rsm_resource_callback_arg; +typedef struct __rsm_resource_callback_arg *rsm_resource_callback_arg_t; + +typedef void (*rsm_resource_callback_t)(rsm_resource_callback_arg_t); + +struct __rsm_callback_arg; +typedef struct __rsm_callback_arg *rsm_callback_arg_t; + +typedef void (*rsm_callback_t)(rsm_callback_arg_t); + +/* Values for resource callback function pointer */ +#define RSM_RESOURCE_SLEEP (rsm_resource_callback_t)0 +#define RSM_RESOURCE_DONTWAIT (rsm_resource_callback_t)-1 + +/* rsm_seg_create() flags values */ +#define RSM_ALLOW_UNBIND_REBIND 0x01 + +typedef uint_t rsm_intr_t; +typedef rsm_intr_t rsm_intr_service_t; +/* The following definitions used to describe the ranges fro rsm_intr_t */ +#define RSM_INTR_T_DRV_BASE 0 +#define RSM_INTR_T_DRV_END 0x3F +#define RSM_INTR_T_FRM_BASE 0x40 +#define RSM_INTR_T_FRM_END 0x4F +#define RSM_INTR_T_RESERVED_BASE 0x50 +#define RSM_INTR_T_RESERVED_END 0x5F +#define RSM_INTR_T_SUN_BASE 0x60 +#define RSM_INTR_T_SUN_END 0xDF +#define RSM_INTR_T_USR_BASE 0xE0 +#define RSM_INTR_T_USR_END 0xFF +#define RSM_INTR_T_NSVC 0x100 + +/* kstat's ks_name for RSMPI controller drivers */ +#define RSM_KS_NAME "rsmpi_stat" + +/* named kstat component names */ +#define RSM_KS_CTLR_STATE "ctlr_state" /* CHAR */ +#define RSM_KS_ADDR "addr" /* UINT64 */ +#define RSM_KS_EX_MEMSEGS "ex_memsegs" /* UINT32 */ +#define RSM_KS_EX_MEMSEGS_PUB "ex_memsegs_pub" /* UINT32 */ +#define RSM_KS_EX_MEMSEGS_CON "ex_memsegs_con" /* UINT32 */ +#define RSM_KS_BYTES_BOUND "bytes_bound" /* UINT64 */ +#define RSM_KS_IM_MEMSEGS_CON "im_memsegs_con" /* UINT32 */ +#define RSM_KS_SENDQS "sendqs" /* UINT64 */ +#define RSM_KS_HANDLERS "handlers" /* UINT64 */ + +/* The following are the possible values of RSM_KS_CTLR_STATE */ +#define RSM_AE_CTLR_DOWN "rsm_down" +#define RSM_AE_CTLR_UP "rsm_up" + + +struct __rsm_send_q_handle; +typedef struct __rsm_send_q_handle *rsm_send_q_handle_t; + +/* rsm_intr_send_q_create flags values */ +#define RSM_INTR_SEND_Q_NO_FENCE 0x1 +#define RSM_INTR_SEND_Q_FULL_FAIL 0x2 +#define RSM_INTR_SEND_Q_UNRELIABLE 0x4 + +typedef struct { + void *is_data; + size_t is_size; + int is_flags; + clock_t is_wait; +} rsm_send_t; + +/* rsm_send_t flags values */ +#define RSM_INTR_SEND_QUEUE 0x1 +#define RSM_INTR_SEND_DELIVER 0x2 +#define RSM_INTR_SEND_POLL 0x4 +#define RSM_INTR_SEND_SLEEP 0x8 +#define RSM_INTR_SEND_LOWER_FENCE 0x10 + +typedef enum { + RSM_INTR_HAND_UNCLAIMED = 0, + RSM_INTR_HAND_CLAIMED = 1, + RSM_INTR_HAND_CLAIMED_EXCLUSIVE = 2 +} rsm_intr_hand_ret_t; + +typedef enum { + RSM_INTR_Q_OP_CREATE, + RSM_INTR_Q_OP_CONFIGURE, + RSM_INTR_Q_OP_DESTROY, + RSM_INTR_Q_OP_RECEIVE, + RSM_INTR_Q_OP_DROP +} rsm_intr_q_op_t; + +struct __rsm_intr_hand_arg; +typedef struct __rsm_intr_hand_arg *rsm_intr_hand_arg_t; + +struct __rsm_registry_item; +typedef struct __rsm_registry_item *rsm_registry_item_t; + +typedef int rsm_intr_pri_t; + +typedef struct { + rsm_addr_t ae_addr; /* node hwaddr allowed access */ + rsm_permission_t ae_permission; /* permissions for node */ +} rsm_access_entry_t; +/* + * ae_addr can be set to the following value to mean that the permissions + * should apply to all nodes accessible through this RSM controller + */ +#define RSM_ACCESS_PUBLIC 0xFFFF + +struct __rsm_controller_handle; +typedef struct __rsm_controller_handle *rsm_controller_handle_t; + +/* + * The following typedef is used to represent a controller object. + */ +typedef struct rsm_controller_object { + struct rsm_ops *ops; + rsm_controller_handle_t handle; +} rsm_controller_object_t; + +typedef rsm_intr_hand_ret_t (*rsm_intr_hand_t)( + rsm_controller_object_t *controller, + rsm_intr_q_op_t operation, + rsm_addr_t sender, + void *data, + size_t size, + rsm_intr_hand_arg_t arg); + +typedef struct { + enum { RSM_MEM_VADDR, + RSM_MEM_BUF, + RSM_MEM_HANDLE, + RSM_MEM_INVALID } ms_type; + union { + struct { + void *vaddr; + size_t length; + ddi_as_handle_t as; + } vr; + struct buf *bp; + rsm_memseg_export_handle_t handle; + } ms_memory; +#define ms_bp ms_memory.bp +#define ms_vaddr ms_memory.vr.vaddr +#define ms_length ms_memory.vr.length +#define ms_as ms_memory.vr.as +} rsm_memory_local_t; + +typedef struct { + rsm_memory_local_t local_mem; + size_t local_offset; + rsm_memseg_import_handle_t remote_handle; + size_t remote_offset; + size_t transfer_length; +} rsmpi_iovec_t; + +typedef struct { + ulong_t io_request_count; /* size of iovec array */ + ulong_t io_residual_count; /* zero for success */ + uio_seg_t io_segflg; /* user/kernel addr */ + rsmpi_iovec_t *iovec; /* ptr to array */ +} rsmpi_scat_gath_t; + +typedef struct { + char *attr_name; + rsm_addr_t attr_controller_addr; + uint_t attr_direct_access_sizes; + uint_t attr_atomic_sizes; + uint_t attr_error_sizes; + uint_t attr_error_behavior; + boolean_t attr_mmu_protections; + size_t attr_page_size; + size_t attr_max_export_segment_size; + size_t attr_tot_export_segment_size; + ulong_t attr_max_export_segments; + size_t attr_max_import_map_size; + size_t attr_tot_import_map_size; + ulong_t attr_max_import_segments; + boolean_t attr_io_space_exportable; + boolean_t attr_imported_space_ioable; + boolean_t attr_intr_sender_ident; + size_t attr_intr_data_size_max; + uint_t attr_intr_data_align; + boolean_t attr_intr_piggyback; + boolean_t attr_resource_callbacks; +} rsm_controller_attr_t; + +/* + * The following three defines are possible values for attr_error_behavior + * field of the rsm_controller_attr_t struct. + */ +#define RSM_ERR_NOCHANGE 0 +#define RSM_ERR_ZEROES 0x1 +#define RSM_ERR_RANDOM 0x2 + +typedef struct rsm_ops { + + /* + * structure revision number: + */ + uint_t rsm_version; + + /* + * export side memory segment operations: + */ + int (*rsm_seg_create) + (rsm_controller_handle_t controller, + rsm_memseg_export_handle_t *memseg, + size_t size, + uint_t flags, + rsm_memory_local_t *memory, + rsm_resource_callback_t callback, + rsm_resource_callback_arg_t callback_arg); + int (*rsm_seg_destroy) + (rsm_memseg_export_handle_t handle); + int (*rsm_bind) + (rsm_memseg_export_handle_t memseg, + off_t offset, + rsm_memory_local_t *memory, + rsm_resource_callback_t callback, + rsm_resource_callback_arg_t callback_arg); + int (*rsm_unbind) + (rsm_memseg_export_handle_t memseg, + off_t offset, + size_t length); + int (*rsm_rebind) + (rsm_memseg_export_handle_t memseg, + off_t offset, + rsm_memory_local_t *memory, + rsm_resource_callback_t callback, + rsm_resource_callback_arg_t callback_arg); + int (*rsm_publish) + (rsm_memseg_export_handle_t memseg, + rsm_access_entry_t access_list[], + uint_t access_list_length, + rsm_memseg_id_t segment_id, + rsm_resource_callback_t callback, + rsm_resource_callback_arg_t callback_arg); + int (*rsm_unpublish) + (rsm_memseg_export_handle_t memseg); + int (*rsm_republish) + (rsm_memseg_export_handle_t memseg, + rsm_access_entry_t access_list[], + uint_t access_list_length, + rsm_resource_callback_t callback, + rsm_resource_callback_arg_t callback_arg); + + /* + * import side memory segment operations + */ + int (*rsm_connect) + (rsm_controller_handle_t controller, + rsm_addr_t addr, + rsm_memseg_id_t segment_id, + rsm_memseg_import_handle_t *im_memseg); + + int (*rsm_disconnect) + (rsm_memseg_import_handle_t im_memseg); + + /* + * import side memory segment operations (read access functions): + */ + int (* rsm_get8) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint8_t *datap, + ulong_t rep_cnt, + boolean_t byte_swap); + int (* rsm_get16) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint16_t *datap, + ulong_t rep_cnt, + boolean_t byte_swap); + int (* rsm_get32) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint32_t *datap, + ulong_t rep_cnt, + boolean_t byte_swap); + int (* rsm_get64) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint64_t *datap, + ulong_t rep_cnt, + boolean_t byte_swap); + int (* rsm_get) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + void *datap, + size_t length); + + /* + * import side memory segment operations (write access functions) + */ + int (* rsm_put8) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint8_t *datap, + ulong_t rep_cnt, + boolean_t byte_swap); + int (* rsm_put16) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint16_t *datap, + ulong_t rep_cnt, + boolean_t byte_swap); + int (* rsm_put32) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint32_t *datap, + ulong_t rep_cnt, + boolean_t byte_swap); + int (* rsm_put64) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + uint64_t *datap, + ulong_t rep_cnt, + boolean_t byte_swap); + int (* rsm_put) + (rsm_memseg_import_handle_t im_memseg, + off_t offset, + void *datap, + size_t length); + + /* + * import side memory segment operations (mapping) + */ + int (*rsm_map)(rsm_memseg_import_handle_t im_memseg, + off_t offset, + size_t len, + size_t *maplen, + dev_info_t **dipp, + uint_t *register_number, + off_t *register_offset, + rsm_resource_callback_t callback, + rsm_resource_callback_arg_t callback_arg); + + int (*rsm_unmap) + (rsm_memseg_import_handle_t im_memseg); + + /* + * import side memory segment operations (barriers): + */ + int (* rsm_open_barrier_region) + (rsm_memseg_import_handle_t region, + rsm_barrier_t *barrier); + int (* rsm_open_barrier_regions) + (rsm_memseg_import_handle_t regions[], + uint_t num_regions, + rsm_barrier_t *barrier); + int (* rsm_open_barrier_node) + (rsm_controller_handle_t controller, + rsm_addr_t addr, + rsm_barrier_t *barrier); + int (* rsm_open_barrier_ctrl) + (rsm_controller_handle_t controller, + rsm_barrier_t *barrier); + int (* rsm_open_barrier_region_thr) + (rsm_memseg_import_handle_t region, + rsm_barrier_t *barrier); + int (* rsm_open_barrier_regions_thr) + (rsm_memseg_import_handle_t regions[], + uint_t num_regions, + rsm_barrier_t *barrier); + int (* rsm_open_barrier_node_thr) + (rsm_controller_handle_t controller, + rsm_addr_t addr, + rsm_barrier_t *barrier); + int (* rsm_open_barrier_ctrl_thr) + (rsm_controller_handle_t controller, + rsm_barrier_t *barrier); + int (* rsm_close_barrier) + (rsm_barrier_t *barrier); + int (* rsm_reopen_barrier) + (rsm_barrier_t *barrier); + int (* rsm_order_barrier) + (rsm_barrier_t *barrier); + int (* rsm_thread_init) + (rsm_controller_handle_t controller); + int (* rsm_thread_fini) + (rsm_controller_handle_t controller); + int (* rsm_get_barrier_mode) + (rsm_memseg_import_handle_t im_memseg, + rsm_barrier_mode_t *mode); + int (* rsm_set_barrier_mode) + (rsm_memseg_import_handle_t im_memseg, + rsm_barrier_mode_t mode); + + /* + * sending side interrupt operations: + */ + int (* rsm_sendq_create) + (rsm_controller_handle_t controller, + rsm_addr_t addr, + rsm_intr_service_t service, + rsm_intr_pri_t pri, + ulong_t qdepth, + uint_t flags, + rsm_resource_callback_t callback, + rsm_resource_callback_arg_t arg, + rsm_send_q_handle_t *iqp); + int (* rsm_sendq_config) + (rsm_send_q_handle_t iq, + rsm_intr_pri_t pri, + ulong_t qdepth, + uint_t flags, + rsm_resource_callback_t callback, + rsm_resource_callback_arg_t arg); + int (* rsm_sendq_destroy) + (rsm_send_q_handle_t iq); + int (* rsm_send) + (rsm_send_q_handle_t iq, + rsm_send_t *is, + rsm_barrier_t *barrier); + + + /* + * receiving side interrupt operations: + */ + int (* rsm_register_handler) + (rsm_controller_handle_t controller, + rsm_controller_object_t *controller_obj, + rsm_intr_t type, + rsm_intr_hand_t handler, + rsm_intr_hand_arg_t handler_arg, + rsm_addr_t senders_list[], + uint_t senders_list_length); + + int (* rsm_unregister_handler) + (rsm_controller_handle_t controller, + rsm_intr_t type, + rsm_intr_hand_t handler, + rsm_intr_hand_arg_t handler_arg); + + + /* scatter-gather I/O */ + int (* rsm_memseg_import_getv) + (rsm_controller_handle_t cp, + rsmpi_scat_gath_t *sg_io); + int (* rsm_memseg_import_putv) + (rsm_controller_handle_t cp, + rsmpi_scat_gath_t *sg_io); + + /* Management operation */ + int (*rsm_get_peers) + (rsm_controller_handle_t controller, + rsm_addr_t *addr_list, + uint_t count, + uint_t *num_addrs); + + /* Extension operation */ + int (*rsm_extension) + (rsm_controller_handle_t controller, + char *extname, + void *extobj); + +} rsm_ops_t; + +/* + * service module function templates: + */ + +int rsm_get_controller(const char *name, uint_t number, + rsm_controller_object_t *controller, + uint_t version); + +int rsm_release_controller(const char *name, uint_t number, + rsm_controller_object_t *controller); + +int rsm_get_controller_attr(rsm_controller_handle_t, + rsm_controller_attr_t **attrp); +/* + * MACROS for Clients requesting services via RSMPI module + */ + +/* + * Export Side segment operations + */ + +#define RSM_SEG_CREATE(controller, memseg, size, flags, memory, callback, \ + callback_arg) \ + (*((controller).ops->rsm_seg_create)) \ + ((controller).handle, (memseg), (size), (flags), (memory), \ + (callback), (callback_arg)) +#define RSM_SEG_DESTROY(controller, memseg) \ + (*((controller).ops->rsm_seg_destroy)) \ + ((memseg)) +#define RSM_BIND(controller, memseg, offset, memory, callback, \ + callback_arg) \ + (*((controller).ops->rsm_bind)) \ + ((memseg), offset, (memory), (callback), (callback_arg)) +#define RSM_UNBIND(controller, memseg, offset, length) \ + (*((controller).ops->rsm_unbind)) \ + ((memseg), (offset), (length)) +#define RSM_REBIND(controller, memseg, offset, memory, callback, \ + callback_arg) \ + (*((controller).ops->rsm_rebind)) \ + ((memseg), offset, (memory), (callback), (callback_arg)) +#define RSM_PUBLISH(controller, memseg, access_list, access_list_length, \ + segment_id, callback, callback_arg) \ + (*((controller).ops->rsm_publish)) \ + ((memseg), access_list, access_list_length, segment_id, \ + (callback), (callback_arg)) +#define RSM_UNPUBLISH(controller, memseg) \ + (*((controller).ops->rsm_unpublish)) \ + ((memseg)) +#define RSM_REPUBLISH(controller, memseg, access_list, access_list_length, \ + callback, callback_arg) \ + (*((controller).ops->rsm_republish)) \ + ((memseg), (access_list), (access_list_length), (callback), \ + (callback_arg)) +#define RSM_CONNECT(controller, addr, segment_id, im_memseg) \ + (*((controller).ops->rsm_connect)) \ + ((controller).handle, (addr), (segment_id), (im_memseg)) +#define RSM_DISCONNECT(controller, im_memseg) \ + (*((controller).ops->rsm_disconnect)) \ + ((im_memseg)) + + /* + * import side memory segment operations (read access functions) + */ + +#define RSM_GET8(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \ + (*((controller).ops->rsm_get8)) \ + ((im_memseg), (offset), (datap), (rep_cnt), (byte_swap)) +#define RSM_GET16(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \ + (*((controller).ops->rsm_get16)) \ + ((im_memseg), (offset), (datap), (rep_cnt), (byte_swap)) +#define RSM_GET32(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \ + (*((controller).ops->rsm_get32)) \ + ((im_memseg), (offset), (datap), (rep_cnt), (byte_swap)) +#define RSM_GET64(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \ + (*((controller).ops->rsm_get64)) \ + ((im_memseg), (offset), (datap), (rep_cnt), (byte_swap)) +#define RSM_GET(controller, im_memseg, offset, dst_addr, length) \ + (*((controller).ops->rsm_get)) \ + ((im_memseg), (offset), (dst_addr), (length)) + + /* + * import side memory segment operations (write access functions) + */ + +#define RSM_PUT8(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \ + (*((controller).ops->rsm_put8)) \ + ((im_memseg), (offset), (datap), (rep_cnt), (byte_swap)) +#define RSM_PUT16(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \ + (*((controller).ops->rsm_put16)) \ + ((im_memseg), (offset), (datap), (rep_cnt), (byte_swap)) +#define RSM_PUT32(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \ + (*((controller).ops->rsm_put32)) \ + ((im_memseg), (offset), (datap), (rep_cnt), (byte_swap)) +#define RSM_PUT64(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \ + (*((controller).ops->rsm_put64)) \ + ((im_memseg), (offset), (datap), (rep_cnt), (byte_swap)) +#define RSM_PUT(controller, im_memseg, offset, datap, length) \ + (*((controller).ops->rsm_put)) \ + ((im_memseg), (offset), (datap), (length)) + + /* + * import side memory segment operations (mapping): + */ + +#define RSM_MAP(controller, im_memseg, offset, length, maplen, dipp, \ + dev_register, dev_offset, callback, arg) \ + (*((controller).ops->rsm_map)) \ + ((im_memseg), (offset), (length), (maplen), (dipp), (dev_register), \ + (dev_offset), (callback), (arg)) +#define RSM_UNMAP(controller, im_memseg) \ + (*((controller).ops->rsm_unmap)) \ + ((im_memseg)) + + /* + * import side memory segment operations (barriers): + */ + +#define RSM_OPEN_BARRIER_REGION(controller, region, barrier) \ + (*((controller).ops->rsm_open_barrier_region)) \ + ((region), (barrier)) +#define RSM_OPEN_BARRIER_REGIONS(controller, regions, num_regions, barrier) \ + (*((controller).ops->rsm_open_barrier_regions)) \ + ((regions), (num_regions), (barrier)) +#define RSM_OPEN_BARRIER_NODE(controller, addr, barrier) \ + (*((controller).ops-> rsm_open_barrier_node)) \ + ((controller).handle, (addr), (barrier)) +#define RSM_OPEN_BARRIER_CTRL(controller, barrier) \ + (*((controller).ops->rsm_open_barrier_ctrl)) \ + ((controller).handle, (barrier)) +#define RSM_OPEN_BARRIER_REGION_THR(controller, region, barrier) \ + (*((controller).ops->rsm_open_barrier_region_thr)) \ + ((region), (barrier)) +#define RSM_OPEN_BARRIER_REGIONS_THR(controller, regions, num_regions, barrier)\ + (*((controller).ops->rsm_open_barrier_regions_thr)) \ + ((regions), (num_regions), (barrier)) +#define RSM_OPEN_BARRIER_NODE_THR(controller, addr, barrier) \ + (*((controller).ops->rsm_open_barrier_node_thr)) \ + ((controller).handle, (addr), (barrier)) +#define RSM_OPEN_BARRIER_CTRL_THR(controller, barrier) \ + (*((controller).ops->rsm_open_barrier_ctrl_thr)) \ + ((controller).handle, (barrier)); +#define RSM_CLOSE_BARRIER(controller, barrier) \ + (*((controller).ops->rsm_close_barrier)) \ + ((barrier)) +#define RSM_REOPEN_BARRIER(controller, barrier) \ + (*((controller).ops->rsm_reopen_barrier)) \ + ((barrier)); +#define RSM_ORDER_BARRIER(controller, barrier) \ + (*((controller).ops->rsm_order_barrier)) \ + ((barrier)) +#define RSM_THREAD_INIT(controller) \ + (*((controller).ops->rsm_thread_init)) \ + ((controller).handle) +#define RSM_THREAD_FINI(controller) \ + (*((controller).ops->rsm_thread_fini)) \ + ((controller).handle) +#define RSM_GET_BARRIER_MODE(controller, im_memseg, mode) \ + (*((controller).ops->rsm_get_barrier_mode)) \ + ((im_memseg), (mode)) +#define RSM_SET_BARRIER_MODE(controller, im_memseg, mode) \ + (*((controller).ops->rsm_set_barrier_mode)) \ + ((im_memseg), (mode)) + /* + * sending side interrupt operations: + */ + +#define RSM_SENDQ_CREATE(controller, addr, service, pri, qdepth, flags, \ + callback, arg, iqp) \ + (*((controller).ops->rsm_sendq_create)) \ + ((controller).handle, (addr), (service), (pri), (qdepth), (flags), \ + (callback), (arg), (iqp)) +#define RSM_SENDQ_CONFIG(controller, iq, pri, qdepth, flags, callback, arg) \ + (*((controller).ops->rsm_sendq_config)) \ + ((iq), (pri), (qdepth), (flags), \ + (callback), (arg)) +#define RSM_SENDQ_DESTROY(controller, iq) \ + (*((controller).ops->rsm_sendq_destroy)) \ + ((iq)) +#define RSM_SEND(controller, iq, is, barrier) \ + (*((controller).ops->rsm_send)) \ + ((iq), (is), (barrier)) + + /* + * receiving side interrupt operations: + */ +#define RSM_REGISTER_HANDLER(controller, type, handler, handler_arg, \ + senders_list, senders_list_length) \ + (*((controller).ops->rsm_register_handler)) \ + ((controller).handle, &(controller), (type), (handler), (handler_arg), \ + (senders_list), (senders_list_length)) +#define RSM_UNREGISTER_HANDLER(controller, type, handler, handler_arg) \ + (*((controller).ops->rsm_unregister_handler)) \ + ((controller).handle, (type), (handler), (handler_arg)) +#define RSM_GETV(controller, sg_io) \ + (*((controller).ops->rsm_memseg_import_getv)) \ + ((controller).handle, (sg_io)) +#define RSM_PUTV(controller, sg_io) \ + (*((controller).ops->rsm_memseg_import_putv)) \ + ((controller).handle, (sg_io)) +#define RSM_GET_PEERS(controller, addr_list, count, num_addrs) \ + (*((controller).ops->rsm_get_peers)) \ + ((controller).handle, (addr_list), (count), (num_addrs)) +#define RSM_EXTENSION(controller, extname, extobj) \ + (*((controller).ops->rsm_extension)) \ + ((controller).handle, (extname), (extobj)) + +#ifdef __cplusplus +} +#endif + + +#endif /* _SYS_RSM_RSMPI_H */ diff --git a/illumos-x86_64/usr/include/sys/rsm/rsmpi_driver.h b/illumos-x86_64/usr/include/sys/rsm/rsmpi_driver.h new file mode 100644 index 00000000..14188d68 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rsm/rsmpi_driver.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2000-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_RSM_RSMPI_DRIVER_H +#define _SYS_RSM_RSMPI_DRIVER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * The following is information which each RSMPI driver must + * provide when registering with the RSMOPS module + */ +#define MAX_DRVNAME 15 + +typedef struct rsmops_registry { + unsigned int rsm_version; /* version of the RSMPI driver */ + char drv_name[MAX_DRVNAME+1]; /* name of the RSMPI driver */ + int (*rsm_get_controller_handler)(const char *name, + uint_t number, + rsm_controller_object_t *pcontroller, + uint_t version); + int (*rsm_release_controller_handler)(const char *name, + uint_t number, + rsm_controller_object_t *pcontroller); + void (*rsm_thread_entry_pt)(const char *name /* name of driver */); +} rsmops_registry_t; + +typedef struct rsmops_ctrl_registry { + uint_t number; + int refcnt; /* number of outstanding handles */ + rsm_controller_attr_t *attrp; + rsm_controller_handle_t handle; + struct rsmops_ctrl_registry *next; + struct rsmops_drv_registry *p_drv; /* back ptr to drvr struct */ +} rsmops_ctrl_t; + +typedef struct rsmops_drv_registry { + rsmops_registry_t drv; + int ctrl_cnt; /* Number of controllers which have registered */ + struct rsmops_drv_registry *next; + rsmops_ctrl_t *ctrl_head; + kthread_id_t thread_id; +} rsmops_drv_t; + +int rsm_register_controller(const char *name, + uint_t number, rsm_controller_attr_t *attrp); + +int rsm_unregister_controller(const char *name, uint_t number); + +int rsm_register_driver(rsmops_registry_t *p_registry); +int rsm_unregister_driver(rsmops_registry_t *p_registry); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RSM_RSMPI_DRIVER_H */ diff --git a/illumos-x86_64/usr/include/sys/rt.h b/illumos-x86_64/usr/include/sys/rt.h new file mode 100644 index 00000000..2ed7320a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rt.h @@ -0,0 +1,95 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_RT_H +#define _SYS_RT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Real-time dispatcher parameter table entry + */ +typedef struct rtdpent { + pri_t rt_globpri; /* global (class independent) priority */ + int rt_quantum; /* default quantum associated with this level */ +} rtdpent_t; + +/* + * Real-time class specific proc structure + */ +typedef struct rtproc { + int rt_pquantum; /* time quantum given to this proc */ + int rt_timeleft; /* time remaining in procs quantum */ + pri_t rt_pri; /* priority within rt class */ + ushort_t rt_flags; /* flags defined below */ + int rt_tqsignal; /* time quantum signal */ + kthread_id_t rt_tp; /* pointer to thread */ + struct rtproc *rt_next; /* link to next rtproc on list */ + struct rtproc *rt_prev; /* link to previous rtproc on list */ +} rtproc_t; + + +/* Flags */ +#define RTBACKQ 0x0002 /* proc goes to back of disp q when preempted */ + + +#ifdef _KERNEL +/* + * Kernel version of real-time class specific parameter structure + */ +typedef struct rtkparms { + pri_t rt_pri; + int rt_tqntm; + int rt_tqsig; /* real-time time quantum signal */ + uint_t rt_cflags; /* real-time control flags */ +} rtkparms_t; + +#define RTGPPRIO0 100 /* Global priority for RT priority 0 */ + +/* + * control flags (kparms->rt_cflags). + */ +#define RT_DOPRI 0x01 /* change priority */ +#define RT_DOTQ 0x02 /* change RT time quantum */ +#define RT_DOSIG 0x04 /* change RT time quantum signal */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RT_H */ diff --git a/illumos-x86_64/usr/include/sys/rtc.h b/illumos-x86_64/usr/include/sys/rtc.h new file mode 100644 index 00000000..51b31bf7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rtc.h @@ -0,0 +1,126 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_RTC_H +#define _SYS_RTC_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Definitions for Real Time Clock driver (Motorola MC146818 chip). + */ + +/* + * MP NOTE: + * cmos_lck must be locked when addressing CMOS via + * RTC_ADDR and RTC_DATA i/o addresses + */ +#define RTC_ADDR 0x70 /* I/O port address of for register select */ +#define RTC_DATA 0x71 /* I/O port address for data read/write */ + +/* + * Register A definitions + */ +#define RTC_A 0x0a /* register A address */ +#define RTC_UIP 0x80 /* Update in progress bit */ +#define RTC_DIV0 0x00 /* Time base of 4.194304 MHz */ +#define RTC_DIV1 0x10 /* Time base of 1.048576 MHz */ +#define RTC_DIV2 0x20 /* Time base of 32.768 KHz */ +#define RTC_RATE6 0x06 /* interrupt rate of 976.562 */ + +/* + * Register B definitions + */ +#define RTC_B 0x0b /* register B address */ +#define RTC_SET 0x80 /* stop updates for time set */ +#define RTC_PIE 0x40 /* Periodic interrupt enable */ +#define RTC_AIE 0x20 /* Alarm interrupt enable */ +#define RTC_UIE 0x10 /* Update ended interrupt enable */ +#define RTC_SQWE 0x08 /* Square wave enable */ +#define RTC_DM 0x04 /* Date mode, 1 = binary, 0 = BCD */ +#define RTC_HM 0x02 /* hour mode, 1 = 24 hour, 0 = 12 hour */ +#define RTC_DSE 0x01 /* Daylight savings enable */ + +/* + * Register C definitions + */ +#define RTC_C 0x0c /* register C address */ +#define RTC_IRQF 0x80 /* IRQ flag */ +#define RTC_PF 0x40 /* PF flag bit */ +#define RTC_AF 0x20 /* AF flag bit */ +#define RTC_UF 0x10 /* UF flag bit */ + +/* + * Register D definitions + */ +#define RTC_D 0x0d /* register D address */ +#define RTC_VRT 0x80 /* Valid RAM and time bit */ + +#define RTC_NREG 0x0e /* number of RTC registers */ +#define RTC_NREGP 0x0c /* number of RTC registers to set time */ +#define RTC_CENTURY 0x32 /* not included in RTC_NREG(P) */ + +/* + * Ioctl definitions for accessing RTC. + */ +#define RTCIOC ('R' << 8) + +#define RTCRTIME (RTCIOC | 0x01) /* Read time from RTC */ +#define RTCSTIME (RTCIOC | 0x02) /* Set time into RTC */ + +struct rtc_t { /* registers 0x0 to 0xD, 0x32 */ + unsigned char rtc_sec; + unsigned char rtc_asec; + unsigned char rtc_min; + unsigned char rtc_amin; + unsigned char rtc_hr; + unsigned char rtc_ahr; + unsigned char rtc_dow; + unsigned char rtc_dom; + unsigned char rtc_mon; + unsigned char rtc_yr; + unsigned char rtc_statusa; + unsigned char rtc_statusb; + unsigned char rtc_statusc; + unsigned char rtc_statusd; + unsigned char rtc_century; /* register 0x32 */ + unsigned char rtc_adom; /* ACPI-provided day alarm */ + unsigned char rtc_amon; /* ACPI-provided mon alarm */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RTC_H */ diff --git a/illumos-x86_64/usr/include/sys/rtpriocntl.h b/illumos-x86_64/usr/include/sys/rtpriocntl.h new file mode 100644 index 00000000..3baa1b62 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rtpriocntl.h @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_RTPRIOCNTL_H +#define _SYS_RTPRIOCNTL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Real-time class specific structures for the priocntl system call. + */ + +typedef struct rtparms { + pri_t rt_pri; /* real-time priority */ + uint_t rt_tqsecs; /* seconds in time quantum */ + int rt_tqnsecs; /* additional nanosecs in time quant */ +} rtparms_t; + + +typedef struct rtinfo { + pri_t rt_maxpri; /* maximum configured real-time priority */ +} rtinfo_t; + + +#define RT_NOCHANGE -1 +#define RT_TQINF -2 +#define RT_TQDEF -3 + +/* + * Real-time class specific keys for the priocntl system call varargs interface. + */ +#define RT_KY_PRI 1 /* real-time priority */ +#define RT_KY_TQSECS 2 /* seconds in time quantum */ +#define RT_KY_TQNSECS 3 /* nanoseconds in time quantum */ +#define RT_KY_TQSIG 4 /* real-time time quantum signal */ + +/* + * The following is used by the dispadmin(8) command for + * scheduler administration and is not for general use. + */ + +#ifdef _SYSCALL32 +/* Data structure for ILP32 clients */ +typedef struct rtadmin32 { + caddr32_t rt_dpents; + int16_t rt_ndpents; + int16_t rt_cmd; +} rtadmin32_t; +#endif /* _SYSCALL32 */ + +typedef struct rtadmin { + struct rtdpent *rt_dpents; + short rt_ndpents; + short rt_cmd; +} rtadmin_t; + +#define RT_GETDPSIZE 1 +#define RT_GETDPTBL 2 +#define RT_SETDPTBL 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RTPRIOCNTL_H */ diff --git a/illumos-x86_64/usr/include/sys/rwlock.h b/illumos-x86_64/usr/include/sys/rwlock.h new file mode 100644 index 00000000..dc2eb93a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rwlock.h @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_RWLOCK_H +#define _SYS_RWLOCK_H + +/* + * Public interface to readers/writer locks. See rwlock(9F) for details. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +typedef enum { + RW_DRIVER = 2, /* driver (DDI) rwlock */ + RW_DEFAULT = 4 /* kernel default rwlock */ +} krw_type_t; + +typedef enum { + RW_WRITER, + RW_READER, + RW_READER_STARVEWRITER +} krw_t; + +typedef struct _krwlock { + void *_opaque[1]; +} krwlock_t; + +#if defined(_KERNEL) + +#define RW_READ_HELD(x) (rw_read_held((x))) +#define RW_WRITE_HELD(x) (rw_write_held((x))) +#define RW_LOCK_HELD(x) (rw_lock_held((x))) +#define RW_ISWRITER(x) (rw_iswriter(x)) + +extern void rw_init(krwlock_t *, char *, krw_type_t, void *); +extern void rw_destroy(krwlock_t *); +extern void rw_enter(krwlock_t *, krw_t); +extern int rw_tryenter(krwlock_t *, krw_t); +extern void rw_exit(krwlock_t *); +extern void rw_downgrade(krwlock_t *); +extern int rw_tryupgrade(krwlock_t *); +extern int rw_read_held(krwlock_t *); +extern int rw_write_held(krwlock_t *); +extern int rw_lock_held(krwlock_t *); +extern int rw_read_locked(krwlock_t *); +extern int rw_iswriter(krwlock_t *); +extern struct _kthread *rw_owner(krwlock_t *); +extern uint_t (*rw_lock_backoff)(uint_t); +extern void (*rw_lock_delay)(uint_t); + +#endif /* defined(_KERNEL) */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RWLOCK_H */ diff --git a/illumos-x86_64/usr/include/sys/rwlock_impl.h b/illumos-x86_64/usr/include/sys/rwlock_impl.h new file mode 100644 index 00000000..9c840cca --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rwlock_impl.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RWLOCK_IMPL_H +#define _SYS_RWLOCK_IMPL_H + +/* + * Implementation-private definitions for readers/writer locks. + */ + +#ifndef _ASM + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rwlock_impl { + uintptr_t rw_wwwh; /* waiters, write wanted, hold count */ +} rwlock_impl_t; + +#endif /* _ASM */ + +#define RW_HAS_WAITERS 1 +#define RW_WRITE_WANTED 2 +#define RW_WRITE_LOCKED 4 +#define RW_READ_LOCK 8 +#define RW_WRITE_LOCK(thread) ((uintptr_t)(thread) | RW_WRITE_LOCKED) +#define RW_HOLD_COUNT (-RW_READ_LOCK) +#define RW_HOLD_COUNT_SHIFT 3 /* log2(RW_READ_LOCK) */ +#define RW_READ_COUNT RW_HOLD_COUNT +#define RW_OWNER RW_HOLD_COUNT +#define RW_LOCKED RW_HOLD_COUNT +#define RW_WRITE_CLAIMED (RW_WRITE_LOCKED | RW_WRITE_WANTED) +#define RW_DOUBLE_LOCK (RW_WRITE_LOCK(0) | RW_READ_LOCK) + +/* + * These macros are used by both the implementation of rw_*() routines and + * by the implementation of the rwlock-related DTrace subroutines. (DTrace + * cannot make calls into the rw_*() routines; it must use the macros.) + */ +#define _RW_READ_HELD(rwlp, tmp) \ + ((((tmp) = ((rwlock_impl_t *)(rwlp))->rw_wwwh) & RW_LOCKED) && \ + !((tmp) & RW_WRITE_LOCKED)) + +#define _RW_WRITE_HELD(rwlp) \ + ((((rwlock_impl_t *)(rwlp))->rw_wwwh & \ + (RW_OWNER | RW_WRITE_LOCKED)) == RW_WRITE_LOCK(curthread)) + +#define _RW_LOCK_HELD(rwlp) \ + ((((rwlock_impl_t *)(rwlp))->rw_wwwh & RW_LOCKED) ? 1 : 0) + +#define _RW_ISWRITER(rwlp) \ + ((((rwlock_impl_t *)(rwlp))->rw_wwwh & RW_WRITE_CLAIMED) ? 1 : 0) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RWLOCK_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/rwstlock.h b/illumos-x86_64/usr/include/sys/rwstlock.h new file mode 100644 index 00000000..c491aef8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/rwstlock.h @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_RWSTLOCK_H +#define _SYS_RWSTLOCK_H + +/* + * Alternate rwlock that is interruptible and can be released by a thread + * other than the one that acquired the lock. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +typedef struct rwstlock { + intptr_t rwst_count; + kcondvar_t rwst_rcv; + kcondvar_t rwst_wcv; + kmutex_t rwst_lock; +} rwstlock_t; + +/* + * The interfaces below are private to Sun Microsystems, + * and these might change without notice. + */ + +#define RWST_TRYENTER 0x01 +#define RWST_SIG 0x02 + +#define RWST_HELD(l) ((l)->rwst_count != 0) +#define RWST_READ_HELD(l) ((l)->rwst_count > 0) +#define RWST_WRITE_HELD(l) ((l)->rwst_count < 0) +#define RWST_WRITE_OWNER(l) \ + ((l)->rwst_count == (LONG_MIN | (intptr_t)curthread)) +#define RWST_OWNER(l) (RWST_WRITE_HELD(l) ? \ + ((struct _kthread *)((l)->rwst_count & ~LONG_MIN)) : NULL) +#define RWST_READ_WANTED(l) CV_HAS_WAITERS(&(l)->rwst_rcv) +#define RWST_WRITE_WANTED(l) CV_HAS_WAITERS(&(l)->rwst_wcv) +#define RWST_WAIT(cv, lock, f) \ + ((f) & RWST_SIG ? cv_wait_sig(cv, lock) : (cv_wait(cv, lock), 1)) +#define RWST_READ_WAIT(l, f) RWST_WAIT(&(l)->rwst_rcv, &(l)->rwst_lock, f) +#define RWST_WRITE_WAIT(l, f) RWST_WAIT(&(l)->rwst_wcv, &(l)->rwst_lock, f) +#define RWST_READ_WAKE_ALL(l) cv_broadcast(&(l)->rwst_rcv) +#define RWST_WRITE_WAKE_ONE(l) cv_signal(&(l)->rwst_wcv) +#define RWST_READ_ENTER(l) (l)->rwst_count++ +#define RWST_WRITE_ENTER(l) (l)->rwst_count = LONG_MIN | (intptr_t)curthread +#define RWST_READ_EXIT(l) (l)->rwst_count-- +#define RWST_WRITE_EXIT(l) (l)->rwst_count = 0 + +extern void rwst_enter(rwstlock_t *, krw_t); +extern int rwst_enter_sig(rwstlock_t *, krw_t); +extern void rwst_exit(rwstlock_t *); +extern void rwst_init(rwstlock_t *, char *, krw_type_t, void *); +extern void rwst_destroy(rwstlock_t *); +extern int rwst_lock_held(rwstlock_t *, krw_t); +extern int rwst_tryenter(rwstlock_t *, krw_t); +extern struct _kthread *rwst_owner(rwstlock_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_RWSTLOCK_H */ diff --git a/illumos-x86_64/usr/include/sys/sad.h b/illumos-x86_64/usr/include/sys/sad.h new file mode 100644 index 00000000..1bc13b74 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sad.h @@ -0,0 +1,243 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_SAD_H +#define _SYS_SAD_H + +#include +#ifdef _KERNEL +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Streams Administrative Driver + */ + +/* + * As time has passed, it has become necessary to add members to some + * of the structures passed downstream with these ioctls. Currently, + * only the SAD_GAP/SAD_SAP ioctls are versioned, (which use the + * strapush structure), but the versioning mechanism is general enough + * to be applied to any SAD ioctls. This is done by repartitioning + * the SAD ioctl namespace to include a version number in addition to + * the command (see below). + * + * In the case of the SAD_GAP/SAD_SAP ioctls, an application can + * choose which "version" of the ioctl to use by #defining AP_VERSION + * before including this file. Old code implicitly has AP_VERSION set + * to 0, and even newly compiled code defaults to an AP_VERSION of 0, + * since it may not be aware of the new structure members and + * therefore not know to set them to reasonable values. In order for + * programs to make use of a newer version, they must explicitly + * #define AP_VERSION to the appropriate value. Note that the kernel + * always defaults to the latest version, since it is internally + * self-consistent. + */ +#ifndef AP_VERSION +#ifdef _KERNEL +#define AP_VERSION 1 /* latest version */ +#else +#define AP_VERSION 0 /* SVR4 version */ +#endif +#endif + +/* + * ioctl defines + * + * The layout for the low 16 bits is 01000101VVVVCCCC, where the + * first bitpattern is `D' in binary, followed by a 4 bit version + * field (limiting the number of versions to 16), followed by a + * 4 bit command field (limiting the number of commands to 16). + */ +#define SADIOC ('D' << 8) +#define SAD_SAP (SADIOC|AP_VERSION << 4|01) +#define SAD_GAP (SADIOC|AP_VERSION << 4|02) +#define SAD_VML (SADIOC|03) /* validate module list */ + +/* + * Device naming and numbering conventions. + */ +#define USERDEV "/dev/sad/user" +#define ADMINDEV "/dev/sad/admin" + +#define USRMIN 0 +#define ADMMIN 1 + +/* + * The maximum modules you can push on a stream using the autopush + * feature. This should be less than NSTRPUSH. + */ +#define MAXAPUSH 8 + +/* + * autopush info common to user and kernel + */ +struct apcommon { + uint_t apc_cmd; /* command (see below) */ + major_t apc_major; /* major # of device */ + minor_t apc_minor; /* minor # of device */ + minor_t apc_lastminor; /* last minor for range */ + uint_t apc_npush; /* number of modules to push */ +}; + +/* + * New autopush information structure. This wouldn't be necessary + * except `struct apcommon' wasn't defined last in the `strapush' + * structure, making it difficult to grow the structure without + * breaking binary compatibility. Note that new members can be added + * to this structure in the future, at which point AP_VERSION should + * be incremented (of course, a new STRAPUSH_Vx_LEN macro should be + * added and sad.c should be changed to handle the new member). + */ +struct apdata { + uint_t apd_anchor; /* position of anchor in stream */ +}; + +/* + * ap_cmd: various flavors of autopush + */ +#define SAP_CLEAR 0 /* remove configuration list */ +#define SAP_ONE 1 /* configure one minor device */ +#define SAP_RANGE 2 /* configure range of minor devices */ +#define SAP_ALL 3 /* configure all minor devices */ + +/* + * format for autopush ioctls + */ +struct strapush { + struct apcommon sap_common; /* see above */ + char sap_list[MAXAPUSH][FMNAMESZ + 1]; /* module list */ +#if AP_VERSION > 0 + struct apdata sap_data; /* see above */ +#endif +}; + +#define sap_cmd sap_common.apc_cmd +#define sap_major sap_common.apc_major +#define sap_minor sap_common.apc_minor +#define sap_lastminor sap_common.apc_lastminor +#define sap_npush sap_common.apc_npush +#define sap_anchor sap_data.apd_anchor + +#ifdef _KERNEL + +/* + * state values for ioctls + */ +#define GETSTRUCT 1 +#define GETRESULT 2 +#define GETLIST 3 + +#define SAD_VER(ioccmd) (((ioccmd) >> 4) & 0x0f) +#define SAD_CMD(ioccmd) ((ioccmd) & ~0xf0) + +#define STRAPUSH_V0_LEN (size_t)(&((struct strapush *)0)->sap_data) +#define STRAPUSH_V1_LEN (size_t)(STRAPUSH_V0_LEN + sizeof (uint_t)) + +struct saddev { + queue_t *sa_qp; /* pointer to read queue */ + caddr_t sa_addr; /* saved address for copyout */ + int sa_flags; /* see below */ + str_stack_t *sa_ss; +}; + +/* + * values for saddev flags field. + */ +#define SADPRIV 0x01 + +/* + * Module Autopush Cache + */ +struct autopush { + struct apcommon ap_common; /* see above */ + char ap_list[MAXAPUSH][FMNAMESZ + 1]; + /* list of modules to push */ + int ap_cnt; /* in use count */ + struct apdata ap_data; /* see above */ +}; + +/* + * The command issued by the user ultimately becomes + * the type of the autopush entry. Therefore, occurrences of + * "type" in the code refer to an existing autopush entry. + * Occurrences of "cmd" in the code refer to the command the + * user is currently trying to complete. types and cmds take + * on the same values. + */ +#define ap_type ap_common.apc_cmd +#define ap_major ap_common.apc_major +#define ap_minor ap_common.apc_minor +#define ap_lastminor ap_common.apc_lastminor +#define ap_npush ap_common.apc_npush +#define ap_anchor ap_data.apd_anchor + +/* + * function prototypes + */ +struct strbuf; +void audit_strputmsg(struct vnode *, struct strbuf *, struct strbuf *, + unsigned char, int, int); +void audit_fdsend(int, struct file *, int); +void audit_fdrecv(int, struct file *); + +extern void sad_initspace(str_stack_t *); +extern void sad_freespace(str_stack_t *); + +/* + * The following interfaces do not care about ss_sad_lock. + */ +extern struct autopush *sad_ap_alloc(void); +extern int sad_apc_verify(struct apcommon *); +extern int sad_ap_verify(struct autopush *); + +/* + * The following interfaces attempt to acquire ss_sad_lock. + */ +extern void sad_ap_rele(struct autopush *, str_stack_t *); +extern struct autopush *sad_ap_find_by_dev(dev_t, str_stack_t *); + +/* + * The following interfaces require ss_sad_lock to be held when invoked. + */ +extern void sad_ap_insert(struct autopush *, str_stack_t *); +extern void sad_ap_remove(struct autopush *, str_stack_t *); +extern struct autopush *sad_ap_find(struct apcommon *, str_stack_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SAD_H */ diff --git a/illumos-x86_64/usr/include/sys/sata/sata_defs.h b/illumos-x86_64/usr/include/sys/sata/sata_defs.h new file mode 100644 index 00000000..ff0ed9aa --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sata/sata_defs.h @@ -0,0 +1,866 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2019 Joyent, Inc. + * Copyright 2024 RackTop Systems, Inc. + */ + +#ifndef _SATA_DEFS_H +#define _SATA_DEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Common ATA commands (subset) + */ +#define SATAC_DIAG 0x90 /* diagnose command */ +#define SATAC_RECAL 0x10 /* restore cmd, 4 bits step rate */ +#define SATAC_FORMAT 0x50 /* format track command */ +#define SATAC_SET_FEATURES 0xef /* set features */ +#define SATAC_IDLE_IM 0xe1 /* idle immediate */ +#define SATAC_STANDBY_IM 0xe0 /* standby immediate */ +#define SATAC_DOOR_LOCK 0xde /* door lock */ +#define SATAC_DOOR_UNLOCK 0xdf /* door unlock */ +#define SATAC_IDLE 0xe3 /* idle */ +#define SATAC_STANDBY 0xe2 /* standby */ + +/* + * ATA/ATAPI disk commands (subset) + */ +#define SATAC_DSM 0x06 /* Data Set Management */ +#define SATAC_DEVICE_RESET 0x08 /* ATAPI device reset */ +#define SATAC_DOWNLOAD_MICROCODE 0x92 /* Download microcode */ +#define SATAC_EJECT 0xed /* media eject */ +#define SATAC_FLUSH_CACHE 0xe7 /* flush write-cache */ +#define SATAC_ID_DEVICE 0xec /* IDENTIFY DEVICE */ +#define SATAC_ID_PACKET_DEVICE 0xa1 /* ATAPI identify packet device */ +#define SATAC_INIT_DEVPARMS 0x91 /* initialize device parameters */ +#define SATAC_PACKET 0xa0 /* ATAPI packet */ +#define SATAC_RDMULT 0xc4 /* read multiple w/DMA */ +#define SATAC_RDSEC 0x20 /* read sector */ +#define SATAC_RDVER 0x40 /* read verify */ +#define SATAC_READ_DMA 0xc8 /* read DMA */ +#define SATAC_SEEK 0x70 /* seek */ +#define SATAC_SERVICE 0xa2 /* queued/overlap service */ +#define SATAC_SETMULT 0xc6 /* set multiple mode */ +#define SATAC_WRITE_DMA 0xca /* write (multiple) w/DMA */ +#define SATAC_WRMULT 0xc5 /* write multiple */ +#define SATAC_WRSEC 0x30 /* write sector */ +#define SATAC_RDSEC_EXT 0x24 /* read sector extended (LBA48) */ +#define SATAC_READ_DMA_EXT 0x25 /* read DMA extended (LBA48) */ +#define SATAC_RDMULT_EXT 0x29 /* read multiple extended (LBA48) */ +#define SATAC_WRSEC_EXT 0x34 /* read sector extended (LBA48) */ +#define SATAC_WRITE_DMA_EXT 0x35 /* read DMA extended (LBA48) */ +#define SATAC_WRMULT_EXT 0x39 /* read multiple extended (LBA48) */ + +#define SATAC_READ_DMA_QUEUED 0xc7 /* read DMA / may be queued */ +#define SATAC_READ_DMA_QUEUED_EXT 0x26 /* read DMA ext / may be queued */ +#define SATAC_WRITE_DMA_QUEUED 0xcc /* read DMA / may be queued */ +#define SATAC_WRITE_DMA_QUEUED_EXT 0x36 /* read DMA ext / may be queued */ +#define SATAC_READ_PM_REG 0xe4 /* read port mult reg */ +#define SATAC_WRITE_PM_REG 0xe8 /* write port mult reg */ + +#define SATAC_READ_FPDMA_QUEUED 0x60 /* First-Party-DMA read queued */ +#define SATAC_WRITE_FPDMA_QUEUED 0x61 /* First-Party-DMA write queued */ + +#define SATAC_READ_LOG_EXT 0x2f /* read log */ + +#define SATAC_SMART 0xb0 /* SMART */ + +#define SATA_LOG_PAGE_10 0x10 /* log page 0x10 - SATA error */ +/* + * Port Multiplier Commands + */ +#define SATAC_READ_PORTMULT 0xe4 /* read port multiplier */ +#define SATAC_WRITE_PORTMULT 0xe8 /* write port multiplier */ + +/* + * Power Managment Commands (subset) + */ +#define SATAC_CHECK_POWER_MODE 0xe5 /* check power mode */ + +#define SATA_PWRMODE_STANDBY 0 /* standby mode */ +#define SATA_PWRMODE_IDLE 0x80 /* idle mode */ +#define SATA_PWRMODE_ACTIVE_SPINDOWN 0x40 /* PM0 and spinning down */ +#define SATA_PWRMODE_ACTIVE_SPINUP 0x41 /* PM0 and spinning up */ +#define SATA_PWRMODE_ACTIVE 0xFF /* active or idle mode */ + + +/* + * SMART FEATURES Subcommands + */ +#define SATA_SMART_READ_DATA 0xd0 +#define SATA_SMART_ATTR_AUTOSAVE 0xd2 +#define SATA_SMART_EXECUTE_OFFLINE_IMM 0xd4 +#define SATA_SMART_READ_LOG 0xd5 +#define SATA_SMART_WRITE_LOG 0xd6 +#define SATA_SMART_ENABLE_OPS 0xd8 +#define SATA_SMART_DISABLE_OPS 0xd9 +#define SATA_SMART_RETURN_STATUS 0xda + +/* + * SET FEATURES Subcommands + */ +#define SATAC_SF_ENABLE_WRITE_CACHE 0x02 +#define SATAC_SF_TRANSFER_MODE 0x03 +#define SATAC_SF_DISABLE_RMSN 0x31 +#define SATAC_SF_ENABLE_ACOUSTIC 0x42 +#define SATAC_SF_DISABLE_READ_AHEAD 0x55 +#define SATAC_SF_DISABLE_WRITE_CACHE 0x82 +#define SATAC_SF_ENABLE_READ_AHEAD 0xaa +#define SATAC_SF_DISABLE_ACOUSTIC 0xc2 +#define SATAC_SF_ENABLE_RMSN 0x95 + +/* + * SET FEATURES transfer mode values + */ +#define SATAC_TRANSFER_MODE_PIO_DEFAULT 0x00 +#define SATAC_TRANSFER_MODE_PIO_DISABLE_IODRY 0x01 +#define SATAC_TRANSFER_MODE_PIO_FLOW_CONTROL 0x08 +#define SATAC_TRANSFER_MODE_MULTI_WORD_DMA 0x20 +#define SATAC_TRANSFER_MODE_ULTRA_DMA 0x40 + +/* + * Download microcode subcommands + */ +#define SATA_DOWNLOAD_MCODE_TEMP 1 /* Revert on/ reset/pwr cycle */ +#define SATA_DOWNLOAD_MCODE_SAVE 7 /* No offset, keep mcode */ + + +/* Generic ATA definitions */ + +#define SATA_TAG_QUEUING_SHIFT 3 +#define SATA_TAG_QUEUING_MASK 0x1f +/* + * Identify Device data + * Although both ATA and ATAPI devices' Identify Data have the same length, + * some words have different meaning/content and/or are irrelevant for + * other type of device. + * Following is the ATA Device Identify data layout + */ +typedef struct sata_id { +/* WORD */ +/* OFFSET COMMENT */ + ushort_t ai_config; /* 0 general configuration bits */ + ushort_t ai_fixcyls; /* 1 # of cylinders (obsolete) */ + ushort_t ai_resv0; /* 2 # reserved */ + ushort_t ai_heads; /* 3 # of heads (obsolete) */ + ushort_t ai_trksiz; /* 4 # of bytes/track (retired) */ + ushort_t ai_secsiz; /* 5 # of bytes/sector (retired) */ + ushort_t ai_sectors; /* 6 # of sectors/track (obsolete) */ + ushort_t ai_resv1[3]; /* 7 "Vendor Unique" */ + char ai_drvser[20]; /* 10 Serial number */ + ushort_t ai_buftype; /* 20 Buffer type */ + ushort_t ai_bufsz; /* 21 Buffer size in 512 byte incr */ + ushort_t ai_ecc; /* 22 # of ecc bytes avail on rd/wr */ + char ai_fw[8]; /* 23 Firmware revision */ + char ai_model[40]; /* 27 Model # */ + ushort_t ai_mult1; /* 47 Multiple command flags */ + ushort_t ai_dwcap; /* 48 Doubleword capabilities */ + ushort_t ai_cap; /* 49 Capabilities */ + ushort_t ai_resv2; /* 50 Reserved */ + ushort_t ai_piomode; /* 51 PIO timing mode */ + ushort_t ai_dmamode; /* 52 DMA timing mode */ + ushort_t ai_validinfo; /* 53 bit0: wds 54-58, bit1: 64-70 */ + ushort_t ai_curcyls; /* 54 # of current cylinders */ + ushort_t ai_curheads; /* 55 # of current heads */ + ushort_t ai_cursectrk; /* 56 # of current sectors/track */ + ushort_t ai_cursccp[2]; /* 57 current sectors capacity */ + ushort_t ai_mult2; /* 59 multiple sectors info */ + ushort_t ai_addrsec[2]; /* 60 LBA only: no of addr secs */ + ushort_t ai_dirdma; /* 62 valid in ATA/ATAPI7, DMADIR */ + ushort_t ai_dworddma; /* 63 multi word dma modes */ + ushort_t ai_advpiomode; /* 64 advanced PIO modes supported */ + ushort_t ai_minmwdma; /* 65 min multi-word dma cycle info */ + ushort_t ai_recmwdma; /* 66 rec multi-word dma cycle info */ + ushort_t ai_minpio; /* 67 min PIO cycle info */ + ushort_t ai_minpioflow; /* 68 min PIO cycle info w/flow ctl */ + ushort_t ai_addsupported; /* 69 additional supported */ + ushort_t ai_resv3; /* 70 reserved */ + ushort_t ai_typtime[2]; /* 71-72 timing */ + ushort_t ai_resv4[2]; /* 73-74 reserved */ + ushort_t ai_qdepth; /* 75 queue depth */ + ushort_t ai_satacap; /* 76 SATA capabilities */ + ushort_t ai_resv5; /* 77 reserved */ + ushort_t ai_satafsup; /* 78 SATA features supported */ + ushort_t ai_satafenbl; /* 79 SATA features enabled */ + ushort_t ai_majorversion; /* 80 major versions supported */ + ushort_t ai_minorversion; /* 81 minor version number supported */ + ushort_t ai_cmdset82; /* 82 command set supported */ + ushort_t ai_cmdset83; /* 83 more command sets supported */ + ushort_t ai_cmdset84; /* 84 more command sets supported */ + ushort_t ai_features85; /* 85 enabled features */ + ushort_t ai_features86; /* 86 enabled features */ + ushort_t ai_features87; /* 87 enabled features */ + ushort_t ai_ultradma; /* 88 Ultra DMA mode */ + ushort_t ai_erasetime; /* 89 security erase time */ + ushort_t ai_erasetimex; /* 90 enhanced security erase time */ + ushort_t ai_adv_pwr_mgmt; /* 91 advanced power management time */ + ushort_t ai_master_pwd; /* 92 master password revision code */ + ushort_t ai_hrdwre_reset; /* 93 hardware reset result */ + ushort_t ai_acoustic; /* 94 accoustic management values */ + ushort_t ai_stream_min_sz; /* 95 stream minimum request size */ + ushort_t ai_stream_xfer_d; /* 96 streaming transfer time (DMA) */ + ushort_t ai_stream_lat; /* 97 streaming access latency */ + ushort_t ai_streamperf[2]; /* 98-99 streaming performance gran. */ + ushort_t ai_addrsecxt[4]; /* 100 extended max LBA sector */ + ushort_t ai_stream_xfer_p; /* 104 streaming transfer time (PIO) */ + ushort_t ai_maxcount; /* 105 max count of 512-byte blocks of */ + /* LBA range entries */ + ushort_t ai_phys_sect_sz; /* 106 physical sector size */ + ushort_t ai_seek_delay; /* 107 inter-seek delay time (usecs) */ + ushort_t ai_naa_ieee_oui; /* 108 NAA/IEEE OUI */ + ushort_t ai_ieee_oui_uid; /* 109 IEEE OUT/unique id */ + ushort_t ai_uid_mid; /* 110 unique id (mid) */ + ushort_t ai_uid_low; /* 111 unique id (low) */ + ushort_t ai_resv_wwn[4]; /* 112-115 reserved for WWN ext. */ + ushort_t ai_incits; /* 116 reserved for INCITS TR-37-2004 */ + ushort_t ai_words_lsec[2]; /* 117-118 words per logical sector */ + ushort_t ai_cmdset119; /* 119 more command sets supported */ + ushort_t ai_features120; /* 120 enabled features */ + ushort_t ai_padding1[6]; /* pad to 126 */ + ushort_t ai_rmsn; /* 127 removable media notification */ + ushort_t ai_securestatus; /* 128 security status */ + ushort_t ai_vendor[31]; /* 129-159 vendor specific */ + ushort_t ai_padding2[8]; /* 160 pad to 168 */ + ushort_t ai_nomformfactor; /* 168 nominal form factor */ + ushort_t ai_dsm; /* 169 data set management */ + ushort_t ai_padding3[6]; /* 170 pad to 176 */ + ushort_t ai_curmedser[30]; /* 176-205 current media serial # */ + ushort_t ai_sctsupport; /* 206 SCT command transport */ + ushort_t ai_padding4[10]; /* 207 pad to 217 */ + ushort_t ai_medrotrate; /* 217 nominal media rotation rate */ + ushort_t ai_padding5[37]; /* 218 pad to 255 */ + ushort_t ai_integrity; /* 255 integrity word */ +} sata_id_t; + + +/* Identify Device: general config bits - word 0 */ + +#define SATA_ATA_TYPE_MASK 0x8001 /* ATA Device type mask */ +#define SATA_ATA_TYPE 0x0000 /* ATA device */ +#define SATA_REM_MEDIA 0x0080 /* Removable media */ +#define SATA_INCOMPLETE_DATA 0x0004 /* Incomplete Identify Device data */ +#define SATA_CFA_TYPE 0x848a /* CFA feature set device */ + +#define SATA_ID_SERIAL_OFFSET 10 +#define SATA_ID_SERIAL_LEN 20 +#define SATA_ID_MODEL_OFFSET 27 +#define SATA_ID_MODEL_LEN 40 +#define SATA_ID_FW_LEN 8 +#define SATA_ID_BDC_LEN 0x3c +#define SATA_ID_ATA_INFO_LEN 0x238 + +/* Identify Device: common capability bits - word 49 */ + +#define SATA_DMA_SUPPORT 0x0100 +#define SATA_LBA_SUPPORT 0x0200 +#define SATA_IORDY_DISABLE 0x0400 +#define SATA_IORDY_SUPPORT 0x0800 +#define SATA_STANDBYTIMER 0x2000 + +/* Identify Device: ai_validinfo (word 53) */ + +#define SATA_VALIDINFO_88 0x0004 /* word 88 supported fields valid */ +#define SATA_VALIDINFO_70_64 0x0004 /* words 70-64 fields valid */ + +/* Identify Device: ai_addsupported (word 69) */ + +#define SATA_DETERMINISTIC_READ 0x4000 /* word 69 deterministic read supp. */ +#define SATA_READ_ZERO 0x0020 /* word 69 read zero after TRIM supp. */ + +/* Identify Device: ai_majorversion (word 80) */ + +#define SATA_MAJVER_7 0x0080 /* ATA/ATAPI-7 version supported */ +#define SATA_MAJVER_654 0x0070 /* ATA/ATAPI-6,5 or 4 ver supported */ +#define SATA_MAJVER_6 0x0040 /* ATA/ATAPI-6 version supported */ +#define SATA_MAJVER_5 0x0020 /* ATA/ATAPI-7 version supported */ +#define SATA_MAJVER_4 0x0010 /* ATA/ATAPI-4 version supported */ + +/* Identify Device: command set supported/enabled bits - words 83 and 86 */ + +#define SATA_EXT48 0x0400 /* 48 bit address feature */ +#define SATA_PWRUP_IN_STANDBY 0x0020 /* Power-up in standby mode supp/en */ +#define SATA_RM_STATUS_NOTIFIC 0x0010 /* Removable Media Stat Notification */ +#define SATA_RW_DMA_QUEUED_CMD 0x0002 /* R/W DMA Queued supported */ +#define SATA_DWNLOAD_MCODE_CMD 0x0001 /* Download Microcode CMD supp/enbld */ +#define SATA_ACOUSTIC_MGMT 0x0200 /* Acoustic Management features */ + +/* Identify Device: command set supported/enabled bits - words 82 and 85 */ + +#define SATA_SMART_SUPPORTED 0x0001 /* SMART feature set is supported */ +#define SATA_WRITE_CACHE 0x0020 /* Write Cache supported/enabled */ +#define SATA_LOOK_AHEAD 0x0040 /* Look Ahead supported/enabled */ +#define SATA_DEVICE_RESET_CMD 0x0200 /* Device Reset CMD supported/enbld */ +#define SATA_READ_BUFFER_CMD 0x2000 /* Read Buffer CMD supported/enbld */ +#define SATA_WRITE_BUFFER_CMD 0x1000 /* Write Buffer CMD supported/enbld */ +#define SATA_SMART_ENABLED 0x0001 /* SMART feature set is enabled */ + +/* Identify Device: command set supported/enabled bits - words 84 & 87 */ +#define SATA_SMART_SELF_TEST_SUPPORTED 0x0002 /* SMART self-test supported */ +/* IDLE IMMEDIATE with UNLOAD FEATURE supported */ +#define SATA_IDLE_UNLOAD_SUPPORTED 0x2000 +#define SATA_GPL_SUPPORTED 0x0020 /* General Purpose Logging supported */ + +/* Identify Device: physical sector size - word 106 */ +#define SATA_L2PS_CHECK_BIT 0x4000 /* Set when this word valid */ +#define SATA_L2PS_HAS_MULT 0x2000 /* Multiple logical sectors per phys */ +#define SATA_L2PS_BIG_SECTORS 0x1000 /* Logical sector size > 512 */ +#define SATA_L2PS_EXP_MASK 0x000f /* Logical sectors per phys exponent */ + +/* Identify (Packet) Device word 63, ATA/ATAPI-6 & 7 */ +#define SATA_MDMA_SEL_MASK 0x0700 /* Multiword DMA selected */ +#define SATA_MDMA_2_SEL 0x0400 /* Multiword DMA mode 2 selected */ +#define SATA_MDMA_1_SEL 0x0200 /* Multiword DMA mode 1 selected */ +#define SATA_MDMA_0_SEL 0x0100 /* Multiword DMA mode 0 selected */ +#define SATA_MDMA_2_SUP 0x0004 /* Multiword DMA mode 2 supported */ +#define SATA_MDMA_1_SUP 0x0002 /* Multiword DMA mode 1 supported */ +#define SATA_MDMA_0_SUP 0x0001 /* Multiword DMA mode 0 supported */ +#define SATA_MDMA_SUP_MASK 0x0007 /* Multiword DMA supported */ + +/* Identify (Packet) Device Word 88 */ +#define SATA_UDMA_SUP_MASK 0x007f /* UDMA modes supported */ +#define SATA_UDMA_SEL_MASK 0x7f00 /* UDMA modes selected */ + +/* Data Set Management: word 169 */ +#define SATA_DSM_TRIM 0x0001 /* Set when TRIM is supported */ + +/* Identify Device: command set supported/enabled bits - word 206 */ + +/* All are SCT Command Transport support */ +#define SATA_SCT_CMD_TRANS_SUP 0x0001 /* anything */ +#define SATA_SCT_CMD_TRANS_LNG_SECT_SUP 0x0002 /* Long Sector Access */ +#define SATA_SCT_CMD_TRANS_WR_SAME_SUP 0x0004 /* Write Same */ +#define SATA_SCT_CMD_TRANS_ERR_RCOV_SUP 0x0008 /* Error Recovery Control */ +#define SATA_SCT_CMD_TRANS_FEAT_CTL_SUP 0x0010 /* Features Control */ +#define SATA_SCT_CMD_TRANS_DATA_TBL_SUP 0x0020 /* Data Tables supported */ + +#define SATA_DISK_SECTOR_SIZE 512 /* HD physical sector size */ + +/* Identify Packet Device data definitions (ATAPI devices) */ + +/* Identify Packet Device: general config bits - word 0 */ + +#define SATA_ATAPI_TYPE_MASK 0xc000 +#define SATA_ATAPI_TYPE 0x8000 /* ATAPI device */ +#define SATA_ATAPI_ID_PKT_SZ 0x0003 /* Packet size mask */ +#define SATA_ATAPI_ID_PKT_12B 0x0000 /* Packet size 12 bytes */ +#define SATA_ATAPI_ID_PKT_16B 0x0001 /* Packet size 16 bytes */ +#define SATA_ATAPI_ID_DRQ_TYPE 0x0060 /* DRQ asserted in 3ms after pkt */ +#define SATA_ATAPI_ID_DRQ_INTR 0x0020 /* Obsolete in ATA/ATAPI 7 */ + +#define SATA_ATAPI_ID_DEV_TYPE 0x1f00 /* device type/command set mask */ +#define SATA_ATAPI_ID_DEV_SHFT 8 +#define SATA_ATAPI_DIRACC_DEV 0x0000 /* Direct Access device */ +#define SATA_ATAPI_SQACC_DEV 0x0100 /* Sequential access dev (tape ?) */ +#define SATA_ATAPI_PROC_DEV 0x0300 /* Processor device */ +#define SATA_ATAPI_CDROM_DEV 0x0500 /* CD_ROM device */ + +/* + * Status bits from ATAPI Interrupt reason register (AT_COUNT) register + */ +#define SATA_ATAPI_I_COD 0x01 /* Command or Data */ +#define SATA_ATAPI_I_IO 0x02 /* IO direction */ +#define SATA_ATAPI_I_RELEASE 0x04 /* Release for ATAPI overlap */ + +/* ATAPI feature reg definitions */ + +#define SATA_ATAPI_F_DATA_DIR_READ 0x04 /* DMA transfer to the host */ +#define SATA_ATAPI_F_OVERLAP 0x02 /* Not used by Sun drivers */ +#define SATA_ATAPI_F_DMA 0x01 /* Packet DMA command */ + + +/* ATAPI IDENTIFY_DRIVE capabilities word (49) */ + +#define SATA_ATAPI_ID_CAP_DMA 0x0100 /* if zero, check word 62 */ +#define SATA_ATAPI_ID_CAP_OVERLAP 0x2000 + +/* + * ATAPI Identify Packet Device word 62 + * Word 62 is not valid for ATA/ATAPI-6 + * Defs below are for ATA/ATAPI-7 + */ +#define SATA_ATAPI_ID_DMADIR_REQ 0x8000 /* DMA direction required */ +#define SATA_ATAPI_ID_DMA_SUP 0x0400 /* DMA is supported */ + +/* + * ATAPI signature bits + */ +#define SATA_ATAPI_SIG_HI 0xeb /* in high cylinder register */ +#define SATA_ATAPI_SIG_LO 0x14 /* in low cylinder register */ + +/* These values are pre-set for CD_ROM/DVD ? */ + +#define SATA_ATAPI_SECTOR_SIZE 2048 +#define SATA_ATAPI_MAX_BYTES_PER_DRQ 0xf800 /* 16 bits - 2KB ie 62KB */ +#define SATA_ATAPI_HEADS 64 +#define SATA_ATAPI_SECTORS_PER_TRK 32 + +/* SATA Capabilites bits (word 76) */ + +#define SATA_NCQ 0x100 +#define SATA_3_SPEED 0x008 +#define SATA_2_SPEED 0x004 +#define SATA_1_SPEED 0x002 + +/* SATA Features Supported (word 78) - not used */ + +/* SATA Features Enabled (word 79) - not used */ + +#define SATA_READ_AHEAD_SUPPORTED(x) ((x).ai_cmdset82 & SATA_LOOK_AHEAD) +#define SATA_READ_AHEAD_ENABLED(x) ((x).ai_features85 & SATA_LOOK_AHEAD) +#define SATA_WRITE_CACHE_SUPPORTED(x) ((x).ai_cmdset82 & SATA_WRITE_CACHE) +#define SATA_WRITE_CACHE_ENABLED(x) ((x).ai_features85 & SATA_WRITE_CACHE) +#define SATA_RM_NOTIFIC_SUPPORTED(x) \ + ((x).ai_cmdset83 & SATA_RM_STATUS_NOTIFIC) +#define SATA_RM_NOTIFIC_ENABLED(x) \ + ((x).ai_features86 & SATA_RM_STATUS_NOTIFIC) + +/* + * Generic NCQ related defines + */ + +#define NQ 0x80 /* Not a queued cmd - tag not valid */ +#define NCQ_TAG_MASK 0x1f /* NCQ command tag mask */ +#define FIS_TYPE_REG_H2D 0x27 /* Reg FIS - Host to Device */ +#define FIS_CMD_UPDATE 0x80 +/* + * Status bits from AT_STATUS register + */ +#define SATA_STATUS_BSY 0x80 /* controller busy */ +#define SATA_STATUS_DRDY 0x40 /* drive ready */ +#define SATA_STATUS_DF 0x20 /* device fault */ +#define SATA_STATUS_DSC 0x10 /* seek operation complete */ +#define SATA_STATUS_DRQ 0x08 /* data request */ +#define SATA_STATUS_CORR 0x04 /* obsolete */ +#define SATA_STATUS_IDX 0x02 /* obsolete */ +#define SATA_STATUS_ERR 0x01 /* error flag */ + +/* + * Status bits from AT_ERROR register + */ +#define SATA_ERROR_ICRC 0x80 /* CRC data transfer error detected */ +#define SATA_ERROR_UNC 0x40 /* uncorrectable data error */ +#define SATA_ERROR_MC 0x20 /* Media change */ +#define SATA_ERROR_IDNF 0x10 /* ID/Address not found */ +#define SATA_ERROR_MCR 0x08 /* media change request */ +#define SATA_ERROR_ABORT 0x04 /* aborted command */ +#define SATA_ERROR_NM 0x02 /* no media */ +#define SATA_ERROR_EOM 0x02 /* end of media (Packet cmds) */ +#define SATA_ERROR_ILI 0x01 /* cmd sepcific */ + + +/* + * Bits from the device control register + */ +#define SATA_DEVCTL_NIEN 0x02 /* not interrupt enabled */ +#define SATA_DEVCTL_SRST 0x04 /* software reset */ +#define SATA_DEVCTL_HOB 0x80 /* high order bit */ + +/* device_reg */ +#define SATA_ADH_LBA 0x40 /* addressing in LBA mode not chs */ + +/* ATAPI transport version-in Inquiry data */ +#define SATA_ATAPI_TRANS_VERSION(inq) \ + (*((uint8_t *)(inq) + 3) >> 4) + +#define SCSI_LOG_PAGE_HDR_LEN 4 /* # bytes of a SCSI log page header */ +#define SCSI_LOG_PARAM_HDR_LEN 4 /* # byttes of a SCSI log param hdr */ + +/* Number of log entries per extended selftest log block */ +#define ENTRIES_PER_EXT_SELFTEST_LOG_BLK 19 + +/* Number of entries per SCSI LOG SENSE SELFTEST RESULTS page */ +#define SCSI_ENTRIES_IN_LOG_SENSE_SELFTEST_RESULTS 20 + +/* Length of a SCSI LOG SENSE SELFTEST RESULTS parameter */ +#define SCSI_LOG_SENSE_SELFTEST_PARAM_LEN 0x10 + +#define DIAGNOSTIC_FAILURE_ON_COMPONENT 0x40 + +#define SCSI_COMPONENT_81 0x81 +#define SCSI_COMPONENT_82 0x82 +#define SCSI_COMPONENT_83 0x83 +#define SCSI_COMPONENT_84 0x84 +#define SCSI_COMPONENT_85 0x85 +#define SCSI_COMPONENT_86 0x86 +#define SCSI_COMPONENT_87 0x87 +#define SCSI_COMPONENT_88 0x88 + +#define SCSI_ASC_ATA_DEV_FEAT_NOT_ENABLED 0x67 +#define SCSI_ASCQ_ATA_DEV_FEAT_NOT_ENABLED 0x0b + +#define SCSI_PREDICTED_FAILURE 0x5d +#define SCSI_GENERAL_HD_FAILURE 0x10 + +#define SCSI_INFO_EXCEPTIONS_PARAM_LEN 4 + +#define READ_LOG_EXT_LOG_DIRECTORY 0x00 +#define DEVICE_STATS_LOG 0x04 +#define DEVSTAT_GENERAL_STATS 0x01 +#define DEVSTAT_ROTATING_MEDIA_PAGE 0x03 +#define DEVSTAT_GENERAL_ERRORS_PAGE 0x04 +#define DEVSTAT_TEMP_PAGE 0x05 +#define DEVSTAT_SSD_PAGE 0x07 +#define SMART_SELFTEST_LOG_PAGE 0x06 +#define EXT_SMART_SELFTEST_LOG_PAGE 0x07 +#define READ_LOG_EXT_NCQ_ERROR_RECOVERY 0x10 + + +#define SATA_STAT_SUPPORTED(x) ((x) & (1ULL << 63)) +#define SATA_STAT_VALID(x) ((x) & (1ULL << 62)) +#define SATA_STAT_VALUE(x) ((x) & ((1ULL << 59) - 1)) + +/* + * SATA NCQ error recovery page (0x10) + */ +struct sata_ncq_error_recovery_page { + uint8_t ncq_tag; + uint8_t reserved1; + uint8_t ncq_status; + uint8_t ncq_error; + uint8_t ncq_sector_number; + uint8_t ncq_cyl_low; + uint8_t ncq_cyl_high; + uint8_t ncq_dev_head; + uint8_t ncq_sector_number_ext; + uint8_t ncq_cyl_low_ext; + uint8_t ncq_cyl_high_ext; + uint8_t reserved2; + uint8_t ncq_sector_count; + uint8_t ncq_sector_count_ext; + uint8_t reserved3[242]; + uint8_t ncq_vendor_unique[255]; + uint8_t ncq_checksum; +}; + +/* SMART attribute of Start/Stop Count */ +#define SMART_START_STOP_COUNT_ID 0x4 + +/* + * SMART data structures + */ +struct smart_data { + uint8_t smart_vendor_specific[362]; + uint8_t smart_offline_data_collection_status; + uint8_t smart_selftest_exec_status; + uint8_t smart_secs_to_complete_offline_data[2]; + uint8_t smart_vendor_specific2; + uint8_t smart_offline_data_collection_capability; + uint8_t smart_capability[2]; + uint8_t smart_error_logging_capability; + uint8_t smart_vendor_specific3; + uint8_t smart_short_selftest_polling_time; + uint8_t smart_extended_selftest_polling_time; + uint8_t smart_conveyance_selftest_polling_time; + uint8_t smart_reserved[11]; + uint8_t smart_vendor_specific4[125]; + uint8_t smart_checksum; +}; + +struct smart_selftest_log_entry { + uint8_t smart_selftest_log_lba_low; + uint8_t smart_selftest_log_status; + uint8_t smart_selftest_log_timestamp[2]; + uint8_t smart_selftest_log_checkpoint; + uint8_t smart_selftest_log_failing_lba[4]; /* from LSB to MSB */ + uint8_t smart_selftest_log_vendor_specific[15]; +}; + +#define NUM_SMART_SELFTEST_LOG_ENTRIES 21 +struct smart_selftest_log { + uint8_t smart_selftest_log_revision[2]; + struct smart_selftest_log_entry + smart_selftest_log_entries[NUM_SMART_SELFTEST_LOG_ENTRIES]; + uint8_t smart_selftest_log_vendor_specific[2]; + uint8_t smart_selftest_log_index; + uint8_t smart_selftest_log_reserved[2]; + uint8_t smart_selftest_log_checksum; +}; + +struct smart_ext_selftest_log_entry { + uint8_t smart_ext_selftest_log_lba_low; + uint8_t smart_ext_selftest_log_status; + uint8_t smart_ext_selftest_log_timestamp[2]; + uint8_t smart_ext_selftest_log_checkpoint; + uint8_t smart_ext_selftest_log_failing_lba[6]; + uint8_t smart_ext_selftest_log_vendor_specific[15]; +}; + +struct smart_ext_selftest_log { + uint8_t smart_ext_selftest_log_rev; + uint8_t smart_ext_selftest_log_reserved; + uint8_t smart_ext_selftest_log_index[2]; + struct smart_ext_selftest_log_entry smart_ext_selftest_log_entries[19]; + uint8_t smart_ext_selftest_log_vendor_specific[2]; + uint8_t smart_ext_selftest_log_reserved2[11]; + uint8_t smart_ext_selftest_log_checksum; +}; + +struct read_log_ext_directory { + uint8_t read_log_ext_vers[2]; /* general purpose log version */ + uint8_t read_log_ext_nblks[255][2]; /* # of blks @ log addr index+1 */ +}; + +/* + * The definition of CONTROL byte field in SCSI command + * according to SAM 5 + */ +#define CTL_BYTE_VENDOR_MASK 0xc0 +#define CTL_BYTE_NACA_MASK 0x04 + +/* + * The definition of mask in START STOP UNIT command + */ +#define START_STOP_IMMED_MASK 0x01 +#define START_STOP_POWER_COND_MASK 0xF0 +#define START_STOP_START_MASK 0x01 +#define START_STOP_LOEJ_MASK 0x02 +#define START_STOP_NOFLUSH_MASK 0x04 +#define START_STOP_MODIFIER_MASK 0x0f +#define START_STOP_POWER_COND_SHIFT 4 + +/* + * SMART specific data + * These eventually need to go to a generic scsi header file + * for now they will reside here + */ +#define PC_CUMULATIVE_VALUES 0x01 +#define PAGE_CODE_GET_SUPPORTED_LOG_PAGES 0x00 +#define PAGE_CODE_READ_ERRORS 0x03 +#define PAGE_CODE_TEMPERATURE 0x0d +#define PAGE_CODE_START_STOP_CYCLE_COUNTER 0x0e +#define PAGE_CODE_SELF_TEST_RESULTS 0x10 +#define PAGE_CODE_SOLID_STATE_MEDIA 0x11 +#define PAGE_CODE_GENERAL_STATS 0x19 +#define PAGE_CODE_INFORMATION_EXCEPTIONS 0x2f +#define PAGE_CODE_SMART_READ_DATA 0x30 + + +struct log_parameter { + uint8_t param_code[2]; /* parameter dependant */ + uint8_t param_ctrl_flags; /* see defines below */ + uint8_t param_len; /* # of bytes following */ + uint8_t param_values[]; /* # of bytes defined by param_len */ +}; + +/* param_ctrl_flag fields */ +#define LOG_CTRL_LP 0x01 /* list parameter */ +#define LOG_CTRL_LBIN 0x02 /* list is binary */ +#define LOG_CTRL_TMC 0x0c /* threshold met criteria */ +#define LOG_CTRL_ETC 0x10 /* enable threshold comparison */ +#define LOG_CTRL_TSD 0x20 /* target save disable */ +#define LOG_CTRL_DS 0x40 /* disable save */ +#define LOG_CTRL_DU 0x80 /* disable update */ + +#define SMART_MAGIC_VAL_1 0x4f +#define SMART_MAGIC_VAL_2 0xc2 +#define SMART_MAGIC_VAL_3 0xf4 +#define SMART_MAGIC_VAL_4 0x2c + +#define SCT_STATUS_LOG_PAGE 0xe0 + +#define SCSI_NO_TEMP 0xff + +/* + * Acoustic management + */ + +struct mode_acoustic_management { + struct mode_page mode_page; /* common mode page header */ + uchar_t acoustic_manag_enable; /* Set to 1 enable, Set 0 disable */ + uchar_t acoustic_manag_level; /* Acoustic management level */ + uchar_t vendor_recommended_value; /* Vendor recommended value */ +}; + +#define PAGELENGTH_DAD_MODE_ACOUSTIC_MANAGEMENT 3 /* Acoustic manag pg len */ +#define P_CNTRL_CURRENT 0 +#define P_CNTRL_CHANGEABLE 1 +#define P_CNTRL_DEFAULT 2 +#define P_CNTRL_SAVED 3 + +#define ACOUSTIC_DISABLED 0 +#define ACOUSTIC_ENABLED 1 + +#define MODEPAGE_ACOUSTIC_MANAG 0x30 + +/* + * Port Multiplier registers' offsets + */ +#define SATA_PMULT_GSCR0 0x0 +#define SATA_PMULT_GSCR1 0x1 +#define SATA_PMULT_GSCR2 0x2 +#define SATA_PMULT_GSCR32 0x20 +#define SATA_PMULT_GSCR33 0x21 +#define SATA_PMULT_GSCR64 0x40 +#define SATA_PMULT_GSCR96 0x60 + +#define SATA_PMULT_PORTNUM_MASK 0xf + +#define SATA_PMULT_PSCR0 0x0 +#define SATA_PMULT_PSCR1 0x1 +#define SATA_PMULT_PSCR2 0x2 +#define SATA_PMULT_PSCR3 0x3 +#define SATA_PMULT_PSCR4 0x4 + +#define SATA_PMULT_REG_SSTS (SATA_PMULT_PSCR0) +#define SATA_PMULT_REG_SERR (SATA_PMULT_PSCR1) +#define SATA_PMULT_REG_SCTL (SATA_PMULT_PSCR2) +#define SATA_PMULT_REG_SACT (SATA_PMULT_PSCR3) +#define SATA_PMULT_REG_SNTF (SATA_PMULT_PSCR4) + +/* + * Port Multiplier capabilities + * (Indicated by GSCR64, and enabled by GSCR96) + */ +#define SATA_PMULT_CAP_BIST (1 << 0) +#define SATA_PMULT_CAP_PMREQ (1 << 1) +#define SATA_PMULT_CAP_SSC (1 << 2) +#define SATA_PMULT_CAP_SNOTIF (1 << 3) +#define SATA_PMULT_CAP_PHYEVENT (1 << 4) + +/* + * sstatus field definitions + */ +#define SSTATUS_DET_SHIFT 0 +#define SSTATUS_SPD_SHIFT 4 +#define SSTATUS_IPM_SHIFT 8 + +#define SSTATUS_DET (0xf << SSTATUS_DET_SHIFT) +#define SSTATUS_SPD (0xf << SSTATUS_SPD_SHIFT) +#define SSTATUS_IPM (0xf << SSTATUS_IPM_SHIFT) + +/* + * sstatus DET values + */ +#define SSTATUS_DET_NODEV 0 /* No dev detected */ +#define SSTATUS_DET_DEVPRE_NOPHYCOM 1 /* dev detected */ +#define SSTATUS_DET_DEVPRE_PHYCOM 3 /* dev detected */ +#define SSTATUS_DET_PHYOFFLINE 4 /* PHY is in offline */ + +#define SSTATUS_GET_DET(x) \ + (x & SSTATUS_DET) + +#define SSTATUS_SET_DET(x, new_val) \ + (x = (x & ~SSTATUS_DET) | (new_val & SSTATUS_DET)) + +#define SSTATUS_SPD_NODEV 0 /* No device present */ +#define SSTATUS_SPD_GEN1 1 /* Gen 1 rate negotiated */ +#define SSTATUS_SPD_GEN2 2 /* Gen 2 rate negotiated */ +#define SSTATUS_SPD_GEN3 3 /* Gen 3 rate negotiated */ + +/* + * sstatus IPM values + */ +#define SSTATUS_IPM_NODEV_NOPHYCOM 0x0 /* No dev, no PHY */ +#define SSTATUS_IPM_ACTIVE 0x1 /* Interface active */ +#define SSTATUS_IPM_POWERPARTIAL 0x2 /* partial power mgmnt */ +#define SSTATUS_IPM_POWERSLUMBER 0x6 /* slumber power mgmt */ + +#define SSTATUS_GET_IPM(x) \ + ((x & SSTATUS_IPM) >> SSTATUS_IPM_SHIFT) + +#define SSTATUS_SET_IPM(x, new_val) \ + (x = (x & ~SSTATUS_IPM) | \ + ((new_val << SSTATUS_IPM_SHIFT) & SSTATUS_IPM)) + + +/* + * serror register fields + */ +#define SERROR_DATA_ERR_FIXED (1 << 0) /* D integrity err */ +#define SERROR_COMM_ERR_FIXED (1 << 1) /* comm err recov */ +#define SERROR_DATA_ERR (1 << 8) /* D integrity err */ +#define SERROR_PERSISTENT_ERR (1 << 9) /* norecov com err */ +#define SERROR_PROTOCOL_ERR (1 << 10) /* protocol err */ +#define SERROR_INT_ERR (1 << 11) /* internal err */ +#define SERROR_PHY_RDY_CHG (1 << 16) /* PHY state change */ +#define SERROR_PHY_INT_ERR (1 << 17) /* PHY internal err */ +#define SERROR_COMM_WAKE (1 << 18) /* COM wake */ +#define SERROR_10B_TO_8B_ERR (1 << 19) /* 10B-to-8B decode */ +#define SERROR_DISPARITY_ERR (1 << 20) /* disparity err */ +#define SERROR_CRC_ERR (1 << 21) /* CRC err */ +#define SERROR_HANDSHAKE_ERR (1 << 22) /* Handshake err */ +#define SERROR_LINK_SEQ_ERR (1 << 23) /* Link seq err */ +#define SERROR_TRANS_ERR (1 << 24) /* Tran state err */ +#define SERROR_FIS_TYPE (1 << 25) /* FIS type err */ +#define SERROR_EXCHANGED_ERR (1 << 26) /* Device exchanged */ + +/* + * S-Control Bridge port x register fields + */ +#define SCONTROL_DET_SHIFT 0 +#define SCONTROL_SPD_SHIFT 4 +#define SCONTROL_IPM_SHIFT 8 +#define SCONTROL_SPM_SHIFT 12 + +#define SCONTROL_DET (0xf << SCONTROL_DET_SHIFT) +#define SCONTROL_SPD (0xf << SCONTROL_SPD_SHIFT) +#define SCONTROL_IPM (0xf << SCONTROL_IPM_SHIFT) +#define SCONTROL_SPM (0xf << SCONTROL_SPM_SHIFT) + +#define SCONTROL_GET_DET(x) \ + (x & SCONTROL_DET) + +#define SCONTROL_SET_DET(x, new_val) \ + (x = (x & ~SCONTROL_DET) | (new_val & SCONTROL_DET)) + +#define SCONTROL_DET_NOACTION 0 /* Do nothing to port */ +#define SCONTROL_DET_COMRESET 1 /* Re-initialize port */ +#define SCONTROL_DET_DISABLE 4 /* Disable port */ + +#define SCONTROL_SPD_NOLIMIT 0 /* No speed limit */ +#define SCONTROL_SPD_GEN1 1 /* Limit Gen 1 rate */ +#define SCONTROL_SPD_GEN2 2 /* Limit Gen 2 rate */ +#define SCONTROL_SPD_GEN3 3 /* Limit Gen 3 rate */ + +#define SCONTROL_GET_IPM(x) \ + ((x & SCONTROL_IPM) >> SCONTROL_IPM_SHIFT) + +#define SCONTROL_SET_IPM(x, new_val) \ + (x = (x & ~SCONTROL_IPM) | \ + ((new_val << SCONTROL_IPM_SHIFT) & SCONTROL_IPM)) + +/* NB: IPM disable value is a bit-field (though not described) */ +#define SCONTROL_IPM_NORESTRICT 0 /* No PM limit */ +#define SCONTROL_IPM_DISABLE_PARTIAL 1 /* Disable partial */ +#define SCONTROL_IPM_DISABLE_SLUMBER 2 /* Disable slumber */ +#define SCONTROL_IPM_DISABLE_BOTH 3 /* Disable both */ +#define SCONTROL_IPM_DISABLE_DEVSLEEP 4 /* Disable devsleep */ +#define SCONTROL_IPM_DISABLE_ALL 7 /* Disable all PM */ + +#define SCONTROL_SPM_NORESTRICT 0 /* No PM limits */ +#define SCONTROL_SPM_DO_PARTIAL 1 /* Go to partial */ +#define SCONTROL_SPM_DO_SLUMBER 2 /* Go to slumber */ +#define SCONTROL_SPM_DO_ACTIVE 4 /* Go to active */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SATA_DEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/sata/sata_hba.h b/illumos-x86_64/usr/include/sys/sata/sata_hba.h new file mode 100644 index 00000000..3680bf7c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sata/sata_hba.h @@ -0,0 +1,795 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SATA_HBA_H +#define _SATA_HBA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * SATA Host Bus Adapter (HBA) driver transport definitions + */ + +#include + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#define SATA_SUCCESS 0 +#define SATA_RETRY 1 +#define SATA_FAILURE -1 + + +/* SATA Framework definitions */ + +#define SATA_MAX_CPORTS 32 /* Max number of controller ports */ + /* Multiplier (PMult) */ +#define SATA_MAX_PMPORTS 16 /* Maximum number of ports on PMult */ +#define SATA_PMULT_HOSTPORT 0xf /* Port Multiplier host port number */ + + +/* + * SATA device address + * Address qualifier flags are used to specify what is addressed (device + * or port) and where (controller or port multiplier data port). + */ +struct sata_address { + uint8_t cport; /* Controller's SATA port number */ + uint8_t pmport; /* Port Multiplier SATA port number */ + uint8_t qual; /* Address Qualifier flags */ + uint8_t pad; /* Reserved */ +}; + +typedef struct sata_address sata_address_t; + +/* + * SATA address Qualifier flags (in qual field of sata_address struct). + * They are mutually exclusive. + */ + +#define SATA_ADDR_NULL 0x00 /* No address */ +#define SATA_ADDR_DCPORT 0x01 /* Device attched to controller port */ +#define SATA_ADDR_DPMPORT 0x02 /* Device attched to PM device port */ +#define SATA_ADDR_CPORT 0x04 /* Controller's device port */ +#define SATA_ADDR_PMPORT 0x08 /* Port Multiplier's device port */ +#define SATA_ADDR_CNTRL 0x10 /* Controller */ +#define SATA_ADDR_PMULT 0x20 /* Port Multiplier */ +#define SATA_ADDR_PMULT_SPEC 0x40 /* Port Multiplier Specific */ + +/* + * SATA port status and control register block. + * The sstatus, serror, scontrol, sactive and snotific + * are the copies of the SATA port status and control registers. + * (Port SStatus, SError, SControl, SActive and SNotification are + * defined by Serial ATA r1.0a sepc and Serial ATA II spec. + */ + +struct sata_port_scr +{ + uint32_t sstatus; /* Port SStatus register */ + uint32_t serror; /* Port SError register */ + uint32_t scontrol; /* Port SControl register */ + uint32_t sactive; /* Port SActive register */ + uint32_t snotific; /* Port SNotification register */ +}; + +typedef struct sata_port_scr sata_port_scr_t; + +/* + * SATA Port Multiplier general status and control register block. + * The gscr0, gscr1, gscr2 are the copyies of the register on port multiplier. + * GSCR[0], GSCR[1], GSCR[2] are defined in SATA defined by Port Multiplier + * 1.0/1.1/1.2 spec. + */ +struct sata_pmult_gscr { + uint32_t gscr0; /* Product Identifier register */ + uint32_t gscr1; /* Resrved Information register */ + uint32_t gscr2; /* Port Information register */ + uint32_t gscr64; /* Feature register */ + uint32_t resv[4]; /* Reseved */ +}; + +typedef struct sata_pmult_gscr sata_pmult_gscr_t; + +/* + * SATA Device Structure (rev 1) + * Used to request/return state of the controller, port, port multiplier + * or an attached drive: + * The satadev_addr.cport, satadev_addr.pmport and satadev_addr.qual + * fields are used to specify SATA address (see sata_address structure + * description). + * The satadev_scr structure is used to pass the content of a port + * status and control registers. + * The satadev_add_info field is used by SATA HBA driver to return an + * additional information, which type depends on the function using + * sata_device as argument. For example: + * - in case of sata_tran_probe_port() this field should contain + * a number of available Port Multiplier device ports; + * - in case of sata_hba_event_notify() this field may contain + * a value specific for a reported event. + */ +#define SATA_DEVICE_REV_1 1 +#define SATA_DEVICE_REV SATA_DEVICE_REV_1 + +struct sata_device +{ + int satadev_rev; /* structure version */ + struct sata_address satadev_addr; /* sata port/device address */ + uint32_t satadev_state; /* Port or device state */ + uint32_t satadev_type; /* Attached device type */ + struct sata_port_scr satadev_scr; /* Port status and ctrl regs */ + uint32_t satadev_add_info; /* additional information, */ + /* function specific */ +}; + +typedef struct sata_device sata_device_t; + +_NOTE(SCHEME_PROTECTS_DATA("unshared data", sata_device)) + + +/* + * satadev_state field of sata_device structure. + * Common flags specifying current state of a port or an attached drive. + * These states are mutually exclusive, obviously + */ +#define SATA_STATE_UNKNOWN 0x000000 +#define SATA_STATE_READY 0x000010 + +/* + * Attached drive specific states (satadev_state field of the sata_device + * structure). + * SATA_DSTATE_PWR_ACTIVE, SATA_DSTATE_PWR_IDLE and SATA_DSTATE_PWR_STANDBY + * are mutually exclusive. All other states may be combined with each other + * and with one of the power states. + * These flags may be used only if the address qualifier (satadev_addr.qual) is + * set to SATA_ADDR_DCPORT or SATA_ADDR_DPMPORT value. + */ + +#define SATA_DSTATE_PWR_ACTIVE 0x000100 +#define SATA_DSTATE_PWR_IDLE 0x000200 +#define SATA_DSTATE_PWR_STANDBY 0x000400 +#define SATA_DSTATE_RESET 0x001000 +#define SATA_DSTATE_PMULT_INIT 0x002000 +#define SATA_DSTATE_FAILED 0x008000 + +/* Mask for drive power states */ +#define SATA_DSTATE_PWR (SATA_DSTATE_PWR_ACTIVE | \ + SATA_DSTATE_PWR_IDLE | \ + SATA_DSTATE_PWR_STANDBY) +/* + * SATA Port specific states (satadev_state field of sata_device structure). + * SATA_PSTATE_PWRON and SATA_PSTATE_PWROFF are mutually exclusive. + * All other states may be combined with each other and with one of the power + * level state. + * These flags may be used only if the address qualifier (satadev_addr.qual) is + * set to SATA_ADDR_CPORT or SATA_ADDR_PMPORT value. + */ + +#define SATA_PSTATE_PWRON 0x010000 +#define SATA_PSTATE_PWROFF 0X020000 +#define SATA_PSTATE_SHUTDOWN 0x040000 +#define SATA_PSTATE_FAILED 0x080000 + +/* Mask for the valid port-specific state flags */ +#define SATA_PSTATE_VALID (SATA_PSTATE_PWRON | \ + SATA_PSTATE_PWROFF | \ + SATA_PSTATE_SHUTDOWN | \ + SATA_PSTATE_FAILED) + +/* Mask for a port power states */ +#define SATA_PSTATE_PWR (SATA_PSTATE_PWRON | \ + SATA_PSTATE_PWROFF) +/* + * Device type (in satadev_type field of sata_device structure). + * More device types may be added in the future. + */ + +#define SATA_DTYPE_NONE 0x00 /* No device attached */ +#define SATA_DTYPE_ATADISK 0x01 /* ATA disk */ +#define SATA_DTYPE_ATAPI 0x40 /* ATAPI device */ +#define SATA_DTYPE_ATAPICD \ + (SATA_DTYPE_ATAPI|0x02) /* ATAPI CD/DVD device */ +#define SATA_DTYPE_ATAPITAPE \ + (SATA_DTYPE_ATAPI|0x04) /* ATAPI tape */ +#define SATA_DTYPE_ATAPIDISK \ + (SATA_DTYPE_ATAPI|0x08) /* ATAPI disk */ +#define SATA_DTYPE_PMULT 0x10 /* Port Multiplier */ +#define SATA_DTYPE_UNKNOWN 0x20 /* Device attached, unkown */ +#define SATA_DTYPE_ATAPIPROC \ + (SATA_DTYPE_ATAPI|0x80) /* ATAPI processor */ + + +/* + * SATA cmd structure (rev 1) + * + * SATA HBA framework always sets all fields except status_reg and error_reg. + * SATA HBA driver action depends on the addressing type specified by + * addr_type field: + * If LBA48 addressing is indicated, SATA HBA driver has to load values from + * satacmd_sec_count_msb_reg, satacmd_lba_low_msb_reg, + * satacmd_lba_mid_msb_reg and satacmd_lba_hi_msb_reg + * to appropriate registers prior to loading other registers. + * For other addressing modes, SATA HBA driver should skip loading values + * from satacmd_sec_count_msb_reg, satacmd_lba_low_msb_reg, + * satacmd_lba_mid_msb_reg and satacmd_lba_hi_msb_reg + * fields and load only remaining field values to corresponding registers. + * + * satacmd_sec_count_msb and satamcd_sec_count_lsb values are loaded into + * sec_count register, satacmd_sec_count_msb loaded first (if LBA48 + * addressing is used). + * satacmd_lba_low_msb and satacmd_lba_low_lsb values are loaded into the + * lba_low register, satacmd_lba_low_msb loaded first (if LBA48 addressing + * is used). The lba_low register is the newer name for the old + * sector_number register. + * satacmd_lba_mid_msb and satacmd_lba_mid_lsb values are loaded into lba_mid + * register, satacmd_lba_mid_msb loaded first (if LBA48 addressing is used). + * The lba_mid register is the newer name for the old cylinder_low register. + * satacmd_lba_high_msb and satacmd_lba_high_lsb values are loaded into + * the lba_high regster, satacmd_lba_high_msb loaded first (if LBA48 + * addressing is used). The lba_high register is a newer name for the old + * cylinder_high register. + * + * No addressing mode is selected when an ata command does not involve actual + * reading/writing data from/to the media (for example IDENTIFY DEVICE or + * SET FEATURE command), or the ATAPI PACKET command is sent. + * If ATAPI PACKET command is sent and tagged commands are used, + * SATA HBA driver has to provide and manage a tag value and + * set it into the sector_count register. + * + * Device Control register is not specified in sata_cmd structure - SATA HBA + * driver shall set it accordingly to current mode of operation (interrupt + * enable/disable). + * + * Buffer structure's b_flags should be used to determine the + * address type of b_un.b_addr. However, there is no need to allocate DMA + * resources for the buffer in SATA HBA driver. + * DMA resources for a buffer structure are allocated by the SATA HBA + * framework. Scatter/gather list is to be used only for DMA transfers + * and it should be based on the DMA cookies list. + * + * Upon completion of a command, SATA HBA driver has to update + * satacmd_status_reg and satacmd_error_reg to reflect the contents of + * the corresponding device status and error registers. + * If the command completed successfully, satacmd_flags.sata_copy_xxx flags + * specify what register fields should be updated in sata_cmd structure. + * If the command completed with error, SATA HBA driver has to update + * satacmd_sec_count_msb, satacmd_sec_count_lsb, satacmd_lba_low_msb, + * satacmd_lba_low_lsb, satacmd_lba_mid_msb, satacmd_lba_mid_lsb, + * satacmd_lba_high_msb and satacmd_lba_high_lsb to values read from the + * corresponding device registers. + * If an operation could not complete because of the port error, the + * sata_pkt.satapkt_device.satadev_scr structure has to be updated. + * + * If ATAPI PACKET command was sent and command completed with error, + * rqsense structure has to be filed by SATA HBA driver. The satacmd_arq_cdb + * points to pre-set request sense cdb that may be used for issuing request + * sense data from the device. + * + * The sata_max_queue_depth field specifies the maximum allowable queue depth + * minus one, i.e. for maximum queue depth of 32, sata_max_queue_depth would + * be set to value 0x1f. + * If FPDMA-type command was sent and command completed with error, the HBA + * driver may use pre-set command READ LOG EXTENDED command pointed to + * by satacmd_rle_sata_cmd field to retrieve error data from a device. + * Only ATA register fields of the sata_cmd are set-up for that purpose. + * + * If the READ MULTIPLIER command was specified in cmd_reg (command directed + * to a port multiplier host port rather then to an attached device), + * upon the command completion SATA HBA driver has to update_sector count + * and lba fields of the sata_cmd structure to values returned via + * command block registers (task file registers). + */ +#define SATA_CMD_REV_1 1 +#define SATA_CMD_REV_2 2 +#define SATA_CMD_REV_3 3 +#define SATA_CMD_REV SATA_CMD_REV_3 + +#define SATA_ATAPI_MAX_CDB_LEN 16 /* Covers both 12 and 16 byte cdbs */ +#define SATA_ATAPI_RQSENSE_LEN 24 /* Allocated Request Sense data */ +#define SATA_ATAPI_MIN_RQSENSE_LEN 18 /* Min Fixed size Request Sense data */ +#define SATA_ATAPI_RQSENSE_CDB_LEN 6 /* Request Sense CDB length */ + +#define SATA_MAX_QUEUE_DEPTH 32 /* Default max queue depth */ + +struct sata_cmd { + int satacmd_rev; /* version */ + struct buf *satacmd_bp; /* ptr to buffer structure */ + struct sata_cmd_flags { + uint32_t sata_data_direction : 3; /* 0-2 */ + uint32_t : 1; /* reserved */ /* 3 */ + uint32_t sata_queue_stag : 1; /* 4 */ + uint32_t sata_queue_otag : 1; /* 5 */ + uint32_t : 2; /* reserved */ /* 6-7 */ + uint32_t sata_queued : 1; /* 8 */ + uint32_t : 3; /* reserved */ /* 9-11 */ + uint32_t sata_ignore_dev_reset : 1; /* 12 */ + uint32_t sata_clear_dev_reset : 1; /* 13 */ + uint32_t : 2; /* reserved */ /* 14-15 */ + uint32_t sata_special_regs : 1; /* 16 */ + uint32_t sata_copy_out_sec_count_msb : 1; /* 17 */ + uint32_t sata_copy_out_lba_low_msb : 1; /* 18 */ + uint32_t sata_copy_out_lba_mid_msb : 1; /* 19 */ + uint32_t sata_copy_out_lba_high_msb : 1; /* 20 */ + uint32_t sata_copy_out_sec_count_lsb : 1; /* 21 */ + uint32_t sata_copy_out_lba_low_lsb : 1; /* 22 */ + uint32_t sata_copy_out_lba_mid_lsb : 1; /* 23 */ + uint32_t sata_copy_out_lba_high_lsb : 1; /* 24 */ + uint32_t sata_copy_out_device_reg : 1; /* 25 */ + uint32_t sata_copy_out_error_reg : 1; /* 26 */ + uint32_t sata_max_queue_depth: 5; /* 27-31 */ + } satacmd_flags; + uint8_t satacmd_addr_type; /* addr type: LBA28, LBA48 */ + uint8_t satacmd_features_reg_ext; /* features reg extended */ + uint8_t satacmd_sec_count_msb; /* sector count MSB (LBA48) */ + uint8_t satacmd_lba_low_msb; /* LBA Low MSB (LBA48) */ + uint8_t satacmd_lba_mid_msb; /* LBA Mid MSB (LBA48) */ + uint8_t satacmd_lba_high_msb; /* LBA High MSB (LBA48) */ + uint8_t satacmd_sec_count_lsb; /* sector count LSB */ + uint8_t satacmd_lba_low_lsb; /* LBA Low LSB */ + uint8_t satacmd_lba_mid_lsb; /* LBA Mid LSB */ + uint8_t satacmd_lba_high_lsb; /* LBA High LSB */ + uint8_t satacmd_device_reg; /* ATA dev reg & LBA28 MSB */ + uint8_t satacmd_cmd_reg; /* ata command code */ + uint8_t satacmd_features_reg; /* ATA features register */ + uint8_t satacmd_status_reg; /* ATA status register */ + uint8_t satacmd_error_reg; /* ATA error register */ + uint8_t satacmd_acdb_len; /* ATAPI cdb length */ + uint8_t satacmd_acdb[SATA_ATAPI_MAX_CDB_LEN]; /* ATAPI cdb */ + + /* kept for binary compat. */ + uint8_t *pad1; /* unused */ + + uint8_t satacmd_rqsense[SATA_ATAPI_RQSENSE_LEN]; + /* + * Error retrieval buffer + * dma handle pointer + * (for buffer DMA syncing) + * Valid only in error + * retrieval packet! + */ + ddi_dma_handle_t *satacmd_err_ret_buf_handle; + + int satacmd_num_dma_cookies; /* number of dma cookies */ + /* ptr to dma cookie list */ + ddi_dma_cookie_t *satacmd_dma_cookie_list; +}; + +typedef struct sata_cmd sata_cmd_t; + +_NOTE(SCHEME_PROTECTS_DATA("unshared data", sata_cmd)) + + +/* ATA address type (in satacmd_addr_type field */ +#define ATA_ADDR_LBA 0x1 +#define ATA_ADDR_LBA28 0x2 +#define ATA_ADDR_LBA48 0x4 + +/* + * satacmd_flags : contain data transfer direction flags, + * tagged queuing type flags, queued command flag, and reset state handling + * flag. + */ + +/* + * Data transfer direction flags (satacmd_flags.sata_data_direction) + * Direction flags are mutually exclusive. + */ +#define SATA_DIR_NODATA_XFER 0x0001 /* No data transfer */ +#define SATA_DIR_READ 0x0002 /* Reading data from a device */ +#define SATA_DIR_WRITE 0x0004 /* Writing data to a device */ + +/* + * Tagged Queuing type flags + * satacmd_flags.sata_queue_stag + * satacmd_flags.sata_queue_otag + * + * These flags indicate how the SATA command should be queued. + * + * sata_queue_stag + * Simple-queue-tagged command. It may be executed out-of-order in respect + * to other queued commands. + * sata_queue_otag + * Ordered-queue-tagged command. It cannot be executed out-of-order in + * respect to other commands, i.e. it should be executed in the order of + * being transported to the HBA. + * + * Translated head-of-queue-tagged scsi commands and commands that are + * to be put at the head of the queue are treated as sata_queue_otag + * tagged commands. + */ + + +/* + * Queuing command set-up flag (satacmd_flags.sata_queued). + * This flag indicates that sata_cmd was set-up for DMA Queued command + * (either READ_DMA_QUEUED, READ_DMA_QUEUED_EXT, WRITE_DMA_QUEUED or + * WRITE_DMA_QUEUED_EXT command) or one of the Native Command Queuing commands + * (either READ_FPDMA_QUEUED or WRITE_FPDMA_QUEUED). + * This flag will be used only if sata_tran_hba_flags indicates controller + * support for queuing and the device for which sata_cmd is prepared supports + * either legacy queuing (indicated by Device Identify data word 83 bit 2) + * or NCQ (indicated by word 76 of Device Identify data). + */ + +/* + * Reset state handling + * satacmd_flags.sata_ignore_dev_reset + * satacmd_flags.sata_clear_dev_reset + * + * SATA HBA device enters reset state if the device was subjected to + * the Device Reset (may also enter this state if the device was reset + * as a side effect of port reset). SATA HBA driver sets this state. + * Device stays in this condition until explicit request from SATA HBA + * framework to clear the state. + */ + +/* + * SATA Packet structure (rev 1) + * hba_driver_private is for a private use of the SATA HBA driver; + * satapkt_framework_private is used only by SATA HBA framework; + * satapkt_comp is a callback function to be called when packet + * execution is completed (for any reason) if mode of operation is not + * synchronous (SATA_OPMODE_SYNCH); + * satapkt_reason specifies why the packet operation was completed + * + * NOTE: after the packet completion callback SATA HBA driver should not + * attempt to access any sata_pkt fields because sata_pkt is not valid anymore + * (it could have been destroyed). + * Since satapkt_hba_driver_private field cannot be retrieved, any hba private + * data respources allocated per packet and accessed via this pointer should + * either be freed before the completion callback is done, or the pointer has + * to be saved by the HBA driver before the completion callback. + */ +#define SATA_PKT_REV_1 1 +#define SATA_PKT_REV SATA_PKT_REV_1 + +struct sata_pkt { + int satapkt_rev; /* version */ + struct sata_device satapkt_device; /* Device address/type */ + + /* HBA driver private data */ + void *satapkt_hba_driver_private; + + /* SATA framework priv data */ + void *satapkt_framework_private; + + /* Rqsted mode of operation */ + uint32_t satapkt_op_mode; + + struct sata_cmd satapkt_cmd; /* composite sata command */ + int satapkt_time; /* time allotted to command */ + void (*satapkt_comp)(struct sata_pkt *); /* callback */ + int satapkt_reason; /* completion reason */ +}; + +typedef struct sata_pkt sata_pkt_t; + +_NOTE(SCHEME_PROTECTS_DATA("unshared data", sata_pkt)) + + +/* + * Operation mode flags (in satapkt_op_mode field of sata_pkt structure). + * Use to specify what should be a mode of operation for specified command. + * Default (000b) means use Interrupt and Asynchronous mode to + * perform an operation. + * Synchronous operation menas that the packet operation has to be completed + * before the function called to initiate the operation returns. + */ +#define SATA_OPMODE_INTERRUPTS 0 /* Use interrupts (hint) */ +#define SATA_OPMODE_POLLING 1 /* Use polling instead of interrupts */ +#define SATA_OPMODE_ASYNCH 0 /* Return immediately after accepting pkt */ +#define SATA_OPMODE_SYNCH 4 /* Perform synchronous operation */ + +/* + * satapkt_reason values: + * + * SATA_PKT_QUEUE_FULL - cmd not sent because of queue full (detected + * by the controller). If a device reject command for this reason, it + * should be reported as SATA_PKT_DEV_ERROR + * + * SATA_PKT_CMD_NOT_SUPPORTED - command not supported by a controller + * Controller is unable to send such command to a device. + * If device rejects a command, it should be reported as + * SATA_PKT_DEV_ERROR. + * + * SATA_PKT_DEV_ERROR - cmd failed because of device reported an error. + * The content of status_reg (ERROR bit has to be set) and error_reg + * fields of the sata_cmd structure have to be set and will be used + * by SATA HBA Framework to determine the error cause. + * + * SATA_PKT_PORT_ERROR - cmd failed because of a link or a port error. + * Link failed / no communication with a device / communication error + * or other port related error was detected by a controller. + * sata_pkt.satapkt_device.satadev_scr.sXXXXXXX words have to be set. + * + * SATA_PKT_ABORTED - cmd execution was aborted by the request from the + * framework. Abort mechanism is HBA driver specific. + * + * SATA_PKT_TIMEOUT - cmd execution has timed-out. Timeout specified by + * pkt_time was exceeded. The command was terminated by the SATA HBA + * driver. + * + * SATA_PKT_COMPLETED - this is a value returned when an operation + * completes without errors. + * + * SATA_PKT_BUSY - packet was not accepted for execution because the + * driver was busy performing some other operation(s). + * + * SATA_PKT_RESET - packet execution was aborted because of device + * reset originated by either the HBA driver or the SATA framework. + * + */ + +#define SATA_PKT_BUSY -1 /* Not completed, busy */ +#define SATA_PKT_COMPLETED 0 /* No error */ +#define SATA_PKT_DEV_ERROR 1 /* Device reported error */ +#define SATA_PKT_QUEUE_FULL 2 /* Not accepted, queue full */ +#define SATA_PKT_PORT_ERROR 3 /* Not completed, port error */ +#define SATA_PKT_CMD_UNSUPPORTED 4 /* Cmd unsupported */ +#define SATA_PKT_ABORTED 5 /* Aborted by request */ +#define SATA_PKT_TIMEOUT 6 /* Operation timeut */ +#define SATA_PKT_RESET 7 /* Aborted by reset request */ + +/* + * Error retrieval sata packet types + */ +#define SATA_ERR_RETR_PKT_TYPE_NCQ 1 +#define SATA_ERR_RETR_PKT_TYPE_ATAPI 2 + +/* + * Read/write port multiplier packet types + */ +#define SATA_RDWR_PMULT_PKT_TYPE_READ 1 +#define SATA_RDWR_PMULT_PKT_TYPE_WRITE 2 + +/* + * Hoplug functions vector structure (rev 1) + */ +#define SATA_TRAN_HOTPLUG_OPS_REV_1 1 + +struct sata_tran_hotplug_ops { + int sata_tran_hotplug_ops_rev; /* version */ + int (*sata_tran_port_activate)(dev_info_t *, sata_device_t *); + int (*sata_tran_port_deactivate)(dev_info_t *, sata_device_t *); +}; + +typedef struct sata_tran_hotplug_ops sata_tran_hotplug_ops_t; + + +/* + * Power management functions vector structure (rev 1) + * The embedded function returns information about the controller's + * power level. + * Additional functions may be added in the future without changes to + * sata_tran structure. + */ +#define SATA_TRAN_PWRMGT_OPS_REV_1 1 + +struct sata_tran_pwrmgt_ops { + int sata_tran_pwrmgt_ops_rev; /* version */ + int (*sata_tran_get_pwr_level)(dev_info_t *, sata_device_t *); +}; + +typedef struct sata_tran_pwrmgt_ops sata_tran_pwrmgt_ops_t; + + +/* + * SATA port PHY Power Level + * These states correspond to the interface power management state as defined + * in Serial ATA spec. + */ +#define SATA_TRAN_PORTPWR_LEVEL1 1 /* Interface in active PM state */ +#define SATA_TRAN_PORTPWR_LEVEL2 2 /* Interface in PARTIAL PM state */ +#define SATA_TRAN_PORTPWR_LEVEL3 3 /* Interface in SLUMBER PM state */ + +/* + * SATA HBA Tran structure (rev 1) + * Registered with SATA Framework + * + * dma_attr is a pointer to data (buffer) dma attibutes of the controller + * DMA engine. + * + * The qdepth field specifies number of commands that may be accepted by + * the controller. Value range 1-32. A value greater than 1 indicates that + * the controller supports queuing. Support for Native Command Queuing + * indicated by SATA_CTLF_NCQ flag also requires qdepth set to a value + * greater then 1. + * + */ +#define SATA_TRAN_HBA_REV_1 1 +#define SATA_TRAN_HBA_REV_2 2 +#define SATA_TRAN_HBA_REV_3 3 +#define SATA_TRAN_HBA_REV SATA_TRAN_HBA_REV_3 + +struct sata_hba_tran { + int sata_tran_hba_rev; /* version */ + dev_info_t *sata_tran_hba_dip; /* Controler dev info */ + ddi_dma_attr_t *sata_tran_hba_dma_attr; /* DMA attributes */ + int sata_tran_hba_num_cports; /* Num of HBA device ports */ + uint16_t sata_tran_hba_features_support; /* HBA features */ + uint16_t sata_tran_hba_qdepth; /* HBA-supported queue depth */ + + int (*sata_tran_probe_port)(dev_info_t *, sata_device_t *); + int (*sata_tran_start)(dev_info_t *, sata_pkt_t *); + int (*sata_tran_abort)(dev_info_t *, sata_pkt_t *, int); + int (*sata_tran_reset_dport)(dev_info_t *, + sata_device_t *); + int (*sata_tran_selftest)(dev_info_t *, sata_device_t *); + + /* Hotplug vector */ + struct sata_tran_hotplug_ops *sata_tran_hotplug_ops; + + /* Power mgt vector */ + struct sata_tran_pwrmgt_ops *sata_tran_pwrmgt_ops; + + int (*sata_tran_ioctl)(dev_info_t *, int, intptr_t); +}; + +typedef struct sata_hba_tran sata_hba_tran_t; + + +/* + * Controller's features support flags (sata_tran_hba_features_support). + * Note: SATA_CTLF_NCQ indicates that SATA controller supports NCQ in addition + * to legacy queuing commands, indicated by SATA_CTLF_QCMD flag. + */ + +#define SATA_CTLF_ATAPI 0x001 /* ATAPI support */ +#define SATA_CTLF_PORT_MULTIPLIER 0x010 /* Port Multiplier suport */ +#define SATA_CTLF_HOTPLUG 0x020 /* Hotplug support */ +#define SATA_CTLF_ASN 0x040 /* Asynchronous Event Support */ +#define SATA_CTLF_QCMD 0x080 /* Queued commands support */ +#define SATA_CTLF_NCQ 0x100 /* NCQ support */ +#define SATA_CTLF_PMULT_FBS 0x200 /* FIS-based switching support */ + +/* + * sata_tran_start() return values. + * When pkt is not accepted, the satapkt_reason has to be updated + * before function returns - it should reflect the same reason for not being + * executed as the return status of above functions. + * If pkt was accepted and executed synchronously, + * satapk_reason should indicate a completion status. + */ +#define SATA_TRAN_ACCEPTED 0 /* accepted */ +#define SATA_TRAN_QUEUE_FULL 1 /* not accepted, queue full */ +#define SATA_TRAN_PORT_ERROR 2 /* not accepted, port error */ +#define SATA_TRAN_CMD_UNSUPPORTED 3 /* not accepted, cmd not supported */ +#define SATA_TRAN_BUSY 4 /* not accepted, busy */ + + +/* + * sata_tran_abort() abort type flag + */ +#define SATA_ABORT_PACKET 0 +#define SATA_ABORT_ALL_PACKETS 1 + + +/* + * Events handled by SATA HBA Framework + * More then one event may be reported at the same time + * + * SATA_EVNT__DEVICE_ATTACHED + * HBA detected the presence of a device ( electrical connection with + * a device was detected ). + * + * SATA_EVNT_DEVICE_DETACHED + * HBA detected the detachment of a device (electrical connection with + * a device was broken) + * + * SATA_EVNT_LINK_LOST + * HBA lost link with an attached device + * + * SATA_EVNT_LINK_ESTABLISHED + * HBA established a link with an attached device + * + * SATA_EVNT_PORT_FAILED + * HBA has determined that the port failed and is unuseable + * + * SATA_EVENT_DEVICE_RESET + * SATA device was reset, causing loss of the device setting + * + * SATA_EVNT_PWR_LEVEL_CHANGED + * A port or entire SATA controller power level has changed + * + * SATA_EVNT_PMULT_LINK_CHANGED + * Port multiplier detect change on a link of its device port + * + */ +#define SATA_EVNT_DEVICE_ATTACHED 0x01 +#define SATA_EVNT_DEVICE_DETACHED 0x02 +#define SATA_EVNT_LINK_LOST 0x04 +#define SATA_EVNT_LINK_ESTABLISHED 0x08 +#define SATA_EVNT_PORT_FAILED 0x10 +#define SATA_EVNT_DEVICE_RESET 0x20 +#define SATA_EVNT_PWR_LEVEL_CHANGED 0x40 +#define SATA_EVNT_PMULT_LINK_CHANGED 0x80 + +/* + * SATA Framework interface entry points + */ +int sata_hba_init(struct modlinkage *); +int sata_hba_attach(dev_info_t *, sata_hba_tran_t *, ddi_attach_cmd_t); +int sata_hba_detach(dev_info_t *, ddi_detach_cmd_t); +void sata_hba_fini(struct modlinkage *); +void sata_hba_event_notify(dev_info_t *, sata_device_t *, int); +sata_pkt_t *sata_get_error_retrieval_pkt(dev_info_t *, sata_device_t *, int); +void sata_free_error_retrieval_pkt(sata_pkt_t *); +sata_pkt_t *sata_get_rdwr_pmult_pkt(dev_info_t *, sata_device_t *, uint16_t, + uint32_t, uint32_t); +void sata_free_rdwr_pmult_pkt(sata_pkt_t *); +void sata_register_pmult(dev_info_t *, sata_device_t *, sata_pmult_gscr_t *); +void sata_free_dma_resources(sata_pkt_t *); +void sata_split_model(char *, char **, char **); + +/* + * SATA trace ring buffer constants + */ +#define DMSG_RING_SIZE 0x100000 /* 1MB */ +#define DMSG_BUF_SIZE 256 + +/* + * SATA trace ring buffer content + */ +typedef struct sata_trace_dmsg { + dev_info_t *dip; + timespec_t timestamp; + char buf[DMSG_BUF_SIZE]; + struct sata_trace_dmsg *next; +} sata_trace_dmsg_t; + +/* + * SATA trace ring buffer header + */ +typedef struct sata_trace_rbuf { + kmutex_t lock; /* lock to avoid clutter */ + int looped; /* completed ring */ + int allocfailed; /* dmsg mem alloc failed */ + size_t size; /* current size */ + size_t maxsize; /* max size */ + sata_trace_dmsg_t *dmsgh; /* messages head */ + sata_trace_dmsg_t *dmsgp; /* ptr to last message */ +} sata_trace_rbuf_t; + +/* + * SATA trace ring buffer interfaces + */ +void sata_trace_debug(dev_info_t *, const char *fmt, ...); +void sata_vtrace_debug(dev_info_t *, const char *fmt, va_list); + +#ifdef __cplusplus +} +#endif + +#endif /* _SATA_HBA_H */ diff --git a/illumos-x86_64/usr/include/sys/schedctl.h b/illumos-x86_64/usr/include/sys/schedctl.h new file mode 100644 index 00000000..121b792c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/schedctl.h @@ -0,0 +1,113 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * The enclosed is a private interface between system libraries and + * the kernel. It should not be used in any other way. It may be + * changed without notice in a minor release of Solaris. + */ + +#ifndef _SYS_SCHEDCTL_H +#define _SYS_SCHEDCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_ASM) + +#include +#include + +/* + * This "public" portion of the sc_shared data is used by libsched/libc. + */ +typedef struct sc_public { + volatile short sc_nopreempt; + volatile short sc_yield; +} sc_public_t; + +/* + * The private portion of the sc_shared data is for + * use by user-level threading support code in libc. + * Java has a contract to look at sc_state and sc_cpu (PSARC/2005/351). + */ +typedef struct sc_shared { + volatile ushort_t sc_state; /* current LWP state */ + volatile char sc_sigblock; /* all signals blocked */ + volatile uchar_t sc_flgs; /* set only by curthread; see below */ + volatile processorid_t sc_cpu; /* last CPU on which LWP ran */ + volatile char sc_cid; /* scheduling class id */ + volatile char sc_cpri; /* class priority, -128..127 */ + volatile uchar_t sc_priority; /* dispatch priority, 0..255 */ + char sc_pad; + sc_public_t sc_preemptctl; /* preemption control data */ +} sc_shared_t; + +/* sc_flgs */ +#define SC_PARK_FLG 0x01 /* calling lwp_park() */ +#define SC_CANCEL_FLG 0x02 /* cancel pending and not disabled */ +#define SC_EINTR_FLG 0x04 /* EINTR returned due to SC_CANCEL_FLG */ + +/* + * Possible state settings. These are same as the kernel thread states + * except there is no zombie state. + */ +#define SC_FREE 0x00 +#define SC_SLEEP 0x01 +#define SC_RUN 0x02 +#define SC_ONPROC 0x04 +#define SC_STOPPED 0x10 +#define SC_WAIT 0x20 + +/* preemption control settings */ +#define SC_MAX_TICKS 2 /* max time preemption can be blocked */ + +#ifdef _KERNEL +caddr_t schedctl(void); +void schedctl_init(void); +void schedctl_lwp_cleanup(kthread_t *); +void schedctl_proc_cleanup(void); +int schedctl_get_nopreempt(kthread_t *); +void schedctl_set_nopreempt(kthread_t *, short); +void schedctl_set_yield(kthread_t *, short); +void schedctl_set_cidpri(kthread_t *); +int schedctl_sigblock(kthread_t *); +void schedctl_finish_sigblock(kthread_t *); +int schedctl_cancel_pending(void); +void schedctl_cancel_eintr(void); +int schedctl_is_park(void); +void schedctl_set_park(void); +void schedctl_unpark(void); +#endif /* _KERNEL */ + +#endif /* !defined(_ASM) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCHEDCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/adapters/scsi_vhci.h b/illumos-x86_64/usr/include/sys/scsi/adapters/scsi_vhci.h new file mode 100644 index 00000000..8ce73913 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/adapters/scsi_vhci.h @@ -0,0 +1,873 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2024 RackTop Systems, Inc. + */ + +#ifndef _SYS_SCSI_ADAPTERS_SCSI_VHCI_H +#define _SYS_SCSI_ADAPTERS_SCSI_VHCI_H + +/* + * Multiplexed I/O SCSI vHCI global include + */ +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL) +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + +#ifdef _KERNEL + +#ifdef UNDEFINED +#undef UNDEFINED +#endif +#define UNDEFINED -1 + +#define VHCI_STATE_OPEN 0x00000001 + + +#define VH_SLEEP 0x0 +#define VH_NOSLEEP 0x1 + +/* + * HBA interface macros + */ + +#define TRAN2HBAPRIVATE(tran) ((struct scsi_vhci *)(tran)->tran_hba_private) +#define VHCI_INIT_WAIT_TIMEOUT 60000000 +#define VHCI_FOWATCH_INTERVAL 1000000 /* in usecs */ +#define VHCI_EXTFO_TIMEOUT (3 * 60 * NANOSEC) /* 3 minutes in nsec */ + +#define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & STATUS_MASK) + +int vhci_do_scsi_cmd(struct scsi_pkt *); +/*PRINTFLIKE3*/ +void vhci_log(int, dev_info_t *, const char *, ...); + +size_t vhci_get_blocksize(dev_info_t *); + +/* + * debugging stuff + */ + +#ifdef DEBUG + +#ifndef VHCI_DEBUG_DEFAULT_VAL +#define VHCI_DEBUG_DEFAULT_VAL 0 +#endif /* VHCI_DEBUG_DEFAULT_VAL */ + +extern int vhci_debug; + +#include + +#define VHCI_DEBUG(level, stmnt) \ + if (vhci_debug >= (level)) vhci_log stmnt + +#else /* !DEBUG */ + +#define VHCI_DEBUG(level, stmnt) + +#endif /* !DEBUG */ + + + +#define VHCI_PKT_PRIV_SIZE 2 + +#define ADDR2VHCI(ap) ((struct scsi_vhci *) \ + ((ap)->a_hba_tran->tran_hba_private)) +#define ADDR2VLUN(ap) (scsi_vhci_lun_t *) \ + (scsi_device_hba_private_get(scsi_address_device(ap))) +#define ADDR2DIP(ap) ((dev_info_t *)(scsi_address_device(ap)->sd_dev)) + +#define HBAPKT2VHCIPKT(pkt) (pkt->pkt_private) +#define TGTPKT2VHCIPKT(pkt) (pkt->pkt_ha_private) +#define VHCIPKT2HBAPKT(pkt) (pkt->pkt_hba_pkt) +#define VHCIPKT2TGTPKT(pkt) (pkt->pkt_tgt_pkt) + +#define VHCI_DECR_PATH_CMDCOUNT(svp) { \ + mutex_enter(&(svp)->svp_mutex); \ + (svp)->svp_cmds--; \ + if ((svp)->svp_cmds == 0) \ + cv_broadcast(&(svp)->svp_cv); \ + mutex_exit(&(svp)->svp_mutex); \ +} + +#define VHCI_INCR_PATH_CMDCOUNT(svp) { \ + mutex_enter(&(svp)->svp_mutex); \ + (svp)->svp_cmds++; \ + mutex_exit(&(svp)->svp_mutex); \ +} + +/* + * When a LUN is HELD it results in new IOs being returned to the target + * driver layer with TRAN_BUSY. Should be used while performing + * operations that require prevention of any new IOs to the LUN and + * the LUN should be HELD for the duration of such operations. + * f can be VH_SLEEP or VH_NOSLEEP. + * h is set to 1 to indicate LUN was successfully HELD. + * h is set to 0 when f is VH_NOSLEEP and LUN is already HELD. + * + * Application examples: + * + * 1) SCSI-II RESERVE: HOLD LUN until it is quiesced and the load balancing + * policy is switched to NONE before proceeding with RESERVE handling. + * + * 2) Failover: HOLD LUN before initiating failover. + * + * 3) When an externally initiated failover is detected, HOLD LUN until all + * path states have been refreshed to reflect the new value. + * + */ +#define VHCI_HOLD_LUN(vlun, f, h) { \ + int sleep = (f); \ + mutex_enter(&(vlun)->svl_mutex); \ + if ((vlun)->svl_transient == 1) { \ + if (sleep == VH_SLEEP) { \ + while ((vlun)->svl_transient == 1) \ + cv_wait(&(vlun)->svl_cv, &(vlun)->svl_mutex); \ + (vlun)->svl_transient = 1; \ + (h) = 1; \ + } else { \ + (h) = 0; \ + } \ + } else { \ + (vlun)->svl_transient = 1; \ + (h) = 1; \ + } \ + sleep = (h); \ + mutex_exit(&(vlun)->svl_mutex); \ +} + +#define VHCI_RELEASE_LUN(vlun) { \ + mutex_enter(&(vlun)->svl_mutex); \ + (vlun)->svl_transient = 0; \ + cv_broadcast(&(vlun)->svl_cv); \ + mutex_exit(&(vlun)->svl_mutex); \ +} + +#define VHCI_LUN_IS_HELD(vlun) ((vlun)->svl_transient == 1) + +/* + * vhci_pkt states + */ +#define VHCI_PKT_IDLE 0x01 +#define VHCI_PKT_ISSUED 0x02 +#define VHCI_PKT_ABORTING 0x04 +#define VHCI_PKT_STALE_BINDING 0x08 +/* + * Set the first time taskq is dispatched from scsi_start for + * a packet. To ensure vhci_scsi_start recognizes that the scsi_pkt + * is being issued from the taskq and not target driver. + */ +#define VHCI_PKT_THRU_TASKQ 0x20 +/* + * Set the first time failover is being triggered. To ensure + * failover won't be triggered again when the packet is being + * retried by target driver. + */ +#define VHCI_PKT_IN_FAILOVER 0x40 + +#define VHCI_PKT_TIMEOUT 30 /* seconds */ +#define VHCI_PKT_RETRY_CNT 2 +#define VHCI_POLL_TIMEOUT 60 /* seconds */ + +/* + * define extended scsi cmd pkt + */ +#define EXTCMDS_STATUS_SIZE (sizeof (struct scsi_arq_status)) + +#define CFLAG_NOWAIT 0x1000 /* don't sleep */ +#define CFLAG_DMA_PARTIAL 0x2000 /* Support Partial DMA */ + +/* + * Maximum size of SCSI cdb in SCSI command + */ +#define VHCI_SCSI_CDB_SIZE 16 +#define VHCI_SCSI_SCB_SIZE (sizeof (struct scsi_arq_status)) + +/* + * OSD specific definitions + */ +#define VHCI_SCSI_OSD_CDB_SIZE 224 +#define VHCI_SCSI_OSD_PKT_FLAGS 0x100000 + +/* + * flag to determine failover support + */ +#define SCSI_NO_FAILOVER 0x0 +#define SCSI_IMPLICIT_FAILOVER 0x1 +#define SCSI_EXPLICIT_FAILOVER 0x2 +#define SCSI_BOTH_FAILOVER \ + (SCSI_IMPLICIT_FAILOVER | SCSI_EXPLICIT_FAILOVER) + +struct scsi_vhci_swarg; + +#define VHCI_NUM_RESV_KEYS 8 + +typedef struct vhci_prin_readkeys { + uint32_t generation; + uint32_t length; + mhioc_resv_key_t keylist[VHCI_NUM_RESV_KEYS]; +} vhci_prin_readkeys_t; + +#define VHCI_PROUT_SIZE \ + ((sizeof (vhci_prout_t) - 2 * (MHIOC_RESV_KEY_SIZE) * sizeof (char))) + +typedef struct vhci_prout { + /* PGR register parameters start */ + uchar_t res_key[MHIOC_RESV_KEY_SIZE]; + uchar_t service_key[MHIOC_RESV_KEY_SIZE]; + uint32_t scope_address; + +#if defined(_BIT_FIELDS_LTOH) + uchar_t aptpl:1, + reserved:7; +#else + uchar_t reserved:7, + aptpl:1; +#endif /* _BIT_FIELDS_LTOH */ + + uchar_t reserved_1; + uint16_t ext_len; + /* PGR register parameters end */ + + /* Update VHCI_PROUT_SIZE if new fields are added here */ + + uchar_t active_res_key[MHIOC_RESV_KEY_SIZE]; + uchar_t active_service_key[MHIOC_RESV_KEY_SIZE]; +} vhci_prout_t; + +#define VHCI_PROUT_REGISTER 0x0 +#define VHCI_PROUT_RESERVE 0x1 +#define VHCI_PROUT_RELEASE 0x2 +#define VHCI_PROUT_CLEAR 0x3 +#define VHCI_PROUT_PREEMPT 0x4 +#define VHCI_PROUT_P_AND_A 0x5 +#define VHCI_PROUT_R_AND_IGNORE 0x6 + +struct vhci_pkt { + struct scsi_pkt *vpkt_tgt_pkt; + mdi_pathinfo_t *vpkt_path; /* path pkt bound to */ + + /* + * pHCI packet that does the actual work. + */ + struct scsi_pkt *vpkt_hba_pkt; + + uint_t vpkt_state; + uint_t vpkt_flags; + + /* + * copy of vhci_scsi_init_pkt args. Used when we invoke + * scsi_init_pkt() of the pHCI corresponding to the path that we + * bind to + */ + int vpkt_tgt_init_cdblen; + int vpkt_tgt_init_scblen; + int vpkt_tgt_init_pkt_flags; + struct buf *vpkt_tgt_init_bp; + + /* + * Pointer to original struct vhci_pkt for cmd send by ssd. + * Saved when the command is being retried internally. + */ + struct vhci_pkt *vpkt_org_vpkt; +}; + +typedef struct scsi_vhci_lun { + kmutex_t svl_mutex; + kcondvar_t svl_cv; + + /* + * following three fields are under svl_mutex protection + */ + int svl_transient; + + /* + * to prevent unnecessary failover when a device is + * is discovered across a passive path and active path + * is still comng up + */ + int svl_waiting_for_activepath; + hrtime_t svl_wfa_time; + + /* + * to keep the failover status in order to return the + * failure status to target driver when targer driver + * retries the command which originally triggered the + * failover. + */ + int svl_failover_status; + + /* + * for RESERVE/RELEASE support + */ + client_lb_t svl_lb_policy_save; + + /* + * Failover ops and ops name selected for the lun. + */ + struct scsi_failover_ops *svl_fops; + char *svl_fops_name; + + void *svl_fops_ctpriv; + + struct scsi_vhci_lun *svl_hash_next; + char *svl_lun_wwn; + + /* + * currently active pathclass + */ + char *svl_active_pclass; + + dev_info_t *svl_dip; + uint32_t svl_flags; /* protected by svl_mutex */ + + /* + * When SCSI-II reservations are active we set the following pip + * to point to the path holding the reservation. As long as + * the reservation is active this svl_resrv_pip is bound for the + * transport directly. We bypass calling mdi_select_path to return + * a pip. + * The following pip is only valid when VLUN_RESERVE_ACTIVE_FLG + * is set. This pip should not be accessed if this flag is reset. + */ + mdi_pathinfo_t *svl_resrv_pip; + + /* + * following fields are for PGR support + */ + taskq_t *svl_taskq; + ksema_t svl_pgr_sema; /* PGR serialization */ + vhci_prin_readkeys_t svl_prin; /* PGR in data */ + vhci_prout_t svl_prout; /* PGR out data */ + uchar_t svl_cdb[CDB_GROUP4]; + int svl_time; /* pkt_time */ + uint32_t svl_bcount; /* amount of data */ + int svl_pgr_active; /* registrations active */ + mdi_pathinfo_t *svl_first_path; + + /* external failover */ + int svl_efo_update_path; + struct scsi_vhci_swarg *svl_swarg; + + uint32_t svl_support_lun_reset; /* Lun reset support */ + int svl_not_supported; + int svl_xlf_capable; /* XLF implementation */ + int svl_sector_size; + int svl_setcap_done; + uint16_t svl_fo_support; /* failover mode */ +} scsi_vhci_lun_t; + +#define VLUN_TASK_D_ALIVE_FLG 0x01 + +/* + * This flag is used to monitor the state of SCSI-II RESERVATION on the + * lun. A SCSI-II RESERVE cmd may be accepted by the target on the inactive + * path. This would then cause a subsequent IO to cause the paths to be + * updated and be returned with a reservation conflict. By monitoring this + * flag, and sending a reset to the target when needed to clear the reservation, + * one can avoid this conflict. + */ +#define VLUN_RESERVE_ACTIVE_FLG 0x04 + +/* + * This flag is set when a SCSI-II RESERVE cmd is received by scsi_vhci + * and cleared when the pkt completes in vhci_intr. It ensures that the + * lun remains quiesced for the duration of this pkt. This is different + * from VHCI_HOLD_LUN as this pertains to IOs only. + */ +#define VLUN_QUIESCED_FLG 0x08 + +/* + * This flag is set to tell vhci_update_pathstates to call back + * into vhci_mpapi_update_tpg_acc_state. + */ +#define VLUN_UPDATE_TPG 0x10 + +/* + * Various reset recovery depth. + */ + +#define VHCI_DEPTH_ALL 3 +#define VHCI_DEPTH_TARGET 2 +#define VHCI_DEPTH_LUN 1 /* For the sake completeness */ +#define TRUE (1) +#define FALSE (0) + +/* + * this is stashed away in the client private area of + * pathinfo + */ +typedef struct scsi_vhci_priv { + kmutex_t svp_mutex; + kcondvar_t svp_cv; + struct scsi_vhci_lun *svp_svl; + + /* + * scsi device associated with this + * pathinfo + */ + struct scsi_device *svp_psd; + + /* + * number of outstanding commands on this + * path. Protected by svp_mutex + */ + int svp_cmds; + + /* + * following is used to prevent packets completing with the + * same error reason from flooding the screen + */ + uchar_t svp_last_pkt_reason; + + /* external failover scsi_watch token */ + opaque_t svp_sw_token; + + /* any cleanup operations for a newly found path. */ + int svp_new_path; +} scsi_vhci_priv_t; + +/* + * argument to scsi_watch callback. Used for processing + * externally initiated failovers + */ +typedef struct scsi_vhci_swarg { + scsi_vhci_priv_t *svs_svp; + hrtime_t svs_tos; /* time of submission */ + mdi_pathinfo_t *svs_pi; /* pathinfo being "watched" */ + int svs_release_lun; + int svs_done; +} scsi_vhci_swarg_t; + +/* + * scsi_vhci softstate + * + * vhci_mutex protects + * vhci_state + * and vhci_reset_notify list + */ +struct scsi_vhci { + kmutex_t vhci_mutex; + dev_info_t *vhci_dip; + struct scsi_hba_tran *vhci_tran; + uint32_t vhci_state; + uint32_t vhci_instance; + kstat_t vhci_kstat; + /* + * This taskq is for general vhci operations like reservations, + * auto-failback, etc. + */ + taskq_t *vhci_taskq; + /* Dedicate taskq to handle external failovers */ + taskq_t *vhci_update_pathstates_taskq; + struct scsi_reset_notify_entry *vhci_reset_notify_listf; + uint16_t vhci_conf_flags; + mpapi_priv_t *mp_priv; +}; + +/* + * vHCI flags for configuration settings, defined in scsi_vhci.conf + */ +#define VHCI_CONF_FLAGS_AUTO_FAILBACK 0x0001 /* Enables auto failback */ + +typedef enum { + SCSI_PATH_INACTIVE, + SCSI_PATH_ACTIVE, + SCSI_PATH_ACTIVE_NONOPT +} scsi_path_state_t; + +#define SCSI_MAXPCLASSLEN 25 + +#define OPINFO_REV 1 + +/* + * structure describing operational characteristics of + * path + */ +struct scsi_path_opinfo { + int opinfo_rev; + + /* + * name of pathclass. Eg. "primary", "secondary" + */ + char opinfo_path_attr[SCSI_MAXPCLASSLEN]; + + /* + * path state: ACTIVE/PASSIVE + */ + scsi_path_state_t opinfo_path_state; + + /* + * the best and worst case time estimates for + * failover operation to complete + */ + uint_t opinfo_pswtch_best; + uint_t opinfo_pswtch_worst; + + /* XLF implementation */ + int opinfo_xlf_capable; + uint16_t opinfo_preferred; + uint16_t opinfo_mode; + +}; + + +#define SFO_REV 1 + +/* + * vectors for device specific failover related operations + */ +struct scsi_failover_ops { + int sfo_rev; + + /* + * failover module name, begins with "f_" + */ + char *sfo_name; + + /* + * devices supported by failover module + * + * NOTE: this is an aproximation, sfo_device_probe has the final say. + */ + char **sfo_devices; + + /* + * initialize the failover module + */ + void (*sfo_init)(); + + /* + * identify device + */ + int (*sfo_device_probe)( + struct scsi_device *sd, + struct scsi_inquiry *stdinq, + void **ctpriv); + + /* + * housekeeping (free memory etc alloc'ed during probe + */ + void (*sfo_device_unprobe)( + struct scsi_device *sd, + void *ctpriv); + + /* + * bring a path ONLINE (ie make it ACTIVE) + */ + int (*sfo_path_activate)( + struct scsi_device *sd, + char *pathclass, + void *ctpriv); + + /* + * inverse of above + */ + int (*sfo_path_deactivate)( + struct scsi_device *sd, + char *pathclass, + void *ctpriv); + + /* + * returns operational characteristics of path + */ + int (*sfo_path_get_opinfo)( + struct scsi_device *sd, + struct scsi_path_opinfo *opinfo, + void *ctpriv); + + /* + * verify path is operational + */ + int (*sfo_path_ping)( + struct scsi_device *sd, + void *ctpriv); + + /* + * analyze SENSE data to detect externally initiated + * failovers + */ + int (*sfo_analyze_sense)( + struct scsi_device *sd, + uint8_t *sense, + void *ctpriv); + + /* + * return the next pathclass in order of preference + * eg. "secondary" comes after "primary" + */ + int (*sfo_pathclass_next)( + char *cur, + char **nxt, + void *ctpriv); +}; + +/* + * Names of (too) 'well-known' failover ops. + * NOTE: consumers of these names should look for a better way... + */ +#define SFO_NAME_SYM "f_sym" +#define SFO_NAME_TPGS "f_tpgs" +#define SCSI_FAILOVER_IS_ASYM(svl) \ + ((svl) ? ((svl)->svl_fo_support != SCSI_NO_FAILOVER) : 0) +#define SCSI_FAILOVER_IS_TPGS(sfo) \ + ((sfo) ? (strcmp((sfo)->sfo_name, SFO_NAME_TPGS) == 0) : 0) + +/* + * Macro to provide plumbing for basic failover module + */ +#define _SCSI_FAILOVER_OP(sfo_name, local_name, ops_name) \ + static struct modlmisc modlmisc = { \ + &mod_miscops, sfo_name \ + }; \ + static struct modlinkage modlinkage = { \ + MODREV_1, (void *)&modlmisc, NULL \ + }; \ + int _init() \ + { \ + return (mod_install(&modlinkage)); \ + } \ + int _fini() \ + { \ + return (mod_remove(&modlinkage)); \ + } \ + int _info(struct modinfo *modinfop) \ + { \ + return (mod_info(&modlinkage, modinfop)); \ + } \ + static int local_name##_device_probe( \ + struct scsi_device *, \ + struct scsi_inquiry *, void **); \ + static void local_name##_device_unprobe( \ + struct scsi_device *, void *); \ + static int local_name##_path_activate( \ + struct scsi_device *, char *, void *); \ + static int local_name##_path_deactivate( \ + struct scsi_device *, char *, void *); \ + static int local_name##_path_get_opinfo( \ + struct scsi_device *, \ + struct scsi_path_opinfo *, void *); \ + static int local_name##_path_ping( \ + struct scsi_device *, void *); \ + static int local_name##_analyze_sense( \ + struct scsi_device *, \ + uint8_t *, void *); \ + static int local_name##_pathclass_next( \ + char *, char **, void *); \ + struct scsi_failover_ops ops_name##_failover_ops = { \ + SFO_REV, \ + sfo_name, \ + local_name##_dev_table, \ + NULL, \ + local_name##_device_probe, \ + local_name##_device_unprobe, \ + local_name##_path_activate, \ + local_name##_path_deactivate, \ + local_name##_path_get_opinfo, \ + local_name##_path_ping, \ + local_name##_analyze_sense, \ + local_name##_pathclass_next \ + } + +#ifdef lint +#define SCSI_FAILOVER_OP(sfo_name, local_name) \ + _SCSI_FAILOVER_OP(sfo_name, local_name, local_name) +#else /* lint */ +#define SCSI_FAILOVER_OP(sfo_name, local_name) \ + _SCSI_FAILOVER_OP(sfo_name, local_name, scsi_vhci) +#endif /* lint */ + +/* + * Return values for sfo_device_probe + */ +#define SFO_DEVICE_PROBE_VHCI 1 /* supported under scsi_vhci */ +#define SFO_DEVICE_PROBE_PHCI 0 /* not supported under scsi_vhci */ + +/* return values for sfo_analyze_sense() */ +#define SCSI_SENSE_NOFAILOVER 0 +#define SCSI_SENSE_FAILOVER_INPROG 1 +#define SCSI_SENSE_ACT2INACT 2 +#define SCSI_SENSE_INACT2ACT 3 +#define SCSI_SENSE_INACTIVE 4 +#define SCSI_SENSE_UNKNOWN 5 +#define SCSI_SENSE_STATE_CHANGED 6 +#define SCSI_SENSE_NOT_READY 7 + +/* vhci_intr action codes */ +#define JUST_RETURN 0 +#define BUSY_RETURN 1 +#define PKT_RETURN 2 + +#if defined(_SYSCALL32) +/* + * 32 bit variants of sv_path_info_prop_t and sv_path_info_t; + * To be used only in the driver and NOT applications + */ +typedef struct sv_path_info_prop32 { + uint32_t buf_size; /* user buffer size */ + caddr32_t ret_buf_size; /* actual buffer needed */ + caddr32_t buf; /* user space buffer */ +} sv_path_info_prop32_t; + +typedef struct sv_path_info32 { + union { + char ret_ct[MAXPATHLEN]; /* client device */ + char ret_phci[MAXPATHLEN]; /* pHCI device */ + } device; + + char ret_addr[MAXNAMELEN]; /* device address */ + mdi_pathinfo_state_t ret_state; /* state information */ + uint32_t ret_ext_state; /* Extended State */ + sv_path_info_prop32_t ret_prop; /* path attributes */ +} sv_path_info32_t; + +typedef struct sv_iocdata32 { + caddr32_t client; /* client dev devfs path name */ + caddr32_t phci; /* pHCI dev devfs path name */ + caddr32_t addr; /* device address */ + uint32_t buf_elem; /* number of path_info elems */ + caddr32_t ret_buf; /* addr of array of sv_path_info */ + caddr32_t ret_elem; /* count of above sv_path_info */ +} sv_iocdata32_t; + +typedef struct sv_switch_to_cntlr_iocdata32 { + caddr32_t client; /* client device devfs path name */ + caddr32_t class; /* desired path class to be made active */ +} sv_switch_to_cntlr_iocdata32_t; + +#endif /* _SYSCALL32 */ + +#endif /* _KERNEL */ + +/* + * Userland (Non Kernel) definitions start here. + * Multiplexed I/O SCSI vHCI IOCTL Definitions + */ + +/* + * IOCTL structure for path properties + */ +typedef struct sv_path_info_prop { + uint_t buf_size; /* user buffer size */ + uint_t *ret_buf_size; /* actual buffer needed */ + caddr_t buf; /* user space buffer */ +} sv_path_info_prop_t; + +/* + * Max buffer size of getting path properties + */ +#define SV_PROP_MAX_BUF_SIZE 4096 + +/* + * String values for "path-class" property + */ +#define PCLASS_PRIMARY "primary" +#define PCLASS_SECONDARY "secondary" + +#define PCLASS_PREFERRED 1 +#define PCLASS_NONPREFERRED 0 + +/* + * IOCTL structure for path information + */ +typedef struct sv_path_info { + union { + char ret_ct[MAXPATHLEN]; /* client device */ + char ret_phci[MAXPATHLEN]; /* pHCI device */ + } device; + + char ret_addr[MAXNAMELEN]; /* device address */ + mdi_pathinfo_state_t ret_state; /* state information */ + uint32_t ret_ext_state; /* Extended State */ + sv_path_info_prop_t ret_prop; /* path attributes */ +} sv_path_info_t; + +/* + * IOCTL argument structure + */ +typedef struct sv_iocdata { + caddr_t client; /* client dev devfs path name */ + caddr_t phci; /* pHCI dev devfs path name */ + caddr_t addr; /* device address */ + uint_t buf_elem; /* number of path_info elems */ + sv_path_info_t *ret_buf; /* array of sv_path_info */ + uint_t *ret_elem; /* count of sv_path_info */ +} sv_iocdata_t; + +/* + * IOCTL argument structure for switching controllers + */ +typedef struct sv_switch_to_cntlr_iocdata { + caddr_t client; /* client device devfs path name */ + caddr_t class; /* desired path class to be made active */ +} sv_switch_to_cntlr_iocdata_t; + + +/* + * IOCTL definitions + */ +#define SCSI_VHCI_CTL ('X' << 8) +#define SCSI_VHCI_CTL_CMD (SCSI_VHCI_CTL | ('S' << 8) | 'P') +#define SCSI_VHCI_CTL_SUB_CMD ('x' << 8) + +#define SCSI_VHCI_GET_CLIENT_MULTIPATH_INFO (SCSI_VHCI_CTL_SUB_CMD + 0x01) +#define SCSI_VHCI_GET_PHCI_MULTIPATH_INFO (SCSI_VHCI_CTL_SUB_CMD + 0x02) +#define SCSI_VHCI_GET_CLIENT_NAME (SCSI_VHCI_CTL_SUB_CMD + 0x03) +#define SCSI_VHCI_PATH_ONLINE (SCSI_VHCI_CTL_SUB_CMD + 0x04) +#define SCSI_VHCI_PATH_OFFLINE (SCSI_VHCI_CTL_SUB_CMD + 0x05) +#define SCSI_VHCI_PATH_STANDBY (SCSI_VHCI_CTL_SUB_CMD + 0x06) +#define SCSI_VHCI_PATH_TEST (SCSI_VHCI_CTL_SUB_CMD + 0x07) +#define SCSI_VHCI_SWITCH_TO_CNTLR (SCSI_VHCI_CTL_SUB_CMD + 0x08) + +#ifdef DEBUG +#define SCSI_VHCI_GET_PHCI_LIST (SCSI_VHCI_CTL_SUB_CMD + 0x09) +#define SCSI_VHCI_CONFIGURE_PHCI (SCSI_VHCI_CTL_SUB_CMD + 0x0A) +#define SCSI_VHCI_UNCONFIGURE_PHCI (SCSI_VHCI_CTL_SUB_CMD + 0x0B) +#endif + +#define SCSI_VHCI_PATH_DISABLE (SCSI_VHCI_CTL_SUB_CMD + 0x0C) +#define SCSI_VHCI_PATH_ENABLE (SCSI_VHCI_CTL_SUB_CMD + 0x0D) +#define SCSI_VHCI_MPAPI (SCSI_VHCI_CTL_SUB_CMD + 0x0E) + +#define SCSI_VHCI_GET_TARGET_LONGNAME (SCSI_VHCI_CTL_SUB_CMD + 0x0F) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_ADAPTERS_SCSI_VHCI_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/conf/autoconf.h b/illumos-x86_64/usr/include/sys/scsi/conf/autoconf.h new file mode 100644 index 00000000..8d0903de --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/conf/autoconf.h @@ -0,0 +1,204 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_CONF_AUTOCONF_H +#define _SYS_SCSI_CONF_AUTOCONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SCSI subsystem scsi_options + */ + +/* + * Following are for debugging purposes (few Sun drivers support this) + */ +#define SCSI_DEBUG_TGT 0x1 /* debug statements in target drivers */ +#define SCSI_DEBUG_LIB 0x2 /* debug statements in library */ +#define SCSI_DEBUG_HA 0x4 /* debug statements in host adapters */ + +/* + * Following are applicable to all interconnects + */ +#define SCSI_OPTIONS_LINK 0x10 /* Global linked commands */ +#define SCSI_OPTIONS_TAG 0x80 /* Global tagged command support */ + +/* + * Following are for parallel SCSI only + */ +#define SCSI_OPTIONS_DR 0x8 /* Global disconnect/reconnect */ +#define SCSI_OPTIONS_SYNC 0x20 /* Global synchronous xfer capability */ +#define SCSI_OPTIONS_PARITY 0x40 /* Global parity support */ +#define SCSI_OPTIONS_FAST 0x100 /* Global FAST scsi support */ +#define SCSI_OPTIONS_WIDE 0x200 /* Global WIDE scsi support */ +#define SCSI_OPTIONS_FAST20 0x400 /* Global FAST20 scsi support */ +#define SCSI_OPTIONS_FAST40 0x800 /* Global FAST40 scsi support */ +#define SCSI_OPTIONS_FAST80 0x1000 /* Global FAST80 scsi support */ +#define SCSI_OPTIONS_FAST160 0x2000 /* Global FAST160 scsi support */ +#define SCSI_OPTIONS_FAST320 0x4000 /* Global FAST320 scsi support */ + +/* + * The following 3 bits are for being able to limit the max. number of LUNs + * a nexus driver will allow -- "default" means that the adapter will + * continue its default behavior. + */ +#define SCSI_OPTIONS_NLUNS_MASK (0x70000) + +#define SCSI_OPTIONS_NLUNS_DEFAULT 0x00000 +#define SCSI_OPTIONS_NLUNS_1 0x10000 +#define SCSI_OPTIONS_NLUNS_8 0x20000 +#define SCSI_OPTIONS_NLUNS_16 0x30000 +#define SCSI_OPTIONS_NLUNS_32 0x40000 +#define SCSI_OPTIONS_NLUNS_64 0x50000 +#define SCSI_OPTIONS_NLUNS_128 0x60000 +#define SCSI_OPTIONS_NLUNS_256 0x70000 + +#define SCSI_OPTIONS_NLUNS(n) ((n) & SCSI_OPTIONS_NLUNS_MASK) + +#define SCSI_OPTIONS_QAS 0x100000 /* Global Quick Arbitration Select */ + +/* + * SCSI autoconfiguration definitions. + * + * The library routine scsi_slave() is provided as a service to target + * driver to check for existence and readiness of a SCSI device. It is + * defined as: + * + * int scsi_slave(struct scsi_device *devp, int (*callback)(void)) + * + * where devp is the scsi_device structure passed to the target driver + * at probe time, and where callback declares whether scsi_slave() can + * sleep awaiting resources or must return an error if it cannot get + * resources (callback == SLEEP_FUNC implies that scsi_slave() + * can sleep - although this + * does not fully guarantee that resources will become available as + * some are allocated from the iopbmap which may just be completely + * full). The user call also supplies a callback function or NULL_FUNC. + * In the process of determining the existence of a SCSI device, + * scsi_slave will allocate space for the sd_inq field of the scsi_device + * pointed to by devp (if it is non-zero upon entry). + * + * scsi_slave() attempts to follow this sequence in order to determine + * the existence of a SCSI device: + * + * Attempt to send 2 TEST UNIT READY commands to the device. + * + * If that gets a check condition, run a non-extended + * REQUEST SENSE command. Ignore the results of it, as + * a the non-extended sense information contains only + * Vendor Unique error codes (the idea is that during + * probe time the nearly invariant first command to a + * device will get a Check Condition, and the real reason + * is that the device wants to tell you that a SCSI bus + * reset just occurred. + * + * Attempt to allocate an inquiry buffer and + * run an INQUIRY command (with response data format 0 set). + * + * If that gets a check condition, run another + * non-extended REQUEST SENSE command. + * + * The library routine scsi_probe() is provided as a service to target + * driver to check for bare-bones existence of a SCSI device. It is + * defined as: + * + * int scsi_probe(struct scsi_device *devp, int (*callback)(void)) + * + * scsi_probe() only executes an inquiry. + * + * Both functions return one of the integer values as defined below: + */ +#define SCSIPROBE_EXISTS 0 /* device exists, inquiry data valid */ +#define SCSIPROBE_NONCCS 1 /* device exists, no inquiry data */ +#define SCSIPROBE_NORESP 2 /* device didn't respond */ +#define SCSIPROBE_NOMEM 3 /* no space available for structures */ +#define SCSIPROBE_FAILURE 4 /* polled cmnd failure- unspecified */ +#define SCSIPROBE_BUSY 5 /* device was busy */ +#define SCSIPROBE_NOMEM_CB 6 /* no space, callback queued */ +#define SCSIPROBE_ASCII \ + {"EXISTS", "NONCCS", "NORESP", "NOMEM", \ + "FAILURE", "BUSY", "NOMEM_CB", NULL} + +/* + * default value for scsi_reset_delay + */ +#define SCSI_DEFAULT_RESET_DELAY 3000 + +/* + * default value for scsi_selection_timeout + */ +#define SCSI_DEFAULT_SELECTION_TIMEOUT 250 + +/* + * SCSI subsystem scsi_enumeration options. + * + * Knob for SPI (SCSI Parallel Intrconnect) enumeration. Unless an HBA defines + * it's own tran_bus_config, SPI enumeration is used. The "scsi_enumeration" + * knob determines how SPI enumeration is performed. + * + * The global variable "scsi_enumeration" is used as the default value of the + * "scsi-enumeration" property. In addition to enabling/disabling enumeration + * (bit 0), target and lun threading can be specified. Having things + * multi-threaded does not guarantee reduce configuration time, however when + * the bus is marginal multi-threading can substaintaly reduce configuration + * time because targets negotiate to stable transfer speeds in parallel - so + * all targets have stabalized by the time the sequential attach(9E) operations + * begin. Running multi-threaded also helps verification of framework and HBA + * locking: a BUS_CONFIG_ALL is equivalent to every target and lun combination + * getting a BUS_CONFIG_ONE from a separate thread at the same time. A disable + * mechanism is provided to accomidate buggy HBAs (set scsi-enumeration=7 + * driver.conf). Values are: + * + * 0 driver.conf enumeration + * 1 dynamic enumeration with target and lun multi-threading. + * 3 dynamic enumeration with lun multi-threading disabled. + * 5 dynamic enumeration with target multi-threading disabled; + * 7 dynamic enumeration with target/lun multi-threading disabled. + */ +#define SCSI_ENUMERATION_ENABLE 0x1 +#define SCSI_ENUMERATION_MT_LUN_DISABLE 0x2 +#define SCSI_ENUMERATION_MT_TARGET_DISABLE 0x4 + +#ifdef _KERNEL +/* + * Global SCSI config variables / options + */ +extern int scsi_options; +extern int scsi_enumeration; +extern unsigned int scsi_reset_delay; /* specified in milli seconds */ +extern int scsi_tag_age_limit; +extern int scsi_watchdog_tick; +extern int scsi_selection_timeout; /* specified in milli seconds */ +extern int scsi_host_id; +extern int scsi_fm_capable; +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_CONF_AUTOCONF_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/conf/device.h b/illumos-x86_64/usr/include/sys/scsi/conf/device.h new file mode 100644 index 00000000..b262bace --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/conf/device.h @@ -0,0 +1,268 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2014 Garrett D'Amore + */ + +/* + * SCSI device structure. + * + * All SCSI target drivers will have one of these per target/lun/sfunc. + * It is allocated and initialized by the framework SCSA HBA nexus code + * for each SCSI target dev_info_t node during HBA nexus DDI_CTLOPS_INITCHILD + * processing of a child device node just prior to tran_tgt_init(9E). A + * pointer the the scsi_device(9S) structure is stored in the + * driver-private data field of the target device's dev_info_t node (in + * 'devi_driver_data') and can be retrieved by ddi_get_driver_private(9F). + */ +#ifndef _SYS_SCSI_CONF_DEVICE_H +#define _SYS_SCSI_CONF_DEVICE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct scsi_device { + /* + * Routing information for a SCSI device (target/lun/sfunc). + * + * The scsi_address(9S) structure contains a pointer to the + * scsi_hba_tran(9S) of the transport. + * + * For devices below an HBA that uses SCSI_HBA_ADDR_SPI + * unit-addressing, the scsi_address(9S) information contains + * decoded target/lun addressing information. + * + * For devices below an HBA that uses SCSI_HBA_ADDR_COMPLEX + * unit-addressing, the scsi_address(9S) information contains a + * pointer to the scsi_device(9S) structure and the HBA can maintain + * its private per-unit-address/per-scsi_device information using + * scsi_address_device(9F) and scsi_device_hba_private_[gs]et(9F). + * + * NOTE: The scsi_address(9S) structure gets structure-copied into + * the scsi_pkt(9S) 'pkt_address' field. Having a pointer to the + * scsi_device(9S) structure within the scsi_address(9S) allows + * the SCSA framework to reflect generic changes in device state + * at scsi_pkt_comp(9F) time (given just a scsi_pkt(9S) pointer). + * + * NOTE: The older SCSI_HBA_TRAN_CLONE method of supporting + * SCSI-3 devices is still supported, but use is discouraged. + */ + struct scsi_address sd_address; + + /* Cross-reference to target device's dev_info_t. */ + dev_info_t *sd_dev; + + /* + * Target driver mutex for this device. Initialized by SCSA HBA + * framework code prior to probe(9E) or attach(9E) of scsi_device. + */ + kmutex_t sd_mutex; + + /* + * SCSA private: use is associated with implementation of + * SCSI_HBA_ADDR_COMPLEX scsi_device_hba_private_[gs]et(9F). + * The HBA driver can store a pointer to per-scsi_device(9S) + * HBA private data during its tran_tgt_init(9E) implementation + * by calling scsi_device_hba_private_set(9F), and free that + * pointer during tran_tgt_free(9E). At tran_send(9E) time, the + * HBA driver can use scsi_address_device(9F) to obtain a pointer + * to the scsi_device(9S) structure, and then gain access to + * its per-scsi_device(9S) hba private data by calling + * scsi_device_hba_private_get(9F). + */ + void *sd_hba_private; + + /* + * If scsi_slave is used to probe out this device, a scsi_inquiry data + * structure will be allocated and an INQUIRY command will be run to + * fill it in. + * + * The inquiry data is allocated/refreshed by scsi_probe/scsi_slave + * and freed by uninitchild (inquiry data is no longer freed by + * scsi_unprobe/scsi_unslave). + * + * NOTE: Additional device identity information may be available + * as properties of sd_dev. + */ + struct scsi_inquiry *sd_inq; + + /* + * Place to point to an extended request sense buffer. + * The target driver is responsible for managing this. + */ + struct scsi_extended_sense *sd_sense; + + /* + * Target driver 'private' information. Typically a pointer to target + * driver private ddi_soft_state(9F) information for the device. This + * information is typically established in target driver attach(9E), + * and freed in the target driver detach(9E). + * + * LEGACY: For a scsi_device structure allocated by scsi_vhci during + * online of a path, this was set by scsi_vhci to point to the + * pathinfo node. Please use sd_pathinfo instead. + */ + void *sd_private; + + /* + * FMA capabilities of scsi_device. + */ + int sd_fm_capable; + + /* + * mdi_pathinfo_t pointer to pathinfo node for scsi_device structure + * allocated by the scsi_vhci for transport to a specific pHCI path. + */ + void *sd_pathinfo; + + /* + * sd_uninit_prevent - Counter that prevents demotion of + * DS_INITIALIZED node (esp loss of devi_addr) by causing + * DDI_CTLOPS_UNINITCHILD failure - devi_ref will not protect + * demotion of DS_INITIALIZED node. + * + * sd_tran_tgt_free_done - in some cases SCSA will call + * tran_tgt_free(9E) independent of devinfo node state, this means + * that uninitchild code should not call tran_tgt_free(9E). + */ + unsigned sd_uninit_prevent:16, + sd_tran_tgt_free_done:1, + sd_flags_pad:15; + + /* + * The 'sd_tran_safe' field is a grotty hack that allows direct-access + * (non-scsa) drivers (like chs, ata, and mlx - which all make cmdk + * children) to *illegally* put their own vector in the scsi_address(9S) + * 'a_hba_tran' field. When all the drivers that overwrite + * 'a_hba_tran' are fixed, we can remove sd_tran_safe (and make + * scsi_hba.c code trust that the 'sd_address.a_hba_tran' established + * during initchild is still valid when uninitchild occurs). + * + * NOTE: This hack is also shows up in the DEVP_TO_TRAN implementation + * in scsi_confsubr.c. + * + * NOTE: The 'sd_tran_safe' field is only referenced by SCSA framework + * code, so always keeping it at the end of the scsi_device structure + * (until it can be removed) is OK. It use to be called 'sd_reserved'. + */ + struct scsi_hba_tran *sd_tran_safe; + +#ifdef SCSI_SIZE_CLEAN_VERIFY + /* + * Must be last: Building a driver with-and-without + * -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for + * differences with a tools like 'wsdiff' allows a developer to verify + * that their driver has no dependencies on scsi*(9S) size. + */ + int _pad[8]; +#endif /* SCSI_SIZE_CLEAN_VERIFY */ +}; + +#ifdef _KERNEL + +/* ==== The following interfaces are public ==== */ + +int scsi_probe(struct scsi_device *sd, int (*callback)(void)); +void scsi_unprobe(struct scsi_device *sd); + +/* ==== The following interfaces are private (currently) ==== */ + +char *scsi_device_unit_address(struct scsi_device *sd); + +/* + * scsi_device_prop_*() property interfaces: flags + * + * SCSI_DEVICE_PROP_PATH: property of path-to-device. + * The property is associated with the sd_pathinfo pathinfo node + * as established by scsi_vhci. If sd_pathinfo is NULL then the + * property is associated with the sd_dev devinfo node. + * Implementation uses mdi_prop_*() interfaces applied to + * mdi_pathinfo_t (sd_pathinfo) nodes. + * + * SCSI_DEVICE_PROP_DEVICE: property of device. + * The property is always associated with the sd_dev devinfo + * node. Implementation uses ndi_prop_*() interfaces applied + * dev_info_t (sd_dev) nodes. + */ +#define SCSI_DEVICE_PROP_PATH 0x1 /* type is property-of-path */ +#define SCSI_DEVICE_PROP_DEVICE 0x2 /* type is property-of-device */ +#define SCSI_DEVICE_PROP_TYPE_MSK 0xF + +int scsi_device_prop_get_int(struct scsi_device *sd, + uint_t flags, char *name, int defvalue); +int64_t scsi_device_prop_get_int64(struct scsi_device *, + uint_t flags, char *name, int64_t defvalue); + +int scsi_device_prop_lookup_byte_array(struct scsi_device *sd, + uint_t flags, char *name, uchar_t **, uint_t *); +int scsi_device_prop_lookup_int_array(struct scsi_device *sd, + uint_t flags, char *name, int **, uint_t *); +int scsi_device_prop_lookup_string(struct scsi_device *sd, + uint_t flags, char *name, char **); +int scsi_device_prop_lookup_string_array(struct scsi_device *sd, + uint_t flags, char *name, char ***, uint_t *); + +int scsi_device_prop_update_byte_array(struct scsi_device *sd, + uint_t flags, char *name, uchar_t *, uint_t); +int scsi_device_prop_update_int(struct scsi_device *sd, + uint_t flags, char *name, int); +int scsi_device_prop_update_int64(struct scsi_device *sd, + uint_t flags, char *name, int64_t); +int scsi_device_prop_update_int_array(struct scsi_device *sd, + uint_t flags, char *name, int *, uint_t); +int scsi_device_prop_update_string(struct scsi_device *sd, + uint_t flags, char *name, char *); +int scsi_device_prop_update_string_array(struct scsi_device *sd, + uint_t flags, char *name, char **, uint_t); + +int scsi_device_prop_remove(struct scsi_device *sd, + uint_t flags, char *name); +void scsi_device_prop_free(struct scsi_device *sd, + uint_t flags, void *data); + +/* SCSI_HBA_ADDR_COMPLEX interfaces */ +struct scsi_device *scsi_address_device(struct scsi_address *sa); +void scsi_device_hba_private_set(struct scsi_device *sd, void *data); +void *scsi_device_hba_private_get(struct scsi_device *sd); + +/* ==== The following interfaces are private ==== */ + +size_t scsi_device_size(); + +/* ==== The following interfaces are obsolete ==== */ + +int scsi_slave(struct scsi_device *sd, int (*callback)(void)); +void scsi_unslave(struct scsi_device *sd); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_CONF_DEVICE_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/commands.h b/illumos-x86_64/usr/include/sys/scsi/generic/commands.h new file mode 100644 index 00000000..ed45141b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/commands.h @@ -0,0 +1,526 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + * + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_SCSI_GENERIC_COMMANDS_H +#define _SYS_SCSI_GENERIC_COMMANDS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Standard SCSI Command Definitions + * + * Macros to determine known command sizes + */ +#define CDB_GROUPID(cmd) ((cmd >> 5) & 0x7) +#define CDB_GROUPID_0 0 +#define CDB_GROUPID_1 1 +#define CDB_GROUPID_2 2 +#define CDB_GROUPID_3 3 +#define CDB_GROUPID_4 4 +#define CDB_GROUPID_5 5 +#define CDB_GROUPID_6 6 +#define CDB_GROUPID_7 7 + +#define CDB_GROUP0 6 /* 6-byte cdb's */ +#define CDB_GROUP1 10 /* 10-byte cdb's */ +#define CDB_GROUP2 10 /* 10-byte cdb's */ +#define CDB_GROUP3 0 /* reserved */ +#define CDB_GROUP4 16 /* 16-byte cdb's */ +#define CDB_GROUP5 12 /* 12-byte cdb's */ +#define CDB_GROUP6 0 /* reserved */ +#define CDB_GROUP7 0 /* reserved */ + +/* + * Generic Command Definitions + * NOTE: CDROM commands are defined in cdio.h + */ + +/* + * Group 0 Commands (CDB range 0x00 - 0x1F) + */ +#define SCMD_GROUP0 0x00 + +/* + * Group 0 commands, All Devices + */ +#define SCMD_TEST_UNIT_READY 0x00 +#define SCMD_REQUEST_SENSE 0x03 +#define SCMD_INQUIRY 0x12 +#define SCMD_COPY 0x18 +#define SCMD_GDIAG 0x1C /* receive diagnostic results */ +#define SCMD_SDIAG 0x1D /* send diagnostic results */ + +/* + * Group 0 commands, Direct Access Devices + */ +/* SCMD_TEST_UNIT_READY 0x00 */ +#define SCMD_REZERO_UNIT 0x01 +/* SCMD_REQUEST_SENSE 0x03 */ +#define SCMD_FORMAT 0x04 +#define SCMD_REASSIGN_BLOCK 0x07 +#define SCMD_READ 0x08 +#define SCMD_WRITE 0x0a +#define SCMD_SEEK 0x0b +/* SCMD_INQUIRY 0x12 */ +#define SCMD_MODE_SELECT 0x15 +#define SCMD_RESERVE 0x16 +#define SCMD_RELEASE 0x17 +/* SCMD_COPY 0x18 */ +#define SCMD_MODE_SENSE 0x1a +#define SCMD_START_STOP 0x1b +/* SCMD_GDIAG 0x1C */ +/* SCMD_SDIAG 0x1D */ +#define SCMD_DOORLOCK 0x1E /* Prevent/Allow Medium Removal */ + +/* + * Group 0 commands, Sequential Access Devices + */ +/* SCMD_TEST_UNIT_READY 0x00 */ +#define SCMD_REWIND 0x01 /* Note similarity to SCMD_REZERO */ +/* SCMD_REQUEST_SENSE 0x03 */ +#define SCMD_READ_BLKLIM 0x05 +/* SCMD_READ 0x08 */ +/* SCMD_WRITE 0x0a */ +#define SCMD_TRK_SEL 0x0b /* Note similarity to SCMD_SEEK */ +#define SCMD_READ_REVERSE 0x0f +#define SCMD_WRITE_FILE_MARK 0x10 +#define SCMD_SPACE 0x11 +/* SCMD_INQUIRY 0x12 */ +#define SCMD_VERIFY_G0 0x13 +#define SCMD_RECOVER_BUF 0x14 +/* SCMD_MODE_SELECT 0x15 */ +/* SCMD_RESERVE 0x16 */ +/* SCMD_RELEASE 0x17 */ +/* SCMD_COPY 0x18 */ +#define SCMD_ERASE 0x19 +/* SCMD_MODE_SENSE 0x1a */ +#define SCMD_LOAD 0x1b /* Note similarity to SCMD_START_STOP */ +/* SCMD_GDIAG 0x1c */ +/* SCMD_SDIAG 0x1d */ +/* SCMD_DOORLOCK 0x1e */ + + +/* + * Group 0 commands, Printer Devices + */ +/* SCMD_TEST_UNIT_READY 0x00 */ +/* SCMD_REQUEST_SENSE 0x03 */ +/* SCMD_FORMAT 0x04 */ +#define SCMD_PRINT 0x0a /* Note similarity to SCMD_WRITE */ +#define SCMD_SLEW_PRINT 0x0b /* ? similar to SCMD_SEEK ? */ +#define SCMD_FLUSH_PRINT_BUF 0x10 /* ? similar to SCMD_WRITE_FILE_MARK */ +/* SCMD_INQUIRY 0x12 */ +/* SCMD_RECOVER_BUF 0x14 */ +/* SCMD_MODE_SELECT 0x15 */ +/* SCMD_RESERVE 0x16 */ +/* SCMD_RELEASE 0x17 */ +/* SCMD_COPY 0x18 */ +/* SCMD_MODE_SENSE 0x1a */ +#define SCMD_STOP_PRINT 0x1b /* Note similarity to SCMD_START_STOP */ +/* SCMD_GDIAG 0x1c */ +/* SCMD_SDIAG 0x1d */ + +/* + * Group 0 commands, Processor Devices + */ +/* SCMD_TEST_UNIT_READY 0x00 */ +/* SCMD_REQUEST_SENSE 0x03 */ +#define SCMD_RECEIVE 0x08 /* Note similarity to SCMD_READ */ +#define SCMD_SEND 0x0a /* Note similarity to SCMD_WRITE */ +/* SCMD_INQUIRY 0x12 */ +/* SCMD_COPY 0x18 */ +/* SCMD_MODE_SENSE 0x1a */ +/* SCMD_GDIAG 0x1c */ +/* SCMD_SDIAG 0x1d */ + +/* + * Group 0 commands, WORM Devices + */ +/* SCMD_TEST_UNIT_READY 0x00 */ +/* SCMD_REZERO_UNIT 0x01 */ +/* SCMD_REQUEST_SENSE 0x03 */ +/* SCMD_REASSIGN_BLOCK 0x07 */ +/* SCMD_READ 0x08 */ +/* SCMD_WRITE 0x0a */ +/* SCMD_SEEK 0x0b */ +/* SCMD_INQUIRY 0x12 */ +/* SCMD_MODE_SELECT 0x15 */ +/* SCMD_RESERVE 0x16 */ +/* SCMD_RELEASE 0x17 */ +/* SCMD_COPY 0x18 */ +/* SCMD_MODE_SENSE 0x1a */ +/* SCMD_START_STOP 0x1b */ +/* SCMD_GDIAG 0x1C */ +/* SCMD_SDIAG 0x1D */ +/* SCMD_DOORLOCK 0x1E */ + +/* + * Group 0 commands, Read Only Devices + */ +/* SCMD_TEST_UNIT_READY 0x00 */ +/* SCMD_REZERO_UNIT 0x01 */ +/* SCMD_REQUEST_SENSE 0x03 */ +/* SCMD_REASSIGN_BLOCK 0x07 */ +/* SCMD_READ 0x08 */ +/* SCMD_SEEK 0x0b */ +/* SCMD_INQUIRY 0x12 */ +/* SCMD_MODE_SELECT 0x15 */ +/* SCMD_RESERVE 0x16 */ +/* SCMD_RELEASE 0x17 */ +/* SCMD_COPY 0x18 */ +/* SCMD_MODE_SENSE 0x1a */ +/* SCMD_START_STOP 0x1b */ +/* SCMD_GDIAG 0x1C */ +/* SCMD_SDIAG 0x1D */ +/* SCMD_DOORLOCK 0x1E */ + +/* + * Group 1 Commands (CDB range 0x20 - 0x3F) + */ +#define SCMD_GROUP1 0x20 + +/* + * Group 1 Commands, All Devices + */ +#define SCMD_COMPARE 0x39 +#define SCMD_COPY_VERIFY 0x3A +#define SCMD_PERSISTENT_RESERVE_IN 0x5E +#define SCMD_PERSISTENT_RESERVE_OUT 0x5F +#define SCMD_PRIN SCMD_PERSISTENT_RESERVE_IN +#define SCMD_PROUT SCMD_PERSISTENT_RESERVE_OUT + +/* + * Group 1 Commands, Direct Access Devices + */ +#define SCMD_READ_FORMAT_CAP 0x23 +#define SCMD_READ_CAPACITY 0x25 +#define SCMD_READ_G1 0x28 /* Note that only the group changed */ +#define SCMD_WRITE_G1 0x2a /* Note that only the group changed */ +#define SCMD_SEEK_G1 0x2b /* Note that only the group changed */ +#define SCMD_WRITE_VERIFY 0x2e +#define SCMD_VERIFY 0x2f +#define SCMD_SEARCH_HIGH 0x30 +#define SCMD_SEARCH_EQUAL 0x31 +#define SCMD_SEARCH_LOW 0x32 +#define SCMD_SET_LIMITS 0x33 +#define SCMD_SYNCHRONIZE_CACHE 0x35 +#define SCMD_READ_DEFECT_LIST 0x37 +#define SCMD_WRITE_BUFFER 0x3B +#define SCMD_READ_BUFFER 0x3c +#define SCMD_READ_LONG 0x3E +#define SCMD_WRITE_LONG 0x3F +#define SCMD_WRITE_SAME_G1 0x41 +#define SCMD_UNMAP 0x42 +#define SCMD_GET_CONFIGURATION 0x46 +#define SCMD_LOG_SELECT_G1 0x4c +#define SCMD_LOG_SENSE_G1 0x4d +#define SCMD_RESERVE_G1 0x56 +#define SCMD_RELEASE_G1 0x57 +#define SCMD_MODE_SELECT_G1 0x55 +#define SCMD_MODE_SENSE_G1 0x5A + + +/* + * Group 1 Commands, Sequential Access Devices + */ +#define SCMD_LOCATE 0x2B /* Note similarity to SCMD_SEEK_G1 */ +#define SCMD_READ_POSITION 0x34 +#define SCMD_REPORT_DENSITIES 0x44 + +/* + * Group 1 Commands, Printer Devices + */ +/* (None Defined) */ + +/* + * Group 1 Commands, Processor Devices + */ +/* (None Defined) */ + +/* + * Group 1 Commands, WORM Devices + */ +/* SCMD_READ_CAPACITY 0x25 */ +/* SCMD_READ_G1 0x28 */ +/* SCMD_WRITE_G1 0x2a */ +/* SCMD_SEEK_G1 0x2b */ +/* SCMD_WRITE_VERIFY 0x2e */ +/* SCMD_VERIFY 0x2f */ +/* SCMD_SEARCH_HIGH 0x30 */ +/* SCMD_SEARCH_EQUAL 0x31 */ +/* SCMD_SEARCH_LOW 0x32 */ +/* SCMD_SET_LIMITS 0x33 */ + +/* + * Group 1 Commands, Read Only Devices + */ +/* SCMD_READ_CAPACITY 0x25 */ +/* SCMD_READ_G1 0x28 */ +/* SCMD_SEEK_G1 0x2b */ +/* SCMD_VERIFY 0x2f */ +/* SCMD_SEARCH_HIGH 0x30 */ +/* SCMD_SEARCH_EQUAL 0x31 */ +/* SCMD_SEARCH_LOW 0x32 */ +/* SCMD_SET_LIMITS 0x33 */ + +/* + * Group 1 Commands, MMC Devices + */ + +/* GET EVENT STATUS NOTIFICATION, MMC-3 5.6 */ +#define SCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a + +/* event header */ +#define SD_GESN_HEADER_LEN 4 +#define SD_GESN_HEADER_NEA 0x80 /* byte 2 */ +#define SD_GESN_HEADER_CLASS 0x07 /* byte 2 */ + +/* media class event class and event data that follows the header */ +#define SD_GESN_MEDIA_CLASS 4 + +#define SD_GESN_MEDIA_DATA_LEN 4 +#define SD_GESN_MEDIA_EVENT_CODE 0x0f /* byte 0 */ +#define SD_GESN_MEDIA_EVENT_STATUS_PRESENT 0x02 /* byte 1 */ +#define SD_GESN_MEDIA_EVENT_STATUS_TRAY_OPEN 0x01 /* byte 1 */ + +/* media event code */ +#define SD_GESN_MEDIA_EVENT_NOCHG 0 +#define SD_GESN_MEDIA_EVENT_EJECTREQUEST 1 +#define SD_GESN_MEDIA_EVENT_NEWMEDIA 2 +#define SD_GESN_MEDIA_EVENT_MEDIAREMOVAL 3 +#define SD_GESN_MEDIA_EVENT_MEDIACHANGED 4 +#define SD_GESN_MEDIA_EVENT_BGFORMATCOMPLETED 5 +#define SD_GESN_MEDIA_EVENT_BGFORMATRESTARTED 6 + + +/* + * Group 3 Commands + */ +#define SCMD_VAR_LEN 0x7f + +/* + * Group 4 Commands, All Devices + */ +#define SCMD_GROUP4 0x80 +#define SCMD_EXTENDED_COPY 0x83 +#define SCMD_RECV_COPY_RESULTS 0x84 +#define SCMD_VERIFY_G4 0x8f + +/* + * Group 4 Commands, Direct Access Devices + */ +#define SCMD_READ_G4 0x88 +#define SCMD_WRITE_G4 0x8a +#define SCMD_WRITE_VERIFY_G4 0x8e +#define SCMD_WRITE_SAME_G4 0x93 +#define SCMD_SVC_ACTION_IN_G4 0x9e +#define SCMD_SVC_ACTION_OUT_G4 0x9f + +/* + * Group 4 Service Actions for Service Action In (16) + */ +#define SSVC_ACTION_READ_CAPACITY_G4 0x10 +#define SSVC_ACTION_READ_LONG_G4 0x11 + +/* + * Group 4 Service Actions for Service Action Out (16) + */ +#define SSVC_ACTION_WRITE_LONG_G4 0x11 + +/* + * Group 4 Commands, Sequential Access Devics + */ +#define SCMD_WRITE_FILE_MARK_G4 0x80 +#define SCMD_READ_REVERSE_G4 0x81 +#define SCMD_COMPARE_AND_WRITE 0x89 +#define SCMD_READ_ATTRIBUTE 0x8c +#define SCMD_WRITE_ATTRIBUTE 0x8d +#define SCMD_SPACE_G4 0x91 +#define SCMD_LOCATE_G4 0x92 + +/* + * Group 5 commands. + */ +#define SCMD_GROUP5 0xA0 +#define SCMD_REPORT_LUNS 0xA0 +#define SCMD_SECURITY_PROTO_IN 0xA2 +#define SCMD_MAINTENANCE_IN 0xA3 +#define SCMD_MAINTENANCE_OUT 0xA4 +#define SCMD_READ_G5 0xA8 +#define SCMD_WRITE_G5 0xAA +#define SCMD_SVC_ACTION_OUT_G5 0xA9 +#define SCMD_SVC_ACTION_IN_G5 0xAB +#define SCMD_GET_PERFORMANCE 0xAC +#define SCMD_WRITE_VERIFY_G5 0xAE +#define SCMD_VERIFY_G5 0xAF +#define SCMD_SECURITY_PROTO_OUT 0xB5 + +/* + * Group 5 Service Actions for Maintenance In (12) + */ +#define SSVC_ACTION_GET_TARGET_PORT_GROUPS 0x0a +#define SSVC_ACTION_GET_SUPPORTED_OPERATIONS 0x0c +#define SSVC_SCTION_GET_SUPPORTED_MANAGEMENT 0x0d +#define SSVC_ACTION_GET_TIMESTAMP 0x0f + +/* + * Group 5 Service Actions for Maintenance Out (12) + */ +#define SSVC_ACTION_SET_DEVICE_IDENTIFIER 0x06 +#define SSVC_ACTION_SET_PRIORITY 0x0e +#define SSVC_ACTION_SET_TARGET_PORT_GROUPS 0x0a +#define SSVC_ACTION_SET_TIMESTAMP 0x0f + +/* + * Group 5 Service Actions for Service Action In (12) + */ +#define SSVC_ACTION_READ_MEDIA_SERIAL 0x01 +/* + * scsi_key_strings for SCMD_ definitions + * NOTE: see SCSI_CMDS_KEY_STRINGS_CDIO in cdio.h for additional + * command-to-string translations. + */ +#define SCSI_CMDS_KEY_STRINGS \ +/* 0x00 */ SCMD_TEST_UNIT_READY, "test_unit_ready", \ +/* 0x01 */ SCMD_REWIND | \ + SCMD_REZERO_UNIT, "rezero/rewind", \ +/* 0x03 */ SCMD_REQUEST_SENSE, "request_sense", \ +/* 0x04 */ SCMD_FORMAT, "format", \ +/* 0x05 */ SCMD_READ_BLKLIM, "read_block_limits", \ +/* 0x07 */ SCMD_REASSIGN_BLOCK, "reassign", \ +/* 0x08 */ SCMD_READ | \ + SCMD_RECEIVE, "read", \ +/* 0x0a */ SCMD_PRINT | \ + SCMD_SEND | \ + SCMD_WRITE, "write", \ +/* 0x0b */ SCMD_SEEK | \ + SCMD_SLEW_PRINT | \ + SCMD_TRK_SEL, "seek", \ +/* 0x0f */ SCMD_READ_REVERSE, "read_reverse", \ +/* 0x10 */ SCMD_WRITE_FILE_MARK | \ + SCMD_FLUSH_PRINT_BUF, "write_file_mark", \ +/* 0x11 */ SCMD_SPACE, "space", \ +/* 0x12 */ SCMD_INQUIRY, "inquiry", \ +/* 0x13 */ SCMD_VERIFY_G0, "verify", \ +/* 0x14 */ SCMD_RECOVER_BUF, "recover_buffer_data", \ +/* 0x15 */ SCMD_MODE_SELECT, "mode_select", \ +/* 0x16 */ SCMD_RESERVE, "reserve", \ +/* 0x17 */ SCMD_RELEASE, "release", \ +/* 0x18 */ SCMD_COPY, "copy", \ +/* 0x19 */ SCMD_ERASE, "erase_tape", \ +/* 0x1a */ SCMD_MODE_SENSE, "mode_sense", \ +/* 0x1b */ SCMD_LOAD | \ + SCMD_START_STOP | \ + SCMD_STOP_PRINT, "load/start/stop", \ +/* 0x1c */ SCMD_GDIAG, "get_diagnostic_results", \ +/* 0x1d */ SCMD_SDIAG, "send_diagnostic_command", \ +/* 0x1e */ SCMD_DOORLOCK, "door_lock", \ +/* 0x23 */ SCMD_READ_FORMAT_CAP, "read_format_capacity", \ +/* 0x25 */ SCMD_READ_CAPACITY, "read_capacity", \ +/* 0x28 */ SCMD_READ_G1, "read(10)", \ +/* 0x2a */ SCMD_WRITE_G1, "write(10)", \ +/* 0x2b */ SCMD_SEEK_G1 | \ + SCMD_LOCATE, "seek(10)", \ +/* 0x2e */ SCMD_WRITE_VERIFY, "write_verify", \ +/* 0x2f */ SCMD_VERIFY, "verify(10)", \ +/* 0x30 */ SCMD_SEARCH_HIGH, "search_data_high", \ +/* 0x31 */ SCMD_SEARCH_EQUAL, "search_data_equal", \ +/* 0x32 */ SCMD_SEARCH_LOW, "search_data_low", \ +/* 0x33 */ SCMD_SET_LIMITS, "set_limits", \ +/* 0x34 */ SCMD_READ_POSITION, "read_position", \ +/* 0x35 */ SCMD_SYNCHRONIZE_CACHE, "synchronize_cache", \ +/* 0x37 */ SCMD_READ_DEFECT_LIST, "read_defect_data", \ +/* 0x39 */ SCMD_COMPARE, "compare", \ +/* 0x3a */ SCMD_COPY_VERIFY, "copy_verify", \ +/* 0x3b */ SCMD_WRITE_BUFFER, "write_buffer", \ +/* 0x3c */ SCMD_READ_BUFFER, "read_buffer", \ +/* 0x3e */ SCMD_READ_LONG, "read_long", \ +/* 0x3f */ SCMD_WRITE_LONG, "write_long", \ +/* 0x41 */ SCMD_WRITE_SAME_G1, "write_same(10)", \ +/* 0x42 */ SCMD_UNMAP, "unmap", \ +/* 0x44 */ SCMD_REPORT_DENSITIES | \ + /* SCMD_READ_HEADER (from cdio.h) | */ \ + 0, "report_densities/read_header", \ +/* 0x46 */ SCMD_GET_CONFIGURATION, "get_configuration", \ +/* 0x4c */ SCMD_LOG_SELECT_G1, "log_select", \ +/* 0x4d */ SCMD_LOG_SENSE_G1, "log_sense", \ +/* 0x55 */ SCMD_MODE_SELECT_G1, "mode_select(10)", \ +/* 0x56 */ SCMD_RESERVE_G1, "reserve(10)", \ +/* 0x57 */ SCMD_RELEASE_G1, "release(10)", \ +/* 0x5a */ SCMD_MODE_SENSE_G1, "mode_sense(10)", \ +/* 0x5e */ SCMD_PERSISTENT_RESERVE_IN, "persistent_reserve_in", \ +/* 0x5f */ SCMD_PERSISTENT_RESERVE_OUT, "persistent_reserve_out", \ +/* 0x80 */ SCMD_WRITE_FILE_MARK_G4, "write_file_mark(16)", \ +/* 0x81 */ SCMD_READ_REVERSE_G4, "read_reverse(16)", \ +/* 0x83 */ SCMD_EXTENDED_COPY, "extended_copy", \ +/* 0x88 */ SCMD_READ_G4, "read(16)", \ +/* 0x8a */ SCMD_WRITE_G4, "write(16)", \ +/* 0x8c */ SCMD_READ_ATTRIBUTE, "read_attribute", \ +/* 0x8d */ SCMD_WRITE_ATTRIBUTE, "write_attribute", \ +/* 0x8e */ SCMD_WRITE_VERIFY_G4, "write_verify(16)", \ +/* 0x8f */ SCMD_VERIFY_G4, "verify(16)", \ +/* 0x91 */ SCMD_SPACE_G4, "space(16)", \ +/* 0x92 */ SCMD_LOCATE_G4, "locate(16)", \ +/* 0x92 */ SCMD_WRITE_SAME_G4, "write_same(16)", \ +/* 0x9e */ SCMD_SVC_ACTION_IN_G4, "service_action_in(16)", \ +/* 0x9f */ SCMD_SVC_ACTION_OUT_G4, "service_action_out(16)", \ +/* 0xa0 */ SCMD_REPORT_LUNS, "report_luns", \ +/* 0xa2 */ SCMD_SECURITY_PROTO_IN, "security_protocol_in", \ +/* 0xa3 */ SCMD_MAINTENANCE_IN, "maintenance_in", \ +/* 0xa4 */ SCMD_MAINTENANCE_OUT, "maintenance_out", \ +/* 0xa8 */ SCMD_READ_G5, "read(12)", \ +/* 0xa9 */ SCMD_SVC_ACTION_OUT_G5, "service_action_out(12)", \ +/* 0xaa */ SCMD_WRITE_G5, "write(12)", \ +/* 0xab */ SCMD_SVC_ACTION_IN_G5, "service_action_in(12)", \ +/* 0xac */ SCMD_GET_PERFORMANCE, "get_performance", \ +/* 0xAE */ SCMD_WRITE_VERIFY_G5, "write_verify(12)", \ +/* 0xAF */ SCMD_VERIFY_G5, "verify(12)", \ +/* 0xb5 */ SCMD_SECURITY_PROTO_OUT, "security_protocol_out" \ + /* see cdio.h for additional command-to-string translations */ + +/* XXX not a command code, does not belong here */ +#define ATAPI_CAPABILITIES 0x2A + +#ifdef __cplusplus +} +#endif + +/* + * Below are inclusions of files describing various command structures + * of interest. + */ +#include +#include + +/* + * Private Vendor Unique Commands - Each implementation provides this. + */ +#include + +#endif /* _SYS_SCSI_GENERIC_COMMANDS_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/dad_mode.h b/illumos-x86_64/usr/include/sys/scsi/generic/dad_mode.h new file mode 100644 index 00000000..b6621450 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/dad_mode.h @@ -0,0 +1,281 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SCSI_GENERIC_DAD_MODE_H +#define _SYS_SCSI_GENERIC_DAD_MODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structures and defines for DIRECT ACCESS mode sense/select operations + */ + +/* + * Direct Access Device mode header device specific byte definitions. + * + * On MODE SELECT operations, the effect of the state of the WP bit is unknown, + * else reflects the Write-Protect status of the device. + * + * On MODE SELECT operations, the the DPOFUA bit is reserved and must + * be zero, else on MODE SENSE operations it reflects whether or not + * DPO and FUA bits are supported. + */ + +#define MODE_DAD_WP 0x80 +#define MODE_DAD_DPOFUA 0x10 + +/* + * Direct Access Device Medium Types (for non direct-access magentic tapes) + */ + +#define DAD_MTYP_DFLT 0x0 /* default (currently mounted) type */ + +#define DAD_MTYP_FLXSS 0x1 /* flexible disk, single side, unspec. media */ +#define DAD_MTYP_FLXDS 0x2 /* flexible disk, double side, unspec. media */ + +#define DAD_MTYP_FLX_8SSSD 0x05 /* 8", single side, single density, 48tpi */ +#define DAD_MTYP_FLX_8DSSD 0x06 /* 8", double side, single density, 48tpi */ +#define DAD_MTYP_FLX_8SSDD 0x09 /* 8", single side, double density, 48tpi */ +#define DAD_MTYP_FLX_8DSDD 0x0A /* 8", double side, double density, 48tpi */ +#define DAD_MTYP_FLX_5SSLD 0x0D /* 5.25", single side, single density, 48tpi */ +#define DAD_MTYP_FLX_5DSMD1 0x12 /* 5.25", double side, medium density, 48tpi */ +#define DAD_MTYP_FLX_5DSMD2 0x16 /* 5.25", double side, medium density, 96tpi */ +#define DAD_MTYP_FLX_5DSQD 0x1A /* 5.25", double side, quad density, 96tpi */ +#define DAD_MTYP_FLX_3DSLD 0x1E /* 3.5", double side, low density, 135tpi */ + + +/* + * Direct Access device Mode Sense/Mode Select Defined pages + */ + +#define DAD_MODE_ERR_RECOV 0x01 +#define DAD_MODE_FORMAT 0x03 +#define DAD_MODE_GEOMETRY 0x04 +#define DAD_MODE_FLEXDISK 0x05 +#define DAD_MODE_VRFY_ERR_RECOV 0x07 +#define DAD_MODE_CACHE 0x08 +#define DAD_MODE_MEDIA_TYPES 0x0B +#define DAD_MODE_NOTCHPART 0x0C +#define DAD_MODE_POWER_COND 0x0D + +/* + * Definitions of selected pages + */ + +/* + * Page 0x1 - Error Recovery Parameters + * + * Note: This structure is incompatible with previous SCSI + * implementations. See for an + * alternative form of this structure. They can be + * distinguished by the length of data returned + * from a MODE SENSE command. + */ + +#define PAGELENGTH_DAD_MODE_ERR_RECOV 0x0A + +struct mode_err_recov { + struct mode_page mode_page; /* common mode page header */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t dcr : 1, /* disable correction */ + dte : 1, /* disable transfer on error */ + per : 1, /* post error */ + eec : 1, /* enable early correction */ + rc : 1, /* read continuous */ + tb : 1, /* transfer block */ + arre : 1, /* auto read realloc enabled */ + awre : 1; /* auto write realloc enabled */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t awre : 1, /* auto write realloc enabled */ + arre : 1, /* auto read realloc enabled */ + tb : 1, /* transfer block */ + rc : 1, /* read continuous */ + eec : 1, /* enable early correction */ + per : 1, /* post error */ + dte : 1, /* disable transfer on error */ + dcr : 1; /* disable correction */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t read_retry_count; + uchar_t correction_span; + uchar_t head_offset_count; + uchar_t strobe_offset_count; + uchar_t reserved; + uchar_t write_retry_count; + uchar_t reserved_2; + ushort_t recovery_time_limit; +}; + +/* + * Page 0x3 - Direct Access Device Format Parameters + */ + +struct mode_format { + struct mode_page mode_page; /* common mode page header */ + ushort_t tracks_per_zone; /* Handling of Defects Fields */ + ushort_t alt_sect_zone; + ushort_t alt_tracks_zone; + ushort_t alt_tracks_vol; + ushort_t sect_track; /* Track Format Field */ + ushort_t data_bytes_sect; /* Sector Format Fields */ + ushort_t interleave; + ushort_t track_skew; + ushort_t cylinder_skew; +#if defined(_BIT_FIELDS_LTOH) + uchar_t : 3, + _reserved_ins : 1, /* see */ + surf : 1, + rmb : 1, + hsec : 1, + ssec : 1; /* Drive Type Field */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t ssec : 1, /* Drive Type Field */ + hsec : 1, + rmb : 1, + surf : 1, + _reserved_ins : 1, /* see */ + : 3; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t reserved[2]; +}; + +/* + * Page 0x4 - Rigid Disk Drive Geometry Parameters + */ + +struct mode_geometry { + struct mode_page mode_page; /* common mode page header */ + uchar_t cyl_ub; /* number of cylinders */ + uchar_t cyl_mb; + uchar_t cyl_lb; + uchar_t heads; /* number of heads */ + uchar_t precomp_cyl_ub; /* cylinder to start precomp */ + uchar_t precomp_cyl_mb; + uchar_t precomp_cyl_lb; + uchar_t current_cyl_ub; /* cyl to start reduced current */ + uchar_t current_cyl_mb; + uchar_t current_cyl_lb; + ushort_t step_rate; /* drive step rate */ + uchar_t landing_cyl_ub; /* landing zone cylinder */ + uchar_t landing_cyl_mb; + uchar_t landing_cyl_lb; +#if defined(_BIT_FIELDS_LTOH) + uchar_t rpl : 2, /* rotational position locking */ + : 6; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t : 6, + rpl : 2; /* rotational position locking */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t rotational_offset; /* rotational offset */ + uchar_t reserved; + ushort_t rpm; /* rotations per minute */ + uchar_t reserved2[2]; +}; + +#define RPL_SPINDLE_SLAVE 1 +#define RPL_SPINDLE_MASTER 2 +#define RPL_SPINDLE_MASTER_CONTROL 3 + +/* + * Page 0x8 - Caching Page + * + * Note: This structure is incompatible with previous SCSI + * implementations. See for an + * alternative form of this structure. They can be + * distinguished by the length of data returned + * from a MODE SENSE command. + */ + +#define PAGELENGTH_DAD_MODE_CACHE_SCSI3 0x12 + +struct mode_cache_scsi3 { + struct mode_page mode_page; /* common mode page header */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t rcd : 1, /* Read Cache Disable */ + mf : 1, /* Multiplication Factor */ + wce : 1, /* Write Cache Enable */ + size : 1, /* Size Enable */ + disc : 1, /* Discontinuity */ + cap : 1, /* Caching Analysis Permitted */ + abpf : 1, /* Abort Pre-Fetch */ + ic : 1; /* Initiator Control */ + uchar_t write_reten_pri : 4, /* Write Retention Priority */ + read_reten_pri : 4; /* Demand Read Retention Priority */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t ic : 1, /* Initiator Control */ + abpf : 1, /* Abort Pre-Fetch */ + cap : 1, /* Caching Analysis Permitted */ + disc : 1, /* Discontinuity */ + size : 1, /* Size Enable */ + wce : 1, /* Write Cache Enable */ + mf : 1, /* Multiplication Factor */ + rcd : 1; /* Read Cache Disable */ + uchar_t read_reten_pri : 4, /* Demand Read Retention Priority */ + write_reten_pri : 4; /* Write Retention Priority */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + ushort_t dis_prefetch_len; /* Disable prefetch xfer length */ + ushort_t min_prefetch; /* minimum prefetch length */ + ushort_t max_prefetch; /* maximum prefetch length */ + ushort_t prefetch_ceiling; /* max prefetch ceiling */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t : 3, /* reserved */ + vu_123 : 1, /* Vendor Specific, byte 12 bit 3 */ + vu_124 : 1, /* Vendor Specific, byte 12 bit 4 */ + dra : 1, /* Disable Read-Ahead */ + lbcss : 1, /* Logical Block Cache Segment Size */ + fsw : 1; /* Force Sequential Write */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t fsw : 1, /* Force Sequential Write */ + lbcss : 1, /* Logical Block Cache Segment Size */ + dra : 1, /* Disable Read-Ahead */ + vu_124 : 1, /* Vendor Specific, byte 12 bit 4 */ + vu_123 : 1, /* Vendor Specific, byte 12 bit 3 */ + : 3; /* reserved */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t num_cache_seg; /* Number of cache segments */ + ushort_t cache_seg_size; /* Cache segment size */ + uchar_t reserved; + uchar_t non_cache_seg_size_ub; /* Non cache segment size */ + uchar_t non_cache_seg_size_mb; + uchar_t non_cache_seg_size_lb; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_GENERIC_DAD_MODE_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/inquiry.h b/illumos-x86_64/usr/include/sys/scsi/generic/inquiry.h new file mode 100644 index 00000000..fcbf00d5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/inquiry.h @@ -0,0 +1,460 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_GENERIC_INQUIRY_H +#define _SYS_SCSI_GENERIC_INQUIRY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SCSI Standard Inquiry Data: + * + * Format of data returned as a result of an INQUIRY command. + * + * NOTE: Fields marked 'DEPRECATED' are defined in older versions of t10 "SCSI + * Primary Command" spec, and are marked 'Obsolete' in newer versions. + */ +#if defined(_BIT_FIELDS_LTOH) +struct scsi_inquiry { + /* + * byte 0 + * + * Bits 7-5 are the Peripheral Device Qualifier + * Bits 4-0 are the Peripheral Device Type + */ + uchar_t inq_dtype; + + /* byte 1 */ + uchar_t inq_qual : 7, /* device type qualifier */ + inq_rmb : 1; /* removable media */ + + /* byte 2 */ + uchar_t inq_ansi : 3, /* ANSI version */ + inq_ecma : 3, /* ECMA version */ + inq_iso : 2; /* ISO version */ + + /* byte 3 */ + uchar_t inq_rdf : 4, /* response data format */ + inq_hisup : 1, /* hierarchical addressing model */ + inq_normaca : 1, /* setting NACA bit supported */ + inq_trmiop : 1, /* DEPRECATED: terminate I/O proc */ + inq_aenc : 1; /* DEPRECATED: async event notify */ + + /* bytes 4-7 */ + uchar_t inq_len; /* additional length */ + + uchar_t inq_protect : 1, /* supports protection information */ + inq_5_1 : 1, + inq_5_2 : 1, + inq_3pc : 1, /* third-party copy */ + inq_tpgs : 2, /* impl/expl asymmetric lun access */ + inq_acc : 1, /* access controls coordinator */ + inq_sccs : 1; /* embedded storage array */ + + uchar_t inq_addr16 : 1, /* SPI: 16-bit wide SCSI addr */ + inq_addr32 : 1, /* DEPRECATED: 32 bit wide address */ + inq_ackqreqq : 1, /* DEPRECATED: data xfer on Q cable */ + inq_mchngr : 1, /* DEPRECATED: embeded medium changer */ + inq_dualp : 1, /* multi port device */ + inq_port : 1, /* DEPRECATED: port rcv inquiry cmd */ + inq_encserv : 1, /* embedded enclosure services */ + inq_bque : 1; /* DEPRECATED: combined with cmdque */ + + uchar_t inq_sftre : 1, /* DEPRECATED: Soft Reset option */ + inq_cmdque : 1, /* supports command queueing */ + inq_trandis : 1, /* DEPRECATED: transfer disable msgs */ + inq_linked : 1, /* DEPRECATED: linked commands */ + inq_sync : 1, /* SPI: synchronous data xfers */ + inq_wbus16 : 1, /* SPI: 16-bit wide data xfers */ + inq_wbus32 : 1, /* DEPRECATED: 32 bit wide data xfers */ + inq_reladdr : 1; /* DEPRECATED: relative addressing */ + + /* bytes 8-35 */ + char inq_vid[8]; /* vendor ID */ + char inq_pid[16]; /* product ID */ + char inq_revision[4]; /* revision level */ + + /* + * Bytes 36-47 are reserved: + * For Sun qualified hard disk drives the inq_serial field contains + * two bytes of mfg date year code (ascii) + * two bytes of mfg date week code (ascii) + * six bytes of mfg serial number (ascii) + * two bytes unused + */ + char inq_serial[12]; + + /* + * Bytes 48-55 are reserved. + */ + uchar_t __inq_48 : 8; + uchar_t __inq_49 : 8; + uchar_t __inq_50 : 8; + uchar_t __inq_51 : 8; + uchar_t __inq_52 : 8; + uchar_t __inq_53 : 8; + uchar_t __inq_54 : 8; + uchar_t __inq_55 : 8; + + /* + * The meanings of byte 56 is specific to SPI-3. For protocols older + * or other than this these fields are reserved. + */ + uchar_t inq_ius : 1, /* SPI3: information units */ + inq_qas : 1, /* SPI3: quick arb sel */ + inq_clk : 2, /* SPI3: clocking */ + __inq_56_4 : 1, /* reserved */ + __inq_56_5 : 1, /* reserved */ + __inq_56_6 : 1, /* reserved */ + __inq_56_7 : 1; /* reserved */ + + uchar_t __inq_57 : 8; /* reserved */ + + /* + * byte pairs 58-73 are version descriptors + * See: Table 51: dpANS SCSI Primary Commands - 2 (SPC-2) T10/1236 + */ + struct inq_vd { + uchar_t inq_vd_msb; + uchar_t inq_vd_lsb; + } inq_vd[8]; + + /* + * Bytes 74-95 are reserved. + * 96 to 'n' are vendor-specific parameter bytes. + * + * Pad structure to 132 bytes so that access to some vendor-specific + * data is possible via scsi_device(9S) sd_inq (for mpxio). + */ + uchar_t __inq_74_127[132 - 74]; +}; + +#elif defined(_BIT_FIELDS_HTOL) + +struct scsi_inquiry { + /* + * byte 0 + * + * Bits 7-5 are the Peripheral Device Qualifier + * Bits 4-0 are the Peripheral Device Type + */ + uchar_t inq_dtype; + + /* byte 1 */ + uchar_t inq_rmb : 1, /* removable media */ + inq_qual : 7; /* device type qualifier */ + + /* byte 2 */ + uchar_t inq_iso : 2, /* ISO version */ + inq_ecma : 3, /* ECMA version */ + inq_ansi : 3; /* ANSI version */ + + /* byte 3 */ + uchar_t inq_aenc : 1, /* DEPRECATED: async event notify */ + inq_trmiop : 1, /* DEPRECATED: terminate I/O proc */ + inq_normaca : 1, /* setting NACA bit supported */ + inq_hisup : 1, /* hierarchical addressing model */ + inq_rdf : 4; /* response data format */ + + /* bytes 4-7 */ + uchar_t inq_len; /* additional length */ + + uchar_t inq_sccs : 1, /* embedded storage array */ + inq_acc : 1, /* access controls coordinator */ + inq_tpgs : 2, /* impl/expl asymmetric lun access */ + inq_3pc : 1, /* third-party copy */ + inq_5_2 : 1, + inq_5_1 : 1, + inq_protect : 1; /* supports protection information */ + + uchar_t inq_bque : 1, /* DEPRECATED: combined with cmdque */ + inq_encserv : 1, /* embedded enclosure services */ + inq_port : 1, /* DEPRECATED: port rcv inquiry cmd */ + inq_dualp : 1, /* multi port device */ + inq_mchngr : 1, /* DEPRECATED: embeded medium changer */ + inq_ackqreqq : 1, /* DEPRECATED: data xfer on Q cable */ + inq_addr32 : 1, /* DEPRECATED: 32 bit wide address */ + inq_addr16 : 1; /* SPI: 16-bit wide SCSI addr */ + + uchar_t inq_reladdr : 1, /* DEPRECATED: relative addressing */ + inq_wbus32 : 1, /* DEPRECATED: 32 bit wide data xfers */ + inq_wbus16 : 1, /* SPI: 16-bit wide data xfers */ + inq_sync : 1, /* SPI: synchronous data xfers */ + inq_linked : 1, /* DEPRECATED: linked commands */ + inq_trandis : 1, /* DEPRECATED: transfer disable msgs */ + inq_cmdque : 1, /* supports command queueing */ + inq_sftre : 1; /* DEPRECATED: Soft Reset option */ + + /* bytes 8-35 */ + char inq_vid[8]; /* vendor ID */ + char inq_pid[16]; /* product ID */ + char inq_revision[4]; /* revision level */ + + /* + * Bytes 36-47 are reserved: + * For Sun qualified hard disk drives the inq_serial field contains + * two bytes of mfg date year code (ascii) + * two bytes of mfg date week code (ascii) + * six bytes of mfg serial number (ascii) + * two bytes unused + */ + char inq_serial[12]; + + /* + * Bytes 48-55 are reserved. + */ + uchar_t __inq_48 : 8; + uchar_t __inq_49 : 8; + uchar_t __inq_50 : 8; + uchar_t __inq_51 : 8; + uchar_t __inq_52 : 8; + uchar_t __inq_53 : 8; + uchar_t __inq_54 : 8; + uchar_t __inq_55 : 8; + + /* + * The meanings of byte 56 is specific to SPI-3. For protocols older + * or other than this these fields are reserved. + */ + uchar_t __inq_56_7 : 1, /* reserved */ + __inq_56_6 : 1, /* reserved */ + __inq_56_5 : 1, /* reserved */ + __inq_56_4 : 1, /* reserved */ + inq_clk : 2, /* SPI3: clocking */ + inq_qas : 1, /* SPI3: quick arb sel */ + inq_ius : 1; /* SPI3: information units */ + + uchar_t __inq_57 : 8; /* reserved */ + + /* + * byte pairs 58-73 are version descriptors + * See: Table 51: dpANS SCSI Primary Commands - 2 (SPC-2) T10/1236 + */ + struct inq_vd { + uchar_t inq_vd_msb; + uchar_t inq_vd_lsb; + } inq_vd[8]; + + /* + * Bytes 74-95 are reserved. + * 96 to 'n' are vendor-specific parameter bytes. + * + * Pad structure to 132 bytes so that access to some vendor-specific + * data is possible via scsi_device(9S) sd_inq (for mpxio). + */ + uchar_t __inq_74_127[132 - 74]; +}; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + +/* + * Defined Peripheral Device Types + */ +#define DTYPE_DIRECT 0x00 /* magnetic disk */ +#define DTYPE_SEQUENTIAL 0x01 /* magnetic tape */ +#define DTYPE_PRINTER 0x02 +#define DTYPE_PROCESSOR 0x03 +#define DTYPE_WORM 0x04 /* some optical disks */ +#define DTYPE_RODIRECT 0x05 +#define DTYPE_SCANNER 0x06 /* obsolete */ +#define DTYPE_OPTICAL 0x07 +#define DTYPE_CHANGER 0x08 /* jukeboxes */ +#define DTYPE_COMM 0x09 /* obsolete */ +#define DTYPE_ARRAY_CTRL 0x0C +#define DTYPE_ESI 0x0D /* Enclosure services device */ +#define DTYPE_RBC 0x0E /* Simplified direct-access device */ +#define DTYPE_OCRW 0x0F /* Optical card reader/writer device */ +#define DTYPE_BCC 0x10 +#define DTYPE_OSD 0x11 /* Object-based Storage Device */ +#define DTYPE_ADC 0x12 +/* + * Device types 0x13-0x1D are reserved in spc-3 (r23) + */ + +#define DTYPE_WELLKNOWN 0x1E +#define DTYPE_UNKNOWN 0x1F +#define DTYPE_MASK 0x1F + +/* ASCII mapping used by scsi_dname(9F) */ +#define DTYPE_ASCII { \ + "Direct Access", "Sequential Access", "Printer", "Processor", \ + "Write-Once/Read-Many", "Read-Only Direct Access", "Scanner", \ + "Optical", "Changer", "Communications", "Unknown-0A", \ + "Unknown-0B", "Array Controller", "Enclosure-Services", \ + "Simplified-Direct-Access", "Optical-Card", "Bridge", \ + "Object-Storage", NULL} + +/* + * The peripheral qualifier tells us more about a particular device. + * (DPQ == DEVICE PERIPHERAL QUALIFIER). + */ +#define DPQ_MASK 0x60 /* DPQ bits */ +#define DPQ_POSSIBLE 0x00 + /* + * The specified peripheral device type is + * currently connected to this logical unit. + * If the target cannot determine whether + * or not a physical device is currently + * connected, it shall also return this + * qualifier. + */ +#define DPQ_SUPPORTED 0x20 + /* + * The target is capable of supporting the + * specified peripheral device type on this + * logical unit, however the physical device + * is not currently connected to this logical + * unit. + */ +#define DPQ_NEVER 0x60 + /* + * The target is not capable of supporting a + * physical device on this logical unit. For + * this peripheral qualifier, the peripheral + * device type will be set to DTYPE_UNKNOWN + * in order to provide compatibility with + * previous versions of SCSI. + */ +#define DPQ_VUNIQ 0x80 + /* + * If this bit is set, this is a vendor + * unique qualifier. + */ + +/* + * To maintain compatibility with previous versions + * of inquiry data formats, if a device peripheral + * qualifier states that the target is not capable + * of supporting a physical device on this logical unit, + * then the qualifier DPQ_NEVER is set, *AND* the + * actual device type must be set to DTYPE_UNKNOWN. + * + * This may make for some problems with older drivers + * that blindly check the entire first byte, where they + * should be checking for only the least 5 bits to see + * whether the correct type is at the specified nexus. + */ +#define DTYPE_NOTPRESENT (DPQ_NEVER | DTYPE_UNKNOWN) + +/* + * Defined Versions for inquiry data. These represent the base version that a + * device supports. + */ +#define RDF_LEVEL0 0x00 /* no conformance claim (SCSI-1) */ +#define RDF_CCS 0x01 /* Obsolete (pseudo-spec) */ +#define RDF_SCSI2 0x02 /* Obsolete (SCSI-2/3 spec) */ +#define RDF_SCSI_SPC 0x03 /* ANSI INCITS 301-1997 (SPC) */ +#define RDF_SCSI_SPC2 0x04 /* ANSI INCITS 351-2001 (SPC-2) */ +#define RDF_SCSI_SPC3 0x05 /* ANSI INCITS 408-2005 (SPC-3) */ +#define RDF_SCSI_SPC4 0x06 /* ANSI INCITS 513-2015 (SPC-4) */ +#define RDF_SCSI_SPC5 0x07 /* t10 (SPC-5) */ + +/* + * Defined Target Port Group Select values: + */ +#define TPGS_FAILOVER_NONE 0x0 +#define TPGS_FAILOVER_IMPLICIT 0x1 +#define TPGS_FAILOVER_EXPLICIT 0x2 +#define TPGS_FAILOVER_BOTH 0x3 + +/* + * SPC-3 revision 21c, section 7.6.4.1 + * Table 289 -- Device Identification VPD page + */ +struct vpd_hdr { +#if defined(_BIT_FIELDS_LTOH) + uchar_t device_type : 4, + periph_qual : 4; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t periph_qual : 4, + device_type : 4; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif + uchar_t page_code, + page_len[2]; +}; + +/* + * SPC-3 revision 21c, section 7.6.4.1 + * Table 290 -- Identification descriptor + */ +struct vpd_desc { +#if defined(_BIT_FIELDS_LTOH) + uchar_t code_set : 4, + proto_id : 4; + uchar_t id_type : 4, + association : 2, + : 1, + piv : 1; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t proto_id : 4, + code_set : 4; + uchar_t piv : 1, + : 1, + association : 2, + id_type : 4; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif + uchar_t resrv1; + uchar_t len; + /* ---- data follows ---- */ +}; + +/* + * "pm-capable" integer property bit mask definitions + */ +#define PM_CAPABLE_PM_MASK 0x0000ffff /* use lower 16 bits to */ + /* indicate PM mode */ +#define PM_CAPABLE_CCS RDF_CCS +#define PM_CAPABLE_SCSI2 RDF_SCSI2 +#define PM_CAPABLE_SPC RDF_SCSI_SPC +#define PM_CAPABLE_SPC2 RDF_SCSI_SPC2 +#define PM_CAPABLE_SPC3 RDF_SCSI_SPC3 +#define PM_CAPABLE_SPC4 RDF_SCSI_SPC4 +#define PM_CAPABLE_SPC5 RDF_SCSI_SPC5 +#define PM_CAPABLE_LOG_MASK 0xffff0000 /* use upper 16 bit to */ + /* indicate log specifics */ +#define PM_CAPABLE_LOG_SUPPORTED 0x10000 /* Log page 0xE might be */ + /* supported */ +#define PM_CAPABLE_SMART_LOG 0x20000 /* Log page 0xE reports SMART */ + /* attributes instead of the */ + /* default SCSI Log pages */ +#ifdef __cplusplus +} +#endif + +/* + * Include in implementation specifuc + * (non-generic) inquiry definitions. + */ + +#include + +#endif /* _SYS_SCSI_GENERIC_INQUIRY_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/message.h b/illumos-x86_64/usr/include/sys/scsi/generic/message.h new file mode 100644 index 00000000..9abbd0d0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/message.h @@ -0,0 +1,178 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996,2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SCSI_GENERIC_MESSAGE_H +#define _SYS_SCSI_GENERIC_MESSAGE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Defined Messages For Parallel SCSI. + */ + +/* + * The SCSI specification defines message codes 0x00, 0x02-0x1F, + * as fixed single byte messages, 0x01 as indicating extended (multi-byte) + * messages, 0x20-0x2F as fixed two byte messages, and 0x80-0xFF + * as IDENTIFY messages. + */ + +#define MSG_COMMAND_COMPLETE 0x00 +#define MSG_SAVE_DATA_PTR 0x02 +#define MSG_RESTORE_PTRS 0x03 +#define MSG_DISCONNECT 0x04 +#define MSG_INITIATOR_ERROR 0x05 +#define MSG_ABORT 0x06 +#define MSG_REJECT 0x07 +#define MSG_NOP 0x08 +#define MSG_MSG_PARITY 0x09 +#define MSG_LINK_CMPLT 0x0A +#define MSG_LINK_CMPLT_FLAG 0x0B +#define MSG_DEVICE_RESET 0x0C +#define MSG_ABORT_TAG 0x0D +#define MSG_CLEAR_QUEUE 0x0E +#define MSG_INITIATE_RECOVERY 0x0F +#define MSG_RELEASE_RECOVERY 0x10 +#define MSG_TERMINATE_PROCESS 0x11 +#define MSG_CONTINUE_TASK 0x12 +#define MSG_TARGET_TRAN_DIS 0x13 +#define MSG_CLEAR_ACA 0x16 + + +/* + * Message code 0x01 indicates an extended + * (two or more) byte message. The EXTENDED + * message byte is followed immediately by + * a message length byte and then an extended + * message code byte. + * + * Note: The EXTENDED IDENTIFY message is pre-SCSI-2. + */ + +#define MSG_EXTENDED 0x01 + +#define MSG_MODIFY_DATA_PTR 0x00 +#define MSG_SYNCHRONOUS 0x01 +#define MSG_IDENTIFY_EXTENDED 0x02 +#define MSG_WIDE_DATA_XFER 0x03 +#define MSG_PARALLEL_PROTOCOL 0x04 + +/* + * parallel protocol message optional flags + */ +#define OPT_IU 0x01 +#define OPT_DT 0x02 +#define OPT_QAS_REQ 0x04 + +/* + * Message codes 0x20-0x2F are fixed two byte messages. + */ + + +#define MSG_SIMPLE_QTAG 0x20 +#define MSG_HEAD_QTAG 0x21 +#define MSG_ORDERED_QTAG 0x22 +#define MSG_IGNORE_WIDE_RESID 0x23 +#define MSG_ACA 0x24 +#define MSG_LUN_RESET 0x25 + +/* + * Codes 0x80-0xFF are identify messages, indicated + * by the setting of the most significant bit in the + * message (0x80). + */ + +#define MSG_IDENTIFY 0x80 + +/* + * Initiators will set bit 6 in an Identify message + * to indicate whether or not they can accommodate + * disconnect/reconnect + */ + +#define INI_CAN_DISCON 0x40 + +/* + * ..so we can have a compound definition + * for Initiators that can accommodate + * disconnect/reconnect + */ + +#define MSG_DR_IDENTIFY (MSG_IDENTIFY|INI_CAN_DISCON) + +/* + * Note: Following is ONLY applicable to pre-SCSI-3. + * + * Bit 5 of the identify message specifies that, if zero, + * that the IDENTIFY message is directed to a logical unit, + * and if one, that the IDENTIFY message is directed to a + * target routine that does not involve a logical unit. + */ + +#define MSG_LUNTAR 0x20 + +/* + * Note: Following is ONLY applicable to pre-SCSI-3. + * + * Bits 2-0 identify either the logical unit or the target + * routine number based upon whether MSG_LUNTAR is clear + * or set. + */ + +#define MSG_LUNRTN 0x07 + +/* + * Note: Following is ONLY applicable to pre-SCSI-3. + * + * Bits 4-3 are reserved and must be zero. + */ + +#define BAD_IDENTIFY 0x18 + +/* + * These macros may be useful to quickly determine the + * length of a message based upon the message code. + */ + +/* + * Note: IS_IDENTIFY_MSG is ONLY applicable to pre-SCSI-3. + * For SCSI-3, use IS_IDENTIFY_MSG_SCSI3. + */ +#define IS_IDENTIFY_MSG(msg) \ + (((msg) & MSG_IDENTIFY) && !((msg) & BAD_IDENTIFY)) +#define IS_IDENTIFY_MSG_SCSI3(msg) ((msg) & MSG_IDENTIFY) +#define IS_EXTENDED_MSG(msg) ((msg) == MSG_EXTENDED) +#define IS_2BYTE_MSG(msg) (((msg) & 0xF0) == 0x20) +#define IS_1BYTE_MSG(msg) (!(IS_EXTENDED_MSG((msg))) && \ + ((((msg) & 0xF0) == 0) || IS_IDENTIFY_MSG((msg)))) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_GENERIC_MESSAGE_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/mode.h b/illumos-x86_64/usr/include/sys/scsi/generic/mode.h new file mode 100644 index 00000000..b2e1d925 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/mode.h @@ -0,0 +1,511 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Nexenta Systems, Inc. + */ + +#ifndef _SYS_SCSI_GENERIC_MODE_H +#define _SYS_SCSI_GENERIC_MODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * Defines and Structures for SCSI Mode Sense/Select data - generic + * + */ + +/* + * Structures and defines common for all device types + */ + +/* + * Mode Sense/Select Header - Group 0 (6-byte). + * + * Mode Sense/Select data consists of a header, followed by zero or more + * block descriptors, followed by zero or more mode pages. + * + */ + +struct mode_header { + uchar_t length; /* number of bytes following */ + uchar_t medium_type; /* device specific */ + uchar_t device_specific; /* device specific parameters */ + uchar_t bdesc_length; /* length of block descriptor(s), if any */ +}; + +#define MODE_HEADER_LENGTH (sizeof (struct mode_header)) + +/* + * Mode Sense/Select Header - Group 1 (10-bytes) + */ + +struct mode_header_g1 { + ushort_t length; /* number of bytes following */ + uchar_t medium_type; /* device specific */ + uchar_t device_specific; /* device specific parameters */ + uchar_t reserved[2]; /* device specific parameters */ + ushort_t bdesc_length; /* len of block descriptor(s), if any */ +}; + +#define MODE_HEADER_LENGTH_G1 (sizeof (struct mode_header_g1)) + +/* + * Block Descriptor. Zero, one, or more may normally follow the mode header. + * + * The density code is device specific. + * + * The 24-bit value described by blks_{hi, mid, lo} describes the number of + * blocks which this block descriptor applies to. A value of zero means + * 'the rest of the blocks on the device'. + * + * The 24-bit value described by blksize_{hi, mid, lo} describes the blocksize + * (in bytes) applicable for this block descriptor. For Sequential Access + * devices, if this value is zero, the block size will be derived from + * the transfer length in I/O operations. + * + */ + +struct block_descriptor { + uchar_t density_code; /* device specific */ + uchar_t blks_hi; /* hi */ + uchar_t blks_mid; /* mid */ + uchar_t blks_lo; /* low */ + uchar_t reserved; /* reserved */ + uchar_t blksize_hi; /* hi */ + uchar_t blksize_mid; /* mid */ + uchar_t blksize_lo; /* low */ +}; + +#define MODE_BLK_DESC_LENGTH (sizeof (struct block_descriptor)) +#define MODE_PARAM_LENGTH (MODE_HEADER_LENGTH + MODE_BLK_DESC_LENGTH) + +/* + * Define a macro to take an address of a mode header to the address + * of the nth (0..n) block_descriptor, or NULL if there either aren't any + * block descriptors or the nth block descriptor doesn't exist. + */ + +#define BLOCK_DESCRIPTOR_ADDR(mhdr, bdnum) \ + ((mhdr)->bdesc_length && ((unsigned)(bdnum)) < \ + ((mhdr)->bdesc_length/(sizeof (struct block_descriptor)))) ? \ + ((struct block_descriptor *)(((ulong_t)(mhdr))+MODE_HEADER_LENGTH+ \ + ((bdnum) * sizeof (struct block_descriptor)))) : \ + ((struct block_descriptor *)0) + +/* + * Mode page header. Zero or more Mode Pages follow either the block + * descriptors (if any), or the Mode Header. + * + * The 'ps' bit must be zero for mode select operations. + * + */ + +struct mode_page { +#if defined(_BIT_FIELDS_LTOH) + uchar_t code :6, /* page code number */ + :1, /* reserved */ + ps :1; /* 'Parameter Saveable' bit */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t ps :1, /* 'Parameter Saveable' bit */ + :1, /* reserved */ + code :6; /* page code number */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t length; /* length of bytes to follow */ + /* + * Mode Page specific data follows right after this... + */ +}; + +/* + * Define a macro to retrieve the first mode page. Could be more + * general (for multiple mode pages). + */ + +#define MODE_PAGE_ADDR(mhdr, type) \ + ((type *)(((ulong_t)(mhdr))+MODE_HEADER_LENGTH+(mhdr)->bdesc_length)) + +/* + * Page Control field (bits 7 and 6) follows the following specification: + * + * Value Meaning + * ---------------------------------------------------------------------- + * 00b current values + * 01b changeable values + * 10b default values + * 11b saved values + */ + +#define MODEPAGE_CURRENT 0x00 +#define MODEPAGE_CHANGEABLE 0x40 +#define MODEPAGE_DEFAULT 0x80 +#define MODEPAGE_SAVED 0xC0 + +/* + * Page codes follow the following specification: + * + * Code Value(s) What + * ---------------------------------------------------------------------- + * 0x00 Vendor Unique (does not require page format) + * + * 0x02, 0x09, 0x0A pages for all Device Types + * 0x1A, 0x1C + * + * 0x01, 0x03-0x08, pages for specific Device Type + * 0x0B-0x19, 0x1B, + * 0x1D-0x1F + * + * 0x20-0x3E Vendor Unique (requires page format) + * + * 0x3F Return all pages (valid for Mode Sense only) + * + */ + +/* + * Page codes and page length values (all device types) + */ + +#define MODEPAGE_DISCO_RECO 0x02 +#define MODEPAGE_FORMAT 0x03 +#define MODEPAGE_GEOMETRY 0x04 +#define MODEPAGE_CACHING 0x08 +#define MODEPAGE_PDEVICE 0x09 +#define MODEPAGE_CTRL_MODE 0x0A +#define MODEPAGE_POWER_COND 0x1A +#define MODEPAGE_INFO_EXCPT 0x1C + +#define MODEPAGE_ALLPAGES 0x3F + +/* + * Mode Select/Sense page structures (for all device types) + */ + +/* + * Disconnect/Reconnect Page + */ + +struct mode_disco_reco { + struct mode_page mode_page; /* common mode page header */ + uchar_t buffer_full_ratio; /* write, how full before reconnect? */ + uchar_t buffer_empty_ratio; /* read, how full before reconnect? */ + ushort_t bus_inactivity_limit; /* how much bus quiet time for BSY- */ + ushort_t disconect_time_limit; /* min to remain disconnected */ + ushort_t connect_time_limit; /* min to remain connected */ + ushort_t max_burst_size; /* max data burst size */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t dtdc : 3, /* data transfer disconenct control */ + dimm : 1, /* disconnect immediate */ + fastat : 1, /* fair for status */ + fawrt : 1, /* fair for write */ + fard : 1, /* fair for read */ + emdp : 1; /* enable modify data pointers */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t emdp : 1, /* enable modify data pointers */ + fard : 1, /* fair for read */ + fawrt : 1, /* fair for write */ + fastat : 1, /* fair for status */ + dimm : 1, /* disconnect immediate */ + dtdc : 3; /* data transfer disconenct control */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t reserved; + ushort_t first_burst_sz; /* first burst size */ +}; + +#define DTDC_DATADONE 0x01 + /* + * Target may not disconnect once + * data transfer is started until + * all data successfully transferred. + */ + +#define DTDC_CMDDONE 0x03 + /* + * Target may not disconnect once + * data transfer is started until + * command completed. + */ +/* + * Caching Page + */ + +struct mode_caching { + struct mode_page mode_page; /* common mode page header */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t rcd : 1, /* Read Cache Disable */ + mf : 1, /* Multiplication Factor */ + wce : 1, /* Write Cache Enable */ + : 5; /* Reserved */ + uchar_t write_ret_prio : 4, /* Write Retention Priority */ + dmd_rd_ret_prio : 4; /* Demand Read Retention Priority */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t : 5, /* Reserved */ + wce : 1, /* Write Cache Enable */ + mf : 1, /* Multiplication Factor */ + rcd : 1; /* Read Cache Disable */ + uchar_t dmd_rd_ret_prio : 4, /* Demand Read Retention Priority */ + write_ret_prio : 4; /* Write Retention Priority */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + ushort_t pf_dsbl_trans_len; /* Disable prefetch transfer length */ + ushort_t min_prefetch; /* Minimum Prefetch */ + ushort_t max_prefetch; /* Maximum Prefetch */ + ushort_t max_prefetch_ceiling; /* Maximum Prefetch Ceiling */ +}; + +/* + * Peripheral Device Page + */ + +struct mode_pdevice { + struct mode_page mode_page; /* common mode page header */ + ushort_t if_ident; /* interface identifier */ + uchar_t reserved[4]; /* reserved */ + uchar_t vendor_uniqe[1]; /* vendor unique data */ +}; + +#define PDEV_SCSI 0x0000 /* scsi interface */ +#define PDEV_SMD 0x0001 /* SMD interface */ +#define PDEV_ESDI 0x0002 /* ESDI interface */ +#define PDEV_IPI2 0x0003 /* IPI-2 interface */ +#define PDEV_IPI3 0x0004 /* IPI-3 interface */ + +/* + * Control Mode Page + * + * Note: This structure is incompatible with previous SCSI + * implementations. See for an + * alternative form of this structure. They can be + * distinguished by the length of data returned + * from a MODE SENSE command. + */ + +#define PAGELENGTH_MODE_CONTROL_SCSI3 0x0A + +struct mode_control_scsi3 { + struct mode_page mode_page; /* common mode page header */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t rlec : 1, /* Report Log Exception bit */ + gltsd : 1, /* global logging target save disable */ + d_sense : 1, /* Use descriptor sense data (SPC-3) */ + : 5; + uchar_t qdisable: 1, /* Queue disable */ + que_err : 1, /* Queue error */ + : 2, + que_mod : 4; /* Queue algorithm modifier */ + uchar_t eanp : 1, /* Enable AEN permission */ + uaaenp : 1, /* Unit attention AEN permission */ + raenp : 1, /* Ready AEN permission */ + : 1, + bybths : 1, /* By both RESET signal */ + byprtm : 1, /* By port message */ + rac : 1, /* report a check */ + eeca : 1; /* enable extended contingent */ + /* allegiance (only pre-SCSI-3) */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t : 5, + d_sense : 1, /* Use descriptor sense data (SPC-3) */ + gltsd : 1, /* global logging target save disable */ + rlec : 1; /* Report Log Exception bit */ + uchar_t que_mod : 4, /* Queue algorithm modifier */ + : 2, + que_err : 1, /* Queue error */ + qdisable: 1; /* Queue disable */ + uchar_t eeca : 1, /* enable extended contingent */ + /* allegiance (only pre-SCSI-3) */ + rac : 1, /* report a check */ + byprtm : 1, /* By port message */ + bybths : 1, /* By both RESET signal */ + : 1, + raenp : 1, /* Ready AEN permission */ + uaaenp : 1, /* Unit attention AEN permission */ + eanp : 1; /* Enable AEN permission */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t reserved; + ushort_t ready_aen_holdoff; /* Ready AEN holdoff period */ + ushort_t busy_timeout; /* Busy timeout period */ + uchar_t reserved_2[2]; +}; + +#ifdef __lock_lint +_NOTE(SCHEME_PROTECTS_DATA("Unshared SCSI payload", \ + mode_control_scsi3)) +#endif + +#define CTRL_QMOD_RESTRICT 0x0 +#define CTRL_QMOD_UNRESTRICT 0x1 + +/* + * Informational Exceptions Control Mode Page + */ + +#define PAGELENGTH_INFO_EXCPT 0x0A + +struct mode_info_excpt_page { + struct mode_page mode_page; /* common mode page header */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t log_err : 1; /* log errors */ + uchar_t : 1; /* reserved */ + uchar_t test : 1; /* create test failure */ + uchar_t dexcpt : 1; /* disable exception */ + uchar_t ewasc : 1; /* enable warning */ + uchar_t ebf : 1; /* enable background function */ + uchar_t : 1; /* reserved */ + uchar_t perf : 1; /* performance */ + uchar_t mrie : 4; /* method of reporting info. excpts. */ + uchar_t : 4; /* reserved */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t perf : 1; /* performance */ + uchar_t : 1; /* reserved */ + uchar_t ebf : 1; /* enable background function */ + uchar_t ewasc : 1; /* enable warning */ + uchar_t dexcpt : 1; /* disable exception */ + uchar_t test : 1; /* create test failure */ + uchar_t : 1; /* reserved */ + uchar_t log_err : 1; /* log errors */ + uchar_t : 4; /* reserved */ + uchar_t mrie : 4; /* method of reporting info. excpts. */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif + uchar_t interval_timer[4]; /* interval timer */ + uchar_t report_count[4]; /* report count */ +}; + +#define MRIE_NO_REPORT 0x0 +#define MRIE_ASYNCH 0x1 +#define MRIE_UNIT_ATTN 0x2 +#define MRIE_COND_RECVD_ERR 0x3 +#define MRIE_UNCOND_RECVD_ERR 0x4 +#define MRIE_NO_SENSE 0x5 +#define MRIE_ONLY_ON_REQUEST 0x6 + +struct mode_info_power_cond { + struct mode_page mode_page; /* common mode page header */ + uchar_t reserved; +#if defined(_BIT_FIELDS_LTOH) + uchar_t standby :1, /* standby bit */ + idle :1, /* idle bit */ + :6; /* reserved */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t :6, /* reserved */ + idle :1, /* idle bit */ + standby :1; /* standby bit */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif + uchar_t idle_cond_timer_high; + uchar_t idle_cond_timer_low; + uchar_t standby_cond_timer[4]; +}; + +struct parameter_control { +#if defined(_BIT_FIELDS_LTOH) + uchar_t fmt_link:2, /* format and link bit */ + tmc :2, /* tmc bit */ + etc :1, /* etc bit */ + tsd :1, /* tsd bit */ + reserv :1, /* obsolete */ + du :1; /* du bit */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t du :1, /* du bit */ + reserv :1, /* obsolete */ + tsd :1, /* tsd bit */ + etc :1, /* etc bit */ + tmc :2, /* tmc bit */ + fmt_link:2; /* format and link bit */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif +}; + +struct start_stop_cycle_counter_log { +#if defined(_BIT_FIELDS_LTOH) + uchar_t code :6, /* page code bit */ + spf :1, /* spf bit */ + ds :1; /* ds bit */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t ds :1, /* ds bit */ + spf :1, /* spf bit */ + code :6; /* page code bit */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif + uchar_t sub_page_code; + uchar_t page_len_high; + uchar_t page_len_low; + + uchar_t manufactor_date_high; + uchar_t manufactor_date_low; + struct parameter_control param_1; + uchar_t param_len_1; + uchar_t year_manu[4]; + uchar_t week_manu[2]; + + uchar_t account_date_high; + uchar_t account_date_low; + struct parameter_control param_2; + uchar_t param_len_2; + uchar_t year_account[4]; + uchar_t week_account[2]; + + uchar_t lifetime_code_high; + uchar_t lifetime_code_low; + struct parameter_control param_3; + uchar_t param_len_3; + uchar_t cycle_lifetime[4]; + + uchar_t cycle_code_high; + uchar_t cycle_code_low; + struct parameter_control param_4; + uchar_t param_len_4; + uchar_t cycle_accumulated[4]; +}; + + +#ifdef __cplusplus +} +#endif + +/* + * Include known generic device specific mode definitions and structures + */ + +#include + +/* + * Include implementation specific mode information + */ + +#include + +#endif /* _SYS_SCSI_GENERIC_MODE_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/persist.h b/illumos-x86_64/usr/include/sys/scsi/generic/persist.h new file mode 100644 index 00000000..2e5a11cc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/persist.h @@ -0,0 +1,519 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_SCSI_GENERIC_PERSIST_H +#define _SYS_SCSI_GENERIC_PERSIST_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SCSI Persistence Data + * + * Format of data returned as a result of PERSISTENCE RESERVER { IN | OUT } + */ + +/* + * SPC-3 revision 23, Section 6.11.1, Table 102 + * Persistent Reservations + * Persistent Reserve In service actions + */ +#define PR_IN_READ_KEYS 0x0 /* Read all registered reservation keys */ +#define PR_IN_READ_RESERVATION 0x1 /* Reads th persistent reservations */ +#define PR_IN_REPORT_CAPABILITIES 0x2 /* Returns capability information */ +#define PR_IN_READ_FULL_STATUS 0x3 /* Reads complete information about all */ + /* registrations and the persistent */ + /* reservations, if any */ +/* + * SPC-3 revision 23, Section 6.11.3.3, Table 106 + * Persistent reservation scope codes + */ +#define PR_LU_SCOPE 0x0 /* Persistent reservation applies to */ + /* full logical unit */ +/* + * SPC-3 revision 23, Section 6.11.3.4, Table 107 + * Persistent Reservations + * Persistent reservation type codes + */ +#define PGR_TYPE_WR_EX 0x1 /* Write Exclusive */ +#define PGR_TYPE_EX_AC 0x3 /* Exclusive Access */ +#define PGR_TYPE_WR_EX_RO 0x5 /* Write Exclusive, Registrants Only */ +#define PGR_TYPE_EX_AC_RO 0x6 /* Exclusive Access, Registrants Only */ +#define PGR_TYPE_WR_EX_AR 0x7 /* Write Exclusive, All Registrants */ +#define PGR_TYPE_EX_AC_AR 0x8 /* Exclusive Access, All Registrants */ + +/* + * SPC-3 revision 23, Section 6.12.2, Table 113 + * Persistent Reservations + * Persistent Reserve Out service action codes + */ +#define PR_OUT_REGISTER 0x0 /* Register/unregister a reservation */ + /* key with the device server */ +#define PR_OUT_RESERVE 0x1 /* Create a persistent reservation */ + /* having a specified SCOPE & TYPE */ +#define PR_OUT_RELEASE 0x2 /* Release the selected persistent */ + /* reservation */ +#define PR_OUT_CLEAR 0x3 /* Clears all reservation keys and */ + /* all persistent reservations */ +#define PR_OUT_PREEMPT 0x4 /* Preempts persistent reservations */ + /* and/or removes reservations */ +#define PR_OUT_PREEMPT_ABORT 0x5 /* Preempts persistent reservations */ + /* and/or removes reservations, and */ + /* aborts all tasks for all preempted */ + /* I_T nexuses */ +#define PR_OUT_REGISTER_AND_IGNORE_EXISTING_KEY 0x06 + /* Register a reservation key with */ + /* the device server, or unregister a */ + /* reservation key */ +#define PR_OUT_REGISTER_MOVE 0x7 /* Register a reservation key for */ + /* another I_T nexus with the device */ + /* server and move a persistent */ + /* reservation to the I_T nexus */ + + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.5 PERSISTENCE RESERVE IN + * Table 111 - full status descriptor format + */ +/* Table 289 - iSCSI Initiator Device TransportID format */ + +#define iSCSI_PROTOCOL_ID 0x5 /* Table 262 - iSCSI Protocol ID */ +#define WW_UID_DEVICE_NAME 0x0 /* Table 288 - iSCSI Transport IDs */ + +/* + * Definitions related SCSI Transport ID + * SPC3 rev 23, Tables 284-287 + */ +#define SCSI_TPTID_SIZE 24 +#define SCSI_TPTID_FC_PORT_NAME_SIZE 8 +#define SCSI_TPTID_SPI_ADDRESS_LEN 2 +#define SCSI_TPTID_SPI_REL_TGTPTID_LEN 2 +#define SCSI_TPTID_SBP_PORT_NAME_LEN 8 +#define SCSI_TPTID_SRP_PORT_NAME_LEN 16 +#define SCSI_TPTID_ISCSI_ISID_SEPERATOR ",i,0x" + +#if defined(_BIT_FIELDS_LTOH) +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.1 PERSISTENCE RESERVE IN + * Table 101 - PERSISTENCE RESERVE IN command + */ +typedef struct scsi_cdb_prin { + uint8_t cmd; + uint8_t action : 5, + resbits : 3; + uint8_t resbytes[5]; + uint8_t alloc_len[2]; + uint8_t control; +} scsi_cdb_prin_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.2 PERSISTENCE RESERVE IN + * Table 103/104/105 - parameter data for READS KEYS + */ +typedef struct scsi_prin_rsrvdesc { + uint8_t reservation_key[8]; + uint8_t obsolete1[4]; + uint8_t resbytes; + uint8_t type : 4, + scope : 4; + uint8_t obsolete2[2]; +} scsi_prin_rsrvdesc_t; +typedef struct scsi_prin_readrsrv { + uint8_t PRgeneration[4]; + uint8_t add_len[4]; + union { + uint64_t service_key[1]; + scsi_prin_rsrvdesc_t res_key_list[1]; + } key_list; +} scsi_prin_readrsrv_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.4 PERSISTENCE RESERVE IN + * Table 108 - parameter data for REPORT CAPABILTIES + */ +typedef struct scsi_per_res_type { + uint8_t resbits1 : 1, + wr_ex : 1, + resbits2 : 1, + ex_ac : 1, + resbits3 : 1, + wr_ex_ro : 1, + ex_ac_ro : 1, + wr_ex_ar : 1; + uint8_t ex_ac_ar : 1, + resbits4 : 7; +} scsi_per_res_type_t; + +/* + * Refer SPC-3, Revision 23 + * Section 6.11.4 REPORT CAPABILITIES service action + */ +typedef struct scsi_prin_rpt_cap { + uint8_t length[2]; + uint8_t ptpl_c : 1, + resbits1 : 1, + atp_c : 1, + sip_c : 1, + crh : 1, + resbits2 : 3; + uint8_t ptpl_a : 1, + resbits3 : 6, + tmv : 1; + scsi_per_res_type_t pr_type; + uint8_t resbytes[2]; +} scsi_prin_rpt_cap_t; + +/* + * Refer SPC-3, Revision 23 + * Section 7.5.4 TransportID identifiers + */ +typedef struct scsi_transport_id { + uint8_t protocol_id : 4, + resbits : 2, + format_code : 2; + uint8_t protocol_data[1]; +} scsi_transport_id_t; + +typedef struct scsi_fc_transport_id { + uint8_t protocol_id : 4, + resbits : 2, + format_code : 2; + uint8_t rsvbytes1[7]; + uint8_t port_name[8]; + uint8_t rsvbytes2[8]; +} scsi_fc_transport_id_t; + +typedef struct iscsi_transport_id { + uint8_t protocol_id : 4, + resbits : 2, + format_code : 2; + uint8_t rsvbyte1; + uint8_t add_len[2]; + char iscsi_name[1]; +} iscsi_transport_id_t; + +typedef struct scsi_srp_transport_id { + uint8_t protocol_id : 4, + resbits : 2, + format_code : 2; + uint8_t rsvbytes1[7]; + uint8_t srp_name[16]; +} scsi_srp_transport_id_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.5 PERSISTENCE RESERVE IN + * Table 110/111 - parameter data for READ FULL STATUS + * Table 281 - TransportId format + */ + +typedef struct scsi_prin_status_t { + uint8_t reservation_key[8]; + uint8_t resbytes1[4]; + uint8_t r_holder : 1, + all_tg_pt : 1, + resbits : 6; + uint8_t type : 4, + scope : 4; + uint8_t resbytes2[4]; + uint8_t rel_tgt_port_id[2]; + uint8_t add_len[4]; + scsi_transport_id_t trans_id; +} scsi_prin_status_t; + +typedef struct scsi_prin_full_status { + uint8_t PRgeneration[4]; + uint8_t add_len[4]; + scsi_prin_status_t full_desc[1]; +} scsi_prin_full_status_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.12.1 PERSISTENCE RESERVE OUT + * Table 112 - PERSISTENCE RESERVE OUT command + */ +typedef struct scsi_cdb_prout { + uint8_t cmd; + uint8_t action : 5, + resbits : 3; + uint8_t type : 4, + scope : 4; + uint8_t resbytes[2]; + uint8_t param_len[4]; + uint8_t control; +} scsi_cdb_prout_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.12.3 PERSISTENCE RESERVE OUT + * Table 114 - PERSISTENCE RESERVE OUT parameter list + */ +typedef struct scsi_prout_plist { + uint8_t reservation_key[8]; + uint8_t service_key[8]; + uint8_t obsolete1[4]; + uint8_t aptpl : 1, + resbits1 : 1, + all_tg_pt : 1, + spec_i_pt : 1, + resbits2 : 4; + uint8_t resbytes1; + uint8_t obsolete2[2]; + uint8_t apd[1]; +} scsi_prout_plist_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.12.4 PERSISTENCE RESERVE OUT command with REGISTER AND MOVE + * Table 117 - REGISTER and MOVE service action parameter list + */ +typedef struct scsi_prout_reg_move_plist { + uint8_t reservation_key[8]; + uint8_t service_key[8]; + uint8_t resbytes1; + uint8_t aptpl : 1, + unreg : 1, + resbits1 : 6; + uint8_t rel_tgt_port_id[2]; + uint8_t tptid_len[4]; + uint8_t tptid[1]; +} scsi_prout_reg_move_plist_t; + +#elif defined(_BIT_FIELDS_HTOL) +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.1 PERSISTENCE RESERVE IN + * Table 101 - PERSISTENCE RESERVE IN command + */ +typedef struct scsi_cdb_prin { + uint8_t cmd; + uint8_t resbits : 3, + action : 5; + uint8_t resbytes[5]; + uint8_t alloc_len[2]; + uint8_t control; +} scsi_cdb_prin_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.2 PERSISTENCE RESERVE IN + * Table 103/104/105 - parameter data for READS KEYS + */ +typedef struct scsi_prin_rsrvdesc { + uint8_t reservation_key[8]; + uint8_t obsolete1[4]; + uint8_t resbytes; + uint8_t scope : 4, + type : 4; + uint8_t obsolete2[2]; +} scsi_prin_rsrvdesc_t; +typedef struct scsi_prin_readrsrv { + uint8_t PRgeneration[4]; + uint8_t add_len[4]; + union { + uint64_t service_key[1]; + scsi_prin_rsrvdesc_t res_key_list[1]; + } key_list; +} scsi_prin_readrsrv_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.4 PERSISTENCE RESERVE IN + * Table 108 - parameter data for REPORT CAPABILTIES + */ +typedef struct scsi_per_res_type { + uint8_t wr_ex_ar : 1, + ex_ac_ro : 1, + wr_ex_ro : 1, + resbits3 : 1, + ex_ac : 1, + resbits2 : 1, + wr_ex : 1, + resbits1 : 1; + uint8_t resbits4 : 7, + ex_ac_ar : 1; +} scsi_per_res_type_t; +/* + * Refer SPC-3, Revision 23 + * Section 6.11.4 REPORT CAPABILITIES service action + */ +typedef struct scsi_prin_rpt_cap { + uint8_t length[2]; + uint8_t resbits2 : 3, + crh : 1, + sip_c : 1, + atp_c : 1, + resbits1 : 1, + ptpl_c : 1; + uint8_t tmv : 1, + resbits3 : 6, + ptpl_a : 1; + scsi_per_res_type_t pr_type; + uint8_t resbytes[2]; +} scsi_prin_rpt_cap_t; + +/* + * Refer SPC-3, Revision 23 + * Section 7.5.4 TransportID identifiers + */ +typedef struct scsi_transport_id { + uint8_t format_code : 2, + resbits : 2, + protocol_id : 4; + uint8_t protocol_data[1]; +} scsi_transport_id_t; + +typedef struct scsi_fc_transport_id { + uint8_t format_code : 2, + resbits : 2, + protocol_id : 4; + uint8_t rsvbytes1[7]; + uint8_t port_name[8]; + uint8_t rsvbytes2[8]; +} scsi_fc_transport_id_t; + +typedef struct iscsi_transport_id { + uint8_t format_code : 2, + resbits : 2, + protocol_id : 4; + uint8_t rsvbyte1; + uint8_t add_len[2]; + char iscsi_name[1]; +} iscsi_transport_id_t; + + +typedef struct scsi_srp_transport_id { + uint8_t format_code : 2, + resbits : 2, + protocol_id : 4; + uint8_t rsvbytes1[7]; + uint8_t srp_name[16]; +} scsi_srp_transport_id_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.11.5 PERSISTENCE RESERVE IN + * Table 110/111 - parameter data for READ FULL STATUS + * Table 281 - TransportId format + */ + +typedef struct scsi_prin_status_t { + uint8_t reservation_key[8]; + uint8_t resbytes1[4]; + uint8_t resbits : 6, + all_tg_pt : 1, + r_holder : 1; + uint8_t scope : 4, + type : 4; + uint8_t resbytes2[4]; + uint8_t rel_tgt_port_id[2]; + uint8_t add_len[4]; + scsi_transport_id_t trans_id; +} scsi_prin_status_t; +typedef struct scsi_prin_full_status { + uint8_t PRgeneration[4]; + uint8_t add_len[4]; + scsi_prin_status_t full_desc[1]; +} scsi_prin_full_status_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.12.1 PERSISTENCE RESERVE OUT + * Table 112 - PERSISTENCE RESERVE OUT command + */ +typedef struct scsi_cdb_prout { + uint8_t cmd; + uint8_t resbits : 3, + action : 5; + uint8_t scope : 4, + type : 4; + uint8_t resbytes[2]; + uint8_t param_len[4]; + uint8_t control; +} scsi_cdb_prout_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.12.3 PERSISTENCE RESERVE OUT + * Table 114 - PERSISTENCE RESERVE OUT parameter list + */ +typedef struct scsi_prout_plist { + uint8_t reservation_key[8]; + uint8_t service_key[8]; + uint8_t obsolete1[4]; + uint8_t resbits1 : 4, + spec_i_pt : 1, + all_tg_pt : 1, + resbits2 : 1, + aptpl : 1; + uint8_t resbytes1; + uint8_t obsolete2[2]; + uint8_t apd[1]; +} scsi_prout_plist_t; + +/* + * Information obtained from: + * SPC-3, Revision 23 + * Section 6.12.4 PERSISTENCE RESERVE OUT command with REGISTER AND MOVE + * Table 117 - REGISTER and MOVE service action parameter list + */ +typedef struct scsi_prout_reg_move_plist { + uint8_t reservation_key[8]; + uint8_t service_key[8]; + uint8_t resbytes1; + uint8_t resbits1 : 6, + unreg : 1, + aptpl : 1; + uint8_t rel_tgt_port_id[2]; + uint8_t tptid_len[4]; + uint8_t tptid[1]; +} scsi_prout_reg_move_plist_t; + +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_GENERIC_PERSIST_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/sense.h b/illumos-x86_64/usr/include/sys/scsi/generic/sense.h new file mode 100644 index 00000000..b51258d6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/sense.h @@ -0,0 +1,405 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_GENERIC_SENSE_H +#define _SYS_SCSI_GENERIC_SENSE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Standard (Non-Extended) SCSI Sense. + * + * For Error Classe 0-6. This is all + * Vendor Unique sense information. + * + * Note: This is pre-SCSI-2. + */ + +struct scsi_sense { +#if defined(_BIT_FIELDS_LTOH) + uchar_t ns_code : 4, /* Vendor Uniqe error code */ + ns_class : 3, /* Error class */ + ns_valid : 1; /* Logical Block Address is val */ + uchar_t ns_lba_hi : 5, /* High Logical Block Address */ + ns_vu : 3; /* Vendor Unique value */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t ns_valid : 1, /* Logical Block Address is valid */ + ns_class : 3, /* Error class */ + ns_code : 4; /* Vendor Uniqe error code */ + uchar_t ns_vu : 3, /* Vendor Unique value */ + ns_lba_hi : 5; /* High Logical Block Address */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t ns_lba_mid; /* Middle Logical Block Address */ + uchar_t ns_lba_lo; /* Low part of Logical Block Address */ +}; + +/* + * SCSI Extended Sense structure + * + * For Error Class 7, the Extended Sense Structure is applicable (now referred + * to in SPC-3 as "fixed format sense data"). The es_code field is used + * to determine whether the extended sense data is actually "fixed format" or + * the newer "descriptor format" introduced in SPC-3. + */ + +#define CLASS_EXTENDED_SENSE 0x7 /* indicates extended sense */ +#define ADDL_SENSE_ADJUST 0x8 /* Add to es_add_length for total */ +#define MIN_FIXED_SENSE_LEN 0xE /* Minimum allowed fixed buf len */ + +struct scsi_extended_sense { +#if defined(_BIT_FIELDS_LTOH) + uchar_t es_code : 4, /* Vendor Unique error code */ + es_class : 3, /* Error Class- fixed at 0x7 */ + es_valid : 1; /* sense data is valid */ + + uchar_t es_segnum; /* segment number: for COPY cmd */ + + uchar_t es_key : 4, /* Sense key (see below) */ + : 1, /* reserved */ + es_ili : 1, /* Incorrect Length Indicator */ + es_eom : 1, /* End of Media */ + es_filmk : 1; /* File Mark Detected */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t es_valid : 1, /* sense data is valid */ + es_class : 3, /* Error Class- fixed at 0x7 */ + es_code : 4; /* Vendor Unique error code */ + + uchar_t es_segnum; /* segment number: for COPY cmd */ + + uchar_t es_filmk : 1, /* File Mark Detected */ + es_eom : 1, /* End of Media */ + es_ili : 1, /* Incorrect Length Indicator */ + : 1, /* reserved */ + es_key : 4; /* Sense key (see below) */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + + uchar_t es_info_1; /* information byte 1 */ + uchar_t es_info_2; /* information byte 2 */ + uchar_t es_info_3; /* information byte 3 */ + uchar_t es_info_4; /* information byte 4 */ + uchar_t es_add_len; /* number of additional bytes */ + + uchar_t es_cmd_info[4]; /* command specific information */ + uchar_t es_add_code; /* Additional Sense Code */ + uchar_t es_qual_code; /* Additional Sense Code Qualifier */ + uchar_t es_fru_code; /* Field Replaceable Unit Code */ + uchar_t es_skey_specific[3]; /* Sense Key Specific information */ + + /* + * Additional bytes may be defined in each implementation. + * The actual amount of space allocated for Sense Information + * is also implementation dependent. + * + * Modulo that, the declaration of an array two bytes in size + * nicely rounds this entire structure to a size of 20 bytes. + */ + + uchar_t es_add_info[2]; /* additional information */ + +}; + +/* + * Sense code values for Extended Sense + */ + +#define CODE_FMT_FIXED_CURRENT 0x0 +#define CODE_FMT_FIXED_DEFERRED 0x1 +#define CODE_FMT_DESCR_CURRENT 0x2 +#define CODE_FMT_DESCR_DEFERRED 0x3 +#define CODE_FMT_VENDOR_SPECIFIC 0xF + +#define SCSI_IS_DESCR_SENSE(sns_ptr) \ + (((((struct scsi_extended_sense *)(sns_ptr))->es_code) == \ + CODE_FMT_DESCR_CURRENT) || \ + ((((struct scsi_extended_sense *)(sns_ptr))->es_code) == \ + CODE_FMT_DESCR_DEFERRED)) + +/* + * Sense Key values for Extended Sense. + */ + +#define KEY_NO_SENSE 0x00 +#define KEY_RECOVERABLE_ERROR 0x01 +#define KEY_NOT_READY 0x02 +#define KEY_MEDIUM_ERROR 0x03 +#define KEY_HARDWARE_ERROR 0x04 +#define KEY_ILLEGAL_REQUEST 0x05 +#define KEY_UNIT_ATTENTION 0x06 +#define KEY_WRITE_PROTECT 0x07 +#define KEY_DATA_PROTECT KEY_WRITE_PROTECT +#define KEY_BLANK_CHECK 0x08 +#define KEY_VENDOR_UNIQUE 0x09 +#define KEY_COPY_ABORTED 0x0A +#define KEY_ABORTED_COMMAND 0x0B +#define KEY_EQUAL 0x0C +#define KEY_VOLUME_OVERFLOW 0x0D +#define KEY_MISCOMPARE 0x0E +#define KEY_RESERVED 0x0F + +/* + * Descriptor sense data header + * + * Descriptor format sense data is described in the SPC-3 standard. Unlike + * the fixed format sense data, descriptor format consists of a header + * followed by a variable length list of sense data descriptors. + */ + +struct scsi_descr_sense_hdr { +#if defined(_BIT_FIELDS_LTOH) + uchar_t ds_code : 4, /* Vendor Unique error code */ + ds_class : 3, /* Error Class- fixed at 0x7 */ + ds_reserved : 1; /* sense data is valid */ + + uchar_t ds_key : 4, /* Sense key */ + ds_reserved2 : 4; /* reserved */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t ds_reserved : 1, /* sense data is valid */ + ds_class : 3, /* Error Class- fixed at 0x7 */ + ds_code : 4; /* Vendor Unique error code */ + + uchar_t ds_reserved2 : 4, /* reserved */ + ds_key : 4; /* Sense key (see below) */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + + uchar_t ds_add_code; /* Additional Sense Code */ + uchar_t ds_qual_code; /* Additional Sense Code Qualifier */ + + uchar_t ds_reserved3[3]; /* reserved */ + + uchar_t ds_addl_sense_length; /* Additional sense data length */ +}; + +/* + * SCSI sense descriptors + */ + +struct scsi_information_sense_descr { + uchar_t isd_descr_type; /* Descriptor type (0x00) */ + uchar_t isd_addl_length; /* Additional byte count (0x0A) */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t isd_reserved1 : 7, /* reserved */ + isd_valid : 1; /* Always set to 1 */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t isd_valid : 1, /* Always set to 1 */ + isd_reserved1 : 7; /* reserved */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t isd_reserved2; /* reserved */ + uchar_t isd_information[8]; /* Information bytes */ +}; + +struct scsi_cmd_specific_sense_descr { + uchar_t css_descr_type; /* Descriptor type (0x01) */ + uchar_t css_addl_length; /* Additional byte count (0x0A) */ + uchar_t css_reserved[2]; /* reserved */ + uchar_t css_cmd_specific_info[8]; /* Command specific info */ +}; + +union scsi_sk_specific_data { + /* + * Field pointer (Sense key = Illegal Request) + */ + struct { +#if defined(_BIT_FIELDS_LTOH) + uchar_t bit_pointer : 3, + bpv : 1, + reserved : 2, + cd : 1, + sksv : 1; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t sksv : 1, + cd : 1, + reserved : 2, + bpv : 1, + bit_pointer : 3; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t field_pointer[2]; + } fp; + /* + * Actual Retry Count (Sense key = Hardware error, + * Medium Error or Recovered Error) + */ + struct { + uchar_t sksv; + uchar_t actual_retry_count[2]; + } arc; + /* + * Progress Indication (Sense key = No Sense or Not Ready + */ + struct { + uchar_t sksv; + uchar_t progress_indication[2]; + } pi; + /* + * Segment Pointer (Sense key = Copy Aborted) + */ + struct { +#if defined(_BIT_FIELDS_LTOH) + uchar_t bit_pointer : 3, + bpv : 1, + reserved : 1, + sd : 1, + reserved2 : 1, + sksv : 1; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t sksv : 1, + reserved2 : 1, + sd : 1, + reserved : 1, + bpv : 1, + bit_pointer : 3; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t field_pointer[2]; + } sp; +}; + +struct scsi_sk_specific_sense_descr { + uchar_t sss_descr_type; /* Descriptor type */ + uchar_t sss_addl_length; /* Additional byte count (0x06) */ + uchar_t sss_reserved[2]; /* reserved */ + union scsi_sk_specific_data sss_data; + uchar_t sss_reserved2; +}; + +struct scsi_fru_sense_descr { + uchar_t fs_descr_type; /* Descriptor type (0x03) */ + uchar_t fs_addl_length; /* Additional byte count (0x02) */ + uchar_t fs_reserved; /* reserved */ + uchar_t fs_fru_code; /* Field Replaceable Unit Code */ +}; + +struct scsi_stream_cmd_data { +#if defined(_BIT_FIELDS_LTOH) + uchar_t scs_reserved2 : 5, + scs_ili : 1, + scs_eom : 1, + scs_filemark : 1; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t scs_filemark : 1, + scs_eom : 1, + scs_ili : 1, + scs_reserved2 : 5; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ +}; + +struct scsi_stream_cmd_sense_descr { + uchar_t scs_descr_type; /* Descriptor type (0x04) */ + uchar_t scs_addl_length; /* Additional byte count (0x02) */ + uchar_t scs_reserved; /* reserved */ + struct scsi_stream_cmd_data scs_data; +}; + +struct scsi_block_cmd_sense_descr { + uchar_t bcs_descr_type; /* Descriptor type (0x05) */ + uchar_t bcs_addl_length; /* Additional byte count (0x02) */ + uchar_t bcs_reserved; /* reserved */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t bcs_reserved2 : 5, + bcs_ili : 1, + bcs_reserved3 : 2; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t bcs_reserved3 : 2, + bcs_ili : 1, + bcs_reserved2 : 5; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ +}; + +struct scsi_ata_status_ret_sense_descr { + uchar_t ars_descr_type; /* Descriptor type (0x09) */ + uchar_t ars_addl_length; /* Additional byte count (0x0c) */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t ars_extend : 1, + ars_reserved1 : 7; /* reserved */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t ars_reserved1 : 7, /* reserved */ + ars_extend : 1; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t ars_error; + uchar_t ars_sec_count_msb; + uchar_t ars_sec_count_lsb; + uchar_t ars_lba_low_msb; + uchar_t ars_lba_low_lsb; + uchar_t ars_lba_mid_msb; + uchar_t ars_lba_mid_lsb; + uchar_t ars_lba_high_msb; + uchar_t ars_lba_high_lsb; + uchar_t ars_device; + uchar_t ars_status; +}; + +struct scsi_vendor_specific_sense_descr { + uchar_t vss_descr_type; /* Descriptor type (0x80-0xFF) */ + uchar_t vss_addl_length; /* Additional byte count */ + /* + * Variable length vendor specific data + */ + uchar_t vss_vendor_specific_info[1]; +}; + +/* + * SCSI Descriptor Types + */ +#define DESCR_INFORMATION 0x00 +#define DESCR_COMMAND_SPECIFIC 0x01 +#define DESCR_SENSE_KEY_SPECIFIC 0x02 +#define DESCR_FRU 0x03 +#define DESCR_STREAM_COMMANDS 0x04 +#define DESCR_BLOCK_COMMANDS 0x05 +#define DESCR_OSD_OID 0x06 +#define DESCR_OSD_RESP_INTEGRITY 0x07 +#define DESCR_OSD_ATTR_ID 0x08 +#define DESCR_ATA_STATUS_RETURN 0x09 + +#ifdef __cplusplus +} +#endif + +/* + * Each implementation will have specific mappings to what + * Sense Information means + */ + +#include + +#endif /* _SYS_SCSI_GENERIC_SENSE_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/sff_frames.h b/illumos-x86_64/usr/include/sys/scsi/generic/sff_frames.h new file mode 100644 index 00000000..b59b88bf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/sff_frames.h @@ -0,0 +1,261 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_SCSI_GENERIC_SFF_FRAMES_H +#define _SYS_SCSI_GENERIC_SFF_FRAMES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * The definitions of SMP frame formats defined by SFF-8485. + * These are NOT compatible with the generic SAS-1 and/or SAS-2 SMP frame + * formats, but the function numbers and result codes are defined by SAS-2. + */ + +#pragma pack(1) + +typedef struct sff_request_frame { + uint8_t srf_frame_type; + uint8_t srf_function; + uint8_t srf_data[1]; +} sff_request_frame_t; + +typedef struct sff_response_frame { + uint8_t srf_frame_type; + uint8_t srf_function; + uint8_t srf_result; + uint8_t _reserved1; + uint8_t srf_data[1]; +} sff_response_frame_t; + +/* + * SFF-8485 8.4.1 GPIO register overview + */ +typedef enum sff_gpio_reg_type { + SFF_GPIO_CFG = 0x00, + SFF_GPIO_RX = 0x01, + SFF_GPIO_RX_GP = 0x02, + SFF_GPIO_TX = 0x03, + SFF_GPIO_TX_GP = 0x04 +} sff_gpio_reg_type_t; + +/* + * SFF-8485 8.4.2.1 GPIO configuration registers overview + */ +typedef enum sff_gpio_cfg_reg_index { + SFF_GPIO_CFG_0 = 0x00, + SFF_GPIO_CFG_1 = 0x01 +} sff_gpio_cfg_reg_index_t; + +/* + * SFF-8485 8.4.2.2 GPIO_CFG[0] register + */ +typedef struct sff_gpio_cfg_reg_0 { + uint8_t _reserved1; + DECL_BITFIELD2( + sgcr0_version :4, + _reserved2 :4); + DECL_BITFIELD3( + sgcr0_gp_register_count :4, + sgcr0_cfg_register_count :3, + sgcr0_gpio_enable :1); + uint8_t sgcr0_supported_drive_count; +} sff_gpio_cfg_reg_0_t; + +/* + * SFF-8485 8.4.2.3 GPIO_CFG[1] register + */ +typedef struct sff_gpio_cfg_reg_1 { + uint8_t _reserved1; + DECL_BITFIELD2( + sgcr1_blink_gen_rate_a :4, + sgcr1_blink_gen_rate_b :4); + DECL_BITFIELD2( + sgcr1_max_activity_on :4, + sgcr1_force_activity_off :4); + DECL_BITFIELD2( + sgcr1_stretch_activity_on :4, + sgcr1_stretch_activity_off :4); +} sff_gpio_cfg_reg_1_t; + +/* + * SFF-8485 8.4.3 GPIO receive registers + */ +typedef struct sff_gpio_rx_reg { + DECL_BITFIELD2( + sgrr_drive_3_gpio_input :3, + _reserved1 :5); + DECL_BITFIELD2( + sgrr_drive_2_gpio_input :3, + _reserved1 :5); + DECL_BITFIELD2( + sgrr_drive_1_gpio_input :3, + _reserved1 :5); + DECL_BITFIELD2( + sgrr_drive_0_gpio_input :3, + _reserved1 :5); +} sff_gpio_rx_reg_t; + +/* + * SFF-8485 8.4.4 GPIO transmit registers + */ +typedef enum sff_drive_error { + SFF_DRIVE_ERR_DISABLE = 0x0, + SFF_DRIVE_ERR_ENABLE = 0x1, + SFF_DRIVE_ERR_BLINK_A_1_0 = 0x2, + SFF_DRIVE_ERR_BLINK_A_0_1 = 0x3, + SFF_DRIVE_ERR_ENABLE_4 = 0x4, + SFF_DRIVE_ERR_ENABLE_5 = 0x5, + SFF_DRIVE_ERR_BLINK_B_1_0 = 0x6, + SFF_DRIVE_ERR_BLINK_B_0_1 = 0x7 +} sff_drive_error_t; + +typedef enum sff_drive_locate { + SFF_DRIVE_LOC_DISABLE = 0x0, + SFF_DRIVE_LOC_ENABLE = 0x1, + SFF_DRIVE_BLINK_A_1_0 = 0x2, + SFF_DRIVE_BLINK_A_0_1 = 0x3 +} sff_drive_locate_t; + +typedef enum sff_drive_activity { + SFF_DRIVE_ACT_DISABLE = 0x0, + SFF_DRIVE_ACT_ENABLE = 0x1, + SFF_DRIVE_ACT_BLINK_A_1_0 = 0x2, + SFF_DRIVE_ACT_BLINK_A_0_1 = 0x3, + SFF_DRIVE_ACT_ENABLE_END = 0x4, + SFF_DRIVE_ACT_ENABLE_START = 0x5, + SFF_DRIVE_ACT_BLINK_B_1_0 = 0x6, + SFF_DRIVE_ACT_BLINK_B_0_1 = 0x7 +} sff_drive_activity_t; + +typedef struct sff_gpio_tx_reg { + DECL_BITFIELD3( + sgtr_drive_3_error :3, /* sff_drive_error_t */ + sgtr_drive_3_locate :2, /* sff_drive_locate_t */ + sgtr_drive_3_activity :3); /* sff_drive_activity_t */ + DECL_BITFIELD3( + sgtr_drive_2_error :3, /* sff_drive_error_t */ + sgtr_drive_2_locate :2, /* sff_drive_locate_t */ + sgtr_drive_2_activity :3); /* sff_drive_activity_t */ + DECL_BITFIELD3( + sgtr_drive_1_error :3, /* sff_drive_error_t */ + sgtr_drive_1_locate :2, /* sff_drive_locate_t */ + sgtr_drive_1_activity :3); /* sff_drive_activity_t */ + DECL_BITFIELD3( + sgtr_drive_0_error :3, /* sff_drive_error_t */ + sgtr_drive_0_locate :2, /* sff_drive_locate_t */ + sgtr_drive_0_activity :3); /* sff_drive_activity_t */ +} sff_gpio_tx_reg_t; + +/* + * SFF-8485 8.4.5.1 GPIO general purpose receive registers overview + */ +typedef enum sff_gpio_rx_gp_reg_index { + SFF_GPIO_REG_RX_GP_CFG = 0x00, + SFF_GPIO_REG_RX_GP_1 = 0x01 /* ... */ +} sff_gpio_rx_gp_reg_index_t; + +/* + * SFF-8485 8.4.5.2 GPIO_RX_GP_CFG register + */ +typedef struct sff_gpio_rx_gp_cfg_reg { + uint8_t _reserved1[2]; + uint8_t sgrgcr_count; + uint8_t _reserved2; +} sff_gpio_rx_gp_cfg_reg_t; + +/* + * SFF-8485 8.4.5.3 GPIO_RX_GP[1..n] register + */ +typedef uint8_t sff_gpio_rx_gp_reg_t[4]; /* little-endian */ + +/* + * SFF-8485 8.4.6.1 GPIO general purpose transmit registers overview + */ +typedef enum sff_gpio_tx_gp_reg_index { + SFF_GPIO_REG_TX_GP_CFG = 0x00, + SFF_GPIO_REG_TX_GP_1 = 0x01 /* ... */ +} sff_gpio_tx_gp_reg_index_t; + +/* + * SFF-8485 8.4.6.2 GPIO_TX_GP_CFG register + */ +typedef struct sff_gpio_tx_cfg_reg { + uint8_t _reserved1[2]; + uint8_t sgtcr_count; + DECL_BITFIELD5( + sgtcr_sload_0 :1, + sgtcr_sload_1 :1, + sgtcr_sload_2 :1, + sgtcr_sload_3 :1, + _reserved2 :4); +} sff_gpio_tx_cfg_reg_t; + +/* + * SFF-8485 8.4.6.3 GPIO_TX_GP[1..n] registers + */ +typedef uint8_t sff_gpio_tx_gp_reg_t[4]; /* little-endian */ + +/* + * SFF-8485 8.2.2 READ GPIO REGISTER request + */ +typedef struct sff_read_gpio_req { + uint8_t srgr_register_type; + uint8_t srgr_register_index; + uint8_t srgr_register_count; + uint8_t _reserved1[3]; +} sff_read_gpio_req_t; + +typedef uint8_t sff_gpio_reg_t[4]; + +/* + * SFF-8485 8.2.2 READ GPIO REGISTER response + */ +typedef struct sff_read_gpio_resp { + sff_gpio_reg_t srgr_regs[1]; +} smp_response_frame_t; + +/* + * SFF-8485 8.2.3 WRITE GPIO REGISTER request (no additional response) + */ +typedef struct sff_write_gpio_req { + uint8_t swgr_register_type; + uint8_t swgr_register_index; + uint8_t swgr_register_count; + uint8_t _reserved1[3]; + sff_gpio_reg_t swgr_regs[1]; +} sff_write_gpio_req_t; + +#pragma pack() + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_GENERIC_SFF_FRAMES_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/smp_frames.h b/illumos-x86_64/usr/include/sys/scsi/generic/smp_frames.h new file mode 100644 index 00000000..9ae358d4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/smp_frames.h @@ -0,0 +1,1146 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_SCSI_GENERIC_SMP_FRAMES_H +#define _SYS_SCSI_GENERIC_SMP_FRAMES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * The definitions of smp frame types and functions conforming to SAS-1.1 and + * SAS-2. Consumers are expected to determine protocol support by examining + * the response to the REPORT GENERAL function. + */ + +typedef enum smp_frame_type { + SMP_FRAME_TYPE_REQUEST = 0x40, + SMP_FRAME_TYPE_RESPONSE = 0x41 +} smp_frame_type_t; + +typedef enum smp_function { + SMP_FUNC_REPORT_GENERAL = 0x00, + SMP_FUNC_REPORT_MANUFACTURER_INFO = 0x01, + SMP_FUNC_READ_GPIO_REGISTER = 0x02, + SMP_FUNC_REPORT_SELF_CONFIG_STATUS = 0x03, + SMP_FUNC_REPORT_ZONE_PERM_TABLE = 0x04, + SMP_FUNC_REPORT_ZONE_MANAGER_PASSWORD = 0x05, + SMP_FUNC_REPORT_BROADCAST = 0x06, + SMP_FUNC_DISCOVER = 0x10, + SMP_FUNC_REPORT_PHY_ERROR_LOG = 0x11, + SMP_FUNC_REPORT_PHY_SATA = 0x12, + SMP_FUNC_REPORT_ROUTE_INFO = 0x13, + SMP_FUNC_REPORT_PHY_EVENT = 0x14, + SMP_FUNC_DISCOVER_LIST = 0x20, + SMP_FUNC_REPORT_PHY_EVENT_LIST = 0x21, + SMP_FUNC_REPORT_EXP_ROUTE_TABLE_LIST = 0x22, + SMP_FUNC_CONFIG_GENERAL = 0x80, + SMP_FUNC_ENABLE_DISABLE_ZONING = 0x81, + SMP_FUNC_WRITE_GPIO_REGISTER = 0x82, + SMP_FUNC_ZONED_BROADCAST = 0x85, + SMP_FUNC_ZONE_LOCK = 0x86, + SMP_FUNC_ZONE_ACTIVATE = 0x87, + SMP_FUNC_ZONE_UNLOCK = 0x88, + SMP_FUNC_CONFIG_ZONE_MANAGER_PASSWORD = 0x89, + SMP_FUNC_CONFIG_ZONE_PHY_INFO = 0x8A, + SMP_FUNC_CONFIG_ZONE_PERM_TABLE = 0x8B, + SMP_FUNC_CONFIG_ROUTE_INFO = 0x90, + SMP_FUNC_PHY_CONTROL = 0x91, + SMP_FUNC_PHY_TEST_FUNCTION = 0x92, + SMP_FUNC_CONFIG_PHY_EVENT = 0x93 +} smp_function_t; + +typedef enum smp_result { + SMP_RES_FUNCTION_ACCEPTED = 0x00, + SMP_RES_UNKNOWN_FUNCTION = 0x01, + SMP_RES_FUNCTION_FAILED = 0x02, + SMP_RES_INVALID_REQUEST_FRAME_LENGTH = 0x03, + SMP_RES_INVALID_EXPANDER_CHANGE_COUNT = 0x04, + SMP_RES_BUSY = 0x05, + SMP_RES_INCOMPLETE_DESCRIPTOR_LIST = 0x06, + SMP_RES_PHY_DOES_NOT_EXIST = 0x10, + SMP_RES_INDEX_DOES_NOT_EXIST = 0x11, + SMP_RES_PHY_DOES_NOT_SUPPORT_SATA = 0x12, + SMP_RES_UNKNOWN_PHY_OPERATION = 0x13, + SMP_RES_UNKNOWN_PHY_TEST_FUNCTION = 0x14, + SMP_RES_PHY_TEST_IN_PROGRESS = 0x15, + SMP_RES_PHY_VACANT = 0x16, + SMP_RES_UNKNOWN_PHY_EVENT_SOURCE = 0x17, + SMP_RES_UNKNOWN_DESCRIPTOR_TYPE = 0x18, + SMP_RES_UNKNOWN_PHY_FILTER = 0x19, + SMP_RES_AFFILIATION_VIOLATION = 0x1A, + SMP_RES_ZONE_VIOLATION = 0x20, + SMP_RES_NO_MANAGEMENT_ACCESS_RIGHTS = 0x21, + SMP_RES_UNKNOWN_ENABLE_DISABLE_ZONING = 0x22, + SMP_RES_ZONE_LOCK_VIOLATION = 0x23, + SMP_RES_NOT_ACTIVATED = 0x24, + SMP_RES_ZONE_GROUP_OUT_OF_RANGE = 0x25, + SMP_RES_NO_PHYSICAL_PRESENCE = 0x26, + SMP_RES_SAVING_NOT_SUPPORTED = 0x27, + SMP_RES_SOURCE_ZONE_GROUP_DNE = 0x28, + SMP_RES_DISABLED_PW_NOT_SUPPORTED = 0x29, + SMP_RES_NONE = -1 +} smp_result_t; + +#pragma pack(1) + +/* + * SAS-2 10.4.3.2 request frame format + */ +typedef struct smp_request_frame { + uint8_t srf_frame_type; + uint8_t srf_function; + uint8_t srf_allocated_response_len; /* reserved in SAS-1 */ + uint8_t srf_request_len; + uint8_t srf_data[1]; +} smp_request_frame_t; + +/* + * SAS-2 10.4.3.3 response frame format + */ +typedef struct smp_response_frame { + uint8_t srf_frame_type; + uint8_t srf_function; + uint8_t srf_result; + uint8_t srf_response_len; /* reserved in SAS-1 */ + uint8_t srf_data[1]; +} smp_response_frame_t; + +typedef uint8_t smp_crc_t[4]; + +#ifdef offsetof +#define SMP_REQ_MINLEN \ + (offsetof(smp_request_frame_t, srf_data[0]) + sizeof (smp_crc_t)) +#define SMP_RESP_MINLEN \ + (offsetof(smp_response_frame_t, srf_data[0]) + sizeof (smp_crc_t)) +#endif /* offsetof */ + +/* + * SAS-2 10.4.3.4 REPORT GENERAL (no additional request bytes) + */ +typedef struct smp_report_general_resp { + uint16_t srgr_exp_change_count; + uint16_t srgr_exp_route_indexes; + DECL_BITFIELD2( + _reserved1 :7, + srgr_long_response :1); + uint8_t srgr_number_of_phys; + DECL_BITFIELD7( + srgr_externally_configurable_route_table :1, + srgr_configuring :1, + srgr_configures_others :1, + srgr_open_reject_retry_supported :1, + srgr_stp_continue_awt :1, + _reserved2 :2, + srgr_table_to_table_supported :1); + uint8_t _reserved3; + uint64_t srgr_enclosure_logical_identifier; + uint8_t _reserved4[8]; + uint8_t _reserved5[2]; + uint16_t srgr_stp_bus_inactivity_time_limit; + uint16_t srgr_stp_maximum_connect_time_limit; + uint16_t srgr_stp_smp_nexus_loss_time; + DECL_BITFIELD7( + srgr_zoning_enabled :1, + srgr_zoning_supported :1, + srgr_physical_presence_asserted :1, + srgr_physical_presence_supported :1, + srgr_zone_locked :1, + _reserved6 :1, + srgr_number_of_zone_grps :2); + DECL_BITFIELD6( + srgr_saving_zoning_enabled_supported :1, + srgr_saving_zone_perm_table_supported :1, + srgr_saving_zone_phy_info_supported :1, + srgr_saving_zone_mgr_password_supported :1, + srgr_saving :1, + _reserved7 :3); + uint16_t srgr_max_routed_sas_addrs; + uint64_t srgr_active_zm_sas_addr; + uint16_t srgr_zone_lock_inactivity_limit; + uint8_t _reserved8[2]; + uint8_t _reserved9; + uint8_t srgr_first_encl_conn_elem_idx; + uint8_t srgr_number_encl_conn_elem_idxs; + uint8_t _reserved10; + DECL_BITFIELD2( + _reserved11 :7, + srgr_reduced_functionality :1); + uint8_t srgr_time_to_reduced_functionality; + uint8_t srgr_initial_time_to_reduced_functionality; + uint8_t srgr_max_reduced_functionality_time; + uint16_t srgr_last_self_conf_status_descr_idx; + uint16_t srgr_max_stored_self_config_status_descrs; + uint16_t srgr_last_phy_event_list_descr_idx; + uint16_t srgr_max_stored_phy_event_list_descrs; + uint16_t srgr_stp_reject_to_open_limit; + uint8_t _reserved12[2]; +} smp_report_general_resp_t; + +typedef enum smp_n_zone_grps { + SMP_ZONE_GROUPS_128 = 0x0, + SMP_ZONE_GROUPS_256 = 0x1 +} smp_n_zone_grps_t; + +/* + * SAS-2 10.4.3.5 REPORT MANUFACTURER INFORMATION (no additional request bytes) + */ +typedef struct smp_report_manufacturer_info_resp { + uint16_t srmir_exp_change_count; + uint8_t _reserved1[2]; + DECL_BITFIELD2( + srmir_sas_1_1_format :1, + _reserved2 :7); + uint8_t _reserved3[3]; + char srmir_vendor_identification[8]; + char srmir_product_identification[16]; + char srmir_product_revision_level[4]; + char srmir_component_vendor_identification[8]; + uint16_t srmir_component_id; + uint8_t srmir_component_revision_level; + uint8_t _reserved4; + uint8_t srmir_vs_52[8]; +} smp_report_manufacturer_info_resp_t; + +/* + * SAS-2 10.4.3.6 REPORT SELF_CONFIGURATION STATUS + */ +typedef struct smp_report_self_config_status_req { + uint8_t _reserved1[2]; + uint16_t srscsr_starting_self_config_status_descr_idx; +} smp_report_self_config_status_req_t; + +typedef struct smp_report_self_config_status_resp { + uint16_t srscsr_exp_change_count; + uint16_t srscsr_starting_self_config_status_descr_idx; + uint16_t srscsr_number_self_config_status_descrs; + uint16_t srscsr_last_self_config_status_descr_idx; + uint8_t srscsr_self_config_status_descr_len; + uint8_t _reserved1[3]; + uint8_t srscsr_descrs[1]; +} smp_report_self_config_status_resp_t; + +typedef struct smp_self_config_status_descr { + uint8_t sscsd_status_type; + DECL_BITFIELD2( + sscsd_final :1, + _reserved1 :7); + uint8_t _reserved2; + uint8_t sscsd_phy_identifier; + uint8_t _reserved3[4]; + uint64_t sscsd_sas_addr; +} smp_self_config_status_descr_t; + +typedef enum smp_self_config_status_type { + SMP_SCST_NONSPECIFIC_ERROR = 0x01, + SMP_SCST_CONNECTION = 0x02, + SMP_SCST_ROUTE_TABLE_FULL = 0x03, + SMP_SCST_NOMEM = 0x04, + SMP_SCST_PHY_LAYER_ERROR = 0x20, + SMP_SCST_LOST_SYNC = 0x21, + SMP_SCST_LINK_LAYER_ERROR = 0x40, + SMP_SCST_OPEN_TIMEOUT = 0x41, + SMP_SCST_ABANDON_OPEN_REJECT = 0x42, + SMP_SCST_RETRY_OPEN_REJECTS = 0x43, + SMP_SCST_NEXUS_LOSS = 0x44, + SMP_SCST_BREAK = 0x45, + SMP_SCST_CRC_ERROR = 0x46, + SMP_SCST_PORT_LAYER_ERROR = 0x60, + SMP_SCST_RESPONSE_TIMEOUT = 0x61, + SMP_SCST_TRANSPORT_LAYER_ERROR = 0x80, + SMP_SCST_APP_LAYER_ERROR = 0xA0, + SMP_SCST_RESPONSE_TOO_SHORT = 0xA1, + SMP_SCST_UNSUPPORTED_VALUES = 0xA2, + SMP_SCST_INCONSISTENT = 0xA3, + SMP_SCST_CONFIGURING = 0xA4 +} smp_self_config_status_type_t; + +/* + * SAS-2 10.4.3.7 REPORT ZONE PERMISSION TABLE + */ +typedef struct smp_report_zone_perm_table_req { + DECL_BITFIELD2( + srzptr_report_type :2, + _reserved1 :6); + uint8_t _reserved2; + uint8_t srzptr_starting_src_zone_grp; + uint8_t srzptr_max_zone_perm_descrs; +} smp_report_zone_perm_table_req_t; + +typedef enum smp_zone_perm_table_report_type { + SMP_ZPTRT_CURRENT = 0x0, + SMP_ZPTRT_SHADOW = 0x1, + SMP_ZPTRT_SAVED = 0x2, + SMP_ZPTRT_DEFAULT = 0x3 +} smp_zone_perm_table_report_type_t; + +typedef struct smp_report_zone_perm_table_resp { + uint16_t srzptr_exp_change_count; + DECL_BITFIELD3( + srzptr_report_type :2, + _reserved1 :5, + srzptr_zone_locked :1); + DECL_BITFIELD2( + _reserved2 :6, + srzptr_number_zone_grps :2); + uint8_t _reserved3[6]; + uint8_t srzptr_starting_src_zone_grp; + uint8_t srzptr_number_zone_perm_descrs; + uint8_t srzptr_descrs[1]; +} smp_report_zone_perm_table_resp_t; + +typedef uint8_t smp_zone_perm_descr128_t[16]; +typedef uint8_t smp_zone_perm_descr256_t[32]; + +#define SMP_ZONE_PERM_BIT128(__d, __z) \ + ((__d)[15 - ((__z) >> 3)] & (1 << ((__z) & 7))) + +#define SMP_ZONE_PERM_SET128(__d, __z) \ + ((__d)[15 - ((__z) >> 3)] |= (1 << ((__z) & 7))) + +#define SMP_ZONE_PERM_CLR128(__d, __z) \ + ((__d)[15 - ((__z) >> 3)] &= ~(1 << ((__z) & 7))) + +#define SMP_ZONE_PERM_BIT256(__d, __z) \ + ((__d)[31 - ((__z) >> 3)] & (1 << ((__z) & 7))) + +#define SMP_ZONE_PERM_SET256(__d, __z) \ + ((__d)[31 - ((__z) >> 3)] |= (1 << ((__z) & 7))) + +#define SMP_ZONE_PERM_CLR256(__d, __z) \ + ((__d)[31 - ((__z) >> 3)] &= ~(1 << ((__z) & 7))) + +/* + * SAS-2 10.4.3.8 REPORT ZONE MANAGER PASSWORD + */ +typedef enum smp_report_zmp_report_type { + SMP_ZMP_TYPE_CURRENT = 0x0, + SMP_ZMP_TYPE_SAVED = 0x2, + SMP_ZMP_TYPE_DEFAULT = 0x3 +} smp_report_zmp_report_type_t; + +typedef struct smp_report_zone_mgr_password_req { + DECL_BITFIELD2( + srzmpr_rpt_type :2, + _reserved1 :6); + uint8_t _reserved2[2]; +} smp_report_zone_mgr_password_req_t; + +typedef struct smp_report_zone_mgr_password_resp { + uint16_t srzmpr_exp_change_count; + DECL_BITFIELD2( + srzmpr_rpt_type :2, + _reserved1 :6); + uint8_t _reserved2; + uint8_t srzmpr_zone_mgr_password[32]; +} smp_report_zone_mgr_password_resp_t; + +/* + * SAS-2 10.4.3.9 REPORT BROADCAST + */ +typedef struct smp_report_broadcast_req { + DECL_BITFIELD2( + srbr_broadcast_type :4, + _reserved1 :4); + uint8_t _reserved2[3]; +} smp_report_broadcast_req_t; + +typedef enum smp_broadcast_type { + SMP_BROADCAST_CHANGE = 0x0, + SMP_BROADCAST_RESERVED_CHANGE_0 = 0x1, + SMP_BROADCAST_RESERVED_CHANGE_1 = 0x2, + SMP_BROADCAST_SES = 0x3, + SMP_BROADCAST_EXPANDER = 0x4, + SMP_BROADCAST_ASYNC_EVENT = 0x5, + SMP_BROADCAST_RESERVED_3 = 0x6, + SMP_BROADCAST_RESERVED_4 = 0x7, + SMP_BROADCAST_ZONE_ACTIVATE = 0x8 +} smp_broadcast_type_t; + +typedef struct smp_broadcast_descr { + DECL_BITFIELD2( + sbd_broadcast_type :4, + _reserved1 :4); + uint8_t sbd_phy_identifier; + DECL_BITFIELD2( + sbd_broadcast_reason :4, + _reserved2 :4); + uint16_t sbd_broadcast_count; + uint8_t _reserved3[10]; +} smp_broadcast_descr_t; + +typedef struct smp_report_broadcast_resp { + uint16_t srbr_exp_change_count; + DECL_BITFIELD2( + srbr_broadcast_type :4, + _reserved1 :4); + uint8_t srbr_number_broadcast_descrs; + smp_broadcast_descr_t srbr_descrs[1]; +} smp_report_broadcast_resp_t; + +/* + * SAS-2 10.4.3.10 DISCOVER + */ +typedef struct smp_discover_req { + uint8_t _reserved1[4]; + DECL_BITFIELD2( + sdr_ignore_zone_grp :1, + _reserved2 :7); + uint8_t sdr_phy_identifier; + uint8_t _reserved3[2]; +} smp_discover_req_t; + +typedef struct smp_snw3_phy_cap { + DECL_BITFIELD4( + sspc_requested_logical_link_rate :4, /* smp_link_rate_t */ + _reserved1 :2, + sspc_tx_ssc_type :1, + sspc_start :1); + DECL_BITFIELD7( + _reserved2 :2, + sspc_g3_ssc :1, + sspc_g3_no_ssc :1, + sspc_g2_ssc :1, + sspc_g2_no_ssc :1, + sspc_g1_ssc :1, + sspc_g1_no_ssc :1); + uint8_t _reserved3; + DECL_BITFIELD2( + sspc_parity :1, + _reserved4 :7); +} smp_snw3_phy_cap_t; + +typedef struct smp_discover_resp { + uint16_t sdr_exp_change_count; + uint8_t _reserved1[3]; + uint8_t sdr_phy_identifier; + uint8_t _reserved2[2]; + DECL_BITFIELD3( + sdr_attached_reason :4, + sdr_attached_device_type :3, + _reserved3 :1); + DECL_BITFIELD2( + sdr_negotiated_logical_link_rate :4, /* smp_link_rate_t */ + _reserved4 :4); + DECL_BITFIELD5( + sdr_attached_sata_host :1, + sdr_attached_smp_initiator :1, + sdr_attached_stp_initiator :1, + sdr_attached_ssp_initiator :1, + _reserved5 :4); + DECL_BITFIELD6( + sdr_attached_sata_device :1, + sdr_attached_smp_target :1, + sdr_attached_stp_target :1, + sdr_attached_ssp_target :1, + _reserved6 :3, + sdr_attached_sata_port_selector :1); + uint64_t sdr_sas_addr; + uint64_t sdr_attached_sas_addr; + uint8_t sdr_attached_phy_identifier; + DECL_BITFIELD4( + sdr_attached_break_reply_capable :1, + sdr_attached_requested_inside_zpsds :1, + sdr_attached_inside_zpsds_persistent :1, + _reserved7 :5); + uint8_t _reserved8[6]; + DECL_BITFIELD2( + sdr_hw_min_phys_link_rate :4, /* smp_link_rate_t */ + sdr_prog_min_phys_link_rate :4); /* smp_link_rate_t */ + DECL_BITFIELD2( + sdr_hw_max_phys_link_rate :4, /* smp_link_rate_t */ + sdr_prog_max_phys_link_rate :4); /* smp_link_rate_t */ + uint8_t sdr_phy_change_count; + DECL_BITFIELD3( + sdr_partial_pwy_timeout :4, + _reserved9 :3, + sdr_virtual_phy :1); + DECL_BITFIELD2( + sdr_routing_attr :4, /* smp_routing_attr_t */ + _reserved10 :4); + DECL_BITFIELD2( + sdr_connector_type :7, + _reserved11 :1); + uint8_t sdr_connector_element_index; + uint8_t sdr_connector_physical_link; + uint8_t _reserved12[2]; + uint8_t sdr_vendor[2]; + uint64_t sdr_attached_device_name; + DECL_BITFIELD8( + sdr_zoning_enabled :1, + sdr_inside_zpsds :1, + sdr_zone_group_persistent :1, + _reserved13 :1, + sdr_requested_inside_zpsds :1, + sdr_inside_zpsds_persistent :1, + sdr_requested_inside_zpsds_changed_by_exp :1, + _reserved14 :1); + uint8_t _reserved15[2]; + uint8_t sdr_zone_group; + uint8_t sdr_self_config_status; + uint8_t sdr_self_config_levels_completed; + uint8_t _reserved16[2]; + uint64_t sdr_self_config_sas_addr; + smp_snw3_phy_cap_t sdr_prog_phy_cap; + smp_snw3_phy_cap_t sdr_current_phy_cap; + smp_snw3_phy_cap_t sdr_attached_phy_cap; + uint8_t _reserved17[6]; + DECL_BITFIELD2( + sdr_negotiated_phys_link_rate :4, /* smp_link_rate_t */ + sdr_reason :4); + DECL_BITFIELD3( + sdr_hw_muxing_supported :1, + sdr_negotiated_ssc :1, + _reserved18 :6); + DECL_BITFIELD7( + sdr_default_zoning_enabled :1, + _reserved19 :1, + sdr_default_zone_group_persistent :1, + _reserved20 :1, + sdr_default_requested_inside_zpsds :1, + sdr_default_inside_zpsds_persistent :1, + _reserved21 :2); + uint8_t _reserved22[2]; + uint8_t sdr_default_zone_group; + DECL_BITFIELD7( + sdr_saved_zoning_enabled :1, + _reserved23 :1, + sdr_saved_zone_group_persistent :1, + _reserved24 :1, + sdr_saved_requested_inside_zpsds :1, + sdr_saved_inside_zpsds_persistent :1, + _reserved25 :2); + uint8_t _reserved26[2]; + uint8_t saved_zone_group; + DECL_BITFIELD6( + _reserved27 :2, + sdr_shadow_zone_group_persistent :1, + _reserved28 :1, + sdr_shadow_requested_inside_zpsds :1, + sdr_shadow_inside_zpsds_persistent :1, + _reserved29 :2); + uint8_t _reserved30[2]; + uint8_t sdr_shadow_zone_group; +} smp_discover_resp_t; + +typedef enum smp_link_rate { + SMP_LINK_RATE_NO_CHANGE = 0x0, + SMP_LINK_RATE_DISABLED = 0x1, + SMP_LINK_RATE_RESET_PROBLEM = 0x2, + SMP_LINK_RATE_SPINUP_HOLD = 0x3, + SMP_LINK_RATE_PORT_SELECTOR = 0x4, + SMP_LINK_RATE_RESET = 0x5, + SMP_LINK_RATE_UNSUPPORTED = 0x6, + SMP_LINK_RATE_1_5 = 0x8, + SMP_LINK_RATE_3 = 0x9, + SMP_LINK_RATE_6 = 0xA +} smp_link_rate_t; + +typedef enum smp_device_type { + SMP_DEV_NONE = 0x0, + SMP_DEV_SAS_SATA = 0x1, + SMP_DEV_EXPANDER = 0x2, + SMP_DEV_EXPANDER_OLD = 0x3 +} smp_device_type_t; + +typedef enum smp_routing_attr { + SMP_ROUTING_DIRECT = 0x0, + SMP_ROUTING_SUBTRACTIVE = 0x1, + SMP_ROUTING_TABLE = 0x2 +} smp_routing_attr_t; + +/* + * SAS-2 10.4.3.11 REPORT PHY ERROR LOG + */ +typedef struct smp_report_phy_error_log_req { + uint8_t _reserved1[5]; + uint8_t srpelr_phy_identifier; + uint8_t _reserved2[2]; +} smp_report_phy_error_log_req_t; + +typedef struct smp_report_phy_error_log_resp { + uint16_t srpelr_exp_change_count; + uint8_t _reserved1[3]; + uint8_t srpelr_phy_identifier; + uint8_t _reserved2[2]; + uint32_t srpelr_invalid_dword_count; + uint32_t srpelr_running_disparity_error_count; + uint32_t srpelr_loss_dword_sync_count; + uint32_t srpelr_phy_reset_problem_count; +} smp_report_phy_error_log_resp_t; + +/* + * SAS-2 10.4.3.12 REPORT PHY SATA + */ +typedef struct smp_report_phy_sata_req { + uint8_t _reserved1[5]; + uint8_t srpsr_phy_identifier; + uint8_t srpsr_affiliation_context; + uint8_t _reserved2; +} smp_report_phy_sata_req_t; + +typedef struct smp_report_phy_sata_resp { + uint16_t srpsr_exp_change_count; + uint8_t _reserved1[3]; + uint8_t srpsr_phy_identifier; + uint8_t _reserved2; + DECL_BITFIELD4( + srpsr_affiliation_valid :1, + srpsr_affiliations_supported :1, + srpsr_stp_nexus_loss :1, + _reserved3 :5); + uint8_t _reserved4[4]; + uint64_t srpsr_stp_sas_addr; + uint8_t srpsr_register_device_host_fis[20]; + uint8_t _reserved5[4]; + uint64_t srpsr_affiliated_stp_init_sas_addr; + uint64_t srpsr_stp_nexus_loss_sas_addr; + uint8_t _reserved6; + uint8_t srpsr_affiliation_context; + uint8_t srpsr_current_affiliation_contexts; + uint8_t srpsr_max_affiliation_contexts; +} smp_report_phy_sata_resp_t; + +/* + * SAS-2 10.4.3.13 REPORT ROUTE INFORMATION + */ +typedef struct smp_report_route_info_req { + uint8_t _reserved1[2]; + uint16_t srrir_exp_route_index; + uint8_t _reserved2; + uint8_t srrir_phy_identifier; + uint8_t _reserved3[2]; +} smp_report_route_info_req_t; + +typedef struct smp_report_route_info_resp { + uint16_t srrir_exp_change_count; + uint16_t srrir_exp_route_index; + uint8_t _reserved1; + uint8_t srrir_phy_identifier; + uint8_t _reserved2[2]; + DECL_BITFIELD2( + _reserved3 :7, + srrir_exp_route_entry_disabled :1); + uint8_t _reserved4[3]; + uint64_t srrir_routed_sas_addr; + uint8_t _reserved5[16]; +} smp_report_route_info_resp_t; + +/* + * SAS-2 10.4.3.14 SAS-2 REPORT PHY EVENT + */ +typedef enum smp_phy_event_source { + SMP_PHY_EVENT_NO_EVENT = 0x00, + SMP_PHY_EVENT_INVALID_DWORD_COUNT = 0x01, + SMP_PHY_EVENT_RUNNING_DISPARITY_ERROR_COUNT = 0x02, + SMP_PHY_EVENT_LOSS_OF_DWORD_SYNC_COUNT = 0x03, + SMP_PHY_EVENT_PHY_RESET_PROBLEM_COUNT = 0x04, + SMP_PHY_EVENT_ELASTICITY_BUFFER_OVERFLOW_COUNT = 0x05, + SMP_PHY_EVENT_RX_ERROR_COUNT = 0x06, + SMP_PHY_EVENT_RX_ADDR_FRAME_ERROR_COUNT = 0x20, + SMP_PHY_EVENT_TX_ABANDON_CLASS_OPEN_REJ_COUNT = 0x21, + SMP_PHY_EVENT_RX_ABANDON_CLASS_OPEN_REJ_COUNT = 0x22, + SMP_PHY_EVENT_TX_RETRY_CLASS_OPEN_REJ_COUNT = 0x23, + SMP_PHY_EVENT_RX_RETRY_CLASS_OPEN_REJ_COUNT = 0x24, + SMP_PHY_EVENT_RX_AIP_W_O_PARTIAL_COUNT = 0x25, + SMP_PHY_EVENT_RX_AIP_W_O_CONN_COUNT = 0x26, + SMP_PHY_EVENT_TX_BREAK_COUNT = 0x27, + SMP_PHY_EVENT_RX_BREAK_COUNT = 0x28, + SMP_PHY_EVENT_BREAK_TIMEOUT_COUNT = 0x29, + SMP_PHY_EVENT_CONNECTION_COUNT = 0x2A, + SMP_PHY_EVENT_PEAK_TX_PATHWAY_BLOCKED_COUNT = 0x2B, + SMP_PHY_EVENT_PEAK_TX_ARB_WAIT_TIME = 0x2C, + SMP_PHY_EVENT_PEAK_ARB_TIME = 0x2D, + SMP_PHY_EVENT_PEAK_CONNECTION_TIME = 0x2E, + SMP_PHY_EVENT_TX_SSP_FRAME_COUNT = 0x40, + SMP_PHY_EVENT_RX_SSP_FRAME_COUNT = 0x41, + SMP_PHY_EVENT_TX_SSP_FRAME_ERROR_COUNT = 0x42, + SMP_PHY_EVENT_RX_SSP_FRAME_ERROR_COUNT = 0x43, + SMP_PHY_EVENT_TX_CREDIT_BLOCKED_COUNT = 0x44, + SMP_PHY_EVENT_RX_CREDIT_BLOCKED_COUNT = 0x45, + SMP_PHY_EVENT_TX_SATA_FRAME_COUNT = 0x50, + SMP_PHY_EVENT_RX_SATA_FRAME_COUNT = 0x51, + SMP_PHY_EVENT_SATA_FLOW_CTRL_BUF_OVERFLOW_COUNT = 0x52, + SMP_PHY_EVENT_TX_SMP_FRAME_COUNT = 0x60, + SMP_PHY_EVENT_RX_SMP_FRAME_COUNT = 0x61, + SMP_PHY_EVENT_RX_SMP_FRAME_ERROR_COUNT = 0x63 +} smp_phy_event_source_t; + +typedef struct smp_report_phy_event_req { + uint8_t _reserved1; + uint8_t _reserved2[4]; + uint8_t srper_phy_identifier; + uint8_t _reserved3[2]; +} smp_report_phy_event_req_t; + +typedef struct smp_phy_event_report_descr { + uint8_t _reserved1[3]; + uint8_t sped_phy_event_source; + uint32_t sped_phy_event; + uint32_t sped_peak_detector_threshold; +} smp_phy_event_report_descr_t; + +typedef struct smp_report_phy_event_resp { + uint16_t srper_exp_change_count; + uint8_t _reserved1[3]; + uint8_t srper_phy_identifier; + uint8_t _reserved2[5]; + uint8_t srper_n_phy_event_descrs; + smp_phy_event_report_descr_t srper_phy_event_descrs[1]; +} smp_report_phy_event_resp_t; + +/* + * SAS-2 10.4.3.15 SAS-2 DISCOVER LIST + */ +typedef struct smp_discover_list_req { + uint8_t _reserved1[4]; + uint8_t sdlr_starting_phy_identifier; + uint8_t sdlr_max_descrs; + DECL_BITFIELD3( + sdlr_phy_filter :4, + _reserved2 :3, + sdlr_ignore_zone_group :1); + DECL_BITFIELD2( + sdlr_descr_type :4, + _reserved3 :4); + uint8_t _reserved4[4]; + uint8_t sdlr_vendor[12]; +} smp_discover_list_req_t; + +typedef struct smp_discover_short_descr { + uint8_t sdsd_phy_identifier; + uint8_t sdsd_function_result; + DECL_BITFIELD3( + sdsd_attached_reason :4, + sdsd_attached_device_type :3, + _restricted1 :1); + DECL_BITFIELD2( + sdsd_negotiated_logical_link_rate :4, /* smp_link_rate_t */ + _restricted2 :4); + DECL_BITFIELD5( + sdsd_attached_sata_host :1, + sdsd_attached_smp_initiator :1, + sdsd_attached_stp_initiator :1, + sdsd_attached_ssp_initiator :1, + _restricted3 :4); + DECL_BITFIELD6( + sdsd_attached_sata_device :1, + sdsd_attached_smp_target :1, + sdsd_attached_stp_target :1, + sdsd_attached_ssp_target :1, + _restricted4 :3, + sdsd_attached_sata_port_selector :1); + DECL_BITFIELD3( + sdsd_routing_attribute :4, /* smp_routing_attr_t */ + _reserved1 :3, + sdsd_virtual_phy :1); + DECL_BITFIELD2( + _reserved2 :4, + sdsd_reason :4); + uint8_t sdsd_zone_group; + DECL_BITFIELD7( + _reserved3 :1, + sdsd_inside_zpsds :1, + sdsd_zone_group_persistent :1, + _reserved4 :1, + sdsd_requested_insize_zpsds :1, + sdsd_inside_zpsds_persistent :1, + _restricted5 :2); + uint8_t sdsd_attached_phy_identifier; + uint8_t sdsd_phy_change_count; + uint64_t sdsd_attached_sas_addr; + uint8_t _reserved5[4]; +} smp_discover_short_descr_t; + +typedef struct smp_discover_long_descr { + uint8_t _reserved1[2]; + uint8_t sdld_function_result; + uint8_t _reserved2[1]; + smp_discover_resp_t sdld_response; +} smp_discover_long_descr_t; + +#define SMP_DISCOVER_RESP(_ld) \ + (((smp_discover_long_descr_t *)(_ld))->sdld_function_result == \ + SMP_FUNCTION_ACCEPTED ? \ + &((smp_discover_long_descr_t *)(_ld))->sdld_response : \ + NULL) + +typedef struct smp_discover_list_resp { + uint16_t sdlr_exp_change_count; + uint8_t _reserved1[2]; + uint8_t sdlr_starting_phy_identifier; + uint8_t sdlr_n_descrs; + DECL_BITFIELD2( + sdlr_phy_filter :4, + _reserved2 :4); + DECL_BITFIELD2( + sdlr_descr_type :4, + _reserved3 :4); + uint8_t sdlr_descr_length; + uint8_t _reserved4[3]; + DECL_BITFIELD5( + sdlr_externally_configurable_route_table :1, + sdlr_configuring :1, + _reserved5 :4, + sdlr_zoning_enabled :1, + sdlr_zoning_supported :1); + uint8_t _reserved6; + uint16_t sdlr_last_sc_status_descr_index; + uint16_t sdlr_last_phy_event_list_descr_index; + uint8_t _reserved7[10]; + uint8_t sdlr_vendor[16]; + uint8_t sdlr_descrs[1]; /* short or long format */ +} smp_discover_list_resp_t; + +/* + * SAS-2 10.4.3.16 REPORT PHY EVENT LIST + */ +typedef struct smp_report_phy_event_list_req { + uint8_t _reserved1[2]; + uint16_t srpelr_starting_descr_index; +} smp_report_phy_event_list_req_t; + +typedef struct smp_phy_event_list_descr { + uint8_t _reserved1[2]; + uint8_t speld_phy_identifier; + uint8_t speld_phy_event_source; + uint32_t speld_phy_event; + uint32_t speld_peak_detector_threshold; +} smp_phy_event_list_descr_t; + +typedef struct smp_report_phy_event_list_resp { + uint16_t srpelr_exp_change_count; + uint16_t srpelr_starting_descr_index; + uint16_t srpelr_last_descr_index; + uint8_t srpelr_phy_event_list_descr_length; + uint8_t _reserved1[3]; + uint8_t srpelr_n_descrs; + smp_phy_event_list_descr_t srpelr_descrs[1]; +} smp_report_phy_event_list_resp_t; + +/* + * SAS-2 10.4.3.17 REPORT EXPANDER ROUTE TABLE LIST + */ +typedef struct smp_report_exp_route_table_list_req { + uint8_t _reserved1[4]; + uint16_t srertlr_max_descrs; + uint16_t srertlr_starting_routed_sas_addr_index; + uint8_t _reserved2[7]; + uint8_t srertlr_starting_phy_identifier; + uint8_t _reserved3[8]; +} smp_report_exp_route_table_list_req_t; + +typedef struct smp_route_table_descr { + uint64_t srtd_routed_sas_addr; + uint8_t srtd_phy_bitmap[6]; + DECL_BITFIELD2( + _reserved1 :7, + srtd_zone_group_valid :1); + uint8_t srtd_zone_group; +} smp_route_table_descr_t; + +#define SMP_ROUTE_PHY(_d, _s, _i) \ + ((_d)->srtd_phy_bitmap[(48 - (_i) + (_s)) >> 3] & \ + (1 << ((48 - (_i) + (_s)) & 7))) + +typedef struct smp_report_exp_route_table_list_resp { + uint16_t srertlr_exp_change_count; + uint16_t srertlr_route_table_change_count; + DECL_BITFIELD5( + srertlr_zoning_enabled :1, + srertlr_configuring :1, + srertlr_zone_configuring :1, + srertlr_self_configuring :1, + _reserved2 :4); + uint8_t _reserved3; + uint8_t srertlr_descr_length; + uint8_t srertlr_n_descrs; + uint16_t srertlr_first_routed_sas_addr_index; + uint16_t srertlr_last_routed_sas_addr_index; + uint8_t _reserved4[3]; + uint8_t srertlr_starting_phy_identifier; + uint8_t _reserved5[12]; + smp_route_table_descr_t srertlr_descrs[1]; +} smp_report_exp_route_table_list_resp_t; + +/* + * SAS-2 10.4.3.18 CONFIGURE GENERAL (no additional response) + */ +typedef struct smp_config_general_req { + uint16_t scgr_expected_exp_change_count; + uint8_t _reserved1[2]; + DECL_BITFIELD6( + scgr_update_stp_bus_inactivity :1, + scgr_update_stp_max_conn :1, + scgr_update_stp_smp_nexus_loss :1, + scgr_update_initial_time_to_reduced_functionality :1, + scgr_update_stp_reject_to_open :1, + _reserved2 :3); + uint8_t _reserved3; + uint16_t scgr_stp_bus_inactivity; + uint16_t scgr_stp_max_conn; + uint16_t scgr_stp_smp_nexus_loss; + uint8_t scgr_initial_time_to_reduced_functionality; + uint8_t _reserved4; + uint16_t scgr_stp_reject_to_open; +} smp_config_general_req_t; + +/* + * SAS-2 10.4.3.19 ENABLE DISABLE ZONING (no additional response) + */ +typedef struct smp_enable_disable_zoning_req { + uint16_t sedzr_expected_exp_change_count; + DECL_BITFIELD2( + sedzr_save :2, /* smp_zoning_save_t */ + _reserved1 :6); + uint8_t _reserved2; + DECL_BITFIELD2( + sedzr_enable_disable_zoning :2, + _reserved3 :6); + uint8_t _reserved4[3]; +} smp_enable_disable_zoning_req_t; + +typedef enum smp_zoning_save { + SMP_ZONING_SAVE_CURRENT = 0x0, + SMP_ZONING_SAVE_SAVED = 0x1, + SMP_ZONING_SAVE_BOTH_IF_SUPP = 0x2, + SMP_ZONING_SAVE_BOTH = 0x3 +} smp_zoning_save_t; + +typedef enum smp_zoning_enable_op { + SMP_ZONING_ENABLE_OP_NONE = 0x0, + SMP_ZONING_ENABLE_OP_ENABLE = 0x1, + SMP_ZONING_ENABLE_OP_DISABLE = 0x2 +} smp_zoning_enable_op_t; + +/* + * SAS-2 10.4.3.20 ZONED BROADCAST (no additional response) + */ +typedef struct smp_zoned_broadcast_req { + uint8_t _restricted1[2]; + DECL_BITFIELD2( + szbr_broadcast_type :4, + _reserved :4); + uint8_t szbr_n_broadcast_source_zone_groups; + uint8_t szbr_broadcast_source_zone_groups[1]; +} smp_zoned_broadcast_req_t; + +/* + * SAS-2 10.4.3.21 ZONE LOCK + */ +typedef struct smp_zone_lock_req { + uint16_t szlr_expected_exp_change_count; + uint16_t szlr_zone_lock_inactivity_timeout; + uint8_t szlr_zone_manager_password[32]; +} smp_zone_lock_req_t; + +typedef struct smp_zone_lock_resp { + uint8_t _reserved1[4]; + uint64_t szlr_active_zone_manager_sas_addr; +} smp_zone_lock_resp_t; + +/* + * SAS-2 10.4.3.22 ZONE ACTIVATE (no additional response) + */ +typedef struct smp_zone_activate_req { + uint16_t szar_expected_exp_change_count; + uint8_t _reserved1[2]; +} smp_zone_activate_req_t; + +/* + * SAS-2 10.4.3.23 ZONE UNLOCK (no additional response) + */ +typedef struct smp_zone_unlock_req { + uint8_t _restricted1[2]; + DECL_BITFIELD2( + szur_activate_required :1, + _reserved1 :7); + uint8_t _reserved2; +} smp_zone_unlock_req_t; + +/* + * SAS-2 10.4.3.24 CONFIGURE ZONE MANAGER PASSWORD (no additional response) + */ +typedef struct smp_config_zone_manager_password_req { + uint16_t sczmpr_expected_exp_change_count; + DECL_BITFIELD2( + sczmpr_save :2, /* smp_zoning_save_t */ + _reserved1 :6); + uint8_t _reserved2; + uint8_t sczmpr_zone_manager_password[32]; + uint8_t sczmpr_new_zone_manager_password[32]; +} smp_config_zone_manager_password_req_t; + +/* + * SAS-2 10.4.3.25 CONFIGURE ZONE PHY INFORMATION (no additional response) + */ +typedef struct smp_zone_phy_config_descr { + uint8_t szpcd_phy_identifier; + DECL_BITFIELD6( + _reserved1 :2, + szpcd_zone_group_persistent :1, + _reserved2 :1, + szpcd_requested_inside_zpsds :1, + szpcd_inside_zpsds_persistent :1, + _reserved3 :2); + uint8_t _reserved4; + uint8_t szpcd_zone_group; +} smp_zone_phy_config_descr_t; + +typedef struct smp_config_zone_phy_info_req { + uint16_t sczpir_expected_exp_change_count; + DECL_BITFIELD2( + sczpir_save :2, /* smp_zoning_save_t */ + _reserved1 :6); + uint8_t sczpir_n_descrs; + smp_zone_phy_config_descr_t sczpir_descrs[1]; +} smp_config_zone_phy_info_req_t; + +/* + * SAS-2 10.4.3.26 CONFIGURE ZONE PERMISSION TABLE (no additional response) + */ +typedef struct smp_config_zone_perm_table_req { + uint16_t sczptr_expected_exp_change_count; + uint8_t sczptr_starting_source_zone_group; + uint8_t sczptr_n_descrs; + DECL_BITFIELD3( + sczptr_save :2, /* smp_zoning_save_t */ + _reserved1 :4, + sczptr_n_zone_groups :2); /* smp_n_zone_grps_t */ + uint8_t _reserved2[7]; + uint8_t sczptr_descrs[1]; /* smp_zone_perm_descrXXX_t */ +} smp_config_zone_perm_table_req_t; + +/* + * SAS-2 10.4.3.27 CONFIGURE ROUTE INFORMATION (no additional response) + */ +typedef struct smp_config_route_info_req { + uint16_t scrir_expected_exp_change_count; + uint16_t scrir_exp_route_index; + uint8_t _reserved1; + uint8_t scrir_phy_identifier; + uint8_t _reserved2[2]; + DECL_BITFIELD2( + _reserved3 :7, + scrir_disable_exp_route_entry :1); + uint8_t _reserved4[3]; + uint64_t scrir_routed_sas_addr; + uint8_t _reserved5[16]; +} smp_config_route_info_req_t; + +/* + * SAS-2 10.4.3.28 PHY CONTROL (no additional response) + */ +typedef struct smp_phy_control_req { + uint16_t spcr_expected_exp_change_count; + uint8_t _reserved1[3]; + uint8_t spcr_phy_identifier; + uint8_t spcr_phy_operation; + DECL_BITFIELD2( + spcr_update_partial_pwy_timeout :1, + _reserved2 :7); + uint8_t _reserved3[12]; + uint64_t spcr_attached_device_name; + DECL_BITFIELD2( + _reserved4 :4, + spcr_prog_min_phys_link_rate :4); /* smp_link_rate_t */ + DECL_BITFIELD2( + _reserved5 :4, + spcr_prog_max_phys_link_rate :4); /* smp_link_rate_t */ + uint8_t _reserved6[2]; + DECL_BITFIELD2( + spcr_partial_pwy_timeout :4, + _reserved7 :4); + uint8_t _reserved8[3]; +} smp_phy_control_req_t; + +typedef enum smp_phy_op { + SMP_PHY_OP_NOP = 0x00, + SMP_PHY_OP_LINK_RESET = 0x01, + SMP_PHY_OP_HARD_RESET = 0x02, + SMP_PHY_OP_DISABLE = 0x03, + SMP_PHY_OP_CLEAR_ERROR_LOG = 0x05, + SMP_PHY_OP_CLEAR_AFFILIATION = 0x06, + SMP_PHY_OP_TRANSMIT_SATA_PORT_SELECTION_SIGNAL = 0x07, + SMP_PHY_OP_CLEAR_STP_NEXUS_LOSS = 0x08, + SMP_PHY_OP_SET_ATTACHED_DEVICE_NAME = 0x09 +} smp_phy_op_t; + +/* + * SAS-2 10.4.3.29 PHY TEST FUNCTION (no additional response) + */ +typedef struct smp_phy_test_function_req { + uint16_t sptfr_expected_exp_change_count; + uint8_t _reserved1[3]; + uint8_t sptfr_phy_identifier; + uint8_t sptfr_phy_test_function; + uint8_t sptfr_phy_test_pattern; /* smp_phy_test_function_t */ + uint8_t _reserved2[3]; + DECL_BITFIELD4( + sptfr_test_pattern_phys_link_rate :4, /* smp_link_rate_t */ + sptfr_test_pattern_ssc :2, + sptfr_test_pattern_sata :1, + _reserved3 :1); + uint8_t _reserved4[3]; + uint8_t sptfr_phy_test_pattern_dwords_ctl; + uint8_t sptfr_phy_test_pattern_dwords[8]; + uint8_t _reserved5[12]; +} smp_phy_test_function_req_t; + +typedef enum smp_phy_test_function { + SMP_PHY_TEST_FN_STOP = 0x00, + SMP_PHY_TEST_FN_TRANSMIT_PATTERN = 0x01 +} smp_phy_test_function_t; + +/* + * SAS-2 10.4.3.30 CONFIGURE PHY EVENT (no additional response) + */ +typedef struct smp_phy_event_config_descr { + uint8_t _reserved1[3]; + uint8_t specd_phy_event_source; + uint32_t specd_peak_value_detector_threshold; +} smp_phy_event_config_descr_t; + +typedef struct smp_config_phy_event_req { + uint16_t scper_expected_exp_change_count; + DECL_BITFIELD2( + scper_clear_peaks :1, + _reserved1 :7); + uint8_t _reserved2[2]; + uint8_t scper_phy_identifier; + uint8_t _reserved3; + uint8_t scper_n_descrs; + smp_phy_event_config_descr_t scper_descrs[1]; +} smp_config_phy_event_req_t; + +#pragma pack() + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_GENERIC_SMP_FRAMES_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/generic/status.h b/illumos-x86_64/usr/include/sys/scsi/generic/status.h new file mode 100644 index 00000000..5638dc63 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/generic/status.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_GENERIC_STATUS_H +#define _SYS_SCSI_GENERIC_STATUS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SCSI status completion block + * + * The SCSI standard specifies one byte of status. + */ + +/* + * The definition of of the Status block as a bitfield + */ + +struct scsi_status { +#if defined(_BIT_FIELDS_LTOH) + uchar_t sts_vu0 : 1, /* vendor unique */ + sts_chk : 1, /* check condition */ + sts_cm : 1, /* condition met */ + sts_busy : 1, /* device busy or reserved */ + sts_is : 1, /* intermediate status sent */ + sts_vu6 : 1, /* vendor unique */ + sts_vu7 : 1, /* vendor unique */ + sts_resvd : 1; /* reserved */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t sts_resvd : 1, /* reserved */ + sts_vu7 : 1, /* vendor unique */ + sts_vu6 : 1, /* vendor unique */ + sts_is : 1, /* intermediate status sent */ + sts_busy : 1, /* device busy or reserved */ + sts_cm : 1, /* condition met */ + sts_chk : 1, /* check condition */ + sts_vu0 : 1; /* vendor unique */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ +}; +#define sts_scsi2 sts_vu6 /* SCSI modifier bit */ + +/* + * if auto request sense has been enabled, then use this structure + */ +struct scsi_arq_status { + struct scsi_status sts_status; + struct scsi_status sts_rqpkt_status; + uchar_t sts_rqpkt_reason; /* reason completion */ + uchar_t sts_rqpkt_resid; /* residue */ + uint_t sts_rqpkt_state; /* state of command */ + uint_t sts_rqpkt_statistics; /* statistics */ + struct scsi_extended_sense sts_sensedata; +}; + +#define SECMDS_STATUS_SIZE (sizeof (struct scsi_arq_status)) + +/* + * Bit Mask definitions, for use accessing the status as a byte. + */ + +#define STATUS_MASK 0x3E +#define STATUS_GOOD 0x00 +#define STATUS_CHECK 0x02 +#define STATUS_MET 0x04 +#define STATUS_BUSY 0x08 +#define STATUS_INTERMEDIATE 0x10 +#define STATUS_SCSI2 0x20 +#define STATUS_INTERMEDIATE_MET 0x14 +#define STATUS_RESERVATION_CONFLICT 0x18 +#define STATUS_TERMINATED 0x22 +#define STATUS_QFULL 0x28 +#define STATUS_ACA_ACTIVE 0x30 +#define STATUS_TASK_ABORT 0x40 + +#ifdef __cplusplus +} +#endif + +/* + * Some deviations from the one byte of Status are known. Each + * implementation will define them specifically + */ + +#include + +#endif /* _SYS_SCSI_GENERIC_STATUS_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/commands.h b/illumos-x86_64/usr/include/sys/scsi/impl/commands.h new file mode 100644 index 00000000..646074c8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/commands.h @@ -0,0 +1,690 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_SCSI_IMPL_COMMANDS_H +#define _SYS_SCSI_IMPL_COMMANDS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Implementation dependent command definitions. + * This file is included by + */ + +/* + * Implementation dependent view of a SCSI command descriptor block + */ + +/* + * Standard SCSI control blocks definitions. + * + * These go in or out over the SCSI bus. + * + * The first 8 bits of the command block are the same for all + * defined command groups. The first byte is an operation which consists + * of a command code component and a group code component. + * + * The group code determines the length of the rest of the command. + * Group 0 commands are 6 bytes, Group 1 and 2 are 10 bytes, Group 4 + * are 16 bytes, and Group 5 are 12 bytes. Groups 3 is Reserved. + * Groups 6 and 7 are Vendor Unique. + * + */ +#define CDB_SIZE CDB_GROUP5 /* deprecated, do not use */ +#define SCSI_CDB_SIZE CDB_GROUP4 /* sizeof (union scsi_cdb) */ + +union scsi_cdb { /* scsi command description block */ + struct { + uchar_t cmd; /* cmd code (byte 0) */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t tag :5; /* rest of byte 1 */ + uchar_t lun :3; /* lun (byte 1) (reserved in SCSI-3) */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t lun :3, /* lun (byte 1) (reserved in SCSI-3) */ + tag :5; /* rest of byte 1 */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + union { + + uchar_t scsi[SCSI_CDB_SIZE-2]; + /* + * G R O U P 0 F O R M A T (6 bytes) + */ +#define scc_cmd cdb_un.cmd +#define scc_lun cdb_un.lun +#define g0_addr2 cdb_un.tag +#define g0_addr1 cdb_un.sg.g0.addr1 +#define g0_addr0 cdb_un.sg.g0.addr0 +#define g0_count0 cdb_un.sg.g0.count0 +#define g0_vu_1 cdb_un.sg.g0.vu_57 +#define g0_vu_0 cdb_un.sg.g0.vu_56 +#define g0_naca cdb_un.sg.g0.naca +#define g0_flag cdb_un.sg.g0.flag +#define g0_link cdb_un.sg.g0.link + /* + * defines for SCSI tape cdb. + */ +#define t_code cdb_un.tag +#define high_count cdb_un.sg.g0.addr1 +#define mid_count cdb_un.sg.g0.addr0 +#define low_count cdb_un.sg.g0.count0 + struct scsi_g0 { + uchar_t addr1; /* middle part of address */ + uchar_t addr0; /* low part of address */ + uchar_t count0; /* usually block count */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t link :1; /* another command follows */ + uchar_t flag :1; /* interrupt when done */ + uchar_t naca :1; /* normal ACA */ + uchar_t rsvd :3; /* reserved */ + uchar_t vu_56 :1; /* vendor unique (byte 5 bit6) */ + uchar_t vu_57 :1; /* vendor unique (byte 5 bit7) */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t vu_57 :1; /* vendor unique (byte 5 bit 7) */ + uchar_t vu_56 :1; /* vendor unique (byte 5 bit 6) */ + uchar_t rsvd :3; /* reserved */ + uchar_t naca :1; /* normal ACA */ + uchar_t flag :1; /* interrupt when done */ + uchar_t link :1; /* another command follows */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + } g0; + + + /* + * G R O U P 1, 2 F O R M A T (10 byte) + */ +#define g1_reladdr cdb_un.tag +#define g1_rsvd0 cdb_un.sg.g1.rsvd1 +#define g1_addr3 cdb_un.sg.g1.addr3 /* msb */ +#define g1_addr2 cdb_un.sg.g1.addr2 +#define g1_addr1 cdb_un.sg.g1.addr1 +#define g1_addr0 cdb_un.sg.g1.addr0 /* lsb */ +#define g1_count1 cdb_un.sg.g1.count1 /* msb */ +#define g1_count0 cdb_un.sg.g1.count0 /* lsb */ +#define g1_vu_1 cdb_un.sg.g1.vu_97 +#define g1_vu_0 cdb_un.sg.g1.vu_96 +#define g1_naca cdb_un.sg.g1.naca +#define g1_flag cdb_un.sg.g1.flag +#define g1_link cdb_un.sg.g1.link + struct scsi_g1 { + uchar_t addr3; /* most sig. byte of address */ + uchar_t addr2; + uchar_t addr1; + uchar_t addr0; + uchar_t rsvd1; /* reserved (byte 6) */ + uchar_t count1; /* transfer length (msb) */ + uchar_t count0; /* transfer length (lsb) */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t link :1; /* another command follows */ + uchar_t flag :1; /* interrupt when done */ + uchar_t naca :1; /* normal ACA */ + uchar_t rsvd0 :3; /* reserved */ + uchar_t vu_96 :1; /* vendor unique (byte 9 bit6) */ + uchar_t vu_97 :1; /* vendor unique (byte 9 bit7) */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t vu_97 :1; /* vendor unique (byte 9 bit 7) */ + uchar_t vu_96 :1; /* vendor unique (byte 9 bit 6) */ + uchar_t rsvd0 :3; /* reserved */ + uchar_t naca :1; /* normal ACA */ + uchar_t flag :1; /* interrupt when done */ + uchar_t link :1; /* another command follows */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + } g1; + + /* + * G R O U P 4 F O R M A T (16 byte) + */ +#define g4_reladdr cdb_un.tag +#define g4_addr3 cdb_un.sg.g4.addr3 /* msb */ +#define g4_addr2 cdb_un.sg.g4.addr2 +#define g4_addr1 cdb_un.sg.g4.addr1 +#define g4_addr0 cdb_un.sg.g4.addr0 /* lsb */ +#define g4_addtl_cdb_data3 cdb_un.sg.g4.addtl_cdb_data3 +#define g4_addtl_cdb_data2 cdb_un.sg.g4.addtl_cdb_data2 +#define g4_addtl_cdb_data1 cdb_un.sg.g4.addtl_cdb_data1 +#define g4_addtl_cdb_data0 cdb_un.sg.g4.addtl_cdb_data0 +#define g4_count3 cdb_un.sg.g4.count3 /* msb */ +#define g4_count2 cdb_un.sg.g4.count2 +#define g4_count1 cdb_un.sg.g4.count1 +#define g4_count0 cdb_un.sg.g4.count0 /* lsb */ +#define g4_rsvd0 cdb_un.sg.g4.rsvd1 +#define g4_vu_1 cdb_un.sg.g4.vu_157 +#define g4_vu_0 cdb_un.sg.g4.vu_156 +#define g4_naca cdb_un.sg.g4.naca +#define g4_flag cdb_un.sg.g4.flag +#define g4_link cdb_un.sg.g4.link + struct scsi_g4 { + uchar_t addr3; /* most sig. byte of address */ + uchar_t addr2; + uchar_t addr1; + uchar_t addr0; + uchar_t addtl_cdb_data3; + uchar_t addtl_cdb_data2; + uchar_t addtl_cdb_data1; + uchar_t addtl_cdb_data0; + uchar_t count3; /* transfer length (msb) */ + uchar_t count2; + uchar_t count1; + uchar_t count0; /* transfer length (lsb) */ + uchar_t rsvd1; /* reserved */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t link :1; /* another command follows */ + uchar_t flag :1; /* interrupt when done */ + uchar_t naca :1; /* normal ACA */ + uchar_t rsvd0 :3; /* reserved */ + uchar_t vu_156 :1; /* vendor unique (byte 15 bit6) */ + uchar_t vu_157 :1; /* vendor unique (byte 15 bit7) */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t vu_157 :1; /* vendor unique (byte 15 bit 7) */ + uchar_t vu_156 :1; /* vendor unique (byte 15 bit 6) */ + uchar_t rsvd0 :3; /* reserved */ + uchar_t naca :1; /* normal ACA */ + uchar_t flag :1; /* interrupt when done */ + uchar_t link :1; /* another command follows */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + } g4; + + /* + * G R O U P 5 F O R M A T (12 byte) + */ +#define scc5_reladdr cdb_un.tag +#define scc5_addr3 cdb_un.sg.g5.addr3 /* msb */ +#define scc5_addr2 cdb_un.sg.g5.addr2 +#define scc5_addr1 cdb_un.sg.g5.addr1 +#define scc5_addr0 cdb_un.sg.g5.addr0 /* lsb */ +#define scc5_count3 cdb_un.sg.g5.count3 /* msb */ +#define scc5_count2 cdb_un.sg.g5.count2 +#define scc5_count1 cdb_un.sg.g5.count1 +#define scc5_count0 cdb_un.sg.g5.count0 /* lsb */ +#define scc5_rsvd0 cdb_un.sg.g5.rsvd1 +#define scc5_vu_1 cdb_un.sg.g5.v117 +#define scc5_vu_0 cdb_un.sg.g5.v116 +#define scc5_naca cdb_un.sg.g5.naca +#define scc5_flag cdb_un.sg.g5.flag +#define scc5_link cdb_un.sg.g5.link + struct scsi_g5 { + uchar_t addr3; /* most sig. byte of address */ + uchar_t addr2; + uchar_t addr1; + uchar_t addr0; + uchar_t count3; /* most sig. byte of count */ + uchar_t count2; + uchar_t count1; + uchar_t count0; + uchar_t rsvd1; /* reserved */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t link :1; /* another command follows */ + uchar_t flag :1; /* interrupt when done */ + uchar_t naca :1; /* normal ACA */ + uchar_t rsvd0 :3; /* reserved */ + uchar_t vu_116 :1; /* vendor unique (byte 11 bit6) */ + uchar_t vu_117 :1; /* vendor unique (byte 11 bit7) */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t vu_117 :1; /* vendor unique (byte 11 bit 7) */ + uchar_t vu_116 :1; /* vendor unique (byte 11 bit 6) */ + uchar_t rsvd0 :3; /* reserved */ + uchar_t naca :1; /* normal ACA */ + uchar_t flag :1; /* interrupt when done */ + uchar_t link :1; /* another command follows */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + } g5; + }sg; + } cdb_un; + uchar_t cdb_opaque[SCSI_CDB_SIZE]; /* addressed as opaque char array */ + uint_t cdb_long[SCSI_CDB_SIZE / sizeof (uint_t)]; /* as a word array */ +}; + + +/* + * Various useful Macros for SCSI commands + */ + +/* + * defines for getting/setting fields in data received from or destined for + * a SCSI device. These macros are necessary (in place of BE16/BE32/BE64) + * because the address to be read or written may not be on a proper alignment. + */ + +#define SCSI_READ16(Sr16_Addr) \ + (((uint16_t)*((uint8_t *)(Sr16_Addr)) << 8) | \ + ((uint16_t)*((uint8_t *)(Sr16_Addr)+1))) + +#define SCSI_READ24(Sr32_Addr) \ + (((uint32_t)*((uint8_t *)(Sr32_Addr)) << 16) | \ + ((uint32_t)*((uint8_t *)(Sr32_Addr)+1) << 8) | \ + ((uint32_t)*((uint8_t *)(Sr32_Addr)+2))) + +#define SCSI_READ32(Sr32_Addr) \ + (((uint32_t)*((uint8_t *)(Sr32_Addr)) << 24) | \ + ((uint32_t)*((uint8_t *)(Sr32_Addr)+1) << 16) | \ + ((uint32_t)*((uint8_t *)(Sr32_Addr)+2) << 8) | \ + ((uint32_t)*((uint8_t *)(Sr32_Addr)+3))) + +#define SCSI_READ40(Sr64_Addr) \ + (((uint64_t)*((uint8_t *)(Sr64_Addr)) << 32) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+1) << 24) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+2) << 16) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+3) << 8) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+4))) + +#define SCSI_READ48(Sr64_Addr) \ + (((uint64_t)*((uint8_t *)(Sr64_Addr)) << 40) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+1) << 32) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+2) << 24) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+3) << 16) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+4) << 8) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+5))) + +#define SCSI_READ64(Sr64_Addr) \ + (((uint64_t)*((uint8_t *)(Sr64_Addr)) << 56) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+1) << 48) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+2) << 40) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+3) << 32) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+4) << 24) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+5) << 16) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+6) << 8) | \ + ((uint64_t)*((uint8_t *)(Sr64_Addr)+7))) + +#define SCSI_WRITE16(Sr16_Addr, Sr16_Val) \ + *((uint8_t *)(Sr16_Addr)) = (((uint16_t)(Sr16_Val) >> 8) & 0xff), \ + *((uint8_t *)(Sr16_Addr)+1) = ((uint16_t)(Sr16_Val) & 0xff) + +#define SCSI_WRITE24(Sr24_Addr, Sr24_Val) \ + SCSI_WRITE16((Sr24_Addr), ((Sr24_Val) & 0xffff00) >> 8), \ + *((uint8_t *)(Sr24_Addr)+2) = ((uint8_t)((Sr24_Val) & 0xff)) + +#define SCSI_WRITE32(Sr32_Addr, Sr32_Val) \ + *(uint8_t *)(Sr32_Addr) = (((uint32_t)(Sr32_Val) >> 24) & 0xff), \ + *((uint8_t *)(Sr32_Addr)+1) = \ + (((uint32_t)(Sr32_Val) >> 16) & 0xff), \ + *((uint8_t *)(Sr32_Addr)+2) = (((uint32_t)(Sr32_Val) >> 8) & 0xff), \ + *((uint8_t *)(Sr32_Addr)+3) = (((uint32_t)(Sr32_Val)) & 0xff) + +#define SCSI_WRITE40(Sr40_Addr, Sr40_Val) \ + SCSI_WRITE32((Sr40_Addr), ((Sr40_Val) & 0xffffffff00ULL) >> 8), \ + *((uint8_t *)(Sr40_Addr)+4) = ((uint8_t)(Sr40_Val) & 0xff) + +#define SCSI_WRITE48(Sr48_Addr, Sr40_Val) \ + SCSI_WRITE32((Sr48_Addr), ((Sr48_Val) & 0xffffffff0000ULL) >> 16), \ + SCSI_WRITE16((uint8_t *)(Sr48_Addr)+4, (Sr40_Val) & 0xffff) + +#define SCSI_WRITE64(Sr64_Addr, Sr64_Val) \ + *(uint8_t *)(Sr64_Addr) = (((uint64_t)(Sr64_Val) >> 56) & 0xff), \ + *((uint8_t *)(Sr64_Addr)+1) = \ + (((uint64_t)(Sr64_Val) >> 48) & 0xff), \ + *((uint8_t *)(Sr64_Addr)+2) = \ + (((uint64_t)(Sr64_Val) >> 40) & 0xff), \ + *((uint8_t *)(Sr64_Addr)+3) = \ + (((uint64_t)(Sr64_Val) >> 32) & 0xff), \ + *((uint8_t *)(Sr64_Addr)+4) = \ + (((uint64_t)(Sr64_Val) >> 24) & 0xff), \ + *((uint8_t *)(Sr64_Addr)+5) = \ + (((uint64_t)(Sr64_Val) >> 16) & 0xff), \ + *((uint8_t *)(Sr64_Addr)+6) = \ + (((uint64_t)(Sr64_Val) >> 8) & 0xff), \ + *((uint8_t *)(Sr64_Addr)+7) = (((uint64_t)(Sr64_Val)) & 0xff) + +/* + * These macros deal with unaligned data that crosses a byte boundary. + */ +#define SCSI_MK8(ms, ls) \ + (((uint8_t)(ms) << 4) | (uint8_t)ls) + +#define SCSI_MK12_4_8(ms, ls) \ + (((uint16_t)(ms) << 8) | (uint16_t)(ls)) +#define SCSI_MK12_8_4(ms, ls) \ + (((uint16_t)(ms) << 4) | (uint16_t)(ls)) + +#define SCSI_MK16_4_8_4(hi, mid, lo) \ + (((uint16_t)(hi) << 12) | ((uint16_t)(mid) << 4) | (uint16_t)(lo)) + +#define SCSI_MK20_4_16(ms, ls) \ + (((uint32_t)(ms) << 16) | ((uint32_t)(ls))) +#define SCSI_MK20_16_4(ms, ls) \ + (((uint32_t)(ms) << 4) | ((uint32_t)(ls))) + +#define SCSI_MK24_4_16_4(hi, mid, lo) \ + (((uint32_t)(hi) << 20) | ((uint32_t)(mid) << 4) | (uint32_t)(lo)) + +#define SCSI_MK36_4_32(ms, ls) \ + (((uint64_t)(ms) << 32) | (uint64_t)(ls)) +#define SCSI_MK36_32_4(ms, ls) \ + (((uint64_t)(ms) << 4) | (uint64_t)(ls)) + +/* + * defines for getting/setting fields within the various command groups + */ + +#define GETCMD(cdb) ((cdb)->scc_cmd & 0x1F) +#define GETGROUP(cdb) (CDB_GROUPID((cdb)->scc_cmd)) + +#define FORMG0COUNT(cdb, cnt) (cdb)->g0_count0 = (cnt) + +#define FORMG0ADDR(cdb, addr) (cdb)->g0_addr2 = (addr) >> 16; \ + (cdb)->g0_addr1 = ((addr) >> 8) & 0xFF; \ + (cdb)->g0_addr0 = (addr) & 0xFF + +#define GETG0COUNT(cdb) (cdb)->g0_count0 + +#define GETG0ADDR(cdb) ((((cdb)->g0_addr2 & 0x1F) << 16) + \ + ((cdb)->g0_addr1 << 8) + ((cdb)->g0_addr0)) + +#define GETG0TAG(cdb) ((cdb)->g0_addr2) + +#define FORMG0COUNT_S(cdb, cnt) (cdb)->high_count = (cnt) >> 16; \ + (cdb)->mid_count = ((cnt) >> 8) & 0xFF; \ + (cdb)->low_count = (cnt) & 0xFF + +#define FORMG1COUNT(cdb, cnt) (cdb)->g1_count1 = ((cnt) >> 8); \ + (cdb)->g1_count0 = (cnt) & 0xFF + +#define FORMG1ADDR(cdb, addr) (cdb)->g1_addr3 = (addr) >> 24; \ + (cdb)->g1_addr2 = ((addr) >> 16) & 0xFF; \ + (cdb)->g1_addr1 = ((addr) >> 8) & 0xFF; \ + (cdb)->g1_addr0 = (addr) & 0xFF + +#define GETG1COUNT(cdb) (((cdb)->g1_count1 << 8) + ((cdb)->g1_count0)) + +#define GETG1ADDR(cdb) (((cdb)->g1_addr3 << 24) + \ + ((cdb)->g1_addr2 << 16) + \ + ((cdb)->g1_addr1 << 8) + \ + ((cdb)->g1_addr0)) + +#define GETG1TAG(cdb) (cdb)->g1_reladdr + +#define FORMG4COUNT(cdb, cnt) (cdb)->g4_count3 = ((cnt) >> 24); \ + (cdb)->g4_count2 = ((cnt) >> 16) & 0xFF; \ + (cdb)->g4_count1 = ((cnt) >> 8) & 0xFF; \ + (cdb)->g4_count0 = (cnt) & 0xFF + +#define FORMG4LONGADDR(cdb, addr) (cdb)->g4_addr3 = (addr) >> 56; \ + (cdb)->g4_addr2 = \ + ((addr) >> 48) & 0xFF; \ + (cdb)->g4_addr1 = \ + ((addr) >> 40) & 0xFF; \ + (cdb)->g4_addr0 = \ + ((addr) >> 32) & 0xFF; \ + (cdb)->g4_addtl_cdb_data3 = \ + ((addr) >> 24) & 0xFF; \ + (cdb)->g4_addtl_cdb_data2 = \ + ((addr) >> 16) & 0xFF; \ + (cdb)->g4_addtl_cdb_data1 = \ + ((addr) >> 8) & 0xFF; \ + (cdb)->g4_addtl_cdb_data0 = \ + (addr) & 0xFF + +#define GETG4COUNT(cdb) (((cdb)->g4_count3 << 24) + \ + ((cdb)->g4_count2 << 16) + \ + ((cdb)->g4_count1 << 8) + \ + ((cdb)->g4_count0)) + +#define GETG4LONGADDR(cdb) (((diskaddr_t)(cdb)->g4_addr3 << 56) + \ + ((diskaddr_t)(cdb)->g4_addr2 << 48) + \ + ((diskaddr_t)(cdb)->g4_addr1 << 40) + \ + ((diskaddr_t)(cdb)->g4_addr0 << 32) + \ + ((diskaddr_t)(cdb)->g4_addtl_cdb_data3 << 24) + \ + ((diskaddr_t)(cdb)->g4_addtl_cdb_data2 << 16) + \ + ((diskaddr_t)(cdb)->g4_addtl_cdb_data1 << 8) + \ + ((diskaddr_t)(cdb)->g4_addtl_cdb_data0)) + +#define FORMG4ADDR(cdb, addr) (cdb)->g4_addr3 = (addr) >> 24; \ + (cdb)->g4_addr2 = ((addr) >> 16) & 0xFF; \ + (cdb)->g4_addr1 = ((addr) >> 8) & 0xFF; \ + (cdb)->g4_addr0 = (addr) & 0xFF + +#define FORMG4ADDTL(cdb, addtl_cdb_data) (cdb)->g4_addtl_cdb_data3 = \ + (addtl_cdb_data) >> 24; \ + (cdb)->g4_addtl_cdb_data2 = \ + ((addtl_cdb_data) >> 16) & 0xFF; \ + (cdb)->g4_addtl_cdb_data1 = \ + ((addtl_cdb_data) >> 8) & 0xFF; \ + (cdb)->g4_addtl_cdb_data0 = \ + (addtl_cdb_data) & 0xFF + +#define GETG4ADDR(cdb) ((cdb)->g4_addr3 << 24) + \ + ((cdb)->g4_addr2 << 16) + \ + ((cdb)->g4_addr1 << 8) + \ + ((cdb)->g4_addr0) + +#define GETG4ADDRTL(cdb) (((cdb)->g4_addtl_cdb_data3 << 24) + \ + ((cdb)->g4_addtl_cdb_data2 << 16) + \ + ((cdb)->g4_addtl_cdb_data1 << 8) + \ + (cdb)->g4_addtl_cdb_data0) + +#define GETG4TAG(cdb) (cdb)->g4_reladdr + +#define FORMG5COUNT(cdb, cnt) (cdb)->scc5_count3 = ((cnt) >> 24); \ + (cdb)->scc5_count2 = ((cnt) >> 16) & 0xFF; \ + (cdb)->scc5_count1 = ((cnt) >> 8) & 0xFF; \ + (cdb)->scc5_count0 = (cnt) & 0xFF + +#define FORMG5ADDR(cdb, addr) (cdb)->scc5_addr3 = (addr) >> 24; \ + (cdb)->scc5_addr2 = ((addr) >> 16) & 0xFF; \ + (cdb)->scc5_addr1 = ((addr) >> 8) & 0xFF; \ + (cdb)->scc5_addr0 = (addr) & 0xFF + +#define GETG5ADDR(cdb) ((cdb)->scc5_addr3 << 24) + \ + ((cdb)->scc5_addr2 << 16) + \ + ((cdb)->scc5_addr1 << 8) + \ + ((cdb)->scc5_addr0) + +#define GETG5COUNT(cdb) ((cdb)->scc5_count3 << 24) + \ + ((cdb)->scc5_count2 << 16) + \ + ((cdb)->scc5_count1 << 8) + \ + ((cdb)->scc5_count0) + +#define GETG5TAG(cdb) (cdb)->scc5_reladdr + + +/* + * Shorthand macros for forming commands + * + * Works only with pre-SCSI-3 because they put lun as part of CDB. + * scsi_setup_cdb() is the recommended interface. + */ + +#define MAKECOM_COMMON(pktp, devp, flag, cmd) \ + (pktp)->pkt_address = (devp)->sd_address, \ + (pktp)->pkt_flags = (flag), \ + ((union scsi_cdb *)(pktp)->pkt_cdbp)->scc_cmd = (cmd), \ + ((union scsi_cdb *)(pktp)->pkt_cdbp)->scc_lun = \ + (pktp)->pkt_address.a_lun + +#define MAKECOM_G0(pktp, devp, flag, cmd, addr, cnt) \ + MAKECOM_COMMON((pktp), (devp), (flag), (cmd)), \ + FORMG0ADDR(((union scsi_cdb *)(pktp)->pkt_cdbp), (addr)), \ + FORMG0COUNT(((union scsi_cdb *)(pktp)->pkt_cdbp), (cnt)) + +#define MAKECOM_G0_S(pktp, devp, flag, cmd, cnt, fixbit) \ + MAKECOM_COMMON((pktp), (devp), (flag), (cmd)), \ + FORMG0COUNT_S(((union scsi_cdb *)(pktp)->pkt_cdbp), (cnt)), \ + ((union scsi_cdb *)(pktp)->pkt_cdbp)->t_code = (fixbit) + +#define MAKECOM_G1(pktp, devp, flag, cmd, addr, cnt) \ + MAKECOM_COMMON((pktp), (devp), (flag), (cmd)), \ + FORMG1ADDR(((union scsi_cdb *)(pktp)->pkt_cdbp), (addr)), \ + FORMG1COUNT(((union scsi_cdb *)(pktp)->pkt_cdbp), (cnt)) + +#define MAKECOM_G5(pktp, devp, flag, cmd, addr, cnt) \ + MAKECOM_COMMON((pktp), (devp), (flag), (cmd)), \ + FORMG5ADDR(((union scsi_cdb *)(pktp)->pkt_cdbp), (addr)), \ + FORMG5COUNT(((union scsi_cdb *)(pktp)->pkt_cdbp), (cnt)) + + +/* + * Direct access disk format defines and parameters. + * + * This is still pretty ugly and is mostly derived + * from Emulex MD21 specific formatting. + */ + +#define fmt_parm_bits g0_addr2 /* for format options */ +#define fmt_interleave g0_count0 /* for encode interleave */ +#define defect_list_descrip g1_addr3 /* list description bits */ + +/* + * defines for value of fmt_parm_bits. + */ + +#define FPB_BFI 0x04 /* bytes-from-index fmt */ +#define FPB_CMPLT 0x08 /* full defect list provided */ +#define FPB_DATA 0x10 /* defect list data provided */ + +/* + * Defines for value of defect_list_descrip. + */ + +#define DLD_MAN_DEF_LIST 0x10 /* manufacturer's defect list */ +#define DLD_GROWN_DEF_LIST 0x08 /* grown defect list */ +#define DLD_BLOCK_FORMAT 0x00 /* block format */ +#define DLD_BFI_FORMAT 0x04 /* bytes-from-index format */ +#define DLD_PS_FORMAT 0x05 /* physical sector format */ + +/* + * Defines for value of CONTROL byte of cdb. + */ +#define CDB_FLAG_NACA 0x04 /* naca flag */ + +/* + * Disk defect list - used by format command. + */ +#define RDEF_ALL 0 /* read all defects */ +#define RDEF_MANUF 1 /* read manufacturer's defects */ +#define RDEF_CKLEN 2 /* check length of manufacturer's list */ +#define ST506_NDEFECT 127 /* must fit in 1K controller buffer... */ +#define ESDI_NDEFECT ST506_NDEFECT + +struct scsi_bfi_defect { /* defect in bytes from index format */ + unsigned cyl : 24; + unsigned head : 8; + int bytes_from_index; +}; + +struct scsi_format_params { /* BFI format list */ + ushort_t reserved; + ushort_t length; + struct scsi_bfi_defect list[ESDI_NDEFECT]; +}; + +/* + * Defect list returned by READ_DEFECT_LIST command. + */ +struct scsi_defect_hdr { /* For getting defect list size */ + uchar_t reserved; + uchar_t descriptor; + ushort_t length; +}; + +struct scsi_defect_list { /* BFI format list */ + uchar_t reserved; + uchar_t descriptor; + ushort_t length; + struct scsi_bfi_defect list[ESDI_NDEFECT]; +}; + +/* + * + * Direct Access device Reassign Block parameter + * + * Defect list format used by reassign block command (logical block format). + * + * This defect list is limited to 1 defect, as that is the only way we use it. + * + */ + +struct scsi_reassign_blk { + ushort_t reserved; + ushort_t length; /* defect length in bytes (defects * 4) */ + uint_t defect; /* Logical block address of defect */ +}; + +/* + * Direct Access Device Capacity Structure -- 8 byte version + */ + +struct scsi_capacity { + uint_t capacity; + uint_t lbasize; +}; + +/* + * Direct Access Device Capacity Structure -- 16 byte version + */ + +struct scsi_capacity_16 { + uint64_t sc_capacity; + uint_t sc_lbasize; +#if defined(_BIT_FIELDS_LTOH) + uchar_t sc_rto_en :1; + uchar_t sc_prot_en :1; + uchar_t sc_rsvd0 :6; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t sc_rsvd0 :6; + uchar_t sc_prot_en :1; + uchar_t sc_rto_en :1; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t sc_rsvd1[19]; +}; + +#ifdef _KERNEL + +/* + * Functional versions of the above macros, and other functions. + * the makecom functions have been deprecated. Please use + * scsi_setup_cdb() + */ + +extern void makecom_g0(struct scsi_pkt *pkt, struct scsi_device *devp, + int flag, int cmd, int addr, int cnt); +extern void makecom_g0_s(struct scsi_pkt *pkt, struct scsi_device *devp, + int flag, int cmd, int cnt, int fixbit); +extern void makecom_g1(struct scsi_pkt *pkt, struct scsi_device *devp, + int flag, int cmd, int addr, int cnt); +extern void makecom_g5(struct scsi_pkt *pkt, struct scsi_device *devp, + int flag, int cmd, int addr, int cnt); +extern int scsi_setup_cdb(union scsi_cdb *cdbp, uchar_t cmd, uint_t addr, + uint_t cnt, uint_t addtl_cdb_data); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_COMMANDS_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/inquiry.h b/illumos-x86_64/usr/include/sys/scsi/impl/inquiry.h new file mode 100644 index 00000000..2d72f71a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/inquiry.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_IMPL_INQUIRY_H +#define _SYS_SCSI_IMPL_INQUIRY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Implementation inquiry data that is not within + * the scope of any released SCSI standard. + */ + +/* + * Minimum inquiry data length (includes up through RDF field) + */ + +#define SUN_MIN_INQLEN 4 + +/* + * Inquiry data size definition + */ +#define SUN_INQSIZE (sizeof (struct scsi_inquiry)) + +/* + * SCSI inquiry properties. The following properties figuratively + * represent 'inquiry' data. Some of the values may be more detailed + * (longer in length) than the basic 'struct scsi_inquiry' fields. For + * example the INQUIRY_REVISION_ID field in 'struct scsi_inquiry' is + * four bytes long, but SATA's 'Identify Device Data' is eight bytes. + * In situations like this an HBA driver's tran_tgt_init(9E) + * implementation may establish different, more detailed, values than + * those returned by 'struct scsi_inquiry'. In addition some + * properties like 'serial number' and 'capacity' are never derived + * from 'struct scsi_inquiry'. Instead, the information is obtained + * from an INQUIRY command to another page (page 0x80 for serial + * number), by some other SCSI commands (like READ_CAPACITY for + * capacity), or by some HBA driver specific mechanism. + */ +#define INQUIRY_DEVICE_TYPE "inquiry-device-type" /* int */ +#define INQUIRY_VENDOR_ID "inquiry-vendor-id" /* string */ +#define INQUIRY_PRODUCT_ID "inquiry-product-id" /* string */ +#define INQUIRY_REVISION_ID "inquiry-revision-id" /* string */ +#define INQUIRY_SERIAL_NO "inquiry-serial-no" /* string */ + +#ifdef _KERNEL +int scsi_ascii_inquiry_len(char *field, size_t length); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_INQUIRY_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/mode.h b/illumos-x86_64/usr/include/sys/scsi/impl/mode.h new file mode 100644 index 00000000..bf4cc995 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/mode.h @@ -0,0 +1,266 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SCSI_IMPL_MODE_H +#define _SYS_SCSI_IMPL_MODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Defines and Structures for SCSI Mode Sense/Select data + * + * Implementation Specific variations + */ + +/* + * Variations to Sequential Access device mode header + */ +struct modeheader_seq { + uchar_t datalen; /* sense data length */ + uchar_t mediumtype; /* medium type */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t speed :4, /* speed */ + bufm :3, /* buffered mode */ + wp :1; /* write protected */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t wp :1, /* write protected */ + bufm :3, /* buffered mode */ + speed :4; /* speed */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t bd_len; /* block length in bytes */ + struct block_descriptor blk_desc; +}; + +/* + * Variations to Direct Access device pages + */ + +/* + * Page 1: CCS error recovery page was a little different than SCSI-2/3 + */ + +#define PAGELENGTH_DAD_MODE_ERR_RECOV_CCS 0x06 + +struct mode_err_recov_ccs { + struct mode_page mode_page; /* common mode page header */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t dcr : 1, /* disable correction */ + dte : 1, /* disable transfer on error */ + per : 1, /* post error */ + eec : 1, /* enable early correction */ + rc : 1, /* read continuous */ + tb : 1, /* transfer block */ + arre : 1, /* auto read realloc enabled */ + awre : 1; /* auto write realloc enabled */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t awre : 1, /* auto write realloc enabled */ + arre : 1, /* auto read realloc enabled */ + tb : 1, /* transfer block */ + rc : 1, /* read continuous */ + eec : 1, /* enable early correction */ + per : 1, /* post error */ + dte : 1, /* disable transfer on error */ + dcr : 1; /* disable correction */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t retry_count; + uchar_t correction_span; + uchar_t head_offset_count; + uchar_t strobe_offset_count; + uchar_t recovery_time_limit; +}; + +/* + * Page 3: CCS Direct Access Device Format Parameters + * + * The 0x8 bit in the Drive Type byte is used in CCS + * as an INHIBIT SAVE bit. This bit is not in SCSI-2/3. + */ + +#define _reserved_ins ins + +/* + * Page 8: SCSI-2 Cache page was a little different than SCSI-3 + */ + +#define PAGELENGTH_DAD_MODE_CACHE 0x0A + +struct mode_cache { + struct mode_page mode_page; /* common mode page header */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t rcd : 1, /* Read Cache Disable */ + mf : 1, /* Multiplication Factor */ + wce : 1, /* Write Cache Enable */ + : 5; + uchar_t write_reten_pri : 4, /* Write Retention Priority */ + read_reten_pri : 4; /* Demand Read Retention Priority */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t : 5, + wce : 1, /* Write Cache Enable */ + mf : 1, /* Multiplication Factor */ + rcd : 1; /* Read Cache Disable */ + uchar_t read_reten_pri : 4, /* Demand Read Retention Priority */ + write_reten_pri : 4; /* Write Retention Priority */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + ushort_t dis_prefetch_len; /* Disable prefetch xfer length */ + ushort_t min_prefetch; /* minimum prefetch length */ + ushort_t max_prefetch; /* maximum prefetch length */ + ushort_t prefetch_ceiling; /* max prefetch ceiling */ +}; + +/* + * Page 0x38 - This is the CCS Cache Page + */ + +struct mode_cache_ccs { + struct mode_page mode_page; /* common mode page header */ + uchar_t mode; /* Cache control and size */ + uchar_t threshold; /* Prefetch threshold */ + uchar_t max_prefetch; /* Max. prefetch */ + uchar_t max_multiplier; /* Max. prefetch multiplier */ + uchar_t min_prefetch; /* Min. prefetch */ + uchar_t min_multiplier; /* Min. prefetch multiplier */ + uchar_t rsvd2[8]; +}; + +/* + * Page A: SCSI-2 control page was a little different than SCSI-3 + */ + +#define PAGELENGTH_MODE_CONTROL 0x06 + +struct mode_control { + struct mode_page mode_page; /* common mode page header */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t rlec : 1, /* Report Log Exception bit */ + : 7; + uchar_t qdisable: 1, /* Queue disable */ + que_err : 1, /* Queue error */ + : 2, + que_mod : 4; /* Queue algorithm modifier */ + uchar_t eanp : 1, + uaaenp : 1, + raenp : 1, + : 4, + eeca : 1; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t : 7, + rlec : 1; /* Report Log Exception bit */ + uchar_t que_mod : 4, /* Queue algorithm modifier */ + : 2, + que_err : 1, /* Queue error */ + qdisable: 1; /* Queue disable */ + uchar_t eeca : 1, + : 4, + raenp : 1, + uaaenp : 1, + eanp : 1; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t reserved; + ushort_t ready_aen_holdoff; +}; + + +/* + * Emulex MD21 Unique Mode Select/Sense structure. + * This is apparently not used, although the MD21 + * documentation refers to it. + * + * The medium_type in the mode header must be 0x80 + * to indicate a vendor unique format. There is then + * a standard block descriptor page, which must be + * zeros (although the block descriptor length is set + * appropriately in the mode header). + * + * After this stuff, comes the vendor unique ESDI + * format parameters for the MD21. + * + * Notes: + * + * 1) The logical number of sectors/track should be the + * number of physical sectors/track less the number spare + * sectors/track. + * + * 2) The logical number of cylinders should be the + * number of physical cylinders less three (3) reserved + * for use by the drive, and less any alternate cylinders + * allocated. + * + * 3) head skew- see MD21 manual. + */ + +struct emulex_format_params { + uchar_t alt_cyl; /* number of alternate cylinders */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t : 1, + sst : 2, /* spare sectors per track */ + ssz : 1, /* sector size. 1 == 256 bps, 0 == 512 bps */ + nheads : 4; /* number of heads */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t nheads : 4, /* number of heads */ + ssz : 1, /* sector size. 1 == 256 bps, 0 == 512 bps */ + sst : 2, /* spare sectors per track */ + : 1; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t nsect; /* logical sectors/track */ + uchar_t ncyl_hi; /* logical number of cylinders, msb */ + uchar_t ncyl_lo; /* logical number of cylinders, lsb */ + uchar_t head_skew; /* head skew */ + uchar_t reserved[3]; +}; + +/* + * Page 0x31: CD-ROM speed page + */ + +#define CDROM_MODE_SPEED 0x31 + +struct mode_speed { + struct mode_page mode_page; /* common mode page header */ + uchar_t speed; /* drive speed */ + uchar_t reserved; +}; + +/* + * Definitions for drive speed supported are in cdio.h + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_MODE_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/scsi_reset_notify.h b/illumos-x86_64/usr/include/sys/scsi/impl/scsi_reset_notify.h new file mode 100644 index 00000000..379e97c3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/scsi_reset_notify.h @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SCSI_RESET_NOTIFY_H +#define _SYS_SCSI_RESET_NOTIFY_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SCSI Control Information for Reset Notification. + */ + +/* + * adapter drivers use the following structure to record the notification + * requests from target drivers. + */ +struct scsi_reset_notify_entry { + struct scsi_address *ap; + void (*callback)(caddr_t); + caddr_t arg; + struct scsi_reset_notify_entry *next; +}; + +#ifdef __lock_lint +_NOTE(SCHEME_PROTECTS_DATA("protected by lock passed as arg", + scsi_reset_notify_entry::ap + scsi_reset_notify_entry::callback + scsi_reset_notify_entry::arg + scsi_reset_notify_entry::next)) +#endif + +#ifdef _KERNEL +extern int scsi_hba_reset_notify_setup(struct scsi_address *, int, + void (*)(caddr_t), caddr_t, kmutex_t *, + struct scsi_reset_notify_entry **); +extern void scsi_hba_reset_notify_tear_down( + struct scsi_reset_notify_entry *listp); +extern void scsi_hba_reset_notify_callback(kmutex_t *mutex, + struct scsi_reset_notify_entry **listp); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_RESET_NOTIFY_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/scsi_sas.h b/illumos-x86_64/usr/include/sys/scsi/impl/scsi_sas.h new file mode 100644 index 00000000..e647ef4d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/scsi_sas.h @@ -0,0 +1,245 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_SCSI_IMPL_SCSI_SAS_H +#define _SYS_SCSI_IMPL_SCSI_SAS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) +/* + * Phymap support + */ +typedef struct __sas_phymap sas_phymap_t; +typedef enum { PHYMAP_MODE_SIMPLE } sas_phymap_mode_t; +typedef void (*sas_phymap_activate_cb_t) + (void *phymap_priv, char *ua, void **ua_privp); +typedef void (*sas_phymap_deactivate_cb_t) + (void *phymap_priv, char *ua, void *ua_priv); + +extern int sas_phymap_create(dev_info_t *hba_dip, + int settle_usec, + sas_phymap_mode_t mode, + void *mode_argument, + void *phymap_priv, + sas_phymap_activate_cb_t activate_cb, + sas_phymap_deactivate_cb_t deactivate_cb, + sas_phymap_t **phymapp); +void sas_phymap_destroy(sas_phymap_t *phymap); + +extern int sas_phymap_phy_add(sas_phymap_t *phymap, + int phy, + uint64_t local_sas_address, + uint64_t remote_sas_address); +extern int sas_phymap_phy_rem(sas_phymap_t *phymap, + int phy); + +extern char *sas_phymap_lookup_ua(sas_phymap_t *phymap, + uint64_t local_sas_address, + uint64_t remote_sas_address); +extern void *sas_phymap_lookup_uapriv(sas_phymap_t *phymap, + char *ua); + +extern char *sas_phymap_phy2ua(sas_phymap_t *phymap, + int phy); +void sas_phymap_ua_free(char *); + +extern int sas_phymap_uahasphys(sas_phymap_t *phymap, + char *ua); + +typedef struct __sas_phymap_phys sas_phymap_phys_t; +extern sas_phymap_phys_t *sas_phymap_ua2phys(sas_phymap_t *phymap, + char *ua); +extern int sas_phymap_phys_next(sas_phymap_phys_t *phys); +void sas_phymap_phys_free(sas_phymap_phys_t *phys); +#endif /* defined(_KERNEL) */ + + + +#define KSTAT_SAS_PHY_CLASS "SAS_phy_stat" +/* + * Format of the ks_name field for SAS Phy Stat + * + * driver_name.initiator_port_SAS_address.initiator_port_instance_number.phyid + * Example: pmcs.5000c50000d756aa.2.0 + * + * driver_name: + * driver name from di_driver_name() on SAS initiator port devinfo node. + * + * initiator_port_SAS_address: + * SAS address of the initiator port that phy stat is reported for. + * + * initiator_port_instance_number: + * instance number of the initiator port that phy stat is reported for. + * + * phyid: + * prop phyIdentifier under initiator port node. + */ + +/* Port Protocol - kstat structure definition */ +typedef struct sas_port_protocol_stats { + kstat_named_t seconds_since_last_reset; + kstat_named_t input_requests; + kstat_named_t output_requests; + kstat_named_t control_requests; + kstat_named_t input_megabytes; + kstat_named_t output_megabytes; +} sas_port_protocol_stats_t; + +/* Port - kstat structure definition */ +typedef struct sas_port_stats { + kstat_named_t seconds_since_last_reset; + kstat_named_t tx_frames; + kstat_named_t tx_words; + kstat_named_t rx_frames; + kstat_named_t rx_words; +} sas_port_stats_t; + +/* PHY - kstat structure definition */ +typedef struct sas_phy_stats { + kstat_named_t seconds_since_last_reset; + kstat_named_t tx_frames; + kstat_named_t tx_words; + kstat_named_t rx_frames; + kstat_named_t rx_words; + kstat_named_t invalid_dword_count; + kstat_named_t running_disparity_error_count; + kstat_named_t loss_of_dword_sync_count; + kstat_named_t phy_reset_problem_count; +} sas_phy_stats_t; + +/* + * Supported Protocol property + */ +#define SAS_PROTOCOL_SSP 0x00000001 +#define SAS_PROTOCOL_STP 0x00000010 +#define SAS_PROTOCOL_SMP 0x00000100 +#define SAS_PROTOCOL_SATA 0x00001000 + + +/* + * Definition - Negotiated Physical Link Rate + * Based on Table 288 (Section 10.4.3.10) of the spec (SAS-2 r-15), these + * constants represent "Negotiated physical link rate" + * (and implicitly the State of the phy). + */ +#define SAS_LINK_RATE_UNKNOWN 0x0 /* Phy is enabled. */ + /* Speed is unknown */ +#define SAS_LINK_RATE_DISABLED 0x1 /* Phy is disabled. */ + /* Speed is undefined */ +#define SAS_LINK_RATE_FAILED 0x2 /* Phy is enabled. */ + /* Failed speed negotiation. */ +#define SAS_LINK_RATE_SATASPINUP 0x3 /* Phy is enabled. */ + /* Detected a SATA device and */ + /* entered the SATA Spinup hold */ + /* state */ +#define SAS_LINK_RATE_SATAPORTSEL 0x4 /* Phy enabled. */ + /* The phy is attached to a */ + /* Port Selector (SATA-2.6). */ +#define SAS_LINK_RATE_RESET_IN_PROGRESS 0x5 /* Phy is enabled. */ + /* Expander is performing SMP */ + /* PHY CONTROL Link/Hard Reset */ +#define SAS_LINK_RATE_PHY_UNSUPPORTED 0x6 /* Phy is enabled. */ + /* Unsupported phy settings */ +#define SAS_LINK_RATE_RESERVED 0x7 /* Undefined. Reserved. */ +#define SAS_LINK_RATE_1_5GBIT 0x8 /* Phy enabled at 1.5 GBit/sec */ +#define SAS_LINK_RATE_3GBIT 0x9 /* Phy enabled at 3 GBit/sec */ +#define SAS_LINK_RATE_6GBIT 0xA /* Phy enabled at 6 GBit/sec. */ + + +/* + * Definition - "phy-info" property + * + * The property is an nvlist_array that represents an array of the + * nvlists on a per HBA basis. The individual elements of the array + * (the nvlists) represent the following properties for each phy of the HBA + */ +#define SAS_PHY_INFO "phy-info" /* Phy property name */ +#define SAS_PHY_INFO_NVL "phy-info-nvl" /* NVL array name */ + +#define SAS_PHY_ID "PhyIdentifier" /* DATA_TYPE_UINT8 */ +#define SAS_NEG_LINK_RATE "NegotiatedLinkRate" /* DATA_TYPE_INT8 */ +#define SAS_PROG_MIN_LINK_RATE "ProgrammedMinLinkRate" /* DATA_TYPE_INT8 */ +#define SAS_HW_MIN_LINK_RATE "HardwareMinLinkRate" /* DATA_TYPE_INT8 */ +#define SAS_PROG_MAX_LINK_RATE "ProgrammedMaxLinkRate" /* DATA_TYPE_INT8 */ +#define SAS_HW_MAX_LINK_RATE "HardwareMaxLinkRate" /* DATA_TYPE_INT8 */ + + +/* + * Phy-mask property names for the target port, attached port and receptacle + */ +#define SCSI_ADDR_PROP_TARGET_PORT_PM "target-port-pm" +#define SCSI_ADDR_PROP_ATTACHED_PORT_PM "attached-port-pm" +#define SCSI_HBA_PROP_RECEPTACLE_PM "receptacle-pm" + +/* + * Target port depth property names - Indicates the number of expanders + * between the initiator port and the target port + */ +#define SCSI_ADDR_PROP_TARGET_PORT_DEPTH "target-port-depth" + + +/* + * Event definitions + */ +/* Event Class */ +#define EC_HBA "EC_hba" + +/* Event Sub-Class */ +#define ESC_SAS_HBA_PORT_BROADCAST "ESC_sas_hba_port_broadcast" +/* Event Types for above Subclass */ +#define SAS_PORT_BROADCAST_CHANGE "port_broadcast_change" +#define SAS_PORT_BROADCAST_SES "port_broadcast_ses" +#define SAS_PORT_BROADCAST_D24_0 "port_broadcast_d24_0" +#define SAS_PORT_BROADCAST_D27_4 "port_broadcast_d27_4" +#define SAS_PORT_BROADCAST_D01_4 "port_broadcast_d01_4" +#define SAS_PORT_BROADCAST_D04_7 "port_broadcast_d04_7" +#define SAS_PORT_BROADCAST_D16_7 "port_broadcast_d16_7" +#define SAS_PORT_BROADCAST_D29_7 "port_broadcast_d29_7" + +/* Event Sub-Class */ +#define ESC_SAS_PHY_EVENT "ESC_sas_phy_event" +/* Event Types for above Subclass */ +#define SAS_PHY_ONLINE "port_online" +#define SAS_PHY_OFFLINE "port_offline" +#define SAS_PHY_REMOVE "port_remove" + +/* Event Payload Names */ +#define SAS_DRV_INST "driver_instance" +#define SAS_PORT_ADDR "port_address" +#define SAS_DEVFS_PATH "devfs_path" +#define SAS_EVENT_TYPE "event_type" +#define SAS_LINK_RATE "link_rate" +/* SAS_PHY_ID - Defined Above */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_SCSI_SAS_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/sense.h b/illumos-x86_64/usr/include/sys/scsi/impl/sense.h new file mode 100644 index 00000000..b1008887 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/sense.h @@ -0,0 +1,150 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_IMPL_SENSE_H +#define _SYS_SCSI_IMPL_SENSE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Implementation Variant defines + * for SCSI Sense Information + */ + +/* + * These are 'pseudo' sense keys for common Sun implementation driver + * detected errors. Note that they start out as being higher than the + * legal key numbers for standard SCSI. + */ + +#define SUN_KEY_FATAL 0x10 /* driver, scsi handshake failure */ +#define SUN_KEY_TIMEOUT 0x11 /* driver, command timeout */ +#define SUN_KEY_EOF 0x12 /* driver, eof hit */ +#define SUN_KEY_EOT 0x13 /* driver, eot hit */ +#define SUN_KEY_LENGTH 0x14 /* driver, length error */ +#define SUN_KEY_BOT 0x15 /* driver, bot hit */ +#define SUN_KEY_WRONGMEDIA 0x16 /* driver, wrong tape media */ + +#define NUM_IMPL_SENSE_KEYS 7 /* seven extra keys */ + +/* + * Common sense length allocation sufficient for this implementation. + */ + +#define SENSE_LENGTH \ + (roundup(sizeof (struct scsi_extended_sense), sizeof (int))) + +/* + * Per SPC-3 standard, the maximum length of sense data is 252 bytes. + */ +#define MAX_SENSE_LENGTH 252 + +/* + * Minimum useful Sense Length value + */ + +#define SUN_MIN_SENSE_LENGTH 4 + +/* + * Specific variants to the Extended Sense structure. + * + * Defines for: + * Emulex MD21 SCSI/ESDI Controller + * Emulex MT02 SCSI/QIC-36 Controller. + * + * 1) The Emulex controllers put error class and error code into the byte + * right after the 'additional sense length' field in Extended Sense. + * + * 2) Except that some people state that this isn't so for the MD21- only + * the MT02. + */ + +#define emulex_ercl_ercd es_cmd_info[0] + +/* + * 2) These are valid on Extended Sense for the MD21, FORMAT command only: + */ + +#define emulex_cyl_msb es_info_1 +#define emulex_cyl_lsb es_info_2 +#define emulex_head_num es_info_3 +#define emulex_sect_num es_info_4 + +struct scsi_descr_template { + uchar_t sdt_descr_type; + uchar_t sdt_addl_length; +}; + +/* + * Function prototypes for descriptor-format sense data functions + */ + +uint8_t *scsi_find_sense_descr(uint8_t *sense_buffer, int sense_buf_len, + int descr_type); + +/* + * Function prototypes for format-neutral sense data functions + */ + +uint8_t scsi_sense_key(uint8_t *sense_buffer); + +uint8_t scsi_sense_asc(uint8_t *sense_buffer); + +uint8_t scsi_sense_ascq(uint8_t *sense_buffer); + +boolean_t scsi_sense_info_uint64(uint8_t *sense_buffer, + int sense_buf_len, uint64_t *information); + +boolean_t scsi_sense_cmdspecific_uint64(uint8_t *sense_buffer, + int sense_buf_len, uint64_t *cmd_spec_info); + +void scsi_ext_sense_fields(uint8_t *sense_buffer, int sense_buf_len, + uint8_t **information, uint8_t **cmd_spec_info, uint8_t **fru_code, + uint8_t **sk_specific, uint8_t **stream_flags); + +int scsi_validate_sense(uint8_t *sense_buffer, int sense_buf_len, int *flags); + +/* + * Return codes for scsi_validate_sense + */ + +#define SENSE_UNUSABLE 0 +#define SENSE_FIXED_FORMAT 1 +#define SENSE_DESCR_FORMAT 2 + +/* + * Flags from scsi_validate_sense + */ + +#define SNS_BUF_OVERFLOW 1 /* Sense buffer too small */ +#define SNS_BUF_DEFERRED 2 /* Sense data is for prior operation */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_SENSE_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/services.h b/illumos-x86_64/usr/include/sys/scsi/impl/services.h new file mode 100644 index 00000000..d014006b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/services.h @@ -0,0 +1,206 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_IMPL_SERVICES_H +#define _SYS_SCSI_IMPL_SERVICES_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Implementation services not classified by type + */ + +#ifdef _KERNEL + +struct scsi_key_strings { + int key; + char *message; +}; + +struct scsi_asq_key_strings { + ushort_t asc; + ushort_t ascq; + char *message; +}; + +int scsi_poll(struct scsi_pkt *); +struct scsi_pkt *get_pktiopb(struct scsi_address *, + caddr_t *datap, int cdblen, int statuslen, + int datalen, int readflag, int (*func)(void)); +void free_pktiopb(struct scsi_pkt *, caddr_t datap, int datalen); + +char *scsi_dname(int dtyp); +char *scsi_rname(uchar_t reason); +char *scsi_mname(uchar_t msg); +char *scsi_cname(uchar_t cmd, char **cmdvec); +char *scsi_cmd_name(uchar_t cmd, struct scsi_key_strings *cmdlist, + char *tmpstr); +char *scsi_sname(uchar_t sense_key); +char *scsi_esname(uint_t sense_key, char *tmpstr); +char *scsi_asc_name(uint_t asc, uint_t ascq, char *tmpstr); + +void scsi_generic_errmsg(struct scsi_device *devp, char *label, + int severity, daddr_t blkno, daddr_t err_blkno, + uchar_t cmd_name, struct scsi_key_strings *cmdlist, + uint8_t *sensep, struct scsi_asq_key_strings *asc_list, + char *(*decode_fru)(struct scsi_device *, char *, int, uchar_t)); + +void scsi_vu_errmsg(struct scsi_device *devp, struct scsi_pkt *pktp, + char *drv_name, int severity, daddr_t blkno, daddr_t err_blkno, + struct scsi_key_strings *cmdlist, + struct scsi_extended_sense *sensep, + struct scsi_asq_key_strings *asc_list, + char *(*decode_fru)(struct scsi_device *, char *, int, uchar_t)); +void scsi_errmsg(struct scsi_device *devp, struct scsi_pkt *pkt, + char *label, int severity, daddr_t blkno, daddr_t err_blkno, + struct scsi_key_strings *cmdlist, + struct scsi_extended_sense *sensep); + + + + +/*PRINTFLIKE4*/ +void scsi_log(dev_info_t *dev, char *label, + uint_t level, const char *fmt, ...) __KPRINTFLIKE(4); + +extern char *scsi_state_bits; +extern char *sense_keys[NUM_SENSE_KEYS + NUM_IMPL_SENSE_KEYS]; + +#define SCSI_DEBUG 0xDEB00000 + +#define SCSI_ERR_ALL 0 +#define SCSI_ERR_UNKNOWN 1 +#define SCSI_ERR_INFO 2 +#define SCSI_ERR_RECOVERED 3 +#define SCSI_ERR_RETRYABLE 4 +#define SCSI_ERR_FATAL 5 +#define SCSI_ERR_NONE 6 + + +/* + * Common Capability Strings Array + */ +#define SCSI_CAP_DMA_MAX 0 +#define SCSI_CAP_MSG_OUT 1 +#define SCSI_CAP_DISCONNECT 2 +#define SCSI_CAP_SYNCHRONOUS 3 +#define SCSI_CAP_WIDE_XFER 4 +#define SCSI_CAP_PARITY 5 +#define SCSI_CAP_INITIATOR_ID 6 +#define SCSI_CAP_UNTAGGED_QING 7 +#define SCSI_CAP_TAGGED_QING 8 +#define SCSI_CAP_ARQ 9 +#define SCSI_CAP_LINKED_CMDS 10 +#define SCSI_CAP_SECTOR_SIZE 11 +#define SCSI_CAP_TOTAL_SECTORS 12 +#define SCSI_CAP_GEOMETRY 13 +#define SCSI_CAP_RESET_NOTIFICATION 14 +#define SCSI_CAP_QFULL_RETRIES 15 +#define SCSI_CAP_QFULL_RETRY_INTERVAL 16 +#define SCSI_CAP_SCSI_VERSION 17 +#define SCSI_CAP_INTERCONNECT_TYPE 18 +#define SCSI_CAP_LUN_RESET 19 +#define SCSI_CAP_CDB_LEN 20 +#define SCSI_CAP_DMA_MAX_ARCH 21 +#define SCSI_CAP_TRAN_LAYER_RETRIES 22 +#define SCSI_CAP_ASCII { \ + "dma-max", "msg-out", "disconnect", "synchronous", \ + "wide-xfer", "parity", "initiator-id", "untagged-qing", \ + "tagged-qing", "auto-rqsense", "linked-cmds", \ + "sector-size", "total-sectors", "geometry", \ + "reset-notification", "qfull-retries", \ + "qfull-retry-interval", "scsi-version", \ + "interconnect-type", "lun-reset", \ + "max-cdb-length", "dma-max-arch", \ + "tran-layer-retries", NULL } + +/* + * Definitions used by some capabilities + */ +/* SCSI_CAP_SCSI_VERSION */ +#define SCSI_VERSION_1 1 +#define SCSI_VERSION_2 2 +#define SCSI_VERSION_3 3 + +/* SCSI_CAP_INTERCONNECT_TYPE */ +#define INTERCONNECT_PARALLEL 1 +#define INTERCONNECT_FIBRE 2 /* PLDA or hard ALPA */ +#define INTERCONNECT_1394 3 +#define INTERCONNECT_SSA 4 /* -EOLed */ +#define INTERCONNECT_FABRIC 5 /* soft ALPA or Switch */ +#define INTERCONNECT_USB 6 +#define INTERCONNECT_ATAPI 7 +#define INTERCONNECT_ISCSI 8 +#define INTERCONNECT_IBSRP 9 +#define INTERCONNECT_SATA 10 +#define INTERCONNECT_SAS 11 +#define INTERCONNECT_MAX 12 /* Change this appropriately, */ + /* as new one(s) are added. */ + /* Is always the last & max. */ + +/* INTERCONNECT TYPE STRINGS */ +#define INTERCONNECT_PARALLEL_STR "SPI" +#define INTERCONNECT_FIBRE_STR "FIBRE" +#define INTERCONNECT_1394_STR "1394" +#define INTERCONNECT_SSA_STR "" +#define INTERCONNECT_FABRIC_STR "FABRIC" +#define INTERCONNECT_USB_STR "USB" +#define INTERCONNECT_ATAPI_STR "ATAPI" +#define INTERCONNECT_ISCSI_STR "iSCSI" +#define INTERCONNECT_IBSRP_STR "IB" +#define INTERCONNECT_SATA_STR "SATA" +#define INTERCONNECT_SAS_STR "SAS" + +#define INTERCONNECT_TYPE_ASCII { \ + "", \ + INTERCONNECT_PARALLEL_STR, \ + INTERCONNECT_FIBRE_STR, \ + INTERCONNECT_1394_STR, \ + INTERCONNECT_SSA_STR, \ + INTERCONNECT_FABRIC_STR, \ + INTERCONNECT_USB_STR, \ + INTERCONNECT_ATAPI_STR, \ + INTERCONNECT_ISCSI_STR, \ + INTERCONNECT_IBSRP_STR, \ + INTERCONNECT_SATA_STR, \ + INTERCONNECT_SAS_STR, \ + NULL \ + }; + +/* + * Compatibility... + */ +#define scsi_cmd_decode scsi_cname + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_SERVICES_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/smp_transport.h b/illumos-x86_64/usr/include/sys/scsi/impl/smp_transport.h new file mode 100644 index 00000000..b5eef4dc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/smp_transport.h @@ -0,0 +1,150 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_IMPL_SMP_TRANSPORT_H +#define _SYS_SCSI_IMPL_SMP_TRANSPORT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) + +/* + * Properties for smp device + */ +#define SMP_PROP "smp-device" +#define SMP_WWN "smp-wwn" +#define SMP_PROP_REPORT_MANUFACTURER "report-manufacturer" + +typedef struct smp_hba_tran smp_hba_tran_t; + +typedef struct smp_address { + uint8_t smp_a_wwn[SAS_WWN_BYTE_SIZE]; /* expander wwn */ + smp_hba_tran_t *smp_a_hba_tran; /* Transport vector */ +} smp_address_t; + +typedef struct smp_device { + smp_address_t smp_sd_address; + dev_info_t *smp_sd_dev; + void *smp_sd_hba_private; + void *smp_sd_private; +} smp_device_t; + +typedef struct smp_pkt { + smp_address_t *smp_pkt_address; + caddr_t smp_pkt_req; + caddr_t smp_pkt_rsp; + size_t smp_pkt_reqsize; + size_t smp_pkt_rspsize; + int smp_pkt_timeout; + uchar_t smp_pkt_reason; /* code from errno.h */ + uchar_t smp_pkt_will_retry; /* will retry on EAGAIN */ +} smp_pkt_t; + +struct smp_hba_tran { + void *smp_tran_hba_private; + + int (*smp_tran_init)( + dev_info_t *self, + dev_info_t *child, + smp_hba_tran_t *tran, + smp_device_t *smp); + + void (*smp_tran_free)( + dev_info_t *self, + dev_info_t *child, + smp_hba_tran_t *tran, + smp_device_t *smp); + + int (*smp_tran_start)( + struct smp_pkt *pkt); + +}; + +/* interfaces for hba/iport driver */ +extern smp_hba_tran_t *smp_hba_tran_alloc(dev_info_t *dip); +extern int smp_hba_attach_setup(dev_info_t *dip, + smp_hba_tran_t *smp); +extern int smp_hba_detach(dev_info_t *self); +extern void smp_hba_tran_free(smp_hba_tran_t *smp); + +/* interfaces target driver (and framework) */ +extern int smp_probe(struct smp_device *smp_devp); +extern int smp_transport(struct smp_pkt *pkt); + +/* ==== The following interfaces are private (currently) ==== */ + +/* + * smp_device_prop_*() property interfaces: flags + * + * SMP_DEVICE_PROP_DEVICE: property of device. + * The property is always associated with the smp_sd_dev devinfo + * node. Implementation uses ndi_prop_*() interfaces applied + * dev_info_t (smp_sd_dev) nodes. + */ +#define SMP_DEVICE_PROP_DEVICE 0x2 /* type is property-of-device */ +#define SMP_DEVICE_PROP_TYPE_MSK 0xF + +int smp_device_prop_get_int(struct smp_device *smp_sd, char *name, + int defvalue); +int64_t smp_device_prop_get_int64(struct smp_device *, char *name, + int64_t defvalue); + +int smp_device_prop_lookup_byte_array(struct smp_device *smp_sd, char *name, + uchar_t **, uint_t *); +int smp_device_prop_lookup_int_array(struct smp_device *smp_sd, char *name, + int **, uint_t *); +int smp_device_prop_lookup_string(struct smp_device *smp_sd, char *name, + char **); +int smp_device_prop_lookup_string_array(struct smp_device *smp_sd, + char *name, char ***, uint_t *); + +int smp_device_prop_update_byte_array(struct smp_device *smp_sd, char *name, + uchar_t *, uint_t); +int smp_device_prop_update_int(struct smp_device *smp_sd, char *name, int); +int smp_device_prop_update_int64(struct smp_device *smp_sd, char *name, + int64_t); +int smp_device_prop_update_int_array(struct smp_device *smp_sd, char *name, + int *, uint_t); +int smp_device_prop_update_string(struct smp_device *smp_sd, char *name, + char *); +int smp_device_prop_update_string_array(struct smp_device *smp_sd, + char *name, char **, uint_t); + +int smp_device_prop_remove(struct smp_device *smp_sd, char *name); +void smp_device_prop_free(struct smp_device *smp_sd, void *data); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_SMP_TRANSPORT_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/spc3_types.h b/illumos-x86_64/usr/include/sys/scsi/impl/spc3_types.h new file mode 100644 index 00000000..4b687eb9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/spc3_types.h @@ -0,0 +1,1134 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _SPC3_TYPES_H +#define _SPC3_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +typedef enum spc3_cmd { + SPC3_CMD_TEST_UNIT_READY = SCMD_TEST_UNIT_READY, + SPC3_CMD_REZERO_UNIT = SCMD_REZERO_UNIT, + SPC3_CMD_REWIND = SCMD_REWIND, + SPC3_CMD_VENDOR_2 = 2, + SPC3_CMD_REQUEST_SENSE = SCMD_REQUEST_SENSE, + SPC3_CMD_FORMAT_UNIT = SCMD_FORMAT, + SPC3_CMD_FORMAT_MEDIUM = SCMD_FORMAT, + SPC3_CMD_FORMAT = SCMD_FORMAT, + SPC3_CMD_READ_BLOCK_LIMITS = SCMD_READ_BLKLIM, + SPC3_CMD_VENDOR_6 = 6, + SPC3_CMD_REASSIGN_BLOCKS = SCMD_REASSIGN_BLOCK, + SPC3_CMD_INITIALIZE_ELEMENT_STATUS = SCMD_REASSIGN_BLOCK, + SPC3_CMD_READ = SCMD_READ, + SPC3_CMD_READ6 = SCMD_READ, + SPC3_CMD_RECEIVE = SCMD_RECEIVE, + SPC3_CMD_GET_MESSAGE = SCMD_READ, + SPC3_CMD_VENDOR_9 = 9, + SPC3_CMD_WRITE = SCMD_WRITE, + SPC3_CMD_WRITE6 = SCMD_WRITE, + SPC3_CMD_SEND = SCMD_SEND, + SPC3_CMD_SEND6 = SCMD_SEND, + SPC3_CMD_SEND_MESSAGE = SCMD_SEND, + SPC3_CMD_PRINT = SCMD_PRINT, + SPC3_CMD_SEEK = SCMD_SEEK, + SPC3_CMD_SEEK6 = SCMD_SEEK, + SPC3_CMD_SET_CAPACITY = SCMD_SEEK, + SPC3_CMD_SLEW_AND_PRINT = SCMD_SLEW_PRINT, + SPC3_CMD_VENDOR_C = 0xc, + SPC3_CMD_VENDOR_D = 0xd, + SPC3_CMD_VENDOR_E = 0xe, + SPC3_CMD_READ_REVERSE = SCMD_READ_REVERSE, + SPC3_CMD_READ_REVERSE6 = SCMD_READ_REVERSE, + SPC3_CMD_WRITE_FILEMARKS = SCMD_WRITE_FILE_MARK, + SPC3_CMD_WRITE_FILEMARKS6 = SCMD_WRITE_FILE_MARK, + SPC3_CMD_SYNCHRONIZE_BUFFER = SCMD_FLUSH_PRINT_BUF, + SPC3_CMD_SPACE = SCMD_SPACE, + SPC3_CMD_SPACE6 = SCMD_SPACE, + SPC3_CMD_INQUIRY = SCMD_INQUIRY, + SPC3_CMD_VERIFY = SCMD_VERIFY_G0, + SPC3_CMD_VERIFY6 = SCMD_VERIFY_G0, + SPC3_CMD_RECOVER_BUFFERED_DATA = SCMD_RECOVER_BUF, + SPC3_CMD_MODE_SELECT = SCMD_MODE_SELECT, + SPC3_CMD_MODE_SELECT6 = SCMD_MODE_SELECT, + SPC3_CMD_RESERVE = SCMD_RESERVE, + SPC3_CMD_RESERVE6 = SCMD_RESERVE, + SPC3_CMD_RESERVE_ELEMENT = SCMD_RESERVE, + SPC3_CMD_RESERVE_ELEMENT6 = SCMD_RESERVE, + SPC3_CMD_RELEASE = SCMD_RELEASE, + SPC3_CMD_RELEASE6 = SCMD_RELEASE, + SPC3_CMD_RELEASE_ELEMENT = SCMD_RELEASE, + SPC3_CMD_RELEASE_ELEMENT6 = SCMD_RELEASE, + SPC3_CMD_COPY = SCMD_COPY, + SPC3_CMD_ERASE = SCMD_ERASE, + SPC3_CMD_ERASE6 = SCMD_ERASE, + SPC3_CMD_MODE_SENSE = SCMD_MODE_SENSE, + SPC3_CMD_MODE_SENSE6 = SCMD_MODE_SENSE, + SPC3_CMD_START_STOP_UNIT = SCMD_START_STOP, + SPC3_CMD_LOAD_UNLOAD = SCMD_LOAD, + SPC3_CMD_SCAN = SCMD_START_STOP, + SPC3_CMD_STOP_PRINT = SCMD_STOP_PRINT, + SPC3_CMD_RECEIVE_DIAGNOSTIC_RESULTS = SCMD_GDIAG, + SPC3_CMD_SEND_DIAGNOSTIC = SCMD_SDIAG, + SPC3_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL = SCMD_DOORLOCK, + SPC3_CMD_VENDOR_20 = 0x20, + SPC3_CMD_VENDOR_21 = 0x21, + SPC3_CMD_VENDOR_22 = 0x22, + SPC3_CMD_VENDOR_23 = 0x23, + SPC3_CMD_SET_WINDOW = 0x24, + SPC3_CMD_READ_CAPACITY = SCMD_READ_CAPACITY, + SPC3_CMD_READ_CAPACITY10 = SCMD_READ_CAPACITY, + SPC3_CMD_READ_CARD_CAPACITY = SCMD_READ_CAPACITY, + SPC3_CMD_GET_WINDOW = SCMD_READ_CAPACITY, + SPC3_CMD_VENDOR_26 = 0x26, + SPC3_CMD_VENDOR_27 = 0x27, + SPC3_CMD_READ10 = SCMD_READ_G1, + SPC3_CMD_GET_MESSAGE10 = SCMD_READ_G1, + SPC3_CMD_READ_GENERATION = 0x29, + SPC3_CMD_WRITE10 = SCMD_WRITE_G1, + SPC3_CMD_SEND10 = SCMD_WRITE_G1, + SPC3_CMD_SEND_MESSAGE10 = SCMD_WRITE_G1, + SPC3_CMD_SEEK10 = SCMD_SEEK_G1, + SPC3_CMD_LOCATE = SCMD_LOCATE, + SPC3_CMD_LOCATE10 = SCMD_LOCATE, + SPC3_CMD_POSITION_TO_ELEMENT = SCMD_SEEK_G1, + SPC3_CMD_ERASE10 = 0x2c, + SPC3_CMD_READ_UPDATED_BLOCK = 0x2d, + SPC3_CMD_WRITE_AND_VERIFY = SCMD_WRITE_VERIFY, + SPC3_CMD_WRITE_AND_VERIFY10 = SCMD_WRITE_VERIFY, + SPC3_CMD_VERIFY10 = SCMD_VERIFY, + SPC3_CMD_SEARCH_DATA_HIGH = SCMD_SEARCH_HIGH, + SPC3_CMD_SEARCH_DATA_HIGH10 = SCMD_SEARCH_HIGH, + SPC3_CMD_SEARCH_DATA_EQUAL = SCMD_SEARCH_EQUAL, + SPC3_CMD_SEARCH_DATA_EQUAL10 = SCMD_SEARCH_EQUAL, + SPC3_CMD_OBJECT_POSITION = SCMD_SEARCH_EQUAL, + SPC3_CMD_SEARCH_DATA_LOW = SCMD_SEARCH_LOW, + SPC3_CMD_SEARCH_DATA_LOW10 = SCMD_SEARCH_LOW, + SPC3_CMD_SET_LIMITS = SCMD_SET_LIMITS, + SPC3_CMD_SET_LIMITS10 = SCMD_SET_LIMITS, + SPC3_CMD_PREFETCH = SCMD_READ_POSITION, + SPC3_CMD_PREFETCH10 = SCMD_READ_POSITION, + SPC3_CMD_READ_POSITION = SCMD_READ_POSITION, + SPC3_CMD_GET_DATA_BUFFER_STATUS = SCMD_READ_POSITION, + SPC3_CMD_SYNCHRONIZE_CACHE = SCMD_SYNCHRONIZE_CACHE, + SPC3_CMD_SYNCHRONIZE_CACHE10 = SCMD_SYNCHRONIZE_CACHE, + SPC3_CMD_LOCK_UNLOCK_CACHE = 0x36, + SPC3_CMD_READ_DEFECT_DATA = SCMD_READ_DEFECT_LIST, + SPC3_CMD_READ_DEFECT_DATA10 = SCMD_READ_DEFECT_LIST, + SPC3_CMD_INITIALIZE_ELEMENT_STATUS_WITH_RANGE = SCMD_READ_DEFECT_LIST, + SPC3_CMD_MEDIUM_SCAN = 0x38, + SPC3_CMD_COMPARE = SCMD_COMPARE, + SPC3_CMD_COPY_AND_VERIFY = SCMD_COPY_VERIFY, + SPC3_CMD_WRITE_BUFFER = SCMD_WRITE_BUFFER, + SPC3_CMD_READ_BUFFER = SCMD_READ_BUFFER, + SPC3_CMD_UPDATE_BLOCK = 0x3d, + SPC3_CMD_READ_LONG = SCMD_READ_LONG, + SPC3_CMD_READ_LONG10 = SCMD_READ_LONG, + SPC3_CMD_WRITE_LONG = SCMD_WRITE_LONG, + SPC3_CMD_WRITE_LONG10 = SCMD_WRITE_LONG, + SPC3_CMD_CHANGE_DEFINITION = 0x40, + SPC3_CMD_WRITE_SAME = 0x41, + SPC3_CMD_WRITE_SAME10 = 0x41, + SPC3_CMD_UNMAP = 0x42, + SPC3_CMD_UNMAP10 = 0x42, + SPC3_CMD_READ_SUBCHANNEL = SCMD_READ_SUBCHANNEL, + SPC3_CMD_READ_TOC = SCMD_READ_TOC, + SPC3_CMD_REPORT_DENSITY_SUPPORT = SCMD_REPORT_DENSITIES, + SPC3_CMD_READ_HEADER = SCMD_READ_HEADER, + SPC3_CMD_PLAY_AUDIO = SCMD_PLAYAUDIO10, + SPC3_CMD_PLAY_AUDIO10 = SCMD_PLAYAUDIO10, + SPC3_CMD_GET_CONFIGURATION = SCMD_GET_CONFIGURATION, + SPC3_CMD_PLAY_AUDIO_MSF = SCMD_PLAYAUDIO_MSF, + /* Not defined by SPC-3 */ + SPC3_CMD_PLAY_AUDIO_TI = SCMD_PLAYAUDIO_TI, + SPC3_CMD_PLAY_TRACK_REL = SCMD_PLAYTRACK_REL10, + SPC3_CMD_PLAY_TRACK_REL10 = SCMD_PLAYTRACK_REL10, + SPC3_CMD_GET_EVENT_STATUS_NOTIFICATION = 0x4a, + SPC3_CMD_PAUSE_RESUME = SCMD_PAUSE_RESUME, + SPC3_CMD_LOG_SELECT = SCMD_LOG_SELECT_G1, + SPC3_CMD_LOG_SENSE = SCMD_LOG_SENSE_G1, + SPC3_CMD_STOP_PLAY_SCAN = 0x4e, + SPC3_CMD_XDWRITE = 0x50, + SPC3_CMD_XDWRITE10 = 0x50, + SPC3_CMD_XPWRITE = 0x51, + SPC3_CMD_XPWRITE10 = 0x51, + SPC3_CMD_READ_DISC_INFORMATION = 0x51, + SPC3_CMD_XDREAD = 0x52, + SPC3_CMD_XDREAD10 = 0x52, + SPC3_CMD_READ_TRACK_INFORMATION = 0x52, + SPC3_CMD_RESERVE_TRACK = 0x53, + SPC3_CMD_SEND_OPC_INFORMATION = 0x54, + SPC3_CMD_MODE_SELECT10 = SCMD_MODE_SELECT_G1, + SPC3_CMD_RESERVE10 = SCMD_RESERVE_G1, + SPC3_CMD_RESERVE_ELEMENT10 = SCMD_RESERVE_G1, + SPC3_CMD_RELEASE10 = SCMD_RELEASE_G1, + SPC3_CMD_RELEASE_ELEMENT10 = SCMD_RELEASE_G1, + SPC3_CMD_REPAIR_TRACK = 0x58, + SPC3_CMD_MODE_SENSE10 = SCMD_MODE_SENSE_G1, + SPC3_CMD_CLOSE_TRACK_SESSION = 0x5b, + SPC3_CMD_READ_BUFFER_CAPACITY = 0x5c, + SPC3_CMD_SEND_CUE_SHEET = 0x5d, + SPC3_CMD_PERSISTENT_RESERVE_IN = SCMD_PERSISTENT_RESERVE_IN, + SPC3_CMD_PERSISTENT_RESERVE_OUT = SCMD_PERSISTENT_RESERVE_OUT, + SPC3_CMD_VARIABLE_LENGTH = SCMD_VAR_LEN, + SPC3_CMD_XDWRITE_EXTENDED = SCMD_WRITE_FILE_MARK_G4, + SPC3_CMD_XDWRITE_EXTENDED16 = SCMD_WRITE_FILE_MARK_G4, + SPC3_CMD_WRITE_FILEMARKS16 = SCMD_WRITE_FILE_MARK_G4, + SPC3_CMD_REBUILD = SCMD_READ_REVERSE_G4, + SPC3_CMD_REBUILD16 = SCMD_READ_REVERSE_G4, + SPC3_CMD_READ_REVERSE16 = SCMD_READ_REVERSE_G4, + SPC3_CMD_REGENERATE = 0x82, + SPC3_CMD_REGENERATE16 = 0x82, + SPC3_CMD_EXTENDED_COPY = SCMD_EXTENDED_COPY, + SPC3_CMD_RECEIVE_COPY_RESULTS = 0x84, + SPC3_CMD_ATA_COMMAND_PASS_THROUGH = 0x85, + SPC3_CMD_ATA_COMMAND_PASS_THROUGH16 = 0x85, + SPC3_CMD_ACCESS_CONTROL_IN = 0x86, + SPC3_CMD_ACCESS_CONTROL_OUT = 0x87, + SPC3_CMD_READ16 = SCMD_READ_G4, + SPC3_CMD_WRITE16 = SCMD_WRITE_G4, + SPC3_CMD_READ_ATTRIBUTE = SCMD_READ_ATTRIBUTE, + SPC3_CMD_WRITE_ATTRIBUTE = SCMD_WRITE_ATTRIBUTE, + SPC3_CMD_WRITE_AND_VERIFY16 = 0x8e, + SPC3_CMD_VERIFY16 = SCMD_VERIFY_G4, + SPC3_CMD_PREFETCH16 = 0x90, + SPC3_CMD_SYNCHRONIZE_CACHE16 = SCMD_SPACE_G4, + SPC3_CMD_SPACE16 = SCMD_SPACE_G4, + SPC3_CMD_LOCK_UNLOCK_CACHE16 = 0x92, + SPC3_CMD_LOCATE16 = 0x92, + SPC3_CMD_WRITE_SAME16 = 0x93, + SPC3_CMD_ERASE16 = 0x93, + SPC3_CMD_SERVICE_ACTION_IN = SCMD_SVC_ACTION_IN_G4, + SPC3_CMD_SERVICE_ACTION_IN16 = SCMD_SVC_ACTION_IN_G4, + SPC3_CMD_SERVICE_ACTION_OUT = SCMD_SVC_ACTION_OUT_G4, + SPC3_CMD_SERVICE_ACTION_OUT16 = SCMD_SVC_ACTION_OUT_G4, + SPC3_CMD_REPORT_LUNS = SCMD_REPORT_LUNS, + SPC3_CMD_BLANK = 0xa1, + SPC3_CMD_ATA_COMMAND_PASS_THROUGH12 = 0xa1, + SPC3_CMD_SECURITY_PROTO_IN = SCMD_SECURITY_PROTO_IN, + SPC3_CMD_MAINTENANCE_IN = SCMD_MAINTENANCE_IN, + SPC3_CMD_SEND_KEY = SCMD_MAINTENANCE_IN, + SPC3_CMD_MAINTENANCE_OUT = SCMD_MAINTENANCE_OUT, + SPC3_CMD_REPORT_KEY = SCMD_MAINTENANCE_OUT, + SPC3_CMD_MOVE_MEDIUM = SCMD_PLAYAUDIO12, + SPC3_CMD_PLAY_AUDIO12 = SCMD_PLAYAUDIO12, + SPC3_CMD_EXCHANGE_MEDIUM = 0xa6, + SPC3_CMD_LOAD_UNLOAD_CD = 0xa6, + SPC3_CMD_MOVE_MEDIUM_ATTACHED = 0xa7, + SPC3_CMD_SET_READ_AHEAD = 0xa7, + SPC3_CMD_READ12 = SCMD_READ_G5, + SPC3_CMD_GET_MESSAGE12 = SCMD_READ_G5, + SPC3_CMD_SERVICE_ACTION_OUT12 = SCMD_SVC_ACTION_OUT_G5, + SPC3_CMD_PLAY_TRACK_REL12 = SCMD_PLAYTRACK_REL12, + SPC3_CMD_WRITE12 = SCMD_WRITE_G5, + SPC3_CMD_SEND_MESSAGE12 = SCMD_WRITE_G5, + SPC3_CMD_SERVICE_ACTION_IN12 = SCMD_SVC_ACTION_IN_G5, + SPC3_CMD_ERASE12 = SCMD_GET_PERFORMANCE, + SPC3_CMD_GET_PERFORMANCE = SCMD_GET_PERFORMANCE, + SPC3_CMD_READ_DVD_STRUCTURE = 0xad, + SPC3_CMD_WRITE_AND_VERIFY12 = 0xae, + SPC3_CMD_VERIFY12 = SCMD_VERIFY_G5, + SPC3_CMD_SEARCH_DATA_HIGH12 = 0xb0, + SPC3_CMD_SEARCH_DATA_EQUAL12 = 0xb1, + SPC3_CMD_SEARCH_DATA_LOW12 = 0xb2, + SPC3_CMD_SET_LIMITS12 = 0xb3, + SPC3_CMD_READ_ELEMENT_STATUS_ATTACHED = 0xb4, + SPC3_CMD_REQUEST_VOLUME_ELEMENT_ADDRESS = 0xb5, + SPC3_CMD_SEND_VOLUME_TAG = 0xb6, + SPC3_CMD_SET_STREAMING = 0xb6, + SPC3_CMD_READ_DEFECT_DATA12 = 0xb7, + SPC3_CMD_READ_ELEMENT_STATUS = 0xb8, + SPC3_CMD_READ_CD_MSF = 0xb9, + SPC3_CMD_REDUNDANCY_GROUP_IN = 0xba, + SPC3_CMD_SCAN12 = 0xba, + SPC3_CMD_REDUNDANCY_GROUP_OUT = SCMD_SET_CDROM_SPEED, + SPC3_CMD_SET_CD_SPEED = SCMD_SET_CDROM_SPEED, + SPC3_CMD_SPARE_IN = 0xbc, + SPC3_CMD_SPARE_OUT = 0xbd, + SPC3_CMD_MECHANISM_STATUS = 0xbd, + SPC3_CMD_VOLUME_SET_IN = SCMD_READ_CD, + SPC3_CMD_READ_CD = SCMD_READ_CD, + SPC3_CMD_VOLUME_SET_OUT = 0xbf, + SPC3_CMD_SEND_DVD_STRUCTURE = 0xbf +} spc3_cmd_t; + +typedef enum spc3_dev_type { + SPC3_DEVTYPE_DIRECT = 0x00, + SPC3_DEVTYPE_SEQUENTIAL = 0x01, + SPC3_DEVTYPE_PRINTER = 0x02, + SPC3_DEVTYPE_PROCESSOR = 0x03, + SPC3_DEVTYPE_WORM = 0x04, + SPC3_DEVTYPE_MMC = 0x05, + SPC3_DEVTYPE_SCANNER = 0x06, + SPC3_DEVTYPE_OPTICAL = 0x07, + SPC3_DEVTYPE_CHANGER = 0x08, + SPC3_DEVTYPE_COMM = 0x09, + SPC3_DEVTYPE_ARRAY_CONTROLLER = 0x0c, + SPC3_DEVTYPE_SES = 0x0d, + SPC3_DEVTYPE_RBC = 0xe, + SPC3_DEVTYPE_OCRW = 0xf, + SPC3_DEVTYPE_BCC = 0x10, + SPC3_DEVTYPE_OSD = 0x11, + SPC3_DEVTYPE_ADC = 0x12 +} spc3_dev_type_t; + +/* + * SAM-4 5.3.1, Table 25 + */ +typedef enum sam4_status { + SAM4_STATUS_GOOD = 0x0, + SAM4_STATUS_CHECK_CONDITION = 0x2, + SAM4_STATUS_CONDITION_MET = 0x4, + SAM4_STATUS_BUSY = 0x8, + SAM4_STATUS_RESERVATION_CONFLICT = 0x18, + SAM4_STATUS_TASK_SET_FULL = 0x28, + SAM4_STATUS_ACA_ACTIVE = 0x30, + SAM4_STATUS_TASK_ABORTED = 0x40 +} sam4_status_t; + +#pragma pack(1) + +typedef union spc3_control { + struct { + DECL_BITFIELD5( + c_link :1, + c_flag :1, + c_naca :1, + _reserved1 :3, + c_vs_6 :2); + } c_bits; + uint8_t c_byte; +} spc3_control_t; + +/* + * SPC-3 6.2.1 CHANGE ALIASES + */ +typedef struct spc3_change_aliases_cdb { + uint8_t cac_opcode; + DECL_BITFIELD2( + cac_service_action :5, + _reserved1 :3); + uint8_t _reserved2[4]; + uint32_t cac_parameter_list_length; + uint8_t _reserved3; + spc3_control_t cac_control; +} spc3_change_aliases_cdb_t; + +typedef struct spc3_alias_entry { + uint64_t ae_alias_value; + uint8_t ae_protocol_identifier; + uint8_t _reserved1[2]; + uint8_t ae_format_code; + uint8_t _reserved2[2]; + uint16_t ae_designation_length; + uint8_t ae_designation[1]; /* Flexible */ +} spc3_alias_entry_t; + +typedef struct spc3_change_aliases_param_list { + uint32_t capl_parameter_data_length; + uint8_t _reserved1[4]; + spc3_alias_entry_t capl_alias_entries[1]; /* Flexible */ +} spc3_change_aliases_param_list_t; + +/* + * SPC-3 6.4.1 INQUIRY + */ +typedef struct spc3_inquiry_cdb { + uint8_t ic_opcode; + DECL_BITFIELD2( + ic_evpd :1, + _reserved1 :7); + uint8_t ic_page_code; + uint16_t ic_allocation_length; + spc3_control_t ic_control; +} spc3_inquiry_cdb_t; + +typedef struct spc3_inquiry_data { + DECL_BITFIELD2( + id_peripheral_device_type :5, + id_peripheral_qualifier :3); + DECL_BITFIELD2( + _reserved1 :7, + id_rmb :1); + uint8_t id_version; + DECL_BITFIELD4( + id_response_data_format :4, + id_hisup :1, + id_naca :1, + _reserved2 :2); + uint8_t additional_length; + DECL_BITFIELD6( + id_protect :1, + _reserved3 :2, + id_3pc :1, + id_tpgs :2, + id_acc :1, + id_sccs :1); + DECL_BITFIELD7( + id_addr16 :1, + _reserved4 :2, + id_mchanger :1, + id_multip :1, + id_vs_6_5 :1, + id_enc_serv :1, + id_b_que :1); + DECL_BITFIELD7( + id_vs_7_0 :1, + id_cmd_que :1, + _reserved5 :1, + id_linked :1, + id_sync :1, + id_wbus16 :1, + _reserved6 :2); + char id_vendor_id[8]; + char id_product_id[16]; + char id_product_revision[4]; + uint8_t id_vs_36[20]; + DECL_BITFIELD4( + id_ius :1, + id_qas :1, + id_clocking :2, + _reserved7 :4); + uint8_t _reserved8; + uint16_t id_version_descriptors[8]; + uint8_t _reserved9[22]; + uint8_t id_vs_96[1]; /* Flexible */ +} spc3_inquiry_data_t; + +/* + * SPC-3 6.5 LOG SELECT + */ +typedef enum spc3_log_page_control { + SPC3_LOG_PC_CUR_THRESHOLD = 0, + SPC3_LOG_PC_CUR_CUMULATIVE = 1, + SPC3_LOG_PC_DEF_THRESHOLD = 2, + SPC3_LOG_PC_DEF_CUMULATIVE = 3 +} spc3_log_page_control_t; + +typedef struct spc3_log_select_cdb { + uint8_t lsc_opcode; + DECL_BITFIELD3( + lsc_sp :1, + lsc_pcr :1, + _reserved1 :6); + DECL_BITFIELD2( + _reserved2 :6, + lsc_pc :2); + uint8_t _reserved3[4]; + uint16_t lsc_parameter_list_length; + spc3_control_t lsc_control; +} spc3_log_select_cdb_t; + +/* + * SPC-3 6.6 LOG SENSE + */ +typedef struct spc3_log_sense_cdb { + uint8_t lsc_opcode; + DECL_BITFIELD3( + lsc_sp :1, + lsc_ppc :1, + _reserved1 :6); + DECL_BITFIELD2( + lsc_page_code :6, + lsc_pc :2); + uint8_t _reserved2[2]; + uint16_t lsc_parameter_ptr; + uint16_t lsc_allocation_length; + spc3_control_t lsc_control; +} spc3_log_sense_cdb_t; + +typedef enum spc3_mode_page_control { + SPC3_MODE_PC_CURRENT = 0, + SPC3_MODE_PC_CHANGEABLE = 1, + SPC3_MODE_PC_DEFAULT = 2, + SPC3_MODE_PC_SAVED = 3 +} spc3_mode_page_control_t; + +typedef struct spc3_mode_param_header6 { + uint8_t mph_mode_data_length; + uint8_t mph_medium_type; + uint8_t mph_device_param; + uint8_t mph_block_descriptor_length; +} spc3_mode_param_header6_t; + +typedef spc3_mode_param_header6_t spc3_mode_param_header_t; + +typedef struct spc3_mode_param_header10 { + uint16_t mph_mode_data_length; + uint8_t mph_medium_type; + uint8_t mph_device_param; + DECL_BITFIELD2( + mph_longlba :1, + _reserved1 :7); + uint8_t _reserved2; + uint16_t mph_block_descriptor_length; +} spc3_mode_param_header10_t; + +typedef struct spc3_mode_param_block_descriptor { + uint8_t mpbd_density_code; + uint8_t mpbd_nblocks[3]; + uint8_t _reserved1; + uint8_t mpbd_block_length[3]; +} spc3_mode_param_block_descriptor_t; + +typedef struct spc3_mode_page_0 { + DECL_BITFIELD3( + mp0_page_code :6, + mp0_spf :1, + mp0_ps :1); + uint8_t mp0_page_length; + uint8_t mp0_mode_parameters[1]; /* Flexible */ +} spc3_mode_page_0_t; + +typedef struct spc3_mode_subpage { + DECL_BITFIELD3( + ms_page_code :6, + ms_spf :1, + ms_ps :1); + uint8_t ms_subpage_code; + uint16_t ms_page_length; + uint8_t ms_mode_parameters[1]; /* Flexible */ +} spc3_mode_subpage_t; + +/* + * SPC-3 7.4.6 Table 246 - TST field + */ +typedef enum spc3_mode_task_set { + SPC3_MODE_TST_ONE = 0, + SPC3_MODE_TST_SEPARATE = 1 +} spc3_mode_task_set_t; + +/* + * SPC-3 7.4.6 Table 247 - Queue Algorithm Modifier field + */ +typedef enum spc3_mode_queue_alg_mod { + SPC3_MODE_QAM_RESTRICTED = 0, + SPC3_MODE_QAM_UNRESTRICTED = 1 +} spc3_mode_queue_alg_mod_t; + +/* + * SPC-3 7.4.6 Table 245 + */ +typedef struct spc3_mode_params_control { + DECL_BITFIELD6( + mpc_rlec :1, + mpc_gltsd :1, + mpc_d_sense :1, + _reserved1 :1, + mpc_tmf_only :1, + mpc_tst :3); + DECL_BITFIELD4( + _reserved2 :1, + mpc_q_err :1, + _reserved3 :1, + mpc_queue_alg_mod :4); + DECL_BITFIELD5( + _reserved4 :3, + mpc_swp :1, + mpc_ua_intlck_ctrl :2, + mpc_rac :1, + mpc_vs_4_7 :1); + DECL_BITFIELD4( + mpc_autoload_mode :3, + _reserved5 :3, + mpc_tas :1, + mpc_ato :1); + uint8_t _reserved6[2]; + uint16_t mpc_busy_timeout_period; + uint16_t mpc_ext_selftest_completion_time; +} spc3_mode_page_params_control_t; + +/* + * SPC-3 7.4.7 Control Extension mode page + */ +typedef struct spc3_mode_params_control_ext { + DECL_BITFIELD4( + mpce_ialuae :1, + mpce_scsip :1, + mpce_tcmos :1, + _reserved1 :5); + DECL_BITFIELD2( + mpce_initial_priority :4, + _reserved2 :4); + uint8_t _reserved3[26]; +} spc3_mode_params_control_ext_t; + +/* + * SPC-3 7.4.8 Disconnect-Reconnect mode page + */ +typedef struct spc3_mode_params_dc_rc { + uint8_t mpdr_buffer_full_ratio; + uint8_t mpdr_buffer_empty_ratio; + uint16_t mpdr_bus_inactivity_limit; + uint16_t mpdr_disconnect_time_limit; + uint16_t mpdr_connect_time_limit; + uint16_t mpdr_max_burst_size; + DECL_BITFIELD4( + mpdr_dtdc :3, + mpdr_di_mm :1, + mpdr_fair_arbitration :3, + mpdr_emdp :1); + uint8_t _reserved1; + uint16_t mpdr_first_burst_size; +} spc3_mode_params_dc_rc_t; + +typedef enum spc3_mode_mrie { + SPC3_MODE_MRIE_NONE = 0, + SPC3_MODE_MRIE_ASYNC = 1, + SPC3_MODE_MRIE_UNIT_ATTN = 2, + SPC3_MODE_MRIE_COND_REC_ERR = 3, + SPC3_MODE_MRIE_UNCOND_REC_ERR = 4, + SPC3_MODE_MRIE_NO_SENSE = 5, + SPC3_MODE_MRIE_REQUEST = 6 +} spc3_mode_mrie_t; + +/* + * SPC-3 7.4.11 Informational Exceptions Control mode page + */ +typedef struct spc3_mode_params_iec { + DECL_BITFIELD8( + mpi_log_err :1, + _reserved1 :1, + mpi_test :1, + mpi_d_excpt :1, + mpi_e_wasc :1, + mpi_ebf :1, + _reserved2 :1, + mpi_perf :1); + DECL_BITFIELD2( + mpi_mrie :4, + _reserved3 :4); + uint32_t mpi_interval_timer; + uint32_t mpi_report_count; +} spc3_mode_params_iec_t; + +/* + * SPC-3 7.4.12 Power Condition mode page + */ +typedef struct spc3_mode_params_pc { + uint8_t _reserved1; + DECL_BITFIELD3( + mpp_standby :1, + mpp_idle :1, + _reserved2 :6); + uint32_t mpp_idle_condition_timer; + uint32_t mpp_standby_condition_timer; +} spc3_mode_params_pc_t; + +/* + * SPC-3 6.7 MODE SELECT(6) + */ +typedef struct spc3_mode_select6_cdb { + uint8_t msc_opcode; + DECL_BITFIELD4( + msc_sp :1, + _reserved1 :3, + msc_pf :1, + _reserved2 :3); + uint8_t _reserved3[2]; + uint8_t msc_parameter_list_length; + spc3_control_t msc_control; +} spc3_mode_select6_cdb_t; + +typedef spc3_mode_select6_cdb_t spc3_mode_select_cdb_t; + +/* + * SPC-3 6.8 MODE SELECT(10) + */ +typedef struct spc3_mode_select10_cdb { + uint8_t msc_opcode; + DECL_BITFIELD4( + msc_sp :1, + _reserved1 :3, + msc_pf :1, + _reserved2 :3); + uint8_t _reserved3[5]; + uint16_t msc_parameter_list_length; + spc3_control_t msc_control; +} spc3_mode_select10_cdb_t; + +/* + * SPC-3 6.9 MODE SENSE(6) + */ +typedef struct spc3_mode_sense6_cdb { + uint8_t msc_opcode; + DECL_BITFIELD3( + _reserved1 :3, + msc_dbd :1, + _reserved2 :4); + DECL_BITFIELD2( + msc_page_code :6, + msc_pc :2); + uint8_t msc_subpage_code; + uint8_t msc_allocation_length; + spc3_control_t msc_control; +} spc3_mode_sense6_cdb_t; + +typedef spc3_mode_sense6_cdb_t spc3_mode_sense_cdb_t; + +/* + * SPC-3 6.10 MODE SENSE(10) + */ +typedef struct spc3_mode_sense10_cdb { + uint8_t msc_opcode; + DECL_BITFIELD4( + _reserved1 :3, + msc_dbd :1, + msc_llbaa :1, + _reserved2 :3); + DECL_BITFIELD2( + msc_page_code :6, + msc_pc :2); + uint8_t msc_subpage_code; + uint8_t _reserved3[3]; + uint16_t msc_allocation_length; + spc3_control_t msc_control; +} spc3_mode_sense10_cdb_t; + +/* + * SPC-3 6.11 PERSISTENT RESERVE IN + */ +typedef enum spc3_persistent_reserve_in_sac { + SPC3_PRI_SAC_READ_KEYS = 0, + SPC3_PRI_SAC_READ_RESERVATION = 1, + SPC3_PRI_SAC_REPORT_CAPABILITIES = 2, + SPC3_PRI_SAC_READ_FULL_STATUS = 3 +} spc3_persistent_reserve_in_sac_t; + +typedef struct spc3_persistent_reserve_in_param_rk { + uint32_t pripr_pr_generation; + uint32_t pripr_additional_length; + uint64_t pripr_keys[1]; /* Flexible */ +} spc3_persistent_reserve_in_param_rk_t; + +typedef enum spc3_persistent_reserve_type { + SPC3_PR_TYPE_WREXCL = 1, + SPC3_PR_TYPE_EXCL = 3, + SPC3_PR_WREXCL_REG_ONLY = 5, + SPC3_PR_EXCL_REG_ONLY = 6, + SPC3_PR_WREXCL_ALL_REG = 7, + SPC3_PR_EXCL_ALL_REG = 8 +} spc3_persistent_reserve_type_t; + +typedef struct spc3_persistent_reserve_in_param_rr { + uint32_t pripr_pr_generation; + uint32_t pripr_additional_length; + uint64_t pripr_key; + uint8_t _reserved1[4]; + uint8_t _reserved2; + DECL_BITFIELD2( + pripr_type :4, + pripr_scope :4); + uint8_t _reserved3[2]; +} spc3_persistent_reserve_in_param_rr_t; + +typedef struct spc3_persistent_reserve_in_param_rc { + uint16_t pripr_length; + DECL_BITFIELD6( + pripr_ptpl_c :1, + _reserved1 :1, + pripr_atp_c :1, + pripr_sip_c :1, + pripr_crh :1, + _reserved2 :3); + DECL_BITFIELD3( + pripr_ptpl_a :1, + _reserved3 :6, + pripr_tmv :1); + DECL_BITFIELD8( + _reserved4 :1, + pripr_wr_ex :1, + _reserved5 :1, + pripr_ex_ac :1, + _reserved6 :1, + pripr_wr_ex_ro :1, + pripr_ex_ac_ro :1, + pripr_wr_ex_ar :1); + DECL_BITFIELD2( + pripr_ex_ac_ar :1, + _reserved7 :7); + uint8_t _reserved8[2]; +} spc3_persistent_reserve_in_param_rc_t; + +typedef struct spc3_persistent_reserve_full_status { + uint64_t prfs_key; + uint8_t _reserved1[4]; + DECL_BITFIELD3( + prfs_r_holder :1, + prfs_all_tg_pt :1, + _reserved2 :6); + DECL_BITFIELD2( + prfs_type :4, + prfs_scope :4); + uint8_t _reserved3[4]; + uint16_t prfs_relative_target_port_identifier; + uint32_t prfs_additional_descriptor_length; + uint8_t prfs_transport_id[1]; /* Flexible */ +} spc3_persistent_reserve_full_status_t; + +typedef struct spc3_persistent_reserve_in_param_rfs { + uint32_t pripr_pr_generation; + uint32_t pripr_additional_length; + uint8_t pripr_status_descriptors[1]; /* Flexible */ +} spc3_persistent_reserve_in_param_rfs_t; + +typedef struct spc3_persistent_reserve_in_cdb { + uint8_t pric_opcode; + DECL_BITFIELD2( + pric_service_action :5, + _reserved1 :3); + uint8_t _reserved2[5]; + uint16_t pric_allocation_length; + spc3_control_t pric_control; +} spc3_persistent_reserve_in_cdb_t; + +/* + * SPC-3 6.15 READ BUFFER + */ +typedef struct spc3_read_buffer_cdb { + uint8_t rbc_opcode; + DECL_BITFIELD2( + rbc_mode :5, + _reserved :3); + uint8_t rbc_bufferid; + uint8_t rbc_buffer_offset[3]; + uint8_t rbc_allocation_len[3]; + spc3_control_t rbc_control; +} spc3_read_buffer_cdb_t; + +typedef enum spc3_read_buffer_mode { + SPC3_RB_MODE_COMB_HDR_DATA = 0x00, + SPC3_RB_MODE_VENDOR_SPECIFIC = 0x01, + SPC3_RB_MODE_DATA = 0x02, + SPC3_RB_MODE_DESCRIPTOR = 0x03, + SPC3_RB_MODE_ECHO_BUF = 0x0a, + SPC3_RB_MODE_ECHO_BUF_DESC = 0x0b, + SPC3_RB_MODE_ENABLE_EXPANDER_ECHO_BUF = 0x1a +} spc3_read_buffer_mode_t; + +/* + * SPC-3 6.16 READ MEDIA SERIAL NUMBER + */ +typedef struct spc3_read_media_serial_number_cdb { + uint8_t rmsnc_opcode; + DECL_BITFIELD2( + rmsnc_service_action :5, + _reserved1 :3); + uint8_t _reserved2[4]; + uint32_t rmsnc_allocation_length; + uint8_t _reserved3; + spc3_control_t rmsnc_control; +} spc3_read_media_serial_number_cdb_t; + +typedef struct spc3_read_media_serial_number_data { + uint32_t msnd_length; + uint8_t msnd_serial_number[1]; /* Flexible */ +} spc3_read_media_serial_number_data_t; + +/* + * SPC-3 6.18 RECEIVE DIAGNOSTIC RESULTS + */ +typedef struct spc3_receive_diagnostic_results_cdb { + uint8_t rdrc_opcode; + DECL_BITFIELD2( + rdrc_pcv :1, + _reserved1 :7); + uint8_t rdrc_page_code; + uint16_t rdrc_allocation_length; + spc3_control_t rdrc_control; +} spc3_receive_diagnostic_results_cdb_t; + +/* + * SPC-3 Diagnostic page format (Table 194, 7.1.1) + */ +typedef struct spc3_diag_page_impl { + uint8_t sdpi_page_code; + uint8_t sdpi_specific; + uint16_t sdpi_page_length; + uint8_t sdpi_data[1]; +} spc3_diag_page_impl_t; + +/* + * SPC-3 Supported diagnostic pages (Table 196, 7.1.2) + */ +typedef struct spc3_supported_diag_page_impl { + uint8_t ssdpi_page_code; + uint8_t _reserved1; + uint16_t ssdpi_page_length; + uint8_t ssdpi_page_list[1]; +} spc3_supported_diag_page_impl_t; + +/* + * SPC-3 6.21 REPORT LUNS + */ +typedef enum spc3_report_luns_select_report { + SPC3_RL_SR_ADDRESSING = 0, + SPC3_RL_SR_WELLKNOWN = 1, + SPC3_RL_SR_ALL = 2 +} spc3_report_luns_select_report_t; + +typedef struct spc3_report_luns_cdb { + uint8_t rlc_opcode; + uint8_t _reserved1; + uint8_t rlc_select_report; + uint8_t _reserved2[3]; + uint32_t rlc_allocation_length; + uint8_t _reserved3; + spc3_control_t rlc_control; +} spc3_report_luns_cdb_t; + +typedef struct spc3_report_luns_data { + uint32_t rld_lun_list_length; + uint8_t _reserved1[4]; + uint64_t rld_luns[1]; /* Flexible */ +} spc3_report_luns_data_t; + +/* + * SPC-3 6.27 REQUEST SENSE + */ +typedef struct spc3_request_sense_cdb { + uint8_t rsc_opcode; + DECL_BITFIELD2( + rsc_desc :1, + _reserved1 :7); + uint8_t _reserved2[2]; + uint8_t rsc_allocation_length; + spc3_control_t rsc_control; +} spc3_request_sense_cdb_t; + +/* + * SPC-3 6.28 SEND DIAGNOSTIC + */ +typedef struct spc3_send_diagnostic_cdb { + uint8_t sdc_opcode; + DECL_BITFIELD6( + sdc_unit_off_l :1, + sdc_dev_off_l :1, + sdc_self_test :1, + _reserved1 :1, + sdc_pf :1, + sdc_selftest_code :3); + uint8_t _reserved2; + uint16_t sdc_parameter_list_length; + spc3_control_t sdc_control; +} spc3_send_diagnostic_cdb_t; + +/* + * SPC-3 6.33 TEST UNIT READY + */ +typedef struct spc3_test_unit_ready_cdb { + uint8_t tur_opcode; + uint8_t _reserved1[4]; + spc3_control_t tur_control; +} spc3_test_unit_ready_cdb_t; + +/* + * SPC-3 6.36 WRITE BUFFER + */ +typedef struct spc3_write_buffer_cdb { + uint8_t wbc_opcode; + DECL_BITFIELD2( + wbc_mode :5, + _reserved :3); + uint8_t wbc_bufferid; + uint8_t wbc_buffer_offset[3]; + uint8_t wbc_parameter_list_len[3]; + spc3_control_t wbc_control; +} spc3_write_buffer_cdb_t; + +typedef enum spc3_write_buffer_mode { + SPC3_WB_MODE_COMB_HDR_DATA = 0x00, + SPC3_WB_MODE_VENDOR_SPECIFIC = 0x01, + SPC3_WB_MODE_DATA = 0x02, + SPC3_WB_MODE_DL_UCODE = 0x04, + SPC3_WB_MODE_DL_UCODE_SAVE = 0x05, + SPC3_WB_MODE_DL_UCODE_OFFS = 0x06, + SPC3_WB_MODE_DL_UCODE_OFFS_SAVE = 0x07, + SPC3_WB_MODE_ECHO_BUF = 0x0a, + SPC3_WB_MODE_DL_UCODE_OFFS_DEFER = 0x0e, + SPC3_WB_MODE_ACTIVATE_DEFERRED_UCODE = 0x0f, + SPC3_WB_MODE_ENABLE_EXPANDER_ECHO_BUF = 0x1a, + SPC3_WB_MODE_DISABLE_EXPANDER = 0x1b, + SPC3_WB_MODE_DL_APP_LOG = 0x1c +} spc3_write_buffer_mode_t; + +typedef struct spc3_write_buffer_log { + uint8_t wbl_vendor[8]; + uint16_t wbl_error_type; + uint16_t _reserved1; + uint8_t wbl_timestamp[6]; + uint16_t _reserved2; + DECL_BITFIELD2( + _reserved3 :4, + wbl_codeset :4); + uint8_t wbl_error_location_fmt; + uint16_t wbl_error_location_len; + uint16_t wbl_client_error_history_len; + uint32_t wbl_data[1]; +} spc3_write_buffer_log_t; + +typedef enum sp3_write_buffer_error_type { + SPC3_WB_ERROR_NONE = 0x0000, + SPC3_WB_ERROR_UNKNOWN = 0x0001, + SPC3_WB_ERROR_DATA_CORRUPT = 0x0002, + SPC3_WB_ERROR_PERMANENT = 0x0003, + SPC3_WB_ERROR_SERVICETARGET_FAILURE = 0x0004 +} spc3_write_buffer_error_type_t; + +typedef enum spc3_write_buffer_codeset { + SPC3_WB_CODESET_RESERVED = 0x00, + SPC3_WB_CODESET_BIN = 0x01, + SPC3_WB_CODESET_ASCII = 0x02, + SPC3_WB_CODESET_UTF8 = 0x03 +} spc3_write_buffer_codeset_t; + +typedef enum spc_3_write_buffer_error_location { + SPC3_WB_ERROR_LOCATION_FMT_NONE = 0x00, + SPC3_WB_ERROR_LOCATION_FMT_LBA = 0x01 +} spc3_write_buffer_error_location_t; + +/* + * SPC-4 7.5.1 Protocol values + */ +typedef enum spc4_protocol_id { + SPC4_PROTO_FIBRE_CHANNEL = 0, + SPC4_PROTO_PARALLEL_SCSI = 1, + SPC4_PROTO_SSA = 2, + SPC4_PROTO_IEEE1394 = 3, + SPC4_PROTO_RDMA = 4, + SPC4_PROTO_ISCSI = 5, + SPC4_PROTO_SAS = 6, + SPC4_PROTO_ADT = 7, + SPC4_PROTO_ATA = 8, + SPC4_PROTO_NONE = 0xf +} spc4_protocol_id_t; + +/* + * SPC-3 NAA identifier format (Table 305, 7.6.3.6.1) + */ +typedef struct spc3_naa_id_impl { + DECL_BITFIELD2( + snii_priv_msn :4, + snii_naa :4); + uint8_t snii_priv[1]; +} spc3_naa_id_impl_t; + +/* + * SPC-3 NAA IEEE Extended Identifier field format (Table 307, 7.6.3.6.2) + */ +typedef struct spc3_naa_ieee_ext_id_impl { + DECL_BITFIELD2( + snieii_vendor_id_a_msn :4, + snieii_naa :4); + uint8_t snieii_vendor_id_a_lsb; + uint8_t snieii_company_id[3]; + uint8_t snieii_vendor_id_b[3]; +} spc3_naa_ieee_ext_id_impl_t; + +#define NAA_IEEE_EXT_VENDOR_A(idp) \ + SCSI_MK12_4_8((idp)->snieii_vendor_id_a_msn, \ + (idp)->snieii_vendor_id_a_lsb) +#define NAA_IEEE_EXT_COMPANY_ID(idp) SCSI_READ24((idp)->snieii_company_id) +#define NAA_IEEE_EXT_VENDOR_B(idp) SCSI_READ24((idp)->snieii_vendor_id_b) + +/* + * Ibid, Table 308 + */ +typedef struct spc3_naa_ieee_reg_id_impl { + DECL_BITFIELD2( + snirii_company_id_msn :4, + snirii_naa :4); + uint16_t snirii_company_id_mid; + DECL_BITFIELD2( + snirii_vendor_id_msn :4, + snirii_company_id_lsn :4); + uint32_t snirii_vendor_id_low; +} spc3_naa_ieee_reg_id_impl_t; + +#define NAA_IEEE_REG_COMPANY_ID(idp) \ + SCSI_MK24_4_16_4((idp)->snirii_company_id_msn, \ + SCSI_READ16(&(idp)->snirii_company_id_mid), \ + (idp)->snirii_company_id_lsn) +#define NAA_IEEE_REG_VENDOR_ID(idp) \ + SCSI_MK36_4_32((idp)->snirii_vendor_id_msn, \ + SCSI_READ32(&(idp)->snirii_vendor_id_low)) + +/* + * Ibid, Table 309 + */ +typedef struct spc3_naa_ieee_reg_ext_id_impl { + DECL_BITFIELD2( + snireii_company_id_msn :4, + snireii_naa :4); + uint16_t snireii_company_id_mid; + DECL_BITFIELD2( + snireii_vendor_id_msn :4, + snireii_company_id_lsn :4); + uint32_t snireii_vendor_id_low; + uint64_t snireii_vendor_id_ext; +} spc3_naa_ieee_reg_ext_id_impl_t; + +#define NAA_IEEE_REG_EXT_COMPANY_ID(idp) \ + SCSI_MK20_4_16_4((idp)->snireii_company_id_msn, \ + SCSI_READ16(&(idp)->snireii_company_id_mid), \ + (idp)->snireii_company_id_lsn) +#define NAA_IEEE_REG_EXT_VENDOR_ID(idp) \ + SCSI_MK36_4_32((idp)->snireii_vendor_id_msn, \ + SCSI_READ32(&(idp)->snireii_vendor_id_low)) + +typedef union spc3_naa_id_8_impl { + struct { + DECL_BITFIELD2( + _reserved1 :4, + sni8i_naa :4); + } sni8i_hdr; + spc3_naa_ieee_ext_id_impl_t sni8i_ext_id; + spc3_naa_ieee_reg_id_impl_t sni8i_reg_id; +} spc3_naa_id_8_impl_t; + +#define sni8i_naa sni8i_hdr.sni8i_naa + +typedef enum naa_id { + NAA_IEEE_EXT = 0x2, + NAA_LOCAL = 0x3, + NAA_IEEE_REG = 0x5, + NAA_IEEE_REG_EXT = 0x6 +} naa_id_t; + +#pragma pack() + +#ifdef __cplusplus +} +#endif + +#endif /* _SPC3_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/status.h b/illumos-x86_64/usr/include/sys/scsi/impl/status.h new file mode 100644 index 00000000..c5b6ea3d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/status.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SCSI_IMPL_STATUS_H +#define _SYS_SCSI_IMPL_STATUS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Implementation specific SCSI status definitions + * + */ + +/* + * The size of a status block (much more than is really needed...) + */ + +#define STATUS_SIZE 4 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_STATUS_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/transport.h b/illumos-x86_64/usr/include/sys/scsi/impl/transport.h new file mode 100644 index 00000000..c1e9d27e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/transport.h @@ -0,0 +1,690 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2014 Garrett D'Amore + * Copyright 2022 RackTop Systems, Inc. + */ + +#ifndef _SYS_SCSI_IMPL_TRANSPORT_H +#define _SYS_SCSI_IMPL_TRANSPORT_H + +/* + * Include the loadable module wrapper. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Opaque handles to address maps + */ +typedef struct __scsi_iportmap scsi_hba_iportmap_t; +typedef struct __scsi_tgtmap scsi_hba_tgtmap_t; + +/* + * SCSI transport structures + * + * As each Host Adapter makes itself known to the system, + * it will create and register with the library the structure + * described below. This is so that the library knows how to route + * packets, resource control requests, and capability requests + * for any particular host adapter. The 'a_hba_tran' field of a + * scsi_address structure made known to a Target driver will + * point to one of these transport structures. + */ + +typedef struct scsi_hba_tran scsi_hba_tran_t; + +struct scsi_hba_tran { + /* + * Ptr to the device info structure for this particular HBA. If a SCSA + * HBA driver separates initiator port function from HBA function, + * this field still refers to the HBA and is used to manage DMA. + */ + dev_info_t *tran_hba_dip; + + /* + * Private fields for use by the HBA itself. + */ + void *tran_hba_private; /* HBA softstate */ + + /* + * The following two fields are only used in the deprecated + * SCSI_HBA_TRAN_CLONE case. Use SCSI_HBA_ADDR_COMPLEX instead. + */ + void *tran_tgt_private; + struct scsi_device *tran_sd; + + /* + * Vectors to point to specific HBA entry points + */ + int (*tran_tgt_init)( + dev_info_t *hba_dip, + dev_info_t *tgt_dip, + scsi_hba_tran_t *tran, + struct scsi_device *sd); + + int (*tran_tgt_probe)( + struct scsi_device *sd, + int (*callback)( + void)); + void (*tran_tgt_free)( + dev_info_t *hba_dip, + dev_info_t *tgt_dip, + scsi_hba_tran_t *tran, + struct scsi_device *sd); + + int (*tran_start)( + struct scsi_address *ap, + struct scsi_pkt *pkt); + + int (*tran_reset)( + struct scsi_address *ap, + int level); + + int (*tran_abort)( + struct scsi_address *ap, + struct scsi_pkt *pkt); + + int (*tran_getcap)( + struct scsi_address *ap, + char *cap, + int whom); + + int (*tran_setcap)( + struct scsi_address *ap, + char *cap, + int value, + int whom); + + struct scsi_pkt *(*tran_init_pkt)( + struct scsi_address *ap, + struct scsi_pkt *pkt, + struct buf *bp, + int cmdlen, + int statuslen, + int tgtlen, + int flags, + int (*callback)( + caddr_t arg), + caddr_t callback_arg); + + void (*tran_destroy_pkt)( + struct scsi_address *ap, + struct scsi_pkt *pkt); + + void (*tran_dmafree)( + struct scsi_address *ap, + struct scsi_pkt *pkt); + + void (*tran_sync_pkt)( + struct scsi_address *ap, + struct scsi_pkt *pkt); + + int (*tran_reset_notify)( + struct scsi_address *ap, + int flag, + void (*callback)(caddr_t), + caddr_t arg); + + int (*tran_get_bus_addr)( + struct scsi_device *sd, + char *name, + int len); + + int (*tran_get_name)( + struct scsi_device *sd, + char *name, + int len); + + int (*tran_clear_aca)( + struct scsi_address *ap); + + int (*tran_clear_task_set)( + struct scsi_address *ap); + + int (*tran_terminate_task)( + struct scsi_address *ap, + struct scsi_pkt *pkt); + + int (*tran_get_eventcookie)( + dev_info_t *hba_dip, + dev_info_t *tgt_dip, + char *name, + ddi_eventcookie_t *eventp); + + int (*tran_add_eventcall)( + dev_info_t *hba_dip, + dev_info_t *tgt_dip, + ddi_eventcookie_t event, + void (*callback)( + dev_info_t *tgt_dip, + ddi_eventcookie_t event, + void *arg, + void *bus_impldata), + void *arg, + ddi_callback_id_t *cb_id); + + int (*tran_remove_eventcall)(dev_info_t *devi, + ddi_callback_id_t cb_id); + + int (*tran_post_event)( + dev_info_t *hba_dip, + dev_info_t *tgt_dip, + ddi_eventcookie_t event, + void *bus_impldata); + + int (*tran_quiesce)( + dev_info_t *hba_dip); + + int (*tran_unquiesce)( + dev_info_t *hba_dip); + + int (*tran_bus_reset)( + dev_info_t *hba_dip, + int level); + + /* + * Implementation-private specifics. + * No HBA should refer to any of the fields below. + * This information can and will change. + */ + int tran_hba_flags; /* flag options */ + + uint_t tran_obs1; + uchar_t tran_obs2; + uchar_t tran_obs3; + + /* + * open_lock: protect tran_minor_isopen + * open_flag: bit field indicating which minor nodes are open. + * 0 = closed, 1 = shared open, all bits 1 = excl open. + * + * NOTE: Unused if HBA driver implements its own open(9e) entry point. + */ + kmutex_t tran_open_lock; + uint64_t tran_open_flag; + + /* + * bus_config vectors - ON Consolidation Private + * These interfaces are subject to change. + */ + int (*tran_bus_config)( + dev_info_t *hba_dip, + uint_t flag, + ddi_bus_config_op_t op, + void *arg, + dev_info_t **tgt_dipp); + + int (*tran_bus_unconfig)( + dev_info_t *hba_dip, + uint_t flag, + ddi_bus_config_op_t op, + void *arg); + + int (*tran_bus_power)( + dev_info_t *dip, + void *impl_arg, + pm_bus_power_op_t op, + void *arg, + void *result); + + /* + * Inter-Connect type of transport as defined in + * usr/src/uts/common/sys/scsi/impl/services.h + */ + int tran_interconnect_type; + + /* tran_setup_pkt(9E) related scsi_pkt fields */ + int (*tran_pkt_constructor)( + struct scsi_pkt *pkt, + scsi_hba_tran_t *tran, + int kmflag); + void (*tran_pkt_destructor)( + struct scsi_pkt *pkt, + scsi_hba_tran_t *tran); + kmem_cache_t *tran_pkt_cache_ptr; + uint_t tran_hba_len; + int (*tran_setup_pkt)( + struct scsi_pkt *pkt, + int (*callback)( + caddr_t arg), + caddr_t callback_arg); + void (*tran_teardown_pkt)( + struct scsi_pkt *pkt); + ddi_dma_attr_t tran_dma_attr; + + void *tran_extension; + + /* + * An fm_capable HBA driver can set tran_fm_capable prior to + * scsi_hba_attach_setup(). If not set, SCSA provides a default + * implementation. + */ + int tran_fm_capable; + + /* + * Ptr to the device info structure for initiator port. If a SCSA HBA + * driver separates initiator port function from HBA function, this + * field still refers to the initiator port. + */ + dev_info_t *tran_iport_dip; + + /* + * map of initiator ports below HBA + */ + scsi_hba_iportmap_t *tran_iportmap; + + /* + * map of targets below initiator + */ + scsi_hba_tgtmap_t *tran_tgtmap; + +#ifdef SCSI_SIZE_CLEAN_VERIFY + /* + * Must be last: Building a driver with-and-without + * -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for + * differences with a tools like 'wsdiff' allows a developer to verify + * that their driver has no dependencies on scsi*(9S) size. + */ + int _pad[8]; +#endif /* SCSI_SIZE_CLEAN_VERIFY */ +}; +size_t scsi_hba_tran_size(); /* private */ + +#ifdef __lock_lint +_NOTE(SCHEME_PROTECTS_DATA("stable data", + scsi_hba_tran::tran_sd + scsi_hba_tran::tran_hba_dip + scsi_hba_tran::tran_hba_flags + scsi_hba_tran::tran_open_flag + scsi_hba_tran::tran_pkt_cache_ptr)) +/* + * we only modify the dma attributes (like dma_attr_granular) upon + * attach and in response to a setcap. It is also up to the target + * driver to not have any outstanding I/Os when it is changing the + * capabilities of the transport. + */ +_NOTE(SCHEME_PROTECTS_DATA("serialized by target driver", \ + scsi_hba_tran::tran_dma_attr.dma_attr_granular)) +#endif + +/* + * Prototypes for SCSI HBA interface functions + * + * All these functions are public interfaces, with the + * exception of: + * interface called by + * scsi_initialize_hba_interface() _init() of scsi module + * scsi_uninitialize_hba_interface() _fini() of scsi module + */ + +void scsi_initialize_hba_interface(void); + +#ifdef NO_SCSI_FINI_YET +void scsi_uninitialize_hba_interface(void); +#endif /* NO_SCSI_FINI_YET */ + +int scsi_hba_init( + struct modlinkage *modlp); + +void scsi_hba_fini( + struct modlinkage *modlp); + +int scsi_hba_attach_setup( + dev_info_t *hba_dip, + ddi_dma_attr_t *hba_dma_attr, + scsi_hba_tran_t *tran, + int flags); + +int scsi_hba_detach( + dev_info_t *hba_dip); + +scsi_hba_tran_t *scsi_hba_tran_alloc( + dev_info_t *hba_dip, + int flags); + +int scsi_tran_ext_alloc( + scsi_hba_tran_t *tran, + size_t length, + int flags); + +void scsi_tran_ext_free( + scsi_hba_tran_t *tran, + size_t length); + +void scsi_hba_tran_free( + scsi_hba_tran_t *tran); + +int scsi_hba_probe( + struct scsi_device *sd, + int (*callback)(void)); + +int scsi_hba_probe_pi( + struct scsi_device *sd, + int (*callback)(void), + int pi); + +int scsi_hba_ua_get_reportdev( + struct scsi_device *sd, + char *ba, + int len); + +int scsi_hba_ua_get( + struct scsi_device *sd, + char *ua, + int len); + +char *scsi_get_device_type_string( + char *prop_name, + dev_info_t *hba_dip, + struct scsi_device *sd); + +int scsi_get_scsi_maxluns( + struct scsi_device *sd); + +int scsi_get_scsi_options( + struct scsi_device *sd, + int default_scsi_options); + +int scsi_get_device_type_scsi_options( + dev_info_t *hba_dip, + struct scsi_device *sd, + int default_scsi_options); + +struct scsi_pkt *scsi_hba_pkt_alloc( + dev_info_t *hba_dip, + struct scsi_address *ap, + int cmdlen, + int statuslen, + int tgtlen, + int hbalen, + int (*callback)(caddr_t), + caddr_t arg); + +void scsi_hba_pkt_free( + struct scsi_address *ap, + struct scsi_pkt *pkt); + + +int scsi_hba_lookup_capstr( + char *capstr); + +int scsi_hba_in_panic(void); + +int scsi_hba_open( + dev_t *devp, + int flags, + int otyp, + cred_t *credp); + +int scsi_hba_close( + dev_t dev, + int flag, + int otyp, + cred_t *credp); + +int scsi_hba_ioctl( + dev_t dev, + int cmd, + intptr_t arg, + int mode, + cred_t *credp, + int *rvalp); + +void scsi_hba_nodename_compatible_get( + struct scsi_inquiry *inq, + char *binding_set, + int dtype_node, + char *compat0, + char **nodenamep, + char ***compatiblep, + int *ncompatiblep); + +void scsi_hba_nodename_compatible_free( + char *nodename, + char **compatible); + +int scsi_device_prop_update_inqstring( + struct scsi_device *sd, + char *name, + char *data, + size_t len); + +void scsi_hba_pkt_comp( + struct scsi_pkt *pkt); + +int scsi_device_identity( + struct scsi_device *sd, + int (*callback)(void)); + +char *scsi_hba_iport_unit_address( + dev_info_t *dip); + +int scsi_hba_iport_register( + dev_info_t *dip, + char *port); + +int scsi_hba_iport_exist( + dev_info_t *dip); + +dev_info_t *scsi_hba_iport_find( + dev_info_t *pdip, + char *portnm); + + +/* + * Flags for scsi_hba_attach + * + * SCSI_HBA_ADDR_SPI The host adapter driver wants the + * scsi_address(9S) structure to be maintained + * in legacy SPI 'a_target'/'a_lun' form (default). + * + * SCSI_HBA_ADDR_COMPLEX The host adapter has a complex unit-address + * space, and the HBA driver wants to maintain + * per-scsi_device(9S) HBA private data using + * scsi_address_device(9F) and + * scsi_device_hba_private_[gs]et(9F). The HBA + * driver must maintain a private representation + * of the scsi_device(9S) unit-address - typically + * established during tran_tgt_init(9E) based on + * property values. + * + * SCSI_HBA_TRAN_PHCI The host adapter is an mpxio/scsi_vhci pHCI. + * The framework should take care of + * mdi_phci_register() stuff. + * + * SCSI_HBA_HBA The host adapter node (associated with a PCI + * function) is just an HBA, all SCSI initiator + * port function is provided by separate 'iport' + * children of the host adapter node. These iport + * children bind to the same driver as the host + * adapter node. Both nodes are managed by the + * same driver. The driver can distinguish context + * by calling scsi_hba_iport_unit_address(). + * + * ::SCSI_HBA_TRAN_CLONE Deprecated: use SCSI_HBA_ADDR_COMPLEX instead. + * SCSI_HBA_TRAN_CLONE was a KLUDGE to address + * limitations of the scsi_address(9S) structure + * via duplication of scsi_hba_tran(9S) and + * use of tran_tgt_private. + * + */ +#define SCSI_HBA_TRAN_CLONE 0x01 /* Deprecated */ +#define SCSI_HBA_TRAN_PHCI 0x02 /* treat HBA as mpxio 'pHCI' */ +#define SCSI_HBA_TRAN_CDB 0x04 /* allocate cdb */ +#define SCSI_HBA_TRAN_SCB 0x08 /* allocate sense */ +#define SCSI_HBA_HBA 0x10 /* all HBA children are iports */ + +#define SCSI_HBA_ADDR_SPI 0x20 /* scsi_address in SPI form */ +#define SCSI_HBA_ADDR_COMPLEX 0x40 /* scsi_address is COMPLEX */ + +/* upper bits used to record SCSA configuration state */ +#define SCSI_HBA_SCSA_PHCI 0x10000 /* need mdi_phci_unregister */ +#define SCSI_HBA_SCSA_TA 0x20000 /* scsi_hba_tran_alloc used */ +#define SCSI_HBA_SCSA_FM 0x40000 /* using common ddi_fm_* */ + +/* + * Flags for scsi_hba allocation functions + */ +#define SCSI_HBA_CANSLEEP 0x01 /* can sleep */ + +/* + * Support extra flavors for SCSA children + */ +#define SCSA_FLAVOR_SCSI_DEVICE NDI_FLAVOR_VANILLA +#define SCSA_FLAVOR_SMP 1 +#define SCSA_FLAVOR_IPORT 2 +#define SCSA_NFLAVORS 3 + +/* + * Maximum number of iport nodes under PCI function + */ +#define SCSI_HBA_MAX_IPORTS 32 + +/* + * SCSI iport map interfaces + */ +int scsi_hba_iportmap_create( + dev_info_t *hba_dip, + int csync_usec, + int stable_usec, + scsi_hba_iportmap_t **iportmapp); + +int scsi_hba_iportmap_iport_add( + scsi_hba_iportmap_t *iportmap, + char *iport_addr, + void *iport_priv); + +int scsi_hba_iportmap_iport_remove( + scsi_hba_iportmap_t *iportmap, + char *iport_addr); + +void scsi_hba_iportmap_destroy(scsi_hba_iportmap_t *iportmap); + +/* + * SCSI target map interfaces + */ +typedef enum { + SCSI_TM_FULLSET = 0, + SCSI_TM_PERADDR +} scsi_tgtmap_mode_t; + +typedef enum { + SCSI_TGT_SCSI_DEVICE = 0, + SCSI_TGT_SMP_DEVICE, + SCSI_TGT_NTYPES +} scsi_tgtmap_tgt_type_t; + +typedef enum { + SCSI_TGT_DEACT_RSN_GONE = 0, + SCSI_TGT_DEACT_RSN_CFG_FAIL, + SCSI_TGT_DEACT_RSN_UNSTBL +} scsi_tgtmap_deact_rsn_t; + +typedef void (*scsi_tgt_activate_cb_t)( + void *tgtmap_priv, + char *tgt_addr, + scsi_tgtmap_tgt_type_t tgt_type, + void **tgt_privp); +typedef boolean_t (*scsi_tgt_deactivate_cb_t)( + void *tgtmap_priv, + char *tgt_addr, + scsi_tgtmap_tgt_type_t tgt_type, + void *tgt_priv, + scsi_tgtmap_deact_rsn_t tgt_deact_rsn); +int scsi_hba_tgtmap_create( + dev_info_t *iport_dip, + scsi_tgtmap_mode_t rpt_mode, + int csync_usec, + int stable_usec, + void *tgtmap_priv, + scsi_tgt_activate_cb_t activate_cb, + scsi_tgt_deactivate_cb_t deactivate_cb, + scsi_hba_tgtmap_t **tgtmapp); + +int scsi_hba_tgtmap_set_begin(scsi_hba_tgtmap_t *tgtmap); + +int scsi_hba_tgtmap_set_add( + scsi_hba_tgtmap_t *tgtmap, + scsi_tgtmap_tgt_type_t tgt_type, + char *tgt_addr, + void *tgt_priv); + +int scsi_hba_tgtmap_set_end( + scsi_hba_tgtmap_t *tgtmap, + uint_t flags); + +int scsi_hba_tgtmap_set_flush(scsi_hba_tgtmap_t *tgtmap); + +int scsi_hba_tgtmap_tgt_add( + scsi_hba_tgtmap_t *tgtmap, + scsi_tgtmap_tgt_type_t tgt_type, + char *tgt_addr, + void *tgt_priv); + +int scsi_hba_tgtmap_tgt_remove( + scsi_hba_tgtmap_t *tgtmap, + scsi_tgtmap_tgt_type_t tgt_type, + char *tgt_addr); + +void scsi_hba_tgtmap_destroy(scsi_hba_tgtmap_t *tgt_map); + +void scsi_hba_tgtmap_scan_luns(scsi_hba_tgtmap_t *tgt_map, + char *tgt_addr); + + +/* + * For minor nodes created by the SCSA framework, minor numbers are + * formed by left-shifting instance by INST_MINOR_SHIFT and OR in a + * number less than 64. + * + * - Numbers 0 - 31 are reserved by the framework, part of the range are + * in use, as defined below. + * + * - Numbers 32 - 63 are available for HBA driver use. + */ +#define INST_MINOR_SHIFT 6 +#define TRAN_MINOR_MASK ((1 << INST_MINOR_SHIFT) - 1) +#define TRAN_OPEN_EXCL (uint64_t)-1 + +#define DEVCTL_MINOR 0 +#define SCSI_MINOR 1 + +#define INST2DEVCTL(x) (((x) << INST_MINOR_SHIFT) | DEVCTL_MINOR) +#define INST2SCSI(x) (((x) << INST_MINOR_SHIFT) | SCSI_MINOR) +#define MINOR2INST(x) ((x) >> INST_MINOR_SHIFT) + +#define SCSI_HBA_PROP_RECEPTACLE_LABEL "receptacle-label" + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_TRANSPORT_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/types.h b/illumos-x86_64/usr/include/sys/scsi/impl/types.h new file mode 100644 index 00000000..4efeac41 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/types.h @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_IMPL_TYPES_H +#define _SYS_SCSI_IMPL_TYPES_H + +/* + * Local Types for SCSI subsystems + */ + +#ifdef _KERNEL + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#endif /* _KERNEL */ + +#include + +#endif /* _SYS_SCSI_IMPL_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/uscsi.h b/illumos-x86_64/usr/include/sys/scsi/impl/uscsi.h new file mode 100644 index 00000000..f416b1bb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/uscsi.h @@ -0,0 +1,228 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2016 Joyent, Inc. + */ + +/* + * Defines for user SCSI commands + */ + +#ifndef _SYS_SCSI_IMPL_USCSI_H +#define _SYS_SCSI_IMPL_USCSI_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * definition for user-scsi command structure + */ +struct uscsi_cmd { + int uscsi_flags; /* read, write, etc. see below */ + short uscsi_status; /* resulting status */ + short uscsi_timeout; /* Command Timeout */ + caddr_t uscsi_cdb; /* cdb to send to target */ + caddr_t uscsi_bufaddr; /* i/o source/destination */ + size_t uscsi_buflen; /* size of i/o to take place */ + size_t uscsi_resid; /* resid from i/o operation */ + uchar_t uscsi_cdblen; /* # of valid cdb bytes */ + uchar_t uscsi_rqlen; /* size of uscsi_rqbuf */ + uchar_t uscsi_rqstatus; /* status of request sense cmd */ + uchar_t uscsi_rqresid; /* resid of request sense cmd */ + caddr_t uscsi_rqbuf; /* request sense buffer */ + ulong_t uscsi_path_instance; /* private: hardware path */ +}; + +#if defined(_SYSCALL32) +struct uscsi_cmd32 { + int uscsi_flags; /* read, write, etc. see below */ + short uscsi_status; /* resulting status */ + short uscsi_timeout; /* Command Timeout */ + caddr32_t uscsi_cdb; /* cdb to send to target */ + caddr32_t uscsi_bufaddr; /* i/o source/destination */ + size32_t uscsi_buflen; /* size of i/o to take place */ + size32_t uscsi_resid; /* resid from i/o operation */ + uchar_t uscsi_cdblen; /* # of valid cdb bytes */ + uchar_t uscsi_rqlen; /* size of uscsi_rqbuf */ + uchar_t uscsi_rqstatus; /* status of request sense cmd */ + uchar_t uscsi_rqresid; /* resid of request sense cmd */ + caddr32_t uscsi_rqbuf; /* request sense buffer */ + uint32_t uscsi_path_instance; /* private: hardware path */ +}; + +#define uscsi_cmd32touscsi_cmd(u32, ucmd) \ + ucmd->uscsi_flags = u32->uscsi_flags; \ + ucmd->uscsi_status = u32->uscsi_status; \ + ucmd->uscsi_timeout = u32->uscsi_timeout; \ + ucmd->uscsi_cdb = (caddr_t)(uintptr_t)u32->uscsi_cdb; \ + ucmd->uscsi_bufaddr = (caddr_t)(uintptr_t)u32->uscsi_bufaddr; \ + ucmd->uscsi_buflen = (size_t)u32->uscsi_buflen; \ + ucmd->uscsi_resid = (size_t)u32->uscsi_resid; \ + ucmd->uscsi_cdblen = u32->uscsi_cdblen; \ + ucmd->uscsi_rqlen = u32->uscsi_rqlen; \ + ucmd->uscsi_rqstatus = u32->uscsi_rqstatus; \ + ucmd->uscsi_rqresid = u32->uscsi_rqresid; \ + ucmd->uscsi_rqbuf = (caddr_t)(uintptr_t)u32->uscsi_rqbuf; \ + ucmd->uscsi_path_instance = (ulong_t)u32->uscsi_path_instance; + + +#define uscsi_cmdtouscsi_cmd32(ucmd, u32) \ + u32->uscsi_flags = ucmd->uscsi_flags; \ + u32->uscsi_status = ucmd->uscsi_status; \ + u32->uscsi_timeout = ucmd->uscsi_timeout; \ + u32->uscsi_cdb = (caddr32_t)(uintptr_t)ucmd->uscsi_cdb; \ + u32->uscsi_bufaddr = (caddr32_t)(uintptr_t)ucmd->uscsi_bufaddr; \ + u32->uscsi_buflen = (size32_t)ucmd->uscsi_buflen; \ + u32->uscsi_resid = (size32_t)ucmd->uscsi_resid; \ + u32->uscsi_cdblen = ucmd->uscsi_cdblen; \ + u32->uscsi_rqlen = ucmd->uscsi_rqlen; \ + u32->uscsi_rqstatus = ucmd->uscsi_rqstatus; \ + u32->uscsi_rqresid = ucmd->uscsi_rqresid; \ + u32->uscsi_rqbuf = (caddr32_t)(uintptr_t)ucmd->uscsi_rqbuf; \ + u32->uscsi_path_instance = (uint32_t)ucmd->uscsi_path_instance; + +#endif /* _SYSCALL32 */ + + +/* + * flags for uscsi_flags field + */ +/* + * generic flags + */ +#define USCSI_SILENT 0x00000001 /* no error messages */ +#define USCSI_DIAGNOSE 0x00000002 /* fail if any error occurs */ +#define USCSI_ISOLATE 0x00000004 /* isolate from normal commands */ +#define USCSI_READ 0x00000008 /* get data from device */ +#define USCSI_WRITE 0x00000000 /* send data to device */ + +#define USCSI_RESET 0x00004000 /* Reset target */ +#define USCSI_RESET_TARGET \ + USCSI_RESET /* Reset target */ +#define USCSI_RESET_ALL 0x00008000 /* Reset all targets */ +#define USCSI_RQENABLE 0x00010000 /* Enable Request Sense extensions */ +#define USCSI_RENEGOT 0x00020000 /* renegotiate wide/sync on next I/O */ +#define USCSI_RESET_LUN 0x00040000 /* Reset logical unit */ +#define USCSI_PATH_INSTANCE \ + 0x00080000 /* use path instance for transport */ + +/* + * suitable for parallel SCSI bus only + */ +#define USCSI_ASYNC 0x00001000 /* Set bus to asynchronous mode */ +#define USCSI_SYNC 0x00002000 /* Set bus to sync mode if possible */ + +/* + * the following flags should not be used at user level but may + * be used by a scsi target driver for internal commands + */ +/* + * generic flags + */ +#define USCSI_NOINTR 0x00000040 /* No interrupts, NEVER use this flag */ +#define USCSI_NOTAG 0x00000100 /* Disable tagged queueing */ +#define USCSI_OTAG 0x00000200 /* ORDERED QUEUE tagged cmd */ +#define USCSI_HTAG 0x00000400 /* HEAD OF QUEUE tagged cmd */ +#define USCSI_HEAD 0x00000800 /* Head of HA queue */ + +/* + * suitable for parallel SCSI bus only + */ +#define USCSI_NOPARITY 0x00000010 /* run command without parity */ +#define USCSI_NODISCON 0x00000020 /* run command without disconnects */ + +/* + * suitable for FMA module for PM purpose + */ +#define USCSI_PMFAILFAST 0x00100000 /* fail command if device is */ + /* in low power */ + + +#define USCSI_RESERVED 0xffe00000 /* Reserved Bits, must be zero */ + +struct uscsi_rqs { + int rqs_flags; /* see below */ + ushort_t rqs_buflen; /* maximum number or bytes to return */ + ushort_t rqs_resid; /* untransferred length of RQS data */ + caddr_t rqs_bufaddr; /* request sense buffer */ +}; + +#if defined(_SYSCALL32) +struct uscsi_rqs32 { + int rqs_flags; /* see below */ + ushort_t rqs_buflen; /* maximum number or bytes to return */ + ushort_t rqs_resid; /* untransferred length of RQS data */ + caddr32_t rqs_bufaddr; /* request sense buffer */ +}; +#endif /* _SYSCALL32 */ + + +/* + * uscsi_rqs flags + */ + +#define RQS_OVR 0x01 /* RQS data has been overwritten */ +#define RQS_VALID 0x02 /* RQS data is valid */ + +/* + * Structure for USCSIMAXXFER ioctls + */ +typedef uint64_t uscsi_xfer_t; + +/* + * User SCSI io control command + */ +#define USCSIIOC (0x04 << 8) +#define USCSICMD (USCSIIOC|201) /* user scsi command */ +#define USCSIMAXXFER (USCSIIOC|202) /* get max transfer size */ + +#ifdef _KERNEL + +#include + +struct uscsi_cmd *scsi_uscsi_alloc(); +int scsi_uscsi_copyin(intptr_t, int, + struct scsi_address *, struct uscsi_cmd **); +int scsi_uscsi_alloc_and_copyin(intptr_t, int, + struct scsi_address *, struct uscsi_cmd **); + +int scsi_uscsi_pktinit(struct uscsi_cmd *, struct scsi_pkt *); +int scsi_uscsi_handle_cmd(dev_t, enum uio_seg, + struct uscsi_cmd *, int (*)(struct buf *), + struct buf *, void *); +int scsi_uscsi_pktfini(struct scsi_pkt *, struct uscsi_cmd *); + +int scsi_uscsi_copyout(intptr_t, struct uscsi_cmd *); +void scsi_uscsi_free(struct uscsi_cmd *); +int scsi_uscsi_copyout_and_free(intptr_t, struct uscsi_cmd *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_USCSI_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/impl/usmp.h b/illumos-x86_64/usr/include/sys/scsi/impl/usmp.h new file mode 100644 index 00000000..bc019182 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/impl/usmp.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_IMPL_USMP_H +#define _SYS_SCSI_IMPL_USMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define SAS_WWN_BYTE_SIZE 8 + +typedef struct usmp_cmd { + caddr_t usmp_req; + caddr_t usmp_rsp; + size_t usmp_reqsize; + size_t usmp_rspsize; + int usmp_timeout; +} usmp_cmd_t; + +#if defined(_SYSCALL32) && defined(_KERNEL) + +typedef struct usmp_cmd32 { + caddr32_t usmp_req; + caddr32_t usmp_rsp; + size32_t usmp_reqsize; + size32_t usmp_rspsize; + int usmp_timeout; +} usmp_cmd32_t; + +#define usmp_cmd32tousmp_cmd(u32, ucmd) \ + ucmd->usmp_req = (caddr_t)(uintptr_t)u32->usmp_req; \ + ucmd->usmp_rsp = (caddr_t)(uintptr_t)u32->usmp_rsp; \ + ucmd->usmp_reqsize = (size_t)u32->usmp_reqsize; \ + ucmd->usmp_rspsize = (size_t)u32->usmp_rspsize; \ + ucmd->usmp_timeout = u32->usmp_timeout; + +#define usmp_cmdtousmp_cmd32(ucmd, u32) \ + u32->usmp_req = (caddr32_t)(uintptr_t)ucmd->usmp_req; \ + u32->usmp_rsp = (caddr32_t)(uintptr_t)ucmd->usmp_rsp; \ + u32->usmp_reqsize = (size32_t)ucmd->usmp_reqsize; \ + u32->usmp_rspsize = (size32_t)ucmd->usmp_rspsize; \ + u32->usmp_timeout = ucmd->usmp_timeout; + +#endif /* _SYSCALL32 && _KERNEL */ + +#define USMPFUNC _IO('S', 01) /* user smp function */ + +#define SMP_DEFAULT_TIMEOUT 60 +#define SMP_MIN_RESPONSE_SIZE 8 +#define SMP_MIN_REQUEST_SIZE 8 +#define SMP_MAX_RESPONSE_SIZE 1032 +#define SMP_MAX_REQUEST_SIZE 1032 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_IMPL_USMP_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi.h b/illumos-x86_64/usr/include/sys/scsi/scsi.h new file mode 100644 index 00000000..aba990af --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi.h @@ -0,0 +1,36 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SCSI_SCSI_H +#define _SYS_SCSI_SCSI_H + +/* + * Global Include for SCSI subsystem + */ + +#include + +#endif /* _SYS_SCSI_SCSI_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_address.h b/illumos-x86_64/usr/include/sys/scsi/scsi_address.h new file mode 100644 index 00000000..d2c11f38 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_address.h @@ -0,0 +1,192 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2017, Joyent, Inc. + */ + +#ifndef _SYS_SCSI_SCSI_ADDRESS_H +#define _SYS_SCSI_SCSI_ADDRESS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SCSI address definition. + * + * A scsi_address(9S) structure stores the host adapter routing and + * scsi_device(9S) unit-address routing information necessary to reference + * a specific SCSI target device logical unit function. + * + * Host adapter routing information is stored in the scsi_hba_tran(9S) + * structure, pointed to by the scsi_address(9S) 'a_hba_tran' field. + * + * The scsi_device(9S) unit-address routing information (i.e. SCSA's + * representation of leaf disk/tape driver's "@unit-address" portion of + * a /devices path) is maintained in three different forms: + * + * SCSI_HBA_ADDR_SPI: In SCSI_HBA_ADDR_SPI mode (default), the SCSA + * framework, during initialization, places unit-address property + * information, converted to numeric form, directly into the + * 'a_target' and 'a_lun' fields of the scsi_address(9S) structure + * (embedded in the scsi_device(9S) structure). To maintain + * per-scsi_device(9S) state, host adapter drivers often use + * 'a_target' and 'a_lun' to index into a large fixed array + * (limited by the drivers idea of maximum supported target and + * lun). + * + * NOTE: a_sublun is reserved for internal use only and has never + * been part of DDI scsi_address(9S). + * + * SCSI_HBA_ADDR_COMPLEX: The host adapter driver will maintain + * per-unit-address/per-scsi_device(9S) HBA private state by using + * scsi_device_hba_private_set(9F) during tran_tgt_init(9E) (using + * property interfaces to obtain/convert unit-address information into + * a host adapter private form). In SCSI_HBA_ADDR_COMPLEX mode, the SCSA + * framework, prior to tran_tgt_init(9E), places a pointer to the + * scsi_device(9S) in the 'a.a_sd' scsi_address(9S) field, and uses + * 'sd_hba_private' to store per-scsi_device hba private data. + * + * SCSI_HBA_TRAN_CLONE: SCSI_HBA_TRAN_CLONE is an older method for + * supporting devices with non-SPI unit-address. It is still + * supported, but its use is discouraged. From a unit-address + * perspective, operation is similar to SCSI_HBA_ADDR_COMPLEX, but + * per-scsi_device(9S) state is supported via 'cloning' of the + * scsi_hba_tran(9S) structure (to provide a per-scsi_device(9S) + * version of 'tran_tgt_private'/'tran_sd' accessible via + * 'a_hba_tran'). + * + * NOTE: Compatible evolution of SCSA is constrained by the fact that the + * scsi_address(9S) structure is embedded at the base of the scsi_device(9S) + * structure, and is structure copied into the base of each allocated + * scsi_pkt(9S) structure. + * + * In general, device unit-address information is used exclusively by + * the host adapter driver (the exception being target drivers + * communicating with SCSI Parallel Interconnect (SPI) SCSI-1 devices + * that embed SCSI logical unit addressing in the CDB). Target drivers + * which need to communicate with SPI SCSI-1 devices that embed logical + * unit addresses in the CDB must obtain target and logical unit + * addresses from the device's properties (SCSI_ADDR_PROP_TARGET and + * SCSI_ADDR_PROP_LUN). + */ +struct scsi_address { + struct scsi_hba_tran *a_hba_tran; /* Transport vector */ + union { + struct { /* SPI: */ + ushort_t a_target; /* ua target */ + uchar_t a_lun; /* ua lun on target */ + uchar_t _a_sublun; /* (private) */ + } spi; + struct scsi_device *a_sd; /* COMPLEX: (private) */ + } a; /* device unit-adddress info */ +}; +#define a_target a.spi.a_target +#define a_lun a.spi.a_lun +#define a_sublun a.spi._a_sublun + +/* Device unit-address property names */ +#define SCSI_ADDR_PROP_TARGET "target" /* int */ +#define SCSI_ADDR_PROP_LUN "lun" /* int */ + +#define SCSI_ADDR_PROP_TARGET_PORT "target-port" /* string */ +#define SCSI_ADDR_PROP_LUN64 "lun64" /* int64 */ +#define SCSI_ADDR_PROP_SFUNC "sfunc" /* int */ + +#define SCSI_ADDR_PROP_IPORTUA "scsi-iport" /* string */ + +#define SCSI_ADDR_PROP_SATA_PHY "sata-phy" /* int */ + +/* + * Addressing property names, values are in string form compatible + * with the SCSI_ADDR_PROP_TARGET_PORT part of the related + * IEEE-1275 OpenFirmware binding unit-address string. + */ +#define SCSI_ADDR_PROP_INITIATOR_PORT "initiator-port" +#define SCSI_ADDR_PROP_ATTACHED_PORT "attached-port" +#define SCSI_ADDR_PROP_BRIDGE_PORT "bridge-port" + +/* + * Normalized representation of a scsi_lun (with SCSI-2 lun positioned + * for compatibility). + */ +typedef uint64_t scsi_lun64_t; +#define PRIlun64 PRIx64 +#ifdef _LP64 +#define SCSI_LUN64_ILLEGAL (-1L) +#else /* _LP64 */ +#define SCSI_LUN64_ILLEGAL (-1LL) +#endif /* _LP64 */ + +/* Structure of a 64-bit SCSI LUN per SCSI standard */ +typedef struct scsi_lun { + uchar_t sl_lun1_msb; /* format */ + uchar_t sl_lun1_lsb; /* first level */ + uchar_t sl_lun2_msb; + uchar_t sl_lun2_lsb; /* second level */ + uchar_t sl_lun3_msb; + uchar_t sl_lun3_lsb; /* third level */ + uchar_t sl_lun4_msb; + uchar_t sl_lun4_lsb; /* fourth level */ +} scsi_lun_t; + +/* SCSI standard defined lun addressing methods (in sl_lunX_msb) */ +#define SCSI_LUN_AM_MASK 0xC0 /* Address Method Mask */ +#define SCSI_LUN_AM_PDEV 0x00 /* Peripheral device AM */ +#define SCSI_LUN_AM_FLAT 0x40 /* Flat space AM */ +#define SCSI_LUN_AM_LUN 0x80 /* Logical unit AM */ +#define SCSI_LUN_AM_EFLAT 0xC0 /* Extended flat space AM */ +#define SCSI_LUN_AM_ELUN 0xC0 /* Extended logical unit AM */ + +#ifdef _KERNEL +/* SCSI LUN conversion between SCSI_ADDR_PROP_LUN64 and SCSI standard forms */ +scsi_lun64_t scsi_lun_to_lun64(scsi_lun_t lun); +scsi_lun_t scsi_lun64_to_lun(scsi_lun64_t lun64); + +/* SCSI WWN conversion (property values should be in unit_address form) */ +int scsi_wwnstr_to_wwn(const char *wwnstr, uint64_t *wwnp); +char *scsi_wwn_to_wwnstr(uint64_t wwn, + int unit_address_form, char *wwnstr); +void scsi_wwnstr_hexcase(char *wwnstr, int lower_case); +const char *scsi_wwnstr_skip_ua_prefix(const char *wwnstr); +void scsi_free_wwnstr(char *wwnstr); + +/* + * Buffer lengths for SCSI strings. SCSI_WWN_STRLEN is the length of a WWN + * that's not in unit-address form. SCSI_WWN_UA_STRLEN includes the + * unit-address. SCSI_WWN_BUFLEN provides a buffer that's large enough for all + * of these. + */ +#define SCSI_WWN_STRLEN 16 +#define SCSI_WWN_UA_STRLEN 17 +#define SCSI_WWN_BUFLEN SCSI_MAXNAMELEN + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_SCSI_ADDRESS_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_ctl.h b/illumos-x86_64/usr/include/sys/scsi/scsi_ctl.h new file mode 100644 index 00000000..32b6f540 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_ctl.h @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_SCSI_CTL_H +#define _SYS_SCSI_SCSI_CTL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SCSI Control Information + * + * Defines for stating level of reset. + * RESET_ALL, RESET_TARGET, and RESET_LUN defined for tran_reset (invoked + * by target/ioctl) + * RESET_BUS defined for tran_bus_reset (invoked by ioctl) + */ +#define RESET_ALL 0 /* reset SCSI bus, host adapter, everything */ +#define RESET_TARGET 1 /* reset SCSI target */ +#define RESET_BUS 2 /* reset SCSI bus only */ +#define RESET_LUN 3 /* reset SCSI logical unit */ + +/* + * Defines for scsi_reset_notify flag, to register or cancel + * the notification of external and internal SCSI bus resets. + */ +#define SCSI_RESET_NOTIFY 0x01 /* register the reset notification */ +#define SCSI_RESET_CANCEL 0x02 /* cancel the reset notification */ + +/* + * Define for scsi_get_name string length. + * This is needed because MAXNAMELEN is not part of DDI. + */ +#define SCSI_MAXNAMELEN MAXNAMELEN + +/* + * Property for customizing hotplug procedure + */ +#define SCSI_NO_QUIESCE "scsi-no-quiesce" + +#ifdef _KERNEL + +/* + * Kernel function declarations + */ + +/* + * Capabilities functions + */ +int scsi_ifgetcap(struct scsi_address *ap, char *cap, int whom); +int scsi_ifsetcap(struct scsi_address *ap, char *cap, int value, int whom); + +/* + * Abort and Reset functions + */ +int scsi_abort(struct scsi_address *ap, struct scsi_pkt *pkt); +int scsi_reset(struct scsi_address *ap, int level); +int scsi_reset_notify(struct scsi_address *ap, int flag, + void (*callback)(caddr_t), caddr_t arg); +int scsi_clear_task_set(struct scsi_address *ap); +int scsi_terminate_task(struct scsi_address *ap, struct scsi_pkt *pkt); + +/* + * Other functions + */ +int scsi_clear_aca(struct scsi_address *ap); +int scsi_ua_get_reportdev(struct scsi_device *sd, char *ba, int len); +int scsi_ua_get(struct scsi_device *sd, char *ua, int len); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_SCSI_CTL_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_fm.h b/illumos-x86_64/usr/include/sys/scsi/scsi_fm.h new file mode 100644 index 00000000..e232da04 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_fm.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_SCSI_SCSI_FM_H +#define _SYS_SCSI_SCSI_FM_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * fault management initialization and clean-up: + * do init/fini from initchild/uninitchild? + */ +void scsi_fm_init(struct scsi_device *); +void scsi_fm_fini(struct scsi_device *); + +/* ereport generation: */ +void scsi_fm_ereport_post(struct scsi_device *sd, int path_instance, + char *devpath, const char *error_class, uint64_t ena, + char *devid, char *tpl0, int sflag, nvlist_t *pl, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_SCSI_FM_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_names.h b/illumos-x86_64/usr/include/sys/scsi/scsi_names.h new file mode 100644 index 00000000..bd2150ae --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_names.h @@ -0,0 +1,50 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2016 Nexenta Systems, Inc. + */ + +#ifndef _SYS_SCSI_SCSI_NAMES_H_ +#define _SYS_SCSI_SCSI_NAMES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* SCSI Name Strings */ +#define SNS_EUI "eui" +#define SNS_IQN "iqn" +#define SNS_MAC "mac" +#define SNS_NAA "naa" +#define SNS_WWN "wwn" + +/* SCSI Name String maximum length definitions */ +#define SNS_EUI_16 16 +#define SNS_IQN_223 223 +#define SNS_MAC_12 12 +#define SNS_NAA_16 16 +#define SNS_NAA_32 32 +#define SNS_WWN_16 16 + +#define SNS_EUI_LEN_MAX sizeof (SNS_EUI) + SNS_EUI_16 +#define SNS_IQN_LEN_MAX SNS_IQN_223 +#define SNS_MAC_LEN_MAX sizeof (SNS_MAC) + SNS_MAC_12 +#define SNS_NAA_LEN_MAX sizeof (SNS_NAA) + SNS_NAA_32 +#define SNS_WWN_LEN_MAX sizeof (SNS_WWN) + SNS_WWN_16 + +#define SNS_LEN_MAX SNS_IQN_LEN_MAX + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_SCSI_NAMES_H_ */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_params.h b/illumos-x86_64/usr/include/sys/scsi/scsi_params.h new file mode 100644 index 00000000..1e89e4d8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_params.h @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_SCSI_PARAMS_H +#define _SYS_SCSI_SCSI_PARAMS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define NUM_SENSE_KEYS 16 /* total number of Sense keys */ + +#define NTAGS 256 /* number of tags per lun */ + +/* + * General parallel SCSI parameters + */ +#define NTARGETS 8 /* total # of targets per SCSI bus */ +#define NTARGETS_WIDE 16 /* #targets per wide SCSI bus */ +#define NLUNS_PER_TARGET 8 /* number of luns per target */ + +/* + * the following defines are useful for setting max LUNs in + * nexus/target drivers + */ +#define SCSI_1LUN_PER_TARGET 1 +#define SCSI_8LUN_PER_TARGET NLUNS_PER_TARGET +#define SCSI_16LUNS_PER_TARGET 16 +#define SCSI_32LUNS_PER_TARGET 32 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_SCSI_PARAMS_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_pkt.h b/illumos-x86_64/usr/include/sys/scsi/scsi_pkt.h new file mode 100644 index 00000000..ffff2ab7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_pkt.h @@ -0,0 +1,289 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_SCSI_PKT_H +#define _SYS_SCSI_SCSI_PKT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +/* + * SCSI packet definition. + * + * This structure defines the packet which is allocated by a library + * function and handed to a target driver. The target driver fills + * in some information, and passes it to the library for transport + * to an addressed SCSI device. The host adapter found by + * the library fills in some other information as the command is + * processed. When the command completes (or can be taken no further) + * the function specified in the packet is called with a pointer to + * the packet as it argument. From fields within the packet, the target + * driver can determine the success or failure of the command. + */ +struct scsi_pkt { + opaque_t pkt_ha_private; /* private data for host adapter */ + struct scsi_address pkt_address; /* destination packet is for */ + opaque_t pkt_private; /* private data for target driver */ + void (*pkt_comp)(struct scsi_pkt *); /* completion routine */ + uint_t pkt_flags; /* flags */ + int pkt_time; /* time allotted to complete command */ + uchar_t *pkt_scbp; /* pointer to status block */ + uchar_t *pkt_cdbp; /* pointer to command block */ + ssize_t pkt_resid; /* data bytes not transferred */ + uint_t pkt_state; /* state of command */ + uint_t pkt_statistics; /* statistics */ + uchar_t pkt_reason; /* reason completion called */ + + /* + * The DDI does not allow a driver to allocate it's own scsi_pkt(9S), + * a driver should not have *any* compiled in dependencies on + * "sizeof (struct scsi_pkt)". If the driver has such dependencies, it + * limits SCSA's ability to evolve. The proper way for an HBA to + * allocate a scsi_pkt is via scsi_hba_pkt_alloc(9F), or the newer + * tran_setup_pkt(9E) interfaces. Allocation rules have been in place + * for many years, unfortunately a significant number of drivers + * are still broken. + * + * NB: Until we can trust drivers to follow DDI scsi_pkt(9S) allocation + * rules, access to all fields below require special consideration. + * Access to these fields is limited to code paths that 'know' correct + * scsi_pkt allocation interfaces must have been used. This means that + * any target driver access to these fields is suspect, since a target + * knows nothing about how an HBA drivers performs scsi_pkt allocation. + * + * NB: A private scsi_pkt_size() interface has been added to simplify + * 'fixing' legacy HBA drivers. Use of scsi_pkt_size() is only + * appropriate when the effort/cost of fixing a legacy driver to use + * proper DDI scsi_pkt allocation interfaces is too great given the + * remaining driver life. New HBA drivers should *not* use + * scsi_pkt_size(). + * + * NB: While HBA drivers with violations are being fixed, in + * rare cases access conditioned by scsi_pkt_allocated_correctly() is + * permitted. + */ + /* + * HBA driver only, iff scsi_hba_pkt_alloc(9F) | tran_setup_pkt(9E) used + */ + uint_t pkt_cdblen; /* length of pkt_cdbp */ + uint_t pkt_tgtlen; /* length of pkt_private */ + uint_t pkt_scblen; /* lenght of pkt_scbp */ + + /* HBA driver only, iff tran_setup_pkt(9E) used */ + ddi_dma_handle_t pkt_handle; /* private */ + uint_t pkt_numcookies; /* number of DMA cookies */ + off_t pkt_dma_offset; /* private */ + size_t pkt_dma_len; /* private */ + uint_t pkt_dma_flags; /* DMA flags */ + ddi_dma_cookie_t *pkt_cookies; /* array of DMA cookies */ + + /* private: iff scsi_pkt_allocated_correctly() */ + int pkt_path_instance; /* pHCI transport path */ + + /* stage-temporary: iff scsi_pkt_allocated_correctly() */ + void *pkt_stmp; /* temporary for current pkt stage */ + +#ifdef SCSI_SIZE_CLEAN_VERIFY + /* + * Must be last: Building a driver with-and-without + * -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for + * differences with a tools like 'wsdiff' allows a developer to verify + * that their driver has no dependencies on scsi*(9S) size. + */ + int i_pkt_pad[8]; +#endif /* SCSI_SIZE_CLEAN_VERIFY */ +}; +#endif /* _KERNEL */ + +/* + * Definitions for the pkt_flags field. + */ + +/* + * Following defines are generic. + */ +#define FLAG_STAG 0x4000 /* Run command with Simple attribute */ +#define FLAG_OTAG 0x2000 /* Run command with Ordered attribute */ +#define FLAG_HTAG 0x1000 /* Run command with Head of Queue attribute */ +#define FLAG_TAGMASK (FLAG_HTAG|FLAG_OTAG|FLAG_STAG) + +#define FLAG_ACA 0x0100 /* internal; do not use */ +#define FLAG_HEAD 0x8000 /* This cmd should be put at the head */ + /* of the HBA driver's queue */ +#define FLAG_SENSING 0x0400 /* Running request sense for failed pkt */ +#define FLAG_NOINTR 0x0001 /* Run command with no cmd completion */ + /* callback; command has been completed */ + /* upon return from scsi_transport(9F) */ + +/* + * Following defines are appropriate for SCSI parallel bus. + */ +#define FLAG_NODISCON 0x0002 /* Run command without disconnects */ +#define FLAG_NOPARITY 0x0008 /* Run command without parity checking */ +#define FLAG_RENEGOTIATE_WIDE_SYNC \ + 0x1000000 /* Do wide and sync renegotiation before */ + /* transporting this command to target */ + +/* + * Following defines are internal i.e. not part of DDI. + */ +#define FLAG_IMMEDIATE_CB \ + 0x0800 /* Immediate callback on command */ + /* completion, ie. do not defer */ + +/* + * Following defines are for USCSI options. + */ +#define FLAG_SILENT 0x00010000 +#define FLAG_DIAGNOSE 0x00020000 +#define FLAG_ISOLATE 0x00040000 + +/* + * pkg_flag for TLR + */ +#define FLAG_TLR 0x00080000 + + +/* + * Following define is for scsi_vhci. + * NOQUEUE If pHCI cannot transport the command to the device, + * do not queue the pkt in pHCI. Return immediately with + * TRAN_BUSY. + * PATH_INSTANCE Select specific path (pkt_path_instance). + * We need both a pkt_path_instance field and flag bit so + * that a retry after a path failure, which sets + * pkt_path_instance to failed path, does not select the + * failed path. + */ +#define FLAG_NOQUEUE 0x80000000 +#define FLAG_PKT_PATH_INSTANCE 0x40000000 /* Tell vhci the path to use */ +#define FLAG_PKT_COMP_CALLED 0x20000000 /* Set once pkt_comp called */ + +/* + * Definitions for the pkt_reason field. + */ + +/* + * Following defines are generic. + */ +#define CMD_CMPLT 0 /* no transport errors- normal completion */ +#define CMD_INCOMPLETE 1 /* transport stopped with not normal state */ +#define CMD_DMA_DERR 2 /* dma direction error occurred */ +#define CMD_TRAN_ERR 3 /* unspecified transport error */ +#define CMD_RESET 4 /* Target completed hard reset sequence */ +#define CMD_ABORTED 5 /* Command transport aborted on request */ +#define CMD_TIMEOUT 6 /* Command timed out */ +#define CMD_DATA_OVR 7 /* Data Overrun */ +#define CMD_CMD_OVR 8 /* Command Overrun */ +#define CMD_STS_OVR 9 /* Status Overrun */ +#define CMD_TERMINATED 22 /* Command transport terminated on request */ +#define CMD_TLR_OFF 23 /* don't support TLR */ + +/* + * Following defines are appropriate for SCSI parallel bus. + */ +#define CMD_BADMSG 10 /* Message not Command Complete */ +#define CMD_NOMSGOUT 11 /* Target refused to go to Message Out phase */ +#define CMD_XID_FAIL 12 /* Extended Identify message rejected */ +#define CMD_IDE_FAIL 13 /* Initiator Detected Error message rejected */ +#define CMD_ABORT_FAIL 14 /* Abort message rejected */ +#define CMD_REJECT_FAIL 15 /* Reject message rejected */ +#define CMD_NOP_FAIL 16 /* No Operation message rejected */ +#define CMD_PER_FAIL 17 /* Message Parity Error message rejected */ +#define CMD_BDR_FAIL 18 /* Bus Device Reset message rejected */ +#define CMD_ID_FAIL 19 /* Identify message rejected */ +#define CMD_UNX_BUS_FREE 20 /* Unexpected Bus Free Phase occurred */ +#define CMD_TAG_REJECT 21 /* Target rejected our tag message */ +#define CMD_DEV_GONE 24 /* The device has been removed */ + +/* Used by scsi_rname(9F) */ +#define CMD_REASON_ASCII { \ + "cmplt", "incomplete", "dma_derr", "tran_err", "reset", \ + "aborted", "timeout", "data_ovr", "cmd_ovr", "sts_ovr", \ + "badmsg", "nomsgout", "xid_fail", "ide_fail", "abort_fail", \ + "reject_fail", "nop_fail", "per_fail", "bdr_fail", "id_fail", \ + "unexpected_bus_free", "tag reject", "terminated", "", "gone", \ + NULL } + +/* + * Definitions for the pkt_state field + */ +#define STATE_GOT_BUS 0x01 /* Success in getting SCSI bus */ +#define STATE_GOT_TARGET 0x02 /* Successfully connected with target */ +#define STATE_SENT_CMD 0x04 /* Command successfully sent */ +#define STATE_XFERRED_DATA 0x08 /* Data transfer took place */ +#define STATE_GOT_STATUS 0x10 /* SCSI status received */ +#define STATE_ARQ_DONE 0x20 /* auto rqsense took place */ +#define STATE_XARQ_DONE 0X40 /* extra auto rqsense took place */ + +/* + * Definitions for the pkt_statistics field + */ + +/* + * Following defines are generic. + */ +#define STAT_BUS_RESET 0x8 /* Reset operation on interconnect */ +#define STAT_DEV_RESET 0x10 /* Target completed hard reset sequence */ +#define STAT_ABORTED 0x20 /* Command was aborted */ +#define STAT_TERMINATED 0x80 /* Command was terminated */ +#define STAT_TIMEOUT 0x40 /* Command experienced a timeout */ + +/* + * Following defines are appropriate for SCSI parallel bus. + */ +#define STAT_DISCON 0x1 /* Command experienced a disconnect */ +#define STAT_SYNC 0x2 /* Command did a synchronous data transfer */ +#define STAT_PERR 0x4 /* Command experienced a SCSI parity error */ + +/* + * Definitions for what scsi_transport returns + */ +#define TRAN_ACCEPT 1 +#define TRAN_BUSY 0 +#define TRAN_BADPKT -1 +#define TRAN_FATAL_ERROR -2 /* HBA cannot accept any pkts */ + +#ifdef _KERNEL +/* + * Kernel function declarations + */ +int scsi_transport(struct scsi_pkt *pkt); + +#define pkt_transport scsi_transport + +#define SCSI_POLL_TIMEOUT 60 + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_SCSI_PKT_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_resource.h b/illumos-x86_64/usr/include/sys/scsi/scsi_resource.h new file mode 100644 index 00000000..65fe05bc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_resource.h @@ -0,0 +1,133 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_SCSI_RESOURCE_H +#define _SYS_SCSI_SCSI_RESOURCE_H + + +#ifdef __lock_lint +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SCSI Resource Function Declarations + */ + +/* + * Defines for stating preferences in resource allocation + */ + +#define NULL_FUNC ((int (*)())0) +#define SLEEP_FUNC ((int (*)())1) + +#ifdef _KERNEL +/* + * Defines for the flags to scsi_init_pkt() + */ +#define PKT_CONSISTENT 0x0001 /* this is an 'iopb' packet */ +#define PKT_DMA_PARTIAL 0x040000 /* partial xfer ok */ +#define PKT_XARQ 0x080000 /* request for extra sense */ + +/* + * Old PKT_CONSISTENT value for binary compatibility with x86 2.1 + */ +#define PKT_CONSISTENT_OLD 0x001000 + +/* + * Kernel function declarations + */ +struct buf *scsi_alloc_consistent_buf(struct scsi_address *, + struct buf *, size_t, uint_t, int (*)(caddr_t), caddr_t); +struct scsi_pkt *scsi_init_pkt(struct scsi_address *, + struct scsi_pkt *, struct buf *, int, int, int, int, + int (*)(caddr_t), caddr_t); +void scsi_destroy_pkt(struct scsi_pkt *); +void scsi_free_consistent_buf(struct buf *); +int scsi_pkt_allocated_correctly(struct scsi_pkt *); +struct scsi_pkt *scsi_dmaget(struct scsi_pkt *, opaque_t, int (*)(void)); +void scsi_dmafree(struct scsi_pkt *); +void scsi_sync_pkt(struct scsi_pkt *); + +/* + * Private wrapper for scsi_pkt's allocated via scsi_init_cache_pkt() + */ +struct scsi_pkt_cache_wrapper { + struct scsi_pkt pcw_pkt; + int pcw_magic; + uint_t pcw_total_xfer; + uint_t pcw_curwin; + uint_t pcw_totalwin; + uint_t pcw_granular; + struct buf *pcw_bp; + ddi_dma_cookie_t pcw_cookie; + uint_t pcw_flags; +}; + +#ifdef __lock_lint +_NOTE(SCHEME_PROTECTS_DATA("unique per packet", + scsi_pkt_cache_wrapper::pcw_bp + scsi_pkt_cache_wrapper::pcw_curwin + scsi_pkt_cache_wrapper::pcw_flags + scsi_pkt_cache_wrapper::pcw_granular + scsi_pkt_cache_wrapper::pcw_total_xfer + scsi_pkt_cache_wrapper::pcw_totalwin)) +#endif +struct buf *scsi_pkt2bp(struct scsi_pkt *); + +#define PCW_NEED_EXT_CDB 0x0001 +#define PCW_NEED_EXT_TGT 0x0002 +#define PCW_NEED_EXT_SCB 0x0004 +#define PCW_BOUND 0x0020 + +/* + * Private defines i.e. not part of the DDI. + */ +#define DEFAULT_CDBLEN 16 +#define DEFAULT_PRIVLEN 0 +#define DEFAULT_SCBLEN (sizeof (struct scsi_arq_status)) + +/* Private functions */ +size_t scsi_pkt_size(); +void scsi_size_clean(dev_info_t *); + +/* Obsolete kernel functions: */ +struct scsi_pkt *scsi_pktalloc(struct scsi_address *, int, int, int (*)(void)); +struct scsi_pkt *scsi_resalloc(struct scsi_address *, int, + int, opaque_t, int (*)(void)); +void scsi_resfree(struct scsi_pkt *); +#define scsi_pktfree scsi_resfree + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_SCSI_RESOURCE_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_types.h b/illumos-x86_64/usr/include/sys/scsi/scsi_types.h new file mode 100644 index 00000000..6aeb2bc0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_types.h @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_SCSI_TYPES_H +#define _SYS_SCSI_SCSI_TYPES_H + + +/* + * Types for SCSI subsystems. + * + * This file picks up specific as well as generic type + * defines, and also serves as a wrapper for many common + * includes. + */ + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _OPAQUE_T +#define _OPAQUE_T +typedef void *opaque_t; +#endif /* _OPAQUE_T */ + +#ifdef __cplusplus +} +#endif + +#ifdef _KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* _KERNEL */ + +/* + * Each implementation will have it's own specific set + * of types it wishes to define. + */ + +/* + * Generally useful files to include + */ +#include +#include +#include +#ifdef _KERNEL +#include +#endif /* _KERNEL */ +#include +#include + +#ifdef _KERNEL +#include +#include +#include +#endif /* _KERNEL */ + +#include +#include +#include +#include + +/* + * Sun SCSI type definitions + */ +#include + +#endif /* _SYS_SCSI_SCSI_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/scsi_watch.h b/illumos-x86_64/usr/include/sys/scsi/scsi_watch.h new file mode 100644 index 00000000..0d532bdb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/scsi_watch.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_SCSI_WATCH_H +#define _SYS_SCSI_SCSI_WATCH_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct scsi_watch_result { + struct scsi_status *statusp; + struct scsi_extended_sense *sensep; + uchar_t actual_sense_length; + uchar_t mmc_data[8]; + struct scsi_pkt *pkt; +}; + +/* + * 120 seconds is a *very* reasonable amount of time for most slow devices + */ +#define SCSI_WATCH_IO_TIME 120 + +/* + * values to pass in "flags" arg for scsi_watch_request_terminate() + */ +#define SCSI_WATCH_TERMINATE_WAIT 0x0 +#define SCSI_WATCH_TERMINATE_NOWAIT 0x1 +#define SCSI_WATCH_TERMINATE_ALL_WAIT 0x2 + +#define SCSI_WATCH_TERMINATE_SUCCESS 0x0 +#define SCSI_WATCH_TERMINATE_FAIL 0x1 + +void scsi_watch_init(); +void scsi_watch_fini(); +opaque_t scsi_watch_request_submit(struct scsi_device *devp, + int interval, int sense_length, + int (*callback)(), caddr_t cb_arg); +opaque_t scsi_mmc_watch_request_submit(struct scsi_device *devp, + int interval, int sense_length, + int (*callback)(), caddr_t cb_arg); +int scsi_watch_request_terminate(opaque_t token, int flags); +int scsi_watch_get_ref_count(opaque_t token); +void scsi_watch_resume(opaque_t token); +void scsi_watch_suspend(opaque_t token); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_SCSI_WATCH_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/targets/sddef.h b/illumos-x86_64/usr/include/sys/scsi/targets/sddef.h new file mode 100644 index 00000000..bb522141 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/targets/sddef.h @@ -0,0 +1,2373 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright 2011 cyril.galibern@opensvc.com + * Copyright 2017 Nexenta Systems, Inc. All rights reserved. + * Copyright 2019 Joyent, Inc. + * Copyright 2022 RackTop Systems, Inc. + * Copyright 2022 Garrett D'Amore + */ + +#ifndef _SYS_SCSI_TARGETS_SDDEF_H +#define _SYS_SCSI_TARGETS_SDDEF_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#if defined(_KERNEL) || defined(_KMEMUSER) + + +#define SD_SUCCESS 0 +#define SD_FAILURE (-1) + +#if defined(TRUE) +#undef TRUE +#endif + +#if defined(FALSE) +#undef FALSE +#endif + +#define TRUE 1 +#define FALSE 0 + +#if defined(VERBOSE) +#undef VERBOSE +#endif + +#if defined(SILENT) +#undef SILENT +#endif + + +/* + * Fault Injection Flag for Inclusion of Code + * + * This should only be defined when SDDEBUG is defined + * #if DEBUG || lint + * #define SD_FAULT_INJECTION + * #endif + */ + +#if DEBUG || lint +#define SD_FAULT_INJECTION +#endif +#define VERBOSE 1 +#define SILENT 0 + +/* + * Structures for recording whether a device is fully open or closed. + * Assumptions: + * + * + There are only 8 (sparc) or 16 (x86) disk slices possible. + * + BLK, MNT, CHR, SWP don't change in some future release! + */ + +#if defined(_SUNOS_VTOC_8) + +#define SDUNIT_SHIFT 3 +#define SDPART_MASK 7 +#define NSDMAP NDKMAP + +#elif defined(_SUNOS_VTOC_16) + +/* + * XXX - NSDMAP has multiple definitions, one more in cmlb_impl.h + * If they are coalesced into one, this definition will follow suit. + * FDISK partitions - 4 primary and MAX_EXT_PARTS number of Extended + * Partitions. + */ +#define FDISK_PARTS (FD_NUMPART + MAX_EXT_PARTS) + +#define SDUNIT_SHIFT 6 +#define SDPART_MASK 63 +#define NSDMAP (NDKMAP + FDISK_PARTS + 1) + +#else +#error "No VTOC format defined." +#endif + + +#define SDUNIT(dev) (getminor((dev)) >> SDUNIT_SHIFT) +#define SDPART(dev) (getminor((dev)) & SDPART_MASK) + +/* + * maximum number of partitions the driver keeps track of; with + * EFI this can be larger than the number of partitions accessible + * through the minor nodes. It won't be used for keeping track + * of open counts, partition kstats, etc. + */ +#define MAXPART (NSDMAP + 1) + +/* + * Macro to retrieve the DDI instance number from the given buf struct. + * The instance number is encoded in the minor device number. + */ +#define SD_GET_INSTANCE_FROM_BUF(bp) \ + (getminor((bp)->b_edev) >> SDUNIT_SHIFT) + + + +struct ocinfo { + /* + * Types BLK, MNT, CHR, SWP, + * assumed to be types 0-3. + */ + uint64_t lyr_open[NSDMAP]; + uint64_t reg_open[OTYPCNT - 1]; +}; + +#define OCSIZE sizeof (struct ocinfo) + +union ocmap { + uchar_t chkd[OCSIZE]; + struct ocinfo rinfo; +}; + +#define lyropen rinfo.lyr_open +#define regopen rinfo.reg_open + + +#define SD_CDB_GROUP0 0 +#define SD_CDB_GROUP1 1 +#define SD_CDB_GROUP5 2 +#define SD_CDB_GROUP4 3 + +struct sd_cdbinfo { + uchar_t sc_grpcode; /* CDB group code */ + uchar_t sc_grpmask; /* CDB group code mask (for cmd opcode) */ + uint64_t sc_maxlba; /* Maximum logical block addr. supported */ + uint32_t sc_maxlen; /* Maximum transfer length supported */ +}; + + + +/* + * The following declaration are for Non-512 byte block support for the + * removable devices. (ex - DVD RAM, MO). + * wm_state: This is an enumeration for the different states for + * manipalating write range list during the read-modify-write-operation. + */ +typedef enum { + SD_WM_CHK_LIST, /* Check list for overlapping writes */ + SD_WM_WAIT_MAP, /* Wait for an overlapping I/O to complete */ + SD_WM_LOCK_RANGE, /* Lock the range of lba to be written */ + SD_WM_DONE /* I/O complete */ +} wm_state; + +/* + * sd_w_map: Every write I/O will get one w_map allocated for it which will tell + * the range on the media which is being written for that request. + */ +struct sd_w_map { + uint_t wm_start; /* Write start location */ + uint_t wm_end; /* Write end location */ + ushort_t wm_flags; /* State of the wmap */ + ushort_t wm_wanted_count; /* # of threads waiting for region */ + void *wm_private; /* Used to store bp->b_private */ + struct buf *wm_bufp; /* to store buf pointer */ + struct sd_w_map *wm_next; /* Forward pointed to sd_w_map */ + struct sd_w_map *wm_prev; /* Back pointer to sd_w_map */ + kcondvar_t wm_avail; /* Sleep on this, while not available */ +}; + +_NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, sd_w_map::wm_flags)) + + +/* + * This is the struct for the layer-private data area for the + * mapblocksize layer. + */ + +struct sd_mapblocksize_info { + void *mbs_oprivate; /* saved value of xb_private */ + struct buf *mbs_orig_bp; /* ptr to original bp */ + struct sd_w_map *mbs_wmp; /* ptr to write-map struct for RMW */ + ssize_t mbs_copy_offset; + int mbs_layer_index; /* chain index for RMW */ +}; + +_NOTE(SCHEME_PROTECTS_DATA("unshared data", sd_mapblocksize_info)) + + +/* Thin-provisioning (UNMAP) flags for un_thin_flags. */ +enum { + SD_THIN_PROV_ENABLED = 1 << 0, /* UNMAP available */ + SD_THIN_PROV_READ_ZEROS = 1 << 1 /* unmapped blk = zeros */ +}; + +/* + * Device limits as read from the Block Limits VPD page (0xB0). If the page + * is unavailable, will be filled with some defaults. + */ +typedef struct sd_blk_limits_s { + uint16_t lim_opt_xfer_len_gran; + uint32_t lim_max_xfer_len; + uint32_t lim_opt_xfer_len; + uint32_t lim_max_pfetch_len; + uint32_t lim_max_unmap_lba_cnt; + uint32_t lim_max_unmap_descr_cnt; + uint32_t lim_opt_unmap_gran; + uint32_t lim_unmap_gran_align; + uint64_t lim_max_write_same_len; +} sd_blk_limits_t; + +typedef struct sd_unmapstats { + kstat_named_t us_cmds; + kstat_named_t us_errs; + kstat_named_t us_extents; + kstat_named_t us_bytes; +} sd_unmapstats_t; + +/* + * sd_lun: The main data structure for a scsi logical unit. + * Stored as the softstate structure for each device. + */ + +struct sd_lun { + + /* Back ptr to the SCSA scsi_device struct for this LUN */ + struct scsi_device *un_sd; + + /* + * Support for Auto-Request sense capability + */ + struct buf *un_rqs_bp; /* ptr to request sense bp */ + struct scsi_pkt *un_rqs_pktp; /* ptr to request sense scsi_pkt */ + int un_sense_isbusy; /* Busy flag for RQS buf */ + + /* + * These specify the layering chains to use with this instance. These + * are initialized according to the values in the sd_chain_index_map[] + * array. See the description of sd_chain_index_map[] for details. + */ + int un_buf_chain_type; + int un_uscsi_chain_type; + int un_direct_chain_type; + int un_priority_chain_type; + + /* Head & tail ptrs to the queue of bufs awaiting transport */ + struct buf *un_waitq_headp; + struct buf *un_waitq_tailp; + + /* Ptr to the buf currently being retried (NULL if none) */ + struct buf *un_retry_bp; + + /* This tracks the last kstat update for the un_retry_bp buf */ + void (*un_retry_statp)(kstat_io_t *); + + void *un_xbuf_attr; /* xbuf attribute struct */ + + + /* System logical block size, in bytes. (defaults to DEV_BSIZE.) */ + uint32_t un_sys_blocksize; + + /* The size of a logical block on the target, in bytes. */ + uint32_t un_tgt_blocksize; + + /* The size of a physical block on the target, in bytes. */ + uint32_t un_phy_blocksize; + + /* + * The number of logical blocks on the target. This is adjusted + * to be in terms of the block size specified by un_sys_blocksize + * (ie, the system block size). + */ + uint64_t un_blockcount; + + /* + * Various configuration data + */ + uchar_t un_ctype; /* Controller type */ + char *un_node_type; /* minor node type */ + uchar_t un_interconnect_type; /* Interconnect for underlying HBA */ + + uint_t un_notready_retry_count; /* Per disk notready retry count */ + uint_t un_busy_retry_count; /* Per disk BUSY retry count */ + + uint_t un_retry_count; /* Per disk retry count */ + uint_t un_victim_retry_count; /* Per disk victim retry count */ + + /* (4356701, 4367306) */ + uint_t un_reset_retry_count; /* max io retries before issuing reset */ + ushort_t un_reserve_release_time; /* reservation release timeout */ + + uchar_t un_reservation_type; /* SCSI-3 or SCSI-2 */ + uint_t un_max_xfer_size; /* Maximum DMA transfer size */ + int un_partial_dma_supported; + int un_buf_breakup_supported; + + int un_mincdb; /* Smallest CDB to use */ + int un_maxcdb; /* Largest CDB to use */ + int un_max_hba_cdb; /* Largest CDB supported by HBA */ + int un_status_len; + int un_pkt_flags; + + /* + * Note: un_uscsi_timeout is a "mirror" of un_cmd_timeout, adjusted + * for ISCD(). Any updates to un_cmd_timeout MUST be reflected + * in un_uscsi_timeout as well! + */ + ushort_t un_cmd_timeout; /* Timeout for completion */ + ushort_t un_uscsi_timeout; /* Timeout for USCSI completion */ + ushort_t un_busy_timeout; /* Timeout for busy retry */ + + /* + * Info on current states, statuses, etc. (Updated frequently) + */ + uchar_t un_state; /* current state */ + uchar_t un_last_state; /* last state */ + uchar_t un_last_pkt_reason; /* used to suppress multiple msgs */ + int un_tagflags; /* Pkt Flags for Tagged Queueing */ + short un_resvd_status; /* Reservation Status */ + + /* + * Control & status info for command throttling + */ + long un_ncmds_in_driver; /* number of cmds in driver */ + short un_ncmds_in_transport; /* number of cmds in transport */ + short un_throttle; /* max #cmds allowed in transport */ + short un_saved_throttle; /* saved value of un_throttle */ + short un_busy_throttle; /* saved un_throttle for BUSY */ + short un_min_throttle; /* min value of un_throttle */ + timeout_id_t un_reset_throttle_timeid; /* timeout(9F) handle */ + + /* + * Multi-host (clustering) support + */ + opaque_t un_mhd_token; /* scsi watch request */ + timeout_id_t un_resvd_timeid; /* for resvd recover */ + + /* Event callback resources (photon) */ + ddi_eventcookie_t un_insert_event; /* insert event */ + ddi_callback_id_t un_insert_cb_id; /* insert callback */ + ddi_eventcookie_t un_remove_event; /* remove event */ + ddi_callback_id_t un_remove_cb_id; /* remove callback */ + + uint_t un_start_stop_cycle_page; /* Saves start/stop */ + /* cycle page */ + timeout_id_t un_dcvb_timeid; /* dlyd cv broadcast */ + + /* + * Data structures for open counts, partition info, VTOC, + * stats, and other such bookkeeping info. + */ + union ocmap un_ocmap; /* open partition map */ + struct kstat *un_pstats[NSDMAP]; /* partition statistics */ + struct kstat *un_stats; /* disk statistics */ + sd_unmapstats_t *un_unmapstats; /* UNMAP stats structure */ + struct kstat *un_unmapstats_ks; /* UNMAP kstat */ + kstat_t *un_errstats; /* for error statistics */ + uint64_t un_exclopen; /* exclusive open bitmask */ + ddi_devid_t un_devid; /* device id */ + uint_t un_vpd_page_mask; /* Supported VPD pages */ + + /* + * Bit fields for various configuration/state/status info. + * Comments indicate the condition if the value of the + * variable is TRUE (nonzero). + */ + uint32_t + un_f_arq_enabled :1, /* Auto request sense is */ + /* currently enabled */ + un_f_blockcount_is_valid :1, /* The un_blockcount */ + /* value is currently valid */ + un_f_tgt_blocksize_is_valid :1, /* The un_tgt_blocksize */ + /* value is currently valid */ + un_f_allow_bus_device_reset :1, /* Driver may issue a BDR as */ + /* a part of error recovery. */ + un_f_is_fibre :1, /* The device supports fibre */ + /* channel */ + un_f_sync_cache_supported :1, /* sync cache cmd supported */ + /* supported */ + un_f_format_in_progress :1, /* The device is currently */ + /* executing a FORMAT cmd. */ + un_f_opt_queueing :1, /* Enable Command Queuing to */ + /* Host Adapter */ + un_f_opt_fab_devid :1, /* Disk has no valid/unique */ + /* serial number. */ + un_f_opt_disable_cache :1, /* Read/Write disk cache is */ + /* disabled. */ + un_f_cfg_is_atapi :1, /* This is an ATAPI device. */ + un_f_write_cache_enabled :1, /* device return success on */ + /* writes before transfer to */ + /* physical media complete */ + un_f_cfg_playmsf_bcd :1, /* Play Audio, BCD params. */ + un_f_cfg_readsub_bcd :1, /* READ SUBCHANNEL BCD resp. */ + un_f_cfg_read_toc_trk_bcd :1, /* track # is BCD */ + un_f_cfg_read_toc_addr_bcd :1, /* address is BCD */ + un_f_cfg_no_read_header :1, /* READ HEADER not supported */ + un_f_cfg_read_cd_xd4 :1, /* READ CD opcode is 0xd4 */ + un_f_mmc_cap :1, /* Device is MMC compliant */ + un_f_mmc_writable_media :1, /* writable media in device */ + un_f_dvdram_writable_device :1, /* DVDRAM device is writable */ + un_f_cfg_cdda :1, /* READ CDDA supported */ + un_f_cfg_tur_check :1, /* verify un_ncmds before tur */ + + un_f_use_adaptive_throttle :1, /* enable/disable adaptive */ + /* throttling */ + un_f_pm_is_enabled :1, /* PM is enabled on this */ + /* instance */ + un_f_watcht_stopped :1, /* media watch thread flag */ + un_f_pkstats_enabled :1, /* Flag to determine if */ + /* partition kstats are */ + /* enabled. */ + un_f_disksort_disabled :1, /* Flag to disable disksort */ + un_f_lun_reset_enabled :1, /* Set if target supports */ + /* SCSI Logical Unit Reset */ + un_f_doorlock_supported :1, /* Device supports Doorlock */ + un_f_start_stop_supported :1, /* device has motor */ + un_f_reserved1 :1; + + uint32_t + un_f_mboot_supported :1, /* mboot supported */ + un_f_is_hotpluggable :1, /* hotpluggable */ + un_f_has_removable_media :1, /* has removable media */ + un_f_non_devbsize_supported :1, /* non-512 blocksize */ + un_f_devid_supported :1, /* device ID supported */ + un_f_eject_media_supported :1, /* media can be ejected */ + un_f_chk_wp_open :1, /* check if write-protected */ + /* when being opened */ + un_f_descr_format_supported :1, /* support descriptor format */ + /* for sense data */ + un_f_check_start_stop :1, /* needs to check if */ + /* START-STOP command is */ + /* supported by hardware */ + /* before issuing it */ + un_f_monitor_media_state :1, /* need a watch thread to */ + /* monitor device state */ + un_f_attach_spinup :1, /* spin up once the */ + /* device is attached */ + un_f_log_sense_supported :1, /* support log sense */ + un_f_pm_supported :1, /* support power-management */ + un_f_wcc_inprog :1, /* write cache change in */ + /* progress */ + un_f_ejecting :1, /* media is ejecting */ + un_f_suppress_cache_flush :1, /* supress flush on */ + /* write cache */ + un_f_sync_nv_supported :1, /* SYNC_NV */ + /* bit is supported */ + un_f_sync_cache_required :1, /* flag to check if */ + /* SYNC CACHE needs to be */ + /* sent in sdclose */ + un_f_devid_transport_defined :1, /* devid defined by transport */ + un_f_rmw_type :2, /* RMW type */ + un_f_power_condition_disabled :1, /* power condition disabled */ + /* through sd configuration */ + un_f_power_condition_supported :1, /* support power condition */ + /* field by hardware */ + un_f_pm_log_sense_smart :1, /* log sense support SMART */ + /* feature attribute */ + un_f_is_solid_state :1, /* has solid state media */ + un_f_is_rotational :1, /* spinning rust */ + un_f_mmc_gesn_polling :1, /* use GET EVENT STATUS */ + /* NOTIFICATION for polling */ + un_f_enable_rmw :1, /* Force RMW in sd driver */ + un_f_expnevent :1, + un_f_cache_mode_changeable :1, /* can change cache mode */ + un_f_reserved :2; + + /* Ptr to table of strings for ASC/ASCQ error message printing */ + struct scsi_asq_key_strings *un_additional_codes; + + /* + * Power Management support. + * + * un_pm_mutex protects, un_pm_count, un_pm_timeid, un_pm_busy, + * un_pm_busy_cv, and un_pm_idle_timeid. + * It's not required that SD_MUTEX be acquired before acquiring + * un_pm_mutex, however if they must both be held + * then acquire SD_MUTEX first. + * + * un_pm_count is used to indicate PM state as follows: + * less than 0 the device is powered down, + * transition from 0 ==> 1, mark the device as busy via DDI + * transition from 1 ==> 0, mark the device as idle via DDI + */ + kmutex_t un_pm_mutex; + int un_pm_count; /* indicates pm state */ + timeout_id_t un_pm_timeid; /* timeout id for pm */ + uint_t un_pm_busy; + kcondvar_t un_pm_busy_cv; + short un_power_level; /* Power Level */ + uchar_t un_save_state; + kcondvar_t un_suspend_cv; /* power management */ + kcondvar_t un_disk_busy_cv; /* wait for IO completion */ + + /* Resources used for media change callback support */ + kcondvar_t un_state_cv; /* Cond Var on mediastate */ + enum dkio_state un_mediastate; /* current media state */ + enum dkio_state un_specified_mediastate; /* expected state */ + opaque_t un_swr_token; /* scsi_watch request token */ + + /* Non-512 byte block support */ + struct kmem_cache *un_wm_cache; /* fast alloc in non-512 write case */ + uint_t un_rmw_count; /* count of read-modify-writes */ + struct sd_w_map *un_wm; /* head of sd_w_map chain */ + uint64_t un_rmw_incre_count; /* count I/O */ + timeout_id_t un_rmw_msg_timeid; /* for RMW message control */ + + /* Thin provisioning support (see SD_THIN_PROV_*) */ + uint64_t un_thin_flags; + + /* Block limits (0xB0 VPD page) */ + sd_blk_limits_t un_blk_lim; + + /* For timeout callback to issue a START STOP UNIT command */ + timeout_id_t un_startstop_timeid; + + /* Timeout callback handle for SD_PATH_DIRECT_PRIORITY cmd restarts */ + timeout_id_t un_direct_priority_timeid; + + /* TRAN_FATAL_ERROR count. Cleared by TRAN_ACCEPT from scsi_transport */ + ulong_t un_tran_fatal_count; + + timeout_id_t un_retry_timeid; + + hrtime_t un_pm_idle_time; + timeout_id_t un_pm_idle_timeid; + + /* + * Support for failfast operation. + */ + struct buf *un_failfast_bp; + struct buf *un_failfast_headp; + struct buf *un_failfast_tailp; + uint32_t un_failfast_state; + /* Callback routine active counter */ + short un_in_callback; + + kcondvar_t un_wcc_cv; /* synchronize changes to */ + /* un_f_write_cache_enabled */ + +#ifdef SD_FAULT_INJECTION + /* SD Fault Injection */ +#define SD_FI_MAX_BUF 65536 +#define SD_FI_MAX_ERROR 1024 + kmutex_t un_fi_mutex; + uint_t sd_fi_buf_len; + char sd_fi_log[SD_FI_MAX_BUF]; + struct sd_fi_pkt *sd_fi_fifo_pkt[SD_FI_MAX_ERROR]; + struct sd_fi_xb *sd_fi_fifo_xb[SD_FI_MAX_ERROR]; + struct sd_fi_un *sd_fi_fifo_un[SD_FI_MAX_ERROR]; + struct sd_fi_arq *sd_fi_fifo_arq[SD_FI_MAX_ERROR]; + uint_t sd_fi_fifo_start; + uint_t sd_fi_fifo_end; + uint_t sd_injection_mask; + +#endif + + cmlb_handle_t un_cmlbhandle; + + /* + * Pointer to internal struct sd_fm_internal in which + * will pass necessary information for FMA ereport posting. + */ + void *un_fm_private; +}; + +#define SD_IS_VALID_LABEL(un) (cmlb_is_valid(un->un_cmlbhandle)) + +/* + * Macros for conversions between "target" and "system" block sizes, and + * for conversion between block counts and byte counts. As used here, + * "system" block size refers to the block size used by the kernel/ + * filesystem (this includes the disk label). The "target" block size + * is the block size returned by the SCSI READ CAPACITY command. + * + * Note: These macros will round up to the next largest blocksize to accomodate + * the number of blocks specified. + */ + +/* Convert a byte count to a number of target blocks */ +#define SD_BYTES2TGTBLOCKS(un, bytecount) \ + ((bytecount + (un->un_tgt_blocksize - 1))/un->un_tgt_blocksize) + +/* Convert a byte count to a number of physical blocks */ +#define SD_BYTES2PHYBLOCKS(un, bytecount) \ + ((bytecount + (un->un_phy_blocksize - 1))/un->un_phy_blocksize) + +/* Convert a target block count to a number of bytes */ +#define SD_TGTBLOCKS2BYTES(un, blockcount) \ + (blockcount * (un)->un_tgt_blocksize) + +/* Convert a byte count to a number of system blocks */ +#define SD_BYTES2SYSBLOCKS(bytecount) \ + ((bytecount + (DEV_BSIZE - 1))/DEV_BSIZE) + +/* Convert a system block count to a number of bytes */ +#define SD_SYSBLOCKS2BYTES(blockcount) \ + (blockcount * DEV_BSIZE) + +/* + * Calculate the number of bytes needed to hold the requested number of bytes + * based upon the native target sector/block size + */ +#define SD_REQBYTES2TGTBYTES(un, bytecount) \ + (SD_BYTES2TGTBLOCKS(un, bytecount) * (un)->un_tgt_blocksize) + +/* + * Calculate the byte offset from the beginning of the target block + * to the system block location. + */ +#define SD_TGTBYTEOFFSET(un, sysblk, tgtblk) \ + (SD_SYSBLOCKS2BYTES(sysblk) - SD_TGTBLOCKS2BYTES(un, tgtblk)) + +/* + * Calculate the target block location from the system block location + */ +#define SD_SYS2TGTBLOCK(un, blockcnt) \ + (blockcnt / ((un)->un_tgt_blocksize / DEV_BSIZE)) + +/* + * Calculate the target block location from the system block location + */ +#define SD_TGT2SYSBLOCK(un, blockcnt) \ + (blockcnt * ((un)->un_tgt_blocksize / DEV_BSIZE)) + +/* + * SD_DEFAULT_MAX_XFER_SIZE is the default value to bound the max xfer + * for physio, for devices without tagged queuing enabled. + * The default for devices with tagged queuing enabled is SD_MAX_XFER_SIZE + */ +#if defined(__i386) || defined(__amd64) +#define SD_DEFAULT_MAX_XFER_SIZE (256 * 1024) +#endif +#define SD_MAX_XFER_SIZE (1024 * 1024) + +/* + * Warlock annotations + */ +_NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, sd_lun)) +_NOTE(READ_ONLY_DATA(sd_lun::un_sd)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_reservation_type)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_mincdb)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_maxcdb)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_max_hba_cdb)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_status_len)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_f_arq_enabled)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_ctype)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_cmlbhandle)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_fm_private)) + + +_NOTE(SCHEME_PROTECTS_DATA("safe sharing", + sd_lun::un_mhd_token + sd_lun::un_state + sd_lun::un_tagflags + sd_lun::un_f_format_in_progress + sd_lun::un_resvd_timeid + sd_lun::un_reset_throttle_timeid + sd_lun::un_startstop_timeid + sd_lun::un_dcvb_timeid + sd_lun::un_f_allow_bus_device_reset + sd_lun::un_sys_blocksize + sd_lun::un_tgt_blocksize + sd_lun::un_phy_blocksize + sd_lun::un_additional_codes)) + +_NOTE(SCHEME_PROTECTS_DATA("stable data", + sd_lun::un_reserve_release_time + sd_lun::un_max_xfer_size + sd_lun::un_partial_dma_supported + sd_lun::un_buf_breakup_supported + sd_lun::un_f_is_fibre + sd_lun::un_node_type + sd_lun::un_buf_chain_type + sd_lun::un_uscsi_chain_type + sd_lun::un_direct_chain_type + sd_lun::un_priority_chain_type + sd_lun::un_xbuf_attr + sd_lun::un_cmd_timeout + sd_lun::un_pkt_flags)) + +_NOTE(SCHEME_PROTECTS_DATA("Unshared data", + block_descriptor + buf + cdrom_subchnl + cdrom_tocentry + cdrom_tochdr + cdrom_read + dk_cinfo + dk_devid + dk_label + dk_map + dk_temperature + mhioc_inkeys + mhioc_inresvs + mode_caching + mode_header + mode_speed + scsi_cdb + scsi_arq_status + scsi_extended_sense + scsi_inquiry + scsi_pkt + uio + uscsi_cmd)) + + +_NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_device dk_cinfo)) +_NOTE(SCHEME_PROTECTS_DATA("unique per pkt", scsi_status scsi_cdb)) + +_NOTE(MUTEX_PROTECTS_DATA(sd_lun::un_pm_mutex, sd_lun::un_pm_count + sd_lun::un_pm_timeid sd_lun::un_pm_busy sd_lun::un_pm_busy_cv + sd_lun::un_pm_idle_timeid)) + +#ifdef SD_FAULT_INJECTION +_NOTE(MUTEX_PROTECTS_DATA(sd_lun::un_fi_mutex, + sd_lun::sd_fi_buf_len sd_lun::sd_fi_log)) +#endif + +/* _NOTE(LOCK_ORDER(sd_lun::un_sd.sd_mutex sd_lun::un_pm_mutex)) */ + + + +/* + * Referenced for frequently-accessed members of the unit structure + */ +#define SD_SCSI_DEVP(un) ((un)->un_sd) +#define SD_DEVINFO(un) ((un)->un_sd->sd_dev) +#define SD_INQUIRY(un) ((un)->un_sd->sd_inq) +#define SD_MUTEX(un) (&((un)->un_sd->sd_mutex)) +#define SD_ADDRESS(un) (&((un)->un_sd->sd_address)) +#define SD_GET_DEV(un) (sd_make_device(SD_DEVINFO(un))) +#define SD_FM_LOG(un) (((struct sd_fm_internal *)\ + ((un)->un_fm_private))->fm_log_level) + +/* + * Version Related Macros + */ +#define SD_SCSI_VERS_IS_GE_SPC_4(un) \ + (SD_INQUIRY(un)->inq_ansi == RDF_SCSI_SPC4 || \ + SD_INQUIRY(un)->inq_ansi == RDF_SCSI_SPC5) + +/* + * Values for un_ctype + */ +#define CTYPE_CDROM 0 +#define CTYPE_MD21 1 /* Obsolete! */ +#define CTYPE_CCS 2 +#define CTYPE_ROD 3 +#define CTYPE_PXRE 4 /* Obsolete! */ + +#define ISCD(un) ((un)->un_ctype == CTYPE_CDROM) +#define ISROD(un) ((un)->un_ctype == CTYPE_ROD) +#define ISPXRE(un) ((un)->un_ctype == CTYPE_PXRE) + +/* + * Macros for non-512 byte writes to removable devices. + */ +#define NOT_DEVBSIZE(un) \ + ((un)->un_tgt_blocksize != (un)->un_sys_blocksize) + +/* + * Check that a write map, used for locking lba ranges for writes, is in + * the linked list. + */ +#define ONLIST(un, wmp) \ + (((un)->un_wm == (wmp)) || ((wmp)->wm_prev != NULL)) + +/* + * Free a write map which is on list. Basically make sure that nobody is + * sleeping on it before freeing it. + */ +#define FREE_ONLIST_WMAP(un, wmp) \ + if (!(wmp)->wm_wanted_count) { \ + sd_free_inlist_wmap((un), (wmp)); \ + (wmp) = NULL; \ + } + +#define CHK_N_FREEWMP(un, wmp) \ + if (!ONLIST((un), (wmp))) { \ + kmem_cache_free((un)->un_wm_cache, (wmp)); \ + (wmp) = NULL; \ + } else { \ + FREE_ONLIST_WMAP((un), (wmp)); \ + } + +/* + * Values used to in wm_flags field of sd_w_map. + */ +#define SD_WTYPE_SIMPLE 0x001 /* Write aligned at blksize boundary */ +#define SD_WTYPE_RMW 0x002 /* Write requires read-modify-write */ +#define SD_WM_BUSY 0x100 /* write-map is busy */ + +/* + * RMW type + */ +#define SD_RMW_TYPE_DEFAULT 0 /* do rmw with warning message */ +#define SD_RMW_TYPE_NO_WARNING 1 /* do rmw without warning message */ +#define SD_RMW_TYPE_RETURN_ERROR 2 /* rmw disabled */ + +/* Device error kstats */ +struct sd_errstats { + struct kstat_named sd_softerrs; + struct kstat_named sd_harderrs; + struct kstat_named sd_transerrs; + struct kstat_named sd_vid; + struct kstat_named sd_pid; + struct kstat_named sd_revision; + struct kstat_named sd_serial; + struct kstat_named sd_capacity; + struct kstat_named sd_rq_media_err; + struct kstat_named sd_rq_ntrdy_err; + struct kstat_named sd_rq_nodev_err; + struct kstat_named sd_rq_recov_err; + struct kstat_named sd_rq_illrq_err; + struct kstat_named sd_rq_pfa_err; +}; + + +/* + * Structs and definitions for SCSI-3 Persistent Reservation + */ +typedef struct sd_prin_readkeys { + uint32_t generation; + uint32_t len; + mhioc_resv_key_t *keylist; +} sd_prin_readkeys_t; + +typedef struct sd_readresv_desc { + mhioc_resv_key_t resvkey; + uint32_t scope_specific_addr; + uint8_t reserved_1; +#if defined(_BIT_FIELDS_LTOH) + uint8_t type:4, + scope:4; +#elif defined(_BIT_FIELDS_HTOL) + uint8_t scope:4, + type:4; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uint8_t reserved_2; + uint8_t reserved_3; +} sd_readresv_desc_t; + +typedef struct sd_prin_readresv { + uint32_t generation; + uint32_t len; + sd_readresv_desc_t *readresv_desc; +} sd_prin_readresv_t; + +typedef struct sd_prout { + uchar_t res_key[MHIOC_RESV_KEY_SIZE]; + uchar_t service_key[MHIOC_RESV_KEY_SIZE]; + uint32_t scope_address; +#if defined(_BIT_FIELDS_LTOH) + uchar_t aptpl:1, + reserved:7; +#elif defined(_BIT_FIELDS_HTOL) + uchar_t reserved:7, + aptpl:1; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + uchar_t reserved_1; + uint16_t ext_len; +} sd_prout_t; + +#define SD_READ_KEYS 0x00 +#define SD_READ_RESV 0x01 + +#define SD_SCSI3_REGISTER 0x00 +#define SD_SCSI3_RESERVE 0x01 +#define SD_SCSI3_RELEASE 0x02 +#define SD_SCSI3_CLEAR 0x03 +#define SD_SCSI3_PREEMPTANDABORT 0x05 +#define SD_SCSI3_REGISTERANDIGNOREKEY 0x06 + +/* + * Note: The default init of un_reservation_type is to the value of '0' + * (from the ddi_softs_state_zalloc) which means it is defaulting to SCSI-3 + * reservation type. This is ok because during attach we use a SCSI-3 + * PRIORITY RESERVE IN command to determine the reservation type, and set + * un_reservation_type for all cases. + */ +#define SD_SCSI3_RESERVATION 0x0 +#define SD_SCSI2_RESERVATION 0x1 +#define SCSI3_RESV_DESC_LEN 16 + +/* + * Reservation Status's + */ +#define SD_RELEASE 0x0000 +#define SD_RESERVE 0x0001 +#define SD_TKOWN 0x0002 +#define SD_LOST_RESERVE 0x0004 +#define SD_FAILFAST 0x0080 +#define SD_WANT_RESERVE 0x0100 +#define SD_RESERVATION_CONFLICT 0x0200 +#define SD_PRIORITY_RESERVE 0x0400 + +#define SD_TARGET_IS_UNRESERVED 0 +#define SD_TARGET_IS_RESERVED 1 + +/* + * Save page in mode_select + */ +#define SD_DONTSAVE_PAGE 0 +#define SD_SAVE_PAGE 1 + +/* + * Delay before reclaiming reservation is 6 seconds, in units of micro seconds + */ +#define SD_REINSTATE_RESV_DELAY 6000000 + +#define SD_MODE2_BLKSIZE 2336 /* bytes */ + +/* + * Solid State Drive default sector size + */ +#define SSD_SECSIZE 4096 + +/* + * Resource type definitions for multi host control operations. Specifically, + * queue and request definitions for reservation request handling between the + * scsi facility callback function (sd_mhd_watch_cb) and the reservation + * reclaim thread (sd_resv_reclaim_thread) + */ +struct sd_thr_request { + dev_t dev; + struct sd_thr_request *sd_thr_req_next; +}; + +struct sd_resv_reclaim_request { + kthread_t *srq_resv_reclaim_thread; + struct sd_thr_request *srq_thr_req_head; + struct sd_thr_request *srq_thr_cur_req; + kcondvar_t srq_inprocess_cv; + kmutex_t srq_resv_reclaim_mutex; + kcondvar_t srq_resv_reclaim_cv; +}; + +_NOTE(MUTEX_PROTECTS_DATA(sd_resv_reclaim_request::srq_resv_reclaim_mutex, + sd_resv_reclaim_request)) +_NOTE(SCHEME_PROTECTS_DATA("unshared data", sd_thr_request)) +_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_prout)) + + + +/* + * Driver Logging Components + * + * These components cover the functional entry points and areas of the + * driver. A component value is used for the entry point and utility + * functions used by the entry point. The common component value is used + * in those routines that are called from many areas of the driver. + * + * This can be done by adding the following two lines to /etc/system: + * set sd:sd_component_mask=0x00080000 + * set sd:sd_level_mask=0x00000008 + */ +#define SD_LOG_PROBE 0x00000001 +#define SD_LOG_ATTACH_DETACH 0x00000002 +#define SD_LOG_OPEN_CLOSE 0x00000004 +#define SD_LOG_READ_WRITE 0x00000008 +#define SD_LOG_POWER 0x00000010 +#define SD_LOG_IOCTL 0x00000020 +#define SD_LOG_IOCTL_MHD 0x00000040 +#define SD_LOG_IOCTL_RMMEDIA 0x00000080 +#define SD_LOG_IOCTL_DKIO 0x00000100 +#define SD_LOG_IO 0x00000200 +#define SD_LOG_IO_CORE 0x00000400 +#define SD_LOG_IO_DISKSORT 0x00000800 +#define SD_LOG_IO_PARTITION 0x00001000 +#define SD_LOG_IO_RMMEDIA 0x00002000 +#define SD_LOG_IO_CHKSUM 0x00004000 +#define SD_LOG_IO_SDIOCTL 0x00008000 +#define SD_LOG_IO_PM 0x00010000 +#define SD_LOG_ERROR 0x00020000 +#define SD_LOG_DUMP 0x00040000 +#define SD_LOG_COMMON 0x00080000 +#define SD_LOG_SDTEST 0x00100000 +#define SD_LOG_IOERR 0x00200000 +#define SD_LOG_IO_FAILFAST 0x00400000 + +/* Driver Logging Levels */ +#define SD_LOGMASK_ERROR 0x00000001 +#define SD_LOGMASK_DUMP_MEM 0x00000002 +#define SD_LOGMASK_INFO 0x00000004 +#define SD_LOGMASK_TRACE 0x00000008 +#define SD_LOGMASK_DIAG 0x00000010 + +/* Driver Logging Formats */ +#define SD_LOG_HEX 0x00000001 +#define SD_LOG_CHAR 0x00000002 + +/* + * The following macros should be used to log driver debug information + * only. The output is filtered according to the component and level mask + * values. Non-debug information, such as driver warnings intended for + * the user should be logged via the scsi_log facility to ensure that + * they are not filtered. + */ +#if DEBUG || lint +#define SDDEBUG + +/* SD_ERROR is called to log driver error conditions */ +#define SD_ERROR sd_log_err + +/* SD_TRACE is called to log driver trace conditions (function entry/exit) */ +#define SD_TRACE sd_log_trace + +/* SD_INFO is called to log general purpose driver info */ +#define SD_INFO sd_log_info + +/* SD_DUMP_MEMORY is called to dump a data buffer to the log */ +#define SD_DUMP_MEMORY sd_dump_memory + +/* RESET/ABORTS testing ioctls */ +#define DKIOCRESET (DKIOC|14) +#define DKIOCABORT (DKIOC|15) + +#ifdef SD_FAULT_INJECTION +/* + * sd_fi_pkt replicates the variables that are exposed through pkt + * + * sd_fi_xb replicates the variables that are exposed through xb + * + * sd_fi_un replicates the variables that are exposed through un + * + * sd_fi_arq replicates the variables that are + * exposed for Auto-Reqeust-Sense + * + */ +struct sd_fi_pkt { + uint_t pkt_flags; /* flags */ + uchar_t pkt_scbp; /* pointer to status block */ + uchar_t pkt_cdbp; /* pointer to command block */ + uint_t pkt_state; /* state of command */ + uint_t pkt_statistics; /* statistics */ + uchar_t pkt_reason; /* reason completion called */ +}; + +struct sd_fi_xb { + daddr_t xb_blkno; + ssize_t xb_dma_resid; + short xb_retry_count; + short xb_victim_retry_count; + uchar_t xb_sense_status; + uint_t xb_sense_state; + ssize_t xb_sense_resid; + uchar_t xb_sense_data[SENSE_LENGTH]; + uchar_t es_code; + uchar_t es_key; + uchar_t es_add_code; + uchar_t es_qual_code; +}; + +struct sd_fi_un { + uchar_t inq_rmb; + uchar_t un_ctype; + uint_t un_notready_retry_count; + uint_t un_reset_retry_count; + uchar_t un_reservation_type; + ushort_t un_notrdy_delay; + short un_resvd_status; + uint32_t + un_f_arq_enabled, + un_f_allow_bus_device_reset, + un_f_opt_queueing; + timeout_id_t un_restart_timeid; +}; + +struct sd_fi_arq { + struct scsi_status sts_status; + struct scsi_status sts_rqpkt_status; + uchar_t sts_rqpkt_reason; + uchar_t sts_rqpkt_resid; + uint_t sts_rqpkt_state; + uint_t sts_rqpkt_statistics; + struct scsi_extended_sense sts_sensedata; +}; + +/* + * Conditional set def + */ +#define SD_CONDSET(a, b, c, d) \ + { \ + a->c = ((fi_ ## b)->c); \ + SD_INFO(SD_LOG_IOERR, un, \ + "sd_fault_injection:" \ + "setting %s to %d\n", \ + d, ((fi_ ## b)->c)); \ + } + +/* SD FaultInjection ioctls */ +#define SDIOC ('T'<<8) +#define SDIOCSTART (SDIOC|1) +#define SDIOCSTOP (SDIOC|2) +#define SDIOCINSERTPKT (SDIOC|3) +#define SDIOCINSERTXB (SDIOC|4) +#define SDIOCINSERTUN (SDIOC|5) +#define SDIOCINSERTARQ (SDIOC|6) +#define SDIOCPUSH (SDIOC|7) +#define SDIOCRETRIEVE (SDIOC|8) +#define SDIOCRUN (SDIOC|9) +#endif + +#else + +#undef SDDEBUG +#define SD_ERROR(...) (void)(0) +#define SD_TRACE(...) (void)(0) +#define SD_INFO(...) (void)(0) +#define SD_DUMP_MEMORY(...) (void)(0) +#endif + + +/* + * Miscellaneous macros + */ + +#define SD_USECTOHZ(x) (drv_usectohz((x)*1000000)) +#define SD_GET_PKT_STATUS(pktp) ((*(pktp)->pkt_scbp) & STATUS_MASK) + +#define SD_BIOERROR(bp, errcode) \ + if ((bp)->b_resid == 0) { \ + (bp)->b_resid = (bp)->b_bcount; \ + } \ + if ((bp)->b_error == 0) { \ + bioerror(bp, errcode); \ + } \ + (bp)->b_flags |= B_ERROR; + +#define SD_FILL_SCSI1_LUN_CDB(lunp, cdbp) \ + if (! (lunp)->un_f_is_fibre && \ + SD_INQUIRY((lunp))->inq_ansi == 0x01) { \ + int _lun = ddi_prop_get_int(DDI_DEV_T_ANY, \ + SD_DEVINFO((lunp)), DDI_PROP_DONTPASS, \ + SCSI_ADDR_PROP_LUN, 0); \ + if (_lun > 0) { \ + (cdbp)->scc_lun = _lun; \ + } \ + } + +#define SD_FILL_SCSI1_LUN(lunp, pktp) \ + SD_FILL_SCSI1_LUN_CDB((lunp), (union scsi_cdb *)(pktp)->pkt_cdbp) + +/* + * Disk driver states + */ + +#define SD_STATE_NORMAL 0 +#define SD_STATE_OFFLINE 1 +#define SD_STATE_RWAIT 2 +#define SD_STATE_DUMPING 3 +#define SD_STATE_SUSPENDED 4 +#define SD_STATE_PM_CHANGING 5 + +/* + * The table is to be interpreted as follows: The rows lists all the states + * and each column is a state that a state in each row *can* reach. The entries + * in the table list the event that cause that transition to take place. + * For e.g.: To go from state RWAIT to SUSPENDED, event (d)-- which is the + * invocation of DDI_SUSPEND-- has to take place. Note the same event could + * cause the transition from one state to two different states. e.g., from + * state SUSPENDED, when we get a DDI_RESUME, we just go back to the *last + * state* whatever that might be. (NORMAL or OFFLINE). + * + * + * State Transition Table: + * + * NORMAL OFFLINE RWAIT DUMPING SUSPENDED PM_SUSPENDED + * + * NORMAL - (a) (b) (c) (d) (h) + * + * OFFLINE (e) - (e) (c) (d) NP + * + * RWAIT (f) NP - (c) (d) (h) + * + * DUMPING NP NP NP - NP NP + * + * SUSPENDED (g) (g) (b) NP* - NP + * + * PM_SUSPENDED (i) NP (b) (c) (d) - + * + * NP : Not Possible. + * (a): Disk does not respond. + * (b): Packet Allocation Fails + * (c): Panic - Crash dump + * (d): DDI_SUSPEND is called. + * (e): Disk has a successful I/O completed. + * (f): sdrunout() calls sdstart() which sets it NORMAL + * (g): DDI_RESUME is called. + * (h): Device threshold exceeded pm framework called power + * entry point or pm_lower_power called in detach. + * (i): When new I/O come in. + * * : When suspended, we dont change state during panic dump + */ + + +#define SD_MAX_THROTTLE 256 +#define SD_MIN_THROTTLE 8 +/* + * Lowest valid max. and min. throttle value. + * This is set to 2 because if un_min_throttle were allowed to be 1 then + * un_throttle would never get set to a value less than un_min_throttle + * (0 is a special case) which means it would never get set back to + * un_saved_throttle in routine sd_restore_throttle(). + */ +#define SD_LOWEST_VALID_THROTTLE 2 + + + +/* Return codes for sd_send_polled_cmd() and sd_scsi_poll() */ +#define SD_CMD_SUCCESS 0 +#define SD_CMD_FAILURE 1 +#define SD_CMD_RESERVATION_CONFLICT 2 +#define SD_CMD_ILLEGAL_REQUEST 3 +#define SD_CMD_BECOMING_READY 4 +#define SD_CMD_CHECK_CONDITION 5 + +/* Return codes for sd_ready_and_valid */ +#define SD_READY_VALID 0 +#define SD_NOT_READY_VALID 1 +#define SD_RESERVED_BY_OTHERS 2 + +#define SD_PATH_STANDARD 0 +#define SD_PATH_DIRECT 1 +#define SD_PATH_DIRECT_PRIORITY 2 + +#define SD_UNIT_ATTENTION_RETRY 40 + +/* + * The following three are bit flags passed into sd_send_scsi_TEST_UNIT_READY + * to control specific behavior. + */ +#define SD_CHECK_FOR_MEDIA 0x01 +#define SD_DONT_RETRY_TUR 0x02 +#define SD_BYPASS_PM 0x04 + +#define SD_GROUP0_MAX_ADDRESS (0x1fffff) +#define SD_GROUP0_MAXCOUNT (0xff) +#define SD_GROUP1_MAX_ADDRESS (0xffffffff) +#define SD_GROUP1_MAXCOUNT (0xffff) + +#define SD_BECOMING_ACTIVE 0x01 +#define SD_REMOVAL_ALLOW 0 +#define SD_REMOVAL_PREVENT 1 + +#define SD_GET_PKT_OPCODE(pktp) \ + (((union scsi_cdb *)((pktp)->pkt_cdbp))->cdb_un.cmd) + + +#define SD_NO_RETRY_ISSUED 0 +#define SD_DELAYED_RETRY_ISSUED 1 +#define SD_IMMEDIATE_RETRY_ISSUED 2 + +#if defined(__i386) || defined(__amd64) +#define SD_UPDATE_B_RESID(bp, pktp) \ + ((bp)->b_resid += (pktp)->pkt_resid + (SD_GET_XBUF(bp)->xb_dma_resid)) +#else +#define SD_UPDATE_B_RESID(bp, pktp) \ + ((bp)->b_resid += (pktp)->pkt_resid) +#endif + + +#define SD_RETRIES_MASK 0x00FF +#define SD_RETRIES_NOCHECK 0x0000 +#define SD_RETRIES_STANDARD 0x0001 +#define SD_RETRIES_VICTIM 0x0002 +#define SD_RETRIES_BUSY 0x0003 +#define SD_RETRIES_UA 0x0004 +#define SD_RETRIES_ISOLATE 0x8000 +#define SD_RETRIES_FAILFAST 0x4000 + +#define SD_UPDATE_RESERVATION_STATUS(un, pktp) \ +if (((pktp)->pkt_reason == CMD_RESET) || \ + ((pktp)->pkt_statistics & (STAT_BUS_RESET | STAT_DEV_RESET))) { \ + if (((un)->un_resvd_status & SD_RESERVE) == SD_RESERVE) { \ + (un)->un_resvd_status |= \ + (SD_LOST_RESERVE | SD_WANT_RESERVE); \ + } \ +} + +#define SD_SENSE_DATA_IS_VALID 0 +#define SD_SENSE_DATA_IS_INVALID 1 + +/* + * Delay (in seconds) before restoring the "throttle limit" back + * to its maximum value. + * 60 seconds is what we will wait for to reset the + * throttle back to it SD_MAX_THROTTLE for TRAN_BUSY. + * 10 seconds for STATUS_QFULL because QFULL will incrementally + * increase the throttle limit until it reaches max value. + */ +#define SD_RESET_THROTTLE_TIMEOUT 60 +#define SD_QFULL_THROTTLE_TIMEOUT 10 + +#define SD_THROTTLE_TRAN_BUSY 0 +#define SD_THROTTLE_QFULL 1 + +#define SD_THROTTLE_RESET_INTERVAL \ + (sd_reset_throttle_timeout * drv_usectohz(1000000)) + +#define SD_QFULL_THROTTLE_RESET_INTERVAL \ + (sd_qfull_throttle_timeout * drv_usectohz(1000000)) + + +/* + * xb_pkt_flags defines + * SD_XB_DMA_FREED indicates the scsi_pkt has had its DMA resources freed + * by a call to scsi_dmafree(9F). The resources must be reallocated before + * before a call to scsi_transport can be made again. + * SD_XB_USCSICMD indicates the scsi request is a uscsi request + * SD_XB_INITPKT_MASK: since this field is also used to store flags for + * a scsi_init_pkt(9F) call, we need a mask to make sure that we don't + * pass any unintended bits to scsi_init_pkt(9F) (ugly hack). + */ +#define SD_XB_DMA_FREED 0x20000000 +#define SD_XB_USCSICMD 0x40000000 +#define SD_XB_INITPKT_MASK (PKT_CONSISTENT | PKT_DMA_PARTIAL) + +/* + * Extension for the buf(9s) struct that we receive from a higher + * layer. Located by b_private in the buf(9S). (The previous contents + * of b_private are saved & restored before calling biodone(9F).) + */ +struct sd_xbuf { + + struct sd_lun *xb_un; /* Ptr to associated sd_lun */ + struct scsi_pkt *xb_pktp; /* Ptr to associated scsi_pkt */ + + /* + * xb_pktinfo points to any optional data that may be needed + * by the initpkt and/or destroypkt functions. Typical + * use might be to point to a struct uscsi_cmd. + */ + void *xb_pktinfo; + + /* + * Layer-private data area. This may be used by any layer to store + * layer-specific data on a per-IO basis. Typical usage is for an + * iostart routine to save some info here for later use by its + * partner iodone routine. This area may be used to hold data or + * a pointer to a data block that is allocated/freed by the layer's + * iostart/iodone routines. Allocation & management policy for the + * layer-private area is defined & implemented by each specific + * layer as required. + * + * IMPORTANT: Since a higher layer may depend on the value in the + * xb_private field, each layer must ensure that it returns the + * buf/xbuf to the next higher layer (via SD_NEXT_IODONE()) with + * the SAME VALUE in xb_private as when the buf/xbuf was first + * received by the layer's iostart routine. Typically this is done + * by the iostart routine saving the contents of xb_private into + * a place in the layer-private data area, and the iodone routine + * restoring the value of xb_private before deallocating the + * layer-private data block and calling SD_NEXT_IODONE(). Of course, + * if a layer never modifies xb_private in a buf/xbuf from a higher + * layer, there will be no need to restore the value. + * + * Note that in the case where a layer _creates_ a buf/xbuf (such as + * by calling sd_shadow_buf_alloc()) to pass to a lower layer, it is + * not necessary to preserve the contents of xb_private as there is + * no higher layer dependency on the value of xb_private. Such a + * buf/xbuf must be deallocated by the layer that allocated it and + * must *NEVER* be passed up to a higher layer. + */ + void *xb_private; /* Layer-private data block */ + + /* + * We do not use the b_blkno provided in the buf(9S), as we need to + * make adjustments to it in the driver, but it is not a field that + * the driver owns or is free to modify. + */ + daddr_t xb_blkno; /* Absolute block # on target */ + uint64_t xb_ena; /* ena for a specific SCSI command */ + + int xb_chain_iostart; /* iostart side index */ + int xb_chain_iodone; /* iodone side index */ + int xb_pkt_flags; /* Flags for scsi_init_pkt() */ + ssize_t xb_dma_resid; + short xb_retry_count; + short xb_victim_retry_count; + short xb_ua_retry_count; /* unit_attention retry counter */ + short xb_nr_retry_count; /* not ready retry counter */ + + /* + * Various status and data used when a RQS command is run on + * the behalf of this command. + */ + struct buf *xb_sense_bp; /* back ptr to buf, for RQS */ + uint_t xb_sense_state; /* scsi_pkt state of RQS command */ + ssize_t xb_sense_resid; /* residual of RQS command */ + uchar_t xb_sense_status; /* scsi status byte of RQS command */ + uchar_t xb_sense_data[SENSE_LENGTH]; /* sense data from RQS cmd */ + /* + * Extra sense larger than SENSE_LENGTH will be allocated + * right after xb_sense_data[SENSE_LENGTH]. Please do not + * add any new field after it. + */ +}; + +_NOTE(SCHEME_PROTECTS_DATA("unique per pkt", sd_xbuf)) + +#define SD_PKT_ALLOC_SUCCESS 0 +#define SD_PKT_ALLOC_FAILURE 1 +#define SD_PKT_ALLOC_FAILURE_NO_DMA 2 +#define SD_PKT_ALLOC_FAILURE_PKT_TOO_SMALL 3 +#define SD_PKT_ALLOC_FAILURE_CDB_TOO_SMALL 4 + +#define SD_GET_XBUF(bp) ((struct sd_xbuf *)((bp)->b_private)) +#define SD_GET_UN(bp) ((SD_GET_XBUF(bp))->xb_un) +#define SD_GET_PKTP(bp) ((SD_GET_XBUF(bp))->xb_pktp) +#define SD_GET_BLKNO(bp) ((SD_GET_XBUF(bp))->xb_blkno) + +/* + * Special-purpose struct for sd_send_scsi_cmd() to pass command-specific + * data through the layering chains to sd_initpkt_for_uscsi(). + */ +struct sd_uscsi_info { + int ui_flags; + struct uscsi_cmd *ui_cmdp; + /* + * ui_dkc is used by sd_send_scsi_SYNCHRONIZE_CACHE() to allow + * for async completion notification. + */ + struct dk_callback ui_dkc; + /* + * The following fields are to be used for FMA ereport generation. + */ + uchar_t ui_pkt_reason; + uint32_t ui_pkt_state; + uint32_t ui_pkt_statistics; + uint64_t ui_lba; + uint64_t ui_ena; +}; + +_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_uscsi_info)) + +/* + * This structure is used to issue 'internal' command sequences from the + * driver's attach(9E)/open(9E)/etc entry points. It provides a common context + * for issuing command sequences, with the ability to issue a command + * and provide expected/unexpected assessment of results at any code + * level within the sd_ssc_t scope and preserve the information needed + * produce telemetry for the problem, when needed, from a single + * outer-most-scope point. + * + * The sd_ssc_t abstraction should result in well-structured code where + * the basic code structure is not jeprodized by future localized improvement. + * + * o Scope for a sequence of commands. + * o Within a scoped sequence of commands, provides a single top-level + * location for initiating telementry generation from captured data. + * o Provide a common place to capture command execution data and driver + * assessment information for delivery to telemetry generation point. + * o Mechanism to get device-as-detector (dad) and transport telemetry + * information from interrupt context (sdintr) back to the internal + * command 'driver-assessment' code. + * o Ability to record assessment, and return information back to + * top-level telemetry generation code when an unexpected condition + * occurs. + * o For code paths were an command itself was successful but + * the data returned looks suspect, the ability to record + * 'unexpected data' conditions. + * o Record assessment of issuing the command and interpreting + * the returned data for consumption by top-level ereport telemetry + * generation code. + * o All data required to produce telemetry available off single data + * structure. + */ +typedef struct { + struct sd_lun *ssc_un; + struct uscsi_cmd *ssc_uscsi_cmd; + struct sd_uscsi_info *ssc_uscsi_info; + int ssc_flags; /* Bits for flags */ + char ssc_info[1024]; /* Buffer holding for info */ +} sd_ssc_t; + +_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_ssc_t)) + +/* + * This struct switch different 'type-of-assessment' + * as an input argument for sd_ssc_assessment + * + * + * in sd_send_scsi_XXX or upper-level + * + * - SD_FMT_IGNORE + * when send uscsi command failed, and + * the following code check sense data properly. + * we use 'ignore' to let sd_ssc_assessment + * trust current and do not do additional + * checking for the uscsi command. + * + * - SD_FMT_IGNORE_COMPROMISE + * when send uscsi command failed, and + * the code does not check sense data or we don't + * think the checking is 100% coverage. We mark it + * as 'compromise' to indicate that we need to + * enhance current code in the future. + * + * - SD_FMT_STATUS_CHECK + * when send uscsi command failed and cause sd entries + * failed finally, we need to send out real reason against + * status of uscsi command no matter if there is sense back + * or not. + * + * - SD_FMT_STANDARD + * when send uscsi command succeeded, and + * the code does not check sense data, we need to check + * it to make sure there is no 'fault'. + */ +enum sd_type_assessment { + SD_FMT_IGNORE = 0, + SD_FMT_IGNORE_COMPROMISE, + SD_FMT_STATUS_CHECK, + SD_FMT_STANDARD +}; + +/* + * The following declaration are used as hints of severities when posting + * SCSI FMA ereport. + * - SD_FM_DRV_FATAL + * When posting ereport with SD_FM_DRV_FATAL, the payload + * "driver-assessment" will be "fail" or "fatal" depending on the + * sense-key value. If driver-assessment is "fail", it will be + * propagated to an upset, otherwise, a fault will be propagated. + * - SD_FM_DRV_RETRY + * When posting ereport with SD_FM_DRV_RETRY, the payload + * "driver-assessment" will be "retry", and it will be propagated to an + * upset. + * - SD_FM_DRV_RECOVERY + * When posting ereport with SD_FM_DRV_RECOVERY, the payload + * "driver-assessment" will be "recovered", and it will be propagated to + * an upset. + * - SD_FM_DRV_NOTICE + * When posting ereport with SD_FM_DRV_NOTICE, the payload + * "driver-assessment" will be "info", and it will be propagated to an + * upset. + */ +enum sd_driver_assessment { + SD_FM_DRV_FATAL = 0, + SD_FM_DRV_RETRY, + SD_FM_DRV_RECOVERY, + SD_FM_DRV_NOTICE +}; + +/* + * The following structure is used as a buffer when posting SCSI FMA + * ereport for raw i/o. It will be allocated per sd_lun when entering + * sd_unit_attach and will be deallocated when entering sd_unit_detach. + */ +struct sd_fm_internal { + sd_ssc_t fm_ssc; + struct uscsi_cmd fm_ucmd; + struct sd_uscsi_info fm_uinfo; + int fm_log_level; +}; + +/* + * Bits in ssc_flags + * sd_ssc_init will mark ssc_flags = SSC_FLAGS_UNKNOWN + * sd_ssc_send will mark ssc_flags = SSC_FLAGS_CMD_ISSUED & + * SSC_FLAGS_NEED_ASSESSMENT + * sd_ssc_assessment will clear SSC_FLAGS_CMD_ISSUED and + * SSC_FLAGS_NEED_ASSESSMENT bits of ssc_flags. + * SSC_FLAGS_CMD_ISSUED is to indicate whether the SCSI command has been + * sent out. + * SSC_FLAGS_NEED_ASSESSMENT is to guarantee we will not miss any + * assessment point. + */ +#define SSC_FLAGS_UNKNOWN 0x00000000 +#define SSC_FLAGS_CMD_ISSUED 0x00000001 +#define SSC_FLAGS_NEED_ASSESSMENT 0x00000002 +#define SSC_FLAGS_TRAN_ABORT 0x00000004 + +/* + * The following bits in ssc_flags are for detecting unexpected data. + */ +#define SSC_FLAGS_INVALID_PKT_REASON 0x00000010 +#define SSC_FLAGS_INVALID_STATUS 0x00000020 +#define SSC_FLAGS_INVALID_SENSE 0x00000040 +#define SSC_FLAGS_INVALID_DATA 0x00000080 + +/* + * The following are the values available for sd_fm_internal::fm_log_level. + * SD_FM_LOG_NSUP The driver will log things in traditional way as if + * the SCSI FMA feature is unavailable. + * SD_FM_LOG_SILENT The driver will not print out syslog for FMA error + * telemetry, all the error telemetries will go into + * FMA error log. + * SD_FM_LOG_EREPORT The driver will both print the FMA error telemetry + * and post the error report, but the traditional + * syslog for error telemetry will be suppressed. + */ +#define SD_FM_LOG_NSUP 0 +#define SD_FM_LOG_SILENT 1 +#define SD_FM_LOG_EREPORT 2 + +/* + * Macros and definitions for driver kstats and errstats + * + * Some third-party layered drivers (they know who they are) do not maintain + * their open/close counts correctly which causes our kstat reporting to get + * messed up & results in panics. These macros will update the driver kstats + * only if the counts are valid. + */ +#define SD_UPDATE_COMMON_KSTATS(kstat_function, kstatp) \ + if ((kstat_function) == kstat_runq_exit || \ + ((kstat_function) == kstat_runq_back_to_waitq)) { \ + if (((kstat_io_t *)(kstatp))->rcnt) { \ + kstat_function((kstatp)); \ + } else { \ + cmn_err(CE_WARN, \ + "kstat rcnt == 0 when exiting runq, please check\n"); \ + } \ + } else if ((kstat_function) == kstat_waitq_exit || \ + ((kstat_function) == kstat_waitq_to_runq)) { \ + if (((kstat_io_t *)(kstatp))->wcnt) { \ + kstat_function(kstatp); \ + } else { \ + cmn_err(CE_WARN, \ + "kstat wcnt == 0 when exiting waitq, please check\n"); \ + } \ + } else { \ + kstat_function(kstatp); \ + } + +#define SD_UPDATE_KSTATS(un, kstat_function, bp) \ + ASSERT(SD_GET_XBUF(bp) != NULL); \ + if (SD_IS_BUFIO(SD_GET_XBUF(bp))) { \ + struct kstat *pksp = \ + (un)->un_pstats[SDPART((bp)->b_edev)]; \ + ASSERT(mutex_owned(SD_MUTEX(un))); \ + if ((un)->un_stats != NULL) { \ + kstat_io_t *kip = KSTAT_IO_PTR((un)->un_stats); \ + SD_UPDATE_COMMON_KSTATS(kstat_function, kip); \ + } \ + if (pksp != NULL) { \ + kstat_io_t *kip = KSTAT_IO_PTR(pksp); \ + SD_UPDATE_COMMON_KSTATS(kstat_function, kip); \ + } \ + } + +#define SD_UPDATE_ERRSTATS(un, x) \ + if ((un)->un_errstats != NULL) { \ + struct sd_errstats *stp; \ + ASSERT(mutex_owned(SD_MUTEX(un))); \ + stp = (struct sd_errstats *)(un)->un_errstats->ks_data; \ + stp->x.value.ui32++; \ + } + +#define SD_UPDATE_RDWR_STATS(un, bp) \ + if ((un)->un_stats != NULL) { \ + kstat_io_t *kip = KSTAT_IO_PTR((un)->un_stats); \ + size_t n_done = (bp)->b_bcount - (bp)->b_resid; \ + if ((bp)->b_flags & B_READ) { \ + kip->reads++; \ + kip->nread += n_done; \ + } else { \ + kip->writes++; \ + kip->nwritten += n_done; \ + } \ + } + +#define SD_UPDATE_PARTITION_STATS(un, bp) \ +{ \ + struct kstat *pksp = (un)->un_pstats[SDPART((bp)->b_edev)]; \ + if (pksp != NULL) { \ + kstat_io_t *kip = KSTAT_IO_PTR(pksp); \ + size_t n_done = (bp)->b_bcount - (bp)->b_resid; \ + if ((bp)->b_flags & B_READ) { \ + kip->reads++; \ + kip->nread += n_done; \ + } else { \ + kip->writes++; \ + kip->nwritten += n_done; \ + } \ + } \ +} + + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + + +/* + * 60 seconds is a *very* reasonable amount of time for most slow CD + * operations. + */ +#define SD_IO_TIME 60 + +/* + * 2 hours is an excessively reasonable amount of time for format operations. + */ +#define SD_FMT_TIME (120 * 60) + +/* + * 5 seconds is what we'll wait if we get a Busy Status back + */ +#define SD_BSY_TIMEOUT (drv_usectohz(5 * 1000000)) + +/* + * 100 msec. is what we'll wait if we get Unit Attention. + */ +#define SD_UA_RETRY_DELAY (drv_usectohz((clock_t)100000)) + +/* + * 100 msec. is what we'll wait for restarted commands. + */ +#define SD_RESTART_TIMEOUT (drv_usectohz((clock_t)100000)) + +/* + * 10s misaligned I/O warning message interval + */ +#define SD_RMW_MSG_PRINT_TIMEOUT (drv_usectohz((clock_t)10000000)) + +/* + * 0 msec. is what we'll wait for certain retries. + */ +#define SD_RETRY_DELAY ((clock_t)0) + +/* + * Number of times we'll retry a normal operation. + * + * This includes retries due to transport failure + * (need to distinguish between Target and Transport failure) + * + */ +#define SD_RETRY_COUNT 5 + +/* + * Number of times we will retry for unit attention. + */ +#define SD_UA_RETRY_COUNT 600 + +#define SD_VICTIM_RETRY_COUNT(un) (un->un_victim_retry_count) +#define CD_NOT_READY_RETRY_COUNT(un) (un->un_retry_count * 2) +#define DISK_NOT_READY_RETRY_COUNT(un) (un->un_retry_count / 2) + + +/* + * Maximum number of units we can support + * (controlled by room in minor device byte) + * + * Note: this value is out of date. + */ +#define SD_MAXUNIT 32 + +/* + * 30 seconds is what we will wait for the IO to finish + * before we fail the DDI_SUSPEND + */ +#define SD_WAIT_CMDS_COMPLETE 30 + +/* + * Prevent/allow media removal flags + */ +#define SD_REMOVAL_ALLOW 0 +#define SD_REMOVAL_PREVENT 1 + + +/* + * Drive Types (and characteristics) + */ +#define VIDMAX 8 +#define PIDMAX 16 + + +/* + * The following #defines and type definitions for the property + * processing component of the sd driver. + */ + + +/* Miscellaneous Definitions */ +#define SD_CONF_VERSION_1 1 +#define SD_CONF_NOT_USED 32 + +/* + * "pm-capable" property values and macros + */ +#define SD_PM_CAPABLE_UNDEFINED -1 + +#define SD_PM_CAPABLE_IS_UNDEFINED(pm_cap) \ + (pm_cap == SD_PM_CAPABLE_UNDEFINED) + +#define SD_PM_CAPABLE_IS_FALSE(pm_cap) \ + ((pm_cap & PM_CAPABLE_PM_MASK) == 0) + +#define SD_PM_CAPABLE_IS_TRUE(pm_cap) \ + (!SD_PM_CAPABLE_IS_UNDEFINED(pm_cap) && \ + ((pm_cap & PM_CAPABLE_PM_MASK) > 0)) + +#define SD_PM_CAPABLE_IS_SPC_4(pm_cap) \ + ((pm_cap & PM_CAPABLE_PM_MASK) == PM_CAPABLE_SPC4) + +#define SD_PM_CAPABLE_IS_GE_SPC_4(pm_cap) \ + (((pm_cap & PM_CAPABLE_PM_MASK) == PM_CAPABLE_SPC4) || \ + ((pm_cap & PM_CAPABLE_PM_MASK) == PM_CAPABLE_SPC5)) + +#define SD_PM_CAP_LOG_SUPPORTED(pm_cap) \ + ((pm_cap & PM_CAPABLE_LOG_SUPPORTED) ? TRUE : FALSE) + +#define SD_PM_CAP_SMART_LOG(pm_cap) \ + ((pm_cap & PM_CAPABLE_SMART_LOG) ? TRUE : FALSE) + +/* + * Property data values used in static configuration table + * These are all based on device characteristics. + * For fibre channel devices, the throttle value is usually + * derived from the devices cmd Q depth divided by the number + * of supported initiators. + */ +#define ELITE_THROTTLE_VALUE 10 +#define SEAGATE_THROTTLE_VALUE 15 +#define IBM_THROTTLE_VALUE 15 +#define ST31200N_THROTTLE_VALUE 8 +#define FUJITSU_THROTTLE_VALUE 15 +#define SYMBIOS_THROTTLE_VALUE 16 +#define SYMBIOS_NOTREADY_RETRIES 24 +#define LSI_THROTTLE_VALUE 16 +#define LSI_NOTREADY_RETRIES 24 +#define LSI_OEM_NOTREADY_RETRIES 36 +#define PURPLE_THROTTLE_VALUE 64 +#define PURPLE_BUSY_RETRIES 60 +#define PURPLE_RESET_RETRY_COUNT 36 +#define PURPLE_RESERVE_RELEASE_TIME 60 +#define SVE_BUSY_RETRIES 60 +#define SVE_RESET_RETRY_COUNT 36 +#define SVE_RESERVE_RELEASE_TIME 60 +#define SVE_THROTTLE_VALUE 10 +#define SVE_MIN_THROTTLE_VALUE 2 +#define SVE_DISKSORT_DISABLED_FLAG 1 +#define MASERATI_DISKSORT_DISABLED_FLAG 1 +#define MASERATI_LUN_RESET_ENABLED_FLAG 1 +#define PIRUS_THROTTLE_VALUE 64 +#define PIRUS_NRR_COUNT 60 +#define PIRUS_BUSY_RETRIES 60 +#define PIRUS_RESET_RETRY_COUNT 36 +#define PIRUS_MIN_THROTTLE_VALUE 16 +#define PIRUS_DISKSORT_DISABLED_FLAG 0 +#define PIRUS_LUN_RESET_ENABLED_FLAG 1 + +/* + * Driver Property Bit Flag definitions + * + * Unfortunately, for historical reasons, the bit-flag definitions are + * different on SPARC, INTEL, & FIBRE platforms. + */ + +/* + * Bit flag telling driver to set throttle from sd.conf sd-config-list + * and driver table. + * + * The max throttle (q-depth) property implementation is for support of + * fibre channel devices that can drop an i/o request when a queue fills + * up. The number of commands sent to the disk from this driver is + * regulated such that queue overflows are avoided. + */ +#define SD_CONF_SET_THROTTLE 0 +#define SD_CONF_BSET_THROTTLE (1 << SD_CONF_SET_THROTTLE) + +/* + * Bit flag telling driver to set the controller type from sd.conf + * sd-config-list and driver table. + */ +#define SD_CONF_SET_CTYPE 1 +#define SD_CONF_BSET_CTYPE (1 << SD_CONF_SET_CTYPE) + +/* + * Bit flag telling driver to set the not ready retry count for a device from + * sd.conf sd-config-list and driver table. + */ +#define SD_CONF_SET_NOTREADY_RETRIES 10 +#define SD_CONF_BSET_NRR_COUNT (1 << SD_CONF_SET_NOTREADY_RETRIES) + +/* + * Bit flag telling driver to set SCSI status BUSY Retries from sd.conf + * sd-config-list and driver table. + */ +#define SD_CONF_SET_BUSY_RETRIES 11 +#define SD_CONF_BSET_BSY_RETRY_COUNT (1 << SD_CONF_SET_BUSY_RETRIES) + +/* + * Bit flag telling driver that device does not have a valid/unique serial + * number. + */ +#define SD_CONF_SET_FAB_DEVID 2 +#define SD_CONF_BSET_FAB_DEVID (1 << SD_CONF_SET_FAB_DEVID) + +/* + * Bit flag telling driver to disable all caching for disk device. + */ +#define SD_CONF_SET_NOCACHE 3 +#define SD_CONF_BSET_NOCACHE (1 << SD_CONF_SET_NOCACHE) + +/* + * Bit flag telling driver that the PLAY AUDIO command requires parms in BCD + * format rather than binary. + */ +#define SD_CONF_SET_PLAYMSF_BCD 4 +#define SD_CONF_BSET_PLAYMSF_BCD (1 << SD_CONF_SET_PLAYMSF_BCD) + +/* + * Bit flag telling driver that the response from the READ SUBCHANNEL command + * has BCD fields rather than binary. + */ +#define SD_CONF_SET_READSUB_BCD 5 +#define SD_CONF_BSET_READSUB_BCD (1 << SD_CONF_SET_READSUB_BCD) + +/* + * Bit in flags telling driver that the track number fields in the READ TOC + * request and respone are in BCD rather than binary. + */ +#define SD_CONF_SET_READ_TOC_TRK_BCD 6 +#define SD_CONF_BSET_READ_TOC_TRK_BCD (1 << SD_CONF_SET_READ_TOC_TRK_BCD) + +/* + * Bit flag telling driver that the address fields in the READ TOC request and + * respone are in BCD rather than binary. + */ +#define SD_CONF_SET_READ_TOC_ADDR_BCD 7 +#define SD_CONF_BSET_READ_TOC_ADDR_BCD (1 << SD_CONF_SET_READ_TOC_ADDR_BCD) + +/* + * Bit flag telling the driver that the device doesn't support the READ HEADER + * command. + */ +#define SD_CONF_SET_NO_READ_HEADER 8 +#define SD_CONF_BSET_NO_READ_HEADER (1 << SD_CONF_SET_NO_READ_HEADER) + +/* + * Bit flag telling the driver that for the READ CD command the device uses + * opcode 0xd4 rather than 0xbe. + */ +#define SD_CONF_SET_READ_CD_XD4 9 +#define SD_CONF_BSET_READ_CD_XD4 (1 << SD_CONF_SET_READ_CD_XD4) + +/* + * Bit flag telling the driver to set SCSI status Reset Retries + * (un_reset_retry_count) from sd.conf sd-config-list and driver table (4356701) + */ +#define SD_CONF_SET_RST_RETRIES 12 +#define SD_CONF_BSET_RST_RETRIES (1 << SD_CONF_SET_RST_RETRIES) + +/* + * Bit flag telling the driver to set the reservation release timeout value + * from sd.conf sd-config-list and driver table. (4367306) + */ +#define SD_CONF_SET_RSV_REL_TIME 13 +#define SD_CONF_BSET_RSV_REL_TIME (1 << SD_CONF_SET_RSV_REL_TIME) + +/* + * Bit flag telling the driver to verify that no commands are pending for a + * device before issuing a Test Unit Ready. This is a fw workaround for Seagate + * eliteI drives. (4392016) + */ +#define SD_CONF_SET_TUR_CHECK 14 +#define SD_CONF_BSET_TUR_CHECK (1 << SD_CONF_SET_TUR_CHECK) + +/* + * Bit in flags telling driver to set min. throttle from ssd.conf + * ssd-config-list and driver table. + */ +#define SD_CONF_SET_MIN_THROTTLE 15 +#define SD_CONF_BSET_MIN_THROTTLE (1 << SD_CONF_SET_MIN_THROTTLE) + +/* + * Bit in flags telling driver to set disksort disable flag from ssd.conf + * ssd-config-list and driver table. + */ +#define SD_CONF_SET_DISKSORT_DISABLED 16 +#define SD_CONF_BSET_DISKSORT_DISABLED (1 << SD_CONF_SET_DISKSORT_DISABLED) + +/* + * Bit in flags telling driver to set LUN Reset enable flag from [s]sd.conf + * [s]sd-config-list and driver table. + */ +#define SD_CONF_SET_LUN_RESET_ENABLED 17 +#define SD_CONF_BSET_LUN_RESET_ENABLED (1 << SD_CONF_SET_LUN_RESET_ENABLED) + +/* + * Bit in flags telling driver that the write cache on the device is + * non-volatile. + */ +#define SD_CONF_SET_CACHE_IS_NV 18 +#define SD_CONF_BSET_CACHE_IS_NV (1 << SD_CONF_SET_CACHE_IS_NV) + +/* + * Bit in flags telling driver that the power condition flag from [s]sd.conf + * [s]sd-config-list and driver table. + */ +#define SD_CONF_SET_PC_DISABLED 19 +#define SD_CONF_BSET_PC_DISABLED (1 << SD_CONF_SET_PC_DISABLED) + +/* + * This is the number of items currently settable in the sd.conf + * sd-config-list. The mask value is defined for parameter checking. The + * item count and mask should be updated when new properties are added. + */ +#define SD_CONF_MAX_ITEMS 19 +#define SD_CONF_BIT_MASK 0x0007FFFF + +typedef struct { + int sdt_throttle; + int sdt_ctype; + int sdt_not_rdy_retries; + int sdt_busy_retries; + int sdt_reset_retries; + int sdt_reserv_rel_time; + int sdt_min_throttle; + int sdt_disk_sort_dis; + int sdt_lun_reset_enable; + int sdt_suppress_cache_flush; + int sdt_power_condition_dis; +} sd_tunables; + +/* Type definition for static configuration table entries */ +typedef struct sd_disk_config { + char device_id[25]; + uint_t flags; + sd_tunables *properties; +} sd_disk_config_t; + +/* + * first 2 bits of byte 4 options for 1bh command + */ +#define SD_TARGET_STOP 0x00 +#define SD_TARGET_START 0x01 +#define SD_TARGET_EJECT 0x02 +#define SD_TARGET_CLOSE 0x03 + +/* + * power condition of byte 4 for 1bh command + */ +#define SD_TARGET_START_VALID 0x00 +#define SD_TARGET_ACTIVE 0x01 +#define SD_TARGET_IDLE 0x02 +#define SD_TARGET_STANDBY 0x03 + + +#define SD_MODE_SENSE_PAGE3_CODE 0x03 +#define SD_MODE_SENSE_PAGE4_CODE 0x04 + +#define SD_MODE_SENSE_PAGE3_LENGTH \ + (sizeof (struct mode_format) + MODE_PARAM_LENGTH) +#define SD_MODE_SENSE_PAGE4_LENGTH \ + (sizeof (struct mode_geometry) + MODE_PARAM_LENGTH) + +/* + * These command codes need to be moved to sys/scsi/generic/commands.h + */ + +/* Both versions of the Read CD command */ + +/* the official SCMD_READ_CD now comes from cdio.h */ +#define SCMD_READ_CDD4 0xd4 /* the one used by some first */ + /* generation ATAPI CD drives */ + +/* expected sector type filter values for Play and Read CD CDBs */ +#define CDROM_SECTOR_TYPE_CDDA (1<<2) /* IEC 908:1987 (CDDA) */ +#define CDROM_SECTOR_TYPE_MODE1 (2<<2) /* Yellow book 2048 bytes */ +#define CDROM_SECTOR_TYPE_MODE2 (3<<2) /* Yellow book 2335 bytes */ +#define CDROM_SECTOR_TYPE_MODE2_FORM1 (4<<2) /* 2048 bytes */ +#define CDROM_SECTOR_TYPE_MODE2_FORM2 (5<<2) /* 2324 bytes */ + +/* READ CD filter bits (cdb[9]) */ +#define CDROM_READ_CD_SYNC 0x80 /* read sync field */ +#define CDROM_READ_CD_HDR 0x20 /* read four byte header */ +#define CDROM_READ_CD_SUBHDR 0x40 /* read sub-header */ +#define CDROM_READ_CD_ALLHDRS 0x60 /* read header and sub-header */ +#define CDROM_READ_CD_USERDATA 0x10 /* read user data */ +#define CDROM_READ_CD_EDC_ECC 0x08 /* read EDC and ECC field */ +#define CDROM_READ_CD_C2 0x02 /* read C2 error data */ +#define CDROM_READ_CD_C2_BEB 0x04 /* read C2 and Block Error Bits */ + + +/* + * These belong in sys/scsi/generic/mode.h + */ + +/* + * Mode Sense/Select Header response for Group 2 CDB. + */ + +struct mode_header_grp2 { + uchar_t length_msb; /* MSB - number of bytes following */ + uchar_t length_lsb; + uchar_t medium_type; /* device specific */ + uchar_t device_specific; /* device specfic parameters */ + uchar_t resv[2]; /* reserved */ + uchar_t bdesc_length_hi; /* length of block descriptor(s) */ + /* (if any) */ + uchar_t bdesc_length_lo; +}; + +_NOTE(SCHEME_PROTECTS_DATA("Unshared data", mode_header_grp2)) + +/* + * Length of the Mode Parameter Header for the Group 2 Mode Select command + */ +#define MODE_HEADER_LENGTH_GRP2 (sizeof (struct mode_header_grp2)) +#define MODE_PARAM_LENGTH_GRP2 (MODE_HEADER_LENGTH_GRP2 + MODE_BLK_DESC_LENGTH) + +/* + * Mode Page 1 - Error Recovery Page + */ +#define MODEPAGE_ERR_RECOVER 1 + +/* + * The following buffer length define is 8 bytes for the Group 2 mode page + * header, 8 bytes for the block descriptor and 26 bytes for the cdrom + * capabilities page (per MMC-2) + */ +#define MODEPAGE_CDROM_CAP 0x2A +#define MODEPAGE_CDROM_CAP_LEN 26 +#define BUFLEN_MODE_CDROM_CAP (MODEPAGE_CDROM_CAP_LEN + \ + MODE_HEADER_LENGTH_GRP2 + MODE_BLK_DESC_LENGTH) + + +/* + * Power management defines + */ +#define SD_SPINDLE_UNINIT (-1) +#define SD_SPINDLE_OFF 0 +#define SD_SPINDLE_ON 1 +#define SD_SPINDLE_STOPPED 0 +#define SD_SPINDLE_STANDBY 1 +#define SD_SPINDLE_IDLE 2 +#define SD_SPINDLE_ACTIVE 3 +#define SD_PM_NOT_SUPPORTED 4 + +/* + * Power method flag + */ +#define SD_START_STOP 0 +#define SD_POWER_CONDITION 1 + + +/* + * Number of power level for start stop or power condition + */ +#define SD_PM_NUM_LEVEL_SSU_SS 2 +#define SD_PM_NUM_LEVEL_SSU_PC 4 + +/* + * SD internal power state change flag + */ +#define SD_PM_STATE_CHANGE 0 +#define SD_PM_STATE_ROLLBACK 1 + +/* + * Power attribute table + */ +typedef struct disk_power_attr_ss { + char *pm_comp[SD_PM_NUM_LEVEL_SSU_SS + 2]; /* pm component */ + int ran_perf[SD_PM_NUM_LEVEL_SSU_SS]; /* random performance */ + int pwr_saving[SD_PM_NUM_LEVEL_SSU_SS]; /* power saving */ + int latency[SD_PM_NUM_LEVEL_SSU_SS]; /* latency */ +}sd_power_attr_ss; + +typedef struct disk_power_attr_pc { + char *pm_comp[SD_PM_NUM_LEVEL_SSU_PC + 2]; /* pm component */ + int ran_perf[SD_PM_NUM_LEVEL_SSU_PC]; /* random performance */ + int pwr_saving[SD_PM_NUM_LEVEL_SSU_PC]; /* power saving */ + int latency[SD_PM_NUM_LEVEL_SSU_PC]; /* latency */ +}sd_power_attr_pc; + + +/* + * No Need to resume if already in PM_SUSPEND state because the thread + * was suspended in sdpower. It will be resumed when sdpower is invoked to make + * the device active. + * When the thread is suspended, the watch thread is terminated and + * the token is NULLed so check for this condition. + * If there's a thread that can be resumed, ie. token is not NULL, then + * it can be resumed. + */ +#define SD_OK_TO_RESUME_SCSI_WATCHER(un) (un->un_swr_token != NULL) +/* + * No Need to resume if already in PM_SUSPEND state because the thread + * was suspended in sdpower. It will be resumed when sdpower is invoked to make + * the device active. + * When the thread is suspended, the watch thread is terminated and + * the token is NULLed so check for this condition. + */ +#define SD_OK_TO_SUSPEND_SCSI_WATCHER(un) (un->un_swr_token != NULL) +#define SD_DEVICE_IS_IN_LOW_POWER(un) ((un->un_f_pm_is_enabled) && \ + (un->un_pm_count < 0)) +#define SD_PM_STATE_ACTIVE(un) \ + (un->un_f_power_condition_supported ? \ + SD_SPINDLE_ACTIVE : SD_SPINDLE_ON) +#define SD_PM_STATE_STOPPED(un) \ + (un->un_f_power_condition_supported ? \ + SD_SPINDLE_STOPPED : SD_SPINDLE_OFF) +#define SD_PM_IS_LEVEL_VALID(un, level) \ + ((un->un_f_power_condition_supported && \ + level >= SD_SPINDLE_STOPPED && \ + level <= SD_SPINDLE_ACTIVE) || \ + (!un->un_f_power_condition_supported && \ + level >= SD_SPINDLE_OFF && \ + level <= SD_SPINDLE_ON)) +#define SD_PM_IS_IO_CAPABLE(un, level) \ + ((un->un_f_power_condition_supported && \ + sd_pwr_pc.ran_perf[level] > 0) || \ + (!un->un_f_power_condition_supported && \ + sd_pwr_ss.ran_perf[level] > 0)) +#define SD_PM_STOP_MOTOR_NEEDED(un, level) \ + ((un->un_f_power_condition_supported && \ + level <= SD_SPINDLE_STANDBY) || \ + (!un->un_f_power_condition_supported && \ + level == SD_SPINDLE_OFF)) + +/* + * Could move this define to some thing like log sense.h in SCSA headers + * But for now let it live here. + */ +#define START_STOP_CYCLE_COUNTER_PAGE_SIZE 0x28 +#define START_STOP_CYCLE_PAGE 0x0E +#define START_STOP_CYCLE_VU_PAGE 0x31 + +/* CD-ROM Error Recovery Parameters page (0x01) */ +#define MODEPAGE_ERR_RECOV 0x1 +#define BUFLEN_CHG_BLK_MODE MODE_HEADER_LENGTH + MODE_BLK_DESC_LENGTH + +/* + * Vendor Specific (Toshiba) CD-ROM Speed page (0x31) + * + * The following buffer length define is 4 bytes for the Group 0 mode page + * header, 8 bytes for the block descriptor and 4 bytes for the mode speed page. + */ +#define MODEPAGE_CDROM_SPEED_LEN 4 +#define BUFLEN_MODE_CDROM_SPEED MODEPAGE_CDROM_SPEED_LEN +\ + MODE_HEADER_LENGTH +\ + MODE_BLK_DESC_LENGTH +#define SD_SPEED_1X 176 + +/* CD-ROM Audio Control Parameters page (0x0E) */ +#define MODEPAGE_AUDIO_CTRL 0x0E +#define MODEPAGE_AUDIO_CTRL_LEN 16 + +/* CD-ROM Sony Read Offset Defines */ +#define SONY_SESSION_OFFSET_LEN 12 +#define SONY_SESSION_OFFSET_KEY 0x40 +#define SONY_SESSION_OFFSET_VALID 0x0a + +/* + * CD-ROM Write Protect Defines + * + * Bit 7 of the device specific field of the mode page header is the write + * protect bit. + */ +#define WRITE_PROTECT 0x80 + +/* + * Define for the length of a profile header returned in response to the + * GET CONFIGURATION command + */ +#define SD_PROFILE_HEADER_LEN 8 /* bytes */ + +/* + * Define the length of the data in response to the GET CONFIGURATION + * command. The 3rd byte of the feature descriptor contains the + * current feature field that is of interest. This field begins + * after the feature header which is 8 bytes. This variable length + * was increased in size from 11 to 24 because some devices became + * unresponsive with the smaller size. + */ +#define SD_CURRENT_FEATURE_LEN 24 /* bytes */ + +/* + * Feature codes associated with GET CONFIGURATION command for supported + * devices. + */ +#define RANDOM_WRITABLE 0x20 +#define HARDWARE_DEFECT_MANAGEMENT 0x24 + +/* + * Could move this define to some thing like log sense.h in SCSA headers + * But for now let it live here. + */ +#define TEMPERATURE_PAGE 0x0D +#define TEMPERATURE_PAGE_SIZE 16 /* bytes */ + +/* delay time used for sd_media_watch_cb delayed cv broadcast */ +#define MEDIA_ACCESS_DELAY 2000000 + + +/* SCSI power on or bus device reset additional sense code */ +#define SD_SCSI_RESET_SENSE_CODE 0x29 + +/* + * These defines are for the Vital Product Data Pages in the inquiry command. + * They are the bits in the un_vpd_page mask, telling the supported pages. + */ +#define SD_VPD_SUPPORTED_PG 0x01 /* 0x00 - Supported VPD pages */ +#define SD_VPD_UNIT_SERIAL_PG 0x02 /* 0x80 - Unit Serial Number */ +#define SD_VPD_OPERATING_PG 0x04 /* 0x81 - Implemented Op Defs */ +#define SD_VPD_ASCII_OP_PG 0x08 /* 0x82 - ASCII Op Defs */ +#define SD_VPD_DEVID_WWN_PG 0x10 /* 0x83 - Device Identification */ +#define SD_VPD_EXTENDED_DATA_PG 0x80 /* 0x86 - Extended data about the lun */ +#define SD_VPD_BLK_LIMITS_PG 0x400 /* 0xB0 - Block Limits */ +#define SD_VPD_DEV_CHARACTER_PG 0x800 /* 0xB1 - Device Characteristics */ + +/* + * Non-volatile cache support + * + * Bit 1 of the byte 6 in the Extended INQUIRY data VPD page + * is NV_SUP bit: An NV_SUP bit set to one indicates that + * the device server supports a non-volatile cache. An + * NV_SUP bit set to zero indicates that the device + * server may or may not support a non-volatile cache. + * + * Bit 2 of the byte 1 in the SYNC CACHE command is SYNC_NV + * bit: The SYNC_NV bit specifies whether the device server + * is required to synchronize volatile and non-volatile + * caches. + */ +#define SD_VPD_NV_SUP 0x02 +#define SD_SYNC_NV_BIT 0x04 + +/* + * Addition from sddef.intel.h + */ +#if defined(__i386) || defined(__amd64) + +#define P0_RAW_DISK (NDKMAP) +#define FDISK_P1 (NDKMAP+1) +#define FDISK_P2 (NDKMAP+2) +#define FDISK_P3 (NDKMAP+3) +#define FDISK_P4 (NDKMAP+4) + +#endif /* __i386 || __amd64 */ + +#ifdef __cplusplus +} +#endif + + +#endif /* _SYS_SCSI_TARGETS_SDDEF_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/targets/ses.h b/illumos-x86_64/usr/include/sys/scsi/targets/ses.h new file mode 100644 index 00000000..ed94b6ec --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/targets/ses.h @@ -0,0 +1,332 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Enclosure Services Device target driver + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2020 RackTop Systems, Inc. + */ + +#ifndef _SYS_SCSI_TARGETS_SES_H +#define _SYS_SCSI_TARGETS_SES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Useful defines and typedefs + */ +#define EOK 0 + +#define INVOP 0x10 + +#define BP_PKT(bp) ((struct scsi_pkt *)(bp)->av_back) +#define SET_BP_PKT(bp, s) (bp)->av_back = (struct buf *)(s) + +#define SCBP(pkt) ((struct scsi_status *)(pkt)->pkt_scbp) +#define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & STATUS_MASK) +#define Scsidevp struct scsi_device * +#define Scsipktp struct scsi_pkt * +#define Uscmd struct uscsi_cmd + +#define SES_SCSI_DEVP (un->ses_scsi_devp) +#define SES_DEVP(softc) ((softc)->ses_devp) +#define SES_DEVINFO(softc) (SES_DEVP(softc)->sd_dev) +#define SES_RQSENSE(softc) (SES_DEVP(softc)->sd_sense) +#define SES_ROUTE(softc) (&SES_DEVP(softc)->sd_address) +#define SES_MUTEX (&ssc->ses_devp->sd_mutex) + +#define ISOPEN(softc) ((softc)->ses_lyropen || (softc)->ses_oflag) +#define UNUSED_PARAMETER(x) x = x + + +/* + * SAF-TE specific defines- Mandatory ones only... + */ + +/* + * READ BUFFER ('get' commands) IDs- placed in offset 2 of cdb + */ +#define SAFTE_RD_RDCFG 0x00 /* read enclosure configuration */ +#define SAFTE_RD_RDESTS 0x01 /* read enclosure status */ +#define SAFTE_RD_RDDSTS 0x04 /* read drive slot status */ + +/* + * WRITE BUFFER ('set' commands) IDs- placed in offset 0 of databuf + */ +#define SAFTE_WT_DSTAT 0x10 /* write device slot status */ +#define SAFTE_WT_SLTOP 0x12 /* perform slot operation */ +#define SAFTE_WT_FANSPD 0x13 /* set fan speed */ +#define SAFTE_WT_ACTPWS 0x14 /* turn on/off power supply */ +#define SAFTE_WT_GLOBAL 0x15 /* send global command */ + + +/* + * Includes + */ +#include + + +/* + * Private info (Device Info. Private) + * + * Pointed to by the un_private pointer + * of one of the SCSI_DEVICE structures. + */ +typedef struct ses_softc ses_softc_t; + +typedef struct { + int (*softc_init)(ses_softc_t *, int); + int (*init_enc)(ses_softc_t *); + int (*get_encstat)(ses_softc_t *, int); + int (*set_encstat)(ses_softc_t *, uchar_t, int); + int (*get_objstat)(ses_softc_t *, ses_objarg *, int); + int (*set_objstat)(ses_softc_t *, ses_objarg *, int); +} encvec; + +typedef enum { SES_TYPE, SAFT_TYPE, SEN_TYPE } enctyp; + +typedef struct { + uchar_t enctype; /* enclosure type */ + uchar_t subenclosure; /* subenclosure id */ + ushort_t svalid : 1, /* enclosure information valid */ + priv : 15; /* private data, per object */ + uchar_t encstat[4]; /* state && stats */ +} encobj; + + +/* + * Overall Status is bits 0..3- status validity reserved at bit 7 + */ +#define ENCI_SVALID 0x80 + +struct ses_softc { + enctyp ses_type; /* type of enclosure */ + encvec ses_vec; /* vector to handlers */ + uint_t ses_nobjects; /* number of objects */ + void * ses_private; /* private data */ + encobj * ses_objmap; /* objects */ + uchar_t ses_encstat; /* overall status */ + Scsidevp ses_devp; /* backpointer to owning SCSI device */ + struct buf *ses_rqbp; /* request sense buf pointer */ + Scsipktp ses_rqpkt; /* SCSI Request Sense Packet */ + struct buf *ses_sbufp; /* for use in internal io */ + timeout_id_t ses_restart_id; /* restart timeout id */ + kcondvar_t ses_sbufcv; /* cv on sbuf */ + uchar_t ses_sbufbsy; /* sbuf busy flag */ + uchar_t ses_oflag; /* nonzero if opened (nonlayered) */ + uchar_t ses_present; /* device present */ + uchar_t ses_suspended; /* nonzero if suspended */ + uchar_t ses_arq; /* auto request sense enabled */ + uint_t ses_lyropen; /* layered open count */ + int ses_retries; /* retry count */ + ddi_devid_t ses_dev_id; /* device id */ + /* + * Associated storage for the special buf. + * Since we're single threaded on sbuf anyway, + * we might as well save ourselves a pile of + * grief and allocate local uscsicmd and + * ancillary storage here. + */ + Uscmd ses_uscsicmd; + uchar_t ses_srqcdb[CDB_SIZE]; + uchar_t ses_srqsbuf[MAX_SENSE_LENGTH]; +}; + +#ifndef __lint /* no warlock for X86 */ +#ifdef _KERNEL +_NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, ses_softc)) +_NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, ses_softc::ses_lyropen)) + +_NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_arq_status)) +_NOTE(SCHEME_PROTECTS_DATA("not shared", ses_softc::ses_restart_id)) +_NOTE(SCHEME_PROTECTS_DATA("not shared", ses_softc::ses_retries)) +_NOTE(SCHEME_PROTECTS_DATA("not shared", ses_softc::ses_present)) +_NOTE(SCHEME_PROTECTS_DATA("not shared", ses_softc::ses_suspended)) +_NOTE(SCHEME_PROTECTS_DATA("stable data", + ses_softc::ses_type + ses_softc::ses_vec + ses_softc::ses_nobjects + ses_softc::ses_devp + ses_softc::ses_arq)) + +_NOTE(SCHEME_PROTECTS_DATA("sbufp cv", + ses_softc::ses_sbufp + ses_softc::ses_rqpkt + ses_softc::ses_rqbp + ses_softc::ses_sbufbsy + ses_softc::ses_uscsicmd + ses_softc::ses_srqcdb + ses_softc::ses_srqsbuf + ses_softc::ses_uscsicmd)) + +_NOTE(SCHEME_PROTECTS_DATA("unique per pkt", scsi_pkt buf uio scsi_cdb)) +_NOTE(SCHEME_PROTECTS_DATA("unique per pkt", scsi_extended_sense scsi_status)) +_NOTE(SCHEME_PROTECTS_DATA("unique per pkt", uscsi_cmd)) +_NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_device)) + +_NOTE(DATA_READABLE_WITHOUT_LOCK(ses_softc::ses_encstat)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ses_softc::ses_objmap)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ses_softc::ses_private)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ses_softc::ses_lyropen)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(ses_softc::ses_oflag)) + +_NOTE(SCHEME_PROTECTS_DATA("absurdities", ses_objarg)) +#endif /* _KERNEL */ +#endif /* __lint */ + + +/* + * Compile options to turn on debugging code + */ +#ifdef DEBUG +#define SES_DEBUG +#endif /* DEBUG */ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#define SES_CE_DEBUG ((1 << 8) | CE_CONT) +#define SES_CE_DEBUG1 ((2 << 8) | CE_CONT) +#define SES_CE_DEBUG2 ((3 << 8) | CE_CONT) +#define SES_CE_DEBUG3 ((4 << 8) | CE_CONT) +#define SES_CE_DEBUG4 ((5 << 8) | CE_CONT) +#define SES_CE_DEBUG5 ((6 << 8) | CE_CONT) +#define SES_CE_DEBUG6 ((7 << 8) | CE_CONT) +#define SES_CE_DEBUG7 ((8 << 8) | CE_CONT) +#define SES_CE_DEBUG8 ((9 << 8) | CE_CONT) +#define SES_CE_DEBUG9 ((10 << 8) | CE_CONT) + +#ifndef SES_DEBUG +#define ses_debug 0 +#endif /* SES_DEBUG */ + +#define SES_LOG if (ses_debug) ses_log +#define SES_DEBUG_ENTER if (ses_debug) debug_enter + + +/* + * Various I/O timeouts. + * + * These are hard-coded and not adjustable. The restart macro + * time input is in milliseconds with 1 msec. the minimum setting. + * + */ +#define SES_IO_TIME 60 /* standard I/O time (sec.) */ +#define SES_RESTART_TIME 100 /* I/O restart time (ms.) */ +#define SES_BUSY_TIME 500 /* I/O busy restart time (ms.) */ + +#define SES_ENABLE_RESTART(ms_time, pkt) { \ + ssc->ses_restart_id = timeout(ses_restart, (void *) pkt, \ + (ms_time)? (drv_usectohz(ms_time * 1000)) : \ + drv_usectohz(1000)); \ +} + + +/* + * Number of times we'll retry a normal operation. + * + * Note, retries have differnt weights to max retries. + * Unit Attention and request sense have the most retries. + * Command retries have the least. + * + * For no auto-request sense operation, the SES_RETRY_MULTIPLIER + * must be greater than the command RETRY_COUNT. Then the request + * sense commands won't impact the command retries. + */ +#define SES_RETRY_COUNT 4 +#define SES_RETRY_MULTIPLIER 8 + +#define SES_CMD_RETRY SES_RETRY_MULTIPLIER +#define SES_NO_RETRY 0 +#define SES_SENSE_RETRY 1 +#define SES_BUSY_RETRY 4 + +/* Retry weight is 1 */ +#define SES_CMD_RETRY1(retry) \ + retry += (retry > 0)? (SES_RETRY_MULTIPLIER -1) : 0; + +/* Retry weight is 2 */ +#define SES_CMD_RETRY2(retry) \ + retry += (retry > 0)? (SES_RETRY_MULTIPLIER -2) : 0; + +/* Retry weight is 4 */ +#define SES_CMD_RETRY4(retry) \ + retry += (retry > 0)? (SES_RETRY_MULTIPLIER -4) : 0; + + +/* + * ses_present definitions + */ +#define SES_CLOSED 0 +#define SES_OPENING 1 +#define SES_OPEN 2 + + +/* + * ses_callback action codes + */ +#define COMMAND_DONE 0 +#define COMMAND_DONE_ERROR 1 +#define QUE_COMMAND_NOW 3 +#define QUE_COMMAND 4 +#define QUE_SENSE 5 + + +/* + * PF bit for RECEIVE DIAG command; + * needed for RSM first release hw. + */ +#define SCSI_ESI_PF 0x10 +#define SEN_ID "UNISYS SUN_SEN" +#define SEN_ID_LEN 24 + +#define SET_BP_ERROR(bp, err) bioerror(bp, err); + +/* + * Common Driver Functions + */ +#if defined(_KERNEL) +extern void ses_log(ses_softc_t *, int, const char *, ...); +extern int ses_runcmd(ses_softc_t *, Uscmd *); +extern int ses_uscsi_cmd(ses_softc_t *, Uscmd *, int); +extern int ses_io_time; + +#ifdef DEBUG +extern int ses_debug; +#endif /* DEBUG */ + +#endif /* defined(_KERNEL) */ + + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_TARGETS_SES_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/targets/sesio.h b/illumos-x86_64/usr/include/sys/scsi/targets/sesio.h new file mode 100644 index 00000000..d063b096 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/targets/sesio.h @@ -0,0 +1,156 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SESIO_H +#define _SYS_SESIO_H + +/* + * Enclosure Services Interface Structures + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Data Structures and definitions for SES Applications + */ + +typedef struct { + unsigned int obj_id; /* Object Identifier */ + unsigned int : 16, /* reserved */ + subencid : 8, /* SubEnclosure ID */ + elem_type : 8; /* Element Type */ +} ses_object; + +/* Known Enclosure Types */ +#define SESTYP_UNSPECIFIED 0x00 +#define SESTYP_DEVICE 0x01 +#define SESTYP_POWER 0x02 +#define SESTYP_FAN 0x03 +#define SESTYP_THERM 0x04 +#define SESTYP_DOORLOCK 0x05 +#define SESTYP_ALARM 0x06 +#define SESTYP_ESCC 0x07 /* Enclosure SCC */ +#define SESTYP_SCC 0x08 /* SCC */ +#define SESTYP_NVRAM 0x09 +#define SESTYP_UPS 0x0b +#define SESTYP_DISPLAY 0x0c +#define SESTYP_KEYPAD 0x0d +#define SESTYP_SCSIXVR 0x0f +#define SESTYP_LANGUAGE 0x10 +#define SESTYP_COMPORT 0x11 +#define SESTYP_VOM 0x12 +#define SESTYP_AMMETER 0x13 +#define SESTYP_SCSI_TGT 0x14 +#define SESTYP_SCSI_INI 0x15 +#define SESTYP_SUBENC 0x16 +#define SESTYP_ARRAY 0x17 /* SES2r19 #7.1 */ +#define SESTYP_SASEXPANDER 0x18 /* SES2r19 #7.1 */ +#define SESTYP_SASCONNECTOR 0x19 /* SES2r19 #7.1 */ + + +/* + * Overall Enclosure Status + */ +#define ENCSTAT_UNRECOV 0x1 +#define ENCSTAT_CRITICAL 0x2 +#define ENCSTAT_NONCRITICAL 0x4 +#define ENCSTAT_INFO 0x8 + +typedef struct { + uint_t obj_id; + uchar_t cstat[4]; +} ses_objarg; + +/* Summary SES Status Defines, Common Status Codes */ +#define SESSTAT_UNSUPPORTED 0 +#define SESSTAT_OK 1 +#define SESSTAT_CRIT 2 +#define SESSTAT_NONCRIT 3 +#define SESSTAT_UNRECOV 4 +#define SESSTAT_NOTINSTALLED 5 +#define SESSTAT_UNKNOWN 6 +#define SESSTAT_NOTAVAIL 7 + +/* + * For control pages, cstat[0] is the same for the + * enclosure and is common across all device types. + * + * If SESCTL_CSEL is set, then PRDFAIL, DISABLE and RSTSWAP + * are checked, otherwise bits that are specific to the device + * type in the other 3 bytes of cstat or checked. + */ +#define SESCTL_CSEL 0x80 +#define SESCTL_PRDFAIL 0x40 +#define SESCTL_DISABLE 0x20 +#define SESCTL_RSTSWAP 0x10 + + +/* Control bits, Device Elements, byte 2 */ +#define SESCTL_DRVLCK 0x40 /* "DO NOT REMOVE" */ +#define SESCTL_RQSINS 0x08 /* RQST INSERT */ +#define SESCTL_RQSRMV 0x04 /* RQST REMOVE */ +#define SESCTL_RQSID 0x02 /* RQST IDENT */ +/* Control bits, Device Elements, byte 3 */ +#define SESCTL_RQSFLT 0x20 /* RQST FAULT */ +#define SESCTL_DEVOFF 0x10 /* DEVICE OFF */ + +/* Control bits, Generic, byte 3 */ +#define SESCTL_RQSTFAIL 0x40 +#define SESCTL_RQSTON 0x20 + + +/* + * SES Driver ioctls + */ +#define SESIOC ('e'<<8) +#define SESIOC_IOCTL_GETSTATE (SESIOC|1) /* get esi status */ +#define SESIOC_IOCTL_SETSTATE (SESIOC|2) /* set esi state */ +#define SESIOC_IOCTL_INQUIRY (SESIOC|3) /* get SCSI Inquiry info */ +#define SESIOC_GETNOBJ (SESIOC|10) +#define SESIOC_GETOBJMAP (SESIOC|11) +#define SESIOC_INIT (SESIOC|12) +#define SESIOC_GETENCSTAT (SESIOC|13) +#define SESIOC_SETENCSTAT (SESIOC|14) +#define SESIOC_GETOBJSTAT (SESIOC|15) +#define SESIOC_SETOBJSTAT (SESIOC|16) + +/* + * The following structure is used by the SES_IOCTL_GETSTATE + * and the SES_IOCTL_SETSTATE ioctls + */ +struct ses_ioctl { + uint32_t page_size; /* Size of page to be read/written */ + uint8_t page_code; /* Page to be read/written */ + caddr_t page; /* Address of page to be read/written */ +}; + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SESIO_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/targets/sgendef.h b/illumos-x86_64/usr/include/sys/scsi/targets/sgendef.h new file mode 100644 index 00000000..00a3602e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/targets/sgendef.h @@ -0,0 +1,176 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright Siemens 1999 + * All rights reserved. + */ + +#ifndef _SYS_SCSI_TARGETS_SGENDEF_H +#define _SYS_SCSI_TARGETS_SGENDEF_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SGEN_IOC (('S' << 16) | ('G' << 8)) +#define SGEN_IOC_READY (SGEN_IOC | 0x01) +#define SGEN_IOC_DIAG (SGEN_IOC | 0x02) + +#if defined(_KERNEL) + +#define SGEN_DIAG1 ((1 << 8) | CE_CONT) +#define SGEN_DIAG2 ((2 << 8) | CE_CONT) +#define SGEN_DIAG3 ((3 << 8) | CE_CONT) + +struct sgen_errstats { + kstat_named_t sgen_trans_err; /* error trying to transport pkt */ + kstat_named_t sgen_restart; /* command restart attempted */ + kstat_named_t sgen_incmp_err; /* command failed to complete */ + kstat_named_t sgen_autosen_rcv; /* autosense occurred */ + kstat_named_t sgen_autosen_bad; /* autosense data looks malformed */ + kstat_named_t sgen_sense_rcv; /* sense fetch occurred */ + kstat_named_t sgen_sense_bad; /* sense data looks malformed */ + kstat_named_t sgen_recov_err; /* sense key is KEY_RECOVERABLE */ + kstat_named_t sgen_nosen_err; /* sense key is KEY_NO_SENSE */ + kstat_named_t sgen_unrecov_err; /* sense key indicates other err */ +}; + +typedef struct sgen_state { + struct scsi_device *sgen_scsidev; /* pointer to scsi_device */ + struct uscsi_cmd *sgen_ucmd; /* uscsi command struct */ + struct buf *sgen_cmdbuf; /* xfer buffer */ + struct scsi_pkt *sgen_cmdpkt; /* scsi packet for command */ + kcondvar_t sgen_cmdbuf_cv; /* cv for cmdbuf */ + int sgen_flags; /* see SGEN_FL_* */ + struct scsi_pkt *sgen_rqspkt; /* request sense packet */ + struct buf *sgen_rqsbuf; /* request sense xfer buffer */ + char *sgen_rqs_sen; /* sense buffer */ + int sgen_arq_enabled; /* auto request sense enabled */ + int sgen_diag; /* diagnostic output level */ + timeout_id_t sgen_restart_timeid; /* timeout for sgen_restart */ + kstat_t *sgen_kstats; /* for error statistics */ +} sgen_state_t; + +/* + * Convenience accessors for sgen_state_t. + */ +#define sgen_mutex sgen_scsidev->sd_mutex +#define sgen_devinfo sgen_scsidev->sd_dev +#define sgen_scsiaddr sgen_scsidev->sd_address +#define sgen_sense sgen_scsidev->sd_sense + +/* + * sgen_flags accessors/mutators + */ +#define SGEN_FL_OPEN 0x01 /* instance is open */ +#define SGEN_FL_SUSP 0x02 /* instance suspended */ +#define SGEN_FL_BUSY 0x04 /* command buffer busy */ +#define SGEN_FL_EXCL 0x08 /* exclusive open */ + +#define SGEN_SET_OPEN(stp) \ + (((sgen_state_t *)(stp))->sgen_flags |= SGEN_FL_OPEN) +#define SGEN_CLR_OPEN(stp) \ + (((sgen_state_t *)(stp))->sgen_flags &= ~SGEN_FL_OPEN) +#define SGEN_IS_OPEN(stp) \ + ((((sgen_state_t *)(stp))->sgen_flags & SGEN_FL_OPEN) == SGEN_FL_OPEN) + +#define SGEN_SET_SUSP(stp) \ + (((sgen_state_t *)(stp))->sgen_flags |= SGEN_FL_SUSP) +#define SGEN_CLR_SUSP(stp) \ + (((sgen_state_t *)(stp))->sgen_flags &= ~SGEN_FL_SUSP) +#define SGEN_IS_SUSP(stp) \ + ((((sgen_state_t *)(stp))->sgen_flags & SGEN_FL_SUSP) == SGEN_FL_SUSP) + +#define SGEN_SET_BUSY(stp) \ + (((sgen_state_t *)(stp))->sgen_flags |= SGEN_FL_BUSY) +#define SGEN_CLR_BUSY(stp) \ + (((sgen_state_t *)(stp))->sgen_flags &= ~SGEN_FL_BUSY) +#define SGEN_IS_BUSY(stp) \ + ((((sgen_state_t *)(stp))->sgen_flags & SGEN_FL_BUSY) == SGEN_FL_BUSY) + +#define SGEN_SET_EXCL(stp) \ + (((sgen_state_t *)(stp))->sgen_flags |= SGEN_FL_EXCL) +#define SGEN_CLR_EXCL(stp) \ + (((sgen_state_t *)(stp))->sgen_flags &= ~SGEN_FL_EXCL) +#define SGEN_IS_EXCL(stp) \ + ((((sgen_state_t *)(stp))->sgen_flags & SGEN_FL_EXCL) == SGEN_FL_EXCL) + +/* + * These structures form the driver's database of binding information. + * Inquiry strings and device types from the inquiry-config-list and + * device-type-config-list properties are stored. + */ +typedef struct sgen_inq_node { + char *node_vendor; /* up to 8 character vendor */ + char *node_product; /* up to 16 character product */ + struct sgen_inq_node *node_next; +} sgen_inq_node_t; + +typedef struct sgen_type_node { + uchar_t node_type; /* SCSI device type */ + struct sgen_type_node *node_next; +} sgen_type_node_t; + +struct sgen_binddb { + int sdb_init; /* has this been initialized? */ + kmutex_t sdb_lock; /* protects this structure */ + sgen_inq_node_t *sdb_inq_nodes; /* inquiry binding nodes */ + sgen_type_node_t *sdb_type_nodes; /* dev-type binding nodes */ +}; + +#define SGEN_ESTIMATED_NUM_DEVS 4 /* for soft-state allocation */ + +/* + * Time to wait before a retry for commands returning Busy Status + */ +#define SGEN_BSY_TIMEOUT (drv_usectohz(5 * 1000000)) +#define SGEN_IO_TIME 60 /* seconds */ + +/* + * sgen_callback action codes + */ +#define COMMAND_DONE 0 /* command completed, biodone it */ +#define COMMAND_DONE_ERROR 1 /* command completed, indicate error */ +#define FETCH_SENSE 2 /* CHECK CONDITION, so initiate sense */ + /* fetch */ + +#define SET_BP_ERROR(bp, err) bioerror(bp, err); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_TARGETS_SGENDEF_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/targets/smp.h b/illumos-x86_64/usr/include/sys/scsi/targets/smp.h new file mode 100644 index 00000000..3087e150 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/targets/smp.h @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_TARGETS_SMP_H +#define _SYS_SCSI_TARGETS_SMP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) + +/* + * smp_open_flag: field indicating open smp instance. + * 0 = closed, 1 = shared open, 2 = exclusive open. + */ +#define SMP_CLOSED 0 +#define SMP_SOPENED 1 +#define SMP_EXOPENED 2 + +typedef struct smp_state { + struct smp_device *smp_sd; /* pointer to smp_device */ + kmutex_t smp_mutex; /* mutex */ + uint32_t smp_open_flag; /* open flag */ + kcondvar_t smp_cv; /* condition variable */ + uint32_t smp_busy; /* busy */ +} smp_state_t; + +#define SMP_ESTIMATED_NUM_DEVS 4 /* for soft-state allocation */ +#define SMP_DEFAULT_RETRY_TIMES 5 + +#define SMP_FLAG_REQBUF 0x1 +#define SMP_FLAG_RSPBUF 0x2 +#define SMP_FLAG_XFER 0x4 + +#endif /* defined(_KERNEL) */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_TARGETS_SMP_H */ diff --git a/illumos-x86_64/usr/include/sys/scsi/targets/stdef.h b/illumos-x86_64/usr/include/sys/scsi/targets/stdef.h new file mode 100644 index 00000000..0fccd8b4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/scsi/targets/stdef.h @@ -0,0 +1,1631 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SCSI_TARGETS_STDEF_H +#define _SYS_SCSI_TARGETS_STDEF_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Defines for SCSI tape drives. + */ + +/* + * Maximum variable length record size for a single request + */ +#define ST_MAXRECSIZE_VARIABLE 65535 + +/* + * If the requested record size exceeds ST_MAXRECSIZE_VARIABLE, + * then the following define is used. + */ +#define ST_MAXRECSIZE_VARIABLE_LIMIT 65534 + +#define ST_MAXRECSIZE_FIXED (63<<10) /* maximum fixed record size */ +#define INF 1000000000 /* old external count backwards from this from EOF */ +#define LASTBLK (-1) /* new internal count backwards from EOF */ + +/* + * Supported tape device types plus default type for opening. + * Types 10 - 13, are special (ancient too) drives - *NOT SUPPORTED* + * Types 14 - 1f, are 1/4-inch cartridge drives. + * Types 20 - 28, are 1/2-inch cartridge or reel drives. + * Types 28+, are rdat (vcr) drives. + */ +#define ST_TYPE_INVALID 0x00 + +#define ST_TYPE_SYSGEN1 MT_ISSYSGEN11 /* Sysgen with QIC-11 only */ +#define ST_TYPE_SYSGEN MT_ISSYSGEN /* Sysgen with QIC-24 and QIC-11 */ + +#define ST_TYPE_DEFAULT MT_ISDEFAULT /* Generic 1/4" or undetermined */ +#define ST_TYPE_EMULEX MT_ISMT02 /* Emulex MT-02 */ +#define ST_TYPE_ARCHIVE MT_ISVIPER1 /* Archive QIC-150 */ +#define ST_TYPE_WANGTEK MT_ISWANGTEK1 /* Wangtek QIC-150 */ + +#define ST_TYPE_CDC MT_ISCDC /* CDC - (not tested) */ +#define ST_TYPE_FUJI MT_ISFUJI /* Fujitsu - (not tested) */ +#define ST_TYPE_KENNEDY MT_ISKENNEDY /* Kennedy */ +#define ST_TYPE_ANRITSU MT_ISANRITSU /* Anritsu */ +#define ST_TYPE_HP MT_ISHP /* HP */ +#define ST_TYPE_HIC MT_ISCCS23 /* Generic 1/2" Cartridge */ +#define ST_TYPE_REEL MT_ISCCS24 /* Generic 1/2" Reel Tape */ +#define ST_TYPE_DAT MT_ISCCS28 /* Generic DAT Tape */ + +#define ST_TYPE_EXABYTE MT_ISEXABYTE /* Exabyte 8200 */ +#define ST_TYPE_EXB8500 MT_ISEXB8500 /* Exabyte 8500 */ +#define ST_TYPE_WANGTHS MT_ISWANGTHS /* Wangtek 6130HS */ +#define ST_TYPE_WANGDAT MT_ISWANGDAT /* WangDAT */ +#define ST_TYPE_PYTHON MT_ISPYTHON /* Archive Python DAT */ +#define ST_TYPE_STC3490 MT_ISSTC /* IBM STC 3490 */ +#define ST_TYPE_TAND25G MT_ISTAND25G /* TANDBERG 2.5G */ +#define ST_TYPE_DLT MT_ISDLT /* DLT */ +#define ST_TYPE_STK9840 MT_ISSTK9840 /* StorageTek 9840, 9940, 9840B */ +#define ST_TYPE_BMDLT1 MT_ISBMDLT1 /* Benchmark DTL1 */ +#define ST_TYPE_LTO MT_LTO /* sun: LTO's by HP, Seagate, IBM.. */ +#define ST_TYPE_AIT MT_ISAIT /* Sony AIT I, II, III and SAIT */ +#define ST_LAST_TYPE ST_TYPE_AIT /* Add new above type and change this */ + + +/* Internal flags */ +#define ST_DYNAMIC 0x2000 /* Device name has been dynamically */ + /* alloc'ed from the st.conf entry, */ + /* instead of being used from the */ + /* st_drivetypes array. */ + +/* + * Defines for supported drive options + * + * WARNING : THESE OPTIONS SHOULD NEVER BE CHANGED, AS OLDER CONFIGURATIONS + * WILL DEPEND ON THE FLAG VALUES REMAINING THE SAME + */ +#define ST_VARIABLE 0x001 /* Device supports variable */ + /* length record sizes */ +#define ST_QIC 0x002 /* QIC tape device */ +#define ST_REEL 0x004 /* 1/2-inch reel tape device */ +#define ST_BSF 0x008 /* Device supports backspace */ + /* file as in mt(1) bsf : */ + /* backspace over EOF marks. */ + /* Devices not supporting bsf */ + /* will fail with ENOTTY upon */ + /* use of bsf */ +#define ST_BSR 0x010 /* Device supports backspace */ + /* record as in mt(1) bsr : */ + /* backspace over records. If */ + /* the device does not support */ + /* bsr, the st driver emulates */ + /* the action by rewinding the */ + /* tape and using forward space */ + /* file (fsf) to the correct */ + /* file and then uses forward */ + /* space record (fsr) to the */ + /* correct record */ +#define ST_LONG_ERASE 0x020 /* Device needs a longer time */ + /* than normal to erase */ +#define ST_AUTODEN_OVERRIDE 0x040 /* Auto-Density override flag */ + /* Device can figure out the */ + /* tape density automatically, */ + /* without issuing a */ + /* mode-select/mode-sense */ +#define ST_NOBUF 0x080 /* Don't use buffered mode. */ + /* This disables the device's */ + /* ability for buffered writes */ + /* I.e. The device acknowledges */ + /* write completion after the */ + /* data is written to the */ + /* device's buffer, but before */ + /* all the data is actually */ + /* written to tape */ +#define ST_RESERVED_BIT1 0x100 /* reserved bit */ + /* parity while talking to it. */ +#define ST_KNOWS_EOD 0x200 /* Device knows when EOD (End */ + /* of Data) has been reached. */ + /* If the device knows EOD, st */ + /* uses fast file skipping. */ + /* If it does not know EOD, */ + /* file skipping happens one */ + /* file at a time. */ +#define ST_UNLOADABLE 0x400 /* Device will not complain if */ + /* the st driver is unloaded & */ + /* loaded again; e.g. will */ + /* return the correct inquiry */ + /* string */ +#define ST_SOFT_ERROR_REPORTING 0x800 /* Do request or log sense on */ + /* close to report soft errors. */ + /* Currently only Exabyte and */ + /* DAT drives support this */ + /* feature. */ +#define ST_LONG_TIMEOUTS 0x1000 /* Device needs 5 times longer */ + /* timeouts for normal */ + /* operation */ +#define ST_BUFFERED_WRITES 0x4000 /* The data is buffered in the */ + /* driver and pre-acked to the */ + /* application */ +#define ST_NO_RECSIZE_LIMIT 0x8000 /* For variable record size */ + /* devices only. If flag is */ + /* set, then don't limit */ + /* record size to 64k as in */ + /* pre-Solaris 2.4 releases. */ + /* The only limit on the */ + /* record size will be the max */ + /* record size the device can */ + /* handle or the max DMA */ + /* transfer size of the */ + /* machine, which ever is */ + /* smaller. Beware of */ + /* incompatabilities with */ + /* tapes of pre-Solaris 2.4 */ + /* OS's written with large */ + /* (>64k) block sizes, as */ + /* their true block size is */ + /* a max of approx 64k */ +#define ST_MODE_SEL_COMP 0x10000 /* use mode select of device */ + /* configuration page (0x10) to */ + /* enable/disable compression */ + /* instead of density codes for */ + /* the "c" and "u" devices */ +#define ST_NO_RESERVE_RELEASE 0x20000 /* For devices which do not */ + /* support RESERVE/RELEASE SCSI */ + /* command. If this is enabled */ + /* then reserve/release would */ + /* not be used during open/ */ + /* close for High Availability */ +#define ST_READ_IGNORE_ILI 0x40000 /* This flag is only applicable */ + /* to variable block devices */ + /* which support the SILI bit */ + /* option. It indicates that */ + /* the SILI bit will be ignored */ + /* during reads */ +#define ST_READ_IGNORE_EOFS 0x80000 /* When this flag is set two */ + /* EOF marks do not indicate an */ + /* EOM. This option is only */ + /* supported on 1/2" reel tapes */ +#define ST_SHORT_FILEMARKS 0x100000 /* This option applies only to */ + /* EXABYTE 8mm tape drives */ + /* which support short */ + /* filemarks. When this flag */ + /* is set, short filemarks */ + /* will be used for writing */ + /* filemarks. */ +#define ST_EJECT_ON_CHANGER_FAILURE 0x200000 /* When this flag is set */ + /* and the tape is trapped in */ + /* the medium changer, the tape */ + /* is automatically ejected */ +#define ST_RETRY_ON_RECOVERED_DEFERRED_ERROR 0x400000 + /* This option applies only to */ + /* IBM MAGSTAR 3590. If this */ + /* flag is set, the st driver */ + /* will retry the last cmd if */ + /* the last error cause a check */ + /* condition with error code */ + /* 0x71 and sense code 0x01 */ +#define ST_KNOWS_MEDIA 0x800000 /* Use configured media type */ + /* detected to select correct */ + /* density code. */ +#define ST_WORMABLE 0x1000000 + /* Drive is capable of doing */ + /* Write Appends only at EOM */ + /* if WORM media type is loaded */ +#define ST_CLN_TYPE_1 0x10000000 /* When this flag is set, */ + /* the tape drive provides the */ + /* clean bit information in */ + /* byte 21, bitmask 0x08 of */ + /* Request Sense data */ +#define ST_CLN_TYPE_2 0x20000000 /* When this flag is set, */ + /* the tape drive provides the */ + /* clean bit information in */ + /* byte 70, bitmask 0xc0 of */ + /* Request Sense data */ +#define ST_CLN_TYPE_3 0x40000000 /* When this flag is set, */ + /* the tape drive provides the */ + /* clean bit information in */ + /* byte 18, bitmask 0x01 of */ + /* Request Sense data */ + +#define ST_CLN_MASK (ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3) +#define ST_VALID_OPTS (ST_VARIABLE | ST_QIC | ST_REEL | ST_BSF | ST_BSR |\ + ST_LONG_ERASE | ST_AUTODEN_OVERRIDE | ST_NOBUF | ST_KNOWS_EOD |\ + ST_UNLOADABLE | ST_SOFT_ERROR_REPORTING | ST_LONG_TIMEOUTS |\ + ST_NO_RECSIZE_LIMIT | ST_MODE_SEL_COMP | ST_NO_RESERVE_RELEASE |\ + ST_READ_IGNORE_ILI | ST_READ_IGNORE_EOFS | ST_SHORT_FILEMARKS |\ + ST_EJECT_ON_CHANGER_FAILURE | ST_RETRY_ON_RECOVERED_DEFERRED_ERROR |\ + ST_WORMABLE | ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3) + +#define NDENSITIES MT_NDENSITIES +#define NSPEEDS MT_NSPEEDS + +/* + * defines for Log Sense Pages + */ +#define SUPPORTED_LOG_PAGES_PAGE 0x00 +#define TAPE_SEQUENTIAL_PAGE 0x0c +#define TAPE_ALERT_PAGE 0x2e + +/* + * Log Page Control definitions + */ +#define CURRENT_THRESHOLD_VALUES 0x00 +#define CURRENT_CUMULATIVE_VALUES 0x40 +#define DEFAULT_THRESHOLD_VALUES 0x80 +#define DEFAULT_CUMULATIVE_VALUES 0xC0 + +/* + * Tape Alert Flag definitions + */ +typedef enum { + TAF_READ_WARN = 0x01, + TAF_WRITE_WARN = 0x02, + TAF_HARD_ERR = 0x03, + TAF_MEDIA_ERR = 0x04, + TAF_READ_FAIL = 0x05, + TAF_WRITE_FAIL = 0x06, + TAF_MEDIA_LIFE = 0x07, + TAF_MEDIA_NOT_DATA_GRADE = 0x08, + TAF_WRITE_PROTECTED = 0x09, + TAF_NO_MEDIA_REMOVE = 0x0A, + TAF_CLEANING_MEDIA = 0x0B, + TAF_UNSUPPERTED_FORMAT = 0x0C, + TAF_RECOVERED_TAPE_BREAK = 0x0D, + TAF_TAPE_BREAK_FAUL = 0x0E, + TAF_CART_MEM_FAIL = 0x0F, + TAF_FORCED_EJECT = 0x10, + TAF_READ_ONLY_FORMAT = 0x11, + TAF_TAPE_DIR_CORRUPT = 0x12, + TAF_NEARING_MEDIA_LIFE = 0x13, + TAF_CLEAN_NOW = 0x14, + TAF_CLEAN_PERIODIC = 0x15, + TAF_EXP_CLEAN_CART = 0x16, + TAF_INVALID_CLEAN_MEDIA = 0x17, + TAF_RETENSION_REQUEST = 0x18, + TAF_DUAL_PORT_INTERFACE_ERR = 0x19, + TAF_COOLING_FAN_FAIL = 0x1A, + TAF_POWER_SUPPLY_FAIL = 0x1B, + TAF_POWER_CONSUMPTION = 0x1C, + TAF_DRIVE_MAINT_REQUEST = 0x1D, + TAF_HARDWARE_A = 0x1E, + TAF_HARDWARE_B = 0x1F, + TAF_INTERFACE = 0x20, + TAF_EJECT_MEDIA = 0x21, + TAF_DOWNLOAD_FAIL = 0x22, + TAF_DRIVE_HUMIDITY = 0x23, + TAF_DRIVE_TEMP = 0x24, + TAF_DRIVE_VOLTAGE = 0x25, + TAF_PREDICTIVE_FAIL = 0x26, + TAF_DIAG_REQUIRED = 0x27, + TAF_LOADER_HDWR_A = 0x28, + TAF_LOADER_STRAY_TAPE = 0x29, + TAF_LOADER_HDWR_B = 0x2A, + TAF_LOADER_DOOR = 0x2B, + TAF_LOADER_HDWR_C = 0x2C, + TAF_LOADER_MAGAZINE = 0x2D, + TAF_LOADER_PREDICTIVE_FAIL = 0x2E, + TAF_LOST_STATISTICS = 0x32, + TAF_TAPE_DIR_CURRUPT_UNLOAD = 0x33, + TAF_TAPE_SYS_WRT_FAIL = 0x34, + TAF_TAPE_SYS_RD_FAIL = 0x35, + TAF_NO_START_OF_DATA = 0x36, + TAF_WORM_INTEGRITY = 0x3B, + TAF_WORM_OVRWRT_ATTEMPT = 0x3C +}tape_alert_flags; + +/* + * For ST_TYPE_STK9840 drives only. STK drive doesn't support retension + * so they reuse TAF_RETENSION_REQUEST. + */ +#define CLEAN_FOR_ERRORS 0x18 + + +#define TAPE_ALERT_SUPPORT_UNKNOWN 0x00 +#define TAPE_ALERT_NOT_SUPPORTED 0x01 +#define TAPE_ALERT_SUPPORTED 0x02 +#define TAPE_ALERT_STILL_DIRTY 0x04 +#define TAPE_SEQUENTIAL_SUPPORTED 0x08 +#define TAPE_PREVIOUSLY_DIRTY 0x10 + +#define TAPE_ALERT_MAX_PARA 64 +#define TAPE_SEQUENTIAL_PAGE_PARA 64 /* way more then really used */ +#define SEQUENTIAL_NEED_CLN 0x0100 + +/* + * Parameters + */ +#define ST_NAMESIZE 44 /* size of pretty string for vid/pid */ +#define VIDLEN 8 /* size of vendor identifier length */ +#define PIDLEN 16 /* size of product identifier length */ +#define VIDPIDLEN (VIDLEN + PIDLEN) + + +struct st_drivetype { + char name[ST_NAMESIZE]; /* Name, for debug */ + char length; /* Length of vendor id */ + char vid[VIDPIDLEN]; /* Vendor id and model (product) id */ + char type; /* Drive type for driver */ + int bsize; /* Block size */ + int options; /* Drive options */ + int max_rretries; /* Max read retries */ + int max_wretries; /* Max write retries */ + uchar_t densities[NDENSITIES]; /* density codes, low->hi */ + uchar_t default_density; /* default density for this drive */ + uchar_t mediatype[NDENSITIES]; /* was speed. mediatype for density. */ + ushort_t non_motion_timeout; /* Inquiry type commands */ + ushort_t io_timeout; /* I/O timeout in seconds */ + ushort_t rewind_timeout; /* rewind timeout in seconds */ + ushort_t space_timeout; /* space cmd timeout in seconds */ + ushort_t load_timeout; /* load tape time in seconds */ + ushort_t unload_timeout; /* unload tape time in seconds */ + ushort_t erase_timeout; /* erase timeout. seconds */ +}; + +#define MINUTES(val) ((val) * 60) + +struct comp_mode_page { +#if defined(_BIT_FIELDS_LTOH) + uchar_t : 6, + dcc: 1, /* Data Compression Capable */ + dce: 1; /* Data Compression Enable */ + uchar_t : 5, + red: 2, /* Report Exceptions on Decompress */ + dde: 1; /* Data Decompression Enabled */ + uchar_t comp_alg_msb; /* Compression Algorithm */ + uchar_t comp_alg_high; + uchar_t comp_alg_low; + uchar_t comp_alg_lsb; + uchar_t decomp_alg_msb; /* Decompression Algorithm */ + uchar_t decomp_alg_high; + uchar_t decomp_alg_low; + uchar_t decomp_alg_lsb; + uchar_t reservered0; + uchar_t reservered1; + uchar_t reservered2; + uchar_t reservered3; + +#elif defined(_BIT_FIELDS_HTOL) + uchar_t dce: 1, /* Data Compression Enable */ + dcc: 1, /* Data Compression Capable */ + : 6; + uchar_t dde: 1, /* Data Decompression Enabled */ + red: 2, /* Report Exceptions on Decompress */ + : 5; + uchar_t comp_alg_msb; /* Compression Algorithm */ + uchar_t comp_alg_high; + uchar_t comp_alg_low; + uchar_t comp_alg_lsb; + uchar_t decomp_alg_msb; /* Decompression Algorithm */ + uchar_t decomp_alg_high; + uchar_t decomp_alg_low; + uchar_t decomp_alg_lsb; + uchar_t reservered0; + uchar_t reservered1; + uchar_t reservered2; + uchar_t reservered3; +#endif +}; + +struct dev_mode_page { +#if defined(_BIT_FIELDS_LTOH) + uchar_t act_format: 5, /* active format */ + caf: 1, /* Change Active Format */ + cap: 1, /* Change Active Partition OBSOLETE */ + : 1; + uchar_t act_partition; /* active partition */ + uchar_t wrt_buf_full_ratio; /* write buffer full ratio */ + uchar_t rd_buf_full_ratio; /* read buffer full ratio */ + uchar_t wrt_delay_time_msb; /* write delay time MSB */ + uchar_t wrt_delay_time_lsb; /* write delay time LSB */ + uchar_t rew: 1, /* Report Early Warning */ + robo: 1, /* Reverse Object Buffer Order */ + socf: 2, /* Stop On Consecutive Filemarks */ + avc: 1, /* Automatic Velocity Control */ + rsmk: 1, /* Report SetMarKs OBSOLETE */ + lois: 1, /* Logical Object Identifiers Support */ + obr: 1; /* Object Buffer Recovery */ + uchar_t gap_size; /* OBSOLETE */ + uchar_t bam: 1, /* Block Address Mode */ + bmal: 1, /* Block Address Mode Lock */ + swp: 1, /* Software Write Protection */ + sew: 1, /* Sync data after Early Warning */ + eeg: 1, /* Enable Early Waring */ + eod_defined: 3; + uchar_t buf_size_leot_msb; /* Buffer size after early warning */ + uchar_t buf_size_leot_mid; + uchar_t buf_size_leot_lsb; + uchar_t comp_alg; /* Compression Algorithm (enable) */ + uchar_t prmwp: 1, /* PeRManent Write Protect */ + perswp: 1, /* persistant write protection */ + asocwp: 1, /* associated write protect */ + rew_on_rst: 2, /* rewind on reset */ + oir: 1, /* Only If Reserved */ + wtre: 2; /* Worm Tamper Read Enable */ + +#elif defined(_BIT_FIELDS_HTOL) + uchar_t : 1, + cap: 1, /* Change Active Partition OBSOLETE */ + caf: 1, /* Change Active Format */ + act_format: 5; /* active format */ + uchar_t act_partition; /* active partition */ + uchar_t wrt_buf_full_ratio; /* write buffer full ratio */ + uchar_t rd_buf_full_ratio; /* read buffer full ratio */ + uchar_t wrt_delay_time_msb; /* write delay time MSB */ + uchar_t wrt_delay_time_lsb; /* write delay time LSB */ + uchar_t obr: 1, /* Object Buffer Recovery */ + lois: 1, /* Logical Object Identifiers Support */ + rsmk: 1, /* Report SetMarKs OBSOLETE */ + avc: 1, /* Automatic Velocity Control */ + socf: 2, /* Stop On Consecutive Filemarks */ + robo: 1, /* Reverse Object Buffer Order */ + rew: 1; /* Report Early Warning */ + uchar_t gap_size; /* OBSELETE */ + uchar_t eod_defined: 3, + eeg: 1, /* Enable Early Waring */ + sew: 1, /* Sync data after Early Warning */ + swp: 1, /* Software Write Protection */ + bmal: 1, /* Block Address Mode Lock */ + bam: 1; /* Block Address Mode */ + uchar_t buf_size_leot_msb; /* Buffer size after early warning */ + uchar_t buf_size_leot_mid; + uchar_t buf_size_leot_lsb; + uchar_t comp_alg; /* Compression Algorithm (enable) */ + uchar_t wtre: 2, /* Worm Tamper Read Enable */ + oir: 1, /* Only If Reserved */ + rew_on_rst: 2, /* rewind on reset */ + asocwp: 1, /* associated write protect */ + perswp: 1, /* persistant write protection */ + prmwp: 1; /* PeRManent Write Protect */ +#endif +}; + +struct sas_lun_mode { +#if defined(_BIT_FIELDS_HTOL) + uchar_t : 3, + tran_layer_ret: 1, + protocol_id: 4; + uchar_t reserved[5]; +#elif defined(_BIT_FIELDS_LTOH) + uchar_t protocol_id: 4, + tran_layer_ret: 1, + : 3; + uchar_t reserved[5]; +#endif +}; +typedef union { + struct comp_mode_page comp; + struct dev_mode_page dev; + struct sas_lun_mode saslun; +}modepage; + +/* + * + * Parameter list for the MODE_SELECT and MODE_SENSE commands. + * The parameter list contains a header, followed by zero or more + * block descriptors, followed by vendor unique parameters, if any. + * + */ +#define MSIZE 0x0c /* Size without additional pages */ +struct seq_mode { +#if defined(_BIT_FIELDS_LTOH) + uchar_t data_len; /* sense data length, sense only */ + uchar_t media_type; /* medium type, sense only */ + uchar_t speed :4, /* speed */ + bufm :3, /* buffered mode */ + wp :1; /* write protected, sense only */ + uchar_t bd_len; /* block length in bytes */ + uchar_t density; /* density code */ + uchar_t high_nb; /* number of logical blocks on the medium */ + uchar_t mid_nb; /* that are to be formatted with the density */ + uchar_t low_nb; /* code and block length in block descriptor */ + uchar_t reserved; /* reserved */ + uchar_t high_bl; /* block length */ + uchar_t mid_bl; /* " " */ + uchar_t low_bl; /* " " */ + uchar_t page_code: 6, + : 1, + ps: 1; /* Page Savable sense only */ + uchar_t page_len; + modepage page; + +#elif defined(_BIT_FIELDS_HTOL) + uchar_t data_len; /* sense data length, sense only */ + uchar_t media_type; /* medium type, sense only */ + uchar_t wp :1, /* write protected, sense only */ + bufm :3, /* buffered mode */ + speed :4; /* speed */ + uchar_t bd_len; /* block length in bytes */ + uchar_t density; /* density code */ + uchar_t high_nb; /* number of logical blocks on the medium */ + uchar_t mid_nb; /* that are to be formatted with the density */ + uchar_t low_nb; /* code and block length in block descriptor */ + uchar_t reserved; /* reserved */ + uchar_t high_bl; /* block length */ + uchar_t mid_bl; /* " " */ + uchar_t low_bl; /* " " */ + uchar_t ps: 1, /* Page Savable sense only */ + : 1, + page_code: 6; + uchar_t page_len; + modepage page; +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ +}; + +/* + * One_command parameter data for REPORT SUPPORTED OPERATION CODES. + */ +struct one_com_des { +#if defined(_BIT_FIELDS_LTOH) + uchar_t reserved0; + uchar_t support: 3, /* support value */ + reserved1: 4, + ctdp: 1; /* cmd timeouts descriptor present */ + ushort_t cdb_size; /* cdb size */ + uchar_t usage[CDB_GROUP4]; /* 16 bytes, the largest CDB group */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t reserved0; + uchar_t ctdp: 1, /* cmd timeouts descriptor present */ + reserved1: 4, + support: 3; /* support value */ + ushort_t cdb_size; /* cdb size */ + uchar_t usage[CDB_GROUP4]; /* 16 bytes, the largest CDB group */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ +}; + +/* + * Command timeouts descriptor + */ +struct com_timeout_des { + ushort_t des_len; /* descriptor length */ + uchar_t reserved; + uchar_t com_spe; /* command specific */ + uint_t nom_timeout; /* nominal command processing timeout */ + uint_t rec_timeout; /* recommended command timeout */ +}; + +/* + * Reporting options + */ +#define ALL_COMMAND_DATA_FORMAT 0 +#define ONE_COMMAND_NO_SERVICE_DATA_FORMAT 1 +#define ONE_COMMAND_DATA_FORMAT 2 + +/* + * Support values in One_command parameter data + */ +#define SUPPORT_VALUES_NOT_AVAILABLE 0 +#define SUPPORT_VALUES_NOT_SUPPORT 1 +#define SUPPORT_VALUES_SUPPORT_SCSI 3 +#define SUPPORT_VALUES_SUPPORT_VENDOR 5 + +/* + * Parameter data for REPORT DENSITY SUPPORT command + */ +struct report_density_header { + ushort_t ava_dens_len; /* available density support length */ + uchar_t reserved0; + uchar_t reserved1; +}; + +struct report_density_desc { +#if defined(_BIT_FIELDS_LTOH) + uchar_t pri_den; /* primary density code */ + uchar_t sec_den; /* secondary density code */ + uchar_t dlv:1; /* descriptor length valid */ + uchar_t reserved:4; + uchar_t deflt:1; /* is default density */ + uchar_t dup:1; /* pri density has one descriptor */ + uchar_t wrtok:1; /* support writing to media */ + uchar_t desc_len_hi; /* descriptor length high */ + uchar_t desc_len_low; /* descriptor length low */ + uchar_t bits_per_mm[3]; /* bits per mm */ + uchar_t media_width_hi; /* media width high */ + uchar_t media_width_low; /* media width low */ + ushort_t tracks; /* tracks */ + uint_t capacity; /* capacity */ + uchar_t ass_org[8]; /* assigning organization */ + uchar_t den_name[8]; /* density name */ + uchar_t description[20]; /* description */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t pri_den; /* primary density code */ + uchar_t sec_den; /* secondary density code */ + uchar_t wrtok:1; /* support writing to media */ + uchar_t dup:1; /* pri density has one descriptor */ + uchar_t deflt:1; /* is default density */ + uchar_t reserved:4; + uchar_t dlv:1; /* descriptor length valid */ + uchar_t desc_len_hi; /* descriptor length high */ + uchar_t desc_len_low; /* descriptor length low */ + uchar_t bits_per_mm[3]; /* bits per mm */ + uchar_t media_width_hi; /* media width high */ + uchar_t media_width_low; /* media width low */ + ushort_t tracks; /* tracks */ + uint_t capacity; /* capacity */ + uchar_t ass_org[8]; /* assigning organization */ + uchar_t den_name[8]; /* density name */ + uchar_t description[20]; /* description */ +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ +}; + +/* + * Data returned from the READ BLOCK LIMITS command. + */ + +#define RBLSIZE (sizeof (struct read_blklim)) +struct read_blklim { +#if defined(_BIT_FIELDS_HTOL) + uchar_t reserved: 3; /* reserved */ + uchar_t granularity: 5; /* Minimum Modularity */ +#elif defined(_BIT_FIELDS_LTOH) + uchar_t granularity: 5; /* Minimum Modularity */ + uchar_t reserved: 3; /* reserved */ +#endif + uchar_t max_hi; /* Maximum block length, high byte */ + uchar_t max_mid; /* Maximum block length, middle byte */ + uchar_t max_lo; /* Maximum block length, low byte */ + uchar_t min_hi; /* Minimum block length, high byte */ + uchar_t min_lo; /* Minimum block length, low byte */ +}; + +/* + * operation codes + */ +typedef enum { + ST_OP_NIL, + ST_OP_CTL, + ST_OP_READ, + ST_OP_WRITE, + ST_OP_WEOF +}optype; + +/* + * eof/eot/eom codes. + */ +typedef enum { + ST_NO_EOF, + ST_EOF_PENDING, /* filemark pending */ + ST_EOF, /* at filemark */ + ST_EOT_PENDING, /* logical eot pending */ + ST_EOT, /* at logical eot */ + ST_EOM, /* at physical eot */ + ST_WRITE_AFTER_EOM /* flag for allowing writes after EOM */ +}pstatus; + +typedef enum { invalid, legacy, logical } posmode; + +typedef struct tapepos { + uint64_t lgclblkno; + int32_t fileno; + int32_t blkno; + int32_t partition; + pstatus eof; /* eof states */ + posmode pmode; + uint32_t: 32; +}tapepos_t; + +/* byte 1 of cdb for type of read position command */ +typedef enum { + SHORT_POS = 0, + LONG_POS = 6, + EXT_POS = 8, + NO_POS = 0xff /* Drive doesn't support read position */ +} read_p_types; + + +/* + * Data returned from the READ POSITION command. + */ + +typedef struct tape_position { +#if defined(_BIT_FIELDS_HTOL) + uchar_t begin_of_part: 1; + uchar_t end_of_part: 1; + uchar_t blk_cnt_unkwn: 1; + uchar_t byte_cnt_unkwn: 1; + uchar_t reserved0: 1; + uchar_t blk_posi_unkwn: 1; + uchar_t posi_err: 1; + uchar_t reserved1: 1; +#elif defined(_BIT_FIELDS_LTOH) + uchar_t reserved1: 1; + uchar_t posi_err: 1; + uchar_t blk_posi_unkwn: 1; + uchar_t reserved0: 1; + uchar_t byte_cnt_unkwn: 1; + uchar_t blk_cnt_unkwn: 1; + uchar_t end_of_part: 1; + uchar_t begin_of_part: 1; +#endif + uchar_t partition_number; + uchar_t reserved2[2]; + uint32_t host_block; + uint32_t media_block; + uchar_t reserved3; + uchar_t block_in_buff[3]; + uint32_t byte_in_buff; +}tape_position_t; + + +typedef struct tape_position_long { +#if defined(_BIT_FIELDS_HTOL) + uint32_t begin_of_part: 1; + uint32_t end_of_part: 1; + uint32_t reserved0: 2; + uint32_t mrk_posi_unkwn:1; + uint32_t blk_posi_unkwn:1; + uint32_t reserved1: 2; +#elif defined(_BIT_FIELDS_LTOH) + uint32_t reserved1: 2; + uint32_t blk_posi_unkwn:1; + uint32_t mrk_posi_unkwn:1; + uint32_t reserved0: 2; + uint32_t end_of_part: 1; + uint32_t begin_of_part: 1; +#endif + uint32_t reserved2: 24; + uint32_t partition; + uint64_t block_number; + uint64_t file_number; + uint64_t set_number; +}tape_position_long_t; + +typedef struct tape_position_ext { +#if defined(_BIT_FIELDS_HTOL) + uchar_t begin_of_part: 1; + uchar_t end_of_part: 1; + uchar_t blk_cnt_unkwn: 1; + uchar_t byte_cnt_unkwn: 1; + uchar_t mrk_posi_unkwn: 1; + uchar_t blk_posi_unkwn: 1; + uchar_t posi_err: 1; + uchar_t reserved0: 1; + + uchar_t partition; + uint16_t parameter_len; +/* start next word */ + uint32_t reserved1: 8; + uint32_t blks_in_buf: 24; +#elif defined(_BIT_FIELDS_LTOH) + uchar_t reserved0: 1; + uchar_t posi_err: 1; + uchar_t blk_posi_unkwn: 1; + uchar_t mrk_posi_unkwn: 1; + uchar_t byte_cnt_unkwn: 1; + uchar_t blk_cnt_unkwn: 1; + uchar_t end_of_part: 1; + uchar_t begin_of_part: 1; + + uchar_t partition; + uint16_t parameter_len; +/* start next word */ + uint32_t blks_in_buf: 24; + uint32_t reserved1: 8; +#endif + uint64_t host_block; + uint64_t media_block; + uint64_t byte_in_buf; +}tape_position_ext_t; + +typedef union { + tape_position_t srt; + tape_position_ext_t ext; + tape_position_long_t lng; +}read_pos_data_t; + +typedef struct { + unsigned char cmd; + unsigned char + requires_reserve: 1, /* reserve must be done */ + retriable: 1, /* can be retried */ + chg_tape_pos: 1, /* position will change */ + chg_tape_data: 1, /* data on media will change */ + explicit_cmd_set: 1, /* explicit command set */ + /* + * 0 doesn't, 1 forward, + * 2 back, 3 either + */ + chg_tape_direction: 2; /* direction of pos change */ +#define DIR_NONE 0 +#define DIR_FORW 1 +#define DIR_REVC 2 +#define DIR_EITH 3 + unsigned char + /* + * 0 doesn't 1 read, 2 write + */ + transfers_data: 2, +#define TRAN_NONE 0 +#define TRAN_READ 1 +#define TRAN_WRTE 2 + recov_pos_type: 1, +#define POS_EXPECTED 0 +#define POS_STARTING 1 + do_not_recover: 1; + uchar_t reserve_byte; + uint32_t reserve_mask; + uint64_t (*get_cnt)(uchar_t *); + uint64_t (*get_lba)(uchar_t *); +}cmd_attribute; + +typedef struct { + buf_t *cmd_bp; + size_t privatelen; + int str_retry_cnt; + int pkt_retry_cnt; +}pkt_info; + +typedef struct { + buf_t *cmd_bp; + size_t privatelen; + int str_retry_cnt; + int pkt_retry_cnt; + tapepos_t pos; + const cmd_attribute *cmd_attrib; +}recov_info; + +#ifdef _KERNEL + +#ifdef __x86 +/* Data structure used in big block I/O on x86/x64 platform */ + +/* + * alloc more than one contig_mem, so mutiple I/O can be + * on-going simultaneously + */ +#define ST_MAX_CONTIG_MEM_NUM 3 + +struct contig_mem { + struct contig_mem *cm_next; + size_t cm_len; + caddr_t cm_addr; + ddi_acc_handle_t cm_acc_hdl; + struct buf *cm_bp; + int cm_use_sbuf; +}; + +#endif + +#endif /* _KERNEL */ + +/* + * driver states.. + */ +typedef enum { + ST_STATE_CLOSED, + ST_STATE_OFFLINE, + ST_STATE_INITIALIZING, + ST_STATE_OPENING, + ST_STATE_OPEN_PENDING_IO, + ST_STATE_APPEND_TESTING, + ST_STATE_OPEN, + ST_STATE_RESOURCE_WAIT, + ST_STATE_CLOSING, + ST_STATE_SENSING, + ST_STATE_CLOSE_PENDING_OPEN +}st_states; + +typedef enum { RDWR, RDONLY, WORM, RDWORM, FAILED } writablity; +typedef enum { + TLR_NOT_KNOWN, + TLR_NOT_SUPPORTED, + TLR_SAS_ONE_DEVICE, + TLR_SAS_TWO_DEVICE +}st_tlr_state; + + +/* + * Private info for scsi tapes. Pointed to by the un_private pointer + * of one of the SCSI_DEVICE chains. + */ + +struct scsi_tape { + struct scsi_device *un_sd; /* back pointer to SCSI_DEVICE */ + struct scsi_pkt *un_rqs; /* ptr to request sense command */ + struct scsi_pkt *un_mkr_pkt; /* ptr to marker packet */ + kcondvar_t un_sbuf_cv; /* cv on ownership of special buf */ + kcondvar_t un_queue_cv; /* cv on all queued commands */ + struct buf *un_sbufp; /* for use in special io */ + char *un_srqbufp; /* sense buffer for special io */ + kcondvar_t un_clscv; /* closing cv */ + struct buf *un_quef; /* head of wait queue */ + struct buf *un_quel; /* tail of wait queue */ + struct buf *un_runqf; /* head of run queue */ + struct buf *un_runql; /* tail of run queue */ + struct seq_mode *un_mspl; /* ptr to mode select info */ + struct st_drivetype *un_dp; /* ptr to drive table entry */ + uint_t un_dp_size; /* size of un_dp alloc'ed */ + caddr_t un_tmpbuf; /* buf for append, autodens ops */ + tapepos_t un_pos; /* Current tape position */ + int un_oflags; /* open flags */ + tapepos_t un_err_pos; /* block in file where err occurred */ + uint_t un_err_resid; /* resid from last error */ + short un_fmneeded; /* filemarks to be written - HP only */ + dev_t un_dev; /* unix device */ + uchar_t un_attached; /* unit known && attached */ + int un_pwr_mgmt; /* power management state */ + uchar_t un_density_known; /* density is known */ + uchar_t un_curdens; /* index into density table */ + optype un_lastop; /* last I/O was: read/write/ctl */ + st_states un_laststate; /* last state */ + st_states un_state; /* current state */ + uchar_t un_status; /* status from last sense */ + uchar_t un_retry_ct; /* retry count */ + writablity un_read_only; /* RDWR, RDONLY, WORM, RDWORM */ + uchar_t un_test_append; /* check writing at end of tape */ + uchar_t un_arq_enabled; /* auto request sense enabled */ + uchar_t un_untagged_qing; /* hba has untagged quing */ + uchar_t un_allow_large_xfer; /* allow >64k xfers if requested */ + uchar_t un_sbuf_busy; /* sbuf busy flag */ + uchar_t un_ncmds; /* number of commands outstanding */ + uchar_t un_throttle; /* curr. max number of cmds outst. */ + uchar_t un_last_throttle; /* saved max number of cmds outst. */ + uchar_t un_max_throttle; /* max poss. number cmds outstanding */ + uchar_t un_persistence; /* 1 = persistence on, 0 off */ + uchar_t un_persist_errors; /* 1 = persistenced flagged */ + uchar_t un_flush_on_errors; /* HBA will flush all I/O's on a */ + /* check condidtion or error */ + uint_t un_kbytes_xferred; /* bytes (in K) counter */ + uint_t un_last_resid; /* keep last resid, for PE */ + uint_t un_last_count; /* keep last count, for PE */ + struct kstat *un_stats; /* for I/O statistics */ + struct buf *un_rqs_bp; /* bp used in rqpkt */ + struct buf *un_wf; /* head of write queue */ + struct buf *un_wl; /* tail of write queue */ + struct read_blklim *un_rbl; /* ptr to read block limit info */ + int un_maxdma; /* max dma xfer allowed by HBA */ + uint_t un_bsize; /* block size currently being used */ + int un_maxbsize; /* max block size allowed by drive */ + uint_t un_minbsize; /* min block size allowed by drive */ + int un_errno; /* errno (b_error) */ + kcondvar_t un_state_cv; /* mediastate condition variable */ + enum mtio_state un_mediastate; /* current media state */ + enum mtio_state un_specified_mediastate; /* expected state */ + timeout_id_t un_delay_tid; /* delayed cv tid */ + timeout_id_t un_hib_tid; /* handle interrupt busy tid */ + opaque_t un_swr_token; /* scsi_watch request token */ + uchar_t un_comp_page; /* compression page */ + uchar_t un_rsvd_status; /* Reservation Status */ + kstat_t *un_errstats; /* for error statistics */ + int un_init_options; /* Init time drive options */ + int un_save_fileno; /* Save here for recovery */ + daddr_t un_save_blkno; /* Save here for recovery */ + uchar_t un_restore_pos; /* Indication to do recovery */ + tapepos_t un_suspend_pos; /* Save blkno for SUSPEND */ + uchar_t un_silent_skip; /* to catch short reads */ + short un_tids_at_suspend; /* timeouts set at suspend */ + kcondvar_t un_tape_busy_cv; /* busy cv */ + kcondvar_t un_suspend_cv; /* busy cv */ + /* restore on close */ + uchar_t un_eject_tape_on_failure; /* 1 = eject tape, 0 = don't */ + uchar_t un_HeadClean; /* support and need head cleaning? */ + uchar_t un_rqs_state; /* see define below */ + struct scsi_extended_sense + *un_uscsi_rqs_buf; /* uscsi_rqs: buffer for RQS data */ + uchar_t un_data_mod; /* Device required data mod */ + writablity (*un_wormable) (struct scsi_tape *un); /* worm test fuct */ + int un_max_cdb_sz; /* max cdb size to use */ + read_p_types un_read_pos_type; + read_pos_data_t *un_read_pos_data; + struct mterror_entry_stack *un_error_entry_stk; + /* latest sense cmd buffer */ +#ifdef __x86 + ddi_dma_handle_t un_contig_mem_hdl; + struct contig_mem *un_contig_mem; + int un_contig_mem_available_num; + int un_contig_mem_total_num; + size_t un_max_contig_mem_len; + kcondvar_t un_contig_mem_cv; + int un_maxdma_arch; /* max dma xfer allowed by HBA & arch */ +#endif + caddr_t un_media_id; + int un_media_id_len; + int (*un_media_id_method)(struct scsi_tape *, int (*)()); + buf_t *un_recov_buf; /* buf to recover failed commands */ + kcondvar_t un_recov_buf_cv; /* cv for buf un_recov_buf */ + uchar_t un_recov_buf_busy; +#ifdef _KERNEL + ddi_taskq_t *un_recov_taskq; +#else + void *un_recov_taskq; +#endif + tapepos_t un_running; + uchar_t un_unit_attention_flags; + uchar_t un_multipath; + ulong_t un_last_path_instance; + st_tlr_state un_tlr_flag; /* tape support TLR flag */ +}; + +typedef int (*bufunc_t)(struct scsi_tape *, int, int64_t, int); +typedef int (*ubufunc_t)(struct scsi_tape *, struct uscsi_cmd *, int); + + +/* + * device error kstats + */ +struct st_errstats { + struct kstat_named st_softerrs; + struct kstat_named st_harderrs; + struct kstat_named st_transerrs; + struct kstat_named st_vid; + struct kstat_named st_pid; + struct kstat_named st_revision; + struct kstat_named st_serial; +}; + +/* + * generic log page struct + */ +struct log_page { +#if defined(_BIT_FIELDS_LTOH) + uchar_t code :6, /* page code number */ + :2; /* reserved */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t :2, /* reserved */ + code :6; /* page code number */ +#endif /* _BIT_FIELDS_LTOH */ + uchar_t reserved; /* reserved */ + uchar_t length_hi; /* length of bytes to follow (msb) */ + uchar_t length_lo; /* length of bytes to follow (lsb) */ + /* + * Log parameters follow right after this... + */ +}; + +/* + * generic log page parameter struct + */ +struct log_param { + uchar_t pc_hi; /* parameter code (msb) */ + uchar_t pc_lo; /* parameter code (lsb) */ +#if defined(_BIT_FIELDS_LTOH) + uchar_t lp : 1, /* list parameter */ + : 1, /* reserved */ + tmc : 2, /* threshold met criteria */ + etc : 1, /* enable threshold comparison */ + tsd : 1, /* target save disable */ + ds : 1, /* disable save */ + du : 1; /* disable update */ +#elif defined(_BIT_FIELDS_HTOL) + uchar_t du : 1, /* disable update */ + ds : 1, /* disable save */ + tsd : 1, /* target save disable */ + etc : 1, /* enable threshold comparison */ + tmc : 2, /* threshold met criteria */ + : 1, /* reserved */ + lp : 1; /* list parameter */ +#endif /* _BIT_FIELDS_LTOH */ + uchar_t length; /* length of bytes to follow */ + /* + * Parameter values follow right after this... + */ +}; +/* + * TapeAlert structures + */ + +struct st_tape_alert_parameter { + struct log_param log_param; + uchar_t param_value; +}; + +struct st_tape_alert { + struct log_page log_page; + struct st_tape_alert_parameter param[TAPE_ALERT_MAX_PARA]; +}; + +#define TAPE_ALERT_PARAMETER_LENGTH \ + (sizeof (struct st_tape_alert_parameter)) * TAPE_ALERT_MAX_PARA + +struct log_sequential_page_parameter { + struct log_param log_param; + uchar_t param_value[8]; +}; + +struct log_sequential_page { + struct log_page log_page; + struct log_sequential_page_parameter param[TAPE_SEQUENTIAL_PAGE_PARA]; +}; + +#if !defined(__lint) +_NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, scsi_tape)) +_NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_tape::un_dp)) +_NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_tape::un_sd)) +_NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_tape::un_rqs)) +_NOTE(SCHEME_PROTECTS_DATA("protected by cv", scsi_tape::un_sbufp)) +_NOTE(DATA_READABLE_WITHOUT_LOCK(scsi_tape::un_bsize)) +_NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_arq_status)) +_NOTE(SCHEME_PROTECTS_DATA("save sharing", + scsi_tape::un_allow_large_xfer + scsi_tape::un_maxbsize + scsi_tape::un_maxdma +)) +#ifdef __x86 +_NOTE(DATA_READABLE_WITHOUT_LOCK(scsi_tape::un_contig_mem_hdl)) +_NOTE(SCHEME_PROTECTS_DATA("not shared", contig_mem)) +#endif +#endif + + +/* + * Power management state + */ +#define ST_PWR_NORMAL 0 +#define ST_PWR_SUSPENDED 1 + + +#define IN_EOF(pos) (pos.eof == ST_EOF_PENDING || pos.eof == ST_EOF) + +/* un_rqs_state codes */ + +#define ST_RQS_OVR 0x1 /* RQS data was overwritten */ +#define ST_RQS_VALID 0x2 /* RQS data is valid */ +#define ST_RQS_READ 0x4 /* RQS data was read */ +#define ST_RQS_ERROR 0x8 /* RQS resulted in an EIO */ + +/* + * st_intr codes + */ +typedef enum { + COMMAND_DONE, + COMMAND_DONE_ERROR, + COMMAND_DONE_ERROR_RECOVERED, + QUE_COMMAND, + QUE_BUSY_COMMAND, + QUE_SENSE, + JUST_RETURN, + COMMAND_DONE_EACCES, + QUE_LAST_COMMAND, + COMMAND_TIMEOUT, + PATH_FAILED, + DEVICE_RESET, + DEVICE_TAMPER, + ATTEMPT_RETRY +}errstate; +#ifdef _KERNEL +typedef struct { + struct scsi_arq_status ei_failing_status; + tapepos_t ei_expected_pos; + errstate ei_error_type; + buf_t *ei_failing_bp; + struct scsi_pkt ei_failed_pkt; /* must be last */ + /* ...scsi_pkt_size() */ +} st_err_info; +#define ST_ERR_INFO_SIZE (sizeof (st_err_info) - \ + sizeof (struct scsi_pkt) + scsi_pkt_size()) +#endif + + +/* + * Reservation Status + * + * ST_INIT_RESERVE -Used to check if the reservation has been lost + * in between opens and also to indicate the reservation + * has not been done till now. + * ST_RELEASE -Tape Unit is Released. + * ST_RESERVE -Tape Unit is Reserved. + * ST_PRESERVE_RESERVE -Reservation is to be preserved across opens. + * + */ +#define ST_INIT_RESERVE 0x001 +#define ST_RELEASE 0x002 +#define ST_RESERVE 0x004 +#define ST_PRESERVE_RESERVE 0x008 +#define ST_RESERVATION_CONFLICT 0x010 +#define ST_LOST_RESERVE 0x020 +#define ST_APPLICATION_RESERVATIONS 0x040 +#define ST_INITIATED_RESET 0x080 +#define ST_LOST_RESERVE_BETWEEN_OPENS \ + (ST_RESERVE | ST_LOST_RESERVE | ST_PRESERVE_RESERVE) + +/* + * Service action defines for Persistant Reservation Commands + */ +#define ST_SA_SCSI3_REGISTER 0x00 +#define ST_SA_SCSI3_RESERVE 0x01 +#define ST_SA_SCSI3_RELEASE 0x02 +#define ST_SA_SCSI3_CLEAR 0x03 +#define ST_SA_SCSI3_PREEMPT 0x04 +#define ST_SA_SCSI3_PREEMPTANDABORT 0x05 +#define ST_SA_SCSI3_REGISTERANDIGNOREKEY 0x06 +#define ST_SA_MASK 0x1f + +#define ST_RESERVATION_DELAY 500000 + +/* + * Asynch I/O tunables + */ +#define ST_MAX_THROTTLE 4 + +/* + * 60 minutes seems a reasonable amount of time + * to wait for tape space operations to complete. + * + */ +#define ST_SPACE_TIME MINUTES(60) /* 60 minutes per space operation */ +#define ST_LONG_SPACE_TIME_X 5 /* multipiler for long space ops */ + +/* + * 2 minutes seems a reasonable amount of time + * to wait for tape i/o operations to complete. + * + */ +#define ST_IO_TIME MINUTES(2) /* minutes per i/o */ +#define ST_LONG_TIMEOUT_X 5 /* multiplier for very long timeouts */ + + +/* + * 10 seconds is what we'll wait if we get a Busy Status back + */ +#define ST_STATUS_BUSY_TIMEOUT 10*hz /* seconds Busy Waiting */ +#define ST_TRAN_BUSY_TIMEOUT 4*hz /* seconds retry on TRAN_BSY */ +#define ST_INTERRUPT_CONTEXT 1 +#define ST_START_CONTEXT 2 + +/* + * Number of times we'll retry a normal operation. + * + * XXX This includes retries due to transport failure as well as + * XXX busy timeouts- Need to distinguish between Target and Transport + * XXX failure. + */ + +#define ST_RETRY_COUNT 20 + +/* + * Number of times to retry a failed selection + */ +#define ST_SEL_RETRY_COUNT 2 + +/* + * es_code value for deferred error + * should be moved to sense.h + */ + +#define ST_DEFERRED_ERROR 0x01 + +/* + * Maximum number of units (determined by minor device byte) + */ +#define ST_MAXUNIT 128 + +/* + * Time to wait for completion of a command before cancelling it. + * For SUSPEND use only + */ +#define ST_WAIT_CMDS_COMPLETE 10 /* seconds */ + +#ifndef SECSIZE +#define SECSIZE 512 +#endif +#ifndef SECDIV +#define SECDIV 9 +#endif + +/* + * convenient defines + */ +#define ST_SCSI_DEVP (un->un_sd) +#define ST_DEVINFO (ST_SCSI_DEVP->sd_dev) +#define ST_INQUIRY (ST_SCSI_DEVP->sd_inq) +#define ST_RQSENSE (ST_SCSI_DEVP->sd_sense) +#define ST_MUTEX (&ST_SCSI_DEVP->sd_mutex) +#define ROUTE (&ST_SCSI_DEVP->sd_address) + +#define BSD_BEHAVIOR (getminor(un->un_dev) & MT_BSD) +#define SVR4_BEHAVIOR ((getminor(un->un_dev) & MT_BSD) == 0) +#define ST_STATUS_MASK (STATUS_MASK | STATUS_TASK_ABORT) +#define SCBP(pkt) ((struct scsi_status *)(pkt)->pkt_scbp) +#define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & ST_STATUS_MASK) +#define CDBP(pkt) ((union scsi_cdb *)(pkt)->pkt_cdbp) +#define BP_PKT(bp) ((struct scsi_pkt *)(bp)->av_back) +#define SET_BP_PKT(bp, pkt) ((bp)->av_back = (struct buf *)(pkt)) +#define BP_UCMD(bp) ((struct uscsi_cmd *)(bp)->b_back) +#define USCSI_CMD(bp) (((bp) == un->un_sbufp) && (BP_UCMD(bp))) + +#define IS_CLOSING(un) ((un)->un_state == ST_STATE_CLOSING || \ + ((un)->un_state == ST_STATE_SENSING && \ + (un)->un_laststate == ST_STATE_CLOSING)) + +#define ASYNC_CMD 0 +#define SYNC_CMD 1 + +#define st_bioerror(bp, error) \ + { bioerror(bp, error); \ + un->un_errno = error; } + +/* + * Macros for internal coding of count for SPACE command: + * + * Top 3 bits of b_bcount define direction and type of space. + * Since b_bcount (size_t) is 32 bits on 32 platforms and 64 bits on + * 64 bit platforms different defines are used. + * if SP_BACKSP is set direction is backward (toward BOP) + * The type of space (Blocks, Filemark or sequential filemarks) is + * carried in the next 2 bits. The remaining bits a signed count of + * how many of that direction and type to do. + */ + +#if (defined(__lock_lint)) +/* + * This is a workaround for warlock not being able to parse an #ULL constant. + */ +#undef UINT64_MAX +#define UINT64_MAX (18446744073709551615UL) +#endif /* __lock_lint */ + +#if (defined(__lock_lint) || (SIZE_MAX < UINT64_MAX)) + +#define SP_BLK UINT32_C(0x00000000) +#define SP_FLM UINT32_C(0x20000000) +#define SP_SQFLM UINT32_C(0x40000000) +#define SP_EOD UINT32_C(0x60000000) +#define SP_BACKSP UINT32_C(0x80000000) +#define SP_CMD_MASK UINT32_C(0x60000000) +#define SP_CNT_MASK UINT32_C(0x1fffffff) + +/* Macros to interpret space cmds */ +#define SPACE_CNT(x) (((x) & SP_BACKSP)? \ + (-((x)&(SP_CNT_MASK))):(x)&(SP_CNT_MASK)) +#define SPACE_TYPE(x) ((x & SP_CMD_MASK)>>29) + +#else /* end of small size_t in buf_t */ + +#define SP_BLK UINT64_C(0x0000000000000000) +#define SP_FLM UINT64_C(0x2000000000000000) +#define SP_SQFLM UINT64_C(0x4000000000000000) +#define SP_EOD UINT64_C(0x6000000000000000) +#define SP_BACKSP UINT64_C(0x8000000000000000) +#define SP_CMD_MASK UINT64_C(0x6000000000000000) +#define SP_CNT_MASK UINT64_C(0x1fffffffffffffff) + +/* Macros to interpret space cmds */ +#define SPACE_CNT(x) (((x) & SP_BACKSP)? \ + (-((x)&(SP_CNT_MASK))):(x)&(SP_CNT_MASK)) +#define SPACE_TYPE(x) ((x & SP_CMD_MASK)>>61) + +#endif /* end of big size_t in buf_t */ + +/* Macros to assemble space cmds */ +#define SPACE(cmd, cnt) ((cnt < 0) ? (SP_BACKSP | (-(cnt)) | cmd) : (cmd | cnt)) +#define Fmk(x) SPACE(SP_FLM, x) +#define Blk(x) SPACE(SP_BLK, x) + + + +/* Defines for byte 4 of load/unload cmd */ +#define LD_UNLOAD 0 +#define LD_LOAD 1 +#define LD_RETEN 2 +#define LD_EOT 4 +#define LD_HOLD 8 + +/* Defines for byte 4 of prevent/allow media removal */ +#define MR_UNLOCK 0 +#define MR_LOCK 1 + +#define GET_SOFT_STATE(dev) \ + register struct scsi_tape *un; \ + register int instance; \ + \ + instance = MTUNIT(dev); \ + if ((un = ddi_get_soft_state(st_state, instance)) == NULL) \ + return (ENXIO); + +/* + * Debugging turned on via conditional compilation switch -DSTDEBUG + */ +#ifdef DEBUG +#define STDEBUG +#endif + +#ifdef STDEBUG +#define DEBUGGING\ + ((scsi_options & SCSI_DEBUG_TGT) || (st_debug & 0x7)) + +#define DEBLOCK(d) \ + int lev = CE_NOTE; \ + mutex_enter(&st_debug_mutex); \ + if (d == st_lastdev || d == 0) { \ + lev = CE_CONT; \ + } \ + mutex_exit(&st_debug_mutex); + +#define DEBUNLOCK(d) \ + mutex_enter(&st_debug_mutex); \ + if (d != 0 && d != st_lastdev) { \ + st_lastdev = d; \ + } \ + mutex_exit(&st_debug_mutex); + + /* initialization */ +#define ST_DEBUG1 if ((st_debug & 0x7) >= 1) scsi_log +#define ST_DEBUG ST_DEBUG1 + + /* errors and UA's */ +#define ST_DEBUG2 if ((st_debug & 0x7) >= 2) scsi_log + + /* func calls */ +#define ST_DEBUG3 if ((st_debug & 0x7) >= 3) scsi_log + + /* ioctl calls */ +#define ST_DEBUG4 if ((st_debug & 0x7) >= 4) scsi_log + +#define ST_DEBUG5 if ((st_debug & 0x7) >= 5) scsi_log + + /* full data tracking */ +#define ST_DEBUG6 if ((st_debug & 0x7) >= 6) scsi_log + + /* debug error recovery */ +#define ST_RECOV if (st_debug & 0x8) scsi_log + + /* Entry Point Functions */ +#define ST_ENTR(d, fn) if (st_debug & 0x10) { DEBLOCK(d) \ + scsi_log(d, st_label, lev, #fn); DEBUNLOCK(d) } + + /* Non-Entry Point Functions */ +#define ST_FUNC(d, fn) if (st_debug & 0x20) { DEBLOCK(d) \ + scsi_log(d, st_label, lev, #fn); DEBUNLOCK(d) } + + /* Space Information */ +#define ST_SPAC if (st_debug & 0x40) scsi_log + + /* CDB's sent */ +#define ST_CDB(d, cmnt, cdb) if (st_debug & 0x180) { DEBLOCK(d) \ + st_print_cdb(d, st_label, lev, cmnt, cdb); DEBUNLOCK(d) } + + /* sense data */ +#define ST_SENSE(d, cmnt, sense, size) if (st_debug & 0x200) { DEBLOCK(d) \ + st_clean_print(d, st_label, lev, cmnt, sense, size); DEBUNLOCK(d) } + + /* position data */ +#define ST_POS(d, cmnt, pdata) if (st_debug & 0x400) { DEBLOCK(d) \ + st_print_position(d, st_label, lev, cmnt, pdata); DEBUNLOCK(d) } + + +#else + +#define st_debug (0) +#define DEBUGGING (0) +#define ST_DEBUG if (0) scsi_log +#define ST_DEBUG1 if (0) scsi_log +#define ST_DEBUG2 if (0) scsi_log +#define ST_DEBUG3 if (0) scsi_log +#define ST_DEBUG4 if (0) scsi_log +#define ST_DEBUG5 if (0) scsi_log +#define ST_DEBUG6 if (0) scsi_log +#define ST_RECOV if (0) scsi_log + +#define ST_ENTR(d, fn) +#define ST_FUNC(d, fn) +#define ST_SPAC if (0) scsi_log +#define ST_CDB(d, cmnt, cdb) +#define ST_SENSE(d, cmnt, sense, size) +#define ST_SENSE(d, cmnt, sense, size) +#define ST_POS(d, cmnt, pdata) + +#endif + +/* + * Media access values + */ +#define MEDIA_ACCESS_DELAY 5000000 /* usecs wait for media state change */ + +/* + * SCSI tape mode sense page information + */ +#define ST_DEV_CONFIG_PAGE 0x10 /* device config mode page */ +#define ST_DEV_CONFIG_NO_COMP 0x00 /* use no compression */ +#define ST_DEV_CONFIG_DEF_COMP 0x01 /* use default compression alg */ +#define ST_COMPRESSION_DENSITY 3 /* compression minor number */ + +/* + * SCSI tape data compression Page definition. + */ +#define ST_DEV_DATACOMP_PAGE 0x0F /* data compression page */ + + + +/* + * maxbsize values + */ +#define MAXBSIZE_UNKNOWN -2 /* not found yet */ + +#define ONE_MEG (1024 * 1024) + +/* + * generic soft error reporting + * + * What we are doing here is allowing a greater number of errors to occur on + * smaller transfers (i.e. usually at the beginning of the tape), than on + * the rest of the tape. + * + * A small transfer is defined as : + * Transfers <= SOFT_ERROR_WARNING_THRESHOLD allow about 1.5 times more errors + * + * A larget tranfer is defined as : + * Transfers > SOFT_ERROR_WARNING_THRESHOLD allow normal amount + * + */ +#define READ_SOFT_ERROR_WARNING_THRESHOLD (25 * ONE_MEG) +#define WRITE_SOFT_ERROR_WARNING_THRESHOLD (20 * ONE_MEG) + +/* + * soft error reporting for exabyte + */ +#define TAPE_SENSE_LENGTH 32 /* allows for softerror info */ + +#define SENSE_19_BITS \ + "\20\10PF\07BPE\06FPE\05ME\04ECO\03TME\02TNP\01LBOT" +#define SENSE_20_BITS \ + "\20\10RSVD\07RSVD\06WP\05FMKE\04URE\03WE1\02SSE\01FW" +#define SENSE_21_BITS \ + "\20\10RSVD\07RSVD\06RRR\05CLND\04CLN\03PEOT\02WSEB\01WSE0" + +/* these are defined in percentages */ +#define EXABYTE_WRITE_ERROR_THRESHOLD 6 +#define EXABYTE_READ_ERROR_THRESHOLD 3 +/* + * minumum amount of data transfer(MB) for checking soft error rate. + */ +#define EXABYTE_MIN_TRANSFER (25 * ONE_MEG) + +#define CLN 0x8 +#define CLND 0x10 + +/* + * soft error reporting for Archive 4mm DAT + */ + +#define LOG_SENSE_LENGTH 0xff +#define MIN_LOG_SENSE_LENGTH 0x2b +#define DAT_SMALL_WRITE_ERROR_THRESHOLD 40 /* retries per 20 mg */ +#define DAT_LARGE_WRITE_ERROR_THRESHOLD 200 /* retries for more 20 mg */ +#define DAT_SMALL_READ_ERROR_THRESHOLD 5 /* errors allowed */ +#define DAT_LARGE_READ_ERROR_THRESHOLD 3 /* errors allowed */ + +/* + * ST timeouts that need to be cancelled for suspend + */ +#define ST_HIB_TID 0x01 +#define ST_DELAY_TID 0x02 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SCSI_TARGETS_STDEF_H */ diff --git a/illumos-x86_64/usr/include/sys/sdt.h b/illumos-x86_64/usr/include/sys/sdt.h new file mode 100644 index 00000000..d0f423ca --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sdt.h @@ -0,0 +1,455 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_SDT_H +#define _SYS_SDT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _KERNEL + +#define DTRACE_PROBE(provider, name) { \ + extern void __dtrace_##provider##___##name(void); \ + __dtrace_##provider##___##name(); \ +} + +#define DTRACE_PROBE1(provider, name, arg1) { \ + extern void __dtrace_##provider##___##name(unsigned long); \ + __dtrace_##provider##___##name((unsigned long)arg1); \ +} + +#define DTRACE_PROBE2(provider, name, arg1, arg2) { \ + extern void __dtrace_##provider##___##name(unsigned long, \ + unsigned long); \ + __dtrace_##provider##___##name((unsigned long)arg1, \ + (unsigned long)arg2); \ +} + +#define DTRACE_PROBE3(provider, name, arg1, arg2, arg3) { \ + extern void __dtrace_##provider##___##name(unsigned long, \ + unsigned long, unsigned long); \ + __dtrace_##provider##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3); \ +} + +#define DTRACE_PROBE4(provider, name, arg1, arg2, arg3, arg4) { \ + extern void __dtrace_##provider##___##name(unsigned long, \ + unsigned long, unsigned long, unsigned long); \ + __dtrace_##provider##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3, \ + (unsigned long)arg4); \ +} + +#define DTRACE_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) { \ + extern void __dtrace_##provider##___##name(unsigned long, \ + unsigned long, unsigned long, unsigned long, unsigned long);\ + __dtrace_##provider##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3, \ + (unsigned long)arg4, (unsigned long)arg5); \ +} + +#else /* _KERNEL */ + +#define DTRACE_PROBE(name) { \ + extern void __dtrace_probe_##name(void); \ + __dtrace_probe_##name(); \ +} + +#define DTRACE_PROBE1(name, type1, arg1) { \ + extern void __dtrace_probe_##name(uintptr_t); \ + __dtrace_probe_##name((uintptr_t)(arg1)); \ +} + +#define DTRACE_PROBE2(name, type1, arg1, type2, arg2) { \ + extern void __dtrace_probe_##name(uintptr_t, uintptr_t); \ + __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2)); \ +} + +#define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) { \ + extern void __dtrace_probe_##name(uintptr_t, uintptr_t, uintptr_t); \ + __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ + (uintptr_t)(arg3)); \ +} + +#define DTRACE_PROBE4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) { \ + extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ + uintptr_t, uintptr_t); \ + __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ + (uintptr_t)(arg3), (uintptr_t)(arg4)); \ +} + +#define DTRACE_PROBE5(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5) { \ + extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ + uintptr_t, uintptr_t, uintptr_t); \ + __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ + (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5)); \ +} + +#define DTRACE_PROBE6(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6) { \ + extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ + uintptr_t, uintptr_t, uintptr_t, uintptr_t); \ + __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ + (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ + (uintptr_t)(arg6)); \ +} + +#define DTRACE_PROBE7(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6, type7, arg7) { \ + extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ + uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); \ + __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ + (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ + (uintptr_t)(arg6), (uintptr_t)(arg7)); \ +} + +#define DTRACE_PROBE8(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) { \ + extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ + uintptr_t, uintptr_t, uintptr_t, uintptr_t, \ + uintptr_t, uintptr_t); \ + __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ + (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ + (uintptr_t)(arg6), (uintptr_t)(arg7), (uintptr_t)(arg8)); \ +} + +#define DTRACE_SCHED(name) \ + DTRACE_PROBE(__sched_##name); + +#define DTRACE_SCHED1(name, type1, arg1) \ + DTRACE_PROBE1(__sched_##name, type1, arg1); + +#define DTRACE_SCHED2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__sched_##name, type1, arg1, type2, arg2); + +#define DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__sched_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_SCHED4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__sched_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_PROC(name) \ + DTRACE_PROBE(__proc_##name); + +#define DTRACE_PROC1(name, type1, arg1) \ + DTRACE_PROBE1(__proc_##name, type1, arg1); + +#define DTRACE_PROC2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__proc_##name, type1, arg1, type2, arg2); + +#define DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__proc_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_PROC4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__proc_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_IO(name) \ + DTRACE_PROBE(__io_##name); + +#define DTRACE_IO1(name, type1, arg1) \ + DTRACE_PROBE1(__io_##name, type1, arg1); + +#define DTRACE_IO2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__io_##name, type1, arg1, type2, arg2); + +#define DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__io_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_IO4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__io_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_ISCSI_2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__iscsi_##name, type1, arg1, type2, arg2); + +#define DTRACE_ISCSI_3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__iscsi_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_ISCSI_4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__iscsi_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_ISCSI_5(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5) \ + DTRACE_PROBE5(__iscsi_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5); + +#define DTRACE_ISCSI_6(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ + DTRACE_PROBE6(__iscsi_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6); + +#define DTRACE_ISCSI_7(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ + DTRACE_PROBE7(__iscsi_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ + type7, arg7); + +#define DTRACE_ISCSI_8(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ + type7, arg7, type8, arg8) \ + DTRACE_PROBE8(__iscsi_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ + type7, arg7, type8, arg8); + +#define DTRACE_NFSV3_3(name, type1, arg1, type2, arg2, \ + type3, arg3) \ + DTRACE_PROBE3(__nfsv3_##name, type1, arg1, type2, arg2, \ + type3, arg3); + +#define DTRACE_NFSV3_4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__nfsv3_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_NFSV3_5(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5) \ + DTRACE_PROBE5(__nfsv3_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5); + +#define DTRACE_NFSV4_1(name, type1, arg1) \ + DTRACE_PROBE1(__nfsv4_##name, type1, arg1); + +#define DTRACE_NFSV4_2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__nfsv4_##name, type1, arg1, type2, arg2); + +#define DTRACE_NFSV4_3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__nfsv4_##name, type1, arg1, type2, arg2, type3, arg3); + +/* + * The SMB probes are done a little differently from the other probes + * in this file for the benefit of the libfksmbsrv USDT provider. + * See: lib/smbsrv/libfksmbsrv/common/sys/sdt.h + */ +#define DTRACE_SMB_START(name, type1, arg1) \ + DTRACE_PROBE1(__smb_##name##__start, type1, arg1); +#define DTRACE_SMB_DONE(name, type1, arg1) \ + DTRACE_PROBE1(__smb_##name##__done, type1, arg1); + +#define DTRACE_SMB2_START(name, type1, arg1) \ + DTRACE_PROBE1(__smb2_##name##__start, type1, arg1); +#define DTRACE_SMB2_DONE(name, type1, arg1) \ + DTRACE_PROBE1(__smb2_##name##__done, type1, arg1); + +#define DTRACE_IP(name) \ + DTRACE_PROBE(__ip_##name); + +#define DTRACE_IP1(name, type1, arg1) \ + DTRACE_PROBE1(__ip_##name, type1, arg1); + +#define DTRACE_IP2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__ip_##name, type1, arg1, type2, arg2); + +#define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__ip_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_IP4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__ip_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_IP5(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5) \ + DTRACE_PROBE5(__ip_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5); + +#define DTRACE_IP6(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ + DTRACE_PROBE6(__ip_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6); + +#define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ + DTRACE_PROBE7(__ip_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ + type7, arg7); + +#define DTRACE_TCP(name) \ + DTRACE_PROBE(__tcp_##name); + +#define DTRACE_TCP1(name, type1, arg1) \ + DTRACE_PROBE1(__tcp_##name, type1, arg1); + +#define DTRACE_TCP2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__tcp_##name, type1, arg1, type2, arg2); + +#define DTRACE_TCP3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__tcp_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_TCP4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__tcp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_TCP5(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5) \ + DTRACE_PROBE5(__tcp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5); + +#define DTRACE_TCP6(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ + DTRACE_PROBE6(__tcp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6); + +#define DTRACE_UDP(name) \ + DTRACE_PROBE(__udp_##name); + +#define DTRACE_UDP1(name, type1, arg1) \ + DTRACE_PROBE1(__udp_##name, type1, arg1); + +#define DTRACE_UDP2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__udp_##name, type1, arg1, type2, arg2); + +#define DTRACE_UDP3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__udp_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_UDP4(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__udp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_UDP5(name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5) \ + DTRACE_PROBE5(__udp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5); + + +#define DTRACE_SYSEVENT2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__sysevent_##name, type1, arg1, type2, arg2); + +#define DTRACE_XPV(name) \ + DTRACE_PROBE(__xpv_##name); + +#define DTRACE_XPV1(name, type1, arg1) \ + DTRACE_PROBE1(__xpv_##name, type1, arg1); + +#define DTRACE_XPV2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__xpv_##name, type1, arg1, type2, arg2); + +#define DTRACE_XPV3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__xpv_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_XPV4(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4) \ + DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_FC_1(name, type1, arg1) \ + DTRACE_PROBE1(__fc_##name, type1, arg1); + +#define DTRACE_FC_2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__fc_##name, type1, arg1, type2, arg2); + +#define DTRACE_FC_3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__fc_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_FC_4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + DTRACE_PROBE4(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4); + +#define DTRACE_FC_5(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5) \ + DTRACE_PROBE5(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5); + +#define DTRACE_SRP_1(name, type1, arg1) \ + DTRACE_PROBE1(__srp_##name, type1, arg1); + +#define DTRACE_SRP_2(name, type1, arg1, type2, arg2) \ + DTRACE_PROBE2(__srp_##name, type1, arg1, type2, arg2); + +#define DTRACE_SRP_3(name, type1, arg1, type2, arg2, type3, arg3) \ + DTRACE_PROBE3(__srp_##name, type1, arg1, type2, arg2, type3, arg3); + +#define DTRACE_SRP_4(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4) \ + DTRACE_PROBE4(__srp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4); + +#define DTRACE_SRP_5(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5) \ + DTRACE_PROBE5(__srp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5); + +#define DTRACE_SRP_6(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6) \ + DTRACE_PROBE6(__srp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6); + +#define DTRACE_SRP_7(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ + DTRACE_PROBE7(__srp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7); + +#define DTRACE_SRP_8(name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \ + DTRACE_PROBE8(__srp_##name, type1, arg1, type2, arg2, \ + type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ + type7, arg7, type8, arg8); + +/* + * The set-error SDT probe is extra static, in that we declare its fake + * function literally, rather than with the DTRACE_PROBE1() macro. This is + * necessary so that SET_ERROR() can evaluate to a value, which wouldn't + * be possible if it required multiple statements (to declare the function + * and then call it). + * + * SET_ERROR() uses the comma operator so that it can be used without much + * additional code. For example, "return (EINVAL);" becomes + * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated + * twice, so it should not have side effects (e.g. something like: + * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). + */ +extern void __dtrace_probe_set__error(uintptr_t); +#define SET_ERROR(err) (__dtrace_probe_set__error(err), err) + +#endif /* _KERNEL */ + +extern const char *sdt_prefix; + +typedef struct sdt_probedesc { + char *sdpd_name; /* name of this probe */ + unsigned long sdpd_offset; /* offset of call in text */ + struct sdt_probedesc *sdpd_next; /* next static probe */ +} sdt_probedesc_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SDT_H */ diff --git a/illumos-x86_64/usr/include/sys/secflags.h b/illumos-x86_64/usr/include/sys/secflags.h new file mode 100644 index 00000000..93c1d79d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/secflags.h @@ -0,0 +1,102 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* Copyright 2014, Richard Lowe */ + +#ifndef _SYS_SECFLAGS_H +#define _SYS_SECFLAGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +struct proc; +typedef uint64_t secflagset_t; + +typedef struct psecflags { + secflagset_t psf_effective; + secflagset_t psf_inherit; + secflagset_t psf_lower; + secflagset_t psf_upper; +} psecflags_t; + +typedef struct secflagdelta { + secflagset_t psd_add; /* Flags to add */ + secflagset_t psd_rem; /* Flags to remove */ + secflagset_t psd_assign; /* Flags to assign */ + boolean_t psd_ass_active; /* Need to assign */ +} secflagdelta_t; + +typedef enum { + PSF_EFFECTIVE = 0, + PSF_INHERIT, + PSF_LOWER, + PSF_UPPER +} psecflagwhich_t; + + +/* + * p_secflags codes + * + * These flags indicate the extra security-related features enabled for a + * given process. + */ +typedef enum { + PROC_SEC_ASLR = 0, + PROC_SEC_FORBIDNULLMAP, + PROC_SEC_NOEXECSTACK +} secflag_t; + +extern secflagset_t secflag_to_bit(secflag_t); +extern boolean_t secflag_isset(secflagset_t, secflag_t); +extern void secflag_clear(secflagset_t *, secflag_t); +extern void secflag_set(secflagset_t *, secflag_t); +extern boolean_t secflags_isempty(secflagset_t); +extern void secflags_zero(secflagset_t *); +extern void secflags_fullset(secflagset_t *); +extern void secflags_copy(secflagset_t *, const secflagset_t *); +extern boolean_t secflags_issubset(secflagset_t, secflagset_t); +extern boolean_t secflags_issuperset(secflagset_t, secflagset_t); +extern boolean_t secflags_intersection(secflagset_t, secflagset_t); +extern void secflags_union(secflagset_t *, const secflagset_t *); +extern void secflags_difference(secflagset_t *, const secflagset_t *); +extern boolean_t psecflags_validate_delta(const psecflags_t *, + const secflagdelta_t *); +extern boolean_t psecflags_validate(const psecflags_t *); +extern void psecflags_default(psecflags_t *sf); +extern const char *secflag_to_str(secflag_t); +extern boolean_t secflag_by_name(const char *, secflag_t *); +extern void secflags_to_str(secflagset_t, char *, size_t); + +/* All valid bits */ +#define PROC_SEC_MASK (secflag_to_bit(PROC_SEC_ASLR) | \ + secflag_to_bit(PROC_SEC_FORBIDNULLMAP) | \ + secflag_to_bit(PROC_SEC_NOEXECSTACK)) + +#if !defined(_KERNEL) +extern int secflags_parse(const secflagset_t *, const char *, secflagdelta_t *); +extern int psecflags(idtype_t, id_t, psecflagwhich_t, secflagdelta_t *); +#endif + +#if defined(_KERNEL) +extern boolean_t secflag_enabled(struct proc *, secflag_t); +extern void secflags_promote(struct proc *); +extern void secflags_apply_delta(secflagset_t *, const secflagdelta_t *); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SECFLAGS_H */ diff --git a/illumos-x86_64/usr/include/sys/segment.h b/illumos-x86_64/usr/include/sys/segment.h new file mode 100644 index 00000000..aad5dc8f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/segment.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_SEGMENT_H +#define _SYS_SEGMENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* access rights for data segments */ +#define UDATA_ACC1 0xF2 /* present dpl=3 writable */ +#define DATA_ACC2 0xC /* 4Kbyte gran. 4Gb limit avl=0 */ +#define DATA_ACC2_S 0x4 /* 1 byte gran., 32bit operands, avl=0 */ +#define UTEXT_ACC1 0xFA /* present dpl=3 readable */ +#define TEXT_ACC2 0xC /* 4Kbyte gran., 32 bit operands avl=0 */ +#define TEXT_ACC2_S 0x4 /* 1 byte gran., 32 bit operands avl=0 */ +#define LDT_UACC1 0xE2 /* present dpl=3 type=ldt */ +#define LDT_ACC2 0x0 /* G=0 avl=0 */ +#define TGATE_UACC1 0xE5 /* present dpl=3 type=task gate */ +#define SEG_CONFORM 0X4 /* conforming bit in acc0007 */ + +#define LDT_TYPE 0x2 /* type of segment is LDT */ + + +/* access rights field for gates */ + +#define GATE_UACC 0xE0 /* present and dpl = 3 */ +#define GATE_386CALL 0xC /* 386 call gate */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SEGMENT_H */ diff --git a/illumos-x86_64/usr/include/sys/segments.h b/illumos-x86_64/usr/include/sys/segments.h new file mode 100644 index 00000000..583a38e7 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/segments.h @@ -0,0 +1,743 @@ +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + */ +/* + * Copyright 2019 Joyent, Inc. + * Copyright 2022 Oxide Computer Company + */ + +#ifndef _SYS_SEGMENTS_H +#define _SYS_SEGMENTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (c) 1989, 1990 William F. Jolitz + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 + * $FreeBSD: src/sys/i386/include/segments.h,v 1.34 2003/09/10 01:07:04 + * jhb Exp $ + * + * 386 Segmentation Data Structures and definitions + * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989 + */ + +#include + +/* + * Selector register format + * CS, DS, ES, FS, GS, SS + * + * 15 3 2 1 0 + * +---------------------+---+----+ + * | SI |TI |RPL | + * +---------------------+---+----+ + * + * SI = selector index + * TI = table indicator (0 = GDT, 1 = LDT) + * RPL = requestor privilege level + */ +#define IDXTOSEL(s) ((s) << 3) /* index to selector */ +#define SELTOIDX(s) ((s) >> 3) /* selector to index */ +#define SEL_GDT(s, r) (IDXTOSEL(s) | r) /* global sel */ + +/* + * SEL_(KPL,UPL,XPL) is the RPL or DPL value for code and data selectors + * and their descriptors respectively. + * + * TRP_(KPL,UPL,XPL) is used to indicate the DPL for system gates only. + * + * This distinction is important to support para-virt guests on the + * 64-bit hypervisor. Both guest kernel and user run in ring 3 and the + * hypervisor runs in ring 0. When the kernel creates its trap and + * interrupt gates it needs a way to prevent any arbitrary int $n + * instruction from entering a gate that is not expected. The hypervisor + * allows these gates to have a DPL from 1 to 3. By creating gates + * with a DPL below user (ring 3) the int $n will generate a #gp fault + * which the hypervisor catches and forwards to the guest. + */ +#if defined(__xpv) + +#define SEL_XPL 0 /* hypervisor privilege level */ +#define SEL_KPL 3 /* both kernel and user in ring 3 */ +#define TRP_KPL 1 /* system gate priv (user blocked) */ +#define TRP_XPL 0 /* system gate priv (hypervisor) */ + +#define IST_DBG 0 + +#else /* __xpv */ + +#define SEL_KPL 0 /* kernel privilege level on metal */ +#define TRP_KPL SEL_KPL /* system gate priv (user blocked) */ + + +#define IST_DF 1 +#define IST_NMI 2 +#define IST_MCE 3 +#define IST_DBG 4 +#define IST_NESTABLE 5 +#define IST_DEFAULT 6 + +#endif /* __xpv */ + +#define IST_NONE 0 + +#define SEL_UPL 3 /* user priority level */ +#define TRP_UPL 3 /* system gate priv (user allowed) */ +#define SEL_TI_LDT 4 /* local descriptor table */ +#define SEL_LDT(s) (IDXTOSEL(s) | SEL_TI_LDT | SEL_UPL) /* local sel */ +#define CPL_MASK 3 /* RPL mask for selector */ +#define SELISLDT(s) (((s) & SEL_TI_LDT) == SEL_TI_LDT) +#define SELISUPL(s) (((s) & CPL_MASK) == SEL_UPL) + +#ifndef _ASM + +typedef uint16_t selector_t; /* selector reigster */ + +/* + * Hardware descriptor table register format for GDT and IDT. + */ +#if defined(__amd64) + +#pragma pack(2) +typedef struct { + uint16_t dtr_limit; /* table limit */ + uint64_t dtr_base; /* table base address */ +} desctbr_t; +#pragma pack() + +#elif defined(__i386) + +#pragma pack(2) +typedef struct { + uint16_t dtr_limit; /* table limit */ + uint32_t dtr_base; /* table base address */ +} desctbr_t; +#pragma pack() + +#endif /* __i386 */ + +/* + * Functions for loading and storing descriptor table + * registers. + */ +extern void rd_idtr(desctbr_t *); +extern void wr_idtr(desctbr_t *); +extern void rd_gdtr(desctbr_t *); +extern void wr_gdtr(desctbr_t *); +extern void wr_ldtr(selector_t); +extern selector_t rd_ldtr(void); +extern void wr_tsr(selector_t); +extern void kmdb_enter(void); + +#if defined(__amd64) + +/* + * inlines for update_segregs + */ +extern void __set_ds(selector_t); +extern void __set_es(selector_t); +extern void __set_fs(selector_t); +extern void __set_gs(selector_t); +#endif /* __amd64 */ + +#if defined(__amd64) +extern void load_segment_registers(selector_t, selector_t, selector_t, + selector_t); /* (alphabetical) */ +#elif defined(__i386) +extern void load_segment_registers(selector_t, selector_t, selector_t, + selector_t, selector_t, selector_t); /* (alphabetical) */ +#endif /* __i386 */ + +#ifdef _KERNEL +selector_t get_cs_register(); +#endif /* _KERNEL */ + +#if !defined(__amd64) + +/* + * User segment descriptors (code and data). + * Legacy mode 64-bits wide. + */ +typedef struct user_desc { + uint32_t usd_lolimit:16; /* segment limit 15:0 */ + uint32_t usd_lobase:16; /* segment base 15:0 */ + uint32_t usd_midbase:8; /* segment base 23:16 */ + uint32_t usd_type:5; /* segment type, includes S bit */ + uint32_t usd_dpl:2; /* segment descriptor priority level */ + uint32_t usd_p:1; /* segment descriptor present */ + uint32_t usd_hilimit:4; /* segment limit 19:16 */ + uint32_t usd_avl:1; /* available to sw, but not used */ + uint32_t usd_reserved:1; /* unused, ignored */ + uint32_t usd_def32:1; /* default 32 vs 16 bit operand */ + uint32_t usd_gran:1; /* limit units (bytes vs pages) */ + uint32_t usd_hibase:8; /* segment base 31:24 */ +} user_desc_t; + +#define USEGD_GETBASE(usd) ((usd)->usd_lobase | \ + (usd)->usd_midbase << 16 | \ + (usd)->usd_hibase << (16 + 8)) + +#define USEGD_SETBASE(usd, b) ((usd)->usd_lobase = (b), \ + (usd)->usd_midbase = (b) >> 16, \ + (usd)->usd_hibase = (b) >> (16 + 8)) + +#define USEGD_GETLIMIT(usd) ((usd)->usd_lolimit | \ + (usd)->usd_hilimit << 16) + +#define USEGD_SETLIMIT(usd, lim) ((usd)->usd_lolimit = lim, \ + (usd)->usd_hilimit = lim >> 16) + +#define USD_TYPESHIFT 5 /* size of usd_type field */ + +#else /* __amd64 */ + +/* + * User segment descriptors. + * Long mode 64-bits wide. + * + * In 32-bit compatibility mode (%cs:usd_long=0) all fields are interpreted + * as in legacy mode for both code and data. + * + * In 64-bit mode (%cs:usd_long=1) code segments only have the conforming + * bit in usd_type, usd_dpl, usd_p, usd_long and usd_def32=0. usd_def32 + * must be zero in 64-bit mode. Setting it to 1 is reserved for future use. + * All other fields are loaded but ignored by hardware. + * + * 64-bit data segments only have usd_p. All other fields are loaded but + * ignored by hardware when in 64-bit mode. + */ +typedef struct user_desc { + uint64_t usd_lolimit:16; /* segment limit 15:0 */ + uint64_t usd_lobase:16; /* segment base 15:0 */ + uint64_t usd_midbase:8; /* segment base 23:16 */ + uint64_t usd_type:5; /* segment type, includes S bit */ + uint64_t usd_dpl:2; /* segment descriptor priority level */ + uint64_t usd_p:1; /* segment descriptor present */ + uint64_t usd_hilimit:4; /* segment limit 19:16 */ + uint64_t usd_avl:1; /* available to sw, but not used */ + uint64_t usd_long:1; /* long mode (%cs only) */ + uint64_t usd_def32:1; /* default 32 vs 16 bit operand */ + uint64_t usd_gran:1; /* limit units (bytes vs page) */ + uint64_t usd_hibase:8; /* segment base 31:24 */ +} user_desc_t; + +#define USEGD_GETBASE(usd) ((usd)->usd_lobase | \ + (usd)->usd_midbase << 16 | \ + (usd)->usd_hibase << (16 + 8)) + +#define USEGD_SETBASE(usd, b) ((usd)->usd_lobase = (b), \ + (usd)->usd_midbase = (b) >> 16, \ + (usd)->usd_hibase = (b) >> (16 + 8)) + +#define USEGD_GETLIMIT(usd) ((usd)->usd_lolimit | \ + (usd)->usd_hilimit << 16) + +#define USEGD_SETLIMIT(usd, lim) ((usd)->usd_lolimit = lim, \ + (usd)->usd_hilimit = lim >> 16) + +#define USD_TYPESHIFT 5 /* size of usd_type field */ + +#endif /* __amd64 */ + +#if !defined(__amd64) + +/* + * System segment descriptors for LDT and TSS segments. + * Legacy mode 64-bits wide. + */ +typedef struct system_desc { + uint32_t ssd_lolimit:16; /* segment limit 15:0 */ + uint32_t ssd_lobase:16; /* segment base 15:0 */ + uint32_t ssd_midbase:8; /* segment base 23:16 */ + uint32_t ssd_type:4; /* segment type */ + uint32_t ssd_zero:1; /* must be zero */ + uint32_t ssd_dpl:2; /* segment descriptor priority level */ + uint32_t ssd_p:1; /* segment descriptor present */ + uint32_t ssd_hilimit:4; /* segment limit 19:16 */ + uint32_t ssd_avl:1; /* available to sw, but not used */ + uint32_t ssd_reserved:2; /* unused, ignored */ + uint32_t ssd_gran:1; /* limit unit (bytes vs pages) */ + uint32_t ssd_hibase:8; /* segment base 31:24 */ +} system_desc_t; + +#else /* __amd64 */ + +/* + * System segment descriptors for LDT and TSS segments. + * Long mode 128-bits wide. + * + * 32-bit LDT and TSS descriptor types are redefined to 64-bit equivalents. + * All other legacy types are reserved and illegal. + */ +typedef struct system_desc { + uint64_t ssd_lolimit:16; /* segment limit 15:0 */ + uint64_t ssd_lobase:16; /* segment base 15:0 */ + uint64_t ssd_midbase:8; /* segment base 23:16 */ + uint64_t ssd_type:4; /* segment type */ + uint64_t ssd_zero1:1; /* must be zero */ + uint64_t ssd_dpl:2; /* segment descriptor priority level */ + uint64_t ssd_p:1; /* segment descriptor present */ + uint64_t ssd_hilimit:4; /* segment limit 19:16 */ + uint64_t ssd_avl:1; /* available to sw, but not used */ + uint64_t ssd_resv1:2; /* unused, ignored */ + uint64_t ssd_gran:1; /* limit unit (bytes vs pages) */ + uint64_t ssd_hibase:8; /* segment base 31:24 */ + uint64_t ssd_hi64base:32; /* segment base 63:32 */ + uint64_t ssd_resv2:8; /* unused, ignored */ + uint64_t ssd_zero2:5; /* must be zero */ + uint64_t ssd_resv3:19; /* unused, ignored */ +} system_desc_t; + +#endif /* __amd64 */ + +#define SYSSEGD_SETLIMIT(ssd, lim) ((ssd)->ssd_lolimit = lim, \ + (ssd)->ssd_hilimit = lim >> 16) + +#define SYSSEGD_GETLIMIT(ssd) (((ssd)->ssd_hilimit << 16) | \ + (ssd)->ssd_lolimit) + +#if !defined(__amd64) + +/* + * System gate segment descriptors for interrupt, trap, call and task gates. + * Legacy mode 64-bits wide. + */ +typedef struct gate_desc { + uint32_t sgd_looffset:16; /* segment code offset 15:0 */ + uint32_t sgd_selector:16; /* target code or task selector */ + uint32_t sgd_stkcpy:5; /* number of stack wds to cpy */ + uint32_t sgd_resv:3; /* unused, ignored */ + uint32_t sgd_type:5; /* segment type, includes S bit */ + uint32_t sgd_dpl:2; /* segment descriptor priority level */ + uint32_t sgd_p:1; /* segment descriptor present */ + uint32_t sgd_hioffset:16; /* code seg off 31:16 */ +} gate_desc_t; + +#define GATESEG_GETOFFSET(sgd) ((uintptr_t)((sgd)->sgd_looffset | \ + (sgd)->sgd_hioffset << 16)) + +#else /* __amd64 */ + +/* + * System segment descriptors for interrupt, trap and call gates. + * Long mode 128-bits wide. + * + * 32-bit interrupt, trap and call gate types are redefined to 64-bit + * equivalents. Task gates along with all other legacy types are reserved + * and illegal. + */ +typedef struct gate_desc { + uint64_t sgd_looffset:16; /* segment code offset 15:0 */ + uint64_t sgd_selector:16; /* target code or task selector */ + uint64_t sgd_ist:3; /* IST table index */ + uint64_t sgd_resv1:5; /* unused, ignored */ + uint64_t sgd_type:5; /* segment type, includes S bit */ + uint64_t sgd_dpl:2; /* segment descriptor priority level */ + uint64_t sgd_p:1; /* segment descriptor present */ + uint64_t sgd_hioffset:16; /* segment code offset 31:16 */ + uint64_t sgd_hi64offset:32; /* segment code offset 63:32 */ + uint64_t sgd_resv2:8; /* unused, ignored */ + uint64_t sgd_zero:5; /* call gate only: must be zero */ + uint64_t sgd_resv3:19; /* unused, ignored */ +} gate_desc_t; + +#define GATESEG_GETOFFSET(sgd) ((uintptr_t)((sgd)->sgd_looffset | \ + (sgd)->sgd_hioffset << 16 | \ + (uint64_t)((sgd)->sgd_hi64offset) << 32)) + +#endif /* __amd64 */ + +/* + * functions for initializing and updating segment descriptors. + */ +#if defined(__amd64) + +extern void set_usegd(user_desc_t *, uint_t, void *, uint32_t, uint_t, uint_t, + uint_t, uint_t); + +#elif defined(__i386) + +extern void set_usegd(user_desc_t *, void *, size_t, uint_t, uint_t, + uint_t, uint_t); + +#endif /* __i386 */ + +extern uint_t idt_vector_to_ist(uint_t); + +extern void set_gatesegd(gate_desc_t *, void (*)(void), selector_t, + uint_t, uint_t, uint_t); + +extern void set_syssegd(system_desc_t *, void *, size_t, uint_t, uint_t); + +extern void *get_ssd_base(system_desc_t *); + +extern void gdt_update_usegd(uint_t, user_desc_t *); + +extern int ldt_update_segd(user_desc_t *, user_desc_t *); + +#if defined(__xpv) + +extern int xen_idt_to_trap_info(uint_t, gate_desc_t *, void *); +extern void xen_idt_write(gate_desc_t *, uint_t); + +#endif /* __xen */ + +void init_boot_gdt(user_desc_t *); + +#endif /* _ASM */ + +/* + * Common segment parameter defintions for granularity, default + * operand size and operaton mode. + */ +#define SDP_BYTES 0 /* segment limit scaled to bytes */ +#define SDP_PAGES 1 /* segment limit scaled to pages */ +#define SDP_OP32 1 /* code and data default operand = 32 bits */ +#define SDP_LONG 1 /* long mode code segment (64 bits) */ +#define SDP_SHORT 0 /* compat/legacy code segment (32 bits) */ + +/* + * The maximum segment limit that can be put into a segment descriptor for + * 16-bit and 32-bit segments. In 64-bit mode, segment base addresses are + * fixed to 0 and the segment limit is ignored. + */ +#define SDP_LIMIT_MAX 0xFFFFFU + +/* + * System segments and gate types. + * + * In long mode i386 32-bit ldt, tss, call, interrupt and trap gate + * types are redefined into 64-bit equivalents. + */ +#define SDT_SYSNULL 0 /* system null */ +#define SDT_SYS286TSS 1 /* system 286 TSS available */ +#define SDT_SYSLDT 2 /* system local descriptor table */ +#define SDT_SYS286BSY 3 /* system 286 TSS busy */ +#define SDT_SYS286CGT 4 /* system 286 call gate */ +#define SDT_SYSTASKGT 5 /* system task gate */ +#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ +#define SDT_SYS286TGT 7 /* system 286 trap gate */ +#define SDT_SYSNULL2 8 /* system null again */ +#define SDT_SYSTSS 9 /* system TSS available */ +#define SDT_SYSNULL3 10 /* system null again */ +#define SDT_SYSTSSBSY 11 /* system TSS busy */ +#define SDT_SYSCGT 12 /* system call gate */ +#define SDT_SYSNULL4 13 /* system null again */ +#define SDT_SYSIGT 14 /* system interrupt gate */ +#define SDT_SYSTGT 15 /* system trap gate */ + +/* + * Memory segment types. + * + * While in long mode expand-down, writable and accessed type field + * attributes are ignored. Only the conforming bit is loaded by hardware + * for long mode code segment descriptors. + */ +#define SDT_MEMRO 16 /* read only */ +#define SDT_MEMROA 17 /* read only accessed */ +#define SDT_MEMRW 18 /* read write */ +#define SDT_MEMRWA 19 /* read write accessed */ +#define SDT_MEMROD 20 /* read only expand dwn limit */ +#define SDT_MEMRODA 21 /* read only expand dwn limit accessed */ +#define SDT_MEMRWD 22 /* read write expand dwn limit */ +#define SDT_MEMRWDA 23 /* read write expand dwn limit accessed */ +#define SDT_MEME 24 /* execute only */ +#define SDT_MEMEA 25 /* execute only accessed */ +#define SDT_MEMER 26 /* execute read */ +#define SDT_MEMERA 27 /* execute read accessed */ +#define SDT_MEMEC 28 /* execute only conforming */ +#define SDT_MEMEAC 29 /* execute only accessed conforming */ +#define SDT_MEMERC 30 /* execute read conforming */ +#define SDT_MEMERAC 31 /* execute read accessed conforming */ + +/* These bits are within the "type" field, like the values above. */ +#define SDT_A 0x01 /* accessed bit */ +#define SDT_S 0x10 /* S-bit at the top of "type" for usegs */ + +/* + * Entries in the Interrupt Descriptor Table (IDT) + */ +#define IDT_DE 0 /* #DE: Divide Error */ +#define IDT_DB 1 /* #DB: Debug */ +#define IDT_NMI 2 /* Nonmaskable External Interrupt */ +#define IDT_BP 3 /* #BP: Breakpoint */ +#define IDT_OF 4 /* #OF: Overflow */ +#define IDT_BR 5 /* #BR: Bound Range Exceeded */ +#define IDT_UD 6 /* #UD: Undefined/Invalid Opcode */ +#define IDT_NM 7 /* #NM: No Math Coprocessor */ +#define IDT_DF 8 /* #DF: Double Fault */ +#define IDT_FPUGP 9 /* Coprocessor Segment Overrun */ +#define IDT_TS 10 /* #TS: Invalid TSS */ +#define IDT_NP 11 /* #NP: Segment Not Present */ +#define IDT_SS 12 /* #SS: Stack Segment Fault */ +#define IDT_GP 13 /* #GP: General Protection Fault */ +#define IDT_PF 14 /* #PF: Page Fault */ +#define IDT_MF 16 /* #MF: FPU Floating-Point Error */ +#define IDT_AC 17 /* #AC: Alignment Check */ +#define IDT_MC 18 /* #MC: Machine Check */ +#define IDT_XF 19 /* #XF: SIMD Floating-Point Exception */ +#define NIDT 256 /* size in entries of IDT */ + +/* + * Entries in the Global Descriptor Table (GDT) + * + * We make sure to space the system descriptors (LDT's, TSS') + * such that they are double gdt slot aligned. This is because + * in long mode system segment decriptors expand to 128 bits. + * + * GDT_LWPFS and GDT_LWPGS must be the same for both 32 and 64-bit + * kernels. See setup_context in libc. 64-bit processes must set + * %fs or %gs to null selector to use 64-bit fsbase or gsbase + * respectively. + */ +#define GDT_NULL 0 /* null */ +#define GDT_B32DATA 1 /* dboot 32 bit data descriptor */ +#define GDT_B32CODE 2 /* dboot 32 bit code descriptor */ +#define GDT_B16CODE 3 /* bios call 16 bit code descriptor */ +#define GDT_B16DATA 4 /* bios call 16 bit data descriptor */ +#define GDT_B64CODE 5 /* dboot 64 bit code descriptor */ +#define GDT_BGSTMP 7 /* kmdb descriptor only used early in boot */ +#define GDT_CPUID 16 /* store numeric id of current CPU */ + +/* + * Early boot code may need to create a temporary GDT; + * this is the minimum length required. + */ +#define LEN_MIN_GDT_BOOT (GDT_B64CODE + 1) + +#if defined(__amd64) + +#define GDT_KCODE 6 /* kernel code seg %cs */ +#define GDT_KDATA 7 /* kernel data seg %ds */ +#define GDT_U32CODE 8 /* 32-bit process on 64-bit kernel %cs */ +#define GDT_UDATA 9 /* user data seg %ds (32 and 64 bit) */ +#define GDT_UCODE 10 /* native user code seg %cs */ +#define GDT_LDT 12 /* (12-13) LDT for current process */ +#define GDT_KTSS 14 /* (14-15) kernel tss */ +#define GDT_FS GDT_NULL /* kernel %fs segment selector */ +#define GDT_GS GDT_NULL /* kernel %gs segment selector */ +#define GDT_LWPFS 55 /* lwp private %fs segment selector (32-bit) */ +#define GDT_LWPGS 56 /* lwp private %gs segment selector (32-bit) */ +#define GDT_BRANDMIN 57 /* first entry in GDT for brand usage */ +#define GDT_BRANDMAX 61 /* last entry in GDT for brand usage */ +#define NGDT 62 /* number of entries in GDT */ + +/* + * This selector is only used in the temporary GDT used to bring additional + * CPUs from 16-bit real mode into long mode in real_mode_start(). + */ +#define TEMPGDT_KCODE64 1 /* 64-bit code selector */ + +#elif defined(__i386) + +#define GDT_LDT 40 /* LDT for current process */ +#define GDT_KTSS 42 /* kernel tss */ +#define GDT_KCODE 43 /* kernel code seg %cs */ +#define GDT_KDATA 44 /* kernel data seg %ds */ +#define GDT_UCODE 45 /* native user code seg %cs */ +#define GDT_UDATA 46 /* user data seg %ds (32 and 64 bit) */ +#define GDT_DBFLT 47 /* double fault #DF selector */ +#define GDT_FS 53 /* kernel %fs segment selector */ +#define GDT_GS 54 /* kernel %gs segment selector */ +#define GDT_LWPFS 55 /* lwp private %fs segment selector */ +#define GDT_LWPGS 56 /* lwp private %gs segment selector */ +#define GDT_BRANDMIN 57 /* first entry in GDT for brand usage */ +#define GDT_BRANDMAX 61 /* last entry in GDT for brand usage */ +#if !defined(__xpv) +#define NGDT 90 /* number of entries in GDT */ +#else +#define NGDT 512 /* single 4K page for the hypervisor */ +#endif + +#endif /* __i386 */ + +/* + * Convenient selector definitions. + */ + +/* + * XXPV 64 bit Xen only allows the guest %cs/%ss be the private ones it + * provides, not the ones we create for ourselves. See FLAT_RING3_CS64 in + * public/arch-x86_64.h + * + * 64-bit Xen runs paravirtual guests in ring 3 but emulates them running in + * ring 0 by clearing CPL in %cs value pushed on guest exception stacks. + * Therefore we will have KCS_SEL value indicate ring 0 and use that everywhere + * in the kernel. But in the few files where we initialize segment registers or + * create and update descriptors we will explicity OR in SEL_KPL (ring 3) for + * kernel %cs. See desctbls.c for an example. + */ + +#if defined(__xpv) && defined(__amd64) +#define KCS_SEL 0xe030 /* FLAT_RING3_CS64 & 0xFFF0 */ +#define KDS_SEL 0xe02b /* FLAT_RING3_SS64 */ +#else +#define KCS_SEL SEL_GDT(GDT_KCODE, SEL_KPL) +#define KDS_SEL SEL_GDT(GDT_KDATA, SEL_KPL) +#endif + +#define UCS_SEL SEL_GDT(GDT_UCODE, SEL_UPL) +#if defined(__amd64) +#define TEMP_CS64_SEL SEL_GDT(TEMPGDT_KCODE64, SEL_KPL) +#define U32CS_SEL SEL_GDT(GDT_U32CODE, SEL_UPL) +#endif + +#define UDS_SEL SEL_GDT(GDT_UDATA, SEL_UPL) +#define ULDT_SEL SEL_GDT(GDT_LDT, SEL_KPL) +#define KTSS_SEL SEL_GDT(GDT_KTSS, SEL_KPL) +#define DFTSS_SEL SEL_GDT(GDT_DBFLT, SEL_KPL) +#define KFS_SEL 0 +#define KGS_SEL SEL_GDT(GDT_GS, SEL_KPL) +#define LWPFS_SEL SEL_GDT(GDT_LWPFS, SEL_UPL) +#define LWPGS_SEL SEL_GDT(GDT_LWPGS, SEL_UPL) +#define BRANDMIN_SEL SEL_GDT(GDT_BRANDMIN, SEL_UPL) +#define BRANDMAX_SEL SEL_GDT(GDT_BRANDMAX, SEL_UPL) + +#define B64CODE_SEL SEL_GDT(GDT_B64CODE, SEL_KPL) +#define B32CODE_SEL SEL_GDT(GDT_B32CODE, SEL_KPL) +#define B32DATA_SEL SEL_GDT(GDT_B32DATA, SEL_KPL) +#define B16CODE_SEL SEL_GDT(GDT_B16CODE, SEL_KPL) +#define B16DATA_SEL SEL_GDT(GDT_B16DATA, SEL_KPL) + +/* + * Temporary %gs descriptor used by kmdb with -d option. Only lives + * in boot's GDT and is not copied into kernel's GDT from boot. + */ +#define KMDBGS_SEL SEL_GDT(GDT_BGSTMP, SEL_KPL) + +/* + * Selector used for kdi_idt when kmdb has taken over the IDT. + */ +#if defined(__amd64) +#define KMDBCODE_SEL B64CODE_SEL +#else +#define KMDBCODE_SEL B32CODE_SEL +#endif + +/* + * Entries in default Local Descriptor Table (LDT) for every process. + */ +#define LDT_SYSCALL 0 /* call gate for libc.a (obsolete) */ +#define LDT_SIGCALL 1 /* EOL me, call gate for static sigreturn */ +#define LDT_RESVD1 2 /* old user %cs */ +#define LDT_RESVD2 3 /* old user %ds */ +#define LDT_ALTSYSCALL 4 /* alternate call gate for system calls */ +#define LDT_ALTSIGCALL 5 /* EOL me, alternate call gate for sigreturn */ +#define LDT_UDBASE 6 /* user descriptor base index */ +#define MINNLDT 512 /* Current min solaris ldt size (1 4K page) */ +#define MAXNLDT 8192 /* max solaris ldt size (16 4K pages) */ + +#ifdef _KERNEL +#define LDT_CPU_SIZE (16 * 4096) /* Size of kernel per-CPU allocation */ +#endif + +#ifndef _ASM + +extern gate_desc_t *idt0; +extern desctbr_t idt0_default_reg; +extern user_desc_t *gdt0; + +extern user_desc_t zero_udesc; +extern user_desc_t null_udesc; +extern system_desc_t null_sdesc; + +#if defined(__amd64) +extern user_desc_t zero_u32desc; +#endif +#if defined(__amd64) +extern user_desc_t ucs_on; +extern user_desc_t ucs_off; +extern user_desc_t ucs32_on; +extern user_desc_t ucs32_off; +#endif /* __amd64 */ + +extern tss_t *ktss0; + +#if defined(__i386) +extern tss_t *dftss0; +#endif /* __i386 */ + +#ifdef _KERNEL +extern void div0trap(), dbgtrap(), nmiint(), brktrap(), ovflotrap(); +extern void boundstrap(), invoptrap(), ndptrap(); +#if !defined(__xpv) +extern void syserrtrap(); +#endif +extern void invaltrap(), invtsstrap(), segnptrap(), stktrap(); +extern void gptrap(), pftrap(), ndperr(); +extern void overrun(), resvtrap(); +extern void _start(), cmnint(); +extern void achktrap(), mcetrap(); +extern void xmtrap(); +extern void fasttrap(); +extern void sys_int80(); +extern void brand_sys_int80(); +extern void dtrace_ret(); + +/* KPTI trampolines */ +extern void tr_invaltrap(); +extern void tr_div0trap(), tr_dbgtrap(), tr_nmiint(), tr_brktrap(); +extern void tr_ovflotrap(), tr_boundstrap(), tr_invoptrap(), tr_ndptrap(); +#if !defined(__xpv) +extern void tr_syserrtrap(); +#endif +extern void tr_invaltrap(), tr_invtsstrap(), tr_segnptrap(), tr_stktrap(); +extern void tr_gptrap(), tr_pftrap(), tr_ndperr(); +extern void tr_overrun(), tr_resvtrap(); +extern void tr_achktrap(), tr_mcetrap(); +extern void tr_xmtrap(); +extern void tr_fasttrap(); +extern void tr_sys_int80(); +extern void tr_brand_sys_int80(); +extern void tr_dtrace_ret(); + +#if !defined(__amd64) +extern void pentium_pftrap(); +#endif + +extern uint64_t kpti_enable; +#endif /* _KERNEL */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SEGMENTS_H */ diff --git a/illumos-x86_64/usr/include/sys/select.h b/illumos-x86_64/usr/include/sys/select.h new file mode 100644 index 00000000..01c561c4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/select.h @@ -0,0 +1,159 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H + +#include + +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +#include +#endif +#include +#endif /* !_KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +/* + * The sigset_t type is defined in and duplicated + * in as a result of XPG4v2 requirements. XPG6 + * now allows the visibility of signal.h in this header, however + * an order of inclusion problem occurs as a result of inclusion + * of in under certain conditions. + * Rather than include here, we've duplicated + * the sigset_t type instead. This type is required for the XPG6 + * introduced pselect() function also declared in this header. + */ +#ifndef _SIGSET_T +#define _SIGSET_T +typedef struct { /* signal set type */ + unsigned int __sigbits[4]; +} sigset_t; +#endif /* _SIGSET_T */ + +#endif /* #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */ + +/* + * Select uses bit masks of file descriptors in longs. + * These macros manipulate such bit fields. + * FD_SETSIZE may be defined by the user, but the default here + * should be >= RLIM_FD_MAX. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 65536 +#endif /* FD_SETSIZE */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +typedef long fd_mask; +#endif +typedef long fds_mask; + +/* + * The value of _NBBY needs to be consistant with the value + * of NBBY in . + */ +#define _NBBY 8 +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#ifndef NBBY /* number of bits per byte */ +#define NBBY _NBBY +#endif +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ +#endif +#define FD_NFDBITS (sizeof (fds_mask) * _NBBY) /* bits per mask */ + +#define __howmany(__x, __y) (((__x)+((__y)-1))/(__y)) +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +typedef struct fd_set { +#else +typedef struct __fd_set { +#endif + long fds_bits[__howmany(FD_SETSIZE, FD_NFDBITS)]; +} fd_set; + +#define FD_SET(__n, __p) ((__p)->fds_bits[(__n)/FD_NFDBITS] |= \ + (1ul << ((__n) % FD_NFDBITS))) + +#define FD_CLR(__n, __p) ((__p)->fds_bits[(__n)/FD_NFDBITS] &= \ + ~(1ul << ((__n) % FD_NFDBITS))) + +#define FD_ISSET(__n, __p) (((__p)->fds_bits[(__n)/FD_NFDBITS] & \ + (1ul << ((__n) % FD_NFDBITS))) != 0l) + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#define FD_ZERO(p) bzero((p), sizeof (*(p))) +#else +extern void *_memset(void *, int, size_t); +#define FD_ZERO(__p) (void) _memset((__p), 0, sizeof (*(__p))) +#endif /* _KERNEL */ + +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) +extern int select(int, fd_set *_RESTRICT_KYWD, fd_set *_RESTRICT_KYWD, + fd_set *_RESTRICT_KYWD, struct timeval *_RESTRICT_KYWD); + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +extern int pselect(int, fd_set *_RESTRICT_KYWD, fd_set *_RESTRICT_KYWD, + fd_set *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD, + const sigset_t *_RESTRICT_KYWD); +#endif + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SELECT_H */ diff --git a/illumos-x86_64/usr/include/sys/sem.h b/illumos-x86_64/usr/include/sys/sem.h new file mode 100644 index 00000000..52c37628 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sem.h @@ -0,0 +1,119 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_SEM_H +#define _SYS_SEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * IPC Semaphore Facility. + */ + +/* + * Implementation Constants. + */ + +/* + * Permission Definitions. + */ + +#define SEM_A 0200 /* alter permission */ +#define SEM_R 0400 /* read permission */ + +/* + * Semaphore Operation Flags. + */ + +#define SEM_UNDO 010000 /* set up adjust on exit entry */ + +/* + * Semctl Command Definitions. + */ + +#define GETNCNT 3 /* get semncnt */ +#define GETPID 4 /* get sempid */ +#define GETVAL 5 /* get semval */ +#define GETALL 6 /* get all semval's */ +#define GETZCNT 7 /* get semzcnt */ +#define SETVAL 8 /* set semval */ +#define SETALL 9 /* set all semval's */ + +/* + * Structure Definitions. + */ + +struct semid_ds { + struct ipc_perm sem_perm; /* operation permission struct */ + struct sem *sem_base; /* ptr to first semaphore in set */ + ushort_t sem_nsems; /* # of semaphores in set */ +#if defined(_LP64) + time_t sem_otime; /* last semop time */ + time_t sem_ctime; /* last change time */ +#else /* _LP64 */ + time_t sem_otime; /* last semop time */ + int32_t sem_pad1; /* reserved for time_t expansion */ + time_t sem_ctime; /* last change time */ + int32_t sem_pad2; /* time_t expansion */ +#endif /* _LP64 */ + int sem_binary; /* flag indicating semaphore type */ + long sem_pad3[3]; /* reserve area */ +}; + +/* + * User semaphore template for semop system calls. + */ +struct sembuf { + ushort_t sem_num; /* semaphore # */ + short sem_op; /* semaphore operation */ + short sem_flg; /* operation flags */ +}; + +#if !defined(_KERNEL) +int semctl(int, int, int, ...); +int semget(key_t, int, int); +int semids(int *, uint_t, uint_t *); +int semop(int, struct sembuf *, size_t); +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) +int semtimedop(int, struct sembuf *, size_t, const struct timespec *); +#endif +#endif /* ! _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SEM_H */ diff --git a/illumos-x86_64/usr/include/sys/sem_impl.h b/illumos-x86_64/usr/include/sys/sem_impl.h new file mode 100644 index 00000000..6fb68b9c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sem_impl.h @@ -0,0 +1,121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_SEM_IMPL_H +#define _SYS_SEM_IMPL_H + +#include +#if defined(_KERNEL) || defined(_KMEMUSER) +#include +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Argument vectors for the various flavors of semsys(). + */ + +#define SEMCTL 0 +#define SEMGET 1 +#define SEMOP 2 +#define SEMIDS 3 +#define SEMTIMEDOP 4 + +#if defined(_KERNEL) || defined(_KMEMUSER) + +/* + * There is one semaphore id data structure (semid_ds) for each set of + * semaphores in the system. + */ +typedef struct ksemid { + kipc_perm_t sem_perm; /* operation permission struct */ + struct sem *sem_base; /* ptr to first semaphore in set */ + ushort_t sem_nsems; /* # of semaphores in set */ + time_t sem_otime; /* last semop time */ + time_t sem_ctime; /* last change time */ + int sem_binary; /* flag indicating semaphore type */ + int sem_maxops; /* maximum number of operations */ + list_t sem_undos; /* list of undo structures */ +} ksemid_t; + +/* + * There is one semaphore structure (sem) for each semaphore in the system. + */ +struct sem { + ushort_t semval; /* semaphore value */ + pid_t sempid; /* pid of last operation */ + ushort_t semncnt; /* # awaiting semval > cval */ + ushort_t semzcnt; /* # awaiting semval = 0 */ + kcondvar_t semncnt_cv; + kcondvar_t semzcnt_cv; +}; + +/* + * There is one undo structure per process in the system. + */ +struct sem_undo { + avl_node_t un_avl; /* node in per-process avl tree */ + list_node_t un_list; /* ptr to next active undo structure */ + proc_t *un_proc; /* back-pointer to process */ + ksemid_t *un_sp; /* back-pointer to semaphore */ + int un_aoe[1]; /* adjust on exit values */ +}; +#endif /* _KERNEL */ + +#if defined(_SYSCALL32) +/* + * LP64 view of the ILP32 semid_ds structure + */ +struct semid_ds32 { + struct ipc_perm32 sem_perm; /* operation permission struct */ + caddr32_t sem_base; /* ptr to first semaphore in set */ + uint16_t sem_nsems; /* # of semaphores in set */ + time32_t sem_otime; /* last semop time */ + int32_t sem_pad1; /* reserved for time_t expansion */ + time32_t sem_ctime; /* last semop time */ + int32_t sem_pad2; /* reserved for time_t expansion */ + int32_t sem_binary; /* flag indicating semaphore type */ + int32_t sem_pad3[3]; /* reserve area */ +}; +#endif + +#ifdef _KERNEL +extern void semexit(proc_t *); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SEM_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/sema_impl.h b/illumos-x86_64/usr/include/sys/sema_impl.h new file mode 100644 index 00000000..7e39420f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sema_impl.h @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993-1997 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * semaphore.h: + * + * definitions for thread synchronization primitives: + * mutexs, semaphores, condition variables, and readers/writer + * locks. + */ + +#ifndef _SYS_SEMA_IMPL_H +#define _SYS_SEMA_IMPL_H + +#ifndef _ASM +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* + * Semaphores. + */ + +typedef struct _sema_impl { + struct _kthread *s_slpq; + int s_count; +} sema_impl_t; + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SEMA_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/semaphore.h b/illumos-x86_64/usr/include/sys/semaphore.h new file mode 100644 index 00000000..0bfb5d1c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/semaphore.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SEMAPHORE_H +#define _SYS_SEMAPHORE_H + +/* + * Public interface to semaphores. See semaphore(9F) for details. + */ + +#ifndef _ASM + +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + SEMA_DEFAULT, + SEMA_DRIVER +} ksema_type_t; + +typedef struct _ksema { + void * _opaque[2]; /* 2 words on 4 byte alignment */ +} ksema_t; + +#if defined(_KERNEL) + +#define SEMA_HELD(x) (sema_held((x))) + +extern void sema_init(ksema_t *, uint32_t, char *, ksema_type_t, void *); +extern void sema_destroy(ksema_t *); +extern void sema_p(ksema_t *); +extern int sema_p_sig(ksema_t *); +extern void sema_v(ksema_t *); +extern int sema_tryp(ksema_t *); +extern int sema_held(ksema_t *); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASM */ + +#endif /* _SYS_SEMAPHORE_H */ diff --git a/illumos-x86_64/usr/include/sys/sendfile.h b/illumos-x86_64/usr/include/sys/sendfile.h new file mode 100644 index 00000000..22bce8cc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sendfile.h @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SENDFILE_H +#define _SYS_SENDFILE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Structure used by sendfilev() + */ +typedef struct sendfilevec { + int sfv_fd; + uint_t sfv_flag; + off_t sfv_off; + size_t sfv_len; +} sendfilevec_t; + +#define SFV_NOWAIT 1 + +#if defined(_LARGEFILE64_SOURCE) +/* + * For 32-bit apps accessing largefile offsets + * using sendfilev64. + */ +typedef struct sendfilevec64 { + int sfv_fd; + uint_t sfv_flag; + off64_t sfv_off; + size_t sfv_len; +} sendfilevec64_t; +#endif /* _LARGEFILE64_SOURCE */ + +#if defined(_SYSCALL32) +/* + * For 32-bit app on a 64-bit kernel to copyin the data. + */ +typedef struct ksendfilevec32 { + int sfv_fd; + uint_t sfv_flag; + off32_t sfv_off; + size32_t sfv_len; +} ksendfilevec32_t; + +/* + * For 32-bit app on a 64-bit kernel in largefile environment + * (sendfilev64) to copyin data. Use pack(4) on amd64 kernel + * to make sizeof(ksendfilevec64_t) == sizeof(sendfilevec64_t). + */ + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct ksendfilevec64 { + int sfv_fd; + uint_t sfv_flag; + off64_t sfv_off; + size32_t sfv_len; +} ksendfilevec64_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ + + +/* The sfv_fd can be a file descriptor or self proc */ +#define SFV_FD_SELF (-2) + +/* System call subcodes */ +#define SENDFILEV 0 +#define SENDFILEV64 1 + +#ifndef _KERNEL +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname sendfilev sendfilev64 +#pragma redefine_extname sendfile sendfile64 +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define sendfilev sendfilev64 +#define sendfile sendfile64 +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +/* In the LP64 compilation environment, the APIs are already large file */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname sendfilev64 sendfilev +#pragma redefine_extname sendfile64 sendfile +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define sendfilev64 sendfilev +#define sendfile64 sendfile +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern ssize_t sendfilev(int, const struct sendfilevec *, int, size_t *); +extern ssize_t sendfile(int, int, off_t *, size_t); +/* Transitional largefile interface */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern ssize_t sendfilev64(int, const struct sendfilevec64 *, int, size_t *); +extern ssize_t sendfile64(int, int, off64_t *, size_t); +#endif +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SENDFILE_H */ diff --git a/illumos-x86_64/usr/include/sys/sensors.h b/illumos-x86_64/usr/include/sys/sensors.h new file mode 100644 index 00000000..f5ff0796 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sensors.h @@ -0,0 +1,132 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2019, Joyent, Inc. + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_SENSORS_H +#define _SYS_SENSORS_H + +/* + * Consolidated sensor ioctls for various parts of the operating system. These + * interfaces should not be relied on at all. They are evolving and will change + * as we add more to the system for this. This may eventually become a larger + * framework, though it's more likely we'll consolidate that in userland. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * List of different possible kinds of sensors. + */ +#define SENSOR_KIND_UNKNOWN 0x00 +#define SENSOR_KIND_TEMPERATURE 0x01 +#define SENSOR_KIND_VOLTAGE 0x02 +#define SENSOR_KIND_CURRENT 0x03 +#define SENSOR_KIND_SYNTHETIC 0x04 + +/* + * Lists of units that sensors may have. The none type is intended for unitless + * sensors such as general control sensors. These sensors are generally derived + * from a secondary unit. A prime example is AMD's CPU control temperature, + * which is a unitless measure that is derived from temperature. + */ +#define SENSOR_UNIT_UNKNOWN 0x00 +#define SENSOR_UNIT_CELSIUS 0x01 +#define SENSOR_UNIT_FAHRENHEIT 0x02 +#define SENSOR_UNIT_KELVIN 0x03 +#define SENSOR_UNIT_VOLTS 0x04 +#define SENSOR_UNIT_AMPS 0x05 +#define SENSOR_UNIT_NONE 0x06 + +#define SENSOR_IOCTL (('s' << 24) | ('e' << 16) | ('n' << 8)) + +/* + * Ask the sensor what kind of sensor it is. + */ +#define SENSOR_IOCTL_KIND (SENSOR_IOCTL | 0x01) + +typedef struct sensor_ioctl_kind { + uint64_t sik_kind; + uint64_t sik_derive; +} sensor_ioctl_kind_t; + +/* + * Ask the sensor for a scalar measurement. The sensor is responsible for + * returning the units it's in. A scalar measurement is broken down into a + * signed value and a notion of its granularity. The sit_gran member indicates + * the granularity: the number of increments per unit in the measurement (the + * sit_value member). sit_gran is signed and the sign indicates whether one + * needs to multiply or divide the granularity. The sit_prec member describes a + * +/- value (taking sit_gran into account) that describes the precision of the + * sensor. + * + * For example, consider a temperature sensor that set sit_gran to 10. This + * would mean that the value in sit_value was in 10ths of a degree and that to + * get the actual value in degrees, one would divide by 10. On the other hand, a + * negative value means that we effectively have to multiply to get there. For + * example, a value of -2 would indicate that each value in sit_value indicated + * two degrees and to get the temperature in degrees you would multiply + * sit_value * by two. + */ +#define SENSOR_IOCTL_SCALAR (SENSOR_IOCTL | 0x02) + +typedef struct sensor_ioctl_scalar { + uint32_t sis_unit; + int32_t sis_gran; + uint32_t sis_prec; + uint32_t sis_pad; + int64_t sis_value; +} sensor_ioctl_scalar_t; + +#ifdef _KERNEL +typedef int (*ksensor_kind_f)(void *, sensor_ioctl_kind_t *); +typedef int (*ksensor_scalar_f)(void *, sensor_ioctl_scalar_t *); + +typedef struct { + ksensor_kind_f kso_kind; + ksensor_scalar_f kso_scalar; +} ksensor_ops_t; + +extern int ksensor_kind_temperature(void *, sensor_ioctl_kind_t *); +extern int ksensor_kind_voltage(void *, sensor_ioctl_kind_t *); +extern int ksensor_kind_current(void *, sensor_ioctl_kind_t *); + +/* + * Create a sensor where the class and name is supplied. + */ +extern int ksensor_create(dev_info_t *, const ksensor_ops_t *, void *, + const char *, const char *, id_t *); + +/* + * Create a scalar sensor for a PCI device. If this is not a device-wide + * (e.g. per-function) sensor, this should not be used. + */ +extern int ksensor_create_scalar_pcidev(dev_info_t *, uint64_t, + const ksensor_ops_t *, void *, const char *, id_t *); + +/* + * Remove a named or all sensors from this driver. + */ +#define KSENSOR_ALL_IDS INT_MIN +extern int ksensor_remove(dev_info_t *, id_t); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SENSORS_H */ diff --git a/illumos-x86_64/usr/include/sys/ser_sync.h b/illumos-x86_64/usr/include/sys/ser_sync.h new file mode 100644 index 00000000..f7f9b292 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ser_sync.h @@ -0,0 +1,258 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SER_SYNC_H +#define _SYS_SER_SYNC_H + +/* + * Initial port setup parameters for sync lines + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define zIOC ('z' << 8) + +#define S_IOCGETMODE (zIOC|01) /* return struct scc_mode */ +#define S_IOCSETMODE (zIOC|02) /* set SCC from struct scc_mode */ +#define S_IOCGETSTATS (zIOC|03) /* return sync data stats */ +#define S_IOCCLRSTATS (zIOC|04) /* clear sync stats */ +#define S_IOCGETSPEED (zIOC|05) /* return int baudrate */ +#define S_IOCGETMRU (zIOC|06) /* return int max receive unit */ +#define S_IOCSETMRU (zIOC|07) /* set max receive unit */ +#define S_IOCGETMTU (zIOC|010) /* return int max transmission unit */ +#define S_IOCSETMTU (zIOC|011) /* set max transmission unit */ +#define S_IOCGETMCTL (zIOC|012) /* return current CD/CTS state */ +#define S_IOCSETDTR (zIOC|013) /* Drive DTR signal */ + +/* reason codes for IOCSETMODE */ +#define SMERR_TXC 0x0001 /* transmit clock source not valid */ +#define SMERR_RXC 0x0002 /* receive clock source not valid */ +#define SMERR_IFLAGS 0x0004 /* inversion flags not valid */ +#define SMERR_HDX 0x0008 /* CONN_HDX set without CONN_IBM */ +#define SMERR_MPT 0x0010 /* CONN_MPT set without CONN_IBM */ +#define SMERR_LPBKS 0x0020 /* invalid loopback/echo combination */ +#define SMERR_BAUDRATE 0x0040 /* baudrate translates to 0 timeconst */ +#define SMERR_PLL 0x0080 /* PLL set with BRG or w/o NRZI */ + +/* + * Definitions for modes of operations of + * synchronous lines, both RS-232 and RS-449 + */ +struct scc_mode { + char sm_txclock; /* enum - transmit clock sources */ + char sm_rxclock; /* enum - receive clock sources */ + char sm_iflags; /* data and clock invert flags: see hsparam.h */ + uchar_t sm_config; /* see CONN defines below */ + int sm_baudrate; + int sm_retval; /* SMERR codes go here, query with GETMODE */ +}; + +/* + * defines for txclock + */ +#define TXC_IS_TXC 0 /* use incoming transmit clock */ +#define TXC_IS_RXC 1 /* use incoming receive clock */ +#define TXC_IS_BAUD 2 /* use baud rate generator */ +#define TXC_IS_PLL 3 /* use phase-lock loop output */ + +/* + * defines for rxclock + */ +#define RXC_IS_RXC 0 /* use incoming receive clock */ +#define RXC_IS_TXC 1 /* use incoming transmit clock */ +#define RXC_IS_BAUD 2 /* use baud rate - only good for loopback */ +#define RXC_IS_PLL 3 /* use phase-lock loop */ + +/* + * defines for clock/data inversion: from hsparam.h + */ +#define TXC_IS_SYSCLK 4 +#define RXC_IS_SYSCLK 4 +#define TXC_IS_INVERT 5 +#define RXC_IS_INVERT 5 +#define TRXD_NO_INVERT 0 +#define RXD_IS_INVERT 1 +#define TXD_IS_INVERT 2 +#define TRXD_IS_INVERT 3 + +/* + * defines for config + */ +#define CONN_HDX 0x01 /* half-duplex if set, else full-duplex */ +#define CONN_MPT 0x02 /* multipoint if set, else point-point */ +#define CONN_IBM 0x04 /* set up in IBM-SDLC mode */ +#define CONN_SIGNAL 0x08 /* report modem signal changes asynchronously */ +#define CONN_NRZI 0x10 /* boolean - use NRZI */ +#define CONN_LPBK 0x20 /* do internal loopback */ +#define CONN_ECHO 0x40 /* place in auto echo mode */ + +struct sl_status { + int type; + int status; + timestruc_t tstamp; +}; + +#if defined(_SYSCALL32) + +struct sl_status32 { + int32_t type; + int32_t status; + timestruc32_t tstamp; +}; + +#endif /* _SYSCALL32 */ + +/* + * defines for type field in sl_status + */ +#define SLS_MDMSTAT 0x01 /* Non-IBM modem line status change */ +#define SLS_LINKERR 0x02 /* IBM mode Link Error, usually modem line. */ + +/* + * defines for status field in sl_status + * DO NOT change the values for CS_(DCD|CTS)_(UP|DOWN)!!! + */ +#define CS_DCD_DOWN 0x08 +#define CS_DCD_UP 0x0c +#define CS_DCD_DROP 0x10 +#define CS_CTS_DOWN 0x20 +#define CS_CTS_UP 0x30 +#define CS_CTS_DROP 0x40 +#define CS_CTS_TO 0x80 +#define CS_DCD CS_DCD_DOWN +#define CS_CTS CS_CTS_DOWN + +/* + * Event statistics reported by hardware. + */ +struct sl_stats { + int ipack; /* input packets */ + int opack; /* output packets */ + int ichar; /* input bytes */ + int ochar; /* output bytes */ + int abort; /* abort received */ + int crc; /* CRC error */ + int cts; /* CTS timeouts */ + int dcd; /* Carrier drops */ + int overrun; /* receiver overrun */ + int underrun; /* xmitter underrun */ + int ierror; /* input error (rxbad) */ + int oerror; /* output error (watchdog timeout) */ + int nobuffers; /* no active receive block available */ +}; + + + +/* + * Per-stream structure. Each of these points to only one device instance, + * but there may be more than one doing so. If marked as ST_CLONE, it has + * been opened throught the clone device, and cannot have the data path. + */ +struct ser_str { + queue_t *str_rq; /* This stream's read queue */ + caddr_t str_com; /* Back pointer to device struct */ + int str_inst; /* Device instance (unit) number */ + int str_state; /* see below */ +}; + +/* + * Synchronous Protocol Private Data Structure + */ +#define ZSH_MAX_RSTANDBY 6 +#define ZSH_RDONE_MAX 20 +struct syncline { + struct ser_str sl_stream; /* data path device points thru here */ + struct scc_mode sl_mode; /* clock, etc. modes */ + struct sl_stats sl_st; /* Data and error statistics */ + mblk_t *sl_rhead; /* receive: head of active message */ + mblk_t *sl_ractb; /* receive: active message block */ + mblk_t *sl_rstandby[ZSH_MAX_RSTANDBY]; + /* receive: standby message blocks */ + mblk_t *sl_xhead; /* transmit: head of active message */ + mblk_t *sl_xactb; /* transmit: active message block */ + mblk_t *sl_xstandby; /* transmit: next available message */ + mblk_t *sl_rdone[ZSH_RDONE_MAX]; + /* complete messages to be sent up */ + int sl_rdone_wptr; + int sl_rdone_rptr; + mblk_t *sl_mstat; /* most recent modem status change */ + bufcall_id_t sl_bufcid; /* pending bufcall ID */ + timeout_id_t sl_wd_id; /* watchdog timeout ID */ + int sl_wd_count; /* watchdog counter */ + int sl_ocnt; /* output message size */ + int sl_mru; /* Maximum Receive Unit */ + int sl_bad_count_int; + uchar_t sl_rr0; /* saved RR0 */ + uchar_t sl_address; /* station address */ + uchar_t sl_txstate; /* transmit state */ + uchar_t sl_flags; /* see below */ + uchar_t sl_m_error; + volatile uchar_t sl_soft_active; /* */ +}; + +/* + * Bit definitions for sl_txstate. + */ +#define TX_OFF 0x0 /* Not available */ +#define TX_IDLE 0x1 /* Initialized */ +#define TX_RTS 0x2 /* IBM: RTS up, okay to transmit */ +#define TX_ACTIVE 0x4 /* Transmission in progress */ +#define TX_CRC 0x8 /* Sent all Data */ +#define TX_FLAG 0x10 /* Sent CRC bytes */ +#define TX_LAST 0x20 /* End-Of-Frame, OK to start new msg */ +#define TX_ABORTED 0x40 /* Transmit was aborted */ + +/* + * Bit definitions for sl_flags. + */ +#define SF_FDXPTP 0x1 /* Full duplex AND Point-To-Point */ +#define SF_XMT_INPROG 0x2 /* Write queue is not empty */ +#define SF_LINKERR 0x4 /* Underrun or CTS/DCD drop */ +#define SF_FLUSH_WQ 0x8 /* */ +#define SF_INITIALIZED 0x10 /* This channel programmed for this protocol */ +#define SF_PHONY 0x20 /* Dummy frame has been sent to close frame */ +#define SF_ZSH_START 0x40 /* */ +/* + * Bit definitions for str_state. + */ +#define STR_CLONE 1 /* This was opened thru clone device */ + +extern int hz; +#define SIO_WATCHDOG_TICK (2 * hz) /* Two second timeout */ +#define SIO_WATCHDOG_ON (zss->sl_wd_id > 0) /* Is it on? */ + + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_SER_SYNC_H */ diff --git a/illumos-x86_64/usr/include/sys/serializer.h b/illumos-x86_64/usr/include/sys/serializer.h new file mode 100644 index 00000000..14b22ee4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/serializer.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SERIALIZER_H +#define _SYS_SERIALIZER_H + +/* + * This file is used for building Solaris kernel. It does not provide any public + * interface, its content is unstable and subject to change without notice at + * any time. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include +#include + +struct serializer_s; +typedef struct serializer_s serializer_t; + +typedef void (srproc_t)(mblk_t *, void *); + +extern void serializer_init(void); +extern serializer_t *serializer_create(int); +extern void serializer_enter(serializer_t *, srproc_t, mblk_t *, void *); +extern void serializer_wait(serializer_t *); +extern void serializer_destroy(serializer_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SERIALIZER_H */ diff --git a/illumos-x86_64/usr/include/sys/session.h b/illumos-x86_64/usr/include/sys/session.h new file mode 100644 index 00000000..5972cd26 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/session.h @@ -0,0 +1,134 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_SESSION_H +#define _SYS_SESSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Session structure overview. + * + * Currently, the only structure in the kernel which has a pointer to a + * session structures is the proc_t via the p_sessp pointer. To + * access a session proc_t->p_sessp pointer a caller must hold either + * pidlock or p_splock. These locks only protect the p_sessp pointer + * itself and do not protect any of the contents of the session structure. + * To prevent the contents of a the session structure from changing the + * caller must grab s_lock. + * + * No callers should ever update the contents of the session structure + * directly. Only the session management code should ever modify the + * contents of the session structure. When the session code attempts + * to modify the contents of a session structure it must hold multiple + * locks. The locking order for all the locks that may need to be + * acquired is: + * sd_lock -> pidlock -> p_splock -> s_lock + * + * If a caller requires access to a session structure for long + * periods of time or across operations that may block it should + * use the tty_hold() and sess_hold() interfaces. + * + * sess_hold() returns a pointer to a session structure associated + * with the proc_t that was passed in. It also increments the reference + * count associated with that session structure to ensure that it + * can't be freed until after the caller is done with it and calls + * sess_rele(). This hold doesn't actually protect any of the + * contents of the session structure. + * + * tty_hold() returns a pointer to a session structure associated + * with the curproc. It also "locks" the contents of the session + * structure. This hold should be used when the caller will be + * doing operations on a controlling tty associated with the session. + * This operation doesn an implicit sess_hold() so that the session + * structure can't be free'd until after the caller is done with it + * and invokes tty_rele(). + * + * NOTE: Neither of these functions (sess_hold() or tty_hold()) + * prevent a process from changing its session. Once these functions + * return a session pointer, that session pointer may no longer be + * associated with the current process. If a caller wants to prevent + * a process from changing its session then it must hold pidlock or + * p_splock. + */ + +typedef struct sess { + struct pid *s_sidp; /* session ID info, never changes */ + + kmutex_t s_lock; /* protects everything below */ + uint_t s_ref; /* reference count */ + boolean_t s_sighuped; /* ctty had sighup sent to it */ + + boolean_t s_exit; /* sesion leader is exiting */ + kcondvar_t s_exit_cv; /* Condvar for s_exit */ + + int s_cnt; /* active users of this ctty */ + kcondvar_t s_cnt_cv; /* Condvar for s_cnt */ + + /* + * The following fields can only be updated while s_lock is held + * and s_cnt is 0. (ie, no one has a tty_hold() on this session.) + */ + dev_t s_dev; /* tty's device number */ + struct vnode *s_vp; /* tty's vnode */ + struct cred *s_cred; /* allocation credentials */ +} sess_t; + +#define s_sid s_sidp->pid_id + +#if defined(_KERNEL) + +extern sess_t session0; + +/* forward referenced structure tags */ +struct vnode; +struct proc; +struct stdata; + +extern void sess_hold(proc_t *p); +extern void sess_rele(sess_t *, boolean_t); +extern sess_t *tty_hold(void); +extern void tty_rele(sess_t *sp); + + +extern void sess_create(void); +extern int strctty(struct stdata *); +extern int freectty(boolean_t); +extern dev_t cttydev(struct proc *); +extern void ctty_clear_sighuped(void); + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SESSION_H */ diff --git a/illumos-x86_64/usr/include/sys/sha1.h b/illumos-x86_64/usr/include/sys/sha1.h new file mode 100644 index 00000000..9e1dcec4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sha1.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SHA1_H +#define _SYS_SHA1_H + +#include /* for uint_* */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NOTE: n2rng (Niagara2 RNG driver) accesses the state field of + * SHA1_CTX directly. NEVER change this structure without verifying + * compatiblity with n2rng. The important thing is that the state + * must be in a field declared as uint32_t state[5]. + */ +/* SHA-1 context. */ +typedef struct { + uint32_t state[5]; /* state (ABCDE) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (msb first) */ + union { + uint8_t buf8[64]; /* undigested input */ + uint32_t buf32[16]; /* realigned input */ + } buf_un; +} SHA1_CTX; + +#define SHA1_BLOCK_LENGTH 64 +#define SHA1_DIGEST_LENGTH 20 + +void SHA1Init(SHA1_CTX *); +void SHA1Update(SHA1_CTX *, const void *, size_t); +void SHA1Final(void *, SHA1_CTX *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SHA1_H */ diff --git a/illumos-x86_64/usr/include/sys/sha2.h b/illumos-x86_64/usr/include/sys/sha2.h new file mode 100644 index 00000000..4dd966b6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sha2.h @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright 2013 Saso Kiselkov. All rights reserved. */ + +#ifndef _SYS_SHA2_H +#define _SYS_SHA2_H + +#include /* for uint_* */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SHA2_HMAC_MIN_KEY_LEN 1 /* SHA2-HMAC min key length in bytes */ +#define SHA2_HMAC_MAX_KEY_LEN INT_MAX /* SHA2-HMAC max key length in bytes */ + +#define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */ +#define SHA384_DIGEST_LENGTH 48 /* SHA384 digest length in bytes */ +#define SHA512_DIGEST_LENGTH 64 /* SHA512 digest length in bytes */ + +/* Truncated versions of SHA-512 according to FIPS-180-4, section 5.3.6 */ +#define SHA512_224_DIGEST_LENGTH 28 /* SHA512/224 digest length */ +#define SHA512_256_DIGEST_LENGTH 32 /* SHA512/256 digest length */ + +#define SHA256_HMAC_BLOCK_SIZE 64 /* SHA256-HMAC block size */ +#define SHA512_HMAC_BLOCK_SIZE 128 /* SHA512-HMAC block size */ + +#define SHA256 0 +#define SHA256_HMAC 1 +#define SHA256_HMAC_GEN 2 +#define SHA384 3 +#define SHA384_HMAC 4 +#define SHA384_HMAC_GEN 5 +#define SHA512 6 +#define SHA512_HMAC 7 +#define SHA512_HMAC_GEN 8 +#define SHA512_224 9 +#define SHA512_256 10 + +/* + * SHA2 context. + * The contents of this structure are a private interface between the + * Init/Update/Final calls of the functions defined below. + * Callers must never attempt to read or write any of the fields + * in this structure directly. + */ +typedef struct { + uint32_t algotype; /* Algorithm Type */ + + /* state (ABCDEFGH) */ + union { + uint32_t s32[8]; /* for SHA256 */ + uint64_t s64[8]; /* for SHA384/512 */ + } state; + /* number of bits */ + union { + uint32_t c32[2]; /* for SHA256 , modulo 2^64 */ + uint64_t c64[2]; /* for SHA384/512, modulo 2^128 */ + } count; + union { + uint8_t buf8[128]; /* undigested input */ + uint32_t buf32[32]; /* realigned input */ + uint64_t buf64[16]; /* realigned input */ + } buf_un; +} SHA2_CTX; + +typedef SHA2_CTX SHA256_CTX; +typedef SHA2_CTX SHA384_CTX; +typedef SHA2_CTX SHA512_CTX; + +extern void SHA2Init(uint64_t mech, SHA2_CTX *); + +extern void SHA2Update(SHA2_CTX *, const void *, size_t); + +extern void SHA2Final(void *, SHA2_CTX *); + +extern void SHA256Init(SHA256_CTX *); + +extern void SHA256Update(SHA256_CTX *, const void *, size_t); + +extern void SHA256Final(void *, SHA256_CTX *); + +extern void SHA384Init(SHA384_CTX *); + +extern void SHA384Update(SHA384_CTX *, const void *, size_t); + +extern void SHA384Final(void *, SHA384_CTX *); + +extern void SHA512Init(SHA512_CTX *); + +extern void SHA512Update(SHA512_CTX *, const void *, size_t); + +extern void SHA512Final(void *, SHA512_CTX *); + +#ifdef _SHA2_IMPL +/* + * The following types/functions are all private to the implementation + * of the SHA2 functions and must not be used by consumers of the interface + */ + +/* + * List of support mechanisms in this module. + * + * It is important to note that in the module, division or modulus calculations + * are used on the enumerated type to determine which mechanism is being used; + * therefore, changing the order or additional mechanisms should be done + * carefully + */ +typedef enum sha2_mech_type { + SHA256_MECH_INFO_TYPE, /* SUN_CKM_SHA256 */ + SHA256_HMAC_MECH_INFO_TYPE, /* SUN_CKM_SHA256_HMAC */ + SHA256_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA256_HMAC_GENERAL */ + SHA384_MECH_INFO_TYPE, /* SUN_CKM_SHA384 */ + SHA384_HMAC_MECH_INFO_TYPE, /* SUN_CKM_SHA384_HMAC */ + SHA384_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA384_HMAC_GENERAL */ + SHA512_MECH_INFO_TYPE, /* SUN_CKM_SHA512 */ + SHA512_HMAC_MECH_INFO_TYPE, /* SUN_CKM_SHA512_HMAC */ + SHA512_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA512_HMAC_GENERAL */ + SHA512_224_MECH_INFO_TYPE, /* SUN_CKM_SHA512_224 */ + SHA512_256_MECH_INFO_TYPE /* SUN_CKM_SHA512_256 */ +} sha2_mech_type_t; + +#endif /* _SHA2_IMPL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SHA2_H */ diff --git a/illumos-x86_64/usr/include/sys/share.h b/illumos-x86_64/usr/include/sys/share.h new file mode 100644 index 00000000..1a8aead0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/share.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SHARE_H +#define _SYS_SHARE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Maximum size of a shrlock owner. + * Must be large enough to handle a netobj. + */ +#define MAX_SHR_OWNER_LEN 1024 + +/* + * Contents of shrlock owner field for local share requests + */ +struct shr_locowner { + pid_t sl_pid; + int sl_id; +}; + +struct shrlock { + short s_access; + short s_deny; + int32_t s_sysid; /* 0 if local otherwise passed by lm */ + pid_t s_pid; /* 0 if remote otherwise local pid */ + int s_own_len; /* if 0 and F_UNSHARE matching sysid */ + caddr_t s_owner; /* variable length opaque owner */ +}; + +struct shrlocklist { + struct shrlock *shr; + struct shrlocklist *next; +}; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +struct flock64; + +extern int add_share(struct vnode *, struct shrlock *); +extern int del_share(struct vnode *, struct shrlock *); +extern void cleanshares(struct vnode *, pid_t); +extern void cleanshares_by_sysid(struct vnode *, int32_t); +extern int shr_has_remote_shares(vnode_t *, int32_t); +extern int proc_has_nbmand_share_on_vp(vnode_t *, pid_t); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SHARE_H */ diff --git a/illumos-x86_64/usr/include/sys/shm.h b/illumos-x86_64/usr/include/sys/shm.h new file mode 100644 index 00000000..8f530afd --- /dev/null +++ b/illumos-x86_64/usr/include/sys/shm.h @@ -0,0 +1,144 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2016 Joyent, Inc. + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_SHM_H +#define _SYS_SHM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * IPC Shared Memory Facility. + */ + +/* + * Implementation Constants. + */ +#if (defined(_KERNEL) || defined(_KMEMUSER)) + +#define SHMLBA PAGESIZE /* segment low boundary address multiple */ + /* (SHMLBA must be a power of 2) */ +#else +#include /* needed for _SC_PAGESIZE */ +extern long _sysconf(int); /* System Private interface to sysconf() */ +#define SHMLBA (_sysconf(_SC_PAGESIZE)) +#endif /* defined(_KERNEL) || defined(_KMEMUSER)) */ + +/* + * Permission Definitions. + */ +#define SHM_R 0400 /* read permission */ +#define SHM_W 0200 /* write permission */ + +/* + * Message Operation Flags. + */ +#define SHM_RDONLY 010000 /* attach read-only (else read-write) */ +#define SHM_RND 020000 /* round attach address to SHMLBA */ +#define SHM_SHARE_MMU 040000 /* share VM resources such as page table */ +#define SHM_PAGEABLE 0100000 /* pageable ISM */ + +/* + * Valid flags bits for shmat shmflag argument. + */ +#define SHMAT_VALID_FLAGS_MASK \ + (SHM_R | SHM_W | SHM_RDONLY | SHM_RND | SHM_SHARE_MMU | SHM_PAGEABLE) + +typedef unsigned long shmatt_t; + +/* + * Structure Definitions. + */ +struct shmid_ds { + struct ipc_perm shm_perm; /* operation permission struct */ + size_t shm_segsz; /* size of segment in bytes */ +#if defined(_LP64) || defined(_XOPEN_SOURCE) + void *shm_amp; +#else + struct anon_map *shm_amp; /* segment anon_map pointer */ +#endif + ushort_t shm_lkcnt; /* number of times it is being locked */ + pid_t shm_lpid; /* pid of last shmop */ + pid_t shm_cpid; /* pid of creator */ + shmatt_t shm_nattch; /* number of attaches */ + ulong_t shm_cnattch; /* number of ISM attaches */ +#if defined(_LP64) + time_t shm_atime; /* last shmat time */ + time_t shm_dtime; /* last shmdt time */ + time_t shm_ctime; /* last change time */ + int64_t shm_pad4[4]; /* reserve area */ +#else /* _LP64 */ + time_t shm_atime; /* last shmat time */ + int32_t shm_pad1; /* reserved for time_t expansion */ + time_t shm_dtime; /* last shmdt time */ + int32_t shm_pad2; /* reserved for time_t expansion */ + time_t shm_ctime; /* last change time */ + int32_t shm_pad3; /* reserved for time_t expansion */ + int32_t shm_pad4[4]; /* reserve area */ +#endif /* _LP64 */ +}; + +/* + * Shared memory control operations + */ +#define SHM_LOCK 3 /* Lock segment in core */ +#define SHM_UNLOCK 4 /* Unlock segment */ + +#if defined(_KERNEL) +#define SHM_RMID 5 /* Private RMID for lx support */ +#endif + +#if !defined(_KERNEL) +int shmget(key_t, size_t, int); +int shmids(int *, uint_t, uint_t *); +int shmctl(int, int, struct shmid_ds *); +void *shmat(int, const void *, int); +#if defined(_XPG4) +int shmdt(const void *); +#else +int shmdt(char *); +#endif /* defined(_XPG4) */ +#endif /* !defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SHM_H */ diff --git a/illumos-x86_64/usr/include/sys/shm_impl.h b/illumos-x86_64/usr/include/sys/shm_impl.h new file mode 100644 index 00000000..1eae2ca0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/shm_impl.h @@ -0,0 +1,147 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _SYS_SHM_IMPL_H +#define _SYS_SHM_IMPL_H + +#include +#if defined(_KERNEL) || defined(_KMEMUSER) +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * shmsys system call subcodes + */ +#define SHMAT 0 +#define SHMCTL 1 +#define SHMDT 2 +#define SHMGET 3 +#define SHMIDS 4 + +/* + * There is a shared mem id data structure (shmid_ds) for each + * segment in the system. + */ +#if defined(_KERNEL) || defined(_KMEMUSER) +typedef struct kshmid { + kipc_perm_t shm_perm; /* operation permission struct */ + size_t shm_segsz; /* size of segment in bytes */ + struct anon_map *shm_amp; /* segment anon_map pointer */ + ushort_t shm_lkcnt; /* number of times it is being locked */ + pgcnt_t shm_lkpages; /* number of pages locked by shmctl */ + kmutex_t shm_mlock; /* held when locking physical pages */ + /* Therefore, protects p_lckcnt for */ + /* pages that back shm */ + pid_t shm_lpid; /* pid of last shmop */ + pid_t shm_cpid; /* pid of creator */ + ulong_t shm_ismattch; /* number of ISM attaches */ + time_t shm_atime; /* last shmat time */ + time_t shm_dtime; /* last shmdt time */ + time_t shm_ctime; /* last change time */ + struct sptinfo *shm_sptinfo; /* info about ISM segment */ + struct seg *shm_sptseg; /* pointer to ISM segment */ + ulong_t shm_opts; + /* + * Composed of: sptprot (uchar_t) and + * RM_PENDING flag (1 bit). + */ +} kshmid_t; + +/* + * Segacct Flags. + */ +#define SHMSA_ISM 1 /* uses shared page table */ + +/* + * shm_opts definitions + * Low byte in shm_opts is used for sptprot (see PROT_ALL). The upper bits are + * used for additional options. + */ +#define SHM_PROT_MASK 0xff +#define SHM_RM_PENDING 0x100 + +typedef struct sptinfo { + struct as *sptas; /* dummy as ptr. for spt segment */ +} sptinfo_t; + +/* + * Protected by p->p_lock + */ +typedef struct segacct { + avl_node_t sa_tree; + caddr_t sa_addr; + size_t sa_len; + ulong_t sa_flags; + kshmid_t *sa_id; +} segacct_t; + +/* + * Error codes for shmgetid(). + */ +#define SHMID_NONE (-1) +#define SHMID_FREE (-2) + +extern void shminit(void); +extern void shmfork(struct proc *, struct proc *); +extern void shmexit(struct proc *); +extern int shmgetid(struct proc *, caddr_t); + +#endif /* _KERNEL */ + +#if defined(_SYSCALL32) +/* + * LP64 view of the ILP32 shmid_ds structure + */ +struct shmid_ds32 { + struct ipc_perm32 shm_perm; /* operation permission struct */ + size32_t shm_segsz; /* size of segment in bytes */ + caddr32_t shm_amp; /* segment anon_map pointer */ + uint16_t shm_lkcnt; /* number of times it is being locked */ + pid32_t shm_lpid; /* pid of last shmop */ + pid32_t shm_cpid; /* pid of creator */ + uint32_t shm_nattch; /* number of attaches */ + uint32_t shm_cnattch; /* number of ISM attaches */ + time32_t shm_atime; /* last shmat time */ + int32_t shm_pad1; /* reserved for time_t expansion */ + time32_t shm_dtime; /* last shmdt time */ + int32_t shm_pad2; /* reserved for time_t expansion */ + time32_t shm_ctime; /* last change time */ + int32_t shm_pad3; /* reserved for time_t expansion */ + int32_t shm_pad4[4]; /* reserve area */ +}; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SHM_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/sid.h b/illumos-x86_64/usr/include/sys/sid.h new file mode 100644 index 00000000..46eb4e2a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sid.h @@ -0,0 +1,143 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2020 Tintri by DDN, Inc. All rights reserved. + */ + +#ifndef _SYS_SID_H +#define _SYS_SID_H + +#include +#include +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#include +#endif + +/* + * Kernel SID data structure and functions. + */ +#ifdef __cplusplus +extern "C" { +#endif + +/* sidsys subcodes */ +#define SIDSYS_ALLOC_IDS 0 +/* Flags for ALLOC_IDS */ +#define SID_EXTEND_RANGE 0 +#define SID_NEW_RANGE 1 + +#define SIDSYS_IDMAP_REG 1 +#define SIDSYS_IDMAP_UNREG 2 +#define SIDSYS_IDMAP_FLUSH_KCACHE 3 + +#define SIDSYS_SID2ID 0 +#define SIDSYS_ID2SID 1 + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#define KSIDLIST_MEM(n) (sizeof (ksidlist_t) + ((n) - 1) * sizeof (ksid_t)) + +/* Domains are stored in AVL trees so we can share them among SIDs */ +typedef struct ksiddomain { + uint_t kd_ref; + uint_t kd_len; + char *kd_name; /* Domain part of SID */ + avl_node_t kd_link; +} ksiddomain_t; + +typedef struct ksid { + uid_t ks_id; /* Cache of (ephemeral) uid */ + uint32_t ks_rid; /* Rid part of the name */ + uint32_t ks_attr; /* Attribute */ + ksiddomain_t *ks_domain; /* Domain descsriptor */ +} ksid_t; + +typedef enum ksid_index { + KSID_USER, + KSID_GROUP, + KSID_OWNER, + KSID_COUNT /* Must be last */ +} ksid_index_t; + +/* + * As no memory may be allocated for credentials while holding p_crlock, + * all sub data structures need to be ref counted. + */ + +typedef struct ksidlist { + uint_t ksl_ref; + uint_t ksl_nsid; + uint_t ksl_neid; /* Number of ids which are ephemeral */ + ksid_t **ksl_sorted; /* ksl_sids sorted by ID */ + ksid_t ksl_sids[1]; /* Allocate ksl_nsid times */ +} ksidlist_t; + +typedef struct credsid { + uint_t kr_ref; /* Reference count */ + ksid_t kr_sidx[KSID_COUNT]; /* User, group, default owner */ + ksidlist_t *kr_sidlist; /* List of SIDS */ +} credsid_t; + +const char *ksid_getdomain(ksid_t *); +uint_t ksid_getrid(ksid_t *); +uid_t ksid_getid(ksid_t *); + +int ksid_lookupbyuid(zone_t *, uid_t, ksid_t *); +int ksid_lookupbygid(zone_t *, gid_t, ksid_t *); +void ksid_rele(ksid_t *); + +credsid_t *kcrsid_alloc(void); + +credsid_t *kcrsid_setsid(credsid_t *, ksid_t *, ksid_index_t); +credsid_t *kcrsid_setsidlist(credsid_t *, ksidlist_t *); + +void kcrsid_rele(credsid_t *); +void kcrsid_hold(credsid_t *); +void kcrsidcopy_to(const credsid_t *okcr, credsid_t *nkcr); + +void ksiddomain_rele(ksiddomain_t *); +void ksiddomain_hold(ksiddomain_t *); +void ksidlist_rele(ksidlist_t *); +void ksidlist_hold(ksidlist_t *); +boolean_t ksidlist_has_sid(ksidlist_t *, const char *, uint32_t); +boolean_t ksidlist_has_pid(ksidlist_t *, uint32_t); + +ksiddomain_t *ksid_lookupdomain(const char *); + +ksidlist_t *kcrsid_gidstosids(zone_t *, int, gid_t *); + +#else /* _KERNEL */ + +int allocids(int, int, uid_t *, int, gid_t *); +int __idmap_reg(int); +int __idmap_unreg(int); +int __idmap_flush_kcache(void); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SID_H */ diff --git a/illumos-x86_64/usr/include/sys/siginfo.h b/illumos-x86_64/usr/include/sys/siginfo.h new file mode 100644 index 00000000..e73a1aac --- /dev/null +++ b/illumos-x86_64/usr/include/sys/siginfo.h @@ -0,0 +1,491 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_SIGINFO_H +#define _SYS_SIGINFO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \ + defined(__EXTENSIONS__) + +/* + * The union sigval is also defined in as per X/Open and + * POSIX requirements. + */ +#ifndef _SIGVAL +#define _SIGVAL +union sigval { + int sival_int; /* integer value */ + void *sival_ptr; /* pointer value */ +}; +#endif /* _SIGVAL */ + +#if defined(_SYSCALL32) + +/* Kernel view of user ILP32 sigval */ + +union sigval32 { + int32_t sival_int; /* integer value */ + caddr32_t sival_ptr; /* pointer value */ +}; + +#endif /* _SYSCALL32 */ + +#else /* needed in siginfo_t structure */ + +union __sigval { + int __sival_int; /* integer value */ + void *__sival_ptr; /* pointer value */ +}; + +#endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */ + +#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \ + defined(__EXTENSIONS__) + +/* + * The sigevent structure is also defined in as per X/Open and + * POSIX requirements. + */ +#ifndef _SIGEVENT +#define _SIGEVENT +struct sigevent { + int sigev_notify; /* notification mode */ + int sigev_signo; /* signal number */ + union sigval sigev_value; /* signal value */ + void (*sigev_notify_function)(union sigval); + pthread_attr_t *sigev_notify_attributes; + int __sigev_pad2; +}; +#endif /* _SIGEVENT */ + +/* values of sigev_notify */ +#define SIGEV_NONE 1 /* no notification */ +#define SIGEV_SIGNAL 2 /* queued signal notification */ +#define SIGEV_THREAD 3 /* call back from another thread */ +#define SIGEV_PORT 4 /* use event port for notification */ + +#if defined(_SYSCALL32) + +/* Kernel view of user ILP32 sigevent */ + +struct sigevent32 { + int32_t sigev_notify; /* notification mode */ + int32_t sigev_signo; /* signal number */ + union sigval32 sigev_value; /* signal value */ + caddr32_t sigev_notify_function; + caddr32_t sigev_notify_attributes; + int32_t __sigev_pad2; +}; + +#endif /* _SYSCALL32 */ + +#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */ + +#if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \ + defined(__EXTENSIONS__) +/* + * negative signal codes are reserved for future use for user generated + * signals + */ + +#define SI_FROMUSER(sip) ((sip)->si_code <= 0) +#define SI_FROMKERNEL(sip) ((sip)->si_code > 0) + +#define SI_NOINFO 32767 /* no signal information */ +#define SI_DTRACE 2050 /* kernel generated signal via DTrace action */ +#define SI_RCTL 2049 /* kernel generated signal via rctl action */ +#define SI_USER 0 /* user generated signal via kill() */ +#define SI_LWP (-1) /* user generated signal via lwp_kill() */ +#define SI_QUEUE (-2) /* user generated signal via sigqueue() */ +#define SI_TIMER (-3) /* from timer expiration */ +#define SI_ASYNCIO (-4) /* from asynchronous I/O completion */ +#define SI_MESGQ (-5) /* from message arrival */ +#endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */ + +#if !defined(_POSIX_C_SOURCE) || defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * Get the machine dependent signal codes (SIGILL, SIGFPE, SIGSEGV, and + * SIGBUS) from + */ + +#include + +/* + * SIGTRAP signal codes + */ + +#define TRAP_BRKPT 1 /* breakpoint trap */ +#define TRAP_TRACE 2 /* trace trap */ +#define TRAP_RWATCH 3 /* read access watchpoint trap */ +#define TRAP_WWATCH 4 /* write access watchpoint trap */ +#define TRAP_XWATCH 5 /* execute access watchpoint trap */ +#define TRAP_DTRACE 6 /* problem with fasttrap DTrace provider */ +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#define NSIGTRAP 6 +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +/* + * SIGCLD signal codes + */ + +#define CLD_EXITED 1 /* child has exited */ +#define CLD_KILLED 2 /* child was killed */ +#define CLD_DUMPED 3 /* child has coredumped */ +#define CLD_TRAPPED 4 /* traced child has stopped */ +#define CLD_STOPPED 5 /* child has stopped on signal */ +#define CLD_CONTINUED 6 /* stopped child has continued */ + +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#define NSIGCLD 6 +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +/* + * SIGPOLL signal codes + */ + +#define POLL_IN 1 /* input available */ +#define POLL_OUT 2 /* output possible */ +#define POLL_MSG 3 /* message available */ +#define POLL_ERR 4 /* I/O error */ +#define POLL_PRI 5 /* high priority input available */ +#define POLL_HUP 6 /* device disconnected */ + +#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#define NSIGPOLL 6 +#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ + +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XPG4_2) ... */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +/* + * SIGPROF signal codes + */ + +#define PROF_SIG 1 /* have to set code non-zero */ +#define NSIGPROF 1 + +#endif /* !defined(__XOPEN_OR_POSIX) || defined (__EXTENSIONS__) */ + +#if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \ + defined(__EXTENSIONS__) + +#ifdef _LP64 +#define SI_MAXSZ 256 +#define SI_PAD ((SI_MAXSZ / sizeof (int)) - 4) +#else +#define SI_MAXSZ 128 +#define SI_PAD ((SI_MAXSZ / sizeof (int)) - 3) +#endif + +/* + * Inclusion of is needed for the declaration of + * timestruc_t. However, since inclusion of results + * in X/Open and POSIX namespace pollution, the definition for + * timestruct_t has been duplicated in a standards namespace safe header + * . In , the structure + * name, tag, and member names, as well as the type itself, all have + * leading underscores to protect namespace. + */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#include +#else +#include +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* + * The inclusion of is needed for definitions of pid_t, etc. + * Placement here is due to a dependency in which is included + * by for the sigevent structure. Hence this inclusion must + * follow that definition. + */ +#include /* for definitions of pid_t, etc. */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +typedef struct siginfo { /* pollutes POSIX/XOPEN namespace */ +#else +typedef struct { +#endif + int si_signo; /* signal from signal.h */ + int si_code; /* code from above */ + int si_errno; /* error from errno.h */ +#ifdef _LP64 + int si_pad; /* _LP64 union starts on an 8-byte boundary */ +#endif + union { + + int __pad[SI_PAD]; /* for future growth */ + + struct { /* kill(), SIGCLD, siqqueue() */ + pid_t __pid; /* process ID */ + union { + struct { + uid_t __uid; +#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \ + defined(__EXTENSIONS__) + union sigval __value; +#else + union __sigval __value; +#endif + } __kill; + struct { + clock_t __utime; + int __status; + clock_t __stime; + } __cld; + } __pdata; + ctid_t __ctid; /* contract ID */ + zoneid_t __zoneid; /* zone ID */ + } __proc; + + struct { /* SIGSEGV, SIGBUS, SIGILL, SIGTRAP, SIGFPE */ + void *__addr; /* faulting address */ + int __trapno; /* illegal trap number */ + caddr_t __pc; /* instruction address */ + } __fault; + + struct { /* SIGPOLL, SIGXFSZ */ + /* fd not currently available for SIGPOLL */ + int __fd; /* file descriptor */ + long __band; + } __file; + + struct { /* SIGPROF */ + caddr_t __faddr; /* last fault address */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + timestruc_t __tstamp; /* real time stamp */ +#else + _timestruc_t __tstamp; /* real time stamp */ +#endif + short __syscall; /* current syscall */ + char __nsysarg; /* number of arguments */ + char __fault; /* last fault type */ + long __sysarg[8]; /* syscall arguments */ + int __mstate[10]; /* see */ + } __prof; + + struct { /* SI_RCTL */ + int32_t __entity; /* type of entity exceeding */ + } __rctl; + } __data; + +} siginfo_t; + +#if defined(_SYSCALL32) + +/* Kernel view of user ILP32 siginfo struct */ + +#define SI32_MAXSZ 128 +#define SI32_PAD ((SI32_MAXSZ / sizeof (int32_t)) - 3) + +typedef struct siginfo32 { + + int32_t si_signo; /* signal from signal.h */ + int32_t si_code; /* code from above */ + int32_t si_errno; /* error from errno.h */ + + union { + + int32_t __pad[SI32_PAD]; /* for future growth */ + + struct { /* kill(), SIGCLD, siqqueue() */ + pid32_t __pid; /* process ID */ + union { + struct { + uid32_t __uid; + union sigval32 __value; + } __kill; + struct { + clock32_t __utime; + int32_t __status; + clock32_t __stime; + } __cld; + } __pdata; + id32_t __ctid; /* contract ID */ + id32_t __zoneid; /* zone ID */ + } __proc; + + struct { /* SIGSEGV, SIGBUS, SIGILL, SIGTRAP, SIGFPE */ + caddr32_t __addr; /* faulting address */ + int32_t __trapno; /* illegal trap number */ + caddr32_t __pc; /* instruction address */ + } __fault; + + struct { /* SIGPOLL, SIGXFSZ */ + /* fd not currently available for SIGPOLL */ + int32_t __fd; /* file descriptor */ + int32_t __band; + } __file; + + struct { /* SIGPROF */ + caddr32_t __faddr; /* last fault address */ + timestruc32_t __tstamp; /* real time stamp */ + int16_t __syscall; /* current syscall */ + int8_t __nsysarg; /* number of arguments */ + int8_t __fault; /* last fault type */ + int32_t __sysarg[8]; /* syscall arguments */ + int32_t __mstate[10]; /* see */ + } __prof; + + struct { /* SI_RCTL */ + int32_t __entity; /* type of entity exceeding */ + } __rctl; + + } __data; + +} siginfo32_t; + +#endif /* _SYSCALL32 */ + +/* + * XXX -- internal version is identical to siginfo_t but without the padding. + * This must be maintained in sync with it. + */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + +typedef struct k_siginfo { + int si_signo; /* signal from signal.h */ + int si_code; /* code from above */ + int si_errno; /* error from errno.h */ +#ifdef _LP64 + int si_pad; /* _LP64 union starts on an 8-byte boundary */ +#endif + union { + struct { /* kill(), SIGCLD, siqqueue() */ + pid_t __pid; /* process ID */ + union { + struct { + uid_t __uid; + union sigval __value; + } __kill; + struct { + clock_t __utime; + int __status; + clock_t __stime; + } __cld; + } __pdata; + ctid_t __ctid; /* contract ID */ + zoneid_t __zoneid; /* zone ID */ + } __proc; + + struct { /* SIGSEGV, SIGBUS, SIGILL, SIGTRAP, SIGFPE */ + void *__addr; /* faulting address */ + int __trapno; /* illegal trap number */ + caddr_t __pc; /* instruction address */ + } __fault; + + struct { /* SIGPOLL, SIGXFSZ */ + /* fd not currently available for SIGPOLL */ + int __fd; /* file descriptor */ + long __band; + } __file; + + struct { /* SIGPROF */ + caddr_t __faddr; /* last fault address */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + timestruc_t __tstamp; /* real time stamp */ +#else + _timestruc_t __tstamp; /* real time stamp */ +#endif + short __syscall; /* current syscall */ + char __nsysarg; /* number of arguments */ + char __fault; /* last fault type */ + /* these are omitted to keep k_siginfo_t small */ + /* long __sysarg[8]; */ + /* int __mstate[10]; */ + } __prof; + + struct { /* SI_RCTL */ + int32_t __entity; /* type of entity exceeding */ + } __rctl; + + } __data; + +} k_siginfo_t; + +typedef struct sigqueue { + struct sigqueue *sq_next; + k_siginfo_t sq_info; + void (*sq_func)(struct sigqueue *); /* destructor function */ + void *sq_backptr; /* pointer to the data structure */ + /* associated by sq_func() */ + int sq_external; /* comes from outside the contract */ +} sigqueue_t; + +/* indication whether to queue the signal or not */ +#define SI_CANQUEUE(c) ((c) <= SI_QUEUE) + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#define si_pid __data.__proc.__pid +#define si_ctid __data.__proc.__ctid +#define si_zoneid __data.__proc.__zoneid +#define si_status __data.__proc.__pdata.__cld.__status +#define si_stime __data.__proc.__pdata.__cld.__stime +#define si_utime __data.__proc.__pdata.__cld.__utime +#define si_uid __data.__proc.__pdata.__kill.__uid +#define si_value __data.__proc.__pdata.__kill.__value +#define si_addr __data.__fault.__addr +#define si_trapno __data.__fault.__trapno +#define si_trapafter __data.__fault.__trapno +#define si_pc __data.__fault.__pc +#define si_fd __data.__file.__fd +#define si_band __data.__file.__band +#define si_tstamp __data.__prof.__tstamp +#define si_syscall __data.__prof.__syscall +#define si_nsysarg __data.__prof.__nsysarg +#define si_sysarg __data.__prof.__sysarg +#define si_fault __data.__prof.__fault +#define si_faddr __data.__prof.__faddr +#define si_mstate __data.__prof.__mstate +#define si_entity __data.__rctl.__entity + +#endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) ... */ + + +#if defined(_SYSCALL32_IMPL) + +extern void siginfo_kto32(const k_siginfo_t *, siginfo32_t *); +extern void siginfo_32tok(const siginfo32_t *, k_siginfo_t *); + +#endif /* _SYSCALL32_IMPL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SIGINFO_H */ diff --git a/illumos-x86_64/usr/include/sys/signal.h b/illumos-x86_64/usr/include/sys/signal.h new file mode 100644 index 00000000..fee54dde --- /dev/null +++ b/illumos-x86_64/usr/include/sys/signal.h @@ -0,0 +1,332 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015, Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_SIGNAL_H +#define _SYS_SIGNAL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || defined(_KERNEL) || !defined(_STRICT_STDC) || \ + defined(__XOPEN_OR_POSIX) + +#if defined(__EXTENSIONS__) || defined(_KERNEL) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) +/* + * We need for the declaration of siginfo_t. + */ +#include +#endif + +/* Duplicated in as a result of XPG4v2 requirements */ +#ifndef _SIGSET_T +#define _SIGSET_T +typedef struct { /* signal set type */ + unsigned int __sigbits[4]; +} sigset_t; +#endif /* _SIGSET_T */ + +typedef struct { + unsigned int __sigbits[3]; +} k_sigset_t; + +/* + * The signal handler routine can have either one or three arguments. With + * K&R C code could use either form so not specifing the arguments neatly + * finessed the problem. Modern C and any C++ do not accept this. To them + * "(*sa_handler)()" indicates a routine with no arguments (what used to be + * "(*sa_handler)(void)"). One or the other form must be used and the only + * logical choice is "(*sa_handler)(int)" to allow the SIG_* defines to work. + * "(*sa_sigaction)(int, siginfo_t *, void *)" can be used for the three + * argument form. + */ + +/* + * Note: storage overlap by sa_handler and sa_sigaction + */ +struct sigaction { + int sa_flags; + union { + void (*_handler)(int); +#if defined(__EXTENSIONS__) || defined(_KERNEL) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) + void (*_sigaction)(int, siginfo_t *, void *); +#endif + } _funcptr; + sigset_t sa_mask; +#ifndef _LP64 + int sa_resv[2]; +#endif +}; +#define sa_handler _funcptr._handler +#define sa_sigaction _funcptr._sigaction + +#if defined(_SYSCALL32) + +/* Kernel view of the ILP32 user sigaction structure */ + +struct sigaction32 { + int32_t sa_flags; + union { + caddr32_t _handler; + caddr32_t _sigaction; + } _funcptr; + sigset_t sa_mask; + int32_t sa_resv[2]; +}; + +#endif /* _SYSCALL32 */ + +/* this is only valid for SIGCLD */ +#define SA_NOCLDSTOP 0x00020000 /* don't send job control SIGCLD's */ +#endif + +#if defined(__EXTENSIONS__) || defined(_KERNEL) || \ + (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \ + defined(_XPG4_2) + + /* non-conformant ANSI compilation */ + +/* definitions for the sa_flags field */ +#define SA_ONSTACK 0x00000001 +#define SA_RESETHAND 0x00000002 +#define SA_RESTART 0x00000004 +#endif + +#if defined(__EXTENSIONS__) || defined(_KERNEL) || \ + (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \ + (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) +#define SA_SIGINFO 0x00000008 +#endif + +#if defined(__EXTENSIONS__) || defined(_KERNEL) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG4_2) +#define SA_NODEFER 0x00000010 + +/* this is only valid for SIGCLD */ +#define SA_NOCLDWAIT 0x00010000 /* don't save zombie children */ + +#if defined(__EXTENSIONS__) || !defined(_XPG4_2) +/* + * use of these symbols by applications is injurious + * to binary compatibility + */ +#define NSIG 75 /* valid signals range from 1 to NSIG-1 */ +#define MAXSIG 74 /* size of u_signal[], NSIG-1 <= MAXSIG */ +#endif /* defined(__EXTENSIONS__) || !defined(_XPG4_2) */ + +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 + +#define SS_ONSTACK 0x00000001 +#define SS_DISABLE 0x00000002 + +/* Duplicated in as a result of XPG4v2 requirements. */ +#ifndef _STACK_T +#define _STACK_T +#if defined(__EXTENSIONS__) || !defined(_XPG4_2) +typedef struct sigaltstack { +#else +typedef struct { +#endif + void *ss_sp; + size_t ss_size; + int ss_flags; +} stack_t; + +#if defined(_SYSCALL32) + +/* Kernel view of the ILP32 user sigaltstack structure */ + +typedef struct sigaltstack32 { + caddr32_t ss_sp; + size32_t ss_size; + int32_t ss_flags; +} stack32_t; + +#endif /* _SYSCALL32 */ + +#endif /* _STACK_T */ + +#endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */ + +#if defined(__EXTENSIONS__) || defined(_KERNEL) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + +/* signotify id used only by libc for mq_notify()/aio_notify() */ +typedef struct signotify_id { /* signotify id struct */ + pid_t sn_pid; /* pid of proc to be notified */ + int sn_index; /* index in preallocated pool */ + int sn_pad; /* reserved */ +} signotify_id_t; + +#if defined(_SYSCALL32) + +/* Kernel view of the ILP32 user signotify_id structure */ + +typedef struct signotify32_id { + pid32_t sn_pid; /* pid of proc to be notified */ + int32_t sn_index; /* index in preallocated pool */ + int32_t sn_pad; /* reserved */ +} signotify32_id_t; + +#endif /* _SYSCALL32 */ + +/* Command codes for sig_notify call */ + +#define SN_PROC 1 /* queue signotify for process */ +#define SN_CANCEL 2 /* cancel the queued signotify */ +#define SN_SEND 3 /* send the notified signal */ + +#endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */ + +/* Added as per XPG4v2 */ +#if defined(__EXTENSIONS__) || defined(_KERNEL) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG4_2) +struct sigstack { + void *ss_sp; + int ss_onstack; +}; +#endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */ + +/* + * For definition of ucontext_t; must follow struct definition + * for sigset_t + */ +#if defined(_XPG4_2) +#include +#endif /* defined(_XPG4_2) */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#include + +extern const k_sigset_t nullsmask; /* a null signal mask */ +extern const k_sigset_t fillset; /* all signals, guaranteed contiguous */ +extern const k_sigset_t cantmask; /* cannot be caught or ignored */ +extern const k_sigset_t cantreset; /* cannot be reset after catching */ +extern const k_sigset_t ignoredefault; /* ignored by default */ +extern const k_sigset_t stopdefault; /* stop by default */ +extern const k_sigset_t coredefault; /* dumps core by default */ +extern const k_sigset_t holdvfork; /* held while doing vfork */ + +#define sigmask(n) ((unsigned int)1 << (((n) - 1) & (32 - 1))) +#define sigword(n) (((unsigned int)((n) - 1))>>5) + +#if ((MAXSIG > (2 * 32)) && (MAXSIG <= (3 * 32))) +#define FILLSET0 0xffffffffu +#define FILLSET1 0xffffffffu +#define FILLSET2 ((1u << (MAXSIG - 64)) - 1) +#else +#error "fix me: MAXSIG out of bounds" +#endif + +#define CANTMASK0 (sigmask(SIGKILL)|sigmask(SIGSTOP)) +#define CANTMASK1 0 +#define CANTMASK2 0 + +#define sigemptyset(s) (*(s) = nullsmask) +#define sigfillset(s) (*(s) = fillset) +#define sigaddset(s, n) ((s)->__sigbits[sigword(n)] |= sigmask(n)) +#define sigdelset(s, n) ((s)->__sigbits[sigword(n)] &= ~sigmask(n)) +#define sigismember(s, n) (sigmask(n) & (s)->__sigbits[sigword(n)]) +#define sigisempty(s) (!((s)->__sigbits[0] | (s)->__sigbits[1] | \ + (s)->__sigbits[2])) +#define sigutok(us, ks) \ + ((ks)->__sigbits[0] = (us)->__sigbits[0] & (FILLSET0 & ~CANTMASK0), \ + (ks)->__sigbits[1] = (us)->__sigbits[1] & (FILLSET1 & ~CANTMASK1), \ + (ks)->__sigbits[2] = (us)->__sigbits[2] & (FILLSET2 & ~CANTMASK2)) +#define sigktou(ks, us) ((us)->__sigbits[0] = (ks)->__sigbits[0], \ + (us)->__sigbits[1] = (ks)->__sigbits[1], \ + (us)->__sigbits[2] = (ks)->__sigbits[2], \ + (us)->__sigbits[3] = 0) +typedef struct { + int sig; /* signal no. */ + int perm; /* flag for EPERM */ + int checkperm; /* check perm or not */ + int sicode; /* has siginfo.si_code */ + union sigval value; /* user specified value */ +} sigsend_t; + +typedef struct { + sigqueue_t sn_sigq; /* sigq struct for notification */ + u_longlong_t sn_snid; /* unique id for notification */ +} signotifyq_t; + +typedef struct sigqhdr { /* sigqueue pool header */ + sigqueue_t *sqb_free; /* free sigq struct list */ + int sqb_count; /* sigq free count */ + uint_t sqb_maxcount; /* sigq max free count */ + size_t sqb_size; /* size of header+free structs */ + uchar_t sqb_pexited; /* process has exited */ + uint_t sqb_sent; /* number of sigq sent */ + kcondvar_t sqb_cv; /* waiting for a sigq struct */ + kmutex_t sqb_lock; /* lock for sigq pool */ +} sigqhdr_t; + +#define _SIGQUEUE_SIZE_BASIC 128 /* basic limit */ +#define _SIGQUEUE_SIZE_PRIVILEGED 512 /* privileged limit */ + +#define _SIGNOTIFY_MAX 32 + +extern void setsigact(int, void (*)(int), const k_sigset_t *, int); +extern void sigorset(k_sigset_t *, const k_sigset_t *); +extern void sigandset(k_sigset_t *, const k_sigset_t *); +extern void sigdiffset(k_sigset_t *, const k_sigset_t *); +extern void sigintr(k_sigset_t *, int); +extern void sigunintr(k_sigset_t *); +extern void sigreplace(k_sigset_t *, k_sigset_t *); + +extern int kill(pid_t, int); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SIGNAL_H */ diff --git a/illumos-x86_64/usr/include/sys/signalfd.h b/illumos-x86_64/usr/include/sys/signalfd.h new file mode 100644 index 00000000..89d06470 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/signalfd.h @@ -0,0 +1,96 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2016 Joyent, Inc. + */ + +/* + * Header file to support the signalfd facility. Note that this facility + * is designed to be binary compatible with the Linux signalfd facility, modulo + * the signals themselves; values for constants here should therefore exactly + * match those found in Linux, and this facility shouldn't be extended + * independently of Linux. + */ + +#ifndef _SYS_SIGNALFD_H +#define _SYS_SIGNALFD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * To assure binary compatibility with Linux, these values are fixed at their + * Linux equivalents, not their native ones. + */ +#define SFD_CLOEXEC 02000000 /* LX_O_CLOEXEC */ +#define SFD_NONBLOCK 04000 /* LX_O_NONBLOCK */ + +/* + * These ioctl values are specific to the native implementation; applications + * shouldn't be using them directly, and they should therefore be safe to + * change without breaking apps. + */ +#define SIGNALFDIOC (('s' << 24) | ('f' << 16) | ('d' << 8)) +#define SIGNALFDIOC_MASK (SIGNALFDIOC | 1) /* set mask */ + +typedef struct signalfd_siginfo { + uint32_t ssi_signo; /* signal from signal.h */ + int32_t ssi_errno; /* error from errno.h */ + int32_t ssi_code; /* signal code */ + uint32_t ssi_pid; /* PID of sender */ + uint32_t ssi_uid; /* real UID of sender */ + int32_t ssi_fd; /* File descriptor (SIGIO) */ + uint32_t ssi_tid; /* unused */ + uint32_t ssi_band; /* band event (SIGIO) */ + uint32_t ssi_overrun; /* unused */ + uint32_t ssi_trapno; /* trap number that caused signal */ + int32_t ssi_status; /* exit status or signal (SIGCHLD) */ + int32_t ssi_int; /* unused */ + uint64_t ssi_ptr; /* unused */ + uint64_t ssi_utime; /* user CPU time consumed (SIGCHLD) */ + uint64_t ssi_stime; /* system CPU time consumed (SIGCHLD) */ + uint64_t ssi_addr; /* address that generated signal */ + uint8_t ssi_pad[48]; /* Pad size to 128 bytes to allow for */ + /* additional fields in the future. */ +} signalfd_siginfo_t; + +#ifndef _KERNEL + +extern int signalfd(int, const sigset_t *, int); + +#else + +#define SIGNALFDMNRN_SIGNALFD 0 +#define SIGNALFDMNRN_CLONE 1 + +/* + * This holds the proc_t state for a process which is using signalfd. + * Its presence and contents are protected by p_lock. + */ +typedef struct sigfd_proc_state { + void (*sigfd_pollwake_cb)(void *, int); + list_t sigfd_list; +} sigfd_proc_state_t; + + +extern void (*sigfd_exit_helper)(); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SIGNALFD_H */ diff --git a/illumos-x86_64/usr/include/sys/skein.h b/illumos-x86_64/usr/include/sys/skein.h new file mode 100644 index 00000000..423e1dc3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/skein.h @@ -0,0 +1,178 @@ +/* + * Interface declarations for Skein hashing. + * Source code author: Doug Whiting, 2008. + * This algorithm and source code is released to the public domain. + * + * The following compile-time switches may be defined to control some + * tradeoffs between speed, code size, error checking, and security. + * + * The "default" note explains what happens when the switch is not defined. + * + * SKEIN_DEBUG -- make callouts from inside Skein code + * to examine/display intermediate values. + * [default: no callouts (no overhead)] + * + * SKEIN_ERR_CHECK -- how error checking is handled inside Skein + * code. If not defined, most error checking + * is disabled (for performance). Otherwise, + * the switch value is interpreted as: + * 0: use assert() to flag errors + * 1: return SKEIN_FAIL to flag errors + */ +/* Copyright 2013 Doug Whiting. This code is released to the public domain. */ +#ifndef _SYS_SKEIN_H_ +#define _SYS_SKEIN_H_ + +#include /* get size_t definition */ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + SKEIN_SUCCESS = 0, /* return codes from Skein calls */ + SKEIN_FAIL = 1, + SKEIN_BAD_HASHLEN = 2 +}; + +#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ + +#define SKEIN_256_STATE_WORDS (4) +#define SKEIN_512_STATE_WORDS (8) +#define SKEIN1024_STATE_WORDS (16) +#define SKEIN_MAX_STATE_WORDS (16) + +#define SKEIN_256_STATE_BYTES (8 * SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BYTES (8 * SKEIN_512_STATE_WORDS) +#define SKEIN1024_STATE_BYTES (8 * SKEIN1024_STATE_WORDS) + +#define SKEIN_256_STATE_BITS (64 * SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BITS (64 * SKEIN_512_STATE_WORDS) +#define SKEIN1024_STATE_BITS (64 * SKEIN1024_STATE_WORDS) + +#define SKEIN_256_BLOCK_BYTES (8 * SKEIN_256_STATE_WORDS) +#define SKEIN_512_BLOCK_BYTES (8 * SKEIN_512_STATE_WORDS) +#define SKEIN1024_BLOCK_BYTES (8 * SKEIN1024_STATE_WORDS) + +typedef struct { + size_t hashBitLen; /* size of hash result, in bits */ + size_t bCnt; /* current byte count in buffer b[] */ + /* tweak words: T[0]=byte cnt, T[1]=flags */ + uint64_t T[SKEIN_MODIFIER_WORDS]; +} Skein_Ctxt_Hdr_t; + +typedef struct { /* 256-bit Skein hash context structure */ + Skein_Ctxt_Hdr_t h; /* common header context variables */ + uint64_t X[SKEIN_256_STATE_WORDS]; /* chaining variables */ + /* partial block buffer (8-byte aligned) */ + uint8_t b[SKEIN_256_BLOCK_BYTES]; +} Skein_256_Ctxt_t; + +typedef struct { /* 512-bit Skein hash context structure */ + Skein_Ctxt_Hdr_t h; /* common header context variables */ + uint64_t X[SKEIN_512_STATE_WORDS]; /* chaining variables */ + /* partial block buffer (8-byte aligned) */ + uint8_t b[SKEIN_512_BLOCK_BYTES]; +} Skein_512_Ctxt_t; + +typedef struct { /* 1024-bit Skein hash context structure */ + Skein_Ctxt_Hdr_t h; /* common header context variables */ + uint64_t X[SKEIN1024_STATE_WORDS]; /* chaining variables */ + /* partial block buffer (8-byte aligned) */ + uint8_t b[SKEIN1024_BLOCK_BYTES]; +} Skein1024_Ctxt_t; + +/* Skein APIs for (incremental) "straight hashing" */ +int Skein_256_Init(Skein_256_Ctxt_t *ctx, size_t hashBitLen); +int Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen); +int Skein1024_Init(Skein1024_Ctxt_t *ctx, size_t hashBitLen); + +int Skein_256_Update(Skein_256_Ctxt_t *ctx, const uint8_t *msg, + size_t msgByteCnt); +int Skein_512_Update(Skein_512_Ctxt_t *ctx, const uint8_t *msg, + size_t msgByteCnt); +int Skein1024_Update(Skein1024_Ctxt_t *ctx, const uint8_t *msg, + size_t msgByteCnt); + +int Skein_256_Final(Skein_256_Ctxt_t *ctx, uint8_t *hashVal); +int Skein_512_Final(Skein_512_Ctxt_t *ctx, uint8_t *hashVal); +int Skein1024_Final(Skein1024_Ctxt_t *ctx, uint8_t *hashVal); + +/* + * Skein APIs for "extended" initialization: MAC keys, tree hashing. + * After an InitExt() call, just use Update/Final calls as with Init(). + * + * Notes: Same parameters as _Init() calls, plus treeInfo/key/keyBytes. + * When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL, + * the results of InitExt() are identical to calling Init(). + * The function Init() may be called once to "precompute" the IV for + * a given hashBitLen value, then by saving a copy of the context + * the IV computation may be avoided in later calls. + * Similarly, the function InitExt() may be called once per MAC key + * to precompute the MAC IV, then a copy of the context saved and + * reused for each new MAC computation. + */ +int Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen, + uint64_t treeInfo, const uint8_t *key, size_t keyBytes); +int Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen, + uint64_t treeInfo, const uint8_t *key, size_t keyBytes); +int Skein1024_InitExt(Skein1024_Ctxt_t *ctx, size_t hashBitLen, + uint64_t treeInfo, const uint8_t *key, size_t keyBytes); + +/* + * Skein APIs for MAC and tree hash: + * Final_Pad: pad, do final block, but no OUTPUT type + * Output: do just the output stage + */ +int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, uint8_t *hashVal); +int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, uint8_t *hashVal); +int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, uint8_t *hashVal); + +#ifndef SKEIN_TREE_HASH +#define SKEIN_TREE_HASH (1) +#endif +#if SKEIN_TREE_HASH +int Skein_256_Output(Skein_256_Ctxt_t *ctx, uint8_t *hashVal); +int Skein_512_Output(Skein_512_Ctxt_t *ctx, uint8_t *hashVal); +int Skein1024_Output(Skein1024_Ctxt_t *ctx, uint8_t *hashVal); +#endif + +/* + * When you initialize a Skein KCF hashing method you can pass this param + * structure in cm_param to fine-tune the algorithm's defaults. + */ +typedef struct skein_param { + size_t sp_digest_bitlen; /* length of digest in bits */ +} skein_param_t; + +/* Module definitions */ +#ifdef SKEIN_MODULE_IMPL +#define CKM_SKEIN_256 "CKM_SKEIN_256" +#define CKM_SKEIN_512 "CKM_SKEIN_512" +#define CKM_SKEIN1024 "CKM_SKEIN1024" +#define CKM_SKEIN_256_MAC "CKM_SKEIN_256_MAC" +#define CKM_SKEIN_512_MAC "CKM_SKEIN_512_MAC" +#define CKM_SKEIN1024_MAC "CKM_SKEIN1024_MAC" + +typedef enum skein_mech_type { + SKEIN_256_MECH_INFO_TYPE, + SKEIN_512_MECH_INFO_TYPE, + SKEIN1024_MECH_INFO_TYPE, + SKEIN_256_MAC_MECH_INFO_TYPE, + SKEIN_512_MAC_MECH_INFO_TYPE, + SKEIN1024_MAC_MECH_INFO_TYPE +} skein_mech_type_t; + +#define VALID_SKEIN_DIGEST_MECH(__mech) \ + ((int)(__mech) >= SKEIN_256_MECH_INFO_TYPE && \ + (__mech) <= SKEIN1024_MECH_INFO_TYPE) +#define VALID_SKEIN_MAC_MECH(__mech) \ + ((int)(__mech) >= SKEIN_256_MAC_MECH_INFO_TYPE && \ + (__mech) <= SKEIN1024_MAC_MECH_INFO_TYPE) +#endif /* SKEIN_MODULE_IMPL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SKEIN_H_ */ diff --git a/illumos-x86_64/usr/include/sys/sleepq.h b/illumos-x86_64/usr/include/sys/sleepq.h new file mode 100644 index 00000000..2c980303 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sleepq.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SLEEPQ_H +#define _SYS_SLEEPQ_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Common definition for a sleep queue, + * be it an old-style sleep queue, or + * a constituent of a turnstile. + */ + +typedef struct sleepq { + struct _kthread *sq_first; +} sleepq_t; + +/* + * Definition of the head of a sleep queue hash bucket. + */ +typedef struct _sleepq_head { + sleepq_t sq_queue; + disp_lock_t sq_lock; +} sleepq_head_t; + +#ifdef _KERNEL + +#define NSLEEPQ 2048 +#define SQHASHINDEX(X) \ + ((((uintptr_t)(X) >> 2) ^ ((uintptr_t)(X) >> 13) ^ \ + ((uintptr_t)(X) >> 24)) & (NSLEEPQ - 1)) +#define SQHASH(X) (&sleepq_head[SQHASHINDEX(X)]) + +extern sleepq_head_t sleepq_head[NSLEEPQ]; + +extern void sleepq_insert(sleepq_t *, struct _kthread *); +extern struct _kthread *sleepq_wakeone_chan(sleepq_t *, void *); +extern void sleepq_wakeall_chan(sleepq_t *, void *); +extern void sleepq_unsleep(struct _kthread *); +extern void sleepq_dequeue(struct _kthread *); +extern void sleepq_unlink(struct _kthread **, struct _kthread *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SLEEPQ_H */ diff --git a/illumos-x86_64/usr/include/sys/smbios.h b/illumos-x86_64/usr/include/sys/smbios.h new file mode 100644 index 00000000..ca2c317f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/smbios.h @@ -0,0 +1,2326 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2025 Oxide Computer Company + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * This header file defines the interfaces available from the SMBIOS access + * library, libsmbios, and an equivalent kernel module. This API can be used + * to access DMTF SMBIOS data from a device, file, or raw memory buffer. + * + * This is NOT a Public interface, and should be considered Unstable, as it is + * subject to change without notice as the DMTF SMBIOS specification evolves. + * Therefore, be aware that any program linked with this API in this + * instance of illumos is almost guaranteed to break in the next release. + */ + +#ifndef _SYS_SMBIOS_H +#define _SYS_SMBIOS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum smbios_entry_point_type { + SMBIOS_ENTRY_POINT_21, + SMBIOS_ENTRY_POINT_30 +} smbios_entry_point_t; + +/* + * SMBIOS Structure Table Entry Point. See DSP0134 5.2.1 for more information. + * The structure table entry point is located by searching for the anchor. + */ +#pragma pack(1) + +typedef struct smbios_21_entry { + char smbe_eanchor[4]; /* anchor tag (SMB_ENTRY_EANCHOR) */ + uint8_t smbe_ecksum; /* checksum of entry point structure */ + uint8_t smbe_elen; /* length in bytes of entry point */ + uint8_t smbe_major; /* major version of the SMBIOS spec */ + uint8_t smbe_minor; /* minor version of the SMBIOS spec */ + uint16_t smbe_maxssize; /* maximum size in bytes of a struct */ + uint8_t smbe_revision; /* entry point structure revision */ + uint8_t smbe_format[5]; /* entry point revision-specific data */ + char smbe_ianchor[5]; /* intermed. tag (SMB_ENTRY_IANCHOR) */ + uint8_t smbe_icksum; /* intermed. checksum */ + uint16_t smbe_stlen; /* length in bytes of structure table */ + uint32_t smbe_staddr; /* physical addr of structure table */ + uint16_t smbe_stnum; /* number of structure table entries */ + uint8_t smbe_bcdrev; /* BCD value representing DMI version */ +} smbios_21_entry_t; + +/* + * The 64-bit SMBIOS 3.0 Entry Point. See DSP0134 5.2.2 for more information. + * The structure table entry point is located by searching for the anchor. + */ + +typedef struct smbios_30_entry { + char smbe_eanchor[5]; /* anchor tag (SMB3_ENTRY_EANCHOR) */ + uint8_t smbe_ecksum; /* checksum of entry point structure */ + uint8_t smbe_elen; /* length in bytes of entry point */ + uint8_t smbe_major; /* major version of the SMBIOS spec */ + uint8_t smbe_minor; /* minor version of the SMBIOS spec */ + uint8_t smbe_docrev; /* specification docrev */ + uint8_t smbe_revision; /* entry point structure revision */ + uint8_t smbe_reserved; + uint32_t smbe_stlen; /* length in bytes of structure table */ + uint64_t smbe_staddr; /* physical addr of structure table */ +} smbios_30_entry_t; + +typedef union { + smbios_21_entry_t ep21; + smbios_30_entry_t ep30; +} smbios_entry_t; + +#pragma pack() + +#define SMB_ENTRY_EANCHOR "_SM_" /* structure table entry point anchor */ +#define SMB_ENTRY_EANCHORLEN 4 /* length of entry point anchor */ +#define SMB3_ENTRY_EANCHOR "_SM3_" /* structure table entry point anchor */ +#define SMB3_ENTRY_EANCHORLEN 5 /* length of entry point anchor */ +#define SMB_ENTRY_IANCHOR "_DMI_" /* intermediate anchor string */ +#define SMB_ENTRY_IANCHORLEN 5 /* length of intermediate anchor */ +#define SMB_ENTRY_MAXLEN 255 /* maximum length of entry point */ + +/* + * Structure type codes. The comments next to each type include an (R) note to + * indicate a structure that is required as of SMBIOS v2.8 and an (O) note to + * indicate a structure that is obsolete as of SMBIOS v2.8. + */ +#define SMB_TYPE_BIOS 0 /* BIOS information (R) */ +#define SMB_TYPE_SYSTEM 1 /* system information (R) */ +#define SMB_TYPE_BASEBOARD 2 /* base board */ +#define SMB_TYPE_CHASSIS 3 /* system enclosure or chassis (R) */ +#define SMB_TYPE_PROCESSOR 4 /* processor (R) */ +#define SMB_TYPE_MEMCTL 5 /* memory controller (O) */ +#define SMB_TYPE_MEMMOD 6 /* memory module (O) */ +#define SMB_TYPE_CACHE 7 /* processor cache (R) */ +#define SMB_TYPE_PORT 8 /* port connector */ +#define SMB_TYPE_SLOT 9 /* upgradeable system slot (R) */ +#define SMB_TYPE_OBDEVS 10 /* on-board devices (O) */ +#define SMB_TYPE_OEMSTR 11 /* OEM string table */ +#define SMB_TYPE_SYSCONFSTR 12 /* system configuration string table */ +#define SMB_TYPE_LANG 13 /* BIOS language information */ +#define SMB_TYPE_GROUP 14 /* group associations */ +#define SMB_TYPE_EVENTLOG 15 /* system event log */ +#define SMB_TYPE_MEMARRAY 16 /* physical memory array (R) */ +#define SMB_TYPE_MEMDEVICE 17 /* memory device (R) */ +#define SMB_TYPE_MEMERR32 18 /* 32-bit memory error information */ +#define SMB_TYPE_MEMARRAYMAP 19 /* memory array mapped address (R) */ +#define SMB_TYPE_MEMDEVICEMAP 20 /* memory device mapped address */ +#define SMB_TYPE_POINTDEV 21 /* built-in pointing device */ +#define SMB_TYPE_BATTERY 22 /* portable battery */ +#define SMB_TYPE_RESET 23 /* system reset settings */ +#define SMB_TYPE_SECURITY 24 /* hardware security settings */ +#define SMB_TYPE_POWERCTL 25 /* system power controls */ +#define SMB_TYPE_VPROBE 26 /* voltage probe */ +#define SMB_TYPE_COOLDEV 27 /* cooling device */ +#define SMB_TYPE_TPROBE 28 /* temperature probe */ +#define SMB_TYPE_IPROBE 29 /* current probe */ +#define SMB_TYPE_OOBRA 30 /* out-of-band remote access facility */ +#define SMB_TYPE_BIS 31 /* boot integrity services */ +#define SMB_TYPE_BOOT 32 /* system boot status (R) */ +#define SMB_TYPE_MEMERR64 33 /* 64-bit memory error information */ +#define SMB_TYPE_MGMTDEV 34 /* management device */ +#define SMB_TYPE_MGMTDEVCP 35 /* management device component */ +#define SMB_TYPE_MGMTDEVDATA 36 /* management device threshold data */ +#define SMB_TYPE_MEMCHAN 37 /* memory channel */ +#define SMB_TYPE_IPMIDEV 38 /* IPMI device information */ +#define SMB_TYPE_POWERSUP 39 /* system power supply */ +#define SMB_TYPE_ADDINFO 40 /* additional information */ +#define SMB_TYPE_OBDEVEXT 41 /* on-board device extended info */ +#define SMB_TYPE_MCHI 42 /* mgmt controller host interface */ +#define SMB_TYPE_TPM 43 /* TPM device */ +#define SMB_TYPE_PROCESSOR_INFO 44 /* Processor Additional Information */ +#define SMB_TYPE_FWINFO 45 /* Firmware Inventory Information */ +#define SMB_TYPE_STRPROP 46 /* String Property */ +#define SMB_TYPE_INACTIVE 126 /* inactive table entry */ +#define SMB_TYPE_EOT 127 /* end of table */ + +#define SMB_TYPE_OEM_LO 128 /* start of OEM-specific type range */ +#define SUN_OEM_EXT_PROCESSOR 132 /* processor extended info */ +#define SUN_OEM_EXT_PORT 136 /* port extended info */ +#define SUN_OEM_PCIEXRC 138 /* PCIE RootComplex/RootPort info */ +#define SUN_OEM_EXT_MEMARRAY 144 /* phys memory array extended info */ +#define SUN_OEM_EXT_MEMDEVICE 145 /* memory device extended info */ +#define SMB_TYPE_OEM_HI 256 /* end of OEM-specific type range */ + +/* + * OEM string indicating "Platform Resource Management Specification" + * compliance. + */ +#define SMB_PRMS1 "SUNW-PRMS-1" + +/* + * Some default values set by BIOS vendor + */ +#define SMB_DEFAULT1 "To Be Filled By O.E.M." +#define SMB_DEFAULT2 "Not Available" +#define SMB_DEFAULT3 "Default string" + +/* + * SMBIOS Common Information. These structures do not correspond to anything + * in the SMBIOS specification, but allow library clients to more easily read + * information that is frequently encoded into the various SMBIOS structures. + */ +typedef struct smbios_info { + const char *smbi_manufacturer; /* manufacturer */ + const char *smbi_product; /* product name */ + const char *smbi_version; /* version */ + const char *smbi_serial; /* serial number */ + const char *smbi_asset; /* asset tag */ + const char *smbi_location; /* location tag */ + const char *smbi_part; /* part number */ +} smbios_info_t; + +typedef struct smbios_version { + uint8_t smbv_major; /* version major number */ + uint8_t smbv_minor; /* version minor number */ +} smbios_version_t; + +#define SMB_CONT_MAX 255 /* maximum contained objects */ + +/* + * SMBIOS Bios Information. See DSP0134 Section 7.1 for more information. + * smbb_romsize is converted from the implementation format into bytes. Note, if + * we do not have an extended BIOS ROM size, it is filled in with the default + * BIOS ROM size. + */ +typedef struct smbios_bios { + const char *smbb_vendor; /* bios vendor string */ + const char *smbb_version; /* bios version string */ + const char *smbb_reldate; /* bios release date */ + uint32_t smbb_segment; /* bios address segment location */ + uint32_t smbb_romsize; /* bios rom size in bytes */ + uint32_t smbb_runsize; /* bios image size in bytes */ + uint64_t smbb_cflags; /* bios characteristics */ + const uint8_t *smbb_xcflags; /* bios characteristics extensions */ + size_t smbb_nxcflags; /* number of smbb_xcflags[] bytes */ + smbios_version_t smbb_biosv; /* bios version */ + smbios_version_t smbb_ecfwv; /* bios embedded ctrl f/w version */ + uint64_t smbb_extromsize; /* Extended bios ROM Size */ +} smbios_bios_t; + +#define SMB_BIOSFL_RSV0 0x00000001 /* reserved bit zero */ +#define SMB_BIOSFL_RSV1 0x00000002 /* reserved bit one */ +#define SMB_BIOSFL_UNKNOWN 0x00000004 /* unknown */ +#define SMB_BIOSFL_BCNOTSUP 0x00000008 /* BIOS chars not supported */ +#define SMB_BIOSFL_ISA 0x00000010 /* ISA is supported */ +#define SMB_BIOSFL_MCA 0x00000020 /* MCA is supported */ +#define SMB_BIOSFL_EISA 0x00000040 /* EISA is supported */ +#define SMB_BIOSFL_PCI 0x00000080 /* PCI is supported */ +#define SMB_BIOSFL_PCMCIA 0x00000100 /* PCMCIA is supported */ +#define SMB_BIOSFL_PLUGNPLAY 0x00000200 /* Plug and Play is supported */ +#define SMB_BIOSFL_APM 0x00000400 /* APM is supported */ +#define SMB_BIOSFL_FLASH 0x00000800 /* BIOS is Flash Upgradeable */ +#define SMB_BIOSFL_SHADOW 0x00001000 /* BIOS shadowing is allowed */ +#define SMB_BIOSFL_VLVESA 0x00002000 /* VL-VESA is supported */ +#define SMB_BIOSFL_ESCD 0x00004000 /* ESCD support is available */ +#define SMB_BIOSFL_CDBOOT 0x00008000 /* Boot from CD is supported */ +#define SMB_BIOSFL_SELBOOT 0x00010000 /* Selectable Boot supported */ +#define SMB_BIOSFL_ROMSOCK 0x00020000 /* BIOS ROM is socketed */ +#define SMB_BIOSFL_PCMBOOT 0x00040000 /* Boot from PCMCIA supported */ +#define SMB_BIOSFL_EDD 0x00080000 /* EDD Spec is supported */ +#define SMB_BIOSFL_NEC9800 0x00100000 /* int 0x13 NEC 9800 floppy */ +#define SMB_BIOSFL_TOSHIBA 0x00200000 /* int 0x13 Toshiba floppy */ +#define SMB_BIOSFL_525_360K 0x00400000 /* int 0x13 5.25" 360K floppy */ +#define SMB_BIOSFL_525_12M 0x00800000 /* int 0x13 5.25" 1.2M floppy */ +#define SMB_BIOSFL_35_720K 0x01000000 /* int 0x13 3.5" 720K floppy */ +#define SMB_BIOSFL_35_288M 0x02000000 /* int 0x13 3.5" 2.88M floppy */ +#define SMB_BIOSFL_I5_PRINT 0x04000000 /* int 0x5 print screen svcs */ +#define SMB_BIOSFL_I9_KBD 0x08000000 /* int 0x9 8042 keyboard svcs */ +#define SMB_BIOSFL_I14_SER 0x10000000 /* int 0x14 serial svcs */ +#define SMB_BIOSFL_I17_PRINTER 0x20000000 /* int 0x17 printer svcs */ +#define SMB_BIOSFL_I10_CGA 0x40000000 /* int 0x10 CGA svcs */ +#define SMB_BIOSFL_NEC_PC98 0x80000000 /* NEC PC-98 */ + +/* + * These values are used to allow consumers to have raw access to the extended + * characteristic flags. We explicitly don't include the extended BIOS + * information from section 3.1 as part of this as it has its own member. + */ +#define SMB_BIOSXB_1 0 /* bios extension byte 1 (7.1.2.1) */ +#define SMB_BIOSXB_2 1 /* bios extension byte 2 (7.1.2.2) */ +#define SMB_BIOSXB_BIOS_MAJ 2 /* bios major version */ +#define SMB_BIOSXB_BIOS_MIN 3 /* bios minor version */ +#define SMB_BIOSXB_ECFW_MAJ 4 /* extended ctlr f/w major version */ +#define SMB_BIOSXB_ECFW_MIN 5 /* extended ctlr f/w minor version */ + +#define SMB_BIOSXB1_ACPI 0x01 /* ACPI is supported */ +#define SMB_BIOSXB1_USBL 0x02 /* USB legacy is supported */ +#define SMB_BIOSXB1_AGP 0x04 /* AGP is supported */ +#define SMB_BIOSXB1_I20 0x08 /* I2O boot is supported */ +#define SMB_BIOSXB1_LS120 0x10 /* LS-120 boot is supported */ +#define SMB_BIOSXB1_ATZIP 0x20 /* ATAPI ZIP drive boot is supported */ +#define SMB_BIOSXB1_1394 0x40 /* 1394 boot is supported */ +#define SMB_BIOSXB1_SMBAT 0x80 /* Smart Battery is supported */ + +#define SMB_BIOSXB2_BBOOT 0x01 /* BIOS Boot Specification supported */ +#define SMB_BIOSXB2_FKNETSVC 0x02 /* F-key Network Svc boot supported */ +#define SMB_BIOSXB2_ETCDIST 0x04 /* Enable Targeted Content Distrib. */ +#define SMB_BIOSXB2_UEFI 0x08 /* UEFI Specification supported */ +#define SMB_BIOSXB2_VM 0x10 /* SMBIOS table describes a VM */ +#define SMB_BIOSXB2_MFG_MODE 0x20 /* Manufacturing mode is supported */ +#define SMB_BIOSXB2_MFG_EN 0x40 /* Manufacturing mode is enabled */ + +/* + * SMBIOS System Information. See DSP0134 Section 7.2 for more information. + * The current set of smbs_wakeup values is defined after the structure. + */ +typedef struct smbios_system { + const uint8_t *smbs_uuid; /* UUID byte array */ + uint8_t smbs_uuidlen; /* UUID byte array length */ + uint8_t smbs_wakeup; /* wake-up event */ + const char *smbs_sku; /* SKU number */ + const char *smbs_family; /* family */ +} smbios_system_t; + +#define SMB_WAKEUP_RSV0 0x00 /* reserved */ +#define SMB_WAKEUP_OTHER 0x01 /* other */ +#define SMB_WAKEUP_UNKNOWN 0x02 /* unknown */ +#define SMB_WAKEUP_APM 0x03 /* APM timer */ +#define SMB_WAKEUP_MODEM 0x04 /* modem ring */ +#define SMB_WAKEUP_LAN 0x05 /* LAN remote */ +#define SMB_WAKEUP_SWITCH 0x06 /* power switch */ +#define SMB_WAKEUP_PCIPME 0x07 /* PCI PME# */ +#define SMB_WAKEUP_AC 0x08 /* AC power restored */ + +/* + * SMBIOS Base Board description. See DSP0134 Section 7.3 for more + * information. smbb_flags and smbb_type definitions are below. + */ +typedef struct smbios_bboard { + id_t smbb_chassis; /* chassis containing this board */ + uint8_t smbb_flags; /* flags (see below) */ + uint8_t smbb_type; /* board type (see below) */ + uint8_t smbb_contn; /* number of contained object hdls */ +} smbios_bboard_t; + +#define SMB_BBFL_MOTHERBOARD 0x01 /* board is a motherboard */ +#define SMB_BBFL_NEEDAUX 0x02 /* auxiliary card or daughter req'd */ +#define SMB_BBFL_REMOVABLE 0x04 /* board is removable */ +#define SMB_BBFL_REPLACABLE 0x08 /* board is field-replaceable */ +#define SMB_BBFL_HOTSWAP 0x10 /* board is hot-swappable */ + +#define SMB_BBT_UNKNOWN 0x1 /* unknown */ +#define SMB_BBT_OTHER 0x2 /* other */ +#define SMB_BBT_SBLADE 0x3 /* server blade */ +#define SMB_BBT_CSWITCH 0x4 /* connectivity switch */ +#define SMB_BBT_SMM 0x5 /* system management module */ +#define SMB_BBT_PROC 0x6 /* processor module */ +#define SMB_BBT_IO 0x7 /* i/o module */ +#define SMB_BBT_MEM 0x8 /* memory module */ +#define SMB_BBT_DAUGHTER 0x9 /* daughterboard */ +#define SMB_BBT_MOTHER 0xA /* motherboard */ +#define SMB_BBT_PROCMEM 0xB /* processor/memory module */ +#define SMB_BBT_PROCIO 0xC /* processor/i/o module */ +#define SMB_BBT_INTER 0xD /* interconnect board */ + +/* + * SMBIOS Chassis description. See DSP0134 Section 7.4 for more information. + * We move the lock bit of the type field into smbc_lock for easier processing. + */ +typedef struct smbios_chassis { + uint32_t smbc_oemdata; /* OEM-specific data */ + uint8_t smbc_lock; /* lock present? */ + uint8_t smbc_type; /* type */ + uint8_t smbc_bustate; /* boot-up state */ + uint8_t smbc_psstate; /* power supply state */ + uint8_t smbc_thstate; /* thermal state */ + uint8_t smbc_security; /* security status */ + uint8_t smbc_uheight; /* enclosure height in U's */ + uint8_t smbc_cords; /* number of power cords */ + uint8_t smbc_elems; /* number of element records (n) */ + uint8_t smbc_elemlen; /* length of contained element (m) */ + const char *smbc_sku; /* SKU number (as a string) */ + uint8_t smbc_rtype; /* rack type */ + uint32_t smbc_rheight; /* rack height */ +} smbios_chassis_t; + +#define SMB_CHT_OTHER 0x01 /* other */ +#define SMB_CHT_UNKNOWN 0x02 /* unknown */ +#define SMB_CHT_DESKTOP 0x03 /* desktop */ +#define SMB_CHT_LPDESKTOP 0x04 /* low-profile desktop */ +#define SMB_CHT_PIZZA 0x05 /* pizza box */ +#define SMB_CHT_MINITOWER 0x06 /* mini-tower */ +#define SMB_CHT_TOWER 0x07 /* tower */ +#define SMB_CHT_PORTABLE 0x08 /* portable */ +#define SMB_CHT_LAPTOP 0x09 /* laptop */ +#define SMB_CHT_NOTEBOOK 0x0A /* notebook */ +#define SMB_CHT_HANDHELD 0x0B /* hand-held */ +#define SMB_CHT_DOCK 0x0C /* docking station */ +#define SMB_CHT_ALLIN1 0x0D /* all-in-one */ +#define SMB_CHT_SUBNOTE 0x0E /* sub-notebook */ +#define SMB_CHT_SPACESAVE 0x0F /* space-saving */ +#define SMB_CHT_LUNCHBOX 0x10 /* lunchbox */ +#define SMB_CHT_MAIN 0x11 /* main server chassis */ +#define SMB_CHT_EXPANSION 0x12 /* expansion chassis */ +#define SMB_CHT_SUB 0x13 /* sub-chassis */ +#define SMB_CHT_BUS 0x14 /* bus expansion chassis */ +#define SMB_CHT_PERIPHERAL 0x15 /* peripheral chassis */ +#define SMB_CHT_RAID 0x16 /* raid chassis */ +#define SMB_CHT_RACK 0x17 /* rack mount chassis */ +#define SMB_CHT_SEALED 0x18 /* sealed case pc */ +#define SMB_CHT_MULTI 0x19 /* multi-system chassis */ +#define SMB_CHT_CPCI 0x1A /* compact PCI */ +#define SMB_CHT_ATCA 0x1B /* advanced TCA */ +#define SMB_CHT_BLADE 0x1C /* blade */ +#define SMB_CHT_BLADEENC 0x1D /* blade enclosure */ +#define SMB_CHT_TABLET 0x1E /* tablet */ +#define SMB_CHT_CONVERTIBLE 0x1F /* convertible */ +#define SMB_CHT_DETACHABLE 0x20 /* detachable */ +#define SMB_CHT_IOTGW 0x21 /* IoT Gateway */ +#define SMB_CHT_EMBEDPC 0x22 /* Embedded PC */ +#define SMB_CHT_MINIPC 0x23 /* Mini PC */ +#define SMB_CHT_STICKPC 0x24 /* Stick PC */ + +#define SMB_CHST_OTHER 0x01 /* other */ +#define SMB_CHST_UNKNOWN 0x02 /* unknown */ +#define SMB_CHST_SAFE 0x03 /* safe */ +#define SMB_CHST_WARNING 0x04 /* warning */ +#define SMB_CHST_CRITICAL 0x05 /* critical */ +#define SMB_CHST_NONREC 0x06 /* non-recoverable */ + +#define SMB_CHSC_OTHER 0x01 /* other */ +#define SMB_CHSC_UNKNOWN 0x02 /* unknown */ +#define SMB_CHSC_NONE 0x03 /* none */ +#define SMB_CHSC_EILOCK 0x04 /* external interface locked out */ +#define SMB_CHSC_EIENAB 0x05 /* external interface enabled */ + +#define SMB_CRT_OU 0x01 /* OU */ + +/* + * Chassis element record types + */ +typedef struct smbios_chassis_entry { + uint8_t smbce_type; /* Type of elt */ + uint8_t smbce_elt; /* Containing Element */ + uint8_t smbce_min; /* minimum number of elt */ + uint8_t smbce_max; /* minimum number of elt */ +} smbios_chassis_entry_t; + +#define SMB_CELT_BBOARD 0 /* smbce_elt is a base board type */ +#define SMB_CELT_SMBIOS 1 /* smbce_elt is an smbios type */ + +/* + * SMBIOS Processor description. See DSP0134 Section 7.5 for more details. + * If the L1, L2, or L3 cache handle is -1, the cache information is unknown. + * If the handle refers to something of size 0, that type of cache is absent. + * + * NOTE: Although SMBIOS exports a 64-bit CPUID result, this value should not + * be used for any purpose other than BIOS debugging. illumos itself computes + * its own CPUID value and applies knowledge of additional errata and processor + * specific CPUID variations, so this value should not be used for anything. + */ +typedef struct smbios_processor { + uint64_t smbp_cpuid; /* processor cpuid information */ + uint32_t smbp_family; /* processor family */ + uint8_t smbp_type; /* processor type (SMB_PRT_*) */ + uint8_t smbp_voltage; /* voltage (SMB_PRV_*) */ + uint8_t smbp_status; /* status (SMB_PRS_*) */ + uint8_t smbp_upgrade; /* upgrade (SMB_PRU_*) */ + uint32_t smbp_clkspeed; /* external clock speed in MHz */ + uint32_t smbp_maxspeed; /* maximum speed in MHz */ + uint32_t smbp_curspeed; /* current speed in MHz */ + id_t smbp_l1cache; /* L1 cache handle */ + id_t smbp_l2cache; /* L2 cache handle */ + id_t smbp_l3cache; /* L3 cache handle */ + uint32_t smbp_corecount; + /* number of cores per processor socket */ + uint32_t smbp_coresenabled; + /* number of enabled cores per processor socket */ + uint32_t smbp_threadcount; + /* number of threads per processor socket */ + uint16_t smbp_cflags; + /* processor characteristics (SMB_PRC_*) */ + uint32_t smbp_threadsenabled; /* number of enabled threads */ + const char *smbp_socktype; /* socket type string */ +} smbios_processor_t; + +#define SMB_PRT_OTHER 0x01 /* other */ +#define SMB_PRT_UNKNOWN 0x02 /* unknown */ +#define SMB_PRT_CENTRAL 0x03 /* central processor */ +#define SMB_PRT_MATH 0x04 /* math processor */ +#define SMB_PRT_DSP 0x05 /* DSP processor */ +#define SMB_PRT_VIDEO 0x06 /* video processor */ + +#define SMB_PRV_LEGACY(v) (!((v) & 0x80)) /* legacy voltage mode */ +#define SMB_PRV_FIXED(v) ((v) & 0x80) /* fixed voltage mode */ + +#define SMB_PRV_5V 0x01 /* 5V is supported */ +#define SMB_PRV_33V 0x02 /* 3.3V is supported */ +#define SMB_PRV_29V 0x04 /* 2.9V is supported */ + +#define SMB_PRV_VOLTAGE(v) ((v) & 0x7f) + +#define SMB_PRSTATUS_PRESENT(s) ((s) & 0x40) /* socket is populated */ +#define SMB_PRSTATUS_STATUS(s) ((s) & 0x07) /* status (see below) */ + +#define SMB_PRS_UNKNOWN 0x0 /* unknown */ +#define SMB_PRS_ENABLED 0x1 /* enabled */ +#define SMB_PRS_BDISABLED 0x2 /* disabled in bios user setup */ +#define SMB_PRS_PDISABLED 0x3 /* disabled in bios from post error */ +#define SMB_PRS_IDLE 0x4 /* waiting to be enabled */ +#define SMB_PRS_OTHER 0x7 /* other */ + +#define SMB_PRU_OTHER 0x01 /* other */ +#define SMB_PRU_UNKNOWN 0x02 /* unknown */ +#define SMB_PRU_DAUGHTER 0x03 /* daughter board */ +#define SMB_PRU_ZIF 0x04 /* ZIF socket */ +#define SMB_PRU_PIGGY 0x05 /* replaceable piggy back */ +#define SMB_PRU_NONE 0x06 /* none */ +#define SMB_PRU_LIF 0x07 /* LIF socket */ +#define SMB_PRU_SLOT1 0x08 /* slot 1 */ +#define SMB_PRU_SLOT2 0x09 /* slot 2 */ +#define SMB_PRU_370PIN 0x0A /* 370-pin socket */ +#define SMB_PRU_SLOTA 0x0B /* slot A */ +#define SMB_PRU_SLOTM 0x0C /* slot M */ +#define SMB_PRU_423 0x0D /* socket 423 */ +#define SMB_PRU_A 0x0E /* socket A (socket 462) */ +#define SMB_PRU_478 0x0F /* socket 478 */ +#define SMB_PRU_754 0x10 /* socket 754 */ +#define SMB_PRU_940 0x11 /* socket 940 */ +#define SMB_PRU_939 0x12 /* socket 939 */ +#define SMB_PRU_MPGA604 0x13 /* mPGA604 */ +#define SMB_PRU_LGA771 0x14 /* LGA771 */ +#define SMB_PRU_LGA775 0x15 /* LGA775 */ +#define SMB_PRU_S1 0x16 /* socket S1 */ +#define SMB_PRU_AM2 0x17 /* socket AM2 */ +#define SMB_PRU_F 0x18 /* socket F */ +#define SMB_PRU_LGA1366 0x19 /* LGA1366 */ +#define SMB_PRU_G34 0x1A /* socket G34 */ +#define SMB_PRU_AM3 0x1B /* socket AM3 */ +#define SMB_PRU_C32 0x1C /* socket C32 */ +#define SMB_PRU_LGA1156 0x1D /* LGA1156 */ +#define SMB_PRU_LGA1567 0x1E /* LGA1567 */ +#define SMB_PRU_PGA988A 0x1F /* PGA988A */ +#define SMB_PRU_BGA1288 0x20 /* BGA1288 */ +#define SMB_PRU_RPGA988B 0x21 /* rPGA988B */ +#define SMB_PRU_BGA1023 0x22 /* BGA1023 */ +#define SMB_PRU_BGA1224 0x23 /* BGA1224 */ +#define SMB_PRU_LGA1155 0x24 /* LGA1155 */ +#define SMB_PRU_LGA1356 0x25 /* LGA1356 */ +#define SMB_PRU_LGA2011 0x26 /* LGA2011 */ +#define SMB_PRU_FS1 0x27 /* socket FS1 */ +#define SMB_PRU_FS2 0x28 /* socket FS2 */ +#define SMB_PRU_FM1 0x29 /* socket FM1 */ +#define SMB_PRU_FM2 0x2A /* socket FM2 */ +#define SMB_PRU_LGA20113 0x2B /* LGA2011-3 */ +#define SMB_PRU_LGA13563 0x2C /* LGA1356-3 */ +#define SMB_PRU_LGA1150 0x2D /* LGA1150 */ +#define SMB_PRU_BGA1168 0x2E /* BGA1168 */ +#define SMB_PRU_BGA1234 0x2F /* BGA1234 */ +#define SMB_PRU_BGA1364 0x30 /* BGA1364 */ +#define SMB_PRU_AM4 0x31 /* socket AM4 */ +#define SMB_PRU_LGA1151 0x32 /* LGA1151 */ +#define SMB_PRU_BGA1356 0x33 /* BGA1356 */ +#define SMB_PRU_BGA1440 0x34 /* BGA1440 */ +#define SMB_PRU_BGA1515 0x35 /* BGA1515 */ +#define SMB_PRU_LGA36471 0x36 /* LGA3647-1 */ +#define SMB_PRU_SP3 0x37 /* socket SP3 */ +#define SMB_PRU_SP3r2 0x38 /* socket SP3r2 */ +#define SMB_PRU_LGA2066 0x39 /* Socket LGA2066 */ +#define SMB_PRU_BGA1392 0x3A /* Socket BGA1392 */ +#define SMB_PRU_BGA1510 0x3B /* Socket BGA1510 */ +#define SMB_PRU_BGA1528 0x3C /* Socket BGA1528 */ +#define SMB_PRU_LGA4189 0x3D /* Socket LGA4189 */ +#define SMB_PRU_LGA1200 0x3E /* Socket LGA1200 */ +#define SMB_PRU_LGA4677 0x3F /* Socket LGA4677 */ +#define SMB_PRU_LGA1700 0x40 /* Socket LGA1700 */ +#define SMB_PRU_BGA1744 0x41 /* Socket BGA1744 */ +#define SMB_PRU_BGA1781 0x42 /* Socket BGA1781 */ +#define SMB_PRU_BGA1211 0x43 /* Socket BGA1211 */ +#define SMB_PRU_BGA2422 0x44 /* Socket BGA2422 */ +#define SMB_PRU_LGA1211 0x45 /* Socket LGA1211 */ +#define SMB_PRU_LGA2422 0x46 /* Socket LGA2422 */ +#define SMB_PRU_LGA5773 0x47 /* Socket LGA5773 */ +#define SMB_PRU_BGA5773 0x48 /* Socket BGA5773 */ +#define SMB_PRU_AM5 0x49 /* Socket AM5 */ +#define SMB_PRU_SP5 0x4A /* Socket SP5 */ +#define SMB_PRU_SP6 0x4B /* Socket SP6 */ +#define SMB_PRU_BGA883 0x4C /* Socket BGA883 */ +#define SMB_PRU_BGA1190 0x4D /* Socket BGA1190 */ +#define SMB_PRU_BGA4129 0x4E /* Socket BGA4129 */ +#define SMB_PRU_LGA4710 0x4F /* Socket LBA4710 */ +#define SMB_PRU_LGA7529 0x50 /* Socket LBA7529 */ +#define SMB_PRU_BGA1964 0x51 /* Socket BGA1964 */ +#define SMB_PRU_BGA1792 0x52 /* Socket BGA1792 */ +#define SMB_PRU_BGA2049 0x53 /* Socket BGA2049 */ +#define SMB_PRU_BGA2551 0x54 /* Socket BGA2551 */ +#define SMB_PRU_LGA1851 0x55 /* Socket LGA1851 */ +#define SMB_PRU_BGA2114 0x56 /* Socket BGA2114 */ +#define SMB_PRU_BGA2883 0x57 /* Socket BGA2883 */ + +#define SMB_PRC_RESERVED 0x0001 /* reserved */ +#define SMB_PRC_UNKNOWN 0x0002 /* unknown */ +#define SMB_PRC_64BIT 0x0004 /* 64-bit capable */ +#define SMB_PRC_MC 0x0008 /* multi-core */ +#define SMB_PRC_HT 0x0010 /* hardware thread */ +#define SMB_PRC_NX 0x0020 /* execution protection */ +#define SMB_PRC_VT 0x0040 /* enhanced virtualization */ +#define SMB_PRC_PM 0x0080 /* power/performance control */ +#define SMB_PRC_128BIT 0x0100 /* 128-bit capable */ + +#define SMB_PRF_OTHER 0x01 /* other */ +#define SMB_PRF_UNKNOWN 0x02 /* unknown */ +#define SMB_PRF_8086 0x03 /* 8086 */ +#define SMB_PRF_80286 0x04 /* 80286 */ +#define SMB_PRF_I386 0x05 /* Intel 386 */ +#define SMB_PRF_I486 0x06 /* Intel 486 */ +#define SMB_PRF_8087 0x07 /* 8087 */ +#define SMB_PRF_80287 0x08 /* 80287 */ +#define SMB_PRF_80387 0x09 /* 80387 */ +#define SMB_PRF_80487 0x0A /* 80487 */ +#define SMB_PRF_PENTIUM 0x0B /* Pentium Family */ +#define SMB_PRF_PENTIUMPRO 0x0C /* Pentium Pro */ +#define SMB_PRF_PENTIUMII 0x0D /* Pentium II */ +#define SMB_PRF_PENTIUM_MMX 0x0E /* Pentium w/ MMX */ +#define SMB_PRF_CELERON 0x0F /* Celeron */ +#define SMB_PRF_PENTIUMII_XEON 0x10 /* Pentium II Xeon */ +#define SMB_PRF_PENTIUMIII 0x11 /* Pentium III */ +#define SMB_PRF_M1 0x12 /* M1 */ +#define SMB_PRF_M2 0x13 /* M2 */ +#define SMB_PRF_CELERON_M 0x14 /* Celeron M */ +#define SMB_PRF_PENTIUMIV_HT 0x15 /* Pentium 4 HT */ +#define SMB_PRF_INTC_PROC 0x16 /* Intel Processor */ +#define SMB_PRF_DURON 0x18 /* AMD Duron */ +#define SMB_PRF_K5 0x19 /* K5 */ +#define SMB_PRF_K6 0x1A /* K6 */ +#define SMB_PRF_K6_2 0x1B /* K6-2 */ +#define SMB_PRF_K6_3 0x1C /* K6-3 */ +#define SMB_PRF_ATHLON 0x1D /* Athlon */ +#define SMB_PRF_2900 0x1E /* AMD 2900 */ +#define SMB_PRF_K6_2PLUS 0x1F /* K6-2+ */ +#define SMB_PRF_PPC 0x20 /* PowerPC */ +#define SMB_PRF_PPC_601 0x21 /* PowerPC 601 */ +#define SMB_PRF_PPC_603 0x22 /* PowerPC 603 */ +#define SMB_PRF_PPC_603PLUS 0x23 /* PowerPC 603+ */ +#define SMB_PRF_PPC_604 0x24 /* PowerPC 604 */ +#define SMB_PRF_PPC_620 0x25 /* PowerPC 620 */ +#define SMB_PRF_PPC_704 0x26 /* PowerPC x704 */ +#define SMB_PRF_PPC_750 0x27 /* PowerPC 750 */ +#define SMB_PRF_CORE_DUO 0x28 /* Core Duo */ +#define SMB_PRF_CORE_DUO_M 0x29 /* Core Duo mobile */ +#define SMB_PRF_CORE_SOLO_M 0x2A /* Core Solo mobile */ +#define SMB_PRF_ATOM 0x2B /* Intel Atom */ +#define SMB_PRF_CORE_M 0x2C /* Intel Core M */ +#define SMB_PRF_CORE_M3 0x2D /* Intel Core m3 */ +#define SMB_PRF_CORE_M5 0x2E /* Intel Core m5 */ +#define SMB_PRF_CORE_M7 0x2F /* Intel Core m7 */ +#define SMB_PRF_ALPHA 0x30 /* Alpha */ +#define SMB_PRF_ALPHA_21064 0x31 /* Alpha 21064 */ +#define SMB_PRF_ALPHA_21066 0x32 /* Alpha 21066 */ +#define SMB_PRF_ALPHA_21164 0x33 /* Alpha 21164 */ +#define SMB_PRF_ALPHA_21164PC 0x34 /* Alpha 21164PC */ +#define SMB_PRF_ALPHA_21164A 0x35 /* Alpha 21164a */ +#define SMB_PRF_ALPHA_21264 0x36 /* Alpha 21264 */ +#define SMB_PRF_ALPHA_21364 0x37 /* Alpha 21364 */ +#define SMB_PRF_TURION2U_2C_MM 0x38 + /* AMD Turion II Ultra Dual-Core Mobile M */ +#define SMB_PRF_TURION2_2C_MM 0x39 /* AMD Turion II Dual-Core Mobile M */ +#define SMB_PRF_ATHLON2_2C_M 0x3A /* AMD Athlon II Dual-Core M */ +#define SMB_PRF_OPTERON_6100 0x3B /* AMD Opteron 6100 series */ +#define SMB_PRF_OPTERON_4100 0x3C /* AMD Opteron 4100 series */ +#define SMB_PRF_OPTERON_6200 0x3D /* AMD Opteron 6200 series */ +#define SMB_PRF_OPTERON_4200 0x3E /* AMD Opteron 4200 series */ +#define SMB_PRF_AMD_FX 0x3F /* AMD FX series */ +#define SMB_PRF_MIPS 0x40 /* MIPS */ +#define SMB_PRF_MIPS_R4000 0x41 /* MIPS R4000 */ +#define SMB_PRF_MIPS_R4200 0x42 /* MIPS R4200 */ +#define SMB_PRF_MIPS_R4400 0x43 /* MIPS R4400 */ +#define SMB_PRF_MIPS_R4600 0x44 /* MIPS R4600 */ +#define SMB_PRF_MIPS_R10000 0x45 /* MIPS R10000 */ +#define SMB_PRF_AMD_C 0x46 /* AMD C-series */ +#define SMB_PRF_AMD_E 0x47 /* AMD E-series */ +#define SMB_PRF_AMD_A 0x48 /* AMD A-series */ +#define SMB_PRF_AMD_G 0x49 /* AMD G-series */ +#define SMB_PRF_AMD_Z 0x4A /* AMD Z-series */ +#define SMB_PRF_AMD_R 0x4B /* AMD R-series */ +#define SMB_PRF_OPTERON_4300 0x4C /* AMD Opteron 4300 series */ +#define SMB_PRF_OPTERON_6300 0x4D /* AMD Opteron 6300 series */ +#define SMB_PRF_OPTERON_3300 0x4E /* AMD Opteron 3300 series */ +#define SMB_PRF_AMD_FIREPRO 0x4F /* AMD FirePro series */ +#define SMB_PRF_SPARC 0x50 /* SPARC */ +#define SMB_PRF_SUPERSPARC 0x51 /* SuperSPARC */ +#define SMB_PRF_MICROSPARCII 0x52 /* microSPARC II */ +#define SMB_PRF_MICROSPARCIIep 0x53 /* microSPARC IIep */ +#define SMB_PRF_ULTRASPARC 0x54 /* UltraSPARC */ +#define SMB_PRF_USII 0x55 /* UltraSPARC II */ +#define SMB_PRF_USIIi 0x56 /* UltraSPARC IIi */ +#define SMB_PRF_USIII 0x57 /* UltraSPARC III */ +#define SMB_PRF_USIIIi 0x58 /* UltraSPARC IIIi */ +#define SMB_PRF_68040 0x60 /* 68040 */ +#define SMB_PRF_68XXX 0x61 /* 68XXX */ +#define SMB_PRF_68000 0x62 /* 68000 */ +#define SMB_PRF_68010 0x63 /* 68010 */ +#define SMB_PRF_68020 0x64 /* 68020 */ +#define SMB_PRF_68030 0x65 /* 68030 */ +#define SMB_PRF_ATHLON_X4 0x66 /* AMD Athlon X4 Quad-Core */ +#define SMB_PRF_OPTERON_X1K 0x67 /* AMD Opteron X1000 */ +#define SMB_PRF_OPTERON_X2K 0x68 /* AMD Opteron X2000 APU */ +#define SMB_PRF_OPTERON_A 0x69 /* AMD Opteron A Series */ +#define SMB_PRF_OPTERON_X3K 0x6A /* AMD Opteron X3000 APU */ +#define SMB_PRF_ZEN 0x6B /* AMD Zen Processor Family */ +#define SMB_PRF_HOBBIT 0x70 /* Hobbit */ +#define SMB_PRF_TM5000 0x78 /* Crusoe TM5000 */ +#define SMB_PRF_TM3000 0x79 /* Crusoe TM3000 */ +#define SMB_PRF_TM8000 0x7A /* Efficeon TM8000 */ +#define SMB_PRF_WEITEK 0x80 /* Weitek */ +#define SMB_PRF_ITANIC 0x82 /* Itanium */ +#define SMB_PRF_ATHLON64 0x83 /* Athlon64 */ +#define SMB_PRF_OPTERON 0x84 /* Opteron */ +#define SMB_PRF_SEMPRON 0x85 /* Sempron */ +#define SMB_PRF_TURION64_M 0x86 /* Turion 64 Mobile */ +#define SMB_PRF_OPTERON_2C 0x87 /* AMD Opteron Dual-Core */ +#define SMB_PRF_ATHLON64_X2_2C 0x88 /* AMD Athlon 64 X2 Dual-Core */ +#define SMB_PRF_TURION64_X2_M 0x89 /* AMD Turion 64 X2 Mobile */ +#define SMB_PRF_OPTERON_4C 0x8A /* AMD Opteron Quad-Core */ +#define SMB_PRF_OPTERON_3G 0x8B /* AMD Opteron 3rd Generation */ +#define SMB_PRF_PHENOM_FX_4C 0x8C /* AMD Phenom FX Quad-Core */ +#define SMB_PRF_PHENOM_X4_4C 0x8D /* AMD Phenom X4 Quad-Core */ +#define SMB_PRF_PHENOM_X2_2C 0x8E /* AMD Phenom X2 Dual-Core */ +#define SMB_PRF_ATHLON_X2_2C 0x8F /* AMD Athlon X2 Dual-Core */ +#define SMB_PRF_PA 0x90 /* PA-RISC */ +#define SMB_PRF_PA8500 0x91 /* PA-RISC 8500 */ +#define SMB_PRF_PA8000 0x92 /* PA-RISC 8000 */ +#define SMB_PRF_PA7300LC 0x93 /* PA-RISC 7300LC */ +#define SMB_PRF_PA7200 0x94 /* PA-RISC 7200 */ +#define SMB_PRF_PA7100LC 0x95 /* PA-RISC 7100LC */ +#define SMB_PRF_PA7100 0x96 /* PA-RISC 7100 */ +#define SMB_PRF_V30 0xA0 /* V30 */ +#define SMB_PRF_XEON_4C_3200 0xA1 /* Xeon Quad Core 3200 */ +#define SMB_PRF_XEON_2C_3000 0xA2 /* Xeon Dual Core 3000 */ +#define SMB_PRF_XEON_4C_5300 0xA3 /* Xeon Quad Core 5300 */ +#define SMB_PRF_XEON_2C_5100 0xA4 /* Xeon Dual Core 5100 */ +#define SMB_PRF_XEON_2C_5000 0xA5 /* Xeon Dual Core 5000 */ +#define SMB_PRF_XEON_2C_LV 0xA6 /* Xeon Dual Core LV */ +#define SMB_PRF_XEON_2C_ULV 0xA7 /* Xeon Dual Core ULV */ +#define SMB_PRF_XEON_2C_7100 0xA8 /* Xeon Dual Core 7100 */ +#define SMB_PRF_XEON_4C_5400 0xA9 /* Xeon Quad Core 5400 */ +#define SMB_PRF_XEON_4C 0xAA /* Xeon Quad Core */ +#define SMB_PRF_XEON_2C_5200 0xAB /* Xeon Dual Core 5200 */ +#define SMB_PRF_XEON_2C_7200 0xAC /* Xeon Dual Core 7200 */ +#define SMB_PRF_XEON_4C_7300 0xAD /* Xeon Quad Core 7300 */ +#define SMB_PRF_XEON_4C_7400 0xAE /* Xeon Quad Core 7400 */ +#define SMB_PRF_XEON_XC_7400 0xAF /* Xeon Multi Core 7400 */ +#define SMB_PRF_PENTIUMIII_XEON 0xB0 /* Pentium III Xeon */ +#define SMB_PRF_PENTIUMIII_SS 0xB1 /* Pentium III with SpeedStep */ +#define SMB_PRF_P4 0xB2 /* Pentium 4 */ +#define SMB_PRF_XEON 0xB3 /* Intel Xeon */ +#define SMB_PRF_AS400 0xB4 /* AS400 */ +#define SMB_PRF_XEON_MP 0xB5 /* Intel Xeon MP */ +#define SMB_PRF_ATHLON_XP 0xB6 /* AMD Athlon XP */ +#define SMB_PRF_ATHLON_MP 0xB7 /* AMD Athlon MP */ +#define SMB_PRF_ITANIC2 0xB8 /* Itanium 2 */ +#define SMB_PRF_PENTIUM_M 0xB9 /* Pentium M */ +#define SMB_PRF_CELERON_D 0xBA /* Celeron D */ +#define SMB_PRF_PENTIUM_D 0xBB /* Pentium D */ +#define SMB_PRF_PENTIUM_EE 0xBC /* Pentium Extreme Edition */ +#define SMB_PRF_CORE_SOLO 0xBD /* Intel Core Solo */ +#define SMB_PRF_CORE2_DUO 0xBF /* Intel Core 2 Duo */ +#define SMB_PRF_CORE2_SOLO 0xC0 /* Intel Core 2 Solo */ +#define SMB_PRF_CORE2_EX 0xC1 /* Intel Core 2 Extreme */ +#define SMB_PRF_CORE2_QUAD 0xC2 /* Intel Core 2 Quad */ +#define SMB_PRF_CORE2_EX_M 0xC3 /* Intel Core 2 Extreme mobile */ +#define SMB_PRF_CORE2_DUO_M 0xC4 /* Intel Core 2 Duo mobile */ +#define SMB_PRF_CORE2_SOLO_M 0xC5 /* Intel Core 2 Solo mobile */ +#define SMB_PRF_CORE_I7 0xC6 /* Intel Core i7 */ +#define SMB_PRF_CELERON_2C 0xC7 /* Celeron Dual-Core */ +#define SMB_PRF_IBM390 0xC8 /* IBM 390 */ +#define SMB_PRF_G4 0xC9 /* G4 */ +#define SMB_PRF_G5 0xCA /* G5 */ +#define SMB_PRF_ESA390 0xCB /* ESA390 */ +#define SMB_PRF_ZARCH 0xCC /* z/Architecture */ +#define SMB_PRF_CORE_I5 0xCD /* Intel Core i5 */ +#define SMB_PRF_CORE_I3 0xCE /* Intel Core i3 */ +#define SMB_PRF_CORE_I9 0xCF /* Intel Core i9 */ +#define SMD_PRF_XEON_D 0xD0 /* Intel Xeon D */ +#define SMB_PRF_C7M 0xD2 /* VIA C7-M */ +#define SMB_PRF_C7D 0xD3 /* VIA C7-D */ +#define SMB_PRF_C7 0xD4 /* VIA C7 */ +#define SMB_PRF_EDEN 0xD5 /* VIA Eden */ +#define SMB_PRF_XEON_XC 0xD6 /* Intel Xeon Multi-Core */ +#define SMB_PRF_XEON_2C_3XXX 0xD7 /* Intel Xeon Dual-Core 3xxx */ +#define SMB_PRF_XEON_4C_3XXX 0xD8 /* Intel Xeon Quad-Core 3xxx */ +#define SMB_PRF_VIA_NANO 0xD9 /* VIA Nano */ +#define SMB_PRF_XEON_2C_5XXX 0xDA /* Intel Xeon Dual-Core 5xxx */ +#define SMB_PRF_XEON_4C_5XXX 0xDB /* Intel Xeon Quad-Core 5xxx */ +#define SMB_PRF_XEON_2C_7XXX 0xDD /* Intel Xeon Dual-Core 7xxx */ +#define SMB_PRF_XEON_4C_7XXX 0xDE /* Intel Xeon Quad-Core 7xxx */ +#define SMB_PRF_XEON_XC_7XXX 0xDF /* Intel Xeon Multi-Core 7xxx */ +#define SMB_PRF_XEON_XC_3400 0xE0 /* Intel Xeon Multi-Core 3400 */ +#define SMB_PRF_OPTERON_3000 0xE4 /* AMD Opteron 3000 */ +#define SMB_PRF_SEMPRON_II 0xE5 /* AMD Sempron II */ +#define SMB_PRF_OPTERON_4C_EM 0xE6 /* AMD Opteron Quad-Core embedded */ +#define SMB_PRF_PHENOM_3C 0xE7 /* AMD Phenom Triple-Core */ +#define SMB_PRF_TURIONU_2C_M 0xE8 /* AMD Turion Ultra Dual-Core mobile */ +#define SMB_PRF_TURION_2C_M 0xE9 /* AMD Turion Dual-Core mobile */ +#define SMB_PRF_ATHLON_2C 0xEA /* AMD Athlon Dual-Core */ +#define SMB_PRF_SEMPRON_SI 0xEB /* AMD Sempron SI */ +#define SMB_PRF_PHENOM_II 0xEC /* AMD Phenom II */ +#define SMB_PRF_ATHLON_II 0xED /* AMD Athlon II */ +#define SMB_PRF_OPTERON_6C 0xEE /* AMD Opteron Six-Core */ +#define SMB_PRF_SEMPRON_M 0xEF /* AMD Sempron M */ +#define SMB_PRF_I860 0xFA /* i860 */ +#define SMB_PRF_I960 0xFB /* i960 */ +#define SMB_PRF_ARMv7 0x100 /* ARMv7 */ +#define SMB_PRF_ARMv8 0x101 /* ARMv8 */ +#define SMB_PRF_ARMv9 0x102 /* ARMv9 */ +#define SMB_PRF_SH3 0x104 /* SH-3 */ +#define SMB_PRF_SH4 0x105 /* SH-4 */ +#define SMB_PRF_ARM 0x118 /* ARM */ +#define SMB_PRF_SARM 0x119 /* StrongARM */ +#define SMB_PRF_6X86 0x12C /* 6x86 */ +#define SMB_PRF_MEDIAGX 0x12D /* MediaGX */ +#define SMB_PRF_MII 0x12E /* MII */ +#define SMB_PRF_WINCHIP 0x140 /* WinChip */ +#define SMB_PRF_DSP 0x15E /* DSP */ +#define SMB_PRF_VIDEO 0x1F4 /* Video Processor */ +#define SMB_PRF_RV32 0x200 /* RISC-V RV32 */ +#define SMB_PRF_RV64 0x201 /* RISC-V RV64 */ +#define SMB_PRF_RV128 0x202 /* RISC-V RV128 */ +#define SMG_PRF_LOONG_ARCH 0x258 /* LoongArch */ +#define SMG_PRF_LOONG_1 0x259 /* Loongson 1 Processor Family */ +#define SMG_PRF_LOONG_2 0x25A /* Loongson 1 Processor Family */ +#define SMG_PRF_LOONG_3 0x25B /* Loongson 3 Processor Family */ +#define SMG_PRF_LOONG_2K 0x25C /* Loongson 2K Processor Family */ +#define SMG_PRF_LOONG_3A 0x25D /* Loongson 3A Processor Family */ +#define SMG_PRF_LOONG_3B 0x25E /* Loongson 3B Processor Family */ +#define SMG_PRF_LOONG_3C 0x25F /* Loongson 3C Processor Family */ +#define SMG_PRF_LOONG_3D 0x260 /* Loongson 3D Processor Family */ +#define SMG_PRF_LOONG_E3 0x261 /* Loongson 3E Processor Family */ +/* BEGIN CSTYLED */ +#define SMG_PRF_LOONG_2K_DC 0x262 /* Dual-Core Loongson 2K Processor 2xxx Series */ +#define SMG_PRF_LOONG_3A_QC 0x26C /* Quad-Core Loongson 3A Processor 5xxx Series */ +#define SMG_PRF_LOONG_3A_MC 0x26D /* Multi-Core Loongson 3A Processor 5xxx Series */ +#define SMG_PRF_LOONG_3B_QC 0x26E /* Quad-Core Loongson 3B Processor 5xxx Series */ +#define SMG_PRF_LOONG_3B_MC 0x26F /* Multi-Core Loongson 3B Processor 5xxx Series */ +#define SMG_PRF_LOONG_3C_MC 0x270 /* Multi-Core Loongson 3C Processor 5xxx Series */ +#define SMG_PRF_LOONG_3D_MC 0x271 /* Multi-Core Loongson 3D Processor 5xxx Series */ +/* END CSTYLED */ +#define SMG_PRF_CORE_3 0x300 /* Intel Core 3 */ +#define SMG_PRF_CORE_5 0x301 /* Intel Core 5 */ +#define SMG_PRF_CORE_7 0x302 /* Intel Core 7 */ +#define SMG_PRF_CORE_9 0x303 /* Intel Core 9 */ +#define SMG_PRF_CORE_ULT_3 0x304 /* Intel Core Ultra 3 */ +#define SMG_PRF_CORE_ULT_5 0x305 /* Intel Core Ultra 5 */ +#define SMG_PRF_CORE_ULT_7 0x306 /* Intel Core Ultra 7 */ +#define SMG_PRF_CORE_ULT_9 0x307 /* Intel Core Ultra 9 */ + +/* + * SMBIOS Cache Information. See DSP0134 Section 7.8 for more information. + * If smba_size is zero, this indicates the specified cache is not present. + * + * SMBIOS 3.1 added extended cache sizes. Unfortunately, we had already baked in + * the uint32_t sizes, so we added extended uint64_t's that correspond to the + * new fields. To make life easier for consumers, we always make sure that the + * _maxsize2 and _size2 members are filled in with the old value if no other + * value is present. + */ +typedef struct smbios_cache { + uint32_t smba_maxsize; /* maximum installed size in bytes */ + uint32_t smba_size; /* installed size in bytes */ + uint16_t smba_stype; /* supported SRAM types (SMB_CAT_*) */ + uint16_t smba_ctype; /* current SRAM type (SMB_CAT_*) */ + uint8_t smba_speed; /* speed in nanoseconds */ + uint8_t smba_etype; /* error correction type (SMB_CAE_*) */ + uint8_t smba_ltype; /* logical cache type (SMB_CAG_*) */ + uint8_t smba_assoc; /* associativity (SMB_CAA_*) */ + uint8_t smba_level; /* cache level */ + uint8_t smba_mode; /* cache mode (SMB_CAM_*) */ + uint8_t smba_location; /* cache location (SMB_CAL_*) */ + uint8_t smba_flags; /* cache flags (SMB_CAF_*) */ + uint64_t smba_maxsize2; /* maximum installed size in bytes */ + uint64_t smba_size2; /* installed size in bytes */ +} smbios_cache_t; + +#define SMB_CAT_OTHER 0x0001 /* other */ +#define SMB_CAT_UNKNOWN 0x0002 /* unknown */ +#define SMB_CAT_NONBURST 0x0004 /* non-burst */ +#define SMB_CAT_BURST 0x0008 /* burst */ +#define SMB_CAT_PBURST 0x0010 /* pipeline burst */ +#define SMB_CAT_SYNC 0x0020 /* synchronous */ +#define SMB_CAT_ASYNC 0x0040 /* asynchronous */ + +#define SMB_CAE_OTHER 0x01 /* other */ +#define SMB_CAE_UNKNOWN 0x02 /* unknown */ +#define SMB_CAE_NONE 0x03 /* none */ +#define SMB_CAE_PARITY 0x04 /* parity */ +#define SMB_CAE_SBECC 0x05 /* single-bit ECC */ +#define SMB_CAE_MBECC 0x06 /* multi-bit ECC */ + +#define SMB_CAG_OTHER 0x01 /* other */ +#define SMB_CAG_UNKNOWN 0x02 /* unknown */ +#define SMB_CAG_INSTR 0x03 /* instruction */ +#define SMB_CAG_DATA 0x04 /* data */ +#define SMB_CAG_UNIFIED 0x05 /* unified */ + +#define SMB_CAA_OTHER 0x01 /* other */ +#define SMB_CAA_UNKNOWN 0x02 /* unknown */ +#define SMB_CAA_DIRECT 0x03 /* direct mapped */ +#define SMB_CAA_2WAY 0x04 /* 2-way set associative */ +#define SMB_CAA_4WAY 0x05 /* 4-way set associative */ +#define SMB_CAA_FULL 0x06 /* fully associative */ +#define SMB_CAA_8WAY 0x07 /* 8-way set associative */ +#define SMB_CAA_16WAY 0x08 /* 16-way set associative */ +#define SMB_CAA_12WAY 0x09 /* 12-way set associative */ +#define SMB_CAA_24WAY 0x0A /* 24-way set associative */ +#define SMB_CAA_32WAY 0x0B /* 32-way set associative */ +#define SMB_CAA_48WAY 0x0C /* 48-way set associative */ +#define SMB_CAA_64WAY 0x0D /* 64-way set associative */ +#define SMB_CAA_20WAY 0x0E /* 20-way set associative */ + +#define SMB_CAM_WT 0x00 /* write-through */ +#define SMB_CAM_WB 0x01 /* write-back */ +#define SMB_CAM_VARY 0x02 /* varies by address */ +#define SMB_CAM_UNKNOWN 0x03 /* unknown */ + +#define SMB_CAL_INTERNAL 0x00 /* internal */ +#define SMB_CAL_EXTERNAL 0x01 /* external */ +#define SMB_CAL_RESERVED 0x02 /* reserved */ +#define SMB_CAL_UNKNOWN 0x03 /* unknown */ + +#define SMB_CAF_ENABLED 0x01 /* enabled at boot time */ +#define SMB_CAF_SOCKETED 0x02 /* cache is socketed */ + +/* + * SMBIOS Port Information. See DSP0134 Section 7.9 for more information. + * The internal reference designator string is also mapped to the location. + */ +typedef struct smbios_port { + const char *smbo_iref; /* internal reference designator */ + const char *smbo_eref; /* external reference designator */ + uint8_t smbo_itype; /* internal connector type (SMB_POC_*) */ + uint8_t smbo_etype; /* external connector type (SMB_POC_*) */ + uint8_t smbo_ptype; /* port type (SMB_POT_*) */ + uint8_t smbo_pad; /* padding */ +} smbios_port_t; + +#define SMB_POC_NONE 0x00 /* none */ +#define SMB_POC_CENT 0x01 /* Centronics */ +#define SMB_POC_MINICENT 0x02 /* Mini-Centronics */ +#define SMB_POC_PROPRIETARY 0x03 /* proprietary */ +#define SMB_POC_DB25M 0x04 /* DB-25 pin male */ +#define SMB_POC_DB25F 0x05 /* DB-25 pin female */ +#define SMB_POC_DB15M 0x06 /* DB-15 pin male */ +#define SMB_POC_DB15F 0x07 /* DB-15 pin female */ +#define SMB_POC_DB9M 0x08 /* DB-9 pin male */ +#define SMB_POC_DB9F 0x09 /* DB-9 pin female */ +#define SMB_POC_RJ11 0x0A /* RJ-11 */ +#define SMB_POC_RJ45 0x0B /* RJ-45 */ +#define SMB_POC_MINISCSI 0x0C /* 50-pin MiniSCSI */ +#define SMB_POC_MINIDIN 0x0D /* Mini-DIN */ +#define SMB_POC_MICRODIN 0x0E /* Micro-DIN */ +#define SMB_POC_PS2 0x0F /* PS/2 */ +#define SMB_POC_IR 0x10 /* Infrared */ +#define SMB_POC_HPHIL 0x11 /* HP-HIL */ +#define SMB_POC_USB 0x12 /* USB */ +#define SMB_POC_SSA 0x13 /* SSA SCSI */ +#define SMB_POC_DIN8M 0x14 /* Circular DIN-8 male */ +#define SMB_POC_DIN8F 0x15 /* Circular DIN-8 female */ +#define SMB_POC_OBIDE 0x16 /* on-board IDE */ +#define SMB_POC_OBFLOPPY 0x17 /* on-board floppy */ +#define SMB_POC_DI9 0x18 /* 9p dual inline (p10 cut) */ +#define SMB_POC_DI25 0x19 /* 25p dual inline (p26 cut) */ +#define SMB_POC_DI50 0x1A /* 50p dual inline */ +#define SMB_POC_DI68 0x1B /* 68p dual inline */ +#define SMB_POC_CDROM 0x1C /* on-board sound from CDROM */ +#define SMB_POC_MINI14 0x1D /* Mini-Centronics Type 14 */ +#define SMB_POC_MINI26 0x1E /* Mini-Centronics Type 26 */ +#define SMB_POC_MINIJACK 0x1F /* Mini-jack (headphones) */ +#define SMB_POC_BNC 0x20 /* BNC */ +#define SMB_POC_1394 0x21 /* 1394 */ +#define SMB_POC_SATA 0x22 /* SAS/SATA plug receptacle */ +#define SMB_POC_USB_C 0x23 /* USB Type-C receptacle */ +#define SMB_POC_PC98 0xA0 /* PC-98 */ +#define SMB_POC_PC98HR 0xA1 /* PC-98Hireso */ +#define SMB_POC_PCH98 0xA2 /* PC-H98 */ +#define SMB_POC_PC98NOTE 0xA3 /* PC-98Note */ +#define SMB_POC_PC98FULL 0xA4 /* PC-98Full */ +#define SMB_POC_OTHER 0xFF /* other */ + +#define SMB_POT_NONE 0x00 /* none */ +#define SMB_POT_PP_XTAT 0x01 /* Parallel Port XT/AT compat */ +#define SMB_POT_PP_PS2 0x02 /* Parallel Port PS/2 */ +#define SMB_POT_PP_ECP 0x03 /* Parallel Port ECP */ +#define SMB_POT_PP_EPP 0x04 /* Parallel Port EPP */ +#define SMB_POT_PP_ECPEPP 0x05 /* Parallel Port ECP/EPP */ +#define SMB_POT_SP_XTAT 0x06 /* Serial Port XT/AT compat */ +#define SMB_POT_SP_16450 0x07 /* Serial Port 16450 compat */ +#define SMB_POT_SP_16550 0x08 /* Serial Port 16550 compat */ +#define SMB_POT_SP_16550A 0x09 /* Serial Port 16550A compat */ +#define SMB_POT_SCSI 0x0A /* SCSI port */ +#define SMB_POT_MIDI 0x0B /* MIDI port */ +#define SMB_POT_JOYSTICK 0x0C /* Joystick port */ +#define SMB_POT_KEYBOARD 0x0D /* Keyboard port */ +#define SMB_POT_MOUSE 0x0E /* Mouse port */ +#define SMB_POT_SSA 0x0F /* SSA SCSI */ +#define SMB_POT_USB 0x10 /* USB */ +#define SMB_POT_FIREWIRE 0x11 /* FireWrite (IEEE P1394) */ +#define SMB_POT_PCMII 0x12 /* PCMCIA Type II */ +#define SMB_POT_PCMIIa 0x13 /* PCMCIA Type II (alternate) */ +#define SMB_POT_PCMIII 0x14 /* PCMCIA Type III */ +#define SMB_POT_CARDBUS 0x15 /* Cardbus */ +#define SMB_POT_ACCESS 0x16 /* Access Bus Port */ +#define SMB_POT_SCSI2 0x17 /* SCSI II */ +#define SMB_POT_SCSIW 0x18 /* SCSI Wide */ +#define SMB_POT_PC98 0x19 /* PC-98 */ +#define SMB_POT_PC98HR 0x1A /* PC-98Hireso */ +#define SMB_POT_PCH98 0x1B /* PC-H98 */ +#define SMB_POT_VIDEO 0x1C /* Video port */ +#define SMB_POT_AUDIO 0x1D /* Audio port */ +#define SMB_POT_MODEM 0x1E /* Modem port */ +#define SMB_POT_NETWORK 0x1F /* Network port */ +#define SMB_POT_SATA 0x20 /* SATA */ +#define SMB_POT_SAS 0x21 /* SAS */ +#define SMB_POT_MFDP 0x22 /* MFDP (Multi-Function Display Port) */ +#define SMB_POT_THUNDERBOLT 0x23 /* Thunderbolt */ +#define SMB_POT_8251 0xA0 /* 8251 compatible */ +#define SMB_POT_8251F 0xA1 /* 8251 FIFO compatible */ +#define SMB_POT_OTHER 0xFF /* other */ + +/* + * SMBIOS Slot Information. See DSP0134 Section 7.10 for more information. + * See DSP0134 7.10.5 for how to interpret the value of smbl_id. + */ +typedef struct smbios_slot { + const char *smbl_name; /* reference designation */ + uint8_t smbl_type; /* slot type */ + uint8_t smbl_width; /* slot data bus width */ + uint8_t smbl_usage; /* current usage */ + uint8_t smbl_length; /* slot length */ + uint16_t smbl_id; /* slot ID */ + uint8_t smbl_ch1; /* slot characteristics 1 */ + uint8_t smbl_ch2; /* slot characteristics 2 */ + uint16_t smbl_sg; /* segment group number */ + uint8_t smbl_bus; /* bus number */ + uint8_t smbl_df; /* device/function number */ + uint8_t smbl_dbw; /* data bus width */ + uint8_t smbl_npeers; /* PCIe bifurcation peers */ + uint8_t smbl_info; /* slot info */ + uint8_t smbl_pwidth; /* slot physical width */ + uint32_t smbl_pitch; /* slot pitch in 10um */ + uint8_t smbl_height; /* slot height */ +} smbios_slot_t; + +#define SMB_SLT_OTHER 0x01 /* other */ +#define SMB_SLT_UNKNOWN 0x02 /* unknown */ +#define SMB_SLT_ISA 0x03 /* ISA */ +#define SMB_SLT_MCA 0x04 /* MCA */ +#define SMB_SLT_EISA 0x05 /* EISA */ +#define SMB_SLT_PCI 0x06 /* PCI */ +#define SMB_SLT_PCMCIA 0x07 /* PCMCIA */ +#define SMB_SLT_VLVESA 0x08 /* VL-VESA */ +#define SMB_SLT_PROPRIETARY 0x09 /* proprietary */ +#define SMB_SLT_PROC 0x0A /* processor card slot */ +#define SMB_SLT_MEM 0x0B /* proprietary memory card slot */ +#define SMB_SLT_IOR 0x0C /* I/O riser card slot */ +#define SMB_SLT_NUBUS 0x0D /* NuBus */ +#define SMB_SLT_PCI66 0x0E /* PCI (66MHz capable) */ +#define SMB_SLT_AGP 0x0F /* AGP */ +#define SMB_SLT_AGP2X 0x10 /* AGP 2X */ +#define SMB_SLT_AGP4X 0x11 /* AGP 4X */ +#define SMB_SLT_PCIX 0x12 /* PCI-X */ +#define SMB_SLT_AGP8X 0x13 /* AGP 8X */ +#define SMB_SLT_M2_1DP 0x14 /* M.2 Socket 1-DP (Mechanical Key A) */ +#define SMB_SLT_M2_1SD 0x15 /* M.2 Socket 1-SD (Mechanical Key E) */ +#define SMB_SLT_M2_2 0x16 /* M.2 Socket 2 (Mechanical Key B) */ +#define SMB_SLT_M2_3 0x17 /* M.2 Socket 3 (Mechanical Key M) */ +#define SMB_SLT_MXM_I 0x18 /* MXM Type I */ +#define SMB_SLT_MXM_II 0x19 /* MXM Type II */ +#define SMB_SLT_MXM_III 0x1A /* MXM Type III (standard connector) */ +#define SMB_SLT_MXM_III_HE 0x1B /* MXM Type III (HE connector) */ +#define SMB_SLT_MXM_V 0x1C /* MXM Type IV */ +#define SMB_SLT_MXM3_A 0x1D /* MXM 3.0 Type A */ +#define SMB_SLT_MXM3_B 0x1E /* MXM 3.0 Type B */ +#define SMB_SLT_PCIEG2_SFF 0x1F /* PCI Express Gen 2 SFF-8639 (U.2) */ +#define SMB_SLT_PCIEG3_SFF 0x20 /* PCI Express Gen 3 SFF-8639 (U.2) */ +/* + * These lines must be on one line for the string generating code. + */ +/* BEGIN CSTYLED */ +#define SMB_SLT_PCIE_M52_WBSKO 0x21 /* PCI Express Mini 52-pin with bottom-side keep-outs */ +#define SMB_SLT_PCIE_M52_WOBSKO 0x22 /* PCI Express Mini 52-pin without bottom-side keep-outs */ +/* END CSTYLED */ +#define SMB_SLT_PCIE_M76 0x23 /* PCI Express Mini 72-pin */ +#define SMB_SLT_PCIEG4_SFF 0x24 /* PCI Express Gen 4 SFF-8639 (U.2) */ +#define SMB_SLT_PCIEG5_SFF 0x25 /* PCI Express Gen 5 SFF-8639 (U.2) */ +#define SMB_SLT_OCP3_SFF 0x26 /* OCP NIC 3.0 Small Form Factor */ +#define SMB_SLT_OCP3_LFF 0x27 /* OCP NIC 3.0 Large Form Factor */ +#define SMB_SLT_OCP_PRE 0x28 /* OCP NIC prior to 3.0 */ +#define SMB_SLT_CXL1 0x30 /* CXL Flexbus 1.0 */ +#define SMB_SLT_PC98_C20 0xA0 /* PC-98/C20 */ +#define SMB_SLT_PC98_C24 0xA1 /* PC-98/C24 */ +#define SMB_SLT_PC98_E 0xA2 /* PC-98/E */ +#define SMB_SLT_PC98_LB 0xA3 /* PC-98/Local Bus */ +#define SMB_SLT_PC98_C 0xA4 /* PC-98/Card */ +#define SMB_SLT_PCIE 0xA5 /* PCI Express */ +#define SMB_SLT_PCIE1 0xA6 /* PCI Express x1 */ +#define SMB_SLT_PCIE2 0xA7 /* PCI Express x2 */ +#define SMB_SLT_PCIE4 0xA8 /* PCI Express x4 */ +#define SMB_SLT_PCIE8 0xA9 /* PCI Express x8 */ +#define SMB_SLT_PCIE16 0xAA /* PCI Express x16 */ +#define SMB_SLT_PCIE2G 0xAB /* PCI Exp. Gen 2 */ +#define SMB_SLT_PCIE2G1 0xAC /* PCI Exp. Gen 2 x1 */ +#define SMB_SLT_PCIE2G2 0xAD /* PCI Exp. Gen 2 x2 */ +#define SMB_SLT_PCIE2G4 0xAE /* PCI Exp. Gen 2 x4 */ +#define SMB_SLT_PCIE2G8 0xAF /* PCI Exp. Gen 2 x8 */ +#define SMB_SLT_PCIE2G16 0xB0 /* PCI Exp. Gen 2 x16 */ +#define SMB_SLT_PCIE3G 0xB1 /* PCI Exp. Gen 3 */ +#define SMB_SLT_PCIE3G1 0xB2 /* PCI Exp. Gen 3 x1 */ +#define SMB_SLT_PCIE3G2 0xB3 /* PCI Exp. Gen 3 x2 */ +#define SMB_SLT_PCIE3G4 0xB4 /* PCI Exp. Gen 3 x4 */ +#define SMB_SLT_PCIE3G8 0xB5 /* PCI Exp. Gen 3 x8 */ +#define SMB_SLT_PCIE3G16 0xB6 /* PCI Exp. Gen 3 x16 */ +#define SMB_SLT_PCIE4G 0xB8 /* PCI Exp. Gen 4 */ +#define SMB_SLT_PCIE4G1 0xB9 /* PCI Exp. Gen 4 x1 */ +#define SMB_SLT_PCIE4G2 0xBA /* PCI Exp. Gen 4 x2 */ +#define SMB_SLT_PCIE4G4 0xBB /* PCI Exp. Gen 4 x4 */ +#define SMB_SLT_PCIE4G8 0xBC /* PCI Exp. Gen 4 x8 */ +#define SMB_SLT_PCIE4G16 0xBD /* PCI Exp. Gen 4 x16 */ +#define SMB_SLT_PCIE5G 0xBE /* PCI Exp. Gen 5 */ +#define SMB_SLT_PCIE5G1 0xBF /* PCI Exp. Gen 5 x1 */ +#define SMB_SLT_PCIE5G2 0xC0 /* PCI Exp. Gen 5 x2 */ +#define SMB_SLT_PCIE5G4 0xC1 /* PCI Exp. Gen 5 x4 */ +#define SMB_SLT_PCIE5G8 0xC2 /* PCI Exp. Gen 5 x8 */ +#define SMB_SLT_PCIE5G16 0xC3 /* PCI Exp. Gen 5 x16 */ +#define SMB_SLT_PCIEG6P 0xC4 /* PCI Exp. Gen 6+ */ +#define SMB_SLT_EDSFF_E1 0xC5 /* Ent. and DC 1U E1 Form Factor */ +#define SMB_SLT_EDSFF_E3 0xC6 /* Ent. and DC 3" E3 Form Factor */ + +#define SMB_SLW_OTHER 0x01 /* other */ +#define SMB_SLW_UNKNOWN 0x02 /* unknown */ +#define SMB_SLW_8 0x03 /* 8 bit */ +#define SMB_SLW_16 0x04 /* 16 bit */ +#define SMB_SLW_32 0x05 /* 32 bit */ +#define SMB_SLW_64 0x06 /* 64 bit */ +#define SMB_SLW_128 0x07 /* 128 bit */ +#define SMB_SLW_1X 0x08 /* 1x or x1 */ +#define SMB_SLW_2X 0x09 /* 2x or x2 */ +#define SMB_SLW_4X 0x0A /* 4x or x4 */ +#define SMB_SLW_8X 0x0B /* 8x or x8 */ +#define SMB_SLW_12X 0x0C /* 12x or x12 */ +#define SMB_SLW_16X 0x0D /* 16x or x16 */ +#define SMB_SLW_32X 0x0E /* 32x or x32 */ + +#define SMB_SLU_OTHER 0x01 /* other */ +#define SMB_SLU_UNKNOWN 0x02 /* unknown */ +#define SMB_SLU_AVAIL 0x03 /* available */ +#define SMB_SLU_INUSE 0x04 /* in use */ + +#define SMB_SLL_OTHER 0x01 /* other */ +#define SMB_SLL_UNKNOWN 0x02 /* unknown */ +#define SMB_SLL_SHORT 0x03 /* short length */ +#define SMB_SLL_LONG 0x04 /* long length */ +#define SMB_SLL_2IN5 0x05 /* 2.5" drive form factor */ +#define SMB_SLL_3IN5 0x06 /* 3.5" drive form factor */ + +#define SMB_SLCH1_UNKNOWN 0x01 /* characteristics unknown */ +#define SMB_SLCH1_5V 0x02 /* provides 5.0V */ +#define SMB_SLCH1_33V 0x04 /* provides 3.3V */ +#define SMB_SLCH1_SHARED 0x08 /* opening shared with other slot */ +#define SMB_SLCH1_PC16 0x10 /* slot supports PC Card-16 */ +#define SMB_SLCH1_PCCB 0x20 /* slot supports CardBus */ +#define SMB_SLCH1_PCZV 0x40 /* slot supports Zoom Video */ +#define SMB_SLCH1_PCMRR 0x80 /* slot supports Modem Ring Resume */ + +#define SMB_SLCH2_PME 0x01 /* slot supports PME# signal */ +#define SMB_SLCH2_HOTPLUG 0x02 /* slot supports hot-plug devices */ +#define SMB_SLCH2_SMBUS 0x04 /* slot supports SMBus signal */ +#define SMB_SLCH2_BIFUR 0x08 /* slot supports PCIe bifurcation */ +#define SMB_SLCH2_SURPREM 0x10 /* slot supports surprise removal */ +#define SMB_SLCH2_CXL1 0x20 /* Flexbus slot, CXL 1.0 capable */ +#define SMB_SLCH2_CXL2 0x40 /* Flexbus slot, CXL 2.0 capable */ +#define SMB_SLCH2_CXL3 0x80 /* Flexbus slot, CXL 3.0 capable */ + +#define SMB_SLHT_NA 0x00 /* not applicable */ +#define SMB_SLHT_OTHER 0x01 /* other */ +#define SMB_SLHT_UNKNOWN 0x02 /* unknown */ +#define SMB_SLHT_FULL 0x03 /* full height */ +#define SMB_SLHT_LP 0x04 /* low profile */ + +/* + * SMBIOS 7.10.9 Slot Peer Devices + * + * This structure represents an optional peer device that may be part of an + * SMBIOS 3.2 slot. + */ +typedef struct smbios_slot_peer { + uint16_t smblp_group; /* peer segment group number */ + uint8_t smblp_bus; /* peer bus number */ + uint8_t smblp_device; /* peer device number */ + uint8_t smblp_function; /* peer function number */ + uint8_t smblp_data_width; /* peer data bus width */ +} smbios_slot_peer_t; + +/* + * SMBIOS On-Board Device Information. See DSP0134 Section 7.11 for more + * information. Any number of on-board device sections may be present, each + * containing one or more records. The smbios_info_obdevs() function permits + * the caller to retrieve one or more of the records from a given section. + */ +typedef struct smbios_obdev { + const char *smbd_name; /* description string for this device */ + uint8_t smbd_type; /* type code (SMB_OBT_*) */ + uint8_t smbd_enabled; /* boolean (device is enabled) */ +} smbios_obdev_t; + +#define SMB_OBT_OTHER 0x01 /* other */ +#define SMB_OBT_UNKNOWN 0x02 /* unknown */ +#define SMB_OBT_VIDEO 0x03 /* video */ +#define SMB_OBT_SCSI 0x04 /* scsi */ +#define SMB_OBT_ETHERNET 0x05 /* ethernet */ +#define SMB_OBT_TOKEN 0x06 /* token ring */ +#define SMB_OBT_SOUND 0x07 /* sound */ +#define SMB_OBT_PATA 0x08 /* pata */ +#define SMB_OBT_SATA 0x09 /* sata */ +#define SMB_OBT_SAS 0x0A /* sas */ + +/* + * SMBIOS BIOS Language Information. See DSP0134 Section 7.14 for more + * information. The smbios_info_strtab() function can be applied using a + * count of smbla_num to retrieve the other possible language settings. + */ +typedef struct smbios_lang { + const char *smbla_cur; /* current language setting */ + uint_t smbla_fmt; /* language name format (see below) */ + uint_t smbla_num; /* number of installed languages */ +} smbios_lang_t; + +#define SMB_LFMT_LONG 0 /* ||Encoding Method */ +#define SMB_LFMT_SHORT 1 /* */ + +/* + * SMBIOS System Event Log Information. See DSP0134 Section 7.16 for more + * information. Accessing the event log itself requires additional interfaces. + */ +typedef struct smbios_evtype { + uint8_t smbevt_ltype; /* log type */ + uint8_t smbevt_dtype; /* variable data format type */ +} smbios_evtype_t; + +typedef struct smbios_evlog { + size_t smbev_size; /* size in bytes of log area */ + size_t smbev_hdr; /* offset or index of header */ + size_t smbev_data; /* offset or index of data */ + uint8_t smbev_method; /* data access method (see below) */ + uint8_t smbev_flags; /* flags (see below) */ + uint8_t smbev_format; /* log header format (see below) */ + uint8_t smbev_pad; /* padding */ + uint32_t smbev_token; /* data update change token */ + union { + struct { + uint16_t evi_iaddr; /* index address */ + uint16_t evi_daddr; /* data address */ + } eva_io; /* i/o address for SMB_EVM_XxY */ + uint32_t eva_addr; /* address for SMB_EVM_MEM32 */ + uint16_t eva_gpnv; /* handle for SMB_EVM_GPNV */ + } smbev_addr; + uint32_t smbev_typec; /* number of type descriptors */ + const smbios_evtype_t *smbev_typev; /* type descriptor array */ +} smbios_evlog_t; + +#define SMB_EVM_1x1i_1x1d 0 /* I/O: 1 1b idx port, 1 1b data port */ +#define SMB_EVM_2x1i_1x1d 1 /* I/O: 2 1b idx port, 1 1b data port */ +#define SMB_EVM_1x2i_1x1d 2 /* I/O: 1 2b idx port, 1 1b data port */ +#define SMB_EVM_MEM32 3 /* Memory-Mapped 32-bit Physical Addr */ +#define SMB_EVM_GPNV 4 /* GP Non-Volatile API Access */ + +#define SMB_EVFL_VALID 0x1 /* log area valid */ +#define SMB_EVFL_FULL 0x2 /* log area full */ + +#define SMB_EVHF_NONE 0 /* no log headers used */ +#define SMB_EVHF_F1 1 /* DMTF log header type 1 */ + +/* + * SMBIOS Physical Memory Array Information. See DSP0134 Section 7.17 for + * more information. This describes a collection of physical memory devices. + */ +typedef struct smbios_memarray { + uint8_t smbma_location; /* physical device location */ + uint8_t smbma_use; /* physical device functional purpose */ + uint8_t smbma_ecc; /* error detect/correct mechanism */ + uint8_t smbma_pad0; /* padding */ + uint32_t smbma_pad1; /* padding */ + uint32_t smbma_ndevs; /* number of slots or sockets */ + id_t smbma_err; /* handle of error (if any) */ + uint64_t smbma_size; /* maximum capacity in bytes */ +} smbios_memarray_t; + +#define SMB_MAL_OTHER 0x01 /* other */ +#define SMB_MAL_UNKNOWN 0x02 /* unknown */ +#define SMB_MAL_SYSMB 0x03 /* system board or motherboard */ +#define SMB_MAL_ISA 0x04 /* ISA add-on card */ +#define SMB_MAL_EISA 0x05 /* EISA add-on card */ +#define SMB_MAL_PCI 0x06 /* PCI add-on card */ +#define SMB_MAL_MCA 0x07 /* MCA add-on card */ +#define SMB_MAL_PCMCIA 0x08 /* PCMCIA add-on card */ +#define SMB_MAL_PROP 0x09 /* proprietary add-on card */ +#define SMB_MAL_NUBUS 0x0A /* NuBus */ +#define SMB_MAL_PC98C20 0xA0 /* PC-98/C20 add-on card */ +#define SMB_MAL_PC98C24 0xA1 /* PC-98/C24 add-on card */ +#define SMB_MAL_PC98E 0xA2 /* PC-98/E add-on card */ +#define SMB_MAL_PC98LB 0xA3 /* PC-98/Local bus add-on card */ +#define SMB_MAL_CXL1 0xA4 /* CXL add-on card */ + +#define SMB_MAU_OTHER 0x01 /* other */ +#define SMB_MAU_UNKNOWN 0x02 /* unknown */ +#define SMB_MAU_SYSTEM 0x03 /* system memory */ +#define SMB_MAU_VIDEO 0x04 /* video memory */ +#define SMB_MAU_FLASH 0x05 /* flash memory */ +#define SMB_MAU_NVRAM 0x06 /* non-volatile RAM */ +#define SMB_MAU_CACHE 0x07 /* cache memory */ + +#define SMB_MAE_OTHER 0x01 /* other */ +#define SMB_MAE_UNKNOWN 0x02 /* unknown */ +#define SMB_MAE_NONE 0x03 /* none */ +#define SMB_MAE_PARITY 0x04 /* parity */ +#define SMB_MAE_SECC 0x05 /* single-bit ECC */ +#define SMB_MAE_MECC 0x06 /* multi-bit ECC */ +#define SMB_MAE_CRC 0x07 /* CRC */ + +/* + * SMBIOS Memory Device Information. See DSP0134 Section 7.18 for more + * information. One or more of these structures are associated with each + * smbios_memarray_t. A structure is present even for unpopulated sockets. + * Unknown values are set to -1. A smbmd_size of 0 indicates unpopulated. + * WARNING: Some BIOSes appear to export the *maximum* size of the device + * that can appear in the corresponding socket as opposed to the current one. + */ +typedef struct smbios_memdevice { + id_t smbmd_array; /* handle of physical memory array */ + id_t smbmd_error; /* handle of memory error data */ + uint32_t smbmd_twidth; /* total width in bits including ecc */ + uint32_t smbmd_dwidth; /* data width in bits */ + uint64_t smbmd_size; /* size in bytes (see note above) */ + uint8_t smbmd_form; /* form factor */ + uint8_t smbmd_set; /* set (0x00=none, 0xFF=unknown) */ + uint8_t smbmd_type; /* memory type */ + uint8_t smbmd_pad; /* padding */ + uint32_t smbmd_flags; /* flags (see below) */ + uint32_t smbmd_speed; /* speed in MT/s */ + const char *smbmd_dloc; /* physical device locator string */ + const char *smbmd_bloc; /* physical bank locator string */ + uint8_t smbmd_rank; /* rank */ + uint16_t smbmd_clkspeed; /* configured clock speed */ + uint16_t smbmd_minvolt; /* minimum voltage */ + uint16_t smbmd_maxvolt; /* maximum voltage */ + uint16_t smbmd_confvolt; /* configured voltage */ + uint8_t smbmd_memtech; /* memory technology */ + uint32_t smbmd_opcap_flags; /* operating mode capability */ + const char *smbmd_firmware_rev; /* firmware rev */ + uint16_t smbmd_modmfg_id; /* JEDEC module mfg id */ + uint16_t smbmd_modprod_id; /* JEDEC module product id */ + uint16_t smbmd_cntrlmfg_id; /* JEDEC controller mfg id */ + uint16_t smbmd_cntrlprod_id; /* JEDEC controller prod id */ + uint64_t smbmd_nvsize; /* non-volatile size in bytes */ + uint64_t smbmd_volatile_size; /* volatile size in bytes */ + uint64_t smbmd_cache_size; /* cache size in bytes */ + uint64_t smbmd_logical_size; /* logical size in bytes */ + uint64_t smbmd_extspeed; /* extended device speed */ + uint64_t smbmd_extclkspeed; /* extended configured speed */ + uint16_t smbmd_pmic0_mfgid; /* JEDEC PMIC0 mfg id */ + uint16_t smbmd_pmic0_rev; /* JEDEC PMIC0 revision id */ + uint16_t smbmd_rcd_mfgid; /* JEDEC RCD mfg id */ + uint16_t smbmd_rcd_rev; /* JEDEC RCD revision id */ +} smbios_memdevice_t; + +#define SMB_MD_MFG_UNKNOWN 0x0000 +#define SMB_MD_REV_UNKNOWN 0xff00 + +#define SMB_MDFF_OTHER 0x01 /* other */ +#define SMB_MDFF_UNKNOWN 0x02 /* unknown */ +#define SMB_MDFF_SIMM 0x03 /* SIMM */ +#define SMB_MDFF_SIP 0x04 /* SIP */ +#define SMB_MDFF_CHIP 0x05 /* chip */ +#define SMB_MDFF_DIP 0x06 /* DIP */ +#define SMB_MDFF_ZIP 0x07 /* ZIP */ +#define SMB_MDFF_PROP 0x08 /* proprietary card */ +#define SMB_MDFF_DIMM 0x09 /* DIMM */ +#define SMB_MDFF_TSOP 0x0A /* TSOP */ +#define SMB_MDFF_CHIPROW 0x0B /* row of chips */ +#define SMB_MDFF_RIMM 0x0C /* RIMM */ +#define SMB_MDFF_SODIMM 0x0D /* SODIMM */ +#define SMB_MDFF_SRIMM 0x0E /* SRIMM */ +#define SMB_MDFF_FBDIMM 0x0F /* FBDIMM */ +#define SMB_MDFF_DIE 0x10 /* die */ +#define SMB_MDFF_CAMM 0x11 /* CAMM */ +#define SMB_MDFF_CUDIMM 0x12 /* CUDIMM */ +#define SMB_MDFF_CSODIMM 0x13 /* CSODIMM */ + +#define SMB_MDT_OTHER 0x01 /* other */ +#define SMB_MDT_UNKNOWN 0x02 /* unknown */ +#define SMB_MDT_DRAM 0x03 /* DRAM */ +#define SMB_MDT_EDRAM 0x04 /* EDRAM */ +#define SMB_MDT_VRAM 0x05 /* VRAM */ +#define SMB_MDT_SRAM 0x06 /* SRAM */ +#define SMB_MDT_RAM 0x07 /* RAM */ +#define SMB_MDT_ROM 0x08 /* ROM */ +#define SMB_MDT_FLASH 0x09 /* FLASH */ +#define SMB_MDT_EEPROM 0x0A /* EEPROM */ +#define SMB_MDT_FEPROM 0x0B /* FEPROM */ +#define SMB_MDT_EPROM 0x0C /* EPROM */ +#define SMB_MDT_CDRAM 0x0D /* CDRAM */ +#define SMB_MDT_3DRAM 0x0E /* 3DRAM */ +#define SMB_MDT_SDRAM 0x0F /* SDRAM */ +#define SMB_MDT_SGRAM 0x10 /* SGRAM */ +#define SMB_MDT_RDRAM 0x11 /* RDRAM */ +#define SMB_MDT_DDR 0x12 /* DDR */ +#define SMB_MDT_DDR2 0x13 /* DDR2 */ +#define SMB_MDT_DDR2FBDIMM 0x14 /* DDR2 FBDIMM */ +#define SMB_MDT_DDR3 0x18 /* DDR3 */ +#define SMB_MDT_FBD2 0x19 /* FBD2 */ +#define SMB_MDT_DDR4 0x1A /* DDR4 */ +#define SMB_MDT_LPDDR 0x1B /* LPDDR */ +#define SMB_MDT_LPDDR2 0x1C /* LPDDR2 */ +#define SMB_MDT_LPDDR3 0x1D /* LPDDR3 */ +#define SMB_MDT_LPDDR4 0x1E /* LPDDR4 */ +#define SMB_MDT_LOGNV 0x1F /* Logical non-volatile device */ +#define SMB_MDT_HBM 0x20 /* High Bandwidth Memory */ +#define SMB_MDT_HBM2 0x21 /* High Bandwidth Memory 2 */ +#define SMB_MDT_DDR5 0x22 /* DDR5 */ +#define SMB_MDT_LPDDR5 0x23 /* LPDDR5 */ +#define SMB_MDT_HBM3 0x24 /* HBM3 */ +#define SMB_MDT_MRDIMM 0x25 /* MRDIMM */ + +#define SMB_MDF_OTHER 0x0002 /* other */ +#define SMB_MDF_UNKNOWN 0x0004 /* unknown */ +#define SMB_MDF_FASTPG 0x0008 /* fast-paged */ +#define SMB_MDF_STATIC 0x0010 /* static column */ +#define SMB_MDF_PSTATIC 0x0020 /* pseudo-static */ +#define SMB_MDF_RAMBUS 0x0040 /* RAMBUS */ +#define SMB_MDF_SYNC 0x0080 /* synchronous */ +#define SMB_MDF_CMOS 0x0100 /* CMOS */ +#define SMB_MDF_EDO 0x0200 /* EDO */ +#define SMB_MDF_WDRAM 0x0400 /* Window DRAM */ +#define SMB_MDF_CDRAM 0x0800 /* Cache DRAM */ +#define SMB_MDF_NV 0x1000 /* non-volatile */ +#define SMB_MDF_REG 0x2000 /* Registered (Buffered) */ +#define SMB_MDF_UNREG 0x4000 /* Unregistered (Unbuffered) */ +#define SMB_MDF_LRDIMM 0x8000 /* LRDIMM */ + +#define SMB_MDR_SINGLE 0x01 /* single */ +#define SMB_MDR_DUAL 0x02 /* dual */ +#define SMB_MDR_QUAD 0x04 /* quad */ +#define SMB_MDR_OCTAL 0x08 /* octal */ + +#define SMB_MTECH_OTHER 0x01 /* other */ +#define SMB_MTECH_UNKNOWN 0x02 /* unknown */ +#define SMB_MTECH_DRAM 0x03 /* DRAM */ +#define SMB_MTECH_NVDIMM_N 0x04 /* NVDIMM-N */ +#define SMB_MTECH_NVDIMM_F 0x05 /* NVDIMM-F */ +#define SMB_MTECH_NVDIMM_P 0x06 /* NVDIMM-P */ +#define SMB_MTECH_INTCPM 0x07 /* Intel Optane persistent memory */ + +#define SMB_MOMC_RESERVED 0x01 /* reserved */ +#define SMB_MOMC_OTHER 0x02 /* other */ +#define SMB_MOMC_UNKNOWN 0x04 /* unknown */ +#define SMB_MOMC_VOLATILE 0x08 /* Volatile memory */ +#define SMB_MOMC_BYTE_PM 0x10 /* Byte-accessible persistent memory */ +#define SMB_MOMC_BLOCK_PM 0x20 /* Block-accessible persistent memory */ + +/* + * SMBIOS Memory Array Mapped Address. See DSP0134 Section 7.20 for more + * information. We convert start/end addresses into addr/size for convenience. + */ +typedef struct smbios_memarrmap { + id_t smbmam_array; /* physical memory array handle */ + uint32_t smbmam_width; /* number of devices that form a row */ + uint64_t smbmam_addr; /* physical address of mapping */ + uint64_t smbmam_size; /* size in bytes of address range */ +} smbios_memarrmap_t; + +/* + * SMBIOS Memory Device Mapped Address. See DSP0134 Section 7.21 for more + * information. We convert start/end addresses into addr/size for convenience. + */ +typedef struct smbios_memdevmap { + id_t smbmdm_device; /* memory device handle */ + id_t smbmdm_arrmap; /* memory array mapped address handle */ + uint64_t smbmdm_addr; /* physical address of mapping */ + uint64_t smbmdm_size; /* size in bytes of address range */ + uint8_t smbmdm_rpos; /* partition row position */ + uint8_t smbmdm_ipos; /* interleave position */ + uint8_t smbmdm_idepth; /* interleave data depth */ +} smbios_memdevmap_t; + +/* + * SMBIOS Builtin Pointing Device (SMB_TYPE_POINTDEV). See DSP0134 Sectin 7.22 + * for more information. + */ +typedef struct smbios_pointdev { + uint16_t smbpd_type; /* device type */ + uint16_t smbpd_iface; /* device information */ + uint8_t smbpd_nbuttons; /* number of buttons */ +} smbios_pointdev_t; + +#define SMB_PDT_OTHER 0x01 /* Other */ +#define SMB_PDT_UNKNOWN 0x02 /* Unknown */ +#define SMB_PDT_MOUSE 0x03 /* Mouse */ +#define SMB_PDT_TRBALL 0x04 /* Track Ball */ +#define SMB_PDT_TRPOINT 0x05 /* Track Point */ +#define SMB_PDT_GLPOINT 0x06 /* Glide Point */ +#define SMB_PDT_TOPAD 0x07 /* Touch Pad */ +#define SMB_PDT_TOSCREEN 0x08 /* Touch Screen */ +#define SMB_PDT_OPTSENSE 0x09 /* Optical Sensor */ + +#define SMB_PDI_OTHER 0x01 /* Other */ +#define SMB_PDI_UNKNOWN 0x02 /* Unknown */ +#define SMB_PDI_SERIAL 0x03 /* Serial */ +#define SMB_PDI_PS2 0x04 /* PS/2 */ +#define SMB_PDI_INFRARED 0x05 /* Infrared */ +#define SMB_PDI_HPHIL 0x06 /* HP-HIL */ +#define SMB_PDI_BUSM 0x07 /* Bus mouse */ +#define SMB_PDI_ADB 0x08 /* ADB (Apple Desktop Bus) */ +#define SMB_PDI_BUSM_DB9 0xA0 /* Bus mouse DB-9 */ +#define SMB_PDI_BUSM_UDIN 0xA1 /* Bus mouse micro-DIN */ +#define SMB_PDI_USB 0xA2 /* USB */ +#define SMB_PDI_I2C 0xA3 /* I2C */ +#define SMB_PDI_SPI 0xA4 /* SPI */ + +/* + * SMBIOS Portable Battery. See DSP0134 Section 7.23 for more information. + */ +typedef struct smbios_battery { + const char *smbb_date; /* Manufacture date */ + const char *smbb_serial; /* Serial number */ + uint8_t smbb_chem; /* Device Chemistry */ + uint32_t smbb_cap; /* Design Capacity */ + uint16_t smbb_volt; /* Design Voltage */ + const char *smbb_version; /* Smart Battery version */ + uint8_t smbb_err; /* Maximum error */ + uint16_t smbb_ssn; /* SBDS serial number */ + uint16_t smbb_syear; /* SBDS manufacture year */ + uint8_t smbb_smonth; /* SBDS manufacture month */ + uint8_t smbb_sday; /* SBDS manufacture day */ + const char *smbb_schem; /* SBDS chemistry */ + uint32_t smbb_oemdata; /* OEM data */ +} smbios_battery_t; + +#define SMB_BDC_OTHER 0x01 /* Other */ +#define SMB_BDC_UNKNOWN 0x02 /* Unknown */ +#define SMB_BDC_LEADACID 0x03 /* Lead Acid */ +#define SMB_BDC_NICD 0x04 /* Nickel Cadmium */ +#define SMB_BDC_NIMH 0x05 /* Nickel Metal hydride */ +#define SMB_BDC_LIB 0x06 /* Lithium-ion */ +#define SMB_BDC_ZINCAIR 0x07 /* Zinc air */ +#define SMB_BDC_LIPO 0x08 /* Lithium Polymer */ + +/* + * SMBIOS Hardware Security Settings. See DSP0134 Section 7.25 for more + * information. Only one such record will be present in the SMBIOS. + */ +typedef struct smbios_hwsec { + uint8_t smbh_pwr_ps; /* power-on password status */ + uint8_t smbh_kbd_ps; /* keyboard password status */ + uint8_t smbh_adm_ps; /* administrator password status */ + uint8_t smbh_pan_ps; /* front panel reset status */ +} smbios_hwsec_t; + +#define SMB_HWSEC_PS_DISABLED 0x00 /* password disabled */ +#define SMB_HWSEC_PS_ENABLED 0x01 /* password enabled */ +#define SMB_HWSEC_PS_NOTIMPL 0x02 /* password not implemented */ +#define SMB_HWSEC_PS_UNKNOWN 0x03 /* password status unknown */ + +/* + * This value is used to represent a probe that has an unknown value. + */ +#define SMB_PROBE_UNKNOWN_VALUE 0x8000 + +/* + * SMBIOS Voltage Probe. See DSP0134 Section 7.27 for more information. + * Please see the specification for the units of each value. + */ +typedef struct smbios_vprobe { + const char *smbvp_description; /* description information */ + uint8_t smbvp_location; /* probe location */ + uint8_t smbvp_status; /* probe status */ + uint16_t smbvp_maxval; /* maximum voltage */ + uint16_t smbvp_minval; /* minimum voltage */ + uint16_t smbvp_resolution; /* probe resolution */ + uint16_t smbvp_tolerance; /* probe tolerance */ + uint16_t smbvp_accuracy; /* probe accuracy */ + uint32_t smbvp_oem; /* vendor-specific data */ + uint16_t smbvp_nominal; /* nominal value */ +} smbios_vprobe_t; + +#define SMB_VPROBE_S_OTHER 0x01 /* other */ +#define SMB_VPROBE_S_UNKNOWN 0x02 /* unknown */ +#define SMB_VPROBE_S_OK 0x03 /* OK */ +#define SMB_VPROBE_S_NONCRIT 0x04 /* non-critical */ +#define SMB_VPROBE_S_CRIT 0x05 /* critical */ +#define SMB_VPROBE_S_NONRECOV 0x06 /* non-recoverable */ + +#define SMB_VPROBE_L_OTHER 0x01 /* other */ +#define SMB_VPROBE_L_UNKNOWN 0x02 /* unknown */ +#define SMB_VPROBE_L_PROC 0x03 /* processor */ +#define SMB_VPROBE_L_DISK 0x04 /* disk */ +#define SMB_VPROBE_L_PBAY 0x05 /* peripheral bay */ +#define SMB_VPROBE_L_MGMT 0x06 /* system management module */ +#define SMB_VPROBE_L_MOBO 0x07 /* motherboard */ +#define SMB_VPROBE_L_MEMMOD 0x08 /* memory module */ +#define SMB_VPROBE_L_PROCMOD 0x09 /* processor module */ +#define SMB_VPROBE_L_POWER 0x0a /* power unit */ +#define SMB_VPROBE_L_AIC 0x0b /* add-in card */ + +/* + * SMBIOS Cooling Device. See DSP0134 Section 7.28 for more information. + * Please see the specification for the units of each value. + */ +typedef struct smbios_cooldev { + id_t smbcd_tprobe; /* temperature probe handle */ + uint8_t smbcd_type; /* cooling device type */ + uint8_t smbcd_status; /* status */ + uint8_t smbcd_group; /* group ID */ + uint32_t smbcd_oem; /* vendor-specific data */ + uint16_t smbcd_nominal; /* nominal speed */ + const char *smbcd_descr; /* device description */ +} smbios_cooldev_t; + +#define SMB_COOLDEV_S_OTHER 0x01 /* other */ +#define SMB_COOLDEV_S_UNKNOWN 0x02 /* unknown */ +#define SMB_COOLDEV_S_OK 0x03 /* OK */ +#define SMB_COOLDEV_S_NONCRIT 0x04 /* non-critical */ +#define SMB_COOLDEV_S_CRIT 0x05 /* critical */ +#define SMB_COOLDEV_S_NONRECOV 0x06 /* non-recoverable */ + +#define SMB_COOLDEV_T_OTHER 0x01 /* other */ +#define SMB_COOLDEV_T_UNKNOWN 0x02 /* unknown */ +#define SMB_COOLDEV_T_FAN 0x03 /* fan */ +#define SMB_COOLDEV_T_BLOWER 0x04 /* centrifugal blower */ +#define SMB_COOLDEV_T_CHIPFAN 0x05 /* chip fan */ +#define SMB_COOLDEV_T_CABFAN 0x06 /* cabinet fan */ +#define SMB_COOLDEV_T_PSFAN 0x07 /* power supply fan */ +#define SMB_COOLDEV_T_HEATPIPE 0x08 /* head pipe */ +#define SMB_COOLDEV_T_IREFRIG 0x09 /* integrated refrigeration */ +#define SMB_COOLDEV_T_ACTCOOL 0x10 /* active cooling */ +#define SMB_COOLDEV_T_PASSCOOL 0x11 /* passive cooling */ + +/* + * SMBIOS Temperature Probe. See DSP0134 Section 7.29 for more information. + * Please see the specification for the units of each value. + */ +typedef struct smbios_tprobe { + const char *smbtp_description; /* description information */ + uint8_t smbtp_location; /* probe location */ + uint8_t smbtp_status; /* probe status */ + uint16_t smbtp_maxval; /* maximum temperature */ + uint16_t smbtp_minval; /* minimum temperature */ + uint16_t smbtp_resolution; /* probe resolution */ + uint16_t smbtp_tolerance; /* probe tolerance */ + uint16_t smbtp_accuracy; /* probe accuracy */ + uint32_t smbtp_oem; /* vendor-specific data */ + uint16_t smbtp_nominal; /* nominal value */ +} smbios_tprobe_t; + +#define SMB_TPROBE_S_OTHER 0x01 /* other */ +#define SMB_TPROBE_S_UNKNOWN 0x02 /* unknown */ +#define SMB_TPROBE_S_OK 0x03 /* OK */ +#define SMB_TPROBE_S_NONCRIT 0x04 /* non-critical */ +#define SMB_TPROBE_S_CRIT 0x05 /* critical */ +#define SMB_TPROBE_S_NONRECOV 0x06 /* non-recoverable */ + +#define SMB_TPROBE_L_OTHER 0x01 /* other */ +#define SMB_TPROBE_L_UNKNOWN 0x02 /* unknown */ +#define SMB_TPROBE_L_PROC 0x03 /* processor */ +#define SMB_TPROBE_L_DISK 0x04 /* disk */ +#define SMB_TPROBE_L_PBAY 0x05 /* peripheral bay */ +#define SMB_TPROBE_L_MGMT 0x06 /* system management module */ +#define SMB_TPROBE_L_MOBO 0x07 /* motherboard */ +#define SMB_TPROBE_L_MEMMOD 0x08 /* memory module */ +#define SMB_TPROBE_L_PROCMOD 0x09 /* processor module */ +#define SMB_TPROBE_L_POWER 0x0a /* power unit */ +#define SMB_TPROBE_L_AIC 0x0b /* add-in card */ +#define SMB_TPROBE_L_FPBOARD 0x0c /* front panel board */ +#define SMB_TPROBE_L_BPBOARD 0x0d /* rear panel board */ +#define SMB_TPROBE_L_PSBOARD 0x0e /* power system board */ +#define SMB_TPROBE_L_DBPANE 0x0f /* drive back plane */ + +/* + * SMBIOS Current Probe. See DSP0134 Section 7.30 for more information. + * Please see the specification for the units of each value. + */ +typedef struct smbios_iprobe { + const char *smbip_description; /* description information */ + uint8_t smbip_location; /* probe location */ + uint8_t smbip_status; /* probe status */ + uint16_t smbip_maxval; /* maximum current */ + uint16_t smbip_minval; /* minimum current */ + uint16_t smbip_resolution; /* probe resolution */ + uint16_t smbip_tolerance; /* probe tolerance */ + uint16_t smbip_accuracy; /* probe accuracy */ + uint32_t smbip_oem; /* vendor-specific data */ + uint16_t smbip_nominal; /* nominal value */ +} smbios_iprobe_t; + +#define SMB_IPROBE_S_OTHER 0x01 /* other */ +#define SMB_IPROBE_S_UNKNOWN 0x02 /* unknown */ +#define SMB_IPROBE_S_OK 0x03 /* OK */ +#define SMB_IPROBE_S_NONCRIT 0x04 /* non-critical */ +#define SMB_IPROBE_S_CRIT 0x05 /* critical */ +#define SMB_IPROBE_S_NONRECOV 0x06 /* non-recoverable */ + +#define SMB_IPROBE_L_OTHER 0x01 /* other */ +#define SMB_IPROBE_L_UNKNOWN 0x02 /* unknown */ +#define SMB_IPROBE_L_PROC 0x03 /* processor */ +#define SMB_IPROBE_L_DISK 0x04 /* disk */ +#define SMB_IPROBE_L_PBAY 0x05 /* peripheral bay */ +#define SMB_IPROBE_L_MGMT 0x06 /* system management module */ +#define SMB_IPROBE_L_MOBO 0x07 /* motherboard */ +#define SMB_IPROBE_L_MEMMOD 0x08 /* memory module */ +#define SMB_IPROBE_L_PROCMOD 0x09 /* processor module */ +#define SMB_IPROBE_L_POWER 0x0a /* power unit */ +#define SMB_IPROBE_L_AIC 0x0b /* add-in card */ + +/* + * SMBIOS System Boot Information. See DSP0134 Section 7.33 for more + * information. The contents of the data varies by type and is undocumented + * from the perspective of DSP0134 -- it seems to be left as vendor-specific. + * The (D) annotation next to SMB_BOOT_* below indicates possible data payload. + */ +typedef struct smbios_boot { + uint8_t smbt_status; /* boot status code (see below) */ + const void *smbt_data; /* data buffer specific to status */ + size_t smbt_size; /* size of smbt_data buffer in bytes */ +} smbios_boot_t; + +#define SMB_BOOT_NORMAL 0 /* no errors detected */ +#define SMB_BOOT_NOMEDIA 1 /* no bootable media */ +#define SMB_BOOT_OSFAIL 2 /* normal o/s failed to load */ +#define SMB_BOOT_FWHWFAIL 3 /* firmware-detected hardware failure */ +#define SMB_BOOT_OSHWFAIL 4 /* o/s-detected hardware failure */ +#define SMB_BOOT_USERREQ 5 /* user-requested boot (keystroke) */ +#define SMB_BOOT_SECURITY 6 /* system security violation */ +#define SMB_BOOT_PREVREQ 7 /* previously requested image (D) */ +#define SMB_BOOT_WATCHDOG 8 /* watchdog initiated reboot */ +#define SMB_BOOT_RESV_LO 9 /* low end of reserved range */ +#define SMB_BOOT_RESV_HI 127 /* high end of reserved range */ +#define SMB_BOOT_OEM_LO 128 /* low end of OEM-specific range */ +#define SMB_BOOT_OEM_HI 191 /* high end of OEM-specific range */ +#define SMB_BOOT_PROD_LO 192 /* low end of product-specific range */ +#define SMB_BOOT_PROD_HI 255 /* high end of product-specific range */ + +/* + * SMBIOS IPMI Device Information. See DSP0134 Section 7.39 and also + * Appendix C1 of the IPMI specification for more information on this record. + */ +typedef struct smbios_ipmi { + uint_t smbip_type; /* BMC interface type */ + smbios_version_t smbip_vers; /* BMC's IPMI specification version */ + uint32_t smbip_i2c; /* BMC I2C bus slave address */ + uint32_t smbip_bus; /* bus ID of NV storage device, or -1 */ + uint64_t smbip_addr; /* BMC base address */ + uint32_t smbip_flags; /* flags (see below) */ + uint16_t smbip_intr; /* interrupt number (or zero if none) */ + uint16_t smbip_regspacing; /* i/o space register spacing (bytes) */ +} smbios_ipmi_t; + +#define SMB_IPMI_T_UNKNOWN 0x00 /* unknown */ +#define SMB_IPMI_T_KCS 0x01 /* KCS: Keyboard Controller Style */ +#define SMB_IPMI_T_SMIC 0x02 /* SMIC: Server Mgmt Interface Chip */ +#define SMB_IPMI_T_BT 0x03 /* BT: Block Transfer */ +#define SMB_IPMI_T_SSIF 0x04 /* SSIF: SMBus System Interface */ + +#define SMB_IPMI_F_IOADDR 0x01 /* base address is in i/o space */ +#define SMB_IPMI_F_INTRSPEC 0x02 /* intr information is specified */ +#define SMB_IPMI_F_INTRHIGH 0x04 /* intr active high (else low) */ +#define SMB_IPMI_F_INTREDGE 0x08 /* intr is edge triggered (else lvl) */ + +/* + * SMBIOS System Power Supply Information. See DSP0134 7.40 for more + * information. + */ +typedef struct smbios_powersup { + uint32_t smbps_group; /* group ID */ + uint64_t smbps_maxout; /* max output in milliwatts */ + uint32_t smbps_flags; /* see below */ + uint8_t smbps_ivrs; /* input voltage range switching type */ + uint8_t smbps_status; /* PSU status */ + uint8_t smbps_pstype; /* PSU type */ + id_t smbps_vprobe; /* voltage probe handle */ + id_t smbps_cooldev; /* cooling device handle */ + id_t smbps_iprobe; /* current probe handle */ +} smbios_powersup_t; + +/* smbpfs_flags */ +#define SMB_POWERSUP_F_HOT 0x01 /* PSU is hot-replaceable */ +#define SMB_POWERSUP_F_PRESENT 0x02 /* PSU is present */ +#define SMB_POWERSUP_F_UNPLUG 0x04 /* PSU is unplugged from outlet */ + +/* Values for smbps_ivrs */ +#define SMB_POWERSUP_I_OTHER 0x01 /* other */ +#define SMB_POWERSUP_I_UNKNOWN 0x02 /* unknown */ +#define SMB_POWERSUP_I_MANUAL 0x03 /* manual */ +#define SMB_POWERSUP_I_AUTO 0x04 /* auto-switch */ +#define SMB_POWERSUP_I_WIDE 0x05 /* wide range */ +#define SMB_POWERSUP_I_NA 0x06 /* not applicable */ + +#define SMB_POWERSUP_S_OTHER 0x01 /* other */ +#define SMB_POWERSUP_S_UNKNOWN 0x02 /* unknown */ +#define SMB_POWERSUP_S_OK 0x03 /* OK */ +#define SMB_POWERSUP_S_NONCRIT 0x04 /* non-critical */ +#define SMB_POWERSUP_S_CRIT 0x05 /* critical; PSU failed */ + +#define SMB_POWERSUP_T_OTHER 0x01 /* other */ +#define SMB_POWERSUP_T_UNKNOWN 0x02 /* unknown */ +#define SMB_POWERSUP_T_LINEAR 0x03 /* linear */ +#define SMB_POWERSUP_T_SWITCH 0x04 /* switching */ +#define SMB_POWERSUP_T_BAT 0x05 /* battery */ +#define SMB_POWERSUP_T_UPS 0x06 /* UPS */ +#define SMB_POWERSUP_T_CONV 0x07 /* converter */ +#define SMB_POWERSUP_T_REGL 0x08 /* regulator */ + +/* + * SMBIOS Additional Information. The top level structure defines a number of + * additional information entries, each of which is variable length and intended + * to augment some existing field in the system. Therefore we have a single + * function to get the number of additional entries present and then a different + * one that retrieves each entity function. + */ +typedef struct smbios_addinfo_ent { + id_t smbai_ref; /* referenced handle */ + uint32_t smbai_ref_off; /* offset into referenced handle */ + const char *smbai_str; /* optional string description */ + uint32_t smbai_dlen; /* optional data length */ + void *smbai_data; /* optional data */ +} smbios_addinfo_ent_t; + +/* + * SMBIOS Onboard Devices Extended Information. See DSP0134 Section 7.42 + * for more information. + */ +typedef struct smbios_obdev_ext { + const char *smboe_name; /* reference designation */ + uint8_t smboe_dtype; /* device type */ + uint8_t smboe_dti; /* device type instance */ + uint16_t smboe_sg; /* segment group number */ + uint8_t smboe_bus; /* bus number */ + uint8_t smboe_df; /* device/function number */ +} smbios_obdev_ext_t; + +#define SMB_OBET_OTHER 0x01 /* Other */ +#define SMB_OBET_UNKNOWN 0x02 /* Unknown */ +#define SMB_OBET_VIDEO 0x03 /* video */ +#define SMB_OBET_SCSI 0x04 /* SCSI */ +#define SMB_OBET_ETHERNET 0x05 /* Ethernet */ +#define SMB_OBET_TOKEN 0x06 /* Token Ring */ +#define SMB_OBET_SOUND 0x07 /* Sound */ +#define SMB_OBET_PATA 0x08 /* PATA */ +#define SMB_OBET_SATA 0x09 /* SATA */ +#define SMB_OBET_SAS 0x0A /* SAS */ +#define SMB_OBET_WLAN 0x0B /* Wireless LAN */ +#define SMB_OBET_BT 0x0C /* Bluetooth */ +#define SMB_OBET_WWAN 0x0D /* WWAN */ +#define SMB_OBET_EMMC 0x0E /* eMMC */ +#define SMB_OBET_NVME 0x0F /* NVMe */ +#define SMB_OBET_UFS 0x10 /* UFS */ + +/* + * SMBIOS Processor Additional Information (Type 44). See section 7.45 for more + * information. + */ +typedef struct smbios_processor_info { + id_t smbpi_processor; /* processor handle */ + uint32_t smbpi_ptype; /* processor type */ +} smbios_processor_info_t; + +/* BEGIN CSTYLED */ +#define SMB_PROCINFO_T_RESERVED 0x00 /* reserved */ +#define SMB_PROCINFO_T_IA32 0x01 /* IA32 (x86) */ +#define SMB_PROCINFO_T_AMD64 0x02 /* X64 (x86-64, Intel64, AMD64, EMT64) */ +#define SMB_PROCINFO_T_IA 0x03 /* Intel Itanium architecture */ +#define SMB_PROCINFO_T_AARCH32 0x04 /* 32-bit ARM (aarch32) */ +#define SMB_PROCINFO_T_AARCH64 0x05 /* 64-bit ARM (aarch64) */ +#define SMB_PROCINFO_T_RV32 0x06 /* 32-bit RISC-V (RV32) */ +#define SMB_PROCINFO_T_RV64 0x07 /* 64-bit RISC-V (RV64) */ +#define SMB_PROCINFO_T_RV128 0x08 /* 128-bit RISC-V (RV128) */ +#define SMB_PROCINFO_T_LA32 0x09 /* 32-bit LoongArch */ +#define SMB_PROCINFO_T_LA64 0x0A /* 64-bit LoongArch */ +/* END CSTYLED */ + +typedef struct smbios_processor_info_riscv { + uint8_t smbpirv_hartid[16]; /* HART ID */ + uint8_t smbpirv_vendid[16]; /* Vendor ID */ + uint8_t smbpirv_archid[16]; /* Architecture ID */ + uint8_t smbpirv_machid[16]; /* Machine ID */ + uint8_t smbpirv_metdi[16]; /* Machine exception delegation */ + uint8_t smbpirv_mitdi[16]; /* Machine interrupt delegation */ + uint64_t smbpirv_isa; /* Supported ISA */ + uint32_t smbpirv_privlvl; /* Privilege Level */ + uint8_t smbpirv_boothart; /* Indicates if boot processor */ + uint8_t smbpirv_xlen; /* Default register width */ + uint8_t smbpirv_mxlen; /* Machine register width */ + uint8_t smbpirv_sxlen; /* Supervisor register width */ + uint8_t smbpirv_uxlen; /* User register width */ +} smbios_processor_info_riscv_t; + +/* + * RISC-V Supported Privilege Levels + */ +#define SMB_RV_PRIV_M (1 << 0) /* Machine Mode */ +#define SMB_RV_PRIV_S (1 << 2) /* Supervisor Mode */ +#define SMB_RV_PRIV_U (1 << 3) /* User Mode */ +#define SMB_RV_PRIV_DBG (1 << 7) /* Debug Mode */ + +/* + * Values used to define the various XLEN Values. + */ +#define SMB_RV_WIDTH_UNSUP 0x00 /* Unsupported */ +#define SMB_RV_WIDTH_32B 0x01 /* 32-bit */ +#define SMB_RV_WIDTH_64B 0x02 /* 64-bit */ +#define SMB_RV_WIDTH_128B 0x03 /* 128-bit */ + +/* + * RISC-V ISA extensions + */ +/* BEGIN CSTYLED */ +#define SMB_RV_ISA_A (1 << 0) /* Atomic */ +#define SMB_RV_ISA_B (1 << 1) /* Reserved */ +#define SMB_RV_ISA_C (1 << 2) /* Compressed */ +#define SMB_RV_ISA_D (1 << 3) /* Double-precision floating-point */ +#define SMB_RV_ISA_E (1 << 4) /* RV32E base */ +#define SMB_RV_ISA_F (1 << 5) /* Single-precision floating-point */ +#define SMB_RV_ISA_G (1 << 6) /* Additional standard extensions present */ +#define SMB_RV_ISA_H (1 << 7) /* Hypervisor */ +#define SMB_RV_ISA_I (1 << 8) /* Integer base ISA */ +#define SMB_RV_ISA_J (1 << 9) /* Reserved */ +#define SMB_RV_ISA_K (1 << 10) /* Reserved */ +#define SMB_RV_ISA_L (1 << 11) /* Reserved */ +#define SMB_RV_ISA_M (1 << 12) /* Integer Multiply/Divide */ +#define SMB_RV_ISA_N (1 << 13) /* User-level interrupts */ +#define SMB_RV_ISA_O (1 << 14) /* Reserved */ +#define SMB_RV_ISA_P (1 << 15) /* Reserved */ +#define SMB_RV_ISA_Q (1 << 16) /* Quad-precision floating-point */ +#define SMB_RV_ISA_R (1 << 17) /* Reserved */ +#define SMB_RV_ISA_S (1 << 18) /* Supervisor mode */ +#define SMB_RV_ISA_T (1 << 19) /* Reserved */ +#define SMB_RV_ISA_U (1 << 20) /* User mode */ +#define SMB_RV_ISA_V (1 << 21) /* Reserved */ +#define SMB_RV_ISA_W (1 << 22) /* Reserved */ +#define SMB_RV_ISA_X (1 << 23) /* Non-standard extensions */ +#define SMB_RV_ISA_Y (1 << 24) /* Reserved */ +#define SMB_RV_ISA_Z (1 << 25) /* Reserved */ +/* END CSTYLED */ + +/* + * SMBIOS Firmware Inventory Information (Type 45). + */ +typedef struct smbios_fwinfo { + const char *smbfw_name; /* Firmware component name */ + const char *smbfw_id; /* Firmware ID */ + const char *smbfw_reldate; /* Release date */ + const char *smbfw_lsv; /* Lowest supported version */ + uint64_t smbfw_imgsz; /* Image size */ + uint16_t smbfw_chars; /* Characteristics */ + uint16_t smbfw_state; /* State */ + uint16_t smbfw_ncomps; /* Number of associated components */ + uint8_t smbfw_vers_fmt; /* Firmware version format */ + uint8_t smbfw_id_fmt; /* Firmware ID format */ +} smbios_fwinfo_t; + +typedef struct smbios_fwinfo_comp { + id_t smbfwe_id; /* Contained element ID */ +} smbios_fwinfo_comp_t; + +/* + * Firmware version format constants. + */ +#define SMB_FWV_FF 0x00 /* free-form */ +#define SMB_FWV_MM 0x01 /* major.minor */ +#define SMB_FWV_HEX32 0x02 /* 32-bit hex */ +#define SMB_FWV_HEX64 0x03 /* 64-bit hex */ + +/* + * Firmware ID format constants. + */ +#define SMB_FWI_FF 0x00 /* free-form */ +#define SMB_FWI_UEFI 0x01 /* UEFI GUID */ + +/* + * Firmware characteristic bitfields. + */ +#define SMB_FWC_UPDATE 0x01 /* updatable */ +#define SMB_FWC_WP 0x02 /* write-protect */ + +/* + * Firmware state constants. + */ +#define SMB_FWS_OTHER 0x01 /* other */ +#define SMB_FWS_UNKNOWN 0x02 /* unknown */ +#define SMB_FWS_DISABLED 0x03 /* disabled */ +#define SMB_FWS_ENABLED 0x04 /* enabled */ +#define SMB_FWS_ABSENT 0x05 /* absent */ +#define SMB_FWS_STB_OFFLINE 0x06 /* standby offline */ +#define SMB_FWS_STB_SPARE 0x07 /* standby spare */ +#define SMB_FWS_UA_OFFLINE 0x08 /* unavailable offline */ + +/* + * SMBIOS String Property (Type 46). See section 7.47 for more information. + */ +typedef struct smbios_strprop { + uint32_t smbsp_prop_id; /* property ID */ + const char *smbsp_prop_val; /* property Value */ + id_t smbsp_parent; /* parent handle */ +} smbios_strprop_t; + +/* + * String Property IDs + */ +#define SMB_STRP_RESERVED 0x00 /* reserved */ +#define SMB_STRP_UEFI_DEVPATH 0x01 /* UEFI device path */ + +/* + * SMBIOS OEM-specific (Type 132) Processor Extended Information. + */ +typedef struct smbios_processor_ext { + uint16_t smbpe_processor; /* extending processor handle */ + uint8_t smbpe_fru; /* FRU indicator */ + uint8_t smbpe_n; /* number of APIC IDs */ + uint16_t *smbpe_apicid; /* strand Inital APIC IDs */ +} smbios_processor_ext_t; + +/* + * SMBIOS OEM-specific (Type 136) Port Extended Information. + */ +typedef struct smbios_port_ext { + uint16_t smbporte_chassis; /* chassis handle */ + uint16_t smbporte_port; /* port connector handle */ + uint8_t smbporte_dtype; /* device type */ + uint16_t smbporte_devhdl; /* device handle */ + uint8_t smbporte_phy; /* PHY number */ +} smbios_port_ext_t; + +/* + * SMBIOS OEM-specific (Type 138) PCI-Express RC/RP Information. + */ +typedef struct smbios_pciexrc { + uint16_t smbpcie_bb; /* base board handle */ + uint16_t smbpcie_bdf; /* Bus/Dev/Funct (PCI) */ +} smbios_pciexrc_t; + +/* + * SMBIOS OEM-specific (Type 144) Memory Array Extended Information. + */ +typedef struct smbios_memarray_ext { + uint16_t smbmae_ma; /* memory array handle */ + uint16_t smbmae_comp; /* component parent handle */ + uint16_t smbmae_bdf; /* Bus/Dev/Funct (PCI) */ +} smbios_memarray_ext_t; + +/* + * SMBIOS OEM-specific (Type 145) Memory Device Extended Information. + */ +typedef struct smbios_memdevice_ext { + uint16_t smbmdeve_md; /* memory device handle */ + uint8_t smbmdeve_drch; /* DRAM channel */ + uint8_t smbmdeve_ncs; /* number of chip selects */ +} smbios_memdevice_ext_t; + +/* + * SMBIOS Interfaces. An SMBIOS image can be opened by either providing a file + * pathname, device pathname, file descriptor, or raw memory buffer. Once an + * image is opened the functions below can be used to iterate over the various + * structures and convert the underlying data representation into the simpler + * data structures described earlier in this header file. The SMB_VERSION + * constant specified when opening an image indicates the version of the ABI + * the caller expects and the DMTF SMBIOS version the client can understand. + * The library will then map older or newer data structures to that as needed. + */ + +#define SMB_VERSION_23 0x0203 /* SMBIOS encoding for DMTF spec 2.3 */ +#define SMB_VERSION_24 0x0204 /* SMBIOS encoding for DMTF spec 2.4 */ +#define SMB_VERSION_25 0x0205 /* SMBIOS encoding for DMTF spec 2.5 */ +#define SMB_VERSION_26 0x0206 /* SMBIOS encoding for DMTF spec 2.6 */ +#define SMB_VERSION_27 0x0207 /* SMBIOS encoding for DMTF spec 2.7 */ +#define SMB_VERSION_28 0x0208 /* SMBIOS encoding for DMTF spec 2.8 */ +#define SMB_VERSION_30 0x0300 /* SMBIOS encoding for DMTF spec 3.0 */ +#define SMB_VERSION_31 0x0301 /* SMBIOS encoding for DMTF spec 3.1 */ +#define SMB_VERSION_32 0x0302 /* SMBIOS encoding for DMTF spec 3.2 */ +#define SMB_VERSION_33 0x0303 /* SMBIOS encoding for DMTF spec 3.3 */ +#define SMB_VERSION_34 0x0304 /* SMBIOS encoding for DMTF spec 3.4 */ +#define SMB_VERSION_35 0x0305 /* SMBIOS encoding for DMTF spec 3.5 */ +#define SMB_VERSION_36 0x0306 /* SMBIOS encoding for DMTF spec 3.6 */ +#define SMB_VERSION_37 0x0307 /* SMBIOS encoding for DMTF spec 3.7 */ +#define SMB_VERSION_38 0x0308 /* SMBIOS encoding for DMTF spec 3.8 */ +#define SMB_VERSION_39 0x0309 /* SMBIOS encoding for DMTF spec 3.9 */ +#define SMB_VERSION SMB_VERSION_39 /* SMBIOS latest version definitions */ + +#define SMB_O_NOCKSUM 0x1 /* do not verify header checksums */ +#define SMB_O_NOVERS 0x2 /* do not verify header versions */ +#define SMB_O_ZIDS 0x4 /* strip out identification numbers */ +#define SMB_O_MASK 0x7 /* mask of valid smbios_*open flags */ + +#define SMB_ID_NOTSUP 0xFFFE /* structure is not supported by BIOS */ +#define SMB_ID_NONE 0xFFFF /* structure is a null reference */ + +#define SMB_ERR (-1) /* id_t value indicating error */ + +typedef struct smbios_hdl smbios_hdl_t; + +typedef struct smbios_struct { + id_t smbstr_id; /* structure ID handle */ + uint_t smbstr_type; /* structure type */ + const void *smbstr_data; /* structure data */ + size_t smbstr_size; /* structure size */ +} smbios_struct_t; + +typedef int smbios_struct_f(smbios_hdl_t *, + const smbios_struct_t *, void *); + +extern smbios_hdl_t *smbios_open(const char *, int, int, int *); +extern smbios_hdl_t *smbios_fdopen(int, int, int, int *); +extern smbios_hdl_t *smbios_bufopen(const smbios_entry_t *, + const void *, size_t, int, int, int *); + +extern const void *smbios_buf(smbios_hdl_t *); +extern size_t smbios_buflen(smbios_hdl_t *); + +extern void smbios_checksum(smbios_hdl_t *, smbios_entry_t *); +extern int smbios_write(smbios_hdl_t *, int); +extern void smbios_close(smbios_hdl_t *); + +extern boolean_t smbios_truncated(smbios_hdl_t *); +extern int smbios_errno(smbios_hdl_t *); +extern const char *smbios_errmsg(int); + +extern int smbios_lookup_id(smbios_hdl_t *, id_t, smbios_struct_t *); +extern int smbios_lookup_type(smbios_hdl_t *, uint_t, smbios_struct_t *); +extern int smbios_iter(smbios_hdl_t *, smbios_struct_f *, void *); + +extern smbios_entry_point_t smbios_info_smbios(smbios_hdl_t *, + smbios_entry_t *); +extern void smbios_info_smbios_version(smbios_hdl_t *, smbios_version_t *); +extern int smbios_info_common(smbios_hdl_t *, id_t, smbios_info_t *); +extern int smbios_info_contains(smbios_hdl_t *, id_t, uint_t, id_t *); +extern id_t smbios_info_bios(smbios_hdl_t *, smbios_bios_t *); +extern id_t smbios_info_system(smbios_hdl_t *, smbios_system_t *); +extern int smbios_info_bboard(smbios_hdl_t *, id_t, smbios_bboard_t *); +extern int smbios_info_chassis(smbios_hdl_t *, id_t, smbios_chassis_t *); +extern int smbios_info_chassis_elts(smbios_hdl_t *, id_t, uint_t *, + smbios_chassis_entry_t **); +extern void smbios_info_chassis_elts_free(smbios_hdl_t *, uint_t, + smbios_chassis_entry_t *); +extern int smbios_info_processor(smbios_hdl_t *, id_t, smbios_processor_t *); +extern int smbios_info_extprocessor(smbios_hdl_t *, id_t, + smbios_processor_ext_t *); +extern int smbios_info_cache(smbios_hdl_t *, id_t, smbios_cache_t *); +extern int smbios_info_pointdev(smbios_hdl_t *, id_t, smbios_pointdev_t *); +extern int smbios_info_battery(smbios_hdl_t *, id_t, smbios_battery_t *); +extern int smbios_info_port(smbios_hdl_t *, id_t, smbios_port_t *); +extern int smbios_info_extport(smbios_hdl_t *, id_t, smbios_port_ext_t *); +extern int smbios_info_slot(smbios_hdl_t *, id_t, smbios_slot_t *); +extern int smbios_info_slot_peers(smbios_hdl_t *, id_t, uint_t *, + smbios_slot_peer_t **); +extern void smbios_info_slot_peers_free(smbios_hdl_t *, uint_t, + smbios_slot_peer_t *); +extern int smbios_info_obdevs(smbios_hdl_t *, id_t, int, smbios_obdev_t *); +extern int smbios_info_obdevs_ext(smbios_hdl_t *, id_t, smbios_obdev_ext_t *); +extern int smbios_info_strtab(smbios_hdl_t *, id_t, int, const char *[]); +extern id_t smbios_info_lang(smbios_hdl_t *, smbios_lang_t *); +extern id_t smbios_info_eventlog(smbios_hdl_t *, smbios_evlog_t *); +extern int smbios_info_memarray(smbios_hdl_t *, id_t, smbios_memarray_t *); +extern int smbios_info_extmemarray(smbios_hdl_t *, id_t, + smbios_memarray_ext_t *); +extern int smbios_info_memarrmap(smbios_hdl_t *, id_t, smbios_memarrmap_t *); +extern int smbios_info_memdevice(smbios_hdl_t *, id_t, smbios_memdevice_t *); +extern int smbios_info_extmemdevice(smbios_hdl_t *, id_t, + smbios_memdevice_ext_t *); +extern int smbios_info_extmemdevice_cs(smbios_hdl_t *, id_t, uint_t *, + uint8_t **); +extern void smbios_info_extmemdevice_cs_free(smbios_hdl_t *, uint_t, uint8_t *); +extern int smbios_info_memdevmap(smbios_hdl_t *, id_t, smbios_memdevmap_t *); +extern id_t smbios_info_hwsec(smbios_hdl_t *, smbios_hwsec_t *); +extern int smbios_info_vprobe(smbios_hdl_t *, id_t, smbios_vprobe_t *); +extern int smbios_info_cooldev(smbios_hdl_t *, id_t, smbios_cooldev_t *); +extern int smbios_info_tprobe(smbios_hdl_t *, id_t, smbios_tprobe_t *); +extern int smbios_info_iprobe(smbios_hdl_t *, id_t, smbios_iprobe_t *); +extern id_t smbios_info_boot(smbios_hdl_t *, smbios_boot_t *); +extern id_t smbios_info_ipmi(smbios_hdl_t *, smbios_ipmi_t *); +extern int smbios_info_powersup(smbios_hdl_t *, id_t, smbios_powersup_t *); +extern int smbios_info_addinfo_nents(smbios_hdl_t *, id_t, uint_t *); +extern int smbios_info_addinfo_ent(smbios_hdl_t *, id_t, uint_t, + smbios_addinfo_ent_t **); +extern void smbios_info_addinfo_ent_free(smbios_hdl_t *, + smbios_addinfo_ent_t *); +extern int smbios_info_pciexrc(smbios_hdl_t *, id_t, smbios_pciexrc_t *); +extern int smbios_info_processor_info(smbios_hdl_t *, id_t, + smbios_processor_info_t *); +extern int smbios_info_processor_riscv(smbios_hdl_t *, id_t, + smbios_processor_info_riscv_t *); +extern int smbios_info_strprop(smbios_hdl_t *, id_t, smbios_strprop_t *); +extern int smbios_info_fwinfo(smbios_hdl_t *, id_t, smbios_fwinfo_t *); +extern int smbios_info_fwinfo_comps(smbios_hdl_t *, id_t, uint_t *, + smbios_fwinfo_comp_t **); +extern void smbios_info_fwinfo_comps_free(smbios_hdl_t *, uint_t, + smbios_fwinfo_comp_t *); + +extern const char *smbios_psn(smbios_hdl_t *); +extern const char *smbios_csn(smbios_hdl_t *); + +#ifndef _KERNEL +/* + * The smbios_*_desc() and smbios_*_name() interfaces can be used for utilities + * such as smbios(8) that wish to decode SMBIOS fields for humans. The _desc + * functions return the comment string next to the #defines listed above, and + * the _name functions return the appropriate #define identifier itself. + */ +extern const char *smbios_battery_chem_desc(uint_t); + +extern const char *smbios_bboard_flag_desc(uint_t); +extern const char *smbios_bboard_flag_name(uint_t); +extern const char *smbios_bboard_type_desc(uint_t); + +extern const char *smbios_bios_flag_desc(uint64_t); +extern const char *smbios_bios_flag_name(uint64_t); + +extern const char *smbios_bios_xb1_desc(uint_t); +extern const char *smbios_bios_xb1_name(uint_t); +extern const char *smbios_bios_xb2_desc(uint_t); +extern const char *smbios_bios_xb2_name(uint_t); + +extern const char *smbios_boot_desc(uint_t); + +extern const char *smbios_cache_assoc_desc(uint_t); +extern const char *smbios_cache_ctype_desc(uint_t); +extern const char *smbios_cache_ctype_name(uint_t); +extern const char *smbios_cache_ecc_desc(uint_t); +extern const char *smbios_cache_flag_desc(uint_t); +extern const char *smbios_cache_flag_name(uint_t); +extern const char *smbios_cache_loc_desc(uint_t); +extern const char *smbios_cache_logical_desc(uint_t); +extern const char *smbios_cache_mode_desc(uint_t); + +extern const char *smbios_chassis_state_desc(uint_t); +extern const char *smbios_chassis_type_desc(uint_t); +extern const char *smbios_chassis_rack_type_desc(uint_t); + +extern const char *smbios_evlog_flag_desc(uint_t); +extern const char *smbios_evlog_flag_name(uint_t); +extern const char *smbios_evlog_format_desc(uint_t); +extern const char *smbios_evlog_method_desc(uint_t); + +extern const char *smbios_fwinfo_ch_name(uint_t); +extern const char *smbios_fwinfo_ch_desc(uint_t); +extern const char *smbios_fwinfo_id_desc(uint_t); +extern const char *smbios_fwinfo_state_desc(uint_t); +extern const char *smbios_fwinfo_vers_desc(uint_t); + +extern const char *smbios_vprobe_loc_desc(uint_t); +extern const char *smbios_vprobe_status_desc(uint_t); + +extern const char *smbios_cooldev_status_desc(uint_t); +extern const char *smbios_cooldev_type_desc(uint_t); + +extern const char *smbios_tprobe_loc_desc(uint_t); +extern const char *smbios_tprobe_status_desc(uint_t); + +extern const char *smbios_iprobe_loc_desc(uint_t); +extern const char *smbios_iprobe_status_desc(uint_t); + +extern const char *smbios_ipmi_flag_name(uint_t); +extern const char *smbios_ipmi_flag_desc(uint_t); +extern const char *smbios_ipmi_type_desc(uint_t); + +extern const char *smbios_powersup_flag_name(uint_t); +extern const char *smbios_powersup_flag_desc(uint_t); +extern const char *smbios_powersup_input_desc(uint_t); +extern const char *smbios_powersup_status_desc(uint_t); +extern const char *smbios_powersup_type_desc(uint_t); + +extern const char *smbios_hwsec_desc(uint_t); + +extern const char *smbios_memarray_loc_desc(uint_t); +extern const char *smbios_memarray_use_desc(uint_t); +extern const char *smbios_memarray_ecc_desc(uint_t); + +extern const char *smbios_memdevice_form_desc(uint_t); +extern const char *smbios_memdevice_type_desc(uint_t); +extern const char *smbios_memdevice_flag_name(uint_t); +extern const char *smbios_memdevice_flag_desc(uint_t); +extern const char *smbios_memdevice_rank_desc(uint_t); +extern const char *smbios_memdevice_memtech_desc(uint_t); +extern const char *smbios_memdevice_op_capab_name(uint_t); +extern const char *smbios_memdevice_op_capab_desc(uint_t); + +extern const char *smbios_onboard_type_desc(uint_t); +extern const char *smbios_onboard_ext_type_desc(uint_t); + +extern const char *smbios_pointdev_iface_desc(uint_t); +extern const char *smbios_pointdev_type_desc(uint_t); + +extern const char *smbios_port_conn_desc(uint_t); +extern const char *smbios_port_type_desc(uint_t); + +extern const char *smbios_processor_family_desc(uint_t); +extern const char *smbios_processor_status_desc(uint_t); +extern const char *smbios_processor_type_desc(uint_t); +extern const char *smbios_processor_upgrade_desc(uint_t); +extern const char *smbios_processor_core_flag_name(uint_t); +extern const char *smbios_processor_core_flag_desc(uint_t); + +extern const char *smbios_processor_info_type_desc(uint_t); +extern const char *smbios_riscv_isa_desc(uint64_t); +extern const char *smbios_riscv_isa_name(uint64_t); +extern const char *smbios_riscv_priv_desc(uint_t); +extern const char *smbios_riscv_priv_name(uint_t); +extern const char *smbios_riscv_width_desc(uint_t); + +extern const char *smbios_slot_type_desc(uint_t); +extern const char *smbios_slot_width_desc(uint_t); +extern const char *smbios_slot_usage_desc(uint_t); +extern const char *smbios_slot_length_desc(uint_t); +extern const char *smbios_slot_ch1_desc(uint_t); +extern const char *smbios_slot_ch1_name(uint_t); +extern const char *smbios_slot_ch2_desc(uint_t); +extern const char *smbios_slot_ch2_name(uint_t); +extern const char *smbios_slot_height_desc(uint_t); + +extern const char *smbios_strprop_id_desc(uint_t); + +extern const char *smbios_type_desc(uint_t); +extern const char *smbios_type_name(uint_t); + +extern const char *smbios_system_wakeup_desc(uint_t); +#endif /* !_KERNEL */ + +#ifdef _KERNEL +/* + * For SMBIOS clients within the kernel itself, ksmbios is used to refer to + * the kernel's current snapshot of the SMBIOS, if one exists, and the + * ksmbios_flags tunable is the set of flags for use with smbios_open(). + */ +extern smbios_hdl_t *ksmbios; +extern int ksmbios_flags; +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SMBIOS_H */ diff --git a/illumos-x86_64/usr/include/sys/smbios_impl.h b/illumos-x86_64/usr/include/sys/smbios_impl.h new file mode 100644 index 00000000..dc315f3f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/smbios_impl.h @@ -0,0 +1,993 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. + * Copyright 2025 Oxide Computer Company + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * This header file defines the implementation structures for the SMBIOS access + * library, libsmbios, and an equivalent kernel module. Clients should use + * the or header files to access DMTF SMBIOS + * information, NOT these underlying implementation structures from the spec. + * In short, do not user this header file or these routines for any purpose. + */ + +#ifndef _SYS_SMBIOS_IMPL_H +#define _SYS_SMBIOS_IMPL_H + +#include +#include + +#ifdef _KERNEL +#include +#else +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions required to interpret the BIOS type information. + */ +#define SMB_BIOSXB_EXTROM 6 + +#define SMB_BIOS_EXTROM_VALUE_MASK(x) ((x) & 0x3fff) +#define SMB_BIOS_EXTROM_SHIFT_MASK(x) (((x) & 0xc000) >> 14) + +#pragma pack(1) + +typedef struct smb_header { + uint8_t smbh_type; /* structure type (SMB_TYPE_* value) */ + uint8_t smbh_len; /* length in bytes of formatted area */ + uint16_t smbh_hdl; /* structure handle */ +} smb_header_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_BIOS. + */ +typedef struct smb_bios { + smb_header_t smbbi_hdr; /* structure header */ + uint8_t smbbi_vendor; /* bios vendor string */ + uint8_t smbbi_version; /* bios version string */ + uint16_t smbbi_segment; /* segment location of bios address */ + uint8_t smbbi_reldate; /* bios release date */ + uint8_t smbbi_romsize; /* bios rom size (64k * (n + 1)) */ + uint64_t smbbi_cflags; /* bios characteristics */ + uint8_t smbbi_xcflags[1]; /* bios characteristics extensions */ +} smb_bios_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_SYSTEM. + */ +typedef struct smb_system { + smb_header_t smbsi_hdr; /* structure header */ + uint8_t smbsi_manufacturer; /* manufacturer */ + uint8_t smbsi_product; /* product name */ + uint8_t smbsi_version; /* version */ + uint8_t smbsi_serial; /* serial number */ + uint8_t smbsi_uuid[16]; /* UUID */ + uint8_t smbsi_wakeup; /* wake-up type */ + uint8_t smbsi_sku; /* SKU number */ + uint8_t smbsi_family; /* family */ +} smb_system_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_BASEBOARD. + */ +typedef struct smb_bboard { + smb_header_t smbbb_hdr; /* structure header */ + uint8_t smbbb_manufacturer; /* manufacturer */ + uint8_t smbbb_product; /* product name */ + uint8_t smbbb_version; /* version */ + uint8_t smbbb_serial; /* serial number */ + uint8_t smbbb_asset; /* asset tag */ + uint8_t smbbb_flags; /* feature flags */ + uint8_t smbbb_location; /* location in chassis */ + uint16_t smbbb_chassis; /* chassis handle */ + uint8_t smbbb_type; /* board type */ + uint8_t smbbb_cn; /* number of contained handles */ + uint16_t smbbb_cv[1]; /* array of contained handles */ +} smb_bboard_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_CHASSIS. + */ +typedef struct smb_chassis { + smb_header_t smbch_hdr; /* structure header */ + uint8_t smbch_manufacturer; /* manufacturer */ + uint8_t smbch_type; /* type */ + uint8_t smbch_version; /* version */ + uint8_t smbch_serial; /* serial number */ + uint8_t smbch_asset; /* asset tag */ + uint8_t smbch_bustate; /* boot-up state */ + uint8_t smbch_psstate; /* power supply state */ + uint8_t smbch_thstate; /* thermal state */ + uint8_t smbch_security; /* security state */ + uint32_t smbch_oemdata; /* OEM-specific data */ + uint8_t smbch_uheight; /* enclosure height */ + uint8_t smbch_cords; /* number of power cords */ + uint8_t smbch_cn; /* number of contained records */ + uint8_t smbch_cm; /* size of contained records */ + uint8_t smbch_cv[]; /* array of contained records */ +} smb_chassis_t; + +#define SMB_CHT_LOCK 0x80 /* lock bit within smbch_type */ + +typedef struct smb_chassis_entry { + uint8_t smbce_type; /* Containing Element and Type */ + uint8_t smbce_min; /* minimum number of elt */ + uint8_t smbce_max; /* minimum number of elt */ +} smb_chassis_entry_t; + +/* + * Bonus information that follows the variable number of elements. + */ +typedef struct smb_chassis_bonus { + uint8_t smbcb_sku; /* chassis SKU, 2.7+ */ + uint8_t smbcb_rtype; /* rack type, 3.9+ */ + uint8_t smbcb_rheight; /* rack height, 3.9+ */ +} smb_chassis_bonus_t; + +#define SMB_CHE_TYPE_IS_SMB(x) (((x) & 0x80) == 0x80) +#define SMB_CHE_TYPE_TYPE(x) (((x) & 0x7f)) + +/* + * SMBIOS implementation structure for SMB_TYPE_PROCESSOR. + */ +typedef struct smb_processor { + smb_header_t smbpr_hdr; /* structure header */ + uint8_t smbpr_socket; /* socket designation */ + uint8_t smbpr_type; /* processor type (see ) */ + uint8_t smbpr_family; /* processor family (see ) */ + uint8_t smbpr_manufacturer; /* manufacturer */ + uint64_t smbpr_cpuid; /* processor cpuid information */ + uint8_t smbpr_version; /* version */ + uint8_t smbpr_voltage; /* voltage */ + uint16_t smbpr_clkspeed; /* external clock speed in MHz */ + uint16_t smbpr_maxspeed; /* maximum speed in MHz */ + uint16_t smbpr_curspeed; /* current speed in MHz */ + uint8_t smbpr_status; /* status (see ) */ + uint8_t smbpr_upgrade; /* upgrade */ + uint16_t smbpr_l1cache; /* L1 cache handle (if any) */ + uint16_t smbpr_l2cache; /* L2 cache handle (if any) */ + uint16_t smbpr_l3cache; /* L3 cache handle (if any) */ + uint8_t smbpr_serial; /* serial number */ + uint8_t smbpr_asset; /* asset tag */ + uint8_t smbpr_part; /* part number */ + uint8_t smbpr_corecount; /* number of cores per socket */ + uint8_t smbpr_coresenabled; /* number of enabled cores per socket */ + uint8_t smbpr_threadcount; /* number of threads per socket */ + uint16_t smbpr_cflags; /* cpu characteristics (see ) */ + uint16_t smbpr_family2; /* processor family2 (see ) */ + uint16_t smbpr_corecount2; /* second number of cores per socket */ + uint16_t smbpr_coresenabled2; /* second number of enabled cores */ + uint16_t smbpr_threadcount2; /* second number of enabled threads */ + uint16_t smbpr_threaden; /* enabled thread count */ + uint8_t smbpr_socktype; /* socket type string */ +} smb_processor_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_CACHE. + */ +typedef struct smb_cache { + smb_header_t smbca_hdr; /* structure header */ + uint8_t smbca_socket; /* socket designation */ + uint16_t smbca_config; /* cache configuration */ + uint16_t smbca_maxsize; /* maximum installed size */ + uint16_t smbca_size; /* installed size */ + uint16_t smbca_stype; /* supported SRAM type */ + uint16_t smbca_ctype; /* current SRAM type */ + uint8_t smbca_speed; /* speed in nanoseconds */ + uint8_t smbca_etype; /* error correction type */ + uint8_t smbca_ltype; /* logical cache type */ + uint8_t smbca_assoc; /* associativity */ + uint32_t smbca_maxsize2; /* maximum installed size 2 */ + uint32_t smbca_size2; /* installed size 2 */ +} smb_cache_t; + +/* + * Convert encoded cache size to bytes: DSP0134 Section 7.8 explains the + * encoding. The highest bit is 0 for 1k units, 1 for 64k units, and this + * macro decodes the value into bytes for exporting to our clients. + */ +#define SMB_CACHE_SIZE(s) (((s) & 0x8000) ? \ + ((uint32_t)((s) & 0x7FFF) * 64 * 1024) : ((uint32_t)(s) * 1024)) + +#define SMB_CACHE_EXT_SIZE(s) (((s) & 0x80000000U) ? \ + ((uint64_t)((s) & 0x7FFFFFFFULL) * 64ULL * 1024ULL) : \ + ((uint64_t)(s) * 1024ULL)) + +#define SMB_CACHE_CFG_MODE(c) (((c) >> 8) & 3) +#define SMB_CACHE_CFG_ENABLED(c) (((c) >> 7) & 1) +#define SMB_CACHE_CFG_LOCATION(c) (((c) >> 5) & 3) +#define SMB_CACHE_CFG_SOCKETED(c) (((c) >> 3) & 1) +#define SMB_CACHE_CFG_LEVEL(c) (((c) & 7) + 1) + +/* + * SMBIOS implementation structure for SMB_TYPE_PORT. + */ +typedef struct smb_port { + smb_header_t smbpo_hdr; /* structure header */ + uint8_t smbpo_iref; /* internal reference designator */ + uint8_t smbpo_itype; /* internal connector type */ + uint8_t smbpo_eref; /* external reference designator */ + uint8_t smbpo_etype; /* external connector type */ + uint8_t smbpo_ptype; /* port type */ +} smb_port_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_SLOT. + */ +typedef struct smb_slot_peer { + uint16_t smbspb_group_no; /* segment group number */ + uint8_t smbspb_bus; /* bus number */ + uint8_t smbspb_df; /* device/function number */ + uint8_t smbspb_width; /* electrical width */ +} smb_slot_peer_t; + +typedef struct smb_slot { + smb_header_t smbsl_hdr; /* structure header */ + uint8_t smbsl_name; /* reference designation */ + uint8_t smbsl_type; /* slot type */ + uint8_t smbsl_width; /* slot data bus width */ + uint8_t smbsl_usage; /* current usage */ + uint8_t smbsl_length; /* slot length */ + uint16_t smbsl_id; /* slot ID */ + uint8_t smbsl_ch1; /* slot characteristics 1 */ + uint8_t smbsl_ch2; /* slot characteristics 2 */ + uint16_t smbsl_sg; /* segment group number */ + uint8_t smbsl_bus; /* bus number */ + uint8_t smbsl_df; /* device/function number */ + /* Added in SMBIOS 3.2+ */ + uint8_t smbsl_dbw; /* Data bus width */ + uint8_t smbsl_npeers; /* Peer bdf groups */ + smb_slot_peer_t smbsl_peers[]; /* bifurcation peers */ + /* There are later additions in 3.4+, see smbios_slot_cont_t */ +} smb_slot_t; + +/* + * After the variable number of smbsl_peers, the smbios_slot has continued in + * size and has the following members defined as of version 3.4. These occur + * starting at byte 14 + 5 * smbsl_npeers. + */ +typedef struct smb_slot_cont { + uint8_t smbsl_info; /* slot info */ + uint8_t smbsl_pwidth; /* slot physical width */ + uint16_t smbsl_pitch; /* slot pitch */ + /* Added in SMBIOS 3.5 */ + uint8_t smbsl_height; /* slot height */ +} smb_slot_cont_t; + +/* + * The first byte that the smb_slot_cont_t is defined to start at. Note, this + * was originally indicated to be 0x14 in the SMBIOS 3.4 specification. This has + * been noted as an errata. Right now we assume that most things have the + * updated behavior in SMBIOS 3.5. However, if we encounter things in the wild + * that have the other offset then we will need to condition this on 3.4. + */ +#define SMB_SLOT_CONT_START 0x13 + +/* + * SMBIOS implementation structure for SMB_TYPE_OBDEVS. + */ +typedef struct smb_obdev { + uint8_t smbob_type; /* encoded type and enable bit */ + uint8_t smbob_name; /* description string */ +} smb_obdev_t; + +#define SMB_OBT_ENABLED 0x80 /* enable bit within smbob_type */ + +/* + * SMBIOS implementation structure for SMB_TYPE_OEMSTR, SMB_TYPE_SYSCONFSTR, + * and SMB_TYPE_LANG. + */ +typedef struct smb_strtab { + smb_header_t smbtb_hdr; /* structure header */ + uint8_t smbtb_count; /* number of strings */ +} smb_strtab_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_LANG. + */ +typedef struct smb_lang { + smb_header_t smblang_hdr; /* structure header */ + uint8_t smblang_num; /* number of installed languages */ + uint8_t smblang_flags; /* flags */ + uint8_t smblang_resv[15]; /* reserved for future use */ + uint8_t smblang_cur; /* current language string */ +} smb_lang_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_EVENTLOG. + */ +typedef struct smb_sel { + smb_header_t smbsel_hdr; /* structure header */ + uint16_t smbsel_len; /* log area length */ + uint16_t smbsel_hdroff; /* header offset */ + uint16_t smbsel_dataoff; /* data offset */ + uint8_t smbsel_method; /* access method */ + uint8_t smbsel_status; /* status flags */ + uint32_t smbsel_token; /* change token */ + uint32_t smbsel_addr; /* access method address */ + uint8_t smbsel_format; /* header format */ + uint8_t smbsel_typec; /* number of type descriptors */ + uint8_t smbsel_typesz; /* size of each type descriptor */ + uint8_t smbsel_typev[1]; /* array of type descriptors */ +} smb_sel_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_MEMARRAY. + */ +typedef struct smb_memarray { + smb_header_t smbmarr_hdr; /* structure header */ + uint8_t smbmarr_loc; /* location */ + uint8_t smbmarr_use; /* use */ + uint8_t smbmarr_ecc; /* error detect/correct mechanism */ + uint32_t smbmarr_cap; /* maximum capacity */ + uint16_t smbmarr_err; /* error handle */ + uint16_t smbmarr_ndevs; /* number of slots or sockets */ + uint64_t smbmarr_extcap; /* extended maximum capacity */ +} smb_memarray_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_MEMARRAYMAP. + */ +typedef struct smb_memarrmap { + smb_header_t smbamap_hdr; /* structure header */ + uint32_t smbamap_start; /* starting address in kilobytes */ + uint32_t smbamap_end; /* ending address in kilobytes */ + uint16_t smbamap_array; /* physical memory array handle */ + uint8_t smbamap_width; /* partition width */ + uint64_t smbamap_extstart; /* extended starting address in bytes */ + uint64_t smbamap_extend; /* extended ending address in bytes */ +} smb_memarrmap_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_MEMDEVICE. + */ +typedef struct smb_memdevice { + smb_header_t smbmdev_hdr; /* structure header */ + uint16_t smbmdev_array; /* array handle */ + uint16_t smbmdev_error; /* error handle */ + uint16_t smbmdev_twidth; /* total width */ + uint16_t smbmdev_dwidth; /* data width */ + uint16_t smbmdev_size; /* size in either K or MB */ + uint8_t smbmdev_form; /* form factor */ + uint8_t smbmdev_set; /* device set */ + uint8_t smbmdev_dloc; /* device locator */ + uint8_t smbmdev_bloc; /* bank locator */ + uint8_t smbmdev_type; /* memory type */ + uint16_t smbmdev_flags; /* detail flags */ + uint16_t smbmdev_speed; /* speed in MT/s */ + uint8_t smbmdev_manufacturer; /* manufacturer */ + uint8_t smbmdev_serial; /* serial number */ + uint8_t smbmdev_asset; /* asset tag */ + uint8_t smbmdev_part; /* part number */ + uint8_t smbmdev_attrs; /* attributes */ + uint32_t smbmdev_extsize; /* extended size */ + uint16_t smbmdev_clkspeed; /* configured clock speed */ + uint16_t smbmdev_minvolt; /* minimum voltage */ + uint16_t smbmdev_maxvolt; /* maximum voltage */ + uint16_t smbmdev_confvolt; /* configured voltage */ + /* Added in SMBIOS 3.2 */ + uint8_t smbmdev_memtech; /* memory technology */ + uint16_t smbmdev_opmode; /* memory operating mode capability */ + uint8_t smbmdev_fwver; /* firmware version */ + uint16_t smbmdev_modulemfgid; /* module manufacturer ID */ + uint16_t smbmdev_moduleprodid; /* module product ID */ + uint16_t smbmdev_memsysmfgid; /* memory controller manufacturer id */ + uint16_t smbmdev_memsysprodid; /* memory controller product id */ + uint64_t smbmdev_nvsize; /* non-volatile memory size */ + uint64_t smbmdev_volsize; /* volatile memory size */ + uint64_t smbmdev_cachesize; /* cache size */ + uint64_t smbmdev_logicalsize; /* logical size */ + /* Added in SMBIOS 3.3 */ + uint32_t smbmdev_extspeed; /* Extended device speed */ + uint32_t smbmdev_extclkspeed; /* Extended clock speed */ + /* Added in SMBIOS 3.7 */ + uint16_t smbmdev_pmic0mfgid; /* PMIC0 Manufacturer ID */ + uint16_t smbmdev_pmic0rev; /* PMIC0 Revision */ + uint16_t smbmdev_rcdmfgid; /* RCD Manufacturer ID */ + uint16_t smbmdev_rcdrev; /* RCD Revision */ +} smb_memdevice_t; + +#define SMB_MDS_KBYTES 0x8000 /* size in specified in kilobytes */ + +/* + * SMBIOS implementation structure for SMB_TYPE_MEMDEVICEMAP. + */ +typedef struct smb_memdevmap { + smb_header_t smbdmap_hdr; /* structure header */ + uint32_t smbdmap_start; /* starting address in kilobytes */ + uint32_t smbdmap_end; /* ending address in kilobytes */ + uint16_t smbdmap_device; /* memory device handle */ + uint16_t smbdmap_array; /* memory array mapped address handle */ + uint8_t smbdmap_rpos; /* row position */ + uint8_t smbdmap_ipos; /* interleave position */ + uint8_t smbdmap_idepth; /* interleave depth */ + uint64_t smbdmap_extstart; /* extended starting address */ + uint64_t smbdmap_extend; /* extended ending address */ +} smb_memdevmap_t; + +typedef struct smb_pointdev { + smb_header_t smbpdev_hdr; /* structure header */ + uint8_t smbpdev_type; /* device type */ + uint8_t smbpdev_iface; /* device interface */ + uint8_t smbpdev_nbuttons; /* number of buttons */ +} smb_pointdev_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_BATTERY. + */ +typedef struct smb_battery { + smb_header_t smbbat_hdr; /* structure header */ + uint8_t smbbat_loc; /* location */ + uint8_t smbbat_manufacturer; /* manufacturer */ + uint8_t smbbat_date; /* manufacture date */ + uint8_t smbbat_serial; /* serial number */ + uint8_t smbbat_devname; /* device name */ + uint8_t smbbat_chem; /* device chemistry */ + uint16_t smbbat_cap; /* design capacity in mW hours */ + uint16_t smbbat_volt; /* design voltage in mV */ + uint8_t smbbat_version; /* SBDS version string */ + uint8_t smbbat_err; /* error percentage */ + uint16_t smbbat_ssn; /* SBDS serial number */ + uint16_t smbbat_sdate; /* SBDS manufacture date */ + uint8_t smbbat_schem; /* SBDS chemistry string */ + uint8_t smbbat_mult; /* design capacity multiplier */ + uint32_t smbbat_oemdata; /* OEM-specific data */ +} smb_battery_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_SECURITY. + */ +typedef struct smb_hwsec { + smb_header_t smbhs_hdr; /* structure header */ + uint8_t smbhs_settings; /* settings byte */ +} smb_hwsec_t; + +#define SMB_HWS_PWR_PS(x) (((x) & 0xC0) >> 6) +#define SMB_HWS_KBD_PS(x) (((x) & 0x30) >> 4) +#define SMB_HWS_ADM_PS(x) (((x) & 0x0C) >> 2) +#define SMB_HWS_PAN_PS(x) (((x) & 0x03) >> 0) + +/* + * SMBIOS implementation structure for SMB_TYPE_VPROBE. + */ +typedef struct smb_vprobe { + smb_header_t smbvpr_hdr; /* structure header */ + uint8_t smbvpr_descr; /* description string */ + uint8_t smbvpr_locstat; /* location and status */ + uint16_t smbvpr_maxval; /* maximum voltage */ + uint16_t smbvpr_minval; /* minimum voltage */ + uint16_t smbvpr_resolution; /* probe resolution */ + uint16_t smbvpr_tolerance; /* probe tolerance */ + uint16_t smbvpr_accuracy; /* probe accuracy */ + uint32_t smbvpr_oem; /* vendor-specific data */ + uint16_t smbvpr_nominal; /* nominal value */ +} smb_vprobe_t; + +#define SMB_VPROBE_MINLEN 0x14 +#define SMB_VPROBE_NOMINAL_MINLEN 0x16 + +#define SMB_VPROBE_LOCATION(x) ((x) & 0x1f) +#define SMB_VPROBE_STATUS(x) (((x) >> 5) & 0x7) + +/* + * SMBIOS implementation structure for SMB_TYPE_COOLDEV. + */ +typedef struct smb_cooldev { + smb_header_t smbcdev_hdr; /* structure header */ + uint16_t smbcdev_tprobe; /* temperature probe */ + uint8_t smbcdev_typstat; /* type and status */ + uint8_t smbcdev_group; /* group identifier */ + uint32_t smbcdev_oem; /* vendor-specific data */ + uint16_t smbcdev_nominal; /* nominal value */ + uint8_t smbcdev_descr; /* description string */ +} smb_cooldev_t; + +#define SMB_COOLDEV_MINLEN 0x0c +#define SMB_COOLDEV_NOMINAL_MINLEN 0x0e +#define SMB_COOLDEV_DESCR_MINLEN 0x0f + +#define SMB_COOLDEV_TYPE(x) ((x) & 0x1f) +#define SMB_COOLDEV_STATUS(x) (((x) >> 5) & 0x7) + +/* + * SMBIOS implementation structure for SMB_TYPE_TPROBE. + */ +typedef struct smb_tprobe { + smb_header_t smbtpr_hdr; /* structure header */ + uint8_t smbtpr_descr; /* description string */ + uint8_t smbtpr_locstat; /* location and status */ + uint16_t smbtpr_maxval; /* maximum temperature */ + uint16_t smbtpr_minval; /* minimum temperature */ + uint16_t smbtpr_resolution; /* probe resolution */ + uint16_t smbtpr_tolerance; /* probe tolerance */ + uint16_t smbtpr_accuracy; /* probe accuracy */ + uint32_t smbtpr_oem; /* vendor-specific data */ + uint16_t smbtpr_nominal; /* nominal value */ +} smb_tprobe_t; + +#define SMB_TPROBE_MINLEN 0x14 +#define SMB_TPROBE_NOMINAL_MINLEN 0x16 + +#define SMB_TPROBE_LOCATION(x) ((x) & 0x1f) +#define SMB_TPROBE_STATUS(x) (((x) >> 5) & 0x7) + +/* + * SMBIOS implementation structure for SMB_TYPE_IPROBE. + */ +typedef struct smb_iprobe { + smb_header_t smbipr_hdr; /* structure header */ + uint8_t smbipr_descr; /* description string */ + uint8_t smbipr_locstat; /* location and status */ + uint16_t smbipr_maxval; /* maximum current */ + uint16_t smbipr_minval; /* minimum current */ + uint16_t smbipr_resolution; /* probe resolution */ + uint16_t smbipr_tolerance; /* probe tolerance */ + uint16_t smbipr_accuracy; /* probe accuracy */ + uint32_t smbipr_oem; /* vendor-specific data */ + uint16_t smbipr_nominal; /* nominal value */ +} smb_iprobe_t; + +#define SMB_IPROBE_MINLEN 0x14 +#define SMB_IPROBE_NOMINAL_MINLEN 0x16 + +#define SMB_IPROBE_LOCATION(x) ((x) & 0x1f) +#define SMB_IPROBE_STATUS(x) (((x) >> 5) & 0x7) + +/* + * SMBIOS implementation structure for SMB_TYPE_BOOT. + */ +typedef struct smb_boot { + smb_header_t smbbo_hdr; /* structure header */ + uint8_t smbbo_pad[6]; /* reserved for future use */ + uint8_t smbbo_status[1]; /* variable-length status buffer */ +} smb_boot_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_IPMIDEV. + */ +typedef struct smb_ipmi { + smb_header_t smbipm_hdr; /* structure header */ + uint8_t smbipm_type; /* interface type */ + uint8_t smbipm_spec; /* specification revision */ + uint8_t smbipm_i2c; /* i2C slave address */ + uint8_t smbipm_bus; /* NV storage device bus ID */ + uint64_t smbipm_addr; /* base address */ + uint8_t smbipm_info; /* base address modifier/intr info */ + uint8_t smbipm_intr; /* interrupt number */ +} smb_ipmi_t; + +#define SMB_IPM_SPEC_MAJOR(x) (((x) & 0xF0) >> 4) +#define SMB_IPM_SPEC_MINOR(x) ((x) & 0x0F) + +#define SMB_IPM_ADDR_IO 1ULL + +#define SMB_IPM_INFO_REGS(x) (((x) & 0xC0) >> 6) +#define SMB_IPM_INFO_LSB(x) (((x) & 0x10) >> 4) +#define SMB_IPM_INFO_ISPEC(x) (((x) & 0x08) >> 3) +#define SMB_IPM_INFO_IPOL(x) (((x) & 0x02) >> 1) +#define SMB_IPM_INFO_IMODE(x) (((x) & 0x01) >> 0) + +#define SMB_IPM_REGS_1B 0 +#define SMB_IPM_REGS_4B 1 +#define SMB_IPM_REGS_16B 2 + +#define SMB_IPM_IPOL_LO 0 +#define SMB_IPM_IPOL_HI 1 + +#define SMB_IPM_IMODE_EDGE 0 +#define SMB_IPM_IMODE_LEVEL 1 + +/* + * SMBIOS implementation structure for SMB_TYPE_POWERSUP. + */ +typedef struct smb_powersup { + smb_header_t smbpsup_hdr; /* structure header */ + uint8_t smbpsup_group; /* group id */ + uint8_t smbpsup_loc; /* location tag */ + uint8_t smbpsup_devname; /* device name */ + uint8_t smbpsup_manufacturer; /* manufacturer */ + uint8_t smbpsup_serial; /* serial number */ + uint8_t smbpsup_asset; /* asset tag */ + uint8_t smbpsup_part; /* part number */ + uint8_t smbpsup_rev; /* revision string */ + uint16_t smbpsup_max; /* max output in milliwatts */ + uint16_t smbpsup_char; /* characteristics */ + uint16_t smbpsup_vprobe; /* voltage probe handle */ + uint16_t smbpsup_cooldev; /* cooling device handle */ + uint16_t smbpsup_iprobe; /* current probe handle */ +} smb_powersup_t; + +#define SMB_PSU_CHARS_ISHOT(x) ((x) & 0x01) +#define SMB_PSU_CHARS_ISPRES(x) ((x) & 0x02) +#define SMB_PSU_CHARS_ISUNPLUG(x) ((x) & 0x04) +#define SMB_PSU_CHARS_IVRS(x) (((x) >> 3) & 0xf) +#define SMB_PSU_CHARS_STATUS(x) (((x) >> 7) & 0x7) +#define SMB_PSU_CHARS_TYPE(x) (((x) >> 10) & 0xf) + +/* + * SMBIOS implementation structure for SMB_TYPE_ADDINFO. + */ +typedef struct smb_addinfo { + smb_header_t smbai_hdr; + uint8_t smbai_nents; + uint8_t smbai_data[]; +} smb_addinfo_t; + +/* + * This contains the additional information entry. There are in theory n of + * these in the smbai_data[] member of the additional information structure + * above. The offset here is to the referenced handle. + */ +typedef struct smb_addinfo_ent { + uint8_t smbaie_len; + uint16_t smbaie_rhdl; + uint8_t smbaie_off; + uint8_t smbaie_str; + uint8_t smbaie_val[]; +} smb_addinfo_ent_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_OBDEVEXT. + */ +typedef struct smb_obdev_ext { + smb_header_t smbobe_hdr; /* structure header */ + uint8_t smbobe_name; /* reference designation */ + uint8_t smbobe_dtype; /* device type */ + uint8_t smbobe_dti; /* device type instance */ + uint16_t smbobe_sg; /* segment group number */ + uint8_t smbobe_bus; /* bus number */ + uint8_t smbobe_df; /* device/function number */ +} smb_obdev_ext_t; + +/* + * SMBIOS implementation structure for SMB_TYPE_PROCESSOR_INFO + */ +typedef struct smb_processor_info { + smb_header_t smbpai_hdr; /* structure handle */ + uint16_t smbpai_proc; /* processor handle */ + uint8_t smbpai_len; /* length of processor specific data */ + uint8_t smbpai_type; /* processor type */ + uint8_t smbpai_data[]; /* processor-specific block */ +} smb_processor_info_t; + +typedef struct smb_processor_info_riscv { + uint16_t smbpairv_vers; /* structure revision */ + uint8_t smbpairv_len; /* length of structure */ + uint8_t smbpairv_hartid[16]; /* id of the hart */ + uint8_t smbpairv_boot; /* boot hart */ + uint8_t smbpairv_vendid[16]; /* machine vendor id */ + uint8_t smbpairv_archid[16]; /* arch vendor id */ + uint8_t smbpairv_machid[16]; /* machine impl id */ + uint32_t smbpairv_isa; /* supported ISA */ + uint8_t smbpairv_privlvl; /* supported privilege levels */ + uint8_t smbpairv_metdi[16]; /* Machine exception trap delegation */ + uint8_t smbpairv_mitdi[16]; /* Machine interrupt trap delegation */ + uint8_t smbpairv_xlen; /* Register width */ + uint8_t smbpairv_mxlen; /* Machine register width */ + uint8_t smbpairv_rsvd; /* Reserved */ + uint8_t smbpairv_sxlen; /* Supervisor register width */ + uint8_t smbpairv_uxlen; /* User register width */ +} smb_processor_info_riscv_t; + +/* + * SMBIOS implementation structure for SMBIOS_TYPE_FWINFO. + */ +typedef struct smb_fwinfo { + smb_header_t smbfwii_hdr; /* structure handle */ + uint8_t smbfwii_name; /* Firmware component name */ + uint8_t smbfwii_vers; /* Firmware version */ + uint8_t smbfwii_vers_fmt; /* Version format */ + uint8_t smbfwii_id; /* Firmware ID */ + uint8_t smbfwii_id_fmt; /* Firmware ID format */ + uint8_t smbfwii_reldate; /* Release Date */ + uint8_t smbfwii_mfg; /* Manufacturer */ + uint8_t smbfwii_lsv; /* Lowest supported version */ + uint64_t smbfwii_imgsz; /* Image size */ + uint16_t smbfwii_chars; /* Characteristics */ + uint8_t smbfwii_state; /* State */ + uint8_t smbfwii_ncomps; /* Number of associated components */ + uint16_t smbfwii_comps[]; /* Variable handles */ +} smb_fwinfo_t; + +/* + * SMBIOS implementation structure for SMBIOS_TYPE_STRPROP. + */ +typedef struct smb_strprop { + smb_header_t smbstrp_hdr; /* structure handle */ + uint16_t smbstrp_prop_id; /* string property ID */ + uint8_t smbstrp_prop_val; /* string property value */ + uint16_t smbstrp_phdl; /* parent handle */ +} smb_strprop_t; + +/* + * SMBIOS implementation structure for SUN_OEM_EXT_PROCESSOR. + */ +typedef struct smb_processor_ext { + smb_header_t smbpre_hdr; /* structure header */ + uint16_t smbpre_processor; /* processor handle */ + uint8_t smbpre_fru; /* FRU indicator */ + uint8_t smbpre_n; /* number of APIC IDs */ + uint16_t smbpre_apicid[1]; /* strand initial apic id */ +} smb_processor_ext_t; + +/* + * SMBIOS implementation structure for SUN_OEM_EXT_PORT. + */ +typedef struct smb_port_ext { + smb_header_t smbpoe_hdr; /* structure header */ + uint16_t smbpoe_chassis; /* chassis handle */ + uint16_t smbpoe_port; /* port connector handle */ + uint8_t smbpoe_dtype; /* device type */ + uint16_t smbpoe_devhdl; /* device handle */ + uint8_t smbpoe_phy; /* PHY number */ +} smb_port_ext_t; + +/* + * SMBIOS implementation structure for SUN_OEM_PCIEXRC. + */ +typedef struct smb_pciexrc { + smb_header_t smbpciexrc_hdr; /* structure header */ + uint16_t smbpciexrc_bboard; /* base board handle */ + uint16_t smbpciexrc_bdf; /* PCI Bus/Dev/Func */ +} smb_pciexrc_t; + +/* + * SMBIOS implementation structure for SUN_OEM_EXT_MEMARRAY. + */ +typedef struct smb_memarray_ext { + smb_header_t smbmarre_hdr; /* structure header */ + uint16_t smbmarre_ma; /* memory array handle */ + uint16_t smbmarre_component; /* component parent handle */ + uint16_t smbmarre_bdf; /* PCI bus/dev/funct */ +} smb_memarray_ext_t; + +/* + * SMBIOS implementation structure for SUN_OEM_EXT_MEMDEVICE. + */ +typedef struct smb_memdevice_ext { + smb_header_t smbmdeve_hdr; /* structure header */ + uint16_t smbmdeve_mdev; /* memory device handle */ + uint8_t smbmdeve_dchan; /* DRAM channel */ + uint8_t smbmdeve_ncs; /* number of chip select */ + uint8_t smbmdeve_cs[]; /* chip selects */ +} smb_memdevice_ext_t; + +#pragma pack() + +typedef struct smb_struct { + const smb_header_t *smbst_hdr; /* address of raw structure data */ + const uchar_t *smbst_str; /* address of string data (if any) */ + const uchar_t *smbst_end; /* address of 0x0000 ending tag */ + struct smb_struct *smbst_next; /* next structure in hash chain */ + uint16_t *smbst_strtab; /* string index -> offset table */ + uint_t smbst_strtablen; /* length of smbst_strtab */ +} smb_struct_t; + +struct smbios_hdl { + smbios_entry_point_t sh_ent_type; /* structure table entry point type */ + smbios_entry_t sh_ent; /* structure table entry point */ + uint_t sh_ent_stnum; /* number of structure table entries */ + const void *sh_buf; /* structure table buffer */ + size_t sh_buflen; /* size of structure table buffer */ + smb_struct_t *sh_structs; /* array of structure descriptors */ + uint_t sh_nstructs; /* number of active structures */ + smb_struct_t **sh_hash; /* hash bucket array for descriptors */ + uint_t sh_hashlen; /* hash bucket array length */ + int sh_err; /* error code for smbios_errno() */ + int sh_libvers; /* library client abi version */ + int sh_smbvers; /* derived underlying format version */ + uint_t sh_flags; /* miscellaneous flags (see below) */ +}; + +#define SMB_FL_DEBUG 0x1 /* print debug messages for this hdl */ +#define SMB_FL_BUFALLOC 0x2 /* sh_buf was allocated by library */ +#define SMB_FL_TRUNC 0x4 /* smbios table is truncated */ + +#define SMB_BIOS_DEVICE "/dev/xsvc" /* device w/ BIOS physmem */ +#define SMB_SMBIOS_DEVICE "/dev/smbios" /* device w/ SMBIOS image */ + +#define SMB_RANGE_START 0xF0000 /* start of physical address range */ +#define SMB_RANGE_LIMIT 0xFFFFF /* limit of physical address range */ +#define SMB_SCAN_STEP 16 /* stepping by paragraph */ + +#define SMB_MAJMIN(M, m) ((((M) & 0xFF) << 8) | ((m) & 0xFF)) +#define SMB_MAJOR(v) (((v) & 0xFF00) >> 8) +#define SMB_MINOR(v) (((v) & 0x00FF)) + +#define ESMB_BASE 1000 /* base value for libsmbios errnos */ + +enum { + ESMB_NOTFOUND = ESMB_BASE, /* SMBIOS table not found on system */ + ESMB_MAPDEV, /* failed to map SMBIOS table */ + ESMB_NOENT, /* failed to locate structure */ + ESMB_NOMEM, /* failed to allocate memory */ + ESMB_NOHDR, /* failed to read SMBIOS header */ + ESMB_NOSTAB, /* failed to read SMBIOS struct table */ + ESMB_NOINFO, /* no common info for structure */ + ESMB_SHORT, /* buffer length doesn't match header */ + ESMB_CORRUPT, /* buffer struct or len is corrupt */ + ESMB_VERSION, /* version not supported by library */ + ESMB_NOTSUP, /* feature not supported by provider */ + ESMB_HEADER, /* SMBIOS header corrupt or invalid */ + ESMB_OLD, /* SMBIOS version is too old for us */ + ESMB_NEW, /* SMBIOS version is too new for us */ + ESMB_CKSUM, /* SMBIOS header checksum mismatch */ + ESMB_INVAL, /* invalid function call argument */ + ESMB_TYPE, /* structure type mismatch */ + ESMB_UNKNOWN, /* unknown error */ + ESMB_REQVAL /* invalid requested value */ +}; + +extern const smb_struct_t *smb_lookup_type(smbios_hdl_t *, uint_t); +extern const smb_struct_t *smb_lookup_id(smbios_hdl_t *, uint_t); +extern const char *smb_strptr(const smb_struct_t *, uint_t); +extern boolean_t smb_gteq(smbios_hdl_t *, int); +extern boolean_t smb_libgteq(smbios_hdl_t *, int); + +extern int smb_set_errno(smbios_hdl_t *, int); +extern smbios_hdl_t *smb_open_error(smbios_hdl_t *, int *, int); +extern const char *smb_strerror(int); + +extern void *smb_alloc(size_t); +extern void *smb_zalloc(size_t); +extern void smb_free(void *, size_t); + +extern void smb_dprintf(smbios_hdl_t *, const char *, ...); + +extern int _smb_debug; + +/* + * The following series of structures represent the base versions of public + * structures that are used inside by the smbios routines. This allows the + * common code to properly know how much it should or should not bzero and how + * to handle additions to the spec. Types should only be added here if we need + * to extend the public structures in sys/smbios.h due to a change in the spec. + * + * Types here have the name smb_base_%s which corresponds to smbios_%s. + */ +typedef struct smb_base_chassis { + uint32_t smbbc_oemdata; /* OEM-specific data */ + uint8_t smbbc_lock; /* lock present? */ + uint8_t smbbc_type; /* type */ + uint8_t smbbc_bustate; /* boot-up state */ + uint8_t smbbc_psstate; /* power supply state */ + uint8_t smbbc_thstate; /* thermal state */ + uint8_t smbbc_security; /* security status */ + uint8_t smbbc_uheight; /* enclosure height in U's */ + uint8_t smbbc_cords; /* number of power cords */ + uint8_t smbbc_elems; /* number of element records (n) */ + uint8_t smbbc_elemlen; /* length of contained element (m) */ +} smb_base_chassis_t; + +typedef struct smb_base_processor { + uint64_t smbbp_cpuid; /* processor cpuid information */ + uint32_t smbbp_family; /* processor family */ + uint8_t smbbp_type; /* processor type (SMB_PRT_*) */ + uint8_t smbbp_voltage; /* voltage (SMB_PRV_*) */ + uint8_t smbbp_status; /* status (SMB_PRS_*) */ + uint8_t smbbp_upgrade; /* upgrade (SMB_PRU_*) */ + uint32_t smbbp_clkspeed; /* external clock speed in MHz */ + uint32_t smbbp_maxspeed; /* maximum speed in MHz */ + uint32_t smbbp_curspeed; /* current speed in MHz */ + id_t smbbp_l1cache; /* L1 cache handle */ + id_t smbbp_l2cache; /* L2 cache handle */ + id_t smbbp_l3cache; /* L3 cache handle */ +} smb_base_processor_t; + +typedef struct smb_base_memdevice { + id_t smbbmd_array; /* handle of physical memory array */ + id_t smbbmd_error; /* handle of memory error data */ + uint32_t smbbmd_twidth; /* total width in bits including ecc */ + uint32_t smbbmd_dwidth; /* data width in bits */ + uint64_t smbbmd_size; /* size in bytes (see note above) */ + uint8_t smbbmd_form; /* form factor */ + uint8_t smbbmd_set; /* set (0x00=none, 0xFF=unknown) */ + uint8_t smbbmd_type; /* memory type */ + uint8_t smbbmd_pad; /* padding */ + uint32_t smbbmd_flags; /* flags (see below) */ + uint32_t smbbmd_speed; /* speed in MHz */ + const char *smbbmd_dloc; /* physical device locator string */ + const char *smbbmd_bloc; /* physical bank locator string */ + uint8_t smbbmd_rank; /* rank */ +} smb_base_memdevice_t; + +typedef struct smb_base_bios { + const char *smbbb_vendor; /* bios vendor string */ + const char *smbbb_version; /* bios version string */ + const char *smbbb_reldate; /* bios release date */ + uint32_t smbbb_segment; /* bios address segment location */ + uint32_t smbbb_romsize; /* bios rom size in bytes */ + uint32_t smbbb_runsize; /* bios image size in bytes */ + uint64_t smbbb_cflags; /* bios characteristics */ + const uint8_t *smbbb_xcflags; /* bios characteristics extensions */ + size_t smbbb_nxcflags; /* number of smbb_xcflags[] bytes */ + smbios_version_t smbbb_biosv; /* bios version */ + smbios_version_t smbbb_ecfwv; /* bios embedded ctrl f/w version */ +} smb_base_bios_t; + +typedef struct smb_base_cache { + uint32_t smbba_maxsize; /* maximum installed size in bytes */ + uint32_t smbba_size; /* installed size in bytes */ + uint16_t smbba_stype; /* supported SRAM types (SMB_CAT_*) */ + uint16_t smbba_ctype; /* current SRAM type (SMB_CAT_*) */ + uint8_t smbba_speed; /* speed in nanoseconds */ + uint8_t smbba_etype; /* error correction type (SMB_CAE_*) */ + uint8_t smbba_ltype; /* logical cache type (SMB_CAG_*) */ + uint8_t smbba_assoc; /* associativity (SMB_CAA_*) */ + uint8_t smbba_level; /* cache level */ + uint8_t smbba_mode; /* cache mode (SMB_CAM_*) */ + uint8_t smbba_location; /* cache location (SMB_CAL_*) */ + uint8_t smbba_flags; /* cache flags (SMB_CAF_*) */ +} smb_base_cache_t; + +typedef struct smb_base_slot { + const char *smbbl_name; /* reference designation */ + uint8_t smbbl_type; /* slot type */ + uint8_t smbbl_width; /* slot data bus width */ + uint8_t smbbl_usage; /* current usage */ + uint8_t smbbl_length; /* slot length */ + uint16_t smbbl_id; /* slot ID */ + uint8_t smbbl_ch1; /* slot characteristics 1 */ + uint8_t smbbl_ch2; /* slot characteristics 2 */ + uint16_t smbbl_sg; /* segment group number */ + uint8_t smbbl_bus; /* bus number */ + uint8_t smbbl_df; /* device/function number */ +} smb_base_slot_t; + +/* + * Prior to reivison 3.5 of the library and interface we had embedded a 256 byte + * string for the SKU into here rather than pointing to constant data. This, + * combined withe bugs in the implementation, generally led to strings with + * garbage. As part of fixing this with the 3.5 support, we moved the struct to + * ve more inline with everything else. + */ +typedef struct smb_chassis_pre35 { + uint32_t smbc_oemdata; /* OEM-specific data */ + uint8_t smbc_lock; /* lock present? */ + uint8_t smbc_type; /* type */ + uint8_t smbc_bustate; /* boot-up state */ + uint8_t smbc_psstate; /* power supply state */ + uint8_t smbc_thstate; /* thermal state */ + uint8_t smbc_security; /* security status */ + uint8_t smbc_uheight; /* enclosure height in U's */ + uint8_t smbc_cords; /* number of power cords */ + uint8_t smbc_elems; /* number of element records (n) */ + uint8_t smbc_elemlen; /* length of contained element (m) */ + char smbc_sku[256]; +} smb_chassis_pre35_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SMBIOS_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/smedia.h b/illumos-x86_64/usr/include/sys/smedia.h new file mode 100644 index 00000000..f7d291ac --- /dev/null +++ b/illumos-x86_64/usr/include/sys/smedia.h @@ -0,0 +1,167 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SMEDIA_H_ +#define _SMEDIA_H_ + +/* + * smedia.h header for libsmedia library + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct smdevice_info { + uchar_t sm_version; + int32_t sm_interface_type; /* Interface type */ + char *sm_vendor_name; /* Vendor name */ + char *sm_product_name; /* Product name */ + char *sm_firmware_version; /* Firmware version */ +}smdevice_info_t; + +typedef void *smedia_handle_t; + + +#define SMDEVICE_INFO_V_1 1 + +/* Interface Types */ + +#define IF_SCSI 0x0 +#define IF_FLOPPY 0x1 +#define IF_PCMCIA 0x2 +#define IF_BLOCK 0x3 + + +typedef struct smmedium_property { + int32_t sm_version; + int32_t sm_media_type; /* Medium type */ + int32_t sm_blocksize; /* Medium block size in bytes */ + int32_t sm_capacity; /* Medium capacity in no. of blocks */ + int32_t sm_pcyl; /* No. of cylinders on the medium */ + int32_t sm_nhead; /* No. of heads */ + int32_t sm_nsect; /* No. of sectors per cylinder */ +}smmedium_prop_t; + +#define SMMEDIA_PROP_V_1 1 + +/* + * Media types not defined for DKIOCGMEDIAINFO + */ + +#define SM_REMOVABLE_DISK 0x20005 /* Removable disk */ + /* FIXED_DISK + REMOVABLE */ +#define SM_FLOPPY 0x10002 /* Floppy media */ +#define SM_SCSI_FLOPPY 0x10005 /* SCSI floppy device */ +#define SM_PCMCIA_MEM 0x20006 /* PCMCIA memory card (Obsolete) */ +#define SM_PCMCIA_ATA 0x20007 /* PCMCIA ata card */ +#define SM_BLOCK 0x20008 /* Generic block device */ +#define SM_NOT_PRESENT 0xFFFF + + +#define MAX_PASSWD_LENGTH 32 + +#define PASSWD 0x1000 + +#define SM_WRITE_PROTECT_DISABLE (PASSWD|0x0) +#define SM_WRITE_PROTECT_NOPASSWD (PASSWD|0x2) +#define SM_WRITE_PROTECT_PASSWD (PASSWD|0x4) +#define SM_READ_WRITE_PROTECT (PASSWD|0x8) +#define SM_TEMP_UNLOCK_MODE (PASSWD|0x10) +#define SM_STATUS_UNKNOWN (PASSWD|0xFF) + +#define SM_UNPROTECTED SM_WRITE_PROTECT_DISABLE +#define SM_WRITE_PROTECTED SM_WRITE_PROTECT_NOPASSWD +#define SM_WRITE_PROTECTED_WP SM_WRITE_PROTECT_PASSWD +#define SM_READ_WRITE_PROTECTED SM_READ_WRITE_PROTECT + + +typedef struct smwp_state { + uchar_t sm_version; + int32_t sm_new_state; + int32_t sm_passwd_len; + char sm_passwd[MAX_PASSWD_LENGTH]; +}smwp_state_t; + +#define SMWP_STATE_V_1 1 + +#define FORMAT 0x2000 + +#define SM_FORMAT_LONG (FORMAT|0x0001) +#define SM_FORMAT_QUICK (FORMAT|0x0002) +#define SM_FORMAT_FORCE (FORMAT|0x0003) + +/* Floppy specific options */ +#define SM_FORMAT_HD (FORMAT|0x0011) /* Format high density (1.44MB) */ +#define SM_FORMAT_DD (FORMAT|0x0012) /* Format Double density (720KB) */ +#define SM_FORMAT_ED (FORMAT|0x0013) /* Format Extended density (2.88MB) */ +#define SM_FORMAT_MD (FORMAT|0x0014) /* Format Medium density (1.2MB) */ + +#define SM_FORMAT_IMMEDIATE (FORMAT|0x0021) +#define SM_FORMAT_BLOCKED (FORMAT|0x0022) + + +/* New Library interface prototypes */ + +int smedia_get_device_info(smedia_handle_t handle, smdevice_info_t *smdevinfop); +int smedia_free_device_info(smedia_handle_t handle, + smdevice_info_t *smdevinfop); +int smedia_get_medium_property(smedia_handle_t handle, + smmedium_prop_t *smpropp); +int smedia_get_protection_status(smedia_handle_t handle, + smwp_state_t *wpstatep); +int smedia_set_protection_status(smedia_handle_t handle, + smwp_state_t *wpstatep); +size_t smedia_raw_read(smedia_handle_t handle, diskaddr_t blockno, + caddr_t buffer, + size_t nbytes); +size_t smedia_raw_write(smedia_handle_t handle, diskaddr_t blockno, + caddr_t buffer, + size_t nbytes); +int smedia_format(smedia_handle_t handle, uint_t flavor, uint_t mode); +int smedia_check_format_status(smedia_handle_t handle); +int smedia_format_track(smedia_handle_t handle, uint_t trackno, uint_t head, + uint_t density); +int smedia_eject(smedia_handle_t handle); +int smedia_reassign_block(smedia_handle_t handle, diskaddr_t blockno); +smedia_handle_t smedia_get_handle(int32_t); +int smedia_release_handle(smedia_handle_t handle); +int smedia_uscsi_cmd(smedia_handle_t handle, struct uscsi_cmd *cmd); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SMEDIA_H_ */ diff --git a/illumos-x86_64/usr/include/sys/sobject.h b/illumos-x86_64/usr/include/sys/sobject.h new file mode 100644 index 00000000..5ea3df8f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sobject.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SOBJECT_H +#define _SYS_SOBJECT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Type-number definitions for the various synchronization + * objects defined for the system. The numeric values + * assigned to the various definitions begin with zero, since + * the synch-object mapping array depends on these values. + */ +#define SOBJ_NONE 0 /* undefined synchonization object */ +#define SOBJ_MUTEX 1 /* mutex synchonization object */ +#define SOBJ_RWLOCK 2 /* readers/writer synchonization object */ +#define SOBJ_CV 3 /* cond. variable synchonization object */ +#define SOBJ_SEMA 4 /* semaphore synchonization object */ +#define SOBJ_USER 5 /* user-level synchronization object */ +#define SOBJ_USER_PI 6 /* user-level sobj having Prio Inheritance */ +#define SOBJ_SHUTTLE 7 /* shuttle synchronization object */ + +/* + * The following data structure is used to map + * synchronization object type numbers to the + * synchronization object's sleep queue number + * or the synch. object's owner function. + */ +typedef struct _sobj_ops { + int sobj_type; + kthread_t *(*sobj_owner)(); + void (*sobj_unsleep)(kthread_t *); + void (*sobj_change_pri)(kthread_t *, pri_t, pri_t *); +} sobj_ops_t; + +#ifdef _KERNEL + +#define SOBJ_TYPE(sobj_ops) sobj_ops->sobj_type +#define SOBJ_OWNER(sobj_ops, sobj) (*(sobj_ops->sobj_owner))(sobj) +#define SOBJ_UNSLEEP(sobj_ops, t) (*(sobj_ops->sobj_unsleep))(t) +#define SOBJ_CHANGE_PRI(sobj_ops, t, pri) \ + (*(sobj_ops->sobj_change_pri))(t, pri, &t->t_pri) +#define SOBJ_CHANGE_EPRI(sobj_ops, t, pri) \ + (*(sobj_ops->sobj_change_pri))(t, pri, &t->t_epri) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SOBJECT_H */ diff --git a/illumos-x86_64/usr/include/sys/socket.h b/illumos-x86_64/usr/include/sys/socket.h new file mode 100644 index 00000000..a2c44acc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/socket.h @@ -0,0 +1,581 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015, Joyent, Inc. All rights reserved. + * Copyright 2022 Garrett D'Amore + * + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +/* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ + +/* + * Copyright (c) 2014, Joyent, Inc. All rights reserved. + */ +#ifndef _SYS_SOCKET_H +#define _SYS_SOCKET_H + +#include +#include +#include +#include +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#ifndef _KERNEL +#include +#endif /* !_KERNEL */ +/* + * Historically, netinet/in.h included sys/stream.h, which pulled in + * several things. The more troublesome namespace pollution was from + * sys/stream.h so that was removed. To avoid having to fix lots of + * programs, pull in a few things that are now (for better or worse) + * expected by programs that include sys/socket.h + */ +#include +#include +#include +#include +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _SOCKLEN_T +#define _SOCKLEN_T + +/* + * The socklen definitions are reproduced in netinet/in.h for the inet6_ + * functions. Exposing all of sys/socket.h via netinet/in.h breaks existing + * applications and is not required by austin. + */ +#if defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) +typedef size_t socklen_t; +#else +typedef uint32_t socklen_t; +#endif /* defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) */ + +#if defined(_XPG4_2) || defined(_BOOT) +typedef socklen_t *_RESTRICT_KYWD Psocklen_t; +#else +typedef void *_RESTRICT_KYWD Psocklen_t; +#endif /* defined(_XPG4_2) || defined(_BOOT) */ + +#endif /* _SOCKLEN_T */ + +/* + * Definitions related to sockets: types, address families, options. + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#ifndef NC_TPI_CLTS +#define NC_TPI_CLTS 1 /* must agree with netconfig.h */ +#define NC_TPI_COTS 2 /* must agree with netconfig.h */ +#define NC_TPI_COTS_ORD 3 /* must agree with netconfig.h */ +#define NC_TPI_RAW 4 /* must agree with netconfig.h */ +#endif /* !NC_TPI_CLTS */ +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Types + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define SOCK_STREAM NC_TPI_COTS /* stream socket */ +#define SOCK_DGRAM NC_TPI_CLTS /* datagram socket */ +#define SOCK_RAW NC_TPI_RAW /* raw-protocol interface */ +#else +#define SOCK_STREAM 2 /* stream socket */ +#define SOCK_DGRAM 1 /* datagram socket */ +#define SOCK_RAW 4 /* raw-protocol interface */ +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ +#define SOCK_RDM 5 /* reliably-delivered message */ +#define SOCK_SEQPACKET 6 /* sequenced packet stream */ +#define SOCK_TYPE_MASK 0xffff /* type reside in these bits only */ + +/* + * Flags for socket() and accept4() + */ +#define SOCK_CLOEXEC 0x080000 /* like open(2) O_CLOEXEC for socket */ +#define SOCK_NONBLOCK 0x100000 /* like O_NONBLOCK */ +#define SOCK_NDELAY 0x200000 /* like O_NDELAY */ +#define SOCK_CLOFORK 0x400000 /* set FD_CLOFORK on the socket */ + +/* + * Option flags per-socket. + */ +#define SO_DEBUG 0x0001 /* turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ +#define SO_LINGER 0x0080 /* linger on close if data present */ +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ +#define SO_DGRAM_ERRIND 0x0200 /* Application wants delayed error */ +#define SO_RECVUCRED 0x0400 /* Application wants ucred of sender */ + +/* + * Socket options are passed using a signed integer, but it is also rare + * for more than one to ever be passed at the same time with setsockopt + * and only one at a time can be retrieved with getsockopt. + * + * Since the lower numbers cannot be renumbered for compatibility reasons, + * it would seem that we need to start a new number space (0x40000000 - + * 0x7fffffff) for those that don't need to be stored as a bit flag + * somewhere. This limits the flag options to 30 but that seems to be + * plenty, anyway. 0x40000000 is reserved for future use. + */ +#define SO_ATTACH_FILTER 0x40000001 +#define SO_DETACH_FILTER 0x40000002 + +#ifdef _KERNEL +#define SO_SND_COPYAVOID 0x0800 /* Internal: use zero-copy */ +#define SO_SND_BUFINFO 0x1000 /* Internal: get buffer info */ + /* when doing zero-copy */ + +struct so_snd_bufinfo { + ushort_t sbi_wroff; /* Write offset */ + ssize_t sbi_maxblk; /* Max size of a single mblk */ + ssize_t sbi_maxpsz; /* Max total size of a mblk chain */ + ushort_t sbi_tail; /* Extra space available at the end */ +}; +#endif /* _KERNEL */ + +/* + * N.B.: The following definition is present only for compatibility + * with release 3.0. It will disappear in later releases. + */ +#define SO_DONTLINGER (~SO_LINGER) /* ~SO_LINGER */ + +/* + * Additional options, not kept in so_options. + */ +#define SO_SNDBUF 0x1001 /* send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ +#define SO_SNDTIMEO 0x1005 /* send timeout */ +#define SO_RCVTIMEO 0x1006 /* receive timeout */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ +#define SO_PROTOTYPE 0x1009 /* get/set protocol type */ +#define SO_PROTOCOL SO_PROTOTYPE /* POSIX name */ +#define SO_ANON_MLP 0x100a /* create MLP on anonymous bind */ +#define SO_MAC_EXEMPT 0x100b /* allow dominated unlabeled peers */ +#define SO_DOMAIN 0x100c /* get socket domain */ +#define SO_RCVPSH 0x100d /* receive interval to push data */ + +/* "Socket"-level control message types: */ +#define SCM_RIGHTS 0x1010 /* access rights (array of int) */ +#define SO_SECATTR 0x1011 /* socket's security attributes */ +#define SCM_UCRED 0x1012 /* sender's ucred */ +#define SO_TIMESTAMP 0x1013 /* socket-level timestamp option */ +#define SCM_TIMESTAMP SO_TIMESTAMP /* socket control message timestamp */ +#define SO_ALLZONES 0x1014 /* bind in all zones */ +#define SO_EXCLBIND 0x1015 /* exclusive binding */ +#define SO_MAC_IMPLICIT 0x1016 /* hide mac labels on wire */ +#define SO_VRRP 0x1017 /* VRRP control socket */ + +#ifdef _KERNEL +#define SO_SRCADDR 0x2001 /* Internal: AF_UNIX source address */ +#define SO_FILEP 0x2002 /* Internal: AF_UNIX file pointer */ +#define SO_UNIX_CLOSE 0x2003 /* Internal: AF_UNIX peer closed */ +#define SO_REUSEPORT 0x2004 /* allow simultaneous port reuse */ +#endif /* _KERNEL */ + +/* + * Socket filter options + */ +#define FIL_ATTACH 0x1 /* attach filter */ +#define FIL_DETACH 0x2 /* detach filter */ +#define FIL_LIST 0x3 /* list attached filters */ + +#define FILNAME_MAX 32 +/* + * Structure returned by FIL_LIST + */ +struct fil_info { + int fi_flags; /* see below (FILF_*) */ + int fi_pos; /* position (0 is bottom) */ + char fi_name[FILNAME_MAX]; /* filter name */ +}; + +#define FILF_PROG 0x1 /* programmatic attach */ +#define FILF_AUTO 0x2 /* automatic attach */ +#define FILF_BYPASS 0x4 /* filter is not active */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +/* + * new socket open flags to identify socket and acceptor streams + */ +#define SO_ACCEPTOR 0x20000 /* acceptor socket */ +#define SO_SOCKSTR 0x40000 /* normal socket stream */ +#define SO_FALLBACK 0x80000 /* fallback to TPI socket */ + +/* + * Flags for socket_create() and socket_newconn() + */ +#define SOCKET_SLEEP KM_SLEEP +#define SOCKET_NOSLEEP KM_NOSLEEP + +#endif /* _KERNEL */ + +/* + * Structure used for manipulating linger option. + */ +struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time */ +}; + +/* + * Levels for (get/set)sockopt() that don't apply to a specific protocol. + */ +#define SOL_SOCKET 0xffff /* options for socket level */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define SOL_ROUTE 0xfffe /* options for routing socket level */ +#endif +#define SOL_PACKET 0xfffd /* options for packet level */ +#define SOL_FILTER 0xfffc /* options for socket filter level */ + +/* + * Address families. + * + * Some of these constant names are copied for the DTrace IP provider in + * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept + * in sync. + */ +#define AF_UNSPEC 0 /* unspecified */ +#define AF_UNIX 1 /* local to host (pipes, portals) */ +#define AF_LOCAL AF_UNIX /* Synonym for AF_UNIX */ +#define AF_FILE AF_UNIX /* Synonym for AF_UNIX */ +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ +#define AF_IMPLINK 3 /* arpanet imp addresses */ +#define AF_PUP 4 /* pup protocols: e.g. BSP */ +#define AF_CHAOS 5 /* mit CHAOS protocols */ +#define AF_NS 6 /* XEROX NS protocols */ +#define AF_NBS 7 /* nbs protocols */ +#define AF_ECMA 8 /* european computer manufacturers */ +#define AF_DATAKIT 9 /* datakit protocols */ +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ +#define AF_SNA 11 /* IBM SNA */ +#define AF_DECnet 12 /* DECnet */ +#define AF_DLI 13 /* Direct data link interface */ +#define AF_LAT 14 /* LAT */ +#define AF_HYLINK 15 /* NSC Hyperchannel */ +#define AF_APPLETALK 16 /* Apple Talk */ +#define AF_NIT 17 /* Network Interface Tap */ +#define AF_802 18 /* IEEE 802.2, also ISO 8802 */ +#define AF_OSI 19 /* umbrella for all families used */ +#define AF_X25 20 /* CCITT X.25 in particular */ +#define AF_OSINET 21 /* AFI = 47, IDI = 4 */ +#define AF_GOSIP 22 /* U.S. Government OSI */ +#define AF_IPX 23 /* Novell Internet Protocol */ +#define AF_ROUTE 24 /* Internal Routing Protocol */ +#define AF_LINK 25 /* Link-layer interface */ +#define AF_INET6 26 /* Internet Protocol, Version 6 */ +#define AF_KEY 27 /* Security Association DB socket */ +#define AF_NCA 28 /* NCA socket (obsolete) */ +#define AF_POLICY 29 /* Security Policy DB socket */ +#define AF_INET_OFFLOAD 30 /* Sun private; do not use */ +#define AF_TRILL 31 /* TRILL interface */ +#define AF_PACKET 32 /* PF_PACKET Linux socket interface */ +#define AF_LX_NETLINK 33 /* Linux-compatible netlink */ + +#define AF_MAX 33 + +/* + * Protocol families, same as address families for now. + */ +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_LOCAL PF_UNIX +#define PF_FILE PF_UNIX +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NS AF_NS +#define PF_NBS AF_NBS +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK +#define PF_NIT AF_NIT +#define PF_802 AF_802 +#define PF_OSI AF_OSI +#define PF_X25 AF_X25 +#define PF_OSINET AF_OSINET +#define PF_GOSIP AF_GOSIP +#define PF_IPX AF_IPX +#define PF_ROUTE AF_ROUTE +#define PF_LINK AF_LINK +#define PF_INET6 AF_INET6 +#define PF_KEY AF_KEY +#define PF_NCA AF_NCA +#define PF_POLICY AF_POLICY +#define PF_INET_OFFLOAD AF_INET_OFFLOAD /* Sun private; do not use */ +#define PF_TRILL AF_TRILL +#define PF_PACKET AF_PACKET +#define PF_LX_NETLINK AF_LX_NETLINK + +#define PF_MAX AF_MAX + +/* + * Maximum queue length specifiable by listen. + */ +#define SOMAXCONN 128 + +/* + * Message header for recvmsg and sendmsg calls. + */ +struct msghdr { + void *msg_name; /* optional address */ + socklen_t msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + int msg_iovlen; /* # elements in msg_iov */ + +#if defined(_XPG4_2) || defined(_KERNEL) + void *msg_control; /* ancillary data */ + socklen_t msg_controllen; /* ancillary data buffer len */ + int msg_flags; /* flags on received message */ +#else + caddr_t msg_accrights; /* access rights sent/received */ + int msg_accrightslen; +#endif /* defined(_XPG4_2) || defined(_KERNEL) */ +}; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * N.B.: we assume that omsghdr and nmsghdr are isomorphic, with + * the sole exception that nmsghdr has the additional msg_flags + * field at the end. + */ +struct omsghdr { + void *msg_name; /* optional address */ + socklen_t msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + int msg_iovlen; /* # elements in msg_iov */ + caddr_t msg_accrights; /* access rights sent/received */ + int msg_accrightslen; +}; + +#define nmsghdr msghdr + +#if defined(_SYSCALL32) + +struct omsghdr32 { + caddr32_t msg_name; /* optional address */ + uint32_t msg_namelen; /* size of address */ + caddr32_t msg_iov; /* scatter/gather array */ + int32_t msg_iovlen; /* # elements in msg_iov */ + caddr32_t msg_accrights; /* access rights sent/received */ + uint32_t msg_accrightslen; +}; + +struct msghdr32 { + caddr32_t msg_name; /* optional address */ + uint32_t msg_namelen; /* size of address */ + caddr32_t msg_iov; /* scatter/gather array */ + int32_t msg_iovlen; /* # elements in msg_iov */ + caddr32_t msg_control; /* ancillary data */ + uint32_t msg_controllen; /* ancillary data buffer len */ + int32_t msg_flags; /* flags on received message */ +}; + +#define nmsghdr32 msghdr32 + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#define MSG_OOB 0x1 /* process out-of-band data */ +#define MSG_PEEK 0x2 /* peek at incoming message */ +#define MSG_DONTROUTE 0x4 /* send without using routing tables */ +#define MSG_EOR 0x8 /* Terminates a record */ +#define MSG_CTRUNC 0x10 /* Control data truncated */ +#define MSG_TRUNC 0x20 /* Normal data truncated */ +#define MSG_WAITALL 0x40 /* Wait for complete recv or error */ +#define MSG_DONTWAIT 0x80 /* Don't block for this recv */ +#define MSG_NOTIFICATION 0x100 /* Notification, not data */ +#define MSG_NOSIGNAL 0x200 /* Don't generate SIGPIPE */ +#define MSG_DUPCTRL 0x800 /* Save control message for use with */ + /* with left over data */ +#define MSG_CMSG_CLOEXEC 0x1000 /* FD_CLOEXEC w/ SCM_RIGHTS */ +#define MSG_CMSG_CLOFORK 0x2000 /* FD_CLOFORK w/ SCM_RIGHTS */ +#define MSG_XPG4_2 0x8000 /* Private: XPG4.2 flag */ + +/* Obsolete but kept for compilation compatibility. Use IOV_MAX. */ +#define MSG_MAXIOVLEN 16 + +#ifdef _KERNEL + +/* + * Internal-only MSG_... flags + */ + +#define MSG_SENDTO_NOXLATE 0x08000000 /* Skip so_ux_addr_xlate */ + +#define MSG_MBLK_QUICKRELE 0x10000000 /* free mblk chain */ + /* in timely manner */ +#define MSG_USERSPACE 0x20000000 /* buffer from user space */ + +#endif /* _KERNEL */ + + +/* Added for XPGv2 compliance */ +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 + +struct cmsghdr { + socklen_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +}; + +#if defined(_XPG4_2) || defined(_KERNEL) +#if defined(__sparc) +/* To maintain backward compatibility, alignment needs to be 8 on sparc. */ +#define _CMSG_HDR_ALIGNMENT 8 +#else +/* for __i386 (and other future architectures) */ +#define _CMSG_HDR_ALIGNMENT 4 +#endif /* defined(__sparc) */ +#endif /* defined(_XPG4_2) || defined(_KERNEL) */ + +#if defined(_XPG4_2) +/* + * The cmsg headers (and macros dealing with them) were made available as + * part of UNIX95 and hence need to be protected with a _XPG4_2 define. + */ +#define _CMSG_DATA_ALIGNMENT (sizeof (int)) +#define _CMSG_HDR_ALIGN(x) (((uintptr_t)(x) + _CMSG_HDR_ALIGNMENT - 1) & \ + ~(_CMSG_HDR_ALIGNMENT - 1)) +#define _CMSG_DATA_ALIGN(x) (((uintptr_t)(x) + _CMSG_DATA_ALIGNMENT - 1) & \ + ~(_CMSG_DATA_ALIGNMENT - 1)) +#define CMSG_DATA(c) \ + ((unsigned char *)_CMSG_DATA_ALIGN((struct cmsghdr *)(c) + 1)) + +#define CMSG_FIRSTHDR(m) \ + (((m)->msg_controllen < sizeof (struct cmsghdr)) ? \ + (struct cmsghdr *)0 : (struct cmsghdr *)((m)->msg_control)) + +#define CMSG_NXTHDR(m, c) \ + (((c) == 0) ? CMSG_FIRSTHDR(m) : \ + ((((uintptr_t)_CMSG_HDR_ALIGN((char *)(c) + \ + ((struct cmsghdr *)(c))->cmsg_len) + sizeof (struct cmsghdr)) > \ + (((uintptr_t)((struct msghdr *)(m))->msg_control) + \ + ((uintptr_t)((struct msghdr *)(m))->msg_controllen))) ? \ + ((struct cmsghdr *)0) : \ + ((struct cmsghdr *)_CMSG_HDR_ALIGN((char *)(c) + \ + ((struct cmsghdr *)(c))->cmsg_len)))) + +/* Amount of space + padding needed for a message of length l */ +#define CMSG_SPACE(l) \ + ((unsigned int)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l))) + +/* Value to be used in cmsg_len, does not include trailing padding */ +#define CMSG_LEN(l) \ + ((unsigned int)_CMSG_DATA_ALIGN(sizeof (struct cmsghdr)) + (l)) + +#endif /* _XPG4_2 */ + +#ifdef _XPG4_2 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname bind __xnet_bind +#pragma redefine_extname connect __xnet_connect +#pragma redefine_extname recvmsg __xnet_recvmsg +#pragma redefine_extname sendmsg __xnet_sendmsg +#pragma redefine_extname sendto __xnet_sendto +#pragma redefine_extname socket __xnet_socket +#pragma redefine_extname socketpair __xnet_socketpair +#pragma redefine_extname getsockopt __xnet_getsockopt +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define bind __xnet_bind +#define connect __xnet_connect +#define recvmsg __xnet_recvmsg +#define sendmsg __xnet_sendmsg +#define sendto __xnet_sendto +#define socket __xnet_socket +#define socketpair __xnet_socketpair +#define getsockopt __xnet_getsockopt +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#endif /* _XPG4_2 */ + +#if defined(_XPG4_2) && !defined(_XPG5) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname listen __xnet_listen +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define listen __xnet_listen +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* (_XPG4_2) && !defined(_XPG5) */ + +#if !defined(_KERNEL) || defined(_BOOT) +extern int accept(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t); +extern int accept4(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t, int); +extern int bind(int, const struct sockaddr *, socklen_t); +extern int connect(int, const struct sockaddr *, socklen_t); +extern int getpeername(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t); +extern int getsockname(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t); +extern int getsockopt(int, int, int, void *_RESTRICT_KYWD, Psocklen_t); +extern int listen(int, int); +extern int socketpair(int, int, int, int *); +extern ssize_t recv(int, void *, size_t, int); +extern ssize_t recvfrom(int, void *_RESTRICT_KYWD, size_t, int, + struct sockaddr *_RESTRICT_KYWD, Psocklen_t); +extern ssize_t recvmsg(int, struct msghdr *, int); +extern ssize_t send(int, const void *, size_t, int); +extern ssize_t sendmsg(int, const struct msghdr *, int); +extern ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, + socklen_t); +extern int setsockopt(int, int, int, const void *, socklen_t); +extern int shutdown(int, int); +extern int socket(int, int, int); + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +extern int sockatmark(int); +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ +#endif /* !defined(_KERNEL) || defined(_BOOT) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SOCKET_H */ diff --git a/illumos-x86_64/usr/include/sys/socket_impl.h b/illumos-x86_64/usr/include/sys/socket_impl.h new file mode 100644 index 00000000..0eacd8a9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/socket_impl.h @@ -0,0 +1,131 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_SOCKET_IMPL_H +#define _SYS_SOCKET_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _SA_FAMILY_T +#define _SA_FAMILY_T +typedef uint16_t sa_family_t; +#endif + +/* + * Structure used by kernel to store most + * addresses. + */ +struct sockaddr { + sa_family_t sa_family; /* address family */ + char sa_data[14]; /* up to 14 bytes of direct address */ +}; + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include +#include +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +/* + * sockaddr_storage: + * Common superset of at least AF_INET, AF_INET6 and AF_LINK sockaddr + * structures. Has sufficient size and alignment for those sockaddrs. + */ + +/* + * Desired maximum size, alignment size and related types. + */ +#define _SS_MAXSIZE 256 /* Implementation specific max size */ + +/* + * To represent desired sockaddr max alignment for platform, a + * type is chosen which may depend on implementation platform architecture. + * Type chosen based on alignment size restrictions from . + * We desire to force up to (but no more than) 64-bit (8 byte) alignment, + * on platforms where it is possible to do so. (e.g not possible on ia32). + * For all currently supported platforms by our implementation + * in , (i.e. sparc, sparcv9, ia32, ia64) + * type "double" is suitable for that intent. + * + * Note: Type "double" is chosen over the more obvious integer type int64_t. + * int64_t is not a valid type for strict ANSI/ISO C compilation on ILP32. + */ +typedef double sockaddr_maxalign_t; + +#define _SS_ALIGNSIZE (sizeof (sockaddr_maxalign_t)) + +/* + * Definitions used for sockaddr_storage structure paddings design. + */ +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t)) +#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t)+ \ + _SS_PAD1SIZE + _SS_ALIGNSIZE)) + +struct sockaddr_storage { + sa_family_t ss_family; /* Address family */ + /* Following fields are implementation specific */ + char _ss_pad1[_SS_PAD1SIZE]; + sockaddr_maxalign_t _ss_align; + char _ss_pad2[_SS_PAD2SIZE]; +}; +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +/* + * To be compatible with the Linux interfaces used, this structure is + * placed in socket_impl.h so that an include for will + * pickup this structure. This structure is for use with PF_PACKET + * sockets. + */ +struct sockaddr_ll { + uint16_t sll_family; + uint16_t sll_protocol; + int32_t sll_ifindex; + uint16_t sll_hatype; + uint8_t sll_pkttype; + uint8_t sll_halen; + uint8_t sll_addr[8]; +}; + +#define LINUX_SLL_HOST 0 +#define LINUX_SLL_BROADCAST 1 +#define LINUX_SLL_MULTICAST 2 +#define LINUX_SLL_OTHERHOST 3 +#define LINUX_SLL_OUTGOING 4 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SOCKET_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/socket_proto.h b/illumos-x86_64/usr/include/sys/socket_proto.h new file mode 100644 index 00000000..825d0501 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/socket_proto.h @@ -0,0 +1,234 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_SOCKET_PROTO_H_ +#define _SYS_SOCKET_PROTO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* + * Generation count + */ +typedef uint64_t sock_connid_t; + +#define SOCK_CONNID_INIT(id) { \ + (id) = 0; \ +} +#define SOCK_CONNID_BUMP(id) (++(id)) +#define SOCK_CONNID_LT(id1, id2) ((int64_t)((id1)-(id2)) < 0) + +/* Socket protocol properties */ +struct sock_proto_props { + uint_t sopp_flags; /* options to set */ + ushort_t sopp_wroff; /* write offset */ + ssize_t sopp_txhiwat; /* tx hi water mark */ + ssize_t sopp_txlowat; /* tx lo water mark */ + ssize_t sopp_rxhiwat; /* recv high water mark */ + ssize_t sopp_rxlowat; /* recv low water mark */ + ssize_t sopp_maxblk; /* maximum message block size */ + ssize_t sopp_maxpsz; /* maximum packet size */ + ssize_t sopp_minpsz; /* minimum packet size */ + ushort_t sopp_tail; /* space available at the end */ + uint_t sopp_zcopyflag; /* zero copy flag */ + boolean_t sopp_oobinline; /* OOB inline */ + uint_t sopp_rcvtimer; /* delayed recv notification (time) */ + uint32_t sopp_rcvthresh; /* delayed recv notification (bytes) */ + socklen_t sopp_maxaddrlen; /* maximum size of protocol address */ + boolean_t sopp_loopback; /* loopback connection */ +}; + +/* flags to determine which socket options are set */ +#define SOCKOPT_WROFF 0x0001 /* set write offset */ +#define SOCKOPT_RCVHIWAT 0x0002 /* set read side high water */ +#define SOCKOPT_RCVLOWAT 0x0004 /* set read side high water */ +#define SOCKOPT_MAXBLK 0x0008 /* set maximum message block size */ +#define SOCKOPT_TAIL 0x0010 /* set the extra allocated space */ +#define SOCKOPT_ZCOPY 0x0020 /* set/unset zero copy for sendfile */ +#define SOCKOPT_MAXPSZ 0x0040 /* set maxpsz for protocols */ +#define SOCKOPT_OOBINLINE 0x0080 /* set oob inline processing */ +#define SOCKOPT_RCVTIMER 0x0100 +#define SOCKOPT_RCVTHRESH 0x0200 +#define SOCKOPT_MAXADDRLEN 0x0400 /* set max address length */ +#define SOCKOPT_MINPSZ 0x0800 /* set minpsz for protocols */ +#define SOCKOPT_LOOPBACK 0x1000 /* set loopback */ + +#define IS_SO_OOB_INLINE(so) ((so)->so_proto_props.sopp_oobinline) + +#ifdef _KERNEL + +struct T_capability_ack; + +typedef struct sock_upcalls_s sock_upcalls_t; +typedef struct sock_downcalls_s sock_downcalls_t; + +/* + * Upcall and downcall handle for sockfs and transport layer. + */ +typedef struct __sock_upper_handle *sock_upper_handle_t; +typedef struct __sock_lower_handle *sock_lower_handle_t; + +struct sock_downcalls_s { + void (*sd_activate)(sock_lower_handle_t, sock_upper_handle_t, + sock_upcalls_t *, int, cred_t *); + int (*sd_accept)(sock_lower_handle_t, sock_lower_handle_t, + sock_upper_handle_t, cred_t *); + int (*sd_bind)(sock_lower_handle_t, struct sockaddr *, socklen_t, + cred_t *); + int (*sd_listen)(sock_lower_handle_t, int, cred_t *); + int (*sd_connect)(sock_lower_handle_t, const struct sockaddr *, + socklen_t, sock_connid_t *, cred_t *); + int (*sd_getpeername)(sock_lower_handle_t, struct sockaddr *, + socklen_t *, cred_t *); + int (*sd_getsockname)(sock_lower_handle_t, struct sockaddr *, + socklen_t *, cred_t *); + int (*sd_getsockopt)(sock_lower_handle_t, int, int, void *, + socklen_t *, cred_t *); + int (*sd_setsockopt)(sock_lower_handle_t, int, int, const void *, + socklen_t, cred_t *); + int (*sd_send)(sock_lower_handle_t, mblk_t *, struct nmsghdr *, + cred_t *); + int (*sd_send_uio)(sock_lower_handle_t, uio_t *, struct nmsghdr *, + cred_t *); + int (*sd_recv_uio)(sock_lower_handle_t, uio_t *, struct nmsghdr *, + cred_t *); + short (*sd_poll)(sock_lower_handle_t, short, int, cred_t *); + int (*sd_shutdown)(sock_lower_handle_t, int, cred_t *); + void (*sd_clr_flowctrl)(sock_lower_handle_t); + int (*sd_ioctl)(sock_lower_handle_t, int, intptr_t, int, + int32_t *, cred_t *); + int (*sd_close)(sock_lower_handle_t, int, cred_t *); +}; + +typedef sock_lower_handle_t (*so_proto_create_func_t)(int, int, int, + sock_downcalls_t **, uint_t *, int *, int, cred_t *); + +typedef struct sock_quiesce_arg { + mblk_t *soqa_exdata_mp; + mblk_t *soqa_urgmark_mp; +} sock_quiesce_arg_t; +typedef mblk_t *(*so_proto_quiesced_cb_t)(sock_upper_handle_t, + sock_quiesce_arg_t *, struct T_capability_ack *, struct sockaddr *, + socklen_t, struct sockaddr *, socklen_t, short); +typedef int (*so_proto_fallback_func_t)(sock_lower_handle_t, queue_t *, + boolean_t, so_proto_quiesced_cb_t, sock_quiesce_arg_t *); + +/* + * These functions return EOPNOTSUPP and are intended for the sockfs + * developer that doesn't wish to supply stubs for every function themselves. + */ +extern int sock_accept_notsupp(sock_lower_handle_t, sock_lower_handle_t, + sock_upper_handle_t, cred_t *); +extern int sock_bind_notsupp(sock_lower_handle_t, struct sockaddr *, + socklen_t, cred_t *); +extern int sock_listen_notsupp(sock_lower_handle_t, int, cred_t *); +extern int sock_connect_notsupp(sock_lower_handle_t, + const struct sockaddr *, socklen_t, sock_connid_t *, cred_t *); +extern int sock_getpeername_notsupp(sock_lower_handle_t, struct sockaddr *, + socklen_t *, cred_t *); +extern int sock_getsockname_notsupp(sock_lower_handle_t, struct sockaddr *, + socklen_t *, cred_t *); +extern int sock_getsockopt_notsupp(sock_lower_handle_t, int, int, void *, + socklen_t *, cred_t *); +extern int sock_setsockopt_notsupp(sock_lower_handle_t, int, int, + const void *, socklen_t, cred_t *); +extern int sock_send_notsupp(sock_lower_handle_t, mblk_t *, + struct nmsghdr *, cred_t *); +extern int sock_send_uio_notsupp(sock_lower_handle_t, uio_t *, + struct nmsghdr *, cred_t *); +extern int sock_recv_uio_notsupp(sock_lower_handle_t, uio_t *, + struct nmsghdr *, cred_t *); +extern short sock_poll_notsupp(sock_lower_handle_t, short, int, cred_t *); +extern int sock_shutdown_notsupp(sock_lower_handle_t, int, cred_t *); +extern void sock_clr_flowctrl_notsupp(sock_lower_handle_t); +extern int sock_ioctl_notsupp(sock_lower_handle_t, int, intptr_t, int, + int32_t *, cred_t *); +extern int sock_close_notsupp(sock_lower_handle_t, int, cred_t *); + +/* + * Upcalls and related information + */ + +/* + * su_opctl() actions + */ +typedef enum sock_opctl_action { + SOCK_OPCTL_ENAB_ACCEPT = 0, + SOCK_OPCTL_SHUT_SEND, + SOCK_OPCTL_SHUT_RECV +} sock_opctl_action_t; + +struct sock_upcalls_s { + sock_upper_handle_t (*su_newconn)(sock_upper_handle_t, + sock_lower_handle_t, sock_downcalls_t *, cred_t *, pid_t, + sock_upcalls_t **); + void (*su_connected)(sock_upper_handle_t, sock_connid_t, cred_t *, + pid_t); + int (*su_disconnected)(sock_upper_handle_t, sock_connid_t, int); + void (*su_opctl)(sock_upper_handle_t, sock_opctl_action_t, + uintptr_t); + ssize_t (*su_recv)(sock_upper_handle_t, mblk_t *, size_t, int, + int *, boolean_t *); + void (*su_set_proto_props)(sock_upper_handle_t, + struct sock_proto_props *); + void (*su_txq_full)(sock_upper_handle_t, boolean_t); + void (*su_signal_oob)(sock_upper_handle_t, ssize_t); + void (*su_zcopy_notify)(sock_upper_handle_t); + void (*su_set_error)(sock_upper_handle_t, int); + /* + * NOTE: This function frees upper handle items. Caller cannot + * rely on them after this upcall. + */ + void (*su_closed)(sock_upper_handle_t); + /* + * NOTE: This function MUST be implemented without using lower-level + * downcalls or accesses. This allows callers to ensure su_closed() + * upcalls can happen indepdently or concurrently. + */ + vnode_t *(*su_get_vnode)(sock_upper_handle_t); +}; + +#define SOCK_UC_VERSION sizeof (sock_upcalls_t) +#define SOCK_DC_VERSION sizeof (sock_downcalls_t) + +#define SOCKET_RECVHIWATER (48 * 1024) +#define SOCKET_RECVLOWATER 1024 + +#define SOCKET_NO_RCVTIMER 0 +#define SOCKET_TIMER_INTERVAL 50 + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SOCKET_PROTO_H_ */ diff --git a/illumos-x86_64/usr/include/sys/socketvar.h b/illumos-x86_64/usr/include/sys/socketvar.h new file mode 100644 index 00000000..20d5f2d4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/socketvar.h @@ -0,0 +1,1123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015 Joyent, Inc. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ +/* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _SYS_SOCKETVAR_H +#define _SYS_SOCKETVAR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Internal representation of the address used to represent addresses + * in the loopback transport for AF_UNIX. While the sockaddr_un is used + * as the sockfs layer address for AF_UNIX the pathnames contained in + * these addresses are not unique (due to relative pathnames) thus can not + * be used in the transport. + * + * The transport level address consists of a magic number (used to separate the + * name space for specific and implicit binds). For a specific bind + * this is followed by a "vnode *" which ensures that all specific binds + * have a unique transport level address. For implicit binds the latter + * part of the address is a byte string (of the same length as a pointer) + * that is assigned by the loopback transport. + * + * The uniqueness assumes that the loopback transport has a separate namespace + * for sockets in order to avoid name conflicts with e.g. TLI use of the + * same transport. + */ +struct so_ux_addr { + void *soua_vp; /* vnode pointer or assigned by tl */ + uint_t soua_magic; /* See below */ +}; + +#define SOU_MAGIC_EXPLICIT 0x75787670 /* "uxvp" */ +#define SOU_MAGIC_IMPLICIT 0x616e6f6e /* "anon" */ + +struct sockaddr_ux { + sa_family_t sou_family; /* AF_UNIX */ + struct so_ux_addr sou_addr; +}; + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#include + +typedef struct sonodeops sonodeops_t; +typedef struct sonode sonode_t; +typedef boolean_t (*so_krecv_f)(sonode_t *, mblk_t *, size_t, int, void *); + +struct sodirect_s; + +/* + * The sonode represents a socket. A sonode never exist in the file system + * name space and can not be opened using open() - only the socket, socketpair + * and accept calls create sonodes. + * + * The locking of sockfs uses the so_lock mutex plus the SOLOCKED and + * SOREADLOCKED flags in so_flag. The mutex protects all the state in the + * sonode. It is expected that the underlying transport protocol serializes + * socket operations, so sockfs will not normally not single-thread + * operations. However, certain sockets, including TPI based ones, can only + * handle one control operation at a time. The SOLOCKED flag is used to + * single-thread operations from sockfs users to prevent e.g. multiple bind() + * calls to operate on the same sonode concurrently. The SOREADLOCKED flag is + * used to ensure that only one thread sleeps in kstrgetmsg for a given + * sonode. This is needed to ensure atomic operation for things like + * MSG_WAITALL. + * + * The so_fallback_rwlock is used to ensure that for sockets that can + * fall back to TPI, the fallback is not initiated until all pending + * operations have completed. + * + * Note that so_lock is sometimes held across calls that might go to sleep + * (kmem_alloc and soallocproto*). This implies that no other lock in + * the system should be held when calling into sockfs; from the system call + * side or from strrput (in case of TPI based sockets). If locks are held + * while calling into sockfs the system might hang when running low on memory. + */ +struct sonode { + struct vnode *so_vnode; /* vnode associated with this sonode */ + + sonodeops_t *so_ops; /* operations vector for this sonode */ + void *so_priv; /* sonode private data */ + + krwlock_t so_fallback_rwlock; + kmutex_t so_lock; /* protects sonode fields */ + + kcondvar_t so_state_cv; /* synchronize state changes */ + kcondvar_t so_single_cv; /* wait due to SOLOCKED */ + kcondvar_t so_read_cv; /* wait due to SOREADLOCKED */ + + /* These fields are protected by so_lock */ + + uint_t so_state; /* internal state flags SS_*, below */ + uint_t so_mode; /* characteristics on socket. SM_* */ + ushort_t so_flag; /* flags, see below */ + int so_count; /* count of opened references */ + + sock_connid_t so_proto_connid; /* protocol generation number */ + + ushort_t so_error; /* error affecting connection */ + + struct sockparams *so_sockparams; /* vnode or socket module */ + /* Needed to recreate the same socket for accept */ + short so_family; + short so_type; + short so_protocol; + short so_version; /* From so_socket call */ + + /* Accept queue */ + kmutex_t so_acceptq_lock; /* protects accept queue */ + list_t so_acceptq_list; /* pending conns */ + list_t so_acceptq_defer; /* deferred conns */ + list_node_t so_acceptq_node; /* acceptq list node */ + unsigned int so_acceptq_len; /* # of conns (both lists) */ + unsigned int so_backlog; /* Listen backlog */ + kcondvar_t so_acceptq_cv; /* wait for new conn. */ + struct sonode *so_listener; /* parent socket */ + + /* Options */ + short so_options; /* From socket call, see socket.h */ + struct linger so_linger; /* SO_LINGER value */ +#define so_sndbuf so_proto_props.sopp_txhiwat /* SO_SNDBUF value */ +#define so_sndlowat so_proto_props.sopp_txlowat /* tx low water mark */ +#define so_rcvbuf so_proto_props.sopp_rxhiwat /* SO_RCVBUF value */ +#define so_rcvlowat so_proto_props.sopp_rxlowat /* rx low water mark */ +#define so_max_addr_len so_proto_props.sopp_maxaddrlen +#define so_minpsz so_proto_props.sopp_minpsz +#define so_maxpsz so_proto_props.sopp_maxpsz + + int so_xpg_rcvbuf; /* SO_RCVBUF value for XPG4 socket */ + clock_t so_sndtimeo; /* send timeout */ + clock_t so_rcvtimeo; /* recv timeout */ + + mblk_t *so_oobmsg; /* outofline oob data */ + ssize_t so_oobmark; /* offset of the oob data */ + + pid_t so_pgrp; /* pgrp for signals */ + + cred_t *so_peercred; /* connected socket peer cred */ + pid_t so_cpid; /* connected socket peer cached pid */ + zoneid_t so_zoneid; /* opener's zoneid */ + + struct pollhead so_poll_list; /* common pollhead */ + short so_pollev; /* events that should be generated */ + + /* Receive */ + unsigned int so_rcv_queued; /* # bytes on both rcv lists */ + mblk_t *so_rcv_q_head; /* processing/copyout rcv queue */ + mblk_t *so_rcv_q_last_head; + mblk_t *so_rcv_head; /* protocol prequeue */ + mblk_t *so_rcv_last_head; /* last mblk in b_next chain */ + kcondvar_t so_rcv_cv; /* wait for data */ + uint_t so_rcv_wanted; /* # of bytes wanted by app */ + timeout_id_t so_rcv_timer_tid; + +#define so_rcv_thresh so_proto_props.sopp_rcvthresh +#define so_rcv_timer_interval so_proto_props.sopp_rcvtimer + + kcondvar_t so_snd_cv; /* wait for snd buffers */ + uint32_t + so_snd_qfull: 1, /* Transmit full */ + so_rcv_wakeup: 1, + so_snd_wakeup: 1, + so_not_str: 1, /* B_TRUE if not streams based socket */ + so_pad_to_bit_31: 28; + + /* Communication channel with protocol */ + sock_lower_handle_t so_proto_handle; + sock_downcalls_t *so_downcalls; + + struct sock_proto_props so_proto_props; /* protocol settings */ + boolean_t so_flowctrld; /* Flow controlled */ + uint_t so_copyflag; /* Copy related flag */ + kcondvar_t so_copy_cv; /* Copy cond variable */ + + /* kernel sockets */ + ksocket_callbacks_t so_ksock_callbacks; + void *so_ksock_cb_arg; /* callback argument */ + kcondvar_t so_closing_cv; + + /* != NULL for sodirect enabled socket */ + struct sodirect_s *so_direct; + + /* socket filters */ + uint_t so_filter_active; /* # of active fil */ + uint_t so_filter_tx; /* pending tx ops */ + struct sof_instance *so_filter_top; /* top of stack */ + struct sof_instance *so_filter_bottom; /* bottom of stack */ + clock_t so_filter_defertime; /* time when deferred */ + + /* Kernel direct receive callbacks */ + so_krecv_f so_krecv_cb; /* recv callback */ + void *so_krecv_arg; /* recv cb arg */ +}; + +#define SO_HAVE_DATA(so) \ + /* \ + * For the (tid == 0) case we must check so_rcv_{q_,}head \ + * rather than (so_rcv_queued > 0), since the latter does not \ + * take into account mblks with only control/name information. \ + */ \ + ((so)->so_rcv_timer_tid == 0 && ((so)->so_rcv_head != NULL || \ + (so)->so_rcv_q_head != NULL)) || \ + ((so)->so_state & SS_CANTRCVMORE) + +/* + * Events handled by the protocol (in case sd_poll is set) + */ +#define SO_PROTO_POLLEV (POLLIN|POLLRDNORM|POLLRDBAND) + + +#endif /* _KERNEL || _KMEMUSER */ + +/* flags */ +#define SOMOD 0x0001 /* update socket modification time */ +#define SOACC 0x0002 /* update socket access time */ + +#define SOLOCKED 0x0010 /* use to serialize open/closes */ +#define SOREADLOCKED 0x0020 /* serialize kstrgetmsg calls */ +#define SOCLONE 0x0040 /* child of clone driver */ +#define SOASYNC_UNBIND 0x0080 /* wait for ACK of async unbind */ + +#define SOCK_IS_NONSTR(so) ((so)->so_not_str) + +/* + * Socket state bits. + */ +#define SS_ISCONNECTED 0x00000001 /* socket connected to a peer */ +#define SS_ISCONNECTING 0x00000002 /* in process, connecting to peer */ +#define SS_ISDISCONNECTING 0x00000004 /* in process of disconnecting */ +#define SS_CANTSENDMORE 0x00000008 /* can't send more data to peer */ + +#define SS_CANTRCVMORE 0x00000010 /* can't receive more data */ +#define SS_ISBOUND 0x00000020 /* socket is bound */ +#define SS_NDELAY 0x00000040 /* FNDELAY non-blocking */ +#define SS_NONBLOCK 0x00000080 /* O_NONBLOCK non-blocking */ + +#define SS_ASYNC 0x00000100 /* async i/o notify */ +#define SS_ACCEPTCONN 0x00000200 /* listen done */ +/* unused 0x00000400 */ /* was SS_HASCONNIND */ +#define SS_SAVEDEOR 0x00000800 /* Saved MSG_EOR rcv side state */ + +#define SS_RCVATMARK 0x00001000 /* at mark on input */ +#define SS_OOBPEND 0x00002000 /* OOB pending or present - poll */ +#define SS_HAVEOOBDATA 0x00004000 /* OOB data present */ +#define SS_HADOOBDATA 0x00008000 /* OOB data consumed */ + +#define SS_CLOSING 0x00010000 /* in process of closing */ +#define SS_FIL_DEFER 0x00020000 /* filter deferred notification */ +#define SS_FILOP_OK 0x00040000 /* socket can attach filters */ +#define SS_FIL_RCV_FLOWCTRL 0x00080000 /* filter asserted rcv flow ctrl */ + +#define SS_FIL_SND_FLOWCTRL 0x00100000 /* filter asserted snd flow ctrl */ +#define SS_FIL_STOP 0x00200000 /* no more filter actions */ +#define SS_SODIRECT 0x00400000 /* transport supports sodirect */ +#define SS_FILOP_UNSF 0x00800000 /* block attaching unsafe filters */ + +#define SS_SENTLASTREADSIG 0x01000000 /* last rx signal has been sent */ +#define SS_SENTLASTWRITESIG 0x02000000 /* last tx signal has been sent */ + +#define SS_FALLBACK_DRAIN 0x20000000 /* data was/is being drained */ +#define SS_FALLBACK_PENDING 0x40000000 /* fallback is pending */ +#define SS_FALLBACK_COMP 0x80000000 /* fallback has completed */ + + +/* Set of states when the socket can't be rebound */ +#define SS_CANTREBIND (SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING|\ + SS_CANTSENDMORE|SS_CANTRCVMORE|SS_ACCEPTCONN) + +/* + * Sockets that can fall back to TPI must ensure that fall back is not + * initiated while a thread is using a socket. Otherwise this disables all + * future filter attachment. + */ +#define SO_BLOCK_FALLBACK(so, fn) \ + ASSERT(MUTEX_NOT_HELD(&(so)->so_lock)); \ + rw_enter(&(so)->so_fallback_rwlock, RW_READER); \ + if ((so)->so_state & (SS_FALLBACK_COMP|SS_FILOP_OK)) { \ + if ((so)->so_state & SS_FALLBACK_COMP) { \ + rw_exit(&(so)->so_fallback_rwlock); \ + return (fn); \ + } else { \ + mutex_enter(&(so)->so_lock); \ + (so)->so_state &= ~SS_FILOP_OK; \ + mutex_exit(&(so)->so_lock); \ + } \ + } + +/* + * Sockets that can fall back to TPI must ensure that fall back is not + * initiated while a thread is using a socket. Otherwise this disables all + * future unsafe filter attachment. Safe filters can still attach after + * we execute the function in which this macro is used. + */ +#define SO_BLOCK_FALLBACK_SAFE(so, fn) \ + ASSERT(MUTEX_NOT_HELD(&(so)->so_lock)); \ + rw_enter(&(so)->so_fallback_rwlock, RW_READER); \ + if ((so)->so_state & SS_FALLBACK_COMP) { \ + rw_exit(&(so)->so_fallback_rwlock); \ + return (fn); \ + } else if (((so)->so_state & SS_FILOP_UNSF) == 0) { \ + mutex_enter(&(so)->so_lock); \ + (so)->so_state |= SS_FILOP_UNSF; \ + mutex_exit(&(so)->so_lock); \ + } + +#define SO_UNBLOCK_FALLBACK(so) { \ + rw_exit(&(so)->so_fallback_rwlock); \ +} + +#define SO_SND_FLOWCTRLD(so) \ + ((so)->so_snd_qfull || (so)->so_state & SS_FIL_SND_FLOWCTRL) + +/* Poll events */ +#define SO_POLLEV_IN 0x1 /* POLLIN wakeup needed */ +#define SO_POLLEV_ALWAYS 0x2 /* wakeups */ + +/* + * Characteristics of sockets. Not changed after the socket is created. + */ +#define SM_PRIV 0x001 /* privileged for broadcast, raw... */ +#define SM_ATOMIC 0x002 /* atomic data transmission */ +#define SM_ADDR 0x004 /* addresses given with messages */ +#define SM_CONNREQUIRED 0x008 /* connection required by protocol */ + +#define SM_FDPASSING 0x010 /* passes file descriptors */ +#define SM_EXDATA 0x020 /* Can handle T_EXDATA_REQ */ +#define SM_OPTDATA 0x040 /* Can handle T_OPTDATA_REQ */ +#define SM_BYTESTREAM 0x080 /* Byte stream - can use M_DATA */ + +#define SM_ACCEPTOR_ID 0x100 /* so_acceptor_id is valid */ + +#define SM_KERNEL 0x200 /* kernel socket */ + +/* The modes below are only for non-streams sockets */ +#define SM_ACCEPTSUPP 0x400 /* can handle accept() */ +#define SM_SENDFILESUPP 0x800 /* Private: proto supp sendfile */ +#define SM_DEFERERR 0x1000 /* Private: defer so_error delivery */ + +/* + * Socket versions. Used by the socket library when calling _so_socket(). + */ +#define SOV_STREAM 0 /* Not a socket - just a stream */ +#define SOV_DEFAULT 1 /* Select based on so_default_version */ +#define SOV_SOCKSTREAM 2 /* Socket plus streams operations */ +#define SOV_SOCKBSD 3 /* Socket with no streams operations */ +#define SOV_XPG4_2 4 /* Xnet socket */ + +#if defined(_KERNEL) || defined(_KMEMUSER) + +/* + * sonode create and destroy functions. + */ +typedef struct sonode *(*so_create_func_t)(struct sockparams *, + int, int, int, int, int, int *, cred_t *); +typedef void (*so_destroy_func_t)(struct sonode *); + +/* STREAM device information */ +typedef struct sdev_info { + char *sd_devpath; + int sd_devpathlen; /* Is 0 if sp_devpath is a static string */ + vnode_t *sd_vnode; +} sdev_info_t; + +#define SOCKMOD_VERSION_1 1 +#define SOCKMOD_VERSION 2 + +/* name of the TPI pseudo socket module */ +#define SOTPI_SMOD_NAME "socktpi" + +typedef struct __smod_priv_s { + so_create_func_t smodp_sock_create_func; + so_destroy_func_t smodp_sock_destroy_func; + so_proto_fallback_func_t smodp_proto_fallback_func; + const char *smodp_fallback_devpath_v4; + const char *smodp_fallback_devpath_v6; +} __smod_priv_t; + +/* + * Socket module register information + */ +typedef struct smod_reg_s { + int smod_version; + char *smod_name; + size_t smod_uc_version; + size_t smod_dc_version; + so_proto_create_func_t smod_proto_create_func; + + /* __smod_priv_data must be NULL */ + __smod_priv_t *__smod_priv; +} smod_reg_t; + +/* + * Socket module information + */ +typedef struct smod_info { + int smod_version; + char *smod_name; + uint_t smod_refcnt; /* # of entries */ + size_t smod_uc_version; /* upcall version */ + size_t smod_dc_version; /* down call version */ + so_proto_create_func_t smod_proto_create_func; + so_proto_fallback_func_t smod_proto_fallback_func; + const char *smod_fallback_devpath_v4; + const char *smod_fallback_devpath_v6; + so_create_func_t smod_sock_create_func; + so_destroy_func_t smod_sock_destroy_func; + list_node_t smod_node; +} smod_info_t; + +typedef struct sockparams_stats { + kstat_named_t sps_nfallback; /* # of fallbacks to TPI */ + kstat_named_t sps_nactive; /* # of active sockets */ + kstat_named_t sps_ncreate; /* total # of created sockets */ +} sockparams_stats_t; + +/* + * sockparams + * + * Used for mapping family/type/protocol to a socket module or STREAMS device + */ +struct sockparams { + /* + * The family, type, protocol, sdev_info and smod_name are + * set when the entry is created, and they will never change + * thereafter. + */ + int sp_family; + int sp_type; + int sp_protocol; + + sdev_info_t sp_sdev_info; /* STREAM device */ + char *sp_smod_name; /* socket module name */ + + kmutex_t sp_lock; /* lock for refcnt and smod_info */ + uint64_t sp_refcnt; /* entry reference count */ + smod_info_t *sp_smod_info; /* socket module */ + + sockparams_stats_t sp_stats; + kstat_t *sp_kstat; + + /* + * The entries below are only modified while holding + * sockconf_lock as a writer. + */ + int sp_flags; /* see below */ + list_node_t sp_node; + + list_t sp_auto_filters; /* list of automatic filters */ + list_t sp_prog_filters; /* list of programmatic filters */ +}; + +struct sof_entry; + +typedef struct sp_filter { + struct sof_entry *spf_filter; + list_node_t spf_node; +} sp_filter_t; + + +/* + * sockparams flags + */ +#define SOCKPARAMS_EPHEMERAL 0x1 /* temp. entry, not on global list */ + +extern void sockparams_init(void); +extern struct sockparams *sockparams_hold_ephemeral_bydev(int, int, int, + const char *, int, int *); +extern struct sockparams *sockparams_hold_ephemeral_bymod(int, int, int, + const char *, int, int *); +extern void sockparams_ephemeral_drop_last_ref(struct sockparams *); + +extern struct sockparams *sockparams_create(int, int, int, char *, char *, int, + int, int, int *); +extern void sockparams_destroy(struct sockparams *); +extern int sockparams_add(struct sockparams *); +extern int sockparams_delete(int, int, int); +extern int sockparams_new_filter(struct sof_entry *); +extern void sockparams_filter_cleanup(struct sof_entry *); +extern int sockparams_copyout_socktable(uintptr_t); + +extern void smod_init(void); +extern void smod_add(smod_info_t *); +extern int smod_register(const smod_reg_t *); +extern int smod_unregister(const char *); +extern smod_info_t *smod_lookup_byname(const char *); + +#define SOCKPARAMS_HAS_DEVICE(sp) \ + ((sp)->sp_sdev_info.sd_devpath != NULL) + +/* Increase the smod_info_t reference count */ +#define SMOD_INC_REF(smodp) { \ + ASSERT((smodp) != NULL); \ + DTRACE_PROBE1(smodinfo__inc__ref, struct smod_info *, (smodp)); \ + atomic_inc_uint(&(smodp)->smod_refcnt); \ +} + +/* + * Decreace the socket module entry reference count. + * When no one mapping to the entry, we try to unload the module from the + * kernel. If the module can't unload, just leave the module entry with + * a zero refcnt. + */ +#define SMOD_DEC_REF(smodp, modname) { \ + ASSERT((smodp) != NULL); \ + ASSERT((smodp)->smod_refcnt != 0); \ + atomic_dec_uint(&(smodp)->smod_refcnt); \ + /* \ + * No need to atomically check the return value because the \ + * socket module framework will verify that no one is using \ + * the module before unloading. Worst thing that can happen \ + * here is multiple calls to mod_remove_by_name(), which is OK. \ + */ \ + if ((smodp)->smod_refcnt == 0) \ + (void) mod_remove_by_name(modname); \ +} + +/* Increase the reference count */ +#define SOCKPARAMS_INC_REF(sp) { \ + ASSERT((sp) != NULL); \ + DTRACE_PROBE1(sockparams__inc__ref, struct sockparams *, (sp)); \ + mutex_enter(&(sp)->sp_lock); \ + (sp)->sp_refcnt++; \ + ASSERT((sp)->sp_refcnt != 0); \ + mutex_exit(&(sp)->sp_lock); \ +} + +/* + * Decrease the reference count. + * + * If the sockparams is ephemeral, then the thread dropping the last ref + * count will destroy the entry. + */ +#define SOCKPARAMS_DEC_REF(sp) { \ + ASSERT((sp) != NULL); \ + DTRACE_PROBE1(sockparams__dec__ref, struct sockparams *, (sp)); \ + mutex_enter(&(sp)->sp_lock); \ + ASSERT((sp)->sp_refcnt > 0); \ + if ((sp)->sp_refcnt == 1) { \ + if ((sp)->sp_flags & SOCKPARAMS_EPHEMERAL) { \ + mutex_exit(&(sp)->sp_lock); \ + sockparams_ephemeral_drop_last_ref((sp)); \ + } else { \ + (sp)->sp_refcnt--; \ + if ((sp)->sp_smod_info != NULL) { \ + SMOD_DEC_REF((sp)->sp_smod_info, \ + (sp)->sp_smod_name); \ + } \ + (sp)->sp_smod_info = NULL; \ + mutex_exit(&(sp)->sp_lock); \ + } \ + } else { \ + (sp)->sp_refcnt--; \ + mutex_exit(&(sp)->sp_lock); \ + } \ +} + +/* + * Used to traverse the list of AF_UNIX sockets to construct the kstat + * for netstat(8). + */ +struct socklist { + kmutex_t sl_lock; + struct sonode *sl_list; +}; + +extern struct socklist socklist; +/* + * ss_full_waits is the number of times the reader thread + * waits when the queue is full and ss_empty_waits is the number + * of times the consumer thread waits when the queue is empty. + * No locks for these as they are just indicators of whether + * disk or network or both is slow or fast. + */ +struct sendfile_stats { + uint32_t ss_file_cached; + uint32_t ss_file_not_cached; + uint32_t ss_full_waits; + uint32_t ss_empty_waits; + uint32_t ss_file_segmap; +}; + +/* + * A single sendfile request is represented by snf_req. + */ +typedef struct snf_req { + struct snf_req *sr_next; + mblk_t *sr_mp_head; + mblk_t *sr_mp_tail; + kmutex_t sr_lock; + kcondvar_t sr_cv; + uint_t sr_qlen; + int sr_hiwat; + int sr_lowat; + int sr_operation; + struct vnode *sr_vp; + file_t *sr_fp; + ssize_t sr_maxpsz; + u_offset_t sr_file_off; + u_offset_t sr_file_size; +#define SR_READ_DONE 0x80000000 + int sr_read_error; + int sr_write_error; +} snf_req_t; + +/* A queue of sendfile requests */ +struct sendfile_queue { + snf_req_t *snfq_req_head; + snf_req_t *snfq_req_tail; + kmutex_t snfq_lock; + kcondvar_t snfq_cv; + int snfq_svc_threads; /* # of service threads */ + int snfq_idle_cnt; /* # of idling threads */ + int snfq_max_threads; + int snfq_req_cnt; /* Number of requests */ +}; + +#define READ_OP 1 +#define SNFQ_TIMEOUT (60 * 5 * hz) /* 5 minutes */ + +/* Socket network operations switch */ +struct sonodeops { + int (*sop_init)(struct sonode *, struct sonode *, cred_t *, + int); + int (*sop_accept)(struct sonode *, int, cred_t *, struct sonode **); + int (*sop_bind)(struct sonode *, struct sockaddr *, socklen_t, + int, cred_t *); + int (*sop_listen)(struct sonode *, int, cred_t *); + int (*sop_connect)(struct sonode *, struct sockaddr *, + socklen_t, int, int, cred_t *); + int (*sop_recvmsg)(struct sonode *, struct msghdr *, + struct uio *, cred_t *); + int (*sop_sendmsg)(struct sonode *, struct msghdr *, + struct uio *, cred_t *); + int (*sop_sendmblk)(struct sonode *, struct msghdr *, int, + cred_t *, mblk_t **); + int (*sop_getpeername)(struct sonode *, struct sockaddr *, + socklen_t *, boolean_t, cred_t *); + int (*sop_getsockname)(struct sonode *, struct sockaddr *, + socklen_t *, cred_t *); + int (*sop_shutdown)(struct sonode *, int, cred_t *); + int (*sop_getsockopt)(struct sonode *, int, int, void *, + socklen_t *, int, cred_t *); + int (*sop_setsockopt)(struct sonode *, int, int, const void *, + socklen_t, cred_t *); + int (*sop_ioctl)(struct sonode *, int, intptr_t, int, + cred_t *, int32_t *); + int (*sop_poll)(struct sonode *, short, int, short *, + struct pollhead **); + int (*sop_close)(struct sonode *, int, cred_t *); +}; + +#define SOP_INIT(so, flag, cr, flags) \ + ((so)->so_ops->sop_init((so), (flag), (cr), (flags))) +#define SOP_ACCEPT(so, fflag, cr, nsop) \ + ((so)->so_ops->sop_accept((so), (fflag), (cr), (nsop))) +#define SOP_BIND(so, name, namelen, flags, cr) \ + ((so)->so_ops->sop_bind((so), (name), (namelen), (flags), (cr))) +#define SOP_LISTEN(so, backlog, cr) \ + ((so)->so_ops->sop_listen((so), (backlog), (cr))) +#define SOP_CONNECT(so, name, namelen, fflag, flags, cr) \ + ((so)->so_ops->sop_connect((so), (name), (namelen), (fflag), (flags), \ + (cr))) +#define SOP_RECVMSG(so, msg, uiop, cr) \ + ((so)->so_ops->sop_recvmsg((so), (msg), (uiop), (cr))) +#define SOP_SENDMSG(so, msg, uiop, cr) \ + ((so)->so_ops->sop_sendmsg((so), (msg), (uiop), (cr))) +#define SOP_SENDMBLK(so, msg, size, cr, mpp) \ + ((so)->so_ops->sop_sendmblk((so), (msg), (size), (cr), (mpp))) +#define SOP_GETPEERNAME(so, addr, addrlen, accept, cr) \ + ((so)->so_ops->sop_getpeername((so), (addr), (addrlen), (accept), (cr))) +#define SOP_GETSOCKNAME(so, addr, addrlen, cr) \ + ((so)->so_ops->sop_getsockname((so), (addr), (addrlen), (cr))) +#define SOP_SHUTDOWN(so, how, cr) \ + ((so)->so_ops->sop_shutdown((so), (how), (cr))) +#define SOP_GETSOCKOPT(so, level, optionname, optval, optlenp, flags, cr) \ + ((so)->so_ops->sop_getsockopt((so), (level), (optionname), \ + (optval), (optlenp), (flags), (cr))) +#define SOP_SETSOCKOPT(so, level, optionname, optval, optlen, cr) \ + ((so)->so_ops->sop_setsockopt((so), (level), (optionname), \ + (optval), (optlen), (cr))) +#define SOP_IOCTL(so, cmd, arg, mode, cr, rvalp) \ + ((so)->so_ops->sop_ioctl((so), (cmd), (arg), (mode), (cr), (rvalp))) +#define SOP_POLL(so, events, anyyet, reventsp, phpp) \ + ((so)->so_ops->sop_poll((so), (events), (anyyet), (reventsp), (phpp))) +#define SOP_CLOSE(so, flag, cr) \ + ((so)->so_ops->sop_close((so), (flag), (cr))) + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +#ifdef _KERNEL + +#define ISALIGNED_cmsghdr(addr) \ + (((uintptr_t)(addr) & (_CMSG_HDR_ALIGNMENT - 1)) == 0) + +#define ROUNDUP_cmsglen(len) \ + (((len) + _CMSG_HDR_ALIGNMENT - 1) & ~(_CMSG_HDR_ALIGNMENT - 1)) + +#define IS_NON_STREAM_SOCK(vp) \ + ((vp)->v_type == VSOCK && (vp)->v_stream == NULL) +/* + * Macros that operate on struct cmsghdr. + * Used in parsing msg_control. + * The CMSG_VALID macro does not assume that the last option buffer is padded. + */ +#define CMSG_NEXT(cmsg) \ + (struct cmsghdr *)((uintptr_t)(cmsg) + \ + ROUNDUP_cmsglen((cmsg)->cmsg_len)) +#define CMSG_CONTENT(cmsg) (&((cmsg)[1])) +#define CMSG_CONTENTLEN(cmsg) ((cmsg)->cmsg_len - sizeof (struct cmsghdr)) +#define CMSG_VALID(cmsg, start, end) \ + (ISALIGNED_cmsghdr(cmsg) && \ + ((uintptr_t)(cmsg) >= (uintptr_t)(start)) && \ + ((uintptr_t)(cmsg) < (uintptr_t)(end)) && \ + ((ssize_t)(cmsg)->cmsg_len >= sizeof (struct cmsghdr)) && \ + ((uintptr_t)(cmsg) + (cmsg)->cmsg_len <= (uintptr_t)(end))) + +/* + * Maximum size of any argument that is copied in (addresses, options, + * access rights). MUST be at least MAXPATHLEN + 3. + * BSD and SunOS 4.X limited this to MLEN or MCLBYTES. + */ +#define SO_MAXARGSIZE 8192 + +/* + * Convert between vnode and sonode + */ +#define VTOSO(vp) ((struct sonode *)((vp)->v_data)) +#define SOTOV(sp) ((sp)->so_vnode) + +/* + * Internal flags for sobind() + */ +#define _SOBIND_REBIND 0x01 /* Bind to existing local address */ +#define _SOBIND_UNSPEC 0x02 /* Bind to unspecified address */ +#define _SOBIND_LOCK_HELD 0x04 /* so_excl_lock held by caller */ +#define _SOBIND_NOXLATE 0x08 /* No addr translation for AF_UNIX */ +#define _SOBIND_XPG4_2 0x10 /* xpg4.2 semantics */ +#define _SOBIND_SOCKBSD 0x20 /* BSD semantics */ +#define _SOBIND_LISTEN 0x40 /* Make into SS_ACCEPTCONN */ +#define _SOBIND_SOCKETPAIR 0x80 /* Internal flag for so_socketpair() */ + /* to enable listen with backlog = 1 */ + +/* + * Internal flags for sounbind() + */ +#define _SOUNBIND_REBIND 0x01 /* Don't clear fields - will rebind */ + +/* + * Internal flags for soconnect() + */ +#define _SOCONNECT_NOXLATE 0x01 /* No addr translation for AF_UNIX */ +#define _SOCONNECT_DID_BIND 0x02 /* Unbind when connect fails */ +#define _SOCONNECT_XPG4_2 0x04 /* xpg4.2 semantics */ + +/* + * Internal flags for sodisconnect() + */ +#define _SODISCONNECT_LOCK_HELD 0x01 /* so_excl_lock held by caller */ + +/* + * Internal flags for sotpi_getsockopt(). + */ +#define _SOGETSOCKOPT_XPG4_2 0x01 /* xpg4.2 semantics */ + +/* + * Internal flags for soallocproto*() + */ +#define _ALLOC_NOSLEEP 0 /* Don't sleep for memory */ +#define _ALLOC_INTR 1 /* Sleep until interrupt */ +#define _ALLOC_SLEEP 2 /* Sleep forever */ + +/* + * Internal structure for handling AF_UNIX file descriptor passing + */ +struct fdbuf { + int fd_size; /* In bytes, for kmem_free */ + int fd_numfd; /* Number of elements below */ + char *fd_ebuf; /* Extra buffer to free */ + int fd_ebuflen; + frtn_t fd_frtn; + struct file *fd_fds[1]; /* One or more */ +}; +#define FDBUF_HDRSIZE (sizeof (struct fdbuf) - sizeof (struct file *)) + +/* + * Variable that can be patched to set what version of socket socket() + * will create. + */ +extern int so_default_version; + +#ifdef DEBUG +/* Turn on extra testing capabilities */ +#define SOCK_TEST +#endif /* DEBUG */ + +#ifdef DEBUG +char *pr_state(uint_t, uint_t); +char *pr_addr(int, struct sockaddr *, t_uscalar_t); +int so_verify_oobstate(struct sonode *); +#endif /* DEBUG */ + +/* + * DEBUG macros + */ +#if defined(DEBUG) +#define SOCK_DEBUG + +extern int sockdebug; +extern int sockprinterr; + +#define eprint(args) printf args +#define eprintso(so, args) \ +{ if (sockprinterr && ((so)->so_options & SO_DEBUG)) printf args; } +#define eprintline(error) \ +{ \ + if (error != EINTR && (sockprinterr || sockdebug > 0)) \ + printf("socket error %d: line %d file %s\n", \ + (error), __LINE__, __FILE__); \ +} + +#define eprintsoline(so, error) \ +{ if (sockprinterr && ((so)->so_options & SO_DEBUG)) \ + printf("socket(%p) error %d: line %d file %s\n", \ + (void *)(so), (error), __LINE__, __FILE__); \ +} +#define dprint(level, args) { if (sockdebug > (level)) printf args; } +#define dprintso(so, level, args) \ +{ if (sockdebug > (level) && ((so)->so_options & SO_DEBUG)) printf args; } + +#else /* define(DEBUG) */ + +#define eprint(args) {} +#define eprintso(so, args) {} +#define eprintline(error) {} +#define eprintsoline(so, error) {} +#define dprint(level, args) {} +#define dprintso(so, level, args) {} + +#endif /* defined(DEBUG) */ + +extern struct vnodeops *socket_vnodeops; +extern const struct fs_operation_def socket_vnodeops_template[]; + +extern vfs_t *sock_vfsp; +extern dev_t sockdev; + +extern krwlock_t sockconf_lock; + +/* + * sockfs vfsops + */ +extern int sockfs_statvfs(vfs_t *, struct statvfs64 *); + +/* + * sockfs functions + */ +extern int sock_getmsg(vnode_t *, struct strbuf *, struct strbuf *, + uchar_t *, int *, int, rval_t *); +extern int sock_putmsg(vnode_t *, struct strbuf *, struct strbuf *, + uchar_t, int, int); +extern int sogetvp(char *, vnode_t **, int); +extern int sockinit(int, char *); +extern int solookup(int, int, int, struct sockparams **); +extern void so_lock_single(struct sonode *); +extern void so_unlock_single(struct sonode *, int); +extern int so_lock_read(struct sonode *, int); +extern int so_lock_read_intr(struct sonode *, int); +extern void so_unlock_read(struct sonode *); +extern void *sogetoff(mblk_t *, t_uscalar_t, t_uscalar_t, uint_t); +extern void so_getopt_srcaddr(void *, t_uscalar_t, + void **, t_uscalar_t *); +extern int so_getopt_unix_close(void *, t_uscalar_t); +extern void fdbuf_free(struct fdbuf *); +extern mblk_t *fdbuf_allocmsg(int, struct fdbuf *); +extern int fdbuf_create(void *, int, struct fdbuf **); +extern void so_closefds(void *, t_uscalar_t, int, int); +extern void so_truncatecmsg(void *, t_uscalar_t, uint_t); + +extern int so_getfdopt(void *, t_uscalar_t, int, void **, int *); +t_uscalar_t so_optlen(void *, t_uscalar_t, int); +extern void so_cmsg2opt(void *, t_uscalar_t, int, mblk_t *); +extern t_uscalar_t + so_cmsglen(mblk_t *, void *, t_uscalar_t, int); +extern int so_opt2cmsg(mblk_t *, void *, t_uscalar_t, int, + void *, t_uscalar_t); +extern void soisconnecting(struct sonode *); +extern void soisconnected(struct sonode *); +extern void soisdisconnected(struct sonode *, int); +extern void socantsendmore(struct sonode *); +extern void socantrcvmore(struct sonode *); +extern void soseterror(struct sonode *, int); +extern int sogeterr(struct sonode *, boolean_t); +extern int sowaitconnected(struct sonode *, int, int); + +extern ssize_t soreadfile(file_t *, uchar_t *, u_offset_t, int *, size_t); +extern void *sock_kstat_init(zoneid_t); +extern void sock_kstat_fini(zoneid_t, void *); +extern struct sonode *getsonode(int, int *, file_t **); +/* + * Function wrappers (mostly around the sonode switch) for + * backward compatibility. + */ +extern int soaccept(struct sonode *, int, struct sonode **); +extern int sobind(struct sonode *, struct sockaddr *, socklen_t, + int, int); +extern int solisten(struct sonode *, int); +extern int soconnect(struct sonode *, struct sockaddr *, socklen_t, + int, int); +extern int sorecvmsg(struct sonode *, struct nmsghdr *, struct uio *); +extern int sosendmsg(struct sonode *, struct nmsghdr *, struct uio *); +extern int soshutdown(struct sonode *, int); +extern int sogetsockopt(struct sonode *, int, int, void *, socklen_t *, + int); +extern int sosetsockopt(struct sonode *, int, int, const void *, + t_uscalar_t); + +extern struct sonode *socreate(struct sockparams *, int, int, int, int, + int *); + +extern int so_copyin(const void *, void *, size_t, int); +extern int so_copyout(const void *, void *, size_t, int); + +/* + * Functions to manipulate the use of direct receive callbacks. This should not + * be used outside of sockfs and ksocket. These are generally considered a use + * once interface for a socket and will cause all outstanding data on the socket + * to be flushed. + */ +extern int so_krecv_set(sonode_t *, so_krecv_f, void *); +extern void so_krecv_unblock(sonode_t *); + +#endif + +/* + * Internal structure for obtaining sonode information from the socklist. + * These types match those corresponding in the sonode structure. + * This is not a published interface, and may change at any time. It is + * used for passing information back up to the kstat consumers. By converting + * kernel addresses to strings, we should be able to pass information from + * the kernel to userland regardless of n-bit kernel we are using. + */ + +#define ADRSTRLEN (2 * sizeof (uint64_t) + 1) + +struct sockinfo { + uint_t si_size; /* real length of this struct */ + short si_family; + short si_type; + ushort_t si_flag; + uint_t si_state; + uint_t si_ux_laddr_sou_magic; + uint_t si_ux_faddr_sou_magic; + t_scalar_t si_serv_type; + t_uscalar_t si_laddr_soa_len; + t_uscalar_t si_faddr_soa_len; + uint16_t si_laddr_family; + uint16_t si_faddr_family; + char si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */ + char si_faddr_sun_path[MAXPATHLEN + 1]; + boolean_t si_faddr_noxlate; + zoneid_t si_szoneid; + char si_son_straddr[ADRSTRLEN]; + char si_lvn_straddr[ADRSTRLEN]; + char si_fvn_straddr[ADRSTRLEN]; + uint64_t si_inode; +}; + +/* + * Subcodes for sockconf() system call + */ +#define SOCKCONFIG_ADD_SOCK 0 +#define SOCKCONFIG_REMOVE_SOCK 1 +#define SOCKCONFIG_ADD_FILTER 2 +#define SOCKCONFIG_REMOVE_FILTER 3 +#define SOCKCONFIG_GET_SOCKTABLE 4 + +/* + * Data structures for configuring socket filters. + */ + +/* + * Placement hint for automatic filters + */ +typedef enum { + SOF_HINT_NONE, + SOF_HINT_TOP, + SOF_HINT_BOTTOM, + SOF_HINT_BEFORE, + SOF_HINT_AFTER +} sof_hint_t; + +/* + * Socket tuple. Used by sockconfig_filter_props to list socket + * types of interest. + */ +typedef struct sof_socktuple { + int sofst_family; + int sofst_type; + int sofst_protocol; +} sof_socktuple_t; + +/* + * Socket filter properties used by sockconfig() system call. + */ +struct sockconfig_filter_props { + char *sfp_modname; + boolean_t sfp_autoattach; + sof_hint_t sfp_hint; + char *sfp_hintarg; + uint_t sfp_socktuple_cnt; + sof_socktuple_t *sfp_socktuple; +}; + +/* + * Data structures for the in-kernel socket configuration table. + */ +typedef struct sockconfig_socktable_entry { + int se_family; + int se_type; + int se_protocol; + int se_refcnt; + int se_flags; + char se_modname[MODMAXNAMELEN]; + char se_strdev[MAXPATHLEN]; +} sockconfig_socktable_entry_t; + +typedef struct sockconfig_socktable { + uint_t num_of_entries; + sockconfig_socktable_entry_t *st_entries; +} sockconfig_socktable_t; + +#ifdef _SYSCALL32 + +typedef struct sof_socktuple32 { + int32_t sofst_family; + int32_t sofst_type; + int32_t sofst_protocol; +} sof_socktuple32_t; + +struct sockconfig_filter_props32 { + caddr32_t sfp_modname; + boolean_t sfp_autoattach; + sof_hint_t sfp_hint; + caddr32_t sfp_hintarg; + uint32_t sfp_socktuple_cnt; + caddr32_t sfp_socktuple; +}; + +typedef struct sockconfig_socktable32 { + uint_t num_of_entries; + caddr32_t st_entries; +} sockconfig_socktable32_t; + +#endif /* _SYSCALL32 */ + +#define SOCKMOD_PATH "socketmod" /* dir where sockmods are stored */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SOCKETVAR_H */ diff --git a/illumos-x86_64/usr/include/sys/sockio.h b/illumos-x86_64/usr/include/sys/sockio.h new file mode 100644 index 00000000..5f020ac9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sockio.h @@ -0,0 +1,346 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, OmniTI Computer Consulting, Inc. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_SOCKIO_H +#define _SYS_SOCKIO_H + +/* + * General socket ioctl definitions. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* socket i/o controls */ +#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ +#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ +#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ +#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ +#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ +#define SIOCSPGRP _IOW('s', 8, int) /* set process group */ +#define SIOCGPGRP _IOR('s', 9, int) /* get process group */ + +/* + * SIOCADDRT and SIOCDELRT ioctls need to be defined using _IOWN macro to + * make them datamodel independent. + */ +#define SIOCADDRT _IOWN('r', 10, 48) /* add route */ +#define SIOCDELRT _IOWN('r', 11, 48) /* delete route */ + +/* For multicast routing. These might change in future release */ +#define SIOCGETVIFCNT _IOWR('r', 20, struct sioc_vif_req) + /* get vif pkt count */ +#define SIOCGETSGCNT _IOWR('r', 21, struct sioc_sg_req) + /* get s,g pkt count */ +#define SIOCGETLSGCNT _IOWR('r', 21, struct sioc_lsg_req) + /* get s,g pkt count */ + +/* + * Obsolete interface ioctls using struct ifreq that are supported + * for compatibility. New interface ioctls use struct lifreq. + */ +#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set if address */ +#define SIOCGIFADDR _IOWR('i', 13, struct ifreq) /* get if address */ +#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ +#define SIOCGIFDSTADDR _IOWR('i', 15, struct ifreq) /* get p-p address */ +#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set if flags */ +#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get if flags */ +#define SIOCSIFMEM _IOW('i', 18, struct ifreq) /* set interface mem */ +#define SIOCGIFMEM _IOWR('i', 19, struct ifreq) /* get interface mem */ + +/* + * Needs to be defined using _IOWRN macro to make it datamodel independent. + * Argument is a struct ifconf. + */ +#define O_SIOCGIFCONF _IOWRN('i', 20, 8) /* old get if list */ + +#define SIOCSIFMTU _IOW('i', 21, struct ifreq) /* set if mtu */ +#define SIOCGIFMTU _IOWR('i', 22, struct ifreq) /* get if mtu */ + + /* from 4.3BSD */ +#define SIOCGIFBRDADDR _IOWR('i', 23, struct ifreq) /* get broadcast addr */ +#define SIOCSIFBRDADDR _IOW('i', 24, struct ifreq) /* set broadcast addr */ +#define SIOCGIFNETMASK _IOWR('i', 25, struct ifreq) /* get subnetmask */ +#define SIOCSIFNETMASK _IOW('i', 26, struct ifreq) /* set subnetmask */ +#define SIOCGIFMETRIC _IOWR('i', 27, struct ifreq) /* get if metric */ +#define SIOCSIFMETRIC _IOW('i', 28, struct ifreq) /* set if metric */ + +#define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */ +#define SIOCGARP _IOWR('i', 31, struct arpreq) /* get arp entry */ +#define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */ +#define SIOCUPPER _IOW('i', 40, struct ifreq) /* attach upper layer */ +#define SIOCLOWER _IOW('i', 41, struct ifreq) /* attach lower layer */ +#define SIOCSETSYNC _IOW('i', 44, struct ifreq) /* set syncmode */ +#define SIOCGETSYNC _IOWR('i', 45, struct ifreq) /* get syncmode */ +#define SIOCSSDSTATS _IOWR('i', 46, struct ifreq) /* sync data stats */ +#define SIOCSSESTATS _IOWR('i', 47, struct ifreq) /* sync error stats */ + +#define SIOCSPROMISC _IOW('i', 48, int) /* request promisc */ + /* mode on/off */ +#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* set m/c address */ +#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* clr m/c address */ + +/* STREAMS based socket emulation */ + +#define SIOCGETNAME _IOR('s', 52, struct sockaddr) /* getsockname */ +#define SIOCGETPEER _IOR('s', 53, struct sockaddr) /* getpeername */ +#define IF_UNITSEL _IOW('s', 54, int) /* set unit number */ +#define SIOCXPROTO _IO('s', 55) /* empty proto table */ + +#define SIOCIFDETACH _IOW('i', 56, struct ifreq) /* detach interface */ +#define SIOCGENPSTATS _IOWR('i', 57, struct ifreq) /* get ENP stats */ +#define SIOCX25XMT _IOWR('i', 59, struct ifreq) /* start a slp proc */ + /* in x25if */ +#define SIOCX25RCV _IOWR('i', 60, struct ifreq) /* start a slp proc */ + /* in x25if */ +#define SIOCX25TBL _IOWR('i', 61, struct ifreq) /* xfer lun table to */ + /* kernel */ +#define SIOCSLGETREQ _IOWR('i', 71, struct ifreq) /* wait for switched */ + /* SLIP request */ +#define SIOCSLSTAT _IOW('i', 72, struct ifreq) /* pass SLIP info to */ + /* kernel */ +#define SIOCSIFNAME _IOW('i', 73, struct ifreq) /* set interface name */ +#define SIOCGENADDR _IOWR('i', 85, struct ifreq) /* Get ethernet addr */ +#define SIOCGIFNUM _IOR('i', 87, int) /* get number of ifs */ + +#define SIOCGIFMUXID _IOWR('i', 88, struct ifreq) /* get if muxid */ +#define SIOCSIFMUXID _IOW('i', 89, struct ifreq) /* set if muxid */ + +#define SIOCGIFINDEX _IOWR('i', 90, struct ifreq) /* get if index */ +#define SIOCSIFINDEX _IOW('i', 91, struct ifreq) /* set if index */ +#define SIOCGIFCONF _IOWRN('i', 92, 8) /* get if list */ + +/* + * New interface ioctls that use the struct lifreq. Can be used for + * both IPv4 and IPv6. + */ +#define SIOCLIFREMOVEIF _IOW('i', 110, struct lifreq) /* delete logical */ +#define SIOCLIFADDIF _IOWR('i', 111, struct lifreq) /* create logical */ + +#define SIOCSLIFADDR _IOW('i', 112, struct lifreq) /* set if address */ +#define SIOCGLIFADDR _IOWR('i', 113, struct lifreq) /* get if address */ +#define SIOCSLIFDSTADDR _IOW('i', 114, struct lifreq) /* set p-p address */ +#define SIOCGLIFDSTADDR _IOWR('i', 115, struct lifreq) /* get p-p address */ +#define SIOCSLIFFLAGS _IOW('i', 116, struct lifreq) /* set if flags */ +#define SIOCGLIFFLAGS _IOWR('i', 117, struct lifreq) /* get if flags */ + +/* + * Needs to be defined using _IOWRN macro to make it datamodel independent. + * Argument is a struct lifconf. + */ +#define O_SIOCGLIFCONF _IOWRN('i', 120, 16) /* old get if list */ +#define SIOCSLIFMTU _IOW('i', 121, struct lifreq) /* set if mtu */ +#define SIOCGLIFMTU _IOWR('i', 122, struct lifreq) /* get if mtu */ +#define SIOCGLIFBRDADDR _IOWR('i', 123, struct lifreq) /* get broadcast addr */ +#define SIOCSLIFBRDADDR _IOW('i', 124, struct lifreq) /* set broadcast addr */ +#define SIOCGLIFNETMASK _IOWR('i', 125, struct lifreq) /* get subnetmask */ +#define SIOCSLIFNETMASK _IOW('i', 126, struct lifreq) /* set subnetmask */ +#define SIOCGLIFMETRIC _IOWR('i', 127, struct lifreq) /* get if metric */ +#define SIOCSLIFMETRIC _IOW('i', 128, struct lifreq) /* set if metric */ +#define SIOCSLIFNAME _IOWR('i', 129, struct lifreq) /* set interface name */ +#define SIOCGLIFNUM _IOWR('i', 130, struct lifnum) /* get number of ifs */ +#define SIOCGLIFMUXID _IOWR('i', 131, struct lifreq) /* get if muxid */ +#define SIOCSLIFMUXID _IOW('i', 132, struct lifreq) /* set if muxid */ + +#define SIOCGLIFINDEX _IOWR('i', 133, struct lifreq) /* get if index */ +#define SIOCSLIFINDEX _IOW('i', 134, struct lifreq) /* set if index */ + +#define SIOCSLIFTOKEN _IOW('i', 135, struct lifreq) /* Set token for link */ + /* local address and */ + /* autoconf */ +#define SIOCGLIFTOKEN _IOWR('i', 136, struct lifreq) /* Get token for link */ + /* local address and */ + /* autoconf */ + +#define SIOCSLIFSUBNET _IOW('i', 137, struct lifreq) /* set subnet prefix */ +#define SIOCGLIFSUBNET _IOWR('i', 138, struct lifreq) /* get subnet prefix */ + +#define SIOCSLIFLNKINFO _IOW('i', 139, struct lifreq) /* set link info */ +#define SIOCGLIFLNKINFO _IOWR('i', 140, struct lifreq) /* get link info */ + +#define SIOCLIFDELND _IOW('i', 141, struct lifreq) /* Delete ND entry */ +#define SIOCLIFGETND _IOWR('i', 142, struct lifreq) /* Get ND entry */ +#define SIOCLIFSETND _IOW('i', 143, struct lifreq) /* Set ND entry */ + +/* + * Address querying ioctls. + */ +#define SIOCTMYADDR _IOWR('i', 144, struct sioc_addrreq) + /* My address? */ +#define SIOCTONLINK _IOWR('i', 145, struct sioc_addrreq) + /* Address on-link? */ +#define SIOCTMYSITE _IOWR('i', 146, struct sioc_addrreq) + /* In this site? */ + +/* 147-152 were SIOC*{TUNPARAM,IPSECONFIG} ioctls. Feel free to re-use. */ + +/* + * 153 can be reused (was consolidation-private SIOCLIFFAILOVER). + */ + +/* + * IP Multipathing ioctls. + */ +#define SIOCGLIFBINDING _IOWR('i', 154, struct lifreq) +#define SIOCSLIFGROUPNAME _IOW('i', 155, struct lifreq) +#define SIOCGLIFGROUPNAME _IOWR('i', 156, struct lifreq) +#define SIOCGLIFGROUPINFO _IOWR('i', 157, struct lifgroupinfo) + +/* + * Leave 158 - 160 unused; used to be SIOC*IFARP ioctls. + * However, 161 can be reused (was consolidation-private SIOCSLIFOINDEX). + */ + +/* + * IOCTLS which provide an interface to the IPv6 address selection policy. + */ +#define SIOCGIP6ADDRPOLICY _IOWRN('i', 162, 0) +#define SIOCSIP6ADDRPOLICY _IOWN('i', 163, 0) + +/* + * IOCTL for retrieving sorting info for a list of destination addrs. + * Use the _IOWRN macro to make it datamodel independent. Argument + * is a struct dstinfo. + */ +#define SIOCGDSTINFO _IOWRN('i', 164, 0) +#define SIOCGLIFCONF _IOWRN('i', 165, 16) /* get if list */ + +/* + * Extended IOCTLS for manipulating ARP cache entries. + */ +#define SIOCSXARP _IOW('i', 166, struct xarpreq) /* set an ARP entry */ +#define SIOCGXARP _IOWR('i', 167, struct xarpreq) /* get an ARP entry */ +#define SIOCDXARP _IOW('i', 168, struct xarpreq) /* delete ARP entry */ + +/* + * IOCTL private to sockfs. + */ +#define _SIOCSOCKFALLBACK _IOW('i', 169, int) + +/* + * IOCTLs for getting and setting zone associated with an interface, and + * unplumbing interfaces associated with a given zone. + */ +#define SIOCGLIFZONE _IOWR('i', 170, struct lifreq) /* get zone id */ +#define SIOCSLIFZONE _IOW('i', 171, struct lifreq) /* set zone id */ + +/* + * IOCTLS for handling SCTP options. + */ +#define SIOCSCTPSOPT _IOWN('i', 172, 16) /* Set SCTP option */ +#define SIOCSCTPGOPT _IOWRN('i', 173, 16) /* Get SCTP option */ +#define SIOCSCTPPEELOFF _IOWR('i', 174, int) /* SCTP peeloff */ + +/* + * IOCTLs for getting and setting the source address that is used for packets + * going out on the given interface. + */ +#define SIOCGLIFUSESRC _IOWR('i', 175, struct lifreq) /* get src addr */ +#define SIOCSLIFUSESRC _IOW('i', 176, struct lifreq) /* set src addr */ + +/* + * IOCTL used to get all the interfaces that use the the specified interfaces' + * source address + */ +#define SIOCGLIFSRCOF _IOWRN('i', 177, 16) /* source of */ + +/* + * IOCTLs for source specific multicast; get or set a socket's + * source filter for a particular multicast group. Argument is + * a struct group_filter. Defined in RFC 3678. + */ +#define SIOCGMSFILTER _IOWR('i', 178, int) +#define SIOCSMSFILTER _IOW('i', 179, int) +/* + * IPv4-specific versions of the above; get or set a socket's source + * filter for a particular multicast group, for PF_INET sockets only. + * Argument is a struct ip_msfilter. + */ +#define SIOCGIPMSFILTER _IOWR('i', 180, int) +#define SIOCSIPMSFILTER _IOW('i', 181, int) + +/* + * 182 can be reused (was consolidation-private SIOCSIPMPFAILBACK). + */ + +#define SIOCSENABLESDP _IOWR('i', 183, int) /* Enable SDP */ + +#define SIOCSQPTR _IOWR('i', 184, int) /* set q_ptr of stream */ + +/* + * SIOCGIFHWADDR and SIOCGLIFHWADDR (below) are available for PF_PACKET, + * PF_INET and PF_INET6 sockets. + */ +#define SIOCGIFHWADDR _IOWR('i', 185, struct ifreq) + +#define SIOCGSTAMP _IOWR('i', 186, struct timeval) /* PF_PACKET */ + +/* + * Private ioctl for Integrated Load Balancer. The ioctl length varies. + */ +#define SIOCILB _IOWR('i', 187, int) + +/* + * IOCTL's to get/set module specific or interface specific properties. + * Argument is a struct mod_ioc_prop_s. These ioctls are Consolidation Private. + */ +#define SIOCGETPROP _IOWRN('p', 188, 0) +#define SIOCSETPROP _IOW('p', 189, int) + +/* + * IOCTL used to check for the given ipif, whether DAD is in progress or + * DAD has completed. This ioctl is Consolidation Private. + */ +#define SIOCGLIFDADSTATE _IOWR('i', 190, struct lifreq) + +/* + * IOCTL used to generate an IPv6 address using the given prefix and the + * default token for the interface. + */ +#define SIOCSLIFPREFIX _IOWR('i', 191, struct lifreq) + +#define SIOCGLIFHWADDR _IOWR('i', 192, struct lifreq) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SOCKIO_H */ diff --git a/illumos-x86_64/usr/include/sys/spl.h b/illumos-x86_64/usr/include/sys/spl.h new file mode 100644 index 00000000..2f74eb31 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/spl.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1992-1993,1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SPL_H +#define _SYS_SPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * on x86 platform these are identity functions + */ +#define ipltospl(n) (n) +#define spltoipl(n) (n) + +/* + * Hardware spl levels + * it should be replace by the appropriate interrupt class info. + */ +#define SPL8 15 +#define SPL7 13 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SPL_H */ diff --git a/illumos-x86_64/usr/include/sys/squeue.h b/illumos-x86_64/usr/include/sys/squeue.h new file mode 100644 index 00000000..040963ee --- /dev/null +++ b/illumos-x86_64/usr/include/sys/squeue.h @@ -0,0 +1,95 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 Joyent, Inc. + */ + +#ifndef _SYS_SQUEUE_H +#define _SYS_SQUEUE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +struct squeue_s; +typedef struct squeue_s squeue_t; + +#define SET_SQUEUE(mp, proc, arg) { \ + ASSERT((mp)->b_prev == NULL); \ + ASSERT((mp)->b_next == NULL); \ + (mp)->b_queue = (queue_t *)(proc); \ + (mp)->b_prev = (mblk_t *)(arg); \ +} + +#define SQ_FILL 0x0001 +#define SQ_NODRAIN 0x0002 +#define SQ_PROCESS 0x0004 + +#define SQUEUE_ENTER(sqp, head, tail, cnt, ira, flag, tag) { \ + sqp->sq_enter(sqp, head, tail, cnt, ira, flag, tag); \ +} + +#define SQUEUE_ENTER_ONE(sqp, mp, proc, arg, ira, flag, tag) { \ + ASSERT(mp->b_next == NULL); \ + ASSERT(mp->b_prev == NULL); \ + SET_SQUEUE(mp, proc, arg); \ + SQUEUE_ENTER(sqp, mp, mp, 1, ira, flag, tag); \ +} + +/* + * May be called only by a thread executing in the squeue. The thread must + * not continue to execute any code needing squeue protection after calling + * this macro. Please see the comments in squeue.c for more details. + */ +#define SQUEUE_SWITCH(connp, new_sqp) \ + (connp)->conn_sqp = new_sqp; + +/* + * Facility-special private data in squeues. + */ +typedef enum { + SQPRIVATE_TCP, + SQPRIVATE_MAX +} sqprivate_t; + +struct ip_recv_attr_s; +extern void squeue_init(void); +extern squeue_t *squeue_create(pri_t); +extern void squeue_bind(squeue_t *, processorid_t); +extern void squeue_unbind(squeue_t *); +extern void squeue_enter(squeue_t *, mblk_t *, mblk_t *, + uint32_t, struct ip_recv_attr_s *, int, uint8_t); +extern uintptr_t *squeue_getprivate(squeue_t *, sqprivate_t); + +struct conn_s; +extern int squeue_synch_enter(struct conn_s *, mblk_t *); +extern void squeue_synch_exit(struct conn_s *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SQUEUE_H */ diff --git a/illumos-x86_64/usr/include/sys/squeue_impl.h b/illumos-x86_64/usr/include/sys/squeue_impl.h new file mode 100644 index 00000000..8eb6a30a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/squeue_impl.h @@ -0,0 +1,175 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Joyent, Inc. + */ + +#ifndef _SYS_SQUEUE_IMPL_H +#define _SYS_SQUEUE_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#define SQ_NAMELEN 31 + +/* + * SQUEUE_DEBUG: If defined as 1, special code is compiled in which records + * additional information aiding debugging is recorded in squeue. + * + * SQUEUE_PROFILE: If defined as 1, special code is compiled in which collects + * various squeue statistics and exports them as kstats. + * + * Ideally we would like both SQUEUE_DEBUG and SQUEUE_PROFILE to be always set, + * but it affects performance, so they are enabled on DEBUG kernels and disabled + * on non-DEBUG by default. + */ +#ifdef DEBUG +#define SQUEUE_DEBUG 1 +#define SQUEUE_PROFILE 1 +#else +#define SQUEUE_DEBUG 0 +#define SQUEUE_PROFILE 0 +#endif + +#define SQUEUE_DEFAULT_PRIORITY MAXCLSYSPRI + +typedef struct sqstat_s { + uint_t sq_max_qlen; + uint_t sq_npackets_worker; + uint_t sq_npackets_intr; + uint_t sq_npackets_other; + uint_t sq_nqueued_intr; + uint_t sq_nqueued_other; + uint_t sq_ndrains_worker; + uint_t sq_ndrains_intr; + uint_t sq_ndrains_other; + hrtime_t sq_time_worker; + hrtime_t sq_time_intr; + hrtime_t sq_time_other; +} sqstat_t; + +typedef struct squeue_set_s { + squeue_t *sqs_head; + squeue_t *sqs_default; + processorid_t sqs_cpuid; +} squeue_set_t; + +typedef void (*sqproc_t)(void *, mblk_t *, void *, struct ip_recv_attr_s *); +typedef void (*sq_enter_proc_t)(squeue_t *, mblk_t *, mblk_t *, uint32_t, + struct ip_recv_attr_s *, int, uint8_t); +typedef void (*sq_drain_proc_t)(squeue_t *, uint_t, hrtime_t); + +extern int ip_squeue_flag; + +struct squeue_s { + sq_enter_proc_t sq_enter; /* sq_process function */ + sq_drain_proc_t sq_drain; /* sq_drain function */ + kmutex_t sq_lock; /* lock before using any member */ + uint32_t sq_state; /* state flags and message count */ + int sq_count; /* # of mblocks in squeue */ + mblk_t *sq_first; /* first mblk chain or NULL */ + mblk_t *sq_last; /* last mblk chain or NULL */ + kthread_t *sq_run; /* Current thread processing sq */ + ill_rx_ring_t *sq_rx_ring; /* The Rx ring tied to this sq */ + ill_t *sq_ill; /* The ill this squeue is tied to */ + + hrtime_t sq_awoken; /* time of worker wake req */ + kcondvar_t sq_worker_cv; /* cond var. worker thread blocks on */ + kcondvar_t sq_poll_cv; /* cond variable poll_thr waits on */ + kcondvar_t sq_synch_cv; /* cond var. synch thread waits on */ + kcondvar_t sq_ctrlop_done_cv; /* cond variable for ctrl ops */ + + processorid_t sq_bind; /* processor to bind to */ + kthread_t *sq_worker; /* kernel thread id */ + kthread_t *sq_poll_thr; /* polling thread */ + uintptr_t sq_private[SQPRIVATE_MAX]; + + squeue_t *sq_next; /* managed by squeue creator */ + squeue_set_t *sq_set; /* managed by squeue creator */ + + pri_t sq_priority; /* squeue thread priority */ + + /* Keep the debug-only fields at the end of the structure */ +#ifdef DEBUG + int sq_isintr; /* serviced by interrupt */ + mblk_t *sq_curmp; + void (*sq_curproc)(); + conn_t *sq_connp; + uchar_t sq_tag; +#endif +}; + +/* + * State flags. + * Note: The MDB IP module depends on the values of these flags. + */ +#define SQS_PROC 0x00000001 /* being processed */ +#define SQS_WORKER 0x00000002 /* worker thread */ +#define SQS_ENTER 0x00000004 /* enter thread */ +#define SQS_FAST 0x00000008 /* enter-fast thread */ + +#define SQS_USER 0x00000010 /* A non interrupt user */ +#define SQS_BOUND 0x00000020 /* Worker thread is bound */ +#define SQS_REENTER 0x00000040 /* Re entered thread */ + +#define SQS_POLL_CAPAB 0x00000100 /* Squeue can control interrupts */ +#define SQS_ILL_BOUND 0x00000200 /* Squeue bound to an ill */ +#define SQS_GET_PKTS 0x00000400 /* Moving pkts from NIC in progress */ +#define SQS_DEFAULT 0x00000800 /* The default squeue for the CPU */ + +#define SQS_POLLING 0x00001000 /* Squeue in polling mode */ +#define SQS_INTR_BLANK 0x00002000 /* Interrupt blanking capability */ +#define SQS_PROC_HELD 0x00004000 /* SQS_PROC is held by the caller */ +#define SQS_FORCE_TIMER 0x00008000 /* Schedule worker due to B/W control */ + +#define SQS_POLL_CLEANUP 0x00010000 +#define SQS_POLL_CLEANUP_DONE 0x00020000 +#define SQS_POLL_QUIESCE 0x00040000 +#define SQS_POLL_QUIESCE_DONE 0x00080000 + +#define SQS_POLL_RESTART 0x00100000 +#define SQS_POLL_THR_QUIESCED 0x00200000 +#define SQS_POLL_THR_RESTART 0x00400000 +#define SQS_POLL_PROC 0x00800000 /* Poll thread processing the sq */ + +#define SQS_POLL_RESTART_DONE 0x01000000 +#define SQS_POLL_THR_QUIESCE 0x02000000 +#define SQS_PAUSE 0x04000000 /* The squeue has been paused */ + +#define SQS_WORKER_THR_CONTROL \ + (SQS_POLL_QUIESCE | SQS_POLL_RESTART | SQS_POLL_CLEANUP) + +#define SQS_POLL_THR_CONTROL \ + (SQS_POLL_THR_QUIESCE | SQS_POLL_THR_RESTART) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SQUEUE_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/sservice.h b/illumos-x86_64/usr/include/sys/sservice.h new file mode 100644 index 00000000..e311839c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sservice.h @@ -0,0 +1,588 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SSERVICE_H +#define _SSERVICE_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int(f_tt)(int, ...); /* for lint - cc -v quieting */ + +/* + * identifiers for all SS functions implemented + */ +#define SS_GetAdapter 0 +#define SS_GetPage 1 +#define SS_GetSocket 2 +#define SS_GetStatus 3 +#define SS_GetWindow 4 +#define SS_InquireAdapter 5 +#define SS_InquireSocket 6 +#define SS_InquireWindow 7 +#define SS_ResetSocket 8 +#define SS_SetPage 9 +#define SS_SetAdapter 10 +#define SS_SetSocket 11 +#define SS_SetWindow 12 +#define SS_SetIRQHandler 13 +#define SS_ClearIRQHandler 14 +#define CSGetActiveDip 98 +#define CSInitDev 99 +#define CSRegister 100 +#define CSCISInit 101 +#define CSUnregister 102 + +/* + * XXX + */ +#define CISGetAddress 103 +#define CISSetAddress 104 +#define CSCardRemoved 105 +#define CSGetCookiesAndDip 106 + +/* + * returns a la Socket Services + */ + +#define SUCCESS 0x00 +#define BAD_ADAPTER 0x01 +#define BAD_ATTRIBUTE 0x02 +#define BAD_BASE 0x03 +#define BAD_EDC 0x04 +#define BAD_IRQ 0x06 +#define BAD_OFFSET 0x07 +#define BAD_PAGE 0x08 +#define READ_FAILURE 0x09 +#define BAD_SIZE 0x0a +#define BAD_SOCKET 0x0b +#define BAD_TYPE 0x0d +#define BAD_VCC 0x0e +#define BAD_VPP 0x0f +#define BAD_WINDOW 0x11 +#define WRITE_FAILURE 0x12 +#define NO_CARD 0x14 +#define BAD_FUNCTION 0x15 +#define BAD_MODE 0x16 +#define BAD_SPEED 0x17 +#define BUSY 0x18 +#define NO_RESOURCE 0x20 + +/* events for callback */ + /* card related events */ +#define PCE_CARD_REMOVAL 0 /* card removed */ +#define PCE_CARD_INSERT 1 /* card inserted */ +#define PCE_CARD_READY 2 /* ready state changed */ +#define PCE_CARD_BATTERY_WARN 3 /* battery is getting low */ +#define PCE_CARD_BATTERY_DEAD 4 /* battery is dead */ +#define PCE_CARD_STATUS_CHANGE 5 /* card status change for I/O card */ +#define PCE_CARD_WRITE_PROTECT 6 /* card write protect status change */ +#define PCE_CARD_RESET 7 /* client requested reset complete */ +#define PCE_CARD_UNLOCK 8 /* lock has been unlocked (opt) */ +#define PCE_CLIENT_INFO 9 /* someone wants client information */ +#define PCE_EJECTION_COMPLETE 10 /* Motor has finished ejecting card */ +#define PCE_EJECTION_REQUEST 11 /* request to eject card */ +#define PCE_ERASE_COMPLETE 12 /* a Flash Erase request completed */ +#define PCE_EXCLUSIVE_COMPLETE 13 +#define PCE_EXCLUSIVE_REQUEST 14 +#define PCE_INSERTION_COMPLETE 15 +#define PCE_INSERTION_REQUEST 16 +#define PCE_REGISTRATION_COMPLETE 17 +#define PCE_RESET_COMPLETE 18 +#define PCE_RESET_PHYSICAL 19 +#define PCE_RESET_REQUEST 20 +#define PCE_TIMER_EXPIRED 21 + +/* added for SPARC CPR support */ +#define PCE_PM_RESUME 22 +#define PCE_PM_SUSPEND 23 + +/* added for dynamic nexus registration */ +#define PCE_SS_INIT_STATE 24 /* SS init state */ +#define PCE_ADD_SOCKET 25 /* add a new socket */ +#define PCE_DROP_SOCKET 26 /* drop an existing socket */ + +#define PCE_DEV_IDENT 30 /* The nexus has identified the device */ +#define PCE_INIT_DEV 31 /* asking for a device */ + +#define PCE_E2M(event) (1 << (event)) + +/* event callback uses an indirect call -- make it look like a function */ +#define CS_EVENT(event, socket, arg) (*pcmcia_cs_event) (event, socket, arg) + +/* values for "socket number" field for PCE_SS_INIT_STATE event */ +#define PCE_SS_STATE_INIT 0x0001 /* SS ready for callbacks */ +#define PCE_SS_STATE_DEINIT 0x0002 /* SS not ready for callbacks */ + +/* + * The following structure is to support CSRegister + */ +typedef struct csregister { + uint32_t cs_magic; /* magic number */ + uint32_t cs_version; /* CS version number */ + /* CS entry point */ + int (*cs_card_services)(int, ...); + /* CS event entry point */ + f_tt *cs_event; +} csregister_t; + +/* GetAdapter(get_adapter_t) */ + +typedef struct get_adapter { + unsigned state; /* adapter hardware state */ + irq_t SCRouting; /* status change IRQ routing */ +} get_adapter_t; + +/* IRQ definitions */ +#define IRQ_ENABLE 0x8000 + +/* GetPage(get_page_t) */ + +typedef struct get_page { + unsigned window; /* window number */ + unsigned page; /* page number within window */ + unsigned state; /* page state: */ + /* + * PS_ATTRIBUTE + * PS_COMMON + * PS_IO (for DoRight?) + * PS_ENABLED + * PS_WP + */ + off_t offset; /* PC card's memory offset */ +} get_page_t; + +/* + * PS flags + */ + +#define PS_ATTRIBUTE 0x01 +#define PS_ENABLED 0x02 +#define PS_WP 0x04 +#define PS_IO 0x08 /* needed? for DoRight */ + +/* GetSocket(get_socket_t) */ + +typedef struct get_socket { + unsigned socket; /* socket number */ + unsigned SCIntMask; /* status change interrupt mask */ + unsigned VccLevel; /* VCC voltage in 1/10 volt */ + unsigned Vpp1Level; /* VPP1 voltage in 1/10 volt */ + unsigned Vpp2Level; /* VPP2 voltage in 1/10 volt */ + unsigned state; /* latched status change signals */ + unsigned CtlInd; /* controls and indicators */ + irq_t IRQRouting; /* I/O IRQ routing */ + unsigned IFType; /* memory-only or memory & I/O */ +} get_socket_t; + +/* GetStatus(get_ss_status_t) */ + +typedef struct get_ss_status { + unsigned socket; /* socket number */ + unsigned CardState; /* real-time card state */ + unsigned SocketState; /* latched status change signals */ + unsigned CtlInd; /* controls and indicators */ + irq_t IRQRouting; /* I/O IRQ routing */ + unsigned IFType; /* memory-only or memory & I/O */ +} get_ss_status_t; + +/* + * Socket specific flags and capabilities + */ + +#define SBM_WP 0x01 +#define SBM_LOCKED 0x02 +#define SBM_EJECT 0x04 +#define SBM_INSERT 0x08 +#define SBM_BVD1 0x10 +#define SBM_BVD2 0x20 +#define SBM_RDYBSY 0x40 +#define SBM_CD 0x80 + + /* capabilities only */ +#define SBM_LOCK 0x10 +#define SBM_BATT 0x20 +#define SBM_BUSY 0x40 +#define SBM_XID 0x80 + +/* GetWindow(get_window_t) */ +typedef uint32_t speed_t; /* memory speed in nanoseconds */ + +typedef struct get_window { + unsigned window; /* window number */ + unsigned socket; /* socket this window is assigned to */ + unsigned size; /* size in bytes */ + unsigned state; /* current state of window hardware */ + uint_t speed; /* speed in nanoseconds */ + uint_t base; + ddi_acc_handle_t handle; /* base addr in host space */ +} get_window_t; + +/* + * window flags (state and capabilities) + */ +#define WS_IO 0x01 +#define WS_ENABLED 0x02 +#define WS_16BIT 0x04 +#define WS_PAGED 0x80 +#define WS_EISA 0x10 +#define WS_CENABLE 0x20 +#define WS_EXACT_MAPIN 0x40 /* map exactly what's asked for */ + +/* Inquire Adapter(inquire_adapter_t) */ + +typedef struct inquire_adapter { + unsigned NumSockets; /* number of sockets */ + unsigned NumWindows; /* number of windows */ + unsigned NumEDCs; /* number of EDCs */ + + unsigned AdpCaps; /* adapter power capabilities */ + irq_t ActiveHigh; /* active high status change IRQ */ + irq_t ActiveLow; /* active low status change IRQ */ + int NumPower; /* number of power entries */ + struct power_entry { + unsigned PowerLevel; /* voltage in 1/10 volt */ + unsigned ValidSignals; /* voltage is valid for: */ + /* + * VCC + * VPP1 + * VPP2 + * if none are set, this is end + * of list + */ + } *power_entry; + int NumInterrupts; /* number of interrupts supportable */ + struct intr_entry { + int pri; + int intr; + } *AvailInterrupts; /* array of intrs, one per intr */ + uint_t ResourceFlags; /* resource allocation requirements */ +} inquire_adapter_t; + +#define VCC 0x80 +#define VPP1 0x40 +#define VPP2 0x20 +#define V_MASK (VCC|VPP1|VPP2) + +#define RES_OWN_IRQ 0x0001 /* adapter owns own IRQ resources */ +#define RES_OWN_IO 0x0002 /* adapter owns own I/O resources */ +#define RES_OWN_MEM 0x0004 /* adapter owns own memory resources */ +#define RES_IRQ_NEXUS 0x0008 /* adapter/nexus must multiplex IRQs */ +#define RES_IRQ_SHAREABLE 0x0010 /* IRQ can be shared */ + +/* InquireSocket(inquire_socket_t) */ + +typedef struct inquire_socket { + unsigned socket; /* socket number */ + unsigned SCIntCaps; /* status change interrupt events */ + unsigned SCRptCaps; /* reportable status change events */ + unsigned CtlIndCaps; /* controls and indicators */ + unsigned SocketCaps; /* socket capabilities */ + irq_t ActiveHigh; /* active high status change IRQ */ + irq_t ActiveLow; /* active low status change IRQ */ +} inquire_socket_t; + +/* InquireWindow(inquire_window_t) */ + +typedef struct memwin_char { + unsigned MemWndCaps; /* memory window characteristcs */ + baseaddr_t FirstByte; /* first byte in host space */ + baseaddr_t LastByte; /* last byte in host space */ + unsigned MinSize; /* minimum window size */ + unsigned MaxSize; /* maximum window size */ + unsigned ReqGran; /* window size constraints */ + unsigned ReqBase; /* base address alignment boundry */ + unsigned ReqOffset; /* offset alignment boundry */ + unsigned Slowest; /* slowest speed in nanoseconds */ + unsigned Fastest; /* fastest speed in nanoseconds */ +} mem_win_char_t; + +typedef struct iowin_char { + unsigned IOWndCaps; /* I/O window characteristcs */ + baseaddr_t FirstByte; /* first byte in host space */ + baseaddr_t LastByte; /* last byte in host space */ + unsigned MinSize; /* minimum window size */ + unsigned MaxSize; /* maximum window size */ + unsigned ReqGran; /* window size constraints */ + unsigned AddrLines; /* number of address lines decoded */ + unsigned EISASlot; /* EISA I/O address decoding */ +} iowin_char_t; + +typedef struct inquire_window { + unsigned window; /* window number */ + unsigned WndCaps; /* window capabilities */ + socket_enum_t Sockets; /* window<->socket assignment mask */ + /* note that we always declare both forms */ + mem_win_char_t mem_win_char; + iowin_char_t iowin_char; +} inquire_window_t; + + +/* interface definitions */ +#define IF_CARDBUS 0x00 /* CardBus interface */ +#define IF_IO 0x01 /* IO + memory */ +#define IF_MEMORY 0x02 /* memory only */ +#define IF_TYPE_MASK 0x03 + +#define DREQ_MASK 0x0c +#define DREQ_NONE 0x00 +#define DREQ_SPKR 0x04 +#define DREQ_IOIS16 0x08 +#define DREQ_INPACK 0x0c + +#define DMA_CHAN_MASK 0xf0 +#define DMA_GET_CHAN(x) (((x) >> 4) & 0xF) +#define DMA_SET_CHAN(x, y) (((x) & 0xF) | ((y) & ~DMA_CHAN_MASK)) + +#define IF_CB 0x04 +#define IF_DMA 0x08 +#define IF_VSKEY 0x10 +#define IF_33VC 0x20 +#define IF_XXVCC 0x40 + + +#define PC_PAGESIZE 0x4000 /* 16K page size */ + +/* window capabilities */ + /* generic */ +#define WC_IO 0x0004 +#define WC_WAIT 0x0080 +#define WC_COMMON 0x0001 +#define WC_ATTRIBUTE 0x0002 + /* I/O and memory */ +#define WC_BASE 0x0001 +#define WC_SIZE 0x0002 +#define WC_WENABLE 0x0004 +#define WC_8BIT 0x0008 +#define WC_16BIT 0x0010 +#define WC_BALIGN 0x0020 +#define WC_POW2 0x0040 + /* memory only */ +#define WC_CALIGN 0x0080 +#define WC_PAVAIL 0x0100 +#define WC_PSHARED 0x0200 +#define WC_PENABLE 0x0400 +#define WC_WP 0x0800 + /* I/O only */ +#define WC_INPACK 0x0080 +#define WC_EISA 0x0100 +#define WC_CENABLE 0x0200 + /* Solaris/SPARC */ +#define WC_IO_RANGE_PER_WINDOW 0x8000 /* I/O range unique for each window */ + +/* SetPage(set_page_t *) */ +typedef struct set_page { + unsigned window; /* window number */ + unsigned page; /* page number */ + unsigned state; /* page state */ + off_t offset; /* offset in PC card space */ +} set_page_t; + +/* SetSocket(set_socket_t) */ + +typedef struct set_socket { + unsigned socket; /* socket number */ + unsigned SCIntMask; /* status change enables */ + unsigned Vcontrol; /* power control flags */ + unsigned VccLevel; /* Vcc power index level */ + unsigned Vpp1Level; /* Vpp1 power index level */ + unsigned Vpp2Level; /* Vpp2 power index level */ + unsigned State; + unsigned CtlInd; /* control and indicator bits */ + irq_t IREQRouting; /* I/O IRQ routing */ + unsigned IFType; /* interface type (mem/IO) */ +} set_socket_t; + +#define VCTL_CISREAD 0x01 /* controlled by Vcc/Vpp sense pins */ +#define VCTL_OVERRIDE 0x02 /* 16-bit cards, ignore the sense pins */ + +/* SetIRQHandler(set_irq_handler_t) */ + +typedef struct set_irq_handler { + unsigned socket; /* associate with a socket for now */ + unsigned irq; + unsigned handler_id; /* ID of this client's handler */ + f_tt *handler; /* client IO IRQ handler entry point */ + void *arg1; /* arg to call client handler with */ + void *arg2; /* arg to call client handler with */ + ddi_iblock_cookie_t *iblk_cookie; /* iblk cookie pointer */ + ddi_idevice_cookie_t *idev_cookie; /* idev cookie pointer */ +} set_irq_handler_t; + +#define IRQ_ANY 0x0 + +/* interrupt priority levels */ +#define PRIORITY_LOW 0x00 +#define PRIORITY_HIGH 0x10 + +/* ClearIRQHandler(clear_irq_handler_t) */ + +typedef struct clear_irq_handler { + unsigned socket; + unsigned handler_id; /* client handler ID to remove */ + f_tt *handler; /* client IO IRQ handler entry point */ +} clear_irq_handler_t; + +/* SetWindow(set_window_t) */ + +typedef struct set_window { + unsigned window; /* window number */ + unsigned socket; /* socket number */ + unsigned WindowSize; /* window size in bytes */ + unsigned state; /* window state */ + unsigned speed; /* window speed, nanoseconds */ + uint_t base; + ddi_acc_handle_t handle; /* base addr in host space */ + dev_info_t *child; /* child's dip */ + ddi_device_acc_attr_t attr; +} set_window_t; + +/* CSInitDev */ +typedef +struct ss_make_device_node { + uint32_t flags; /* operation flags */ + dev_info_t *dip; /* dip for this client */ + char *name; /* device node path and name */ + char *slot; /* slot name string */ + char *busaddr; /* bus addr name string */ + int spec_type; /* dev special type (block/char) */ + int minor_num; /* device node minor number */ + char *node_type; /* device node type */ +} ss_make_device_node_t; + +#define SS_CSINITDEV_CREATE_DEVICE 0x01 /* create device node */ +#define SS_CSINITDEV_REMOVE_DEVICE 0x02 /* remove device node */ +#define SS_CSINITDEV_USE_SLOT 0x04 /* use slot name from caller */ +#define SS_CSINITDEV_USE_BUSADDR 0x08 /* use bus addr from caller */ +#define SS_CSINITDEV_MORE_DEVICES 0x10 /* send PCE_INIT_DEV */ +#define SS_CSINITDEV_SEND_DEV_EVENT 0x10 /* send PCE_INIT_DEV */ + +/* + * csss_adapter_info_t - provides additional per-socket adapter info + */ +typedef struct csss_adapter_info_t { + char name[MODMAXNAMELEN]; /* adapter name */ + int major; /* adapter major number */ + int minor; /* adapter minor number */ + int number; /* canonical adapter number */ + int num_sockets; /* # sockets on this adapter */ + int first_socket; /* first socket # on this adapter */ +} csss_adapter_info_t; + +/* CSGetCookiesAndDip */ +typedef struct get_cookies_and_dip_t { + unsigned socket; /* socket number */ + dev_info_t *dip; /* adapter instance dip */ + ddi_iblock_cookie_t *iblock; /* for event handler */ + ddi_idevice_cookie_t *idevice; /* for event handler */ + csss_adapter_info_t adapter_info; /* adapter info for socket */ +} get_cookies_and_dip_t; + +/* ResetSocket */ +#define RESET_MODE_FULL 0 /* Reset to SocketServices Specification */ +#define RESET_MODE_CARD_ONLY 1 /* only reset the card itself */ + +/* union of all exported functions functions */ +typedef +union sservice { + get_adapter_t get_adapter; + get_page_t get_page; + get_socket_t get_socket; + get_window_t get_window; + get_ss_status_t get_ss_status; + inquire_adapter_t inquire_adapter; + inquire_socket_t inquire_socket; + inquire_window_t inquire_window; + set_page_t set_page; + set_socket_t set_socket; + set_irq_handler_t set_irq_handler; + set_window_t set_window; + get_cookies_and_dip_t get_cookies; + ss_make_device_node_t make_device; +} sservice_t; + +/* event manager structures */ +struct pcm_make_dev { + int socket; + int flags; + int op; + dev_t dev; + int type; + char driver[MODMAXNAMELEN]; + char path[MAXPATHLEN]; +}; + +#define PCM_EVENT_MORE 0x0001 /* more events of this type coming */ + +#ifdef _KERNEL + +#include + +/* + * prototypes for nexi + */ + +int pcmcia_attach(dev_info_t *, struct pcmcia_adapter_nexus_private *); +int pcmcia_ctlops(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *); +int pcmcia_prop_op(dev_t, dev_info_t *, dev_info_t *, ddi_prop_op_t, + int, char *, caddr_t, int *); +int pcmcia_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t intr_op, + ddi_intr_handle_impl_t *hdlp, void *result); + +int pcmcia_open(dev_t *, int, int, cred_t *); +int pcmcia_close(dev_t, int, int, cred_t *); +int pcmcia_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); +int pcmcia_power(dev_info_t *, int, int); +void pcmcia_begin_resume(dev_info_t *); +void pcmcia_wait_insert(dev_info_t *); + + +/* resource allocation functions and structure */ +typedef struct ra_return { + uint_t ra_addr_hi; + uint_t ra_addr_lo; + uint_t ra_len; +} ra_return_t; + +int pcmcia_alloc_mem(dev_info_t *, ndi_ra_request_t *, ra_return_t *, + dev_info_t **); +int pcmcia_alloc_io(dev_info_t *, ndi_ra_request_t *, ra_return_t *, + dev_info_t **); +int pcmcia_free_mem(dev_info_t *, ra_return_t *); +int pcmcia_free_io(dev_info_t *, ra_return_t *); +int pcmcia_map_reg(dev_info_t *, dev_info_t *, ra_return_t *, + uint32_t, caddr_t *, ddi_acc_handle_t *, + ddi_device_acc_attr_t *, uint32_t); +int pcmcia_bus_map(dev_info_t *, dev_info_t *, ddi_map_req_t *, + off_t, off_t, caddr_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SSERVICE_H */ diff --git a/illumos-x86_64/usr/include/sys/stack.h b/illumos-x86_64/usr/include/sys/stack.h new file mode 100644 index 00000000..a893e317 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stack.h @@ -0,0 +1,160 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STACK_H +#define _SYS_STACK_H + +#if !defined(_ASM) + +#include + +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * In the x86 world, a stack frame looks like this: + * + * |--------------------------| + * 4n+8(%ebp) ->| argument word n | + * | ... | (Previous frame) + * 8(%ebp) ->| argument word 0 | + * |--------------------------|-------------------- + * 4(%ebp) ->| return address | + * |--------------------------| + * 0(%ebp) ->| previous %ebp (optional) | + * |--------------------------| + * -4(%ebp) ->| unspecified | (Current frame) + * | ... | + * 0(%esp) ->| variable size | + * |--------------------------| + */ + +/* + * Stack alignment macros. + */ + +#define STACK_ALIGN32 4 +#define STACK_ENTRY_ALIGN32 4 +#define STACK_BIAS32 0 +#define SA32(x) (((x)+(STACK_ALIGN32-1)) & ~(STACK_ALIGN32-1)) +#define STACK_RESERVE32 0 +#define MINFRAME32 0 + +#if defined(__amd64) + +/* + * In the amd64 world, a stack frame looks like this: + * + * |--------------------------| + * 8n+16(%rbp)->| argument word n | + * | ... | (Previous frame) + * 16(%rbp) ->| argument word 0 | + * |--------------------------|-------------------- + * 8(%rbp) ->| return address | + * |--------------------------| + * 0(%rbp) ->| previous %rbp | + * |--------------------------| + * -8(%rbp) ->| unspecified | (Current frame) + * | ... | + * 0(%rsp) ->| variable size | + * |--------------------------| + * -128(%rsp) ->| reserved for function | + * |--------------------------| + * + * The end of the input argument area must be aligned on a 16-byte + * boundary; i.e. (%rsp - 8) % 16 == 0 at function entry. + * + * The 128-byte location beyond %rsp is considered to be reserved for + * functions and is NOT modified by signal handlers. It can be used + * to store temporary data that is not needed across function calls. + */ + +/* + * Stack alignment macros. + */ + +#define STACK_ALIGN64 16 +#define STACK_ENTRY_ALIGN64 8 +#define STACK_BIAS64 0 +#define SA64(x) (((x)+(STACK_ALIGN64-1)) & ~(STACK_ALIGN64-1)) +#define STACK_RESERVE64 128 +#define MINFRAME64 0 + +#define STACK_ALIGN STACK_ALIGN64 +#define STACK_ENTRY_ALIGN STACK_ENTRY_ALIGN64 +#define STACK_BIAS STACK_BIAS64 +#define SA(x) SA64(x) +#define STACK_RESERVE STACK_RESERVE64 +#define MINFRAME MINFRAME64 + +#elif defined(__i386) + +#define STACK_ALIGN STACK_ALIGN32 +#define STACK_ENTRY_ALIGN STACK_ENTRY_ALIGN32 +#define STACK_BIAS STACK_BIAS32 +#define SA(x) SA32(x) +#define STACK_RESERVE STACK_RESERVE32 +#define MINFRAME MINFRAME32 + +#endif /* __i386 */ + +#if defined(_KERNEL) && !defined(_ASM) + +#if defined(DEBUG) +#if STACK_ALIGN == 4 +#define ASSERT_STACK_ALIGNED() \ + { \ + uint32_t __tmp; \ + ASSERT((((uintptr_t)&__tmp) & (STACK_ALIGN - 1)) == 0); \ + } +#elif (STACK_ALIGN == 16) && (_LONG_DOUBLE_ALIGNMENT == 16) +#define ASSERT_STACK_ALIGNED() \ + { \ + long double __tmp; \ + ASSERT((((uintptr_t)&__tmp) & (STACK_ALIGN - 1)) == 0); \ + } +#endif +#else /* DEBUG */ +#define ASSERT_STACK_ALIGNED() +#endif /* DEBUG */ + +struct regs; + +void traceregs(struct regs *); +void traceback(caddr_t); + +#endif /* defined(_KERNEL) && !defined(_ASM) */ + +#define STACK_GROWTH_DOWN /* stacks grow from high to low addresses */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STACK_H */ diff --git a/illumos-x86_64/usr/include/sys/stat.h b/illumos-x86_64/usr/include/sys/stat.h new file mode 100644 index 00000000..42cc4064 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stat.h @@ -0,0 +1,525 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_STAT_H +#define _SYS_STAT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The implementation specific header includes a + * definition for timestruc_t needed by the stat structure. However, + * including either , which includes , or + * including directly will break both X/Open and + * POSIX namespace. Preceeding tag, structure, and structure member + * names with underscores eliminates the namespace breakage and at the + * same time, with unique type names, eliminates the possibility of + * timespec_t or timestruct_t naming conflicts that could otherwise + * result based on the order of inclusion of and + * . The header contains the + * standards namespace safe versions of these definitions. + */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#include +#else +#include +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#define _ST_FSTYPSZ 16 /* array size for file system type name */ + +/* + * stat structure, used by stat(2) and fstat(2) + */ + +#if defined(_KERNEL) + + /* Expanded stat structure */ + +#if defined(_LP64) + +struct stat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; + blksize_t st_blksize; + blkcnt_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; +}; + +struct stat64 { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; + blksize_t st_blksize; + blkcnt_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; +}; + +#else /* _LP64 */ + +struct stat { + dev_t st_dev; + long st_pad1[3]; /* reserve for dev expansion, */ + /* sysid definition */ + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + long st_pad2[2]; + off_t st_size; + long st_pad3; /* pad for future off_t expansion */ + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; + blksize_t st_blksize; + blkcnt_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; + long st_pad4[8]; /* expansion area */ +}; + +struct stat64 { + dev_t st_dev; + long st_pad1[3]; /* reserve for dev expansion, */ + /* sysid definition */ + ino64_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + long st_pad2[2]; + off64_t st_size; /* large file support */ + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; + blksize_t st_blksize; + blkcnt64_t st_blocks; /* large file support */ + char st_fstype[_ST_FSTYPSZ]; + long st_pad4[8]; /* expansion area */ +}; + +#endif /* _LP64 */ + +#else /* !defined(_KERNEL) */ + +/* + * large file compilation environment setup + */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname fstat fstat64 +#pragma redefine_extname stat stat64 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \ + defined(_ATFILE_SOURCE) +#pragma redefine_extname fstatat fstatat64 +#endif /* defined (_ATFILE_SOURCE) */ + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__) +#pragma redefine_extname lstat lstat64 +#endif +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define fstat fstat64 +#define stat stat64 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \ + defined(_ATFILE_SOURCE) +#define fstatat fstatat64 +#endif /* defined (_ATFILE_SOURCE) */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__) +#define lstat lstat64 +#endif +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +/* + * In the LP64 compilation environment, map large file interfaces + * back to native versions where possible. + */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname fstat64 fstat +#pragma redefine_extname stat64 stat +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \ + defined(_ATFILE_SOURCE) +#pragma redefine_extname fstatat64 fstatat +#endif /* defined (_ATFILE_SOURCE) */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__) +#pragma redefine_extname lstat64 lstat +#endif +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define fstat64 fstat +#define stat64 stat +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \ + defined(_ATFILE_SOURCE) +#define fstatat64 fstatat +#endif /* defined (_ATFILE_SOURCE) */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__) +#define lstat64 lstat +#endif +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +/* + * User level stat structure definitions. + */ + +#if defined(_LP64) + +struct stat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; +#else + _timestruc_t st_atim; + _timestruc_t st_mtim; + _timestruc_t st_ctim; +#endif + blksize_t st_blksize; + blkcnt_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; +}; + +#else /* _LP64 */ + +struct stat { + dev_t st_dev; + long st_pad1[3]; /* reserved for network id */ + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + long st_pad2[2]; + off_t st_size; +#if _FILE_OFFSET_BITS != 64 + long st_pad3; /* future off_t expansion */ +#endif +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; +#else + _timestruc_t st_atim; + _timestruc_t st_mtim; + _timestruc_t st_ctim; +#endif + blksize_t st_blksize; + blkcnt_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; + long st_pad4[8]; /* expansion area */ +}; + +#endif /* _LP64 */ + +/* transitional large file interface version */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +#if defined(_LP64) + +struct stat64 { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; +#else + _timestruc_t st_atim; + _timestruc_t st_mtim; + _timestruc_t st_ctim; +#endif + blksize_t st_blksize; + blkcnt_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; +}; + +#else /* _LP64 */ + +struct stat64 { + dev_t st_dev; + long st_pad1[3]; /* reserved for network id */ + ino64_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + long st_pad2[2]; + off64_t st_size; +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; +#else + _timestruc_t st_atim; + _timestruc_t st_mtim; + _timestruc_t st_ctim; +#endif + blksize_t st_blksize; + blkcnt64_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; + long st_pad4[8]; /* expansion area */ +}; + +#endif /* _LP64 */ +#endif + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define st_atime st_atim.tv_sec +#define st_mtime st_mtim.tv_sec +#define st_ctime st_ctim.tv_sec +#else +#define st_atime st_atim.__tv_sec +#define st_mtime st_mtim.__tv_sec +#define st_ctime st_ctim.__tv_sec +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#endif /* end defined(_KERNEL) */ + +#if defined(_SYSCALL32) + +/* + * Kernel's view of user ILP32 stat and stat64 structures + */ + +struct stat32 { + dev32_t st_dev; + int32_t st_pad1[3]; + ino32_t st_ino; + mode32_t st_mode; + nlink32_t st_nlink; + uid32_t st_uid; + gid32_t st_gid; + dev32_t st_rdev; + int32_t st_pad2[2]; + off32_t st_size; + int32_t st_pad3; + timestruc32_t st_atim; + timestruc32_t st_mtim; + timestruc32_t st_ctim; + int32_t st_blksize; + blkcnt32_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; + int32_t st_pad4[8]; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +struct stat64_32 { + dev32_t st_dev; + int32_t st_pad1[3]; + ino64_t st_ino; + mode32_t st_mode; + nlink32_t st_nlink; + uid32_t st_uid; + gid32_t st_gid; + dev32_t st_rdev; + int32_t st_pad2[2]; + off64_t st_size; + timestruc32_t st_atim; + timestruc32_t st_mtim; + timestruc32_t st_ctim; + int32_t st_blksize; + blkcnt64_t st_blocks; + char st_fstype[_ST_FSTYPSZ]; + int32_t st_pad4[8]; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ + +/* MODE MASKS */ + +/* de facto standard definitions */ + +#define S_IFMT 0xF000 /* type of file */ +#define S_IAMB 0x1FF /* access mode bits */ +#define S_IFIFO 0x1000 /* fifo */ +#define S_IFCHR 0x2000 /* character special */ +#define S_IFDIR 0x4000 /* directory */ +/* XENIX definitions are not relevant to Solaris */ +#define S_IFNAM 0x5000 /* XENIX special named file */ +#define S_INSEM 0x1 /* XENIX semaphore subtype of IFNAM */ +#define S_INSHD 0x2 /* XENIX shared data subtype of IFNAM */ +#define S_IFBLK 0x6000 /* block special */ +#define S_IFREG 0x8000 /* regular */ +#define S_IFLNK 0xA000 /* symbolic link */ +#define S_IFSOCK 0xC000 /* socket */ +#define S_IFDOOR 0xD000 /* door */ +#define S_IFPORT 0xE000 /* event port */ +#define S_ISUID 0x800 /* set user id on execution */ +#define S_ISGID 0x400 /* set group id on execution */ +#define S_ISVTX 0x200 /* save swapped text even after use */ +#define S_IREAD 00400 /* read permission, owner */ +#define S_IWRITE 00200 /* write permission, owner */ +#define S_IEXEC 00100 /* execute/search permission, owner */ +#define S_ENFMT S_ISGID /* record locking enforcement flag */ + +/* the following macros are for POSIX conformance */ + +#define S_IRWXU 00700 /* read, write, execute: owner */ +#define S_IRUSR 00400 /* read permission: owner */ +#define S_IWUSR 00200 /* write permission: owner */ +#define S_IXUSR 00100 /* execute permission: owner */ +#define S_IRWXG 00070 /* read, write, execute: group */ +#define S_IRGRP 00040 /* read permission: group */ +#define S_IWGRP 00020 /* write permission: group */ +#define S_IXGRP 00010 /* execute permission: group */ +#define S_IRWXO 00007 /* read, write, execute: other */ +#define S_IROTH 00004 /* read permission: other */ +#define S_IWOTH 00002 /* write permission: other */ +#define S_IXOTH 00001 /* execute permission: other */ + + +#define S_ISFIFO(mode) (((mode)&0xF000) == 0x1000) +#define S_ISCHR(mode) (((mode)&0xF000) == 0x2000) +#define S_ISDIR(mode) (((mode)&0xF000) == 0x4000) +#define S_ISBLK(mode) (((mode)&0xF000) == 0x6000) +#define S_ISREG(mode) (((mode)&0xF000) == 0x8000) +#define S_ISLNK(mode) (((mode)&0xF000) == 0xa000) +#define S_ISSOCK(mode) (((mode)&0xF000) == 0xc000) +#define S_ISDOOR(mode) (((mode)&0xF000) == 0xd000) +#define S_ISPORT(mode) (((mode)&0xF000) == 0xe000) + +/* POSIX.4 macros */ +#define S_TYPEISMQ(_buf) (0) +#define S_TYPEISSEM(_buf) (0) +#define S_TYPEISSHM(_buf) (0) + +#if defined(__i386) || (defined(__i386_COMPAT) && defined(_KERNEL)) + +/* + * A version number is included in the x86 SVR4 stat and mknod interfaces + * so that SVR4 binaries can be supported. An LP64 kernel that supports + * the i386 ABI need to be aware of this too. + */ + +#define _R3_MKNOD_VER 1 /* SVR3.0 mknod */ +#define _MKNOD_VER 2 /* current version of mknod */ +#define _R3_STAT_VER 1 /* SVR3.0 stat */ +#define _STAT_VER 2 /* current version of stat */ + +#endif /* __i386 || (__i386_COMPAT && _KERNEL) */ + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +/* for use with futimens() and utimensat() */ +#define UTIME_NOW -1L +#define UTIME_OMIT -2L +#endif /* defined(__EXTENSIONS__) ... */ + +#if !defined(_KERNEL) || defined(_BOOT) + +#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \ + defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int fchmod(int, mode_t); +#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */ + +extern int chmod(const char *, mode_t); +extern int mkdir(const char *, mode_t); +extern int mkfifo(const char *, mode_t); +extern mode_t umask(mode_t); + +/* transitional large file interfaces */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int fstat64(int, struct stat64 *); +extern int stat64(const char *_RESTRICT_KYWD, struct stat64 *_RESTRICT_KYWD); +extern int lstat64(const char *_RESTRICT_KYWD, struct stat64 *_RESTRICT_KYWD); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \ + defined(_ATFILE_SOURCE) +extern int fstatat64(int, const char *, struct stat64 *, int); +#endif /* defined (_ATFILE_SOURCE) */ +#endif + +#if defined(__EXTENSIONS__) || defined(_ATFILE_SOURCE) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern int mkdirat(int, const char *, mode_t); +extern int mkfifoat(int, const char *, mode_t); +extern int mknodat(int, const char *, mode_t, dev_t); +extern int fchmodat(int, const char *, mode_t, int); +extern int futimens(int, const struct timespec[2]); +extern int utimensat(int, const char *, const struct timespec[2], int); +#endif /* defined(__EXTENSIONS__) ... */ + +#include + +#endif /* !defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STAT_H */ diff --git a/illumos-x86_64/usr/include/sys/stat_impl.h b/illumos-x86_64/usr/include/sys/stat_impl.h new file mode 100644 index 00000000..e8d3cfcf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stat_impl.h @@ -0,0 +1,106 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STAT_IMPL_H +#define _SYS_STAT_IMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The implementation specific header for + */ + +#if !defined(_KERNEL) + +#if defined(__STDC__) + +extern int fstat(int, struct stat *); +extern int stat(const char *_RESTRICT_KYWD, struct stat *_RESTRICT_KYWD); + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \ + defined(_ATFILE_SOURCE) +extern int fstatat(int, const char *, struct stat *, int); +#endif /* defined (_ATFILE_SOURCE) */ + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int lstat(const char *_RESTRICT_KYWD, struct stat *_RESTRICT_KYWD); +extern int mknod(const char *, mode_t, dev_t); +#endif /* !defined(__XOPEN_OR_POSIX) ... */ + +#else /* defined(__STDC__) */ + +extern int fstat(); +extern int stat(); + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \ + defined(_ATFILE_SOURCE) +extern int fstatat(); +#endif + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int lstat(); +extern int mknod(); +#endif /* !defined(__XOPEN_OR_POSIX) ... */ + +#endif /* defined(__STDC__) */ + +#if defined(__i386) && _FILE_OFFSET_BITS == 32 && \ + (!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)) + +/* + * Obsolete SVR3 compatibility functions. + * Application software should NOT program to the _xstat interface. + */ +#if defined(__STDC__) + +extern int _fxstat(const int, int, struct stat *); +extern int _xstat(const int, const char *, struct stat *); +extern int _lxstat(const int, const char *, struct stat *); +extern int _xmknod(const int, const char *, mode_t, dev_t); + +#else /* __STDC__ */ + +extern int _fxstat(); +extern int _xstat(); +extern int _lxstat(); +extern int _xmknod(); + +#endif /* __STDC__ */ + +#endif /* defined(__i386) ... */ + +#endif /* !defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STAT_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/statfs.h b/illumos-x86_64/usr/include/sys/statfs.h new file mode 100644 index 00000000..6f3d275d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/statfs.h @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1996 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_STATFS_H +#define _SYS_STATFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structure returned by statfs(2) and fstatfs(2). + * This structure and associated system calls have been replaced + * by statvfs(2) and fstatvfs(2) and will be removed from the system + * in a near-future release. + */ + +struct statfs { + short f_fstyp; /* File system type */ + long f_bsize; /* Block size */ + long f_frsize; /* Fragment size (if supported) */ + long f_blocks; /* Total number of blocks on file system */ + long f_bfree; /* Total number of free blocks */ + ino_t f_files; /* Total number of file nodes (inodes) */ + ino_t f_ffree; /* Total number of free file nodes */ + char f_fname[6]; /* Volume name */ + char f_fpack[6]; /* Pack name */ +}; + +#ifdef _SYSCALL32 + +struct statfs32 { + int16_t f_fstyp; + int32_t f_bsize; + int32_t f_frsize; + int32_t f_blocks; + int32_t f_bfree; + ino32_t f_files; + ino32_t f_ffree; + char f_fname[6]; + char f_fpack[6]; +}; + +#endif /* _SYSCALL32 */ + +#if !defined(_KERNEL) +int statfs(const char *, struct statfs *, int, int); +int fstatfs(int, struct statfs *, int, int); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STATFS_H */ diff --git a/illumos-x86_64/usr/include/sys/statvfs.h b/illumos-x86_64/usr/include/sys/statvfs.h new file mode 100644 index 00000000..c0b97045 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/statvfs.h @@ -0,0 +1,205 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STATVFS_H +#define _SYS_STATVFS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structure returned by statvfs(2). + */ + +#define _FSTYPSZ 16 +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#ifndef FSTYPSZ +#define FSTYPSZ _FSTYPSZ +#endif +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +typedef struct statvfs { + unsigned long f_bsize; /* fundamental file system block size */ + unsigned long f_frsize; /* fragment size */ + fsblkcnt_t f_blocks; /* total blocks of f_frsize on fs */ + fsblkcnt_t f_bfree; /* total free blocks of f_frsize */ + fsblkcnt_t f_bavail; /* free blocks avail to non-superuser */ + fsfilcnt_t f_files; /* total file nodes (inodes) */ + fsfilcnt_t f_ffree; /* total free file nodes */ + fsfilcnt_t f_favail; /* free nodes avail to non-superuser */ + unsigned long f_fsid; /* file system id (dev for now) */ + char f_basetype[_FSTYPSZ]; /* target fs type name, */ + /* null-terminated */ + unsigned long f_flag; /* bit-mask of flags */ + unsigned long f_namemax; /* maximum file name length */ + char f_fstr[32]; /* filesystem-specific string */ +#if !defined(_LP64) + unsigned long f_filler[16]; /* reserved for future expansion */ +#endif +} statvfs_t; + +#if defined(_SYSCALL32) + +/* Kernel view of user ILP32 statvfs structure */ + +typedef struct statvfs32 { + uint32_t f_bsize; /* fundamental file system block size */ + uint32_t f_frsize; /* fragment size */ + fsblkcnt32_t f_blocks; /* total blocks of f_frsize on fs */ + fsblkcnt32_t f_bfree; /* total free blocks of f_frsize */ + fsblkcnt32_t f_bavail; /* free blocks avail to non-superuser */ + fsfilcnt32_t f_files; /* total file nodes (inodes) */ + fsfilcnt32_t f_ffree; /* total free file nodes */ + fsfilcnt32_t f_favail; /* free nodes avail to non-superuser */ + uint32_t f_fsid; /* file system id (dev for now) */ + char f_basetype[_FSTYPSZ]; /* target fs type name, */ + /* null-terminated */ + uint32_t f_flag; /* bit-mask of flags */ + uint32_t f_namemax; /* maximum file name length */ + char f_fstr[32]; /* filesystem-specific string */ + uint32_t f_filler[16]; /* reserved for future expansion */ +} statvfs32_t; + +#endif /* _SYSCALL32 */ + +/* transitional large file interface version */ +#if defined(_LARGEFILE64_SOURCE) +typedef struct statvfs64 { + unsigned long f_bsize; /* preferred file system block size */ + unsigned long f_frsize; /* fundamental file system block size */ + fsblkcnt64_t f_blocks; /* total blocks of f_frsize */ + fsblkcnt64_t f_bfree; /* total free blocks of f_frsize */ + fsblkcnt64_t f_bavail; /* free blocks avail to non-superuser */ + fsfilcnt64_t f_files; /* total # of file nodes (inodes) */ + fsfilcnt64_t f_ffree; /* total # of free file nodes */ + fsfilcnt64_t f_favail; /* free nodes avail to non-superuser */ + unsigned long f_fsid; /* file system id (dev for now) */ + char f_basetype[FSTYPSZ]; /* target fs type name, */ + /* null-terminated */ + unsigned long f_flag; /* bit-mask of flags */ + unsigned long f_namemax; /* maximum file name length */ + char f_fstr[32]; /* filesystem-specific string */ +#if !defined(_LP64) + unsigned long f_filler[16]; /* reserved for future expansion */ +#endif /* _LP64 */ +} statvfs64_t; +#endif + +#if defined(_SYSCALL32) + +/* Kernel view of user ILP32 statvfs64 structure */ + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct statvfs64_32 { + uint32_t f_bsize; /* preferred file system block size */ + uint32_t f_frsize; /* fundamental file system block size */ + fsblkcnt64_t f_blocks; /* total blocks of f_frsize */ + fsblkcnt64_t f_bfree; /* total free blocks of f_frsize */ + fsblkcnt64_t f_bavail; /* free blocks avail to non-superuser */ + fsfilcnt64_t f_files; /* total # of file nodes (inodes) */ + fsfilcnt64_t f_ffree; /* total # of free file nodes */ + fsfilcnt64_t f_favail; /* free nodes avail to non-superuser */ + uint32_t f_fsid; /* file system id (dev for now) */ + char f_basetype[FSTYPSZ]; /* target fs type name, */ + /* null-terminated */ + uint32_t f_flag; /* bit-mask of flags */ + uint32_t f_namemax; /* maximum file name length */ + char f_fstr[32]; /* filesystem-specific string */ + uint32_t f_filler[16]; /* reserved for future expansion */ +} statvfs64_32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#endif /* _SYSCALL32 */ + +/* + * Flag definitions. + */ + +#define ST_RDONLY 0x01 /* read-only file system */ +#define ST_NOSUID 0x02 /* does not support setuid/setgid semantics */ +#define ST_NOTRUNC 0x04 /* does not truncate long file names */ + +#if !defined(_KERNEL) +/* + * large file compilation environment setup + */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname statvfs statvfs64 +#pragma redefine_extname fstatvfs fstatvfs64 +#else +#define statvfs_t statvfs64_t +#define statvfs statvfs64 +#define fstatvfs fstatvfs64 +#endif +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +/* + * In the LP64 compilation environment, map large file interfaces + * back to native versions where possible. + */ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname statvfs64 statvfs +#pragma redefine_extname fstatvfs64 fstatvfs +#else +#define statvfs64_t statvfs_t +#define statvfs64 statvfs +#define fstatvfs64 fstatvfs +#endif +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +int statvfs(const char *_RESTRICT_KYWD, statvfs_t *_RESTRICT_KYWD); +int fstatvfs(int, statvfs_t *); + +/* transitional large file interface versions */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +int statvfs64(const char *_RESTRICT_KYWD, statvfs64_t *_RESTRICT_KYWD); +int fstatvfs64(int, statvfs64_t *); +#endif /* _LARGEFILE64_SOURCE... */ +#endif /* !defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STATVFS_H */ diff --git a/illumos-x86_64/usr/include/sys/stdalign.h b/illumos-x86_64/usr/include/sys/stdalign.h new file mode 100644 index 00000000..b9121d2d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stdalign.h @@ -0,0 +1,56 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2016 Joyent, Inc. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_STDALIGN_H +#define _SYS_STDALIGN_H + +/* + * ISO/IEC C11 stdalign.h. This header is meant to provide definitions for the + * alignas and alignof 'keywords' into the underlying compiler-understood value. + * In addition, there are two macros that are meant to define that this process + * has happened. C++11 added alignas/alignof as keywords and including this + * header is meant to cause us to still have the _is_defined macros, but not + * define this overall. + * + * Unlike other cases we don't use any symbol guards here (other than C++) and + * just allow the implementation to either have _Alignas and _Alignof or not + * have it and lead to a compiler error for the user. The main justification of + * this is that this header is only defined in C11 (and newer). It's not defined + * in other standards and just as if you include a non-standard header, in this + * case we don't try to stop that (same as if you included something like + * libdevinfo.h). + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __cplusplus + +#define alignas _Alignas +/*CSTYLED*/ +#define alignof _Alignof + +#endif /* !__cplusplus */ + +#define __alignas_is_defined 1 +#define __alignof_is_defined 1 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STDALIGN_H */ diff --git a/illumos-x86_64/usr/include/sys/stdbit.h b/illumos-x86_64/usr/include/sys/stdbit.h new file mode 100644 index 00000000..776896ed --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stdbit.h @@ -0,0 +1,346 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +#ifndef _SYS_STDBIT_H +#define _SYS_STDBIT_H + +/* + * This header implements all of the different aspects of the C23 stdbit.h + * functionality. We attempt to make this header useful to all C versions other + * than the type generic interfaces, for which we require the asked for version + * of C to be at least C23. The functions that are present here are allowed to + * be inline or not. To provide wider ranging compiler support we declare extern + * versions of all of these symbols which are provided in both libc and the + * kernel. This also avoids cases where a compiler builtin relies on external + * runtime library support. + * + * In the future, we should provide inline versions with compilers that support + * common builtins. + */ + +#include +#include + +/* + * This header is required specifically to make the size_t, uintXX_t, and the + * _least_ variants available. The generic values are allowed to leverage the + * 'bool' type. In C23, bool became a keyword as opposed to a definition to + * _Bool. We therefore include it so we can attempt to be consistent and + * generally useful. + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Declare our version. + */ +#define __STDC_VERSION_STDBIT_H__ 202311L + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* _SIZE_T */ + +/* + * Endian values and detection. + */ +#define __STDC_ENDIAN_LITTLE__ 1234 +#define __STDC_ENDIAN_BIG__ 4321 +#if defined(_LITTLE_ENDIAN) +#define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_LITTLE__ +#elif defined(_BIG_ENDIAN) +#define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_BIG__ +#else +#error "Unknown byte order" +#endif /* _LITTLE_ENDIAN */ + +/* + * Count Leading Zeros + */ +extern unsigned int stdc_leading_zeros_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_leading_zeros_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_leading_zeros_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_leading_zeros_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Count Leading Ones + */ +extern unsigned int stdc_leading_ones_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_leading_ones_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_leading_ones_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_leading_ones_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Count Trailing Zeros + */ +extern unsigned int stdc_trailing_zeros_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_trailing_zeros_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_trailing_zeros_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_trailing_zeros_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Count Trailing Ones + */ +extern unsigned int stdc_trailing_ones_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_trailing_ones_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_trailing_ones_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_trailing_ones_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * First Leading Zero + */ +extern unsigned int stdc_first_leading_zero_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_leading_zero_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_leading_zero_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_leading_zero_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * First Leading One + */ +extern unsigned int stdc_first_leading_one_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_leading_one_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_leading_one_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_leading_one_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * First Trailing Zero + */ +extern unsigned int stdc_first_trailing_zero_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_trailing_zero_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_trailing_zero_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_trailing_zero_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * First Trailing One + */ +extern unsigned int stdc_first_trailing_one_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_trailing_one_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_trailing_one_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_trailing_one_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Count Zeros + */ +extern unsigned int stdc_count_zeros_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_count_zeros_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_count_zeros_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_count_zeros_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Count Ones + */ +extern unsigned int stdc_count_ones_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_count_ones_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_count_ones_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_count_ones_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Single-bit Check + */ +extern bool stdc_has_single_bit_uc(unsigned char) _C23_UNSEQ_ATTR; +extern bool stdc_has_single_bit_us(unsigned short) _C23_UNSEQ_ATTR; +extern bool stdc_has_single_bit_ui(unsigned int) _C23_UNSEQ_ATTR; +extern bool stdc_has_single_bit_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Bit Width + */ +extern unsigned int stdc_bit_width_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned int stdc_bit_width_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_bit_width_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned int stdc_bit_width_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Bit Floor + */ +extern unsigned char stdc_bit_floor_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned short stdc_bit_floor_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_bit_floor_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned long stdc_bit_floor_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * Bit Ceiling + */ +extern unsigned char stdc_bit_ceil_uc(unsigned char) _C23_UNSEQ_ATTR; +extern unsigned short stdc_bit_ceil_us(unsigned short) _C23_UNSEQ_ATTR; +extern unsigned int stdc_bit_ceil_ui(unsigned int) _C23_UNSEQ_ATTR; +extern unsigned long stdc_bit_ceil_ul(unsigned long) _C23_UNSEQ_ATTR; + +/* + * long long variants of functions. This check is just for some non-C23 + * environments out of courtesy. + */ +#if defined(_LONGLONG_TYPE) +extern unsigned int stdc_leading_zeros_ull(unsigned long long) _C23_UNSEQ_ATTR; +extern unsigned int stdc_leading_ones_ull(unsigned long long) _C23_UNSEQ_ATTR; +extern unsigned int stdc_trailing_zeros_ull(unsigned long long) _C23_UNSEQ_ATTR; +extern unsigned int stdc_trailing_ones_ull(unsigned long long) _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_leading_zero_ull(unsigned long long) + _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_leading_one_ull(unsigned long long) + _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_trailing_zero_ull(unsigned long long) + _C23_UNSEQ_ATTR; +extern unsigned int stdc_first_trailing_one_ull(unsigned long long) + _C23_UNSEQ_ATTR; +extern unsigned int stdc_count_zeros_ull(unsigned long long) _C23_UNSEQ_ATTR; +extern unsigned int stdc_count_ones_ull(unsigned long long) _C23_UNSEQ_ATTR; +extern bool stdc_has_single_bit_ull(unsigned long long) _C23_UNSEQ_ATTR; +extern unsigned int stdc_bit_width_ull(unsigned long long) _C23_UNSEQ_ATTR; +extern unsigned long long stdc_bit_floor_ull(unsigned long long) + _C23_UNSEQ_ATTR; +extern unsigned long long stdc_bit_ceil_ull(unsigned long long) _C23_UNSEQ_ATTR; +#endif /* _LONGLONG_TYPE */ + +/* + * Type Generic functions. The standard requires that these be a generic return + * type that operates on the following types of values: + * + * - Standard unsigned integer types (excluding bool) i.e. 'unsigned int'. + * - Extended unsigned integer types i.e. 'uint128_t' which is not something + * currently supported and up to the platform. + * - Bit-precise integers that match standard or extended integers. This means + * that _BitInt(32) is accepted, but a value that basically doesn't match a + * uint8_t, uint16_t, uint32_t, or uint64_t like _BitInt(48) is not valid. + * + * There currently is no way to match ranges of _BitInt in the _Generic macro so + * we end up focusing on the size of the type that was passed. _Generic matches + * on the type of the first expression, so rather than just the base type of the + * value, we instead use a suggestion to transform it into a fixed-length array. + * This works for signed and unsigned integers, implicitly doing a cast to the + * unsigned value for signed integers. Similarly, this incidentally works for + * signed and unsigned _BitInt() values that are able to be translated into + * standard sizes. We always use the ull versions for 64-bit values as that is + * always 64-bit regardless if we're in an ILP32 or LP64 environment. + * + * _Generic was introduced in C11. As we currently don't have any _Generic + * statements that aren't valid in C11, we reduce our guard for these to C11 as + * there isn't really a good way to test for the presence of the _Generic + * construct otherwise. If we end up having to modify these to use more explicit + * types, we'll have to have per-standard versions of these macros. + */ +#if defined(_STDC_C11) +/* CSTYLED */ +#define stdc_leading_zeros(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_leading_zeros_uc(val), \ + char(*)[2]: stdc_leading_zeros_us(val), \ + char(*)[4]: stdc_leading_zeros_ui(val), \ + char(*)[8]: stdc_leading_zeros_ull(val)) + +/* CSTYLED */ +#define stdc_leading_ones(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_leading_ones_uc(val), \ + char(*)[2]: stdc_leading_ones_us(val), \ + char(*)[4]: stdc_leading_ones_ui(val), \ + char(*)[8]: stdc_leading_ones_ull(val)) + +/* CSTYLED */ +#define stdc_trailing_zeros(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_trailing_zeros_uc(val), \ + char(*)[2]: stdc_trailing_zeros_us(val), \ + char(*)[4]: stdc_trailing_zeros_ui(val), \ + char(*)[8]: stdc_trailing_zeros_ull(val)) + +/* CSTYLED */ +#define stdc_trailing_ones(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_trailing_ones_uc(val), \ + char(*)[2]: stdc_trailing_ones_us(val), \ + char(*)[4]: stdc_trailing_ones_ui(val), \ + char(*)[8]: stdc_trailing_ones_ull(val)) + +/* CSTYLED */ +#define stdc_first_leading_zero(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_first_leading_zero_uc(val), \ + char(*)[2]: stdc_first_leading_zero_us(val), \ + char(*)[4]: stdc_first_leading_zero_ui(val), \ + char(*)[8]: stdc_first_leading_zero_ull(val)) + +/* CSTYLED */ +#define stdc_first_leading_one(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_first_leading_one_uc(val), \ + char(*)[2]: stdc_first_leading_one_us(val), \ + char(*)[4]: stdc_first_leading_one_ui(val), \ + char(*)[8]: stdc_first_leading_one_ull(val)) + +/* CSTYLED */ +#define stdc_first_trailing_zero(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_first_trailing_zero_uc(val), \ + char(*)[2]: stdc_first_trailing_zero_us(val), \ + char(*)[4]: stdc_first_trailing_zero_ui(val), \ + char(*)[8]: stdc_first_trailing_zero_ull(val)) + +/* CSTYLED */ +#define stdc_first_trailing_one(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_first_trailing_one_uc(val), \ + char(*)[2]: stdc_first_trailing_one_us(val), \ + char(*)[4]: stdc_first_trailing_one_ui(val), \ + char(*)[8]: stdc_first_trailing_one_ull(val)) + +/* CSTYLED */ +#define stdc_count_zeros(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_count_zeros_uc(val), \ + char(*)[2]: stdc_count_zeros_us(val), \ + char(*)[4]: stdc_count_zeros_ui(val), \ + char(*)[8]: stdc_count_zeros_ull(val)) + +/* CSTYLED */ +#define stdc_count_ones(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_count_ones_uc(val), \ + char(*)[2]: stdc_count_ones_us(val), \ + char(*)[4]: stdc_count_ones_ui(val), \ + char(*)[8]: stdc_count_ones_ull(val)) + +/* CSTYLED */ +#define stdc_has_single_bit(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_has_single_bit_uc(val), \ + char(*)[2]: stdc_has_single_bit_us(val), \ + char(*)[4]: stdc_has_single_bit_ui(val), \ + char(*)[8]: stdc_has_single_bit_ull(val)) + +/* CSTYLED */ +#define stdc_bit_width(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_bit_width_uc(val), \ + char(*)[2]: stdc_bit_width_us(val), \ + char(*)[4]: stdc_bit_width_ui(val), \ + char(*)[8]: stdc_bit_width_ull(val)) + +/* CSTYLED */ +#define stdc_bit_floor(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_bit_floor_uc(val), \ + char(*)[2]: stdc_bit_floor_us(val), \ + char(*)[4]: stdc_bit_floor_ui(val), \ + char(*)[8]: stdc_bit_floor_ull(val)) + +/* CSTYLED */ +#define stdc_bit_ceil(val) _Generic((char(*)[sizeof (val)]){ 0 }, \ + char(*)[1]: stdc_bit_ceil_uc(val), \ + char(*)[2]: stdc_bit_ceil_us(val), \ + char(*)[4]: stdc_bit_ceil_ui(val), \ + char(*)[8]: stdc_bit_ceil_ull(val)) +#endif /* STDC_C11 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STDBIT_H */ diff --git a/illumos-x86_64/usr/include/sys/stdbool.h b/illumos-x86_64/usr/include/sys/stdbool.h new file mode 100644 index 00000000..6b3227c3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stdbool.h @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STDBOOL_H +#define _SYS_STDBOOL_H + +/* + * This header is included for alignment with the ISO/IEC 9899:1999 standard. + * The contents are only visible when using a c99 compiler. In the case of + * the Sun compiler, some C99 features, including the _Bool built-in type, + * are provided in the default compilation mode. This is a subset of what + * is provided when __STDC_VERSION__ is 199901; hence the contents of this + * header are made visible when either __STDC_VERSION__ >= 199901 (_STDC_C99 + * as defined in sys/feature_tests.h) or if __C99FEATURES__ (a Sun compiler + * built-in) is defined. Likewise for GNU C, support for C99 features, + * including this header, is provided in versions 3.0 or greater. In no + * case should the contents of this header be visible in a C++ build + * environment. + * + * Note that the ability to undefine and redefine the macros bool, + * true, and false is an obsolescent feature which may be withdrawn + * in a future version of the standards specifications. + */ + +#include + +#ifndef __cplusplus +#if defined(_STDC_C99) || defined(__C99FEATURES__) || __GNUC__ >= 3 + +#undef bool +#undef true +#undef false + +#define bool _Bool +#define true 1 +#define false 0 + +#define __bool_true_false_are_defined 1 + +#endif /* defined(_STDC_C99) || defined(__C99FEATURES__) || __GNUC__ >= 3 */ +#endif /* __cplusplus */ + +#endif /* !_SYS_STDBOOL_H */ diff --git a/illumos-x86_64/usr/include/sys/stddef.h b/illumos-x86_64/usr/include/sys/stddef.h new file mode 100644 index 00000000..99cadf39 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stddef.h @@ -0,0 +1,43 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 Toomas Soome + */ + +#ifndef _SYS_STDDEF_H +#define _SYS_STDDEF_H + +/* + * Commonly used macros and definitions. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(offsetof) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) +#define offsetof(s, m) __builtin_offsetof(s, m) +#else +#if __cplusplus >= 199711L +#define offsetof(s, m) (std::size_t)(&(((s *)NULL)->m)) +#else +#define offsetof(s, m) ((size_t)(&(((s *)NULL)->m))) +#endif +#endif +#endif /* !offsetof */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STDDEF_H */ diff --git a/illumos-x86_64/usr/include/sys/stdint.h b/illumos-x86_64/usr/include/sys/stdint.h new file mode 100644 index 00000000..ec165605 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stdint.h @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STDINT_H +#define _SYS_STDINT_H + +/* + * This header is included by which was introduced by + * the ISO C Standard, ISO/IEC 9899:1999 Programming language - C. + * The header is a subset of the header. + */ + +#include +#include +#include + +#endif /* _SYS_STDINT_H */ diff --git a/illumos-x86_64/usr/include/sys/stermio.h b/illumos-x86_64/usr/include/sys/stermio.h new file mode 100644 index 00000000..fe801f61 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stermio.h @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_STERMIO_H +#define _SYS_STERMIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ioctl commands for control channels + */ +#define STSTART 1 /* start protocol */ +#define STHALT 2 /* cease protocol */ +#define STPRINT 3 /* assign device to printer */ +#define STENABLE 4 /* enable polling */ +#define STDISABLE 5 /* disable polling */ +#define STPOLL 6 /* set polling rate */ +#define STCNTRS 7 /* poke for status reports */ +#define STTCHAN 8 /* set trace channel number */ + +/* + * ioctl commands for terminal and printer channels + */ +#define STGET (('X'<<8)|0) /* get line options */ +#define STSET (('X'<<8)|1) /* set line options */ +#define STTHROW (('X'<<8)|2) /* throw away queued input */ +#define STWLINE (('X'<<8)|3) /* get synchronous line # */ +#define STTSV (('X'<<8)|4) /* get all line information */ + +struct stio { + unsigned short ttyid; + char row; + char col; + char orow; + char ocol; + char tab; + char aid; + char ss1; + char ss2; + unsigned short imode; + unsigned short lmode; + unsigned short omode; +}; + +/* + * Mode Definitions. + */ +#define STFLUSH 00400 /* FLUSH mode; lmode */ +#define STWRAP 01000 /* WRAP mode; lmode */ +#define STAPPL 02000 /* APPLICATION mode; lmode */ + +struct sttsv { + char st_major; + short st_pcdnum; + char st_devaddr; + int st_csidev; +}; + +struct stcntrs { + char st_lrc; + char st_xnaks; + char st_rnaks; + char st_xwaks; + char st_rwaks; + char st_scc; +}; + +/* trace message definitions */ + +#define LOC 113 /* loss of carrier */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STERMIO_H */ diff --git a/illumos-x86_64/usr/include/sys/stmf.h b/illumos-x86_64/usr/include/sys/stmf.h new file mode 100644 index 00000000..76f378b2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stmf.h @@ -0,0 +1,435 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. + */ + +#ifndef _STMF_H +#define _STMF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum stmf_struct_id { + STMF_STRUCT_LU_PROVIDER = 1, + STMF_STRUCT_PORT_PROVIDER, + STMF_STRUCT_STMF_LOCAL_PORT, + STMF_STRUCT_STMF_LU, + STMF_STRUCT_SCSI_SESSION, + STMF_STRUCT_SCSI_TASK, + STMF_STRUCT_DATA_BUF, + STMF_STRUCT_DBUF_STORE, + STMF_MAX_STRUCT_IDS +} stmf_struct_id_t; + +/* + * Provider callback commands + */ +#define STMF_PROVIDER_DATA_UPDATED 0x01 + +/* + * Provider callback flags + */ +#define STMF_PCB_STMF_ONLINING 0x0001 +#define STMF_PCB_PREG_COMPLETE 0x0002 + +typedef void *data_seg_handle_t; +#define STMF_MAX_LU_CACHE_NTASKS 16 + +#define STMF_NO_HANDLE 0xffffffff + +#define COMPANY_ID_NONE 0xFFFFFFFF +#define COMPANY_ID_SUN 0x00144F + +/* + * The scatter/gather list buffer format is used in 2 different + * contexts within stmf: + * 1) supplied by the port provider that the LU provider uses to exchange + * data with the backing store. + * 2) supplied by the LU provider that the port provider uses exchange + * data with the host initiator. + * The second format is optionally supported by the port provided as + * indicated by the command task flags. + */ + +typedef struct stmf_sglist_ent { + uint32_t seg_length; + uint8_t *seg_addr; +} stmf_sglist_ent_t; + +typedef struct stmf_data_buf { + void *db_stmf_private; + void *db_port_private; + void *db_lu_private; + uint32_t db_buf_size; /* Total size of this buffer */ + uint32_t db_data_size; /* Intended xfer size of this buffer */ + uint32_t db_relative_offset; + uint16_t db_sglist_length; + uint16_t db_flags; /* Direction, auto status etc */ + stmf_status_t db_xfer_status; + uint8_t db_handle; /* To track parallel buffers */ + hrtime_t db_xfer_start_timestamp; + stmf_sglist_ent_t db_sglist[1]; /* PP scatter/gather list */ +} stmf_data_buf_t; + +/* + * db_flags + */ +#define DB_DIRECTION_TO_RPORT 0x0001 +#define DB_DIRECTION_FROM_RPORT 0x0002 +#define DB_SEND_STATUS_GOOD 0x0004 +#define DB_STATUS_GOOD_SENT 0x0008 +#define DB_DONT_CACHE 0x0010 +#define DB_DONT_REUSE 0x0020 +#define DB_LU_DATA_BUF 0x0040 +#define DB_LPORT_XFER_ACTIVE 0x8000 + +typedef struct scsi_task { + void *task_stmf_private; + void *task_port_private; + + void *task_lu_private; + struct stmf_scsi_session *task_session; + struct stmf_local_port *task_lport; + struct stmf_lu *task_lu; + void *task_lu_itl_handle; /* Assigned by LU */ + + /* CMD information from initiator */ + uint8_t task_lun_no[8]; + uint8_t task_flags; /* See def. for task flags */ + uint8_t task_priority; /* As per SAM-3 */ + uint8_t task_mgmt_function; /* If this is a TM request */ + uint8_t task_max_nbufs; + uint8_t task_cur_nbufs; + uint8_t task_csn_size; /* cmd seq no size in bits */ + uint16_t task_additional_flags; + uint32_t task_cmd_seq_no; + uint32_t task_expected_xfer_length; + uint32_t task_timeout; /* In seconds */ + uint16_t task_ext_id; + uint16_t task_cdb_length; + uint8_t *task_cdb; + + /* Fields to manage data phase */ + uint32_t task_cmd_xfer_length; /* xfer len based on CDB */ + uint32_t task_nbytes_transferred; + uint32_t task_max_xfer_len; /* largest xfer allowed */ + uint32_t task_1st_xfer_len; /* 1st xfer hint */ + uint32_t task_copy_threshold; /* copy reduction threshold */ + + + /* Status Phase */ + stmf_status_t task_completion_status; + uint32_t task_resid; + uint8_t task_status_ctrl; /* See def. for status ctrl */ + uint8_t task_scsi_status; + uint16_t task_sense_length; + uint8_t *task_sense_data; + + /* Misc. task data */ + void *task_extended_cmd; + +} scsi_task_t; + +/* + * Maximum expected transfer length. Can also be used when the transfer + * length is unknown when the task is allocated (e.g. SAS) + */ + +#define TASK_MAX_XFER_LENGTH 0xFFFFFFFF + +/* + * task_flags definitions. + */ +/* + * If TF_INITIAL_BURST is set, the dbuf passed with new_task() contains + * data from initial burst. Otherwise its just a buffer which the port + * passed to the LU. + */ +#define TF_INITIAL_BURST 0x80 +/* Both READ_DATA and WRITE_DATA can be set for bidirectional xfers */ +#define TF_READ_DATA 0x40 +#define TF_WRITE_DATA 0x20 +#define TF_ATTR_MASK 0x07 +#define TF_ATTR_UNTAGGED 0x0 +#define TF_ATTR_SIMPLE_QUEUE 0x1 +#define TF_ATTR_ORDERED_QUEUE 0x2 +#define TF_ATTR_HEAD_OF_QUEUE 0x3 +#define TF_ATTR_ACA 0x4 + +/* + * Task Management flags. + */ +#define TM_NONE 0x00 +#define TM_ABORT_TASK 0x01 +#define TM_ABORT_TASK_SET 0x02 +#define TM_CLEAR_ACA 0x03 +#define TM_CLEAR_TASK_SET 0x04 +#define TM_LUN_RESET 0x05 +#define TM_TARGET_WARM_RESET 0x06 +#define TM_TARGET_COLD_RESET 0x07 +#define TM_TASK_REASSIGN 0x08 +#define TM_TARGET_RESET 0x09 +#define TM_QUERY_TASK 0x0A + +/* + * additional flags + */ +#define TASK_AF_ENABLE_COMP_CONF 0x01 +#define TASK_AF_PORT_LOAD_HIGH 0x02 +#define TASK_AF_NO_EXPECTED_XFER_LENGTH 0x04 +/* + * PP sets this flag if it can process dbufs created by the LU. + */ +#define TASK_AF_ACCEPT_LU_DBUF 0x08 + +/* + * Indicating a PPPT task + */ +#define TASK_AF_PPPT_TASK 0x10 + +/* + * scsi_task_t extension identifiers + */ +#define STMF_TASK_EXT_NONE 0 + +/* + * max_nbufs + */ +#define STMF_BUFS_MAX 255 + +/* + * Task status ctrl + */ +#define TASK_SCTRL_OVER 1 +#define TASK_SCTRL_UNDER 2 + +/* + * The flags used by I/O flow. + */ +#define STMF_IOF_LU_DONE 0x0001 +#define STMF_IOF_LPORT_DONE 0x0002 +#define STMF_IOF_STATS_ONLY 0x0004 + +/* + * struct allocation flags + */ +#define AF_FORCE_NOSLEEP 0x0001 +#define AF_DONTZERO 0x0002 + +typedef struct stmf_state_change_info { + uint64_t st_rflags; /* Reason behind this change */ + char *st_additional_info; +} stmf_state_change_info_t; + +typedef struct stmf_change_status { + stmf_status_t st_completion_status; + char *st_additional_info; +} stmf_change_status_t; + +/* + * conditions causing or affecting the change. + */ +#define STMF_RFLAG_USER_REQUEST 0x0001 +#define STMF_RFLAG_FATAL_ERROR 0x0002 +#define STMF_RFLAG_STAY_OFFLINED 0x0004 +#define STMF_RFLAG_RESET 0x0008 +#define STMF_RFLAG_COLLECT_DEBUG_DUMP 0x0010 +#define STMF_RFLAG_LU_ABORT 0x0020 +#define STMF_RFLAG_LPORT_ABORT 0x0040 + +#define STMF_CHANGE_INFO_LEN 160 + +/* + * cmds to stmf_abort entry point + */ +#define STMF_QUEUE_TASK_ABORT 1 +#define STMF_REQUEUE_TASK_ABORT_LPORT 2 +#define STMF_REQUEUE_TASK_ABORT_LU 3 +#define STMF_QUEUE_ABORT_LU 4 + +/* + * cmds to be used by stmf ctl + */ +#define STMF_CMD_LU_OP 0x0100 +#define STMF_CMD_LPORT_OP 0x0200 +#define STMF_CMD_MASK 0x00ff +#define STMF_CMD_ONLINE 0x0001 +#define STMF_CMD_OFFLINE 0x0002 +#define STMF_CMD_GET_STATUS 0x0003 +#define STMF_CMD_ONLINE_COMPLETE 0x0004 +#define STMF_CMD_OFFLINE_COMPLETE 0x0005 +#define STMF_ACK_ONLINE_COMPLETE 0x0006 +#define STMF_ACK_OFFLINE_COMPLETE 0x0007 + +#define STMF_CMD_LU_ONLINE (STMF_CMD_LU_OP | STMF_CMD_ONLINE) +#define STMF_CMD_LU_OFFLINE (STMF_CMD_LU_OP | STMF_CMD_OFFLINE) +#define STMF_CMD_LPORT_ONLINE (STMF_CMD_LPORT_OP | STMF_CMD_ONLINE) +#define STMF_CMD_LPORT_OFFLINE (STMF_CMD_LPORT_OP | STMF_CMD_OFFLINE) +#define STMF_CMD_GET_LU_STATUS (STMF_CMD_LU_OP | STMF_CMD_GET_STATUS) +#define STMF_CMD_GET_LPORT_STATUS \ + (STMF_CMD_LPORT_OP | STMF_CMD_GET_STATUS) +#define STMF_CMD_LU_ONLINE_COMPLETE \ + (STMF_CMD_LU_OP | STMF_CMD_ONLINE_COMPLETE) +#define STMF_CMD_LPORT_ONLINE_COMPLETE \ + (STMF_CMD_LPORT_OP | STMF_CMD_ONLINE_COMPLETE) +#define STMF_ACK_LU_ONLINE_COMPLETE \ + (STMF_CMD_LU_OP | STMF_ACK_ONLINE_COMPLETE) +#define STMF_ACK_LPORT_ONLINE_COMPLETE \ + (STMF_CMD_LPORT_OP | STMF_ACK_ONLINE_COMPLETE) +#define STMF_CMD_LU_OFFLINE_COMPLETE \ + (STMF_CMD_LU_OP | STMF_CMD_OFFLINE_COMPLETE) +#define STMF_CMD_LPORT_OFFLINE_COMPLETE \ + (STMF_CMD_LPORT_OP | STMF_CMD_OFFLINE_COMPLETE) +#define STMF_ACK_LU_OFFLINE_COMPLETE \ + (STMF_CMD_LU_OP | STMF_ACK_OFFLINE_COMPLETE) +#define STMF_ACK_LPORT_OFFLINE_COMPLETE \ + (STMF_CMD_LPORT_OP | STMF_ACK_OFFLINE_COMPLETE) +/* + * For LPORTs and LUs to create their own ctl cmds which dont + * conflict with stmf ctl cmds. + */ +#define STMF_LPORT_CTL_CMDS 0x1000 +#define STMF_LU_CTL_CMDS 0x2000 + +/* + * Commands for various info routines. + */ +/* Command classifiers */ +#define SI_LPORT 0x1000000 +#define SI_STMF 0x2000000 +#define SI_LU 0x4000000 +#define SI_LPORT_FC 0x0000000 +#define SI_LPORT_ISCSI 0x0010000 +#define SI_LPORT_SAS 0x0020000 +#define SI_STMF_LU 0x0010000 +#define SI_STMF_LPORT 0x0020000 + +#define SI_GET_CLASS(v) ((v) & 0xFF000000) +#define SI_GET_SUBCLASS(v) ((v) & 0x00FF0000) + +/* Commands for LPORT info routines */ +/* XXX - Implement these. */ +#if 0 +#define SI_LPORT_FC_PORTINFO (SI_LPORT | SI_LPORT_FC | 1) +#define SI_RPORT_FC_PORTINFO (SI_LPORT | SI_LPORT_FC | 2) +#endif + +/* + * Events + */ +#define STMF_EVENT_ALL ((int)-1) +#define LPORT_EVENT_INITIAL_LUN_MAPPED 0 + +/* + * This needs to go into common/ddi/sunddi.h + */ +#define DDI_NT_STMF "ddi_scsi_target:framework" +#define DDI_NT_STMF_LP "ddi_scsi_target:lu_provider" +#define DDI_NT_STMF_PP "ddi_scsi_target:port_provider" + +/* + * VPD page bits. + */ +#define STMF_VPD_LU_ID 0x01 +#define STMF_VPD_TARGET_ID 0x02 +#define STMF_VPD_TP_GROUP 0x04 +#define STMF_VPD_RELATIVE_TP_ID 0x08 + +/* + * Common macros to simplify coding + */ +#define STMF_SEC2TICK(x_sec) (drv_usectohz((x_sec) * 1000000)) + +void stmf_trace(caddr_t ident, const char *fmt, ...); +void *stmf_alloc(stmf_struct_id_t sid, int additional_size, int alloc_flags); +void stmf_free(void *struct_ptr); +struct scsi_task *stmf_task_alloc(struct stmf_local_port *lport, + struct stmf_scsi_session *ss, uint8_t *lun, uint16_t cdb_length, + uint16_t ext_id); +void stmf_post_task(scsi_task_t *task, stmf_data_buf_t *dbuf); +stmf_data_buf_t *stmf_alloc_dbuf(scsi_task_t *task, uint32_t size, + uint32_t *pminsize, uint32_t flags); +void stmf_free_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf); +stmf_status_t stmf_setup_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf, + uint32_t flags); +void stmf_teardown_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf); +stmf_status_t stmf_xfer_data(scsi_task_t *task, stmf_data_buf_t *dbuf, + uint32_t ioflags); +stmf_status_t stmf_send_scsi_status(scsi_task_t *task, uint32_t ioflags); +void stmf_data_xfer_done(scsi_task_t *task, stmf_data_buf_t *dbuf, + uint32_t iof); +void stmf_send_status_done(scsi_task_t *task, stmf_status_t s, uint32_t iof); +void stmf_task_lu_done(scsi_task_t *task); +void stmf_abort(int abort_cmd, scsi_task_t *task, stmf_status_t s, void *arg); +void stmf_task_lu_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof); +void stmf_task_lport_aborted_unlocked(scsi_task_t *task, stmf_status_t s, + uint32_t iof); +stmf_status_t stmf_task_poll_lu(scsi_task_t *task, uint32_t timeout); +stmf_status_t stmf_task_poll_lport(scsi_task_t *task, uint32_t timeout); +stmf_status_t stmf_ctl(int cmd, void *obj, void *arg); +stmf_status_t stmf_register_itl_handle(struct stmf_lu *lu, uint8_t *lun, + struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle); +stmf_status_t stmf_deregister_all_lu_itl_handles(struct stmf_lu *lu); +stmf_status_t stmf_get_itl_handle(struct stmf_lu *lu, uint8_t *lun, + struct stmf_scsi_session *ss, uint64_t session_id, void **itl_handle_retp); +stmf_data_buf_t *stmf_handle_to_buf(scsi_task_t *task, uint8_t h); +stmf_status_t stmf_lu_add_event(struct stmf_lu *lu, int eventid); +stmf_status_t stmf_lu_remove_event(struct stmf_lu *lu, int eventid); +stmf_status_t stmf_lport_add_event(struct stmf_local_port *lport, int eventid); +stmf_status_t stmf_lport_remove_event(struct stmf_local_port *lport, + int eventid); +void stmf_wwn_to_devid_desc(struct scsi_devid_desc *sdid, uint8_t *wwn, + uint8_t protocol_id); +stmf_status_t stmf_scsilib_uniq_lu_id(uint32_t company_id, + struct scsi_devid_desc *lu_id); +stmf_status_t stmf_scsilib_uniq_lu_id2(uint32_t company_id, uint32_t host_id, + struct scsi_devid_desc *lu_id); +void stmf_scsilib_send_status(scsi_task_t *task, uint8_t st, uint32_t saa); +uint32_t stmf_scsilib_prepare_vpd_page83(scsi_task_t *task, uint8_t *page, + uint32_t page_len, uint8_t byte0, uint32_t vpd_mask); +uint16_t stmf_scsilib_get_lport_rtid(struct scsi_devid_desc *devid); +struct scsi_devid_desc *stmf_scsilib_get_devid_desc(uint16_t rtpid); +void stmf_scsilib_handle_report_tpgs(scsi_task_t *task, stmf_data_buf_t *dbuf); +void stmf_scsilib_handle_task_mgmt(scsi_task_t *task); + +struct stmf_remote_port *stmf_scsilib_devid_to_remote_port( + struct scsi_devid_desc *); +boolean_t stmf_scsilib_tptid_validate(struct scsi_transport_id *, + uint32_t, uint16_t *); +boolean_t stmf_scsilib_tptid_compare(struct scsi_transport_id *, + struct scsi_transport_id *); +struct stmf_remote_port *stmf_remote_port_alloc(uint16_t); +void stmf_remote_port_free(struct stmf_remote_port *); +struct stmf_lu *stmf_check_and_hold_lu(struct scsi_task *task, uint8_t *guid); +void stmf_release_lu(struct stmf_lu *lu); +int stmf_is_task_being_aborted(struct scsi_task *task); +#ifdef __cplusplus +} +#endif + +#endif /* _STMF_H */ diff --git a/illumos-x86_64/usr/include/sys/stmf_defines.h b/illumos-x86_64/usr/include/sys/stmf_defines.h new file mode 100644 index 00000000..0fbab945 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stmf_defines.h @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ +#ifndef _STMF_DEFINES_H +#define _STMF_DEFINES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define BIT_0 0x1 +#define BIT_1 0x2 +#define BIT_2 0x4 +#define BIT_3 0x8 +#define BIT_4 0x10 +#define BIT_5 0x20 +#define BIT_6 0x40 +#define BIT_7 0x80 +#define BIT_8 0x100 +#define BIT_9 0x200 +#define BIT_10 0x400 +#define BIT_11 0x800 +#define BIT_12 0x1000 +#define BIT_13 0x2000 +#define BIT_14 0x4000 +#define BIT_15 0x8000 +#define BIT_16 0x10000 +#define BIT_17 0x20000 +#define BIT_18 0x40000 +#define BIT_19 0x80000 +#define BIT_20 0x100000 +#define BIT_21 0x200000 +#define BIT_22 0x400000 +#define BIT_23 0x800000 +#define BIT_24 0x1000000 +#define BIT_25 0x2000000 +#define BIT_26 0x4000000 +#define BIT_27 0x8000000 +#define BIT_28 0x10000000 +#define BIT_29 0x20000000 +#define BIT_30 0x40000000 +#define BIT_31 0x80000000 + +/* + * stmf status definitions + */ +typedef uint64_t stmf_status_t; +#define STMF_SUCCESS ((uint64_t)0) +#define STMF_FAILURE ((uint64_t)0x1000000000000000) +#define STMF_TARGET_FAILURE ((uint64_t)0x2000000000000000) +#define STMF_LU_FAILURE ((uint64_t)0x3000000000000000) +#define STMF_FSC(x) (((uint64_t)(x)) << 32) +#define STMF_GET_FSC(x) ((((uint64_t)(x)) >> 32) & 0xFFFFFF) +#define STMF_RETRY_BIT ((uint64_t)0x0080000000000000) +#define STMF_BUSY (STMF_FAILURE | STMF_RETRY_BIT | STMF_FSC(0)) +#define STMF_NOT_FOUND (STMF_FAILURE | STMF_FSC(1)) +#define STMF_INVALID_ARG (STMF_FAILURE | STMF_FSC(2)) +#define STMF_LUN_TAKEN (STMF_FAILURE | STMF_FSC(3)) +#define STMF_ABORTED (STMF_FAILURE | STMF_FSC(5)) +#define STMF_ABORT_SUCCESS (STMF_FAILURE | STMF_FSC(6)) +#define STMF_ALLOC_FAILURE (STMF_FAILURE | STMF_FSC(7)) +#define STMF_ALREADY (STMF_FAILURE | STMF_FSC(8)) +#define STMF_TIMEOUT (STMF_FAILURE | STMF_FSC(9)) +#define STMF_NOT_SUPPORTED (STMF_FAILURE | STMF_FSC(10)) +#define STMF_BADSTATE (STMF_FAILURE | STMF_FSC(11)) + +#define GET_BYTE_OFFSET(ptr, off) (((uint8_t *)(ptr)) + (off)) +#define GET_STRUCT_SIZE(s) ((sizeof (s) + 7) & 0xfffffff8) +#define READ_SCSI16(addr, type) ((((type)(((uint8_t *)(addr))[0])) \ + << 8) |\ + ((type)(((uint8_t *)(addr))[1]))) +#define READ_SCSI21(addr, type) ((((type)(((uint8_t *)(addr))[0] & \ + 0x1F)) << 16)\ + | (READ_SCSI16(addr+1, type))) +#define READ_SCSI32(addr, type) (((READ_SCSI16(addr, type)) << 16) |\ + (READ_SCSI16((addr+2), type))) +#define READ_SCSI64(addr, type) (((READ_SCSI32(addr, type)) << 32) |\ + (READ_SCSI32((addr+4), type))) +#define PTR2INT(p, t) ((t)((ulong_t)(p))) +#define INT2PTR(i, t) ((t)((ulong_t)(i))) + +/* + * CDB definitions that don't exist in commands.h + */ +#define SCMD_SYNCHRONIZE_CACHE_G4 0x91 + +/* + * Common key, asc, ascq for stmf_scsilib_send_status + */ +#define STMF_SAA_MEDIUM_NOT_PRESENT 0X023A00 +#define STMF_SAA_LU_NO_ACCESS_TRANSITION 0X02040A +#define STMF_SAA_LU_NO_ACCESS_STANDBY 0X02040B +#define STMF_SAA_LU_NO_ACCESS_UNAVAIL 0X02040C +#define STMF_SAA_WRITE_ERROR 0x030C00 +#define STMF_SAA_READ_ERROR 0x031100 +#define STMF_SAA_OPERATION_IN_PROGRESS 0x050016 +#define STMF_SAA_INVALID_FIELD_IN_CMD_IU 0x050E03 +#define STMF_SAA_PARAM_LIST_LENGTH_ERROR 0x051A00 +#define STMF_SAA_INVALID_OPCODE 0x052000 +#define STMF_SAA_INVALID_LU 0x052009 +#define STMF_SAA_LBA_OUT_OF_RANGE 0x052100 +#define STMF_SAA_INVALID_FIELD_IN_CDB 0x052400 +#define STMF_SAA_INVALID_FIELD_IN_PARAM_LIST 0x052600 +#define STMF_SAA_INVALID_RELEASE_OF_PR 0x052604 +#define STMF_SAA_MEDIUM_REMOVAL_PREVENTED 0x055302 +#define STMF_SAA_INSUFFICIENT_REG_RESRCS 0x055504 +#define STMF_SAA_POR 0x062900 +#define STMF_SAA_MODE_PARAMETERS_CHANGED 0x062A01 +#define STMF_SAA_ASYMMETRIC_ACCESS_CHANGED 0x062A06 +#define STMF_SAA_CAPACITY_DATA_HAS_CHANGED 0x062A09 +#define STMF_SAA_REPORT_LUN_DATA_HAS_CHANGED 0x063F0E +#define STMF_SAA_WRITE_PROTECTED 0X072700 + +struct stmf_lu_provider; +struct stmf_lu; +struct stmf_port_provider; +struct stmf_local_port; +struct stmf_remote_port; +struct stmf_scsi_session; +struct scsi_task; +struct scsi_devid_desc; +struct scsi_transport_id; +struct stmf_data_buf; +struct stmf_lun_map; +struct scsi_devid_desc; + +#ifdef __cplusplus +} +#endif + +#endif /* _STMF_DEFINES_H */ diff --git a/illumos-x86_64/usr/include/sys/stmf_ioctl.h b/illumos-x86_64/usr/include/sys/stmf_ioctl.h new file mode 100644 index 00000000..d28129ca --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stmf_ioctl.h @@ -0,0 +1,297 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + */ +#ifndef _STMF_IOCTL_H +#define _STMF_IOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define STMF_VERSION_1 1 + +#define STMF_IOCTL (((uint32_t)'S') << 24) +#define STMF_IOCTL_LU_LIST (STMF_IOCTL | 1) +#define STMF_IOCTL_TARGET_PORT_LIST (STMF_IOCTL | 2) +#define STMF_IOCTL_SESSION_LIST (STMF_IOCTL | 3) +#define STMF_IOCTL_GET_LU_PROPERTIES (STMF_IOCTL | 4) +#define STMF_IOCTL_GET_TARGET_PORT_PROPERTIES (STMF_IOCTL | 5) +#define STMF_IOCTL_SET_STMF_STATE (STMF_IOCTL | 6) +#define STMF_IOCTL_GET_STMF_STATE (STMF_IOCTL | 7) +#define STMF_IOCTL_SET_LU_STATE (STMF_IOCTL | 8) +#define STMF_IOCTL_SET_TARGET_PORT_STATE (STMF_IOCTL | 9) +#define STMF_IOCTL_CREATE_HOST_GROUP (STMF_IOCTL | 10) +#define STMF_IOCTL_REMOVE_HOST_GROUP (STMF_IOCTL | 11) +#define STMF_IOCTL_ADD_HG_ENTRY (STMF_IOCTL | 12) +#define STMF_IOCTL_REMOVE_HG_ENTRY (STMF_IOCTL | 13) +#define STMF_IOCTL_CREATE_TARGET_GROUP (STMF_IOCTL | 14) +#define STMF_IOCTL_REMOVE_TARGET_GROUP (STMF_IOCTL | 15) +#define STMF_IOCTL_ADD_TG_ENTRY (STMF_IOCTL | 16) +#define STMF_IOCTL_REMOVE_TG_ENTRY (STMF_IOCTL | 17) +#define STMF_IOCTL_ADD_VIEW_ENTRY (STMF_IOCTL | 18) +#define STMF_IOCTL_REMOVE_VIEW_ENTRY (STMF_IOCTL | 19) +#define STMF_IOCTL_GET_HG_LIST (STMF_IOCTL | 20) +#define STMF_IOCTL_GET_TG_LIST (STMF_IOCTL | 21) +#define STMF_IOCTL_GET_HG_ENTRIES (STMF_IOCTL | 22) +#define STMF_IOCTL_GET_TG_ENTRIES (STMF_IOCTL | 23) +#define STMF_IOCTL_GET_VE_LIST (STMF_IOCTL | 24) +#define STMF_IOCTL_LOAD_PP_DATA (STMF_IOCTL | 25) +#define STMF_IOCTL_CLEAR_PP_DATA (STMF_IOCTL | 26) +#define STMF_IOCTL_GET_PP_DATA (STMF_IOCTL | 27) +#define STMF_IOCTL_CLEAR_TRACE (STMF_IOCTL | 28) +#define STMF_IOCTL_ADD_TRACE (STMF_IOCTL | 29) +#define STMF_IOCTL_GET_TRACE_POSITION (STMF_IOCTL | 30) +#define STMF_IOCTL_GET_TRACE (STMF_IOCTL | 31) +#define STMF_IOCTL_REG_LU_LIST (STMF_IOCTL | 32) +#define STMF_IOCTL_VE_LU_LIST (STMF_IOCTL | 33) +#define STMF_IOCTL_LU_VE_LIST (STMF_IOCTL | 34) +#define STMF_IOCTL_VALIDATE_VIEW (STMF_IOCTL | 35) +#define STMF_IOCTL_SET_ALUA_STATE (STMF_IOCTL | 36) +#define STMF_IOCTL_GET_ALUA_STATE (STMF_IOCTL | 37) +#define STMF_IOCTL_SET_STMF_PROPS (STMF_IOCTL | 38) + +typedef struct stmf_iocdata { + uint32_t stmf_version; + uint32_t stmf_error; + uint32_t stmf_ibuf_size; + uint32_t stmf_obuf_size; + uint32_t stmf_obuf_nentries; /* # entries xferred */ + uint32_t stmf_obuf_max_nentries; /* #,could have been xferred */ + uint64_t stmf_ibuf; + uint64_t stmf_obuf; +} stmf_iocdata_t; + +typedef struct slist_lu { + uint8_t lu_guid[16]; +} slist_lu_t; + +typedef struct slist_target_port { + uint8_t target[260]; +} slist_target_port_t; + +typedef struct slist_scsi_session { + uint8_t initiator[260]; + /* creation_time is really time_t. But time_t is defined as long. */ + uint32_t creation_time; + char alias[256]; +} slist_scsi_session_t; + +/* + * States for LUs and LPORTs + */ +#define STMF_STATE_OFFLINE 0 +#define STMF_STATE_ONLINING 1 +#define STMF_STATE_ONLINE 2 +#define STMF_STATE_OFFLINING 3 + +/* + * States for the STMF config. + */ +#define STMF_CONFIG_NONE 0 +#define STMF_CONFIG_INIT 1 +#define STMF_CONFIG_INIT_DONE 2 + +typedef struct sioc_lu_props { + uint8_t lu_guid[16]; + uint8_t lu_state:4, + lu_present:1, + lu_rsvd:3; + char lu_provider_name[255]; + char lu_alias[256]; +} sioc_lu_props_t; + +typedef struct sioc_target_port_props { + uint8_t tgt_id[260]; + uint8_t tgt_state:4, + tgt_present:1, + tgt_rsvd:3; + char tgt_provider_name[255]; + char tgt_alias[256]; +} sioc_target_port_props_t; + +/* + * This struct is used for getting and setting state of LU/LPORT or STMF. + */ +typedef struct stmf_state_desc { + uint8_t ident[260]; /* N/A for STMF itself */ + uint8_t state; + uint8_t config_state; /* N/A for LU/LPORTs */ +} stmf_state_desc_t; + +/* + * This struct is used for setting the alua state + */ +typedef struct stmf_alua_state_desc { + uint8_t alua_state; + uint16_t alua_node; +} stmf_alua_state_desc_t; + +/* Error definitions for group/view entry/provider dataioctls */ +#define STMF_IOCERR_NONE 0 +#define STMF_IOCERR_HG_EXISTS 1 +#define STMF_IOCERR_INVALID_HG 2 +#define STMF_IOCERR_TG_EXISTS 3 +#define STMF_IOCERR_INVALID_TG 4 +#define STMF_IOCERR_HG_ENTRY_EXISTS 5 +#define STMF_IOCERR_INVALID_HG_ENTRY 6 +#define STMF_IOCERR_TG_ENTRY_EXISTS 7 +#define STMF_IOCERR_INVALID_TG_ENTRY 8 +#define STMF_IOCERR_TG_UPDATE_NEED_SVC_OFFLINE 9 +#define STMF_IOCERR_LU_NUMBER_IN_USE 10 +#define STMF_IOCERR_INVALID_LU_ID 11 +#define STMF_IOCERR_VIEW_ENTRY_CONFLICT 12 +#define STMF_IOCERR_HG_IN_USE 13 +#define STMF_IOCERR_TG_IN_USE 14 +#define STMF_IOCERR_INVALID_VIEW_ENTRY 15 +#define STMF_IOCERR_INVALID_VE_ID 16 +#define STMF_IOCERR_UPDATE_NEED_CFG_INIT 17 +#define STMF_IOCERR_PPD_UPDATED 18 +#define STMF_IOCERR_INSUFFICIENT_BUF 19 +#define STMF_IOCERR_TG_NEED_TG_OFFLINE 20 + + +typedef struct stmf_group_name { + uint16_t name_size; /* in bytes */ + uint16_t rsvd_1; + uint32_t rsvd_2; + uint8_t name[512]; /* 256 * wchar_t */ +} stmf_group_name_t; + +/* + * struct used to operate (add/remove entry) on a group. + */ + +typedef struct stmf_ge_ident { + uint16_t ident_size; + uint8_t ident[256]; +} stmf_ge_ident_t; + +typedef struct stmf_group_op_data { + stmf_group_name_t group; + uint8_t ident[260]; +} stmf_group_op_data_t; + +typedef struct stmf_view_op_entry { + uint32_t ve_ndx_valid:1, + ve_lu_number_valid:1, + ve_all_hosts:1, + ve_all_targets:1, + rsvd:28; + uint32_t ve_ndx; + uint8_t ve_lu_nbr[8]; + uint8_t ve_guid[16]; + stmf_group_name_t ve_host_group; + stmf_group_name_t ve_target_group; +} stmf_view_op_entry_t; + +typedef struct stmf_ppioctl_data { + char ppi_name[255]; /* Provider name including \0 */ + uint8_t ppi_port_provider:1, + ppi_lu_provider:1, + ppi_token_valid:1, + ppt_rsvd:5; + uint64_t ppi_token; + uint64_t ppi_data_size; + uint8_t ppi_data[8]; +} stmf_ppioctl_data_t; + +typedef struct stmf_set_props { + uint32_t default_lu_state_value; + uint32_t default_target_state_value; +} stmf_set_props_t; + +/* + * SCSI device ID descriptor as per SPC3 7.6.3 + */ +typedef struct scsi_devid_desc { +#ifdef _BIT_FIELDS_HTOL + uint8_t protocol_id:4, + code_set:4; + uint8_t piv:1, + rsvd1:1, + association:2, + ident_type:4; +#else + uint8_t code_set:4, + protocol_id:4; + uint8_t ident_type:4, + association:2, + rsvd1:1, + piv:1; +#endif + uint8_t rsvd2; + uint8_t ident_length; + uint8_t ident[1]; +} scsi_devid_desc_t; + +/* + * Protocol Identifier + */ +#define PROTOCOL_FIBRE_CHANNEL 0 +#define PROTOCOL_PARALLEL_SCSI 1 +#define PROTOCOL_SSA 2 +#define PROTOCOL_IEEE_1394 3 +#define PROTOCOL_SRP 4 +#define PROTOCOL_iSCSI 5 +#define PROTOCOL_SAS 6 +#define PROTOCOL_ADT 7 +#define PROTOCOL_ATAPI 8 +#define PROTOCOL_ANY 15 + +/* + * Code set definitions + */ +#define CODE_SET_BINARY 1 +#define CODE_SET_ASCII 2 +#define CODE_SET_UTF8 3 + +/* + * Association values + */ +#define ID_IS_LOGICAL_UNIT 0 +#define ID_IS_TARGET_PORT 1 +#define ID_IS_TARGET_CONTAINING_LU 2 + +/* + * ident type + */ +#define ID_TYPE_VENDOR_SPECIFIC 0 +#define ID_TYPE_T10_VID 1 +#define ID_TYPE_EUI64 2 +#define ID_TYPE_NAA 3 +#define ID_TYPE_RELATIVE_TARGET_PORT 4 +#define ID_TYPE_TARGET_PORT_GROUP 5 +#define ID_TYPE_LOGICAL_UNIT_GROUP 6 +#define ID_TYPE_MD5_LOGICAL_UNIT 7 +#define ID_TYPE_SCSI_NAME_STRING 8 + +int stmf_copyin_iocdata(intptr_t data, int mode, stmf_iocdata_t **iocd, + void **ibuf, void **obuf); +int stmf_copyout_iocdata(intptr_t data, int mode, stmf_iocdata_t *iocd, + void *obuf); + +#ifdef __cplusplus +} +#endif + +#endif /* _STMF_IOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/stream.h b/illumos-x86_64/usr/include/sys/stream.h new file mode 100644 index 00000000..7d118b09 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stream.h @@ -0,0 +1,863 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent, Inc. All rights reserved. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2015 Joyent, Inc. All rights reserved. + * Copyright 2022 Garrett D'Amore + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_STREAM_H +#define _SYS_STREAM_H + +/* + * For source compatibility + */ +#include +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#include +#include +#endif +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Data queue. + * + * NOTE: The *only* public fields are documented in queue(9S). + * Everything else is implementation-private. + * + * The locking rules for the queue_t structure are extremely subtle and vary + * widely depending on the field in question. As such, each field is + * annotated according to the following legend: + * + * Q9S: The field is documented in queue(9S) and may be accessed without + * locks by a STREAMS module when inside an entry point (e.g., put(9E)). + * However, no fields can be directly modified unless q_lock is held + * (which is not possible in a DDI compliant STREAMS module), with the + * following exceptions: + * + * - q_ptr: can be modified as per the rules of the STREAMS module. + * The STREAMS framework ignores q_ptr and thus imposes *no* + * locking rules on it. + * - q_qinfo: can be modified before qprocson(). + * + * - q_minpsz, q_maxpsz, q_hiwat, q_lowat: can be modified as per the + * rules of the STREAMS module. The STREAMS framework never + * modifies these fields, and is tolerant of temporarily + * stale field values. + * + * In general, the STREAMS framework employs one of the following + * techniques to ensure STREAMS modules can safely access Q9S fields: + * + * - The field is only modified by the framework when the stream is + * locked with strlock() (q_next). + * + * - The field is modified by the framework, but the modifies are + * atomic, and temporarily stale values are harmless (q_count, + * q_first, q_last). + * + * - The field is modified by the framework, but the field's visible + * values are either constant or directly under the control + * of the STREAMS module itself (q_flag). + * + * QLK: The field must be accessed or modified under q_lock, except when + * the stream has been locked with strlock(). If multiple q_locks must + * be acquired, q_locks at higher addresses must be taken first. + * + * STR: The field can be accessed without a lock, but must be modified under + * strlock(). + * + * SQLK: The field must be accessed or modified under SQLOCK(). + * + * NOLK: The field can be accessed without a lock, but can only be modified + * when the queue_t is not known to any other threads. + * + * SVLK: The field must be accessed or modified under the service_queue lock. + * Note that service_lock must be taken after any needed q_locks, + * and that no other lock should be taken while service_lock is held. + * + * In addition, it is always acceptable to modify a field that is not yet + * known to any other threads -- and other special case exceptions exist in + * the code. Also, q_lock is used with q_wait to implement a stream head + * monitor for reads and writes. + */ +typedef struct queue { + struct qinit *q_qinfo; /* Q9S: Q processing procedure */ + struct msgb *q_first; /* Q9S: first message in Q */ + struct msgb *q_last; /* Q9S: last message in Q */ + struct queue *q_next; /* Q9S: next Q in stream */ + struct queue *q_link; /* SVLK: next Q for scheduling */ + void *q_ptr; /* Q9S: module-specific data */ + size_t q_count; /* Q9S: number of bytes on Q */ + uint_t q_flag; /* Q9S: Q state */ + ssize_t q_minpsz; /* Q9S: smallest packet OK on Q */ + ssize_t q_maxpsz; /* Q9S: largest packet OK on Q */ + size_t q_hiwat; /* Q9S: Q high water mark */ + size_t q_lowat; /* Q9S: Q low water mark */ + struct qband *q_bandp; /* QLK: band flow information */ + kmutex_t q_lock; /* NOLK: structure lock */ + struct stdata *q_stream; /* NOLK: stream backpointer */ + struct syncq *q_syncq; /* NOLK: associated syncq */ + unsigned char q_nband; /* QLK: number of bands */ + kcondvar_t q_wait; /* NOLK: read/write sleep CV */ + struct queue *q_nfsrv; /* STR: next Q with svc routine */ + ushort_t q_draining; /* QLK: Q is draining */ + short q_struiot; /* QLK: sync streams Q UIO mode */ + clock_t q_qtstamp; /* QLK: when Q was enabled */ + size_t q_mblkcnt; /* QLK: mblk count */ + uint_t q_syncqmsgs; /* QLK: syncq message count */ + size_t q_rwcnt; /* QLK: # threads in rwnext() */ + pri_t q_spri; /* QLK: Q scheduling priority */ + + /* + * Syncq scheduling + */ + struct msgb *q_sqhead; /* QLK: first syncq message */ + struct msgb *q_sqtail; /* QLK: last syncq message */ + struct queue *q_sqnext; /* SQLK: next Q on syncq list */ + struct queue *q_sqprev; /* SQLK: prev Q on syncq list */ + uint_t q_sqflags; /* SQLK: syncq flags */ + clock_t q_sqtstamp; /* SQLK: when Q was scheduled for sq */ + + /* + * NOLK: Reference to the queue's module's implementation + * structure. This will be NULL for queues associated with drivers. + */ + struct fmodsw_impl *q_fp; +} queue_t; + +/* + * Queue flags; unused flags not documented in queue(9S) can be recycled. + */ +#define QENAB 0x00000001 /* Queue is already enabled to run */ +#define QWANTR 0x00000002 /* Someone wants to read Q */ +#define QWANTW 0x00000004 /* Someone wants to write Q */ +#define QFULL 0x00000008 /* Q is considered full */ +#define QREADR 0x00000010 /* This is the reader (first) Q */ +#define QUSE 0x00000020 /* This queue in use (allocation) */ +#define QNOENB 0x00000040 /* Don't enable Q via putq */ +#define QWANTRMQSYNC 0x00000080 /* Want to remove sync stream Q */ +#define QBACK 0x00000100 /* queue has been back-enabled */ +/* UNUSED 0x00000200 was QHLIST */ +/* UNUSED 0x00000400 was QUNSAFE */ +#define QPAIR 0x00000800 /* per queue-pair syncq */ +#define QPERQ 0x00001000 /* per queue-instance syncq */ +#define QPERMOD 0x00002000 /* per module syncq */ +#define QMTSAFE 0x00004000 /* stream module is MT-safe */ +#define QMTOUTPERIM 0x00008000 /* Has outer perimeter */ +#define QMT_TYPEMASK (QPAIR|QPERQ|QPERMOD|QMTSAFE|QMTOUTPERIM) + /* all MT type flags */ +#define QINSERVICE 0x00010000 /* service routine executing */ +#define QWCLOSE 0x00020000 /* will not be enabled */ +#define QEND 0x00040000 /* last queue in stream */ +#define QWANTWSYNC 0x00080000 /* Streamhead wants to write Q */ +#define QSYNCSTR 0x00100000 /* Q supports Synchronous STREAMS */ +#define QISDRV 0x00200000 /* the Queue is attached to a driver */ +/* UNUSED 0x00400000 was QHOT */ +/* UNUSED 0x00800000 was QNEXTHOT */ +/* UNUSED 0x01000000 was _QNEXTLESS */ +#define _QINSERTING 0x04000000 /* Private, module is being inserted */ +#define _QREMOVING 0x08000000 /* Private, module is being removed */ +#define _QASSOCIATED 0x10000000 /* queue is associated with a device */ +#define _QDIRECT 0x20000000 /* Private; transport module uses */ + /* direct interface to/from sockfs */ +#define _QSINGLE_INSTANCE 0x40000000 /* Private; module may only */ + /* be pushed once */ + +/* queue sqflags (protected by SQLOCK). */ +#define Q_SQQUEUED 0x01 /* Queue is in the syncq list */ +#define Q_SQDRAINING 0x02 /* Servicing syncq msgs. */ + /* This is also noted by the */ + /* q_draining field, but this one is */ + /* protected by SQLOCK */ + +/* + * Structure that describes the separate information + * for each priority band in the queue. + */ +typedef struct qband { + struct qband *qb_next; /* next band's info */ + size_t qb_count; /* number of bytes in band */ + struct msgb *qb_first; /* beginning of band's data */ + struct msgb *qb_last; /* end of band's data */ + size_t qb_hiwat; /* high water mark for band */ + size_t qb_lowat; /* low water mark for band */ + uint_t qb_flag; /* see below */ + size_t qb_mblkcnt; /* mblk counter for runaway msgs */ +} qband_t; + +/* + * qband flags + */ +#define QB_FULL 0x01 /* band is considered full */ +#define QB_WANTW 0x02 /* Someone wants to write to band */ +#define QB_BACK 0x04 /* queue has been back-enabled */ + +/* + * Maximum number of bands. + */ +#define NBAND 256 + +/* + * Fields that can be manipulated through strqset() and strqget(). + */ +typedef enum qfields { + QHIWAT = 0, /* q_hiwat or qb_hiwat */ + QLOWAT = 1, /* q_lowat or qb_lowat */ + QMAXPSZ = 2, /* q_maxpsz */ + QMINPSZ = 3, /* q_minpsz */ + QCOUNT = 4, /* q_count or qb_count */ + QFIRST = 5, /* q_first or qb_first */ + QLAST = 6, /* q_last or qb_last */ + QFLAG = 7, /* q_flag or qb_flag */ + QSTRUIOT = 8, /* q_struiot */ + QBAD = 9 +} qfields_t; + +/* + * Module information structure + */ +struct module_info { + ushort_t mi_idnum; /* module id number */ + char *mi_idname; /* module name */ + ssize_t mi_minpsz; /* min packet size accepted */ + ssize_t mi_maxpsz; /* max packet size accepted */ + size_t mi_hiwat; /* hi-water mark */ + size_t mi_lowat; /* lo-water mark */ +}; + +/* + * queue information structure (with Synchronous STREAMS extensions) + */ + +typedef struct msgb mblk_t; +typedef struct struiod struiod_t; +typedef struct infod infod_t; + +typedef int (*qi_putp_t)(queue_t *, mblk_t *); +typedef int (*qi_srvp_t)(queue_t *); +typedef int (*qi_qopen_t)(queue_t *, dev_t *, int, int, cred_t *); +typedef int (*qi_qclose_t)(queue_t *, int, cred_t *); +typedef int (*qi_qadmin_t)(void); +typedef int (*qi_rwp_t)(queue_t *, struiod_t *); +typedef int (*qi_infop_t)(queue_t *, infod_t *); + +struct qinit { + qi_putp_t qi_putp; /* put procedure */ + qi_srvp_t qi_srvp; /* service procedure */ + qi_qopen_t qi_qopen; /* called on startup */ + qi_qclose_t qi_qclose; /* called on finish */ + qi_qadmin_t qi_qadmin; /* for future use */ + struct module_info *qi_minfo; /* module information structure */ + struct module_stat *qi_mstat; /* module statistics structure */ + qi_rwp_t qi_rwp; /* r/w procedure */ + qi_infop_t qi_infop; /* information procedure */ + int qi_struiot; /* stream uio type for struio() */ +}; + +/* + * Values for qi_struiot and q_struiot: + */ +#define STRUIOT_NONE -1 /* doesn't support struio() */ +#define STRUIOT_DONTCARE 0 /* use current uiomove() (default) */ +#define STRUIOT_STANDARD 1 /* use standard uiomove() */ + +/* + * Streamtab (used in cdevsw and fmodsw to point to module or driver) + */ +struct streamtab { + struct qinit *st_rdinit; + struct qinit *st_wrinit; + struct qinit *st_muxrinit; + struct qinit *st_muxwinit; +}; + +/* + * Structure sent to mux drivers to indicate a link. + */ +struct linkblk { + queue_t *l_qtop; /* lowest level write queue of upper stream */ + /* (set to NULL for persistent links) */ + queue_t *l_qbot; /* highest level write queue of lower stream */ + int l_index; /* index for lower stream. */ +}; + +/* + * Esballoc data buffer freeing routine + */ +typedef struct free_rtn { + void (*free_func)(); + caddr_t free_arg; +} frtn_t; + +/* + * Data block descriptor + * + * NOTE: db_base, db_lim, db_ref and db_type are the *only* public fields, + * as described in datab(9S). Everything else is implementation-private. + */ + +#define DBLK_REFMAX 255U + +typedef struct datab { + frtn_t *db_frtnp; + unsigned char *db_base; + unsigned char *db_lim; + unsigned char db_ref; + unsigned char db_type; + unsigned char db_flags; + unsigned char db_struioflag; + pid_t db_cpid; /* cached pid, needs verification */ + void *db_cache; /* kmem cache descriptor */ + struct msgb *db_mblk; + void (*db_free)(struct msgb *, struct datab *); + void (*db_lastfree)(struct msgb *, struct datab *); + intptr_t db_cksumstart; + intptr_t db_cksumend; + intptr_t db_cksumstuff; + union { + double enforce_alignment; + unsigned char data[8]; + struct { + union { + uint32_t u32; + uint16_t u16; + } cksum_val; /* used to store calculated cksum */ + uint16_t flags; + uint16_t pad; + } cksum; + /* + * Union used for future extensions (pointer to data ?). + */ + } db_struioun; + struct fthdr *db_fthdr; + cred_t *db_credp; /* credential */ +} dblk_t; + +#define db_cksum16 db_struioun.cksum.cksum_val.u16 +#define db_cksum32 db_struioun.cksum.cksum_val.u32 + +/* + * Accessor macros for private dblk_t fields (the rest are in ). + */ +#define DB_CPID(mp) ((mp)->b_datap->db_cpid) +#define DB_CRED(mp) ((mp)->b_datap->db_credp) +#define DB_FTHDR(mp) ((mp)->b_datap->db_fthdr) +/* + * Used by GLDv2 to store the TCI information. + */ +#define DB_TCI(mp) ((mp)->b_datap->db_struioun.cksum.pad) + +/* + * Message block descriptor + */ +struct msgb { + struct msgb *b_next; + struct msgb *b_prev; + struct msgb *b_cont; + unsigned char *b_rptr; + unsigned char *b_wptr; + struct datab *b_datap; + unsigned char b_band; + unsigned char b_tag; + unsigned short b_flag; + queue_t *b_queue; /* for sync queues */ +}; + +/* + * bcache descriptor + */ +typedef struct bcache { + kmutex_t mutex; + struct kmem_cache *buffer_cache; + struct kmem_cache *dblk_cache; + int alloc; + int destroy; + size_t size; + uint_t align; +} bcache_t; + +/* + * db_flags values (all implementation private!) + */ +#define DBLK_REFMIN 0x01 /* min refcnt stored in low bit */ +#define DBLK_COOKED 0x02 /* message has been processed once */ +#define DBLK_UIOA 0x04 /* uioamove() is pending */ + +/* + * db_struioflag values: + */ +#define STRUIO_SPEC 0x01 /* struio{get,put}() special mblk */ +#define STRUIO_DONE 0x02 /* struio done (could be partial) */ +#define STRUIO_IP 0x04 /* IP checksum stored in db_struioun */ +#define STRUIO_ZC 0x08 /* mblk eligible for zero-copy */ +#define STRUIO_ZCNOTIFY 0x10 /* notify stream head when mblk acked */ + +/* + * Message flags. These are interpreted by the stream head. + */ +#define MSGMARK 0x01 /* last byte of message is "marked" */ +#define MSGNOLOOP 0x02 /* don't loop message around to */ + /* write side of stream */ +#define MSGDELIM 0x04 /* message is delimited */ +/* UNUSED 0x08 was MSGNOGET (can be recycled) */ +#define MSGMARKNEXT 0x10 /* Private: first byte of next msg marked */ +#define MSGNOTMARKNEXT 0x20 /* Private: ... not marked */ +#define MSGWAITSYNC 0x40 /* Private: waiting for sync squeue enter */ + +/* + * Streams message types. + */ + +/* + * Data and protocol messages (regular and priority) + */ +#define M_DATA 0x00 /* regular data */ +#define M_PROTO 0x01 /* protocol control */ +#define M_MULTIDATA 0x02 /* obsolete, do not use */ + +/* + * Control messages (regular and priority) + */ +#define M_BREAK 0x08 /* line break */ +#define M_PASSFP 0x09 /* pass file pointer */ +#define M_EVENT 0x0a /* Obsoleted: do not use */ +#define M_SIG 0x0b /* generate process signal */ +#define M_DELAY 0x0c /* real-time xmit delay (1 param) */ +#define M_CTL 0x0d /* device-specific control message */ +#define M_IOCTL 0x0e /* ioctl; set/get params */ +#define M_SETOPTS 0x10 /* set various stream head options */ +#define M_RSE 0x11 /* reserved for RSE use only */ + +/* + * Control messages (high priority; go to head of queue) + */ +#define M_IOCACK 0x81 /* acknowledge ioctl */ +#define M_IOCNAK 0x82 /* negative ioctl acknowledge */ +#define M_PCPROTO 0x83 /* priority proto message */ +#define M_PCSIG 0x84 /* generate process signal */ +#define M_READ 0x85 /* generate read notification */ +#define M_FLUSH 0x86 /* flush your queues */ +#define M_STOP 0x87 /* stop transmission immediately */ +#define M_START 0x88 /* restart transmission after stop */ +#define M_HANGUP 0x89 /* line disconnect */ +#define M_ERROR 0x8a /* send error to stream head */ +#define M_COPYIN 0x8b /* request to copyin data */ +#define M_COPYOUT 0x8c /* request to copyout data */ +#define M_IOCDATA 0x8d /* response to M_COPYIN and M_COPYOUT */ +#define M_PCRSE 0x8e /* reserved for RSE use only */ +#define M_STOPI 0x8f /* stop reception immediately */ +#define M_STARTI 0x90 /* restart reception after stop */ +#define M_PCEVENT 0x91 /* Obsoleted: do not use */ +#define M_UNHANGUP 0x92 /* line reconnect, sigh */ +#define M_CMD 0x93 /* out-of-band ioctl command */ + +/* + * Queue message class definitions. + */ +#define QNORM 0x00 /* normal priority messages */ +#define QPCTL 0x80 /* high priority cntrl messages */ + +/* + * IOCTL structure - this structure is the format of the M_IOCTL message type. + */ +#if defined(_LP64) +struct iocblk { + int ioc_cmd; /* ioctl command type */ + cred_t *ioc_cr; /* full credentials */ + uint_t ioc_id; /* ioctl id */ + uint_t ioc_flag; /* see below */ + size_t ioc_count; /* count of bytes in data field */ + int ioc_rval; /* return value */ + int ioc_error; /* error code */ +}; +#else +struct iocblk { + int ioc_cmd; /* ioctl command type */ + cred_t *ioc_cr; /* full credentials */ + uint_t ioc_id; /* ioctl id */ + size_t ioc_count; /* count of bytes in data field */ + int ioc_error; /* error code */ + int ioc_rval; /* return value */ + int ioc_fill1; + uint_t ioc_flag; /* see below */ + int ioc_filler[2]; /* reserved for future use */ +}; +#endif /* _LP64 */ + +typedef struct iocblk *IOCP; + +/* {ioc,cp}_flags values */ + +#define IOC_MODELS DATAMODEL_MASK /* Note: 0x0FF00000 */ +#define IOC_ILP32 DATAMODEL_ILP32 /* ioctl origin is ILP32 */ +#define IOC_LP64 DATAMODEL_LP64 /* ioctl origin is LP64 */ +#define IOC_NATIVE DATAMODEL_NATIVE +#define IOC_NONE DATAMODEL_NONE /* dummy comparison value */ + +/* + * Is the ioctl data formatted for our native model? + */ +#define IOC_CONVERT_FROM(iocp) ddi_model_convert_from( \ + ((struct iocblk *)iocp)->ioc_flag) + +/* + * structure for the M_COPYIN and M_COPYOUT message types. + */ +#if defined(_LP64) +struct copyreq { + int cq_cmd; /* ioctl command (from ioc_cmd) */ + cred_t *cq_cr; /* full credentials (from ioc_cmd) */ + uint_t cq_id; /* ioctl id (from ioc_id) */ + uint_t cq_flag; /* must be zero */ + mblk_t *cq_private; /* private state information */ + caddr_t cq_addr; /* address to copy data to/from */ + size_t cq_size; /* number of bytes to copy */ +}; +#else +struct copyreq { + int cq_cmd; /* ioctl command (from ioc_cmd) */ + cred_t *cq_cr; /* full credentials */ + uint_t cq_id; /* ioctl id (from ioc_id) */ + caddr_t cq_addr; /* address to copy data to/from */ + size_t cq_size; /* number of bytes to copy */ + uint_t cq_flag; /* must be zero */ + mblk_t *cq_private; /* private state information */ + int cq_filler[4]; /* reserved for future use */ +}; +#endif /* _LP64 */ + +/* + * structure for the M_IOCDATA message type. + */ +#if defined(_LP64) +struct copyresp { + int cp_cmd; /* ioctl command (from ioc_cmd) */ + cred_t *cp_cr; /* full credentials (from ioc_cmd) */ + uint_t cp_id; /* ioctl id (from ioc_id) */ + uint_t cp_flag; /* datamodel IOC_ flags; see above */ + mblk_t *cp_private; /* private state information */ + caddr_t cp_rval; /* status of request: 0 -> success */ + /* non-zero -> failure */ +}; +#else +struct copyresp { + int cp_cmd; /* ioctl command (from ioc_cmd) */ + cred_t *cp_cr; /* full credentials */ + uint_t cp_id; /* ioctl id (from ioc_id) */ + caddr_t cp_rval; /* status of request: 0 -> success */ + /* non-zero -> failure */ + size_t cp_pad1; + uint_t cp_pad2; + mblk_t *cp_private; /* private state information */ + uint_t cp_flag; /* datamodel IOC_ flags; see above */ + int cp_filler[3]; +}; +#endif /* _LP64 */ + +/* + * Since these structures are all intended to travel in the same message + * at different stages of a STREAMS ioctl, this union is used to determine + * the message size in strdoioctl(). + */ +union ioctypes { + struct iocblk iocblk; + struct copyreq copyreq; + struct copyresp copyresp; +}; + +/* + * Options structure for M_SETOPTS message. This is sent upstream + * by a module or driver to set stream head options. + */ +struct stroptions { + uint_t so_flags; /* options to set */ + short so_readopt; /* read option */ + ushort_t so_wroff; /* write offset */ + ssize_t so_minpsz; /* minimum read packet size */ + ssize_t so_maxpsz; /* maximum read packet size */ + size_t so_hiwat; /* read queue high water mark */ + size_t so_lowat; /* read queue low water mark */ + unsigned char so_band; /* band for water marks */ + ushort_t so_erropt; /* error option */ + ssize_t so_maxblk; /* maximum message block size */ + ushort_t so_copyopt; /* copy options (see stropts.h) */ + ushort_t so_tail; /* space available at the end */ +}; + +/* flags for stream options set message */ + +#define SO_ALL 0x003f /* set all old options */ +#define SO_READOPT 0x0001 /* set read option */ +#define SO_WROFF 0x0002 /* set write offset */ +#define SO_MINPSZ 0x0004 /* set min packet size */ +#define SO_MAXPSZ 0x0008 /* set max packet size */ +#define SO_HIWAT 0x0010 /* set high water mark */ +#define SO_LOWAT 0x0020 /* set low water mark */ +#define SO_MREADON 0x0040 /* set read notification ON */ +#define SO_MREADOFF 0x0080 /* set read notification OFF */ +#define SO_NDELON 0x0100 /* old TTY semantics for NDELAY reads/writes */ +#define SO_NDELOFF 0x0200 /* STREAMS semantics for NDELAY reads/writes */ +#define SO_ISTTY 0x0400 /* the stream is acting as a terminal */ +#define SO_ISNTTY 0x0800 /* the stream is not acting as a terminal */ +#define SO_TOSTOP 0x1000 /* stop on background writes to this stream */ +#define SO_TONSTOP 0x2000 /* do not stop on background writes to stream */ +#define SO_BAND 0x4000 /* water marks affect band */ +#define SO_DELIM 0x8000 /* messages are delimited */ +#define SO_NODELIM 0x010000 /* turn off delimiters */ +#define SO_STRHOLD 0x020000 /* No longer implemented */ +#define SO_ERROPT 0x040000 /* set error option */ +#define SO_COPYOPT 0x080000 /* copy option(s) present */ +#define SO_MAXBLK 0x100000 /* set maximum message block size */ +#define SO_TAIL 0x200000 /* set the extra allocated space */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +/* + * Structure for rw (read/write) procedure calls. A pointer + * to a struiod_t is passed as a parameter to the rwnext() call. + */ +struct struiod { + mblk_t *d_mp; /* pointer to mblk (chain) */ + uio_t d_uio; /* uio info */ + iovec_t *d_iov; /* iov referenced by uio */ +}; + +/* + * Structure for information procedure calls. + */ +struct infod { + unsigned char d_cmd; /* info info request command */ + unsigned char d_res; /* info info command results */ + int d_bytes; /* mblk(s) byte count */ + int d_count; /* count of mblk(s) */ + uio_t *d_uiop; /* pointer to uio struct */ +}; +/* + * Values for d_cmd & d_res. + */ +#define INFOD_FIRSTBYTES 0x02 /* return msgbsize() of first mblk */ +#define INFOD_BYTES 0x04 /* return msgbsize() of all mblk(s) */ +#define INFOD_COUNT 0x08 /* return count of mblk(s) */ +#define INFOD_COPYOUT 0x10 /* copyout any M_DATA mblk(s) */ + +/* + * Structure used by _I_CMD mechanism, similar in spirit to iocblk. + */ +typedef struct cmdblk { + int cb_cmd; /* ioctl command type */ + cred_t *cb_cr; /* full credentials */ + uint_t cb_len; /* payload size */ + int cb_error; /* error code */ +} cmdblk_t; + +#endif /* _KERNEL */ + +/* + * Miscellaneous parameters and flags. + */ + +/* + * Values for stream flag in open to indicate module open, clone open, + * and the return value for failure. + */ +#define MODOPEN 0x1 /* open as a module */ +#define CLONEOPEN 0x2 /* clone open; pick own minor dev */ +#define OPENFAIL -1 /* returned for open failure */ + +/* + * Priority definitions for block allocation. + */ +#define BPRI_LO 1 +#define BPRI_MED 2 +#define BPRI_HI 3 + +/* + * Value for packet size that denotes infinity + */ +#define INFPSZ -1 + +/* + * Flags for flushq() + */ +#define FLUSHALL 1 /* flush all messages */ +#define FLUSHDATA 0 /* don't flush control messages */ + +/* + * Flag for transparent ioctls + */ +#define TRANSPARENT (unsigned int)(-1) + +/* + * Stream head default high/low water marks + */ +#define STRHIGH 5120 +#define STRLOW 1024 + +/* + * qwriter perimeter types + */ +#define PERIM_INNER 1 /* The inner perimeter */ +#define PERIM_OUTER 2 /* The outer perimeter */ + +/* + * Definitions of Streams macros and function interfaces. + */ + +/* + * canenable - check if queue can be enabled by putq(). + */ +#define canenable(q) !((q)->q_flag & QNOENB) + +/* + * Test if data block type is one of the data messages (i.e. not a control + * message). + */ +#define datamsg(type) \ + ((type) == M_DATA || \ + (type) == M_PROTO || \ + (type) == M_PCPROTO || \ + (type) == M_DELAY) + +/* + * Extract queue class of message block. + */ +#define queclass(bp) (((bp)->b_datap->db_type >= QPCTL) ? QPCTL : QNORM) + +/* + * Align address on next lower word boundary. + */ +#define straln(a) (caddr_t)((intptr_t)(a) & -(sizeof (int)-1)) + +/* + * Find the max size of data block. + */ +#define bpsize(bp) ((unsigned int)(bp->b_datap->db_lim - bp->b_datap->db_base)) + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * For two-byte M_ERROR messages: indication that a side does not have an error + */ +#define NOERROR ((unsigned char)-1) + +/* + * declarations of common routines + */ + +extern mblk_t *allocb(size_t, uint_t); +extern mblk_t *desballoc(unsigned char *, size_t, uint_t, frtn_t *); +extern mblk_t *esballoc(unsigned char *, size_t, uint_t, frtn_t *); +extern bcache_t *bcache_create(char *, size_t, uint_t); +extern void bcache_destroy(bcache_t *); +extern mblk_t *bcache_allocb(bcache_t *, uint_t); +extern mblk_t *mkiocb(uint_t); +extern int testb(size_t, uint_t); +extern bufcall_id_t bufcall(size_t, uint_t, void (*)(void *), void *); +extern bufcall_id_t esbbcall(uint_t, void (*)(void *), void *); +extern void freeb(struct msgb *); +extern void freemsg(mblk_t *); +extern mblk_t *dupb(mblk_t *); +extern mblk_t *dupmsg(mblk_t *); +extern mblk_t *dupmsg_noloan(mblk_t *); +extern mblk_t *copyb(mblk_t *); +extern mblk_t *copymsg(mblk_t *); +extern void linkb(mblk_t *, mblk_t *); +extern mblk_t *unlinkb(mblk_t *); +extern mblk_t *reallocb(mblk_t *, size_t, uint_t); /* private */ +extern mblk_t *rmvb(mblk_t *, mblk_t *); +extern int pullupmsg(struct msgb *, ssize_t); +extern mblk_t *msgpullup(struct msgb *, ssize_t); +extern int adjmsg(struct msgb *, ssize_t); +extern size_t msgdsize(struct msgb *); +extern mblk_t *getq(queue_t *); +extern void rmvq(queue_t *, mblk_t *); +extern void flushq(queue_t *, int); +extern void flushq_common(queue_t *, int, int); +extern void flushband(queue_t *, unsigned char, int); +extern int canput(queue_t *); +extern int bcanput(queue_t *, unsigned char); +extern int canputnext(queue_t *); +extern int bcanputnext(queue_t *, unsigned char); +extern int putq(queue_t *, mblk_t *); +extern int putbq(queue_t *, mblk_t *); +extern int insq(queue_t *, mblk_t *, mblk_t *); +extern void put(queue_t *, mblk_t *); +extern void putnext(queue_t *, mblk_t *); +extern int putctl(queue_t *, int); +extern int putctl1(queue_t *, int, int); +extern int putnextctl(queue_t *, int); +extern int putnextctl1(queue_t *, int, int); +extern queue_t *backq(queue_t *); +extern void qreply(queue_t *, mblk_t *); +extern void qenable(queue_t *); +extern int qsize(queue_t *); +extern void noenable(queue_t *); +extern void enableok(queue_t *); +extern int strqset(queue_t *, qfields_t, unsigned char, intptr_t); +extern int strqget(queue_t *, qfields_t, unsigned char, void *); +extern void unbufcall(bufcall_id_t); +extern void qprocson(queue_t *); +extern void qprocsoff(queue_t *); +extern void freezestr(queue_t *); +extern void unfreezestr(queue_t *); +extern void qwait(queue_t *); +extern int qwait_sig(queue_t *); +extern boolean_t qwait_rw(queue_t *); +extern void qwriter(queue_t *, mblk_t *, void (*func)(), int); +extern timeout_id_t qtimeout(queue_t *, void (*func)(void *), void *, clock_t); +extern bufcall_id_t qbufcall(queue_t *, size_t, uint_t, + void (*)(void *), void *); +extern clock_t quntimeout(queue_t *, timeout_id_t); +extern void qunbufcall(queue_t *, bufcall_id_t); +extern void strwakeq(queue_t *, int); +extern int struioget(queue_t *, mblk_t *, struiod_t *, int); +extern int rwnext(queue_t *, struiod_t *); +extern int infonext(queue_t *, infod_t *); +extern int isuioq(queue_t *); +extern void create_putlocks(queue_t *, int); +extern int mp_cont_len(mblk_t *, int *); + +/* + * shared or externally configured data structures + */ +extern int nstrpush; /* maximum number of pushes allowed */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STREAM_H */ diff --git a/illumos-x86_64/usr/include/sys/strft.h b/illumos-x86_64/usr/include/sys/strft.h new file mode 100644 index 00000000..150bbf01 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/strft.h @@ -0,0 +1,199 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STRFT_H +#define _SYS_STRFT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The flow trace subsystem is used to trace the flow of STREAMS messages + * through a stream. + * + * WARNING: this is a private subsystem and subject to change at any time! + */ + +#include +#include +#include + +/* + * Some evnt defines, values 0..N are reserved for internal use, + * (N+1)..0x1FFF are available for arbitrary module/drvier use, + * 0x8000 (RD/WR q marker) and 0x4000 (thread cs marker) are or'ed + * flag bits reserved for internal use. + */ +#define FTEV_MASK 0x1FFF +#define FTEV_ISWR 0x8000 +#define FTEV_CS 0x4000 +#define FTEV_PS 0x2000 + +#define FTEV_QMASK 0x1F00 + +#define FTEV_ALLOCMASK 0x1FF8 +#define FTEV_ALLOCB 0x0000 +#define FTEV_ESBALLOC 0x0001 +#define FTEV_DESBALLOC 0x0002 +#define FTEV_ESBALLOCA 0x0003 +#define FTEV_DESBALLOCA 0x0004 +#define FTEV_ALLOCBIG 0x0005 +#define FTEV_ALLOCBW 0x0006 +#define FTEV_BCALLOCB 0x0007 +#define FTEV_FREEB 0x0008 +#define FTEV_DUPB 0x0009 +#define FTEV_COPYB 0x000A + +#define FTEV_CALLER 0x000F + +#define FTEV_PUT 0x0100 +#define FTEV_PUTQ 0x0105 +#define FTEV_GETQ 0x0106 +#define FTEV_RMVQ 0x0107 +#define FTEV_INSQ 0x0108 +#define FTEV_PUTBQ 0x0109 +#define FTEV_FLUSHQ 0x010A +#define FTEV_PUTNEXT 0x010D +#define FTEV_RWNEXT 0x010E + +#define FTBLK_EVNTS 9 +#define FTSTK_DEPTH 15 + +/* + * Stack information for each flow trace event; recorded when str_ftstack + * is non-zero. + */ +typedef struct ftstk { + uint_t fs_depth; + pc_t fs_stk[FTSTK_DEPTH]; +} ftstk_t; + +/* + * Data structure that contains the timestamp, module/driver name, next + * module/driver name, optional callstack, event and event data (not certain + * as to its use yet: RSF). There is one per event. Every time str_ftevent() + * is called, one of the indices is filled in with this data. + */ +typedef struct ftevnt { + hrtime_t ts; /* event timestamp, per gethrtime() */ + char *mid; /* module/driver name */ + char *midnext; /* next module/driver name */ + ushort_t evnt; /* FTEV_* value above */ + ushort_t data; /* event data */ + ftstk_t *stk; /* optional event callstack */ +} ftevnt_t; + +/* + * A linked list of ftevnt arrays. + */ +typedef struct ftblk { + struct ftblk *nxt; /* next ftblk (or NULL if none) */ + int ix; /* index of next free ev[] */ + struct ftevnt ev[FTBLK_EVNTS]; +} ftblk_t; + +/* + * The flow trace header (start of event list). It consists of the + * current writable block (tail) + * a hash value (for recovering trace information) + * The last thread to process an event + * The last cpu to process an event + * The start of the list + * This structure is attached to a dblk, and traces a message through + * a flow. + */ +typedef struct fthdr { + struct ftblk *tail; + uint_t hash; /* accumulated hash value (sum of mid's) */ + void *thread; + int cpu_seqid; + struct ftblk first; +} fthdr_t; + +#ifdef _KERNEL + +struct datab; + +extern void str_ftevent(fthdr_t *, void *, ushort_t, ushort_t); +extern void str_ftfree(struct datab *); +extern int str_ftnever, str_ftstack; + +/* + * Allocate flow-trace information and record an allocation event. + */ +#define STR_FTALLOC(hpp, e, d) { \ + if (str_ftnever == 0) { \ + fthdr_t *_hp = *(hpp); \ + \ + ASSERT(_hp == NULL); \ + _hp = kmem_cache_alloc(fthdr_cache, KM_NOSLEEP); \ + if ((*hpp = _hp) != NULL) { \ + _hp->tail = &_hp->first; \ + _hp->hash = 0; \ + _hp->thread = curthread; \ + _hp->cpu_seqid = CPU->cpu_seqid; \ + _hp->first.nxt = NULL; \ + _hp->first.ix = 0; \ + str_ftevent(_hp, caller(), (e), (d)); \ + } \ + } \ +} + +/* + * Add a flow-trace event to the passed-in mblk_t and any other mblk_t's + * chained off of b_cont. + */ +#define STR_FTEVENT_MSG(mp, p, e, d) { \ + if (str_ftnever == 0) { \ + mblk_t *_mp; \ + fthdr_t *_hp; \ + \ + for (_mp = (mp); _mp != NULL; _mp = _mp->b_cont) { \ + if ((_hp = DB_FTHDR(_mp)) != NULL) \ + str_ftevent(_hp, (p), (e), (d)); \ + } \ + } \ +} + +/* + * Add a flow-trace event to *just* the passed-in mblk_t. + */ +#define STR_FTEVENT_MBLK(mp, p, e, d) { \ + if (str_ftnever == 0) { \ + fthdr_t *_hp; \ + \ + if ((mp) != NULL && ((_hp = DB_FTHDR(mp)) != NULL)) \ + str_ftevent(_hp, (p), (e), (d)); \ + } \ +} + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STRFT_H */ diff --git a/illumos-x86_64/usr/include/sys/strlog.h b/illumos-x86_64/usr/include/sys/strlog.h new file mode 100644 index 00000000..90090c1c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/strlog.h @@ -0,0 +1,140 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STRLOG_H +#define _SYS_STRLOG_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Streams Log Driver Interface Definitions + */ + +/* + * structure of control portion of log message + */ +typedef struct log_ctl { + short mid; + short sid; + char level; /* level of message for tracing */ + short flags; /* message disposition */ +#if defined(_LP64) + clock32_t ltime; /* time in machine ticks since boot */ + time32_t ttime; /* time in seconds since 1970 */ +#else + clock_t ltime; + time_t ttime; +#endif + int seq_no; /* sequence number */ + int pri; /* priority = (facility|level) */ +} log_ctl_t; + +/* + * Public flags for log messages + */ +#define SL_FATAL 0x01 /* indicates fatal error */ +#define SL_NOTIFY 0x02 /* logger must notify administrator */ +#define SL_ERROR 0x04 /* include on the error log */ +#define SL_TRACE 0x08 /* include on the trace log */ +#define SL_CONSOLE 0x10 /* include on the console log */ +#define SL_WARN 0x20 /* warning message */ +#define SL_NOTE 0x40 /* notice message */ + +/* + * Private flags for log messages -- used by internal implementation only + */ +#define SL_CONSONLY 0x1000 /* send message only to /dev/console */ +#define SL_LOGONLY 0x2000 /* send message only to /var/adm/messages */ +#define SL_USER 0x4000 /* send message to user's terminal */ +#define SL_PANICMSG 0x8000 /* message was created while panicking */ + +/* + * Structure defining ids and levels desired by the tracer (I_TRCLOG). + */ +typedef struct trace_ids { + short ti_mid; + short ti_sid; + int8_t ti_level; +} trace_ids_t; + +/* + * Log Driver I_STR ioctl commands + */ + +#define LOGCTL (('L')<<8) +#define I_TRCLOG (LOGCTL|1) /* process is tracer */ +#define I_ERRLOG (LOGCTL|2) /* process is error logger */ +#define I_CONSLOG (LOGCTL|3) /* process is console logger */ + +#define STRLOG_MAKE_MSGID(fmt, msgid) \ +{ \ + uchar_t *__cp = (uchar_t *)fmt; \ + uchar_t __c; \ + uint32_t __id = 0; \ + while ((__c = *__cp++) != '\0') \ + if (__c >= ' ') \ + __id = (__id >> 5) + (__id << 27) + __c; \ + msgid = (__id % 899981) + 100000; \ +} + +#ifdef _KERNEL + +#ifndef _ASM +#include +#endif + +/*PRINTFLIKE5*/ +extern int strlog(short, short, char, unsigned short, char *, ...) + __KPRINTFLIKE(5); +extern int vstrlog(short, short, char, unsigned short, char *, __va_list) + __KVPRINTFLIKE(5); + +/* + * STRLOG(mid,sid,level,flags,fmt,args) should be used for those trace + * calls that are only to be made during debugging. + */ +#if defined(DEBUG) || defined(__lint) +#define STRLOG strlog +#else +#define STRLOG 0 && strlog +#endif /* DEBUG || __lint */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STRLOG_H */ diff --git a/illumos-x86_64/usr/include/sys/strmdep.h b/illumos-x86_64/usr/include/sys/strmdep.h new file mode 100644 index 00000000..1d39c4a3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/strmdep.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_STRMDEP_H +#define _SYS_STRMDEP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains all machine-dependent declarations + * in STREAMS. + */ + +/* + * Copy data from one data buffer to another. + * The addresses must be word aligned - if not, use bcopy! + */ +#define strbcpy(s, d, c) bcopy(s, d, c) + +/* + * save the address of the calling function on the 3b2 to + * enable tracking of who is allocating message blocks + */ +#define saveaddr(funcp) + +/* + * macro to check pointer alignment + * (true if alignment is sufficient for worst case) + */ +#define str_aligned(X) (((ulong_t)(X) & (sizeof (long) - 1)) == 0) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STRMDEP_H */ diff --git a/illumos-x86_64/usr/include/sys/stropts.h b/illumos-x86_64/usr/include/sys/stropts.h new file mode 100644 index 00000000..e6b3e59d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/stropts.h @@ -0,0 +1,514 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STROPTS_H +#define _SYS_STROPTS_H + +#include +#include +/* + * For FMNAMESZ define. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Write options + */ +#define SNDZERO 0x001 /* send a zero length message */ +#define SNDPIPE 0x002 /* send SIGPIPE on write and */ + /* putmsg if sd_werror is set */ + +/* + * Read options + */ +#define RNORM 0x000 /* read msg norm */ +#define RMSGD 0x001 /* read msg discard */ +#define RMSGN 0x002 /* read msg no discard */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define RMODEMASK 0x003 /* all above bits */ +#endif + +/* + * These next three read options are added for the sake of + * user-level transparency. RPROTDAT will cause the stream head + * to treat the contents of M_PROTO and M_PCPROTO message blocks + * as data. RPROTDIS will prevent the stream head from failing + * a read with EBADMSG if an M_PROTO or M_PCPROTO message is on + * the front of the stream head read queue. Rather, the protocol + * blocks will be silently discarded and the data associated with + * the message (in linked M_DATA blocks), if any, will be delivered + * to the user. RPROTNORM sets the default behavior, where read + * will fail with EBADMSG if an M_PROTO or M_PCPROTO are at the + * stream head. + */ +#define RPROTDAT 0x004 /* read protocol messages as data */ +#define RPROTDIS 0x008 /* discard protocol messages, but */ + /* read data portion */ +#define RPROTNORM 0x010 + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define RPROTMASK 0x01c /* all RPROT bits */ + +/* + * The next read option is used so that a TPI aware module can tell the + * stream head to not flush M_PCPROTO messages when processing a read side + * flush. This will avoid problems where a flush removes a T_OK_ACK. + */ +#define RFLUSHMASK 0x020 /* all RFLUSH bits */ + +#define RFLUSHPCPROT 0x020 /* do not flush PCPROTOs */ + +#endif + +/* + * Error options + */ + +/* + * Error options to adjust the stream head error behavior with respect + * to M_ERROR message for read and write side errors respectively. + * The normal case is that the read/write side error is + * persistent and these options allow the application or streams module/driver + * to specify that errors are nonpersistent. In this case the error is cleared + * after having been returned to read(), getmsg(), ioctl(), write(), putmsg(), + * etc. + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define RERRNORM 0x001 /* Normal, persistent read errors */ +#define RERRNONPERSIST 0x002 /* Nonpersistent read errors */ + +#define RERRMASK (RERRNORM|RERRNONPERSIST) + +#define WERRNORM 0x004 /* Normal, persistent write errors */ +#define WERRNONPERSIST 0x008 /* Nonpersistent write errors */ + +#define WERRMASK (WERRNORM|WERRNONPERSIST) +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Flush options + */ + +#define FLUSHR 0x01 /* flush read queue */ +#define FLUSHW 0x02 /* flush write queue */ +#define FLUSHRW 0x03 /* flush both queues */ +#define FLUSHBAND 0x04 /* flush only band specified */ + /* in next byte */ +/* + * Copy options for M_SETOPS/SO_COPYOPT + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define ZCVMSAFE 0x01 /* safe to borrow file (segmapped) */ + /* pages instead of bcopy */ +#define ZCVMUNSAFE 0x02 /* unsafe to borrow file pages */ +#define COPYCACHED 0x04 /* copy should NOT bypass cache */ +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Events for which the SIGPOLL signal is to be sent. + */ +#define S_INPUT 0x0001 /* any msg but hipri on read Q */ +#define S_HIPRI 0x0002 /* high priority msg on read Q */ +#define S_OUTPUT 0x0004 /* write Q no longer full */ +#define S_MSG 0x0008 /* signal msg at front of read Q */ +#define S_ERROR 0x0010 /* error msg arrived at stream head */ +#define S_HANGUP 0x0020 /* hangup msg arrived at stream head */ +#define S_RDNORM 0x0040 /* normal msg on read Q */ +#define S_WRNORM S_OUTPUT +#define S_RDBAND 0x0080 /* out of band msg on read Q */ +#define S_WRBAND 0x0100 /* can write out of band */ +#define S_BANDURG 0x0200 /* modifier to S_RDBAND, to generate */ + /* SIGURG instead of SIGPOLL */ + +/* + * Flags for getmsg() and putmsg() syscall arguments. + * "RS" stands for recv/send. The system calls were originally called + * recv() and send(), but were renamed to avoid confusion with the BSD + * calls of the same name. A value of zero will cause getmsg() to return + * the first message on the stream head read queue and putmsg() to send + * a normal priority message. + * + * Flags for strmakemsg() arguments (should define strmakemsg() flags). + * Used to determine the message type of the control part of a message, + * if RS_HIPRI, M_PCPROTO, else M_PROTO. + */ + +#define RS_HIPRI 0x01 /* send/recv high priority message */ +#define STRUIO_POSTPONE 0x08 /* postpone copyin() for struio() */ + +/* + * Flags for getpmsg() and putpmsg() syscall arguments. + */ + +/* + * These are settable by the user and will be set on return + * to indicate the priority of message received. + */ +#define MSG_HIPRI 0x01 /* send/recv high priority message */ +#define MSG_ANY 0x02 /* recv any messages */ +#define MSG_BAND 0x04 /* recv messages from specified band */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * This is a private flag passed by libc to kernel to + * identify that it is a XPG4_2 application. No + * applications need to know about this flag. + */ +#define MSG_XPG4 0x08 +#endif + +#ifdef _KERNEL + +/* + * Additional private flags for kstrgetmsg and kstrputmsg. + * These must be bit-wise distinct from the above MSG flags. + */ +#define MSG_IPEEK 0x10 /* Peek - don't remove the message */ +#define MSG_DISCARDTAIL 0x20 /* Discard tail if it doesn't fit */ +#define MSG_HOLDSIG 0x40 /* Ignore signals. */ +#define MSG_IGNERROR 0x80 /* Ignore stream head errors */ +#define MSG_DELAYERROR 0x100 /* Delay error check until we sleep */ +#define MSG_IGNFLOW 0x200 /* Ignore flow control */ +#define MSG_NOMARK 0x400 /* Do not read if message is marked */ + +#endif /* _KERNEL */ + +/* + * Flags returned as value of getmsg() and getpmsg() syscall. + */ +#define MORECTL 1 /* more ctl info is left in message */ +#define MOREDATA 2 /* more data is left in message */ + +/* + * Define to indicate that all multiplexors beneath a stream should + * be unlinked. + */ +#define MUXID_ALL (-1) + +/* + * Flag definitions for the I_ATMARK ioctl. + */ +#define ANYMARK 0x01 +#define LASTMARK 0x02 + +/* + * Stream Ioctl defines + */ +#define STR ('S'<<8) +/* (STR|000) in use */ +#define I_NREAD (STR|01) +#define I_PUSH (STR|02) +#define I_POP (STR|03) +#define I_LOOK (STR|04) +#define I_FLUSH (STR|05) +#define I_SRDOPT (STR|06) +#define I_GRDOPT (STR|07) +#define I_STR (STR|010) +#define I_SETSIG (STR|011) +#define I_GETSIG (STR|012) +#define I_FIND (STR|013) +#define I_LINK (STR|014) +#define I_UNLINK (STR|015) +/* (STR|016) in use */ +#define I_PEEK (STR|017) +#define I_FDINSERT (STR|020) +#define I_SENDFD (STR|021) + +#if defined(_KERNEL) +#define I_RECVFD (STR|022) +#define I_E_RECVFD (STR|016) +#else /* user level definition */ +#define I_RECVFD (STR|016) /* maps to kernel I_E_RECVFD */ +#endif /* defined(_KERNEL) */ + +#define I_SWROPT (STR|023) +#define I_GWROPT (STR|024) +#define I_LIST (STR|025) +#define I_PLINK (STR|026) +#define I_PUNLINK (STR|027) +#define I_ANCHOR (STR|030) +#define I_FLUSHBAND (STR|034) +#define I_CKBAND (STR|035) +#define I_GETBAND (STR|036) +#define I_ATMARK (STR|037) +#define I_SETCLTIME (STR|040) +#define I_GETCLTIME (STR|041) +#define I_CANPUT (STR|042) +#define I_SERROPT (STR|043) +#define I_GERROPT (STR|044) +#define I_ESETSIG (STR|045) +#define I_EGETSIG (STR|046) + +#define __I_PUSH_NOCTTY (STR|047) /* push module, no cntrl tty */ + +/* + * IOCTLs (STR|050) - (STR|055) are available for use. + */ + +#define _I_MUXID2FD (STR|056) /* Private: get a fd from a muxid */ +#define _I_INSERT (STR|057) /* Private: insert a module */ +#define _I_REMOVE (STR|060) /* Private: remove a module */ +#define _I_GETPEERCRED (STR|061) /* Private: get peer cred */ +#define _I_PLINK_LH (STR|062) /* Private: Layered Driver ioctl */ +#define _I_CMD (STR|063) /* Private: send ioctl via M_CMD */ + +/* + * User level ioctl format for ioctls that go downstream (I_STR) + */ +struct strioctl { + int ic_cmd; /* command */ + int ic_timout; /* timeout value */ + int ic_len; /* length of data */ + char *ic_dp; /* pointer to data */ +}; + +#if defined(_SYSCALL32) + +struct strioctl32 { + int32_t ic_cmd; /* command */ + int32_t ic_timout; /* timeout value */ + int32_t ic_len; /* length of data */ + caddr32_t ic_dp; /* pointer to data */ +}; + +#endif /* _SYSCALL32 */ + +/* + * Value for timeouts (ioctl, select) that denotes infinity + */ +#define _INFTIM -1 +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define INFTIM _INFTIM +#endif + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +/* + * For _I_CMD: similar to strioctl, but with included buffer (to avoid copyin/ + * copyout from another address space). NOTE: the size of this structure must + * be less than libproc.h`MAXARGL for pr_ioctl() to handle it. + */ +#define STRCMDBUFSIZE 2048 +typedef struct strcmd { + int sc_cmd; /* ioctl command */ + int sc_timeout; /* timeout value (in seconds) */ + int sc_len; /* length of data */ + int sc_pad; + char sc_buf[STRCMDBUFSIZE]; /* data buffer */ +} strcmd_t; +#endif + +/* + * Stream buffer structure for putmsg and getmsg system calls + */ +struct strbuf { + int maxlen; /* no. of bytes in buffer */ + int len; /* no. of bytes returned */ + caddr_t buf; /* pointer to data */ +}; + +#if defined(_SYSCALL32) + +struct strbuf32 { + int32_t maxlen; /* no. of bytes in buffer */ + int32_t len; /* no. of bytes returned */ + caddr32_t buf; /* pointer to data */ +}; +#endif /* _SYSCALL32 */ + +/* + * Stream I_PEEK ioctl format + */ +struct strpeek { + struct strbuf ctlbuf; + struct strbuf databuf; + t_uscalar_t flags; +}; + +#if defined(_SYSCALL32) + +struct strpeek32 { + struct strbuf32 ctlbuf; + struct strbuf32 databuf; + uint32_t flags; +}; + +#endif /* _SYSCALL32 */ + +/* + * Stream I_FDINSERT ioctl format + */ +struct strfdinsert { + struct strbuf ctlbuf; + struct strbuf databuf; + t_uscalar_t flags; + int fildes; + int offset; +}; + +#if defined(_SYSCALL32) + +struct strfdinsert32 { + struct strbuf32 ctlbuf; + struct strbuf32 databuf; + uint32_t flags; + int32_t fildes; + int32_t offset; +}; + +#endif /* _SYSCALL32 */ + +/* + * Receive file descriptor structure + */ +#if defined(_KERNEL) + +struct o_strrecvfd { /* SVR3 syscall structure */ + int fd; + o_uid_t uid; /* always ushort */ + o_gid_t gid; + char fill[8]; +}; + +/* + * Although EFT is enabled in the kernel we kept the following definition + * to support an EFT application on a 4.0 non-EFT system. + */ +struct k_strrecvfd { /* SVR4 expanded syscall interface structure */ + struct file *fp; + uid_t uid; + gid_t gid; + char fill[8]; +}; + +/* + * Private _I_GETPEERCRED data. + */ + +typedef struct k_peercred { + cred_t *pc_cr; + pid_t pc_cpid; +} k_peercred_t; + +#endif /* defined(_KERNEL) */ + +struct strrecvfd { + int fd; + uid_t uid; + gid_t gid; +#if defined(_XPG4_2) + char __fill[8]; +#else + char fill[8]; +#endif +}; + + +/* + * For I_LIST ioctl. + */ +struct str_mlist { + char l_name[FMNAMESZ+1]; +}; + +struct str_list { + int sl_nmods; + struct str_mlist *sl_modlist; +}; + +#if defined(_SYSCALL32) + +struct str_list32 { + int32_t sl_nmods; + caddr32_t sl_modlist; +}; + +#endif /* _SYSCALL32 */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * Private, for _I_INSERT/_I_REMOVE ioctl. + */ +struct strmodconf { + int pos; /* Position to be inserted/removed. */ + caddr_t mod_name; /* Name of module. */ +}; + +#if defined(_SYSCALL32) + +struct strmodconf32 { + int32_t pos; + caddr32_t mod_name; +}; + +#endif /* _SYSCALL32 */ +#endif /* (_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * For I_FLUSHBAND ioctl. Describes the priority + * band for which the operation applies. + */ +struct bandinfo { + unsigned char bi_pri; + int bi_flag; +}; + + +/* + * The argument for I_ESETSIG and I_EGETSIG ioctls. + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +struct strsigset { + pid_t ss_pid; /* pgrp if negative */ + int ss_events; /* S_ events */ +}; +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef _XPG4_2 +#ifdef __PRAGMA_REDEFINE_EXTNAME + +#pragma redefine_extname putmsg __xpg4_putmsg +#pragma redefine_extname putpmsg __xpg4_putpmsg + +#else /* __PRAGMA_REDEFINE_EXTNAME */ + +#define putmsg __xpg4_putmsg +#define putpmsg __xpg4_putpmsg + +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* _XPG4_2 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STROPTS_H */ diff --git a/illumos-x86_64/usr/include/sys/strredir.h b/illumos-x86_64/usr/include/sys/strredir.h new file mode 100644 index 00000000..f95f7b2a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/strredir.h @@ -0,0 +1,72 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STRREDIR_H +#define _SYS_STRREDIR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * strredir.h: Declarations for the redirection driver and its matching + * STREAMS module. + */ + +/* + * The module's module id. + * + * XXX: Since there's no authority responsible for administering this name + * space, there's no guarantee that this value is unique. That wouldn't + * be so bad except that the DKI now suggests that ioctl cookie values + * should be based on module id to make them unique... + */ +#define STRREDIR_MODID 7326 + +/* + * Redirection ioctls: + */ +#define SRIOCSREDIR ((STRREDIR_MODID<<16) | 1) /* set redir target */ +#define SRIOCISREDIR ((STRREDIR_MODID<<16) | 2) /* is redir target? */ + + +/* + * Everything from here on is of interest only to the kernel. + */ +#ifdef _KERNEL + +/* name of the module used to detect closes on redirected streams */ +#define STRREDIR_MOD "redirmod" + +extern void srpop(vnode_t *, boolean_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STRREDIR_H */ diff --git a/illumos-x86_64/usr/include/sys/strstat.h b/illumos-x86_64/usr/include/sys/strstat.h new file mode 100644 index 00000000..36c67e88 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/strstat.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1994 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_STRSTAT_H +#define _SYS_STRSTAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Streams Statistics header file. This file defines the counters + * which are maintained for statistics gathering under Streams. + */ + +/* + * per-module statistics structure + */ +struct module_stat { + long ms_pcnt; /* count of calls to put proc */ + long ms_scnt; /* count of calls to service proc */ + long ms_ocnt; /* count of calls to open proc */ + long ms_ccnt; /* count of calls to close proc */ + long ms_acnt; /* count of calls to admin proc */ + char *ms_xptr; /* pointer to private statistics */ + short ms_xsize; /* length of private statistics buffer */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STRSTAT_H */ diff --git a/illumos-x86_64/usr/include/sys/strsubr.h b/illumos-x86_64/usr/include/sys/strsubr.h new file mode 100644 index 00000000..c90aeeac --- /dev/null +++ b/illumos-x86_64/usr/include/sys/strsubr.h @@ -0,0 +1,1364 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2018 Joyent, Inc. + */ + +/* + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. + */ + +/* + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Garrett D'Amore + */ + +#ifndef _SYS_STRSUBR_H +#define _SYS_STRSUBR_H + +/* + * WARNING: + * Everything in this file is private, belonging to the + * STREAMS subsystem. The only guarantee made about the + * contents of this file is that if you include it, your + * code will not port to the next release. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * In general, the STREAMS locks are disjoint; they are only held + * locally, and not simultaneously by a thread. However, module + * code, including at the stream head, requires some locks to be + * acquired in order for its safety. + * 1. Stream level claim. This prevents the value of q_next + * from changing while module code is executing. + * 2. Queue level claim. This prevents the value of q_ptr + * from changing while put or service code is executing. + * In addition, it provides for queue single-threading + * for QPAIR and PERQ MT-safe modules. + * 3. Stream head lock. May be held by the stream head module + * to implement a read/write/open/close monitor. + * Note: that the only types of twisted stream supported are + * the pipe and transports which have read and write service + * procedures on both sides of the twist. + * 4. Queue lock. May be acquired by utility routines on + * behalf of a module. + */ + +/* + * In general, sd_lock protects the consistency of the stdata + * structure. Additionally, it is used with sd_monitor + * to implement an open/close monitor. In particular, it protects + * the following fields: + * sd_iocblk + * sd_flag + * sd_copyflag + * sd_iocid + * sd_iocwait + * sd_sidp + * sd_pgidp + * sd_wroff + * sd_tail + * sd_rerror + * sd_werror + * sd_pushcnt + * sd_sigflags + * sd_siglist + * sd_pollist + * sd_mark + * sd_closetime + * sd_wakeq + * sd_maxblk + * + * The following fields are modified only by the allocator, which + * has exclusive access to them at that time: + * sd_wrq + * sd_strtab + * + * The following field is protected by the overlying file system + * code, guaranteeing single-threading of opens: + * sd_vnode + * + * Stream-level locks should be acquired before any queue-level locks + * are acquired. + * + * The stream head write queue lock(sd_wrq) is used to protect the + * fields qn_maxpsz and qn_minpsz because freezestr() which is + * necessary for strqset() only gets the queue lock. + */ + +/* + * Function types for the parameterized stream head. + * The msgfunc_t takes the parameters: + * msgfunc(vnode_t *vp, mblk_t *mp, strwakeup_t *wakeups, + * strsigset_t *firstmsgsigs, strsigset_t *allmsgsigs, + * strpollset_t *pollwakeups); + * It returns an optional message to be processed by the stream head. + * + * The parameters for errfunc_t are: + * errfunc(vnode *vp, int ispeek, int *clearerr); + * It returns an errno and zero if there was no pending error. + */ +typedef uint_t strwakeup_t; +typedef uint_t strsigset_t; +typedef short strpollset_t; +typedef uintptr_t callbparams_id_t; +typedef mblk_t *(*msgfunc_t)(vnode_t *, mblk_t *, strwakeup_t *, + strsigset_t *, strsigset_t *, strpollset_t *); +typedef int (*errfunc_t)(vnode_t *, int, int *); + +/* + * Per stream sd_lock in putnext may be replaced by per cpu stream_putlocks + * each living in a separate cache line. putnext/canputnext grabs only one of + * stream_putlocks while strlock() (called on behalf of insertq()/removeq()) + * acquires all stream_putlocks. Normally stream_putlocks are only employed + * for highly contended streams that have SQ_CIPUT queues in the critical path + * (e.g. NFS/UDP stream). + * + * stream_putlocks are dynamically assigned to stdata structure through + * sd_ciputctrl pointer possibly when a stream is already in use. Since + * strlock() uses stream_putlocks only under sd_lock acquiring sd_lock when + * assigning stream_putlocks to the stream ensures synchronization with + * strlock(). + * + * For lock ordering purposes stream_putlocks are treated as the extension of + * sd_lock and are always grabbed right after grabbing sd_lock and released + * right before releasing sd_lock except putnext/canputnext where only one of + * stream_putlocks locks is used and where it is the first lock to grab. + */ + +typedef struct ciputctrl_str { + union _ciput_un { + uchar_t pad[64]; + struct _ciput_str { + kmutex_t ciput_lck; + ushort_t ciput_cnt; + } ciput_str; + } ciput_un; +} ciputctrl_t; + +#define ciputctrl_lock ciput_un.ciput_str.ciput_lck +#define ciputctrl_count ciput_un.ciput_str.ciput_cnt + +/* + * Header for a stream: interface to rest of system. + * + * NOTE: While this is a consolidation-private structure, some unbundled and + * third-party products inappropriately make use of some of the fields. + * As such, please take care to not gratuitously change any offsets of + * existing members. + */ +typedef struct stdata { + struct queue *sd_wrq; /* write queue */ + struct msgb *sd_iocblk; /* return block for ioctl */ + struct vnode *sd_vnode; /* pointer to associated vnode */ + struct streamtab *sd_strtab; /* pointer to streamtab for stream */ + uint_t sd_flag; /* state/flags */ + uint_t sd_iocid; /* ioctl id */ + struct pid *sd_sidp; /* controlling session info */ + struct pid *sd_pgidp; /* controlling process group info */ + ushort_t sd_tail; /* reserved space in written mblks */ + ushort_t sd_wroff; /* write offset */ + int sd_rerror; /* error to return on read ops */ + int sd_werror; /* error to return on write ops */ + int sd_pushcnt; /* number of pushes done on stream */ + int sd_sigflags; /* logical OR of all siglist events */ + struct strsig *sd_siglist; /* pid linked list to rcv SIGPOLL sig */ + struct pollhead sd_pollist; /* list of all pollers to wake up */ + struct msgb *sd_mark; /* "marked" message on read queue */ + clock_t sd_closetime; /* time to wait to drain q in close */ + kmutex_t sd_lock; /* protect head consistency */ + kcondvar_t sd_monitor; /* open/close/push/pop monitor */ + kcondvar_t sd_iocmonitor; /* ioctl single-threading */ + kcondvar_t sd_refmonitor; /* sd_refcnt monitor */ + ssize_t sd_qn_minpsz; /* These two fields are a performance */ + ssize_t sd_qn_maxpsz; /* enhancements, cache the values in */ + /* the stream head so we don't have */ + /* to ask the module below the stream */ + /* head to get this information. */ + struct stdata *sd_mate; /* pointer to twisted stream mate */ + kthread_id_t sd_freezer; /* thread that froze stream */ + kmutex_t sd_reflock; /* Protects sd_refcnt */ + int sd_refcnt; /* number of claimstr */ + uint_t sd_wakeq; /* strwakeq()'s copy of sd_flag */ + struct queue *sd_struiordq; /* sync barrier struio() read queue */ + struct queue *sd_struiowrq; /* sync barrier struio() write queue */ + char sd_struiodnak; /* defer NAK of M_IOCTL by rput() */ + struct msgb *sd_struionak; /* pointer M_IOCTL mblk(s) to NAK */ + caddr_t sd_t_audit_data; /* For audit purposes only */ + ssize_t sd_maxblk; /* maximum message block size */ + uint_t sd_rput_opt; /* options/flags for strrput */ + uint_t sd_wput_opt; /* options/flags for write/putmsg */ + uint_t sd_read_opt; /* options/flags for strread */ + msgfunc_t sd_rprotofunc; /* rput M_*PROTO routine */ + msgfunc_t sd_rputdatafunc; /* read M_DATA routine */ + msgfunc_t sd_rmiscfunc; /* rput routine (non-data/proto) */ + msgfunc_t sd_wputdatafunc; /* wput M_DATA routine */ + errfunc_t sd_rderrfunc; /* read side error callback */ + errfunc_t sd_wrerrfunc; /* write side error callback */ + /* + * support for low contention concurrent putnext. + */ + ciputctrl_t *sd_ciputctrl; + uint_t sd_nciputctrl; + + int sd_anchor; /* position of anchor in stream */ + /* + * Service scheduling at the stream head. + */ + kmutex_t sd_qlock; + struct queue *sd_qhead; /* Head of queues to be serviced. */ + struct queue *sd_qtail; /* Tail of queues to be serviced. */ + void *sd_servid; /* Service ID for bckgrnd schedule */ + ushort_t sd_svcflags; /* Servicing flags */ + short sd_nqueues; /* Number of queues in the list */ + kcondvar_t sd_qcv; /* Waiters for qhead to become empty */ + kcondvar_t sd_zcopy_wait; + uint_t sd_copyflag; /* copy-related flags */ + zoneid_t sd_anchorzone; /* Allow removal from same zone only */ + struct msgb *sd_cmdblk; /* reply from _I_CMD */ + + /* + * When a STREAMS device is cloned, the sd_vnode element of this + * structure is replaced by a pointer to a common vnode shared across + * all streams that are using the device. In this case, it is no longer + * possible to get from the stream head back to the original vnode via + * sd_vnode. Therefore, when such a device is cloned, the parent vnode - + * i.e. that which was created during the device clone in spec_clone() + * - is kept in sd_pvnode. + */ + struct vnode *sd_pvnode; +} stdata_t; + +/* + * stdata servicing flags. + */ +#define STRS_WILLSERVICE 0x01 +#define STRS_SCHEDULED 0x02 + +#define STREAM_NEEDSERVICE(stp) ((stp)->sd_qhead != NULL) + +/* + * stdata flag field defines + */ +#define IOCWAIT 0x00000001 /* Someone is doing an ioctl */ +#define RSLEEP 0x00000002 /* Someone wants to read/recv msg */ +#define WSLEEP 0x00000004 /* Someone wants to write */ +#define STRPRI 0x00000008 /* An M_PCPROTO is at stream head */ +#define STRHUP 0x00000010 /* Device has vanished */ +#define STWOPEN 0x00000020 /* waiting for 1st open */ +#define STPLEX 0x00000040 /* stream is being multiplexed */ +#define STRISTTY 0x00000080 /* stream is a terminal */ +#define STRGETINPROG 0x00000100 /* (k)strgetmsg is running */ +#define IOCWAITNE 0x00000200 /* STR_NOERROR ioctl running */ +#define STRDERR 0x00000400 /* fatal read error from M_ERROR */ +#define STWRERR 0x00000800 /* fatal write error from M_ERROR */ +#define STRDERRNONPERSIST 0x00001000 /* nonpersistent read errors */ +#define STWRERRNONPERSIST 0x00002000 /* nonpersistent write errors */ +#define STRCLOSE 0x00004000 /* wait for a close to complete */ +#define SNDMREAD 0x00008000 /* used for read notification */ +#define OLDNDELAY 0x00010000 /* use old TTY semantics for */ + /* NDELAY reads and writes */ +#define STRXPG4TTY 0x00020000 /* Use XPG4 TTY semantics */ + /* 0x00040000 unused */ +#define STRTOSTOP 0x00080000 /* block background writes */ +#define STRCMDWAIT 0x00100000 /* someone is doing an _I_CMD */ + /* 0x00200000 unused */ +#define STRMOUNT 0x00400000 /* stream is mounted */ +#define STRNOTATMARK 0x00800000 /* Not at mark (when empty read q) */ +#define STRDELIM 0x01000000 /* generate delimited messages */ +#define STRATMARK 0x02000000 /* At mark (due to MSGMARKNEXT) */ +#define STZCNOTIFY 0x04000000 /* wait for zerocopy mblk to be acked */ +#define STRPLUMB 0x08000000 /* push/pop pending */ +#define STREOF 0x10000000 /* End-of-file indication */ +#define STREOPENFAIL 0x20000000 /* indicates if re-open has failed */ +#define STRMATE 0x40000000 /* this stream is a mate */ +#define STRHASLINKS 0x80000000 /* I_LINKs under this stream */ + +/* + * Copy-related flags (sd_copyflag), set by SO_COPYOPT. + */ +#define STZCVMSAFE 0x00000001 /* safe to borrow file (segmapped) */ + /* pages instead of bcopy */ +#define STZCVMUNSAFE 0x00000002 /* unsafe to borrow file pages */ +#define STRCOPYCACHED 0x00000004 /* copy should NOT bypass cache */ + +/* + * Options and flags for strrput (sd_rput_opt) + */ +#define SR_POLLIN 0x00000001 /* pollwakeup needed for band0 data */ +#define SR_SIGALLDATA 0x00000002 /* Send SIGPOLL for all M_DATA */ +#define SR_CONSOL_DATA 0x00000004 /* Consolidate M_DATA onto q_last */ +#define SR_IGN_ZEROLEN 0x00000008 /* Ignore zero-length M_DATA */ + +/* + * Options and flags for strwrite/strputmsg (sd_wput_opt) + */ +#define SW_SIGPIPE 0x00000001 /* Send SIGPIPE for write error */ +#define SW_RECHECK_ERR 0x00000002 /* Recheck errors in strwrite loop */ +#define SW_SNDZERO 0x00000004 /* send 0-length msg down pipe/FIFO */ + +/* + * Options and flags for strread (sd_read_opt) + */ +#define RD_MSGDIS 0x00000001 /* read msg discard */ +#define RD_MSGNODIS 0x00000002 /* read msg no discard */ +#define RD_PROTDAT 0x00000004 /* read M_[PC]PROTO contents as data */ +#define RD_PROTDIS 0x00000008 /* discard M_[PC]PROTO blocks and */ + /* retain data blocks */ +/* + * Flags parameter for strsetrputhooks() and strsetwputhooks(). + * These flags define the interface for setting the above internal + * flags in sd_rput_opt and sd_wput_opt. + */ +#define SH_CONSOL_DATA 0x00000001 /* Consolidate M_DATA onto q_last */ +#define SH_SIGALLDATA 0x00000002 /* Send SIGPOLL for all M_DATA */ +#define SH_IGN_ZEROLEN 0x00000004 /* Drop zero-length M_DATA */ + +#define SH_SIGPIPE 0x00000100 /* Send SIGPIPE for write error */ +#define SH_RECHECK_ERR 0x00000200 /* Recheck errors in strwrite loop */ + +/* + * Each queue points to a sync queue (the inner perimeter) which keeps + * track of the number of threads that are inside a given queue (sq_count) + * and also is used to implement the asynchronous putnext + * (by queuing messages if the queue can not be entered.) + * + * Messages are queued on sq_head/sq_tail including deferred qwriter(INNER) + * messages. The sq_head/sq_tail list is a singly-linked list with + * b_queue recording the queue and b_prev recording the function to + * be called (either the put procedure or a qwriter callback function.) + * + * The sq_count counter tracks the number of threads that are + * executing inside the perimeter or (in the case of outer perimeters) + * have some work queued for them relating to the perimeter. The sq_rmqcount + * counter tracks the subset which are in removeq() (usually invoked from + * qprocsoff(9F)). + * + * In addition a module writer can declare that the module has an outer + * perimeter (by setting D_MTOUTPERIM) in which case all inner perimeter + * syncq's for the module point (through sq_outer) to an outer perimeter + * syncq. The outer perimeter consists of the doubly linked list (sq_onext and + * sq_oprev) linking all the inner perimeter syncq's with out outer perimeter + * syncq. This is used to implement qwriter(OUTER) (an asynchronous way of + * getting exclusive access at the outer perimeter) and outer_enter/exit + * which are used by the framework to acquire exclusive access to the outer + * perimeter during open and close of modules that have set D_MTOUTPERIM. + * + * In the inner perimeter case sq_save is available for use by machine + * dependent code. sq_head/sq_tail are used to queue deferred messages on + * the inner perimeter syncqs and to queue become_writer requests on the + * outer perimeter syncqs. + * + * Note: machine dependent optimized versions of putnext may depend + * on the order of sq_flags and sq_count (so that they can e.g. + * read these two fields in a single load instruction.) + * + * Per perimeter SQLOCK/sq_count in putnext/put may be replaced by per cpu + * sq_putlocks/sq_putcounts each living in a separate cache line. Obviously + * sq_putlock[x] protects sq_putcount[x]. putnext/put routine will grab only 1 + * of sq_putlocks and update only 1 of sq_putcounts. strlock() and many + * other routines in strsubr.c and ddi.c will grab all sq_putlocks (as well as + * SQLOCK) and figure out the count value as the sum of sq_count and all of + * sq_putcounts. The idea is to make critical fast path -- putnext -- much + * faster at the expense of much less often used slower path like + * strlock(). One known case where entersq/strlock is executed pretty often is + * SpecWeb but since IP is SQ_CIOC and socket TCP/IP stream is nextless + * there's no need to grab multiple sq_putlocks and look at sq_putcounts. See + * strsubr.c for more comments. + * + * Note regular SQLOCK and sq_count are still used in many routines + * (e.g. entersq(), rwnext()) in the same way as before sq_putlocks were + * introduced. + * + * To understand when all sq_putlocks need to be held and all sq_putcounts + * need to be added up one needs to look closely at putnext code. Basically if + * a routine like e.g. wait_syncq() needs to be sure that perimeter is empty + * all sq_putlocks/sq_putcounts need to be held/added up. On the other hand + * there's no need to hold all sq_putlocks and count all sq_putcounts in + * routines like leavesq()/dropsq() and etc. since the are usually exit + * counterparts of entersq/outer_enter() and etc. which have already either + * prevented put entry poins from executing or did not care about put + * entrypoints. entersq() doesn't need to care about sq_putlocks/sq_putcounts + * if the entry point has a shared access since put has the highest degree of + * concurrency and such entersq() does not intend to block out put + * entrypoints. + * + * Before sq_putcounts were introduced the standard way to wait for perimeter + * to become empty was: + * + * mutex_enter(SQLOCK(sq)); + * while (sq->sq_count > 0) { + * sq->sq_flags |= SQ_WANTWAKEUP; + * cv_wait(&sq->sq_wait, SQLOCK(sq)); + * } + * mutex_exit(SQLOCK(sq)); + * + * The new way is: + * + * mutex_enter(SQLOCK(sq)); + * count = sq->sq_count; + * SQ_PUTLOCKS_ENTER(sq); + * SUM_SQ_PUTCOUNTS(sq, count); + * while (count != 0) { + * sq->sq_flags |= SQ_WANTWAKEUP; + * SQ_PUTLOCKS_EXIT(sq); + * cv_wait(&sq->sq_wait, SQLOCK(sq)); + * count = sq->sq_count; + * SQ_PUTLOCKS_ENTER(sq); + * SUM_SQ_PUTCOUNTS(sq, count); + * } + * SQ_PUTLOCKS_EXIT(sq); + * mutex_exit(SQLOCK(sq)); + * + * Note that SQ_WANTWAKEUP is set before dropping SQ_PUTLOCKS. This makes sure + * putnext won't skip a wakeup. + * + * sq_putlocks are treated as the extension of SQLOCK for lock ordering + * purposes and are always grabbed right after grabbing SQLOCK and released + * right before releasing SQLOCK. This also allows dynamic creation of + * sq_putlocks while holding SQLOCK (by making sq_ciputctrl non null even when + * the stream is already in use). Only in putnext one of sq_putlocks + * is grabbed instead of SQLOCK. putnext return path remembers what counter it + * incremented and decrements the right counter on its way out. + */ + +struct syncq { + kmutex_t sq_lock; /* atomic access to syncq */ + uint16_t sq_count; /* # threads inside */ + uint16_t sq_flags; /* state and some type info */ + /* + * Distributed syncq scheduling + * The list of queue's is handled by sq_head and + * sq_tail fields. + * + * The list of events is handled by the sq_evhead and sq_evtail + * fields. + */ + queue_t *sq_head; /* queue of deferred messages */ + queue_t *sq_tail; /* queue of deferred messages */ + mblk_t *sq_evhead; /* Event message on the syncq */ + mblk_t *sq_evtail; + uint_t sq_nqueues; /* # of queues on this sq */ + /* + * Concurrency and condition variables + */ + uint16_t sq_type; /* type (concurrency) of syncq */ + uint16_t sq_rmqcount; /* # threads inside removeq() */ + kcondvar_t sq_wait; /* block on this sync queue */ + kcondvar_t sq_exitwait; /* waiting for thread to leave the */ + /* inner perimeter */ + /* + * Handling synchronous callbacks such as qtimeout and qbufcall + */ + ushort_t sq_callbflags; /* flags for callback synchronization */ + callbparams_id_t sq_cancelid; /* id of callback being cancelled */ + struct callbparams *sq_callbpend; /* Pending callbacks */ + + /* + * Links forming an outer perimeter from one outer syncq and + * a set of inner sync queues. + */ + struct syncq *sq_outer; /* Pointer to outer perimeter */ + struct syncq *sq_onext; /* Linked list of syncq's making */ + struct syncq *sq_oprev; /* up the outer perimeter. */ + /* + * support for low contention concurrent putnext. + */ + ciputctrl_t *sq_ciputctrl; + uint_t sq_nciputctrl; + /* + * Counter for the number of threads wanting to become exclusive. + */ + uint_t sq_needexcl; + /* + * These two fields are used for scheduling a syncq for + * background processing. The sq_svcflag is protected by + * SQLOCK lock. + */ + struct syncq *sq_next; /* for syncq scheduling */ + void * sq_servid; + uint_t sq_servcount; /* # pending background threads */ + uint_t sq_svcflags; /* Scheduling flags */ + clock_t sq_tstamp; /* Time when was enabled */ + /* + * Maximum priority of the queues on this syncq. + */ + pri_t sq_pri; +}; +typedef struct syncq syncq_t; + +/* + * sync queue scheduling flags (for sq_svcflags). + */ +#define SQ_SERVICE 0x1 /* being serviced */ +#define SQ_BGTHREAD 0x2 /* awaiting service by bg thread */ +#define SQ_DISABLED 0x4 /* don't put syncq in service list */ + +/* + * FASTPUT bit in sd_count/putcount. + */ +#define SQ_FASTPUT 0x8000 +#define SQ_FASTMASK 0x7FFF + +/* + * sync queue state flags + */ +#define SQ_EXCL 0x0001 /* exclusive access to inner */ + /* perimeter */ +#define SQ_BLOCKED 0x0002 /* qprocsoff */ +#define SQ_FROZEN 0x0004 /* freezestr */ +#define SQ_WRITER 0x0008 /* qwriter(OUTER) pending or running */ +#define SQ_MESSAGES 0x0010 /* messages on syncq */ +#define SQ_WANTWAKEUP 0x0020 /* do cv_broadcast on sq_wait */ +#define SQ_WANTEXWAKEUP 0x0040 /* do cv_broadcast on sq_exitwait */ +#define SQ_EVENTS 0x0080 /* Events pending */ +#define SQ_QUEUED (SQ_MESSAGES | SQ_EVENTS) +#define SQ_FLAGMASK 0x00FF + +/* + * Test a queue to see if inner perimeter is exclusive. + */ +#define PERIM_EXCL(q) ((q)->q_syncq->sq_flags & SQ_EXCL) + +/* + * If any of these flags are set it is not possible for a thread to + * enter a put or service procedure. Instead it must either block + * or put the message on the syncq. + */ +#define SQ_GOAWAY (SQ_EXCL|SQ_BLOCKED|SQ_FROZEN|SQ_WRITER|\ + SQ_QUEUED) +/* + * If any of these flags are set it not possible to drain the syncq + */ +#define SQ_STAYAWAY (SQ_BLOCKED|SQ_FROZEN|SQ_WRITER) + +/* + * Flags to trigger syncq tail processing. + */ +#define SQ_TAIL (SQ_QUEUED|SQ_WANTWAKEUP|SQ_WANTEXWAKEUP) + +/* + * Syncq types (stored in sq_type) + * The SQ_TYPES_IN_FLAGS (ciput) are also stored in sq_flags + * for performance reasons. Thus these type values have to be in the low + * 16 bits and not conflict with the sq_flags values above. + * + * Notes: + * - putnext() and put() assume that the put procedures have the highest + * degree of concurrency. Thus if any of the SQ_CI* are set then SQ_CIPUT + * has to be set. This restriction can be lifted by adding code to putnext + * and put that check that sq_count == 0 like entersq does. + * - putnext() and put() does currently not handle !SQ_COPUT + * - In order to implement !SQ_COCB outer_enter has to be fixed so that + * the callback can be cancelled while cv_waiting in outer_enter. + * - If SQ_CISVC needs to be implemented, qprocsoff() needs to wait + * for the currently running services to stop (wait for QINSERVICE + * to go off). disable_svc called from qprcosoff disables only + * services that will be run in future. + * + * All the SQ_CO flags are set when there is no outer perimeter. + */ +#define SQ_CIPUT 0x0100 /* Concurrent inner put proc */ +#define SQ_CISVC 0x0200 /* Concurrent inner svc proc */ +#define SQ_CIOC 0x0400 /* Concurrent inner open/close */ +#define SQ_CICB 0x0800 /* Concurrent inner callback */ +#define SQ_COPUT 0x1000 /* Concurrent outer put proc */ +#define SQ_COSVC 0x2000 /* Concurrent outer svc proc */ +#define SQ_COOC 0x4000 /* Concurrent outer open/close */ +#define SQ_COCB 0x8000 /* Concurrent outer callback */ + +/* Types also kept in sq_flags for performance */ +#define SQ_TYPES_IN_FLAGS (SQ_CIPUT) + +#define SQ_CI (SQ_CIPUT|SQ_CISVC|SQ_CIOC|SQ_CICB) +#define SQ_CO (SQ_COPUT|SQ_COSVC|SQ_COOC|SQ_COCB) +#define SQ_TYPEMASK (SQ_CI|SQ_CO) + +/* + * Flag combinations passed to entersq and leavesq to specify the type + * of entry point. + */ +#define SQ_PUT (SQ_CIPUT|SQ_COPUT) +#define SQ_SVC (SQ_CISVC|SQ_COSVC) +#define SQ_OPENCLOSE (SQ_CIOC|SQ_COOC) +#define SQ_CALLBACK (SQ_CICB|SQ_COCB) + +/* + * Other syncq types which are not copied into flags. + */ +#define SQ_PERMOD 0x01 /* Syncq is PERMOD */ + +/* + * Asynchronous callback qun*** flag. + * The mechanism these flags are used in is one where callbacks enter + * the perimeter thanks to framework support. To use this mechanism + * the q* and qun* flavors of the callback routines must be used. + * e.g. qtimeout and quntimeout. The synchronization provided by the flags + * avoids deadlocks between blocking qun* routines and the perimeter + * lock. + */ +#define SQ_CALLB_BYPASSED 0x01 /* bypassed callback fn */ + +/* + * Cancel callback mask. + * The mask expands as the number of cancelable callback types grows + * Note - separate callback flag because different callbacks have + * overlapping id space. + */ +#define SQ_CALLB_CANCEL_MASK (SQ_CANCEL_TOUT|SQ_CANCEL_BUFCALL) + +#define SQ_CANCEL_TOUT 0x02 /* cancel timeout request */ +#define SQ_CANCEL_BUFCALL 0x04 /* cancel bufcall request */ + +typedef struct callbparams { + syncq_t *cbp_sq; + void (*cbp_func)(void *); + void *cbp_arg; + callbparams_id_t cbp_id; + uint_t cbp_flags; + struct callbparams *cbp_next; + size_t cbp_size; +} callbparams_t; + +typedef struct strbufcall { + void (*bc_func)(void *); + void *bc_arg; + size_t bc_size; + bufcall_id_t bc_id; + struct strbufcall *bc_next; + kthread_id_t bc_executor; +} strbufcall_t; + +/* + * Structure of list of processes to be sent SIGPOLL/SIGURG signal + * on request. The valid S_* events are defined in stropts.h. + */ +typedef struct strsig { + struct pid *ss_pidp; /* pid/pgrp pointer */ + pid_t ss_pid; /* positive pid, negative pgrp */ + int ss_events; /* S_* events */ + struct strsig *ss_next; +} strsig_t; + +/* + * bufcall list + */ +struct bclist { + strbufcall_t *bc_head; + strbufcall_t *bc_tail; +}; + +/* + * Structure used to track mux links and unlinks. + */ +struct mux_node { + major_t mn_imaj; /* internal major device number */ + uint16_t mn_indegree; /* number of incoming edges */ + struct mux_node *mn_originp; /* where we came from during search */ + struct mux_edge *mn_startp; /* where search left off in mn_outp */ + struct mux_edge *mn_outp; /* list of outgoing edges */ + uint_t mn_flags; /* see below */ +}; + +/* + * Flags for mux_nodes. + */ +#define VISITED 1 + +/* + * Edge structure - a list of these is hung off the + * mux_node to represent the outgoing edges. + */ +struct mux_edge { + struct mux_node *me_nodep; /* edge leads to this node */ + struct mux_edge *me_nextp; /* next edge */ + int me_muxid; /* id of link */ + dev_t me_dev; /* dev_t - used for kernel PUNLINK */ +}; + +/* + * Queue info + * + * The syncq is included here to reduce memory fragmentation + * for kernel memory allocators that only allocate in sizes that are + * powers of two. If the kernel memory allocator changes this should + * be revisited. + */ +typedef struct queinfo { + struct queue qu_rqueue; /* read queue - must be first */ + struct queue qu_wqueue; /* write queue - must be second */ + struct syncq qu_syncq; /* syncq - must be third */ +} queinfo_t; + +/* + * Multiplexed streams info + */ +typedef struct linkinfo { + struct linkblk li_lblk; /* must be first */ + struct file *li_fpdown; /* file pointer for lower stream */ + struct linkinfo *li_next; /* next in list */ + struct linkinfo *li_prev; /* previous in list */ +} linkinfo_t; + +/* + * List of syncq's used by freeezestr/unfreezestr + */ +typedef struct syncql { + struct syncql *sql_next; + syncq_t *sql_sq; +} syncql_t; + +typedef struct sqlist { + syncql_t *sqlist_head; + size_t sqlist_size; /* structure size in bytes */ + size_t sqlist_index; /* next free entry in array */ + syncql_t sqlist_array[4]; /* 4 or more entries */ +} sqlist_t; + +typedef struct perdm { + struct perdm *dm_next; + syncq_t *dm_sq; + struct streamtab *dm_str; + uint_t dm_ref; +} perdm_t; + +#define NEED_DM(dmp, qflag) \ + (dmp == NULL && (qflag & (QPERMOD | QMTOUTPERIM))) + +/* + * fmodsw_impl_t is used within the kernel. fmodsw is used by + * the modules/drivers. The information is copied from fmodsw + * defined in the module/driver into the fmodsw_impl_t structure + * during the module/driver initialization. + */ +typedef struct fmodsw_impl fmodsw_impl_t; + +struct fmodsw_impl { + fmodsw_impl_t *f_next; + char f_name[FMNAMESZ + 1]; + struct streamtab *f_str; + uint32_t f_qflag; + uint32_t f_sqtype; + perdm_t *f_dmp; + uint32_t f_ref; + uint32_t f_hits; +}; + +typedef enum { + FMODSW_HOLD = 0x00000001, + FMODSW_LOAD = 0x00000002 +} fmodsw_flags_t; + +typedef struct cdevsw_impl { + struct streamtab *d_str; + uint32_t d_qflag; + uint32_t d_sqtype; + perdm_t *d_dmp; +} cdevsw_impl_t; + +/* + * Enumeration of the types of access that can be requested for a + * controlling terminal under job control. + */ +enum jcaccess { + JCREAD, /* read data on a ctty */ + JCWRITE, /* write data to a ctty */ + JCSETP, /* set ctty parameters */ + JCGETP /* get ctty parameters */ +}; + +struct str_stack { + netstack_t *ss_netstack; /* Common netstack */ + + kmutex_t ss_sad_lock; /* autopush lock */ + mod_hash_t *ss_sad_hash; + size_t ss_sad_hash_nchains; + struct saddev *ss_saddev; /* sad device array */ + int ss_sadcnt; /* number of sad devices */ + + int ss_devcnt; /* number of mux_nodes */ + struct mux_node *ss_mux_nodes; /* mux info for cycle checking */ +}; +typedef struct str_stack str_stack_t; + +/* + * Finding related queues + */ +#define STREAM(q) ((q)->q_stream) +#define SQ(rq) ((syncq_t *)((rq) + 2)) + +/* + * Get the module/driver name for a queue. Since some queues don't have + * q_info structures (e.g., see log_makeq()), fall back to "?". + */ +#define Q2NAME(q) \ + (((q)->q_qinfo != NULL && (q)->q_qinfo->qi_minfo->mi_idname != NULL) ? \ + (q)->q_qinfo->qi_minfo->mi_idname : "?") + +/* + * Locking macros + */ +#define QLOCK(q) (&(q)->q_lock) +#define SQLOCK(sq) (&(sq)->sq_lock) + +#define STREAM_PUTLOCKS_ENTER(stp) { \ + ASSERT(MUTEX_HELD(&(stp)->sd_lock)); \ + if ((stp)->sd_ciputctrl != NULL) { \ + int i; \ + int nlocks = (stp)->sd_nciputctrl; \ + ciputctrl_t *cip = (stp)->sd_ciputctrl; \ + for (i = 0; i <= nlocks; i++) { \ + mutex_enter(&cip[i].ciputctrl_lock); \ + } \ + } \ + } + +#define STREAM_PUTLOCKS_EXIT(stp) { \ + ASSERT(MUTEX_HELD(&(stp)->sd_lock)); \ + if ((stp)->sd_ciputctrl != NULL) { \ + int i; \ + int nlocks = (stp)->sd_nciputctrl; \ + ciputctrl_t *cip = (stp)->sd_ciputctrl; \ + for (i = 0; i <= nlocks; i++) { \ + mutex_exit(&cip[i].ciputctrl_lock); \ + } \ + } \ + } + +#define SQ_PUTLOCKS_ENTER(sq) { \ + ASSERT(MUTEX_HELD(SQLOCK(sq))); \ + if ((sq)->sq_ciputctrl != NULL) { \ + int i; \ + int nlocks = (sq)->sq_nciputctrl; \ + ciputctrl_t *cip = (sq)->sq_ciputctrl; \ + ASSERT((sq)->sq_type & SQ_CIPUT); \ + for (i = 0; i <= nlocks; i++) { \ + mutex_enter(&cip[i].ciputctrl_lock); \ + } \ + } \ + } + +#define SQ_PUTLOCKS_EXIT(sq) { \ + ASSERT(MUTEX_HELD(SQLOCK(sq))); \ + if ((sq)->sq_ciputctrl != NULL) { \ + int i; \ + int nlocks = (sq)->sq_nciputctrl; \ + ciputctrl_t *cip = (sq)->sq_ciputctrl; \ + ASSERT((sq)->sq_type & SQ_CIPUT); \ + for (i = 0; i <= nlocks; i++) { \ + mutex_exit(&cip[i].ciputctrl_lock); \ + } \ + } \ + } + +#define SQ_PUTCOUNT_SETFAST(sq) { \ + ASSERT(MUTEX_HELD(SQLOCK(sq))); \ + if ((sq)->sq_ciputctrl != NULL) { \ + int i; \ + int nlocks = (sq)->sq_nciputctrl; \ + ciputctrl_t *cip = (sq)->sq_ciputctrl; \ + ASSERT((sq)->sq_type & SQ_CIPUT); \ + for (i = 0; i <= nlocks; i++) { \ + mutex_enter(&cip[i].ciputctrl_lock); \ + cip[i].ciputctrl_count |= SQ_FASTPUT; \ + mutex_exit(&cip[i].ciputctrl_lock); \ + } \ + } \ + } + +#define SQ_PUTCOUNT_CLRFAST(sq) { \ + ASSERT(MUTEX_HELD(SQLOCK(sq))); \ + if ((sq)->sq_ciputctrl != NULL) { \ + int i; \ + int nlocks = (sq)->sq_nciputctrl; \ + ciputctrl_t *cip = (sq)->sq_ciputctrl; \ + ASSERT((sq)->sq_type & SQ_CIPUT); \ + for (i = 0; i <= nlocks; i++) { \ + mutex_enter(&cip[i].ciputctrl_lock); \ + cip[i].ciputctrl_count &= ~SQ_FASTPUT; \ + mutex_exit(&cip[i].ciputctrl_lock); \ + } \ + } \ + } + + +#ifdef DEBUG + +#define SQ_PUTLOCKS_HELD(sq) { \ + ASSERT(MUTEX_HELD(SQLOCK(sq))); \ + if ((sq)->sq_ciputctrl != NULL) { \ + int i; \ + int nlocks = (sq)->sq_nciputctrl; \ + ciputctrl_t *cip = (sq)->sq_ciputctrl; \ + ASSERT((sq)->sq_type & SQ_CIPUT); \ + for (i = 0; i <= nlocks; i++) { \ + ASSERT(MUTEX_HELD(&cip[i].ciputctrl_lock)); \ + } \ + } \ + } + +#define SUMCHECK_SQ_PUTCOUNTS(sq, countcheck) { \ + if ((sq)->sq_ciputctrl != NULL) { \ + int i; \ + uint_t count = 0; \ + int ncounts = (sq)->sq_nciputctrl; \ + ASSERT((sq)->sq_type & SQ_CIPUT); \ + for (i = 0; i <= ncounts; i++) { \ + count += \ + (((sq)->sq_ciputctrl[i].ciputctrl_count) & \ + SQ_FASTMASK); \ + } \ + ASSERT(count == (countcheck)); \ + } \ + } + +#define SUMCHECK_CIPUTCTRL_COUNTS(ciput, nciput, countcheck) { \ + int i; \ + uint_t count = 0; \ + ASSERT((ciput) != NULL); \ + for (i = 0; i <= (nciput); i++) { \ + count += (((ciput)[i].ciputctrl_count) & \ + SQ_FASTMASK); \ + } \ + ASSERT(count == (countcheck)); \ + } + +#else /* DEBUG */ + +#define SQ_PUTLOCKS_HELD(sq) +#define SUMCHECK_SQ_PUTCOUNTS(sq, countcheck) +#define SUMCHECK_CIPUTCTRL_COUNTS(sq, nciput, countcheck) + +#endif /* DEBUG */ + +#define SUM_SQ_PUTCOUNTS(sq, count) { \ + if ((sq)->sq_ciputctrl != NULL) { \ + int i; \ + int ncounts = (sq)->sq_nciputctrl; \ + ciputctrl_t *cip = (sq)->sq_ciputctrl; \ + ASSERT((sq)->sq_type & SQ_CIPUT); \ + for (i = 0; i <= ncounts; i++) { \ + (count) += ((cip[i].ciputctrl_count) & \ + SQ_FASTMASK); \ + } \ + } \ + } + +#define CLAIM_QNEXT_LOCK(stp) mutex_enter(&(stp)->sd_lock) +#define RELEASE_QNEXT_LOCK(stp) mutex_exit(&(stp)->sd_lock) + +/* + * syncq message manipulation macros. + */ +/* + * Put a message on the queue syncq. + * Assumes QLOCK held. + */ +#define SQPUT_MP(qp, mp) \ + { \ + qp->q_syncqmsgs++; \ + if (qp->q_sqhead == NULL) { \ + qp->q_sqhead = qp->q_sqtail = mp; \ + } else { \ + qp->q_sqtail->b_next = mp; \ + qp->q_sqtail = mp; \ + } \ + set_qfull(qp); \ + } + +/* + * Miscellaneous parameters and flags. + */ + +/* + * Default timeout in milliseconds for ioctls and close + */ +#define STRTIMOUT 15000 + +/* + * Flag values for stream io + */ +#define WRITEWAIT 0x1 /* waiting for write event */ +#define READWAIT 0x2 /* waiting for read event */ +#define NOINTR 0x4 /* error is not to be set for signal */ +#define GETWAIT 0x8 /* waiting for getmsg event */ + +/* + * These flags need to be unique for stream io name space + * and copy modes name space. These flags allow strwaitq + * and strdoioctl to proceed as if signals or errors on the stream + * head have not occurred; i.e. they will be detected by some other + * means. + * STR_NOSIG does not allow signals to interrupt the call + * STR_NOERROR does not allow stream head read, write or hup errors to + * affect the call. When used with strdoioctl(), if a previous ioctl + * is pending and times out, STR_NOERROR will cause strdoioctl() to not + * return ETIME. If, however, the requested ioctl times out, ETIME + * will be returned (use ic_timout instead) + * STR_PEEK is used to inform strwaitq that the reader is peeking at data + * and that a non-persistent error should not be cleared. + * STR_DELAYERR is used to inform strwaitq that it should not check errors + * after being awoken since, in addition to an error, there might also be + * data queued on the stream head read queue. + */ +#define STR_NOSIG 0x10 /* Ignore signals during strdoioctl/strwaitq */ +#define STR_NOERROR 0x20 /* Ignore errors during strdoioctl/strwaitq */ +#define STR_PEEK 0x40 /* Peeking behavior on non-persistent errors */ +#define STR_DELAYERR 0x80 /* Do not check errors on return */ + +/* + * Copy modes for tty and I_STR ioctls + */ +#define U_TO_K 01 /* User to Kernel */ +#define K_TO_K 02 /* Kernel to Kernel */ + +/* + * Mux defines. + */ +#define LINKNORMAL 0x01 /* normal mux link */ +#define LINKPERSIST 0x02 /* persistent mux link */ +#define LINKTYPEMASK 0x03 /* bitmask of all link types */ +#define LINKCLOSE 0x04 /* unlink from strclose */ + +/* + * Definitions of Streams macros and function interfaces. + */ + +/* + * Obsolete queue scheduling macros. They are not used anymore, but still kept + * here for 3-d party modules and drivers who might still use them. + */ +#define setqsched() +#define qready() 1 + +#ifdef _KERNEL +#define runqueues() +#define queuerun() +#endif + +/* compatibility module for style 2 drivers with DR race condition */ +#define DRMODNAME "drcompat" + +/* + * Macros dealing with mux_nodes. + */ +#define MUX_VISIT(X) ((X)->mn_flags |= VISITED) +#define MUX_CLEAR(X) ((X)->mn_flags &= (~VISITED)); \ + ((X)->mn_originp = NULL) +#define MUX_DIDVISIT(X) ((X)->mn_flags & VISITED) + + +/* + * Twisted stream macros + */ +#define STRMATED(X) ((X)->sd_flag & STRMATE) +#define STRLOCKMATES(X) if (&((X)->sd_lock) > &(((X)->sd_mate)->sd_lock)) { \ + mutex_enter(&((X)->sd_lock)); \ + mutex_enter(&(((X)->sd_mate)->sd_lock)); \ + } else { \ + mutex_enter(&(((X)->sd_mate)->sd_lock)); \ + mutex_enter(&((X)->sd_lock)); \ + } +#define STRUNLOCKMATES(X) mutex_exit(&((X)->sd_lock)); \ + mutex_exit(&(((X)->sd_mate)->sd_lock)) + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern void strinit(void); +extern int strdoioctl(struct stdata *, struct strioctl *, int, int, + cred_t *, int *); +extern void strsendsig(struct strsig *, int, uchar_t, int); +extern void str_sendsig(vnode_t *, int, uchar_t, int); +extern void strhup(struct stdata *); +extern int qattach(queue_t *, dev_t *, int, cred_t *, fmodsw_impl_t *, + boolean_t); +extern int qreopen(queue_t *, dev_t *, int, cred_t *); +extern void qdetach(queue_t *, int, int, cred_t *, boolean_t); +extern void enterq(queue_t *); +extern void leaveq(queue_t *); +extern int putiocd(mblk_t *, caddr_t, int, cred_t *); +extern int getiocd(mblk_t *, caddr_t, int); +extern struct linkinfo *alloclink(queue_t *, queue_t *, struct file *); +extern void lbfree(struct linkinfo *); +extern int linkcycle(stdata_t *, stdata_t *, str_stack_t *); +extern struct linkinfo *findlinks(stdata_t *, int, int, str_stack_t *); +extern queue_t *getendq(queue_t *); +extern int mlink(vnode_t *, int, int, cred_t *, int *, int); +extern int mlink_file(vnode_t *, int, struct file *, cred_t *, int *, int); +extern int munlink(struct stdata *, struct linkinfo *, int, cred_t *, int *, + str_stack_t *); +extern int munlinkall(struct stdata *, int, cred_t *, int *, str_stack_t *); +extern void mux_addedge(stdata_t *, stdata_t *, int, str_stack_t *); +extern void mux_rmvedge(stdata_t *, int, str_stack_t *); +extern int devflg_to_qflag(struct streamtab *, uint32_t, uint32_t *, + uint32_t *); +extern void setq(queue_t *, struct qinit *, struct qinit *, perdm_t *, + uint32_t, uint32_t, boolean_t); +extern perdm_t *hold_dm(struct streamtab *, uint32_t, uint32_t); +extern void rele_dm(perdm_t *); +extern int strmakectl(struct strbuf *, int32_t, int32_t, mblk_t **); +extern int strmakedata(ssize_t *, struct uio *, stdata_t *, int32_t, mblk_t **); +extern int strmakemsg(struct strbuf *, ssize_t *, struct uio *, + struct stdata *, int32_t, mblk_t **); +extern int strgetmsg(vnode_t *, struct strbuf *, struct strbuf *, uchar_t *, + int *, int, rval_t *); +extern int strputmsg(vnode_t *, struct strbuf *, struct strbuf *, uchar_t, + int flag, int fmode); +extern int strstartplumb(struct stdata *, int, int); +extern void strendplumb(struct stdata *); +extern int stropen(struct vnode *, dev_t *, int, cred_t *); +extern int strclose(struct vnode *, int, cred_t *); +extern int strpoll(register struct stdata *, short, int, short *, + struct pollhead **); +extern void strclean(struct vnode *); +extern void str_cn_clean(); /* XXX hook for consoles signal cleanup */ +extern int strwrite(struct vnode *, struct uio *, cred_t *); +extern int strwrite_common(struct vnode *, struct uio *, cred_t *, int); +extern int strread(struct vnode *, struct uio *, cred_t *); +extern int strioctl(struct vnode *, int, intptr_t, int, int, cred_t *, int *); +extern int strrput(queue_t *, mblk_t *); +extern int strrput_nondata(queue_t *, mblk_t *); +extern mblk_t *strrput_proto(vnode_t *, mblk_t *, + strwakeup_t *, strsigset_t *, strsigset_t *, strpollset_t *); +extern mblk_t *strrput_misc(vnode_t *, mblk_t *, + strwakeup_t *, strsigset_t *, strsigset_t *, strpollset_t *); +extern int getiocseqno(void); +extern int strwaitbuf(size_t, int); +extern int strwaitq(stdata_t *, int, ssize_t, int, clock_t, int *); +extern struct stdata *shalloc(queue_t *); +extern void shfree(struct stdata *s); +extern queue_t *allocq(void); +extern void freeq(queue_t *); +extern qband_t *allocband(void); +extern void freeband(qband_t *); +extern void freebs_enqueue(mblk_t *, dblk_t *); +extern void setqback(queue_t *, unsigned char); +extern int strcopyin(void *, void *, size_t, int); +extern int strcopyout(void *, void *, size_t, int); +extern void strsignal(struct stdata *, int, int32_t); +extern clock_t str_cv_wait(kcondvar_t *, kmutex_t *, clock_t, int); +extern void disable_svc(queue_t *); +extern void enable_svc(queue_t *); +extern void remove_runlist(queue_t *); +extern void wait_svc(queue_t *); +extern void backenable(queue_t *, uchar_t); +extern void set_qend(queue_t *); +extern int strgeterr(stdata_t *, int32_t, int); +extern void qenable_locked(queue_t *); +extern mblk_t *getq_noenab(queue_t *, ssize_t); +extern void rmvq_noenab(queue_t *, mblk_t *); +extern void qbackenable(queue_t *, uchar_t); +extern void set_qfull(queue_t *); + +extern void strblock(queue_t *); +extern void strunblock(queue_t *); +extern int qclaimed(queue_t *); +extern int straccess(struct stdata *, enum jcaccess); + +extern void entersq(syncq_t *, int); +extern void leavesq(syncq_t *, int); +extern void claimq(queue_t *); +extern void releaseq(queue_t *); +extern void claimstr(queue_t *); +extern void releasestr(queue_t *); +extern void removeq(queue_t *); +extern void insertq(struct stdata *, queue_t *); +extern void drain_syncq(syncq_t *); +extern void qfill_syncq(syncq_t *, queue_t *, mblk_t *); +extern void qdrain_syncq(syncq_t *, queue_t *); +extern int flush_syncq(syncq_t *, queue_t *); +extern void wait_sq_svc(syncq_t *); + +extern void outer_enter(syncq_t *, uint16_t); +extern void outer_exit(syncq_t *); +extern void qwriter_inner(queue_t *, mblk_t *, void (*)()); +extern void qwriter_outer(queue_t *, mblk_t *, void (*)()); + +extern callbparams_t *callbparams_alloc(syncq_t *, void (*)(void *), + void *, int); +extern void callbparams_free(syncq_t *, callbparams_t *); +extern void callbparams_free_id(syncq_t *, callbparams_id_t, int32_t); +extern void qcallbwrapper(void *); + +extern mblk_t *esballoc_wait(unsigned char *, size_t, uint_t, frtn_t *); +extern mblk_t *esballoca(unsigned char *, size_t, uint_t, frtn_t *); +extern mblk_t *esballoca_wait(unsigned char *, size_t, uint_t, frtn_t *); +extern mblk_t *desballoca(unsigned char *, size_t, uint_t, frtn_t *); +extern int do_sendfp(struct stdata *, struct file *, struct cred *); +extern int frozenstr(queue_t *); +extern size_t xmsgsize(mblk_t *); + +extern void putnext_tail(syncq_t *, queue_t *, uint32_t); +extern void stream_willservice(stdata_t *); +extern void stream_runservice(stdata_t *); + +extern void strmate(vnode_t *, vnode_t *); +extern queue_t *strvp2wq(vnode_t *); +extern vnode_t *strq2vp(queue_t *); +extern mblk_t *allocb_wait(size_t, uint_t, uint_t, int *); +extern mblk_t *allocb_cred(size_t, cred_t *, pid_t); +extern mblk_t *allocb_cred_wait(size_t, uint_t, int *, cred_t *, pid_t); +extern mblk_t *allocb_tmpl(size_t, const mblk_t *); +extern mblk_t *allocb_tryhard(size_t); +extern void mblk_copycred(mblk_t *, const mblk_t *); +extern void mblk_setcred(mblk_t *, cred_t *, pid_t); +extern cred_t *msg_getcred(const mblk_t *, pid_t *); +extern struct ts_label_s *msg_getlabel(const mblk_t *); +extern cred_t *msg_extractcred(mblk_t *, pid_t *); +extern void strpollwakeup(vnode_t *, short); +extern int putnextctl_wait(queue_t *, int); + +extern int kstrputmsg(struct vnode *, mblk_t *, struct uio *, ssize_t, + unsigned char, int, int); +extern int kstrgetmsg(struct vnode *, mblk_t **, struct uio *, + unsigned char *, int *, clock_t, rval_t *); + +extern void strsetrerror(vnode_t *, int, int, errfunc_t); +extern void strsetwerror(vnode_t *, int, int, errfunc_t); +extern void strseteof(vnode_t *, int); +extern void strflushrq(vnode_t *, int); +extern void strsetrputhooks(vnode_t *, uint_t, msgfunc_t, msgfunc_t); +extern void strsetwputhooks(vnode_t *, uint_t, clock_t); +extern void strsetrwputdatahooks(vnode_t *, msgfunc_t, msgfunc_t); +extern int strwaitmark(vnode_t *); +extern void strsignal_nolock(stdata_t *, int, uchar_t); + +struct pdesc_s; + +extern void lso_info_set(mblk_t *, uint32_t, uint32_t); +extern void lso_info_cleanup(mblk_t *); +extern unsigned int bcksum(uchar_t *, int, unsigned int); + +extern int fmodsw_register(const char *, struct streamtab *, int); +extern int fmodsw_unregister(const char *); +extern fmodsw_impl_t *fmodsw_find(const char *, fmodsw_flags_t); +extern void fmodsw_rele(fmodsw_impl_t *); + +extern void freemsgchain(mblk_t *); +extern mblk_t *copymsgchain(mblk_t *); + +extern mblk_t *mcopyinuio(struct stdata *, uio_t *, ssize_t, ssize_t, int *); + +/* + * shared or externally configured data structures + */ +extern ssize_t strmsgsz; /* maximum stream message size */ +extern ssize_t strctlsz; /* maximum size of ctl message */ +extern int nstrpush; /* maximum number of pushes allowed */ + +/* + * Bufcalls related variables. + */ +extern struct bclist strbcalls; /* List of bufcalls */ +extern kmutex_t strbcall_lock; /* Protects the list of bufcalls */ +extern kcondvar_t strbcall_cv; /* Signaling when a bufcall is added */ +extern kcondvar_t bcall_cv; /* wait of executing bufcall completes */ + +extern frtn_t frnop; + +extern struct kmem_cache *ciputctrl_cache; +extern int n_ciputctrl; +extern int max_n_ciputctrl; +extern int min_n_ciputctrl; + +extern cdevsw_impl_t *devimpl; + +/* + * esballoc queue for throttling + */ +typedef struct esb_queue { + kmutex_t eq_lock; + uint_t eq_len; /* number of queued messages */ + mblk_t *eq_head; /* head of queue */ + mblk_t *eq_tail; /* tail of queue */ + uint_t eq_flags; /* esballoc queue flags */ +} esb_queue_t; + +/* + * esballoc flags for queue processing. + */ +#define ESBQ_PROCESSING 0x01 /* queue is being processed */ +#define ESBQ_TIMER 0x02 /* timer is active */ + +extern void esballoc_queue_init(void); + +#endif /* _KERNEL */ + +/* + * Note: Use of these macros are restricted to kernel/unix and + * intended for the STREAMS framework. + * All modules/drivers should include sys/ddi.h. + * + * Finding related queues + */ +#define _OTHERQ(q) ((q)->q_flag&QREADR? (q)+1: (q)-1) +#define _WR(q) ((q)->q_flag&QREADR? (q)+1: (q)) +#define _RD(q) ((q)->q_flag&QREADR? (q): (q)-1) +#define _SAMESTR(q) (!((q)->q_flag & QEND)) + +/* + * These are also declared here for modules/drivers that erroneously + * include strsubr.h after ddi.h or fail to include ddi.h at all. + */ +extern struct queue *OTHERQ(queue_t *); /* stream.h */ +extern struct queue *RD(queue_t *); +extern struct queue *WR(queue_t *); +extern int SAMESTR(queue_t *); + +/* + * The following hardware checksum related macros are private + * interfaces that are subject to change without notice. + */ +#ifdef _KERNEL +#define DB_CKSUMSTART(mp) ((mp)->b_datap->db_cksumstart) +#define DB_CKSUMEND(mp) ((mp)->b_datap->db_cksumend) +#define DB_CKSUMSTUFF(mp) ((mp)->b_datap->db_cksumstuff) +#define DB_CKSUMFLAGS(mp) ((mp)->b_datap->db_struioun.cksum.flags) +#define DB_CKSUM16(mp) ((mp)->b_datap->db_cksum16) +#define DB_CKSUM32(mp) ((mp)->b_datap->db_cksum32) +#define DB_LSOFLAGS(mp) ((mp)->b_datap->db_struioun.cksum.flags) +#define DB_LSOMSS(mp) ((mp)->b_datap->db_struioun.cksum.pad) +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + + +#endif /* _SYS_STRSUBR_H */ diff --git a/illumos-x86_64/usr/include/sys/strsun.h b/illumos-x86_64/usr/include/sys/strsun.h new file mode 100644 index 00000000..3c2b7588 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/strsun.h @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_STRSUN_H +#define _SYS_STRSUN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Solaris DDI STREAMS utility routines. + * + * See the appropriate section 9F manpage for documentation. + */ + +#define DB_BASE(mp) ((mp)->b_datap->db_base) +#define DB_LIM(mp) ((mp)->b_datap->db_lim) +#define DB_REF(mp) ((mp)->b_datap->db_ref) +#define DB_TYPE(mp) ((mp)->b_datap->db_type) +#define DB_FLAGS(mp) ((mp)->b_datap->db_flags) + +#define _PTRDIFF(p1, p2) ((intptr_t)((uintptr_t)(p1) - (uintptr_t)(p2))) +#define MBLKL(mp) _PTRDIFF((mp)->b_wptr, (mp)->b_rptr) +#define MBLKSIZE(mp) _PTRDIFF(DB_LIM(mp), DB_BASE(mp)) +#define MBLKHEAD(mp) _PTRDIFF((mp)->b_rptr, DB_BASE(mp)) +#define MBLKTAIL(mp) _PTRDIFF(DB_LIM(mp), (mp)->b_wptr) +#define MBLKIN(mp, off, len) (((off) <= MBLKL(mp)) && \ + (((mp)->b_rptr + (off) + (len)) <= (mp)->b_wptr)) + +#ifdef _KERNEL +extern void mcopyin(mblk_t *, void *, size_t, void *); +extern void mcopyout(mblk_t *, void *, size_t, void *, mblk_t *); +extern void merror(queue_t *, mblk_t *, int); +extern void mioc2ack(mblk_t *, mblk_t *, size_t, int); +extern void miocack(queue_t *, mblk_t *, int, int); +extern void miocnak(queue_t *, mblk_t *, int, int); +extern int miocpullup(mblk_t *, size_t); +extern mblk_t *mexchange(queue_t *, mblk_t *, size_t, uchar_t, int32_t); +extern size_t msgsize(mblk_t *); +extern void mcopymsg(mblk_t *, void *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STRSUN_H */ diff --git a/illumos-x86_64/usr/include/sys/strtty.h b/illumos-x86_64/usr/include/sys/strtty.h new file mode 100644 index 00000000..05c49b1e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/strtty.h @@ -0,0 +1,142 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_STRTTY_H +#define _SYS_STRTTY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * header file for STREAMS TTY subsystem + */ + +/* + * The t_buf data structure holds information about a message + * block and its associated data buffer. One is used for received + * blocks, and another is used for blocks to be transmitted to + * a user terminal or a printer. + */ + +struct t_buf +{ + mblk_t *bu_bp; /* message block pointer */ + unsigned char *bu_ptr; /* data buffer pointer */ + ushort_t bu_cnt; /* data buffer character count */ +}; + +/* + * A tty structure is needed for each character device used for normal + * tty I/O. Each PORTS board supports 4 user terminals and 1 CENTRONICS- + * TYPE printer. + */ + +struct strtty +{ + struct t_buf t_in; /* input buffer info */ + struct t_buf t_out; /* output buffer info */ + queue_t *t_rdqp; /* pointer to tty read queue */ + mblk_t *t_ioctlp; /* ioctl block pointer */ + mblk_t *t_lbuf; /* pointer to a large data buffer */ + int t_dev; /* tty minor device number */ + int t_iflag; /* input setting flags */ + int t_oflag; /* output setting flags */ + int t_cflag; /* physical setting flags */ + int t_lflag; /* "line discipline" flags */ + short t_state; /* internal state */ + char t_line; /* active line discipline */ + char t_dstat; /* more internal state flags */ + unsigned char t_cc[NCCS]; /* settable control chars */ +}; + +/* + * Size of internal ports data buffer, one per port + */ +#define LARGEBUFSZ 512 + +#define TTIPRI 28 +#define TTOPRI 29 + +/* Internal state */ +#define TIMEOUT 01 /* Delay timeout in progress */ +#define WOPEN 02 /* Waiting for open to complete */ +#define ISOPEN 04 /* Device is open */ +#define TBLOCK 010 +#define CARR_ON 020 /* Software copy of carrier-present */ +#define BUSY 040 /* Output in progress */ +#define WIOC 0100 /* Wait for ioctl to complete */ +#define WGETTY 0200 /* opened by supergetty, waiting for getty */ +#define TTSTOP 0400 /* Output stopped by ctl-s */ +#define EXTPROC 01000 /* External processing */ +#define TACT 02000 +#define CLESC 04000 /* Last char escape */ +#define RTO 010000 /* Raw Timeout */ +#define TTIOW 020000 +#define TTXON 040000 +#define TTXOFF 0100000 + +/* l_output status */ +#define CPRES 0100000 + +/* device commands */ +#define T_OUTPUT 0 +#define T_TIME 1 +#define T_SUSPEND 2 +#define T_RESUME 3 +#define T_BLOCK 4 +#define T_UNBLOCK 5 +#define T_RFLUSH 6 +#define T_WFLUSH 7 +#define T_BREAK 8 +#define T_INPUT 9 +#define T_DISCONNECT 10 +#define T_PARM 11 +#define T_SWTCH 12 +/* + * M_CTL message types. + */ +#define MC_NO_CANON 0 /* module below saying it will canonicalize */ +#define MC_DO_CANON 1 /* module below saying it won't canonicalize */ +#define MC_CANONQUERY 2 /* module above asking whether module below */ + /* canonicalizes */ +#define MC_PART_CANON 3 /* tell line discipline to do some */ + /* canonicalization */ +/* XXX - These seem pretty device dependent... */ +#define MC_SERVICEIMM 3 /* tell the ZS driver to return input */ + /* immediately */ +#define MC_SERVICEDEF 4 /* tell the ZS driver it can wait */ +#define MC_POSIXQUERY 5 /* check if driver has POSIX close semantics */ +#define MC_HAS_POSIX 6 /* driver does support POSIX */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STRTTY_H */ diff --git a/illumos-x86_64/usr/include/sys/sunddi.h b/illumos-x86_64/usr/include/sys/sunddi.h new file mode 100644 index 00000000..aa99d03a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sunddi.h @@ -0,0 +1,2319 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore . All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright 2019 Joyent, Inc. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. + */ + +#ifndef _SYS_SUNDDI_H +#define _SYS_SUNDDI_H + +/* + * Sun Specific DDI definitions + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(__i386) || defined(__amd64) +#include +#endif +#include +#include +#include +#include +#include +#if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL) +#include +#endif +#ifdef _KERNEL +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Generic Sun DDI definitions. + */ + +#define DDI_SUCCESS (0) /* successful return */ +#define DDI_FAILURE (-1) /* unsuccessful return */ +#define DDI_NOT_WELL_FORMED (-2) /* A dev_info node is not valid */ +#define DDI_EAGAIN (-3) /* not enough interrupt resources */ +#define DDI_EINVAL (-4) /* invalid request or arguments */ +#define DDI_ENOTSUP (-5) /* operation is not supported */ +#define DDI_EPENDING (-6) /* operation or an event is pending */ +#define DDI_EALREADY (-7) /* operation already in progress */ + +/* + * General-purpose DDI error return value definitions + */ +#define DDI_ENOMEM 1 /* memory not available */ +#define DDI_EBUSY 2 /* busy */ +#define DDI_ETRANSPORT 3 /* transport down */ +#define DDI_ECONTEXT 4 /* context error */ + + +/* + * General DDI sleep/nosleep allocation flags + */ +#define DDI_SLEEP 0 +#define DDI_NOSLEEP 1 + +/* + * The following special nodeid values are reserved for use when creating + * nodes ONLY. They specify the attributes of the DDI_NC_PSEUDO class node + * being created: + * + * o DEVI_PSEUDO_NODEID specifics a node without persistence. + * o DEVI_SID_NODEID specifies a node with persistence. + * o DEVI_SID_HIDDEN_NODEID specifies a hidden node with persistence. + * + * A node with the 'hidden' attribute will not show up in devinfo snapshots + * or in /devices file system. + * + * A node with the 'persistent' attribute will not be automatically removed by + * the framework in the current implementation - driver.conf nodes are without + * persistence. + * + * The actual nodeid value may be assigned by the framework and may be + * different than these special values. Drivers may not make assumptions + * about the nodeid value that is actually assigned to the node. + */ + +#define DEVI_PSEUDO_NODEID ((int)-1) +#define DEVI_SID_NODEID ((int)-2) +#define DEVI_SID_HIDDEN_NODEID ((int)-3) +#define DEVI_SID_HP_NODEID ((int)-4) +#define DEVI_SID_HP_HIDDEN_NODEID ((int)-5) + +#define DEVI_PSEUDO_NEXNAME "pseudo" +#define DEVI_ISA_NEXNAME "isa" +#define DEVI_EISA_NEXNAME "eisa" + +/* + * ddi_create_minor_node flags + */ +#define CLONE_DEV 1 /* device is a clone device */ +#define PRIVONLY_DEV 0x10 /* policy-based permissions only */ + +/* + * Historical values used for the flag field in ddi_create_minor_node. + * Future use of flag bits should avoid these fields to keep binary + * compatibility + * #define GLOBAL_DEV 0x2 + * #define NODEBOUND_DEV 0x4 + * #define NODESPECIFIC_DEV 0x6 + * #define ENUMERATED_DEV 0x8 + */ + +/* + * Device type defines which are used by the 'node_type' element of the + * ddi_minor_data structure + */ +#define DDI_NT_SERIAL "ddi_serial" /* Serial port */ +#define DDI_NT_SERIAL_MB "ddi_serial:mb" /* the 'built-in' serial */ + /* ports (the old ttya, b */ + /* (,c ,d)) */ +#define DDI_NT_SERIAL_DO "ddi_serial:dialout" /* dialout ports */ +#define DDI_NT_SERIAL_MB_DO "ddi_serial:dialout,mb" /* dialout for onboard */ + /* ports */ +#define DDI_NT_SERIAL_LOMCON "ddi_serial:lomcon" /* LOMlite2 console port */ + +/* + * *_CHAN disk type devices have channel numbers or target numbers. + * (i.e. ipi and scsi devices) + */ +#define DDI_NT_BLOCK "ddi_block" /* hard disks */ +/* + * The next define is for block type devices that can possible exist on + * a sub-bus like the scsi bus or the ipi channel. The 'disks' program + * will pick up on this and create logical names like c0t0d0s0 instead of + * c0d0s0 + */ +#define DDI_NT_BLOCK_CHAN "ddi_block:channel" +#define DDI_NT_BLOCK_WWN "ddi_block:wwn" +#define DDI_NT_CD "ddi_block:cdrom" /* rom drives (cd-rom) */ +#define DDI_NT_CD_CHAN "ddi_block:cdrom:channel" /* rom drives (scsi type) */ +#define DDI_NT_FD "ddi_block:diskette" /* floppy disks */ + +#define DDI_NT_ENCLOSURE "ddi_enclosure" +#define DDI_NT_SCSI_ENCLOSURE "ddi_enclosure:scsi" + +#define DDI_NT_BLOCK_SAS "ddi_block:sas" +#define DDI_NT_BLOCK_BLKDEV "ddi_block:blkdev" + +/* + * xVM virtual block devices + */ +#define DDI_NT_BLOCK_XVMD "ddi_block:xvmd" +#define DDI_NT_CD_XVMD "ddi_block:cdrom:xvmd" + + +#define DDI_NT_TAPE "ddi_byte:tape" /* tape drives */ + +#define DDI_NT_NET "ddi_network" /* DLPI network devices */ + +#define DDI_NT_NET_WIFI "ddi_network:wifi" /* wifi devices */ + +#define DDI_NT_DISPLAY "ddi_display" /* display devices */ + +#define DDI_NT_DISPLAY_DRM "ddi_display:drm" /* drm display devices */ + +#define DDI_PSEUDO "ddi_pseudo" /* general pseudo devices */ + +#define DDI_NT_AUDIO "ddi_audio" /* audio device */ + +#define DDI_NT_MOUSE "ddi_mouse" /* mouse device */ + +#define DDI_NT_KEYBOARD "ddi_keyboard" /* keyboard device */ + +#define DDI_NT_PARALLEL "ddi_parallel" /* parallel port */ + +#define DDI_NT_PRINTER "ddi_printer" /* printer device */ + +#define DDI_NT_UGEN "ddi_generic:usb" /* USB generic drv */ + +#define DDI_NT_SMP "ddi_sas_smp" /* smp devcies */ + +#define DDI_NT_NEXUS "ddi_ctl:devctl" /* nexus drivers */ + +#define DDI_NT_NVME_NEXUS "ddi_ctl:devctl:nvme" /* nexus drivers */ + +#define DDI_NT_SCSI_NEXUS "ddi_ctl:devctl:scsi" /* nexus drivers */ + +#define DDI_NT_SATA_NEXUS "ddi_ctl:devctl:sata" /* nexus drivers */ + +#define DDI_NT_IB_NEXUS "ddi_ctl:devctl:ib" /* nexus drivers */ + +#define DDI_NT_ATTACHMENT_POINT "ddi_ctl:attachment_point" /* attachment pt */ + +#define DDI_NT_NVME_ATTACHMENT_POINT "ddi_ctl:attachment_point:nvme" + /* nvme attachment pt */ + +#define DDI_NT_SCSI_ATTACHMENT_POINT "ddi_ctl:attachment_point:scsi" + /* scsi attachment pt */ + +#define DDI_NT_SATA_ATTACHMENT_POINT "ddi_ctl:attachment_point:sata" + /* sata attachment pt */ + +#define DDI_NT_SDCARD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sdcard" + /* sdcard attachment pt */ + +#define DDI_NT_PCI_ATTACHMENT_POINT "ddi_ctl:attachment_point:pci" + /* PCI attachment pt */ +#define DDI_NT_SBD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sbd" + /* generic bd attachment pt */ +#define DDI_NT_FC_ATTACHMENT_POINT "ddi_ctl:attachment_point:fc" + /* FC attachment pt */ +#define DDI_NT_USB_ATTACHMENT_POINT "ddi_ctl:attachment_point:usb" + /* USB devices */ +#define DDI_NT_BLOCK_FABRIC "ddi_block:fabric" + /* Fabric Devices */ +#define DDI_NT_IB_ATTACHMENT_POINT "ddi_ctl:attachment_point:ib" + /* IB devices */ +#define DDI_NT_CCID_ATTACHMENT_POINT "ddi_ctl:attachment_point:ccid" + /* CCID devices */ + +#define DDI_NT_AV_ASYNC "ddi_av:async" /* asynchronous AV device */ +#define DDI_NT_AV_ISOCH "ddi_av:isoch" /* isochronous AV device */ + +/* Device types used for agpgart driver related devices */ +#define DDI_NT_AGP_PSEUDO "ddi_agp:pseudo" /* agpgart pseudo device */ +#define DDI_NT_AGP_MASTER "ddi_agp:master" /* agp master device */ +#define DDI_NT_AGP_TARGET "ddi_agp:target" /* agp target device */ +#define DDI_NT_AGP_CPUGART "ddi_agp:cpugart" /* amd64 on-cpu gart device */ + +#define DDI_NT_REGACC "ddi_tool_reg" /* tool register access */ +#define DDI_NT_INTRCTL "ddi_tool_intr" /* tool intr access */ + +/* + * Various device types used for sensors. + */ +#define DDI_NT_SENSOR_TEMP_CPU "ddi_sensor:temperature:cpu" +#define DDI_NT_SENSOR_TEMP_PCH "ddi_sensor:temperature:pch" + +/* + * DDI event definitions + */ +#define EC_DEVFS "EC_devfs" /* Event class devfs */ +#define EC_DDI "EC_ddi" /* Event class ddi */ + +/* Class devfs subclasses */ +#define ESC_DEVFS_MINOR_CREATE "ESC_devfs_minor_create" +#define ESC_DEVFS_MINOR_REMOVE "ESC_devfs_minor_remove" +#define ESC_DEVFS_DEVI_ADD "ESC_devfs_devi_add" +#define ESC_DEVFS_DEVI_REMOVE "ESC_devfs_devi_remove" +#define ESC_DEVFS_INSTANCE_MOD "ESC_devfs_instance_mod" +#define ESC_DEVFS_BRANCH_ADD "ESC_devfs_branch_add" +#define ESC_DEVFS_BRANCH_REMOVE "ESC_devfs_branch_remove" +#define ESC_DEVFS_START "ESC_devfs_start" + +/* Class ddi subclasses */ +#define ESC_DDI_INITIATOR_REGISTER "ESC_ddi_initiator_register" +#define ESC_DDI_INITIATOR_UNREGISTER "ESC_ddi_initiator_unregister" + +/* DDI/NDI event publisher */ +#define EP_DDI SUNW_KERN_PUB"ddi" + +/* + * devfs event class attributes + * + * The following attributes are private to EC_DEVFS event data. + */ +#define DEVFS_DRIVER_NAME "di.driver" +#define DEVFS_INSTANCE "di.instance" +#define DEVFS_PATHNAME "di.path" +#define DEVFS_DEVI_CLASS "di.devi_class" +#define DEVFS_BRANCH_EVENT "di.branch_event" +#define DEVFS_MINOR_NAME "mi.name" +#define DEVFS_MINOR_NODETYPE "mi.nodetype" +#define DEVFS_MINOR_ISCLONE "mi.isclone" +#define DEVFS_MINOR_MAJNUM "mi.majorno" +#define DEVFS_MINOR_MINORNUM "mi.minorno" + +/* + * ddi event class payload + * + * The following attributes are private to EC_DDI event data. + */ +#define DDI_DRIVER_NAME "ddi.driver" +#define DDI_DRIVER_MAJOR "ddi.major" +#define DDI_INSTANCE "ddi.instance" +#define DDI_PATHNAME "ddi.path" +#define DDI_CLASS "ddi.class" + +/* + * Fault-related definitions + * + * The specific numeric values have been chosen to be ordered, but + * not consecutive, to allow for future interpolation if required. + */ +typedef enum { + DDI_SERVICE_LOST = -32, + DDI_SERVICE_DEGRADED = -16, + DDI_SERVICE_UNAFFECTED = 0, + DDI_SERVICE_RESTORED = 16 +} ddi_fault_impact_t; + +typedef enum { + DDI_DATAPATH_FAULT = -32, + DDI_DEVICE_FAULT = -16, + DDI_EXTERNAL_FAULT = 0 +} ddi_fault_location_t; + +typedef enum { + DDI_DEVSTATE_OFFLINE = -32, + DDI_DEVSTATE_DOWN = -16, + DDI_DEVSTATE_QUIESCED = 0, + DDI_DEVSTATE_DEGRADED = 16, + DDI_DEVSTATE_UP = 32 +} ddi_devstate_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * Common property definitions + */ +#define DDI_FORCEATTACH "ddi-forceattach" +#define DDI_NO_AUTODETACH "ddi-no-autodetach" +#define DDI_VHCI_CLASS "ddi-vhci-class" +#define DDI_NO_ROOT_SUPPORT "ddi-no-root-support" +#define DDI_OPEN_RETURNS_EINTR "ddi-open-returns-eintr" +#define DDI_DEVID_REGISTRANT "ddi-devid-registrant" + +/* + * Values that the function supplied to the dev_info + * tree traversal functions defined below must return. + */ + +/* + * Continue search, if appropriate. + */ +#define DDI_WALK_CONTINUE 0 + +/* + * Terminate current depth of traversal. That is, terminate + * the current traversal of children nodes, but continue + * traversing sibling nodes and their children (if any). + */ + +#define DDI_WALK_PRUNECHILD -1 + +/* + * Terminate current width of traversal. That is, terminate + * the current traversal of sibling nodes, but continue with + * traversing children nodes and their siblings (if appropriate). + */ + +#define DDI_WALK_PRUNESIB -2 + +/* + * Terminate the entire search. + */ + +#define DDI_WALK_TERMINATE -3 + +/* + * Terminate the entire search because an error occurred in function + */ +#define DDI_WALK_ERROR -4 + +/* + * Drivers that are prepared to support full driver layering + * should create and export a null-valued property of the following + * name. + * + * Such drivers should be prepared to be called with FKLYR in + * the 'flag' argument of their open(9E), close(9E) routines, and + * with FKIOCTL in the 'mode' argument of their ioctl(9E) routines. + * + * See ioctl(9E) and ddi_copyin(9F) for details. + */ +#define DDI_KERNEL_IOCTL "ddi-kernel-ioctl" + +/* + * Model definitions for ddi_mmap_get_model(9F) and ddi_model_convert_from(9F). + */ +#define DDI_MODEL_MASK DATAMODEL_MASK /* Note: 0x0FF00000 */ +#define DDI_MODEL_ILP32 DATAMODEL_ILP32 +#define DDI_MODEL_LP64 DATAMODEL_LP64 +#define DDI_MODEL_NATIVE DATAMODEL_NATIVE +#define DDI_MODEL_NONE DATAMODEL_NONE + +/* if set to B_TRUE is DER_MODE is equivalent to DERE_PANIC */ +extern boolean_t ddi_err_panic; + +/* + * Defines for ddi_err(). + */ +typedef enum { + DER_INVALID = 0, /* must be 0 */ + DER_CONT = 1, + DER_CONS, + DER_LOG, + DER_VERB, + DER_NOTE, + DER_WARN, + DER_PANIC, + DER_MODE, + DER_DEBUG +} ddi_err_t; + +extern void ddi_err(ddi_err_t de, dev_info_t *rdip, const char *fmt, ...); + + +extern char *ddi_strdup(const char *str, int flag); +extern char *strdup(const char *str); +extern void strfree(char *str); + +/* + * Functions and data references which really should be in + */ + +extern int maxphys; +extern void minphys(struct buf *); +extern int physio(int (*)(struct buf *), struct buf *, dev_t, + int, void (*)(struct buf *), struct uio *); +extern void disksort(struct diskhd *, struct buf *); + +extern size_t strlen(const char *) __PURE; +extern size_t strnlen(const char *, size_t) __PURE; +extern char *strcpy(char *, const char *); +extern char *strncpy(char *, const char *, size_t); +/* Need to be consistent with C++ definition for strchr() */ +#if __cplusplus >= 199711L +extern const char *strchr(const char *, int); +#ifndef _STRCHR_INLINE +#define _STRCHR_INLINE +extern "C++" { + inline char *strchr(char *__s, int __c) { + return (char *)strchr((const char *)__s, __c); + } +} +#endif /* _STRCHR_INLINE */ +#else +extern char *strchr(const char *, int); +#endif /* __cplusplus >= 199711L */ +#define DDI_STRSAME(s1, s2) ((*(s1) == *(s2)) && (strcmp((s1), (s2)) == 0)) +extern int strcmp(const char *, const char *) __PURE; +extern int strncmp(const char *, const char *, size_t) __PURE; +extern char *strncat(char *, const char *, size_t); +extern size_t strlcat(char *, const char *, size_t); +extern size_t strlcpy(char *, const char *, size_t); +extern size_t strspn(const char *, const char *); +extern size_t strcspn(const char *, const char *); +extern char *strsep(char **, const char *); +extern char *strtok_r(char *, const char *, char **); +extern int bcmp(const void *, const void *, size_t) __PURE; +extern int stoi(char **); +extern void numtos(ulong_t, char *); +extern void bcopy(const void *, void *, size_t); +extern void bzero(void *, size_t); + +extern void *memcpy(void *, const void *, size_t); +extern void *memset(void *, int, size_t); +extern void *memmove(void *, const void *, size_t); +extern int memcmp(const void *, const void *, size_t) __PURE; +/* Need to be consistent with C++ definition for memchr() */ +#if __cplusplus >= 199711L +extern const void *memchr(const void *, int, size_t); +#ifndef _MEMCHR_INLINE +#define _MEMCHR_INLINE +extern "C++" { + inline void *memchr(void * __s, int __c, size_t __n) { + return (void *)memchr((const void *)__s, __c, __n); + } +} +#endif /* _MEMCHR_INLINE */ +#else +extern void *memchr(const void *, int, size_t); +#endif /* __cplusplus >= 199711L */ + +extern int ddi_strtol(const char *, char **, int, long *); +extern int ddi_strtoul(const char *, char **, int, unsigned long *); +extern int ddi_strtoll(const char *, char **, int, longlong_t *); +extern int ddi_strtoull(const char *, char **, int, u_longlong_t *); + +/* + * kiconv functions and their macros. + */ +#define KICONV_IGNORE_NULL (0x0001) +#define KICONV_REPLACE_INVALID (0x0002) + +extern kiconv_t kiconv_open(const char *, const char *); +extern size_t kiconv(kiconv_t, char **, size_t *, char **, size_t *, int *); +extern int kiconv_close(kiconv_t); +extern size_t kiconvstr(const char *, const char *, char *, size_t *, char *, + size_t *, int, int *); + +#endif /* _KERNEL || _FAKE_KERNEL */ +#ifdef _KERNEL + +/* + * ddi_map_regs + * + * Map in the register set given by rnumber. + * The register number determine which register + * set will be mapped if more than one exists. + * The parent driver gets the information + * from parent private data and sets up the + * appropriate mappings and returns the kernel + * virtual address of the register set in *kaddrp. + * The offset specifies an offset into the register + * space to start from and len indicates the size + * of the area to map. If len and offset are 0 then + * the entire space is mapped. It returns DDI_SUCCESS on + * success or DDI_FAILURE otherwise. + * + */ +int +ddi_map_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp, + off_t offset, off_t len); + +/* + * ddi_unmap_regs + * + * Undo mappings set up by ddi_map_regs. + * The register number determines which register + * set will be unmapped if more than one exists. + * This is provided for drivers preparing + * to detach themselves from the system to + * allow them to release allocated mappings. + * + * The kaddrp and len specify the area to be + * unmapped. *kaddrp was returned from ddi_map_regs + * and len should match what ddi_map_regs was called + * with. + */ + +void +ddi_unmap_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp, + off_t offset, off_t len); + +int +ddi_map(dev_info_t *dp, ddi_map_req_t *mp, off_t offset, off_t len, + caddr_t *addrp); + +int +ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp); + +/* + * ddi_rnumber_to_regspec: Not for use by leaf drivers. + */ +struct regspec * +ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber); + +int +ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset, + off_t len, caddr_t *vaddrp); + +int +nullbusmap(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset, + off_t len, caddr_t *vaddrp); + +int ddi_peek8(dev_info_t *dip, int8_t *addr, int8_t *val_p); +int ddi_peek16(dev_info_t *dip, int16_t *addr, int16_t *val_p); +int ddi_peek32(dev_info_t *dip, int32_t *addr, int32_t *val_p); +int ddi_peek64(dev_info_t *dip, int64_t *addr, int64_t *val_p); + +int ddi_poke8(dev_info_t *dip, int8_t *addr, int8_t val); +int ddi_poke16(dev_info_t *dip, int16_t *addr, int16_t val); +int ddi_poke32(dev_info_t *dip, int32_t *addr, int32_t val); +int ddi_poke64(dev_info_t *dip, int64_t *addr, int64_t val); + +/* + * Peek and poke to and from a uio structure in xfersize pieces, + * using the parent nexi. + */ +int ddi_peekpokeio(dev_info_t *devi, struct uio *uio, enum uio_rw rw, + caddr_t addr, size_t len, uint_t xfersize); + +/* + * Pagesize conversions using the parent nexi + */ +unsigned long ddi_btop(dev_info_t *dip, unsigned long bytes); +unsigned long ddi_btopr(dev_info_t *dip, unsigned long bytes); +unsigned long ddi_ptob(dev_info_t *dip, unsigned long pages); + +/* + * There are no more "block" interrupt functions, per se. + * All thread of control should be done with MP/MT lockings. + * + * However, there are certain times in which a driver needs + * absolutely a critical guaranteed non-preemptable time + * in which to execute a few instructions. + * + * The following pair of functions attempt to guarantee this, + * but they are dangerous to use. That is, use them with + * extreme care. They do not guarantee to stop other processors + * from executing, but they do guarantee that the caller + * of ddi_enter_critical will continue to run until the + * caller calls ddi_exit_critical. No intervening DDI functions + * may be called between an entry and an exit from a critical + * region. + * + * ddi_enter_critical returns an integer identifier which must + * be passed to ddi_exit_critical. + * + * Be very sparing in the use of these functions since it is + * likely that absolutely nothing else can occur in the system + * whilst in the critical region. + */ + +unsigned int +ddi_enter_critical(void); + +void +ddi_exit_critical(unsigned int); + +/* + * devmap functions + */ +int +devmap_setup(dev_t dev, offset_t off, ddi_as_handle_t as, caddr_t *addrp, + size_t len, uint_t prot, uint_t maxprot, uint_t flags, struct cred *cred); + +int +ddi_devmap_segmap(dev_t dev, off_t off, ddi_as_handle_t as, caddr_t *addrp, + off_t len, uint_t prot, uint_t maxprot, uint_t flags, struct cred *cred); + +int +devmap_load(devmap_cookie_t dhp, offset_t offset, size_t len, uint_t type, + uint_t rw); + +int +devmap_unload(devmap_cookie_t dhp, offset_t offset, size_t len); + +int +devmap_devmem_setup(devmap_cookie_t dhp, dev_info_t *dip, + struct devmap_callback_ctl *callback_ops, + uint_t rnumber, offset_t roff, size_t len, uint_t maxprot, + uint_t flags, const ddi_device_acc_attr_t *accattrp); + +int +devmap_umem_setup(devmap_cookie_t dhp, dev_info_t *dip, + struct devmap_callback_ctl *callback_ops, + ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot, + uint_t flags, const ddi_device_acc_attr_t *accattrp); + +int +devmap_devmem_remap(devmap_cookie_t dhp, dev_info_t *dip, + uint_t rnumber, offset_t roff, size_t len, uint_t maxprot, + uint_t flags, const ddi_device_acc_attr_t *accattrp); + +int +devmap_umem_remap(devmap_cookie_t dhp, dev_info_t *dip, + ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot, + uint_t flags, const ddi_device_acc_attr_t *accattrp); + +void +devmap_set_ctx_timeout(devmap_cookie_t dhp, clock_t ticks); + +int +devmap_default_access(devmap_cookie_t dhp, void *pvtp, offset_t off, + size_t len, uint_t type, uint_t rw); + +int +devmap_do_ctxmgt(devmap_cookie_t dhp, void *pvtp, offset_t off, size_t len, + uint_t type, uint_t rw, int (*ctxmgt)(devmap_cookie_t, void *, offset_t, + size_t, uint_t, uint_t)); + + +void *ddi_umem_alloc(size_t size, int flag, ddi_umem_cookie_t *cookiep); + +void ddi_umem_free(ddi_umem_cookie_t cookie); + +/* + * Functions to lock user memory and do repeated I/O or do devmap_umem_setup + */ +int +ddi_umem_lock(caddr_t addr, size_t size, int flags, ddi_umem_cookie_t *cookie); + +void +ddi_umem_unlock(ddi_umem_cookie_t cookie); + +struct buf * +ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len, int direction, + dev_t dev, daddr_t blkno, int (*iodone)(struct buf *), int sleepflag); + +/* + * Mapping functions + */ +int +ddi_segmap(dev_t dev, off_t offset, struct as *asp, caddr_t *addrp, off_t len, + uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp); + +int +ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, caddr_t *addrp, + off_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cred, + const ddi_device_acc_attr_t *accattrp, uint_t rnumber); + +int +ddi_map_fault(dev_info_t *dip, struct hat *hat, struct seg *seg, caddr_t addr, + struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock); + +int +ddi_device_mapping_check(dev_t dev, const ddi_device_acc_attr_t *accattrp, + uint_t rnumber, uint_t *hat_flags); + +/* + * Property functions: See also, ddipropdefs.h. + * In general, the underlying driver MUST be held + * to call it's property functions. + */ + +/* + * Used to create, modify, and lookup integer properties + */ +int ddi_prop_get_int(dev_t match_dev, dev_info_t *dip, uint_t flags, + char *name, int defvalue); +int64_t ddi_prop_get_int64(dev_t match_dev, dev_info_t *dip, uint_t flags, + char *name, int64_t defvalue); +int ddi_prop_lookup_int_array(dev_t match_dev, dev_info_t *dip, uint_t flags, + char *name, int **data, uint_t *nelements); +int ddi_prop_lookup_int64_array(dev_t match_dev, dev_info_t *dip, uint_t flags, + char *name, int64_t **data, uint_t *nelements); +int ddi_prop_update_int(dev_t match_dev, dev_info_t *dip, + char *name, int data); +int ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip, + char *name, int64_t data); +int ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, + char *name, int *data, uint_t nelements); +int ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, + char *name, int64_t *data, uint_t nelements); +/* + * Used to create, modify, and lookup string properties + */ +int ddi_prop_lookup_string(dev_t match_dev, dev_info_t *dip, uint_t flags, + char *name, char **data); +int ddi_prop_lookup_string_array(dev_t match_dev, dev_info_t *dip, uint_t flags, + char *name, char ***data, uint_t *nelements); +int ddi_prop_update_string(dev_t match_dev, dev_info_t *dip, + char *name, char *data); +int ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip, + char *name, char **data, uint_t nelements); + +/* + * Used to create, modify, and lookup byte properties + */ +int ddi_prop_lookup_byte_array(dev_t match_dev, dev_info_t *dip, uint_t flags, + char *name, uchar_t **data, uint_t *nelements); +int ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip, + char *name, uchar_t *data, uint_t nelements); + +/* + * Used to verify the existence of a property or to see if a boolean + * property exists. + */ +int ddi_prop_exists(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name); + +/* + * Used to free the data returned by the above property routines. + */ +void ddi_prop_free(void *data); + +/* + * nopropop: For internal use in `dummy' cb_prop_op functions only + */ + +int +nopropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags, + char *name, caddr_t valuep, int *lengthp); + +/* + * ddi_prop_op: The basic property operator for drivers. + * + * In ddi_prop_op, the type of valuep is interpreted based on prop_op: + * + * prop_op valuep + * ------ ------ + * + * PROP_LEN + * + * PROP_LEN_AND_VAL_BUF Pointer to callers buffer + * + * PROP_LEN_AND_VAL_ALLOC Address of callers pointer (will be set to + * address of allocated buffer, if successful) + */ + +int +ddi_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags, + char *name, caddr_t valuep, int *lengthp); + +/* ddi_prop_op_size: for drivers that implement size in bytes */ +int +ddi_prop_op_size(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, + int mod_flags, char *name, caddr_t valuep, int *lengthp, + uint64_t size64); + +/* ddi_prop_op_size_blksize: like ddi_prop_op_size, in blksize blocks */ +int +ddi_prop_op_size_blksize(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, + int mod_flags, char *name, caddr_t valuep, int *lengthp, + uint64_t size64, uint_t blksize); + +/* ddi_prop_op_nblocks: for drivers that implement size in DEV_BSIZE blocks */ +int +ddi_prop_op_nblocks(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, + int mod_flags, char *name, caddr_t valuep, int *lengthp, + uint64_t nblocks64); + +/* ddi_prop_op_nblocks_blksize: like ddi_prop_op_nblocks, in blksize blocks */ +int +ddi_prop_op_nblocks_blksize(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, + int mod_flags, char *name, caddr_t valuep, int *lengthp, + uint64_t nblocks64, uint_t blksize); + +/* + * Variable length props... + */ + +/* + * ddi_getlongprop: Get variable length property len+val into a buffer + * allocated by property provider via kmem_alloc. Requester + * is responsible for freeing returned property via kmem_free. + * + * Arguments: + * + * dev: Input: dev_t of property. + * dip: Input: dev_info_t pointer of child. + * flags: Input: Possible flag modifiers are: + * DDI_PROP_DONTPASS: Don't pass to parent if prop not found. + * DDI_PROP_CANSLEEP: Memory allocation may sleep. + * name: Input: name of property. + * valuep: Output: Addr of callers buffer pointer. + * lengthp:Output: *lengthp will contain prop length on exit. + * + * Possible Returns: + * + * DDI_PROP_SUCCESS: Prop found and returned. + * DDI_PROP_NOT_FOUND: Prop not found + * DDI_PROP_UNDEFINED: Prop explicitly undefined. + * DDI_PROP_NO_MEMORY: Prop found, but unable to alloc mem. + */ + +int +ddi_getlongprop(dev_t dev, dev_info_t *dip, int flags, + char *name, caddr_t valuep, int *lengthp); + +/* + * + * ddi_getlongprop_buf: Get long prop into pre-allocated callers + * buffer. (no memory allocation by provider). + * + * dev: Input: dev_t of property. + * dip: Input: dev_info_t pointer of child. + * flags: Input: DDI_PROP_DONTPASS or NULL + * name: Input: name of property + * valuep: Input: ptr to callers buffer. + * lengthp:I/O: ptr to length of callers buffer on entry, + * actual length of property on exit. + * + * Possible returns: + * + * DDI_PROP_SUCCESS Prop found and returned + * DDI_PROP_NOT_FOUND Prop not found + * DDI_PROP_UNDEFINED Prop explicitly undefined. + * DDI_PROP_BUF_TOO_SMALL Prop found, callers buf too small, + * no value returned, but actual prop + * length returned in *lengthp + * + */ + +int +ddi_getlongprop_buf(dev_t dev, dev_info_t *dip, int flags, + char *name, caddr_t valuep, int *lengthp); + +/* + * Integer/boolean sized props. + * + * Call is value only... returns found boolean or int sized prop value or + * defvalue if prop not found or is wrong length or is explicitly undefined. + * Only flag is DDI_PROP_DONTPASS... + * + * By convention, this interface returns boolean (0) sized properties + * as value (int)1. + */ + +int +ddi_getprop(dev_t dev, dev_info_t *dip, int flags, char *name, int defvalue); + +/* + * Get prop length interface: flags are 0 or DDI_PROP_DONTPASS + * if returns DDI_PROP_SUCCESS, length returned in *lengthp. + */ + +int +ddi_getproplen(dev_t dev, dev_info_t *dip, int flags, char *name, int *lengthp); + + +/* + * Interface to create/modify a managed property on child's behalf... + * Only flag is DDI_PROP_CANSLEEP to allow memory allocation to sleep + * if no memory available for internal prop structure. Long property + * (non integer sized) value references are not copied. + * + * Define property with DDI_DEV_T_NONE dev_t for properties not associated + * with any particular dev_t. Use the same dev_t when modifying or undefining + * a property. + * + * No guarantee on order of property search, so don't mix the same + * property name with wildcard and non-wildcard dev_t's. + */ + +/* + * ddi_prop_create: Define a managed property: + */ + +int +ddi_prop_create(dev_t dev, dev_info_t *dip, int flag, + char *name, caddr_t value, int length); + +/* + * ddi_prop_modify: Modify a managed property value + */ + +int +ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag, + char *name, caddr_t value, int length); + +/* + * ddi_prop_remove: Undefine a managed property: + */ + +int +ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name); + +/* + * ddi_prop_remove_all: Used before unloading a driver to remove + * all properties. (undefines all dev_t's props.) + * Also removes `undefined' prop defs. + */ + +void +ddi_prop_remove_all(dev_info_t *dip); + + +/* + * ddi_prop_undefine: Explicitly undefine a property. Property + * searches which match this property return + * the error code DDI_PROP_UNDEFINED. + * + * Use ddi_prop_remove to negate effect of + * ddi_prop_undefine + */ + +int +ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name); + + +/* + * ddi_prop_cache_invalidate + * Invalidate a property in the current cached + * devinfo snapshot - next cached snapshot will + * return the latest property value available. + */ +void +ddi_prop_cache_invalidate(dev_t dev, dev_info_t *dip, char *name, int flags); + +/* + * The default ddi_bus_prop_op wrapper... + */ + +int +ddi_bus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip, + ddi_prop_op_t prop_op, int mod_flags, + char *name, caddr_t valuep, int *lengthp); + + +/* + * Routines to traverse the tree of dev_info nodes. + * The general idea of these functions is to provide + * various tree traversal utilities. For each node + * that the tree traversal function finds, a caller + * supplied function is called with arguments of + * the current node and a caller supplied argument. + * The caller supplied function should return one + * of the integer values defined below which will + * indicate to the tree traversal function whether + * the traversal should be continued, and if so, how, + * or whether the traversal should terminate. + */ + +/* + * This general-purpose routine traverses the tree of dev_info nodes, + * starting from the given node, and calls the given function for each + * node that it finds with the current node and the pointer arg (which + * can point to a structure of information that the function + * needs) as arguments. + * + * It does the walk a layer at a time, not depth-first. + * + * The given function must return one of the values defined above. + * + */ + +void +ddi_walk_devs(dev_info_t *, int (*)(dev_info_t *, void *), void *); + +/* + * Routines to get at elements of the dev_info structure + */ + +/* + * ddi_node_name gets the device's 'name' from the device node. + * + * ddi_binding_name gets the string the OS used to bind the node to a driver, + * in certain cases, the binding name may be different from the node name, + * if the node name does not name a specific device driver. + * + * ddi_get_name is a synonym for ddi_binding_name(). + */ +char * +ddi_get_name(dev_info_t *dip); + +char * +ddi_binding_name(dev_info_t *dip); + +const char * +ddi_driver_name(dev_info_t *dip); + +major_t +ddi_driver_major(dev_info_t *dip); + +major_t +ddi_compatible_driver_major(dev_info_t *dip, char **formp); + +char * +ddi_node_name(dev_info_t *dip); + +int +ddi_get_nodeid(dev_info_t *dip); + +int +ddi_get_instance(dev_info_t *dip); + +struct dev_ops * +ddi_get_driver(dev_info_t *dip); + +void +ddi_set_driver(dev_info_t *dip, struct dev_ops *devo); + +void +ddi_set_driver_private(dev_info_t *dip, void *data); + +void * +ddi_get_driver_private(dev_info_t *dip); + +/* + * ddi_dev_is_needed tells system that a device is about to use a + * component. Returns when component is ready. + */ +int +ddi_dev_is_needed(dev_info_t *dip, int cmpt, int level); + +/* + * check if DDI_SUSPEND may result in power being removed from a device. + */ +int +ddi_removing_power(dev_info_t *dip); + +/* + * (Obsolete) power entry point + */ +int +ddi_power(dev_info_t *dip, int cmpt, int level); + +/* + * ddi_get_parent requires that the branch of the tree with the + * node be held (ddi_hold_installed_driver) or that the devinfo tree + * lock be held + */ +dev_info_t * +ddi_get_parent(dev_info_t *dip); + +/* + * ddi_get_child and ddi_get_next_sibling require that the devinfo + * tree lock be held + */ +dev_info_t * +ddi_get_child(dev_info_t *dip); + +dev_info_t * +ddi_get_next_sibling(dev_info_t *dip); + +dev_info_t * +ddi_get_next(dev_info_t *dip); + +void +ddi_set_next(dev_info_t *dip, dev_info_t *nextdip); + +/* + * dev_info manipulation functions + */ + +/* + * Add and remove child devices. These are part of the system framework. + * + * ddi_add_child creates a dev_info structure with the passed name, + * nodeid and instance arguments and makes it a child of pdip. Devices + * that are known directly by the hardware have real nodeids; devices + * that are software constructs use the defined DEVI_PSEUDO_NODEID + * for the node id. + * + * ddi_remove_node removes the node from the tree. This fails if this + * child has children. Parent and driver private data should already + * be released (freed) prior to calling this function. If flag is + * non-zero, the child is removed from it's linked list of instances. + */ +dev_info_t * +ddi_add_child(dev_info_t *pdip, char *name, uint_t nodeid, uint_t instance); + +int +ddi_remove_child(dev_info_t *dip, int flag); + +/* + * Given the major number for a driver, make sure that dev_info nodes + * are created form the driver's hwconf file, the driver for the named + * device is loaded and attached, as well as any drivers for parent devices. + * Return a pointer to the driver's dev_ops struct with the dev_ops held. + * Note - Callers must release the dev_ops with ddi_rele_driver. + * + * When a driver is held, the branch of the devinfo tree from any of the + * drivers devinfos to the root node are automatically held. This only + * applies to tree traversals up (and back down) the tree following the + * parent pointers. + * + * Use of this interface is discouraged, it may be removed in a future release. + */ +struct dev_ops * +ddi_hold_installed_driver(major_t major); + +void +ddi_rele_driver(major_t major); + +/* + * Attach and hold the specified instance of a driver. The flags argument + * should be zero. + */ +dev_info_t * +ddi_hold_devi_by_instance(major_t major, int instance, int flags); + +void +ddi_release_devi(dev_info_t *); + +/* + * Associate a streams queue with a devinfo node + */ +void +ddi_assoc_queue_with_devi(queue_t *, dev_info_t *); + +/* + * Given the identifier string passed, make sure that dev_info nodes + * are created form the driver's hwconf file, the driver for the named + * device is loaded and attached, as well as any drivers for parent devices. + * + * Note that the driver is not held and is subject to being removed the instant + * this call completes. You probably really want ddi_hold_installed_driver. + */ +int +ddi_install_driver(char *idstring); + +/* + * Routines that return specific nodes + */ + +dev_info_t * +ddi_root_node(void); + +/* + * Given a name and an instance number, find and return the + * dev_info from the current state of the device tree. + * + * If instance number is -1, return the first named instance. + * + * If attached is 1, exclude all nodes that are < DS_ATTACHED + * + * Requires that the devinfo tree be locked. + * If attached is 1, the driver must be held. + */ +dev_info_t * +ddi_find_devinfo(char *name, int instance, int attached); + +/* + * Synchronization of I/O with respect to various + * caches and system write buffers. + * + * Done at varying points during an I/O transfer (including at the + * removal of an I/O mapping). + * + * Due to the support of systems with write buffers which may + * not be able to be turned off, this function *must* used at + * any point in which data consistency might be required. + * + * Generally this means that if a memory object has multiple mappings + * (both for I/O, as described by the handle, and the IU, via, e.g. + * a call to ddi_dma_kvaddrp), and one mapping may have been + * used to modify the memory object, this function must be called + * to ensure that the modification of the memory object is + * complete, as well as possibly to inform other mappings of + * the object that any cached references to the object are + * now stale (and flush or invalidate these stale cache references + * as necessary). + * + * The function ddi_dma_sync() provides the general interface with + * respect to this capability. Generally, ddi_dma_free() (below) may + * be used in preference to ddi_dma_sync() as ddi_dma_free() calls + * ddi_dma_sync(). + * + * Returns 0 if all caches that exist and are specified by cache_flags + * are successfully operated on, else -1. + * + * The argument offset specifies an offset into the mapping of the mapped + * object in which to perform the synchronization. It will be silently + * truncated to the granularity of underlying cache line sizes as + * appropriate. + * + * The argument len specifies a length starting from offset in which to + * perform the synchronization. A value of (uint_t) -1 means that the length + * proceeds from offset to the end of the mapping. The length argument + * will silently rounded up to the granularity of underlying cache line + * sizes as appropriate. + * + * The argument flags specifies what to synchronize (the device's view of + * the object or the cpu's view of the object). + * + * Inquiring minds want to know when ddi_dma_sync should be used: + * + * + When an object is mapped for dma, assume that an + * implicit ddi_dma_sync() is done for you. + * + * + When an object is unmapped (ddi_dma_free()), assume + * that an implicit ddi_dma_sync() is done for you. + * + * + At any time between the two times above that the + * memory object may have been modified by either + * the DMA device or a processor and you wish that + * the change be noticed by the master that didn't + * do the modifying. + * + * Clearly, only the third case above requires the use of ddi_dma_sync. + * + * Inquiring minds also want to know which flag to use: + * + * + If you *modify* with a cpu the object, you use + * ddi_dma_sync(...DDI_DMA_SYNC_FORDEV) (you are making sure + * that the DMA device sees the changes you made). + * + * + If you are checking, with the processor, an area + * of the object that the DMA device *may* have modified, + * you use ddi_dma_sync(....DDI_DMA_SYNC_FORCPU) (you are + * making sure that the processor(s) will see the changes + * that the DMA device may have made). + */ + +int +ddi_dma_sync(ddi_dma_handle_t handle, off_t offset, size_t len, uint_t flags); + +/* + * Return the allowable DMA burst size for the object mapped by handle. + * The burst sizes will returned in an integer that encodes power + * of two burst sizes that are allowed in bit encoded format. For + * example, a transfer that could allow 1, 2, 4, 8 and 32 byte bursts + * would be encoded as 0x2f. A transfer that could be allowed as solely + * a halfword (2 byte) transfers would be returned as 0x2. + */ + +int +ddi_dma_burstsizes(ddi_dma_handle_t handle); + +/* + * Merge DMA attributes + */ + +void +ddi_dma_attr_merge(ddi_dma_attr_t *attr, const ddi_dma_attr_t *mod); + +/* + * Allocate a DMA handle + */ + +int +ddi_dma_alloc_handle(dev_info_t *dip, const ddi_dma_attr_t *attr, + int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep); + +/* + * Free DMA handle + */ + +void +ddi_dma_free_handle(ddi_dma_handle_t *handlep); + +/* + * Allocate memory for DMA transfers + */ + +int +ddi_dma_mem_alloc(ddi_dma_handle_t handle, size_t length, + const ddi_device_acc_attr_t *accattrp, uint_t xfermodes, + int (*waitfp)(caddr_t), caddr_t arg, caddr_t *kaddrp, + size_t *real_length, ddi_acc_handle_t *handlep); + +/* + * Free DMA memory + */ + +void +ddi_dma_mem_free(ddi_acc_handle_t *hp); + +/* + * bind address to a DMA handle + */ + +int +ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as, + caddr_t addr, size_t len, uint_t flags, + int (*waitfp)(caddr_t), caddr_t arg, + ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +/* + * bind buffer to DMA handle + */ + +int +ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp, + uint_t flags, int (*waitfp)(caddr_t), caddr_t arg, + ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +/* + * unbind mapping object to handle + */ + +int +ddi_dma_unbind_handle(ddi_dma_handle_t handle); + +/* + * get next DMA cookie + * + * This function has been deprecated because it is unsafe. Please use + * ddi_dma_cookie_iter(), ddi_dma_cookie_get(), or ddi_dma_cookie_one() instead. + * For more information on the problems, please see the manual page. + */ + +void +ddi_dma_nextcookie(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep); + +/* + * get number of DMA windows + */ + +int +ddi_dma_numwin(ddi_dma_handle_t handle, uint_t *nwinp); + +/* + * get specific DMA window + */ + +int +ddi_dma_getwin(ddi_dma_handle_t handle, uint_t win, off_t *offp, + size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +/* + * activate 64 bit SBus support + */ + +int +ddi_dma_set_sbus64(ddi_dma_handle_t handle, ulong_t burstsizes); + +/* + * Miscellaneous functions + */ + +/* + * ddi_report_dev: Report a successful attach. + */ + +void +ddi_report_dev(dev_info_t *dev); + +/* + * ddi_dev_regsize + * + * If the device has h/w register(s), report + * the size, in bytes, of the specified one into *resultp. + * + * Returns DDI_FAILURE if there are not registers, + * or the specified register doesn't exist. + */ + +int +ddi_dev_regsize(dev_info_t *dev, uint_t rnumber, off_t *resultp); + +/* + * ddi_dev_nregs + * + * If the device has h/w register(s), report + * how many of them that there are into resultp. + * Return DDI_FAILURE if the device has no registers. + */ + +int +ddi_dev_nregs(dev_info_t *dev, int *resultp); + +/* + * ddi_dev_is_sid + * + * If the device is self-identifying, i.e., + * has already been probed by a smart PROM + * (and thus registers are known to be valid) + * return DDI_SUCCESS, else DDI_FAILURE. + */ + + +int +ddi_dev_is_sid(dev_info_t *dev); + +/* + * ddi_slaveonly + * + * If the device is on a bus that precludes + * the device from being either a dma master or + * a dma slave, return DDI_SUCCESS. + */ + +int +ddi_slaveonly(dev_info_t *); + + +/* + * ddi_dev_affinity + * + * Report, via DDI_SUCCESS, whether there exists + * an 'affinity' between two dev_info_t's. An + * affinity is defined to be either a parent-child, + * or a sibling relationship such that the siblings + * or in the same part of the bus they happen to be + * on. + */ + +int +ddi_dev_affinity(dev_info_t *deva, dev_info_t *devb); + + +/* + * ddi_set_callback + * + * Set a function/arg pair into the callback list identified + * by listid. *listid must always initially start out as zero. + */ + +void +ddi_set_callback(int (*funcp)(caddr_t), caddr_t arg, uintptr_t *listid); + +/* + * ddi_run_callback + * + * Run the callback list identified by listid. + */ + +void +ddi_run_callback(uintptr_t *listid); + +/* + * More miscellaneous + */ + +int +nochpoll(dev_t dev, short events, int anyyet, short *reventsp, + struct pollhead **phpp); + +dev_info_t * +nodevinfo(dev_t dev, int otyp); + +int +ddi_no_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result); + +int +ddi_getinfo_1to1(dev_info_t *dip, ddi_info_cmd_t infocmd, + void *arg, void **result); + +int +ddifail(dev_info_t *devi, ddi_attach_cmd_t cmd); + +int +ddi_no_dma_map(dev_info_t *dip, dev_info_t *rdip, + struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep); + +int +ddi_no_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr, + int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep); + +int +ddi_no_dma_freehdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + +int +ddi_no_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, struct ddi_dma_req *dmareq, + ddi_dma_cookie_t *cp, uint_t *ccountp); + +int +ddi_no_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + +int +ddi_no_dma_flush(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, off_t off, size_t len, + uint_t cache_flags); + +int +ddi_no_dma_win(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, uint_t win, off_t *offp, + size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +int +ddi_no_dma_mctl(register dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, enum ddi_dma_ctlops request, + off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags); + +void +ddivoid(); + +cred_t * +ddi_get_cred(void); + +time_t +ddi_get_time(void); + +pid_t +ddi_get_pid(void); + +kt_did_t +ddi_get_kt_did(void); + +boolean_t +ddi_can_receive_sig(void); + +void +swab(void *src, void *dst, size_t nbytes); + +int +ddi_create_minor_node(dev_info_t *dip, const char *name, int spec_type, + minor_t minor_num, const char *node_type, int flag); + +int +ddi_create_priv_minor_node(dev_info_t *dip, const char *name, int spec_type, + minor_t minor_num, const char *node_type, int flag, + const char *rdpriv, const char *wrpriv, mode_t priv_mode); + +void +ddi_remove_minor_node(dev_info_t *dip, const char *name); + +int +ddi_in_panic(void); + +int +ddi_streams_driver(dev_info_t *dip); + +/* + * DDI wrappers for ffs and fls + */ +int +ddi_ffs(long mask); + +int +ddi_fls(long mask); + +/* + * The ddi_soft_state* routines comprise generic storage management utilities + * for driver soft state structures. Two types of soft_state indexes are + * supported: 'integer index', and 'string index'. + */ +typedef struct __ddi_soft_state_bystr ddi_soft_state_bystr; + +/* + * Initialize a soft_state set, establishing the 'size' of soft state objects + * in the set. + * + * For an 'integer indexed' soft_state set, the initial set will accommodate + * 'n_items' objects - 'n_items' is a hint (i.e. zero is allowed), allocations + * that exceed 'n_items' have additional overhead. + * + * For a 'string indexed' soft_state set, 'n_items' should be the typical + * number of soft state objects in the set - 'n_items' is a hint, there may + * be additional overhead if the hint is too small (and wasted memory if the + * hint is too big). + */ +int +ddi_soft_state_init(void **state_p, size_t size, size_t n_items); +int +ddi_soft_state_bystr_init(ddi_soft_state_bystr **state_p, + size_t size, int n_items); + +/* + * Allocate a soft state object associated with either 'integer index' or + * 'string index' from a soft_state set. + */ +int +ddi_soft_state_zalloc(void *state, int item); +int +ddi_soft_state_bystr_zalloc(ddi_soft_state_bystr *state, const char *str); + +/* + * Get the pointer to the allocated soft state object associated with + * either 'integer index' or 'string index'. + */ +void * +ddi_get_soft_state(void *state, int item); +void * +ddi_soft_state_bystr_get(ddi_soft_state_bystr *state, const char *str); + +/* + * Free the soft state object associated with either 'integer index' + * or 'string index'. + */ +void +ddi_soft_state_free(void *state, int item); +void +ddi_soft_state_bystr_free(ddi_soft_state_bystr *state, const char *str); + +/* + * Free the soft state set and any associated soft state objects. + */ +void +ddi_soft_state_fini(void **state_p); +void +ddi_soft_state_bystr_fini(ddi_soft_state_bystr **state_p); + +/* + * The ddi_strid_* routines provide string-to-index management utilities. + */ +typedef struct __ddi_strid ddi_strid; +int +ddi_strid_init(ddi_strid **strid_p, int n_items); +id_t +ddi_strid_alloc(ddi_strid *strid, char *str); +id_t +ddi_strid_str2id(ddi_strid *strid, char *str); +char * +ddi_strid_id2str(ddi_strid *strid, id_t id); +void +ddi_strid_free(ddi_strid *strid, id_t id); +void +ddi_strid_fini(ddi_strid **strid_p); + +/* + * Set the addr field of the name in dip to name + */ +void +ddi_set_name_addr(dev_info_t *dip, char *name); + +/* + * Get the address part of the name. + */ +char * +ddi_get_name_addr(dev_info_t *dip); + +void +ddi_set_parent_data(dev_info_t *dip, void *pd); + +void * +ddi_get_parent_data(dev_info_t *dip); + +int +ddi_initchild(dev_info_t *parent, dev_info_t *proto); + +int +ddi_uninitchild(dev_info_t *dip); + +major_t +ddi_name_to_major(const char *name); + +char * +ddi_major_to_name(major_t major); + +char * +ddi_deviname(dev_info_t *dip, char *name); + +char * +ddi_pathname(dev_info_t *dip, char *path); + +char * +ddi_pathname_minor(struct ddi_minor_data *dmdp, char *path); + +char * +ddi_pathname_obp(dev_info_t *dip, char *path); + +int +ddi_pathname_obp_set(dev_info_t *dip, char *component); + +int +ddi_dev_pathname(dev_t devt, int spec_type, char *name); + +dev_t +ddi_pathname_to_dev_t(char *pathname); + +/* + * High resolution system timer functions. + * + * These functions are already in the kernel (see sys/time.h). + * The ddi supports the notion of a hrtime_t type and the + * functions gethrtime, hrtadd, hrtsub and hrtcmp. + */ + + +/* + * Nexus wrapper functions + * + * These functions are for entries in a bus nexus driver's bus_ops + * structure for when the driver doesn't have such a function and + * doesn't wish to prohibit such a function from existing. They + * may also be called to start passing a request up the dev_info + * tree. + */ + +/* + * bus_ctl wrapper + */ + +int +ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v); + +/* + * bus_dma_map wrapper + */ + +int +ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr, + int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep); + +int +ddi_dma_freehdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + +int +ddi_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, struct ddi_dma_req *dmareq, + ddi_dma_cookie_t *cp, uint_t *ccountp); + +int +ddi_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle); + +int +ddi_dma_flush(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, off_t off, size_t len, + uint_t cache_flags); + +int +ddi_dma_win(dev_info_t *dip, dev_info_t *rdip, + ddi_dma_handle_t handle, uint_t win, off_t *offp, + size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp); + +/* + * bus_dma_ctl wrapper + */ + +int +ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle, + enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, + caddr_t *objp, uint_t flags); + +/* + * dvma support for networking drivers + */ + +unsigned long +dvma_pagesize(dev_info_t *dip); + +int +dvma_reserve(dev_info_t *dip, ddi_dma_lim_t *limp, uint_t pages, + ddi_dma_handle_t *handlep); + +void +dvma_release(ddi_dma_handle_t h); + +void +dvma_kaddr_load(ddi_dma_handle_t h, caddr_t a, uint_t len, uint_t index, + ddi_dma_cookie_t *cp); + +void +dvma_unload(ddi_dma_handle_t h, uint_t objindex, uint_t type); + +void +dvma_sync(ddi_dma_handle_t h, uint_t objindex, uint_t type); + +/* + * Layered driver support + */ + +extern int ddi_copyin(const void *, void *, size_t, int); +extern int ddi_copyout(const void *, void *, size_t, int); + +/* + * Send signals to processes + */ +extern void *proc_ref(void); +extern void proc_unref(void *pref); +extern int proc_signal(void *pref, int sig); + +/* I/O port access routines */ +extern uint8_t inb(int port); +extern uint16_t inw(int port); +extern uint32_t inl(int port); +extern void outb(int port, uint8_t value); +extern void outw(int port, uint16_t value); +extern void outl(int port, uint32_t value); + +/* + * Console bell routines + */ +extern void ddi_ring_console_bell(clock_t duration); +extern void ddi_set_console_bell(void (*bellfunc)(clock_t duration)); + +/* + * Fault-related functions + */ +extern int ddi_check_acc_handle(ddi_acc_handle_t); +extern int ddi_check_dma_handle(ddi_dma_handle_t); +extern void ddi_dev_report_fault(dev_info_t *, ddi_fault_impact_t, + ddi_fault_location_t, const char *); +extern ddi_devstate_t ddi_get_devstate(dev_info_t *); + +/* + * Replacement DMA cookie functions for ddi_dma_nextcookie(). + */ +extern int ddi_dma_ncookies(ddi_dma_handle_t); +extern const ddi_dma_cookie_t *ddi_dma_cookie_iter(ddi_dma_handle_t, + const ddi_dma_cookie_t *); +extern const ddi_dma_cookie_t *ddi_dma_cookie_get(ddi_dma_handle_t, uint_t); +extern const ddi_dma_cookie_t *ddi_dma_cookie_one(ddi_dma_handle_t); + + +/* + * Miscellaneous redefines + */ +#define uiophysio physio + +/* + * utilities - "reg" mapping and all common portable data access functions + */ + +/* + * error code from ddi_regs_map_setup + */ + +#define DDI_REGS_ACC_CONFLICT (-10) + +/* + * Device address advance flags + */ + +#define DDI_DEV_NO_AUTOINCR 0x0000 +#define DDI_DEV_AUTOINCR 0x0001 + +int +ddi_regs_map_setup(dev_info_t *dip, uint_t rnumber, caddr_t *addrp, + offset_t offset, offset_t len, const ddi_device_acc_attr_t *accattrp, + ddi_acc_handle_t *handle); + +void +ddi_regs_map_free(ddi_acc_handle_t *handle); + +/* + * these are the prototypes for the common portable data access functions + */ + +uint8_t +ddi_get8(ddi_acc_handle_t handle, uint8_t *addr); + +uint16_t +ddi_get16(ddi_acc_handle_t handle, uint16_t *addr); + +uint32_t +ddi_get32(ddi_acc_handle_t handle, uint32_t *addr); + +uint64_t +ddi_get64(ddi_acc_handle_t handle, uint64_t *addr); + +void +ddi_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr, + size_t repcount, uint_t flags); + +void +ddi_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr, + size_t repcount, uint_t flags); + +void +ddi_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr, + size_t repcount, uint_t flags); + +void +ddi_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr, + size_t repcount, uint_t flags); + +void +ddi_put8(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value); + +void +ddi_put16(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value); + +void +ddi_put32(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value); + +void +ddi_put64(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value); + +void +ddi_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr, + size_t repcount, uint_t flags); +void +ddi_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr, + size_t repcount, uint_t flags); +void +ddi_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr, + size_t repcount, uint_t flags); + +void +ddi_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr, + size_t repcount, uint_t flags); + +/* + * these are special device handling functions + */ +int +ddi_device_zero(ddi_acc_handle_t handle, caddr_t dev_addr, + size_t bytecount, ssize_t dev_advcnt, uint_t dev_datasz); + +int +ddi_device_copy( + ddi_acc_handle_t src_handle, caddr_t src_addr, ssize_t src_advcnt, + ddi_acc_handle_t dest_handle, caddr_t dest_addr, ssize_t dest_advcnt, + size_t bytecount, uint_t dev_datasz); + +/* + * these are software byte swapping functions + */ +uint16_t +ddi_swap16(uint16_t value); + +uint32_t +ddi_swap32(uint32_t value); + +uint64_t +ddi_swap64(uint64_t value); + +/* + * these are the prototypes for PCI local bus functions + */ +/* + * PCI power management capabilities reporting in addition to those + * provided by the PCI Power Management Specification. + */ +#define PCI_PM_IDLESPEED 0x1 /* clock for idle dev - cap */ +#define PCI_PM_IDLESPEED_ANY (void *)-1 /* any clock for idle dev */ +#define PCI_PM_IDLESPEED_NONE (void *)-2 /* regular clock for idle dev */ + +int +pci_config_setup(dev_info_t *dip, ddi_acc_handle_t *handle); + +void +pci_config_teardown(ddi_acc_handle_t *handle); + +uint8_t +pci_config_get8(ddi_acc_handle_t handle, off_t offset); + +uint16_t +pci_config_get16(ddi_acc_handle_t handle, off_t offset); + +uint32_t +pci_config_get32(ddi_acc_handle_t handle, off_t offset); + +uint64_t +pci_config_get64(ddi_acc_handle_t handle, off_t offset); + +void +pci_config_put8(ddi_acc_handle_t handle, off_t offset, uint8_t value); + +void +pci_config_put16(ddi_acc_handle_t handle, off_t offset, uint16_t value); + +void +pci_config_put32(ddi_acc_handle_t handle, off_t offset, uint32_t value); + +void +pci_config_put64(ddi_acc_handle_t handle, off_t offset, uint64_t value); + +int +pci_report_pmcap(dev_info_t *dip, int cap, void *arg); + +int +pci_restore_config_regs(dev_info_t *dip); + +int +pci_save_config_regs(dev_info_t *dip); + +void +pci_ereport_setup(dev_info_t *dip); + +void +pci_ereport_teardown(dev_info_t *dip); + +void +pci_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status); + +#if defined(__i386) || defined(__amd64) +int +pci_peekpoke_check(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *, + int (*handler)(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *), + kmutex_t *, kmutex_t *, void (*scan)(dev_info_t *, ddi_fm_error_t *)); +#endif + +void +pci_target_enqueue(uint64_t, char *, char *, uint64_t); + +void +pci_targetq_init(void); + +int +pci_post_suspend(dev_info_t *dip); + +int +pci_pre_resume(dev_info_t *dip); + +/* + * the prototype for the C Language Type Model inquiry. + */ +model_t ddi_mmap_get_model(void); +model_t ddi_model_convert_from(model_t); + +/* + * these are the prototypes for device id functions. + */ +int +ddi_devid_valid(ddi_devid_t devid); + +int +ddi_devid_register(dev_info_t *dip, ddi_devid_t devid); + +void +ddi_devid_unregister(dev_info_t *dip); + +int +ddi_devid_init(dev_info_t *dip, ushort_t devid_type, ushort_t nbytes, + void *id, ddi_devid_t *ret_devid); + +int +ddi_devid_get(dev_info_t *dip, ddi_devid_t *ret_devid); + +size_t +ddi_devid_sizeof(ddi_devid_t devid); + +void +ddi_devid_free(ddi_devid_t devid); + +int +ddi_devid_compare(ddi_devid_t id1, ddi_devid_t id2); + +int +ddi_devid_scsi_encode(int version, char *driver_name, + uchar_t *inq, size_t inq_len, uchar_t *inq80, size_t inq80_len, + uchar_t *inq83, size_t inq83_len, ddi_devid_t *ret_devid); + +int +ddi_devid_smp_encode(int version, char *driver_name, + char *wwnstr, uchar_t *srmir_buf, size_t srmir_len, + ddi_devid_t *ret_devid); + +char +*ddi_devid_to_guid(ddi_devid_t devid); + +void +ddi_devid_free_guid(char *guid); + +int +ddi_lyr_get_devid(dev_t dev, ddi_devid_t *ret_devid); + +int +ddi_lyr_get_minor_name(dev_t dev, int spec_type, char **minor_name); + +int +ddi_lyr_devid_to_devlist(ddi_devid_t devid, const char *minor_name, + int *retndevs, dev_t **retdevs); + +void +ddi_lyr_free_devlist(dev_t *devlist, int ndevs); + +char * +ddi_devid_str_encode(ddi_devid_t devid, char *minor_name); + +int +ddi_devid_str_decode(char *devidstr, ddi_devid_t *devidp, char **minor_namep); + +void +ddi_devid_str_free(char *devidstr); + +int +ddi_devid_str_compare(char *id1_str, char *id2_str); + +/* + * Event to post to when a devinfo node is removed. + */ +#define DDI_DEVI_REMOVE_EVENT "DDI:DEVI_REMOVE" +#define DDI_DEVI_INSERT_EVENT "DDI:DEVI_INSERT" +#define DDI_DEVI_BUS_RESET_EVENT "DDI:DEVI_BUS_RESET" +#define DDI_DEVI_DEVICE_RESET_EVENT "DDI:DEVI_DEVICE_RESET" + +/* + * Invoke bus nexus driver's implementation of the + * (*bus_remove_eventcall)() interface to remove a registered + * callback handler for "event". + */ +int +ddi_remove_event_handler(ddi_callback_id_t id); + +/* + * Invoke bus nexus driver's implementation of the + * (*bus_add_eventcall)() interface to register a callback handler + * for "event". + */ +int +ddi_add_event_handler(dev_info_t *dip, ddi_eventcookie_t event, + void (*handler)(dev_info_t *, ddi_eventcookie_t, void *, void *), + void *arg, ddi_callback_id_t *id); + +/* + * Return a handle for event "name" by calling up the device tree + * hierarchy via (*bus_get_eventcookie)() interface until claimed + * by a bus nexus or top of dev_info tree is reached. + */ +int +ddi_get_eventcookie(dev_info_t *dip, char *name, + ddi_eventcookie_t *event_cookiep); + +/* + * log a system event + */ +int +ddi_log_sysevent(dev_info_t *dip, char *vendor, char *class_name, + char *subclass_name, nvlist_t *attr_list, sysevent_id_t *eidp, + int sleep_flag); + +/* + * ddi_log_sysevent() vendors + */ +#define DDI_VENDOR_SUNW "SUNW" + +/* + * Opaque task queue handle. + */ +typedef struct ddi_taskq ddi_taskq_t; + +/* + * Use default system priority. + */ +#define TASKQ_DEFAULTPRI -1 + +/* + * Create a task queue + */ +ddi_taskq_t *ddi_taskq_create(dev_info_t *dip, const char *name, + int nthreads, pri_t pri, uint_t cflags); + +/* + * destroy a task queue + */ +void ddi_taskq_destroy(ddi_taskq_t *tq); + +/* + * Dispatch a task to a task queue + */ +int ddi_taskq_dispatch(ddi_taskq_t *tq, void (* func)(void *), + void *arg, uint_t dflags); + +/* + * Wait for all previously scheduled tasks to complete. + */ +void ddi_taskq_wait(ddi_taskq_t *tq); + +/* + * Suspend all task execution. + */ +void ddi_taskq_suspend(ddi_taskq_t *tq); + +/* + * Resume task execution. + */ +void ddi_taskq_resume(ddi_taskq_t *tq); + +/* + * Is task queue suspended? + */ +boolean_t ddi_taskq_suspended(ddi_taskq_t *tq); + +/* + * Parse an interface name of the form ## where + * is maximal. + */ +int ddi_parse(const char *, char *, uint_t *); +/* Version with caller-specified destination buffer length. */ +int ddi_parse_dlen(const char *, char *, size_t, uint_t *); + +/* + * DDI interrupt priority level + */ +#define DDI_IPL_0 (0) /* kernel context */ +#define DDI_IPL_1 (1) /* interrupt priority level 1 */ +#define DDI_IPL_2 (2) /* interrupt priority level 2 */ +#define DDI_IPL_3 (3) /* interrupt priority level 3 */ +#define DDI_IPL_4 (4) /* interrupt priority level 4 */ +#define DDI_IPL_5 (5) /* interrupt priority level 5 */ +#define DDI_IPL_6 (6) /* interrupt priority level 6 */ +#define DDI_IPL_7 (7) /* interrupt priority level 7 */ +#define DDI_IPL_8 (8) /* interrupt priority level 8 */ +#define DDI_IPL_9 (9) /* interrupt priority level 9 */ +#define DDI_IPL_10 (10) /* interrupt priority level 10 */ + +/* + * DDI periodic timeout interface + */ +ddi_periodic_t ddi_periodic_add(void (*)(void *), void *, hrtime_t, int); +void ddi_periodic_delete(ddi_periodic_t); + +/* + * Default quiesce(9E) implementation for drivers that don't need to do + * anything. + */ +int ddi_quiesce_not_needed(dev_info_t *); + +/* + * Default quiesce(9E) initialization function for drivers that should + * implement quiesce but haven't yet. + */ +int ddi_quiesce_not_supported(dev_info_t *); + +/* + * DDI generic callback interface + */ + +typedef struct __ddi_cb **ddi_cb_handle_t; + +int ddi_cb_register(dev_info_t *dip, ddi_cb_flags_t flags, + ddi_cb_func_t cbfunc, void *arg1, void *arg2, + ddi_cb_handle_t *ret_hdlp); +int ddi_cb_unregister(ddi_cb_handle_t hdl); + +/* Notify DDI of memory added */ +void ddi_mem_update(uint64_t addr, uint64_t size); + +/* Path alias interfaces */ +typedef struct plat_alias { + char *pali_current; + uint64_t pali_naliases; + char **pali_aliases; +} plat_alias_t; + +typedef struct alias_pair { + char *pair_alias; + char *pair_curr; +} alias_pair_t; + +extern boolean_t ddi_aliases_present; + +typedef struct ddi_alias { + alias_pair_t *dali_alias_pairs; + alias_pair_t *dali_curr_pairs; + int dali_num_pairs; + mod_hash_t *dali_alias_TLB; + mod_hash_t *dali_curr_TLB; +} ddi_alias_t; + +extern ddi_alias_t ddi_aliases; + +void ddi_register_aliases(plat_alias_t *pali, uint64_t npali); +dev_info_t *ddi_alias_redirect(char *alias); +char *ddi_curr_redirect(char *curr); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SUNDDI_H */ diff --git a/illumos-x86_64/usr/include/sys/sunldi.h b/illumos-x86_64/usr/include/sys/sunldi.h new file mode 100644 index 00000000..1a5992d1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sunldi.h @@ -0,0 +1,168 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_SUNLDI_H +#define _SYS_SUNLDI_H + +#include +#include +#include + +/* + * DDI interfaces for Layered driver support. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + + +/* + * Opaque layered driver data structures. + * + * The contents of these data structures are private to this + * implementation of Solaris and are subject to change at any + * time without notice. + * + * Applications and drivers accessing the contents of these structures + * directly will fail to run on future releases. + */ +typedef struct __ldi_ident *ldi_ident_t; + +typedef struct __ldi_handle *ldi_handle_t; + +typedef struct __ldi_callback_id *ldi_callback_id_t; + +typedef struct __ldi_ev_cookie *ldi_ev_cookie_t; + +/* + * LDI event interface related + */ +#define LDI_EV_SUCCESS 0 +#define LDI_EV_FAILURE (-1) +#define LDI_EV_NONE (-2) /* no matching callbacks registered */ +#define LDI_EV_OFFLINE "LDI:EVENT:OFFLINE" +#define LDI_EV_DEGRADE "LDI:EVENT:DEGRADE" +#define LDI_EV_DEVICE_REMOVE "LDI:EVENT:DEVICE_REMOVE" + +#define LDI_EV_CB_VERS_1 1 +#define LDI_EV_CB_VERS LDI_EV_CB_VERS_1 + +typedef struct ldi_ev_callback { + uint_t cb_vers; + int (*cb_notify)(ldi_handle_t, ldi_ev_cookie_t, void *, void *); + void (*cb_finalize)(ldi_handle_t, ldi_ev_cookie_t, int, void *, void *); +} ldi_ev_callback_t; + +/* + * LDI Ident manipulation functions + */ +extern ldi_ident_t ldi_ident_from_anon(void); + +extern int ldi_ident_from_mod(struct modlinkage *, ldi_ident_t *); +extern int ldi_ident_from_major(major_t major, ldi_ident_t *); +extern int ldi_ident_from_dip(dev_info_t *dip, ldi_ident_t *); +extern int ldi_ident_from_dev(dev_t, ldi_ident_t *); +extern int ldi_ident_from_stream(struct queue *, ldi_ident_t *); +extern void ldi_ident_release(ldi_ident_t); + + +/* + * LDI Handle manipulation functions + */ +extern int ldi_open_by_dev(dev_t *, int, int, cred_t *, + ldi_handle_t *, ldi_ident_t); +extern int ldi_open_by_name(const char *, int, cred_t *, + ldi_handle_t *, ldi_ident_t); +extern int ldi_open_by_devid(ddi_devid_t, const char *, int, cred_t *, + ldi_handle_t *, ldi_ident_t); +extern int ldi_vp_from_name(const char *, vnode_t **); +extern int ldi_vp_from_devid(ddi_devid_t, const char *, vnode_t **); + +extern int ldi_close(ldi_handle_t, int flag, cred_t *); + +extern int ldi_read(ldi_handle_t, struct uio *, cred_t *); +extern int ldi_write(ldi_handle_t, struct uio *, cred_t *); +extern int ldi_ioctl(ldi_handle_t, int, intptr_t, int, cred_t *, int *); +extern int ldi_poll(ldi_handle_t, short, int, short *, struct pollhead **); +extern int ldi_get_size(ldi_handle_t, uint64_t *); +extern int ldi_prop_op(ldi_handle_t, ddi_prop_op_t, int, + char *, caddr_t, int *); + +extern int ldi_strategy(ldi_handle_t, struct buf *); +extern int ldi_dump(ldi_handle_t, caddr_t, daddr_t, int); +extern int ldi_devmap(ldi_handle_t, devmap_cookie_t, offset_t, + size_t, size_t *, uint_t); +extern int ldi_aread(ldi_handle_t, struct aio_req *, cred_t *); +extern int ldi_awrite(ldi_handle_t, struct aio_req *, cred_t *); + +extern int ldi_putmsg(ldi_handle_t, mblk_t *); +extern int ldi_getmsg(ldi_handle_t, mblk_t **, timestruc_t *); + +extern int ldi_prop_lookup_int_array(ldi_handle_t lh, + uint_t flags, char *name, int **data, uint_t *nelements); +extern int ldi_prop_lookup_int64_array(ldi_handle_t lh, + uint_t flags, char *name, int64_t **data, uint_t *nelements); +extern int ldi_prop_lookup_string_array(ldi_handle_t lh, + uint_t flags, char *name, char ***data, uint_t *nelements); +extern int ldi_prop_lookup_string(ldi_handle_t lh, + uint_t flags, char *name, char **data); +extern int ldi_prop_lookup_byte_array(ldi_handle_t lh, + uint_t flags, char *name, uchar_t **data, uint_t *nelements); +extern int ldi_prop_get_int(ldi_handle_t lh, + uint_t flags, char *name, int defvalue); +extern int64_t ldi_prop_get_int64(ldi_handle_t lh, + uint_t flags, char *name, int64_t defvalue); +extern int ldi_prop_exists(ldi_handle_t lh, + uint_t flags, char *name); + +extern int ldi_get_dev(ldi_handle_t, dev_t *); +extern int ldi_get_otyp(ldi_handle_t, int *); +extern int ldi_get_devid(ldi_handle_t, ddi_devid_t *); +extern int ldi_get_minor_name(ldi_handle_t, char **); + +/* + * LDI events related declarations + */ +extern int ldi_ev_get_cookie(ldi_handle_t lh, char *evname, + ldi_ev_cookie_t *cookiep); +extern char *ldi_ev_get_type(ldi_ev_cookie_t cookie); +extern int ldi_ev_register_callbacks(ldi_handle_t lh, + ldi_ev_cookie_t cookie, ldi_ev_callback_t *callb, + void *arg, ldi_callback_id_t *id); +extern int ldi_ev_notify(dev_info_t *dip, minor_t minor, int spec_type, + ldi_ev_cookie_t cookie, void *ev_data); +extern void ldi_ev_finalize(dev_info_t *dip, minor_t minor, int spec_type, + int ldi_result, ldi_ev_cookie_t cookie, void *ev_data); +extern int ldi_ev_remove_callbacks(ldi_callback_id_t id); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SUNLDI_H */ diff --git a/illumos-x86_64/usr/include/sys/sunldi_impl.h b/illumos-x86_64/usr/include/sys/sunldi_impl.h new file mode 100644 index 00000000..3d04078a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sunldi_impl.h @@ -0,0 +1,224 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_SUNLDI_IMPL_H +#define _SYS_SUNLDI_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * NOTE + * + * The contents of this file are private to this implementation + * of Solaris and are subject to change at any time without notice. + * + * Applications and drivers using these interfaces will fail + * to run on future releases. + */ + +/* + * LDI hash definitions + */ +#define LH_HASH_SZ 32 +#define LI_HASH_SZ 32 + +/* + * Obsolete LDI event interfaces are available for now but are deprecated and a + * warning will be issued to consumers. + */ +#define LDI_OBSOLETE_EVENT 1 + +/* + * Flag for LDI handle's lh_flags field + */ +#define LH_FLAGS_NOTIFY 0x0001 /* invoked in context of a notify */ + +/* + * LDI initialization function + */ +void ldi_init(void); + +/* + * LDI streams linking interfaces + */ +extern int ldi_mlink_lh(vnode_t *, int, intptr_t, cred_t *, int *); +extern int ldi_mlink_fp(struct stdata *, struct file *, int, int); +extern int ldi_munlink_fp(struct stdata *, struct file *, int); + +/* + * LDI module identifier + */ +struct ldi_ident { + /* protected by ldi_ident_hash_lock */ + struct ldi_ident *li_next; + uint_t li_ref; + + /* unique/static fields in the ident */ + char li_modname[MODMAXNAMELEN]; + modid_t li_modid; + major_t li_major; + dev_info_t *li_dip; + dev_t li_dev; +}; + +/* + * LDI handle + */ +struct ldi_handle { + /* protected by ldi_handle_hash_lock */ + struct ldi_handle *lh_next; + uint_t lh_ref; + uint_t lh_flags; + + /* unique/static fields in the handle */ + uint_t lh_type; + struct ldi_ident *lh_ident; + vnode_t *lh_vp; + +#ifdef LDI_OBSOLETE_EVENT + /* fields protected by lh_lock */ + kmutex_t lh_lock[1]; + struct ldi_event *lh_events; +#endif +}; + +/* + * LDI event information + */ +#ifdef LDI_OBSOLETE_EVENT +typedef struct ldi_event { + /* fields protected by le_lhp->lh_lock */ + struct ldi_event *le_next; + struct ldi_event *le_prev; + + /* unique/static fields in the handle */ + struct ldi_handle *le_lhp; + void (*le_handler)(); + void *le_arg; + ddi_callback_id_t le_id; +} ldi_event_t; +#endif + +typedef struct ldi_ev_callback_impl { + struct ldi_handle *lec_lhp; + dev_info_t *lec_dip; + dev_t lec_dev; + int lec_spec; + int (*lec_notify)(); + void (*lec_finalize)(); + void *lec_arg; + void *lec_cookie; + void *lec_id; + list_node_t lec_list; +} ldi_ev_callback_impl_t; + +/* + * Members of "struct ldi_ev_callback_list" are protected by their le_lock + * member. The struct is currently only used once, as a file-level global, + * and the locking protocol is currently implemented in ldi_ev_lock() and + * ldi_ev_unlock(). + * + * When delivering events to subscribers, ldi_invoke_notify() and + * ldi_invoke_finalize() will walk the list of callbacks: le_head. It is + * possible that an invoked callback function will need to unregister an + * arbitrary number of callbacks from this list. + * + * To enable ldi_ev_remove_callbacks() to remove elements from the list + * without breaking the walk-in-progress, we store the next element in the + * walk direction on the struct as le_walker_next and le_walker_prev. + */ +struct ldi_ev_callback_list { + kmutex_t le_lock; + kcondvar_t le_cv; + int le_busy; + void *le_thread; + list_t le_head; + ldi_ev_callback_impl_t *le_walker_next; + ldi_ev_callback_impl_t *le_walker_prev; +}; + +int ldi_invoke_notify(dev_info_t *dip, dev_t dev, int spec_type, char *event, + void *ev_data); +void ldi_invoke_finalize(dev_info_t *dip, dev_t dev, int spec_type, char *event, + int ldi_result, void *ev_data); +int e_ddi_offline_notify(dev_info_t *dip); +void e_ddi_offline_finalize(dev_info_t *dip, int result); + + +/* + * LDI device usage interfaces + * + * ldi_usage_count(), ldi_usage_walker(), and ldi_usage_t + * + * These functions are used by the devinfo driver and fuser to get a + * device usage information from the LDI. These functions along with + * the ldi_usage_t data structure allow these other subsystems to have + * no knowledge of how the LDI stores it's internal state. + * + * ldi_usage_count() provides an count of how many kernel + * device clients currently exist. + * + * ldi_usage_walker() reports all kernel device usage information. + */ +#define LDI_USAGE_CONTINUE 0 +#define LDI_USAGE_TERMINATE 1 + +typedef struct ldi_usage { + /* + * information about the kernel subsystem that is accessing + * the target device + */ + modid_t src_modid; + char *src_name; + dev_info_t *src_dip; + dev_t src_devt; + + /* + * information about the target device that is open + */ + modid_t tgt_modid; + char *tgt_name; + dev_info_t *tgt_dip; + dev_t tgt_devt; + int tgt_spec_type; +} ldi_usage_t; + +int ldi_usage_count(); +void ldi_usage_walker(void *arg, + int (*callback)(const ldi_usage_t *ldi_usage, void *arg)); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SUNLDI_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/sunmdi.h b/illumos-x86_64/usr/include/sys/sunmdi.h new file mode 100644 index 00000000..4090e2be --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sunmdi.h @@ -0,0 +1,328 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_SUNMDI_H +#define _SYS_SUNMDI_H + +/* + * Multiplexed I/O global include + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Most MDI functions return success or failure + */ +#define MDI_SUCCESS 0 /* Call Success */ +#define MDI_FAILURE -1 /* Unspecified Error */ +#define MDI_NOMEM -2 /* No resources available */ +#define MDI_ACCEPT -3 /* Request accepted */ +#define MDI_BUSY -4 /* Busy */ +#define MDI_NOPATH -5 /* No more paths are available */ +#define MDI_EINVAL -6 /* Invalid parameter */ +#define MDI_NOT_SUPPORTED -8 /* Device not supported */ +#define MDI_DEVI_ONLINING -9 /* Devi is onlining */ + +/* + * handle to mdi_pathinfo node + */ +typedef struct x_mdi_pathinfo *mdi_pathinfo_t; + +/* + * Path info node state definitions + */ +typedef enum { + MDI_PATHINFO_STATE_INIT, + MDI_PATHINFO_STATE_ONLINE, + MDI_PATHINFO_STATE_STANDBY, + MDI_PATHINFO_STATE_FAULT, + MDI_PATHINFO_STATE_OFFLINE +} mdi_pathinfo_state_t; + +/* + * MDI vHCI class definitions + */ +#define MDI_HCI_CLASS_SCSI "scsi_vhci" +#define MDI_HCI_CLASS_IB "ib" + +#ifdef _KERNEL + +/* + * mpxio component definitions: Every registered component of the + * mpxio system has a "mpxio-component" property attached to it. + * Identify its function + */ +#define MDI_COMPONENT_NONE 0 +#define MDI_COMPONENT_VHCI 0x1 +#define MDI_COMPONENT_PHCI 0x2 +#define MDI_COMPONENT_CLIENT 0x4 + +/* + * mdi_pathinfo node state utility definitions (bits in mdi_pathinfo_state_t) + * + * NOTE: having mdi_pathinfo_state_t contain both state and flags is error + * prone. For new flags, please consider using MDI_PATHINFO_FLAG_ (and + * moving existing EXT_STATE_MASK flags over would be good too). + */ +#define MDI_PATHINFO_STATE_TRANSIENT 0x00010000 +#define MDI_PATHINFO_STATE_USER_DISABLE 0x00100000 +#define MDI_PATHINFO_STATE_DRV_DISABLE 0x00200000 +#define MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT 0x00400000 +#define MDI_PATHINFO_STATE_MASK 0x0000FFFF +#define MDI_PATHINFO_EXT_STATE_MASK 0xFFF00000 + +/* + * mdi_pathinfo flags definitions + */ +#define MDI_PATHINFO_FLAGS_HIDDEN 0x00000001 +#define MDI_PATHINFO_FLAGS_DEVICE_REMOVED 0x00000002 + +#define USER_DISABLE 1 +#define DRIVER_DISABLE 2 +#define DRIVER_DISABLE_TRANSIENT 3 + + +/* + * Most MDI functions return success or failure + */ +#define MDI_SUCCESS 0 /* Call Success */ +#define MDI_FAILURE -1 /* Unspecified Error */ +#define MDI_NOMEM -2 /* No resources available */ +#define MDI_ACCEPT -3 /* Request accepted */ +#define MDI_BUSY -4 /* Busy */ +#define MDI_NOPATH -5 /* No more paths are available */ +#define MDI_EINVAL -6 /* Invalid parameter */ +#define MDI_NOT_SUPPORTED -8 /* Device not supported */ +#define MDI_DEVI_ONLINING -9 /* Devi is onlining */ + +/* + * MDI operation vector structure definition + */ +#define MDI_OPS_REV_1 1 +#define MDI_OPS_REV MDI_OPS_REV_1 + +#define MDI_VHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI) +#define MDI_PHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI) +#define MDI_CLIENT(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT) + +/* + * MDI device hotplug notification + */ +int mdi_devi_online(dev_info_t *, uint_t); +int mdi_devi_offline(dev_info_t *, uint_t); + +/* + * MDI path retire interfaces + */ +void mdi_phci_mark_retiring(dev_info_t *dip, char **cons_array); +void mdi_phci_retire_notify(dev_info_t *dip, int *constraint); +void mdi_phci_retire_finalize(dev_info_t *dip, int phci_only, void *constraint); +void mdi_phci_unretire(dev_info_t *dip); + +/* + * MDI devinfo locking functions. + */ +void mdi_devi_enter(dev_info_t *, boolean_t *); +int mdi_devi_tryenter(dev_info_t *, boolean_t *); +void mdi_devi_exit(dev_info_t *, boolean_t); +void mdi_devi_exit_phci(dev_info_t *); +void mdi_devi_enter_phci(dev_info_t *); + +/* + * MDI device support functions. + */ +dev_info_t *mdi_devi_get_vdip(dev_info_t *); +int mdi_devi_pdip_entered(dev_info_t *); + +/* + * MDI component device instance attach/detach notification + */ +int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t); +void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int); +int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t); +void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int); + +/* + * mdi_pathinfo management functions. + * + * Find, allocate and Free functions. + */ +mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *); +int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **); +int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *, + char **, int, int, mdi_pathinfo_t **); +int mdi_pi_free(mdi_pathinfo_t *, int); + +void mdi_hold_path(mdi_pathinfo_t *); +void mdi_rele_path(mdi_pathinfo_t *); + +/* + * mdi_pathinfo node state change functions. + */ +int mdi_pi_online(mdi_pathinfo_t *, int); +int mdi_pi_standby(mdi_pathinfo_t *, int); +int mdi_pi_fault(mdi_pathinfo_t *, int); +int mdi_pi_offline(mdi_pathinfo_t *, int); +/* + * NOTE: the next 2 interfaces will be removed once the NWS files are + * changed to use the new mdi_{enable,disable}_path interfaces + */ +int mdi_pi_disable(dev_info_t *, dev_info_t *, int); +int mdi_pi_enable(dev_info_t *, dev_info_t *, int); +int mdi_pi_disable_path(mdi_pathinfo_t *, int); +int mdi_pi_enable_path(mdi_pathinfo_t *, int); + +int mdi_pi_ishidden(mdi_pathinfo_t *); + +int mdi_pi_device_isremoved(mdi_pathinfo_t *); +int mdi_pi_device_remove(mdi_pathinfo_t *); +int mdi_pi_device_insert(mdi_pathinfo_t *); + +/* + * MPxIO-PM stuff + */ +typedef enum { + MDI_PM_PRE_CONFIG = 0, + MDI_PM_POST_CONFIG, + MDI_PM_PRE_UNCONFIG, + MDI_PM_POST_UNCONFIG, + MDI_PM_HOLD_POWER, + MDI_PM_RELE_POWER +} mdi_pm_op_t; + +int +mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *); + +int +mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int); + +/* + * mdi_pathinfo node walker function. + */ +int mdi_component_is_vhci(dev_info_t *, const char **); +int mdi_component_is_phci(dev_info_t *, const char **); +int mdi_component_is_client(dev_info_t *, const char **); +mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *); +mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *); + +/* + * mdi_pathinfo node member functions + */ +void mdi_pi_lock(mdi_pathinfo_t *); +void mdi_pi_unlock(mdi_pathinfo_t *); +dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *); +dev_info_t *mdi_pi_get_phci(mdi_pathinfo_t *); +char *mdi_pi_get_node_name(mdi_pathinfo_t *); +char *mdi_pi_get_addr(mdi_pathinfo_t *); +mdi_pathinfo_state_t mdi_pi_get_state(mdi_pathinfo_t *); +uint_t mdi_pi_get_flags(mdi_pathinfo_t *); +int mdi_pi_get_path_instance(mdi_pathinfo_t *); +char *mdi_pi_pathname_by_instance(int); +char *mdi_pi_pathname(mdi_pathinfo_t *); +char *mdi_pi_pathname_obp(mdi_pathinfo_t *, char *); +int mdi_pi_pathname_obp_set(mdi_pathinfo_t *, char *); +char *mdi_pi_spathname_by_instance(int); +char *mdi_pi_spathname(mdi_pathinfo_t *); + +/* + * mdi_pathinfo Property handling functions + */ +int mdi_prop_remove(mdi_pathinfo_t *, char *); +int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t); +int mdi_prop_update_int(mdi_pathinfo_t *, char *, int); +int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t); +int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t); +int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *); +int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t); +nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *); + +int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *); +int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *); +int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *); +int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *); +int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **); +int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *); +int mdi_prop_free(void *); + +/* + * pHCI driver instance registration/unregistration + * + * mdi_phci_register() is called by a pHCI drivers to register itself as a + * transport provider for a specific 'class' (see mdi_vhci_register() above); + * it should be called from attach(9e). + * + * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI + * instance from the framework. + */ +int mdi_phci_register(char *, dev_info_t *, int); +int mdi_phci_unregister(dev_info_t *, int); + +/* get set phci private data */ +caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *); +void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t); + +int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *, + dev_info_t **, char *); + +/* + * mdi_vhci node walker function + */ +void mdi_walk_vhcis(int (*f)(dev_info_t *, void *), void *arg); + +/* + * mdi_phci node walker function + */ +void mdi_vhci_walk_phcis(dev_info_t *, int (*f)(dev_info_t *, void *), + void *arg); + +/* + * mdi_client node walker function + */ +void mdi_vhci_walk_clients(dev_info_t *, int (*f)(dev_info_t *, void *), + void *arg); + +/* + * MDI PHCI driver list helper functions + */ +char **mdi_get_phci_driver_list(char *vhci_class, int *ndrivers); +void mdi_free_phci_driver_list(char **driver_list, int ndrivers); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SUNMDI_H */ diff --git a/illumos-x86_64/usr/include/sys/sunndi.h b/illumos-x86_64/usr/include/sys/sunndi.h new file mode 100644 index 00000000..d30ea1f6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sunndi.h @@ -0,0 +1,850 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_SUNNDI_H +#define _SYS_SUNNDI_H + +/* + * Sun Specific NDI definitions + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#define NDI_SUCCESS DDI_SUCCESS /* successful return */ +#define NDI_FAILURE DDI_FAILURE /* unsuccessful return */ +#define NDI_NOMEM -2 /* failed to allocate resources */ +#define NDI_BADHANDLE -3 /* bad handle passed to in function */ +#define NDI_FAULT -4 /* fault during copyin/copyout */ +#define NDI_BUSY -5 /* device busy - could not offline */ +#define NDI_UNBOUND -6 /* device not bound to a driver */ +#define NDI_EINVAL -7 /* invalid request or arguments */ +#define NDI_ENOTSUP -8 /* operation or event not supported */ +#define NDI_CLAIMED NDI_SUCCESS /* event is claimed */ +#define NDI_UNCLAIMED -9 /* event is not claimed */ + +/* + * Property functions: See also, ddipropdefs.h. + * In general, the underlying driver MUST be held + * to call it's property functions. + */ + +/* + * Used to create boolean properties + */ +int +ndi_prop_create_boolean(dev_t match_dev, dev_info_t *dip, char *name); + +/* + * Used to create, modify, and lookup integer properties + */ +int +ndi_prop_update_int(dev_t match_dev, dev_info_t *dip, char *name, int data); + +int +ndi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, char *name, + int *data, uint_t nelements); + +int +ndi_prop_update_int64(dev_t match_dev, dev_info_t *dip, char *name, + int64_t data); + +int +ndi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, char *name, + int64_t *data, uint_t nelements); + +/* + * Used to create, modify, and lookup string properties + */ +int +ndi_prop_update_string(dev_t match_dev, dev_info_t *dip, char *name, + char *data); + +int +ndi_prop_update_string_array(dev_t match_dev, dev_info_t *dip, + char *name, char **data, uint_t nelements); + +/* + * Used to create, modify, and lookup byte properties + */ +int +ndi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip, + char *name, uchar_t *data, uint_t nelements); + +/* + * Used to remove properties + */ +int +ndi_prop_remove(dev_t dev, dev_info_t *dip, char *name); + +void +ndi_prop_remove_all(dev_info_t *dip); + +/* + * Nexus Driver Functions + */ +/* + * Allocate and initialize a new dev_info structure. + * This routine will often be called at interrupt time by a nexus in + * response to a hotplug event, therefore memory allocations are + * not allowed to sleep. + */ +int +ndi_devi_alloc(dev_info_t *parent, const char *node_name, pnode_t nodeid, + dev_info_t **ret_dip); + +void +ndi_devi_alloc_sleep(dev_info_t *parent, const char *node_name, pnode_t nodeid, + dev_info_t **ret_dip); + +/* + * Remove an initialized (but not yet attached) dev_info + * node from it's parent. + */ +int +ndi_devi_free(dev_info_t *dip); + +/* devinfo locking: use DEVI_BUSY_OWNED in ASSERTs to verify */ +void ndi_devi_enter(dev_info_t *dip); +void ndi_devi_exit(dev_info_t *dip); +int ndi_devi_tryenter(dev_info_t *dip); + +/* devinfo ref counting */ +void ndi_hold_devi(dev_info_t *dip); +void ndi_rele_devi(dev_info_t *dip); + +/* driver ref counting */ +struct dev_ops *ndi_hold_driver(dev_info_t *dip); +void ndi_rele_driver(dev_info_t *dip); + +/* + * Change the node name + */ +int +ndi_devi_set_nodename(dev_info_t *dip, char *name, int flags); + +/* + * Place the devinfo in the DS_BOUND state, + * binding a driver to the device + * + * Flags: + * all flags are ignored. + */ +int +ndi_devi_bind_driver(dev_info_t *dip, uint_t flags); + +/* + * Asynchronous version of ndi_devi_bind_driver, callable from + * interrupt context. The dip must be a persistent node. + */ +int +ndi_devi_bind_driver_async(dev_info_t *dip, uint_t flags); + +/* + * Return devctl state of the child addressed by "name@addr". + * For use by a driver's DEVCTL_DEVICE_GETSTATE handler. + */ +int +ndi_devctl_device_getstate(dev_info_t *parent, struct devctl_iocdata *dcp, + uint_t *state); + +/* + * Transition the child addressed by "name@addr" to the online state. + * For use by a driver's DEVCTL_DEVICE_ONLINE handler. + */ +int +ndi_devctl_device_online(dev_info_t *dip, struct devctl_iocdata *dcp, + uint_t flags); + +/* + * Transition the child addressed by "name@addr" to the offline state. + * For use by a driver's DEVCTL_DEVICE_OFFLINE handler. + */ +int +ndi_devctl_device_offline(dev_info_t *dip, struct devctl_iocdata *dcp, + uint_t flags); + +/* + * Remove the child addressed by name@addr. + * For use by a driver's DEVCTL_DEVICE_REMOVE handler. + */ +int +ndi_devctl_device_remove(dev_info_t *dip, struct devctl_iocdata *dcp, + uint_t flags); + +/* + * Bus get state + * For use by a driver's DEVCTL_BUS_GETSTATE handler. + */ +int +ndi_devctl_bus_getstate(dev_info_t *dip, struct devctl_iocdata *dcp, + uint_t *state); + +/* + * Place the devinfo in the ONLINE state + */ +int +ndi_devi_online(dev_info_t *dip, uint_t flags); + +/* + * Generic devctl ioctl handler + */ +int +ndi_devctl_ioctl(dev_info_t *dip, int cmd, intptr_t arg, int mode, + uint_t flags); + +/* + * Asynchronous version of ndi_devi_online, callable from interrupt + * context. The dip must be a persistent node. + */ +int +ndi_devi_online_async(dev_info_t *dip, uint_t flags); + + +/* + * Configure children of a nexus node. + * + * Flags: + * NDI_ONLINE_ATTACH - Attach driver to devinfo node when placing + * the device Online. + * NDI_CONFIG - Recursively configure children if child is nexus node + */ +int +ndi_devi_config(dev_info_t *dip, int flags); + +int +ndi_devi_config_driver(dev_info_t *dip, int flags, major_t major); + +int +ndi_devi_config_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, int flags); + +/* + * Unconfigure children of a nexus node. + * + * Flags: + * NDI_DEVI_REMOVE - Remove child devinfo nodes + * + * NDI_UNCONFIG - Put child devinfo nodes to uninitialized state, + * release resources held by child nodes. + */ +int +ndi_devi_unconfig(dev_info_t *dip, int flags); + +int +e_ddi_devi_unconfig(dev_info_t *dip, dev_info_t **dipp, int flags); + +int +ndi_devi_unconfig_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, + int flags); + +int +ndi_devi_unconfig_driver(dev_info_t *dip, int flags, major_t major); + +void +ndi_set_bus_private(dev_info_t *dip, boolean_t up, uint32_t port_type, + void *data); + +void * +ndi_get_bus_private(dev_info_t *dip, boolean_t up); + +boolean_t +ndi_port_type(dev_info_t *dip, boolean_t up, uint32_t port_type); + +/* + * Interrupt Resource Management (IRM) Pools. + */ +int +ndi_irm_create(dev_info_t *dip, ddi_irm_params_t *paramsp, + ddi_irm_pool_t **pool_retp); + +int +ndi_irm_destroy(ddi_irm_pool_t *poolp); + +int +ndi_irm_resize_pool(ddi_irm_pool_t *poolp, uint_t newsize); + +/* + * Take a device node "Offline". + * + * Offline means to detach the device instance from the bound + * driver and setting the devinfo state to prevent deferred attach + * from re-attaching the device instance. + * + * Flags: + * NDI_DEVI_REMOVE - Remove the node from the devinfo tree after + * first taking it Offline. + */ + +#define NDI_DEVI_REMOVE 0x00000001 /* remove after unconfig */ +#define NDI_ONLINE_ATTACH 0x00000002 /* online/attach after config */ +#define NDI_MDI_FALLBACK 0x00000004 /* Leadville to fallback to phci */ +#define NDI_CONFIG 0x00000008 /* recursively config descendants */ +#define NDI_UNCONFIG 0x00000010 /* unconfig to uninitialized state */ +#define NDI_DEVI_BIND 0x00000020 /* transition to DS_BOUND state */ +#define NDI_DEVI_PERSIST 0x00000040 /* do not config offlined nodes */ +#define NDI_PROMNAME 0x00000080 /* name comes from prom */ +#define NDI_DEVFS_CLEAN 0x00001000 /* clean dv_nodes only, no detach */ +#define NDI_AUTODETACH 0x00002000 /* moduninstall daemon */ +#define NDI_NO_EVENT 0x00004000 /* don't devfs add/remove events */ +#define NDI_DEVI_DEBUG 0x00008000 /* turn on observability */ +#define NDI_CONFIG_REPROBE 0x00010000 /* force reprobe (deferred attach) */ +#define NDI_DEVI_ONLINE 0x00020000 /* force offlined device to online */ +#define NDI_DEVI_OFFLINE 0x00040000 /* set detached device to offline */ +#define NDI_POST_EVENT 0x00080000 /* Post NDI events before remove */ +#define NDI_BRANCH_EVENT_OP 0x01000000 /* branch op needs branch event */ +#define NDI_NO_EVENT_STATE_CHNG 0x02000000 /* don't change the event state */ +#define NDI_DRV_CONF_REPROBE 0x04000000 /* reprobe conf-enum'd nodes only */ +#define NDI_DETACH_DRIVER 0x08000000 /* performing driver_detach */ +#define NDI_MTC_OFF 0x10000000 /* disable multi-threading */ +#define NDI_USER_REQ 0x20000000 /* user requested operation */ + +/* ndi interface flag values */ +#define NDI_SLEEP 0x000000 +#define NDI_NOSLEEP 0x100000 +#define NDI_EVENT_NOPASS 0x200000 /* do not pass event req up the tree */ + +int +ndi_devi_offline(dev_info_t *dip, uint_t flags); + +/* + * Find the child dev_info node of parent nexus 'p' whose name + * matches "cname"@"caddr". Use ndi_devi_findchild() instead. + */ +dev_info_t * +ndi_devi_find(dev_info_t *p, char *cname, char *caddr); + +/* + * Find the child dev_info node of parent nexus 'p' whose name + * matches device name "name"@"addr". + */ +dev_info_t * +ndi_devi_findchild(dev_info_t *p, char *devname); + +/* + * Find the child dev_info node of parent nexus 'p' whose name + * matches "dname"@"ua". If a child doesn't have a "ua" + * value, it calls the function "make_ua" to create it. + */ +dev_info_t * +ndi_devi_findchild_by_callback(dev_info_t *p, char *dname, char *ua, + int (*make_ua)(dev_info_t *, char *, int)); + +/* + * Maintain DEVI_DEVICE_REMOVED hotplug devi_state for remove/reinsert hotplug + * of open devices. + */ +int +ndi_devi_device_isremoved(dev_info_t *dip); +int +ndi_devi_device_remove(dev_info_t *dip); +int +ndi_devi_device_insert(dev_info_t *dip); + +/* + * generate debug msg via NDI_DEVI_DEBUG flag + */ +#define NDI_DEBUG(flags, args) \ + if (flags & NDI_DEVI_DEBUG) cmn_err args + +/* + * Copy in the devctl IOCTL data structure and the strings referenced + * by the structure. + * + * Convenience functions for use by nexus drivers as part of the + * implementation of devctl IOCTL handling. + */ +int +ndi_dc_allochdl(void *iocarg, struct devctl_iocdata **rdcp); + +void +ndi_dc_freehdl(struct devctl_iocdata *dcp); + +char * +ndi_dc_getpath(struct devctl_iocdata *dcp); + +char * +ndi_dc_getname(struct devctl_iocdata *dcp); + +char * +ndi_dc_getaddr(struct devctl_iocdata *dcp); + +nvlist_t * +ndi_dc_get_ap_data(struct devctl_iocdata *dcp); + +char * +ndi_dc_getminorname(struct devctl_iocdata *dcp); + +int +ndi_dc_return_dev_state(dev_info_t *dip, struct devctl_iocdata *dcp); + +int +ndi_dc_return_ap_state(devctl_ap_state_t *ap, struct devctl_iocdata *dcp); + +int +ndi_dc_return_bus_state(dev_info_t *dip, struct devctl_iocdata *dcp); + +int +ndi_dc_devi_create(struct devctl_iocdata *dcp, dev_info_t *pdip, int flags, + dev_info_t **rdip); + +int +ndi_get_bus_state(dev_info_t *dip, uint_t *rstate); + +int +ndi_set_bus_state(dev_info_t *dip, uint_t state); + +/* + * Post an event notification up the device tree hierarchy to the + * parent nexus, until claimed by a bus nexus driver or the top + * of the dev_info tree is reached. + */ +int +ndi_post_event(dev_info_t *dip, dev_info_t *rdip, ddi_eventcookie_t eventhdl, + void *impl_data); + +/* + * Called by the NDI Event Framework to deliver a registration request to the + * appropriate bus nexus driver. + */ +int +ndi_busop_add_eventcall(dev_info_t *dip, dev_info_t *rdip, + ddi_eventcookie_t eventhdl, void (*callback)(), void *arg, + ddi_callback_id_t *cb_id); + +/* + * Called by the NDI Event Framework to deliver an unregister request to the + * appropriate bus nexus driver. + */ +int +ndi_busop_remove_eventcall(dev_info_t *ddip, ddi_callback_id_t id); + +/* + * Called by the NDI Event Framework and/or a bus nexus driver's + * implementation of the (*bus_get_eventcookie)() interface up the device tree + * hierarchy, until claimed by a bus nexus driver or the top of the dev_info + * tree is reached. The NDI Event Framework will skip nexus drivers which are + * not configured to handle NDI events. + */ +int +ndi_busop_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, char *name, + ddi_eventcookie_t *event_cookiep); + +/* + * ndi event callback support routines: + * + * these functions require an opaque ndi event handle + */ +typedef struct ndi_event_hdl *ndi_event_hdl_t; + +/* + * structure for maintaining each registered callback + */ +typedef struct ndi_event_callbacks { + struct ndi_event_callbacks *ndi_evtcb_next; + struct ndi_event_callbacks *ndi_evtcb_prev; + dev_info_t *ndi_evtcb_dip; + char *devname; /* name of device defining this callback */ + void (*ndi_evtcb_callback)(); + void *ndi_evtcb_arg; + ddi_eventcookie_t ndi_evtcb_cookie; +} ndi_event_callbacks_t; + +/* + * a nexus driver defines events that it can support using the + * following structure + */ +typedef struct ndi_event_definition { + int ndi_event_tag; + char *ndi_event_name; + ddi_plevel_t ndi_event_plevel; + uint_t ndi_event_attributes; +} ndi_event_definition_t; + +typedef struct ndi_event_cookie { + ndi_event_definition_t *definition; /* Event Description */ + dev_info_t *ddip; /* Devi defining this event */ + ndi_event_callbacks_t *callback_list; /* Cb's reg'd to w/ this evt */ + struct ndi_event_cookie *next_cookie; /* Next cookie def'd in hdl */ +} ndi_event_cookie_t; + + +#define NDI_EVENT(cookie) ((struct ndi_event_cookie *)(void *)(cookie)) +#define NDI_EVENT_NAME(cookie) (NDI_EVENT(cookie)->definition->ndi_event_name) +#define NDI_EVENT_TAG(cookie) (NDI_EVENT(cookie)->definition->ndi_event_tag) +#define NDI_EVENT_ATTRIBUTES(cookie) \ + (NDI_EVENT(cookie)->definition->ndi_event_attributes) +#define NDI_EVENT_PLEVEL(cookie) \ + (NDI_EVENT(cookie)->definition->ndi_event_plevel) +#define NDI_EVENT_DDIP(cookie) (NDI_EVENT(cookie)->ddip) + +/* ndi_event_attributes */ +#define NDI_EVENT_POST_TO_ALL 0x0 /* broadcast: post to all handlers */ +#define NDI_EVENT_POST_TO_TGT 0x1 /* call only specific child's hdlr */ + +typedef struct ndi_event_set { + ushort_t ndi_events_version; + ushort_t ndi_n_events; + ndi_event_definition_t *ndi_event_defs; +} ndi_event_set_t; + + +#define NDI_EVENTS_REV0 0 +#define NDI_EVENTS_REV1 1 + +/* + * allocate an ndi event handle + */ +int +ndi_event_alloc_hdl(dev_info_t *dip, ddi_iblock_cookie_t cookie, + ndi_event_hdl_t *ndi_event_hdl, uint_t flag); + +/* + * free the ndi event handle + */ +int +ndi_event_free_hdl(ndi_event_hdl_t handle); + +/* + * bind or unbind a set of events to/from the event handle + */ +int +ndi_event_bind_set(ndi_event_hdl_t handle, ndi_event_set_t *ndi_event_set, + uint_t flag); + +int +ndi_event_unbind_set(ndi_event_hdl_t handle, ndi_event_set_t *ndi_event_set, + uint_t flag); + +/* + * get an event cookie + */ +int +ndi_event_retrieve_cookie(ndi_event_hdl_t handle, dev_info_t *child_dip, + char *eventname, ddi_eventcookie_t *cookiep, uint_t flag); + +/* + * add an event callback info to the ndi event handle + */ +int +ndi_event_add_callback(ndi_event_hdl_t handle, dev_info_t *child_dip, + ddi_eventcookie_t cookie, ddi_event_cb_f event_callback, void *arg, + uint_t flag, ddi_callback_id_t *cb_id); + +/* + * remove an event callback registration from the ndi event handle + */ +int +ndi_event_remove_callback(ndi_event_hdl_t handle, ddi_callback_id_t id); + +/* + * perform callbacks for a specified cookie + */ +int +ndi_event_run_callbacks(ndi_event_hdl_t handle, dev_info_t *child_dip, + ddi_eventcookie_t cookie, void *bus_impldata); + +/* + * do callback for just one child_dip, regardless of attributes + */ +int ndi_event_do_callback(ndi_event_hdl_t handle, dev_info_t *child_dip, + ddi_eventcookie_t cookie, void *bus_impldata); + +/* + * ndi_event_tag_to_cookie: utility function to find an event cookie + * given an event tag + */ +ddi_eventcookie_t +ndi_event_tag_to_cookie(ndi_event_hdl_t handle, int event_tag); + +/* + * ndi_event_cookie_to_tag: utility function to find an event tag + * given an event_cookie + */ +int +ndi_event_cookie_to_tag(ndi_event_hdl_t handle, + ddi_eventcookie_t cookie); + +/* + * ndi_event_cookie_to_name: utility function to find an event + * name given an event_cookie + */ +char * +ndi_event_cookie_to_name(ndi_event_hdl_t handle, + ddi_eventcookie_t cookie); + +/* + * ndi_event_tag_to_name: utility function to find an event + * name given an event_tag + */ +char * +ndi_event_tag_to_name(ndi_event_hdl_t handle, int event_tag); + +dev_info_t * +ndi_devi_config_vhci(char *, int); + +#ifdef DEBUG +/* + * ndi_event_dump_hdl: debug functionality used to display event handle + */ +void +ndi_event_dump_hdl(struct ndi_event_hdl *hdl, char *location); +#endif + +/* + * Default busop bus_config helper functions + */ +int +ndi_busop_bus_config(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op, + void *arg, dev_info_t **child, clock_t reset_delay); + +int +ndi_busop_bus_unconfig(dev_info_t *dip, uint_t flags, ddi_bus_config_op_t op, + void *arg); + +/* + * Called by the Nexus/HPC drivers to register, unregister and interact + * with the hotplug framework for the specified hotplug connection. + */ +int +ndi_hp_register(dev_info_t *dip, ddi_hp_cn_info_t *info_p); + +int +ndi_hp_unregister(dev_info_t *dip, char *cn_name); + +int +ndi_hp_state_change_req(dev_info_t *dip, char *cn_name, + ddi_hp_cn_state_t state, uint_t flag); + +void +ndi_hp_walk_cn(dev_info_t *dip, int (*f)(ddi_hp_cn_info_t *, void *), + void *arg); + +/* + * Bus Resource allocation structures and function prototypes exported + * by busra module + */ + +/* structure for specifying a request */ +typedef struct ndi_ra_request { + uint_t ra_flags; /* General flags */ + /* see bit definitions below */ + + uint64_t ra_len; /* Requested allocation length */ + + uint64_t ra_addr; /* Specific base address requested */ + + uint64_t ra_boundbase; /* Base address of the area for */ + /* the allocated resource to be */ + /* restricted to */ + + uint64_t ra_boundlen; /* Length of the area, starting */ + /* from ra_boundbase, for the */ + /* allocated resource to be */ + /* restricted to. */ + + uint64_t ra_align_mask; /* Alignment mask used for */ + /* allocated base address */ +} ndi_ra_request_t; + + +/* ra_flags bit definitions */ +#define NDI_RA_ALIGN_SIZE 0x0001 /* Set the alignment of the */ + /* allocated resource address */ + /* according to the ra_len */ + /* value (alignment mask will */ + /* be (ra_len - 1)). Value of */ + /* ra_len has to be power of 2. */ + /* If this flag is set, value of */ + /* ra_align_mask will be ignored. */ + + +#define NDI_RA_ALLOC_BOUNDED 0x0002 /* Indicates that the resource */ + /* should be restricted to the */ + /* area specified by ra_boundbase */ + /* and ra_boundlen */ + +#define NDI_RA_ALLOC_SPECIFIED 0x0004 /* Indicates that a specific */ + /* address (ra_addr value) is */ + /* requested. */ + +#define NDI_RA_ALLOC_PARTIAL_OK 0x0008 /* Indicates if requested size */ + /* (ra_len) chunk is not available */ + /* then allocate as big chunk as */ + /* possible which is less than or */ + /* equal to ra_len size. */ + + +/* return values specific to bus resource allocator */ +#define NDI_RA_PARTIAL_REQ -7 + + + + +/* Predefined types for generic type of resources */ +#define NDI_RA_TYPE_MEM "memory" +#define NDI_RA_TYPE_IO "io" +#define NDI_RA_TYPE_PCI_BUSNUM "pci_bus_number" +#define NDI_RA_TYPE_PCI_PREFETCH_MEM "pci_prefetchable_memory" +#define NDI_RA_TYPE_INTR "interrupt" + +/* flag bit definition */ +#define NDI_RA_PASS 0x0001 /* pass request up the dev tree */ + +/* + * Prototype definitions for functions exported + */ + +int +ndi_ra_map_setup(dev_info_t *dip, char *type); + +int +ndi_ra_map_destroy(dev_info_t *dip, char *type); + +int +ndi_ra_alloc(dev_info_t *dip, ndi_ra_request_t *req, uint64_t *basep, + uint64_t *lenp, char *type, uint_t flag); + +int +ndi_ra_free(dev_info_t *dip, uint64_t base, uint64_t len, char *type, + uint_t flag); + +/* + * ndi_dev_is_prom_node: Return non-zero if the node is a prom node + */ +int ndi_dev_is_prom_node(dev_info_t *); + +/* + * ndi_dev_is_pseudo_node: Return non-zero if the node is a pseudo node. + * NB: all non-prom nodes are pseudo nodes. + * c.f. ndi_dev_is_persistent_node + */ +int ndi_dev_is_pseudo_node(dev_info_t *); + +/* + * ndi_dev_is_persistent_node: Return non-zero if the node has the + * property of persistence. + */ +int ndi_dev_is_persistent_node(dev_info_t *); + +/* + * ndi_dev_is_hotplug_node: Return non-zero if the node was created by hotplug. + */ +int ndi_dev_is_hotplug_node(dev_info_t *); + +/* + * ndi_dev_is_hidden_node: Return non-zero if the node is hidden. + */ +int ndi_dev_is_hidden_node(dev_info_t *); + +/* + * ndi_devi_set_hidden: mark a node as hidden + * ndi_devi_clr_hidden: mark a node as visible + */ +void ndi_devi_set_hidden(dev_info_t *); +void ndi_devi_clr_hidden(dev_info_t *); + +/* + * Event posted when a fault is reported + */ +#define DDI_DEVI_FAULT_EVENT "DDI:DEVI_FAULT" + +struct ddi_fault_event_data { + dev_info_t *f_dip; + ddi_fault_impact_t f_impact; + ddi_fault_location_t f_location; + const char *f_message; + ddi_devstate_t f_oldstate; +}; + +/* + * Access handle/DMA handle fault flag setting/clearing functions for nexi + */ +void ndi_set_acc_fault(ddi_acc_handle_t ah); +void ndi_clr_acc_fault(ddi_acc_handle_t ah); +void ndi_set_dma_fault(ddi_dma_handle_t dh); +void ndi_clr_dma_fault(ddi_dma_handle_t dh); + +/* Driver.conf property merging */ +int ndi_merge_node(dev_info_t *, int (*)(dev_info_t *, char *, int)); +void ndi_merge_wildcard_node(dev_info_t *); + +/* + * Ndi 'flavor' support: These interfaces are to support a nexus driver + * with multiple 'flavors' of children (devi_flavor of child), coupled + * with a child flavor-specifc private data mechanism (via devi_flavor_v + * of parent). This is provided as an extension to ddi_[sg]et_driver_private, + * where the vanilla 'flavor' is what is stored or retrieved via + * ddi_[sg]et_driver_private. + * + * Flavors are indexed with a small integer. The first flavor, flavor + * zero, is always present and reserved as the 'vanilla' flavor. + * Space for extra flavors can be allocated and private pointers + * with respect to each flavor set and retrieved. + * + * NOTE:For a nexus driver, if the need to support multiple flavors of + * children is understood from the begining, then a private 'flavor' + * mechanism can be implemented via ddi_[sg]et_driver_private. + * + * With SCSA, the need to support multiple flavors of children was not + * anticipated, and ddi_get_driver_private(9F) of an initiator port + * devinfo node was publicly defined in the DDI to return a + * scsi_device(9S) child-flavor specific value: a pointer to + * scsi_hba_tran(9S). Over the years, each time the need to support + * a new flavor of child has occurred, a new form of overload/kludge + * has been devised. The ndi 'flavors' interfaces provide a simple way + * to address this issue that can be used by both SCSA nexus support, + * and by other nexus drivers. + */ + +/* + * Interfaces to maintain flavor-specific private data for children of self + */ +#define NDI_FLAVOR_VANILLA 0 + +void ndi_flavorv_alloc(dev_info_t *self, int nflavors); +void ndi_flavorv_set(dev_info_t *self, ndi_flavor_t child_flavor, void *); +void *ndi_flavorv_get(dev_info_t *self, ndi_flavor_t child_flavor); + +/* Interfaces for 'self' nexus driver to get/set flavor of child */ +void ndi_flavor_set(dev_info_t *child, ndi_flavor_t child_flavor); +ndi_flavor_t ndi_flavor_get(dev_info_t *child); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SUNNDI_H */ diff --git a/illumos-x86_64/usr/include/sys/sunpm.h b/illumos-x86_64/usr/include/sys/sunpm.h new file mode 100644 index 00000000..7ce11e0b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sunpm.h @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SUNPM_H +#define _SYS_SUNPM_H + +/* + * Sun Specific Power Management definitions + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Power cycle transition check is supported for SCSI and SATA devices. + */ +#define DC_SCSI_FORMAT 0x1 /* SCSI */ +#define DC_SMART_FORMAT 0x2 /* SMART */ + +#define DC_SCSI_MFR_LEN 6 /* YYYYWW */ + +struct pm_scsi_cycles { + int lifemax; /* lifetime max power cycles */ + int ncycles; /* number of cycles so far */ + char svc_date[DC_SCSI_MFR_LEN]; /* service date YYYYWW */ + int flag; /* reserved for future */ +}; + +struct pm_smart_count { + int allowed; /* normalized max cycles allowed */ + int consumed; /* normalized consumed cycles */ + int flag; /* type of cycles */ +}; + +struct pm_trans_data { + int format; /* data format */ + union { + struct pm_scsi_cycles scsi_cycles; + struct pm_smart_count smart_count; + } un; +}; + +/* + * Power levels for devices supporting ACPI based D0, D1, D2, D3 states. + * + * Note that 0 is off in Solaris PM framework but D0 is full power + * for these devices. + */ +#define PM_LEVEL_D3 0 /* D3 state - off */ +#define PM_LEVEL_D2 1 /* D2 state */ +#define PM_LEVEL_D1 2 /* D1 state */ +#define PM_LEVEL_D0 3 /* D0 state - fully on */ + +/* + * Useful strings for creating pm-components property for these devices. + * If a device driver wishes to provide more specific description of power + * levels (highly recommended), it should NOT use following generic defines. + */ +#define PM_LEVEL_D3_STR "0=Device D3 State" +#define PM_LEVEL_D2_STR "1=Device D2 State" +#define PM_LEVEL_D1_STR "2=Device D1 State" +#define PM_LEVEL_D0_STR "3=Device D0 State" + +/* + * Generic Sun PM definitions. + */ + +/* + * These are obsolete power management interfaces, they will be removed from + * a subsequent release. + */ +int pm_create_components(dev_info_t *dip, int num_components); + +void pm_destroy_components(dev_info_t *dip); + +void pm_set_normal_power(dev_info_t *dip, int component_number, int level); + +int pm_get_normal_power(dev_info_t *dip, int component_number); + +/* + * These are power management interfaces. + */ + +int pm_busy_component(dev_info_t *dip, int component_number); + +int pm_idle_component(dev_info_t *dip, int component_number); + +int pm_get_current_power(dev_info_t *dip, int component, int *levelp); + +int pm_power_has_changed(dev_info_t *, int, int); + +int pm_trans_check(struct pm_trans_data *datap, time_t *intervalp); + +int pm_lower_power(dev_info_t *dip, int comp, int level); + +int pm_raise_power(dev_info_t *dip, int comp, int level); + +int pm_update_maxpower(dev_info_t *dip, int comp, int level); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SUNPM_H */ diff --git a/illumos-x86_64/usr/include/sys/suntpi.h b/illumos-x86_64/usr/include/sys/suntpi.h new file mode 100644 index 00000000..4b252bb5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/suntpi.h @@ -0,0 +1,79 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1990-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_SUNTPI_H +#define _SYS_SUNTPI_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Persistent information about the capabilities of transport providers. + * This structure is for the internal use of sockfs and timod. Because + * bitfield operations are not atomic, the lock must be used to avoid + * inconsistencies. + */ +typedef struct tpi_provinfo { + struct tpi_provinfo *tpi_next; + void *tpi_key; + size_t tpi_keylen; + kmutex_t tpi_lock; + uint32_t tpi_capability : 2, + tpi_myname : 2, + tpi_peername : 2, + _tpi_unused : 26; +} tpi_provinfo_t; + +/* + * Possible values for the above 2-bitfields. A capability is either + * supported, unsupported or unknown. + */ +#define PI_DONTKNOW 0 +#define PI_NO 1 +#define PI_YES 2 + +extern void tpi_init(void); +extern tpi_provinfo_t *tpi_findprov(queue_t *); + +#define PI_PROVLOCK(tp) mutex_enter(&(tp)->tpi_lock) +#define PI_PROVUNLOCK(tp) mutex_exit(&(tp)->tpi_lock) + +extern mblk_t *tpi_ack_alloc(mblk_t *, size_t, uchar_t, t_scalar_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SUNTPI_H */ diff --git a/illumos-x86_64/usr/include/sys/suntty.h b/illumos-x86_64/usr/include/sys/suntty.h new file mode 100644 index 00000000..601080a9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/suntty.h @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_SUNTTY_H +#define _SYS_SUNTTY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Kludge header file to get kernel to build. + * #define TIOCCONS (tIOC|32) get console I/O + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SUNTTY_H */ diff --git a/illumos-x86_64/usr/include/sys/swap.h b/illumos-x86_64/usr/include/sys/swap.h new file mode 100644 index 00000000..8da9a941 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/swap.h @@ -0,0 +1,242 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_SWAP_H +#define _SYS_SWAP_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#error "Cannot use swapctl in the large files compilation environment" +#endif + +/* The following are for the swapctl system call */ + +#define SC_ADD 1 /* add a specified resource for swapping */ +#define SC_LIST 2 /* list all the swapping resources */ +#define SC_REMOVE 3 /* remove the specified swapping resource */ +#define SC_GETNSWP 4 /* get number of swap resources configured */ +#define SC_AINFO 5 /* get anonymous memory resource information */ + +typedef struct swapres { + char *sr_name; /* pathname of the resource specified */ + off_t sr_start; /* starting offset of the swapping resource */ + off_t sr_length; /* length of the swap area */ +} swapres_t; + +typedef struct swapent { + char *ste_path; /* get the name of the swap file */ + off_t ste_start; /* starting block for swapping */ + off_t ste_length; /* length of swap area */ + long ste_pages; /* numbers of pages for swapping */ + long ste_free; /* numbers of ste_pages free */ + int ste_flags; /* see below */ +} swapent_t; + +typedef struct swaptable { + int swt_n; /* number of swapents following */ + struct swapent swt_ent[1]; /* array of swt_n swapents */ +} swaptbl_t; + + +#if defined(_SYSCALL32) + +/* Kernel's view of user ILP32 swapres and swapent structures */ + +typedef struct swapres32 { + caddr32_t sr_name; /* pathname of the resource specified */ + off32_t sr_start; /* starting offset of the swapping resource */ + off32_t sr_length; /* length of the swap area */ +} swapres32_t; + +typedef struct swapent32 { + caddr32_t ste_path; /* get the name of the swap file */ + off32_t ste_start; /* starting block for swapping */ + off32_t ste_length; /* length of swap area */ + int32_t ste_pages; /* numbers of pages for swapping */ + int32_t ste_free; /* numbers of ste_pages free */ + int32_t ste_flags; /* see below */ +} swapent32_t; + +typedef struct swaptable32 { + int32_t swt_n; /* number of swapents following */ + struct swapent32 swt_ent[1]; /* array of swt_n swapents */ +} swaptbl32_t; + +#endif /* _SYSCALL32 */ + +#if defined(_KERNEL) +extern int swapctl(int, void *, int *); +#if defined(_LP64) && defined(_SYSCALL32) +extern int swapctl32(int, void *, int *); +#endif /* _LP64 && _SYSCALL32 */ +#else /* !_KERNEL */ +extern int swapctl(int, void *); +#endif /* _KERNEL */ + + +/* ste_flags values */ + +#define ST_INDEL 0x01 /* Deletion of file is in progress. */ + /* Prevents others from deleting or */ + /* allocating from it */ +#define ST_DOINGDEL 0x02 /* Set during deletion of file */ + /* Clearing during deletion signals */ + /* that you want to add the file back */ + /* again, and will eventually cause */ + /* it to be added back */ + +/* + * VM - virtual swap device. + */ +struct swapinfo { + ulong_t si_soff; /* starting offset (bytes) of file */ + ulong_t si_eoff; /* ending offset (bytes) of file */ + struct vnode *si_vp; /* vnode (commonvp if device) */ + struct swapinfo *si_next; /* next swap area */ + int si_allocs; /* # of conseq. allocs from this area */ + short si_flags; /* flags defined below */ + pgcnt_t si_npgs; /* number of pages of swap space */ + pgcnt_t si_nfpgs; /* number of free pages of swap space */ + int si_pnamelen; /* swap file name length + 1 */ + char *si_pname; /* swap file name */ + ssize_t si_mapsize; /* # bytes allocated for bitmap */ + uint_t *si_swapslots; /* bitmap of slots, unset == free */ + pgcnt_t si_hint; /* first page to check if free */ + ssize_t si_checkcnt; /* # of checks to find freeslot */ + ssize_t si_alloccnt; /* used to find ave checks */ +}; + +/* + * Stuff to convert an anon slot pointer to a page name. + * Because the address of the slot (ap) is a unique identifier, we + * use it to generate a unique (vp,off), as shown in the comment for + * swap_alloc(). + * + * The off bits are shifted PAGESHIFT to directly form a page aligned + * offset; the vp index bits map 1-1 to a vnode. + * + */ +#define MAX_SWAP_VNODES_LOG2 11 /* log2(MAX_SWAP_VNODES) */ +#define MAX_SWAP_VNODES (1U << MAX_SWAP_VNODES_LOG2) /* max # swap vnodes */ +#define AN_VPMASK (MAX_SWAP_VNODES - 1) /* vp index mask */ +#define AN_VPSHIFT MAX_SWAP_VNODES_LOG2 +/* + * Convert from an anon slot to associated vnode and offset. + */ +#define swap_xlate(AP, VPP, OFFP) \ +{ \ + *(VPP) = (AP)->an_vp; \ + *(OFFP) = (AP)->an_off; \ +} +#define swap_xlate_nopanic swap_xlate + +/* + * Get a vnode name for an anon slot. + * The vnum, offset are derived from anon struct address which is + * 16 bytes aligned. anon structs may be kmem_cache_alloc'd concurrently by + * multiple threads and come from a small range of addresses (same slab), in + * which case high order AP bits do not vary much, so choose vnum from low + * order bits which vary the most. Different threads will thus get different + * vnums and vnodes, which avoids vph_mutex_contention on the subsequent + * page_hashin(). + * + * +-----------...-------------------+-----------------------+----+ + * | swap offset | vnum |0000| + * +-----------...-------------------+-----------------------+----+ + * 63 15 14 4 3 0 + */ +#define swap_alloc(AP) \ +{ \ + (AP)->an_vp = swapfs_getvp(((uintptr_t)(AP) >> AN_CACHE_ALIGN_LOG2) \ + & AN_VPMASK); \ + (AP)->an_off = (anoff_t)((((uintptr_t)(AP)) >> \ + AN_VPSHIFT + AN_CACHE_ALIGN_LOG2) << PAGESHIFT); \ +} + +/* + * Free the page name for the specified anon slot. + * For now there's nothing to do. + */ +#define swap_free(AP) + +/* Flags for swap_phys_alloc */ +#define SA_NOT 0x01 /* Must have slot from swap dev other than input one */ + +/* Special error codes for swap_newphysname() */ +#define SE_NOSWAP -1 /* No physical swap slots available */ +#define SE_NOANON -2 /* No anon slot for swap slot */ + +#ifdef _KERNEL +extern struct anon *swap_anon(struct vnode *vp, u_offset_t off); +extern int swap_phys_alloc(struct vnode **vpp, u_offset_t *offp, size_t *lenp, + uint_t flags); +extern void swap_phys_free(struct vnode *vp, u_offset_t off, size_t len); +extern int swap_getphysname(struct vnode *vp, u_offset_t off, + struct vnode **pvpp, u_offset_t *poffp); +extern int swap_newphysname(struct vnode *vp, u_offset_t offset, + u_offset_t *offp, size_t *lenp, struct vnode **pvpp, u_offset_t *poffp); + +extern struct swapinfo *swapinfo; +extern int swap_debug; +#endif /* _KERNEL */ + +#ifdef SWAP_DEBUG +#define SW_RENAME 0x01 +#define SW_RESV 0x02 +#define SW_ALLOC 0x04 +#define SW_CTL 0x08 +#define SWAP_PRINT(f, s, x1, x2, x3, x4, x5) \ + if (swap_debug & f) \ + printf(s, x1, x2, x3, x4, x5); +#else /* SWAP_DEBUG */ +#define SWAP_PRINT(f, s, x1, x2, x3, x4, x5) +#endif /* SWAP_DEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SWAP_H */ diff --git a/illumos-x86_64/usr/include/sys/synch.h b/illumos-x86_64/usr/include/sys/synch.h new file mode 100644 index 00000000..0e4983b0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/synch.h @@ -0,0 +1,161 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYNCH_H +#define _SYS_SYNCH_H + +#ifndef _ASM +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM +/* + * Thread and LWP mutexes have the same type + * definitions. + * + * NOTE: + * + * POSIX requires that define the structures pthread_mutex_t + * and pthread_cond_t. Although these structures are identical to mutex_t + * (lwp_mutex_t) and cond_t (lwp_cond_t), defined here, a typedef of these + * types would require including in , pulling in + * non-posix symbols/constants, violating POSIX namespace restrictions. Hence, + * pthread_mutex_t/pthread_cond_t have been redefined (in ). + * Any modifications done to mutex_t/lwp_mutex_t or cond_t/lwp_cond_t must + * also be done to pthread_mutex_t/pthread_cond_t. + */ +typedef struct _lwp_mutex { + struct { + uint16_t flag1; + uint8_t flag2; + uint8_t ceiling; + union { + uint16_t bcptype; + struct { + uint8_t count_type1; + uint8_t count_type2; + } mtype_rcount; + } mbcp_type_un; + uint16_t magic; + } flags; + union { + struct { + uint8_t pad[8]; + } lock64; + struct { + uint32_t ownerpid; + uint32_t lockword; + } lock32; + upad64_t owner64; + } lock; + upad64_t data; +} lwp_mutex_t; + +/* + * Thread and LWP condition variables have the same + * type definition. + * NOTE: + * The layout of the following structure should be kept in sync with the + * layout of pthread_cond_t in sys/types.h. See NOTE above for lwp_mutex_t. + */ +typedef struct _lwp_cond { + struct { + uint8_t flag[4]; + uint16_t type; + uint16_t magic; + } flags; + upad64_t data; +} lwp_cond_t; + +/* + * LWP semaphores + */ +typedef struct _lwp_sema { + uint32_t count; /* semaphore count */ + uint16_t type; + uint16_t magic; + uint8_t flags[8]; /* last byte reserved for waiters */ + upad64_t data; /* optional data */ +} lwp_sema_t; + +/* + * Thread and LWP rwlocks have the same type definition. + * NOTE: The layout of this structure should be kept in sync with the layout + * of the correponding structure of pthread_rwlock_t in sys/types.h. + * Also, because we have to deal with C++, there is an identical structure + * for rwlock_t in head/sync.h that we cannot change. + */ +typedef struct _lwp_rwlock { + int32_t readers; /* rwstate word */ + uint16_t type; + uint16_t magic; + lwp_mutex_t mutex; /* used with process-shared rwlocks */ + lwp_cond_t readercv; /* used only to indicate ownership */ + lwp_cond_t writercv; /* used only to indicate ownership */ +} lwp_rwlock_t; + +#endif /* _ASM */ +/* + * Definitions of synchronization types. + */ +#define USYNC_THREAD 0x00 /* private to a process */ +#define USYNC_PROCESS 0x01 /* shared by processes */ + +/* Keep the following values in sync with pthread.h */ +#define LOCK_NORMAL 0x00 /* same as USYNC_THREAD */ +#define LOCK_SHARED 0x01 /* same as USYNC_PROCESS */ +#define LOCK_ERRORCHECK 0x02 /* error check lock */ +#define LOCK_RECURSIVE 0x04 /* recursive lock */ +#define LOCK_PRIO_INHERIT 0x10 /* priority inheritance lock */ +#define LOCK_PRIO_PROTECT 0x20 /* priority ceiling lock */ +#define LOCK_ROBUST 0x40 /* robust lock */ + +/* + * USYNC_PROCESS_ROBUST is a deprecated historical type. It is mapped + * into (USYNC_PROCESS | LOCK_ROBUST) by mutex_init(). Application code + * should be revised to use (USYNC_PROCESS | LOCK_ROBUST) rather than this. + */ +#define USYNC_PROCESS_ROBUST 0x08 + +/* + * lwp_mutex_t flags + */ +#define LOCK_OWNERDEAD 0x1 +#define LOCK_NOTRECOVERABLE 0x2 +#define LOCK_INITED 0x4 +#define LOCK_UNMAPPED 0x8 +#define LOCK_DEADLOCK 0x10 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYNCH_H */ diff --git a/illumos-x86_64/usr/include/sys/syscall.h b/illumos-x86_64/usr/include/sys/syscall.h new file mode 100644 index 00000000..cd4f5445 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/syscall.h @@ -0,0 +1,529 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + * Copyright 2020 Oxide Computer Company + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_SYSCALL_H +#define _SYS_SYSCALL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * system call numbers + * syscall(SYS_xxxx, ...) + */ + + /* syscall enumeration MUST begin with 1 */ + + /* + * SunOS/SPARC uses 0 for the indirect system call SYS_syscall + * but this doesn't count because it is just another way + * to specify the real system call number. + */ + +#define SYS_syscall 0 +#define SYS_exit 1 +#define SYS_psecflags 2 +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_linkat 7 +#define SYS_link 9 +#define SYS_unlink 10 +#define SYS_symlinkat 11 +#define SYS_chdir 12 +#define SYS_time 13 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_chown 16 +#define SYS_brk 17 +#define SYS_stat 18 +#define SYS_lseek 19 +#define SYS_getpid 20 +#define SYS_mount 21 +#define SYS_readlinkat 22 +#define SYS_setuid 23 +#define SYS_getuid 24 +#define SYS_stime 25 +#define SYS_pcsample 26 +#define SYS_alarm 27 +#define SYS_fstat 28 +#define SYS_pause 29 +#define SYS_stty 31 +#define SYS_gtty 32 +#define SYS_access 33 +#define SYS_nice 34 +#define SYS_statfs 35 +#define SYS_sync 36 +#define SYS_kill 37 +#define SYS_fstatfs 38 +#define SYS_pgrpsys 39 + /* + * subcodes: + * getpgrp() :: syscall(39,0) + * setpgrp() :: syscall(39,1) + * getsid(pid) :: syscall(39,2,pid) + * setsid() :: syscall(39,3) + * getpgid(pid) :: syscall(39,4,pid) + * setpgid(pid,pgid) :: syscall(39,5,pid,pgid) + */ +#define SYS_uucopystr 40 +#define SYS_pipe 42 +#define SYS_times 43 +#define SYS_profil 44 +#define SYS_faccessat 45 +#define SYS_setgid 46 +#define SYS_getgid 47 +#define SYS_mknodat 48 +#define SYS_msgsys 49 + /* + * subcodes: + * msgget(...) :: msgsys(0, ...) + * msgctl(...) :: msgsys(1, ...) + * msgrcv(...) :: msgsys(2, ...) + * msgsnd(...) :: msgsys(3, ...) + * msgids(...) :: msgsys(4, ...) + * msgsnap(...) :: msgsys(5, ...) + * see + */ +#define SYS_sysi86 50 + /* + * subcodes: + * sysi86(code, ...) + */ +#define SYS_acct 51 +#define SYS_shmsys 52 + /* + * subcodes: + * shmat (...) :: shmsys(0, ...) + * shmctl(...) :: shmsys(1, ...) + * shmdt (...) :: shmsys(2, ...) + * shmget(...) :: shmsys(3, ...) + * shmids(...) :: shmsys(4, ...) + * see + */ +#define SYS_semsys 53 + /* + * subcodes: + * semctl(...) :: semsys(0, ...) + * semget(...) :: semsys(1, ...) + * semop (...) :: semsys(2, ...) + * semids(...) :: semsys(3, ...) + * semtimedop(...) :: semsys(4, ...) + * see + */ +#define SYS_ioctl 54 +#define SYS_uadmin 55 +#define SYS_fchownat 56 +#define SYS_utssys 57 + /* + * subcodes (third argument): + * uname(obuf) (obsolete) :: syscall(57, obuf, ign, 0) + * subcode 1 unused + * ustat(dev, obuf) :: syscall(57, obuf, dev, 2) + * fusers(path, flags, obuf) :: syscall(57, path, flags, 3, obuf) + * see + */ +#define SYS_fdsync 58 +#define SYS_execve 59 +#define SYS_umask 60 +#define SYS_chroot 61 +#define SYS_fcntl 62 +#define SYS_ulimit 63 +#define SYS_renameat 64 +#define SYS_unlinkat 65 +#define SYS_fstatat 66 +#define SYS_fstatat64 67 +#define SYS_openat 68 +#define SYS_openat64 69 +#define SYS_tasksys 70 + /* + * subcodes: + * settaskid(...) :: tasksys(0, ...) + * gettaskid(...) :: tasksys(1, ...) + * getprojid(...) :: tasksys(2, ...) + */ +#define SYS_acctctl 71 +#define SYS_exacctsys 72 + /* + * subcodes: + * getacct(...) :: exacct(0, ...) + * putacct(...) :: exacct(1, ...) + * wracct(...) :: exacct(2, ...) + */ +#define SYS_getpagesizes 73 + /* + * subcodes: + * getpagesizes2(...) :: getpagesizes(0, ...) + * getpagesizes(...) :: getpagesizes(1, ...) legacy + */ +#define SYS_rctlsys 74 + /* + * subcodes: + * getrctl(...) :: rctlsys(0, ...) + * setrctl(...) :: rctlsys(1, ...) + * rctllist(...) :: rctlsys(2, ...) + * rctlctl(...) :: rctlsys(3, ...) + */ +#define SYS_sidsys 75 + /* + * subcodes: + * allocids(...) :: sidsys(0, ...) + * idmap_reg(...) :: sidsys(1, ...) + * idmap_unreg(...) :: sidsys(2, ...) + */ +#define SYS_lwp_park 77 + /* + * subcodes: + * _lwp_park(timespec_t *, lwpid_t) :: syslwp_park(0, ...) + * _lwp_unpark(lwpid_t, int) :: syslwp_park(1, ...) + * _lwp_unpark_all(lwpid_t *, int) :: syslwp_park(2, ...) + * _lwp_unpark_cancel(lwpid_t *, int) :: syslwp_park(3, ...) + * _lwp_set_park(lwpid_t *, int) :: syslwp_park(4, ...) + */ +#define SYS_sendfilev 78 + /* + * subcodes : + * sendfilev() :: sendfilev(0, ...) + * sendfilev64() :: sendfilev(1, ...) + */ +#define SYS_rmdir 79 +#define SYS_mkdir 80 +#define SYS_getdents 81 +#define SYS_privsys 82 + /* + * subcodes: + * setppriv(...) :: privsys(0, ...) + * getppriv(...) :: privsys(1, ...) + * getimplinfo(...) :: privsys(2, ...) + * setpflags(...) :: privsys(3, ...) + * getpflags(...) :: privsys(4, ...) + * issetugid(); :: privsys(5) + */ +#define SYS_ucredsys 83 + /* + * subcodes: + * ucred_get(...) :: ucredsys(0, ...) + * getpeerucred(...) :: ucredsys(1, ...) + */ +#define SYS_sysfs 84 + /* + * subcodes: + * sysfs(code, ...) + * see + */ +#define SYS_getmsg 85 +#define SYS_putmsg 86 +#define SYS_lstat 88 +#define SYS_symlink 89 +#define SYS_readlink 90 +#define SYS_setgroups 91 +#define SYS_getgroups 92 +#define SYS_fchmod 93 +#define SYS_fchown 94 +#define SYS_sigprocmask 95 +#define SYS_sigsuspend 96 +#define SYS_sigaltstack 97 +#define SYS_sigaction 98 +#define SYS_sigpending 99 + /* + * subcodes: + * subcode 0 unused + * sigpending(...) :: syscall(99, 1, ...) + * sigfillset(...) :: syscall(99, 2, ...) + */ +#define SYS_context 100 + /* + * subcodes: + * getcontext(...) :: syscall(100, 0, ...) + * setcontext(...) :: syscall(100, 1, ...) + */ +#define SYS_fchmodat 101 +#define SYS_mkdirat 102 +#define SYS_statvfs 103 +#define SYS_fstatvfs 104 +#define SYS_getloadavg 105 +#define SYS_nfssys 106 +#define SYS_waitid 107 +#define SYS_waitsys SYS_waitid /* historical */ +#define SYS_sigsendsys 108 +#define SYS_hrtsys 109 +#define SYS_utimesys 110 + /* + * subcodes: + * futimens(...) :: syscall(110, 0, ...) + * utimensat(...) :: syscall(110, 1, ...) + */ +#define SYS_sigresend 111 +#define SYS_priocntlsys 112 +#define SYS_pathconf 113 +#define SYS_mincore 114 +#define SYS_mmap 115 +#define SYS_mprotect 116 +#define SYS_munmap 117 +#define SYS_fpathconf 118 +#define SYS_vfork 119 +#define SYS_fchdir 120 +#define SYS_readv 121 +#define SYS_writev 122 +#define SYS_preadv 123 +#define SYS_pwritev 124 +#define SYS_upanic 125 +#define SYS_getrandom 126 +#define SYS_mmapobj 127 +#define SYS_setrlimit 128 +#define SYS_getrlimit 129 +#define SYS_lchown 130 +#define SYS_memcntl 131 +#define SYS_getpmsg 132 +#define SYS_putpmsg 133 +#define SYS_rename 134 +#define SYS_uname 135 +#define SYS_setegid 136 +#define SYS_sysconfig 137 +#define SYS_adjtime 138 +#define SYS_systeminfo 139 +#define SYS_sharefs 140 +#define SYS_seteuid 141 +#define SYS_forksys 142 + /* + * subcodes: + * forkx(flags) :: forksys(0, flags) + * forkallx(flags) :: forksys(1, flags) + * vforkx(flags) :: forksys(2, flags) + */ +#define SYS_sigtimedwait 144 +#define SYS_lwp_info 145 +#define SYS_yield 146 +#define SYS_lwp_sema_post 148 +#define SYS_lwp_sema_trywait 149 +#define SYS_lwp_detach 150 +#define SYS_corectl 151 +#define SYS_modctl 152 +#define SYS_fchroot 153 +#define SYS_vhangup 155 +#define SYS_gettimeofday 156 +#define SYS_getitimer 157 +#define SYS_setitimer 158 +#define SYS_lwp_create 159 +#define SYS_lwp_exit 160 +#define SYS_lwp_suspend 161 +#define SYS_lwp_continue 162 +#define SYS_lwp_kill 163 +#define SYS_lwp_self 164 +#define SYS_lwp_sigmask 165 +#define SYS_lwp_private 166 +#define SYS_lwp_wait 167 +#define SYS_lwp_mutex_wakeup 168 +#define SYS_lwp_cond_wait 170 +#define SYS_lwp_cond_signal 171 +#define SYS_lwp_cond_broadcast 172 +#define SYS_pread 173 +#define SYS_pwrite 174 +#define SYS_llseek 175 +#define SYS_inst_sync 176 +#define SYS_brand 177 +#define SYS_kaio 178 + /* + * subcodes: + * aioread(...) :: kaio(AIOREAD, ...) + * aiowrite(...) :: kaio(AIOWRITE, ...) + * aiowait(...) :: kaio(AIOWAIT, ...) + * aiocancel(...) :: kaio(AIOCANCEL, ...) + * aionotify() :: kaio(AIONOTIFY) + * aioinit() :: kaio(AIOINIT) + * aiostart() :: kaio(AIOSTART) + * see + */ +#define SYS_cpc 179 +#define SYS_lgrpsys 180 +#define SYS_meminfosys SYS_lgrpsys + /* + * subcodes: + * meminfo(...) :: meminfosys(MISYS_MEMINFO, ...) + */ +#define SYS_rusagesys 181 + /* + * subcodes: + * getrusage(...) :: rusagesys(RUSAGESYS_GETRUSAGE, ...) + * getvmusage(...) :: rusagesys(RUSAGESYS_GETVMUSAGE, ...) + */ +#define SYS_port 182 + /* + * subcodes: + * port_create(...) :: portfs(PORT_CREATE, ...) + * port_associate(...) :: portfs(PORT_ASSOCIATE, ...) + * port_dissociate(...) :: portfs(PORT_DISSOCIATE, ...) + * port_send(...) :: portfs(PORT_SEND, ...) + * port_sendn(...) :: portfs(PORT_SENDN, ...) + * port_get(...) :: portfs(PORT_GET, ...) + * port_getn(...) :: portfs(PORT_GETN, ...) + * port_alert(...) :: portfs(PORT_ALERT, ...) + * port_dispatch(...) :: portfs(PORT_DISPATCH, ...) + */ +#define SYS_pollsys 183 +#define SYS_labelsys 184 +#define SYS_acl 185 +#define SYS_auditsys 186 +#define SYS_processor_bind 187 +#define SYS_processor_info 188 +#define SYS_p_online 189 +#define SYS_sigqueue 190 +#define SYS_clock_gettime 191 +#define SYS_clock_settime 192 +#define SYS_clock_getres 193 +#define SYS_timer_create 194 +#define SYS_timer_delete 195 +#define SYS_timer_settime 196 +#define SYS_timer_gettime 197 +#define SYS_timer_getoverrun 198 +#define SYS_nanosleep 199 +#define SYS_facl 200 +#define SYS_door 201 + /* + * Door Subcodes: + * 0 door_create + * 1 door_revoke + * 2 door_info + * 3 door_call + * 4 door_return + */ +#define SYS_setreuid 202 +#define SYS_setregid 203 +#define SYS_install_utrap 204 +#define SYS_signotify 205 +#define SYS_schedctl 206 +#define SYS_pset 207 +#define SYS_sparc_utrap_install 208 +#define SYS_resolvepath 209 +#define SYS_lwp_mutex_timedlock 210 +#define SYS_lwp_sema_timedwait 211 +#define SYS_lwp_rwlock_sys 212 + /* + * subcodes: + * lwp_rwlock_rdlock(...) :: syscall(212, 0, ...) + * lwp_rwlock_wrlock(...) :: syscall(212, 1, ...) + * lwp_rwlock_tryrdlock(...) :: syscall(212, 2, ...) + * lwp_rwlock_trywrlock(...) :: syscall(212, 3, ...) + * lwp_rwlock_unlock(...) :: syscall(212, 4, ...) + */ +/* system calls for large file ( > 2 gigabyte) support */ +#define SYS_getdents64 213 +#define SYS_mmap64 214 +#define SYS_stat64 215 +#define SYS_lstat64 216 +#define SYS_fstat64 217 +#define SYS_statvfs64 218 +#define SYS_fstatvfs64 219 +#define SYS_setrlimit64 220 +#define SYS_getrlimit64 221 +#define SYS_pread64 222 +#define SYS_pwrite64 223 +#define SYS_open64 225 +#define SYS_rpcsys 226 +#define SYS_zone 227 + /* + * subcodes: + * zone_create(...) :: zone(ZONE_CREATE, ...) + * zone_destroy(...) :: zone(ZONE_DESTROY, ...) + * zone_getattr(...) :: zone(ZONE_GETATTR, ...) + * zone_enter(...) :: zone(ZONE_ENTER, ...) + * zone_list(...) :: zone(ZONE_LIST, ...) + * zone_shutdown(...) :: zone(ZONE_SHUTDOWN, ...) + * zone_lookup(...) :: zone(ZONE_LOOKUP, ...) + * zone_boot(...) :: zone(ZONE_BOOT, ...) + * zone_version(...) :: zone(ZONE_VERSION, ...) + * zone_setattr(...) :: zone(ZONE_SETATTR, ...) + * zone_add_datalink(...) :: zone(ZONE_ADD_DATALINK, ...) + * zone_remove_datalink(...) :: zone(ZONE_DEL_DATALINK, ...) + * zone_check_datalink(...) :: zone(ZONE_CHECK_DATALINK, ...) + * zone_list_datalink(...) :: zone(ZONE_LIST_DATALINK, ...) + */ +#define SYS_autofssys 228 +#define SYS_getcwd 229 +#define SYS_so_socket 230 +#define SYS_so_socketpair 231 +#define SYS_bind 232 +#define SYS_listen 233 +#define SYS_accept 234 +#define SYS_connect 235 +#define SYS_shutdown 236 +#define SYS_recv 237 +#define SYS_recvfrom 238 +#define SYS_recvmsg 239 +#define SYS_send 240 +#define SYS_sendmsg 241 +#define SYS_sendto 242 +#define SYS_getpeername 243 +#define SYS_getsockname 244 +#define SYS_getsockopt 245 +#define SYS_setsockopt 246 +#define SYS_sockconfig 247 + /* + * NTP codes + */ +#define SYS_ntp_gettime 248 +#define SYS_ntp_adjtime 249 +#define SYS_lwp_mutex_unlock 250 +#define SYS_lwp_mutex_trylock 251 +#define SYS_lwp_mutex_register 252 +#define SYS_cladm 253 +#define SYS_uucopy 254 +#define SYS_umount2 255 + +#ifndef _ASM + +typedef struct { /* syscall set type */ + unsigned int word[16]; +} sysset_t; + +typedef struct { /* return values from system call */ + long sys_rval1; /* primary return value from system call */ + long sys_rval2; /* second return value from system call */ +} sysret_t; + +#if !defined(_KERNEL) + +extern long syscall(int, ...); +extern long __systemcall(sysret_t *, int, ...); +extern int __set_errno(int); + +#endif /* _KERNEL */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSCALL_H */ diff --git a/illumos-x86_64/usr/include/sys/sysconf.h b/illumos-x86_64/usr/include/sys/sysconf.h new file mode 100644 index 00000000..5c2d6972 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysconf.h @@ -0,0 +1,102 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * sysconf.h - include file for sysconf utility and the kernel. + */ + +#ifndef _SYS_SYSCONF_H +#define _SYS_SYSCONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * For each entry in /etc/system a sysparam record is created. + */ +struct sysparam { + struct sysparam *sys_next; /* pointer to next */ + int sys_type; /* type of record */ + int sys_op; /* operation */ + char *sys_modnam; /* module name (null if param in kernel) */ + char *sys_ptr; /* string pointer to device, etc. */ + u_longlong_t sys_info; /* additional information */ + char *sys_config; /* configuration data */ + int sys_len; /* len of config data */ + ulong_t *addrp; /* pointer to valloced config addresses */ + int sys_flags; /* flags to check duplicate entries */ +}; + +#define MAXLINESIZE 80 /* max size of a line in /etc/system */ + +struct modcmd { + char *mc_cmdname; + int mc_type; +}; + +#define MOD_EXCLUDE 0 /* we'll never load this one */ +#define MOD_INCLUDE 1 /* load on demand */ +#define MOD_FORCELOAD 2 /* load during initialization */ +#define MOD_ROOTDEV 3 /* root device */ +#define MOD_ROOTFS 4 /* root fs type */ +#define MOD_SWAPDEV 5 /* swap device */ +#define MOD_SWAPFS 6 /* swap fs type */ +#define MOD_MODDIR 7 /* default directory for modules */ +#define MOD_SET 8 /* set int to specified value */ +#define MOD_UNKNOWN 9 /* unknown command */ +#define MOD_SET32 10 /* like MOD_SET but -only- on 32-bit kernel */ +#define MOD_SET64 11 /* like MOD_SET but -only- on 64-bit kernel */ + +/* + * Commands for mod_sysctl() + */ +#define SYS_FORCELOAD 0 /* forceload modules */ +#define SYS_SET_KVAR 1 /* set kernel variables */ +#define SYS_SET_MVAR 2 /* set module variables */ +#define SYS_CHECK_EXCLUDE 3 /* check if a module is excluded */ + +/* + * Legal operations for MOD_SET. + */ +#define SETOP_NONE 0 /* no op - for types other than MOD_SET */ +#define SETOP_ASSIGN 1 /* '=' - simple assignment */ +#define SETOP_AND 2 /* '&' - bitwise AND */ +#define SETOP_OR 3 /* '|' - bitwise OR */ + +/* + * Defines for sys_flags. + */ +#define SYSPARAM_STR_TOKEN 0x0001 /* a string token is set */ +#define SYSPARAM_HEX_TOKEN 0x0002 /* a hexadecimal number is set */ +#define SYSPARAM_DEC_TOKEN 0x0004 /* a decimal number is set */ +#define SYSPARAM_DUP 0x0010 /* this entry is duplicated */ +#define SYSPARAM_TERM 0x0020 /* this entry is the last entry */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSCONF_H */ diff --git a/illumos-x86_64/usr/include/sys/sysconfig.h b/illumos-x86_64/usr/include/sys/sysconfig.h new file mode 100644 index 00000000..7e87d7a9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysconfig.h @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _SYS_SYSCONFIG_H +#define _SYS_SYSCONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +extern int mach_sysconfig(int); +#endif /* KERNEL */ + +/* + * cmd values for _sysconfig system call. + * WARNING: This is an undocumented system call, + * therefore future compatibility can not + * guaranteed. + */ + +#define UNUSED 1 +#define _CONFIG_NGROUPS 2 /* # configured supplemental groups */ +#define _CONFIG_CHILD_MAX 3 /* max # of processes per uid session */ +#define _CONFIG_OPEN_FILES 4 /* max # of open files per process */ +#define _CONFIG_POSIX_VER 5 /* POSIX version */ +#define _CONFIG_PAGESIZE 6 /* system page size */ +#define _CONFIG_CLK_TCK 7 /* ticks per second */ +#define _CONFIG_XOPEN_VER 8 + +/* + * NOTE: XOPEN VERSION. This is process dependent. The kernel will return + * the default value, currently 3. + */ + +#define _CONFIG_PROF_TCK 10 /* profiling ticks per second */ +#define _CONFIG_NPROC_CONF 11 /* processors configured */ +#define _CONFIG_NPROC_ONLN 12 /* processors online */ + +/* posix dot4 names */ +#define _CONFIG_AIO_LISTIO_MAX 13 /* # of operation in a list I/O call */ +#define _CONFIG_AIO_MAX 14 /* # of outstanding async I/O op. */ +#define _CONFIG_AIO_PRIO_DELTA_MAX 15 /* amount I/O priority decrease */ +#define _CONFIG_DELAYTIMER_MAX 16 /* timer timer expiration overruns */ +#define _CONFIG_MQ_OPEN_MAX 17 /* # message queues open per process */ +#define _CONFIG_MQ_PRIO_MAX 18 /* # of message priorities supported */ +#define _CONFIG_RTSIG_MAX 19 /* # of realtime signal numbers */ +#define _CONFIG_SEM_NSEMS_MAX 20 /* No. of semaphore per process */ +#define _CONFIG_SEM_VALUE_MAX 21 /* max. value a semaphore may have */ +#define _CONFIG_SIGQUEUE_MAX 22 /* # of pending queued signal */ +#define _CONFIG_SIGRT_MIN 23 /* first highest-pri realtime signal */ +#define _CONFIG_SIGRT_MAX 24 /* last realtime signal */ +#define _CONFIG_TIMER_MAX 25 /* # of timers per process */ + +#define _CONFIG_PHYS_PAGES 26 /* phys mem installed in pages */ +#define _CONFIG_AVPHYS_PAGES 27 /* available phys mem in pages */ +#define _CONFIG_COHERENCY 28 /* # bytes coherency */ +#define _CONFIG_SPLIT_CACHE 29 /* split i and d or not */ +#define _CONFIG_ICACHESZ 30 /* icache size in bytes */ +#define _CONFIG_DCACHESZ 31 /* dcache size in bytes */ +#define _CONFIG_ICACHELINESZ 32 /* linesize bytes */ +#define _CONFIG_DCACHELINESZ 33 /* linesize bytes */ +#define _CONFIG_ICACHEBLKSZ 34 /* block size bytes */ +#define _CONFIG_DCACHEBLKSZ 35 /* block size bytes */ +#define _CONFIG_DCACHETBLKSZ 36 /* block size bytes when touched */ +#define _CONFIG_ICACHE_ASSOC 37 /* associativity 1, 2, 3 whatever */ +#define _CONFIG_DCACHE_ASSOC 38 /* associativity 1, 2, 3 whatever */ +#define _CONFIG_MAXPID 42 /* highest PID available */ +#define _CONFIG_STACK_PROT 43 /* default stack protection */ +#define _CONFIG_NPROC_MAX 44 /* maximum # of processors possible */ +#define _CONFIG_CPUID_MAX 45 /* maximum CPU id */ + +/* UNIX 03 names */ +#define _CONFIG_SYMLOOP_MAX 46 /* maximum # of symlinks in pathname */ + +#define _CONFIG_EPHID_MAX 47 /* maximum ephemeral uid */ +#define _CONFIG_UADDR_MAX 48 /* maximum user address */ + +#define _CONFIG_NPROC_NCPU 49 /* NCPU (sometimes > NPROC_MAX) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSCONFIG_H */ diff --git a/illumos-x86_64/usr/include/sys/sysconfig_impl.h b/illumos-x86_64/usr/include/sys/sysconfig_impl.h new file mode 100644 index 00000000..2bc6be94 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysconfig_impl.h @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995,1999 by Sun Microsystems, Inc. + * All rights reserved. + */ +/* + * sysconfig_impl.h: + * + * platform-specific variables for the SUN private sysconfig syscall + * + */ + +#ifndef _SYS_SYSCONFIG_IMPL_H +#define _SYS_SYSCONFIG_IMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSCONFIG_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/sysdc.h b/illumos-x86_64/usr/include/sys/sysdc.h new file mode 100644 index 00000000..35d49aeb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysdc.h @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSDC_H +#define _SYS_SYSDC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct _kthread; + +#define SYSDC_THREAD_BATCH 0x1 /* thread does batch processing */ +extern void sysdc_thread_enter(struct _kthread *, uint_t, uint_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSDC_H */ diff --git a/illumos-x86_64/usr/include/sys/sysdc_impl.h b/illumos-x86_64/usr/include/sys/sysdc_impl.h new file mode 100644 index 00000000..bbc38143 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysdc_impl.h @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSDC_IMPL_H +#define _SYS_SYSDC_IMPL_H + +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct _kthread; +struct cpupart; + +/* + * Tracks per-processor-set information for SDC. Its main use is to + * implement per-processor-set breaks. + */ +typedef struct sysdc_pset { + list_node_t sdp_node; /* node on sysdc_psets list */ + struct cpupart *sdp_cpupart; /* associated cpu partition */ + size_t sdp_nthreads; /* reference count */ + + /* The remainder is only touched by sysdc_update() */ + hrtime_t sdp_onproc_time; /* time onproc at last update */ + boolean_t sdp_need_break; /* threads forced to minpri */ + uint_t sdp_should_break; /* # updates need_break is set */ + uint_t sdp_dont_break; /* after break, # updates until next */ + + /* debugging fields */ + uint_t sdp_onproc_threads; + hrtime_t sdp_vtime_last_interval; + uint_t sdp_DC_last_interval; +} sysdc_pset_t; + +/* + * Per-thread information, pointed to by t_cldata. + */ +typedef struct sysdc { + uint_t sdc_target_DC; /* target duty cycle */ + uint_t sdc_minpri; /* our minimum priority */ + uint_t sdc_maxpri; /* our maximum priority */ + + sysdc_pset_t *sdc_pset; /* the processor set bound to */ + + /* protected by sdl_lock */ + struct _kthread *sdc_thread; /* back-pointer, or NULL if freeable */ + + /* protected by arrangement between thread and sysdc_update() */ + struct sysdc *sdc_next; /* next in hash table, NULL if not in */ + + /* protected by thread_lock() */ + uint_t sdc_nupdates; /* number of sysdc_update_times() */ + + hrtime_t sdc_base_O; /* on-cpu time at last reset */ + hrtime_t sdc_base_R; /* runnable time at last reset */ + + uint_t sdc_sleep_updates; /* 0, or nupdates when we slept */ + clock_t sdc_ticks; /* sdc_tick() calls */ + clock_t sdc_update_ticks; /* value of ticks for forced update */ + clock_t sdc_pri_check; /* lbolt when we checked our priority */ + hrtime_t sdc_last_base_O; /* onproc time at sysdc_update() */ + + uint_t sdc_pri; /* our last computed priority */ + uint_t sdc_epri; /* our actual thread priority */ + + /* for debugging only */ + clock_t sdc_reset; /* lbolt when we reset our bases */ + hrtime_t sdc_cur_O; /* on-cpu time at last prio check */ + hrtime_t sdc_cur_R; /* runnable time at last prio check */ + hrtime_t sdc_last_O; /* onproc time at thread update */ + uint_t sdc_cur_DC; /* our actual duty cycle at last chk */ +} sysdc_t; + +/* + * Hash bucket of active SDC threads. + */ +typedef struct sysdc_list { + kmutex_t sdl_lock; /* lock keeping threads from exiting */ + sysdc_t *volatile sdl_list; /* list of active threads in bucket */ + char sdl_pad[64 - sizeof (kmutex_t) - sizeof (sysdc_t *)]; +} sysdc_list_t; + +/* + * Args to CL_ENTERCLASS(). + */ +typedef struct sysdc_params { + uint_t sdp_minpri; + uint_t sdp_maxpri; + uint_t sdp_DC; +} sysdc_params_t; + +/* + * Duty cycles are percentages in the range [1,100]. + */ +#define SYSDC_DC_MAX 100u /* 1 <= DC <= DC_MAX */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSDC_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent.h b/illumos-x86_64/usr/include/sys/sysevent.h new file mode 100644 index 00000000..c2be00ad --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent.h @@ -0,0 +1,279 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015 Joyent, Inc. + */ + +#ifndef _SYS_SYSEVENT_H +#define _SYS_SYSEVENT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Internal registration class and subclass */ +#define EC_ALL "register_all_classes" +#define EC_SUB_ALL "register_all_subclasses" + +/* + * Event allocation/enqueuing sleep/nosleep flags + */ +#define SE_SLEEP 0 +#define SE_NOSLEEP 1 + +/* Framework error codes */ +#define SE_EINVAL 1 /* Invalid argument */ +#define SE_ENOMEM 2 /* Unable to allocate memory */ +#define SE_EQSIZE 3 /* Maximum event q size exceeded */ +#define SE_EFAULT 4 /* Copy fault */ +#define SE_NOTFOUND 5 /* Attribute not found */ +#define SE_NO_TRANSPORT 6 /* sysevent transport down */ + +/* Internal data types */ + +#define SE_DATA_TYPE_BYTE DATA_TYPE_BYTE +#define SE_DATA_TYPE_INT16 DATA_TYPE_INT16 +#define SE_DATA_TYPE_UINT16 DATA_TYPE_UINT16 +#define SE_DATA_TYPE_INT32 DATA_TYPE_INT32 +#define SE_DATA_TYPE_UINT32 DATA_TYPE_UINT32 +#define SE_DATA_TYPE_INT64 DATA_TYPE_INT64 +#define SE_DATA_TYPE_UINT64 DATA_TYPE_UINT64 +#define SE_DATA_TYPE_STRING DATA_TYPE_STRING +#define SE_DATA_TYPE_BYTES DATA_TYPE_BYTE_ARRAY +#define SE_DATA_TYPE_TIME DATA_TYPE_HRTIME + +#define SE_KERN_PID 0 + +#define SUNW_VENDOR "SUNW" +#define ILLUMOS_VENDOR "ILLUMOS" +#define SE_USR_PUB "usr:" +#define SE_KERN_PUB "kern:" +#define SUNW_KERN_PUB SUNW_VENDOR ":" SE_KERN_PUB +#define SUNW_USR_PUB SUNW_VENDOR ":" SE_USR_PUB +#define ILLUMOS_KERN_PUB ILLUMOS_VENDOR ":" SE_KERN_PUB + +/* + * Event header and attribute value limits + */ +#define MAX_ATTR_NAME 1024 +#define MAX_STRING_SZ 1024 +#define MAX_BYTE_ARRAY 1024 + +#define MAX_CLASS_LEN 64 +#define MAX_SUBCLASS_LEN 64 +#define MAX_PUB_LEN 128 +#define MAX_CHNAME_LEN 128 +#define MAX_SUBID_LEN 16 + +/* + * Limit for the event payload size + */ +#define MAX_EV_SIZE_LEN (SHRT_MAX/4) + +/* Opaque sysevent_t data type */ +typedef void *sysevent_t; + +/* Opaque channel bind data type */ +typedef void evchan_t; + +/* sysevent attribute list */ +typedef nvlist_t sysevent_attr_list_t; + +/* sysevent attribute name-value pair */ +typedef nvpair_t sysevent_attr_t; + +/* Unique event identifier */ +typedef struct sysevent_id { + uint64_t eid_seq; + hrtime_t eid_ts; +} sysevent_id_t; + +/* Event attribute value structures */ +typedef struct sysevent_bytes { + int32_t size; + uchar_t *data; +} sysevent_bytes_t; + +typedef struct sysevent_value { + int32_t value_type; /* data type */ + union { + uchar_t sv_byte; + int16_t sv_int16; + uint16_t sv_uint16; + int32_t sv_int32; + uint32_t sv_uint32; + int64_t sv_int64; + uint64_t sv_uint64; + hrtime_t sv_time; + char *sv_string; + sysevent_bytes_t sv_bytes; + } value; +} sysevent_value_t; + +/* + * The following flags determine the memory allocation semantics to use for + * kernel event buffer allocation by userland and kernel versions of + * sysevent_evc_publish(). + * + * EVCH_SLEEP and EVCH_NOSLEEP respectively map to KM_SLEEP and KM_NOSLEEP. + * EVCH_TRYHARD is a kernel-only publish flag that allow event allocation + * routines to use use alternate kmem caches in situations where free memory + * may be low. Kernel callers of sysevent_evc_publish() must set flags to + * one of EVCH_SLEEP, EVCH_NOSLEEP or EVCH_TRYHARD. Userland callers of + * sysevent_evc_publish() must set flags to one of EVCH_SLEEP or EVCH_NOSLEEP. + * + * EVCH_QWAIT determines whether or not we should wait for slots in the event + * queue at publication time. EVCH_QWAIT may be used by kernel and userland + * publishers and must be used in conjunction with any of one of EVCH_SLEEP, + * EVCH_NOSLEEP or EVCH_TRYHARD (kernel-only). + */ + +#define EVCH_NOSLEEP 0x0001 /* No sleep on kmem_alloc() */ +#define EVCH_SLEEP 0x0002 /* Sleep on kmem_alloc() */ +#define EVCH_TRYHARD 0x0004 /* May use alternate kmem cache for alloc */ +#define EVCH_QWAIT 0x0008 /* Wait for slot in event queue */ + +/* + * Meaning of flags for subscribe. Bits 8 to 15 are dedicated to + * the consolidation private interface, so flags defined here are restricted + * to the LSB. + * + * EVCH_SUB_KEEP indicates that this subscription should persist even if + * this subscriber id should die unexpectedly; matching events will be + * queued (up to a limit) and will be delivered if/when we restart again + * with the same subscriber id. + */ +#define EVCH_SUB_KEEP 0x01 + +/* + * Subscriptions may be wildcarded, but we limit the number of + * wildcards permitted. + */ +#define EVCH_WILDCARD_MAX 10 + +/* + * Used in unsubscribe to indicate all subscriber ids for a channel. + */ +#define EVCH_ALLSUB "all_subs" + +/* + * Meaning of flags parameter of channel bind function + * + * EVCH_CREAT indicates to create a channel if not already present. + * + * EVCH_HOLD_PEND indicates that events should be published to this + * channel even if there are no matching subscribers present; when + * a subscriber belatedly binds to the channel and registers their + * subscriptions they will receive events that predate their bind. + * If the channel is closed, however, with no remaining bindings then + * the channel is destroyed. + * + * EVCH_HOLD_PEND_INDEF is a stronger version of EVCH_HOLD_PEND - + * even if the channel has no remaining bindings it will not be + * destroyed so long as events remain unconsumed. This is suitable for + * use with short-lived event producers that may bind to (create) the + * channel and exit before the intended consumer has started. + */ +#define EVCH_CREAT 0x0001 +#define EVCH_HOLD_PEND 0x0002 +#define EVCH_HOLD_PEND_INDEF 0x0004 +#define EVCH_B_FLAGS 0x0007 /* All valid bits */ + +/* + * Meaning of commands of evc_control function + */ +#define EVCH_GET_CHAN_LEN_MAX 1 /* Get event queue length limit */ +#define EVCH_GET_CHAN_LEN 2 /* Get event queue length */ +#define EVCH_SET_CHAN_LEN 3 /* Set event queue length */ +#define EVCH_CMD_LAST EVCH_SET_CHAN_LEN /* Last command */ + +/* + * Shared user/kernel event channel interface definitions + */ +extern int sysevent_evc_bind(const char *, evchan_t **, uint32_t); +extern int sysevent_evc_unbind(evchan_t *); +extern int sysevent_evc_subscribe(evchan_t *, const char *, const char *, + int (*)(sysevent_t *, void *), void *, uint32_t); +extern int sysevent_evc_unsubscribe(evchan_t *, const char *); +extern int sysevent_evc_publish(evchan_t *, const char *, const char *, + const char *, const char *, nvlist_t *, uint32_t); +extern int sysevent_evc_control(evchan_t *, int, ...); +extern int sysevent_evc_setpropnvl(evchan_t *, nvlist_t *); +extern int sysevent_evc_getpropnvl(evchan_t *, nvlist_t **); + +#ifndef _KERNEL + +/* + * Userland-only event channel interfaces + */ + +#include + +typedef struct sysevent_subattr sysevent_subattr_t; + +extern sysevent_subattr_t *sysevent_subattr_alloc(void); +extern void sysevent_subattr_free(sysevent_subattr_t *); + +extern void sysevent_subattr_thrattr(sysevent_subattr_t *, pthread_attr_t *); +extern void sysevent_subattr_sigmask(sysevent_subattr_t *, sigset_t *); + +extern void sysevent_subattr_thrcreate(sysevent_subattr_t *, + door_xcreate_server_func_t *, void *); +extern void sysevent_subattr_thrsetup(sysevent_subattr_t *, + door_xcreate_thrsetup_func_t *, void *); + +extern int sysevent_evc_xsubscribe(evchan_t *, const char *, const char *, + int (*)(sysevent_t *, void *), void *, uint32_t, sysevent_subattr_t *); + +#else + +/* + * Kernel log_event interfaces. + */ +extern int log_sysevent(sysevent_t *, int, sysevent_id_t *); + +extern sysevent_t *sysevent_alloc(char *, char *, char *, int); +extern void sysevent_free(sysevent_t *); +extern int sysevent_add_attr(sysevent_attr_list_t **, char *, + sysevent_value_t *, int); +extern void sysevent_free_attr(sysevent_attr_list_t *); +extern int sysevent_attach_attributes(sysevent_t *, sysevent_attr_list_t *); +extern void sysevent_detach_attributes(sysevent_t *); +extern char *sysevent_get_class_name(sysevent_t *); +extern char *sysevent_get_subclass_name(sysevent_t *); +extern uint64_t sysevent_get_seq(sysevent_t *); +extern void sysevent_get_time(sysevent_t *, hrtime_t *); +extern size_t sysevent_get_size(sysevent_t *); +extern char *sysevent_get_pub(sysevent_t *); +extern int sysevent_get_attr_list(sysevent_t *, nvlist_t **); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/datalink.h b/illumos-x86_64/usr/include/sys/sysevent/datalink.h new file mode 100644 index 00000000..90fb9267 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/datalink.h @@ -0,0 +1,54 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2015 Joyent, Inc. + */ + +#ifndef _SYS_SYSEVENT_DATALINK_H +#define _SYS_SYSEVENT_DATALINK_H + +/* + * Datalink System Event payloads + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Event schema for EC_DATALINK_LINK_STATE + * + * Event Class - EC_DATALINK + * Event Sub-Class - EC_DATALINK_LINK_STATE + * + * Attribute Name - DATALINK_EV_LINK_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Name of the datalink] + * + * Attribute Name - DATALINK_EV_LINK_ID + * Attribute Type - SE_DATA_TYPE_INT32 + * Attribute Value - [datalink_id_t for the device] + * + * Attribute Name - DATALINK_EV_ZONE_ID + * Attribute Type - SE_DATA_TYPE_INT32 + * Attribute Value - [zoneid_t of the zone the datalink is in] + */ + +#define DATALINK_EV_LINK_NAME "link" +#define DATALINK_EV_LINK_ID "linkid" +#define DATALINK_EV_ZONE_ID "zone" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_DATALINK_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/dev.h b/illumos-x86_64/usr/include/sys/sysevent/dev.h new file mode 100644 index 00000000..9f9c2b59 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/dev.h @@ -0,0 +1,254 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSEVENT_DEV_H +#define _SYS_SYSEVENT_DEV_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Event schema for EC_DEV_ADD/ESC_DISK + * + * Event Class - EC_DEV_ADD + * Event Sub-Class - ESC_DISK + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - /dev name to the raw device. + * The name does not include the slice number component. + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path of the device without the "/devices" + * prefix. + * + * Attribute Name - DEV_DRIVER_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - driver name + * + * Attribute Name - DEV_INSTANCE + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - driver instance number + * + * Attribute Name - DEV_PROP_PREFIX + * Attribute Type - data type of the devinfo_node_property + * Attribute Value - value of the devinfo_node_property + * + * + * Event schema for EC_DEV_ADD/ESC_NETWORK + * + * Event Class - EC_DEV_ADD + * Event Sub-Class - ESC_NETWORK + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - /dev name associated with the device if exists. + * /dev name associated with the driver for DLPI + * Style-2 only drivers. + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path of the device without the "/devices" + * prefix. + * + * Attribute Name - DEV_DRIVER_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - driver name + * + * Attribute Name - DEV_INSTANCE + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - driver instance number + * + * Attribute Name - DEV_PROP_PREFIX + * Attribute Type - data type of the devinfo_node_property + * Attribute Value - value of the devinfo_node_property + * + * + * Event schema for EC_DEV_ADD/ESC_PRINTER + * + * Event Class - EC_DEV_ADD + * Event Sub-Class - ESC_PRINTER + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - /dev/printers name associated with the device + * if exists. + * /dev name associated with the device if it exists + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path of the device without the "/devices" + * prefix. + * + * Attribute Name - DEV_DRIVER_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - driver name + * + * Attribute Name - DEV_INSTANCE + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - driver instance number + * + * Attribute Name - DEV_PROP_PREFIX + * Attribute Type - data type of the devinfo_node_property + * Attribute Value - value of the devinfo_node_property + * + * + * Event schema for EC_DEV_REMOVE/ESC_DISK + * + * Event Class - EC_DEV_REMOVE + * Event Sub-Class - ESC_DISK + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - /dev name to the raw device. + * The name does not include the slice number component. + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path of the device without the "/devices" + * prefix. + * + * Attribute Name - DEV_DRIVER_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - driver name + * + * Attribute Name - DEV_INSTANCE + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - driver instance number + * + * + * Event schema for EC_DEV_REMOVE/ESC_NETWORK + * + * Event Class - EC_DEV_REMOVE + * Event Sub-Class - ESC_NETWORK + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - /dev name associated with the device if exists. + * /dev name associated with the driver for DLPI + * Style-2 only drivers. + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path of the device without the "/devices" + * prefix. + * + * Attribute Name - DEV_DRIVER_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - driver name + * + * Attribute Name - DEV_INSTANCE + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - driver instance number + * + * + * Event schema for EC_DEV_REMOVE/ESC_PRINTER + * + * Event Class - EC_DEV_REMOVE + * Event Sub-Class - ESC_PRINTER + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - /dev/printers name associated with the device + * if exists. + * /dev name associated with the device if it exists + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path of the device without the "/devices" + * prefix. + * + * Attribute Name - DEV_DRIVER_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - driver name + * + * Attribute Name - DEV_INSTANCE + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - driver instance number + * + * + * Event schema for EC_DEV_BRANCH/ESC_DEV_BRANCH_ADD or ESC_DEV_BRANCH_REMOVE + * + * Event Class - EC_DEV_BRANCH + * Event Sub-Class - ESC_DEV_BRANCH_ADD or ESC_DEV_BRANCH_REMOVE + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path to the root node of the device subtree + * without the "/devices" prefix. + */ + +#define EV_VERSION "version" +#define DEV_PHYS_PATH "phys_path" +#define DEV_NAME "dev_name" +#define DEV_DRIVER_NAME "driver_name" +#define DEV_INSTANCE "instance" +#define DEV_PROP_PREFIX "prop-" + +#define EV_V1 1 + +/* maximum number of devinfo node properties added to the event */ +#define MAX_PROP_COUNT 100 + +/* only properties with size less than PROP_LEN_LIMIT are added to the event */ +#define PROP_LEN_LIMIT 1024 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_DEV_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/domain.h b/illumos-x86_64/usr/include/sys/sysevent/domain.h new file mode 100644 index 00000000..e6e4f2a0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/domain.h @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2000-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSEVENT_DOMAIN_H +#define _SYS_SYSEVENT_DOMAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Event type EC_DOMAIN/ESC_DOMAIN_STATE_CHANGE schema + * Event Class - EC_DOMAIN + * Event Sub-Class - ESC_DOMAIN_STATE_CHANGE + * Event Publisher - SUNW:kern:[domain env monitor] + * Attribute Name - DOMAIN_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - [version of the schema] + * Attribute Name - DOMAIN_WHAT_CHANGED + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - DOMAIN_RESERVED_ATTR | DOMAIN_KEYSWITCH | DOMAIN_FRU + */ +#define DOMAIN_VERSION "domain_version" +#define DOMAIN_WHAT_CHANGED "domain_what_changed" +#define DOMAIN_KEYSWITCH "domain_keyswitch" +#define DOMAIN_FRU "domain_fru" +#define DOMAIN_RESERVED_ATTR "" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_DOMAIN_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/dr.h b/illumos-x86_64/usr/include/sys/sysevent/dr.h new file mode 100644 index 00000000..a26306f8 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/dr.h @@ -0,0 +1,109 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSEVENT_DR_H +#define _SYS_SYSEVENT_DR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * dr.h contains the publicly defined sysevent attribute names and values + * for all DR type sysevents. Additions/removals/changes are subject to + * PSARC approval. + */ + +/* + * Event type EC_DR/ESC_DR_AP_STATE_CHANGE event schema + * Event Class - EC_DR + * Event Sub-Class - ESC_DR_AP_STATE_CHANGE + * Event Publisher - SUNW:kern:[dr_subsystem_name] + * Attribute Name - DR_AP_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Attachment Point Identifier] + * Attribute Name - DR_HINT + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - DR_RESERVED_ATTR | DR_HINT_INSERT | DR_HINT_REMOVE + */ +#define DR_AP_ID "dr_ap_id" /* Attachment point id */ +#define DR_HINT "dr_hint" /* Operation hint */ +#define DR_HINT_INSERT "dr_insert" /* Insert hint */ +#define DR_HINT_REMOVE "dr_remove" /* Remove hint */ +#define DR_RESERVED_ATTR "" + +/* + * Useful macros for insert/remove event. + */ +#define SE_NO_HINT 0x0 +#define SE_HINT_INSERT 0x1 +#define SE_HINT_REMOVE 0x2 +#define SE_HINT2STR(h) ((h) == SE_HINT_INSERT ? DR_HINT_INSERT : \ + (h) == SE_HINT_REMOVE ? DR_HINT_REMOVE : \ + DR_RESERVED_ATTR) +/* + * Event type EC_DR/ESC_DR_REQ event schema + * Event Class - EC_DR + * Event Sub-Class - ESC_DR_REQ + * Event Publisher - SUNW:kern:[dr_subsystem_name] + * Attribute Name - DR_AP_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Attachment Point Name] + * Attribute Name - DR_REQ_TYPE + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - DR_RESERVED_ATTR | DR_REQ_INCOMING_RES | + * DR_REQ_OUTGOING_RES | DR_REQ_INVESTIGATE_RES + */ +#define DR_REQ_TYPE "dr_request_type" /* User request type */ +#define DR_REQ_INCOMING_RES "dr_request_incoming_resource" +#define DR_REQ_OUTGOING_RES "dr_request_outgoing_resource" +#define DR_REQ_INVESTIGATE_RES "dr_request_investigate_resource" + +#define SE_INVESTIGATE_RES 0x0 +#define SE_INCOMING_RES 0x1 +#define SE_OUTGOING_RES 0x2 +#define SE_REQ2STR(h) ((h) == SE_INCOMING_RES ? \ + DR_REQ_INCOMING_RES : \ + (h) == SE_OUTGOING_RES ? \ + DR_REQ_OUTGOING_RES : \ + DR_REQ_INVESTIGATE_RES) +/* + * Event Class - EC_DR + * Event Sub-Class - ESC_DR_TARGET_STATE_CHANGE + * Event Publisher - SUNW:kern: + * Attribute Name - DR_TARGET_ID + * Attribute Type - [SE_DATA_TYPE_STRING] + * Attribute Value - + * Attribute Name - DR_HINT + * Attribute Type - [SE_DATA_TYPE_STRING] + * Attribute Value - DR_RESERVED_ATTR | DR_HINT_INSERT | DR_HINT_REMOVE + */ +#define DR_TARGET_ID "dr_target_id" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_DR_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/env.h b/illumos-x86_64/usr/include/sys/sysevent/env.h new file mode 100644 index 00000000..b0d75de2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/env.h @@ -0,0 +1,167 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2000-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSEVENT_ENV_H +#define _SYS_SYSEVENT_ENV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Event type EC_ENV/ESC_ENV_TEMP schema + * Event Class - EC_ENV + * Event Sub-Class - ESC_ENV_TEMP + * Event Publisher - SUNW:kern:[environmental monitor name] + * Attribute Name - ENV_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - [version of the schema] + * Attribute Name - ENV_FRU_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the FRU or SE_RESERVED_ATTR] + * Attribute Name - ENV_FRU_RESOURCE_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the Resource within the FRU or + * SE_RESERVED_ATTR] + * Attribute Name - ENV_FRU_DEVICE + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - ENV_RESERVED_ATTR + * Attribute Name - ENV_FRU_STATE + * Attribute Type - SE_DATA_TYPE_INT32 + * Attribute Value - ENV_OK | ENV_WARNING | ENV_FAILED + * Attribute Name - ENV_MSG + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [message passed by environmental monitor] + */ + +#define ENV_VERSION "env_version" /* version of the schema */ +#define ENV_FRU_ID "env_fru_id" /* PICL FRU name */ +#define ENV_FRU_RESOURCE_ID "env_fru_resource_id" /* FRU resource name */ +#define ENV_FRU_DEVICE "env_fru_device_path" /* Device path of sensor */ +#define ENV_FRU_STATE "env_fru_state" /* State of FRU */ +#define ENV_MSG "env_msg" /* environmental montitor msg */ +#define ENV_RESERVED_ATTR "" /* Reserved attribute */ + +/* + * Event type EC_ENV/ESC_ENV_POWER schema + * Event Class - EC_ENV + * Event Sub-Class - ESC_ENV_POWER + * Event Publisher - SUNW:kern:[environmental monitor name] + * Attribute Name - ENV_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - [version of the schema] + * Attribute Name - ENV_FRU_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the FRU or SE_RESERVED_ATTR] + * Attribute Name - ENV_FRU_RESOURCE_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the Resource within the FRU or + * SE_RESERVED_ATTR] + * Attribute Name - ENV_FRU_DEVICE + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - ENV_RESERVED_ATTR + * Attribute Name - ENV_FRU_STATE + * Attribute Type - SE_DATA_TYPE_INT32 + * Attribute Value - ENV_OK | ENV_WARNING | ENV_FAILED + * Attribute Name - ENV_MSG + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [message passed by environmental monitor] + * + * + * + * Event type EC_ENV/ESC_ENV_FAN event schema + * Event Class - EC_ENV + * Event Sub-Class - ESC_ENV_FAN + * Event Publisher - SUNW:kern:[environmental monitor name] + * Attribute Name - ENV_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - [version of the schema] + * Attribute Name - ENV_FRU_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the FRU or SE_RESERVED_ATTR] + * Attribute Name - ENV_FRU_RESOURCE_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the Resource within the FRU or + * SE_RESERVED_ATTR] + * Attribute Name - ENV_FRU_DEVICE + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - ENV_RESERVED_ATTR + * Attribute Name - ENV_FRU_STATE + * Attribute Type - SE_DATA_TYPE_INT32 + * Attribute Value - ENV_OK | ENV_WARNING | ENV_FAILED + * Attribute Name - ENV_MSG + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [message passed by environmental monitor] + */ + +#define ENV_OK 1 +#define ENV_WARNING 2 +#define ENV_FAILED 3 + +/* + * Event type EC_ENV/ESC_ENV_LED event schema + * Event Class - EC_ENV + * Event Sub-Class - ESC_ENV_LED + * Event Publisher - SUNW:kern:[environmental monitor name] + * Attribute Name - ENV_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - [version of the schema] + * Attribute Name - ENV_FRU_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the FRU or SE_RESERVED_ATTR] + * Attribute Name - ENV_FRU_RESOURCE_ID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the Resource within the FRU or + * SE_RESERVED_ATTR] + * Attribute Name - ENV_FRU_DEVICE + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - ENV_RESERVED_ATTR + * Attribute Name - ENV_LED_COLOR + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - ENV_RESERVED_ATTR + * Attribute Name - ENV_FRU_STATE + * Attribute Type - SE_DATA_TYPE_INT32 + * Attribute Value - ENV_LED_ON | ENV_LED_OFF | ENV_LED_BLINKING | + * ENV_LED_FLASHING | ENV_LED_INACCESSIBLE | + * ENV_LED_STANDBY | ENV_LED_NOT_PRESENT + * Attribute Name - ENV_MSG + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [message passed by environmental monitor] + */ + +#define ENV_LED_ON 1 +#define ENV_LED_OFF 2 +#define ENV_LED_BLINKING 3 +#define ENV_LED_FLASHING 4 +#define ENV_LED_INACCESSIBLE 5 +#define ENV_LED_STANDBY 6 +#define ENV_LED_NOT_PRESENT 7 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_ENV_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/eventdefs.h b/illumos-x86_64/usr/include/sys/sysevent/eventdefs.h new file mode 100644 index 00000000..c9f2bbac --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/eventdefs.h @@ -0,0 +1,230 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. + * Copyright 2019 Joyent, Inc. + * Copyright 2022 Garrett D'Amore + */ + +#ifndef _SYS_SYSEVENT_EVENTDEFS_H +#define _SYS_SYSEVENT_EVENTDEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * eventdefs.h contains public definitions for sysevent types (classes + * and subclasses). All additions/removal/changes are subject + * to PSARC approval. + */ + +/* Sysevent Class definitions */ +#define EC_NONE "EC_none" +#define EC_PRIV "EC_priv" +#define EC_PLATFORM "EC_platform" /* events private to platform */ +#define EC_DR "EC_dr" /* Dynamic reconfiguration event class */ +#define EC_ENV "EC_env" /* Environmental monitor event class */ +#define EC_DOMAIN "EC_domain" /* Domain event class */ +#define EC_IPMP "EC_ipmp" /* IP Multipathing event class */ +#define EC_DEV_ADD "EC_dev_add" /* device add event class */ +#define EC_DEV_REMOVE "EC_dev_remove" /* device remove event class */ +#define EC_DEV_BRANCH "EC_dev_branch" /* device tree branch event class */ +#define EC_DEV_STATUS "EC_dev_status" /* device status event class */ +#define EC_FM "EC_fm" /* FMA error report event */ +#define EC_ZFS "EC_zfs" /* ZFS event */ +#define EC_DATALINK "EC_datalink" /* datalink event */ +#define EC_VRRP "EC_vrrp" /* VRRP event */ +#define EC_PCIE "EC_pcie" /* PCIe event */ + +/* + * The following event class is reserved for exclusive use + * by Sun Cluster software. + */ +#define EC_CLUSTER "EC_Cluster" + +/* + * EC_DR subclass definitions - supporting attributes (name/value pairs) + * are found in sys/sysevent/dr.h + */ + +/* Attachment point state change */ +#define ESC_DR_AP_STATE_CHANGE "ESC_dr_ap_state_change" +#define ESC_DR_REQ "ESC_dr_req" /* Request DR */ +#define ESC_DR_TARGET_STATE_CHANGE "ESC_dr_target_state_change" + +/* + * EC_ENV subclass definitions - supporting attributes (name/value pairs) + * are found in sys/sysevent/env.h + */ +#define ESC_ENV_TEMP "ESC_env_temp" /* Temperature change event subclass */ +#define ESC_ENV_FAN "ESC_env_fan" /* Fan status change event subclass */ +#define ESC_ENV_POWER "ESC_env_power" /* Power supply change event subclass */ +#define ESC_ENV_LED "ESC_env_led" /* LED change event subclass */ + +/* + * EC_DOMAIN subclass definitions - supporting attributes (name/value pairs) + * are found in sys/sysevent/domain.h + */ + +/* Domain state change */ +#define ESC_DOMAIN_STATE_CHANGE "ESC_domain_state_change" +/* Domain loghost name change */ +#define ESC_DOMAIN_LOGHOST_CHANGE "ESC_domain_loghost_change" + +/* + * EC_IPMP subclass definitions - supporting attributes (name/value pairs) + * are found in sys/sysevent/ipmp.h + */ + +/* IPMP group has changed state */ +#define ESC_IPMP_GROUP_STATE "ESC_ipmp_group_state" + +/* IPMP group has been created or removed */ +#define ESC_IPMP_GROUP_CHANGE "ESC_ipmp_group_change" + +/* IPMP group has had an interface added or removed */ +#define ESC_IPMP_GROUP_MEMBER_CHANGE "ESC_ipmp_group_member_change" + +/* Interface within an IPMP group has changed state or type */ +#define ESC_IPMP_IF_CHANGE "ESC_ipmp_if_change" + +/* IPMP probe has changed state */ +#define ESC_IPMP_PROBE_STATE "ESC_ipmp_probe_state" + +/* + * EC_DEV_ADD and EC_DEV_REMOVE subclass definitions - supporting attributes + * (name/value pairs) are found in sys/sysevent/dev.h + */ +#define ESC_DISK "disk" /* disk device */ +#define ESC_NETWORK "network" /* network interface */ +#define ESC_PRINTER "printer" /* printer device */ +#define ESC_LOFI "lofi" /* lofi device */ + +/* + * EC_DEV_BRANCH subclass definitions - supporting attributes (name/value pairs) + * are found in sys/sysevent/dev.h + */ + +/* device tree branch added */ +#define ESC_DEV_BRANCH_ADD "ESC_dev_branch_add" + +/* device tree branch removed */ +#define ESC_DEV_BRANCH_REMOVE "ESC_dev_branch_remove" + +/* + * EC_DEV_STATUS subclass definitions + * + * device capacity dynamically changed + */ +#define ESC_DEV_DLE "ESC_dev_dle" + +/* LUN has received an eject request from the user */ +#define ESC_DEV_EJECT_REQUEST "ESC_dev_eject_request" + +/* FMA Fault and Error event protocol subclass */ +#define ESC_FM_ERROR "ESC_FM_error" +#define ESC_FM_ERROR_REPLAY "ESC_FM_error_replay" + +/* Service processor subclass definitions */ +#define ESC_PLATFORM_SP_RESET "ESC_platform_sp_reset" + +/* + * EC_PWRCTL subclass definitions + */ +#define EC_PWRCTL "EC_pwrctl" +#define ESC_PWRCTL_ADD "ESC_pwrctl_add" +#define ESC_PWRCTL_REMOVE "ESC_pwrctl_remove" +#define ESC_PWRCTL_WARN "ESC_pwrctl_warn" +#define ESC_PWRCTL_LOW "ESC_pwrctl_low" +#define ESC_PWRCTL_STATE_CHANGE "ESC_pwrctl_state_change" +#define ESC_PWRCTL_POWER_BUTTON "ESC_pwrctl_power_button" +#define ESC_PWRCTL_BRIGHTNESS_UP "ESC_pwrctl_brightness_up" +#define ESC_PWRCTL_BRIGHTNESS_DOWN "ESC_pwrctl_brightness_down" + +/* EC_ACPIEV subclass definitions */ +#define EC_ACPIEV "EC_acpiev" +#define ESC_ACPIEV_DISPLAY_SWITCH "ESC_acpiev_display_switch" +#define ESC_ACPIEV_SCREEN_LOCK "ESC_acpiev_screen_lock" +#define ESC_ACPIEV_SLEEP "ESC_acpiev_sleep" +#define ESC_ACPIEV_AUDIO_MUTE "ESC_acpiev_audio_mute" +#define ESC_ACPIEV_WIFI "ESC_acpiev_wifi" +#define ESC_ACPIEV_TOUCHPAD "ESC_acpiev_touchpad" + +/* + * ZFS subclass definitions. supporting attributes (name/value paris) are found + * in sys/fs/zfs.h + */ +#define ESC_ZFS_RESILVER_START "ESC_ZFS_resilver_start" +#define ESC_ZFS_RESILVER_FINISH "ESC_ZFS_resilver_finish" +#define ESC_ZFS_VDEV_REMOVE "ESC_ZFS_vdev_remove" +#define ESC_ZFS_VDEV_REMOVE_AUX "ESC_ZFS_vdev_remove_aux" +#define ESC_ZFS_VDEV_REMOVE_DEV "ESC_ZFS_vdev_remove_dev" +#define ESC_ZFS_POOL_CREATE "ESC_ZFS_pool_create" +#define ESC_ZFS_POOL_DESTROY "ESC_ZFS_pool_destroy" +#define ESC_ZFS_POOL_IMPORT "ESC_ZFS_pool_import" +#define ESC_ZFS_VDEV_ADD "ESC_ZFS_vdev_add" +#define ESC_ZFS_VDEV_ATTACH "ESC_ZFS_vdev_attach" +#define ESC_ZFS_VDEV_CLEAR "ESC_ZFS_vdev_clear" +#define ESC_ZFS_VDEV_CHECK "ESC_ZFS_vdev_check" +#define ESC_ZFS_VDEV_ONLINE "ESC_ZFS_vdev_online" +#define ESC_ZFS_CONFIG_SYNC "ESC_ZFS_config_sync" +#define ESC_ZFS_SCRUB_START "ESC_ZFS_scrub_start" +#define ESC_ZFS_SCRUB_FINISH "ESC_ZFS_scrub_finish" +#define ESC_ZFS_SCRUB_ABORT "ESC_ZFS_scrub_abort" +#define ESC_ZFS_SCRUB_RESUME "ESC_ZFS_scrub_resume" +#define ESC_ZFS_SCRUB_PAUSED "ESC_ZFS_scrub_paused" +#define ESC_ZFS_VDEV_SPARE "ESC_ZFS_vdev_spare" +#define ESC_ZFS_BOOTFS_VDEV_ATTACH "ESC_ZFS_bootfs_vdev_attach" +#define ESC_ZFS_POOL_REGUID "ESC_ZFS_pool_reguid" +#define ESC_ZFS_HISTORY_EVENT "ESC_ZFS_history_event" +#define ESC_ZFS_TRIM_START "ESC_ZFS_trim_start" +#define ESC_ZFS_TRIM_FINISH "ESC_ZFS_trim_finish" +#define ESC_ZFS_TRIM_CANCEL "ESC_ZFS_trim_cancel" +#define ESC_ZFS_TRIM_RESUME "ESC_ZFS_trim_resume" +#define ESC_ZFS_TRIM_SUSPEND "ESC_ZFS_trim_suspend" + +/* + * datalink subclass definitions. Supporting attributes for datalink state found + * in sys/sysevent/datalink.h. + */ +#define ESC_DATALINK_PHYS_ADD "ESC_datalink_phys_add" /* new physical link */ +#define ESC_DATALINK_LINK_STATE "ESC_datalink_link_state" /* link state */ + +/* + * VRRP subclass definitions. Supporting attributes (name/value paris) are + * found in sys/sysevent/vrrp.h + */ +#define ESC_VRRP_STATE_CHANGE "ESC_vrrp_state_change" + +/* + * PCIe subclass definitions. Supporting attributes for PCIe state found in + * sys/sysevent/pcie.h. + */ +#define ESC_PCIE_LINK_STATE "ESC_pcie_link_state" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_EVENTDEFS_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/ipmp.h b/illumos-x86_64/usr/include/sys/sysevent/ipmp.h new file mode 100644 index 00000000..ba39a5bb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/ipmp.h @@ -0,0 +1,279 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSEVENT_IPMP_H +#define _SYS_SYSEVENT_IPMP_H + +/* + * IPMP sysevent definitions. Note that all of these definitions are + * Sun-private and are subject to change at any time. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Event channel associated with these events + */ +#define IPMP_EVENT_CHAN "com.sun:ipmp:events" + +/* + * Event type EC_IPMP/ESC_IPMP_GROUP_STATE event schema + * + * Event Class - EC_IPMP + * Event Sub-Class - ESC_IPMP_GROUP_STATE + * Event Vendor - com.sun + * Event Publisher - in.mpathd + * + * Attribute Name - IPMP_EVENT_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_GROUP_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - + * + * Attribute Name - IPMP_GROUP_SIGNATURE + * Attribute Type - SE_DATA_TYPE_UINT64 + * Attribute Value - + * + * Attribute Name - IPMP_GROUP_STATE + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + */ + +#define IPMP_EVENT_VERSION "ipmp_event_version" +#define IPMP_GROUP_NAME "ipmp_group_name" +#define IPMP_GROUP_SIGNATURE "ipmp_group_signature" +#define IPMP_GROUP_STATE "ipmp_group_state" + +typedef enum { + IPMP_GROUP_OK, /* all interfaces in the group are ok */ + IPMP_GROUP_FAILED, /* all interfaces in the group are unusable */ + IPMP_GROUP_DEGRADED /* some interfaces in the group are unusable */ +} ipmp_group_state_t; + +#define IPMP_EVENT_CUR_VERSION 2 + +/* + * Event type EC_IPMP/ESC_IPMP_GROUP_CHANGE event schema + * + * Event Class - EC_IPMP + * Event Sub-Class - ESC_IPMP_GROUP_CHANGE + * Event Vendor - com.sun + * Event Publisher - in.mpathd + * + * Attribute Name - IPMP_GROUP_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - + * + * Attribute Name - IPMP_EVENT_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_GROUPLIST_SIGNATURE + * Attribute Type - SE_DATA_TYPE_UINT64 + * Attribute Value - + * + * Attribute Name - IPMP_GROUP_OPERATION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + */ + +#define IPMP_GROUPLIST_SIGNATURE "ipmp_grouplist_signature" +#define IPMP_GROUP_OPERATION "ipmp_group_operation" + +typedef enum { + IPMP_GROUP_ADD, /* a new IPMP group has been created */ + IPMP_GROUP_REMOVE /* an existing IPMP group has been removed */ +} ipmp_group_op_t; + +/* + * Event type EC_IPMP/ESC_IPMP_GROUP_MEMBER event schema + * + * Event Class - EC_IPMP + * Event Sub-Class - ESC_IPMP_GROUP_MEMBER_CHANGE + * Event Vendor - com.sun + * Event Publisher - in.mpathd + * + * Attribute Name - IPMP_GROUP_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - + * + * Attribute Name - IPMP_EVENT_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_GROUP_SIGNATURE + * Attribute Type - SE_DATA_TYPE_UINT64 + * Attribute Value - + * + * Attribute Name - IPMP_IF_OPERATION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_IF_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - + * + * Attribute Name - IPMP_IF_TYPE + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_IF_STATE + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + */ + +#define IPMP_IF_OPERATION "ipmp_if_operation" +#define IPMP_IF_NAME "ipmp_if_name" +#define IPMP_IF_TYPE "ipmp_if_type" +#define IPMP_IF_STATE "ipmp_if_state" + +typedef enum { + IPMP_IF_ADD, /* a new interface has joined the group */ + IPMP_IF_REMOVE /* an existing interface has left the group */ +} ipmp_if_op_t; + +typedef enum { + IPMP_IF_STANDBY, /* the interface is a standby */ + IPMP_IF_NORMAL /* the interface is not a standby */ +} ipmp_if_type_t; + +typedef enum { + IPMP_IF_OK, /* the interface is functional */ + IPMP_IF_FAILED, /* the interface is in a failed state */ + IPMP_IF_OFFLINE, /* the interface is offline */ + IPMP_IF_UNKNOWN /* the interface may or may not be ok */ +} ipmp_if_state_t; /* (not enough probes have been sent) */ + +/* + * Event type EC_IPMP/ESC_IPMP_IF_CHANGE event schema + * + * Event Class - EC_IPMP + * Event Sub-Class - ESC_IPMP_IF_CHANGE + * Event Vendor - com.sun + * Event Publisher - in.mpathd + * + * Attribute Name - IPMP_GROUP_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - + * + * Attribute Name - IPMP_EVENT_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_GROUP_SIGNATURE + * Attribute Type - SE_DATA_TYPE_UINT64 + * Attribute Value - + * + * Attribute Name - IPMP_IF_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - + * + * Attribute Name - IPMP_IF_STATE + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_IF_TYPE + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + */ + +#define IPMP_PROBE_ID "ipmp_probe_id" +#define IPMP_PROBE_STATE "ipmp_probe_state" +#define IPMP_PROBE_START_TIME "ipmp_probe_start_time" +#define IPMP_PROBE_SENT_TIME "ipmp_probe_sent_time" +#define IPMP_PROBE_ACKRECV_TIME "ipmp_probe_ackrecv_time" +#define IPMP_PROBE_ACKPROC_TIME "ipmp_probe_ackproc_time" +#define IPMP_PROBE_TARGET "ipmp_probe_target" +#define IPMP_PROBE_TARGET_RTTAVG "ipmp_probe_target_rttavg" +#define IPMP_PROBE_TARGET_RTTDEV "ipmp_probe_target_rttdev" + +typedef enum { + IPMP_PROBE_SENT, /* the probe has been sent */ + IPMP_PROBE_ACKED, /* the probe has been acked */ + IPMP_PROBE_LOST /* the probe has been lost */ +} ipmp_probe_state_t; + +/* + * Event type EC_IPMP/ESC_IPMP_PROBE_STATE event schema + * + * Event Class - EC_IPMP + * Event Sub-Class - ESC_IPMP_PROBE_STATE + * Event Vendor - com.sun + * Event Publisher - in.mpathd + * + * Attribute Name - IPMP_PROBE_ID + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_EVENT_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_IF_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - + * + * Attribute Name - IPMP_PROBE_STATE + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_PROBE_START_TIME + * Attribute Type - SE_DATA_TYPE_TIME + * Attribute Value - + * + * Attribute Name - IPMP_PROBE_SENT_TIME + * Attribute Type - SE_DATA_TYPE_TIME + * Attribute Value - + * + * Attribute Name - IPMP_PROBE_ACKRECV_TIME + * Attribute Type - SE_DATA_TYPE_TIME + * Attribute Value - + * + * Attribute Name - IPMP_PROBE_ACKPROC_TIME + * Attribute Type - SE_DATA_TYPE_TIME + * Attribute Value - + * + * Attribute Name - IPMP_PROBE_TARGET + * Attribute Type - SE_DATA_TYPE_BYTES + * Attribute Value - + * + * Attribute Name - IPMP_PROBE_TARGET_RTTAVG + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + * + * Attribute Name - IPMP_PROBE_TARGET_RTTDEV + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_IPMP_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/pwrctl.h b/illumos-x86_64/usr/include/sys/sysevent/pwrctl.h new file mode 100644 index 00000000..968ec94e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/pwrctl.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSEVENT_PWRCTL_H +#define _SYS_SYSEVENT_PWRCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Event type schema for EC_PWRCTL: + * Event Class - EC_PWRCTL + * Event Sub-Class - ESC_PWRCTL_ADD | + * ESC_PWRCTL_REMOVE | + * ESC_PWRCTL_WARN | + * ESC_PWRCTL_LOW | + * ESC_PWRCTL_STATE_CHANGE | + * ESC_PWRCTL_POWER_BUTTON | + * ESC_PWRCTL_BRIGHTNESS_UP | + * ESC_PWRCTL_BRIGHTNESS_DOWN + * Event Publisher - SUNW:kern:[environmental monitor name] + * Attribute Name - PWRCTL_VERSION + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - [version of the schema] + * Attribute Name - PWRCTL_DEV_HID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Label identifying the ACPI hardware] + * Attribute Name - PWRCTL_DEV_UID + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - [Both the _HID and _UID values can be of either type + * STRING or NUMBER in the ACPI tables. In order to + * provide a consistent data type in the external + * interface, these values are always returned as NULL + * terminated strings, regardless of the original data + * type in the source ACPI table.] + * Attribute Name - PWRCTL_DEV_INDEX + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - [Device index] + * + * ESC_PWRCTL_WARN, ESC_PWRCTL_LOW only field: + * Attribute Name - PWRCTL_CHARGE_LEVEL + * Attribute Type - SE_DATA_TYPE_UINT32 + * Attribute Value - [charge level] + */ + +#define PWRCTL_VERSION "pwrctl_version" /* Version of the schema */ +#define PWRCTL_DEV_PHYS_PATH "pwrctl_dev_phys_path" /* Physical Path */ +#define PWRCTL_DEV_HID "pwrctl_dev_hid" /* ACPI device Hardware Id */ +#define PWRCTL_DEV_UID "pwrctl_dev_uid" /* ACPI device Unique Id */ +#define PWRCTL_DEV_INDEX "pwrctl_dev_index" /* Device index */ +#define PWRCTL_CHARGE_LEVEL "pwrctl_charge_level" /* Event related state */ +#define PWRCTL_BRIGHTNESS_LEVEL "pwrctl_brightness_level" + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_PWRCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent/vrrp.h b/illumos-x86_64/usr/include/sys/sysevent/vrrp.h new file mode 100644 index 00000000..e8b4420a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent/vrrp.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSEVENT_VRRP_H +#define _SYS_SYSEVENT_VRRP_H + +/* + * VRRP sysevent definitions. Note that all of these definitions are + * Sun-private and are subject to change at any time. + */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Event type EC_VRRP/ESC_VRRP_GROUP_STATE event schema + * + * Event Class - EC_VRRP + * Event Sub-Class - ESC_VRRP_STATE_CHANGE + * Event Vendor - SUNW_VENDOR (defined in sys/sysevent.h) + * Event Publisher - VRRP_EVENT_PUBLISHER (defined in this file) + * + * Attribute Name - VRRP_EVENT_VERSION + * Attribute Type - SE_DATA_TYPE_UINT8 + * Attribute Value - + * + * Attribute Name - VRRP_EVENT_ROUTER_NAME + * Attribute Type - SE_DATA_TYPE_STRING + * Attribute Value - + * + * Attribute Name - VRRP_EVENT_STATE + * Attribute Type - SE_DATA_TYPE_UINT8 + * Attribute Value - + * + * Attribute Name - VRRP_EVENT_PREV_STATE + * Attribute Type - SE_DATA_TYPE_UINT8 + * Attribute Value - + */ + +#define VRRP_EVENT_PUBLISHER "vrrpd" + +#define VRRP_EVENT_VERSION "vrrp_event_version" +#define VRRP_EVENT_ROUTER_NAME "vrrp_router_name" +#define VRRP_EVENT_STATE "vrrp_state" +#define VRRP_EVENT_PREV_STATE "vrrp_prev_state" + +#define VRRP_EVENT_CUR_VERSION 1 + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_VRRP_H */ diff --git a/illumos-x86_64/usr/include/sys/sysevent_impl.h b/illumos-x86_64/usr/include/sys/sysevent_impl.h new file mode 100644 index 00000000..11745276 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysevent_impl.h @@ -0,0 +1,582 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_SYSEVENT_IMPL_H +#define _SYS_SYSEVENT_IMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint64_t se_data_t; + +/* + * The following data structure assist in loading and extracting event + * header and attribute data into contiguous memory. Access to all typed + * data done so on 64-bit boundaries. *Do Not* alter any of the structures + * defined below without thorough thought and testing. + */ + +/* Attribute name */ +typedef struct se_name { + int32_t name_sz; + int32_t name_pad; + se_data_t name; /* 64-bit aligned offset */ +} se_name_t; + +/* Attribute value */ +typedef struct se_value { + int32_t value_type; /* data type */ + int32_t value_sz; + se_data_t value; /* data value - 64-bit aligned offset */ +} se_value_t; + +/* sysevent internal attribute name-value pair stored in contiguous memory */ +typedef struct sysevent_attr_impl { + int32_t se_attr_sz; /* Size of attribute data */ + int32_t se_attr_pad; /* pad */ + se_data_t se_attr_name; /* name of data attribute */ + se_data_t se_attr_val; /* value and type of data */ +} sysevent_attr_impl_t; + +/* Attribute list states */ +#define ATTR_DETACHED 0 +#define ATTR_ATTACHED 1 + +/* + * The following type definitions describe a sysevent object that is + * generated by a call to sysevent_alloc and sent to userland. + */ + +/* + * sysevent event header information - + * contained in every event generated. The header and the event + * must remain 64-bit aligned. The header, up to the attribute + * offset, can be contained in a single cache line. + */ +typedef struct sysevent_hdr { + sysevent_id_t se_id; /* unique identifier */ + uint32_t se_version; /* version of this data structure */ + uint32_t se_flag; + uint32_t se_class; /* event class id - reserved */ + uint32_t se_subclass; /* event subclass id - reserved */ + int32_t se_payload_sz; /* size of attr data + strings */ + uint16_t se_subclass_off; /* offset to subclass string */ + uint16_t se_pub_off; /* offset to publisher string */ + uint64_t se_attr_off; /* pointer or offset to attr data */ +} sysevent_hdr_t; + +/* sysevent event buffer - 64-bit aligned offsets */ +typedef struct sys_event_impl { + sysevent_hdr_t se_header; + se_data_t se_class_name; /* class string in contig memory */ + se_data_t se_subclass_name; /* subclass string in contig memory */ + se_data_t se_pub; /* publisher string in contig mem */ + se_data_t se_attr_buf; /* contiguous attribute memory */ +} sysevent_impl_t; + +/* Helpful defines */ +#define seh_version se_header.se_version +#define seh_class se_header.se_class +#define seh_subclass se_header.se_subclass +#define seh_seq se_header.se_id.eid_seq +#define seh_time se_header.se_id.eid_ts +#define seh_subclass_off se_header.se_subclass_off +#define seh_pub_off se_header.se_pub_off +#define seh_attr_off se_header.se_attr_off +#define seh_payload_sz se_header.se_payload_sz +#define seh_flag se_header.se_flag + +/* Event buffer version */ +#define SYS_EVENT_VERSION 0 + +/* Event buffer flags */ +#define SE_PACKED_BUF 1 + +#define SYSEVENT_IMPL(ev) ((sysevent_impl_t *)(void *)(ev)) +#define SE_VERSION(ev) (SYSEVENT_IMPL(ev)->seh_version) +#define SE_CLASS(ev) (SYSEVENT_IMPL(ev)->seh_class) +#define SE_SUBCLASS(ev) (SYSEVENT_IMPL(ev)->seh_subclass) +#define SE_SEQ(ev) (SYSEVENT_IMPL(ev)->seh_seq) +#define SE_TIME(ev) (SYSEVENT_IMPL(ev)->seh_time) +#define SE_SUBCLASS_OFF(ev) (SYSEVENT_IMPL(ev)->seh_subclass_off) +#define SE_PUB_OFF(ev) (SYSEVENT_IMPL(ev)->seh_pub_off) +#define SE_PAYLOAD_SZ(ev) (SYSEVENT_IMPL(ev)->seh_payload_sz) +#define SE_FLAG(ev) (SYSEVENT_IMPL(ev)->seh_flag) +#define SE_SIZE(ev) (sizeof (sysevent_impl_t) + SE_PAYLOAD_SZ(ev)) +#define SE_CLASS_NAME(ev) ((char *)&(SYSEVENT_IMPL(ev)->se_class_name)) +#define SE_SUBCLASS_NAME(ev) ((char *)((caddr_t)(ev) + SE_SUBCLASS_OFF(ev))) +#define SE_PUB_NAME(ev) ((char *)((caddr_t)(ev) + SE_PUB_OFF(ev))) + +/* + * Attribute data can be stored in contiguous memory or + * as a list of attribute data elements. The storage format is determined + * by the SE_PACKED_BUF flag in the event buffer flags. + * + */ + +/* 64-bit boundary alignment function */ +#define SE_ALIGN(x) ((((ulong_t)x) + 7ul) & ~7ul) + +/* Access to unpacked attribute list */ +#define SE_ATTR_PTR(ev) (SYSEVENT_IMPL(ev)->seh_attr_off) + +/* Offset to packed attribute data */ +#define SE_ATTR_OFF(ev) SE_PUB_OFF(ev) + SE_ALIGN(strlen(SE_PUB_NAME(ev)) + 1) + +/* syseventd door */ +#define LOGEVENT_DOOR_UPCALL "/var/run/sysevent_door" + +/* + * door upcall data structures + */ +typedef struct log_event_upcall_arg { + int32_t retcode; + int32_t pad; + sysevent_impl_t buf; +} log_event_upcall_arg_t; + +typedef struct log_eventq { + struct log_eventq *next; + log_event_upcall_arg_t arg; +} log_eventq_t; + +/* Syseventd Channel structures */ + +#define MAX_CHAN 256 /* Maximum channels per system */ +#define MAX_SUBSCRIBERS 100 /* Maximum subscribers per channel */ +#define MAX_PUBLISHERS 1 /* Maximum publishers per channel */ + +/* + * Channel-based subscription structures + */ + +/* Class hashing defines */ +#define CLASS_HASH_SZ 63 +#define CLASS_HASH(class_name) ((hash_func(class_name) \ + % CLASS_HASH_SZ) + 1) +#define CHAN_HASH_SZ 32 + +typedef struct subclass_lst { + struct subclass_lst *sl_next; + char *sl_name; + uchar_t sl_num[MAX_SUBSCRIBERS + 1]; +} subclass_lst_t; + +typedef struct class_lst { + struct class_lst *cl_next; + char *cl_name; + struct subclass_lst *cl_subclass_list; +} class_lst_t; + +/* User/Kernel Structure to pass event registration modctl data */ +typedef struct se_pubsub { + uint32_t ps_buflen; + uint32_t ps_channel_name_len; + uint32_t ps_id; + uint32_t ps_op; + uint32_t ps_type; +} se_pubsub_t; + +/* op defines */ +#define SE_REGISTER 0 +#define SE_UNREGISTER 1 +#define SE_CLEANUP 2 +#define SE_OPEN_REGISTRATION 3 +#define SE_CLOSE_REGISTRATION 4 +#define SE_BIND_REGISTRATION 5 +#define SE_UNBIND_REGISTRATION 6 +#define SE_GET_REGISTRATION 7 + +/* type defines */ +#define SUBSCRIBER 0 +#define PUBLISHER 1 + +/* nvpair names */ +#define CLASS_NAME "class" + +#ifdef _KERNEL + +typedef struct sysevent_channel_descriptor { + char *scd_channel_name; /* Name of channel */ + struct sysevent_channel_descriptor *scd_next; + int scd_ref_cnt; /* Reference count of channel opens */ + id_space_t *scd_subscriber_cache; /* cache of subscriber ids */ + id_space_t *scd_publisher_cache; /* cache of publisher ids */ + uchar_t scd_subscriber_ids[MAX_SUBSCRIBERS + 1]; /* used sub ids */ + uchar_t scd_publisher_ids[MAX_PUBLISHERS + 1]; /* used pub ids */ + class_lst_t *scd_class_list_tbl[CLASS_HASH_SZ + 1]; +} sysevent_channel_descriptor_t; + +/* + * log_sysevent private interfaces + */ +extern void log_event_init(void); +extern void log_sysevent_flushq(int, uint_t); +extern int log_sysevent_filename(char *); +extern int log_usr_sysevent(sysevent_t *, int, sysevent_id_t *); +extern int log_sysevent_copyout_data(sysevent_id_t *, size_t, caddr_t); +extern int log_sysevent_free_data(sysevent_id_t *); +extern int log_sysevent_register(char *, char *, se_pubsub_t *); +extern uint64_t log_sysevent_new_id(void); + +/* + * Structures and definitions for general purpose event channels + */ + +/* Limits */ +#define EVCH_MAX_CHANNELS 1024 +#define EVCH_MAX_BINDS_PER_CHANNEL 512 +#define EVCH_MAX_SUBSCRIPTIONS 32 +#define EVCH_SUBPOOLFACT 8 +#define EVCH_DEFAULT_EVENTS 2000 +#define EVCH_MAX_TRY_DELIVERY 3 + +/* Linkage element for evch_dlist_t lists */ +typedef struct evch_dlelem { + struct evch_dlelem *dl_next; + struct evch_dlelem *dl_prev; +} evch_dlelem_t; + +/* List head */ +typedef struct { + evch_dlelem_t dh_head; + int dh_count; +} evch_dlist_t; + +/* Placeholder for elements in a evch_squeue_t queue */ +typedef struct evch_qelem { + struct evch_qelem *q_next; + void *q_objref; + size_t q_objsize; +} evch_qelem_t; + +/* Queue head data */ +typedef struct { + evch_qelem_t *sq_head; + evch_qelem_t *sq_tail; + uint32_t sq_count; + uint32_t sq_highwm; +} evch_squeue_t; + +/* + * Defines for event queue routines + */ +#define EVQ_IGNORE 1 +#define EVQ_DELIVER 2 + +#define EVQ_CONT 0 +#define EVQ_AGAIN 1 +#define EVQ_SLEEP 2 + +/* Call back routine typedefs */ +typedef int (*filter_f)(void *, void *); +typedef int (*deliver_f)(void *, void *); +typedef int (*kerndlv_f)(void *, void *); +typedef void (*destr_f)(void *, void *); +typedef int (*compare_f)(evch_dlelem_t *, char *); + +/* + * Event structure handled by evch_evq_* functions. Sysevent type events are + * stored as the payload. + */ +typedef struct { + uint32_t ge_size; /* Total size of event structure */ + uint32_t ge_refcount; /* No of queues event is linked to */ + destr_f ge_destruct; /* Destructor for event structure */ + uint32_t *ge_dstcookie; /* Cookie for destructor function */ + uchar_t ge_payload[1]; /* Placeholder for event data */ +} evch_gevent_t; + +/* + * Event queue descriptor + */ +typedef struct { + evch_squeue_t eq_eventq; /* Protected by eq_dtmutex */ + kt_did_t eq_thrid; /* Id delivery thread */ + kmutex_t eq_queuemx; /* Protect. of this struct and ev q */ + kcondvar_t eq_thrsleepcv; /* Delivery thread sleeps on empty q */ + int eq_dactive; /* Event delivery is in progress */ + kcondvar_t eq_dactivecv; /* Unsubscr. has to wait on this */ + evch_dlist_t eq_subscr; /* Chain of all evch_evqsub_t */ + uint32_t eq_nsleep; /* Statistic: Publisher set to sleep */ + int eq_holdmode; /* Hold event delivery */ + evch_gevent_t *eq_curevent; /* Event currently beeing delivered */ + evch_qelem_t *eq_nextev; /* For iterating over events in a q */ + kcondvar_t eq_onholdcv; /* To signal hold mode of deliv. thr. */ + uchar_t eq_tabortflag; /* Request to abort delivery thread */ +} evch_eventq_t; + +/* + * Event queue per subscriber structure + */ +typedef struct { + evch_dlelem_t su_link; + filter_f su_filter; /* Event filter function pointer */ + void *su_fcookie; /* cookie for event filter */ + deliver_f su_callb; /* Event delivery callback */ + void *su_cbcookie; /* callback cookie */ +} evch_evqsub_t; + +/* Eveny delivery type */ +#define EVCH_DELKERN 1 /* Kernel event delivery */ +#define EVCH_DELDOOR 2 /* User event delivery via doors */ + +/* + * Per channel subscriber data structure. Chained in a linked list to an + * event channel and to a binding. + */ +typedef struct chsubd { + evch_dlelem_t sd_link; /* Links all subscribers of this ch. */ + struct chsubd *sd_subnxt; /* Links all subscr. for a binding */ + char *sd_ident; /* Subscriber identifier */ + evch_eventq_t *sd_queue; /* Event queue for this subscriber */ + evch_evqsub_t *sd_msub; /* Main event queue subscr. */ + char *sd_classname; /* Filter criteria */ + size_t sd_clnsize; /* Size of sd_classname buffer */ + evch_evqsub_t *sd_ssub; /* Subscriber queue subscr. */ + int sd_type; /* Type of event delivery */ + kerndlv_f sd_callback; /* Callback for kernel delivery */ + void *sd_cbcookie; /* Cookie for kernel delivery */ + door_handle_t sd_door; /* Door handle for user delivery */ + int sd_active; /* Subscription is in use indicator */ + pid_t sd_pid; /* PID of subscribing process */ + uint8_t sd_persist; /* Persistent user land subscription */ + uint8_t sd_dump; /* Dump with sysevent_evc_walk_* */ +} evch_subd_t; + +/* + * General purpose event channel descriptor structure. This is the main + * structure for event subscribing, publishing, delivery to/from an event + * channel. + */ +typedef struct { + evch_dlelem_t ch_link; /* Must be first elem. of structure */ + char *ch_name; /* Channel name */ + size_t ch_namelen; /* Length of channel name buffer */ + kmutex_t ch_mutex; /* To protect this structure */ + evch_eventq_t *ch_queue; /* Publisher event queue */ + evch_dlist_t ch_subscr; /* List of subscr. data (evch_subd_t) */ + uint32_t ch_bindings; /* No of bindings to this channel */ + int ch_maxbinds; /* Maximum number of binds */ + uid_t ch_uid; /* Creators effective user id */ + gid_t ch_gid; /* Creators effective group id */ + kmutex_t ch_pubmx; /* Mutex for ch_pubcv and ch_nevents */ + kcondvar_t ch_pubcv; /* To set publisher to sleep */ + uint32_t ch_nevents; /* Current number of events */ + uint32_t ch_maxev; /* Maximum number of events */ + int ch_maxsubscr; /* Maximum number of subscriptions */ + int ch_holdpend; /* Hold pending events mode if != 0 */ + time_t ch_ctime; /* Channel creation time */ + nvlist_t *ch_propnvl; /* Channel properties nvlist */ + int64_t ch_propnvlgen; /* Properties generation number */ +} evch_chan_t; + +/* + * Channel binding structure. Allocated per binding to a channel. Protected + * by locking the channel structure + */ +typedef struct { + evch_chan_t *bd_channel; + evch_subd_t *bd_sublst; /* chain of all subscriptions */ +} evch_bind_t; + +/* + * Structure to keep a snapshot of all events of a channel + */ +typedef struct { + evch_eventq_t *sn_queue; /* Event queue with snapshot of ev's */ + sysevent_impl_t *sn_nxtev; /* Pointer to find next event */ +} evchanq_t; + +/* Project private interfaces */ +extern evchan_t *evch_usrchanopen(const char *name, uint32_t flags, int *err); +extern void evch_usrchanclose(evchan_t *cbp); +extern sysevent_impl_t *evch_usrallocev(size_t evsize, uint32_t flags); +extern void evch_usrfreeev(sysevent_impl_t *ev); +extern int evch_usrpostevent(evchan_t *bp, sysevent_impl_t *ev, uint32_t flags); +extern int evch_usrsubscribe(evchan_t *bp, const char *sid, const char *class, + int d, uint32_t flags); +extern int evch_usrcontrol_set(evchan_t *bp, int cmd, uint32_t value); +extern int evch_usrcontrol_get(evchan_t *bp, int cmd, uint32_t *value); +extern void evch_usrunsubscribe(evchan_t *bp, const char *subid, uint32_t flag); +extern int evch_usrgetchnames(char *buf, size_t size); +extern int evch_usrgetchdata(char *chname, void *buf, size_t size); +extern void evch_usrsetpropnvl(evchan_t *bp, nvlist_t *nvl); +extern int evch_usrgetpropnvl(evchan_t *bp, nvlist_t **nvlp, int64_t *genp); + +extern void sysevent_evc_init(); +extern void sysevent_evc_thrinit(); +extern evchanq_t *sysevent_evc_walk_init(evchan_t *, char *); +extern sysevent_t *sysevent_evc_walk_step(evchanq_t *); +extern void sysevent_evc_walk_fini(evchanq_t *); +extern char *sysevent_evc_event_attr(sysevent_t *, size_t *); + +#endif /* _KERNEL */ + +/* + * Structures and limits to deliver channel data to syseventadm + */ +#define EVCH_MAX_DATA_SIZE (1024 * 1024) + +typedef struct { + uint32_t sb_nextoff; /* Offset to next subscr info struct */ + uint32_t sb_stroff; /* Offset to strings */ + uint32_t sb_clnamoff; /* Offset of class in sb_strings */ + uint32_t sb_pid; /* Subscriber process id */ + uint32_t sb_nevents; /* Current no of event in sub q */ + uint32_t sb_evhwm; /* High watermark of sub q */ + uint32_t sb_persist; /* != 0 if subscription persists */ + uint32_t sb_status; /* != 0 if subscription is inactive */ + uint32_t sb_active; /* > 0 if subscription is in use */ + uint32_t sb_dump; /* != 0 if sub will be dumped */ + char sb_strings[1]; /* String space for subid and class */ +} sev_subinfo_t; + +typedef struct { + uint32_t cd_version; /* Version of this structure */ + uint32_t cd_suboffs; /* Offset of subscriber info struct */ + uint64_t cd_ctime; /* Creation time */ + uint32_t cd_uid; /* User id */ + uint32_t cd_gid; /* Owner group id */ + uint32_t cd_perms; /* Permission bits */ + uint32_t cd_maxev; /* Max number of events */ + uint32_t cd_evhwm; /* High watermark of main event queue */ + uint32_t cd_nevents; /* current no of events in main ev q */ + uint32_t cd_maxsub; /* Max number of subscriptions */ + uint32_t cd_nsub; /* Current number of subscriptions */ + uint32_t cd_maxbinds; /* Max number of binds */ + uint32_t cd_nbinds; /* Current number of binds */ + uint32_t cd_holdpend; /* != 0 when HOLDPEND mode is set */ + uint32_t cd_limev; /* Limit of events per channel */ + sev_subinfo_t cd_subinfo[1]; /* Per subscriber data */ +} sev_chinfo_t; + +/* + * Project private flags for sysevent_evc_subscribe. Bits 0 to 7 are reserved + * for the consolidation private interface, so we must use bits 8-15 here. + */ +#define EVCH_SUB_DUMP (0x01 << 8) + +/* + * Permission flags + */ +#define EVCH_PUB 0x0004 /* wants to publish events */ +#define EVCH_SUB 0x0008 /* wants to subscribe to channel */ + +#define EVCH_SUBU 0x0001 /* Subscribing allowed for uid */ +#define EVCH_PUBU 0x0002 /* Publishing allowed for uid */ +#define EVCH_PSUSR 0x0003 /* EVCH_SUBU + EVCH_PUBU */ +#define EVCH_SUBG 0x0004 /* Subscribing allowed for gid */ +#define EVCH_PUBG 0x0008 /* Publishing allowed for gid */ +#define EVCH_PSGRP 0x000C /* EVCH_SUBG + EVCH_PUBG */ +#define EVCH_SUBO 0x0010 /* Subscribing allowed to all users */ +#define EVCH_PUBO 0x0020 /* Publishing allowed to all users */ +#define EVCH_PSOTH 0x0030 /* EVCH_SUBO + EVCH_PUBO */ +#define EVCH_PSALL 0x003f /* Mask of all permission bits */ + +/* + * Sysevent driver ioctls + */ +#define SEV_BASE 0x53455600 +#define SEV_PUBLISH SEV_BASE | 0x01 +#define SEV_CHAN_OPEN SEV_BASE | 0x02 +#define SEV_CHAN_CONTROL SEV_BASE | 0x03 +#define SEV_SUBSCRIBE SEV_BASE | 0x04 +#define SEV_UNSUBSCRIBE SEV_BASE | 0x05 +#define SEV_CHANNAMES SEV_BASE | 0x06 +#define SEV_CHANDATA SEV_BASE | 0x07 +#define SEV_SETPROPNVL SEV_BASE | 0x08 +#define SEV_GETPROPNVL SEV_BASE | 0x09 + +#define DEVSYSEVENT "/dev/sysevent" +#define DEVICESYSEVENT "/devices/pseudo/sysevent@0:sysevent" + +/* + * Maximum allowed binding handles + * It's a limit required by bitmap algorithm design (see sys/bitmap.h). + * Use pack(4) to make sizeof structs be the same on x86 and amd64. + */ +#define SYSEVENT_MINOR_MAX SHRT_MAX + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* copyin/copyout data */ +typedef struct box { + uint64_t name; /* pointer to something */ + uint32_t len; +} sev_box_t; + +typedef struct bind_args { + sev_box_t chan_name; + uint32_t flags; +} sev_bind_args_t; + +typedef struct control_args { + uint32_t cmd; + uint32_t value; +} sev_control_args_t; + +typedef struct publish_args { + sev_box_t ev; + uint32_t flags; +} sev_publish_args_t; + +typedef struct subscribe_args { + sev_box_t sid; + sev_box_t class_info; + int door_desc; + uint32_t flags; +} sev_subscribe_args_t; + +typedef struct unsubscribe_args { + sev_box_t sid; +} sev_unsubscribe_args_t; + +typedef struct chandata { + sev_box_t in_data; + sev_box_t out_data; +} sev_chandata_args_t; + +typedef struct propnvl_args { + sev_box_t packednvl; /* input and output */ + int64_t generation; /* output on get operation */ +} sev_propnvl_args_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/sysi86.h b/illumos-x86_64/usr/include/sys/sysi86.h new file mode 100644 index 00000000..ede0e42d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysi86.h @@ -0,0 +1,256 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_SYSI86_H +#define _SYS_SYSI86_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef DIRSIZ +#define DIRSIZ 14 +#endif + +/* + * Commands for sysi86 system call (1-?) + */ + +#define SI86SWPI 1 /* General swap interface. */ +#define SI86SYM 2 /* acquire boot-built symbol table */ +#define SI86CONF 4 /* acquire boot-built configuration table */ +#define SI86BOOT 5 /* acquire timestamp and name of program */ + /* booted */ +#define SI86AUTO 9 /* was an auto-config boot done? */ +#define SI86EDT 10 /* copy contents of EDT to user */ +#define SI86SWAP 12 /* Declare swap space */ +#define SI86FPHW 40 /* what (if any?) floating-point hardware */ +#define SI86FPSTART 41 /* extended version of SI86FPHW */ + +#define GRNON 52 /* set green light to solid on state */ +#define GRNFLASH 53 /* start green light flashing */ +#define STIME 54 /* set internal time */ +#define SETNAME 56 /* rename the system */ +#define RNVR 58 /* read NVRAM */ +#define WNVR 59 /* write NVRAM */ +#define RTODC 60 /* read time of day clock */ +#define CHKSER 61 /* check soft serial number */ +#define SI86NVPRT 62 /* print an xtra_nvr structure */ +#define SANUPD 63 /* sanity update of kernel buffers */ +#define SI86KSTR 64 /* make a copy of a kernel string */ +#define SI86MEM 65 /* return the memory size of system */ +#define SI86TODEMON 66 /* Transfer control to firmware. */ +#define SI86CCDEMON 67 /* Control character access to demon. */ +#define SI86CACHE 68 /* Turn cache on and off. */ +#define SI86DELMEM 69 /* Delete available memory for testing. */ +#define SI86ADDMEM 70 /* Add back deleted memory. */ +/* 71 through 74 reserved for VPIX */ +#define SI86V86 71 /* V86 system calls (see below) */ +#define SI86SLTIME 72 /* Set local time correction */ +#define SI86DSCR 75 /* Set a segment or gate descriptor */ +#define RDUBLK 76 /* Read U Block */ +/* NFA entry point */ +#define SI86NFA 77 /* make nfa_sys system call */ +#define SI86VM86 81 +#define SI86VMENABLE 82 +#define SI86LIMUSER 91 /* license interface */ +#define SI86RDID 92 /* ROM BIOS Machid ID */ +#define SI86RDBOOT 93 /* Bootable Non-SCSI Hard Disk */ +/* XENIX Support */ +#define SI86SHFIL 100 /* map a file into addr space of a proc */ +#define SI86PCHRGN 101 /* make globally visible change to a region */ +#define SI86BADVISE 102 /* badvise subcommand - see below for */ + /* badvise subfunction definitions */ +#define SI86SHRGN 103 /* enable/disable XENIX small model shared */ + /* data context switching */ +#define SI86CHIDT 104 /* set user level int 0xf0, ... 0xff handlers */ +#define SI86EMULRDA 105 /* remove special emulator read access */ + +/* + * NOTE: Numbers 106 - 110 have been registered and are reserved + * for future use for AT&T hardware. + */ + +/* + * Commands for allowing the real time clock to keep local time. + */ + +#define WTODC 111 /* write tod clock */ +#define SGMTL 112 /* set GMT lag */ +#define GGMTL 113 /* get GMT lag */ +#define RTCSYNC 114 /* set UNIX 'time' based on RTC and GMT lag */ + +#define V86SC_IOPL 4 /* The only supported V86 system call */ + +/* + * The SI86DSCR subcommand of the sysi86() system call + * sets a segment or gate descriptor in the kernel. + * The following descriptor types are accepted: + * - executable and data segments in the LDT at DPL 3 + * - a call gate in the GDT at DPL 3 that points to a segment in the LDT + * The request structure declared below is used to pass the values + * to be placed in the descriptor. A pointer to the structure is + * passed as the second argument of the system call. + * If acc1 is zero, the descriptor is cleared. + */ + +/* + * XX64 Do we need to support this for 64-bit apps? + * + * request structure passed by user + */ +struct ssd { + unsigned int sel; /* descriptor selector */ + unsigned int bo; /* segment base or gate offset */ + unsigned int ls; /* segment limit or gate selector */ + unsigned int acc1; /* access byte 5 */ + unsigned int acc2; /* access bits in byte 6 or gate count */ +}; + +#define SI86SSD_TYPE(ssd) ((ssd)->acc1 & 0x1F) +#define SI86SSD_DPL(ssd) (((ssd)->acc1 >> 5) & 0x3) +#define SI86SSD_PRES(ssd) (((ssd)->acc1 >> 7) & 1) +#define SI86SSD_ISUSEG(ssd) (SI86SSD_TYPE(ssd) >= SDT_MEMRO) +#define SI86SSD_ISLONG(ssd) ((ssd)->acc2 & 0x2) + +#ifdef _KERNEL +extern void usd_to_ssd(user_desc_t *, struct ssd *, selector_t); +extern int setdscr(struct ssd *); +#endif /* _KERNEL */ + +/* + * The SI86SHFIL subcommand of the sysi86() system call + * maps a file into a region in user address space. + * The request structure declared below is used to pass the + * system call parameters. A pointer to the structure is + * passed as the second argument of the system call. + */ +struct mmf { + char *mf_filename; /* path name of file */ + long mf_filesz; /* Size in bytes of section of file */ + /* from which this region is mapped. */ + long mf_regsz; /* Size of region in bytes */ + short mf_flags; /* Either 0 or RG_NOSHARE */ +}; + +/* + * The SI86PCHRGN subcommand of the sysi86() system call + * change the memory mapped image of a file. + * The request structure declared below is used to pass the values + * system call parameters. A pointer to the structure is + * passed as the second argument of the system call. + */ +struct cmf { + char *cf_srcva; /* modified image address */ + char *cf_dstva; /* location to patch */ + long cf_count; /* size of patch */ +}; + +/* + * The SI86BADVISE subcommand of the sysi86() system call specifies + * XENIX variant behavior for certain system calls and kernel routines. + * The 'arg' argument of sysi86() for SI86BADVISE is an integer. Bits + * 8..15 specify SI86B_SET or SI86B_GET. Bits 0..7 contain + * SI86B_PRE_SV, SI86B_XOUT, or SI86B_XSDSWTCH. All these constants are + * defined below. The 'arg' argument thus consists of either SI86B_SET + * OR'ed with zero or more of SI86B_PRE_SV, SI86B_XOUT, and SI86B_XSDSWTCH, + * or of SI86B_GET. + */ +#define SI86B_SET 0x0100 /* set badvise bits */ +#define SI86B_GET 0x0200 /* retrieve badvise bits */ + +#define SI86B_PRE_SV 0x0008 /* follow pre-System V x.out behavior */ +#define SI86B_XOUT 0x0010 /* follow XENIX x.out behavior */ +#define SI86B_XSDSWTCH 0x0080 /* XENIX small model shared data */ + /* context switching enabled */ + +/* + * The request structure declared below is used by the XENIX 286 emulator + * (/bin/x286emul) in conjunction with the SI86SHRGN subcommand of sysi86(). + * The SI86SHRGN subcommand is used by the XENIX 286 emulator to support + * XENIX shared data. The second argument passed to sysi86() is a + * pointer to an xsdbuf struct. + * + * If the 'xsd_cmd' field of xsdbuf is SI86SHR_CP, the XENIX 286 emulator is + * using the SI86SHRGN subcommand to set up XENIX small model shared data + * context switching support for a given XENIX shared data segment. In this + * case, the xsdbuf struct contains the start addr for the shared data in + * 386 space, followed by the start addr for the shared data in the 286 + * executable's private data. + * + * If the 'xsd_cmd' field is SI86SHR_SZ, the XENIX 286 emulator is using the + * SI86SHRGN subcommand to retrieve the size of an existing XENIX shared + * data segment. In this case, the xsdbuf struct contains the start addr + * for the shared data in 386 space. + * The size of the shared data segment starting at 'xsd_386vaddr' will + * be returned in the 'xsd_size' field by sysi86(). + */ + +#define SI86SHR_CP 0x1 /* SI86SHRGN used for XENIX sd context switch */ +#define SI86SHR_SZ 0x2 /* SI86SHRGN used to get XENIX sd seg size */ + +struct xsdbuf { + unsigned xsd_cmd; /* SI86SHRGN subcommand, either SI86SHR_CP */ + /* or SI86SHR_SZ. */ + char *xsd_386vaddr; /* Addr of "real" XENIX shared data seg in */ + /* the emulator. */ + union { + char *xsd_286vaddr; /* Addr of XENIX shared data seg */ + /* in the 286 data portion of the */ + /* emulator. */ + unsigned long xsd_size; /* Size of XENIX shared data seg */ + } xsd_un; +}; +/* End XENIX Support */ + +/* + * Cascade defines + */ + +#define C2 'E' +#define C3 'F' +#define C4 'G' +#define C6 'K' + +/* Enterprise IDNO defines */ +#define E8R1 'R' + +#ifndef _KERNEL +#ifdef __STDC__ +extern int sysi86(int, ...); +#else +extern int sysi86(); +#endif /* __STDC__ */ +#endif /* !_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSI86_H */ diff --git a/illumos-x86_64/usr/include/sys/sysinfo.h b/illumos-x86_64/usr/include/sys/sysinfo.h new file mode 100644 index 00000000..99ebd08a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysinfo.h @@ -0,0 +1,291 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_SYSINFO_H +#define _SYS_SYSINFO_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * System Information. + */ +#define CPU_IDLE 0 +#define CPU_USER 1 +#define CPU_KERNEL 2 +#define CPU_WAIT 3 +#define CPU_STATES 4 + +#define W_IO 0 +#define W_SWAP 1 +#define W_PIO 2 +#define W_STATES 3 + +typedef struct cpu_sysinfo { + uint_t cpu[CPU_STATES]; /* CPU utilization */ + uint_t wait[W_STATES]; /* CPU wait time breakdown */ + /* + * The two stats lwrite and bwrite are used by sar(1) to + * generate the write cache hit percentage (%wcache value). + * + * The value is calculated as follows (unless lwrite < 0.5 and + * then %wcache is coded to 100%): + * + * (lwrite - bwrite)/lwrite * 100.0 + * + * This calculation assumes that when a physical write occurs + * (bwrite incremented), that a logical write (lwrite + * incremented) has also occured. Note that a logical write + * (lwrite incremented) my occur on its own. + * + * Similar for lread/bread and %rcache. + */ + uint_t bread; /* physical block reads */ + uint_t bwrite; /* physical block writes (sync+async) */ + uint_t lread; /* logical block reads */ + uint_t lwrite; /* logical block writes */ + uint_t phread; /* raw I/O reads */ + uint_t phwrite; /* raw I/O writes */ + uint_t pswitch; /* context switches */ + uint_t trap; /* traps */ + uint_t intr; /* device interrupts */ + uint_t syscall; /* system calls */ + uint_t sysread; /* read() + readv() system calls */ + uint_t syswrite; /* write() + writev() system calls */ + uint_t sysfork; /* forks */ + uint_t sysvfork; /* vforks */ + uint_t sysexec; /* execs */ + uint_t readch; /* bytes read by rdwr() */ + uint_t writech; /* bytes written by rdwr() */ + uint_t rcvint; /* XXX: UNUSED */ + uint_t xmtint; /* XXX: UNUSED */ + uint_t mdmint; /* XXX: UNUSED */ + uint_t rawch; /* terminal input characters */ + uint_t canch; /* chars handled in canonical mode */ + uint_t outch; /* terminal output characters */ + uint_t msg; /* msg count (msgrcv()+msgsnd() calls) */ + uint_t sema; /* semaphore ops count (semop() calls) */ + uint_t namei; /* pathname lookups */ + uint_t ufsiget; /* ufs_iget() calls */ + uint_t ufsdirblk; /* directory blocks read */ + uint_t ufsipage; /* inodes taken with attached pages */ + uint_t ufsinopage; /* inodes taked with no attached pages */ + uint_t inodeovf; /* inode table overflows */ + uint_t fileovf; /* file table overflows */ + uint_t procovf; /* proc table overflows */ + uint_t intrthread; /* interrupts as threads (below clock) */ + uint_t intrblk; /* intrs blkd/prempted/released (swtch) */ + uint_t idlethread; /* times idle thread scheduled */ + uint_t inv_swtch; /* involuntary context switches */ + uint_t nthreads; /* thread_create()s */ + uint_t cpumigrate; /* cpu migrations by threads */ + uint_t xcalls; /* xcalls to other cpus */ + uint_t mutex_adenters; /* failed mutex enters (adaptive) */ + uint_t rw_rdfails; /* rw reader failures */ + uint_t rw_wrfails; /* rw writer failures */ + uint_t modload; /* times loadable module loaded */ + uint_t modunload; /* times loadable module unloaded */ + uint_t bawrite; /* physical block writes (async) */ +/* Following are gathered only under #ifdef STATISTICS in source */ + uint_t rw_enters; /* tries to acquire rw lock */ + uint_t win_uo_cnt; /* reg window user overflows */ + uint_t win_uu_cnt; /* reg window user underflows */ + uint_t win_so_cnt; /* reg window system overflows */ + uint_t win_su_cnt; /* reg window system underflows */ + uint_t win_suo_cnt; /* reg window system user overflows */ +} cpu_sysinfo_t; + +typedef struct sysinfo { /* (update freq) update action */ + uint_t updates; /* (1 sec) ++ */ + uint_t runque; /* (1 sec) += num runnable procs */ + uint_t runocc; /* (1 sec) ++ if num runnable procs > 0 */ + uint_t swpque; /* (1 sec) += num swapped procs */ + uint_t swpocc; /* (1 sec) ++ if num swapped procs > 0 */ + uint_t waiting; /* (1 sec) += jobs waiting for I/O */ +} sysinfo_t; + +typedef struct cpu_syswait { + int iowait; /* procs waiting for block I/O */ + int swap; /* XXX: UNUSED */ + int physio; /* XXX: UNUSED */ +} cpu_syswait_t; + +typedef struct cpu_vminfo { + uint_t pgrec; /* page reclaims (includes pageout) */ + uint_t pgfrec; /* page reclaims from free list */ + uint_t pgin; /* pageins */ + uint_t pgpgin; /* pages paged in */ + uint_t pgout; /* pageouts */ + uint_t pgpgout; /* pages paged out */ + uint_t swapin; /* swapins */ + uint_t pgswapin; /* pages swapped in */ + uint_t swapout; /* swapouts */ + uint_t pgswapout; /* pages swapped out */ + uint_t zfod; /* pages zero filled on demand */ + uint_t dfree; /* pages freed by daemon or auto */ + uint_t scan; /* pages examined by pageout daemon */ + uint_t rev; /* revolutions of the page daemon hand */ + uint_t hat_fault; /* minor page faults via hat_fault() */ + uint_t as_fault; /* minor page faults via as_fault() */ + uint_t maj_fault; /* major page faults */ + uint_t cow_fault; /* copy-on-write faults */ + uint_t prot_fault; /* protection faults */ + uint_t softlock; /* faults due to software locking req */ + uint_t kernel_asflt; /* as_fault()s in kernel addr space */ + uint_t pgrrun; /* times pager scheduled */ + uint_t execpgin; /* executable pages paged in */ + uint_t execpgout; /* executable pages paged out */ + uint_t execfree; /* executable pages freed */ + uint_t anonpgin; /* anon pages paged in */ + uint_t anonpgout; /* anon pages paged out */ + uint_t anonfree; /* anon pages freed */ + uint_t fspgin; /* fs pages paged in */ + uint_t fspgout; /* fs pages paged out */ + uint_t fsfree; /* fs pages free */ +} cpu_vminfo_t; + +typedef struct vminfo { /* (update freq) update action */ + uint64_t freemem; /* (1 sec) += freemem in pages */ + uint64_t swap_resv; /* (1 sec) += reserved swap in pages */ + uint64_t swap_alloc; /* (1 sec) += allocated swap in pages */ + uint64_t swap_avail; /* (1 sec) += unreserved swap in pages */ + uint64_t swap_free; /* (1 sec) += unallocated swap in pages */ + uint64_t updates; /* (1 sec) ++ */ +} vminfo_t; + +typedef struct cpu_stat { + uint_t __cpu_stat_lock[2]; /* 32-bit kstat compat. */ + cpu_sysinfo_t cpu_sysinfo; + cpu_syswait_t cpu_syswait; + cpu_vminfo_t cpu_vminfo; +} cpu_stat_t; + +typedef struct cpu_sys_stats { + uint64_t cpu_ticks_idle; /* CPU utilization */ + uint64_t cpu_ticks_user; + uint64_t cpu_ticks_kernel; + uint64_t cpu_ticks_wait; + uint64_t wait_ticks_io; /* CPU wait time breakdown */ + uint64_t bread; /* physical block reads */ + uint64_t bwrite; /* physical block writes (sync+async) */ + uint64_t lread; /* logical block reads */ + uint64_t lwrite; /* logical block writes */ + uint64_t phread; /* raw I/O Reads */ + uint64_t phwrite; /* raw I/O writes */ + uint64_t pswitch; /* context switches */ + uint64_t trap; /* traps */ + uint64_t intr[PIL_MAX]; /* device interrupts per PIL */ + uint64_t syscall; /* system calls */ + uint64_t sysread; /* read() + readv() system calls */ + uint64_t syswrite; /* write() + writev() system calls */ + uint64_t sysfork; /* forks */ + uint64_t sysvfork; /* vforks */ + uint64_t sysexec; /* execs */ + uint64_t readch; /* bytes read by rdwr() */ + uint64_t writech; /* bytes written by rdwr() */ + uint64_t rcvint; /* XXX: unused (mostly) */ + uint64_t xmtint; /* XXX: unused */ + uint64_t mdmint; /* XXX: unused */ + uint64_t rawch; /* terminal input characters */ + uint64_t canch; /* chars handled in canonical mode */ + uint64_t outch; /* terminal output characters */ + uint64_t msg; /* msg count (msgrcv() + msgsnd()) */ + uint64_t sema; /* semaphore ops count (semop()) */ + uint64_t namei; /* pathname lookups */ + uint64_t ufsiget; /* ufs_iget() calls */ + uint64_t ufsdirblk; /* directory blocks read */ + uint64_t ufsipage; /* inodes taken with attached pages */ + uint64_t ufsinopage; /* inodes taken with no attached pgs */ + uint64_t procovf; /* failed forks */ + uint64_t intrblk; /* ints blkd/prempted/rel'd (swtch) */ + uint64_t intrunpin; /* intr thread unpins pinned thread */ + uint64_t idlethread; /* times idle thread scheduled */ + uint64_t inv_swtch; /* involuntary context switches */ + uint64_t nthreads; /* thread_create()s */ + uint64_t cpumigrate; /* cpu migrations by threads */ + uint64_t xcalls; /* xcalls to other cpus */ + uint64_t mutex_adenters; /* failed mutex enters (adaptive) */ + uint64_t rw_rdfails; /* rw reader failures */ + uint64_t rw_wrfails; /* rw writer failures */ + uint64_t modload; /* times loadable module loaded */ + uint64_t modunload; /* times loadable module unloaded */ + uint64_t bawrite; /* physical block writes (async) */ + uint64_t iowait; /* count of waiters for block I/O */ +} cpu_sys_stats_t; + +typedef struct cpu_vm_stats { + uint64_t pgrec; /* page reclaims (includes pageout) */ + uint64_t pgfrec; /* page reclaims from free list */ + uint64_t pgin; /* pageins */ + uint64_t pgpgin; /* pages paged in */ + uint64_t pgout; /* pageouts */ + uint64_t pgpgout; /* pages paged out */ + uint64_t swapin; /* swapins */ + uint64_t pgswapin; /* pages swapped in */ + uint64_t swapout; /* swapouts */ + uint64_t pgswapout; /* pages swapped out */ + uint64_t zfod; /* pages zero filled on demand */ + uint64_t dfree; /* pages freed by daemon or auto */ + uint64_t scan; /* pages examined by pageout daemon */ + uint64_t rev; /* revolutions of page daemon hand */ + uint64_t hat_fault; /* minor page faults via hat_fault() */ + uint64_t as_fault; /* minor page faults via as_fault() */ + uint64_t maj_fault; /* major page faults */ + uint64_t cow_fault; /* copy-on-write faults */ + uint64_t prot_fault; /* protection faults */ + uint64_t softlock; /* faults due to software locking req */ + uint64_t kernel_asflt; /* as_fault()s in kernel addr space */ + uint64_t pgrrun; /* times pager scheduled */ + uint64_t execpgin; /* executable pages paged in */ + uint64_t execpgout; /* executable pages paged out */ + uint64_t execfree; /* executable pages freed */ + uint64_t anonpgin; /* anon pages paged in */ + uint64_t anonpgout; /* anon pages paged out */ + uint64_t anonfree; /* anon pages freed */ + uint64_t fspgin; /* fs pages paged in */ + uint64_t fspgout; /* fs pages paged out */ + uint64_t fsfree; /* fs pages free */ +} cpu_vm_stats_t; + +typedef struct cpu_stats { + cpu_sys_stats_t sys; + cpu_vm_stats_t vm; +} cpu_stats_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSINFO_H */ diff --git a/illumos-x86_64/usr/include/sys/syslog.h b/illumos-x86_64/usr/include/sys/syslog.h new file mode 100644 index 00000000..7395ab68 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/syslog.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2013 Gary Mills + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_SYSLOG_H +#define _SYS_SYSLOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Facility codes + */ +#define LOG_KERN (0<<3) /* kernel messages */ +#define LOG_USER (1<<3) /* random user-level messages */ +#define LOG_MAIL (2<<3) /* mail system */ +#define LOG_DAEMON (3<<3) /* system daemons */ +#define LOG_AUTH (4<<3) /* security/authorization messages */ +#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ +#define LOG_LPR (6<<3) /* line printer subsystem */ +#define LOG_NEWS (7<<3) /* netnews subsystem */ +#define LOG_UUCP (8<<3) /* uucp subsystem */ +#define LOG_ALTCRON (9<<3) /* BSD cron/at subsystem */ +#define LOG_AUTHPRIV (10<<3) /* BSD security/authorization messages */ +#define LOG_FTP (11<<3) /* file transfer subsystem */ +#define LOG_NTP (12<<3) /* network time subsystem */ +#define LOG_AUDIT (13<<3) /* audit subsystem */ +#define LOG_CONSOLE (14<<3) /* BSD console messages */ +#define LOG_CRON (15<<3) /* cron/at subsystem */ +#define LOG_LOCAL0 (16<<3) /* reserved for local use */ +#define LOG_LOCAL1 (17<<3) /* reserved for local use */ +#define LOG_LOCAL2 (18<<3) /* reserved for local use */ +#define LOG_LOCAL3 (19<<3) /* reserved for local use */ +#define LOG_LOCAL4 (20<<3) /* reserved for local use */ +#define LOG_LOCAL5 (21<<3) /* reserved for local use */ +#define LOG_LOCAL6 (22<<3) /* reserved for local use */ +#define LOG_LOCAL7 (23<<3) /* reserved for local use */ + +#define LOG_NFACILITIES 24 /* maximum number of facilities */ +#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ + +/* + * Priorities (these are ordered) + */ +#define LOG_EMERG 0 /* system is unusable */ +#define LOG_ALERT 1 /* action must be taken immediately */ +#define LOG_CRIT 2 /* critical conditions */ +#define LOG_ERR 3 /* error conditions */ +#define LOG_WARNING 4 /* warning conditions */ +#define LOG_NOTICE 5 /* normal but signification condition */ +#define LOG_INFO 6 /* informational */ +#define LOG_DEBUG 7 /* debug-level messages */ + +#define LOG_PRIMASK 0x0007 /* mask to extract priority part (internal) */ + +/* + * arguments to setlogmask. + */ +#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ +#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ + +/* + * Option flags for openlog. + * + * LOG_ODELAY no longer does anything; LOG_NDELAY is the + * inverse of what it used to be. + */ +#define LOG_PID 0x01 /* log the pid with each message */ +#define LOG_CONS 0x02 /* log on the console if errors in sending */ +#define LOG_ODELAY 0x04 /* delay open until syslog() is called */ +#define LOG_NDELAY 0x08 /* don't delay open */ +#define LOG_NOWAIT 0x10 /* if forking to log on console, don't wait() */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSLOG_H */ diff --git a/illumos-x86_64/usr/include/sys/sysmacros.h b/illumos-x86_64/usr/include/sys/sysmacros.h new file mode 100644 index 00000000..1540840a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/sysmacros.h @@ -0,0 +1,397 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * + * Copyright 2018 Joyent Inc. + */ + +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Some macros for units conversion + */ +/* + * Disk blocks (sectors) and bytes. + */ +#define dtob(DD) ((DD) << DEV_BSHIFT) +#define btod(BB) (((BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) +#define btodt(BB) ((BB) >> DEV_BSHIFT) +#define lbtod(BB) (((offset_t)(BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) + +/* common macros */ +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) ((a) < (b) ? (b) : (a)) +#endif +#ifndef ABS +#define ABS(a) ((a) < 0 ? -(a) : (a)) +#endif +#ifndef SIGNOF +#define SIGNOF(a) ((a) < 0 ? -1 : (a) > 0) +#endif + +#ifndef __DECONST +#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var)) +#endif + +#ifdef _KERNEL + +/* + * Convert a single byte to/from binary-coded decimal (BCD). + */ +extern unsigned char byte_to_bcd[256]; +extern unsigned char bcd_to_byte[256]; + +#define BYTE_TO_BCD(x) byte_to_bcd[(x) & 0xff] +#define BCD_TO_BYTE(x) bcd_to_byte[(x) & 0xff] + +#endif /* _KERNEL */ + +/* + * WARNING: The device number macros defined here should not be used by device + * drivers or user software. Device drivers should use the device functions + * defined in the DDI/DKI interface (see also ddi.h). Application software + * should make use of the library routines available in makedev(3). A set of + * new device macros are provided to operate on the expanded device number + * format supported in SVR4. Macro versions of the DDI device functions are + * provided for use by kernel proper routines only. Macro routines bmajor(), + * major(), minor(), emajor(), eminor(), and makedev() will be removed or + * their definitions changed at the next major release following SVR4. + */ + +#define O_BITSMAJOR 7 /* # of SVR3 major device bits */ +#define O_BITSMINOR 8 /* # of SVR3 minor device bits */ +#define O_MAXMAJ 0x7f /* SVR3 max major value */ +#define O_MAXMIN 0xff /* SVR3 max minor value */ + + +#define L_BITSMAJOR32 14 /* # of SVR4 major device bits */ +#define L_BITSMINOR32 18 /* # of SVR4 minor device bits */ +#define L_MAXMAJ32 0x3fff /* SVR4 max major value */ +#define L_MAXMIN32 0x3ffff /* MAX minor for 3b2 software drivers. */ + /* For 3b2 hardware devices the minor is */ + /* restricted to 256 (0-255) */ + +#ifdef _LP64 +#define L_BITSMAJOR 32 /* # of major device bits in 64-bit Solaris */ +#define L_BITSMINOR 32 /* # of minor device bits in 64-bit Solaris */ +#define L_MAXMAJ 0xfffffffful /* max major value */ +#define L_MAXMIN 0xfffffffful /* max minor value */ +#else +#define L_BITSMAJOR L_BITSMAJOR32 +#define L_BITSMINOR L_BITSMINOR32 +#define L_MAXMAJ L_MAXMAJ32 +#define L_MAXMIN L_MAXMIN32 +#endif + +#ifdef _KERNEL + +/* major part of a device internal to the kernel */ + +#define major(x) (major_t)((((unsigned)(x)) >> O_BITSMINOR) & O_MAXMAJ) +#define bmajor(x) (major_t)((((unsigned)(x)) >> O_BITSMINOR) & O_MAXMAJ) + +/* get internal major part of expanded device number */ + +#define getmajor(x) (major_t)((((dev_t)(x)) >> L_BITSMINOR) & L_MAXMAJ) + +/* minor part of a device internal to the kernel */ + +#define minor(x) (minor_t)((x) & O_MAXMIN) + +/* get internal minor part of expanded device number */ + +#define getminor(x) (minor_t)((x) & L_MAXMIN) + +#else /* _KERNEL */ + +/* major part of a device external from the kernel (same as emajor below) */ + +#define major(x) (major_t)((((unsigned)(x)) >> O_BITSMINOR) & O_MAXMAJ) + +/* minor part of a device external from the kernel (same as eminor below) */ + +#define minor(x) (minor_t)((x) & O_MAXMIN) + +#endif /* _KERNEL */ + +/* create old device number */ + +#define makedev(x, y) (unsigned short)(((x) << O_BITSMINOR) | ((y) & O_MAXMIN)) + +/* make an new device number */ + +#define makedevice(x, y) (dev_t)(((dev_t)(x) << L_BITSMINOR) | ((y) & L_MAXMIN)) + + +/* + * emajor() allows kernel/driver code to print external major numbers + * eminor() allows kernel/driver code to print external minor numbers + */ + +#define emajor(x) \ + (major_t)(((unsigned int)(x) >> O_BITSMINOR) > O_MAXMAJ) ? \ + NODEV : (((unsigned int)(x) >> O_BITSMINOR) & O_MAXMAJ) + +#define eminor(x) \ + (minor_t)((x) & O_MAXMIN) + +/* + * get external major and minor device + * components from expanded device number + */ +#define getemajor(x) (major_t)((((dev_t)(x) >> L_BITSMINOR) > L_MAXMAJ) ? \ + NODEV : (((dev_t)(x) >> L_BITSMINOR) & L_MAXMAJ)) +#define geteminor(x) (minor_t)((x) & L_MAXMIN) + +/* + * These are versions of the kernel routines for compressing and + * expanding long device numbers that don't return errors. + */ +#if (L_BITSMAJOR32 == L_BITSMAJOR) && (L_BITSMINOR32 == L_BITSMINOR) + +#define DEVCMPL(x) (x) +#define DEVEXPL(x) (x) + +#else + +#define DEVCMPL(x) \ + (dev32_t)((((x) >> L_BITSMINOR) > L_MAXMAJ32 || \ + ((x) & L_MAXMIN) > L_MAXMIN32) ? NODEV32 : \ + ((((x) >> L_BITSMINOR) << L_BITSMINOR32) | ((x) & L_MAXMIN32))) + +#define DEVEXPL(x) \ + (((x) == NODEV32) ? NODEV : \ + makedevice(((x) >> L_BITSMINOR32) & L_MAXMAJ32, (x) & L_MAXMIN32)) + +#endif /* L_BITSMAJOR32 ... */ + +/* convert to old (SVR3.2) dev format */ + +#define cmpdev(x) \ + (o_dev_t)((((x) >> L_BITSMINOR) > O_MAXMAJ || \ + ((x) & L_MAXMIN) > O_MAXMIN) ? NODEV : \ + ((((x) >> L_BITSMINOR) << O_BITSMINOR) | ((x) & O_MAXMIN))) + +/* convert to new (SVR4) dev format */ + +#define expdev(x) \ + (dev_t)(((dev_t)(((x) >> O_BITSMINOR) & O_MAXMAJ) << L_BITSMINOR) | \ + ((x) & O_MAXMIN)) + +/* + * Macro for checking power of 2 address alignment. + */ +#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) + +/* + * Macros for counting and rounding. + */ +#define howmany(x, y) (((x)+((y)-1))/(y)) +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) + +/* + * Macro to determine if value is a power of 2 + */ +#define ISP2(x) (((x) & ((x) - 1)) == 0) + +/* + * Macros for various sorts of alignment and rounding. The "align" must + * be a power of 2. Often times it is a block, sector, or page. + */ + +/* + * return x rounded down to an align boundary + * eg, P2ALIGN(1200, 1024) == 1024 (1*align) + * eg, P2ALIGN(1024, 1024) == 1024 (1*align) + * eg, P2ALIGN(0x1234, 0x100) == 0x1200 (0x12*align) + * eg, P2ALIGN(0x5600, 0x100) == 0x5600 (0x56*align) + */ +#define P2ALIGN(x, align) ((x) & -(align)) + +/* + * return x % (mod) align + * eg, P2PHASE(0x1234, 0x100) == 0x34 (x-0x12*align) + * eg, P2PHASE(0x5600, 0x100) == 0x00 (x-0x56*align) + */ +#define P2PHASE(x, align) ((x) & ((align) - 1)) + +/* + * return how much space is left in this block (but if it's perfectly + * aligned, return 0). + * eg, P2NPHASE(0x1234, 0x100) == 0xcc (0x13*align-x) + * eg, P2NPHASE(0x5600, 0x100) == 0x00 (0x56*align-x) + */ +#define P2NPHASE(x, align) (-(x) & ((align) - 1)) + +/* + * return x rounded up to an align boundary + * eg, P2ROUNDUP(0x1234, 0x100) == 0x1300 (0x13*align) + * eg, P2ROUNDUP(0x5600, 0x100) == 0x5600 (0x56*align) + */ +#define P2ROUNDUP(x, align) (-(-(x) & -(align))) + +/* + * return the ending address of the block that x is in + * eg, P2END(0x1234, 0x100) == 0x12ff (0x13*align - 1) + * eg, P2END(0x5600, 0x100) == 0x56ff (0x57*align - 1) + */ +#define P2END(x, align) (-(~(x) & -(align))) + +/* + * return x rounded up to the next phase (offset) within align. + * phase should be < align. + * eg, P2PHASEUP(0x1234, 0x100, 0x10) == 0x1310 (0x13*align + phase) + * eg, P2PHASEUP(0x5600, 0x100, 0x10) == 0x5610 (0x56*align + phase) + */ +#define P2PHASEUP(x, align, phase) ((phase) - (((phase) - (x)) & -(align))) + +/* + * return TRUE if adding len to off would cause it to cross an align + * boundary. + * eg, P2BOUNDARY(0x1234, 0xe0, 0x100) == TRUE (0x1234 + 0xe0 == 0x1314) + * eg, P2BOUNDARY(0x1234, 0x50, 0x100) == FALSE (0x1234 + 0x50 == 0x1284) + */ +#define P2BOUNDARY(off, len, align) \ + (((off) ^ ((off) + (len) - 1)) > (align) - 1) + +/* + * Return TRUE if they have the same highest bit set. + * eg, P2SAMEHIGHBIT(0x1234, 0x1001) == TRUE (the high bit is 0x1000) + * eg, P2SAMEHIGHBIT(0x1234, 0x3010) == FALSE (high bit of 0x3010 is 0x2000) + */ +#define P2SAMEHIGHBIT(x, y) (((x) ^ (y)) < ((x) & (y))) + +/* + * Typed version of the P2* macros. These macros should be used to ensure + * that the result is correctly calculated based on the data type of (x), + * which is passed in as the last argument, regardless of the data + * type of the alignment. For example, if (x) is of type uint64_t, + * and we want to round it up to a page boundary using "PAGESIZE" as + * the alignment, we can do either + * P2ROUNDUP(x, (uint64_t)PAGESIZE) + * or + * P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t) + */ +#define P2ALIGN_TYPED(x, align, type) \ + ((type)(x) & -(type)(align)) +#define P2PHASE_TYPED(x, align, type) \ + ((type)(x) & ((type)(align) - 1)) +#define P2NPHASE_TYPED(x, align, type) \ + (-(type)(x) & ((type)(align) - 1)) +#define P2ROUNDUP_TYPED(x, align, type) \ + (-(-(type)(x) & -(type)(align))) +#define P2END_TYPED(x, align, type) \ + (-(~(type)(x) & -(type)(align))) +#define P2PHASEUP_TYPED(x, align, phase, type) \ + ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align))) +#define P2CROSS_TYPED(x, y, align, type) \ + (((type)(x) ^ (type)(y)) > (type)(align) - 1) +#define P2SAMEHIGHBIT_TYPED(x, y, type) \ + (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y))) + +/* + * Macros to atomically increment/decrement a variable. mutex and var + * must be pointers. + */ +#define INCR_COUNT(var, mutex) mutex_enter(mutex), (*(var))++, mutex_exit(mutex) +#define DECR_COUNT(var, mutex) mutex_enter(mutex), (*(var))--, mutex_exit(mutex) + +/* + * Macros to declare bitfields - the order in the parameter list is + * Low to High - that is, declare bit 0 first. We only support 8-bit bitfields + * because if a field crosses a byte boundary it's not likely to be meaningful + * without reassembly in its nonnative endianness. + */ +#if defined(_BIT_FIELDS_LTOH) +#define DECL_BITFIELD2(_a, _b) \ + uint8_t _a, _b +#define DECL_BITFIELD3(_a, _b, _c) \ + uint8_t _a, _b, _c +#define DECL_BITFIELD4(_a, _b, _c, _d) \ + uint8_t _a, _b, _c, _d +#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \ + uint8_t _a, _b, _c, _d, _e +#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \ + uint8_t _a, _b, _c, _d, _e, _f +#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \ + uint8_t _a, _b, _c, _d, _e, _f, _g +#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \ + uint8_t _a, _b, _c, _d, _e, _f, _g, _h +#elif defined(_BIT_FIELDS_HTOL) +#define DECL_BITFIELD2(_a, _b) \ + uint8_t _b, _a +#define DECL_BITFIELD3(_a, _b, _c) \ + uint8_t _c, _b, _a +#define DECL_BITFIELD4(_a, _b, _c, _d) \ + uint8_t _d, _c, _b, _a +#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \ + uint8_t _e, _d, _c, _b, _a +#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \ + uint8_t _f, _e, _d, _c, _b, _a +#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \ + uint8_t _g, _f, _e, _d, _c, _b, _a +#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \ + uint8_t _h, _g, _f, _e, _d, _c, _b, _a +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ + +#if !defined(ARRAY_SIZE) +#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0])) +#endif + +/* + * Add a value to a uint64_t that saturates at UINT64_MAX instead of wrapping + * around. + */ +#define UINT64_OVERFLOW_ADD(val, add) \ + ((val) > ((val) + (add)) ? (UINT64_MAX) : ((val) + (add))) + +/* + * Convert to an int64, saturating at INT64_MAX. + */ +#define UINT64_OVERFLOW_TO_INT64(uval) \ + (((uval) > INT64_MAX) ? INT64_MAX : (int64_t)(uval)) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSMACROS_H */ diff --git a/illumos-x86_64/usr/include/sys/systeminfo.h b/illumos-x86_64/usr/include/sys/systeminfo.h new file mode 100644 index 00000000..951d799a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/systeminfo.h @@ -0,0 +1,113 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2017 RackTop Systems. + * Copyright 2020 Oxide Computer Company + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_SYSTEMINFO_H +#define _SYS_SYSTEMINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +extern char architecture[]; +extern char architecture_32[]; +extern char hw_serial[]; /* machine's 32-bit hostid; a decimal string */ +extern char hw_provider[]; +extern char srpc_domain[]; +extern char platform[]; +#endif /* _KERNEL || _FAKE_KERNEL */ + +/* + * Commands to sysinfo(2) + * + * Values for sysinfo(2) commands are to be assigned by the following + * algorithm: + * + * 1 - 256 Unix International assigned numbers for `get' style commands. + * 257 - 512 Unix International assigned numbers for `set' style commands + * where the value is selected to be the value for the + * corresponding `get' command plus 256. + * 513 - 768 illumos-defined `get' style commands. + * 769 - 1024 illumos-defined `set' style commands where the value is + * selected to be the value for the corresponding `get' command + * plus 256. + * + * These values have be registered + * with Unix International can't be corrected now. The status of a command + * as published or unpublished does not alter the algorithm. + */ + +/* UI defined `get' commands (1-256) */ +#define SI_SYSNAME 1 /* return name of operating system */ +#define SI_HOSTNAME 2 /* return name of node */ +#define SI_RELEASE 3 /* return release of operating system */ +#define SI_VERSION 4 /* return version field of utsname */ +#define SI_MACHINE 5 /* return kind of machine */ +#define SI_ARCHITECTURE 6 /* return instruction set arch */ +#define SI_HW_SERIAL 7 /* return hardware serial number */ +#define SI_HW_PROVIDER 8 /* return hardware manufacturer */ +#define SI_SRPC_DOMAIN 9 /* return secure RPC domain */ + +/* UI defined `set' commands (257-512) */ +#define SI_SET_HOSTNAME 258 /* set name of node */ +#define SI_SET_SRPC_DOMAIN 265 /* set secure RPC domain */ + +/* illumos-defined `get' commands (513-768) */ +#define SI_PLATFORM 513 /* return platform identifier */ +#define SI_ISALIST 514 /* return supported isa list */ +#define SI_DHCP_CACHE 515 /* return kernel-cached DHCPACK */ +#define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */ +#define SI_ARCHITECTURE_64 517 /* basic 64-bit SI_ARCHITECTURE */ +#define SI_ARCHITECTURE_K 518 /* kernel SI_ARCHITECTURE equivalent */ +#define SI_ARCHITECTURE_NATIVE 519 /* SI_ARCHITECTURE of the caller */ +#define SI_ADDRESS_WIDTH 520 /* number of bits in native address */ + +/* illumos-defined `set' commands (769-1024) (none currently assigned) */ + + +#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */ +#define HW_HOSTID_LEN 11 /* minimum buffer size needed */ + /* to hold a decimal or hex */ + /* hostid string */ +#define DOM_NM_LN 64 /* maximum length of domain */ + /* name */ + +#if !defined(_KERNEL) +int sysinfo(int, char *, long); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSTEMINFO_H */ diff --git a/illumos-x86_64/usr/include/sys/systm.h b/illumos-x86_64/usr/include/sys/systm.h new file mode 100644 index 00000000..ebd2ae35 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/systm.h @@ -0,0 +1,552 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2016 Nexenta Systems, Inc. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_SYSTM_H +#define _SYS_SYSTM_H + +#if defined(_STANDALONE) +#include +#include +#else +#include +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_STANDALONE) +/* + * The pc_t is the type of the kernel's program counter. In general, a + * pc_t is a uintptr_t -- except for a sparcv9 kernel, in which case all + * instruction text is below 4G, and a pc_t is thus a uint32_t. + */ +#ifdef __sparcv9 +typedef uint32_t pc_t; +#else +typedef uintptr_t pc_t; +#endif + +/* + * Random set of variables used by more than one routine. + */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#include +#include +#include +#include + +extern int hz; /* system clock rate */ +extern struct vnode *rootdir; /* pointer to vnode of root directory */ +extern struct vnode *devicesdir; /* pointer to /devices vnode */ +extern int interrupts_unleashed; /* set after the spl0() in main() */ + +extern char runin; /* scheduling flag */ +extern char runout; /* scheduling flag */ +extern char wake_sched; /* causes clock to wake swapper on next tick */ +extern char wake_sched_sec; /* causes clock to wake swapper after a sec */ + +extern pgcnt_t maxmem; /* max available memory (pages) */ +extern pgcnt_t physmem; /* physical memory (pages) on this CPU */ +extern pfn_t physmax; /* highest numbered physical page present */ +extern pgcnt_t physinstalled; /* physical pages including PROM/boot use */ + +extern caddr_t s_text; /* start of kernel text segment */ +extern caddr_t e_text; /* end of kernel text segment */ +extern caddr_t s_data; /* start of kernel text segment */ +extern caddr_t e_data; /* end of kernel text segment */ + +extern pgcnt_t availrmem; /* Available resident (not swapable) */ + /* memory in pages. */ +extern pgcnt_t availrmem_initial; /* initial value of availrmem */ +extern pgcnt_t segspt_minfree; /* low water mark for availrmem in seg_spt */ +extern pgcnt_t freemem; /* Current free memory. */ + +extern dev_t rootdev; /* device of the root */ +extern struct vnode *rootvp; /* vnode of root device */ +extern boolean_t root_is_ramdisk; /* root is boot_archive ramdisk */ +extern uint32_t ramdisk_size; /* (KB) set only for sparc netboots */ +extern char *volatile panicstr; /* panic string pointer */ +extern va_list panicargs; /* panic arguments */ +extern volatile int quiesce_active; /* quiesce(9E) is in progress */ + +extern int rstchown; /* 1 ==> restrictive chown(2) semantics */ +extern int klustsize; + +extern int abort_enable; /* Platform input-device abort policy */ + +extern int audit_active; /* Solaris Auditing module state */ + +extern int avenrun[]; /* array of load averages */ + +extern char *isa_list; /* For sysinfo's isalist option */ + +extern int noexec_user_stack; /* patchable via /etc/system */ +extern int noexec_user_stack_log; /* patchable via /etc/system */ + +/* + * Use NFS client operations in the global zone only. Under contract with + * admin/install; do not change without coordinating with that consolidation. + */ +extern int nfs_global_client_only; + +extern void report_stack_exec(proc_t *, caddr_t); + +extern void startup(void); +extern void clkstart(void); +extern void post_startup(void); +extern void kern_setup1(void); +extern void ka_init(void); +extern void nodename_set(void); + +/* + * for tod fault detection + */ +enum tod_fault_type { + TOD_REVERSED = 0, + TOD_STALLED, + TOD_JUMPED, + TOD_RATECHANGED, + TOD_RDONLY, + TOD_NOFAULT +}; + +#define TOD_GET_FAILED 0x1 /* TOD could not be read */ +#define TOD_SET_DONE 0x2 /* TOD has been modified */ +#define TOD_CPR_RESUME_DONE 0x4 /* CPR resume has occurred */ +#define TOD_DR_RESUME_DONE 0x8 /* DR resume has occurred */ + +extern time_t tod_validate(time_t); +extern void tod_status_set(int); +extern void tod_status_clear(int); +extern void plat_tod_fault(enum tod_fault_type); + +#ifndef _LP64 +#ifndef min +int min(int, int); +#endif + +#ifndef max +int max(int, int); +#endif + +uint_t umin(uint_t, uint_t); +uint_t umax(uint_t, uint_t); +#endif /* !_LP64 */ +int grow(caddr_t); +int grow_internal(caddr_t, uint_t); +int brk_internal(caddr_t, uint_t); +typedef uint64_t callout_id_t; +timeout_id_t timeout(void (*)(void *), void *, clock_t); +timeout_id_t realtime_timeout(void (*)(void *), void *, clock_t); +clock_t untimeout(timeout_id_t); +/* + * The last argument to timeout_generic() is flags. See callo.h for the + * flags definitions. + */ +callout_id_t timeout_generic(int, void (*)(void *), void *, hrtime_t, hrtime_t, + int); +callout_id_t timeout_default(void (*)(void *), void *, clock_t); +callout_id_t realtime_timeout_default(void (*)(void *), void *, clock_t); +/* + * The last argument to untimeout_generic() is flags. See callout.c for the + * use. + */ +hrtime_t untimeout_generic(callout_id_t, int); +clock_t untimeout_default(callout_id_t, int); +void delay(clock_t); +int delay_sig(clock_t); +void delay_random(clock_t); +int nodev(); +int nulldev(); +major_t getudev(void); +int cmpldev(dev32_t *, dev_t); +dev_t expldev(dev32_t); +int bcmp(const void *, const void *, size_t) __PURE; +int stoi(char **); +void numtos(ulong_t, char *); +char *kmem_asprintf(const char *fmt, ...); +int strident_valid(const char *); +void strident_canon(char *, size_t); +int getsubopt(char **optionsp, char * const *tokens, char **valuep); +char *append_subopt(const char *, size_t, char *, const char *); +#ifndef _FAKE_KERNEL +/* conflicts with libc definition */ +int ffs(uintmax_t); +#endif +int copyin(const void *, void *, size_t); +void copyin_noerr(const void *, void *, size_t); +int xcopyin(const void *, void *, size_t); +int xcopyin_nta(const void *, void *, size_t, int); +int copyout(const void *, void *, size_t); +void copyout_noerr(const void *, void *, size_t); +int xcopyout(const void *, void *, size_t); +int xcopyout_nta(const void *, void *, size_t, int); +int copyinstr(const char *, char *, size_t, size_t *); +int copyinstr_noerr(const char *, char *, size_t, size_t *); +int copyoutstr(const char *, char *, size_t, size_t *); +int copyoutstr_noerr(const char *, char *, size_t, size_t *); +int copystr(const char *, char *, size_t, size_t *); +void ucopy(const void *, void *, size_t); +void ucopystr(const char *, char *, size_t, size_t *); +void pgcopy(const void *, void *, size_t); +void ovbcopy(const void *, void *, size_t); +void uzero(void *, size_t); +int kcopy(const void *, void *, size_t); +int kcopy_nta(const void *, void *, size_t, int); +int kzero(void *, size_t); + +int fuword8(const void *, uint8_t *); +int fuword16(const void *, uint16_t *); +int fuword32(const void *, uint32_t *); +int fulword(const void *, ulong_t *); +void fuword8_noerr(const void *, uint8_t *); +void fuword16_noerr(const void *, uint16_t *); +void fuword32_noerr(const void *, uint32_t *); +void fulword_noerr(const void *, ulong_t *); + +#ifdef _LP64 +int fuword64(const void *, uint64_t *); +void fuword64_noerr(const void *, uint64_t *); +#endif + +int subyte(void *, uint8_t); +int suword8(void *, uint8_t); +int suword16(void *, uint16_t); +int suword32(void *, uint32_t); +int sulword(void *, ulong_t); +void subyte_noerr(void *, uint8_t); +void suword8_noerr(void *, uint8_t); +void suword16_noerr(void *, uint16_t); +void suword32_noerr(void *, uint32_t); +void sulword_noerr(void *, ulong_t); + +#ifdef _LP64 +int suword64(void *, uint64_t); +void suword64_noerr(void *, uint64_t); +#endif + +#if !defined(_BOOT) && !defined(_FAKE_KERNEL) +/* conflicts with libc definition */ +int setjmp(label_t *) __RETURNS_TWICE; +extern void longjmp(label_t *) + __NORETURN; +#pragma unknown_control_flow(setjmp) +#endif + +void prefetch_read_once(void *); +void prefetch_write_once(void *); +void prefetch_read_many(void *); +void prefetch_write_many(void *); +caddr_t caller(void); +caddr_t callee(void); +int getpcstack(pc_t *, int); +int on_fault(label_t *) __RETURNS_TWICE; +void no_fault(void); +void halt(char *); +int scanc(size_t, uchar_t *, uchar_t *, uchar_t); +int movtuc(size_t, uchar_t *, uchar_t *, uchar_t *); +int splr(int); +int splhigh(void); +int splhi(void); +int splzs(void); +int spl0(void); +int spl6(void); +int spl7(void); +int spl8(void); +void splx(int); +void set_base_spl(void); +int __ipltospl(int); +int spl_xcall(void); + +void softcall_init(void); +void softcall(void (*)(void *), void *); +void softint(void); + +extern void sync_icache(caddr_t, uint_t); +extern void sync_data_memory(caddr_t, size_t); +extern void hot_patch_kernel_text(caddr_t, uint32_t, uint_t); + +void _insque(caddr_t, caddr_t); +void _remque(caddr_t); + +/* casts to keep lint happy */ +#define insque(q, p) _insque((caddr_t)q, (caddr_t)p) +#define remque(q) _remque((caddr_t)q) + +#pragma unknown_control_flow(on_fault) + +struct timeval; +extern void uniqtime(struct timeval *); +struct timeval32; +extern void uniqtime32(struct timeval32 *); + +uint_t page_num_pagesizes(void); +size_t page_get_pagesize(uint_t n); + +extern int maxusers; +extern int pidmax; + +extern void param_preset(void); +extern void param_calc(int); +extern void param_init(void); +extern void param_check(void); + +/* + * It is easy to run afoul of integer promotion bugs when writing checks for + * potential overflow. These helpers are provided to make the right thing easy. + * + * They return a "bool-y" int: non-zero for if the addition overflows + */ +static inline int +sum_overflows_u16(uint16_t a, uint16_t b) +{ + return (((uint32_t)a + (uint32_t)b) > UINT16_MAX); +} + +static inline int +sum_overflows_hrtime(hrtime_t a, hrtime_t b) +{ + return (((unsigned long long)a + (unsigned long long)b) < + (unsigned long long)a); +} + +static inline int +sum_overflows_off(off_t a, off_t b) +{ + return (((unsigned long long)a + (unsigned long long)b) < + (unsigned long long)a); +} + +#endif /* _KERNEL */ + +/* + * Structure of the system-entry table. + * + * Changes to struct sysent should maintain binary compatibility with + * loadable system calls, although the interface is currently private. + * + * This means it should only be expanded on the end, and flag values + * should not be reused. + * + * It is desirable to keep the size of this struct a power of 2 for quick + * indexing. + */ +struct sysent { + char sy_narg; /* total number of arguments */ +#ifdef _LP64 + unsigned short sy_flags; /* various flags as defined below */ +#else + unsigned char sy_flags; /* various flags as defined below */ +#endif + int (*sy_call)(); /* argp, rvalp-style handler */ + krwlock_t *sy_lock; /* lock for loadable system calls */ + int64_t (*sy_callc)(); /* C-style call hander or wrapper */ +}; + +extern struct sysent sysent[]; +#ifdef _SYSCALL32_IMPL +extern struct sysent sysent32[]; +#endif + +extern struct sysent nosys_ent; /* entry for invalid system call */ + +#define NSYSCALL 256 /* number of system calls */ + +#define LOADABLE_SYSCALL(s) (s->sy_flags & SE_LOADABLE) +#define LOADED_SYSCALL(s) (s->sy_flags & SE_LOADED) + +/* + * sy_flags values + * Values 1, 2, and 4 were used previously for SETJUMP, ASYNC, and IOSYS. + */ +#define SE_32RVAL1 0x0 /* handler returns int32_t in rval1 */ +#define SE_32RVAL2 0x1 /* handler returns int32_t in rval2 */ +#define SE_64RVAL 0x2 /* handler returns int64_t in rvals */ +#define SE_RVAL_MASK 0x3 /* mask of rval_t bits */ + +#define SE_LOADABLE 0x08 /* syscall is loadable */ +#define SE_LOADED 0x10 /* syscall is completely loaded */ +#define SE_NOUNLOAD 0x20 /* syscall never needs unload */ +#define SE_ARGC 0x40 /* syscall takes C-style args */ + +/* + * Structure of the return-value parameter passed by reference to + * system entries. + */ +union rval { + struct { + int r_v1; + int r_v2; + } r_v; + off_t r_off; + offset_t r_offset; + time_t r_time; + int64_t r_vals; +}; +#define r_val1 r_v.r_v1 +#define r_val2 r_v.r_v2 + +typedef union rval rval_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern void reset_syscall_args(void); +extern int save_syscall_args(void); +extern uint_t get_syscall_args(klwp_t *lwp, long *argp, int *nargsp); +#ifdef _SYSCALL32_IMPL +extern uint_t get_syscall32_args(klwp_t *lwp, int *argp, int *nargp); +#endif + +extern uint_t set_errno(uint_t error); +#pragma rarely_called(set_errno) + +extern int64_t syscall_ap(void); +extern int64_t loadable_syscall(long, long, long, long, long, long, long, long); +extern int64_t nosys(void); +extern int nosys32(void); + +extern void swtch(void); + +extern uint_t kcpc_key; /* TSD key for performance counter context */ + +/* + * initname holds the path to init and is used as a point of rendezvous + * between krtld (which processes the boot arguments) and the kernel. + */ +#define INITNAME_SZ 32 +extern char initname[INITNAME_SZ]; + +/* + * initargs holds the arguments to init (such as -v, -s, -r, -m verbose) and + * is a point of rendezvous between krtld (which processes the boot arguments) + * and the kernel. + */ +extern char initargs[BOOTARGS_MAX]; + +extern int exec_init(const char *, const char *); +extern int start_init_common(void); + +#endif /* _KERNEL */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) || defined(_BOOT) + +size_t strlcat(char *, const char *, size_t); +size_t strlen(const char *) __PURE; +char *strcat(char *, const char *); +char *strncat(char *, const char *, size_t); +char *strcpy(char *, const char *); +char *strncpy(char *, const char *, size_t); + +extern size_t strlcpy(char *, const char *, size_t); +extern size_t strspn(const char *, const char *); +extern size_t strcspn(const char *, const char *); +extern char *strdup(const char *); +extern void strfree(char *); + +/* Need to be consistent with C++ definitions */ +#if __cplusplus >= 199711L +extern const char *strchr(const char *, int); +#ifndef _STRCHR_INLINE +#define _STRCHR_INLINE +extern "C++" { + inline char *strchr(char *__s, int __c) { + return (char *)strchr((const char *)__s, __c); + } +} +#endif /* _STRCHR_INLINE */ +extern const char *strrchr(const char *, int); +#ifndef _STRRCHR_INLINE +#define _STRRCHR_INLINE +extern "C++" { + inline char *strrchr(char *__s, int __c) { + return (char *)strrchr((const char *)__s, __c); + } +} +#endif /* _STRRCHR_INLINE */ +extern const char *strstr(const char *, const char *); +#ifndef _STRSTR_INLINE +#define _STRSTR_INLINE +extern "C++" { + inline char *strstr(char *__s1, const char *__s2) { + return (char *)strstr((const char *)__s1, __s2); + } +} +#endif /* _STRSTR_INLINE */ +#else /* __cplusplus >= 199711L */ +char *strchr(const char *, int); +char *strrchr(const char *, int); +char *strstr(const char *, const char *); +#endif /* __cplusplus >= 199711L */ +char *strnrchr(const char *, int, size_t); +int strcmp(const char *, const char *) __PURE; +int strncmp(const char *, const char *, size_t) __PURE; +int strcasecmp(const char *, const char *) __PURE; +int strncasecmp(const char *, const char *, size_t) __PURE; +/* Need to be consistent with C++ definitions */ +#if __cplusplus >= 199711L +extern const char *strpbrk(const char *, const char *); +#ifndef _STRPBRK_INLINE +#define _STRPBRK_INLINE +extern "C++" { + inline char *strpbrk(char *__s1, const char *__s2) { + return (char *)strpbrk((const char *)__s1, __s2); + } +} +#endif /* _STRPBRK_INLINE */ +#else /* __cplusplus >= 199711L */ +char *strpbrk(const char *, const char *); +#endif /* __cplusplus >= 199711L */ +void bcopy(const void *, void *, size_t); +void bzero(void *, size_t); + +extern void *memset(void *, int, size_t); +extern void *memcpy(void *, const void *, size_t); +extern void *memmove(void *, const void *, size_t); +extern int memcmp(const void *, const void *, size_t); + +#ifdef __lint +extern int __lintzero; /* for spoofing lint */ +#else /* __lint */ +#define __lintzero 0 +#endif /* __lint */ +#endif /* _KERNEL || _BOOT */ +#endif /* !_STANDALONE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSTM_H */ diff --git a/illumos-x86_64/usr/include/sys/t_kuser.h b/illumos-x86_64/usr/include/sys/t_kuser.h new file mode 100644 index 00000000..b3c4da65 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/t_kuser.h @@ -0,0 +1,144 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_T_KUSER_H +#define _SYS_T_KUSER_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Note this structure will need to be expanded to handle data + * related to connection oriented transports. + */ +typedef struct tiuser { + struct file *fp; + struct t_info tp_info; /* Transport provider Info. */ + int flags; +} TIUSER; +#define TIUSERSZ sizeof (TIUSER) + +struct knetbuf { + mblk_t *udata_mp; /* current receive streams block */ + unsigned int maxlen; + unsigned int len; + char *buf; +}; + +struct t_kunitdata { + struct netbuf addr; + struct netbuf opt; + struct knetbuf udata; +}; + + +#ifdef KTLIDEBUG +extern int ktli_log(); +extern int ktlilog; + +#define KTLILOG(A, B, C) ((void)((ktlilog) && ktli_log((A), (B), (C)))) +#else +#define KTLILOG(A, B, C) +#endif + +/* + * flags + */ +#define MADE_FP 0x02 + +extern int t_kalloc(TIUSER *, int, int, char **); +extern int t_kbind(TIUSER *, struct t_bind *, struct t_bind *); +extern int t_kclose(TIUSER *, int); +extern int t_kconnect(TIUSER *, struct t_call *, struct t_call *); +extern int t_kfree(TIUSER *, char *, int); +extern int t_kgetstate(TIUSER *, int *); +extern int t_kopen(struct file *, dev_t, int, TIUSER **, struct cred *); +extern int t_koptmgmt(TIUSER *, struct t_optmgmt *, struct t_optmgmt *); +extern int t_krcvudata(TIUSER *, struct t_kunitdata *, int *, int *); +extern int t_ksndudata(TIUSER *, struct t_kunitdata *, frtn_t *); +extern int t_kspoll(TIUSER *, int, int, int *); +extern int t_kunbind(TIUSER *); +extern int tli_send(TIUSER *, mblk_t *, int); +extern int tli_recv(TIUSER *, mblk_t **, int); +extern int t_tlitosyserr(int); +extern int get_ok_ack(TIUSER *, int, int); + +/* + * these make life a lot easier + */ +#define TCONNREQSZ sizeof (struct T_conn_req) +#define TCONNRESSZ sizeof (struct T_conn_res) +#define TDISCONREQSZ sizeof (struct T_discon_req) +#define TDATAREQSZ sizeof (struct T_data_req) +#define TEXDATAREQSZ sizeof (struct T_exdata_req) +#define TINFOREQSZ sizeof (struct T_info_req) +#define TBINDREQSZ sizeof (struct T_bind_req) +#define TUNBINDREQSZ sizeof (struct T_unbind_req) +#define TUNITDATAREQSZ sizeof (struct T_unitdata_req) +#define TOPTMGMTREQSZ sizeof (struct T_optmgmt_req) +#define TORDRELREQSZ sizeof (struct T_ordrel_req) +#define TCONNINDSZ sizeof (struct T_conn_ind) +#define TCONNCONSZ sizeof (struct T_conn_con) +#define TDISCONINDSZ sizeof (struct T_discon_ind) +#define TDATAINDSZ sizeof (struct T_data_ind) +#define TEXDATAINDSZ sizeof (struct T_exdata_ind) +#define TINFOACKSZ sizeof (struct T_info_ack) +#define TBINDACKSZ sizeof (struct T_bind_ack) +#define TERRORACKSZ sizeof (struct T_error_ack) +#define TOKACKSZ sizeof (struct T_ok_ack) +#define TUNITDATAINDSZ sizeof (struct T_unitdata_ind) +#define TUDERRORINDSZ sizeof (struct T_uderror_ind) +#define TOPTMGMTACKSZ sizeof (struct T_optmgmt_ack) +#define TORDRELINDSZ sizeof (struct T_ordrel_ind) +#define TPRIMITIVES sizeof (struct T_primitives) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_T_KUSER_H */ diff --git a/illumos-x86_64/usr/include/sys/t_lock.h b/illumos-x86_64/usr/include/sys/t_lock.h new file mode 100644 index 00000000..34b0ad9d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/t_lock.h @@ -0,0 +1,103 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1991-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * t_lock.h: Prototypes for disp_locks, plus include files + * that describe the interfaces to kernel synch. + * objects. + */ + +#ifndef _SYS_T_LOCK_H +#define _SYS_T_LOCK_H + +#ifndef _ASM +#include +#include +#include +#include +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +/* + * Mutual exclusion locks described in common/sys/mutex.h. + * + * Semaphores described in common/sys/semaphore.h. + * + * Readers/Writer locks described in common/sys/rwlock.h. + * + * Condition variables described in common/sys/condvar.h + */ + +#if defined(_KERNEL) + +extern int ncpus; + +/* + * Dispatcher lock type, macros and routines. + * + * disp_lock_t is defined in machlock.h + */ +extern void disp_lock_enter(disp_lock_t *); +extern void disp_lock_exit(disp_lock_t *); +extern void disp_lock_exit_nopreempt(disp_lock_t *); +extern void disp_lock_enter_high(disp_lock_t *); +extern void disp_lock_exit_high(disp_lock_t *); +extern void disp_lock_init(disp_lock_t *lp, char *name); +extern void disp_lock_destroy(disp_lock_t *lp); + +#define DISP_LOCK_INIT(lp) LOCK_INIT_CLEAR((lock_t *)(lp)) +#define DISP_LOCK_HELD(lp) LOCK_HELD((lock_t *)(lp)) +#define DISP_LOCK_DESTROY(lp) ASSERT(!DISP_LOCK_HELD(lp)) + +/* + * The following definitions are for assertions which can be checked + * statically by tools like lock_lint. You can also define your own + * run-time test for each. If you don't, we define them to 1 so that + * such assertions simply pass. + */ +#ifndef NO_LOCKS_HELD +#define NO_LOCKS_HELD 1 +#endif +#ifndef NO_COMPETING_THREADS +#define NO_COMPETING_THREADS 1 +#endif + +#endif /* defined(_KERNEL) */ + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_T_LOCK_H */ diff --git a/illumos-x86_64/usr/include/sys/task.h b/illumos-x86_64/usr/include/sys/task.h new file mode 100644 index 00000000..a6051b79 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/task.h @@ -0,0 +1,121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_TASK_H +#define _SYS_TASK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define TASK_NORMAL 0x0 /* task may create tasks via settaskid() */ +#define TASK_FINAL 0x1 /* task finalized, settaskid() will fail */ +#define TASK_MASK 0x1 /* task flags mask */ + +#define TASK_PROJ_PURGE 0x100000 /* purge project.* rctl entities */ +#define TASK_PROJ_MASK 0x100000 + +#ifdef _KERNEL + +#include +#include +#include + +struct proc; +struct zone; + +typedef struct task { + taskid_t tk_tkid; /* task id */ + uint_t tk_flags; /* task properties */ + struct kproject *tk_proj; /* project membership */ + uint_t tk_hold_count; /* number of members/observers */ + struct proc *tk_memb_list; /* pointer to the first process */ + /* in a doubly linked list of */ + /* task members */ + kmutex_t tk_usage_lock; /* lock to protect tk_*usage */ + task_usage_t *tk_usage; /* total task resource usage */ + task_usage_t *tk_prevusage; /* previous interval usage */ + task_usage_t *tk_zoneusage; /* previous interval usage in zone */ + rctl_set_t *tk_rctls; /* task's resource controls */ + rctl_qty_t tk_nlwps; /* protected by */ + /* tk_zone->zone_nlwps_lock */ + rctl_qty_t tk_nlwps_ctl; /* protected by tk_rctls->rcs_lock */ + rctl_qty_t tk_cpu_time; /* accumulated CPU seconds */ + struct zone *tk_zone; /* zone task belongs to */ + task_usage_t *tk_inherited; /* task resource usage */ + /* inherited with the first */ + /* member process */ + rctl_qty_t tk_cpu_ticks; /* accumulated CPU ticks */ + kmutex_t tk_cpu_time_lock; /* accumulated CPU seconds lock */ + rctl_qty_t tk_nprocs; /* protected by */ + /* tk_zone->zone_nlwps_lock */ + rctl_qty_t tk_nprocs_ctl; /* protected by tk_rctls->rcs_lock */ + kstat_t *tk_nprocs_kstat; /* max-processes rctl kstat */ + struct task *tk_commit_next; /* next task on task commit list */ +} task_t; + +typedef struct task_kstat { + kstat_named_t ktk_zonename; + kstat_named_t ktk_usage; + kstat_named_t ktk_value; +} task_kstat_t; + +extern task_t *task0p; +extern rctl_hndl_t rc_task_lwps; +extern rctl_hndl_t rc_task_nprocs; +extern rctl_hndl_t rc_task_cpu_time; + +extern void task_init(void); +extern task_t *task_create(projid_t, struct zone *); +extern void task_begin(task_t *, struct proc *); +extern void task_attach(task_t *, struct proc *); +extern void task_change(task_t *, struct proc *); +extern void task_detach(struct proc *); +extern task_t *task_join(task_t *, uint_t); +extern task_t *task_hold_by_id(taskid_t); +extern task_t *task_hold_by_id_zone(taskid_t, zoneid_t); +extern void task_rele(task_t *); +extern void task_hold(task_t *); +extern void task_end(task_t *); +extern rctl_qty_t task_cpu_time_incr(task_t *, rctl_qty_t); +extern void task_commit_thread_init(void); + +#else /* _KERNEL */ + +struct task; + +extern taskid_t settaskid(projid_t, uint_t); +extern taskid_t gettaskid(void); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TASK_H */ diff --git a/illumos-x86_64/usr/include/sys/taskq.h b/illumos-x86_64/usr/include/sys/taskq.h new file mode 100644 index 00000000..1de0be03 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/taskq.h @@ -0,0 +1,101 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2018, Joyent, Inc. + * Copyright 2023 RackTop Systems, Inc. + */ + +#ifndef _SYS_TASKQ_H +#define _SYS_TASKQ_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TASKQ_NAMELEN 31 + +typedef struct taskq taskq_t; +typedef uintptr_t taskqid_t; +typedef void (task_func_t)(void *); + +struct proc; + +/* + * Public flags for taskq_create(): bit range 0-15 + */ +#define TASKQ_PREPOPULATE 0x0001 /* Prepopulate with threads and data */ +#define TASKQ_CPR_SAFE 0x0002 /* Use CPR safe protocol */ +#define TASKQ_DYNAMIC 0x0004 /* Use dynamic thread scheduling */ +#define TASKQ_THREADS_CPU_PCT 0x0008 /* number of threads as % of ncpu */ +#define TASKQ_DC_BATCH 0x0010 /* Taskq uses SDC in batch mode */ +#define TASKQ_THREADS_LWP 0x0020 /* create LWP threads */ + +/* + * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as + * KM_SLEEP/KM_NOSLEEP. + */ +#define TQ_SLEEP 0x00 /* Can block for memory */ +#define TQ_NOSLEEP 0x01 /* cannot block for memory; may fail */ +#define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */ +#define TQ_NOALLOC 0x04 /* cannot allocate memory; may fail */ +#define TQ_FRONT 0x08 /* Put task at the front of the queue */ + +#define TASKQID_INVALID ((taskqid_t)0) + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern taskq_t *system_taskq; + +extern void taskq_init(void); +extern void taskq_mp_init(void); + +extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t); +extern taskq_t *taskq_create_instance(const char *, int, int, pri_t, int, + int, uint_t); +extern taskq_t *taskq_create_proc(const char *, int, pri_t, int, int, + struct proc *, uint_t); +extern taskq_t *taskq_create_sysdc(const char *, int, int, int, + struct proc *, uint_t, uint_t); +extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t); +extern void nulltask(void *); +extern void taskq_destroy(taskq_t *); +extern void taskq_wait(taskq_t *); +void taskq_wait_id(taskq_t *, taskqid_t); +extern boolean_t taskq_empty(taskq_t *); +extern void taskq_suspend(taskq_t *); +extern int taskq_suspended(taskq_t *); +extern void taskq_resume(taskq_t *); +extern int taskq_member(taskq_t *, kthread_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TASKQ_H */ diff --git a/illumos-x86_64/usr/include/sys/taskq_impl.h b/illumos-x86_64/usr/include/sys/taskq_impl.h new file mode 100644 index 00000000..2e1bf7cf --- /dev/null +++ b/illumos-x86_64/usr/include/sys/taskq_impl.h @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. + * Copyright 2017-2024 RackTop Systems. + */ + +#ifndef _SYS_TASKQ_IMPL_H +#define _SYS_TASKQ_IMPL_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct taskq_bucket taskq_bucket_t; + +typedef struct taskq_ent { + struct taskq_ent *tqent_next; + struct taskq_ent *tqent_prev; + task_func_t *tqent_func; + void *tqent_arg; + union { + taskq_bucket_t *tqent_bucket; + uintptr_t tqent_flags; + } tqent_un; + kthread_t *tqent_thread; + kcondvar_t tqent_cv; +} taskq_ent_t; + +#define TQENT_FLAG_PREALLOC 0x1 + +/* + * Taskq Statistics fields are not protected by any locks. + */ +typedef struct tqstat { + uint64_t tqs_hits; + uint64_t tqs_misses; + uint64_t tqs_disptcreates; + uint64_t tqs_overflow; /* dispatch used backlog */ + uint_t tqs_maxbacklog; + uint_t tqs_tcreates; /* threads created */ + uint_t tqs_tdeaths; /* threads died */ + uint_t tqs_maxthreads; /* max # of alive threads */ +} tqstat_t; + +/* + * Per-CPU hash bucket manages taskq_bent_t structures using freelist. + */ +struct taskq_bucket { + kmutex_t tqbucket_lock; + taskq_t *tqbucket_taskq; /* Enclosing taskq */ + taskq_ent_t tqbucket_backlog; /* distributed backlog */ + taskq_ent_t tqbucket_freelist; + uint_t tqbucket_nalloc; /* # of allocated entries */ + uint_t tqbucket_nbacklog; /* # of backlog entries */ + uint_t tqbucket_nfree; /* # of free entries */ + kcondvar_t tqbucket_cv; + ushort_t tqbucket_flags; + hrtime_t tqbucket_totaltime; + tqstat_t tqbucket_stat; +}; + +/* + * Bucket flags. + */ +#define TQBUCKET_CLOSE 0x01 +#define TQBUCKET_SUSPEND 0x02 +#define TQBUCKET_REDIRECT 0x04 + +#define TASKQ_INTERFACE_FLAGS 0x0000ffff /* defined in */ + +/* + * taskq implementation flags: bit range 16-31 + */ +#define TASKQ_CHANGING 0x00010000 /* nthreads != target */ +#define TASKQ_SUSPENDED 0x00020000 /* taskq is suspended */ +#define TASKQ_NOINSTANCE 0x00040000 /* no instance number */ +#define TASKQ_THREAD_CREATED 0x00080000 /* a thread has been created */ +#define TASKQ_DUTY_CYCLE 0x00100000 /* using the SDC class */ + +struct taskq { + char tq_name[TASKQ_NAMELEN + 1]; + kmutex_t tq_lock; + krwlock_t tq_threadlock; + kcondvar_t tq_dispatch_cv; + kcondvar_t tq_wait_cv; + kcondvar_t tq_exit_cv; + pri_t tq_pri; /* Scheduling priority */ + uint_t tq_flags; + int tq_active; + int tq_nthreads; + int tq_nthreads_target; + int tq_nthreads_max; + int tq_threads_ncpus_pct; + int tq_nalloc; + int tq_minalloc; + int tq_maxalloc; + kcondvar_t tq_maxalloc_cv; + int tq_maxalloc_wait; + taskq_ent_t *tq_freelist; + taskq_ent_t tq_task; + int tq_maxsize; + uint_t tq_atpb; /* avg. thr. per bucket */ + taskq_bucket_t *tq_buckets; /* Per-cpu array of buckets */ + int tq_instance; + uint_t tq_nbuckets; /* # of buckets (2^n) */ + union { + kthread_t *_tq_thread; + kthread_t **_tq_threadlist; + } tq_thr; + + list_node_t tq_cpupct_link; /* linkage for taskq_cpupct_list */ + struct proc *tq_proc; /* process for taskq threads */ + int tq_cpupart; /* cpupart id bound to */ + uint_t tq_DC; /* duty cycle for SDC */ + + /* + * Statistics. + */ + kstat_t *tq_kstat; /* Exported statistics */ + hrtime_t tq_totaltime; /* Time spent processing tasks */ + uint64_t tq_nomem; /* # of times there was no memory */ + uint64_t tq_tasks; /* Total # of tasks posted */ + uint64_t tq_executed; /* Total # of tasks executed */ + int tq_maxtasks; /* Max number of tasks in the queue */ + int tq_dnthreads; /* Dynamic N threads */ +}; + +/* Special form of taskq dispatch that uses preallocated entries. */ +void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t, taskq_ent_t *); + + +#define tq_thread tq_thr._tq_thread +#define tq_threadlist tq_thr._tq_threadlist + +/* The MAX guarantees we have at least one thread */ +#define TASKQ_THREADS_PCT(ncpus, pct) MAX(((ncpus) * (pct)) / 100, 1) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TASKQ_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/telioctl.h b/illumos-x86_64/usr/include/sys/telioctl.h new file mode 100644 index 00000000..0ac669b4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/telioctl.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1994 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TELIOCTL_H +#define _SYS_TELIOCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Ioctl's to control telnet protocol module + * (See also, logindmux.h LOGDMX_IOC_QEXCHANGE) + * + * TEL_IOC_ENABLE: Allow processing, and forward normal data messages. This + * resumes processing after telmod receives a protocol sequence which it does + * not process itself. If data is attached to this ioctl, telmod inserts it + * at the head of the read queue. + * + * TEL_IOC_MODE: Establish the mode for data processing. Currently binary + * input and output are the only modes supported. + * + * TEL_IOC_GETBLK: When telmod is not enabled, this ioctl requests that + * the next input message from the network to be processed is forwarded + * through the mux to the daemon. + */ +#define TELIOC ('n' << 8) +#define TEL_IOC_ENABLE (TELIOC|2) +#define TEL_IOC_MODE (TELIOC|3) +#define TEL_IOC_GETBLK (TELIOC|4) + +/* + * Bits for indicating binary input (from the net) and output (to the net). + */ +#define TEL_BINARY_IN 1 +#define TEL_BINARY_OUT 2 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TELIOCTL_H */ diff --git a/illumos-x86_64/usr/include/sys/termio.h b/illumos-x86_64/usr/include/sys/termio.h new file mode 100644 index 00000000..34622aa0 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/termio.h @@ -0,0 +1,102 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_TERMIO_H +#define _SYS_TERMIO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* all the ioctl codes and flags are now in termios.h */ + +/* + * Ioctl control packet + */ +struct termio { + unsigned short c_iflag; /* input modes */ + unsigned short c_oflag; /* output modes */ + unsigned short c_cflag; /* control modes */ + unsigned short c_lflag; /* line discipline modes */ + char c_line; /* line discipline */ + unsigned char c_cc[_NCC]; /* control chars */ +}; + +#define IOCTYPE 0xff00 + + +/* + * structure of ioctl arg for LDGETT and LDSETT + */ +struct termcb { + char st_flgs; /* term flags */ + char st_termt; /* term type */ + char st_crow; /* gtty only - current row */ + char st_ccol; /* gtty only - current col */ + char st_vrow; /* variable row */ + char st_lrow; /* last row */ +}; + +#ifndef u3b15 +#define SSPEED 7 /* default speed: 300 baud */ +#else +#define SSPEED 9 /* default speed: 1200 baud */ +#endif + +#ifdef u3b15 +#define TTYTYPE (_TIOC|8) +#endif +#define TCDSET (_TIOC|32) + +/* + * Terminal types + */ +#define TERM_NONE 0 /* tty */ +#define TERM_TEC 1 /* TEC Scope */ +#define TERM_V61 2 /* DEC VT61 */ +#define TERM_V10 3 /* DEC VT100 */ +#define TERM_TEX 4 /* Tektronix 4023 */ +#define TERM_D40 5 /* TTY Mod 40/1 */ +#define TERM_H45 6 /* Hewlitt-Packard 45 */ +#define TERM_D42 7 /* TTY Mod 40/2B */ + +/* + * Terminal flags + */ +#define TM_NONE 0000 /* use default flags */ +#define TM_SNL 0001 /* special newline flag */ +#define TM_ANL 0002 /* auto newline on column 80 */ +#define TM_LCF 0004 /* last col of last row special */ +#define TM_CECHO 0010 /* echo terminal cursor control */ +#define TM_CINVIS 0020 /* do not send esc seq to user */ +#define TM_SET 0200 /* must be on to set/res flags */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TERMIO_H */ diff --git a/illumos-x86_64/usr/include/sys/termios.h b/illumos-x86_64/usr/include/sys/termios.h new file mode 100644 index 00000000..4edeb7a4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/termios.h @@ -0,0 +1,594 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_TERMIOS_H +#define _SYS_TERMIOS_H + +#include + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#include +#include +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * _POSIX_VDISABLE has been defined in since the + * introduction of the header. The POSIX standard, IEEE Std. + * 1003.1-1988 also required the existence of _POSIX_VDISABLE in + * this header. Subsequent versions of the IEEE Standard as well + * as the X/Open specifications required that _POSIX_VDISABLE be + * defined in while still allowing for it's existence + * here. With the introduction of XPG6, _POSIX_VDISABLE can only + * be defined in . + */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE 0 /* Disable special character functions */ +#endif +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define CTRL(c) ((c)&037) +#define IBSHIFT 16 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* required by termio.h and VCEOF/VCEOL */ +#define _NCC 8 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define NCC _NCC +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* some defines required by POSIX */ +#define NCCS 19 + +/* + * types defined by POSIX. These are better off in types.h, but + * the standard says that they have to be in termios.h. + */ +typedef unsigned int tcflag_t; +typedef unsigned char cc_t; +typedef unsigned int speed_t; + +/* + * Ioctl control packet + */ +struct termios { + tcflag_t c_iflag; /* input modes */ + tcflag_t c_oflag; /* output modes */ + tcflag_t c_cflag; /* control modes */ + tcflag_t c_lflag; /* line discipline modes */ + cc_t c_cc[NCCS]; /* control chars */ +}; + +/* + * POSIX termios functions + * These functions get mapped into ioctls. + */ + +#ifndef _KERNEL + +extern speed_t cfgetospeed(const struct termios *); +extern int cfsetospeed(struct termios *, speed_t); +extern speed_t cfgetispeed(const struct termios *); +extern int cfsetispeed(struct termios *, speed_t); +extern int tcgetattr(int, struct termios *); +extern int tcsetattr(int, int, const struct termios *); +extern int tcsendbreak(int, int); +extern int tcdrain(int); +extern int tcflush(int, int); +extern int tcflow(int, int); + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) + +extern pid_t tcgetsid(int); + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */ + +#endif + +/* control characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VEOL 5 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define VEOL2 6 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#define VMIN 4 +#define VTIME 5 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define VSWTCH 7 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define VDSUSP 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VSTATUS 16 +#define VERASE2 17 +/* 18 through 19 reserved for future use */ + +/* + * control characters form Xenix termio.h + */ +#define VCEOF NCC /* RESERVED true EOF char (V7 compatability) */ +#define VCEOL (NCC + 1) /* RESERVED true EOL char */ + +#define CNUL 0 +#define CDEL 0177 + +/* S5 default control chars */ +/* CINTR, CERASE and CKILL modified to SunOS traditional values */ +#define CESC '\\' +#define CINTR CTRL('c') +#define CQUIT 034 /* FS, cntl | */ +#define CERASE 0177 /* DEL */ +#define CERASE2 CTRL('h') +#define CKILL CTRL('u') +#define CEOT 04 +#define CEOL 0 +#define CEOL2 0 +#define CEOF 04 /* cntl d */ +#define CSTART 021 /* cntl q */ +#define CSTOP 023 /* cntl s */ +#define CSWTCH 032 /* cntl z */ +#define CNSWTCH 0 +#define CSUSP CTRL('z') +#define CDSUSP CTRL('y') +#define CRPRNT CTRL('r') +#define CFLUSH CTRL('o') +#define CWERASE CTRL('w') +#define CLNEXT CTRL('v') +#define CSTATUS CTRL('t') +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + + +/* input modes */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#if !defined(_POSIX_C_SOURCE) || \ + (defined(_XOPEN_SOURCE) && !defined(_XPG6)) || \ + defined(__EXTENSIONS__) +#define IUCLC 0001000 +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ +#define IXON 0002000 +#if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(__EXTENSIONS__) +#define IXANY 0004000 +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ +#define IXOFF 0010000 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define IMAXBEL 0020000 +#define DOSMODE 0100000 /* for 386 compatibility */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* output modes */ +#define OPOST 0000001 +#if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(__EXTENSIONS__) +#if !defined(_XPG6) || defined(__EXTENSIONS__) +#define OLCUC 0000002 +#endif +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define XTABS 0014000 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(__EXTENSIONS__) +#define BSDLY 0020000 +#define BS0 0 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0 +#define VT1 0040000 +#define FFDLY 0100000 +#define FF0 0 +#define FF1 0100000 +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define PAGEOUT 0200000 +#define WRAP 0400000 + +/* control modes */ +#define CBAUD 0000017 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#define CSIZE 0000060 +#define CS5 0 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define RCV1EN 0010000 +#define XMT1EN 0020000 +#define LOBLK 0040000 +#define XCLUDE 0100000 /* *V7* exclusive use coming fron XENIX */ +#define CRTSXOFF 010000000000 +#define CRTSCTS 020000000000 +#define CIBAUD 03600000 +#define PAREXT 04000000 +#define CBAUDEXT 010000000 +#define CIBAUDEXT 020000000 + +/* + * 4.4BSD hardware flow control flags + */ +#define CRTS_IFLOW 010000000000 +#define CCTS_OFLOW 020000000000 + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* line discipline 0 modes */ +#define ISIG 0000001 +#define ICANON 0000002 +#if !defined(_POSIX_C_SOURCE) || \ + (defined(_XOPEN_SOURCE) && !defined(_XPG6)) || \ + defined(__EXTENSIONS__) +#define XCASE 0000004 +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define DEFECHO 0010000 +#define FLUSHO 0020000 +#define PENDIN 0040000 +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#define IEXTEN 0100000 /* POSIX flag - enable POSIX extensions */ +#define _TIOC ('T'<<8) + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + +#define TIOC _TIOC + +#define TCGETA (_TIOC|1) +#define TCSETA (_TIOC|2) +#define TCSETAW (_TIOC|3) +#define TCSETAF (_TIOC|4) +#define TCSBRK (_TIOC|5) +#define TCXONC (_TIOC|6) +#define TCFLSH (_TIOC|7) + +/* Slots reserved for 386/XENIX compatibility - keyboard control */ + +#define TIOCKBON (_TIOC|8) +#define TIOCKBOF (_TIOC|9) +#define KBENABLED (_TIOC|10) + +#ifndef IOCTYPE +#define IOCTYPE 0xff00 +#endif + +#define TCDSET (_TIOC|32) +#define RTS_TOG (_TIOC|33) /* 386 - "RTS" toggle define 8A1 protocol */ + +#define TIOCGWINSZ (_TIOC|104) +#define TIOCSWINSZ (_TIOC|103) + +/* + * Softcarrier ioctls + */ +#define TIOCGSOFTCAR (_TIOC|105) +#define TIOCSSOFTCAR (_TIOC|106) + + +/* termios ioctls */ + +#define TCGETS (_TIOC|13) +#define TCSETS (_TIOC|14) +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#define TCSANOW (_TIOC|14) /* same as TCSETS */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define TCSETSW (_TIOC|15) +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#define TCSADRAIN (_TIOC|15) /* same as TCSETSW */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define TCSETSF (_TIOC|16) + +/* + * linux terminal ioctls we need to be aware of + */ +#define TIOCSETLD (_TIOC|123) /* set line discipline parms */ +#define TIOCGETLD (_TIOC|124) /* get line discipline parms */ + +/* + * The VMIN and VTIME and solaris overlap with VEOF and VEOL - This is + * perfectly legal except, linux expects them to be separate. So we keep + * them separately. + */ +struct lx_cc { + unsigned char veof; /* veof value */ + unsigned char veol; /* veol value */ + unsigned char vmin; /* vmin value */ + unsigned char vtime; /* vtime value */ +}; + +/* + * NTP PPS ioctls + */ +#define TIOCGPPS (_TIOC|125) +#define TIOCSPPS (_TIOC|126) +#define TIOCGPPSEV (_TIOC|127) + +/* Argument filled in by TIOCGPPSEV */ +struct ppsclockev { + struct timeval tv; + uint_t serial; +}; + +#if defined(_SYSCALL32) +struct ppsclockev32 { + struct timeval32 tv; + uint32_t serial; +}; +#endif /* _SYSCALL32 */ + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#define TCSAFLUSH (_TIOC|16) /* same as TCSETSF */ + +/* termios option flags */ + +#define TCIFLUSH 0 /* flush data received but not read */ +#define TCOFLUSH 1 /* flush data written but not transmitted */ +#define TCIOFLUSH 2 /* flush both data both input and output queues */ + +#define TCOOFF 0 /* suspend output */ +#define TCOON 1 /* restart suspended output */ +#define TCIOFF 2 /* suspend input */ +#define TCION 3 /* restart suspended input */ + +/* TIOC ioctls for BSD, ptys, job control and modem control */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define tIOC ('t'<<8) +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* Slots for 386/XENIX compatibility */ +/* BSD includes these ioctls in ttold.h */ + +#ifndef _SYS_TTOLD_H + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define TIOCGETD (tIOC|0) +#define TIOCSETD (tIOC|1) +#define TIOCHPCL (tIOC|2) +#define TIOCGETP (tIOC|8) +#define TIOCSETP (tIOC|9) +#define TIOCSETN (tIOC|10) +#define TIOCEXCL (tIOC|13) +#define TIOCNXCL (tIOC|14) +#define TIOCFLUSH (tIOC|16) +#define TIOCSETC (tIOC|17) +#define TIOCGETC (tIOC|18) +/* + * BSD ioctls that are not the same as XENIX are included here. + * There are also some relevant ioctls from SUN/BSD sys/ttycom.h + * BSD pty ioctls like TIOCPKT are not supported in SVR4. + */ + +#define TIOCLBIS (tIOC|127) /* bis local mode bits */ +#define TIOCLBIC (tIOC|126) /* bic local mode bits */ +#define TIOCLSET (tIOC|125) /* set entire local mode word */ +#define TIOCLGET (tIOC|124) /* get local modes */ +#define TIOCSBRK (tIOC|123) /* set break bit */ +#define TIOCCBRK (tIOC|122) /* clear break bit */ +#define TIOCSDTR (tIOC|121) /* set data terminal ready */ +#define TIOCCDTR (tIOC|120) /* clear data terminal ready */ +#define TIOCSLTC (tIOC|117) /* set local special chars */ +#define TIOCGLTC (tIOC|116) /* get local special chars */ +#define TIOCOUTQ (tIOC|115) /* driver output queue size */ +#define TIOCNOTTY (tIOC|113) /* void tty association */ +#define TIOCSCTTY (tIOC|132) /* get a ctty */ +#define TIOCSTOP (tIOC|111) /* stop output, like ^S */ +#define TIOCSTART (tIOC|110) /* start output, like ^Q */ +#define TIOCSILOOP (tIOC|109) /* private to Sun; do not use */ +#define TIOCCILOOP (tIOC|108) /* private to Sun; do not use */ + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#endif /* end _SYS_TTOLD_H */ + +/* POSIX job control ioctls */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define TIOCGPGRP (tIOC|20) /* get pgrp of tty */ +#define TIOCSPGRP (tIOC|21) /* set pgrp of tty */ +#define TIOCGSID (tIOC|22) /* get session id on ctty */ + +/* Miscellaneous */ +#define TIOCSTI (tIOC|23) /* simulate terminal input */ + +/* Modem control */ +#define TIOCMSET (tIOC|26) /* set all modem bits */ +#define TIOCMBIS (tIOC|27) /* bis modem bits */ +#define TIOCMBIC (tIOC|28) /* bic modem bits */ +#define TIOCMGET (tIOC|29) /* get all modem bits */ +#define TIOCM_LE 0001 /* line enable */ +#define TIOCM_DTR 0002 /* data terminal ready */ +#define TIOCM_RTS 0004 /* request to send */ +#define TIOCM_ST 0010 /* secondary transmit */ +#define TIOCM_SR 0020 /* secondary receive */ +#define TIOCM_CTS 0040 /* clear to send */ +#define TIOCM_CAR 0100 /* carrier detect */ +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RNG 0200 /* ring */ +#define TIOCM_RI TIOCM_RNG +#define TIOCM_DSR 0400 /* data set ready */ + +/* pseudo-tty */ + +#define TIOCREMOTE (tIOC|30) /* remote input editing */ +#define TIOCSIGNAL (tIOC|31) /* pty: send signal to subsidiary */ + + +/* Some more 386 xenix stuff */ + +#define LDIOC ('D'<<8) + +#define LDOPEN (LDIOC|0) +#define LDCLOSE (LDIOC|1) +#define LDCHG (LDIOC|2) +#define LDGETT (LDIOC|8) +#define LDSETT (LDIOC|9) + +/* Slots for 386 compatibility */ + +#define LDSMAP (LDIOC|110) +#define LDGMAP (LDIOC|111) +#define LDNMAP (LDIOC|112) +#define LDEMAP (LDIOC|113) +#define LDDMAP (LDIOC|114) + +/* + * These are retained for 386/XENIX compatibility. + */ + +#define DIOC ('d'<<8) +#define DIOCGETP (DIOC|8) /* V7 */ +#define DIOCSETP (DIOC|9) /* V7 */ + +/* + * Returns a non-zero value if there + * are characters in the input queue. + * + * XXX - somebody is confused here. V7 had no such "ioctl", although XENIX may + * have added it; 4BSD had FIONREAD, which returned the number of characters + * waiting, and was supposed to work on all descriptors (i.e., every driver + * should make a stab at implementing it). + */ +#define FIORDCHK (('f'<<8)|3) /* V7 */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* + * Speeds + */ +#define B0 0 +#define B50 1 +#define B75 2 +#define B110 3 +#define B134 4 +#define B150 5 +#define B200 6 +#define B300 7 +#define B600 8 +#define B1200 9 +#define B1800 10 +#define B2400 11 +#define B4800 12 +#define B9600 13 +#define B19200 14 +#define B38400 15 +#define B57600 16 +#define B76800 17 +#define B115200 18 +#define B153600 19 +#define B230400 20 +#define B307200 21 +#define B460800 22 +#define B921600 23 +#define B1000000 24 +#define B1152000 25 +#define B1500000 26 +#define B2000000 27 +#define B2500000 28 +#define B3000000 29 +#define B3500000 30 +#define B4000000 31 + +#ifndef _SYS_TTOLD_H + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +/* Windowing structure to support JWINSIZE/TIOCSWINSZ/TIOCGWINSZ */ +struct winsize { + unsigned short ws_row; /* rows, in characters */ + unsigned short ws_col; /* columns, in character */ + unsigned short ws_xpixel; /* horizontal size, pixels */ + unsigned short ws_ypixel; /* vertical size, pixels */ +}; +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#endif /* end _SYS_TTOLD_H */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TERMIOS_H */ diff --git a/illumos-x86_64/usr/include/sys/termiox.h b/illumos-x86_64/usr/include/sys/termiox.h new file mode 100644 index 00000000..df588188 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/termiox.h @@ -0,0 +1,124 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_TERMIOX_H +#define _SYS_TERMIOX_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* This structure provides an extended terminal interface. */ +/* Features of this interface are optional and may not be */ +/* implemented on all machines. */ + + +#define NFF 5 + +/* hardware flow control modes */ + +#define RTSXOFF 0000001 /* Enable RTS hardware flow control on input */ +#define CTSXON 0000002 /* Enable CTS hardware flow control on output */ +#define DTRXOFF 0000004 /* Enable DTR hardware flow control on input */ +#define CDXON 0000010 /* Enable CD hardware flow control on output */ +#define ISXOFF 0000020 /* Enable isochronous hardware flow control on input */ + +/* clock modes */ + +#define XMTCLK 0000007 /* Transmit Clock Source: */ +#define XCIBRG 0000000 /* Get transmit clock from */ + /* internal baud rate generator */ +#define XCTSET 0000001 /* Get transmit clock from */ + /* transmitter signal element */ + /* timing (DCE source) lead, */ + /* CCITT V.24 circuit 114, */ + /* EIA-232-D pin 15 */ +#define XCRSET 0000002 /* Get transmit clock from */ + /* receiver signal element */ + /* timing (DCE source) lead, */ + /* CCITT V.24 circuit 115, */ + /* EIA-232-D pin 17 */ + +#define RCVCLK 0000070 /* Receive Clock Source: */ +#define RCIBRG 0000000 /* get receive clock from internal */ + /* baud rate generator */ +#define RCTSET 0000010 /* Get receive clock from */ + /* transmitter signal element */ + /* timing (DCE source) lead, */ + /* CCITT V.24 circuit 114, */ + /* EIA-232-D pin 15 */ +#define RCRSET 0000020 /* Get receive clock from */ + /* receiver signal element */ + /* timing (DCE source) lead, */ + /* CCITT V.24 circuit 115, */ + /* EIA-232-D pin 17 */ + +#define TSETCLK 0000700 /* Transmitter Signal Element */ + /* timing (DTE source) lead, */ + /* CCITT V.24 circuit 113, */ + /* EIA-232-D pin 24, clock source: */ +#define TSETCOFF 0000000 /* TSET clock not provided */ +#define TSETCRBRG 0000100 /* Output receive baud rate generator */ + /* on circuit 113 */ +#define TSETCTBRG 0000200 /* Output transmit baud rate generator */ + /* on circuit 113 */ +#define TSETCTSET 0000300 /* Output transmitter signal element */ + /* timing (DCE source) on circuit 113 */ +#define TSETCRSET 0000400 /* Output receiver signal element */ + /* timing (DCE source) on circuit 113 */ + +#define RSETCLK 0007000 /* Receiver Signal Element */ + /* timing (DTE source) lead, */ + /* CCITT V.24 circuit 128, */ + /* no EIA-232-D pin, clock source: */ +#define RSETCOFF 0000000 /* RSET clock not provided */ +#define RSETCRBRG 0001000 /* Output receive baud rate generator */ + /* on circuit 128 */ +#define RSETCTBRG 0002000 /* Output transmit baud rate generator */ + /* on circuit 128 */ +#define RSETCTSET 0003000 /* Output transmitter signal element */ + /* timing (DCE source) on circuit 128 */ +#define RSETCRSET 0004000 /* Output receiver signal element */ + /* timing (DCE source) on circuit 128 */ + + +struct termiox { + unsigned short x_hflag; /* hardware flow control modes */ + unsigned short x_cflag; /* clock modes */ + unsigned short x_rflag[NFF]; /* reserved modes */ + unsigned short x_sflag; /* spare modes */ +}; + +#define XIOC ('X'<<8) +#define TCGETX (XIOC|1) +#define TCSETX (XIOC|2) +#define TCSETXW (XIOC|3) +#define TCSETXF (XIOC|4) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TERMIOX_H */ diff --git a/illumos-x86_64/usr/include/sys/thread.h b/illumos-x86_64/usr/include/sys/thread.h new file mode 100644 index 00000000..492990ea --- /dev/null +++ b/illumos-x86_64/usr/include/sys/thread.h @@ -0,0 +1,733 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_THREAD_H +#define _SYS_THREAD_H + + +#include +#include +#include +#include +#include +#include +#if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The thread object, its states, and the methods by which it + * is accessed. + */ + +/* + * Values that t_state may assume. Note that t_state cannot have more + * than one of these flags set at a time. + */ +#define TS_FREE 0x00 /* Thread at loose ends */ +#define TS_SLEEP 0x01 /* Awaiting an event */ +#define TS_RUN 0x02 /* Runnable, but not yet on a processor */ +#define TS_ONPROC 0x04 /* Thread is being run on a processor */ +#define TS_ZOMB 0x08 /* Thread has died but hasn't been reaped */ +#define TS_STOPPED 0x10 /* Stopped, initial state */ +#define TS_WAIT 0x20 /* Waiting to become runnable */ + +typedef struct ctxop { + void (*save_op)(void *); /* function to invoke to save context */ + void (*restore_op)(void *); /* function to invoke to restore ctx */ + void (*fork_op)(void *, void *); /* invoke to fork context */ + void (*lwp_create_op)(void *, void *); /* lwp_create context */ + void (*exit_op)(void *); /* invoked during {thread,lwp}_exit() */ + void (*free_op)(void *, int); /* function which frees the context */ + void *arg; /* argument to above functions, ctx pointer */ + struct ctxop *next; /* next context ops */ + struct ctxop *prev; /* previous context ops */ + hrtime_t save_ts; /* timestamp of last save */ + hrtime_t restore_ts; /* timestamp of last restore */ +} ctxop_t; + +/* + * The active file descriptor table. + * Each member of a_fd[] not equalling -1 represents an active fd. + * The structure is initialized on first use; all zeros means uninitialized. + */ +typedef struct { + kmutex_t a_fdlock; /* protects a_fd and a_nfd */ + int *a_fd; /* pointer to list of fds */ + int a_nfd; /* number of entries in *a_fd */ + int a_stale; /* one of the active fds is being closed */ + int a_buf[2]; /* buffer to which a_fd initially refers */ +} afd_t; + +/* + * An lwpchan provides uniqueness when sleeping on user-level + * synchronization primitives. The lc_wchan member is used + * for sleeping on kernel synchronization primitives. + */ +typedef struct { + caddr_t lc_wchan0; + caddr_t lc_wchan; +} lwpchan_t; + +typedef struct _kthread *kthread_id_t; + +struct turnstile; +struct panic_trap_info; +struct upimutex; +struct kproject; +struct on_trap_data; +struct waitq; +struct _kcpc_ctx; +struct _kcpc_set; + +/* Definition for kernel thread identifier type */ +typedef uint64_t kt_did_t; + +typedef struct _kthread { + struct _kthread *t_link; /* dispq, sleepq, and free queue link */ + + caddr_t t_stk; /* base of stack (kernel sp value to use) */ + void (*t_startpc)(void); /* PC where thread started */ + struct cpu *t_bound_cpu; /* cpu bound to, or NULL if not bound */ + short t_affinitycnt; /* nesting level of kernel affinity-setting */ + short t_bind_cpu; /* user-specified CPU binding (-1 if none) */ + uint_t t_flag; /* modified only by current thread */ + ushort_t t_proc_flag; /* modified holding ttproc(t)->p_lock */ + ushort_t t_schedflag; /* modified holding thread_lock(t) */ + volatile char t_preempt; /* don't preempt thread if set */ + volatile char t_preempt_lk; + uint_t t_state; /* thread state (protected by thread_lock) */ + pri_t t_pri; /* assigned thread priority */ + pri_t t_epri; /* inherited thread priority */ + pri_t t_cpri; /* thread scheduling class priority */ + char t_writer; /* sleeping in lwp_rwlock_lock(RW_WRITE_LOCK) */ + uchar_t t_bindflag; /* CPU and pset binding type */ + label_t t_pcb; /* pcb, save area when switching */ + lwpchan_t t_lwpchan; /* reason for blocking */ +#define t_wchan0 t_lwpchan.lc_wchan0 +#define t_wchan t_lwpchan.lc_wchan + struct _sobj_ops *t_sobj_ops; + id_t t_cid; /* scheduling class id */ + struct thread_ops *t_clfuncs; /* scheduling class ops vector */ + void *t_cldata; /* per scheduling class specific data */ + ctxop_t *t_ctx; /* thread context */ + uintptr_t t_lofault; /* ret pc for failed page faults */ + label_t *t_onfault; /* on_fault() setjmp buf */ + struct on_trap_data *t_ontrap; /* on_trap() protection data */ + caddr_t t_swap; /* the bottom of the stack, if from segkp */ + lock_t t_lock; /* used to resume() a thread */ + uint8_t t_lockstat; /* set while thread is in lockstat code */ + uint8_t t_pil; /* interrupt thread PIL */ + disp_lock_t t_pi_lock; /* lock protecting t_prioinv list */ + char t_nomigrate; /* do not migrate if set */ + struct cpu *t_cpu; /* CPU that thread last ran on */ + struct cpu *t_weakbound_cpu; /* cpu weakly bound to */ + struct lgrp_ld *t_lpl; /* load average for home lgroup */ + void *t_lgrp_reserv[2]; /* reserved for future */ + struct _kthread *t_intr; /* interrupted (pinned) thread */ + uint64_t t_intr_start; /* timestamp when time slice began */ + kt_did_t t_did; /* thread id for kernel debuggers */ + struct _kcpc_ctx *t_cpc_ctx; /* performance counter context */ + struct _kcpc_set *t_cpc_set; /* set this thread has bound */ + + /* + * non swappable part of the lwp state. + */ + id_t t_tid; /* lwp's id */ + id_t t_waitfor; /* target lwp id in lwp_wait() */ + struct sigqueue *t_sigqueue; /* queue of siginfo structs */ + k_sigset_t t_sig; /* signals pending to this process */ + k_sigset_t t_extsig; /* signals sent from another contract */ + k_sigset_t t_hold; /* hold signal bit mask */ + k_sigset_t t_sigwait; /* sigtimedwait/sigfd accepting these */ + struct _kthread *t_forw; /* process's forward thread link */ + struct _kthread *t_back; /* process's backward thread link */ + struct _kthread *t_thlink; /* tid (lwpid) lookup hash link */ + klwp_t *t_lwp; /* thread's lwp pointer */ + struct proc *t_procp; /* proc pointer */ + struct t_audit_data *t_audit_data; /* per thread audit data */ + struct _kthread *t_next; /* doubly linked list of all threads */ + struct _kthread *t_prev; + ushort_t t_whystop; /* reason for stopping */ + ushort_t t_whatstop; /* more detailed reason */ + int t_dslot; /* index in proc's thread directory */ + struct pollstate *t_pollstate; /* state used during poll(2) */ + struct pollcache *t_pollcache; /* to pass a pcache ptr by /dev/poll */ + struct cred *t_cred; /* pointer to current cred */ + time_t t_start; /* start time, seconds since epoch */ + clock_t t_lbolt; /* lbolt at last clock_tick() */ + hrtime_t t_stoptime; /* timestamp at stop() */ + uint_t t_pctcpu; /* %cpu at last clock_tick(), binary */ + /* point at right of high-order bit */ + short t_sysnum; /* system call number */ + kcondvar_t t_delay_cv; + kmutex_t t_delay_lock; + + /* + * Pointer to the dispatcher lock protecting t_state and state-related + * flags. This pointer can change during waits on the lock, so + * it should be grabbed only by thread_lock(). + */ + disp_lock_t *t_lockp; /* pointer to the dispatcher lock */ + ushort_t t_oldspl; /* spl level before dispatcher locked */ + volatile char t_pre_sys; /* pre-syscall work needed */ + lock_t t_lock_flush; /* for lock_mutex_flush() impl */ + struct _disp *t_disp_queue; /* run queue for chosen CPU */ + clock_t t_disp_time; /* last time this thread was running */ + + /* + * Post-syscall / post-trap flags. + * No lock is required to set these. + * These must be cleared only by the thread itself. + * + * t_astflag indicates that some post-trap processing is required, + * possibly a signal or a preemption. The thread will not + * return to user with this set. + * t_post_sys indicates that some unusualy post-system call + * handling is required, such as an error or tracing. + * t_sig_check indicates that some condition in ISSIG() must be + * checked, but doesn't prevent returning to user. + * t_post_sys_ast is a way of checking whether any of these three + * flags are set. + */ + union __tu { + struct __ts { + volatile char _t_astflag; /* AST requested */ + volatile char _t_sig_check; /* ISSIG required */ + volatile char _t_post_sys; /* post_syscall req */ + volatile char _t_trapret; /* call CL_TRAPRET */ + } _ts; + volatile int _t_post_sys_ast; /* OR of these flags */ + } _tu; +#define t_astflag _tu._ts._t_astflag +#define t_sig_check _tu._ts._t_sig_check +#define t_post_sys _tu._ts._t_post_sys +#define t_trapret _tu._ts._t_trapret +#define t_post_sys_ast _tu._t_post_sys_ast + + /* + * Real time microstate profiling. + */ + /* possible 4-byte filler */ + hrtime_t t_waitrq; /* timestamp for run queue wait time */ + int t_mstate; /* current microstate */ + struct rprof { + int rp_anystate; /* set if any state non-zero */ + uint_t rp_state[NMSTATES]; /* mstate profiling counts */ + } *t_rprof; + + /* + * There is a turnstile inserted into the list below for + * every priority inverted synchronization object that + * this thread holds. + */ + + struct turnstile *t_prioinv; + + /* + * Pointer to the turnstile attached to the synchronization + * object where this thread is blocked. + */ + + struct turnstile *t_ts; + + /* + * kernel thread specific data + * Borrowed from userland implementation of POSIX tsd + */ + struct tsd_thread { + struct tsd_thread *ts_next; /* threads with TSD */ + struct tsd_thread *ts_prev; /* threads with TSD */ + uint_t ts_nkeys; /* entries in value array */ + void **ts_value; /* array of value/key */ + } *t_tsd; + + clock_t t_stime; /* time stamp used by the swapper */ + struct door_data *t_door; /* door invocation data */ + kmutex_t *t_plockp; /* pointer to process's p_lock */ + + struct sc_shared *t_schedctl; /* scheduler activations shared data */ + uintptr_t t_sc_uaddr; /* user-level address of shared data */ + + struct cpupart *t_cpupart; /* partition containing thread */ + int t_bind_pset; /* processor set binding */ + + struct copyops *t_copyops; /* copy in/out ops vector */ + + caddr_t t_stkbase; /* base of the the stack */ + struct page *t_red_pp; /* if non-NULL, redzone is mapped */ + + afd_t t_activefd; /* active file descriptor table */ + + struct _kthread *t_priforw; /* sleepq per-priority sublist */ + struct _kthread *t_priback; + + struct sleepq *t_sleepq; /* sleep queue thread is waiting on */ + struct panic_trap_info *t_panic_trap; /* saved data from fatal trap */ + int *t_lgrp_affinity; /* lgroup affinity */ + struct upimutex *t_upimutex; /* list of upimutexes owned by thread */ + uint32_t t_nupinest; /* number of nested held upi mutexes */ + struct kproject *t_proj; /* project containing this thread */ + uint8_t t_unpark; /* modified holding t_delay_lock */ + uint8_t t_release; /* lwp_release() waked up the thread */ + uint8_t t_hatdepth; /* depth of recursive hat_memloads */ + uint8_t t_xpvcntr; /* see xen_block_migrate() */ + kcondvar_t t_joincv; /* cv used to wait for thread exit */ + void *t_taskq; /* for threads belonging to taskq */ + hrtime_t t_anttime; /* most recent time anticipatory load */ + /* was added to an lgroup's load */ + /* on this thread's behalf */ + char *t_pdmsg; /* privilege debugging message */ + + uint_t t_predcache; /* DTrace predicate cache */ + hrtime_t t_dtrace_vtime; /* DTrace virtual time */ + hrtime_t t_dtrace_start; /* DTrace slice start time */ + + uint8_t t_dtrace_stop; /* indicates a DTrace-desired stop */ + uint8_t t_dtrace_sig; /* signal sent via DTrace's raise() */ + + union __tdu { + struct __tds { + uint8_t _t_dtrace_on; /* hit a fasttrap tracepoint */ + uint8_t _t_dtrace_step; /* about to return to kernel */ + uint8_t _t_dtrace_ret; /* handling a return probe */ + uint8_t _t_dtrace_ast; /* saved ast flag */ +#ifdef __amd64 + uint8_t _t_dtrace_reg; /* modified register */ +#endif + } _tds; + ulong_t _t_dtrace_ft; /* bitwise or of these flags */ + } _tdu; +#define t_dtrace_ft _tdu._t_dtrace_ft +#define t_dtrace_on _tdu._tds._t_dtrace_on +#define t_dtrace_step _tdu._tds._t_dtrace_step +#define t_dtrace_ret _tdu._tds._t_dtrace_ret +#define t_dtrace_ast _tdu._tds._t_dtrace_ast +#ifdef __amd64 +#define t_dtrace_reg _tdu._tds._t_dtrace_reg +#endif + + uintptr_t t_dtrace_pc; /* DTrace saved pc from fasttrap */ + uintptr_t t_dtrace_npc; /* DTrace next pc from fasttrap */ + uintptr_t t_dtrace_scrpc; /* DTrace per-thread scratch location */ + uintptr_t t_dtrace_astpc; /* DTrace return sequence location */ +#ifdef __amd64 + uint64_t t_dtrace_regv; /* DTrace saved reg from fasttrap */ + uint64_t t_useracc; /* SMAP state saved across swtch() */ +#endif + hrtime_t t_hrtime; /* high-res last time on cpu */ + kmutex_t t_ctx_lock; /* protects t_ctx in removectx() */ + struct waitq *t_waitq; /* wait queue */ + kmutex_t t_wait_mutex; /* used in CV wait functions */ + + char *t_name; /* thread name */ + + uint64_t t_unsafe; /* unsafe to run with SMT VCPU thread */ +} kthread_t; + +/* + * Thread flag (t_flag) definitions. + * These flags must be changed only for the current thread, + * and not during preemption code, since the code being + * preempted could be modifying the flags. + * + * For the most part these flags do not need locking. + * The following flags will only be changed while the thread_lock is held, + * to give assurrance that they are consistent with t_state: + * T_WAKEABLE + */ +#define T_INTR_THREAD 0x0001 /* thread is an interrupt thread */ +#define T_WAKEABLE 0x0002 /* thread is blocked, signals enabled */ +#define T_TOMASK 0x0004 /* use lwp_sigoldmask on return from signal */ +#define T_TALLOCSTK 0x0008 /* thread structure allocated from stk */ +#define T_FORKALL 0x0010 /* thread was cloned by forkall() */ +#define T_WOULDBLOCK 0x0020 /* for lockfs */ +#define T_DONTBLOCK 0x0040 /* for lockfs */ +#define T_DONTPEND 0x0080 /* for lockfs */ +#define T_SYS_PROF 0x0100 /* profiling on for duration of system call */ +#define T_WAITCVSEM 0x0200 /* waiting for a lwp_cv or lwp_sema on sleepq */ +#define T_WATCHPT 0x0400 /* thread undergoing a watchpoint emulation */ +#define T_PANIC 0x0800 /* thread initiated a system panic */ +#define T_LWPREUSE 0x1000 /* stack and LWP can be reused */ +#define T_CAPTURING 0x2000 /* thread is in page capture logic */ +#define T_VFPARENT 0x4000 /* thread is vfork parent, must call vfwait */ +#define T_DONTDTRACE 0x8000 /* disable DTrace probes */ +#define T_KFPU 0x10000 /* kernel FPU active */ +#define T_PUSHPAGE 0x20000 /* this thread may be assisting pageout */ + +/* + * Flags in t_proc_flag. + * These flags must be modified only when holding the p_lock + * for the associated process. + */ +#define TP_DAEMON 0x0001 /* this is an LWP_DAEMON lwp */ +#define TP_HOLDLWP 0x0002 /* hold thread's lwp */ +#define TP_TWAIT 0x0004 /* wait to be freed by lwp_wait() */ +#define TP_LWPEXIT 0x0008 /* lwp has exited */ +#define TP_PRSTOP 0x0010 /* thread is being stopped via /proc */ +#define TP_CHKPT 0x0020 /* thread is being stopped via CPR checkpoint */ +#define TP_EXITLWP 0x0040 /* terminate this lwp */ +#define TP_PRVSTOP 0x0080 /* thread is virtually stopped via /proc */ +#define TP_MSACCT 0x0100 /* collect micro-state accounting information */ +#define TP_STOPPING 0x0200 /* thread is executing stop() */ +#define TP_WATCHPT 0x0400 /* process has watchpoints in effect */ +#define TP_PAUSE 0x0800 /* process is being stopped via pauselwps() */ +#define TP_CHANGEBIND 0x1000 /* thread has a new cpu/cpupart binding */ +#define TP_ZTHREAD 0x2000 /* this is a kernel thread for a zone */ +#define TP_WATCHSTOP 0x4000 /* thread is stopping via holdwatch() */ +#define TP_KTHREAD 0x8000 /* in-kernel worker thread for a process */ + +/* + * Thread scheduler flag (t_schedflag) definitions. + * The thread must be locked via thread_lock() or equiv. to change these. + */ +#define TS_LOAD 0x0001 /* thread is in memory */ +#define TS_DONT_SWAP 0x0002 /* thread/lwp should not be swapped */ +#define TS_SWAPENQ 0x0004 /* swap thread when it reaches a safe point */ +#define TS_ON_SWAPQ 0x0008 /* thread is on the swap queue */ +#define TS_SIGNALLED 0x0010 /* thread was awakened by cv_signal() */ +#define TS_PROJWAITQ 0x0020 /* thread is on its project's waitq */ +#define TS_ZONEWAITQ 0x0040 /* thread is on its zone's waitq */ +#define TS_VCPU 0x0080 /* thread will enter guest context */ +#define TS_CSTART 0x0100 /* setrun() by continuelwps() */ +#define TS_UNPAUSE 0x0200 /* setrun() by unpauselwps() */ +#define TS_XSTART 0x0400 /* setrun() by SIGCONT */ +#define TS_PSTART 0x0800 /* setrun() by /proc */ +#define TS_RESUME 0x1000 /* setrun() by CPR resume process */ +#define TS_CREATE 0x2000 /* setrun() by syslwp_create() */ +#define TS_RUNQMATCH 0x4000 /* exact run queue balancing by setbackdq() */ +#define TS_BSTART 0x8000 /* setrun() by brand */ +#define TS_ALLSTART \ + (TS_CSTART|TS_UNPAUSE|TS_XSTART|TS_PSTART|TS_RESUME|TS_CREATE|TS_BSTART) +#define TS_ANYWAITQ (TS_PROJWAITQ|TS_ZONEWAITQ) + +/* + * Thread binding types + */ +#define TB_ALLHARD 0 +#define TB_CPU_SOFT 0x01 /* soft binding to CPU */ +#define TB_PSET_SOFT 0x02 /* soft binding to pset */ + +#define TB_CPU_SOFT_SET(t) ((t)->t_bindflag |= TB_CPU_SOFT) +#define TB_CPU_HARD_SET(t) ((t)->t_bindflag &= ~TB_CPU_SOFT) +#define TB_PSET_SOFT_SET(t) ((t)->t_bindflag |= TB_PSET_SOFT) +#define TB_PSET_HARD_SET(t) ((t)->t_bindflag &= ~TB_PSET_SOFT) +#define TB_CPU_IS_SOFT(t) ((t)->t_bindflag & TB_CPU_SOFT) +#define TB_CPU_IS_HARD(t) (!TB_CPU_IS_SOFT(t)) +#define TB_PSET_IS_SOFT(t) ((t)->t_bindflag & TB_PSET_SOFT) + +/* + * No locking needed for AST field. + */ +#define aston(t) ((t)->t_astflag = 1) +#define astoff(t) ((t)->t_astflag = 0) + +/* True if thread is stopped on an event of interest */ +#define ISTOPPED(t) ((t)->t_state == TS_STOPPED && \ + !((t)->t_schedflag & TS_PSTART)) + +/* True if thread is stopped for a brand-specific reason */ +#define BSTOPPED(t) ((t)->t_state == TS_STOPPED && \ + !((t)->t_schedflag & TS_BSTART)) + +/* True if thread is asleep and wakeable */ +#define ISWAKEABLE(t) (((t)->t_state == TS_SLEEP && \ + ((t)->t_flag & T_WAKEABLE))) + +/* True if thread is on the wait queue */ +#define ISWAITING(t) ((t)->t_state == TS_WAIT) + +/* similar to ISTOPPED except the event of interest is CPR */ +#define CPR_ISTOPPED(t) ((t)->t_state == TS_STOPPED && \ + !((t)->t_schedflag & TS_RESUME)) + +/* + * True if thread is virtually stopped (is or was asleep in + * one of the lwp_*() system calls and marked to stop by /proc.) + */ +#define VSTOPPED(t) ((t)->t_proc_flag & TP_PRVSTOP) + +/* similar to VSTOPPED except the point of interest is CPR */ +#define CPR_VSTOPPED(t) \ + ((t)->t_state == TS_SLEEP && \ + (t)->t_wchan0 != NULL && \ + ((t)->t_flag & T_WAKEABLE) && \ + ((t)->t_proc_flag & TP_CHKPT)) + +/* True if thread has been stopped by hold*() or was created stopped */ +#define SUSPENDED(t) ((t)->t_state == TS_STOPPED && \ + ((t)->t_schedflag & (TS_CSTART|TS_UNPAUSE)) != (TS_CSTART|TS_UNPAUSE)) + +/* True if thread possesses an inherited priority */ +#define INHERITED(t) ((t)->t_epri != 0) + +/* The dispatch priority of a thread */ +#define DISP_PRIO(t) ((t)->t_epri > (t)->t_pri ? (t)->t_epri : (t)->t_pri) + +/* The assigned priority of a thread */ +#define ASSIGNED_PRIO(t) ((t)->t_pri) + +/* + * Macros to determine whether a thread can be swapped. + * If t_lock is held, the thread is either on a processor or being swapped. + */ +#define SWAP_OK(t) (!LOCK_HELD(&(t)->t_lock)) + +/* + * proctot(x) + * convert a proc pointer to a thread pointer. this only works with + * procs that have only one lwp. + * + * proctolwp(x) + * convert a proc pointer to a lwp pointer. this only works with + * procs that have only one lwp. + * + * ttolwp(x) + * convert a thread pointer to its lwp pointer. + * + * ttoproc(x) + * convert a thread pointer to its proc pointer. + * + * ttoproj(x) + * convert a thread pointer to its project pointer. + * + * ttozone(x) + * convert a thread pointer to its zone pointer. + * + * lwptot(x) + * convert a lwp pointer to its thread pointer. + * + * lwptoproc(x) + * convert a lwp to its proc pointer. + */ +#define proctot(x) ((x)->p_tlist) +#define proctolwp(x) ((x)->p_tlist->t_lwp) +#define ttolwp(x) ((x)->t_lwp) +#define ttoproc(x) ((x)->t_procp) +#define ttoproj(x) ((x)->t_proj) +#define ttozone(x) ((x)->t_procp->p_zone) +#define lwptot(x) ((x)->lwp_thread) +#define lwptoproc(x) ((x)->lwp_procp) + +#define t_pc t_pcb.val[0] +#define t_sp t_pcb.val[1] + +#ifdef _KERNEL + +extern kthread_t *threadp(void); /* inline, returns thread pointer */ +#define curthread (threadp()) /* current thread pointer */ +#define curproc (ttoproc(curthread)) /* current process pointer */ +#define curproj (ttoproj(curthread)) /* current project pointer */ +#define curzone (curproc->p_zone) /* current zone pointer */ + +extern struct _kthread t0; /* the scheduler thread */ +extern kmutex_t pidlock; /* global process lock */ + +/* + * thread_free_lock is used by the tick accounting thread to keep a thread + * from being freed while it is being examined. + * + * Thread structures are 32-byte aligned structures. That is why we use the + * following formula. + */ +#define THREAD_FREE_BITS 10 +#define THREAD_FREE_NUM (1 << THREAD_FREE_BITS) +#define THREAD_FREE_MASK (THREAD_FREE_NUM - 1) +#define THREAD_FREE_1 PTR24_LSB +#define THREAD_FREE_2 (PTR24_LSB + THREAD_FREE_BITS) +#define THREAD_FREE_SHIFT(t) \ + (((ulong_t)(t) >> THREAD_FREE_1) ^ ((ulong_t)(t) >> THREAD_FREE_2)) +#define THREAD_FREE_HASH(t) (THREAD_FREE_SHIFT(t) & THREAD_FREE_MASK) + +typedef struct thread_free_lock { + kmutex_t tf_lock; + uchar_t tf_pad[64 - sizeof (kmutex_t)]; +} thread_free_lock_t; + +extern void thread_free_prevent(kthread_t *); +extern void thread_free_allow(kthread_t *); + +/* + * Routines to change the priority and effective priority + * of a thread-locked thread, whatever its state. + */ +extern int thread_change_pri(kthread_t *t, pri_t disp_pri, int front); +extern void thread_change_epri(kthread_t *t, pri_t disp_pri); + +/* + * Routines that manipulate the dispatcher lock for the thread. + * The locking heirarchy is as follows: + * cpu_lock > sleepq locks > run queue locks + */ +void thread_transition(kthread_t *); /* move to transition lock */ +void thread_stop(kthread_t *); /* move to stop lock */ +void thread_lock(kthread_t *); /* lock thread and its queue */ +void thread_lock_high(kthread_t *); /* lock thread and its queue */ +void thread_onproc(kthread_t *, struct cpu *); /* set onproc state lock */ + +#define thread_unlock(t) disp_lock_exit((t)->t_lockp) +#define thread_unlock_high(t) disp_lock_exit_high((t)->t_lockp) +#define thread_unlock_nopreempt(t) disp_lock_exit_nopreempt((t)->t_lockp) + +#define THREAD_LOCK_HELD(t) (DISP_LOCK_HELD((t)->t_lockp)) + +extern disp_lock_t transition_lock; /* lock protecting transiting threads */ +extern disp_lock_t stop_lock; /* lock protecting stopped threads */ + +caddr_t thread_stk_init(caddr_t); /* init thread stack */ + +int thread_setname(kthread_t *, const char *); +int thread_vsetname(kthread_t *, const char *, ...); + +extern int default_binding_mode; +extern int default_stksize; + +#endif /* _KERNEL */ + +#define THREAD_NAME_MAX 32 /* includes terminating NUL */ + +/* + * Macro to change a thread's priority. + */ +#define THREAD_CHANGE_PRI(t, pri) { \ + pri_t __new_pri = (pri); \ + DTRACE_SCHED2(change__pri, kthread_t *, (t), pri_t, __new_pri); \ + (t)->t_pri = __new_pri; \ + schedctl_set_cidpri(t); \ +} + +/* + * Macro to indicate that a thread's priority is about to be changed. + */ +#define THREAD_WILLCHANGE_PRI(t, pri) { \ + DTRACE_SCHED2(change__pri, kthread_t *, (t), pri_t, (pri)); \ +} + +/* + * Macros to change thread state and the associated lock. + */ +#define THREAD_SET_STATE(tp, state, lp) \ + ((tp)->t_state = state, (tp)->t_lockp = lp) + +/* + * Point it at the transition lock, which is always held. + * The previosly held lock is dropped. + */ +#define THREAD_TRANSITION(tp) thread_transition(tp); +/* + * Set the thread's lock to be the transition lock, without dropping + * previosly held lock. + */ +#define THREAD_TRANSITION_NOLOCK(tp) ((tp)->t_lockp = &transition_lock) + +/* + * Put thread in run state, and set the lock pointer to the dispatcher queue + * lock pointer provided. This lock should be held. + */ +#define THREAD_RUN(tp, lp) THREAD_SET_STATE(tp, TS_RUN, lp) + +/* + * Put thread in wait state, and set the lock pointer to the wait queue + * lock pointer provided. This lock should be held. + */ +#define THREAD_WAIT(tp, lp) THREAD_SET_STATE(tp, TS_WAIT, lp) + +/* + * Put thread in run state, and set the lock pointer to the dispatcher queue + * lock pointer provided (i.e., the "swapped_lock"). This lock should be held. + */ +#define THREAD_SWAP(tp, lp) THREAD_SET_STATE(tp, TS_RUN, lp) + +/* + * Put the thread in zombie state and set the lock pointer to NULL. + * The NULL will catch anything that tries to lock a zombie. + */ +#define THREAD_ZOMB(tp) THREAD_SET_STATE(tp, TS_ZOMB, NULL) + +/* + * Set the thread into ONPROC state, and point the lock at the CPUs + * lock for the onproc thread(s). This lock should be held, so the + * thread deoes not become unlocked, since these stores can be reordered. + */ +#define THREAD_ONPROC(tp, cpu) \ + THREAD_SET_STATE(tp, TS_ONPROC, &(cpu)->cpu_thread_lock) + +/* + * Set the thread into the TS_SLEEP state, and set the lock pointer to + * to some sleep queue's lock. The new lock should already be held. + */ +#define THREAD_SLEEP(tp, lp) { \ + disp_lock_t *tlp; \ + tlp = (tp)->t_lockp; \ + THREAD_SET_STATE(tp, TS_SLEEP, lp); \ + disp_lock_exit_high(tlp); \ + } + +/* + * Interrupt threads are created in TS_FREE state, and their lock + * points at the associated CPU's lock. + */ +#define THREAD_FREEINTR(tp, cpu) \ + THREAD_SET_STATE(tp, TS_FREE, &(cpu)->cpu_thread_lock) + +/* if tunable kmem_stackinfo is set, fill kthread stack with a pattern */ +#define KMEM_STKINFO_PATTERN 0xbadcbadcbadcbadcULL + +/* + * If tunable kmem_stackinfo is set, log the latest KMEM_LOG_STK_USAGE_SIZE + * dead kthreads that used their kernel stack the most. + */ +#define KMEM_STKINFO_LOG_SIZE 16 + +/* kthread name (cmd/lwpid) string size in the stackinfo log */ +#define KMEM_STKINFO_STR_SIZE 64 + +/* + * stackinfo logged data. + */ +typedef struct kmem_stkinfo { + caddr_t kthread; /* kthread pointer */ + caddr_t t_startpc; /* where kthread started */ + caddr_t start; /* kthread stack start address */ + size_t stksz; /* kthread stack size */ + size_t percent; /* kthread stack high water mark */ + id_t t_tid; /* kthread id */ + char cmd[KMEM_STKINFO_STR_SIZE]; /* kthread name (cmd/lwpid) */ +} kmem_stkinfo_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_THREAD_H */ diff --git a/illumos-x86_64/usr/include/sys/ticlts.h b/illumos-x86_64/usr/include/sys/ticlts.h new file mode 100644 index 00000000..a0f42424 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ticlts.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993 by Sun Microsystems Inc. + */ + +#ifndef _SYS_TICLTS_H +#define _SYS_TICLTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Old error codes exposed in old man pages. Only for compatability. + * Do not use in any new program. + */ +#define TCL_BADADDR EINVAL /* bad addr specification */ +#define TCL_BADOPT EINVAL /* bad option specification */ +#define TCL_NOPEER EFAULT /* dest addr is unbound */ +#define TCL_PEERBADSTATE EPROTO /* peer in wrong state */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TICLTS_H */ diff --git a/illumos-x86_64/usr/include/sys/ticots.h b/illumos-x86_64/usr/include/sys/ticots.h new file mode 100644 index 00000000..e0000855 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ticots.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993 by Sun Microsystems Inc. + */ + +#ifndef _SYS_TICOTS_H +#define _SYS_TICOTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Old error codes exposed in old man pages. Only for compatability. + * Do not use in any new program. + */ +#define TCO_NOPEER ECONNREFUSED /* no listener on dest addr */ +#define TCO_PEERNOROOMONQ ECONNREFUSED /* no room on incoming queue */ +#define TCO_PEERBADSTATE ECONNREFUSED /* peer in wrong state */ +#define TCO_PEERINITIATED ECONNRESET /* peer-initiated disconnect */ +#define TCO_PROVIDERINITIATED ECONNRESET /* provider-initiated discon */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TICOTS_H */ diff --git a/illumos-x86_64/usr/include/sys/ticotsord.h b/illumos-x86_64/usr/include/sys/ticotsord.h new file mode 100644 index 00000000..8fce8430 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ticotsord.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993 by Sun Microsystems Inc. + */ + +#ifndef _SYS_TICOTSORD_H +#define _SYS_TICOTSORD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Old error codes exposed in old man pages. Only for compatability. + * Do not use in any new program. + */ +#define TCOO_NOPEER ECONNREFUSED /* no listener on dest addr */ +#define TCOO_PEERNOROOMONQ ECONNREFUSED /* no room on incoming queue */ +#define TCOO_PEERBADSTATE ECONNREFUSED /* peer in wrong state */ +#define TCOO_PEERINITIATED ECONNRESET /* peer-initiated disconnect */ +#define TCOO_PROVIDERINITIATED ECONNRESET /* provider-initiated discon */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TICOTSORD_H */ diff --git a/illumos-x86_64/usr/include/sys/tihdr.h b/illumos-x86_64/usr/include/sys/tihdr.h new file mode 100644 index 00000000..e3bc4759 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tihdr.h @@ -0,0 +1,726 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_TIHDR_H +#define _SYS_TIHDR_H + +#include +/* + * Include declarations implicit to TPI and shared with user level code + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The feature test macro, _SUN_TPI_VERSION makes some of additional + * declarations available and changes some existing ones. There was + * some changes done to this interface and this feature test macro + * enables transitioning to those changes while maintaining retaining + * backward compatibility. + * + * The following is all the information + * needed by the Transport Service Interface. + */ + +/* + * The following are the definitions of the Transport + * Service Interface primitives. + */ + +/* + * Primitives that are initiated by the transport user. + */ +#define T_CONN_REQ 0 /* connection request */ +#if _SUN_TPI_VERSION > 1 +#define O_T_CONN_RES 1 /* old connection response */ +#else +#define T_CONN_RES 1 /* connection response */ +#endif /* _SUN_TPI_VERSION > 1 */ +#define T_DISCON_REQ 2 /* disconnect request */ +#define T_DATA_REQ 3 /* data request */ +#define T_EXDATA_REQ 4 /* expedited data request */ +#define T_INFO_REQ 5 /* information request */ +/* + * Bind Request primitive (TLI inspired + * address binding semantics). If requested address is + * found to be busy, an alternative free address is + * returned. (Requires comparison of requested address to + * returned address to verify if the requested address was + * bound) + * + */ +#if _SUN_TPI_VERSION > 0 +#define O_T_BIND_REQ 6 +#else +#define T_BIND_REQ 6 +#endif /* _SUN_TPI_VERSION > 0 */ + +#define T_UNBIND_REQ 7 /* unbind request */ +#define T_UNITDATA_REQ 8 /* unitdata request */ + +/* + * Option management request (with TLI inspired semantics ) + * The preferred name for this primitive in new code is T_SVR4_OPTMGMT_REQ. + * This primitive had the name T_OPTMGMT_REQ in old SVR4 derived TPI. + * This primitive is used for TLI and Socket API support. + * The packing of options in option buffer is private contract + * between transport provider and its users and can differ + * between different transports. + * (The name O_T_OPTMGMT_REQ continues to exist for Solaris 2.6 + * compilation environment compatibility only) + * + */ +#define T_SVR4_OPTMGMT_REQ 9 +#if _SUN_TPI_VERSION > 0 +#define O_T_OPTMGMT_REQ T_SVR4_OPTMGMT_REQ +#else +#define T_OPTMGMT_REQ T_SVR4_OPTMGMT_REQ +#endif /* _SUN_TPI_VERSION > 0 */ + +#define T_ORDREL_REQ 10 /* orderly release req */ + +/* + * Primitives that are initiated by the transport provider. + */ +#define T_CONN_IND 11 /* connection indication */ +#define T_CONN_CON 12 /* connection confirmation */ +#define T_DISCON_IND 13 /* disconnect indication */ +#define T_DATA_IND 14 /* data indication */ +#define T_EXDATA_IND 15 /* expeditied data indication */ +#define T_INFO_ACK 16 /* information acknowledgment */ +#define T_BIND_ACK 17 /* bind acknowledment */ +#define T_ERROR_ACK 18 /* error acknowledgment */ +#define T_OK_ACK 19 /* ok acknowledgment */ +#define T_UNITDATA_IND 20 /* unitdata indication */ +#define T_UDERROR_IND 21 /* unitdata error indication */ +#define T_OPTMGMT_ACK 22 /* manage options ack */ +#define T_ORDREL_IND 23 /* orderly release ind */ +/* + * Primitives added to namespace and contain a mix of ones + * initiated by transport user or provider. + */ +#define T_ADDR_REQ 24 /* address request */ +#define T_ADDR_ACK 25 /* address acknowledgement */ + +#if _SUN_TPI_VERSION > 0 +/* + * Bind request primitive with better address + * binding semantics. (XTI inspired) + * If the requested address is found to be busy, + * an error is returned. (No need to compare addresses on successful + * bind acknowledgement). + */ +#define T_BIND_REQ 26 /* bind request */ + +/* + * Option management request (with XTI inspired semantics) + * The packing of options in option buffer is required to + * be with 'struct T_opthdr' data structure defined later in + * this header. + */ +#define T_OPTMGMT_REQ 27 /* manage options req - T_opthdr option header */ +#endif /* _SUN_TPI_VERSION > 0 */ + +#if _SUN_TPI_VERSION > 1 +/* + * The connection response that expects its ACCEPTOR_id to have been + * filled in from the value supplied via a T_CAPABILITY_ACK. + */ +#define T_CONN_RES 28 /* connection response */ + +/* + * Capability request and ack. These primitives are optional and + * subsume the functionality of T_INFO_{REQ,ACK}. + */ +#define T_CAPABILITY_REQ 30 +#define T_CAPABILITY_ACK 31 +#endif /* _SUN_TPI_VERSION > 1 */ + +#ifdef _KERNEL +/* + * Sun private TPI extensions. They are currently used for transparently + * passing options through the connection-oriented loopback transport. + * Values assigned to them may change. + * + * T_EXTCONN_IND (extended T_CONN_IND) is used to return dst as well as + * src addr/port. + */ +#define T_OPTDATA_REQ 0x1001 /* data (with options) request */ +#define T_OPTDATA_IND 0x1002 /* data (with options) indication */ +#define T_EXTCONN_IND 0x1003 /* extended T_CONN_IND to return dst as well */ + +#endif /* _KERNEL */ + +/* + * The following are the possible states of the Transport + * Service Interface + */ + +#define TS_UNBND 0 /* unbound */ +#define TS_WACK_BREQ 1 /* waiting ack of BIND_REQ */ +#define TS_WACK_UREQ 2 /* waiting ack of UNBIND_REQ */ +#define TS_IDLE 3 /* idle */ +#define TS_WACK_OPTREQ 4 /* wait ack options request */ +#define TS_WACK_CREQ 5 /* waiting ack of CONN_REQ */ +#define TS_WCON_CREQ 6 /* waiting confirm of CONN_REQ */ +#define TS_WRES_CIND 7 /* waiting response of CONN_IND */ +#define TS_WACK_CRES 8 /* waiting ack of CONN_RES */ +#define TS_DATA_XFER 9 /* data transfer */ +#define TS_WIND_ORDREL 10 /* releasing rd but not wr */ +#define TS_WREQ_ORDREL 11 /* wait to release wr but not rd */ +#define TS_WACK_DREQ6 12 /* waiting ack of DISCON_REQ */ +#define TS_WACK_DREQ7 13 /* waiting ack of DISCON_REQ */ +#define TS_WACK_DREQ9 14 /* waiting ack of DISCON_REQ */ +#define TS_WACK_DREQ10 15 /* waiting ack of DISCON_REQ */ +#define TS_WACK_DREQ11 16 /* waiting ack of DISCON_REQ */ + +#define TS_NOSTATES 17 + + +/* + * The following structure definitions define the format of the + * stream message block of the above primitives. + * (everything is declared t_scalar_t to ensure proper alignment + * across different machines) + */ + +/* connection request */ + +struct T_conn_req { + t_scalar_t PRIM_type; /* always T_CONN_REQ */ + t_scalar_t DEST_length; /* dest addr length */ + t_scalar_t DEST_offset; /* dest addr offset */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ +}; + +/* connect response */ + +/* + * Historical compatibility note for "struct T_conn_res" usage. + * "QUEUE_ptr" field of type "queue_t" is obsolete to support + * code portability and application binary compatibility + * between ILP32(32-bit) and LP64 (64-bit) environments. + * Use field "ACCEPTOR_id" instead. + * For compatibility, drivers using (_SUN_TPI_VERSION >= 2) interface + * can support treating ACCEPTOR_id content as queue pointer + * only when PRIM_type is O_T_CONN_RES. + */ +struct T_conn_res { + t_scalar_t PRIM_type; /* T_CONN_RES (or O_T_CONN_RES) */ + t_uscalar_t ACCEPTOR_id; /* id of accepting endpoint */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ + t_scalar_t SEQ_number; /* sequence number */ +}; + +/* disconnect request */ + +struct T_discon_req { + t_scalar_t PRIM_type; /* always T_DISCON_REQ */ + t_scalar_t SEQ_number; /* sequnce number */ +}; + +/* data request */ + +struct T_data_req { + t_scalar_t PRIM_type; /* always T_DATA_REQ */ + t_scalar_t MORE_flag; /* more data */ +}; + +/* expedited data request */ + +struct T_exdata_req { + t_scalar_t PRIM_type; /* always T_EXDATA_REQ */ + t_scalar_t MORE_flag; /* more data */ +}; + +/* information request */ + +struct T_info_req { + t_scalar_t PRIM_type; /* always T_INFO_REQ */ +}; + +/* bind request */ + +struct T_bind_req { + t_scalar_t PRIM_type; /* T_BIND_REQ (or O_T_BIND_REQ) */ + t_scalar_t ADDR_length; /* addr length */ + t_scalar_t ADDR_offset; /* addr offset */ + t_uscalar_t CONIND_number; /* connect indications requested */ +}; + +/* unbind request */ + +struct T_unbind_req { + t_scalar_t PRIM_type; /* always T_UNBIND_REQ */ +}; + +/* unitdata request */ + +struct T_unitdata_req { + t_scalar_t PRIM_type; /* always T_UNITDATA_REQ */ + t_scalar_t DEST_length; /* dest addr length */ + t_scalar_t DEST_offset; /* dest addr offset */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ +}; + +/* manage options request */ + +struct T_optmgmt_req { + t_scalar_t PRIM_type; /* T_OPTMGMT_REQ or */ + /* T_SVR4_OPTMGMT_REQ */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ + t_scalar_t MGMT_flags; /* options flags */ +}; + +/* orderly release request */ + +struct T_ordrel_req { + t_scalar_t PRIM_type; /* always T_ORDREL_REQ */ +}; + +/* protocol address request */ + +struct T_addr_req { + t_scalar_t PRIM_type; /* always T_ADDR_REQ */ +}; + +/* connect indication */ + +struct T_conn_ind { + t_scalar_t PRIM_type; /* always T_CONN_IND */ + t_scalar_t SRC_length; /* src addr length */ + t_scalar_t SRC_offset; /* src addr offset */ + t_scalar_t OPT_length; /* option length */ + t_scalar_t OPT_offset; /* option offset */ + t_scalar_t SEQ_number; /* sequnce number */ +}; + +/* connect confirmation */ + +struct T_conn_con { + t_scalar_t PRIM_type; /* always T_CONN_CON */ + t_scalar_t RES_length; /* responding addr length */ + t_scalar_t RES_offset; /* responding addr offset */ + t_scalar_t OPT_length; /* option length */ + t_scalar_t OPT_offset; /* option offset */ +}; + +/* disconnect indication */ + +struct T_discon_ind { + t_scalar_t PRIM_type; /* always T_DISCON_IND */ + t_scalar_t DISCON_reason; /* disconnect reason */ + t_scalar_t SEQ_number; /* sequnce number */ +}; + +/* data indication */ + +struct T_data_ind { + t_scalar_t PRIM_type; /* always T_DATA_IND */ + t_scalar_t MORE_flag; /* more data */ +}; + +/* expedited data indication */ + +struct T_exdata_ind { + t_scalar_t PRIM_type; /* always T_EXDATA_IND */ + t_scalar_t MORE_flag; /* more data */ +}; + +/* information acknowledgment */ + +struct T_info_ack { + t_scalar_t PRIM_type; /* always T_INFO_ACK */ + t_scalar_t TSDU_size; /* max TSDU size */ + t_scalar_t ETSDU_size; /* max ETSDU size */ + t_scalar_t CDATA_size; /* max connect data size */ + t_scalar_t DDATA_size; /* max discon data size */ + t_scalar_t ADDR_size; /* address size */ + t_scalar_t OPT_size; /* options size */ + t_scalar_t TIDU_size; /* max TIDU size */ + t_scalar_t SERV_type; /* provider service type */ + t_scalar_t CURRENT_state; /* current state */ + t_scalar_t PROVIDER_flag; /* provider flags */ +}; + +/* + * The following are definitions of flags available to the transport + * provider to set in the PROVIDER_flag field of the T_info_ack + * structure. + */ + +#if _SUN_TPI_VERSION > 0 +#define SENDZERO 0x0001 /* provider can handle --length TSDUs */ + +#define OLD_SENDZERO 0x1000 /* reserved for compatibility with */ + /* old providers- old value of */ + /* SENDZERO defined in */ +#else +#define SENDZERO 0x1000 /* old SENDZERO value */ +#endif /* _SUN_TPI_VERSION > 0 */ + +#define EXPINLINE 0x0002 /* provider wants ETSDUs in band 0 */ +/* + * Flag XPG4_1: + * transport provider supports TPI modifications motivated by and + * in conjunction with XTI inspired TPI support and all the + * compatibility baggage that implies. + * It implies, - primitives T_ADDR_REQ & T_ADDR_ACK supported + * - primitives O_T_BIND_REQ & T_BIND_REQ separately supported + * - primitives T_SVR4_OPTMGMT_REQ & T_OPTMGMT_REQ separately + * supported. + */ +#define XPG4_1 0x0004 + +/* bind acknowledgment */ + +struct T_bind_ack { + t_scalar_t PRIM_type; /* always T_BIND_ACK */ + t_scalar_t ADDR_length; /* addr length */ + t_scalar_t ADDR_offset; /* addr offset */ + t_uscalar_t CONIND_number; /* connect ind to be queued */ +}; + +/* error acknowledgment */ + +struct T_error_ack { + t_scalar_t PRIM_type; /* always T_ERROR_ACK */ + t_scalar_t ERROR_prim; /* primitive in error */ + t_scalar_t TLI_error; /* TLI error code */ + t_scalar_t UNIX_error; /* UNIX error code */ +}; + +/* ok acknowledgment */ + +struct T_ok_ack { + t_scalar_t PRIM_type; /* always T_OK_ACK */ + t_scalar_t CORRECT_prim; /* correct primitive */ +}; + +/* unitdata indication */ + +struct T_unitdata_ind { + t_scalar_t PRIM_type; /* always T_UNITDATA_IND */ + t_scalar_t SRC_length; /* source addr length */ + t_scalar_t SRC_offset; /* source addr offset */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ +}; + +/* unitdata error indication */ + +struct T_uderror_ind { + t_scalar_t PRIM_type; /* always T_UDERROR_IND */ + t_scalar_t DEST_length; /* dest addr length */ + t_scalar_t DEST_offset; /* dest addr offset */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ + t_scalar_t ERROR_type; /* error type */ +}; + +/* manage options ack */ + +struct T_optmgmt_ack { + t_scalar_t PRIM_type; /* always T_OPTMGMT_ACK */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ + t_scalar_t MGMT_flags; /* managment flags */ +}; + +/* orderly release indication */ + +struct T_ordrel_ind { + t_scalar_t PRIM_type; /* always T_ORDREL_IND */ +}; + + +/* protocol address acknowledgment */ + +struct T_addr_ack { + t_scalar_t PRIM_type; /* always T_ADDR_ACK */ + t_scalar_t LOCADDR_length; /* length of local address */ + t_scalar_t LOCADDR_offset; /* offset of local address */ + t_scalar_t REMADDR_length; /* length of remote address */ + t_scalar_t REMADDR_offset; /* offset of remote address */ +}; + +#if _SUN_TPI_VERSION > 1 +/* + * Capability request and ack. These primitives are optional and + * subsume the functionality of T_INFO_{REQ,ACK}. + */ +struct T_capability_req { + t_scalar_t PRIM_type; /* always T_CAPABILITY_REQ */ + t_uscalar_t CAP_bits1; /* capability bits #1 */ +}; + +struct T_capability_ack { + t_scalar_t PRIM_type; /* always T_CAPABILITY_ACK */ + t_uscalar_t CAP_bits1; /* capability bits #1 */ + struct T_info_ack + INFO_ack; /* info acknowledgement */ + t_uscalar_t ACCEPTOR_id; /* accepting endpoint id */ +}; + +#define TC1_INFO (1u << 0) /* Info request/ack */ +#define TC1_ACCEPTOR_ID (1u << 1) /* Acceptor_id request/ack */ +#define TC1_CAP_BITS2 (1u << 31) /* Reserved for future use */ + +#endif /* _SUN_TPI_VERSION > 1 */ + +#ifdef _KERNEL +/* + * Private Sun TPI extensions. + */ + +/* data (with options) request */ +struct T_optdata_req { + t_scalar_t PRIM_type; /* always T_OPTDATA_REQ */ + t_scalar_t DATA_flag; /* flags like "more data" */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ +}; + +/* data (with options) indication */ +struct T_optdata_ind { + t_scalar_t PRIM_type; /* always T_OPTDATA_IND */ + t_scalar_t DATA_flag; /* flags like "more data" */ + t_scalar_t OPT_length; /* options length */ + t_scalar_t OPT_offset; /* options offset */ +}; + +/* extended connect indication to return dst addr/port as well as src */ +struct T_extconn_ind { + t_scalar_t PRIM_type; /* always T_EXTCONN_IND */ + t_scalar_t SRC_length; /* src addr length */ + t_scalar_t SRC_offset; /* src addr offset */ + t_scalar_t OPT_length; /* option length */ + t_scalar_t OPT_offset; /* option offset */ + t_scalar_t SEQ_number; /* sequnce number */ + t_scalar_t DEST_length; /* dest addr length */ + t_scalar_t DEST_offset; /* dest addr offset */ +}; +#endif /* _KERNEL */ + +/* + * The following is a union of the primitives + */ +union T_primitives { + t_scalar_t type; /* primitive type */ + struct T_conn_req conn_req; /* connect request */ + struct T_conn_res conn_res; /* connect response */ + struct T_discon_req discon_req; /* disconnect request */ + struct T_data_req data_req; /* data request */ + struct T_exdata_req exdata_req; /* expedited data req */ + struct T_info_req info_req; /* information req */ + struct T_bind_req bind_req; /* bind request */ + struct T_unbind_req unbind_req; /* unbind request */ + struct T_unitdata_req unitdata_req; /* unitdata requset */ + struct T_optmgmt_req optmgmt_req; /* manage opt req */ + struct T_ordrel_req ordrel_req; /* orderly rel req */ + struct T_addr_req addr_req; /* address request */ + struct T_conn_ind conn_ind; /* connect indication */ + struct T_conn_con conn_con; /* connect corfirm */ + struct T_discon_ind discon_ind; /* discon indication */ + struct T_data_ind data_ind; /* data indication */ + struct T_exdata_ind exdata_ind; /* expedited data ind */ + struct T_info_ack info_ack; /* info ack */ + struct T_bind_ack bind_ack; /* bind ack */ + struct T_error_ack error_ack; /* error ack */ + struct T_ok_ack ok_ack; /* ok ack */ + struct T_unitdata_ind unitdata_ind; /* unitdata ind */ + struct T_uderror_ind uderror_ind; /* unitdata error ind */ + struct T_optmgmt_ack optmgmt_ack; /* manage opt ack */ + struct T_ordrel_ind ordrel_ind; /* orderly rel ind */ + struct T_addr_ack addr_ack; /* address ack */ +#if _SUN_TPI_VERSION > 1 + struct T_capability_req capability_req; /* capability req */ + struct T_capability_ack capability_ack; /* capability ack */ +#endif /* _SUN_TPI_VERSION > 1 */ +#ifdef _KERNEL + struct T_optdata_req optdata_req; /* option data request */ + struct T_optdata_ind optdata_ind; /* option data ind */ + struct T_extconn_ind extconn_ind; /* above plus dst addr */ +#endif /* _KERNEL */ +}; + +/* + * TPI specification is not clear on how to pack options in option + * buffers. What follows is the Solaris TPI interpretation of it. + * + * struct T_opthdr data structure is used to pack options in T_OPTMGMT_{REQ,ACK} + * message primitives in buffer delimited by [OPT_offset, OPT_length] fields in + * struct T_optmgmt_req/T_optmgmt_ack data structures. + * + * It is also used to pack options in similar buffers for data structures in + * T_CONN_{REQ,IND,RES,CONN} primitives and T_UNITDATA_{REQ,IND} primitives + * Needs to be on t_uscalar_t (32-bit word) aligned boundary. + * + * Note: T_SVR4_OPTMGMT_REQ primitive can, but need not, use this data + * structure for packing options. The format of option buffer for + * T_SVR4_OPTMGMT_REQ primitive is undefined and is a private contract + * between transport provider and its users. + * + * |<--------------first option---------------->| |<--second option--... + * ______________________________________ _ _ _ ____________________________ + * | len | level | name | status | value.......| / / | len ... + * -------------------------------------- - - - ---------------------------- + * |32bit| 32bit |32bit | 32bit | ^ | 32bit... + * | + * | + * alignment characters + */ +struct T_opthdr { + t_uscalar_t len; /* total length of option (header+value) */ + t_uscalar_t level; /* protocol level */ + t_uscalar_t name; /* option name */ + t_uscalar_t status; /* status value */ + /* option value aligned on t_uscalar_t (32-bit) alignment boundary */ +}; + +/* + * ------------------------------------------------------------------------ + * Common experimental private TPI alignment related macros. Not for + * use outside Solaris bundled code and can change in any release. + * The alignment boundary _TPI_ALIGN_SIZE represents an implementation + * choice for aligning many data objects which are directly or indirectly + * associated with Solaris TPI implementation. + * ------------------------------------------------------------------------ + */ + +#define __TPI_ALIGN_SIZE (sizeof (t_scalar_t)) +#define __TPI_ALIGN(x) \ + (((uintptr_t)(x) + __TPI_ALIGN_SIZE - 1) & ~(__TPI_ALIGN_SIZE - 1)) +#define __TPI_SIZE_ISALIGNED(x) \ + (((uintptr_t)(x) & (__TPI_ALIGN_SIZE - 1)) == 0) + +/* + * TPI primitive in message must be aligned at _TPI_ALIGN_SIZE boundary + */ +#define __TPI_PRIM_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x) + +/* + * TPI option header "struct opthdr" objects must be aligned + * at __TPI_ALIGN_SIZE boundary. + */ +#define __TPI_OPT_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x) +#define _TPI_ALIGN_OPT(x) __TPI_ALIGN(x) + +/* + * TPI option header "struct T_opthdr" objects must be aligned + * at __TPI_ALIGN_SIZE boundary. + */ +#define __TPI_TOPT_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x) +#define _TPI_ALIGN_TOPT(x) __TPI_ALIGN(x) + +/* + * -------------------------------------------------------------------- + * Private experimental macros. Not for use outside Solaris bundled + * source code and can change in any release. + * Macros that operate on struct T_opthdr. These are roughly modelled + * after the corresponding Socket CMSG_*() and XTI T_OPT_*() macros, but + * are applied to TPI option buffers. + * -------------------------------------------------------------------- + * + * unsigned char * + * _TPI_TOPT_DATA(struct T_opthdr *tohp): + * Get start of data part after option header + */ +#define _TPI_TOPT_DATA(tohp) \ + ((unsigned char *)((char *)(tohp) + sizeof (struct T_opthdr))) + +/* + * t_uscalar_t + * _TPI_TOPT_DATALEN(tohp) + * Get length of contents of option data excluding header (and + * padding etc if any). + */ +#define _TPI_TOPT_DATALEN(tohp) ((tohp)->len - sizeof (struct T_opthdr)) + +/* + * struct T_opthdr * + * _TPI_TOPT_FIRSTHDR(char *pbuf, t_scalar_t buflen): + * Get pointer to the first option header in buffer 'pbuf' + * Return NULL if there is not enough room for the header + * + * struct T_opthdr * + * _TPI_TOPT_NEXTHDR(char *pbuf, t_scalar_t buflen, + * struct T_opthdr *popt): + * Skip to next option header + * + * Notes: _TPI_TOPT_NEXTHDR performs the roundup of the length. + * + * If _TPI_TOPT_{FIRST,NEXT}HDR returns a non-null value, the user of + * _TPI_TOPT_{FIRST,NEXT}HDR must still verify that the resulting pointer + * is valid, by making a call to _TPI_TOPT_VALID. The _TPI_TOPT_VALID + * macro does not assume that the last option buffer is padded. + */ +#define _TPI_TOPT_FIRSTHDR(pbuf, buflen) \ + ((((buflen) >= (unsigned int) sizeof (struct T_opthdr)) && \ + __TPI_TOPT_ISALIGNED(pbuf)) ? \ + (struct T_opthdr *)(pbuf) : (struct T_opthdr *)0) + +#define _TPI_TOPT_NEXTHDR(pbuf, buflen, popt) \ + (((char *)(popt) + _TPI_ALIGN_TOPT((popt)->len)) < \ + ((char *)(pbuf) + (buflen)) ? \ + (struct T_opthdr *)((char *)(popt) + _TPI_ALIGN_TOPT((popt)->len)) : \ + (struct T_opthdr *)0) + +/* + * bool_t + * _TPI_TOPT_VALID(struct T_opthdr *tohp, char *start, char *end) + * Validate the option header at tohp, for its alignment and length. + * 1. check that tohp is aligned at t_scalar_t boundary + * 2. check that start <= tohp < end + * 3. validate the length, should be >= sizeof(T_opthdr) and + * check that there is no pointer arithmetic overflow. + * (could be caused by a very large value for tohp->len) + */ + +#define _TPI_TOPT_VALID(tohp, start, end) \ + (__TPI_TOPT_ISALIGNED(tohp) && \ + ((uintptr_t)(tohp) >= (uintptr_t)(start)) && \ + ((uintptr_t)(tohp) < (uintptr_t)(end)) && \ + ((ssize_t)(tohp)->len >= sizeof (struct T_opthdr)) && \ + ((uintptr_t)(tohp) + (tohp)->len <= (uintptr_t)(end)) && \ + ((uintptr_t)(tohp) + (tohp)->len >= (uintptr_t)(tohp) + \ + sizeof (struct T_opthdr))) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIHDR_H */ diff --git a/illumos-x86_64/usr/include/sys/time.h b/illumos-x86_64/usr/include/sys/time.h new file mode 100644 index 00000000..c071a4a5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/time.h @@ -0,0 +1,511 @@ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright (c) 1982, 1986, 1993 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +/* + * Copyright (c) 2013, 2016 by Delphix. All rights reserved. + */ + +#ifndef _SYS_TIME_H +#define _SYS_TIME_H + +#include + +/* + * Structure returned by gettimeofday(2) system call, + * and used in other calls. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ + defined(__EXTENSIONS__) +#ifndef _ASM + +#if !defined(_TIME_T) || __cplusplus >= 199711L +#define _TIME_T +typedef long time_t; /* time of day in seconds */ +#endif /* _TIME_T */ + +#ifndef _SUSECONDS_T +#define _SUSECONDS_T +typedef long suseconds_t; /* signed # of microseconds */ +#endif /* _SUSECONDS_T */ + +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* and microseconds */ +}; + +#if defined(_SYSCALL32) + +#include + +#define TIMEVAL32_TO_TIMEVAL(tv, tv32) { \ + (tv)->tv_sec = (time_t)(tv32)->tv_sec; \ + (tv)->tv_usec = (tv32)->tv_usec; \ +} + +#define TIMEVAL_TO_TIMEVAL32(tv32, tv) { \ + (tv32)->tv_sec = (time32_t)(tv)->tv_sec; \ + (tv32)->tv_usec = (int32_t)(tv)->tv_usec; \ +} + +#define TIME32_MAX INT32_MAX +#define TIME32_MIN INT32_MIN + +#define TIMEVAL_OVERFLOW(tv) \ + ((tv)->tv_sec < TIME32_MIN || (tv)->tv_sec > TIME32_MAX) + +#endif /* _SYSCALL32 */ + +#endif /* _ASM */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#ifndef _ASM +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +#endif /* _ASM */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +/* + * Needed for longlong_t type. Placement of this due to + * including which relies on the presense of the itimerval + * structure. + */ +#ifndef _ASM +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + +#define DST_NONE 0 /* not on dst */ +#define DST_USA 1 /* USA style dst */ +#define DST_AUST 2 /* Australian style dst */ +#define DST_WET 3 /* Western European dst */ +#define DST_MET 4 /* Middle European dst */ +#define DST_EET 5 /* Eastern European dst */ +#define DST_CAN 6 /* Canada */ +#define DST_GB 7 /* Great Britain and Eire */ +#define DST_RUM 8 /* Rumania */ +#define DST_TUR 9 /* Turkey */ +#define DST_AUSTALT 10 /* Australian style with shift in 1986 */ + +/* + * Operations on timevals. + */ +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + /* CSTYLED */ \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + /* CSTYLED */ \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) + +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 + +#ifdef __lint +/* + * Make innocuous, lint-happy versions until do {} while (0) is acknowleged as + * lint-safe. If the compiler could know that we always make tv_usec < 1000000 + * we wouldn't need a special linted version. + */ +#define timeradd(tvp, uvp, vvp) \ + do \ + { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) \ + { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while ((vvp)->tv_usec >= 1000000) +#define timersub(tvp, uvp, vvp) \ + do \ + { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) \ + { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while ((vvp)->tv_usec >= 1000000) +#else +#define timeradd(tvp, uvp, vvp) \ + do \ + { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) \ + { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while (0) + +#define timersub(tvp, uvp, vvp) \ + do \ + { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) \ + { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while (0) +#endif /* __lint */ + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * Names of the interval timers, and structure + * defining a timer setting. + */ +#define ITIMER_REAL 0 /* Decrements in real time */ +#define ITIMER_VIRTUAL 1 /* Decrements in process virtual time */ +#define ITIMER_PROF 2 /* Decrements both in process virtual */ + /* time and when system is running on */ + /* behalf of the process. */ +#define ITIMER_REALPROF 3 /* Decrements in real time for real- */ + /* time profiling of multithreaded */ + /* programs. */ + +#ifndef _ASM +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +#if defined(_SYSCALL32) + +struct itimerval32 { + struct timeval32 it_interval; + struct timeval32 it_value; +}; + +#define ITIMERVAL32_TO_ITIMERVAL(itv, itv32) { \ + TIMEVAL32_TO_TIMEVAL(&(itv)->it_interval, &(itv32)->it_interval); \ + TIMEVAL32_TO_TIMEVAL(&(itv)->it_value, &(itv32)->it_value); \ +} + +#define ITIMERVAL_TO_ITIMERVAL32(itv32, itv) { \ + TIMEVAL_TO_TIMEVAL32(&(itv32)->it_interval, &(itv)->it_interval); \ + TIMEVAL_TO_TIMEVAL32(&(itv32)->it_value, &(itv)->it_value); \ +} + +#define ITIMERVAL_OVERFLOW(itv) \ + (TIMEVAL_OVERFLOW(&(itv)->it_interval) || \ + TIMEVAL_OVERFLOW(&(itv)->it_value)) + +#endif /* _SYSCALL32 */ +#endif /* _ASM */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */ + + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +/* + * Definitions for commonly used resolutions. + */ +#define SEC 1 +#define MILLISEC 1000 +#define MICROSEC 1000000 +#define NANOSEC 1000000000LL + +#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC)) +#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) + +#define USEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MICROSEC)) +#define NSEC2USEC(n) ((n) / (NANOSEC / MICROSEC)) + +#define NSEC2SEC(n) ((n) / (NANOSEC / SEC)) +#define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC)) + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#ifndef _ASM + +/* + * Time expressed as a 64-bit nanosecond counter. + */ +typedef longlong_t hrtime_t; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * Unsigned counterpart to hrtime_t + */ +typedef u_longlong_t uhrtime_t; + +#define HRTIME_MAX LLONG_MAX +#define UHRTIME_MAX ULLONG_MAX + +#include +#include + +extern int tick_per_msec; /* clock ticks per millisecond (may be zero) */ +extern int msec_per_tick; /* milliseconds per clock tick (may be zero) */ +extern int usec_per_tick; /* microseconds per clock tick */ +extern int nsec_per_tick; /* nanoseconds per clock tick */ + +/* + * Macros to convert from common units of time (sec, msec, usec, nsec, + * timeval, timestruc) to clock ticks and vice versa. + */ +#define TICK_TO_SEC(tick) ((tick) / hz) +#define SEC_TO_TICK(sec) ((sec) * hz) + +#define TICK_TO_MSEC(tick) \ + (msec_per_tick ? (tick) * msec_per_tick : (tick) / tick_per_msec) +#define MSEC_TO_TICK(msec) \ + (msec_per_tick ? (msec) / msec_per_tick : (msec) * tick_per_msec) +#define MSEC_TO_TICK_ROUNDUP(msec) \ + (msec_per_tick ? \ + ((msec) == 0 ? 0 : ((msec) - 1) / msec_per_tick + 1) : \ + (msec) * tick_per_msec) + +#define TICK_TO_USEC(tick) ((tick) * usec_per_tick) +#define USEC_TO_TICK(usec) ((usec) / usec_per_tick) +#define USEC_TO_TICK_ROUNDUP(usec) \ + ((usec) == 0 ? 0 : USEC_TO_TICK((usec) - 1) + 1) + +#define TICK_TO_NSEC(tick) ((hrtime_t)(tick) * nsec_per_tick) +#define NSEC_TO_TICK(nsec) ((nsec) / nsec_per_tick) +#define NSEC_TO_TICK_ROUNDUP(nsec) \ + ((nsec) == 0 ? 0 : NSEC_TO_TICK((nsec) - 1) + 1) + +#define TICK_TO_TIMEVAL(tick, tvp) { \ + clock_t __tmptck = (tick); \ + (tvp)->tv_sec = TICK_TO_SEC(__tmptck); \ + (tvp)->tv_usec = TICK_TO_USEC(__tmptck - SEC_TO_TICK((tvp)->tv_sec)); \ +} + +#define TICK_TO_TIMEVAL32(tick, tvp) { \ + clock_t __tmptck = (tick); \ + time_t __tmptm = TICK_TO_SEC(__tmptck); \ + (tvp)->tv_sec = (time32_t)__tmptm; \ + (tvp)->tv_usec = TICK_TO_USEC(__tmptck - SEC_TO_TICK(__tmptm)); \ +} + +#define TICK_TO_TIMESTRUC(tick, tsp) { \ + clock_t __tmptck = (tick); \ + (tsp)->tv_sec = TICK_TO_SEC(__tmptck); \ + (tsp)->tv_nsec = TICK_TO_NSEC(__tmptck - SEC_TO_TICK((tsp)->tv_sec)); \ +} + +#define TICK_TO_TIMESTRUC32(tick, tsp) { \ + clock_t __tmptck = (tick); \ + time_t __tmptm = TICK_TO_SEC(__tmptck); \ + (tsp)->tv_sec = (time32_t)__tmptm; \ + (tsp)->tv_nsec = TICK_TO_NSEC(__tmptck - SEC_TO_TICK(__tmptm)); \ +} + +#define TIMEVAL_TO_TICK(tvp) \ + (SEC_TO_TICK((tvp)->tv_sec) + USEC_TO_TICK((tvp)->tv_usec)) + +#define TIMESTRUC_TO_TICK(tsp) \ + (SEC_TO_TICK((tsp)->tv_sec) + NSEC_TO_TICK((tsp)->tv_nsec)) + +typedef struct todinfo { + int tod_sec; /* seconds 0-59 */ + int tod_min; /* minutes 0-59 */ + int tod_hour; /* hours 0-23 */ + int tod_dow; /* day of week 1-7 */ + int tod_day; /* day of month 1-31 */ + int tod_month; /* month 1-12 */ + int tod_year; /* year 70+ */ +} todinfo_t; + +extern int64_t timedelta; +extern int timechanged; +extern int tod_needsync; +extern kmutex_t tod_lock; +extern volatile timestruc_t hrestime; +extern hrtime_t hres_last_tick; +extern int64_t hrestime_adj; +extern uint_t adj_shift; + +extern timestruc_t tod_get(void); +extern void tod_set(timestruc_t); +extern void set_hrestime(timestruc_t *); +extern todinfo_t utc_to_tod(time_t); +extern time_t tod_to_utc(todinfo_t); +extern int hr_clock_lock(void); +extern void hr_clock_unlock(int); +extern hrtime_t gethrtime(void); +extern hrtime_t gethrtime_unscaled(void); +extern hrtime_t gethrtime_max(void); +extern hrtime_t gethrtime_waitfree(void); +extern void scalehrtime(hrtime_t *); +extern uint64_t unscalehrtime(hrtime_t); +extern void gethrestime(timespec_t *); +extern time_t gethrestime_sec(void); +extern void gethrestime_lasttick(timespec_t *); +extern void hrt2ts(hrtime_t, timestruc_t *); +extern hrtime_t ts2hrt(const timestruc_t *); +extern void hrt2tv(hrtime_t, struct timeval *); +extern hrtime_t tv2hrt(struct timeval *); +extern int itimerfix(struct timeval *, int); +extern int itimerdecr(struct itimerval *, int); +extern void timevaladd(struct timeval *, struct timeval *); +extern void timevalsub(struct timeval *, struct timeval *); +extern void timevalfix(struct timeval *); +extern void dtrace_hres_tick(void); + +extern clock_t ddi_get_lbolt(void); +extern int64_t ddi_get_lbolt64(void); + +#if defined(_SYSCALL32) +extern void hrt2ts32(hrtime_t, timestruc32_t *); +#endif + +#endif /* _KERNEL */ + +#if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +int adjtime(const struct timeval *, struct timeval *); +#endif /* !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) ... */ + +#if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || \ + defined(_ATFILE_SOURCE) || defined(__EXTENSIONS__) +int futimesat(int, const char *, const struct timeval *); +#endif /* defined(__ATFILE_SOURCE) */ + +#if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ + defined(__EXTENSIONS__) + +int getitimer(int, struct itimerval *); +int utimes(const char *, const struct timeval *); + +#if defined(_XPG4_2) +int setitimer(int, const struct itimerval *_RESTRICT_KYWD, + struct itimerval *_RESTRICT_KYWD); +#else +int setitimer(int, struct itimerval *_RESTRICT_KYWD, + struct itimerval *_RESTRICT_KYWD); +#endif /* defined(_XPG2_2) */ + +#endif /* !defined(_KERNEL) ... defined(_XPG4_2) */ + +#if !defined(_KERNEL) && !defined(_STRICT_SYMBOLS) +int futimes(int, const struct timeval *); +int lutimes(const char *, const struct timeval *); + +#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +} + +#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} + +#endif /* !defined(_KERNEL) && !defined(_STRICT_SYMBOLS) */ + +/* + * gettimeofday() and settimeofday() were included in SVr4 due to their + * common use in BSD based applications. They were to be included exactly + * as in BSD, with two parameters. However, AT&T/USL noted that the second + * parameter was unused and deleted it, thereby making a routine included + * for compatibility, incompatible. + * + * XSH4.2 (spec 1170) defines gettimeofday and settimeofday to have two + * parameters. + * + * This has caused general disagreement in the application community as to + * the syntax of these routines. Solaris defaults to the XSH4.2 definition. + * The flag _SVID_GETTOD may be used to force the SVID version. + */ +#if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + +#if defined(_SVID_GETTOD) +int settimeofday(struct timeval *); +#else +int settimeofday(struct timeval *, void *); +#endif +hrtime_t gethrtime(void); +hrtime_t gethrvtime(void); + +#endif /* !(defined _KERNEL) && !defined(__XOPEN_OR_POSIX) ... */ + +#if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ + defined(__EXTENSIONS__) + +#if defined(_SVID_GETTOD) +int gettimeofday(struct timeval *); +#else +int gettimeofday(struct timeval *_RESTRICT_KYWD, void *_RESTRICT_KYWD); +#endif + +#endif /* !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) ... */ + +/* + * The inclusion of is historical and was added for + * backward compatibility in delta 1.2 when a number of definitions + * were moved out of . More recently, the timespec and + * itimerspec structure definitions, along with the _CLOCK_*, CLOCK_*, + * _TIMER_*, and TIMER_* symbols were moved to , + * which is now included by . This change was due to POSIX + * 1003.1b-1993 and X/Open UNIX 98 requirements. For non-POSIX and + * non-X/Open applications, including this header will still make + * visible these definitions. + */ +#if !defined(_BOOT) && !defined(_KERNEL) && !defined(_FAKE_KERNEL) && \ + !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#include +#endif + +/* + * The inclusion of is needed for the FD_CLR, + * FD_ISSET, FD_SET, and FD_SETSIZE macros as well as the + * select() prototype defined in the XOpen specifications + * beginning with XSH4v2. Placement required after definition + * for itimerval. + */ +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) && \ + !defined(__XOPEN_OR_POSIX) || \ + defined(_XPG4_2) || defined(__EXTENSIONS__) +#include +#endif + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIME_H */ diff --git a/illumos-x86_64/usr/include/sys/time_impl.h b/illumos-x86_64/usr/include/sys/time_impl.h new file mode 100644 index 00000000..4fb2551c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/time_impl.h @@ -0,0 +1,140 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Implementation-private. This header should not be included + * directly by an application. The application should instead + * include which includes this header conditionally + * depending on which feature test macros are defined. By default, + * this header is included by . X/Open and POSIX + * standards requirements result in this header being included + * by only under a restricted set of conditions. + */ + +#ifndef _SYS_TIME_IMPL_H +#define _SYS_TIME_IMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +#if !defined(_TIME_T) || __cplusplus >= 199711L +#define _TIME_T +typedef long time_t; /* time of day in seconds */ +#endif /* _TIME_T */ + +/* + * Time expressed in seconds and nanoseconds + */ + +typedef struct timespec { /* definition per POSIX.4 */ + time_t tv_sec; /* seconds */ + long tv_nsec; /* and nanoseconds */ +} timespec_t; + +#if defined(_SYSCALL32) + +#include + +#define TIMESPEC32_TO_TIMESPEC(ts, ts32) { \ + (ts)->tv_sec = (time_t)(ts32)->tv_sec; \ + (ts)->tv_nsec = (ts32)->tv_nsec; \ +} + +#define TIMESPEC_TO_TIMESPEC32(ts32, ts) { \ + (ts32)->tv_sec = (time32_t)(ts)->tv_sec; \ + (ts32)->tv_nsec = (ts)->tv_nsec; \ +} + +#define TIMESPEC_OVERFLOW(ts) \ + ((ts)->tv_sec < TIME32_MIN || (ts)->tv_sec > TIME32_MAX) + +#endif /* _SYSCALL32 */ + +typedef struct timespec timestruc_t; /* definition per SVr4 */ + +/* + * The following has been left in for backward compatibility. Portable + * applications should not use the structure name timestruc. + */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#define timestruc timespec /* structure name per SVr4 */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* + * Timer specification + */ +typedef struct itimerspec { /* definition per POSIX.4 */ + struct timespec it_interval; /* timer period */ + struct timespec it_value; /* timer expiration */ +} itimerspec_t; + +#if defined(_SYSCALL32) + +#define ITIMERSPEC32_TO_ITIMERSPEC(it, it32) { \ + TIMESPEC32_TO_TIMESPEC(&(it)->it_interval, &(it32)->it_interval); \ + TIMESPEC32_TO_TIMESPEC(&(it)->it_value, &(it32)->it_value); \ +} + +#define ITIMERSPEC_TO_ITIMERSPEC32(it32, it) { \ + TIMESPEC_TO_TIMESPEC32(&(it32)->it_interval, &(it)->it_interval); \ + TIMESPEC_TO_TIMESPEC32(&(it32)->it_value, &(it)->it_value); \ +} + +#define ITIMERSPEC_OVERFLOW(it) \ + (TIMESPEC_OVERFLOW(&(it)->it_interval) && \ + TIMESPEC_OVERFLOW(&(it)->it_value)) + +#endif /* _SYSCALL32 */ + +#endif /* _ASM */ + +#define __CLOCK_REALTIME0 0 /* obsolete; same as CLOCK_REALTIME */ +#define CLOCK_VIRTUAL 1 /* thread's user-level CPU clock */ +#define CLOCK_THREAD_CPUTIME_ID 2 /* thread's user+system CPU clock */ +#define CLOCK_REALTIME 3 /* wall clock */ +#define CLOCK_MONOTONIC 4 /* high resolution monotonic clock */ +#define CLOCK_PROCESS_CPUTIME_ID 5 /* process's user+system CPU clock */ +#define CLOCK_HIGHRES CLOCK_MONOTONIC /* alternate name */ +#define CLOCK_PROF CLOCK_THREAD_CPUTIME_ID /* alternate name */ + +#ifdef _KERNEL +#define CLOCK_MAX 6 +#endif + +#define TIMER_RELTIME 0x0 /* set timer relative */ +#define TIMER_ABSTIME 0x1 /* set timer absolute */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIME_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/time_std_impl.h b/illumos-x86_64/usr/include/sys/time_std_impl.h new file mode 100644 index 00000000..fbac1043 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/time_std_impl.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Implementation-private header. An application should not include + * this header directly. The definitions contained here are standards + * namespace safe. The timespec_t and timestruc_t structures as defined + * in , contain member names that break X/Open and POSIX + * namespace when included by or . This + * header was created to provide namespace safe definitions that are + * made visible only in the X/Open and POSIX compilation environments. + */ + +#ifndef _SYS_TIME_STD_IMPL_H +#define _SYS_TIME_STD_IMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_TIME_T) || __cplusplus >= 199711L +#define _TIME_T +typedef long time_t; /* time of day in seconds */ +#endif /* _TIME_T */ + +typedef struct _timespec { + time_t __tv_sec; /* seconds */ + long __tv_nsec; /* and nanoseconds */ +} _timespec_t; + +typedef struct _timespec _timestruc_t; /* definition per SVr4 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIME_STD_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/timeb.h b/illumos-x86_64/usr/include/sys/timeb.h new file mode 100644 index 00000000..c16fa7f5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/timeb.h @@ -0,0 +1,69 @@ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TIMEB_H +#define _SYS_TIMEB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* The ftime(2) system call structure */ +struct timeb { + time_t time; /* seconds since the Epoch */ + unsigned short millitm; /* + milliseconds since the Epoch */ + short timezone; /* minutes west of CUT */ + short dstflag; /* DST == non-zero */ +}; + +extern int ftime(struct timeb *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIMEB_H */ diff --git a/illumos-x86_64/usr/include/sys/timer.h b/illumos-x86_64/usr/include/sys/timer.h new file mode 100644 index 00000000..db279604 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/timer.h @@ -0,0 +1,188 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_TIMER_H +#define _SYS_TIMER_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#define _TIMER_MAX 32 +/* + * Max timers per process. This is patchable via /etc/system and can be + * updated via kmdb. Sticking to positive powers of 2 is recommended. + * The default value is 4 * NCPU. Setting timer_max to a value below the + * default via /etc/system is ignored. + */ +extern int timer_max; + +#define _TIMER_ALLOC_INIT 8 /* initial size for p_itimer array */ + +/* + * Bit values for the it_lock field. + */ +#define ITLK_LOCKED 0x01 +#define ITLK_WANTED 0x02 +#define ITLK_REMOVE 0x04 + +/* + * Bit values for the it_flags field. + */ +#define IT_SIGNAL 0x01 +#define IT_PORT 0x02 /* use event port notification */ +#define IT_CALLBACK 0x04 /* custom callback function */ + +struct clock_backend; + +struct itimer; +typedef struct itimer itimer_t; + +struct itimer { + itimerspec_t it_itime; + hrtime_t it_hrtime; + ushort_t it_flags; + ushort_t it_lock; + void *it_arg; /* clock backend-specific data */ + struct proc *it_proc; + union { + struct { + sigqueue_t *__it_sigq; + klwp_t *__it_lwp; + } __proc; + void *__it_frontend; + } __data; /* timer frontend-specific data */ + kcondvar_t it_cv; + int it_blockers; + int it_pending; + int it_overrun; + struct clock_backend *it_backend; + void (*it_fire)(itimer_t *); + kmutex_t it_mutex; + union { + struct { + void *_it_portev; /* port_kevent_t pointer */ + void *_it_portsrc; /* port_source_t pointer */ + int _it_portfd; /* port file descriptor */ + } _it_ev_port; + struct { + void (*_it_cb_func)(itimer_t *); + uintptr_t _it_cb_data[2]; + } _it_ev_cb; + } _it_ev_data; +}; + +#define it_sigq __data.__proc.__it_sigq +#define it_lwp __data.__proc.__it_lwp +#define it_frontend __data.__it_frontend +#define it_portev _it_ev_data._it_ev_port._it_portev +#define it_portsrc _it_ev_data._it_ev_port._it_portsrc +#define it_portfd _it_ev_data._it_ev_port._it_portfd +#define it_cb_func _it_ev_data._it_ev_cb._it_cb_func +#define it_cb_data _it_ev_data._it_ev_cb._it_cb_data + +typedef struct clock_backend { + struct sigevent clk_default; + int (*clk_clock_settime)(timespec_t *); + int (*clk_clock_gettime)(timespec_t *); + int (*clk_clock_getres)(timespec_t *); + int (*clk_timer_create)(itimer_t *, void (*)(itimer_t *)); + int (*clk_timer_settime)(itimer_t *, int, const struct itimerspec *); + int (*clk_timer_gettime)(itimer_t *, struct itimerspec *); + int (*clk_timer_delete)(itimer_t *); + void (*clk_timer_lwpbind)(itimer_t *); +} clock_backend_t; + +extern void clock_add_backend(clockid_t clock, clock_backend_t *backend); +extern clock_backend_t *clock_get_backend(clockid_t clock); + +extern void timer_release(struct proc *, itimer_t *); +extern void timer_delete_grabbed(struct proc *, timer_t tid, itimer_t *it); +extern void timer_lwpbind(); +extern int timer_setup(clock_backend_t *, struct sigevent *, port_notify_t *, + itimer_t **, timer_t *); + +extern void timer_func(sigqueue_t *); +extern void timer_exit(void); +extern void timer_lwpexit(void); +extern clock_t hzto(struct timeval *); +extern clock_t timespectohz(timespec_t *, timespec_t); +extern int64_t timespectohz64(timespec_t *); +extern int itimerspecfix(timespec_t *); +extern void timespecadd(timespec_t *, timespec_t *); +extern void timespecsub(timespec_t *, timespec_t *); +extern void timespecfix(timespec_t *); +extern int xgetitimer(uint_t, struct itimerval *, int); +extern int xsetitimer(uint_t, struct itimerval *, int); +extern void delete_itimer_realprof(void); + +#define timerspecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) +#define timerspeccmp(tvp, uvp) (((tvp)->tv_sec - (uvp)->tv_sec) ? \ + ((tvp)->tv_sec - (uvp)->tv_sec):((tvp)->tv_nsec - (uvp)->tv_nsec)) +#define timerspecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) + +struct oldsigevent { + /* structure definition prior to notification attributes member */ + int _notify; + union { + int _signo; + void (*_notify_function)(union sigval); + } _un; + union sigval _value; +}; + +#if defined(_SYSCALL32) + +struct oldsigevent32 { + int32_t _notify; + union { + int32_t _signo; + caddr32_t _notify_function; + } _un; + union sigval32 _value; +}; + +#endif /* _SYSCALL32 */ +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIMER_H */ diff --git a/illumos-x86_64/usr/include/sys/timerfd.h b/illumos-x86_64/usr/include/sys/timerfd.h new file mode 100644 index 00000000..66cb50ac --- /dev/null +++ b/illumos-x86_64/usr/include/sys/timerfd.h @@ -0,0 +1,81 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2015 Joyent, Inc. All rights reserved. + */ + +/* + * Header file to support for the timerfd facility. + */ + +#ifndef _SYS_TIMERFD_H +#define _SYS_TIMERFD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * To assure binary compatibility with Linux, these values are fixed at their + * Linux equivalents, not their native ones. + */ +#define TFD_CLOEXEC 02000000 /* LX_O_CLOEXEC */ +#define TFD_NONBLOCK 04000 /* LX_O_NONBLOCK */ +#define TFD_TIMER_ABSTIME (1 << 0) +#define TFD_TIMER_CANCEL_ON_SET (1 << 1) + +/* + * These ioctl values are specific to the native implementation; applications + * shouldn't be using them directly, and they should therefore be safe to + * change without breaking apps. + */ +#define TIMERFDIOC (('t' << 24) | ('f' << 16) | ('d' << 8)) +#define TIMERFDIOC_CREATE (TIMERFDIOC | 1) /* create timer */ +#define TIMERFDIOC_SETTIME (TIMERFDIOC | 2) /* timerfd_settime() */ +#define TIMERFDIOC_GETTIME (TIMERFDIOC | 3) /* timerfd_gettime() */ + +typedef struct timerfd_settime { + uint64_t tfd_settime_flags; /* flags (e.g., TFD_TIMER_ABSTIME) */ + uint64_t tfd_settime_value; /* pointer to value */ + uint64_t tfd_settime_ovalue; /* pointer to old value, if any */ +} timerfd_settime_t; + +#ifndef _KERNEL + +extern int timerfd_create(int, int); +extern int timerfd_settime(int, int, + const struct itimerspec *, struct itimerspec *); +extern int timerfd_gettime(int, struct itimerspec *); + +#else + +#define TIMERFDMNRN_TIMERFD 0 +#define TIMERFDMNRN_CLONE 1 +#define TIMERFD_VALMAX (ULLONG_MAX - 1ULL) + +/* + * Fortunately, the values for the Linux clocks that are valid for timerfd + * (namely, CLOCK_REALTIME and CLOCK_MONOTONIC) don't overlap with our values + * the same. + */ +#define TIMERFD_MONOTONIC 1 /* Linux value for CLOCK_MONOTONIC */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIMERFD_H */ diff --git a/illumos-x86_64/usr/include/sys/times.h b/illumos-x86_64/usr/include/sys/times.h new file mode 100644 index 00000000..6fc3e99d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/times.h @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_TIMES_H +#define _SYS_TIMES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structure returned by times() + */ +struct tms { + clock_t tms_utime; /* user time */ + clock_t tms_stime; /* system time */ + clock_t tms_cutime; /* user time, children */ + clock_t tms_cstime; /* system time, children */ +}; + +#if defined(_SYSCALL32) + +/* + * Kernel's view of ILP32 data structure + */ +struct tms32 { + clock32_t tms_utime; /* user time */ + clock32_t tms_stime; /* system time */ + clock32_t tms_cutime; /* user time, children */ + clock32_t tms_cstime; /* system time, children */ +}; + +#endif /* _SYSCALL32 */ + +clock_t times(struct tms *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIMES_H */ diff --git a/illumos-x86_64/usr/include/sys/timex.h b/illumos-x86_64/usr/include/sys/timex.h new file mode 100644 index 00000000..fc7365ab --- /dev/null +++ b/illumos-x86_64/usr/include/sys/timex.h @@ -0,0 +1,276 @@ +/* + * Copyright (c) David L. Mills 1993, 1994 + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appears in all copies and that both the + * copyright notice and this permission notice appear in supporting + * documentation, and that the name University of Delaware not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. The University of Delaware + * makes no representations about the suitability this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1996-1997, 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TIMEX_H +#define _SYS_TIMEX_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +/* + * The following defines establish the engineering parameters of the + * phase-lock loop (PLL) model used in the kernel implementation. These + * parameters have been carefully chosen by analysis for good stability + * and wide dynamic range. + * + * The hz variable is defined in the kernel build environment. It + * establishes the timer interrupt frequency. + * + * SCALE_KG and SCALE_KF establish the damping of the PLL and are chosen + * for a slightly underdamped convergence characteristic. SCALE_KH + * establishes the damping of the FLL and is chosen by wisdom and black + * art. + * + * MAXTC establishes the maximum time constant of the PLL. With the + * SCALE_KG and SCALE_KF values given and a time constant range from + * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours, + * respectively. + */ +#define SCALE_KG (1<<6) /* phase factor (multiplier) */ +#define SCALE_KF (1<<16) /* PLL frequency factor (multiplier) */ +#define SCALE_KH (1<<2) /* FLL frequency factor (multiplier) */ +#define MAXTC (1<<6) /* maximum time constant */ + + +/* + * The following defines establish the scaling of the various variables + * used by the PLL. They are chosen to allow the greatest precision + * possible without overflow of a 32-bit word. + * + * SCALE_PHASE defines the scaling (multiplier) of the time_phase variable, + * which serves as a an extension to the low-order bits of the system + * clock variable time.tv_usec. + * + * SCALE_UPDATE defines the scaling (multiplier) of the time_offset variable, + * which represents the current time offset with respect to standard + * time. + * + * SCALE_USEC defines the scaling (multiplier) of the time_freq and + * time_tolerance variables, which represent the current frequency + * offset and maximum frequency tolerance. + * + * FINEUSEC is 1 us in SCALE_UPDATE units of the time_phase variable. + */ +#define SCALE_PHASE (1<<22) /* phase scale */ +#define SCALE_USEC (1<<16) +#define SCALE_UPDATE (SCALE_KG * MAXTC) /* */ +#define FINEUSEC (1<<22) /* 1 us in phase units */ + +/* + * The following defines establish the performance envelope of the PLL. + * They insure it operates within predefined limits, in order to satisfy + * correctness assertions. An excursion which exceeds these bounds is + * clamped to the bound and operation proceeds accordingly. In practice, + * this can occur only if something has failed or is operating out of + * tolerance, but otherwise the PLL continues to operate in a stable + * mode. + * + * MAXPHASE must be set greater than or equal to CLOCK.MAX (128 ms), as + * defined in the NTP specification. CLOCK.MAX establishes the maximum + * time offset allowed before the system time is reset, rather than + * incrementally adjusted. Here, the maximum offset is clamped to + * MAXPHASE only in order to prevent overflow errors due to defective + * protocol implementations. + * + * MAXFREQ is the maximum frequency tolerance of the CPU clock + * oscillator plus the maximum slew rate allowed by the protocol. It + * should be set to at least the frequency tolerance of the oscillator + * plus 100 ppm for vernier frequency adjustments. The oscillator time and + * frequency are disciplined to an external source, presumably with + * negligible time and frequency error relative to UTC, and MAXFREQ can + * be reduced. + * + * MAXTIME is the maximum jitter tolerance of the PPS signal. + * + * MINSEC and MAXSEC define the lower and upper bounds on the interval + * between protocol updates. + */ +#define MAXPHASE 512000 /* max phase error (us) */ +#define MAXFREQ (512 * SCALE_USEC) /* max freq error (100 ppm) */ +#define MAXTIME (200 << PPS_AVG) /* max PPS error (jitter) (200 us) */ +#define MINSEC 16 /* min interval between updates (s) */ +#define MAXSEC 1200 /* max interval between updates (s) */ + +/* + * The following defines are used only if a pulse-per-second (PPS) + * signal is available and connected via a modem control lead, such as + * produced by the optional ppsclock feature incorporated in the Sun + * asynch driver. They establish the design parameters of the frequency- + * lock loop used to discipline the CPU clock oscillator to the PPS + * signal. + * + * PPS_AVG is the averaging factor for the frequency loop, as well as + * the time and frequency dispersion. + * + * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum + * calibration intervals, respectively, in seconds as a power of two. + * + * PPS_VALID is the maximum interval before the PPS signal is considered + * invalid and protocol updates used directly instead. + * + * MAXGLITCH is the maximum interval before a time offset of more than + * MAXTIME is believed. + */ +#define PPS_AVG 2 /* pps averaging constant (shift) */ +#define PPS_SHIFT 2 /* min interval duration (s) (shift) */ +#define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */ +#define PPS_VALID 120 /* pps signal watchdog max (s) */ +#define MAXGLITCH 30 /* pps signal glitch max (s) */ + +/* + * The following defines and structures define the user interface for + * the ntp_gettime() and ntp_adjtime() system calls. + * + * Control mode codes (timex.modes) + */ +#define MOD_OFFSET 0x0001 /* set time offset */ +#define MOD_FREQUENCY 0x0002 /* set frequency offset */ +#define MOD_MAXERROR 0x0004 /* set maximum time error */ +#define MOD_ESTERROR 0x0008 /* set estimated time error */ +#define MOD_STATUS 0x0010 /* set clock status bits */ +#define MOD_TIMECONST 0x0020 /* set pll time constant */ +#define MOD_CLKB 0x4000 /* set clock B */ +#define MOD_CLKA 0x8000 /* set clock A */ + +/* + * Status codes (timex.status) + */ +#define STA_PLL 0x0001 /* enable PLL updates (rw) */ +#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ +#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ +#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */ + +#define STA_INS 0x0010 /* insert leap (rw) */ +#define STA_DEL 0x0020 /* delete leap (rw) */ +#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ +#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ + +#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ +#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ +#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ +#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ + +#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ + +#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ + STA_PPSERROR | STA_CLOCKERR) /* read-only bits */ + +/* + * Clock states (time_state) + */ +#define TIME_OK 0 /* no leap second warning */ +#define TIME_INS 1 /* insert leap second warning */ +#define TIME_DEL 2 /* delete leap second warning */ +#define TIME_OOP 3 /* leap second in progress */ +#define TIME_WAIT 4 /* leap second has occured */ +#define TIME_ERROR 5 /* clock not synchronized */ + +/* + * NTP user interface (ntp_gettime()) - used to read kernel clock values + * + * Note: maximum error = NTP synch distance = dispersion + delay / 2; + * estimated error = NTP dispersion. + */ +struct ntptimeval { + struct timeval time; /* current time (ro) */ + int32_t maxerror; /* maximum error (us) (ro) */ + int32_t esterror; /* estimated error (us) (ro) */ +}; + +#if defined(_SYSCALL32) + +/* Kernel's view of _ILP32 application's ntptimeval struct */ + +struct ntptimeval32 { + struct timeval32 time; + int32_t maxerror; + int32_t esterror; +}; + +#endif /* _SYSCALL32 */ + +/* + * NTP daemon interface - (ntp_adjtime()) used to discipline CPU clock + * oscillator + */ +struct timex { + uint32_t modes; /* clock mode bits (wo) */ + int32_t offset; /* time offset (us) (rw) */ + int32_t freq; /* frequency offset (scaled ppm) (rw) */ + int32_t maxerror; /* maximum error (us) (rw) */ + int32_t esterror; /* estimated error (us) (rw) */ + int32_t status; /* clock status bits (rw) */ + int32_t constant; /* pll time constant (rw) */ + int32_t precision; /* clock precision (us) (ro) */ + int32_t tolerance; /* clock freq tolerance (scaled ppm) (ro) */ + int32_t ppsfreq; /* pps frequency (scaled ppm) (ro) */ + int32_t jitter; /* pps jitter (us) (ro) */ + int32_t shift; /* interval duration (s) (shift) (ro) */ + int32_t stabil; /* pps stability (scaled ppm) (ro) */ + int32_t jitcnt; /* jitter limit exceeded (ro) */ + int32_t calcnt; /* calibration intervals (ro) */ + int32_t errcnt; /* calibration errors (ro) */ + int32_t stbcnt; /* stability limit exceeded (ro) */ +}; + +/* + * NTP syscalls + */ +int ntp_gettime(struct ntptimeval *); +int ntp_adjtime(struct timex *); + +#ifdef _KERNEL + +extern int32_t time_state; /* clock state */ +extern int32_t time_status; /* clock status bits */ +extern int32_t time_offset; /* time adjustment (us) */ +extern int32_t time_freq; /* frequency offset (scaled ppm) */ +extern int32_t time_maxerror; /* maximum error (us) */ +extern int32_t time_esterror; /* estimated error (us) */ +extern int32_t time_constant; /* pll time constant */ +extern int32_t time_precision; /* clock precision (us) */ +extern int32_t time_tolerance; /* frequency tolerance (scaled ppm) */ +extern int32_t pps_shift; /* interval duration (s) (shift) */ +extern int32_t pps_freq; /* pps frequency offset (scaled ppm) */ +extern int32_t pps_jitter; /* pps jitter (us) */ +extern int32_t pps_stabil; /* pps stability (scaled ppm) */ +extern int32_t pps_jitcnt; /* jitter limit exceeded */ +extern int32_t pps_calcnt; /* calibration intervals */ +extern int32_t pps_errcnt; /* calibration errors */ +extern int32_t pps_stbcnt; /* stability limit exceeded */ + +extern void clock_update(int); +extern void ddi_hardpps(struct timeval *, int); + +#endif /* _KERNEL */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIMEX_H */ diff --git a/illumos-x86_64/usr/include/sys/timod.h b/illumos-x86_64/usr/include/sys/timod.h new file mode 100644 index 00000000..4c9d5aad --- /dev/null +++ b/illumos-x86_64/usr/include/sys/timod.h @@ -0,0 +1,121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_TIMOD_H +#define _SYS_TIMOD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Timod ioctls */ +#define TIMOD ('T'<<8) +#define TI_GETINFO (TIMOD|140) +#define TI_OPTMGMT (TIMOD|141) +#define TI_BIND (TIMOD|142) +#define TI_UNBIND (TIMOD|143) +#define TI_GETMYNAME (TIMOD|144) +#define TI_GETPEERNAME (TIMOD|145) +#define TI_SETMYNAME (TIMOD|146) +#define TI_SETPEERNAME (TIMOD|147) +#define TI_SYNC (TIMOD|148) +#define TI_GETADDRS (TIMOD|149) +#define TI_CAPABILITY (TIMOD|150) + +/* + * There are two ioctls to get information from the kernel. One is TI_SYNC + * and it should be only used to exchange information between the library and + * timod. It should not request any TPI information. The second ioctl is + * TI_CAPABILITY which is extensible ioctl for getting all the information from + * transport provider. + */ + +/* sent with TI_SYNC */ +struct ti_sync_req { + uint32_t tsr_flags; + /* can grow at the end */ +}; + +/* + * For use with tsr_flags + * TSRF_INFO_REQ is obsolete and shouldn't be used in new code. Use + * TI_CAPABILITY ioctl instead. + */ +#define TSRF_INFO_REQ 0x1 /* get info about transport endpoint */ +#define TSRF_IS_EXP_IN_RCVBUF 0x2 /* look for exp ind in rcvbuf */ +#define TSRF_QLEN_REQ 0x4 /* get qlen from timod */ + +/* returned by TI_SYNC */ +struct ti_sync_ack { + /* + * - initial part derived from and matches T_info_ack + * - returned when TSRF_INFO_REQ is set on request + */ + t_scalar_t PRIM_type; + t_scalar_t TSDU_size; + t_scalar_t ETSDU_size; + t_scalar_t CDATA_size; + t_scalar_t DDATA_size; + t_scalar_t ADDR_size; + t_scalar_t OPT_size; + t_scalar_t TIDU_size; + t_scalar_t SERV_type; + t_scalar_t CURRENT_state; + t_scalar_t PROVIDER_flag; + + /* + * endpoint qlen backlog, returned when TSRF_INFO_REQ is set on request + */ + t_uscalar_t tsa_qlen; + + /* + * misc flags info - bits set based on what is requested. + */ + uint32_t tsa_flags; + /* can grow at the end */ +}; + +/* + * Flag bits for use with tsa_flags + */ + +/* + * TSAF_EXP_QUEUED: + * set/clear significant when TSRF_IS_EXP_IN_RCVBUF is set on request + */ +#define TSAF_EXP_QUEUED 0x1 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIMOD_H */ diff --git a/illumos-x86_64/usr/include/sys/tirdwr.h b/illumos-x86_64/usr/include/sys/tirdwr.h new file mode 100644 index 00000000..e2b0848f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tirdwr.h @@ -0,0 +1,37 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_TIRDWR_H +#define _SYS_TIRDWR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIRDWR_H */ diff --git a/illumos-x86_64/usr/include/sys/tiuser.h b/illumos-x86_64/usr/include/sys/tiuser.h new file mode 100644 index 00000000..5bb9cfb6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tiuser.h @@ -0,0 +1,237 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + * + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2014 Gary Mills + */ + +#ifndef _SYS_TIUSER_H +#define _SYS_TIUSER_H + +#include +/* + * The following include file has declarations needed by both the kernel + * level transport providers and the user level library. + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * The following are the events returned by t_look + */ +#define T_LISTEN 0x0001 /* connection indication received */ +#define T_CONNECT 0x0002 /* connect confirmation received */ +#define T_DATA 0x0004 /* normal data received */ +#define T_EXDATA 0x0008 /* expedited data received */ +#define T_DISCONNECT 0x0010 /* disconnect received */ +#define T_UDERR 0x0040 /* data gram error indication */ +#define T_ORDREL 0x0080 /* orderly release indication */ +#define T_EVENTS 0x00ff /* event mask */ + +/* + * Flags for data primitives. + */ +#define T_MORE 0x001 /* more data */ +#define T_EXPEDITED 0x002 /* expedited data */ + + +/* + * protocol specific service limits + */ + +struct t_info { + t_scalar_t addr; /* size of protocol address */ + t_scalar_t options; /* size of protocol options */ + t_scalar_t tsdu; /* size of max transport service data unit */ + t_scalar_t etsdu; /* size of max expedited tsdu */ + t_scalar_t connect; /* max data for connection primitives */ + t_scalar_t discon; /* max data for disconnect primitives */ + t_scalar_t servtype; /* provider service type */ +}; + +/* + * netbuf structure + */ + +struct netbuf { + unsigned int maxlen; + unsigned int len; + char *buf; +}; + +#ifdef _SYSCALL32 +struct netbuf32 { + uint32_t maxlen; + uint32_t len; + caddr32_t buf; +}; +#endif /* _SYSCALL32 */ + +/* + * t_bind - format of the address and options arguments of bind + */ + +struct t_bind { + struct netbuf addr; + unsigned int qlen; +}; + +/* + * options management + */ +struct t_optmgmt { + struct netbuf opt; + t_scalar_t flags; +}; + +/* + * disconnect structure + */ +struct t_discon { + struct netbuf udata; /* user data */ + int reason; /* reason code */ + int sequence; /* sequence number */ +}; + +/* + * call structure + */ +struct t_call { + struct netbuf addr; /* address */ + struct netbuf opt; /* options */ + struct netbuf udata; /* user data */ + int sequence; /* sequence number */ +}; + +/* + * data gram structure + */ +struct t_unitdata { + struct netbuf addr; /* address */ + struct netbuf opt; /* options */ + struct netbuf udata; /* user data */ +}; + +/* + * unitdata error + */ +struct t_uderr { + struct netbuf addr; /* address */ + struct netbuf opt; /* options */ + t_scalar_t error; /* error code */ +}; + +/* + * The following are structure types used when dynamically + * allocating the above structures via t_structalloc(). + */ +#define T_BIND 1 /* struct t_bind */ +#define T_OPTMGMT 2 /* struct t_optmgmt */ +#define T_CALL 3 /* struct t_call */ +#define T_DIS 4 /* struct t_discon */ +#define T_UNITDATA 5 /* struct t_unitdata */ +#define T_UDERROR 6 /* struct t_uderr */ +#define T_INFO 7 /* struct t_info */ + +/* + * The following bits specify which fields of the above + * structures should be allocated by t_structalloc(). + */ +#define T_ADDR 0x01 /* address */ +#define T_OPT 0x02 /* options */ +#define T_UDATA 0x04 /* user data */ +#define T_ALL 0x07 /* all the above */ + +/* + * the following are the states for the user + */ + +#define T_UNINIT 0 /* uninitialized */ +#define T_UNBND 1 /* unbound */ +#define T_IDLE 2 /* idle */ +#define T_OUTCON 3 /* outgoing connection pending */ +#define T_INCON 4 /* incoming connection pending */ +#define T_DATAXFER 5 /* data transfer */ +#define T_OUTREL 6 /* outgoing release pending */ +#define T_INREL 7 /* incoming release pending */ +#define T_BADSTATE 8 /* illegal state */ + +/* + * Flags for t_getname. + */ +#define LOCALNAME 0 +#define REMOTENAME 1 + +extern int t_accept(int fildes, int resfd, struct t_call *call); +extern char *t_alloc(int fildes, int struct_type, int fields); +extern int t_bind(int fildes, struct t_bind *req, struct t_bind *ret); +extern int t_close(int fildes); +extern int t_connect(int fildes, struct t_call *sndcall, + struct t_call *rcvcall); +extern void t_error(const char *errmsg); +extern int t_free(char *ptr, int struct_type); +extern int t_getinfo(int fildes, struct t_info *info); +extern int t_getname(int fildes, struct netbuf *name, int type); +extern int t_getstate(int fildes); +extern int t_listen(int fildes, struct t_call *call); +extern int t_look(int fildes); +extern int t_open(const char *path, int oflag, struct t_info *info); +extern int t_optmgmt(int fildes, struct t_optmgmt *req, + struct t_optmgmt *ret); +extern int t_rcv(int fildes, char *buf, unsigned nbytes, int *flags); +extern int t_rcvconnect(int fildes, struct t_call *call); +extern int t_rcvdis(int fildes, struct t_discon *discon); +extern int t_rcvrel(int fildes); +extern int t_rcvudata(int fildes, struct t_unitdata *unitdata, int *flags); +extern int t_rcvuderr(int fildes, struct t_uderr *uderr); +extern int t_snd(int fildes, char *buf, unsigned nbytes, int flags); +extern int t_snddis(int fildes, struct t_call *call); +extern int t_sndrel(int fildes); +extern int t_sndudata(int fildes, struct t_unitdata *unitdata); +extern char *t_strerror(int errnum); +extern int t_sync(int fildes); +extern int t_unbind(int fildes); + +/* + * N.B.: this interface is deprecated. Use t_strerror() instead. + */ +extern char *t_errlist[]; +extern int t_nerr; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIUSER_H */ diff --git a/illumos-x86_64/usr/include/sys/tl.h b/illumos-x86_64/usr/include/sys/tl.h new file mode 100644 index 00000000..f3330d9c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tl.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TL_H +#define _SYS_TL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These are Sun private declarations. Not to be used by any + * external applications/code. + */ + +/* + * Protocol level for option header - (hex for ascii "TL") + * (Hopefully unique!) + */ +#define TL_PROT_LEVEL 0x544c + +/* + * Option and data structures used for sending credentials + */ +#define TL_OPT_PEER_CRED 10 +typedef struct tl_credopt { + uid_t tc_uid; /* Effective user id */ + gid_t tc_gid; /* Effective group id */ + uid_t tc_ruid; /* Real user id */ + gid_t tc_rgid; /* Real group id */ + uid_t tc_suid; /* Saved user id (from exec) */ + gid_t tc_sgid; /* Saved group id (from exec) */ + uint_t tc_ngroups; /* number of supplementary groups */ +} tl_credopt_t; + +#define TL_OPT_PEER_UCRED 11 /* data structure is ucred */ + +/* + * Ioctl's for the 'tl' driver + */ +#define TL_IOC (('T' << 16)|('L' << 8)) +#define TL_IOC_CREDOPT (TL_IOC|001) +/* unused (TL_IOC|002) */ +#define TL_IOC_UCREDOPT (TL_IOC|003) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TL_H */ diff --git a/illumos-x86_64/usr/include/sys/todio.h b/illumos-x86_64/usr/include/sys/todio.h new file mode 100644 index 00000000..ae354cb4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/todio.h @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995 - 1996, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_TODIO_H +#define _SYS_TODIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define TOD_IOC ('t' << 8) +#define TOD_GET_DATE (TOD_IOC | 0) +#define TOD_SET_ALARM (TOD_IOC | 1) +#define TOD_CLEAR_ALARM (TOD_IOC | 2) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TODIO_H */ diff --git a/illumos-x86_64/usr/include/sys/tpicommon.h b/illumos-x86_64/usr/include/sys/tpicommon.h new file mode 100644 index 00000000..8fe05783 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tpicommon.h @@ -0,0 +1,197 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TPICOMMON_H +#define _SYS_TPICOMMON_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * WARNING: This header should not ever be included directly by application + * programs. It exists so that common definitions can be included by other + * system header files which define a documented interface. The interfaces + * that share and expose the definitions in this file are: + * + * (1) TLI interface (which includes which + * includes this file) + * (2) XTI interface + * (3) Kernel Streams TPI message based inteface + */ + + +/* + * The following are "t_errno" error codes needed by both the kernel + * level transport providers and the user level interfaces. + */ + +#define TBADADDR 1 /* Incorrect address format */ +#define TBADOPT 2 /* Incorrect options format */ +#define TACCES 3 /* Illegal permissions */ +#define TBADF 4 /* Illegal file descriptor */ +#define TNOADDR 5 /* Couldn't allocate address */ +#define TOUTSTATE 6 /* Routine will place interface out of state */ +#define TBADSEQ 7 /* Illegal called/calling sequence number */ +#define TSYSERR 8 /* System error */ +#define TLOOK 9 /* An event requires attention */ +#define TBADDATA 10 /* Illegal amount of data */ +#define TBUFOVFLW 11 /* Buffer not large enough */ +#define TFLOW 12 /* Can't send message - (blocked) */ +#define TNODATA 13 /* No message currently available */ +#define TNODIS 14 /* Disconnect message not found */ +#define TNOUDERR 15 /* Unitdata error message not found */ +#define TBADFLAG 16 /* Incorrect flags specified */ +#define TNOREL 17 /* Orderly release message not found */ +#define TNOTSUPPORT 18 /* Primitive not supported by provider */ +#define TSTATECHNG 19 /* State is in process of changing */ +/* + * Following new error codes added to namespace with introduction of XTI + */ +#define TNOSTRUCTYPE 20 /* Unsupported structure type requested */ +#define TBADNAME 21 /* Invalid transport provider name */ +#define TBADQLEN 22 /* Listener queue length limit is zero */ +#define TADDRBUSY 23 /* Transport address is in use */ +#define TINDOUT 24 /* Outstanding connection indications */ +#define TPROVMISMATCH 25 + /* Listener-acceptor transport provider mismatch */ + +#define TRESQLEN 26 +/* Connection acceptor has listen queue length limit greater than zero */ + +#define TRESADDR 27 +/* Connection acceptor-listener addresses not same but required by transport */ + +#define TQFULL 28 /* Incoming connection queue is full */ +#define TPROTO 29 /* Protocol error on transport primitive */ + +/* + * Service type defines - used with T_info_ack + */ +#define T_COTS 1 /* connection oriented transport service */ +#define T_COTS_ORD 2 /* connection oriented w/ orderly release */ +#define T_CLTS 3 /* connectionless transport service */ +/* + * NOT FOR PUBLIC USE, Solaris internal only. + * This value of nc_semantics is strictly for use of Remote Direct + * Memory Access provider interfaces in Solaris only and not for + * general use. Do not use this value for general purpose user or + * kernel programming. If used the behavior is undefined. + * This is a PRIVATE interface to be used by Solaris kRPC only. + */ +#define T_RDMA 4 /* rdma transport service */ + + +/* + * The following are the flag definitions needed by the + * user level library routines. + */ + +/* + * flags for option management request primitives + * Note: + * - This namespace is distinct from the namespace for data + * primitives. + * - Flags T_NEGOTIATE, T_CHECK, T_DEFAULT, T_CURRENT + * are associated with an option request + * - Flags T_SUCCESS, T_FAILURE, T_PARTSUCCESS, T_READONLY, + * T_NOTSUPPORT are associated with results of option request. + */ +#define T_NEGOTIATE 0x004 /* set opts request */ +#define T_CHECK 0x008 /* check opts request */ +#define T_DEFAULT 0x010 /* get default opts request */ +#define T_SUCCESS 0x020 /* successful result */ +#define T_FAILURE 0x040 /* failure result */ +#define T_CURRENT 0x080 /* get current options request */ +#define T_PARTSUCCESS 0x100 /* partial success result */ +#define T_READONLY 0x200 /* read-only result */ +#define T_NOTSUPPORT 0x400 /* not supported result */ + + +/* + * General purpose defines - used in multiple options context. + * They (T_YES and T_NO) need to be bitwise distinct from T_GARBAGE + * used with TCP level options by XTI for historical XTI specification + * reasons. + * (T_GARBAGE declared in included by ). + */ +#define T_YES 1 +#define T_NO 0 + +/* + * Values used with struct T_info_ack fields + */ +#define T_INFINITE -1 +#define T_INVALID -2 + +/* + * Constants used with option management "name" or "value" fields. + */ + +/* + * XTI defined value reserved for stating 'unspecified' value used + * in some option namespaces. + */ +#define T_UNSPEC (~0-2) /* applicable to ulong_t, long, char */ + +/* + * XTI inspired option management defined an option name T_ALLOPT + * to imply all options of a certain level. + * No option name (for any level) should be defined with constant value of + * T_ALLOPT (0). + */ +#define T_ALLOPT 0 /* all options at any level */ + +/* + * An option specification consists of an opthdr, followed by the value of + * the option. An options buffer contains one or more options. The len + * field of opthdr specifies the length of the option value in bytes. This + * length must be a multiple of sizeof (t_scalar_t) (use OPTLEN macro). + * This is an antique definition which is used (unofficially) by TLI but + * superceded in XTI. + */ +/* + * The opthdr types are now t_uscalar_t - inspired by XTI + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +struct opthdr { + t_uscalar_t level; /* protocol level affected */ + t_uscalar_t name; /* option to modify */ + t_uscalar_t len; /* length of option value */ +}; + +#define OPTLEN(x) ((((x) + sizeof (t_uscalar_t) - 1) / \ + sizeof (t_uscalar_t)) * sizeof (t_uscalar_t)) +#define OPTVAL(opt) ((char *)(opt + 1)) +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TPICOMMON_H */ diff --git a/illumos-x86_64/usr/include/sys/trap.h b/illumos-x86_64/usr/include/sys/trap.h new file mode 100644 index 00000000..3bc5f323 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/trap.h @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _SYS_TRAP_H +#define _SYS_TRAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Trap type values + */ + +#define T_ZERODIV 0x0 /* #de divide by 0 error */ +#define T_SGLSTP 0x1 /* #db single step */ +#define T_NMIFLT 0x2 /* NMI */ +#define T_BPTFLT 0x3 /* #bp breakpoint fault, INT3 insn */ +#define T_OVFLW 0x4 /* #of INTO overflow fault */ +#define T_BOUNDFLT 0x5 /* #br BOUND insn fault */ +#define T_ILLINST 0x6 /* #ud invalid opcode fault */ +#define T_NOEXTFLT 0x7 /* #nm device not available: x87 */ +#define T_DBLFLT 0x8 /* #df double fault */ +#define T_EXTOVRFLT 0x9 /* [not generated: 386 only] */ +#define T_TSSFLT 0xa /* #ts invalid TSS fault */ +#define T_SEGFLT 0xb /* #np segment not present fault */ +#define T_STKFLT 0xc /* #ss stack fault */ +#define T_GPFLT 0xd /* #gp general protection fault */ +#define T_PGFLT 0xe /* #pf page fault */ +#define T_RESVTRAP 0xf /* reserved */ +#define T_EXTERRFLT 0x10 /* #mf x87 FPU error fault */ +#define T_ALIGNMENT 0x11 /* #ac alignment check error */ +#define T_MCE 0x12 /* #mc machine check exception */ +#define T_SIMDFPE 0x13 /* #xm SSE/SSE exception */ +#define T_DBGENTR 0x14 /* debugger entry */ +#define T_INVALTRAP 0x1e /* invalid */ +#define T_ENDPERR 0x21 /* emulated extension error flt */ +#define T_ENOEXTFLT 0x20 /* emulated ext not present */ +#define T_FASTTRAP 0xd2 /* fast system call */ +#define T_SYSCALLINT 0x91 /* general system call */ +#define T_DTRACE_RET 0x92 /* DTrace pid return */ +#define T_INT80 0x80 /* int80 handler for linux emulation */ +#define T_SOFTINT 0x50fd /* pseudo softint trap type */ + +/* + * Pseudo traps. + */ +#define T_INTERRUPT 0x100 +#define T_FAULT 0x200 +#define T_AST 0x400 +#define T_SYSCALL 0x180 + + +/* + * Values of error code on stack in case of page fault + */ + +#define PF_ERR_MASK 0x01 /* Mask for error bit */ +#define PF_ERR_PAGE 0x00 /* page not present */ +#define PF_ERR_PROT 0x01 /* protection error */ +#define PF_ERR_WRITE 0x02 /* fault caused by write (else read) */ +#define PF_ERR_USER 0x04 /* processor was in user mode */ + /* (else supervisor) */ +#define PF_ERR_EXEC 0x10 /* attempt to execute a No eXec page (AMD) */ + /* or kernel tried to execute a user page */ + /* (Intel SMEP) */ + +/* + * Definitions for fast system call subfunctions + */ +#define T_FNULL 0 /* Null trap for testing */ +#define T_FGETFP 1 /* Get emulated FP context */ +#define T_FSETFP 2 /* Set emulated FP context */ +#define T_GETHRTIME 3 /* Get high resolution time */ +#define T_GETHRVTIME 4 /* Get high resolution virtual time */ +#define T_GETHRESTIME 5 /* Get high resolution time */ +#define T_GETLGRP 6 /* Get home lgrpid */ + +#define T_LASTFAST 6 /* Last valid subfunction */ + +/* + * Offsets for an interrupt/trap frame. + */ +#define T_FRAME_ERR 0 +#define T_FRAME_RIP 8 +#define T_FRAME_CS 16 +#define T_FRAME_RFLAGS 24 +#define T_FRAME_RSP 32 +#define T_FRAME_SS 40 + +#define T_FRAMERET_RIP 0 +#define T_FRAMERET_CS 8 +#define T_FRAMERET_RFLAGS 16 +#define T_FRAMERET_RSP 24 +#define T_FRAMERET_SS 32 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TRAP_H */ diff --git a/illumos-x86_64/usr/include/sys/traptrace.h b/illumos-x86_64/usr/include/sys/traptrace.h new file mode 100644 index 00000000..b8e57949 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/traptrace.h @@ -0,0 +1,297 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_TRAPTRACE_H +#define _SYS_TRAPTRACE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Trap tracing. If TRAPTRACE is defined, an entry is recorded every time + * the CPU jumps through the Interrupt Descriptor Table (IDT). One exception + * is the Double Fault handler, which does not record a traptrace entry. + * + * There are facilities to (conditionally) interleave tracing of related + * facilities e.h. x-calls. + */ + +/* + * Note: non-assembler files that include this file must include + * before it, for the typedef of pc_t to be visible. + */ + +#define TTR_STACK_DEPTH 10 + +#ifndef _ASM + +#define TTR_PAD1_SIZE (sizeof (long) - 1) + +typedef struct { + uintptr_t ttc_next; + uintptr_t ttc_first; + uintptr_t ttc_limit; + uintptr_t ttc_current; +} trap_trace_ctl_t; + +typedef struct { + struct regs ttr_regs; + greg_t ttr_cr2; + union _ttr_info { + struct _idt_entry { + int cpuid; + short vector; + uchar_t ipl; + uchar_t spl; + uchar_t pri; + } idt_entry; + struct _gate_entry { + int sysnum; + } gate_entry; + } ttr_info; + uintptr_t ttr_curthread; + uchar_t ttr_pad[TTR_PAD1_SIZE]; + uchar_t ttr_marker; + hrtime_t ttr_stamp; + int ttr_sdepth; + pc_t ttr_stack[TTR_STACK_DEPTH]; +} trap_trace_rec_t; + +#define ttr_cpuid ttr_info.idt_entry.cpuid +#define ttr_vector ttr_info.idt_entry.vector +#define ttr_ipl ttr_info.idt_entry.ipl +#define ttr_spl ttr_info.idt_entry.spl +#define ttr_pri ttr_info.idt_entry.pri +#define ttr_sysnum ttr_info.gate_entry.sysnum + +#define TRAPTR_NENT 128 + +extern trap_trace_ctl_t trap_trace_ctl[NCPU]; /* Allocated in locore.s */ +extern size_t trap_trace_bufsize; +extern int trap_trace_freeze; +extern trap_trace_rec_t trap_trace_postmort; /* Entry used after death */ + +#define TRAPTRACE_FREEZE trap_trace_freeze = 1; +#define TRAPTRACE_UNFREEZE trap_trace_freeze = 0; + +#else /* _ASM */ + +/* + * ptr -- will be set to a TRAPTRACE entry. + * scr1 -- scratch + * scr1_32 -- 32-bit version of scr1 + * scr2 -- scratch + * marker -- register containing byte to store in marker field of entry + * + * Note that this macro defines labels "8" and "9". + */ +#ifdef TRAPTRACE + +#if defined(__amd64) + +#define TRACE_PTR(ptr, scr1, scr1_32, scr2, marker) \ + leaq trap_trace_postmort(%rip), ptr; \ + cmpl $0, trap_trace_freeze(%rip); \ + jne 9f; \ + LOADCPU(ptr); \ + movl CPU_ID(ptr), scr1_32; \ + shlq $TRAPTR_SIZE_SHIFT, scr1; \ + leaq trap_trace_ctl(%rip), scr2; \ + addq scr2, scr1; \ + movq TRAPTR_NEXT(scr1), ptr; \ + leaq TRAP_ENT_SIZE(ptr), scr2; \ + cmpq TRAPTR_LIMIT(scr1), scr2; \ + jl 8f; \ + movq TRAPTR_FIRST(scr1), scr2; \ +8: movq scr2, TRAPTR_NEXT(scr1); \ +9: movb marker, TTR_MARKER(ptr); + +#elif defined(__i386) + +#define TRACE_PTR(ptr, scr1, scr1_32, scr2, marker) \ + movl $trap_trace_postmort, ptr; \ + cmpl $0, trap_trace_freeze; \ + jne 9f; \ + LOADCPU(ptr); \ + movl CPU_ID(ptr), scr1_32; \ + shll $TRAPTR_SIZE_SHIFT, scr1; \ + addl $trap_trace_ctl, scr1; \ + movl TRAPTR_NEXT(scr1), ptr; \ + leal TRAP_ENT_SIZE(ptr), scr2; \ + cmpl TRAPTR_LIMIT(scr1), scr2; \ + jl 8f; \ + movl TRAPTR_FIRST(scr1), scr2; \ +8: movl scr2, TRAPTR_NEXT(scr1); \ +9: movb marker, TTR_MARKER(ptr); + +#endif /* __i386 */ + +/* + * ptr -- pointer to the current TRAPTRACE entry. + * reg -- pointer to the stored registers; must be on the stack + * scr1 -- scratch used as array index + * scr2 -- scratch used as temporary + * + * Note that this macro defines label "9". + * Also captures curthread on exit of loop. + */ +#if defined(__xpv) +#define __GETCR2(_mov, reg) \ + _mov %gs:CPU_VCPU_INFO, reg; \ + _mov VCPU_INFO_ARCH_CR2(reg), reg +#else +#define __GETCR2(_mov, reg) \ + _mov %cr2, reg +#endif + +#if defined(__amd64) + +#define TRACE_REGS(ptr, reg, scr1, scr2) \ + xorq scr1, scr1; \ + /*CSTYLED*/ \ +9: movq (reg, scr1, 1), scr2; \ + movq scr2, (ptr, scr1, 1); \ + addq $CLONGSIZE, scr1; \ + cmpq $REGSIZE, scr1; \ + jl 9b; \ + movq %gs:CPU_THREAD, scr2; \ + movq scr2, TTR_CURTHREAD(ptr); \ + __GETCR2(movq, scr2); \ + movq scr2, TTR_CR2(ptr) + +#elif defined(__i386) + +#define TRACE_REGS(ptr, reg, scr1, scr2) \ + xorl scr1, scr1; \ + /*CSTYLED*/ \ +9: movl (reg, scr1, 1), scr2; \ + movl scr2, (ptr, scr1, 1); \ + addl $CLONGSIZE, scr1; \ + cmpl $REGSIZE, scr1; \ + jl 9b; \ + movl %gs:CPU_THREAD, scr2; \ + movl scr2, TTR_CURTHREAD(ptr); \ + __GETCR2(movl, scr2); \ + movl scr2, TTR_CR2(ptr) + +#endif /* __i386 */ + +/* + * The time stamp macro records a high-resolution time stamp for the + * given TRAPTRACE entry. Note that %eax and %edx are plowed by this + * macro; if they are to be preserved, it's up to the caller of the macro. + */ + +#if defined(__amd64) + +#define TRACE_STAMP(reg) \ + rdtsc; \ + movl %eax, TTR_STAMP(reg); \ + movl %edx, TTR_STAMP+4(reg) + +/* + * %rbp should be set before invoking this macro. + */ + +#define TRACE_STACK(tt) \ + pushq %rdi; \ + pushq %rsi; \ + pushq %rdx; \ + pushq %rcx; \ + pushq %r8; \ + pushq %r9; \ + pushq %rax; \ + pushq %r12; \ + movq tt, %r12; \ + leaq TTR_STACK(%r12), %rdi; \ + movl $TTR_STACK_DEPTH, %esi; \ + call getpcstack; \ + movl %eax, TTR_SDEPTH(%r12); \ + popq %r12; \ + popq %rax; \ + popq %r9; \ + popq %r8; \ + popq %rcx; \ + popq %rdx; \ + popq %rsi; \ + popq %rdi + +#elif defined(__i386) + +#define TRACE_STAMP(reg) \ + xorl %eax, %eax; \ + xorl %edx, %edx; \ + btl $X86FSET_TSC, x86_featureset; \ + jnc 9f; \ + rdtsc; \ +9: movl %eax, TTR_STAMP(reg); \ + movl %edx, TTR_STAMP+4(reg) + +#define TRACE_STACK(tt) \ + pushl %eax; \ + pushl %ecx; \ + pushl %edx; \ + pushl %ebx; \ + pushl $TTR_STACK_DEPTH; \ + movl tt, %ebx; \ + leal TTR_STACK(%ebx), %eax; \ + pushl %eax; \ + call getpcstack; \ + addl $8, %esp; \ + movl %eax, TTR_SDEPTH(%ebx); \ + popl %ebx; \ + popl %edx; \ + popl %ecx; \ + popl %eax + +#endif /* __i386 */ + +#else + +#define TRACE_PTR(ptr, scr1, scr1_32, scr2, marker) +#define TRACE_REGS(ptr, reg, scr1, scr2) +#define TRACE_STAMP(reg) +#define TRACE_STACK(reg) + +#endif /* TRAPTRACE */ + +#endif /* _ASM */ + +#define TT_SYSCALL 0xaa /* system call via lcall */ +#define TT_SYSENTER 0xab /* system call via sysenter */ +#define TT_SYSC 0xad /* system call via syscall (32-bit) */ +#define TT_SYSC64 0xae /* system call via syscall (64-bit) */ +#define TT_INTERRUPT 0xbb +#define TT_TRAP 0xcc +#define TT_INTTRAP 0xdd +#define TT_EVENT 0xee /* hypervisor event */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TRAPTRACE_H */ diff --git a/illumos-x86_64/usr/include/sys/ts.h b/illumos-x86_64/usr/include/sys/ts.h new file mode 100644 index 00000000..2cf5dcad --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ts.h @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2019 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_TS_H +#define _SYS_TS_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * time-sharing dispatcher parameter table entry + */ +typedef struct tsdpent { + pri_t ts_globpri; /* global (class independent) priority */ + int ts_quantum; /* time quantum given to procs at this level */ + pri_t ts_tqexp; /* ts_umdpri assigned when proc at this level */ + /* exceeds its time quantum */ + pri_t ts_slpret; /* ts_umdpri assigned when proc at this level */ + /* returns to user mode after sleeping */ + short ts_maxwait; /* bumped to ts_lwait if more than ts_maxwait */ + /* secs elapse before receiving full quantum */ + short ts_lwait; /* ts_umdpri assigned if ts_dispwait exceeds */ + /* ts_maxwait */ +} tsdpent_t; + +#ifdef _KERNEL +/* + * time-sharing class specific thread structure + */ +typedef struct tsproc { + int ts_timeleft; /* time remaining in procs quantum */ + uint_t ts_dispwait; /* wall clock seconds since start */ + /* of quantum (not reset upon preempt) */ + pri_t ts_cpupri; /* system controlled component of ts_umdpri */ + pri_t ts_uprilim; /* user priority limit */ + pri_t ts_upri; /* user priority */ + pri_t ts_umdpri; /* user mode priority within ts class */ + pri_t ts_scpri; /* remembered priority, for schedctl */ + char ts_nice; /* nice value for compatibility */ + char ts_boost; /* interactive priority offset */ + uchar_t ts_flags; /* flags defined below */ + kthread_t *ts_tp; /* pointer to thread */ + struct tsproc *ts_next; /* link to next tsproc on list */ + struct tsproc *ts_prev; /* link to previous tsproc on list */ + caps_sc_t ts_caps; /* CPU caps specific data */ +} tsproc_t; + +/* flags */ + +/* Formerly: TSKPRI 0x01 - thread at kernel mode priority */ +#define TSBACKQ 0x02 /* thread goes to back of dispq if preempted */ +#define TSIA 0x04 /* thread is interactive */ +#define TSIASET 0x08 /* interactive thread is "on" */ +#define TSIANICED 0x10 /* interactive thread has been niced */ +#define TSRESTORE 0x20 /* thread was not preempted, due to schedctl */ + /* restore priority from ts_scpri */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TS_H */ diff --git a/illumos-x86_64/usr/include/sys/tsol/label.h b/illumos-x86_64/usr/include/sys/tsol/label.h new file mode 100644 index 00000000..f88f4097 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tsol/label.h @@ -0,0 +1,168 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TSOL_LABEL_H +#define _SYS_TSOL_LABEL_H + +#include +#ifdef _KERNEL +#include +#include +#include +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * types of label comparison + */ +#define EQUALITY_CHECK 0 +#define DOMINANCE_CHECK 1 + +/* Manifest human readable label names */ +#define ADMIN_LOW "ADMIN_LOW" +#define ADMIN_HIGH "ADMIN_HIGH" + +/* Binary Label Structure Definitions */ + +typedef struct _mac_label_impl m_label_t; + +typedef m_label_t blevel_t, /* compatibility */ + bslabel_t, /* Sensitivity Label */ + bclear_t; /* Clearance */ + +typedef struct _tsol_binary_level_lrange { /* Level Range */ + m_label_t *lower_bound; + m_label_t *upper_bound; +} m_range_t; + +typedef m_range_t blrange_t; + +typedef struct tsol_mlp_s { + uchar_t mlp_ipp; + uint16_t mlp_port; + uint16_t mlp_port_upper; +} tsol_mlp_t; + +/* Procedure Interface Definitions available to user and kernel */ + +extern int bltype(const void *, uint8_t); +extern int blequal(const m_label_t *, const m_label_t *); +extern int bldominates(const m_label_t *, const m_label_t *); +extern int blstrictdom(const m_label_t *, const m_label_t *); +extern int blinrange(const m_label_t *, const m_range_t *); +extern void blmaximum(m_label_t *, const m_label_t *); +extern void blminimum(m_label_t *, const m_label_t *); +extern void bsllow(m_label_t *); +extern void bslhigh(m_label_t *); +extern void bclearlow(m_label_t *); +extern void bclearhigh(m_label_t *); +extern void bslundef(m_label_t *); +extern void bclearundef(m_label_t *); +extern void setbltype(void *, uint8_t); +extern boolean_t bisinvalid(const void *); + +#ifdef _KERNEL +typedef struct tsol_mlp_entry_s { + struct tsol_mlp_entry_s *mlpe_next, *mlpe_prev; + zoneid_t mlpe_zoneid; + tsol_mlp_t mlpe_mlp; +} tsol_mlp_entry_t; + +typedef struct tsol_mlp_list_s { + krwlock_t mlpl_rwlock; + tsol_mlp_entry_t *mlpl_first, *mlpl_last; +} tsol_mlp_list_t; + +typedef struct ts_label_s { + uint_t tsl_ref; /* Reference count */ + uint32_t tsl_doi; /* Domain of Interpretation */ + uint32_t tsl_flags; /* TSLF_* below */ + m_label_t tsl_label; /* Actual label */ +} ts_label_t; + +#define DEFAULT_DOI 1 + +/* + * TSLF_UNLABELED is set in tsl_flags for packets with no explicit label + * when the peer is unlabeled. + * + * TSLF_IMPLICIT_IN is set when a packet is received with no explicit label + * from a peer which is flagged in the tnrhdb as label-aware. + * + * TSLF_IMPLICIT_OUT is set when the packet should be sent without an + * explict label even if the peer or next-hop router is flagged in the + * tnrhdb as label-aware. + */ + +#define TSLF_UNLABELED 0x00000001 /* peer is unlabeled */ +#define TSLF_IMPLICIT_IN 0x00000002 /* inbound implicit */ +#define TSLF_IMPLICIT_OUT 0x00000004 /* outbound implicit */ + +#define CR_SL(cr) (label2bslabel(crgetlabel(cr))) + +extern ts_label_t *l_admin_low; +extern ts_label_t *l_admin_high; +extern uint32_t default_doi; +extern int sys_labeling; + +extern void label_init(void); +extern ts_label_t *labelalloc(const m_label_t *, uint32_t, int); +extern ts_label_t *labeldup(const ts_label_t *, int); +extern void label_hold(ts_label_t *); +extern void label_rele(ts_label_t *); +extern m_label_t *label2bslabel(ts_label_t *); +extern uint32_t label2doi(ts_label_t *); +extern boolean_t label_equal(const ts_label_t *, const ts_label_t *); +extern cred_t *newcred_from_bslabel(m_label_t *, uint32_t, int); +extern cred_t *copycred_from_bslabel(const cred_t *, m_label_t *, + uint32_t, int); +extern cred_t *copycred_from_tslabel(const cred_t *, ts_label_t *, + int); +extern ts_label_t *getflabel(vnode_t *); +extern int getlabel(const char *, m_label_t *); +extern int fgetlabel(int, m_label_t *); +extern int _blinrange(const m_label_t *, const brange_t *); +extern int blinlset(const m_label_t *, const blset_t); + +extern int l_to_str_internal(const m_label_t *, char **); +extern int hexstr_to_label(const char *, m_label_t *); + +/* + * The use of '!!' here prevents users from referencing this function-like + * macro as though it were an l-value, and in normal use is optimized away + * by the compiler. + */ +#define is_system_labeled() (!!(sys_labeling > 0)) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_TSOL_LABEL_H */ diff --git a/illumos-x86_64/usr/include/sys/tsol/label_macro.h b/illumos-x86_64/usr/include/sys/tsol/label_macro.h new file mode 100644 index 00000000..1d576eb3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tsol/label_macro.h @@ -0,0 +1,359 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LABEL_MACRO_H +#define _LABEL_MACRO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* PRIVATE ONLY TO THE LABEL LIBRARY. DO NOT USE ELSEWHERE */ + +/* Actual Binary Label Structure Definitions */ + +typedef int16_t _Classification; +typedef struct { + union { + uint8_t class_ar[2]; + _Classification class_chunk; + } class_u; +} Classification_t; + +typedef struct { + uint32_t c1; + uint32_t c2; + uint32_t c3; + uint32_t c4; + uint32_t c5; + uint32_t c6; + uint32_t c7; + uint32_t c8; +} Compartments_t; + +typedef struct { + uint32_t m1; + uint32_t m2; + uint32_t m3; + uint32_t m4; + uint32_t m5; + uint32_t m6; + uint32_t m7; + uint32_t m8; +} Markings_t; + +typedef struct _mac_label_impl { + uint8_t id; /* Magic to say label type */ + uint8_t _c_len; /* Number of Compartment words */ + Classification_t classification; + Compartments_t compartments; +} _mac_label_impl_t; + +typedef _mac_label_impl_t _blevel_impl_t, /* compatibility */ + _bslabel_impl_t, /* Sensitivity Label */ + _bclear_impl_t; /* Clearance */ + +typedef struct _binary_information_label_impl { /* Information Label */ + _mac_label_impl_t binformation_level; + Markings_t markings; +} _bilabel_impl_t; + +typedef struct _binary_cmw_label_impl { /* CMW Label */ + _bslabel_impl_t bcl_sensitivity_label; + _bilabel_impl_t bcl_information_label; +} _bclabel_impl_t; + +typedef struct _binary_level_range_impl { /* Level Range */ + _mac_label_impl_t lower_bound; + _mac_label_impl_t upper_bound; +} _brange_impl_t, brange_t; + +#define NMLP_MAX 0x10 +#define NSLS_MAX 0x4 + +typedef _mac_label_impl_t blset_t[NSLS_MAX]; + +/* Label Identifier Types */ + +#define SUN_MAC_ID 0x41 /* MAC label, legacy SUN_SL_ID */ +#define SUN_UCLR_ID 0x49 /* User Clearance, legacy SUN_CLR_ID */ + +#define _C_LEN 8 /* number of compartments words */ + +/* m_label_t macros */ +#define _MTYPE(l, t) \ + (((_mac_label_impl_t *)(l))->id == (t)) + +#define _MSETTYPE(l, t) \ + (((_mac_label_impl_t *)(l))->id = (t)) + +#define _MGETTYPE(l) (((_mac_label_impl_t *)(l))->id) + +#define _MEQUAL(l1, l2) \ + (LCLASS(l1) == LCLASS(l2) && \ + (l1)->_comps.c1 == (l2)->_comps.c1 && \ + (l1)->_comps.c2 == (l2)->_comps.c2 && \ + (l1)->_comps.c3 == (l2)->_comps.c3 && \ + (l1)->_comps.c4 == (l2)->_comps.c4 && \ + (l1)->_comps.c5 == (l2)->_comps.c5 && \ + (l1)->_comps.c6 == (l2)->_comps.c6 && \ + (l1)->_comps.c7 == (l2)->_comps.c7 && \ + (l1)->_comps.c8 == (l2)->_comps.c8) + +#define SUN_INVALID_ID 0 /* uninitialized label */ +#define SUN_CMW_ID 0x83 /* 104 - total bytes in CMW Label */ +#define SUN_SL_ID 0x41 /* 36 - total bytes in Sensitivity Label */ +#define SUN_SL_UN 0xF1 /* undefined Sensitivity Label */ +#define SUN_IL_ID 0x42 /* 68 - total bytes in Information Label */ +#define SUN_IL_UN 0x73 /* undefined Information Label */ +#define SUN_CLR_ID 0x49 /* 36 - total bytes in Clearance */ +#define SUN_CLR_UN 0xF9 /* undefined Clearance */ + +#define _bcl_sl bcl_sensitivity_label +#define _bcl_il bcl_information_label +#define _bslev_il binformation_level + +#define _lclass classification +#ifdef _BIG_ENDIAN +#define LCLASS(slp) ((slp)->_lclass.class_u.class_chunk) +#define LCLASS_SET(slp, l) ((slp)->_lclass.class_u.class_chunk = (l)) +#else +#define LCLASS(slp) \ + ((_Classification)(((slp)->_lclass.class_u.class_ar[0] << 8) | \ + (slp)->_lclass.class_u.class_ar[1])) +#define LCLASS_SET(slp, l) \ + ((slp)->_lclass.class_u.class_ar[0] = (uint8_t)((l)>> 8), \ + (slp)->_lclass.class_u.class_ar[1] = (uint8_t)(l)) +#endif /* _BIG_ENDIAN */ +#define _comps compartments + +#define _iid _bslev_il.id +#define _i_c_len _bslev_il._c_len +#define _iclass _bslev_il._lclass +#ifdef _BIG_ENDIAN +#define ICLASS(ilp) ((ilp)->_iclass.class_u.class_chunk) +#define ICLASS_SET(ilp, l) ((ilp)->_iclass.class_u.class_chunk = (l)) +#else +#define ICLASS(ilp) \ + ((_Classification)(((ilp)->_iclass.class_u.class_ar[0] << 8) | \ + (ilp)->_iclass.class_u.class_ar[1])) +#define ICLASS_SET(ilp, l) \ + ((ilp)->_iclass.class_u.class_ar[0] = (uint8_t)((l)>> 8), \ + (ilp)->_iclass.class_u.class_ar[1] = (uint8_t)(l)) +#endif /* _BIG_ENDIAN */ +#define _icomps _bslev_il._comps +#define _imarks markings + +/* Manifest Constant Values */ + +#define LOW_CLASS 0 /* Admin_Low classification value */ +#define HIGH_CLASS 0x7FFF /* Admin_High classification value */ +#define EMPTY_SET 0 /* Empty compartments and markings set */ +#define UNIVERSAL_SET 0xFFFFFFFFU /* Universal compartments and */ + /* markings set */ + +/* Construct initial labels */ + +#define _LOW_LABEL(l, t) \ + ((l)->id = t, (l)->_c_len = _C_LEN, LCLASS_SET(l, LOW_CLASS), \ + (l)->_comps.c1 = (l)->_comps.c2 = (l)->_comps.c3 = (l)->_comps.c4 = \ + (l)->_comps.c5 = (l)->_comps.c6 = (l)->_comps.c7 = (l)->_comps.c8 = \ + EMPTY_SET) + +#define _HIGH_LABEL(l, t) \ + ((l)->id = t, (l)->_c_len = _C_LEN, LCLASS_SET(l, HIGH_CLASS), \ + (l)->_comps.c1 = (l)->_comps.c2 = (l)->_comps.c3 = (l)->_comps.c4 = \ + (l)->_comps.c5 = (l)->_comps.c6 = (l)->_comps.c7 = (l)->_comps.c8 = \ + UNIVERSAL_SET) + +/* Macro equivalents */ + +/* Is this memory a properly formatted label of type t? */ +#define BLTYPE(l, t) \ + ((t) == SUN_CMW_ID ? \ + (((_bclabel_impl_t *)(l))->_bcl_sl.id == SUN_SL_ID || \ + ((_bclabel_impl_t *)(l))->_bcl_sl.id == SUN_SL_UN) && \ + (((_bclabel_impl_t *)(l))->_bcl_il._iid == SUN_IL_ID || \ + ((_bclabel_impl_t *)(l))->_bcl_il._iid == SUN_IL_UN) : \ + ((_mac_label_impl_t *)(l))->id == (t)) + +/* Are the levels of these labels equal? */ +#define BLEQUAL(l1, l2) \ + _BLEQUAL((_mac_label_impl_t *)(l1), (_mac_label_impl_t *)(l2)) + +#define _BLEQUAL(l1, l2) \ + (LCLASS(l1) == LCLASS(l2) && \ + (l1)->_comps.c1 == (l2)->_comps.c1 && \ + (l1)->_comps.c2 == (l2)->_comps.c2 && \ + (l1)->_comps.c3 == (l2)->_comps.c3 && \ + (l1)->_comps.c4 == (l2)->_comps.c4 && \ + (l1)->_comps.c5 == (l2)->_comps.c5 && \ + (l1)->_comps.c6 == (l2)->_comps.c6 && \ + (l1)->_comps.c7 == (l2)->_comps.c7 && \ + (l1)->_comps.c8 == (l2)->_comps.c8) + +/* Does the level of l1 dominate that of l2? */ +#define BLDOMINATES(l1, l2) \ + _BLDOMINATES((_mac_label_impl_t *)(l1), (_mac_label_impl_t *)(l2)) + +#define _BLDOMINATES(l1, l2) (LCLASS(l1) >= LCLASS(l2) && \ + (l2)->_comps.c1 == ((l1)->_comps.c1 & (l2)->_comps.c1) && \ + (l2)->_comps.c2 == ((l1)->_comps.c2 & (l2)->_comps.c2) && \ + (l2)->_comps.c3 == ((l1)->_comps.c3 & (l2)->_comps.c3) && \ + (l2)->_comps.c4 == ((l1)->_comps.c4 & (l2)->_comps.c4) && \ + (l2)->_comps.c5 == ((l1)->_comps.c5 & (l2)->_comps.c5) && \ + (l2)->_comps.c6 == ((l1)->_comps.c6 & (l2)->_comps.c6) && \ + (l2)->_comps.c7 == ((l1)->_comps.c7 & (l2)->_comps.c7) && \ + (l2)->_comps.c8 == ((l1)->_comps.c8 & (l2)->_comps.c8)) + +/* Does the level of l1 strictly dominate that of l2? */ +#define BLSTRICTDOM(l1, l2) (!BLEQUAL(l1, l2) && BLDOMINATES(l1, l2)) + +/* Is the level of l within the range r? */ +#define BLINRANGE(l, r)\ + (BLDOMINATES((l), &((r)->lower_bound)) && \ + BLDOMINATES(&((r)->upper_bound), (l))) + +/* Least Upper Bound level l1 and l2 replacing l1 with the result. */ +#define BLMAXIMUM(l1, l2) \ + _BLMAXIMUM((_mac_label_impl_t *)(l1), (_mac_label_impl_t *)(l2)) + +#define _BLMAXIMUM(l1, l2)\ + (((l1)->_lclass = (LCLASS(l1) < LCLASS(l2)) ? \ + (l2)->_lclass : (l1)->_lclass), \ + (l1)->_comps.c1 |= (l2)->_comps.c1, \ + (l1)->_comps.c2 |= (l2)->_comps.c2, \ + (l1)->_comps.c3 |= (l2)->_comps.c3, \ + (l1)->_comps.c4 |= (l2)->_comps.c4, \ + (l1)->_comps.c5 |= (l2)->_comps.c5, \ + (l1)->_comps.c6 |= (l2)->_comps.c6, \ + (l1)->_comps.c7 |= (l2)->_comps.c7, \ + (l1)->_comps.c8 |= (l2)->_comps.c8) + +/* Greatest Lower Bound level l1 and l2 replacing l1 with the result. */ +#define BLMINIMUM(l1, l2) \ + _BLMINIMUM((_mac_label_impl_t *)(l1), (_mac_label_impl_t *)(l2)) + +#define _BLMINIMUM(l1, l2)\ + (((l1)->_lclass = (LCLASS(l1) > LCLASS(l2)) ? \ + (l2)->_lclass : (l1)->_lclass), \ + (l1)->_comps.c1 &= (l2)->_comps.c1, \ + (l1)->_comps.c2 &= (l2)->_comps.c2, \ + (l1)->_comps.c3 &= (l2)->_comps.c3, \ + (l1)->_comps.c4 &= (l2)->_comps.c4, \ + (l1)->_comps.c5 &= (l2)->_comps.c5, \ + (l1)->_comps.c6 &= (l2)->_comps.c6, \ + (l1)->_comps.c7 &= (l2)->_comps.c7, \ + (l1)->_comps.c8 &= (l2)->_comps.c8) + +/* Create Manifest Labels */ + +/* Write a System_Low CMW Label into this memory. */ +#define BCLLOW(l) (BSLLOW(BCLTOSL(l)), BILLOW(BCLTOIL(l))) + +/* Write a System_Low Sensitivity Label into this memory. */ +#define BSLLOW(l) _BSLLOW((_bslabel_impl_t *)(l)) + +#define _BSLLOW(l) \ + ((l)->id = SUN_SL_ID, (l)->_c_len = _C_LEN, LCLASS_SET(l, LOW_CLASS), \ + (l)->_comps.c1 = (l)->_comps.c2 = (l)->_comps.c3 = (l)->_comps.c4 = \ + (l)->_comps.c5 = (l)->_comps.c6 = (l)->_comps.c7 = (l)->_comps.c8 = \ + EMPTY_SET) + +/* Write a System_High Sensitivity Label into this memory. */ +#define BSLHIGH(l) _BSLHIGH((_bslabel_impl_t *)(l)) + +#define _BSLHIGH(l) \ + ((l)->id = SUN_SL_ID, (l)->_c_len = _C_LEN, LCLASS_SET(l, HIGH_CLASS), \ + (l)->_comps.c1 = (l)->_comps.c2 = (l)->_comps.c3 = (l)->_comps.c4 = \ + (l)->_comps.c5 = (l)->_comps.c6 = (l)->_comps.c7 = (l)->_comps.c8 = \ + UNIVERSAL_SET) + +/* Write a System_Low Information Label into this memory. */ +#define BILLOW(l) _BILLOW((_bilabel_impl_t *)(l)) + +#define _BILLOW(l) \ + ((l)->_iid = SUN_IL_ID, (l)->_i_c_len = _C_LEN, \ + ICLASS_SET(l, LOW_CLASS), \ + (l)->_icomps.c1 = (l)->_icomps.c2 = (l)->_icomps.c3 = \ + (l)->_icomps.c4 = (l)->_icomps.c5 = (l)->_icomps.c6 = \ + (l)->_icomps.c7 = (l)->_icomps.c8 = EMPTY_SET, \ + (l)->_imarks.m1 = (l)->_imarks.m2 = (l)->_imarks.m3 = \ + (l)->_imarks.m4 = (l)->_imarks.m5 = (l)->_imarks.m6 = \ + (l)->_imarks.m7 = (l)->_imarks.m8 = EMPTY_SET) + + +/* Write a System_Low Sensitivity Label into this memory. */ +#define BCLEARLOW(l) _BCLEARLOW((_bclear_impl_t *)(l)) + +#define _BCLEARLOW(c) \ + ((c)->id = SUN_CLR_ID, (c)->_c_len = _C_LEN, \ + LCLASS_SET(c, LOW_CLASS), \ + (c)->_comps.c1 = (c)->_comps.c2 = (c)->_comps.c3 = (c)->_comps.c4 = \ + (c)->_comps.c5 = (c)->_comps.c6 = (c)->_comps.c7 = (c)->_comps.c8 = \ + EMPTY_SET) + +/* Write a System_High Sensitivity Label into this memory. */ +#define BCLEARHIGH(l) _BCLEARHIGH((_bclear_impl_t *)(l)) + +#define _BCLEARHIGH(c) \ + ((c)->id = SUN_CLR_ID, (c)->_c_len = _C_LEN, \ + LCLASS_SET(c, HIGH_CLASS), \ + (c)->_comps.c1 = (c)->_comps.c2 = (c)->_comps.c3 = (c)->_comps.c4 = \ + (c)->_comps.c5 = (c)->_comps.c6 = (c)->_comps.c7 = (c)->_comps.c8 = \ + UNIVERSAL_SET) + +/* Write an undefined Sensitivity Label into this memory. */ +#define BSLUNDEF(l) (((_bslabel_impl_t *)(l))->id = SUN_SL_UN) + +/* Write an undefined Clearance into this memory. */ +#define BCLEARUNDEF(c) (((_bclear_impl_t *)(c))->id = SUN_CLR_UN) + +/* Retrieve the Sensitivity Label portion of a CMW Label */ +#define BCLTOSL(l) ((bslabel_t *)&((_bclabel_impl_t *)(l))->_bcl_sl) + +/* Retrieve the Information Label portion of a CMW Label */ +#define BCLTOIL(l) ((_bilabel_impl_t *)&((_bclabel_impl_t *)(l))->_bcl_il) + +/* Copy the Sensitivity Label portion from a CMW Label */ +#define GETCSL(l1, l2) \ + (*((_bslabel_impl_t *)(l1)) = ((_bclabel_impl_t *)(l2))->_bcl_sl) + +/* Replace the Sensitivity Label portion of a CMW Label */ +#define SETCSL(l1, l2) \ + (((_bclabel_impl_t *)(l1))->_bcl_sl = *((_bslabel_impl_t *)(l2))) + +/* Set type of this memory to the label type 't' */ +#define SETBLTYPE(l, t) (((_bclabel_impl_t *)(l))->_bcl_sl.id = (t)) + +#define GETBLTYPE(l) (((const _bclabel_impl_t *)(l))->_bcl_sl.id) + +#ifdef __cplusplus +} +#endif + +#endif /* !_LABEL_MACRO_H */ diff --git a/illumos-x86_64/usr/include/sys/tsol/priv.h b/illumos-x86_64/usr/include/sys/tsol/priv.h new file mode 100644 index 00000000..e0354f4b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tsol/priv.h @@ -0,0 +1,114 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TSOL_PRIV_H +#define _SYS_TSOL_PRIV_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum priv_ftype { + PRIV_ALLOWED, + PRIV_FORCED +} priv_ftype_t; + +/* + * Privilege macros. + */ + +/* + * PRIV_ASSERT(a, b) setst.privilege "b" in privilege set "a". + */ +#define PRIV_ASSERT(a, b) (priv_addset(a, b)) + +/* + * PRIV_CLEAR(a,b) clearst.privilege "b" in privilege set "a". + */ +#define PRIV_CLEAR(a, b) (priv_delset(a, b)) + +/* + * PRIV_EQUAL(set_a, set_b) is true if set_a and set_b are identical. + */ +#define PRIV_EQUAL(a, b) (priv_isequalset(a, b)) +#define PRIV_EMPTY(a) (priv_emptyset(a)) +#define PRIV_FILL(a) (priv_fillset(a)) + +/* + * PRIV_ISASSERT tests if privilege 'b' is asserted in privilege set 'a'. + */ +#define PRIV_ISASSERT(a, b) (priv_ismember(a, b)) +#define PRIV_ISEMPTY(a) (priv_isemptyset(a)) +#define PRIV_ISFULL(a) (priv_isfullset(a)) + +/* + * This macro returns 1 if all privileges asserted in privilege set "a" + * are also asserted in privilege set "b" (i.e. if a is a subset of b) + */ +#define PRIV_ISSUBSET(a, b) (priv_issubset(a, b)) + +/* + * Takes intersection of "a" and "b" and stores in "b". + */ +#define PRIV_INTERSECT(a, b) (priv_intersect(a, b)) + +/* + * Replaces "a" with inverse of "a". + */ +#define PRIV_INVERSE(a) (priv_inverse(a)) + +/* + * Takes union of "a" and "b" and stores in "b". + */ +#define PRIV_UNION(a, b) (priv_union(a, b)) + + +#define PRIV_FILE_UPGRADE_SL ((const char *)"file_upgrade_sl") +#define PRIV_FILE_DOWNGRADE_SL ((const char *)"file_downgrade_sl") +# +#define PRIV_PROC_AUDIT_TCB ((const char *)"proc_audit") +#define PRIV_PROC_AUDIT_APPL ((const char *)"proc_audit") +# +#define PRIV_SYS_TRANS_LABEL ((const char *)"sys_trans_label") +#define PRIV_WIN_COLORMAP ((const char *)"win_colormap") +#define PRIV_WIN_CONFIG ((const char *)"win_config") +#define PRIV_WIN_DAC_READ ((const char *)"win_dac_read") +#define PRIV_WIN_DAC_WRITE ((const char *)"win_dac_write") +#define PRIV_WIN_DGA ((const char *)"win_dga") +#define PRIV_WIN_DEVICES ((const char *)"win_devices") +#define PRIV_WIN_DOWNGRADE_SL ((const char *)"win_downgrade_sl") +#define PRIV_WIN_FONTPATH ((const char *)"win_fontpath") +#define PRIV_WIN_MAC_READ ((const char *)"win_mac_read") +#define PRIV_WIN_MAC_WRITE ((const char *)"win_mac_write") +#define PRIV_WIN_SELECTION ((const char *)"win_selection") +#define PRIV_WIN_UPGRADE_SL ((const char *)"win_upgrade_sl") + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TSOL_PRIV_H */ diff --git a/illumos-x86_64/usr/include/sys/tsol/tndb.h b/illumos-x86_64/usr/include/sys/tsol/tndb.h new file mode 100644 index 00000000..f74cd509 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tsol/tndb.h @@ -0,0 +1,407 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * from "tndb.h 7.34 01/08/31 SMI; TSOL 2.x" + */ + +#ifndef _SYS_TSOL_TNDB_H +#define _SYS_TSOL_TNDB_H + +#include +#include +#include +#include +#include + +#ifdef _KERNEL +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* same on ILP32 and LP64 */ +typedef union tnaddr { + struct sockaddr_in ip_addr_v4; + struct sockaddr_in6 ip_addr_v6; +} tnaddr_t; + +#define ta_family ip_addr_v4.sin_family +#define ta_addr_v4 ip_addr_v4.sin_addr +#define ta_addr_v6 ip_addr_v6.sin6_addr +#define ta_port_v4 ip_addr_v4.sin_port +#define ta_port_v6 ip_addr_v6.sin6_port + +#define TNADDR_EQ(addr1, addr2) \ + (((addr1)->ta_family == AF_INET && (addr2)->ta_family == AF_INET && \ + (addr1)->ta_addr_v4.s_addr == (addr2)->ta_addr_v4.s_addr) || \ + ((addr1)->ta_family == AF_INET6 && (addr2)->ta_family == AF_INET6 && \ + IN6_ARE_ADDR_EQUAL(&(addr1)->ta_addr_v6, &(addr2)->ta_addr_v6))) + +/* + * structure for TN database access routines and TN system calls + */ + +typedef enum tsol_dbops { + TNDB_NOOP = 0, + TNDB_LOAD = 1, + TNDB_DELETE = 2, + TNDB_FLUSH = 3, + TNDB_GET = 5 +} tsol_dbops_t; + +#define TNTNAMSIZ ZONENAME_MAX /* template name size */ +#define IP_STR_SIZE 200 /* string ip address size */ + +#define TNRHDB_NCOL 2 /* # of columns in tnrhdb */ + +/* + * For tnrhdb access library routines and tnrh(2TSOL) + * same for both ILP32 and LP64. + */ +typedef struct tsol_rhent { + short rh_prefix; /* length of subnet mask */ + short rh_unused; /* padding */ + tnaddr_t rh_address; /* IP address */ + char rh_template[TNTNAMSIZ]; /* template name */ +} tsol_rhent_t; + +typedef struct tsol_rhstr_s { + int family; + char *address; + char *template; +} tsol_rhstr_t; + +/* + * host types recognized by tsol hosts + */ +typedef enum { + UNLABELED = 1, + SUN_CIPSO = 3 +} tsol_host_type_t; + +typedef enum { + OPT_NONE = 0, + OPT_CIPSO = 1 +} tsol_ip_label_t; + +typedef struct cipso_tag_type_1 { + uchar_t tag_type; /* Tag Type (1) */ + uchar_t tag_length; /* Length of Tag */ + uchar_t tag_align; /* Alignment Octet */ + uchar_t tag_sl; /* Sensitivity Level */ + uchar_t tag_cat[1]; /* Categories */ +} cipso_tag_type_1_t; + +#define TSOL_CIPSO_MIN_LENGTH 6 +#define TSOL_CIPSO_MAX_LENGTH IP_MAX_OPT_LENGTH +#define TSOL_TT1_MIN_LENGTH 4 +#define TSOL_TT1_MAX_LENGTH 34 + +#define TSOL_CIPSO_DOI_OFFSET 2 +#define TSOL_CIPSO_TAG_OFFSET 6 + +typedef struct cipso_option { + uchar_t cipso_type; /* Type of option (134) */ + uchar_t cipso_length; /* Length of option */ + uchar_t cipso_doi[4]; /* Domain of Interpretation */ + uchar_t cipso_tag_type[1]; /* variable length */ +} cipso_option_t; + +/* + * RIPSO classifications + */ +#define TSOL_CL_TOP_SECRET 0x3d +#define TSOL_CL_SECRET 0x5a +#define TSOL_CL_CONFIDENTIAL 0x96 +#define TSOL_CL_UNCLASSIFIED 0xab + +/* + * RIPSO protection authorities + */ +#define TSOL_PA_GENSER 0x80 +#define TSOL_PA_SIOP_ESI 0x40 +#define TSOL_PA_SCI 0x20 +#define TSOL_PA_NSA 0x10 +#define TSOL_PA_DOE 0x08 + +/* + * this mask is only used for tndb structures, and is different + * from t6mask_t bits definitions + */ + +typedef unsigned int tnmask_t; + +/* + * unlabeled host structure for the tnrhtp template. + * same for both ILP32 and LP64. + */ +struct tsol_unl { + tnmask_t mask; /* tells which attributes are returned by the library */ + bslabel_t def_label; /* default label */ + brange_t gw_sl_range; /* for routing only */ + blset_t sl_set; /* label set */ +}; + +/* + * CIPSO host structure for the tnrhtp template + * same for both ILP32 and LP64. + */ +struct tsol_cipso { + tnmask_t mask; /* tells which attributes are returned by the library */ + bclear_t def_cl; /* default clearance */ + brange_t sl_range; /* min/max SL range */ + blset_t sl_set; /* label set */ +}; + +/* + * Valid keys and values of the key=value pairs for tnrhtp + */ +#define TP_UNLABELED "unlabeled" +#define TP_CIPSO "cipso" +#define TP_ZONE "zone" +#define TP_HOSTTYPE "host_type" +#define TP_DOI "doi" +#define TP_DEFLABEL "def_label" +#define TP_MINLABEL "min_sl" +#define TP_MAXLABEL "max_sl" +#define TP_SET "sl_set" + +#define TP_COMMA "," + +#define TNRHTP_NCOL 2 /* # of columns in tnrhtp */ + +/* + * For tnrhtp access library routines and tnrhtp(2TSOL) + * same for both ILP32 and LP64. + */ +typedef struct tsol_tpent { + char name[TNTNAMSIZ]; /* template name */ + tsol_host_type_t host_type; /* specifies host type */ + int tp_doi; /* Domain of Interpretation */ +#define tp_cipso_doi_unl tp_doi +#define tp_cipso_doi_cipso tp_doi + union { + struct tsol_unl unl; /* template for unlabeled */ +#define tp_mask_unl un.unl.mask +#define tp_def_label un.unl.def_label +#define tp_gw_sl_range un.unl.gw_sl_range +#define tp_gw_sl_set un.unl.sl_set + + struct tsol_cipso cipso; /* template for CIPSO */ +#define tp_mask_cipso un.cipso.mask +#define tp_def_cl_cipso un.cipso.def_cl +#define tp_sl_range_cipso un.cipso.sl_range +#define tp_sl_set_cipso un.cipso.sl_set + } un; +} tsol_tpent_t; + +typedef struct tsol_tpstr_s { + char *template; + char *attrs; +} tsol_tpstr_t; + +/* + * For tnmlp(2TSOL); same for both ILP32 and LP64. + */ +typedef struct tsol_mlpent { + zoneid_t tsme_zoneid; + uint_t tsme_flags; /* TSOL_MEF_* */ + tsol_mlp_t tsme_mlp; +} tsol_mlpent_t; + +#define TSOL_MEF_SHARED 0x00000001 /* MLP defined on shared addresses */ + +/* + * For tnzonecfg access library routines. + * List of MLPs ends with null entry, where protocol and port are both zero. + */ +typedef struct tsol_zcent { + char zc_name[ZONENAME_MAX]; + int zc_doi; + bslabel_t zc_label; + int zc_match; + tsol_mlp_t *zc_private_mlp; + tsol_mlp_t *zc_shared_mlp; +} tsol_zcent_t; +#define TSOL_MLP_END(mlp) ((mlp)->mlp_ipp == 0 && (mlp)->mlp_port == 0) + +#if (defined(_KERNEL) || defined(_KMEMUSER)) +typedef struct tsol_tpc { + kmutex_t tpc_lock; /* lock for structure */ + uint_t tpc_refcnt; /* reference count */ + boolean_t tpc_invalid; /* entry has been deleted */ + struct tsol_tpent tpc_tp; /* template */ +} tsol_tpc_t; + +typedef struct tsol_tnrhc { + struct tsol_tnrhc *rhc_next; /* link to next entry */ + kmutex_t rhc_lock; /* lock for structure */ + tnaddr_t rhc_host; /* IPv4/IPv6 host address */ + tsol_tpc_t *rhc_tpc; /* pointer to template */ + uint_t rhc_refcnt; /* Number of references */ + char rhc_invalid; /* out-of-date rhc */ + char rhc_isbcast; /* broadcast address */ + char rhc_local; /* loopback or local interace */ +} tsol_tnrhc_t; +#endif /* _KERNEL || _KMEMUSER */ + +/* Size of remote host hash tables in kernel */ +#define TNRHC_SIZE 256 +#define TSOL_MASK_TABLE_SIZE 33 +#define TSOL_MASK_TABLE_SIZE_V6 129 + +#ifdef _KERNEL +#define TNRHC_HOLD(a) { \ + mutex_enter(&(a)->rhc_lock); \ + (a)->rhc_refcnt++; \ + ASSERT((a)->rhc_refcnt > 0); \ + mutex_exit(&(a)->rhc_lock); \ +} +#define TNRHC_RELE(a) { \ + mutex_enter(&(a)->rhc_lock); \ + ASSERT((a)->rhc_refcnt > 0); \ + if (--(a)->rhc_refcnt <= 0) \ + tnrhc_free(a); \ + else \ + mutex_exit(&(a)->rhc_lock); \ +} +extern void tnrhc_free(tsol_tnrhc_t *); +#define TPC_HOLD(a) { \ + mutex_enter(&(a)->tpc_lock); \ + (a)->tpc_refcnt++; \ + ASSERT((a)->tpc_refcnt > 0); \ + mutex_exit(&(a)->tpc_lock); \ +} +#define TPC_RELE(a) { \ + mutex_enter(&(a)->tpc_lock); \ + ASSERT((a)->tpc_refcnt > 0); \ + if (--(a)->tpc_refcnt <= 0) \ + tpc_free(a); \ + else \ + mutex_exit(&(a)->tpc_lock); \ +} +extern void tpc_free(tsol_tpc_t *); +#endif /* _KERNEL */ + +/* + * The next three hashing macros are copied from macros in ip_ire.h. + */ +#define TSOL_ADDR_HASH(addr, table_size) \ + (((((addr) >> 16) ^ (addr)) ^ ((((addr) >> 16) ^ (addr))>> 8)) \ + % (table_size)) + +#define TSOL_ADDR_HASH_V6(addr, table_size) \ + (((addr).s6_addr8[8] ^ (addr).s6_addr8[9] ^ \ + (addr).s6_addr8[10] ^ (addr).s6_addr8[13] ^ \ + (addr).s6_addr8[14] ^ (addr).s6_addr8[15]) % (table_size)) + +/* This assumes that table_size is a power of 2. */ +#define TSOL_ADDR_MASK_HASH_V6(addr, mask, table_size) \ + ((((addr).s6_addr8[8] & (mask).s6_addr8[8]) ^ \ + ((addr).s6_addr8[9] & (mask).s6_addr8[9]) ^ \ + ((addr).s6_addr8[10] & (mask).s6_addr8[10]) ^ \ + ((addr).s6_addr8[13] & (mask).s6_addr8[13]) ^ \ + ((addr).s6_addr8[14] & (mask).s6_addr8[14]) ^ \ + ((addr).s6_addr8[15] & (mask).s6_addr8[15])) & ((table_size) - 1)) + + +/* + * Constants used for getting the mask value in struct tsol_tpent + */ +enum { + TNT_DEF_LABEL, + TNT_DEF_CL, + TNT_SL_RANGE_TSOL, /* use this for both unl and zone */ + TNT_CIPSO_DOI +}; + +/* + * mask definitions + */ +#define tsol_tntmask(value) ((unsigned int)(1<<(value))) + +#define TSOL_MSK_DEF_LABEL tsol_tntmask(TNT_DEF_LABEL) +#define TSOL_MSK_DEF_CL tsol_tntmask(TNT_DEF_CL) +#define TSOL_MSK_SL_RANGE_TSOL tsol_tntmask(TNT_SL_RANGE_TSOL) +#define TSOL_MSK_CIPSO_DOI tsol_tntmask(TNT_CIPSO_DOI) + +/* + * TN errors + */ +#define TSOL_PARSE_ERANGE 1 /* result buffer not allocated */ +#define TSOL_NOT_SUPPORTED 2 /* address family not supported */ +#define TSOL_NOT_FOUND 3 /* search by * routines target not found */ + +/* + * Structure used to hold a list of IP addresses. + */ +typedef struct tsol_address { + struct tsol_address *next; + in_addr_t ip_address; +} tsol_address_t; + +#if (defined(_KERNEL) || defined(_KMEMUSER)) +/* This is shared between tcache and mdb */ +typedef struct tnrhc_hash_s { + tsol_tnrhc_t *tnrh_list; + kmutex_t tnrh_lock; +} tnrhc_hash_t; +#endif /* _KERNEL || _KMEMUSER */ + +#ifdef _KERNEL +typedef enum { + mlptSingle, + mlptPrivate, + mlptShared, + mlptBoth +} mlp_type_t; + +extern tsol_tpc_t *find_tpc(const void *, uchar_t, boolean_t); +extern void tcache_init(void); +extern in_port_t tsol_next_port(zone_t *, in_port_t, int, boolean_t); +extern mlp_type_t tsol_mlp_port_type(zone_t *, uchar_t, uint16_t, mlp_type_t); +extern zoneid_t tsol_mlp_findzone(uchar_t, uint16_t); +extern int tsol_mlp_anon(zone_t *, mlp_type_t, uchar_t, uint16_t, boolean_t); +extern void tsol_print_label(const blevel_t *, const char *); + +struct tsol_gc_s; +struct tsol_gcgrp_s; +struct tsol_gcgrp_addr_s; + +extern struct tsol_gc_s *gc_create(struct rtsa_s *, struct tsol_gcgrp_s *, + boolean_t *); +extern void gc_inactive(struct tsol_gc_s *); +extern int rtsa_validate(const struct rtsa_s *); +extern struct tsol_gcgrp_s *gcgrp_lookup(struct tsol_gcgrp_addr_s *, boolean_t); +extern void gcgrp_inactive(struct tsol_gcgrp_s *); +extern int tnrh_load(const tsol_rhent_t *); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TSOL_TNDB_H */ diff --git a/illumos-x86_64/usr/include/sys/tsol/tsyscall.h b/illumos-x86_64/usr/include/sys/tsol/tsyscall.h new file mode 100644 index 00000000..b1d9112a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tsol/tsyscall.h @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TSOL_TSYSCALL_H +#define _SYS_TSOL_TSYSCALL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * the defines for subcode of labelsys system call. + */ + +#define TSOL_SYSLABELING 1 +#define TSOL_TNRH 2 +#define TSOL_TNRHTP 3 +#define TSOL_TNMLP 4 +#define TSOL_GETLABEL 5 +#define TSOL_FGETLABEL 6 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TSOL_TSYSCALL_H */ diff --git a/illumos-x86_64/usr/include/sys/tspriocntl.h b/illumos-x86_64/usr/include/sys/tspriocntl.h new file mode 100644 index 00000000..6d814631 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tspriocntl.h @@ -0,0 +1,92 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright (c) 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_TSPRIOCNTL_H +#define _SYS_TSPRIOCNTL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Time-sharing class specific structures for the priocntl system call. + */ + +typedef struct tsparms { + pri_t ts_uprilim; /* user priority limit */ + pri_t ts_upri; /* user priority */ +} tsparms_t; + + +typedef struct tsinfo { + pri_t ts_maxupri; /* configured limits of user priority range */ +} tsinfo_t; + +#define TS_NOCHANGE -32768 + +/* + * Time-sharing class specific keys for the priocntl system call + * varargs interface. + */ +#define TS_KY_UPRILIM 1 /* user priority limit */ +#define TS_KY_UPRI 2 /* user priority */ + +/* + * The following is used by the dispadmin(8) command for + * scheduler administration and is not for general use. + */ + +#ifdef _SYSCALL32 +/* Data structure for ILP32 clients */ +typedef struct tsadmin32 { + caddr32_t ts_dpents; + int16_t ts_ndpents; + int16_t ts_cmd; +} tsadmin32_t; +#endif /* _SYSCALL32 */ + +typedef struct tsadmin { + struct tsdpent *ts_dpents; + short ts_ndpents; + short ts_cmd; +} tsadmin_t; + +#define TS_GETDPSIZE 1 +#define TS_GETDPTBL 2 +#define TS_SETDPTBL 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TSPRIOCNTL_H */ diff --git a/illumos-x86_64/usr/include/sys/tss.h b/illumos-x86_64/usr/include/sys/tss.h new file mode 100644 index 00000000..443ee252 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tss.h @@ -0,0 +1,179 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TSS_H +#define _SYS_TSS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)tss.h 5.4 (Berkeley) 1/18/91 + * $FreeBSD: src/sys/i386/include/tss.h,v 1.13 2002/09/23 05:04:05 peter Exp $ + */ +/* + * Copyright 2011 Joyent, Inc. All rights reserved. + */ + +/* + * Maximum I/O address that will be in TSS bitmap + */ +#define MAXTSSIOADDR 0x3ff /* XXX - needs to support 64K I/O space */ + +#ifndef _ASM + +/* + * Task state segment (tss). Holds the processor state assoicated with a task. + * + * Historically, this header only exposed a struct tss that was relevant to the + * specific Intel architecture that we were deploying on. However, the tss + * structures are defined by the Intel Architecture and other consumers would + * like to use them. Rather than requiring them to duplicate all of this + * information, we instead expose each version under different names but in a + * backwards compatible manner. + */ + +#pragma pack(4) +struct tss64 { + uint32_t tss_rsvd0; /* reserved, ignored */ + uint64_t tss_rsp0; /* stack pointer CPL = 0 */ + uint64_t tss_rsp1; /* stack pointer CPL = 1 */ + uint64_t tss_rsp2; /* stack pointer CPL = 2 */ + uint64_t tss_rsvd1; /* reserved, ignored */ + uint64_t tss_ist1; /* Interrupt stack table 1 */ + uint64_t tss_ist2; /* Interrupt stack table 2 */ + uint64_t tss_ist3; /* Interrupt stack table 3 */ + uint64_t tss_ist4; /* Interrupt stack table 4 */ + uint64_t tss_ist5; /* Interrupt stack table 5 */ + uint64_t tss_ist6; /* Interrupt stack table 6 */ + uint64_t tss_ist7; /* Interrupt stack table 7 */ + uint64_t tss_rsvd2; /* reserved, ignored */ + uint16_t tss_rsvd3; /* reserved, ignored */ + uint16_t tss_bitmapbase; /* io permission bitmap base address */ +}; +#pragma pack() + +struct tss32 { + uint16_t tss_link; /* 16-bit prior TSS selector */ + uint16_t tss_rsvd0; /* reserved, ignored */ + uint32_t tss_esp0; + uint16_t tss_ss0; + uint16_t tss_rsvd1; /* reserved, ignored */ + uint32_t tss_esp1; + uint16_t tss_ss1; + uint16_t tss_rsvd2; /* reserved, ignored */ + uint32_t tss_esp2; + uint16_t tss_ss2; + uint16_t tss_rsvd3; /* reserved, ignored */ + uint32_t tss_cr3; + uint32_t tss_eip; + uint32_t tss_eflags; + uint32_t tss_eax; + uint32_t tss_ecx; + uint32_t tss_edx; + uint32_t tss_ebx; + uint32_t tss_esp; + uint32_t tss_ebp; + uint32_t tss_esi; + uint32_t tss_edi; + uint16_t tss_es; + uint16_t tss_rsvd4; /* reserved, ignored */ + uint16_t tss_cs; + uint16_t tss_rsvd5; /* reserved, ignored */ + uint16_t tss_ss; + uint16_t tss_rsvd6; /* reserved, ignored */ + uint16_t tss_ds; + uint16_t tss_rsvd7; /* reserved, ignored */ + uint16_t tss_fs; + uint16_t tss_rsvd8; /* reserved, ignored */ + uint16_t tss_gs; + uint16_t tss_rsvd9; /* reserved, ignored */ + uint16_t tss_ldt; + uint16_t tss_rsvd10; /* reserved, ignored */ + uint16_t tss_rsvd11; /* reserved, ignored */ + uint16_t tss_bitmapbase; /* io permission bitmap base address */ +}; + +struct tss16 { + uint16_t tss_link; + uint16_t tss_sp0; + uint16_t tss_ss0; + uint16_t tss_sp1; + uint16_t tss_ss1; + uint16_t tss_sp2; + uint16_t tss_ss2; + uint16_t tss_ip; + uint16_t tss_flag; + uint16_t tss_ax; + uint16_t tss_cx; + uint16_t tss_dx; + uint16_t tss_bx; + uint16_t tss_sp; + uint16_t tss_bp; + uint16_t tss_si; + uint16_t tss_di; + uint16_t tss_es; + uint16_t tss_cs; + uint16_t tss_ss; + uint16_t tss_ds; + uint16_t tss_ldt; +}; + +#if defined(__amd64) + +typedef struct tss64 tss_t; + +#elif defined(__i386) + +typedef struct tss32 tss_t; + +#endif /* __i386 */ + +#endif /* !_ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TSS_H */ diff --git a/illumos-x86_64/usr/include/sys/ttcompat.h b/illumos-x86_64/usr/include/sys/ttcompat.h new file mode 100644 index 00000000..2d35c358 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ttcompat.h @@ -0,0 +1,95 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_TTCOMPAT_H +#define _SYS_TTCOMPAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * BSD/XENIX/V7 ttcompat module header file + */ + +/* + * Old-style terminal state. + */ +typedef struct { + int t_flags; /* flags */ + char t_ispeed, t_ospeed; /* speeds */ + char t_erase; /* erase last character */ + char t_kill; /* erase entire line */ + char t_intrc; /* interrupt */ + char t_quitc; /* quit */ + char t_startc; /* start output */ + char t_stopc; /* stop output */ + char t_eofc; /* end-of-file */ + char t_brkc; /* input delimiter (like nl) */ + char t_suspc; /* stop process signal */ + char t_dsuspc; /* delayed stop process signal */ + char t_rprntc; /* reprint line */ + char t_flushc; /* flush output (toggles) */ + char t_werasc; /* word erase */ + char t_lnextc; /* literal next character */ + int t_xflags; /* XXX extended flags */ +} compat_state_t; + +/* + * Per-tty structure. + */ +typedef struct { + mblk_t *t_iocpending; /* ioctl pending successful */ + /* allocation */ + compat_state_t t_curstate; /* current emulated state */ + struct sgttyb t_new_sgttyb; /* new sgttyb from TIOCSET[PN] */ + struct tchars t_new_tchars; /* new tchars from TIOCSETC */ + struct ltchars t_new_ltchars; /* new ltchars from TIOCSLTC */ + int t_new_lflags; /* new lflags from TIOCLSET/LBIS/LBIC */ + int t_state; /* state bits */ + int t_iocid; /* ID of "ioctl" we handle specially */ + int t_ioccmd; /* ioctl code for that "ioctl" */ + bufcall_id_t t_bufcallid; /* ID from qbufcall */ + intptr_t t_arg; /* third argument to ioctl */ +} ttcompat_state_t; + + +#define TS_FREE 0x00 /* not in use */ +#define TS_INUSE 0x01 /* allocated */ +#define TS_W_IN 0x02 /* waiting for an M_IOCDATA response to an */ + /* M_COPYIN request */ +#define TS_W_OUT 0x04 /* waiting for an M_IOCDATA response to an */ + /* M_COPYOUT request */ +#define TS_IOCWAIT 0x08 /* waiting for an M_IOCACK/M_IOCNAK from downstream */ +#define TS_TIOCNAK 0x10 /* received a NAK in response to a ttcompat message */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TTCOMPAT_H */ diff --git a/illumos-x86_64/usr/include/sys/ttold.h b/illumos-x86_64/usr/include/sys/ttold.h new file mode 100644 index 00000000..d2d9c3bd --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ttold.h @@ -0,0 +1,283 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_TTOLD_H +#define _SYS_TTOLD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* All the ioctls (BSD, V7, XENIX, S5) defines are in termios.h */ +/* this file has mostly BSD structures and flags */ + +/* BSD special characters. Structure for TIOCSTC/TIOCGTC */ +struct tchars { + char t_intrc; /* interrupt */ + char t_quitc; /* quit */ + char t_startc; /* start output */ + char t_stopc; /* stop output */ + char t_eofc; /* end-of-file */ + char t_brkc; /* input delimiter (like nl) */ +}; + +/* note xenix defines tchars as tc */ +struct tc { + char t_intrc; /* interrupt */ + char t_quitc; /* quit */ + char t_startc; /* start output */ + char t_stopc; /* stop output */ + char t_eofc; /* end-of-file */ + char t_brkc; /* input delimiter (like nl) */ +}; + +#ifndef _SGTTY_H +/* + * Structure for TIOCGETP and TIOCSETP ioctls. + */ + +/* sg_flags value changed from short (in SUN/BSD) to int in System V to */ +/* match sgtty.h definition */ +struct sgttyb { + char sg_ispeed; /* input speed */ + char sg_ospeed; /* output speed */ + char sg_erase; /* erase character */ + char sg_kill; /* kill character */ + int sg_flags; /* mode flags */ +}; + +/* BSD local special chars. Structure for TIOCSLTC/TIOCGLTC */ +struct ltchars { + char t_suspc; /* stop process signal */ + char t_dsuspc; /* delayed stop process signal */ + char t_rprntc; /* reprint line */ + char t_flushc; /* flush output (toggles) */ + char t_werasc; /* word erase */ + char t_lnextc; /* literal next character */ +}; +#endif /* _SGTTY_H */ + +/* + * 4.3BSD/XENIX tty ioctl commands that are either: + * 1) deprecated + * 2) not implemented (and never were implemented) + * 3) implemented on top of new-style "ioctl"s. + */ + +/* + * These ioctls are also defined in termios.h. + * because XENIX expects to see them in termio.h + */ + +#ifndef tIOC +#define tIOC ('t'<<8) +#endif + +#ifndef _SYS_TERMIOS_H +/* defined in termios.h also so that all the ioctl codes are visible */ + +#define TIOCGETD (tIOC|0) +#define TIOCSETD (tIOC|1) +#ifndef _SGTTY_H +#define TIOCHPCL (tIOC|2) +#define TIOCGETP (tIOC|8) +#define TIOCSETP (tIOC|9) +#endif /* _SGTTY_H */ +#define TIOCSETN (tIOC|10) +#ifndef _SGTTY_H +#define TIOCEXCL (tIOC|13) +#define TIOCNXCL (tIOC|14) +#endif /* _SGTTY_H */ +#define TIOCFLUSH (tIOC|16) +#define TIOCSETC (tIOC|17) +#define TIOCGETC (tIOC|18) + +/* BSD ioctls that are not the same as XENIX */ +#define TIOCLBIS (tIOC|127) /* bis local mode bits */ +#define TIOCLBIC (tIOC|126) /* bic local mode bits */ +#define TIOCLSET (tIOC|125) /* set entire local mode word */ +#define TIOCLGET (tIOC|124) /* get local modes */ +#define TIOCSBRK (tIOC|123) /* set break bit */ +#define TIOCCBRK (tIOC|122) /* clear break bit */ +#define TIOCSDTR (tIOC|121) /* set data terminal ready */ +#define TIOCCDTR (tIOC|120) /* clear data terminal ready */ +#define TIOCSLTC (tIOC|117) /* set local special chars */ +#define TIOCGLTC (tIOC|116) /* get local special chars */ +#define TIOCOUTQ (tIOC|115) /* driver output queue size */ +#define TIOCNOTTY (tIOC|113) /* void tty association */ +#define TIOCSTOP (tIOC|111) /* stop output, like ^S */ +#define TIOCSTART (tIOC|110) /* start output, like ^Q */ + +#define TIOCREMOTE (tIOC|30) /* remote input editing */ + +/* windowing ioctls and structure also defined in termios.h */ + +#ifndef _TIOC +#define _TIOC ('T'<<8) +#endif + +#define TIOCGWINSZ (_TIOC|104) +#define TIOCSWINSZ (_TIOC|103) + +/* Windowing structure to support TIOCSWINSZ/TIOCGWINSZ */ +struct winsize { + unsigned short ws_row; /* rows, in characters */ + unsigned short ws_col; /* columns, in character */ + unsigned short ws_xpixel; /* horizontal size, pixels */ + unsigned short ws_ypixel; /* vertical size, pixels */ +}; + + +#endif /* end _SYS_TERMIOS_H */ + +/* Old SVR3.0 flags - should be removed if there is no problem */ +/* note they are commented out */ + +#if 0 + +#define O_HUPCL 01 +#define O_XTABS 02 +#define O_LCASE 04 /* simulate lower case */ +#define O_ECHO 010 /* echo input */ +#define O_CRMOD 020 /* map \r to \r\n on output */ +#define O_RAW 040 /* no i/o processing */ +#define O_ODDP 0100 /* get/send odd parity */ +#define O_EVENP 0200 /* get/send even parity */ +#define O_NLDELAY 001400 /* \n delay */ +#define O_NL1 000400 +#define O_NL2 001000 +#define O_TBDELAY 002000 /* horizontal tab delay */ +#define O_NOAL 004000 +#define O_CRDELAY 030000 /* \r delay */ +#define O_CR1 010000 +#define O_CR2 020000 +#define O_VTDELAY 040000 /* vertical tab delay */ +#define O_BSDELAY 0100000 /* \b delay */ + +#endif + +/* + * 4.3 BSD additions. These are new codes and some of the + * flags that were there in SVR3.2 ttold.h have been given + * new codes. Otherwise they will not fit in a word. + */ + +#define O_TANDEM 0x00000001 /* send stopc on out q full */ +#define O_CBREAK 0x00000002 /* half-cooked mode */ +#define O_LCASE 0x00000004 /* simulate lower case */ +#define O_ECHO 0x00000008 /* echo input */ +#define O_CRMOD 0x00000010 /* map \r to \r\n on output */ +#define O_RAW 0x00000020 /* no i/o processing */ +#define O_ODDP 0x00000040 /* get/send odd parity */ +#define O_EVENP 0x00000080 /* get/send even parity */ +#define O_ANYP 0x000000c0 /* get any parity/send none */ +#define O_NLDELAY 0x00000300 /* \n delay */ +#define O_NL0 0x00000000 +#define O_NL1 0x00000100 /* tty 37 */ +#define O_NL2 0x00000200 /* vt05 */ +#define O_NL3 0x00000300 +#define O_TBDELAY 0x00000c00 /* horizontal tab delay */ +#define O_TAB0 0x00000000 +#define O_TAB1 0x00000400 /* tty 37 */ +#define O_TAB2 0x00000800 +#define O_XTABS 0x00000c00 /* expand tabs on output */ +#define O_CRDELAY 0x00003000 /* \r delay */ +#define O_CR0 0x00000000 +#define O_CR1 0x00001000 /* tn 300 */ +#define O_CR2 0x00002000 /* tty 37 */ +#define O_CR3 0x00003000 /* concept 100 */ +#define O_VTDELAY 0x00004000 /* vertical tab delay */ +#define O_FF0 0x00000000 +#define O_FF1 0x00004000 /* tty 37 */ +#define O_BSDELAY 0x00008000 /* \b delay */ +#define O_BS0 0x00000000 +#define O_BS1 0x00008000 +#define O_ALLDELAY \ + (O_NLDELAY|O_TBDELAY|O_CRDELAY|O_VTDELAY|O_BSDELAY) +#define O_CRTBS 0x00010000 /* do backspacing for crt */ +#define O_PRTERA 0x00020000 /* \ ... / erase */ +#define O_CRTERA 0x00040000 /* " \b " to wipe out char */ +#define O_TILDE 0x00080000 /* hazeltine tilde kludge */ +#define O_MDMBUF 0x00100000 /* start/stop output on */ + /* carrier intr */ +#define O_LITOUT 0x00200000 /* literal output */ +#define O_TOSTOP 0x00400000 /* SIGSTOP on background */ + /* output */ +#define O_FLUSHO 0x00800000 /* flush output to terminal */ +#define O_NOHANG 0x01000000 /* no SIGHUP on carrier drop */ +#define O_L001000 0x02000000 +#define O_CRTKIL 0x04000000 /* kill line with " \b " */ +#define O_PASS8 0x08000000 +#define O_CTLECH 0x10000000 /* echo control chars as ^X */ +#define O_PENDIN 0x20000000 /* tp->t_rawq needs reread */ +#define O_DECCTQ 0x40000000 /* only ^Q starts after ^S */ +#define O_NOFLSH 0x80000000 /* no output flush on signal */ + +/* more BSD flags */ +#define LCRTBS (O_CRTBS>>16) +#define LPRTERA (O_PRTERA>>16) +#define LCRTERA (O_CRTERA>>16) +#define LTILDE (O_TILDE>>16) +#define LMDMBUF (O_MDMBUF>>16) +#define LLITOUT (O_LITOUT>>16) +#define LTOSTOP (O_TOSTOP>>16) +#define LFLUSHO (O_FLUSHO>>16) +#define LNOHANG (O_NOHANG>>16) +#define LCRTKIL (O_CRTKIL>>16) +#define LPASS8 (O_PASS8>>16) +#define LCTLECH (O_CTLECH>>16) +#define LPENDIN (O_PENDIN>>16) +#define LDECCTQ (O_DECCTQ>>16) +#define LNOFLSH (O_NOFLSH>>16) + + +#define NOPOST 0x00000001 /* no processing on output (LITOUT */ + /* with 7 bits + parity) */ +#define NOISIG 0x00000002 /* disable all signal-generating */ + /* characters */ +#define STOPB 0x00000004 /* two stop bits */ + +#define OTTYDISC 0 /* old, v7 std tty driver */ +#define NETLDISC 1 /* line discip for berk net */ +#define NTTYDISC 2 /* new tty discipline */ +#define TABLDISC 3 /* hitachi tablet discipline */ +#define NTABLDISC 4 /* gtco tablet discipline */ +#define MOUSELDISC 5 /* mouse discipline */ +#define KBDLDISC 6 /* up/down keyboard trans (console) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TTOLD_H */ diff --git a/illumos-x86_64/usr/include/sys/tty.h b/illumos-x86_64/usr/include/sys/tty.h new file mode 100644 index 00000000..ccefaeec --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tty.h @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1987-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _SYS_TTY_H +#define _SYS_TTY_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct tty_common { + int t_flags; + queue_t *t_readq; /* stream's read queue */ + queue_t *t_writeq; /* stream's write queue */ + tcflag_t t_iflag; /* copy of iflag from tty modes */ + tcflag_t t_cflag; /* copy of cflag from tty modes */ + uchar_t t_stopc; /* copy of c_cc[VSTOP] from tty modes */ + uchar_t t_startc; /* copy of c_cc[VSTART] from tty modes */ + struct winsize t_size; /* screen/page size */ + mblk_t *t_iocpending; /* ioctl reply pending successful allocation */ + kmutex_t t_excl; /* keeps struct consistent */ +} tty_common_t; + +#define TS_XCLUDE 0x00000001 /* tty is open for exclusive use */ +#define TS_SOFTCAR 0x00000002 /* force carrier on */ + +#ifdef _KERNEL +extern void ttycommon_close(tty_common_t *); +extern void ttycommon_qfull(tty_common_t *, queue_t *); +extern size_t ttycommon_ioctl(tty_common_t *, queue_t *, mblk_t *, int *); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TTY_H */ diff --git a/illumos-x86_64/usr/include/sys/ttychars.h b/illumos-x86_64/usr/include/sys/ttychars.h new file mode 100644 index 00000000..24ad5900 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ttychars.h @@ -0,0 +1,92 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_TTYCHARS_H +#define _SYS_TTYCHARS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * User visible structures and constants + * related to terminal handling. + */ + +struct ttychars { + char tc_erase; /* erase last character */ + char tc_kill; /* erase entire line */ + char tc_intrc; /* interrupt */ + char tc_quitc; /* quit */ + char tc_startc; /* start output */ + char tc_stopc; /* stop output */ + char tc_eofc; /* end-of-file */ + char tc_brkc; /* input delimiter (like nl) */ + char tc_suspc; /* stop process signal */ + char tc_dsuspc; /* delayed stop process signal */ + char tc_rprntc; /* reprint line */ + char tc_flushc; /* flush output (toggles) */ + char tc_werasc; /* word erase */ + char tc_lnextc; /* literal next character */ +}; + +#ifndef _SYS_TERMIOS_H + +#define CTRL(c) ((c)&037) + +/* default BSD special characters */ +#define CERASE 0177 +#define CKILL CTRL('u') +#define CINTR CTRL('c') +#define CQUIT 034 /* FS, ^\ */ +#define CSTART CTRL('q') +#define CSTOP CTRL('s') +#define CEOF CTRL('d') +#define CEOT CEOF +#define CBRK 0377 +#define CSUSP CTRL('z') +#define CDSUSP CTRL('y') +#define CRPRNT CTRL('r') +#define CFLUSH CTRL('o') +#define CWERASE CTRL('w') +#define CLNEXT CTRL('v') +#define CSTATUS CTRL('t') + +#endif /* _SYS_TERMIOS_H */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TTYCHARS_H */ diff --git a/illumos-x86_64/usr/include/sys/ttydev.h b/illumos-x86_64/usr/include/sys/ttydev.h new file mode 100644 index 00000000..f92ac10c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ttydev.h @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_TTYDEV_H +#define _SYS_TTYDEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Terminal definitions related to underlying hardware. + */ + +/* + * Speeds + */ +#define B0 0 +#define B50 1 +#define B75 2 +#define B110 3 +#define B134 4 +#define B150 5 +#define B200 6 +#define B300 7 +#define B600 8 +#define B1200 9 +#define B1800 10 +#define B2400 11 +#define B4800 12 +#define B9600 13 +#define B19200 14 +#define B38400 15 +#define EXTA 14 +#define EXTB 15 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TTYDEV_H */ diff --git a/illumos-x86_64/usr/include/sys/tuneable.h b/illumos-x86_64/usr/include/sys/tuneable.h new file mode 100644 index 00000000..d212e50d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tuneable.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_TUNEABLE_H +#define _SYS_TUNEABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct tune { + int t_gpgslo; /* If freemem < t_getpgslow, then start */ + /* to steal pages from processes. */ + int t_pad[7]; /* Padding for driver compatibility. */ + int t_fsflushr; /* The rate at which fsflush is run in */ + /* seconds. */ + int t_minarmem; /* The minimum available resident (not */ + /* swappable) memory to maintain in */ + /* order to avoid deadlock. In pages. */ + int t_minasmem; /* The minimum available swappable */ + /* memory to maintain in order to avoid */ + /* deadlock. In pages. */ + int t_flckrec; /* max number of active frlocks */ +} tune_t; + +extern tune_t tune; + +/* + * The following is the default value for t_gpgsmsk. It cannot be + * defined in /etc/master or /stand/system due to limitations of the + * config program. + */ + +#define GETPGSMSK PG_REF|PG_NDREF + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TUNEABLE_H */ diff --git a/illumos-x86_64/usr/include/sys/turnstile.h b/illumos-x86_64/usr/include/sys/turnstile.h new file mode 100644 index 00000000..8708085f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/turnstile.h @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_TURNSTILE_H +#define _SYS_TURNSTILE_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TS_WRITER_Q 0 /* writer sleepq (exclusive access to sobj) */ +#define TS_READER_Q 1 /* reader sleepq (shared access to sobj) */ +#define TS_NUM_Q 2 /* number of sleep queues per turnstile */ + +typedef struct turnstile turnstile_t; +struct _sobj_ops; + +struct turnstile { + turnstile_t *ts_next; /* next on hash chain */ + turnstile_t *ts_free; /* next on freelist */ + void *ts_sobj; /* s-object threads are blocking on */ + int ts_waiters; /* number of blocked threads */ + pri_t ts_epri; /* max priority of blocked threads */ + struct _kthread *ts_inheritor; /* thread inheriting priority */ + turnstile_t *ts_prioinv; /* next in inheritor's t_prioinv list */ + sleepq_t ts_sleepq[TS_NUM_Q]; /* read/write sleep queues */ +}; + +#ifdef _KERNEL + +extern turnstile_t *turnstile_lookup(void *); +extern void turnstile_exit(void *); +extern int turnstile_block(turnstile_t *, int, void *, struct _sobj_ops *, + kmutex_t *, lwp_timer_t *); +extern void turnstile_wakeup(turnstile_t *, int, int, struct _kthread *); +extern void turnstile_change_pri(struct _kthread *, pri_t, pri_t *); +extern void turnstile_unsleep(struct _kthread *); +extern void turnstile_stay_asleep(struct _kthread *); +extern void turnstile_pi_recalc(void); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TURNSTILE_H */ diff --git a/illumos-x86_64/usr/include/sys/types.h b/illumos-x86_64/usr/include/sys/types.h new file mode 100644 index 00000000..a066fe99 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/types.h @@ -0,0 +1,707 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Joyent, Inc. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H + +#include +#include + +/* + * Machine dependent definitions moved to . + */ +#include + +/* + * Include fixed width type declarations proposed by the ISO/JTC1/SC22/WG14 C + * committee's working draft for the revision of the current ISO C standard, + * ISO/IEC 9899:1990 Programming language - C. These are not currently + * required by any standard but constitute a useful, general purpose set + * of type definitions which is namespace clean with respect to all standards. + */ +#if defined(_KERNEL) || defined(_BOOT) +#include +#else +#include +#endif + +#if defined(_KERNEL) || defined(_SYSCALL32) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Strictly conforming ANSI C environments prior to the 1999 + * revision of the C Standard (ISO/IEC 9899:1999) do not have + * the long long data type. + */ +#if defined(_LONGLONG_TYPE) +typedef long long longlong_t; +typedef unsigned long long u_longlong_t; +#else +/* used to reserve space and generate alignment */ +typedef union { + double _d; + int32_t _l[2]; +} longlong_t; +typedef union { + double _d; + uint32_t _l[2]; +} u_longlong_t; +#endif /* defined(_LONGLONG_TYPE) */ + +/* + * These types (t_{u}scalar_t) exist because the XTI/TPI/DLPI standards had + * to use them instead of int32_t and uint32_t because DEC had + * shipped 64-bit wide. + */ +#if defined(_LP64) +typedef int32_t t_scalar_t; +typedef uint32_t t_uscalar_t; +#else +typedef long t_scalar_t; /* historical versions */ +typedef unsigned long t_uscalar_t; +#endif /* defined(_LP64) */ + +/* + * POSIX Extensions + */ +typedef unsigned char uchar_t; +typedef unsigned short ushort_t; +typedef unsigned int uint_t; +typedef unsigned long ulong_t; + +typedef char *caddr_t; /* ? type */ +typedef long daddr_t; /* type */ +typedef short cnt_t; /* ? type */ + +#if !defined(_PTRDIFF_T) || __cplusplus >= 199711L +#define _PTRDIFF_T +#if defined(_LP64) +typedef long ptrdiff_t; /* pointer difference */ +#else +typedef int ptrdiff_t; /* (historical version) */ +#endif +#endif + +/* + * VM-related types + */ +typedef ulong_t pfn_t; /* page frame number */ +typedef ulong_t pgcnt_t; /* number of pages */ +typedef long spgcnt_t; /* signed number of pages */ + +typedef uchar_t use_t; /* use count for swap. */ +typedef short sysid_t; +typedef short index_t; +typedef void *timeout_id_t; /* opaque handle from timeout(9F) */ +typedef void *bufcall_id_t; /* opaque handle from bufcall(9F) */ + +/* + * The size of off_t and related types depends on the setting of + * _FILE_OFFSET_BITS. (Note that other system headers define other types + * related to those defined here.) + * + * If _LARGEFILE64_SOURCE is defined, variants of these types that are + * explicitly 64 bits wide become available. + */ +#ifndef _OFF_T +#define _OFF_T + +#if defined(_LP64) || _FILE_OFFSET_BITS == 32 +typedef long off_t; /* offsets within files */ +#elif _FILE_OFFSET_BITS == 64 +typedef longlong_t off_t; /* offsets within files */ +#endif + +#if defined(_LARGEFILE64_SOURCE) +#ifdef _LP64 +typedef off_t off64_t; /* offsets within files */ +#else +typedef longlong_t off64_t; /* offsets within files */ +#endif +#endif /* _LARGEFILE64_SOURCE */ + +#endif /* _OFF_T */ + +#if defined(_LP64) || _FILE_OFFSET_BITS == 32 +typedef ulong_t ino_t; /* expanded inode type */ +typedef long blkcnt_t; /* count of file blocks */ +typedef ulong_t fsblkcnt_t; /* count of file system blocks */ +typedef ulong_t fsfilcnt_t; /* count of files */ +#elif _FILE_OFFSET_BITS == 64 +typedef u_longlong_t ino_t; /* expanded inode type */ +typedef longlong_t blkcnt_t; /* count of file blocks */ +typedef u_longlong_t fsblkcnt_t; /* count of file system blocks */ +typedef u_longlong_t fsfilcnt_t; /* count of files */ +#endif + +#if defined(_LARGEFILE64_SOURCE) +#ifdef _LP64 +typedef ino_t ino64_t; /* expanded inode type */ +typedef blkcnt_t blkcnt64_t; /* count of file blocks */ +typedef fsblkcnt_t fsblkcnt64_t; /* count of file system blocks */ +typedef fsfilcnt_t fsfilcnt64_t; /* count of files */ +#else +typedef u_longlong_t ino64_t; /* expanded inode type */ +typedef longlong_t blkcnt64_t; /* count of file blocks */ +typedef u_longlong_t fsblkcnt64_t; /* count of file system blocks */ +typedef u_longlong_t fsfilcnt64_t; /* count of files */ +#endif +#endif /* _LARGEFILE64_SOURCE */ + +#ifdef _LP64 +typedef int blksize_t; /* used for block sizes */ +#else +typedef long blksize_t; /* used for block sizes */ +#endif + +/* + * The boolean_t type has had a varied amount of exposure over the years in + * terms of how its enumeration constants have been exposed. In particular, it + * originally used the __XOPEN_OR_POSIX macro to determine whether to prefix the + * B_TRUE and B_FALSE with an underscore. This check never included the + * question of if we were in a strict ANSI C environment or whether extensions + * were defined. + * + * Compilers such as clang started defaulting to always including an + * XOPEN_SOURCE declaration on behalf of users, but also noted __EXTENSIONS__. + * This would lead most software that had used the non-underscore versions to + * need it. As such, we have adjusted the non-strict XOPEN environment to retain + * its old behavior so as to minimize namespace pollution; however, we instead + * include both variants of the definitions in the generally visible version + * allowing software written in either world to hopefully end up in a good + * place. + * + * This isn't perfect, but should hopefully minimize the pain for folks actually + * trying to build software. + */ +#if defined(__XOPEN_OR_POSIX) && !defined(__EXTENSIONS__) +typedef enum { _B_FALSE, _B_TRUE } boolean_t; +#else +typedef enum { B_FALSE = 0, B_TRUE = 1, _B_FALSE = 0, _B_TRUE = 1 } boolean_t; +#endif /* __XOPEN_OR_POSIX && !__EXTENSIONS__ */ + +#ifdef _KERNEL +#define VALID_BOOLEAN(x) (((x) == B_FALSE) || ((x) == B_TRUE)) +#define VOID2BOOLEAN(x) (((uintptr_t)(x) == 0) ? B_FALSE : B_TRUE) +#endif /* _KERNEL */ + +#ifdef _KERNEL +#define BOOLEAN2VOID(x) ((x) ? 1 : 0) +#endif /* _KERNEL */ + +/* + * The {u,}pad64_t types can be used in structures such that those structures + * may be accessed by code produced by compilation environments which don't + * support a 64 bit integral datatype. The intention is not to allow + * use of these fields in such environments, but to maintain the alignment + * and offsets of the structure. + * + * Similar comments for {u,}pad128_t. + * + * Note that these types do NOT generate any stronger alignment constraints + * than those available in the underlying ABI. See + */ +#if defined(_INT64_TYPE) +typedef int64_t pad64_t; +typedef uint64_t upad64_t; +#else +typedef union { + double _d; + int32_t _l[2]; +} pad64_t; + +typedef union { + double _d; + uint32_t _l[2]; +} upad64_t; +#endif + +typedef union { + long double _q; + int32_t _l[4]; +} pad128_t; + +typedef union { + long double _q; + uint32_t _l[4]; +} upad128_t; + +typedef union { + long double _q[2]; + uint32_t _l[8]; +} upad256_t; + +typedef union { + long double _q[4]; + uint32_t _l[16]; +} upad512_t; + +typedef longlong_t offset_t; +typedef u_longlong_t u_offset_t; +typedef u_longlong_t len_t; +typedef u_longlong_t diskaddr_t; +#if (defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT)) +typedef uint64_t paddr_t; +#endif + +/* + * Definitions remaining from previous partial support for 64-bit file + * offsets. This partial support for devices greater than 2gb requires + * compiler support for long long. + */ +#ifdef _LONG_LONG_LTOH +typedef union { + offset_t _f; /* Full 64 bit offset value */ + struct { + int32_t _l; /* lower 32 bits of offset value */ + int32_t _u; /* upper 32 bits of offset value */ + } _p; +} lloff_t; +#endif + +#ifdef _LONG_LONG_HTOL +typedef union { + offset_t _f; /* Full 64 bit offset value */ + struct { + int32_t _u; /* upper 32 bits of offset value */ + int32_t _l; /* lower 32 bits of offset value */ + } _p; +} lloff_t; +#endif + +#ifdef _LONG_LONG_LTOH +typedef union { + longlong_t _f; /* Full 64 bit disk address value */ + struct { + int32_t _l; /* lower 32 bits of disk address value */ + int32_t _u; /* upper 32 bits of disk address value */ + } _p; +} lldaddr_t; +#endif + +#ifdef _LONG_LONG_HTOL +typedef union { + longlong_t _f; /* Full 64 bit disk address value */ + struct { + int32_t _u; /* upper 32 bits of disk address value */ + int32_t _l; /* lower 32 bits of disk address value */ + } _p; +} lldaddr_t; +#endif + +typedef uint_t k_fltset_t; /* kernel fault set type */ + +/* + * The following type is for various kinds of identifiers. The + * actual type must be the same for all since some system calls + * (such as sigsend) take arguments that may be any of these + * types. The enumeration type idtype_t defined in sys/procset.h + * is used to indicate what type of id is being specified -- + * a process id, process group id, session id, scheduling class id, + * user id, group id, project id, task id or zone id. + */ +#if defined(_LP64) +typedef int id_t; +#else +typedef long id_t; /* (historical version) */ +#endif + +typedef id_t lgrp_id_t; /* lgroup ID */ + +/* + * Type useconds_t is an unsigned integral type capable of storing + * values at least in the range of zero to 1,000,000. + */ +typedef uint_t useconds_t; /* Time, in microseconds */ + +#ifndef _SUSECONDS_T +#define _SUSECONDS_T +typedef long suseconds_t; /* signed # of microseconds */ +#endif /* _SUSECONDS_T */ + +/* + * Typedefs for dev_t components. + */ +#if defined(_LP64) +typedef uint_t major_t; /* major part of device number */ +typedef uint_t minor_t; /* minor part of device number */ +#else +typedef ulong_t major_t; /* (historical version) */ +typedef ulong_t minor_t; /* (historical version) */ +#endif + +/* + * The data type of a thread priority. + */ +typedef short pri_t; + +/* + * The data type for a CPU flags field. (Can be extended to larger unsigned + * types, if needed, limited by ability to update atomically.) + */ +typedef ushort_t cpu_flag_t; + +/* + * For compatibility reasons the following typedefs (prefixed o_) + * can't grow regardless of the EFT definition. Although, + * applications should not explicitly use these typedefs + * they may be included via a system header definition. + * WARNING: These typedefs may be removed in a future + * release. + * ex. the definitions in s5inode.h (now obsoleted) + * remained small to preserve compatibility + * in the S5 file system type. + */ +typedef ushort_t o_mode_t; /* old file attribute type */ +typedef short o_dev_t; /* old device type */ +typedef ushort_t o_uid_t; /* old UID type */ +typedef o_uid_t o_gid_t; /* old GID type */ +typedef short o_nlink_t; /* old file link type */ +typedef short o_pid_t; /* old process id type */ +typedef ushort_t o_ino_t; /* old inode type */ + + +/* + * POSIX and XOPEN Declarations + */ +typedef int key_t; /* IPC key type */ +#if defined(_LP64) +typedef uint_t mode_t; /* file attribute type */ +#else +typedef ulong_t mode_t; /* (historical version) */ +#endif + +#ifndef _UID_T +#define _UID_T +typedef unsigned int uid_t; /* UID type */ +#endif /* _UID_T */ + +typedef uid_t gid_t; /* GID type */ + +typedef uint32_t datalink_id_t; +typedef uint32_t vrid_t; + +typedef id_t taskid_t; +typedef id_t projid_t; +typedef id_t poolid_t; +typedef id_t zoneid_t; +typedef id_t ctid_t; + +/* + * POSIX definitions are same as defined in thread.h and synch.h. + * Any changes made to here should be reflected in corresponding + * files as described in comments. + */ +typedef uint_t pthread_t; /* = thread_t in thread.h */ +typedef uint_t pthread_key_t; /* = thread_key_t in thread.h */ + +/* "Magic numbers" tagging synchronization object types */ +#define _MUTEX_MAGIC 0x4d58 /* "MX" */ +#define _SEMA_MAGIC 0x534d /* "SM" */ +#define _COND_MAGIC 0x4356 /* "CV" */ +#define _RWL_MAGIC 0x5257 /* "RW" */ + +typedef struct _pthread_mutex { /* = mutex_t in synch.h */ + struct { + uint16_t __pthread_mutex_flag1; + uint8_t __pthread_mutex_flag2; + uint8_t __pthread_mutex_ceiling; + uint16_t __pthread_mutex_type; + uint16_t __pthread_mutex_magic; + } __pthread_mutex_flags; + union { + struct { + uint8_t __pthread_mutex_pad[8]; + } __pthread_mutex_lock64; + struct { + uint32_t __pthread_ownerpid; + uint32_t __pthread_lockword; + } __pthread_mutex_lock32; + upad64_t __pthread_mutex_owner64; + } __pthread_mutex_lock; + upad64_t __pthread_mutex_data; +} pthread_mutex_t; + +typedef struct _pthread_cond { /* = cond_t in synch.h */ + struct { + uint8_t __pthread_cond_flag[4]; + uint16_t __pthread_cond_type; + uint16_t __pthread_cond_magic; + } __pthread_cond_flags; + upad64_t __pthread_cond_data; +} pthread_cond_t; + +/* + * UNIX 98 Extension + */ +typedef struct _pthread_rwlock { /* = rwlock_t in synch.h */ + int32_t __pthread_rwlock_readers; + uint16_t __pthread_rwlock_type; + uint16_t __pthread_rwlock_magic; + pthread_mutex_t __pthread_rwlock_mutex; + pthread_cond_t __pthread_rwlock_readercv; + pthread_cond_t __pthread_rwlock_writercv; +} pthread_rwlock_t; + +/* + * SUSV3 + */ +typedef struct { + uint32_t __pthread_barrier_count; + uint32_t __pthread_barrier_current; + upad64_t __pthread_barrier_cycle; + upad64_t __pthread_barrier_reserved; + pthread_mutex_t __pthread_barrier_lock; + pthread_cond_t __pthread_barrier_cond; +} pthread_barrier_t; + +typedef pthread_mutex_t pthread_spinlock_t; + +/* + * attributes for threads, dynamically allocated by library + */ +typedef struct _pthread_attr { + void *__pthread_attrp; +} pthread_attr_t; + +/* + * attributes for mutex, dynamically allocated by library + */ +typedef struct _pthread_mutexattr { + void *__pthread_mutexattrp; +} pthread_mutexattr_t; + +/* + * attributes for cond, dynamically allocated by library + */ +typedef struct _pthread_condattr { + void *__pthread_condattrp; +} pthread_condattr_t; + +/* + * pthread_once + */ +typedef struct _once { + upad64_t __pthread_once_pad[4]; +} pthread_once_t; + +/* + * UNIX 98 Extensions + * attributes for rwlock, dynamically allocated by library + */ +typedef struct _pthread_rwlockattr { + void *__pthread_rwlockattrp; +} pthread_rwlockattr_t; + +/* + * SUSV3 + * attributes for pthread_barrier_t, dynamically allocated by library + */ +typedef struct { + void *__pthread_barrierattrp; +} pthread_barrierattr_t; + +typedef ulong_t dev_t; /* expanded device type */ + +#if defined(_LP64) +typedef uint_t nlink_t; /* file link type */ +typedef int pid_t; /* process id type */ +#else +typedef ulong_t nlink_t; /* (historical version) */ +typedef long pid_t; /* (historical version) */ +#endif + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef ulong_t size_t; /* size of something in bytes */ +#else +typedef uint_t size_t; /* (historical version) */ +#endif +#endif /* _SIZE_T */ + +#ifndef _SSIZE_T +#define _SSIZE_T +#if defined(_LP64) +typedef long ssize_t; /* size of something in bytes or -1 */ +#else +typedef int ssize_t; /* (historical version) */ +#endif +#endif /* _SSIZE_T */ + +#if !defined(_TIME_T) || __cplusplus >= 199711L +#define _TIME_T +typedef long time_t; /* time of day in seconds */ +#endif /* _TIME_T */ + +#if !defined(_CLOCK_T) || __cplusplus >= 199711L +#define _CLOCK_T +typedef long clock_t; /* relative time in a specified resolution */ +#endif /* ifndef _CLOCK_T */ + +#ifndef _CLOCKID_T +#define _CLOCKID_T +typedef int clockid_t; /* clock identifier type */ +#endif /* ifndef _CLOCKID_T */ + +#ifndef _TIMER_T +#define _TIMER_T +typedef int timer_t; /* timer identifier type */ +#endif /* ifndef _TIMER_T */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) + +/* BEGIN CSTYLED */ +typedef unsigned char unchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; +/* END CSTYLED */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +#define CHAR_BIT 8 /* max # of bits in a "char" */ +#define SCHAR_MIN (-128) /* min value of a "signed char" */ +#define SCHAR_MAX 127 /* max value of a "signed char" */ +#define UCHAR_MAX 255 /* max value of an "unsigned char" */ + +#if defined(_CHAR_IS_SIGNED) +#define CHAR_MIN SCHAR_MIN /* min value of a "char" */ +#define CHAR_MAX SCHAR_MAX /* max value of a "char" */ +#elif defined(_CHAR_IS_UNSIGNED) +#define CHAR_MIN 0 /* min value of a "char" */ +#define CHAR_MAX UCHAR_MAX /* max value of a "char" */ +#else +#error "chars are signed or unsigned" +#endif + +#define SHRT_MIN (-32768) /* min value of a "short int" */ +#define SHRT_MAX 32767 /* max value of a "short int" */ +#define USHRT_MAX 65535 /* max of "unsigned short int" */ +#define INT_MIN (-2147483647-1) /* min value of an "int" */ +#define INT_MAX 2147483647 /* max value of an "int" */ +#define UINT_MAX 4294967295U /* max value of an "unsigned int" */ +#if defined(_LP64) +#define LONG_MIN (-9223372036854775807L-1L) + /* min value of a "long int" */ +#define LONG_MAX 9223372036854775807L + /* max value of a "long int" */ +#define ULONG_MAX 18446744073709551615UL + /* max of "unsigned long int" */ +#else /* _ILP32 */ +#define LONG_MIN (-2147483647L-1L) + /* min value of a "long int" */ +#define LONG_MAX 2147483647L /* max value of a "long int" */ +#define ULONG_MAX 4294967295UL /* max of "unsigned long int" */ +#endif + +#define LLONG_MIN (-9223372036854775807LL-1LL) + /* min of "long long int" */ +#define LLONG_MAX 9223372036854775807LL + /* max of "long long int" */ +#define ULLONG_MAX 18446744073709551615ULL + /* max of "unsigned long long int" */ + +#if defined(_LP64) || _FILE_OFFSET_BITS == 32 +#define OFF_MIN LONG_MIN +#define OFF_MAX LONG_MAX +#elif _FILE_OFFSET_BITS == 64 +#define OFF_MIN LLONG_MIN +#define OFF_MAX LLONG_MAX +#endif /* _LP64 || _FILE_OFFSET_BITS == 32 */ + +#endif /* defined(_KERNEL) */ + +#define P_MYPID ((pid_t)0) + +/* + * The following is the value of type id_t to use to indicate the + * caller's current id. See procset.h for the type idtype_t + * which defines which kind of id is being specified. + */ +#define P_MYID (-1) +#define NOPID (pid_t)(-1) + +#ifndef NODEV +#define NODEV (dev_t)(-1l) +#ifdef _SYSCALL32 +#define NODEV32 (dev32_t)(-1) +#endif /* _SYSCALL32 */ +#endif /* NODEV */ + +/* + * The following value of type pfn_t is used to indicate + * invalid page frame number. + */ +#define PFN_INVALID ((pfn_t)-1) +#define PFN_SUSPENDED ((pfn_t)-2) + +/* BEGIN CSTYLED */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef struct _quad { int val[2]; } quad_t; /* used by UFS */ +typedef quad_t quad; /* used by UFS */ +/* END CSTYLED */ + +/* + * Nested include for BSD/sockets source compatibility. + * (The select macros used to be defined here). + */ +#include + +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* + * _VOID was defined to be either void or char but this is not + * required because previous SunOS compilers have accepted the void + * type. However, because many system header and source files use the + * void keyword, the volatile keyword, and ANSI C function prototypes, + * non-ANSI compilers cannot compile the system anyway. The _VOID macro + * should therefore not be used and remains for source compatibility + * only. + */ +/* CSTYLED */ +#define _VOID void + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TYPES_H */ diff --git a/illumos-x86_64/usr/include/sys/types32.h b/illumos-x86_64/usr/include/sys/types32.h new file mode 100644 index 00000000..d1c6ae9f --- /dev/null +++ b/illumos-x86_64/usr/include/sys/types32.h @@ -0,0 +1,92 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Nexenta Systems, Inc. + */ + +#ifndef _SYS_TYPES32_H +#define _SYS_TYPES32_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Interoperability types for programs. Used for: + * + * Crossing between 32-bit and 64-bit domains. + * + * On disk data formats such as filesystem meta data + * and disk label. + * + * Note: Applications should never include this + * header file. + */ +typedef uint32_t caddr32_t; +typedef int32_t daddr32_t; +typedef int32_t off32_t; +typedef uint32_t ino32_t; +typedef int32_t blkcnt32_t; +typedef uint32_t fsblkcnt32_t; +typedef uint32_t fsfilcnt32_t; +typedef int32_t id32_t; +typedef uint32_t major32_t; +typedef uint32_t minor32_t; +typedef int32_t key32_t; +typedef uint32_t mode32_t; +typedef uint32_t uid32_t; +typedef uint32_t gid32_t; +typedef uint32_t nlink32_t; +typedef uint32_t dev32_t; +typedef int32_t pid32_t; +typedef uint32_t size32_t; +typedef int32_t ssize32_t; +typedef int32_t time32_t; +typedef int32_t clock32_t; +typedef uint32_t uintptr32_t; +typedef int32_t intptr32_t; + +struct timeval32 { + time32_t tv_sec; /* seconds */ + int32_t tv_usec; /* and microseconds */ +}; + +typedef struct timespec32 { + time32_t tv_sec; /* seconds */ + int32_t tv_nsec; /* and nanoseconds */ +} timespec32_t; + +typedef struct timespec32 timestruc32_t; + +typedef struct itimerspec32 { + struct timespec32 it_interval; + struct timespec32 it_value; +} itimerspec32_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TYPES32_H */ diff --git a/illumos-x86_64/usr/include/sys/tzfile.h b/illumos-x86_64/usr/include/sys/tzfile.h new file mode 100644 index 00000000..912a00a9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/tzfile.h @@ -0,0 +1,164 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * from Arthur Olson's 6.1 + */ + +#ifndef _SYS_TZFILE_H +#define _SYS_TZFILE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Information about time zone files. + */ + +#define TZDIR "/usr/share/lib/zoneinfo" /* Time zone object file directory */ + +#define TZDEFAULT (getenv("TZ")) + +#define TZDEFRULES "posixrules" + +/* + * Each file begins with. . . + */ + +struct tzhead { + char tzh_reserved[24]; /* reserved for future use */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ +}; + +/* + * . . .followed by. . . + * + * tzh_timecnt (char [4])s coded transition times a la time(2) + * tzh_timecnt (unsigned char)s types of local time starting at above + * tzh_typecnt repetitions of + * one (char [4]) coded GMT offset in seconds + * one (unsigned char) used to set tm_isdst + * one (unsigned char) that's an abbreviation list index + * tzh_charcnt (char)s '\0'-terminated zone abbreviations + * tzh_leapcnt repetitions of + * one (char [4]) coded leap second transition times + * one (char [4]) total correction after above + * tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition + * time is standard time, if FALSE, + * transition time is wall clock time + * if absent, transition times are + * assumed to be wall clock time + */ + +/* + * In the current implementation, "tzset()" refuses to deal with files that + * exceed any of the limits below. + */ + +/* + * The TZ_MAX_TIMES value below is enough to handle a bit more than a + * year's worth of solar time (corrected daily to the nearest second) or + * 138 years of Pacific Presidential Election time + * (where there are three time zone transitions every fourth year). + */ +#define TZ_MAX_TIMES 370 + +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ + +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long)SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +/* + * Accurate only for the past couple of centuries; + * that will probably do. + */ + +#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) + +/* + * Use of the underscored variants may cause problems if you move your code to + * certain System-V-based systems; for maximum portability, use the + * underscore-free variants. The underscored variants are provided for + * backward compatibility only; they may disappear from future versions of + * this file. + */ + +#define SECS_PER_MIN SECSPERMIN +#define MINS_PER_HOUR MINSPERHOUR +#define HOURS_PER_DAY HOURSPERDAY +#define DAYS_PER_WEEK DAYSPERWEEK +#define DAYS_PER_NYEAR DAYSPERNYEAR +#define DAYS_PER_LYEAR DAYSPERLYEAR +#define SECS_PER_HOUR SECSPERHOUR +#define SECS_PER_DAY SECSPERDAY +#define MONS_PER_YEAR MONSPERYEAR + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TZFILE_H */ diff --git a/illumos-x86_64/usr/include/sys/u8_textprep.h b/illumos-x86_64/usr/include/sys/u8_textprep.h new file mode 100644 index 00000000..acbcdb03 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/u8_textprep.h @@ -0,0 +1,111 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_U8_TEXTPREP_H +#define _SYS_U8_TEXTPREP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Unicode encoding conversion functions and their macros. + */ +#define UCONV_IN_BIG_ENDIAN 0x0001 +#define UCONV_OUT_BIG_ENDIAN 0x0002 +#define UCONV_IN_SYSTEM_ENDIAN 0x0004 +#define UCONV_OUT_SYSTEM_ENDIAN 0x0008 +#define UCONV_IN_LITTLE_ENDIAN 0x0010 +#define UCONV_OUT_LITTLE_ENDIAN 0x0020 +#define UCONV_IGNORE_NULL 0x0040 +#define UCONV_IN_ACCEPT_BOM 0x0080 +#define UCONV_OUT_EMIT_BOM 0x0100 + +extern int uconv_u16tou32(const uint16_t *, size_t *, uint32_t *, size_t *, + int); +extern int uconv_u16tou8(const uint16_t *, size_t *, uchar_t *, size_t *, int); +extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *, + int); +extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int); +extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int); +extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int); + +/* + * UTF-8 text preparation functions and their macros. + * + * Among the macros defined, U8_CANON_DECOMP, U8_COMPAT_DECOMP, and + * U8_CANON_COMP are not public interfaces and must not be used directly + * at the flag input argument. + */ +#define U8_STRCMP_CS (0x00000001) +#define U8_STRCMP_CI_UPPER (0x00000002) +#define U8_STRCMP_CI_LOWER (0x00000004) + +#define U8_CANON_DECOMP (0x00000010) +#define U8_COMPAT_DECOMP (0x00000020) +#define U8_CANON_COMP (0x00000040) + +#define U8_STRCMP_NFD (U8_CANON_DECOMP) +#define U8_STRCMP_NFC (U8_CANON_DECOMP | U8_CANON_COMP) +#define U8_STRCMP_NFKD (U8_COMPAT_DECOMP) +#define U8_STRCMP_NFKC (U8_COMPAT_DECOMP | U8_CANON_COMP) + +#define U8_TEXTPREP_TOUPPER (U8_STRCMP_CI_UPPER) +#define U8_TEXTPREP_TOLOWER (U8_STRCMP_CI_LOWER) + +#define U8_TEXTPREP_NFD (U8_STRCMP_NFD) +#define U8_TEXTPREP_NFC (U8_STRCMP_NFC) +#define U8_TEXTPREP_NFKD (U8_STRCMP_NFKD) +#define U8_TEXTPREP_NFKC (U8_STRCMP_NFKC) + +#define U8_TEXTPREP_IGNORE_NULL (0x00010000) +#define U8_TEXTPREP_IGNORE_INVALID (0x00020000) +#define U8_TEXTPREP_NOWAIT (0x00040000) + +#define U8_UNICODE_320 (0) +#define U8_UNICODE_500 (1) +#define U8_UNICODE_LATEST (U8_UNICODE_500) + +#define U8_VALIDATE_ENTIRE (0x00100000) +#define U8_VALIDATE_CHECK_ADDITIONAL (0x00200000) +#define U8_VALIDATE_UCS2_RANGE (0x00400000) + +#define U8_ILLEGAL_CHAR (-1) +#define U8_OUT_OF_RANGE_CHAR (-2) + +extern int u8_validate(char *, size_t, char **, int, int *); +extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *); +extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t, + int *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_U8_TEXTPREP_H */ diff --git a/illumos-x86_64/usr/include/sys/uadmin.h b/illumos-x86_64/usr/include/sys/uadmin.h new file mode 100644 index 00000000..904b52ca --- /dev/null +++ b/illumos-x86_64/usr/include/sys/uadmin.h @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_UADMIN_H +#define _SYS_UADMIN_H + + +#if !defined(_ASM) +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define A_REBOOT 1 +#define A_SHUTDOWN 2 +#define A_FREEZE 3 /* For freeze and thaw */ +#define A_REMOUNT 4 +#define A_DUMP 5 +#define A_FTRACE 15 +#define A_SWAPCTL 16 +/* 17-21 reserved for obsolete interface */ +#define A_SDTTEST 22 /* DTrace sdt:::test */ +#define A_CONFIG 23 /* For system configuration */ + +#define AD_UNKNOWN -1 /* no method */ +#define AD_HALT 0 /* halt the processor */ +#define AD_BOOT 1 /* multi-user reboot */ +#define AD_IBOOT 2 /* multi-user reboot, ask for name of file */ +#define AD_SBOOT 3 /* single-user reboot */ +#define AD_SIBOOT 4 /* single-user reboot, ask for name of file */ +#define AD_POWEROFF 6 /* software poweroff */ +#define AD_NOSYNC 7 /* do not sync filesystems on next A_DUMP */ +#define AD_FASTREBOOT 8 /* bypass firmware and boot loader */ +#define AD_FASTREBOOT_DRYRUN 9 /* Fast reboot Dry run */ + +/* + * Functions reserved for A_FREEZE (may not be available on all platforms) + * Note: AD_COMPRESS, AD_CHECK and AD_FORCE are now obsolete + * The first two are succeeded by AD_SUSPEND_TO_DISK and + * AD_CHECK_SUSPEND_TO_DISK respectively. + * AD_FORCE should not be used by any new application + * + * We maintain compatibility with the earlier interfaces: + * AD_COMPRESS and AD_CHECK, by preserving those values + * in the corresponding new interfaces + */ + +#define AD_COMPRESS 0 /* store state file compressed during CPR */ +#define AD_FORCE 1 /* force to do AD_COMPRESS */ +#define AD_CHECK 2 /* test if CPR module is available */ +#define AD_SUSPEND_TO_DISK AD_COMPRESS /* A_FREEZE, CPR or ACPI S4 */ +#define AD_CHECK_SUSPEND_TO_DISK AD_CHECK /* A_FREEZE, CPR/S4 capable? */ +#define AD_SUSPEND_TO_RAM 20 /* A_FREEZE, S3 */ +#define AD_CHECK_SUSPEND_TO_RAM 21 /* A_FREEZE, S3 capable? */ + +/* + * NOTE: the following defines comprise an Unstable interface. Their semantics + * may change or they may be removed completely in a later release + */ +#define AD_REUSEINIT 3 /* prepare for AD_REUSABLE */ +#define AD_REUSABLE 4 /* create reusable statefile */ +#define AD_REUSEFINI 5 /* revert to normal CPR mode (not reusable) */ + +#define AD_FTRACE_START 1 +#define AD_FTRACE_STOP 2 + +/* + * Functions of A_CONFIG. Unstable interface. + */ +#define AD_UPDATE_BOOT_CONFIG 1 /* Update boot config variables */ + +/* + * When 'mdep' (the second argument to uadmin(2)) is initialized for A_REBOOT, + * A_SHUTDOWN or A_DUMP, it represents the boot arguments string of at most + * 256 characters. + */ +#define BOOTARGS_MAX 256 + +#if !defined(_KERNEL) +/* + * FMRI for boot-config service. + */ +#define FMRI_BOOT_CONFIG \ + "svc:/system/boot-config:default" + +/* + * Property group that contains all Fast Reboot configuration properties. + */ +#define BOOT_CONFIG_PG_PARAMS "config" + +/* + * Property group that contains all Fast Reboot blacklisting information. + */ +#define BOOT_CONFIG_PG_FBBLACKLIST "fastreboot_blacklist" + +/* + * Non-persistent property group which contains all the properties that + * will override settings in the BOOT_CONFIG_PG_PARAMS property group. + */ +#define BOOT_CONFIG_PG_OVR "config_ovr" + +#endif /* _KERNEL */ + +/* + * Flag representations of fastboot configuration. + */ +#define UA_FASTREBOOT_DEFAULT 0x01 +#define UA_FASTREBOOT_ONPANIC 0x02 + +#define FASTREBOOT_DEFAULT "fastreboot_default" +#define FASTREBOOT_ONPANIC "fastreboot_onpanic" +#define FASTREBOOT_ONPANIC_CMDLINE "fastreboot_onpanic_cmdline" + +#define FASTREBOOT_ONPANIC_NOTSET(p) \ + (strcmp((p), "false") == 0 || \ + strcmp((p), "no") == 0 || \ + strcmp((p), "0") == 0) + +#define FASTREBOOT_ONPANIC_ISSET(p) \ + (strcmp((p), "true") == 0 || \ + strcmp((p), "yes") == 0 || \ + strcmp((p), "1") == 0) + +#if !defined(_ASM) + +#if defined(_KERNEL) +extern kmutex_t ualock; +extern void mdboot(int, int, char *, boolean_t); +extern void mdpreboot(int, int, char *); +extern int kadmin(int, int, void *, cred_t *); +extern void killall(zoneid_t); +#endif + +extern int uadmin(int, int, uintptr_t); + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UADMIN_H */ diff --git a/illumos-x86_64/usr/include/sys/ucode.h b/illumos-x86_64/usr/include/sys/ucode.h new file mode 100644 index 00000000..045cd1a2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ucode.h @@ -0,0 +1,164 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Joyent, Inc. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_UCODE_H +#define _SYS_UCODE_H + +#ifdef _KERNEL +#include +#include +#endif +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * /dev/ucode + */ +#define UCODE_DRIVER_NAME "ucode" +#define UCODE_NODE_NAME "ucode" +#define UCODE_MINOR ((minor_t)0x3fffful) + +/* + * ioctl numbers + */ +#define UCODE_IOC (('u'<<24)|('c'<<16)|('o'<<8)) + +#define UCODE_GET_VERSION (UCODE_IOC|0) +#define UCODE_UPDATE (UCODE_IOC|1) + +struct ucode_get_rev_struct { + uint32_t *ugv_rev; /* microcode revision array */ + int ugv_size; /* size of the array */ + ucode_errno_t ugv_errno; /* EUC error code */ +}; + +struct ucode_write_struct { + uint32_t uw_size; /* size of the uw_code buffer */ + uint8_t *uw_ucode; /* pointer to the undigested microcode */ + ucode_errno_t uw_errno; /* EUC error code */ +}; + +#if defined(_SYSCALL32_IMPL) + +#include + +struct ucode_get_rev_struct32 { + caddr32_t ugv_rev; /* microcode revision array */ + int ugv_size; /* size of the array */ + ucode_errno_t ugv_errno; /* EUC error code */ +}; + +struct ucode_write_struct32 { + uint32_t uw_size; /* size of the uw_code buffer */ + caddr32_t uw_ucode; /* pointer to the undigested microcode */ + ucode_errno_t uw_errno; /* EUC error code */ +}; + +#endif /* _SYSCALL32_IMPL */ + +#define UCODE_KB(a) ((a) << 10) /* KiB */ +#define UCODE_MB(a) ((a) << 20) /* MiB */ + +/* + * For a single microcode file, the following minimum and maximum sizes are + * defined. Such limitations, while somewhat artificial, are not only to + * provide better sanity checks, but also avoid wasting precious memory at + * startup time as the microcode buffer for the first processor has to be + * statically allocated. + * + * The last limit is for the concatenation of all the microcode binary files. + */ +#define UCODE_MIN_SIZE UCODE_KB(1) +#define UCODE_MAX_SIZE UCODE_MB(2) +#define UCODE_MAX_COMBINED_SIZE UCODE_MB(16) + +#ifdef _KERNEL + +extern ucode_errno_t ucode_get_rev(uint32_t *); +extern ucode_errno_t ucode_validate(uint8_t *, size_t); +extern ucode_errno_t ucode_update(uint8_t *, size_t); + +/* + * Microcode specific information per core + */ +typedef struct cpu_ucode_info { + uint32_t cui_platid; /* platform id */ + uint32_t cui_rev; /* microcode revision */ + uint32_t cui_pending_rev; /* pending microcode revision */ + void *cui_pending_ucode; /* pending microcode update */ + size_t cui_pending_size; /* pending microcode size */ +} cpu_ucode_info_t; + +/* + * Data structure used for xcall + */ +typedef struct ucode_update { + uint32_t sig; /* signature */ + cpu_ucode_info_t info; /* ucode info */ + uint32_t expected_rev; + uint32_t new_rev; + uint8_t *ucodep; /* pointer to ucode */ + uint32_t usize; +} ucode_update_t; + +/* + * To register a microcode update method, a ucode_source_t instance should be + * created and passed to UCODE_SOURCE() to include it in the list of sources + * that are tried. + */ +typedef struct ucode_source { + const char *us_name; + uint32_t us_write_msr; + bool us_invalidate; + bool (*us_select)(cpu_t *); + bool (*us_capable)(cpu_t *); + void (*us_file_reset)(void); + void (*us_read_rev)(cpu_ucode_info_t *); + void (*us_load)(cpu_ucode_info_t *); + ucode_errno_t (*us_validate)(uint8_t *, size_t); + ucode_errno_t (*us_extract)(ucode_update_t *, uint8_t *, size_t); + ucode_errno_t (*us_locate)(cpu_t *, cpu_ucode_info_t *); + ucode_errno_t (*us_locate_fallback)(cpu_t *, cpu_ucode_info_t *); +} ucode_source_t; +#define UCODE_SOURCE(x) DATA_SET(ucode_source_set, x) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UCODE_H */ diff --git a/illumos-x86_64/usr/include/sys/ucode_amd.h b/illumos-x86_64/usr/include/sys/ucode_amd.h new file mode 100644 index 00000000..5e470aed --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ucode_amd.h @@ -0,0 +1,110 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Joyent, Inc. + * Copyright 2025 Oxide Computer Company + */ + +#ifndef _SYS_UCODE_AMD_H +#define _SYS_UCODE_AMD_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * AMD microcode is generally distributed in container files which start with a + * magic number and then contain multiple TLV-encoded sections. Typically such + * a file will contain an equivalence table section followed by one or more + * patches. + */ +#define UCODE_AMD_CONTAINER_MAGIC 0x00414d44 /* "AMD\0" */ +#define UCODE_AMD_CONTAINER_TYPE_EQUIV 0 +#define UCODE_AMD_CONTAINER_TYPE_PATCH 1 + +typedef struct ucode_section_amd { + uint32_t usa_type; + uint32_t usa_size; + uint8_t usa_data[]; +} ucode_section_amd_t; + +CTASSERT(sizeof (ucode_section_amd_t) == 8); +CTASSERT(offsetof(ucode_section_amd_t, usa_data) == 8); + +/* + * AMD Microcode file information + */ +typedef struct ucode_header_amd { + uint32_t uh_date; + uint32_t uh_patch_id; + uint32_t uh_internal; /* patch data id & length, init flag */ + uint32_t uh_cksum; + uint32_t uh_nb_id; + uint32_t uh_sb_id; + uint16_t uh_cpu_rev; + uint8_t uh_nb_rev; + uint8_t uh_sb_rev; + uint32_t uh_bios_rev; + uint32_t uh_match[8]; +} ucode_header_amd_t; + +/* + * This is the maximum size of a microcode blob that we are prepared to load + * in the kernel. AMD Turin microcode files are 14KiB and the size has been + * increasing with each generation. This value provides some margin for the + * future. + */ +#define UCODE_AMD_MAXSIZE (256 * 1024) + +typedef struct ucode_file_amd { + ucode_header_amd_t uf_header; + uint8_t uf_data[896]; + uint8_t uf_resv[896]; + uint8_t uf_code_present; + uint8_t uf_code[191]; + uint8_t uf_encr[]; +} ucode_file_amd_t; + +typedef struct ucode_eqtbl_amd { + uint32_t ue_inst_cpu; + uint32_t ue_fixed_mask; + uint32_t ue_fixed_comp; + uint16_t ue_equiv_cpu; + uint16_t ue_reserved; +} ucode_eqtbl_amd_t; + +#define UCODE_AMD_EQUIVALENCE_TABLE_NAME "equivalence-table" +#define UCODE_MAX_NAME_LEN_AMD (sizeof (UCODE_AMD_EQUIVALENCE_TABLE_NAME)) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UCODE_AMD_H */ diff --git a/illumos-x86_64/usr/include/sys/ucode_intel.h b/illumos-x86_64/usr/include/sys/ucode_intel.h new file mode 100644 index 00000000..95db4d15 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ucode_intel.h @@ -0,0 +1,102 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Joyent, Inc. + * Copyright 2023 Oxide Computer Company + */ + +#ifndef _SYS_UCODE_INTEL_H +#define _SYS_UCODE_INTEL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Intel Microcode file information + */ +typedef struct ucode_header_intel { + uint32_t uh_header_ver; + uint32_t uh_rev; + uint32_t uh_date; + uint32_t uh_signature; + uint32_t uh_checksum; + uint32_t uh_loader_ver; + uint32_t uh_proc_flags; + uint32_t uh_body_size; + uint32_t uh_total_size; + uint32_t uh_reserved[3]; +} ucode_header_intel_t; + +typedef struct ucode_ext_sig_intel { + uint32_t ues_signature; + uint32_t ues_proc_flags; + uint32_t ues_checksum; +} ucode_ext_sig_intel_t; + +typedef struct ucode_ext_table_intel { + uint32_t uet_count; + uint32_t uet_checksum; + uint32_t uet_reserved[3]; + ucode_ext_sig_intel_t uet_ext_sig[1]; +} ucode_ext_table_intel_t; + +typedef struct ucode_file_intel { + ucode_header_intel_t *uf_header; + uint8_t *uf_body; + ucode_ext_table_intel_t *uf_ext_table; +} ucode_file_intel_t; + +/* "32-bit-sig"-"8-bit-platid"\0 */ +#define UCODE_MAX_NAME_LEN_INTEL (sizeof ("XXXXXXXX-XX")) + +#define UCODE_HEADER_SIZE_INTEL (sizeof (struct ucode_header_intel)) +#define UCODE_EXT_TABLE_SIZE_INTEL (20) /* 20-bytes */ +#define UCODE_EXT_SIG_SIZE_INTEL (sizeof (struct ucode_ext_sig_intel)) + +#define UCODE_DEFAULT_TOTAL_SIZE UCODE_KB(2) +#define UCODE_DEFAULT_BODY_SIZE (UCODE_KB(2) - UCODE_HEADER_SIZE_INTEL) + +#define UCODE_SIZE_CONVERT(size, default_size) \ + ((size) == 0 ? (default_size) : (size)) + +#define UCODE_BODY_SIZE_INTEL(size) \ + UCODE_SIZE_CONVERT((size), UCODE_DEFAULT_BODY_SIZE) + +#define UCODE_TOTAL_SIZE_INTEL(size) \ + UCODE_SIZE_CONVERT((size), UCODE_DEFAULT_TOTAL_SIZE) + +#define UCODE_MATCH_INTEL(sig1, sig2, pf1, pf2) \ + (((sig1) == (sig2)) && \ + (((pf1) & (pf2)) || (((pf1) == 0) && ((pf2) == 0)))) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UCODE_INTEL_H */ diff --git a/illumos-x86_64/usr/include/sys/ucontext.h b/illumos-x86_64/usr/include/sys/ucontext.h new file mode 100644 index 00000000..71157152 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ucontext.h @@ -0,0 +1,207 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2015 Joyent, Inc. + * Copyright 2023 Oxide Computer Company + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_UCONTEXT_H +#define _SYS_UCONTEXT_H + +#include + +#include +#include +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Inclusion of for sigset_t and stack_t definitions + * breaks XPG4v2 namespace. Therefore we must duplicate the defines + * for these types here when _XPG4_2 is defined. + */ + +#if defined(_XPG4_2) && !defined(__EXTENSIONS__) +#ifndef _SIGSET_T +#define _SIGSET_T +typedef struct { /* signal set type */ + unsigned long __sigbits[4]; +} sigset_t; +#endif /* _SIGSET_T */ + +#ifndef _STACK_T +#define _STACK_T +typedef struct { + void *ss_sp; + size_t ss_size; + int ss_flags; +} stack_t; +#endif /* _STACK_T */ +#endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +typedef struct ucontext ucontext_t; +#else +typedef struct __ucontext ucontext_t; +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +struct ucontext { +#else +struct __ucontext { +#endif + unsigned long uc_flags; + ucontext_t *uc_link; + sigset_t uc_sigmask; + stack_t uc_stack; + mcontext_t uc_mcontext; + /* + * The first three entries have been borrowed by the lx brand right now. + * That should be consolidated into a single uc_brand entry with a + * UC_BRAND flag. Until such time, to help folks downstream who have the + * lx brand, we leave them as is. + */ + void *uc_brand_data[3]; /* Was uc_filler[3] */ + long uc_xsave; + long uc_filler1; +}; + +/* + * We deviate from upstream-gate here in that we use what was uc_filler[3] for + * brand data. In order to reduce changes elsewhere in code that computes the + * offset of uc_filler, we provide the following definition. + */ +#define uc_filler uc_brand_data + +#if defined(_SYSCALL32) + +/* Kernel view of user ILP32 ucontext structure */ + +typedef struct ucontext32 { + uint32_t uc_flags; + caddr32_t uc_link; + sigset_t uc_sigmask; + stack32_t uc_stack; + mcontext32_t uc_mcontext; + caddr32_t uc_brand_data[3]; + int32_t uc_xsave; + int32_t uc_filler1; +} ucontext32_t; + +#if defined(_KERNEL) +extern void ucontext_nto32(const ucontext_t *src, ucontext32_t *dest); +extern void ucontext_32ton(const ucontext32_t *src, ucontext_t *dest); +#endif + +#endif /* _SYSCALL32 */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define GETCONTEXT 0 +#define SETCONTEXT 1 +#define GETUSTACK 2 +#define SETUSTACK 3 +#define GETCONTEXT_EXTD 4 + +/* + * values for uc_flags + * these are implementation dependent flags, that should be hidden + * from the user interface, defining which elements of ucontext + * are valid, and should be restored on call to setcontext + */ + +#define UC_SIGMASK 0x01 +#define UC_STACK 0x02 +#define UC_CPU 0x04 +#define UC_MAU 0x08 +#define UC_FPU UC_MAU +#define UC_XSAVE 0x10 + +#define UC_MCONTEXT (UC_CPU|UC_FPU) + +/* + * UC_ALL specifies the default context + */ + +#define UC_ALL (UC_SIGMASK|UC_STACK|UC_MCONTEXT) +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef _KERNEL +/* + * This structure is the private header for the xsave data that we end up + * sending to the stack. This is basically our own compressed form. See, + * uts/intel/os/fpu.c for more information. To help maintain the private nature, + * this is unfortunately duplicated in the xsave tests. If you change this you + * must update test/os-tests/tests/xsave/xsave_util.h. + */ +#define UC_XSAVE_VERS (('u' << 24) | ('c' << 16) | 0x01) +typedef struct uc_xsave { + uint32_t ucx_vers; + uint32_t ucx_len; + uint64_t ucx_bv; +} uc_xsave_t; + +typedef enum { + /* + * Do a boring old savecontext() where we assume that only the data + * structure that we're given must be filled in. + */ + SAVECTXT_F_NONE = 0, + /* + * Indicate that we should treat the ucontext_t as having valid user + * pointers for copying out extended state. Currently this means that we + * treat the uc_xsave member as something that points to a user address. + */ + SAVECTXT_F_EXTD = 1 << 0, + /* + * This indicates that we shouldn't do normal copyout handling and need + * to actually avoid potentially triggering a watchpoint because we're + * probably in signal handling context. + */ + SAVECTXT_F_ONFAULT = 1 << 1 +} savecontext_flags_t; + +int savecontext(ucontext_t *, const k_sigset_t *, savecontext_flags_t); +void restorecontext(ucontext_t *); + +#ifdef _SYSCALL32 +extern int savecontext32(ucontext32_t *, const k_sigset_t *, + savecontext_flags_t); +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UCONTEXT_H */ diff --git a/illumos-x86_64/usr/include/sys/uio.h b/illumos-x86_64/usr/include/sys/uio.h new file mode 100644 index 00000000..9584be55 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/uio.h @@ -0,0 +1,315 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_UIO_H +#define _SYS_UIO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * I/O parameter information. A uio structure describes the I/O which + * is to be performed by an operation. Typically the data movement will + * be performed by a routine such as uiomove(), which updates the uio + * structure to reflect what was done. + */ + +#if defined(_XPG4_2) +typedef struct iovec { + void *iov_base; + size_t iov_len; +} iovec_t; +#else +typedef struct iovec { + caddr_t iov_base; +#if defined(_LP64) + size_t iov_len; +#else + long iov_len; +#endif +} iovec_t; +#endif /* defined(_XPG4_2) */ + +#if defined(_SYSCALL32) + +/* Kernel's view of user ILP32 iovec struct */ + +typedef struct iovec32 { + caddr32_t iov_base; + int32_t iov_len; +} iovec32_t; + +#endif /* _SYSCALL32 */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * Segment flag values. + */ +typedef enum uio_seg { UIO_USERSPACE, UIO_SYSSPACE, UIO_USERISPACE } uio_seg_t; + +typedef struct uio { + iovec_t *uio_iov; /* pointer to array of iovecs */ + int uio_iovcnt; /* number of iovecs */ + lloff_t _uio_offset; /* file offset */ + uio_seg_t uio_segflg; /* address space (kernel or user) */ + uint16_t uio_fmode; /* file mode flags */ + uint16_t uio_extflg; /* extended flags */ + lloff_t _uio_limit; /* u-limit (maximum byte offset) */ + ssize_t uio_resid; /* residual count */ +} uio_t; + +/* + * Extended uio_t uioa_t used for asynchronous uio. + * + * Note: UIOA_IOV_MAX is defined and used as it is in "fs/vncalls.c" + * as there isn't a formal definition of IOV_MAX for the kernel. + */ +#define UIOA_IOV_MAX 16 + +typedef struct uioa_page_s { /* locked uio_iov state */ + int uioa_pfncnt; /* count of pfn_t(s) in *uioa_ppp */ + void **uioa_ppp; /* page_t or pfn_t arrary */ + caddr_t uioa_base; /* address base */ + size_t uioa_len; /* span length */ +} uioa_page_t; + +typedef struct uioa_s { + iovec_t *uio_iov; /* pointer to array of iovecs */ + int uio_iovcnt; /* number of iovecs */ + lloff_t _uio_offset; /* file offset */ + uio_seg_t uio_segflg; /* address space (kernel or user) */ + uint16_t uio_fmode; /* file mode flags */ + uint16_t uio_extflg; /* extended flags */ + lloff_t _uio_limit; /* u-limit (maximum byte offset) */ + ssize_t uio_resid; /* residual count */ + /* + * uioa extended members. + */ + uint32_t uioa_state; /* state of asynch i/o */ + ssize_t uioa_mbytes; /* bytes that have been uioamove()ed */ + uioa_page_t *uioa_lcur; /* pointer into uioa_locked[] */ + void **uioa_lppp; /* pointer into lcur->uioa_ppp[] */ + void *uioa_hwst[4]; /* opaque hardware state */ + uioa_page_t uioa_locked[UIOA_IOV_MAX]; /* Per iov locked pages */ +} uioa_t; + +/* + * uio extensions + * + * PSARC 2009/478: Copy Reduction Interfaces + */ +typedef enum xuio_type { + UIOTYPE_ASYNCIO, + UIOTYPE_ZEROCOPY, + UIOTYPE_PEEKSIZE +} xuio_type_t; + +typedef struct xuio { + uio_t xu_uio; /* Embedded UIO structure */ + + /* Extended uio fields */ + enum xuio_type xu_type; /* What kind of uio structure? */ + union { + /* Async I/O Support, intend to replace uioa_t. */ + struct { + uint32_t xu_a_state; /* state of async i/o */ + /* bytes that have been uioamove()ed */ + ssize_t xu_a_mbytes; + uioa_page_t *xu_a_lcur; /* pointer into uioa_locked[] */ + /* pointer into lcur->uioa_ppp[] */ + void **xu_a_lppp; + void *xu_a_hwst[4]; /* opaque hardware state */ + /* Per iov locked pages */ + uioa_page_t xu_a_locked[UIOA_IOV_MAX]; + } xu_aio; + + /* + * Copy Reduction Support -- facilate loaning / returning of + * filesystem cache buffers. + */ + struct { + int xu_zc_rw; /* read or write buffer */ + void *xu_zc_priv; /* fs specific */ + } xu_zc; + + /* + * Peek Size Support -- facilitate peeking at the size of a + * waiting message on a socket. + */ + struct { + ssize_t xu_ps_size; /* size of waiting msg */ + boolean_t xu_ps_set; /* was size calculated? */ + } xu_ps; + } xu_ext; +} xuio_t; + +#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv +#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw + +#define UIOA_ALLOC 0x0001 /* allocated but not yet initialized */ +#define UIOA_INIT 0x0002 /* initialized but not yet enabled */ +#define UIOA_ENABLED 0x0004 /* enabled, asynch i/o active */ +#define UIOA_FINI 0x0008 /* finished waiting for uioafini() */ + +#define UIOA_CLR (~0x000F) /* clear mutually exclusive bits */ + +#define UIOA_POLL 0x0010 /* need dcopy_poll() */ + +#define uio_loffset _uio_offset._f +#if !defined(_LP64) +#define uio_offset _uio_offset._p._l +#else +#define uio_offset uio_loffset +#endif + +#define uio_llimit _uio_limit._f +#if !defined(_LP64) +#define uio_limit _uio_limit._p._l +#else +#define uio_limit uio_llimit +#endif + +/* + * I/O direction. + */ +typedef enum uio_rw { UIO_READ, UIO_WRITE } uio_rw_t; + +/* + * uio_extflg: extended flags + * + * NOTE: This flag will be used in uiomove to determine if non-temporal + * access, ie, access bypassing caches, should be used. Filesystems that + * don't initialize this field could experience suboptimal performance due to + * the random data the field contains. + * + * NOTE: This flag is also used by uioasync callers to pass an extended + * uio_t (uioa_t), to uioasync enabled consumers. Unlike above all + * consumers of a uioa_t require the uio_extflg to be initialized. + */ +#define UIO_COPY_DEFAULT 0x0000 /* no special options to copy */ +#define UIO_COPY_CACHED 0x0001 /* copy should not bypass caches */ + +#define UIO_ASYNC 0x0002 /* uio_t is really a uioa_t */ +#define UIO_XUIO 0x0004 /* Structure is xuio_t */ + +/* + * Global uioasync capability shadow state. + */ +typedef struct uioasync_s { + boolean_t enabled; /* Is uioasync enabled? */ + size_t mincnt; /* Minimum byte count for use of */ +} uioasync_t; + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +int uiomove(void *, size_t, enum uio_rw, uio_t *); +void uio_prefaultpages(ssize_t, uio_t *); +int uiocopy(void *, size_t, enum uio_rw, uio_t *, size_t *); +int ureadc(int, uio_t *); /* should be errno_t in future */ +int uwritec(struct uio *); +void uioskip(uio_t *, size_t); +int uiodup(uio_t *, uio_t *, iovec_t *, int); + +int uioamove(void *, size_t, enum uio_rw, uioa_t *); +int uioainit(uio_t *, uioa_t *); +int uioafini(uio_t *, uioa_t *); +extern uioasync_t uioasync; + +#else /* defined(_KERNEL) */ + +extern ssize_t readv(int, const struct iovec *, int); +extern ssize_t writev(int, const struct iovec *, int); + +/* + * When in the large file compilation environment, + * map preadv/pwritev to their 64 bit offset versions + */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname preadv preadv64 +#pragma redefine_extname pwritev pwritev64 +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define preadv preadv64 +#define pwritev pwritev64 +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +/* In the LP64 compilation environment, the APIs are already large file */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname preadv64 preadv +#pragma redefine_extname pwritev64 pwritev +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define preadv64 preadv +#define pwritev64 pwritev +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern ssize_t preadv(int, const struct iovec *, int, off_t); +extern ssize_t pwritev(int, const struct iovec *, int, off_t); + +/* + * preadv64 and pwritev64 should be defined when: + * - Using the transitional compilation environment, and not + * the large file compilation environment. + */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern ssize_t preadv64(int, const struct iovec *, int, off64_t); +extern ssize_t pwritev64(int, const struct iovec *, int, off64_t); +#endif /* _LARGEFILE64_SOURCE */ + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UIO_H */ diff --git a/illumos-x86_64/usr/include/sys/ulimit.h b/illumos-x86_64/usr/include/sys/ulimit.h new file mode 100644 index 00000000..3bcb3e65 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ulimit.h @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* Copyright (c) 1987, 1988 Microsoft Corporation */ +/* All Rights Reserved */ + +#ifndef _SYS_ULIMIT_H +#define _SYS_ULIMIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following are codes which can be + * passed to the ulimit system call. + */ + +#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) +#define UL_GFILLIM UL_GETFSIZE /* get file limit */ +#define UL_SFILLIM UL_SETFSIZE /* set file limit */ +#define UL_GMEMLIM 3 /* get process size limit */ +#define UL_GDESLIM 4 /* get file descriptor limit */ +#endif + +/* + * The following are symbolic constants required for + * X/Open Conformance. They are the equivalents of + * the constants above. + */ + +#define UL_GETFSIZE 1 /* get file limit */ +#define UL_SETFSIZE 2 /* set file limit */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ULIMIT_H */ diff --git a/illumos-x86_64/usr/include/sys/un.h b/illumos-x86_64/usr/include/sys/un.h new file mode 100644 index 00000000..988f729b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/un.h @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_UN_H +#define _SYS_UN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _SA_FAMILY_T +#define _SA_FAMILY_T +typedef unsigned short sa_family_t; +#endif + +/* + * Definitions for UNIX IPC domain. + */ +struct sockaddr_un { + sa_family_t sun_family; /* AF_UNIX */ + char sun_path[108]; /* path name (gag) */ +}; + +#if (!defined(_XOPEN_SOURCE) && !defined(_POSIX_C_SOURCE)) || \ + defined(__EXTENSIONS__) +/* + * NOTE: If we ever go to BSD-style sun_len + sun_family, this macro needs to + * change. + * + * Also, include a strlen() prototype, and we have to protect it w.r.t. + * UNIX{98,03}. And because there's strlen, we need size_t as well. + */ +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* _SIZE_T */ + +extern size_t strlen(const char *); + +#define SUN_LEN(su) (sizeof (sa_family_t) + strlen((su)->sun_path)) + +#endif /* (!defined(_XOPEN_SOURCE) && !defined(_POSIX_C_SOURCE)) || ... */ + +#ifdef _KERNEL +int unp_discard(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UN_H */ diff --git a/illumos-x86_64/usr/include/sys/unistd.h b/illumos-x86_64/usr/include/sys/unistd.h new file mode 100644 index 00000000..591a3426 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/unistd.h @@ -0,0 +1,418 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + * + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * WARNING: This is an implementation-specific header, + * its contents are not guaranteed. Applications + * should include and not this header. + */ + +#ifndef _SYS_UNISTD_H +#define _SYS_UNISTD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* command names for confstr */ + +#define _CS_PATH 65 + +/* + * command names for large file configuration information + */ +/* large file compilation environment configuration */ +#define _CS_LFS_CFLAGS 68 +#define _CS_LFS_LDFLAGS 69 +#define _CS_LFS_LIBS 70 +#define _CS_LFS_LINTFLAGS 71 +/* transitional large file interface configuration */ +#define _CS_LFS64_CFLAGS 72 +#define _CS_LFS64_LDFLAGS 73 +#define _CS_LFS64_LIBS 74 +#define _CS_LFS64_LINTFLAGS 75 + +/* UNIX 98 */ +#define _CS_XBS5_ILP32_OFF32_CFLAGS 700 +#define _CS_XBS5_ILP32_OFF32_LDFLAGS 701 +#define _CS_XBS5_ILP32_OFF32_LIBS 702 +#define _CS_XBS5_ILP32_OFF32_LINTFLAGS 703 +#define _CS_XBS5_ILP32_OFFBIG_CFLAGS 705 +#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS 706 +#define _CS_XBS5_ILP32_OFFBIG_LIBS 707 +#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS 708 +#define _CS_XBS5_LP64_OFF64_CFLAGS 709 +#define _CS_XBS5_LP64_OFF64_LDFLAGS 710 +#define _CS_XBS5_LP64_OFF64_LIBS 711 +#define _CS_XBS5_LP64_OFF64_LINTFLAGS 712 +#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS 713 +#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS 714 +#define _CS_XBS5_LPBIG_OFFBIG_LIBS 715 +#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 716 + +/* UNIX 03 */ +#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 800 +#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 801 +#define _CS_POSIX_V6_ILP32_OFF32_LIBS 802 +#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 803 +#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 804 +#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 805 +#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 806 +#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 807 +#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 808 +#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 809 +#define _CS_POSIX_V6_LP64_OFF64_LIBS 810 +#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 811 +#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 812 +#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 813 +#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 814 +#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 815 +#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 816 + +/* command names for POSIX sysconf */ + +/* POSIX.1 names */ +#define _SC_ARG_MAX 1 +#define _SC_CHILD_MAX 2 +#define _SC_CLK_TCK 3 +#define _SC_NGROUPS_MAX 4 +#define _SC_OPEN_MAX 5 +#define _SC_JOB_CONTROL 6 +#define _SC_SAVED_IDS 7 +#define _SC_VERSION 8 +/* SVR4 names */ +#define _SC_PASS_MAX 9 +#define _SC_LOGNAME_MAX 10 +#define _SC_PAGESIZE 11 +#define _SC_XOPEN_VERSION 12 +/* 13 reserved for SVr4-ES/MP _SC_NACLS_MAX */ +#define _SC_NPROCESSORS_CONF 14 +#define _SC_NPROCESSORS_ONLN 15 +#define _SC_STREAM_MAX 16 +#define _SC_TZNAME_MAX 17 +/* POSIX.4 names */ +#define _SC_AIO_LISTIO_MAX 18 +#define _SC_AIO_MAX 19 +#define _SC_AIO_PRIO_DELTA_MAX 20 +#define _SC_ASYNCHRONOUS_IO 21 +#define _SC_DELAYTIMER_MAX 22 +#define _SC_FSYNC 23 +#define _SC_MAPPED_FILES 24 +#define _SC_MEMLOCK 25 +#define _SC_MEMLOCK_RANGE 26 +#define _SC_MEMORY_PROTECTION 27 +#define _SC_MESSAGE_PASSING 28 +#define _SC_MQ_OPEN_MAX 29 +#define _SC_MQ_PRIO_MAX 30 +#define _SC_PRIORITIZED_IO 31 +#define _SC_PRIORITY_SCHEDULING 32 +#define _SC_REALTIME_SIGNALS 33 +#define _SC_RTSIG_MAX 34 +#define _SC_SEMAPHORES 35 +#define _SC_SEM_NSEMS_MAX 36 +#define _SC_SEM_VALUE_MAX 37 +#define _SC_SHARED_MEMORY_OBJECTS 38 +#define _SC_SIGQUEUE_MAX 39 +#define _SC_SIGRT_MIN 40 +#define _SC_SIGRT_MAX 41 +#define _SC_SYNCHRONIZED_IO 42 +#define _SC_TIMERS 43 +#define _SC_TIMER_MAX 44 +/* XPG4 names */ +#define _SC_2_C_BIND 45 +#define _SC_2_C_DEV 46 +#define _SC_2_C_VERSION 47 +#define _SC_2_FORT_DEV 48 +#define _SC_2_FORT_RUN 49 +#define _SC_2_LOCALEDEF 50 +#define _SC_2_SW_DEV 51 +#define _SC_2_UPE 52 +#define _SC_2_VERSION 53 +#define _SC_BC_BASE_MAX 54 +#define _SC_BC_DIM_MAX 55 +#define _SC_BC_SCALE_MAX 56 +#define _SC_BC_STRING_MAX 57 +#define _SC_COLL_WEIGHTS_MAX 58 +#define _SC_EXPR_NEST_MAX 59 +#define _SC_LINE_MAX 60 +#define _SC_RE_DUP_MAX 61 +#define _SC_XOPEN_CRYPT 62 +#define _SC_XOPEN_ENH_I18N 63 +#define _SC_XOPEN_SHM 64 + +/* additional XSH4/XCU4 command names for sysconf */ +#define _SC_2_CHAR_TERM 66 +#define _SC_XOPEN_XCU_VERSION 67 + +/* additional XPG4v2 (UNIX 95) command names */ +#define _SC_ATEXIT_MAX 76 +#define _SC_IOV_MAX 77 +#define _SC_XOPEN_UNIX 78 +#define _SC_PAGE_SIZE _SC_PAGESIZE + +/* defined for XTI (XNS Issue 5) */ +#ifndef _SC_T_IOV_MAX +#define _SC_T_IOV_MAX 79 /* Must be same in */ +#endif /* T_IOV_MAX must be <= IOV_MAX */ + +#define _SC_PHYS_PAGES 500 +#define _SC_AVPHYS_PAGES 501 + +/* + * Hardware specific items + * Note that not all items are supported on all architectures + */ +#define _SC_COHER_BLKSZ 503 /* Coherence block size */ +#define _SC_SPLIT_CACHE 504 /* != 0 iff a split cache */ +#define _SC_ICACHE_SZ 505 /* Instruction cache size (bytes) */ +#define _SC_DCACHE_SZ 506 /* Data cache size (bytes) */ +#define _SC_ICACHE_LINESZ 507 /* Instruction cache line size */ +#define _SC_DCACHE_LINESZ 508 /* Data cache line size */ +#define _SC_ICACHE_BLKSZ 509 /* Block size invalidated for icache */ +#define _SC_DCACHE_BLKSZ 510 /* Block size for dcache */ +#define _SC_DCACHE_TBLKSZ 511 /* Block size for dcache prefetch */ +#define _SC_ICACHE_ASSOC 512 /* Icache associativity 1, 2, 3 etc */ +#define _SC_DCACHE_ASSOC 513 /* Dcache associativity 1, 2, 3 etc */ + +#define _SC_MAXPID 514 /* maximum pid value */ +#define _SC_STACK_PROT 515 /* default stack protection */ +#define _SC_NPROCESSORS_MAX 516 /* maximum # of processors */ +#define _SC_CPUID_MAX 517 /* maximum CPU id */ +#define _SC_EPHID_MAX 518 /* maximum ephemeral id */ +#define _SC_UADDR_MAX 519 /* maximum user address */ + +/* + * POSIX.1c (pthreads) names. These values are defined above + * the sub-500 range. See psarc case 1995/257. + */ +#define _SC_THREAD_DESTRUCTOR_ITERATIONS 568 +#define _SC_GETGR_R_SIZE_MAX 569 +#define _SC_GETPW_R_SIZE_MAX 570 +#define _SC_LOGIN_NAME_MAX 571 +#define _SC_THREAD_KEYS_MAX 572 +#define _SC_THREAD_STACK_MIN 573 +#define _SC_THREAD_THREADS_MAX 574 +#define _SC_TTY_NAME_MAX 575 +#define _SC_THREADS 576 +#define _SC_THREAD_ATTR_STACKADDR 577 +#define _SC_THREAD_ATTR_STACKSIZE 578 +#define _SC_THREAD_PRIORITY_SCHEDULING 579 +#define _SC_THREAD_PRIO_INHERIT 580 +#define _SC_THREAD_PRIO_PROTECT 581 +#define _SC_THREAD_PROCESS_SHARED 582 +#define _SC_THREAD_SAFE_FUNCTIONS 583 + +/* UNIX 98 */ +#define _SC_XOPEN_LEGACY 717 +#define _SC_XOPEN_REALTIME 718 +#define _SC_XOPEN_REALTIME_THREADS 719 +#define _SC_XBS5_ILP32_OFF32 720 +#define _SC_XBS5_ILP32_OFFBIG 721 +#define _SC_XBS5_LP64_OFF64 722 +#define _SC_XBS5_LPBIG_OFFBIG 723 + +/* UNIX 03 */ +#define _SC_2_PBS 724 +#define _SC_2_PBS_ACCOUNTING 725 +#define _SC_2_PBS_CHECKPOINT 726 +#define _SC_2_PBS_LOCATE 728 +#define _SC_2_PBS_MESSAGE 729 +#define _SC_2_PBS_TRACK 730 +#define _SC_ADVISORY_INFO 731 +#define _SC_BARRIERS 732 +#define _SC_CLOCK_SELECTION 733 +#define _SC_CPUTIME 734 +#define _SC_HOST_NAME_MAX 735 +#define _SC_MONOTONIC_CLOCK 736 +#define _SC_READER_WRITER_LOCKS 737 +#define _SC_REGEXP 738 +#define _SC_SHELL 739 +#define _SC_SPAWN 740 +#define _SC_SPIN_LOCKS 741 +#define _SC_SPORADIC_SERVER 742 +#define _SC_SS_REPL_MAX 743 +#define _SC_SYMLOOP_MAX 744 +#define _SC_THREAD_CPUTIME 745 +#define _SC_THREAD_SPORADIC_SERVER 746 +#define _SC_TIMEOUTS 747 +#define _SC_TRACE 748 +#define _SC_TRACE_EVENT_FILTER 749 +#define _SC_TRACE_EVENT_NAME_MAX 750 +#define _SC_TRACE_INHERIT 751 +#define _SC_TRACE_LOG 752 +#define _SC_TRACE_NAME_MAX 753 +#define _SC_TRACE_SYS_MAX 754 +#define _SC_TRACE_USER_EVENT_MAX 755 +#define _SC_TYPED_MEMORY_OBJECTS 756 +#define _SC_V6_ILP32_OFF32 757 +#define _SC_V6_ILP32_OFFBIG 758 +#define _SC_V6_LP64_OFF64 759 +#define _SC_V6_LPBIG_OFFBIG 760 +#define _SC_XOPEN_STREAMS 761 +#define _SC_IPV6 762 +#define _SC_RAW_SOCKETS 763 + +/* command names for POSIX pathconf */ + +/* POSIX.1 names */ +#define _PC_LINK_MAX 1 +#define _PC_MAX_CANON 2 +#define _PC_MAX_INPUT 3 +#define _PC_NAME_MAX 4 +#define _PC_PATH_MAX 5 +#define _PC_PIPE_BUF 6 +#define _PC_NO_TRUNC 7 +#define _PC_VDISABLE 8 +#define _PC_CHOWN_RESTRICTED 9 +/* POSIX.4 names */ +#define _PC_ASYNC_IO 10 +#define _PC_PRIO_IO 11 +#define _PC_SYNC_IO 12 +/* UNIX 03 names */ +#define _PC_ALLOC_SIZE_MIN 13 +#define _PC_REC_INCR_XFER_SIZE 14 +#define _PC_REC_MAX_XFER_SIZE 15 +#define _PC_REC_MIN_XFER_SIZE 16 +#define _PC_REC_XFER_ALIGN 17 +#define _PC_SYMLINK_MAX 18 +#define _PC_2_SYMLINKS 19 +#define _PC_ACL_ENABLED 20 +#define _PC_MIN_HOLE_SIZE 21 +#define _PC_CASE_BEHAVIOR 22 +#define _PC_SATTR_ENABLED 23 +#define _PC_SATTR_EXISTS 24 +#define _PC_ACCESS_FILTERING 25 +/* UNIX 08 names */ +#define _PC_TIMESTAMP_RESOLUTION 26 + +/* + * Large File Summit names + * + * This value matches the MIPS ABI choice, but leaves a large gap in the + * value space. + */ +#define _PC_FILESIZEBITS 67 + +/* + * Extended attributes + */ +#define _PC_XATTR_ENABLED 100 +#define _PC_XATTR_EXISTS 101 + +/* + * If you add a _PC define above 101, you must change _PC_LAST (and truss). + */ +#define _PC_LAST 101 + +/* + * Case sensitivity values (related to _PC_CASE_BEHAVIOR) + */ +#define _CASE_SENSITIVE 0x1 +#define _CASE_INSENSITIVE 0x2 + +/* + * The value of 0 is returned when + * ACL's are not supported + */ +#define _ACL_ACLENT_ENABLED 0x1 +#define _ACL_ACE_ENABLED 0x2 + +#ifndef _POSIX_VERSION +#ifdef _XPG6 +#define _POSIX_VERSION 200112L /* Supports IEEE Std 1003.1-2001 */ +#else +#define _POSIX_VERSION 199506L /* Supports POSIX-1c DIS */ +#endif +#endif /* _POSIX_VERSION */ + +#ifndef _POSIX2_VERSION +#ifdef _XPG6 +#define _POSIX2_VERSION 200112L /* Supports IEEE Std 1003.1-2001 */ +#else +#define _POSIX2_VERSION 199209L /* Supports ISO POSIX-2 DIS */ +#endif +#endif /* _POSIX2_VERSION */ + +/* + * Marked LEGACY in SUSv2 and removed in SUSv3. Though SUSv3 applications + * should not rely on this value, it has been aligned with the current + * standard to avoid confusion if used. + */ +#ifndef _POSIX2_C_VERSION +#ifdef _XPG6 +#define _POSIX2_C_VERSION 200112L /* Supports IEEE Std 1003.1-2001 */ +#else +#define _POSIX2_C_VERSION 199209L /* Supports ISO POSIX-2 DIS */ +#endif +#endif /* _POSIX2_C_VERSION */ + +#define _XOPEN_XPG3 /* Supports XPG, Issue 3 */ +#define _XOPEN_XPG4 /* Supports XPG, Issue 4 */ +#define _XOPEN_UNIX 0 /* Supports X/Open System Interfaces */ + +#ifndef _XOPEN_XCU_VERSION +#define _XOPEN_XCU_VERSION 4 /* Supports XCU4 */ +#endif + +#define _XOPEN_REALTIME 1 /* Supports Realtime */ +#define _XOPEN_ENH_I18N 1 /* Supports Enhanced International */ +#define _XOPEN_SHM 1 /* Supports Shared Memory Feature */ +#define _POSIX2_CHAR_TERM 1 /* Supports at least 1 terminal type */ + +#ifdef _XPG6 +#define _POSIX2_C_BIND 200112L /* Supports C Language Bindings */ +#define _POSIX2_C_DEV 200112L /* Supports C language dev utility */ +#define _POSIX2_FORT_RUN 200112L /* Supports FORTRAN runtime */ +#define _POSIX2_LOCALEDEF 200112L /* Supports creation of locales */ +#define _POSIX2_SW_DEV 200112L /* Supports S/W Development Utility */ +#define _POSIX2_UPE 200112L /* Supports User Portability Utility */ +#else +#define _POSIX2_C_BIND 1 /* Supports C Language Bindings */ +#define _POSIX2_C_DEV 1 /* Supports C language dev utility */ +#define _POSIX2_FORT_RUN 1 /* Supports FORTRAN runtime */ +#define _POSIX2_LOCALEDEF 1 /* Supports creation of locales */ +#define _POSIX2_SW_DEV 1 /* Supports S/W Development Utility */ +#define _POSIX2_UPE 1 /* Supports User Portability Utility */ +#endif /* _XPG6 */ + +/* UNIX 03 names */ +#define _POSIX_REGEXP 1 /* Supports POSIX Regular Expressions */ +#define _POSIX_SHELL 1 /* Supports POSIX shell */ +#define _XOPEN_STREAMS 1 /* Supports XSI Streams Option Group */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UNISTD_H */ diff --git a/illumos-x86_64/usr/include/sys/user.h b/illumos-x86_64/usr/include/sys/user.h new file mode 100644 index 00000000..90fde4ef --- /dev/null +++ b/illumos-x86_64/usr/include/sys/user.h @@ -0,0 +1,320 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +/* + * Copyright 2019 Joyent, Inc. + * Copyright 2022 Oxide Computer Company + */ + + +#ifndef _SYS_USER_H +#define _SYS_USER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * struct exdata is visible in and out of the kernel. This is because it + * is referenced in which doesn't have this kind of magic. + */ +struct exdata { + struct vnode *vp; + size_t ux_tsize; /* text size */ + size_t ux_dsize; /* data size */ + size_t ux_bsize; /* bss size */ + size_t ux_lsize; /* lib size */ + long ux_nshlibs; /* number of shared libs needed */ + short ux_mach; /* machine type */ + short ux_mag; /* magic number MUST be here */ + off_t ux_toffset; /* file offset to raw text */ + off_t ux_doffset; /* file offset to raw data */ + off_t ux_loffset; /* file offset to lib sctn */ + caddr_t ux_txtorg; /* start addr of text in mem */ + caddr_t ux_datorg; /* start addr of data in mem */ + caddr_t ux_entloc; /* entry location */ +}; + +#ifdef __cplusplus +} +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * File Descriptor assignment generation. + * + * Certain file descriptor consumers (namely epoll) need to be able to detect + * when the resource underlying an fd change due to (re)assignment. Checks + * comparing old and new file_t pointers work OK, but could easily be fooled by + * an entry freed-to and reused-from the cache. To better detect such + * assingments, a generation number is kept in the uf_entry. Whenever a + * non-NULL file_t is assigned to the entry, the generation is incremented, + * indicating the change. There is a minute possibility that a rollover of the + * value could cause assigments to evade detection by consumers, but it is + * considered acceptably small. + */ +typedef uint_t uf_entry_gen_t; + +/* + * Entry in the per-process list of open files. + * Note: only certain fields are copied in flist_grow() and flist_fork(). + * This is indicated in brackets in the structure member comments. + */ +typedef struct uf_entry { + kmutex_t uf_lock; /* per-fd lock [never copied] */ + struct file *uf_file; /* file pointer [grow, fork] */ + struct fpollinfo *uf_fpollinfo; /* poll state [grow] */ + int uf_refcnt; /* LWPs accessing this file [grow] */ + int uf_alloc; /* right subtree allocs [grow, fork] */ + short uf_flag; /* fcntl F_GETFD flags [grow, fork] */ + short uf_busy; /* file is allocated [grow, fork] */ + kcondvar_t uf_wanted_cv; /* waiting for setf() [never copied] */ + kcondvar_t uf_closing_cv; /* waiting for close() [never copied] */ + struct portfd *uf_portfd; /* associated with port [grow] */ + uf_entry_gen_t uf_gen; /* assigned fd generation [grow,fork] */ + /* Avoid false sharing - pad to coherency granularity (64 bytes) */ + char uf_pad[64 - sizeof (kmutex_t) - 2 * sizeof (void*) - + 2 * sizeof (int) - 2 * sizeof (short) - + 2 * sizeof (kcondvar_t) - sizeof (struct portfd *) - + sizeof (uf_entry_gen_t)]; +} uf_entry_t; + +/* + * Retired file lists -- see flist_grow() for details. + */ +typedef struct uf_rlist { + struct uf_rlist *ur_next; + uf_entry_t *ur_list; + int ur_nfiles; +} uf_rlist_t; + +/* + * Per-process file information. + */ +typedef struct uf_info { + kmutex_t fi_lock; /* see below */ + int fi_badfd; /* bad file descriptor # */ + int fi_action; /* action to take on bad fd use */ + int fi_nfiles; /* number of entries in fi_list[] */ + uf_entry_t *volatile fi_list; /* current file list */ + uf_rlist_t *fi_rlist; /* retired file lists */ +} uf_info_t; + +/* + * File list locking. + * + * Each process has a list of open files, fi_list, indexed by fd. + * fi_list is an array of uf_entry_t structures, each with its own lock. + * One might think that the correct way to lock a file descriptor would be: + * + * ufp = fip->fi_list[fd]; + * mutex_enter(&ufp->uf_lock); + * + * However, that construct is only safe if fi_lock is already held. If not, + * fi_list can change in the window between loading ufp and entering uf_lock. + * The UF_ENTER() macro deals with this possibility. UF_ENTER(ufp, fip, fd) + * locks fd and sets ufp to fd's uf_entry. The locking rules are as follows: + * + * (1) fi_lock protects fi_list and fi_nfiles. It also protects the + * uf_alloc and uf_busy fields of every fd's ufp; see fd_find() for + * details on file descriptor allocation. + * + * (2) UF_ENTER(ufp, fip, fd) locks descriptor fd and sets ufp to point + * to the uf_entry_t for fd. UF_ENTER() protects all fields in ufp + * except uf_alloc and uf_busy. UF_ENTER(ufp, fip, fd) also prevents + * ufp->uf_alloc, ufp->uf_busy, fip->fi_list and fip->fi_nfiles from + * changing. + * + * (3) The lock ordering is (1), (2). + * + * (4) Note that fip->fi_list and fip->fi_nfiles cannot change while *any* + * file list lock is held. Thus flist_grow() must acquire all such + * locks -- fi_lock and every fd's uf_lock -- to install a new file list. + */ +#define UF_ENTER(ufp, fip, fd) \ + for (;;) { \ + uf_entry_t *_flist = (fip)->fi_list; \ + ufp = &_flist[fd]; \ + ASSERT((fd) < (fip)->fi_nfiles); \ + mutex_enter(&ufp->uf_lock); \ + if (_flist == (fip)->fi_list) \ + break; \ + mutex_exit(&ufp->uf_lock); \ + } + +#define UF_EXIT(ufp) mutex_exit(&ufp->uf_lock) + +#define PSARGSZ 80 /* Space for exec arguments (used by ps(1)) */ +#define MAXCOMLEN 16 /* <= MAXNAMLEN, >= sizeof (ac_comm) */ + +typedef struct { /* kernel syscall set type */ + uint_t word[9]; /* space for syscall numbers [1..288] */ +} k_sysset_t; + +/* + * __KERN_NAUXV_IMPL is defined as a convenience sizing mechanism + * for the portions of the kernel that care about aux vectors. + * + * Applications that need to know how many aux vectors the kernel + * supplies should use the proc(5) interface to read /proc/PID/auxv. + * + * This value should not be changed in a patch. + */ +#if defined(__sparc) +#define __KERN_NAUXV_IMPL 24 +#elif defined(__i386) || defined(__amd64) +#define __KERN_NAUXV_IMPL 29 +#endif + +struct execsw; + +/* + * The user structure; one allocated per process. Contains all the + * per-process data that doesn't need to be referenced while the + * process is swapped. + */ +typedef struct user { + /* + * These fields are initialized at process creation time and never + * modified. They can be accessed without acquiring locks. + */ + struct execsw *u_execsw; /* pointer to exec switch entry */ + auxv_t u_auxv[__KERN_NAUXV_IMPL]; /* aux vector from exec */ + timestruc_t u_start; /* hrestime at process start */ + clock_t u_ticks; /* lbolt at process start */ + char u_comm[MAXCOMLEN + 1]; /* executable file name from exec */ + char u_psargs[PSARGSZ]; /* arguments from exec */ + int u_argc; /* value of argc passed to main() */ + uintptr_t u_argv; /* value of argv passed to main() */ + uintptr_t u_argvstrs; /* argv string space pointer */ + size_t u_argvstrsize; /* size of argv string space */ + uintptr_t u_envp; /* value of envp passed to main() */ + uintptr_t u_envstrs; /* env string space pointer */ + size_t u_envstrsize; /* size of env string space */ + uintptr_t u_commpagep; /* address of mapped comm page */ + + /* + * These fields are protected by p_lock: + */ + struct vnode *u_cdir; /* current directory */ + struct vnode *u_rdir; /* root directory */ + uint64_t u_mem; /* accumulated memory usage */ + size_t u_mem_max; /* peak RSS (K) */ + mode_t u_cmask; /* mask for file creation */ + char u_acflag; /* accounting flag */ + char u_systrap; /* /proc: any syscall mask bits set? */ + refstr_t *u_cwd; /* cached string for cwd */ + + k_sysset_t u_entrymask; /* /proc syscall stop-on-entry mask */ + k_sysset_t u_exitmask; /* /proc syscall stop-on-exit mask */ + k_sigset_t u_signodefer; /* signals defered when caught */ + k_sigset_t u_sigonstack; /* signals taken on alternate stack */ + k_sigset_t u_sigresethand; /* signals reset when caught */ + k_sigset_t u_sigrestart; /* signals that restart system calls */ + k_sigset_t u_sigmask[MAXSIG]; /* signals held while in catcher */ + void (*u_signal[MAXSIG])(); /* Disposition of signals */ + + /* + * Resource controls provide the backend for process resource limits, + * the interfaces for which are maintained for compatibility. To + * preserve the behaviour associated with the RLIM_SAVED_CUR and + * RLIM_SAVED_MAX tokens, we retain the "saved" rlimits. + */ + struct rlimit64 u_saved_rlimit[RLIM_NSAVED]; + + uf_info_t u_finfo; /* open file information */ +} user_t; + +#include /* cannot include before user defined */ + +#ifdef _KERNEL +#define P_FINFO(p) (&(p)->p_user.u_finfo) +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#else /* defined(_KERNEL) || defined(_KMEMUSER) */ + +/* + * Here, we define a fake version of struct user for programs + * (debuggers) that use ptrace() to read and modify the saved + * registers directly in the u-area. ptrace() has been removed + * from the operating system and now exists as a library function + * in libc, built on the /proc process filesystem. The ptrace() + * library function provides access only to the members of the + * fake struct user defined here. + * + * User-level programs that must know the real contents of struct + * user will have to define _KMEMUSER before including . + * Such programs also become machine specific. Carefully consider + * the consequences of your actions. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PSARGSZ 80 /* Space for exec arguments (used by ps(1)) */ + +typedef struct user { + gregset_t u_reg; /* user's saved registers */ + greg_t *u_ar0; /* address of user's saved R0 */ + char u_psargs[PSARGSZ]; /* arguments from exec */ + void (*u_signal[MAXSIG])(); /* Disposition of signals */ + int u_code; /* fault code on trap */ + caddr_t u_addr; /* fault PC on trap */ +} user_t; + +#ifdef __cplusplus +} +#endif + +#endif /* defined(_KERNEL) || defined(_KMEMUSER) */ + +#endif /* _SYS_USER_H */ diff --git a/illumos-x86_64/usr/include/sys/ustat.h b/illumos-x86_64/usr/include/sys/ustat.h new file mode 100644 index 00000000..03e2bbe6 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/ustat.h @@ -0,0 +1,72 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * WARNING: The ustat system call will become obsolete in the + * next major release following SVR4. Application code should + * migrate to the replacement system call statvfs(2). + */ + +/* + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_USTAT_H +#define _SYS_USTAT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#error "Cannot use ustat in the large files compilation environment" +#endif + +struct ustat { + daddr_t f_tfree; /* total free */ + ino_t f_tinode; /* total inodes free */ + char f_fname[6]; /* filsys name */ + char f_fpack[6]; /* filsys pack name */ +}; + +#if defined(_SYSCALL32) + +struct ustat32 { + daddr32_t f_tfree; /* total free */ + ino32_t f_tinode; /* total inodes free */ + char f_fname[6]; /* filsys name */ + char f_fpack[6]; /* filsys pack name */ +}; + +#endif /* _SYSCALL32 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_USTAT_H */ diff --git a/illumos-x86_64/usr/include/sys/utime.h b/illumos-x86_64/usr/include/sys/utime.h new file mode 100644 index 00000000..dab1ee7d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/utime.h @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_UTIME_H +#define _SYS_UTIME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* utimbuf is used by utime(2) */ +struct utimbuf { + time_t actime; /* access time */ + time_t modtime; /* modification time */ +}; + +#if defined(_SYSCALL32) + +/* Kernel's view of ILP32 utimbuf structure */ + +struct utimbuf32 { + time32_t actime; /* access time */ + time32_t modtime; /* modification time */ +}; + +#endif /* _SYSCALL32 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UTIME_H */ diff --git a/illumos-x86_64/usr/include/sys/utrap.h b/illumos-x86_64/usr/include/sys/utrap.h new file mode 100644 index 00000000..fc018eb2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/utrap.h @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _UTRAP_H +#define _UTRAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains definitions for user-level traps. + */ + +#ifndef _ASM + +/* + * This architecture does not support install_utrap() (yet). + */ + +#define UTH_NOCHANGE ((utrap_handler_t)(-1)) +#define UTRAP_UTH_NOCHANGE UTH_NOCHANGE + +typedef int utrap_entry_t; +typedef void *utrap_handler_t; /* user trap handler entry point */ + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UTRAP_H */ diff --git a/illumos-x86_64/usr/include/sys/utsname.h b/illumos-x86_64/usr/include/sys/utsname.h new file mode 100644 index 00000000..3d332ca2 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/utsname.h @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_UTSNAME_H +#define _SYS_UTSNAME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define _SYS_NMLN 257 /* 4.0 size of utsname elements */ + /* Must be at least 257 to */ + /* support Internet hostnames. */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#ifndef SYS_NMLN +#define SYS_NMLN _SYS_NMLN +#endif +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +struct utsname { + char sysname[_SYS_NMLN]; + char nodename[_SYS_NMLN]; + char release[_SYS_NMLN]; + char version[_SYS_NMLN]; + char machine[_SYS_NMLN]; +}; + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern struct utsname utsname; +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#if !defined(_KERNEL) + +#if defined(__i386) && !defined(__amd64) + +extern int uname(struct utsname *); +extern int _uname(struct utsname *); + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int nuname(struct utsname *); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +extern int _nuname(struct utsname *); + +/* + * On i386 in SVID.2 uname() returns a utsname structure with 8 byte members, + * and nuname() returns the real struct utsname. In SVID.3 uname and nuname + * are equivalent. Anyone who includes this header gets the SVID.3 behaviour. + * The SVID.2 behaviour exists solely for compatibility, and is what is + * implemented by the libc uname/_uname entrypoints. + */ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname uname _nuname +#pragma redefine_extname _uname _nuname +#else +#define uname _nuname +#define _uname _nuname +#endif + +#else /* defined(__i386) */ + +extern int uname(struct utsname *); + +#endif /* defined(__i386) */ + +#else /* !(_KERNEL) */ +/* + * Routine to retrieve the nodename as seen in the current process's zone. + */ +extern char *uts_nodename(void); +#endif /* !(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UTSNAME_H */ diff --git a/illumos-x86_64/usr/include/sys/utssys.h b/illumos-x86_64/usr/include/sys/utssys.h new file mode 100644 index 00000000..f393c4d3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/utssys.h @@ -0,0 +1,114 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_UTSSYS_H +#define _SYS_UTSSYS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions related to the utssys() system call. + */ + +/* + * "commands" of utssys + */ +#define UTS_UNAME 0x0 /* obsolete */ +#define UTS_USTAT 0x2 /* 1 was umask */ +#define UTS_FUSERS 0x3 + +/* + * Flags to UTS_FUSERS + */ +#define F_FILE_ONLY 0x01 +#define F_CONTAINED 0x02 +#define F_NBMANDLIST 0x04 /* Only NBMAND locks users */ +#define F_DEVINFO 0x08 /* get device usage info for a dip instead */ + /* of a minor node */ +#define F_KINFO_COUNT 0x10 /* get the current number of kernel */ + /* device consumers */ + +/* + * structures yielded by UTS_FUSERS + */ +typedef struct f_user { + int fu_flags; /* see below */ + union { + struct { + pid_t u_pid; + uid_t u_uid; + } u_info; + struct { + int k_modid; + int k_instance; + int k_minor; + } k_info; + } fu_info; +} f_user_t; + +typedef struct fu_data { + int fud_user_max; + int fud_user_count; + struct f_user fud_user[1]; +} fu_data_t; + +/* + * defines to simplify access to members of the f_user_t structure + */ +#define fu_pid fu_info.u_info.u_pid +#define fu_uid fu_info.u_info.u_uid + +#define fu_modid fu_info.k_info.k_modid +#define fu_instance fu_info.k_info.k_instance +#define fu_minor fu_info.k_info.k_minor + +#define fu_data_size(x) (sizeof (fu_data_t) - sizeof (f_user_t) + \ + ((x) * sizeof (f_user_t))) + +/* + * fu_flags values + */ +#define F_CDIR 0x1 +#define F_RDIR 0x2 +#define F_TEXT 0x4 +#define F_MAP 0x8 +#define F_OPEN 0x10 +#define F_TRACE 0x20 +#define F_TTY 0x40 +#define F_NBM 0x80 /* NBMAND lock in place */ +#define F_KERNEL 0x80000000 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UTSSYS_H */ diff --git a/illumos-x86_64/usr/include/sys/uuid.h b/illumos-x86_64/usr/include/sys/uuid.h new file mode 100644 index 00000000..9ce872e3 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/uuid.h @@ -0,0 +1,98 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_UUID_H +#define _SYS_UUID_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The copyright in this file is taken from the original Leach + * & Salz UUID specification, from which this implementation + * is derived. + */ + +/* + * Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. + * Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & + * Digital Equipment Corporation, Maynard, Mass. Copyright (c) 1998 + * Microsoft. To anyone who acknowledges that this file is provided + * "AS IS" without any express or implied warranty: permission to use, + * copy, modify, and distribute this file for any purpose is hereby + * granted without fee, provided that the above copyright notices and + * this notice appears in all source code copies, and that none of the + * names of Open Software Foundation, Inc., Hewlett-Packard Company, + * or Digital Equipment Corporation be used in advertising or + * publicity pertaining to distribution of the software without + * specific, written prior permission. Neither Open Software + * Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital + * Equipment Corporation makes any representations about the + * suitability of this software for any purpose. + */ + +#include +#include + +typedef struct { + uint8_t nodeID[6]; +} uuid_node_t; + +/* + * The uuid type used throughout when referencing uuids themselves + */ +struct uuid { + uint32_t time_low; + uint16_t time_mid; + uint16_t time_hi_and_version; + uint8_t clock_seq_hi_and_reserved; + uint8_t clock_seq_low; + uint8_t node_addr[6]; +}; + +#define UUID_LEN 16 + +#define UUID_PRINTABLE_STRING_LENGTH 37 + +typedef uchar_t uuid_t[UUID_LEN]; + +/* + * Convert a uuid to/from little-endian format + */ +#define UUID_LE_CONVERT(dest, src) \ +{ \ + (dest) = (src); \ + (dest).time_low = LE_32((dest).time_low); \ + (dest).time_mid = LE_16((dest).time_mid); \ + (dest).time_hi_and_version = LE_16((dest).time_hi_and_version); \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UUID_H */ diff --git a/illumos-x86_64/usr/include/sys/va_impl.h b/illumos-x86_64/usr/include/sys/va_impl.h new file mode 100644 index 00000000..d11a6564 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/va_impl.h @@ -0,0 +1,171 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VA_IMPL_H +#define _SYS_VA_IMPL_H + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers, + * specifically and . + * + * This header serves two purposes. + * + * First, it provides a common set of definitions that implementations + * of the various standards for variable argument lists may use. These + * various standards are implemented in , , + * , , and . + * + * Second, it provides varying implementations of the common definitions, + * depending upon the compiler. + */ + +/* + * The common definitions exported by this header or compilers using + * this header are: + * + * the macro __va_start(list, name) starting the list iteration + * the macro __va_arg(list, type) getting the current arg and iterating + * the macro __va_copy(to, from) to bookmark the list iteration + * the macro __va_end(list) to end the iteration + * + * In addition, the following are exported via inclusion of : + * + * the identifier __builtin_va_alist for the variable list pseudo parameter + * the type __va_alist_type for the variable list pseudo parameter + * the type __va_list defining the type of the variable list iterator + */ + +/* + * This header uses feature macros (e.g. __BUILTIN_VA_ARG_INCR and + * __BUILTIN_VA_STRUCT), compiler macros (e.g. __GNUC__), and processor + * macros (e.g. __sparc) to determine the protocol appropriate to the + * current compilation. It is intended that the compilation system + * define the feature, processor, and compiler macros, not the user of + * the system. + */ + +/* + * Many compilation systems depend upon the use of special functions + * built into the the compilation system to handle variable argument + * lists. These built-in symbols may include one or more of the + * following: + * + * __builtin_va_alist + * __builtin_va_start + * __builtin_va_arg_incr + * __builtin_stdarg_start + * __builtin_va_end + * __builtin_va_arg + * __builtin_va_copy + */ + +/* + * The following are defined in : + * + * __va_alist_type + * __va_void() + * __va_ptr_base + * ISA definitions via inclusion of + * + * Inclusion of this header also makes visible the symbols in . + * This header is included in , and in + * via inclusion of . + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__lint) /* ---------------------------------------- protocol */ + +#define __va_start(list, name) ((list) = (__va_list)&name) +#define __va_arg(list, type) ((type *)(list))[0] +#define __va_copy(to, from) __va_void(((to) = (from))) +/*ARGSUSED*/ +static void __va_end(__va_list list) { __va_end(list); } + +#elif defined(__BUILTIN_VA_STRUCT) /* ------------------------ protocol */ + +/* ISA __va_list structures defined in */ + +void __builtin_va_start(__va_list, ...); +void *__builtin_va_arg_incr(__va_list, ...); + +#define __va_start(list, name) __builtin_va_start(list, 0) +#define __va_arg(list, type) \ + ((type *)__builtin_va_arg_incr(list, (type *)0))[0] +#define __va_copy(to, from) __va_void(((to)[0] = (from)[0])) +#define __va_end(list) __va_void(0) + +#elif defined(__BUILTIN_VA_ARG_INCR) /* ------------------------ protocol */ + +#define __va_start(list, name) \ + __va_void(((list) = (__va_list)&__builtin_va_alist)) +#define __va_arg(list, type) \ + ((type *)__builtin_va_arg_incr((type *)(list)))[0] +#define __va_copy(to, from) __va_void(((to) = (from))) +#define __va_end(list) __va_void(0) + +#elif defined(__GNUC__) && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || \ + (__GNUC__ >= 3)) /* ------------------------ protocol */ +#if (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3)) +#define __va_start(list, name) __builtin_stdarg_start(list, name) +#else +#define __va_start(list, name) __builtin_va_start(list, name) +#endif + +#define __va_arg(list, type) __builtin_va_arg(list, type) +#define __va_end(list) __builtin_va_end(list) +#define __va_copy(to, from) __builtin_va_copy(to, from) + +#else /* ----------------------- protocol */ + +/* + * Because we can not predict the compiler protocol for unknown compilers, we + * force an error in order to avoid unpredictable behavior. For versions of + * gcc 2.95 and earlier, variable argument lists are handled in gcc specific + * stdarg.h and varargs.h headers created via the gcc fixincl utility. In + * those cases, the gcc headers would override this header. + */ + +#error("Unrecognized compiler protocol for variable argument lists") + +#endif /* -------------------------------------------------------- protocol */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VA_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/va_list.h b/illumos-x86_64/usr/include/sys/va_list.h new file mode 100644 index 00000000..dbd69f33 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/va_list.h @@ -0,0 +1,126 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VA_LIST_H +#define _SYS_VA_LIST_H + +/* + * An application should not include this header directly. Instead it + * should be included only through the inclusion of other Sun headers. + * + * The purpose of this header is to provide the type definitions for + * the va_list argument used by a number of printf and printf like + * functions. The headers that define these various function prototypes + * #include this header directly. These include but are not necessarily + * limited to , , , and + * . The type definitions included in this header are for + * the benefit of consumers of va_list. + * + * Any application that accepts variable argument lists must as documented, + * include either or the preferred . Doing so will + * pull in the appropriate compiler protocols defined in + * which is in turn is included by and . See comments + * in for more detailed information regarding implementation + * and compiler specific protocols. + */ + +/* + * The common definitions exported by this header or compilers using + * this header are: + * + * the identifier __builtin_va_alist for the variable list pseudo parameter + * the type __va_alist_type for the variable list pseudo parameter + * the type __va_list defining the type of the variable list iterator + * + * The feature macros (e.g. __BUILTIN_VA_STRUCT) and compiler macros + * (__GNUC__) and processor macros (e.g. __amd64) are intended to be + * defined by the compilation system, not the user of the system. + */ + +#include /* sys/isa_defs needed for _LP64. */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_LP64) +#define __va_alist_type long +#else +#define __va_alist_type int +#endif + +#define __va_void(expr) ((void)expr) +#define __va_ptr_base void + +#if defined(__BUILTIN_VA_STRUCT) && !defined(__lint) /* -------- protocol */ + +#if defined(__amd64) /* processor */ + +typedef struct __va_list_element { + unsigned int __va_gp_offset; + unsigned int __va_fp_offset; + void *__va_overflow_arg_area; + void *__va_reg_sve_area; +} __va_list[1]; + +/* Other ISA __va_list structures added here under #elif */ + +#else /* processor */ + +#error("No __va_list structure defined for ISA") + +#endif /* processor */ + +#elif (defined(__GNUC__) && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || \ + (__GNUC__ >= 3))) && !defined(__lint) /* ---------------- protocol */ + +#define __GNUC_VA_LIST + +typedef __builtin_va_list __gnuc_va_list; +/* + * XX64 This seems unnecessary .. but is needed because vcmn_err is + * defined with __va_list instead of plain old va_list. + * Perhaps that should be fixed! + */ +typedef __builtin_va_list __va_list; + +#else /* default */ /* ---------------- protocol */ + +typedef __va_ptr_base *__va_list; + +#endif /* -------------------------------------------------------- protocol */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VA_LIST_H */ diff --git a/illumos-x86_64/usr/include/sys/var.h b/illumos-x86_64/usr/include/sys/var.h new file mode 100644 index 00000000..0396c9c1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/var.h @@ -0,0 +1,72 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _SYS_VAR_H +#define _SYS_VAR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * System Configuration Information + */ +struct var { + int v_buf; /* Nbr of I/O buffers. */ + int v_call; /* Nbr of callout (timeout) entries. */ + int v_proc; /* Max processes system wide */ + int v_maxupttl; /* Max user processes system wide */ + int v_nglobpris; /* Nbr of global sched prios configured */ + int v_maxsyspri; /* Max global pri used by sys class. */ + int v_clist; /* Nbr of clists allocated. */ + int v_maxup; /* Max number of processes per user. */ + int v_hbuf; /* Nbr of hash buffers to allocate. */ + int v_hmask; /* Hash mask for buffers. */ + int v_pbuf; /* Nbr of physical I/O buffers. */ + int v_sptmap; /* Size of system virtual space */ + /* allocation map. */ + int v_maxpmem; /* The maximum physical memory to use. */ + /* If v_maxpmem == 0, then use all */ + /* available physical memory. */ + /* Otherwise, value is amount of mem to */ + /* use specified in pages. */ + int v_autoup; /* The age a delayed-write buffer must */ + /* be in seconds before bdflush will */ + /* write it out. */ + int v_bufhwm; /* high-water-mark of buffer cache */ + /* memory usage, in units of K Bytes */ +}; + +extern struct var v; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VAR_H */ diff --git a/illumos-x86_64/usr/include/sys/varargs.h b/illumos-x86_64/usr/include/sys/varargs.h new file mode 100644 index 00000000..a1257ef9 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/varargs.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VARARGS_H +#define _SYS_VARARGS_H + +/* + * This header defines the Solaris system definitions for variable + * argument lists. For the most part, it follows the definitions of + * ISO C 1999. It does not follow the namespace rules for ISO C++ + * 1998. + * + * The varargs definitions within this header are defined in terms of + * implementation definitions. These implementation definitions reside + * in . This organization enables protected use of + * the implementation by other standard headers without introducing + * names into the users' namespace. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _VA_LIST +#define _VA_LIST +typedef __va_list va_list; +#endif + +/* + * This file provides stdarg semantics despite the name of the file. + */ + +#define va_start(list, name) __va_start(list, name) +#define va_arg(list, type) __va_arg(list, type) +#define va_copy(to, from) __va_copy(to, from) +#define va_end(list) __va_end(list) + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VARARGS_H */ diff --git a/illumos-x86_64/usr/include/sys/vfs.h b/illumos-x86_64/usr/include/sys/vfs.h new file mode 100644 index 00000000..b881bfcb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vfs.h @@ -0,0 +1,620 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Toomas Soome + * Copyright (c) 2016, 2017 by Delphix. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_VFS_H +#define _SYS_VFS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Data associated with mounted file systems. + */ + +/* + * Operations vector. This is used internal to the kernel; file systems + * supply their list of operations via vfs_setfsops(). + */ + +typedef struct vfsops vfsops_t; + +/* + * File system identifier. Should be unique (at least per machine). + */ +typedef struct { + int val[2]; /* file system id type */ +} fsid_t; + +/* + * File identifier. Should be unique per filesystem on a single + * machine. This is typically called by a stateless file server + * in order to generate "file handles". + * + * Many underlying file systems cast a struct fid into other + * file system dependent structures which may require 4 byte alignment. + * Because a fid starts with a short it may not be 4 byte aligned, the + * fid_pad will force the alignment. + */ +#define MAXFIDSZ 64 +#define OLD_MAXFIDSZ 16 + +typedef struct fid { + union { + long fid_pad; + struct { + ushort_t len; /* length of data in bytes */ + char data[MAXFIDSZ]; /* data (variable len) */ + } _fid; + } un; +} fid_t; + +#ifdef _SYSCALL32 +/* + * Solaris 64 - use old-style cache format with 32-bit aligned fid for on-disk + * struct compatibility. + */ +typedef struct fid32 { + union { + int32_t fid_pad; + struct { + uint16_t len; /* length of data in bytes */ + char data[MAXFIDSZ]; /* data (variable len) */ + } _fid; + } un; +} fid32_t; +#else /* not _SYSCALL32 */ +#define fid32 fid +typedef fid_t fid32_t; +#endif /* _SYSCALL32 */ + +#define fid_len un._fid.len +#define fid_data un._fid.data + +/* + * Structure defining a mount option for a filesystem. + * option names are found in mntent.h + */ +typedef struct mntopt { + char *mo_name; /* option name */ + char **mo_cancel; /* list of options cancelled by this one */ + char *mo_arg; /* argument string for this option */ + int mo_flags; /* flags for this mount option */ + void *mo_data; /* filesystem specific data */ +} mntopt_t; + +/* + * Flags that apply to mount options + */ + +#define MO_SET 0x01 /* option is set */ +#define MO_NODISPLAY 0x02 /* option not listed in mnttab */ +#define MO_HASVALUE 0x04 /* option takes a value */ +#define MO_IGNORE 0x08 /* option ignored by parser */ +#define MO_DEFAULT MO_SET /* option is on by default */ +#define MO_TAG 0x10 /* flags a tag set by user program */ +#define MO_EMPTY 0x20 /* empty space in option table */ + +#define VFS_NOFORCEOPT 0x01 /* honor MO_IGNORE (don't set option) */ +#define VFS_DISPLAY 0x02 /* Turn off MO_NODISPLAY bit for opt */ +#define VFS_NODISPLAY 0x04 /* Turn on MO_NODISPLAY bit for opt */ +#define VFS_CREATEOPT 0x08 /* Create the opt if it's not there */ + +/* + * Structure holding mount option strings for the mounted file system. + */ +typedef struct mntopts { + uint_t mo_count; /* number of entries in table */ + mntopt_t *mo_list; /* list of mount options */ +} mntopts_t; + +/* + * The kstat structures associated with the vopstats are kept in an + * AVL tree. This is to avoid the case where a file system does not + * use a unique fsid_t for each vfs (e.g., namefs). In order to do + * this, we need a structure that the AVL tree can use that also + * references the kstat. + * Note that the vks_fsid is generated from the value reported by + * VFS_STATVFS(). + */ +typedef struct vskstat_anchor { + avl_node_t vsk_node; /* Required for use by AVL routines */ + kstat_t *vsk_ksp; /* kstat structure for vopstats */ + ulong_t vsk_fsid; /* fsid associated w/this FS */ +} vsk_anchor_t; + +extern avl_tree_t vskstat_tree; +extern kmutex_t vskstat_tree_lock; + +/* + * Structure per mounted file system. Each mounted file system has + * an array of operations and an instance record. + * + * The file systems are kept on a doubly linked circular list headed by + * "rootvfs". + * File system implementations should not access this list; + * it's intended for use only in the kernel's vfs layer. + * + * Each zone also has its own list of mounts, containing filesystems mounted + * somewhere within the filesystem tree rooted at the zone's rootpath. The + * list is doubly linked to match the global list. + * + * mnttab locking: the in-kernel mnttab uses the vfs_mntpt, vfs_resource and + * vfs_mntopts fields in the vfs_t. mntpt and resource are refstr_ts that + * are set at mount time and can only be modified during a remount. + * It is safe to read these fields if you can prevent a remount on the vfs, + * or through the convenience funcs vfs_getmntpoint() and vfs_getresource(). + * The mntopts field may only be accessed through the provided convenience + * functions, as it is protected by the vfs list lock. Modifying a mount + * option requires grabbing the vfs list write lock, which can be a very + * high latency lock. + */ +struct zone; /* from zone.h */ +struct fem_head; /* from fem.h */ + +typedef struct vfs { + struct vfs *vfs_next; /* next VFS in VFS list */ + struct vfs *vfs_prev; /* prev VFS in VFS list */ + +/* vfs_op should not be used directly. Accessor functions are provided */ + vfsops_t *vfs_op; /* operations on VFS */ + + struct vnode *vfs_vnodecovered; /* vnode mounted on */ + uint_t vfs_flag; /* flags */ + uint_t vfs_bsize; /* native block size */ + int vfs_fstype; /* file system type index */ + fsid_t vfs_fsid; /* file system id */ + void *vfs_data; /* private data */ + dev_t vfs_dev; /* device of mounted VFS */ + ulong_t vfs_bcount; /* I/O count (accounting) */ + struct vfs *vfs_list; /* sync list pointer */ + struct vfs *vfs_hash; /* hash list pointer */ + ksema_t vfs_reflock; /* mount/unmount/sync lock */ + uint_t vfs_count; /* vfs reference count */ + mntopts_t vfs_mntopts; /* options mounted with */ + refstr_t *vfs_resource; /* mounted resource name */ + refstr_t *vfs_mntpt; /* mount point name */ + time_t vfs_mtime; /* time we were mounted */ + struct vfs_impl *vfs_implp; /* impl specific data */ + /* + * Zones support. Note that the zone that "owns" the mount isn't + * necessarily the same as the zone in which the zone is visible. + * That is, vfs_zone and (vfs_zone_next|vfs_zone_prev) may refer to + * different zones. + */ + struct zone *vfs_zone; /* zone that owns the mount */ + struct vfs *vfs_zone_next; /* next VFS visible in zone */ + struct vfs *vfs_zone_prev; /* prev VFS visible in zone */ + + struct fem_head *vfs_femhead; /* fs monitoring */ + uint32_t vfs_lofi_id; /* ID if lofi mount */ +} vfs_t; + +#define vfs_featureset vfs_implp->vi_featureset +#define vfs_vskap vfs_implp->vi_vskap +#define vfs_fstypevsp vfs_implp->vi_fstypevsp +#define vfs_vopstats vfs_implp->vi_vopstats +#define vfs_hrctime vfs_implp->vi_hrctime + +/* + * VFS flags. + */ +#define VFS_RDONLY 0x01 /* read-only vfs */ +#define VFS_NOMNTTAB 0x02 /* vfs not seen in mnttab */ +#define VFS_NOSETUID 0x08 /* setuid disallowed */ +#define VFS_REMOUNT 0x10 /* modify mount options only */ +#define VFS_NOTRUNC 0x20 /* does not truncate long file names */ +#define VFS_UNLINKABLE 0x40 /* unlink(2) can be applied to root */ +#define VFS_PXFS 0x80 /* clustering: global fs proxy vfs */ +#define VFS_UNMOUNTED 0x100 /* file system has been unmounted */ +#define VFS_NBMAND 0x200 /* allow non-blocking mandatory locks */ +#define VFS_XATTR 0x400 /* fs supports extended attributes */ +#define VFS_NODEVICES 0x800 /* device-special files disallowed */ +#define VFS_NOEXEC 0x1000 /* executables disallowed */ +#define VFS_STATS 0x2000 /* file system can collect stats */ +#define VFS_XID 0x4000 /* file system supports extended ids */ + +#define VFS_NORESOURCE "unspecified_resource" +#define VFS_NOMNTPT "unspecified_mountpoint" + +/* + * VFS features are implemented as bits set in the vfs_t. + * The vfs_feature_t typedef is a 64-bit number that will translate + * into an element in an array of bitmaps and a bit in that element. + * Developers must not depend on the implementation of this and + * need to use vfs_has_feature()/vfs_set_feature() routines. + */ +typedef uint64_t vfs_feature_t; + +#define VFSFT_XVATTR 0x100000001 /* Supports xvattr for attrs */ +#define VFSFT_CASEINSENSITIVE 0x100000002 /* Supports case-insensitive */ +#define VFSFT_NOCASESENSITIVE 0x100000004 /* NOT case-sensitive */ +#define VFSFT_DIRENTFLAGS 0x100000008 /* Supports dirent flags */ +#define VFSFT_ACLONCREATE 0x100000010 /* Supports ACL on create */ +#define VFSFT_ACEMASKONACCESS 0x100000020 /* Can use ACEMASK for access */ +#define VFSFT_SYSATTR_VIEWS 0x100000040 /* Supports sysattr view i/f */ +#define VFSFT_ACCESS_FILTER 0x100000080 /* dirents filtered by access */ +#define VFSFT_REPARSE 0x100000100 /* Supports reparse point */ +#define VFSFT_ZEROCOPY_SUPPORTED 0x100000200 + /* Support loaning /returning cache buffer */ +/* + * Argument structure for mount(2). + * + * Flags are defined in . + * + * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in + * this structure are to be interpreted as kernel addresses. File systems + * should be prepared for this possibility. + */ +struct mounta { + char *spec; + char *dir; + int flags; + char *fstype; + char *dataptr; + int datalen; + char *optptr; + int optlen; +}; + +/* + * Reasons for calling the vfs_mountroot() operation. + */ +enum whymountroot { ROOT_INIT, ROOT_REMOUNT, ROOT_UNMOUNT}; +typedef enum whymountroot whymountroot_t; + +/* + * Reasons for calling the VFS_VNSTATE(): + */ +enum vntrans { + VNTRANS_EXISTS, + VNTRANS_IDLED, + VNTRANS_RECLAIMED, + VNTRANS_DESTROYED +}; +typedef enum vntrans vntrans_t; + +/* + * VFS_OPS defines all the vfs operations. It is used to define + * the vfsops structure (below) and the fs_func_p union (vfs_opreg.h). + */ +#define VFS_OPS \ + int (*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *); \ + int (*vfs_unmount)(vfs_t *, int, cred_t *); \ + int (*vfs_root)(vfs_t *, vnode_t **); \ + int (*vfs_statvfs)(vfs_t *, statvfs64_t *); \ + int (*vfs_sync)(vfs_t *, short, cred_t *); \ + int (*vfs_vget)(vfs_t *, vnode_t **, fid_t *); \ + int (*vfs_mountroot)(vfs_t *, enum whymountroot); \ + void (*vfs_freevfs)(vfs_t *); \ + int (*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t); \ + int (*vfs_syncfs)(vfs_t *, uint64_t, cred_t *) /* NB: No ";" */ + +/* + * Operations supported on virtual file system. + */ +struct vfsops { + VFS_OPS; /* Signature of all vfs operations (vfsops) */ +}; + +extern int fsop_mount(vfs_t *, vnode_t *, struct mounta *, cred_t *); +extern int fsop_unmount(vfs_t *, int, cred_t *); +extern int fsop_root(vfs_t *, vnode_t **); +extern int fsop_statfs(vfs_t *, statvfs64_t *); +extern int fsop_sync(vfs_t *, short, cred_t *); +extern int fsop_vget(vfs_t *, vnode_t **, fid_t *); +extern int fsop_mountroot(vfs_t *, enum whymountroot); +extern void fsop_freefs(vfs_t *); +extern int fsop_sync_by_kind(int, short, cred_t *); +extern int fsop_vnstate(vfs_t *, vnode_t *, vntrans_t); +extern int fsop_syncfs(vfs_t *, uint64_t, cred_t *); + +#define VFS_MOUNT(vfsp, mvp, uap, cr) fsop_mount(vfsp, mvp, uap, cr) +#define VFS_UNMOUNT(vfsp, flag, cr) fsop_unmount(vfsp, flag, cr) +#define VFS_ROOT(vfsp, vpp) fsop_root(vfsp, vpp) +#define VFS_STATVFS(vfsp, sp) fsop_statfs(vfsp, sp) +#define VFS_SYNC(vfsp, flag, cr) fsop_sync(vfsp, flag, cr) +#define VFS_VGET(vfsp, vpp, fidp) fsop_vget(vfsp, vpp, fidp) +#define VFS_MOUNTROOT(vfsp, init) fsop_mountroot(vfsp, init) +#define VFS_FREEVFS(vfsp) fsop_freefs(vfsp) +#define VFS_VNSTATE(vfsp, vn, ns) fsop_vnstate(vfsp, vn, ns) +#define VFS_SYNCFS(vfsp, flag, cr) fsop_syncfs(vfsp, flag, cr) + +#define VFSNAME_MOUNT "mount" +#define VFSNAME_UNMOUNT "unmount" +#define VFSNAME_ROOT "root" +#define VFSNAME_STATVFS "statvfs" +#define VFSNAME_SYNC "sync" +#define VFSNAME_VGET "vget" +#define VFSNAME_MOUNTROOT "mountroot" +#define VFSNAME_FREEVFS "freevfs" +#define VFSNAME_VNSTATE "vnstate" +#define VFSNAME_SYNCFS "syncfs" + +/* + * Filesystem type switch table. + */ + +typedef struct vfssw { + char *vsw_name; /* type name -- max len _ST_FSTYPSZ */ + int (*vsw_init) (int, char *); + /* init routine (for non-loadable fs only) */ + int vsw_flag; /* flags */ + mntopts_t vsw_optproto; /* mount options table prototype */ + uint_t vsw_count; /* count of references */ + kmutex_t vsw_lock; /* lock to protect vsw_count */ + vfsops_t vsw_vfsops; /* filesystem operations vector */ +} vfssw_t; + +/* + * Filesystem type definition record. All file systems must export a record + * of this type through their modlfs structure. N.B., changing the version + * number requires a change in sys/modctl.h. + */ + +typedef struct vfsdef_v5 { + int def_version; /* structure version, must be first */ + char *name; /* filesystem type name */ + int (*init) (int, char *); /* init routine */ + int flags; /* filesystem flags */ + mntopts_t *optproto; /* mount options table prototype */ +} vfsdef_v5; + +typedef struct vfsdef_v5 vfsdef_t; + +enum { + VFSDEF_VERSION = 5 +}; + +/* + * flags for vfssw and vfsdef + */ +#define VSW_HASPROTO 0x01 /* struct has a mount options prototype */ +#define VSW_CANRWRO 0x02 /* file system can transition from rw to ro */ +#define VSW_CANREMOUNT 0x04 /* file system supports remounts */ +#define VSW_NOTZONESAFE 0x08 /* zone_enter(2) should fail for these files */ +#define VSW_VOLATILEDEV 0x10 /* vfs_dev can change each time fs is mounted */ +#define VSW_STATS 0x20 /* file system can collect stats */ +#define VSW_XID 0x40 /* file system supports extended ids */ +#define VSW_CANLOFI 0x80 /* file system supports lofi mounts */ +#define VSW_ZMOUNT 0x100 /* file system always allowed in a zone */ +#define VSW_MOUNTDEV 0x200 /* file system is mounted via device path */ + +#define VSW_INSTALLED 0x8000 /* this vsw is associated with a file system */ + +/* + * A flag for vfs_setpath(). + */ +#define VFSSP_VERBATIM 0x1 /* do not prefix the supplied path */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * Private vfs data, NOT to be used by a file system implementation. + */ + +#define VFS_FEATURE_MAXSZ 4 + +typedef struct vfs_impl { + /* Counted array - Bitmap of vfs features */ + uint32_t vi_featureset[VFS_FEATURE_MAXSZ]; + /* + * Support for statistics on the vnode operations + */ + vsk_anchor_t *vi_vskap; /* anchor for vopstats' kstat */ + vopstats_t *vi_fstypevsp; /* ptr to per-fstype vopstats */ + vopstats_t vi_vopstats; /* per-mount vnode op stats */ + + timespec_t vi_hrctime; /* High-res creation time */ + + zone_ref_t vi_zone_ref; /* reference to zone */ +} vfs_impl_t; + +/* + * Public operations. + */ +struct umounta; +struct statvfsa; +struct fstatvfsa; + +void vfs_freevfsops(vfsops_t *); +int vfs_freevfsops_by_type(int); +void vfs_setops(vfs_t *, vfsops_t *); +vfsops_t *vfs_getops(vfs_t *vfsp); +int vfs_matchops(vfs_t *, vfsops_t *); +int vfs_can_sync(vfs_t *vfsp); +vfs_t *vfs_alloc(int); +void vfs_free(vfs_t *); +void vfs_init(vfs_t *vfsp, vfsops_t *, void *); +void vfsimpl_setup(vfs_t *vfsp); +void vfsimpl_teardown(vfs_t *vfsp); +void vn_exists(vnode_t *); +void vn_idle(vnode_t *); +void vn_reclaim(vnode_t *); +void vn_invalid(vnode_t *); + +int rootconf(void); +int domount(char *, struct mounta *, vnode_t *, struct cred *, + struct vfs **); +int dounmount(struct vfs *, int, cred_t *); +int vfs_lock(struct vfs *); +int vfs_rlock(struct vfs *); +void vfs_lock_wait(struct vfs *); +void vfs_rlock_wait(struct vfs *); +void vfs_unlock(struct vfs *); +int vfs_lock_held(struct vfs *); +struct _kthread *vfs_lock_owner(struct vfs *); +void sync(void); +void vfs_sync(int); +void vfs_mountroot(void); +void vfs_add(vnode_t *, struct vfs *, int); +void vfs_remove(struct vfs *); + +/* VFS feature routines */ +void vfs_set_feature(vfs_t *, vfs_feature_t); +void vfs_clear_feature(vfs_t *, vfs_feature_t); +int vfs_has_feature(vfs_t *, vfs_feature_t); +void vfs_propagate_features(vfs_t *, vfs_t *); + +/* The following functions are not for general use by filesystems */ + +void vfs_createopttbl(mntopts_t *, const char *); +void vfs_copyopttbl(const mntopts_t *, mntopts_t *); +void vfs_mergeopttbl(const mntopts_t *, const mntopts_t *, mntopts_t *); +void vfs_freeopttbl(mntopts_t *); +void vfs_parsemntopts(mntopts_t *, char *, int); +int vfs_buildoptionstr(const mntopts_t *, char *, int); +struct mntopt *vfs_hasopt(const mntopts_t *, const char *); +void vfs_mnttab_modtimeupd(void); + +void vfs_clearmntopt(struct vfs *, const char *); +void vfs_setmntopt(struct vfs *, const char *, const char *, int); +void vfs_setresource(struct vfs *, const char *, uint32_t); +void vfs_setmntpoint(struct vfs *, const char *, uint32_t); +refstr_t *vfs_getresource(const struct vfs *); +refstr_t *vfs_getmntpoint(const struct vfs *); +int vfs_optionisset(const struct vfs *, const char *, char **); +int vfs_settag(uint_t, uint_t, const char *, const char *, cred_t *); +int vfs_clrtag(uint_t, uint_t, const char *, const char *, cred_t *); +void vfs_syncall(void); +void vfsinit(void); +void vfs_unmountall(void); +void vfs_make_fsid(fsid_t *, dev_t, int); +void vfs_addmip(dev_t, struct vfs *); +void vfs_delmip(struct vfs *); +int vfs_devismounted(dev_t); +int vfs_devmounting(dev_t, struct vfs *); +int vfs_opsinuse(vfsops_t *); +struct vfs *getvfs(fsid_t *); +struct vfs *vfs_dev2vfsp(dev_t); +struct vfs *vfs_mntpoint2vfsp(const char *); +struct vfssw *allocate_vfssw(const char *); +struct vfssw *vfs_getvfssw(const char *); +struct vfssw *vfs_getvfsswbyname(const char *); +struct vfssw *vfs_getvfsswbyvfsops(vfsops_t *); +void vfs_refvfssw(struct vfssw *); +void vfs_unrefvfssw(struct vfssw *); +uint_t vf_to_stf(uint_t); +void vfs_mnttab_modtime(timespec_t *); +void vfs_mnttab_poll(timespec_t *, struct pollhead **); + +void vfs_list_lock(void); +void vfs_list_read_lock(void); +void vfs_list_unlock(void); +void vfs_list_add(struct vfs *); +void vfs_list_remove(struct vfs *); +void vfs_hold(vfs_t *vfsp); +void vfs_rele(vfs_t *vfsp); +void fs_freevfs(vfs_t *); +void vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype); + +int vfs_zone_change_safe(vfs_t *); + +int vfs_get_lofi(vfs_t *, vnode_t **); + +#define VFSHASH(maj, min) (((int)((maj)+(min))) & (vfshsz - 1)) +#define VFS_ON_LIST(vfsp) \ + ((vfsp)->vfs_next != (vfsp) && (vfsp)->vfs_next != NULL) + +/* + * Globals. + */ + +extern struct vfssw vfssw[]; /* table of filesystem types */ +extern krwlock_t vfssw_lock; +extern char rootfstype[]; /* name of root fstype */ +extern const int nfstype; /* # of elements in vfssw array */ +extern vfsops_t *EIO_vfsops; /* operations for vfs being torn-down */ + +/* + * The following variables are private to the the kernel's vfs layer. File + * system implementations should not access them. + */ +extern struct vfs *rootvfs; /* ptr to root vfs structure */ +typedef struct { + struct vfs *rvfs_head; /* head vfs in chain */ + kmutex_t rvfs_lock; /* mutex protecting this chain */ + uint32_t rvfs_len; /* length of this chain */ +} rvfs_t; +extern rvfs_t *rvfs_list; +extern int vfshsz; /* # of elements in rvfs_head array */ +extern const mntopts_t vfs_mntopts; /* globally recognized options */ + +#endif /* defined(_KERNEL) */ + +#define VFS_HOLD(vfsp) { \ + vfs_hold(vfsp); \ +} + +#define VFS_RELE(vfsp) { \ + vfs_rele(vfsp); \ +} + +#define VFS_INIT(vfsp, op, data) { \ + vfs_init((vfsp), (op), (data)); \ +} + + +#define VFS_INSTALLED(vfsswp) (((vfsswp)->vsw_flag & VSW_INSTALLED) != 0) +#define ALLOCATED_VFSSW(vswp) ((vswp)->vsw_name[0] != '\0') +#define RLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_READER)) +#define RUNLOCK_VFSSW() (rw_exit(&vfssw_lock)) +#define WLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_WRITER)) +#define WUNLOCK_VFSSW() (rw_exit(&vfssw_lock)) +#define VFSSW_LOCKED() (RW_LOCK_HELD(&vfssw_lock)) +#define VFSSW_WRITE_LOCKED() (RW_WRITE_HELD(&vfssw_lock)) +/* + * VFS_SYNC flags. + */ +#define SYNC_ATTR 0x01 /* sync attributes only */ +#define SYNC_CLOSE 0x02 /* close open file */ +#define SYNC_ALL 0x04 /* force to sync all fs */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VFS_H */ diff --git a/illumos-x86_64/usr/include/sys/vfs_opreg.h b/illumos-x86_64/usr/include/sys/vfs_opreg.h new file mode 100644 index 00000000..5ab9fca5 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vfs_opreg.h @@ -0,0 +1,114 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VFS_OPREG_H +#define _SYS_VFS_OPREG_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * The following union allows us to use C99's "designated initializer" + * feature so that we can have strong typechecking for the operations + * used in the the fs_operation_def structures. + */ + +typedef union fs_func { + fs_generic_func_p fs_generic; /* Generic function signature */ + int (*error)(); /* Signature of error function */ + VFS_OPS; /* Signatures of all vfs operations (vfsops) */ + VNODE_OPS; /* Signatures of all vnode operations (vops) */ + FEM_OPS; /* Signatures of all FEM operations (femops) */ + FSEM_OPS; /* Signatures of all FSEM ops (fsemops) */ +} fs_func_p; + +/* + * File systems use arrays of fs_operation_def structures to form + * name/value pairs of operations. These arrays get passed to: + * + * - vn_make_ops() to create vnodeops + * - vfs_makefsops()/vfs_setfsops() to create vfsops. + */ +typedef struct fs_operation_def { + char *name; /* name of operation (NULL at end) */ + fs_func_p func; /* function implementing operation */ +} fs_operation_def_t; + +/* + * The operation registration mechanism uses two master tables of operations: + * one for vnode operations (vn_ops_table[]) and one for vfs operations + * (vfs_ops_table[]). These tables are arrays of fs_operation_trans_def + * structures. They contain all of the information necessary for the system + * to populate an operations structure (e.g., vnodeops, vfsops). + * + * File systems call registration routines (vfs_setfsops(), vfs_makefsops(), + * and vn_make_ops()) and pass in their operations specification tables + * (arrays of fs_operation_def structures). These routines use the master + * table(s) of operations to build a vnodeops or vfsops structure. + */ +typedef struct fs_operation_trans_def { + char *name; /* name of operation (NULL at end) */ + size_t offset; /* byte offset within ops vector */ + fs_generic_func_p defaultFunc; /* default function */ + fs_generic_func_p errorFunc; /* error function */ +} fs_operation_trans_def_t; + +/* + * Generic operations vector types (used for vfs/vnode ops registration). + */ + +extern int fs_default(); /* "default" function placeholder */ +extern int fs_error(); /* "error" function placeholder */ + +int fs_build_vector(void *vector, int *unused_ops, + const fs_operation_trans_def_t *translation, + const fs_operation_def_t *operations); + +/* + * Public operations. + */ + +int vn_make_ops(const char *, const struct fs_operation_def *, + vnodeops_t **); +void vn_freevnodeops(vnodeops_t *); + +int vfs_setfsops(int, const fs_operation_def_t *, vfsops_t **); +int vfs_makefsops(const fs_operation_def_t *, vfsops_t **); +void vfs_freevfsops(vfsops_t *); +int vfs_freevfsops_by_type(int); + +#endif /* _KERNEL || _FAKE_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VFS_OPREG_H */ diff --git a/illumos-x86_64/usr/include/sys/vfstab.h b/illumos-x86_64/usr/include/sys/vfstab.h new file mode 100644 index 00000000..226c6d93 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vfstab.h @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_VFSTAB_H +#define _SYS_VFSTAB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define VFSTAB "/etc/vfstab" +#define VFS_LINE_MAX 1024 + +#define VFS_TOOLONG 1 /* entry exceeds VFS_LINE_MAX */ +#define VFS_TOOMANY 2 /* too many fields in line */ +#define VFS_TOOFEW 3 /* too few fields in line */ + +#define vfsnull(vp) ((vp)->vfs_special = (vp)->vfs_fsckdev = \ + (vp)->vfs_mountp = (vp)->vfs_fstype = \ + (vp)->vfs_fsckpass = (vp)->vfs_automnt = \ + (vp)->vfs_mntopts = NULL) + +#define putvfsent(fd, vp)\ + fprintf((fd), "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", \ + (vp)->vfs_special ? (vp)->vfs_special : "-", \ + (vp)->vfs_fsckdev ? (vp)->vfs_fsckdev : "-", \ + (vp)->vfs_mountp ? (vp)->vfs_mountp : "-", \ + (vp)->vfs_fstype ? (vp)->vfs_fstype : "-", \ + (vp)->vfs_fsckpass ? (vp)->vfs_fsckpass : "-", \ + (vp)->vfs_automnt ? (vp)->vfs_automnt : "-", \ + (vp)->vfs_mntopts ? (vp)->vfs_mntopts : "-") + +struct vfstab { + char *vfs_special; + char *vfs_fsckdev; + char *vfs_mountp; + char *vfs_fstype; + char *vfs_fsckpass; + char *vfs_automnt; + char *vfs_mntopts; +}; + +extern int getvfsent(FILE *, struct vfstab *); +extern int getvfsspec(FILE *, struct vfstab *, char *); +extern int getvfsfile(FILE *, struct vfstab *, char *); +extern int getvfsany(FILE *, struct vfstab *, struct vfstab *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VFSTAB_H */ diff --git a/illumos-x86_64/usr/include/sys/videodev2.h b/illumos-x86_64/usr/include/sys/videodev2.h new file mode 100644 index 00000000..f675901c --- /dev/null +++ b/illumos-x86_64/usr/include/sys/videodev2.h @@ -0,0 +1,1429 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef __LINUX_VIDEODEV2_H +#define __LINUX_VIDEODEV2_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Video for Linux Two + * + * Header file for v4l or V4L2 drivers and applications + * with public API. + * All kernel-specific stuff were moved to media/v4l2-dev.h, so + * no #if __KERNEL tests are allowed here + * + * See http://linuxtv.org for more info + * + * Author: Bill Dirks + * Justin Schoeman + * et al. + */ + +#include + +/* + * Common stuff for both V4L1 and V4L2 + * Moved from videodev.h + */ +#define VIDEO_MAX_FRAME 32 + +#define VID_TYPE_CAPTURE 1 /* Can capture */ +#define VID_TYPE_TUNER 2 /* Can tune */ +#define VID_TYPE_TELETEXT 4 /* Does teletext */ +#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */ +#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */ +#define VID_TYPE_CLIPPING 32 /* Can clip */ +#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */ +#define VID_TYPE_SCALES 128 /* Scalable */ +#define VID_TYPE_MONOCHROME 256 /* Monochrome only */ +#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */ +#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */ +#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ +#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ +#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ + +/* + * M I S C E L L A N E O U S + */ + +/* Four-character-code (FOURCC) */ +#define v4l2_fourcc(a, b, c, d) \ + (((uint32_t)(a)<<0) | ((uint32_t)(b)<<8) | \ + ((uint32_t)(c)<<16)|((uint32_t)(d)<<24)) + +/* + * E N U M S + */ +enum v4l2_field { + + /* + * driver can choose from none, top, bottom, interlaced + * depending on whatever it thinks is approximate ... + */ + V4L2_FIELD_ANY = 0, + V4L2_FIELD_NONE = 1, /* this device has no fields ... */ + V4L2_FIELD_TOP = 2, /* top field only */ + V4L2_FIELD_BOTTOM = 3, /* bottom field only */ + V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ + + /* both fields sequential into one buffer, top-bottom order */ + V4L2_FIELD_SEQ_TB = 5, + + V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ + + /* both fields alternating into separate buffers */ + V4L2_FIELD_ALTERNATE = 7 +}; +#define V4L2_FIELD_HAS_TOP(field) \ + ((field) == V4L2_FIELD_TOP || \ + (field) == V4L2_FIELD_INTERLACED || \ + (field) == V4L2_FIELD_SEQ_TB || \ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTTOM(field) \ + ((field) == V4L2_FIELD_BOTTOM || \ + (field) == V4L2_FIELD_INTERLACED || \ + (field) == V4L2_FIELD_SEQ_TB || \ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTH(field) \ + ((field) == V4L2_FIELD_INTERLACED || \ + (field) == V4L2_FIELD_SEQ_TB || \ + (field) == V4L2_FIELD_SEQ_BT) + +enum v4l2_buf_type { + V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, + V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, + V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, + V4L2_BUF_TYPE_VBI_CAPTURE = 4, + V4L2_BUF_TYPE_VBI_OUTPUT = 5, +#if 1 + /* Experimental Sliced VBI */ + V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, + V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, +#endif + V4L2_BUF_TYPE_PRIVATE = 0x80 +}; + +enum v4l2_ctrl_type { + V4L2_CTRL_TYPE_INTEGER = 1, + V4L2_CTRL_TYPE_BOOLEAN = 2, + V4L2_CTRL_TYPE_MENU = 3, + V4L2_CTRL_TYPE_BUTTON = 4, + V4L2_CTRL_TYPE_INTEGER64 = 5, + V4L2_CTRL_TYPE_CTRL_CLASS = 6 +}; + +enum v4l2_tuner_type { + V4L2_TUNER_RADIO = 1, + V4L2_TUNER_ANALOG_TV = 2, + V4L2_TUNER_DIGITAL_TV = 3 +}; + +enum v4l2_memory { + V4L2_MEMORY_MMAP = 1, + V4L2_MEMORY_USERPTR = 2, + V4L2_MEMORY_OVERLAY = 3 +}; + +/* see also http: vektor.theorem.ca/graphics/ycbcr/ */ +enum v4l2_colorspace { + /* ITU-R 601 -- broadcast NTSC/PAL */ + V4L2_COLORSPACE_SMPTE170M = 1, + + /* 1125-Line (US) HDTV */ + V4L2_COLORSPACE_SMPTE240M = 2, + + /* HD and modern captures. */ + V4L2_COLORSPACE_REC709 = 3, + + /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */ + V4L2_COLORSPACE_BT878 = 4, + + /* These should be useful. Assume 601 extents. */ + V4L2_COLORSPACE_470_SYSTEM_M = 5, + V4L2_COLORSPACE_470_SYSTEM_BG = 6, + + /* + * I know there will be cameras that send this. So, this is + * unspecified chromaticities and full 0-255 on each of the + * Y'CbCr components + */ + V4L2_COLORSPACE_JPEG = 7, + + /* For RGB colourspaces, this is probably a good start. */ + V4L2_COLORSPACE_SRGB = 8 +}; + +enum v4l2_priority { + V4L2_PRIORITY_UNSET = 0, /* not initialized */ + V4L2_PRIORITY_BACKGROUND = 1, + V4L2_PRIORITY_INTERACTIVE = 2, + V4L2_PRIORITY_RECORD = 3, + V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE +}; + +struct v4l2_rect { + int32_t left; + int32_t top; + int32_t width; + int32_t height; +}; + +struct v4l2_fract { + uint32_t numerator; + uint32_t denominator; +}; + +/* + * D R I V E R C A P A B I L I T I E S + */ +struct v4l2_capability +{ + uint8_t driver[16]; /* i.e. "bttv" */ + uint8_t card[32]; /* i.e. "Hauppauge WinTV" */ + uint8_t bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ + uint32_t version; /* should use KERNEL_VERSION() */ + uint32_t capabilities; /* Device capabilities */ + uint32_t reserved[4]; +}; + +/* Values for 'capabilities' field */ + +/* Is a video capture device */ +#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 + +/* Is a video output device */ +#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 +#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ + +/* Is a raw VBI capture device */ +#define V4L2_CAP_VBI_CAPTURE 0x00000010 + +/* Is a raw VBI output device */ +#define V4L2_CAP_VBI_OUTPUT 0x00000020 +#if 1 + +/* Is a sliced VBI capture device */ +#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 + +/* Is a sliced VBI output device */ +#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 +#endif +#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ + +#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ +#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ +#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ + +#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ +#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ +#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ + +/* + * V I D E O I M A G E F O R M A T + */ +struct v4l2_pix_format +{ + uint32_t width; + uint32_t height; + uint32_t pixelformat; + enum v4l2_field field; + uint32_t bytesperline; /* for padding, zero if unused */ + uint32_t sizeimage; + enum v4l2_colorspace colorspace; + uint32_t priv; /* private data, depends on pixelformat */ +}; + +/* Pixel format FOURCC depth Description */ +#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */ +#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */ +#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') /* 16 RGB-5-6-5 */ + +/* 16 RGB-5-5-5 BE */ +#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') + +/* 16 RGB-5-6-5 BE */ +#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') + +#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */ +#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */ +#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */ +#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */ +#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ +#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */ +#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */ +#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */ + +/* 16 YVU422 planar */ +#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') + +/* 16 YVU411 planar */ +#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') + +#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ + +/* two planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ +#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */ + +/* The following formats are not defined in the V4L2 specification */ +#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */ +#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */ +#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit colo */ + +/* 8 YUV 4:1:1 16x16 macroblocks */ +#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') + +/* see www.siliconimaging.com/RGB%20Bayer.htm */ + +/* 8 BGBG.. GRGR.. */ +#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') + +/* compressed formats */ + +/* Motion-JPEG */ +#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') +#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG */ +#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd') /* 1394 */ +#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 */ + +/* Vendor-specific formats */ + +/* Winnov hw compress */ +#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') + +/* SN9C10x compression */ +#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') + +/* pwc older webcam */ +#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1') + +/* pwc newer webcam */ +#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2') + +/* ET61X251 compression */ +#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5') + +/* + * F O R M A T E N U M E R A T I O N + */ +struct v4l2_fmtdesc +{ + uint32_t index; /* Format number */ + enum v4l2_buf_type type; /* buffer type */ + uint32_t flags; + char description[32]; /* Description string */ + uint32_t pixelformat; /* Format fourcc */ + uint32_t reserved[4]; +}; + +#define V4L2_FMT_FLAG_COMPRESSED 0x0001 + +/* + * T I M E C O D E + */ +struct v4l2_timecode +{ + uint32_t type; + uint32_t flags; + uint8_t frames; + uint8_t seconds; + uint8_t minutes; + uint8_t hours; + uint8_t userbits[4]; +}; + +/* Type */ +#define V4L2_TC_TYPE_24FPS 1 +#define V4L2_TC_TYPE_25FPS 2 +#define V4L2_TC_TYPE_30FPS 3 +#define V4L2_TC_TYPE_50FPS 4 +#define V4L2_TC_TYPE_60FPS 5 + +/* Flags */ +#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */ +#define V4L2_TC_FLAG_COLORFRAME 0x0002 +#define V4L2_TC_USERBITS_field 0x000C +#define V4L2_TC_USERBITS_USERDEFINED 0x0000 +#define V4L2_TC_USERBITS_8BITCHARS 0x0008 +/* The above is based on SMPTE timecodes */ + +#ifdef __KERNEL__ +/* + * M P E G C O M P R E S S I O N P A R A M E T E R S + * + * ### WARNING: This experimental MPEG compression API is obsolete. + * ### It is replaced by the MPEG controls API. + * ### This old API will disappear in the near future! + * + */ +enum v4l2_bitrate_mode { + V4L2_BITRATE_NONE = 0, /* not specified */ + V4L2_BITRATE_CBR, /* constant bitrate */ + V4L2_BITRATE_VBR /* variable bitrate */ +}; +struct v4l2_bitrate { + /* rates are specified in kbit/sec */ + enum v4l2_bitrate_mode mode; + uint32_t min; + uint32_t target; /* use this one for CBR */ + uint32_t max; +}; + +enum v4l2_mpeg_streamtype { + V4L2_MPEG_SS_1, /* MPEG-1 system stream */ + V4L2_MPEG_PS_2, /* MPEG-2 program stream */ + V4L2_MPEG_TS_2, /* MPEG-2 transport stream */ + + /* MPEG-2 program stream with DVD header fixups */ + V4L2_MPEG_PS_DVD +}; +enum v4l2_mpeg_audiotype { + V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */ + V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */ + V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */ + V4L2_MPEG_AC3, /* AC3 */ + V4L2_MPEG_LPCM /* LPCM */ +}; +enum v4l2_mpeg_videotype { + V4L2_MPEG_VI_1, /* MPEG-1 */ + V4L2_MPEG_VI_2 /* MPEG-2 */ +}; +enum v4l2_mpeg_aspectratio { + V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */ + V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */ + V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */ + V4L2_MPEG_ASPECT_1_221 = 4 /* 1 : 2,21 */ +}; + +struct v4l2_mpeg_compression { + /* general */ + enum v4l2_mpeg_streamtype st_type; + struct v4l2_bitrate st_bitrate; + + /* transport streams */ + uint16_t ts_pid_pmt; + uint16_t ts_pid_audio; + uint16_t ts_pid_video; + uint16_t ts_pid_pcr; + + /* program stream */ + uint16_t ps_size; + uint16_t reserved_1; /* align */ + + /* audio */ + enum v4l2_mpeg_audiotype au_type; + struct v4l2_bitrate au_bitrate; + uint32_t au_sample_rate; + uint8_t au_pesid; + uint8_t reserved_2[3]; /* align */ + + /* video */ + enum v4l2_mpeg_videotype vi_type; + enum v4l2_mpeg_aspectratio vi_aspect_ratio; + struct v4l2_bitrate vi_bitrate; + uint32_t vi_frame_rate; + uint16_t vi_frames_per_gop; + uint16_t vi_bframes_count; + uint8_t vi_pesid; + uint8_t reserved_3[3]; /* align */ + + /* misc flags */ + uint32_t closed_gops:1; + uint32_t pulldown:1; + uint32_t reserved_4:30; /* align */ + + /* I don't expect the above being perfect yet ;) */ + uint32_t reserved_5[8]; +}; +#endif + +struct v4l2_jpegcompression +{ + int quality; + + /* Number of APP segment to be written, must be 0..15 */ + int APPn; + + int APP_len; /* Length of data in JPEG APPn segment */ + char APP_data[60]; /* Data in the JPEG APPn segment. */ + + int COM_len; /* Length of data in JPEG COM segment */ + char COM_data[60]; /* Data in JPEG COM segment */ + + /* + * Which markers should go into the JPEG output. Unless you exactly + * know what you do, leave them untouched. Inluding less markers will + * make the resulting code smaller, but there will be fewer + * aplications which can read it. The presence of the APP and COM + * marker is influenced by APP_len and COM_len + * ONLY, not by this property! + */ + uint32_t jpeg_markers; + +#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */ +#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */ +#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ +#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */ + +/* App segment, driver will allways use APP0 */ +#define V4L2_JPEG_MARKER_APP (1<<7) +}; + +/* + * M E M O R Y - M A P P I N G B U F F E R S + */ +struct v4l2_requestbuffers +{ + uint32_t count; + enum v4l2_buf_type type; + enum v4l2_memory memory; + uint32_t reserved[2]; +}; + +/* + * this structure is defined to replace timeval structure which includes + * "long" type elements + */ +struct v4l2_timeval { + uint64_t tv_sec; /* seconds */ + uint64_t tv_usec; /* and microseconds */ +}; + +/* this structure is now 64bits alignment */ +struct v4l2_buffer +{ + uint32_t index; + uint32_t bytesused; + enum v4l2_buf_type type; + enum v4l2_field field; + struct v4l2_timeval timestamp; + struct v4l2_timecode timecode; + uint32_t flags; + uint32_t sequence; + union { + uint32_t offset; + uint64_t userptr; + } m; + /* memory location */ + enum v4l2_memory memory; + uint32_t length; + uint32_t input; + uint32_t reserved; +}; + +/* Flags for 'flags' field */ +#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */ +#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */ +#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */ +#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */ +#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */ +#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */ +#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ +#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */ + +/* + * O V E R L A Y P R E V I E W + */ +struct v4l2_framebuffer +{ + uint32_t capability; + uint32_t flags; +/* + * FIXME: in theory we should pass something like PCI device + memory + * region + offset instead of some physical address + */ + void* base; + struct v4l2_pix_format fmt; +}; +/* Flags for the 'capability' field. Read only */ +#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001 +#define V4L2_FBUF_CAP_CHROMAKEY 0x0002 +#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004 +#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 +/* Flags for the 'flags' field. */ +#define V4L2_FBUF_FLAG_PRIMARY 0x0001 +#define V4L2_FBUF_FLAG_OVERLAY 0x0002 +#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 + +struct v4l2_clip +{ + struct v4l2_rect c; + struct v4l2_clip *next; /* __user */ +}; + +struct v4l2_window +{ + struct v4l2_rect w; + enum v4l2_field field; + uint32_t chromakey; + struct v4l2_clip *clips; /* __user */ + uint32_t clipcount; + void *bitmap; /* __user */ +}; + +/* + * C A P T U R E P A R A M E T E R S + */ +struct v4l2_captureparm +{ + uint32_t capability; /* Supported modes */ + uint32_t capturemode; /* Current mode */ + + /* Time per frame in .1us units */ + struct v4l2_fract timeperframe; + uint32_t extendedmode; /* Driver-specific extensions */ + uint32_t readbuffers; /* # of buffers for read */ + uint32_t reserved[4]; +}; + +/* Flags for 'capability' and 'capturemode' fields */ +#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ +#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ + +struct v4l2_outputparm +{ + uint32_t capability; /* Supported modes */ + uint32_t outputmode; /* Current mode */ + + /* Time per frame in seconds */ + struct v4l2_fract timeperframe; + uint32_t extendedmode; /* Driver-specific extensions */ + uint32_t writebuffers; /* # of buffers for write */ + uint32_t reserved[4]; +}; + +/* + * I N P U T I M A G E C R O P P I N G + */ +struct v4l2_cropcap { + enum v4l2_buf_type type; + struct v4l2_rect bounds; + struct v4l2_rect defrect; + struct v4l2_fract pixelaspect; +}; + +struct v4l2_crop { + enum v4l2_buf_type type; + struct v4l2_rect c; +}; + +/* + * A N A L O G V I D E O S T A N D A R D + */ + +typedef uint64_t v4l2_std_id; + +/* one bit for each */ +#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001) +#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002) +#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004) +#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008) +#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010) +#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020) +#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040) +#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080) + +#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100) +#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200) +#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400) +#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800) + +#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000) +#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000) +#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000) +#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000) + +#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000) +#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000) +#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000) +#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000) +#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000) +#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000) +#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000) +#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000) + +/* ATSC/HDTV */ +#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) +#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) + +/* some merged standards */ +#define V4L2_STD_MN \ + (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) +#define V4L2_STD_B \ + (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) +#define V4L2_STD_GH \ + (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) +#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK) + +/* some common needed stuff */ +#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ + V4L2_STD_PAL_B1 |\ + V4L2_STD_PAL_G) +#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\ + V4L2_STD_PAL_D1 |\ + V4L2_STD_PAL_K) +#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\ + V4L2_STD_PAL_DK |\ + V4L2_STD_PAL_H |\ + V4L2_STD_PAL_I) +#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\ + V4L2_STD_NTSC_M_JP |\ + V4L2_STD_NTSC_M_KR) +#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\ + V4L2_STD_SECAM_K |\ + V4L2_STD_SECAM_K1) +#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\ + V4L2_STD_SECAM_G |\ + V4L2_STD_SECAM_H |\ + V4L2_STD_SECAM_DK |\ + V4L2_STD_SECAM_L |\ + V4L2_STD_SECAM_LC) + +#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\ + V4L2_STD_PAL_60 |\ + V4L2_STD_NTSC |\ + V4L2_STD_NTSC_443) +#define V4L2_STD_625_50 (V4L2_STD_PAL |\ + V4L2_STD_PAL_N |\ + V4L2_STD_PAL_Nc |\ + V4L2_STD_SECAM) +#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\ + V4L2_STD_ATSC_16_VSB) + +#define V4L2_STD_UNKNOWN 0 +#define V4L2_STD_ALL (V4L2_STD_525_60 |\ + V4L2_STD_625_50) + +/* + * On amd64, use pack(4) to make structures match the x86 alignment rules. + */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +struct v4l2_standard +{ + uint32_t index; + v4l2_std_id id; + uint8_t name[24]; + struct v4l2_fract frameperiod; /* Frames, not fields */ + uint32_t framelines; + uint32_t reserved[4]; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* + * V I D E O I N P U T S + */ +struct v4l2_input +{ + uint8_t name[32]; /* Label */ + uint32_t index; /* Which input */ + uint32_t type; /* Type of input */ + uint32_t audioset; /* Associated audios (bitfield) */ + uint32_t tuner; /* Associated tuner */ + v4l2_std_id std; + uint32_t status; + + /* + * Added for 64bits alignment, or, ENUMINPUT ioctl will fail. Because + * 32 bits app and 64bits driver will get different structure size + * which cause the values of ENUMINPUT are different. v4l2_input has a + * 64-bit element which make v4l2_input structure has to be 64bit + * alignment. + */ + uint32_t pad; + + uint32_t reserved[4]; +}; + +/* Values for the 'type' field */ +#define V4L2_INPUT_TYPE_TUNER 1 +#define V4L2_INPUT_TYPE_CAMERA 2 + +/* field 'status' - general */ +#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */ +#define V4L2_IN_ST_NO_SIGNAL 0x00000002 +#define V4L2_IN_ST_NO_COLOR 0x00000004 + +/* field 'status' - analog */ +#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ +#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ + +/* field 'status' - digital */ +#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */ +#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */ +#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */ + +/* field 'status' - VCR and set-top box */ +#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */ +#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */ +#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */ + +/* + * V I D E O O U T P U T S + */ +struct v4l2_output +{ + uint32_t index; /* Which output */ + uint8_t name[32]; /* Label */ + uint32_t type; /* Type of output */ + uint32_t audioset; /* Associated audios (bitfield) */ + uint32_t modulator; /* Associated modulator */ + v4l2_std_id std; + uint32_t reserved[4]; +}; +/* Values for the 'type' field */ +#define V4L2_OUTPUT_TYPE_MODULATOR 1 +#define V4L2_OUTPUT_TYPE_ANALOG 2 +#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 + +/* + * C O N T R O L S + */ +struct v4l2_control +{ + uint32_t id; + int32_t value; +}; + +struct v4l2_ext_control +{ + uint32_t id; + uint32_t reserved2[2]; + union { + int32_t value; + int64_t value64; + void *reserved; + } value; +}; /* __attribute__ ((packed)), comment for solaris to compile */ + +struct v4l2_ext_controls +{ + uint32_t ctrl_class; + uint32_t count; + uint32_t error_idx; + uint32_t reserved[2]; + struct v4l2_ext_control *controls; +}; + +/* Values for ctrl_class field */ +#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ +#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ + +#define V4L2_CTRL_ID_MASK (0x0fffffff) +#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) +#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) + +/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ +struct v4l2_queryctrl +{ + uint32_t id; + enum v4l2_ctrl_type type; + char name[32]; /* Whatever */ + int32_t minimum; /* Note signedness */ + int32_t maximum; + int32_t step; + int32_t default_value; + uint32_t flags; + uint32_t reserved[2]; +}; + +/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ +struct v4l2_querymenu +{ + uint32_t id; + uint32_t index; + uint8_t name[32]; /* Whatever */ + uint32_t reserved; +}; + +/* Control flags */ +#define V4L2_CTRL_FLAG_DISABLED 0x0001 +#define V4L2_CTRL_FLAG_GRABBED 0x0002 +#define V4L2_CTRL_FLAG_READ_ONLY 0x0004 +#define V4L2_CTRL_FLAG_UPDATE 0x0008 +#define V4L2_CTRL_FLAG_INACTIVE 0x0010 +#define V4L2_CTRL_FLAG_SLIDER 0x0020 + +/* Query flag, to be ORed with the control ID */ +#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 + +/* User-class control IDs defined by V4L2 */ +#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) +#define V4L2_CID_USER_BASE V4L2_CID_BASE +/* IDs reserved for driver specific controls */ +#define V4L2_CID_PRIVATE_BASE 0x08000000 + +#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) +#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0) +#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) +#define V4L2_CID_SATURATION (V4L2_CID_BASE+2) +#define V4L2_CID_HUE (V4L2_CID_BASE+3) +#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5) +#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6) +#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7) +#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) +#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) +#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) +#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) +#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) +#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) +#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) +#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) +#define V4L2_CID_GAMMA (V4L2_CID_BASE+16) +#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */ +#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) +#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) +#define V4L2_CID_GAIN (V4L2_CID_BASE+19) +#define V4L2_CID_HFLIP (V4L2_CID_BASE+20) +#define V4L2_CID_VFLIP (V4L2_CID_BASE+21) +#define V4L2_CID_HCENTER (V4L2_CID_BASE+22) +#define V4L2_CID_VCENTER (V4L2_CID_BASE+23) +#define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */ + +/* MPEG-class control IDs defined by V4L2 */ +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) + +/* MPEG streams */ +#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0) +enum v4l2_mpeg_stream_type { + V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5 /* MPEG-2 SVCD-compatible stream */ +}; +#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1) +#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2) +#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3) +#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4) +#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5) +#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6) +#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7) +enum v4l2_mpeg_stream_vbi_fmt { + V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */ + + /* VBI in private packets, IVTV format */ + V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1 +}; + +/* MPEG audio */ +#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100) +enum v4l2_mpeg_audio_sampling_freq { + V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2 +}; +#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101) +enum v4l2_mpeg_audio_encoding { + V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, + V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, + V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2 +}; +#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) +enum v4l2_mpeg_audio_l1_bitrate { + V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1, + V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2, + V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3, + V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4, + V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5, + V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6, + V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7, + V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8, + V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9, + V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10, + V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11, + V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12, + V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13 +}; +#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103) +enum v4l2_mpeg_audio_l2_bitrate { + V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1, + V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2, + V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3, + V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4, + V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5, + V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6, + V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7, + V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8, + V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9, + V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10, + V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11, + V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12, + V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13 +}; +#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104) +enum v4l2_mpeg_audio_l3_bitrate { + V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1, + V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2, + V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3, + V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4, + V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5, + V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6, + V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7, + V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8, + V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9, + V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10, + V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11, + V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12, + V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13 +}; +#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105) +enum v4l2_mpeg_audio_mode { + V4L2_MPEG_AUDIO_MODE_STEREO = 0, + V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1, + V4L2_MPEG_AUDIO_MODE_DUAL = 2, + V4L2_MPEG_AUDIO_MODE_MONO = 3 +}; +#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106) +enum v4l2_mpeg_audio_mode_extension { + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3 +}; +#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107) +enum v4l2_mpeg_audio_emphasis { + V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0, + V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1, + V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2 +}; +#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108) +enum v4l2_mpeg_audio_crc { + V4L2_MPEG_AUDIO_CRC_NONE = 0, + V4L2_MPEG_AUDIO_CRC_CRC16 = 1 +}; + +/* MPEG video */ +#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) +enum v4l2_mpeg_video_encoding { + V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, + V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1 +}; +#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) +enum v4l2_mpeg_video_aspect { + V4L2_MPEG_VIDEO_ASPECT_1x1 = 0, + V4L2_MPEG_VIDEO_ASPECT_4x3 = 1, + V4L2_MPEG_VIDEO_ASPECT_16x9 = 2, + V4L2_MPEG_VIDEO_ASPECT_221x100 = 3 +}; +#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202) +#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203) +#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204) +#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205) +#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206) +enum v4l2_mpeg_video_bitrate_mode { + V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, + V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1 +}; +#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) +#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) +#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) + +/* MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */ +#define V4L2_CID_MPEG_CX2341X_BASE \ + (V4L2_CTRL_CLASS_MPEG | 0x1000) +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE \ + (V4L2_CID_MPEG_CX2341X_BASE+0) +enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1 +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER \ + (V4L2_CID_MPEG_CX2341X_BASE+1) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE \ + (V4L2_CID_MPEG_CX2341X_BASE+2) +enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = + 4 +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE \ + (V4L2_CID_MPEG_CX2341X_BASE+3) +enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1 +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE \ + (V4L2_CID_MPEG_CX2341X_BASE+4) +enum v4l2_mpeg_cx2341x_video_temporal_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1 +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER \ + (V4L2_CID_MPEG_CX2341X_BASE+5) +#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE \ + (V4L2_CID_MPEG_CX2341X_BASE+6) +enum v4l2_mpeg_cx2341x_video_median_filter_type { + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4 +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM \ + (V4L2_CID_MPEG_CX2341X_BASE+7) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP \ + (V4L2_CID_MPEG_CX2341X_BASE+8) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM \ + (V4L2_CID_MPEG_CX2341X_BASE+9) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP \ + (V4L2_CID_MPEG_CX2341X_BASE+10) + +/* + * T U N I N G + */ +struct v4l2_tuner +{ + uint32_t index; + uint8_t name[32]; + enum v4l2_tuner_type type; + uint32_t capability; + uint32_t rangelow; + uint32_t rangehigh; + uint32_t rxsubchans; + uint32_t audmode; + int32_t signal; + int32_t afc; + uint32_t reserved[4]; +}; + +struct v4l2_modulator +{ + uint32_t index; + uint8_t name[32]; + uint32_t capability; + uint32_t rangelow; + uint32_t rangehigh; + uint32_t txsubchans; + uint32_t reserved[4]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_TUNER_CAP_LOW 0x0001 +#define V4L2_TUNER_CAP_NORM 0x0002 +#define V4L2_TUNER_CAP_STEREO 0x0010 +#define V4L2_TUNER_CAP_LANG2 0x0020 +#define V4L2_TUNER_CAP_SAP 0x0020 +#define V4L2_TUNER_CAP_LANG1 0x0040 + +/* Flags for the 'rxsubchans' field */ +#define V4L2_TUNER_SUB_MONO 0x0001 +#define V4L2_TUNER_SUB_STEREO 0x0002 +#define V4L2_TUNER_SUB_LANG2 0x0004 +#define V4L2_TUNER_SUB_SAP 0x0004 +#define V4L2_TUNER_SUB_LANG1 0x0008 + +/* Values for the 'audmode' field */ +#define V4L2_TUNER_MODE_MONO 0x0000 +#define V4L2_TUNER_MODE_STEREO 0x0001 +#define V4L2_TUNER_MODE_LANG2 0x0002 +#define V4L2_TUNER_MODE_SAP 0x0002 +#define V4L2_TUNER_MODE_LANG1 0x0003 +#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 + +struct v4l2_frequency +{ + uint32_t tuner; + enum v4l2_tuner_type type; + uint32_t frequency; + uint32_t reserved[8]; +}; + +/* + * A U D I O + */ +struct v4l2_audio +{ + uint32_t index; + uint8_t name[32]; + uint32_t capability; + uint32_t mode; + uint32_t reserved[2]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_AUDCAP_STEREO 0x00001 +#define V4L2_AUDCAP_AVL 0x00002 + +/* Flags for the 'mode' field */ +#define V4L2_AUDMODE_AVL 0x00001 + +struct v4l2_audioout +{ + uint32_t index; + uint8_t name[32]; + uint32_t capability; + uint32_t mode; + uint32_t reserved[2]; +}; + +/* + * D A T A S E R V I C E S ( V B I ) + * + * Data services API by Michael Schimek + */ + +/* Raw VBI */ +struct v4l2_vbi_format +{ + uint32_t sampling_rate; /* in 1 Hz */ + uint32_t offset; + uint32_t samples_per_line; + uint32_t sample_format; /* V4L2_PIX_FMT_* */ + int32_t start[2]; + uint32_t count[2]; + uint32_t flags; /* V4L2_VBI_* */ + uint32_t reserved[2]; /* must be zero */ +}; + +/* VBI flags */ +#define V4L2_VBI_UNSYNC (1<< 0) +#define V4L2_VBI_INTERLACED (1<< 1) + +#if 1 +/* + * Sliced VBI + * + * This implements is a proposal V4L2 API to allow SLICED VBI + * required for some hardware encoders. It should change without + * notice in the definitive implementation. + */ + +struct v4l2_sliced_vbi_format +{ + uint16_t service_set; + + /* + * service_lines[0][...] specifies lines 0-23 (1-23 used) of the first + * field + * service_lines[1][...] specifies lines 0-23 (1-23 used) of the second + * field + * (equals frame lines 313-336 for 625 line video standards, + * 263-286 for 525 line standards) + */ + uint16_t service_lines[2][24]; + uint32_t io_size; + uint32_t reserved[2]; /* must be zero */ +}; + +/* + * Teletext World System Teletext + * (WST), defined on ITU-R BT.653-2 + */ +#define V4L2_SLICED_TELETEXT_B (0x0001) +/* Video Program System, defined on ETS 300 231 */ +#define V4L2_SLICED_VPS (0x0400) +/* Closed Caption, defined on EIA-608 */ +#define V4L2_SLICED_CAPTION_525 (0x1000) +/* Wide Screen System, defined on ITU-R BT1119.1 */ +#define V4L2_SLICED_WSS_625 (0x4000) + +#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) +#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | \ + V4L2_SLICED_WSS_625) + + +struct v4l2_sliced_vbi_cap +{ + uint16_t service_set; + /* + * service_lines[0][...] specifies lines 0-23 (1-23 used) of the first + * field + * service_lines[1][...] specifies lines 0-23 (1-23 used) of the second + * field + * (equals frame lines 313-336 for 625 line video standards, 263-286 + * for 525 line standards) + */ + uint16_t service_lines[2][24]; + uint32_t reserved[4]; /* must be 0 */ +}; + +struct v4l2_sliced_vbi_data +{ + uint32_t id; + uint32_t field; /* 0: first field, 1: second field */ + uint32_t line; /* 1-23 */ + uint32_t reserved; /* must be 0 */ + uint8_t data[48]; +}; +#endif + +/* + * A G G R E G A T E S T R U C T U R E S + */ + +/* + * Stream data format + */ +struct v4l2_format +{ + enum v4l2_buf_type type; + + /* + * Added for 64bits alignment, or, S_FMT ioctl will fail. Because + * 32 bits app and 64bits driver will get different structure size + * which cause the values of S_FMT are different. v4l2_window has + * pointers which make v4l2_format structure has to be 64bit alignment. + */ + uint32_t pad; + union + { + struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */ + struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */ + struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */ +#if 1 + + /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ + struct v4l2_sliced_vbi_format sliced; +#endif + uint8_t raw_data[200]; /* user-defined */ + } fmt; +}; + + +/* + * Stream type-dependent parameters + */ +struct v4l2_streamparm +{ + enum v4l2_buf_type type; + union + { + struct v4l2_captureparm capture; + struct v4l2_outputparm output; + uint8_t raw_data[200]; /* user-defined */ + } parm; +}; + +/* + * I O C T L C O D E S F O R V I D E O D E V I C E S + * + */ +#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability) +#define VIDIOC_RESERVED _IO('V', 1) +#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc) +#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format) +#define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format) +#ifdef __KERNEL__ +#define VIDIOC_G_MPEGCOMP _IOR('V', 6, struct v4l2_mpeg_compression) +#define VIDIOC_S_MPEGCOMP _IOW('V', 7, struct v4l2_mpeg_compression) +#endif +#define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers) +#define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer) +#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer) +#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer) +#define VIDIOC_OVERLAY _IOW('V', 14, int) +#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer) +#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer) +#define VIDIOC_STREAMON _IOW('V', 18, int) +#define VIDIOC_STREAMOFF _IOW('V', 19, int) +#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm) +#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm) +#define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id) +#define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id) +#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard) +#define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input) +#define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control) +#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control) +#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner) +#define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner) +#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio) +#define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio) +#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl) +#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu) +#define VIDIOC_G_INPUT _IOR('V', 38, int) +#define VIDIOC_S_INPUT _IOWR('V', 39, int) +#define VIDIOC_G_OUTPUT _IOR('V', 46, int) +#define VIDIOC_S_OUTPUT _IOWR('V', 47, int) +#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output) +#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout) +#define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout) +#define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator) +#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator) +#define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency) +#define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency) +#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap) +#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop) +#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop) +#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression) +#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression) +#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id) +#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format) +#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio) +#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout) +#define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority) +#define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority) +#if 1 +#define VIDIOC_G_SLICED_VBI_CAP _IOR('V', 69, struct v4l2_sliced_vbi_cap) +#endif +#define VIDIOC_LOG_STATUS _IO('V', 70) +#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls) +#define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls) +#define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls) + +#ifdef __OLD_VIDIOC_ +/* for compatibility, will go away some day */ +#define VIDIOC_OVERLAY_OLD _IOWR('V', 14, int) +#define VIDIOC_S_PARM_OLD _IOW('V', 22, struct v4l2_streamparm) +#define VIDIOC_S_CTRL_OLD _IOW('V', 28, struct v4l2_control) +#define VIDIOC_G_AUDIO_OLD _IOWR('V', 33, struct v4l2_audio) +#define VIDIOC_G_AUDOUT_OLD _IOWR('V', 49, struct v4l2_audioout) +#define VIDIOC_CROPCAP_OLD _IOR('V', 58, struct v4l2_cropcap) +#endif + +#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __LINUX_VIDEODEV2_H */ + +/* + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/illumos-x86_64/usr/include/sys/visual_io.h b/illumos-x86_64/usr/include/sys/visual_io.h new file mode 100644 index 00000000..c894bb48 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/visual_io.h @@ -0,0 +1,340 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VISUAL_IO_H +#define _SYS_VISUAL_IO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define VIOC ('V' << 8) +#define VIOCF ('F' << 8) + + +/* + * Device Identification + * + * VIS_GETIDENTIFIER returns an identifier string to uniquely identify + * a device type used in the Solaris VISUAL environment. The identifier + * must be unique. We suggest the convention: + * + * + * + * for example: SUNWcg6 + */ + +#define VIS_MAXNAMELEN 128 + +struct vis_identifier { + char name[VIS_MAXNAMELEN]; /* */ +}; + +#define VIS_GETIDENTIFIER (VIOC | 0) + + + +/* + * Hardware Cursor Control + * + * Devices with hardware cursors may implement these ioctls in their + * kernel device drivers. + */ + + +struct vis_cursorpos { + short x; /* cursor x coordinate */ + short y; /* cursor y coordinate */ +}; + +struct vis_cursorcmap { + int version; /* version */ + int reserved; + unsigned char *red; /* red color map elements */ + unsigned char *green; /* green color map elements */ + unsigned char *blue; /* blue color map elements */ +}; + + +/* + * These ioctls fetch and set various cursor attributes, using the + * vis_cursor struct. + */ + +#define VIS_SETCURSOR (VIOCF|24) +#define VIS_GETCURSOR (VIOCF|25) + +struct vis_cursor { + short set; /* what to set */ + short enable; /* cursor on/off */ + struct vis_cursorpos pos; /* cursor position */ + struct vis_cursorpos hot; /* cursor hot spot */ + struct vis_cursorcmap cmap; /* color map info */ + struct vis_cursorpos size; /* cursor bit map size */ + char *image; /* cursor image bits */ + char *mask; /* cursor mask bits */ +}; + +#define VIS_CURSOR_SETCURSOR 0x01 /* set cursor */ +#define VIS_CURSOR_SETPOSITION 0x02 /* set cursor position */ +#define VIS_CURSOR_SETHOTSPOT 0x04 /* set cursor hot spot */ +#define VIS_CURSOR_SETCOLORMAP 0x08 /* set cursor colormap */ +#define VIS_CURSOR_SETSHAPE 0x10 /* set cursor shape */ + +#define VIS_CURSOR_SETALL (VIS_CURSOR_SETCURSOR | \ + VIS_CURSOR_SETPOSITION | \ + VIS_CURSOR_SETHOTSPOT | \ + VIS_CURSOR_SETCOLORMAP | \ + VIS_CURSOR_SETSHAPE) + + +/* + * These ioctls fetch and move the current cursor position, using the + * vis_cursorposition struct. + */ + +#define VIS_MOVECURSOR (VIOCF|26) +#define VIS_GETCURSORPOS (VIOCF|27) + +/* + * VIS_SETCMAP: + * VIS_GETCMAP: + * Set/Get the indicated color map entries. The index states the first + * color to be update and count specifies the number of entries to be + * updated from index. red, green, and blue are arrays of color + * values. The length of the arrays is count. + */ +#define VIS_GETCMAP (VIOC|9) +#define VIS_PUTCMAP (VIOC|10) +struct vis_cmap { + int index; /* Index into colormap to start updating */ + int count; /* Number of entries to update */ + unsigned char *red; /* List of red values */ + unsigned char *green; /* List of green values */ + unsigned char *blue; /* List of blue values */ +}; + + +#if defined(_KERNEL) || defined(_STANDALONE) +/* + * The following ioctls are used for communication between the layered + * device and the framebuffer. The layered driver calls the framebuffer + * with these ioctls. + * + * On machines that don't have a prom, kmdb uses the kernel to display + * characters. The kernel in turn will use the routines returned by + * VIS_DEVINIT to ask the framebuffer driver to display the data. The + * framebuffer driver CANNOT use any DDI services to display this data. It + * must just dump the data to the framebuffer. In particular, the mutex and + * copy routines do not work. + * + * On machines without a prom, the framebuffer driver must implement all + * of these ioctls to be a console. On machines with a prom, the + * framebuffer driver can set vis_devinit.polledio to NULL. + */ +typedef short screen_pos_t; +typedef short screen_size_t; + +/* + * Union of pixel depths + */ +typedef union { + unsigned char mono; /* one-bit */ + unsigned char four; /* four bit */ + unsigned char eight; /* eight bit */ + unsigned char sixteen[2]; /* 16 bit */ + unsigned char twentyfour[3]; /* 24 bit */ + unsigned char thirtytwo[4]; /* 32 bit */ +} color_t; + +/* + * VIS_DEVINIT: + * Initialize the framebuffer as a console device. The terminal emulator + * will provide the following structure to the device driver to be filled in. + * The driver is expected to fill it in. + * + * ioctl(fd, VIS_DEVINIT, struct vis_devinit *) + */ +#define VIS_DEVINIT (VIOC|1) +#define VIS_CONS_REV 5 /* Console IO interface version */ +/* Modes */ +#define VIS_TEXT 0 /* Use text mode when displaying data */ +#define VIS_PIXEL 1 /* Use pixel mode when displaying data */ + +/* + * VIS_DEVFINI: + * Tells the framebuffer that it is no longer being used as a console. + * + * ioctl(fd, VIS_DEVFINI, unused) + */ +#define VIS_DEVFINI (VIOC|2) + +/* + * VIS_CONSCURSOR: + * Display/Hide cursor on the screen. The layered driver uses this ioctl to + * display, hide, and move the cursor on the console. The framebuffer driver + * is expected to draw a cursor at position (col,row) of size width x height. + * + * ioctl(fd, VIS_CONSCURSOR, struct vis_conscursor *) + */ +#define VIS_CONSCURSOR (VIOC|3) +/* Cursor action - Either display or hide cursor */ +#define VIS_HIDE_CURSOR 0 +#define VIS_DISPLAY_CURSOR 1 +#define VIS_GET_CURSOR 2 + +/* + * VIS_CONSDISPLAY: + * Display data on the framebuffer. The data will be in the form specified + * by the driver during console initialization (see VIS_CONSDEVINIT above). + * The driver is expected to display the data at location (row,col). Width + * and height specify the size of the data. + * + * ioctl(fd, VIS_CONSDISPLAY, struct vis_consdisplay *) + */ + +#define VIS_CONSDISPLAY (VIOC|5) + +/* + * VIS_CONSCOPY: + * Move data on the framebuffer. Used to scroll the screen by the terminal + * emulator or to move data by applications. The driver must copy the data + * specified by the rectangle (s_col,s_row),(e_col,e_row) to the location + * which starts at (t_col,t_row), handling overlapping copies correctly. + * + * ioctl(fd, VIS_CONSCOPY, struct vis_conscopy *) + */ +#define VIS_CONSCOPY (VIOC|7) + +/* + * VIS_CONSCLEAR: + * Clear the screen using provided color. Used on VIS_PIXEL mode. + * + * ioctl(fd, VIS_CONSCLEAR, struct vis_consclear *) + */ +#define VIS_CONSCLEAR (VIOC|8) + +struct vis_consclear { + color_t bg_color; /* Background color */ +}; + +struct vis_consdisplay { + screen_pos_t row; /* Row to display data at */ + screen_pos_t col; /* Col to display data at */ + screen_size_t width; /* Width of data */ + screen_size_t height; /* Height of data */ + unsigned char *data; /* Data to display */ + color_t fg_color; /* Foreground color */ + color_t bg_color; /* Background color */ +}; + +struct vis_conscopy { + screen_pos_t s_row; /* Starting row */ + screen_pos_t s_col; /* Starting col */ + screen_pos_t e_row; /* Ending row */ + screen_pos_t e_col; /* Ending col */ + screen_pos_t t_row; /* Row to move to */ + screen_pos_t t_col; /* Col to move to */ +}; + +struct vis_conscursor { + screen_pos_t row; /* Row to display cursor at */ + screen_pos_t col; /* Col to display cursor at */ + screen_size_t width; /* Width of cursor */ + screen_size_t height; /* Height of cursor */ + color_t fg_color; /* Foreground color */ + color_t bg_color; /* Background color */ + short action; /* Hide or show cursor */ +}; + +/* + * Each software-console-capable frame buffer driver defines its own + * instance of this (with its own name!) and casts to/from this at the + * interface with the terminal emulator. These yield somewhat better + * type checking than "void *". + */ +struct vis_polledio_arg; +struct vis_modechg_arg; + +/* + * Each software-console-capable frame buffer driver supplies these routines + * for I/O from "polled" contexts - kmdb, OBP, etc. No system services are + * available. + */ +struct vis_polledio { + struct vis_polledio_arg *arg; + void (*display)(struct vis_polledio_arg *, struct vis_consdisplay *); + void (*copy)(struct vis_polledio_arg *, struct vis_conscopy *); + void (*cursor)(struct vis_polledio_arg *, struct vis_conscursor *); +}; + +struct vis_devinit; /* forward decl. for typedef */ + +typedef void (*vis_modechg_cb_t)(struct vis_modechg_arg *, + struct vis_devinit *); + +typedef uint32_t (*color_map_fn_t)(uint8_t color); + +struct vis_devinit { + /* + * This set of fields are used as parameters passed from the + * layered framebuffer driver to the terminal emulator. + */ + int version; /* Console IO interface version */ + screen_size_t width; /* Width of the device */ + screen_size_t height; /* Height of the device */ + screen_size_t linebytes; /* Bytes per scan line */ + int depth; /* Device depth */ + color_map_fn_t color_map; /* Color map tem -> fb */ + short mode; /* Mode to use when displaying data */ + struct vis_polledio *polledio; /* Polled output routines */ + + /* + * The following fields are used as parameters passed from the + * terminal emulator to the underlying framebuffer driver. + */ + vis_modechg_cb_t modechg_cb; /* Video mode change callback */ + struct vis_modechg_arg *modechg_arg; /* Mode change cb arg */ +}; + +struct visual_ops { + const struct vis_identifier *ident; + int (*kdsetmode)(int); + int (*devinit)(struct vis_devinit *); + void (*cons_copy)(struct vis_conscopy *); + void (*cons_display)(struct vis_consdisplay *); + void (*cons_cursor)(struct vis_conscursor *); + int (*cons_clear)(struct vis_consclear *); + int (*cons_put_cmap)(struct vis_cmap *); +}; + +#endif /* _KERNEL || _STANDALONE */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_VISUAL_IO_H */ diff --git a/illumos-x86_64/usr/include/sys/vm.h b/illumos-x86_64/usr/include/sys/vm.h new file mode 100644 index 00000000..51ec03ad --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vm.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 Joyent, Inc. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_VM_H +#define _SYS_VM_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) +#include + +void setupclock(void); +void pageout(void); +void cv_signal_pageout(void); +int queue_io_request(struct vnode *, u_offset_t); + +extern kmutex_t memavail_lock; +extern kcondvar_t memavail_cv; + +#define WAKE_PAGEOUT_SCANNER(tag) \ + do { \ + DTRACE_PROBE(schedpage__wake__ ## tag); \ + cv_broadcast(&proc_pageout->p_cv); \ + } while (0) + +#endif /* defined(_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VM_H */ diff --git a/illumos-x86_64/usr/include/sys/vm_usage.h b/illumos-x86_64/usr/include/sys/vm_usage.h new file mode 100644 index 00000000..afbf438e --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vm_usage.h @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Joyent, Inc. All rights reserved. + */ + +#ifndef _SYS_VM_USAGE_H +#define _SYS_VM_USAGE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The flags passed to getvmusage() request how to aggregate rss/swap results. + * Results can be aggregated by zone, project, task, ruser, and/or euser. + * + * If VMUSAGE_ALL_* or VMUSAGE_COL_* are passed from a non-global-zone, the + * flag is treated as VMUSAGE_*. For example, VMUSAGE_ALL_ZONES would be + * treated as VMUSAGE_ZONE. + * + * If VMUSAGE_SYSTEM is passed from a non-global zone, a result of type + * VMUSAGE_SYSTEM will be returned, but it will only reflect the usage + * of the calling zone. + * + * VMUSAGE_* requests results for the calling zone. + * VMUSAGE_ALL_* requests results for all zones. + * VMUSAGE_COL_* requests results for all zones, but collapses out the zoneid. + * For example, VMUSAGE_COL_PROJECTS requests results for all + * projects in all zones, and project N in ANY zone is treated + * as the same project. + */ +#define VMUSAGE_SYSTEM 0x1 /* rss/swap for ALL processes */ +#define VMUSAGE_ZONE 0x2 /* rss/swap for caller's zone */ +#define VMUSAGE_PROJECTS 0x4 /* rss/swap for all projects in */ + /* caller's zone */ +#define VMUSAGE_TASKS 0x8 /* rss/swap for all tasks in */ + /* caller's zones */ +#define VMUSAGE_RUSERS 0x10 /* rss/swap for all users (by process */ + /* ruser) in the caller's zone */ +#define VMUSAGE_EUSERS 0x20 /* same as VMUSAGE_RUSERS, but by */ + /* euser */ + +#define VMUSAGE_ALL_ZONES 0x40 /* rss/swap for all zones */ +#define VMUSAGE_ALL_PROJECTS 0x80 /* rss/swap for all projects in */ + /* all zones */ +#define VMUSAGE_ALL_TASKS 0x100 /* rss/swap for all tasks in all */ + /* zones */ +#define VMUSAGE_ALL_RUSERS 0x200 /* rss/swap for all users (by process */ + /* ruser) in all zones */ +#define VMUSAGE_ALL_EUSERS 0x400 /* same as VMUSAGE_ALL_RUSERS, but by */ + /* euser */ + +#define VMUSAGE_COL_PROJECTS 0x800 /* rss/swap for all projects in */ + /* all zones. Collapse zoneid. */ +#define VMUSAGE_COL_RUSERS 0x1000 /* rss/swap for all users (by process */ + /* ruser), in all zones. Collapse */ + /* zoneid */ +#define VMUSAGE_COL_EUSERS 0x2000 /* same as VMUSAGE_COL_RUSERS, but by */ + /* euser */ +#define VMUSAGE_A_ZONE 0x4000 /* rss/swap for a specified zone */ + +#define VMUSAGE_MASK 0x7fff /* all valid flags for getvmusage() */ + +#define VMUSAGE_ZONE_FLAGS (VMUSAGE_ZONE | VMUSAGE_ALL_ZONES | \ + VMUSAGE_A_ZONE) + +typedef struct vmusage { + id_t vmu_zoneid; /* zoneid, or ALL_ZONES for */ + /* VMUSAGE_COL_* results */ + /* ALL_ZONES means that the result */ + /* reflects swap and rss usage for */ + /* a projid/uid across all zones */ + uint_t vmu_type; /* Entity type of result. One of: */ + /* VMUSAGE_(SYSTEM|ZONE|PROJECTS| */ + /* TASKS|RUSERS|EUSERS) */ + id_t vmu_id; /* zoneid, projid, taskid, ... */ + size_t vmu_rss_all; /* total resident memory of entity */ + /* in bytes */ + size_t vmu_rss_private; /* total resident private memory */ + size_t vmu_rss_shared; /* total resident shared memory */ + size_t vmu_swap_all; /* total swap reserved, in bytes */ + size_t vmu_swap_private; /* swap reserved for private mappings */ + size_t vmu_swap_shared; /* swap reserved for shared mappings */ + +} vmusage_t; + +extern int getvmusage(uint_t flags, time_t age, vmusage_t *buf, size_t *nres); + +#ifdef _KERNEL + +int vm_getusage(uint_t, time_t, vmusage_t *, size_t *, int); +void vm_usage_init(); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VM_USAGE_H */ diff --git a/illumos-x86_64/usr/include/sys/vmem.h b/illumos-x86_64/usr/include/sys/vmem.h new file mode 100644 index 00000000..9d72797a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vmem.h @@ -0,0 +1,152 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +#ifndef _SYS_VMEM_H +#define _SYS_VMEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Per-allocation flags + */ +#define VM_SLEEP 0x00000000 /* same as KM_SLEEP */ +#define VM_NOSLEEP 0x00000001 /* same as KM_NOSLEEP */ +#define VM_PANIC 0x00000002 /* same as KM_PANIC */ +#define VM_PUSHPAGE 0x00000004 /* same as KM_PUSHPAGE */ +#define VM_NORMALPRI 0x00000008 /* same as KM_NORMALPRI */ +#define VM_KMFLAGS 0x000000ff /* flags that must match KM_* flags */ + +#define VM_BESTFIT 0x00000100 +#define VM_FIRSTFIT 0x00000200 +#define VM_NEXTFIT 0x00000400 + +/* + * The following flags are restricted for use only within the kernel. + * VM_MEMLOAD is for use by the HAT to avoid infinite recursion. + * VM_NORELOC is used by the kernel when static VA->PA mappings are required. + */ +#define VM_MEMLOAD 0x00000800 +#define VM_NORELOC 0x00001000 +/* + * VM_ABORT requests that vmem_alloc() *ignore* the VM_SLEEP/VM_NOSLEEP flags + * and forgo reaping if the allocation or attempted import, fails. This + * flag is a segkmem-specific flag, and should not be used by anyone else. + */ +#define VM_ABORT 0x00002000 + +/* + * VM_ENDALLOC requests that large addresses be preferred in allocations. + * Has no effect if VM_NEXTFIT is active. + */ +#define VM_ENDALLOC 0x00004000 + +#define VM_FLAGS 0x0000FFFF + +/* + * Arena creation flags + */ +#define VMC_POPULATOR 0x00010000 +#define VMC_NO_QCACHE 0x00020000 /* cannot use quantum caches */ +#define VMC_IDENTIFIER 0x00040000 /* not backed by memory */ +#define VMC_DUMPSAFE 0x00200000 /* can use alternate dump memory */ +/* + * internal use only; the import function uses the vmem_ximport_t interface + * and may increase the request size if it so desires. + * VMC_XALIGN, for use with vmem_xcreate, specifies that + * the address returned by the import function will be + * aligned according to the alignment argument. + */ +#define VMC_XALLOC 0x00080000 +#define VMC_XALIGN 0x00100000 +#define VMC_FLAGS 0xFFFF0000 + +/* + * Public segment types + */ +#define VMEM_ALLOC 0x01 +#define VMEM_FREE 0x02 + +/* + * Implementation-private segment types + */ +#define VMEM_SPAN 0x10 +#define VMEM_ROTOR 0x20 +#define VMEM_WALKER 0x40 + +/* + * VMEM_REENTRANT indicates to vmem_walk() that the callback routine may + * call back into the arena being walked, so vmem_walk() must drop the + * arena lock before each callback. The caveat is that since the arena + * isn't locked, its state can change. Therefore it is up to the callback + * routine to handle cases where the segment isn't of the expected type. + * For example, we use this to walk heap_arena when generating a crash dump; + * see segkmem_dump() for sample usage. + */ +#define VMEM_REENTRANT 0x80000000 + +typedef struct vmem vmem_t; +typedef void *(vmem_alloc_t)(vmem_t *, size_t, int); +typedef void (vmem_free_t)(vmem_t *, void *, size_t); + +/* + * Alternate import style; the requested size is passed in a pointer, + * which can be increased by the import function if desired. + */ +typedef void *(vmem_ximport_t)(vmem_t *, size_t *, size_t, int); + +#ifdef _KERNEL +extern vmem_t *vmem_init(const char *, void *, size_t, size_t, + vmem_alloc_t *, vmem_free_t *); +extern void vmem_update(void *); +extern int vmem_is_populator(); +extern size_t vmem_seg_size; +#endif + +extern vmem_t *vmem_create(const char *, void *, size_t, size_t, + vmem_alloc_t *, vmem_free_t *, vmem_t *, size_t, int); +extern vmem_t *vmem_xcreate(const char *, void *, size_t, size_t, + vmem_ximport_t *, vmem_free_t *, vmem_t *, size_t, int); +extern void vmem_destroy(vmem_t *); +extern void *vmem_alloc(vmem_t *, size_t, int); +extern void *vmem_xalloc(vmem_t *, size_t, size_t, size_t, size_t, + void *, void *, int); +extern void vmem_free(vmem_t *, void *, size_t); +extern void vmem_xfree(vmem_t *, void *, size_t); +extern void *vmem_add(vmem_t *, void *, size_t, int); +extern int vmem_contains(vmem_t *, void *, size_t); +extern void vmem_walk(vmem_t *, int, void (*)(void *, void *, size_t), void *); +extern size_t vmem_size(vmem_t *, int); +extern void vmem_qcache_reap(vmem_t *vmp); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VMEM_H */ diff --git a/illumos-x86_64/usr/include/sys/vmem_impl.h b/illumos-x86_64/usr/include/sys/vmem_impl.h new file mode 100644 index 00000000..27a005ce --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vmem_impl.h @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1999-2001, 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VMEM_IMPL_H +#define _SYS_VMEM_IMPL_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct vmem_seg vmem_seg_t; + +#define VMEM_STACK_DEPTH 20 + +struct vmem_seg { + /* + * The first four fields must match vmem_freelist_t exactly. + */ + uintptr_t vs_start; /* start of segment (inclusive) */ + uintptr_t vs_end; /* end of segment (exclusive) */ + vmem_seg_t *vs_knext; /* next of kin (alloc, free, span) */ + vmem_seg_t *vs_kprev; /* prev of kin */ + + vmem_seg_t *vs_anext; /* next in arena */ + vmem_seg_t *vs_aprev; /* prev in arena */ + uint8_t vs_type; /* alloc, free, span */ + uint8_t vs_import; /* non-zero if segment was imported */ + uint8_t vs_depth; /* stack depth if KMF_AUDIT active */ + /* + * The following fields are present only when KMF_AUDIT is set. + */ + kthread_t *vs_thread; + hrtime_t vs_timestamp; + pc_t vs_stack[VMEM_STACK_DEPTH]; +}; + +typedef struct vmem_freelist { + uintptr_t vs_start; /* always zero */ + uintptr_t vs_end; /* segment size */ + vmem_seg_t *vs_knext; /* next of kin */ + vmem_seg_t *vs_kprev; /* prev of kin */ +} vmem_freelist_t; + +#define VS_SIZE(vsp) ((vsp)->vs_end - (vsp)->vs_start) + +/* + * Segment hashing + */ +#define VMEM_HASH_INDEX(a, s, q, m) \ + ((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m)) + +#define VMEM_HASH(vmp, addr) \ + (&(vmp)->vm_hash_table[VMEM_HASH_INDEX(addr, \ + (vmp)->vm_hash_shift, (vmp)->vm_qshift, (vmp)->vm_hash_mask)]) + +#define VMEM_QCACHE_SLABSIZE(max) \ + MAX(1 << highbit(3 * (max)), 64) + +#define VMEM_NAMELEN 30 +#define VMEM_HASH_INITIAL 16 +#define VMEM_NQCACHE_MAX 16 +#define VMEM_FREELISTS (sizeof (void *) * 8) + +typedef struct vmem_kstat { + kstat_named_t vk_mem_inuse; /* memory in use */ + kstat_named_t vk_mem_import; /* memory imported */ + kstat_named_t vk_mem_total; /* total memory in arena */ + kstat_named_t vk_source_id; /* vmem id of vmem source */ + kstat_named_t vk_alloc; /* number of allocations */ + kstat_named_t vk_free; /* number of frees */ + kstat_named_t vk_wait; /* number of allocations that waited */ + kstat_named_t vk_fail; /* number of allocations that failed */ + kstat_named_t vk_lookup; /* hash lookup count */ + kstat_named_t vk_search; /* freelist search count */ + kstat_named_t vk_populate_wait; /* populates that waited */ + kstat_named_t vk_populate_fail; /* populates that failed */ + kstat_named_t vk_contains; /* vmem_contains() calls */ + kstat_named_t vk_contains_search; /* vmem_contains() search cnt */ +} vmem_kstat_t; + +struct vmem { + char vm_name[VMEM_NAMELEN]; /* arena name */ + kcondvar_t vm_cv; /* cv for blocking allocations */ + kmutex_t vm_lock; /* arena lock */ + uint32_t vm_id; /* vmem id */ + uint32_t vm_mtbf; /* induced alloc failure rate */ + int vm_cflags; /* arena creation flags */ + int vm_qshift; /* log2(vm_quantum) */ + size_t vm_quantum; /* vmem quantum */ + size_t vm_qcache_max; /* maximum size to front by kmem */ + size_t vm_min_import; /* smallest amount to import */ + void *(*vm_source_alloc)(vmem_t *, size_t, int); + void (*vm_source_free)(vmem_t *, void *, size_t); + vmem_t *vm_source; /* vmem source for imported memory */ + vmem_t *vm_next; /* next in vmem_list */ + kstat_t *vm_ksp; /* kstat */ + ssize_t vm_nsegfree; /* number of free vmem_seg_t's */ + vmem_seg_t *vm_segfree; /* free vmem_seg_t list */ + vmem_seg_t **vm_hash_table; /* allocated-segment hash table */ + size_t vm_hash_mask; /* hash_size - 1 */ + size_t vm_hash_shift; /* log2(vm_hash_mask + 1) */ + ulong_t vm_freemap; /* bitmap of non-empty freelists */ + vmem_seg_t vm_seg0; /* anchor segment */ + vmem_seg_t vm_rotor; /* rotor for VM_NEXTFIT allocations */ + vmem_seg_t *vm_hash0[VMEM_HASH_INITIAL]; /* initial hash table */ + void *vm_qcache[VMEM_NQCACHE_MAX]; /* quantum caches */ + vmem_freelist_t vm_freelist[VMEM_FREELISTS + 1]; /* power-of-2 flists */ + vmem_kstat_t vm_kstat; /* kstat data */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VMEM_IMPL_H */ diff --git a/illumos-x86_64/usr/include/sys/vmem_impl_user.h b/illumos-x86_64/usr/include/sys/vmem_impl_user.h new file mode 100644 index 00000000..f870a261 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vmem_impl_user.h @@ -0,0 +1,150 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VMEM_IMPL_USER_H +#define _SYS_VMEM_IMPL_USER_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct vmem_seg vmem_seg_t; + +#define VMEM_STACK_DEPTH 20 + +struct vmem_seg { + /* + * The first four fields must match vmem_freelist_t exactly. + */ + uintptr_t vs_start; /* start of segment (inclusive) */ + uintptr_t vs_end; /* end of segment (exclusive) */ + vmem_seg_t *vs_knext; /* next of kin (alloc, free, span) */ + vmem_seg_t *vs_kprev; /* prev of kin */ + + vmem_seg_t *vs_anext; /* next in arena */ + vmem_seg_t *vs_aprev; /* prev in arena */ + uint8_t vs_type; /* alloc, free, span */ + uint8_t vs_import; /* non-zero if segment was imported */ + uint8_t vs_depth; /* stack depth if UMF_AUDIT active */ + /* + * The following fields are present only when UMF_AUDIT is set. + */ + thread_t vs_thread; + hrtime_t vs_timestamp; + uintptr_t vs_stack[VMEM_STACK_DEPTH]; +}; + +typedef struct vmem_freelist { + uintptr_t vs_start; /* always zero */ + uintptr_t vs_end; /* segment size */ + vmem_seg_t *vs_knext; /* next of kin */ + vmem_seg_t *vs_kprev; /* prev of kin */ +} vmem_freelist_t; + +#define VS_SIZE(vsp) ((vsp)->vs_end - (vsp)->vs_start) + +/* + * Segment hashing + */ +#define VMEM_HASH_INDEX(a, s, q, m) \ + ((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m)) + +#define VMEM_HASH(vmp, addr) \ + (&(vmp)->vm_hash_table[VMEM_HASH_INDEX(addr, \ + (vmp)->vm_hash_shift, (vmp)->vm_qshift, (vmp)->vm_hash_mask)]) + +#define VMEM_NAMELEN 30 +#define VMEM_HASH_INITIAL 16 +#define VMEM_NQCACHE_MAX 16 +#define VMEM_FREELISTS (sizeof (void *) * 8) + +typedef struct vmem_kstat { + uint64_t vk_mem_inuse; /* memory in use */ + uint64_t vk_mem_import; /* memory imported */ + uint64_t vk_mem_total; /* total memory in arena */ + uint32_t vk_source_id; /* vmem id of vmem source */ + uint64_t vk_alloc; /* number of allocations */ + uint64_t vk_free; /* number of frees */ + uint64_t vk_wait; /* number of allocations that waited */ + uint64_t vk_fail; /* number of allocations that failed */ + uint64_t vk_lookup; /* hash lookup count */ + uint64_t vk_search; /* freelist search count */ + uint64_t vk_populate_wait; /* populates that waited */ + uint64_t vk_populate_fail; /* populates that failed */ + uint64_t vk_contains; /* vmem_contains() calls */ + uint64_t vk_contains_search; /* vmem_contains() search cnt */ +} vmem_kstat_t; + +struct vmem { + char vm_name[VMEM_NAMELEN]; /* arena name */ + cond_t vm_cv; /* cv for blocking allocations */ + mutex_t vm_lock; /* arena lock */ + uint32_t vm_id; /* vmem id */ + uint32_t vm_mtbf; /* induced alloc failure rate */ + int vm_cflags; /* arena creation flags */ + int vm_qshift; /* log2(vm_quantum) */ + size_t vm_quantum; /* vmem quantum */ + size_t vm_qcache_max; /* maximum size to front by umem */ + vmem_alloc_t *vm_source_alloc; + vmem_free_t *vm_source_free; + vmem_t *vm_source; /* vmem source for imported memory */ + vmem_t *vm_next; /* next in vmem_list */ + ssize_t vm_nsegfree; /* number of free vmem_seg_t's */ + vmem_seg_t *vm_segfree; /* free vmem_seg_t list */ + vmem_seg_t **vm_hash_table; /* allocated-segment hash table */ + size_t vm_hash_mask; /* hash_size - 1 */ + size_t vm_hash_shift; /* log2(vm_hash_mask + 1) */ + ulong_t vm_freemap; /* bitmap of non-empty freelists */ + vmem_seg_t vm_seg0; /* anchor segment */ + vmem_seg_t vm_rotor; /* rotor for VM_NEXTFIT allocations */ + vmem_seg_t *vm_hash0[VMEM_HASH_INITIAL]; /* initial hash table */ + void *vm_qcache[VMEM_NQCACHE_MAX]; /* quantum caches */ + vmem_freelist_t vm_freelist[VMEM_FREELISTS + 1]; /* power-of-2 flists */ + vmem_kstat_t vm_kstat; /* kstat data */ +}; + +/* + * We cannot use a mutex_t and MUTEX_HELD, since that will not work + * when libthread is not linked. + */ +typedef struct vmem_populate_lock { + mutex_t vmpl_mutex; + thread_t vmpl_thr; +} vmem_populate_lock_t; + +#define VM_UMFLAGS VM_KMFLAGS + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VMEM_IMPL_USER_H */ diff --git a/illumos-x86_64/usr/include/sys/vmparam.h b/illumos-x86_64/usr/include/sys/vmparam.h new file mode 100644 index 00000000..48b6166b --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vmparam.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_VMPARAM_H +#define _SYS_VMPARAM_H + +#if (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define SSIZE 4096 /* initial stack size */ +#define SINCR 4096 /* increment of stack */ + +/* + * USRSTACK is the top (end) of the user stack. + */ +#if defined(__amd64) +#define USRSTACK USERLIMIT +#define USRSTACK32 0x8048000 +#define USRSTACK64_32 USERLIMIT32 +#elif defined(__i386) +#define USRSTACK 0x8048000 +#define USRSTACK32 USRSTACK +#define USRSTACK64_32 USRSTACK +#endif + +/* + * Implementation architecture independent sections of the kernel use + * this section. + */ +#if (defined(_KERNEL) || defined(_KMEMUSER)) && !defined(_MACHDEP) + +#if defined(_KERNEL) && !defined(_ASM) +extern const unsigned int _diskrpm; +extern const unsigned long _pgthresh; +extern const unsigned int _maxslp; +extern const unsigned long _maxhandspreadpages; +#endif /* defined(_KERNEL) && !defined(_ASM) */ + +#define DISKRPM _diskrpm +#define PGTHRESH _pgthresh +#define MAXSLP _maxslp +#define MAXHANDSPREADPAGES _maxhandspreadpages + +#endif /* (defined(_KERNEL) || defined(_KMEMUSER)) && !defined(_MACHDEP) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VMPARAM_H */ diff --git a/illumos-x86_64/usr/include/sys/vmsystm.h b/illumos-x86_64/usr/include/sys/vmsystm.h new file mode 100644 index 00000000..5ff9ce09 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vmsystm.h @@ -0,0 +1,177 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2017, Joyent, Inc. All rights reserved. + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_VMSYSTM_H +#define _SYS_VMSYSTM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Miscellaneous virtual memory subsystem variables and structures. + */ +#ifdef _KERNEL +extern pgcnt_t freemem; /* remaining blocks of free memory */ +extern pgcnt_t avefree; /* 5 sec moving average of free memory */ +extern pgcnt_t avefree30; /* 30 sec moving average of free memory */ +extern pgcnt_t deficit; /* estimate of needs of new swapped in procs */ +extern pgcnt_t nscan; /* number of scans in last second */ +extern pgcnt_t desscan; /* desired pages scanned per second */ +extern pgcnt_t slowscan; +extern pgcnt_t fastscan; +extern pgcnt_t pushes; /* number of pages pushed to swap device */ +extern uint64_t low_mem_scan; /* num times page scan due to low memory */ +extern uint64_t zone_cap_scan; /* num times page scan due to zone cap */ +extern volatile uint64_t n_throttle; /* num times page create throttled */ + +/* writable copies of tunables */ +extern pgcnt_t maxpgio; /* max paging i/o per sec before start swaps */ +extern pgcnt_t lotsfree; /* max free before clock freezes */ +extern pgcnt_t desfree; /* minimum free pages before swapping begins */ +extern pgcnt_t minfree; /* no of pages to try to keep free via daemon */ +extern pgcnt_t needfree; /* no of pages currently being waited for */ +extern pgcnt_t throttlefree; /* point at which we block PG_WAIT calls */ +extern pgcnt_t pageout_reserve; /* point at which we deny non-PG_WAIT calls */ +extern pgcnt_t pages_before_pager; /* XXX */ + +/* + * TRUE if the pageout daemon, fsflush daemon, or the scheduler. These threads + * can't sleep while trying to free up memory since a deadlock will occur if + * they do sleep. + */ +#define NOMEMWAIT() (ttoproc(curthread) == proc_pageout || \ + ttoproc(curthread) == proc_fsflush || \ + ttoproc(curthread) == proc_sched || \ + (curthread->t_flag & T_PUSHPAGE) != 0) + +/* insure non-zero */ +#define nz(x) ((x) != 0 ? (x) : 1) + +/* + * Flags passed by the swapper to swapout routines of each + * scheduling class. + */ +#define HARDSWAP 1 +#define SOFTSWAP 2 + +/* + * Values returned by valid_usr_range() + */ +#define RANGE_OKAY (0) +#define RANGE_BADADDR (1) +#define RANGE_BADPROT (2) + +/* + * map_pgsz: temporary - subject to change. + */ +#define MAPPGSZ_VA 0x01 +#define MAPPGSZ_STK 0x02 +#define MAPPGSZ_HEAP 0x04 +#define MAPPGSZ_ISM 0x08 + +/* + * Flags for map_pgszcvec + */ +#define MAPPGSZC_SHM 0x01 +#define MAPPGSZC_PRIVM 0x02 +#define MAPPGSZC_STACK 0x04 +#define MAPPGSZC_HEAP 0x08 + +/* + * vacalign values for choose_addr + */ +#define ADDR_NOVACALIGN 0 +#define ADDR_VACALIGN 1 + +struct as; +struct page; +struct anon; + +extern int maxslp; +extern ulong_t pginrate; +extern ulong_t pgoutrate; +extern void swapout_lwp(klwp_t *); + +extern int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen, + int dir); +extern int valid_va_range_aligned(caddr_t *basep, size_t *lenp, + size_t minlen, int dir, size_t align, size_t redzone, size_t off); + +extern int valid_usr_range(caddr_t, size_t, uint_t, struct as *, caddr_t); +extern int useracc(void *, size_t, int); +extern size_t map_pgsz(int maptype, struct proc *p, caddr_t addr, size_t len, + int memcntl); +extern uint_t map_pgszcvec(caddr_t addr, size_t size, uintptr_t off, int flags, + int type, int memcntl); +extern int choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off, + int vacalign, uint_t flags); +extern void map_addr(caddr_t *addrp, size_t len, offset_t off, int vacalign, + uint_t flags); +extern int map_addr_vacalign_check(caddr_t, u_offset_t); +extern void map_addr_proc(caddr_t *addrp, size_t len, offset_t off, + int vacalign, caddr_t userlimit, struct proc *p, uint_t flags); +extern void vmmeter(void); +extern int cow_mapin(struct as *, caddr_t, caddr_t, struct page **, + struct anon **, size_t *, int); + +extern caddr_t ppmapin(struct page *, uint_t, caddr_t); +extern void ppmapout(caddr_t); + +extern int pf_is_memory(pfn_t); + +extern void dcache_flushall(void); + +extern void *boot_virt_alloc(void *addr, size_t size); + +extern size_t exec_get_spslew(void); + +extern caddr_t map_userlimit(proc_t *pp, struct as *as, int flags); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VMSYSTM_H */ diff --git a/illumos-x86_64/usr/include/sys/vnode.h b/illumos-x86_64/usr/include/sys/vnode.h new file mode 100644 index 00000000..a61007da --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vnode.h @@ -0,0 +1,1603 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 Joyent, Inc. + * Copyright (c) 2011, 2017 by Delphix. All rights reserved. + * Copyright 2016-2024 RackTop Systems, Inc. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _SYS_VNODE_H +#define _SYS_VNODE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +#include +#include +#endif /* _KERNEL || _FAKE_KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Statistics for all vnode operations. + * All operations record number of ops (since boot/mount/zero'ed). + * Certain I/O operations (read, write, readdir) also record number + * of bytes transferred. + * This appears in two places in the system: one is embedded in each + * vfs_t. There is also an array of vopstats_t structures allocated + * on a per-fstype basis. + */ + +#define VOPSTATS_STR "vopstats_" /* Initial string for vopstat kstats */ + +typedef struct vopstats { + kstat_named_t nopen; /* VOP_OPEN */ + kstat_named_t nclose; /* VOP_CLOSE */ + kstat_named_t nread; /* VOP_READ */ + kstat_named_t read_bytes; + kstat_named_t nwrite; /* VOP_WRITE */ + kstat_named_t write_bytes; + kstat_named_t nioctl; /* VOP_IOCTL */ + kstat_named_t nsetfl; /* VOP_SETFL */ + kstat_named_t ngetattr; /* VOP_GETATTR */ + kstat_named_t nsetattr; /* VOP_SETATTR */ + kstat_named_t naccess; /* VOP_ACCESS */ + kstat_named_t nlookup; /* VOP_LOOKUP */ + kstat_named_t ncreate; /* VOP_CREATE */ + kstat_named_t nremove; /* VOP_REMOVE */ + kstat_named_t nlink; /* VOP_LINK */ + kstat_named_t nrename; /* VOP_RENAME */ + kstat_named_t nmkdir; /* VOP_MKDIR */ + kstat_named_t nrmdir; /* VOP_RMDIR */ + kstat_named_t nreaddir; /* VOP_READDIR */ + kstat_named_t readdir_bytes; + kstat_named_t nsymlink; /* VOP_SYMLINK */ + kstat_named_t nreadlink; /* VOP_READLINK */ + kstat_named_t nfsync; /* VOP_FSYNC */ + kstat_named_t ninactive; /* VOP_INACTIVE */ + kstat_named_t nfid; /* VOP_FID */ + kstat_named_t nrwlock; /* VOP_RWLOCK */ + kstat_named_t nrwunlock; /* VOP_RWUNLOCK */ + kstat_named_t nseek; /* VOP_SEEK */ + kstat_named_t ncmp; /* VOP_CMP */ + kstat_named_t nfrlock; /* VOP_FRLOCK */ + kstat_named_t nspace; /* VOP_SPACE */ + kstat_named_t nrealvp; /* VOP_REALVP */ + kstat_named_t ngetpage; /* VOP_GETPAGE */ + kstat_named_t nputpage; /* VOP_PUTPAGE */ + kstat_named_t nmap; /* VOP_MAP */ + kstat_named_t naddmap; /* VOP_ADDMAP */ + kstat_named_t ndelmap; /* VOP_DELMAP */ + kstat_named_t npoll; /* VOP_POLL */ + kstat_named_t ndump; /* VOP_DUMP */ + kstat_named_t npathconf; /* VOP_PATHCONF */ + kstat_named_t npageio; /* VOP_PAGEIO */ + kstat_named_t ndumpctl; /* VOP_DUMPCTL */ + kstat_named_t ndispose; /* VOP_DISPOSE */ + kstat_named_t nsetsecattr; /* VOP_SETSECATTR */ + kstat_named_t ngetsecattr; /* VOP_GETSECATTR */ + kstat_named_t nshrlock; /* VOP_SHRLOCK */ + kstat_named_t nvnevent; /* VOP_VNEVENT */ + kstat_named_t nreqzcbuf; /* VOP_REQZCBUF */ + kstat_named_t nretzcbuf; /* VOP_RETZCBUF */ +} vopstats_t; + +/* + * The vnode is the focus of all file activity in UNIX. + * A vnode is allocated for each active file, each current + * directory, each mounted-on file, and the root. + * + * Each vnode is usually associated with a file-system-specific node (for + * UFS, this is the in-memory inode). Generally, a vnode and an fs-node + * should be created and destroyed together as a pair. + * + * If a vnode is reused for a new file, it should be reinitialized by calling + * either vn_reinit() or vn_recycle(). + * + * vn_reinit() resets the entire vnode as if it was returned by vn_alloc(). + * The caller is responsible for setting up the entire vnode after calling + * vn_reinit(). This is important when using kmem caching where the vnode is + * allocated by a constructor, for instance. + * + * vn_recycle() is used when the file system keeps some state around in both + * the vnode and the associated FS-node. In UFS, for example, the inode of + * a deleted file can be reused immediately. The v_data, v_vfsp, v_op, etc. + * remains the same but certain fields related to the previous instance need + * to be reset. In particular: + * v_femhead + * v_path + * v_rdcnt, v_wrcnt + * v_mmap_read, v_mmap_write + */ + +/* + * vnode types. VNON means no type. These values are unrelated to + * values in on-disk inodes. + */ +typedef enum vtype { + VNON = 0, + VREG = 1, + VDIR = 2, + VBLK = 3, + VCHR = 4, + VLNK = 5, + VFIFO = 6, + VDOOR = 7, + VPROC = 8, + VSOCK = 9, + VPORT = 10, + VBAD = 11 +} vtype_t; + +/* + * VSD - Vnode Specific Data + * Used to associate additional private data with a vnode. + */ +struct vsd_node { + list_node_t vs_nodes; /* list of all VSD nodes */ + uint_t vs_nkeys; /* entries in value array */ + void **vs_value; /* array of value/key */ +}; + +/* + * Many of the fields in the vnode are read-only once they are initialized + * at vnode creation time. Other fields are protected by locks. + * + * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc(). They + * may not be embedded into the file-system specific node (inode). The + * size of vnodes may change. + * + * The v_lock protects: + * v_flag + * v_stream + * v_count + * v_shrlocks + * v_path + * v_phantom_count + * v_vsd + * v_xattrdir + * + * A special lock (implemented by vn_vfswlock in vnode.c) protects: + * v_vfsmountedhere + * + * The global flock_lock mutex (in flock.c) protects: + * v_filocks + * + * IMPORTANT NOTE: + * + * The following vnode fields are considered public and may safely be + * accessed by file systems or other consumers: + * + * v_lock + * v_flag + * v_count + * v_phantom_count + * v_data + * v_vfsp + * v_stream + * v_type + * v_rdev + * + * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD. + * In particular, file systems should not access other fields; they may + * change or even be removed. The functionality which was once provided + * by these fields is available through vn_* functions. + * + * VNODE PATH THEORY: + * In each vnode, the v_path field holds a cached version of the canonical + * filesystem path which that node represents. Because vnodes lack contextual + * information about their own name or position in the VFS hierarchy, this path + * must be calculated when the vnode is instantiated by operations such as + * fop_create, fop_lookup, or fop_mkdir. During said operations, both the + * parent vnode (and its cached v_path) and future name are known, so the + * v_path of the resulting object can easily be set. + * + * The caching nature of v_path is complicated in the face of directory + * renames. Filesystem drivers are responsible for calling vn_renamepath when + * a fop_rename operation succeeds. While the v_path on the renamed vnode will + * be updated, existing children of the directory (direct, or at deeper levels) + * will now possess v_path caches which are stale. + * + * It is expensive (and for non-directories, impossible) to recalculate stale + * v_path entries during operations such as vnodetopath. The best time during + * which to correct such wrongs is the same as when v_path is first + * initialized: during fop_create/fop_lookup/fop_mkdir/etc, where adequate + * context is available to generate the current path. + * + * In order to quickly detect stale v_path entries (without full lookup + * verification) to trigger a v_path update, the v_path_stamp field has been + * added to vnode_t. As part of successful fop_create/fop_lookup/fop_mkdir + * operations, where the name and parent vnode are available, the following + * rules are used to determine updates to the child: + * + * 1. If the parent lacks a v_path, clear any existing v_path and v_path_stamp + * on the child. Until the parent v_path is refreshed to a valid state, the + * child v_path must be considered invalid too. + * + * 2. If the child lacks a v_path (implying v_path_stamp == 0), it inherits the + * v_path_stamp value from its parent and its v_path is updated. + * + * 3. If the child v_path_stamp is less than v_path_stamp in the parent, it is + * an indication that the child v_path is stale. The v_path is updated and + * v_path_stamp in the child is set to the current hrtime(). + * + * It does _not_ inherit the parent v_path_stamp in order to propagate the + * the time of v_path invalidation through the directory structure. This + * prevents concurrent invalidations (operating with a now-incorrect v_path) + * at deeper levels in the tree from persisting. + * + * 4. If the child v_path_stamp is greater or equal to the parent, no action + * needs to be taken. + * + * Note that fop_rename operations do not follow this ruleset. They perform an + * explicit update of v_path and v_path_stamp (setting it to the current time) + * + * With these constraints in place, v_path invalidations and updates should + * proceed in a timely manner as vnodes are accessed. While there still are + * limited cases where vnodetopath operations will fail, the risk is minimized. + */ + +struct fem_head; /* from fem.h */ + +typedef struct vnode { + kmutex_t v_lock; /* protects vnode fields */ + uint_t v_flag; /* vnode flags (see below) */ + uint_t v_count; /* reference count */ + /* non vn_count() ref count (see below) */ + uint_t v_phantom_count; + void *v_data; /* private data for fs */ + struct vfs *v_vfsp; /* ptr to containing VFS */ + struct stdata *v_stream; /* associated stream */ + enum vtype v_type; /* vnode type */ + dev_t v_rdev; /* device (VCHR, VBLK) */ + + /* PRIVATE FIELDS BELOW - DO NOT USE */ + + struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ + struct vnodeops *v_op; /* vnode operations */ + struct page *v_pages; /* vnode pages list */ + struct filock *v_filocks; /* ptr to filock list */ + struct shrlocklist *v_shrlocks; /* ptr to shrlock list */ + krwlock_t v_nbllock; /* sync for NBMAND locks */ + kcondvar_t v_cv; /* synchronize locking */ + void *v_locality; /* hook for locality info */ + struct fem_head *v_femhead; /* fs monitoring */ + char *v_path; /* cached path */ + hrtime_t v_path_stamp; /* timestamp for cached path */ + uint_t v_rdcnt; /* open for read count (VREG only) */ + uint_t v_wrcnt; /* open for write count (VREG only) */ + u_longlong_t v_mmap_read; /* mmap read count */ + u_longlong_t v_mmap_write; /* mmap write count */ + void *v_mpssdata; /* info for large page mappings */ + void *v_fopdata; /* list of file ops event watches */ + kmutex_t v_vsd_lock; /* protects v_vsd field */ + struct vsd_node *v_vsd; /* vnode specific data */ + struct vnode *v_xattrdir; /* unnamed extended attr dir (GFS) */ + uint_t v_count_dnlc; /* dnlc reference count */ +} vnode_t; + +#define IS_DEVVP(vp) \ + ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) + +#define VNODE_ALIGN 64 +/* Count of low-order 0 bits in a vnode *, based on size and alignment. */ +#if defined(_LP64) +#define VNODE_ALIGN_LOG2 8 +#else +#define VNODE_ALIGN_LOG2 7 +#endif + +/* + * vnode flags. + */ +#define VROOT 0x01 /* root of its file system */ +#define VNOCACHE 0x02 /* don't keep cache pages on vnode */ +#define VNOMAP 0x04 /* file cannot be mapped/faulted */ +#define VDUP 0x08 /* file should be dup'ed rather then opened */ +#define VNOSWAP 0x10 /* file cannot be used as virtual swap device */ +#define VNOMOUNT 0x20 /* file cannot be covered by mount */ +#define VISSWAP 0x40 /* vnode is being used for swap */ +#define VSWAPLIKE 0x80 /* vnode acts like swap (but may not be) */ + +#define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0) + +#ifdef _KERNEL +typedef struct vn_vfslocks_entry { + rwstlock_t ve_lock; + void *ve_vpvfs; + struct vn_vfslocks_entry *ve_next; + uint32_t ve_refcnt; + char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \ + sizeof (uint32_t)]; +} vn_vfslocks_entry_t; +#endif + +/* + * The following two flags are used to lock the v_vfsmountedhere field + */ +#define VVFSLOCK 0x100 +#define VVFSWAIT 0x200 + +/* + * Used to serialize VM operations on a vnode + */ +#define VVMLOCK 0x400 + +/* + * Tell vn_open() not to fail a directory open for writing but + * to go ahead and call VOP_OPEN() to let the filesystem check. + */ +#define VDIROPEN 0x800 + +/* + * Flag to let the VM system know that this file is most likely a binary + * or shared library since it has been mmap()ed EXEC at some time. + */ +#define VVMEXEC 0x1000 + +#define VPXFS 0x2000 /* clustering: global fs proxy vnode */ + +#define IS_PXFSVP(vp) ((vp)->v_flag & VPXFS) + +#define V_XATTRDIR 0x4000 /* attribute unnamed directory */ + +#define IS_XATTRDIR(vp) ((vp)->v_flag & V_XATTRDIR) + +#define V_LOCALITY 0x8000 /* whether locality aware */ + +/* + * Flag that indicates the VM should maintain the v_pages list with all modified + * pages on one end and unmodified pages at the other. This makes finding dirty + * pages to write back to disk much faster at the expense of taking a minor + * fault on the first store instruction which touches a writable page. + */ +#define VMODSORT (0x10000) +#define IS_VMODSORT(vp) \ + (pvn_vmodsort_supported != 0 && ((vp)->v_flag & VMODSORT) != 0) + +#define VISSWAPFS 0x20000 /* vnode is being used for swapfs */ + +/* + * The mdb memstat command assumes that IS_SWAPFSVP only uses the + * vnode's v_flag field. If this changes, cache the additional + * fields in mdb; see vn_get in mdb/common/modules/genunix/memory.c + */ +#define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0) + +#define V_SYSATTR 0x40000 /* vnode is a GFS system attribute */ + +/* + * Indication that VOP_LOOKUP operations on this vnode may yield results from a + * different VFS instance. The main use of this is to suppress v_path + * calculation logic when filesystems such as procfs emit results which defy + * expectations about normal VFS behavior. + */ +#define VTRAVERSE 0x80000 + +/* + * Vnode attributes. A bit-mask is supplied as part of the + * structure to indicate the attributes the caller wants to + * set (setattr) or extract (getattr). + */ + +/* + * Note that va_nodeid and va_nblocks are 64bit data type. + * We support large files over NFSV3. With Solaris client and + * Server that generates 64bit ino's and sizes these fields + * will overflow if they are 32 bit sizes. + */ + +typedef struct vattr { + uint_t va_mask; /* bit-mask of attributes */ + vtype_t va_type; /* vnode type (for create) */ + mode_t va_mode; /* file access mode */ + uid_t va_uid; /* owner user id */ + gid_t va_gid; /* owner group id */ + dev_t va_fsid; /* file system id (dev for now) */ + u_longlong_t va_nodeid; /* node id */ + nlink_t va_nlink; /* number of references to file */ + u_offset_t va_size; /* file size in bytes */ + timestruc_t va_atime; /* time of last access */ + timestruc_t va_mtime; /* time of last modification */ + timestruc_t va_ctime; /* time of last status change */ + dev_t va_rdev; /* device the file represents */ + uint_t va_blksize; /* fundamental block size */ + u_longlong_t va_nblocks; /* # of blocks allocated */ + uint_t va_seq; /* sequence number */ +} vattr_t; + +#define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */ + +/* + * Structure of all optional attributes. + */ +typedef struct xoptattr { + timestruc_t xoa_createtime; /* Create time of file */ + uint8_t xoa_archive; + uint8_t xoa_system; + uint8_t xoa_readonly; + uint8_t xoa_hidden; + uint8_t xoa_nounlink; + uint8_t xoa_immutable; + uint8_t xoa_appendonly; + uint8_t xoa_nodump; + uint8_t xoa_opaque; + uint8_t xoa_av_quarantined; + uint8_t xoa_av_modified; + uint8_t xoa_av_scanstamp[AV_SCANSTAMP_SZ]; + uint8_t xoa_reparse; + uint64_t xoa_generation; + uint8_t xoa_offline; + uint8_t xoa_sparse; + uint8_t xoa_projinherit; + uint64_t xoa_projid; +} xoptattr_t; + +/* + * The xvattr structure is really a variable length structure that + * is made up of: + * - The classic vattr_t (xva_vattr) + * - a 32 bit quantity (xva_mapsize) that specifies the size of the + * attribute bitmaps in 32 bit words. + * - A pointer to the returned attribute bitmap (needed because the + * previous element, the requested attribute bitmap) is variable lenth. + * - The requested attribute bitmap, which is an array of 32 bit words. + * Callers use the XVA_SET_REQ() macro to set the bits corresponding to + * the attributes that are being requested. + * - The returned attribute bitmap, which is an array of 32 bit words. + * File systems that support optional attributes use the XVA_SET_RTN() + * macro to set the bits corresponding to the attributes that are being + * returned. + * - The xoptattr_t structure which contains the attribute values + * + * xva_mapsize determines how many words in the attribute bitmaps. + * Immediately following the attribute bitmaps is the xoptattr_t. + * xva_getxoptattr() is used to get the pointer to the xoptattr_t + * section. + */ + +#define XVA_MAPSIZE 3 /* Size of attr bitmaps */ +#define XVA_MAGIC 0x78766174 /* Magic # for verification */ + +/* + * The xvattr structure is an extensible structure which permits optional + * attributes to be requested/returned. File systems may or may not support + * optional attributes. They do so at their own discretion but if they do + * support optional attributes, they must register the VFSFT_XVATTR feature + * so that the optional attributes can be set/retrived. + * + * The fields of the xvattr structure are: + * + * xva_vattr - The first element of an xvattr is a legacy vattr structure + * which includes the common attributes. If AT_XVATTR is set in the va_mask + * then the entire structure is treated as an xvattr. If AT_XVATTR is not + * set, then only the xva_vattr structure can be used. + * + * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification. + * + * xva_mapsize - Size of requested and returned attribute bitmaps. + * + * xva_rtnattrmapp - Pointer to xva_rtnattrmap[]. We need this since the + * size of the array before it, xva_reqattrmap[], could change which means + * the location of xva_rtnattrmap[] could change. This will allow unbundled + * file systems to find the location of xva_rtnattrmap[] when the sizes change. + * + * xva_reqattrmap[] - Array of requested attributes. Attributes are + * represented by a specific bit in a specific element of the attribute + * map array. Callers set the bits corresponding to the attributes + * that the caller wants to get/set. + * + * xva_rtnattrmap[] - Array of attributes that the file system was able to + * process. Not all file systems support all optional attributes. This map + * informs the caller which attributes the underlying file system was able + * to set/get. (Same structure as the requested attributes array in terms + * of each attribute corresponding to specific bits and array elements.) + * + * xva_xoptattrs - Structure containing values of optional attributes. + * These values are only valid if the corresponding bits in xva_reqattrmap + * are set and the underlying file system supports those attributes. + */ +typedef struct xvattr { + vattr_t xva_vattr; /* Embedded vattr structure */ + uint32_t xva_magic; /* Magic Number */ + uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */ + uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */ + uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */ + uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */ + xoptattr_t xva_xoptattrs; /* Optional attributes */ +} xvattr_t; + +#ifdef _SYSCALL32 +/* + * For bigtypes time_t changed to 64 bit on the 64-bit kernel. + * Define an old version for user/kernel interface + */ + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +typedef struct vattr32 { + uint32_t va_mask; /* bit-mask of attributes */ + vtype_t va_type; /* vnode type (for create) */ + mode32_t va_mode; /* file access mode */ + uid32_t va_uid; /* owner user id */ + gid32_t va_gid; /* owner group id */ + dev32_t va_fsid; /* file system id (dev for now) */ + u_longlong_t va_nodeid; /* node id */ + nlink_t va_nlink; /* number of references to file */ + u_offset_t va_size; /* file size in bytes */ + timestruc32_t va_atime; /* time of last access */ + timestruc32_t va_mtime; /* time of last modification */ + timestruc32_t va_ctime; /* time of last status change */ + dev32_t va_rdev; /* device the file represents */ + uint32_t va_blksize; /* fundamental block size */ + u_longlong_t va_nblocks; /* # of blocks allocated */ + uint32_t va_seq; /* sequence number */ +} vattr32_t; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#else /* not _SYSCALL32 */ +#define vattr32 vattr +typedef vattr_t vattr32_t; +#endif /* _SYSCALL32 */ + +/* + * Attributes of interest to the caller of setattr or getattr. + */ +#define AT_TYPE 0x00001 +#define AT_MODE 0x00002 +#define AT_UID 0x00004 +#define AT_GID 0x00008 +#define AT_FSID 0x00010 +#define AT_NODEID 0x00020 +#define AT_NLINK 0x00040 +#define AT_SIZE 0x00080 +#define AT_ATIME 0x00100 +#define AT_MTIME 0x00200 +#define AT_CTIME 0x00400 +#define AT_RDEV 0x00800 +#define AT_BLKSIZE 0x01000 +#define AT_NBLOCKS 0x02000 +/* 0x04000 */ /* unused */ +#define AT_SEQ 0x08000 +/* + * If AT_XVATTR is set then there are additional bits to process in + * the xvattr_t's attribute bitmap. If this is not set then the bitmap + * MUST be ignored. Note that this bit must be set/cleared explicitly. + * That is, setting AT_ALL will NOT set AT_XVATTR. + */ +#define AT_XVATTR 0x10000 + +#define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ + AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ + AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) + +#define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ + AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE) + +#define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME) + +#define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ + AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) + +/* + * Attribute bits used in the extensible attribute's (xva's) attribute + * bitmaps. Note that the bitmaps are made up of a variable length number + * of 32-bit words. The convention is to use XAT{n}_{attrname} where "n" + * is the element in the bitmap (starting at 1). This convention is for + * the convenience of the maintainer to keep track of which element each + * attribute belongs to. + * + * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY. CONSUMERS + * MUST USE THE XAT_* DEFINES. + */ +#define XAT0_INDEX 0LL /* Index into bitmap for XAT0 attrs */ +#define XAT0_CREATETIME 0x00000001 /* Create time of file */ +#define XAT0_ARCHIVE 0x00000002 /* Archive */ +#define XAT0_SYSTEM 0x00000004 /* System */ +#define XAT0_READONLY 0x00000008 /* Readonly */ +#define XAT0_HIDDEN 0x00000010 /* Hidden */ +#define XAT0_NOUNLINK 0x00000020 /* Nounlink */ +#define XAT0_IMMUTABLE 0x00000040 /* immutable */ +#define XAT0_APPENDONLY 0x00000080 /* appendonly */ +#define XAT0_NODUMP 0x00000100 /* nodump */ +#define XAT0_OPAQUE 0x00000200 /* opaque */ +#define XAT0_AV_QUARANTINED 0x00000400 /* anti-virus quarantine */ +#define XAT0_AV_MODIFIED 0x00000800 /* anti-virus modified */ +#define XAT0_AV_SCANSTAMP 0x00001000 /* anti-virus scanstamp */ +#define XAT0_REPARSE 0x00002000 /* FS reparse point */ +#define XAT0_GEN 0x00004000 /* object generation number */ +#define XAT0_OFFLINE 0x00008000 /* offline */ +#define XAT0_SPARSE 0x00010000 /* sparse */ +#define XAT0_PROJINHERIT 0x00020000 /* Create with parent projid */ +#define XAT0_PROJID 0x00040000 /* Project ID */ + +#define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \ + XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \ + XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| XAT0_AV_MODIFIED| \ + XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE| \ + XAT0_PROJINHERIT | XAT0_PROJID) + +/* Support for XAT_* optional attributes */ +#define XVA_MASK 0xffffffff /* Used to mask off 32 bits */ +#define XVA_SHFT 32 /* Used to shift index */ + +/* + * Used to pry out the index and attribute bits from the XAT_* attributes + * defined below. Note that we're masking things down to 32 bits then + * casting to uint32_t. + */ +#define XVA_INDEX(attr) ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK)) +#define XVA_ATTRBIT(attr) ((uint32_t)((attr) & XVA_MASK)) + +/* + * The following defines present a "flat namespace" so that consumers don't + * need to keep track of which element belongs to which bitmap entry. + * + * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER + */ +#define XAT_CREATETIME ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME) +#define XAT_ARCHIVE ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE) +#define XAT_SYSTEM ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM) +#define XAT_READONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY) +#define XAT_HIDDEN ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN) +#define XAT_NOUNLINK ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK) +#define XAT_IMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE) +#define XAT_APPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY) +#define XAT_NODUMP ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP) +#define XAT_OPAQUE ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE) +#define XAT_AV_QUARANTINED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED) +#define XAT_AV_MODIFIED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED) +#define XAT_AV_SCANSTAMP ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP) +#define XAT_REPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE) +#define XAT_GEN ((XAT0_INDEX << XVA_SHFT) | XAT0_GEN) +#define XAT_OFFLINE ((XAT0_INDEX << XVA_SHFT) | XAT0_OFFLINE) +#define XAT_SPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE) +#define XAT_PROJINHERIT ((XAT0_INDEX << XVA_SHFT) | XAT0_PROJINHERIT) +#define XAT_PROJID ((XAT0_INDEX << XVA_SHFT) | XAT0_PROJID) + +/* + * The returned attribute map array (xva_rtnattrmap[]) is located past the + * requested attribute map array (xva_reqattrmap[]). Its location changes + * when the array sizes change. We use a separate pointer in a known location + * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[]. This is + * set in xva_init() + */ +#define XVA_RTNATTRMAP(xvap) ((xvap)->xva_rtnattrmapp) + +/* + * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap + * of requested attributes (xva_reqattrmap[]). + */ +#define XVA_SET_REQ(xvap, attr) \ + ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ + ASSERT((xvap)->xva_magic == XVA_MAGIC); \ + (xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) +/* + * XVA_CLR_REQ() clears an attribute bit in the proper element in the bitmap + * of requested attributes (xva_reqattrmap[]). + */ +#define XVA_CLR_REQ(xvap, attr) \ + ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ + ASSERT((xvap)->xva_magic == XVA_MAGIC); \ + (xvap)->xva_reqattrmap[XVA_INDEX(attr)] &= ~XVA_ATTRBIT(attr) + +/* + * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap + * of returned attributes (xva_rtnattrmap[]). + */ +#define XVA_SET_RTN(xvap, attr) \ + ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ + ASSERT((xvap)->xva_magic == XVA_MAGIC); \ + (XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) + +/* + * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[]) + * to see of the corresponding attribute bit is set. If so, returns non-zero. + */ +#define XVA_ISSET_REQ(xvap, attr) \ + ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ + ((xvap)->xva_magic == XVA_MAGIC) && \ + ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ + ((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) + +/* + * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[]) + * to see of the corresponding attribute bit is set. If so, returns non-zero. + */ +#define XVA_ISSET_RTN(xvap, attr) \ + ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ + ((xvap)->xva_magic == XVA_MAGIC) && \ + ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ + ((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) + +/* + * Modes. Some values same as S_xxx entries from stat.h for convenience. + */ +#define VSUID 04000 /* set user id on execution */ +#define VSGID 02000 /* set group id on execution */ +#define VSVTX 01000 /* save swapped text even after use */ + +/* + * Permissions. + */ +#define VREAD 00400 +#define VWRITE 00200 +#define VEXEC 00100 + +#define MODEMASK 07777 /* mode bits plus permission bits */ +#define PERMMASK 00777 /* permission bits */ + +/* + * VOP_ACCESS flags + */ +#define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */ +#define V_APPEND 0x2 /* want to do append only check */ + +/* + * Check whether mandatory file locking is enabled. + */ + +#define MANDMODE(mode) (((mode) & (VSGID|(VEXEC>>3))) == VSGID) +#define MANDLOCK(vp, mode) ((vp)->v_type == VREG && MANDMODE(mode)) + +/* + * Flags for vnode operations. + */ +enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */ +enum symfollow { NO_FOLLOW, FOLLOW }; /* follow symlinks (or not) */ +enum vcexcl { NONEXCL, EXCL }; /* (non)excl create */ +enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */ + +typedef enum rm rm_t; +typedef enum symfollow symfollow_t; +typedef enum vcexcl vcexcl_t; +typedef enum create create_t; + +/* + * Vnode Events - Used by VOP_VNEVENT + * The VE_PRE_RENAME_* events fire before the rename operation and are + * primarily used for specialized applications, such as NFSv4 delegation, which + * need to know about rename before it occurs. + */ +typedef enum vnevent { + VE_SUPPORT = 0, /* Query */ + VE_RENAME_SRC = 1, /* Rename, with vnode as source */ + VE_RENAME_DEST = 2, /* Rename, with vnode as target/destination */ + VE_REMOVE = 3, /* Remove of vnode's name */ + VE_RMDIR = 4, /* Remove of directory vnode's name */ + VE_CREATE = 5, /* Create with vnode's name which exists */ + VE_LINK = 6, /* Link with vnode's name as source */ + VE_RENAME_DEST_DIR = 7, /* Rename with vnode as target dir */ + VE_MOUNTEDOVER = 8, /* File or Filesystem got mounted over vnode */ + VE_TRUNCATE = 9, /* Truncate */ + VE_PRE_RENAME_SRC = 10, /* Pre-rename, with vnode as source */ + VE_PRE_RENAME_DEST = 11, /* Pre-rename, with vnode as target/dest. */ + VE_PRE_RENAME_DEST_DIR = 12, /* Pre-rename with vnode as target dir */ + VE_RENAME_SRC_DIR = 13, /* Rename with vnode as source dir */ + VE_RESIZE = 14 /* Resize/truncate to non-zero offset */ +} vnevent_t; + +/* + * Values for checking vnode open and map counts + */ +enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR }; + +typedef enum v_mode v_mode_t; + +#define V_TRUE 1 +#define V_FALSE 0 + +/* + * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations + */ + +typedef struct vsecattr { + uint_t vsa_mask; /* See below */ + int vsa_aclcnt; /* ACL entry count */ + void *vsa_aclentp; /* pointer to ACL entries */ + int vsa_dfaclcnt; /* default ACL entry count */ + void *vsa_dfaclentp; /* pointer to default ACL entries */ + size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */ + uint_t vsa_aclflags; /* ACE ACL flags */ +} vsecattr_t; + +/* vsa_mask values */ +#define VSA_ACL 0x0001 +#define VSA_ACLCNT 0x0002 +#define VSA_DFACL 0x0004 +#define VSA_DFACLCNT 0x0008 +#define VSA_ACE 0x0010 +#define VSA_ACECNT 0x0020 +#define VSA_ACE_ALLTYPES 0x0040 +#define VSA_ACE_ACLFLAGS 0x0080 /* get/set ACE ACL flags */ + +/* + * Structure used by various vnode operations to determine + * the context (pid, host, identity) of a caller. + * + * The cc_caller_id is used to identify one or more callers who invoke + * operations, possibly on behalf of others. For example, the NFS + * server could have it's own cc_caller_id which can be detected by + * vnode/vfs operations or (FEM) monitors on those operations. New + * caller IDs are generated by fs_new_caller_id(). + */ +typedef struct caller_context { + pid_t cc_pid; /* Process ID of the caller */ + int cc_sysid; /* System ID, used for remote calls */ + u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ + ulong_t cc_flags; +} caller_context_t; + +/* + * Flags for caller context. The caller sets CC_DONTBLOCK if it does not + * want to block inside of a FEM monitor. The monitor will set CC_WOULDBLOCK + * and return EAGAIN if the operation would have blocked. + */ +#define CC_WOULDBLOCK 0x01 +#define CC_DONTBLOCK 0x02 + +/* + * Structure tags for function prototypes, defined elsewhere. + */ +struct pathname; +struct fid; +struct flock64; +struct flk_callback; +struct shrlock; +struct page; +struct seg; +struct as; +struct pollhead; +struct taskq; + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +/* + * VNODE_OPS defines all the vnode operations. It is used to define + * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h). + */ +#define VNODE_OPS \ + int (*vop_open)(vnode_t **, int, cred_t *, \ + caller_context_t *); \ + int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *, \ + caller_context_t *); \ + int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, \ + caller_context_t *); \ + int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, \ + caller_context_t *); \ + int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, \ + int *, caller_context_t *); \ + int (*vop_setfl)(vnode_t *, int, int, cred_t *, \ + caller_context_t *); \ + int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *, \ + caller_context_t *); \ + int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, \ + caller_context_t *); \ + int (*vop_access)(vnode_t *, int, int, cred_t *, \ + caller_context_t *); \ + int (*vop_lookup)(vnode_t *, char *, vnode_t **, \ + struct pathname *, \ + int, vnode_t *, cred_t *, \ + caller_context_t *, int *, \ + struct pathname *); \ + int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, \ + int, vnode_t **, cred_t *, int, \ + caller_context_t *, vsecattr_t *); \ + int (*vop_remove)(vnode_t *, char *, cred_t *, \ + caller_context_t *, int); \ + int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *, \ + caller_context_t *, int); \ + int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, \ + cred_t *, caller_context_t *, int); \ + int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, \ + cred_t *, caller_context_t *, int, \ + vsecattr_t *); \ + int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *, \ + caller_context_t *, int); \ + int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *, \ + caller_context_t *, int); \ + int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, \ + cred_t *, caller_context_t *, int); \ + int (*vop_readlink)(vnode_t *, uio_t *, cred_t *, \ + caller_context_t *); \ + int (*vop_fsync)(vnode_t *, int, cred_t *, \ + caller_context_t *); \ + void (*vop_inactive)(vnode_t *, cred_t *, \ + caller_context_t *); \ + int (*vop_fid)(vnode_t *, struct fid *, \ + caller_context_t *); \ + int (*vop_rwlock)(vnode_t *, int, caller_context_t *); \ + void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); \ + int (*vop_seek)(vnode_t *, offset_t, offset_t *, \ + caller_context_t *); \ + int (*vop_cmp)(vnode_t *, vnode_t *, caller_context_t *); \ + int (*vop_frlock)(vnode_t *, int, struct flock64 *, \ + int, offset_t, \ + struct flk_callback *, cred_t *, \ + caller_context_t *); \ + int (*vop_space)(vnode_t *, int, struct flock64 *, \ + int, offset_t, \ + cred_t *, caller_context_t *); \ + int (*vop_realvp)(vnode_t *, vnode_t **, \ + caller_context_t *); \ + int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, \ + struct page **, size_t, struct seg *, \ + caddr_t, enum seg_rw, cred_t *, \ + caller_context_t *); \ + int (*vop_putpage)(vnode_t *, offset_t, size_t, \ + int, cred_t *, caller_context_t *); \ + int (*vop_map)(vnode_t *, offset_t, struct as *, \ + caddr_t *, size_t, \ + uchar_t, uchar_t, uint_t, cred_t *, \ + caller_context_t *); \ + int (*vop_addmap)(vnode_t *, offset_t, struct as *, \ + caddr_t, size_t, \ + uchar_t, uchar_t, uint_t, cred_t *, \ + caller_context_t *); \ + int (*vop_delmap)(vnode_t *, offset_t, struct as *, \ + caddr_t, size_t, \ + uint_t, uint_t, uint_t, cred_t *, \ + caller_context_t *); \ + int (*vop_poll)(vnode_t *, short, int, short *, \ + struct pollhead **, \ + caller_context_t *); \ + int (*vop_dump)(vnode_t *, caddr_t, offset_t, offset_t, \ + caller_context_t *); \ + int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *, \ + caller_context_t *); \ + int (*vop_pageio)(vnode_t *, struct page *, \ + u_offset_t, size_t, int, cred_t *, \ + caller_context_t *); \ + int (*vop_dumpctl)(vnode_t *, int, offset_t *, \ + caller_context_t *); \ + void (*vop_dispose)(vnode_t *, struct page *, \ + int, int, cred_t *, \ + caller_context_t *); \ + int (*vop_setsecattr)(vnode_t *, vsecattr_t *, \ + int, cred_t *, caller_context_t *); \ + int (*vop_getsecattr)(vnode_t *, vsecattr_t *, \ + int, cred_t *, caller_context_t *); \ + int (*vop_shrlock)(vnode_t *, int, struct shrlock *, \ + int, cred_t *, caller_context_t *); \ + int (*vop_vnevent)(vnode_t *, vnevent_t, vnode_t *, \ + char *, caller_context_t *); \ + int (*vop_reqzcbuf)(vnode_t *, enum uio_rw, xuio_t *, \ + cred_t *, caller_context_t *); \ + int (*vop_retzcbuf)(vnode_t *, xuio_t *, cred_t *, \ + caller_context_t *) + /* NB: No ";" */ + +/* + * Operations on vnodes. Note: File systems must never operate directly + * on a 'vnodeops' structure -- it WILL change in future releases! They + * must use vn_make_ops() to create the structure. + */ +typedef struct vnodeops { + const char *vnop_name; + VNODE_OPS; /* Signatures of all vnode operations (vops) */ +} vnodeops_t; + +typedef int (*fs_generic_func_p) (); /* Generic vop/vfsop/femop/fsemop ptr */ + +extern int fop_open(vnode_t **, int, cred_t *, caller_context_t *); +extern int fop_close(vnode_t *, int, int, offset_t, cred_t *, + caller_context_t *); +extern int fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *); +extern int fop_write(vnode_t *, uio_t *, int, cred_t *, + caller_context_t *); +extern int fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *, + caller_context_t *); +extern int fop_setfl(vnode_t *, int, int, cred_t *, caller_context_t *); +extern int fop_getattr(vnode_t *, vattr_t *, int, cred_t *, + caller_context_t *); +extern int fop_setattr(vnode_t *, vattr_t *, int, cred_t *, + caller_context_t *); +extern int fop_access(vnode_t *, int, int, cred_t *, caller_context_t *); +extern int fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *, + int, vnode_t *, cred_t *, caller_context_t *, + int *, struct pathname *); +extern int fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int, + vnode_t **, cred_t *, int, caller_context_t *, + vsecattr_t *); +extern int fop_remove(vnode_t *vp, char *, cred_t *, caller_context_t *, + int); +extern int fop_link(vnode_t *, vnode_t *, char *, cred_t *, + caller_context_t *, int); +extern int fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *, + caller_context_t *, int); +extern int fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *, + caller_context_t *, int, vsecattr_t *); +extern int fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *, + caller_context_t *, int); +extern int fop_readdir(vnode_t *, uio_t *, cred_t *, int *, + caller_context_t *, int); +extern int fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *, + caller_context_t *, int); +extern int fop_readlink(vnode_t *, uio_t *, cred_t *, caller_context_t *); +extern int fop_fsync(vnode_t *, int, cred_t *, caller_context_t *); +extern void fop_inactive(vnode_t *, cred_t *, caller_context_t *); +extern int fop_fid(vnode_t *, struct fid *, caller_context_t *); +extern int fop_rwlock(vnode_t *, int, caller_context_t *); +extern void fop_rwunlock(vnode_t *, int, caller_context_t *); +extern int fop_seek(vnode_t *, offset_t, offset_t *, caller_context_t *); +extern int fop_cmp(vnode_t *, vnode_t *, caller_context_t *); +extern int fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t, + struct flk_callback *, cred_t *, + caller_context_t *); +extern int fop_space(vnode_t *, int, struct flock64 *, int, offset_t, + cred_t *, caller_context_t *); +extern int fop_realvp(vnode_t *, vnode_t **, caller_context_t *); +extern int fop_getpage(vnode_t *, offset_t, size_t, uint_t *, + struct page **, size_t, struct seg *, + caddr_t, enum seg_rw, cred_t *, + caller_context_t *); +extern int fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *, + caller_context_t *); +extern int fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t, + uchar_t, uchar_t, uint_t, cred_t *cr, + caller_context_t *); +extern int fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, + uchar_t, uchar_t, uint_t, cred_t *, + caller_context_t *); +extern int fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, + uint_t, uint_t, uint_t, cred_t *, + caller_context_t *); +extern int fop_poll(vnode_t *, short, int, short *, struct pollhead **, + caller_context_t *); +extern int fop_dump(vnode_t *, caddr_t, offset_t, offset_t, + caller_context_t *); +extern int fop_pathconf(vnode_t *, int, ulong_t *, cred_t *, + caller_context_t *); +extern int fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int, + cred_t *, caller_context_t *); +extern int fop_dumpctl(vnode_t *, int, offset_t *, caller_context_t *); +extern void fop_dispose(vnode_t *, struct page *, int, int, cred_t *, + caller_context_t *); +extern int fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *, + caller_context_t *); +extern int fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *, + caller_context_t *); +extern int fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *, + caller_context_t *); +extern int fop_vnevent(vnode_t *, vnevent_t, vnode_t *, char *, + caller_context_t *); +extern int fop_reqzcbuf(vnode_t *, enum uio_rw, xuio_t *, cred_t *, + caller_context_t *); +extern int fop_retzcbuf(vnode_t *, xuio_t *, cred_t *, caller_context_t *); + +#endif /* _KERNEL || _FAKE_KERNEL */ + +#define VOP_OPEN(vpp, mode, cr, ct) \ + fop_open(vpp, mode, cr, ct) +#define VOP_CLOSE(vp, f, c, o, cr, ct) \ + fop_close(vp, f, c, o, cr, ct) +#define VOP_READ(vp, uiop, iof, cr, ct) \ + fop_read(vp, uiop, iof, cr, ct) +#define VOP_WRITE(vp, uiop, iof, cr, ct) \ + fop_write(vp, uiop, iof, cr, ct) +#define VOP_IOCTL(vp, cmd, a, f, cr, rvp, ct) \ + fop_ioctl(vp, cmd, a, f, cr, rvp, ct) +#define VOP_SETFL(vp, f, a, cr, ct) \ + fop_setfl(vp, f, a, cr, ct) +#define VOP_GETATTR(vp, vap, f, cr, ct) \ + fop_getattr(vp, vap, f, cr, ct) +#define VOP_SETATTR(vp, vap, f, cr, ct) \ + fop_setattr(vp, vap, f, cr, ct) +#define VOP_ACCESS(vp, mode, f, cr, ct) \ + fop_access(vp, mode, f, cr, ct) +#define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) \ + fop_lookup(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) +#define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) \ + fop_create(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) +#define VOP_REMOVE(dvp, p, cr, ct, f) \ + fop_remove(dvp, p, cr, ct, f) +#define VOP_LINK(tdvp, fvp, p, cr, ct, f) \ + fop_link(tdvp, fvp, p, cr, ct, f) +#define VOP_RENAME(fvp, fnm, tdvp, tnm, cr, ct, f) \ + fop_rename(fvp, fnm, tdvp, tnm, cr, ct, f) +#define VOP_MKDIR(dp, p, vap, vpp, cr, ct, f, vsap) \ + fop_mkdir(dp, p, vap, vpp, cr, ct, f, vsap) +#define VOP_RMDIR(dp, p, cdir, cr, ct, f) \ + fop_rmdir(dp, p, cdir, cr, ct, f) +#define VOP_READDIR(vp, uiop, cr, eofp, ct, f) \ + fop_readdir(vp, uiop, cr, eofp, ct, f) +#define VOP_SYMLINK(dvp, lnm, vap, tnm, cr, ct, f) \ + fop_symlink(dvp, lnm, vap, tnm, cr, ct, f) +#define VOP_READLINK(vp, uiop, cr, ct) \ + fop_readlink(vp, uiop, cr, ct) +#define VOP_FSYNC(vp, syncflag, cr, ct) \ + fop_fsync(vp, syncflag, cr, ct) +#define VOP_INACTIVE(vp, cr, ct) \ + fop_inactive(vp, cr, ct) +#define VOP_FID(vp, fidp, ct) \ + fop_fid(vp, fidp, ct) +#define VOP_RWLOCK(vp, w, ct) \ + fop_rwlock(vp, w, ct) +#define VOP_RWUNLOCK(vp, w, ct) \ + fop_rwunlock(vp, w, ct) +#define VOP_SEEK(vp, ooff, noffp, ct) \ + fop_seek(vp, ooff, noffp, ct) +#define VOP_CMP(vp1, vp2, ct) \ + fop_cmp(vp1, vp2, ct) +#define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr, ct) \ + fop_frlock(vp, cmd, a, f, o, cb, cr, ct) +#define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \ + fop_space(vp, cmd, a, f, o, cr, ct) +#define VOP_REALVP(vp1, vp2, ct) \ + fop_realvp(vp1, vp2, ct) +#define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) \ + fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) +#define VOP_PUTPAGE(vp, of, sz, fl, cr, ct) \ + fop_putpage(vp, of, sz, fl, cr, ct) +#define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ + fop_map(vp, of, as, a, sz, p, mp, fl, cr, ct) +#define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ + fop_addmap(vp, of, as, a, sz, p, mp, fl, cr, ct) +#define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ + fop_delmap(vp, of, as, a, sz, p, mp, fl, cr, ct) +#define VOP_POLL(vp, events, anyyet, reventsp, phpp, ct) \ + fop_poll(vp, events, anyyet, reventsp, phpp, ct) +#define VOP_DUMP(vp, addr, bn, count, ct) \ + fop_dump(vp, addr, bn, count, ct) +#define VOP_PATHCONF(vp, cmd, valp, cr, ct) \ + fop_pathconf(vp, cmd, valp, cr, ct) +#define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr, ct) \ + fop_pageio(vp, pp, io_off, io_len, flags, cr, ct) +#define VOP_DUMPCTL(vp, action, blkp, ct) \ + fop_dumpctl(vp, action, blkp, ct) +#define VOP_DISPOSE(vp, pp, flag, dn, cr, ct) \ + fop_dispose(vp, pp, flag, dn, cr, ct) +#define VOP_GETSECATTR(vp, vsap, f, cr, ct) \ + fop_getsecattr(vp, vsap, f, cr, ct) +#define VOP_SETSECATTR(vp, vsap, f, cr, ct) \ + fop_setsecattr(vp, vsap, f, cr, ct) +#define VOP_SHRLOCK(vp, cmd, shr, f, cr, ct) \ + fop_shrlock(vp, cmd, shr, f, cr, ct) +#define VOP_VNEVENT(vp, vnevent, dvp, fnm, ct) \ + fop_vnevent(vp, vnevent, dvp, fnm, ct) +#define VOP_REQZCBUF(vp, rwflag, xuiop, cr, ct) \ + fop_reqzcbuf(vp, rwflag, xuiop, cr, ct) +#define VOP_RETZCBUF(vp, xuiop, cr, ct) \ + fop_retzcbuf(vp, xuiop, cr, ct) + +#define VOPNAME_OPEN "open" +#define VOPNAME_CLOSE "close" +#define VOPNAME_READ "read" +#define VOPNAME_WRITE "write" +#define VOPNAME_IOCTL "ioctl" +#define VOPNAME_SETFL "setfl" +#define VOPNAME_GETATTR "getattr" +#define VOPNAME_SETATTR "setattr" +#define VOPNAME_ACCESS "access" +#define VOPNAME_LOOKUP "lookup" +#define VOPNAME_CREATE "create" +#define VOPNAME_REMOVE "remove" +#define VOPNAME_LINK "link" +#define VOPNAME_RENAME "rename" +#define VOPNAME_MKDIR "mkdir" +#define VOPNAME_RMDIR "rmdir" +#define VOPNAME_READDIR "readdir" +#define VOPNAME_SYMLINK "symlink" +#define VOPNAME_READLINK "readlink" +#define VOPNAME_FSYNC "fsync" +#define VOPNAME_INACTIVE "inactive" +#define VOPNAME_FID "fid" +#define VOPNAME_RWLOCK "rwlock" +#define VOPNAME_RWUNLOCK "rwunlock" +#define VOPNAME_SEEK "seek" +#define VOPNAME_CMP "cmp" +#define VOPNAME_FRLOCK "frlock" +#define VOPNAME_SPACE "space" +#define VOPNAME_REALVP "realvp" +#define VOPNAME_GETPAGE "getpage" +#define VOPNAME_PUTPAGE "putpage" +#define VOPNAME_MAP "map" +#define VOPNAME_ADDMAP "addmap" +#define VOPNAME_DELMAP "delmap" +#define VOPNAME_POLL "poll" +#define VOPNAME_DUMP "dump" +#define VOPNAME_PATHCONF "pathconf" +#define VOPNAME_PAGEIO "pageio" +#define VOPNAME_DUMPCTL "dumpctl" +#define VOPNAME_DISPOSE "dispose" +#define VOPNAME_GETSECATTR "getsecattr" +#define VOPNAME_SETSECATTR "setsecattr" +#define VOPNAME_SHRLOCK "shrlock" +#define VOPNAME_VNEVENT "vnevent" +#define VOPNAME_REQZCBUF "reqzcbuf" +#define VOPNAME_RETZCBUF "retzcbuf" + +/* + * Flags for VOP_LOOKUP + * + * Defined in file.h, but also possible, FIGNORECASE and FSEARCH + * + */ +#define LOOKUP_DIR 0x01 /* want parent dir vp */ +#define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ +#define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */ +#define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */ +/* LOOKUP_CHECKREAD 0x10 - private lookuppnvp flag */ +#define LOOKUP_NOACLCHECK 0x20 /* Dont check ACL when checking perms */ + +/* + * Flags for VOP_READDIR + */ +#define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */ +#define V_RDDIR_ACCFILTER 0x02 /* filter out inaccessible dirents */ + +/* + * Flags for VOP_RWLOCK/VOP_RWUNLOCK + * VOP_RWLOCK will return the flag that was actually set, or -1 if none. + */ +#define V_WRITELOCK_TRUE (1) /* Request write-lock on the vnode */ +#define V_WRITELOCK_FALSE (0) /* Request read-lock on the vnode */ + +/* + * Flags for VOP_DUMPCTL + */ +#define DUMP_ALLOC 0 +#define DUMP_FREE 1 +#define DUMP_SCAN 2 + +/* + * Public vnode manipulation functions. + */ +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +vnode_t *vn_alloc(int); +void vn_reinit(vnode_t *); +void vn_recycle(vnode_t *); +void vn_free(vnode_t *); + +int vn_is_readonly(vnode_t *); +int vn_is_opened(vnode_t *, v_mode_t); +int vn_is_mapped(vnode_t *, v_mode_t); +int vn_has_other_opens(vnode_t *, v_mode_t); +void vn_open_upgrade(vnode_t *, int); +void vn_open_downgrade(vnode_t *, int); + +int vn_can_change_zones(vnode_t *vp); + +int vn_has_flocks(vnode_t *); +int vn_has_mandatory_locks(vnode_t *, int); +int vn_has_cached_data(vnode_t *); + +void vn_setops(vnode_t *, vnodeops_t *); +vnodeops_t *vn_getops(vnode_t *); +int vn_matchops(vnode_t *, vnodeops_t *); +int vn_matchopval(vnode_t *, char *, fs_generic_func_p); +int vn_ismntpt(vnode_t *); + +struct vfs *vn_mountedvfs(vnode_t *); + +int vn_in_dnlc(vnode_t *); + +void vn_create_cache(void); +void vn_destroy_cache(void); + +void vn_freevnodeops(vnodeops_t *); + +int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode, + struct vnode **vpp, enum create crwhy, mode_t umask); +int vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode, + struct vnode **vpp, enum create crwhy, + mode_t umask, struct vnode *startvp, int fd); +int vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap, + enum vcexcl excl, int mode, struct vnode **vpp, + enum create why, int flag, mode_t umask); +int vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap, + enum vcexcl excl, int mode, struct vnode **vpp, + enum create why, int flag, mode_t umask, struct vnode *startvp); +int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len, + offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit, + cred_t *cr, ssize_t *residp); +uint_t vn_count(struct vnode *vp); +void vn_rele(struct vnode *vp); +void vn_rele_async(struct vnode *vp, struct taskq *taskq); +void vn_rele_dnlc(struct vnode *vp); +void vn_rele_stream(struct vnode *vp); +void vn_phantom_rele(struct vnode *vp); +int vn_link(char *from, char *to, enum uio_seg seg); +int vn_linkat(vnode_t *fstartvp, char *from, enum symfollow follow, + vnode_t *tstartvp, char *to, enum uio_seg seg); +int vn_rename(char *from, char *to, enum uio_seg seg); +int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname, + enum uio_seg seg); +int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag); +int vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg, + enum rm dirflag); +int vn_compare(vnode_t *vp1, vnode_t *vp2); +int vn_vfswlock(struct vnode *vp); +int vn_vfswlock_wait(struct vnode *vp); +int vn_vfsrlock(struct vnode *vp); +int vn_vfsrlock_wait(struct vnode *vp); +void vn_vfsunlock(struct vnode *vp); +int vn_vfswlock_held(struct vnode *vp); +vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr); +vnode_t *makespecvp(dev_t dev, vtype_t type); + +#if !defined(_FAKE_KERNEL) +vn_vfslocks_entry_t *vn_vfslocks_getlock(void *); +void vn_vfslocks_rele(vn_vfslocks_entry_t *); +#endif + +boolean_t vn_is_reparse(vnode_t *, cred_t *, caller_context_t *); + +void vn_copypath(struct vnode *src, struct vnode *dst); +void vn_setpath_str(struct vnode *vp, const char *str, size_t len); +void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp, + const char *path, size_t plen); +void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len); + +/* Private vnode manipulation functions */ +void vn_clearpath(vnode_t *, hrtime_t); +void vn_updatepath(vnode_t *, vnode_t *, const char *); + + +/* Vnode event notification */ +void vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *); +void vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *); +void vnevent_remove(vnode_t *, vnode_t *, char *, caller_context_t *); +void vnevent_rmdir(vnode_t *, vnode_t *, char *, caller_context_t *); +void vnevent_create(vnode_t *, caller_context_t *); +void vnevent_link(vnode_t *, caller_context_t *); +void vnevent_rename_dest_dir(vnode_t *, vnode_t *, char *, + caller_context_t *ct); +void vnevent_mountedover(vnode_t *, caller_context_t *); +void vnevent_truncate(vnode_t *, caller_context_t *); +int vnevent_support(vnode_t *, caller_context_t *); +void vnevent_pre_rename_src(vnode_t *, vnode_t *, char *, + caller_context_t *); +void vnevent_pre_rename_dest(vnode_t *, vnode_t *, char *, + caller_context_t *); +void vnevent_pre_rename_dest_dir(vnode_t *, vnode_t *, char *, + caller_context_t *); +void vnevent_resize(vnode_t *, caller_context_t *); + +/* Vnode specific data */ +void vsd_create(uint_t *, void (*)(void *)); +void vsd_destroy(uint_t *); +void *vsd_get(vnode_t *, uint_t); +int vsd_set(vnode_t *, uint_t, void *); +void vsd_free(vnode_t *); + +/* + * Extensible vnode attribute (xva) routines: + * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR) + * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t + */ +void xva_init(xvattr_t *); +xoptattr_t *xva_getxoptattr(xvattr_t *); /* Get ptr to xoptattr_t */ + +void xattr_init(void); /* Initialize vnodeops for xattrs */ + +/* GFS tunnel for xattrs */ +int xattr_dir_lookup(vnode_t *, vnode_t **, int, cred_t *); + +/* Reparse Point */ +void reparse_point_init(void); + +/* Context identification */ +u_longlong_t fs_new_caller_id(); + +int vn_vmpss_usepageio(vnode_t *); + +/* Empty v_path placeholder */ +extern char *vn_vpath_empty; + +/* + * Needed for use of IS_VMODSORT() in kernel. + */ +extern uint_t pvn_vmodsort_supported; + +/* + * All changes to v_count should be done through VN_HOLD() or VN_RELE(), or + * one of their variants. This makes it possible to ensure proper locking, + * and to guarantee that all modifications are accompanied by a firing of + * the vn-hold or vn-rele SDT DTrace probe. + * + * Example DTrace command for tracing vnode references using these probes: + * + * dtrace -q -n 'sdt:::vn-hold,sdt:::vn-rele + * { + * this->vp = (vnode_t *)arg0; + * printf("%s %s(%p[%s]) %d\n", execname, probename, this->vp, + * this->vp->v_path == NULL ? "NULL" : stringof(this->vp->v_path), + * this->vp->v_count) + * }' + * + * There are some situations where we don't want a hold to make the vnode + * 'busy'. For example, watching a directory via port events or inotify + * should not prevent a filesystem from mounting on a watched directory. + * For those instances, a phantom hold is used via VN_PHANTOM_HOLD(). + * + * A phantom hold works identically to regular hold, except that those holds + * are excluded from the return value of vn_count(). + * + * A phantom hold must be released by VN_PHANTOM_RELE(). + */ +#define VN_HOLD_LOCKED(vp) { \ + ASSERT(mutex_owned(&(vp)->v_lock)); \ + (vp)->v_count++; \ + DTRACE_PROBE1(vn__hold, vnode_t *, vp); \ +} + +#define VN_HOLD(vp) { \ + mutex_enter(&(vp)->v_lock); \ + VN_HOLD_LOCKED(vp); \ + mutex_exit(&(vp)->v_lock); \ +} + +#define VN_RELE(vp) { \ + vn_rele(vp); \ +} + +#define VN_RELE_ASYNC(vp, taskq) { \ + vn_rele_async(vp, taskq); \ +} + +#define VN_RELE_LOCKED(vp) { \ + ASSERT(mutex_owned(&(vp)->v_lock)); \ + ASSERT((vp)->v_count >= 1); \ + (vp)->v_count--; \ + DTRACE_PROBE1(vn__rele, vnode_t *, vp); \ +} + +#define VN_PHANTOM_HOLD_LOCKED(vp) { \ + VN_HOLD_LOCKED(vp); \ + (vp)->v_phantom_count++; \ + DTRACE_PROBE1(vn__phantom_hold, vnode_t *, vp); \ +} + +#define VN_PHANTOM_HOLD(vp) { \ + mutex_enter(&(vp)->v_lock); \ + VN_PHANTOM_HOLD_LOCKED(vp); \ + mutex_exit(&(vp)->v_lock); \ +} + +#define VN_PHANTOM_RELE(vp) { \ + vn_phantom_rele(vp); \ +} + +#define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \ + (vp)->v_vfsp = (vfsp); \ + (vp)->v_type = (type); \ + (vp)->v_rdev = (dev); \ +} + +/* + * Compare two vnodes for equality. In general this macro should be used + * in preference to calling VOP_CMP directly. + */ +#define VN_CMP(VP1, VP2) ((VP1) == (VP2) ? 1 : \ + ((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \ + VOP_CMP(VP1, VP2, NULL) : 0)) + +/* + * Some well-known global vnodes used by the VM system to name pages. + */ +extern struct vnode kvps[]; + +typedef enum { + KV_KVP, /* vnode for all segkmem pages */ + KV_ZVP, /* vnode for all ZFS pages */ + KV_VVP, /* vnode for all VMM pages */ +#if defined(__sparc) + KV_MPVP, /* vnode for all page_t meta-pages */ + KV_PROMVP, /* vnode for all PROM pages */ +#endif /* __sparc */ + KV_MAX /* total number of vnodes in kvps[] */ +} kvps_index_t; + +#define VN_ISKAS(vp) ((vp) >= &kvps[0] && (vp) < &kvps[KV_MAX]) + +#endif /* _KERNEL || _FAKE_KERNEL */ + +/* + * Flags to VOP_SETATTR/VOP_GETATTR. + */ +#define ATTR_UTIME 0x01 /* non-default utime(2) request */ +#define ATTR_EXEC 0x02 /* invocation from exec(2) */ +#define ATTR_COMM 0x04 /* yield common vp attributes */ +#define ATTR_HINT 0x08 /* information returned will be `hint' */ +#define ATTR_REAL 0x10 /* yield attributes of the real vp */ +#define ATTR_NOACLCHECK 0x20 /* Don't check ACL when checking permissions */ +#define ATTR_TRIGGER 0x40 /* Mount first if vnode is a trigger mount */ +#define ATTR_NOIMPLICIT 0x80 /* Disable any implicit owner rights */ +/* + * Generally useful macros. + */ +#define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize) + +#define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone) + +#define NULLVP ((struct vnode *)0) +#define NULLVPP ((struct vnode **)0) + +#ifdef _KERNEL + +/* + * Structure used while handling asynchronous VOP_PUTPAGE operations. + */ +struct async_reqs { + struct async_reqs *a_next; /* pointer to next arg struct */ + struct vnode *a_vp; /* vnode pointer */ + u_offset_t a_off; /* offset in file */ + uint_t a_len; /* size of i/o request */ + int a_flags; /* flags to indicate operation type */ + struct cred *a_cred; /* cred pointer */ + ushort_t a_prealloced; /* set if struct is pre-allocated */ +}; + +/* + * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE(). + * Note that there is no guarantee that the page passed in will be + * freed. If that is required, then a check after calling VN_DISPOSE would + * be necessary to ensure the page was freed. + */ +#define VN_DISPOSE(pp, flag, dn, cr) { \ + if ((pp)->p_vnode != NULL && !VN_ISKAS((pp)->p_vnode)) \ + VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr), NULL); \ + else if ((flag) == B_FREE) \ + page_free((pp), (dn)); \ + else \ + page_destroy((pp), (dn)); \ + } + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VNODE_H */ diff --git a/illumos-x86_64/usr/include/sys/vt.h b/illumos-x86_64/usr/include/sys/vt.h new file mode 100644 index 00000000..2ecaf37a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vt.h @@ -0,0 +1,121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _SYS_VT_H +#define _SYS_VT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Public IOCTLs supported by the VT, which are shared with + * other operating systems. + */ +#define VTIOC ('V'<<8) +#define VT_OPENQRY (VTIOC|1) /* inquires if this vt already open */ +#define VT_SETMODE (VTIOC|2) /* set vt into auto or process mode */ + +#define VT_GETMODE (VTIOC|3) /* returns mode vt is currently in */ +#define VT_RELDISP (VTIOC|4) /* tells vt when display released */ +#define VT_ACTIVATE (VTIOC|5) /* activates specified vt */ +#define VT_WAITACTIVE (VTIOC|6) /* wait for vt to be activated */ +#define VT_GETSTATE (VTIOC|100) /* returns active and open vts */ + +/* + * Solaris specific public IOCTL. + * Inquires if the vt functionality is available. + */ +#define VT_ENABLED (VTIOC|101) + +/* get/set the target of /dev/vt/console_user symbol link */ +#define VT_GET_CONSUSER (VTIOC|108) +#define VT_SET_CONSUSER (VTIOC|109) + +struct vt_mode { + char mode; /* mode to set vt into, VT_AUTO or VT_PROCESS */ + char waitv; /* if != 0, vt hangs on writes when not active */ + short relsig; /* signal to use for release request */ + short acqsig; /* signal to use for display acquired */ + short frsig; /* signal to use for forced release */ +}; + +/* vt switching mode */ +enum { + VT_AUTO = 0, /* this vt switching is automatic */ + VT_PROCESS /* this vt switching controlled by process */ +}; + +#define VT_ACKACQ 2 /* ack from v86 acquire routine */ + +/* + * structure used by VT_GETSTATE ioctl + */ + +struct vt_stat { + unsigned short v_active; + unsigned short v_signal; + unsigned short v_state; +}; + +/* project private IOCTLs */ +#define VT_CONFIG (VTIOC|102) /* config virtual console number */ +#define VT_SETDISPINFO (VTIOC|103) /* set display number */ +#define VT_SETDISPLOGIN (VTIOC|104) /* set display login */ +#define VT_GETDISPINFO (VTIOC|105) /* get display info */ + +/* + * setting target console is only used by vtdaemon + * to set target console while vtdaemon is authenticating + * for it, which is returned in VT_GETSTATE. At that + * time, the real active console is the vtdaemon special console, + * but VT_GETSTATE should not be aware of it. Instead, VT_GETACTIVE + * is used to get the real active console for vtdaemon. + */ +#define VT_SET_TARGET (VTIOC|106) +#define VT_GETACTIVE (VTIOC|107) + +/* + * Used by cn to convert a VT_SET_CONSUSER to a internal interface + * so that /dev/console and /dev/vt/0 could be differentiated. + */ +#define VT_RESET_CONSUSER (VTIOC|110) + +/* + * structure used by VT_GETDISPINFO + */ +struct vt_dispinfo { + pid_t v_pid; /* -1 if no display info (auto mode) */ + int v_dispnum; /* display number associated with vt */ + int v_login; /* if the user logged in the display */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VT_H */ diff --git a/illumos-x86_64/usr/include/sys/vtdaemon.h b/illumos-x86_64/usr/include/sys/vtdaemon.h new file mode 100644 index 00000000..95d512ef --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vtdaemon.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VTDAEMON_H +#define _SYS_VTDAEMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define VT_DAEMON_DOOR_FILE "/var/run/vt/vtdaemon_door" + +#define VT_EV_X_EXIT 0 /* */ +#define VT_EV_HOTKEYS 1 /* */ + +/* + * The structure of a request to vtdaemon. + */ +typedef struct vt_cmd_arg { + uchar_t vt_ev; + uint32_t vt_num; +} vt_cmd_arg_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VTDAEMON_H */ diff --git a/illumos-x86_64/usr/include/sys/vtoc.h b/illumos-x86_64/usr/include/sys/vtoc.h new file mode 100644 index 00000000..af55f868 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vtoc.h @@ -0,0 +1,365 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Toomas Soome + */ + + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYS_VTOC_H +#define _SYS_VTOC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Note: the VTOC is not implemented fully, nor in the manner + * that AT&T implements it. AT&T puts the vtoc structure + * into a sector, usually the second sector (pdsector is first). + * + * Sun incorporates the tag, flag, version, and volume vtoc fields into + * its Disk Label, which already has some vtoc-equivalent fields. + * Upon reading the vtoc with read_vtoc(), the following exceptions + * occur: + * v_bootinfo [all] returned as zero + * v_sanity returned as VTOC_SANE + * if Disk Label was sane + * v_sectorsz returned as 512 + * v_reserved [all] retunred as zero + * timestamp [all] returned as zero + * + * See dklabel.h, read_vtoc(), and write_vtoc(). + */ + +#define V_NUMPAR NDKMAP /* The number of partitions */ + /* (from dkio.h) */ + +#define VTOC_SANE 0x600DDEEE /* Indicates a sane VTOC */ +#define V_VERSION 0x01 /* layout version number */ +#define V_EXTVERSION V_VERSION /* extvtoc layout version number */ + +/* + * Partition identification tags + */ +#define V_UNASSIGNED 0x00 /* unassigned partition */ +#define V_BOOT 0x01 /* Boot partition */ +#define V_ROOT 0x02 /* Root filesystem */ +#define V_SWAP 0x03 /* Swap filesystem */ +#define V_USR 0x04 /* Usr filesystem */ +#define V_BACKUP 0x05 /* full disk */ +#define V_STAND 0x06 /* Stand partition */ +#define V_VAR 0x07 /* Var partition */ +#define V_HOME 0x08 /* Home partition */ +#define V_ALTSCTR 0x09 /* Alternate sector partition */ +#define V_CACHE 0x0a /* CacheFS partition (obsolete) */ + +/* Tags for EFI/GPT labels */ +#define V_RESERVED 0x0b /* SMI reserved data */ +#define V_SYSTEM 0x0c /* EFI/GPT system partition */ +#define V_BIOS_BOOT 0x18 /* BIOS Boot partition */ + +#define V_VXVM_PUB 0x0e /* VxVM public region */ +#define V_VXVM_PRIV 0x0f /* VxVM private region */ + +#define V_BIOS_BOOT 0x18 /* Grub2 BIOS Boot partition */ + +/* NetBSD/mips defines this */ +#define V_NETBSD_FFS 0xff + +/* FreeBSD tags: the high byte equals ELFOSABI_FREEBSD */ +#define V_FREEBSD_BOOT 0x0900 +#define V_FREEBSD_SWAP 0x0901 +#define V_FREEBSD_UFS 0x0902 +#define V_FREEBSD_VINUM 0x0903 +#define V_FREEBSD_ZFS 0x0904 +#define V_FREEBSD_NANDFS 0x0905 + +#define V_UNKNOWN 0xffff /* Unknown partition */ + +/* + * Partition permission flags + */ +#define V_UNMNT 0x01 /* Unmountable partition */ +#define V_RONLY 0x10 /* Read only */ + +/* + * error codes for reading & writing vtoc + */ +#define VT_ERROR (-2) /* errno supplies specific error */ +#define VT_EIO (-3) /* I/O error accessing vtoc */ +#define VT_EINVAL (-4) /* illegal value in vtoc or request */ +#define VT_ENOTSUP (-5) /* VTOC op. not supported */ +#define VT_ENOSPC (-6) /* requested space not found */ +#define VT_EOVERFLOW (-7) /* VTOC op. data struct limited */ + +struct partition { + ushort_t p_tag; /* ID tag of partition */ + ushort_t p_flag; /* permission flags */ + daddr_t p_start; /* start sector no of partition */ + long p_size; /* # of blocks in partition */ +}; + +struct vtoc { + unsigned long v_bootinfo[3]; /* info needed by mboot (unsupported) */ + unsigned long v_sanity; /* to verify vtoc sanity */ + unsigned long v_version; /* layout version */ + char v_volume[LEN_DKL_VVOL]; /* volume name */ + ushort_t v_sectorsz; /* sector size in bytes */ + ushort_t v_nparts; /* number of partitions */ + unsigned long v_reserved[10]; /* free space */ + struct partition v_part[V_NUMPAR]; /* partition headers */ + time_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */ + char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ +}; + +struct extpartition { + ushort_t p_tag; /* ID tag of partition */ + ushort_t p_flag; /* permission flags */ + ushort_t p_pad[2]; + diskaddr_t p_start; /* start sector no of partition */ + diskaddr_t p_size; /* # of blocks in partition */ +}; + + +struct extvtoc { + uint64_t v_bootinfo[3]; /* info needed by mboot (unsupported) */ + uint64_t v_sanity; /* to verify vtoc sanity */ + uint64_t v_version; /* layout version */ + char v_volume[LEN_DKL_VVOL]; /* volume name */ + ushort_t v_sectorsz; /* sector size in bytes */ + ushort_t v_nparts; /* number of partitions */ + ushort_t pad[2]; + uint64_t v_reserved[10]; + struct extpartition v_part[V_NUMPAR]; /* partition headers */ + uint64_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */ + char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ +}; + +#ifdef _KERNEL +#define extvtoctovtoc(extv, v) \ + { \ + int i; \ + v.v_bootinfo[0] = (unsigned long)extv.v_bootinfo[0]; \ + v.v_bootinfo[1] = (unsigned long)extv.v_bootinfo[1]; \ + v.v_bootinfo[2] = (unsigned long)extv.v_bootinfo[2]; \ + v.v_sanity = (unsigned long)extv.v_sanity; \ + v.v_version = (unsigned long)extv.v_version; \ + bcopy(extv.v_volume, v.v_volume, LEN_DKL_VVOL); \ + v.v_sectorsz = extv.v_sectorsz; \ + v.v_nparts = extv.v_nparts; \ + for (i = 0; i < 10; i++) \ + v.v_reserved[i] = (unsigned long)extv.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + v.v_part[i].p_tag = extv.v_part[i].p_tag; \ + v.v_part[i].p_flag = extv.v_part[i].p_flag; \ + v.v_part[i].p_start = (daddr_t)extv.v_part[i].p_start; \ + v.v_part[i].p_size = (long)extv.v_part[i].p_size; \ + v.timestamp[i] = (time_t)extv.timestamp[i]; \ + } \ + bcopy(extv.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \ + } + +#define vtoctoextvtoc(v, extv) \ + { \ + int i; \ + extv.v_bootinfo[0] = (uint64_t)v.v_bootinfo[0]; \ + extv.v_bootinfo[1] = (uint64_t)v.v_bootinfo[1]; \ + extv.v_bootinfo[2] = (uint64_t)v.v_bootinfo[2]; \ + extv.v_sanity = (uint64_t)v.v_sanity; \ + extv.v_version = (uint64_t)v.v_version; \ + bcopy(v.v_volume, extv.v_volume, LEN_DKL_VVOL); \ + extv.v_sectorsz = v.v_sectorsz; \ + extv.v_nparts = v.v_nparts; \ + for (i = 0; i < 10; i++) \ + extv.v_reserved[i] = (uint64_t)v.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + extv.v_part[i].p_tag = v.v_part[i].p_tag; \ + extv.v_part[i].p_flag = v.v_part[i].p_flag; \ + extv.v_part[i].p_start = \ + (diskaddr_t)(unsigned long)v.v_part[i].p_start; \ + extv.v_part[i].p_size = \ + (diskaddr_t)(unsigned long)v.v_part[i].p_size; \ + extv.timestamp[i] = (uint64_t)v.timestamp[i]; \ + } \ + bcopy(v.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII); \ + } +#endif /* _KERNEL */ + +#if defined(_SYSCALL32) +struct partition32 { + uint16_t p_tag; /* ID tag of partition */ + uint16_t p_flag; /* permission flags */ + daddr32_t p_start; /* start sector no of partition */ + int32_t p_size; /* # of blocks in partition */ +}; + +struct vtoc32 { + uint32_t v_bootinfo[3]; /* info needed by mboot (unsupported) */ + uint32_t v_sanity; /* to verify vtoc sanity */ + uint32_t v_version; /* layout version */ + char v_volume[LEN_DKL_VVOL]; /* volume name */ + uint16_t v_sectorsz; /* sector size in bytes */ + uint16_t v_nparts; /* number of partitions */ + uint32_t v_reserved[10]; /* free space */ + struct partition32 v_part[V_NUMPAR]; /* partition headers */ + time32_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */ + char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ +}; + +#define vtoc32tovtoc(v32, v) \ + { \ + int i; \ + v.v_bootinfo[0] = v32.v_bootinfo[0]; \ + v.v_bootinfo[1] = v32.v_bootinfo[1]; \ + v.v_bootinfo[2] = v32.v_bootinfo[2]; \ + v.v_sanity = v32.v_sanity; \ + v.v_version = v32.v_version; \ + bcopy(v32.v_volume, v.v_volume, LEN_DKL_VVOL); \ + v.v_sectorsz = v32.v_sectorsz; \ + v.v_nparts = v32.v_nparts; \ + v.v_version = v32.v_version; \ + for (i = 0; i < 10; i++) \ + v.v_reserved[i] = v32.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + v.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \ + v.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \ + v.v_part[i].p_start = (unsigned)v32.v_part[i].p_start; \ + v.v_part[i].p_size = (unsigned)v32.v_part[i].p_size; \ + } \ + for (i = 0; i < V_NUMPAR; i++) \ + v.timestamp[i] = (time_t)v32.timestamp[i]; \ + bcopy(v32.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \ + } + +#define vtoc32toextvtoc(v32, extv) \ + { \ + int i; \ + extv.v_bootinfo[0] = v32.v_bootinfo[0]; \ + extv.v_bootinfo[1] = v32.v_bootinfo[1]; \ + extv.v_bootinfo[2] = v32.v_bootinfo[2]; \ + extv.v_sanity = v32.v_sanity; \ + extv.v_version = v32.v_version; \ + bcopy(v32.v_volume, extv.v_volume, LEN_DKL_VVOL); \ + extv.v_sectorsz = v32.v_sectorsz; \ + extv.v_nparts = v32.v_nparts; \ + extv.v_version = v32.v_version; \ + for (i = 0; i < 10; i++) \ + extv.v_reserved[i] = v32.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + extv.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \ + extv.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \ + extv.v_part[i].p_start = (diskaddr_t)v32.v_part[i].p_start; \ + extv.v_part[i].p_size = (diskaddr_t)v32.v_part[i].p_size; \ + extv.timestamp[i] = (time_t)v32.timestamp[i]; \ + } \ + bcopy(v32.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII); \ + } + + +#define vtoctovtoc32(v, v32) \ + { \ + int i; \ + v32.v_bootinfo[0] = (uint32_t)v.v_bootinfo[0]; \ + v32.v_bootinfo[1] = (uint32_t)v.v_bootinfo[1]; \ + v32.v_bootinfo[2] = (uint32_t)v.v_bootinfo[2]; \ + v32.v_sanity = (uint32_t)v.v_sanity; \ + v32.v_version = (uint32_t)v.v_version; \ + bcopy(v.v_volume, v32.v_volume, LEN_DKL_VVOL); \ + v32.v_sectorsz = v.v_sectorsz; \ + v32.v_nparts = v.v_nparts; \ + v32.v_version = (uint32_t)v.v_version; \ + for (i = 0; i < 10; i++) \ + v32.v_reserved[i] = v.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + v32.v_part[i].p_tag = (ushort_t)v.v_part[i].p_tag; \ + v32.v_part[i].p_flag = (ushort_t)v.v_part[i].p_flag; \ + v32.v_part[i].p_start = (unsigned)v.v_part[i].p_start; \ + v32.v_part[i].p_size = (unsigned)v.v_part[i].p_size; \ + } \ + for (i = 0; i < V_NUMPAR; i++) { \ + if (v.timestamp[i] > TIME32_MAX) \ + v32.timestamp[i] = TIME32_MAX; \ + else \ + v32.timestamp[i] = (time32_t)v.timestamp[i]; \ + } \ + bcopy(v.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \ + } + +#define extvtoctovtoc32(extv, v32) \ + { \ + int i; \ + v32.v_bootinfo[0] = extv.v_bootinfo[0]; \ + v32.v_bootinfo[1] = extv.v_bootinfo[1]; \ + v32.v_bootinfo[2] = extv.v_bootinfo[2]; \ + v32.v_sanity = extv.v_sanity; \ + v32.v_version = extv.v_version; \ + bcopy(extv.v_volume, v32.v_volume, LEN_DKL_VVOL); \ + v32.v_sectorsz = extv.v_sectorsz; \ + v32.v_nparts = extv.v_nparts; \ + v32.v_version = extv.v_version; \ + for (i = 0; i < 10; i++) \ + v32.v_reserved[i] = extv.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + v32.v_part[i].p_tag = (ushort_t)extv.v_part[i].p_tag; \ + v32.v_part[i].p_flag = (ushort_t)extv.v_part[i].p_flag; \ + v32.v_part[i].p_start = (unsigned)extv.v_part[i].p_start; \ + v32.v_part[i].p_size = (unsigned)extv.v_part[i].p_size; \ + } \ + for (i = 0; i < V_NUMPAR; i++) { \ + if (extv.timestamp[i] > TIME32_MAX) \ + v32.timestamp[i] = TIME32_MAX; \ + else \ + v32.timestamp[i] = (time32_t)extv.timestamp[i]; \ + } \ + bcopy(extv.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \ + } + + +#endif /* _SYSCALL32 */ + +/* + * These defines are the mode parameter for the checksum routines. + */ +#define CK_CHECKSUM 0 /* check checksum */ +#define CK_MAKESUM 1 /* generate checksum */ + +extern int read_vtoc(int, struct vtoc *); +extern int write_vtoc(int, struct vtoc *); +extern int read_extvtoc(int, struct extvtoc *); +extern int write_extvtoc(int, struct extvtoc *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VTOC_H */ diff --git a/illumos-x86_64/usr/include/sys/vtrace.h b/illumos-x86_64/usr/include/sys/vtrace.h new file mode 100644 index 00000000..b4f0482d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vtrace.h @@ -0,0 +1,1121 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYS_VTRACE_H +#define _SYS_VTRACE_H + +#ifndef _ASM +#include +#include +#ifdef _KERNEL +#include +#endif /* _KERNEL */ +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * vtrace is a legacy tracing framework that has been subsumed by the DTrace + * framework. To allow tracing of legacy vtrace points, the points themselves + * have been retained, and are provided to DTrace via the "vtrace" DTrace + * provider (which is itself implemented in terms of the statically defined + * tracing provider). Provided in this header file are the facility + * definitions currently in use, along with the specific tracing codes still + * in use. They are here purely for understanding extant vtrace points; the + * constants should not be changed, and should not be added to. (And any all + * new tracing points should be implemented in terms of DTRACE_PROBE() and + * friends.) + */ +#define TR_FAC_TRAP 2 /* traps */ +#define TR_FAC_INTR 3 /* interrupts */ +#define TR_FAC_DISP 5 /* dispatcher */ +#define TR_FAC_VM 6 /* VM system */ +#define TR_FAC_PROC 7 /* process subsystem */ +#define TR_FAC_STREAMS_FR 11 /* STREAMS framework */ +#define TR_FAC_TCP 14 /* tcp protocol module */ +#define TR_FAC_UDP 15 /* udp protocol module */ +#define TR_FAC_IP 16 /* ip protocol module */ +#define TR_FAC_ARP 17 /* arp protocol module */ +#define TR_FAC_LE 18 /* lance ethernet driver */ +#define TR_FAC_SCSI 21 /* SCSI */ +#define TR_FAC_CALLOUT 24 /* callout table */ +#define TR_FAC_SPECFS 29 /* specfs fileystem */ +#define TR_FAC_SWAPFS 30 /* swapfs fileystem */ +#define TR_FAC_TMPFS 31 /* tmpfs fileystem */ +#define TR_FAC_UFS 32 /* UFS */ +#define TR_FAC_NFS 33 /* NFS */ +#define TR_FAC_KRPC 36 /* Kernel RPC */ +#define TR_FAC_SCHED 37 /* swapper */ +#define TR_FAC_SCSI_RES 38 /* SCSI_RESOURCE */ +#define TR_FAC_SCSI_ISP 39 /* ISP HBA Driver SCSI */ +#define TR_FAC_IA 40 /* IA scheduling class */ +#define TR_FAC_BE 43 /* Fast Ethernet driver */ +#define TR_FAC_FIFO 44 /* Fifos */ +#define TR_FAC_RLOGINP 45 /* rlmod protocol module */ +#define TR_FAC_PHYSIO 47 /* physio */ +#define TR_FAC_META 48 /* meta disk */ +#define TR_FAC_SCSI_FAS 49 /* fas scsi HBA driver */ +#define TR_FAC_SOCKFS 50 /* socket fileystem */ +#define TR_FAC_DEVMAP 51 /* devmap */ +#define TR_FAC_DADA 52 /* target driver for ide */ + +/* + * TR_FAC_TRAP tags + */ + +#define TR_TRAP_END 1 +#define TR_C_TRAP_HANDLER_ENTER 6 +#define TR_C_TRAP_HANDLER_EXIT 7 + +/* + * TR_FAC_INTR tags + */ + +#define TR_INTR_PASSIVATE 3 + +/* + * TR_FAC_DISP tags + */ + +#define TR_DISP_START 0 +#define TR_DISP_END 1 +#define TR_SWTCH_START 2 +#define TR_SWTCH_END 3 +#define TR_PREEMPT_START 4 +#define TR_PREEMPT_END 5 +#define TR_RESUME_START 6 +#define TR_FRONTQ 8 +#define TR_BACKQ 9 +#define TR_CPU_RESCHED 10 +#define TR_SLEEP 11 +#define TR_TRAPRET 12 +#define TR_TICK 13 +#define TR_UPDATE 14 +#define TR_CPU_SURRENDER 16 +#define TR_PREEMPT 17 + + +/* + * TR_FAC_VM tags + */ + +#define TR_PAGE_INIT 0 +#define TR_PAGE_WS_IN 1 +#define TR_PAGE_WS_OUT 2 +#define TR_PAGE_WS_FREE 3 +#define TR_PAGEOUT_START 5 +#define TR_PAGEOUT_END 6 +#define TR_PAGEOUT_HAND_WRAP 7 +#define TR_PAGEOUT_ISREF 9 +#define TR_PAGEOUT_FREE 10 +#define TR_PAGEOUT_CV_SIGNAL 11 +#define TR_SEGMAP_FAULT 20 +#define TR_SEGMAP_GETMAP 21 +#define TR_SEGMAP_RELMAP 22 +#define TR_SEGMAP_PAGECREATE 23 +#define TR_SEGMAP_GETPAGE 24 +#define TR_SEGVN_FAULT 25 +#define TR_SEGVN_GETPAGE 26 +#define TR_ANON_GETPAGE 27 +#define TR_ANON_PRIVATE 28 +#define TR_SWAP_ALLOC 30 +#define TR_PVN_READ_KLUSTER 31 +#define TR_PVN_GETDIRTY 32 +#define TR_PAGE_CREATE_START 33 +#define TR_PAGE_CREATE_TOOBIG 34 +#define TR_PAGE_CREATE_NOMEM 35 +#define TR_PAGE_CREATE_SUCCESS 36 +#define TR_PAGE_CREATE_SLEEP_START 37 +#define TR_PAGE_CREATE_SLEEP_END 38 +#define TR_PAGE_FREE_FREE 40 +#define TR_PAGE_FREE_CACHE_HEAD 41 +#define TR_PAGE_FREE_CACHE_TAIL 42 +#define TR_PAGE_UNFREE_FREE 43 +#define TR_PAGE_UNFREE_CACHE 44 +#define TR_PAGE_DESTROY 45 +#define TR_PAGE_HASHIN 46 +#define TR_PAGE_HASHOUT 47 +#define TR_ANON_PROC 48 +#define TR_ANON_SHM 49 +#define TR_ANON_TMPFS 50 +#define TR_ANON_SEGKP 53 +#define TR_SAMPLE_WS_START 56 +#define TR_SAMPLE_WS_END 57 +#define TR_AS_INFO 59 +#define TR_SEG_INFO 60 +#define TR_PAGE_RENAME 61 + +/* + * TR_FAC_PROC tags + */ + +#define TR_PROC_EXEC 0 +#define TR_PROC_EXIT 1 +#define TR_PROC_FORK 2 +#define TR_EXECMAP_PREREAD 3 +#define TR_EXECMAP_NO_PREREAD 4 + +/* + * TR_FAC_SCHED tags + */ + +#define TR_SWAPIN 0 +#define TR_SWAPOUT 1 +#define TR_RUNIN 2 +#define TR_RUNOUT 3 +#define TR_CHOOSE_SWAPOUT 4 +#define TR_CHOOSE_SWAPIN 5 +#define TR_SOFTSWAP 6 +#define TR_DESPERATE 8 +#define TR_HIGH_DEFICIT 9 +#define TR_SWAPIN_VALUES 10 +#define TR_UNLOAD 11 +#define TR_SWAPOUT_LWP 12 +#define TR_SWAPQ_LWP 13 +#define TR_SWAPQ_PROC 14 + +/* + * TR_FAC_STREAMS_FR tags + */ + +#define TR_STRREAD_AWAKE 6 +#define TR_STRRPUT_PROTERR 8 +#define TR_I_PUSH 14 +#define TR_I_POP 15 +#define TR_STRSENDSIG 24 +#define TR_QATTACH_FLAGS 25 +#define TR_STRWAITQ_TIME 31 +#define TR_STRWAITQ_WAIT2 32 +#define TR_STRWAITQ_INTR2 33 +#define TR_STRWAITQ_WAKE2 34 +#define TR_QRUNSERVICE_START 39 +#define TR_SENDSIG 42 +#define TR_INSERTQ 43 +#define TR_REMOVEQ 44 +#define TR_CANPUT_IN 47 +#define TR_CANPUT_OUT 48 +#define TR_BCANPUT_IN 49 +#define TR_BCANPUT_OUT 50 +#define TR_STRWRITE_IN 51 +#define TR_STRWRITE_OUT 52 +#define TR_STRWRITE_WAIT 53 +#define TR_STRWRITE_WAKE 54 +#define TR_STRWRITE_RESID 56 +#define TR_STRPUTMSG_IN 57 +#define TR_STRPUTMSG_WAIT 58 +#define TR_STRPUTMSG_WAKE 59 +#define TR_STRPUTMSG_OUT 60 +#define TR_QRUNSERVICE_END 65 +#define TR_PUT_START 68 +#define TR_PUTNEXT_START 70 +#define TR_PUTNEXT_END 71 +#define TR_DRAIN_SYNCQ_START 72 +#define TR_DRAIN_SYNCQ_END 73 +#define TR_STRGETMSG_ENTER 74 +#define TR_STRGETMSG_WAIT 75 +#define TR_STRGETMSG_DONE 76 +#define TR_STRGETMSG_AWAKE 77 +#define TR_KSTRGETMSG_ENTER 78 +#define TR_KSTRGETMSG_WAIT 79 +#define TR_KSTRGETMSG_DONE 80 +#define TR_KSTRGETMSG_AWAKE 81 +#define TR_KSTRPUTMSG_IN 82 +#define TR_KSTRPUTMSG_WAIT 83 +#define TR_KSTRPUTMSG_WAKE 84 +#define TR_KSTRPUTMSG_OUT 85 +#define TR_CANPUTNEXT_IN 86 +#define TR_CANPUTNEXT_OUT 87 + +/* + * TR_FAC_TCP tags + */ + +#define TR_TCP_RPUT_IN 2 +#define TR_TCP_RPUT_OUT 3 +#define TR_TCP_WPUT_IN 4 +#define TR_TCP_WPUT_OUT 5 +#define TR_TCP_RSRV_IN 6 +#define TR_TCP_RSRV_OUT 7 +#define TR_TCP_WSRV_IN 8 + +/* + * TR_FAC_UDP tags + */ + +#define TR_UDP_OPEN 0 +#define TR_UDP_CLOSE 1 +#define TR_UDP_RPUT_START 2 +#define TR_UDP_RPUT_END 3 +#define TR_UDP_WPUT_START 4 +#define TR_UDP_WPUT_END 5 +#define TR_UDP_WPUT_OTHER_START 6 +#define TR_UDP_WPUT_OTHER_END 7 + +/* + * TR_FAC_IP tags + */ + +#define TR_IP_OPEN 0 +#define TR_IP_CLOSE 1 +#define TR_IP_RPUT_START 2 +#define TR_IP_RPUT_END 3 +#define TR_IP_WPUT_START 4 +#define TR_IP_WPUT_END 5 +#define TR_IP_RPUT_LOCL_START 12 +#define TR_IP_RPUT_LOCL_END 13 +#define TR_IP_RPUT_LOCL_ERR 14 +#define TR_IP_RSRV_START 15 +#define TR_IP_RSRV_END 16 +#define TR_IP_CKSUM_START 17 +#define TR_IP_CKSUM_END 18 +#define TR_IP_WPUT_IRE_START 21 +#define TR_IP_WPUT_IRE_END 22 +#define TR_IP_WPUT_FRAG_START 23 +#define TR_IP_WPUT_FRAG_END 24 +#define TR_IP_WPUT_LOCAL_START 25 +#define TR_IP_WPUT_LOCAL_END 26 + +/* + * TR_FAC_ARP tags + */ + +#define TR_ARP_OPEN 0 +#define TR_ARP_CLOSE 1 +#define TR_ARP_RPUT_START 2 +#define TR_ARP_RPUT_END 3 +#define TR_ARP_WPUT_START 4 +#define TR_ARP_WPUT_END 5 +#define TR_ARP_WSRV_START 6 +#define TR_ARP_WSRV_END 7 + +/* + * TR_FAC_LE tags + */ + +#define TR_LE_OPEN 0 +#define TR_LE_CLOSE 1 +#define TR_LE_WPUT_START 2 +#define TR_LE_WPUT_END 3 +#define TR_LE_WSRV_START 4 +#define TR_LE_WSRV_END 5 +#define TR_LE_START_START 6 +#define TR_LE_START_END 7 +#define TR_LE_INTR_START 8 +#define TR_LE_INTR_END 9 +#define TR_LE_READ_START 10 +#define TR_LE_READ_END 11 +#define TR_LE_SENDUP_START 12 +#define TR_LE_SENDUP_END 13 +#define TR_LE_ADDUDIND_START 14 +#define TR_LE_ADDUDIND_END 15 +#define TR_LE_GETBUF_START 16 +#define TR_LE_GETBUF_END 17 +#define TR_LE_FREEBUF_START 18 +#define TR_LE_FREEBUF_END 19 +#define TR_LE_PROTO_START 20 +#define TR_LE_PROTO_END 21 +#define TR_LE_INIT_START 22 +#define TR_LE_INIT_END 23 + +/* + * TR_FAC_BE tags + */ + +#define TR_BE_OPEN 0 +#define TR_BE_CLOSE 1 +#define TR_BE_WPUT_START 2 +#define TR_BE_WPUT_END 3 +#define TR_BE_WSRV_START 4 +#define TR_BE_WSRV_END 5 +#define TR_BE_START_START 6 +#define TR_BE_START_END 7 +#define TR_BE_INTR_START 8 +#define TR_BE_INTR_END 9 +#define TR_BE_READ_START 10 +#define TR_BE_READ_END 11 +#define TR_BE_SENDUP_START 12 +#define TR_BE_SENDUP_END 13 +#define TR_BE_ADDUDIND_START 14 +#define TR_BE_ADDUDIND_END 15 +#define TR_BE_PROTO_START 20 +#define TR_BE_PROTO_END 21 +#define TR_BE_INIT_START 22 + +/* + * TR_FAC_PHYSIO + */ +#define TR_PHYSIO_START 0 +#define TR_PHYSIO_LOCK_START 1 +#define TR_PHYSIO_LOCK_END 2 +#define TR_PHYSIO_UNLOCK_START 3 +#define TR_PHYSIO_UNLOCK_END 4 +#define TR_PHYSIO_GETBUF_START 5 +#define TR_PHYSIO_GETBUF_END 6 +#define TR_PHYSIO_END 7 +#define TR_PHYSIO_AS_LOCK_START 8 +#define TR_PHYSIO_SEG_LOCK_START 9 +#define TR_PHYSIO_SEG_LOCK_END 10 +#define TR_PHYSIO_AS_FAULT_START 11 +#define TR_PHYSIO_AS_LOCK_END 12 +#define TR_PHYSIO_AS_UNLOCK_START 13 +#define TR_PHYSIO_SEG_UNLOCK_START 14 +#define TR_PHYSIO_AS_UNLOCK_END 15 +#define TR_PHYSIO_SEGVN_START 16 +#define TR_PHYSIO_SEGVN_UNLOCK_END 17 +#define TR_PHYSIO_SEGVN_HIT_END 18 +#define TR_PHYSIO_SEGVN_FILL_END 19 +#define TR_PHYSIO_SEGVN_MISS_END 20 + +/* + * TR_FAC_IA tags + */ + +#define TR_PID_ON 0 +#define TR_PID_OFF 1 +#define TR_GROUP_ON 2 +#define TR_GROUP_OFF 3 +#define TR_ACTIVE_CHAIN 5 + +/* + * TR_FAC_SCSI tags + */ + +#define TR_ESPSVC_ACTION_CALL 0 +#define TR_ESPSVC_START 1 +#define TR_ESPSVC_END 2 +#define TR_ESP_CALLBACK_START 3 +#define TR_ESP_CALLBACK_END 4 +#define TR_ESP_DOPOLL_START 5 +#define TR_ESP_DOPOLL_END 6 +#define TR_ESP_FINISH_START 7 +#define TR_ESP_FINISH_END 8 +#define TR_ESP_FINISH_SELECT_START 9 +#define TR_ESP_FINISH_SELECT_RESET1_END 10 +#define TR_ESP_FINISH_SELECT_FINISH_END 13 +#define TR_ESP_FINISH_SELECT_ACTION1_END 14 +#define TR_ESP_FINISH_SELECT_ACTION2_END 15 +#define TR_ESP_FINISH_SELECT_RESET2_END 16 +#define TR_ESP_FINISH_SELECT_RESET3_END 17 +#define TR_ESP_FINISH_SELECT_ACTION3_END 18 +#define TR_ESP_HANDLE_CLEARING_START 19 +#define TR_ESP_HANDLE_CLEARING_END 20 +#define TR_ESP_HANDLE_CLEARING_RETURN1_END 22 +#define TR_ESP_HANDLE_CLEARING_ABORT_END 23 +#define TR_ESP_HANDLE_CLEARING_RETURN3_END 26 +#define TR_ESP_HANDLE_CMD_START_START 27 +#define TR_ESP_HANDLE_CMD_START_END 28 +#define TR_ESP_HANDLE_CMD_DONE_START 30 +#define TR_ESP_HANDLE_CMD_DONE_END 31 +#define TR_ESP_HANDLE_CMD_DONE_ABORT1_END 32 +#define TR_ESP_HANDLE_CMD_DONE_ABORT2_END 33 +#define TR_ESP_HANDLE_C_CMPLT_START 34 +#define TR_ESP_HANDLE_C_CMPLT_RETURN1_END 36 +#define TR_ESP_HANDLE_C_CMPLT_ACTION1_END 37 +#define TR_ESP_HANDLE_C_CMPLT_ACTION2_END 38 +#define TR_ESP_HANDLE_C_CMPLT_ACTION3_END 39 +#define TR_ESP_HANDLE_C_CMPLT_ACTION4_END 40 +#define TR_ESP_HANDLE_C_CMPLT_RETURN2_END 41 +#define TR_ESP_HANDLE_C_CMPLT_ACTION5_END 42 +#define TR_ESP_HANDLE_C_CMPLT_PHASEMANAGE_END 43 +#define TR_ESP_HANDLE_DATA_START 44 +#define TR_ESP_HANDLE_DATA_END 45 +#define TR_ESP_HANDLE_DATA_ABORT1_END 46 +#define TR_ESP_HANDLE_DATA_ABORT2_END 47 +#define TR_ESP_HANDLE_DATA_ABORT3_END 48 +#define TR_ESP_HANDLE_DATA_DONE_START 49 +#define TR_ESP_HANDLE_DATA_DONE_END 50 +#define TR_ESP_HANDLE_DATA_DONE_RESET_END 51 +#define TR_ESP_HANDLE_DATA_DONE_PHASEMANAGE_END 52 +#define TR_ESP_HANDLE_MORE_MSGIN_START 55 +#define TR_ESP_HANDLE_MORE_MSGIN_RETURN2_END 57 +#define TR_ESP_HANDLE_MSG_IN_START 58 +#define TR_ESP_HANDLE_MSG_IN_END 59 +#define TR_ESP_HANDLE_MSG_IN_DONE_START 60 +#define TR_ESP_HANDLE_MSG_IN_DONE_SNDMSG_END 64 +#define TR_ESP_HANDLE_MSG_IN_DONE_ACTION_END 65 +#define TR_ESP_HANDLE_MSG_IN_DONE_RETURN2_END 66 +#define TR_ESP_HANDLE_MSG_OUT_START 67 +#define TR_ESP_HANDLE_MSG_OUT_END 68 +#define TR_ESP_HANDLE_MSG_OUT_PHASEMANAGE_END 69 +#define TR_ESP_HANDLE_MSG_OUT_DONE_START 70 +#define TR_ESP_HANDLE_MSG_OUT_DONE_END 71 +#define TR_ESP_HANDLE_MSG_OUT_DONE_PHASEMANAGE_END 73 +#define TR_ESP_HANDLE_UNKNOWN_START 76 +#define TR_ESP_HANDLE_UNKNOWN_INT_DISCON_END 78 +#define TR_ESP_HANDLE_UNKNOWN_RESET_END 84 +#define TR_ESP_ISTART_START 89 +#define TR_ESP_ISTART_END 90 +#define TR_ESP_PHASEMANAGE_CALL 91 +#define TR_ESP_PHASEMANAGE_START 92 +#define TR_ESP_PHASEMANAGE_END 93 +#define TR_ESP_RECONNECT_START 96 +#define TR_ESP_RECONNECT_F2_END 99 +#define TR_ESP_RECONNECT_RETURN2_END 107 +#define TR_ESP_RECONNECT_RESET5_END 108 +#define TR_ESP_RUNPOLL_START 109 +#define TR_ESP_RUNPOLL_END 110 +#define TR_ESP_SCSI_IMPL_PKTALLOC_START 111 +#define TR_ESP_SCSI_IMPL_PKTALLOC_END 112 +#define TR_ESP_SCSI_IMPL_PKTFREE_START 113 +#define TR_ESP_SCSI_IMPL_PKTFREE_END 114 +#define TR_ESP_STARTCMD_START 115 +#define TR_ESP_STARTCMD_END 116 +#define TR_ESP_STARTCMD_RE_SELECTION_END 117 +#define TR_ESP_STARTCMD_ALLOC_TAG2_END 119 +#define TR_ESP_STARTCMD_PREEMPT_CALL 120 +#define TR_ESP_START_START 121 +#define TR_ESP_START_END 122 +#define TR_ESP_START_PREPARE_PKT_END 123 +#define TR_ESP_WATCH_START 124 +#define TR_ESP_WATCH_END 125 +#define TR_MAKE_SD_CMD_START 126 +#define TR_MAKE_SD_CMD_END 127 +#define TR_MAKE_SD_CMD_INIT_PKT_START 136 +#define TR_MAKE_SD_CMD_INIT_PKT_END 137 +#define TR_MAKE_SD_CMD_INIT_PKT_SBUF_START 138 +#define TR_MAKE_SD_CMD_INIT_PKT_SBUF_END 139 +#define TR_SDDONE_BIODONE_CALL 142 +#define TR_SDDONE_START 143 +#define TR_SDDONE_END 144 +#define TR_SDINTR_START 145 +#define TR_SDINTR_END 146 +#define TR_SDINTR_COMMAND_DONE_END 147 +#define TR_SDRUNOUT_START 150 +#define TR_SDRUNOUT_END 151 +#define TR_SDSTART_START 152 +#define TR_SDSTART_END 153 +#define TR_SDSTART_NO_WORK_END 154 +#define TR_SDSTART_NO_RESOURCES_END 155 +#define TR_SDSTRATEGY_START 156 +#define TR_SDSTRATEGY_END 157 +#define TR_SDSTRATEGY_DISKSORT_START 158 +#define TR_SDSTRATEGY_DISKSORT_END 159 +#define TR_SD_CHECK_ERROR_START 162 +#define TR_SD_CHECK_ERROR_END 164 +#define TR__ESP_START_START 165 +#define TR__ESP_START_END 166 +#define TR_ESP_EMPTY_STARTQ_START 169 +#define TR_ESP_EMPTY_STARTQ_END 170 +#define TR_SDSTRATEGY_SMALL_WINDOW_START 171 +#define TR_SDSTRATEGY_SMALL_WINDOW_END 172 +#define TR_SDSTART_SMALL_WINDOW_START 173 +#define TR_SDSTART_SMALL_WINDOW_END 174 +#define TR_ESP_USTART_START 175 +#define TR_ESP_USTART_END 176 +#define TR_ESP_USTART_NOT_FOUND_END 177 +#define TR_ESP_USTART_DEFAULT_END 178 +#define TR_ESP_PREPARE_PKT_TRAN_BADPKT_END 180 +#define TR_ESP_PREPARE_PKT_TRAN_ACCEPT_END 181 +#define TR_ESP_ALLOC_TAG_START 182 +#define TR_ESP_ALLOC_TAG_END 183 +#define TR_ESP_CALL_PKT_COMP_START 184 +#define TR_ESP_CALL_PKT_COMP_END 185 +#define TR_ESP_SCSI_IMPL_DMAFREE_START 192 +#define TR_ESP_SCSI_IMPL_DMAFREE_END 193 + +/* + * TR_FAC_SCSI_ISP tags + */ + +#define TR_ISP_SCSI_GETCAP_START 1 +#define TR_ISP_SCSI_GETCAP_END 2 +#define TR_ISP_SCSI_SETCAP_START 3 +#define TR_ISP_SCSI_SETCAP_END 4 +#define TR_ISP_SCSI_START_START 7 +#define TR_ISP_SCSI_START_DMA_START 8 +#define TR_ISP_SCSI_START_DMA_END 9 +#define TR_ISP_SCSI_START_END 10 +#define TR_ISP_I_START_CMD_START 11 +#define TR_ISP_I_START_CMD_Q_FULL_END 12 +#define TR_ISP_I_START_CMD_END 15 +#define TR_ISP_I_RUN_POLLED_CMD_START 16 +#define TR_ISP_I_RUN_POLLED_CMD_END 17 +#define TR_ISP_INTR_START 18 +#define TR_ISP_INTR_Q_END 25 +#define TR_ISP_INTR_END 26 +#define TR_ISP_I_ASYNCH_EVENT_START 33 +#define TR_ISP_I_ASYNCH_EVENT_END 34 +#define TR_ISP_I_WATCH_START 43 +#define TR_ISP_I_WATCH_END 44 +#define TR_ISP_I_TIMEOUT_START 45 +#define TR_ISP_I_TIMEOUT_END 46 +#define TR_ISP_I_QFLUSH_START 47 +#define TR_ISP_I_QFLUSH_END 48 +#define TR_ISP_I_SET_MARKER_START 49 +#define TR_ISP_I_SET_MARKER_END 50 +#define TR_ISP_SCSI_ABORT_START 51 +#define TR_ISP_SCSI_ABORT_END 53 +#define TR_ISP_SCSI_RESET_START 54 +#define TR_ISP_SCSI_RESET_END 56 +#define TR_ISP_I_RESET_INTERFACE_START 57 +#define TR_ISP_I_RESET_INTERFACE_END 58 +#define TR_ISP_I_CALL_PKT_COMP_START 59 +#define TR_ISP_I_CALL_PKT_COMP_END 60 +#define TR_ISP_I_EMPTY_WAITQ_START 61 +#define TR_ISP_I_EMPTY_WAITQ_END 62 +#define TR_ISP_I_START_CMD_AFTER_SYNC 66 +#define TR_ISP_INTR_ASYNC_END 69 +#define TR_ISP_INTR_MBOX_END 70 +#define TR_ISP_I_MBOX_CMD_COMPLETE_START 74 +#define TR_ISP_I_MBOX_CMD_COMPLETE_END 75 +#define TR_ISP_I_MBOX_CMD_START_START 76 +#define TR_ISP_I_MBOX_CMD_START_END 77 +#define TR_ISP_SCSI_PKTALLOC_START 78 +#define TR_ISP_SCSI_PKTALLOC_END 79 +#define TR_ISP_SCSI_PKTFREE_START 80 +#define TR_ISP_SCSI_PKTFREE_DONE 81 +#define TR_ISP_SCSI_PKTFREE_END 82 +#define TR_ISP_SCSI_DMAGET_START 83 +#define TR_ISP_SCSI_DMAGET_ERROR_END 84 +#define TR_ISP_SCSI_DMAGET_END 85 +#define TR_ISP_SCSI_DMAFREE_START 86 +#define TR_ISP_SCSI_DMAFREE_END 87 +#define TR_ISP_I_RESET_INIT_CHIP_START 88 +#define TR_ISP_I_RESET_INIT_CHIP_END 89 + +/* + * TR_FAC_SCSI_FAS tags + */ + +#define TR_FASSVC_ACTION_CALL 1 +#define TR_FASSVC_END 2 +#define TR_FASSVC_START 3 +#define TR_FAS_ALLOC_TAG_END 4 +#define TR_FAS_ALLOC_TAG_START 5 +#define TR_FAS_DOPOLL_END 6 +#define TR_FAS_DOPOLL_START 7 +#define TR_FAS_EMPTY_WAITQ_END 8 +#define TR_FAS_EMPTY_WAITQ_START 9 +#define TR_FAS_FINISH_END 10 +#define TR_FAS_FINISH_SELECT_ACTION3_END 11 +#define TR_FAS_FINISH_SELECT_FINISH_END 12 +#define TR_FAS_FINISH_SELECT_RESET1_END 13 +#define TR_FAS_FINISH_SELECT_RESET2_END 14 +#define TR_FAS_FINISH_SELECT_START 16 +#define TR_FAS_FINISH_START 17 +#define TR_FAS_HANDLE_CLEARING_ABORT_END 18 +#define TR_FAS_HANDLE_CLEARING_END 19 +#define TR_FAS_HANDLE_CLEARING_START 22 +#define TR_FAS_HANDLE_CMD_DONE_END 24 +#define TR_FAS_HANDLE_CMD_DONE_START 25 +#define TR_FAS_HANDLE_CMD_START_END 26 +#define TR_FAS_HANDLE_CMD_START_START 27 +#define TR_FAS_HANDLE_C_CMPLT_ACTION1_END 28 +#define TR_FAS_HANDLE_C_CMPLT_ACTION2_END 29 +#define TR_FAS_HANDLE_C_CMPLT_START 34 +#define TR_FAS_HANDLE_DATA_ABORT1_END 35 +#define TR_FAS_HANDLE_DATA_ABORT2_END 36 +#define TR_FAS_HANDLE_DATA_DONE_ACTION2_END 37 +#define TR_FAS_HANDLE_DATA_DONE_RESET_END 39 +#define TR_FAS_HANDLE_DATA_DONE_START 40 +#define TR_FAS_HANDLE_DATA_END 41 +#define TR_FAS_HANDLE_DATA_START 42 +#define TR_FAS_HANDLE_MORE_MSGIN_RETURN2_END 43 +#define TR_FAS_HANDLE_MORE_MSGIN_START 44 +#define TR_FAS_HANDLE_MSG_IN_DONE_ACTION_END 45 +#define TR_FAS_HANDLE_MSG_IN_DONE_RETURN2_END 46 +#define TR_FAS_HANDLE_MSG_IN_DONE_SNDMSG_END 47 +#define TR_FAS_HANDLE_MSG_IN_DONE_START 48 +#define TR_FAS_HANDLE_MSG_IN_END 49 +#define TR_FAS_HANDLE_MSG_IN_START 50 +#define TR_FAS_HANDLE_MSG_OUT_DONE_END 51 +#define TR_FAS_HANDLE_MSG_OUT_DONE_START 53 +#define TR_FAS_HANDLE_MSG_OUT_END 54 +#define TR_FAS_HANDLE_MSG_OUT_PHASEMANAGE_END 55 +#define TR_FAS_HANDLE_MSG_OUT_START 56 +#define TR_FAS_HANDLE_UNKNOWN_INT_DISCON_END 57 +#define TR_FAS_HANDLE_UNKNOWN_RESET_END 58 +#define TR_FAS_HANDLE_UNKNOWN_START 59 +#define TR_FAS_ISTART_END 60 +#define TR_FAS_ISTART_START 61 +#define TR_FAS_PHASEMANAGE_CALL 62 +#define TR_FAS_PHASEMANAGE_END 63 +#define TR_FAS_PHASEMANAGE_START 64 +#define TR_FAS_POLL_END 65 +#define TR_FAS_POLL_START 66 +#define TR_FAS_PREPARE_PKT_TRAN_ACCEPT_END 67 +#define TR_FAS_PREPARE_PKT_TRAN_BADPKT_END 68 +#define TR_FAS_RECONNECT_RESET5_END 70 +#define TR_FAS_RECONNECT_RETURN2_END 71 +#define TR_FAS_RECONNECT_START 72 +#define TR_FAS_RUNPOLL_END 73 +#define TR_FAS_RUNPOLL_START 74 +#define TR_FAS_SCSI_IMPL_DMAFREE_END 75 +#define TR_FAS_SCSI_IMPL_DMAFREE_START 76 +#define TR_FAS_SCSI_IMPL_PKTALLOC_END 77 +#define TR_FAS_SCSI_IMPL_PKTALLOC_START 78 +#define TR_FAS_SCSI_IMPL_PKTFREE_END 79 +#define TR_FAS_SCSI_IMPL_PKTFREE_START 80 +#define TR_FAS_STARTCMD_END 81 +#define TR_FAS_STARTCMD_START 82 +#define TR_FAS_START_END 83 +#define TR_FAS_START_PREPARE_PKT_END 84 +#define TR_FAS_START_START 85 +#define TR_FAS_USTART_END 86 +#define TR_FAS_USTART_NOT_FOUND_END 87 +#define TR_FAS_USTART_START 88 +#define TR_FAS_WATCH_END 89 +#define TR_FAS_SCSI_IMPL_DMAGET_END 90 +#define TR_FAS_SCSI_IMPL_DMAGET_START 91 +#define TR__FAS_START_END 92 +#define TR__FAS_START_START 93 +#define TR_FAS_EMPTY_CALLBACKQ_START 111 +#define TR_FAS_EMPTY_CALLBACKQ_END 112 +#define TR_FAS_CALL_PKT_COMP_START 113 +#define TR_FAS_CALL_PKT_COMP_END 114 + +/* + * TR_FAC_CALLOUT tags + */ + +#define TR_TIMEOUT 0 +#define TR_UNTIMEOUT 1 +#define TR_UNTIMEOUT_BOGUS_ID 2 +#define TR_UNTIMEOUT_EXECUTING 3 +#define TR_UNTIMEOUT_SELF 4 +#define TR_CALLOUT_START 5 +#define TR_CALLOUT_END 6 + +/* + * TR_FAC_SPECFS tags + */ + +#define TR_SPECFS_GETPAGE 0 +#define TR_SPECFS_GETAPAGE 1 +#define TR_SPECFS_PUTPAGE 2 +#define TR_SPECFS_PUTAPAGE 3 +#define TR_SPECFS_SEGMAP 4 +#define TR_SPECFS_OPEN 5 + +/* + * TR_FAC_TMPFS tags + */ + +#define TR_TMPFS_LOOKUP 0 +#define TR_TMPFS_CREATE 1 +#define TR_TMPFS_REMOVE 2 +#define TR_TMPFS_RENAME 3 +#define TR_TMPFS_RWTMP_START 4 +#define TR_TMPFS_RWTMP_END 5 + +/* + * TR_FAC_SWAPFS tags + */ + +#define TR_SWAPFS_GETPAGE 2 +#define TR_SWAPFS_GETAPAGE 3 +#define TR_SWAPFS_PUTPAGE 4 +#define TR_SWAPFS_PUTAPAGE 5 + +/* + * TR_FAC_UFS tags + */ + +#define TR_UFS_SYNCIP_START 0 +#define TR_UFS_SYNCIP_END 1 +#define TR_UFS_OPEN 2 +#define TR_UFS_CLOSE 4 +#define TR_UFS_READ_START 6 +#define TR_UFS_READ_END 7 +#define TR_UFS_WRITE_START 8 +#define TR_UFS_WRITE_END 9 +#define TR_UFS_RWIP_START 10 +#define TR_UFS_RWIP_END 11 +#define TR_UFS_GETATTR_START 12 +#define TR_UFS_GETATTR_END 13 +#define TR_UFS_SETATTR_START 14 +#define TR_UFS_SETATTR_END 15 +#define TR_UFS_ACCESS_START 16 +#define TR_UFS_ACCESS_END 17 +#define TR_UFS_READLINK_START 18 +#define TR_UFS_READLINK_END 19 +#define TR_UFS_FSYNC_START 20 +#define TR_UFS_FSYNC_END 21 +#define TR_UFS_LOOKUP_START 22 +#define TR_UFS_LOOKUP_END 23 +#define TR_UFS_CREATE_START 24 +#define TR_UFS_CREATE_END 25 +#define TR_UFS_REMOVE_START 26 +#define TR_UFS_REMOVE_END 27 +#define TR_UFS_LINK_START 28 +#define TR_UFS_LINK_END 29 +#define TR_UFS_RENAME_START 30 +#define TR_UFS_RENAME_END 31 +#define TR_UFS_MKDIR_START 32 +#define TR_UFS_MKDIR_END 33 +#define TR_UFS_RMDIR_START 34 +#define TR_UFS_RMDIR_END 35 +#define TR_UFS_READDIR_START 36 +#define TR_UFS_READDIR_END 37 +#define TR_UFS_SYMLINK_START 38 +#define TR_UFS_SYMLINK_END 39 +#define TR_UFS_GETPAGE_START 40 +#define TR_UFS_GETPAGE_END 41 +#define TR_UFS_PUTPAGE_START 44 +#define TR_UFS_PUTPAGE_END 45 +#define TR_UFS_PUTAPAGE_START 46 +#define TR_UFS_PUTAPAGE_END 47 +#define TR_UFS_MAP_START 48 +#define TR_UFS_MAP_END 49 +#define TR_UFS_GETSECATTR_START 50 +#define TR_UFS_GETSECATTR_END 51 +#define TR_UFS_SETSECATTR_START 52 +#define TR_UFS_SETSECATTR_END 53 + +/* + * TR_FAC_NFS tags + * + * Simple convention: client tags range from 0-99, server + * tags range from 100 up. + */ + +#define TR_RFSCALL_START 0 +#define TR_RFSCALL_END 1 +#define TR_FHTOVP_START 2 +#define TR_FHTOVP_END 3 + +#define TR_VOP_GETATTR_START 100 +#define TR_VOP_GETATTR_END 101 +#define TR_VOP_SETATTR_START 102 +#define TR_VOP_SETATTR_END 103 +#define TR_VOP_LOOKUP_START 104 +#define TR_VOP_LOOKUP_END 105 +#define TR_VOP_READLINK_START 106 +#define TR_VOP_READLINK_END 107 +#define TR_VOP_RWLOCK_START 108 +#define TR_VOP_RWLOCK_END 109 +#define TR_VOP_ACCESS_START 110 +#define TR_VOP_ACCESS_END 111 +#define TR_VOP_READ_START 114 +#define TR_VOP_READ_END 115 +#define TR_VOP_RWUNLOCK_START 118 +#define TR_VOP_RWUNLOCK_END 119 +#define TR_VOP_WRITE_START 120 +#define TR_VOP_WRITE_END 121 +#define TR_VOP_CREATE_START 122 +#define TR_VOP_CREATE_END 123 +#define TR_VOP_REMOVE_START 124 +#define TR_VOP_REMOVE_END 125 +#define TR_VOP_RENAME_START 126 +#define TR_VOP_RENAME_END 127 +#define TR_VOP_LINK_START 128 +#define TR_VOP_LINK_END 129 +#define TR_VOP_SYMLINK_START 130 +#define TR_VOP_SYMLINK_END 131 +#define TR_VOP_MKDIR_START 132 +#define TR_VOP_MKDIR_END 133 +#define TR_VOP_RMDIR_START 134 +#define TR_VOP_RMDIR_END 135 +#define TR_VOP_READDIR_START 136 +#define TR_VOP_READDIR_END 137 +#define TR_RFS_GETATTR_START 142 +#define TR_RFS_GETATTR_END 143 +#define TR_RFS_SETATTR_START 144 +#define TR_RFS_SETATTR_END 145 +#define TR_RFS_LOOKUP_START 146 +#define TR_RFS_LOOKUP_END 147 +#define TR_RFS_READLINK_START 148 +#define TR_RFS_READLINK_END 149 +#define TR_RFS_READ_START 150 +#define TR_RFS_READ_END 151 +#define TR_RFS_WRITE_START 152 +#define TR_RFS_WRITE_END 153 +#define TR_RFS_CREATE_START 154 +#define TR_RFS_CREATE_END 155 +#define TR_RFS_REMOVE_START 156 +#define TR_RFS_REMOVE_END 157 +#define TR_RFS_RENAME_START 158 +#define TR_RFS_RENAME_END 159 +#define TR_RFS_LINK_START 160 +#define TR_RFS_LINK_END 161 +#define TR_RFS_SYMLINK_START 162 +#define TR_RFS_SYMLINK_END 163 +#define TR_RFS_MKDIR_START 164 +#define TR_RFS_MKDIR_END 165 +#define TR_RFS_RMDIR_START 166 +#define TR_RFS_RMDIR_END 167 +#define TR_RFS_READDIR_START 168 +#define TR_RFS_READDIR_END 169 +#define TR_RFS_STATFS_START 170 +#define TR_RFS_STATFS_END 171 +#define TR_SVC_SENDREPLY_START 178 +#define TR_SVC_SENDREPLY_END 179 + +/* More VOP calls */ +#define TR_VOP_FSYNC_START 180 +#define TR_VOP_FSYNC_END 181 +#define TR_VOP_PUTPAGE_START 182 +#define TR_VOP_PUTPAGE_END 183 +#define TR_SVC_GETARGS_START 186 +#define TR_SVC_GETARGS_END 187 +#define TR_CHECKEXPORT_START 188 +#define TR_CHECKEXPORT_END 189 +#define TR_SVC_FREEARGS_START 192 +#define TR_SVC_FREEARGS_END 193 + +/* NFS fast path server trace points */ +#define TR_NFSFP_QUE_REQ_ENQ 212 +#define TR_NFSFP_QUE_REQ_DEQ 213 +#define TR_SVC_FREERES_START 222 +#define TR_SVC_FREERES_END 223 + +/* Name cache tracing */ +#define TR_DNLC_ENTER_START 218 +#define TR_DNLC_ENTER_END 219 +#define TR_DNLC_LOOKUP_START 220 +#define TR_DNLC_LOOKUP_END 221 + +/* Common dispatch tracing */ +#define TR_CMN_DISPATCH_START 224 +#define TR_CMN_PROC_START 225 +#define TR_CMN_PROC_END 226 +#define TR_CMN_DISPATCH_END 227 + +/* More VOP calls */ +#define TR_VOP_SPACE_START 228 +#define TR_VOP_SPACE_END 229 + +/* + * TR_FAC_KRPC tags + */ + +#define TR_SVC_GETREQ_START 0 +#define TR_SVC_RUN 4 +#define TR_SVC_CLTS_KRECV_START 5 +#define TR_SVC_CLTS_KRECV_END 6 +#define TR_XDR_CALLMSG_START 7 +#define TR_XDR_CALLMSG_END 8 +#define TR_SVC_CLTS_KSEND_START 9 +#define TR_SVC_CLTS_KSEND_END 10 +#define TR_XDR_REPLYMSG_START 11 +#define TR_XDR_REPLYMSG_END 12 +#define TR_RPCMODOPEN_START 13 +#define TR_RPCMODOPEN_END 14 +#define TR_RPCMODRPUT_START 15 +#define TR_RPCMODRPUT_END 16 +#define TR_SVC_QUEUEREQ_START 23 +#define TR_SVC_QUEUEREQ_END 24 +#define TR_SVC_GETREQ_AUTH_START 25 +#define TR_SVC_GETREQ_AUTH_END 26 +#define TR_SVC_COTS_KRECV_START 32 +#define TR_SVC_COTS_KRECV_END 33 +#define TR_SVC_COTS_KDUP_DONE 34 +#define TR_SVC_COTS_KSEND_START 36 +#define TR_SVC_COTS_KSEND_END 37 + +/* + * TR_FAC_SCSI_RES + */ + +#define TR_SCSI_INIT_PKT_START 0 +#define TR_SCSI_INIT_PKT_END 3 +#define TR_SCSI_ALLOC_CONSISTENT_BUF_START 10 +#define TR_SCSI_ALLOC_CONSISTENT_BUF_END 14 +#define TR_SCSI_FREE_CONSISTENT_BUF_START 15 +#define TR_SCSI_FREE_CONSISTENT_BUF_END 16 +#define TR_SCSI_IMPL_DMAGET_START 24 +#define TR_SCSI_IMPL_DMAGET_END 25 +#define TR_SCSI_DESTROY_PKT_START 28 +#define TR_SCSI_DESTROY_PKT_END 29 + +#define TR_FIFOREAD_WAIT 3 +#define TR_FIFOREAD_WAKE 4 +#define TR_FIFOWRITE_OUT 7 +#define TR_FIFOWRITE_WAIT 9 +#define TR_FIFOWRITE_WAKE 10 + +#define TR_RLOGINP_RPUT_IN 0 +#define TR_RLOGINP_RPUT_OUT 1 +#define TR_RLOGINP_RSRV_IN 2 +#define TR_RLOGINP_RSRV_OUT 3 +#define TR_RLOGINP_WSRV_IN 4 +#define TR_RLOGINP_WSRV_OUT 5 +#define TR_RLOGINP_WPUT_IN 6 +#define TR_RLOGINP_WPUT_OUT 7 +#define TR_RLOGINP_WINCTL_IN 8 +#define TR_RLOGINP_WINCTL_OUT 9 + +/* + * TR_FAC_SOCKFS tags + */ +#define TR_SOCKFS_OPEN 0 + +/* + * TR_FAC_DEVMAP tags + */ + +#define TR_DEVMAP_DUP 0 +#define TR_DEVMAP_UNMAP 1 +#define TR_DEVMAP_FREE 2 +#define TR_DEVMAP_FAULT 3 +#define TR_DEVMAP_FAULTA 4 +#define TR_DEVMAP_SETPROT 5 +#define TR_DEVMAP_CHECKPROT 6 +#define TR_DEVMAP_SEGDEV_BADOP 7 +#define TR_DEVMAP_SYNC 8 +#define TR_DEVMAP_INCORE 9 +#define TR_DEVMAP_LOCKOP 10 +#define TR_DEVMAP_GETPROT 11 +#define TR_DEVMAP_GETOFFSET 12 +#define TR_DEVMAP_GETTYPE 13 +#define TR_DEVMAP_GETVP 14 +#define TR_DEVMAP_ADVISE 15 +#define TR_DEVMAP_PAGELOCK 17 +#define TR_DEVMAP_GETMEMID 18 +#define TR_DEVMAP_SOFTUNLOCK 19 +#define TR_DEVMAP_FAULTPAGE 20 +#define TR_DEVMAP_FAULTPAGES 21 +#define TR_DEVMAP_SEGMAP_SETUP 22 +#define TR_DEVMAP_DEVICE 23 +#define TR_DEVMAP_DO_CTXMGT 24 +#define TR_DEVMAP_ROUNDUP 25 +#define TR_DEVMAP_FIND_HANDLE 26 +#define TR_DEVMAP_UNLOAD 27 +#define TR_DEVMAP_GET_LARGE_PGSIZE 28 +#define TR_DEVMAP_SOFTLOCK_INIT 29 +#define TR_DEVMAP_SOFTLOCK_RELE 30 +#define TR_DEVMAP_CTX_RELE 31 +#define TR_DEVMAP_LOAD 32 +#define TR_DEVMAP_SETUP 33 +#define TR_DEVMAP_SEGMAP 34 +#define TR_DEVMAP_DEVMEM_SETUP 35 +#define TR_DEVMAP_DEVMEM_REMAP 36 +#define TR_DEVMAP_UMEM_SETUP 37 +#define TR_DEVMAP_UMEM_REMAP 38 +#define TR_DEVMAP_SET_CTX_TIMEOUT 39 +#define TR_DEVMAP_DEFAULT_ACCESS 40 +#define TR_DEVMAP_UMEM_ALLOC 41 +#define TR_DEVMAP_UMEM_FREE 42 +#define TR_DEVMAP_CTXTO 43 +#define TR_DEVMAP_DUP_CK1 44 +#define TR_DEVMAP_UNMAP_CK1 45 +#define TR_DEVMAP_UNMAP_CK2 46 +#define TR_DEVMAP_UNMAP_CK3 47 +#define TR_DEVMAP_FAULT_CK1 48 +#define TR_DEVMAP_SETPROT_CK1 49 +#define TR_DEVMAP_FAULTPAGE_CK1 50 +#define TR_DEVMAP_DO_CTXMGT_CK1 51 +#define TR_DEVMAP_DO_CTXMGT_CK2 52 +#define TR_DEVMAP_DO_CTXMGT_CK3 53 +#define TR_DEVMAP_DO_CTXMGT_CK4 54 +#define TR_DEVMAP_ROUNDUP_CK1 55 +#define TR_DEVMAP_ROUNDUP_CK2 56 +#define TR_DEVMAP_CTX_RELE_CK1 57 + +/* + * TR_FAC_DAD tags + */ + +#define TR_DCDSTRATEGY_START 1 +#define TR_DCDSTRATEGY_DISKSORT_START 2 +#define TR_DCDSTRATEGY_DISKSORT_END 3 +#define TR_DCDSTRATEGY_SMALL_WINDOW_START 4 +#define TR_DCDSTRATEGY_SMALL_WINDOW_END 5 +#define TR_DCDSTRATEGY_END 6 +#define TR_DCDSTART_START 7 +#define TR_DCDSTART_NO_WORK_END 8 +#define TR_DCDSTART_NO_RESOURCES_END 9 +#define TR_DCASTART_SMALL_WINDOW_START 10 +#define TR_DCDSTART_SMALL_WINDOW_END 11 +#define TR_DCDSTART_END 12 +#define TR_MAKE_DCD_CMD_START 13 +#define TR_MAKE_DCD_CMD_INIT_PKT_START 14 +#define TR_MAKE_DCD_CMD_INIT_PKT_END 15 +#define TR_MAKE_DCD_CMD_END 17 +#define TR_DCDINTR_START 18 +#define TR_DCDINTR_COMMAND_DONE_END 19 +#define TR_DCDINTR_END 20 +#define TR_DCDONE_START 21 +#define TR_DCDDONE_BIODONE_CALL 22 +#define TR_DCDDONE_END 23 +#define TR_DCD_CHECK_ERROR_START 24 +#define TR_DCD_CHECK_ERROR_END 25 +#define TR_DCDRUNOUT_START 26 +#define TR_DCDRUNOUT_END 27 + +#if defined(DEBUG) || defined(lint) || defined(__lint) + +#define TRACE_0(fac, tag, name) { \ + extern void __dtrace_probe___vtrace_##tag(void); \ + __dtrace_probe___vtrace_##tag(); \ +} + +#define TRACE_1(fac, tag, name, d1) { \ + extern void __dtrace_probe___vtrace_##tag(ulong_t); \ + __dtrace_probe___vtrace_##tag((ulong_t)(d1)); \ +} + +#define TRACE_2(fac, tag, name, d1, d2) { \ + extern void __dtrace_probe___vtrace_##tag(ulong_t, ulong_t); \ + __dtrace_probe___vtrace_##tag((ulong_t)(d1), (ulong_t)(d2)); \ +} + +#define TRACE_3(fac, tag, name, d1, d2, d3) { \ + extern void __dtrace_probe___vtrace_##tag(ulong_t, ulong_t, ulong_t); \ + __dtrace_probe___vtrace_##tag((ulong_t)(d1), (ulong_t)(d2), \ + (ulong_t)(d3)); \ +} + +#define TRACE_4(fac, tag, name, d1, d2, d3, d4) { \ + extern void __dtrace_probe___vtrace_##tag(ulong_t, ulong_t, ulong_t, \ + ulong_t); \ + __dtrace_probe___vtrace_##tag((ulong_t)(d1), (ulong_t)(d2), \ + (ulong_t)(d3), (ulong_t)(d4)); \ +} + +#define TRACE_5(fac, tag, name, d1, d2, d3, d4, d5) { \ + extern void __dtrace_probe___vtrace_##tag(ulong_t, ulong_t, ulong_t, \ + ulong_t, ulong_t); \ + __dtrace_probe___vtrace_##tag((ulong_t)(d1), (ulong_t)(d2), \ + (ulong_t)(d3), (ulong_t)(d4), (ulong_t)(d5)); \ +} + +#else + +#define TRACE_0(fac, tag, name) +#define TRACE_1(fac, tag, name, d1) +#define TRACE_2(fac, tag, name, d1, d2) +#define TRACE_3(fac, tag, name, d1, d2, d3) +#define TRACE_4(fac, tag, name, d1, d2, d3, d4) +#define TRACE_5(fac, tag, name, d1, d2, d3, d4, d5) + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VTRACE_H */ diff --git a/illumos-x86_64/usr/include/sys/vuid_event.h b/illumos-x86_64/usr/include/sys/vuid_event.h new file mode 100644 index 00000000..b1139304 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vuid_event.h @@ -0,0 +1,437 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VUID_EVENT_H +#define _SYS_VUID_EVENT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file describes a virtual user input device (vuid) interface. This + * is an interface between input devices and their clients. The interface + * defines an idealized user input device that may not correspond to any + * existing physical collection of input devices. + * + * It is targeted to input devices that gather command data from humans, + * e.g., mice, keyboards, tablets, joysticks, light pens, knobs, sliders, + * buttons, ascii terminals, etc. The vuid interface is specifically not + * designed to support input devices that produce voluminous amounts of + * data, e.g., input scanners, disk drives, voice packets. + * + * Here are some of the properties that are expected of a typical client + * of vuid: + * + * The client has a richer user interface than can be supported by + * a simple ascii terminal. + * + * The client serializes multiple input devices being used + * by the user into a single stream of events. + * + * The client preserves the entire state of its input so that + * it may query this state. + * + * Here are some features that vuid provides to its clients: + * + * A client may extend the capabilities of the predefined vuid by + * adding input devices. A client wants to be able to do this in + * a way that fits smoothly with its existing input paradigm. + * + * A client can write its code to be input device independent. A + * client can replace the underlaying physical devices and not + * have to be concerned. In fact, the vuid interface doesn't + * really care about physical devices. One physical device can + * masquerade a many logical devices and many physical devices can + * look like a single logical device. + * + * This file defines the protocol that makes up the virtual user input + * device. This includes: + * + * The vuid station codes and there meanings. + * + * The form by which changes to vuid stations, i.e., firm events, + * are communicated to clients (typically via the read system + * call). + * + * The form by which clients send commands to input devices that + * support the vuid (typically via an ioctl system call to send + * vuid instead of a native byte stream). + * + * Explicitly, this file does not define: + * + * How to store the state of the vuid + * (see ../sunwindowdev/vuid_state.h). + * + * How to dynamically allocate additional vuid segments in order + * to extend the vuid (one could statically allocate additional + * vuid segments by treating this file as the central registry + * of vuid segments). + */ + +/* + * VUID_SEG_SIZE is the size of a virtual user input "device" address space + * segment. + */ +#define VUID_SEG_SIZE (256) + +/* + * This is the central registry of virtual user input devices. + * To allocate a new vuid: + * + * o Choose an unused portion of the address space. + * Vuids from 0x00 to 0x7F are reserved for Sun implementers. + * Vuids from 0x80 to 0xFF are reserved for Sun customers. + * + * o Note the new device with a *_DEVID define. Breifly describe + * the purpose/usage of the device. Point to the place where + * more information can be found. + * + * o Note the new device with a VUID_* entry in the Vuid_device + * enumeration. + * + * o List the specific event codes in another header file that is + * specific to the new device (ASCII_DEVID, TOP_DEVID & + * WORKSTATION_DEVID events are listing here for historical + * reasons). + */ + +#define ASCII_DEVID 0x00 + /* Ascii codes, which include META codes and 8-bit EUC codes */ + /* (see below) */ +#define TOP_DEVID 0x01 + /* Top codes, which is ASCII with the 9th bit on (see below) */ +#define ISO_DEVID 0x02 + /* ISO characters 0x80 - 0xFF (backwards compatibility) */ +/* ... Sun implementers add new device ids here ... */ +#define WHEEL_DEVID 0x78 +#define LIGHTPEN_DEVID 0x79 + /* Lightpen events for Lightpen */ +#define BUTTON_DEVID 0x7A + /* Button events from Sun button box */ +#define DIAL_DEVID 0x7B + /* Dial events from Sun dial box */ +#define SUNVIEW_DEVID 0x7C + /* Sunview Semantic events */ +#define PANEL_DEVID 0x7D + /* Panel subwindow package event codes passed around internal */ + /* to the panel package (see ) */ +#define SCROLL_DEVID 0x7E + /* Scrollbar package event codes passed to scrollbar clients on */ + /* interesting scrollbar activity (see ) */ +#define WORKSTATION_DEVID 0x7F + /* Virtual keyboard and locator (mouse) related event codes */ + /* that describe a basic "workstation" device collection (see below). */ + /* This device is a bit of a hodge podge for historical reasons; */ + /* the middle of the address space has SunWindows related events */ + /* in it (see ), and the virtual keyboard */ + /* and virtual locator are thrown together. */ +/* ... Sun customers add new device ids here ... */ +#define LAST_DEVID 0xFF + /* No more device ids beyond LAST_DEVID */ + +typedef enum vuid_device { + VUID_ASCII = ASCII_DEVID, + VUID_TOP = TOP_DEVID, + VUID_ISO = ISO_DEVID, + VUID_WHEEL = WHEEL_DEVID, + VUID_LIGHTPEN = LIGHTPEN_DEVID, + VUID_DIAL = DIAL_DEVID, + VUID_SUNVIEW = SUNVIEW_DEVID, + VUID_PANEL = PANEL_DEVID, + VUID_SCROLL = SCROLL_DEVID, + VUID_WORKSTATION = WORKSTATION_DEVID, + VUID_LAST = LAST_DEVID +} Vuid_device; + +#define vuid_first(devid) ((devid) << 8) +#define vuid_last(devid) (((devid) << 8)+VUID_SEG_SIZE-1) +#define vuid_in_range(devid, id) \ + ((id >= vuid_first(devid)) && (id <= vuid_last(devid))) + +/* + * EUC (Extended UNIX Code) device related definitions: + */ +#define EUC_FIRST (0) +#define EUC_LAST (255) + +/* + * Old ASCII definitions for backwards compatibility: + */ +#define ASCII_FIRST (0) +#define ASCII_LAST (127) +#define META_FIRST (128) +#define META_LAST (255) + +/* + * Top device related definitions: + */ +#define TOP_FIRST (256) +#define TOP_LAST (511) + +/* + * Old ISO definitions for backwards compatibility: + */ +#define ISO_FIRST (512) +#define ISO_LAST (767) + +/* + * Workstation device related definitions. First are virtual keyboard + * assignments. All events for the virtual keyboard have 0 (went up) or + * 1 (went down) values. + */ + +#define VKEY_FIRST vuid_first(WORKSTATION_DEVID) +#define VKEY_UP 0 +#define VKEY_DOWN 1 + +#define VKEY_KBD_CODES (128) /* The number of event codes in a subset of */ + /* the workstation device's address space */ + /* that belong to the virtual keyboard */ + +#define VKEY_FIRSTPSEUDO (VKEY_FIRST) /* 32512 */ +/* + * VKEY_FIRSTPSEUDO thru VKEY_LASTPSEUDO are taken (for historical + * reasons) by SunWindows related codes (see ). + */ +#define VKEY_LASTPSEUDO (VKEY_FIRSTPSEUDO+15) /* 32527 */ + +#define VKEY_FIRSTSHIFT (VKEY_LASTPSEUDO+1) /* 32528 */ +#define SHIFT_CAPSLOCK (VKEY_FIRSTSHIFT+0) /* 32528 */ +#define SHIFT_LOCK (VKEY_FIRSTSHIFT+1) /* 32529 */ +#define SHIFT_LEFT (VKEY_FIRSTSHIFT+2) /* 32530 */ +#define SHIFT_RIGHT (VKEY_FIRSTSHIFT+3) /* 32531 */ +#define SHIFT_LEFTCTRL (VKEY_FIRSTSHIFT+4) /* 32532 */ +/* SHIFT_CTRL is for compatability with previous releases */ /* 32532 */ +#define SHIFT_CTRL SHIFT_LEFTCTRL /* 32532 */ +#define SHIFT_RIGHTCTRL (VKEY_FIRSTSHIFT+5) /* 32533 */ +#define SHIFT_META (VKEY_FIRSTSHIFT+6) /* 32534 */ +#define SHIFT_TOP (VKEY_FIRSTSHIFT+7) /* 32535 */ +#define SHIFT_CMD (VKEY_FIRSTSHIFT+8) /* 32536 */ +#define SHIFT_ALTG (VKEY_FIRSTSHIFT+9) /* 32537 */ +#define SHIFT_ALT (VKEY_FIRSTSHIFT+10) /* 32538 */ +#define SHIFT_NUMLOCK (VKEY_FIRSTSHIFT+11) /* 32539 */ +#define VKEY_LASTSHIFT (VKEY_FIRSTSHIFT+15) /* 32543 */ + +#define VKEY_FIRSTFUNC (VKEY_LASTSHIFT+1) /* 32544 */ + +#define BUT_FIRST (VKEY_FIRSTFUNC) /* 32544 */ +#define BUT(i) ((BUT_FIRST)+(i)-1) /* 32544+i-1 */ +#define BUT_LAST (BUT_FIRST+9) /* 32553 */ + +#define KEY_LEFTFIRST ((BUT_LAST)+1) /* 32554 */ +#define KEY_LEFT(i) ((KEY_LEFTFIRST)+(i)-1) /* 32554+i-1 */ +#define KEY_LEFTLAST ((KEY_LEFTFIRST)+15) /* 32569 */ + +#define KEY_RIGHTFIRST ((KEY_LEFTLAST)+1) /* 32570 */ +#define KEY_RIGHT(i) ((KEY_RIGHTFIRST)+(i)-1) /* 32570+i-1 */ +#define KEY_RIGHTLAST ((KEY_RIGHTFIRST)+15) /* 32585 */ + +#define KEY_TOPFIRST ((KEY_RIGHTLAST)+1) /* 32586 */ +#define KEY_TOP(i) ((KEY_TOPFIRST)+(i)-1) /* 32586+i-1 */ +#define KEY_TOPLAST ((KEY_TOPFIRST)+15) /* 32601 */ + +#define KEY_BOTTOMLEFT ((KEY_TOPLAST)+1) /* 32602 */ +#define KEY_BOTTOMRIGHT ((KEY_BOTTOMLEFT)+1) /* 32603 */ +#define KEY_BOTTOMFIRST ((KEY_TOPLAST)+1) /* 32602 */ +#define KEY_BOTTOM(i) ((KEY_BOTTOMFIRST)+(i)-1) /* 32602+i-1 */ +#define KEY_BOTTOMLAST ((KEY_BOTTOMFIRST)+15) /* 32617 */ + +#define VKEY_LASTFUNC (VKEY_FIRSTFUNC+73) /* 32617 */ + +#define VKEY_FIRSTPAD (VKEY_LASTFUNC+1) /* 32618 */ + +#define VKEY_PADEQUAL (VKEY_FIRSTPAD+0) /* 32618 */ +#define VKEY_PADSLASH (VKEY_FIRSTPAD+1) /* 32619 */ +#define VKEY_PADSTAR (VKEY_FIRSTPAD+2) /* 32620 */ +#define VKEY_PADMINUS (VKEY_FIRSTPAD+3) /* 32621 */ +#define VKEY_PADSEP (VKEY_FIRSTPAD+4) /* 32622 */ +#define VKEY_PAD7 (VKEY_FIRSTPAD+5) /* 32623 */ +#define VKEY_PAD8 (VKEY_FIRSTPAD+6) /* 32624 */ +#define VKEY_PAD9 (VKEY_FIRSTPAD+7) /* 32625 */ +#define VKEY_PADPLUS (VKEY_FIRSTPAD+8) /* 32626 */ +#define VKEY_PAD4 (VKEY_FIRSTPAD+9) /* 32627 */ +#define VKEY_PAD5 (VKEY_FIRSTPAD+10) /* 32628 */ +#define VKEY_PAD6 (VKEY_FIRSTPAD+11) /* 32629 */ +#define VKEY_PAD1 (VKEY_FIRSTPAD+12) /* 32630 */ +#define VKEY_PAD2 (VKEY_FIRSTPAD+13) /* 32631 */ +#define VKEY_PAD3 (VKEY_FIRSTPAD+14) /* 32632 */ +#define VKEY_PAD0 (VKEY_FIRSTPAD+15) /* 32633 */ +#define VKEY_PADDOT (VKEY_FIRSTPAD+16) /* 32634 */ +#define VKEY_PADENTER (VKEY_FIRSTPAD+17) /* 32635 */ + +#define VKEY_LASTPAD (VKEY_FIRSTPAD+17) /* 32635 */ + +#define VKEY_LAST (VKEY_FIRST+VKEY_KBD_CODES-1) /* 32639 */ + +/* + * More workstation device definitions. These are virtual locator + * related event code assignments. Values for these events are int. + * VLOC_BATCH's value is a uint_t that describes the number of events + * that follow that should be treated as a batch. + */ +#define MOUSE_DEVID WORKSTATION_DEVID /* Backward compatibility */ + +#define VLOC_FIRST (VKEY_LAST+1) /* 32640 */ +#define LOC_FIRST_DELTA (VLOC_FIRST+0) /* 32640 */ +#define LOC_X_DELTA (VLOC_FIRST+0) /* 32640 */ +#define LOC_Y_DELTA (VLOC_FIRST+1) /* 32641 */ +#define LOC_LAST_DELTA (VLOC_FIRST+1) /* 32641 */ + +#define LOC_FIRST_ABSOLUTE (VLOC_FIRST+2) /* 32642 */ +#define LOC_X_ABSOLUTE (VLOC_FIRST+2) /* 32642 */ +#define LOC_Y_ABSOLUTE (VLOC_FIRST+3) /* 32643 */ +#define LOC_LAST_ABSOLUTE (VLOC_FIRST+3) /* 32643 */ + +#define VLOC_BATCH (VLOC_FIRST+4) /* 32644 */ +#define VLOC_LAST (VLOC_BATCH+1) /* 32645 */ + +#define MOUSE_CAP_CHANGE_FIRST (VLOC_LAST+1) /* 32646 */ +#define MOUSE_CAP_CHANGE_NUM_BUT (MOUSE_CAP_CHANGE_FIRST+0) /* 32646 */ +#define MOUSE_CAP_CHANGE_NUM_WHEEL (MOUSE_CAP_CHANGE_FIRST+1) /* 32647 */ + +#define MOUSE_TYPE_ABSOLUTE (VLOC_LAST+3) /* 32648 */ + +#define MOUSE_LAST (VLOC_LAST+3) /* 32648 */ +#define KEYBOARD_LAYOUT_CHANGE (MOUSE_LAST+1) /* 32649 */ + +/* + * Common names for certain input codes. The buttons on the physical + * mouse are thought to actually belong to the virtual keyboard. + */ +#define MS_LEFT BUT(1) /* 32544 */ +#define MS_MIDDLE BUT(2) /* 32545 */ +#define MS_RIGHT BUT(3) /* 32546 */ + +/* + * A firm_event structure is encoded in the byte stream of a device + * when the device has been asked to format its byte stream so. + * The time stamp is not defined to be meaningful except to compare + * with other Firm_event time stamps. + * + * The pair field is critical for a state maintainence package + * (such as vuid_state.h), one that is designed to not know anything + * about the semantics of particular events, to maintain correct data + * for corresponding absolute, delta and paired state variables. + * + * pair, when defined (as indicated by pair_type), is the associated + * state variable that should be updated due to this events generation. + * This is used to maintain a correspondence between an event that is a + * delta and a state that is an absolute value (with a known delta event + * defined) and visa versa, e.g., LOC_X_DELTA & LOC_X_ABSOLUTE. + * pair is also used to indicate another state variable that + * should be updated with the occurrence of this event, e.g., if id is + * '^G' then pair could be 'g' or 'G' depending on the state of the shift + * key. + */ +typedef struct firm_event { + ushort_t id; /* Event's unique id */ + uchar_t pair_type; /* Event pair's type */ +#define FE_PAIR_NONE 0 /* pair is not defined */ +#define FE_PAIR_SET 1 /* pair is accompanying id to set */ + /* to this events value */ +#define FE_PAIR_DELTA 2 /* pair is accompanying id that */ + /* should be set to the delta of */ + /* id's current value and the new */ + /* value indicated by this event */ +#define FE_PAIR_ABSOLUTE 3 /* pair is accompanying id that */ + /* should be set to the sum of its */ + /* current value and the delta */ + /* indicated by this event's value */ + uchar_t pair; /* Event id's associated delta|absolute|pair */ + /* offset within id's segment (minus id's */ + /* address) */ + int value; /* Event's value */ +#if defined(_LP64) + struct timeval32 time; /* Event's time stamp */ +#else + struct timeval time; +#endif +} Firm_event; +#define FIRM_EVENT_NULL ((Firm_event *)0) +#define vuid_id_addr(id) ((id) & 0xFF00) +#define vuid_id_offset(id) ((id) & 0xFF) +#define vuid_boolean_value(value) (((value) == 0) || ((value) == 1)) +#define vuid_int_value(value) (!(vuid_boolean_value((value)))) + +/* + * Ioctls to input devices that support vuid. + */ + +/* + * VUID*FORMAT ioctls are used to control which byte stream format that + * a input device should use. An errno of ENOTTY or EINVAL indicates that + * a device can't speak Firm_events. + */ +#define VUIOC ('v'<<8) +#if defined(__i386) || defined(__i386_COMPAT) +#define VUIDSFORMAT (VUIOC|11) /* avoid conflict with VT_?????? */ +#define VUIDGFORMAT (VUIOC|12) /* avoid conflict with VT_?????? */ +#else +#define VUIDSFORMAT (VUIOC|1) /* Set input device byte stream format */ +#define VUIDGFORMAT (VUIOC|2) /* Get input device byte stream format */ +#endif +#define VUID_NATIVE 0 /* Native byte stream format */ +#define VUID_FIRM_EVENT 1 /* struct firm_event byte stream format */ + +/* + * VUID*ADDR ioctls are used to control which address a particular + * virtual input device segment has. This is used to have an instancing + * capability, e.g., a second mouse. An errno of ENOTTY indicates that + * a device can't deal with these commands. An errno of ENODEV indicates + * that the requested virtual device has no events generated for it by + * this physical device. + * + * VUIDSADDR sets the virtual input device segment address indicated by + * default to next. + * + * VUIDGADDR gets the in force address of the virtual input device segment + * indicated by default into current. + */ +typedef struct vuid_addr_probe { + short base; /* default vuid device addr directed too */ + union { + short next; /* next addr for default when VUIDSADDR */ + short current; /* current addr of default when VUIDGADDR */ + } data; +} Vuid_addr_probe; + +#if defined(__i386) || defined(__i386_COMPAT) +#define VUIDSADDR (VUIOC|13) /* avoid conflict with VT_?????? */ +#define VUIDGADDR (VUIOC|14) /* avoid conflict with VT_?????? */ +#else +#define VUIDSADDR (VUIOC|3) /* Set vuid address */ +#define VUIDGADDR (VUIOC|4) /* Get vuid address */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VUID_EVENT_H */ diff --git a/illumos-x86_64/usr/include/sys/vuid_queue.h b/illumos-x86_64/usr/include/sys/vuid_queue.h new file mode 100644 index 00000000..09e7a21a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vuid_queue.h @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1985,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * This file describes a virtual user input device (vuid) event queue + * maintainence package (see ../sundev/vuid_event.h for a description + * of what vuid is). This header file defines the interface that a + * client of this package sees. This package is used to maintain queues + * of firm events awaiting deliver to some consumer. + */ + +#ifndef _SYS_VUID_QUEUE_H +#define _SYS_VUID_QUEUE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Vuid input queue structure. + */ +typedef struct vuid_queue { + struct vuid_q_node *top; /* input queue head (first in line) */ + struct vuid_q_node *bottom; /* input queue head (last in line) */ + struct vuid_q_node *free; /* input queue free list */ + int num; /* number of items currently on queue */ + int size; /* number of items allowed on queue */ +} Vuid_queue; +#define VUID_QUEUE_NULL ((Vuid_queue *)0) +#define vq_used(vq) ((vq)->num) +#define vq_avail(vq) ((vq)->size - (vq)->num) +#define vq_size(vq) ((vq)->size) +#define vq_is_empty(vq) ((vq)->top == VUID_Q_NODE_NULL) +#define vq_is_full(vq) ((vq)->num == (vq)->size) + +/* + * Vuid input queue node structure. + */ +typedef struct vuid_q_node { + struct vuid_q_node *next; /* Next item in queue */ + struct vuid_q_node *prev; /* Previous item in queue */ + Firm_event firm_event; /* Firm event */ +} Vuid_q_node; +#define VUID_Q_NODE_NULL ((Vuid_q_node *)0) + +/* + * Vuid input queue status codes. + */ +typedef enum vuid_q_code { + VUID_Q_OK = 0, /* OK */ + VUID_Q_OVERFLOW = 1, /* overflow */ + VUID_Q_EMPTY = 2 /* empty */ +} Vuid_q_code; + +extern void vq_initialize(); /* (Vuid_queue *vq, caddr_t data, uint_t bytes) */ + /* Client allocates bytes worth of storage */ + /* and pass in a data. Client destroys the q */ + /* simply by releasing data. */ +extern Vuid_q_code vq_put(); /* (Vuid_queue *vq, Firm_event *firm_event) */ + /* Place firm_event on queue, position is */ + /* dependent on the firm event's time. Can */ + /* return VUID_Q_OVERFLOW if no more room. */ +extern Vuid_q_code vq_get(); /* (Vuid_queue *vq, Firm_event *firm_event) */ + /* Place event on top of queue in firm_event. */ + /* Can return VUID_Q_EMPTY if no more events */ +extern Vuid_q_code vq_peek(); /* Like vq_get but doesn't remove from queue */ +extern Vuid_q_code vq_putback(); /* (Vuid_queue *vq, Firm_event *firm_event) */ + /* Push firm_event on top of queue. Can */ + /* return VUID_Q_OVERFLOW if no more room. */ + +extern int vq_compress(); /* (Vuid_queue *vq, factor) Try to */ + /* collapse the queue to a size of 1/factor */ + /* by squeezing like valuator events together */ + /* Returns number collapsed */ +extern int vq_is_valuator(); /* (Vuid_q_node *vqn) if value is not 0 or 1 */ + /* || pair_type is FE_PAIR_DELTA or */ + /* FE_PAIR_ABSOLUTE */ +extern void vq_delete_node(); /* (Vuid_queue *vq, Vuid_q_node *vqn) */ + /* Deletes vqn from vq */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VUID_QUEUE_H */ diff --git a/illumos-x86_64/usr/include/sys/vuid_state.h b/illumos-x86_64/usr/include/sys/vuid_state.h new file mode 100644 index 00000000..87b1cb8d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vuid_state.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1985,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * This file describes a virtual user input device (vuid) state + * maintainence package (see ../sundev/vuid_event.h for a description + * of what vuid is). This header file defines the interface that a + * client of this package sees. This package is used to maintain the + * state of all the events generated by an arbitrary number of physical + * devices which are all producing Firm_events. + */ + +#ifndef _SYS_VUID_STATE_H +#define _SYS_VUID_STATE_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef caddr_t Vuid_state; +#define VUID_STATE_NULL ((Vuid_state)0) + +void vuid_set_value(); /* (Vuid_state *state, Firm_event *event) */ + /* Don't call in critical section or */ + /* at interrupt level */ +int vuid_get_value(); /* (Vuid_state state, ushort_t id) */ +void vuid_destroy_state(); /* (Vuid_state state) Don't call in critical */ + /* section or at interrupt level */ +Vuid_state vuid_copy_state(); /* (Vuid_state state) Don't call in critical */ + /* section or at interrupt level */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VUID_STATE_H */ diff --git a/illumos-x86_64/usr/include/sys/vuid_store.h b/illumos-x86_64/usr/include/sys/vuid_store.h new file mode 100644 index 00000000..48ebde0a --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vuid_store.h @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1985,1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * This file is used by the code of a virtual user input device + * (vuid) state maintainence package (see ../sundev/vuid_event.h for a + * description of what vuid is) and is private to that implementation. + * It implements the interface defined by ../sunwindowdev/vuid_state.h. + */ + +#ifndef _SYS_VUID_STORE_H +#define _SYS_VUID_STORE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The typical struct vuid_seg state list contains 2 segments: + * + * First, the VKEY_FIRST segment with four values in its list, + * LOC_*_ABSOLUTE and LOC_*_DELTA. The rest of the values are + * booleans. The vuid storage package know to update the + * LOC_*_ABSOLUTE value when its gets a LOC_*_DELTA and visa + * versa. + * The ascii/meta segment has all booleans. + * + * The implementation is skewed to optimize the space usage but + * still be efficient in terms of accessing short vuid_value lists + * (e.g., during high volume mouse tracking) and gang requests + * about the state of shift buttons. + */ + +/* + * A component of virutal user input device (vuid) state storage. + * A struct vuid_value holds a single non-boolean value. + */ +typedef struct vuid_value { + struct vuid_value *next; /* Next node in list */ + ushort_t offset; /* Offset of value from seg addr */ + int value; /* Value */ +} Vuid_value; +#define VUID_VALUE_NULL ((Vuid_value *)0) + +#define BITSPERBYTE 8 +#define VUID_BIT_ARRAY_SIZE (VUID_SEG_SIZE/((sizeof (char))*BITSPERBYTE)) +/* + * A component of virutal user input device (vuid) state storage. + * A struct vuid_seg contains all the values for a vuid segment. + * Neither the vuid_seg list or the vuid_value list will be sorted + * unless a performance problem is identified. As a new event is + * sent to vuid_set_value, so the lists grow. + */ +typedef struct vuid_seg { + struct vuid_seg *next; /* Next state segment in list */ + ushort_t addr; /* Starting address of segment */ + char booleans[VUID_BIT_ARRAY_SIZE]; + /* Up/down value of boolean codes */ + char ints[VUID_BIT_ARRAY_SIZE]; + /* In/not in list */ + struct vuid_value *list; /* Linked list of values of */ + /* non-boolean codes. If a code is */ + /* in this list, the boolean value is */ + /* ignored and the corresponding bit */ + /* in values is on. */ +} Vuid_seg; +#define VUID_SEG_NULL ((Vuid_seg *)0) +#define vuid_cstate_to_state(cstate) ((Vuid_seg *)cstate) + +#define vuid_set_boolean_bit(seg, offset) \ + (seg)->booleans[(offset)/BITSPERBYTE] |= \ + (1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE))) +#define vuid_clear_boolean_bit(seg, offset) \ + (seg)->booleans[(offset)/BITSPERBYTE] &= \ + (~(1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE)))) +#define vuid_get_boolean_bit(seg, offset) \ + ((seg)->booleans[(offset)/BITSPERBYTE] & \ + (1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE)))) + +#define vuid_set_int_bit(seg, offset) \ + (seg)->ints[(offset)/BITSPERBYTE] |= \ + (1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE))) +#define vuid_clear_int_bit(seg, offset) \ + (seg)->ints[(offset)/BITSPERBYTE] &= \ + (~(1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE)))) +#define vuid_get_int_bit(seg, offset) \ + ((seg)->ints[(offset)/BITSPERBYTE] & \ + (1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE)))) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VUID_STORE_H */ diff --git a/illumos-x86_64/usr/include/sys/vuid_wheel.h b/illumos-x86_64/usr/include/sys/vuid_wheel.h new file mode 100644 index 00000000..d83e1904 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/vuid_wheel.h @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VUID_WHEEL_H +#define _SYS_VUID_WHEEL_H + +#include /* for VUIOC definition */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define VUID_WHEEL_MAX_COUNT 256 +#define VUIDGWHEELCOUNT (VUIOC|15) +#define VUIDGWHEELINFO (VUIOC|16) +#define VUIDGWHEELSTATE (VUIOC|17) +#define VUIDSWHEELSTATE (VUIOC|18) + +typedef struct { + int vers; /* set to VUID_WHEEL_INFO_VERS */ + int id; + int format; +} wheel_info; + +#define VUID_WHEEL_INFO_VERS 1 + +#define VUID_WHEEL_FORMAT_UNKNOWN 0 +#define VUID_WHEEL_FORMAT_HORIZONTAL 1 +#define VUID_WHEEL_FORMAT_VERTICAL 2 + +typedef struct { + int vers; /* set to VUID_WHEEL_STATE_VERS */ + int id; + uint32_t stateflags; +} wheel_state; + +#define VUID_WHEEL_STATE_VERS 1 +#define VUID_WHEEL_STATE_ENABLED (1 << 0) /* Can get & set */ +#define VUID_WHEEL_DELTAMASK 0x000000FF + +#define VUID_WHEEL_GETDELTA(event_value) \ + ((signed char) ((event_value) & VUID_WHEEL_DELTAMASK)) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VUID_WHEEL_H */ diff --git a/illumos-x86_64/usr/include/sys/wait.h b/illumos-x86_64/usr/include/sys/wait.h new file mode 100644 index 00000000..ab16b89d --- /dev/null +++ b/illumos-x86_64/usr/include/sys/wait.h @@ -0,0 +1,119 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_WAIT_H +#define _SYS_WAIT_H + +#include + +#include + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +#include /* Added for XSH4.2 */ +#include +#include +#endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) ... */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * arguments to wait functions + */ + +#define WUNTRACED 0004 /* wait for processes stopped by signals */ +#define WNOHANG 0100 /* non blocking form of wait */ + + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +#define WEXITED 0001 /* wait for processes that have exited */ +#define WTRAPPED 0002 /* wait for processes stopped while tracing */ +#define WSTOPPED WUNTRACED /* backwards compatibility */ +#define WCONTINUED 0010 /* wait for processes continued */ +#define WNOWAIT 0200 /* non destructive form of wait */ +#define WOPTMASK (WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT) +#endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) ... */ + +/* + * macros for stat return from wait functions + */ + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) + +#define WSTOPFLG 0177 +#define WCONTFLG 0177777 +#define WCOREFLG 0200 +#define WSIGMASK 0177 + +#define WLOBYTE(stat) ((int)((stat)&0377)) +#define WHIBYTE(stat) ((int)(((stat)>>8)&0377)) +#define WWORD(stat) ((int)((stat))&0177777) + +#define WIFCONTINUED(stat) (WWORD(stat) == WCONTFLG) +#define WCOREDUMP(stat) ((stat)&WCOREFLG) + +#endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) ... */ + +#define WIFEXITED(stat) ((int)((stat)&0xFF) == 0) +#define WIFSIGNALED(stat) ((int)((stat)&0xFF) > 0 && \ + (int)((stat)&0xFF00) == 0) +#define WIFSTOPPED(stat) ((int)((stat)&0xFF) == 0177 && \ + (int)((stat)&0xFF00) != 0) +#define WEXITSTATUS(stat) ((int)(((stat)>>8)&0xFF)) +#define WTERMSIG(stat) ((int)((stat)&0x7F)) +#define WSTOPSIG(stat) ((int)(((stat)>>8)&0xFF)) + + +#if !defined(_KERNEL) + +extern pid_t wait(int *); +extern pid_t waitpid(pid_t, int *, int); + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int waitid(idtype_t, id_t, siginfo_t *, int); +/* Marked as LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +extern pid_t wait3(int *, int, struct rusage *); +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ +#endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) ... */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern pid_t wait4(pid_t, int *, int, struct rusage *); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_WAIT_H */ diff --git a/illumos-x86_64/usr/include/sys/waitq.h b/illumos-x86_64/usr/include/sys/waitq.h new file mode 100644 index 00000000..48468374 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/waitq.h @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_WAITQ_H +#define _SYS_WAITQ_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +#include +#include +#include + +typedef struct waitq { + disp_lock_t wq_lock; /* protects all fields */ + kthread_t *wq_first; /* first thread on the queue */ + int wq_count; /* number of threads on the queue */ + boolean_t wq_blocked; /* True if threads can't be enqueued */ +} waitq_t; + +extern void waitq_init(waitq_t *); +extern void waitq_fini(waitq_t *); + +/* + * Place the thread on the wait queue. An attempt to enqueue a thread onto a + * blocked queue fails and returns zero. Successful enqueue returns non-zero + * value. + */ +extern int waitq_enqueue(waitq_t *, kthread_t *); + +/* + * Take thread off its wait queue and make it runnable. + */ +extern void waitq_setrun(kthread_t *t); + +/* + * Change priority for the thread on wait queue. + */ +extern void waitq_change_pri(kthread_t *, pri_t); + +/* + * Take the first thread off the wait queue and make it runnable. + */ +extern void waitq_runone(waitq_t *); + +/* + * Return True if there are no threads on the queue. + */ +extern boolean_t waitq_isempty(waitq_t *); + +/* + * Prevent and allow placing new threads on wait queue. + */ +extern void waitq_block(waitq_t *); +extern void waitq_unblock(waitq_t *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_WAITQ_H */ diff --git a/illumos-x86_64/usr/include/sys/watchpoint.h b/illumos-x86_64/usr/include/sys/watchpoint.h new file mode 100644 index 00000000..7483a1fc --- /dev/null +++ b/illumos-x86_64/usr/include/sys/watchpoint.h @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_WATCHPOINT_H +#define _SYS_WATCHPOINT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for the VM implementation of watchpoints. + * See proc(5) and for definitions of the user interface. + */ + +/* + * Each process with watchpoints has a linked list of watched areas. + * The list is kept sorted by user-level virtual address. + */ +typedef struct watched_area { + avl_node_t wa_link; /* link in AVL tree */ + caddr_t wa_vaddr; /* virtual address of watched area */ + caddr_t wa_eaddr; /* virtual address plus size */ + ulong_t wa_flags; /* watch type flags (see ) */ +} watched_area_t; + +/* + * The list of watched areas maps into a list of pages with modified + * protections. The list is kept sorted by user-level virtual address. + */ +typedef struct watched_page { + avl_node_t wp_link; /* Link in AVL tree */ + struct watched_page *wp_list; /* link in p_wprot */ + caddr_t wp_vaddr; /* virtual address of this page */ + uchar_t wp_prot; /* modified protection bits */ + uchar_t wp_oprot; /* original protection bits */ + uchar_t wp_umap[3]; /* reference counts of user pr_mappage()s */ + uchar_t wp_kmap[3]; /* reference counts of kernel pr_mappage()s */ + ushort_t wp_flags; /* see below */ + short wp_read; /* number of WA_READ areas in this page */ + short wp_write; /* number of WA_WRITE areas in this page */ + short wp_exec; /* number of WA_EXEC areas in this page */ +} watched_page_t; + +/* wp_flags */ +#define WP_NOWATCH 0x01 /* protections temporarily restored */ +#define WP_SETPROT 0x02 /* SEGOP_SETPROT() needed on this page */ + +#ifdef _KERNEL + +/* + * These functions handle the necessary logic to perform the copy operation + * while ignoring watchpoints. + */ +extern int copyin_nowatch(const void *, void *, size_t); +extern int copyout_nowatch(const void *, void *, size_t); +extern int fuword32_nowatch(const void *, uint32_t *); +extern int suword32_nowatch(void *, uint32_t); +#ifdef _LP64 +extern int suword64_nowatch(void *, uint64_t); +extern int fuword64_nowatch(const void *, uint64_t *); +#endif + +/* + * Disable watchpoints for a given region of memory. When bracketed by these + * calls, functions can use copyops and ignore watchpoints. + */ +extern int watch_disable_addr(const void *, size_t, enum seg_rw); +extern void watch_enable_addr(const void *, size_t, enum seg_rw); + +/* + * Enable/Disable watchpoints for an entire thread. + */ +extern void watch_enable(kthread_id_t); +extern void watch_disable(kthread_id_t); + +struct as; +struct proc; +struct k_siginfo; +extern void setallwatch(void); +extern int pr_is_watchpage(caddr_t, enum seg_rw); +extern int pr_is_watchpage_as(caddr_t, enum seg_rw, struct as *); +extern int pr_is_watchpoint(caddr_t *, int *, size_t, size_t *, + enum seg_rw); +extern void do_watch_step(caddr_t, size_t, enum seg_rw, int, greg_t); +extern int undo_watch_step(struct k_siginfo *); +extern int wp_compare(const void *, const void *); +extern int wa_compare(const void *, const void *); + +extern struct copyops watch_copyops; + +extern watched_area_t *pr_find_watched_area(struct proc *, watched_area_t *, + avl_index_t *); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_WATCHPOINT_H */ diff --git a/illumos-x86_64/usr/include/sys/x86_archext.h b/illumos-x86_64/usr/include/sys/x86_archext.h new file mode 100644 index 00000000..9e186ee1 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/x86_archext.h @@ -0,0 +1,1995 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011 by Delphix. All rights reserved. + */ +/* + * Copyright (c) 2010, Intel Corporation. + * All rights reserved. + */ +/* + * Copyright 2020 Joyent, Inc. + * Copyright 2012 Jens Elkner + * Copyright 2012 Hans Rosenfeld + * Copyright 2014 Josef 'Jeff' Sipek + * Copyright 2018 Nexenta Systems, Inc. + * Copyright 2025 Oxide Computer Company + * Copyright 2024 MNX Cloud, Inc. + */ + +#ifndef _SYS_X86_ARCHEXT_H +#define _SYS_X86_ARCHEXT_H + +#if !defined(_ASM) +#include +#include +#include +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * cpuid instruction feature flags in %edx (standard function 1) + */ + +#define CPUID_INTC_EDX_FPU 0x00000001 /* x87 fpu present */ +#define CPUID_INTC_EDX_VME 0x00000002 /* virtual-8086 extension */ +#define CPUID_INTC_EDX_DE 0x00000004 /* debugging extensions */ +#define CPUID_INTC_EDX_PSE 0x00000008 /* page size extension */ +#define CPUID_INTC_EDX_TSC 0x00000010 /* time stamp counter */ +#define CPUID_INTC_EDX_MSR 0x00000020 /* rdmsr and wrmsr */ +#define CPUID_INTC_EDX_PAE 0x00000040 /* physical addr extension */ +#define CPUID_INTC_EDX_MCE 0x00000080 /* machine check exception */ +#define CPUID_INTC_EDX_CX8 0x00000100 /* cmpxchg8b instruction */ +#define CPUID_INTC_EDX_APIC 0x00000200 /* local APIC */ + /* 0x400 - reserved */ +#define CPUID_INTC_EDX_SEP 0x00000800 /* sysenter and sysexit */ +#define CPUID_INTC_EDX_MTRR 0x00001000 /* memory type range reg */ +#define CPUID_INTC_EDX_PGE 0x00002000 /* page global enable */ +#define CPUID_INTC_EDX_MCA 0x00004000 /* machine check arch */ +#define CPUID_INTC_EDX_CMOV 0x00008000 /* conditional move insns */ +#define CPUID_INTC_EDX_PAT 0x00010000 /* page attribute table */ +#define CPUID_INTC_EDX_PSE36 0x00020000 /* 36-bit pagesize extension */ +#define CPUID_INTC_EDX_PSN 0x00040000 /* processor serial number */ +#define CPUID_INTC_EDX_CLFSH 0x00080000 /* clflush instruction */ + /* 0x100000 - reserved */ +#define CPUID_INTC_EDX_DS 0x00200000 /* debug store exists */ +#define CPUID_INTC_EDX_ACPI 0x00400000 /* monitoring + clock ctrl */ +#define CPUID_INTC_EDX_MMX 0x00800000 /* MMX instructions */ +#define CPUID_INTC_EDX_FXSR 0x01000000 /* fxsave and fxrstor */ +#define CPUID_INTC_EDX_SSE 0x02000000 /* streaming SIMD extensions */ +#define CPUID_INTC_EDX_SSE2 0x04000000 /* SSE extensions */ +#define CPUID_INTC_EDX_SS 0x08000000 /* self-snoop */ +#define CPUID_INTC_EDX_HTT 0x10000000 /* Hyper Thread Technology */ +#define CPUID_INTC_EDX_TM 0x20000000 /* thermal monitoring */ +#define CPUID_INTC_EDX_IA64 0x40000000 /* Itanium emulating IA32 */ +#define CPUID_INTC_EDX_PBE 0x80000000 /* Pending Break Enable */ + +/* + * cpuid instruction feature flags in %ecx (standard function 1) + */ + +#define CPUID_INTC_ECX_SSE3 0x00000001 /* Yet more SSE extensions */ +#define CPUID_INTC_ECX_PCLMULQDQ 0x00000002 /* PCLMULQDQ insn */ +#define CPUID_INTC_ECX_DTES64 0x00000004 /* 64-bit DS area */ +#define CPUID_INTC_ECX_MON 0x00000008 /* MONITOR/MWAIT */ +#define CPUID_INTC_ECX_DSCPL 0x00000010 /* CPL-qualified debug store */ +#define CPUID_INTC_ECX_VMX 0x00000020 /* Hardware VM extensions */ +#define CPUID_INTC_ECX_SMX 0x00000040 /* Secure mode extensions */ +#define CPUID_INTC_ECX_EST 0x00000080 /* enhanced SpeedStep */ +#define CPUID_INTC_ECX_TM2 0x00000100 /* thermal monitoring */ +#define CPUID_INTC_ECX_SSSE3 0x00000200 /* Supplemental SSE3 insns */ +#define CPUID_INTC_ECX_CID 0x00000400 /* L1 context ID */ + /* 0x00000800 - reserved */ +#define CPUID_INTC_ECX_FMA 0x00001000 /* Fused Multiply Add */ +#define CPUID_INTC_ECX_CX16 0x00002000 /* cmpxchg16 */ +#define CPUID_INTC_ECX_ETPRD 0x00004000 /* extended task pri messages */ +#define CPUID_INTC_ECX_PDCM 0x00008000 /* Perf/Debug Capability MSR */ + /* 0x00010000 - reserved */ +#define CPUID_INTC_ECX_PCID 0x00020000 /* process-context ids */ +#define CPUID_INTC_ECX_DCA 0x00040000 /* direct cache access */ +#define CPUID_INTC_ECX_SSE4_1 0x00080000 /* SSE4.1 insns */ +#define CPUID_INTC_ECX_SSE4_2 0x00100000 /* SSE4.2 insns */ +#define CPUID_INTC_ECX_X2APIC 0x00200000 /* x2APIC */ +#define CPUID_INTC_ECX_MOVBE 0x00400000 /* MOVBE insn */ +#define CPUID_INTC_ECX_POPCNT 0x00800000 /* POPCNT insn */ +#define CPUID_INTC_ECX_TSCDL 0x01000000 /* Deadline TSC */ +#define CPUID_INTC_ECX_AES 0x02000000 /* AES insns */ +#define CPUID_INTC_ECX_XSAVE 0x04000000 /* XSAVE/XRESTOR insns */ +#define CPUID_INTC_ECX_OSXSAVE 0x08000000 /* OS supports XSAVE insns */ +#define CPUID_INTC_ECX_AVX 0x10000000 /* AVX supported */ +#define CPUID_INTC_ECX_F16C 0x20000000 /* F16C supported */ +#define CPUID_INTC_ECX_RDRAND 0x40000000 /* RDRAND supported */ +#define CPUID_INTC_ECX_HV 0x80000000 /* Hypervisor */ + +/* + * cpuid instruction feature flags in %edx (extended function 0x80000001) + */ + +#define CPUID_AMD_EDX_FPU 0x00000001 /* x87 fpu present */ +#define CPUID_AMD_EDX_VME 0x00000002 /* virtual-8086 extension */ +#define CPUID_AMD_EDX_DE 0x00000004 /* debugging extensions */ +#define CPUID_AMD_EDX_PSE 0x00000008 /* page size extensions */ +#define CPUID_AMD_EDX_TSC 0x00000010 /* time stamp counter */ +#define CPUID_AMD_EDX_MSR 0x00000020 /* rdmsr and wrmsr */ +#define CPUID_AMD_EDX_PAE 0x00000040 /* physical addr extension */ +#define CPUID_AMD_EDX_MCE 0x00000080 /* machine check exception */ +#define CPUID_AMD_EDX_CX8 0x00000100 /* cmpxchg8b instruction */ +#define CPUID_AMD_EDX_APIC 0x00000200 /* local APIC */ + /* 0x00000400 - sysc on K6m6 */ +#define CPUID_AMD_EDX_SYSC 0x00000800 /* AMD: syscall and sysret */ +#define CPUID_AMD_EDX_MTRR 0x00001000 /* memory type and range reg */ +#define CPUID_AMD_EDX_PGE 0x00002000 /* page global enable */ +#define CPUID_AMD_EDX_MCA 0x00004000 /* machine check arch */ +#define CPUID_AMD_EDX_CMOV 0x00008000 /* conditional move insns */ +#define CPUID_AMD_EDX_PAT 0x00010000 /* K7: page attribute table */ +#define CPUID_AMD_EDX_FCMOV 0x00010000 /* FCMOVcc etc. */ +#define CPUID_AMD_EDX_PSE36 0x00020000 /* 36-bit pagesize extension */ + /* 0x00040000 - reserved */ + /* 0x00080000 - reserved */ +#define CPUID_AMD_EDX_NX 0x00100000 /* AMD: no-execute page prot */ + /* 0x00200000 - reserved */ +#define CPUID_AMD_EDX_MMXamd 0x00400000 /* AMD: MMX extensions */ +#define CPUID_AMD_EDX_MMX 0x00800000 /* MMX instructions */ +#define CPUID_AMD_EDX_FXSR 0x01000000 /* fxsave and fxrstor */ +#define CPUID_AMD_EDX_FFXSR 0x02000000 /* fast fxsave/fxrstor */ +#define CPUID_AMD_EDX_1GPG 0x04000000 /* 1GB page */ +#define CPUID_AMD_EDX_TSCP 0x08000000 /* rdtscp instruction */ + /* 0x10000000 - reserved */ +#define CPUID_AMD_EDX_LM 0x20000000 /* AMD: long mode */ +#define CPUID_AMD_EDX_3DNowx 0x40000000 /* AMD: extensions to 3DNow! */ +#define CPUID_AMD_EDX_3DNow 0x80000000 /* AMD: 3DNow! instructions */ + +/* + * AMD extended function 0x80000001 %ecx + */ + +#define CPUID_AMD_ECX_AHF64 0x00000001 /* LAHF and SAHF in long mode */ +#define CPUID_AMD_ECX_CMP_LGCY 0x00000002 /* AMD: multicore chip */ +#define CPUID_AMD_ECX_SVM 0x00000004 /* AMD: secure VM */ +#define CPUID_AMD_ECX_EAS 0x00000008 /* extended apic space */ +#define CPUID_AMD_ECX_CR8D 0x00000010 /* AMD: 32-bit mov %cr8 */ +#define CPUID_AMD_ECX_LZCNT 0x00000020 /* AMD: LZCNT insn */ +#define CPUID_AMD_ECX_SSE4A 0x00000040 /* AMD: SSE4A insns */ +#define CPUID_AMD_ECX_MAS 0x00000080 /* AMD: MisAlignSse mnode */ +#define CPUID_AMD_ECX_3DNP 0x00000100 /* AMD: 3DNowPrefectch */ +#define CPUID_AMD_ECX_OSVW 0x00000200 /* AMD: OSVW */ +#define CPUID_AMD_ECX_IBS 0x00000400 /* AMD: IBS */ +#define CPUID_AMD_ECX_XOP 0x00000800 /* AMD: Extended Operation */ +#define CPUID_AMD_ECX_SKINIT 0x00001000 /* AMD: SKINIT */ +#define CPUID_AMD_ECX_WDT 0x00002000 /* AMD: WDT */ + /* 0x00004000 - reserved */ +#define CPUID_AMD_ECX_LWP 0x00008000 /* AMD: Lightweight profiling */ +#define CPUID_AMD_ECX_FMA4 0x00010000 /* AMD: 4-operand FMA support */ + /* 0x00020000 - reserved */ + /* 0x00040000 - reserved */ +#define CPUID_AMD_ECX_NIDMSR 0x00080000 /* AMD: Node ID MSR */ + /* 0x00100000 - reserved */ +#define CPUID_AMD_ECX_TBM 0x00200000 /* AMD: trailing bit manips. */ +#define CPUID_AMD_ECX_TOPOEXT 0x00400000 /* AMD: Topology Extensions */ +#define CPUID_AMD_ECX_PCEC 0x00800000 /* AMD: Core ext perf counter */ +#define CUPID_AMD_ECX_PCENB 0x01000000 /* AMD: NB ext perf counter */ + /* 0x02000000 - reserved */ +#define CPUID_AMD_ECX_DBKP 0x40000000 /* AMD: Data breakpoint */ +#define CPUID_AMD_ECX_PERFTSC 0x08000000 /* AMD: TSC Perf Counter */ +#define CPUID_AMD_ECX_PERFL3 0x10000000 /* AMD: L3 Perf Counter */ +#define CPUID_AMD_ECX_MONITORX 0x20000000 /* AMD: clzero */ + /* 0x40000000 - reserved */ + /* 0x80000000 - reserved */ + +/* + * AMD uses %ebx for some of their features (extended function 0x80000008). + */ +#define CPUID_AMD_EBX_CLZERO 0x000000001 /* AMD: CLZERO instr */ +#define CPUID_AMD_EBX_IRCMSR 0x000000002 /* AMD: Ret. instrs MSR */ +#define CPUID_AMD_EBX_ERR_PTR_ZERO 0x000000004 /* AMD: FP Err. Ptr. Zero */ +#define CPUID_AMD_EBX_IBPB 0x000001000 /* AMD: IBPB */ +#define CPUID_AMD_EBX_IBRS 0x000004000 /* AMD: IBRS */ +#define CPUID_AMD_EBX_STIBP 0x000008000 /* AMD: STIBP */ +#define CPUID_AMD_EBX_IBRS_ALL 0x000010000 /* AMD: Enhanced IBRS */ +#define CPUID_AMD_EBX_STIBP_ALL 0x000020000 /* AMD: STIBP ALL */ +#define CPUID_AMD_EBX_PREFER_IBRS 0x000040000 /* AMD: Don't retpoline */ +#define CPUID_AMD_EBX_PPIN 0x000800000 /* AMD: PPIN Support */ +#define CPUID_AMD_EBX_SSBD 0x001000000 /* AMD: SSBD */ +#define CPUID_AMD_EBX_VIRT_SSBD 0x002000000 /* AMD: VIRT SSBD */ +#define CPUID_AMD_EBX_SSB_NO 0x004000000 /* AMD: SSB Fixed */ + +/* + * AMD SVM features (extended function 0x8000000A). + */ +#define CPUID_AMD_EDX_NESTED_PAGING (1 << 0) /* AMD: Nested paging */ +#define CPUID_AMD_EDX_LBR_VIRT (1 << 1) /* AMD: LBR virt. */ +#define CPUID_AMD_EDX_SVML (1 << 2) /* AMD: SVM lock */ +#define CPUID_AMD_EDX_NRIPS (1 << 3) /* AMD: NRIP save */ +#define CPUID_AMD_EDX_TSC_RATE_MSR (1 << 4) /* AMD: TSC ratio ctrl */ +#define CPUID_AMD_EDX_VMCB_CLEAN (1 << 5) /* AMD: VMCB clean bits */ +#define CPUID_AMD_EDX_FLUSH_ASID (1 << 6) /* AMD: flush by ASID */ +#define CPUID_AMD_EDX_DECODE_ASSISTS (1 << 7) /* AMD: decode assists */ +#define CPUID_AMD_EDX_PAUSE_INCPT (1 << 8) /* AMD: pause intercept */ +#define CPUID_AMD_EDX_PAUSE_TRSH (1 << 9) /* AMD: pause threshold */ +#define CPUID_AMD_EDX_AVIC (1 << 10) /* AMD: AVIC */ + +/* + * AMD Encrypted Memory Capabilities -- 0x8000_001F + * + * %ecx is the number of encrypted guests. + * %edx is the minimum ASID value for SEV enabled, SEV-ES disabled guests + */ +#define CPUID_AMD_8X1F_EAX_NVS (1 << 29) /* VIRT_RMPUPDATE MSR */ +#define CPUID_AMD_8X1F_EAX_SCP (1 << 28) /* SVSM Comm Page MSR */ +#define CPUID_AMD_8X1F_EAX_SMT_PROT (1 << 25) /* SMT Protection */ +#define CPUID_AMD_8X1F_EAX_VMSAR_PROT (1 << 24) /* VMSA Reg Protection */ +#define CPUID_AMD_8X1F_EAX_IBSVGC (1 << 19) /* IBS Virt. for SEV-ES */ +#define CPUID_AMD_8X1F_EAX_VIRT_TOM (1 << 18) /* Virt TOM MSR */ +#define CPUID_AMD_8X1F_EAX_VMGEXIT (1 << 17) /* VMGEXIT Parameter */ +#define CPUID_AMD_8X1F_EAX_VTE (1 << 16) /* Virt Transparent Enc. */ +#define CPUID_AMD_8X1F_EAX_NO_IBS (1 << 15) /* No IBS by host */ +#define CPUID_AMD_8X1F_EAX_DBGSWP (1 << 14) /* Debug state for SEV-ES */ +#define CPUID_AMD_8X1F_EAX_ALT_INJ (1 << 13) /* Alternate Injection */ +#define CPUID_AMD_8X1F_EAX_RES_INJ (1 << 12) /* Restricted Injection */ +#define CPUID_AMD_8X1F_EAX_64B_HOST (1 << 11) /* SEV requires amd64 */ +#define CPUID_AMD_8X1F_EAX_HWECC (1 << 10) /* HW cache coherency req */ +#define CPUID_AMD_8X1F_EAX_TSC_AUX (1 << 9) /* TSC AUX Virtualization */ +#define CPUID_AMD_8X1F_EAX_SEC_TSC (1 << 8) /* Secure TSC */ +#define CPUID_AMD_8X1F_EAX_VSSS (1 << 7) /* VMPL Super. Shadow Stack */ +#define CPUID_AMD_8X1F_EAX_RMPQUERY (1 << 6) /* RMPQUERY Instr */ +#define CPUID_AMD_8X1F_EAX_VMPL (1 << 5) /* VM Permission Levels */ +#define CPUID_AMD_8X1F_EAX_SEV_SNP (1 << 4) /* SEV Secure Nested Paging */ +#define CPUID_AMD_8X1F_EAX_SEV_ES (1 << 3) /* SEV Encrypted State */ +#define CPUID_AMD_8X1F_EAX_PAGE_FLUSH (1 << 2) /* Page Flush MSR */ +#define CPUID_AMD_8X1F_EAX_SEV (1 << 1) /* Secure Encrypted Virt. */ +#define CPUID_AMD_8X1F_EAX_SME (1 << 0) /* Secure Memory Encrypt. */ + +#define CPUID_AMD_8X1F_EBX_NVMPL(r) bitx32(r, 15, 12) /* num VM Perm lvl */ +#define CPUID_AMD_8X1F_EBX_PAR(r) bitx32(r, 11, 6) /* paddr bit rem */ +#define CPUID_AMD_8X1F_EBX_CBIT(r) bitx32(r, 5, 0) /* C-bit loc in PTE */ + +/* + * AMD Platform QoS Extended Features -- 0x8000_0020 + */ +#define CPUID_AMD_8X20_EBX_L3RR (1 << 4) /* L3 Range Reservations */ + +/* + * AMD Extended Feature 2 -- 0x8000_0021 + */ +#define CPUID_AMD_8X21_EAX_CPUID_DIS (1 << 17) /* CPUID dis for CPL > 0 */ +#define CPUID_AMD_8X21_EAX_PREFETCH (1 << 13) /* Prefetch control MSR */ +#define CPUID_AMD_8X21_EAX_NO_SMMCTL (1 << 9) /* No SMM_CTL MSR */ +#define CPUID_AMD_8X21_EAX_AIBRS (1 << 8) /* Automatic IBRS */ +#define CPUID_AMD_8X21_EAX_UAI (1 << 7) /* Upper Address Ignore */ +#define CPUID_AMD_8X21_EAX_SMM_PGLK (1 << 3) /* SMM Page config lock */ +#define CPUID_AMD_8X21_EAX_LFENCE_SER (1 << 2) /* LFENCE is dispatch serial */ +#define CPUID_AMD_8X21_EAX_NO_NDBP (1 << 0) /* No nested data #BP */ + +#define CPUID_AMD_8X21_EBX_MPS(r) bitx32(11, 0) /* MCU Patch size x 16B */ + +/* + * AMD Extended Performance Monitoring and Debug -- 0x8000_0022 + */ +#define CPUID_AMD_8X22_LBR_FRZ (1 << 2) /* Freeze PMC / LBR on ovflw */ +#define CPUID_AMD_8X22_LBR_STK (1 << 1) /* Last Branch Record Stack */ +#define CPUID_AMD_8X22_EAX_PMV2 (1 << 0) /* Perfmon v2 */ + +#define CPUID_AMD_8X22_EBX_NPMC_NB(r) bitx32(r, 15, 10) /* # NB PMC */ +#define CPUID_AMD_8X22_EBX_LBR_SZ(r) bitx32(r, 9, 4) /* # LBR Stack ents. */ +#define CPUID_AMD_8X22_EBX_NPMC_CORE(r) bitx32(r, 3, 0) /* # core PMC */ + +/* + * AMD Secure Multi-key Encryption -- 0x8000_00023 + */ +#define CPUID_AMD_8X23_EAX_MEMHMK (1 << 0) /* Secure Host Multi-Key Mem */ + +#define CPUID_AMD_8X23_EBX_MAX_HMK(r) bitx32(r, 15, 0) /* Max HMK IDs */ + +/* + * AMD Extended CPU Topology -- 0x8000_0026 + * + * This is AMD's version of extended CPU topology. The topology level is placed + * in %ecx and also contains information about the heterogeneity of the CPUs at + * the core level. Note, this is similar to, but not the same as Intel's 0x1f. + * + * The %eax values other than the APIC shift are only available when the type is + * a core. The %ebx values other than the number of logical processors are only + * available when the type is a core. The core and native model ID values are + * processor specific. + * + * %edx is the entire extended APIC ID of the logical processor we're on. + */ +#define CPUID_AMD_8X26_EAX_ASYM_TOPO(r) bitx32(r, 31, 31) +#define CPUID_AMD_8x26_EAX_HET_CORES(r) bitx32(r, 30, 30) +#define CPUID_AMD_8X26_EAX_EFF_AVAIL(r) bitx32(r, 29, 29) +#define CPUID_AMD_8X26_EAX_APIC_SHIFT(r) bitx32(r, 4, 0) + +#define CPUID_AMD_8X26_EBX_CORE_TYPE(r) bitx32(r, 31, 28) +#define CPUID_AMD_8X26_EBX_MODEL_ID(r) bitx32(r, 27, 24) +#define CPUID_AMD_8X26_EBX_PWR_EFF(r) bitx32(r, 23, 16) +#define CPUID_AMD_8X26_EBX_NLOG_PROC(r) bitx32(r, 15, 0) + +#define CPUID_AMD_8X26_ECX_TYPE(r) bitx32(r, 15, 8) +#define CPUID_AMD_8X26_TYPE_DONE 0 /* Technically reserved */ +#define CUPID_AMD_8X26_TYPE_CORE 1 +#define CUPID_AMD_8X26_TYPE_COMPLEX 2 +#define CUPID_AMD_8X26_TYPE_DIE 3 +#define CUPID_AMD_8X26_TYPE_SOCK 4 +#define CPUID_AMD_8X26_ECX_INPUT(r) bitx32(r, 7, 0) + +/* + * Intel now seems to have claimed part of the "extended" function + * space that we previously for non-Intel implementors to use. + * More excitingly still, they've claimed bit 20 to mean LAHF/SAHF + * is available in long mode i.e. what AMD indicate using bit 0. + * On the other hand, everything else is labelled as reserved. + */ +#define CPUID_INTC_ECX_AHF64 0x00100000 /* LAHF and SAHF in long mode */ + +/* + * Intel uses cpuid leaf 6 to cover various thermal and power control + * operations. + */ +#define CPUID_INTC_EAX_DTS 0x00000001 /* Digital Thermal Sensor */ +#define CPUID_INTC_EAX_TURBO 0x00000002 /* Turboboost */ +#define CPUID_INTC_EAX_ARAT 0x00000004 /* APIC-Timer-Always-Running */ +/* bit 3 is reserved */ +#define CPUID_INTC_EAX_PLN 0x00000010 /* Power limit notification */ +#define CPUID_INTC_EAX_ECMD 0x00000020 /* Clock mod. duty cycle */ +#define CPUID_INTC_EAX_PTM 0x00000040 /* Package thermal management */ +#define CPUID_INTC_EAX_HWP 0x00000080 /* HWP base registers */ +#define CPUID_INTC_EAX_HWP_NOT 0x00000100 /* HWP Notification */ +#define CPUID_INTC_EAX_HWP_ACT 0x00000200 /* HWP Activity Window */ +#define CPUID_INTC_EAX_HWP_EPR 0x00000400 /* HWP Energy Perf. Pref. */ +#define CPUID_INTC_EAX_HWP_PLR 0x00000800 /* HWP Package Level Request */ +/* bit 12 is reserved */ +#define CPUID_INTC_EAX_HDC 0x00002000 /* HDC */ +#define CPUID_INTC_EAX_TURBO3 0x00004000 /* Turbo Boost Max Tech 3.0 */ +#define CPUID_INTC_EAX_HWP_CAP 0x00008000 /* HWP Capabilities */ +#define CPUID_INTC_EAX_HWP_PECI 0x00010000 /* HWP PECI override */ +#define CPUID_INTC_EAX_HWP_FLEX 0x00020000 /* Flexible HWP */ +#define CPUID_INTC_EAX_HWP_FAST 0x00040000 /* Fast IA32_HWP_REQUEST */ +/* bit 19 is reserved */ +#define CPUID_INTC_EAX_HWP_IDLE 0x00100000 /* Ignore Idle Logical HWP */ + +#define CPUID_INTC_EBX_DTS_NTRESH(x) ((x) & 0xf) + +#define CPUID_INTC_ECX_MAPERF 0x00000001 /* IA32_MPERF / IA32_APERF */ +/* bits 1-2 are reserved */ +#define CPUID_INTC_ECX_PERFBIAS 0x00000008 /* IA32_ENERGY_PERF_BIAS */ + +/* + * Intel also uses cpuid leaf 7 to have additional instructions and features. + * Like some other leaves, but unlike the current ones we care about, it + * requires us to specify both a leaf in %eax and a sub-leaf in %ecx. To deal + * with the potential use of additional sub-leaves in the future, we now + * specifically label the EBX features with their leaf and sub-leaf. + */ +#define CPUID_INTC_EBX_7_0_FSGSBASE 0x00000001 /* FSGSBASE */ +#define CPUID_INTC_EBX_7_0_TSC_ADJ 0x00000002 /* TSC adjust MSR */ +#define CPUID_INTC_EBX_7_0_SGX 0x00000004 /* SGX */ +#define CPUID_INTC_EBX_7_0_BMI1 0x00000008 /* BMI1 instrs */ +#define CPUID_INTC_EBX_7_0_HLE 0x00000010 /* HLE */ +#define CPUID_INTC_EBX_7_0_AVX2 0x00000020 /* AVX2 supported */ +#define CPUID_INTC_EBX_7_0_FDP_EXCPN 0x00000040 /* FDP on exception */ +#define CPUID_INTC_EBX_7_0_SMEP 0x00000080 /* SMEP in CR4 */ +#define CPUID_INTC_EBX_7_0_BMI2 0x00000100 /* BMI2 instrs */ +#define CPUID_INTC_EBX_7_0_ENH_REP_MOV 0x00000200 /* Enhanced REP MOVSB */ +#define CPUID_INTC_EBX_7_0_INVPCID 0x00000400 /* invpcid instr */ +#define CPUID_INTC_EBX_7_0_RTM 0x00000800 /* RTM instrs */ +#define CPUID_INTC_EBX_7_0_PQM 0x00001000 /* QoS Monitoring */ +#define CPUID_INTC_EBX_7_0_DEP_CSDS 0x00002000 /* Deprecates CS/DS */ +#define CPUID_INTC_EBX_7_0_MPX 0x00004000 /* Mem. Prot. Ext. */ +#define CPUID_INTC_EBX_7_0_PQE 0x00080000 /* QoS Enforcement */ +#define CPUID_INTC_EBX_7_0_AVX512F 0x00010000 /* AVX512 foundation */ +#define CPUID_INTC_EBX_7_0_AVX512DQ 0x00020000 /* AVX512DQ */ +#define CPUID_INTC_EBX_7_0_RDSEED 0x00040000 /* RDSEED instr */ +#define CPUID_INTC_EBX_7_0_ADX 0x00080000 /* ADX instrs */ +#define CPUID_INTC_EBX_7_0_SMAP 0x00100000 /* SMAP in CR 4 */ +#define CPUID_INTC_EBX_7_0_AVX512IFMA 0x00200000 /* AVX512IFMA */ +/* Bit 22 is reserved */ +#define CPUID_INTC_EBX_7_0_CLFLUSHOPT 0x00800000 /* CLFLUSOPT */ +#define CPUID_INTC_EBX_7_0_CLWB 0x01000000 /* CLWB */ +#define CPUID_INTC_EBX_7_0_PTRACE 0x02000000 /* Processor Trace */ +#define CPUID_INTC_EBX_7_0_AVX512PF 0x04000000 /* AVX512PF */ +#define CPUID_INTC_EBX_7_0_AVX512ER 0x08000000 /* AVX512ER */ +#define CPUID_INTC_EBX_7_0_AVX512CD 0x10000000 /* AVX512CD */ +#define CPUID_INTC_EBX_7_0_SHA 0x20000000 /* SHA extensions */ +#define CPUID_INTC_EBX_7_0_AVX512BW 0x40000000 /* AVX512BW */ +#define CPUID_INTC_EBX_7_0_AVX512VL 0x80000000 /* AVX512VL */ + +#define CPUID_INTC_EBX_7_0_ALL_AVX512 \ + (CPUID_INTC_EBX_7_0_AVX512F | CPUID_INTC_EBX_7_0_AVX512DQ | \ + CPUID_INTC_EBX_7_0_AVX512IFMA | CPUID_INTC_EBX_7_0_AVX512PF | \ + CPUID_INTC_EBX_7_0_AVX512ER | CPUID_INTC_EBX_7_0_AVX512CD | \ + CPUID_INTC_EBX_7_0_AVX512BW | CPUID_INTC_EBX_7_0_AVX512VL) + +#define CPUID_INTC_ECX_7_0_PREFETCHWT1 0x00000001 /* PREFETCHWT1 */ +#define CPUID_INTC_ECX_7_0_AVX512VBMI 0x00000002 /* AVX512VBMI */ +#define CPUID_INTC_ECX_7_0_UMIP 0x00000004 /* UMIP */ +#define CPUID_INTC_ECX_7_0_PKU 0x00000008 /* umode prot. keys */ +#define CPUID_INTC_ECX_7_0_OSPKE 0x00000010 /* OSPKE */ +#define CPUID_INTC_ECX_7_0_WAITPKG 0x00000020 /* WAITPKG */ +#define CPUID_INTC_ECX_7_0_AVX512VBMI2 0x00000040 /* AVX512 VBMI2 */ +#define CPUID_INTC_ECX_7_0_CET_SS 0x00000080 /* CET Shadow Stack */ +#define CPUID_INTC_ECX_7_0_GFNI 0x00000100 /* GFNI */ +#define CPUID_INTC_ECX_7_0_VAES 0x00000200 /* VAES */ +#define CPUID_INTC_ECX_7_0_VPCLMULQDQ 0x00000400 /* VPCLMULQDQ */ +#define CPUID_INTC_ECX_7_0_AVX512VNNI 0x00000800 /* AVX512 VNNI */ +#define CPUID_INTC_ECX_7_0_AVX512BITALG 0x00001000 /* AVX512 BITALG */ +#define CPUID_INTC_ECX_7_0_TME_EN 0x00002000 /* Total Memory Encr. */ +#define CPUID_INTC_ECX_7_0_AVX512VPOPCDQ 0x00004000 /* AVX512 VPOPCNTDQ */ +/* bit 15 is reserved */ +#define CPUID_INTC_ECX_7_0_LA57 0x00010000 /* 57-bit paging */ +/* bits 17-21 are the value of MAWAU */ +#define CPUID_INTC_ECX_7_0_RDPID 0x00400000 /* RPID, IA32_TSC_AUX */ +#define CPUID_INTC_ECX_7_0_KLSUP 0x00800000 /* Key Locker */ +/* bit 24 is reserved */ +#define CPUID_INTC_ECX_7_0_CLDEMOTE 0x02000000 /* Cache line demote */ +/* bit 26 is resrved */ +#define CPUID_INTC_ECX_7_0_MOVDIRI 0x08000000 /* MOVDIRI insn */ +#define CPUID_INTC_ECX_7_0_MOVDIR64B 0x10000000 /* MOVDIR64B insn */ +#define CPUID_INTC_ECX_7_0_ENQCMD 0x20000000 /* Enqueue Stores */ +#define CPUID_INTC_ECX_7_0_SGXLC 0x40000000 /* SGX Launch config */ +#define CPUID_INTC_ECX_7_0_PKS 0x80000000 /* protection keys */ + +/* + * While CPUID_INTC_ECX_7_0_GFNI, CPUID_INTC_ECX_7_0_VAES, and + * CPUID_INTC_ECX_7_0_VPCLMULQDQ all have AVX512 components, they are still + * valid when AVX512 is not. However, the following flags all are only valid + * when AVX512 is present. + */ +#define CPUID_INTC_ECX_7_0_ALL_AVX512 \ + (CPUID_INTC_ECX_7_0_AVX512VBMI | CPUID_INTC_ECX_7_0_AVX512VNNI | \ + CPUID_INTC_ECX_7_0_AVX512BITALG | CPUID_INTC_ECX_7_0_AVX512VPOPCDQ) + +/* bits 0-1 are reserved */ +#define CPUID_INTC_EDX_7_0_AVX5124NNIW 0x00000004 /* AVX512 4NNIW */ +#define CPUID_INTC_EDX_7_0_AVX5124FMAPS 0x00000008 /* AVX512 4FMAPS */ +#define CPUID_INTC_EDX_7_0_FSREPMOV 0x00000010 /* fast short rep mov */ +#define CPUID_INTC_EDX_7_0_UINTR 0x00000020 /* user interrupts */ +/* bits 6-7 are reserved */ +#define CPUID_INTC_EDX_7_0_AVX512VP2INT 0x00000100 /* VP2INTERSECT */ +/* bit 9 is reserved */ +#define CPUID_INTC_EDX_7_0_MD_CLEAR 0x00000400 /* MB VERW */ +/* bits 11-13 are reserved */ +#define CPUID_INTC_EDX_7_0_SERIALIZE 0x00004000 /* Serialize instr */ +#define CPUID_INTC_EDX_7_0_HYBRID 0x00008000 /* Hybrid CPU */ +#define CPUID_INTC_EDX_7_0_TSXLDTRK 0x00010000 /* TSX load track */ +/* bit 17 is reserved */ +#define CPUID_INTC_EDX_7_0_PCONFIG 0x00040000 /* PCONFIG */ +/* bit 19 is reserved */ +#define CPUID_INTC_EDX_7_0_CET_IBT 0x00100000 /* CET ind. branch */ +/* bit 21 is reserved */ +#define CPUID_INTC_EDX_7_0_AMX_BF16 0x00400000 /* Tile F16 */ +#define CPUID_INTC_EDX_7_0_AVX512FP16 0x00800000 /* AVX512 FP16 */ +#define CPUID_INTC_EDX_7_0_AMX_TILE 0x01000000 /* Tile arch */ +#define CPUID_INTC_EDX_7_0_AMX_INT8 0x02000000 /* Tile INT8 */ +#define CPUID_INTC_EDX_7_0_SPEC_CTRL 0x04000000 /* Spec, IBPB, IBRS */ +#define CPUID_INTC_EDX_7_0_STIBP 0x08000000 /* STIBP */ +#define CPUID_INTC_EDX_7_0_FLUSH_CMD 0x10000000 /* IA32_FLUSH_CMD */ +#define CPUID_INTC_EDX_7_0_ARCH_CAPS 0x20000000 /* IA32_ARCH_CAPS */ +#define CPUID_INTC_EDX_7_0_SSBD 0x80000000 /* SSBD */ + +#define CPUID_INTC_EDX_7_0_ALL_AVX512 \ + (CPUID_INTC_EDX_7_0_AVX5124NNIW | CPUID_INTC_EDX_7_0_AVX5124FMAPS | \ + CPUID_INTC_EDX_7_0_AVX512VP2INT | CPUID_INTC_EDX_7_0_AVX512FP16) + +/* bits 0-3 are reserved */ +#define CPUID_INTC_EAX_7_1_AVXVNNI 0x00000010 /* VEX VNNI */ +#define CPUID_INTC_EAX_7_1_AVX512_BF16 0x00000020 /* AVX512 BF16 */ +/* bits 6-9 are reserved */ +#define CPUID_INTC_EAX_7_1_ZL_MOVSB 0x00000400 /* zero-length MOVSB */ +#define CPUID_INTC_EAX_7_1_FS_STOSB 0x00000800 /* fast short STOSB */ +#define CPUID_INTC_EAX_7_1_FS_CMPSB 0x00001000 /* fast CMPSB, SCASB */ +/* bits 13-21 are reserved */ +#define CPUID_INTC_EAX_7_1_HRESET 0x00400000 /* History Reset leaf */ +/* bits 23-25 are reserved */ +#define CPUID_INTC_EAX_7_1_LAM 0x02000000 /* Linear addr mask */ +/* bits 27-31 are reserved */ + +#define CPUID_INTC_EDX_7_2_BHI_CTRL (1U << 4U) /* BHI controls */ + +/* + * Intel also uses cpuid leaf 0xd to report additional instructions and features + * when the sub-leaf in %ecx == 1. We label these using the same convention as + * with leaf 7. + */ +#define CPUID_INTC_EAX_D_1_XSAVEOPT 0x00000001 /* xsaveopt inst. */ +#define CPUID_INTC_EAX_D_1_XSAVEC 0x00000002 /* xsavec inst. */ +#define CPUID_INTC_EAX_D_1_XSAVES 0x00000008 /* xsaves inst. */ + +#define REG_PAT 0x277 +#define REG_TSC 0x10 /* timestamp counter */ +#define REG_APIC_BASE_MSR 0x1b +#define REG_X2APIC_BASE_MSR 0x800 /* The MSR address offset of x2APIC */ + +#if !defined(__xpv) +/* + * AMD C1E + */ +#define MSR_AMD_INT_PENDING_CMP_HALT 0xC0010055 +#define AMD_ACTONCMPHALT_SHIFT 27 +#define AMD_ACTONCMPHALT_MASK 3 +#endif + +#define MSR_DEBUGCTL 0x1d9 + +#define DEBUGCTL_LBR 0x01 +#define DEBUGCTL_BTF 0x02 + +/* Intel P6, AMD */ +#define MSR_LBR_FROM 0x1db +#define MSR_LBR_TO 0x1dc +#define MSR_LEX_FROM 0x1dd +#define MSR_LEX_TO 0x1de + +/* Intel P4 (pre-Prescott, non P4 M) */ +#define MSR_P4_LBSTK_TOS 0x1da +#define MSR_P4_LBSTK_0 0x1db +#define MSR_P4_LBSTK_1 0x1dc +#define MSR_P4_LBSTK_2 0x1dd +#define MSR_P4_LBSTK_3 0x1de + +/* Intel Pentium M */ +#define MSR_P6M_LBSTK_TOS 0x1c9 +#define MSR_P6M_LBSTK_0 0x040 +#define MSR_P6M_LBSTK_1 0x041 +#define MSR_P6M_LBSTK_2 0x042 +#define MSR_P6M_LBSTK_3 0x043 +#define MSR_P6M_LBSTK_4 0x044 +#define MSR_P6M_LBSTK_5 0x045 +#define MSR_P6M_LBSTK_6 0x046 +#define MSR_P6M_LBSTK_7 0x047 + +/* Intel P4 (Prescott) */ +#define MSR_PRP4_LBSTK_TOS 0x1da +#define MSR_PRP4_LBSTK_FROM_0 0x680 +#define MSR_PRP4_LBSTK_FROM_1 0x681 +#define MSR_PRP4_LBSTK_FROM_2 0x682 +#define MSR_PRP4_LBSTK_FROM_3 0x683 +#define MSR_PRP4_LBSTK_FROM_4 0x684 +#define MSR_PRP4_LBSTK_FROM_5 0x685 +#define MSR_PRP4_LBSTK_FROM_6 0x686 +#define MSR_PRP4_LBSTK_FROM_7 0x687 +#define MSR_PRP4_LBSTK_FROM_8 0x688 +#define MSR_PRP4_LBSTK_FROM_9 0x689 +#define MSR_PRP4_LBSTK_FROM_10 0x68a +#define MSR_PRP4_LBSTK_FROM_11 0x68b +#define MSR_PRP4_LBSTK_FROM_12 0x68c +#define MSR_PRP4_LBSTK_FROM_13 0x68d +#define MSR_PRP4_LBSTK_FROM_14 0x68e +#define MSR_PRP4_LBSTK_FROM_15 0x68f +#define MSR_PRP4_LBSTK_TO_0 0x6c0 +#define MSR_PRP4_LBSTK_TO_1 0x6c1 +#define MSR_PRP4_LBSTK_TO_2 0x6c2 +#define MSR_PRP4_LBSTK_TO_3 0x6c3 +#define MSR_PRP4_LBSTK_TO_4 0x6c4 +#define MSR_PRP4_LBSTK_TO_5 0x6c5 +#define MSR_PRP4_LBSTK_TO_6 0x6c6 +#define MSR_PRP4_LBSTK_TO_7 0x6c7 +#define MSR_PRP4_LBSTK_TO_8 0x6c8 +#define MSR_PRP4_LBSTK_TO_9 0x6c9 +#define MSR_PRP4_LBSTK_TO_10 0x6ca +#define MSR_PRP4_LBSTK_TO_11 0x6cb +#define MSR_PRP4_LBSTK_TO_12 0x6cc +#define MSR_PRP4_LBSTK_TO_13 0x6cd +#define MSR_PRP4_LBSTK_TO_14 0x6ce +#define MSR_PRP4_LBSTK_TO_15 0x6cf + +/* + * PPIN definitions for Intel and AMD. Unfortunately, Intel and AMD use + * different MSRS for this and different MSRS to control whether or not it + * should be readable. + */ +#define MSR_PPIN_CTL_INTC 0x04e +#define MSR_PPIN_INTC 0x04f +#define MSR_PLATFORM_INFO 0x0ce +#define MSR_PLATFORM_INFO_PPIN (1 << 23) + +#define MSR_PPIN_CTL_AMD 0xC00102F0 +#define MSR_PPIN_AMD 0xC00102F1 + +/* + * These values are currently the same between Intel and AMD. + */ +#define MSR_PPIN_CTL_MASK 0x03 +#define MSR_PPIN_CTL_DISABLED 0x00 +#define MSR_PPIN_CTL_LOCKED 0x01 +#define MSR_PPIN_CTL_ENABLED 0x02 + +/* + * Intel IA32_ARCH_CAPABILITIES MSR. + */ +#define MSR_IA32_ARCH_CAPABILITIES 0x10a +#define IA32_ARCH_CAP_RDCL_NO (1UL << 0) +#define IA32_ARCH_CAP_IBRS_ALL (1UL << 1) +#define IA32_ARCH_CAP_RSBA (1UL << 2) +#define IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY (1UL << 3) +#define IA32_ARCH_CAP_SSB_NO (1UL << 4) +#define IA32_ARCH_CAP_MDS_NO (1UL << 5) +#define IA32_ARCH_CAP_IF_PSCHANGE_MC_NO (1UL << 6) +#define IA32_ARCH_CAP_TSX_CTRL (1UL << 7) +#define IA32_ARCH_CAP_TAA_NO (1UL << 8) +#define IA32_ARCH_CAP_RESERVED_1 (1UL << 9) +#define IA32_ARCH_CAP_MCU_CONTROL (1UL << 10) +#define IA32_ARCH_CAP_ENERGY_FILTERING_CTL (1UL << 11) +#define IA32_ARCH_CAP_DOITM (1UL << 12) +#define IA32_ARCH_CAP_SBDR_SSDP_NO (1UL << 13) +#define IA32_ARCH_CAP_FBSDP_NO (1UL << 14) +#define IA32_ARCH_CAP_PSDP_NO (1UL << 15) +#define IA32_ARCH_CAP_RESERVED_2 (1UL << 16) +#define IA32_ARCH_CAP_FB_CLEAR (1UL << 17) +#define IA32_ARCH_CAP_FB_CLEAR_CTRL (1UL << 18) +#define IA32_ARCH_CAP_RRSBA (1UL << 19) +#define IA32_ARCH_CAP_BHI_NO (1UL << 20) +#define IA32_ARCH_CAP_XAPIC_DISABLE_STATUS (1UL << 21) +#define IA32_ARCH_CAP_RESERVED_3 (1UL << 22) +#define IA32_ARCH_CAP_OVERCLOCKING_STATUS (1UL << 23) +#define IA32_ARCH_CAP_PBRSB_NO (1UL << 24) +#define IA32_ARCH_CAP_GDS_CTRL (1UL << 25) +#define IA32_ARCH_CAP_GDS_NO (1UL << 26) +#define IA32_ARCH_CAP_RFDS_NO (1UL << 27) +#define IA32_ARCH_CAP_RFDS_CLEAR (1UL << 28) + +/* + * Intel Speculation related MSRs + */ +#define MSR_IA32_SPEC_CTRL 0x48 +#define IA32_SPEC_CTRL_IBRS (1UL << 0) +#define IA32_SPEC_CTRL_STIBP (1UL << 1) +#define IA32_SPEC_CTRL_SSBD (1UL << 2) +#define IA32_SPEC_CTRL_IPRED_DIS_U (1UL << 3) +#define IA32_SPEC_CTRL_IPRED_DIS_S (1UL << 4) +#define IA32_SPEC_CTRL_RRSBA_DIS_U (1UL << 5) +#define IA32_SPEC_CTRL_RRSBA_DIS_S (1UL << 6) +#define IA32_SPEC_CTRL_PSFD (1UL << 7) +#define IA32_SPEC_CTRL_DDPD_U (1UL << 8) +#define IA32_SPEC_CTRL_BHI_DIS_S (1UL << 10) + +#define MSR_IA32_PRED_CMD 0x49 +#define IA32_PRED_CMD_IBPB 0x01 + +#define MSR_IA32_FLUSH_CMD 0x10b +#define IA32_FLUSH_CMD_L1D 0x01 + +/* + * Intel VMX related MSRs + */ +#define MSR_IA32_FEAT_CTRL 0x03a +#define IA32_FEAT_CTRL_LOCK 0x1 +#define IA32_FEAT_CTRL_SMX_EN 0x2 +#define IA32_FEAT_CTRL_VMX_EN 0x4 + +#define MSR_IA32_VMX_BASIC 0x480 +#define IA32_VMX_BASIC_INS_OUTS (1UL << 54) +#define IA32_VMX_BASIC_TRUE_CTRLS (1UL << 55) + +#define MSR_IA32_VMX_PROCBASED_CTLS 0x482 +#define MSR_IA32_VMX_TRUE_PROCBASED_CTLS 0x48e +#define IA32_VMX_PROCBASED_2ND_CTLS (1UL << 31) + +#define MSR_IA32_VMX_PROCBASED2_CTLS 0x48b +#define IA32_VMX_PROCBASED2_EPT (1UL << 1) +#define IA32_VMX_PROCBASED2_VPID (1UL << 5) + +#define MSR_IA32_VMX_EPT_VPID_CAP 0x48c +#define IA32_VMX_EPT_VPID_EXEC_ONLY (1UL << 0) +#define IA32_VMX_EPT_VPID_PWL4 (1UL << 6) +#define IA32_VMX_EPT_VPID_TYPE_UC (1UL << 8) +#define IA32_VMX_EPT_VPID_TYPE_WB (1UL << 14) +#define IA32_VMX_EPT_VPID_MAP_2M (1UL << 16) +#define IA32_VMX_EPT_VPID_MAP_1G (1UL << 17) +#define IA32_VMX_EPT_VPID_HW_AD (1UL << 21) +#define IA32_VMX_EPT_VPID_INVEPT (1UL << 20) +#define IA32_VMX_EPT_VPID_INVEPT_SINGLE (1UL << 25) +#define IA32_VMX_EPT_VPID_INVEPT_ALL (1UL << 26) +#define IA32_VMX_EPT_VPID_INVVPID (1UL << 32) +#define IA32_VMX_EPT_VPID_INVVPID_ADDR (1UL << 40) +#define IA32_VMX_EPT_VPID_INVVPID_SINGLE (1UL << 41) +#define IA32_VMX_EPT_VPID_INVVPID_ALL (1UL << 42) +#define IA32_VMX_EPT_VPID_INVVPID_RETAIN (1UL << 43) + +/* + * Intel TSX Control MSRs + */ +#define MSR_IA32_TSX_CTRL 0x122 +#define IA32_TSX_CTRL_RTM_DISABLE 0x01 +#define IA32_TSX_CTRL_CPUID_CLEAR 0x02 + +/* + * Intel Thermal MSRs + */ +#define MSR_IA32_THERM_INTERRUPT 0x19b +#define IA32_THERM_INTERRUPT_HIGH_IE 0x00000001 +#define IA32_THERM_INTERRUPT_LOW_IE 0x00000002 +#define IA32_THERM_INTERRUPT_PROCHOT_IE 0x00000004 +#define IA32_THERM_INTERRUPT_FORCEPR_IE 0x00000008 +#define IA32_THERM_INTERRUPT_CRIT_IE 0x00000010 +#define IA32_THERM_INTERRUPT_TR1_VAL(x) (((x) >> 8) & 0x7f) +#define IA32_THERM_INTTERUPT_TR1_IE 0x00008000 +#define IA32_THERM_INTTERUPT_TR2_VAL(x) (((x) >> 16) & 0x7f) +#define IA32_THERM_INTERRUPT_TR2_IE 0x00800000 +#define IA32_THERM_INTERRUPT_PL_NE 0x01000000 + +#define MSR_IA32_THERM_STATUS 0x19c +#define IA32_THERM_STATUS_STATUS 0x00000001 +#define IA32_THERM_STATUS_STATUS_LOG 0x00000002 +#define IA32_THERM_STATUS_PROCHOT 0x00000004 +#define IA32_THERM_STATUS_PROCHOT_LOG 0x00000008 +#define IA32_THERM_STATUS_CRIT_STATUS 0x00000010 +#define IA32_THERM_STATUS_CRIT_LOG 0x00000020 +#define IA32_THERM_STATUS_TR1_STATUS 0x00000040 +#define IA32_THERM_STATUS_TR1_LOG 0x00000080 +#define IA32_THERM_STATUS_TR2_STATUS 0x00000100 +#define IA32_THERM_STATUS_TR2_LOG 0x00000200 +#define IA32_THERM_STATUS_POWER_LIMIT_STATUS 0x00000400 +#define IA32_THERM_STATUS_POWER_LIMIT_LOG 0x00000800 +#define IA32_THERM_STATUS_CURRENT_STATUS 0x00001000 +#define IA32_THERM_STATUS_CURRENT_LOG 0x00002000 +#define IA32_THERM_STATUS_CROSS_DOMAIN_STATUS 0x00004000 +#define IA32_THERM_STATUS_CROSS_DOMAIN_LOG 0x00008000 +#define IA32_THERM_STATUS_READING(x) (((x) >> 16) & 0x7f) +#define IA32_THERM_STATUS_RESOLUTION(x) (((x) >> 27) & 0x0f) +#define IA32_THERM_STATUS_READ_VALID 0x80000000 + +#define MSR_TEMPERATURE_TARGET 0x1a2 +#define MSR_TEMPERATURE_TARGET_TARGET(x) (((x) >> 16) & 0xff) +/* + * Not all models support the offset. Refer to the Intel SDM Volume 4 for a list + * of which models have support for which bits. + */ +#define MSR_TEMPERATURE_TARGET_OFFSET(x) (((x) >> 24) & 0x0f) + +#define MSR_IA32_PACKAGE_THERM_STATUS 0x1b1 +#define IA32_PKG_THERM_STATUS_STATUS 0x00000001 +#define IA32_PKG_THERM_STATUS_STATUS_LOG 0x00000002 +#define IA32_PKG_THERM_STATUS_PROCHOT 0x00000004 +#define IA32_PKG_THERM_STATUS_PROCHOT_LOG 0x00000008 +#define IA32_PKG_THERM_STATUS_CRIT_STATUS 0x00000010 +#define IA32_PKG_THERM_STATUS_CRIT_LOG 0x00000020 +#define IA32_PKG_THERM_STATUS_TR1_STATUS 0x00000040 +#define IA32_PKG_THERM_STATUS_TR1_LOG 0x00000080 +#define IA32_PKG_THERM_STATUS_TR2_STATUS 0x00000100 +#define IA32_PKG_THERM_STATUS_TR2_LOG 0x00000200 +#define IA32_PKG_THERM_STATUS_READING(x) (((x) >> 16) & 0x7f) + +#define MSR_IA32_PACKAGE_THERM_INTERRUPT 0x1b2 +#define IA32_PKG_THERM_INTERRUPT_HIGH_IE 0x00000001 +#define IA32_PKG_THERM_INTERRUPT_LOW_IE 0x00000002 +#define IA32_PKG_THERM_INTERRUPT_PROCHOT_IE 0x00000004 +#define IA32_PKG_THERM_INTERRUPT_OVERHEAT_IE 0x00000010 +#define IA32_PKG_THERM_INTERRUPT_TR1_VAL(x) (((x) >> 8) & 0x7f) +#define IA32_PKG_THERM_INTTERUPT_TR1_IE 0x00008000 +#define IA32_PKG_THERM_INTTERUPT_TR2_VAL(x) (((x) >> 16) & 0x7f) +#define IA32_PKG_THERM_INTERRUPT_TR2_IE 0x00800000 +#define IA32_PKG_THERM_INTERRUPT_PL_NE 0x01000000 + +/* + * AMD Performance counters + * + * Older (pre-F15h) CPUs exposed a set of 4 CPU performance counters, along with + * corresponding control registers. F15h and later CPUs added an additional 2 + * CPU counters, exposing them all through a new range of MSRs (with the + * original 4 counters aliasing onto the new ones, entries 0-3) + * + * Support for those newer extended counters is denoted by CPUID_AMD_ECX_PCEC in + * function 0x80000001. + */ +#define MSR_AMD_K7_PERF_EVTSEL0 0xc0010000 +#define MSR_AMD_K7_PERF_EVTSEL1 0xc0010001 +#define MSR_AMD_K7_PERF_EVTSEL2 0xc0010002 +#define MSR_AMD_K7_PERF_EVTSEL3 0xc0010003 +#define MSR_AMD_K7_PERF_CTR0 0xc0010004 +#define MSR_AMD_K7_PERF_CTR1 0xc0010005 +#define MSR_AMD_K7_PERF_CTR2 0xc0010006 +#define MSR_AMD_K7_PERF_CTR3 0xc0010007 + +#define MSR_AMD_F15H_PERF_EVTSEL0 0xc0010200 +#define MSR_AMD_F15H_PERF_EVTSEL1 0xc0010202 +#define MSR_AMD_F15H_PERF_EVTSEL2 0xc0010204 +#define MSR_AMD_F15H_PERF_EVTSEL3 0xc0010206 +#define MSR_AMD_F15H_PERF_EVTSEL4 0xc0010208 +#define MSR_AMD_F15H_PERF_EVTSEL5 0xc001020a + +#define MSR_AMD_F15H_PERF_CTR0 0xc0010201 +#define MSR_AMD_F15H_PERF_CTR1 0xc0010203 +#define MSR_AMD_F15H_PERF_CTR2 0xc0010205 +#define MSR_AMD_F15H_PERF_CTR3 0xc0010207 +#define MSR_AMD_F15H_PERF_CTR4 0xc0010209 +#define MSR_AMD_F15H_PERF_CTR5 0xc001020b + +#define AMD_PERF_EVTSEL_EVT_MASK 0xf000000ff /* Event select bits */ +#define AMD_PERF_EVTSEL_UNIT_MASK 0xff00 /* Unit mask */ +#define AMD_PERF_EVTSEL_USER_MODE (1 << 16) /* User mode */ +#define AMD_PERF_EVTSEL_OS_MODE (1 << 17) /* OS mode */ +#define AMD_PERF_EVTSEL_EDGE (1 << 18) /* Edge detect */ +#define AMD_PERF_EVTSEL_INT_EN (1 << 20) /* Interrupt enable */ +#define AMD_PERF_EVTSEL_CTR_EN (1 << 22) /* Counter enable */ +#define AMD_PERF_EVTSEL_INV_CMP (1 << 23) /* Invert comparison */ +#define AMD_PERF_EVTSEL_CNT_MASK 0xff000000 /* Counter mask */ +#define AMD_PERF_EVTSEL_HG_MASK 0x30000000000 /* Host/guest mask */ + +#define AMD_PERF_EVTSEL_HG_GUEST 0x10000000000 /* Guest-only */ +#define AMD_PERF_EVTSEL_HG_HOST 0x20000000000 /* Host-only */ +#define AMD_PERF_EVTSEL_HG_BOTH 0x30000000000 /* Guest and host */ + +/* + * AMD TOM and TOM2 MSRs. These control the split between DRAM and MMIO below + * and above 4 GiB respectively. These have existed since family 0xf. + * + * Note that these widened around the time of Zen 4, going from 48 to 52 bits. + * However, in a presumed nod to backwards compatibily, the AMD APM Vol 2 + * section 7.9.4 ("Top of Memory"), states that "a given processor may implement + * fewer than the architecturally-defined number of physical address bits." It + * also states that unused bits are ignored, though system software should zero + * them for compatibility future extensions. These facts taken together suggest + * that we are safe to define these masks as the widest architecturally allowed. + */ +#define MSR_AMD_TOM 0xc001001a +#define MSR_AMD_TOM_MASK(x) ((x) & 0x000fffffff800000) +#define MSR_AMD_TOM2 0xc001001d +#define MSR_AMD_TOM2_MASK(x) ((x) & 0x000fffffff800000) + + +#define MCI_CTL_VALUE 0xffffffff + +#define MTRR_TYPE_UC 0 +#define MTRR_TYPE_WC 1 +#define MTRR_TYPE_WT 4 +#define MTRR_TYPE_WP 5 +#define MTRR_TYPE_WB 6 +#define MTRR_TYPE_UC_ 7 + +/* + * For Solaris we set up the page attritubute table in the following way: + * PAT0 Write-Back + * PAT1 Write-Through + * PAT2 Unchacheable- + * PAT3 Uncacheable + * PAT4 Write-Back + * PAT5 Write-Through + * PAT6 Write-Combine + * PAT7 Uncacheable + * The only difference from h/w default is entry 6. + */ +#define PAT_DEFAULT_ATTRIBUTE \ + ((uint64_t)MTRR_TYPE_WB | \ + ((uint64_t)MTRR_TYPE_WT << 8) | \ + ((uint64_t)MTRR_TYPE_UC_ << 16) | \ + ((uint64_t)MTRR_TYPE_UC << 24) | \ + ((uint64_t)MTRR_TYPE_WB << 32) | \ + ((uint64_t)MTRR_TYPE_WT << 40) | \ + ((uint64_t)MTRR_TYPE_WC << 48) | \ + ((uint64_t)MTRR_TYPE_UC << 56)) + +#define X86FSET_LARGEPAGE 0 +#define X86FSET_TSC 1 +#define X86FSET_MSR 2 +#define X86FSET_MTRR 3 +#define X86FSET_PGE 4 +#define X86FSET_DE 5 +#define X86FSET_CMOV 6 +#define X86FSET_MMX 7 +#define X86FSET_MCA 8 +#define X86FSET_PAE 9 +#define X86FSET_CX8 10 +#define X86FSET_PAT 11 +#define X86FSET_SEP 12 +#define X86FSET_SSE 13 +#define X86FSET_SSE2 14 +#define X86FSET_HTT 15 +#define X86FSET_ASYSC 16 +#define X86FSET_NX 17 +#define X86FSET_SSE3 18 +#define X86FSET_CX16 19 +#define X86FSET_CMP 20 +#define X86FSET_TSCP 21 +#define X86FSET_MWAIT 22 +#define X86FSET_SSE4A 23 +#define X86FSET_CPUID 24 +#define X86FSET_SSSE3 25 +#define X86FSET_SSE4_1 26 +#define X86FSET_SSE4_2 27 +#define X86FSET_1GPG 28 +#define X86FSET_CLFSH 29 +#define X86FSET_64 30 +#define X86FSET_AES 31 +#define X86FSET_PCLMULQDQ 32 +#define X86FSET_XSAVE 33 +#define X86FSET_AVX 34 +#define X86FSET_VMX 35 +#define X86FSET_SVM 36 +#define X86FSET_TOPOEXT 37 +#define X86FSET_F16C 38 +#define X86FSET_RDRAND 39 +#define X86FSET_X2APIC 40 +#define X86FSET_AVX2 41 +#define X86FSET_BMI1 42 +#define X86FSET_BMI2 43 +#define X86FSET_FMA 44 +#define X86FSET_SMEP 45 +#define X86FSET_SMAP 46 +#define X86FSET_ADX 47 +#define X86FSET_RDSEED 48 +#define X86FSET_MPX 49 +#define X86FSET_AVX512F 50 +#define X86FSET_AVX512DQ 51 +#define X86FSET_AVX512PF 52 +#define X86FSET_AVX512ER 53 +#define X86FSET_AVX512CD 54 +#define X86FSET_AVX512BW 55 +#define X86FSET_AVX512VL 56 +#define X86FSET_AVX512FMA 57 +#define X86FSET_AVX512VBMI 58 +#define X86FSET_AVX512VPOPCDQ 59 +#define X86FSET_AVX512NNIW 60 +#define X86FSET_AVX512FMAPS 61 +#define X86FSET_XSAVEOPT 62 +#define X86FSET_XSAVEC 63 +#define X86FSET_XSAVES 64 +#define X86FSET_SHA 65 +#define X86FSET_UMIP 66 +#define X86FSET_PKU 67 +#define X86FSET_OSPKE 68 +#define X86FSET_PCID 69 +#define X86FSET_INVPCID 70 +#define X86FSET_IBRS 71 +#define X86FSET_IBPB 72 +#define X86FSET_STIBP 73 +#define X86FSET_SSBD 74 +#define X86FSET_SSBD_VIRT 75 +#define X86FSET_RDCL_NO 76 +#define X86FSET_IBRS_ALL 77 +#define X86FSET_RSBA 78 +#define X86FSET_SSB_NO 79 +#define X86FSET_STIBP_ALL 80 +#define X86FSET_FLUSH_CMD 81 +#define X86FSET_L1D_VM_NO 82 +#define X86FSET_FSGSBASE 83 +#define X86FSET_CLFLUSHOPT 84 +#define X86FSET_CLWB 85 +#define X86FSET_MONITORX 86 +#define X86FSET_CLZERO 87 +#define X86FSET_XOP 88 +#define X86FSET_FMA4 89 +#define X86FSET_TBM 90 +#define X86FSET_AVX512VNNI 91 +#define X86FSET_AMD_PCEC 92 +#define X86FSET_MD_CLEAR 93 +#define X86FSET_MDS_NO 94 +#define X86FSET_CORE_THERMAL 95 +#define X86FSET_PKG_THERMAL 96 +#define X86FSET_TSX_CTRL 97 +#define X86FSET_TAA_NO 98 +#define X86FSET_PPIN 99 +#define X86FSET_VAES 100 +#define X86FSET_VPCLMULQDQ 101 +#define X86FSET_LFENCE_SER 102 +#define X86FSET_GFNI 103 +#define X86FSET_AVX512_VP2INT 104 +#define X86FSET_AVX512_BITALG 105 +#define X86FSET_AVX512_VBMI2 106 +#define X86FSET_AVX512_BF16 107 +#define X86FSET_AUTO_IBRS 108 +#define X86FSET_RFDS_NO 109 +#define X86FSET_RFDS_CLEAR 110 +#define X86FSET_PBRSB_NO 111 +#define X86FSET_BHI_NO 112 +#define X86FSET_BHI_CTRL 113 + +/* + * Intel Deep C-State invariant TSC in leaf 0x80000007. + */ +#define CPUID_TSC_CSTATE_INVARIANCE (0x100) + +/* + * Intel TSC deadline timer + */ +#define CPUID_DEADLINE_TSC (1 << 24) + +/* + * x86_type is a legacy concept; this is supplanted + * for most purposes by x86_featureset; modern CPUs + * should be X86_TYPE_OTHER + */ +#define X86_TYPE_OTHER 0 +#define X86_TYPE_486 1 +#define X86_TYPE_P5 2 +#define X86_TYPE_P6 3 +#define X86_TYPE_CYRIX_486 4 +#define X86_TYPE_CYRIX_6x86L 5 +#define X86_TYPE_CYRIX_6x86 6 +#define X86_TYPE_CYRIX_GXm 7 +#define X86_TYPE_CYRIX_6x86MX 8 +#define X86_TYPE_CYRIX_MediaGX 9 +#define X86_TYPE_CYRIX_MII 10 +#define X86_TYPE_VIA_CYRIX_III 11 +#define X86_TYPE_P4 12 + +/* + * x86_vendor allows us to select between + * implementation features and helps guide + * the interpretation of the cpuid instruction. + */ +#define X86_VENDOR_Intel 0 +#define X86_VENDORSTR_Intel "GenuineIntel" + +#define X86_VENDOR_IntelClone 1 + +#define X86_VENDOR_AMD 2 +#define X86_VENDORSTR_AMD "AuthenticAMD" + +#define X86_VENDOR_Cyrix 3 +#define X86_VENDORSTR_CYRIX "CyrixInstead" + +#define X86_VENDOR_UMC 4 +#define X86_VENDORSTR_UMC "UMC UMC UMC " + +#define X86_VENDOR_NexGen 5 +#define X86_VENDORSTR_NexGen "NexGenDriven" + +#define X86_VENDOR_Centaur 6 +#define X86_VENDORSTR_Centaur "CentaurHauls" + +#define X86_VENDOR_Rise 7 +#define X86_VENDORSTR_Rise "RiseRiseRise" + +#define X86_VENDOR_SiS 8 +#define X86_VENDORSTR_SiS "SiS SiS SiS " + +#define X86_VENDOR_TM 9 +#define X86_VENDORSTR_TM "GenuineTMx86" + +#define X86_VENDOR_NSC 10 +#define X86_VENDORSTR_NSC "Geode by NSC" + +#define X86_VENDOR_HYGON 11 +#define X86_VENDORSTR_HYGON "HygonGenuine" + +/* + * Vendor string max len + \0 + */ +#define X86_VENDOR_STRLEN 13 + +/* + * For lookups and matching functions only; not an actual vendor. + */ +#define _X86_VENDOR_MATCH_ALL 0xff + +/* + * See the big theory statement at the top of cpuid.c for information about how + * processor families and microarchitecture families relate to cpuid families, + * models, and steppings. + */ + +#define _X86_CHIPREV_VENDOR_SHIFT 24 +#define _X86_CHIPREV_FAMILY_SHIFT 16 + +#define _X86_CHIPREV_VENDOR(x) \ + bitx32((uint32_t)(x), 31, _X86_CHIPREV_VENDOR_SHIFT) + +#define _X86_CHIPREV_FAMILY(x) \ + bitx32((uint32_t)(x), 23, _X86_CHIPREV_FAMILY_SHIFT) + +#define _X86_CHIPREV_REV(x) \ + bitx32((uint32_t)(x), 15, 0) + +#define _X86_CHIPREV_MKREV(vendor, family, rev) \ + ((uint32_t)(vendor) << _X86_CHIPREV_VENDOR_SHIFT | \ + (uint32_t)(family) << _X86_CHIPREV_FAMILY_SHIFT | (uint32_t)(rev)) + +/* + * The legacy families here are a little bit unfortunate. Part of this is that + * the way AMD used the cpuid family/model/stepping changed somewhat over time, + * but the more immediate reason it's this way is more that the way we use + * chiprev/processor family changed with it. The ancient amd_opteron and mc-amd + * drivers used the chiprevs that were based on cpuid family, mainly 0xf and + * 0x10. amdzen_umc wants the processor family, in part because AMD's + * overloading of the cpuid family has made it effectively useless for + * discerning anything about the processor. That also tied into the way + * amd_revmap was previously organised in cpuid_subr.c: up to family 0x14 + * everything was just "rev A", "rev B", etc.; afterward we started using the + * new shorthand, again tied to how AMD was presenting this information. + * Because there are other consumers of the processor family, it no longer made + * sense for amdzen to derive the processor family from the cpuid family/model + * given that we have this collection of definitions already and code in + * cpuid_subr.c to make use of them. The result is this unified approach that + * tries to keep old consumers happy while allowing new ones to get the degree + * of detail they need and expect. That required bending things a bit to make + * them fit, though critically as long as AMD keep on their current path and all + * new consumers look like the ones we are adding these days, we will be able to + * continue making new additions that will match all the recent ones and the way + * AMD are currently using families and models. There is absolutely no reason + * we couldn't go back and dig through all the legacy parts and break them down + * the same way, then change the old MC and CPU drivers to match, but I didn't + * feel like doing a lot of work for processors that it's unlikely anyone is + * still using and even more unlikely anyone will introduce new code to support. + * My compromise was to flesh things out starting where we already had more + * detail even if nothing was consuming it programmatically: at 0x15. Before + * that, processor family and cpuid family were effectively the same, because + * that's what those old consumers expect. + */ + +#ifndef _ASM +typedef enum x86_processor_family { + X86_PF_UNKNOWN, + X86_PF_AMD_LEGACY_F = 0xf, + X86_PF_AMD_LEGACY_10 = 0x10, + X86_PF_AMD_LEGACY_11 = 0x11, + X86_PF_AMD_LEGACY_12 = 0x12, + X86_PF_AMD_LEGACY_14 = 0x14, + X86_PF_AMD_OROCHI, + X86_PF_AMD_TRINITY, + X86_PF_AMD_KAVERI, + X86_PF_AMD_CARRIZO, + X86_PF_AMD_STONEY_RIDGE, + X86_PF_AMD_KABINI, + X86_PF_AMD_MULLINS, + X86_PF_AMD_NAPLES, + X86_PF_AMD_PINNACLE_RIDGE, + X86_PF_AMD_RAVEN_RIDGE, + X86_PF_AMD_PICASSO, + X86_PF_AMD_DALI, + X86_PF_AMD_ROME, + X86_PF_AMD_RENOIR, + X86_PF_AMD_MATISSE, + X86_PF_AMD_VAN_GOGH, + X86_PF_AMD_MENDOCINO, + X86_PF_HYGON_DHYANA, + X86_PF_AMD_MILAN, + X86_PF_AMD_GENOA, + X86_PF_AMD_VERMEER, + X86_PF_AMD_REMBRANDT, + X86_PF_AMD_CEZANNE, + X86_PF_AMD_RAPHAEL, + X86_PF_AMD_PHOENIX, + X86_PF_AMD_BERGAMO, + X86_PF_AMD_TURIN, + X86_PF_AMD_DENSE_TURIN, + X86_PF_AMD_STRIX, + X86_PF_AMD_GRANITE_RIDGE, + X86_PF_AMD_KRACKAN, + X86_PF_AMD_STRIX_HALO, + + X86_PF_ANY = 0xff +} x86_processor_family_t; + +#define _DECL_CHIPREV(_v, _f, _revn, _revb) \ + X86_CHIPREV_ ## _v ## _ ## _f ## _ ## _revn = \ + _X86_CHIPREV_MKREV(X86_VENDOR_ ## _v, X86_PF_ ## _v ## _ ## _f, _revb) + +#define _X86_CHIPREV_REV_MATCH_ALL 0xffff + +typedef enum x86_chiprev { + X86_CHIPREV_UNKNOWN, + _DECL_CHIPREV(AMD, LEGACY_F, REV_B, 0x0001), + /* + * Definitions for AMD Family 0xf. Minor revisions C0 and CG are + * sufficiently different that we will distinguish them; in all other + * case we will identify the major revision. + */ + _DECL_CHIPREV(AMD, LEGACY_F, REV_C0, 0x0002), + _DECL_CHIPREV(AMD, LEGACY_F, REV_CG, 0x0004), + _DECL_CHIPREV(AMD, LEGACY_F, REV_D, 0x0008), + _DECL_CHIPREV(AMD, LEGACY_F, REV_E, 0x0010), + _DECL_CHIPREV(AMD, LEGACY_F, REV_F, 0x0020), + _DECL_CHIPREV(AMD, LEGACY_F, REV_G, 0x0040), + _DECL_CHIPREV(AMD, LEGACY_F, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, LEGACY_10, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, LEGACY_10, REV_A, 0x0002), + _DECL_CHIPREV(AMD, LEGACY_10, REV_B, 0x0004), + _DECL_CHIPREV(AMD, LEGACY_10, REV_C2, 0x0008), + _DECL_CHIPREV(AMD, LEGACY_10, REV_C3, 0x0010), + _DECL_CHIPREV(AMD, LEGACY_10, REV_D0, 0x0020), + _DECL_CHIPREV(AMD, LEGACY_10, REV_D1, 0x0040), + _DECL_CHIPREV(AMD, LEGACY_10, REV_E, 0x0080), + _DECL_CHIPREV(AMD, LEGACY_10, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, LEGACY_11, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, LEGACY_11, REV_B, 0x0002), + _DECL_CHIPREV(AMD, LEGACY_11, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, LEGACY_12, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, LEGACY_12, REV_B, 0x0002), + _DECL_CHIPREV(AMD, LEGACY_12, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, LEGACY_14, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, LEGACY_14, REV_B, 0x0002), + _DECL_CHIPREV(AMD, LEGACY_14, REV_C, 0x0004), + _DECL_CHIPREV(AMD, LEGACY_14, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, OROCHI, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, OROCHI, REV_B2, 0x0002), + _DECL_CHIPREV(AMD, OROCHI, REV_C0, 0x0004), + _DECL_CHIPREV(AMD, OROCHI, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, TRINITY, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, TRINITY, REV_A1, 0x0002), + _DECL_CHIPREV(AMD, TRINITY, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, KAVERI, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, KAVERI, REV_A1, 0x0002), + _DECL_CHIPREV(AMD, KAVERI, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, CARRIZO, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, CARRIZO, REV_A0, 0x0002), + _DECL_CHIPREV(AMD, CARRIZO, REV_A1, 0x0004), + _DECL_CHIPREV(AMD, CARRIZO, REV_DDR4, 0x0008), + _DECL_CHIPREV(AMD, CARRIZO, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, STONEY_RIDGE, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, STONEY_RIDGE, REV_A0, 0x0002), + _DECL_CHIPREV(AMD, STONEY_RIDGE, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, KABINI, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, KABINI, A1, 0x0002), + _DECL_CHIPREV(AMD, KABINI, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, MULLINS, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, MULLINS, A1, 0x0002), + _DECL_CHIPREV(AMD, MULLINS, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, NAPLES, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, NAPLES, A0, 0x0002), + _DECL_CHIPREV(AMD, NAPLES, B1, 0x0004), + _DECL_CHIPREV(AMD, NAPLES, B2, 0x0008), + _DECL_CHIPREV(AMD, NAPLES, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, PINNACLE_RIDGE, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, PINNACLE_RIDGE, B2, 0x0002), + _DECL_CHIPREV(AMD, PINNACLE_RIDGE, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, RAVEN_RIDGE, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, RAVEN_RIDGE, B0, 0x0002), + _DECL_CHIPREV(AMD, RAVEN_RIDGE, B1, 0x0004), + _DECL_CHIPREV(AMD, RAVEN_RIDGE, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, PICASSO, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, PICASSO, B1, 0x0002), + _DECL_CHIPREV(AMD, PICASSO, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, DALI, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, DALI, A1, 0x0002), + _DECL_CHIPREV(AMD, DALI, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, ROME, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, ROME, A0, 0x0002), + _DECL_CHIPREV(AMD, ROME, B0, 0x0004), + _DECL_CHIPREV(AMD, ROME, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, RENOIR, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, RENOIR, A1, 0x0002), + _DECL_CHIPREV(AMD, RENOIR, LCN_A1, 0x0004), + _DECL_CHIPREV(AMD, RENOIR, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, MATISSE, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, MATISSE, B0, 0x0002), + _DECL_CHIPREV(AMD, MATISSE, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, VAN_GOGH, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, VAN_GOGH, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, MENDOCINO, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, MENDOCINO, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(HYGON, DHYANA, UNKNOWN, 0x0001), + _DECL_CHIPREV(HYGON, DHYANA, A1, 0x0002), + _DECL_CHIPREV(HYGON, DHYANA, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, MILAN, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, MILAN, A0, 0x0002), + _DECL_CHIPREV(AMD, MILAN, B0, 0x0004), + _DECL_CHIPREV(AMD, MILAN, B1, 0x0008), + _DECL_CHIPREV(AMD, MILAN, B2, 0x0010), + _DECL_CHIPREV(AMD, MILAN, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, GENOA, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, GENOA, A0, 0x0002), + _DECL_CHIPREV(AMD, GENOA, A1, 0x0004), + _DECL_CHIPREV(AMD, GENOA, B0, 0x0008), + _DECL_CHIPREV(AMD, GENOA, B1, 0x0010), + _DECL_CHIPREV(AMD, GENOA, B2, 0x0020), + _DECL_CHIPREV(AMD, GENOA, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, VERMEER, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, VERMEER, A0, 0x0002), + _DECL_CHIPREV(AMD, VERMEER, B0, 0x0004), + _DECL_CHIPREV(AMD, VERMEER, B2, 0x0008), /* No B1 */ + _DECL_CHIPREV(AMD, VERMEER, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, REMBRANDT, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, REMBRANDT, A0, 0x0002), + _DECL_CHIPREV(AMD, REMBRANDT, B0, 0x0004), + _DECL_CHIPREV(AMD, REMBRANDT, B1, 0x0008), + _DECL_CHIPREV(AMD, REMBRANDT, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, CEZANNE, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, CEZANNE, A0, 0x0002), + _DECL_CHIPREV(AMD, CEZANNE, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, RAPHAEL, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, RAPHAEL, B2, 0x0002), + _DECL_CHIPREV(AMD, RAPHAEL, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, PHOENIX, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, PHOENIX, A0, 0x0002), + _DECL_CHIPREV(AMD, PHOENIX, A1, 0x0004), + _DECL_CHIPREV(AMD, PHOENIX, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, BERGAMO, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, BERGAMO, A0, 0x0002), + _DECL_CHIPREV(AMD, BERGAMO, A1, 0x0004), + _DECL_CHIPREV(AMD, BERGAMO, A2, 0x0008), + _DECL_CHIPREV(AMD, BERGAMO, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, TURIN, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, TURIN, A0, 0x0002), + _DECL_CHIPREV(AMD, TURIN, B0, 0x0004), + _DECL_CHIPREV(AMD, TURIN, B1, 0x0008), + _DECL_CHIPREV(AMD, TURIN, C0, 0x0010), + _DECL_CHIPREV(AMD, TURIN, C1, 0x0020), + _DECL_CHIPREV(AMD, TURIN, ANY, _X86_CHIPREV_REV_MATCH_ALL), + _DECL_CHIPREV(AMD, DENSE_TURIN, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, DENSE_TURIN, A0, 0x0002), + _DECL_CHIPREV(AMD, DENSE_TURIN, B0, 0x0004), + _DECL_CHIPREV(AMD, DENSE_TURIN, B1, 0x0008), + _DECL_CHIPREV(AMD, DENSE_TURIN, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, STRIX, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, STRIX, B0, 0x0002), + _DECL_CHIPREV(AMD, STRIX, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, GRANITE_RIDGE, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, GRANITE_RIDGE, B0, 0x0002), + _DECL_CHIPREV(AMD, GRANITE_RIDGE, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, KRACKAN, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, KRACKAN, A0, 0x0002), + _DECL_CHIPREV(AMD, KRACKAN, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + _DECL_CHIPREV(AMD, STRIX_HALO, UNKNOWN, 0x0001), + _DECL_CHIPREV(AMD, STRIX_HALO, A0, 0x0002), + _DECL_CHIPREV(AMD, STRIX_HALO, ANY, _X86_CHIPREV_REV_MATCH_ALL), + + + /* Keep at the end */ + X86_CHIPREV_ANY = _X86_CHIPREV_MKREV(_X86_VENDOR_MATCH_ALL, X86_PF_ANY, + _X86_CHIPREV_REV_MATCH_ALL) +} x86_chiprev_t; + +#undef _DECL_CHIPREV + +/* + * Same thing, but for microarchitecture (core implementations). We are not + * attempting to capture every possible fine-grained detail here; to the extent + * that it matters, we do so in cpuid.c via ISA/feature bits. We use the same + * number of bits for each field as in chiprev. + */ + +#define _X86_UARCHREV_VENDOR(x) _X86_CHIPREV_VENDOR(x) +#define _X86_UARCHREV_UARCH(x) _X86_CHIPREV_FAMILY(x) +#define _X86_UARCHREV_REV(x) _X86_CHIPREV_REV(x) + +#define _X86_UARCHREV_MKREV(vendor, family, rev) \ + _X86_CHIPREV_MKREV(vendor, family, rev) + +typedef enum x86_uarch { + X86_UARCH_UNKNOWN, + + X86_UARCH_AMD_LEGACY, + X86_UARCH_AMD_ZEN1, + X86_UARCH_AMD_ZENPLUS, + X86_UARCH_AMD_ZEN2, + X86_UARCH_AMD_ZEN3, + X86_UARCH_AMD_ZEN4, + X86_UARCH_AMD_ZEN5, + + X86_UARCH_ANY = 0xff +} x86_uarch_t; + +#define _DECL_UARCHREV(_v, _f, _revn, _revb) \ + X86_UARCHREV_ ## _v ## _ ## _f ## _ ## _revn = \ + _X86_UARCHREV_MKREV(X86_VENDOR_ ## _v, X86_UARCH_ ## _v ## _ ## _f, \ + _revb) + +#define _DECL_UARCHREV_NOREV(_v, _f, _revb) \ + X86_UARCHREV_ ## _v ## _ ## _f = \ + _X86_UARCHREV_MKREV(X86_VENDOR_ ## _v, X86_UARCH_ ## _v ## _ ## _f, \ + _revb) + +#define _X86_UARCHREV_REV_MATCH_ALL 0xffff + +typedef enum x86_uarchrev { + X86_UARCHREV_UNKNOWN, + _DECL_UARCHREV_NOREV(AMD, LEGACY, 0x0001), + _DECL_UARCHREV(AMD, LEGACY, ANY, _X86_UARCHREV_REV_MATCH_ALL), + + _DECL_UARCHREV_NOREV(AMD, ZEN1, 0x0001), + _DECL_UARCHREV(AMD, ZEN1, ANY, _X86_UARCHREV_REV_MATCH_ALL), + + _DECL_UARCHREV_NOREV(AMD, ZENPLUS, 0x0001), + _DECL_UARCHREV(AMD, ZENPLUS, ANY, _X86_UARCHREV_REV_MATCH_ALL), + + _DECL_UARCHREV(AMD, ZEN2, UNKNOWN, 0x0001), + _DECL_UARCHREV(AMD, ZEN2, A0, 0x0002), + _DECL_UARCHREV(AMD, ZEN2, B0, 0x0004), + _DECL_UARCHREV(AMD, ZEN2, ANY, _X86_UARCHREV_REV_MATCH_ALL), + + _DECL_UARCHREV(AMD, ZEN3, UNKNOWN, 0x0001), + _DECL_UARCHREV(AMD, ZEN3, A0, 0x0002), + _DECL_UARCHREV(AMD, ZEN3, B0, 0x0004), + _DECL_UARCHREV(AMD, ZEN3, B1, 0x0008), + _DECL_UARCHREV(AMD, ZEN3, B2, 0x0010), + _DECL_UARCHREV(AMD, ZEN3, ANY, _X86_UARCHREV_REV_MATCH_ALL), + + _DECL_UARCHREV(AMD, ZEN4, UNKNOWN, 0x0001), + _DECL_UARCHREV(AMD, ZEN4, A0, 0x0002), + _DECL_UARCHREV(AMD, ZEN4, A1, 0x0004), + _DECL_UARCHREV(AMD, ZEN4, A2, 0x0008), + _DECL_UARCHREV(AMD, ZEN4, B0, 0x0010), + _DECL_UARCHREV(AMD, ZEN4, B1, 0x0020), + _DECL_UARCHREV(AMD, ZEN4, B2, 0x0040), + _DECL_UARCHREV(AMD, ZEN4, ANY, _X86_UARCHREV_REV_MATCH_ALL), + + _DECL_UARCHREV(AMD, ZEN5, UNKNOWN, 0x0001), + _DECL_UARCHREV(AMD, ZEN5, A0, 0x0002), + _DECL_UARCHREV(AMD, ZEN5, B0, 0x0004), + _DECL_UARCHREV(AMD, ZEN5, B1, 0x0008), + _DECL_UARCHREV(AMD, ZEN5, C0, 0x0010), + _DECL_UARCHREV(AMD, ZEN5, C1, 0x0020), + _DECL_UARCHREV(AMD, ZEN5, ANY, _X86_UARCHREV_REV_MATCH_ALL), + + /* Keep at the end */ + _X86_UARCHREV_ANY = _X86_UARCHREV_MKREV(_X86_VENDOR_MATCH_ALL, + X86_UARCH_ANY, _X86_UARCHREV_REV_MATCH_ALL) +} x86_uarchrev_t; + +#undef _DECL_UARCHREV + +#endif /* !_ASM */ + +/* + * Various socket/package types, extended as the need to distinguish + * a new type arises. The top 8 byte identfies the vendor and the + * remaining 24 bits describe 24 socket types. + */ + +#define _X86_SOCKET_VENDOR_SHIFT 24 +#define _X86_SOCKET_VENDOR(x) ((x) >> _X86_SOCKET_VENDOR_SHIFT) +#define _X86_SOCKET_TYPE_MASK 0x00ffffff +#define _X86_SOCKET_TYPE(x) ((x) & _X86_SOCKET_TYPE_MASK) + +#define _X86_SOCKET_MKVAL(vendor, bitval) \ + ((uint32_t)(vendor) << _X86_SOCKET_VENDOR_SHIFT | (bitval)) + +#define X86_SOCKET_MATCH(s, mask) \ + (_X86_SOCKET_VENDOR(s) == _X86_SOCKET_VENDOR(mask) && \ + (_X86_SOCKET_TYPE(s) & _X86_SOCKET_TYPE(mask)) != 0) + +#define X86_SOCKET_UNKNOWN 0x0 + /* + * AMD socket types + */ +#define X86_SOCKET_754 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x01) +#define X86_SOCKET_939 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x02) +#define X86_SOCKET_940 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x03) +#define X86_SOCKET_S1g1 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x04) +#define X86_SOCKET_AM2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x05) +#define X86_SOCKET_F1207 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x06) +#define X86_SOCKET_S1g2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x07) +#define X86_SOCKET_S1g3 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x08) +#define X86_SOCKET_AM _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x09) +#define X86_SOCKET_AM2R2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x0a) +#define X86_SOCKET_AM3 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x0b) +#define X86_SOCKET_G34 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x0c) +#define X86_SOCKET_ASB2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x0d) +#define X86_SOCKET_C32 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x0e) +#define X86_SOCKET_S1g4 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x0f) +#define X86_SOCKET_FT1 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x10) +#define X86_SOCKET_FM1 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x11) +#define X86_SOCKET_FS1 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x12) +#define X86_SOCKET_AM3R2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x13) +#define X86_SOCKET_FP2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x14) +#define X86_SOCKET_FS1R2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x15) +#define X86_SOCKET_FM2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x16) +#define X86_SOCKET_FP3 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x17) +#define X86_SOCKET_FM2R2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x18) +#define X86_SOCKET_FP4 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x19) +#define X86_SOCKET_AM4 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x1a) +#define X86_SOCKET_FT3 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x1b) +#define X86_SOCKET_FT4 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x1c) +#define X86_SOCKET_FS1B _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x1d) +#define X86_SOCKET_FT3B _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x1e) +#define X86_SOCKET_SP3 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x1f) +#define X86_SOCKET_SP3R2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x20) +#define X86_SOCKET_FP5 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x21) +#define X86_SOCKET_FP6 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x22) +#define X86_SOCKET_STRX4 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x23) +#define X86_SOCKET_SP5 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x24) +#define X86_SOCKET_AM5 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x25) +#define X86_SOCKET_FP7 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x26) +#define X86_SOCKET_FP7R2 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x27) +#define X86_SOCKET_FF3 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x28) +#define X86_SOCKET_FT6 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x29) +#define X86_SOCKET_FP8 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x2a) +#define X86_SOCKET_FL1 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x2b) +#define X86_SOCKET_SP6 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x2c) +#define X86_SOCKET_TR5 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x2d) +#define X86_SOCKET_FP11 _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x2e) +#define X86_NUM_SOCKETS_AMD 0x2e + +/* + * Hygon socket types + */ +#define X86_SOCKET_SL1 _X86_SOCKET_MKVAL(X86_VENDOR_HYGON, 0x01) +#define X86_SOCKET_SL1R2 _X86_SOCKET_MKVAL(X86_VENDOR_HYGON, 0x02) +#define X86_SOCKET_DM1 _X86_SOCKET_MKVAL(X86_VENDOR_HYGON, 0x03) +#define X86_NUM_SOCKETS_HYGON 0x03 + +#define X86_NUM_SOCKETS (X86_NUM_SOCKETS_AMD + X86_NUM_SOCKETS_HYGON) + +/* + * Definitions for Intel processor models. These are all for Family 6 + * processors. This list and the Atom set below it are not exhuastive. + */ +#define INTC_MODEL_YONAH 0x0e +#define INTC_MODEL_MEROM 0x0f +#define INTC_MODEL_MEROM_L 0x16 +#define INTC_MODEL_PENRYN 0x17 +#define INTC_MODEL_DUNNINGTON 0x1d + +#define INTC_MODEL_NEHALEM 0x1e +#define INTC_MODEL_NEHALEM2 0x1f +#define INTC_MODEL_NEHALEM_EP 0x1a +#define INTC_MODEL_NEHALEM_EX 0x2e + +#define INTC_MODEL_WESTMERE 0x25 +#define INTC_MODEL_WESTMERE_EP 0x2c +#define INTC_MODEL_WESTMERE_EX 0x2f + +#define INTC_MODEL_SANDYBRIDGE 0x2a +#define INTC_MODEL_SANDYBRIDGE_XEON 0x2d +#define INTC_MODEL_IVYBRIDGE 0x3a +#define INTC_MODEL_IVYBRIDGE_XEON 0x3e + +#define INTC_MODEL_HASWELL 0x3c +#define INTC_MODEL_HASWELL_ULT 0x45 +#define INTC_MODEL_HASWELL_GT3E 0x46 +#define INTC_MODEL_HASWELL_XEON 0x3f + +#define INTC_MODEL_BROADWELL 0x3d +#define INTC_MODEL_BROADWELL_2 0x47 +#define INTC_MODEL_BROADWELL_XEON 0x4f +#define INTC_MODEL_BROADWELL_XEON_D 0x56 + +#define INTC_MODEL_SKYLAKE_MOBILE 0x4e +/* + * Note, this model is shared with Cascade Lake and Cooper Lake. + */ +#define INTC_MODEL_SKYLAKE_XEON 0x55 +#define INTC_MODEL_SKYLAKE_DESKTOP 0x5e + +#define INTC_MODEL_CANNON_LAKE 0x66 + +/* + * Note, both Kaby Lake models are shared with Coffee Lake, Whiskey Lake, Amber + * Lake, and some Comet Lake parts. + */ +#define INTC_MODEL_KABYLAKE_MOBILE 0x8e +#define INTC_MODEL_KABYLAKE_DESKTOP 0x9e + +#define INTC_MODEL_ICELAKE_XEON 0x6a +#define INTC_MODEL_ICELAKE_MOBILE 0x7e +#define INTC_MODEL_ICELAKE_XEON_DE 0x6c + +#define INTC_MODEL_TIGERLAKE_MOBILE 0x8c +#define INTC_MODEL_TIGERLAKE_MOBILE_2 0x8d +#define INTC_MODEL_SAPPHIRE_RAPIDS 0x8f + +#define INTC_MODEL_COMETLAKE 0xa5 +#define INTC_MODEL_COMETLAKE_MOBILE 0xa6 +#define INTC_MODEL_ROCKETLAKE 0xa7 + +#define INTC_MODEL_ALDER_LAKE_DESKTOP 0x97 +#define INTC_MODEL_ALDER_LAKE_MOBILE 0x9a /* And some Atom parts too */ +#define INTC_MODEL_RAPTOR_LAKE_MOBILE_1 0xb7 +#define INTC_MODEL_RAPTOR_LAKE_MOBILE_2 0xba +#define INTC_MODEL_RAPTOR_LAKE_MOBILE_3 0xbf + +#define INTC_MODEL_METEOR_LAKE 0xaa + +#define INTC_MODEL_EMERALD_RAPIDS 0xcf + +/* + * Atom Processors + */ +#define INTC_MODEL_SILVERTHORNE 0x1c +#define INTC_MODEL_LINCROFT 0x26 +#define INTC_MODEL_PENWELL 0x27 +#define INTC_MODEL_CLOVERVIEW 0x35 +#define INTC_MODEL_CEDARVIEW 0x36 +#define INTC_MODEL_BAY_TRAIL 0x37 +#define INTC_MODEL_MERRIFIELD 0x4a +#define INTC_MODEL_AVATON 0x4d +#define INTC_MODEL_AIRMONT 0x4c +#define INTC_MODEL_MOOREFIELD 0x5a +#define INTC_MODEL_APOLLO_LAKE 0x5c +#define INTC_MODEL_SOFIA_3G_R 0x5d +#define INTC_MODEL_DENVERTON 0x5f +#define INTC_MODEL_GEMINI_LAKE 0x7a +#define INTC_MODEL_TREMONT 0x86 /* Parker Ridge & Snow Ridge */ +#define INTC_MODEL_LAKEFIELD 0x8a +#define INTC_MODEL_ELKHART_LAKE 0x96 +#define INTC_MODEL_JASPER_LAKE 0x9c +#define INTC_MODEL_ALDER_LAKE_N 0xbe /* And some {desk,lap}top too */ + +/* + * xgetbv/xsetbv support + * See section 13.3 in vol. 1 of the Intel Developer's manual. + */ + +#define XFEATURE_ENABLED_MASK 0x0 +/* + * XFEATURE_ENABLED_MASK values (eax) + * See setup_xfem(). + */ +#define XFEATURE_LEGACY_FP (1 << 0) +#define XFEATURE_SSE (1 << 1) +#define XFEATURE_AVX (1 << 2) +/* + * MPX is meant to be all or nothing, therefore for most of the kernel prefer + * the XFEATURE_MPX definition over the individual state bits. + */ +#define XFEATURE_MPX_BNDREGS (1 << 3) +#define XFEATURE_MPX_BNDCSR (1 << 4) +#define XFEATURE_MPX (XFEATURE_MPX_BNDREGS | XFEATURE_MPX_BNDCSR) +/* + * AX512 is meant to be all or nothing, therefore for most of the kernel prefer + * the XFEATURE_AVX512 definition over the individual state bits. + */ +#define XFEATURE_AVX512_OPMASK (1 << 5) +#define XFEATURE_AVX512_ZMM (1 << 6) +#define XFEATURE_AVX512_HI_ZMM (1 << 7) +#define XFEATURE_AVX512 (XFEATURE_AVX512_OPMASK | \ + XFEATURE_AVX512_ZMM | XFEATURE_AVX512_HI_ZMM) + /* bit 8 unused */ +#define XFEATURE_PKRU (1 << 9) +#define XFEATURE_FP_ALL \ + (XFEATURE_LEGACY_FP | XFEATURE_SSE | XFEATURE_AVX | XFEATURE_MPX | \ + XFEATURE_AVX512 | XFEATURE_PKRU) + +/* + * Define the set of xfeature flags that should be considered valid in the xsave + * state vector when we initialize an lwp. This is distinct from the full set so + * that all of the processor's normal logic and tracking of the xsave state is + * usable. This should correspond to the state that's been initialized by the + * ABI to hold meaningful values. Adding additional bits here can have serious + * performance implications and cause performance degradations when using the + * FPU vector (xmm) registers. + */ +#define XFEATURE_FP_INITIAL (XFEATURE_LEGACY_FP | XFEATURE_SSE) + +#if !defined(_ASM) + +#if defined(_KERNEL) || defined(_KMEMUSER) + +#define NUM_X86_FEATURES 114 +extern uchar_t x86_featureset[]; + +extern void free_x86_featureset(void *featureset); +extern boolean_t is_x86_feature(void *featureset, uint_t feature); +extern void add_x86_feature(void *featureset, uint_t feature); +extern void remove_x86_feature(void *featureset, uint_t feature); +extern boolean_t compare_x86_featureset(void *setA, void *setB); +extern void print_x86_featureset(void *featureset); + + +extern uint_t x86_type; +extern uint_t x86_vendor; +extern uint_t x86_clflush_size; + +extern uint_t pentiumpro_bug4046376; + +/* + * These functions are all used to perform various side-channel mitigations. + * Please see uts/intel/os/cpuid.c for more information. + */ +extern void (*spec_uarch_flush)(void); +extern void x86_rsb_stuff(void); +extern void x86_rsb_stuff_vmexit(void); +extern void x86_bhb_clear(void); +extern void x86_md_clear(void); + +#endif + +#if defined(_KERNEL) + +/* + * This structure is used to pass arguments and get return values back + * from the CPUID instruction in __cpuid_insn() routine. + */ +struct cpuid_regs { + uint32_t cp_eax; + uint32_t cp_ebx; + uint32_t cp_ecx; + uint32_t cp_edx; +}; + +extern int x86_use_pcid; +extern int x86_use_invpcid; + +/* + * Utility functions to get/set extended control registers (XCR) + * Initial use is to get/set the contents of the XFEATURE_ENABLED_MASK. + */ +extern uint64_t get_xcr(uint_t); +extern void set_xcr(uint_t, uint64_t); + +extern uint64_t rdmsr(uint_t); +extern void wrmsr(uint_t, const uint64_t); +extern uint64_t xrdmsr(uint_t); +extern void xwrmsr(uint_t, const uint64_t); +extern int checked_rdmsr(uint_t, uint64_t *); +extern int checked_wrmsr(uint_t, uint64_t); +extern void wrmsr_and_test(uint_t, const uint64_t); + +extern void invalidate_cache(void); +extern ulong_t getcr4(void); +extern void setcr4(ulong_t); + +extern void mtrr_sync(void); + +extern void cpu_fast_syscall_enable(void); +extern void cpu_fast_syscall_disable(void); + +typedef enum cpuid_pass { + CPUID_PASS_NONE = 0, + CPUID_PASS_PRELUDE, + CPUID_PASS_IDENT, + CPUID_PASS_BASIC, + CPUID_PASS_EXTENDED, + CPUID_PASS_DYNAMIC, + CPUID_PASS_RESOLVE +} cpuid_pass_t; + +struct cpu; + +extern boolean_t cpuid_checkpass(const struct cpu *const, const cpuid_pass_t); +extern void cpuid_execpass(struct cpu *, const cpuid_pass_t, void *); +extern void cpuid_pass_ucode(struct cpu *, uchar_t *); +extern uint32_t cpuid_insn(struct cpu *, struct cpuid_regs *); +extern uint32_t __cpuid_insn(struct cpuid_regs *); +extern int cpuid_getbrandstr(struct cpu *, char *, size_t); +extern int cpuid_getidstr(struct cpu *, char *, size_t); +extern const char *cpuid_getvendorstr(struct cpu *); +extern uint_t cpuid_getvendor(struct cpu *); +extern uint_t cpuid_getfamily(struct cpu *); +extern uint_t cpuid_getmodel(struct cpu *); +extern uint_t cpuid_getstep(struct cpu *); +extern uint_t cpuid_getsig(struct cpu *); +extern uint_t cpuid_get_ncpu_per_chip(struct cpu *); +extern uint_t cpuid_get_ncore_per_chip(struct cpu *); +extern uint_t cpuid_get_ncpu_sharing_last_cache(struct cpu *); +extern id_t cpuid_get_last_lvl_cacheid(struct cpu *); +extern int cpuid_get_chipid(struct cpu *); +extern id_t cpuid_get_coreid(struct cpu *); +extern int cpuid_get_pkgcoreid(struct cpu *); +extern int cpuid_get_clogid(struct cpu *); +extern int cpuid_get_cacheid(struct cpu *); +extern uint32_t cpuid_get_apicid(struct cpu *); +extern uint_t cpuid_get_procnodeid(struct cpu *cpu); +extern uint_t cpuid_get_procnodes_per_pkg(struct cpu *cpu); +extern uint_t cpuid_get_compunitid(struct cpu *cpu); +extern uint_t cpuid_get_cores_per_compunit(struct cpu *cpu); +extern size_t cpuid_get_xsave_size(void); +extern void cpuid_get_xsave_info(uint64_t, size_t *, size_t *); +extern boolean_t cpuid_need_fp_excp_handling(void); +extern int cpuid_is_cmt(struct cpu *); +extern int cpuid_syscall32_insn(struct cpu *); +extern int getl2cacheinfo(struct cpu *, int *, int *, int *); + +extern x86_chiprev_t cpuid_getchiprev(struct cpu *); +extern const char *cpuid_getchiprevstr(struct cpu *); +extern uint32_t cpuid_getsockettype(struct cpu *); +extern const char *cpuid_getsocketstr(struct cpu *); +extern x86_uarchrev_t cpuid_getuarchrev(struct cpu *); + +extern int cpuid_opteron_erratum(struct cpu *, uint_t); + +struct cpuid_info; + +extern void setx86isalist(void); +extern void cpuid_alloc_space(struct cpu *); +extern void cpuid_free_space(struct cpu *); +extern void cpuid_set_cpu_properties(void *, processorid_t, + struct cpuid_info *); +extern void cpuid_post_ucodeadm(void); + +extern void cpuid_get_addrsize(struct cpu *, uint_t *, uint_t *); +extern uint_t cpuid_get_dtlb_nent(struct cpu *, size_t); + +#if !defined(__xpv) +extern uint32_t *cpuid_mwait_alloc(struct cpu *); +extern void cpuid_mwait_free(struct cpu *); +extern int cpuid_deep_cstates_supported(void); +extern int cpuid_arat_supported(void); +extern int cpuid_iepb_supported(struct cpu *); +extern int cpuid_deadline_tsc_supported(void); +extern void vmware_port(int, uint32_t *); +#endif + +extern x86_processor_family_t chiprev_family(const x86_chiprev_t); +extern boolean_t chiprev_matches(const x86_chiprev_t, const x86_chiprev_t); +extern boolean_t chiprev_at_least(const x86_chiprev_t, const x86_chiprev_t); + +extern x86_uarch_t uarchrev_uarch(const x86_uarchrev_t); +extern boolean_t uarchrev_matches(const x86_uarchrev_t, const x86_uarchrev_t); +extern boolean_t uarchrev_at_least(const x86_uarchrev_t, const x86_uarchrev_t); + +/* + * Cache information intended for topology and wider use. + */ +typedef enum { + X86_CACHE_TYPE_DATA, + X86_CACHE_TYPE_INST, + X86_CACHE_TYPE_UNIFIED +} x86_cache_type_t; + +typedef enum { + X86_CACHE_F_FULL_ASSOC = 1 << 0 +} x86_cache_flags_t; + +typedef struct x86_cache { + uint32_t xc_level; + x86_cache_type_t xc_type; + x86_cache_flags_t xc_flags; + uint32_t xc_nparts; + uint32_t xc_nways; + uint32_t xc_line_size; + uint64_t xc_nsets; + uint64_t xc_size; + uint64_t xc_id; + uint32_t xc_apic_shift; +} x86_cache_t; + +extern int cpuid_getncaches(struct cpu *, uint32_t *); +extern int cpuid_getcache(struct cpu *, uint32_t, x86_cache_t *); + +struct cpu_ucode_info; + +extern void ucode_alloc_space(struct cpu *); +extern void ucode_free_space(struct cpu *); +extern void ucode_init(void); +extern void ucode_check_boot(void); +extern void ucode_read_rev(struct cpu *); +extern void ucode_locate(struct cpu *); +extern void ucode_apply(struct cpu *); +extern void ucode_finish(struct cpu *); +extern void ucode_cleanup(); + +#if !defined(__xpv) +extern char _tsc_mfence_start; +extern char _tsc_mfence_end; +extern char _tscp_start; +extern char _tscp_end; +extern char _no_rdtsc_start; +extern char _no_rdtsc_end; +extern char _tsc_lfence_start; +extern char _tsc_lfence_end; +#endif + +#if !defined(__xpv) +extern char bcopy_patch_start; +extern char bcopy_patch_end; +extern char bcopy_ck_size; +#endif + +extern void post_startup_cpu_fixups(void); + +extern uint_t workaround_errata(struct cpu *); + +#if defined(OPTERON_ERRATUM_93) +extern int opteron_erratum_93; +#endif + +#if defined(OPTERON_ERRATUM_91) +extern int opteron_erratum_91; +#endif + +#if defined(OPTERON_ERRATUM_100) +extern int opteron_erratum_100; +#endif + +#if defined(OPTERON_ERRATUM_121) +extern int opteron_erratum_121; +#endif + +#if defined(OPTERON_ERRATUM_147) +extern int opteron_erratum_147; +extern void patch_erratum_147(void); +#endif + +#if !defined(__xpv) +extern void determine_platform(void); +#endif +extern int get_hwenv(void); +extern int is_controldom(void); + +extern void enable_pcid(void); + +extern void xsave_setup_msr(struct cpu *); + +#if !defined(__xpv) +extern void reset_gdtr_limit(void); +#endif + +extern int enable_platform_detection; + +/* + * Hypervisor signatures + */ +#define HVSIG_XEN_HVM "XenVMMXenVMM" +#define HVSIG_VMWARE "VMwareVMware" +#define HVSIG_KVM "KVMKVMKVM" +#define HVSIG_MICROSOFT "Microsoft Hv" +#define HVSIG_BHYVE "bhyve bhyve " +#define HVSIG_QEMU_TCG "TCGTCGTCGTCG" +#define HVSIG_VIRTUALBOX "VBoxVBoxVBox" +#define HVSIG_ACRN "ACRNACRNACRN" + +/* + * Defined hardware environments + */ +#define HW_NATIVE (1 << 0) /* Running on bare metal */ +#define HW_XEN_PV (1 << 1) /* Running on Xen PVM */ + +#define HW_XEN_HVM (1 << 2) /* Running on Xen HVM */ +#define HW_VMWARE (1 << 3) /* Running on VMware hypervisor */ +#define HW_KVM (1 << 4) /* Running on KVM hypervisor */ +#define HW_MICROSOFT (1 << 5) /* Running on Microsoft hypervisor */ +#define HW_BHYVE (1 << 6) /* Running on bhyve hypervisor */ +#define HW_QEMU_TCG (1 << 7) /* Running on QEMU TCG hypervisor */ +#define HW_VIRTUALBOX (1 << 8) /* Running on VirtualBox hypervisor */ +#define HW_ACRN (1 << 9) /* Running on ACRN hypervisor */ + +#define HW_VIRTUAL (HW_XEN_HVM | HW_VMWARE | HW_KVM | HW_MICROSOFT | \ + HW_BHYVE | HW_QEMU_TCG | HW_VIRTUALBOX | HW_ACRN) + +#endif /* _KERNEL */ + +#endif /* !_ASM */ + +/* + * VMware hypervisor related defines + */ +#define VMWARE_HVMAGIC 0x564d5868 +#define VMWARE_HVPORT 0x5658 +#define VMWARE_HVCMD_GETVERSION 0x0a +#define VMWARE_HVCMD_GETTSCFREQ 0x2d + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_X86_ARCHEXT_H */ diff --git a/illumos-x86_64/usr/include/sys/xen_errno.h b/illumos-x86_64/usr/include/sys/xen_errno.h new file mode 100644 index 00000000..ee0c4b38 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/xen_errno.h @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_XEN_ERRNO_H +#define _SYS_XEN_ERRNO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Xen errno's for HYPERVISOR calls + * + * XXPV This is maintained by hand :( + * + * Unfortunately native Xen currently uses the same namespace as the Solaris + * errno namespace but with (some) different numeric values. + * + * This set of errno values match Xen 3.0.3; sigh. + * + * In a better world, Xen would make its namespace explicitly different + * e.g. something like below. + */ + +#define X_EPERM 1 +#define X_ENOENT 2 +#define X_ESRCH 3 +#define X_EINTR 4 +#define X_EIO 5 +#define X_ENXIO 6 +#define X_E2BIG 7 + +#define X_EAGAIN 11 +#define X_ENOMEM 12 +#define X_EACCES 13 +#define X_EFAULT 14 + +#define X_EBUSY 16 +#define X_EEXIST 17 + +#define X_ENODEV 19 +#define X_EISDIR 21 +#define X_EINVAL 22 + +#define X_ENOSPC 28 +#define X_ESPIPE 29 +#define X_EROFS 30 + +#define X_ENOSYS 38 +#define X_ENOTEMPTY 39 + +#define X_ENODATA 61 + +#define X_EISCONN 106 + +#ifndef _ASM +#if defined(_KERNEL) +/* + * Error code translation routine to translate xen error codes to + * Solaris error codes. Xen returns negative error codes which this + * routine will translate to a positive one. + */ +extern int xen_xlate_errcode(int); +#endif /* _KERNEL */ +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_XEN_ERRNO_H */ diff --git a/illumos-x86_64/usr/include/sys/xti_inet.h b/illumos-x86_64/usr/include/sys/xti_inet.h new file mode 100644 index 00000000..503e7959 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/xti_inet.h @@ -0,0 +1,232 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1996-1998 Sun Microsystems, Inc. */ +/* All Rights Reserved */ + +/* + * This is a private header file. Applications should not directly include + * this file. Instead they should include + */ + +#ifndef _SYS_XTI_INET_H +#define _SYS_XTI_INET_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This is a private header file. Applications should not directly include + * this file. Instead they should include + */ + +#if !defined(_XPG5) + +/* + * INTERNET SPECIFIC ENVIRONMENT + * + * Note: + * Unfortunately, XTI specification test assertions require exposing in + * headers options that are not implemented. They also require exposing + * Internet and OSI related options as part of inclusion of + * + * Also XTI specification intrudes on TCP_ and IP_ namespaces + * and sometimes redefines the semantics or types of some options with a + * different history in that namespace. The name and binary value are exposed + * but option semantics may be different from what is in XTI spec and we defer + * to the precedent. + * + * New applications should not use these constants. These are meant + * for compatibility with older applications. + */ + +/* + * TCP level + */ +#define INET_TCP 6 /* must be same as IPPROTO_TCP in */ + +/* + * TCP level options + */ +#ifndef TCP_NODELAY +#define TCP_NODELAY 0x1 /* must be same as */ +#endif + +#ifndef TCP_MAXSEG +#define TCP_MAXSEG 0x2 /* must be same as */ +#endif + +#ifndef TCP_KEEPALIVE +#define TCP_KEEPALIVE 0x8 /* must be same as */ +#endif + +#endif /* !defined(_XPG5) */ + +/* + * New applications must not use the constants defined above. Instead + * they must use the constants with the T_ prefix defined below. The + * constants without the T_ prefix are meant for compatibility with + * older applications. + */ + +/* + * TCP level + */ +#define T_INET_TCP 6 + +#define T_TCP_NODELAY 0x1 /* Don't delay packets to coalesce */ +#define T_TCP_MAXSEG 0x2 /* Get maximum segment size */ +#define T_TCP_KEEPALIVE 0x8 /* check, if connections are alive */ + +/* + * Structure used with TCP_KEEPALIVE option. + */ +struct t_kpalive { + t_scalar_t kp_onoff; /* option on/off */ + t_scalar_t kp_timeout; /* timeout in minutes */ +}; + + +#if !defined(_XPG5) + +/* + * New applications must not use the constants defined below. Instead they + * must use the corresponding T_prefix constants. The constants without the + * T_ prefix are supported for legacy applications. + */ + +#define T_GARBAGE 0x02 /* send garbage byte */ + +/* + * UDP level + */ +#define INET_UDP 17 /* must be same as IPPROTO_UDP in */ + + +/* + * UDP level Options + */ + +#ifndef UDP_CHECKSUM +#define UDP_CHECKSUM 0x0600 /* must be same as in */ +#endif + +/* + * IP level + */ +#define INET_IP 0 /* must be same as IPPROTO_IP in */ + +/* + * IP level Options + */ + +#ifndef IP_OPTIONS +#define IP_OPTIONS 0x1 /* must be same as */ +#endif + +#ifndef IP_TOS +#define IP_TOS 0x3 /* must be same as */ +#endif + +#ifndef IP_TTL +#define IP_TTL 0x4 /* must be same as */ +#endif + +/* + * following also added to and be in sync to keep namespace + * sane + */ + +#ifndef IP_REUSEADDR +#define IP_REUSEADDR 0x104 /* allow local address reuse */ +#endif + +#ifndef IP_DONTROUTE +#define IP_DONTROUTE 0x105 /* just use interface addresses */ +#endif + +#ifndef IP_BROADCAST +#define IP_BROADCAST 0x106 /* permit sending of broadcast msgs */ +#endif + +#endif /* !defined(_XPG5) */ + +/* + * New applications should use the T_ prefix constants below + */ + +/* + * UDP level + */ +#define T_INET_UDP 17 + +/* + * UDP level Options + */ +#define T_UDP_CHECKSUM 0x0600 /* Checksum computation */ + +/* + * IP level + */ +#define T_INET_IP 0 + +/* + * IP level Options + */ +#define T_IP_TTL 0x4 /* IP per packet time to live */ +#define T_IP_REUSEADDR 0x104 /* allow local address reuse */ +#define T_IP_DONTROUTE 0x105 /* just use interface addresses */ +#define T_IP_BROADCAST 0x106 /* permit sending of broadcast msgs */ +#define T_IP_OPTIONS 0x107 /* IP per-packet options */ +#define T_IP_TOS 0x108 /* IP per packet type of service */ + +/* + * IP_TOS precedence level + */ +#define T_ROUTINE 0 +#define T_PRIORITY 1 +#define T_IMMEDIATE 2 +#define T_FLASH 3 +#define T_OVERRIDEFLASH 4 +#define T_CRITIC_ECP 5 +#define T_INETCONTROL 6 +#define T_NETCONTROL 7 + + +/* + * IP_TOS type of service + */ +#define T_NOTOS 0 +#define T_LDELAY (1<<4) +#define T_HITHRPT (1<<3) +#define T_HIREL (1<<2) +#define T_LOCOST (1<<1) + +#define SET_TOS(prec, tos) ((0x7 & (prec)) << 5 | (0x1e & (tos))) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_XTI_INET_H */ diff --git a/illumos-x86_64/usr/include/sys/xti_osi.h b/illumos-x86_64/usr/include/sys/xti_osi.h new file mode 100644 index 00000000..bb9645b4 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/xti_osi.h @@ -0,0 +1,177 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1996-1998 Sun Microsystems, Inc. */ +/* All Rights Reserved */ + + +#ifndef _SYS_XTI_OSI_H +#define _SYS_XTI_OSI_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_XPG5) + +/* + * SPECIFIC ISO OPTION AND MANAGEMENT PARAMETERS + * + * Note: + * Unfortunately, XTI specification test assertions require exposing in + * headers options that are not implemented. They also require exposing + * Internet and OSI related options as part of inclusion of + * + */ + + +/* + * Definitions of ISO transport classes + */ + +#define T_CLASS0 0 +#define T_CLASS1 1 +#define T_CLASS2 2 +#define T_CLASS3 3 +#define T_CLASS4 4 + + +/* + * Definition of the priorities + */ + +#define T_PRITOP 0 +#define T_PRIHIGH 1 +#define T_PRIMID 2 +#define T_PRILOW 3 +#define T_PRIDFLT 4 + +/* + * Definitions of the protection levels + */ + +#define T_NOPROTECT 1 +#define T_PASSIVEPROTECT 2 +#define T_ACTIVEPROTECT 4 + +/* + * Default values for the length of TPDUs + * Note: Sigh ! This obsolete constant required according to XTI test + * assertions. + */ + +#define T_LTPDUDFLT 128 /* define obsolete in XPG4 */ + +/* + * rate structure + */ + +struct rate { + t_scalar_t targetvalue; /* target value */ + t_scalar_t minacceptvalue; /* value of minimum */ + /* acceptable quality */ +}; + +/* + * reqvalue structure + */ + +struct reqvalue { + struct rate called; /* called rate */ + struct rate calling; /* calling rate */ +}; + +/* + * thrpt structure + */ + +struct thrpt { + struct reqvalue maxthrpt; /* maximum throughput */ + struct reqvalue avgthrpt; /* average throughput */ +}; + +/* + * transdel structure + */ + +struct transdel { + struct reqvalue maxdel; /* maximum transit delay */ + struct reqvalue avgdel; /* average throughput */ +}; + +/* + * Protocol Levels + */ + +#define ISO_TP 0x0100 + +/* + * Options for Quality of Service and Expedited Data (ISO 8072:1986) + */ + +#define TCO_THROUGHPUT 0x0001 +#define TCO_TRANSDEL 0x0002 +#define TCO_RESERRORRATE 0x0003 +#define TCO_TRANSFFAILPROB 0x0004 +#define TCO_ESTFAILPROB 0x0005 +#define TCO_RELFAILPROB 0x0006 +#define TCO_ESTDELAY 0x0007 +#define TCO_RELDELAY 0x0008 +#define TCO_CONNRESIL 0x0009 +#define TCO_PROTECTION 0x000a +#define TCO_PRIORITY 0x000b +#define TCO_EXPD 0x000c + +#define TCL_TRANSDEL 0x000d +#define TCL_RESERRORRATE TCO_RESERRORRATE +#define TCL_PROTECTION TCO_PROTECTION +#define TCL_PRIORITY TCO_PRIORITY + + +/* + * Management Options + */ + +#define TCO_LTPDU 0x0100 +#define TCO_ACKTIME 0x0200 +#define TCO_REASTIME 0x0300 +#define TCO_EXTFORM 0x0400 +#define TCO_FLOWCTRL 0x0500 +#define TCO_CHECKSUM 0x0600 +#define TCO_NETEXP 0x0700 +#define TCO_NETRECPTCF 0x0800 +#define TCO_PREFCLASS 0x0900 +#define TCO_ALTCLASS1 0x0a00 +#define TCO_ALTCLASS2 0x0b00 +#define TCO_ALTCLASS3 0x0c00 +#define TCO_ALTCLASS4 0x0d00 + +#define TCL_CHECKSUM TCO_CHECKSUM + +#endif /* !defined(_XPG5) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_XTI_OSI_H */ diff --git a/illumos-x86_64/usr/include/sys/xti_xtiopt.h b/illumos-x86_64/usr/include/sys/xti_xtiopt.h new file mode 100644 index 00000000..7d183ecb --- /dev/null +++ b/illumos-x86_64/usr/include/sys/xti_xtiopt.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_XTI_XTIOPT_H +#define _SYS_XTI_XTIOPT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * OPTIONS ON XTI LEVEL + * + * Note: + * Unfortunately, XTI specification test assertions require exposing in + * headers options that are not implemented. They also require exposing + * Internet and OSI related options as part of inclusion of + */ + +/* XTI level */ + +#define XTI_GENERIC 0xfffe + +/* + * XTI-level Options + */ + +#define XTI_DEBUG 0x0001 /* enable debugging */ +#define XTI_LINGER 0x0080 /* linger on close if data present */ +#define XTI_RCVBUF 0x1002 /* receive buffer size */ +#define XTI_RCVLOWAT 0x1004 /* receive low water mark */ +#define XTI_SNDBUF 0x1001 /* send buffer size */ +#define XTI_SNDLOWAT 0x1003 /* send low-water mark */ + + +/* + * Structure used with linger option. + */ + +struct t_linger { + t_scalar_t l_onoff; /* option on/off */ + t_scalar_t l_linger; /* linger time */ +}; + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_XTI_XTIOPT_H */ diff --git a/illumos-x86_64/usr/include/sys/zcons.h b/illumos-x86_64/usr/include/sys/zcons.h new file mode 100644 index 00000000..84abdc12 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/zcons.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ZCONS_H +#define _SYS_ZCONS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Minor node name of the global zone side (often called the "manager" side) + * of the zcons driver. + */ +#define ZCONS_MANAGER_NAME "globalconsole" + +/* + * Minor node name of the non-global zone side (often called the "subsidiary" + * side) of the zcons driver. We name it "zoneconsole" since that name + * will show up in 'ps' output, and will make some sense to the global zone + * user. Inside the zone, it will simply show up as "console" due to the + * links we create. + */ +#define ZCONS_SUBSIDIARY_NAME "zoneconsole" + +/* + * ZC_IOC forms the base for all zcons ioctls. + */ +#define ZC_IOC (('Z' << 24) | ('o' << 16) | ('n' << 8)) + +/* + * These ioctls instruct the manager side of the console to hold or release + * a reference to the subsidiary side's vnode. They are meant to be issued by + * zoneadmd after the console device node is created and before it is destroyed + * so that the subsidiary's STREAMS anchor, ptem, is preserved when ttymon + * starts popping STREAMS modules from within the associated zone. This + * guarantees that the zone subsidiary console will always have terminal + * semantics while the zone is running. + * + * A more detailed description can be found in uts/common/io/zcons.c. + */ +#define ZC_HOLDSUBSID (ZC_IOC | 0) +#define ZC_RELEASESUBSID (ZC_IOC | 1) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ZCONS_H */ diff --git a/illumos-x86_64/usr/include/sys/zmod.h b/illumos-x86_64/usr/include/sys/zmod.h new file mode 100644 index 00000000..c606b1db --- /dev/null +++ b/illumos-x86_64/usr/include/sys/zmod.h @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ZMOD_H +#define _ZMOD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * zmod - RFC-1950-compatible decompression routines + * + * This file provides the public interfaces to zmod, an in-kernel RFC 1950 + * decompression library. More information about the implementation of these + * interfaces can be found in the usr/src/uts/common/zmod/ directory. + */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) + +extern int z_uncompress(void *, size_t *, const void *, size_t); +extern int z_compress(void *, size_t *, const void *, size_t); +extern int z_compress_level(void *, size_t *, const void *, size_t, int); +extern const char *z_strerror(int); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZMOD_H */ diff --git a/illumos-x86_64/usr/include/sys/zone.h b/illumos-x86_64/usr/include/sys/zone.h new file mode 100644 index 00000000..cf0c5c47 --- /dev/null +++ b/illumos-x86_64/usr/include/sys/zone.h @@ -0,0 +1,1053 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2014 Igor Kozhukhov . + * Copyright 2019 Nexenta Systems, Inc. All rights reserved. + * Copyright 2020 Joyent, Inc. + */ + +#ifndef _SYS_ZONE_H +#define _SYS_ZONE_H + +#include +#include +#include +#include +#include + +#ifdef _KERNEL +/* + * Many includes are kernel-only to reduce namespace pollution of + * userland applications. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NOTE + * + * The contents of this file are private to the implementation of + * illumos and are subject to change at any time without notice. + * Applications and drivers using these interfaces may fail to + * run on future releases. + */ + +/* Available both in kernel and for user space */ + +/* + * zone id restrictions and special ids. + * See 'maxzones' for run-time zone limit. + * + * The current 8k value for MAX_ZONES was originally derived from the virtual + * interface limit in IP when "shared-stack" was the only supported networking + * for zones. The virtual interface limit is the number of addresses allowed + * on an interface (see MAX_ADDRS_PER_IF). Even with exclusive stacks, an 8k + * zone limit is still a reasonable choice at this time, given other limits + * within the kernel. Since we only support 8192 zones (which includes GZ), + * there is no point in allowing MAX_ZONEID > 8k. + */ +#define MAX_ZONES 8192 +#define MAX_ZONEID (MAX_ZONES - 1) +#define MIN_USERZONEID 1 /* lowest user-creatable zone ID */ +#define MIN_ZONEID 0 /* minimum zone ID on system */ +#define GLOBAL_ZONEID 0 +#define ZONEID_WIDTH 4 /* for printf */ + +/* + * Special zoneid_t token to refer to all zones. + */ +#define ALL_ZONES (-1) + +/* system call subcodes */ +#define ZONE_CREATE 0 +#define ZONE_DESTROY 1 +#define ZONE_GETATTR 2 +#define ZONE_ENTER 3 +#define ZONE_LIST 4 +#define ZONE_SHUTDOWN 5 +#define ZONE_LOOKUP 6 +#define ZONE_BOOT 7 +#define ZONE_VERSION 8 +#define ZONE_SETATTR 9 +#define ZONE_ADD_DATALINK 10 +#define ZONE_DEL_DATALINK 11 +#define ZONE_CHECK_DATALINK 12 +#define ZONE_LIST_DATALINK 13 + +/* + * zone attributes + * + * Note that values up to ZONE_ATTR_HOSTID are baked into things like Solaris + * 10 which can be run under the s10 brand; don't renumber or change them. Ones + * which are no longer used are commented out. + */ +#define ZONE_ATTR_ROOT 1 +#define ZONE_ATTR_NAME 2 +#define ZONE_ATTR_STATUS 3 +#define ZONE_ATTR_PRIVSET 4 +#define ZONE_ATTR_UNIQID 5 +#define ZONE_ATTR_POOLID 6 +#define ZONE_ATTR_INITPID 7 +#define ZONE_ATTR_SLBL 8 +#define ZONE_ATTR_INITNAME 9 +#define ZONE_ATTR_BOOTARGS 10 +#define ZONE_ATTR_BRAND 11 +/* #define ZONE_ATTR_PHYS_MCAP 12 */ +#define ZONE_ATTR_SCHED_CLASS 13 +#define ZONE_ATTR_FLAGS 14 +#define ZONE_ATTR_HOSTID 15 +#define ZONE_ATTR_FS_ALLOWED 16 +#define ZONE_ATTR_NETWORK 17 + +/* illumos extensions */ +#define ZONE_ATTR_INITNORESTART 20 +#define ZONE_ATTR_SECFLAGS 21 +#define ZONE_ATTR_INITRESTART0 22 +#define ZONE_ATTR_INITREBOOT 23 + +/* OmniOS/SmartOS extensions */ +#define ZONE_ATTR_DID 30 +#define ZONE_ATTR_APP_SVC_CT 31 +#define ZONE_ATTR_SCHED_FIXEDHI 32 + +/* Start of the brand-specific attribute namespace */ +#define ZONE_ATTR_BRAND_ATTRS 32768 + +#define ZONE_FS_ALLOWED_MAX 1024 + +#define ZONE_EVENT_CHANNEL "com.sun:zones:status" +#define ZONE_EVENT_STATUS_CLASS "status" +#define ZONE_EVENT_STATUS_SUBCLASS "change" + +#define ZONE_EVENT_UNINITIALIZED "uninitialized" +#define ZONE_EVENT_INITIALIZED "initialized" +#define ZONE_EVENT_READY "ready" +#define ZONE_EVENT_RUNNING "running" +#define ZONE_EVENT_SHUTTING_DOWN "shutting_down" + +#define ZONE_CB_NAME "zonename" +#define ZONE_CB_NEWSTATE "newstate" +#define ZONE_CB_OLDSTATE "oldstate" +#define ZONE_CB_TIMESTAMP "when" +#define ZONE_CB_ZONEID "zoneid" + +/* + * Exit values that may be returned by scripts or programs invoked by various + * zone commands. + * + * These are defined as: + * + * ZONE_SUBPROC_OK + * =============== + * The subprocess completed successfully. + * + * ZONE_SUBPROC_USAGE + * ================== + * The subprocess failed with a usage message, or a usage message should + * be output in its behalf. + * + * ZONE_SUBPROC_NOTCOMPLETE + * ======================== + * The subprocess did not complete, but the actions performed by the + * subprocess require no recovery actions by the user. + * + * For example, if the subprocess were called by "zoneadm install," the + * installation of the zone did not succeed but the user need not perform + * a "zoneadm uninstall" before attempting another install. + * + * ZONE_SUBPROC_FATAL + * ================== + * The subprocess failed in a fatal manner, usually one that will require + * some type of recovery action by the user. + * + * For example, if the subprocess were called by "zoneadm install," the + * installation of the zone did not succeed and the user will need to + * perform a "zoneadm uninstall" before another install attempt is + * possible. + * + * The non-success exit values are large to avoid accidental collision + * with values used internally by some commands (e.g. "Z_ERR" and + * "Z_USAGE" as used by zoneadm.) + */ +#define ZONE_SUBPROC_OK 0 +#define ZONE_SUBPROC_USAGE 253 +#define ZONE_SUBPROC_NOTCOMPLETE 254 +#define ZONE_SUBPROC_FATAL 255 + +#ifdef _SYSCALL32 +typedef struct { + caddr32_t zone_name; + caddr32_t zone_root; + caddr32_t zone_privs; + size32_t zone_privssz; + caddr32_t rctlbuf; + size32_t rctlbufsz; + caddr32_t extended_error; + caddr32_t zfsbuf; + size32_t zfsbufsz; + int match; /* match level */ + uint32_t doi; /* DOI for label */ + caddr32_t label; /* label associated with zone */ + int flags; + zoneid_t zoneid; /* requested zoneid */ +} zone_def32; +#endif +typedef struct { + const char *zone_name; + const char *zone_root; + const struct priv_set *zone_privs; + size_t zone_privssz; + const char *rctlbuf; + size_t rctlbufsz; + int *extended_error; + const char *zfsbuf; + size_t zfsbufsz; + int match; /* match level */ + uint32_t doi; /* DOI for label */ + const bslabel_t *label; /* label associated with zone */ + int flags; + zoneid_t zoneid; /* requested zoneid */ +} zone_def; + +/* extended error information */ +#define ZE_UNKNOWN 0 /* No extended error info */ +#define ZE_CHROOTED 1 /* tried to zone_create from chroot */ +#define ZE_AREMOUNTS 2 /* there are mounts within the zone */ +#define ZE_LABELINUSE 3 /* label is already in use by some other zone */ + +/* + * zone_status values + * + * You must modify zone_status_names in mdb(1)'s genunix module + * (genunix/zone.c) when you modify this enum. + */ +typedef enum { + ZONE_IS_UNINITIALIZED = 0, + ZONE_IS_INITIALIZED, + ZONE_IS_READY, + ZONE_IS_BOOTING, + ZONE_IS_RUNNING, + ZONE_IS_SHUTTING_DOWN, + ZONE_IS_EMPTY, + ZONE_IS_DOWN, + ZONE_IS_DYING, + ZONE_IS_DEAD +} zone_status_t; +#define ZONE_MIN_STATE ZONE_IS_UNINITIALIZED +#define ZONE_MAX_STATE ZONE_IS_DEAD + +/* + * Valid commands which may be issued by zoneadm to zoneadmd. The kernel also + * communicates with zoneadmd, but only uses Z_REBOOT and Z_HALT. + */ +typedef enum zone_cmd { + Z_READY, Z_BOOT, Z_FORCEBOOT, Z_REBOOT, Z_HALT, Z_NOTE_UNINSTALLING, + Z_MOUNT, Z_FORCEMOUNT, Z_UNMOUNT, Z_SHUTDOWN +} zone_cmd_t; + +/* + * The structure of a request to zoneadmd. + */ +typedef struct zone_cmd_arg { + uint64_t uniqid; /* unique "generation number" */ + zone_cmd_t cmd; /* requested action */ + int status; /* init status on shutdown */ + uint32_t debug; /* enable brand hook debug */ + char locale[MAXPATHLEN]; /* locale in which to render messages */ + char bootbuf[BOOTARGS_MAX]; /* arguments passed to zone_boot() */ + /* Needed for 32/64 zoneadm -> zoneadmd door arg size check. */ + int pad; +} zone_cmd_arg_t; + +/* + * Structure of zoneadmd's response to a request. A NULL return value means + * the caller should attempt to restart zoneadmd and retry. + */ +typedef struct zone_cmd_rval { + int rval; /* return value of request */ + char errbuf[1]; /* variable-sized buffer containing error messages */ +} zone_cmd_rval_t; + +/* + * The zone support infrastructure uses the zone name as a component + * of unix domain (AF_UNIX) sockets, which are limited to 108 characters + * in length, so ZONENAME_MAX is limited by that. + */ +#define ZONENAME_MAX 64 + +#define GLOBAL_ZONENAME "global" + +/* + * Extended Regular expression (see regex(7)) which matches all valid zone + * names. + */ +#define ZONENAME_REGEXP "[a-zA-Z0-9][-_.a-zA-Z0-9]{0,62}" + +/* + * Where the zones support infrastructure places temporary files. + */ +#define ZONES_TMPDIR "/var/run/zones" + +/* + * The path to the door used by clients to communicate with zoneadmd. + */ +#define ZONE_DOOR_PATH ZONES_TMPDIR "/%s.zoneadmd_door" + + +/* zone_flags */ +/* + * Threads that read or write the following flag must hold zone_lock. + */ +#define ZF_REFCOUNTS_LOGGED 0x1 /* a thread logged the zone's refs */ + +/* + * The following threads are set when the zone is created and never changed. + * Threads that test for these flags don't have to hold zone_lock. + */ +#define ZF_HASHED_LABEL 0x2 /* zone has a unique label */ +#define ZF_IS_SCRATCH 0x4 /* scratch zone */ +#define ZF_NET_EXCL 0x8 /* Zone has an exclusive IP stack */ + + +/* zone_create flags */ +#define ZCF_NET_EXCL 0x1 /* Create a zone with exclusive IP */ + +/* zone network properties */ +#define ZONE_NETWORK_ADDRESS 1 +#define ZONE_NETWORK_DEFROUTER 2 + +#define ZONE_NET_ADDRNAME "address" +#define ZONE_NET_RTRNAME "route" + +typedef struct zone_net_data { + int zn_type; + int zn_len; + datalink_id_t zn_linkid; + uint8_t zn_val[1]; +} zone_net_data_t; + + +#ifdef _KERNEL + +#define GLOBAL_ZONEUNIQID 0 /* uniqid of the global zone */ + +/* + * Indexes into ->zone_ustate array, summing the micro state of all threads in a + * particular zone. + */ +#define ZONE_USTATE_STIME (0) +#define ZONE_USTATE_UTIME (1) +#define ZONE_USTATE_WTIME (2) +#define ZONE_USTATE_MAX (3) + +struct pool; +struct brand; + +/* + * Each of these constants identifies a kernel subsystem that acquires and + * releases zone references. Each subsystem that invokes + * zone_hold_ref() and zone_rele_ref() should specify the + * zone_ref_subsys_t constant associated with the subsystem. Tracked holds + * help users and developers quickly identify subsystems that stall zone + * shutdowns indefinitely. + * + * NOTE: You must modify zone_ref_subsys_names in usr/src/uts/common/os/zone.c + * when you modify this enumeration. + */ +typedef enum zone_ref_subsys { + ZONE_REF_NFS, /* NFS */ + ZONE_REF_NFSV4, /* NFSv4 */ + ZONE_REF_SMBFS, /* SMBFS */ + ZONE_REF_MNTFS, /* MNTFS */ + ZONE_REF_LOFI, /* LOFI devices */ + ZONE_REF_VFS, /* VFS infrastructure */ + ZONE_REF_IPC, /* IPC infrastructure */ + ZONE_REF_NUM_SUBSYS /* This must be the last entry. */ +} zone_ref_subsys_t; + +/* + * zone_ref represents a general-purpose references to a zone. Each zone's + * references are linked into the zone's zone_t::zone_ref_list. This allows + * debuggers to walk zones' references. + */ +typedef struct zone_ref { + struct zone *zref_zone; /* the zone to which the reference refers */ + list_node_t zref_linkage; /* linkage for zone_t::zone_ref_list */ +} zone_ref_t; + +/* + * Structure to record list of ZFS datasets exported to a zone. + */ +typedef struct zone_dataset { + char *zd_dataset; + list_node_t zd_linkage; +} zone_dataset_t; + +/* + * structure for zone kstats + */ +typedef struct zone_kstat { + kstat_named_t zk_zonename; + kstat_named_t zk_usage; + kstat_named_t zk_value; +} zone_kstat_t; + +struct cpucap; + +typedef struct { + hrtime_t cycle_start; + uint_t cycle_cnt; + hrtime_t zone_avg_cnt; +} sys_zio_cntr_t; + +typedef struct { + kstat_named_t zv_zonename; + kstat_named_t zv_nread; + kstat_named_t zv_reads; + kstat_named_t zv_rtime; + kstat_named_t zv_rlentime; + kstat_named_t zv_rcnt; + kstat_named_t zv_nwritten; + kstat_named_t zv_writes; + kstat_named_t zv_wtime; + kstat_named_t zv_wlentime; + kstat_named_t zv_wcnt; + kstat_named_t zv_10ms_ops; + kstat_named_t zv_100ms_ops; + kstat_named_t zv_1s_ops; + kstat_named_t zv_10s_ops; + kstat_named_t zv_delay_cnt; + kstat_named_t zv_delay_time; +} zone_vfs_kstat_t; + +typedef struct { + kstat_named_t zz_zonename; + kstat_named_t zz_nread; + kstat_named_t zz_reads; + kstat_named_t zz_rtime; + kstat_named_t zz_rlentime; + kstat_named_t zz_nwritten; + kstat_named_t zz_writes; + kstat_named_t zz_waittime; +} zone_zfs_kstat_t; + +typedef struct { + kstat_named_t zm_zonename; + kstat_named_t zm_rss; + kstat_named_t zm_phys_cap; + kstat_named_t zm_swap; + kstat_named_t zm_swap_cap; + kstat_named_t zm_nover; + kstat_named_t zm_pagedout; + kstat_named_t zm_pgpgin; + kstat_named_t zm_anonpgin; + kstat_named_t zm_execpgin; + kstat_named_t zm_fspgin; + kstat_named_t zm_anon_alloc_fail; + kstat_named_t zm_pf_throttle; + kstat_named_t zm_pf_throttle_usec; +} zone_mcap_kstat_t; + +typedef struct { + kstat_named_t zm_zonename; /* full name, kstat truncates name */ + kstat_named_t zm_utime; + kstat_named_t zm_stime; + kstat_named_t zm_wtime; + kstat_named_t zm_avenrun1; + kstat_named_t zm_avenrun5; + kstat_named_t zm_avenrun15; + kstat_named_t zm_ffcap; + kstat_named_t zm_ffnoproc; + kstat_named_t zm_ffnomem; + kstat_named_t zm_ffmisc; + kstat_named_t zm_mfseglim; + kstat_named_t zm_nested_intp; + kstat_named_t zm_init_pid; + kstat_named_t zm_boot_time; +} zone_misc_kstat_t; + +typedef struct zone { + /* + * zone_name is never modified once set. + */ + char *zone_name; /* zone's configuration name */ + /* + * zone_nodename and zone_domain are never freed once allocated. + */ + char *zone_nodename; /* utsname.nodename equivalent */ + char *zone_domain; /* srpc_domain equivalent */ + /* + * zone_hostid is used for per-zone hostid emulation. + * Currently it isn't modified after it's set (so no locks protect + * accesses), but that might have to change when we allow + * administrators to change running zones' properties. + * + * The global zone's zone_hostid must always be HW_INVALID_HOSTID so + * that zone_get_hostid() will function correctly. + */ + uint32_t zone_hostid; /* zone's hostid, HW_INVALID_HOSTID */ + /* if not emulated */ + /* + * zone_lock protects the following fields of a zone_t: + * zone_ref + * zone_cred_ref + * zone_subsys_ref + * zone_ref_list + * zone_ntasks + * zone_flags + * zone_zsd + * zone_pfexecd + */ + kmutex_t zone_lock; + /* + * zone_linkage is the zone's linkage into the active or + * death-row list. The field is protected by zonehash_lock. + */ + list_node_t zone_linkage; + zoneid_t zone_id; /* ID of zone */ + zoneid_t zone_did; /* persistent debug ID of zone */ + uint_t zone_ref; /* count of zone_hold()s on zone */ + uint_t zone_cred_ref; /* count of zone_hold_cred()s on zone */ + /* + * Fixed-sized array of subsystem-specific reference counts + * The sum of all of the counts must be less than or equal to zone_ref. + * The array is indexed by the counts' subsystems' zone_ref_subsys_t + * constants. + */ + uint_t zone_subsys_ref[ZONE_REF_NUM_SUBSYS]; + list_t zone_ref_list; /* list of zone_ref_t structs */ + /* + * zone_rootvp and zone_rootpath can never be modified once set. + */ + struct vnode *zone_rootvp; /* zone's root vnode */ + char *zone_rootpath; /* Path to zone's root + '/' */ + ushort_t zone_flags; /* misc flags */ + zone_status_t zone_status; /* protected by zone_status_lock */ + uint_t zone_ntasks; /* number of tasks executing in zone */ + kmutex_t zone_nlwps_lock; /* protects zone_nlwps, and *_nlwps */ + /* counters in projects and tasks */ + /* that are within the zone */ + rctl_qty_t zone_nlwps; /* number of lwps in zone */ + rctl_qty_t zone_nlwps_ctl; /* protected by zone_rctls->rcs_lock */ + rctl_qty_t zone_shmmax; /* System V shared memory usage */ + ipc_rqty_t zone_ipc; /* System V IPC id resource usage */ + + uint_t zone_rootpathlen; /* strlen(zone_rootpath) + 1 */ + uint32_t zone_shares; /* FSS shares allocated to zone */ + rctl_set_t *zone_rctls; /* zone-wide (zone.*) rctls */ + kmutex_t zone_mem_lock; /* protects zone_locked_mem and */ + /* kpd_locked_mem for all */ + /* projects in zone. */ + /* Also protects zone_max_swap */ + /* grab after p_lock, before rcs_lock */ + rctl_qty_t zone_locked_mem; /* bytes of locked memory in */ + /* zone */ + rctl_qty_t zone_locked_mem_ctl; /* Current locked memory */ + /* limit. Protected by */ + /* zone_rctls->rcs_lock */ + rctl_qty_t zone_max_swap; /* bytes of swap reserved by zone */ + rctl_qty_t zone_max_swap_ctl; /* current swap limit. */ + /* Protected by */ + /* zone_rctls->rcs_lock */ + kmutex_t zone_rctl_lock; /* protects zone_max_lofi */ + rctl_qty_t zone_max_lofi; /* lofi devs for zone */ + rctl_qty_t zone_max_lofi_ctl; /* current lofi limit. */ + /* Protected by */ + /* zone_rctls->rcs_lock */ + list_t zone_zsd; /* list of Zone-Specific Data values */ + kcondvar_t zone_cv; /* used to signal state changes */ + struct proc *zone_zsched; /* Dummy kernel "zsched" process */ + pid_t zone_proc_initpid; /* pid of "init" for this zone */ + char *zone_initname; /* fs path to 'init' */ + int zone_init_status; /* init's exit status */ + int zone_boot_err; /* for zone_boot() if boot fails */ + char *zone_bootargs; /* arguments passed via zone_boot() */ + /* + * zone_kthreads is protected by zone_status_lock. + */ + kthread_t *zone_kthreads; /* kernel threads in zone */ + struct priv_set *zone_privset; /* limit set for zone */ + /* + * zone_vfslist is protected by vfs_list_lock(). + */ + struct vfs *zone_vfslist; /* list of FS's mounted in zone */ + uint64_t zone_uniqid; /* unique zone generation number */ + struct cred *zone_kcred; /* kcred-like, zone-limited cred */ + /* + * zone_pool is protected by pool_lock(). + */ + struct pool *zone_pool; /* pool the zone is bound to */ + hrtime_t zone_pool_mod; /* last pool bind modification time */ + /* zone_psetid is protected by cpu_lock */ + psetid_t zone_psetid; /* pset the zone is bound to */ + + time_t zone_boot_time; /* Similar to boot_time */ + + /* + * The following two can be read without holding any locks. They are + * updated under cpu_lock. + */ + int zone_ncpus; /* zone's idea of ncpus */ + int zone_ncpus_online; /* zone's idea of ncpus_online */ + /* + * List of ZFS datasets exported to this zone. + */ + list_t zone_datasets; /* list of datasets */ + + ts_label_t *zone_slabel; /* zone sensitivity label */ + int zone_match; /* require label match for packets */ + tsol_mlp_list_t zone_mlps; /* MLPs on zone-private addresses */ + + boolean_t zone_restart_init; /* Restart init if it dies? */ + boolean_t zone_reboot_on_init_exit; /* Reboot if init dies? */ + boolean_t zone_restart_init_0; /* Restart only if it exits 0 */ + boolean_t zone_setup_app_contract; /* set up contract? */ + struct brand *zone_brand; /* zone's brand */ + void *zone_brand_data; /* store brand specific data */ + id_t zone_defaultcid; /* dflt scheduling class id */ + boolean_t zone_fixed_hipri; /* fixed sched. hi prio */ + kstat_t *zone_swapresv_kstat; + kstat_t *zone_lockedmem_kstat; + /* + * zone_dl_list is protected by zone_lock + */ + list_t zone_dl_list; + netstack_t *zone_netstack; + struct cpucap *zone_cpucap; /* CPU caps data */ + + /* + * kstats and counters for VFS ops and bytes. + */ + kmutex_t zone_vfs_lock; /* protects VFS statistics */ + kstat_t *zone_vfs_ksp; + kstat_io_t zone_vfs_rwstats; + zone_vfs_kstat_t *zone_vfs_stats; + + /* + * kstats for ZFS I/O ops and bytes. + */ + kmutex_t zone_zfs_lock; /* protects ZFS statistics */ + kstat_t *zone_zfs_ksp; + zone_zfs_kstat_t *zone_zfs_stats; + + /* + * illumos Auditing per-zone audit context + */ + struct au_kcontext *zone_audit_kctxt; + /* + * For private use by mntfs. + */ + struct mntelem *zone_mntfs_db; + krwlock_t zone_mntfs_db_lock; + + struct klpd_reg *zone_pfexecd; + + char *zone_fs_allowed; + rctl_qty_t zone_nprocs; /* number of processes in the zone */ + rctl_qty_t zone_nprocs_ctl; /* current limit protected by */ + /* zone_rctls->rcs_lock */ + kstat_t *zone_nprocs_kstat; + + /* + * kstats and counters for physical memory capping. + */ + kstat_t *zone_physmem_kstat; + kmutex_t zone_mcap_lock; /* protects mcap statistics */ + kstat_t *zone_mcap_ksp; + zone_mcap_kstat_t *zone_mcap_stats; + uint64_t zone_pgpgin; /* pages paged in */ + uint64_t zone_anonpgin; /* anon pages paged in */ + uint64_t zone_execpgin; /* exec pages paged in */ + uint64_t zone_fspgin; /* fs pages paged in */ + uint64_t zone_anon_alloc_fail; /* cnt of anon alloc fails */ + + psecflags_t zone_secflags; /* default zone security-flags */ + + /* + * Misc. kstats and counters for zone cpu-usage aggregation. + */ + kmutex_t zone_misc_lock; /* protects misc statistics */ + kstat_t *zone_misc_ksp; + zone_misc_kstat_t *zone_misc_stats; + /* Accumulated microstate for all threads in this zone. */ + cpu_uarray_t *zone_ustate; + /* fork-fail kstat tracking */ + uint32_t zone_ffcap; /* hit an rctl cap */ + uint32_t zone_ffnoproc; /* get proc/lwp error */ + uint32_t zone_ffnomem; /* as_dup/memory error */ + uint32_t zone_ffmisc; /* misc. other error */ + + uint32_t zone_mfseglim; /* map failure (# segs limit) */ + + uint32_t zone_nested_intp; /* nested interp. kstat */ + + struct loadavg_s zone_loadavg; /* loadavg for this zone */ + uint64_t zone_hp_avenrun[3]; /* high-precision avenrun */ + int zone_avenrun[3]; /* FSCALED avg. run queue len */ + + /* + * FSS stats updated once per second by fss_decay_usage. + */ + uint32_t zone_fss_gen; /* FSS generation cntr */ + uint64_t zone_run_ticks; /* tot # of ticks running */ + + /* + * DTrace-private per-zone state + */ + int zone_dtrace_getf; /* # of unprivileged getf()s */ + + /* + * Synchronization primitives used to synchronize between mounts and + * zone creation/destruction. + */ + int zone_mounts_in_progress; + kcondvar_t zone_mount_cv; + kmutex_t zone_mount_lock; +} zone_t; + +/* + * Data and counters used for ZFS fair-share disk IO. + */ +typedef struct zone_zfs_io { + uint16_t zpers_zfs_io_pri; /* ZFS IO priority - 16k max */ + uint_t zpers_zfs_queued[2]; /* sync I/O enqueued count */ + sys_zio_cntr_t zpers_rd_ops; /* Counters for ZFS reads, */ + sys_zio_cntr_t zpers_wr_ops; /* writes, and */ + sys_zio_cntr_t zpers_lwr_ops; /* logical writes. */ + kstat_io_t zpers_zfs_rwstats; + uint64_t zpers_io_util; /* IO utilization metric */ + uint64_t zpers_zfs_rd_waittime; + uint8_t zpers_io_delay; /* IO delay on logical r/w */ + uint8_t zpers_zfs_weight; /* used to prevent starvation */ + uint8_t zpers_io_util_above_avg; /* IO util percent > avg. */ +} zone_zfs_io_t; + +/* + * "Persistent" zone data which can be accessed idependently of the zone_t. + */ +typedef struct zone_persist { + kmutex_t zpers_zfs_lock; /* Protects zpers_zfsp references */ + zone_zfs_io_t *zpers_zfsp; /* ZFS fair-share IO data */ + uint8_t zpers_over; /* currently over cap */ + uint32_t zpers_pg_cnt; /* current RSS in pages */ + uint32_t zpers_pg_limit; /* current RRS limit in pages */ + uint32_t zpers_nover; /* # of times over phys. cap */ +#ifndef DEBUG + uint64_t zpers_pg_out; /* # pages flushed */ +#else + /* + * To conserve memory, some detailed kstats are only kept for DEBUG + * builds. + */ + uint64_t zpers_zfs_rd_waittime; + + uint64_t zpers_pg_anon; /* # clean anon pages flushed */ + uint64_t zpers_pg_anondirty; /* # dirty anon pages flushed */ + uint64_t zpers_pg_fs; /* # clean fs pages flushed */ + uint64_t zpers_pg_fsdirty; /* # dirty fs pages flushed */ +#endif +} zone_persist_t; + +typedef enum zone_pageout_op { + ZPO_DIRTY, ZPO_FS, ZPO_ANON, ZPO_ANONDIRTY +} zone_pageout_op_t; + +/* + * Special value of zone_psetid to indicate that pools are disabled. + */ +#define ZONE_PS_INVAL PS_MYID + +extern zone_t zone0; +extern zone_t *global_zone; +extern uint_t maxzones; +extern rctl_hndl_t rc_zone_nlwps; +extern rctl_hndl_t rc_zone_nprocs; + +extern long zone(int, void *, void *, void *, void *); +extern void zone_zsd_init(void); +extern void zone_init(void); +extern void zone_hold(zone_t *); +extern void zone_rele(zone_t *); +extern void zone_init_ref(zone_ref_t *); +extern void zone_hold_ref(zone_t *, zone_ref_t *, zone_ref_subsys_t); +extern void zone_rele_ref(zone_ref_t *, zone_ref_subsys_t); +extern void zone_cred_hold(zone_t *); +extern void zone_cred_rele(zone_t *); +extern void zone_task_hold(zone_t *); +extern void zone_task_rele(zone_t *); +extern zone_t *zone_find_by_id(zoneid_t); +extern zone_t *zone_find_by_label(const ts_label_t *); +extern zone_t *zone_find_by_name(char *); +extern zone_t *zone_find_by_any_path(const char *, boolean_t); +extern zone_t *zone_find_by_path(const char *); +extern zoneid_t getzoneid(void); +extern zone_t *zone_find_by_id_nolock(zoneid_t); +extern int zone_datalink_walk(zoneid_t, int (*)(datalink_id_t, void *), void *); +extern int zone_check_datalink(zoneid_t *, datalink_id_t); +extern void zone_loadavg_update(); + +/* + * Zone-specific data (ZSD) APIs + */ +/* + * The following is what code should be initializing its zone_key_t to if it + * calls zone_getspecific() without necessarily knowing that zone_key_create() + * has been called on the key. + */ +#define ZONE_KEY_UNINITIALIZED 0 + +typedef uint_t zone_key_t; + +extern void zone_key_create(zone_key_t *, void *(*)(zoneid_t), + void (*)(zoneid_t, void *), void (*)(zoneid_t, void *)); +extern int zone_key_delete(zone_key_t); +extern void *zone_getspecific(zone_key_t, zone_t *); +extern int zone_setspecific(zone_key_t, zone_t *, const void *); + +/* + * The definition of a zsd_entry is truly private to zone.c and is only + * placed here so it can be shared with mdb. + * + * State maintained for each zone times each registered key, which tracks + * the state of the create, shutdown and destroy callbacks. + * + * zsd_flags is used to keep track of pending actions to avoid holding locks + * when calling the create/shutdown/destroy callbacks, since doing so + * could lead to deadlocks. + */ +struct zsd_entry { + zone_key_t zsd_key; /* Key used to lookup value */ + void *zsd_data; /* Caller-managed value */ + /* + * Callbacks to be executed when a zone is created, shutdown, and + * destroyed, respectively. + */ + void *(*zsd_create)(zoneid_t); + void (*zsd_shutdown)(zoneid_t, void *); + void (*zsd_destroy)(zoneid_t, void *); + list_node_t zsd_linkage; + uint16_t zsd_flags; /* See below */ + kcondvar_t zsd_cv; +}; + +/* + * zsd_flags + */ +#define ZSD_CREATE_NEEDED 0x0001 +#define ZSD_CREATE_INPROGRESS 0x0002 +#define ZSD_CREATE_COMPLETED 0x0004 +#define ZSD_SHUTDOWN_NEEDED 0x0010 +#define ZSD_SHUTDOWN_INPROGRESS 0x0020 +#define ZSD_SHUTDOWN_COMPLETED 0x0040 +#define ZSD_DESTROY_NEEDED 0x0100 +#define ZSD_DESTROY_INPROGRESS 0x0200 +#define ZSD_DESTROY_COMPLETED 0x0400 + +#define ZSD_CREATE_ALL \ + (ZSD_CREATE_NEEDED|ZSD_CREATE_INPROGRESS|ZSD_CREATE_COMPLETED) +#define ZSD_SHUTDOWN_ALL \ + (ZSD_SHUTDOWN_NEEDED|ZSD_SHUTDOWN_INPROGRESS|ZSD_SHUTDOWN_COMPLETED) +#define ZSD_DESTROY_ALL \ + (ZSD_DESTROY_NEEDED|ZSD_DESTROY_INPROGRESS|ZSD_DESTROY_COMPLETED) + +#define ZSD_ALL_INPROGRESS \ + (ZSD_CREATE_INPROGRESS|ZSD_SHUTDOWN_INPROGRESS|ZSD_DESTROY_INPROGRESS) + +/* + * Macros to help with zone visibility restrictions. + */ + +/* + * Is process in the global zone? + */ +#define INGLOBALZONE(p) \ + ((p)->p_zone == global_zone) + +/* + * Can process view objects in given zone? + */ +#define HASZONEACCESS(p, zoneid) \ + ((p)->p_zone->zone_id == (zoneid) || INGLOBALZONE(p)) + +/* + * Convenience macro to see if a resolved path is visible from within a + * given zone. + * + * The basic idea is that the first (zone_rootpathlen - 1) bytes of the + * two strings must be equal. Since the rootpathlen has a trailing '/', + * we want to skip everything in the path up to (but not including) the + * trailing '/'. + */ +#define ZONE_PATH_VISIBLE(path, zone) \ + (strncmp((path), (zone)->zone_rootpath, \ + (zone)->zone_rootpathlen - 1) == 0) + +/* + * Convenience macro to go from the global view of a path to that seen + * from within said zone. It is the responsibility of the caller to + * ensure that the path is a resolved one (ie, no '..'s or '.'s), and is + * in fact visible from within the zone. + */ +#define ZONE_PATH_TRANSLATE(path, zone) \ + (ASSERT(ZONE_PATH_VISIBLE(path, zone)), \ + (path) + (zone)->zone_rootpathlen - 2) + +/* + * Special processes visible in all zones. + */ +#define ZONE_SPECIALPID(x) ((x) == 0 || (x) == 1) + +/* + * A root vnode of the current zone. + * + * NOTE: It may be necessary (initialization time for file sharing where an + * NGZ loads a file-sharing kernel module that does zsd initialization) to NOT + * use this macro. One should ASSERT() that curzone == active ZSD (an + * ASSERTion that's not always true at ZSD initialization time) during regular + * use of this macro. + */ +#define ZONE_ROOTVP() (curzone->zone_rootvp) + +/* + * Since a zone's root isn't necessarily an actual filesystem boundary + * (i.e. VROOT may not be set on zone->zone_rootvp) we need to not assume it. + * This macro helps in checking if a vnode is the current zone's rootvp. + * NOTE: Using the VN_ prefix, even though it's defined here in zone.h. + * NOTE2: See above warning about ZONE_ROOTVP(). + */ +#define VN_IS_CURZONEROOT(vp) (VN_CMP(vp, ZONE_ROOTVP())) + +/* + * Zone-safe version of thread_create() to be used when the caller wants to + * create a kernel thread to run within the current zone's context. + */ +extern kthread_t *zthread_create(caddr_t, size_t, void (*)(), void *, size_t, + pri_t); +extern void zthread_exit(void); + +/* + * Functions for an external observer to register interest in a zone's status + * change. Observers will be woken up when the zone status equals the status + * argument passed in (in the case of zone_status_timedwait, the function may + * also return because of a timeout; zone_status_wait_sig may return early due + * to a signal being delivered; zone_status_timedwait_sig may return for any of + * the above reasons). + * + * Otherwise these behave identically to cv_timedwait(), cv_wait(), and + * cv_wait_sig() respectively. + */ +extern clock_t zone_status_timedwait(zone_t *, clock_t, zone_status_t); +extern clock_t zone_status_timedwait_sig(zone_t *, clock_t, zone_status_t); +extern void zone_status_wait(zone_t *, zone_status_t); +extern int zone_status_wait_sig(zone_t *, zone_status_t); + +/* + * Get the status of the zone (at the time it was called). The state may + * have progressed by the time it is returned. + */ +extern zone_status_t zone_status_get(zone_t *); + +/* + * Safely get the hostid of the specified zone (defaults to machine's hostid + * if the specified zone doesn't emulate a hostid). Passing NULL retrieves + * the global zone's (i.e., physical system's) hostid. + */ +extern uint32_t zone_get_hostid(zone_t *); + +/* + * Get the "kcred" credentials corresponding to the given zone. + */ +extern struct cred *zone_get_kcred(zoneid_t); + +/* + * Get/set the pool the zone is currently bound to. + */ +extern struct pool *zone_pool_get(zone_t *); +extern void zone_pool_set(zone_t *, struct pool *); + +/* + * Get/set the pset the zone is currently using. + */ +extern psetid_t zone_pset_get(zone_t *); +extern void zone_pset_set(zone_t *, psetid_t); + +/* + * Get the number of cpus/online-cpus visible from the given zone. + */ +extern int zone_ncpus_get(zone_t *); +extern int zone_ncpus_online_get(zone_t *); + +/* + * Returns true if the named pool/dataset is visible in the current zone. + */ +extern int zone_dataset_visible(const char *, int *); +extern int zone_dataset_visible_inzone(zone_t *, const char *, int *); + +/* + * zone version of kadmin() + */ +extern int zone_kadmin(int, int, const char *, cred_t *); +extern void zone_shutdown_global(void); + +extern void mount_in_progress(zone_t *); +extern void mount_completed(zone_t *); + +extern int zone_walk(int (*)(zone_t *, void *), void *); + +struct page; +extern void zone_add_page(struct page *); +extern void zone_rm_page(struct page *); +extern void zone_pageout_stat(int, zone_pageout_op_t); +extern void zone_get_physmem_data(int, pgcnt_t *, pgcnt_t *); + +/* Interfaces for page scanning */ +extern uint_t zone_num_over_cap; +extern zone_persist_t zone_pdata[MAX_ZONES]; + +extern rctl_hndl_t rc_zone_locked_mem; +extern rctl_hndl_t rc_zone_max_swap; +extern rctl_hndl_t rc_zone_phys_mem; +extern rctl_hndl_t rc_zone_max_lofi; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ZONE_H */ diff --git a/illumos-x86_64/usr/include/sysexits.h b/illumos-x86_64/usr/include/sysexits.h new file mode 100644 index 00000000..546c3218 --- /dev/null +++ b/illumos-x86_64/usr/include/sysexits.h @@ -0,0 +1,128 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1989 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _SYSEXITS_H +#define _SYSEXITS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SYSEXITS.H -- Exit status codes employed by the mail subsystem. + * + * This include file attempts to categorize possible error + * exit statuses for mail subsystem. + * + * Error numbers begin at EX__BASE to reduce the possibility of + * clashing with other exit statuses that random programs may + * already return. The meaning of the codes is approximately + * as follows: + * + * EX_USAGE -- The command was used incorrectly, e.g., with + * the wrong number of arguments, a bad flag, a bad + * syntax in a parameter, or whatever. + * EX_DATAERR -- The input data was incorrect in some way. + * This should only be used for user's data & not + * system files. + * EX_NOINPUT -- An input file (not a system file) did not + * exist or was not readable. This could also include + * errors like "No message" to a mailer (if it cared + * to catch it). + * EX_NOUSER -- The user specified did not exist. This might + * be used for mail addresses or remote logins. + * EX_NOHOST -- The host specified did not exist. This is used + * in mail addresses or network requests. + * EX_UNAVAILABLE -- A service is unavailable. This can occur + * if a support program or file does not exist. This + * can also be used as a catchall message when something + * you wanted to do doesn't work, but you don't know + * why. + * EX_SOFTWARE -- An internal software error has been detected. + * This should be limited to non-operating system related + * errors as possible. + * EX_OSERR -- An operating system error has been detected. + * This is intended to be used for such things as "cannot + * fork", "cannot create pipe", or the like. It includes + * things like getuid returning a user that does not + * exist in the passwd file. + * EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, + * etc.) does not exist, cannot be opened, or has some + * sort of error (e.g., syntax error). + * EX_CANTCREAT -- A (user specified) output file cannot be + * created. + * EX_IOERR -- An error occurred while doing I/O on some file. + * EX_TEMPFAIL -- temporary failure, indicating something that + * is not really an error. In sendmail, this means + * that a mailer (e.g.) could not create a connection, + * and the request should be reattempted later. + * EX_PROTOCOL -- the remote system returned something that + * was "not possible" during a protocol exchange. + * EX_NOPERM -- You did not have sufficient permission to + * perform the operation. This is not intended for + * file system problems, which should use NOINPUT or + * CANTCREAT, but rather for higher level permissions. + * For example, kre uses this to restrict who students + * can send mail to. + */ + +#define EX_OK 0 /* successful termination */ + +#define EX__BASE 64 /* base value for error messages */ + +#define EX_USAGE 64 /* command line usage error */ +#define EX_DATAERR 65 /* data format error */ +#define EX_NOINPUT 66 /* cannot open input */ +#define EX_NOUSER 67 /* addressee unknown */ +#define EX_NOHOST 68 /* host name unknown */ +#define EX_UNAVAILABLE 69 /* service unavailable */ +#define EX_SOFTWARE 70 /* internal software error */ +#define EX_OSERR 71 /* system error (e.g., can't fork) */ +#define EX_OSFILE 72 /* critical OS file missing */ +#define EX_CANTCREAT 73 /* can't create (user) output file */ +#define EX_IOERR 74 /* input/output error */ +#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ +#define EX_PROTOCOL 76 /* remote error in protocol */ +#define EX_NOPERM 77 /* permission denied */ +#define EX_CONFIG 78 /* configuration error */ + +#define EX_NOTFOUND 79 /* entry not found */ +#define EX__MAX 79 /* maximum listed value */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSEXITS_H */ diff --git a/illumos-x86_64/usr/include/syslog.h b/illumos-x86_64/usr/include/syslog.h new file mode 100644 index 00000000..2a51a5a8 --- /dev/null +++ b/illumos-x86_64/usr/include/syslog.h @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _SYSLOG_H +#define _SYSLOG_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void openlog(const char *, int, int); +void syslog(int, const char *, ...); +void closelog(void); +int setlogmask(int); +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +void vsyslog(int, const char *, __va_list); +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSLOG_H */ diff --git a/illumos-x86_64/usr/include/tar.h b/illumos-x86_64/usr/include/tar.h new file mode 100644 index 00000000..cf4098f8 --- /dev/null +++ b/illumos-x86_64/usr/include/tar.h @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#ifndef _TAR_H +#define _TAR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define TMAGIC "ustar" +#define TMAGLEN 6 +#define TVERSION "00" +#define TVERSLEN 2 + +/* + * Typeflag field definitions. + */ + +#define REGTYPE '0' +#define AREGTYPE '\0' +#define LNKTYPE '1' +#define SYMTYPE '2' +#define CHRTYPE '3' +#define BLKTYPE '4' +#define DIRTYPE '5' +#define FIFOTYPE '6' +#define CONTTYPE '7' + +/* + * Mode fild bit definitions. + */ + +#define TSUID 04000 +#define TSGID 02000 +#define TSVTX 01000 +#define TUREAD 00400 +#define TUWRITE 00200 +#define TUEXEC 00100 +#define TGREAD 00040 +#define TGWRITE 00020 +#define TGEXEC 00010 +#define TOREAD 00004 +#define TOWRITE 00002 +#define TOEXEC 00001 + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +/* + * Types used in ancillary files + */ +#define ACL_HDR 'A' /* Access Control List */ +#define LBL_TYPE 'L' /* Trusted Extensions file label */ +#define DIR_TYPE 'D' /* Trusted Extensions directory label */ +/* + * Attribute types used in Trusted Solaris ancillary files + * that are interpreted for backward compatibility + */ +#define SLD_TYPE 'S' /* single-level directory component */ +#define PATH_TYPE 'P' /* Path component */ +#define MLD_TYPE 'M' /* multi-level directory component */ +#define FILE_TYPE 'F' /* Have to handle files differently */ +#define APRIV_TYPE 'P' /* allowed privileges data type in file */ +#define FPRIV_TYPE 'p' /* forced privileges data type in file */ +#define COMP_TYPE 'C' /* path components, use for MLD */ +#define ATTR_FLAG_TYPE 'F' /* file attribute flag bytes data type */ +#define LK_COMP_TYPE 'K' /* link data path component */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _TAR_H */ diff --git a/illumos-x86_64/usr/include/tcpd.h b/illumos-x86_64/usr/include/tcpd.h new file mode 100644 index 00000000..2cda9e01 --- /dev/null +++ b/illumos-x86_64/usr/include/tcpd.h @@ -0,0 +1,316 @@ +/* + * Copyright 2014 Sachidananda Urs + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * @(#) tcpd.h 1.5 96/03/19 16:22:24 + * + * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. + */ + +#ifndef _TCPD_H +#define _TCPD_H + +/* + * HAVE_IPV6 is traditionally configured at tcp_wrappers build time but for + * Solaris it must always be defined to keep the library interface binary + * compatible. + */ +#define HAVE_IPV6 + +/* Structure to describe one communications endpoint. */ + +#define STRING_LENGTH 128 /* hosts, users, processes */ + +#include +#include + +typedef struct sockaddr_gen { + union { + struct sockaddr _sg_sa; + struct sockaddr_in _sg_sin; +#ifdef HAVE_IPV6 + struct sockaddr_in6 _sg_sin6; +#endif + } sg_addr; +} sockaddr_gen; + +typedef union gen_addr { + struct in_addr ga_in; +#ifdef HAVE_IPV6 + struct in6_addr ga_in6; +#endif +} gen_addr; + +extern void sockgen_simplify(); + +#define sg_sa sg_addr._sg_sa +#define sg_sin sg_addr._sg_sin +#define sg_sin6 sg_addr._sg_sin6 +#define sg_family sg_sa.sa_family +#ifdef HAVE_IPV6 +#define SGADDRSZ(sag) ((sag)->sg_family == AF_INET6 ? \ + sizeof (struct in6_addr) : \ + sizeof (struct in_addr)) +#define SGSOCKADDRSZ(sag) ((sag)->sg_family == AF_INET6 ? \ + sizeof (struct sockaddr_in6) : \ + sizeof (struct sockaddr_in)) +#define SGPORT(sag) (*((sag)->sg_family == AF_INET6 ? \ + &(sag)->sg_sin6.sin6_port : \ + &(sag)->sg_sin.sin_port)) +#define SGADDRP(sag) (((sag)->sg_family == AF_INET6 ? \ + (char *)&(sag)->sg_sin6.sin6_addr : \ + (char *)&(sag)->sg_sin.sin_addr)) +#define SGFAM(sag) ((sag)->sg_family == AF_INET6 ? \ + AF_INET6 : AF_INET) + +#define SG_IS_UNSPECIFIED(sag) \ + ((sag)->sg_family == AF_INET6 ? \ + IN6_IS_ADDR_UNSPECIFIED(&(sag)->sg_sin6.sin6_addr) : \ + (sag)->sg_sin.sin_addr.s_addr == 0) + +#define VALID_ADDRTYPE(t) ((t) == AF_INET || (t) == AF_INET6) + +#ifndef IPV6_ABITS +#define IPV6_ABITS 128 /* Size of IPV6 address in bits */ +#endif + +#else /* HAVE_IPV6 */ + +#define SGADDRSZ(sag) sizeof (struct in_addr) +#define SGSOCKADDRSZ(sag) sizeof (struct sockaddr_in) +#define SGPORT(sag) ((sag)->sg_sin.sin_port) +#define SGADDRP(sag) ((char *)&(sag)->sg_sin.sin_addr) +#define SGFAM(sag) AF_INET +#define SG_IS_UNSPECIFIED(sag) ((sag)->sg_sin.sin_addr.s_addr == 0) + +#define VALID_ADDRTYPE(t) ((t) == AF_INET) + +#endif /* HAVE_IPV6 */ + +struct host_info { + char name[STRING_LENGTH]; /* access via eval_hostname(host) */ + char addr[STRING_LENGTH]; /* access via eval_hostaddr(host) */ + struct sockaddr_gen *sin; /* socket address or 0 */ + struct t_unitdata *unit; /* TLI transport address or 0 */ + struct request_info *request; /* for shared information */ +}; + +/* Structure to describe what we know about a service request. */ + +struct request_info { + int fd; /* socket handle */ + char user[STRING_LENGTH]; /* access via eval_user(request) */ + char daemon[STRING_LENGTH]; /* access via eval_daemon(request) */ + char pid[10]; /* access via eval_pid(request) */ + struct host_info client[1]; /* client endpoint info */ + struct host_info server[1]; /* server endpoint info */ + void (*sink) (); /* datagram sink function or 0 */ + void (*hostname) (); /* address to printable hostname */ + void (*hostaddr) (); /* address to printable address */ + void (*cleanup) (); /* cleanup function or 0 */ + struct netconfig *config; /* netdir handle */ +}; + +/* Common string operations. Less clutter should be more readable. */ + +#define STRN_CPY(d, s, l) { strncpy((d), (s), (l)); (d)[(l)-1] = 0; } + +#define STRN_EQ(x, y, l) (strncasecmp((x), (y), (l)) == 0) +#define STRN_NE(x, y, l) (strncasecmp((x), (y), (l)) != 0) +#define STR_EQ(x, y) (strcasecmp((x), (y)) == 0) +#define STR_NE(x, y) (strcasecmp((x), (y)) != 0) + +/* + * Initially, all above strings have the empty value. Information that + * cannot be determined at runtime is set to "unknown", so that we can + * distinguish between `unavailable' and `not yet looked up'. A hostname + * that we do not believe in is set to "paranoid". + */ + +#define STRING_UNKNOWN "unknown" /* lookup failed */ +#define STRING_PARANOID "paranoid" /* hostname conflict */ + +extern char unknown[]; +extern char paranoid[]; + +#define HOSTNAME_KNOWN(s) (STR_NE((s), unknown) && STR_NE((s), paranoid)) + +#ifdef HAVE_IPV6 +#define NOT_INADDR(s) (strchr(s, ':') == 0 && s[strspn(s, "0123456789./")] != 0) +#else +#define NOT_INADDR(s) (s[strspn(s, "0123456789./")] != 0) +#endif + +/* Global functions. */ + +#if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) +extern void fromhost(); /* get/validate client host info */ +#else +#define fromhost sock_host /* no TLI support needed */ +#endif + +extern int hosts_ctl(); /* wrapper around request_init() */ +extern int hosts_access(); /* access control */ +extern void shell_cmd(); /* execute shell command */ +extern char *percent_x(); /* do % expansion */ +extern void rfc931(); /* client name from RFC 931 daemon */ +extern void clean_exit(); /* clean up and exit */ +extern void refuse(); /* clean up and exit */ +extern char *xgets(); /* fgets() on steroids */ +extern char *split_at(); /* strchr() and split */ +extern unsigned long dot_quad_addr(); /* restricted inet_addr() */ +extern int numeric_addr(); /* IP4/IP6 inet_addr (restricted) */ +extern struct hostent *tcpd_gethostbyname(); + /* IP4/IP6 gethostbyname */ +#ifdef HAVE_IPV6 +extern char *skip_ipv6_addrs(); /* skip over colons in IPv6 addrs */ +#else +#define skip_ipv6_addrs(x) x +#endif + +/* Global variables. */ + +extern int allow_severity; /* for connection logging */ +extern int deny_severity; /* for connection logging */ +extern char *hosts_allow_table; /* for verification mode redirection */ +extern char *hosts_deny_table; /* for verification mode redirection */ +extern int hosts_access_verbose; /* for verbose matching mode */ +extern int rfc931_timeout; /* user lookup timeout */ +extern int resident; /* > 0 if resident process */ + +/* + * Routines for controlled initialization and update of request structure + * attributes. Each attribute has its own key. + */ + +#ifdef __STDC__ +extern struct request_info *request_init(struct request_info *, ...); +extern struct request_info *request_set(struct request_info *, ...); +#else +extern struct request_info *request_init(); /* initialize request */ +extern struct request_info *request_set(); /* update request structure */ +#endif + +#define RQ_FILE 1 /* file descriptor */ +#define RQ_DAEMON 2 /* server process (argv[0]) */ +#define RQ_USER 3 /* client user name */ +#define RQ_CLIENT_NAME 4 /* client host name */ +#define RQ_CLIENT_ADDR 5 /* client host address */ +#define RQ_CLIENT_SIN 6 /* client endpoint (internal) */ +#define RQ_SERVER_NAME 7 /* server host name */ +#define RQ_SERVER_ADDR 8 /* server host address */ +#define RQ_SERVER_SIN 9 /* server endpoint (internal) */ + +/* + * Routines for delayed evaluation of request attributes. Each attribute + * type has its own access method. The trivial ones are implemented by + * macros. The other ones are wrappers around the transport-specific host + * name, address, and client user lookup methods. The request_info and + * host_info structures serve as caches for the lookup results. + */ + +extern char *eval_user(); /* client user */ +extern char *eval_hostname(); /* printable hostname */ +extern char *eval_hostaddr(); /* printable host address */ +extern char *eval_hostinfo(); /* host name or address */ +extern char *eval_client(); /* whatever is available */ +extern char *eval_server(); /* whatever is available */ +#define eval_daemon(r) ((r)->daemon) /* daemon process name */ +#define eval_pid(r) ((r)->pid) /* process id */ + +/* Socket-specific methods, including DNS hostname lookups. */ + +extern void sock_host(); /* look up endpoint addresses */ +extern void sock_hostname(); /* translate address to hostname */ +extern void sock_hostaddr(); /* address to printable address */ +#define sock_methods(r) \ + { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; } + +/* The System V Transport-Level Interface (TLI) interface. */ + +#if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) +extern void tli_host(); /* look up endpoint addresses etc. */ +#endif + +/* + * Problem reporting interface. Additional file/line context is reported + * when available. The jump buffer (tcpd_buf) is not declared here, or + * everyone would have to include . + */ + +#ifdef __STDC__ +extern void tcpd_warn(char *, ...); /* report problem and proceed */ +extern void tcpd_jump(char *, ...); /* report problem and jump */ +#else +extern void tcpd_warn(); +extern void tcpd_jump(); +#endif + +struct tcpd_context { + char *file; /* current file */ + int line; /* current line */ +}; +extern struct tcpd_context tcpd_context; + +/* + * While processing access control rules, error conditions are handled by + * jumping back into the hosts_access() routine. This is cleaner than + * checking the return value of each and every silly little function. The + * (-1) returns are here because zero is already taken by longjmp(). + */ + +#define AC_PERMIT 1 /* permit access */ +#define AC_DENY (-1) /* deny_access */ +#define AC_ERROR AC_DENY /* XXX */ + +/* + * In verification mode an option function should just say what it would do, + * instead of really doing it. An option function that would not return + * should clear the dry_run flag to inform the caller of this unusual + * behavior. + */ + +extern void process_options(); /* execute options */ +extern int dry_run; /* verification flag */ + +/* Bug workarounds. */ + +#ifdef INET_ADDR_BUG /* inet_addr() returns struct */ +#define inet_addr fix_inet_addr +extern long fix_inet_addr(); +#endif + +#ifdef BROKEN_FGETS /* partial reads from sockets */ +#define fgets fix_fgets +extern char *fix_fgets(); +#endif + +#ifdef RECVFROM_BUG /* no address family info */ +#define recvfrom fix_recvfrom +extern int fix_recvfrom(); +#endif + +#ifdef GETPEERNAME_BUG /* claims success with UDP */ +#define getpeername fix_getpeername +extern int fix_getpeername(); +#endif + +#ifdef SOLARIS_24_GETHOSTBYNAME_BUG /* lists addresses as aliases */ +#define gethostbyname fix_gethostbyname +extern struct hostent *fix_gethostbyname(); +#endif + +#ifdef USE_STRSEP /* libc calls strtok() */ +#define strtok fix_strtok +extern char *fix_strtok(); +#endif + +#ifdef LIBC_CALLS_STRTOK /* libc calls strtok() */ +#define strtok my_strtok +extern char *my_strtok(); +#endif + +#endif /* _TCPD_H */ diff --git a/illumos-x86_64/usr/include/term.h b/illumos-x86_64/usr/include/term.h new file mode 100644 index 00000000..b27a2b69 --- /dev/null +++ b/illumos-x86_64/usr/include/term.h @@ -0,0 +1,1254 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ +#ifndef _TERM_H +#define _TERM_H + +/* + * term.h - this file is automatically made from caps and maketerm.ed. + * Don't make changes directly to term.h. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define auto_left_margin CUR _b1 +#define auto_right_margin CUR _b2 +#define no_esc_ctlc CUR _b3 +#define ceol_standout_glitch CUR _b4 +#define eat_newline_glitch CUR _b5 +#define erase_overstrike CUR _b6 +#define generic_type CUR _b7 +#define hard_copy CUR _b8 +#define has_meta_key CUR _b9 +#define has_status_line CUR _b10 +#define insert_null_glitch CUR _b11 +#define memory_above CUR _b12 +#define memory_below CUR _b13 +#define move_insert_mode CUR _b14 +#define move_standout_mode CUR _b15 +#define over_strike CUR _b16 +#define status_line_esc_ok CUR _b17 +#define dest_tabs_magic_smso CUR _b18 +#define tilde_glitch CUR _b19 +#define transparent_underline CUR _b20 +#define xon_xoff CUR _b21 +#define needs_xon_xoff CURB _needs_xon_xoff +#define prtr_silent CURB _prtr_silent +#define hard_cursor CURB _hard_cursor +#define non_rev_rmcup CURB _non_rev_rmcup +#define no_pad_char CURB _no_pad_char +#define non_dest_scroll_region CURB _non_dest_scroll_region +#define can_change CURB _can_change +#define back_color_erase CURB _back_color_erase +#define hue_lightness_saturation CURB _hue_lightness_saturation +#define col_addr_glitch CURB _col_addr_glitch +#define cr_cancels_micro_mode CURB _cr_cancels_micro_mode +#define has_print_wheel CURB _has_print_wheel +#define row_addr_glitch CURB _row_addr_glitch +#define semi_auto_right_margin CURB _semi_auto_right_margin +#define cpi_changes_res CURB _cpi_changes_res +#define lpi_changes_res CURB _lpi_changes_res +#define columns CUR _c1 +#define init_tabs CUR _c2 +#define lines CUR _c3 +#define lines_of_memory CUR _c4 +#define magic_cookie_glitch CUR _c5 +#define padding_baud_rate CUR _c6 +#define virtual_terminal CUR _c7 +#define width_status_line CUR _c8 +#define num_labels CURN _num_labels +#define label_height CURN _labl_height +#define label_width CURN _labl_width +#define max_attributes CURN _max_attributes +#define maximum_windows CURN _maximum_windows +#define max_colors CURN _max_colors +#define max_pairs CURN _max_pairs +#define no_color_video CURN _no_color_video +#define buffer_capacity CURN _buffer_capacity +#define dot_vert_spacing CURN _dot_vert_spacing +#define dot_horz_spacing CURN _dot_horz_spacing +#define max_micro_address CURN _max_micro_address +#define max_micro_jump CURN _max_micro_jump +#define micro_char_size CURN _micro_char_size +#define micro_line_size CURN _micro_line_size +#define number_of_pins CURN _number_of_pins +#define output_res_char CURN _output_res_char +#define output_res_line CURN _output_res_line +#define output_res_horz_inch CURN _output_res_horz_inch +#define output_res_vert_inch CURN _output_res_vert_inch +#define print_rate CURN _print_rate +#define wide_char_size CURN _wide_char_size +#define buttons CURN _buttons +#define bit_image_entwining CURN _bit_image_entwining +#define bit_image_type CURN _bit_image_type +#define back_tab CUR _Vr2_Astrs._s1 +#define bell CUR _Vr2_Astrs._s2 +#define carriage_return CUR _Vr2_Astrs._s3 +#define change_scroll_region CUR _Vr2_Astrs._s4 +#define clear_all_tabs CUR _Vr2_Astrs._s5 +#define clear_screen CUR _Vr2_Astrs._s6 +#define clr_eol CUR _Vr2_Astrs._s7 +#define clr_eos CUR _Vr2_Astrs._s8 +#define column_address CUR _Vr2_Astrs._s9 +#define command_character CUR _Vr2_Astrs._s10 +#define cursor_address CUR _Vr2_Astrs._s11 +#define cursor_down CUR _Vr2_Astrs._s12 +#define cursor_home CUR _Vr2_Astrs._s13 +#define cursor_invisible CUR _Vr2_Astrs._s14 +#define cursor_left CUR _Vr2_Astrs._s15 +#define cursor_mem_address CUR _Vr2_Astrs._s16 +#define cursor_normal CUR _Vr2_Astrs._s17 +#define cursor_right CUR _Vr2_Astrs._s18 +#define cursor_to_ll CUR _Vr2_Astrs._s19 +#define cursor_up CUR _Vr2_Astrs._s20 +#define cursor_visible CUR _Vr2_Astrs._s21 +#define delete_character CUR _Vr2_Astrs._s22 +#define delete_line CUR _Vr2_Astrs._s23 +#define dis_status_line CUR _Vr2_Astrs._s24 +#define down_half_line CUR _Vr2_Astrs._s25 +#define enter_alt_charset_mode CUR _Vr2_Astrs._s26 +#define enter_blink_mode CUR _Vr2_Astrs._s27 +#define enter_bold_mode CUR _Vr2_Astrs._s28 +#define enter_ca_mode CUR _Vr2_Astrs._s29 +#define enter_delete_mode CUR _Vr2_Astrs._s30 +#define enter_dim_mode CUR _Vr2_Astrs._s31 +#define enter_insert_mode CUR _Vr2_Astrs._s32 +#define enter_secure_mode CUR _Vr2_Astrs._s33 +#define enter_protected_mode CUR _Vr2_Astrs._s34 +#define enter_reverse_mode CUR _Vr2_Astrs._s35 +#define enter_standout_mode CUR _Vr2_Astrs._s36 +#define enter_underline_mode CUR _Vr2_Astrs._s37 +#define erase_chars CUR _Vr2_Astrs._s38 +#define exit_alt_charset_mode CUR _Vr2_Astrs._s39 +#define exit_attribute_mode CUR _Vr2_Astrs._s40 +#define exit_ca_mode CUR _Vr2_Astrs._s41 +#define exit_delete_mode CUR _Vr2_Astrs._s42 +#define exit_insert_mode CUR _Vr2_Astrs._s43 +#define exit_standout_mode CUR _Vr2_Astrs._s44 +#define exit_underline_mode CUR _Vr2_Astrs._s45 +#define flash_screen CUR _Vr2_Astrs._s46 +#define form_feed CUR _Vr2_Astrs._s47 +#define from_status_line CUR _Vr2_Astrs._s48 +#define init_1string CUR _Vr2_Astrs._s49 +#define init_2string CUR _Vr2_Astrs._s50 +#define init_3string CUR _Vr2_Astrs._s51 +#define init_file CUR _Vr2_Astrs._s52 +#define insert_character CUR _Vr2_Astrs._s53 +#define insert_line CUR _Vr2_Astrs._s54 +#define insert_padding CUR _Vr2_Astrs._s55 +#define key_backspace CUR _Vr2_Astrs._s56 +#define key_catab CUR _Vr2_Astrs._s57 +#define key_clear CUR _Vr2_Astrs._s58 +#define key_ctab CUR _Vr2_Astrs._s59 +#define key_dc CUR _Vr2_Astrs._s60 +#define key_dl CUR _Vr2_Astrs._s61 +#define key_down CUR _Vr2_Astrs._s62 +#define key_eic CUR _Vr2_Astrs._s63 +#define key_eol CUR _Vr2_Astrs._s64 +#define key_eos CUR _Vr2_Astrs._s65 +#define key_f0 CUR _Vr2_Astrs._s66 +#define key_f1 CUR _Vr2_Astrs._s67 +#define key_f10 CUR _Vr2_Astrs._s68 +#define key_f2 CUR _Vr2_Astrs._s69 +#define key_f3 CUR _Vr2_Astrs._s70 +#define key_f4 CUR _Vr2_Astrs._s71 +#define key_f5 CUR _Vr2_Astrs._s72 +#define key_f6 CUR _Vr2_Astrs._s73 +#define key_f7 CUR _Vr2_Astrs._s74 +#define key_f8 CUR _Vr2_Astrs._s75 +#define key_f9 CUR _Vr2_Astrs._s76 +#define key_home CUR _Vr2_Astrs._s77 +#define key_ic CUR _Vr2_Astrs._s78 +#define key_il CUR _Vr2_Astrs._s79 +#define key_left CUR _Vr2_Astrs._s80 +#define key_ll CUR _Vr2_Astrs._s81 +#define key_npage CUR _Vr2_Astrs._s82 +#define key_ppage CUR _Vr2_Astrs._s83 +#define key_right CUR _Vr2_Astrs._s84 +#define key_sf CUR _Vr2_Astrs._s85 +#define key_sr CUR _Vr2_Astrs._s86 +#define key_stab CUR _Vr2_Astrs._s87 +#define key_up CUR _Vr2_Astrs._s88 +#define keypad_local CUR _Vr2_Astrs._s89 +#define keypad_xmit CUR _Vr2_Astrs._s90 +#define lab_f0 CUR _Vr2_Astrs._s91 +#define lab_f1 CUR _Vr2_Astrs._s92 +#define lab_f10 CUR _Vr2_Astrs._s93 +#define lab_f2 CUR _Vr2_Astrs._s94 +#define lab_f3 CUR _Vr2_Astrs._s95 +#define lab_f4 CUR _Vr2_Astrs._s96 +#define lab_f5 CUR _Vr2_Astrs._s97 +#define lab_f6 CUR _Vr2_Astrs._s98 +#define lab_f7 CUR _Vr2_Astrs._s99 +#define lab_f8 CUR _Vr2_Astrs._s100 +#define lab_f9 CUR _Vr2_Bstrs._s101 +#define meta_off CUR _Vr2_Bstrs._s102 +#define meta_on CUR _Vr2_Bstrs._s103 +#define newline CUR _Vr2_Bstrs._s104 +#define pad_char CUR _Vr2_Bstrs._s105 +#define parm_dch CUR _Vr2_Bstrs._s106 +#define parm_delete_line CUR _Vr2_Bstrs._s107 +#define parm_down_cursor CUR _Vr2_Bstrs._s108 +#define parm_ich CUR _Vr2_Bstrs._s109 +#define parm_index CUR _Vr2_Bstrs._s110 +#define parm_insert_line CUR _Vr2_Bstrs._s111 +#define parm_left_cursor CUR _Vr2_Bstrs._s112 +#define parm_right_cursor CUR _Vr2_Bstrs._s113 +#define parm_rindex CUR _Vr2_Bstrs._s114 +#define parm_up_cursor CUR _Vr2_Bstrs._s115 +#define pkey_key CUR _Vr2_Bstrs._s116 +#define pkey_local CUR _Vr2_Bstrs._s117 +#define pkey_xmit CUR _Vr2_Bstrs._s118 +#define print_screen CUR _Vr2_Bstrs._s119 +#define prtr_off CUR _Vr2_Bstrs._s120 +#define prtr_on CUR _Vr2_Bstrs._s121 +#define repeat_char CUR _Vr2_Bstrs._s122 +#define reset_1string CUR _Vr2_Bstrs._s123 +#define reset_2string CUR _Vr2_Bstrs._s124 +#define reset_3string CUR _Vr2_Bstrs._s125 +#define reset_file CUR _Vr2_Bstrs._s126 +#define restore_cursor CUR _Vr2_Bstrs._s127 +#define row_address CUR _Vr2_Bstrs._s128 +#define save_cursor CUR _Vr2_Bstrs._s129 +#define scroll_forward CUR _Vr2_Bstrs._s130 +#define scroll_reverse CUR _Vr2_Bstrs._s131 +#define set_attributes CUR _Vr2_Bstrs._s132 +#define set_tab CUR _Vr2_Bstrs._s133 +#define set_window CUR _Vr2_Bstrs._s134 +#define tab CUR _Vr2_Bstrs._s135 +#define to_status_line CUR _Vr2_Bstrs._s136 +#define underline_char CUR _Vr2_Bstrs._s137 +#define up_half_line CUR _Vr2_Bstrs._s138 +#define init_prog CUR _Vr2_Bstrs._s139 +#define key_a1 CUR _Vr2_Bstrs._s140 +#define key_a3 CUR _Vr2_Bstrs._s141 +#define key_b2 CUR _Vr2_Bstrs._s142 +#define key_c1 CUR _Vr2_Bstrs._s143 +#define key_c3 CUR _Vr2_Bstrs._s144 +#define prtr_non CUR _Vr2_Bstrs._s145 +#define char_padding CURS strs2._char_padding +#define acs_chars CURS strs2._acs_chars +#define plab_norm CURS strs2._plab_norm +#define key_btab CURS strs2._ky_btab +#define enter_xon_mode CURS strs2._entr_xon_mode +#define exit_xon_mode CURS strs2._exit_xon_mode +#define enter_am_mode CURS strs2._entr_am_mode +#define exit_am_mode CURS strs2._exit_am_mode +#define xon_character CURS strs2._xon_character +#define xoff_character CURS strs2._xoff_character +#define ena_acs CURS strs2._ena_acs +#define label_on CURS strs2._labl_on +#define label_off CURS strs2._labl_off +#define key_beg CURS strs2._ky_beg +#define key_cancel CURS strs2._ky_cancel +#define key_close CURS strs2._ky_close +#define key_command CURS strs2._ky_command +#define key_copy CURS strs2._ky_copy +#define key_create CURS strs2._ky_create +#define key_end CURS strs2._ky_end +#define key_enter CURS strs2._ky_enter +#define key_exit CURS strs2._ky_exit +#define key_find CURS strs2._ky_find +#define key_help CURS strs2._ky_help +#define key_mark CURS strs2._ky_mark +#define key_message CURS strs2._ky_message +#define key_move CURS strs2._ky_move +#define key_next CURS strs2._ky_next +#define key_open CURS strs2._ky_open +#define key_options CURS strs2._ky_options +#define key_previous CURS strs2._ky_previous +#define key_print CURS strs2._ky_print +#define key_redo CURS strs2._ky_redo +#define key_reference CURS strs2._ky_reference +#define key_refresh CURS strs2._ky_refresh +#define key_replace CURS strs2._ky_replace +#define key_restart CURS strs2._ky_restart +#define key_resume CURS strs2._ky_resume +#define key_save CURS strs2._ky_save +#define key_suspend CURS strs2._ky_suspend +#define key_undo CURS strs2._ky_undo +#define key_sbeg CURS strs2._ky_sbeg +#define key_scancel CURS strs2._ky_scancel +#define key_scommand CURS strs2._ky_scommand +#define key_scopy CURS strs2._ky_scopy +#define key_screate CURS strs2._ky_screate +#define key_sdc CURS strs2._ky_sdc +#define key_sdl CURS strs2._ky_sdl +#define key_select CURS strs2._ky_select +#define key_send CURS strs2._ky_send +#define key_seol CURS strs2._ky_seol +#define key_sexit CURS strs2._ky_sexit +#define key_sfind CURS strs2._ky_sfind +#define key_shelp CURS strs2._ky_shelp +#define key_shome CURS strs2._ky_shome +#define key_sic CURS strs3._ky_sic +#define key_sleft CURS strs3._ky_sleft +#define key_smessage CURS strs3._ky_smessage +#define key_smove CURS strs3._ky_smove +#define key_snext CURS strs3._ky_snext +#define key_soptions CURS strs3._ky_soptions +#define key_sprevious CURS strs3._ky_sprevious +#define key_sprint CURS strs3._ky_sprint +#define key_sredo CURS strs3._ky_sredo +#define key_sreplace CURS strs3._ky_sreplace +#define key_sright CURS strs3._ky_sright +#define key_srsume CURS strs3._ky_srsume +#define key_ssave CURS strs3._ky_ssave +#define key_ssuspend CURS strs3._ky_ssuspend +#define key_sundo CURS strs3._ky_sundo +#define req_for_input CURS strs3._req_for_input +#define key_f11 CURS strs3._ky_f11 +#define key_f12 CURS strs3._ky_f12 +#define key_f13 CURS strs3._ky_f13 +#define key_f14 CURS strs3._ky_f14 +#define key_f15 CURS strs3._ky_f15 +#define key_f16 CURS strs3._ky_f16 +#define key_f17 CURS strs3._ky_f17 +#define key_f18 CURS strs3._ky_f18 +#define key_f19 CURS strs3._ky_f19 +#define key_f20 CURS strs3._ky_f20 +#define key_f21 CURS strs3._ky_f21 +#define key_f22 CURS strs3._ky_f22 +#define key_f23 CURS strs3._ky_f23 +#define key_f24 CURS strs3._ky_f24 +#define key_f25 CURS strs3._ky_f25 +#define key_f26 CURS strs3._ky_f26 +#define key_f27 CURS strs3._ky_f27 +#define key_f28 CURS strs3._ky_f28 +#define key_f29 CURS strs3._ky_f29 +#define key_f30 CURS strs3._ky_f30 +#define key_f31 CURS strs3._ky_f31 +#define key_f32 CURS strs3._ky_f32 +#define key_f33 CURS strs3._ky_f33 +#define key_f34 CURS strs3._ky_f34 +#define key_f35 CURS strs3._ky_f35 +#define key_f36 CURS strs3._ky_f36 +#define key_f37 CURS strs3._ky_f37 +#define key_f38 CURS strs3._ky_f38 +#define key_f39 CURS strs3._ky_f39 +#define key_f40 CURS strs3._ky_f40 +#define key_f41 CURS strs3._ky_f41 +#define key_f42 CURS strs3._ky_f42 +#define key_f43 CURS strs3._ky_f43 +#define key_f44 CURS strs3._ky_f44 +#define key_f45 CURS strs3._ky_f45 +#define key_f46 CURS strs3._ky_f46 +#define key_f47 CURS strs3._ky_f47 +#define key_f48 CURS strs3._ky_f48 +#define key_f49 CURS strs3._ky_f49 +#define key_f50 CURS strs3._ky_f50 +#define key_f51 CURS strs3._ky_f51 +#define key_f52 CURS strs3._ky_f52 +#define key_f53 CURS strs3._ky_f53 +#define key_f54 CURS strs3._ky_f54 +#define key_f55 CURS strs3._ky_f55 +#define key_f56 CURS strs3._ky_f56 +#define key_f57 CURS strs3._ky_f57 +#define key_f58 CURS strs3._ky_f58 +#define key_f59 CURS strs3._ky_f59 +#define key_f60 CURS strs3._ky_f60 +#define key_f61 CURS strs3._ky_f61 +#define key_f62 CURS strs3._ky_f62 +#define key_f63 CURS strs3._ky_f63 +#define clr_bol CURS strs3._clr_bol +#define clear_margins CURS strs3._clear_margins +#define set_left_margin CURS strs3._set_left_margin +#define set_right_margin CURS strs3._set_right_margin +#define label_format CURS strs3._labl_format +#define set_clock CURS strs3._set_clock +#define display_clock CURS strs3._display_clock +#define remove_clock CURS strs3._remove_clock +#define create_window CURS strs3._create_window +#define goto_window CURS strs3._goto_window +#define hangup CURS strs3._hangup +#define dial_phone CURS strs3._dial_phone +#define quick_dial CURS strs3._quick_dial +#define tone CURS strs3._tone +#define pulse CURS strs3._pulse +#define flash_hook CURS strs3._flash_hook +#define fixed_pause CURS strs3._fixed_pause +#define wait_tone CURS strs3._wait_tone +#define user0 CURS strs3._user0 +#define user1 CURS strs3._user1 +#define user2 CURS strs3._user2 +#define user3 CURS strs3._user3 +#define user4 CURS strs3._user4 +#define user5 CURS strs3._user5 +#define user6 CURS strs3._user6 +#define user7 CURS strs3._user7 +#define user8 CURS strs3._user8 +#define user9 CURS strs3._user9 +#define orig_pair CURS strs3._orig_pair +#define orig_colors CURS strs3._orig_colors +#define initialize_color CURS strs3._initialize_color +#define initialize_pair CURS strs4._initialize_pair +#define set_color_pair CURS strs4._set_color_pair +#define set_foreground CURS strs4._set_foreground +#define set_background CURS strs4._set_background +#define change_char_pitch CURS strs4._change_char_pitch +#define change_line_pitch CURS strs4._change_line_pitch +#define change_res_horz CURS strs4._change_res_horz +#define change_res_vert CURS strs4._change_res_vert +#define define_char CURS strs4._define_char +#define enter_doublewide_mode CURS strs4._entr_doublewide_mode +#define enter_draft_quality CURS strs4._entr_draft_quality +#define enter_italics_mode CURS strs4._entr_italics_mode +#define enter_leftward_mode CURS strs4._entr_leftward_mode +#define enter_micro_mode CURS strs4._entr_micro_mode +#define enter_near_letter_quality CURS strs4._entr_near_letter_quality +#define enter_normal_quality CURS strs4._entr_normal_quality +#define enter_shadow_mode CURS strs4._entr_shadow_mode +#define enter_subscript_mode CURS strs4._entr_subscript_mode +#define enter_superscript_mode CURS strs4._entr_superscript_mode +#define enter_upward_mode CURS strs4._entr_upward_mode +#define exit_doublewide_mode CURS strs4._exit_doublewide_mode +#define exit_italics_mode CURS strs4._exit_italics_mode +#define exit_leftward_mode CURS strs4._exit_leftward_mode +#define exit_micro_mode CURS strs4._exit_micro_mode +#define exit_shadow_mode CURS strs4._exit_shadow_mode +#define exit_subscript_mode CURS strs4._exit_subscript_mode +#define exit_superscript_mode CURS strs4._exit_superscript_mode +#define exit_upward_mode CURS strs4._exit_upward_mode +#define micro_column_address CURS strs4._micro_column_address +#define micro_down CURS strs4._micro_down +#define micro_left CURS strs4._micro_left +#define micro_right CURS strs4._micro_right +#define micro_row_address CURS strs4._micro_row_address +#define micro_up CURS strs4._micro_up +#define order_of_pins CURS strs4._order_of_pins +#define parm_down_micro CURS strs4._prm_down_micro +#define parm_left_micro CURS strs4._prm_left_micro +#define parm_right_micro CURS strs4._prm_right_micro +#define parm_up_micro CURS strs4._prm_up_micro +#define select_char_set CURS strs4._select_char_set +#define set_bottom_margin CURS strs4._set_bottom_margin +#define set_bottom_margin_parm CURS strs4._set_bottom_margin_parm +#define set_left_margin_parm CURS strs4._set_left_margin_parm +#define set_right_margin_parm CURS strs4._set_right_margin_parm +#define set_top_margin CURS strs4._set_top_margin +#define set_top_margin_parm CURS strs4._set_top_margin_parm +#define start_bit_image CURS strs4._start_bit_image +#define start_char_set_def CURS strs4._start_char_set_def +#define stop_bit_image CURS strs4._stop_bit_image +#define stop_char_set_def CURS strs4._stop_char_set_def +#define subscript_characters CURS strs4._subscript_characters +#define superscript_characters CURS strs4._superscript_characters +#define these_cause_cr CURS strs4._these_cause_cr +#define zero_motion CURS strs4._zero_motion +#define char_set_names CURS strs4._char_set_names +#define key_mouse CURS strs4._ky_mouse +#define mouse_info CURS strs4._mouse_info +#define req_mouse_pos CURS strs4._req_mouse_pos +#define get_mouse CURS strs4._get_mouse +#define set_a_foreground CURS strs4._set_a_foreground +#define set_a_background CURS strs4._set_a_background +#define pkey_plab CURS strs4._pkey_plab +#define device_type CURS strs4._device_type +#define code_set_init CURS strs4._code_set_init +#define set0_des_seq CURS strs4._set0_des_seq +#define set1_des_seq CURS strs4._set1_des_seq +#define set2_des_seq CURS strs4._set2_des_seq +#define set3_des_seq CURS strs4._set3_des_seq +#define set_lr_margin CURS strs4._set_lr_margin +#define set_tb_margin CURS strs4._set_tb_margin +#define bit_image_repeat CURS strs4._bit_image_repeat +#define bit_image_newline CURS strs4._bit_image_newline +#define bit_image_carriage_return CURS strs4._bit_image_carriage_return +#define color_names CURS strs4._color_names +#define define_bit_image_region CURS strs4._define_bit_image_region +#define end_bit_image_region CURS strs4._end_bit_image_region +#define set_color_band CURS strs4._set_color_band +#define set_page_length CURS strs4._set_page_length +#define display_pc_char CURS strs4._display_pc_char +#define enter_pc_charset_mode CURS strs4._entr_pc_charset_mode +#define exit_pc_charset_mode CURS strs4._exit_pc_charset_mode +#define enter_scancode_mode CURS strs4._entr_scancode_mode +#define exit_scancode_mode CURS strs4._exit_scancode_mode +#define pc_term_options CURS strs4._pc_term_options +#define scancode_escape CURS strs4._scancode_escape +#define alt_scancode_esc CURS strs4._alt_scancode_esc +#define enter_horizontal_hl_mode CURS strs4._entr_horizontal_hl_mode +#define enter_left_hl_mode CURS strs4._entr_left_hl_mode +#define enter_low_hl_mode CURS strs4._entr_low_hl_mode +#define enter_right_hl_mode CURS strs4._entr_right_hl_mode +#define enter_top_hl_mode CURS strs4._entr_top_hl_mode +#define enter_vertical_hl_mode CURS strs4._entr_vertical_hl_mode +#define set_a_attributes CURS strs4._set_a_attributes +#define set_pglen_inch CURS strs4._set_pglen_inch + +typedef char *charptr; +struct strs { + charptr + _back_tab, /* Back tab */ + _bell, /* Audible signal (bell) */ + _carriage_return, /* Carriage return (*) */ + _change_scroll_region, /* change to lines #1 thru #2 (vt100) (G) */ + _clear_all_tabs, /* Clear all tab stops. */ + _clear_screen, /* Clear screen (*) */ + _clr_eol, /* Clear to end of line */ + _clr_eos, /* Clear to end of display (*) */ + _column_address, /* Set cursor column (G) */ + _command_character, /* Term. settable cmd char in prototype */ + _crsr_address, /* Cursor motion to row #1 col #2 (G) */ + _crsr_down, /* Down one line */ + _crsr_home, /* Home cursor (if no cup) */ + _crsr_invisible, /* Make cursor invisible */ + _crsr_left, /* Move cursor left one space. */ + _crsr_mem_address, /* Memory relative cursor addressing. */ + _crsr_normal, /* Make cursor appear normal (undo vs/vi) */ + _crsr_right, /* Non-destructive space (cursor right) */ + _crsr_to_ll, /* Last line, first column (if no cup) */ + _crsr_up, /* Upline (cursor up) */ + _crsr_visible, /* Make cursor very visible */ + _dlt_character, /* Delete character (*) */ + _dlt_line, /* Delete line (*) */ + _dis_status_line, /* Disable status line */ + _down_half_line, /* Half-line down (forward 1/2 linefeed) */ + _entr_alt_charset_mode, /* Start alternate character set */ + _entr_blink_mode, /* Turn on blinking */ + _entr_bold_mode, /* Turn on bold (extra bright) mode */ + _entr_ca_mode, /* String to begin programs that use cup */ + _entr_delete_mode, /* Delete mode (enter) */ + _entr_dim_mode, /* Turn on half-bright mode */ + _entr_insert_mode, /* Insert mode (enter); */ + _entr_secure_mode, /* Turn on blank mode (chars invisible) */ + _entr_protected_mode, /* Turn on protected mode */ + _entr_reverse_mode, /* Turn on reverse video mode */ + _entr_standout_mode, /* Begin stand out mode */ + _entr_underline_mode, /* Start underscore mode */ + _erase_chars, /* Erase #1 characters (G) */ + _exit_alt_charset_mode, /* End alternate character set */ + _exit_attribute_mode, /* Turn off all attributes */ + _exit_ca_mode, /* String to end programs that use cup */ + _exit_delete_mode, /* End delete mode */ + _exit_insert_mode, /* End insert mode; */ + _exit_standout_mode, /* End stand out mode */ + _exit_underline_mode, /* End underscore mode */ + _flash_screen, /* Visible bell (may not move cursor) */ + _form_feed, /* Hardcopy terminal page eject (*) */ + _from_status_line, /* Return from status line */ + _init_1string, /* Terminal initialization string */ + _init_2string, /* Terminal initialization string */ + _init_3string, /* Terminal initialization string */ + _init_file, /* Name of file containing is */ + _ins_character, /* Insert character */ + _ins_line, /* Add new blank line (*) */ + _ins_padding, /* Insert pad after character inserted (*) */ + _ky_backspace, /* KEY_BACKSPACE, 0407, Sent by backspace key */ + _ky_catab, /* KEY_CATAB, 0526, Sent by clear-all-tabs key. */ + _ky_clear, /* KEY_CLEAR, 0515, Sent by clear screen or erase key. */ + _ky_ctab, /* KEY_CTAB, 0525, Sent by clear-tab key */ + _ky_dc, /* KEY_DC, 0512, Sent by delete character key. */ + _ky_dl, /* KEY_DL, 0510, Sent by delete line key. */ + _ky_down, /* KEY_DOWN, 0402, Sent by terminal down arrow key */ + _ky_eic, /* KEY_EIC, 0514, Sent by rmir or smir in ins mode. */ + _ky_eol, /* KEY_EOL, 0517, Sent by clear-to-end-of-line key. */ + _ky_eos, /* KEY_EOS, 0516, Sent by clear-to-end-of-screen. */ + _ky_f0, /* KEY_F(0), 0410, function key f0. */ + _ky_f1, /* KEY_F(1), 0411, function key f1. */ + _ky_f10, /* KEY_F(10), 0422, function key f10. */ + _ky_f2, /* KEY_F(2), 0412, function key f2. */ + _ky_f3, /* KEY_F(3), 0413, function key f3. */ + _ky_f4, /* KEY_F(4), 0414, function key f4. */ + _ky_f5, /* KEY_F(5), 0415, function key f5. */ + _ky_f6, /* KEY_F(6), 0416, function key f6. */ + _ky_f7, /* KEY_F(7), 0417, function key f7. */ + _ky_f8, /* KEY_F(8), 0420, function key f8. */ + _ky_f9, /* KEY_F(9), 0421, function key f9. */ + _ky_home, /* KEY_HOME, 0406, Sent by home key. */ + _ky_ic, /* KEY_IC, 0513, Sent by ins char/enter mode key. */ + _ky_il, /* KEY_IL, 0511, Sent by insert line. */ + _ky_left, /* KEY_LEFT, 0404, Sent by terminal left arrow key */ + _ky_ll, /* KEY_LL, 0533, Sent by home-down key */ + _ky_npage, /* KEY_NPAGE, 0522, Sent by next-page key */ + _ky_ppage, /* KEY_PPAGE, 0523, Sent by previous-page key */ + _ky_right, /* KEY_RIGHT, 0405, Sent by terminal right arrow key */ + _ky_sf, /* KEY_SF, 0520, Sent by scroll-forward/down key */ + _ky_sr, /* KEY_SR, 0521, Sent by scroll-backward/up key */ + _ky_stab, /* KEY_STAB, 0524, Sent by set-tab key */ + _ky_up, /* KEY_UP, 0403, Sent by terminal up arrow key */ + _kpad_local, /* Out of "keypad transmit" mode */ + _kpad_xmit, /* Put terminal in "keypad transmit" mode */ + _lab_f0, /* Labels on function key f0 if not f0 */ + _lab_f1, /* Labels on function key f1 if not f1 */ + _lab_f10, /* Labels on function key f10 if not f10 */ + _lab_f2, /* Labels on function key f2 if not f2 */ + _lab_f3, /* Labels on function key f3 if not f3 */ + _lab_f4, /* Labels on function key f4 if not f4 */ + _lab_f5, /* Labels on function key f5 if not f5 */ + _lab_f6, /* Labels on function key f6 if not f6 */ + _lab_f7, /* Labels on function key f7 if not f7 */ + _lab_f8; /* Labels on function key f8 if not f8 */ +}; + +struct strs2 { + charptr + _lab_f9, /* Labels on function key f9 if not f9 */ + _meta_off, /* Turn off "meta mode" */ + _meta_on, /* Turn on "meta mode" (8th bit) */ + _newline, /* Newline (behaves like cr followed by lf) */ + _pad_char, /* Pad character (rather than null) */ + _prm_dch, /* Delete #1 chars (G*) */ + _prm_delete_line, /* Delete #1 lines (G*) */ + _prm_down_cursor, /* Move cursor down #1 lines. (G*) */ + _prm_ich, /* Insert #1 blank chars (G*) */ + _prm_index, /* Scroll forward #1 lines. (G) */ + _prm_insert_line, /* Add #1 new blank lines (G*) */ + _prm_left_cursor, /* Move cursor left #1 spaces (G) */ + _prm_right_cursor, /* Move cursor right #1 spaces. (G*) */ + _prm_rindex, /* Scroll backward #1 lines. (G) */ + _prm_up_cursor, /* Move cursor up #1 lines. (G*) */ + _pkey_key, /* Prog funct key #1 to type string #2 */ + _pkey_local, /* Prog funct key #1 to execute string #2 */ + _pkey_xmit, /* Prog funct key #1 to xmit string #2 */ + _print_screen, /* Print contents of the screen */ + _prtr_off, /* Turn off the printer */ + _prtr_on, /* Turn on the printer */ + _repeat_char, /* Repeat char #1 #2 times. (G*) */ + _reset_1string, /* Reset terminal completely to sane modes. */ + _reset_2string, /* Reset terminal completely to sane modes. */ + _reset_3string, /* Reset terminal completely to sane modes. */ + _reset_file, /* Name of file containing reset string. */ + _restore_cursor, /* Restore cursor to position of last sc. */ + _row_address, /* Like hpa but sets row. (G) */ + _save_cursor, /* Save cursor position. */ + _scrll_forward, /* Scroll text up */ + _scrll_reverse, /* Scroll text down */ + _set_attributes, /* Define the video attributes (G9) */ + _set_tab, /* Set a tab in all rows, current column. */ + _set_window, /* Current window is lines #1-#2 cols #3-#4 */ + _tab, /* Tab to next 8 space hardware tab stop. */ + _to_status_line, /* Go to status line, col #1 */ + _underline_char, /* Underscore one char and move past it */ + _up_half_line, /* Half-line up (reverse 1/2 linefeed) */ + _init_prog, /* Path name of program for init. */ + _ky_a1, /* KEY_A1, 0534, Upper left of keypad */ + _ky_a3, /* KEY_A3, 0535, Upper right of keypad */ + _ky_b2, /* KEY_B2, 0536, Center of keypad */ + _ky_c1, /* KEY_C1, 0537, Lower left of keypad */ + _ky_c3, /* KEY_C3, 0540, Lower right of keypad */ + _prtr_non, /* Turn on the printer for #1 bytes. */ + _char_padding, /* Like ip but when in replace mode */ + _acs_chars, /* Graphic charset pairs aAbBcC - def=vt100 */ + _plab_norm, /* Prog label #1 to show string #2 */ + _ky_btab, /* KEY_BTAB, 0541, Back tab key */ + _entr_xon_mode, /* Turn on xon/xoff handshaking */ + _exit_xon_mode, /* Turn off xon/xoff handshaking */ + _entr_am_mode, /* Turn on automatic margins */ + _exit_am_mode, /* Turn off automatic margins */ + _xon_character, /* X-on character */ + _xoff_character, /* X-off character */ + _ena_acs, /* Enable alternate char set */ + _labl_on, /* Turn on soft labels */ + _labl_off, /* Turn off soft labels */ + _ky_beg, /* KEY_BEG, 0542, beg(inning) key */ + _ky_cancel, /* KEY_CANCEL, 0543, cancel key */ + _ky_close, /* KEY_CLOSE, 0544, close key */ + _ky_command, /* KEY_COMMAND, 0545, cmd (command) key */ + _ky_copy, /* KEY_COPY, 0546, copy key */ + _ky_create, /* KEY_CREATE, 0547, create key */ + _ky_end, /* KEY_END, 0550, end key */ + _ky_enter, /* KEY_ENTER, 0527, Enter/send (unreliable) */ + _ky_exit, /* KEY_EXIT, 0551, exit key */ + _ky_find, /* KEY_FIND, 0552, find key */ + _ky_help, /* KEY_HELP, 0553, help key */ + _ky_mark, /* KEY_MARK, 0554, mark key */ + _ky_message, /* KEY_MESSAGE, 0555, message key */ + _ky_move, /* KEY_MOVE, 0556, move key */ + _ky_next, /* KEY_NEXT, 0557, next object key */ + _ky_open, /* KEY_OPEN, 0560, open key */ + _ky_options, /* KEY_OPTIONS, 0561, options key */ + _ky_previous, /* KEY_PREVIOUS, 0562, previous object key */ + _ky_print, /* KEY_PRINT, 0532, print or copy */ + _ky_redo, /* KEY_REDO, 0563, redo key */ + _ky_reference, /* KEY_REFERENCE, 0564, ref(erence) key */ + _ky_refresh, /* KEY_REFRESH, 0565, refresh key */ + _ky_replace, /* KEY_REPLACE, 0566, replace key */ + _ky_restart, /* KEY_RESTART, 0567, restart key */ + _ky_resume, /* KEY_RESUME, 0570, resume key */ + _ky_save, /* KEY_SAVE, 0571, save key */ + _ky_suspend, /* KEY_SUSPEND, 0627, suspend key */ + _ky_undo, /* KEY_UNDO, 0630, undo key */ + _ky_sbeg, /* KEY_SBEG, 0572, shifted beginning key */ + _ky_scancel, /* KEY_SCANCEL, 0573, shifted cancel key */ + _ky_scommand, /* KEY_SCOMMAND, 0574, shifted command key */ + _ky_scopy, /* KEY_SCOPY, 0575, shifted copy key */ + _ky_screate, /* KEY_SCREATE, 0576, shifted create key */ + _ky_sdc, /* KEY_SDC, 0577, shifted delete char key */ + _ky_sdl, /* KEY_SDL, 0600, shifted delete line key */ + _ky_select, /* KEY_SELECT, 0601, select key */ + _ky_send, /* KEY_SEND, 0602, shifted end key */ + _ky_seol, /* KEY_SEOL, 0603, shifted clear line key */ + _ky_sexit, /* KEY_SEXIT, 0604, shifted exit key */ + _ky_sfind, /* KEY_SFIND, 0605, shifted find key */ + _ky_shelp, /* KEY_SHELP, 0606, shifted help key */ + _ky_shome; /* KEY_SHOME, 0607, shifted home key */ +}; + +struct strs3 { + charptr + _ky_sic, /* KEY_SIC, 0610, shifted input key */ + _ky_sleft, /* KEY_SLEFT, 0611, shifted left arrow key */ + _ky_smessage, /* KEY_SMESSAGE, 0612, shifted message key */ + _ky_smove, /* KEY_SMOVE, 0613, shifted move key */ + _ky_snext, /* KEY_SNEXT, 0614, shifted next key */ + _ky_soptions, /* KEY_SOPTIONS, 0615, shifted options key */ + _ky_sprevious, /* KEY_SPREVIOUS, 0616, shifted prev key */ + _ky_sprint, /* KEY_SPRINT, 0617, shifted print key */ + _ky_sredo, /* KEY_SREDO, 0620, shifted redo key */ + _ky_sreplace, /* KEY_SREPLACE, 0621, shifted replace key */ + _ky_sright, /* KEY_SRIGHT, 0622, shifted right arrow */ + _ky_srsume, /* KEY_SRSUME, 0623, shifted resume key */ + _ky_ssave, /* KEY_SSAVE, 0624, shifted save key */ + _ky_ssuspend, /* KEY_SSUSPEND, 0625, shifted suspend key */ + _ky_sundo, /* KEY_SUNDO, 0626, shifted undo key */ + _req_for_input, /* send next input char (for ptys) */ + _ky_f11, /* KEY_F(11), 0423, function key f11. */ + _ky_f12, /* KEY_F(12), 0424, function key f12. */ + _ky_f13, /* KEY_F(13), 0425, function key f13. */ + _ky_f14, /* KEY_F(14), 0426, function key f14. */ + _ky_f15, /* KEY_F(15), 0427, function key f15. */ + _ky_f16, /* KEY_F(16), 0430, function key f16. */ + _ky_f17, /* KEY_F(17), 0431, function key f17. */ + _ky_f18, /* KEY_F(18), 0432, function key f18. */ + _ky_f19, /* KEY_F(19), 0433, function key f19. */ + _ky_f20, /* KEY_F(20), 0434, function key f20. */ + _ky_f21, /* KEY_F(21), 0435, function key f21. */ + _ky_f22, /* KEY_F(22), 0436, function key f22. */ + _ky_f23, /* KEY_F(23), 0437, function key f23. */ + _ky_f24, /* KEY_F(24), 0440, function key f24. */ + _ky_f25, /* KEY_F(25), 0441, function key f25. */ + _ky_f26, /* KEY_F(26), 0442, function key f26. */ + _ky_f27, /* KEY_F(27), 0443, function key f27. */ + _ky_f28, /* KEY_F(28), 0444, function key f28. */ + _ky_f29, /* KEY_F(29), 0445, function key f29. */ + _ky_f30, /* KEY_F(30), 0446, function key f30. */ + _ky_f31, /* KEY_F(31), 0447, function key f31. */ + _ky_f32, /* KEY_F(32), 0450, function key f32. */ + _ky_f33, /* KEY_F(33), 0451, function key f33. */ + _ky_f34, /* KEY_F(34), 0452, function key f34. */ + _ky_f35, /* KEY_F(35), 0453, function key f35. */ + _ky_f36, /* KEY_F(36), 0454, function key f36. */ + _ky_f37, /* KEY_F(37), 0455, function key f37. */ + _ky_f38, /* KEY_F(38), 0456, function key f38. */ + _ky_f39, /* KEY_F(39), 0457, function key f39. */ + _ky_f40, /* KEY_F(40), 0460, function key f40. */ + _ky_f41, /* KEY_F(41), 0461, function key f41. */ + _ky_f42, /* KEY_F(42), 0462, function key f42. */ + _ky_f43, /* KEY_F(43), 0463, function key f43. */ + _ky_f44, /* KEY_F(44), 0464, function key f44. */ + _ky_f45, /* KEY_F(45), 0465, function key f45. */ + _ky_f46, /* KEY_F(46), 0466, function key f46. */ + _ky_f47, /* KEY_F(47), 0467, function key f47. */ + _ky_f48, /* KEY_F(48), 0470, function key f48. */ + _ky_f49, /* KEY_F(49), 0471, function key f49. */ + _ky_f50, /* KEY_F(50), 0472, function key f50. */ + _ky_f51, /* KEY_F(51), 0473, function key f51. */ + _ky_f52, /* KEY_F(52), 0474, function key f52. */ + _ky_f53, /* KEY_F(53), 0475, function key f53. */ + _ky_f54, /* KEY_F(54), 0476, function key f54. */ + _ky_f55, /* KEY_F(55), 0477, function key f55. */ + _ky_f56, /* KEY_F(56), 0500, function key f56. */ + _ky_f57, /* KEY_F(57), 0501, function key f57. */ + _ky_f58, /* KEY_F(58), 0502, function key f58. */ + _ky_f59, /* KEY_F(59), 0503, function key f59. */ + _ky_f60, /* KEY_F(60), 0504, function key f60. */ + _ky_f61, /* KEY_F(61), 0505, function key f61. */ + _ky_f62, /* KEY_F(62), 0506, function key f62. */ + _ky_f63, /* KEY_F(63), 0507, function key f63. */ + _clr_bol, /* Clear to beginning of line, inclusive */ + _clear_margins, /* Clear left and right soft margins */ + _set_left_margin, /* Set soft left margin */ + _set_right_margin, /* Set soft right margin */ + _labl_format, /* Label format */ + _set_clock, /* Set time-of-day clock */ + _display_clock, /* Display time-of-day clock */ + _remove_clock, /* Remove time-of-day clock */ + _create_window, /* Define win #1 to go from #2,#3 to #4,#5 */ + _goto_window, /* Got to window #1 */ + _hangup, /* Hang-up phone */ + _dial_phone, /* Dial phone number #1 */ + _quick_dial, /* Dial phone number #1, without progress detection */ + _tone, /* Select touch tone dialing */ + _pulse, /* Select pulse dialing */ + _flash_hook, /* Flash the switch hook */ + _fixed_pause, /* Pause for 2-3 seconds */ + _wait_tone, /* Wait for dial tone */ + _user0, /* User string 0 */ + _user1, /* User string 1 */ + _user2, /* User string 2 */ + _user3, /* User string 3 */ + _user4, /* User string 4 */ + _user5, /* User string 5 */ + _user6, /* User string 6 */ + _user7, /* User string 7 */ + _user8, /* User string 8 */ + _user9, /* User string 9 */ + _orig_pair, /* Original color-pair */ + _orig_colors, /* Original colors */ + _initialize_color; /* Initialize the definition of color */ +}; + +struct strs4 { + charptr + _initialize_pair, /* Initialize color pair */ + _set_color_pair, /* Set color pair */ + _set_foreground, /* Set foreground color using RGB escape */ + _set_background, /* Set background color using RGB escape */ + _change_char_pitch, /* Change no. characters per inch */ + _change_line_pitch, /* Change no. lines per inch */ + _change_res_horz, /* Change horizontal resolution */ + _change_res_vert, /* Change vertical resolution */ + _define_char, /* Define a character in a character set */ + _entr_doublewide_mode, /* Enable double wide printing */ + _entr_draft_quality, /* Set draft quality print */ + _entr_italics_mode, /* Enable italics */ + _entr_leftward_mode, /* Enable leftward carriage motion */ + _entr_micro_mode, /* Enable micro motion capabilities */ + _entr_near_letter_quality, /* Set near-letter quality print */ + _entr_normal_quality, /* Set normal quality print */ + _entr_shadow_mode, /* Enable shadow printing */ + _entr_subscript_mode, /* Enable subscript printing */ + _entr_superscript_mode, /* Enable superscript printing */ + _entr_upward_mode, /* Enable upward carriage motion */ + _exit_doublewide_mode, /* Disable double wide printing */ + _exit_italics_mode, /* Disable italics */ + _exit_leftward_mode, /* Enable rightward (normal) carriage motion */ + _exit_micro_mode, /* Disable micro motion capabilities */ + _exit_shadow_mode, /* Disable shadow printing */ + _exit_subscript_mode, /* Disable subscript printing */ + _exit_superscript_mode, /* Disable superscript printing */ + _exit_upward_mode, /* Enable downward (normal) carriage motion */ + _micro_column_address, /* Like column_address for micro adjustment */ + _micro_down, /* Like cursor_down for micro adjustment */ + _micro_left, /* Like cursor_left for micro adjustment */ + _micro_right, /* Like cursor_right for micro adjustment */ + _micro_row_address, /* Like row_address for micro adjustment */ + _micro_up, /* Like cursor_up for micro adjustment */ + _order_of_pins, /* Matches software bits to print-head pins */ + _prm_down_micro, /* Like parm_down_cursor for micro adjust. */ + _prm_left_micro, /* Like parm_left_cursor for micro adjust. */ + _prm_right_micro, /* Like parm_right_cursor for micro adjust. */ + _prm_up_micro, /* Like parm_up_cursor for micro adjust. */ + _select_char_set, /* Select character set */ + _set_bottom_margin, /* Set soft bottom margin at current line */ + _set_bottom_margin_parm, /* Set soft bottom margin */ + _set_left_margin_parm, /* Set soft left margin */ + _set_right_margin_parm, /* Set soft right margin */ + _set_top_margin, /* Set soft top margin at current line */ + _set_top_margin_parm, /* Set soft top margin */ + _start_bit_image, /* Start printing bit image graphics */ + _start_char_set_def, /* Start definition of a character set */ + _stop_bit_image, /* End printing bit image graphics (use tputs) */ + _stop_char_set_def, /* End definition of a character set */ + _subscript_characters, /* List of ``subscript-able'' characters */ + _superscript_characters, /* List of ``superscript-able'' characters */ + _these_cause_cr, /* Printing any of these chars causes cr */ + _zero_motion, /* No motion for the subsequent character */ + _char_set_names, /* List of character set names */ + _ky_mouse, /* KEY_MOUSE, 0631, Mouse event has occured */ + _mouse_info, /* Mouse status information */ + _req_mouse_pos, /* Request mouse position report */ + _get_mouse, /* Curses should get button events */ + _set_a_foreground, /* Set foreground color using ANSI escape */ + _set_a_background, /* Set background color using ANSI escape */ + _pkey_plab, /* Prog key #1 to xmit string #2 and show string #3 */ + _device_type, /* Indicate language/codeset support */ + _code_set_init, /* Init sequence for multiple codesets */ + _set0_des_seq, /* Shift into codeset 0 (EUC set 0, ASCII) */ + _set1_des_seq, /* Shift into codeset 1 */ + _set2_des_seq, /* Shift into codeset 2 */ + _set3_des_seq, /* Shift into codeset 3 */ + _set_lr_margin, /* Sets both left and right margins */ + _set_tb_margin, /* Sets both top and bottom margins */ + _bit_image_repeat, /* Repeat bit-image cell #1 #2 times (use tparm) */ + _bit_image_newline, /* Move to next row of the bit image (use tparm) */ + _bit_image_carriage_return, /* Move to beginning of same row (use tparm) */ + _color_names, /* Give name for color #1 */ + _define_bit_image_region, /* Define rectangular bit-image region (use tparm) */ + _end_bit_image_region, /* End a bit-image region (use tparm) */ + _set_color_band, /* Change to ribbon color #1 */ + _set_page_length, /* Set page length to #1 lines (use tparm) */ + _display_pc_char, /* Display PC character */ + _entr_pc_charset_mode, /* Enter PC character display mode */ + _exit_pc_charset_mode, /* Disable PC character display mode */ + _entr_scancode_mode, /* Enter PC scancode mode */ + _exit_scancode_mode, /* Disable PC scancode mode */ + _pc_term_options, /* PC terminal options */ + _scancode_escape, /* Escape for scancode emulation */ + _alt_scancode_esc, /* Alternate escape for scancode emulation */ + _entr_horizontal_hl_mode, /* Horizontal highlight mode */ + _entr_left_hl_mode, /* Left highlight mode */ + _entr_low_hl_mode, /* Low highlight mode */ + _entr_right_hl_mode, /* Right highlight mode */ + _entr_top_hl_mode, /* Top highlight mode */ + _entr_vertical_hl_mode, /* Vertical highlight mode */ + _set_a_attributes, /* Define second set of attributes #1-#6 */ + _set_pglen_inch, /* Set page length to #1/100 of an inch */ + Sentinel; /* End of strings. DO NOT MOVE! */ +}; + +struct _bool_struct { + char + _auto_left_margin, /* cub1 wraps from column 0 to last column */ + _auto_right_margin, /* Terminal has automatic margins */ + _no_esc_ctlc, /* Beehive (f1=escape, f2=ctrl C) */ + _ceol_standout_glitch, /* Standout not erased by overwriting (hp) */ + _eat_newline_glitch, /* newline ignored after 80 cols (Concept) */ + _erase_overstrike, /* Can erase overstrikes with a blank */ + _generic_type, /* Generic line type (e.g. dialup, switch). */ + _hard_copy, /* Hardcopy terminal */ + _has_meta_key, /* Has a meta key (shift, sets parity bit) */ + _has_status_line, /* Has extra "status line" */ + _ins_null_glitch, /* Insert mode distinguishes nulls */ + _mem_above, /* Display may be retained above the screen */ + _mem_below, /* Display may be retained below the screen */ + _move_insert_mode, /* Safe to move while in insert mode */ + _move_standout_mode, /* Safe to move in standout modes */ + _over_strike, /* Terminal overstrikes */ + _status_line_esc_ok, /* Escape can be used on the status line */ + _dest_tabs_magic_smso, /* Tabs destructive, magic so char (t1061) */ + _tilde_glitch, /* Hazeltine; can't print ~'s */ + _transparent_underline, /* underline character overstrikes */ + _xon_xoff, /* Terminal uses xon/xoff handshaking */ + _needs_xon_xoff, /* Padding won't work, xon/xoff required */ + _prtr_silent, /* Printer won't echo on screen. */ + _hard_cursor, /* Cursor is hard to see. */ + _non_rev_rmcup, /* Smcup does not reverse rmcup. */ + _no_pad_char, /* Pad character doesn't exist. */ + _non_dest_scroll_region, /* Scrolling region is non-destructive. */ + _can_change, /* Can re-define existing color */ + _back_color_erase, /* Erases screen with current background */ + _hue_lightness_saturation, /* HLS color notation is used (Tek) */ + _col_addr_glitch, /* Only positive motion for hpa/mhpa caps */ + _cr_cancels_micro_mode, /* Using cr turns off micro mode */ + _has_print_wheel, /* Printer needs operator to change character set */ + _row_addr_glitch, /* Only positive motion for vpa/mvpa caps */ + _semi_auto_right_margin, /* Printing in last column causes cr */ + _cpi_changes_res, /* Changing char. pitch changes resolution */ + _lpi_changes_res, /* Changing line pitch changes resolution */ + Sentinel; /* End of bools. DO NOT MOVE! */ +}; + +struct _num_struct { + short + _columns, /* Number of columns in a line */ + _init_tabs, /* Tabs initially every # spaces. */ + _lines, /* Number of lines on screen or page */ + _lines_of_memory, /* Lines of memory if > lines. 0 => varies */ + _magic_cookie_glitch, /* Number blank chars left by smso or rmso */ + _padding_baud_rate, /* Lowest baud rate where padding needed */ + _virtual_terminal, /* Virtual terminal number (CB/Unix) */ + _width_status_line, /* # columns in status line */ + _num_labels, /* # of labels on screen (start at 1) */ + _labl_height, /* # rows in each label */ + _labl_width, /* # cols in each label */ + _max_attributes, /* max combined video attributes terminal can display */ + _maximum_windows, /* Maximum number of defineable windows */ + _max_colors, /* max # of color on the screen */ + _max_pairs, /* max # of color pairs on the screen */ + _no_color_video, /* Video attributes that cannot be used with colors */ + _buffer_capacity, /* Number of bytes buffered before printing */ + _dot_vert_spacing, /* Spacing of pins vertically in pins per inch */ + _dot_horz_spacing, /* Spacing of dots horizontally in dots per inch */ + _max_micro_address, /* Maximum value in micro_..._address */ + _max_micro_jump, /* Maximum value in parm_..._micro */ + _micro_char_size, /* Character step size when in micro mode */ + _micro_line_size, /* Line step size when in micro mode */ + _number_of_pins, /* Number of pins in print-head */ + _output_res_char, /* Horizontal resolution in units per character */ + _output_res_line, /* Vertical resolution in units per line */ + _output_res_horz_inch, /* Horizontal resolution in units per inch */ + _output_res_vert_inch, /* Vertical resolution in units per inch */ + _print_rate, /* Print rate in characters per second */ + _wide_char_size, /* Character step size when in double wide mode */ + _buttons, /* Number of buttons on the mouse */ + _bit_image_entwining, /* Number of passes for each bit-image row */ + _bit_image_type, /* Type of bit-image device */ + Sentinel; /* End of nums. DO NOT MOVE! */ +}; + +struct _str_struct { + struct strs strs; + struct strs2 strs2; + struct strs3 strs3; + struct strs4 strs4; +}; + +#define NUM_ATTRIBUTES 9 +#define UNACCESSIBLE 1 +#define NO_TERMINAL 2 +#define CORRUPTED 3 +#define ENTRY_TOO_LONG 4 +#define TERMINFO_TOO_LONG 5 +#define TERM_BAD_MALLOC 6 +#define NOT_READABLE 7 +#define _VR2_COMPAT_CODE +#ifdef _VR2_COMPAT_CODE +struct _Vr2_Astrs { + charptr + _s1, _s2, _s3, _s4, _s5, _s6, _s7, _s8, _s9, _s10, + _s11, _s12, _s13, _s14, _s15, _s16, _s17, _s18, _s19, _s20, + _s21, _s22, _s23, _s24, _s25, _s26, _s27, _s28, _s29, _s30, + _s31, _s32, _s33, _s34, _s35, _s36, _s37, _s38, _s39, _s40, + _s41, _s42, _s43, _s44, _s45, _s46, _s47, _s48, _s49, _s50, + _s51, _s52, _s53, _s54, _s55, _s56, _s57, _s58, _s59, _s60, + _s61, _s62, _s63, _s64, _s65, _s66, _s67, _s68, _s69, _s70, + _s71, _s72, _s73, _s74, _s75, _s76, _s77, _s78, _s79, _s80, + _s81, _s82, _s83, _s84, _s85, _s86, _s87, _s88, _s89, _s90, + _s91, _s92, _s93, _s94, _s95, _s96, _s97, _s98, _s99, _s100; +}; + +struct _Vr2_Bstrs { + charptr + _s101, _s102, _s103, _s104, _s105, _s106, _s107, _s108, _s109, _s110, + _s111, _s112, _s113, _s114, _s115, _s116, _s117, _s118, _s119, _s120, + _s121, _s122, _s123, _s124, _s125, _s126, _s127, _s128, _s129, _s130, + _s131, _s132, _s133, _s134, _s135, _s136, _s137, _s138, _s139, _s140, + _s141, _s142, _s143, _s144, _s145; +}; +#endif /* _VR2_COMPAT_CODE */ + +typedef struct { + char *_sends; /* Characters sent when key is pressed */ + short _keyval; /* "char" we pass back to program */ +} _KEY_MAP; + +typedef struct { + short foreground; /* foreground color */ + short background; /* background color */ + bool init; /* TRUE if pair was initialized */ +} _Color_pair; + + +typedef struct { + short r, g, b; +} _Color; + + +/* + * This definition for the term struct allows the boolean, number + * and string information to grow in the future and still allow .o + * compatibility. + */ + +struct term { +#ifdef _VR2_COMPAT_CODE + char + _b1, _b2, _b3, _b4, _b5, _b6, _b7, _b8, _b9, _b10, + _b11, _b12, _b13, _b14, _b15, _b16, _b17, _b18, _b19, _b20, _b21; + short + _c1, _c2, _c3, _c4, _c5, _c6, _c7, _c8; + struct _Vr2_Astrs _Vr2_Astrs; + struct _Vr2_Bstrs _Vr2_Bstrs; +#endif /* _VR2_COMPAT_CODE */ + short Filedes; /* file descriptor being written to */ + SGTTY Ottyb, /* original state of the terminal */ + Nttyb; /* current state of the terminal */ +#ifdef SYSV + SGTTYS Ottybs, /* original state of the terminal */ + Nttybs; /* current state of the terminal */ +#endif +#ifdef DIOCSETT + struct termcb new, old; /* CB/UNIX virtual terminals */ +#endif +#ifdef LTILDE + int newlmode, oldlmode; /* BSD tty driver */ +#endif + /* end of Vr2 structure */ + struct _bool_struct *_bools; + struct _num_struct *_nums; + struct _str_struct *_strs; + char *_strtab; +#ifdef FIONREAD + long timeout; /* for BSD halfdelay mode */ +#endif + /* end of Vr3 structure */ + chtype sgr_mode; /* current phys. graphic rendition */ + chtype sgr_faked; /* attributes faked by vidputs */ + int _delay; /* timeout for inputs */ + int _inputfd; /* input file descriptor */ + int _check_fd; /* typeahead file descriptor */ + _KEY_MAP **_keys, /* key map */ + *internal_keys; /* pointer to free key structures */ + short _ksz, /* size of keymap */ + _lastkey_ordered, /* where the last ordered key is */ + _lastmacro_ordered, /* where last ordered macro is */ + _first_macro; + bool funckeystarter[0400]; + /* map of which chars start fn keys */ + bool _fl_rawmode, /* in cbreak(=1) or raw(=2) mode */ + fl_typeahdok, /* ok to use typeahead */ + _cursorstate, /* cursor: 0=invis, 1=norm, 2=vvis */ + _iwait; /* true if input-pending */ + short _regs[26]; /* tparm static registers */ +#define INP_QSIZE 32 + chtype /* a place to put stuff ungetch'ed */ + _input_queue[INP_QSIZE]; + short _ungotten; /* # chars ungotten by ungetch() */ + char _chars_on_queue; /* # chars on queue */ +#ifdef _VR3_COMPAT_CODE + _ochtype *_acsmap; + chtype *_acs32map; /* map of alternate char set chars */ +#else /* _VR3_COMPAT_CODE */ + chtype *_acsmap; /* map of alternate char set chars */ +#endif /* _VR3_COMPAT_CODE */ + char *turn_on_seq[NUM_ATTRIBUTES]; + chtype bit_vector; + char *cursor_seq[3]; + char _termname[15]; + char *turn_off_seq[3]; + chtype check_turn_off; + chtype non_faked_mode; + _Color_pair _cur_pair; + _Color_pair *_pairs_tbl; + _Color *_color_tbl; +}; + +typedef struct term TERMINAL; + +/* allow old names for these capabilities */ +#define beehive_glitch no_esc_ctlc +#define teleray_glitch dest_tabs_magic_smso + +extern TERMINAL *cur_term; +extern struct _bool_struct *cur_bools; +extern struct _num_struct *cur_nums; +extern struct _str_struct *cur_strs; + +#ifdef SINGLE +extern TERMINAL _first_term; +extern struct _bool_struct _frst_bools; +extern struct _num_struct _frst_nums; +extern struct _str_struct _frst_strs; + +#define CUR _first_term. +#define CURB _frst_bools. +#define CURN _frst_nums. +#define CURS _frst_strs. +#define PROGTTY _first_term.Nttyb +#define SHELLTTY _first_term.Ottyb +#ifdef SYSV +#define PROGTTYS _first_term.Nttybs +#define SHELLTTYS _first_term.Ottybs +#endif +#else +#define CUR cur_term-> +#define CURB cur_bools-> +#define CURN cur_nums-> +#define CURS cur_strs-> +#define PROGTTY (cur_term->Nttyb) +#define SHELLTTY (cur_term->Ottyb) +#ifdef SYSV +#define PROGTTYS (cur_term->Nttybs) +#define SHELLTTYS (cur_term->Ottybs) +#endif +#endif + +#ifndef NOMACROS +#define set_curterm setcurterm +#define del_curterm delterm +#else /* NOMACROS */ + +#ifdef __STDC__ +extern TERMINAL *set_curterm(TERMINAL *); +extern int del_curterm(TERMINAL *); +#else /* __STDC__ */ +extern TERMINAL *set_curterm(); +extern int del_curterm(); +#endif /* __STDC__ */ + +#endif /* NOMACROS */ + +extern short term_errno; + +#ifdef SYSV +extern int prog_istermios; +extern int shell_istermios; +#endif + +extern char term_parm_err[], *term_err_strings[], *Def_term, + *boolnames[], *boolcodes[], *boolfnames[], + *numnames[], *numcodes[], *numfnames[], + *strnames[], *strcodes[], *strfnames[]; + +#ifdef __STDC__ +extern TERMINAL *setcurterm(TERMINAL *); + +#if defined(_XPG4_2) || defined(_LP64) || defined(__cplusplus) +extern char + *tparm(char *, long, long, long, long, long, long, long, long, long); +#else +/* this is wrong, but is needed for historical reasons */ +extern char *tparm(); +#endif + +extern char *tgoto(char *, int, int), + *tgetstr(char *, char **), + *tigetstr(char *), + *termname(void); + +extern int tgetent(char *, char *), tgetflag(char *), tgetnum(char *), + tputs(char *, int, int (*)(char)), putp(char *), + tigetint(char *), tigetflag(char *), tigetnum(char *), + vidputs(chtype, int (*)(char)), vidattr(chtype); + +extern int resetterm(void), fixterm(void), saveterm(void), + restartterm(char *, int, int *), delterm(TERMINAL *); + +extern void termerr(void), tinputfd(int); +#else /* __STDC__ */ +extern TERMINAL *setcurterm(); +extern char *tparm(), *tgoto(), *tgetstr(), *tigetstr(), + *termname(); + +extern int tgetent(), tgetflag(), tgetnum(), + tigetint(), tigetflag(), tigetnum(), + tputs(), putp(), vidputs(), vidattr(); + +extern int resetterm(), fixterm(), saveterm(), + restartterm(), delterm(); + +extern void termerr(), tinputfd(); +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TERM_H */ diff --git a/illumos-x86_64/usr/include/termcap.h b/illumos-x86_64/usr/include/termcap.h new file mode 100644 index 00000000..20cd9bcb --- /dev/null +++ b/illumos-x86_64/usr/include/termcap.h @@ -0,0 +1,53 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _TERMCAP_H_ +#define _TERMCAP_H_ + +/* + * This declares the public functions exported by the + * "filter" library: libtermcap. That exports only + * the traditional BSD-style functions and data. + * + * Note that the libtermcap filter library uses NODIRECT + * linker bindings when filtering what libcurses exports + * so that an application can link with an alternative + * curses library providing the symbols below, and those + * will be used instead of the ones in libcurses. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char PC, *UP, *BC; +extern short ospeed; + +/* + * These are intentionally the same as term.h declares + * so the compiler won't bark if you include that too. + */ +extern int tgetent(char *, char *); +extern int tgetflag(char *); +extern int tgetnum(char *); +extern char *tgetstr(char *, char **); +extern char *tgoto(char *, int, int); +extern int tputs(char *, int, int (*)(char)); + +#ifdef __cplusplus +} +#endif + +#endif /* _TERMCAP_H_ */ diff --git a/illumos-x86_64/usr/include/termio.h b/illumos-x86_64/usr/include/termio.h new file mode 100644 index 00000000..03320519 --- /dev/null +++ b/illumos-x86_64/usr/include/termio.h @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _TERMIO_H +#define _TERMIO_H + +#include + +#endif /* _TERMIO_H */ diff --git a/illumos-x86_64/usr/include/termios.h b/illumos-x86_64/usr/include/termios.h new file mode 100644 index 00000000..926b062c --- /dev/null +++ b/illumos-x86_64/usr/include/termios.h @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _TERMIOS_H +#define _TERMIOS_H + +#include + +#endif /* _TERMIOS_H */ diff --git a/illumos-x86_64/usr/include/tgmath.h b/illumos-x86_64/usr/include/tgmath.h new file mode 100644 index 00000000..c5b2c519 --- /dev/null +++ b/illumos-x86_64/usr/include/tgmath.h @@ -0,0 +1,171 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _TGMATH_H +#define _TGMATH_H + +#if !defined(__cplusplus) + +#include +#include + +/* + * real-floating and complex + */ +#undef acos +#define acos(x) __tgmath_acos(x) +#undef asin +#define asin(x) __tgmath_asin(x) +#undef atan +#define atan(x) __tgmath_atan(x) +#undef acosh +#define acosh(x) __tgmath_acosh(x) +#undef asinh +#define asinh(x) __tgmath_asinh(x) +#undef atanh +#define atanh(x) __tgmath_atanh(x) +#undef cos +#define cos(x) __tgmath_cos(x) +#undef sin +#define sin(x) __tgmath_sin(x) +#undef tan +#define tan(x) __tgmath_tan(x) +#undef cosh +#define cosh(x) __tgmath_cosh(x) +#undef sinh +#define sinh(x) __tgmath_sinh(x) +#undef tanh +#define tanh(x) __tgmath_tanh(x) +#undef exp +#define exp(x) __tgmath_exp(x) +#undef log +#define log(x) __tgmath_log(x) +#undef pow +#define pow(x, y) __tgmath_pow(x, y) +#undef sqrt +#define sqrt(x) __tgmath_sqrt(x) +#undef fabs +#define fabs(x) __tgmath_fabs(x) + +/* + * real-floating only + */ +#undef atan2 +#define atan2(y, x) __tgmath_atan2(y, x) +#undef cbrt +#define cbrt(x) __tgmath_cbrt(x) +#undef ceil +#define ceil(x) __tgmath_ceil(x) +#undef copysign +#define copysign(x, y) __tgmath_copysign(x, y) +#undef erf +#define erf(x) __tgmath_erf(x) +#undef erfc +#define erfc(x) __tgmath_erfc(x) +#undef exp2 +#define exp2(x) __tgmath_exp2(x) +#undef expm1 +#define expm1(x) __tgmath_expm1(x) +#undef fdim +#define fdim(x, y) __tgmath_fdim(x, y) +#undef floor +#define floor(x) __tgmath_floor(x) +#undef fma +#define fma(x, y, z) __tgmath_fma(x, y, z) +#undef fmax +#define fmax(x, y) __tgmath_fmax(x, y) +#undef fmin +#define fmin(x, y) __tgmath_fmin(x, y) +#undef fmod +#define fmod(x, y) __tgmath_fmod(x, y) +#undef frexp +#define frexp(x, ip) __tgmath_frexp(x, ip) +#undef hypot +#define hypot(x, y) __tgmath_hypot(x, y) +#undef ilogb +#define ilogb(x) __tgmath_ilogb(x) +#undef ldexp +#define ldexp(x, i) __tgmath_ldexp(x, i) +#undef lgamma +#define lgamma(x) __tgmath_lgamma(x) +#undef llrint +#define llrint(x) __tgmath_llrint(x) +#undef llround +#define llround(x) __tgmath_llround(x) +#undef log10 +#define log10(x) __tgmath_log10(x) +#undef log1p +#define log1p(x) __tgmath_log1p(x) +#undef log2 +#define log2(x) __tgmath_log2(x) +#undef logb +#define logb(x) __tgmath_logb(x) +#undef lrint +#define lrint(x) __tgmath_lrint(x) +#undef lround +#define lround(x) __tgmath_lround(x) +#undef nearbyint +#define nearbyint(x) __tgmath_nearbyint(x) +#undef nextafter +#define nextafter(x, y) __tgmath_nextafter(x, y) +#undef nexttoward +#define nexttoward(x, y) __tgmath_nexttoward(x, y) +#undef remainder +#define remainder(x, y) __tgmath_remainder(x, y) +#undef remquo +#define remquo(x, y, ip) __tgmath_remquo(x, y, ip) +#undef rint +#define rint(x) __tgmath_rint(x) +#undef round +#define round(x) __tgmath_round(x) +#undef scalbln +#define scalbln(x, l) __tgmath_scalbln(x, l) +#undef scalbn +#define scalbn(x, i) __tgmath_scalbn(x, i) +#undef tgamma +#define tgamma(x) __tgmath_tgamma(x) +#undef trunc +#define trunc(x) __tgmath_trunc(x) + +/* + * complex only + */ +#undef carg +#define carg(x) __tgmath_carg(x) +#undef cimag +#define cimag(x) __tgmath_cimag(x) +#undef conj +#define conj(x) __tgmath_conj(x) +#undef cproj +#define cproj(x) __tgmath_cproj(x) +#undef creal +#define creal(x) __tgmath_creal(x) + +#endif /* !defined(__cplusplus) */ + +#endif /* _TGMATH_H */ diff --git a/illumos-x86_64/usr/include/thread.h b/illumos-x86_64/usr/include/thread.h new file mode 100644 index 00000000..704174d4 --- /dev/null +++ b/illumos-x86_64/usr/include/thread.h @@ -0,0 +1,132 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _THREAD_H +#define _THREAD_H + +/* + * thread.h: + * definitions needed to use the thread interface except synchronization. + * use for thread synchronization. + */ + +#ifndef _ASM +#include +#include +#include +#endif /* _ASM */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM +typedef unsigned int thread_t; +typedef unsigned int thread_key_t; + +extern int thr_create(void *, size_t, void *(*)(void *), void *, long, + thread_t *); +extern int thr_join(thread_t, thread_t *, void **); +extern int thr_setconcurrency(int); +extern int thr_getconcurrency(void); +extern void thr_exit(void *) __NORETURN; +extern thread_t thr_self(void); + +/* + * the definition of thr_sigsetmask() is not strict ansi-c since sigset_t is + * not in the strict ansi-c name space. Hence, include the prototype for + * thr_sigsetmask() only if strict ansi-c conformance is not turned on. + */ +#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) +extern int thr_sigsetmask(int, const sigset_t *, sigset_t *); +#endif + +/* + * the definition of thr_stksegment() is not strict ansi-c since stack_t is + * not in the strict ansi-c name space. Hence, include the prototype for + * thr_stksegment() only if strict ansi-c conformance is not turned on. + */ +#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) +extern int thr_stksegment(stack_t *); +#endif + +extern int thr_main(void); +extern int thr_kill(thread_t, int); +extern int thr_suspend(thread_t); +extern int thr_continue(thread_t); +extern void thr_yield(void); +extern int thr_setprio(thread_t, int); +extern int thr_getprio(thread_t, int *); +extern int thr_keycreate(thread_key_t *, void(*)(void *)); +extern int thr_keycreate_once(thread_key_t *, void(*)(void *)); +extern int thr_setspecific(thread_key_t, void *); +extern int thr_getspecific(thread_key_t, void **); +extern size_t thr_min_stack(void); +extern int thr_getname(thread_t, char *, size_t); +extern int thr_setname(thread_t, const char *); + +#endif /* _ASM */ + +#define THR_MIN_STACK thr_min_stack() +/* + * thread flags (one word bit mask) + */ +/* + * POSIX.1c Note: + * THR_BOUND is defined same as PTHREAD_SCOPE_SYSTEM in + * THR_DETACHED is defined same as PTHREAD_CREATE_DETACHED in + * Any changes in these definitions should be reflected in + */ +#define THR_BOUND 0x00000001 /* = PTHREAD_SCOPE_SYSTEM */ +#define THR_NEW_LWP 0x00000002 +#define THR_DETACHED 0x00000040 /* = PTHREAD_CREATE_DETACHED */ +#define THR_SUSPENDED 0x00000080 +#define THR_DAEMON 0x00000100 + +/* + * The key to be created by thr_keycreate_once() + * must be statically initialized with THR_ONCE_KEY. + * This must be the same as PTHREAD_ONCE_KEY_NP in + */ +#define THR_ONCE_KEY (thread_key_t)(-1) + +/* + * The available register states returned by thr_getstate(). + */ +#define TRS_VALID 0 +#define TRS_NONVOLATILE 1 +#define TRS_LWPID 2 +#define TRS_INVALID 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _THREAD_H */ diff --git a/illumos-x86_64/usr/include/thread_db.h b/illumos-x86_64/usr/include/thread_db.h new file mode 100644 index 00000000..d3d5b51f --- /dev/null +++ b/illumos-x86_64/usr/include/thread_db.h @@ -0,0 +1,690 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _THREAD_DB_H +#define _THREAD_DB_H + +/* + * + * Description: + * Types, global variables, and function definitions for users + * of libc_db (formerly libthread_db). + * + */ + + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TD_THR_ANY_USER_FLAGS 0xffffffff +#define TD_THR_LOWEST_PRIORITY -128 +#define TD_SIGNO_MASK 0 +#define TD_EVENTSIZE 2 + +/* + * Opaque handle types. + */ + +/* Client's handle for a process */ +struct ps_prochandle; + +/* libthread's handle for a process */ +typedef struct td_thragent td_thragent_t; + +/* The thread handle. */ +typedef struct td_thrhandle { + td_thragent_t *th_ta_p; + psaddr_t th_unique; +} td_thrhandle_t; + +/* The handle for a synchronization object. */ +typedef struct td_synchandle { + td_thragent_t *sh_ta_p; + psaddr_t sh_unique; +} td_synchandle_t; + +/* ------------------------------------------------------------------ */ + +/* + * The libc_db event facility. + */ +#define BT_UISHIFT 5 /* log base 2 of BT_NBIPUI, to extract word index */ +#define BT_NBIPUI (1 << BT_UISHIFT) /* n bits per uint */ +#define BT_UIMASK (BT_NBIPUI - 1) /* to extract bit index */ + +/* Bitmask of enabled events. */ +typedef struct td_thr_events { + uint_t event_bits[TD_EVENTSIZE]; +} td_thr_events_t; + +/* Event set manipulation macros. */ +#define __td_eventmask(n) ((unsigned int)1 << (((n) - 1) \ + & (BT_NBIPUI - 1))) +#define __td_eventword(n) (((unsigned int)((n) - 1))>>5) + +#define td_event_emptyset(setp) \ + { \ + int _i_; \ + _i_ = TD_EVENTSIZE; \ + while (_i_) (setp)->event_bits[--_i_] = 0; \ + } + +#define td_event_fillset(setp) \ + { \ + int _i_; \ + _i_ = TD_EVENTSIZE; \ + while (_i_) (setp)->event_bits[--_i_] = \ + 0xffffffff; \ + } + +#define td_event_addset(setp, n) \ + (((setp)->event_bits[__td_eventword(n)]) |= __td_eventmask(n)) +#define td_event_delset(setp, n) \ + (((setp)->event_bits[__td_eventword(n)]) &= ~__td_eventmask(n)) +#define td_eventismember(setp, n) \ + (__td_eventmask(n) & ((setp)->event_bits[__td_eventword(n)])) +#define td_eventisempty(setp) \ + (!((setp)->event_bits[0]) && !((setp)->event_bits[1])) + +typedef enum { + TD_ALL_EVENTS, /* pseudo-event number */ + TD_EVENT_NONE = TD_ALL_EVENTS, /* depends on context */ + TD_READY, + TD_SLEEP, + TD_SWITCHTO, + TD_SWITCHFROM, + TD_LOCK_TRY, + TD_CATCHSIG, + TD_IDLE, + TD_CREATE, + TD_DEATH, + TD_PREEMPT, + TD_PRI_INHERIT, + TD_REAP, + TD_CONCURRENCY, + TD_TIMEOUT, + TD_MIN_EVENT_NUM = TD_READY, + TD_MAX_EVENT_NUM = TD_TIMEOUT, + TD_EVENTS_ENABLE = 31 /* Event reporting enabled */ +} td_event_e; + +/* + * Ways that an event type can be reported. + */ +typedef enum { + NOTIFY_BPT, + /* + * bpt to be inserted at u.bptaddr by + * debugger + */ + NOTIFY_AUTOBPT, /* bpt inserted at u.bptaddr by application */ + NOTIFY_SYSCALL /* syscall u.syscallno will be invoked */ +} td_notify_e; + +/* + * How an event type is reported. + */ +typedef struct td_notify { + td_notify_e type; + union { + psaddr_t bptaddr; + int syscallno; + } u; +} td_notify_t; + +/* + * An event message. + */ +typedef struct td_event_msg { + td_event_e event; /* Event type being reported */ + const td_thrhandle_t *th_p; /* Thread reporting the event */ + union { /* Type-dependent event data */ + td_synchandle_t *sh; /* historical rubbish; ignore */ + uintptr_t data; /* valid, depending on event type */ + } msg; +} td_event_msg_t; + +/* --------------------------------------------------------------------- */ + +/* + * Thread information structure as returned by td_thr_get_info(), and + * related types. + */ + +/* + * Possible thread states. TD_THR_ANY_STATE is a pseudo-state used + * to select threads regardless of state in td_ta_thr_iter(). + */ +typedef enum { + TD_THR_ANY_STATE, + TD_THR_UNKNOWN, + TD_THR_STOPPED, + TD_THR_RUN, + TD_THR_ACTIVE, + TD_THR_ZOMBIE, + TD_THR_SLEEP, + TD_THR_STOPPED_ASLEEP +} td_thr_state_e; + +/* + * Thread type: user or system. + * As of Solaris 9, all threads are type TD_THR_USER. + */ +typedef enum { + TD_THR_ANY_TYPE, /* not used */ + TD_THR_USER, + TD_THR_SYSTEM +} td_thr_type_e; + +typedef struct td_thrinfo { + td_thragent_t *ti_ta_p; /* process handle */ + unsigned ti_user_flags; /* flags passed to thr_create() */ + thread_t ti_tid; /* tid returned by thr_create() */ + void *ti_exitval; /* thread exit value (TD_THR_ZOMBIE) */ + psaddr_t ti_startfunc; /* startfunc passed to thr_create() */ + psaddr_t ti_stkbase; /* base of thread's stack */ + long ti_stksize; /* size of thread's stack */ + psaddr_t ti_ro_area; /* address of uthread_t struct */ + int ti_ro_size; /* size of uthread_t struct */ + td_thr_state_e ti_state; /* thread state */ + uchar_t ti_db_suspended; /* boolean: suspended by debugger? */ + td_thr_type_e ti_type; /* thread type */ + intptr_t ti_pc; /* resume PC when sleeping */ + intptr_t ti_sp; /* resume SP when sleeping */ + short ti_flags; /* flags used by libthread */ + int ti_pri; /* thread priority */ + lwpid_t ti_lid; /* last LWP assigned to this thread */ + sigset_t ti_sigmask; /* signal mask */ + uchar_t ti_traceme; /* event reporting enabled? */ + uchar_t ti_preemptflag; /* was thread preemppted? */ + uchar_t ti_pirecflag; /* priority inheritance happened */ + sigset_t ti_pending; /* set of pending signals */ + td_thr_events_t ti_events; /* set of enabled events */ +} td_thrinfo_t; + +#define ti_tls ti_exitval /* for source compatibility */ + +typedef struct td_ta_stats { + int nthreads; /* total number of threads in use */ + int r_concurrency; /* requested concurrency level */ + int nrunnable_num; /* numerator, avg. runnable threads */ + int nrunnable_den; /* denominator, avg. runnable threads */ + int a_concurrency_num; /* numerator, achieved concurrency level */ + int a_concurrency_den; /* denominator, concurrency level */ + int nlwps_num; /* numerator, average number of LWP's in use */ + int nlwps_den; /* denom., average number of LWP's in use */ + int nidle_num; /* numerator, avg. number of idling LWP's */ + int nidle_den; /* denom., avg. number of idling LWP's */ +} td_ta_stats_t; + +/* + * Iterator callback function declarations. + */ + +/* Callback function for td_ta_tsd_iter(). */ +typedef int td_key_iter_f(thread_key_t, void (*destructor)(), void *); + +/* Callback function for td_ta_thr_iter(). */ +typedef int td_thr_iter_f(const td_thrhandle_t *, void *); + +/* Callback function for td_ta_sync_iter(). */ +typedef int td_sync_iter_f(const td_synchandle_t *, void *); + +/* -------------------------------------------------------------------- */ + +/* + * Synchronization Objects + */ + +/* Enumeration of synchronization object types. */ +typedef enum td_sync_type_e { + TD_SYNC_UNKNOWN, /* Sync. variable of unknown type */ + TD_SYNC_COND, /* Condition variable */ + TD_SYNC_MUTEX, /* Mutex lock */ + TD_SYNC_SEMA, /* Semaphore */ + TD_SYNC_RWLOCK /* Reader/Writer lock */ +} td_sync_type_e; + +#define TD_SV_MAX_FLAGS 4 +typedef uint8_t td_sync_flags_t; + +/* + * Synchronization object information structure filled in by td_sync_get_info() + */ +typedef struct td_syncinfo { + td_thragent_t *si_ta_p; /* process handle */ + psaddr_t si_sv_addr; /* address of sync. object */ + td_sync_type_e si_type; /* object type */ + uint32_t si_shared_type; /* process-shared or process-private */ + td_sync_flags_t si_flags[TD_SV_MAX_FLAGS]; /* flags (?) */ + pid_t si_ownerpid; /* owner's process-id (USYNC_PROCESS) */ + union _si_un_state { + int sem_count; /* semaphore count */ + int nreaders; /* number of readers, -1 if writer */ + int mutex_locked; /* non-zero iff locked */ + } si_state; + int si_size; /* size in bytes of synch variable */ + uint8_t si_has_waiters; /* non-zero iff at least one waiter */ + uint8_t si_is_wlock; /* non-zero iff rwlock write-locked */ + uint8_t si_rcount; /* count for locked recursive mutex */ + uint8_t si_prioceiling; /* ceiling pri (PTHREAD_PRIO_PROTECT) */ + td_thrhandle_t si_owner; /* mutex holder or write-lock holder */ + psaddr_t si_data; /* optional data */ +} td_syncinfo_t; + +/* + * Statistics structures for the various synchronization objects, contained + * within the td_syncstats structure returned by td_sync_get_stats(). + */ +typedef struct { + uint_t mutex_lock; + uint_t mutex_sleep; + hrtime_t mutex_sleep_time; + hrtime_t mutex_hold_time; + uint_t mutex_try; + uint_t mutex_try_fail; + uint_t mutex_internal; /* internal to libthread */ +} td_mutex_stats_t; + +typedef struct { + uint_t cond_wait; + uint_t cond_timedwait; + hrtime_t cond_wait_sleep_time; + hrtime_t cond_timedwait_sleep_time; + uint_t cond_timedwait_timeout; + uint_t cond_signal; + uint_t cond_broadcast; + uint_t cond_internal; /* internal to libthread */ +} td_cond_stats_t; + +typedef struct { + uint_t rw_rdlock; + uint_t rw_rdlock_sleep; + hrtime_t rw_rdlock_sleep_time; + uint_t rw_rdlock_try; + uint_t rw_rdlock_try_fail; + uint_t rw_wrlock; + uint_t rw_wrlock_sleep; + hrtime_t rw_wrlock_sleep_time; + hrtime_t rw_wrlock_hold_time; + uint_t rw_wrlock_try; + uint_t rw_wrlock_try_fail; +} td_rwlock_stats_t; + +typedef struct { + uint_t sema_wait; + uint_t sema_wait_sleep; + hrtime_t sema_wait_sleep_time; + uint_t sema_trywait; + uint_t sema_trywait_fail; + uint_t sema_post; + uint_t sema_max_count; + uint_t sema_min_count; +} td_sema_stats_t; + +/* + * Synchronization object statistics structure filled in by td_sync_get_stats() + */ +typedef struct td_syncstats { + td_syncinfo_t ss_info; /* as returned by td_sync_get_info() */ + union { + td_mutex_stats_t mutex; + td_cond_stats_t cond; + td_rwlock_stats_t rwlock; + td_sema_stats_t sema; + uint_t pad[32]; /* for future growth */ + } ss_un; +} td_syncstats_t; + +/* The set of error codes. */ +typedef enum { + TD_OK, /* generic "call succeeded" */ + TD_ERR, /* generic error. */ + TD_NOTHR, /* no thread can be found to satisfy query */ + TD_NOSV, /* no synch. handle can be found to satisfy query */ + TD_NOLWP, /* no lwp can be found to satisfy query */ + TD_BADPH, /* invalid process handle */ + TD_BADTH, /* invalid thread handle */ + TD_BADSH, /* invalid synchronization handle */ + TD_BADTA, /* invalid thread agent */ + TD_BADKEY, /* invalid key */ + TD_NOMSG, /* no event message for td_thr_event_getmsg() */ + TD_NOFPREGS, /* FPU register set not available */ + TD_NOLIBTHREAD, /* application not linked with libthread */ + TD_NOEVENT, /* requested event is not supported */ + TD_NOCAPAB, /* capability not available */ + TD_DBERR, /* Debugger service failed */ + TD_NOAPLIC, /* Operation not applicable to */ + TD_NOTSD, /* No thread-specific data for this thread */ + TD_MALLOC, /* Malloc failed */ + TD_PARTIALREG, /* Only part of register set was writen/read */ + TD_NOXREGS, /* X register set not available for given thread */ + TD_NOTLS, /* There is no TLS in the specified module */ + TD_TLSDEFER /* module's TLS not yet allocated by the thread */ +} td_err_e; + + +/* ----------------------------------------------------------------------- */ + +/* + * Exported functions. + */ + +/* + * Initialize the threads debug interface. + */ +td_err_e +td_init(void); + +/* + * A no-op, left for historical reasons. + */ +void +td_log(void); + +/* + * Allocate a new process handle ("thread agent"). + */ +td_err_e +td_ta_new(struct ps_prochandle *, td_thragent_t **); + +/* + * De-allocate a process handle, releasing all related resources. + */ +td_err_e +td_ta_delete(td_thragent_t *); + +/* + * Map a process handle to a client process handle. + */ +td_err_e +td_ta_get_ph(const td_thragent_t *, struct ps_prochandle **); + +/* + * Set the process's suggested concurrency level. + */ +td_err_e +td_ta_setconcurrency(const td_thragent_t *, int); + +/* + * Get the number of threads in the process, including zombie threads. + */ +td_err_e +td_ta_get_nthreads(const td_thragent_t *, int *); + +/* + * Map a tid, as returned by thr_create(), to a thread handle. + */ +td_err_e +td_ta_map_id2thr(const td_thragent_t *, thread_t, td_thrhandle_t *); + +/* + * Map the address of a synchronization object to a sync. object handle. + */ +td_err_e +td_ta_map_addr2sync(const td_thragent_t *, psaddr_t, td_synchandle_t *); + +/* + * Iterate over a process's thread-specific data (TSD) keys. + */ +td_err_e +td_ta_tsd_iter(const td_thragent_t *, td_key_iter_f *, void *); + +/* + * Iterate over a process's threads, including zombie threads. + */ +td_err_e +td_ta_thr_iter(const td_thragent_t *, td_thr_iter_f *, void *, + td_thr_state_e, int, sigset_t *, unsigned); + +/* + * Iterate over a process's known synchronization objects. + */ +td_err_e +td_ta_sync_iter(const td_thragent_t *, td_sync_iter_f *, void *); + +/* + * Enable/disable process statistics collection. + */ +td_err_e +td_ta_enable_stats(const td_thragent_t *, int); + +/* + * Reset process statistics. + */ +td_err_e +td_ta_reset_stats(const td_thragent_t *); + +/* + * Read process statistics. + */ +td_err_e +td_ta_get_stats(const td_thragent_t *, td_ta_stats_t *); + +/* + * Get thread information. + */ +td_err_e +td_thr_get_info(const td_thrhandle_t *, td_thrinfo_t *); + +/* + * Get the "event address" for an event type. + */ +td_err_e +td_ta_event_addr(const td_thragent_t *, td_event_e, td_notify_t *); + +/* + * Enable/disable event reporting for a thread. + */ +td_err_e +td_thr_event_enable(const td_thrhandle_t *, int); + +/* + * Enable a set of events for a thread. + */ +td_err_e +td_thr_set_event(const td_thrhandle_t *, td_thr_events_t *); + +/* + * Disable a set of events for a thread. + */ +td_err_e +td_thr_clear_event(const td_thrhandle_t *, td_thr_events_t *); + +/* + * Retrieve (and consume) an event message for a thread. + */ +td_err_e +td_thr_event_getmsg(const td_thrhandle_t *, td_event_msg_t *); + +/* + * Enable a set of events in the process. + */ +td_err_e +td_ta_set_event(const td_thragent_t *, td_thr_events_t *); + +/* + * Disable a set of events in the process. + */ +td_err_e +td_ta_clear_event(const td_thragent_t *, td_thr_events_t *); + +/* + * Retrieve (and consume) an event message for some thread in the process. + */ +td_err_e +td_ta_event_getmsg(const td_thragent_t *, td_event_msg_t *); + +/* + * Suspend a thread. + */ +td_err_e +td_thr_dbsuspend(const td_thrhandle_t *); + +/* + * Resume a suspended thread. + */ +td_err_e +td_thr_dbresume(const td_thrhandle_t *); + +/* + * Set a thread's signal mask. + */ +td_err_e +td_thr_sigsetmask(const td_thrhandle_t *, const sigset_t); + +/* + * Set a thread's "signals-pending" set. + */ +td_err_e +td_thr_setsigpending(const td_thrhandle_t *, uchar_t, const sigset_t); + +/* + * Get a thread's general register set. + */ +td_err_e +td_thr_getgregs(const td_thrhandle_t *, prgregset_t); + +/* + * Set a thread's general register set. + */ +td_err_e +td_thr_setgregs(const td_thrhandle_t *, const prgregset_t); + +/* + * Get a thread's floating-point register set. + */ +td_err_e +td_thr_getfpregs(const td_thrhandle_t *, prfpregset_t *); + +/* + * Set a thread's floating-point register set. + */ +td_err_e +td_thr_setfpregs(const td_thrhandle_t *, const prfpregset_t *); + +/* + * Get the size of the extra state register set for this architecture. + */ +td_err_e +td_thr_getxregsize(const td_thrhandle_t *th_p, int *xregsize); + +/* + * Get a thread's extra state register set. + */ +td_err_e +td_thr_getxregs(const td_thrhandle_t *th_p, void *xregs); + +/* + * Set a thread's extra state register set. + */ +td_err_e +td_thr_setxregs(const td_thrhandle_t *th_p, const void *xregs); + +/* + * Validate a thread handle. + */ +td_err_e +td_thr_validate(const td_thrhandle_t *); + +/* + * Get a thread-specific data pointer for a thread. + */ +td_err_e +td_thr_tsd(const td_thrhandle_t *, thread_key_t, void **); + +/* + * Get the base address of a thread's thread local storage (TLS) block + * for the module (executable or shared object) identified by 'moduleid'. + */ +td_err_e +td_thr_tlsbase(const td_thrhandle_t *, ulong_t moduleid, psaddr_t *base); + +/* + * Set a thread's priority. + */ +td_err_e +td_thr_setprio(const td_thrhandle_t *, int); + +/* + * Iterate over the set of locks owned by a thread. + */ +td_err_e +td_thr_lockowner(const td_thrhandle_t *, td_sync_iter_f *, void *); + +/* + * Return the sync. handle of the object this thread is sleeping on. + */ +td_err_e +td_thr_sleepinfo(const td_thrhandle_t *, td_synchandle_t *); + +/* + * Map an lwpid, as returned by _lwp_create(), to a thread handle. + */ +td_err_e +td_ta_map_lwp2thr(const td_thragent_t *, lwpid_t, td_thrhandle_t *th_p); + +/* + * Enable/disable a process's synchronization object tracking. + */ +td_err_e +td_ta_sync_tracking_enable(const td_thragent_t *, int); + +/* + * Get information about a synchronization object. + */ +td_err_e +td_sync_get_info(const td_synchandle_t *, td_syncinfo_t *); + +/* + * Get statistics for a synchronization object. + */ +td_err_e +td_sync_get_stats(const td_synchandle_t *, td_syncstats_t *); + +/* + * Set the state of a synchronization object. + */ +td_err_e +td_sync_setstate(const td_synchandle_t *, int value); + +/* + * Iterate over all threads blocked on a synchronization object. + */ +td_err_e +td_sync_waiters(const td_synchandle_t *, td_thr_iter_f *, void *); + +#ifdef __cplusplus +} +#endif + +#endif /* _THREAD_DB_H */ diff --git a/illumos-x86_64/usr/include/threads.h b/illumos-x86_64/usr/include/threads.h new file mode 100644 index 00000000..86e0164f --- /dev/null +++ b/illumos-x86_64/usr/include/threads.h @@ -0,0 +1,104 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _THREADS_H +#define _THREADS_H + +/* + * ISO/IEC C11 threads.h support + */ + +#include + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11) + +#if !defined(_NORETURN_KYWD) +#if __STDC_VERSION__ - 0 >= 201112L +#define _NORETURN_KYWD _Noreturn +#else +#define _NORETURN_KYWD +#endif /* __STDC_VERSION__ - 0 >= 201112L */ +#endif /* !defined(_NORETURN_KYWD) */ + +#define thread_local _Thread_local +#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT +#define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS + +typedef pthread_cond_t cnd_t; +typedef pthread_t thrd_t; +typedef pthread_key_t tss_t; +typedef pthread_mutex_t mtx_t; +typedef void (*tss_dtor_t)(void *); +typedef int (*thrd_start_t)(void *); +typedef pthread_once_t once_flag; + +enum { + mtx_plain = 0x1, + mtx_recursive = 0x2, + mtx_timed = 0x4 +}; + +enum { + thrd_success = 0, + thrd_error = 1, + thrd_busy = 2, + thrd_timedout = 3, + thrd_nomem = 4 +}; + +extern void call_once(once_flag *, void (*)(void)); +extern int cnd_broadcast(cnd_t *); +extern void cnd_destroy(cnd_t *); +extern int cnd_init(cnd_t *); +extern int cnd_signal(cnd_t *); +extern int cnd_timedwait(cnd_t *_RESTRICT_KYWD, mtx_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +extern int cnd_wait(cnd_t *, mtx_t *); +extern void mtx_destroy(mtx_t *); +extern int mtx_init(mtx_t *, int); +extern int mtx_lock(mtx_t *); +extern int mtx_timedlock(mtx_t *_RESTRICT_KYWD, + const struct timespec *_RESTRICT_KYWD); +extern int mtx_trylock(mtx_t *); +extern int mtx_unlock(mtx_t *); +extern int thrd_create(thrd_t *, thrd_start_t, void *); +extern thrd_t thrd_current(void); +extern int thrd_detach(thrd_t); +extern int thrd_equal(thrd_t, thrd_t); +extern _NORETURN_KYWD void thrd_exit(int) __NORETURN; +extern int thrd_join(thrd_t, int *); +extern int thrd_sleep(const struct timespec *, struct timespec *); +extern void thrd_yield(void); +extern int tss_create(tss_t *, tss_dtor_t); +extern void tss_delete(tss_t); +extern void *tss_get(tss_t); +extern int tss_set(tss_t, void *); + +#endif /* !_STRICT_SYMBOLS | _STDC_C11 */ + +#ifdef __cplusplus +} +#endif + +#endif /* _THREADS_H */ diff --git a/illumos-x86_64/usr/include/time.h b/illumos-x86_64/usr/include/time.h new file mode 100644 index 00000000..5ec0b1c7 --- /dev/null +++ b/illumos-x86_64/usr/include/time.h @@ -0,0 +1,323 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright 2010 Nexenta Systems, Inc. Al rights reserved. + * Copyright 2016 Joyent, Inc. + */ + +#ifndef _TIME_H +#define _TIME_H + +#include +#include +/* + * C11 requires sys/time_impl.h for the definition of the struct timespec. + */ +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__) || defined(_STDC_C11) +#include +#include +#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) ... */ + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::size_t; +using std::clock_t; +using std::time_t; +using std::tm; +using std::asctime; +using std::clock; +using std::ctime; +using std::difftime; +using std::gmtime; +using std::localtime; +using std::mktime; +using std::time; +using std::strftime; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _CLOCKID_T +#define _CLOCKID_T +typedef int clockid_t; +#endif + +#ifndef _TIMER_T +#define _TIMER_T +typedef int timer_t; +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT) +extern struct tm *gmtime_r(const time_t *_RESTRICT_KYWD, + struct tm *_RESTRICT_KYWD); +extern struct tm *localtime_r(const time_t *_RESTRICT_KYWD, + struct tm *_RESTRICT_KYWD); +#endif + +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG4) || defined(__EXTENSIONS__) + +#ifdef _STRPTIME_DONTZERO +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname strptime __strptime_dontzero +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern char *__strptime_dontzero(const char *, const char *, struct tm *); +#define strptime __strptime_dontzero +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* _STRPTIME_DONTZERO */ + +extern char *strptime(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + struct tm *_RESTRICT_KYWD); + +#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */ + +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__) +/* + * Neither X/Open nor POSIX allow the inclusion of for the + * definition of the sigevent structure. Both require the inclusion + * of and when using the timer_create() function. + * However, X/Open also specifies that the sigevent structure be defined + * in as described in the header . This prevents + * compiler warnings for applications that only include and not + * also . The sigval union and the sigevent structure is + * therefore defined both here and in which gets included + * via inclusion of . + */ +#ifndef _SIGVAL +#define _SIGVAL +union sigval { + int sival_int; /* integer value */ + void *sival_ptr; /* pointer value */ +}; +#endif /* _SIGVAL */ + +#ifndef _SIGEVENT +#define _SIGEVENT +struct sigevent { + int sigev_notify; /* notification mode */ + int sigev_signo; /* signal number */ + union sigval sigev_value; /* signal value */ + void (*sigev_notify_function)(union sigval); + pthread_attr_t *sigev_notify_attributes; + int __sigev_pad2; +}; +#endif /* _SIGEVENT */ + +extern int clock_getres(clockid_t, struct timespec *); +extern int clock_gettime(clockid_t, struct timespec *); +extern int clock_settime(clockid_t, const struct timespec *); +extern int timer_create(clockid_t, struct sigevent *_RESTRICT_KYWD, + timer_t *_RESTRICT_KYWD); +extern int timer_delete(timer_t); +extern int timer_getoverrun(timer_t); +extern int timer_gettime(timer_t, struct itimerspec *); +extern int timer_settime(timer_t, int, const struct itimerspec *_RESTRICT_KYWD, + struct itimerspec *_RESTRICT_KYWD); + +extern int nanosleep(const struct timespec *, struct timespec *); +extern int clock_nanosleep(clockid_t, int, + const struct timespec *, struct timespec *); + +#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */ + +#if !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX) || \ + defined(__EXTENSIONS__) + +extern void tzset(void); +extern char *tzname[2]; + +/* CLK_TCK marked as LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +#ifndef CLK_TCK +extern long _sysconf(int); /* System Private interface to sysconf() */ +#define CLK_TCK ((clock_t)_sysconf(3)) /* clock ticks per second */ + /* 3 is _SC_CLK_TCK */ +#endif +#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ + +#if (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \ + defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +extern long timezone; +extern int daylight; +#endif + +#endif /* !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)... */ + +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(__EXTENSIONS__) +extern time_t timegm(struct tm *); +extern int cftime(char *, char *, const time_t *); +extern int ascftime(char *, const char *, const struct tm *); +extern long altzone; +#endif + +#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + defined(_XPG4_2) || defined(__EXTENSIONS__) +extern struct tm *getdate(const char *); +#ifdef _REENTRANT +#undef getdate_err +#define getdate_err *(int *)_getdate_err_addr() +extern int *_getdate_err_addr(void); +#else +extern int getdate_err; +#endif /* _REENTRANT */ +#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */ + +/* + * ctime_r() & asctime_r() prototypes are defined here. + */ + +/* + * Previous releases of Solaris, starting at 2.3, provided definitions of + * various functions as specified in POSIX.1c, Draft 6. For some of these + * functions, the final POSIX 1003.1c standard had a different number of + * arguments and return values. + * + * The following segment of this header provides support for the standard + * interfaces while supporting applications written under earlier + * releases. The application defines appropriate values of the feature + * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate + * whether it was written to expect the Draft 6 or standard versions of + * these interfaces, before including this header. This header then + * provides a mapping from the source version of the interface to an + * appropriate binary interface. Such mappings permit an application + * to be built from libraries and objects which have mixed expectations + * of the definitions of these functions. + * + * For applications using the Draft 6 definitions, the binary symbol is the + * same as the source symbol, and no explicit mapping is needed. For the + * standard interface, the function func() is mapped to the binary symbol + * _posix_func(). The preferred mechanism for the remapping is a compiler + * #pragma. If the compiler does not provide such a #pragma, the header file + * defines a static function func() which calls the _posix_func() version; + * this has to be done instead of #define since POSIX specifies that an + * application can #undef the symbol and still be bound to the correct + * implementation. Unfortunately, the statics confuse lint so we fallback to + * #define in that case. + * + * NOTE: Support for the Draft 6 definitions is provided for compatibility + * only. New applications/libraries should use the standard definitions. + */ + +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \ + (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) + +#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname ctime_r __posix_ctime_r +#pragma redefine_extname asctime_r __posix_asctime_r +extern char *asctime_r(const struct tm *_RESTRICT_KYWD, char *_RESTRICT_KYWD); +extern char *ctime_r(const time_t *, char *); +#else /* __PRAGMA_REDEFINE_EXTNAME */ + +extern char *__posix_asctime_r(const struct tm *_RESTRICT_KYWD, + char *_RESTRICT_KYWD); +extern char *__posix_ctime_r(const time_t *, char *); + +#ifdef __lint + +#define ctime_r __posix_ctime_r +#define asctime_r __posix_asctime_r + +#else /* !__lint */ + +static char * +asctime_r(const struct tm *_RESTRICT_KYWD __tm, char *_RESTRICT_KYWD __buf) +{ + return (__posix_asctime_r(__tm, __buf)); +} + +static char * +ctime_r(const time_t *__time, char *__buf) +{ + return (__posix_ctime_r(__time, __buf)); +} + +#endif /* !__lint */ +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +extern char *asctime_r(const struct tm *, char *, int); +extern char *ctime_r(const time_t *, char *, int); + +#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */ + + +#if defined(_XPG7) || !defined(_STRICT_SYMBOLS) + +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +extern size_t strftime_l(char *_RESTRICT_KYWD, size_t, + const char *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD, locale_t); + +#endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */ + +#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11) + +/* + * Note, the C11 standard requires that all the various base values that are + * passed into timespec_get() be non-zero. Hence why TIME_UTC starts at one. + */ +#define TIME_UTC 0x1 /* CLOCK_REALTIME */ +#define TIME_MONOTONIC 0x2 /* CLOCK_HIGHRES */ +#define TIME_ACTIVE 0x3 /* CLOCK_PROCESS_CPUTIME_ID */ +#define TIME_THREAD_ACTIVE 0x4 /* CLOCK_THREAD_CPUTIME_ID */ +#define TIME_THREAD_ACTIVE_USR 0x5 /* CLOCK_VIRTUAL */ + +extern int timespec_get(struct timespec *, int); +#endif + +#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C23) +extern int timespec_getres(struct timespec *, int); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _TIME_H */ diff --git a/illumos-x86_64/usr/include/tiuser.h b/illumos-x86_64/usr/include/tiuser.h new file mode 100644 index 00000000..069b2c92 --- /dev/null +++ b/illumos-x86_64/usr/include/tiuser.h @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _TIUSER_H +#define _TIUSER_H + +/* + * TLI user interface definitions. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_REENTRANT) || defined(_TS_ERRNO) || \ + _POSIX_C_SOURCE - 0 >= 199506L +extern int *__t_errno(void); +#define t_errno (*(__t_errno())) +#else +extern int t_errno; +#endif /* defined(_REENTRANT) || defined(_TS_ERRNO) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TIUSER_H */ diff --git a/illumos-x86_64/usr/include/tld.h b/illumos-x86_64/usr/include/tld.h new file mode 100644 index 00000000..c1460790 --- /dev/null +++ b/illumos-x86_64/usr/include/tld.h @@ -0,0 +1,162 @@ +/* tld.h --- Declarations for TLD restriction checking. + Copyright (C) 2004-2025 Simon Josefsson. + Copyright (C) 2003-2025 Free Software Foundation, Inc. + + Author: Thomas Jacob, Internet24.de + + This file is part of GNU Libidn. + + GNU Libidn is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version. + + or both in parallel, as here. + + GNU Libidn is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see . */ + +#ifndef TLD_H +# define TLD_H + +/** + * SECTION:tld + * @title: tld.h + * @short_description: TLD-related functions + * + * TLD-related functions. + */ + +# ifndef IDNAPI +# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY +# define IDNAPI __attribute__((__visibility__("default"))) +# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllexport) +# elif defined _MSC_VER && ! defined LIBIDN_STATIC +# define IDNAPI __declspec(dllimport) +# else +# define IDNAPI +# endif +# endif + +# ifdef __cplusplus +extern "C" +{ +# endif + + /* Get size_t. */ +# include + + /* Get uint32_t. */ +# include + + /* *INDENT-OFF* */ + + /* Why INDENT-OFF? See stringprep.h */ + + /** + * Tld_table_element: + * @start: Start of range. + * @end: End of range, end == start if single. + * + * Interval of valid code points in the TLD. + */ + struct Tld_table_element + { + uint32_t start; + uint32_t end; +}; + typedef struct Tld_table_element Tld_table_element; + + /** + * Tld_table: + * @name: TLD name, e.g., "no". + * @version: Version string from TLD file. + * @nvalid: Number of entries in data. + * @valid: Sorted array (of size @nvalid) of valid code points. + * + * List valid code points in a TLD. + */ + struct Tld_table + { + const char *name; + const char *version; + size_t nvalid; + const Tld_table_element *valid; +}; + typedef struct Tld_table Tld_table; + /* *INDENT-ON* */ + + /* Error codes. */ + typedef enum + { + TLD_SUCCESS = 0, + TLD_INVALID = 1, /* Invalid character found. */ + TLD_NODATA = 2, /* Char, domain or inlen = 0. */ + TLD_MALLOC_ERROR = 3, + TLD_ICONV_ERROR = 4, + TLD_NO_TLD = 5, + /* Workaround typo in earlier versions. */ + TLD_NOTLD = TLD_NO_TLD + } Tld_rc; + + extern IDNAPI const char *tld_strerror (Tld_rc rc); + + /* Extract TLD, as ASCII string, of UCS4 domain name into "out". */ + extern IDNAPI int tld_get_4 (const uint32_t * in, size_t inlen, char **out); + extern IDNAPI int tld_get_4z (const uint32_t * in, char **out); + extern IDNAPI int tld_get_z (const char *in, char **out); + + /* Return structure corresponding to the named TLD from specified + * list of TLD tables, or return NULL if no matching TLD can be + * found. */ + extern IDNAPI const Tld_table *tld_get_table (const char *tld, + const Tld_table ** tables); + + /* Return structure corresponding to the named TLD, first looking + * thru overrides then thru built-in list, or return NULL if no + * matching TLD can be found. */ + extern IDNAPI const Tld_table *tld_default_table (const char *tld, + const Tld_table ** + overrides); + + /* Check NAMEPREPPED domain name for valid characters as defined by + * the relevant registering body (plus [a-z0-9.-]). If error is + * TLD_INVALID, set errpos to position of offending character. */ + extern IDNAPI int tld_check_4t (const uint32_t * in, size_t inlen, + size_t *errpos, const Tld_table * tld); + extern IDNAPI int tld_check_4tz (const uint32_t * in, size_t *errpos, + const Tld_table * tld); + + /* Utility interfaces that uses tld_get_4* to find TLD of string, + then tld_default_table (with overrides) to find proper TLD table + for the string, and then hands over to tld_check_4t*. */ + extern IDNAPI int tld_check_4 (const uint32_t * in, size_t inlen, + size_t *errpos, + const Tld_table ** overrides); + extern IDNAPI int tld_check_4z (const uint32_t * in, size_t *errpos, + const Tld_table ** overrides); + extern IDNAPI int tld_check_8z (const char *in, size_t *errpos, + const Tld_table ** overrides); + extern IDNAPI int tld_check_lz (const char *in, size_t *errpos, + const Tld_table ** overrides); + +# ifdef __cplusplus +} +# endif + +#endif /* TLD_H */ diff --git a/illumos-x86_64/usr/include/trousers/trousers.h b/illumos-x86_64/usr/include/trousers/trousers.h new file mode 100644 index 00000000..10136d55 --- /dev/null +++ b/illumos-x86_64/usr/include/trousers/trousers.h @@ -0,0 +1,283 @@ + +/* + * Licensed Materials - Property of IBM + * + * trousers - An open source TCG Software Stack + * + * (C) Copyright International Business Machines Corp. 2004-2007 + * + */ + +#ifndef _TROUSERS_H_ +#define _TROUSERS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Utility functions offered by trousers for use in your TSS app. + * + * All functions listed here are specific to the trousers TSS and should not be + * used in applications that are intended to be portable. + * + */ + +/* Blob unloading functions */ +void Trspi_UnloadBlob(UINT64 *offset, size_t size, BYTE *container, BYTE *object); +void Trspi_UnloadBlob_BYTE(UINT64 *offset, BYTE *dataOut, BYTE *blob); +void Trspi_UnloadBlob_BOOL(UINT64 *offset, TSS_BOOL *dataOut, BYTE *blob); +void Trspi_UnloadBlob_UINT64(UINT64 *offset, UINT64 *out, BYTE *blob); +void Trspi_UnloadBlob_UINT32(UINT64 *offset, UINT32 *out, BYTE *blob); +void Trspi_UnloadBlob_UINT16(UINT64 *offset, UINT16 *out, BYTE *blob); +void Trspi_UnloadBlob_TSS_VERSION(UINT64 *offset, BYTE *blob, TSS_VERSION *out); +void Trspi_UnloadBlob_TCPA_VERSION(UINT64 *offset, BYTE *blob, TCPA_VERSION *out); +TSS_RESULT Trspi_UnloadBlob_PCR_INFO(UINT64 *offset, BYTE *blob, TCPA_PCR_INFO *pcr); +TSS_RESULT Trspi_UnloadBlob_PCR_INFO_LONG(UINT64 *offset, BYTE *blob, TPM_PCR_INFO_LONG *pcr); +TSS_RESULT Trspi_UnloadBlob_PCR_INFO_SHORT(UINT64 *offset, BYTE *blob, TPM_PCR_INFO_SHORT *pcr); +TSS_RESULT Trspi_UnloadBlob_PCR_SELECTION(UINT64 *offset, BYTE *blob, TCPA_PCR_SELECTION *pcr); +TSS_RESULT Trspi_UnloadBlob_PCR_COMPOSITE(UINT64 *offset, BYTE *blob, TCPA_PCR_COMPOSITE *out); +TSS_RESULT Trspi_UnloadBlob_STORED_DATA(UINT64 *offset, BYTE *blob, TCPA_STORED_DATA *data); +void Trspi_UnloadBlob_KEY_FLAGS(UINT64 *offset, BYTE *blob, TCPA_KEY_FLAGS *flags); +TSS_RESULT Trspi_UnloadBlob_KEY_PARMS(UINT64 *offset, BYTE *blob, TCPA_KEY_PARMS *keyParms); +void Trspi_UnloadBlob_UUID(UINT64 *offset, BYTE *blob, TSS_UUID *uuid); +TSS_RESULT Trspi_UnloadBlob_STORE_PUBKEY(UINT64 *, BYTE *, TCPA_STORE_PUBKEY *); +void Trspi_UnloadBlob_DIGEST(UINT64 *offset, BYTE *blob, TPM_DIGEST *digest); +TSS_RESULT Trspi_UnloadBlob_PUBKEY(UINT64 *offset, BYTE *blob, TCPA_PUBKEY *pubKey); +TSS_RESULT Trspi_UnloadBlob_KEY(UINT64 *offset, BYTE *blob, TCPA_KEY *key); +TSS_RESULT Trspi_UnloadBlob_KEY12(UINT64 *offset, BYTE *blob, TPM_KEY12 *key); +TSS_RESULT Trspi_UnloadBlob_MIGRATIONKEYAUTH(UINT64 *offset, BYTE *blob, TPM_MIGRATIONKEYAUTH *migAuth); +TSS_RESULT Trspi_UnloadBlob_PCR_EVENT(UINT64 *offset, BYTE *blob, TSS_PCR_EVENT *event); +TSS_RESULT Trspi_UnloadBlob_KM_KEYINFO(UINT64 *offset, BYTE *blob, TSS_KM_KEYINFO *info); +TSS_RESULT Trspi_UnloadBlob_KM_KEYINFO2(UINT64 *offset, BYTE *blob, TSS_KM_KEYINFO2 *info); +TSS_RESULT Trspi_UnloadBlob_SYMMETRIC_KEY(UINT64 *offset, BYTE *blob, TCPA_SYMMETRIC_KEY *key); +TSS_RESULT Trspi_UnloadBlob_SYM_CA_ATTESTATION(UINT64 *offset, BYTE *blob, TCPA_SYM_CA_ATTESTATION *sym); +TSS_RESULT Trspi_UnloadBlob_ASYM_CA_CONTENTS(UINT64 *offset, BYTE *blob, TCPA_ASYM_CA_CONTENTS *asym); +TSS_RESULT Trspi_UnloadBlob_IDENTITY_REQ(UINT64 *offset, BYTE *blob, TCPA_IDENTITY_REQ *req); +TSS_RESULT Trspi_UnloadBlob_IDENTITY_PROOF(UINT64 *offset, BYTE *blob, TCPA_IDENTITY_PROOF *proof); +void Trspi_UnloadBlob_COUNTER_VALUE(UINT64 *offset, BYTE *blob, TPM_COUNTER_VALUE *ctr); +void Trspi_UnloadBlob_CURRENT_TICKS(UINT64 *offset, BYTE *blob, TPM_CURRENT_TICKS *ticks); +void Trspi_UnloadBlob_TRANSPORT_PUBLIC(UINT64 *offset, BYTE *blob, TPM_TRANSPORT_PUBLIC *t); +void Trspi_UnloadBlob_NONCE(UINT64 *offset, BYTE* blob, TPM_NONCE *n); +TSS_RESULT Trspi_UnloadBlob_CERTIFY_INFO(UINT64 *offset, BYTE* blob, TPM_CERTIFY_INFO *c); +void Trspi_UnloadBlob_TPM_FAMILY_LABEL(UINT64 *offset, BYTE *blob, TPM_FAMILY_LABEL *label); +void Trspi_UnloadBlob_TPM_FAMILY_TABLE_ENTRY(UINT64 *offset, BYTE *blob, TPM_FAMILY_TABLE_ENTRY *entry); +void Trspi_UnloadBlob_TPM_DELEGATE_LABEL(UINT64 *offset, BYTE *blob, TPM_DELEGATE_LABEL *label); +void Trspi_UnloadBlob_TPM_DELEGATIONS(UINT64 *offset, BYTE *blob, TPM_DELEGATIONS *delegations); +TSS_RESULT Trspi_UnloadBlob_TPM_DELEGATE_PUBLIC(UINT64 *offset, BYTE *blob, TPM_DELEGATE_PUBLIC *pub); +TSS_RESULT Trspi_UnloadBlob_TPM_DELEGATE_OWNER_BLOB(UINT64 *offset, BYTE *blob, TPM_DELEGATE_OWNER_BLOB *owner); +TSS_RESULT Trspi_UnloadBlob_TPM_DELEGATE_KEY_BLOB(UINT64 *offset, BYTE *blob, TPM_DELEGATE_KEY_BLOB *key); +void Trspi_UnloadBlob_TSS_FAMILY_TABLE_ENTRY(UINT64 *offset, BYTE *blob, TSS_FAMILY_TABLE_ENTRY *entry); +TSS_RESULT Trspi_UnloadBlob_TSS_PCR_INFO_SHORT(UINT64 *offset, BYTE *blob, TSS_PCR_INFO_SHORT *pcr); +TSS_RESULT Trspi_UnloadBlob_TSS_DELEGATION_TABLE_ENTRY(UINT64 *offset, BYTE *blob, TSS_DELEGATION_TABLE_ENTRY *entry); +TSS_RESULT Trspi_UnloadBlob_TSS_PLATFORM_CLASS(UINT64 *offset, BYTE *blob, TSS_PLATFORM_CLASS *platClass); +TSS_RESULT Trspi_UnloadBlob_CAP_VERSION_INFO(UINT64 *offset, BYTE *blob, TPM_CAP_VERSION_INFO *v); +TSS_RESULT Trspi_UnloadBlob_NV_INDEX(UINT64 *offset, BYTE *blob, TPM_NV_INDEX *v); +TSS_RESULT Trspi_UnloadBlob_NV_ATTRIBUTES(UINT64 *offset, BYTE *blob, TPM_NV_ATTRIBUTES *v); +TSS_RESULT Trspi_UnloadBlob_NV_DATA_PUBLIC(UINT64 *offset, BYTE *blob, TPM_NV_DATA_PUBLIC *v); + +/* Blob loading functions */ +void Trspi_LoadBlob_BOUND_DATA(UINT64 *, TCPA_BOUND_DATA, UINT32, BYTE *); +void Trspi_LoadBlob_CHANGEAUTH_VALIDATE(UINT64 *, BYTE *, TPM_CHANGEAUTH_VALIDATE *); +void Trspi_LoadBlob(UINT64 *offset, size_t size, BYTE *to, BYTE *from); +void Trspi_LoadBlob_UINT32(UINT64 *offset, UINT32 in, BYTE *blob); +void Trspi_LoadBlob_UINT16(UINT64 *offset, UINT16 in, BYTE *blob); +void Trspi_LoadBlob_BYTE(UINT64 *offset, BYTE data, BYTE *blob); +void Trspi_LoadBlob_BOOL(UINT64 *offset, TSS_BOOL data, BYTE *blob); +void Trspi_LoadBlob_RSA_KEY_PARMS(UINT64 *offset, BYTE *blob, TCPA_RSA_KEY_PARMS *parms); +void Trspi_LoadBlob_TSS_VERSION(UINT64 *offset, BYTE *blob, TSS_VERSION version); +void Trspi_LoadBlob_TCPA_VERSION(UINT64 *offset, BYTE *blob, TCPA_VERSION version); +void Trspi_LoadBlob_PCR_INFO(UINT64 *offset, BYTE *blob, TCPA_PCR_INFO *pcr); +void Trspi_LoadBlob_PCR_INFO_LONG(UINT64 *offset, BYTE *blob, TPM_PCR_INFO_LONG *pcr); +void Trspi_LoadBlob_PCR_INFO_SHORT(UINT64 *offset, BYTE *blob, TPM_PCR_INFO_SHORT *pcr); +void Trspi_LoadBlob_PCR_SELECTION(UINT64 *offset, BYTE *blob, TCPA_PCR_SELECTION *pcr); +void Trspi_LoadBlob_STORED_DATA(UINT64 *offset, BYTE *blob, TCPA_STORED_DATA *data); +void Trspi_LoadBlob_PUBKEY(UINT64 *offset, BYTE *blob, TCPA_PUBKEY *pubKey); +void Trspi_LoadBlob_KEY(UINT64 *offset, BYTE *blob, TCPA_KEY *key); +void Trspi_LoadBlob_KEY12(UINT64 *offset, BYTE *blob, TPM_KEY12 *key); +void Trspi_LoadBlob_KEY_FLAGS(UINT64 *offset, BYTE *blob, TCPA_KEY_FLAGS *flags); +void Trspi_LoadBlob_KEY_PARMS(UINT64 *offset, BYTE *blob, TCPA_KEY_PARMS *keyInfo); +void Trspi_LoadBlob_STORE_PUBKEY(UINT64 *offset, BYTE *blob, TCPA_STORE_PUBKEY *store); +void Trspi_LoadBlob_UUID(UINT64 *offset, BYTE *blob, TSS_UUID uuid); +void Trspi_LoadBlob_CERTIFY_INFO(UINT64 *offset, BYTE *blob, TCPA_CERTIFY_INFO *certify); +void Trspi_LoadBlob_STORE_ASYMKEY(UINT64 *offset, BYTE *blob, TCPA_STORE_ASYMKEY *store); +void Trspi_LoadBlob_PCR_EVENT(UINT64 *offset, BYTE *blob, TSS_PCR_EVENT *event); +void Trspi_LoadBlob_PRIVKEY_DIGEST(UINT64 *offset, BYTE *blob, TCPA_KEY *key); +void Trspi_LoadBlob_PRIVKEY_DIGEST12(UINT64 *offset, BYTE *blob, TPM_KEY12 *key); +void Trspi_LoadBlob_SYMMETRIC_KEY(UINT64 *offset, BYTE *blob, TCPA_SYMMETRIC_KEY *key); +void Trspi_LoadBlob_SYM_CA_ATTESTATION(UINT64 *offset, BYTE *blob, TCPA_SYM_CA_ATTESTATION *sym); +void Trspi_LoadBlob_ASYM_CA_CONTENTS(UINT64 *offset, BYTE *blob, TCPA_ASYM_CA_CONTENTS *asym); +void Trspi_LoadBlob_IDENTITY_REQ(UINT64 *offset, BYTE *blob, TCPA_IDENTITY_REQ *req); +void Trspi_LoadBlob_COUNTER_VALUE(UINT64 *offset, BYTE *blob, TPM_COUNTER_VALUE *ctr); +void Trspi_LoadBlob_TRANSPORT_PUBLIC(UINT64 *offset, BYTE *blob, TPM_TRANSPORT_PUBLIC *t); +void Trspi_LoadBlob_TRANSPORT_AUTH(UINT64 *offset, BYTE *blob, TPM_TRANSPORT_AUTH *t); +void Trspi_LoadBlob_SIGN_INFO(UINT64 *offset, BYTE *blob, TPM_SIGN_INFO *s); +void Trspi_LoadBlob_DIGEST(UINT64 *offset, BYTE *blob, TPM_DIGEST *digest); +void Trspi_LoadBlob_NONCE(UINT64 *offset, BYTE *blob, TPM_NONCE *n); +void Trspi_LoadBlob_TPM_FAMILY_LABEL(UINT64 *offset, BYTE *blob, TPM_FAMILY_LABEL *label); +void Trspi_LoadBlob_TPM_FAMILY_TABLE_ENTRY(UINT64 *offset, BYTE *blob, TPM_FAMILY_TABLE_ENTRY *entry); +void Trspi_LoadBlob_TPM_DELEGATE_LABEL(UINT64 *offset, BYTE *blob, TPM_DELEGATE_LABEL *label); +void Trspi_LoadBlob_TPM_DELEGATIONS(UINT64 *offset, BYTE *blob, TPM_DELEGATIONS *delegations); +void Trspi_LoadBlob_TPM_DELEGATE_PUBLIC(UINT64 *offset, BYTE *blob, TPM_DELEGATE_PUBLIC *pub); +void Trspi_LoadBlob_TPM_DELEGATE_OWNER_BLOB(UINT64 *offset, BYTE *blob, TPM_DELEGATE_OWNER_BLOB *owner); +void Trspi_LoadBlob_TPM_DELEGATE_KEY_BLOB(UINT64 *offset, BYTE *blob, TPM_DELEGATE_KEY_BLOB *key); +void Trspi_LoadBlob_TSS_FAMILY_TABLE_ENTRY(UINT64 *offset, BYTE *blob, TSS_FAMILY_TABLE_ENTRY *entry); +void Trspi_LoadBlob_TSS_PCR_INFO_SHORT(UINT64 *offset, BYTE *blob, TSS_PCR_INFO_SHORT *pcr); +void Trspi_LoadBlob_TSS_DELEGATION_TABLE_ENTRY(UINT64 *offset, BYTE *blob, TSS_DELEGATION_TABLE_ENTRY *entry); +void Trspi_LoadBlob_MIGRATIONKEYAUTH(UINT64 *offset, BYTE *blob, TPM_MIGRATIONKEYAUTH *migAuth); +void Trspi_LoadBlob_MSA_COMPOSITE(UINT64 *offset, BYTE *blob, TPM_MSA_COMPOSITE *msaComp); +void Trspi_LoadBlob_CMK_AUTH(UINT64 *offset, BYTE *blob, TPM_CMK_AUTH *cmkAuth); +void Trspi_LoadBlob_CAP_VERSION_INFO(UINT64 *offset, BYTE *blob, TPM_CAP_VERSION_INFO *v); + +/* Cryptographic Functions */ + +/* Hash @BufSize bytes at location @Buf using the algorithm @HashType. Currently only + * TSS_HASH_SHA1 is a suported type, so 20 bytes will be written to @Digest */ +TSS_RESULT Trspi_Hash(UINT32 HashType, UINT32 BufSize, BYTE *Buf, BYTE *Digest); + +typedef struct _Trspi_HashCtx { + void *ctx; +} Trspi_HashCtx; + +TSS_RESULT Trspi_HashInit(Trspi_HashCtx *c, UINT32 type); +TSS_RESULT Trspi_HashUpdate(Trspi_HashCtx *c, UINT32 size, BYTE *data); +TSS_RESULT Trspi_HashFinal(Trspi_HashCtx *c, BYTE *out_digest); + +/* Functions to support incremental hashing */ +TSS_RESULT Trspi_Hash_UINT16(Trspi_HashCtx *c, UINT16 i); +TSS_RESULT Trspi_Hash_UINT32(Trspi_HashCtx *c, UINT32 i); +TSS_RESULT Trspi_Hash_UINT64(Trspi_HashCtx *c, UINT64 i); +TSS_RESULT Trspi_Hash_DAA_PK(Trspi_HashCtx *c, TSS_DAA_PK *pk); +TSS_RESULT Trspi_Hash_PUBKEY(Trspi_HashCtx *c, TCPA_PUBKEY *pubKey); +TSS_RESULT Trspi_Hash_BYTE(Trspi_HashCtx *c, BYTE data); +TSS_RESULT Trspi_Hash_BOOL(Trspi_HashCtx *c, TSS_BOOL data); +TSS_RESULT Trspi_Hash_RSA_KEY_PARMS(Trspi_HashCtx *c, TCPA_RSA_KEY_PARMS *parms); +TSS_RESULT Trspi_Hash_VERSION(Trspi_HashCtx *c, TSS_VERSION *version); +TSS_RESULT Trspi_Hash_STORED_DATA(Trspi_HashCtx *c, TCPA_STORED_DATA *data); +TSS_RESULT Trspi_Hash_PCR_SELECTION(Trspi_HashCtx *c, TCPA_PCR_SELECTION *pcr); +TSS_RESULT Trspi_Hash_KEY(Trspi_HashCtx *c, TCPA_KEY *key); +TSS_RESULT Trspi_Hash_KEY12(Trspi_HashCtx *c, TPM_KEY12 *key); +TSS_RESULT Trspi_Hash_KEY_FLAGS(Trspi_HashCtx *c, TCPA_KEY_FLAGS *flags); +TSS_RESULT Trspi_Hash_KEY_PARMS(Trspi_HashCtx *c, TCPA_KEY_PARMS *keyInfo); +TSS_RESULT Trspi_Hash_STORE_PUBKEY(Trspi_HashCtx *c, TCPA_STORE_PUBKEY *store); +TSS_RESULT Trspi_Hash_UUID(Trspi_HashCtx *c, TSS_UUID uuid); +TSS_RESULT Trspi_Hash_PCR_EVENT(Trspi_HashCtx *c, TSS_PCR_EVENT *event); +TSS_RESULT Trspi_Hash_PRIVKEY_DIGEST(Trspi_HashCtx *c, TCPA_KEY *key); +TSS_RESULT Trspi_Hash_PRIVKEY_DIGEST12(Trspi_HashCtx *c, TPM_KEY12 *key); +TSS_RESULT Trspi_Hash_SYMMETRIC_KEY(Trspi_HashCtx *c, TCPA_SYMMETRIC_KEY *key); +TSS_RESULT Trspi_Hash_IDENTITY_REQ(Trspi_HashCtx *c, TCPA_IDENTITY_REQ *req); +TSS_RESULT Trspi_Hash_CHANGEAUTH_VALIDATE(Trspi_HashCtx *c, TPM_CHANGEAUTH_VALIDATE *caValidate); +TSS_RESULT Trspi_Hash_SYM_CA_ATTESTATION(Trspi_HashCtx *c, TCPA_SYM_CA_ATTESTATION *sym); +TSS_RESULT Trspi_Hash_ASYM_CA_CONTENTS(Trspi_HashCtx *c, TCPA_ASYM_CA_CONTENTS *asym); +TSS_RESULT Trspi_Hash_BOUND_DATA(Trspi_HashCtx *c, TCPA_BOUND_DATA *bd, UINT32 payloadLength); +TSS_RESULT Trspi_Hash_TRANSPORT_AUTH(Trspi_HashCtx *c, TPM_TRANSPORT_AUTH *a); +TSS_RESULT Trspi_Hash_TRANSPORT_LOG_IN(Trspi_HashCtx *c, TPM_TRANSPORT_LOG_IN *l); +TSS_RESULT Trspi_Hash_TRANSPORT_LOG_OUT(Trspi_HashCtx *c, TPM_TRANSPORT_LOG_OUT *l); +TSS_RESULT Trspi_Hash_CURRENT_TICKS(Trspi_HashCtx *c, TPM_CURRENT_TICKS *t); +TSS_RESULT Trspi_Hash_SIGN_INFO(Trspi_HashCtx *c, TPM_SIGN_INFO *s); +TSS_RESULT Trspi_Hash_MSA_COMPOSITE(Trspi_HashCtx *c, TPM_MSA_COMPOSITE *m); +#define Trspi_Hash_DIGEST(c, d) Trspi_HashUpdate(c, TPM_SHA1_160_HASH_LEN, d) +#define Trspi_Hash_NONCE(c, d) Trspi_HashUpdate(c, TPM_SHA1_160_HASH_LEN, d) +#define Trspi_Hash_ENCAUTH(c, d) Trspi_HashUpdate(c, TPM_SHA1_160_HASH_LEN, d) +#define Trspi_Hash_HMAC(c, d) Trspi_HashUpdate(c, TPM_SHA1_160_HASH_LEN, d) +#define Trspi_Hash_SECRET(c, d) Trspi_HashUpdate(c, TPM_SHA1_160_HASH_LEN, d) + + +UINT32 Trspi_HMAC(UINT32 HashType, UINT32 SecretSize, BYTE*Secret, UINT32 BufSize, BYTE*Buf, BYTE*hmacOut); + +/* RSA encrypt @dataToEncryptLen bytes at location @dataToEncrypt using public key + * @publicKey of size @keysize. This data will be encrypted using OAEP padding in + * the openssl library using the OAEP padding parameter "TCPA". This will allow + * data encrypted with this function to be decrypted by a TPM using non-legacy keys */ +int Trspi_RSA_Encrypt(unsigned char *dataToEncrypt, + unsigned int dataToEncryptLen, + unsigned char *encryptedData, + unsigned int *encryptedDataLen, + unsigned char *publicKey, + unsigned int keysize); + +TSS_RESULT Trspi_Verify(UINT32 HashType, BYTE *pHash, UINT32 iHashLength, + unsigned char *pModulus, int iKeyLength, + BYTE *pSignature, UINT32 sig_len); + +int Trspi_RSA_Public_Encrypt(unsigned char *in, unsigned int inlen, + unsigned char *out, unsigned int *outlen, + unsigned char *pubkey, unsigned int pubsize, + unsigned int e, int padding); + +#define TR_RSA_PKCS1_PADDING 1 +#define TR_RSA_PKCS1_OAEP_PADDING 2 +#define TR_RSA_NO_PADDING 3 + +#define Trspi_RSA_PKCS15_Encrypt(in,inlen,out,outlen,pubKey,pubSize) \ + Trspi_RSA_Public_Encrypt(in,inlen,out,outlen,pubKey,pubSize,65537,TR_RSA_PKCS1_PADDING) + +#define Trspi_RSA_OAEP_Encrypt(in,inlen,out,outlen,pubKey,pubSize) \ + Trspi_RSA_Public_Encrypt(in,inlen,out,outlen,pubKey,pubSize,65537, \ + TR_RSA_PKCS1_OAEP_PADDING) + +#define Trspi_TPM_RSA_OAEP_Encrypt(in,inlen,out,outlen,pubKey,pubSize) \ + Trspi_RSA_Encrypt(in,inlen,out,outlen,pubKey,pubSize) + +/* Symmetric Encryption */ + +TSS_RESULT Trspi_Encrypt_ECB(UINT16 alg, BYTE *key, BYTE *in, UINT32 in_len, + BYTE *out, UINT32 *out_len); +TSS_RESULT Trspi_Decrypt_ECB(UINT16 alg, BYTE *key, BYTE *in, UINT32 in_len, + BYTE *out, UINT32 *out_len); + +#define TR_SYM_MODE_ECB 1 +#define TR_SYM_MODE_CBC 2 +#define TR_SYM_MODE_CTR 3 +#define TR_SYM_MODE_OFB 4 + +TSS_RESULT Trspi_SymEncrypt(UINT16 alg, UINT16 mode, BYTE *key, BYTE *iv, BYTE *in, UINT32 in_len, + BYTE *out, UINT32 *out_len); +TSS_RESULT Trspi_SymDecrypt(UINT16 alg, UINT16 mode, BYTE *key, BYTE *iv, BYTE *in, UINT32 in_len, + BYTE *out, UINT32 *out_len); + +TSS_RESULT Trspi_MGF1(UINT32 alg, UINT32 seedLen, BYTE *seed, UINT32 outLen, BYTE *out); + +/* String Functions */ + +/* Below UNICODE is in reference to the TSS type of that name, which is + * actually UTF-16. */ + +/* Convert @string to a UNICODE string. On error, NULL is returned. If len + * is non-NULL, *len will be set to the size of the returned buffer. */ +BYTE *Trspi_Native_To_UNICODE(BYTE *string, unsigned *len); + +/* convert UNICODE @string to a string from the current codeset. If len + * is non-NULL, *len will be set to the size of the returned buffer. */ +BYTE *Trspi_UNICODE_To_Native(BYTE *string, unsigned *len); + +/* Error Functions */ + +/* return a human readable string based on the result */ +char *Trspi_Error_String(TSS_RESULT); + +/* return a human readable error layer ( "tpm", "tddl", etc...) */ +char *Trspi_Error_Layer(TSS_RESULT); + +/* return just the error code bits of the result */ +TSS_RESULT Trspi_Error_Code(TSS_RESULT); + +#ifdef __cplusplus +} +#endif + +/* masks */ +#define TSS_KEY_SIZE_MASK 0x00000F00 +#define TSS_KEY_TYPE_MASK 0x000000F0 +#define TSS_ENCDATA_TYPE_MASK 0x0000000F + +/* These should be passed an TSS_FLAG parameter as to + * Tspi_Context_CreateObject + */ +#define TSS_KEY_SIZE(x) (x & TSS_KEY_SIZE_MASK) +#define TSS_KEY_TYPE(x) (x & TSS_KEY_TYPE_MASK) +#define TSS_ENCDATA_TYPE(x) (x & TSS_ENCDATA_TYPE_MASK) + +#define TSS_LOCALITY_ALL (TPM_LOC_ZERO|TPM_LOC_ONE|TPM_LOC_TWO|TPM_LOC_THREE|TPM_LOC_FOUR) + +#endif diff --git a/illumos-x86_64/usr/include/trousers/tss.h b/illumos-x86_64/usr/include/trousers/tss.h new file mode 100644 index 00000000..d0897af8 --- /dev/null +++ b/illumos-x86_64/usr/include/trousers/tss.h @@ -0,0 +1,33 @@ + +/* + * Licensed Materials - Property of IBM + * + * trousers - An open source TCG Software Stack + * + * (C) Copyright International Business Machines Corp. 2004-2006 + * + */ + +#ifndef _TSS_H_ +#define _TSS_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#endif diff --git a/illumos-x86_64/usr/include/tsol/label.h b/illumos-x86_64/usr/include/tsol/label.h new file mode 100644 index 00000000..d6b3600c --- /dev/null +++ b/illumos-x86_64/usr/include/tsol/label.h @@ -0,0 +1,248 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _TSOL_LABEL_H +#define _TSOL_LABEL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Procedural Interface Structure Definitions */ + +struct label_info { /* structure returned by label_info */ + short ilabel_len; /* max Information Label length */ + short slabel_len; /* max Sensitivity Label length */ + short clabel_len; /* max CMW Label length */ + short clear_len; /* max Clearance Label length */ + short vers_len; /* version string length */ + short header_len; /* max len of banner page header */ + short protect_as_len; /* max len of banner page protect as */ + short caveats_len; /* max len of banner page caveats */ + short channels_len; /* max len of banner page channels */ +}; + +typedef struct label_set_identifier { /* valid label set identifier */ + int type; /* type of the set */ + char *name; /* name of the set if needed */ +} set_id; + +struct name_fields { /* names for label builder fields */ + char *class_name; /* Classifications field name */ + char *comps_name; /* Compartments field name */ + char *marks_name; /* Markings field name */ +}; + +/* Label Set Identifier Types */ + +/* + * The accreditation ranges as specified in the label encodings file. + * The name parameter is ignored. + * + * System Accreditation Range is all valid labels plus Admin High and Low. + * + * User Accreditation Range is valid user labels as defined in the + * ACCREDITATION RANGE: section of the label encodings file. + */ + +#define SYSTEM_ACCREDITATION_RANGE 1 +#define USER_ACCREDITATION_RANGE 2 + + +/* System Call Interface Definitions */ + +extern int getlabel(const char *, m_label_t *); +extern int fgetlabel(int, m_label_t *); + +extern int getplabel(m_label_t *); +extern int setflabel(const char *, m_label_t *); +extern char *getpathbylabel(const char *, char *, size_t, + const m_label_t *sl); +extern m_label_t *getzonelabelbyid(zoneid_t); +extern m_label_t *getzonelabelbyname(const char *); +extern zoneid_t getzoneidbylabel(const m_label_t *); +extern char *getzonenamebylabel(const m_label_t *); +extern char *getzonerootbyid(zoneid_t); +extern char *getzonerootbyname(const char *); +extern char *getzonerootbylabel(const m_label_t *); +extern m_label_t *getlabelbypath(const char *); + + +/* Flag word values */ + +#define ALL_ENTRIES 0x00000000 +#define ACCESS_RELATED 0x00000001 +#define ACCESS_MASK 0x0000FFFF +#define ACCESS_SHIFT 0 + +#define LONG_WORDS 0x00010000 /* use long names */ +#define SHORT_WORDS 0x00020000 /* use short names if present */ +#define LONG_CLASSIFICATION 0x00040000 /* use long classification */ +#define SHORT_CLASSIFICATION 0x00080000 /* use short classification */ +#define NO_CLASSIFICATION 0x00100000 /* don't translate the class */ +#define VIEW_INTERNAL 0x00200000 /* don't promote/demote */ +#define VIEW_EXTERNAL 0x00400000 /* promote/demote label */ + +#define NEW_LABEL 0x00000001 /* create a full new label */ +#define NO_CORRECTION 0x00000002 /* don't correct label errors */ + /* implies NEW_LABEL */ + +#define CVT_DIM 0x01 /* display word dimmed */ +#define CVT_SET 0x02 /* display word currently set */ + +/* Procedure Interface Definitions available to user */ + +/* APIs shared with the kernel are in + +#define TCPA_Vendor_Specific32 TPM_Vendor_Specific32 +#define TCPA_Vendor_Specific8 TPM_Vendor_Specific8 + +typedef TSS_UNICODE UNICODE; +typedef TPM_DIGEST TCPA_DIGEST; +typedef TPM_NONCE TCPA_NONCE; +typedef TPM_NONCE TCPA_SALT_NONCE; +typedef TPM_PUBKEY TCPA_PUBKEY; +typedef TPM_SECRET TCPA_SECRET; +typedef TPM_KEY TCPA_KEY; +typedef TPM_DIRVALUE TCPA_DIRVALUE; +typedef TPM_COMMAND_CODE TCPA_COMMAND_CODE; +typedef TPM_BOUND_DATA TCPA_BOUND_DATA; +typedef TPM_STRUCT_VER TCPA_VERSION; +typedef TPM_RESULT TCPA_RESULT; +typedef TPM_PAYLOAD_TYPE TCPA_PAYLOAD_TYPE; +typedef TPM_STORE_PRIVKEY TCPA_STORE_PRIVKEY; +typedef TPM_CHOSENID_HASH TCPA_CHOSENID_HASH; +typedef TPM_SYMMETRIC_KEY TCPA_SYMMETRIC_KEY; +typedef TPM_PCR_INFO TCPA_PCR_INFO; +typedef TPM_PCR_SELECTION TCPA_PCR_SELECTION; +typedef TPM_STORED_DATA TCPA_STORED_DATA; +typedef TPM_SEALED_DATA TCPA_SEALED_DATA; +typedef TPM_KEY_FLAGS TCPA_KEY_FLAGS; +typedef TPM_KEY_PARMS TCPA_KEY_PARMS; +typedef TPM_STORE_PUBKEY TCPA_STORE_PUBKEY; +typedef TPM_MIGRATIONKEYAUTH TCPA_MIGRATIONKEYAUTH; +typedef TPM_RSA_KEY_PARMS TCPA_RSA_KEY_PARMS; +typedef TPM_CERTIFY_INFO TCPA_CERTIFY_INFO; +typedef TPM_STORE_ASYMKEY TCPA_STORE_ASYMKEY; +typedef TPM_ENCAUTH TCPA_ENCAUTH; +typedef TPM_PCRINDEX TCPA_PCRINDEX; +typedef TPM_PCRVALUE TCPA_PCRVALUE; +typedef TPM_DIRINDEX TCPA_DIRINDEX; +typedef TPM_PROTOCOL_ID TCPA_PROTOCOL_ID; +typedef TPM_ALGORITHM_ID TCPA_ALGORITHM_ID; +typedef TPM_ENTITY_TYPE TCPA_ENTITY_TYPE; +typedef TPM_CAPABILITY_AREA TCPA_CAPABILITY_AREA; +typedef TPM_HMAC TCPA_HMAC; +typedef TPM_MIGRATE_SCHEME TCPA_MIGRATE_SCHEME; +typedef TPM_PHYSICAL_PRESENCE TCPA_PHYSICAL_PRESENCE; +typedef TPM_KEY_HANDLE TCPA_KEY_HANDLE; +typedef TPM_KEY_HANDLE_LIST TCPA_KEY_HANDLE_LIST; +typedef TPM_PCR_COMPOSITE TCPA_PCR_COMPOSITE; +typedef TPM_AUTH_DATA_USAGE TCPA_AUTH_DATA_USAGE; +typedef TPM_AUTHDATA TCPA_AUTHDATA; +typedef TPM_KEY_USAGE TCPA_KEY_USAGE; +typedef TPM_COMPOSITE_HASH TCPA_COMPOSITE_HASH; +typedef TPM_QUOTE_INFO TCPA_QUOTE_INFO; +typedef TPM_TAG TCPA_TAG; +typedef TPM_ENC_SCHEME TCPA_ENC_SCHEME; +typedef TPM_SIG_SCHEME TCPA_SIG_SCHEME; +typedef TPM_STARTUP_TYPE TCPA_STARTUP_TYPE; +typedef TPM_AUTHHANDLE TCPA_AUTHHANDLE; +typedef TPM_SYM_CA_ATTESTATION TCPA_SYM_CA_ATTESTATION; +typedef TPM_ASYM_CA_CONTENTS TCPA_ASYM_CA_CONTENTS; +typedef TPM_IDENTITY_REQ TCPA_IDENTITY_REQ; +typedef TPM_IDENTITY_PROOF TCPA_IDENTITY_PROOF; + +// These were removed from the 1.2 TPM spec +typedef UINT32 TCPA_ENCHANDLE; +typedef UINT32 TCPA_EVENTTYPE; +typedef struct tdTCPA_AUDIT_EVENT { + TCPA_COMMAND_CODE ordinal; + TCPA_RESULT returncode; +} TCPA_AUDIT_EVENT; + +#define TCPA_SHA1_160_HASH_LEN TPM_SHA1_160_HASH_LEN +#define TCPA_SHA1BASED_NONCE_LEN TPM_SHA1BASED_NONCE_LEN + +#define redirection TSS_KEYFLAG_REDIRECTION +#define migratable TSS_KEYFLAG_MIGRATABLE +#define volatileKey TSS_KEYFLAG_VOLATILEKEY + +#define TCPA_ET_KEYHANDLE TPM_ET_KEYHANDLE +#define TCPA_ET_KEY TPM_ET_KEY +#define TCPA_ET_OWNER TPM_ET_OWNER +#define TCPA_ET_SRK TPM_ET_SRK +#define TCPA_ET_DATA TPM_ET_DATA + +#define TCPA_PID_OIAP TPM_PID_OIAP +#define TCPA_PID_OSAP TPM_PID_OSAP +#define TCPA_PID_ADIP TPM_PID_ADIP +#define TCPA_PID_ADCP TPM_PID_ADCP +#define TCPA_PID_OWNER TPM_PID_OWNER + +#define TCPA_PT_ASYM TPM_PT_ASYM +#define TCPA_PT_BIND TPM_PT_BIND +#define TCPA_PT_MIGRATE TPM_PT_MIGRATE +#define TCPA_PT_MAINT TPM_PT_MAINT +#define TCPA_PT_SEAL TPM_PT_SEAL + +#define TCPA_CAP_ALG TPM_CAP_ALG +#define TCPA_CAP_ORD TPM_CAP_ORD +#define TCPA_CAP_PID TPM_CAP_PID +#define TCPA_CAP_FLAG TPM_CAP_FLAG +#define TCPA_CAP_VERSION TPM_CAP_VERSION +#define TCPA_CAP_PROPERTY TPM_CAP_PROPERTY +#define TCPA_CAP_KEY_HANDLE TPM_CAP_KEY_HANDLE +#define TCPA_CAP_CHECK_LOADED TPM_CAP_CHECK_LOADED + +#define TCPA_ALG_RSA TPM_ALG_RSA +#define TCPA_ALG_DES TPM_ALG_DES +#define TCPA_ALG_3DES TPM_ALG_3DES +#define TCPA_ALG_SHA TPM_ALG_SHA +#define TCPA_ALG_HMAC TPM_ALG_HMAC +#define TCPA_ALG_AES TPM_ALG_AES + +#define TCPA_PROTECTED_ORDINAL TPM_PROTECTED_ORDINAL +#define TCPA_UNPROTECTED_ORDINAL TPM_UNPROTECTED_ORDINAL +#define TCPA_CONNECTION_ORDINAL TPM_CONNECTION_ORDINAL + +#define TCPA_PROTECTED_COMMAND TPM_PROTECTED_COMMAND +#define TCPA_UNPROTECTED_COMMAND TPM_UNPROTECTED_COMMAND +#define TCPA_CONNECTION_COMMAND TPM_CONNECTION_COMMAND +#define TCPA_VENDOR_COMMAND TPM_VENDOR_COMMAND + +#define TCPA_MAIN TPM_MAIN +#define TCPA_PC TPM_PC +#define TCPA_PDA TPM_PDA +#define TCPA_CELL_PHONE TPM_CELL_PHONE + +#define TCPA_MS_MIGRATE TPM_MS_MIGRATE +#define TCPA_MS_REWRAP TPM_MS_REWRAP +#define TCPA_MS_MAINT TPM_MS_MAINT + +#define TCPA_ES_NONE TPM_ES_NONE +#define TCPA_ES_RSAESPKCSv15 TPM_ES_RSAESPKCSv15 +#define TCPA_ES_RSAESOAEP_SHA1_MGF1 TPM_ES_RSAESOAEP_SHA1_MGF1 + +#define TCPA_SS_NONE TPM_SS_NONE +#define TCPA_SS_RSASSAPKCS1v15_SHA1 TPM_SS_RSASSAPKCS1v15_SHA1 +#define TCPA_SS_RSASSAPKCS1v15_DER TPM_SS_RSASSAPKCS1v15_DER +#define TCPA_SS_RSASSAPKCS1v15_INFO TPM_SS_RSASSAPKCS1v15_INFO + +#define TCPA_PHYSICAL_PRESENCE_LIFETIME_LOCK TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK +#define TCPA_PHYSICAL_PRESENCE_HW_ENABLE TPM_PHYSICAL_PRESENCE_HW_ENABLE +#define TCPA_PHYSICAL_PRESENCE_CMD_ENABLE TPM_PHYSICAL_PRESENCE_CMD_ENABLE +#define TCPA_PHYSICAL_PRESENCE_LOCK TPM_PHYSICAL_PRESENCE_LOCK +#define TCPA_PHYSICAL_PRESENCE_PRESENT TPM_PHYSICAL_PRESENCE_PRESENT +#define TCPA_PHYSICAL_PRESENCE_NOTPRESENT TPM_PHYSICAL_PRESENCE_NOTPRESENT + +#define TCPA_SUCCESS TPM_SUCCESS +#define TCPA_E_BASE TPM_E_BASE +#define TCPA_E_NON_FATAL TPM_E_NON_FATAL +#define TCPA_E_AUTHFAIL TPM_E_AUTHFAIL +#define TCPA_E_BAD_PARAMETER TPM_E_BAD_PARAMETER +#define TCPA_E_BADINDEX TPM_E_BADINDEX +#define TCPA_E_AUDITFAILURE TPM_E_AUDITFAILURE +#define TCPA_E_CLEAR_DISABLED TPM_E_CLEAR_DISABLED +#define TCPA_E_DEACTIVATED TPM_E_DEACTIVATED +#define TCPA_E_DISABLED TPM_E_DISABLED +#define TCPA_E_DISABLED_CMD TPM_E_DISABLED_CMD +#define TCPA_E_FAIL TPM_E_FAIL +#define TCPA_E_INACTIVE TPM_E_BAD_ORDINAL +#define TCPA_E_INSTALL_DISABLED TPM_E_INSTALL_DISABLED +#define TCPA_E_INVALID_KEYHANDLE TPM_E_INVALID_KEYHANDLE +#define TCPA_E_KEYNOTFOUND TPM_E_KEYNOTFOUND +#define TCPA_E_NEED_SELFTEST TPM_E_INAPPROPRIATE_ENC +#define TCPA_E_MIGRATEFAIL TPM_E_MIGRATEFAIL +#define TCPA_E_NO_PCR_INFO TPM_E_INVALID_PCR_INFO +#define TCPA_E_NOSPACE TPM_E_NOSPACE +#define TCPA_E_NOSRK TPM_E_NOSRK +#define TCPA_E_NOTSEALED_BLOB TPM_E_NOTSEALED_BLOB +#define TCPA_E_OWNER_SET TPM_E_OWNER_SET +#define TCPA_E_RESOURCES TPM_E_RESOURCES +#define TCPA_E_SHORTRANDOM TPM_E_SHORTRANDOM +#define TCPA_E_SIZE TPM_E_SIZE +#define TCPA_E_WRONGPCRVAL TPM_E_WRONGPCRVAL +#define TCPA_E_BAD_PARAM_SIZE TPM_E_BAD_PARAM_SIZE +#define TCPA_E_SHA_THREAD TPM_E_SHA_THREAD +#define TCPA_E_SHA_ERROR TPM_E_SHA_ERROR +#define TCPA_E_FAILEDSELFTEST TPM_E_FAILEDSELFTEST +#define TCPA_E_AUTH2FAIL TPM_E_AUTH2FAIL +#define TCPA_E_BADTAG TPM_E_BADTAG +#define TCPA_E_IOERROR TPM_E_IOERROR +#define TCPA_E_ENCRYPT_ERROR TPM_E_ENCRYPT_ERROR +#define TCPA_E_DECRYPT_ERROR TPM_E_DECRYPT_ERROR +#define TCPA_E_INVALID_AUTHHANDLE TPM_E_INVALID_AUTHHANDLE +#define TCPA_E_NO_ENDORSEMENT TPM_E_NO_ENDORSEMENT +#define TCPA_E_INVALID_KEYUSAGE TPM_E_INVALID_KEYUSAGE +#define TCPA_E_WRONG_ENTITYTYPE TPM_E_WRONG_ENTITYTYPE +#define TCPA_E_INVALID_POSTINIT TPM_E_INVALID_POSTINIT +#define TCPA_E_INAPPROPRIATE_SIG TPM_E_INAPPROPRIATE_SIG +#define TCPA_E_BAD_KEY_PROPERTY TPM_E_BAD_KEY_PROPERTY +#define TCPA_E_BAD_MIGRATION TPM_E_BAD_MIGRATION +#define TCPA_E_BAD_SCHEME TPM_E_BAD_SCHEME +#define TCPA_E_BAD_DATASIZE TPM_E_BAD_DATASIZE +#define TCPA_E_BAD_MODE TPM_E_BAD_MODE +#define TCPA_E_BAD_PRESENCE TPM_E_BAD_PRESENCE +#define TCPA_E_BAD_VERSION TPM_E_BAD_VERSION +#define TCPA_E_RETRY TPM_E_RETRY + +#endif diff --git a/illumos-x86_64/usr/include/tss/platform.h b/illumos-x86_64/usr/include/tss/platform.h new file mode 100644 index 00000000..251e13e1 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/platform.h @@ -0,0 +1,46 @@ +/*++ + +There are platform dependent and general defines. + +--*/ + +#ifndef TSS_PLATFORM_H +#define TSS_PLATFORM_H + + +/* The default implementation is to use stdint.h, a part of the C99 standard. + * Systems that don't support this are handled on a case-by-case basis. + */ + +#if !defined(WIN32) +#include + typedef uint8_t BYTE; + typedef int8_t TSS_BOOL; + typedef uint16_t UINT16; + typedef uint32_t UINT32; + typedef uint64_t UINT64; + + typedef uint16_t TSS_UNICODE; + typedef void* PVOID; + +#elif defined(WIN32) +#include + typedef unsigned char BYTE; + typedef signed char TSS_BOOL; +#ifndef _BASETSD_H_ + // basetsd.h provides definitions of UINT16, UINT32 and UINT64. + typedef unsigned short UINT16; + typedef unsigned long UINT32; + typedef unsigned __int64 UINT64; +#endif + typedef unsigned short TSS_UNICODE; + typedef void* PVOID; +#endif + + +/* Include this so that applications that use names as defined in the + * 1.1 TSS specification can still compile + */ +#include + +#endif // TSS_PLATFORM_H diff --git a/illumos-x86_64/usr/include/tss/tcpa_defines.h b/illumos-x86_64/usr/include/tss/tcpa_defines.h new file mode 100644 index 00000000..acc391de --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcpa_defines.h @@ -0,0 +1,7 @@ + +#ifndef __TCPA_DEFINES_H__ +#define __TCPA_DEFINES_H__ + +#warning including deprecated header file tcpa_defines.h + +#endif diff --git a/illumos-x86_64/usr/include/tss/tcpa_error.h b/illumos-x86_64/usr/include/tss/tcpa_error.h new file mode 100644 index 00000000..cbb2a22e --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcpa_error.h @@ -0,0 +1,7 @@ + +#ifndef __TCPA_ERROR_H__ +#define __TCPA_ERROR_H__ + +#warning including deprecated header file tcpa_error.h + +#endif diff --git a/illumos-x86_64/usr/include/tss/tcpa_struct.h b/illumos-x86_64/usr/include/tss/tcpa_struct.h new file mode 100644 index 00000000..1b5b95dc --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcpa_struct.h @@ -0,0 +1,7 @@ + +#ifndef __TCPA_STRUCT_H__ +#define __TCPA_STRUCT_H__ + +#warning including deprecated header file tcpa_struct.h + +#endif diff --git a/illumos-x86_64/usr/include/tss/tcpa_typedef.h b/illumos-x86_64/usr/include/tss/tcpa_typedef.h new file mode 100644 index 00000000..a0de2fc2 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcpa_typedef.h @@ -0,0 +1,7 @@ + +#ifndef __TCPA_TYPEDEF_H__ +#define __TCPA_TYPEDEF_H__ + +#warning including deprecated header file tcpa_typedef.h + +#endif diff --git a/illumos-x86_64/usr/include/tss/tcs.h b/illumos-x86_64/usr/include/tss/tcs.h new file mode 100644 index 00000000..f6538da0 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcs.h @@ -0,0 +1,1129 @@ +#ifndef TCS_H +#define TCS_H +#include +#include +#include +#include +#include +#include +#include + +#if defined __cplusplus +extern "C" { +#endif + +extern TSS_RESULT Tcsi_OpenContext +( + TCS_CONTEXT_HANDLE* hContext // out +); +extern TSS_RESULT Tcsi_CloseContext +( + TCS_CONTEXT_HANDLE hContext // in +); +extern TSS_RESULT Tcsi_FreeMemory +( + TCS_CONTEXT_HANDLE hContext, // in + BYTE* pMemory // in +); +extern TSS_RESULT Tcsi_GetCapability +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_CAPABILITY_AREA capArea, // in + UINT32 subCapSize, // in + BYTE* subCap, // in + UINT32* respSize, // out + BYTE** resp // out +); +extern TSS_RESULT Tcsi_RegisterKey +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_UUID WrappingKeyUUID, // in + TSS_UUID KeyUUID, // in + UINT32 cKeySize, // in + BYTE* rgbKey, // in + UINT32 cVendorDataSize, // in + BYTE* gbVendorData // in +); +extern TSS_RESULT Tcsip_UnregisterKey +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_UUID KeyUUID // in +); +extern TSS_RESULT Tcsip_KeyControlOwner +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hKey, // in + UINT32 ulPubKeyLength, // in + BYTE* prgbPubKey, // in + UINT32 attribName, // in + TSS_BOOL attribValue, // in + TPM_AUTH* pOwnerAuth, // in, out + TSS_UUID* pUuidData // out +); +extern TSS_RESULT Tcsi_EnumRegisteredKeys +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_UUID* pKeyUUID, // in + UINT32* pcKeyHierarchySize, // out + TSS_KM_KEYINFO** ppKeyHierarchy // out +); +extern TSS_RESULT Tcsi_GetRegisteredKey +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_UUID KeyUUID, // in + TSS_KM_KEYINFO** ppKeyInfo // out +); +extern TSS_RESULT Tcsi_GetRegisteredKeyBlob +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_UUID KeyUUID, // in + UINT32* pcKeySize, // out + BYTE** prgbKey // out +); +extern TSS_RESULT Tcsip_GetRegisteredKeyByPublicInfo +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_ALGORITHM_ID algID, // in + UINT32 ulPublicInfoLength, // in + BYTE* rgbPublicInfo, // in + UINT32* keySize, // out + BYTE** keyBlob // out +); +extern TSS_RESULT Tcsip_LoadKeyByBlob +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hUnwrappingKey, // in + UINT32 cWrappedKeyBlobSize, // in + BYTE* rgbWrappedKeyBlob, // in + TPM_AUTH* pAuth, // in, out + TCS_KEY_HANDLE* phKeyTCSI, // out + TCS_KEY_HANDLE* phKeyHMAC // out +); +extern TSS_RESULT Tcsip_LoadKeyByUUID +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_UUID KeyUUID, // in + TCS_LOADKEY_INFO* pLoadKeyInfo, // in, out + TCS_KEY_HANDLE* phKeyTCSI // out +); +extern TSS_RESULT Tcsip_EvictKey +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hKey // in +); +extern TSS_RESULT Tcsip_CreateWrapKey +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hWrappingKey, // in + TPM_ENCAUTH KeyUsageAuth, // in + TPM_ENCAUTH KeyMigrationAuth, // in + UINT32 keyInfoSize, // in + BYTE* keyInfo, // in + TPM_AUTH* pAuth, // in, out + UINT32* keyDataSize, // out + BYTE** keyData // out +); +extern TSS_RESULT Tcsip_GetPubKey +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hKey, // in + TPM_AUTH* pAuth, // in, out + UINT32* pcPubKeySize, // out + BYTE** prgbPubKey // out +); +extern TSS_RESULT Tcsip_MakeIdentity +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_ENCAUTH identityAuth, // in + TPM_CHOSENID_HASH IDLabel_PrivCAHash, // in + UINT32 idIdentityKeyInfoSize, // in + BYTE* idIdentityKeyInfo, // in + TPM_AUTH* pSrkAuth, // in, out + TPM_AUTH* pOwnerAuth, // in, out + UINT32* idIdentityKeySize, // out + BYTE** idIdentityKey, // out + UINT32* pcIdentityBindingSize, // out + BYTE** prgbIdentityBinding, // out + UINT32* pcEndorsementCredentialSize, // out + BYTE** prgbEndorsementCredential, // out + UINT32* pcPlatformCredentialSize, // out + BYTE** prgbPlatformCredential, // out + UINT32* pcConformanceCredentialSize, // out + BYTE** prgbConformanceCredential // out +); +extern TSS_RESULT Tcsip_MakeIdentity2 +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_ENCAUTH identityAuth, // in + TPM_CHOSENID_HASH IDLabel_PrivCAHash, // in + UINT32 idIdentityKeyInfoSize, // in + BYTE* idIdentityKeyInfo, // in + TPM_AUTH* pSrkAuth, // in, out + TPM_AUTH* pOwnerAuth, // in, out + UINT32* idIdentityKeySize, // out + BYTE** idIdentityKey, // out + UINT32* pcIdentityBindingSize, // out + BYTE** prgbIdentityBinding // out +); +extern TSS_RESULT Tcsi_LogPcrEvent +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_PCR_EVENT Event, // in + UINT32* pNumber // out +); +extern TSS_RESULT Tcsi_GetPcrEvent +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 PcrIndex, // in + UINT32* pNumber, // in, out + TSS_PCR_EVENT** ppEvent // out +); +extern TSS_RESULT Tcsi_GetPcrEventsByPcr +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 PcrIndex, // in + UINT32 FirstEvent, // in + UINT32* pEventCount, // in, out + TSS_PCR_EVENT** ppEvents // out +); +extern TSS_RESULT Tcsi_GetPcrEventLog +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32* pEventCount, // out + TSS_PCR_EVENT** ppEvents // out +); +extern TSS_RESULT Tcsip_SetOwnerInstall +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_BOOL state // in +); +extern TSS_RESULT Tcsip_TakeOwnership +( + TCS_CONTEXT_HANDLE hContext, // in + UINT16 protocolID, // in + UINT32 encOwnerAuthSize, // in + BYTE* encOwnerAuth, // in + UINT32 encSrkAuthSize, // in + BYTE* encSrkAuth, // in + UINT32 srkKeyInfoSize, // in + BYTE* srkKeyInfo, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* srkKeyDataSize, // out + BYTE** srkKeyData // out +); +extern TSS_RESULT Tcsip_SetOperatorAuth +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_SECRET operatorAuth // in +); +extern TSS_RESULT Tcsip_OIAP +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_AUTHHANDLE* authHandle, // out + TPM_NONCE* nonce0 // out +); +extern TSS_RESULT Tcsip_OSAP +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_ENTITY_TYPE entityType, // in + UINT32 entityValue, // in + TPM_NONCE nonceOddOSAP, // in + TCS_AUTHHANDLE* authHandle, // out + TPM_NONCE* nonceEven, // out + TPM_NONCE* nonceEvenOSAP // out +); +extern TSS_RESULT Tcsip_ChangeAuth +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE parentHandle, // in + TPM_PROTOCOL_ID protocolID, // in + TPM_ENCAUTH newAuth, // in + TPM_ENTITY_TYPE entityType, // in + UINT32 encDataSize, // in + BYTE* encData, // in + TPM_AUTH* ownerAuth, // in, out + TPM_AUTH* entityAuth, // in, out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_ChangeAuthOwner +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_PROTOCOL_ID protocolID, // in + TPM_ENCAUTH newAuth, // in + TPM_ENTITY_TYPE entityType, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_ChangeAuthAsymStart +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE idHandle, // in + TPM_NONCE antiReplay, // in + UINT32 TempKeyInfoSize, // in + BYTE* TempKeyInfoData, // in + TPM_AUTH* pAuth, // in, out + UINT32* TempKeySize, // out + BYTE** TempKeyData, // out + UINT32* CertifyInfoSize, // out + BYTE** CertifyInfo, // out + UINT32* sigSize, // out + BYTE** sig, // out + TCS_KEY_HANDLE* ephHandle // out +); +extern TSS_RESULT Tcsip_ChangeAuthAsymFinish +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE parentHandle, // in + TCS_KEY_HANDLE ephHandle, // in + TPM_ENTITY_TYPE entityType, // in + TPM_HMAC newAuthLink, // in + UINT32 newAuthSize, // in + BYTE* encNewAuth, // in + UINT32 encDataSizeIn, // in + BYTE* encDataIn, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* encDataSizeOut, // out + BYTE** encDataOut, // out + TPM_NONCE* saltNonce, // out + TPM_DIGEST* changeProof // out +); +extern TSS_RESULT Tcsip_TerminateHandle +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_AUTHHANDLE handle // in +); +extern TSS_RESULT Tcsip_ActivateTPMIdentity +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE idKey, // in + UINT32 blobSize, // in + BYTE* blob, // in + TPM_AUTH* idKeyAuth, // in, out + TPM_AUTH* ownerAuth, // in, out + UINT32* SymmetricKeySize, // out + BYTE** SymmetricKey // out +); +extern TSS_RESULT Tcsip_EstablishTransport +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 ulTransControlFlags, // in + TCS_KEY_HANDLE hEncKey, // in + UINT32 ulTransSessionInfoSize, // in + BYTE* rgbTransSessionInfo, // in + UINT32 ulSecretSize, // in + BYTE* rgbSecret, // in + TPM_AUTH* pEncKeyAuth, // in, out + TPM_MODIFIER_INDICATOR* pbLocality, // out + TCS_HANDLE* hTransSession, // out + UINT32* ulCurrentTicksSize, // out + BYTE** prgbCurrentTicks, // out + TPM_NONCE* pTransNonce // out +); +extern TSS_RESULT Tcsip_ExecuteTransport +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_COMMAND_CODE unWrappedCommandOrdinal, // in + UINT32 ulWrappedCmdParamInSize, // in + BYTE* rgbWrappedCmdParamIn, // in + UINT32* pulHandleListSize, // in, out + TCS_HANDLE** rghHandles, // in, out + TPM_AUTH* pWrappedCmdAuth1, // in, out + TPM_AUTH* pWrappedCmdAuth2, // in, out + TPM_AUTH* pTransAuth, // in, out + UINT64* punCurrentTicks, // out + TPM_MODIFIER_INDICATOR* pbLocality, // out + TPM_RESULT* pulWrappedCmdReturnCode, // out + UINT32* ulWrappedCmdParamOutSize, // out + BYTE** rgbWrappedCmdParamOut // out +); +extern TSS_RESULT Tcsip_ReleaseTransportSigned +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hSignatureKey, // in + TPM_NONCE AntiReplayNonce, // in + TPM_AUTH* pKeyAuth, // in, out + TPM_AUTH* pTransAuth, // in, out + TPM_MODIFIER_INDICATOR* pbLocality, // out + UINT32* pulCurrentTicksSize, // out + BYTE** prgbCurrentTicks, // out + UINT32* pulSignatureSize, // out + BYTE** prgbSignature // out +); +extern TSS_RESULT Tcsip_Extend +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_PCRINDEX pcrNum, // in + TPM_DIGEST inDigest, // in + TPM_PCRVALUE* outDigest // out +); +extern TSS_RESULT Tcsip_PcrRead +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_PCRINDEX pcrNum, // in + TPM_PCRVALUE* outDigest // out +); +extern TSS_RESULT Tcsip_Quote +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_NONCE antiReplay, // in + UINT32 pcrTargetSize, // in + BYTE* pcrTarget, // in + TPM_AUTH* privAuth, // in, out + UINT32* pcrDataSize, // out + BYTE** pcrData, // out + UINT32* sigSize, // out + BYTE** sig // out +); +extern TSS_RESULT Tcsip_Quote2 +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_NONCE antiReplay, // in + UINT32 pcrTargetSize, // in + BYTE* pcrTarget, // in + TSS_BOOL addVersion, // in + TPM_AUTH* privAuth, // in, out + UINT32* pcrDataSize, // out + BYTE** pcrData, // out + UINT32* versionInfoSize, // out + BYTE** versionInfo, // out + UINT32* sigSize, // out + BYTE** sig // out +); +extern TSS_RESULT Tcsip_DirWriteAuth +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_DIRINDEX dirIndex, // in + TPM_DIRVALUE newContents, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_DirRead +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_DIRINDEX dirIndex, // in + TPM_DIRVALUE* dirValue // out +); +extern TSS_RESULT Tcsip_Seal +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_ENCAUTH encAuth, // in + UINT32 pcrInfoSize, // in + BYTE* PcrInfo, // in + UINT32 inDataSize, // in + BYTE* inData, // in + TPM_AUTH* pubAuth, // in, out + UINT32* SealedDataSize, // out + BYTE** SealedData // out +); +extern TSS_RESULT Tcsip_Unseal +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + UINT32 SealedDataSize, // in + BYTE* SealedData, // in + TPM_AUTH* keyAuth, // in, out + TPM_AUTH* dataAuth, // in, out + UINT32* DataSize, // out + BYTE** Data // out +); +extern TSS_RESULT Tcsip_UnBind +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + UINT32 inDataSize, // in + BYTE* inData, // in + TPM_AUTH* privAuth, // in, out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_Sealx +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_ENCAUTH encAuth, // in + UINT32 pcrInfoSize, // in + BYTE* PcrInfo, // in + UINT32 inDataSize, // in + BYTE* inData, // in + TPM_AUTH* pubAuth, // in, out + UINT32* SealedDataSize, // out + BYTE** SealedData // out +); +extern TSS_RESULT Tcsip_LoadKey2ByBlob +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hUnwrappingKey, // in + UINT32 cWrappedKeyBlobSize, // in + BYTE* rgbWrappedKeyBlob, // in + TPM_AUTH* pAuth, // in, out + TCS_KEY_HANDLE* phKeyTCSI // out +); +extern TSS_RESULT Tcsip_CreateMigrationBlob +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE parentHandle, // in + TSS_MIGRATE_SCHEME migrationType, // in + UINT32 MigrationKeyAuthSize, // in + BYTE* MigrationKeyAuth, // in + UINT32 encDataSize, // in + BYTE* encData, // in + TPM_AUTH* parentAuth, // in, out + TPM_AUTH* entityAuth, // in, out + UINT32* randomSize, // out + BYTE** random, // out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_ConvertMigrationBlob +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE parentHandle, // in + UINT32 inDataSize, // in + BYTE* inData, // in + UINT32 randomSize, // in + BYTE* random, // in + TPM_AUTH* parentAuth, // in, out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_AuthorizeMigrationKey +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_MIGRATE_SCHEME migrateScheme, // in + UINT32 MigrationKeySize, // in + BYTE* MigrationKey, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* MigrationKeyAuthSize, // out + BYTE** MigrationKeyAuth // out +); +extern TSS_RESULT Tcsip_CertifyKey +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE certHandle, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_NONCE antiReplay, // in + TPM_AUTH* certAuth, // in, out + TPM_AUTH* keyAuth, // in, out + UINT32* CertifyInfoSize, // out + BYTE** CertifyInfo, // out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_CertifyKey2 +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE certHandle, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_DIGEST MSAdigest, // in + TPM_NONCE antiReplay, // in + TPM_AUTH* certAuth, // in, out + TPM_AUTH* keyAuth, // in, out + UINT32* CertifyInfoSize, // out + BYTE** CertifyInfo, // out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_Sign +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + UINT32 areaToSignSize, // in + BYTE* areaToSign, // in + TPM_AUTH* privAuth, // in, out + UINT32* sigSize, // out + BYTE** sig // out +); +extern TSS_RESULT Tcsip_GetRandom +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32* bytesRequested, // in, out + BYTE** randomBytes // out +); +extern TSS_RESULT Tcsip_StirRandom +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 inDataSize, // in + BYTE* inData // in +); +extern TSS_RESULT Tcsip_GetCapability +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_CAPABILITY_AREA capArea, // in + UINT32 subCapSize, // in + BYTE* subCap, // in + UINT32* respSize, // out + BYTE** resp // out +); +extern TSS_RESULT Tcsip_GetCapabilitySigned +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_NONCE antiReplay, // in + TPM_CAPABILITY_AREA capArea, // in + UINT32 subCapSize, // in + BYTE* subCap, // in + TPM_AUTH* privAuth, // in, out + TPM_VERSION* Version, // out + UINT32* respSize, // out + BYTE** resp, // out + UINT32* sigSize, // out + BYTE** sig // out +); +extern TSS_RESULT Tcsip_GetCapabilityOwner +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_AUTH* pOwnerAuth, // in, out + TPM_VERSION* pVersion, // out + UINT32* pNonVolatileFlags, // out + UINT32* pVolatileFlags // out +); +extern TSS_RESULT Tcsip_CreateEndorsementKeyPair +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_NONCE antiReplay, // in + UINT32 endorsementKeyInfoSize, // in + BYTE* endorsementKeyInfo, // in + UINT32* endorsementKeySize, // out + BYTE** endorsementKey, // out + TPM_DIGEST* checksum // out +); +extern TSS_RESULT Tcsip_ReadPubek +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_NONCE antiReplay, // in + UINT32* pubEndorsementKeySize, // out + BYTE** pubEndorsementKey, // out + TPM_DIGEST* checksum // out +); +extern TSS_RESULT Tcsip_DisablePubekRead +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_OwnerReadPubek +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* pubEndorsementKeySize, // out + BYTE** pubEndorsementKey // out +); +extern TSS_RESULT Tcsip_SelfTestFull +( + TCS_CONTEXT_HANDLE hContext // in +); +extern TSS_RESULT Tcsip_CertifySelfTest +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_NONCE antiReplay, // in + TPM_AUTH* privAuth, // in, out + UINT32* sigSize, // out + BYTE** sig // out +); +extern TSS_RESULT Tcsip_ContinueSelfTest +( + TCS_CONTEXT_HANDLE hContext // in +); +extern TSS_RESULT Tcsip_GetTestResult +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_OwnerSetDisable +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_BOOL disableState, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_OwnerClear +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_DisableOwnerClear +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_ForceClear +( + TCS_CONTEXT_HANDLE hContext // in +); +extern TSS_RESULT Tcsip_DisableForceClear +( + TCS_CONTEXT_HANDLE hContext // in +); +extern TSS_RESULT Tcsip_PhysicalDisable +( + TCS_CONTEXT_HANDLE hContext // in +); +extern TSS_RESULT Tcsip_PhysicalEnable +( + TCS_CONTEXT_HANDLE hContext // in +); +extern TSS_RESULT Tcsip_PhysicalSetDeactivated +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_BOOL state // in +); +extern TSS_RESULT Tcsip_SetTempDeactivated +( + TCS_CONTEXT_HANDLE hContext // in +); +extern TSS_RESULT Tcsip_SetTempDeactivated2 +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_AUTH* pOperatorAuth // in, out +); +extern TSS_RESULT Tcsip_OwnerReadInternalPub +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hKey, // in + TPM_AUTH* pOwnerAuth, // in, out + UINT32* punPubKeySize, // out + BYTE** ppbPubKeyData // out +); +extern TSS_RESULT Tcsip_PhysicalPresence +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_PHYSICAL_PRESENCE fPhysicalPresence // in +); +extern TSS_RESULT Tcsip_FieldUpgrade +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 dataInSize, // in + BYTE* dataIn, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* dataOutSize, // out + BYTE** dataOut // out +); +extern TSS_RESULT Tcsip_ResetLockValue +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_FlushSpecific +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_HANDLE hResHandle, // in + TPM_RESOURCE_TYPE resourceType // in +); +extern TSS_RESULT Tcsip_SetRedirection +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + UINT32 c1, // in + UINT32 c2, // in + TPM_AUTH* privAuth // in, out +); +extern TSS_RESULT Tcsip_DSAP +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_ENTITY_TYPE entityType, // in + TCS_KEY_HANDLE keyHandle, // in + TPM_NONCE nonceOddDSAP, // in + UINT32 entityValueSize, // in + BYTE* entityValue, // in + TCS_AUTHHANDLE* authHandle, // out + TPM_NONCE* nonceEven, // out + TPM_NONCE* nonceEvenDSAP // out +); +extern TSS_RESULT Tcsip_Delegate_Manage +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_FAMILY_ID familyID, // in + TPM_FAMILY_OPERATION opFlag, // in + UINT32 opDataSize, // in + BYTE* opData, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* retDataSize, // out + BYTE** retData // out +); +extern TSS_RESULT Tcsip_Delegate_CreateKeyDelegation +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hKey, // in + UINT32 publicInfoSize, // in + BYTE* publicInfo, // in + TPM_ENCAUTH encDelAuth, // in + TPM_AUTH* keyAuth, // in, out + UINT32* blobSize, // out + BYTE** blob // out +); +extern TSS_RESULT Tcsip_Delegate_CreateOwnerDelegation +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_BOOL increment, // in + UINT32 publicInfoSize, // in + BYTE* publicInfo, // in + TPM_ENCAUTH encDelAuth, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* blobSize, // out + BYTE** blob // out +); +extern TSS_RESULT Tcsip_Delegate_LoadOwnerDelegation +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_DELEGATE_INDEX index, // in + UINT32 blobSize, // in + BYTE* blob, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_Delegate_UpdateVerificationCount +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 inputSize, // in + BYTE* input, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* outputSize, // out + BYTE** output // out +); +extern TSS_RESULT Tcsip_Delegate_VerifyDelegation +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 delegateSize, // in + BYTE* delegate // in +); +extern TSS_RESULT Tcsip_Delegate_ReadTable +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32* pulFamilyTableSize, // out + BYTE** ppFamilyTable, // out + UINT32* pulDelegateTableSize, // out + BYTE** ppDelegateTable // out +); +extern TSS_RESULT Tcsip_NV_DefineOrReleaseSpace +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 cPubInfoSize, // in + BYTE* pPubInfo, // in + TPM_ENCAUTH encAuth, // in + TPM_AUTH* pAuth // in, out +); +extern TSS_RESULT Tcsip_NV_WriteValue +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_NV_INDEX hNVStore, // in + UINT32 offset, // in + UINT32 ulDataLength, // in + BYTE* rgbDataToWrite, // in + TPM_AUTH* privAuth // in, out +); +extern TSS_RESULT Tcsip_NV_WriteValueAuth +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_NV_INDEX hNVStore, // in + UINT32 offset, // in + UINT32 ulDataLength, // in + BYTE* rgbDataToWrite, // in + TPM_AUTH* NVAuth // in, out +); +extern TSS_RESULT Tcsip_NV_ReadValue +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_NV_INDEX hNVStore, // in + UINT32 offset, // in + UINT32* pulDataLength, // in, out + TPM_AUTH* privAuth, // in, out + BYTE** rgbDataRead // out +); +extern TSS_RESULT Tcsip_NV_ReadValueAuth +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_NV_INDEX hNVStore, // in + UINT32 offset, // in + UINT32* pulDataLength, // in, out + TPM_AUTH* NVAuth, // in, out + BYTE** rgbDataRead // out +); +extern TSS_RESULT Tcsip_CreateMaintenanceArchive +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_BOOL generateRandom, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* randomSize, // out + BYTE** random, // out + UINT32* archiveSize, // out + BYTE** archive // out +); +extern TSS_RESULT Tcsip_LoadMaintenanceArchive +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 dataInSize, // in + BYTE* dataIn, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* dataOutSize, // out + BYTE** dataOut // out +); +extern TSS_RESULT Tcsip_KillMaintenanceFeature +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_LoadManuMaintPub +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_NONCE antiReplay, // in + UINT32 PubKeySize, // in + BYTE* PubKey, // in + TPM_DIGEST* checksum // out +); +extern TSS_RESULT Tcsip_ReadManuMaintPub +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_NONCE antiReplay, // in + TPM_DIGEST* checksum // out +); +extern TSS_RESULT Tcsip_CreateRevocableEndorsementKeyPair +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_NONCE antiReplay, // in + UINT32 endorsementKeyInfoSize, // in + BYTE* endorsementKeyInfo, // in + TSS_BOOL GenResetAuth, // in + TPM_DIGEST* EKResetAuth, // in, out + UINT32* endorsementKeySize, // out + BYTE** endorsementKey, // out + TPM_DIGEST* checksum // out +); +extern TSS_RESULT Tcsip_RevokeEndorsementKeyPair +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_DIGEST EKResetAuth // in +); +extern TSS_RESULT Tcsip_PcrReset +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 pcrTargetSize, // in + BYTE* pcrTarget // in +); +extern TSS_RESULT Tcsip_ReadCounter +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_COUNTER_ID idCounter, // in + TPM_COUNTER_VALUE* counterValue // out +); +extern TSS_RESULT Tcsip_CreateCounter +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 LabelSize, // in (=4) + BYTE* pLabel, // in + TPM_ENCAUTH CounterAuth, // in + TPM_AUTH* pOwnerAuth, // in, out + TSS_COUNTER_ID* idCounter, // out + TPM_COUNTER_VALUE* counterValue // out +); +extern TSS_RESULT Tcsip_IncrementCounter +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_COUNTER_ID idCounter, // in + TPM_AUTH* pCounterAuth, // in, out + TPM_COUNTER_VALUE* counterValue // out +); +extern TSS_RESULT Tcsip_ReleaseCounter +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_COUNTER_ID idCounter, // in + TPM_AUTH* pCounterAuth // in, out +); +extern TSS_RESULT Tcsip_ReleaseCounterOwner +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_COUNTER_ID idCounter, // in + TPM_AUTH* pOwnerAuth // in, out +); +extern TSS_RESULT Tcsip_ReadCurrentTicks +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32* pulCurrentTimeSize, // out + BYTE** prgbCurrentTime // out +); +extern TSS_RESULT Tcsip_TickStampBlob +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hKey, // in + TPM_NONCE antiReplay, // in + TPM_DIGEST digestToStamp, // in + TPM_AUTH* privAuth, // in, out + UINT32* pulSignatureLength, // out + BYTE** prgbSignature, // out + UINT32* pulTickCountSize, // out + BYTE** prgbTickCount // out +); +extern TSS_RESULT Tcsip_TPM_DAA_Join +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_HANDLE handle, // in + BYTE stage, // in + UINT32 inputSize0, // in + BYTE* inputData0, // in + UINT32 inputSize1, // in + BYTE* inputData1, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* outputSize, // out + BYTE** outputData // out +); +extern TSS_RESULT Tcsip_TPM_DAA_Sign +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_HANDLE handle, // in + BYTE stage, // in + UINT32 inputSize0, // in + BYTE* inputData0, // in + UINT32 inputSize1, // in + BYTE* inputData1, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* outputSize, // out + BYTE** outputData // out +); +extern TSS_RESULT Tcsip_MigrateKey +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hMaKey, // in + UINT32 PublicKeySize, // in + BYTE* PublicKey, // in + UINT32 inDataSize, // in + BYTE* inData, // in + TPM_AUTH* ownerAuth, // in, out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_CMK_SetRestrictions +( + TCS_CONTEXT_HANDLE hContext, // in + TSS_CMK_DELEGATE Restriction, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_CMK_ApproveMA +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_DIGEST migAuthorityDigest, // in + TPM_AUTH* ownerAuth, // in, out + TPM_HMAC* HmacMigAuthDigest // out +); +extern TSS_RESULT Tcsip_CMK_CreateKey +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE hWrappingKey, // in + TPM_ENCAUTH KeyUsageAuth, // in + TPM_HMAC MigAuthApproval, // in + TPM_DIGEST MigAuthorityDigest, // in + UINT32* keyDataSize, // in, out + BYTE** prgbKeyData, // in, out + TPM_AUTH* pAuth // in, out +); +extern TSS_RESULT Tcsip_CMK_CreateTicket +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 PublicVerifyKeySize, // in + BYTE* PublicVerifyKey, // in + TPM_DIGEST SignedData, // in + UINT32 SigValueSize, // in + BYTE* SigValue, // in + TPM_AUTH* pOwnerAuth, // in, out + TPM_HMAC* SigTicket // out +); +extern TSS_RESULT Tcsip_CMK_CreateBlob +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE parentHandle, // in + TSS_MIGRATE_SCHEME migrationType, // in + UINT32 MigrationKeyAuthSize, // in + BYTE* MigrationKeyAuth, // in + TPM_DIGEST PubSourceKeyDigest, // in + UINT32 msaListSize, // in + BYTE* msaList, // in + UINT32 restrictTicketSize, // in + BYTE* restrictTicket, // in + UINT32 sigTicketSize, // in + BYTE* sigTicket, // in + UINT32 encDataSize, // in + BYTE* encData, // in + TPM_AUTH* parentAuth, // in, out + UINT32* randomSize, // out + BYTE** random, // out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_CMK_ConvertMigration +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE parentHandle, // in + TPM_CMK_AUTH restrictTicket, // in + TPM_HMAC sigTicket, // in + UINT32 keyDataSize, // in + BYTE* prgbKeyData, // in + UINT32 msaListSize, // in + BYTE* msaList, // in + UINT32 randomSize, // in + BYTE* random, // in + TPM_AUTH* parentAuth, // in, out + UINT32* outDataSize, // out + BYTE** outData // out +); +extern TSS_RESULT Tcsip_SetCapability +( + TCS_CONTEXT_HANDLE hContext, // in + TPM_CAPABILITY_AREA capArea, // in + UINT32 subCapSize, // in + BYTE* subCap, // in + UINT32 valueSize, // in + BYTE* value, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsip_GetAuditDigest +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 startOrdinal, // in + TPM_DIGEST* auditDigest, // out + UINT32* counterValueSize, // out + BYTE** counterValue, // out + TSS_BOOL* more, // out + UINT32* ordSize, // out + UINT32** ordList // out +); +extern TSS_RESULT Tcsip_GetAuditDigestSigned +( + TCS_CONTEXT_HANDLE hContext, // in + TCS_KEY_HANDLE keyHandle, // in + TSS_BOOL closeAudit, // in + TPM_NONCE antiReplay, // in + TPM_AUTH* privAuth, // in, out + UINT32* counterValueSize, // out + BYTE** counterValue, // out + TPM_DIGEST* auditDigest, // out + TPM_DIGEST* ordinalDigest, // out + UINT32* sigSize, // out + BYTE** sig // out +); +extern TSS_RESULT Tcsip_SetOrdinalAuditStatus +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 ordinalToAudit, // in + TSS_BOOL auditState, // in + TPM_AUTH* ownerAuth // in, out +); +extern TSS_RESULT Tcsi_Admin_TSS_SessionsPerLocality +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 ulLocality, // in + UINT32 ulSessions, // in + TPM_AUTH* pOwnerAuth // in, out +); +extern TSS_RESULT Tcsi_GetCredential +( + TCS_CONTEXT_HANDLE hContext, // in + UINT32 ulCredentialType, // in + UINT32 ulCredentialAccessMode, // in + UINT32* pulCredentialSize, // out + BYTE** prgbCredentialData // out +); + +#if defined __cplusplus +} // extern "C" +#endif + +#endif /* TCS_H */ diff --git a/illumos-x86_64/usr/include/tss/tcs_defines.h b/illumos-x86_64/usr/include/tss/tcs_defines.h new file mode 100644 index 00000000..b5a1e3d1 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcs_defines.h @@ -0,0 +1,28 @@ +/*++ + +TSS Core Service structures + +*/ + +#ifndef __TCS_DEFINES_H__ +#define __TCS_DEFINES_H__ + +#define TSS_TCSATTRIB_TRANSPORT_DEFAULT ((UINT32)(0x00000000)) +#define TSS_TCSATTRIB_TRANSPORT_EXCLUSIVE ((UINT32)(0x00000001)) + + +// Values for the ulCredentialType parameter to Tcsi_GetCredential +#define TSS_TCS_CREDENTIAL_EKCERT ((UINT32)0x00000001) +#define TSS_TCS_CREDENTIAL_TPM_CC ((UINT32)0x00000002) +#define TSS_TCS_CREDENTIAL_PLATFORMCERT ((UINT32)0x00000003) + + +// Values for the ulCredentialAccessMode parameter to Tcsi_GetCredential +// TSS_TCS_CERT_ACCESS_AUTO triggers the default behavior. +// Values with TSS_TCS_CERT_VENDOR_SPECIFIC_BIT set trigger +// vendor specific behavior. +#define TSS_TCS_CERT_ACCESS_AUTO ((UINT32)0x00000001) + +#define TSS_TCS_CERT_VENDOR_SPECIFIC_BIT ((UINT32)0x80000000) + +#endif // __TCS_DEFINES_H__ diff --git a/illumos-x86_64/usr/include/tss/tcs_error.h b/illumos-x86_64/usr/include/tss/tcs_error.h new file mode 100644 index 00000000..7ce7ef96 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcs_error.h @@ -0,0 +1,56 @@ +/*++ + +TSS Core Service error return codes + +--*/ + +#ifndef __TCS_ERROR_H__ +#define __TCS_ERROR_H__ + + +#ifndef TSS_E_BASE +#define TSS_E_BASE 0x00000000L +#endif // TSS_E_BASE + +// The context handle supplied is invalid. +#define TCS_E_INVALID_CONTEXTHANDLE (UINT32)(TSS_E_BASE + 0x0C1L) + +// The key handle supplied is invalid. +#define TCS_E_INVALID_KEYHANDLE (UINT32)(TSS_E_BASE + 0x0C2L) + +// The authorization session handle supplied is invalid. +#define TCS_E_INVALID_AUTHHANDLE (UINT32)(TSS_E_BASE + 0x0C3L) + +// the auth session has been closed by the TPM +#define TCS_E_INVALID_AUTHSESSION (UINT32)(TSS_E_BASE + 0x0C4L) + +// the key has been unloaded +#define TCS_E_INVALID_KEY (UINT32)(TSS_E_BASE + 0x0C5L) + +// Key addressed by the application key handle does not match the key addressed +// by the given UUID. +#define TCS_E_KEY_MISMATCH (UINT32)(TSS_E_BASE + 0x0C8L) + +// Key adressed by Key's UUID cannot be loaded because one of the required +// parent keys needs authorization. +#define TCS_E_KM_LOADFAILED (UINT32)(TSS_E_BASE + 0x0CAL) + +// The Key Cache Manager could not reload the key into the TPM. +#define TCS_E_KEY_CONTEXT_RELOAD (UINT32)(TSS_E_BASE + 0x0CCL) + +// Bad memory index +#define TCS_E_BAD_INDEX (UINT32)(TSS_E_BASE + 0x0CDL) + + +// These TCS_E_ macros are defined by name in the TSS spec, however +// they are defined to have the same values as the TSS_E_ equivalents. +#define TCS_SUCCESS TSS_SUCCESS +#define TCS_E_KEY_ALREADY_REGISTERED TSS_E_KEY_ALREADY_REGISTERED +#define TCS_E_KEY_NOT_REGISTERED TSS_E_KEY_NOT_REGISTERED +#define TCS_E_BAD_PARAMETER TSS_E_BAD_PARAMETER +#define TCS_E_OUTOFMEMORY TSS_E_OUTOFMEMORY +#define TCS_E_SIZE TSS_E_SIZE +#define TCS_E_NOTIMPL TSS_E_NOTIMPL +#define TCS_E_INTERNAL_ERROR TSS_E_INTERNAL_ERROR + +#endif // __TCS_ERROR_H__ diff --git a/illumos-x86_64/usr/include/tss/tcs_structs.h b/illumos-x86_64/usr/include/tss/tcs_structs.h new file mode 100644 index 00000000..02554661 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcs_structs.h @@ -0,0 +1,40 @@ +/*++ + +TSS Core Service structures + +*/ + +#ifndef __TCS_STRUCT_H__ +#define __TCS_STRUCT_H__ + +#include +#include +#include + +typedef struct tdTCS_AUTH +{ + TCS_AUTHHANDLE AuthHandle; + TPM_NONCE NonceOdd; // system + TPM_NONCE NonceEven; // TPM + TSS_BOOL fContinueAuthSession; + TPM_AUTHDATA HMAC; +} TCS_AUTH; + +// This is kept for legacy compatibility +typedef TCS_AUTH TPM_AUTH; + + +typedef struct tdTCS_LOADKEY_INFO +{ + TSS_UUID keyUUID; + TSS_UUID parentKeyUUID; + TPM_DIGEST paramDigest; // SHA1 digest of the TPM_LoadKey + // Command input parameters + // As defined in TPM Main Specification + TPM_AUTH authData; // Data regarding a valid auth + // Session including the + // HMAC digest +} TCS_LOADKEY_INFO; + +#endif // __TCS_STRUCT_H__ + diff --git a/illumos-x86_64/usr/include/tss/tcs_typedef.h b/illumos-x86_64/usr/include/tss/tcs_typedef.h new file mode 100644 index 00000000..7ef48af8 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tcs_typedef.h @@ -0,0 +1,32 @@ +/*++ + +Global typedefs for TSS Core Service + +*/ + +#ifndef __TCS_TYPEDEF_H__ +#define __TCS_TYPEDEF_H__ + +#include +#include + +typedef UINT32 TCS_AUTHHANDLE; +typedef UINT32 TCS_CONTEXT_HANDLE; +typedef UINT32 TCS_KEY_HANDLE; +typedef UINT32 TCS_HANDLE; + + +// Substitution definitions for TCS-IDL +typedef TPM_ENCAUTH TCG_ENCAUTH; +typedef TPM_NONCE TCG_NONCE; +typedef TPM_ENTITY_TYPE TCG_ENTITY_TYPE; +typedef TPM_PCRINDEX TCG_PCRINDEX; +typedef TPM_DIGEST TCG_DIGEST; +typedef TPM_PCRVALUE TCG_PCRVALUE; +typedef TPM_DIRVALUE TCG_DIRVALUE; +typedef TPM_DIRINDEX TCG_DIRINDEX; + + + +#endif // __TCS_TYPEDEF_H__ + diff --git a/illumos-x86_64/usr/include/tss/tddl_error.h b/illumos-x86_64/usr/include/tss/tddl_error.h new file mode 100644 index 00000000..0b4b2a40 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tddl_error.h @@ -0,0 +1,51 @@ +/*++ + +TPM Device Driver Library error return codes + +--*/ + +#ifndef __TDDL_ERROR_H__ +#define __TDDL_ERROR_H__ + +#include +#include + + +#ifndef TSS_E_BASE +#define TSS_E_BASE 0x00000000L +#endif // TSS_E_BASE + + +// +// specific error codes returned by the TPM device driver library +// offset TSS_TDDL_OFFSET +// +#define TDDL_E_FAIL TSS_E_FAIL +#define TDDL_E_TIMEOUT TSS_E_TIMEOUT + +// The connection was already established. +#define TDDL_E_ALREADY_OPENED (UINT32)(TSS_E_BASE + 0x081L) + +// The device was not connected. +#define TDDL_E_ALREADY_CLOSED (UINT32)(TSS_E_BASE + 0x082L) + +// The receive buffer is too small. +#define TDDL_E_INSUFFICIENT_BUFFER (UINT32)(TSS_E_BASE + 0x083L) + +// The command has already completed. +#define TDDL_E_COMMAND_COMPLETED (UINT32)(TSS_E_BASE + 0x084L) + +// TPM aborted processing of command. +#define TDDL_E_COMMAND_ABORTED (UINT32)(TSS_E_BASE + 0x085L) + +// The request could not be performed because of an I/O device error. +#define TDDL_E_IOERROR (UINT32)(TSS_E_BASE + 0x087L) + +// Unsupported TAG is requested +#define TDDL_E_BADTAG (UINT32)(TSS_E_BASE + 0x088L) + +// the requested TPM component was not found +#define TDDL_E_COMPONENT_NOT_FOUND (UINT32)(TSS_E_BASE + 0x089L) + +#endif // __TDDL_ERROR_H__ + diff --git a/illumos-x86_64/usr/include/tss/tddlapi_error.h b/illumos-x86_64/usr/include/tss/tddlapi_error.h new file mode 100644 index 00000000..449779ba --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tddlapi_error.h @@ -0,0 +1,54 @@ +/*++ + +TDDL error return codes for the TPM Device Driver Library Interface (TDDLI) + +--*/ + +#ifndef __TDDLAPI_ERROR_H__ +#define __TDDLAPI_ERROR_H__ + + +// +// error coding scheme for a Microsoft Windows platform - +// refer to the TSS Specification Parts +// +// Values are 32 bit values layed out as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---+-+-+-----------------------+-------+-----------------------+ +// |Lev|C|R| Facility | Layer | Code | +// +---+-+-+-----------------------+-------+-----------------------+ +// | Platform specific coding | TSS error coding system | +// +---+-+-+-----------------------+-------+-----------------------+ +// +// Lev - is the Level code +// +// 00 - Success +// 01 - Informational +// 10 - Warning +// 11 - Error +// +// C - is the Customer code flag (must actually be set) +// +// R - is a reserved bit (unused) +// +// Facility - is the facility code: TCPA: proposal 0x028 +// +// Code - is the facility's status code +// + + +// no macros are used below intentionally +// for a better error code recognition by the reader + +// note that the values of TPM_E_BASE and TSS_E_BASE, TSS_W_BASE and TSS_I_BASE +// have to be adjusted for a platform other than Windows + +// +// TPM specific error codes (layer nibble set to TPM layer TSS_LAYER_TPM) +// + + +#endif // __TDDLAPI_ERROR_H__ + diff --git a/illumos-x86_64/usr/include/tss/tddli.h b/illumos-x86_64/usr/include/tss/tddli.h new file mode 100644 index 00000000..2a833b2c --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tddli.h @@ -0,0 +1,94 @@ +/*++ + +TPM Device Driver Library interface + +--*/ + +#ifndef __TDDLI_H__ +#define __TDDLI_H__ + +#include +#include + +#if !defined(TDDLI) +#ifdef WIN32 +// --- This should be used on Windows platforms +#ifdef TDDLI_EXPORTS +#define TDDLI __declspec(dllexport) +#else +#define TDDLI __declspec(dllimport) +#endif +#else +#define TDDLI +#endif +#endif /* !defined(TDDLI) */ + + +#define TDDL_CAP_VERSION 0x0100 +#define TDDL_CAP_VER_DRV 0x0101 +#define TDDL_CAP_VER_FW 0x0102 +#define TDDL_CAP_VER_FW_DATE 0x0103 + +#define TDDL_CAP_PROPERTY 0x0200 +#define TDDL_CAP_PROP_MANUFACTURER 0x0201 +#define TDDL_CAP_PROP_MODULE_TYPE 0x0202 +#define TDDL_CAP_PROP_GLOBAL_STATE 0x0203 + + +//-------------------------------------------------------------------- +// TDDL specific helper redefinitions + +#ifdef __cplusplus +extern "C" { +#endif + + //establish a connection to the TPM device driver + TDDLI TSS_RESULT Tddli_Open(void); + + //close a open connection to the TPM device driver + TDDLI TSS_RESULT Tddli_Close(void); + + //cancels the last outstanding TPM command + TDDLI TSS_RESULT Tddli_Cancel(void); + + // read the attributes returned by the TPM HW/FW + TDDLI TSS_RESULT Tddli_GetCapability( + UINT32 CapArea, + UINT32 SubCap, + BYTE *pCapBuf, + UINT32 *puntCapBufLen); + + // set parameters to the TPM HW/FW + TDDLI TSS_RESULT Tddli_SetCapability( + UINT32 CapArea, + UINT32 SubCap, + BYTE *pCapBuf, + UINT32 puntCapBufLen); + + // get status of the TPM driver and device + TDDLI TSS_RESULT Tddli_GetStatus( + UINT32 ReqStatusType, + UINT32 *puntStatus); + + // send any data to the TPM module + TDDLI TSS_RESULT Tddli_TransmitData( + BYTE *pTransmitBuf, + UINT32 TransmitBufLen, + BYTE *pReceiveBuf, + UINT32 *puntReceiveBufLen); + + TDDLI TSS_RESULT Tddli_SetPowerManagement( + TSS_BOOL SendSaveStateCommand, // in + UINT32 *QuerySetNewTPMPowerState); // in, out + + TDDLI TSS_RESULT Tddli_PowerManagementControl( + TSS_BOOL SendPowerManager, // in + UINT32 *DriverManagesPowerStates); // out + + +#ifdef __cplusplus +} +#endif + +#endif // __TDDLI_H__ + diff --git a/illumos-x86_64/usr/include/tss/tpm.h b/illumos-x86_64/usr/include/tss/tpm.h new file mode 100644 index 00000000..d131c4f2 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tpm.h @@ -0,0 +1,1667 @@ +/*++ + * + * TPM structures extracted from the TPM specification 1.2, + * Part 2 (Structures), rev 85. + * + * Errata: + * + * *) The individual bits of TPM_STARTUP_EFFECTS were not given names in + * the TPM spec so they are not defined in tpm.h. + * + * *) A few typedefs not present in the TPM 1.2 specification have been + * added. This was generally done when the TPM 1.2 spec defined a set of + * related values (either bitmasks or enumeration values) but did not + * define an associated type to hold these values. The typedefs have been + * added and structure fields that were to hold those values have been + * switched from generic UINT* types to the more specific types. This was + * done to highlight exactly where those #defined values were to be used. + * The types that have been added are: + * TPM_NV_PER_ATTRIBUTES + * TPM_DELEGATE_TYPE + * + * *) The layout of bitfields within a structure are compiler-dependent + * and the use of structure bitfields has been avoided where possible. In + * cases where a value is a collection of independent bits the type is + * given a name (typedeffed to UINT16 or UINT32 as appropriate) and masks + * are #defined to access the individual bits. This is not possible for + * TPM_VERSION_BYTE because the fields are 4-bit values. A best attempt + * has been made to make this compiler independent but it has only been + * checked on GCC and Visual C++ on little-endian machines. + * + * *) The TPM_DELEGATIONS per1 and per2 fields field are a bitmask but + * are defined as a UINT32 because the bitfields have different meaning + * based on the type of delegation blob. + * + * *) The definitions of TPM_PERMANENT_DATA, TPM_STCLEAR_DATA, + * TPM_STANY_DATA, and TPM_DELEGATE_TABLE_ROW are commented out. These + * structures are internal to the TPM and are not directly accessible by + * external software so this should not be a problem. + * + * *) The definitions of TPM_FAMILY_TABLE and TPM_DELEGATE_TABLE are + * commented out because they are variable length arrays internal to the + * TPM. As above they are not directly accessible by external software + * so this should not be a problem. + */ + +#ifndef __TPM_H__ +#define __TPM_H__ + +#ifdef __midl +#define SIZEIS(x) [size_is(x)] +#else +#define SIZEIS(x) +#endif + +#include + +//------------------------------------------------------------------- +// Part 2, section 2.1: Basic data types +typedef BYTE TPM_BOOL; +#ifndef FALSE +#define FALSE 0x00 +#define TRUE 0x01 +#endif /* ifndef FALSE */ + +//------------------------------------------------------------------- +// Part 2, section 2.3: Helper Redefinitions +// Many of the helper redefinitions appear later in this file +// so that they are declared next to the list of valid values +// they may hold. +typedef BYTE TPM_LOCALITY_MODIFIER; +typedef UINT32 TPM_COMMAND_CODE; /* 1.1b */ +typedef UINT32 TPM_COUNT_ID; +typedef UINT32 TPM_REDIT_COMMAND; +typedef UINT32 TPM_HANDLE; +typedef UINT32 TPM_AUTHHANDLE; +typedef UINT32 TPM_TRANSHANDLE; +typedef UINT32 TPM_KEYHANDLE; +typedef UINT32 TPM_DIRINDEX; +typedef UINT32 TPM_PCRINDEX; +typedef UINT32 TPM_RESULT; +typedef UINT32 TPM_MODIFIER_INDICATOR; + + + +//------------------------------------------------------------------- +// Part 2, section 2.2.4: Vendor Specific +#define TPM_Vendor_Specific32 0x00000400 +#define TPM_Vendor_Specific8 0x80 + + +//------------------------------------------------------------------- +// Part 2, section 3: Structure Tags +typedef UINT16 TPM_STRUCTURE_TAG; +#define TPM_TAG_CONTEXTBLOB ((UINT16)0x0001) +#define TPM_TAG_CONTEXT_SENSITIVE ((UINT16)0x0002) +#define TPM_TAG_CONTEXTPOINTER ((UINT16)0x0003) +#define TPM_TAG_CONTEXTLIST ((UINT16)0x0004) +#define TPM_TAG_SIGNINFO ((UINT16)0x0005) +#define TPM_TAG_PCR_INFO_LONG ((UINT16)0x0006) +#define TPM_TAG_PERSISTENT_FLAGS ((UINT16)0x0007) +#define TPM_TAG_VOLATILE_FLAGS ((UINT16)0x0008) +#define TPM_TAG_PERSISTENT_DATA ((UINT16)0x0009) +#define TPM_TAG_VOLATILE_DATA ((UINT16)0x000a) +#define TPM_TAG_SV_DATA ((UINT16)0x000b) +#define TPM_TAG_EK_BLOB ((UINT16)0x000c) +#define TPM_TAG_EK_BLOB_AUTH ((UINT16)0x000d) +#define TPM_TAG_COUNTER_VALUE ((UINT16)0x000e) +#define TPM_TAG_TRANSPORT_INTERNAL ((UINT16)0x000f) +#define TPM_TAG_TRANSPORT_LOG_IN ((UINT16)0x0010) +#define TPM_TAG_TRANSPORT_LOG_OUT ((UINT16)0x0011) +#define TPM_TAG_AUDIT_EVENT_IN ((UINT16)0x0012) +#define TPM_TAG_AUDIT_EVENT_OUT ((UINT16)0x0013) +#define TPM_TAG_CURRENT_TICKS ((UINT16)0x0014) +#define TPM_TAG_KEY ((UINT16)0x0015) +#define TPM_TAG_STORED_DATA12 ((UINT16)0x0016) +#define TPM_TAG_NV_ATTRIBUTES ((UINT16)0x0017) +#define TPM_TAG_NV_DATA_PUBLIC ((UINT16)0x0018) +#define TPM_TAG_NV_DATA_SENSITIVE ((UINT16)0x0019) +#define TPM_TAG_DELEGATIONS ((UINT16)0x001a) +#define TPM_TAG_DELEGATE_PUBLIC ((UINT16)0x001b) +#define TPM_TAG_DELEGATE_TABLE_ROW ((UINT16)0x001c) +#define TPM_TAG_TRANSPORT_AUTH ((UINT16)0x001d) +#define TPM_TAG_TRANSPORT_PUBLIC ((UINT16)0x001e) +#define TPM_TAG_PERMANENT_FLAGS ((UINT16)0x001f) +#define TPM_TAG_STCLEAR_FLAGS ((UINT16)0x0020) +#define TPM_TAG_STANY_FLAGS ((UINT16)0x0021) +#define TPM_TAG_PERMANENT_DATA ((UINT16)0x0022) +#define TPM_TAG_STCLEAR_DATA ((UINT16)0x0023) +#define TPM_TAG_STANY_DATA ((UINT16)0x0024) +#define TPM_TAG_FAMILY_TABLE_ENTRY ((UINT16)0x0025) +#define TPM_TAG_DELEGATE_SENSITIVE ((UINT16)0x0026) +#define TPM_TAG_DELG_KEY_BLOB ((UINT16)0x0027) +#define TPM_TAG_KEY12 ((UINT16)0x0028) +#define TPM_TAG_CERTIFY_INFO2 ((UINT16)0x0029) +#define TPM_TAG_DELEGATE_OWNER_BLOB ((UINT16)0x002a) +#define TPM_TAG_EK_BLOB_ACTIVATE ((UINT16)0x002b) +#define TPM_TAG_DAA_BLOB ((UINT16)0x002c) +#define TPM_TAG_DAA_CONTEXT ((UINT16)0x002d) +#define TPM_TAG_DAA_ENFORCE ((UINT16)0x002e) +#define TPM_TAG_DAA_ISSUER ((UINT16)0x002f) +#define TPM_TAG_CAP_VERSION_INFO ((UINT16)0x0030) +#define TPM_TAG_DAA_SENSITIVE ((UINT16)0x0031) +#define TPM_TAG_DAA_TPM ((UINT16)0x0032) +#define TPM_TAG_CMK_MIGAUTH ((UINT16)0x0033) +#define TPM_TAG_CMK_SIGTICKET ((UINT16)0x0034) +#define TPM_TAG_CMK_MA_APPROVAL ((UINT16)0x0035) +#define TPM_TAG_QUOTE_INFO2 ((UINT16)0x0036) +#define TPM_TAG_DA_INFO ((UINT16)0x0037) +#define TPM_TAG_DA_INFO_LIMITED ((UINT16)0x0038) +#define TPM_TAG_DA_ACTION_TYPE ((UINT16)0x0039) + + +//------------------------------------------------------------------- +// Part 2, section 4: Types +typedef UINT32 TPM_RESOURCE_TYPE; +#define TPM_RT_KEY ((UINT32)0x00000001) +#define TPM_RT_AUTH ((UINT32)0x00000002) +#define TPM_RT_HASH ((UINT32)0x00000003) +#define TPM_RT_TRANS ((UINT32)0x00000004) +#define TPM_RT_CONTEXT ((UINT32)0x00000005) +#define TPM_RT_COUNTER ((UINT32)0x00000006) +#define TPM_RT_DELEGATE ((UINT32)0x00000007) +#define TPM_RT_DAA_TPM ((UINT32)0x00000008) +#define TPM_RT_DAA_V0 ((UINT32)0x00000009) +#define TPM_RT_DAA_V1 ((UINT32)0x0000000a) + + +typedef BYTE TPM_PAYLOAD_TYPE; /* 1.1b */ +#define TPM_PT_ASYM ((BYTE)0x01) /* 1.1b */ +#define TPM_PT_BIND ((BYTE)0x02) /* 1.1b */ +#define TPM_PT_MIGRATE ((BYTE)0x03) /* 1.1b */ +#define TPM_PT_MAINT ((BYTE)0x04) /* 1.1b */ +#define TPM_PT_SEAL ((BYTE)0x05) /* 1.1b */ +#define TPM_PT_MIGRATE_RESTRICTED ((BYTE)0x06) +#define TPM_PT_MIGRATE_EXTERNAL ((BYTE)0x07) +#define TPM_PT_CMK_MIGRATE ((BYTE)0x08) + + +typedef UINT16 TPM_ENTITY_TYPE; /* 1.1b */ +#define TPM_ET_KEYHANDLE ((UINT16)0x0001) /* 1.1b */ +#define TPM_ET_OWNER ((UINT16)0x0002) /* 1.1b */ +#define TPM_ET_DATA ((UINT16)0x0003) /* 1.1b */ +#define TPM_ET_SRK ((UINT16)0x0004) /* 1.1b */ +#define TPM_ET_KEY ((UINT16)0x0005) /* 1.1b */ +#define TPM_ET_REVOKE ((UINT16)0x0006) +#define TPM_ET_DEL_OWNER_BLOB ((UINT16)0x0007) +#define TPM_ET_DEL_ROW ((UINT16)0x0008) +#define TPM_ET_DEL_KEY_BLOB ((UINT16)0x0009) +#define TPM_ET_COUNTER ((UINT16)0x000a) +#define TPM_ET_NV ((UINT16)0x000b) +#define TPM_ET_OPERATOR ((UINT16)0x000c) +#define TPM_ET_RESERVED_HANDLE ((UINT16)0x0040) + +/* The following values may be ORed into the MSB of the TPM_ENTITY_TYPE + * to indicate particular encryption scheme + */ +#define TPM_ET_XOR ((BYTE)0x00) +#define TPM_ET_AES ((BYTE)0x06) + +typedef UINT32 TPM_KEY_HANDLE; /* 1.1b */ +#define TPM_KH_SRK ((UINT32)0x40000000) +#define TPM_KH_OWNER ((UINT32)0x40000001) +#define TPM_KH_REVOKE ((UINT32)0x40000002) +#define TPM_KH_TRANSPORT ((UINT32)0x40000003) +#define TPM_KH_OPERATOR ((UINT32)0x40000004) +#define TPM_KH_ADMIN ((UINT32)0x40000005) +#define TPM_KH_EK ((UINT32)0x40000006) +/* 1.1b used different names, but the same values */ +#define TPM_KEYHND_SRK (TPM_KH_SRK) /* 1.1b */ +#define TPM_KEYHND_OWNER (TPM_KH_OWNER) /* 1.1b */ + + +typedef UINT16 TPM_STARTUP_TYPE; /* 1.1b */ +#define TPM_ST_CLEAR ((UINT16)0x0001) /* 1.1b */ +#define TPM_ST_STATE ((UINT16)0x0002) /* 1.1b */ +#define TPM_ST_DEACTIVATED ((UINT16)0x0003) /* 1.1b */ + + +//typedef UINT32 TPM_STARTUP_EFFECTS; +// 32-bit mask, see spec for meaning. Names not currently defined. +// bits 0-8 have meaning + +typedef UINT16 TPM_PROTOCOL_ID; /* 1.1b */ +#define TPM_PID_OIAP ((UINT16)0x0001) /* 1.1b */ +#define TPM_PID_OSAP ((UINT16)0x0002) /* 1.1b */ +#define TPM_PID_ADIP ((UINT16)0x0003) /* 1.1b */ +#define TPM_PID_ADCP ((UINT16)0x0004) /* 1.1b */ +#define TPM_PID_OWNER ((UINT16)0x0005) /* 1.1b */ +#define TPM_PID_DSAP ((UINT16)0x0006) +#define TPM_PID_TRANSPORT ((UINT16)0x0007) + + +// Note in 1.2 rev 104, DES and 3DES are eliminated +typedef UINT32 TPM_ALGORITHM_ID; /* 1.1b */ +#define TPM_ALG_RSA ((UINT32)0x00000001) /* 1.1b */ +#define TPM_ALG_DES ((UINT32)0x00000002) /* 1.1b */ +#define TPM_ALG_3DES ((UINT32)0x00000003) /* 1.1b */ +#define TPM_ALG_SHA ((UINT32)0x00000004) /* 1.1b */ +#define TPM_ALG_HMAC ((UINT32)0x00000005) /* 1.1b */ +#define TPM_ALG_AES ((UINT32)0x00000006) /* 1.1b */ +#define TPM_ALG_AES128 (TPM_ALG_AES) +#define TPM_ALG_MGF1 ((UINT32)0x00000007) +#define TPM_ALG_AES192 ((UINT32)0x00000008) +#define TPM_ALG_AES256 ((UINT32)0x00000009) +#define TPM_ALG_XOR ((UINT32)0x0000000a) + + +typedef UINT16 TPM_PHYSICAL_PRESENCE; /* 1.1b */ +#define TPM_PHYSICAL_PRESENCE_LOCK ((UINT16)0x0004) /* 1.1b */ +#define TPM_PHYSICAL_PRESENCE_PRESENT ((UINT16)0x0008) /* 1.1b */ +#define TPM_PHYSICAL_PRESENCE_NOTPRESENT ((UINT16)0x0010) /* 1.1b */ +#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE ((UINT16)0x0020) /* 1.1b */ +#define TPM_PHYSICAL_PRESENCE_HW_ENABLE ((UINT16)0x0040) /* 1.1b */ +#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((UINT16)0x0080) /* 1.1b */ +#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE ((UINT16)0x0100) +#define TPM_PHYSICAL_PRESENCE_HW_DISABLE ((UINT16)0x0200) + + +typedef UINT16 TPM_MIGRATE_SCHEME; /* 1.1b */ +#define TPM_MS_MIGRATE ((UINT16)0x0001) /* 1.1b */ +#define TPM_MS_REWRAP ((UINT16)0x0002) /* 1.1b */ +#define TPM_MS_MAINT ((UINT16)0x0003) /* 1.1b */ +#define TPM_MS_RESTRICT_MIGRATE ((UINT16)0x0004) +#define TPM_MS_RESTRICT_APPROVE_DOUBLE ((UINT16)0x0005) + + +typedef UINT16 TPM_EK_TYPE; +#define TPM_EK_TYPE_ACTIVATE ((UINT16)0x0001) +#define TPM_EK_TYPE_AUTH ((UINT16)0x0002) + + +typedef UINT16 TPM_PLATFORM_SPECIFIC; +#define TPM_PS_PC_11 ((UINT16)0x0001) +#define TPM_PS_PC_12 ((UINT16)0x0002) +#define TPM_PS_PDA_12 ((UINT16)0x0003) +#define TPM_PS_Server_12 ((UINT16)0x0004) +#define TPM_PS_Mobile_12 ((UINT16)0x0005) + +//------------------------------------------------------------------- +// Part 2, section 5: Basic Structures + +typedef struct tdTPM_STRUCT_VER +{ + BYTE major; + BYTE minor; + BYTE revMajor; + BYTE revMinor; +} TPM_STRUCT_VER; + +typedef struct tdTPM_VERSION_BYTE +{ + // This needs to be made compiler-independent. + int leastSigVer : 4; // least significant 4 bits + int mostSigVer : 4; // most significant 4 bits +} TPM_VERSION_BYTE; + +typedef struct tdTPM_VERSION +{ + BYTE major; // Should really be a TPM_VERSION_BYTE + BYTE minor; // Should really be a TPM_VERSION_BYTE + BYTE revMajor; + BYTE revMinor; +} TPM_VERSION; + + +// Put this in the right place: +// byte size definition for 160 bit SHA1 hash value +#define TPM_SHA1_160_HASH_LEN 0x14 +#define TPM_SHA1BASED_NONCE_LEN TPM_SHA1_160_HASH_LEN + +typedef struct tdTPM_DIGEST +{ + BYTE digest[TPM_SHA1_160_HASH_LEN]; +} TPM_DIGEST; + +typedef TPM_DIGEST TPM_CHOSENID_HASH; +typedef TPM_DIGEST TPM_COMPOSITE_HASH; +typedef TPM_DIGEST TPM_DIRVALUE; +typedef TPM_DIGEST TPM_HMAC; +typedef TPM_DIGEST TPM_PCRVALUE; +typedef TPM_DIGEST TPM_AUDITDIGEST; + +typedef struct tdTPM_NONCE /* 1.1b */ +{ + BYTE nonce[TPM_SHA1BASED_NONCE_LEN]; +} TPM_NONCE; + +typedef TPM_NONCE TPM_DAA_TPM_SEED; +typedef TPM_NONCE TPM_DAA_CONTEXT_SEED; + +typedef struct tdTPM_AUTHDATA /* 1.1b */ +{ + BYTE authdata[TPM_SHA1_160_HASH_LEN]; +} TPM_AUTHDATA; + +typedef TPM_AUTHDATA TPM_SECRET; +typedef TPM_AUTHDATA TPM_ENCAUTH; + + +typedef struct tdTPM_KEY_HANDLE_LIST /* 1.1b */ +{ + UINT16 loaded; + SIZEIS(loaded) + TPM_KEY_HANDLE *handle; +} TPM_KEY_HANDLE_LIST; + + +//------------------------------------------------------------------- +// Part 2, section 5.8: Key usage values + +typedef UINT16 TPM_KEY_USAGE; /* 1.1b */ +#define TPM_KEY_SIGNING ((UINT16)0x0010) /* 1.1b */ +#define TPM_KEY_STORAGE ((UINT16)0x0011) /* 1.1b */ +#define TPM_KEY_IDENTITY ((UINT16)0x0012) /* 1.1b */ +#define TPM_KEY_AUTHCHANGE ((UINT16)0x0013) /* 1.1b */ +#define TPM_KEY_BIND ((UINT16)0x0014) /* 1.1b */ +#define TPM_KEY_LEGACY ((UINT16)0x0015) /* 1.1b */ +#define TPM_KEY_MIGRATE ((UINT16)0x0016) + +typedef UINT16 TPM_SIG_SCHEME; /* 1.1b */ +#define TPM_SS_NONE ((UINT16)0x0001) /* 1.1b */ +#define TPM_SS_RSASSAPKCS1v15_SHA1 ((UINT16)0x0002) /* 1.1b */ +#define TPM_SS_RSASSAPKCS1v15_DER ((UINT16)0x0003) /* 1.1b */ +#define TPM_SS_RSASSAPKCS1v15_INFO ((UINT16)0x0004) + +typedef UINT16 TPM_ENC_SCHEME; /* 1.1b */ +#define TPM_ES_NONE ((UINT16)0x0001) /* 1.1b */ +#define TPM_ES_RSAESPKCSv15 ((UINT16)0x0002) /* 1.1b */ +#define TPM_ES_RSAESOAEP_SHA1_MGF1 ((UINT16)0x0003) /* 1.1b */ +#define TPM_ES_SYM_CNT ((UINT16)0x0004) +#define TPM_ES_SYM_CTR TPM_ES_SYM_CNT +#define TPM_ES_SYM_OFB ((UINT16)0x0005) +#define TPM_ES_SYM_CBC_PKCS5PAD ((UINT16)0x00ff) + +//------------------------------------------------------------------- +// Part 2, section 5.9: TPM_AUTH_DATA_USAGE values + +typedef BYTE TPM_AUTH_DATA_USAGE; /* 1.1b */ +#define TPM_AUTH_NEVER ((BYTE)0x00) /* 1.1b */ +#define TPM_AUTH_ALWAYS ((BYTE)0x01) /* 1.1b */ +#define TPM_AUTH_PRIV_USE_ONLY ((BYTE)0x11) + + +//------------------------------------------------------------------- +// Part 2, section 5.10: TPM_KEY_FLAGS flags + +typedef UINT32 TPM_KEY_FLAGS; /* 1.1b */ +#define TPM_REDIRECTION ((UINT32)0x00000001) /* 1.1b */ +#define TPM_MIGRATABLE ((UINT32)0x00000002) /* 1.1b */ +#define TPM_VOLATILE ((UINT32)0x00000004) /* 1.1b */ +#define TPM_PCRIGNOREDONREAD ((UINT32)0x00000008) +#define TPM_MIGRATEAUTHORITY ((UINT32)0x00000010) + + +//------------------------------------------------------------------- +// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE + +typedef struct tdTPM_CHANGEAUTH_VALIDATE +{ + TPM_SECRET newAuthSecret; + TPM_NONCE n1; +} TPM_CHANGEAUTH_VALIDATE; + +//------------------------------------------------------------------- +// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH +// declared after section 10 to catch declaration of TPM_PUBKEY + +//------------------------------------------------------------------- +// Part 2, section 5.13: TPM_COUNTER_VALUE; + +typedef UINT32 TPM_ACTUAL_COUNT; +typedef struct tdTPM_COUNTER_VALUE +{ + TPM_STRUCTURE_TAG tag; + BYTE label[4]; + TPM_ACTUAL_COUNT counter; +} TPM_COUNTER_VALUE; + +//------------------------------------------------------------------- +// Part 2, section 5.14: TPM_SIGN_INFO structure + +typedef struct tdTPM_SIGN_INFO +{ + TPM_STRUCTURE_TAG tag; + BYTE fixed[4]; + TPM_NONCE replay; + UINT32 dataLen; + SIZEIS(dataLen) + BYTE *data; +} TPM_SIGN_INFO; + +//------------------------------------------------------------------- +// Part 2, section 5.15: TPM_MSA_COMPOSITE + +typedef struct tdTPM_MSA_COMPOSITE +{ + UINT32 MSAlist; + SIZEIS(MSAlist) + TPM_DIGEST *migAuthDigest; +} TPM_MSA_COMPOSITE; + +//------------------------------------------------------------------- +// Part 2, section 5.16: TPM_CMK_AUTH + +typedef struct tdTPM_CMK_AUTH +{ + TPM_DIGEST migrationAuthorityDigest; + TPM_DIGEST destinationKeyDigest; + TPM_DIGEST sourceKeyDigest; +} TPM_CMK_AUTH; + +//------------------------------------------------------------------- +// Part 2, section 5.17: TPM_CMK_DELEGATE + +typedef UINT32 TPM_CMK_DELEGATE; +#define TPM_CMK_DELEGATE_SIGNING (((UINT32)1)<<31) +#define TPM_CMK_DELEGATE_STORAGE (((UINT32)1)<<30) +#define TPM_CMK_DELEGATE_BIND (((UINT32)1)<<29) +#define TPM_CMK_DELEGATE_LEGACY (((UINT32)1)<<28) +#define TPM_CMK_DELEGATE_MIGRATE (((UINT32)1)<<27) + +//------------------------------------------------------------------- +// Part 2, section 5.18: TPM_SELECT_SIZE + +typedef struct tdTPM_SELECT_SIZE +{ + BYTE major; + BYTE minor; + UINT16 reqSize; +} TPM_SELECT_SIZE; + +//------------------------------------------------------------------- +// Part 2, section 5.19: TPM_CMK_MIGAUTH + +typedef struct tdTPM_CMK_MIGAUTH +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST msaDigest; + TPM_DIGEST pubKeyDigest; +} TPM_CMK_MIGAUTH; + +//------------------------------------------------------------------- +// Part 2, section 5.20: TPM_CMK_SIGTICKET + +typedef struct tdTPM_CMK_SIGTICKET +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST verKeyDigest; + TPM_DIGEST signedData; +} TPM_CMK_SIGTICKET; + +//------------------------------------------------------------------- +// Part 2, section 5.21: TPM_CMK_MA_APPROVAL + +typedef struct tdTPM_CMK_MA_APPROVAL +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST migrationAuthorityDigest; +} TPM_CMK_MA_APPROVAL; + + +//------------------------------------------------------------------- +// Part 2, section 6: Command Tags + +typedef UINT16 TPM_TAG; /* 1.1b */ +#define TPM_TAG_RQU_COMMAND ((UINT16)0x00c1) +#define TPM_TAG_RQU_AUTH1_COMMAND ((UINT16)0x00c2) +#define TPM_TAG_RQU_AUTH2_COMMAND ((UINT16)0x00c3) +#define TPM_TAG_RSP_COMMAND ((UINT16)0x00c4) +#define TPM_TAG_RSP_AUTH1_COMMAND ((UINT16)0x00c5) +#define TPM_TAG_RSP_AUTH2_COMMAND ((UINT16)0x00c6) + + +//------------------------------------------------------------------- +// Part 2, section 7.1: TPM_PERMANENT_FLAGS + +typedef struct tdTPM_PERMANENT_FLAGS +{ + TPM_STRUCTURE_TAG tag; + TSS_BOOL disable; + TSS_BOOL ownership; + TSS_BOOL deactivated; + TSS_BOOL readPubek; + TSS_BOOL disableOwnerClear; + TSS_BOOL allowMaintenance; + TSS_BOOL physicalPresenceLifetimeLock; + TSS_BOOL physicalPresenceHWEnable; + TSS_BOOL physicalPresenceCMDEnable; + TSS_BOOL CEKPUsed; + TSS_BOOL TPMpost; + TSS_BOOL TPMpostLock; + TSS_BOOL FIPS; + TSS_BOOL Operator; + TSS_BOOL enableRevokeEK; + TSS_BOOL nvLocked; + TSS_BOOL readSRKPub; + TSS_BOOL tpmEstablished; + TSS_BOOL maintenanceDone; + TSS_BOOL disableFullDALogicInfo; +} TPM_PERMANENT_FLAGS; + +#define TPM_PF_DISABLE ((UINT32)0x00000001) +#define TPM_PF_OWNERSHIP ((UINT32)0x00000002) +#define TPM_PF_DEACTIVATED ((UINT32)0x00000003) +#define TPM_PF_READPUBEK ((UINT32)0x00000004) +#define TPM_PF_DISABLEOWNERCLEAR ((UINT32)0x00000005) +#define TPM_PF_ALLOWMAINTENANCE ((UINT32)0x00000006) +#define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((UINT32)0x00000007) +#define TPM_PF_PHYSICALPRESENCEHWENABLE ((UINT32)0x00000008) +#define TPM_PF_PHYSICALPRESENCECMDENABLE ((UINT32)0x00000009) +#define TPM_PF_CEKPUSED ((UINT32)0x0000000A) +#define TPM_PF_TPMPOST ((UINT32)0x0000000B) +#define TPM_PF_TPMPOSTLOCK ((UINT32)0x0000000C) +#define TPM_PF_FIPS ((UINT32)0x0000000D) +#define TPM_PF_OPERATOR ((UINT32)0x0000000E) +#define TPM_PF_ENABLEREVOKEEK ((UINT32)0x0000000F) +#define TPM_PF_NV_LOCKED ((UINT32)0x00000010) +#define TPM_PF_READSRKPUB ((UINT32)0x00000011) +#define TPM_PF_RESETESTABLISHMENTBIT ((UINT32)0x00000012) +#define TPM_PF_MAINTENANCEDONE ((UINT32)0x00000013) +#define TPM_PF_DISABLEFULLDALOGICINFO ((UINT32)0x00000014) + + +//------------------------------------------------------------------- +// Part 2, section 7.2: TPM_STCLEAR_FLAGS + +typedef struct tdTPM_STCLEAR_FLAGS +{ + TPM_STRUCTURE_TAG tag; + TSS_BOOL deactivated; + TSS_BOOL disableForceClear; + TSS_BOOL physicalPresence; + TSS_BOOL physicalPresenceLock; + TSS_BOOL bGlobalLock; +} TPM_STCLEAR_FLAGS; + +#define TPM_SF_DEACTIVATED ((UINT32)0x00000001) +#define TPM_SF_DISABLEFORCECLEAR ((UINT32)0x00000002) +#define TPM_SF_PHYSICALPRESENCE ((UINT32)0x00000003) +#define TPM_SF_PHYSICALPRESENCELOCK ((UINT32)0x00000004) +#define TPM_SF_GLOBALLOCK ((UINT32)0x00000005) + + +//------------------------------------------------------------------- +// Part 2, section 7.3: TPM_STANY_FLAGS + +typedef struct tdTPM_STANY_FLAGS +{ + TPM_STRUCTURE_TAG tag; + TSS_BOOL postInitialise; + TPM_MODIFIER_INDICATOR localityModifier; + TSS_BOOL transportExclusive; + TSS_BOOL TOSPresent; +} TPM_STANY_FLAGS; + +#define TPM_AF_POSTINITIALIZE ((UINT32)0x00000001) +#define TPM_AF_LOCALITYMODIFIER ((UINT32)0x00000002) +#define TPM_AF_TRANSPORTEXCLUSIVE ((UINT32)0x00000003) +#define TPM_AF_TOSPRESENT ((UINT32)0x00000004) + + +//------------------------------------------------------------------- +// Part 2, section 7.4: TPM_PERMANENT_DATA +// available inside TPM only +// +//#define TPM_MIN_COUNTERS 4 +//#define TPM_NUM_PCR 16 +//#define TPM_MAX_NV_WRITE_NOOWNER 64 +// +//typedef struct tdTPM_PERMANENT_DATA +//{ +// TPM_STRUCTURE_TAG tag; +// BYTE revMajor; +// BYTE revMinor; +// TPM_NONCE tpmProof; +// TPM_NONCE ekReset; +// TPM_SECRET ownerAuth; +// TPM_SECRET operatorAuth; +// TPM_DIRVALUE authDIR[1]; +// TPM_PUBKEY manuMaintPub; +// TPM_KEY endorsementKey; +// TPM_KEY srk; +// TPM_KEY contextKey; +// TPM_KEY delegateKey; +// TPM_COUNTER_VALUE auditMonotonicCounter; +// TPM_COUNTER_VALUE monitonicCounter[TPM_MIN_COUNTERS]; +// TPM_PCR_ATTRIBUTES pcrAttrib[TPM_NUM_PCR]; +// BYTE ordinalAuditStatus[]; +// BYTE *rngState; +// TPM_FAMILY_TABLE familyTable; +// TPM_DELEGATE_TABLE delegateTable; +// UINT32 maxNVBufSize; +// UINT32 lastFamilyID; +// UINT32 noOwnerNVWrite; +// TPM_CMK_DELEGATE restrictDelegate; +// TPM_DAA_TPM_SEED tpmDAASeed; +// TPM_NONCE daaProof; +// TPM_NONCE daaBlobKey; +//} TPM_PERMANENT_DATA; + + +//------------------------------------------------------------------- +// Part 2, section 7.5: TPM_STCLEAR_DATA +// available inside TPM only +// +//typedef struct tdTPM_STCLEAR_DATA +//{ +// TPM_STRUCTURE_TAG tag; +// TPM_NONCE contextNonceKey; +// TPM_COUNT_ID countID; +// UINT32 ownerReference; +// TPM_BOOL disableResetLock; +// TPM_PCRVALUE PCR[TPM_NUM_PCR]; +// UINT32 deferredPhysicalPresence; +//} TPM_STCLEAR_DATA; + + + +//------------------------------------------------------------------- +// Part 2, section 7.5: TPM_STANY_DATA +// available inside TPM only +// +//typedef struct tdTPM_STANY_DATA +//{ +// TPM_STRUCTURE_TAG tag; +// TPM_NONCE contextNonceSession; +// TPM_DIGEST auditDigest; +// TPM_CURRENT_TICKS currentTicks; +// UINT32 contextCount; +// UINT32 contextList[TPM_MIN_SESSION_LIST]; +// TPM_SESSION_DATA sessions[TPM_MIN_SESSIONS]; +// // The following appear in section 22.6 but not in 7.5 +// TPM_DAA_ISSUER DAA_issuerSettings; +// TPM_DAA_TPM DAA_tpmSpecific; +// TPM_DAA_CONTEXT DAA_session; +// TPM_DAA_JOINDATA DAA_joinSession; +//} TPM_STANY_DATA; + + + +//------------------------------------------------------------------- +// Part 2, section 8: PCR Structures + +typedef BYTE TPM_LOCALITY_SELECTION; +#define TPM_LOC_FOUR (((UINT32)1)<<4) +#define TPM_LOC_THREE (((UINT32)1)<<3) +#define TPM_LOC_TWO (((UINT32)1)<<2) +#define TPM_LOC_ONE (((UINT32)1)<<1) +#define TPM_LOC_ZERO (((UINT32)1)<<0) + +typedef struct tdTPM_PCR_SELECTION /* 1.1b */ +{ + UINT16 sizeOfSelect; + SIZEIS(sizeOfSelect) + BYTE *pcrSelect; +} TPM_PCR_SELECTION; + +typedef struct tdTPM_PCR_COMPOSITE /* 1.1b */ +{ + TPM_PCR_SELECTION select; + UINT32 valueSize; + SIZEIS(valueSize) + TPM_PCRVALUE *pcrValue; +} TPM_PCR_COMPOSITE; + +typedef struct tdTPM_PCR_INFO /* 1.1b */ +{ + TPM_PCR_SELECTION pcrSelection; + TPM_COMPOSITE_HASH digestAtRelease; + TPM_COMPOSITE_HASH digestAtCreation; +} TPM_PCR_INFO; + +typedef struct tdTPM_PCR_INFO_LONG +{ + TPM_STRUCTURE_TAG tag; + TPM_LOCALITY_SELECTION localityAtCreation; + TPM_LOCALITY_SELECTION localityAtRelease; + TPM_PCR_SELECTION creationPCRSelection; + TPM_PCR_SELECTION releasePCRSelection; + TPM_COMPOSITE_HASH digestAtCreation; + TPM_COMPOSITE_HASH digestAtRelease; +} TPM_PCR_INFO_LONG; + +typedef struct tdTPM_PCR_INFO_SHORT +{ + TPM_PCR_SELECTION pcrSelection; + TPM_LOCALITY_SELECTION localityAtRelease; + TPM_COMPOSITE_HASH digestAtRelease; +} TPM_PCR_INFO_SHORT; + +typedef struct tdTPM_PCR_ATTRIBUTES +{ + BYTE pcrReset; + TPM_LOCALITY_SELECTION pcrExtendLocal; + TPM_LOCALITY_SELECTION pcrResetLocal; +} TPM_PCR_ATTRIBUTES; + + + +//------------------------------------------------------------------- +// Part 2, section 9: + +typedef struct tdTPM_STORED_DATA /* 1.1b */ +{ + TPM_STRUCT_VER ver; + UINT32 sealInfoSize; + SIZEIS(sealInfoSize) + BYTE *sealInfo; + UINT32 encDataSize; + SIZEIS(encDataSize) + BYTE *encData; +} TPM_STORED_DATA; + +typedef struct tdTPM_STORED_DATA12 +{ + TPM_STRUCTURE_TAG tag; + TPM_ENTITY_TYPE et; + UINT32 sealInfoSize; + SIZEIS(sealInfoSize) + BYTE *sealInfo; + UINT32 encDataSize; + SIZEIS(encDataSize) + BYTE *encData; +} TPM_STORED_DATA12; + +typedef struct tdTPM_SEALED_DATA /* 1.1b */ +{ + TPM_PAYLOAD_TYPE payload; + TPM_SECRET authData; + TPM_NONCE tpmProof; + TPM_DIGEST storedDigest; + UINT32 dataSize; + SIZEIS(dataSize) + BYTE *data; +} TPM_SEALED_DATA; + +typedef struct tdTPM_SYMMETRIC_KEY /* 1.1b */ +{ + TPM_ALGORITHM_ID algId; + TPM_ENC_SCHEME encScheme; + UINT16 size; + SIZEIS(size) + BYTE *data; +} TPM_SYMMETRIC_KEY; + +typedef struct tdTPM_BOUND_DATA +{ + TPM_STRUCT_VER ver; + TPM_PAYLOAD_TYPE payload; + BYTE *payloadData; // length is implied +} TPM_BOUND_DATA; + + +//------------------------------------------------------------------- +// Part 2, section 10: TPM_KEY complex + +typedef struct tdTPM_KEY_PARMS /* 1.1b */ +{ + TPM_ALGORITHM_ID algorithmID; + TPM_ENC_SCHEME encScheme; + TPM_SIG_SCHEME sigScheme; + UINT32 parmSize; + SIZEIS(parmSize) + BYTE *parms; +} TPM_KEY_PARMS; + +typedef struct tdTPM_RSA_KEY_PARMS /* 1.1b */ +{ + UINT32 keyLength; + UINT32 numPrimes; + UINT32 exponentSize; + SIZEIS(exponentSize) + BYTE *exponent; +} TPM_RSA_KEY_PARMS; + +typedef struct tdTPM_SYMMETRIC_KEY_PARMS +{ + UINT32 keyLength; + UINT32 blockSize; + UINT32 ivSize; + SIZEIS(ivSize) + BYTE *IV; +} TPM_SYMMETRIC_KEY_PARMS; + +typedef struct tdTPM_STORE_PUBKEY /* 1.1b */ +{ + UINT32 keyLength; + SIZEIS(keyLength) + BYTE *key; +} TPM_STORE_PUBKEY; + +typedef struct tdTPM_PUBKEY /* 1.1b */ +{ + TPM_KEY_PARMS algorithmParms; + TPM_STORE_PUBKEY pubKey; +} TPM_PUBKEY; + +typedef struct tdTPM_STORE_PRIVKEY /* 1.1b */ +{ + UINT32 keyLength; + SIZEIS(keyLength) + BYTE *key; +} TPM_STORE_PRIVKEY; + +typedef struct tdTPM_STORE_ASYMKEY /* 1.1b */ +{ + TPM_PAYLOAD_TYPE payload; + TPM_SECRET usageAuth; + TPM_SECRET migrationAuth; + TPM_DIGEST pubDataDigest; + TPM_STORE_PRIVKEY privKey; +} TPM_STORE_ASYMKEY; + +typedef struct tdTPM_KEY /* 1.1b */ +{ + TPM_STRUCT_VER ver; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + UINT32 PCRInfoSize; + SIZEIS(PCRInfoSize) + BYTE *PCRInfo; + TPM_STORE_PUBKEY pubKey; + UINT32 encSize; + SIZEIS(encSize) + BYTE *encData; +} TPM_KEY; + +typedef struct tdTPM_KEY12 +{ + TPM_STRUCTURE_TAG tag; + UINT16 fill; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + UINT32 PCRInfoSize; + SIZEIS(PCRInfoSize) + BYTE *PCRInfo; + TPM_STORE_PUBKEY pubKey; + UINT32 encSize; + SIZEIS(encSize) + BYTE *encData; +} TPM_KEY12; + +typedef struct tdTPM_MIGRATE_ASYMKEY +{ + TPM_PAYLOAD_TYPE payload; + TPM_SECRET usageAuth; + TPM_DIGEST pubDataDigest; + UINT32 partPrivKeyLen; + SIZEIS(partPrivKeyLen) + BYTE *partPrivKey; +} TPM_MIGRATE_ASYMKEY; + + +typedef UINT32 TPM_KEY_CONTROL; +#define TPM_KEY_CONTROL_OWNER_EVICT ((UINT32)0x00000001) + + +//------------------------------------------------------------------- +// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH + +typedef struct tdTPM_MIGRATIONKEYAUTH /* 1.1b */ +{ + TPM_PUBKEY migrationKey; + TPM_MIGRATE_SCHEME migrationScheme; + TPM_DIGEST digest; +} TPM_MIGRATIONKEYAUTH; + + +//------------------------------------------------------------------- +// Part 2, section 11: Signed Structures + +typedef struct tdTPM_CERTIFY_INFO /* 1.1b */ +{ + TPM_STRUCT_VER version; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + TPM_DIGEST pubkeyDigest; + TPM_NONCE data; + TPM_BOOL parentPCRStatus; + UINT32 PCRInfoSize; + SIZEIS(PCRInfoSize) + BYTE *PCRInfo; +} TPM_CERTIFY_INFO; + +typedef struct tdTPM_CERTIFY_INFO2 +{ + TPM_STRUCTURE_TAG tag; + BYTE fill; + TPM_PAYLOAD_TYPE payloadType; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + TPM_DIGEST pubkeyDigest; + TPM_NONCE data; + TPM_BOOL parentPCRStatus; + UINT32 PCRInfoSize; + SIZEIS(PCRInfoSize) + BYTE *PCRInfo; + UINT32 migrationAuthoritySize; + SIZEIS(migrationAuthoritySize) + BYTE *migrationAuthority; +} TPM_CERTIFY_INFO2; + +typedef struct tdTPM_QUOTE_INFO /* 1.1b */ +{ + TPM_STRUCT_VER version; + BYTE fixed[4]; + TPM_COMPOSITE_HASH compositeHash; /* in 1.2 TPM spec, named digestValue */ + TPM_NONCE externalData; +} TPM_QUOTE_INFO; + +typedef struct tdTPM_QUOTE_INFO2 +{ + TPM_STRUCTURE_TAG tag; + BYTE fixed[4]; + TPM_NONCE externalData; + TPM_PCR_INFO_SHORT infoShort; +} TPM_QUOTE_INFO2; + + + +//------------------------------------------------------------------- +// Part 2, section 12: Identity Structures + + +typedef struct tdTPM_EK_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_EK_TYPE ekType; + UINT32 blobSize; + SIZEIS(blobSize) + BYTE *blob; +} TPM_EK_BLOB; + +typedef struct tdTPM_EK_BLOB_ACTIVATE +{ + TPM_STRUCTURE_TAG tag; + TPM_SYMMETRIC_KEY sessionKey; + TPM_DIGEST idDigest; + TPM_PCR_INFO_SHORT pcrInfo; +} TPM_EK_BLOB_ACTIVATE; + +typedef struct tdTPM_EK_BLOB_AUTH +{ + TPM_STRUCTURE_TAG tag; + TPM_SECRET authValue; +} TPM_EK_BLOB_AUTH; + + +typedef struct tdTPM_IDENTITY_CONTENTS +{ + TPM_STRUCT_VER ver; + UINT32 ordinal; + TPM_CHOSENID_HASH labelPrivCADigest; + TPM_PUBKEY identityPubKey; +} TPM_IDENTITY_CONTENTS; + +typedef struct tdTPM_IDENTITY_REQ /* 1.1b */ +{ + UINT32 asymSize; + UINT32 symSize; + TPM_KEY_PARMS asymAlgorithm; + TPM_KEY_PARMS symAlgorithm; + SIZEIS(asymSize) + BYTE *asymBlob; + SIZEIS(symSize) + BYTE *symBlob; +} TPM_IDENTITY_REQ; + +typedef struct tdTPM_IDENTITY_PROOF /* 1.1b */ +{ + TPM_STRUCT_VER ver; + UINT32 labelSize; + UINT32 identityBindingSize; + UINT32 endorsementSize; + UINT32 platformSize; + UINT32 conformanceSize; + TPM_PUBKEY identityKey; + SIZEIS(labelSize) + BYTE *labelArea; + SIZEIS(identityBindingSize) + BYTE *identityBinding; + SIZEIS(endorsementSize) + BYTE *endorsementCredential; + SIZEIS(platformSize) + BYTE *platformCredential; + SIZEIS(conformanceSize) + BYTE *conformanceCredential; +} TPM_IDENTITY_PROOF; + +typedef struct tdTPM_ASYM_CA_CONTENTS /* 1.1b */ +{ + TPM_SYMMETRIC_KEY sessionKey; + TPM_DIGEST idDigest; +} TPM_ASYM_CA_CONTENTS; + +typedef struct tdTPM_SYM_CA_ATTESTATION +{ + UINT32 credSize; + TPM_KEY_PARMS algorithm; + SIZEIS(credSize) + BYTE *credential; +} TPM_SYM_CA_ATTESTATION; + + + +//------------------------------------------------------------------- +// Part 2, section 15: Tick Structures +// Placed here out of order because definitions are used in section 13. + +typedef struct tdTPM_CURRENT_TICKS +{ + TPM_STRUCTURE_TAG tag; + UINT64 currentTicks; + UINT16 tickRate; + TPM_NONCE tickNonce; +} TPM_CURRENT_TICKS; + + + +//------------------------------------------------------------------- +// Part 2, section 13: Transport structures + +typedef UINT32 TPM_TRANSPORT_ATTRIBUTES; +#define TPM_TRANSPORT_ENCRYPT ((UINT32)0x00000001) +#define TPM_TRANSPORT_LOG ((UINT32)0x00000002) +#define TPM_TRANSPORT_EXCLUSIVE ((UINT32)0x00000004) + +typedef struct tdTPM_TRANSPORT_PUBLIC +{ + TPM_STRUCTURE_TAG tag; + TPM_TRANSPORT_ATTRIBUTES transAttributes; + TPM_ALGORITHM_ID algId; + TPM_ENC_SCHEME encScheme; +} TPM_TRANSPORT_PUBLIC; + +typedef struct tdTPM_TRANSPORT_INTERNAL +{ + TPM_STRUCTURE_TAG tag; + TPM_AUTHDATA authData; + TPM_TRANSPORT_PUBLIC transPublic; + TPM_TRANSHANDLE transHandle; + TPM_NONCE transNonceEven; + TPM_DIGEST transDigest; +} TPM_TRANSPORT_INTERNAL; + +typedef struct tdTPM_TRANSPORT_LOG_IN +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST parameters; + TPM_DIGEST pubKeyHash; +} TPM_TRANSPORT_LOG_IN; + +typedef struct tdTPM_TRANSPORT_LOG_OUT +{ + TPM_STRUCTURE_TAG tag; + TPM_CURRENT_TICKS currentTicks; + TPM_DIGEST parameters; + TPM_MODIFIER_INDICATOR locality; +} TPM_TRANSPORT_LOG_OUT; + +typedef struct tdTPM_TRANSPORT_AUTH +{ + TPM_STRUCTURE_TAG tag; + TPM_AUTHDATA authData; +} TPM_TRANSPORT_AUTH; + + + +//------------------------------------------------------------------- +// Part 2, section 14: Audit Structures + +typedef struct tdTPM_AUDIT_EVENT_IN +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST inputParms; + TPM_COUNTER_VALUE auditCount; +} TPM_AUDIT_EVENT_IN; + +typedef struct tdTPM_AUDIT_EVENT_OUT +{ + TPM_STRUCTURE_TAG tag; + TPM_COMMAND_CODE ordinal; + TPM_DIGEST outputParms; + TPM_COUNTER_VALUE auditCount; + TPM_RESULT returnCode; +} TPM_AUDIT_EVENT_OUT; + + + +//------------------------------------------------------------------- +// Part 2, section 16: Return codes + +#include + + +//------------------------------------------------------------------- +// Part 2, section 17: Ordinals + +#include + +//------------------------------------------------------------------- +// Part 2, section 18: Context structures + +typedef struct tdTPM_CONTEXT_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_RESOURCE_TYPE resourceType; + TPM_HANDLE handle; + BYTE label[16]; + UINT32 contextCount; + TPM_DIGEST integrityDigest; + UINT32 additionalSize; + SIZEIS(additionalSize) + BYTE *additionalData; + UINT32 sensitiveSize; + SIZEIS(sensitiveSize) + BYTE *sensitiveData; +} TPM_CONTEXT_BLOB; + +typedef struct tdTPM_CONTEXT_SENSITIVE +{ + TPM_STRUCTURE_TAG tag; + TPM_NONCE contextNonce; + UINT32 internalSize; + SIZEIS(internalSize) + BYTE *internalData; +} TPM_CONTEXT_SENSITIVE; + +//------------------------------------------------------------------- +// Part 2, section 19: NV Structures + +typedef UINT32 TPM_NV_INDEX; +#define TPM_NV_INDEX_LOCK ((UINT32)0xffffffff) +#define TPM_NV_INDEX0 ((UINT32)0x00000000) +#define TPM_NV_INDEX_DIR ((UINT32)0x10000001) +// The reserved index values MAY have their D bit set by the +// TPM vendor to permanently reserve the index in the TPM. +// e.g. the typical EK certificate would have the D bit set +// so the actual address would be 1000f000 +#define TPM_NV_INDEX_EKCert ((UINT32)0x0000f000) +#define TPM_NV_INDEX_TPM_CC ((UINT32)0x0000f001) +#define TPM_NV_INDEX_PlatformCert ((UINT32)0x0000f002) +#define TPM_NV_INDEX_Platform_CC ((UINT32)0x0000f003) +// The following define ranges of reserved indices. +#define TPM_NV_INDEX_TSS_BASE ((UINT32)0x00011100) +#define TPM_NV_INDEX_PC_BASE ((UINT32)0x00011200) +#define TPM_NV_INDEX_SERVER_BASE ((UINT32)0x00011300) +#define TPM_NV_INDEX_MOBILE_BASE ((UINT32)0x00011400) +#define TPM_NV_INDEX_PERIPHERAL_BASE ((UINT32)0x00011500) +#define TPM_NV_INDEX_GROUP_RESV_BASE ((UINT32)0x00010000) + + +typedef UINT32 TPM_NV_PER_ATTRIBUTES; +#define TPM_NV_PER_READ_STCLEAR (((UINT32)1)<<31) +#define TPM_NV_PER_AUTHREAD (((UINT32)1)<<18) +#define TPM_NV_PER_OWNERREAD (((UINT32)1)<<17) +#define TPM_NV_PER_PPREAD (((UINT32)1)<<16) +#define TPM_NV_PER_GLOBALLOCK (((UINT32)1)<<15) +#define TPM_NV_PER_WRITE_STCLEAR (((UINT32)1)<<14) +#define TPM_NV_PER_WRITEDEFINE (((UINT32)1)<<13) +#define TPM_NV_PER_WRITEALL (((UINT32)1)<<12) +#define TPM_NV_PER_AUTHWRITE (((UINT32)1)<<2) +#define TPM_NV_PER_OWNERWRITE (((UINT32)1)<<1) +#define TPM_NV_PER_PPWRITE (((UINT32)1)<<0) + +typedef struct tdTPM_NV_ATTRIBUTES +{ + TPM_STRUCTURE_TAG tag; + TPM_NV_PER_ATTRIBUTES attributes; +} TPM_NV_ATTRIBUTES; + + +typedef struct tdTPM_NV_DATA_PUBLIC +{ + TPM_STRUCTURE_TAG tag; + TPM_NV_INDEX nvIndex; + TPM_PCR_INFO_SHORT pcrInfoRead; + TPM_PCR_INFO_SHORT pcrInfoWrite; + TPM_NV_ATTRIBUTES permission; + TPM_BOOL bReadSTClear; + TPM_BOOL bWriteSTClear; + TPM_BOOL bWriteDefine; + UINT32 dataSize; +} TPM_NV_DATA_PUBLIC; + + +#if 0 +// Internal to TPM: +typedef struct tdTPM_NV_DATA_SENSITIVE +{ + TPM_STRUCTURE_TAG tag; + TPM_NV_DATA_PUBLIC pubInfo; + TPM_AUTHDATA authValue; + SIZEIS(pubInfo.dataSize) + BYTE *data; +} TPM_NV_DATA_SENSITIVE; +#endif + + +//------------------------------------------------------------------- +// Part 2, section 20: Delegation + +//------------------------------------------------------------------- +// Part 2, section 20.3: Owner Permissions Settings for per1 bits +#define TPM_DELEGATE_SetOrdinalAuditStatus (((UINT32)1)<<30) +#define TPM_DELEGATE_DirWriteAuth (((UINT32)1)<<29) +#define TPM_DELEGATE_CMK_ApproveMA (((UINT32)1)<<28) +#define TPM_DELEGATE_NV_WriteValue (((UINT32)1)<<27) +#define TPM_DELEGATE_CMK_CreateTicket (((UINT32)1)<<26) +#define TPM_DELEGATE_NV_ReadValue (((UINT32)1)<<25) +#define TPM_DELEGATE_Delegate_LoadOwnerDelegation (((UINT32)1)<<24) +#define TPM_DELEGATE_DAA_Join (((UINT32)1)<<23) +#define TPM_DELEGATE_AuthorizeMigrationKey (((UINT32)1)<<22) +#define TPM_DELEGATE_CreateMaintenanceArchive (((UINT32)1)<<21) +#define TPM_DELEGATE_LoadMaintenanceArchive (((UINT32)1)<<20) +#define TPM_DELEGATE_KillMaintenanceFeature (((UINT32)1)<<19) +#define TPM_DELEGATE_OwnerReadInternalPub (((UINT32)1)<<18) +#define TPM_DELEGATE_ResetLockValue (((UINT32)1)<<17) +#define TPM_DELEGATE_OwnerClear (((UINT32)1)<<16) +#define TPM_DELEGATE_DisableOwnerClear (((UINT32)1)<<15) +#define TPM_DELEGATE_NV_DefineSpace (((UINT32)1)<<14) +#define TPM_DELEGATE_OwnerSetDisable (((UINT32)1)<<13) +#define TPM_DELEGATE_SetCapability (((UINT32)1)<<12) +#define TPM_DELEGATE_MakeIdentity (((UINT32)1)<<11) +#define TPM_DELEGATE_ActivateIdentity (((UINT32)1)<<10) +#define TPM_DELEGATE_OwnerReadPubek (((UINT32)1)<<9) +#define TPM_DELEGATE_DisablePubekRead (((UINT32)1)<<8) +#define TPM_DELEGATE_SetRedirection (((UINT32)1)<<7) +#define TPM_DELEGATE_FieldUpgrade (((UINT32)1)<<6) +#define TPM_DELEGATE_Delegate_UpdateVerification (((UINT32)1)<<5) +#define TPM_DELEGATE_CreateCounter (((UINT32)1)<<4) +#define TPM_DELEGATE_ReleaseCounterOwner (((UINT32)1)<<3) +#define TPM_DELEGATE_DelegateManage (((UINT32)1)<<2) +#define TPM_DELEGATE_Delegate_CreateOwnerDelegation (((UINT32)1)<<1) +#define TPM_DELEGATE_DAA_Sign (((UINT32)1)<<0) + +//------------------------------------------------------------------- +// Part 2, section 20.3: Key Permissions Settings for per1 bits +#define TPM_KEY_DELEGATE_CMK_ConvertMigration (((UINT32)1)<<28) +#define TPM_KEY_DELEGATE_TickStampBlob (((UINT32)1)<<27) +#define TPM_KEY_DELEGATE_ChangeAuthAsymStart (((UINT32)1)<<26) +#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish (((UINT32)1)<<25) +#define TPM_KEY_DELEGATE_CMK_CreateKey (((UINT32)1)<<24) +#define TPM_KEY_DELEGATE_MigrateKey (((UINT32)1)<<23) +#define TPM_KEY_DELEGATE_LoadKey2 (((UINT32)1)<<22) +#define TPM_KEY_DELEGATE_EstablishTransport (((UINT32)1)<<21) +#define TPM_KEY_DELEGATE_ReleaseTransportSigned (((UINT32)1)<<20) +#define TPM_KEY_DELEGATE_Quote2 (((UINT32)1)<<19) +#define TPM_KEY_DELEGATE_Sealx (((UINT32)1)<<18) +#define TPM_KEY_DELEGATE_MakeIdentity (((UINT32)1)<<17) +#define TPM_KEY_DELEGATE_ActivateIdentity (((UINT32)1)<<16) +#define TPM_KEY_DELEGATE_GetAuditDigestSigned (((UINT32)1)<<15) +#define TPM_KEY_DELEGATE_Sign (((UINT32)1)<<14) +#define TPM_KEY_DELEGATE_CertifyKey2 (((UINT32)1)<<13) +#define TPM_KEY_DELEGATE_CertifyKey (((UINT32)1)<<12) +#define TPM_KEY_DELEGATE_CreateWrapKey (((UINT32)1)<<11) +#define TPM_KEY_DELEGATE_CMK_CreateBlob (((UINT32)1)<<10) +#define TPM_KEY_DELEGATE_CreateMigrationBlob (((UINT32)1)<<9) +#define TPM_KEY_DELEGATE_ConvertMigrationBlob (((UINT32)1)<<8) +#define TPM_KEY_DELEGATE_CreateKeyDelegation (((UINT32)1)<<7) +#define TPM_KEY_DELEGATE_ChangeAuth (((UINT32)1)<<6) +#define TPM_KEY_DELEGATE_GetPubKey (((UINT32)1)<<5) +#define TPM_KEY_DELEGATE_UnBind (((UINT32)1)<<4) +#define TPM_KEY_DELEGATE_Quote (((UINT32)1)<<3) +#define TPM_KEY_DELEGATE_Unseal (((UINT32)1)<<2) +#define TPM_KEY_DELEGATE_Seal (((UINT32)1)<<1) +#define TPM_KEY_DELEGATE_LoadKey (((UINT32)1)<<0) + +typedef UINT32 TPM_FAMILY_VERIFICATION; + +typedef UINT32 TPM_FAMILY_ID; + +typedef UINT32 TPM_DELEGATE_INDEX; + +typedef UINT32 TPM_FAMILY_OPERATION; +#define TPM_FAMILY_CREATE ((UINT32)0x00000001) +#define TPM_FAMILY_ENABLE ((UINT32)0x00000002) +#define TPM_FAMILY_ADMIN ((UINT32)0x00000003) +#define TPM_FAMILY_INVALIDATE ((UINT32)0x00000004) + +typedef UINT32 TPM_FAMILY_FLAGS; +#define TPM_FAMFLAG_DELEGATE_ADMIN_LOCK (((UINT32)1)<<1) +#define TPM_FAMFLAG_ENABLE (((UINT32)1)<<0) + +typedef struct tdTPM_FAMILY_LABEL +{ + BYTE label; +} TPM_FAMILY_LABEL; + +typedef struct tdTPM_FAMILY_TABLE_ENTRY +{ + TPM_STRUCTURE_TAG tag; + TPM_FAMILY_LABEL label; + TPM_FAMILY_ID familyID; + TPM_FAMILY_VERIFICATION verificationCount; + TPM_FAMILY_FLAGS flags; +} TPM_FAMILY_TABLE_ENTRY; + + +#define TPM_FAMILY_TABLE_ENTRY_MIN 8 +//typedef struct tdTPM_FAMILY_TABLE +//{ +// TPM_FAMILY_TABLE_ENTRY FamTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN]; +//} TPM_FAMILY_TABLE; + + +typedef struct tdTPM_DELEGATE_LABEL +{ + BYTE label; +} TPM_DELEGATE_LABEL; + + +typedef UINT32 TPM_DELEGATE_TYPE; +#define TPM_DEL_OWNER_BITS ((UINT32)0x00000001) +#define TPM_DEL_KEY_BITS ((UINT32)0x00000002) + +typedef struct tdTPM_DELEGATIONS +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_TYPE delegateType; + UINT32 per1; + UINT32 per2; +} TPM_DELEGATIONS; + +typedef struct tdTPM_DELEGATE_PUBLIC +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_LABEL label; + TPM_PCR_INFO_SHORT pcrInfo; + TPM_DELEGATIONS permissions; + TPM_FAMILY_ID familyID; + TPM_FAMILY_VERIFICATION verificationCount; +} TPM_DELEGATE_PUBLIC; + +typedef struct tdTPM_DELEGATE_TABLE_ROW +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_SECRET authValue; +} TPM_DELEGATE_TABLE_ROW; + + +#define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2 +//typedef struct tdTPM_DELEGATE_TABLE +//{ +// TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN]; +//} TPM_DELEGATE_TABLE; + +typedef struct tdTPM_DELEGATE_SENSITIVE +{ + TPM_STRUCTURE_TAG tag; + TPM_SECRET authValue; +} TPM_DELEGATE_SENSITIVE; + +typedef struct tdTPM_DELEGATE_OWNER_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_DIGEST integrityDigest; + UINT32 additionalSize; + SIZEIS(additionalSize) + BYTE *additionalArea; + UINT32 sensitiveSize; + SIZEIS(sensitiveSize) + BYTE *sensitiveArea; +} TPM_DELEGATE_OWNER_BLOB; + +typedef struct tdTPM_DELEGATE_KEY_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_DIGEST integrityDigest; + TPM_DIGEST pubKeyDigest; + UINT32 additionalSize; + SIZEIS(additionalSize) + BYTE *additionalArea; + UINT32 sensitiveSize; + SIZEIS(sensitiveSize) + BYTE *sensitiveArea; +} TPM_DELEGATE_KEY_BLOB; + + +//------------------------------------------------------------------- +// Part 2, section 21.1: TPM_CAPABILITY_AREA + +typedef UINT32 TPM_CAPABILITY_AREA; /* 1.1b */ +#define TPM_CAP_ORD ((UINT32)0x00000001) /* 1.1b */ +#define TPM_CAP_ALG ((UINT32)0x00000002) /* 1.1b */ +#define TPM_CAP_PID ((UINT32)0x00000003) /* 1.1b */ +#define TPM_CAP_FLAG ((UINT32)0x00000004) /* 1.1b */ +#define TPM_CAP_PROPERTY ((UINT32)0x00000005) /* 1.1b */ +#define TPM_CAP_VERSION ((UINT32)0x00000006) /* 1.1b */ +#define TPM_CAP_KEY_HANDLE ((UINT32)0x00000007) /* 1.1b */ +#define TPM_CAP_CHECK_LOADED ((UINT32)0x00000008) /* 1.1b */ +#define TPM_CAP_SYM_MODE ((UINT32)0x00000009) +#define TPM_CAP_KEY_STATUS ((UINT32)0x0000000C) +#define TPM_CAP_NV_LIST ((UINT32)0x0000000D) +#define TPM_CAP_MFR ((UINT32)0x00000010) +#define TPM_CAP_NV_INDEX ((UINT32)0x00000011) +#define TPM_CAP_TRANS_ALG ((UINT32)0x00000012) +#define TPM_CAP_HANDLE ((UINT32)0x00000014) +#define TPM_CAP_TRANS_ES ((UINT32)0x00000015) +#define TPM_CAP_AUTH_ENCRYPT ((UINT32)0x00000017) +#define TPM_CAP_SELECT_SIZE ((UINT32)0x00000018) +#define TPM_CAP_DA_LOGIC ((UINT32)0x00000019) +#define TPM_CAP_VERSION_VAL ((UINT32)0x0000001A) + +// Part 2, section 21.1: Subcap values for CAP_FLAG +#define TPM_CAP_FLAG_PERMANENT ((UINT32)0x00000108) +#define TPM_CAP_FLAG_VOLATILE ((UINT32)0x00000109) + +//------------------------------------------------------------------- +// Part 2, section 21.2: Subcap values for CAP_PROPERTY + +#define TPM_CAP_PROP_PCR ((UINT32)0x00000101) /* 1.1b */ +#define TPM_CAP_PROP_DIR ((UINT32)0x00000102) /* 1.1b */ +#define TPM_CAP_PROP_MANUFACTURER ((UINT32)0x00000103) /* 1.1b */ +#define TPM_CAP_PROP_KEYS ((UINT32)0x00000104) +#define TPM_CAP_PROP_SLOTS (TPM_CAP_PROP_KEYS) +#define TPM_CAP_PROP_MIN_COUNTER ((UINT32)0x00000107) +#define TPM_CAP_PROP_AUTHSESS ((UINT32)0x0000010A) +#define TPM_CAP_PROP_TRANSSESS ((UINT32)0x0000010B) +#define TPM_CAP_PROP_COUNTERS ((UINT32)0x0000010C) +#define TPM_CAP_PROP_MAX_AUTHSESS ((UINT32)0x0000010D) +#define TPM_CAP_PROP_MAX_TRANSSESS ((UINT32)0x0000010E) +#define TPM_CAP_PROP_MAX_COUNTERS ((UINT32)0x0000010F) +#define TPM_CAP_PROP_MAX_KEYS ((UINT32)0x00000110) +#define TPM_CAP_PROP_OWNER ((UINT32)0x00000111) +#define TPM_CAP_PROP_CONTEXT ((UINT32)0x00000112) +#define TPM_CAP_PROP_MAX_CONTEXT ((UINT32)0x00000113) +#define TPM_CAP_PROP_FAMILYROWS ((UINT32)0x00000114) +#define TPM_CAP_PROP_TIS_TIMEOUT ((UINT32)0x00000115) +#define TPM_CAP_PROP_STARTUP_EFFECT ((UINT32)0x00000116) +#define TPM_CAP_PROP_DELEGATE_ROW ((UINT32)0x00000117) +#define TPM_CAP_PROP_MAX_DAASESS ((UINT32)0x00000119) +#define TPM_CAP_PROP_DAA_MAX TPM_CAP_PROP_MAX_DAASESS +#define TPM_CAP_PROP_DAASESS ((UINT32)0x0000011A) +#define TPM_CAP_PROP_SESSION_DAA TPM_CAP_PROP_DAASESS +#define TPM_CAP_PROP_CONTEXT_DIST ((UINT32)0x0000011B) +#define TPM_CAP_PROP_DAA_INTERRUPT ((UINT32)0x0000011C) +#define TPM_CAP_PROP_SESSIONS ((UINT32)0x0000011D) +#define TPM_CAP_PROP_MAX_SESSIONS ((UINT32)0x0000011E) +#define TPM_CAP_PROP_CMK_RESTRICTION ((UINT32)0x0000011F) +#define TPM_CAP_PROP_DURATION ((UINT32)0x00000120) +#define TPM_CAP_PROP_ACTIVE_COUNTER ((UINT32)0x00000122) +#define TPM_CAP_PROP_NV_AVAILABLE ((UINT32)0x00000123) +#define TPM_CAP_PROP_INPUT_BUFFER ((UINT32)0x00000124) + + +// Part 2, section 21.4: SetCapability Values +#define TPM_SET_PERM_FLAGS ((UINT32)0x00000001) +#define TPM_SET_PERM_DATA ((UINT32)0x00000002) +#define TPM_SET_STCLEAR_FLAGS ((UINT32)0x00000003) +#define TPM_SET_STCLEAR_DATA ((UINT32)0x00000004) +#define TPM_SET_STANY_FLAGS ((UINT32)0x00000005) +#define TPM_SET_STANY_DATA ((UINT32)0x00000006) +#define TPM_SET_VENDOR ((UINT32)0x00000007) + + +// Part 2, section 21.6: TPM_CAP_VERSION_INFO +typedef struct tdTPM_CAP_VERSION_INFO +{ + TPM_STRUCTURE_TAG tag; + TPM_VERSION version; + UINT16 specLevel; + BYTE errataRev; + BYTE tpmVendorID[4]; + UINT16 vendorSpecificSize; + SIZEIS(vendorSpecificSize) + BYTE *vendorSpecific; +} TPM_CAP_VERSION_INFO; + + +// Part 2, section 21.9: TPM_DA_STATE +// out of order to make it available for structure definitions +typedef BYTE TPM_DA_STATE; +#define TPM_DA_STATE_INACTIVE (0x00) +#define TPM_DA_STATE_ACTIVE (0x01) + +// Part 2, section 21.10: TPM_DA_ACTION_TYPE +typedef struct tdTPM_DA_ACTION_TYPE +{ + TPM_STRUCTURE_TAG tag; + UINT32 actions; +} TPM_DA_ACTION_TYPE; +#define TPM_DA_ACTION_TIMEOUT ((UINT32)0x00000001) +#define TPM_DA_ACTION_DISABLE ((UINT32)0x00000002) +#define TPM_DA_ACTION_DEACTIVATE ((UINT32)0x00000004) +#define TPM_DA_ACTION_FAILURE_MODE ((UINT32)0x00000008) + +// Part 2, section 21.7: TPM_DA_INFO +typedef struct tdTPM_DA_INFO +{ + TPM_STRUCTURE_TAG tag; + TPM_DA_STATE state; + UINT16 currentCount; + UINT16 threshholdCount; + TPM_DA_ACTION_TYPE actionAtThreshold; + UINT32 actionDependValue; + UINT32 vendorDataSize; + SIZEIS(vendorDataSize) + BYTE *vendorData; +} TPM_DA_INFO; + +// Part 2, section 21.8: TPM_DA_INFO_LIMITED +typedef struct tdTPM_DA_INFO_LIMITED +{ + TPM_STRUCTURE_TAG tag; + TPM_DA_STATE state; + TPM_DA_ACTION_TYPE actionAtThreshold; + UINT32 vendorDataSize; + SIZEIS(vendorDataSize) + BYTE *vendorData; +} TPM_DA_INFO_LIMITED; + + + +//------------------------------------------------------------------- +// Part 2, section 22: DAA Structures + +#define TPM_DAA_SIZE_r0 (43) +#define TPM_DAA_SIZE_r1 (43) +#define TPM_DAA_SIZE_r2 (128) +#define TPM_DAA_SIZE_r3 (168) +#define TPM_DAA_SIZE_r4 (219) +#define TPM_DAA_SIZE_NT (20) +#define TPM_DAA_SIZE_v0 (128) +#define TPM_DAA_SIZE_v1 (192) +#define TPM_DAA_SIZE_NE (256) +#define TPM_DAA_SIZE_w (256) +#define TPM_DAA_SIZE_issuerModulus (256) +#define TPM_DAA_power0 (104) +#define TPM_DAA_power1 (1024) + +typedef struct tdTPM_DAA_ISSUER +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digest_R0; + TPM_DIGEST DAA_digest_R1; + TPM_DIGEST DAA_digest_S0; + TPM_DIGEST DAA_digest_S1; + TPM_DIGEST DAA_digest_n; + TPM_DIGEST DAA_digest_gamma; + BYTE DAA_generic_q[26]; +} TPM_DAA_ISSUER; + + +typedef struct tdTPM_DAA_TPM +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digestIssuer; + TPM_DIGEST DAA_digest_v0; + TPM_DIGEST DAA_digest_v1; + TPM_DIGEST DAA_rekey; + UINT32 DAA_count; +} TPM_DAA_TPM; + +typedef struct tdTPM_DAA_CONTEXT +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digestContext; + TPM_DIGEST DAA_digest; + TPM_DAA_CONTEXT_SEED DAA_contextSeed; + BYTE DAA_scratch[256]; + BYTE DAA_stage; +} TPM_DAA_CONTEXT; + +typedef struct tdTPM_DAA_JOINDATA +{ + BYTE DAA_join_u0[128]; + BYTE DAA_join_u1[138]; + TPM_DIGEST DAA_digest_n0; +} TPM_DAA_JOINDATA; + +typedef struct tdTPM_DAA_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_RESOURCE_TYPE resourceType; + BYTE label[16]; + TPM_DIGEST blobIntegrity; + UINT32 additionalSize; + SIZEIS(additionalSize) + BYTE *additionalData; + UINT32 sensitiveSize; + SIZEIS(sensitiveSize) + BYTE *sensitiveData; +} TPM_DAA_BLOB; + +typedef struct tdTPM_DAA_SENSITIVE +{ + TPM_STRUCTURE_TAG tag; + UINT32 internalSize; + SIZEIS(internalSize) + BYTE *internalData; +} TPM_DAA_SENSITIVE; + + + +//------------------------------------------------------------------- +// Part 2, section 23: Redirection + +// This section of the TPM spec defines exactly one value but does not +// give it a name. The definition of TPM_SetRedirection in Part3 +// refers to exactly one name but does not give its value. We join +// them here. +#define TPM_REDIR_GPIO (0x00000001) + + +//------------------------------------------------------------------- +// Part 2, section 24.6: TPM_SYM_MODE +// Deprecated by TPM 1.2 spec + +typedef UINT32 TPM_SYM_MODE; +#define TPM_SYM_MODE_ECB (0x00000001) +#define TPM_SYM_MODE_CBC (0x00000002) +#define TPM_SYM_MODE_CFB (0x00000003) + +#endif // __TPM_H__ + diff --git a/illumos-x86_64/usr/include/tss/tpm_error.h b/illumos-x86_64/usr/include/tss/tpm_error.h new file mode 100644 index 00000000..3596e6d8 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tpm_error.h @@ -0,0 +1,963 @@ +/* + * The TPM error codes extracted from the TPM main specification + * version 1.2 revision 85. + */ + +#ifndef __TPM_ERROR_H__ +#define __TPM_ERROR_H__ + + +#ifndef TPM_E_BASE +#define TPM_E_BASE ((UINT32)0) +#endif + +#ifndef TPM_E_NON_FATAL +#define TPM_E_NON_FATAL ((UINT32)0x00000800) +#endif + + +// Successful completion of the TPM operation. +#define TPM_SUCCESS TPM_E_BASE + +// +// MessageId: TPM_E_AUTHFAIL +// +// MessageText: +// +// Authentication failed +// +#define TPM_E_AUTHFAIL ((UINT32)(TPM_E_BASE + 0x00000001)) + +// +// MessageId: TPM_E_BADINDEX +// +// MessageText: +// +// The index to a PCR, DIR or other register is incorrect +// +#define TPM_E_BADINDEX ((UINT32)(TPM_E_BASE + 0x00000002)) + +// +// MessageId: TPM_E_BAD_PARAMETER +// +// MessageText: +// +// One or more parameter is bad +// +#define TPM_E_BAD_PARAMETER ((UINT32)(TPM_E_BASE + 0x00000003)) + +// +// MessageId: TPM_E_AUDITFAILURE +// +// MessageText: +// +// An operation completed successfully but the auditing of that +// operation failed. +// +#define TPM_E_AUDITFAILURE ((UINT32)(TPM_E_BASE + 0x00000004)) + +// +// MessageId: TPM_E_CLEAR_DISABLED +// +// MessageText: +// +// The clear disable flag is set and all clear operations now require +// physical access +// +#define TPM_E_CLEAR_DISABLED ((UINT32)(TPM_E_BASE + 0x00000005)) + +// +// MessageId: TPM_E_DEACTIVATED +// +// MessageText: +// +// The TPM is deactivated +// +#define TPM_E_DEACTIVATED ((UINT32)(TPM_E_BASE + 0x00000006)) + +// +// MessageId: TPM_E_DISABLED +// +// MessageText: +// +// The TPM is disabled +// +#define TPM_E_DISABLED ((UINT32)(TPM_E_BASE + 0x00000007)) + +// +// MessageId: TPM_E_DISABLED_CMD +// +// MessageText: +// +// The target command has been disabled +// +#define TPM_E_DISABLED_CMD ((UINT32)(TPM_E_BASE + 0x00000008)) + +// +// MessageId: TPM_E_FAIL +// +// MessageText: +// +// The operation failed +// +#define TPM_E_FAIL ((UINT32)(TPM_E_BASE + 0x00000009)) + +// +// MessageId: TPM_E_BAD_ORDINAL +// +// MessageText: +// +// The ordinal was unknown or inconsistent +// +#define TPM_E_BAD_ORDINAL ((UINT32)(TPM_E_BASE + 0x0000000a)) + +// +// MessageId: TPM_E_INSTALL_DISABLED +// +// MessageText: +// +// The ability to install an owner is disabled +// +#define TPM_E_INSTALL_DISABLED ((UINT32)(TPM_E_BASE + 0x0000000b)) + +// +// MessageId: TPM_E_INVALID_KEYHANDLE +// +// MessageText: +// +// The key handle can not be interpreted +// +#define TPM_E_INVALID_KEYHANDLE ((UINT32)(TPM_E_BASE + 0x0000000c)) + +// +// MessageId: TPM_E_KEYNOTFOUND +// +// MessageText: +// +// The key handle points to an invalid key +// +#define TPM_E_KEYNOTFOUND ((UINT32)(TPM_E_BASE + 0x0000000d)) + +// +// MessageId: TPM_E_INAPPROPRIATE_ENC +// +// MessageText: +// +// Unacceptable encryption scheme +// +#define TPM_E_INAPPROPRIATE_ENC ((UINT32)(TPM_E_BASE + 0x0000000e)) + +// +// MessageId: TPM_E_MIGRATEFAIL +// +// MessageText: +// +// Migration authorization failed +// +#define TPM_E_MIGRATEFAIL ((UINT32)(TPM_E_BASE + 0x0000000f)) + +// +// MessageId: TPM_E_INVALID_PCR_INFO +// +// MessageText: +// +// PCR information could not be interpreted +// +#define TPM_E_INVALID_PCR_INFO ((UINT32)(TPM_E_BASE + 0x00000010)) + +// +// MessageId: TPM_E_NOSPACE +// +// MessageText: +// +// No room to load key. +// +#define TPM_E_NOSPACE ((UINT32)(TPM_E_BASE + 0x00000011)) + +// +// MessageId: TPM_E_NOSRK +// +// MessageText: +// +// There is no SRK set +// +#define TPM_E_NOSRK ((UINT32)(TPM_E_BASE + 0x00000012)) + +// +// MessageId: TPM_E_NOTSEALED_BLOB +// +// MessageText: +// +// An encrypted blob is invalid or was not created by this TPM +// +#define TPM_E_NOTSEALED_BLOB ((UINT32)(TPM_E_BASE + 0x00000013)) + +// +// MessageId: TPM_E_OWNER_SET +// +// MessageText: +// +// There is already an Owner +// +#define TPM_E_OWNER_SET ((UINT32)(TPM_E_BASE + 0x00000014)) + +// +// MessageId: TPM_E_RESOURCES +// +// MessageText: +// +// The TPM has insufficient internal resources to perform the +// requested action. +// +#define TPM_E_RESOURCES ((UINT32)(TPM_E_BASE + 0x00000015)) + +// +// MessageId: TPM_E_SHORTRANDOM +// +// MessageText: +// +// A random string was too short +// +#define TPM_E_SHORTRANDOM ((UINT32)(TPM_E_BASE + 0x00000016)) + +// +// MessageId: TPM_E_SIZE +// +// MessageText: +// +// The TPM does not have the space to perform the operation. +// +#define TPM_E_SIZE ((UINT32)(TPM_E_BASE + 0x00000017)) + +// +// MessageId: TPM_E_WRONGPCRVAL +// +// MessageText: +// +// The named PCR value does not match the current PCR value. +// +#define TPM_E_WRONGPCRVAL ((UINT32)(TPM_E_BASE + 0x00000018)) + +// +// MessageId: TPM_E_BAD_PARAM_SIZE +// +// MessageText: +// +// The paramSize argument to the command has the incorrect value +// +#define TPM_E_BAD_PARAM_SIZE ((UINT32)(TPM_E_BASE + 0x00000019)) + +// +// MessageId: TPM_E_SHA_THREAD +// +// MessageText: +// +// There is no existing SHA-1 thread. +// +#define TPM_E_SHA_THREAD ((UINT32)(TPM_E_BASE + 0x0000001a)) + +// +// MessageId: TPM_E_SHA_ERROR +// +// MessageText: +// +// The calculation is unable to proceed because the existing SHA-1 +// thread has already encountered an error. +// +#define TPM_E_SHA_ERROR ((UINT32)(TPM_E_BASE + 0x0000001b)) + +// +// MessageId: TPM_E_FAILEDSELFTEST +// +// MessageText: +// +// Self-test has failed and the TPM has shutdown. +// +#define TPM_E_FAILEDSELFTEST ((UINT32)(TPM_E_BASE + 0x0000001c)) + +// +// MessageId: TPM_E_AUTH2FAIL +// +// MessageText: +// +// The authorization for the second key in a 2 key function failed +// authorization +// +#define TPM_E_AUTH2FAIL ((UINT32)(TPM_E_BASE + 0x0000001d)) + +// +// MessageId: TPM_E_BADTAG +// +// MessageText: +// +// The tag value sent to for a command is invalid +// +#define TPM_E_BADTAG ((UINT32)(TPM_E_BASE + 0x0000001e)) + +// +// MessageId: TPM_E_IOERROR +// +// MessageText: +// +// An IO error occurred transmitting information to the TPM +// +#define TPM_E_IOERROR ((UINT32)(TPM_E_BASE + 0x0000001f)) + +// +// MessageId: TPM_E_ENCRYPT_ERROR +// +// MessageText: +// +// The encryption process had a problem. +// +#define TPM_E_ENCRYPT_ERROR ((UINT32)(TPM_E_BASE + 0x00000020)) + +// +// MessageId: TPM_E_DECRYPT_ERROR +// +// MessageText: +// +// The decryption process did not complete. +// +#define TPM_E_DECRYPT_ERROR ((UINT32)(TPM_E_BASE + 0x00000021)) + +// +// MessageId: TPM_E_INVALID_AUTHHANDLE +// +// MessageText: +// +// An invalid handle was used. +// +#define TPM_E_INVALID_AUTHHANDLE ((UINT32)(TPM_E_BASE + 0x00000022)) + +// +// MessageId: TPM_E_NO_ENDORSEMENT +// +// MessageText: +// +// The TPM does not a EK installed +// +#define TPM_E_NO_ENDORSEMENT ((UINT32)(TPM_E_BASE + 0x00000023)) + +// +// MessageId: TPM_E_INVALID_KEYUSAGE +// +// MessageText: +// +// The usage of a key is not allowed +// +#define TPM_E_INVALID_KEYUSAGE ((UINT32)(TPM_E_BASE + 0x00000024)) + +// +// MessageId: TPM_E_WRONG_ENTITYTYPE +// +// MessageText: +// +// The submitted entity type is not allowed +// +#define TPM_E_WRONG_ENTITYTYPE ((UINT32)(TPM_E_BASE + 0x00000025)) + +// +// MessageId: TPM_E_INVALID_POSTINIT +// +// MessageText: +// +// The command was received in the wrong sequence relative to TPM_Init +// and a subsequent TPM_Startup +// +#define TPM_E_INVALID_POSTINIT ((UINT32)(TPM_E_BASE + 0x00000026)) + +// +// MessageId: TPM_E_INAPPROPRIATE_SIG +// +// MessageText: +// +// Signed data cannot include additional DER information +// +#define TPM_E_INAPPROPRIATE_SIG ((UINT32)(TPM_E_BASE + 0x00000027)) + +// +// MessageId: TPM_E_BAD_KEY_PROPERTY +// +// MessageText: +// +// The key properties in TPM_KEY_PARMs are not supported by this TPM +// +#define TPM_E_BAD_KEY_PROPERTY ((UINT32)(TPM_E_BASE + 0x00000028)) + +// +// MessageId: TPM_E_BAD_MIGRATION +// +// MessageText: +// +// The migration properties of this key are incorrect. +// +#define TPM_E_BAD_MIGRATION ((UINT32)(TPM_E_BASE + 0x00000029)) + +// +// MessageId: TPM_E_BAD_SCHEME +// +// MessageText: +// +// The signature or encryption scheme for this key is incorrect or not +// permitted in this situation. +// +#define TPM_E_BAD_SCHEME ((UINT32)(TPM_E_BASE + 0x0000002a)) + +// +// MessageId: TPM_E_BAD_DATASIZE +// +// MessageText: +// +// The size of the data (or blob) parameter is bad or inconsistent +// with the referenced key +// +#define TPM_E_BAD_DATASIZE ((UINT32)(TPM_E_BASE + 0x0000002b)) + +// +// MessageId: TPM_E_BAD_MODE +// +// MessageText: +// +// A mode parameter is bad, such as capArea or subCapArea for +// TPM_GetCapability, physicalPresence parameter for +// TPM_PhysicalPresence, or migrationType for TPM_CreateMigrationBlob. +// +#define TPM_E_BAD_MODE ((UINT32)(TPM_E_BASE + 0x0000002c)) + +// +// MessageId: TPM_E_BAD_PRESENCE +// +// MessageText: +// +// Either the physicalPresence or physicalPresenceLock bits have the +// wrong value +// +#define TPM_E_BAD_PRESENCE ((UINT32)(TPM_E_BASE + 0x0000002d)) + +// +// MessageId: TPM_E_BAD_VERSION +// +// MessageText: +// +// The TPM cannot perform this version of the capability +// +#define TPM_E_BAD_VERSION ((UINT32)(TPM_E_BASE + 0x0000002e)) + +// +// MessageId: TPM_E_NO_WRAP_TRANSPORT +// +// MessageText: +// +// The TPM does not allow for wrapped transport sessions +// +#define TPM_E_NO_WRAP_TRANSPORT ((UINT32)(TPM_E_BASE + 0x0000002f)) + +// +// MessageId: TPM_E_AUDITFAIL_UNSUCCESSFUL +// +// MessageText: +// +// TPM audit construction failed and the underlying command was +// returning a failure code also +// +#define TPM_E_AUDITFAIL_UNSUCCESSFUL ((UINT32)(TPM_E_BASE + 0x00000030)) + +// +// MessageId: TPM_E_AUDITFAIL_SUCCESSFUL +// +// MessageText: +// +// TPM audit construction failed and the underlying command was +// returning success +// +#define TPM_E_AUDITFAIL_SUCCESSFUL ((UINT32)(TPM_E_BASE + 0x00000031)) + +// +// MessageId: TPM_E_NOTRESETABLE +// +// MessageText: +// +// Attempt to reset a PCR register that does not have the resettable +// attribute +// +#define TPM_E_NOTRESETABLE ((UINT32)(TPM_E_BASE + 0x00000032)) + +// +// MessageId: TPM_E_NOTLOCAL +// +// MessageText: +// +// Attempt to reset a PCR register that requires locality and locality +// modifier not part of command transport +// +#define TPM_E_NOTLOCAL ((UINT32)(TPM_E_BASE + 0x00000033)) + +// +// MessageId: TPM_E_BAD_TYPE +// +// MessageText: +// +// Make identity blob not properly typed +// +#define TPM_E_BAD_TYPE ((UINT32)(TPM_E_BASE + 0x00000034)) + +// +// MessageId: TPM_E_INVALID_RESOURCE +// +// MessageText: +// +// When saving context identified resource type does not match actual +// resource +// +#define TPM_E_INVALID_RESOURCE ((UINT32)(TPM_E_BASE + 0x00000035)) + +// +// MessageId: TPM_E_NOTFIPS +// +// MessageText: +// +// The TPM is attempting to execute a command only available when in +// FIPS mode +// +#define TPM_E_NOTFIPS ((UINT32)(TPM_E_BASE + 0x00000036)) + +// +// MessageId: TPM_E_INVALID_FAMILY +// +// MessageText: +// +// The command is attempting to use an invalid family ID +// +#define TPM_E_INVALID_FAMILY ((UINT32)(TPM_E_BASE + 0x00000037)) + +// +// MessageId: TPM_E_NO_NV_PERMISSION +// +// MessageText: +// +// The permission to manipulate the NV storage is not available +// +#define TPM_E_NO_NV_PERMISSION ((UINT32)(TPM_E_BASE + 0x00000038)) + +// +// MessageId: TPM_E_REQUIRES_SIGN +// +// MessageText: +// +// The operation requires a signed command +// +#define TPM_E_REQUIRES_SIGN ((UINT32)(TPM_E_BASE + 0x00000039)) + +// +// MessageId: TPM_E_KEY_NOTSUPPORTED +// +// MessageText: +// +// Wrong operation to load an NV key +// +#define TPM_E_KEY_NOTSUPPORTED ((UINT32)(TPM_E_BASE + 0x0000003a)) + +// +// MessageId: TPM_E_AUTH_CONFLICT +// +// MessageText: +// +// NV_LoadKey blob requires both owner and blob authorization +// +#define TPM_E_AUTH_CONFLICT ((UINT32)(TPM_E_BASE + 0x0000003b)) + +// +// MessageId: TPM_E_AREA_LOCKED +// +// MessageText: +// +// The NV area is locked and not writable +// +#define TPM_E_AREA_LOCKED ((UINT32)(TPM_E_BASE + 0x0000003c)) + +// +// MessageId: TPM_E_BAD_LOCALITY +// +// MessageText: +// +// The locality is incorrect for the attempted operation +// +#define TPM_E_BAD_LOCALITY ((UINT32)(TPM_E_BASE + 0x0000003d)) + +// +// MessageId: TPM_E_READ_ONLY +// +// MessageText: +// +// The NV area is read only and can't be written to +// +#define TPM_E_READ_ONLY ((UINT32)(TPM_E_BASE + 0x0000003e)) + +// +// MessageId: TPM_E_PER_NOWRITE +// +// MessageText: +// +// There is no protection on the write to the NV area +// +#define TPM_E_PER_NOWRITE ((UINT32)(TPM_E_BASE + 0x0000003f)) + +// +// MessageId: TPM_E_FAMILYCOUNT +// +// MessageText: +// +// The family count value does not match +// +#define TPM_E_FAMILYCOUNT ((UINT32)(TPM_E_BASE + 0x00000040)) + +// +// MessageId: TPM_E_WRITE_LOCKED +// +// MessageText: +// +// The NV area has already been written to +// +#define TPM_E_WRITE_LOCKED ((UINT32)(TPM_E_BASE + 0x00000041)) + +// +// MessageId: TPM_E_BAD_ATTRIBUTES +// +// MessageText: +// +// The NV area attributes conflict +// +#define TPM_E_BAD_ATTRIBUTES ((UINT32)(TPM_E_BASE + 0x00000042)) + +// +// MessageId: TPM_E_INVALID_STRUCTURE +// +// MessageText: +// +// The structure tag and version are invalid or inconsistent +// +#define TPM_E_INVALID_STRUCTURE ((UINT32)(TPM_E_BASE + 0x00000043)) + +// +// MessageId: TPM_E_KEY_OWNER_CONTROL +// +// MessageText: +// +// The key is under control of the TPM Owner and can only be evicted +// by the TPM Owner. +// +#define TPM_E_KEY_OWNER_CONTROL ((UINT32)(TPM_E_BASE + 0x00000044)) + +// +// MessageId: TPM_E_BAD_COUNTER +// +// MessageText: +// +// The counter handle is incorrect +// +#define TPM_E_BAD_COUNTER ((UINT32)(TPM_E_BASE + 0x00000045)) + +// +// MessageId: TPM_E_NOT_FULLWRITE +// +// MessageText: +// +// The write is not a complete write of the area +// +#define TPM_E_NOT_FULLWRITE ((UINT32)(TPM_E_BASE + 0x00000046)) + +// +// MessageId: TPM_E_CONTEXT_GAP +// +// MessageText: +// +// The gap between saved context counts is too large +// +#define TPM_E_CONTEXT_GAP ((UINT32)(TPM_E_BASE + 0x00000047)) + +// +// MessageId: TPM_E_MAXNVWRITES +// +// MessageText: +// +// The maximum number of NV writes without an owner has been exceeded +// +#define TPM_E_MAXNVWRITES ((UINT32)(TPM_E_BASE + 0x00000048)) + +// +// MessageId: TPM_E_NOOPERATOR +// +// MessageText: +// +// No operator AuthData value is set +// +#define TPM_E_NOOPERATOR ((UINT32)(TPM_E_BASE + 0x00000049)) + +// +// MessageId: TPM_E_RESOURCEMISSING +// +// MessageText: +// +// The resource pointed to by context is not loaded +// +#define TPM_E_RESOURCEMISSING ((UINT32)(TPM_E_BASE + 0x0000004a)) + +// +// MessageId: TPM_E_DELEGATE_LOCK +// +// MessageText: +// +// The delegate administration is locked +// +#define TPM_E_DELEGATE_LOCK ((UINT32)(TPM_E_BASE + 0x0000004b)) + +// +// MessageId: TPM_E_DELEGATE_FAMILY +// +// MessageText: +// +// Attempt to manage a family other then the delegated family +// +#define TPM_E_DELEGATE_FAMILY ((UINT32)(TPM_E_BASE + 0x0000004c)) + +// +// MessageId: TPM_E_DELEGATE_ADMIN +// +// MessageText: +// +// Delegation table management not enabled +// +#define TPM_E_DELEGATE_ADMIN ((UINT32)(TPM_E_BASE + 0x0000004d)) + +// +// MessageId: TPM_E_TRANSPORT_NOTEXCLUSIVE +// +// MessageText: +// +// There was a command executed outside of an exclusive transport session +// +#define TPM_E_TRANSPORT_NOTEXCLUSIVE ((UINT32)(TPM_E_BASE + 0x0000004e)) + +// +// MessageId: TPM_E_OWNER_CONTROL +// +// MessageText: +// +// Attempt to context save a owner evict controlled key +// +#define TPM_E_OWNER_CONTROL ((UINT32)(TPM_E_BASE + 0x0000004f)) + +// +// MessageId: TPM_E_DAA_RESOURCES +// +// MessageText: +// +// The DAA command has no resources available to execute the command +// +#define TPM_E_DAA_RESOURCES ((UINT32)(TPM_E_BASE + 0x00000050)) + +// +// MessageId: TPM_E_DAA_INPUT_DATA0 +// +// MessageText: +// +// The consistency check on DAA parameter inputData0 has failed. +// +#define TPM_E_DAA_INPUT_DATA0 ((UINT32)(TPM_E_BASE + 0x00000051)) + +// +// MessageId: TPM_E_DAA_INPUT_DATA1 +// +// MessageText: +// +// The consistency check on DAA parameter inputData1 has failed. +// +#define TPM_E_DAA_INPUT_DATA1 ((UINT32)(TPM_E_BASE + 0x00000052)) + +// +// MessageId: TPM_E_DAA_ISSUER_SETTINGS +// +// MessageText: +// +// The consistency check on DAA_issuerSettings has failed. +// +#define TPM_E_DAA_ISSUER_SETTINGS ((UINT32)(TPM_E_BASE + 0x00000053)) + +// +// MessageId: TPM_E_DAA_TPM_SETTINGS +// +// MessageText: +// +// The consistency check on DAA_tpmSpecific has failed. +// +#define TPM_E_DAA_TPM_SETTINGS ((UINT32)(TPM_E_BASE + 0x00000054)) + +// +// MessageId: TPM_E_DAA_STAGE +// +// MessageText: +// +// The atomic process indicated by the submitted DAA command is not +// the expected process. +// +#define TPM_E_DAA_STAGE ((UINT32)(TPM_E_BASE + 0x00000055)) + +// +// MessageId: TPM_E_DAA_ISSUER_VALIDITY +// +// MessageText: +// +// The issuer's validity check has detected an inconsistency +// +#define TPM_E_DAA_ISSUER_VALIDITY ((UINT32)(TPM_E_BASE + 0x00000056)) + +// +// MessageId: TPM_E_DAA_WRONG_W +// +// MessageText: +// +// The consistency check on w has failed. +// +#define TPM_E_DAA_WRONG_W ((UINT32)(TPM_E_BASE + 0x00000057)) + +// +// MessageId: TPM_E_BAD_HANDLE +// +// MessageText: +// +// The handle is incorrect +// +#define TPM_E_BAD_HANDLE ((UINT32)(TPM_E_BASE + 0x00000058)) + +// +// MessageId: TPM_E_BAD_DELEGATE +// +// MessageText: +// +// Delegation is not correct +// +#define TPM_E_BAD_DELEGATE ((UINT32)(TPM_E_BASE + 0x00000059)) + +// +// MessageId: TPM_E_BADCONTEXT +// +// MessageText: +// +// The context blob is invalid +// +#define TPM_E_BADCONTEXT ((UINT32)(TPM_E_BASE + 0x0000005a)) + +// +// MessageId: TPM_E_TOOMANYCONTEXTS +// +// MessageText: +// +// Too many contexts held by the TPM +// +#define TPM_E_TOOMANYCONTEXTS ((UINT32)(TPM_E_BASE + 0x0000005b)) + +// +// MessageId: TPM_E_MA_TICKET_SIGNATURE +// +// MessageText: +// +// Migration authority signature validation failure +// +#define TPM_E_MA_TICKET_SIGNATURE ((UINT32)(TPM_E_BASE + 0x0000005c)) + +// +// MessageId: TPM_E_MA_DESTINATION +// +// MessageText: +// +// Migration destination not authenticated +// +#define TPM_E_MA_DESTINATION ((UINT32)(TPM_E_BASE + 0x0000005d)) + +// +// MessageId: TPM_E_MA_SOURCE +// +// MessageText: +// +// Migration source incorrect +// +#define TPM_E_MA_SOURCE ((UINT32)(TPM_E_BASE + 0x0000005e)) + +// +// MessageId: TPM_E_MA_AUTHORITY +// +// MessageText: +// +// Incorrect migration authority +// +#define TPM_E_MA_AUTHORITY ((UINT32)(TPM_E_BASE + 0x0000005f)) + +// +// MessageId: TPM_E_PERMANENTEK +// +// MessageText: +// +// Attempt to revoke the EK and the EK is not revocable +// +#define TPM_E_PERMANENTEK ((UINT32)(TPM_E_BASE + 0x00000061)) + +// +// MessageId: TPM_E_BAD_SIGNATURE +// +// MessageText: +// +// Bad signature of CMK ticket +// +#define TPM_E_BAD_SIGNATURE ((UINT32)(TPM_E_BASE + 0x00000062)) + +// +// MessageId: TPM_E_NOCONTEXTSPACE +// +// MessageText: +// +// There is no room in the context list for additional contexts +// +#define TPM_E_NOCONTEXTSPACE ((UINT32)(TPM_E_BASE + 0x00000063)) + + +// +// MessageId: TPM_E_RETRY +// +// MessageText: +// +// The TPM is too busy to respond to the command immediately, but the +// command could be resubmitted at a later time. The TPM MAY return +// TPM_Retry for any command at any time. +// +#define TPM_E_RETRY ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL)) + +// +// MessageId: TPM_E_NEEDS_SELFTEST +// +// MessageText: +// +// SelfTestFull has not been run +// +#define TPM_E_NEEDS_SELFTEST ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 1)) + +// +// MessageId: TPM_E_DOING_SELFTEST +// +// MessageText: +// +// The TPM is currently executing a full selftest +// +#define TPM_E_DOING_SELFTEST ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 2)) + +// +// MessageId: TPM_E_DEFEND_LOCK_RUNNING +// +// MessageText: +// +// The TPM is defending against dictionary attacks and is in some +// time-out period. +// +#define TPM_E_DEFEND_LOCK_RUNNING ((UINT32)(TPM_E_BASE + TPM_E_NON_FATAL + 3)) + +#endif /* __TPM_ERROR_H__ */ diff --git a/illumos-x86_64/usr/include/tss/tpm_ordinal.h b/illumos-x86_64/usr/include/tss/tpm_ordinal.h new file mode 100644 index 00000000..ca096116 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tpm_ordinal.h @@ -0,0 +1,151 @@ +/* + * TPM Ordinal definitions extracted from the TPM 1.2 specification, rev 85. + */ + +#ifndef __TPM_ORDINAL_H__ +#define __TPM_ORDINAL_H__ + +#define TPM_PROTECTED_COMMAND ((UINT32)(0x00000000)) +#define TPM_UNPROTECTED_COMMAND ((UINT32)(0x80000000)) +#define TPM_CONNECTION_COMMAND ((UINT32)(0x40000000)) +#define TPM_VENDOR_COMMAND ((UINT32)(0x20000000)) + +#define TPM_MAIN ((UINT16)(0x0000)) +#define TPM_PC ((UINT16)(0x0001)) +#define TPM_PDA ((UINT16)(0x0002)) +#define TPM_CELL_PHONE ((UINT16)(0x0003)) +#define TPM_SERVER ((UINT16)(0x0004)) + +#define TPM_PROTECTED_ORDINAL (TPM_MAIN | TPM_PROTECTED_COMMAND) +#define TPM_UNPROTECTED_ORDINAL (TPM_MAIN | TPM_UNPROTECTED_COMMAND) +#define TPM_CONNECTION_ORDINAL (TPM_MAIN | TPM_CONNECTION_COMMAND) + + +#define TPM_ORD_OIAP ((UINT32)0x0000000A) +#define TPM_ORD_OSAP ((UINT32)0x0000000B) +#define TPM_ORD_ChangeAuth ((UINT32)0x0000000C) +#define TPM_ORD_TakeOwnership ((UINT32)0x0000000D) +#define TPM_ORD_ChangeAuthAsymStart ((UINT32)0x0000000E) +#define TPM_ORD_ChangeAuthAsymFinish ((UINT32)0x0000000F) +#define TPM_ORD_ChangeAuthOwner ((UINT32)0x00000010) +#define TPM_ORD_DSAP ((UINT32)0x00000011) +#define TPM_ORD_CMK_CreateTicket ((UINT32)0x00000012) +#define TPM_ORD_CMK_CreateKey ((UINT32)0x00000013) +#define TPM_ORD_Extend ((UINT32)0x00000014) +#define TPM_ORD_PcrRead ((UINT32)0x00000015) +#define TPM_ORD_Quote ((UINT32)0x00000016) +#define TPM_ORD_Seal ((UINT32)0x00000017) +#define TPM_ORD_Unseal ((UINT32)0x00000018) +#define TPM_ORD_DirWriteAuth ((UINT32)0x00000019) +#define TPM_ORD_DirRead ((UINT32)0x0000001A) +#define TPM_ORD_CMK_CreateBlob ((UINT32)0x0000001B) +#define TPM_ORD_CMK_SetRestrictions ((UINT32)0x0000001C) +#define TPM_ORD_CMK_ApproveMA ((UINT32)0x0000001D) +#define TPM_ORD_UnBind ((UINT32)0x0000001E) +#define TPM_ORD_CreateWrapKey ((UINT32)0x0000001F) +#define TPM_ORD_LoadKey ((UINT32)0x00000020) +#define TPM_ORD_GetPubKey ((UINT32)0x00000021) +#define TPM_ORD_EvictKey ((UINT32)0x00000022) +#define TPM_ORD_KeyControlOwner ((UINT32)0x00000023) +#define TPM_ORD_CMK_ConvertMigration ((UINT32)0x00000024) +#define TPM_ORD_MigrateKey ((UINT32)0x00000025) +#define TPM_ORD_CreateMigrationBlob ((UINT32)0x00000028) +#define TPM_ORD_DAA_Join ((UINT32)0x00000029) +#define TPM_ORD_ConvertMigrationBlob ((UINT32)0x0000002A) +#define TPM_ORD_AuthorizeMigrationKey ((UINT32)0x0000002B) +#define TPM_ORD_CreateMaintenanceArchive ((UINT32)0x0000002C) +#define TPM_ORD_LoadMaintenanceArchive ((UINT32)0x0000002D) +#define TPM_ORD_KillMaintenanceFeature ((UINT32)0x0000002E) +#define TPM_ORD_LoadManuMaintPub ((UINT32)0x0000002F) +#define TPM_ORD_ReadManuMaintPub ((UINT32)0x00000030) +#define TPM_ORD_DAA_Sign ((UINT32)0x00000031) +#define TPM_ORD_CertifyKey ((UINT32)0x00000032) +#define TPM_ORD_CertifyKey2 ((UINT32)0x00000033) +#define TPM_ORD_Sign ((UINT32)0x0000003C) +#define TPM_ORD_Sealx ((UINT32)0x0000003D) +#define TPM_ORD_Quote2 ((UINT32)0x0000003E) +#define TPM_ORD_SetCapability ((UINT32)0x0000003F) +#define TPM_ORD_ResetLockValue ((UINT32)0x00000040) +#define TPM_ORD_LoadKey2 ((UINT32)0x00000041) +#define TPM_ORD_GetRandom ((UINT32)0x00000046) +#define TPM_ORD_StirRandom ((UINT32)0x00000047) +#define TPM_ORD_SelfTestFull ((UINT32)0x00000050) +#define TPM_ORD_CertifySelfTest ((UINT32)0x00000052) +#define TPM_ORD_ContinueSelfTest ((UINT32)0x00000053) +#define TPM_ORD_GetTestResult ((UINT32)0x00000054) +#define TPM_ORD_Reset ((UINT32)0x0000005A) +#define TPM_ORD_OwnerClear ((UINT32)0x0000005B) +#define TPM_ORD_DisableOwnerClear ((UINT32)0x0000005C) +#define TPM_ORD_ForceClear ((UINT32)0x0000005D) +#define TPM_ORD_DisableForceClear ((UINT32)0x0000005E) +#define TPM_ORD_GetCapabilitySigned ((UINT32)0x00000064) +#define TPM_ORD_GetCapability ((UINT32)0x00000065) +#define TPM_ORD_GetCapabilityOwner ((UINT32)0x00000066) +#define TPM_ORD_OwnerSetDisable ((UINT32)0x0000006E) +#define TPM_ORD_PhysicalEnable ((UINT32)0x0000006F) +#define TPM_ORD_PhysicalDisable ((UINT32)0x00000070) +#define TPM_ORD_SetOwnerInstall ((UINT32)0x00000071) +#define TPM_ORD_PhysicalSetDeactivated ((UINT32)0x00000072) +#define TPM_ORD_SetTempDeactivated ((UINT32)0x00000073) +#define TPM_ORD_SetOperatorAuth ((UINT32)0x00000074) +#define TPM_ORD_SetOwnerPointer ((UINT32)0x00000075) +#define TPM_ORD_CreateEndorsementKeyPair ((UINT32)0x00000078) +#define TPM_ORD_MakeIdentity ((UINT32)0x00000079) +#define TPM_ORD_ActivateIdentity ((UINT32)0x0000007A) +#define TPM_ORD_ReadPubek ((UINT32)0x0000007C) +#define TPM_ORD_OwnerReadPubek ((UINT32)0x0000007D) +#define TPM_ORD_DisablePubekRead ((UINT32)0x0000007E) +#define TPM_ORD_CreateRevocableEK ((UINT32)0x0000007F) +#define TPM_ORD_RevokeTrust ((UINT32)0x00000080) +#define TPM_ORD_OwnerReadInternalPub ((UINT32)0x00000081) +#define TPM_ORD_GetAuditEvent ((UINT32)0x00000082) +#define TPM_ORD_GetAuditEventSigned ((UINT32)0x00000083) +#define TPM_ORD_GetAuditDigest ((UINT32)0x00000085) +#define TPM_ORD_GetAuditDigestSigned ((UINT32)0x00000086) +#define TPM_ORD_GetOrdinalAuditStatus ((UINT32)0x0000008C) +#define TPM_ORD_SetOrdinalAuditStatus ((UINT32)0x0000008D) +#define TPM_ORD_Terminate_Handle ((UINT32)0x00000096) +#define TPM_ORD_Init ((UINT32)0x00000097) +#define TPM_ORD_SaveState ((UINT32)0x00000098) +#define TPM_ORD_Startup ((UINT32)0x00000099) +#define TPM_ORD_SetRedirection ((UINT32)0x0000009A) +#define TPM_ORD_SHA1Start ((UINT32)0x000000A0) +#define TPM_ORD_SHA1Update ((UINT32)0x000000A1) +#define TPM_ORD_SHA1Complete ((UINT32)0x000000A2) +#define TPM_ORD_SHA1CompleteExtend ((UINT32)0x000000A3) +#define TPM_ORD_FieldUpgrade ((UINT32)0x000000AA) +#define TPM_ORD_SaveKeyContext ((UINT32)0x000000B4) +#define TPM_ORD_LoadKeyContext ((UINT32)0x000000B5) +#define TPM_ORD_SaveAuthContext ((UINT32)0x000000B6) +#define TPM_ORD_LoadAuthContext ((UINT32)0x000000B7) +#define TPM_ORD_SaveContext ((UINT32)0x000000B8) +#define TPM_ORD_LoadContext ((UINT32)0x000000B9) +#define TPM_ORD_FlushSpecific ((UINT32)0x000000BA) +#define TPM_ORD_PCR_Reset ((UINT32)0x000000C8) +#define TPM_ORD_NV_DefineSpace ((UINT32)0x000000CC) +#define TPM_ORD_NV_WriteValue ((UINT32)0x000000CD) +#define TPM_ORD_NV_WriteValueAuth ((UINT32)0x000000CE) +#define TPM_ORD_NV_ReadValue ((UINT32)0x000000CF) +#define TPM_ORD_NV_ReadValueAuth ((UINT32)0x000000D0) +#define TPM_ORD_Delegate_UpdateVerification ((UINT32)0x000000D1) +#define TPM_ORD_Delegate_Manage ((UINT32)0x000000D2) +#define TPM_ORD_Delegate_CreateKeyDelegation ((UINT32)0x000000D4) +#define TPM_ORD_Delegate_CreateOwnerDelegation ((UINT32)0x000000D5) +#define TPM_ORD_Delegate_VerifyDelegation ((UINT32)0x000000D6) +#define TPM_ORD_Delegate_LoadOwnerDelegation ((UINT32)0x000000D8) +#define TPM_ORD_Delegate_ReadTable ((UINT32)0x000000DB) +#define TPM_ORD_CreateCounter ((UINT32)0x000000DC) +#define TPM_ORD_IncrementCounter ((UINT32)0x000000DD) +#define TPM_ORD_ReadCounter ((UINT32)0x000000DE) +#define TPM_ORD_ReleaseCounter ((UINT32)0x000000DF) +#define TPM_ORD_ReleaseCounterOwner ((UINT32)0x000000E0) +#define TPM_ORD_EstablishTransport ((UINT32)0x000000E6) +#define TPM_ORD_ExecuteTransport ((UINT32)0x000000E7) +#define TPM_ORD_ReleaseTransportSigned ((UINT32)0x000000E8) +#define TPM_ORD_GetTicks ((UINT32)0x000000F1) +#define TPM_ORD_TickStampBlob ((UINT32)0x000000F2) + +#define TSC_ORD_PhysicalPresence ((UINT32)0x4000000A) +#define TSC_ORD_ResetEstablishmentBit ((UINT32)0x4000000B) + +#endif // __TPM_ORDINAL_H__ diff --git a/illumos-x86_64/usr/include/tss/tspi.h b/illumos-x86_64/usr/include/tss/tspi.h new file mode 100644 index 00000000..b5882e99 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tspi.h @@ -0,0 +1,1198 @@ +#if !defined(_TSPI_H_) +#define _TSPI_H_ + +#include +#include +#include +#include +#include + +#if !defined( TSPICALL ) + #if !defined(WIN32) || defined (TSP_STATIC) + // Linux, or a Win32 static library + #define TSPICALL extern TSS_RESULT + #elif defined (TSPDLL_EXPORTS) + // Win32 DLL build + #define TSPICALL extern __declspec(dllexport) TSS_RESULT + #else + // Win32 DLL import + #define TSPICALL extern __declspec(dllimport) TSS_RESULT + #endif +#endif /* TSPICALL */ + +#if defined ( __cplusplus ) +extern "C" { +#endif /* __cplusplus */ + + +// Class-independent ASN.1 conversion functions +TSPICALL Tspi_EncodeDER_TssBlob +( + UINT32 rawBlobSize, // in + BYTE* rawBlob, // in + UINT32 blobType, // in + UINT32* derBlobSize, // in, out + BYTE* derBlob // out +); + +TSPICALL Tspi_DecodeBER_TssBlob +( + UINT32 berBlobSize, // in + BYTE* berBlob, // in + UINT32* blobType, // out + UINT32* rawBlobSize, // in, out + BYTE* rawBlob // out +); + + + +// Common Methods +TSPICALL Tspi_SetAttribUint32 +( + TSS_HOBJECT hObject, // in + TSS_FLAG attribFlag, // in + TSS_FLAG subFlag, // in + UINT32 ulAttrib // in +); + +TSPICALL Tspi_GetAttribUint32 +( + TSS_HOBJECT hObject, // in + TSS_FLAG attribFlag, // in + TSS_FLAG subFlag, // in + UINT32* pulAttrib // out +); + +TSPICALL Tspi_SetAttribData +( + TSS_HOBJECT hObject, // in + TSS_FLAG attribFlag, // in + TSS_FLAG subFlag, // in + UINT32 ulAttribDataSize, // in + BYTE* rgbAttribData // in +); + +TSPICALL Tspi_GetAttribData +( + TSS_HOBJECT hObject, // in + TSS_FLAG attribFlag, // in + TSS_FLAG subFlag, // in + UINT32* pulAttribDataSize, // out + BYTE** prgbAttribData // out +); + +TSPICALL Tspi_ChangeAuth +( + TSS_HOBJECT hObjectToChange, // in + TSS_HOBJECT hParentObject, // in + TSS_HPOLICY hNewPolicy // in +); + +TSPICALL Tspi_ChangeAuthAsym +( + TSS_HOBJECT hObjectToChange, // in + TSS_HOBJECT hParentObject, // in + TSS_HKEY hIdentKey, // in + TSS_HPOLICY hNewPolicy // in +); + +TSPICALL Tspi_GetPolicyObject +( + TSS_HOBJECT hObject, // in + TSS_FLAG policyType, // in + TSS_HPOLICY* phPolicy // out +); + + + +// Tspi_Context Class Definitions +TSPICALL Tspi_Context_Create +( + TSS_HCONTEXT* phContext // out +); + +TSPICALL Tspi_Context_Close +( + TSS_HCONTEXT hContext // in +); + +TSPICALL Tspi_Context_Connect +( + TSS_HCONTEXT hContext, // in + TSS_UNICODE* wszDestination // in +); + +TSPICALL Tspi_Context_FreeMemory +( + TSS_HCONTEXT hContext, // in + BYTE* rgbMemory // in +); + +TSPICALL Tspi_Context_GetDefaultPolicy +( + TSS_HCONTEXT hContext, // in + TSS_HPOLICY* phPolicy // out +); + +TSPICALL Tspi_Context_CreateObject +( + TSS_HCONTEXT hContext, // in + TSS_FLAG objectType, // in + TSS_FLAG initFlags, // in + TSS_HOBJECT* phObject // out +); + +TSPICALL Tspi_Context_CloseObject +( + TSS_HCONTEXT hContext, // in + TSS_HOBJECT hObject // in +); + +TSPICALL Tspi_Context_GetCapability +( + TSS_HCONTEXT hContext, // in + TSS_FLAG capArea, // in + UINT32 ulSubCapLength, // in + BYTE* rgbSubCap, // in + UINT32* pulRespDataLength, // out + BYTE** prgbRespData // out +); + +TSPICALL Tspi_Context_GetTpmObject +( + TSS_HCONTEXT hContext, // in + TSS_HTPM* phTPM // out +); + +TSPICALL Tspi_Context_SetTransEncryptionKey +( + TSS_HCONTEXT hContext, // in + TSS_HKEY hKey // in +); + +TSPICALL Tspi_Context_CloseSignTransport +( + TSS_HCONTEXT hContext, // in + TSS_HKEY hSigningKey, // in + TSS_VALIDATION* pValidationData // in, out +); + +TSPICALL Tspi_Context_LoadKeyByBlob +( + TSS_HCONTEXT hContext, // in + TSS_HKEY hUnwrappingKey, // in + UINT32 ulBlobLength, // in + BYTE* rgbBlobData, // in + TSS_HKEY* phKey // out +); + +TSPICALL Tspi_Context_LoadKeyByUUID +( + TSS_HCONTEXT hContext, // in + TSS_FLAG persistentStorageType, // in + TSS_UUID uuidData, // in + TSS_HKEY* phKey // out +); + +TSPICALL Tspi_Context_RegisterKey +( + TSS_HCONTEXT hContext, // in + TSS_HKEY hKey, // in + TSS_FLAG persistentStorageType, // in + TSS_UUID uuidKey, // in + TSS_FLAG persistentStorageTypeParent, // in + TSS_UUID uuidParentKey // in +); + +TSPICALL Tspi_Context_UnregisterKey +( + TSS_HCONTEXT hContext, // in + TSS_FLAG persistentStorageType, // in + TSS_UUID uuidKey, // in + TSS_HKEY* phkey // out +); + +TSPICALL Tspi_Context_GetKeyByUUID +( + TSS_HCONTEXT hContext, // in + TSS_FLAG persistentStorageType, // in + TSS_UUID uuidData, // in + TSS_HKEY* phKey // out +); + +TSPICALL Tspi_Context_GetKeyByPublicInfo +( + TSS_HCONTEXT hContext, // in + TSS_FLAG persistentStorageType, // in + TSS_ALGORITHM_ID algID, // in + UINT32 ulPublicInfoLength, // in + BYTE* rgbPublicInfo, // in + TSS_HKEY* phKey // out +); + +TSPICALL Tspi_Context_GetRegisteredKeysByUUID +( + TSS_HCONTEXT hContext, // in + TSS_FLAG persistentStorageType, // in + TSS_UUID* pUuidData, // in + UINT32* pulKeyHierarchySize, // out + TSS_KM_KEYINFO** ppKeyHierarchy // out +); + +TSPICALL Tspi_Context_GetRegisteredKeysByUUID2 +( + TSS_HCONTEXT hContext, // in + TSS_FLAG persistentStorageType, // in + TSS_UUID* pUuidData, // in + UINT32* pulKeyHierarchySize, // out + TSS_KM_KEYINFO2** ppKeyHierarchy // out +); + + +// Policy class definitions +TSPICALL Tspi_Policy_SetSecret +( + TSS_HPOLICY hPolicy, // in + TSS_FLAG secretMode, // in + UINT32 ulSecretLength, // in + BYTE* rgbSecret // in +); + +TSPICALL Tspi_Policy_FlushSecret +( + TSS_HPOLICY hPolicy // in +); + +TSPICALL Tspi_Policy_AssignToObject +( + TSS_HPOLICY hPolicy, // in + TSS_HOBJECT hObject // in +); + + + +// TPM Class Definitions +TSPICALL Tspi_TPM_KeyControlOwner +( + TSS_HTPM hTPM, // in + TSS_HKEY hKey, // in + UINT32 attribName, // in + TSS_BOOL attribValue, // in + TSS_UUID* pUuidData // out +); + +TSPICALL Tspi_TPM_CreateEndorsementKey +( + TSS_HTPM hTPM, // in + TSS_HKEY hKey, // in + TSS_VALIDATION* pValidationData // in, out +); + +TSPICALL Tspi_TPM_CreateRevocableEndorsementKey +( + TSS_HTPM hTPM, // in + TSS_HKEY hKey, // in + TSS_VALIDATION* pValidationData, // in, out + UINT32* pulEkResetDataLength, // in, out + BYTE** rgbEkResetData // in, out +); + +TSPICALL Tspi_TPM_RevokeEndorsementKey +( + TSS_HTPM hTPM, // in + UINT32 ulEkResetDataLength, // in + BYTE* rgbEkResetData // in +); + +TSPICALL Tspi_TPM_GetPubEndorsementKey +( + TSS_HTPM hTPM, // in + TSS_BOOL fOwnerAuthorized, // in + TSS_VALIDATION* pValidationData, // in, out + TSS_HKEY* phEndorsementPubKey // out +); + +TSPICALL Tspi_TPM_OwnerGetSRKPubKey +( + TSS_HTPM hTPM, // in + UINT32* pulPubKeyLength, // out + BYTE** prgbPubKey // out +); + +TSPICALL Tspi_TPM_TakeOwnership +( + TSS_HTPM hTPM, // in + TSS_HKEY hKeySRK, // in + TSS_HKEY hEndorsementPubKey // in +); + +TSPICALL Tspi_TPM_ClearOwner +( + TSS_HTPM hTPM, // in + TSS_BOOL fForcedClear // in +); + +TSPICALL Tspi_TPM_CollateIdentityRequest +( + TSS_HTPM hTPM, // in + TSS_HKEY hKeySRK, // in + TSS_HKEY hCAPubKey, // in + UINT32 ulIdentityLabelLength, // in + BYTE* rgbIdentityLabelData, // in + TSS_HKEY hIdentityKey, // in + TSS_ALGORITHM_ID algID, // in + UINT32* pulTCPAIdentityReqLength, // out + BYTE** prgbTCPAIdentityReq // out +); + +TSPICALL Tspi_TPM_ActivateIdentity +( + TSS_HTPM hTPM, // in + TSS_HKEY hIdentKey, // in + UINT32 ulAsymCAContentsBlobLength, // in + BYTE* rgbAsymCAContentsBlob, // in + UINT32 ulSymCAAttestationBlobLength, // in + BYTE* rgbSymCAAttestationBlob, // in + UINT32* pulCredentialLength, // out + BYTE** prgbCredential // out +); + +TSPICALL Tspi_TPM_CreateMaintenanceArchive +( + TSS_HTPM hTPM, // in + TSS_BOOL fGenerateRndNumber, // in + UINT32* pulRndNumberLength, // out + BYTE** prgbRndNumber, // out + UINT32* pulArchiveDataLength, // out + BYTE** prgbArchiveData // out +); + +TSPICALL Tspi_TPM_KillMaintenanceFeature +( + TSS_HTPM hTPM // in +); + +TSPICALL Tspi_TPM_LoadMaintenancePubKey +( + TSS_HTPM hTPM, // in + TSS_HKEY hMaintenanceKey, // in + TSS_VALIDATION* pValidationData // in, out +); + +TSPICALL Tspi_TPM_CheckMaintenancePubKey +( + TSS_HTPM hTPM, // in + TSS_HKEY hMaintenanceKey, // in + TSS_VALIDATION* pValidationData // in, out +); + +TSPICALL Tspi_TPM_SetOperatorAuth +( + TSS_HTPM hTPM, // in + TSS_HPOLICY hOperatorPolicy // in +); + +TSPICALL Tspi_TPM_SetStatus +( + TSS_HTPM hTPM, // in + TSS_FLAG statusFlag, // in + TSS_BOOL fTpmState // in +); + +TSPICALL Tspi_TPM_GetStatus +( + TSS_HTPM hTPM, // in + TSS_FLAG statusFlag, // in + TSS_BOOL* pfTpmState // out +); + +TSPICALL Tspi_TPM_GetCapability +( + TSS_HTPM hTPM, // in + TSS_FLAG capArea, // in + UINT32 ulSubCapLength, // in + BYTE* rgbSubCap, // in + UINT32* pulRespDataLength, // out + BYTE** prgbRespData // out +); + +TSPICALL Tspi_TPM_GetCapabilitySigned +( + TSS_HTPM hTPM, // in + TSS_HKEY hKey, // in + TSS_FLAG capArea, // in + UINT32 ulSubCapLength, // in + BYTE* rgbSubCap, // in + TSS_VALIDATION* pValidationData, // in, out + UINT32* pulRespDataLength, // out + BYTE** prgbRespData // out +); + +TSPICALL Tspi_TPM_SelfTestFull +( + TSS_HTPM hTPM // in +); + +TSPICALL Tspi_TPM_CertifySelfTest +( + TSS_HTPM hTPM, // in + TSS_HKEY hKey, // in + TSS_VALIDATION* pValidationData // in, out +); + +TSPICALL Tspi_TPM_GetTestResult +( + TSS_HTPM hTPM, // in + UINT32* pulTestResultLength, // out + BYTE** prgbTestResult // out +); + +TSPICALL Tspi_TPM_GetRandom +( + TSS_HTPM hTPM, // in + UINT32 ulRandomDataLength, // in + BYTE** prgbRandomData // out +); + +TSPICALL Tspi_TPM_StirRandom +( + TSS_HTPM hTPM, // in + UINT32 ulEntropyDataLength, // in + BYTE* rgbEntropyData // in +); + +TSPICALL Tspi_TPM_GetEvent +( + TSS_HTPM hTPM, // in + UINT32 ulPcrIndex, // in + UINT32 ulEventNumber, // in + TSS_PCR_EVENT* pPcrEvent // out +); + +TSPICALL Tspi_TPM_GetEvents +( + TSS_HTPM hTPM, // in + UINT32 ulPcrIndex, // in + UINT32 ulStartNumber, // in + UINT32* pulEventNumber, // in, out + TSS_PCR_EVENT** prgPcrEvents // out +); + +TSPICALL Tspi_TPM_GetEventLog +( + TSS_HTPM hTPM, // in + UINT32* pulEventNumber, // out + TSS_PCR_EVENT** prgPcrEvents // out +); + +TSPICALL Tspi_TPM_Quote +( + TSS_HTPM hTPM, // in + TSS_HKEY hIdentKey, // in + TSS_HPCRS hPcrComposite, // in + TSS_VALIDATION* pValidationData // in, out +); + +TSPICALL Tspi_TPM_Quote2 +( + TSS_HTPM hTPM, // in + TSS_HKEY hIdentKey, // in + TSS_BOOL fAddVersion, // in + TSS_HPCRS hPcrComposite, // in + TSS_VALIDATION* pValidationData, // in, out + UINT32* versionInfoSize, // out + BYTE** versionInfo // out +); + +TSPICALL Tspi_TPM_PcrExtend +( + TSS_HTPM hTPM, // in + UINT32 ulPcrIndex, // in + UINT32 ulPcrDataLength, // in + BYTE* pbPcrData, // in + TSS_PCR_EVENT* pPcrEvent, // in + UINT32* pulPcrValueLength, // out + BYTE** prgbPcrValue // out +); + +TSPICALL Tspi_TPM_PcrRead +( + TSS_HTPM hTPM, // in + UINT32 ulPcrIndex, // in + UINT32* pulPcrValueLength, // out + BYTE** prgbPcrValue // out +); + +TSPICALL Tspi_TPM_PcrReset +( + TSS_HTPM hTPM, // in + TSS_HPCRS hPcrComposite // in +); + +TSPICALL Tspi_TPM_AuthorizeMigrationTicket +( + TSS_HTPM hTPM, // in + TSS_HKEY hMigrationKey, // in + TSS_MIGRATE_SCHEME migrationScheme, // in + UINT32* pulMigTicketLength, // out + BYTE** prgbMigTicket // out +); + +TSPICALL Tspi_TPM_CMKSetRestrictions +( + TSS_HTPM hTPM, // in + TSS_CMK_DELEGATE CmkDelegate // in +); + +TSPICALL Tspi_TPM_CMKApproveMA +( + TSS_HTPM hTPM, // in + TSS_HMIGDATA hMaAuthData // in +); + +TSPICALL Tspi_TPM_CMKCreateTicket +( + TSS_HTPM hTPM, // in + TSS_HKEY hVerifyKey, // in + TSS_HMIGDATA hSigData // in +); + +TSPICALL Tspi_TPM_ReadCounter +( + TSS_HTPM hTPM, // in + UINT32* counterValue // out +); + +TSPICALL Tspi_TPM_ReadCurrentTicks +( + TSS_HTPM hTPM, // in + TPM_CURRENT_TICKS* tickCount // out +); + +TSPICALL Tspi_TPM_DirWrite +( + TSS_HTPM hTPM, // in + UINT32 ulDirIndex, // in + UINT32 ulDirDataLength, // in + BYTE* rgbDirData // in +); + +TSPICALL Tspi_TPM_DirRead +( + TSS_HTPM hTPM, // in + UINT32 ulDirIndex, // in + UINT32* pulDirDataLength, // out + BYTE** prgbDirData // out +); + +TSPICALL Tspi_TPM_Delegate_AddFamily +( + TSS_HTPM hTPM, // in, must not be NULL + BYTE bLabel, // in + TSS_HDELFAMILY* phFamily // out +); + +TSPICALL Tspi_TPM_Delegate_GetFamily +( + TSS_HTPM hTPM, // in, must not NULL + UINT32 ulFamilyID, // in + TSS_HDELFAMILY* phFamily // out +); + +TSPICALL Tspi_TPM_Delegate_InvalidateFamily +( + TSS_HTPM hTPM, // in, must not be NULL + TSS_HDELFAMILY hFamily // in +); + +TSPICALL Tspi_TPM_Delegate_CreateDelegation +( + TSS_HOBJECT hObject, // in + BYTE bLabel, // in + UINT32 ulFlags, // in + TSS_HPCRS hPcr, // in, may be NULL + TSS_HDELFAMILY hFamily, // in + TSS_HPOLICY hDelegation // in, out +); + +TSPICALL Tspi_TPM_Delegate_CacheOwnerDelegation +( + TSS_HTPM hTPM, // in, must not be NULL + TSS_HPOLICY hDelegation, // in, out + UINT32 ulIndex, // in + UINT32 ulFlags // in +); + +TSPICALL Tspi_TPM_Delegate_UpdateVerificationCount +( + TSS_HTPM hTPM, // in + TSS_HPOLICY hDelegation // in, out +); + +TSPICALL Tspi_TPM_Delegate_VerifyDelegation +( + TSS_HPOLICY hDelegation // in, out +); + +TSPICALL Tspi_TPM_Delegate_ReadTables +( + TSS_HCONTEXT hContext, // in + UINT32* pulFamilyTableSize, // out + TSS_FAMILY_TABLE_ENTRY** ppFamilyTable, // out + UINT32* pulDelegateTableSize, // out + TSS_DELEGATION_TABLE_ENTRY** ppDelegateTable // out +); + +TSPICALL Tspi_TPM_DAA_JoinInit +( + TSS_HTPM hTPM, // in + TSS_HDAA_ISSUER_KEY hIssuerKey, // in + UINT32 daaCounter, // in + UINT32 issuerAuthPKsLength, // in + TSS_HKEY* issuerAuthPKs, // in + UINT32 issuerAuthPKSignaturesLength, // in + UINT32 issuerAuthPKSignaturesLength2, // in + BYTE** issuerAuthPKSignatures, // in + UINT32* capitalUprimeLength, // out + BYTE** capitalUprime, // out + TSS_DAA_IDENTITY_PROOF** identityProof, // out + UINT32* joinSessionLength, // out + BYTE** joinSession // out +); + +TSPICALL Tspi_TPM_DAA_JoinCreateDaaPubKey +( + TSS_HTPM hTPM, // in + TSS_HDAA_CREDENTIAL hDAACredential, // in + UINT32 authenticationChallengeLength, // in + BYTE* authenticationChallenge, // in + UINT32 nonceIssuerLength, // in + BYTE* nonceIssuer, // in + UINT32 attributesPlatformLength, // in + UINT32 attributesPlatformLength2, // in + BYTE** attributesPlatform, // in + UINT32 joinSessionLength, // in + BYTE* joinSession, // in + TSS_DAA_CREDENTIAL_REQUEST** credentialRequest // out +); + +TSPICALL Tspi_TPM_DAA_JoinStoreCredential +( + TSS_HTPM hTPM, // in + TSS_HDAA_CREDENTIAL hDAACredential, // in + TSS_DAA_CRED_ISSUER* credIssuer, // in + UINT32 joinSessionLength, // in + BYTE* joinSession // in +); + +TSPICALL Tspi_TPM_DAA_Sign +( + TSS_HTPM hTPM, // in + TSS_HDAA_CREDENTIAL hDAACredential, // in + TSS_HDAA_ARA_KEY hARAKey, // in + TSS_DAA_SELECTED_ATTRIB* revealAttributes, // in + UINT32 verifierNonceLength, // in + BYTE* verifierNonce, // in + UINT32 verifierBaseNameLength, // in + BYTE* verifierBaseName, // in + TSS_HOBJECT signData, // in + TSS_DAA_SIGNATURE** daaSignature // out +); + +TSPICALL Tspi_TPM_GetAuditDigest +( + TSS_HTPM hTPM, // in + TSS_HKEY hKey, // in + TSS_BOOL closeAudit, // in + UINT32* pulAuditDigestSize, // out + BYTE** prgbAuditDigest, // out + TPM_COUNTER_VALUE* pCounterValue, // out + TSS_VALIDATION* pValidationData, // out + UINT32* ordSize, // out + UINT32** ordList // out +); + + + +// PcrComposite Class Definitions +TSPICALL Tspi_PcrComposite_SelectPcrIndex +( + TSS_HPCRS hPcrComposite, // in + UINT32 ulPcrIndex // in +); + +TSPICALL Tspi_PcrComposite_SelectPcrIndexEx +( + TSS_HPCRS hPcrComposite, // in + UINT32 ulPcrIndex, // in + UINT32 direction // in +); + +TSPICALL Tspi_PcrComposite_SetPcrValue +( + TSS_HPCRS hPcrComposite, // in + UINT32 ulPcrIndex, // in + UINT32 ulPcrValueLength, // in + BYTE* rgbPcrValue // in +); + +TSPICALL Tspi_PcrComposite_GetPcrValue +( + TSS_HPCRS hPcrComposite, // in + UINT32 ulPcrIndex, // in + UINT32* pulPcrValueLength, // out + BYTE** prgbPcrValue // out +); + +TSPICALL Tspi_PcrComposite_SetPcrLocality +( + TSS_HPCRS hPcrComposite, // in + UINT32 LocalityValue // in +); + +TSPICALL Tspi_PcrComposite_GetPcrLocality +( + TSS_HPCRS hPcrComposite, // in + UINT32* pLocalityValue // out +); + +TSPICALL Tspi_PcrComposite_GetCompositeHash +( + TSS_HPCRS hPcrComposite, // in + UINT32* pLen, // in + BYTE** ppbHashData // out +); + + + +// Key Class Definition +TSPICALL Tspi_Key_LoadKey +( + TSS_HKEY hKey, // in + TSS_HKEY hUnwrappingKey // in +); + +TSPICALL Tspi_Key_UnloadKey +( + TSS_HKEY hKey // in +); + +TSPICALL Tspi_Key_GetPubKey +( + TSS_HKEY hKey, // in + UINT32* pulPubKeyLength, // out + BYTE** prgbPubKey // out +); + +TSPICALL Tspi_Key_CertifyKey +( + TSS_HKEY hKey, // in + TSS_HKEY hCertifyingKey, // in + TSS_VALIDATION* pValidationData // in, out +); + +TSPICALL Tspi_Key_CreateKey +( + TSS_HKEY hKey, // in + TSS_HKEY hWrappingKey, // in + TSS_HPCRS hPcrComposite // in, may be NULL +); + +TSPICALL Tspi_Key_WrapKey +( + TSS_HKEY hKey, // in + TSS_HKEY hWrappingKey, // in + TSS_HPCRS hPcrComposite // in, may be NULL +); + +TSPICALL Tspi_Key_CreateMigrationBlob +( + TSS_HKEY hKeyToMigrate, // in + TSS_HKEY hParentKey, // in + UINT32 ulMigTicketLength, // in + BYTE* rgbMigTicket, // in + UINT32* pulRandomLength, // out + BYTE** prgbRandom, // out + UINT32* pulMigrationBlobLength, // out + BYTE** prgbMigrationBlob // out +); + +TSPICALL Tspi_Key_ConvertMigrationBlob +( + TSS_HKEY hKeyToMigrate, // in + TSS_HKEY hParentKey, // in + UINT32 ulRandomLength, // in + BYTE* rgbRandom, // in + UINT32 ulMigrationBlobLength, // in + BYTE* rgbMigrationBlob // in +); + +TSPICALL Tspi_Key_MigrateKey +( + TSS_HKEY hMaKey, // in + TSS_HKEY hPublicKey, // in + TSS_HKEY hMigData // in +); + +TSPICALL Tspi_Key_CMKCreateBlob +( + TSS_HKEY hKeyToMigrate, // in + TSS_HKEY hParentKey, // in + TSS_HMIGDATA hMigrationData, // in + UINT32* pulRandomLength, // out + BYTE** prgbRandom // out +); + +TSPICALL Tspi_Key_CMKConvertMigration +( + TSS_HKEY hKeyToMigrate, // in + TSS_HKEY hParentKey, // in + TSS_HMIGDATA hMigrationData, // in + UINT32 ulRandomLength, // in + BYTE* rgbRandom // in +); + + + +// Hash Class Definition +TSPICALL Tspi_Hash_Sign +( + TSS_HHASH hHash, // in + TSS_HKEY hKey, // in + UINT32* pulSignatureLength, // out + BYTE** prgbSignature // out +); + +TSPICALL Tspi_Hash_VerifySignature +( + TSS_HHASH hHash, // in + TSS_HKEY hKey, // in + UINT32 ulSignatureLength, // in + BYTE* rgbSignature // in +); + +TSPICALL Tspi_Hash_SetHashValue +( + TSS_HHASH hHash, // in + UINT32 ulHashValueLength, // in + BYTE* rgbHashValue // in +); + +TSPICALL Tspi_Hash_GetHashValue +( + TSS_HHASH hHash, // in + UINT32* pulHashValueLength, // out + BYTE** prgbHashValue // out +); + +TSPICALL Tspi_Hash_UpdateHashValue +( + TSS_HHASH hHash, // in + UINT32 ulDataLength, // in + BYTE* rgbData // in +); + +TSPICALL Tspi_Hash_TickStampBlob +( + TSS_HHASH hHash, // in + TSS_HKEY hIdentKey, // in + TSS_VALIDATION* pValidationData // in +); + + + +// EncData Class Definition +TSPICALL Tspi_Data_Bind +( + TSS_HENCDATA hEncData, // in + TSS_HKEY hEncKey, // in + UINT32 ulDataLength, // in + BYTE* rgbDataToBind // in +); + +TSPICALL Tspi_Data_Unbind +( + TSS_HENCDATA hEncData, // in + TSS_HKEY hKey, // in + UINT32* pulUnboundDataLength, // out + BYTE** prgbUnboundData // out +); + +TSPICALL Tspi_Data_Seal +( + TSS_HENCDATA hEncData, // in + TSS_HKEY hEncKey, // in + UINT32 ulDataLength, // in + BYTE* rgbDataToSeal, // in + TSS_HPCRS hPcrComposite // in +); + +TSPICALL Tspi_Data_Unseal +( + TSS_HENCDATA hEncData, // in + TSS_HKEY hKey, // in + UINT32* pulUnsealedDataLength, // out + BYTE** prgbUnsealedData // out +); + + + +// NV Class Definition +TSPICALL Tspi_NV_DefineSpace +( + TSS_HNVSTORE hNVStore, // in + TSS_HPCRS hReadPcrComposite, // in, may be NULL + TSS_HPCRS hWritePcrComposite // in, may be NULL +); + +TSPICALL Tspi_NV_ReleaseSpace +( + TSS_HNVSTORE hNVStore // in +); + +TSPICALL Tspi_NV_WriteValue +( + TSS_HNVSTORE hNVStore, // in + UINT32 offset, // in + UINT32 ulDataLength, // in + BYTE* rgbDataToWrite // in +); + +TSPICALL Tspi_NV_ReadValue +( + TSS_HNVSTORE hNVStore, // in + UINT32 offset, // in + UINT32* ulDataLength, // in, out + BYTE** rgbDataRead // out +); + + +// DAA Utility functions (optional, do not require a TPM or TCS) +TSPICALL Tspi_DAA_IssuerKeyVerify +( + TSS_HDAA_CREDENTIAL hDAACredential, // in + TSS_HDAA_ISSUER_KEY hIssuerKey, // in + TSS_BOOL* isCorrect // out +); + +TSPICALL Tspi_DAA_Issuer_GenerateKey +( + TSS_HDAA_ISSUER_KEY hIssuerKey, // in + UINT32 issuerBaseNameLength, // in + BYTE* issuerBaseName // in +); + +TSPICALL Tspi_DAA_Issuer_InitCredential +( + TSS_HDAA_ISSUER_KEY hIssuerKey, // in + TSS_HKEY issuerAuthPK, // in + TSS_DAA_IDENTITY_PROOF* identityProof, // in + UINT32 capitalUprimeLength, // in + BYTE* capitalUprime, // in + UINT32 daaCounter, // in + UINT32* nonceIssuerLength, // out + BYTE** nonceIssuer, // out + UINT32* authenticationChallengeLength, // out + BYTE** authenticationChallenge, // out + UINT32* joinSessionLength, // out + BYTE** joinSession // out +); + +TSPICALL Tspi_DAA_Issuer_IssueCredential +( + TSS_HDAA_ISSUER_KEY hIssuerKey, // in + TSS_DAA_CREDENTIAL_REQUEST* credentialRequest, // in + UINT32 issuerJoinSessionLength, // in + BYTE* issuerJoinSession, // in + TSS_DAA_CRED_ISSUER** credIssuer // out +); + +TSPICALL Tspi_DAA_Verifier_Init +( + TSS_HDAA_CREDENTIAL hDAACredential, // in + UINT32* nonceVerifierLength, // out + BYTE** nonceVerifier, // out + UINT32* baseNameLength, // out + BYTE** baseName // out +); + +TSPICALL Tspi_DAA_VerifySignature +( + TSS_HDAA_CREDENTIAL hDAACredential, // in + TSS_HDAA_ISSUER_KEY hIssuerKey, // in + TSS_HDAA_ARA_KEY hARAKey, // in + TSS_HHASH hARACondition, // in + UINT32 attributesLength, // in + UINT32 attributesLength2, // in + BYTE** attributes, // in + UINT32 verifierNonceLength, // in + BYTE* verifierNonce, // in + UINT32 verifierBaseNameLength, // in + BYTE* verifierBaseName, // in + TSS_HOBJECT signData, // in + TSS_DAA_SIGNATURE* daaSignature, // in + TSS_BOOL* isCorrect // out +); + +TSPICALL Tspi_DAA_ARA_GenerateKey +( + TSS_HDAA_ISSUER_KEY hIssuerKey, // in + TSS_HDAA_ARA_KEY hARAKey // in +); + +TSPICALL Tspi_DAA_ARA_RevokeAnonymity +( + TSS_HDAA_ARA_KEY hARAKey, // in + TSS_HHASH hARACondition, // in + TSS_HDAA_ISSUER_KEY hIssuerKey, // in + TSS_DAA_PSEUDONYM_ENCRYPTED* encryptedPseudonym, // in + TSS_DAA_PSEUDONYM_PLAIN** pseudonym // out +); + + + +// Callback typedefs +typedef TSS_RESULT (*Tspicb_CallbackHMACAuth) +( + PVOID lpAppData, // in + TSS_HOBJECT hAuthorizedObject, // in + TSS_BOOL ReturnOrVerify, // in + UINT32 ulPendingFunction, // in + TSS_BOOL ContinueUse, // in + UINT32 ulSizeNonces, // in + BYTE* rgbNonceEven, // in + BYTE* rgbNonceOdd, // in + BYTE* rgbNonceEvenOSAP, // in + BYTE* rgbNonceOddOSAP, // in + UINT32 ulSizeDigestHmac, // in + BYTE* rgbParamDigest, // in + BYTE* rgbHmacData // in, out +); + +typedef TSS_RESULT (*Tspicb_CallbackXorEnc) +( + PVOID lpAppData, // in + TSS_HOBJECT hOSAPObject, // in + TSS_HOBJECT hObject, // in + TSS_FLAG PurposeSecret, // in + UINT32 ulSizeNonces, // in + BYTE* rgbNonceEven, // in + BYTE* rgbNonceOdd, // in + BYTE* rgbNonceEvenOSAP, // in + BYTE* rgbNonceOddOSAP, // in + UINT32 ulSizeEncAuth, // in + BYTE* rgbEncAuthUsage, // out + BYTE* rgbEncAuthMigration // out +); + +typedef TSS_RESULT (*Tspicb_CallbackTakeOwnership) +( + PVOID lpAppData, // in + TSS_HOBJECT hObject, // in + TSS_HKEY hObjectPubKey, // in + UINT32 ulSizeEncAuth, // in + BYTE* rgbEncAuth // out +); + +typedef TSS_RESULT (*Tspicb_CallbackSealxMask) +( + PVOID lpAppData, // in + TSS_HKEY hKey, // in + TSS_HENCDATA hEncData, // in + TSS_ALGORITHM_ID algID, // in + UINT32 ulSizeNonces, // in + BYTE* rgbNonceEven, // in + BYTE* rgbNonceOdd, // in + BYTE* rgbNonceEvenOSAP, // in + BYTE* rgbNonceOddOSAP, // in + UINT32 ulDataLength, // in + BYTE* rgbDataToMask, // in + BYTE* rgbMaskedData // out +); + +typedef TSS_RESULT (*Tspicb_CallbackChangeAuthAsym) +( + PVOID lpAppData, // in + TSS_HOBJECT hObject, // in + TSS_HKEY hObjectPubKey, // in + UINT32 ulSizeEncAuth, // in + UINT32 ulSizeAuthLink, // in + BYTE* rgbEncAuth, // out + BYTE* rgbAuthLink // out +); + +typedef TSS_RESULT (*Tspicb_CollateIdentity) +( + PVOID lpAppData, // in + UINT32 ulTCPAPlainIdentityProofLength, // in + BYTE* rgbTCPAPlainIdentityProof, // in + TSS_ALGORITHM_ID algID, // in + UINT32 ulSessionKeyLength, // out + BYTE* rgbSessionKey, // out + UINT32* pulTCPAIdentityProofLength, // out + BYTE* rgbTCPAIdentityProof // out +); + + +typedef TSS_RESULT (*Tspicb_ActivateIdentity) +( + PVOID lpAppData, // in + UINT32 ulSessionKeyLength, // in + BYTE* rgbSessionKey, // in + UINT32 ulSymCAAttestationBlobLength, // in + BYTE* rgbSymCAAttestationBlob, // in + UINT32* pulCredentialLength, // out + BYTE* rgbCredential // out +); + + +typedef TSS_RESULT (*Tspicb_DAA_Sign) +( + PVOID lpAppData, // in + TSS_HDAA_ISSUER_KEY daaPublicKey, // in + UINT32 gammasLength, // in + BYTE** gammas, // in + UINT32 attributesLength, // in + BYTE** attributes, // in + UINT32 randomAttributesLength, // in + BYTE** randomAttributes, // in + UINT32 attributeCommitmentsLength,// in + TSS_DAA_ATTRIB_COMMIT* attributeCommitments, // in + TSS_DAA_ATTRIB_COMMIT* attributeCommitmentsProof, // in + TSS_DAA_PSEUDONYM_PLAIN* pseudonym, // in + TSS_DAA_PSEUDONYM_PLAIN* pseudonymTilde, // in + TSS_DAA_PSEUDONYM_ENCRYPTED* pseudonymEncrypted, // in + TSS_DAA_PSEUDONYM_ENCRYPTED* pseudonymEncProof, // in + TSS_DAA_SIGN_CALLBACK** additionalProof // out +); + +typedef TSS_RESULT (*Tspicb_DAA_VerifySignature) +( + PVOID lpAppData, // in + UINT32 challengeLength, // in + BYTE* challenge, // in + TSS_DAA_SIGN_CALLBACK* additionalProof, // in + TSS_HDAA_ISSUER_KEY daaPublicKey, // in + UINT32 gammasLength, // in + BYTE** gammas, // in + UINT32 sAttributesLength, // in + BYTE** sAttributes, // in + UINT32 attributeCommitmentsLength,// in + TSS_DAA_ATTRIB_COMMIT* attributeCommitments, // in + TSS_DAA_ATTRIB_COMMIT* attributeCommitmentsProof, // in + UINT32 zetaLength, // in + BYTE* zeta, // in + UINT32 sFLength, // in + BYTE* sF, // in + TSS_DAA_PSEUDONYM* pseudonym, // in + TSS_DAA_PSEUDONYM* pseudonymProof, // in + TSS_BOOL* isCorrect // out +); + + +#if defined ( __cplusplus ) +} +#endif /* __cplusplus */ + + +#endif /* _TSPI_H_ */ diff --git a/illumos-x86_64/usr/include/tss/tss_defines.h b/illumos-x86_64/usr/include/tss/tss_defines.h new file mode 100644 index 00000000..b8fafc95 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tss_defines.h @@ -0,0 +1,1288 @@ +/*++ + +Global defines for TSS. + +--*/ + +#ifndef __TSS_DEFINES_H__ +#define __TSS_DEFINES_H__ + +#include +#include + + +////////////////////////////////////////////////////////////////////////// +// Object types: +////////////////////////////////////////////////////////////////////////// + +// +// definition of the object types that can be created via CreateObject +// +#define TSS_OBJECT_TYPE_POLICY (0x01) // Policy object +#define TSS_OBJECT_TYPE_RSAKEY (0x02) // RSA-Key object +#define TSS_OBJECT_TYPE_ENCDATA (0x03) // Encrypted data object +#define TSS_OBJECT_TYPE_PCRS (0x04) // PCR composite object +#define TSS_OBJECT_TYPE_HASH (0x05) // Hash object +#define TSS_OBJECT_TYPE_DELFAMILY (0x06) // Delegation Family object +#define TSS_OBJECT_TYPE_NV (0x07) // NV object +#define TSS_OBJECT_TYPE_MIGDATA (0x08) // CMK Migration data object +#define TSS_OBJECT_TYPE_DAA_CERTIFICATE (0x09) // DAA credential +#define TSS_OBJECT_TYPE_DAA_ISSUER_KEY (0x0a) // DAA cred. issuer keypair +#define TSS_OBJECT_TYPE_DAA_ARA_KEY (0x0b) // DAA anonymity revocation + // authority keypair + + +////////////////////////////////////////////////////////////////////////// +// CreateObject: Flags +////////////////////////////////////////////////////////////////////////// + + +//************************************ +// Flags for creating RSAKEY object: * +//************************************ + +// +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// |x x|Auth +// |x| Volatility +// |x| Migration +// |x x x x| Type +// |x x x x| Size +// |x x| CMK +// |x x x| Version +// |0 0 0 0 0 0 0 0 0| Reserved +// |x x x x x x| Fixed Type +// + +// Authorization: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// Never |0 0| +// Always |0 1| +// Private key always |1 0| +// +#define TSS_KEY_NO_AUTHORIZATION (0x00000000) // no auth needed + // for this key +#define TSS_KEY_AUTHORIZATION (0x00000001) // key needs auth + // for all ops +#define TSS_KEY_AUTHORIZATION_PRIV_USE_ONLY (0x00000002) // key needs auth + // for privkey ops, + // noauth for pubkey + +// +// Volatility +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// Non Volatile |0| +// Volatile |1| +// +#define TSS_KEY_NON_VOLATILE (0x00000000) // Key is non-volatile +#define TSS_KEY_VOLATILE (0x00000004) // Key is volatile + +// +// Migration +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// Non Migratable |0| +// Migratable |1| +// +#define TSS_KEY_NOT_MIGRATABLE (0x00000000) // key is not migratable +#define TSS_KEY_MIGRATABLE (0x00000008) // key is migratable + +// +// Usage +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// Default (Legacy) |0 0 0 0| +// Signing |0 0 0 1| +// Storage |0 0 1 0| +// Identity |0 0 1 1| +// AuthChange |0 1 0 0| +// Bind |0 1 0 1| +// Legacy |0 1 1 0| +// +#define TSS_KEY_TYPE_DEFAULT (0x00000000) // indicate a default key + // (Legacy-Key) +#define TSS_KEY_TYPE_SIGNING (0x00000010) // indicate a signing key +#define TSS_KEY_TYPE_STORAGE (0x00000020) // used as storage key +#define TSS_KEY_TYPE_IDENTITY (0x00000030) // indicate an idendity key +#define TSS_KEY_TYPE_AUTHCHANGE (0x00000040) // indicate an ephemeral key +#define TSS_KEY_TYPE_BIND (0x00000050) // indicate a key for TPM_Bind +#define TSS_KEY_TYPE_LEGACY (0x00000060) // indicate a key that can + // perform signing and binding +#define TSS_KEY_TYPE_MIGRATE (0x00000070) // indicate a key that can + // act as a CMK MA +#define TSS_KEY_TYPE_BITMASK (0x000000F0) // mask to extract key type + +// +// Key size +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// DEFAULT |0 0 0 0| +// 512 |0 0 0 1| +// 1024 |0 0 1 0| +// 2048 |0 0 1 1| +// 4096 |0 1 0 0| +// 8192 |0 1 0 1| +// 16384 |0 1 1 0| +// +#define TSS_KEY_SIZE_DEFAULT (UINT32)(0x00000000) // indicate tpm-specific size +#define TSS_KEY_SIZE_512 (UINT32)(0x00000100) // indicate a 512-bit key +#define TSS_KEY_SIZE_1024 (UINT32)(0x00000200) // indicate a 1024-bit key +#define TSS_KEY_SIZE_2048 (UINT32)(0x00000300) // indicate a 2048-bit key +#define TSS_KEY_SIZE_4096 (UINT32)(0x00000400) // indicate a 4096-bit key +#define TSS_KEY_SIZE_8192 (UINT32)(0x00000500) // indicate a 8192-bit key +#define TSS_KEY_SIZE_16384 (UINT32)(0x00000600) // indicate a 16384-bit key +#define TSS_KEY_SIZE_BITMASK (UINT32)(0x00000F00) // mask to extract key size + +// +// Certified Migratability +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// DEFAULT |0 0| +// Not Certified Migratable |0 0| +// Certified Migratable |0 1| +// +#define TSS_KEY_NOT_CERTIFIED_MIGRATABLE (UINT32)(0x00000000) +#define TSS_KEY_CERTIFIED_MIGRATABLE (UINT32)(0x00001000) + +// +// Specification version +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// Context default |0 0 0| +// TPM_KEY 1.1b key |0 0 1| +// TPM_KEY12 1.2 key |0 1 0| +// +#define TSS_KEY_STRUCT_DEFAULT (UINT32)(0x00000000) +#define TSS_KEY_STRUCT_KEY (UINT32)(0x00004000) +#define TSS_KEY_STRUCT_KEY12 (UINT32)(0x00008000) +#define TSS_KEY_STRUCT_BITMASK (UINT32)(0x0001C000) + + +// +// fixed KeyTypes (templates) +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// |0 0 0 0 0 0| Empty Key +// |0 0 0 0 0 1| Storage Root Key +// +#define TSS_KEY_EMPTY_KEY (0x00000000) // no TPM key template + // (empty TSP key object) +#define TSS_KEY_TSP_SRK (0x04000000) // use a TPM SRK template + // (TSP key object for SRK) +#define TSS_KEY_TEMPLATE_BITMASK (0xFC000000) // bitmask to extract key + // template + + +//************************************* +// Flags for creating ENCDATA object: * +//************************************* + +// +// Type +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// Seal |0 0 1| +// Bind |0 1 0| +// Legacy |0 1 1| +// +// ENCDATA Reserved: +// |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x| +// +#define TSS_ENCDATA_SEAL (0x00000001) // data for seal operation +#define TSS_ENCDATA_BIND (0x00000002) // data for bind operation +#define TSS_ENCDATA_LEGACY (0x00000003) // data for legacy bind operation + + +//********************************** +// Flags for creating HASH object: * +//********************************** + +// +// Algorithm +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// DEFAULT +// |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0| +// SHA1 +// |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1| +// OTHER +// |1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1| +// +#define TSS_HASH_DEFAULT (0x00000000) // Default hash algorithm +#define TSS_HASH_SHA1 (0x00000001) // SHA-1 with 20 bytes +#define TSS_HASH_OTHER (0xFFFFFFFF) // Not-specified hash algorithm + + +//************************************ +// Flags for creating POLICY object: * +//************************************ + +// +// Type +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// +// Usage |0 0 1| +// Migration |0 1 0| +// Operator |0 1 1| +// +// POLICY Reserved: +// |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x| + +#define TSS_POLICY_USAGE (0x00000001) // usage policy object +#define TSS_POLICY_MIGRATION (0x00000002) // migration policy object +#define TSS_POLICY_OPERATOR (0x00000003) // migration policy object + + +//****************************************** +// Flags for creating PCRComposite object: * +//****************************************** + +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// |x x| Struct +// |x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x| Reserved +// + +// PCRComposite Version: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// --------------------------------------------------------------- +// TPM_PCR_DEFAULT |0 0 0| +// TPM_PCR_INFO |0 0 1| +// TPM_PCR_INFO_LONG |0 1 0| +// TPM_PCR_INFO_SHORT |0 1 1| +// + +#define TSS_PCRS_STRUCT_DEFAULT (0x00000000) // depends on context +#define TSS_PCRS_STRUCT_INFO (0x00000001) // TPM_PCR_INFO +#define TSS_PCRS_STRUCT_INFO_LONG (0x00000002) // TPM_PCR_INFO_LONG +#define TSS_PCRS_STRUCT_INFO_SHORT (0x00000003) // TPM_PCR_INFO_SHORT + + + +////////////////////////////////////////////////////////////////////////// +// Attribute Flags, Subflags, and Values +////////////////////////////////////////////////////////////////////////// + + +//****************** +// Context object: * +//****************** + +// +// Attributes +// +#define TSS_TSPATTRIB_CONTEXT_SILENT_MODE (0x00000001) + // dialog display control +#define TSS_TSPATTRIB_CONTEXT_MACHINE_NAME (0x00000002) + // remote machine name +#define TSS_TSPATTRIB_CONTEXT_VERSION_MODE (0x00000003) + // context version +#define TSS_TSPATTRIB_CONTEXT_TRANSPORT (0x00000004) + // transport control +#define TSS_TSPATTRIB_CONTEXT_CONNECTION_VERSION (0x00000005) + // connection version +#define TSS_TSPATTRIB_SECRET_HASH_MODE (0x00000006) + // flag indicating whether + // NUL is included in the + // hash of the password +// +// SubFlags for Flag TSS_TSPATTRIB_CONTEXT_TRANSPORT +// +#define TSS_TSPATTRIB_CONTEXTTRANS_CONTROL (0x00000008) +#define TSS_TSPATTRIB_CONTEXTTRANS_MODE (0x00000010) + +// +// Values for the TSS_TSPATTRIB_CONTEXT_SILENT_MODE attribute +// +#define TSS_TSPATTRIB_CONTEXT_NOT_SILENT (0x00000000) // TSP dialogs enabled +#define TSS_TSPATTRIB_CONTEXT_SILENT (0x00000001) // TSP dialogs disabled + +// +// Values for the TSS_TSPATTRIB_CONTEXT_VERSION_MODE attribute +// +#define TSS_TSPATTRIB_CONTEXT_VERSION_AUTO (0x00000001) +#define TSS_TSPATTRIB_CONTEXT_VERSION_V1_1 (0x00000002) +#define TSS_TSPATTRIB_CONTEXT_VERSION_V1_2 (0x00000003) + +// +// Values for the subflag TSS_TSPATTRIB_CONTEXT_TRANS_CONTROL +// +#define TSS_TSPATTRIB_DISABLE_TRANSPORT (0x00000016) +#define TSS_TSPATTRIB_ENABLE_TRANSPORT (0x00000032) + +// +// Values for the subflag TSS_TSPATTRIB_CONTEXT_TRANS_MODE +// +#define TSS_TSPATTRIB_TRANSPORT_NO_DEFAULT_ENCRYPTION (0x00000000) +#define TSS_TSPATTRIB_TRANSPORT_DEFAULT_ENCRYPTION (0x00000001) +#define TSS_TSPATTRIB_TRANSPORT_AUTHENTIC_CHANNEL (0x00000002) +#define TSS_TSPATTRIB_TRANSPORT_EXCLUSIVE (0x00000004) +#define TSS_TSPATTRIB_TRANSPORT_STATIC_AUTH (0x00000008) + +// +// Values for the TSS_TSPATTRIB_CONTEXT_CONNECTION_VERSION attribute +// +#define TSS_CONNECTION_VERSION_1_1 (0x00000001) +#define TSS_CONNECTION_VERSION_1_2 (0x00000002) + + +// +// Subflags of TSS_TSPATTRIB_SECRET_HASH_MODE +// +#define TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP (0x00000001) + +// +// Values for TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP subflag +// +#define TSS_TSPATTRIB_HASH_MODE_NOT_NULL (0x00000000) +#define TSS_TSPATTRIB_HASH_MODE_NULL (0x00000001) + + +// ************* +// TPM object: * +// ************* + +// +// Attributes: +// +#define TSS_TSPATTRIB_TPM_CALLBACK_COLLATEIDENTITY 0x00000001 +#define TSS_TSPATTRIB_TPM_CALLBACK_ACTIVATEIDENTITY 0x00000002 +#define TSS_TSPATTRIB_TPM_ORDINAL_AUDIT_STATUS 0x00000003 +#define TSS_TSPATTRIB_TPM_CREDENTIAL 0x00001000 + +// +// Subflags for TSS_TSPATTRIB_TPM_ORDINAL_AUDIT_STATUS +// +#define TPM_CAP_PROP_TPM_CLEAR_ORDINAL_AUDIT 0x00000000 +#define TPM_CAP_PROP_TPM_SET_ORDINAL_AUDIT 0x00000001 + +// +// Subflags for TSS_TSPATTRIB_TPM_CREDENTIAL +// +#define TSS_TPMATTRIB_EKCERT 0x00000001 +#define TSS_TPMATTRIB_TPM_CC 0x00000002 +#define TSS_TPMATTRIB_PLATFORMCERT 0x00000003 +#define TSS_TPMATTRIB_PLATFORM_CC 0x00000004 + + +//***************** +// Policy object: * +//***************** + +// +// Attributes +// +#define TSS_TSPATTRIB_POLICY_CALLBACK_HMAC (0x00000080) + // enable/disable callback function + +#define TSS_TSPATTRIB_POLICY_CALLBACK_XOR_ENC (0x00000100) + // enable/disable callback function + +#define TSS_TSPATTRIB_POLICY_CALLBACK_TAKEOWNERSHIP (0x00000180) + // enable/disable callback function + +#define TSS_TSPATTRIB_POLICY_CALLBACK_CHANGEAUTHASYM (0x00000200) + // enable/disable callback function + +#define TSS_TSPATTRIB_POLICY_SECRET_LIFETIME (0x00000280) + // set lifetime mode for policy secret + +#define TSS_TSPATTRIB_POLICY_POPUPSTRING (0x00000300) + // set a NULL terminated UNICODE string + // which is displayed in the TSP policy + // popup dialog +#define TSS_TSPATTRIB_POLICY_CALLBACK_SEALX_MASK (0x00000380) + // enable/disable callback function +#if 0 +/* This attribute flag is defined earlier with the context attributes. + * It is valid for both context and policy objects. It is copied + * here as a reminder to avoid collisions. + */ +#define TSS_TSPATTRIB_SECRET_HASH_MODE (0x00000006) + // flag indicating whether + // NUL is included in the + // hash of the password +#endif + + +#define TSS_TSPATTRIB_POLICY_DELEGATION_INFO (0x00000001) +#define TSS_TSPATTRIB_POLICY_DELEGATION_PCR (0x00000002) + +// +// SubFlags for Flag TSS_TSPATTRIB_POLICY_SECRET_LIFETIME +// +#define TSS_SECRET_LIFETIME_ALWAYS (0x00000001) // secret will not be + // invalidated +#define TSS_SECRET_LIFETIME_COUNTER (0x00000002) // secret lifetime + // controlled by counter +#define TSS_SECRET_LIFETIME_TIMER (0x00000003) // secret lifetime + // controlled by time +#define TSS_TSPATTRIB_POLSECRET_LIFETIME_ALWAYS TSS_SECRET_LIFETIME_ALWAYS +#define TSS_TSPATTRIB_POLSECRET_LIFETIME_COUNTER TSS_SECRET_LIFETIME_COUNTER +#define TSS_TSPATTRIB_POLSECRET_LIFETIME_TIMER TSS_SECRET_LIFETIME_TIMER + +// Alternate names misspelled in the 1.1 TSS spec. +#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_ALWAYS TSS_SECRET_LIFETIME_ALWAYS +#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_COUNTER TSS_SECRET_LIFETIME_COUNTER +#define TSS_TSPATTRIB_POLICYSECRET_LIFETIME_TIMER TSS_SECRET_LIFETIME_TIMER + +// +// Subflags of TSS_TSPATTRIB_POLICY_DELEGATION_INFO +// +#define TSS_TSPATTRIB_POLDEL_TYPE (0x00000001) +#define TSS_TSPATTRIB_POLDEL_INDEX (0x00000002) +#define TSS_TSPATTRIB_POLDEL_PER1 (0x00000003) +#define TSS_TSPATTRIB_POLDEL_PER2 (0x00000004) +#define TSS_TSPATTRIB_POLDEL_LABEL (0x00000005) +#define TSS_TSPATTRIB_POLDEL_FAMILYID (0x00000006) +#define TSS_TSPATTRIB_POLDEL_VERCOUNT (0x00000007) +#define TSS_TSPATTRIB_POLDEL_OWNERBLOB (0x00000008) +#define TSS_TSPATTRIB_POLDEL_KEYBLOB (0x00000009) + +// +// Subflags of TSS_TSPATTRIB_POLICY_DELEGATION_PCR +// +#define TSS_TSPATTRIB_POLDELPCR_LOCALITY (0x00000001) +#define TSS_TSPATTRIB_POLDELPCR_DIGESTATRELEASE (0x00000002) +#define TSS_TSPATTRIB_POLDELPCR_SELECTION (0x00000003) + +// +// Values for the Policy TSS_TSPATTRIB_POLDEL_TYPE attribute +// +#define TSS_DELEGATIONTYPE_NONE (0x00000001) +#define TSS_DELEGATIONTYPE_OWNER (0x00000002) +#define TSS_DELEGATIONTYPE_KEY (0x00000003) + + + +// +// Flags used for the 'mode' parameter in Tspi_Policy_SetSecret() +// +#define TSS_SECRET_MODE_NONE (0x00000800) // No authorization will be + // processed +#define TSS_SECRET_MODE_SHA1 (0x00001000) // Secret string will not be + // touched by TSP +#define TSS_SECRET_MODE_PLAIN (0x00001800) // Secret string will be hashed + // using SHA1 +#define TSS_SECRET_MODE_POPUP (0x00002000) // TSS SP will ask for a secret +#define TSS_SECRET_MODE_CALLBACK (0x00002800) // Application has to provide a + // call back function + + + +//****************** +// EncData object: * +//****************** + +// +// Attributes +// +#define TSS_TSPATTRIB_ENCDATA_BLOB (0x00000008) +#define TSS_TSPATTRIB_ENCDATA_PCR (0x00000010) +#define TSS_TSPATTRIB_ENCDATA_PCR_LONG (0x00000018) +#define TSS_TSPATTRIB_ENCDATA_SEAL (0x00000020) + +// +// SubFlags for Flag TSS_TSPATTRIB_ENCDATA_BLOB +// +#define TSS_TSPATTRIB_ENCDATABLOB_BLOB (0x00000001) // encrypted data blob + +// +// SubFlags for Flag TSS_TSPATTRIB_ENCDATA_PCR +// +#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATCREATION (0x00000002) +#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE (0x00000003) +#define TSS_TSPATTRIB_ENCDATAPCR_SELECTION (0x00000004) +// support typo from 1.1 headers +#define TSS_TSPATTRIB_ENCDATAPCR_DIGEST_RELEASE \ + TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE + +#define TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATCREATION (0x00000005) +#define TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATRELEASE (0x00000006) +#define TSS_TSPATTRIB_ENCDATAPCRLONG_CREATION_SELECTION (0x00000007) +#define TSS_TSPATTRIB_ENCDATAPCRLONG_RELEASE_SELECTION (0x00000008) +#define TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATCREATION (0x00000009) +#define TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATRELEASE (0x0000000A) + + +// +// Attribute subflags TSS_TSPATTRIB_ENCDATA_SEAL +// +#define TSS_TSPATTRIB_ENCDATASEAL_PROTECT_MODE (0x00000001) + +// +// Attribute values for +// TSS_TSPATTRIB_ENCDATA_SEAL/TSS_TSPATTRIB_ENCDATASEAL_PROTECT_MODE +// +#define TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT (0x00000000) +#define TSS_TSPATTRIB_ENCDATASEAL_PROTECT (0x00000001) + +// Accounting for typos in original header files +#define TSS_TSPATTRIB_ENCDATASEAL_NO_PROTECT \ + TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT + +//************* +// NV object: * +//************* + +// +// Attributes +// +#define TSS_TSPATTRIB_NV_INDEX (0x00000001) +#define TSS_TSPATTRIB_NV_PERMISSIONS (0x00000002) +#define TSS_TSPATTRIB_NV_STATE (0x00000003) +#define TSS_TSPATTRIB_NV_DATASIZE (0x00000004) +#define TSS_TSPATTRIB_NV_PCR (0x00000005) + +#define TSS_TSPATTRIB_NVSTATE_READSTCLEAR (0x00100000) +#define TSS_TSPATTRIB_NVSTATE_WRITESTCLEAR (0x00200000) +#define TSS_TSPATTRIB_NVSTATE_WRITEDEFINE (0x00300000) + +#define TSS_TSPATTRIB_NVPCR_READPCRSELECTION (0x01000000) +#define TSS_TSPATTRIB_NVPCR_READDIGESTATRELEASE (0x02000000) +#define TSS_TSPATTRIB_NVPCR_READLOCALITYATRELEASE (0x03000000) +#define TSS_TSPATTRIB_NVPCR_WRITEPCRSELECTION (0x04000000) +#define TSS_TSPATTRIB_NVPCR_WRITEDIGESTATRELEASE (0x05000000) +#define TSS_TSPATTRIB_NVPCR_WRITELOCALITYATRELEASE (0x06000000) + +/* NV index flags + * + * From the TPM spec, Part 2, Section 19.1. + * + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |T|P|U|D| resvd | Purview | Index | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +#define TSS_NV_TPM (0x80000000) // TPM mfr reserved bit +#define TSS_NV_PLATFORM (0x40000000) // Platform mfr reserved bit +#define TSS_NV_USER (0x20000000) // User reserved bit +#define TSS_NV_DEFINED (0x10000000) // "Defined permanently" flag +#define TSS_NV_MASK_TPM (0x80000000) // mask to extract 'T' +#define TSS_NV_MASK_PLATFORM (0x40000000) // mask to extract 'P' +#define TSS_NV_MASK_USER (0x20000000) // mask to extract 'U' +#define TSS_NV_MASK_DEFINED (0x10000000) // mask to extract 'D' +#define TSS_NV_MASK_RESERVED (0x0f000000) // mask to extract reserved bits +#define TSS_NV_MASK_PURVIEW (0x00ff0000) // mask to extract purview byte +#define TSS_NV_MASK_INDEX (0x0000ffff) // mask to extract index byte + +// This is the index of the NV storage area where the number of sessions +// per locality is stored. +#define TSS_NV_INDEX_SESSIONS (0x00011101) + + +//****************** +// MigData object: * +//****************** + +// +// Attributes +// +#define TSS_MIGATTRIB_MIGRATIONBLOB (0x00000010) +#define TSS_MIGATTRIB_MIGRATIONTICKET (0x00000020) +#define TSS_MIGATTRIB_AUTHORITY_DATA (0x00000030) +#define TSS_MIGATTRIB_MIG_AUTH_DATA (0x00000040) +#define TSS_MIGATTRIB_TICKET_DATA (0x00000050) +#define TSS_MIGATTRIB_PAYLOAD_TYPE (0x00000060) + +// +// Attribute subflags TSS_MIGATTRIB_MIGRATIONBLOB +// +#define TSS_MIGATTRIB_MIGRATION_XOR_BLOB (0x00000101) +#define TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB (0x00000102) +#define TSS_MIGATTRIB_MIG_MSALIST_PUBKEY_BLOB (0x00000103) +#define TSS_MIGATTRIB_MIG_AUTHORITY_PUBKEY_BLOB (0x00000104) +#define TSS_MIGATTRIB_MIG_DESTINATION_PUBKEY_BLOB (0x00000105) +#define TSS_MIGATTRIB_MIG_SOURCE_PUBKEY_BLOB (0x00000106) +#define TSS_MIGATTRIB_MIG_REWRAPPED_BLOB TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB +#define TSS_MIGATTRIB_MIG_XOR_BLOB TSS_MIGATTRIB_MIGRATION_XOR_BLOB + +// +// Attribute subflags TSS_MIGATTRIB_MIGRATIONTICKET +// +// none + +// +// Attribute subflags TSS_MIGATTRIB_AUTHORITY_DATA +// +#define TSS_MIGATTRIB_AUTHORITY_DIGEST (0x00000301) +#define TSS_MIGATTRIB_AUTHORITY_APPROVAL_HMAC (0x00000302) +#define TSS_MIGATTRIB_AUTHORITY_MSALIST (0x00000303) + +// +// Attribute subflags TSS_MIGATTRIB_MIG_AUTH_DATA +// +#define TSS_MIGATTRIB_MIG_AUTH_AUTHORITY_DIGEST (0x00000401) +#define TSS_MIGATTRIB_MIG_AUTH_DESTINATION_DIGEST (0x00000402) +#define TSS_MIGATTRIB_MIG_AUTH_SOURCE_DIGEST (0x00000403) + +// +// Attribute subflags TSS_MIGATTRIB_TICKET_DATA +// +#define TSS_MIGATTRIB_TICKET_SIG_DIGEST (0x00000501) +#define TSS_MIGATTRIB_TICKET_SIG_VALUE (0x00000502) +#define TSS_MIGATTRIB_TICKET_SIG_TICKET (0x00000503) +#define TSS_MIGATTRIB_TICKET_RESTRICT_TICKET (0x00000504) + +// +// Attribute subflags TSS_MIGATTRIB_PAYLOAD_TYPE +// +#define TSS_MIGATTRIB_PT_MIGRATE_RESTRICTED (0x00000601) +#define TSS_MIGATTRIB_PT_MIGRATE_EXTERNAL (0x00000602) + + + + +//*************** +// Hash object: * +//*************** + +// +// Attributes +// +#define TSS_TSPATTRIB_HASH_IDENTIFIER (0x00001000) // Hash algorithm identifier +#define TSS_TSPATTRIB_ALG_IDENTIFIER (0x00002000) // ASN.1 alg identifier + + + +//*************** +// PCRs object: * +//*************** + +// +// Attributes +// +#define TSS_TSPATTRIB_PCRS_INFO (0x00000001) // info + +// +// Subflags for TSS_TSPATTRIB_PCRS_INFO flag +// +#define TSS_TSPATTRIB_PCRSINFO_PCRSTRUCT (0x00000001) // type of pcr struct + // TSS_PCRS_STRUCT_TYPE_XX + +//**************************** +// Delegation Family object: * +//**************************** + +// +// Attributes +// +#define TSS_TSPATTRIB_DELFAMILY_STATE (0x00000001) +#define TSS_TSPATTRIB_DELFAMILY_INFO (0x00000002) + +// DELFAMILY_STATE sub-attributes +#define TSS_TSPATTRIB_DELFAMILYSTATE_LOCKED (0x00000001) +#define TSS_TSPATTRIB_DELFAMILYSTATE_ENABLED (0x00000002) + +// DELFAMILY_INFO sub-attributes +#define TSS_TSPATTRIB_DELFAMILYINFO_LABEL (0x00000003) +#define TSS_TSPATTRIB_DELFAMILYINFO_VERCOUNT (0x00000004) +#define TSS_TSPATTRIB_DELFAMILYINFO_FAMILYID (0x00000005) + +// Bitmasks for the 'ulFlags' argument to Tspi_TPM_Delegate_CreateDelegation. +// Only one bit used for now. +#define TSS_DELEGATE_INCREMENTVERIFICATIONCOUNT ((UINT32)1) + +// Bitmasks for the 'ulFlags' argument to +// Tspi_TPM_Delegate_CacheOwnerDelegation. Only 1 bit is used for now. +#define TSS_DELEGATE_CACHEOWNERDELEGATION_OVERWRITEEXISTING ((UINT32)1) + + + +//************************* +// DAA Credential Object: * +//************************* + +// +// Attribute flags +// +#define TSS_TSPATTRIB_DAACRED_COMMIT (0x00000001) +#define TSS_TSPATTRIB_DAACRED_ATTRIB_GAMMAS (0x00000002) +#define TSS_TSPATTRIB_DAACRED_CREDENTIAL_BLOB (0x00000003) +#define TSS_TSPATTRIB_DAACRED_CALLBACK_SIGN (0x00000004) +#define TSS_TSPATTRIB_DAACRED_CALLBACK_VERIFYSIGNATURE (0x00000005) + +// +// Subflags for TSS_TSPATTRIB_DAACRED_COMMIT +// +#define TSS_TSPATTRIB_DAACOMMIT_NUMBER (0x00000001) +#define TSS_TSPATTRIB_DAACOMMIT_SELECTION (0x00000002) +#define TSS_TSPATTRIB_DAACOMMIT_COMMITMENTS (0x00000003) + +// +// Subflags for TSS_TSPATTRIB_DAACRED_ATTRIB_GAMMAS +// +#define TSS_TSPATTRIB_DAAATTRIBGAMMAS_BLOB (0xffffffff) + + + +//************************* +// DAA Issuer Key Object: * +//************************* + +// +// Attribute flags +// +#define TSS_TSPATTRIB_DAAISSUERKEY_BLOB (0x00000001) +#define TSS_TSPATTRIB_DAAISSUERKEY_PUBKEY (0x00000002) + +// +// Subflags for TSS_TSPATTRIB_DAAISSUERKEY_BLOB +// +#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_PUBLIC_KEY (0x00000001) +#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_SECRET_KEY (0x00000002) +#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_KEYBLOB (0x00000003) +#define TSS_TSPATTRIB_DAAISSUERKEYBLOB_PROOF (0x00000004) + +// +// Subflags for TSS_TSPATTRIB_DAAISSUERKEY_PUBKEY +// +#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ATTRIBS (0x00000001) +#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_PLATFORM_ATTRIBS (0x00000002) +#define TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ISSUER_ATTRIBS (0x00000003) + + + +//*************************************** +// DAA Anonymity Revocation Key Object: * +//*************************************** + +// +// Attribute flags +// +#define TSS_TSPATTRIB_DAAARAKEY_BLOB (0x00000001) + +// +// Subflags for TSS_TSPATTRIB_DAAARAKEY_BLOB +// +#define TSS_TSPATTRIB_DAAARAKEYBLOB_PUBLIC_KEY (0x00000001) +#define TSS_TSPATTRIB_DAAARAKEYBLOB_SECRET_KEY (0x00000002) +#define TSS_TSPATTRIB_DAAARAKEYBLOB_KEYBLOB (0x00000003) + + + +// +// Structure payload flags for TSS_DAA_PSEUDONYM, +// (TSS_DAA_PSEUDONYM.payloadFlag) +// +#define TSS_FLAG_DAA_PSEUDONYM_PLAIN (0x00000000) +#define TSS_FLAG_DAA_PSEUDONYM_ENCRYPTED (0x00000001) + + +//************** +// Key Object: * +//************** + +// +// Attribute flags +// +#define TSS_TSPATTRIB_KEY_BLOB (0x00000040) // key info as blob data +#define TSS_TSPATTRIB_KEY_INFO (0x00000080) // keyparam info as blob data +#define TSS_TSPATTRIB_KEY_UUID (0x000000C0) // key UUID info as blob data +#define TSS_TSPATTRIB_KEY_PCR (0x00000100) // composite digest value for + // the key +#define TSS_TSPATTRIB_RSAKEY_INFO (0x00000140) // public key info +#define TSS_TSPATTRIB_KEY_REGISTER (0x00000180) // register location +#define TSS_TSPATTRIB_KEY_PCR_LONG (0x000001c0) // PCR_INFO_LONG for the key +#define TSS_TSPATTRIB_KEY_CONTROLBIT (0x00000200) // key control flags +#define TSS_TSPATTRIB_KEY_CMKINFO (0x00000400) // CMK info + +// +// SubFlags for Flag TSS_TSPATTRIB_KEY_BLOB +// +#define TSS_TSPATTRIB_KEYBLOB_BLOB (0x00000008) // key info using the + // key blob +#define TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY (0x00000010) // public key info + // using the blob +#define TSS_TSPATTRIB_KEYBLOB_PRIVATE_KEY (0x00000028) // encrypted private key + // blob + +// +// SubFlags for Flag TSS_TSPATTRIB_KEY_INFO +// +#define TSS_TSPATTRIB_KEYINFO_SIZE (0x00000080) // key size in bits +#define TSS_TSPATTRIB_KEYINFO_USAGE (0x00000100) // key usage info +#define TSS_TSPATTRIB_KEYINFO_KEYFLAGS (0x00000180) // key flags +#define TSS_TSPATTRIB_KEYINFO_AUTHUSAGE (0x00000200) // key auth usage info +#define TSS_TSPATTRIB_KEYINFO_ALGORITHM (0x00000280) // key algorithm ID +#define TSS_TSPATTRIB_KEYINFO_SIGSCHEME (0x00000300) // key sig scheme +#define TSS_TSPATTRIB_KEYINFO_ENCSCHEME (0x00000380) // key enc scheme +#define TSS_TSPATTRIB_KEYINFO_MIGRATABLE (0x00000400) // if true then key is + // migratable +#define TSS_TSPATTRIB_KEYINFO_REDIRECTED (0x00000480) // key is redirected +#define TSS_TSPATTRIB_KEYINFO_VOLATILE (0x00000500) // if true key is + // volatile +#define TSS_TSPATTRIB_KEYINFO_AUTHDATAUSAGE (0x00000580) // if true auth is + // required +#define TSS_TSPATTRIB_KEYINFO_VERSION (0x00000600) // version info as TSS + // version struct +#define TSS_TSPATTRIB_KEYINFO_CMK (0x00000680) // if true then key + // is certified + // migratable +#define TSS_TSPATTRIB_KEYINFO_KEYSTRUCT (0x00000700) // type of key struct + // used for this key + // (TPM_KEY or + // TPM_KEY12) +#define TSS_TSPATTRIB_KEYCONTROL_OWNEREVICT (0x00000780) // Get current status + // of owner evict flag + +// +// SubFlags for Flag TSS_TSPATTRIB_RSAKEY_INFO +// +#define TSS_TSPATTRIB_KEYINFO_RSA_EXPONENT (0x00001000) +#define TSS_TSPATTRIB_KEYINFO_RSA_MODULUS (0x00002000) +#define TSS_TSPATTRIB_KEYINFO_RSA_KEYSIZE (0x00003000) +#define TSS_TSPATTRIB_KEYINFO_RSA_PRIMES (0x00004000) + +// +// SubFlags for Flag TSS_TSPATTRIB_KEY_PCR +// +#define TSS_TSPATTRIB_KEYPCR_DIGEST_ATCREATION (0x00008000) +#define TSS_TSPATTRIB_KEYPCR_DIGEST_ATRELEASE (0x00010000) +#define TSS_TSPATTRIB_KEYPCR_SELECTION (0x00018000) + +// +// SubFlags for TSS_TSPATTRIB_KEY_REGISTER +// +#define TSS_TSPATTRIB_KEYREGISTER_USER (0x02000000) +#define TSS_TSPATTRIB_KEYREGISTER_SYSTEM (0x04000000) +#define TSS_TSPATTRIB_KEYREGISTER_NO (0x06000000) + +// +// SubFlags for Flag TSS_TSPATTRIB_KEY_PCR_LONG +// +#define TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATCREATION (0x00040000) /* UINT32 */ +#define TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATRELEASE (0x00080000) /* UINT32 */ +#define TSS_TSPATTRIB_KEYPCRLONG_CREATION_SELECTION (0x000C0000) /* DATA */ +#define TSS_TSPATTRIB_KEYPCRLONG_RELEASE_SELECTION (0x00100000) /* DATA */ +#define TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATCREATION (0x00140000) /* DATA */ +#define TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATRELEASE (0x00180000) /* DATA */ + +// +// SubFlags for Flag TSS_TSPATTRIB_KEY_CMKINFO +// +#define TSS_TSPATTRIB_KEYINFO_CMK_MA_APPROVAL (0x00000010) +#define TSS_TSPATTRIB_KEYINFO_CMK_MA_DIGEST (0x00000020) + + +// +// Attribute Values +// + +// +// key size definitions +// +#define TSS_KEY_SIZEVAL_512BIT (0x0200) +#define TSS_KEY_SIZEVAL_1024BIT (0x0400) +#define TSS_KEY_SIZEVAL_2048BIT (0x0800) +#define TSS_KEY_SIZEVAL_4096BIT (0x1000) +#define TSS_KEY_SIZEVAL_8192BIT (0x2000) +#define TSS_KEY_SIZEVAL_16384BIT (0x4000) + +// +// key usage definitions +// Values intentionally moved away from corresponding TPM values to avoid +// possible misuse +// +#define TSS_KEYUSAGE_BIND (0x00) +#define TSS_KEYUSAGE_IDENTITY (0x01) +#define TSS_KEYUSAGE_LEGACY (0x02) +#define TSS_KEYUSAGE_SIGN (0x03) +#define TSS_KEYUSAGE_STORAGE (0x04) +#define TSS_KEYUSAGE_AUTHCHANGE (0x05) +#define TSS_KEYUSAGE_MIGRATE (0x06) + +// +// key flag definitions +// +#define TSS_KEYFLAG_REDIRECTION (0x00000001) +#define TSS_KEYFLAG_MIGRATABLE (0x00000002) +#define TSS_KEYFLAG_VOLATILEKEY (0x00000004) +#define TSS_KEYFLAG_CERTIFIED_MIGRATABLE (0x00000008) + +// +// algorithm ID definitions +// +// This table defines the algo id's +// Values intentionally moved away from corresponding TPM values to avoid +// possible misuse +// +#define TSS_ALG_RSA (0x20) +#define TSS_ALG_DES (0x21) +#define TSS_ALG_3DES (0x22) +#define TSS_ALG_SHA (0x23) +#define TSS_ALG_HMAC (0x24) +#define TSS_ALG_AES128 (0x25) +#define TSS_ALG_AES192 (0x26) +#define TSS_ALG_AES256 (0x27) +#define TSS_ALG_XOR (0x28) +#define TSS_ALG_MGF1 (0x29) + +#define TSS_ALG_AES TSS_ALG_AES128 + +// Special values for +// Tspi_Context_GetCapability(TSS_TSPCAP_ALG) +// Tspi_Context_GetCapability(TSS_TCSCAP_ALG) +#define TSS_ALG_DEFAULT (0xfe) +#define TSS_ALG_DEFAULT_SIZE (0xff) + + +// +// key signature scheme definitions +// +#define TSS_SS_NONE (0x10) +#define TSS_SS_RSASSAPKCS1V15_SHA1 (0x11) +#define TSS_SS_RSASSAPKCS1V15_DER (0x12) +#define TSS_SS_RSASSAPKCS1V15_INFO (0x13) + +// +// key encryption scheme definitions +// +#define TSS_ES_NONE (0x10) +#define TSS_ES_RSAESPKCSV15 (0x11) +#define TSS_ES_RSAESOAEP_SHA1_MGF1 (0x12) +#define TSS_ES_SYM_CNT (0x13) +#define TSS_ES_SYM_OFB (0x14) +#define TSS_ES_SYM_CBC_PKCS5PAD (0x15) + + +// +// persistent storage registration definitions +// +#define TSS_PS_TYPE_USER (1) // Key is registered persistantly in the user + // storage database. +#define TSS_PS_TYPE_SYSTEM (2) // Key is registered persistantly in the system + // storage database. + +// +// migration scheme definitions +// Values intentionally moved away from corresponding TPM values to avoid +// possible misuse +// +#define TSS_MS_MIGRATE (0x20) +#define TSS_MS_REWRAP (0x21) +#define TSS_MS_MAINT (0x22) +#define TSS_MS_RESTRICT_MIGRATE (0x23) +#define TSS_MS_RESTRICT_APPROVE_DOUBLE (0x24) +#define TSS_MS_RESTRICT_MIGRATE_EXTERNAL (0x25) + +// +// TPM key authorization +// Values intentionally moved away from corresponding TPM values to avoid +// possible misuse +// +#define TSS_KEYAUTH_AUTH_NEVER (0x10) +#define TSS_KEYAUTH_AUTH_ALWAYS (0x11) +#define TSS_KEYAUTH_AUTH_PRIV_USE_ONLY (0x12) + + +// +// Flags for TPM status information (GetStatus and SetStatus) +// +#define TSS_TPMSTATUS_DISABLEOWNERCLEAR (0x00000001) // persistent flag +#define TSS_TPMSTATUS_DISABLEFORCECLEAR (0x00000002) // volatile flag +#define TSS_TPMSTATUS_DISABLED (0x00000003) // persistent flag +#define TSS_TPMSTATUS_DEACTIVATED (0x00000004) // volatile flag +#define TSS_TPMSTATUS_OWNERSETDISABLE (0x00000005) // persistent flag + // for SetStatus + // (disable flag) +#define TSS_TPMSTATUS_SETOWNERINSTALL (0x00000006) // persistent flag + // (ownership flag) +#define TSS_TPMSTATUS_DISABLEPUBEKREAD (0x00000007) // persistent flag +#define TSS_TPMSTATUS_ALLOWMAINTENANCE (0x00000008) // persistent flag +#define TSS_TPMSTATUS_PHYSPRES_LIFETIMELOCK (0x00000009) // persistent flag +#define TSS_TPMSTATUS_PHYSPRES_HWENABLE (0x0000000A) // persistent flag +#define TSS_TPMSTATUS_PHYSPRES_CMDENABLE (0x0000000B) // persistent flag +#define TSS_TPMSTATUS_PHYSPRES_LOCK (0x0000000C) // volatile flag +#define TSS_TPMSTATUS_PHYSPRESENCE (0x0000000D) // volatile flag +#define TSS_TPMSTATUS_PHYSICALDISABLE (0x0000000E) // persistent flag + // (SetStatus + // disable flag) +#define TSS_TPMSTATUS_CEKP_USED (0x0000000F) // persistent flag +#define TSS_TPMSTATUS_PHYSICALSETDEACTIVATED (0x00000010) // persistent flag + // (deactivated flag) +#define TSS_TPMSTATUS_SETTEMPDEACTIVATED (0x00000011) // volatile flag + // (deactivated flag) +#define TSS_TPMSTATUS_POSTINITIALISE (0x00000012) // volatile flag +#define TSS_TPMSTATUS_TPMPOST (0x00000013) // persistent flag +#define TSS_TPMSTATUS_TPMPOSTLOCK (0x00000014) // persistent flag +#define TSS_TPMSTATUS_DISABLEPUBSRKREAD (0x00000016) // persistent flag +#define TSS_TPMSTATUS_MAINTENANCEUSED (0x00000017) // persistent flag +#define TSS_TPMSTATUS_OPERATORINSTALLED (0x00000018) // persistent flag +#define TSS_TPMSTATUS_OPERATOR_INSTALLED (TSS_TPMSTATUS_OPERATORINSTALLED) +#define TSS_TPMSTATUS_FIPS (0x00000019) // persistent flag +#define TSS_TPMSTATUS_ENABLEREVOKEEK (0x0000001A) // persistent flag +#define TSS_TPMSTATUS_ENABLE_REVOKEEK (TSS_TPMSTATUS_ENABLEREVOKEEK) +#define TSS_TPMSTATUS_NV_LOCK (0x0000001B) // persistent flag +#define TSS_TPMSTATUS_TPM_ESTABLISHED (0x0000001C) // persistent flag +#define TSS_TPMSTATUS_RESETLOCK (0x0000001D) // volatile flag +#define TSS_TPMSTATUS_DISABLE_FULL_DA_LOGIC_INFO (0x0000001D) //persistent flag + + +// +// Capability flag definitions +// +// TPM capabilities +// +#define TSS_TPMCAP_ORD (0x10) +#define TSS_TPMCAP_ALG (0x11) +#define TSS_TPMCAP_FLAG (0x12) +#define TSS_TPMCAP_PROPERTY (0x13) +#define TSS_TPMCAP_VERSION (0x14) +#define TSS_TPMCAP_VERSION_VAL (0x15) +#define TSS_TPMCAP_NV_LIST (0x16) +#define TSS_TPMCAP_NV_INDEX (0x17) +#define TSS_TPMCAP_MFR (0x18) +#define TSS_TPMCAP_SYM_MODE (0x19) +#define TSS_TPMCAP_HANDLE (0x1a) +#define TSS_TPMCAP_TRANS_ES (0x1b) +#define TSS_TPMCAP_AUTH_ENCRYPT (0x1c) +#define TSS_TPMCAP_SET_PERM_FLAGS (0x1d) // cf. TPM_SET_PERM_FLAGS +#define TSS_TPMCAP_SET_VENDOR (0x1e) // cf. TPM_SET_VENDOR +#define TSS_TPMCAP_DA_LOGIC (0x1f) + +// +// Sub-Capability Flags for TSS_TPMCAP_PROPERTY +// +#define TSS_TPMCAP_PROP_PCR (0x10) +#define TSS_TPMCAP_PROP_DIR (0x11) +#define TSS_TPMCAP_PROP_MANUFACTURER (0x12) +#define TSS_TPMCAP_PROP_SLOTS (0x13) +#define TSS_TPMCAP_PROP_KEYS TSS_TPMCAP_PROP_SLOTS +#define TSS_TPMCAP_PROP_FAMILYROWS (0x14) +#define TSS_TPMCAP_PROP_DELEGATEROWS (0x15) +#define TSS_TPMCAP_PROP_OWNER (0x16) +#define TSS_TPMCAP_PROP_MAXKEYS (0x18) +#define TSS_TPMCAP_PROP_AUTHSESSIONS (0x19) +#define TSS_TPMCAP_PROP_MAXAUTHSESSIONS (0x1a) +#define TSS_TPMCAP_PROP_TRANSESSIONS (0x1b) +#define TSS_TPMCAP_PROP_MAXTRANSESSIONS (0x1c) +#define TSS_TPMCAP_PROP_SESSIONS (0x1d) +#define TSS_TPMCAP_PROP_MAXSESSIONS (0x1e) +#define TSS_TPMCAP_PROP_CONTEXTS (0x1f) +#define TSS_TPMCAP_PROP_MAXCONTEXTS (0x20) +#define TSS_TPMCAP_PROP_DAASESSIONS (0x21) +#define TSS_TPMCAP_PROP_MAXDAASESSIONS (0x22) +#define TSS_TPMCAP_PROP_DAA_INTERRUPT (0x23) +#define TSS_TPMCAP_PROP_COUNTERS (0x24) +#define TSS_TPMCAP_PROP_MAXCOUNTERS (0x25) +#define TSS_TPMCAP_PROP_ACTIVECOUNTER (0x26) +#define TSS_TPMCAP_PROP_MIN_COUNTER (0x27) +#define TSS_TPMCAP_PROP_TISTIMEOUTS (0x28) +#define TSS_TPMCAP_PROP_STARTUPEFFECTS (0x29) +#define TSS_TPMCAP_PROP_MAXCONTEXTCOUNTDIST (0x2a) +#define TSS_TPMCAP_PROP_CMKRESTRICTION (0x2b) +#define TSS_TPMCAP_PROP_DURATION (0x2c) +#define TSS_TPMCAP_PROP_MAXNVAVAILABLE (0x2d) +#define TSS_TPMCAP_PROP_INPUTBUFFERSIZE (0x2e) +#define TSS_TPMCAP_PROP_REVISION (0x2f) +#define TSS_TPMCAP_PROP_LOCALITIES_AVAIL (0x32) + +// +// Resource type flags +// Sub-Capability Flags for TSS_TPMCAP_HANDLE +// +#define TSS_RT_KEY ((UINT32)0x00000010) +#define TSS_RT_AUTH ((UINT32)0x00000020) +#define TSS_RT_TRANS ((UINT32)0x00000030) +#define TSS_RT_COUNTER ((UINT32)0x00000040) + + +// +// TSS Core Service Capabilities +// +#define TSS_TCSCAP_ALG (0x00000001) +#define TSS_TCSCAP_VERSION (0x00000002) +#define TSS_TCSCAP_CACHING (0x00000003) +#define TSS_TCSCAP_PERSSTORAGE (0x00000004) +#define TSS_TCSCAP_MANUFACTURER (0x00000005) +#define TSS_TCSCAP_PLATFORM_CLASS (0x00000006) +#define TSS_TCSCAP_TRANSPORT (0x00000007) +#define TSS_TCSCAP_PLATFORM_INFO (0x00000008) + +// +// Sub-Capability Flags TSS-CoreService-Capabilities +// +#define TSS_TCSCAP_PROP_KEYCACHE (0x00000100) +#define TSS_TCSCAP_PROP_AUTHCACHE (0x00000101) +#define TSS_TCSCAP_PROP_MANUFACTURER_STR (0x00000102) +#define TSS_TCSCAP_PROP_MANUFACTURER_ID (0x00000103) +#define TSS_TCSCAP_PLATFORM_VERSION (0x00001100) +#define TSS_TCSCAP_PLATFORM_TYPE (0x00001101) +#define TSS_TCSCAP_TRANS_EXCLUSIVE (0x00002100) +#define TSS_TCSCAP_PROP_HOST_PLATFORM (0x00003001) +#define TSS_TCSCAP_PROP_ALL_PLATFORMS (0x00003002) + +// +// TSS Service Provider Capabilities +// +#define TSS_TSPCAP_ALG (0x00000010) +#define TSS_TSPCAP_VERSION (0x00000011) +#define TSS_TSPCAP_PERSSTORAGE (0x00000012) +#define TSS_TSPCAP_MANUFACTURER (0x00000013) +#define TSS_TSPCAP_RETURNVALUE_INFO (0x00000015) +#define TSS_TSPCAP_PLATFORM_INFO (0x00000016) + +// Sub-Capability Flags for TSS_TSPCAP_MANUFACTURER +// +#define TSS_TSPCAP_PROP_MANUFACTURER_STR (0x00000102) +#define TSS_TSPCAP_PROP_MANUFACTURER_ID (0x00000103) + +// Sub-Capability Flags for TSS_TSPCAP_PLATFORM_INFO +// +#define TSS_TSPCAP_PLATFORM_TYPE (0x00000201) +#define TSS_TSPCAP_PLATFORM_VERSION (0x00000202) + + + +// Sub-Capability Flags for TSS_TSPCAP_RETURNVALUE_INFO +// +#define TSS_TSPCAP_PROP_RETURNVALUE_INFO (0x00000201) + +// +// Event type definitions +// +#define TSS_EV_CODE_CERT (0x00000001) +#define TSS_EV_CODE_NOCERT (0x00000002) +#define TSS_EV_XML_CONFIG (0x00000003) +#define TSS_EV_NO_ACTION (0x00000004) +#define TSS_EV_SEPARATOR (0x00000005) +#define TSS_EV_ACTION (0x00000006) +#define TSS_EV_PLATFORM_SPECIFIC (0x00000007) + + +// +// TSP random number limits +// +#define TSS_TSPCAP_RANDOMLIMIT (0x00001000) // Errata: Missing from spec + +// +// UUIDs +// +// Errata: This are not in the spec +#define TSS_UUID_SRK {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 1}} // Storage root key +#define TSS_UUID_SK {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 2}} // System key +#define TSS_UUID_RK {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 3}} // roaming key +#define TSS_UUID_CRK {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 8}} // CMK roaming key +#define TSS_UUID_USK1 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 4}} // user storage key 1 +#define TSS_UUID_USK2 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 5}} // user storage key 2 +#define TSS_UUID_USK3 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 6}} // user storage key 3 +#define TSS_UUID_USK4 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 7}} // user storage key 4 +#define TSS_UUID_USK5 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 9}} // user storage key 5 +#define TSS_UUID_USK6 {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 10}}// user storage key 6 + +// macro to derive UUIDs for keys whose "OwnerEvict" key is set. +#define TSS_UUID_OWNEREVICT(i) {0, 0, 0, 0, 0, {0, 0, 0, 0, 1, (i)}} + + +// +// TPM well-known secret +// +#define TSS_WELL_KNOWN_SECRET \ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + + +// Values for the "direction" parameters in the Tspi_PcrComposite_XX functions. +#define TSS_PCRS_DIRECTION_CREATION ((UINT32)1) +#define TSS_PCRS_DIRECTION_RELEASE ((UINT32)2) + + +// +// TSS blob version definition for ASN.1 blobs +// +#define TSS_BLOB_STRUCT_VERSION 0x01 + +// +// TSS blob type definitions for ASN.1 blobs +// +#define TSS_BLOB_TYPE_KEY 0x01 +#define TSS_BLOB_TYPE_PUBKEY 0x02 +#define TSS_BLOB_TYPE_MIGKEY 0x03 +#define TSS_BLOB_TYPE_SEALEDDATA 0x04 +#define TSS_BLOB_TYPE_BOUNDDATA 0x05 +#define TSS_BLOB_TYPE_MIGTICKET 0x06 +#define TSS_BLOB_TYPE_PRIVATEKEY 0x07 +#define TSS_BLOB_TYPE_PRIVATEKEY_MOD1 0x08 +#define TSS_BLOB_TYPE_RANDOM_XOR 0x09 +#define TSS_BLOB_TYPE_CERTIFY_INFO 0x0A +#define TSS_BLOB_TYPE_KEY_1_2 0x0B +#define TSS_BLOB_TYPE_CERTIFY_INFO_2 0x0C +#define TSS_BLOB_TYPE_CMK_MIG_KEY 0x0D +#define TSS_BLOB_TYPE_CMK_BYTE_STREAM 0x0E + + + +// +// Values for TPM_CMK_DELEGATE bitmasks +// For now these are exactly the same values as the corresponding +// TPM_CMK_DELEGATE_* bitmasks. +// +#define TSS_CMK_DELEGATE_SIGNING (((UINT32)1)<<31) +#define TSS_CMK_DELEGATE_STORAGE (((UINT32)1)<<30) +#define TSS_CMK_DELEGATE_BIND (((UINT32)1)<<29) +#define TSS_CMK_DELEGATE_LEGACY (((UINT32)1)<<28) +#define TSS_CMK_DELEGATE_MIGRATE (((UINT32)1)<<27) + + +// +// Constants for DAA +// +#define TSS_DAA_LENGTH_N 256 // Length of the RSA Modulus (2048 bits) +#define TSS_DAA_LENGTH_F 13 // Length of the f_i's (information encoded into the certificate, 104 bits) +#define TSS_DAA_LENGTH_E 46 // Length of the e's (exponents, part of certificate, 386 bits) +#define TSS_DAA_LENGTH_E_PRIME 15 // Length of the interval the e's are chosen from (120 bits) +#define TSS_DAA_LENGTH_V 317 // Length of the v's (random value, part of certificate, 2536 bits) +#define TSS_DAA_LENGTH_SAFETY 10 // Length of the security parameter controlling the statistical zero-knowledge property (80 bits) +#define TSS_DAA_LENGTH_HASH TPM_SHA1_160_HASH_LEN // Length of the output of the hash function SHA-1 used for the Fiat-Shamir heuristic(160 bits) +#define TSS_DAA_LENGTH_S 128 // Length of the split large exponent for easier computations on the TPM (1024 bits) +#define TSS_DAA_LENGTH_GAMMA 204 // Length of the modulus 'Gamma' (1632 bits) +#define TSS_DAA_LENGTH_RHO 26 // Length of the order 'rho' of the sub group of Z*_Gamma that is used for roggue tagging (208 bits) +#define TSS_DAA_LENGTH_MFG1_GAMMA 214 // Length of the output of MGF1 in conjunction with the modulus Gamma (1712 bits) +#define TSS_DAA_LENGTH_MGF1_AR 25 // Length of the output of MGF1 used for anonymity revocation (200 bits) + + +#endif // __TSS_DEFINES_H__ diff --git a/illumos-x86_64/usr/include/tss/tss_error.h b/illumos-x86_64/usr/include/tss/tss_error.h new file mode 100644 index 00000000..dd64c8ae --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tss_error.h @@ -0,0 +1,687 @@ +/*++ + +TSS error return codes + +--*/ + +#ifndef __TSS_ERROR_H__ +#define __TSS_ERROR_H__ + +#include + +// +// error coding scheme for a Microsoft Windows platform - +// refer to the TSS Specification Parts +// +// Values are 32 bit values layed out as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---+-+-+-----------------------+-------+-----------------------+ +// |Lev|C|R| Facility | Layer | Code | +// +---+-+-+-----------------------+-------+-----------------------+ +// | Platform specific coding | TSS error coding system | +// +---+-+-+-----------------------+-------+-----------------------+ +// +// Lev - is the Level code +// +// 00 - Success +// 01 - Informational +// 10 - Warning +// 11 - Error +// +// C - is the Customer code flag (must actually be set) +// +// R - is a reserved bit (unused) +// +// Facility - is the facility code: TCPA: proposal 0x028 +// +// Code - is the facility's status code +// + +// +// definitions for the code level information +// +#define TSS_LEVEL_SUCCESS 0x00 // code level success +#define TSS_LEVEL_INFO 0x40000000L // code level information +#define TSS_LEVEL_WARNING 0x80000000L // code level warning +#define TSS_LEVEL_ERROR 0xC0000000L // code level error + +// +// some defines for the platform specific information +// +#define FACILITY_TSS 0x28L // facility number for TCPA return codes +#define FACILITY_TSS_CODEPOS (FACILITY_TSS << 16) // shift the facility info to the code + // position + +#define TSS_CUSTOM_CODEFLAG 0x20000000L // bit position for the custom flag in + // return code + +// +// +// TSS error return codes +// +// +#ifndef TSS_E_BASE +#define TSS_E_BASE 0x00000000L +#endif // TSS_E_BASE +#ifndef TSS_W_BASE +#define TSS_W_BASE 0x00000000L +#endif // TSS_W_BASE +#ifndef TSS_I_BASE +#define TSS_I_BASE 0x00000000L +#endif // TSS_I_BASE + +// +// basic error return codes common to all TSS Service Provider Interface methods +// and returned by all TSS SW stack components +// + +// +// MessageId: TSS_SUCCESS +// +// MessageText: +// +// Successful completion of the operation. +// +#define TSS_SUCCESS (UINT32)(0x00000000L) + +// +// MessageId: TSS_E_FAIL +// +// MessageText: +// +// An internal error has been detected, but the source is unknown. +// +#define TSS_E_FAIL (UINT32)(TSS_E_BASE + 0x002L) + +// +// MessageId: TSS_E_BAD_PARAMETER +// +// MessageText: +// +// One or more parameter is bad. +// +#define TSS_E_BAD_PARAMETER (UINT32)(TSS_E_BASE + 0x003L) + +// +// MessageId: TSS_E_INTERNAL_ERROR +// +// MessageText: +// +// An internal SW error has been detected. +// +#define TSS_E_INTERNAL_ERROR (UINT32)(TSS_E_BASE + 0x004L) + +// +// MessageId: TSS_E_OUTOFMEMORY +// +// MessageText: +// +// Ran out of memory. +// +#define TSS_E_OUTOFMEMORY (UINT32)(TSS_E_BASE + 0x005L) + +// +// MessageId: TSS_E_NOTIMPL +// +// MessageText: +// +// Not implemented. +// +#define TSS_E_NOTIMPL (UINT32)(TSS_E_BASE + 0x006L) + +// +// MessageId: TSS_E_KEY_ALREADY_REGISTERED +// +// MessageText: +// +// Key is already registered +// +#define TSS_E_KEY_ALREADY_REGISTERED (UINT32)(TSS_E_BASE + 0x008L) + + +// +// MessageId: TSS_E_TPM_UNEXPECTED +// +// MessageText: +// +// An unexpected TPM error has occurred. +// +#define TSS_E_TPM_UNEXPECTED (UINT32)(TSS_E_BASE + 0x010L) + +// +// MessageId: TSS_E_COMM_FAILURE +// +// MessageText: +// +// A communications error with the TPM has been detected. +// +#define TSS_E_COMM_FAILURE (UINT32)(TSS_E_BASE + 0x011L) + +// +// MessageId: TSS_E_TIMEOUT +// +// MessageText: +// +// The operation has timed out. +// +#define TSS_E_TIMEOUT (UINT32)(TSS_E_BASE + 0x012L) + +// +// MessageId: TSS_E_TPM_UNSUPPORTED_FEATURE +// +// MessageText: +// +// The TPM does not support the requested feature. +// +#define TSS_E_TPM_UNSUPPORTED_FEATURE (UINT32)(TSS_E_BASE + 0x014L) + +// +// MessageId: TSS_E_CANCELED +// +// MessageText: +// +// The action was canceled by request. +// +#define TSS_E_CANCELED (UINT32)(TSS_E_BASE + 0x016L) + +// +// MessageId: TSS_E_PS_KEY_NOTFOUND +// +// MessageText: +// +// The key cannot be found in the persistent storage database. +// +#define TSS_E_PS_KEY_NOTFOUND (UINT32)(TSS_E_BASE + 0x020L) +// +// MessageId: TSS_E_PS_KEY_EXISTS +// +// MessageText: +// +// The key already exists in the persistent storage database. +// +#define TSS_E_PS_KEY_EXISTS (UINT32)(TSS_E_BASE + 0x021L) + +// +// MessageId: TSS_E_PS_BAD_KEY_STATE +// +// MessageText: +// +// The key data set not valid in the persistent storage database. +// +#define TSS_E_PS_BAD_KEY_STATE (UINT32)(TSS_E_BASE + 0x022L) + + +// +// error codes returned by specific TSS Service Provider Interface methods +// offset TSS_TSPI_OFFSET +// + +// +// MessageId: TSS_E_INVALID_OBJECT_TYPE +// +// MessageText: +// +// Object type not valid for this operation. +// +#define TSS_E_INVALID_OBJECT_TYPE (UINT32)(TSS_E_BASE + 0x101L) + +// +// MessageId: TSS_E_NO_CONNECTION +// +// MessageText: +// +// Core Service connection doesn't exist. +// +#define TSS_E_NO_CONNECTION (UINT32)(TSS_E_BASE + 0x102L) + +// +// MessageId: TSS_E_CONNECTION_FAILED +// +// MessageText: +// +// Core Service connection failed. +// +#define TSS_E_CONNECTION_FAILED (UINT32)(TSS_E_BASE + 0x103L) + +// +// MessageId: TSS_E_CONNECTION_BROKEN +// +// MessageText: +// +// Communication with Core Service failed. +// +#define TSS_E_CONNECTION_BROKEN (UINT32)(TSS_E_BASE + 0x104L) + +// +// MessageId: TSS_E_HASH_INVALID_ALG +// +// MessageText: +// +// Invalid hash algorithm. +// +#define TSS_E_HASH_INVALID_ALG (UINT32)(TSS_E_BASE + 0x105L) + +// +// MessageId: TSS_E_HASH_INVALID_LENGTH +// +// MessageText: +// +// Hash length is inconsistent with hash algorithm. +// +#define TSS_E_HASH_INVALID_LENGTH (UINT32)(TSS_E_BASE + 0x106L) + +// +// MessageId: TSS_E_HASH_NO_DATA +// +// MessageText: +// +// Hash object has no internal hash value. +// +#define TSS_E_HASH_NO_DATA (UINT32)(TSS_E_BASE + 0x107L) + + +// +// MessageId: TSS_E_INVALID_ATTRIB_FLAG +// +// MessageText: +// +// Flag value for attrib-functions inconsistent. +// +#define TSS_E_INVALID_ATTRIB_FLAG (UINT32)(TSS_E_BASE + 0x109L) + +// +// MessageId: TSS_E_INVALID_ATTRIB_SUBFLAG +// +// MessageText: +// +// Subflag value for attrib-functions inconsistent. +// +#define TSS_E_INVALID_ATTRIB_SUBFLAG (UINT32)(TSS_E_BASE + 0x10AL) + +// +// MessageId: TSS_E_INVALID_ATTRIB_DATA +// +// MessageText: +// +// Data for attrib-functions invalid. +// +#define TSS_E_INVALID_ATTRIB_DATA (UINT32)(TSS_E_BASE + 0x10BL) + +// +// MessageId: TSS_E_INVALID_OBJECT_INITFLAG +// +// MessageText: +// +// Wrong flag information for object creation. +// +// The alternate spelling is supported to be compatible with a typo +// in the 1.1b header files. +// +#define TSS_E_INVALID_OBJECT_INIT_FLAG (UINT32)(TSS_E_BASE + 0x10CL) +#define TSS_E_INVALID_OBJECT_INITFLAG TSS_E_INVALID_OBJECT_INIT_FLAG + +// +// MessageId: TSS_E_NO_PCRS_SET +// +// MessageText: +// +// No PCR register are selected or set. +// +#define TSS_E_NO_PCRS_SET (UINT32)(TSS_E_BASE + 0x10DL) + +// +// MessageId: TSS_E_KEY_NOT_LOADED +// +// MessageText: +// +// The addressed key is currently not loaded. +// +#define TSS_E_KEY_NOT_LOADED (UINT32)(TSS_E_BASE + 0x10EL) + +// +// MessageId: TSS_E_KEY_NOT_SET +// +// MessageText: +// +// No key information is currently available. +// +#define TSS_E_KEY_NOT_SET (UINT32)(TSS_E_BASE + 0x10FL) + +// +// MessageId: TSS_E_VALIDATION_FAILED +// +// MessageText: +// +// Internal validation of data failed. +// +#define TSS_E_VALIDATION_FAILED (UINT32)(TSS_E_BASE + 0x110L) + +// +// MessageId: TSS_E_TSP_AUTHREQUIRED +// +// MessageText: +// +// Authorization is required. +// +#define TSS_E_TSP_AUTHREQUIRED (UINT32)(TSS_E_BASE + 0x111L) + +// +// MessageId: TSS_E_TSP_AUTH2REQUIRED +// +// MessageText: +// +// Multiple authorization is required. +// +#define TSS_E_TSP_AUTH2REQUIRED (UINT32)(TSS_E_BASE + 0x112L) + +// +// MessageId: TSS_E_TSP_AUTHFAIL +// +// MessageText: +// +// Authorization failed. +// +#define TSS_E_TSP_AUTHFAIL (UINT32)(TSS_E_BASE + 0x113L) + +// +// MessageId: TSS_E_TSP_AUTH2FAIL +// +// MessageText: +// +// Multiple authorization failed. +// +#define TSS_E_TSP_AUTH2FAIL (UINT32)(TSS_E_BASE + 0x114L) + +// +// MessageId: TSS_E_KEY_NO_MIGRATION_POLICY +// +// MessageText: +// +// There's no migration policy object set for the addressed key. +// +#define TSS_E_KEY_NO_MIGRATION_POLICY (UINT32)(TSS_E_BASE + 0x115L) + +// +// MessageId: TSS_E_POLICY_NO_SECRET +// +// MessageText: +// +// No secret information is currently available for the addressed policy object. +// +#define TSS_E_POLICY_NO_SECRET (UINT32)(TSS_E_BASE + 0x116L) + +// +// MessageId: TSS_E_INVALID_OBJ_ACCESS +// +// MessageText: +// +// The operation failed due to an invalid object status. +// +#define TSS_E_INVALID_OBJ_ACCESS (UINT32)(TSS_E_BASE + 0x117L) + +// +// MessageId: TSS_E_INVALID_ENCSCHEME +// +// MessageText: +// +// +// +#define TSS_E_INVALID_ENCSCHEME (UINT32)(TSS_E_BASE + 0x118L) + + +// +// MessageId: TSS_E_INVALID_SIGSCHEME +// +// MessageText: +// +// +// +#define TSS_E_INVALID_SIGSCHEME (UINT32)(TSS_E_BASE + 0x119L) + +// +// MessageId: TSS_E_ENC_INVALID_LENGTH +// +// MessageText: +// +// +// +#define TSS_E_ENC_INVALID_LENGTH (UINT32)(TSS_E_BASE + 0x120L) + + +// +// MessageId: TSS_E_ENC_NO_DATA +// +// MessageText: +// +// +// +#define TSS_E_ENC_NO_DATA (UINT32)(TSS_E_BASE + 0x121L) + +// +// MessageId: TSS_E_ENC_INVALID_TYPE +// +// MessageText: +// +// +// +#define TSS_E_ENC_INVALID_TYPE (UINT32)(TSS_E_BASE + 0x122L) + + +// +// MessageId: TSS_E_INVALID_KEYUSAGE +// +// MessageText: +// +// +// +#define TSS_E_INVALID_KEYUSAGE (UINT32)(TSS_E_BASE + 0x123L) + +// +// MessageId: TSS_E_VERIFICATION_FAILED +// +// MessageText: +// +// +// +#define TSS_E_VERIFICATION_FAILED (UINT32)(TSS_E_BASE + 0x124L) + +// +// MessageId: TSS_E_HASH_NO_IDENTIFIER +// +// MessageText: +// +// Hash algorithm identifier not set. +// +#define TSS_E_HASH_NO_IDENTIFIER (UINT32)(TSS_E_BASE + 0x125L) + +// +// MessageId: TSS_E_INVALID_HANDLE +// +// MessageText: +// +// An invalid handle +// +#define TSS_E_INVALID_HANDLE (UINT32)(TSS_E_BASE + 0x126L) + +// +// MessageId: TSS_E_SILENT_CONTEXT +// +// MessageText: +// +// A silent context requires user input +// +#define TSS_E_SILENT_CONTEXT (UINT32)(TSS_E_BASE + 0x127L) + +// +// MessageId: TSS_E_EK_CHECKSUM +// +// MessageText: +// +// TSP is instructed to verify the EK checksum and it does not verify. +// +#define TSS_E_EK_CHECKSUM (UINT32)(TSS_E_BASE + 0x128L) + + +// +// MessageId: TSS_E_DELGATION_NOTSET +// +// MessageText: +// +// The Policy object does not have a delegation blob set. +// +#define TSS_E_DELEGATION_NOTSET (UINT32)(TSS_E_BASE + 0x129L) + +// +// MessageId: TSS_E_DELFAMILY_NOTFOUND +// +// MessageText: +// +// The specified delegation family was not found +// +#define TSS_E_DELFAMILY_NOTFOUND (UINT32)(TSS_E_BASE + 0x130L) + +// +// MessageId: TSS_E_DELFAMILY_ROWEXISTS +// +// MessageText: +// +// The specified delegation family table row is already in use and +// the command flags does not allow the TSS to overwrite the existing +// entry. +// +#define TSS_E_DELFAMILY_ROWEXISTS (UINT32)(TSS_E_BASE + 0x131L) + +// +// MessageId: TSS_E_VERSION_MISMATCH +// +// MessageText: +// +// The specified delegation family table row is already in use and +// the command flags does not allow the TSS to overwrite the existing +// entry. +// +#define TSS_E_VERSION_MISMATCH (UINT32)(TSS_E_BASE + 0x132L) + +// +// MessageId: TSS_E_DAA_AR_DECRYPTION_ERROR +// +// Decryption of the encrypted pseudonym has failed, due to +// either a wrong secret key or a wrong decryption condition. +// +#define TSS_E_DAA_AR_DECRYPTION_ERROR (UINT32)(TSS_E_BASE + 0x133L) + +// +// MessageId: TSS_E_DAA_AUTHENTICATION_ERROR +// +// The TPM could not be authenticated by the DAA Issuer. +// +#define TSS_E_DAA_AUTHENTICATION_ERROR (UINT32)(TSS_E_BASE + 0x134L) + +// +// MessageId: TSS_E_DAA_CHALLENGE_RESPONSE_ERROR +// +// DAA Challenge response error. +// +#define TSS_E_DAA_CHALLENGE_RESPONSE_ERROR (UINT32)(TSS_E_BASE + 0x135L) + +// +// MessageId: TSS_E_DAA_CREDENTIAL_PROOF_ERROR +// +// Verification of the credential TSS_DAA_CRED_ISSUER issued by +// the DAA Issuer has failed. +// +#define TSS_E_DAA_CREDENTIAL_PROOF_ERROR (UINT32)(TSS_E_BASE + 0x136L) + +// +// MessageId: TSS_E_DAA_CREDENTIAL_REQUEST_PROOF_ERROR +// +// Verification of the platform's credential request +// TSS_DAA_CREDENTIAL_REQUEST has failed. +// +#define TSS_E_DAA_CREDENTIAL_REQUEST_PROOF_ERROR (UINT32)(TSS_E_BASE + 0x137L) + +// +// MessageId: TSS_E_DAA_ISSUER_KEY_ERROR +// +// DAA Issuer's authentication key chain could not be verified or +// is not correct. +// +#define TSS_E_DAA_ISSUER_KEY_ERROR (UINT32)(TSS_E_BASE + 0x138L) + +// +// MessageId: TSS_E_DAA_PSEUDONYM_ERROR +// +// While verifying the pseudonym of the TPM, the private key of the +// TPM was found on the rogue list. +// +#define TSS_E_DAA_PSEUDONYM_ERROR (UINT32)(TSS_E_BASE + 0x139L) + +// +// MessageId: TSS_E_INVALID_RESOURCE +// +// Pointer to memory wrong. +// +#define TSS_E_INVALID_RESOURCE (UINT32)(TSS_E_BASE + 0x13AL) + +// +// MessageId: TSS_E_NV_AREA_EXIST +// +// The NV area referenced already exists +// +#define TSS_E_NV_AREA_EXIST (UINT32)(TSS_E_BASE + 0x13BL) + +// +// MessageId: TSS_E_NV_AREA_NOT_EXIST +// +// The NV area referenced doesn't exist +// +#define TSS_E_NV_AREA_NOT_EXIST (UINT32)(TSS_E_BASE + 0x13CL) + +// +// MessageId: TSS_E_TSP_TRANS_AUTHFAIL +// +// The transport session authorization failed +// +#define TSS_E_TSP_TRANS_AUTHFAIL (UINT32)(TSS_E_BASE + 0x13DL) + +// +// MessageId: TSS_E_TSP_TRANS_AUTHREQUIRED +// +// Authorization for transport is required +// +#define TSS_E_TSP_TRANS_AUTHREQUIRED (UINT32)(TSS_E_BASE + 0x13EL) + +// +// MessageId: TSS_E_TSP_TRANS_NOT_EXCLUSIVE +// +// A command was executed outside of an exclusive transport session. +// +#define TSS_E_TSP_TRANS_NOTEXCLUSIVE (UINT32)(TSS_E_BASE + 0x13FL) + +// +// MessageId: TSS_E_TSP_TRANS_FAIL +// +// Generic transport protection error. +// +#define TSS_E_TSP_TRANS_FAIL (UINT32)(TSS_E_BASE + 0x140L) + +// +// MessageId: TSS_E_TSP_TRANS_NO_PUBKEY +// +// A command could not be executed through a logged transport session +// because the command used a key and the key's public key is not +// known to the TSP. +// +#define TSS_E_TSP_TRANS_NO_PUBKEY (UINT32)(TSS_E_BASE + 0x141L) + +// +// MessageId: TSS_E_NO_ACTIVE_COUNTER +// +// The TPM active counter has not been set yet. +// +#define TSS_E_NO_ACTIVE_COUNTER (UINT32)(TSS_E_BASE + 0x142L) + + +#endif // __TSS_ERROR_H__ diff --git a/illumos-x86_64/usr/include/tss/tss_error_basics.h b/illumos-x86_64/usr/include/tss/tss_error_basics.h new file mode 100644 index 00000000..0ffa51c8 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tss_error_basics.h @@ -0,0 +1,59 @@ +/*++ + +Basic defines for TSS error return codes + +--*/ + +#ifndef __TSS_ERROR_BASICS_H__ +#define __TSS_ERROR_BASICS_H__ + + +// +// definitions for the various TSS-SW layers +// +#ifndef TSS_LAYER_TPM +#define TSS_LAYER_TPM 0x0000L // definition for TPM layer +#endif // TSS_LAYER_TPM + +#define TSS_LAYER_TDDL 0x1000L // definition for TDDL layer +#define TSS_LAYER_TCS 0x2000L // definition for TCS layer + +#ifndef TSS_LAYER_TSP +#define TSS_LAYER_TSP 0x3000L // definition for TSP layer +#endif // TSS_LAYER_TSP + + +// +// definitions for the start points of layer specific error codes +// +#ifndef TSS_COMMON_OFFSET +#define TSS_COMMON_OFFSET 0x000L +#endif // TSS_COMMON_OFFSET + +#define TSS_TDDL_OFFSET 0x080L +#define TSS_TCSI_OFFSET 0x0C0L + +#ifndef TSS_TSPI_OFFSET +#define TSS_TSPI_OFFSET 0x100L +#endif // TSS_TSPI_OFFSET + +#ifndef TSS_VENDOR_OFFSET +#define TSS_VENDOR_OFFSET 0x800L +#endif // TSS_VENDOR_OFFSET + +// do not exceed TSS_MAX_ERROR for vendor specific code values: +#ifndef TSS_MAX_ERROR +#define TSS_MAX_ERROR 0xFFFL +#endif // TSS_MAX_ERROR + + +/* Macros for the construction and interpretation of error codes */ +#define TPM_ERROR(code) (code) +#define TDDL_ERROR(code) ((code) ? (TSS_LAYER_TDDL | (code)) : (code)) +#define TCS_ERROR(code) ((code) ? (TSS_LAYER_TCS | (code)) : (code)) +#define TSP_ERROR(code) ((code) ? (TSS_LAYER_TSP | (code)) : (code)) +#define ERROR_LAYER(error) ((error) & 0xf000) +#define ERROR_CODE(error) ((error) & 0x0fff) + +#endif // __TSS_ERROR_BASICS_H__ + diff --git a/illumos-x86_64/usr/include/tss/tss_structs.h b/illumos-x86_64/usr/include/tss/tss_structs.h new file mode 100644 index 00000000..8b769e44 --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tss_structs.h @@ -0,0 +1,653 @@ +/*++ + +TSS structures for TSS + +*/ + +#ifndef __TSS_STRUCTS_H__ +#define __TSS_STRUCTS_H__ + +#include +#include +#include + +typedef struct tdTSS_VERSION +{ + BYTE bMajor; + BYTE bMinor; + BYTE bRevMajor; + BYTE bRevMinor; +} TSS_VERSION; + +typedef struct tdTSS_PCR_EVENT +{ + TSS_VERSION versionInfo; + UINT32 ulPcrIndex; + TSS_EVENTTYPE eventType; + UINT32 ulPcrValueLength; +#ifdef __midl + [size_is(ulPcrValueLength)] +#endif + BYTE* rgbPcrValue; + UINT32 ulEventLength; +#ifdef __midl + [size_is(ulEventLength)] +#endif + BYTE* rgbEvent; +} TSS_PCR_EVENT; + + +typedef struct tdTSS_EVENT_CERT +{ + TSS_VERSION versionInfo; + UINT32 ulCertificateHashLength; +#ifdef __midl + [size_is(ulCertificateHashLength)] +#endif + BYTE* rgbCertificateHash; + UINT32 ulEntityDigestLength; +#ifdef __midl + [size_is(ulEntityDigestLength)] +#endif + BYTE* rgbentityDigest; + TSS_BOOL fDigestChecked; + TSS_BOOL fDigestVerified; + UINT32 ulIssuerLength; +#ifdef __midl + [size_is(ulIssuerLength)] +#endif + BYTE* rgbIssuer; +} TSS_EVENT_CERT; + +typedef struct tdTSS_UUID +{ + UINT32 ulTimeLow; + UINT16 usTimeMid; + UINT16 usTimeHigh; + BYTE bClockSeqHigh; + BYTE bClockSeqLow; + BYTE rgbNode[6]; +} TSS_UUID; + +typedef struct tdTSS_KM_KEYINFO +{ + TSS_VERSION versionInfo; + TSS_UUID keyUUID; + TSS_UUID parentKeyUUID; + BYTE bAuthDataUsage; // whether auth is needed to load child keys + TSS_BOOL fIsLoaded; // TRUE: actually loaded in TPM + UINT32 ulVendorDataLength; // may be 0 +#ifdef __midl + [size_is(ulVendorDataLength)] +#endif + BYTE *rgbVendorData; // may be NULL +} TSS_KM_KEYINFO; + + +typedef struct tdTSS_KM_KEYINFO2 +{ + TSS_VERSION versionInfo; + TSS_UUID keyUUID; + TSS_UUID parentKeyUUID; + BYTE bAuthDataUsage; // whether auth is needed to load child keys + TSS_FLAG persistentStorageType; + TSS_FLAG persistentStorageTypeParent; + TSS_BOOL fIsLoaded; // TRUE: actually loaded in TPM + UINT32 ulVendorDataLength; // may be 0 +#ifdef __midl + [size_is(ulVendorDataLength)] +#endif + BYTE *rgbVendorData; // may be NULL +} TSS_KM_KEYINFO2; + + +typedef struct tdTSS_NONCE +{ + BYTE nonce[TPM_SHA1BASED_NONCE_LEN]; +} TSS_NONCE; + + +typedef struct tdTSS_VALIDATION +{ + TSS_VERSION versionInfo; + UINT32 ulExternalDataLength; +#ifdef __midl + [size_is(ulExternalDataLength)] +#endif + BYTE* rgbExternalData; + UINT32 ulDataLength; +#ifdef __midl + [size_is(ulDataLength)] +#endif + BYTE* rgbData; + UINT32 ulValidationDataLength; +#ifdef __midl + [size_is(ulValidationDataLength)] +#endif + BYTE* rgbValidationData; +} TSS_VALIDATION; + + +typedef struct tdTSS_CALLBACK +{ + PVOID callback; + PVOID appData; + TSS_ALGORITHM_ID alg; +} TSS_CALLBACK; + + +typedef struct tdTSS_DAA_PK +{ + TSS_VERSION versionInfo; + UINT32 modulusLength; +#ifdef __midl + [size_is(modulusLength)] +#endif + BYTE* modulus; + UINT32 capitalSLength; +#ifdef __midl + [size_is(capitalSLength)] +#endif + BYTE* capitalS; + UINT32 capitalZLength; +#ifdef __midl + [size_is(capitalZLength)] +#endif + BYTE* capitalZ; + UINT32 capitalR0Length; +#ifdef __midl + [size_is(capitalR0Length)] +#endif + BYTE* capitalR0; + UINT32 capitalR1Length; +#ifdef __midl + [size_is(capitalR1Length)] +#endif + BYTE* capitalR1; + UINT32 gammaLength; +#ifdef __midl + [size_is(gammaLength)] +#endif + BYTE* gamma; + UINT32 capitalGammaLength; +#ifdef __midl + [size_is(capitalGammaLength)] +#endif + BYTE* capitalGamma; + UINT32 rhoLength; +#ifdef __midl + [size_is(rhoLength)] +#endif + BYTE* rho; + UINT32 capitalYLength; // Length of first dimenstion + UINT32 capitalYLength2; // Length of second dimension +#ifdef __midl + [size_is(capitalYLength,capitalYLength2)] +#endif + BYTE** capitalY; + UINT32 capitalYPlatformLength; + UINT32 issuerBaseNameLength; +#ifdef __midl + [size_is(issuerBaseName)] +#endif + BYTE* issuerBaseName; + UINT32 numPlatformAttributes; + UINT32 numIssuerAttributes; +} TSS_DAA_PK; + +typedef struct tdTSS_DAA_PK_PROOF +{ + TSS_VERSION versionInfo; + UINT32 challengeLength; +#ifdef __midl + [size_is(challengeLength)] +#endif + BYTE* challenge; + UINT32 responseLength; // Length of first dimension + UINT32 responseLength2; // Length of second dimension +#ifdef __midl + [size_is(responseLength,responseLength2)] +#endif + BYTE** response; +} TSS_DAA_PK_PROOF; + +typedef struct tdTSS_DAA_SK +{ + TSS_VERSION versionInfo; + UINT32 productPQprimeLength; +#ifdef __midl + [size_is(productPQprimeLength)] +#endif + BYTE* productPQprime; +} TSS_DAA_SK; + + +typedef struct tdTSS_DAA_KEY_PAIR +{ + TSS_VERSION versionInfo; + TSS_DAA_SK secretKey; + TSS_DAA_PK publicKey; +} TSS_DAA_KEY_PAIR; + +typedef struct tdTSS_DAA_AR_PK +{ + TSS_VERSION versionInfo; + UINT32 etaLength; +#ifdef __midl + [size_is(etaLength)] +#endif + BYTE* eta; + UINT32 lambda1Length; +#ifdef __midl + [size_is(lambda1Length)] +#endif + BYTE* lambda1; + UINT32 lambda2Length; +#ifdef __midl + [size_is(lambda2Length)] +#endif + BYTE* lambda2; + UINT32 lambda3Length; +#ifdef __midl + [size_is(lambda3Length)] +#endif + BYTE* lambda3; +} TSS_DAA_AR_PK; + +typedef struct tdTSS_DAA_AR_SK +{ + TSS_VERSION versionInfo; + UINT32 x0Length; +#ifdef __midl + [size_is(x0Length)] +#endif + BYTE* x0; + UINT32 x1Length; +#ifdef __midl + [size_is(x1Length)] +#endif + BYTE* x1; + UINT32 x2Length; +#ifdef __midl + [size_is(x2Length)] +#endif + BYTE* x2; + UINT32 x3Length; +#ifdef __midl + [size_is(x3Length)] +#endif + BYTE* x3; + UINT32 x4Length; +#ifdef __midl + [size_is(x4Length)] +#endif + BYTE* x4; + UINT32 x5Length; +#ifdef __midl + [size_is(x5Length)] +#endif + BYTE* x5; +} TSS_DAA_AR_SK; + +typedef struct tdTSS_DAA_AR_KEY_PAIR +{ + TSS_VERSION versionInfo; + TSS_DAA_AR_SK secretKey; + TSS_DAA_AR_PK publicKey; +} TSS_DAA_AR_KEY_PAIR; + +typedef struct tdTSS_DAA_CRED_ISSUER +{ + TSS_VERSION versionInfo; + UINT32 capitalALength; +#ifdef __midl + [size_is(capitalALength)] +#endif + BYTE* capitalA; + UINT32 eLength; +#ifdef __midl + [size_is(eLength)] +#endif + BYTE* e; + UINT32 vPrimePrimeLength; +#ifdef __midl + [size_is(vPrimePrimeLength)] +#endif + BYTE* vPrimePrime; + UINT32 attributesIssuerLength; // Length of first dimension + UINT32 attributesIssuerLength2; // Length of second dimension +#ifdef __midl + [size_is(attributesIssuerLength,attributesIssuerLength2)] +#endif + BYTE** attributesIssuer; + UINT32 cPrimeLength; +#ifdef __midl + [size_is(cPrimeLength)] +#endif + BYTE* cPrime; + UINT32 sELength; +#ifdef __midl + [size_is(sELength)] +#endif + BYTE* sE; +} TSS_DAA_CRED_ISSUER; + +typedef struct tdTSS_DAA_CREDENTIAL +{ + TSS_VERSION versionInfo; + UINT32 capitalALength; +#ifdef __midl + [size_is(capitalALength)] +#endif + BYTE* capitalA; + UINT32 exponentLength; +#ifdef __midl + [size_is(exponentLength)] +#endif + BYTE* exponent; + UINT32 vBar0Length; +#ifdef __midl + [size_is(vBar0Length)] +#endif + BYTE* vBar0; + UINT32 vBar1Length; +#ifdef __midl + [size_is(vBar1Length)] +#endif + BYTE* vBar1; + UINT32 attributesLength; // Length of first dimension + UINT32 attributesLength2; // Length of second dimension +#ifdef __midl + [size_is(attributesLength,attributesLength2)] +#endif + BYTE** attributes; + TSS_DAA_PK issuerPK; + UINT32 tpmSpecificEncLength; +#ifdef __midl + [size_is(tpmSpecificEncLength)] +#endif + BYTE* tpmSpecificEnc; + UINT32 daaCounter; +} TSS_DAA_CREDENTIAL; + +typedef struct tdTSS_DAA_ATTRIB_COMMIT +{ + TSS_VERSION versionInfo; + UINT32 betaLength; +#ifdef __midl + [size_is(betaLength)] +#endif + BYTE* beta; + UINT32 sMuLength; +#ifdef __midl + [size_is(sMuLength)] +#endif + BYTE* sMu; +} TSS_DAA_ATTRIB_COMMIT; + +typedef struct tdTSS_DAA_CREDENTIAL_REQUEST +{ + TSS_VERSION versionInfo; + UINT32 capitalULength; +#ifdef __midl + [size_is(capitalULength)] +#endif + BYTE* capitalU; + UINT32 capitalNiLength; +#ifdef __midl + [size_is(capitalNiLength)] +#endif + BYTE* capitalNi; + UINT32 authenticationProofLength; +#ifdef __midl + [size_is(authenticationProofLength)] +#endif + BYTE* authenticationProof; + UINT32 challengeLength; +#ifdef __midl + [size_is(challengeLength)] +#endif + BYTE* challenge; + UINT32 nonceTpmLength; +#ifdef __midl + [size_is(nonceTpmLength)] +#endif + BYTE* nonceTpm; + UINT32 noncePlatformLength; +#ifdef __midl + [size_is(noncePlatformLength)] +#endif + BYTE* noncePlatform; + UINT32 sF0Length; +#ifdef __midl + [size_is(sF0Length)] +#endif + BYTE* sF0; + UINT32 sF1Length; +#ifdef __midl + [size_is(sF1Length)] +#endif + BYTE* sF1; + UINT32 sVprimeLength; +#ifdef __midl + [size_is(sVprimeLength)] +#endif + BYTE* sVprime; + UINT32 sVtildePrimeLength; +#ifdef __midl + [size_is(sVtildePrimeLength)] +#endif + BYTE* sVtildePrime; + UINT32 sALength; // Length of first dimension + UINT32 sALength2; // Length of second dimension +#ifdef __midl + [size_is(sALength,sALength2)] +#endif + BYTE** sA; + UINT32 attributeCommitmentsLength; + TSS_DAA_ATTRIB_COMMIT* attributeCommitments; +} TSS_DAA_CREDENTIAL_REQUEST; + +typedef struct tdTSS_DAA_SELECTED_ATTRIB +{ + TSS_VERSION versionInfo; + UINT32 indicesListLength; +#ifdef __midl + [size_is(indicesListLength)] +#endif + TSS_BOOL* indicesList; +} TSS_DAA_SELECTED_ATTRIB; + +typedef struct tdTSS_DAA_PSEUDONYM +{ + TSS_VERSION versionInfo; + TSS_FLAG payloadFlag; + UINT32 payloadLength; +#ifdef __midl + [size_is(payloadLength)] +#endif + BYTE* payload; +} TSS_DAA_PSEUDONYM; + +typedef struct tdTSS_DAA_PSEUDONYM_PLAIN +{ + TSS_VERSION versionInfo; + UINT32 capitalNvLength; +#ifdef __midl + [size_is(capitalNvLength)] +#endif + BYTE* capitalNv; +} TSS_DAA_PSEUDONYM_PLAIN; + +typedef struct tdTSS_DAA_PSEUDONYM_ENCRYPTED +{ + TSS_VERSION versionInfo; + UINT32 delta1Length; +#ifdef __midl + [size_is(delta1Length)] +#endif + BYTE* delta1; + UINT32 delta2Length; +#ifdef __midl + [size_is(delta2Length)] +#endif + BYTE* delta2; + UINT32 delta3Length; +#ifdef __midl + [size_is(delta3Length)] +#endif + BYTE* delta3; + UINT32 delta4Length; +#ifdef __midl + [size_is(delta4Length)] +#endif + BYTE* delta4; + UINT32 sTauLength; +#ifdef __midl + [size_is(sTauLength)] +#endif + BYTE* sTau; +} TSS_DAA_PSEUDONYM_ENCRYPTED; + +typedef struct tdTSS_DAA_SIGN_CALLBACK +{ + TSS_VERSION versionInfo; + TSS_HHASH challenge; + TSS_FLAG payloadFlag; + UINT32 payloadLength; +#ifdef __midl + [size_is(payloadLength)] +#endif + BYTE* payload; +} TSS_DAA_SIGN_CALLBACK; + +typedef struct tdTSS_DAA_SIGNATURE +{ + TSS_VERSION versionInfo; + UINT32 zetaLength; +#ifdef __midl + [size_is(zetaLength)] +#endif + BYTE* zeta; + UINT32 capitalTLength; +#ifdef __midl + [size_is(capitalTLength)] +#endif + BYTE* capitalT; + UINT32 challengeLength; +#ifdef __midl + [size_is(challengeLength)] +#endif + BYTE* challenge; + UINT32 nonceTpmLength; +#ifdef __midl + [size_is(nonceTpmLength)] +#endif + BYTE* nonceTpm; + UINT32 sVLength; +#ifdef __midl + [size_is(sVLength)] +#endif + BYTE* sV; + UINT32 sF0Length; +#ifdef __midl + [size_is(sF0Length)] +#endif + BYTE* sF0; + UINT32 sF1Length; +#ifdef __midl + [size_is(sF1Length)] +#endif + BYTE* sF1; + UINT32 sELength; +#ifdef __midl + [size_is(sELength)] +#endif + BYTE* sE; + UINT32 sALength; // Length of first dimension + UINT32 sALength2; // Length of second dimension +#ifdef __midl + [size_is(sALength,sALength2)] +#endif + BYTE** sA; + UINT32 attributeCommitmentsLength; +#ifdef __midl + [size_is(attributeCommitmentsLength)] +#endif + TSS_DAA_ATTRIB_COMMIT* attributeCommitments; + TSS_DAA_PSEUDONYM signedPseudonym; + TSS_DAA_SIGN_CALLBACK callbackResult; +} TSS_DAA_SIGNATURE; + +typedef struct tdTSS_DAA_IDENTITY_PROOF +{ + TSS_VERSION versionInfo; + UINT32 endorsementLength; +#ifdef __midl + [size_is(endorsementLength)] +#endif + BYTE* endorsementCredential; + UINT32 platformLength; +#ifdef __midl + [size_is(platformLength)] +#endif + BYTE* platform; + UINT32 conformanceLength; +#ifdef __midl + [size_is(conformanceLength)] +#endif + BYTE* conformance; +} TSS_DAA_IDENTITY_PROOF; + + +//////////////////////////////////////////////////////////////////// + +typedef UINT32 TSS_FAMILY_ID; +typedef BYTE TSS_DELEGATION_LABEL; +// Values are TSS_DELEGATIONTYPE_KEY or TSS_DELEGATIONTYPE_OWNER +typedef UINT32 TSS_DELEGATION_TYPE; + +typedef struct tdTSS_PCR_INFO_SHORT +{ + UINT32 sizeOfSelect; +#ifdef __midl + [size_is(sizeOfSelect)] +#endif + BYTE *selection; + BYTE localityAtRelease; + UINT32 sizeOfDigestAtRelease; +#ifdef __midl + [size_is(sizeOfDigestAtRelease)] +#endif + BYTE *digestAtRelease; +} TSS_PCR_INFO_SHORT; + +typedef struct tdTSS_FAMILY_TABLE_ENTRY +{ + TSS_FAMILY_ID familyID; + TSS_DELEGATION_LABEL label; + UINT32 verificationCount; + TSS_BOOL enabled; + TSS_BOOL locked; +} TSS_FAMILY_TABLE_ENTRY; + +typedef struct tdTSS_DELEGATION_TABLE_ENTRY +{ + UINT32 tableIndex; + TSS_DELEGATION_LABEL label; + TSS_PCR_INFO_SHORT pcrInfo; + UINT32 per1; + UINT32 per2; + TSS_FAMILY_ID familyID; + UINT32 verificationCount; +} TSS_DELEGATION_TABLE_ENTRY; + +typedef struct tdTSS_PLATFORM_CLASS +{ + UINT32 platformClassSimpleIdentifier; + UINT32 platformClassURISize; + BYTE* pPlatformClassURI; +} TSS_PLATFORM_CLASS; + +#endif // __TSS_STRUCTS_H__ + diff --git a/illumos-x86_64/usr/include/tss/tss_typedef.h b/illumos-x86_64/usr/include/tss/tss_typedef.h new file mode 100644 index 00000000..269ce00a --- /dev/null +++ b/illumos-x86_64/usr/include/tss/tss_typedef.h @@ -0,0 +1,48 @@ +/*++ + +Global typedefs for TSS + +*/ + +#ifndef __TSS_TYPEDEF_H__ +#define __TSS_TYPEDEF_H__ + +#include + +//-------------------------------------------------------------------- +// definitions for TSS Service Provider (TSP) +// +typedef UINT32 TSS_HANDLE; + +typedef UINT32 TSS_FLAG; // object attributes +typedef UINT32 TSS_RESULT; // the return code from a TSS function + +typedef UINT32 TSS_HOBJECT; // basic object handle +typedef TSS_HOBJECT TSS_HCONTEXT; // context object handle +typedef TSS_HOBJECT TSS_HPOLICY; // policy object handle +typedef TSS_HOBJECT TSS_HTPM; // TPM object handle +typedef TSS_HOBJECT TSS_HKEY; // key object handle +typedef TSS_HOBJECT TSS_HENCDATA; // encrypted data object handle +typedef TSS_HOBJECT TSS_HPCRS; // PCR composite object handle +typedef TSS_HOBJECT TSS_HHASH; // hash object handle +typedef TSS_HOBJECT TSS_HNVSTORE; // NV storage object handle +typedef TSS_HOBJECT TSS_HMIGDATA; // migration data utility obj handle +typedef TSS_HOBJECT TSS_HDELFAMILY; // delegation family object handle +typedef TSS_HOBJECT TSS_HDAA_CREDENTIAL; // daa credential +typedef TSS_HOBJECT TSS_HDAA_ISSUER_KEY; // daa credential issuer keypair +typedef TSS_HOBJECT TSS_HDAA_ARA_KEY; // daa anonymity revocation + // authority keypair + +typedef UINT32 TSS_EVENTTYPE; +typedef UINT16 TSS_MIGRATE_SCHEME; +typedef UINT32 TSS_ALGORITHM_ID; +typedef UINT32 TSS_KEY_USAGE_ID; +typedef UINT16 TSS_KEY_ENC_SCHEME; +typedef UINT16 TSS_KEY_SIG_SCHEME; +typedef BYTE TSS_KEY_AUTH_DATA_USAGE; +typedef UINT32 TSS_CMK_DELEGATE; +typedef UINT32 TSS_NV_INDEX; +typedef UINT32 TSS_COUNTER_ID; + +#endif // __TSS_TYPEDEF_H__ + diff --git a/illumos-x86_64/usr/include/ucd-snmp/agent_index.h b/illumos-x86_64/usr/include/ucd-snmp/agent_index.h new file mode 100644 index 00000000..12851202 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/agent_index.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/agent_read_config.h b/illumos-x86_64/usr/include/ucd-snmp/agent_read_config.h new file mode 100644 index 00000000..5e157b29 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/agent_read_config.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/agent_registry.h b/illumos-x86_64/usr/include/ucd-snmp/agent_registry.h new file mode 100644 index 00000000..ca66cec3 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/agent_registry.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/agent_trap.h b/illumos-x86_64/usr/include/ucd-snmp/agent_trap.h new file mode 100644 index 00000000..dfbfeec5 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/agent_trap.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/asn1.h b/illumos-x86_64/usr/include/ucd-snmp/asn1.h new file mode 100644 index 00000000..078034b7 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/asn1.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/auto_nlist.h b/illumos-x86_64/usr/include/ucd-snmp/auto_nlist.h new file mode 100644 index 00000000..2fcd6682 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/auto_nlist.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/callback.h b/illumos-x86_64/usr/include/ucd-snmp/callback.h new file mode 100644 index 00000000..8fe29cd3 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/callback.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/default_store.h b/illumos-x86_64/usr/include/ucd-snmp/default_store.h new file mode 100644 index 00000000..0274f257 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/default_store.h @@ -0,0 +1,88 @@ +#ifdef UCD_COMPATIBLE + +#include + +/* Compatibility definitions -- see above header for meaningful comments. */ + +#define DS_MAX_IDS NETSNMP_DS_MAX_IDS +#define DS_MAX_SUBIDS NETSNMP_DS_MAX_SUBIDS + +#define DS_LIBRARY_ID NETSNMP_DS_LIBRARY_ID +#define DS_APPLICATION_ID NETSNMP_DS_APPLICATION_ID +#define DS_TOKEN_ID NETSNMP_DS_TOKEN_ID + +#define DS_LIB_MIB_ERRORS NETSNMP_DS_LIB_MIB_ERRORS +#define DS_LIB_SAVE_MIB_DESCRS NETSNMP_DS_LIB_SAVE_MIB_DESCRS +#define DS_LIB_MIB_COMMENT_TERM NETSNMP_DS_LIB_MIB_COMMENT_TERM +#define DS_LIB_MIB_PARSE_LABEL NETSNMP_DS_LIB_MIB_PARSE_LABEL +#define DS_LIB_DUMP_PACKET NETSNMP_DS_LIB_DUMP_PACKET +#define DS_LIB_LOG_TIMESTAMP NETSNMP_DS_LIB_LOG_TIMESTAMP +#define DS_LIB_DONT_READ_CONFIGS NETSNMP_DS_LIB_DONT_READ_CONFIGS +#define DS_LIB_MIB_REPLACE NETSNMP_DS_LIB_MIB_REPLACE +#define DS_LIB_PRINT_NUMERIC_ENUM NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM +#define DS_LIB_PRINT_NUMERIC_OIDS NETSNMP_DS_LIB_PRINT_NUMERIC_OIDS +#define DS_LIB_DONT_BREAKDOWN_OIDS NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS +#define DS_LIB_ALARM_DONT_USE_SIG NETSNMP_DS_LIB_ALARM_DONT_USE_SIG +#define DS_LIB_PRINT_FULL_OID NETSNMP_DS_LIB_PRINT_FULL_OID +#define DS_LIB_QUICK_PRINT NETSNMP_DS_LIB_QUICK_PRINT +#define DS_LIB_RANDOM_ACCESS NETSNMP_DS_LIB_RANDOM_ACCESS +#define DS_LIB_REGEX_ACCESS NETSNMP_DS_LIB_REGEX_ACCESS +#define DS_LIB_DONT_CHECK_RANGE NETSNMP_DS_LIB_DONT_CHECK_RANGE +#define DS_LIB_NO_TOKEN_WARNINGS NETSNMP_DS_LIB_NO_TOKEN_WARNINGS +#define DS_LIB_NUMERIC_TIMETICKS NETSNMP_DS_LIB_NUMERIC_TIMETICKS +#define DS_LIB_ESCAPE_QUOTES NETSNMP_DS_LIB_ESCAPE_QUOTES +#define DS_LIB_REVERSE_ENCODE NETSNMP_DS_LIB_REVERSE_ENCODE +#define DS_LIB_PRINT_BARE_VALUE NETSNMP_DS_LIB_PRINT_BARE_VALUE +#define DS_LIB_EXTENDED_INDEX NETSNMP_DS_LIB_EXTENDED_INDEX +#define DS_LIB_PRINT_HEX_TEXT NETSNMP_DS_LIB_PRINT_HEX_TEXT + +#define DS_LIB_MIB_WARNINGS NETSNMP_DS_LIB_MIB_WARNINGS +#define DS_LIB_SECLEVEL NETSNMP_DS_LIB_SECLEVEL +#define DS_LIB_SNMPVERSION NETSNMP_DS_LIB_SNMPVERSION +#define DS_LIB_DEFAULT_PORT NETSNMP_DS_LIB_DEFAULT_PORT +#define DS_LIB_PRINT_SUFFIX_ONLY NETSNMP_DS_LIB_PRINT_SUFFIX_ONLY + +#define DS_LIB_SECNAME NETSNMP_DS_LIB_SECNAME +#define DS_LIB_CONTEXT NETSNMP_DS_LIB_CONTEXT +#define DS_LIB_PASSPHRASE NETSNMP_DS_LIB_PASSPHRASE +#define DS_LIB_AUTHPASSPHRASE NETSNMP_DS_LIB_AUTHPASSPHRASE +#define DS_LIB_PRIVPASSPHRASE NETSNMP_DS_LIB_PRIVPASSPHRASE +#define DS_LIB_OPTIONALCONFIG NETSNMP_DS_LIB_OPTIONALCONFIG +#define DS_LIB_APPTYPE NETSNMP_DS_LIB_APPTYPE +#define DS_LIB_COMMUNITY NETSNMP_DS_LIB_COMMUNITY +#define DS_LIB_PERSISTENT_DIR NETSNMP_DS_LIB_PERSISTENT_DIR +#define DS_LIB_CONFIGURATION_DIR NETSNMP_DS_LIB_CONFIGURATION_DIR + +#ifdef __cplusplus +extern "C" { +#endif + +int ds_set_boolean (int storeid, int which, int value); +int ds_get_boolean (int storeid, int which); +int ds_toggle_boolean (int storeid, int which); + +int ds_set_int (int storeid, int which, int value); +int ds_get_int (int storeid, int which); + +int ds_set_string (int storeid, int which, const char *value); +char *ds_get_string (int storeid, int which); + +int ds_set_void (int storeid, int which, void *value); +void *ds_get_void (int storeid, int which); + +int ds_register_config (u_char type, const char *ftype, + const char *token, int storeid, int which); +int ds_register_premib (u_char type, const char *ftype, + const char *token, int storeid, int which); + +void ds_shutdown (void); + +#ifdef __cplusplus +} +#endif + +#else /* UCD_COMPATIBLE */ + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/ds_agent.h b/illumos-x86_64/usr/include/ucd-snmp/ds_agent.h new file mode 100644 index 00000000..f8abb2f2 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/ds_agent.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/header_complex.h b/illumos-x86_64/usr/include/ucd-snmp/header_complex.h new file mode 100644 index 00000000..7c7a0d7e --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/header_complex.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/int64.h b/illumos-x86_64/usr/include/ucd-snmp/int64.h new file mode 100644 index 00000000..fe7e56c3 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/int64.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/keytools.h b/illumos-x86_64/usr/include/ucd-snmp/keytools.h new file mode 100644 index 00000000..3049f3f0 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/keytools.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/mib.h b/illumos-x86_64/usr/include/ucd-snmp/mib.h new file mode 100644 index 00000000..08d509ab --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/mib.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/mib_module_config.h b/illumos-x86_64/usr/include/ucd-snmp/mib_module_config.h new file mode 100644 index 00000000..5def4f82 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/mib_module_config.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/mibincl.h b/illumos-x86_64/usr/include/ucd-snmp/mibincl.h new file mode 100644 index 00000000..c15cfb82 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/mibincl.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/parse.h b/illumos-x86_64/usr/include/ucd-snmp/parse.h new file mode 100644 index 00000000..ba3054a1 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/parse.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/read_config.h b/illumos-x86_64/usr/include/ucd-snmp/read_config.h new file mode 100644 index 00000000..460ff273 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/read_config.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/scapi.h b/illumos-x86_64/usr/include/ucd-snmp/scapi.h new file mode 100644 index 00000000..b668c935 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/scapi.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp-tc.h b/illumos-x86_64/usr/include/ucd-snmp/snmp-tc.h new file mode 100644 index 00000000..e15b8fd2 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp-tc.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp.h b/illumos-x86_64/usr/include/ucd-snmp/snmp.h new file mode 100644 index 00000000..030b69d7 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_agent.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_agent.h new file mode 100644 index 00000000..54a5910e --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_agent.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_alarm.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_alarm.h new file mode 100644 index 00000000..6680699e --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_alarm.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_api.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_api.h new file mode 100644 index 00000000..a9c188ab --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_api.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_client.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_client.h new file mode 100644 index 00000000..f2292784 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_client.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_debug.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_debug.h new file mode 100644 index 00000000..83c170e1 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_debug.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_impl.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_impl.h new file mode 100644 index 00000000..2539c5eb --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_impl.h @@ -0,0 +1,11 @@ +#ifdef UCD_COMPATIBLE + +#include +#include +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_logging.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_logging.h new file mode 100644 index 00000000..a4e51d26 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_logging.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_parse_args.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_parse_args.h new file mode 100644 index 00000000..621638db --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_parse_args.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmp_vars.h b/illumos-x86_64/usr/include/ucd-snmp/snmp_vars.h new file mode 100644 index 00000000..66095873 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmp_vars.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmpusm.h b/illumos-x86_64/usr/include/ucd-snmp/snmpusm.h new file mode 100644 index 00000000..98f1207e --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmpusm.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/snmpv3.h b/illumos-x86_64/usr/include/ucd-snmp/snmpv3.h new file mode 100644 index 00000000..7a40e7cb --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/snmpv3.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/struct.h b/illumos-x86_64/usr/include/ucd-snmp/struct.h new file mode 100644 index 00000000..9432815e --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/struct.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/system.h b/illumos-x86_64/usr/include/ucd-snmp/system.h new file mode 100644 index 00000000..ca2096e1 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/system.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/tools.h b/illumos-x86_64/usr/include/ucd-snmp/tools.h new file mode 100644 index 00000000..51483ee9 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/tools.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/transform_oids.h b/illumos-x86_64/usr/include/ucd-snmp/transform_oids.h new file mode 100644 index 00000000..b960afd1 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/transform_oids.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-agent-includes.h b/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-agent-includes.h new file mode 100644 index 00000000..501f7a83 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-agent-includes.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-config.h b/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-config.h new file mode 100644 index 00000000..667a4b79 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-config.h @@ -0,0 +1,2 @@ +#define UCD_COMPATIBLE +#include diff --git a/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-includes.h b/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-includes.h new file mode 100644 index 00000000..df7254bb --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/ucd-snmp-includes.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/util_funcs.h b/illumos-x86_64/usr/include/ucd-snmp/util_funcs.h new file mode 100644 index 00000000..96329a41 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/util_funcs.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/var_struct.h b/illumos-x86_64/usr/include/ucd-snmp/var_struct.h new file mode 100644 index 00000000..747c9cc3 --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/var_struct.h @@ -0,0 +1,9 @@ +#ifdef UCD_COMPATIBLE + +#include + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/ucd-snmp/version.h b/illumos-x86_64/usr/include/ucd-snmp/version.h new file mode 100644 index 00000000..342110bf --- /dev/null +++ b/illumos-x86_64/usr/include/ucd-snmp/version.h @@ -0,0 +1,11 @@ +#ifdef UCD_COMPATIBLE + +#include + +#define VersionInfo NetSnmpVersionInfo + +#else + +#error "Please update your headers or configure using --enable-ucd-snmp-compatibility" + +#endif diff --git a/illumos-x86_64/usr/include/uchar.h b/illumos-x86_64/usr/include/uchar.h new file mode 100644 index 00000000..ac73e895 --- /dev/null +++ b/illumos-x86_64/usr/include/uchar.h @@ -0,0 +1,74 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2020 Robert Mustacchi + */ + +#ifndef _UCHAR_H +#define _UCHAR_H + +/* + * C11 Unicode utilities support. + * + * Note, we do not define either __STDC_UTF_16__ or __STDC_UTF_32__. While the + * functions that are implemented work in that fashion, the ability to represent + * any UTF-16 or UTF-32 code point depends on the current locale. Though in + * practice they function that way. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_SIZE_T) || __cplusplus >= 199711L +#define _SIZE_T +#if defined(_LP64) +typedef unsigned long size_t; /* size of something in bytes */ +#else +typedef unsigned int size_t; /* (historical version) */ +#endif +#endif /* _SIZE_T */ + +#if !defined(_MBSTATE_T) || __cplusplus >= 199711L +#define _MBSTATE_T +typedef __mbstate_t mbstate_t; +#endif /* _MBSTATE_T */ + +/* + * These types must match the uint_least16_t and uint_least32_t. They are + * defined in terms of the same type so as to minimize the needed includes. + * C++11 also defines these types and they are considered built in, so we should + * not define them in that context. + */ +#if __cplusplus < 201103L +typedef unsigned short char16_t; +typedef unsigned int char32_t; +#endif + +extern size_t mbrtoc16(char16_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + size_t, mbstate_t *_RESTRICT_KYWD); +extern size_t mbrtoc32(char32_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + size_t, mbstate_t *_RESTRICT_KYWD); +extern size_t c16rtomb(char *_RESTRICT_KYWD, char16_t, + mbstate_t *_RESTRICT_KYWD); +extern size_t c32rtomb(char *_RESTRICT_KYWD, char32_t, + mbstate_t *_RESTRICT_KYWD); + +#ifdef __cplusplus +} +#endif + +#endif /* _UCHAR_H */ diff --git a/illumos-x86_64/usr/include/ucontext.h b/illumos-x86_64/usr/include/ucontext.h new file mode 100644 index 00000000..687b8950 --- /dev/null +++ b/illumos-x86_64/usr/include/ucontext.h @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2023 Oxide Computer Company + * + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _UCONTEXT_H +#define _UCONTEXT_H + +#include +/* + * The file sys/regset.h defines indices in the gregset_t array, + * such as EIP on i386. Those defines were historically exposed + * via sys/ucontext.h, sys/signal.h, etc. which caused surprises + * due to those defines unexpectedly polluting the namespace. + * On the other hand, several existing applications assume that + * the regset names are defined after an include . + * To solve both problems at once: (this file) + * DOES include sys/regset.h for you but + * does NOT include sys/regset.h anymore. + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __sparc +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname makecontext __makecontext_v2 +#else +#define makecontext __makecontext_v2 +#endif +#endif + +extern int getcontext(ucontext_t *) __RETURNS_TWICE; +#pragma unknown_control_flow(getcontext) +extern int setcontext(const ucontext_t *); +extern int swapcontext(ucontext_t *_RESTRICT_KYWD, + const ucontext_t *_RESTRICT_KYWD); +extern void makecontext(ucontext_t *, void(*)(), int, ...); + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +extern ucontext_t *ucontext_alloc(uint32_t); +extern void ucontext_free(ucontext_t *); +extern int getcontext_extd(ucontext_t *, uint32_t) __RETURNS_TWICE; +#pragma unknown_control_flow(getcontext_extd) +extern int swapcontext_extd(ucontext_t *_RESTRICT_KYWD, uint32_t, + const ucontext_t *_RESTRICT_KYWD); +extern int walkcontext(const ucontext_t *, int (*)(uintptr_t, int, void *), + void *); +extern int printstack(int); +extern int addrtosymstr(void *, char *, int); +extern int getustack(stack_t **); +extern int setustack(stack_t *); + +extern int stack_getbounds(stack_t *); +extern int stack_setbounds(const stack_t *); +extern int stack_inbounds(void *); +extern int stack_violation(int, const siginfo_t *, const ucontext_t *); + +extern void *_stack_grow(void *); +#endif /* !_XPG4_2 || __EXTENSIONS__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UCONTEXT_H */ diff --git a/illumos-x86_64/usr/include/ucred.h b/illumos-x86_64/usr/include/ucred.h new file mode 100644 index 00000000..375e4cef --- /dev/null +++ b/illumos-x86_64/usr/include/ucred.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _UCRED_H_ +#define _UCRED_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ucred_s ucred_t; + +/* + * library functions prototype. + */ + +extern ucred_t *ucred_get(pid_t pid); + +extern void ucred_free(ucred_t *); + +extern uid_t ucred_geteuid(const ucred_t *); +extern uid_t ucred_getruid(const ucred_t *); +extern uid_t ucred_getsuid(const ucred_t *); +extern gid_t ucred_getegid(const ucred_t *); +extern gid_t ucred_getrgid(const ucred_t *); +extern gid_t ucred_getsgid(const ucred_t *); +extern int ucred_getgroups(const ucred_t *, const gid_t **); + +extern const priv_set_t *ucred_getprivset(const ucred_t *, priv_ptype_t); +extern uint_t ucred_getpflags(const ucred_t *, uint_t); + +extern pid_t ucred_getpid(const ucred_t *); /* for door_cred compatibility */ + +extern size_t ucred_size(void); + +extern int getpeerucred(int, ucred_t **); + +extern zoneid_t ucred_getzoneid(const ucred_t *); + +extern bslabel_t *ucred_getlabel(const ucred_t *); + +extern projid_t ucred_getprojid(const ucred_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _UCRED_H_ */ diff --git a/illumos-x86_64/usr/include/uid_stp.h b/illumos-x86_64/usr/include/uid_stp.h new file mode 100644 index 00000000..4ecbfa61 --- /dev/null +++ b/illumos-x86_64/usr/include/uid_stp.h @@ -0,0 +1,202 @@ +/************************************************************************ + * RSTP library - Rapid Spanning Tree (802.1t, 802.1w) + * Copyright (C) 2001-2003 Optical Access + * Author: Alex Rozin + * + * This file is part of RSTP library. + * + * RSTP library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; version 2.1 + * + * RSTP library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with RSTP library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + **********************************************************************/ + +/* External management communication API definitions */ + +#ifndef _UID_STP_H__ +#define _UID_STP_H__ + +#define STP_DBG 1 + +#define NAME_LEN 20 + +typedef enum { + STP_DISABLED, + STP_ENABLED +} UID_STP_MODE_T; + +typedef struct { + unsigned short prio; + unsigned char addr[6]; +} UID_BRIDGE_ID_T; + +typedef struct { + char vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */ + char action; /* 1-create, 0- delete */ +} UID_STP_BR_CTRL_T; + +#define BR_CFG_STATE (1L << 0) +#define BR_CFG_PRIO (1L << 1) +#define BR_CFG_AGE (1L << 2) +#define BR_CFG_HELLO (1L << 3) +#define BR_CFG_DELAY (1L << 4) +#define BR_CFG_FORCE_VER (1L << 5) +#define BR_CFG_AGE_MODE (1L << 6) +#define BR_CFG_AGE_TIME (1L << 7) +#define BR_CFG_HOLD_TIME (1L << 8) +#define BR_CFG_ALL BR_CFG_STATE | \ + BR_CFG_PRIO | \ + BR_CFG_AGE | \ + BR_CFG_HELLO | \ + BR_CFG_DELAY | \ + BR_CFG_FORCE_VER | \ + BR_CFG_AGE_MODE | \ + BR_CFG_AGE_TIME | \ + BR_CFG_HOLD_TIME + +typedef struct { + /* service data */ + unsigned long field_mask; /* which fields to change */ + UID_STP_MODE_T stp_enabled; + char vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */ + + /* protocol data */ + int bridge_priority; + int max_age; + int hello_time; + int forward_delay; + int force_version; + int hold_time; +} UID_STP_CFG_T; + +typedef struct { + /* service data */ + char vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */ + unsigned long vlan_id; + UID_STP_MODE_T stp_enabled; + + /* protocol data */ + UID_BRIDGE_ID_T designated_root; + unsigned long root_path_cost; + + unsigned long timeSince_Topo_Change; /* 14.8.1.1.3.b: TBD */ + unsigned long Topo_Change_Count; /* 14.8.1.1.3.c: TBD */ + unsigned char Topo_Change; /* 14.8.1.1.3.d: TBD */ + + unsigned short root_port; + int max_age; + int hello_time; + int forward_delay; + UID_BRIDGE_ID_T bridge_id; +} UID_STP_STATE_T; + +typedef enum { + UID_PORT_DISABLED = 0, + UID_PORT_DISCARDING, + UID_PORT_LEARNING, + UID_PORT_FORWARDING, + UID_PORT_NON_STP, + UID_PORT_BADSDU +} RSTP_PORT_STATE; + +typedef unsigned short UID_PORT_ID; + +typedef enum { + P2P_FORCE_TRUE, + P2P_FORCE_FALSE, + P2P_AUTO +} ADMIN_P2P_T; + +#define PT_CFG_STATE (1L << 0) +#define PT_CFG_COST (1L << 1) +#define PT_CFG_PRIO (1L << 2) +#define PT_CFG_P2P (1L << 3) +#define PT_CFG_EDGE (1L << 4) +#define PT_CFG_MCHECK (1L << 5) +#define PT_CFG_NON_STP (1L << 6) +#ifdef STP_DBG +#define PT_CFG_DBG_SKIP_RX (1L << 16) +#define PT_CFG_DBG_SKIP_TX (1L << 17) +#endif + +#define PT_CFG_ALL PT_CFG_STATE | \ + PT_CFG_COST | \ + PT_CFG_PRIO | \ + PT_CFG_P2P | \ + PT_CFG_EDGE | \ + PT_CFG_MCHECK | \ + PT_CFG_NON_STP + +#define ADMIN_PORT_PATH_COST_AUTO 0 + +typedef struct { + /* service data */ + unsigned long field_mask; /* which fields to change */ + char vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */ + + /* protocol data */ + int port_priority; + unsigned long admin_port_path_cost; /* ADMIN_PORT_PATH_COST_AUTO - auto sence */ + ADMIN_P2P_T admin_point2point; + unsigned char admin_edge; + unsigned char admin_non_stp; /* 1- doesn't participate in STP, 1 - regular */ +#ifdef STP_DBG + unsigned int skip_rx; + unsigned int skip_tx; +#endif + +} UID_STP_PORT_CFG_T; + +typedef struct { + /* service data */ + char vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */ + unsigned int port_no; /* key of the entry */ + + /* protocol data */ + UID_PORT_ID port_id; + RSTP_PORT_STATE state; + unsigned long path_cost; + + UID_BRIDGE_ID_T designated_root; + unsigned long designated_cost; + UID_BRIDGE_ID_T designated_bridge; + UID_PORT_ID designated_port; + +#if 0 + int infoIs; + unsigned short handshake_flags; +#endif + + unsigned long rx_cfg_bpdu_cnt; + unsigned long rx_rstp_bpdu_cnt; + unsigned long rx_tcn_bpdu_cnt; + int fdWhile; /* 17.15.1 */ + int helloWhen; /* 17.15.2 */ + int mdelayWhile; /* 17.15.3 */ + int rbWhile; /* 17.15.4 */ + int rcvdInfoWhile;/* 17.15.5 */ + int rrWhile; /* 17.15.6 */ + int tcWhile; /* 17.15.7 */ + int txCount; /* 17.18.40 */ + int lnkWhile; + + unsigned long uptime; /* 14.8.2.1.3.a */ + unsigned long oper_port_path_cost; + unsigned char role; + unsigned char oper_point2point; + unsigned char oper_edge; + unsigned char oper_stp_neigb; + unsigned char top_change_ack; + unsigned char tc; +} UID_STP_PORT_STATE_T; + +#endif diff --git a/illumos-x86_64/usr/include/ulimit.h b/illumos-x86_64/usr/include/ulimit.h new file mode 100644 index 00000000..07c9f1f8 --- /dev/null +++ b/illumos-x86_64/usr/include/ulimit.h @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _ULIMIT_H +#define _ULIMIT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern long ulimit(int, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _ULIMIT_H */ diff --git a/illumos-x86_64/usr/include/umem.h b/illumos-x86_64/usr/include/umem.h new file mode 100644 index 00000000..62297be4 --- /dev/null +++ b/illumos-x86_64/usr/include/umem.h @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _UMEM_H +#define _UMEM_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define UMEM_DEFAULT 0x0000 /* normal -- may fail */ +#define UMEM_NOFAIL 0x0100 /* Never fails -- may call exit(2) */ + +#define UMEM_FLAGS 0xffff /* all settable umem flags */ + +extern void *umem_alloc(size_t, int); +extern void *umem_alloc_align(size_t, size_t, int); +extern void *umem_zalloc(size_t, int); +extern void umem_free(void *, size_t); +extern void umem_free_align(void *, size_t); + +/* + * Flags for umem_cache_create() + */ +#define UMC_NOTOUCH 0x00010000 +#define UMC_NODEBUG 0x00020000 +#define UMC_NOMAGAZINE 0x00040000 +#define UMC_NOHASH 0x00080000 + +struct umem_cache; /* cache structure is opaque to umem clients */ + +typedef struct umem_cache umem_cache_t; +typedef int umem_constructor_t(void *, void *, int); +typedef void umem_destructor_t(void *, void *); +typedef void umem_reclaim_t(void *); + +typedef int umem_nofail_callback_t(void); +#define UMEM_CALLBACK_RETRY 0 +#define UMEM_CALLBACK_EXIT(status) (0x100 | ((status) & 0xFF)) + +extern void umem_nofail_callback(umem_nofail_callback_t *); + +extern umem_cache_t *umem_cache_create(char *, size_t, + size_t, umem_constructor_t *, umem_destructor_t *, umem_reclaim_t *, + void *, vmem_t *, int); +extern void umem_cache_destroy(umem_cache_t *); + +extern void *umem_cache_alloc(umem_cache_t *, int); +extern void umem_cache_free(umem_cache_t *, void *); + +extern void umem_reap(void); + +extern void umem_setmtbf(uint32_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _UMEM_H */ diff --git a/illumos-x86_64/usr/include/umem_impl.h b/illumos-x86_64/usr/include/umem_impl.h new file mode 100644 index 00000000..7d5056f1 --- /dev/null +++ b/illumos-x86_64/usr/include/umem_impl.h @@ -0,0 +1,416 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2012 Joyent, Inc. All rights reserved. + * Copyright (c) 2015 by Delphix. All rights reserved. + */ + +#ifndef _UMEM_IMPL_H +#define _UMEM_IMPL_H + +#include + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * umem memory allocator: implementation-private data structures + */ + +/* + * Internal flags for umem_cache_create + */ +#define UMC_QCACHE 0x00100000 +#define UMC_INTERNAL 0x80000000 + +/* + * Cache flags + */ +#define UMF_AUDIT 0x00000001 /* transaction auditing */ +#define UMF_DEADBEEF 0x00000002 /* deadbeef checking */ +#define UMF_REDZONE 0x00000004 /* redzone checking */ +#define UMF_CONTENTS 0x00000008 /* freed-buffer content logging */ +#define UMF_CHECKSIGNAL 0x00000010 /* abort when in signal context */ +#define UMF_NOMAGAZINE 0x00000020 /* disable per-cpu magazines */ +#define UMF_FIREWALL 0x00000040 /* put all bufs before unmapped pages */ +#define UMF_LITE 0x00000100 /* lightweight debugging */ + +#define UMF_HASH 0x00000200 /* cache has hash table */ +#define UMF_RANDOMIZE 0x00000400 /* randomize other umem_flags */ +#define UMF_PTC 0x00000800 /* cache has per-thread caching */ + +#define UMF_CHECKNULL 0x00001000 /* heap exhaustion checking */ + +#define UMF_BUFTAG (UMF_DEADBEEF | UMF_REDZONE) +#define UMF_TOUCH (UMF_BUFTAG | UMF_LITE | UMF_CONTENTS) +#define UMF_RANDOM (UMF_TOUCH | UMF_AUDIT | UMF_NOMAGAZINE) +#define UMF_DEBUG (UMF_RANDOM | UMF_FIREWALL) + +#define UMEM_STACK_DEPTH umem_stack_depth + +#define UMEM_FREE_PATTERN 0xdeadbeefdeadbeefULL +#define UMEM_UNINITIALIZED_PATTERN 0xbaddcafebaddcafeULL +#define UMEM_REDZONE_PATTERN 0xfeedfacefeedfaceULL +#define UMEM_REDZONE_BYTE 0xbb + +#define UMEM_FATAL_FLAGS (UMEM_NOFAIL) +#define UMEM_SLEEP_FLAGS (0) + +/* + * Redzone size encodings for umem_alloc() / umem_free(). We encode the + * allocation size, rather than storing it directly, so that umem_free() + * can distinguish frees of the wrong size from redzone violations. + */ +#define UMEM_SIZE_ENCODE(x) (251 * (x) + 1) +#define UMEM_SIZE_DECODE(x) ((x) / 251) +#define UMEM_SIZE_VALID(x) ((x) % 251 == 1) + +/* + * The bufctl (buffer control) structure keeps some minimal information + * about each buffer: its address, its slab, and its current linkage, + * which is either on the slab's freelist (if the buffer is free), or + * on the cache's buf-to-bufctl hash table (if the buffer is allocated). + * In the case of non-hashed, or "raw", caches (the common case), only + * the freelist linkage is necessary: the buffer address is at a fixed + * offset from the bufctl address, and the slab is at the end of the page. + * + * NOTE: bc_next must be the first field; raw buffers have linkage only. + */ +typedef struct umem_bufctl { + struct umem_bufctl *bc_next; /* next bufctl struct */ + void *bc_addr; /* address of buffer */ + struct umem_slab *bc_slab; /* controlling slab */ +} umem_bufctl_t; + +/* + * The UMF_AUDIT version of the bufctl structure. The beginning of this + * structure must be identical to the normal bufctl structure so that + * pointers are interchangeable. + */ + +#define UMEM_BUFCTL_AUDIT_SIZE_DEPTH(frames) \ + ((size_t)(&((umem_bufctl_audit_t *)0)->bc_stack[frames])) + +/* + * umem_bufctl_audits must be allocated from a UMC_NOHASH cache, so we + * require that 2 of them, plus 2 buftags, plus a umem_slab_t, all fit on + * a single page. + * + * For ILP32, this is about 1000 frames. + * For LP64, this is about 490 frames. + */ + +#define UMEM_BUFCTL_AUDIT_ALIGN 32 + +#define UMEM_BUFCTL_AUDIT_MAX_SIZE \ + (P2ALIGN((PAGESIZE - sizeof (umem_slab_t))/2 - \ + sizeof (umem_buftag_t), UMEM_BUFCTL_AUDIT_ALIGN)) + +#define UMEM_MAX_STACK_DEPTH \ + ((UMEM_BUFCTL_AUDIT_MAX_SIZE - \ + UMEM_BUFCTL_AUDIT_SIZE_DEPTH(0)) / sizeof (uintptr_t)) + +typedef struct umem_bufctl_audit { + struct umem_bufctl *bc_next; /* next bufctl struct */ + void *bc_addr; /* address of buffer */ + struct umem_slab *bc_slab; /* controlling slab */ + umem_cache_t *bc_cache; /* controlling cache */ + hrtime_t bc_timestamp; /* transaction time */ + thread_t bc_thread; /* thread doing transaction */ + struct umem_bufctl *bc_lastlog; /* last log entry */ + void *bc_contents; /* contents at last free */ + int bc_depth; /* stack depth */ + uintptr_t bc_stack[1]; /* pc stack */ +} umem_bufctl_audit_t; + +#define UMEM_LOCAL_BUFCTL_AUDIT(bcpp) \ + *(bcpp) = (umem_bufctl_audit_t *) \ + alloca(UMEM_BUFCTL_AUDIT_SIZE) + +#define UMEM_BUFCTL_AUDIT_SIZE \ + UMEM_BUFCTL_AUDIT_SIZE_DEPTH(UMEM_STACK_DEPTH) + +/* + * A umem_buftag structure is appended to each buffer whenever any of the + * UMF_BUFTAG flags (UMF_DEADBEEF, UMF_REDZONE, UMF_VERIFY) are set. + */ +typedef struct umem_buftag { + uint64_t bt_redzone; /* 64-bit redzone pattern */ + umem_bufctl_t *bt_bufctl; /* bufctl */ + intptr_t bt_bxstat; /* bufctl ^ (alloc/free) */ +} umem_buftag_t; + +#define UMEM_BUFTAG(cp, buf) \ + ((umem_buftag_t *)((char *)(buf) + (cp)->cache_buftag)) + +#define UMEM_BUFCTL(cp, buf) \ + ((umem_bufctl_t *)((char *)(buf) + (cp)->cache_bufctl)) + +#define UMEM_BUF(cp, bcp) \ + ((void *)((char *)(bcp) - (cp)->cache_bufctl)) + +#define UMEM_SLAB(cp, buf) \ + ((umem_slab_t *)P2END((uintptr_t)(buf), (cp)->cache_slabsize) - 1) + +#define UMEM_CPU_CACHE(cp, cpu) \ + (umem_cpu_cache_t *)((char *)cp + cpu->cpu_cache_offset) + +#define UMEM_MAGAZINE_VALID(cp, mp) \ + (((umem_slab_t *)P2END((uintptr_t)(mp), PAGESIZE) - 1)->slab_cache == \ + (cp)->cache_magtype->mt_cache) + +#define UMEM_SLAB_MEMBER(sp, buf) \ + ((size_t)(buf) - (size_t)(sp)->slab_base < \ + (sp)->slab_cache->cache_slabsize) + +#define UMEM_BUFTAG_ALLOC 0xa110c8edUL +#define UMEM_BUFTAG_FREE 0xf4eef4eeUL + +typedef struct umem_slab { + struct umem_cache *slab_cache; /* controlling cache */ + void *slab_base; /* base of allocated memory */ + struct umem_slab *slab_next; /* next slab on freelist */ + struct umem_slab *slab_prev; /* prev slab on freelist */ + struct umem_bufctl *slab_head; /* first free buffer */ + long slab_refcnt; /* outstanding allocations */ + long slab_chunks; /* chunks (bufs) in this slab */ +} umem_slab_t; + +#define UMEM_HASH_INITIAL 64 + +#define UMEM_HASH(cp, buf) \ + ((cp)->cache_hash_table + \ + (((uintptr_t)(buf) >> (cp)->cache_hash_shift) & (cp)->cache_hash_mask)) + +typedef struct umem_magazine { + void *mag_next; + void *mag_round[1]; /* one or more rounds */ +} umem_magazine_t; + +/* + * The magazine types for fast per-cpu allocation + */ +typedef struct umem_magtype { + int mt_magsize; /* magazine size (number of rounds) */ + int mt_align; /* magazine alignment */ + size_t mt_minbuf; /* all smaller buffers qualify */ + size_t mt_maxbuf; /* no larger buffers qualify */ + umem_cache_t *mt_cache; /* magazine cache */ +} umem_magtype_t; + +#define UMEM_CPU_CACHE_SIZE 64 /* must be power of 2 */ +#define UMEM_CPU_PAD (UMEM_CPU_CACHE_SIZE - sizeof (mutex_t) - \ + 2 * sizeof (uint_t) - 2 * sizeof (void *) - 4 * sizeof (int)) +#define UMEM_CACHE_SIZE(ncpus) \ + ((size_t)(&((umem_cache_t *)0)->cache_cpu[ncpus])) + +typedef struct umem_cpu_cache { + mutex_t cc_lock; /* protects this cpu's local cache */ + uint_t cc_alloc; /* allocations from this cpu */ + uint_t cc_free; /* frees to this cpu */ + umem_magazine_t *cc_loaded; /* the currently loaded magazine */ + umem_magazine_t *cc_ploaded; /* the previously loaded magazine */ + int cc_rounds; /* number of objects in loaded mag */ + int cc_prounds; /* number of objects in previous mag */ + int cc_magsize; /* number of rounds in a full mag */ + int cc_flags; /* CPU-local copy of cache_flags */ +#ifndef _LP64 + char cc_pad[UMEM_CPU_PAD]; /* for nice alignment (32-bit) */ +#endif +} umem_cpu_cache_t; + +/* + * The magazine lists used in the depot. + */ +typedef struct umem_maglist { + umem_magazine_t *ml_list; /* magazine list */ + long ml_total; /* number of magazines */ + long ml_min; /* min since last update */ + long ml_reaplimit; /* max reapable magazines */ + uint64_t ml_alloc; /* allocations from this list */ +} umem_maglist_t; + +#define UMEM_CACHE_NAMELEN 31 + +struct umem_cache { + /* + * Statistics + */ + uint64_t cache_slab_create; /* slab creates */ + uint64_t cache_slab_destroy; /* slab destroys */ + uint64_t cache_slab_alloc; /* slab layer allocations */ + uint64_t cache_slab_free; /* slab layer frees */ + uint64_t cache_alloc_fail; /* total failed allocations */ + uint64_t cache_buftotal; /* total buffers */ + uint64_t cache_bufmax; /* max buffers ever */ + uint64_t cache_rescale; /* # of hash table rescales */ + uint64_t cache_lookup_depth; /* hash lookup depth */ + uint64_t cache_depot_contention; /* mutex contention count */ + uint64_t cache_depot_contention_prev; /* previous snapshot */ + + /* + * Cache properties + */ + char cache_name[UMEM_CACHE_NAMELEN + 1]; + size_t cache_bufsize; /* object size */ + size_t cache_align; /* object alignment */ + umem_constructor_t *cache_constructor; + umem_destructor_t *cache_destructor; + umem_reclaim_t *cache_reclaim; + void *cache_private; /* opaque arg to callbacks */ + vmem_t *cache_arena; /* vmem source for slabs */ + int cache_cflags; /* cache creation flags */ + int cache_flags; /* various cache state info */ + int cache_uflags; /* UMU_* flags */ + uint32_t cache_mtbf; /* induced alloc failure rate */ + umem_cache_t *cache_next; /* forward cache linkage */ + umem_cache_t *cache_prev; /* backward cache linkage */ + umem_cache_t *cache_unext; /* next in update list */ + umem_cache_t *cache_uprev; /* prev in update list */ + uint32_t cache_cpu_mask; /* mask for cpu offset */ + + /* + * Slab layer + */ + mutex_t cache_lock; /* protects slab layer */ + size_t cache_chunksize; /* buf + alignment [+ debug] */ + size_t cache_slabsize; /* size of a slab */ + size_t cache_bufctl; /* buf-to-bufctl distance */ + size_t cache_buftag; /* buf-to-buftag distance */ + size_t cache_verify; /* bytes to verify */ + size_t cache_contents; /* bytes of saved content */ + size_t cache_color; /* next slab color */ + size_t cache_mincolor; /* maximum slab color */ + size_t cache_maxcolor; /* maximum slab color */ + size_t cache_hash_shift; /* get to interesting bits */ + size_t cache_hash_mask; /* hash table mask */ + umem_slab_t *cache_freelist; /* slab free list */ + umem_slab_t cache_nullslab; /* end of freelist marker */ + umem_cache_t *cache_bufctl_cache; /* source of bufctls */ + umem_bufctl_t **cache_hash_table; /* hash table base */ + /* + * Depot layer + */ + mutex_t cache_depot_lock; /* protects depot */ + umem_magtype_t *cache_magtype; /* magazine type */ + umem_maglist_t cache_full; /* full magazines */ + umem_maglist_t cache_empty; /* empty magazines */ + + /* + * Per-CPU layer + */ + umem_cpu_cache_t cache_cpu[1]; /* cache_cpu_mask + 1 entries */ +}; + +typedef struct umem_cpu_log_header { + mutex_t clh_lock; + char *clh_current; + size_t clh_avail; + int clh_chunk; + int clh_hits; + char clh_pad[64 - sizeof (mutex_t) - sizeof (char *) - + sizeof (size_t) - 2 * sizeof (int)]; +} umem_cpu_log_header_t; + +typedef struct umem_log_header { + mutex_t lh_lock; + char *lh_base; + int *lh_free; + size_t lh_chunksize; + int lh_nchunks; + int lh_head; + int lh_tail; + int lh_hits; + umem_cpu_log_header_t lh_cpu[1]; /* actually umem_max_ncpus */ +} umem_log_header_t; + +typedef struct umem_cpu { + uint32_t cpu_cache_offset; + uint32_t cpu_number; +} umem_cpu_t; + +#define UMEM_MAXBUF 131072 + +#define UMEM_ALIGN 8 /* min guaranteed alignment */ +#define UMEM_ALIGN_SHIFT 3 /* log2(UMEM_ALIGN) */ +#define UMEM_VOID_FRACTION 8 /* never waste more than 1/8 of slab */ + +/* + * For 64 bits, buffers >= 16 bytes must be 16-byte aligned + */ +#ifdef _LP64 +#define UMEM_SECOND_ALIGN 16 +#else +#define UMEM_SECOND_ALIGN UMEM_ALIGN +#endif + +#define MALLOC_MAGIC 0x3a10c000 /* 8-byte tag */ +#define MEMALIGN_MAGIC 0x3e3a1000 + +#ifdef _LP64 +#define MALLOC_SECOND_MAGIC 0x16ba7000 /* 8-byte tag, 16-aligned */ +#define MALLOC_OVERSIZE_MAGIC 0x06e47000 /* 16-byte tag, _LP64 */ +#endif + +#define UMEM_MALLOC_ENCODE(type, sz) (uint32_t)((type) - (sz)) +#define UMEM_MALLOC_DECODE(stat, sz) (uint32_t)((stat) + (sz)) +#define UMEM_FREE_PATTERN_32 (uint32_t)(UMEM_FREE_PATTERN) + +#define UMU_MAGAZINE_RESIZE 0x00000001 +#define UMU_HASH_RESCALE 0x00000002 +#define UMU_REAP 0x00000004 +#define UMU_NOTIFY 0x08000000 +#define UMU_ACTIVE 0x80000000 + +#define UMEM_READY_INIT_FAILED -1 +#define UMEM_READY_STARTUP 1 +#define UMEM_READY_INITING 2 +#define UMEM_READY 3 + +#ifdef UMEM_STANDALONE +extern void umem_startup(caddr_t, size_t, size_t, caddr_t, caddr_t); +extern int umem_add(caddr_t, size_t); +#endif + +/* + * Private interface with libc for tcumem. + */ +extern uintptr_t _tmem_get_base(void); +extern int _tmem_get_nentries(void); +extern void _tmem_set_cleanup(void(*)(void *, int)); + +#ifdef __cplusplus +} +#endif + +#endif /* _UMEM_IMPL_H */ diff --git a/illumos-x86_64/usr/include/unctrl.h b/illumos-x86_64/usr/include/unctrl.h new file mode 100644 index 00000000..7ba9d1c7 --- /dev/null +++ b/illumos-x86_64/usr/include/unctrl.h @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _UNCTRL_H +#define _UNCTRL_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern char *_unctrl[]; + +#if !defined(NOMACROS) && !defined(__lint) + +#define unctrl(ch) (_unctrl[(unsigned)ch]) + +#endif /* NOMACROS && __lint */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UNCTRL_H */ diff --git a/illumos-x86_64/usr/include/unistd.h b/illumos-x86_64/usr/include/unistd.h new file mode 100644 index 00000000..e93d1023 --- /dev/null +++ b/illumos-x86_64/usr/include/unistd.h @@ -0,0 +1,723 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 PALO, Richard. + * Copyright 2014 Garrett D'Amore + * Copyright (c) 2013 Gary Mills + * + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ + +#ifndef _UNISTD_H +#define _UNISTD_H + +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Symbolic constants for the "access" routine: */ +#define R_OK 4 /* Test for Read permission */ +#define W_OK 2 /* Test for Write permission */ +#define X_OK 1 /* Test for eXecute permission */ +#define F_OK 0 /* Test for existence of File */ + +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +#define F_ULOCK 0 /* Unlock a previously locked region */ +#define F_LOCK 1 /* Lock a region for exclusive use */ +#define F_TLOCK 2 /* Test and lock a region for exclusive use */ +#define F_TEST 3 /* Test a region for other processes locks */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ + +/* Symbolic constants for the "lseek" routine: */ + +#ifndef SEEK_SET +#define SEEK_SET 0 /* Set file pointer to "offset" */ +#endif + +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* Set file pointer to current plus "offset" */ +#endif + +#ifndef SEEK_END +#define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +#ifndef SEEK_DATA +#define SEEK_DATA 3 /* Set file pointer to next data past offset */ +#endif + +#ifndef SEEK_HOLE +#define SEEK_HOLE 4 /* Set file pointer to next hole past offset */ +#endif +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +/* Path names: */ +#define GF_PATH "/etc/group" /* Path name of the "group" file */ +#define PF_PATH "/etc/passwd" /* Path name of the "passwd" file */ +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* + * compile-time symbolic constants, + * Support does not mean the feature is enabled. + * Use pathconf/sysconf to obtain actual configuration value. + */ + +/* Values unchanged in UNIX 03 */ +#define _POSIX_ASYNC_IO 1 +#define _POSIX_JOB_CONTROL 1 +#define _POSIX_SAVED_IDS 1 +#define _POSIX_SYNC_IO 1 + +/* + * POSIX.1b compile-time symbolic constants. + */ +#if defined(_XPG6) +#define _POSIX_ASYNCHRONOUS_IO 200112L +#define _POSIX_FSYNC 200112L +#define _POSIX_MAPPED_FILES 200112L +#define _POSIX_MEMLOCK 200112L +#define _POSIX_MEMLOCK_RANGE 200112L +#define _POSIX_MEMORY_PROTECTION 200112L +#define _POSIX_MESSAGE_PASSING 200112L +#define _POSIX_PRIORITY_SCHEDULING 200112L +#define _POSIX_REALTIME_SIGNALS 200112L +#define _POSIX_SEMAPHORES 200112L +#define _POSIX_SHARED_MEMORY_OBJECTS 200112L +#define _POSIX_SYNCHRONIZED_IO 200112L +#else +#define _POSIX_ASYNCHRONOUS_IO 1 +#define _POSIX_FSYNC 1 +#define _POSIX_MAPPED_FILES 1 +#define _POSIX_MEMLOCK 1 +#define _POSIX_MEMLOCK_RANGE 1 +#define _POSIX_MEMORY_PROTECTION 1 +#define _POSIX_MESSAGE_PASSING 1 +#define _POSIX_PRIORITY_SCHEDULING 1 +#define _POSIX_REALTIME_SIGNALS 1 +#define _POSIX_SEMAPHORES 1 +#define _POSIX_SHARED_MEMORY_OBJECTS 1 +#define _POSIX_SYNCHRONIZED_IO 1 +#endif + +/* + * POSIX.1c compile-time symbolic constants. + */ +#if defined(_XPG6) +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L +#define _POSIX_THREADS 200112L +#define _POSIX_THREAD_ATTR_STACKADDR 200112L +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L +#define _POSIX_THREAD_PROCESS_SHARED 200112L +#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L +#define _POSIX_TIMERS 200112L +#else +#define _POSIX_THREAD_SAFE_FUNCTIONS 1 +#define _POSIX_THREADS 1 +#define _POSIX_THREAD_ATTR_STACKADDR 1 +#define _POSIX_THREAD_ATTR_STACKSIZE 1 +#define _POSIX_THREAD_PROCESS_SHARED 1 +#define _POSIX_THREAD_PRIORITY_SCHEDULING 1 +#define _POSIX_TIMERS 1 +#endif + +/* New in UNIX 03 */ +#define _POSIX_ADVISORY_INFO 200112L +#define _POSIX_BARRIERS 200112L +#define _POSIX_CLOCK_SELECTION 200112L +#define _POSIX_IPV6 200112L +#define _POSIX_MONOTONIC_CLOCK 200112L +#define _POSIX_RAW_SOCKETS 200112L +#define _POSIX_READER_WRITER_LOCKS 200112L +#define _POSIX_SPAWN 200112L +#define _POSIX_SPIN_LOCKS 200112L +#define _POSIX_TIMEOUTS 200112L + +/* + * Support for the POSIX.1 mutex protocol attribute. For realtime applications + * which need mutexes to support priority inheritance/ceiling. + */ +#if defined(_XPG6) +#define _POSIX_THREAD_PRIO_INHERIT 200112L +#define _POSIX_THREAD_PRIO_PROTECT 200112L +#else +#define _POSIX_THREAD_PRIO_INHERIT 1 +#define _POSIX_THREAD_PRIO_PROTECT 1 +#endif + +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE 0 +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +/* + * Large File Summit-related announcement macros. The system supports both + * the additional and transitional Large File Summit interfaces. (The final + * two macros provide a finer granularity breakdown of _LFS64_LARGEFILE.) + */ +#define _LFS_LARGEFILE 1 +#define _LFS64_LARGEFILE 1 +#define _LFS64_STDIO 1 +#define _LFS64_ASYNCHRONOUS_IO 1 + +/* large file compilation environment setup */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname ftruncate ftruncate64 +#pragma redefine_extname lseek lseek64 +#pragma redefine_extname pread pread64 +#pragma redefine_extname pwrite pwrite64 +#pragma redefine_extname truncate truncate64 +#pragma redefine_extname lockf lockf64 +#pragma redefine_extname tell tell64 +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define ftruncate ftruncate64 +#define lseek lseek64 +#define pread pread64 +#define pwrite pwrite64 +#define truncate truncate64 +#define lockf lockf64 +#define tell tell64 +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ + +/* In the LP64 compilation environment, the APIs are already large file */ +#if defined(_LP64) && defined(_LARGEFILE64_SOURCE) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname ftruncate64 ftruncate +#pragma redefine_extname lseek64 lseek +#pragma redefine_extname pread64 pread +#pragma redefine_extname pwrite64 pwrite +#pragma redefine_extname truncate64 truncate +#pragma redefine_extname lockf64 lockf +#pragma redefine_extname tell64 tell +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define ftruncate64 ftruncate +#define lseek64 lseek +#define pread64 pread +#define pwrite64 pwrite +#define truncate64 truncate +#define lockf64 lockf +#define tell64 tell +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* _LP64 && _LARGEFILE64_SOURCE */ + +extern int access(const char *, int); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int acct(const char *); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +extern unsigned alarm(unsigned); +/* Marked as LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \ + defined(__EXTENSIONS__) +extern int brk(void *); +#endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */ +extern int chdir(const char *); +extern int chown(const char *, uid_t, gid_t); +/* Marked as LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_POSIX_C_SOURCE) || (defined(_XOPEN_SOURCE) && \ + !defined(_XPG6)) || defined(__EXTENSIONS__) +extern int chroot(const char *); +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE))... */ +extern int close(int); +#if defined(_XPG4) || defined(__EXTENSIONS__) +extern size_t confstr(int, char *, size_t); +extern char *crypt(const char *, const char *); +#endif /* defined(_XPG4) || defined(__EXTENSIONS__) */ +#if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(__EXTENSIONS__) +extern char *ctermid(char *); +#endif /* (!defined(_POSIX_C_SOURCE) ... */ +#if !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) || defined(__EXTENSIONS__) +extern char *ctermid_r(char *); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) ... */ +/* Marked as LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +extern char *cuserid(char *); +#endif +extern int dup(int); +extern int dup2(int, int); +extern int dup3(int, int, int); +#if defined(_XPG4) || defined(__EXTENSIONS__) +extern void encrypt(char *, int); +#endif /* defined(XPG4) || defined(__EXTENSIONS__) */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern void endusershell(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +extern int execl(const char *, const char *, ...); +extern int execle(const char *, const char *, ...); +extern int execlp(const char *, const char *, ...); +extern int execv(const char *, char *const *); +extern int execve(const char *, char *const *, char *const *); +extern int execvp(const char *, char *const *); +#if defined(_XPG7) || !defined(_STRICT_SYMBOLS) +extern int fexecve(int, char *const[], char *const[]); +#endif +#if !defined(_STRICT_SYMBOLS) +extern int execvpe(const char *, char *const [], char *const []); +extern int syncfs(int); +#endif /* !_STRICT_SYMBOLS */ +extern void _exit(int) + __NORETURN; +/* + * The following fattach prototype is duplicated in . The + * duplication is necessitated by XPG4.2 which requires the prototype + * be defined in . + */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int fattach(int, const char *); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int fchdir(int); +extern int fchown(int, uid_t, gid_t); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int fchroot(int); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \ + defined(__EXTENSIONS__) +extern int fdatasync(int); +#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */ +/* + * The following fdetach prototype is duplicated in . The + * duplication is necessitated by XPG4.2 which requires the prototype + * be defined in . + */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int fdetach(const char *); +#endif /* !defined(__XOPEN_OR_POSIX)... */ +extern pid_t fork(void); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern pid_t fork1(void); +extern pid_t forkall(void); +#endif /* !defined(__XOPEN_OR_POSIX)... */ +extern long fpathconf(int, int); +#if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \ + defined(__EXTENSIONS__) +extern int fsync(int); +#endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */ +#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \ + (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ + defined(__EXTENSIONS__) +extern int ftruncate(int, off_t); +#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */ +extern char *getcwd(char *, size_t); +#if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \ + defined(__EXTENSIONS__) +extern int getdtablesize(void); +#endif +extern gid_t getegid(void); +extern uid_t geteuid(void); +extern gid_t getgid(void); +extern int getgroups(int, gid_t *); +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern long gethostid(void); +#endif +#if defined(_XPG4_2) +extern int gethostname(char *, size_t); +#elif !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int gethostname(char *, int); +#endif + +#ifndef __GETLOGIN_DEFINED /* Avoid duplicate in stdlib.h */ +#define __GETLOGIN_DEFINED +#ifndef __USE_LEGACY_LOGNAME__ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getlogin getloginx +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern char *getloginx(void); +#define getlogin getloginx +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* __USE_LEGACY_LOGNAME__ */ +extern char *getlogin(void); +#endif /* __GETLOGIN_DEFINED */ + +#if defined(_XPG4) || defined(__EXTENSIONS__) +extern int getopt(int, char *const *, const char *); +extern char *optarg; +extern int opterr, optind, optopt; +/* Marked as LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +extern char *getpass(const char *); +#endif +#endif /* defined(_XPG4) || defined(__EXTENSIONS__) */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +/* Marked as LEGACY in SUSv2 and removed in SUSv3 */ +#if !defined(_XPG6) || defined(__EXTENSIONS__) +extern int getpagesize(void); +#endif +extern pid_t getpgid(pid_t); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ +extern pid_t getpid(void); +extern pid_t getppid(void); +extern pid_t getpgrp(void); + +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +char *gettxt(const char *, const char *); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern pid_t getsid(pid_t); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ +extern uid_t getuid(void); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern char *getusershell(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +/* + * The following ioctl prototype is duplicated in . The + * duplication is necessitated by XPG4.2 which requires the prototype + * be defined in . ioctl() is also duplicated in + * for broader portability aid. + */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int ioctl(int, int, ...); +extern int isaexec(const char *, char *const *, char *const *); +extern int issetugid(void); +#endif +extern int isatty(int); +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int lchown(const char *, uid_t, gid_t); +#endif +extern int link(const char *, const char *); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern offset_t llseek(int, offset_t, int); +#endif +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ + (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ + defined(__EXTENSIONS__) +extern int lockf(int, int, off_t); +#endif +extern off_t lseek(int, off_t, int); +#if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(__EXTENSIONS__) +extern int nice(int); +#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int mincore(caddr_t, size_t, char *); +#endif +extern long pathconf(const char *, int); +extern int pause(void); +extern int pipe(int *); +extern int pipe2(int *, int); +#if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \ + (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ + defined(__EXTENSIONS__) +extern ssize_t pread(int, void *, size_t, off_t); +#endif +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern void profil(unsigned short *, size_t, unsigned long, unsigned int); +#endif +/* + * pthread_atfork() is also declared in as per SUSv3. The + * declarations are identical. A change to either one may also require + * appropriate namespace updates in order to avoid redeclaration + * warnings in the case where both prototypes are exposed via inclusion + * of both and . + */ +#if !defined(__XOPEN_OR_POSIX) || \ + ((_POSIX_C_SOURCE > 2) && !defined(_XPG6)) || \ + defined(__EXTENSIONS__) +extern int pthread_atfork(void (*) (void), void (*) (void), void (*) (void)); +#endif /* !defined(__XOPEN_OR_POSIX) || ((_POSIX_C_SOURCE > 2) ... */ +#if !defined(_LP64) && \ + (!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)) +extern int ptrace(int, pid_t, int, int); +#endif +#if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \ + (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ + defined(__EXTENSIONS__) +extern ssize_t pwrite(int, const void *, size_t, off_t); +#endif +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +/* per RFC 3542; This is also defined in netdb.h */ +extern int rcmd_af(char **, unsigned short, const char *, const char *, + const char *, int *, int); +#endif +extern ssize_t read(int, void *, size_t); +#if !defined(__XOPEN_OR_POSIX) || \ + defined(_XPG4_2) || defined(__EXTENSIONS__) +extern ssize_t readlink(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD, + size_t); +#endif +#if (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3) && !defined(_XPG4))) || \ + defined(__EXTENSIONS__) +#if __cplusplus >= 199711L +namespace std { +#endif +extern int rename(const char *, const char *); +#if __cplusplus >= 199711L +} /* end of namespace std */ + +using std::rename; +#endif /* __cplusplus >= 199711L */ +#endif /* (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int resolvepath(const char *, char *, size_t); +/* per RFC 3542; This is also defined in netdb.h */ +extern int rexec_af(char **, unsigned short, const char *, const char *, + const char *, int *, int); +#endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */ +extern int rmdir(const char *); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +/* per RFC 3542; This is also defined in netdb.h */ +extern int rresvport_af(int *, int); +#endif + +#if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \ + defined(__EXTENSIONS__) +extern void *sbrk(intptr_t); +#endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) +extern int setegid(gid_t); +extern int seteuid(uid_t); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */ +extern int setgid(gid_t); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int setgroups(int, const gid_t *); +extern int sethostname(char *, int); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +extern int setpgid(pid_t, pid_t); +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern pid_t setpgrp(void); +extern int setregid(gid_t, gid_t); +extern int setreuid(uid_t, uid_t); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ +extern pid_t setsid(void); +extern int setuid(uid_t); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern void setusershell(void); +#endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */ +extern unsigned sleep(unsigned); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int stime(const time_t *); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +#if defined(_XPG4) +/* __EXTENSIONS__ makes the SVID Third Edition prototype in stdlib.h visible */ +extern void swab(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, ssize_t); +#endif /* defined(_XPG4) */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int symlink(const char *, const char *); +extern void sync(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) */ +#if defined(_XPG5) && !defined(_XPG6) +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname sysconf __sysconf_xpg5 +#else /* __PRAGMA_REDEFINE_EXTNAME */ +#define sysconf __sysconf_xpg5 +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* defined(_XPG5) && !defined(_XPG6) */ +extern long sysconf(int); +extern pid_t tcgetpgrp(int); +extern int tcsetpgrp(int, pid_t); +#if !defined(__XOPEN_OR_POSIX) || \ + (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ + defined(__EXTENSIONS__) +extern off_t tell(int); +#endif /* !defined(__XOPEN_OR_POSIX)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ + (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ + defined(__EXTENSIONS__) +extern int truncate(const char *, off_t); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ +extern char *ttyname(int); +#if (defined(_XPG4_2) && !defined(_XPG7)) || !defined(_STRICT_SYMBOLS) +extern useconds_t ualarm(useconds_t, useconds_t); +#endif +extern int unlink(const char *); +#if (defined(_XPG4_2) && !defined(_XPG7)) || !defined(_STRICT_SYMBOLS) +extern char *getwd(char *); +extern int usleep(useconds_t); +extern pid_t vfork(void) __RETURNS_TWICE; +#pragma unknown_control_flow(vfork) +#endif +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern void vhangup(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ +extern ssize_t write(int, const void *, size_t); +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern void yield(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ + defined(__EXTENSIONS__) + /* || defined(_XPG7) */ +extern int faccessat(int, const char *, int, int); +extern int fchownat(int, const char *, uid_t, gid_t, int); +extern int linkat(int, const char *, int, const char *, int); +extern ssize_t readlinkat(int, const char *_RESTRICT_KYWD, + char *_RESTRICT_KYWD, size_t); +extern int renameat(int, const char *, int, const char *); +extern int symlinkat(const char *, int, const char *); +extern int unlinkat(int, const char *, int); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int get_nprocs(void); +extern int get_nprocs_conf(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + +/* transitional large file interface versions */ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ + !defined(__PRAGMA_REDEFINE_EXTNAME)) +extern int ftruncate64(int, off64_t); +extern off64_t lseek64(int, off64_t, int); +extern ssize_t pread64(int, void *, size_t, off64_t); +extern ssize_t pwrite64(int, const void *, size_t, off64_t); +extern off64_t tell64(int); +extern int truncate64(const char *, off64_t); +extern int lockf64(int, int, off64_t); +#endif /* _LARGEFILE64_SOURCE */ + +/* + * getlogin_r() & ttyname_r() prototypes are defined here. + */ + +/* + * Previous releases of Solaris, starting at 2.3, provided definitions of + * various functions as specified in POSIX.1c, Draft 6. For some of these + * functions, the final POSIX 1003.1c standard had a different number of + * arguments and return values. + * + * The following segment of this header provides support for the standard + * interfaces while supporting applications written under earlier + * releases. The application defines appropriate values of the feature + * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate + * whether it was written to expect the Draft 6 or standard versions of + * these interfaces, before including this header. This header then + * provides a mapping from the source version of the interface to an + * appropriate binary interface. Such mappings permit an application + * to be built from libraries and objects which have mixed expectations + * of the definitions of these functions. + * + * For applications using the Draft 6 definitions, the binary symbol is the + * same as the source symbol, and no explicit mapping is needed. For the + * standard interface, the function func() is mapped to the binary symbol + * _posix_func(). The preferred mechanism for the remapping is a compiler + * #pragma. If the compiler does not provide such a #pragma, the header file + * defines a static function func() which calls the _posix_func() version; + * this has to be done instead of #define since POSIX specifies that an + * application can #undef the symbol and still be bound to the correct + * implementation. Unfortunately, the statics confuse lint so we fallback to + * #define in that case. + * + * NOTE: Support for the Draft 6 definitions is provided for compatibility + * only. New applications/libraries should use the standard definitions. + */ + +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ + !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \ + defined(_POSIX_PTHREAD_SEMANTICS) + +#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) + +#ifndef __USE_LEGACY_LOGNAME__ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getlogin_r __posix_getloginx_r +extern int getlogin_r(char *, int); +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern int __posix_getloginx_r(char *, int); +#define getlogin_r __posix_getloginx_r +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#else /* __USE_LEGACY_LOGNAME__ */ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getlogin_r __posix_getlogin_r +extern int getlogin_r(char *, int); +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern int __posix_getlogin_r(char *, int); + +#ifdef __lint + +#define getlogin_r __posix_getlogin_r + +#else /* !__lint */ + +static int +getlogin_r(char *__name, int __len) +{ + return (__posix_getlogin_r(__name, __len)); +} + +#endif /* !__lint */ +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* __USE_LEGACY_LOGNAME__ */ + +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname ttyname_r __posix_ttyname_r +extern int ttyname_r(int, char *, size_t); +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern int __posix_ttyname_r(int, char *, size_t); + +#ifdef __lint + +#define ttyname_r __posix_ttyname_r + +#else /* !__lint */ + +static int +ttyname_r(int __fildes, char *__buf, size_t __size) +{ + return (__posix_ttyname_r(__fildes, __buf, __size)); +} + +#endif /* !__lint */ +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +#ifndef __USE_LEGACY_LOGNAME__ +#ifdef __PRAGMA_REDEFINE_EXTNAME +#pragma redefine_extname getlogin_r getloginx_r +#else /* __PRAGMA_REDEFINE_EXTNAME */ +extern char *getloginx_r(char *, int); +#define getlogin_r getloginx_r +#endif /* __PRAGMA_REDEFINE_EXTNAME */ +#endif /* __USE_LEGACY_LOGNAME__ */ +extern char *getlogin_r(char *, int); + +extern char *ttyname_r(int, char *, int); + +#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ + +#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */ + +#if !defined(_STRICT_SYMBOLS) +extern int getentropy(void *, size_t); +#endif /* !_STRICT_SYMBOLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UNISTD_H */ diff --git a/illumos-x86_64/usr/include/upanic.h b/illumos-x86_64/usr/include/upanic.h new file mode 100644 index 00000000..be34d02b --- /dev/null +++ b/illumos-x86_64/usr/include/upanic.h @@ -0,0 +1,36 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2020 Oxide Computer Company + */ + +#ifndef _UPANIC_H +#define _UPANIC_H + +/* + * Support for guaranteed user process abort-like termination. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern _NORETURN_KYWD void upanic(const char *, size_t) __NORETURN; + +#ifdef __cplusplus +} +#endif + +#endif /* _UPANIC_H */ diff --git a/illumos-x86_64/usr/include/user_attr.h b/illumos-x86_64/usr/include/user_attr.h new file mode 100644 index 00000000..15169c06 --- /dev/null +++ b/illumos-x86_64/usr/include/user_attr.h @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _USER_ATTR_H +#define _USER_ATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include +#include + + +struct __FILE; /* structure tag for type FILE defined in stdio.h */ + +/* + * Some macros used internally by the nsswitch code + */ +#define USERATTR_FILENAME "/etc/user_attr" +#define USERATTR_DB_NAME "user_attr.org_dir" +#define USERATTR_DB_NCOL 5 /* total columns */ +#define USERATTR_DB_NKEYCOL 2 /* total searchable columns */ +#define USERATTR_DB_TBL "user_attr_tbl" +#define USERATTR_NAME_DEFAULT_KW "nobody" + +#define USERATTR_COL0_KW "name" +#define USERATTR_COL1_KW "qualifier" +#define USERATTR_COL2_KW "res1" +#define USERATTR_COL3_KW "res2" +#define USERATTR_COL4_KW "attr" + +#define DEF_LIMITPRIV "PRIV_LIMIT=" +#define DEF_DFLTPRIV "PRIV_DEFAULT=" + +/* + * indices of searchable columns + */ +#define USERATTR_KEYCOL0 0 /* name */ +#define USERATTR_KEYCOL1 1 /* qualifier */ + +/* + * Key words used in the user_attr database + */ +#define USERATTR_LOCK_KW "lock" +#define USERATTR_LOCK_LOCKED_KW "locked" +#define USERATTR_LOCK_OPEN_KW "open" +#define USERATTR_LOCK_FIXED_KW "fixed" +#define USERATTR_GEN_KW "gen" +#define USERATTR_GEN_AUTOMATIC_KW "automatic" +#define USERATTR_GEN_MANUAL_KW "manual" +#define USERATTR_GEN_SYSDEF_KW "sysdef" +#define USERATTR_PROFILES_KW "profiles" +#define USERATTR_PROFILES_NONE_KW "none" +#define USERATTR_ROLES_KW "roles" +#define USERATTR_ROLES_NONE_KW "none" +#define USERATTR_DEFAULTPROJ_KW "project" +#define USERATTR_TYPE_KW "type" +#define USERATTR_TYPE_NORMAL_KW "normal" +#define USERATTR_TYPE_ADMIN_KW "admin" +#define USERATTR_TYPE_NONADMIN_KW "role" +#define USERATTR_AUTHS_KW "auths" +#define USERATTR_LIMPRIV_KW "limitpriv" +#define USERATTR_DFLTPRIV_KW "defaultpriv" +#define USERATTR_LOCK_AFTER_RETRIES_KW "lock_after_retries" +#define USERATTR_CLEARANCE "clearance" +#define USERATTR_LABELVIEW "labelview" +#define USERATTR_LABELVIEW_EXTERNAL "external" +#define USERATTR_LABELVIEW_HIDESL "hidesl" +#define USERATTR_HIDESL USERATTR_LABELVIEW_HIDESL +#define USERATTR_LABELVIEW_INTERNAL "internal" +#define USERATTR_LABELVIEW_SHOWSL "showsl" +#define USERATTR_LABELTRANS "labeltrans" +#define USERATTR_LOCK_NO "no" +#define USERATTR_LOCK_YES "yes" +#define USERATTR_MINLABEL "min_label" +#define USERATTR_PASSWD "password" +#define USERATTR_PASSWD_AUTOMATIC "automatic" +#define USERATTR_PASSWD_MANUAL "manual" +#define USERATTR_TYPE_ROLE USERATTR_TYPE_NONADMIN_KW +#define USERATTR_AUDIT_FLAGS_KW "audit_flags" +#define USERATTR_ROLEAUTH_KW "roleauth" +#define USERATTR_ROLEAUTH_USER "user" +#define USERATTR_ROLEAUTH_ROLE "role" + + +/* + * Nsswitch representation of user attributes. + */ +typedef struct userstr_s { + char *name; /* user name */ + char *qualifier; /* reserved for future use */ + char *res1; /* reserved for future use */ + char *res2; /* reserved for future use */ + char *attr; /* string of key-value pair attributes */ +} userstr_t; + +/* + * API representation of user attributes. + */ +typedef struct userattr_s { + char *name; /* user name */ + char *qualifier; /* reserved for future use */ + char *res1; /* reserved for future use */ + char *res2; /* reserved for future use */ + kva_t *attr; /* array of key-value pair attributes */ +} userattr_t; + +extern userattr_t *getusernam(const char *); +extern userattr_t *getuseruid(uid_t uid); +extern userattr_t *getuserattr(void); +extern userattr_t *fgetuserattr(struct __FILE *); +extern void setuserattr(void); +extern void enduserattr(void); +extern void free_userattr(userattr_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _USER_ATTR_H */ diff --git a/illumos-x86_64/usr/include/userdefs.h b/illumos-x86_64/usr/include/userdefs.h new file mode 100644 index 00000000..39608f06 --- /dev/null +++ b/illumos-x86_64/usr/include/userdefs.h @@ -0,0 +1,177 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + +#ifndef _USERDEFS_H +#define _USERDEFS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The definitions in this file are local to the OA&M subsystem. General + * use is not encouraged. + */ + +/* User/group default values */ +#define DEFGID 99 /* max reserved group id */ +#define DEFRID 99 +#define DEFPROJ 3 +#define DEFPROJNAME "default" +#define DEFGROUP 1 +#define DEFGNAME "other" +#define DEFPARENT "/home" +#define DEFSKL "/etc/skel" +#define DEFSHL "/bin/sh" +#define DEFROLESHL "/bin/pfsh" +#define DEFINACT 0 +#define DEFEXPIRE "" +#define DEFAUTH "" +#define DEFPROF "" +#define DEFROLEPROF "All" +#define DEFROLE "" +#define DEFLIMPRIV "" +#define DEFDFLTPRIV "" +#define DEFLOCK_AFTER_RETRIES "" +#define DEFROLEAUTH "" +#define DEFROLEROLEAUTH "role" + +/* Defaults file keywords */ +#define RIDSTR "defrid=" +#define GIDSTR "defgroup=" +#define GNAMSTR "defgname=" +#define PARSTR "defparent=" +#define SKLSTR "defskel=" +#define SHELLSTR "defshell=" +#define INACTSTR "definact=" +#define EXPIRESTR "defexpire=" +#define AUTHSTR "defauthorization=" +#define PROFSTR "defprofile=" +#define ROLESTR "defrole=" +#define PROJSTR "defproj=" +#define PROJNMSTR "defprojname=" +#define LIMPRSTR "deflimitpriv=" +#define DFLTPRSTR "defdefaultpriv=" +#define FHEADER "# Default values for useradd. Changed " +#define FHEADER_ROLE "# Default values for roleadd. Changed " +#define LOCK_AFTER_RETRIESSTR "deflock_after_retries=" +#define ROLEAUTHSTR "defroleauth=" + +/* Defaults file */ +#define DEFFILE "/usr/sadm/defadduser" +#define DEFROLEFILE "/usr/sadm/defaddrole" +#define GROUP "/etc/group" + +/* various limits */ +#define MAXGLEN 9 /* max length of group name */ +#define MAXDLEN 80 /* max length of a date string */ + +/* defaults structure */ +struct userdefs { + int defrid; /* highest reserved uid */ + int defgroup; /* default group id */ + char *defgname; /* default group name */ + char *defparent; /* default base directory for new logins */ + char *defskel; /* default skel directory */ + char *defshell; /* default shell */ + int definact; /* default inactive */ + char *defexpire; /* default expire date */ + char *defauth; /* default authorization */ + char *defprof; /* default profile */ + char *defrole; /* default role */ + projid_t defproj; /* default project id */ + char *defprojname; /* default project name */ + char *deflimpriv; /* default limitpriv */ + char *defdfltpriv; /* default defaultpriv */ + char *deflock_after_retries; /* default lock_after_retries */ + char *defroleauth; /* default roleauth */ + +}; + +/* exit() values for user/group commands */ + +/* Everything succeeded */ +#define EX_SUCCESS 0 + +/* No permission */ +#define EX_NO_PERM 1 + +/* Command syntax error */ +#define EX_SYNTAX 2 + +/* Invalid argument given */ +#define EX_BADARG 3 + +/* A gid or uid already exists */ +#define EX_ID_EXISTS 4 + +/* PASSWD and SHADOW are inconsistent with each other */ +#define EX_INCONSISTENT 5 + +/* A group or user name doesn't exist */ +#define EX_NAME_NOT_EXIST 6 + +/* GROUP, PASSWD, or SHADOW file missing */ +#define EX_MISSING 7 + +/* GROUP, PASSWD, or SHAWOW file is busy */ +#define EX_BUSY 8 + +/* A group or user name already exists */ +#define EX_NAME_EXISTS 9 + +/* Unable to update GROUP, PASSWD, or SHADOW file */ +#define EX_UPDATE 10 + +/* Not enough space */ +#define EX_NOSPACE 11 + +/* Unable to create/remove/move home directory */ +#define EX_HOMEDIR 12 + +/* new login already in use */ +#define EX_NL_USED 13 + +/* Unexpected failure */ +#define EX_FAILURE 14 + +/* A user name is in a non-local name service */ +#define EX_NOT_LOCAL 15 + +#ifdef __cplusplus +} +#endif + +#endif /* _USERDEFS_H */ diff --git a/illumos-x86_64/usr/include/ustat.h b/illumos-x86_64/usr/include/ustat.h new file mode 100644 index 00000000..df0d7f45 --- /dev/null +++ b/illumos-x86_64/usr/include/ustat.h @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _USTAT_H +#define _USTAT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int ustat(dev_t, struct ustat *); + +#ifdef __cplusplus +} +#endif + +#endif /* _USTAT_H */ diff --git a/illumos-x86_64/usr/include/utempter.h b/illumos-x86_64/usr/include/utempter.h new file mode 100644 index 00000000..fab58d94 --- /dev/null +++ b/illumos-x86_64/usr/include/utempter.h @@ -0,0 +1,47 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2009 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _UTEMPTER_H +#define _UTEMPTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +int utempter_add_record(int, const char *); +int utempter_remove_added_record(void); +int utempter_remove_record(int); +void addToUtmp(const char *, const char *, int); +void removeFromUtmp(void); +void removeLineFromUtmp(const char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* !_UTEMPTER_H */ diff --git a/illumos-x86_64/usr/include/utility.h b/illumos-x86_64/usr/include/utility.h new file mode 100644 index 00000000..c49d5aa0 --- /dev/null +++ b/illumos-x86_64/usr/include/utility.h @@ -0,0 +1,264 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _UTILITY_H +#define _UTILITY_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* miscellaneous #defines */ +typedef int BOOLEAN; + +#define MIN(x, y) ((x) < (y) ? (x) : (y)) + +/* form status flags */ +#define POSTED 0x0001 /* posted flag */ +#define DRIVER 0x0002 /* inside init/term routine */ +#define OVERLAY 0x0004 /* insert/overlay mode */ +#define WIN_CHG 0x0010 /* window change (system flag) */ +#define BUF_CHG 0x0020 /* buffer change (system flag) */ +/* field status flags */ +#define USR_CHG 0x0001 /* buffer change (user's flag) */ +#define TOP_CHG 0x0002 /* toprow change (system flag) */ +#define NEW_PAGE 0x0004 /* new page (system flag) */ +#define GROWABLE 0x0008 /* growable page (system flag) */ +/* field type status flags */ +#define LINKED 0x0001 /* conjunctive field type */ +#define ARGS 0x0002 /* has additional arguments */ +#define CHOICE 0x0004 /* has choice functions */ +/* form/field/fieldtype status manipulation macros */ +#define Status(f, s) ((f) -> status & (s)) +#define Set(f, s) ((f) -> status |= (s)) +#define Clr(f, s) ((f) -> status &= ~(s)) +/* form/field option manipulation macros */ +#define Opt(f, x) ((f) -> opts & (x)) +/* alloc/free with check */ +#define Alloc(x, t) ((x = (t *) malloc(sizeof (t))) != (t *)0) +#define arrayAlloc(x, n, t) ((x = (t *) malloc((n) * sizeof (t))) != \ + (t *)0) +#define Free(x) { if (x) free(x); } +/* field type macros */ +#define MakeArg(f, p, err) (_makearg((f) -> type, p, err)) +#define CopyArg(f, err) (_copyarg((f) -> type, (f) -> arg, err)) +#define FreeArg(f) (_freearg((f) -> type, (f) -> arg)) +#define CheckField(f) (_checkfield((f) -> type, (f), (f) -> arg)) +#define CheckChar(f, c) (_checkchar((f) -> type, (c), (f) -> arg)) +#define NextChoice(f) (_nextchoice((f) -> type, (f), (f) -> arg)) +#define PrevChoice(f) (_prevchoice((f) -> type, (f), (f) -> arg)) +#define IncrType(type) { if (type) ++(type -> ref); } +#define DecrType(type) { if (type) --(type -> ref); } +/* form/field init/term calls */ +#define init_field(f) { \ + if ((f) -> fieldinit) \ + { \ + Set(f, DRIVER); \ + (*(f) -> fieldinit)(f); \ + Clr(f, DRIVER); \ + } \ + } +#define term_field(f) { \ + if ((f) -> fieldterm) \ + { \ + Set(f, DRIVER); \ + (*(f) -> fieldterm)(f); \ + Clr(f, DRIVER); \ + } \ + } +#define init_form(f) { \ + if ((f) -> forminit) \ + { \ + Set(f, DRIVER); \ + (*(f) -> forminit)(f); \ + Clr(f, DRIVER); \ + } \ + } +#define term_form(f) { \ + if ((f) -> formterm) \ + { \ + Set(f, DRIVER); \ + (*(f) -> formterm)(f); \ + Clr(f, DRIVER); \ + } \ + } +/* page macros */ +#define P(f) ((f) -> curpage) +#define Pmin(f, p) ((f) -> page [p].pmin) +#define Pmax(f, p) ((f) -> page [p].pmax) +#define Smin(f, p) ((f) -> page [p].smin) +#define Smax(f, p) ((f) -> page [p].smax) +/* form macros */ +#define Form(f) ((f) ? (f) : _DEFAULT_FORM) +#define ValidIndex(f, i) ((i) >= 0 && (i) < (f) -> maxfield) +#define ValidPage(f, i) ((i) >= 0 && (i) < (f) -> maxpage) +#define C(f) ((f) -> current) +#define W(f) ((f) -> w) +#define X(f) ((f) -> curcol) +#define Y(f) ((f) -> currow) +#define T(f) ((f) -> toprow) +#define B(f) ((f) -> begincol) +#define Xmax(f) (C(f) -> dcols) +#define Ymax(f) (C(f) -> drows) +#define Win(f) ((f) -> win ? (f) -> win : stdscr) +#define Sub(f) ((f) -> sub ? (f) -> sub : Win(f)) +/* field macros */ +#define Field(f) ((f) ? (f) : _DEFAULT_FIELD) +#define Buf(f) ((f) -> buf) +#define OneRow(f) ((f)->rows + (f)->nrow == 1) +#define GrowSize(f) (((f) -> rows + (f) -> nrow) * (f) -> cols) +#define BufSize(f) ((f) -> drows * (f) -> dcols) +#define Buffer(f, n) (Buf(f) + (n) * (BufSize(f) + 1)) +#define LineBuf(f, n) (Buf(f) + (n) * (f) -> dcols) +#define TotalBuf(f) ((BufSize(f) + 1) * ((f) -> nbuf + 1)) +#define Just(f) ((f) -> just) +#define Fore(f) ((f) -> fore) +#define Back(f) ((f) -> back) +#define Pad(f) ((f) -> pad) +/* system externs */ +extern int _next_page(FORM *); /* REQ_NEXT_PAGE */ +extern int _prev_page(FORM *); /* REQ_PREV_PAGE */ +extern int _first_page(FORM *); /* REQ_FIRST_PAGE */ +extern int _last_page(FORM *); /* REQ_LAST_PAGE */ + +extern int _next_field(FORM *); /* REQ_NEXT_FIELD */ +extern int _prev_field(FORM *); /* REQ_PREV_FIELD */ +extern int _first_field(FORM *); /* REQ_FIRST_FIELD */ +extern int _last_field(FORM *); /* REQ_LAST_FIELD */ +extern int _snext_field(FORM *); /* REQ_SNEXT_FIELD */ +extern int _sprev_field(FORM *); /* REQ_SPREV_FIELD */ +extern int _sfirst_field(FORM *); /* REQ_SFIRST_FIELD */ +extern int _slast_field(FORM *); /* REQ_SLAST_FIELD */ +extern int _left_field(FORM *); /* REQ_LEFT_FIELD */ +extern int _right_field(FORM *); /* REQ_RIGHT_FIELD */ +extern int _up_field(FORM *); /* REQ_UP_FIELD */ +extern int _down_field(FORM *); /* REQ_DOWN_FIELD */ + +extern int _next_char(FORM *); /* REQ_NEXT_CHAR */ +extern int _prev_char(FORM *); /* REQ_PREV_CHAR */ +extern int _next_line(FORM *); /* REQ_NEXT_LINE */ +extern int _prev_line(FORM *); /* REQ_PREV_LINE */ +extern int _next_word(FORM *); /* REQ_NEXT_WORD */ +extern int _prev_word(FORM *); /* REQ_PREV_WORD */ +extern int _beg_field(FORM *); /* REQ_BEG_FIELD */ +extern int _end_field(FORM *); /* REQ_END_FIELD */ +extern int _beg_line(FORM *); /* REQ_BEG_LINE */ +extern int _end_line(FORM *); /* REQ_END_LINE */ +extern int _left_char(FORM *); /* REQ_LEFT_CHAR */ +extern int _right_char(FORM *); /* REQ_RIGHT_CHAR */ +extern int _up_char(FORM *); /* REQ_UP_CHAR */ +extern int _down_char(FORM *); /* REQ_DOWN_CHAR */ + +extern int _new_line(FORM *); /* REQ_NEW_LINE */ +extern int _ins_char(FORM *); /* REQ_INS_CHAR */ +extern int _ins_line(FORM *); /* REQ_INS_LINE */ +extern int _del_char(FORM *); /* REQ_DEL_CHAR */ +extern int _del_prev(FORM *); /* REQ_DEL_PREV */ +extern int _del_line(FORM *); /* REQ_DEL_LINE */ +extern int _del_word(FORM *); /* REQ_DEL_WORD */ +extern int _clr_eol(FORM *); /* REQ_CLR_EOL */ +extern int _clr_eof(FORM *); /* REQ_CLR_EOF */ +extern int _clr_field(FORM *); /* REQ_CLR_FIELD */ +extern int _ovl_mode(FORM *); /* REQ_OVL_MODE */ +extern int _ins_mode(FORM *); /* REQ_INS_MODE */ +extern int _scr_fline(FORM *); /* REQ_SCR_FLINE */ +extern int _scr_bline(FORM *); /* REQ_SCR_BLINE */ +extern int _scr_fpage(FORM *); /* REQ_SCR_FPAGE */ +extern int _scr_fhpage(FORM *); /* REQ_SCR_FHPAGE */ +extern int _scr_bpage(FORM *); /* REQ_SCR_BPAGE */ +extern int _scr_bhpage(FORM *); /* REQ_SCR_BHPAGE */ + +extern int _scr_fchar(FORM *); /* REQ_SCR_FCHAR */ +extern int _scr_bchar(FORM *); /* REQ_SCR_BCHAR */ +extern int _scr_hfline(FORM *); /* REQ_SCR_HFLINE */ +extern int _scr_hbline(FORM *); /* REQ_SCR_HBLINE */ +extern int _scr_hfhalf(FORM *); /* REQ_SCR_HFHALF */ +extern int _scr_hbhalf(FORM *); /* REQ_SCR_HBHALF */ + +extern int _validation(FORM *); /* REQ_VALIDATION */ +extern int _next_choice(FORM *); /* REQ_NEXT_CHOICE */ +extern int _prev_choice(FORM *); /* REQ_PREV_CHOICE */ + +extern char * _makearg(FIELDTYPE *, va_list *, int *); +extern char * _copyarg(FIELDTYPE *, char *, int *); +extern void _freearg(FIELDTYPE *, char *); +extern int _checkfield(FIELDTYPE *, FIELD *, char *); +extern int _checkchar(FIELDTYPE *, int, char *); +extern int _nextchoice(FIELDTYPE *, FIELD *, char *); +extern int _prevchoice(FIELDTYPE *, FIELD *, char *); + +extern BOOLEAN _grow_field(FIELD *, int); +extern FIELD * _first_active(FORM *); +extern char * _data_beg(char *, int); +extern char * _data_end(char *, int); +extern char * _whsp_beg(char *, int); +extern char * _whsp_end(char *, int); +extern void _buf_to_win(FIELD *, WINDOW *); +extern void _win_to_buf(WINDOW *, FIELD *); +extern void _adjust_cursor(FORM *, char *); +extern void _sync_buffer(FORM *); +extern int _sync_linked(FIELD *); +extern int _sync_field(FIELD *); +extern int _sync_attrs(FIELD *); +extern int _sync_opts(FIELD *, OPTIONS); +extern int _validate(FORM *); +extern int _set_current_field(FORM *, FIELD *); +extern int _set_form_page(FORM *, int, FIELD *); +extern int _pos_form_cursor(FORM *); +extern int _update_current(FORM *); +extern int _data_entry(FORM *, int); +extern int _page_navigation(PTF_int, FORM *); +extern int _field_navigation(PTF_int, FORM *); +extern int _data_navigation(PTF_int, FORM *); +extern int _data_manipulation(PTF_int, FORM *); +extern int _misc_request(PTF_int, FORM *); + +extern intptr_t __execute(char *, char *); +extern intptr_t __advance(char *, char *); +extern intptr_t __xpop(intptr_t); +extern intptr_t __xpush(intptr_t, char *); +extern intptr_t __getrnge(intptr_t *, intptr_t *, char *); +extern intptr_t __cclass(char *, char, intptr_t); +extern int __size(char *); +extern int __rpush(char *); +extern intptr_t __rpop(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _UTILITY_H */ diff --git a/illumos-x86_64/usr/include/utime.h b/illumos-x86_64/usr/include/utime.h new file mode 100644 index 00000000..90e0f559 --- /dev/null +++ b/illumos-x86_64/usr/include/utime.h @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* utimbuf is used by utime(2) */ + +#ifndef _UTIME_H +#define _UTIME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int utime(const char *, const struct utimbuf *); + +#ifdef __cplusplus +} +#endif + +#endif /* _UTIME_H */ diff --git a/illumos-x86_64/usr/include/utmp.h b/illumos-x86_64/usr/include/utmp.h new file mode 100644 index 00000000..dd7458fc --- /dev/null +++ b/illumos-x86_64/usr/include/utmp.h @@ -0,0 +1,168 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _UTMP_H +#define _UTMP_H + +/* + * Note: The getutent(3c) family of interfaces are obsolete. + * The getutxent(3c) family provide a superset of this functionality + * and should be used in place of getutent(3c). + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define UTMP_FILE "/var/adm/utmp" +#define WTMP_FILE "/var/adm/wtmp" +#endif + +#define ut_name ut_user + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +struct exit_status { + short e_termination; /* Process termination status */ + short e_exit; /* Process exit status */ +}; +#else +struct ut_exit_status { + short ut_e_termination; /* Process termination status */ + short ut_e_exit; /* Process exit status */ +}; +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + +/* + * This data structure describes the utmp entries returned by + * the getutent(3c) family of APIs. It does not (necessarily) + * correspond to the contents of the utmp or wtmp files. + * + * Applications should only interact with this subsystem via + * the getutxent(3c) family of APIs, as the getutent(3c) family + * are obsolete. + */ +struct utmp { + char ut_user[8]; /* User login name */ + char ut_id[4]; /* /etc/inittab id(usually line #) */ + char ut_line[12]; /* device name (console, lnxx) */ + short ut_pid; /* short for compat. - process id */ + short ut_type; /* type of entry */ + struct exit_status ut_exit; /* The exit status of a process */ + /* marked as DEAD_PROCESS. */ + time_t ut_time; /* time entry was made */ +}; + +#include +#include + +/* + * This data structure describes the utmp *file* contents using + * fixed-width data types. It should only be used by the implementation. + * + * Applications should use the getutxent(3c) family of routines to interact + * with this database. + */ + +struct futmp { + char ut_user[8]; /* User login name */ + char ut_id[4]; /* /etc/inittab id */ + char ut_line[12]; /* device name (console, lnxx) */ + int16_t ut_pid; /* process id */ + int16_t ut_type; /* type of entry */ + struct { + int16_t e_termination; /* Process termination status */ + int16_t e_exit; /* Process exit status */ + } ut_exit; /* The exit status of a process */ + time32_t ut_time; /* time entry was made */ +}; + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* Definitions for ut_type */ + +#define EMPTY 0 +#define RUN_LVL 1 +#define BOOT_TIME 2 +#define OLD_TIME 3 +#define NEW_TIME 4 +#define INIT_PROCESS 5 /* Process spawned by "init" */ +#define LOGIN_PROCESS 6 /* A "getty" process waiting for login */ +#define USER_PROCESS 7 /* A user process */ +#define DEAD_PROCESS 8 + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + +#define ACCOUNTING 9 +#define DOWN_TIME 10 + +#define UTMAXTYPE DOWN_TIME /* Largest legal value of ut_type */ + +/* Special strings or formats used in the "ut_line" field when */ +/* accounting for something other than a process. */ +/* No string for the ut_line field can be more than 11 chars + */ +/* a NULL in length. */ + +#define RUNLVL_MSG "run-level %c" +#define BOOT_MSG "system boot" +#define OTIME_MSG "old time" +#define NTIME_MSG "new time" +#define PSRADM_MSG "%03d %s" /* processor on or off */ +#define DOWN_MSG "system down" + +/* Define and macro for determing if a normal user wrote the entry */ +/* and marking the utmpx entry as a normal user */ +#define NONROOT_USR 2 +#define nonuser(ut) ((ut).ut_exit.e_exit == NONROOT_USR ? 1 : 0) +#define setuser(ut) ((ut).ut_exit.e_exit = NONROOT_USR) + + +extern void endutent(void); +extern struct utmp *getutent(void); +extern struct utmp *getutid(const struct utmp *); +extern struct utmp *getutline(const struct utmp *); +extern struct utmp *pututline(const struct utmp *); +extern void setutent(void); +extern int utmpname(const char *); + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UTMP_H */ diff --git a/illumos-x86_64/usr/include/utmpx.h b/illumos-x86_64/usr/include/utmpx.h new file mode 100644 index 00000000..2056d205 --- /dev/null +++ b/illumos-x86_64/usr/include/utmpx.h @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _UTMPX_H +#define _UTMPX_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define _UTMPX_FILE "/var/adm/utmpx" +#define _WTMPX_FILE "/var/adm/wtmpx" +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define UTMPX_FILE _UTMPX_FILE +#define WTMPX_FILE _WTMPX_FILE +#endif + +#define ut_name ut_user +#define ut_xtime ut_tv.tv_sec + +/* + * This data structure describes the utmpx entries returned by + * the getutxent(3c) family of APIs. It does not (necessarily) + * correspond to the contents of the utmpx or wtmpx files. + * + * Applications should only interact with this subsystem via + * the getutxent(3c) family of APIs. + */ +struct utmpx { + char ut_user[32]; /* user login name */ + char ut_id[4]; /* inittab id */ + char ut_line[32]; /* device name (console, lnxx) */ + pid_t ut_pid; /* process id */ + short ut_type; /* type of entry */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + struct exit_status ut_exit; /* process termination/exit status */ +#else + struct ut_exit_status ut_exit; /* process termination/exit status */ +#endif + struct timeval ut_tv; /* time entry was made */ + int ut_session; /* session ID, used for windowing */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + int pad[5]; /* reserved for future use */ +#else + int __pad[5]; /* reserved for future use */ +#endif + short ut_syslen; /* significant length of ut_host */ + /* including terminating null */ + char ut_host[257]; /* remote host name */ +}; + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + +#include +#include + +/* + * This data structure describes the utmp *file* contents using + * fixed-width data types. It should only be used by the implementation. + * + * Applications should use the getutxent(3c) family of routines to interact + * with this database. + */ + +struct futmpx { + char ut_user[32]; /* user login name */ + char ut_id[4]; /* inittab id */ + char ut_line[32]; /* device name (console, lnxx) */ + pid32_t ut_pid; /* process id */ + int16_t ut_type; /* type of entry */ + struct { + int16_t e_termination; /* process termination status */ + int16_t e_exit; /* process exit status */ + } ut_exit; /* exit status of a process */ + struct timeval32 ut_tv; /* time entry was made */ + int32_t ut_session; /* session ID, user for windowing */ + int32_t pad[5]; /* reserved for future use */ + int16_t ut_syslen; /* significant length of ut_host */ + char ut_host[257]; /* remote host name */ +}; + +#define MOD_WIN 10 + +/* Define and macro for determing if a normal user wrote the entry */ +/* and marking the utmpx entry as a normal user */ +#define NONROOT_USRX 2 +#define nonuserx(utx) ((utx).ut_exit.e_exit == NONROOT_USRX ? 1 : 0) +#define setuserx(utx) ((utx).ut_exit.e_exit = NONROOT_USRX) + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +extern void endutxent(void); +extern struct utmpx *getutxent(void); +extern struct utmpx *getutxid(const struct utmpx *); +extern struct utmpx *getutxline(const struct utmpx *); +extern struct utmpx *pututxline(const struct utmpx *); +extern void setutxent(void); + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +extern int utmpxname(const char *); +extern struct utmpx *makeutx(const struct utmpx *); +extern struct utmpx *modutx(const struct utmpx *); +extern void getutmp(const struct utmpx *, struct utmp *); +extern void getutmpx(const struct utmp *, struct utmpx *); +extern void updwtmp(const char *, struct utmp *); +extern void updwtmpx(const char *, struct utmpx *); +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UTMPX_H */ diff --git a/illumos-x86_64/usr/include/uuid/uuid.h b/illumos-x86_64/usr/include/uuid/uuid.h new file mode 100644 index 00000000..78d3c7de --- /dev/null +++ b/illumos-x86_64/usr/include/uuid/uuid.h @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2014 Andrew Stormont. + */ + +#ifndef _UUID_H +#define _UUID_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The copyright in this file is taken from the original Leach & Salz + * UUID specification, from which this implementation is derived. + */ + +/* + * Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. + * Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & + * Digital Equipment Corporation, Maynard, Mass. Copyright (c) 1998 + * Microsoft. To anyone who acknowledges that this file is provided + * "AS IS" without any express or implied warranty: permission to use, + * copy, modify, and distribute this file for any purpose is hereby + * granted without fee, provided that the above copyright notices and + * this notice appears in all source code copies, and that none of the + * names of Open Software Foundation, Inc., Hewlett-Packard Company, + * or Digital Equipment Corporation be used in advertising or + * publicity pertaining to distribution of the software without + * specific, written prior permission. Neither Open Software + * Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital + * Equipment Corporation makes any representations about the + * suitability of this software for any purpose. + */ + +#include +#include + +extern void uuid_generate(uuid_t); +extern void uuid_generate_random(uuid_t); +extern void uuid_generate_time(uuid_t); +extern void uuid_copy(uuid_t, uuid_t); +extern void uuid_clear(uuid_t); +extern void uuid_unparse(uuid_t, char *); +extern void uuid_unparse_lower(uuid_t, char *); +extern void uuid_unparse_upper(uuid_t, char *); +extern int uuid_compare(uuid_t, uuid_t); +extern int uuid_is_null(uuid_t); +extern int uuid_parse(char *, uuid_t); +extern time_t uuid_time(uuid_t, struct timeval *); + +#ifdef __cplusplus +} +#endif + +#endif /* _UUID_H */ diff --git a/illumos-x86_64/usr/include/valtools.h b/illumos-x86_64/usr/include/valtools.h new file mode 100644 index 00000000..41e40478 --- /dev/null +++ b/illumos-x86_64/usr/include/valtools.h @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#ifndef _VALTOOLS_H +#define _VALTOOLS_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct _choice_ { + char *token; + char *text; + struct _choice_ *next; +}; + +struct _menu_ { + char *label; + int attr; + short longest; + short nchoices; + struct _choice_ + *choice; + char **invis; +}; + +typedef struct _menu_ CKMENU; + +#define P_ABSOLUTE 0x0001 +#define P_RELATIVE 0x0002 +#define P_EXIST 0x0004 +#define P_NEXIST 0x0008 +#define P_REG 0x0010 +#define P_DIR 0x0020 +#define P_BLK 0x0040 +#define P_CHR 0x0080 +#define P_NONZERO 0x0100 +#define P_READ 0x0200 +#define P_WRITE 0x0400 +#define P_EXEC 0x0800 +#define P_CREAT 0x1000 + +#define CKUNNUM 0x01 +#define CKALPHA 0x02 +#define CKONEFLAG 0x04 + +#ifdef __cplusplus +} +#endif + +#endif /* _VALTOOLS_H */ diff --git a/illumos-x86_64/usr/include/values.h b/illumos-x86_64/usr/include/values.h new file mode 100644 index 00000000..ca54e510 --- /dev/null +++ b/illumos-x86_64/usr/include/values.h @@ -0,0 +1,142 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _VALUES_H +#define _VALUES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These values work with any binary representation of integers + * where the high-order bit contains the sign. + */ + +/* a number used normally for size of a shift */ +#define BITSPERBYTE 8 + +#define BITS(type) (BITSPERBYTE * (long)sizeof (type)) + +/* short, regular and long ints with only the high-order bit turned on */ +#define HIBITS ((short)(1 << (BITS(short) - 1))) + +#define HIBITI (1U << (BITS(int) - 1)) +#define HIBITL (1UL << (BITS(long) - 1)) + +/* largest short, regular and long int */ +#define MAXSHORT ((short)~HIBITS) +#define MAXINT ((int)(~HIBITI)) +#define MAXLONG ((long)(~HIBITL)) + +/* + * various values that describe the binary floating-point representation + * _EXPBASE - the exponent base + * DMAXEXP - the maximum exponent of a double (as returned by frexp()) + * FMAXEXP - the maximum exponent of a float (as returned by frexp()) + * DMINEXP - the minimum exponent of a double (as returned by frexp()) + * FMINEXP - the minimum exponent of a float (as returned by frexp()) + * MAXDOUBLE - the largest double + * ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF))) + * MAXFLOAT - the largest float + * ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF))) + * MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1)) + * MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1)) + * DSIGNIF - the number of significant bits in a double + * FSIGNIF - the number of significant bits in a float + * DMAXPOWTWO - the largest power of two exactly representable as a double + * FMAXPOWTWO - the largest power of two exactly representable as a float + * _IEEE - 1 if IEEE standard representation is used + * _DEXPLEN - the number of bits for the exponent of a double + * _FEXPLEN - the number of bits for the exponent of a float + * _HIDDENBIT - 1 if high-significance bit of mantissa is implicit + * LN_MAXDOUBLE - the natural log of the largest double -- log(MAXDOUBLE) + * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE) + * LN_MAXFLOAT - the natural log of the largest float -- log(MAXFLOAT) + * LN_MINFLOAT - the natural log of the smallest float -- log(MINFLOAT) + */ + +/* + * Currently, only IEEE-754 format is supported. + */ +#if defined(_IEEE_754) +#define MAXDOUBLE 1.79769313486231570e+308 +#define MAXFLOAT ((float)3.40282346638528860e+38) +#define MINDOUBLE 4.94065645841246544e-324 +#define MINFLOAT ((float)1.40129846432481707e-45) +#define _IEEE 1 +#define _DEXPLEN 11 +#define _HIDDENBIT 1 +#define _LENBASE 1 +#define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3)) +#define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3)) +#else +/* #error is strictly ansi-C, but works as well as anything for K&R systems. */ +#error "ISA not supported" +#endif + +#define _EXPBASE (1 << _LENBASE) +#define _FEXPLEN 8 +#define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1) +#define FSIGNIF (BITS(float) - _FEXPLEN + _HIDDENBIT - 1) +#define DMAXPOWTWO ((double)(1 << (BITS(int) - 2)) * \ + (1 << (DSIGNIF - BITS(int) + 1))) +#define FMAXPOWTWO ((float)(1 << (FSIGNIF - 1))) +#define DMAXEXP ((1 << (_DEXPLEN - 1)) - 1 + _IEEE) +#define FMAXEXP ((1 << (_FEXPLEN - 1)) - 1 + _IEEE) +#define LN_MAXDOUBLE (M_LN2 * DMAXEXP) +#define LN_MAXFLOAT (float)(M_LN2 * FMAXEXP) +#define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1)) +#define LN_MINFLOAT (float)(M_LN2 * (FMINEXP - 1)) +#define H_PREC (DSIGNIF % 2 ? (1 << DSIGNIF/2) * M_SQRT2 : 1 << DSIGNIF/2) +#define FH_PREC \ + (float)(FSIGNIF % 2 ? (1 << FSIGNIF/2) * M_SQRT2 : 1 << FSIGNIF/2) +#define X_EPS (1.0/H_PREC) +#define FX_EPS (float)((float)1.0/FH_PREC) +#define X_PLOSS ((double)(int)(M_PI * H_PREC)) +#define FX_PLOSS ((float)(int)(M_PI * FH_PREC)) +#define X_TLOSS (M_PI * DMAXPOWTWO) +#define FX_TLOSS (float)(M_PI * FMAXPOWTWO) +#define M_LN2 0.69314718055994530942 +#define M_PI 3.14159265358979323846 +#define M_SQRT2 1.41421356237309504880 +#define MAXBEXP DMAXEXP /* for backward compatibility */ +#define MINBEXP DMINEXP /* for backward compatibility */ +#define MAXPOWTWO DMAXPOWTWO /* for backward compatibility */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VALUES_H */ diff --git a/illumos-x86_64/usr/include/varargs.h b/illumos-x86_64/usr/include/varargs.h new file mode 100644 index 00000000..46b6484c --- /dev/null +++ b/illumos-x86_64/usr/include/varargs.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _VARARGS_H +#define _VARARGS_H + +/* + * This header defines the pre-standard variable argument definitions. + * Programs using this header should migrate to using . + * + * The varargs definitions within this header are defined in terms of + * implementation definitions. These implementation definitions reside + * in . This organization enables protected use of + * the implementation by other standard headers without introducing + * names into the users' namespace. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _VA_LIST +#define _VA_LIST +typedef __va_list va_list; +#endif + +#define va_alist __builtin_va_alist +#define va_dcl __va_alist_type va_alist; +#define va_start(list) __va_start(list, va_alist) +#define va_arg(list, type) __va_arg(list, type) +#define va_end(list) __va_end(list) + +/* + * va_copy is a Solaris extension to provide a portable way to perform + * a variable argument list ``bookmarking'' function. + */ +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + +#define va_copy(to, from) __va_copy(to, from) + +#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && ... ) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VARARGS_H */ diff --git a/illumos-x86_64/usr/include/vm/anon.h b/illumos-x86_64/usr/include/vm/anon.h new file mode 100644 index 00000000..1273b984 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/anon.h @@ -0,0 +1,504 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_ANON_H +#define _VM_ANON_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * VM - Anonymous pages. + */ + +typedef unsigned long anoff_t; /* anon offsets */ + +/* + * Each anonymous page, either in memory or in swap, has an anon structure. + * The structure (slot) provides a level of indirection between anonymous pages + * and their backing store. + * + * (an_vp, an_off) names the vnode of the anonymous page for this slot. + * + * (an_pvp, an_poff) names the location of the physical backing store + * for the page this slot represents. If the name is null there is no + * associated physical store. The physical backing store location can + * change while the slot is in use. + * + * an_hash is a hash list of anon slots. The list is hashed by + * (an_vp, an_off) of the associated anonymous page and provides a + * method of going from the name of an anonymous page to its + * associated anon slot. + * + * an_refcnt holds a reference count which is the number of separate + * copies that will need to be created in case of copy-on-write. + * A refcnt > 0 protects the existence of the slot. The refcnt is + * initialized to 1 when the anon slot is created in anon_alloc(). + * If a client obtains an anon slot and allows multiple threads to + * share it, then it is the client's responsibility to insure that + * it does not allow one thread to try to reference the slot at the + * same time as another is trying to decrement the last count and + * destroy the anon slot. E.g., the seg_vn segment type protects + * against this with higher level locks. + */ + +struct anon { + struct vnode *an_vp; /* vnode of anon page */ + struct vnode *an_pvp; /* vnode of physical backing store */ + anoff_t an_off; /* offset of anon page */ + anoff_t an_poff; /* offset in vnode */ + struct anon *an_hash; /* hash table of anon slots */ + int an_refcnt; /* # of people sharing slot */ +}; + +#define AN_CACHE_ALIGN_LOG2 4 /* log2(AN_CACHE_ALIGN) */ +#define AN_CACHE_ALIGN (1U << AN_CACHE_ALIGN_LOG2) /* anon address aligned */ + /* 16 bytes */ + + +#ifdef _KERNEL +/* + * The swapinfo_lock protects: + * swapinfo list + * individual swapinfo structures + * + * The anoninfo_lock protects: + * anoninfo counters + * + * The anonhash_lock protects: + * anon hash lists + * anon slot fields + * + * Fields in the anon slot which are read-only for the life of the slot + * (an_vp, an_off) do not require the anonhash_lock be held to access them. + * If you access a field without the anonhash_lock held you must be holding + * the slot with an_refcnt to make sure it isn't destroyed. + * To write (an_pvp, an_poff) in a given slot you must also hold the + * p_iolock of the anonymous page for slot. + */ +extern kmutex_t anoninfo_lock; +extern kmutex_t swapinfo_lock; +extern pad_mutex_t *anonhash_lock; +extern pad_mutex_t anon_array_lock[]; +extern kcondvar_t anon_array_cv[]; + +/* + * Global hash table to provide a function from (vp, off) -> ap + */ +extern size_t anon_hash_size; +extern unsigned int anon_hash_shift; +extern struct anon **anon_hash; +#define ANON_HASH_SIZE anon_hash_size +#define ANON_HASHAVELEN 4 +/* + * Try to use as many bits of randomness from both vp and off as we can. + * This should help spreading evenly for a variety of workloads. See comments + * for PAGE_HASH_FUNC for more explanation. + */ +#define ANON_HASH(vp, off) \ + (((((uintptr_t)(off) >> PAGESHIFT) ^ \ + ((uintptr_t)(off) >> (PAGESHIFT + anon_hash_shift))) ^ \ + (((uintptr_t)(vp) >> 3) ^ \ + ((uintptr_t)(vp) >> (3 + anon_hash_shift)) ^ \ + ((uintptr_t)(vp) >> (3 + 2 * anon_hash_shift)) ^ \ + ((uintptr_t)(vp) << \ + (anon_hash_shift - AN_VPSHIFT - VNODE_ALIGN_LOG2)))) & \ + (anon_hash_size - 1)) + +#define AH_LOCK_SIZE (2 << NCPU_LOG2) + +#define AH_MUTEX(vp, off) \ + (&anonhash_lock[(ANON_HASH((vp), (off)) & \ + (AH_LOCK_SIZE - 1))].pad_mutex) + +#endif /* _KERNEL */ + +/* + * Declaration for the Global counters to accurately + * track the kernel foot print in memory. + */ +extern pgcnt_t pages_locked; +extern pgcnt_t pages_claimed; +extern pgcnt_t pages_useclaim; +extern pgcnt_t obp_pages; + +/* + * Anonymous backing store accounting structure for swapctl. + * + * ani_max = maximum amount of swap space + * (including potentially available physical memory) + * ani_free = amount of unallocated anonymous memory + * (some of which might be reserved and including + * potentially available physical memory) + * ani_resv = amount of claimed (reserved) anonymous memory + * + * The swap data can be aquired more efficiently through the + * kstats interface. + * Total slots currently available for reservation = + * MAX(ani_max - ani_resv, 0) + (availrmem - swapfs_minfree) + */ +struct anoninfo { + pgcnt_t ani_max; + pgcnt_t ani_free; + pgcnt_t ani_resv; +}; + +#ifdef _SYSCALL32 +struct anoninfo32 { + size32_t ani_max; + size32_t ani_free; + size32_t ani_resv; +}; +#endif /* _SYSCALL32 */ + +/* + * Define the NCPU pool of the ani_free counters. Update the counter + * of the cpu on which the thread is running and in every clock intr + * sync anoninfo.ani_free with the current total off all the NCPU entries. + */ + +typedef struct ani_free { + pgcnt_t ani_count; + uchar_t pad[64 - sizeof (pgcnt_t)]; + /* XXX 64 = cacheline size */ +} ani_free_t; + +#define ANI_MAX_POOL (NCPU_P2) +extern ani_free_t *ani_free_pool; + +/* + * Since each CPU has its own bucket in ani_free_pool, there should be no + * contention here. + */ +#define ANI_ADD(inc) { \ + pgcnt_t *ani_countp; \ + int index; \ + index = (CPU->cpu_seqid & (ANI_MAX_POOL - 1)); \ + ani_countp = &ani_free_pool[index].ani_count; \ + atomic_add_long(ani_countp, inc); \ +} + +extern void set_anoninfo(void); + +/* + * Anon array pointers are allocated in chunks. Each chunk + * has PAGESIZE/sizeof(u_long *) of anon pointers. + * There are two levels of arrays for anon array pointers larger + * than a chunk. The first level points to anon array chunks. + * The second level consists of chunks of anon pointers. + * + * If anon array is smaller than a chunk then the whole anon array + * is created (memory is allocated for whole anon array). + * If anon array is larger than a chunk only first level array is + * allocated. Then other arrays (chunks) are allocated only when + * they are initialized with anon pointers. + */ +struct anon_hdr { + kmutex_t serial_lock; /* serialize array chunk allocation */ + pgcnt_t size; /* number of pointers to (anon) pages */ + void **array_chunk; /* pointers to anon pointers or chunks of */ + /* anon pointers */ + int flags; /* ANON_ALLOC_FORCE force preallocation of */ + /* whole anon array */ +}; + +#ifdef _LP64 +#define ANON_PTRSHIFT 3 +#define ANON_PTRMASK ~7 +#else +#define ANON_PTRSHIFT 2 +#define ANON_PTRMASK ~3 +#endif + +#define ANON_CHUNK_SIZE (PAGESIZE >> ANON_PTRSHIFT) +#define ANON_CHUNK_SHIFT (PAGESHIFT - ANON_PTRSHIFT) +#define ANON_CHUNK_OFF (ANON_CHUNK_SIZE - 1) + +/* + * Anon flags. + */ +#define ANON_SLEEP 0x0 /* ok to block */ +#define ANON_NOSLEEP 0x1 /* non-blocking call */ +#define ANON_ALLOC_FORCE 0x2 /* force single level anon array */ +#define ANON_GROWDOWN 0x4 /* anon array should grow downward */ + +struct kshmid; + +/* + * The anon_map structure is used by various clients of the anon layer to + * manage anonymous memory. When anonymous memory is shared, + * then the different clients sharing it will point to the + * same anon_map structure. Also, if a segment is unmapped + * in the middle where an anon_map structure exists, the + * newly created segment will also share the anon_map structure, + * although the two segments will use different ranges of the + * anon array. When mappings are private (or shared with + * a reference count of 1), an unmap operation will free up + * a range of anon slots in the array given by the anon_map + * structure. Because of fragmentation due to this unmapping, + * we have to store the size of the anon array in the anon_map + * structure so that we can free everything when the referernce + * count goes to zero. + * + * A new rangelock scheme is introduced to make the anon layer scale. + * A reader/writer lock per anon_amp and an array of system-wide hash + * locks, anon_array_lock[] are introduced to replace serial_lock and + * anonmap lock. The writer lock is held when we want to singlethreaD + * the reference to the anon array pointers or when references to + * anon_map's members, whereas reader lock and anon_array_lock are + * held to allows multiple threads to reference different part of + * anon array. A global set of condition variables, anon_array_cv, + * are used with anon_array_lock[] to make the hold time of the locks + * short. + * + * szc is used to calculate the index of hash locks and cv's. We + * could've just used seg->s_szc if not for the possible sharing of + * anon_amp between SYSV shared memory and ISM, so now we introduce + * szc in the anon_map structure. For MAP_SHARED, the amp->szc is either + * 0 (base page size) or page_num_pagesizes() - 1, while MAP_PRIVATE + * the amp->szc could be anything in [0, page_num_pagesizes() - 1]. + */ +typedef struct anon_map { + krwlock_t a_rwlock; /* protect anon_map and anon array */ + size_t size; /* size in bytes mapped by the anon array */ + struct anon_hdr *ahp; /* anon array header pointer, containing */ + /* anon pointer array(s) */ + size_t swresv; /* swap space reserved for this anon_map */ + ulong_t refcnt; /* reference count on this structure */ + ushort_t a_szc; /* max szc among shared processes */ + void *locality; /* lgroup locality info */ + struct kshmid *a_sp; /* kshmid if amp backs sysV, or NULL */ + int a_purgewait; /* somebody waits for slocks to go away */ + kcondvar_t a_purgecv; /* cv for waiting for slocks to go away */ + kmutex_t a_purgemtx; /* mutex for anonmap_purge() */ + spgcnt_t a_softlockcnt; /* number of pages locked in pcache */ + kmutex_t a_pmtx; /* protects amp's pcache list */ + pcache_link_t a_phead; /* head of amp's pcache list */ +} amp_t; + +#ifdef _KERNEL + +#define ANON_BUSY 0x1 +#define ANON_ISBUSY(slot) (*(slot) & ANON_BUSY) +#define ANON_SETBUSY(slot) (*(slot) |= ANON_BUSY) +#define ANON_CLRBUSY(slot) (*(slot) &= ~ANON_BUSY) + +#define ANON_MAP_SHIFT 6 /* log2(sizeof (struct anon_map)) */ +#define ANON_ARRAY_SHIFT 7 /* log2(ANON_LOCKSIZE) */ +#define ANON_LOCKSIZE 128 + +#define ANON_LOCK_ENTER(lock, type) rw_enter((lock), (type)) +#define ANON_LOCK_EXIT(lock) rw_exit((lock)) +#define ANON_LOCK_HELD(lock) RW_LOCK_HELD((lock)) +#define ANON_READ_HELD(lock) RW_READ_HELD((lock)) +#define ANON_WRITE_HELD(lock) RW_WRITE_HELD((lock)) + +#define ANON_ARRAY_HASH(amp, idx)\ + ((((idx) + ((idx) >> ANON_ARRAY_SHIFT) +\ + ((idx) >> (ANON_ARRAY_SHIFT << 1)) +\ + ((idx) >> (ANON_ARRAY_SHIFT + (ANON_ARRAY_SHIFT << 1)))) ^\ + ((uintptr_t)(amp) >> ANON_MAP_SHIFT)) & (ANON_LOCKSIZE - 1)) + +typedef struct anon_sync_obj { + kmutex_t *sync_mutex; + kcondvar_t *sync_cv; + ulong_t *sync_data; +} anon_sync_obj_t; + +/* + * Anonymous backing store accounting structure for kernel. + * ani_max = total reservable slots on physical (disk-backed) swap + * ani_phys_resv = total phys slots reserved for use by clients + * ani_mem_resv = total mem slots reserved for use by clients + * ani_free = # unallocated physical slots + # of reserved unallocated + * memory slots + */ + +/* + * Initial total swap slots available for reservation + */ +#define TOTAL_AVAILABLE_SWAP \ + (k_anoninfo.ani_max + MAX((spgcnt_t)(availrmem - swapfs_minfree), 0)) + +/* + * Swap slots currently available for reservation + */ +#define CURRENT_TOTAL_AVAILABLE_SWAP \ + ((k_anoninfo.ani_max - k_anoninfo.ani_phys_resv) + \ + MAX((spgcnt_t)(availrmem - swapfs_minfree), 0)) + +struct k_anoninfo { + pgcnt_t ani_max; /* total reservable slots on phys */ + /* (disk) swap */ + pgcnt_t ani_free; /* # of unallocated phys and mem slots */ + pgcnt_t ani_phys_resv; /* # of reserved phys (disk) slots */ + pgcnt_t ani_mem_resv; /* # of reserved mem slots */ + pgcnt_t ani_locked_swap; /* # of swap slots locked in reserved */ + /* mem swap */ +}; + +extern struct k_anoninfo k_anoninfo; + +extern void anon_init(void); +extern struct anon *anon_alloc(struct vnode *, anoff_t); +extern void anon_dup(struct anon_hdr *, ulong_t, + struct anon_hdr *, ulong_t, size_t); +extern void anon_dup_fill_holes(struct anon_hdr *, ulong_t, + struct anon_hdr *, ulong_t, size_t, uint_t, int); +extern int anon_fill_cow_holes(struct seg *, caddr_t, struct anon_hdr *, + ulong_t, struct vnode *, u_offset_t, size_t, uint_t, + uint_t, struct vpage [], struct cred *); +extern void anon_free(struct anon_hdr *, ulong_t, size_t); +extern void anon_free_pages(struct anon_hdr *, ulong_t, size_t, uint_t); +extern int anon_disclaim(struct anon_map *, + ulong_t, size_t, uint_t, pgcnt_t *); +extern int anon_getpage(struct anon **, uint_t *, struct page **, + size_t, struct seg *, caddr_t, enum seg_rw, struct cred *); +extern int swap_getconpage(struct vnode *, u_offset_t, size_t, + uint_t *, page_t *[], size_t, page_t *, uint_t *, + spgcnt_t *, struct seg *, caddr_t, + enum seg_rw, struct cred *); +extern int anon_map_getpages(struct anon_map *, ulong_t, + uint_t, struct seg *, caddr_t, uint_t, + uint_t *, page_t *[], uint_t *, + struct vpage [], enum seg_rw, int, int, int, struct cred *); +extern int anon_map_privatepages(struct anon_map *, ulong_t, + uint_t, struct seg *, caddr_t, uint_t, + page_t *[], struct vpage [], int, int, struct cred *); +extern struct page *anon_private(struct anon **, struct seg *, + caddr_t, uint_t, struct page *, + int, struct cred *); +extern struct page *anon_zero(struct seg *, caddr_t, + struct anon **, struct cred *); +extern int anon_map_createpages(struct anon_map *, ulong_t, + size_t, struct page **, + struct seg *, caddr_t, + enum seg_rw, struct cred *); +extern int anon_map_demotepages(struct anon_map *, ulong_t, + struct seg *, caddr_t, uint_t, + struct vpage [], struct cred *); +extern void anon_shmap_free_pages(struct anon_map *, ulong_t, size_t); +extern int anon_resvmem(size_t, boolean_t, zone_t *, int); +extern void anon_unresvmem(size_t, zone_t *); +extern struct anon_map *anonmap_alloc(size_t, size_t, int); +extern void anonmap_free(struct anon_map *); +extern void anonmap_purge(struct anon_map *); +extern void anon_swap_free(struct anon *, struct page *); +extern void anon_decref(struct anon *); +extern int non_anon(struct anon_hdr *, ulong_t, u_offset_t *, size_t *); +extern pgcnt_t anon_pages(struct anon_hdr *, ulong_t, pgcnt_t); +extern int anon_swap_adjust(pgcnt_t); +extern void anon_swap_restore(pgcnt_t); +extern struct anon_hdr *anon_create(pgcnt_t, int); +extern void anon_release(struct anon_hdr *, pgcnt_t); +extern struct anon *anon_get_ptr(struct anon_hdr *, ulong_t); +extern ulong_t *anon_get_slot(struct anon_hdr *, ulong_t); +extern struct anon *anon_get_next_ptr(struct anon_hdr *, ulong_t *); +extern int anon_set_ptr(struct anon_hdr *, ulong_t, struct anon *, int); +extern int anon_copy_ptr(struct anon_hdr *, ulong_t, + struct anon_hdr *, ulong_t, pgcnt_t, int); +extern pgcnt_t anon_grow(struct anon_hdr *, ulong_t *, pgcnt_t, pgcnt_t, int); +extern void anon_array_enter(struct anon_map *, ulong_t, + anon_sync_obj_t *); +extern int anon_array_try_enter(struct anon_map *, ulong_t, + anon_sync_obj_t *); +extern void anon_array_exit(anon_sync_obj_t *); + +/* + * anon_resv checks to see if there is enough swap space to fulfill a + * request and if so, reserves the appropriate anonymous memory resources. + * anon_checkspace just checks to see if there is space to fulfill the request, + * without taking any resources. Both return 1 if successful and 0 if not. + * + * Macros are provided as anon reservation is usually charged to the zone of + * the current process. In some cases (such as anon reserved by tmpfs), a + * zone pointer is needed to charge the appropriate zone. + */ +#define anon_unresv(size) anon_unresvmem(size, curproc->p_zone) +#define anon_unresv_zone(size, zone) anon_unresvmem(size, zone) +#define anon_resv(size) \ + anon_resvmem((size), 1, curproc->p_zone, 1) +#define anon_resv_zone(size, zone) anon_resvmem((size), 1, zone, 1) +#define anon_checkspace(size, zone) anon_resvmem((size), 0, zone, 0) +#define anon_try_resv_zone(size, zone) anon_resvmem((size), 1, zone, 0) + +/* + * Flags to anon_private + */ +#define STEAL_PAGE 0x1 /* page can be stolen */ +#define LOCK_PAGE 0x2 /* page must be ``logically'' locked */ + +/* + * SEGKP ANON pages that are locked are assumed to be LWP stack pages + * and thus count towards the user pages locked count. + * This value is protected by the same lock as availrmem. + */ +extern pgcnt_t anon_segkp_pages_locked; + +extern int anon_debug; + +#ifdef ANON_DEBUG + +#define A_ANON 0x01 +#define A_RESV 0x02 +#define A_MRESV 0x04 + +/* vararg-like debugging macro. */ +#define ANON_PRINT(f, printf_args) \ + if (anon_debug & f) \ + printf printf_args + +#else /* ANON_DEBUG */ + +#define ANON_PRINT(f, printf_args) + +#endif /* ANON_DEBUG */ + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_ANON_H */ diff --git a/illumos-x86_64/usr/include/vm/as.h b/illumos-x86_64/usr/include/vm/as.h new file mode 100644 index 00000000..83bd7b52 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/as.h @@ -0,0 +1,316 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 2018 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_AS_H +#define _VM_AS_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * VM - Address spaces. + */ + +/* + * Each address space consists of a sorted list of segments + * and machine dependent address translation information. + * + * All the hard work is in the segment drivers and the + * hardware address translation code. + * + * The segment list is represented as an AVL tree. + * + * The address space lock (a_lock) is a long term lock which serializes + * access to certain operations (as_map, as_unmap) and protects the + * underlying generic segment data (seg.h) along with some fields in the + * address space structure as shown below: + * + * address space structure segment structure + * + * a_segtree s_base + * a_size s_size + * a_lastgap s_link + * a_seglast s_ops + * s_as + * s_data + * + * The address space contents lock (a_contents) is a short term + * lock that protects most of the data in the address space structure. + * This lock is always acquired after the "a_lock" in all situations + * except while dealing with AS_CLAIMGAP to avoid deadlocks. + * + * The following fields are protected by this lock: + * + * a_flags (AS_PAGLCK, AS_CLAIMGAP, etc.) + * a_unmapwait + * a_seglast + * + * The address space lock (a_lock) is always held prior to any segment + * operation. Some segment drivers use the address space lock to protect + * some or all of their segment private data, provided the version of + * "a_lock" (read vs. write) is consistent with the use of the data. + * + * The following fields are protected by the hat layer lock: + * + * a_vbits + * a_hat + * a_hrm + */ + +struct as { + kmutex_t a_contents; /* protect certain fields in the structure */ + uchar_t a_flags; /* as attributes */ + uchar_t a_vbits; /* used for collecting statistics */ + kcondvar_t a_cv; /* used by as_rangelock */ + struct hat *a_hat; /* hat structure */ + struct hrmstat *a_hrm; /* ref and mod bits */ + caddr_t a_userlimit; /* highest allowable address in this as */ + struct seg *a_seglast; /* last segment hit on the addr space */ + krwlock_t a_lock; /* protects segment related fields */ + size_t a_size; /* total size of address space */ + struct seg *a_lastgap; /* last seg found by as_gap() w/ AS_HI (mmap) */ + struct seg *a_lastgaphl; /* last seg saved in as_gap() either for */ + /* AS_HI or AS_LO used in as_addseg() */ + avl_tree_t a_segtree; /* segments in this address space. (AVL tree) */ + avl_tree_t a_wpage; /* watched pages (procfs) */ + uchar_t a_updatedir; /* mappings changed, rebuild a_objectdir */ + timespec_t a_updatetime; /* time when mappings last changed */ + vnode_t **a_objectdir; /* object directory (procfs) */ + size_t a_sizedir; /* size of object directory */ + struct as_callback *a_callbacks; /* callback list */ + proc_t *a_proc; /* back pointer to proc */ + size_t a_resvsize; /* size of reserved part of address space */ +}; + +#define AS_PAGLCK 0x80 +#define AS_CLAIMGAP 0x40 +#define AS_UNMAPWAIT 0x20 +#define AS_NEEDSPURGE 0x10 /* mostly for seg_nf, see as_purge() */ +#define AS_NOUNMAPWAIT 0x02 + +#define AS_ISPGLCK(as) ((as)->a_flags & AS_PAGLCK) +#define AS_ISCLAIMGAP(as) ((as)->a_flags & AS_CLAIMGAP) +#define AS_ISUNMAPWAIT(as) ((as)->a_flags & AS_UNMAPWAIT) +#define AS_ISNOUNMAPWAIT(as) ((as)->a_flags & AS_NOUNMAPWAIT) + +#define AS_SETPGLCK(as) ((as)->a_flags |= AS_PAGLCK) +#define AS_SETCLAIMGAP(as) ((as)->a_flags |= AS_CLAIMGAP) +#define AS_SETUNMAPWAIT(as) ((as)->a_flags |= AS_UNMAPWAIT) +#define AS_SETNOUNMAPWAIT(as) ((as)->a_flags |= AS_NOUNMAPWAIT) + +#define AS_CLRPGLCK(as) ((as)->a_flags &= ~AS_PAGLCK) +#define AS_CLRCLAIMGAP(as) ((as)->a_flags &= ~AS_CLAIMGAP) +#define AS_CLRUNMAPWAIT(as) ((as)->a_flags &= ~AS_UNMAPWAIT) +#define AS_CLRNOUNMAPWAIT(as) ((as)->a_flags &= ~AS_NOUNMAPWAIT) + +#define AS_TYPE_64BIT(as) \ + (((as)->a_userlimit > (caddr_t)UINT32_MAX) ? 1 : 0) + +/* + * Flags for as_map/as_map_ansegs + */ +#define AS_MAP_NO_LPOOB ((uint_t)-1) +#define AS_MAP_HEAP ((uint_t)-2) +#define AS_MAP_STACK ((uint_t)-3) + +/* + * The as_callback is the basic structure which supports the ability to + * inform clients of specific events pertaining to address space management. + * A user calls as_add_callback to register an address space callback + * for a range of pages, specifying the events that need to occur. + * When as_do_callbacks is called and finds a 'matching' entry, the + * callback is called once, and the callback function MUST call + * as_delete_callback when all callback activities are complete. + * The thread calling as_do_callbacks blocks until the as_delete_callback + * is called. This allows for asynchorous events to subside before the + * as_do_callbacks thread continues. + * + * An example of the need for this is a driver which has done long-term + * locking of memory. Address space management operations (events) such + * as as_free, as_umap, and as_setprot will block indefinitely until the + * pertinent memory is unlocked. The callback mechanism provides the + * way to inform the driver of the event so that the driver may do the + * necessary unlocking. + * + * The contents of this structure is protected by a_contents lock + */ +typedef void (*callback_func_t)(struct as *, void *, uint_t); +struct as_callback { + struct as_callback *ascb_next; /* list link */ + uint_t ascb_events; /* event types */ + callback_func_t ascb_func; /* callback function */ + void *ascb_arg; /* callback argument */ + caddr_t ascb_saddr; /* start address */ + size_t ascb_len; /* address range */ +}; +/* + * Callback events + */ +#define AS_FREE_EVENT 0x1 +#define AS_SETPROT_EVENT 0x2 +#define AS_UNMAP_EVENT 0x4 +#define AS_CALLBACK_CALLED ((uint_t)(1U << (8 * sizeof (uint_t) - 1U))) +#define AS_UNMAPWAIT_EVENT \ + (AS_FREE_EVENT | AS_SETPROT_EVENT | AS_UNMAP_EVENT) +#define AS_ALL_EVENT \ + (AS_FREE_EVENT | AS_SETPROT_EVENT | AS_UNMAP_EVENT) + + +/* Return code values for as_callback_delete */ +enum as_cbdelete_rc { + AS_CALLBACK_DELETED, + AS_CALLBACK_NOTFOUND, + AS_CALLBACK_DELETE_DEFERRED +}; + +#ifdef _KERNEL + +/* + * Flags for as_gap. + */ +#define AH_DIR 0x1 /* direction flag mask */ +#define AH_LO 0x0 /* find lowest hole */ +#define AH_HI 0x1 /* find highest hole */ +#define AH_CONTAIN 0x2 /* hole must contain `addr' */ + +extern struct as kas; /* kernel's address space */ + +/* + * Macros for address space locking. Note that we use RW_READER_STARVEWRITER + * whenever we acquire the address space lock as reader to assure that it can + * be used without regard to lock order in conjunction with filesystem locks. + * This allows filesystems to safely induce user-level page faults with + * filesystem locks held while concurrently allowing filesystem entry points + * acquiring those same locks to be called with the address space lock held as + * reader. RW_READER_STARVEWRITER thus prevents reader/reader+RW_WRITE_WANTED + * deadlocks in the style of fop_write()+as_fault()/as_*()+fop_putpage() and + * fop_read()+as_fault()/as_*()+fop_getpage(). (See the Big Theory Statement + * in rwlock.c for more information on the semantics of and motivation behind + * RW_READER_STARVEWRITER.) + */ +#define AS_LOCK_ENTER(as, type) rw_enter(&(as)->a_lock, \ + (type) == RW_READER ? RW_READER_STARVEWRITER : (type)) +#define AS_LOCK_EXIT(as) rw_exit(&(as)->a_lock) +#define AS_LOCK_DESTROY(as) rw_destroy(&(as)->a_lock) +#define AS_LOCK_TRYENTER(as, type) rw_tryenter(&(as)->a_lock, \ + (type) == RW_READER ? RW_READER_STARVEWRITER : (type)) + +/* + * Macros to test lock states. + */ +#define AS_LOCK_HELD(as) RW_LOCK_HELD(&(as)->a_lock) +#define AS_READ_HELD(as) RW_READ_HELD(&(as)->a_lock) +#define AS_WRITE_HELD(as) RW_WRITE_HELD(&(as)->a_lock) + +/* + * macros to walk thru segment lists + */ +#define AS_SEGFIRST(as) avl_first(&(as)->a_segtree) +#define AS_SEGNEXT(as, seg) AVL_NEXT(&(as)->a_segtree, (seg)) +#define AS_SEGPREV(as, seg) AVL_PREV(&(as)->a_segtree, (seg)) + +typedef int (*segcreate_func_t)(struct seg **, void *); + +void as_init(void); +void as_avlinit(struct as *); +struct seg *as_segat(struct as *as, caddr_t addr); +void as_rangelock(struct as *as); +void as_rangeunlock(struct as *as); +struct as *as_alloc(); +void as_free(struct as *as); +int as_dup(struct as *as, struct proc *forkedproc); +struct seg *as_findseg(struct as *as, caddr_t addr, int tail); +int as_addseg(struct as *as, struct seg *newseg); +struct seg *as_removeseg(struct as *as, struct seg *seg); +faultcode_t as_fault(struct hat *hat, struct as *as, caddr_t addr, size_t size, + enum fault_type type, enum seg_rw rw); +faultcode_t as_faulta(struct as *as, caddr_t addr, size_t size); +int as_setprot(struct as *as, caddr_t addr, size_t size, uint_t prot); +int as_checkprot(struct as *as, caddr_t addr, size_t size, uint_t prot); +int as_unmap(struct as *as, caddr_t addr, size_t size); +int as_map(struct as *as, caddr_t addr, size_t size, segcreate_func_t crfp, + void *argsp); +int as_map_locked(struct as *as, caddr_t addr, size_t size, + segcreate_func_t crfp, void *argsp); +void as_purge(struct as *as); +int as_gap(struct as *as, size_t minlen, caddr_t *basep, size_t *lenp, + uint_t flags, caddr_t addr); +int as_gap_aligned(struct as *as, size_t minlen, caddr_t *basep, + size_t *lenp, uint_t flags, caddr_t addr, size_t align, + size_t redzone, size_t off); + +int as_memory(struct as *as, caddr_t *basep, size_t *lenp); +size_t as_swapout(struct as *as); +int as_incore(struct as *as, caddr_t addr, size_t size, char *vec, + size_t *sizep); +int as_ctl(struct as *as, caddr_t addr, size_t size, int func, int attr, + uintptr_t arg, ulong_t *lock_map, size_t pos); +int as_pagelock(struct as *as, struct page ***ppp, caddr_t addr, + size_t size, enum seg_rw rw); +void as_pageunlock(struct as *as, struct page **pp, caddr_t addr, + size_t size, enum seg_rw rw); +int as_setpagesize(struct as *as, caddr_t addr, size_t size, uint_t szc, + boolean_t wait); +int as_set_default_lpsize(struct as *as, caddr_t addr, size_t size); +void as_setwatch(struct as *as); +void as_clearwatch(struct as *as); +int as_getmemid(struct as *, caddr_t, memid_t *); + +int as_add_callback(struct as *, void (*)(), void *, uint_t, + caddr_t, size_t, int); +uint_t as_delete_callback(struct as *, void *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_AS_H */ diff --git a/illumos-x86_64/usr/include/vm/faultcode.h b/illumos-x86_64/usr/include/vm/faultcode.h new file mode 100644 index 00000000..5b170dcd --- /dev/null +++ b/illumos-x86_64/usr/include/vm/faultcode.h @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_FAULTCODE_H +#define _VM_FAULTCODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file describes the data type returned by vm routines + * which handle faults. + * + * If FC_CODE(fc) == FC_OBJERR, then FC_ERRNO(fc) contains the errno value + * returned by the underlying object mapped at the fault address. + */ +#define FC_HWERR 0x1 /* misc hardware error (e.g. bus timeout) */ +#define FC_ALIGN 0x2 /* hardware alignment error */ +#define FC_OBJERR 0x3 /* underlying object returned errno value */ +#define FC_PROT 0x4 /* access exceeded current protections */ +#define FC_NOMAP 0x5 /* no mapping at the fault address */ +#define FC_NOSUPPORT 0x6 /* operation not supported by driver */ + +#define FC_MAKE_ERR(e) (((e) << 8) | FC_OBJERR) + +#define FC_CODE(fc) ((fc) & 0xff) +#define FC_ERRNO(fc) ((unsigned)(fc) >> 8) + +#ifndef _ASM +typedef int faultcode_t; /* type returned by vm fault routines */ + +extern int fc_decode(faultcode_t); + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_FAULTCODE_H */ diff --git a/illumos-x86_64/usr/include/vm/hat.h b/illumos-x86_64/usr/include/vm/hat.h new file mode 100644 index 00000000..37351390 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/hat.h @@ -0,0 +1,635 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2014 Joyent, Inc. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_HAT_H +#define _VM_HAT_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * VM - Hardware Address Translation management. + * + * This file describes the machine independent interfaces to + * the hardware address translation management routines. Other + * machine specific interfaces and structures are defined + * in . The hat layer manages the address + * translation hardware as a cache driven by calls from the + * higher levels of the VM system. + */ + +struct hat; +struct kpme; +struct memseg; + +#include + +/* + * a callback used with hat_unload_callback() + * start and end mark are set to a range of unloaded addresses + * and the function is invoked with a pointer to this data structure + */ +typedef struct hat_callback { + caddr_t hcb_start_addr; + caddr_t hcb_end_addr; + void (*hcb_function)(struct hat_callback *); + void *hcb_data; +} hat_callback_t; + +typedef void *hat_region_cookie_t; + +#ifdef _KERNEL + +/* + * One time hat initialization + */ +void hat_init(void); + +/* + * Notify hat of a system dump + */ +void hat_dump(void); + +/* + * Operations on an address space: + * + * struct hat *hat_alloc(as) + * allocated a hat structure for as. + * + * void hat_free_start(hat) + * informs hat layer process has finished executing but as has not + * been cleaned up yet. + * + * void hat_free_end(hat) + * informs hat layer as is being destroyed. hat layer cannot use as + * pointer after this call. + * + * void hat_swapin(hat) + * allocate any hat resources required for process being swapped in. + * + * void hat_swapout(hat) + * deallocate hat resources for process being swapped out. + * + * size_t hat_get_mapped_size(hat) + * returns number of bytes that have valid mappings in hat. + * + * void hat_stats_enable(hat) + * void hat_stats_disable(hat) + * enables/disables collection of stats for hat. + * + * int hat_dup(parenthat, childhat, addr, len, flags) + * Duplicate address translations of the parent to the child. Supports + * the entire address range or a range depending on flag, + * zero returned on success, non-zero on error + * + * void hat_thread_exit(thread) + * Notifies the HAT that a thread is exiting, called after it has been + * reassigned to the kernel AS. + */ + +struct hat *hat_alloc(struct as *); +void hat_free_start(struct hat *); +void hat_free_end(struct hat *); +int hat_dup(struct hat *, struct hat *, caddr_t, size_t, uint_t); +void hat_swapin(struct hat *); +void hat_swapout(struct hat *); +size_t hat_get_mapped_size(struct hat *); +int hat_stats_enable(struct hat *); +void hat_stats_disable(struct hat *); +void hat_thread_exit(kthread_t *); + +/* + * Operations on a named address within a segment: + * + * void hat_memload(hat, addr, pp, attr, flags) + * load/lock the given page struct + * + * void hat_memload_array(hat, addr, len, ppa, attr, flags) + * load/lock the given array of page structs + * + * void hat_devload(hat, addr, len, pf, attr, flags) + * load/lock the given page frame number + * + * void hat_unlock(hat, addr, len) + * unlock a given range of addresses + * + * void hat_unload(hat, addr, len, flags) + * void hat_unload_callback(hat, addr, len, flags, callback) + * unload a given range of addresses (has optional callback) + * + * void hat_sync(hat, addr, len, flags) + * synchronize mapping with software data structures + * + * void hat_map(hat, addr, len, flags) + * + * void hat_setattr(hat, addr, len, attr) + * void hat_clrattr(hat, addr, len, attr) + * void hat_chgattr(hat, addr, len, attr) + * modify attributes for a range of addresses. skips any invalid mappings + * + * uint_t hat_getattr(hat, addr, *attr) + * returns attr for in *attr. returns 0 if there was a + * mapping and *attr is valid, nonzero if there was no mapping and + * *attr is not valid. + * + * size_t hat_getpagesize(hat, addr) + * returns pagesize in bytes for . returns -1 if there is + * no mapping. This is an advisory call. + * + * pfn_t hat_getpfnum(hat, addr) + * returns pfn for or PFN_INVALID if mapping is invalid. + * + * int hat_probe(hat, addr) + * return 0 if no valid mapping is present. Faster version + * of hat_getattr in certain architectures. + * + * int hat_share(dhat, daddr, shat, saddr, len, szc) + * + * void hat_unshare(hat, addr, len, szc) + * + * void hat_chgprot(hat, addr, len, vprot) + * This is a deprecated call. New segment drivers should store + * all attributes and use hat_*attr calls. + * Change the protections in the virtual address range + * given to the specified virtual protection. If vprot is ~PROT_WRITE, + * then remove write permission, leaving the other permissions + * unchanged. If vprot is ~PROT_USER, remove user permissions. + * + * void hat_flush_range(hat, addr, size) + * Invalidate a virtual address translation for the local CPU. + */ + +void hat_memload(struct hat *, caddr_t, struct page *, uint_t, uint_t); +void hat_memload_array(struct hat *, caddr_t, size_t, struct page **, + uint_t, uint_t); +void hat_memload_region(struct hat *, caddr_t, struct page *, uint_t, + uint_t, hat_region_cookie_t); +void hat_memload_array_region(struct hat *, caddr_t, size_t, struct page **, + uint_t, uint_t, hat_region_cookie_t); + +void hat_devload(struct hat *, caddr_t, size_t, pfn_t, uint_t, int); + +void hat_unlock(struct hat *, caddr_t, size_t); +void hat_unlock_region(struct hat *, caddr_t, size_t, hat_region_cookie_t); + +void hat_unload(struct hat *, caddr_t, size_t, uint_t); +void hat_unload_callback(struct hat *, caddr_t, size_t, uint_t, + hat_callback_t *); +void hat_flush_range(struct hat *, caddr_t, size_t); +void hat_sync(struct hat *, caddr_t, size_t, uint_t); +void hat_map(struct hat *, caddr_t, size_t, uint_t); +void hat_setattr(struct hat *, caddr_t, size_t, uint_t); +void hat_clrattr(struct hat *, caddr_t, size_t, uint_t); +void hat_chgattr(struct hat *, caddr_t, size_t, uint_t); +uint_t hat_getattr(struct hat *, caddr_t, uint_t *); +ssize_t hat_getpagesize(struct hat *, caddr_t); +pfn_t hat_getpfnum(struct hat *, caddr_t); +int hat_probe(struct hat *, caddr_t); +int hat_share(struct hat *, caddr_t, struct hat *, caddr_t, size_t, uint_t); +void hat_unshare(struct hat *, caddr_t, size_t, uint_t); +void hat_chgprot(struct hat *, caddr_t, size_t, uint_t); +void hat_reserve(struct as *, caddr_t, size_t); +pfn_t va_to_pfn(void *); +uint64_t va_to_pa(void *); + +/* + * Kernel Physical Mapping (segkpm) hat interface routines. + */ +caddr_t hat_kpm_mapin(struct page *, struct kpme *); +void hat_kpm_mapout(struct page *, struct kpme *, caddr_t); +caddr_t hat_kpm_mapin_pfn(pfn_t); +void hat_kpm_mapout_pfn(pfn_t); +caddr_t hat_kpm_page2va(struct page *, int); +struct page *hat_kpm_vaddr2page(caddr_t); +int hat_kpm_fault(struct hat *, caddr_t); +void hat_kpm_mseghash_clear(int); +void hat_kpm_mseghash_update(pgcnt_t, struct memseg *); +void hat_kpm_addmem_mseg_update(struct memseg *, pgcnt_t, offset_t); +void hat_kpm_addmem_mseg_insert(struct memseg *); +void hat_kpm_addmem_memsegs_update(struct memseg *); +caddr_t hat_kpm_mseg_reuse(struct memseg *); +void hat_kpm_delmem_mseg_update(struct memseg *, struct memseg **); +void hat_kpm_split_mseg_update(struct memseg *, struct memseg **, + struct memseg *, struct memseg *, struct memseg *); +void hat_kpm_walk(void (*)(void *, void *, size_t), void *); + +/* + * Operations on all translations for a given page(s) + * + * void hat_page_setattr(pp, flag) + * void hat_page_clrattr(pp, flag) + * used to set/clr red/mod bits. + * + * uint hat_page_getattr(pp, flag) + * If flag is specified, returns 0 if attribute is disabled + * and non zero if enabled. If flag specifes multiple attributs + * then returns 0 if ALL atriibutes are disabled. This is an advisory + * call. + * + * int hat_pageunload(pp, forceflag) + * Unload all translations attached to pp. On x86 the bulk of the work is + * done by hat_page_inval. + * + * void hat_page_inval(pp, pgsz, curhat) + * Unload translations attached to pp. If curhat is provided, only the + * translation for that process is unloaded, otherwise all are unloaded. + * + * uint_t hat_pagesync(pp, flags) + * get hw stats from hardware into page struct and reset hw stats + * returns attributes of page + * + * ulong_t hat_page_getshare(pp) + * returns approx number of mappings to this pp. A return of 0 implies + * there are no mappings to the page. + * + * faultcode_t hat_softlock(hat, addr, lenp, ppp, flags); + * called to softlock pages for zero copy tcp + * + * void hat_page_demote(pp); + * unload all large mappings to pp and decrease p_szc of all + * constituent pages according to the remaining mappings. + */ + +void hat_page_setattr(struct page *, uint_t); +void hat_page_clrattr(struct page *, uint_t); +uint_t hat_page_getattr(struct page *, uint_t); +int hat_pageunload(struct page *, uint_t); +void hat_page_inval(struct page *, uint_t, struct hat *); +uint_t hat_pagesync(struct page *, uint_t); +ulong_t hat_page_getshare(struct page *); +int hat_page_checkshare(struct page *, ulong_t); +faultcode_t hat_softlock(struct hat *, caddr_t, size_t *, + struct page **, uint_t); +void hat_page_demote(struct page *); + +/* + * Rountine to expose supported HAT features to PIM. + */ +enum hat_features { + HAT_SHARED_PT, /* Shared page tables */ + HAT_DYNAMIC_ISM_UNMAP, /* hat_pageunload() handles ISM pages */ + HAT_VMODSORT, /* support for VMODSORT flag of vnode */ + HAT_SHARED_REGIONS /* shared regions support */ +}; + +int hat_supported(enum hat_features, void *); + +/* + * Services provided to the hat: + * + * void as_signal_proc(as, siginfo) + * deliver signal to all processes that have this as. + * + * int hat_setstat(as, addr, len, rmbits) + * informs hatstat layer that ref/mod bits need to be updated for + * address range. Returns 0 on success, 1 for failure. + */ +void as_signal_proc(struct as *, k_siginfo_t *siginfo); +void hat_setstat(struct as *, caddr_t, size_t, uint_t); + +/* + * Flags to pass to hat routines. + * + * Certain flags only apply to some interfaces: + * + * HAT_LOAD Default flags to load a translation to the page. + * HAT_LOAD_LOCK Lock down mapping resources; hat_map(), hat_memload(), + * and hat_devload(). + * HAT_LOAD_ADV Advisory load - Load translation if and only if + * sufficient MMU resources exist (i.e., do not steal). + * HAT_LOAD_SHARE A flag to hat_memload() to indicate h/w page tables + * that map some user pages (not kas) is shared by more + * than one process (eg. ISM). + * HAT_LOAD_CONTIG Pages are contigous + * HAT_LOAD_NOCONSIST Do not add mapping to mapping list. + * HAT_LOAD_REMAP Reload a valid pte with a different page frame. + * HAT_RELOAD_SHARE Reload a shared page table entry. Some platforms + * may require different actions than on the first + * load of a shared mapping. + * HAT_NO_KALLOC Do not kmem_alloc while creating the mapping; at this + * point, it's setting up mapping to allocate internal + * hat layer data structures. This flag forces hat layer + * to tap its reserves in order to prevent infinite + * recursion. + * HAT_LOAD_TEXT A flag to hat_memload() to indicate loading text pages. + */ + +/* + * Flags for hat_memload/hat_devload + */ +#define HAT_FLAGS_RESV 0xFF000000 /* resv for hat impl */ +#define HAT_LOAD 0x00 +#define HAT_LOAD_LOCK 0x01 +#define HAT_LOAD_ADV 0x04 +#define HAT_LOAD_CONTIG 0x10 +#define HAT_LOAD_NOCONSIST 0x20 +#define HAT_LOAD_SHARE 0x40 +#define HAT_LOAD_REMAP 0x80 +#define HAT_RELOAD_SHARE 0x100 +#define HAT_NO_KALLOC 0x200 +#define HAT_LOAD_TEXT 0x400 + +/* + * Flags for initializing disable_*large_pages. + * + * HAT_AUTO_TEXT Get MMU specific disable_auto_text_large_pages + * HAT_AUTO_DATA Get MMU specific disable_auto_data_large_pages + */ +#define HAT_AUTO_TEXT 0x800 +#define HAT_AUTO_DATA 0x1000 + +/* + * Attributes for hat_memload/hat_devload/hat_*attr + * are a superset of prot flags defined in mman.h. + */ +#define HAT_PLAT_ATTR_MASK 0xF00000 +#define HAT_PROT_MASK 0x0F + +#define HAT_NOFAULT 0x10 +#define HAT_NOSYNC 0x20 + +/* + * Advisory ordering attributes. Apply only to device mappings. + * + * HAT_STRICTORDER: the CPU must issue the references in order, as the + * programmer specified. This is the default. + * HAT_UNORDERED_OK: the CPU may reorder the references (this is all kinds + * of reordering; store or load with store or load). + * HAT_MERGING_OK: merging and batching: the CPU may merge individual stores + * to consecutive locations (for example, turn two consecutive byte + * stores into one halfword store), and it may batch individual loads + * (for example, turn two consecutive byte loads into one halfword load). + * This also implies re-ordering. + * HAT_LOADCACHING_OK: the CPU may cache the data it fetches and reuse it + * until another store occurs. The default is to fetch new data + * on every load. This also implies merging. + * HAT_STORECACHING_OK: the CPU may keep the data in the cache and push it to + * the device (perhaps with other data) at a later time. The default is + * to push the data right away. This also implies load caching. + */ +#define HAT_STRICTORDER 0x0000 +#define HAT_UNORDERED_OK 0x0100 +#define HAT_MERGING_OK 0x0200 +#define HAT_LOADCACHING_OK 0x0300 +#define HAT_STORECACHING_OK 0x0400 +#define HAT_ORDER_MASK 0x0700 + +/* endian attributes */ +#define HAT_NEVERSWAP 0x0000 +#define HAT_STRUCTURE_BE 0x1000 +#define HAT_STRUCTURE_LE 0x2000 +#define HAT_ENDIAN_MASK 0x3000 + +/* flags for hat_softlock */ +#define HAT_COW 0x0001 + +/* + * Flags for hat_unload + */ +#define HAT_UNLOAD 0x00 +#define HAT_UNLOAD_NOSYNC 0x02 +#define HAT_UNLOAD_UNLOCK 0x04 +#define HAT_UNLOAD_OTHER 0x08 +#define HAT_UNLOAD_UNMAP 0x10 + +/* + * Flags for hat_pagesync, hat_getstat, hat_sync + */ +#define HAT_SYNC_DONTZERO 0x00 +#define HAT_SYNC_ZERORM 0x01 +/* Additional flags for hat_pagesync */ +#define HAT_SYNC_STOPON_REF 0x02 +#define HAT_SYNC_STOPON_MOD 0x04 +#define HAT_SYNC_STOPON_RM (HAT_SYNC_STOPON_REF | HAT_SYNC_STOPON_MOD) +#define HAT_SYNC_STOPON_SHARED 0x08 + +/* + * Flags for hat_dup + * + * HAT_DUP_ALL dup entire address space + * HAT_DUP_COW dup plus hat_clrattr(..PROT_WRITE) on newas + */ +#define HAT_DUP_ALL 1 +#define HAT_DUP_COW 2 +#define HAT_DUP_SRD 3 + + +/* + * Flags for hat_map + */ +#define HAT_MAP 0x00 + +/* + * Flag for hat_pageunload + */ +#define HAT_ADV_PGUNLOAD 0x00 +#define HAT_FORCE_PGUNLOAD 0x01 +#define HAT_CURPROC_PGUNLOAD 0x02 + +/* + * Attributes for hat_page_*attr, hat_setstats and + * returned by hat_pagesync. + */ +#define P_MOD 0x1 /* the modified bit */ +#define P_REF 0x2 /* the referenced bit */ +#define P_RO 0x4 /* Read only page */ +#define P_NSH 0x8 /* Not to shuffle v_pages */ + +#define hat_ismod(pp) (hat_page_getattr(pp, P_MOD)) +#define hat_isref(pp) (hat_page_getattr(pp, P_REF)) +#define hat_isro(pp) (hat_page_getattr(pp, P_RO)) + +#define hat_setmod(pp) (hat_page_setattr(pp, P_MOD)) +#define hat_setmod_only(pp) (hat_page_setattr(pp, P_MOD|P_NSH)) +#define hat_setref(pp) (hat_page_setattr(pp, P_REF)) +#define hat_setrefmod(pp) (hat_page_setattr(pp, P_REF|P_MOD)) + +#define hat_clrmod(pp) (hat_page_clrattr(pp, P_MOD)) +#define hat_clrref(pp) (hat_page_clrattr(pp, P_REF)) +#define hat_clrrefmod(pp) (hat_page_clrattr(pp, P_REF|P_MOD)) + +#define hat_page_is_mapped(pp) (hat_page_getshare(pp)) + +/* + * hat_setup is being used in sparc/os/sundep.c + */ +void hat_setup(struct hat *, int); + +/* + * Flags for hat_setup + */ +#define HAT_DONTALLOC 0 +#define HAT_ALLOC 1 +#define HAT_INIT 2 + +/* + * Other routines, for statistics + */ +int hat_startstat(struct as *); +void hat_getstat(struct as *, caddr_t, size_t, uint_t, char *, int); +void hat_freestat(struct as *, int); +void hat_resvstat(size_t, struct as *, caddr_t); + +/* + * Relocation callback routines. Currently only sfmmu HAT supports + * these. + */ +extern int hat_add_callback(id_t, caddr_t, uint_t, uint_t, void *, + pfn_t *, void **); +extern id_t hat_register_callback(int, + int (*prehandler)(caddr_t, uint_t, uint_t, void *), + int (*posthandler)(caddr_t, uint_t, uint_t, void *, pfn_t), + int (*errhandler)(caddr_t, uint_t, uint_t, void *), int); +extern void hat_delete_callback(caddr_t, uint_t, void *, uint_t, void *); + +/* + * hat_add_callback()/hat_delete_callback() flags. + */ +#define HAC_NOSLEEP 0x0 +#define HAC_SLEEP 0x1 +#define HAC_PAGELOCK 0x2 + +/* + * Suspend/unsuspend handler callback arguments. + */ +#define HAT_SUSPEND 0x0010 +#define HAT_UNSUSPEND 0x0010 +#define HAT_PRESUSPEND 0x0020 +#define HAT_POSTUNSUSPEND 0x0020 + +/* + * Error handler callback arguments. See the block comments + * before the implementation of hat_add_callback() for an + * explanation of what these mean. + */ +#define HAT_CB_ERR_LEAKED 0x1 + +#endif /* _KERNEL */ + +/* + * The size of the bit array for ref and mod bit storage must be a power of 2. + * 2 bits are collected for each page. Below the power used is 4, + * which is 16 8-bit characters = 128 bits, ref and mod bit information + * for 64 pages. + */ +#define HRM_SHIFT 4 +#define HRM_BYTES (1 << HRM_SHIFT) +#define HRM_PAGES ((HRM_BYTES * NBBY) / 2) +#define HRM_PGPERBYTE (NBBY/2) +#define HRM_PGBYTEMASK (HRM_PGPERBYTE-1) + +#define HRM_PGOFFMASK ((HRM_PGPERBYTE-1) << MMU_PAGESHIFT) +#define HRM_BASEOFFSET (((MMU_PAGESIZE * HRM_PAGES) - 1)) +#define HRM_BASEMASK (~(HRM_BASEOFFSET)) + +#define HRM_BASESHIFT (MMU_PAGESHIFT + (HRM_SHIFT + 2)) +#define HRM_PAGEMASK (MMU_PAGEMASK ^ HRM_BASEMASK) + +#define HRM_HASHSIZE 0x200 +#define HRM_HASHMASK (HRM_HASHSIZE - 1) + +#define HRM_BLIST_INCR 0x200 + +/* + * The structure for maintaining referenced and modified information + */ +struct hrmstat { + struct as *hrm_as; /* stat block belongs to this as */ + uintptr_t hrm_base; /* base of block */ + ushort_t hrm_id; /* opaque identifier, one of a_vbits */ + struct hrmstat *hrm_anext; /* as statistics block list */ + struct hrmstat *hrm_hnext; /* list for hashed blocks */ + uchar_t hrm_bits[HRM_BYTES]; /* the ref and mod bits */ +}; + +extern struct hrmstat **hrm_hashtab; + +/* + * For global monitoring of the reference and modified bits + * of all address spaces we reserve one id bit. + */ +#define HRM_SWSMONID 1 + + +#ifdef _KERNEL + +/* + * Hat locking functions + * XXX - these two functions are currently being used by hatstats + * they can be removed by using a per-as mutex for hatstats. + */ +void hat_enter(struct hat *); +void hat_exit(struct hat *); + +typedef void (*hat_rgn_cb_func_t)(caddr_t, caddr_t, caddr_t, + size_t, void *, u_offset_t); + +void hat_join_srd(struct hat *, vnode_t *); + +hat_region_cookie_t hat_join_region(struct hat *, caddr_t, size_t, void *, + u_offset_t, uchar_t, uchar_t, hat_rgn_cb_func_t, + uint_t); +void hat_leave_region(struct hat *, hat_region_cookie_t, + uint_t); +void hat_dup_region(struct hat *, hat_region_cookie_t); + +#define HAT_INVALID_REGION_COOKIE ((hat_region_cookie_t)-1) +#define HAT_IS_REGION_COOKIE_VALID(c) ((c) != HAT_INVALID_REGION_COOKIE) + +/* hat_join_region() flags */ + +#define HAT_REGION_TEXT 0x1 /* passed by segvn */ +#define HAT_REGION_ISM 0x2 /* for hat_share()/hat_unshare() */ + +#define HAT_REGION_TYPE_MASK (0x7) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_HAT_H */ diff --git a/illumos-x86_64/usr/include/vm/kpm.h b/illumos-x86_64/usr/include/vm/kpm.h new file mode 100644 index 00000000..06e1cee0 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/kpm.h @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _VM_KPM_H +#define _VM_KPM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _LP64 +#define SEGKPM_SUPPORT +#endif + +#ifndef _ASM + +/* + * Machine independent per instance kpm mapping structure + */ +struct kpme { + struct kpme *kpe_next; + struct kpme *kpe_prev; + struct page *kpe_page; /* back pointer to (start) page */ +}; + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_KPM_H */ diff --git a/illumos-x86_64/usr/include/vm/page.h b/illumos-x86_64/usr/include/vm/page.h new file mode 100644 index 00000000..bd17487b --- /dev/null +++ b/illumos-x86_64/usr/include/vm/page.h @@ -0,0 +1,1236 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017, Joyent, Inc. + * Copyright 2021 Oxide Computer Company + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_PAGE_H +#define _VM_PAGE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_KERNEL) || defined(_KMEMUSER) + +/* + * Shared/Exclusive lock. + */ + +/* + * Types of page locking supported by page_lock & friends. + */ +typedef enum { + SE_SHARED, + SE_EXCL /* exclusive lock (value == -1) */ +} se_t; + +/* + * For requesting that page_lock reclaim the page from the free list. + */ +typedef enum { + P_RECLAIM, /* reclaim page from free list */ + P_NO_RECLAIM /* DON`T reclaim the page */ +} reclaim_t; + +/* + * Callers of page_try_reclaim_lock and page_lock_es can use this flag + * to get SE_EXCL access before reader/writers are given access. + */ +#define SE_EXCL_WANTED 0x02 + +/* + * All page_*lock() requests will be denied unless this flag is set in + * the 'es' parameter. + */ +#define SE_RETIRED 0x04 + +#endif /* _KERNEL | _KMEMUSER */ + +typedef int selock_t; + +/* + * Define VM_STATS to turn on all sorts of statistic gathering about + * the VM layer. By default, it is only turned on when DEBUG is + * also defined. + */ +#ifdef DEBUG +#define VM_STATS +#endif /* DEBUG */ + +#ifdef VM_STATS +#define VM_STAT_ADD(stat) (stat)++ +#define VM_STAT_COND_ADD(cond, stat) ((void) (!(cond) || (stat)++)) +#else +#define VM_STAT_ADD(stat) +#define VM_STAT_COND_ADD(cond, stat) +#endif /* VM_STATS */ + +#ifdef _KERNEL + +/* + * PAGE_LLOCK_SIZE is 2 * NCPU, but no smaller than 128. + * PAGE_LLOCK_SHIFT is log2(PAGE_LLOCK_SIZE). + * + * We use ? : instead of #if because is included everywhere; + * NCPU_P2 is only a constant in the "unix" module. + * + */ +#define PAGE_LLOCK_SHIFT \ + ((unsigned)(((2*NCPU_P2) > 128) ? NCPU_LOG2 + 1 : 7)) + +#define PAGE_LLOCK_SIZE (1ul << PAGE_LLOCK_SHIFT) + +/* + * The number of low order 0 (or less variable) bits in the page_t address. + */ +#if defined(__sparc) +#define PP_SHIFT 7 +#else +#define PP_SHIFT 6 +#endif + +/* + * pp may be the root of a large page, and many low order bits will be 0. + * Shift and XOR multiple times to capture the good bits across the range of + * possible page sizes. + */ +#define PAGE_LLOCK_HASH(pp) \ + (((((uintptr_t)(pp) >> PP_SHIFT) ^ \ + ((uintptr_t)(pp) >> (PAGE_LLOCK_SHIFT + PP_SHIFT))) ^ \ + ((uintptr_t)(pp) >> ((PAGE_LLOCK_SHIFT * 2) + PP_SHIFT)) ^ \ + ((uintptr_t)(pp) >> ((PAGE_LLOCK_SHIFT * 3) + PP_SHIFT))) & \ + (PAGE_LLOCK_SIZE - 1)) + +#define page_struct_lock(pp) \ + mutex_enter(&page_llocks[PAGE_LLOCK_HASH(PP_PAGEROOT(pp))].pad_mutex) +#define page_struct_unlock(pp) \ + mutex_exit(&page_llocks[PAGE_LLOCK_HASH(PP_PAGEROOT(pp))].pad_mutex) + +#endif /* _KERNEL */ + +#include + +struct as; + +/* + * Each physical page has a page structure, which is used to maintain + * these pages as a cache. A page can be found via a hashed lookup + * based on the [vp, offset]. If a page has an [vp, offset] identity, + * then it is entered on a doubly linked circular list off the + * vnode using the vpnext/vpprev pointers. If the p_free bit + * is on, then the page is also on a doubly linked circular free + * list using next/prev pointers. If the "p_selock" and "p_iolock" + * are held, then the page is currently being read in (exclusive p_selock) + * or written back (shared p_selock). In this case, the next/prev pointers + * are used to link the pages together for a consecutive i/o request. If + * the page is being brought in from its backing store, then other processes + * will wait for the i/o to complete before attaching to the page since it + * will have an "exclusive" lock. + * + * Each page structure has the locks described below along with + * the fields they protect: + * + * p_selock This is a per-page shared/exclusive lock that is + * used to implement the logical shared/exclusive + * lock for each page. The "shared" lock is normally + * used in most cases while the "exclusive" lock is + * required to destroy or retain exclusive access to + * a page (e.g., while reading in pages). The appropriate + * lock is always held whenever there is any reference + * to a page structure (e.g., during i/o). + * (Note that with the addition of the "writer-lock-wanted" + * semantics (via SE_EWANTED), threads must not acquire + * multiple reader locks or else a deadly embrace will + * occur in the following situation: thread 1 obtains a + * reader lock; next thread 2 fails to get a writer lock + * but specified SE_EWANTED so it will wait by either + * blocking (when using page_lock_es) or spinning while + * retrying (when using page_try_reclaim_lock) until the + * reader lock is released; then thread 1 attempts to + * get another reader lock but is denied due to + * SE_EWANTED being set, and now both threads are in a + * deadly embrace.) + * + * p_hash + * p_vnode + * p_offset + * + * p_free + * p_age + * + * p_iolock This is a binary semaphore lock that provides + * exclusive access to the i/o list links in each + * page structure. It is always held while the page + * is on an i/o list (i.e., involved in i/o). That is, + * even though a page may be only `shared' locked + * while it is doing a write, the following fields may + * change anyway. Normally, the page must be + * `exclusively' locked to change anything in it. + * + * p_next + * p_prev + * + * The following fields are protected by the global page_llocks[]: + * + * p_lckcnt + * p_cowcnt + * + * The following lists are protected by the global page_freelock: + * + * page_cachelist + * page_freelist + * + * The following, for our purposes, are protected by + * the global freemem_lock: + * + * freemem + * freemem_wait + * freemem_cv + * + * The following fields are protected by hat layer lock(s). When a page + * structure is not mapped and is not associated with a vnode (after a call + * to page_hashout() for example) the p_nrm field may be modified with out + * holding the hat layer lock: + * + * p_nrm + * p_mapping + * p_share + * p_zoneid + * + * The following field is file system dependent. How it is used and + * the locking strategies applied are up to the individual file system + * implementation. + * + * p_fsdata + * + * The page structure is used to represent and control the system's + * physical pages. There is one instance of the structure for each + * page that is not permenately allocated. For example, the pages that + * hold the page structures are permanently held by the kernel + * and hence do not need page structures to track them. The array + * of page structures is allocated early on in the kernel's life and + * is based on the amount of available physical memory. + * + * Each page structure may simultaneously appear on several linked lists. + * The lists are: hash list, free or in i/o list, and a vnode's page list. + * Each type of list is protected by a different group of mutexes as described + * below: + * + * The hash list is used to quickly find a page when the page's vnode and + * offset within the vnode are known. Each page that is hashed is + * connected via the `p_hash' field. The anchor for each hash is in the + * array `page_hash'. An array of mutexes, `ph_mutex', protects the + * lists anchored by page_hash[]. To either search or modify a given hash + * list, the appropriate mutex in the ph_mutex array must be held. + * + * The free list contains pages that are `free to be given away'. For + * efficiency reasons, pages on this list are placed in two catagories: + * pages that are still associated with a vnode, and pages that are not + * associated with a vnode. Free pages always have their `p_free' bit set, + * free pages that are still associated with a vnode also have their + * `p_age' bit set. Pages on the free list are connected via their + * `p_next' and `p_prev' fields. When a page is involved in some sort + * of i/o, it is not free and these fields may be used to link associated + * pages together. At the moment, the free list is protected by a + * single mutex `page_freelock'. The list of free pages still associated + * with a vnode is anchored by `page_cachelist' while other free pages + * are anchored in architecture dependent ways (to handle page coloring etc.). + * + * Pages associated with a given vnode appear on a list anchored in the + * vnode by the `v_pages' field. They are linked together with + * `p_vpnext' and `p_vpprev'. The field `p_offset' contains a page's + * offset within the vnode. The pages on this list are not kept in + * offset order. These lists, in a manner similar to the hash lists, + * are protected by an array of mutexes called `vph_hash'. Before + * searching or modifying this chain the appropriate mutex in the + * vph_hash[] array must be held. + * + * Again, each of the lists that a page can appear on is protected by a + * mutex. Before reading or writing any of the fields comprising the + * list, the appropriate lock must be held. These list locks should only + * be held for very short intervals. + * + * In addition to the list locks, each page structure contains a + * shared/exclusive lock that protects various fields within it. + * To modify one of these fields, the `p_selock' must be exclusively held. + * To read a field with a degree of certainty, the lock must be at least + * held shared. + * + * Removing a page structure from one of the lists requires holding + * the appropriate list lock and the page's p_selock. A page may be + * prevented from changing identity, being freed, or otherwise modified + * by acquiring p_selock shared. + * + * To avoid deadlocks, a strict locking protocol must be followed. Basically + * there are two cases: In the first case, the page structure in question + * is known ahead of time (e.g., when the page is to be added or removed + * from a list). In the second case, the page structure is not known and + * must be found by searching one of the lists. + * + * When adding or removing a known page to one of the lists, first the + * page must be exclusively locked (since at least one of its fields + * will be modified), second the lock protecting the list must be acquired, + * third the page inserted or deleted, and finally the list lock dropped. + * + * The more interesting case occures when the particular page structure + * is not known ahead of time. For example, when a call is made to + * page_lookup(), it is not known if a page with the desired (vnode and + * offset pair) identity exists. So the appropriate mutex in ph_mutex is + * acquired, the hash list searched, and if the desired page is found + * an attempt is made to lock it. The attempt to acquire p_selock must + * not block while the hash list lock is held. A deadlock could occure + * if some other process was trying to remove the page from the list. + * The removing process (following the above protocol) would have exclusively + * locked the page, and be spinning waiting to acquire the lock protecting + * the hash list. Since the searching process holds the hash list lock + * and is waiting to acquire the page lock, a deadlock occurs. + * + * The proper scheme to follow is: first, lock the appropriate list, + * search the list, and if the desired page is found either use + * page_trylock() (which will not block) or pass the address of the + * list lock to page_lock(). If page_lock() can not acquire the page's + * lock, it will drop the list lock before going to sleep. page_lock() + * returns a value to indicate if the list lock was dropped allowing the + * calling program to react appropriately (i.e., retry the operation). + * + * If the list lock was dropped before the attempt at locking the page + * was made, checks would have to be made to ensure that the page had + * not changed identity before its lock was obtained. This is because + * the interval between dropping the list lock and acquiring the page + * lock is indeterminate. + * + * In addition, when both a hash list lock (ph_mutex[]) and a vnode list + * lock (vph_mutex[]) are needed, the hash list lock must be acquired first. + * The routine page_hashin() is a good example of this sequence. + * This sequence is ASSERTed by checking that the vph_mutex[] is not held + * just before each acquisition of one of the mutexs in ph_mutex[]. + * + * So, as a quick summary: + * + * pse_mutex[]'s protect the p_selock and p_cv fields. + * + * p_selock protects the p_free, p_age, p_vnode, p_offset and p_hash, + * + * ph_mutex[]'s protect the page_hash[] array and its chains. + * + * vph_mutex[]'s protect the v_pages field and the vp page chains. + * + * First lock the page, then the hash chain, then the vnode chain. When + * this is not possible `trylocks' must be used. Sleeping while holding + * any of these mutexes (p_selock is not a mutex) is not allowed. + * + * + * field reading writing ordering + * ====================================================================== + * p_vnode p_selock(E,S) p_selock(E) + * p_offset + * p_free + * p_age + * ===================================================================== + * p_hash p_selock(E,S) p_selock(E) && p_selock, ph_mutex + * ph_mutex[] + * ===================================================================== + * p_vpnext p_selock(E,S) p_selock(E) && p_selock, vph_mutex + * p_vpprev vph_mutex[] + * ===================================================================== + * When the p_free bit is set: + * + * p_next p_selock(E,S) p_selock(E) && p_selock, + * p_prev page_freelock page_freelock + * + * When the p_free bit is not set: + * + * p_next p_selock(E,S) p_selock(E) && p_selock, p_iolock + * p_prev p_iolock + * ===================================================================== + * p_selock pse_mutex[] pse_mutex[] can`t acquire any + * p_cv other mutexes or + * sleep while holding + * this lock. + * ===================================================================== + * p_lckcnt p_selock(E,S) p_selock(E) + * OR + * p_selock(S) && + * page_llocks[] + * p_cowcnt + * ===================================================================== + * p_nrm hat layer lock hat layer lock + * p_mapping + * p_pagenum + * ===================================================================== + * + * where: + * E----> exclusive version of p_selock. + * S----> shared version of p_selock. + * + * + * Global data structures and variable: + * + * field reading writing ordering + * ===================================================================== + * page_hash[] ph_mutex[] ph_mutex[] can hold this lock + * before acquiring + * a vph_mutex or + * pse_mutex. + * ===================================================================== + * vp->v_pages vph_mutex[] vph_mutex[] can only acquire + * a pse_mutex while + * holding this lock. + * ===================================================================== + * page_cachelist page_freelock page_freelock can't acquire any + * page_freelist page_freelock page_freelock + * ===================================================================== + * freemem freemem_lock freemem_lock can't acquire any + * freemem_wait other mutexes while + * freemem_cv holding this mutex. + * ===================================================================== + * + * Page relocation, PG_NORELOC and P_NORELOC. + * + * Pages may be relocated using the page_relocate() interface. Relocation + * involves moving the contents and identity of a page to another, free page. + * To relocate a page, the SE_EXCL lock must be obtained. The way to prevent + * a page from being relocated is to hold the SE_SHARED lock (the SE_EXCL + * lock must not be held indefinitely). If the page is going to be held + * SE_SHARED indefinitely, then the PG_NORELOC hint should be passed + * to page_create_va so that pages that are prevented from being relocated + * can be managed differently by the platform specific layer. + * + * Pages locked in memory using page_pp_lock (p_lckcnt/p_cowcnt != 0) + * are guaranteed to be held in memory, but can still be relocated + * providing the SE_EXCL lock can be obtained. + * + * The P_NORELOC bit in the page_t.p_state field is provided for use by + * the platform specific code in managing pages when the PG_NORELOC + * hint is used. + * + * Memory delete and page locking. + * + * The set of all usable pages is managed using the global page list as + * implemented by the memseg structure defined below. When memory is added + * or deleted this list changes. Additions to this list guarantee that the + * list is never corrupt. In order to avoid the necessity of an additional + * lock to protect against failed accesses to the memseg being deleted and, + * more importantly, the page_ts, the memseg structure is never freed and the + * page_t virtual address space is remapped to a page (or pages) of + * zeros. If a page_t is manipulated while it is p_selock'd, or if it is + * locked indirectly via a hash or freelist lock, it is not possible for + * memory delete to collect the page and so that part of the page list is + * prevented from being deleted. If the page is referenced outside of one + * of these locks, it is possible for the page_t being referenced to be + * deleted. Examples of this are page_t pointers returned by + * page_numtopp_nolock, page_first and page_next. Providing the page_t + * is re-checked after taking the p_selock (for p_vnode != NULL), the + * remapping to the zero pages will be detected. + * + * + * Page size (p_szc field) and page locking. + * + * p_szc field of free pages is changed by free list manager under freelist + * locks and is of no concern to the rest of VM subsystem. + * + * p_szc changes of allocated anonymous (swapfs) can only be done only after + * exclusively locking all constituent pages and calling hat_pageunload() on + * each of them. To prevent p_szc changes of non free anonymous (swapfs) large + * pages it's enough to either lock SHARED any of constituent pages or prevent + * hat_pageunload() by holding hat level lock that protects mapping lists (this + * method is for hat code only) + * + * To increase (promote) p_szc of allocated non anonymous file system pages + * one has to first lock exclusively all involved constituent pages and call + * hat_pageunload() on each of them. To prevent p_szc promote it's enough to + * either lock SHARED any of constituent pages that will be needed to make a + * large page or prevent hat_pageunload() by holding hat level lock that + * protects mapping lists (this method is for hat code only). + * + * To decrease (demote) p_szc of an allocated non anonymous file system large + * page one can either use the same method as used for changeing p_szc of + * anonymous large pages or if it's not possible to lock all constituent pages + * exclusively a different method can be used. In the second method one only + * has to exclusively lock one of constituent pages but then one has to + * acquire further locks by calling page_szc_lock() and + * hat_page_demote(). hat_page_demote() acquires hat level locks and then + * demotes the page. This mechanism relies on the fact that any code that + * needs to prevent p_szc of a file system large page from changeing either + * locks all constituent large pages at least SHARED or locks some pages at + * least SHARED and calls page_szc_lock() or uses hat level page locks. + * Demotion using this method is implemented by page_demote_vp_pages(). + * Please see comments in front of page_demote_vp_pages(), hat_page_demote() + * and page_szc_lock() for more details. + * + * Lock order: p_selock, page_szc_lock, ph_mutex/vph_mutex/freelist, + * hat level locks. + */ + +typedef struct page { + u_offset_t p_offset; /* offset into vnode for this page */ + struct vnode *p_vnode; /* vnode that this page is named by */ + selock_t p_selock; /* shared/exclusive lock on the page */ +#if defined(_LP64) + uint_t p_vpmref; /* vpm ref - index of the vpmap_t */ +#endif + struct page *p_hash; /* hash by [vnode, offset] */ + struct page *p_vpnext; /* next page in vnode list */ + struct page *p_vpprev; /* prev page in vnode list */ + struct page *p_next; /* next page in free/intrans lists */ + struct page *p_prev; /* prev page in free/intrans lists */ + ushort_t p_lckcnt; /* number of locks on page data */ + ushort_t p_cowcnt; /* number of copy on write lock */ + kcondvar_t p_cv; /* page struct's condition var */ + kcondvar_t p_io_cv; /* for iolock */ + uchar_t p_iolock_state; /* replaces p_iolock */ + volatile uchar_t p_szc; /* page size code */ + uchar_t p_fsdata; /* file system dependent byte */ + uchar_t p_state; /* p_free, p_noreloc */ + uchar_t p_nrm; /* non-cache, ref, mod readonly bits */ +#if defined(__sparc) + uchar_t p_vcolor; /* virtual color */ +#else + uchar_t p_embed; /* x86 - changes p_mapping & p_index */ +#endif + uchar_t p_index; /* MPSS mapping info. Not used on x86 */ + uchar_t p_toxic; /* page has an unrecoverable error */ + void *p_mapping; /* hat specific translation info */ + pfn_t p_pagenum; /* physical page number */ + + uint_t p_share; /* number of translations */ + short p_zoneid; /* zone page use tracking */ + short p_pad1; /* TBD */ + uint_t p_slckcnt; /* number of softlocks */ +#if defined(__sparc) + uint_t p_kpmref; /* number of kpm mapping sharers */ + struct kpme *p_kpmelist; /* kpm specific mapping info */ +#else + /* index of entry in p_map when p_embed is set */ + uint_t p_mlentry; +#endif +#if defined(_LP64) + kmutex_t p_ilock; /* protects p_vpmref */ +#else + uint64_t p_msresv_2; /* page allocation debugging */ +#endif +} page_t; + + +typedef page_t devpage_t; +#define devpage page + +#define PAGE_LOCK_MAXIMUM \ + ((1 << (sizeof (((page_t *)0)->p_lckcnt) * NBBY)) - 1) + +#define PAGE_SLOCK_MAXIMUM UINT_MAX + +/* + * Page hash table is a power-of-two in size, externally chained + * through the hash field. PAGE_HASHAVELEN is the average length + * desired for this chain, from which the size of the page_hash + * table is derived at boot time and stored in the kernel variable + * page_hashsz. In the hash function it is given by PAGE_HASHSZ. + * + * PAGE_HASH_FUNC returns an index into the page_hash[] array. This + * index is also used to derive the mutex that protects the chain. + * + * In constructing the hash function, first we dispose of unimportant bits + * (page offset from "off" and the low 3 bits of "vp" which are zero for + * struct alignment). Then shift and sum the remaining bits a couple times + * in order to get as many source bits from the two source values into the + * resulting hashed value. Note that this will perform quickly, since the + * shifting/summing are fast register to register operations with no additional + * memory references). + * + * PH_SHIFT_SIZE is the amount to use for the successive shifts in the hash + * function below. The actual value is LOG2(PH_TABLE_SIZE), so that as many + * bits as possible will filter thru PAGE_HASH_FUNC() and PAGE_HASH_MUTEX(). + * + * We use ? : instead of #if because is included everywhere; + * NCPU maps to a global variable outside of the "unix" module. + */ +#if defined(_LP64) +#define PH_SHIFT_SIZE ((NCPU < 4) ? 7 : (NCPU_LOG2 + 1)) +#else /* 32 bits */ +#define PH_SHIFT_SIZE ((NCPU < 4) ? 4 : 7) +#endif /* _LP64 */ + +#define PH_TABLE_SIZE (1ul << PH_SHIFT_SIZE) + +/* + * + * We take care to get as much randomness as possible from both the vp and + * the offset. Workloads can have few vnodes with many offsets, many vnodes + * with few offsets or a moderate mix of both. This hash should perform + * equally well for each of these possibilities and for all types of memory + * allocations. + * + * vnodes representing files are created over a long period of time and + * have good variation in the upper vp bits, and the right shifts below + * capture these bits. However, swap vnodes are created quickly in a + * narrow vp* range. Refer to comments at swap_alloc: vnum has exactly + * AN_VPSHIFT bits, so the kmem_alloc'd vnode addresses have approximately + * AN_VPSHIFT bits of variation above their VNODE_ALIGN low order 0 bits. + * Spread swap vnodes widely in the hash table by XOR'ing a term with the + * vp bits of variation left shifted to the top of the range. + */ + +#define PAGE_HASHSZ page_hashsz +#define PAGE_HASHAVELEN 4 +#define PAGE_HASH_FUNC(vp, off) \ + (((((uintptr_t)(off) >> PAGESHIFT) ^ \ + ((uintptr_t)(off) >> (PAGESHIFT + PH_SHIFT_SIZE))) ^ \ + (((uintptr_t)(vp) >> 3) ^ \ + ((uintptr_t)(vp) >> (3 + PH_SHIFT_SIZE)) ^ \ + ((uintptr_t)(vp) >> (3 + 2 * PH_SHIFT_SIZE)) ^ \ + ((uintptr_t)(vp) << \ + (page_hashsz_shift - AN_VPSHIFT - VNODE_ALIGN_LOG2)))) & \ + (PAGE_HASHSZ - 1)) + +#ifdef _KERNEL + +/* + * The page hash value is re-hashed to an index for the ph_mutex array. + * + * For 64 bit kernels, the mutex array is padded out to prevent false + * sharing of cache sub-blocks (64 bytes) of adjacent mutexes. + * + * For 32 bit kernels, we don't want to waste kernel address space with + * padding, so instead we rely on the hash function to introduce skew of + * adjacent vnode/offset indexes (the left shift part of the hash function). + * Since sizeof (kmutex_t) is 8, we shift an additional 3 to skew to a different + * 64 byte sub-block. + */ +extern pad_mutex_t ph_mutex[]; + +#define PAGE_HASH_MUTEX(x) \ + &(ph_mutex[((x) ^ (((x) >> PH_SHIFT_SIZE) + ((x) << 3))) & \ + (PH_TABLE_SIZE - 1)].pad_mutex) + +/* + * Flags used while creating pages. + */ +#define PG_EXCL 0x0001 +#define PG_WAIT 0x0002 /* Blocking memory allocations */ +#define PG_PHYSCONTIG 0x0004 /* NOT SUPPORTED */ +#define PG_MATCH_COLOR 0x0008 /* SUPPORTED by free list routines */ +#define PG_NORELOC 0x0010 /* Non-relocatable alloc hint. */ + /* Page must be PP_ISNORELOC */ +#define PG_PANIC 0x0020 /* system will panic if alloc fails */ +#define PG_PUSHPAGE 0x0040 /* alloc may use reserve */ +#define PG_LOCAL 0x0080 /* alloc from given lgrp only */ +#define PG_NORMALPRI 0x0100 /* PG_WAIT like priority, but */ + /* non-blocking */ +/* + * When p_selock has the SE_EWANTED bit set, threads waiting for SE_EXCL + * access are given priority over all other waiting threads. + */ +#define SE_EWANTED 0x40000000 +#define PAGE_LOCKED(pp) (((pp)->p_selock & ~SE_EWANTED) != 0) +#define PAGE_SHARED(pp) (((pp)->p_selock & ~SE_EWANTED) > 0) +#define PAGE_EXCL(pp) ((pp)->p_selock < 0) +#define PAGE_LOCKED_SE(pp, se) \ + ((se) == SE_EXCL ? PAGE_EXCL(pp) : PAGE_SHARED(pp)) + +extern long page_hashsz; +extern unsigned int page_hashsz_shift; +extern page_t **page_hash; + +extern pad_mutex_t page_llocks[]; /* page logical lock mutex */ +extern kmutex_t freemem_lock; /* freemem lock */ + +extern pgcnt_t total_pages; /* total pages in the system */ + +/* + * Variables controlling locking of physical memory. + */ +extern pgcnt_t pages_pp_maximum; /* tuning: lock + claim <= max */ +extern void init_pages_pp_maximum(void); + +struct lgrp; + +/* page_list_{add,sub} flags */ + +/* which list */ +#define PG_FREE_LIST 0x0001 +#define PG_CACHE_LIST 0x0002 + +/* where on list */ +#define PG_LIST_TAIL 0x0010 +#define PG_LIST_HEAD 0x0020 + +/* called from */ +#define PG_LIST_ISINIT 0x1000 + +/* + * Page frame operations. + */ +page_t *page_lookup(struct vnode *, u_offset_t, se_t); +page_t *page_lookup_create(struct vnode *, u_offset_t, se_t, page_t *, + spgcnt_t *, int); +page_t *page_lookup_nowait(struct vnode *, u_offset_t, se_t); +page_t *page_find(struct vnode *, u_offset_t); +page_t *page_exists(struct vnode *, u_offset_t); +int page_exists_physcontig(vnode_t *, u_offset_t, uint_t, page_t *[]); +int page_exists_forreal(struct vnode *, u_offset_t, uint_t *); +void page_needfree(spgcnt_t); +page_t *page_create(struct vnode *, u_offset_t, size_t, uint_t); +int page_alloc_pages(struct vnode *, struct seg *, caddr_t, page_t **, + page_t **, uint_t, int, int); +page_t *page_create_va_large(vnode_t *vp, u_offset_t off, size_t bytes, + uint_t flags, struct seg *seg, caddr_t vaddr, void *arg); +page_t *page_create_va(struct vnode *, u_offset_t, size_t, uint_t, + struct seg *, caddr_t); +int page_create_wait(pgcnt_t npages, uint_t flags); +void page_create_putback(spgcnt_t npages); +void page_free(page_t *, int); +void page_free_at_startup(page_t *); +void page_free_pages(page_t *); +void free_vp_pages(struct vnode *, u_offset_t, size_t); +int page_reclaim(page_t *, kmutex_t *); +int page_reclaim_pages(page_t *, kmutex_t *, uint_t); +void page_destroy(page_t *, int); +void page_destroy_pages(page_t *); +void page_destroy_free(page_t *); +void page_rename(page_t *, struct vnode *, u_offset_t); +int page_hashin(page_t *, struct vnode *, u_offset_t, kmutex_t *); +void page_hashout(page_t *, kmutex_t *); +int page_num_hashin(pfn_t, struct vnode *, u_offset_t); +void page_add(page_t **, page_t *); +void page_add_common(page_t **, page_t *); +void page_sub(page_t **, page_t *); +void page_sub_common(page_t **, page_t *); +page_t *page_get_freelist(struct vnode *, u_offset_t, struct seg *, + caddr_t, size_t, uint_t, struct lgrp *); + +page_t *page_get_cachelist(struct vnode *, u_offset_t, struct seg *, + caddr_t, uint_t, struct lgrp *); +#if defined(__i386) || defined(__amd64) +int page_chk_freelist(uint_t); +#endif +void page_list_add(page_t *, int); +void page_boot_demote(page_t *); +void page_promote_size(page_t *, uint_t); +void page_list_add_pages(page_t *, int); +void page_list_sub(page_t *, int); +void page_list_sub_pages(page_t *, uint_t); +void page_list_xfer(page_t *, int, int); +void page_list_break(page_t **, page_t **, size_t); +void page_list_concat(page_t **, page_t **); +void page_vpadd(page_t **, page_t *); +void page_vpsub(page_t **, page_t *); +int page_lock(page_t *, se_t, kmutex_t *, reclaim_t); +int page_lock_es(page_t *, se_t, kmutex_t *, reclaim_t, int); +void page_lock_clr_exclwanted(page_t *); +int page_trylock(page_t *, se_t); +int page_try_reclaim_lock(page_t *, se_t, int); +int page_tryupgrade(page_t *); +void page_downgrade(page_t *); +void page_unlock(page_t *); +void page_unlock_nocapture(page_t *); +void page_lock_delete(page_t *); +int page_deleted(page_t *); +int page_pp_lock(page_t *, int, int); +void page_pp_unlock(page_t *, int, int); +int page_xresv(pgcnt_t, uint_t, int (*)(void)); +int page_resv(pgcnt_t, uint_t); +void page_unresv(pgcnt_t); +void page_pp_useclaim(page_t *, page_t *, uint_t); +int page_addclaim(page_t *); +int page_subclaim(page_t *); +int page_addclaim_pages(page_t **); +int page_subclaim_pages(page_t **); +pfn_t page_pptonum(page_t *); +page_t *page_numtopp(pfn_t, se_t); +page_t *page_numtopp_noreclaim(pfn_t, se_t); +page_t *page_numtopp_nolock(pfn_t); +page_t *page_numtopp_nowait(pfn_t, se_t); +page_t *page_first(); +page_t *page_next(page_t *); +page_t *page_list_next(page_t *); +page_t *page_nextn(page_t *, ulong_t); +page_t *page_next_scan_init(void **); +page_t *page_next_scan_large(page_t *, ulong_t *, void **); +void prefetch_page_r(void *); +int ppcopy(page_t *, page_t *); +void page_relocate_hash(page_t *, page_t *); +void pagezero(page_t *, uint_t, uint_t); +void pagescrub(page_t *, uint_t, uint_t); +void page_io_lock(page_t *); +void page_io_unlock(page_t *); +int page_io_trylock(page_t *); +int page_iolock_assert(page_t *); +void page_iolock_init(page_t *); +void page_io_wait(page_t *); +int page_io_locked(page_t *); +pgcnt_t page_busy(int); +void page_lock_init(void); +ulong_t page_share_cnt(page_t *); +int page_isshared(page_t *); +int page_isfree(page_t *); +int page_isref(page_t *); +int page_ismod(page_t *); +int page_release(page_t *, int); +void page_retire_init(void); +int page_retire(uint64_t, uchar_t); +int page_retire_check(uint64_t, uint64_t *); +int page_unretire(uint64_t); +int page_unretire_pp(page_t *, int); +void page_tryretire(page_t *); +void page_retire_mdboot(); +uint64_t page_retire_pend_count(void); +uint64_t page_retire_pend_kas_count(void); +void page_retire_incr_pend_count(void *); +void page_retire_decr_pend_count(void *); +void page_clrtoxic(page_t *, uchar_t); +void page_settoxic(page_t *, uchar_t); + +int page_reclaim_mem(pgcnt_t, pgcnt_t, int); + +void page_set_props(page_t *, uint_t); +void page_clr_all_props(page_t *); +int page_clear_lck_cow(page_t *, int); + +kmutex_t *page_vnode_mutex(struct vnode *); +kmutex_t *page_se_mutex(struct page *); +kmutex_t *page_szc_lock(struct page *); +int page_szc_lock_assert(struct page *pp); + +/* + * Page relocation interfaces. page_relocate() is generic. + * page_get_replacement_page() is provided by the PSM. + * page_free_replacement_page() is generic. + */ +int group_page_trylock(page_t *, se_t); +void group_page_unlock(page_t *); +int page_relocate(page_t **, page_t **, int, int, spgcnt_t *, struct lgrp *); +int do_page_relocate(page_t **, page_t **, int, spgcnt_t *, struct lgrp *); +page_t *page_get_replacement_page(page_t *, struct lgrp *, uint_t); +void page_free_replacement_page(page_t *); +int page_relocate_cage(page_t **, page_t **); + +int page_try_demote_pages(page_t *); +int page_try_demote_free_pages(page_t *); +void page_demote_free_pages(page_t *); + +struct anon_map; + +void page_mark_migrate(struct seg *, caddr_t, size_t, struct anon_map *, + ulong_t, vnode_t *, u_offset_t, int); +void page_migrate(struct seg *, caddr_t, page_t **, pgcnt_t); + +/* + * Tell the PIM we are adding physical memory + */ +void add_physmem(page_t *, size_t, pfn_t); +void add_physmem_cb(page_t *, pfn_t); /* callback for page_t part */ + +/* + * hw_page_array[] is configured with hardware supported page sizes by + * platform specific code. + */ +typedef struct { + size_t hp_size; + uint_t hp_shift; + uint_t hp_colors; + pgcnt_t hp_pgcnt; /* base pagesize cnt */ +} hw_pagesize_t; + +extern hw_pagesize_t hw_page_array[]; +extern uint_t page_coloring_shift; +extern uint_t page_colors_mask; +extern int cpu_page_colors; +extern uint_t colorequiv; +extern uchar_t colorequivszc[]; + +uint_t page_num_pagesizes(void); +uint_t page_num_user_pagesizes(int); +size_t page_get_pagesize(uint_t); +size_t page_get_user_pagesize(uint_t n); +pgcnt_t page_get_pagecnt(uint_t); +uint_t page_get_shift(uint_t); +int page_szc(size_t); +int page_szc_user_filtered(size_t); + +/* page_get_replacement page flags */ +#define PGR_SAMESZC 0x1 /* only look for page size same as orig */ +#define PGR_NORELOC 0x2 /* allocate a P_NORELOC page */ + +/* + * macros for "masked arithmetic" + * The purpose is to step through all combinations of a set of bits while + * keeping some other bits fixed. Fixed bits need not be contiguous. The + * variable bits need not be contiguous either, or even right aligned. The + * trick is to set all fixed bits to 1, then increment, then restore the + * fixed bits. If incrementing causes a carry from a low bit position, the + * carry propagates thru the fixed bits, because they are temporarily set to 1. + * v is the value + * i is the increment + * eq_mask defines the fixed bits + * mask limits the size of the result + */ +#define ADD_MASKED(v, i, eq_mask, mask) \ + (((((v) | (eq_mask)) + (i)) & (mask) & ~(eq_mask)) | ((v) & (eq_mask))) + +/* + * convenience macro which increments by 1 + */ +#define INC_MASKED(v, eq_mask, mask) ADD_MASKED(v, 1, eq_mask, mask) + +#endif /* _KERNEL */ + +/* + * Constants used for the p_iolock_state + */ +#define PAGE_IO_INUSE 0x1 +#define PAGE_IO_WANTED 0x2 + +/* + * Constants used for page_release status + */ +#define PGREL_NOTREL 0x1 +#define PGREL_CLEAN 0x2 +#define PGREL_MOD 0x3 + +/* + * The p_state field holds what used to be the p_age and p_free + * bits. These fields are protected by p_selock (see above). + */ +#define P_FREE 0x80 /* Page on free list */ +#define P_NORELOC 0x40 /* Page is non-relocatable */ +#define P_MIGRATE 0x20 /* Migrate page on next touch */ +#define P_SWAP 0x10 /* belongs to vnode that is V_ISSWAP */ +#define P_BOOTPAGES 0x08 /* member of bootpages list */ +#define P_RAF 0x04 /* page retired at free */ + +#define PP_ISFREE(pp) ((pp)->p_state & P_FREE) +#define PP_ISAGED(pp) (((pp)->p_state & P_FREE) && \ + ((pp)->p_vnode == NULL)) +#define PP_ISNORELOC(pp) ((pp)->p_state & P_NORELOC) +#define PP_ISKAS(pp) (VN_ISKAS((pp)->p_vnode)) +#define PP_ISNORELOCKERNEL(pp) (PP_ISNORELOC(pp) && PP_ISKAS(pp)) +#define PP_ISMIGRATE(pp) ((pp)->p_state & P_MIGRATE) +#define PP_ISSWAP(pp) ((pp)->p_state & P_SWAP) +#define PP_ISBOOTPAGES(pp) ((pp)->p_state & P_BOOTPAGES) +#define PP_ISRAF(pp) ((pp)->p_state & P_RAF) + +#define PP_SETFREE(pp) ((pp)->p_state = ((pp)->p_state & ~P_MIGRATE) \ + | P_FREE) +#define PP_SETAGED(pp) ASSERT(PP_ISAGED(pp)) +#define PP_SETNORELOC(pp) ((pp)->p_state |= P_NORELOC) +#define PP_SETMIGRATE(pp) ((pp)->p_state |= P_MIGRATE) +#define PP_SETSWAP(pp) ((pp)->p_state |= P_SWAP) +#define PP_SETBOOTPAGES(pp) ((pp)->p_state |= P_BOOTPAGES) +#define PP_SETRAF(pp) ((pp)->p_state |= P_RAF) + +#define PP_CLRFREE(pp) ((pp)->p_state &= ~P_FREE) +#define PP_CLRAGED(pp) ASSERT(!PP_ISAGED(pp)) +#define PP_CLRNORELOC(pp) ((pp)->p_state &= ~P_NORELOC) +#define PP_CLRMIGRATE(pp) ((pp)->p_state &= ~P_MIGRATE) +#define PP_CLRSWAP(pp) ((pp)->p_state &= ~P_SWAP) +#define PP_CLRBOOTPAGES(pp) ((pp)->p_state &= ~P_BOOTPAGES) +#define PP_CLRRAF(pp) ((pp)->p_state &= ~P_RAF) + +/* + * Flags for page_t p_toxic, for tracking memory hardware errors. + * + * These flags are OR'ed into p_toxic with page_settoxic() to track which + * error(s) have occurred on a given page. The flags are cleared with + * page_clrtoxic(). Both page_settoxic() and page_cleartoxic use atomic + * primitives to manipulate the p_toxic field so no other locking is needed. + * + * When an error occurs on a page, p_toxic is set to record the error. The + * error could be a memory error or something else (i.e. a datapath). The Page + * Retire mechanism does not try to determine the exact cause of the error; + * Page Retire rightly leaves that sort of determination to FMA's Diagnostic + * Engine (DE). + * + * Note that, while p_toxic bits can be set without holding any locks, they + * should only be cleared while holding the page exclusively locked. + * There is one exception to this, the PR_CAPTURE bit is protected by a mutex + * within the page capture logic and thus to set or clear the bit, that mutex + * needs to be held. The page does not need to be locked but the page_clrtoxic + * function must be used as we need an atomic operation. + * Also note that there is what amounts to a hack to prevent recursion with + * large pages such that if we are unlocking a page and the PR_CAPTURE bit is + * set, we will only try to capture the page if the current threads T_CAPTURING + * flag is not set. If the flag is set, the unlock will not try to capture + * the page even though the PR_CAPTURE bit is set. + * + * Pages with PR_UE or PR_FMA flags are retired unconditionally, while pages + * with PR_MCE are retired if the system has not retired too many of them. + * + * A page must be exclusively locked to be retired. Pages can be retired if + * they are mapped, modified, or both, as long as they are not marked PR_UE, + * since pages with uncorrectable errors cannot be relocated in memory. + * Once a page has been successfully retired it is zeroed, attached to the + * retired_pages vnode and, finally, PR_RETIRED is set in p_toxic. The other + * p_toxic bits are NOT cleared. Pages are not left locked after retiring them + * to avoid special case code throughout the kernel; rather, page_*lock() will + * fail to lock the page, unless SE_RETIRED is passed as an argument. + * + * While we have your attention, go take a look at the comments at the + * beginning of page_retire.c too. + */ +#define PR_OK 0x00 /* no problem */ +#define PR_MCE 0x01 /* page has seen two or more CEs */ +#define PR_UE 0x02 /* page has an unhandled UE */ +#define PR_UE_SCRUBBED 0x04 /* page has seen a UE but was cleaned */ +#define PR_FMA 0x08 /* A DE wants this page retired */ +#define PR_CAPTURE 0x10 /* page is hashed on page_capture_hash[] */ +#define PR_RESV 0x20 /* Reserved for future use */ +#define PR_MSG 0x40 /* message(s) already printed for this page */ +#define PR_RETIRED 0x80 /* This page has been retired */ + +#define PR_REASONS (PR_UE | PR_MCE | PR_FMA) +#define PR_TOXIC (PR_UE) +#define PR_ERRMASK (PR_UE | PR_UE_SCRUBBED | PR_MCE | PR_FMA) +#define PR_TOXICFLAGS (0xCF) + +#define PP_RETIRED(pp) ((pp)->p_toxic & PR_RETIRED) +#define PP_TOXIC(pp) ((pp)->p_toxic & PR_TOXIC) +#define PP_PR_REQ(pp) (((pp)->p_toxic & PR_REASONS) && !PP_RETIRED(pp)) +#define PP_PR_NOSHARE(pp) \ + ((((pp)->p_toxic & (PR_RETIRED | PR_FMA | PR_UE)) == PR_FMA) && \ + !PP_ISKAS(pp)) + +/* + * Flags for page_unretire_pp + */ +#define PR_UNR_FREE 0x1 +#define PR_UNR_CLEAN 0x2 +#define PR_UNR_TEMP 0x4 + +/* + * kpm large page description. + * The virtual address range of segkpm is divided into chunks of + * kpm_pgsz. Each chunk is controlled by a kpm_page_t. The ushort + * is sufficient for 2^^15 * PAGESIZE, so e.g. the maximum kpm_pgsz + * for 8K is 256M and 2G for 64K pages. It it kept as small as + * possible to save physical memory space. + * + * There are 2 segkpm mapping windows within in the virtual address + * space when we have to prevent VAC alias conflicts. The so called + * Alias window (mappings are always by PAGESIZE) is controlled by + * kp_refcnta. The regular window is controlled by kp_refcnt for the + * normal operation, which is to use the largest available pagesize. + * When VAC alias conflicts are present within a chunk in the regular + * window the large page mapping is broken up into smaller PAGESIZE + * mappings. kp_refcntc is used to control the pages that are invoked + * in the conflict and kp_refcnts holds the active mappings done + * with the small page size. In non vac conflict mode kp_refcntc is + * also used as "go" indication (-1) for the trap level tsbmiss + * handler. + */ +typedef struct kpm_page { + short kp_refcnt; /* pages mapped large */ + short kp_refcnta; /* pages mapped in Alias window */ + short kp_refcntc; /* TL-tsbmiss flag; #vac alias conflict pages */ + short kp_refcnts; /* vac alias: pages mapped small */ +} kpm_page_t; + +/* + * Note: khl_lock offset changes must be reflected in sfmmu_asm.s + */ +typedef struct kpm_hlk { + kmutex_t khl_mutex; /* kpm_page mutex */ + uint_t khl_lock; /* trap level tsbmiss handling */ +} kpm_hlk_t; + +/* + * kpm small page description. + * When kpm_pgsz is equal to PAGESIZE a smaller representation is used + * to save memory space. Alias range mappings and regular segkpm + * mappings are done in units of PAGESIZE and can share the mapping + * information and the mappings are always distinguishable by their + * virtual address. Other information needed for VAC conflict prevention + * is already available on a per page basis. + * + * The state about how a kpm page is mapped and whether it is ready to go + * is indicated by the following 1 byte kpm_spage structure. This byte is + * split into two 4-bit parts - kp_mapped and kp_mapped_go. + * - kp_mapped == 1 the page is mapped cacheable + * - kp_mapped == 2 the page is mapped non-cacheable + * - kp_mapped_go == 1 the mapping is ready to be dropped in + * - kp_mapped_go == 0 the mapping is not ready to be dropped in. + * When kp_mapped_go == 0, we will have C handler resolve the VAC conflict. + * Otherwise, the assembly tsb miss handler can simply drop in the mapping + * when a tsb miss occurs. + */ +typedef union kpm_spage { + struct { +#ifdef _BIG_ENDIAN + uchar_t mapped_go: 4; /* go or nogo flag */ + uchar_t mapped: 4; /* page mapped small */ +#else + uchar_t mapped: 4; /* page mapped small */ + uchar_t mapped_go: 4; /* go or nogo flag */ +#endif + } kpm_spage_un; + uchar_t kp_mapped_flag; +} kpm_spage_t; + +#define kp_mapped kpm_spage_un.mapped +#define kp_mapped_go kpm_spage_un.mapped_go + +/* + * Note: kshl_lock offset changes must be reflected in sfmmu_asm.s + */ +typedef struct kpm_shlk { + uint_t kshl_lock; /* trap level tsbmiss handling */ +} kpm_shlk_t; + +/* + * Each segment of physical memory is described by a memseg struct. + * Within a segment, memory is considered contiguous. The members + * can be categorized as follows: + * . Platform independent: + * pages, epages, pages_base, pages_end, next, lnext. + * . 64bit only but platform independent: + * kpm_pbase, kpm_nkpmpgs, kpm_pages, kpm_spages. + * . Really platform or mmu specific: + * pagespa, epagespa, nextpa, kpm_pagespa. + * . Mixed: + * msegflags. + */ +struct memseg { + page_t *pages, *epages; /* [from, to] in page array */ + pfn_t pages_base, pages_end; /* [from, to] in page numbers */ + struct memseg *next; /* next segment in list */ + struct memseg *lnext; /* next segment in deleted list */ +#if defined(__sparc) + uint64_t pagespa, epagespa; /* [from, to] page array physical */ + uint64_t nextpa; /* physical next pointer */ + pfn_t kpm_pbase; /* start of kpm range */ + pgcnt_t kpm_nkpmpgs; /* # of kpm_pgsz pages */ + union _mseg_un { + kpm_page_t *kpm_lpgs; /* ptr to kpm_page array */ + kpm_spage_t *kpm_spgs; /* ptr to kpm_spage array */ + } mseg_un; + uint64_t kpm_pagespa; /* physical ptr to kpm (s)pages array */ +#endif /* __sparc */ + uint_t msegflags; /* memseg flags */ +}; + +/* memseg union aliases */ +#define kpm_pages mseg_un.kpm_lpgs +#define kpm_spages mseg_un.kpm_spgs + +/* msegflags */ +#define MEMSEG_DYNAMIC 0x1 /* DR: memory was added dynamically */ +#define MEMSEG_META_INCL 0x2 /* DR: memseg includes it's metadata */ +#define MEMSEG_META_ALLOC 0x4 /* DR: memseg allocated it's metadata */ + +/* memseg support macros */ +#define MSEG_NPAGES(SEG) ((SEG)->pages_end - (SEG)->pages_base) + +/* memseg hash */ +#define MEM_HASH_SHIFT 0x9 +#define N_MEM_SLOTS 0x200 /* must be a power of 2 */ +#define MEMSEG_PFN_HASH(pfn) (((pfn)/mhash_per_slot) & (N_MEM_SLOTS - 1)) + +/* memseg externals */ +extern struct memseg *memsegs; /* list of memory segments */ +extern ulong_t mhash_per_slot; +extern uint64_t memsegspa; /* memsegs as physical address */ + +void build_pfn_hash(); +extern struct memseg *page_numtomemseg_nolock(pfn_t pfnum); + +/* + * page capture related info: + * The page capture routines allow us to asynchronously capture given pages + * for the explicit use of the requestor. New requestors can be added by + * explicitly adding themselves to the PC_* flags below and incrementing + * PC_NUM_CALLBACKS as necessary. + * + * Subsystems using page capture must register a callback before attempting + * to capture a page. A duration of -1 will indicate that we will never give + * up while trying to capture a page and will only stop trying to capture the + * given page once we have successfully captured it. Thus the user needs to be + * aware of the behavior of all callers who have a duration of -1. + * + * For now, only /dev/physmem and page retire use the page capture interface + * and only a single request can be outstanding for a given page. Thus, if + * /dev/phsymem wants a page and page retire also wants the same page, only + * the page retire request will be honored until the point in time that the + * page is actually retired, at which point in time, subsequent requests by + * /dev/physmem will succeed if the CAPTURE_GET_RETIRED flag was set. + */ + +#define PC_RETIRE (0) +#define PC_PHYSMEM (1) +#define PC_NUM_CALLBACKS (2) +#define PC_MASK ((1 << PC_NUM_CALLBACKS) - 1) + +#define CAPTURE_RETIRE (1 << PC_RETIRE) +#define CAPTURE_PHYSMEM (1 << PC_PHYSMEM) + +#define CAPTURE_ASYNC (0x0200) + +#define CAPTURE_GET_RETIRED (0x1000) +#define CAPTURE_GET_CAGE (0x2000) + +struct page_capture_callback { + int cb_active; /* 1 means active, 0 means inactive */ + clock_t duration; /* the length in time that we'll attempt to */ + /* capture this page asynchronously. (in HZ) */ + krwlock_t cb_rwlock; + int (*cb_func)(page_t *, void *, uint_t); /* callback function */ +}; + +extern kcondvar_t pc_cv; + +void page_capture_register_callback(uint_t index, clock_t duration, + int (*cb_func)(page_t *, void *, uint_t)); +void page_capture_unregister_callback(uint_t index); +int page_trycapture(page_t *pp, uint_t szc, uint_t flags, void *datap); +void page_unlock_capture(page_t *pp); +int page_capture_unretire_pp(page_t *); + +extern int memsegs_trylock(int); +extern void memsegs_lock(int); +extern void memsegs_unlock(int); +extern int memsegs_lock_held(void); +extern void memlist_read_lock(void); +extern void memlist_read_unlock(void); +extern void memlist_write_lock(void); +extern void memlist_write_unlock(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_PAGE_H */ diff --git a/illumos-x86_64/usr/include/vm/pvn.h b/illumos-x86_64/usr/include/vm/pvn.h new file mode 100644 index 00000000..cf8409ec --- /dev/null +++ b/illumos-x86_64/usr/include/vm/pvn.h @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_PVN_H +#define _VM_PVN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * VM - paged vnode. + * + * The VM system manages memory as a cache of paged vnodes. + * This file desribes the interfaces to common subroutines + * used to help implement the VM/file system routines. + */ + +struct page *pvn_read_kluster(struct vnode *vp, u_offset_t off, + struct seg *seg, caddr_t addr, u_offset_t *offp, + size_t *lenp, u_offset_t vp_off, size_t vp_len, + int isra); +struct page *pvn_write_kluster(struct vnode *vp, struct page *pp, + u_offset_t *offp, size_t *lenp, u_offset_t vp_off, + size_t vp_len, int flags); +void pvn_read_done(struct page *plist, int flags); +void pvn_write_done(struct page *plist, int flags); +void pvn_io_done(struct page *plist); +int pvn_vplist_dirty(struct vnode *vp, u_offset_t off, + int (*putapage)(vnode_t *, struct page *, u_offset_t *, + size_t *, int, cred_t *), + int flags, struct cred *cred); +void pvn_vplist_setdirty(vnode_t *vp, int (*page_check)(page_t *)); +int pvn_getdirty(struct page *pp, int flags); +void pvn_vpzero(struct vnode *vp, u_offset_t vplen, size_t zbytes); +int pvn_getpages( + int (*getpage)(vnode_t *, u_offset_t, size_t, uint_t *, + struct page *[], size_t, struct seg *, + caddr_t, enum seg_rw, cred_t *), + struct vnode *vp, u_offset_t off, size_t len, + uint_t *protp, struct page **pl, size_t plsz, + struct seg *seg, caddr_t addr, enum seg_rw rw, + struct cred *cred); +void pvn_plist_init(struct page *pp, struct page **pl, size_t plsz, + u_offset_t off, size_t io_len, enum seg_rw rw); +void pvn_init(void); + +/* + * The value is put in p_hash to identify marker pages. It is safe to + * test p_hash ==(!=) PVN_VPLIST_HASH_TAG even without holding p_selock. + */ +#define PVN_VPLIST_HASH_TAG ((page_t *)-1) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_PVN_H */ diff --git a/illumos-x86_64/usr/include/vm/rm.h b/illumos-x86_64/usr/include/vm/rm.h new file mode 100644 index 00000000..768ee745 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/rm.h @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_RM_H +#define _VM_RM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +extern size_t rm_asrss(struct as *); +extern ushort_t rm_pctmemory(struct as *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_RM_H */ diff --git a/illumos-x86_64/usr/include/vm/seg.h b/illumos-x86_64/usr/include/vm/seg.h new file mode 100644 index 00000000..9dde7028 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg.h @@ -0,0 +1,288 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2017 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_SEG_H +#define _VM_SEG_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * VM - Segments. + */ + +struct anon_map; + +/* + * kstat statistics for segment advise + */ +typedef struct { + kstat_named_t MADV_FREE_hit; + kstat_named_t MADV_FREE_miss; +} segadvstat_t; + +/* + * memory object ids + */ +typedef struct memid { u_longlong_t val[2]; } memid_t; + +/* + * An address space contains a set of segments, managed by drivers. + * Drivers support mapped devices, sharing, copy-on-write, etc. + * + * The seg structure contains a lock to prevent races, the base virtual + * address and size of the segment, a back pointer to the containing + * address space, pointers to maintain an AVL tree of segments in the + * same address space, and procedure and data hooks for the driver. + * The AVL tree of segments for the address space is sorted by + * ascending base addresses and overlapping segments are not allowed. + * + * After a segment is created, faults may occur on pages of the segment. + * When a fault occurs, the fault handling code must get the desired + * object and set up the hardware translation to the object. For some + * objects, the fault handling code also implements copy-on-write. + * + * When the hat wants to unload a translation, it can call the unload + * routine which is responsible for processing reference and modify bits. + * + * Each segment is protected by it's containing address space lock. To + * access any field in the segment structure, the "as" must be locked. + * If a segment field is to be modified, the address space lock must be + * write locked. + */ + +typedef struct pcache_link { + struct pcache_link *p_lnext; + struct pcache_link *p_lprev; +} pcache_link_t; + +typedef struct seg { + caddr_t s_base; /* base virtual address */ + size_t s_size; /* size in bytes */ + uint_t s_szc; /* max page size code */ + uint_t s_flags; /* flags for segment, see below */ + struct as *s_as; /* containing address space */ + avl_node_t s_tree; /* AVL tree links to segs in this as */ + struct seg_ops *s_ops; /* ops vector: see below */ + void *s_data; /* private data for instance */ + kmutex_t s_pmtx; /* protects seg's pcache list */ + pcache_link_t s_phead; /* head of seg's pcache list */ +} seg_t; + +#define S_PURGE (0x01) /* seg should be purged in as_gap() */ +#define S_HOLE (0x02) /* seg represents hole in AS */ + +struct seg_ops { + int (*dup)(struct seg *, struct seg *); + int (*unmap)(struct seg *, caddr_t, size_t); + void (*free)(struct seg *); + faultcode_t (*fault)(struct hat *, struct seg *, caddr_t, size_t, + enum fault_type, enum seg_rw); + faultcode_t (*faulta)(struct seg *, caddr_t); + int (*setprot)(struct seg *, caddr_t, size_t, uint_t); + int (*checkprot)(struct seg *, caddr_t, size_t, uint_t); + int (*kluster)(struct seg *, caddr_t, ssize_t); + size_t (*swapout)(struct seg *); + int (*sync)(struct seg *, caddr_t, size_t, int, uint_t); + size_t (*incore)(struct seg *, caddr_t, size_t, char *); + int (*lockop)(struct seg *, caddr_t, size_t, int, int, ulong_t *, + size_t); + int (*getprot)(struct seg *, caddr_t, size_t, uint_t *); + u_offset_t (*getoffset)(struct seg *, caddr_t); + int (*gettype)(struct seg *, caddr_t); + int (*getvp)(struct seg *, caddr_t, struct vnode **); + int (*advise)(struct seg *, caddr_t, size_t, uint_t); + void (*dump)(struct seg *); + int (*pagelock)(struct seg *, caddr_t, size_t, struct page ***, + enum lock_type, enum seg_rw); + int (*setpagesize)(struct seg *, caddr_t, size_t, uint_t); + int (*getmemid)(struct seg *, caddr_t, memid_t *); + struct lgrp_mem_policy_info *(*getpolicy)(struct seg *, caddr_t); + int (*capable)(struct seg *, segcapability_t); + int (*inherit)(struct seg *, caddr_t, size_t, uint_t); +}; + +#ifdef _KERNEL + +/* + * Generic segment operations + */ +extern void seg_init(void); +extern struct seg *seg_alloc(struct as *as, caddr_t base, size_t size); +extern int seg_attach(struct as *as, caddr_t base, size_t size, + struct seg *seg); +extern void seg_unmap(struct seg *seg); +extern void seg_free(struct seg *seg); + +/* + * functions for pagelock cache support + */ +typedef int (*seg_preclaim_cbfunc_t)(void *, caddr_t, size_t, + struct page **, enum seg_rw, int); + +extern struct page **seg_plookup(struct seg *seg, struct anon_map *amp, + caddr_t addr, size_t len, enum seg_rw rw, uint_t flags); +extern void seg_pinactive(struct seg *seg, struct anon_map *amp, + caddr_t addr, size_t len, struct page **pp, enum seg_rw rw, + uint_t flags, seg_preclaim_cbfunc_t callback); + +extern void seg_ppurge(struct seg *seg, struct anon_map *amp, + uint_t flags); +extern void seg_ppurge_wiredpp(struct page **pp); + +extern int seg_pinsert_check(struct seg *seg, struct anon_map *amp, + caddr_t addr, size_t len, uint_t flags); +extern int seg_pinsert(struct seg *seg, struct anon_map *amp, + caddr_t addr, size_t len, size_t wlen, struct page **pp, enum seg_rw rw, + uint_t flags, seg_preclaim_cbfunc_t callback); + +extern void seg_pasync_thread(void); +extern void seg_preap(void); +extern int seg_p_disable(void); +extern void seg_p_enable(void); + +extern segadvstat_t segadvstat; + +/* + * Flags for pagelock cache support. + * Flags argument is passed as uint_t to pcache routines. upper 16 bits of + * the flags argument are reserved for alignment page shift when SEGP_PSHIFT + * is set. + */ +#define SEGP_FORCE_WIRED 0x1 /* skip check against seg_pwindow */ +#define SEGP_AMP 0x2 /* anon map's pcache entry */ +#define SEGP_PSHIFT 0x4 /* addr pgsz shift for hash function */ + +/* + * Return values for seg_pinsert and seg_pinsert_check functions. + */ +#define SEGP_SUCCESS 0 /* seg_pinsert() succeeded */ +#define SEGP_FAIL 1 /* seg_pinsert() failed */ + +/* Page status bits for segop_incore */ +#define SEG_PAGE_INCORE 0x01 /* VA has a page backing it */ +#define SEG_PAGE_LOCKED 0x02 /* VA has a page that is locked */ +#define SEG_PAGE_HASCOW 0x04 /* VA has a page with a copy-on-write */ +#define SEG_PAGE_SOFTLOCK 0x08 /* VA has a page with softlock held */ +#define SEG_PAGE_VNODEBACKED 0x10 /* Segment is backed by a vnode */ +#define SEG_PAGE_ANON 0x20 /* VA has an anonymous page */ +#define SEG_PAGE_VNODE 0x40 /* VA has a vnode page backing it */ + +#define SEGOP_DUP(s, n) (*(s)->s_ops->dup)((s), (n)) +#define SEGOP_UNMAP(s, a, l) (*(s)->s_ops->unmap)((s), (a), (l)) +#define SEGOP_FREE(s) (*(s)->s_ops->free)((s)) +#define SEGOP_FAULT(h, s, a, l, t, rw) \ + (*(s)->s_ops->fault)((h), (s), (a), (l), (t), (rw)) +#define SEGOP_FAULTA(s, a) (*(s)->s_ops->faulta)((s), (a)) +#define SEGOP_SETPROT(s, a, l, p) (*(s)->s_ops->setprot)((s), (a), (l), (p)) +#define SEGOP_CHECKPROT(s, a, l, p) (*(s)->s_ops->checkprot)((s), (a), (l), (p)) +#define SEGOP_KLUSTER(s, a, d) (*(s)->s_ops->kluster)((s), (a), (d)) +#define SEGOP_SWAPOUT(s) (*(s)->s_ops->swapout)((s)) +#define SEGOP_SYNC(s, a, l, atr, f) \ + (*(s)->s_ops->sync)((s), (a), (l), (atr), (f)) +#define SEGOP_INCORE(s, a, l, v) (*(s)->s_ops->incore)((s), (a), (l), (v)) +#define SEGOP_LOCKOP(s, a, l, atr, op, b, p) \ + (*(s)->s_ops->lockop)((s), (a), (l), (atr), (op), (b), (p)) +#define SEGOP_GETPROT(s, a, l, p) (*(s)->s_ops->getprot)((s), (a), (l), (p)) +#define SEGOP_GETOFFSET(s, a) (*(s)->s_ops->getoffset)((s), (a)) +#define SEGOP_GETTYPE(s, a) (*(s)->s_ops->gettype)((s), (a)) +#define SEGOP_GETVP(s, a, vpp) (*(s)->s_ops->getvp)((s), (a), (vpp)) +#define SEGOP_ADVISE(s, a, l, b) (*(s)->s_ops->advise)((s), (a), (l), (b)) +#define SEGOP_DUMP(s) (*(s)->s_ops->dump)((s)) +#define SEGOP_PAGELOCK(s, a, l, p, t, rw) \ + (*(s)->s_ops->pagelock)((s), (a), (l), (p), (t), (rw)) +#define SEGOP_SETPAGESIZE(s, a, l, szc) \ + (*(s)->s_ops->setpagesize)((s), (a), (l), (szc)) +#define SEGOP_GETMEMID(s, a, mp) (*(s)->s_ops->getmemid)((s), (a), (mp)) +#define SEGOP_GETPOLICY(s, a) (*(s)->s_ops->getpolicy)((s), (a)) +#define SEGOP_CAPABLE(s, c) (*(s)->s_ops->capable)((s), (c)) +#define SEGOP_INHERIT(s, a, l, b) (*(s)->s_ops->inherit)((s), (a), (l), (b)) + +#define seg_page(seg, addr) \ + (((uintptr_t)((addr) - (seg)->s_base)) >> PAGESHIFT) + +#define seg_pages(seg) \ + (((uintptr_t)((seg)->s_size + PAGEOFFSET)) >> PAGESHIFT) + +#define IE_NOMEM -1 /* internal to seg layer */ +#define IE_RETRY -2 /* internal to seg layer */ +#define IE_REATTACH -3 /* internal to seg layer */ + +/* Values for SEGOP_INHERIT */ +#define SEGP_INH_ZERO 0x01 + +int seg_inherit_notsup(struct seg *, caddr_t, size_t, uint_t); + +/* Delay/retry factors for seg_p_mem_config_pre_del */ +#define SEGP_PREDEL_DELAY_FACTOR 4 +/* + * As a workaround to being unable to purge the pagelock + * cache during a DR delete memory operation, we use + * a stall threshold that is twice the maximum seen + * during testing. This workaround will be removed + * when a suitable fix is found. + */ +#define SEGP_STALL_SECONDS 25 +#define SEGP_STALL_THRESHOLD \ + (SEGP_STALL_SECONDS * SEGP_PREDEL_DELAY_FACTOR) + +#ifdef VMDEBUG + +uint_t seg_page(struct seg *, caddr_t); +uint_t seg_pages(struct seg *); + +#endif /* VMDEBUG */ + +boolean_t seg_can_change_zones(struct seg *); +size_t seg_swresv(struct seg *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_H */ diff --git a/illumos-x86_64/usr/include/vm/seg_dev.h b/illumos-x86_64/usr/include/vm/seg_dev.h new file mode 100644 index 00000000..07a15afc --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg_dev.h @@ -0,0 +1,138 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2018 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_SEG_DEV_H +#define _VM_SEG_DEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct proc; + +/* + * Structure whose pointer is passed to the segdev_create routine + */ +struct segdev_crargs { + offset_t offset; /* starting offset */ + int (*mapfunc)(dev_t dev, off_t off, int prot); /* map function */ + dev_t dev; /* device number */ + uchar_t type; /* type of sharing done */ + uchar_t prot; /* protection */ + uchar_t maxprot; /* maximum protection */ + uint_t hat_attr; /* hat attr */ + uint_t hat_flags; /* currently, hat_flags is used ONLY for */ + /* HAT_LOAD_NOCONSIST; in future, it can be */ + /* expanded to include any flags that are */ + /* not already part of hat_attr */ + void *devmap_data; /* devmap_handle private data */ +}; + +/* + * (Semi) private data maintained by the seg_dev driver per segment mapping + * + * The segment lock is necessary to protect fields that are modified + * when the "read" version of the address space lock is held. This lock + * is not needed when the segment operation has the "write" version of + * the address space lock (it would be redundant). + * + * The following fields in segdev_data are read-only when the address + * space is "read" locked, and don't require the segment lock: + * + * vp + * offset + * mapfunc + * maxprot + */ +struct segdev_data { + offset_t offset; /* device offset for start of mapping */ + krwlock_t lock; /* protects segdev_data */ + int (*mapfunc)(dev_t dev, off_t off, int prot); + struct vnode *vp; /* vnode associated with device */ + uchar_t pageprot; /* true if per page protections present */ + uchar_t prot; /* current segment prot if pageprot == 0 */ + uchar_t maxprot; /* maximum segment protections */ + uchar_t type; /* type of sharing done */ + struct vpage *vpage; /* per-page information, if needed */ + uint_t hat_attr; /* hat attr - pass to attr in hat_devload */ + uint_t hat_flags; /* set HAT_LOAD_NOCONSIST flag in hat_devload */ + /* see comments above in segdev_crargs */ + size_t softlockcnt; /* # of SOFTLOCKED in seg */ + void *devmap_data; /* devmap_handle private data */ +}; + +/* Direct physical-userland mapping, without occupying kernel address space */ +#define DEVMAP_PMEM_COOKIE ((ddi_umem_cookie_t)0x2) + +/* + * pmem_cookie: + * Records physical memory pages to be exported to userland. + */ +struct devmap_pmem_cookie { + pgcnt_t dp_npages; /* number of allocated mem pages */ + page_t **dp_pparray; /* pages allocated for this cookie */ + vnode_t *dp_vnp; /* vnode associated with this cookie */ + proc_t *dp_proc; /* proc ptr for resource control */ +}; + +#ifdef _KERNEL + +/* + * Mappings of /dev/null come from segdev and have no mapping type. + */ + +#define SEG_IS_DEVNULL_MAPPING(seg) \ + ((seg)->s_ops == &segdev_ops && \ + ((SEGOP_GETTYPE(seg, (seg)->s_base) & (MAP_SHARED | MAP_PRIVATE)) == 0)) + +extern void segdev_init(void); + +extern int segdev_create(struct seg **, void *); + +extern int segdev_copyto(struct seg *, caddr_t, const void *, void *, size_t); +extern int segdev_copyfrom(struct seg *, caddr_t, const void *, void *, size_t); +extern struct seg_ops segdev_ops; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_DEV_H */ diff --git a/illumos-x86_64/usr/include/vm/seg_enum.h b/illumos-x86_64/usr/include/vm/seg_enum.h new file mode 100644 index 00000000..3f81e08a --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg_enum.h @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#ifndef _VM_SEG_ENUM_H +#define _VM_SEG_ENUM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These enumerations are needed in both and + * in order to declare function prototypes. + */ + +/* + * Fault information passed to the seg fault handling routine. + * The F_SOFTLOCK and F_SOFTUNLOCK are used by software + * to lock and unlock pages for physical I/O. + */ +enum fault_type { + F_INVAL, /* invalid page */ + F_PROT, /* protection fault */ + F_SOFTLOCK, /* software requested locking */ + F_SOFTUNLOCK /* software requested unlocking */ +}; + +/* + * Lock information passed to the seg pagelock handling routine. + */ +enum lock_type { + L_PAGELOCK, /* lock pages */ + L_PAGEUNLOCK /* unlock pages */ +}; + +/* + * seg_rw gives the access type for a fault operation + */ +enum seg_rw { + S_OTHER, /* unknown or not touched */ + S_READ, /* read access attempted */ + S_WRITE, /* write access attempted */ + S_EXEC, /* execution access attempted */ + S_CREATE, /* create if page doesn't exist */ + S_READ_NOCOW /* read access, don't do a copy on write */ +}; + +/* + * Capabilities for capability segment op. + */ +typedef enum { + S_CAPABILITY_NOMINFLT /* supports non-faulting page renaming */ +} segcapability_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_ENUM_H */ diff --git a/illumos-x86_64/usr/include/vm/seg_kmem.h b/illumos-x86_64/usr/include/vm/seg_kmem.h new file mode 100644 index 00000000..9a201016 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg_kmem.h @@ -0,0 +1,153 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2018 Joyent, Inc. + * Copyright 2017 RackTop Systems. + */ + +#ifndef _VM_SEG_KMEM_H +#define _VM_SEG_KMEM_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include + +/* + * VM - Kernel Segment Driver + */ + +#if defined(_KERNEL) || defined(_FAKE_KERNEL) + +extern char *kernelheap; /* start of primary kernel heap */ +extern char *ekernelheap; /* end of primary kernel heap */ +extern char *heap_lp_base; /* start of kernel large page heap arena */ +extern char *heap_lp_end; /* end of kernel large page heap arena */ +extern struct seg kvseg; /* primary kernel heap segment */ +extern struct seg kvseg_core; /* "core" kernel heap segment */ +extern struct seg kzioseg; /* Segment for zio mappings */ +extern vmem_t *heap_lp_arena; /* kernel large page heap arena */ +extern vmem_t *heap_arena; /* primary kernel heap arena */ +extern vmem_t *hat_memload_arena; /* HAT translation arena */ +extern struct seg kvseg32; /* 32-bit kernel heap segment */ +extern vmem_t *heap32_arena; /* 32-bit kernel heap arena */ +extern vmem_t *heaptext_arena; /* kernel text arena, from heap */ +extern struct as kas; /* kernel address space */ +extern int segkmem_reloc; /* enable/disable segkmem relocatable pages */ +extern vmem_t *static_arena; /* arena for caches to import static memory */ +extern vmem_t *static_alloc_arena; /* arena for allocating static memory */ +extern vmem_t *zio_arena; /* arena for zio caches */ +extern vmem_t *zio_alloc_arena; /* arena for zio caches */ + +#if defined(__amd64) +extern struct seg kvmmseg; /* Segment for vmm mappings */ +extern vmem_t *kvmm_arena; /* arena for vmm VA */ +extern void segkmem_kvmm_init(void *, size_t); +#endif + +extern struct vnode kvps[]; +/* + * segkmem page vnodes (please don't add more defines here...) + */ +#define kvp (kvps[KV_KVP]) +#if defined(__sparc) +#define mpvp (kvps[KV_MPVP]) +#define promvp (kvps[KV_PROMVP]) +#endif /* __sparc */ + +extern int segkmem_create(struct seg *); +extern page_t *segkmem_page_create(void *, size_t, int, void *); +extern void *segkmem_xalloc(vmem_t *, void *, size_t, int, uint_t, + page_t *(*page_create_func)(void *, size_t, int, void *), void *); +extern void *segkmem_alloc(vmem_t *, size_t, int); +extern void *segkmem_alloc_permanent(vmem_t *, size_t, int); +extern void segkmem_free(vmem_t *, void *, size_t); +extern void segkmem_xfree(vmem_t *, void *, size_t, + struct vnode *, void (*)(page_t *)); + +extern void *boot_alloc(void *, size_t, uint_t); +extern void boot_mapin(caddr_t addr, size_t size); +extern void kernelheap_init(void *, void *, char *, void *, void *); +extern void segkmem_gc(void); + +extern void segkmem_zio_init(void *, size_t); + +/* + * Flags for segkmem_xalloc(). + * + * SEGKMEM_SHARELOCKED requests pages which are locked SE_SHARED to be + * returned rather than unlocked which is now the default. Note that + * memory returned by SEGKMEM_SHARELOCKED cannot be freed by segkmem_free(). + * This is a hack for seg_dev that should be cleaned up in the future. + */ +#define SEGKMEM_SHARELOCKED 0x20000 + +/* + * Large page for kmem caches support + */ +typedef struct segkmem_lpcb { + kmutex_t lp_lock; + kcondvar_t lp_cv; + uint_t lp_wait; + uint_t lp_uselp; + ulong_t lp_throttle; + + /* stats */ + uint64_t sleep_allocs_failed; + uint64_t nosleep_allocs_failed; + uint64_t allocs_throttled; + uint64_t allocs_limited; + uint64_t alloc_bytes_failed; +} segkmem_lpcb_t; + +extern void *segkmem_alloc_lp(vmem_t *, size_t *, size_t, int); +extern void segkmem_free_lp(vmem_t *, void *, size_t); +extern int segkmem_lpsetup(); +extern void segkmem_heap_lp_init(void); + +extern size_t segkmem_lpsize; +extern int segkmem_lpszc; +extern size_t segkmem_heaplp_quantum; +extern size_t segkmem_kmemlp_max; + +#define SEGKMEM_USE_LARGEPAGES (segkmem_lpsize > PAGESIZE) + +#define IS_KMEM_VA_LARGEPAGE(vaddr) \ + (((vaddr) >= heap_lp_base) && ((vaddr) < heap_lp_end)) + +extern struct seg_ops segkmem_ops; + +#endif /* _KERNEL || _FAKE_KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_KMEM_H */ diff --git a/illumos-x86_64/usr/include/vm/seg_kp.h b/illumos-x86_64/usr/include/vm/seg_kp.h new file mode 100644 index 00000000..095c6672 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg_kp.h @@ -0,0 +1,163 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _VM_SEG_KP_H +#define _VM_SEG_KP_H + +/* + * segkp (as in kernel pageable) is a segment driver that supports allocation + * of page-aligned variable size of vm resources. + * + * Each vm resource represents a page-aligned range of virtual addresses. + * The caller may specify whether the resource should include a redzone, + * be locked down, or be zero initialized. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +/* + * Private information per overall segkp segment (as opposed + * to per resource within segment). There are as many anon slots + * allocated as there there are pages in the segment. + */ +struct segkp_segdata { + struct anon_hdr *kpsd_anon; /* anon structs */ + vmem_t *kpsd_arena; /* virtual memory descriptor */ + struct segkp_data **kpsd_hash; /* Hash table for lookups */ +}; + +#define SEGKP_VMEM(seg) (((struct segkp_segdata *)(seg)->s_data)->kpsd_arena) + +/* + * A hash table is used to aid in the lookup of a kpd's based on vaddr. + * Since the heaviest use of segkp occurs from segkp_*get and segkp_*release, + * the hashing is based on the vaddr used by these routines. + */ +#define SEGKP_HASHSZ 256 /* power of two */ +#define SEGKP_HASHMASK (SEGKP_HASHSZ - 1) +#define SEGKP_HASH(vaddr) \ + ((int)(((uintptr_t)vaddr >> PAGESHIFT) & SEGKP_HASHMASK)) + +struct segkp_data { + kmutex_t kp_lock; /* per resource lock */ + caddr_t kp_base; /* starting addr of chunk */ + size_t kp_len; /* # of bytes */ + uint_t kp_flags; /* state info */ + int kp_cookie; /* index into cache array */ + ulong_t kp_anon_idx; /* index into main anon array */ + /* in segkp_segdata */ + struct anon_hdr *kp_anon; /* anon structs */ + struct segkp_data *kp_next; /* ptr to next in hash chain */ +}; + +/* + * Flag bits + * + */ +#define KPD_ZERO 0x01 /* initialize resource with 0 */ +#define KPD_LOCKED 0x02 /* resources locked */ +#define KPD_NO_ANON 0x04 /* no swap resources required */ +#define KPD_HASREDZONE 0x08 /* include a redzone */ +#define KPD_NOWAIT 0x10 /* do not wait for res. if unavail. */ +#define KPD_WRITEDIRTY 0x20 /* dirty pages should be flushed */ +#define KPD_HASAMP 0x40 /* anon_hdr managed by caller */ + +/* + * A cache of segkp elements may be created via segkp_cache_init(). + * The elements on the freelist all have the same len and flags value. + * The cookie passed to the client is an index into the freelist array. + */ +struct segkp_cache { + int kpf_max; /* max # of elements allowed */ + int kpf_count; /* current no. of elments */ + int kpf_inuse; /* list inuse */ + uint_t kpf_flags; /* seg_kp flag value */ + size_t kpf_len; /* len of resource */ + struct seg *kpf_seg; /* segment */ + struct segkp_data *kpf_list; /* list of kpd's */ +}; +#define SEGKP_MAX_CACHE 4 /* Number of caches maintained */ + +/* + * Define redzone, and stack_to_memory macros. + * The redzone is PAGESIZE bytes. + */ +#ifdef STACK_GROWTH_DOWN +#define KPD_REDZONE(kpd) (0) +#define stom(v, flags) (((flags) & KPD_HASREDZONE) ? (v) + PAGESIZE : (v)) + +#else /* STACK_GROWTH_DOWN */ + +#define KPD_REDZONE(kpd) (btop(kpd->kp_len) - 1) +#define stom(v) (v) +#endif /* STACK_GROWTH_DOWN */ + +#define SEGKP_MAPLEN(len, flags) \ + (((flags) & KPD_HASREDZONE) ? (len) - PAGESIZE : (len)) + +extern struct seg *segkp; +/* If segkp becomes more than one seg this test will need changing. */ +#define SEG_IS_SEGKP(SEG) ((SEG) == segkp) + +/* + * Public routine declarations not part of the segment ops vector go here. + */ +int segkp_create(struct seg *seg); +caddr_t segkp_get(struct seg *seg, size_t len, uint_t flags); +void segkp_release(struct seg *seg, caddr_t vaddr); +void * segkp_cache_init(struct seg *seg, int maxsize, size_t len, + uint_t flags); +void segkp_cache_free(); +caddr_t segkp_cache_get(void *cookie); +int segkp_map_red(void); +void segkp_unmap_red(void); +size_t swapsize(caddr_t v); + +/* Special currently only used by schedctl. */ +struct anon_map; /* Make the compiler happy about the next line. */ +caddr_t segkp_get_withanonmap(struct seg *, size_t, uint_t, struct anon_map *); + +/* + * We allow explicit calls to segkp_fault, even though it's part + * of the segkp ops vector. + */ +faultcode_t segkp_fault(struct hat *hat, struct seg *seg, caddr_t addr, + size_t len, enum fault_type type, enum seg_rw rw); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_KP_H */ diff --git a/illumos-x86_64/usr/include/vm/seg_kpm.h b/illumos-x86_64/usr/include/vm/seg_kpm.h new file mode 100644 index 00000000..b61980df --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg_kpm.h @@ -0,0 +1,120 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _VM_SEG_KPM_H +#define _VM_SEG_KPM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Kernel Physical Mapping (segkpm) segment driver. + */ + +#include + +struct segkpm_data { + ushort_t *skd_va_select; /* page_create_va kpm vaddr bin count */ + short skd_nvcolors; /* VAC colors to deal with */ + uchar_t skd_prot; +}; + +/* + * segkpm create needs some platform knowledge + */ +struct segkpm_crargs { + uint_t prot; + short nvcolors; /* VAC # virtual colors, 0 for PAC. */ +}; + +extern struct seg *segkpm; +extern u_offset_t kpm_pgoff; +extern size_t kpm_pgsz; +extern uint_t kpm_pgshft; +extern uint_t kpmp2pshft; +extern pgcnt_t kpmpnpgs; + +/* kpm controls */ +extern int kpm_enable; +extern int kpm_smallpages; +extern int segmap_kpm; + +/* + * kpm_page_t macros: + * . bytes (b) to kpm pages (kpmp) + * . pages (p) to kpm pages (kpmp), and back (with and without roundup) + * . kpm page offset in bytes + * . pages (p) modulo kpm pages (kpmp) + */ +#define btokpmp(x) ((x) >> kpm_pgshft) +#define btokpmpr(x) (((x) + kpm_pgoff) >> kpm_pgshft) +#define ptokpmp(x) ((x) >> kpmp2pshft) +#define ptokpmpr(x) (((x) + (kpmpnpgs - 1)) >> kpmp2pshft) +#define kpmptop(x) ((x) << kpmp2pshft) +#define kpmpageoff(x) ((x) & kpm_pgoff) +#define pmodkpmp(x) ((x) & (kpmpnpgs - 1)) + +#ifdef SEGKPM_SUPPORT + +#define IS_KPM_ADDR(addr) \ + ((addr) >= segkpm->s_base && (addr) < (segkpm->s_base + segkpm->s_size)) + +#ifdef __x86 +/* x86 systems use neither kpm_page_t nor kpm_spage_t when supporting kpm. */ +#define KPMPAGE_T_SZ (0) +#else /* __x86 */ +#define KPMPAGE_T_SZ \ + ((kpm_smallpages == 0) ? sizeof (kpm_page_t) : sizeof (kpm_spage_t)) +#endif /* __x86 */ + +#else /* SEGKPM_SUPPORT */ + +#define IS_KPM_ADDR(addr) (segkpm != NULL) +#define KPMPAGE_T_SZ (0) + +#endif /* SEGKPM_SUPPORT */ + +#ifdef _KERNEL +/* + * Public seg_kpm segment operations. + */ +extern int segkpm_create(struct seg *, void *); +extern faultcode_t segkpm_fault(struct hat *, struct seg *, caddr_t, + size_t, enum fault_type, enum seg_rw); + +/* + * Public seg_kpm interfaces. + */ +extern caddr_t segkpm_create_va(u_offset_t); +extern void segkpm_mapout_validkpme(struct kpme *); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_KPM_H */ diff --git a/illumos-x86_64/usr/include/vm/seg_map.h b/illumos-x86_64/usr/include/vm/seg_map.h new file mode 100644 index 00000000..5dffe67c --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg_map.h @@ -0,0 +1,292 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_SEG_MAP_H +#define _VM_SEG_MAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * When segmap is created it is possible to program its behavior, + * using the create args [needed for performance reasons]. + * Segmap creates n lists of pages. + * For VAC machines, there will be at least one free list + * per color. If more than one free list per color is needed, + * set nfreelist as needed. + * + * For PAC machines, it will be treated as VAC with only one + * color- every page is of the same color. Again, set nfreelist + * to get more than one free list. + */ +struct segmap_crargs { + uint_t prot; + uint_t shmsize; /* shm_alignment for VAC, 0 for PAC. */ + uint_t nfreelist; /* number of freelist per color, >= 1 */ +}; + +#include +#include + +/* + * Each smap struct represents a MAXBSIZE sized mapping to the + * given in the structure. The location of the + * the structure in the array gives the virtual address of the + * mapping. Structure rearranged for 64bit sm_off. + */ +struct smap { + kmutex_t sm_mtx; /* protect non-list fields */ + struct vnode *sm_vp; /* vnode pointer (if mapped) */ + struct smap *sm_hash; /* hash pointer */ + struct smap *sm_next; /* next pointer */ + struct smap *sm_prev; /* previous pointer */ + u_offset_t sm_off; /* file offset for mapping */ + ushort_t sm_bitmap; /* bit map for locked translations */ + ushort_t sm_refcnt; /* reference count for uses */ + ushort_t sm_flags; /* smap flags */ + ushort_t sm_free_ndx; /* freelist */ +#ifdef SEGKPM_SUPPORT + struct kpme sm_kpme; /* segkpm */ +#endif +}; + +#ifdef SEGKPM_SUPPORT +#define GET_KPME(smp) (&(smp)->sm_kpme) +#define sm_kpme_next sm_kpme.kpe_next +#define sm_kpme_prev sm_kpme.kpe_prev +#define sm_kpme_page sm_kpme.kpe_page +#else +#define GET_KPME(smp) ((struct kpme *)NULL) +#endif + +/* sm_flags */ +#define SM_KPM_NEWPAGE 0x00000001 /* page created in segmap_getmapft */ +#define SM_NOTKPM_RELEASED 0x00000002 /* released smap not in segkpm mode */ +#define SM_QNDX_ZERO 0x00000004 /* on the index 0 freelist */ +#define SM_READ_DATA 0x00000010 /* page created for read */ +#define SM_WRITE_DATA 0x00000020 /* page created for write */ + +/* + * Multiple smap free lists are maintained so that allocations + * will scale with cpu count. Each free list is made up of 2 queues + * so that allocations and deallocations can proceed concurrently. + * Each queue structure is padded to 64 bytes to avoid false sharing. + */ +#define SM_FREEQ_PAD (64 - sizeof (struct smap *) - sizeof (kmutex_t)) +struct sm_freeq { + struct smap *smq_free; /* points into freelist */ + kmutex_t smq_mtx; /* protects smq_free */ + char smq_pad[SM_FREEQ_PAD]; +}; + +struct smfree { + struct sm_freeq sm_freeq[2]; /* alloc and release queues */ + struct sm_freeq *sm_allocq; /* current allocq */ + struct sm_freeq *sm_releq; /* current releq */ + kcondvar_t sm_free_cv; + ushort_t sm_want; /* someone wants a slot of this color */ +}; + +/* + * Cached smaps are kept on hash chains to enable fast reclaim lookups. + */ +struct smaphash { + kmutex_t sh_mtx; /* protects this hash chain */ + struct smap *sh_hash_list; /* start of hash chain */ +}; + +/* + * (Semi) private data maintained by the segmap driver per SEGMENT mapping + * All fields in segmap_data are read-only after the segment is created. + * + */ + +struct segmap_data { + struct smap *smd_sm; /* array of smap structures */ + long smd_npages; /* size of smap array */ + struct smfree *smd_free; /* ptr to freelist header array */ + struct smaphash *smd_hash; /* ptr to hash header array */ + int smd_nfree; /* number of free lists */ + uchar_t smd_prot; /* protections for all smap's */ +}; + +/* + * Statistics for segmap operations. + * + * No explicit locking to protect these stats. + */ +struct segmapcnt { + kstat_named_t smp_fault; /* number of segmap_faults */ + kstat_named_t smp_faulta; /* number of segmap_faultas */ + kstat_named_t smp_getmap; /* number of segmap_getmaps */ + kstat_named_t smp_get_use; /* getmaps that reuse existing map */ + kstat_named_t smp_get_reclaim; /* getmaps that do a reclaim */ + kstat_named_t smp_get_reuse; /* getmaps that reuse a slot */ + kstat_named_t smp_get_unused; /* getmaps that reuse existing map */ + kstat_named_t smp_get_nofree; /* getmaps with no free slots */ + kstat_named_t smp_rel_async; /* releases that are async */ + kstat_named_t smp_rel_write; /* releases that write */ + kstat_named_t smp_rel_free; /* releases that free */ + kstat_named_t smp_rel_abort; /* releases that abort */ + kstat_named_t smp_rel_dontneed; /* releases with dontneed set */ + kstat_named_t smp_release; /* releases with no other action */ + kstat_named_t smp_pagecreate; /* pagecreates */ + kstat_named_t smp_free_notfree; /* pages not freed in */ + /* segmap_pagefree */ + kstat_named_t smp_free_dirty; /* dirty pages freeed */ + /* in segmap_pagefree */ + kstat_named_t smp_free; /* clean pages freeed in */ + /* segmap_pagefree */ + kstat_named_t smp_stolen; /* segmap_getmapflt() stole */ + /* from get_free_smp() */ + kstat_named_t smp_get_nomtx; /* free smaps but no mutex */ +}; + +/* + * These are flags used on release. Some of these might get handled + * by segment operations needed for msync (when we figure them out). + * SM_ASYNC modifies SM_WRITE. SM_DONTNEED modifies SM_FREE. SM_FREE + * and SM_INVAL as well as SM_FREE and SM_DESTROY are mutually exclusive. + * SM_DESTROY behaves like SM_INVAL but also forces the pages to be + * destroyed -- this prevents them from being written to the backing + * store. + */ +#define SM_WRITE 0x01 /* write back the pages upon release */ +#define SM_ASYNC 0x02 /* do the write asynchronously */ +#define SM_FREE 0x04 /* put pages back on free list */ +#define SM_INVAL 0x08 /* invalidate page (no caching) */ +#define SM_DONTNEED 0x10 /* less likely to be needed soon */ +#define SM_DESTROY 0x20 /* invalidate page, don't write back */ + +/* + * These are the forcefault flags used on getmapflt. + * + * The orginal semantic was extended to allow using the segkpm mapping + * scheme w/o a major segmap interface change for MAXBSIZE == PAGESIZE + * (which is required to enable segkpm for MAXBSIZE > PAGESIZE). + * Most segmap consumers needn't to be changed at all or only need to + * be changed slightly to take advantage of segkpm. Because the segkpm + * virtual address is based on the physical address of a page, a page is + * required to determine the virtual address (return value). Pages mapped + * with segkpm are always at least read locked and are hence protected + * from pageout or fsflush from segmap_getmap until segmap_release. This + * implies, that the segkpm mappings are locked within this period too. + * No trap driven segmap_fault's are possible in segkpm mode. + * + * The following combinations of "forcefault" and "rw" allow segkpm mode. + * (1) SM_FAULT, S_READ + * (2) SM_FAULT, S_WRITE + * (3) SM_PAGECREATE, S_WRITE + * (4) SM_LOCKPROTO, {S_READ, S_WRITE, S_OTHER} + * + * The regular additional operations (come in pairs in most of the cases): + * . segmap_pagecreate/segmap_pageunlock + * . segmap_fault(F_SOFTLOCK)/segmap_fault(F_SOFTUNLOCK) + * + * are mostly a no-op in segkpm mode with the following exceptions: + * . The "newpage" return value of segmap_pagecreate is still supported + * for zeroout operations needed on newly created pages. + * + * . segmap_fault() must follow when a error could be expected in + * the VOP_GETPAGE. In segkpm mode this error is recognized in + * segmap_getmapflt and returned from the following segmap_fault() + * call. The "hole" optimization (read only after first VOP_GETPAGE + * mapping in segmap_getmapflt followed by a trap driven protection + * fault and a second VOP_GETPAGE via segmap_fault) cannot be used. + * + * . segmap_fault(F_SOFTUNLOCK) must follow when segmap_getmapflt was + * called w/ (SM_LOCKPROTO, S_OTHER). S_WRITE has to be applied, when + * the page should be marked "dirty". Otherwise the page is not + * written to the backing store later (as mentioned above, no page + * or protection faults are possible in segkpm mode). Caller cannot + * use only S_OTHER and rely on a protection fault to force the page + * to become dirty. + * + * . The segmap_pagecreate parameter softlock is ignored, pages and + * mappings are locked anyway. + * + * SM_LOCKPROTO is used in the fbio layer and some special segmap consumers. + */ +#define SM_PAGECREATE 0x00 /* create page in segkpm mode, no I/O */ +#define SM_FAULT 0x01 /* fault in page if necessary */ +#define SM_LOCKPROTO 0x02 /* lock/unlock protocol used */ + +#define MAXBSHIFT 13 /* log2(MAXBSIZE) */ + +#define MAXBOFFSET (MAXBSIZE - 1) +#define MAXBMASK (~MAXBOFFSET) + +/* + * SMAP_HASHAVELEN is the average length desired for this chain, from + * which the size of the smd_hash table is derived at segment create time. + * SMAP_HASHVPSHIFT is defined so that 1 << SMAP_HASHVPSHIFT is the + * approximate size of a vnode struct. + */ +#define SMAP_HASHAVELEN 4 +#define SMAP_HASHVPSHIFT 6 + + +#ifdef _KERNEL +/* + * The kernel generic mapping segment. + */ +extern struct seg *segkmap; + +/* + * Public seg_map segment operations. + */ +extern int segmap_create(struct seg *, void *); +extern int segmap_pagecreate(struct seg *, caddr_t, size_t, int); +extern void segmap_pageunlock(struct seg *, caddr_t, size_t, enum seg_rw); +extern faultcode_t segmap_fault(struct hat *, struct seg *, caddr_t, size_t, + enum fault_type, enum seg_rw); +extern caddr_t segmap_getmap(struct seg *, struct vnode *, u_offset_t); +extern caddr_t segmap_getmapflt(struct seg *, struct vnode *, u_offset_t, + size_t, int, enum seg_rw); +extern int segmap_release(struct seg *, caddr_t, uint_t); +extern void segmap_flush(struct seg *, struct vnode *); +extern void segmap_inval(struct seg *, struct vnode *, u_offset_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_MAP_H */ diff --git a/illumos-x86_64/usr/include/vm/seg_spt.h b/illumos-x86_64/usr/include/vm/seg_spt.h new file mode 100644 index 00000000..d8cea0a4 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg_spt.h @@ -0,0 +1,156 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2018 Joyent, Inc. + */ + +#ifndef _VM_SEG_SPT_H +#define _VM_SEG_SPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +#include +#include +#include + +/* + * Passed data when creating spt segment. + */ +struct segspt_crargs { + struct seg *seg_spt; + struct anon_map *amp; + uint_t prot; + uint_t flags; + uint_t szc; +}; + +typedef struct spt_data { + struct vnode *spt_vp; + struct anon_map *spt_amp; + size_t spt_realsize; + struct page **spt_ppa; + ushort_t *spt_ppa_lckcnt; + uint_t spt_prot; + kmutex_t spt_lock; + size_t spt_pcachecnt; /* # of times in pcache */ + uint_t spt_flags; /* Dynamic ISM or regular ISM */ + kcondvar_t spt_cv; + ushort_t spt_gen; /* only updated for DISM */ + /* + * Initial memory allocation policy + * used during pre-allocation done in shmat() + */ + lgrp_mem_policy_info_t spt_policy_info; +} spt_data_t; + +/* + * Private data for spt_shm segment. + */ +typedef struct shm_data { + struct as *shm_sptas; + struct anon_map *shm_amp; + spgcnt_t shm_softlockcnt; /* # outstanding lock operations */ + struct seg *shm_sptseg; /* pointer to spt segment */ + char *shm_vpage; /* indicating locked pages */ + spgcnt_t shm_lckpgs; /* # of locked pages per attached seg */ + /* + * Memory allocation policy after shmat() + */ + lgrp_mem_policy_info_t shm_policy_info; + kmutex_t shm_segfree_syncmtx; /* barrier lock for segspt_shmfree() */ +} shm_data_t; + +#define DISM_PG_LOCKED 0x1 /* DISM page is locked */ +#define DISM_PPA_CHANGED 0x2 /* DISM new lock, need to rebuild ppa */ + +#define DISM_LOCK_MAX 0xfffe /* max number of locks per DISM page */ +#endif + +#ifdef _KERNEL + +#ifndef _ASM + +/* + * Functions used in shm.c to call ISM. + */ +int sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp, + uint_t prot, uint_t flags, uint_t szc); +void sptdestroy(struct as *, struct anon_map *); +int segspt_shmattach(struct seg **, void *); + +#define isspt(sp) ((sp)->shm_sptinfo ? (sp)->shm_sptinfo->sptas : NULL) +#define spt_locked(a) ((a) & SHM_SHARE_MMU) +#define spt_pageable(a) ((a) & SHM_PAGEABLE) +#define spt_invalid(a) (spt_locked((a)) && spt_pageable((a))) + +/* + * This can be applied to a segment with seg->s_ops == &segspt_shmops + * to determine the real size of the ISM segment. + */ +#define spt_realsize(seg) (((struct spt_data *)(((struct shm_data *)\ + ((seg)->s_data))->shm_sptseg->s_data))->spt_realsize) + +/* + * This can be applied to a segment with seg->s_ops == &segspt_ops + * to determine the flags of the {D}ISM segment. + */ +#define spt_flags(seg) (((struct spt_data *)((seg)->s_data))->spt_flags) + +/* + * For large page support + */ +extern int segvn_anypgsz; + +#endif + +/* + * In a 64-bit address space, we'll try to put ISM segments between + * PREDISM_BASE and PREDISM_BOUND. The HAT may use these constants to + * predict that a VA is contained by an ISM segment, which may optimize + * translation. The range must _only_ be treated as advisory; ISM segments + * may fall outside of the range, and non-ISM segments may be contained + * within the range. + * In order to avoid collision between ISM/DISM addresses with e.g. + * process heap addresses we will try to put ISM/DISM segments above + * PREDISM_1T_BASESHIFT (1T). + * The HAT is still expecting that any VA larger than PREDISM_BASESHIFT + * may belong to ISM/DISM (so on tlb miss it will probe first for 4M + * translation) + */ +#define PREDISM_BASESHIFT 33 +#define PREDISM_1T_BASESHIFT 40 +#define PREDISM_BASE ((uintptr_t)1 << PREDISM_BASESHIFT) +#define PREDISM_1T_BASE ((uintptr_t)1 << PREDISM_1T_BASESHIFT) +#define PREDISM_BOUND ((uintptr_t)1 << 63) + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_SPT_H */ diff --git a/illumos-x86_64/usr/include/vm/seg_vn.h b/illumos-x86_64/usr/include/vm/seg_vn.h new file mode 100644 index 00000000..97a0db01 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/seg_vn.h @@ -0,0 +1,249 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2018 Joyent, Inc. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_SEG_VN_H +#define _VM_SEG_VN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A pointer to this structure is passed to segvn_create(). + */ +typedef struct segvn_crargs { + struct vnode *vp; /* vnode mapped from */ + struct cred *cred; /* credentials */ + u_offset_t offset; /* starting offset of vnode for mapping */ + uchar_t type; /* type of sharing done */ + uchar_t prot; /* protections */ + uchar_t maxprot; /* maximum protections */ + uint_t flags; /* flags */ + struct anon_map *amp; /* anon mapping to map to */ + uint_t szc; /* max preferred page size code */ + uint_t lgrp_mem_policy_flags; +} segvn_crargs_t; + +/* + * (Semi) private data maintained by the seg_vn driver per segment mapping. + * + * The read/write segment lock protects all of segvn_data including the + * vpage array. All fields in segvn_data are treated as read-only when + * the "read" version of the address space and the segment locks are held. + * The "write" version of the segment lock, however, is required in order to + * update the following fields: + * + * pageprot + * prot + * amp + * vpage + * + * softlockcnt + * is written by acquiring either the readers lock on the segment and + * freemem lock, or any lock combination which guarantees exclusive use + * of this segment (e.g., adress space writers lock, + * address space readers lock + segment writers lock). + */ +typedef struct segvn_data { + krwlock_t lock; /* protect segvn_data and vpage array */ + kmutex_t segfree_syncmtx; /* barrier lock for segvn_free() */ + uchar_t pageprot; /* true if per page protections present */ + uchar_t prot; /* current segment prot if pageprot == 0 */ + uchar_t maxprot; /* maximum segment protections */ + uchar_t type; /* type of sharing done */ + u_offset_t offset; /* starting offset of vnode for mapping */ + struct vnode *vp; /* vnode that segment mapping is to */ + ulong_t anon_index; /* starting index into anon_map anon array */ + struct anon_map *amp; /* pointer to anon share structure, if needed */ + struct vpage *vpage; /* per-page information, if needed */ + struct cred *cred; /* mapping credentials */ + size_t swresv; /* swap space reserved for this segment */ + uchar_t advice; /* madvise flags for segment */ + uchar_t pageadvice; /* true if per page advice set */ + uchar_t svn_inz; /* true if pages marked as inherit zero */ + ushort_t flags; /* flags - from sys/mman.h */ + spgcnt_t softlockcnt; /* # of pages SOFTLOCKED in seg */ + lgrp_mem_policy_info_t policy_info; /* memory allocation policy */ + hat_region_cookie_t rcookie; /* region for hat calls */ + lgrp_mem_policy_info_t tr_policy_info; /* memory allocation for TR */ + struct seg *seg; /* pointer back to seg */ + struct segvn_data *svn_trnext; /* textrepl list next link */ + struct segvn_data *svn_trprev; /* textrepl list prev link */ + int tr_state; /* TR (text replication) state */ + uchar_t pageswap; /* true if per page swap accounting is set */ + spgcnt_t softlockcnt_sbase; /* # of softlocks for seg start addr */ + spgcnt_t softlockcnt_send; /* # of softlocks for seg end addr */ +} segvn_data_t; + +#ifdef _KERNEL + +/* + * segment text replication states. + */ +#define SEGVN_TR_INIT (0) /* Check if text replication can be enabled */ +#define SEGVN_TR_ON (1) /* Text replication is enabled */ +#define SEGVN_TR_OFF (2) /* Text replication is disabled */ + +/* + * Inherit zero states + */ +#define SEGVN_INZ_NONE (0) /* Nothing in the segment is inherit zero */ +#define SEGVN_INZ_ALL (1) /* Everything in the segment is inherit zero */ +#define SEGVN_INZ_VPP (2) /* Check struct vpages for inherit zero */ + +/* + * Macros for segvn segment driver locking. + */ +#define SEGVN_LOCK_ENTER(as, lock, type) rw_enter((lock), (type)) +#define SEGVN_LOCK_EXIT(as, lock) rw_exit((lock)) +#define SEGVN_LOCK_DOWNGRADE(as, lock) rw_downgrade((lock)) +#define SEGVN_LOCK_TRYENTER(as, lock, type) rw_tryenter((lock), (type)) + +/* + * Macros to test lock states. + */ +#define SEGVN_LOCK_HELD(as, lock) RW_LOCK_HELD((lock)) +#define SEGVN_READ_HELD(as, lock) RW_READ_HELD((lock)) +#define SEGVN_WRITE_HELD(as, lock) RW_WRITE_HELD((lock)) + +/* + * Macro used to detect the need to Break the sharing of COW pages + * + * The rw == S_WRITE is for the COW case + * rw == S_READ and type == SOFTLOCK is for the physio case + * We don't want to share a softlocked page because it can cause problems + * with multithreaded apps but if rw == S_READ_NOCOW it's ok to not break + * sharing of COW pages even in SOFTLOCK case. + */ +#define BREAK_COW_SHARE(rw, type, seg_type) ((rw == S_WRITE || \ + (type == F_SOFTLOCK && rw != S_READ_NOCOW)) && \ + seg_type == MAP_PRIVATE) + +#define SEGVN_ZFOD_ARGS(prot, max) \ + { NULL, NULL, 0, MAP_PRIVATE, prot, max, 0, NULL, 0, 0 } + +#define AS_MAP_CHECK_VNODE_LPOOB(crfp, argsp) \ + ((crfp) == (segcreate_func_t)segvn_create && \ + (((struct segvn_crargs *)(argsp))->flags & \ + (MAP_TEXT | MAP_INITDATA)) && \ + ((struct segvn_crargs *)(argsp))->szc == 0 && \ + ((struct segvn_crargs *)(argsp))->vp != NULL) + +#define AS_MAP_CHECK_ANON_LPOOB(crfp, argsp) \ + ((crfp) == (segcreate_func_t)segvn_create && \ + (((struct segvn_crargs *)(argsp))->szc == 0 || \ + ((struct segvn_crargs *)(argsp))->szc == AS_MAP_HEAP || \ + ((struct segvn_crargs *)(argsp))->szc == AS_MAP_STACK) && \ + ((struct segvn_crargs *)(argsp))->vp == NULL) + +#define SVNTR_HASH_FUNC(vp) (((((uintptr_t)(vp)) >> 4) ^ \ + (((uintptr_t)(vp)) >> 11)) & \ + (svntr_hashtab_sz - 1)) + +#define SEGVN_TR_ADDSTAT(stat) \ + segvn_textrepl_stats[CPU->cpu_id].tr_stat_##stat++ + +#define SEGVN_DATA(seg) ((struct segvn_data *)(seg)->s_data) +#define SEG_IS_PARTIAL_RESV(seg) \ + ((seg)->s_ops == &segvn_ops && SEGVN_DATA(seg) != NULL && \ + (SEGVN_DATA(seg)->vp == NULL || \ + SEGVN_DATA(seg)->vp->v_type != VREG) && \ + (SEGVN_DATA(seg)->flags & MAP_NORESERVE)) + +/* + * A hash table entry looked up by vnode, off/eoff and szc to find anon map to + * use for text replication based on main thread's (t_tid = 1) lgrp. + */ +typedef struct svntr { + struct vnode *tr_vp; /* text file vnode */ + u_offset_t tr_off; /* tr_vp mapping start offset */ + size_t tr_eoff; /* tr_vp mapping end offset */ + uint_t tr_szc; /* tr_vp mapping pagesize */ + int tr_valid; /* entry validity state */ + struct svntr *tr_next; /* next svntr in this hash bucket */ + timestruc_t tr_mtime; /* tr_vp modification time */ + timestruc_t tr_ctime; /* time of last change to attributes */ + ulong_t tr_refcnt; /* number of segs sharing this entry */ + segvn_data_t *tr_svnhead; /* list of segs sharing this entry */ + struct anon_map *tr_amp[NLGRPS_MAX]; /* per lgrp anon maps */ +} svntr_t; + +typedef struct svntr_bucket { + svntr_t *tr_head; /* first svntr in this hash bucket */ + kmutex_t tr_lock; /* per bucket lock */ +} svntr_bucket_t; + +typedef struct svntr_stats { + ulong_t tr_stat_gaerr; /* VOP_GETATTR() failures */ + ulong_t tr_stat_overmap; /* no TR due to beyond EOF mappings */ + ulong_t tr_stat_wrcnt; /* no TR due to writtable mappings */ + ulong_t tr_stat_stale; /* TR entry is stale */ + ulong_t tr_stat_overlap; /* overlap with other mappings */ + ulong_t tr_stat_nokmem; /* no TR due to kmem alloc failures */ + ulong_t tr_stat_noanon; /* no TR due to no swap space */ + ulong_t tr_stat_normem; /* no TR due to no repl memory */ + ulong_t tr_stat_nolock; /* async TR failure due to locks */ + ulong_t tr_stat_asyncrepl; /* number of async TRs */ + ulong_t tr_stat_repl; /* number of sync TRs */ + ulong_t tr_stat_newamp; /* number of new amp allocs for TR */ +} svntr_stats_t; + +extern void segvn_init(void); +extern int segvn_create(struct seg **, void *); + +extern struct seg_ops segvn_ops; + +/* + * Provided as shorthand for creating user zfod segments. + */ +extern caddr_t zfod_argsp; +extern caddr_t kzfod_argsp; +extern caddr_t stack_exec_argsp; +extern caddr_t stack_noexec_argsp; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_SEG_VN_H */ diff --git a/illumos-x86_64/usr/include/vm/vpage.h b/illumos-x86_64/usr/include/vm/vpage.h new file mode 100644 index 00000000..b11349bd --- /dev/null +++ b/illumos-x86_64/usr/include/vm/vpage.h @@ -0,0 +1,98 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _VM_VPAGE_H +#define _VM_VPAGE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * VM - Information per virtual page. + */ +struct vpage { + uchar_t nvp_prot; /* see prot flags */ + uchar_t nvp_advice; /* pplock & madvise flags */ +}; + +/* + * This was changed from a bitfield to flags/macros in order + * to conserve space (uchar_t bitfields are not ANSI). This could + * have been condensed to a uchar_t, but at the expense of complexity. + * We've stolen three bits from the top of nvp_advice: the first to store + * pplock, the second to identify pages for which we have reserved + * swap space, but have not necessarily allocated anon slots, and the third to + * indicate that the page should be zeroed on fork. + * + * WARNING: VPP_SETADVICE(vpp, x) evaluates vpp twice, and VPP_PLOCK(vpp) + * returns a positive integer when the lock is held, not necessarily (1). + */ +#define VP_ADVICE_MASK (0x07) +#define VP_PPLOCK_MASK (0x80) /* physical page locked by me */ +#define VP_PPLOCK_SHIFT (0x07) /* offset of lock hiding inside nvp_advice */ +#define VP_SWAPRES_MASK (0x40) /* Swap space has been reserved, but we */ + /* might not have allocated an anon slot */ +#define VP_INHZERO_MASK (0x20) /* zero page on fork() */ + +#define VPP_PROT(vpp) ((vpp)->nvp_prot) +#define VPP_ADVICE(vpp) ((vpp)->nvp_advice & VP_ADVICE_MASK) +#define VPP_ISPPLOCK(vpp) \ + ((uchar_t)((vpp)->nvp_advice & VP_PPLOCK_MASK)) +#define VPP_ISSWAPRES(vpp) \ + ((uchar_t)((vpp)->nvp_advice & VP_SWAPRES_MASK)) +#define VPP_ISINHZERO(vpp) \ + ((uchar_t)((vpp)->nvp_advice & VP_INHZERO_MASK)) + +#define VPP_SETPROT(vpp, x) ((vpp)->nvp_prot = (x)) +#define VPP_SETADVICE(vpp, x) \ + ((vpp)->nvp_advice = ((vpp)->nvp_advice & ~VP_ADVICE_MASK) | \ + ((x) & VP_ADVICE_MASK)) +#define VPP_SETPPLOCK(vpp) ((vpp)->nvp_advice |= VP_PPLOCK_MASK) +#define VPP_CLRPPLOCK(vpp) ((vpp)->nvp_advice &= ~VP_PPLOCK_MASK) +#define VPP_SETSWAPRES(vpp) ((vpp)->nvp_advice |= VP_SWAPRES_MASK) +#define VPP_CLRSWAPRES(vpp) ((vpp)->nvp_advice &= ~VP_SWAPRES_MASK) +#define VPP_SETINHZERO(vpp) ((vpp)->nvp_advice |= VP_INHZERO_MASK) +#define VPP_CLRINHZERO(vpp) ((vpp)->nvp_advice &= ~VP_INHZERO_MASK) + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_VPAGE_H */ diff --git a/illumos-x86_64/usr/include/vm/vpm.h b/illumos-x86_64/usr/include/vm/vpm.h new file mode 100644 index 00000000..a049f486 --- /dev/null +++ b/illumos-x86_64/usr/include/vm/vpm.h @@ -0,0 +1,297 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _VM_VPM_H +#define _VM_VPM_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The vnode page mappings(VPM) interfaces. + * "Commitment level - Consolidation private". They are subject + * to change without notice. Use them at your own risk. + * + * At this stage these interfaces are provided only to utilize the + * segkpm mappings. Therefore these interfaces have to be used under + * the 'vpm_enable' check as an alternative to segmap interfaces where + * applicable. + * + * The VPM interfaces provide temporary mappings to file pages. They + * return the mappings in a scatter gather list(SGL). + * The SGL elements are the structure 'vmap_t'. + * + * typedef struct vmap { + * caddr_t vs_addr; / public - mapped address / + * size_t vs_len; / public - length of mapping / + * void *vs_data; / opaque - private data / + * } vmap_t; + * + * An array of this structure has to be passed to the interface routines + * along with the size(# of elements) of the SGL array. Depending on the + * requested length and mapped chunk sizes(PAGESIZE here), the number of + * valid mappings returned can be less then actual size of the SGL array. + * Always, an element in the SGL will have 'vs_addr' set to NULL which + * marks the end of the valid entires in the SGL. + * + * The vmap_t structure members are populated with the mapped address + * in 'vs_addr' and length of the mapping in 'vs_len'. Currently the + * mapping length is fixed at PAGESIZE. The 'vs_data' member is private + * and the caller should not access or modify it. + * + * Using a scatter gather list to return the mappings and length makes it + * possible to provide mappings of variable length. Mapping length upto + * VPMMAXLEN is supported. The scatter gather list array size needs to + * be a minimum of MINVMAPS elements. + * + * Interfaces: + * + * int vpm_map_pages( struct vnode *vp, u_offset_t off, size_t len, + * int fetchpage, vmap_t *vml, int vmlsz, + * int *newpagecreated, enum seg_rw rw); + * + * This function returns mappings to vnode pages. + * + * It takes a vnode, offset and length and returns mappings to the pages + * covering the range [off, off + len) in the vmap_t SGL array 'vml'. + * The length passed in should satisfy the following criteria + * '(off + len) <= ((off & PAGEMASK) + VPMMAXLEN)' + * The mapped address returned, in 'vs_addr', of first vml[] entry + * is at begining of page containing 'off'. + * + * The 'vmlsz' is the size(# elements) of the 'vml' array. + * + * When the 'fetchpage' flag is set, the vnode(file) pages will be fetched + * (calls VOP_GETPAGE) from the backing store(disk) if not found in the + * system page cache. If 'fetchpage == 0', the vnode(file) pages for the + * given offset will be just created if they are not already present in the + * system page cache. The 'newpagecreated' flag is set on return if new pages + * are created when 'fetchpage == 0'(requested to just create new pages). + * + * The 'seg_rw rw' indicates the intended operation on these mappings + * (S_WRITE or S_READ). + * + * Currently these interfaces only return segkpm mappings. The vnode pages + * that are being accessed will be locked(at least SHARED locked) for the + * duration these mappings are in use. After use, the unmap function, + * vpm_unmap_pages(), has to be called and the same SGL array + * needs to be passed to the unmap function. + * + * + * void vpm_unmap_pages(vpmap_t *vml, enum seg_rw rw);. + * + * This function unmaps the pages that where mapped by vpm_map_pages. + * The SGL array 'vml' has to be the one that was passed to vpm_map_pages(). + * + * + * ex: + * To copy file data of vnode(file) 'vp' at offset 'off' to a kernel buffer + * 'buf' the following code snippet shows how to use the above two interfaces. + * Here the the copy length is till the MAXBSIZE boundary. This code can be + * executed repeatedly, in a loop to copy more then MAXBSIZE length of data. + * + * vmap_t vml[MINVMAPS]; + * int err, i, newpage, len; + * int pon; + * + * pon = (off & PAGEOFFSET); + * len = MAXBSIZE - pon; + * + * if (vpm_enable) { + * err = vpm_map_pages(vp, off, len, 0, vml, MINVMAPS, + * &newpage, S_WRITE); + * + * if (err) + * return; + * + * for (i=0; vml[i].vs_addr != NULL); i++) { + * bcopy (buf, vml[i].vs_addr + pon, + * PAGESIZE - pon); + * buf += (PAGESIZE - pon); + * pon = 0; + * } + * + * if (newpage) { + * pon = (off & PAGEOFFSET); + * bzero(vml[i-1].vs_addr + pon, PAGESIZE - pon); + * } + * + * vpm_unmap_pages(vml, S_WRITE); + * } + * + * + * + * + * int vpm_data_copy(struct vnode *vp, u_offset_t off, size_t len, + * struct uio *uio, int fetchpage, int *newpagecreated, + * int zerostart, enum seg_rw rw); + * + * This function can be called if the need is to just transfer data to/from + * the vnode pages. It takes a 'uio' structure and calls 'uiomove()' to + * do the data transfer. It can be used in the context of read and write + * system calls to transfer data between a user buffer, which is specified + * in the uio structure, and the vnode pages. If the data needs to be + * transferred between a kernel buffer and the pages, like in the above + * example, a uio structure can be set up accordingly and passed. The 'rw' + * parameter will determine the direction of the data transfer. + * + * The 'fetchpage' and 'newpagecreated' are same as explained before. + * The 'zerostart' flag when set will zero fill start of the page till the + * offset 'off' in the first page. i.e from 'off & PAGEMASK' to 'off'. + * + * + * int vpm_sync_pages(struct vnode *vp, u_offset_t off, + * size_t len, uint_t flags) + * + * This function can be called to flush or sync the vnode(file) pages that + * have been accessed. It will call VOP_PUTPAGE(). + * + * For the given vnode, off and len the pages covering the range + * [off, off + len) are flushed. Currently it uses the same flags that + * are used with segmap_release() interface. Refer vm/seg_map.h. + * (SM_DONTNEED, SM_ASYNC, SM_FREE, SM_INVAL, SM_DESTROY) + * + */ + + +/* + * vpm cache related definitions. + */ +#define VPMAP_MINCACHE (64 * 1024 * 1024) +#define VPMAP_MAXCACHE (256L * 1024L * 1024L * 1024L) /* 256G */ + + +/* + * vpm caching mode + */ +#define VPMCACHE_LRU 0 +#define VPMCACHE_RANDOM 1 +/* + * Data structures to manage the cache of pages referenced by + * the vpm interfaces. There is one vpmap struct per page in the cache. + */ +struct vpmap { + kmutex_t vpm_mtx; /* protects non list fields */ + struct vnode *vpm_vp; /* pointer to vnode of cached page */ + struct vpmap *vpm_next; /* free list pointers */ + struct vpmap *vpm_prev; + u_offset_t vpm_off; /* offset of the page */ + page_t *vpm_pp; /* page pointer */ + ushort_t vpm_refcnt; /* Number active references */ + ushort_t vpm_ndxflg; /* indicates which queue */ + ushort_t vpm_free_ndx; /* freelist it belongs to */ +}; + +/* + * Multiple vpmap free lists are maintaned so that allocations + * scale with cpu count. To further reduce contentions between + * allocation and deallocations, each list is made up of two queues. + */ +#define VPM_FREEQ_PAD 64 +union vpm_freeq { + struct { + struct vpmap *vpmsq_free; + kmutex_t vpmsq_mtx; + } vpmfq; + char vpmq_pad[VPM_FREEQ_PAD]; +}; + +#define vpmq_free vpmfq.vpmsq_free +#define vpmq_mtx vpmfq.vpmsq_mtx + +struct vpmfree { + union vpm_freeq vpm_freeq[2]; /* alloc and release queue */ + union vpm_freeq *vpm_allocq; /* current alloc queue */ + union vpm_freeq *vpm_releq; /* current release queue */ + kcondvar_t vpm_free_cv; + ushort_t vpm_want; +}; + +#define VPMALLOCQ 0 +#define VPMRELEQ 1 + +/* + * VPM Interface definitions. + */ + +/* + * This structure is the scatter gather list element. The page + * mappings will be returned in this structure. A pointer to an + * array of this structure is passed to the interface routines. + */ +typedef struct vmap { + caddr_t vs_addr; /* mapped address */ + size_t vs_len; /* length, currently fixed at PAGESIZE */ + void *vs_data; /* opaque - private data */ +} vmap_t; + +#define VPM_FETCHPAGE 0x01 /* fault in pages */ + +/* + * Max request length - Needs to be a multiple of + * 8192 (PAGESIZE on sparc) so it works properly on both + * x86 & sparc systems. Max set to 128k. + */ +#define VPMMAXLEN (128*1024) + +/* + * The minimum and maximum number of array elements in the scatter + * gather list. + */ +#define MINVMAPS 3 /* ((MAXBSIZE/4096 + 1) min # mappings */ +#if defined(__sparc) +#define VPMMAXPGS (VPMMAXLEN/8192) /* Max # pages at a time */ +#else +#define VPMMAXPGS (VPMMAXLEN/4096) +#endif +#define MAXVMAPS (VPMMAXPGS + 1) /* Max # elements in the */ + /* scatter gather list */ + /* +1 element to mark the */ + /* end of the list of valid */ + /* mappings */ + +#ifdef _KERNEL + +extern int vpm_enable; +/* + * vpm page mapping operations. + */ +extern void vpm_init(void); +extern int vpm_map_pages(struct vnode *, u_offset_t, size_t, int, + vmap_t *, int, int *, enum seg_rw); + +extern void vpm_unmap_pages(vmap_t *, enum seg_rw); +extern int vpm_sync_pages(struct vnode *, u_offset_t, size_t, uint_t); +extern int vpm_data_copy(struct vnode *, u_offset_t, size_t, + struct uio *, int, int *, int, enum seg_rw rw); +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_VPM_H */ diff --git a/illumos-x86_64/usr/include/volmgt.h b/illumos-x86_64/usr/include/volmgt.h new file mode 100644 index 00000000..cb141e62 --- /dev/null +++ b/illumos-x86_64/usr/include/volmgt.h @@ -0,0 +1,325 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1993, by Sun Microsystems, Inc. + */ + +#ifndef _VOLMGT_H +#define _VOLMGT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * volmgt_check: + * have volume management look at its devices to check + * for media having arrived. Since volume management can't + * automatically check all types of devices, this function is provided + * to allow applications to cause the check to happen automatically. + * + * arguments: + * path - the name of the device in /dev. For example, + * /dev/rdiskette. If path is NULL, all "checkable" devices are + * checked. + * + * return value(s): + * TRUE if media was found in the device, FALSE if not. + */ +int volmgt_check(char *path); + +/* + * volmgt_inuse: + * check to see if volume management is currently + * managing a particular device. + * + * arguments: + * path - the name of the device in /dev. For example, + * "/dev/rdiskette". + * + * return value(s): + * TRUE if volume management is managing the device, FALSE if not. + */ +int volmgt_inuse(char *path); + +/* + * volmgt_running: + * check to see if volume management is running. + * + * arguments: + * none. + * + * return value(s): + * TRUE if volume management is running, FALSE if not. + */ +int volmgt_running(void); + +/* + * volmgt_symname: + * Returns the volume management symbolic name + * for a given device. If an application wants to determine + * what the symbolic name (e.g. "floppy0") for the /dev/rdiskette + * device would be, this is the function to use. + * + * arguments: + * path - a string containing the /dev device name. For example, + * "/dev/diskette" or "/dev/rdiskette". + * + * return value(s): + * pointer to a string containing the symbolic name. + * + * NULL indicates that volume management isn't managing that device. + * + * The string must be free(3)'d. + */ +char *volmgt_symname(char *path); + +/* + * volmgt_symdev: + * Returns the device given the volume management + * symbolic name. If an application wants to determine + * what the device associated with a particular symbolic name + * might be, this is the function to use. + * + * arguments: + * path - a string containing the symbolic device name. For example, + * "cdrom0" or "floppy0". + * + * return value(s): + * pointer to a string containing the /dev name. + * + * NULL indicates that volume management isn't managing that device. + * + * The string must be free(3)'d. + */ +char *volmgt_symdev(char *symname); + +/* + * volmgt_ownspath: + * check to see if the given path is contained in + * the volume management name space. + * + * arguments: + * path - string containing the path. + * + * return value(s): + * TRUE if the path is owned by volume management, FALSE if not. + * Will return FALSE if volume management isn't running. + * + */ +int volmgt_ownspath(char *path); + +/* + * volmgt_root: + * return the root of where the volume management + * name space is mounted. + * + * arguments: + * none. + * + * return value(s): + * Returns a pointer to a string containing the path to the + * volume management root (e.g. "/vol"). + * Will return NULL if volume management isn't running. + */ +const char *volmgt_root(void); + +/* + * media_findname: + * try to come up with the character device when + * provided with a starting point. This interface provides the + * application programmer to provide "user friendly" names and + * easily determine the "/vol" name. + * + * arguments: + * start - a string describing a device. This string can be: + * - a full path name to a device (insures it's a + * character device by using getfullrawname()). + * - a full path name to a volume management media name + * with partitions (will return the lowest numbered + * raw partition. + * - the name of a piece of media (e.g. "fred"). + * - a symbolic device name (e.g. floppy0, cdrom0, etc) + * - a name like "floppy" or "cdrom". Will pick the lowest + * numbered device with media in it. + * + * return value(s): + * A pointer to a string that contains the character device + * most appropriate to the "start" argument. + * + * NULL indicates that we were unable to find media based on "start". + * + * The string must be free(3)'d. + */ +char *media_findname(char *start); + +/* + * media_getattr: + * returns the value for an attribute for a piece of + * removable media. + * + * arguments: + * path - Path to the media in /vol. Can be the block or character + * device. + * + * attr - name of the attribute. + * + * return value(s): + * returns NULL or a pointer to a string that contains the value for + * the requested attribute. + * + * NULL can mean: + * - the media doesn't exist + * - there is no more space for malloc(3) + * - the attribute doesn't exist for the named media + * - the attribute is a boolean and is FALSE + * + * the pointer to the string must be free'd with free(3). + */ +char *media_getattr(char *path, char *attr); + +/* + * media_setattr: + * set an attribute for a piece of media to a + * particular value. + * + * arguments: + * path - Path to the media in /vol. Can be the block or character + * device. + * + * attr - name of the attribute. + * + * value - value of the attribute. If value == "", the flag is + * considered to be a boolean that is TRUE. If value == 0, it + * is considered to be a FALSE boolean. + * + * return value(s): + * TRUE on success, FALSE for failure. + * + * Can fail because: + * - don't have permission to set the attribute because caller + * is not the owner of the media and attribute is a "system" + * attribute. + * + * - don't have permission to set the attribute because the + * attribute is a "system" attribute and is read-only. + */ +int media_setattr(char *path, char *attr, char *value); + +/* + * media_getid: + * return the "id" of a piece of media. + * + * arguments: + * path - Path to the media in /vol. Can be the block or character + * device. + * return value(s): + * returns a u_longlong_t that is the "id" of the volume. + * + */ +u_longlong_t media_getid(char *path); + +/* + * volmgt_feature_enabled: + * check to see if a volume management feature is available + * + * arguments: + * feat_str - a string containing the feature to be checked for + * + * return value(s): + * returns non-zero if the specified feature is available + * in volume management, else return zero + */ +int volmgt_feature_enabled(char *feat_str); + +/* + * volmgt_acquire + * try to acquire the volmgt advisory device reservation + * for a specific device. -- if volmgt isn't running then try to + * reserve the device specified + * + * arguments: + * dev - a device name to attempt reserving. This string can be: + * - a full path name to a device in /vol if volmgt is running + * - a symbolic device name (e.g. floppy0) if volmgt is running + * - a /dev pathname if volmgt is not running + * + * id - a reservation string that hopefully describes the application + * making this reservation. + * + * ovr - an override indicator. If set to non-zero, the caller requests + * that this reservation be made unconditionally. + * + * err - the address of a char ptr that will updated to point to the + * id argument used when the current device was reserved. This + * is only used when the current reservation attempt fails due + * to an already existing reservation for this device. + * + * pidp - a pointer to a pid_t type. If this argument is not NULL + * and the requested device is already reserved, the process + * id of the reservation owner will be returned in this + * location. + * + * + * return value(s): + * A non-zero indicator if successful. + * + * A zero indicator if unsuccessful. If errno is EBUSY, then the err + * argument will be set to point to the string that the process currently + * holding the reservation supplied when reserving the device. It is up + * to the caller to release the storage occupied by the string via + * free(3C) when no longer needed. + */ +int volmgt_acquire(char *dev, char *id, int ovr, char **err, pid_t *pidp); + +/* + * the max length for the "id" string in volmgt_acquire + */ +#define VOL_RSV_MAXIDLEN 256 + +/* + * volmgt_release: + * try to release the volmgt advisory device reservation + * for a specific device. + * + * arguments: + * dev - a device name to attempt reserving. This string can be: + * - a full path name to a device in /vol if volmgt is running + * - a symbolic device name (e.g. floppy0) if volmgt is running + * - a /dev pathname if volmgt is not running + * + * return value(s): + * A non-zero indicator if successful + * A zero indicator if unsuccessful + * + * preconditions: + * none + */ +int volmgt_release(char *dev); + +#ifdef __cplusplus +} +#endif + +#endif /* _VOLMGT_H */ diff --git a/illumos-x86_64/usr/include/wait.h b/illumos-x86_64/usr/include/wait.h new file mode 100644 index 00000000..0b190d19 --- /dev/null +++ b/illumos-x86_64/usr/include/wait.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#ifndef _WAIT_H +#define _WAIT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern pid_t wait(int *); +extern pid_t waitpid(pid_t, int *, int); +extern int waitid(idtype_t, id_t, siginfo_t *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _WAIT_H */ diff --git a/illumos-x86_64/usr/include/wchar.h b/illumos-x86_64/usr/include/wchar.h new file mode 100644 index 00000000..fd0ab3ae --- /dev/null +++ b/illumos-x86_64/usr/include/wchar.h @@ -0,0 +1,206 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _WCHAR_H +#define _WCHAR_H + +#include +#include +#include + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::FILE; +using std::wint_t; +using std::clock_t; +using std::size_t; +using std::time_t; +using std::tm; +using std::mbstate_t; +using std::fgetwc; +using std::fgetws; +using std::fputwc; +using std::fputws; +using std::ungetwc; +using std::getwc; +using std::getwchar; +using std::putwc; +using std::putwchar; +using std::wcstod; +using std::wcstol; +using std::wcstoul; +using std::wcscat; +using std::wcschr; +using std::wcscmp; +using std::wcscoll; +using std::wcscpy; +using std::wcscspn; +using std::wcslen; +using std::wcsncat; +using std::wcsncmp; +using std::wcsncpy; +using std::wcspbrk; +using std::wcsrchr; +using std::wcsspn; +using std::wcsxfrm; +using std::wcstok; +using std::wcsftime; +/* not XPG4 and not XPG4v2 */ +#if (!defined(_XPG4) && !defined(_XPG4_2) || defined(_XPG5)) +using std::btowc; +using std::fwprintf; +using std::fwscanf; +using std::fwide; +using std::mbsinit; +using std::mbrlen; +using std::mbrtowc; +using std::mbsrtowcs; +using std::swprintf; +using std::swscanf; +using std::vfwprintf; +using std::vwprintf; +using std::vswprintf; +using std::wcrtomb; +using std::wcsrtombs; +using std::wcsstr; +using std::wctob; +using std::wmemchr; +using std::wmemcmp; +using std::wmemcpy; +using std::wmemmove; +using std::wmemset; +using std::wprintf; +using std::wscanf; +#endif /* not XPG4 and not XPG4v2 */ +#endif /* __cplusplus >= 199711L */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#if !defined(_WCTYPE_T) || __cplusplus >= 199711L +#define _WCTYPE_T +typedef int wctype_t; +#endif +#endif /* !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE)... */ + +/* + * XPG6 requires that va_list be defined as defined in , + * however, inclusion of breaks Standard C namespace. + */ +#if defined(_XPG6) && !defined(_VA_LIST) +#define _VA_LIST +typedef __va_list va_list; +#endif /* defined(_XPG6) && !defined(_VA_LIST) */ + +#if !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) +#if __cplusplus >= 199711L +namespace std { +#endif +extern int iswalpha(wint_t); +extern int iswupper(wint_t); +extern int iswlower(wint_t); +extern int iswdigit(wint_t); +extern int iswxdigit(wint_t); +extern int iswalnum(wint_t); +extern int iswspace(wint_t); +extern int iswpunct(wint_t); +extern int iswprint(wint_t); +extern int iswgraph(wint_t); +extern int iswcntrl(wint_t); +extern int iswctype(wint_t, wctype_t); +extern wint_t towlower(wint_t); +extern wint_t towupper(wint_t); +extern wchar_t *wcswcs(const wchar_t *, const wchar_t *); +extern int wcswidth(const wchar_t *, size_t); +extern int wcwidth(wchar_t); +extern wctype_t wctype(const char *); +#if __cplusplus >= 199711L +} /* namespace std */ + +using std::iswalpha; +using std::iswupper; +using std::iswlower; +using std::iswdigit; +using std::iswxdigit; +using std::iswalnum; +using std::iswspace; +using std::iswpunct; +using std::iswprint; +using std::iswgraph; +using std::iswcntrl; +using std::iswctype; +using std::towlower; +using std::towupper; +using std::wcswcs; +using std::wcswidth; +using std::wcwidth; +using std::wctype; +#endif +#endif /* !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE)... */ + +#if defined(_XPG7) || !defined(_STRICT_SYMBOLS) + +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +extern size_t wcsnlen(const wchar_t *, size_t); +extern wchar_t *wcpcpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD); +extern wchar_t *wcpncpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); +extern size_t wcsxfrm_l(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t, locale_t); +extern int wcscoll_l(const wchar_t *, const wchar_t *, locale_t); +extern wchar_t *wcsdup(const wchar_t *); +extern int wcscasecmp(const wchar_t *, const wchar_t *); +extern int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t); +extern int wcsncasecmp(const wchar_t *, const wchar_t *, size_t); +extern int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t); +extern size_t mbsnrtowcs(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD, + size_t, size_t, mbstate_t *_RESTRICT_KYWD); + +extern FILE *open_wmemstream(wchar_t **, size_t *); + +#endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */ + +#if defined(_XPG8) || !defined(_STRICT_SYMBOLS) +extern size_t wcslcat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); +extern size_t wcslcpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); +#endif /* defined(_XPG8) || !defined(_STRICT_SYMBOLS) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _WCHAR_H */ diff --git a/illumos-x86_64/usr/include/wchar_impl.h b/illumos-x86_64/usr/include/wchar_impl.h new file mode 100644 index 00000000..b5d5b0e9 --- /dev/null +++ b/illumos-x86_64/usr/include/wchar_impl.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _WCHAR_IMPL_H +#define _WCHAR_IMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _MBSTATET_H +#define _MBSTATET_H +typedef struct __mbstate_t { +#if defined(_LP64) + long __filler[4]; +#else + int __filler[6]; +#endif +} __mbstate_t; +#endif /* _MBSTATET_H */ + +#ifdef __cplusplus +} +#endif + +#endif /* _WCHAR_IMPL_H */ diff --git a/illumos-x86_64/usr/include/wctype.h b/illumos-x86_64/usr/include/wctype.h new file mode 100644 index 00000000..26ff9a83 --- /dev/null +++ b/illumos-x86_64/usr/include/wctype.h @@ -0,0 +1,162 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* wctype.h 1.13 89/11/02 SMI; JLE */ +/* from AT&T JAE 2.1 */ +/* definitions for international functions */ + +/* + * Copyright 2015 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _WCTYPE_H +#define _WCTYPE_H + +#include +#include +#ifndef _STRICT_SYMBOLS +#include +#include +#endif + +/* + * Allow global visibility for symbols defined in + * C++ "std" namespace in . + */ +#if __cplusplus >= 199711L +using std::wint_t; +using std::wctrans_t; +using std::iswalnum; +using std::iswalpha; +using std::iswcntrl; +using std::iswdigit; +using std::iswgraph; +using std::iswlower; +using std::iswprint; +using std::iswpunct; +using std::iswspace; +using std::iswupper; +using std::iswxdigit; +using std::towlower; +using std::towupper; +using std::wctrans; +using std::towctrans; +using std::iswctype; +using std::wctype; +#if (__cplusplus >= 201103L) || defined(_STDC_C99) || defined(_XPG6) || \ + !defined(_STRICT_SYMBOLS) +using std::iswblank; +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* do not allow any of the following in a strictly conforming application */ +#ifndef _STRICT_SYMBOLS + +/* + * data structure for supplementary code set + * for character class and conversion + */ +struct _wctype { + wchar_t tmin; /* minimum code for wctype */ + wchar_t tmax; /* maximum code for wctype */ + unsigned char *index; /* class index */ + unsigned int *type; /* class type */ + wchar_t cmin; /* minimum code for conversion */ + wchar_t cmax; /* maximum code for conversion */ + wchar_t *code; /* conversion code */ +}; + + +#ifdef _ILLUMOS_PRIVATE +extern int __iswrune(wint_t); +extern wint_t __nextwctype(wint_t, wctype_t); +#define iswrune(c) __iswrune(c) +#define nextwctype(c, t) __nextwctype(c, t) +#endif + +/* character classification functions */ + +/* iswascii is still a macro */ +#define iswascii(c) isascii(c) + +/* isw*, except iswascii(), are not macros any more. They become functions */ + +/* is* also become functions */ +extern int isphonogram(wint_t); +extern int isideogram(wint_t); +extern int isenglish(wint_t); +extern int isnumber(wint_t); +extern int isspecial(wint_t); +/* From BSD/MacOS */ +extern int iswideogram(wint_t); +extern int iswphonogram(wint_t); +extern int iswnumber(wint_t); +extern int iswhexnumber(wint_t); +extern int iswspecial(wint_t); + +#define iscodeset0(c) isascii(c) +#define iscodeset1(c) (((c) & WCHAR_CSMASK) == WCHAR_CS1) +#define iscodeset2(c) (((c) & WCHAR_CSMASK) == WCHAR_CS2) +#define iscodeset3(c) (((c) & WCHAR_CSMASK) == WCHAR_CS3) + +#endif /* !defined(_STRICT_SYMBOLS)... */ + + +/* XPG7 extended locale support */ +#if defined(_XPG7) || !defined(_STRICT_SYMBOLS) + +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +extern wint_t towlower_l(wint_t, locale_t); +extern wint_t towupper_l(wint_t, locale_t); +extern wint_t towctrans_l(wint_t, wctrans_t, locale_t); +extern int iswctype_l(wint_t, wctype_t, locale_t); +extern int iswalnum_l(wint_t, locale_t); +extern int iswalpha_l(wint_t, locale_t); +extern int iswblank_l(wint_t, locale_t); +extern int iswcntrl_l(wint_t, locale_t); +extern int iswdigit_l(wint_t, locale_t); +extern int iswgraph_l(wint_t, locale_t); +extern int iswlower_l(wint_t, locale_t); +extern int iswprint_l(wint_t, locale_t); +extern int iswpunct_l(wint_t, locale_t); +extern int iswspace_l(wint_t, locale_t); +extern int iswupper_l(wint_t, locale_t); +extern int iswxdigit_l(wint_t, locale_t); +extern wctrans_t wctrans_l(const char *, locale_t); +extern wctype_t wctype_l(const char *, locale_t); +#endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _WCTYPE_H */ diff --git a/illumos-x86_64/usr/include/wget.h b/illumos-x86_64/usr/include/wget.h new file mode 100644 index 00000000..f4315689 --- /dev/null +++ b/illumos-x86_64/usr/include/wget.h @@ -0,0 +1,2888 @@ +/* + * Copyright (c) 2012-2015 Tim Ruehsen + * Copyright (c) 2015-2024 Free Software Foundation, Inc. + * + * This file is part of libwget. + * + * Libwget is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Libwget is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libwget. If not, see . + * + * + * Header file for libwget library routines + * + * Changelog + * 28.12.2012 Tim Ruehsen created (moved wget.h and list.h and into here) + * + */ + +#ifndef WGET_WGET_H +#define WGET_WGET_H + +#include // size_t +#include +#include +#include // va_list +#include // FILE +#include +#include // bool +#include // int64_t + +#ifdef WGETVER_FILE +# include WGETVER_FILE +#else //not WGETVER_FILE +# include "wgetver.h" +#endif //WGETVER_FILE + +// see https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html +#if defined BUILDING_LIBWGET && HAVE_VISIBILITY +# define WGETAPI __attribute__ ((__visibility__("default"))) +#elif defined BUILDING_LIBWGET && defined _MSC_VER && !defined LIBWGET_STATIC +# define WGETAPI __declspec(dllexport) +#elif defined _MSC_VER && !defined LIBWGET_STATIC +# define WGETAPI __declspec(dllimport) +#else +# define WGETAPI +#endif + +/* + * Attribute defines specific for clang (especially for improving clang analyzer) + * Using G_GNU_ as prefix to let gtk-doc recognize the attributes. + */ + +/* + * Attribute defines for GCC and compatible compilers + * Using G_GNU_ as prefix to let gtk-doc recognize the attributes. + * + * Clang also defines __GNUC__. It promotes a GCC version of 4.2.1. + */ + +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define GCC_VERSION_AT_LEAST(major, minor) ((__GNUC__ > (major)) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) +#else +# define GCC_VERSION_AT_LEAST(major, minor) 0 +#endif + +#if defined __clang_major__ && defined __clang_minor__ +# define CLANG_VERSION_AT_LEAST(major, minor) ((__clang_major__ > (major)) || (__clang_major__ == (major) && __clang_minor__ >= (minor))) +#else +# define CLANG_VERSION_AT_LEAST(major, minor) 0 +#endif + +#if GCC_VERSION_AT_LEAST(2,5) +# define WGET_GCC_CONST __attribute__ ((const)) +#else +# define WGET_GCC_CONST +#endif + +#define WGET_GCC_NORETURN_FUNCPTR +#if GCC_VERSION_AT_LEAST(2,8) || __SUNPRO_C >= 0x5110 +# define WGET_GCC_NORETURN __attribute__ ((__noreturn__)) +# undef WGET_GCC_NORETURN_FUNCPTR +# define G_GNUC_NORETURN_FUNCPTR WGET_GCC_NORETURN +#elif _MSC_VER >= 1200 +# define WGET_GCC_NORETURN __declspec (noreturn) +#elif __STDC_VERSION__ >= 201112 +# define WGET_GCC_NORETURN _Noreturn +#else +# define WGET_GCC_NORETURN +#endif + +#if GCC_VERSION_AT_LEAST(2,95) +# define WGET_GCC_PRINTF_FORMAT(a, b) __attribute__ ((format (printf, a, b))) +# define WGET_GCC_UNUSED __attribute__ ((unused)) +#else +# define WGET_GCC_PRINTF_FORMAT(a, b) +# define WGET_GCC_UNUSED +#endif + +#if GCC_VERSION_AT_LEAST(2,96) +# define WGET_GCC_PURE __attribute__ ((pure)) +#else +# define WGET_GCC_PURE +#endif + +#if GCC_VERSION_AT_LEAST(3,0) +# define WGET_GCC_MALLOC __attribute__ ((malloc)) +# define unlikely(expr) __builtin_expect(!!(expr), 0) +# define likely(expr) __builtin_expect(!!(expr), 1) +#else +# define WGET_GCC_MALLOC +# define unlikely(expr) expr +# define likely(expr) expr +#endif + +#if GCC_VERSION_AT_LEAST(3,1) +# define WGET_GCC_ALWAYS_INLINE __attribute__ ((always_inline)) +# define WGET_GCC_FLATTEN __attribute__ ((flatten)) +# define WGET_GCC_DEPRECATED __attribute__ ((deprecated)) +#else +# define WGET_GCC_ALWAYS_INLINE +# define WGET_GCC_FLATTEN +# define WGET_GCC_DEPRECATED +#endif + +// nonnull is dangerous to use with current gcc <= 4.7.1. +// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308 +// we have to use e.g. the clang analyzer if we want NONNULL. +// but even clang is not perfect - don't use nonnull in production +#if GCC_VERSION_AT_LEAST(3,3) +# define WGET_GCC_NONNULL_ALL __attribute__ ((nonnull)) +# define WGET_GCC_NONNULL(a) __attribute__ ((nonnull a)) +#else +# define WGET_GCC_NONNULL_ALL +# define WGET_GCC_NONNULL(a) +#endif + +#if GCC_VERSION_AT_LEAST(3,4) +# define WGET_GCC_UNUSED_RESULT __attribute__ ((warn_unused_result)) +#else +# define WGET_GCC_UNUSED_RESULT +#endif + +#if GCC_VERSION_AT_LEAST(4,0) +# define WGET_GCC_NULL_TERMINATED __attribute__((__sentinel__)) +#else +# define WGET_GCC_NULL_TERMINATED +#endif + +#if GCC_VERSION_AT_LEAST(4,9) || CLANG_VERSION_AT_LEAST(7,0) +# define WGET_GCC_RETURNS_NONNULL __attribute__((returns_nonnull)) +#else +# define WGET_GCC_RETURNS_NONNULL +#endif + +#if GCC_VERSION_AT_LEAST(4,3) || CLANG_VERSION_AT_LEAST(6,0) +# define WGET_GCC_ALLOC_SIZE(a) __attribute__ ((__alloc_size__(a))) +# define WGET_GCC_ALLOC_SIZE2(a, b) __attribute__ ((__alloc_size__(a, b))) +#else +# define WGET_GCC_ALLOC_SIZE(a) +# define WGET_GCC_ALLOC_SIZE2(a, b) +#endif + +#ifdef BUILDING_LIBWGET +# define LIBWGET_WARN_UNUSED_RESULT WGET_GCC_UNUSED_RESULT +#else +# define LIBWGET_WARN_UNUSED_RESULT +#endif + +// Let C++ include C headers +#ifdef __cplusplus +# define WGET_BEGIN_DECLS extern "C" { +# define WGET_END_DECLS } +#else +# define WGET_BEGIN_DECLS +# define WGET_END_DECLS +#endif + +// define MALLOC_RETURNS_NONNULL when using appropriate implementations of the alloc functions +#ifdef MALLOC_RETURNS_NONNULL +# define RETURNS_NONNULL WGET_GCC_RETURNS_NONNULL +# define NULLABLE +#else +# define RETURNS_NONNULL +# if defined __clang_major__ && defined WGET_MANYWARNINGS +# define NULLABLE _Nullable +# else +# define NULLABLE +# endif +#endif + +#undef GCC_VERSION_AT_LEAST +#undef CLANG_VERSION_AT_LEAST + +WGET_BEGIN_DECLS + +/* + * Library initialization functions + */ + +// Why not using enum ? Might result in different values if one entry is inserted. +// And that might break the ABI. +#define WGET_DEBUG_STREAM 1000 +#define WGET_DEBUG_FUNC 1001 +#define WGET_DEBUG_FILE 1002 +#define WGET_ERROR_STREAM 1003 +#define WGET_ERROR_FUNC 1004 +#define WGET_ERROR_FILE 1005 +#define WGET_INFO_STREAM 1006 +#define WGET_INFO_FUNC 1007 +#define WGET_INFO_FILE 1008 +#define WGET_DNS_CACHING 1009 +#define WGET_COOKIE_SUFFIXES 1010 +#define WGET_COOKIES_ENABLED 1011 +#define WGET_COOKIE_FILE 1012 +#define WGET_COOKIE_DB 1013 +#define WGET_COOKIE_KEEPSESSIONCOOKIES 1014 +#define WGET_BIND_ADDRESS 1015 +#define WGET_NET_FAMILY_EXCLUSIVE 1016 +#define WGET_NET_FAMILY_PREFERRED 1017 +#define WGET_TCP_FASTFORWARD 1018 +#define WGET_BIND_INTERFACE 1019 + +#define WGET_HTTP_URL 2000 +#define WGET_HTTP_URL_ENCODING 2001 +#define WGET_HTTP_URI 2002 +#define WGET_HTTP_COOKIE_STORE 2003 +#define WGET_HTTP_HEADER_ADD 2004 +//#define WGET_HTTP_HEADER_DEL 2005 +//#define WGET_HTTP_HEADER_SET 2006 +//#define WGET_HTTP_BIND_ADDRESS 2007 +#define WGET_HTTP_CONNECTION_PTR 2008 +#define WGET_HTTP_RESPONSE_KEEPHEADER 2009 +#define WGET_HTTP_MAX_REDIRECTIONS 2010 +#define WGET_HTTP_BODY_SAVEAS_STREAM 2011 +#define WGET_HTTP_BODY_SAVEAS_FILE 2012 +#define WGET_HTTP_BODY_SAVEAS_FD 2013 +#define WGET_HTTP_BODY_SAVEAS_FUNC 2014 +#define WGET_HTTP_HEADER_FUNC 2015 +#define WGET_HTTP_SCHEME 2016 +#define WGET_HTTP_BODY 2017 +#define WGET_HTTP_BODY_SAVEAS 2018 +#define WGET_HTTP_USER_DATA 2019 +#define WGET_HTTP_RESPONSE_IGNORELENGTH 2020 +#define WGET_HTTP_DEBUG_SKIP_BODY 2021 + +// definition of error conditions +typedef enum { + WGET_E_SUCCESS = 0, /* OK */ + WGET_E_UNKNOWN = -1, /* general error if nothing else appropriate */ + WGET_E_MEMORY = -2, /* memory allocation failure */ + WGET_E_INVALID = -3, /* invalid value to function */ + WGET_E_TIMEOUT = -4, /* timeout condition */ + WGET_E_CONNECT = -5, /* connect failure */ + WGET_E_HANDSHAKE = -6, /* general TLS handshake failure */ + WGET_E_CERTIFICATE = -7, /* general TLS certificate failure */ + WGET_E_TLS_DISABLED = -8, /* TLS was not enabled at compile time */ + WGET_E_XML_PARSE_ERR = -9, /* XML parsing failed */ + WGET_E_OPEN = -10, /* Failed to open file */ + WGET_E_IO = -11, /* General I/O error (read/write/stat/...) */ + WGET_E_UNSUPPORTED = -12, /* Unsupported function */ +} wget_error; + +WGETAPI const char * + wget_strerror(wget_error err); + +typedef void wget_global_func(const char *, size_t); + +WGETAPI void + wget_global_init(int key, ...); +WGETAPI void + wget_global_deinit(void); +WGETAPI const void * NULLABLE + wget_global_get_ptr(int key); +WGETAPI int + wget_global_get_int(int key); +WGETAPI wget_global_func * + wget_global_get_func(int key); + +/* + * Utility functions + */ + +/** + * WGET_UTILITY: + * + * General utility functions + */ + +// values for wget_ready_to_transfer() +#define WGET_IO_READABLE 1 +#define WGET_IO_WRITABLE 2 + +// types for --restrict-file-names / wget_restrict_file_name() +#define WGET_RESTRICT_NAMES_NONE 0 +#define WGET_RESTRICT_NAMES_UNIX 1<<0 +#define WGET_RESTRICT_NAMES_WINDOWS 1<<1 +#define WGET_RESTRICT_NAMES_NOCONTROL 1<<2 +#define WGET_RESTRICT_NAMES_ASCII 1<<3 +#define WGET_RESTRICT_NAMES_UPPERCASE 1<<4 +#define WGET_RESTRICT_NAMES_LOWERCASE 1<<5 + +typedef int wget_update_load_fn(void *, FILE *fp); +typedef int wget_update_save_fn(void *, FILE *fp); + +WGETAPI int + wget_ready_2_read(int fd, int timeout); +WGETAPI int + wget_ready_2_write(int fd, int timeout); +WGETAPI int + wget_ready_2_transfer(int fd, int timeout, int mode); +WGETAPI int + wget_strcmp(const char *s1, const char *s2) WGET_GCC_PURE; +WGETAPI int + wget_strcasecmp(const char *s1, const char *s2) WGET_GCC_PURE; +WGETAPI int + wget_strcasecmp_ascii(const char *s1, const char *s2) WGET_GCC_PURE; +WGETAPI int + wget_strncasecmp_ascii(const char *s1, const char *s2, size_t n) WGET_GCC_PURE; +WGETAPI char * + wget_strtolower(char *s); +WGETAPI int + wget_strncmp(const char *s1, const char *s2, size_t n) WGET_GCC_PURE; +WGETAPI int + wget_strncasecmp(const char *s1, const char *s2, size_t n) WGET_GCC_PURE; +WGETAPI void + wget_memtohex(const unsigned char * __restrict src, size_t src_len, char * __restrict dst, size_t dst_size); +WGETAPI void + wget_millisleep(int ms); +WGETAPI long long + wget_get_timemillis(void); +WGETAPI int + wget_percent_unescape(char *src); +WGETAPI int + wget_match_tail(const char *s, const char *tail) WGET_GCC_PURE WGET_GCC_NONNULL_ALL; +WGETAPI int + wget_match_tail_nocase(const char *s, const char *tail) WGET_GCC_PURE WGET_GCC_NONNULL_ALL; +WGETAPI char * NULLABLE + wget_strnglob(const char *str, size_t n, int flags) WGET_GCC_PURE; +WGETAPI char * + wget_human_readable(char *buf, size_t bufsize, uint64_t n); +WGETAPI int + wget_get_screen_size(int *width, int *height); +WGETAPI ssize_t + wget_fdgetline(char **buf, size_t *bufsize, int fd); +WGETAPI ssize_t + wget_getline(char **buf, size_t *bufsize, FILE *fp); +WGETAPI FILE * NULLABLE + wget_vpopenf(const char *type, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0); +WGETAPI FILE * NULLABLE + wget_popenf(const char *type, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3); +WGETAPI FILE * NULLABLE + wget_popen2f(FILE **fpin, FILE **fpout, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(3,4); +WGETAPI pid_t + wget_fd_popen3(int *fdin, int *fdout, int *fderr, const char *const *argv); +WGETAPI pid_t + wget_popen3(FILE **fpin, FILE **fpout, FILE **fperr, const char *const *argv); +WGETAPI char * NULLABLE + wget_read_file(const char *fname, size_t *size) WGET_GCC_MALLOC; +WGETAPI int + wget_update_file(const char *fname, wget_update_load_fn *load_func, wget_update_save_fn *save_func, void *context); +WGETAPI int + wget_truncate(const char *path, off_t length); +WGETAPI const char * + wget_local_charset_encoding(void); +WGETAPI int + wget_memiconv(const char *src_encoding, const void *src, size_t srclen, const char *dst_encoding, char **out, size_t *outlen); +WGETAPI char * NULLABLE + wget_striconv(const char *src, const char *src_encoding, const char *dst_encoding) WGET_GCC_MALLOC; +WGETAPI bool + wget_str_needs_encoding(const char *s) WGET_GCC_PURE; +WGETAPI bool + wget_str_is_valid_utf8(const char *utf8) WGET_GCC_PURE; +WGETAPI char * NULLABLE + wget_str_to_utf8(const char *src, const char *encoding) WGET_GCC_MALLOC; +WGETAPI char * NULLABLE + wget_utf8_to_str(const char *src, const char *encoding) WGET_GCC_MALLOC; +WGETAPI const char * + wget_str_to_ascii(const char *src); + +/** + * WGET_COMPATIBILITY: + * + * General compatibility functions + */ + +WGETAPI size_t + wget_strlcpy(char *__restrict dst, const char *__restrict src, size_t size); +WGETAPI ssize_t + wget_strscpy(char *__restrict dst, const char *__restrict src, size_t size); + +/** + * \ingroup libwget-list + * + * Type for double linked lists and list entries. + */ +typedef struct wget_list_st wget_list; +typedef int wget_list_browse_fn(void *context, void *elem); + +WGETAPI void * NULLABLE + wget_list_append(wget_list **list, const void *data, size_t size) WGET_GCC_NONNULL_ALL; +WGETAPI void * NULLABLE + wget_list_prepend(wget_list **list, const void *data, size_t size) WGET_GCC_NONNULL_ALL; +WGETAPI void * NULLABLE + wget_list_getfirst(const wget_list *list) WGET_GCC_CONST; +WGETAPI void * NULLABLE + wget_list_getlast(const wget_list *list) WGET_GCC_PURE; +WGETAPI void * NULLABLE + wget_list_getnext(const void *elem) WGET_GCC_PURE; +WGETAPI void + wget_list_remove(wget_list **list, void *elem) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_list_free(wget_list **list) WGET_GCC_NONNULL_ALL; +WGETAPI int + wget_list_browse(const wget_list *list, wget_list_browse_fn *browse, void *context) WGET_GCC_NONNULL((2)); + +/** + * \ingroup libwget-xalloc + * + * Memory allocation function pointers + * @{ + */ + +// Don't leave freed pointers hanging around +#define wget_xfree(a) do { if (a) { wget_free((void *)(a)); a=NULL; } } while (0) + +/// Type of malloc() function +typedef void *wget_malloc_function(size_t); + +/// Type of calloc() function +typedef void *wget_calloc_function(size_t, size_t); + +/// Type of realloc() function +typedef void *wget_realloc_function(void *, size_t); + +/// Type of free() function +typedef void wget_free_function(void *); + +/* For use in callbacks */ +extern WGETAPI wget_malloc_function *wget_malloc_fn; +extern WGETAPI wget_calloc_function *wget_calloc_fn; +extern WGETAPI wget_realloc_function *wget_realloc_fn; +extern WGETAPI wget_free_function *wget_free; + +// we use (inline) functions here to apply function attributes +RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE(1) WGET_GCC_MALLOC +static inline void * NULLABLE wget_malloc(size_t size) +{ + return wget_malloc_fn(size); +} + +RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE2(1,2) WGET_GCC_MALLOC +static inline void * NULLABLE wget_calloc(size_t nmemb, size_t size) +{ + return wget_calloc_fn(nmemb, size); +} + +RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE(2) +static inline void * NULLABLE wget_realloc(void *ptr, size_t size) +{ + return wget_realloc_fn(ptr, size); +} + +/** @} */ + +/* + * String/Memory routines, slightly different than standard functions + */ + +LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE(2) +WGETAPI void * NULLABLE + wget_memdup(const void *m, size_t n); + +LIBWGET_WARN_UNUSED_RESULT WGET_GCC_MALLOC +WGETAPI char * NULLABLE + wget_strdup(const char *s); + +LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE(2) +WGETAPI char * NULLABLE + wget_strmemdup(const void *m, size_t n); + +WGETAPI size_t + wget_strmemcpy(char *__restrict s, size_t ssize, const void *__restrict m, size_t n); + +LIBWGET_WARN_UNUSED_RESULT WGET_GCC_NONNULL_ALL +WGETAPI void * NULLABLE + wget_strmemcpy_a(char *s, size_t ssize, const void *m, size_t n); + +/* + * Base64 routines + */ + +WGETAPI bool + wget_base64_is_string(const char *src) WGET_GCC_PURE; +WGETAPI size_t + wget_base64_get_decoded_length(size_t len) WGET_GCC_PURE; +WGETAPI size_t + wget_base64_get_encoded_length(size_t len) WGET_GCC_PURE; +WGETAPI size_t + wget_base64_decode(char *__restrict dst, const char *__restrict src, size_t n) WGET_GCC_NONNULL_ALL; +WGETAPI size_t + wget_base64_encode(char *__restrict dst, const char *__restrict src, size_t n) WGET_GCC_NONNULL_ALL; +WGETAPI size_t + wget_base64_urlencode(char *__restrict dst, const char *__restrict src, size_t n) WGET_GCC_NONNULL_ALL; +WGETAPI char * NULLABLE + wget_base64_decode_alloc(const char *src, size_t n, size_t *outlen) WGET_GCC_NONNULL((1)); +WGETAPI char * NULLABLE + wget_base64_encode_alloc(const char *src, size_t n) WGET_GCC_NONNULL_ALL; +WGETAPI char * NULLABLE + wget_base64_encode_vprintf_alloc(const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(1,0) WGET_GCC_NONNULL_ALL; +WGETAPI char * NULLABLE + wget_base64_encode_printf_alloc(const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(1,2) WGET_GCC_NONNULL_ALL; + +/* + * Bitmap routines + */ + +typedef struct wget_bitmap_st wget_bitmap; + +WGETAPI int + wget_bitmap_init(wget_bitmap **bitmap, unsigned bits); +WGETAPI void + wget_bitmap_free(wget_bitmap **bitmap); +WGETAPI void + wget_bitmap_set(wget_bitmap *bitmap, unsigned n); // n is the index +WGETAPI void + wget_bitmap_clear(wget_bitmap *bitmap, unsigned n); +WGETAPI bool + wget_bitmap_get(const wget_bitmap *bitmap, unsigned n); + +/* + * Buffer routines + */ + +typedef struct { + char * + data; //!< pointer to internal memory + size_t + length; //!< number of bytes in 'data' + size_t + size; //!< capacity of 'data' (terminating 0 byte doesn't count here) + bool + release_data : 1, //!< 'data' has been malloc'ed and must be freed + release_buf : 1, //!< wget_buffer structure has been malloc'ed and must be freed + error : 1; //!< a memory failure occurred, the result in 'data' is likely erroneous +} wget_buffer; + +WGETAPI int + wget_buffer_init(wget_buffer *buf, char *data, size_t size) WGET_GCC_NONNULL((1)); +WGETAPI wget_buffer * + wget_buffer_alloc(size_t size) WGET_GCC_MALLOC WGET_GCC_ALLOC_SIZE(1) RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT; +WGETAPI int + wget_buffer_ensure_capacity(wget_buffer *buf, size_t size) LIBWGET_WARN_UNUSED_RESULT; +WGETAPI void + wget_buffer_deinit(wget_buffer *buf) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_buffer_free(wget_buffer **buf); +WGETAPI void + wget_buffer_free_data(wget_buffer *buf); +WGETAPI void + wget_buffer_reset(wget_buffer *buf); +WGETAPI size_t + wget_buffer_memcpy(wget_buffer *buf, const void *data, size_t length); +WGETAPI size_t + wget_buffer_memcat(wget_buffer *buf, const void *data, size_t length); +WGETAPI size_t + wget_buffer_strcpy(wget_buffer *buf, const char *s); +WGETAPI size_t + wget_buffer_strcat(wget_buffer *buf, const char *s); +WGETAPI size_t + wget_buffer_bufcpy(wget_buffer *buf, wget_buffer *src); +WGETAPI size_t + wget_buffer_bufcat(wget_buffer *buf, wget_buffer *src); +WGETAPI size_t + wget_buffer_memset(wget_buffer *buf, char c, size_t length); +WGETAPI size_t + wget_buffer_memset_append(wget_buffer *buf, char c, size_t length); +WGETAPI char * + wget_buffer_trim(wget_buffer *buf); +WGETAPI size_t + wget_buffer_vprintf_append(wget_buffer *buf, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0); +WGETAPI size_t + wget_buffer_printf_append(wget_buffer *buf, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3); +WGETAPI size_t + wget_buffer_vprintf(wget_buffer *buf, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0); +WGETAPI size_t + wget_buffer_printf(wget_buffer *buf, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3); + +/* + * Printf-style routines + */ + +WGETAPI size_t + wget_vasprintf(char **__restrict strp, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0); +WGETAPI size_t + wget_asprintf(char **__restrict strp, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3); +WGETAPI char * NULLABLE + wget_vaprintf(const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(1,0); +WGETAPI char * NULLABLE + wget_aprintf(const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(1,2); +WGETAPI size_t + wget_vfprintf(FILE *__restrict fp, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0); +WGETAPI size_t + wget_fprintf(FILE *__restrict fp, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3); +WGETAPI size_t + wget_printf(const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(1,2); +WGETAPI size_t + wget_vsnprintf(char *__restrict str, size_t size, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(3,0); +WGETAPI size_t + wget_snprintf(char *__restrict str, size_t size, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(3,4); + +/* + * Logger routines + */ + +typedef struct wget_logger_st wget_logger; +typedef void wget_logger_func(const char *buf , size_t len) WGET_GCC_NONNULL_ALL; + +WGETAPI void + wget_logger_set_func(wget_logger *logger, wget_logger_func *func); +WGETAPI void + wget_logger_set_stream(wget_logger *logger, FILE *fp); +WGETAPI void + wget_logger_set_file(wget_logger *logger, const char *fname); +WGETAPI wget_logger_func * NULLABLE + wget_logger_get_func(wget_logger *logger) WGET_GCC_PURE; +WGETAPI FILE * NULLABLE + wget_logger_get_stream(wget_logger *logger) WGET_GCC_PURE; +WGETAPI const char * NULLABLE + wget_logger_get_file(wget_logger *logger) WGET_GCC_PURE; +WGETAPI bool + wget_logger_is_active(wget_logger *logger) WGET_GCC_PURE; + +/* + * Logging routines + */ + +#define WGET_LOGGER_INFO 1 +#define WGET_LOGGER_ERROR 2 +#define WGET_LOGGER_DEBUG 3 + +WGETAPI void + wget_info_vprintf(const char *__restrict fmt, va_list args) WGET_GCC_NONNULL_ALL WGET_GCC_PRINTF_FORMAT(1,0); +WGETAPI void + wget_info_printf(const char *__restrict fmt, ...) WGET_GCC_NONNULL((1)) WGET_GCC_PRINTF_FORMAT(1,2); +WGETAPI void + wget_error_vprintf(const char *__restrict fmt, va_list args) WGET_GCC_NONNULL_ALL WGET_GCC_PRINTF_FORMAT(1,0); +WGETAPI void + wget_error_printf(const char *__restrict fmt, ...) WGET_GCC_NONNULL((1)) WGET_GCC_PRINTF_FORMAT(1,2); +WGETAPI void WGET_GCC_NONNULL((1)) WGET_GCC_NORETURN WGET_GCC_PRINTF_FORMAT(1,2) + wget_error_printf_exit(const char *__restrict fmt, ...); +WGETAPI void + wget_debug_vprintf(const char *__restrict fmt, va_list args) WGET_GCC_NONNULL_ALL WGET_GCC_PRINTF_FORMAT(1,0); +WGETAPI void + wget_debug_printf(const char *__restrict fmt, ...) WGET_GCC_NONNULL((1)) WGET_GCC_PRINTF_FORMAT(1,2); +WGETAPI void + wget_debug_write(const char *buf, size_t len) WGET_GCC_NONNULL_ALL; +WGETAPI wget_logger * + wget_get_logger(int id) WGET_GCC_CONST; + +/* + * Vector datatype routines + */ + +typedef struct wget_vector_st wget_vector; +typedef int wget_vector_compare_fn(const void *elem1, const void *elem2); +typedef int wget_vector_find_fn(void *elem); +typedef int wget_vector_browse_fn(void *ctx, void *elem); +typedef void wget_vector_destructor(void *elem); + +WGETAPI wget_vector * NULLABLE + wget_vector_create(int max, wget_vector_compare_fn *cmp) WGET_GCC_MALLOC; +WGETAPI void + wget_vector_set_resize_factor(wget_vector *v, float off); +WGETAPI int + wget_vector_find(const wget_vector *v, const void *elem) WGET_GCC_NONNULL((2)); +WGETAPI int + wget_vector_findext(const wget_vector *v, int start, int direction, wget_vector_find_fn *find) WGET_GCC_NONNULL((4)); +WGETAPI bool + wget_vector_contains(const wget_vector *v, const void *elem) WGET_GCC_NONNULL((2)); +WGETAPI int + wget_vector_insert(wget_vector *v, const void *elem, int pos) WGET_GCC_NONNULL((2)); +WGETAPI int + wget_vector_insert_sorted(wget_vector *v, const void *elem) WGET_GCC_NONNULL((2)); +WGETAPI int + wget_vector_add_memdup(wget_vector *v, const void *elem, size_t size) WGET_GCC_NONNULL((2)); +WGETAPI int + wget_vector_add(wget_vector *v, const void *elem) WGET_GCC_NONNULL((2)); +WGETAPI int + wget_vector_add_vprintf(wget_vector *v, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0); +WGETAPI int + wget_vector_add_printf(wget_vector *v, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3); +WGETAPI int + wget_vector_replace(wget_vector *v, const void *elem, int pos) WGET_GCC_NONNULL((2)); +WGETAPI int + wget_vector_move(wget_vector *v, int old_pos, int new_pos); +WGETAPI int + wget_vector_swap(wget_vector *v, int pos1, int pos2); +WGETAPI int + wget_vector_remove(wget_vector *v, int pos); +WGETAPI int + wget_vector_remove_nofree(wget_vector *v, int pos); +WGETAPI int + wget_vector_size(const wget_vector *v) WGET_GCC_PURE; +WGETAPI int + wget_vector_browse(const wget_vector *v, wget_vector_browse_fn *browse, void *ctx) WGET_GCC_NONNULL((2)); +WGETAPI void + wget_vector_free(wget_vector **v); +WGETAPI void + wget_vector_clear(wget_vector *v); +WGETAPI void + wget_vector_clear_nofree(wget_vector *v); +WGETAPI void * NULLABLE + wget_vector_get(const wget_vector *v, int pos) WGET_GCC_PURE; +WGETAPI void + wget_vector_setcmpfunc(wget_vector *v, wget_vector_compare_fn *cmp) WGET_GCC_NONNULL((2)); +WGETAPI void + wget_vector_set_destructor(wget_vector *v, wget_vector_destructor *destructor); +WGETAPI void + wget_vector_sort(wget_vector *v); + +/** + * \ingroup libwget-hashmap + * + * @{ + */ + +/// Type of the hashmap +typedef struct wget_hashmap_st wget_hashmap; + +/// Type of the hashmap compare function +typedef int wget_hashmap_compare_fn(const void *key1, const void *key2); + +/// Type of the hashmap hash function +typedef unsigned int wget_hashmap_hash_fn(const void *key); + +/// Type of the hashmap browse callback function +typedef int wget_hashmap_browse_fn(void *ctx, const void *key, void *value); + +/// Type of the hashmap key destructor function +typedef void wget_hashmap_key_destructor(void *key); + +/// Type of the hashmap value destructor function +typedef void wget_hashmap_value_destructor(void *value); +/** @} */ + +WGETAPI wget_hashmap * NULLABLE + wget_hashmap_create(int max, wget_hashmap_hash_fn *hash, wget_hashmap_compare_fn *cmp) WGET_GCC_MALLOC; +WGETAPI void + wget_hashmap_set_resize_factor(wget_hashmap *h, float factor); +WGETAPI int + wget_hashmap_put(wget_hashmap *h, const void *key, const void *value); +WGETAPI int + wget_hashmap_size(const wget_hashmap *h) WGET_GCC_PURE; +WGETAPI int + wget_hashmap_browse(const wget_hashmap *h, wget_hashmap_browse_fn *browse, void *ctx); +WGETAPI void + wget_hashmap_free(wget_hashmap **h); +WGETAPI void + wget_hashmap_clear(wget_hashmap *h); +WGETAPI int + wget_hashmap_get(const wget_hashmap *h, const void *key, void **value) WGET_GCC_UNUSED_RESULT; +#define wget_hashmap_get(a, b, c) wget_hashmap_get((a), (b), (void **)(c)) +WGETAPI int + wget_hashmap_contains(const wget_hashmap *h, const void *key); +WGETAPI int + wget_hashmap_remove(wget_hashmap *h, const void *key); +WGETAPI int + wget_hashmap_remove_nofree(wget_hashmap *h, const void *key); +WGETAPI void + wget_hashmap_setcmpfunc(wget_hashmap *h, wget_hashmap_compare_fn *cmp); +WGETAPI int + wget_hashmap_sethashfunc(wget_hashmap *h, wget_hashmap_hash_fn *hash); +WGETAPI void + wget_hashmap_set_key_destructor(wget_hashmap *h, wget_hashmap_key_destructor *destructor); +WGETAPI void + wget_hashmap_set_value_destructor(wget_hashmap *h, wget_hashmap_value_destructor *destructor); +WGETAPI void + wget_hashmap_set_load_factor(wget_hashmap *h, float factor); + +/// Type of the hashmap iterator +typedef struct wget_hashmap_iterator_st wget_hashmap_iterator; + +WGETAPI wget_hashmap_iterator * NULLABLE + wget_hashmap_iterator_alloc(wget_hashmap *h) WGET_GCC_MALLOC; +WGETAPI void + wget_hashmap_iterator_free(wget_hashmap_iterator **iter); +WGETAPI void * NULLABLE + wget_hashmap_iterator_next(wget_hashmap_iterator *iter, void **value); + +/** + * \ingroup libwget-stringmap + * + * @{ + */ + +/// Type of the stringmap +typedef wget_hashmap wget_stringmap; + +/// Type of the stringmap compare function +typedef int wget_stringmap_compare_fn(const char *key1, const char *key2); + +/// Type of the stringmap hash function +typedef unsigned int wget_stringmap_hash_fn(const char *key); + +/// Type of the stringmap browse callback function +typedef int wget_stringmap_browse_fn(void *ctx, const char *key, void *value); + +/// Type of the stringmap key destructor function +typedef void wget_stringmap_key_destructor(char *key); + +/// Type of the stringmap value destructor function +typedef void wget_stringmap_value_destructor(void *value); + +/// Type of the stringmap iterator +typedef wget_hashmap_iterator wget_stringmap_iterator; + +/// Wrapper around wget_hashmap_iterator_alloc(). +#define wget_stringmap_iterator_alloc wget_hashmap_iterator_alloc +/// Wrapper around wget_hashmap_iterator_free(). +#define wget_stringmap_iterator_free wget_hashmap_iterator_free + +WGETAPI wget_stringmap * NULLABLE + wget_stringmap_create(int max) WGET_GCC_MALLOC; +WGETAPI wget_stringmap * NULLABLE + wget_stringmap_create_nocase(int max) WGET_GCC_MALLOC; +/** @} */ + +/** + * \ingroup libwget-stringmap + * + * @{ + */ + +/** + * \param[in] h Stringmap to put data into + * \param[in] key Key to insert into \p h + * \param[in] value Value to insert into \p h + * \return 0 if inserted a new entry, 1 if entry existed + * + * Insert a key/value pair into stringmap \p h. + * + * \p key and \p value are *not* cloned, the stringmap takes 'ownership' of both. + * + * If \p key already exists and the pointer values the old and the new key differ, + * the old key will be destroyed by calling the key destructor function (default is free()). + * + * To realize a hashset (just keys without values), \p value may be %NULL. + * + * Neither \p h nor \p key must be %NULL. + */ +static inline +int wget_stringmap_put(wget_stringmap *h, const char *key, const void *value) +{ + return wget_hashmap_put(h, key, value); +} + +/** + * \param[in] h Stringmap + * \param[in] key Key to search for + * \param[out] value Value to be returned + * \return 1 if \p key has been found, 0 if not found + * + * Get the value for a given key. + * + * Neither \p h nor \p key must be %NULL. + */ +static inline WGET_GCC_UNUSED_RESULT +int wget_stringmap_get(const wget_stringmap *h, const char *key, void **value) +{ + return wget_hashmap_get(h, key, value); +} +#define wget_stringmap_get(h, k, v) wget_stringmap_get((h), (k), (void **)(v)) + +/** + * \param[in] h Stringmap + * \param[in] key Key to search for + * \return 1 if \p key has been found, 0 if not found + * + * Check if \p key exists in \p h. + */ +static inline +int wget_stringmap_contains(const wget_stringmap *h, const char *key) +{ + return wget_hashmap_contains(h, key); +} + +/** + * \param[in] h Stringmap + * \param[in] key Key to be removed + * \return 1 if \p key has been removed, 0 if not found + * + * Remove \p key from stringmap \p h. + * + * If \p key is found, the key and value destructor functions are called + * when removing the entry from the stringmap. + */ +static inline +int wget_stringmap_remove(wget_stringmap *h, const char *key) +{ + return wget_hashmap_remove(h, key); +} + +/** + * \param[in] h Stringmap + * \param[in] key Key to be removed + * \return 1 if \p key has been removed, 0 if not found + * + * Remove \p key from stringmap \p h. + * + * Key and value destructor functions are *not* called when removing the entry from the stringmap. + */ +static inline +int wget_stringmap_remove_nofree(wget_stringmap *h, const char *key) +{ + return wget_hashmap_remove_nofree(h, key); +} + +/** + * \param[in] h Stringmap to be free'd + * + * Remove all entries from stringmap \p h and free the stringmap instance. + * + * Key and value destructor functions are called for each entry in the stringmap. + */ +static inline +void wget_stringmap_free(wget_stringmap **h) +{ + wget_hashmap_free(h); +} + +/** + * \param[in] h Stringmap to be cleared + * + * Remove all entries from stringmap \p h. + * + * Key and value destructor functions are called for each entry in the stringmap. + */ +static inline +void wget_stringmap_clear(wget_stringmap *h) +{ + wget_hashmap_clear(h); +} + +/** + * \param[in] h Stringmap + * \return Number of entries in stringmap \p h + * + * Return the number of entries in the stringmap \p h. + */ +static inline +int wget_stringmap_size(const wget_stringmap *h) +{ + return wget_hashmap_size(h); +} + +/** + * \param[in] h Stringmap + * \param[in] browse Function to be called for each element of \p h + * \param[in] ctx Context variable use as param to \p browse + * \return Return value of the last call to \p browse + * + * Call function \p browse for each element of stringmap \p h or until \p browse + * returns a value not equal to zero. + * + * \p browse is called with \p ctx and the pointer to the current element. + * + * The return value of the last call to \p browse is returned or 0 if either \p h or \p browse is %NULL. + */ +static inline +int wget_stringmap_browse(const wget_stringmap *h, wget_stringmap_browse_fn *browse, void *ctx) +{ + return wget_hashmap_browse(h, (wget_hashmap_browse_fn *) browse, ctx); +} + +/** + * \param[in] h Stringmap + * \param[in] cmp Comparison function used to find keys + * + * Set the comparison function. + */ +static inline +void wget_stringmap_setcmpfunc(wget_stringmap *h, wget_stringmap_compare_fn *cmp) +{ + wget_hashmap_setcmpfunc(h, (wget_hashmap_compare_fn *) cmp); +} + +/** + * \param[in] h Stringmap + * \param[in] hash Hash function used to hash keys + * + * Set the key hash function. + * + * The keys of all entries in the stringmap will be hashed again. + */ +static inline +int wget_stringmap_sethashfunc(wget_stringmap *h, wget_stringmap_hash_fn *hash) +{ + return wget_hashmap_sethashfunc(h, (wget_hashmap_hash_fn *) hash); +} + +/** + * \param[in] h Stringmap + * \param[in] destructor Destructor function for keys + * + * Set the key destructor function. + * + * Default is free(). + */ +static inline +void wget_stringmap_set_key_destructor(wget_hashmap *h, wget_stringmap_key_destructor *destructor) +{ + wget_hashmap_set_key_destructor(h, (wget_hashmap_key_destructor *) destructor); +} + +/** + * \param[in] h Stringmap + * \param[in] destructor Destructor function for values + * + * Set the value destructor function. + * + * Default is free(). + */ +static inline +void wget_stringmap_set_value_destructor(wget_hashmap *h, wget_stringmap_value_destructor *destructor) +{ + wget_hashmap_set_value_destructor(h, (wget_hashmap_value_destructor *) destructor); +} + +/** + * \param[in] h Stringmap + * \param[in] factor The load factor + * + * Set the load factor function. + * + * The load factor is determines when to resize the internal memory. + * 0.75 means "resize if 75% or more of all slots are used". + * + * The resize strategy is set by wget_stringmap_set_growth_policy(). + * + * The resize (and rehashing) occurs earliest on the next insertion of a new key. + * + * Default is 0.75. + */ +static inline +void wget_stringmap_set_load_factor(wget_stringmap *h, float factor) +{ + wget_hashmap_set_load_factor(h, factor); +} + +/** + * \param[in] h Stringmap + * \param[in] off Stringmap growth factor + * + * Set the factor for resizing the stringmap when it's load factor is reached. + * + * The new size is 'factor * oldsize'. If the new size is less or equal 0, + * the involved put function will do nothing and the internal state of + * the stringmap will not change. + * + * Default is 2. + */ +static inline +void wget_stringmap_set_resize_factor(wget_stringmap *h, float factor) +{ + wget_hashmap_set_resize_factor(h, factor); +} + +/** + * \param[in] iter Stringmap iterator + * \param[out] value Pointer to the value belonging to the returned key + * \return Pointer to the key or NULL if no more elements left + * + * Returns the next key / value in the stringmap. If all key/value pairs have been + * iterated over the function returns NULL and \p value is untouched. + * + * When iterating over a stringmap, the order of returned key/value pairs is not defined. + */ +static inline +void * NULLABLE wget_stringmap_iterator_next(wget_stringmap_iterator *h, void **value) +{ + return wget_hashmap_iterator_next(h, (void **) value); +} + +/** @} */ + +/* + * Thread wrapper routines + */ + +typedef unsigned long wget_thread_id; +typedef struct wget_thread_st *wget_thread; +typedef struct wget_thread_mutex_st *wget_thread_mutex; +typedef struct wget_thread_cond_st *wget_thread_cond; + +WGETAPI int + wget_thread_start(wget_thread *thread, void *(*start_routine)(void *), void *arg, int flags); +WGETAPI int + wget_thread_mutex_init(wget_thread_mutex *mutex); +WGETAPI int + wget_thread_mutex_destroy(wget_thread_mutex *mutex); +WGETAPI void + wget_thread_mutex_lock(wget_thread_mutex mutex); +WGETAPI void + wget_thread_mutex_unlock(wget_thread_mutex mutex); +WGETAPI int + wget_thread_kill(wget_thread thread, int sig); +WGETAPI int + wget_thread_cancel(wget_thread thread); +WGETAPI int + wget_thread_join(wget_thread *thread); +WGETAPI int + wget_thread_cond_init(wget_thread_cond *cond); +WGETAPI int + wget_thread_cond_destroy(wget_thread_cond *cond); +WGETAPI int + wget_thread_cond_signal(wget_thread_cond cond); +WGETAPI int + wget_thread_cond_wait(wget_thread_cond cond, wget_thread_mutex mutex, long long ms); +WGETAPI wget_thread_id + wget_thread_self(void) WGET_GCC_CONST; +WGETAPI bool + wget_thread_support(void) WGET_GCC_CONST; + +/* + * Decompressor routines + */ + +typedef struct wget_decompressor_st wget_decompressor; +typedef int wget_decompressor_sink_fn(void *context, const char *data, size_t length); +typedef int wget_decompressor_error_handler(wget_decompressor *dc, int err); + +typedef enum { + wget_content_encoding_unknown = -1, + wget_content_encoding_identity = 0, + wget_content_encoding_gzip = 1, + wget_content_encoding_deflate = 2, + wget_content_encoding_xz = 3, + wget_content_encoding_lzma = 4, + wget_content_encoding_bzip2 = 5, + wget_content_encoding_brotli = 6, + wget_content_encoding_zstd = 7, + wget_content_encoding_lzip = 8, + wget_content_encoding_max = 9 +} wget_content_encoding; + +WGETAPI WGET_GCC_PURE wget_content_encoding + wget_content_encoding_by_name(const char *name); +WGETAPI WGET_GCC_PURE const char * NULLABLE + wget_content_encoding_to_name(wget_content_encoding type); +WGETAPI wget_decompressor * NULLABLE + wget_decompress_open(wget_content_encoding encoding, wget_decompressor_sink_fn *data_sink, void *context); +WGETAPI void + wget_decompress_close(wget_decompressor *dc); +WGETAPI int + wget_decompress(wget_decompressor *dc, const char *src, size_t srclen); +WGETAPI void + wget_decompress_set_error_handler(wget_decompressor *dc, wget_decompressor_error_handler *error_handler); +WGETAPI void * NULLABLE + wget_decompress_get_context(wget_decompressor *dc); + +/* + * URI/IRI routines + */ + +typedef enum { + WGET_IRI_SCHEME_HTTP = 0, + WGET_IRI_SCHEME_HTTPS = 1 +} wget_iri_scheme; + +// flags for wget_iri_get_basename() +#define WGET_IRI_WITH_QUERY 1 + +/** + * \ingroup libwget-iri + * + * @{ + * + * Internal representation of a URI/IRI. + */ +struct wget_iri_st { + /** + * Pointer to the original URI string, unescaped and converted to UTF-8. + */ + const char * + uri; + + /** + * Pointer to the URI which does not contain credentials. + */ + const char * + safe_uri; + /** + * Display part, if present. + */ + const char * + display; + /** + * Username, if present. + */ + const char * + userinfo; + /** + * Password, if present. + */ + const char * + password; + /** + * Hostname (or literal IP address). Lowercase and unescaped. + */ + const char * + host; + /** + * Path, if present. Unescaped. + */ + const char * + path; + /** + * Query part, if present. Unescaped. + */ + const char * + query; + /** + * Fragment part, if present. Unescaped. + */ + const char * + fragment; + /** + * Connection part. This is not specified by the spec, it's just a helper. + * + * The connection part is formed by the scheme, the hostname and the port together. Example: + * + * https://www.example.com:8080 + * + */ + const char * + connection_part; + /** + * Length of the directory part in `path`. + * + * This is the length from the beginning up to the last slash (`/`). + */ + size_t + dirlen; + /// size of memory to hold the parsed URI, it contains 0 bytes + size_t + msize; + /// Port number + uint16_t + port; + /// URI/IRI scheme (`http` or `https`). + wget_iri_scheme + scheme; + /// If set, port was explicitly given + bool + port_given : 1; + /// If set, free uri in iri_free() + bool + uri_allocated : 1; + /// If set, free host in iri_free() + bool + host_allocated : 1; + /// If set, free path in iri_free() + bool + path_allocated : 1; + /// If set, free query in iri_free() + bool + query_allocated : 1; + /// If set, free fragment in iri_free() + bool + fragment_allocated : 1; + /// If set, the hostname part is a literal IPv4/IPv6 address + bool + is_ip_address : 1; +}; + +typedef struct wget_iri_st wget_iri; +/** @} */ + +WGETAPI void + wget_iri_test(void); +WGETAPI void + wget_iri_free(wget_iri **iri); +WGETAPI void + wget_iri_free_content(wget_iri *iri); +WGETAPI void + wget_iri_set_defaultpage(const char *page); +WGETAPI int + wget_iri_set_defaultport(wget_iri_scheme scheme, unsigned short port); +WGETAPI bool + wget_iri_supported(const wget_iri *iri) WGET_GCC_PURE WGET_GCC_NONNULL_ALL; +WGETAPI bool + wget_iri_isgendelim(char c) WGET_GCC_CONST; +WGETAPI bool + wget_iri_issubdelim(char c) WGET_GCC_CONST; +WGETAPI bool + wget_iri_isreserved(char c) WGET_GCC_CONST; +WGETAPI bool + wget_iri_isunreserved(char c) WGET_GCC_CONST; +WGETAPI int + wget_iri_compare(const wget_iri *iri1, const wget_iri *iri2) WGET_GCC_PURE; +WGETAPI char * + wget_iri_unescape_inline(char *src) WGET_GCC_NONNULL_ALL; +WGETAPI char * + wget_iri_unescape_url_inline(char *src) WGET_GCC_NONNULL_ALL; +WGETAPI wget_iri * + wget_iri_parse(const char *uri, const char *encoding); +WGETAPI wget_iri * NULLABLE + wget_iri_parse_base(const wget_iri *base, const char *url, const char *encoding); +WGETAPI wget_iri * NULLABLE + wget_iri_clone(const wget_iri *iri); +WGETAPI const char * NULLABLE + wget_iri_get_connection_part(const wget_iri *iri, wget_buffer *buf); +WGETAPI const char * + wget_iri_relative_to_abs(const wget_iri *base, const char *val, size_t len, wget_buffer *buf); +WGETAPI const char * + wget_iri_escape(const char *src, wget_buffer *buf); +WGETAPI const char * + wget_iri_escape_path(const char *src, wget_buffer *buf) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_iri_escape_query(const char *src, wget_buffer *buf) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_iri_get_escaped_host(const wget_iri *iri, wget_buffer *buf) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_iri_get_escaped_resource(const wget_iri *iri, wget_buffer *buf) WGET_GCC_NONNULL_ALL; +WGETAPI char * + wget_iri_get_path(const wget_iri *iri, wget_buffer *buf, const char *encoding) WGET_GCC_NONNULL((1,2)); +WGETAPI char * + wget_iri_get_query_as_filename(const wget_iri *iri, wget_buffer *buf, const char *encoding) WGET_GCC_NONNULL((1,2)); +WGETAPI char * + wget_iri_get_basename(const wget_iri *iri, wget_buffer *buf, const char *encoding, int flags) WGET_GCC_NONNULL((1,2)); +WGETAPI wget_iri_scheme + wget_iri_set_scheme(wget_iri *iri, wget_iri_scheme scheme); +WGETAPI const char * NULLABLE + wget_iri_scheme_get_name(wget_iri_scheme scheme); + +/* + * Cookie routines + */ + +// typedef for cookie database +typedef struct wget_cookie_db_st wget_cookie_db; + +// typedef for cookie +typedef struct wget_cookie_st wget_cookie; + +WGETAPI wget_cookie * NULLABLE + wget_cookie_init(wget_cookie *cookie); +WGETAPI void + wget_cookie_deinit(wget_cookie *cookie); +WGETAPI void + wget_cookie_free(wget_cookie **cookie); +WGETAPI char * + wget_cookie_to_setcookie(wget_cookie *cookie); +WGETAPI const char * + wget_cookie_parse_setcookie(const char *s, wget_cookie **cookie) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_cookie_normalize_cookies(const wget_iri *iri, const wget_vector *cookies); +WGETAPI int + wget_cookie_store_cookie(wget_cookie_db *cookie_db, wget_cookie *cookie); +WGETAPI void + wget_cookie_store_cookies(wget_cookie_db *cookie_db, wget_vector *cookies); +WGETAPI int + wget_cookie_normalize(const wget_iri *iri, wget_cookie *cookie); +WGETAPI int + wget_cookie_check_psl(const wget_cookie_db *cookie_db, const wget_cookie *cookie); +WGETAPI wget_cookie_db * NULLABLE + wget_cookie_db_init(wget_cookie_db *cookie_db); +WGETAPI void + wget_cookie_db_deinit(wget_cookie_db *cookie_db); +WGETAPI void + wget_cookie_db_free(wget_cookie_db **cookie_db); +WGETAPI void + wget_cookie_set_keep_session_cookies(wget_cookie_db *cookie_db, bool keep); +WGETAPI int + wget_cookie_db_save(wget_cookie_db *cookie_db, const char *fname); +WGETAPI int + wget_cookie_db_load(wget_cookie_db *cookie_db, const char *fname); +WGETAPI int + wget_cookie_db_load_psl(wget_cookie_db *cookie_db, const char *fname); +WGETAPI char * + wget_cookie_create_request_header(wget_cookie_db *cookie_db, const wget_iri *iri); + +/* + * HTTP Strict Transport Security (HSTS) routines + */ + +/** + * \ingroup libwget-hsts + * + * Structure representing HSTS database for storing HTTP Strict Transport Security (HSTS) entries + */ +typedef struct wget_hsts_db_st wget_hsts_db; + +/** + * \ingroup libwget-hsts + * + * It is possible to implement a custom HSTS database as a plugin. + * See tests/test-plugin-dummy.c and tests/Makefile.am for details. + */ + +typedef int wget_hsts_host_match_fn(const wget_hsts_db *hsts_db, const char *host, uint16_t port); +typedef wget_hsts_db *wget_hsts_db_init_fn(wget_hsts_db *hsts_db, const char *fname); +typedef void wget_hsts_db_deinit_fn(wget_hsts_db *hsts_db); +typedef void wget_hsts_db_free_fn(wget_hsts_db **hsts_db); +typedef void wget_hsts_db_add_fn(wget_hsts_db *hsts_db, const char *host, uint16_t port, int64_t maxage, bool include_subdomains); +typedef int wget_hsts_db_save_fn(wget_hsts_db *hsts_db); +typedef int wget_hsts_db_load_fn(wget_hsts_db *hsts_db); +typedef void wget_hsts_db_set_fname_fn(wget_hsts_db *hsts_db, const char *fname); + +typedef struct { + /// Callback replacing wget_hsts_host_match() + wget_hsts_host_match_fn *host_match; + /// Callback replacing wget_hsts_db_init() + wget_hsts_db_init_fn *init; + /// Callback replacing wget_hsts_db_deinit() + wget_hsts_db_deinit_fn *deinit; + /// Callback replacing wget_hsts_db_free() + wget_hsts_db_free_fn *free; + /// Callback replacing wget_hsts_db_add() + wget_hsts_db_add_fn *add; + /// Callback replacing wget_hsts_db_load() + wget_hsts_db_load_fn *load; + /// Callback replacing wget_hsts_db_save() + wget_hsts_db_save_fn *save; +} wget_hsts_db_vtable; + +WGETAPI wget_hsts_host_match_fn wget_hsts_host_match; +WGETAPI wget_hsts_db_init_fn wget_hsts_db_init; +WGETAPI wget_hsts_db_deinit_fn wget_hsts_db_deinit; +WGETAPI wget_hsts_db_free_fn wget_hsts_db_free; +WGETAPI wget_hsts_db_add_fn wget_hsts_db_add; +WGETAPI wget_hsts_db_load_fn wget_hsts_db_load; +WGETAPI wget_hsts_db_save_fn wget_hsts_db_save; +WGETAPI void + wget_hsts_db_set_fname(wget_hsts_db *hsts_db, const char *fname); +WGETAPI void + wget_hsts_set_plugin(const wget_hsts_db_vtable *vtable); + +/* + * HTTP Public Key Pinning (HPKP) + */ + +/** + * \ingroup libwget-hpkp + * + * HPKP database for storing HTTP Public Key Pinning (HPKP) entries + */ +typedef struct wget_hpkp_db_st wget_hpkp_db; + +/** + * \ingroup libwget-hpkp + * + * HPKP database entry. Corresponds to one 'Public-Key-Pins' HTTP response header. + */ +typedef struct wget_hpkp_st wget_hpkp; + +/* FIXME: the following entries are not used. review the hpkp function return values ! */ +/** + * \addtogroup libwget-hpkp + * + * @{ + */ +/// Success +#define WGET_HPKP_OK 0 +/// General error +#define WGET_HPKP_ERROR -1 +/// The HPKP entry is expired +#define WGET_HPKP_ENTRY_EXPIRED -2 +/// The HPKP entry was deleted +#define WGET_HPKP_WAS_DELETED -3 +/// The entry doesn't have enough PINs +#define WGET_HPKP_NOT_ENOUGH_PINS -4 +/// The entry already exists +#define WGET_HPKP_ENTRY_EXISTS -5 +/// Failed to open a file +#define WGET_HPKP_ERROR_FILE_OPEN -6 +/** @} */ + +/** + * \ingroup libwget-hpkp + * + * It is possible to implement a custom HPKP database as a plugin. + * See tests/test-plugin-dummy.c and tests/Makefile.am for details. + */ + +typedef wget_hpkp_db *wget_hpkp_db_init_fn(wget_hpkp_db *hpkp_db, const char *fname); +typedef void wget_hpkp_db_deinit_fn(wget_hpkp_db *hpkp_db); +typedef void wget_hpkp_db_free_fn(wget_hpkp_db **hpkp_db); +typedef int wget_hpkp_db_check_pubkey_fn(wget_hpkp_db *hpkp_db, const char *host, const void *pubkey, size_t pubkeysize); +typedef void wget_hpkp_db_add_fn(wget_hpkp_db *hpkp_db, wget_hpkp **hpkp); +typedef int wget_hpkp_db_load_fn(wget_hpkp_db *hpkp_db); +typedef int wget_hpkp_db_save_fn(wget_hpkp_db *hpkp_db); + +typedef struct { + /// Callback replacing \ref wget_hpkp_db_free "wget_hpkp_db_free()" + wget_hpkp_db_init_fn *init; + /// Callback replacing \ref wget_hpkp_db_free "wget_hpkp_db_free()" + wget_hpkp_db_deinit_fn *deinit; + /// Callback replacing \ref wget_hpkp_db_free "wget_hpkp_db_free()" + wget_hpkp_db_free_fn *free; + /// Callback replacing \ref wget_hpkp_db_check_pubkey "wget_hpkp_db_check_pubkey()" + wget_hpkp_db_check_pubkey_fn *check_pubkey; + /// Callback replacing \ref wget_hpkp_db_add "wget_hpkp_db_add()" + wget_hpkp_db_add_fn *add; + /// Callback replacing \ref wget_hpkp_db_load "wget_hpkp_db_load()" + wget_hpkp_db_load_fn *load; + /// Callback replacing \ref wget_hpkp_db_save "wget_hpkp_db_save()" + wget_hpkp_db_save_fn *save; +} wget_hpkp_db_vtable; + +WGETAPI wget_hpkp * NULLABLE + wget_hpkp_new(void); +WGETAPI void + wget_hpkp_free(wget_hpkp *hpkp); +WGETAPI void + wget_hpkp_pin_add(wget_hpkp *hpkp, const char *pin_type, const char *pin_b64); +WGETAPI void + wget_hpkp_set_host(wget_hpkp *hpkp, const char *host); +WGETAPI void + wget_hpkp_set_maxage(wget_hpkp *hpkp, int64_t maxage); +WGETAPI void + wget_hpkp_set_include_subdomains(wget_hpkp *hpkp, bool include_subdomains); +WGETAPI int + wget_hpkp_get_n_pins(wget_hpkp *hpkp); +WGETAPI void + wget_hpkp_get_pins_b64(wget_hpkp *hpkp, const char **pin_types, const char **pins_b64); +WGETAPI void + wget_hpkp_get_pins(wget_hpkp *hpkp, const char **pin_types, size_t *sizes, const void **pins); +WGETAPI const char * + wget_hpkp_get_host(wget_hpkp *hpkp); +WGETAPI int64_t + wget_hpkp_get_maxage(wget_hpkp *hpkp); +WGETAPI bool + wget_hpkp_get_include_subdomains(wget_hpkp *hpkp); + +WGETAPI wget_hpkp_db_init_fn wget_hpkp_db_init; +WGETAPI wget_hpkp_db_deinit_fn wget_hpkp_db_deinit; +WGETAPI wget_hpkp_db_free_fn wget_hpkp_db_free; +WGETAPI wget_hpkp_db_check_pubkey_fn wget_hpkp_db_check_pubkey; +WGETAPI wget_hpkp_db_add_fn wget_hpkp_db_add; +WGETAPI wget_hpkp_db_load_fn wget_hpkp_db_load; +WGETAPI wget_hpkp_db_save_fn wget_hpkp_db_save; +WGETAPI void + wget_hpkp_db_set_fname(wget_hpkp_db *hpkp_db, const char *fname); +WGETAPI void + wget_hpkp_set_plugin(const wget_hpkp_db_vtable *vtable); + +/* + * TLS session resumption + */ + +// structure for TLS resumption cache entries +typedef struct wget_tls_session_st wget_tls_session; +typedef struct wget_tls_session_db_st wget_tls_session_db; + +WGETAPI wget_tls_session * NULLABLE + wget_tls_session_init(wget_tls_session *tls_session); +WGETAPI void + wget_tls_session_deinit(wget_tls_session *tls_session); +WGETAPI void + wget_tls_session_free(wget_tls_session *tls_session); +WGETAPI wget_tls_session * NULLABLE + wget_tls_session_new(const char *host, int64_t maxage, const void *data, size_t data_size); +WGETAPI int + wget_tls_session_get(const wget_tls_session_db *tls_session_db, const char *host, void **data, size_t *size); +WGETAPI wget_tls_session_db * NULLABLE + wget_tls_session_db_init(wget_tls_session_db *tls_session_db); +WGETAPI void + wget_tls_session_db_deinit(wget_tls_session_db *tls_session_db); +WGETAPI void + wget_tls_session_db_free(wget_tls_session_db **tls_session_db); +WGETAPI void + wget_tls_session_db_add(wget_tls_session_db *tls_session_db, wget_tls_session *tls_session); +WGETAPI int + wget_tls_session_db_save(wget_tls_session_db *tls_session_db, const char *fname); +WGETAPI int + wget_tls_session_db_load(wget_tls_session_db *tls_session_db, const char *fname); +WGETAPI int + wget_tls_session_db_changed(wget_tls_session_db *tls_session_db) WGET_GCC_PURE; + +/* + * Online Certificate Status Protocol (OCSP) routines + */ + +/** + * \ingroup libwget-ocsp + * + * structure for Online Certificate Status Protocol (OCSP) entries + */ +typedef struct wget_ocsp_db_st wget_ocsp_db; + +/** + * \ingroup libwget-ocsp + * + * It is possible to implement a custom OCSP database as a plugin. + * See tests/test-plugin-dummy.c and tests/Makefile.am for details. + */ + +typedef wget_ocsp_db *wget_ocsp_db_init_fn(wget_ocsp_db *ocsp_db, const char *fname); +typedef void wget_ocsp_db_deinit_fn(wget_ocsp_db *ocsp_db); +typedef void wget_ocsp_db_free_fn(wget_ocsp_db **ocsp_db); +typedef bool wget_ocsp_fingerprint_in_cache_fn(const wget_ocsp_db *ocsp_db, const char *fingerprint, int *valid); +typedef bool wget_ocsp_hostname_is_valid_fn(const wget_ocsp_db *ocsp_db, const char *hostname); +typedef void wget_ocsp_db_add_fingerprint_fn(wget_ocsp_db *ocsp_db, const char *fingerprint, int64_t maxage, bool valid); +typedef void wget_ocsp_db_add_host_fn(wget_ocsp_db *ocsp_db, const char *host, int64_t maxage); +typedef int wget_ocsp_db_save_fn(wget_ocsp_db *ocsp_db); +typedef int wget_ocsp_db_load_fn(wget_ocsp_db *ocsp_db); + +typedef struct { + /// Callback replacing wget_ocsp_db_free() + wget_ocsp_db_init_fn *init; + /// Callback replacing wget_ocsp_db_free() + wget_ocsp_db_deinit_fn *deinit; + /// Callback replacing wget_ocsp_db_free() + wget_ocsp_db_free_fn *free; + /// Callback replacing wget_ocsp_db_fingerprint_in_cache() + wget_ocsp_fingerprint_in_cache_fn *fingerprint_in_cache; + /// Callback replacing wget_ocsp_db_hostname_is_valid() + wget_ocsp_hostname_is_valid_fn *hostname_is_valid; + /// Callback replacing wget_ocsp_db_add_fingerprint() + wget_ocsp_db_add_fingerprint_fn *add_fingerprint; + /// Callback replacing wget_ocsp_db_add_host() + wget_ocsp_db_add_host_fn *add_host; + /// Callback replacing wget_ocsp_db_load() + wget_ocsp_db_save_fn *load; + /// Callback replacing wget_ocsp_db_save() + wget_ocsp_db_load_fn *save; +} wget_ocsp_db_vtable; + +WGETAPI wget_ocsp_db_init_fn wget_ocsp_db_init; +WGETAPI wget_ocsp_db_deinit_fn wget_ocsp_db_deinit; +WGETAPI wget_ocsp_db_free_fn wget_ocsp_db_free; +WGETAPI wget_ocsp_fingerprint_in_cache_fn wget_ocsp_fingerprint_in_cache; +WGETAPI wget_ocsp_hostname_is_valid_fn wget_ocsp_hostname_is_valid; +WGETAPI wget_ocsp_db_add_fingerprint_fn wget_ocsp_db_add_fingerprint; +WGETAPI wget_ocsp_db_add_host_fn wget_ocsp_db_add_host; +WGETAPI wget_ocsp_db_save_fn wget_ocsp_db_save; +WGETAPI wget_ocsp_db_load_fn wget_ocsp_db_load; +WGETAPI void + wget_ocsp_db_set_fname(wget_ocsp_db *ocsp_db, const char *fname); +WGETAPI void + wget_ocsp_set_plugin(const wget_ocsp_db_vtable *vtable); + +/* + * .netrc routines + */ + +/** + * container for .netrc entries + */ +typedef struct wget_netrc_db_st wget_netrc_db; + +/** + * structure for a single .netrc entry + * + * The GNU extensions are described at + * https://www.gnu.org/software/emacs/manual/html_node/gnus/NNTP.html. + */ +struct wget_netrc_st { + const char * + host; //!< hostname/domain/ip + const char * + login; //!< login/username for the host + const char * + password; //!< password for the host + uint16_t + port; //!< GNU extension: port number + bool + force : 1; //!< GNU extension: unused +}; +typedef struct wget_netrc_st wget_netrc; + +WGETAPI wget_netrc * NULLABLE + wget_netrc_init(wget_netrc *netrc); +WGETAPI void + wget_netrc_deinit(wget_netrc *netrc); +WGETAPI void + wget_netrc_free(wget_netrc *netrc); +WGETAPI wget_netrc * NULLABLE + wget_netrc_new(const char *machine, const char *login, const char *password); +WGETAPI wget_netrc_db * + wget_netrc_db_init(wget_netrc_db *netrc_db); +WGETAPI void + wget_netrc_db_deinit(wget_netrc_db *netrc_db); +WGETAPI void + wget_netrc_db_free(wget_netrc_db **netrc_db); +WGETAPI void + wget_netrc_db_add(wget_netrc_db *netrc_db, wget_netrc *netrc); +WGETAPI wget_netrc * NULLABLE + wget_netrc_get(const wget_netrc_db *netrc_db, const char *host); +WGETAPI int + wget_netrc_db_load(wget_netrc_db *netrc_db, const char *fname); + +/* + * CSS parsing routines + */ + +struct wget_css_parsed_url_st { + size_t + len; //!< length of found URL + size_t + pos; //!< position of found URL within the scanned CSS data + const char * + url; //!< zero-terminated copy the found URL + const char * + abs_url; //!< the found URL converted into an absolute URL +}; +typedef struct wget_css_parsed_url_st wget_css_parsed_url; + +typedef void wget_css_parse_uri_callback(void *user_ctx, const char *url, size_t len, size_t pos); +typedef void wget_css_parse_encoding_callback(void *user_ctx, const char *url, size_t len); + +WGETAPI void + wget_css_parse_buffer( + const char *buf, + size_t len, + wget_css_parse_uri_callback *callback_uri, + wget_css_parse_encoding_callback *callback_encoding, + void *user_ctx) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_css_parse_file( + const char *fname, + wget_css_parse_uri_callback *callback_uri, + wget_css_parse_encoding_callback *callback_encoding, + void *user_ctx) WGET_GCC_NONNULL((1)); +WGETAPI wget_vector * + wget_css_get_urls( + const char *css, + size_t len, + wget_iri *base, + const char **encoding) WGET_GCC_NONNULL((1)); +WGETAPI wget_vector * + wget_css_get_urls_from_localfile( + const char *fname, + wget_iri *base, + const char **encoding) WGET_GCC_NONNULL((1)); + +typedef struct { + const char + *p; //!< pointer to memory region + size_t + len; //!< length of memory region +} wget_string; + +typedef struct { + wget_string + url; //!< URL within the parsed document (pointer and length) + wget_string + download; //!< Value of additional 'download' attribute, the name to be saved to disk + char + attr[16]; //!< name of the attribute containing the URL, e.g. 'href' + char + tag[16]; //!< name of the HTML tag containing the URL, e.g. 'a' + bool + link_inline : 1; //!< 1 = rel was 'stylesheet' or 'shortcut icon' +} wget_html_parsed_url; + +typedef struct { + wget_vector + *uris; //!< list of found URLs (entries: wget_html_parsed_url) + const char * + encoding; //!< the charset encoding set by the parsed document or NULL if none + wget_string + base; //!< the BASE set in the document or NULL if none + bool + follow : 1; //!< if the 'follow' attribute was found in a META tag +} wget_html_parsed_result; + +/** + * HTML tag consisting of name and an optional attribute + */ +typedef struct { + const char * + name; //!< name of HTML tag + const char * + attribute; //!< attribute of the HTML tag +} wget_html_tag; + +WGETAPI wget_html_parsed_result * NULLABLE + wget_html_get_urls_inline(const char *html, wget_vector *additional_tags, wget_vector *ignore_tags); +WGETAPI void + wget_html_free_urls_inline(wget_html_parsed_result **res); +WGETAPI void + wget_sitemap_get_urls_inline(const char *sitemap, wget_vector **urls, wget_vector **sitemap_urls); +WGETAPI void + wget_atom_get_urls_inline(const char *atom, wget_vector **urls); +WGETAPI void + wget_rss_get_urls_inline(const char *rss, wget_vector **urls); + +/* + * XML and HTML parsing routines + */ + +#define XML_FLG_BEGIN (1<<0) // < +#define XML_FLG_CLOSE (1<<1) // > +#define XML_FLG_END (1<<2) // +#define XML_FLG_ATTRIBUTE (1<<3) // attr="value" +#define XML_FLG_CONTENT (1<<4) +#define XML_FLG_COMMENT (1<<5) // +//#define XML_FLG_CDATA (1<<6) // , now same handling as 'special' +#define XML_FLG_PROCESSING (1<<7) // e.g. +#define XML_FLG_SPECIAL (1<<8) // e.g. + +#define XML_HINT_REMOVE_EMPTY_CONTENT (1<<0) // merge spaces, remove empty content +#define XML_HINT_HTML (1<<1) // parse HTML instead of XML + +#define HTML_HINT_REMOVE_EMPTY_CONTENT XML_HINT_REMOVE_EMPTY_CONTENT + +typedef void wget_xml_callback(void *, int, const char *, const char *, const char *, size_t, size_t); + +WGETAPI int + wget_xml_parse_buffer( + const char *buf, + wget_xml_callback *callback, + void *user_ctx, + int hints) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_xml_parse_file( + const char *fname, + wget_xml_callback *callback, + void *user_ctx, + int hints) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_html_parse_buffer( + const char *buf, + wget_xml_callback *callback, + void *user_ctx, + int hints) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_html_parse_file( + const char *fname, + wget_xml_callback *callback, + void *user_ctx, + int hints) WGET_GCC_NONNULL((1)); +WGETAPI char * + wget_xml_decode_entities_inline(char *src) WGET_GCC_NONNULL((1)); + +/* + * DNS caching routines + */ + +typedef struct wget_dns_cache_st wget_dns_cache; + +WGETAPI int + wget_dns_cache_init(wget_dns_cache **cache); +WGETAPI void + wget_dns_cache_free(wget_dns_cache **cache); +WGETAPI struct addrinfo * NULLABLE + wget_dns_cache_get(wget_dns_cache *cache, const char *host, uint16_t port); +WGETAPI int + wget_dns_cache_add(wget_dns_cache *cache, const char *host, uint16_t port, struct addrinfo **addrinfo); + +/* + * DNS resolving routines + */ + +typedef struct wget_dns_st wget_dns; + +WGETAPI int + wget_dns_init(wget_dns **dns); +WGETAPI void + wget_dns_free(wget_dns **dns); +WGETAPI void + wget_dns_set_timeout(wget_dns *dns, int timeout); +WGETAPI void + wget_dns_set_cache(wget_dns *dns, wget_dns_cache *cache); +WGETAPI wget_dns_cache * NULLABLE + wget_dns_get_cache(wget_dns *dns) WGET_GCC_PURE; +WGETAPI struct addrinfo * NULLABLE + wget_dns_resolve(wget_dns *dns, const char *host, uint16_t port, int family, int preferred_family); +WGETAPI void + wget_dns_freeaddrinfo(wget_dns *dns, struct addrinfo **addrinfo); +WGETAPI int + wget_dns_cache_ip(wget_dns *dns, const char *ip, const char *name, uint16_t port); + +/* + * TCP network routines + */ + +#define WGET_NET_FAMILY_ANY 0 +#define WGET_NET_FAMILY_IPV4 1 +#define WGET_NET_FAMILY_IPV6 2 + +#define WGET_PROTOCOL_HTTP_1_1 0 +#define WGET_PROTOCOL_HTTP_2_0 1 + +typedef struct wget_tcp_st wget_tcp; + +WGETAPI int + wget_net_init(void); +WGETAPI int + wget_net_deinit(void); +WGETAPI wget_tcp * NULLABLE + wget_tcp_init(void); +WGETAPI void + wget_tcp_deinit(wget_tcp **tcp); +WGETAPI void + wget_tcp_close(wget_tcp *tcp); +WGETAPI void + wget_tcp_set_dns(wget_tcp *tcp, wget_dns *dns); +WGETAPI void + wget_tcp_set_timeout(wget_tcp *tcp, int timeout); +WGETAPI int + wget_tcp_get_timeout(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI void + wget_tcp_set_connect_timeout(wget_tcp *tcp, int timeout); +WGETAPI void + wget_tcp_set_tcp_fastopen(wget_tcp *tcp, bool tcp_fastopen); +WGETAPI void + wget_tcp_set_tls_false_start(wget_tcp *tcp, bool false_start); +WGETAPI void + wget_tcp_set_ssl(wget_tcp *tcp, bool ssl); +WGETAPI bool + wget_tcp_get_ssl(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI const char * NULLABLE + wget_tcp_get_ip(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI void + wget_tcp_set_ssl_hostname(wget_tcp *tcp, const char *hostname); +WGETAPI const char * + wget_tcp_get_ssl_hostname(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI void + wget_tcp_set_ssl_ca_file(wget_tcp *tcp, const char *cafile); +WGETAPI void + wget_tcp_set_ssl_key_file(wget_tcp *tcp, const char *certfile, const char *keyfile); +WGETAPI bool + wget_tcp_get_tcp_fastopen(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI bool + wget_tcp_get_tls_false_start(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI int + wget_tcp_get_family(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI int + wget_tcp_get_preferred_family(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI int + wget_tcp_get_protocol(wget_tcp *tcp) WGET_GCC_PURE; +WGETAPI int + wget_tcp_get_local_port(wget_tcp *tcp); +WGETAPI void + wget_tcp_set_debug(wget_tcp *tcp, int debug); +WGETAPI void + wget_tcp_set_family(wget_tcp *tcp, int family); +WGETAPI void + wget_tcp_set_preferred_family(wget_tcp *tcp, int family); +WGETAPI void + wget_tcp_set_protocol(wget_tcp *tcp, int protocol); +WGETAPI void + wget_tcp_set_bind_address(wget_tcp *tcp, const char *bind_address); +WGETAPI void + wget_tcp_set_bind_interface(wget_tcp *tcp, const char *bind_interface); +WGETAPI int + wget_tcp_connect(wget_tcp *tcp, const char *host, uint16_t port); +WGETAPI int + wget_tcp_tls_start(wget_tcp *tcp); +WGETAPI void + wget_tcp_tls_stop(wget_tcp *tcp); +WGETAPI ssize_t + wget_tcp_vprintf(wget_tcp *tcp, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0); +WGETAPI ssize_t + wget_tcp_printf(wget_tcp *tcp, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3); +WGETAPI ssize_t + wget_tcp_write(wget_tcp *tcp, const char *buf, size_t count); +WGETAPI ssize_t + wget_tcp_read(wget_tcp *tcp, char *buf, size_t count); +WGETAPI int + wget_tcp_ready_2_transfer(wget_tcp *tcp, int flags); + +WGETAPI bool + wget_ip_is_family(const char *host, int family) WGET_GCC_PURE; + +/* + * SSL routines + */ + +#define WGET_SSL_X509_FMT_PEM 0 +#define WGET_SSL_X509_FMT_DER 1 + +#define WGET_SSL_SECURE_PROTOCOL 1 +#define WGET_SSL_CA_DIRECTORY 2 +#define WGET_SSL_CA_FILE 3 +#define WGET_SSL_CERT_FILE 4 +#define WGET_SSL_KEY_FILE 5 +#define WGET_SSL_CA_TYPE 6 +#define WGET_SSL_CERT_TYPE 7 +#define WGET_SSL_KEY_TYPE 8 +#define WGET_SSL_CHECK_CERTIFICATE 9 +#define WGET_SSL_CHECK_HOSTNAME 10 +#define WGET_SSL_PRINT_INFO 11 +#define WGET_SSL_CRL_FILE 13 +#define WGET_SSL_OCSP_STAPLING 14 +#define WGET_SSL_OCSP_SERVER 15 +#define WGET_SSL_OCSP 16 +#define WGET_SSL_OCSP_CACHE 17 +#define WGET_SSL_ALPN 18 +#define WGET_SSL_SESSION_CACHE 19 +#define WGET_SSL_HPKP_CACHE 20 +#define WGET_SSL_OCSP_NONCE 21 +#define WGET_SSL_OCSP_DATE 22 +#define WGET_SSL_REPORT_INVALID_CERT 23 +#define WGET_SSL_DANE 24 + +WGETAPI void + wget_ssl_init(void); +WGETAPI void + wget_ssl_deinit(void); +WGETAPI void + wget_ssl_set_config_string(int key, const char *value); +WGETAPI void + wget_ssl_set_config_object(int key, void *value); +WGETAPI void + wget_ssl_set_config_int(int key, int value); +WGETAPI int + wget_ssl_open(wget_tcp *tcp); +WGETAPI void + wget_ssl_close(void **session); +WGETAPI void + wget_ssl_set_check_certificate(char value); +WGETAPI ssize_t + wget_ssl_read_timeout(void *session, char *buf, size_t count, int timeout) WGET_GCC_NONNULL_ALL; +WGETAPI ssize_t + wget_ssl_write_timeout(void *session, const char *buf, size_t count, int timeout) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_ssl_default_cert_dir(void); +WGETAPI const char * + wget_ssl_default_ca_bundle_path(void); + +/* + * HTTP routines + */ + +/** + * Parsed name/value pair as often found in HTTP headers + */ +typedef struct { + const char * + name; //!< name of the param + const char * + value; //!< value of the param (might be NULL) +} wget_http_header_param; + +/** + * Parsed Link HTTP header + */ +typedef struct { + const char * + uri; //!< URI reference + const char * + type; //!< value of type param or NULL + int + pri; //!< value of pri param + enum { + link_rel_none = 0, + link_rel_describedby, + link_rel_duplicate + } rel; //!< value of 'rel' param, either none (if not found), 'describedby' or 'duplicate' +} wget_http_link; + +/** + * Parsed Digest HTTP header (RFC 3230) + */ +typedef struct { + const char * + algorithm; //!< name of the digest, e.g. 'md5' + const char * + encoded_digest; //!< value of the digest +} wget_http_digest; + +/** + * Parsed WWW-Authenticate or Proxy-Authenticate HTTP header + */ +typedef struct { + const char * + auth_scheme; //!< name of the challenge, e.g. 'basic' or 'digest' + wget_stringmap * + params; //!< name/value pairs of the challenge +} wget_http_challenge; + +typedef enum { + wget_transfer_encoding_identity = 0, + wget_transfer_encoding_chunked = 1 +} wget_transfer_encoding; + +typedef struct wget_http_response_st wget_http_response; +typedef int wget_http_header_callback(wget_http_response *, void *); +typedef int wget_http_body_callback(wget_http_response *, void *, const char *, size_t); + +/** + * HTTP request data + */ +typedef struct { + wget_vector * + headers; //!< list of HTTP headers + const char * + body; //!< body data to be sent or NULL + wget_http_header_callback + *header_callback; //!< called after HTTP header has been received + wget_http_body_callback + *body_callback; //!< called for each body data packet received + void * + user_data; //!< user data for the request (used by async application code) + void * + header_user_data; //!< meant to be used in header callback function + void * + body_user_data; //!< meant to be used in body callback function + wget_buffer + esc_resource; //!< URI escaped resource + wget_buffer + esc_host; //!< URI escaped host + size_t + body_length; //!< length of the body data + int32_t + stream_id; //!< HTTP2 stream id + wget_iri_scheme + scheme; //!< scheme of the request for proxied connections + char + esc_resource_buf[256]; //!< static buffer used by esc_resource (avoids mallocs) + char + esc_host_buf[64]; //!< static buffer used by esc_host (avoids mallocs) + char + method[8]; //!< currently we just need HEAD, GET and POST + bool + response_keepheader : 1; //!< the application wants the response header data + bool + response_ignorelength : 1; //!< ignore the Content-Length in the response header + bool + debug_skip_body : 1; //!< if set, do not print the request body (e.g. because it's binary) + long long + request_start; //!< When this request was sent out + long long + first_response_start; //!< The time we read the first bytes back + +} wget_http_request; + +/** + * HTTP response data + */ +struct wget_http_response_st { + wget_http_request * + req; + wget_vector * + links; + wget_vector * + digests; + wget_vector * + cookies; + wget_vector * + challenges; + wget_hpkp * + hpkp; + const char * + content_type; + const char * + content_type_encoding; + const char * + content_filename; + const char * + location; + const char * + etag; //!< ETag value + wget_buffer * + header; //!< the raw header data if requested by the application + wget_buffer * + body; //!< the body data + long long + response_end; //!< when this response was received + size_t + content_length; //!< length of the body data + size_t + cur_downloaded, + accounted_for; // reported to bar + int64_t + last_modified; + int64_t + hsts_maxage; + char + reason[32]; //!< reason string after the status code + int + icy_metaint; //!< value of the SHOUTCAST header 'icy-metaint' + short + major; //!< HTTP major version + short + minor; //!< HTTP minor version + short + code; //!< request only status code + wget_transfer_encoding + transfer_encoding; + char + content_encoding; + bool + hsts_include_subdomains, + keep_alive; + bool + content_length_valid : 1, + length_inconsistent : 1, //!< set when length of data received is not same as Content-Length + hsts : 1, //!< if hsts_maxage and hsts_include_subdomains are valid + csp : 1; +}; + +typedef struct wget_http_connection_st wget_http_connection; + +WGETAPI const char * + wget_http_get_host(const wget_http_connection *conn) WGET_GCC_NONNULL_ALL; +WGETAPI uint16_t + wget_http_get_port(const wget_http_connection *conn) WGET_GCC_NONNULL_ALL; +WGETAPI wget_iri_scheme + wget_http_get_scheme(const wget_http_connection *conn) WGET_GCC_NONNULL_ALL; +WGETAPI int + wget_http_get_protocol(const wget_http_connection *conn) WGET_GCC_NONNULL_ALL; + +WGETAPI bool + wget_http_isseparator(char c) WGET_GCC_CONST; +WGETAPI bool + wget_http_istoken(char c) WGET_GCC_CONST; + +WGETAPI const char * + wget_http_parse_token(const char *s, const char **token) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_quoted_string(const char *s, const char **qstring) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_param(const char *s, const char **param, const char **value) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_name(const char *s, const char **name) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_parse_name_fixed(const char *s, const char **name, size_t *namelen) WGET_GCC_NONNULL_ALL; +WGETAPI int64_t + wget_http_parse_full_date(const char *s) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_link(const char *s, wget_http_link *link) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_digest(const char *s, wget_http_digest *digest) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_challenge(const char *s, wget_http_challenge *challenge) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_challenges(const char *s, wget_vector *challenges) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_location(const char *s, const char **location) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_transfer_encoding(const char *s, wget_transfer_encoding *transfer_encoding) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_content_type(const char *s, const char **content_type, const char **charset) WGET_GCC_NONNULL((1)); +WGETAPI const char * + wget_http_parse_content_encoding(const char *s, char *content_encoding) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_content_disposition(const char *s, const char **filename) WGET_GCC_NONNULL((1)); +WGETAPI const char * + wget_http_parse_strict_transport_security(const char *s, int64_t *maxage, bool *include_subdomains) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_public_key_pins(const char *s, wget_hpkp *hpkp) WGET_GCC_NONNULL((1)); +WGETAPI const char * + wget_http_parse_connection(const char *s, bool *keep_alive) WGET_GCC_NONNULL_ALL; +WGETAPI const char * + wget_http_parse_setcookie(const char *s, wget_cookie **cookie) WGET_GCC_NONNULL((1)); +WGETAPI const char * + wget_http_parse_etag(const char *s, const char **etag) WGET_GCC_NONNULL((1)); + +WGETAPI char * + wget_http_print_date(int64_t t, char *buf, size_t bufsize) WGET_GCC_NONNULL_ALL; + +WGETAPI void + wget_http_add_param(wget_vector **params, wget_http_header_param *param) WGET_GCC_NONNULL_ALL; +WGETAPI int + wget_http_add_header_vprintf(wget_http_request *req, const char *name, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(3,0) WGET_GCC_NONNULL_ALL; +WGETAPI int + wget_http_add_header_printf(wget_http_request *req, const char *name, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(3,4) WGET_GCC_NONNULL((1,2,3)); +WGETAPI int + wget_http_add_header(wget_http_request *req, const char *name, const char *value) WGET_GCC_NONNULL_ALL; +WGETAPI int + wget_http_add_header_param(wget_http_request *req, wget_http_header_param *param) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_http_add_credentials(wget_http_request *req, wget_http_challenge *challenge, const char *username, const char *password, int proxied) WGET_GCC_NONNULL((1)); +WGETAPI int + wget_http_set_http_proxy(const char *proxy, const char *encoding); +WGETAPI int + wget_http_set_https_proxy(const char *proxy, const char *encoding); +WGETAPI int + wget_http_set_no_proxy(const char *no_proxy, const char *encoding); +WGETAPI const wget_vector * + wget_http_get_no_proxy(void); +WGETAPI int + wget_http_match_no_proxy(const wget_vector *no_proxies, const char *host); +WGETAPI void + wget_http_abort_connection(wget_http_connection *conn); +WGETAPI bool + wget_http_connection_receive_only(wget_http_connection *conn); + +WGETAPI void + wget_http_free_param(wget_http_header_param *param); +WGETAPI void + wget_http_free_cookie(wget_cookie *cookie); +WGETAPI void + wget_http_free_digest(wget_http_digest *digest); +WGETAPI void + wget_http_free_challenge(wget_http_challenge *challenge); +WGETAPI void + wget_http_free_link(wget_http_link *link); + +WGETAPI void + wget_http_free_cookies(wget_vector **cookies); +WGETAPI void + wget_http_free_hpkp_entries(wget_hpkp **hpkp); +WGETAPI void + wget_http_free_digests(wget_vector **digests); +WGETAPI void + wget_http_free_challenges(wget_vector **challenges); +WGETAPI void + wget_http_free_links(wget_vector **links); +//WGETAPI void +// wget_http_free_header(HTTP_HEADER **header); +WGETAPI void + wget_http_free_request(wget_http_request **req); +WGETAPI void + wget_http_free_response(wget_http_response **resp); + +WGETAPI int + wget_http_parse_header_line(wget_http_response *resp, const char *name, size_t namelen, const char *value, size_t valuelen); +WGETAPI wget_http_response * NULLABLE + wget_http_parse_response_header(char *buf) WGET_GCC_NONNULL_ALL; +WGETAPI wget_http_response * NULLABLE + wget_http_get_response_cb(wget_http_connection *conn) WGET_GCC_NONNULL((1)); +//WGETAPI HTTP_RESPONSE * +// http_get_response_mem(HTTP_CONNECTION *conn, HTTP_REQUEST *req) NONNULL_ALL; +WGETAPI wget_http_response * NULLABLE + wget_http_get_response(wget_http_connection *conn) WGET_GCC_NONNULL((1)); + +WGETAPI void + wget_http_init(void); +WGETAPI void + wget_http_exit(void); +WGETAPI int + wget_http_open(wget_http_connection **_conn, const wget_iri *iri); +WGETAPI wget_http_request * NULLABLE + wget_http_create_request(const wget_iri *iri, const char *method) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_http_close(wget_http_connection **conn) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_http_request_set_header_cb(wget_http_request *req, wget_http_header_callback *cb, void *user_data) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_http_request_set_body_cb(wget_http_request *req, wget_http_body_callback *cb, void *user_data) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_http_request_set_int(wget_http_request *req, int key, int value) WGET_GCC_NONNULL((1)); +WGETAPI int + wget_http_request_get_int(wget_http_request *req, int key) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_http_request_set_ptr(wget_http_request *req, int key, void *value) WGET_GCC_NONNULL((1)); +WGETAPI void * + wget_http_request_get_ptr(wget_http_request *req, int key) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_http_request_set_body(wget_http_request *req, const char *mimetype, char *body, size_t length) WGET_GCC_NONNULL((1)); +WGETAPI int + wget_http_send_request(wget_http_connection *conn, wget_http_request *req) WGET_GCC_NONNULL_ALL; +WGETAPI ssize_t + wget_http_request_to_buffer(wget_http_request *req, wget_buffer *buf, int proxied, int port) WGET_GCC_NONNULL_ALL; + +/* + * Highlevel HTTP routines + */ + +WGETAPI wget_http_response * + wget_http_get(int first_key, ...); + + +/* + * random routines + */ + +WGETAPI void + wget_random_init(void); +WGETAPI void + wget_random_exit(void); +WGETAPI int + wget_random(void); +WGETAPI void + wget_srandom(unsigned int seed); + + +/** + * \ingroup libwget-hash + * \brief Type for hash / digest routines + */ + typedef struct wget_hash_hd_st wget_hash_hd; + +/** + * \ingroup libwget-hash + * \brief Enumeration of different hash digest algorithms + */ +typedef enum { + WGET_DIGTYPE_UNKNOWN = 0, /**< Indicates 'Unknown hash algorithm', returned by wget_hash_get_algorithm() */ + WGET_DIGTYPE_MD5, /**< Type 'MD5' digest */ + WGET_DIGTYPE_SHA1, /**< Type SHA1 digest */ + WGET_DIGTYPE_RMD160, /**< Type RMD160 digest */ + WGET_DIGTYPE_MD2, /**< Type 'MD2' digest */ + WGET_DIGTYPE_SHA256, /**< Type 'SHA256' digest */ + WGET_DIGTYPE_SHA384, /**< Type 'SHA384' digest */ + WGET_DIGTYPE_SHA512, /**< Type 'SHA512' digest */ + WGET_DIGTYPE_SHA224, /**< Type 'SHA224' digest */ + WGET_DIGTYPE_MAX /**< Number of digest types */ +} wget_digest_algorithm; + +WGETAPI wget_digest_algorithm + wget_hash_get_algorithm(const char *hashname); +WGETAPI int + wget_hash_fast(wget_digest_algorithm algorithm, const void *text, size_t textlen, void *digest); +WGETAPI int + wget_hash_get_len(wget_digest_algorithm algorithm) WGET_GCC_CONST; +WGETAPI int + wget_hash_init(wget_hash_hd **dig, wget_digest_algorithm algorithm); +WGETAPI int + wget_hash(wget_hash_hd *handle, const void *text, size_t textlen); +WGETAPI int + wget_hash_deinit(wget_hash_hd **handle, void *digest); + +/* + * Hash file routines + */ + +WGETAPI int + wget_hash_file_fd(const char *hashname, int fd, char *digest_hex, size_t digest_hex_size, off_t offset, off_t length) WGET_GCC_NONNULL_ALL; +WGETAPI int + wget_hash_file_offset(const char *hashname, const char *fname, char *digest_hex, size_t digest_hex_size, off_t offset, off_t length) WGET_GCC_NONNULL_ALL; +WGETAPI int + wget_hash_file(const char *hashname, const char *fname, char *digest_hex, size_t digest_hex_size) WGET_GCC_NONNULL_ALL; + +/* + * Hash convenience routines + */ + +// don't use 'restrict' here as out, fmt and argument pointers may overlap +WGETAPI void WGET_GCC_PRINTF_FORMAT(4,5) WGET_GCC_NONNULL_ALL + wget_hash_printf_hex(wget_digest_algorithm algorithm, char *out, size_t outsize, const char *fmt, ...); + + +/* + * Metalink types and routines + */ + +typedef struct { + const wget_iri + *iri; //!< parsed URL of the mirror + int + priority; //!< priority of the mirror + char + location[8]; //!< location of the mirror, e.g. 'de', 'fr' or 'jp' +} wget_metalink_mirror; + +typedef struct { + char + type[16], //!< type of hash, e.g. 'MD5' or 'SHA-256' + hash_hex[128+1]; //!< hash value as HEX string +} wget_metalink_hash; + +// Metalink piece, for checksumming after download +typedef struct { + wget_metalink_hash + hash; //!< hash of the data chunk + off_t + position; //!< start position of the data chunk in the file + off_t + length; //!< length of the data chunk +} wget_metalink_piece; + +typedef struct { + const char + *name; //!< filename + wget_vector + *mirrors, //!< mirrors that provide the file (element: wget_metalink_mirror) + *hashes, //!< checksums of complete file (element: wget_metalink_hash) + *pieces; //!< checksums of smaller pieces of the file (element: wget_metalink_piece) + off_t + size; //!< total size of the file +} wget_metalink; + +WGETAPI wget_metalink * NULLABLE + wget_metalink_parse(const char *xml); +WGETAPI void + wget_metalink_free(wget_metalink **metalink); +WGETAPI void + wget_metalink_sort_mirrors(wget_metalink *metalink); + +/* + * Robots types and routines + */ + +typedef struct wget_robots_st wget_robots; + +WGETAPI int + wget_robots_parse(wget_robots **robots, const char *data, const char *client); +WGETAPI void + wget_robots_free(wget_robots **robots); +WGETAPI int + wget_robots_get_path_count(wget_robots *robots); +WGETAPI wget_string * NULLABLE + wget_robots_get_path(wget_robots *robots, int index); +WGETAPI int + wget_robots_get_sitemap_count(wget_robots *robots); +WGETAPI const char * NULLABLE + wget_robots_get_sitemap(wget_robots *robots, int index); + +/* + * Progress bar routines + */ + +// values for --report-speed and wget_bar_set_speed_type() +typedef enum { + WGET_REPORT_SPEED_BYTES, + WGET_REPORT_SPEED_BITS +} wget_report_speed; + +typedef struct wget_bar_st wget_bar; + +WGETAPI wget_bar * NULLABLE + wget_bar_init(wget_bar *bar, int nslots); +WGETAPI void + wget_bar_deinit(wget_bar *bar); +WGETAPI void + wget_bar_free(wget_bar **bar); +WGETAPI void + wget_bar_print(wget_bar *bar, int slot, const char *s); +WGETAPI void + wget_bar_vprintf(wget_bar *bar, int slot, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(3,0) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_bar_printf(wget_bar *bar, int slot, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(3,4) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_bar_slot_begin(wget_bar *bar, int slot, const char *filename, int new_file, ssize_t filesize) WGET_GCC_NONNULL((1)); +WGETAPI void + wget_bar_slot_downloaded(wget_bar *bar, int slot, size_t nbytes); +WGETAPI void + wget_bar_slot_deregister(wget_bar *bar, int slot) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_bar_update(wget_bar *bar) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_bar_set_slots(wget_bar *bar, int nslots) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_bar_screen_resized(void); +WGETAPI void + wget_bar_write_line(wget_bar *bar, const char *buf, size_t len) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_bar_write_line_ext(wget_bar *bar, const char *buf, size_t len, const char *pre, const char *post) WGET_GCC_NONNULL_ALL; +WGETAPI void + wget_bar_set_speed_type(wget_report_speed type); + +/* + * Console routines + */ + +// console color definitions +typedef enum { + WGET_CONSOLE_COLOR_RESET = 0, + WGET_CONSOLE_COLOR_WHITE = 1, + WGET_CONSOLE_COLOR_BLUE = 2, + WGET_CONSOLE_COLOR_GREEN = 3, + WGET_CONSOLE_COLOR_RED = 4, + WGET_CONSOLE_COLOR_MAGENTA = 5 +} wget_console_color; + +WGETAPI int + wget_console_init(void); +WGETAPI int + wget_console_deinit(void); +WGETAPI void + wget_console_set_fg_color(wget_console_color colorid); +WGETAPI void + wget_console_reset_fg_color(void); + +/* + * Plugin support + */ + +/** + * \ingroup libwget-plugin + * + * Mark a function to be exported. + * A common use for this is to mark the `wget_plugin_initializer()` function for plugin initialization. + * + * WGET_EXPORT void wget_plugin_initializer(wget_plugin *plugin); + */ +#ifdef _WIN32 +# define WGET_EXPORT __declspec(dllexport) +#elif __GNUC__ > 4 +# define WGET_EXPORT __attribute__ ((__visibility__("default"))) +#else +# define WGET_EXPORT +#endif + +struct wget_plugin_vtable; + +/** + * \ingroup libwget-plugin + * + * A handle used to identify the plugin. + * + * Only two members shown here are public, and only plugin_data is writable. + */ +struct wget_plugin_st +{ + /// Plugin specific data. Plugins are free to assign any value to this. + void *plugin_data; + + /// Pointer to the vtable. Used by wget to implement functions. + struct wget_plugin_vtable *vtable; +}; + +typedef struct wget_plugin_st wget_plugin; + +/** + * \ingroup libwget-plugin + * + * Prototype for the initializer function. + * + * \param[in] plugin The plugin handle + * \return Should return 0 if initialization succeeded, or any other value to indicate failure. + * On failure, wget2 will continue without the plugin + * and will not call the finalizer function even if registered. + */ +typedef int wget_plugin_initializer_fn(wget_plugin *plugin); + +/** + * \ingroup libwget-plugin + * + * Prototype of the finalizer function. + * + * \param[in] plugin The plugin handle + * \param[in] exit_status The exit status wget will exit with + */ +typedef void wget_plugin_finalizer_fn(wget_plugin *plugin, int exit_status); + +// Gets the name the plugin is known as. +WGETAPI const char * + wget_plugin_get_name(wget_plugin *plugin) WGET_GCC_NONNULL_ALL; + +// Registers a function to be called when wget exits. +WGETAPI void + wget_plugin_register_finalizer(wget_plugin *plugin, wget_plugin_finalizer_fn *fn) WGET_GCC_NONNULL((1)); + +/** + * \ingroup libwget-plugin + * + * Prototype for the function that will accept forwarded command line arguments. + * + * \param[in] plugin The plugin handle + * \param[in] option Option name. If the option is "help", a help message must be printed to stdout. + * \param[in] value The value of the option if provided, or NULL + * \return Must return 0 if option and its value is valid, or any other value if invalid. In that case wget will exit. + */ +typedef int wget_plugin_option_callback(wget_plugin *plugin, const char *option, const char *value); + +// Registers a function for command line option forwarding. +WGETAPI void + wget_plugin_register_option_callback(wget_plugin *plugin, wget_plugin_option_callback *fn) WGET_GCC_NONNULL((1)); + +/** + * \ingroup libwget-plugin + * + * Stores any action taken by the plugin + */ +typedef struct { + struct wget_plugin_vtable *vtable; +} wget_intercept_action; + +// Marks the URL to be rejected. +WGETAPI void + wget_intercept_action_reject(wget_intercept_action *action) WGET_GCC_NONNULL_ALL; + +// Marks the URL to be accepted. +WGETAPI void + wget_intercept_action_accept(wget_intercept_action *action) WGET_GCC_NONNULL_ALL; + +// Specifies an alternative URL to be fetched instead. +WGETAPI void + wget_intercept_action_set_alt_url(wget_intercept_action *action, const wget_iri *iri) WGET_GCC_NONNULL((1)); + +// Specifies that the fetched data should be written to an alternative file. +WGETAPI void + wget_intercept_action_set_local_filename(wget_intercept_action *action, const char *local_filename) WGET_GCC_NONNULL((1)); + +/** + * \ingroup libwget-plugin + * + * Prototype for the function for intercepting URLs + * The function must be thread-safe. + * + * \param[in] plugin The plugin handle + * \param[in] iri The URL about to be fetched + * \param[in] action Output the action to be taken + */ +typedef void wget_plugin_url_filter_callback(wget_plugin *plugin, const wget_iri *iri, wget_intercept_action *action); + +// Registers a plugin function for intercepting URLs +WGETAPI void + wget_plugin_register_url_filter_callback(wget_plugin *plugin, wget_plugin_url_filter_callback *filter_fn); + +/** + * \ingroup libwget-plugin + * + * Handle that represents a downloaded file. + */ +typedef struct { + struct wget_plugin_vtable *vtable; +} wget_downloaded_file; + +// Gets the source address the file was downloaded from. +WGETAPI const wget_iri * + wget_downloaded_file_get_source_url(wget_downloaded_file *file); + +// Gets the file name the downloaded file was written to. +WGETAPI const char * + wget_downloaded_file_get_local_filename(wget_downloaded_file *file); + +// Gets the size of the downloaded file. +WGETAPI uint64_t + wget_downloaded_file_get_size(wget_downloaded_file *file); + +// Reads the downloaded file into memory. +WGETAPI int + wget_downloaded_file_get_contents(wget_downloaded_file *file, const void **data, size_t *size); + +// Opens the downloaded file as a new stream. +WGETAPI FILE * + wget_downloaded_file_open_stream(wget_downloaded_file *file); + +// Gets whether the file should be scanned for more URLs. +WGETAPI bool + wget_downloaded_file_get_recurse(wget_downloaded_file *file); + +// Adds a URL for recursive downloading. +WGETAPI void + wget_downloaded_file_add_recurse_url(wget_downloaded_file *file, const wget_iri *iri); + +/** + * \ingroup libwget-plugin + * + * Prototype of the function for intercepting downloaded files. The function must be thread-safe. + * + * \param[in] plugin The plugin handle + * \param[in] file Downloaded file handle + * \return 0 if further postprocessing of downloaded files should be stopped. + */ +typedef int wget_plugin_post_processor(wget_plugin *plugin, wget_downloaded_file *file); + +// Registers a plugin function for intercepting downloaded files. +WGETAPI void + wget_plugin_register_post_processor(wget_plugin *plugin, wget_plugin_post_processor *fn); + +/** + * \ingroup libwget-plugin + * + * vtable for implementing plugin API in wget +*/ +struct wget_plugin_vtable +{ + const char * (* get_name)(wget_plugin *); + void (* register_finalizer)(wget_plugin *, wget_plugin_finalizer_fn *); + void (* register_argp)(wget_plugin *, wget_plugin_option_callback *); + + void (* action_reject)(wget_intercept_action *); + void (* action_accept)(wget_intercept_action *); + void (* action_set_alt_url)(wget_intercept_action *, const wget_iri *); + void (* action_set_local_filename)(wget_intercept_action *, const char *); + void (* register_url_filter)(wget_plugin *, wget_plugin_url_filter_callback *); + + const wget_iri *(*file_get_source_url)(wget_downloaded_file *); + const char *(*file_get_local_filename)(wget_downloaded_file *); + uint64_t (*file_get_size)(wget_downloaded_file *); + int (*file_get_contents)(wget_downloaded_file *, const void **data, size_t *size); + FILE *(*file_open_stream)(wget_downloaded_file *); + bool (*file_get_recurse)(wget_downloaded_file *); + void (*file_add_recurse_url)(wget_downloaded_file *, const wget_iri *); + void (*register_post_processor)(wget_plugin *, wget_plugin_post_processor *); +}; + +/** + * \ingroup libwget-dns + * + * DNS statistics data + * + * @{ + */ +typedef struct +{ + const char + *hostname, //!< hostname/domain to be resolved + *ip; //!< resulting IP string + uint16_t + port; //!< port to be resolved + long long + dns_secs; //!< milliseconds it took to resolve +} wget_dns_stats_data; + +typedef void + wget_dns_stats_callback(wget_dns *dns, wget_dns_stats_data *stats, void *ctx); + +WGETAPI void + wget_dns_set_stats_callback(wget_dns *dns, wget_dns_stats_callback *fn, void *ctx); + +/** + * \ingroup libwget-ssl + * + * TLS statistics data + * + * @{ + */ +typedef struct +{ + const char + *hostname; + int + nvalid, + nrevoked, + nignored, + stapling; +} wget_ocsp_stats_data; + +typedef void + wget_ocsp_stats_callback(wget_ocsp_stats_data *stats, void *ctx); + +WGETAPI void + wget_ssl_set_stats_callback_ocsp(wget_ocsp_stats_callback *fn, void *ctx); +/** @} */ + +/** + * \ingroup libwget-ssl + * + * OCSP statistics data + * + * @{ + */ +typedef struct +{ + const char + *hostname, + *alpn_protocol; + long long + tls_secs; //milliseconds + int + version, + cert_chain_size; + char + http_protocol; + bool + false_start, + tfo, + tls_con, + resumed; +} wget_tls_stats_data; + +typedef void + wget_tls_stats_callback(wget_tls_stats_data *stats, void *ctx); + +WGETAPI void + wget_ssl_set_stats_callback_tls(wget_tls_stats_callback *fn, void *ctx); +/** @} */ + +typedef enum { + WGET_STATS_HPKP_NO = 0, + WGET_STATS_HPKP_MATCH = 1, + WGET_STATS_HPKP_NOMATCH = 2, + WGET_STATS_HPKP_ERROR = 3 +} wget_hpkp_stats_result; + +typedef void + wget_server_stats_callback(wget_http_connection *conn, wget_http_response *resp); + +WGETAPI void + wget_server_set_stats_callback(wget_server_stats_callback *fn); + +typedef enum { + WGET_STATS_FORMAT_HUMAN = 0, + WGET_STATS_FORMAT_CSV = 1, +} wget_stats_format; + +WGET_END_DECLS + +/* + * Regex Types + */ + +#define WGET_REGEX_TYPE_POSIX 0 +#define WGET_REGEX_TYPE_PCRE 1 + +#undef RETURNS_NONNULL + +#endif /* WGET_WGET_H */ diff --git a/illumos-x86_64/usr/include/wgetver.h b/illumos-x86_64/usr/include/wgetver.h new file mode 100644 index 00000000..77d2d50f --- /dev/null +++ b/illumos-x86_64/usr/include/wgetver.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016-2024 Free Software Foundation, Inc. + * + * This file is part of libwget. + * + * Libwget is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Libwget is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libwget. If not, see . + * + * + * Libwget version information + */ + +#ifndef WGET_WGETVER_H +#define WGET_WGETVER_H + +#define LIBWGET_VERSION "2.2.0" +#define LIBWGET_VERSION_MAJOR 2 +#define LIBWGET_VERSION_MINOR 2 +#define LIBWGET_VERSION_PATCH 0 +#define LIBWGET_VERSION_NUMBER 0x020200 + +#endif /* WGET_WGETVER_H */ diff --git a/illumos-x86_64/usr/include/widec.h b/illumos-x86_64/usr/include/widec.h new file mode 100644 index 00000000..afce2c44 --- /dev/null +++ b/illumos-x86_64/usr/include/widec.h @@ -0,0 +1,126 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1986 AT&T */ +/* All Rights Reserved */ + + +/* This module is created for NLS on Jun.04.86 */ + +#ifndef _WIDEC_H +#define _WIDEC_H + +#include + +#include /* For definition of FILE */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Character based input and output functions */ +extern wchar_t *getws(wchar_t *); +extern int putws(const wchar_t *); + +#if !defined(__lint) +#define getwc(p) fgetwc(p) +#define putwc(x, p) fputwc((x), (p)) +#define getwchar() getwc(stdin) +#define putwchar(x) putwc((x), stdout) +#endif + +/* wchar_t string operation functions */ +extern wchar_t *strtows(wchar_t *, char *); +extern wchar_t *wscpy(wchar_t *, const wchar_t *); +extern wchar_t *wsncpy(wchar_t *, const wchar_t *, size_t); +extern wchar_t *wscat(wchar_t *, const wchar_t *); +extern wchar_t *wsncat(wchar_t *, const wchar_t *, size_t); +extern wchar_t *wschr(const wchar_t *, wchar_t); +extern wchar_t *wsrchr(const wchar_t *, wchar_t); +extern wchar_t *wspbrk(const wchar_t *, const wchar_t *); +extern wchar_t *wstok(wchar_t *, const wchar_t *); +extern char *wstostr(char *, wchar_t *); + +extern int wscmp(const wchar_t *, const wchar_t *); +extern int wsncmp(const wchar_t *, const wchar_t *, size_t); +extern size_t wslen(const wchar_t *); +extern size_t wsspn(const wchar_t *, const wchar_t *); +extern size_t wscspn(const wchar_t *, const wchar_t *); +extern int wscoll(const wchar_t *, const wchar_t *); +extern size_t wsxfrm(wchar_t *, const wchar_t *, size_t); + +#if !defined(_STRICT_SYMBOLS) + +extern wchar_t *wsdup(const wchar_t *); +extern int wscol(const wchar_t *); +extern double wstod(const wchar_t *, wchar_t **); +extern long wstol(const wchar_t *, wchar_t **, int); +extern int wscasecmp(const wchar_t *, const wchar_t *); +extern int wsncasecmp(const wchar_t *, const wchar_t *, size_t); +extern int wsprintf(wchar_t *, const char *, ...); +#if defined(_LONGLONG_TYPE) +extern long long wstoll(const wchar_t *, wchar_t **, int); +#endif /* defined(_LONGLONG_TYPE) */ + +#endif /* !defined(_STRICT_SYMBOLS) */ + +/* Returns the code set number for the process code c. */ +#define WCHAR_SHIFT 7 +#define WCHAR_S_MASK 0x7f +#define wcsetno(c) \ + (((c)&0x20000000)?(((c)&0x10000000)?1:3):(((c)&0x10000000)?2:0)) + +/* Aliases... */ +#define windex wschr +#define wrindex wsrchr + +#define watol(s) wstol((s), (wchar_t **)0, 10) +#if defined(_LONGLONG_TYPE) && !defined(__lint) +#define watoll(s) wstoll((s), (wchar_t **)0, 10) +#endif /* defined(_LONGLONG_TYPE) && !defined(__lint) */ +#define watoi(s) ((int)wstol((s), (wchar_t **)0, 10)) +#define watof(s) wstod((s), (wchar_t **)0) + +/* + * other macros. + */ +#define WCHAR_CSMASK 0x30000000 +#define EUCMASK 0x30000000 +#define WCHAR_CS0 0x00000000 +#define WCHAR_CS1 0x30000000 +#define WCHAR_CS2 0x10000000 +#define WCHAR_CS3 0x20000000 +#define WCHAR_BYTE_OF(wc, i) (((wc&~0x30000000)>>(7*(3-i)))&0x7f) + +#ifdef __cplusplus +} +#endif + +#endif /* _WIDEC_H */ diff --git a/illumos-x86_64/usr/include/wordexp.h b/illumos-x86_64/usr/include/wordexp.h new file mode 100644 index 00000000..a5513c39 --- /dev/null +++ b/illumos-x86_64/usr/include/wordexp.h @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright 1985, 1992 by Mortice Kern Systems Inc. All rights reserved. + */ + +#ifndef _WORDEXP_H +#define _WORDEXP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct wordexp_t { + size_t we_wordc; /* Count of paths matched by pattern */ + char **we_wordv; /* List of matched pathnames */ + size_t we_offs; /* # of slots reserved in we_pathv */ + /* following are internal to the implementation */ + char **we_wordp; /* we_pathv + we_offs */ + int we_wordn; /* # of elements allocated */ +} wordexp_t; + +/* + * wordexp flags. + */ +#define WRDE_APPEND 0x0001 /* append to existing wordexp_t */ +#define WRDE_DOOFFS 0x0002 /* use we_offs */ +#define WRDE_NOCMD 0x0004 /* don't allow $() */ +#define WRDE_REUSE 0x0008 +#define WRDE_SHOWERR 0x0010 /* don't 2>/dev/null */ +#define WRDE_UNDEF 0x0020 /* set -u */ + +/* + * wordexp errors. + */ +#define WRDE_ERRNO (2) /* error in "errno" */ +#define WRDE_BADCHAR (3) /* shell syntax character */ +#define WRDE_BADVAL (4) /* undefined variable expanded */ +#define WRDE_CMDSUB (5) /* prohibited $() */ +#define WRDE_NOSPACE (6) /* no memory */ +#define WRDE_SYNTAX (7) /* bad syntax */ +#define WRDE_NOSYS (8) /* function not supported (XPG4) */ + +extern int wordexp(const char *_RESTRICT_KYWD, wordexp_t *_RESTRICT_KYWD, int); +extern void wordfree(wordexp_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _WORDEXP_H */ diff --git a/illumos-x86_64/usr/include/xlocale.h b/illumos-x86_64/usr/include/xlocale.h new file mode 100644 index 00000000..23cede35 --- /dev/null +++ b/illumos-x86_64/usr/include/xlocale.h @@ -0,0 +1,130 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2014 Garrett D'Amore + * Copyright 2025 Bill Sommerfeld + */ + +#ifndef _XLOCALE_H +#define _XLOCALE_H + +/* + * This file supplies declarations for extended locale routines, as + * originally delivered by MacOS X. Many of these things are now + * officially part of XPG7. (Note that while the interfaces are the + * same as MacOS X, there is no shared implementation.) + * + * Those declarations that are part of XPG7 are provided for the in the + * XPG7-specified location. This file lists just the declarations that + * were not part of the standard. These will be useful in their own right, + * and will aid porting programs that don't strictly follow the standard. + * + * Note that it is an error to include this file in a program with strict + * symbol visibilty rules (under strict ANSI or POSIX_C_SOURCE rules.) + * If this is done, the symbols defined here will indeed be exposed to your + * program, but those symbols that are part of the related standards might + * not be. + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _LOCALE_T +#define _LOCALE_T +typedef struct _locale *locale_t; +#endif + +extern int mbsinit_l(const mbstate_t *, locale_t); + +extern size_t mbsrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD, + size_t, mbstate_t *_RESTRICT_KYWD, locale_t); + +extern size_t mbsnrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD, + size_t, size_t, mbstate_t *_RESTRICT_KYWD, locale_t); + +extern char *strptime_l(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + struct tm *_RESTRICT_KYWD, locale_t); + +extern int wcwidth_l(wchar_t, locale_t); + +extern int wcswidth_l(const wchar_t *, size_t, locale_t); + +extern int iswspecial_l(wint_t, locale_t); +extern int iswnumber_l(wint_t, locale_t); +extern int iswhexnumber_l(wint_t, locale_t); +extern int iswideogram_l(wint_t, locale_t); +extern int iswphonogram_l(wint_t, locale_t); + +extern wint_t btowc_l(int, locale_t); +extern int wctob_l(wint_t, locale_t); +extern size_t mbrtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + size_t, mbstate_t *_RESTRICT_KYWD, locale_t); +extern size_t mbstowcs_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, + size_t, locale_t); +extern int mblen_l(const char *, size_t, locale_t); +extern size_t mbrlen_l(const char *_RESTRICT_KYWD, size_t, + mbstate_t *_RESTRICT_KYWD, locale_t); +extern int mbtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t, + locale_t); +extern size_t wcsrtombs_l(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, + size_t, mbstate_t *_RESTRICT_KYWD, locale_t); +extern size_t wcsnrtombs_l(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, + size_t, size_t, mbstate_t *_RESTRICT_KYWD, locale_t); +extern size_t wcrtomb_l(char *_RESTRICT_KYWD, wchar_t, + mbstate_t *_RESTRICT_KYWD, locale_t); +extern size_t wcstombs_l(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t, locale_t); +extern int wctomb_l(char *, wchar_t, locale_t); + +extern unsigned char __mb_cur_max_l(locale_t); +#ifndef MB_CUR_MAX_L +#define MB_CUR_MAX_L(l) (__mb_cur_max_l(l)) +#endif + +extern struct lconv *localeconv_l(locale_t); + +extern size_t wcsftime_l(wchar_t *_RESTRICT_KYWD, + size_t, const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD, + locale_t); + +/* these three are also in stdlib.h */ +extern float strtof_l(const char *, char **, locale_t); +extern double strtod_l(const char *, char **, locale_t); +extern long double strtold_l(const char *, char **, locale_t); + +extern void string_to_decimal_l(char **, int, int, decimal_record *, + enum decimal_string_form *, char **, locale_t); + +#if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L +#define _FILEDEFED +typedef __FILE FILE; +#endif + +extern wint_t fgetwc_l(FILE *, locale_t); +extern wint_t getwc_l(FILE *, locale_t); + +#ifndef getwchar_l +#define getwchar_l(l) fgetwc_l(stdin, (l)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _XLOCALE_H */ diff --git a/illumos-x86_64/usr/include/xti.h b/illumos-x86_64/usr/include/xti.h new file mode 100644 index 00000000..0ce140da --- /dev/null +++ b/illumos-x86_64/usr/include/xti.h @@ -0,0 +1,540 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2014 Garrett D'Amore + */ +/* Copyright (c) 1996 Sun Microsystems, Inc. */ +/* All Rights Reserved */ + + +#ifndef _XTI_H +#define _XTI_H + +#include + +/* + * The following include file has declarations needed by both the kernel + * level transport providers and the user level library. This file includes + * it to expose its namespaces to XTI user level interface. + */ +#include + +/* + * Include XTI interface level options management declarations + */ +#include + +#if !defined(_XPG5) + +/* + * Include declarations related to OSI transport and management data + * structures, and the Internet Protocol Suite. + * Note: The older Unix95/XNS4 XTI spec required these to be + * exposed through the generic interface header. + */ +#include +#include + +#endif /* !defined(_XPG5) */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The following t_errno error codes are included in the namespace by + * inclusion of above. The english language error strings + * associated with the error values are reproduced here for easy reference. + * + * Error Value Error message string + * ---- ----- -------------------- + * TBADADDR 1 Incorrect address format + * TBADOPT 2 Incorrect options format + * TACCES 3 Illegal permissions + * TBADF 4 Illegal file descriptor + * TNOADDR 5 Couldn't allocate address + * TOUTSTATE 6 Routine will place interface out of state + * TBADSEQ 7 Illegal called/calling sequence number + * TSYSERR 8 System error + * TLOOK 9 An event requires attention + * TBADDATA 10 Illegal amount of data + * TBUFOVFLW 11 Buffer not large enough + * TFLOW 12 Can't send message - (blocked) + * TNODATA 13 No message currently available + * TNODIS 14 Disconnect message not found + * TNOUDERR 15 Unitdata error message not found + * TBADFLAG 16 Incorrect flags specified + * TNOREL 17 Orderly release message not found + * TNOTSUPPORT 18 Primitive not supported by provider + * TSTATECHNG 19 State is in process of changing + * TNOSTRUCTYPE 20 Unsupported structure type requested + * TBADNAME 21 Invalid transport provider name + * TBADQLEN 22 Listener queue length limit is zero + * TADDRBUSY 23 Transport address is in use + * TINDOUT 24 Outstanding connection indications + * TPROVMISMATCH 25 Listener-acceptor transport provider mismatch + * TRESQLEN 26 Connection acceptor has listen queue length + * limit greater than zero + * TRESADDR 27 Connection acceptor-listener addresses not + * same but required by transport + * TQFULL 28 Incoming connection queue is full + * TPROTO 29 Protocol error on transport primitive + * + */ + +/* + * The following are the events returned by t_look + */ +#define T_LISTEN 0x0001 /* connection indication received */ +#define T_CONNECT 0x0002 /* connect confirmation received */ +#define T_DATA 0x0004 /* normal data received */ +#define T_EXDATA 0x0008 /* expedited data received */ +#define T_DISCONNECT 0x0010 /* disconnect received */ +#define T_UDERR 0x0040 /* data gram error indication */ +#define T_ORDREL 0x0080 /* orderly release indication */ +#define T_GODATA 0x0100 /* sending normal data is again possible */ +#define T_GOEXDATA 0x0200 /* sending expedited data is again possible */ + +/* + * Flags for data primitives + */ +#define T_MORE 0x001 /* more data */ +#define T_EXPEDITED 0x002 /* expedited data */ +#define T_PUSH 0x004 /* send data immediately */ + +/* + * XTI error return + */ +#if defined(_REENTRANT) || defined(_TS_ERRNO) +extern int *__t_errno(); +#define t_errno (*(__t_errno())) +#else +extern int t_errno; +#endif /* defined(_REENTRANT) || defined(_TS_ERRNO) */ + + +/* + * The following are for t_sysconf() + */ +#ifndef T_IOV_MAX +#define T_IOV_MAX 16 /* Maximum number of scatter/gather buffers */ +#endif /* Should be <= IOV_MAX */ + +#ifndef _SC_T_IOV_MAX +#define _SC_T_IOV_MAX 79 /* Should be same in for use by */ +#endif /* sysconf() */ + +struct t_iovec { + void *iov_base; + size_t iov_len; +}; + +/* + * Translate source level interface to binary entry point names. + * + * Note: This is done to maintain co-existence of TLI and XTI + * interfaces which have identical names for most functions but + * different semantics. The XTI names are moved to the different + * prefix space in the ABI. The #ifdef is required to make use of + * of the compiler feature to allow redefinition of external names + * where available. Otherwise a simple #define is used when this + * header is used with other compilers. + * The use of #define also has the effect of renaming all names (not + * just function names) to the new name. The TLI function names + * (e.g. t_bind) can have identical names for structure names + * (e.g struct t_bind). Therefore, this redefinition of names needs + * to be before all structure and function name declarations in the header. + */ + +#ifdef __PRAGMA_REDEFINE_EXTNAME + +#if defined(_XOPEN_SOURCE) && !defined(_XPG5) +#pragma redefine_extname t_accept _xti_accept +#else +#pragma redefine_extname t_accept _xti_xns5_accept +#endif +#pragma redefine_extname t_alloc _xti_alloc +#pragma redefine_extname t_bind _xti_bind +#pragma redefine_extname t_close _xti_close +#pragma redefine_extname t_connect _xti_connect +#pragma redefine_extname t_error _xti_error +#pragma redefine_extname t_free _xti_free +#pragma redefine_extname t_getinfo _xti_getinfo +#pragma redefine_extname t_getstate _xti_getstate +#pragma redefine_extname t_getprotaddr _xti_getprotaddr +#pragma redefine_extname t_listen _xti_listen +#pragma redefine_extname t_look _xti_look +#pragma redefine_extname t_open _xti_open +#pragma redefine_extname t_optmgmt _xti_optmgmt +#pragma redefine_extname t_rcv _xti_rcv +#pragma redefine_extname t_rcvconnect _xti_rcvconnect +#pragma redefine_extname t_rcvdis _xti_rcvdis +#pragma redefine_extname t_rcvrel _xti_rcvrel +#pragma redefine_extname t_rcvreldata _xti_rcvreldata +#pragma redefine_extname t_rcvudata _xti_rcvudata +#pragma redefine_extname t_rcvuderr _xti_rcvuderr +#pragma redefine_extname t_rcvv _xti_rcvv +#pragma redefine_extname t_rcvvudata _xti_rcvvudata +#if defined(_XOPEN_SOURCE) && !defined(_XPG5) +#pragma redefine_extname t_snd _xti_snd +#else +#pragma redefine_extname t_snd _xti_xns5_snd +#endif +#pragma redefine_extname t_snddis _xti_snddis +#pragma redefine_extname t_sndrel _xti_sndrel +#pragma redefine_extname t_sndreldata _xti_sndreldata +#pragma redefine_extname t_sndudata _xti_sndudata +#pragma redefine_extname t_sndv _xti_sndv +#pragma redefine_extname t_sndvudata _xti_sndvudata +#pragma redefine_extname t_strerror _xti_strerror +#pragma redefine_extname t_sync _xti_sync +#pragma redefine_extname t_sysconf _xti_sysconf +#pragma redefine_extname t_unbind _xti_unbind + +#else /* __PRAGMA_REDEFINE_EXTNAME */ + +#if defined(_XOPEN_SOURCE) && !defined(_XPG5) +#define t_accept _xti_accept +#else +#define t_accept _xti_xns5_accept +#endif +#define t_alloc _xti_alloc +#define t_bind _xti_bind +#define t_close _xti_close +#define t_connect _xti_connect +#define t_error _xti_error +#define t_free _xti_free +#define t_getinfo _xti_getinfo +#define t_getstate _xti_getstate +#define t_getprotaddr _xti_getprotaddr +#define t_listen _xti_listen +#define t_look _xti_look +#define t_open _xti_open +#define t_optmgmt _xti_optmgmt +#define t_rcv _xti_rcv +#define t_rcvconnect _xti_rcvconnect +#define t_rcvdis _xti_rcvdis +#define t_rcvrel _xti_rcvrel +#define t_rcvreldata _xti_rcvreldata +#define t_rcvudata _xti_rcvudata +#define t_rcvuderr _xti_rcvuderr +#define t_rcvv _xti_rcvv +#define t_rcvvudata _xti_rcvvudata +#if defined(_XOPEN_SOURCE) && !defined(_XPG5) +#define t_snd _xti_snd +#else +#define t_snd _xti_xns5_snd +#endif +#define t_snddis _xti_snddis +#define t_sndrel _xti_sndrel +#define t_sndreldata _xti_sndreldata +#define t_sndudata _xti_sndudata +#define t_sndv _xti_sndv +#define t_sndvudata _xti_sndvudata +#define t_strerror _xti_strerror +#define t_sync _xti_sync +#define t_sysconf _xti_sysconf +#define t_unbind _xti_unbind + +#endif /* __PRAGMA_REDEFINE_EXTNAME */ + +/* + * protocol specific service limits + */ +struct t_info { + t_scalar_t addr; /* max size of protocol address */ + t_scalar_t options; /* max size of protocol options */ + t_scalar_t tsdu; /* max size of max transport service */ + /* data unit */ + t_scalar_t etsdu; /* max size of max expedited tsdu */ + t_scalar_t connect; /* max data for connection primitives */ + t_scalar_t discon; /* max data for disconnect primitives */ + t_scalar_t servtype; /* provider service type */ + t_scalar_t flags; /* other info about transport providers */ +}; + +/* + * Flags definitions for the t_info structure + */ +#define T_SENDZERO 0x001 /* supports 0-length TSDUs */ +#define T_ORDRELDATA 0x002 /* supports orderly release data */ + +/* + * netbuf structure + */ +struct netbuf { + unsigned int maxlen; + unsigned int len; +#if defined(_XPG5) + void *buf; +#else + char *buf; +#endif +}; + +/* + * t_opthdr structure + */ +struct t_opthdr { + t_uscalar_t len; /* total length of option */ + t_uscalar_t level; /* protocol level */ + t_uscalar_t name; /* option name */ + t_uscalar_t status; /* status value */ + /* followed by option value */ +}; + +/* + * t_bind - format of the addres and options arguments of bind + */ + +struct t_bind { + struct netbuf addr; + unsigned int qlen; +}; + +/* + * options management + */ +struct t_optmgmt { + struct netbuf opt; + t_scalar_t flags; +}; + +/* + * disconnect structure + */ +struct t_discon { + struct netbuf udata; /* user data */ + int reason; /* reason code */ + int sequence; /* sequence number */ +}; + +/* + * call structure + */ +struct t_call { + struct netbuf addr; /* address */ + struct netbuf opt; /* options */ + struct netbuf udata; /* user data */ + int sequence; /* sequence number */ +}; + +/* + * data gram structure + */ +struct t_unitdata { + struct netbuf addr; /* address */ + struct netbuf opt; /* options */ + struct netbuf udata; /* user data */ +}; + +/* + * unitdata error + */ +struct t_uderr { + struct netbuf addr; /* address */ + struct netbuf opt; /* options */ + t_scalar_t error; /* error code */ +}; + +/* + * The following are structure types used when dynamically + * allocating the above structures via t_structalloc(). + */ +#define T_BIND 1 /* struct t_bind */ +#define T_OPTMGMT 2 /* struct t_optmgmt */ +#define T_CALL 3 /* struct t_call */ +#define T_DIS 4 /* struct t_discon */ +#define T_UNITDATA 5 /* struct t_unitdata */ +#define T_UDERROR 6 /* struct t_uderr */ +#define T_INFO 7 /* struct t_info */ + +/* + * The following bits specify which fields of the above + * structures should be allocated by t_alloc(). + */ +#define T_ADDR 0x01 /* address */ +#define T_OPT 0x02 /* options */ +#define T_UDATA 0x04 /* user data */ +#define T_ALL 0xffff /* all the above fields */ + + +/* + * the following are the states for the user + */ + +#define T_UNINIT 0 /* uninitialized */ +#define T_UNBND 1 /* unbound */ +#define T_IDLE 2 /* idle */ +#define T_OUTCON 3 /* outgoing connection pending */ +#define T_INCON 4 /* incoming connection pending */ +#define T_DATAXFER 5 /* data transfer */ +#define T_OUTREL 6 /* outgoing release pending */ +#define T_INREL 7 /* incoming release pending */ + + +#define T_UNUSED -1 +#define T_NULL 0 + + +/* + * Allegedly general purpose constant. Used with (and needs to be bitwise + * distinct from) T_NOPROTECT, T_PASSIVEPROTECT and T_ACTIVEPROTECT + * which are OSI specific constants but part of this header (defined + * in which is included in this header for historical + * XTI specification reasons) + */ +#define T_ABSREQ 0x8000 + +/* + * General definitions for option management + * + * Multiple variable length options may be packed into a single option buffer. + * Each option consists of a fixed length header followed by variable length + * data. The header and data will have to be aligned at appropriate + * boundaries. The following macros are used to manipulate the options. + * + * Helper Macros: Macros beginning with a "_T" prefix are helper macros. + * They are private, not meant for public use and may + * change without notice. Users should use the standard + * XTI macros beginning with "T_" prefix + */ + +#define _T_OPT_HALIGN_SZ (sizeof (t_scalar_t)) /* Hdr Alignment size */ +#define _T_OPT_DALIGN_SZ (sizeof (int32_t)) /* Data Alignment size */ +#define _T_OPTHDR_SZ (sizeof (struct t_opthdr)) + +/* Align 'x' to the next 'asize' alignment boundary */ +#define _T_OPT_ALIGN(x, asize) \ + (((uintptr_t)(x) + ((asize) - 1L)) & ~((asize) - 1L)) + +/* Align 'x' to the next header alignment boundary */ +#define _T_OPTHDR_ALIGN(x) \ + (_T_OPT_ALIGN((x), _T_OPT_HALIGN_SZ)) + +/* Align 'x' to the next data alignment boundary */ +#define _T_OPTDATA_ALIGN(x) \ + (_T_OPT_ALIGN((x), _T_OPT_DALIGN_SZ)) + +/* + * struct t_opthdr *T_OPT_FIRSTHDR(struct netbuf *nbp): + * Get aligned start of first option header + * + * unsigned char *T_OPT_DATA(struct t_opthdr *tohp): + * Get aligned start of data part after option header + * + * struct t_opthdr *T_OPT_NEXTHDR(struct netbuf *nbp, struct t_opthdr *tohp): + * Skip to next option header + */ + +#define T_OPT_FIRSTHDR(nbp) \ + ((nbp)->len >= _T_OPTHDR_SZ ? (struct t_opthdr *)(nbp)->buf : \ + (struct t_opthdr *)0) + +#define T_OPT_DATA(tohp) \ + ((unsigned char *)_T_OPTDATA_ALIGN((char *)(tohp) + _T_OPTHDR_SZ)) + +#define _T_NEXTHDR(pbuf, buflen, popt) \ + (((char *)_T_OPTHDR_ALIGN((char *)(popt) + (popt)->len) + \ + _T_OPTHDR_SZ <= ((char *)(pbuf) + (buflen))) ? \ + (struct t_opthdr *)((char *)_T_OPTHDR_ALIGN((char *)(popt) + \ + (popt)->len)) : (struct t_opthdr *)0) + +#define T_OPT_NEXTHDR(nbp, tohp) (_T_NEXTHDR((nbp)->buf, (nbp)->len, (tohp))) + +#if !defined(_XPG5) +/* + * The macros below are meant for older applications for compatibility. + * New applications should use the T_OPT_* macros, obviating the need + * to explicitly use the T_ALIGN macro + * + * struct t_opthdr *OPT_NEXTHDR(char *pbuf, unsigned int buflen, + * struct t_opthdr *popt): + * Skip to next option header + */ +#define T_ALIGN(p) (((uintptr_t)(p) + (sizeof (t_scalar_t) - 1))\ + & ~(sizeof (t_scalar_t) - 1)) +#define OPT_NEXTHDR(pbuf, buflen, popt) (_T_NEXTHDR((pbuf), (buflen), (popt))) +#endif + +/* + * XTI LIBRARY FUNCTIONS + */ + +#if defined(_XOPEN_SOURCE) && !defined(_XPG5) +extern int t_accept(int, int, struct t_call *); +extern char *t_alloc(int, int, int); +extern int t_bind(int, struct t_bind *, struct t_bind *); +extern int t_connect(int, struct t_call *, struct t_call *); +extern int t_error(char *); +extern int t_free(char *, int); +extern int t_open(char *, int, struct t_info *); +extern int t_optmgmt(int, struct t_optmgmt *, struct t_optmgmt *); +extern int t_rcv(int, char *, unsigned int, int *); +extern int t_snd(int, char *, unsigned int, int); +extern int t_snddis(int, struct t_call *); +extern int t_sndudata(int, struct t_unitdata *); +extern char *t_strerror(int); +#else +extern int t_accept(int, int, const struct t_call *); +extern void *t_alloc(int, int, int); +extern int t_bind(int, const struct t_bind *, struct t_bind *); +extern int t_connect(int, const struct t_call *, struct t_call *); +extern int t_error(const char *); +extern int t_free(void *, int); +extern int t_open(const char *, int, struct t_info *); +extern int t_optmgmt(int, const struct t_optmgmt *, struct t_optmgmt *); +extern int t_rcv(int, void *, unsigned int, int *); +extern int t_snd(int, void *, unsigned int, int); +extern int t_snddis(int, const struct t_call *); +extern int t_sndudata(int, const struct t_unitdata *); +extern const char *t_strerror(int); +#endif +extern int t_close(int); +extern int t_getinfo(int, struct t_info *); +extern int t_getstate(int); +extern int t_getprotaddr(int, struct t_bind *, struct t_bind *); +extern int t_listen(int, struct t_call *); +extern int t_look(int); +extern int t_rcvconnect(int, struct t_call *); +extern int t_rcvdis(int, struct t_discon *); +extern int t_rcvrel(int); +extern int t_rcvreldata(int, struct t_discon *); +extern int t_rcvudata(int, struct t_unitdata *, int *); +extern int t_rcvuderr(int, struct t_uderr *); +extern int t_rcvv(int, struct t_iovec *, unsigned int, int *); +extern int t_rcvvudata(int, struct t_unitdata *, struct t_iovec *, + unsigned int, int *); +extern int t_sndrel(int); +extern int t_sndreldata(int, struct t_discon *); +extern int t_sndv(int, const struct t_iovec *, unsigned int, int); +extern int t_sndvudata(int, struct t_unitdata *, struct t_iovec *, + unsigned int); +extern int t_sync(int); +extern int t_sysconf(int); +extern int t_unbind(int); + +#ifdef __cplusplus +} +#endif + +#endif /* _XTI_H */ diff --git a/illumos-x86_64/usr/include/xti_inet.h b/illumos-x86_64/usr/include/xti_inet.h new file mode 100644 index 00000000..9a22bf8c --- /dev/null +++ b/illumos-x86_64/usr/include/xti_inet.h @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1998 Sun Microsystems, Inc. */ +/* All Rights Reserved */ + + +#ifndef _XTI_INET_H +#define _XTI_INET_H + +#include + +#endif /* _XTI_INET_H */ diff --git a/illumos-x86_64/usr/include/zconf.h b/illumos-x86_64/usr/include/zconf.h new file mode 100644 index 00000000..ede3c82e --- /dev/null +++ b/illumos-x86_64/usr/include/zconf.h @@ -0,0 +1,543 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols and init macros */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define crc32_combine_gen z_crc32_combine_gen +# define crc32_combine_gen64 z_crc32_combine_gen64 +# define crc32_combine_op z_crc32_combine_op +# define crc32_z z_crc32_z +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary +# define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateValidate z_inflateValidate +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# define uncompress2 z_uncompress2 +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +#ifdef Z_SOLO +# ifdef _WIN64 + typedef unsigned long long z_size_t; +# else + typedef unsigned long z_size_t; +# endif +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#if 1 /* was set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#if 1 /* was set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + +#ifdef _WIN32 +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#ifndef Z_HAVE_UNISTD_H +# ifdef __WATCOMC__ +# define Z_HAVE_UNISTD_H +# endif +#endif +#ifndef Z_HAVE_UNISTD_H +# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32) +# define Z_HAVE_UNISTD_H +# endif +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/illumos-x86_64/usr/include/zdict.h b/illumos-x86_64/usr/include/zdict.h new file mode 100644 index 00000000..599b7930 --- /dev/null +++ b/illumos-x86_64/usr/include/zdict.h @@ -0,0 +1,481 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +#ifndef ZSTD_ZDICT_H +#define ZSTD_ZDICT_H + + +/*====== Dependencies ======*/ +#include /* size_t */ + +#if defined (__cplusplus) +extern "C" { +#endif + +/* ===== ZDICTLIB_API : control library symbols visibility ===== */ +#ifndef ZDICTLIB_VISIBLE + /* Backwards compatibility with old macro name */ +# ifdef ZDICTLIB_VISIBILITY +# define ZDICTLIB_VISIBLE ZDICTLIB_VISIBILITY +# elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__) +# define ZDICTLIB_VISIBLE __attribute__ ((visibility ("default"))) +# else +# define ZDICTLIB_VISIBLE +# endif +#endif + +#ifndef ZDICTLIB_HIDDEN +# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__) +# define ZDICTLIB_HIDDEN __attribute__ ((visibility ("hidden"))) +# else +# define ZDICTLIB_HIDDEN +# endif +#endif + +#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) +# define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBLE +#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) +# define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ +#else +# define ZDICTLIB_API ZDICTLIB_VISIBLE +#endif + +/******************************************************************************* + * Zstd dictionary builder + * + * FAQ + * === + * Why should I use a dictionary? + * ------------------------------ + * + * Zstd can use dictionaries to improve compression ratio of small data. + * Traditionally small files don't compress well because there is very little + * repetition in a single sample, since it is small. But, if you are compressing + * many similar files, like a bunch of JSON records that share the same + * structure, you can train a dictionary on ahead of time on some samples of + * these files. Then, zstd can use the dictionary to find repetitions that are + * present across samples. This can vastly improve compression ratio. + * + * When is a dictionary useful? + * ---------------------------- + * + * Dictionaries are useful when compressing many small files that are similar. + * The larger a file is, the less benefit a dictionary will have. Generally, + * we don't expect dictionary compression to be effective past 100KB. And the + * smaller a file is, the more we would expect the dictionary to help. + * + * How do I use a dictionary? + * -------------------------- + * + * Simply pass the dictionary to the zstd compressor with + * `ZSTD_CCtx_loadDictionary()`. The same dictionary must then be passed to + * the decompressor, using `ZSTD_DCtx_loadDictionary()`. There are other + * more advanced functions that allow selecting some options, see zstd.h for + * complete documentation. + * + * What is a zstd dictionary? + * -------------------------- + * + * A zstd dictionary has two pieces: Its header, and its content. The header + * contains a magic number, the dictionary ID, and entropy tables. These + * entropy tables allow zstd to save on header costs in the compressed file, + * which really matters for small data. The content is just bytes, which are + * repeated content that is common across many samples. + * + * What is a raw content dictionary? + * --------------------------------- + * + * A raw content dictionary is just bytes. It doesn't have a zstd dictionary + * header, a dictionary ID, or entropy tables. Any buffer is a valid raw + * content dictionary. + * + * How do I train a dictionary? + * ---------------------------- + * + * Gather samples from your use case. These samples should be similar to each + * other. If you have several use cases, you could try to train one dictionary + * per use case. + * + * Pass those samples to `ZDICT_trainFromBuffer()` and that will train your + * dictionary. There are a few advanced versions of this function, but this + * is a great starting point. If you want to further tune your dictionary + * you could try `ZDICT_optimizeTrainFromBuffer_cover()`. If that is too slow + * you can try `ZDICT_optimizeTrainFromBuffer_fastCover()`. + * + * If the dictionary training function fails, that is likely because you + * either passed too few samples, or a dictionary would not be effective + * for your data. Look at the messages that the dictionary trainer printed, + * if it doesn't say too few samples, then a dictionary would not be effective. + * + * How large should my dictionary be? + * ---------------------------------- + * + * A reasonable dictionary size, the `dictBufferCapacity`, is about 100KB. + * The zstd CLI defaults to a 110KB dictionary. You likely don't need a + * dictionary larger than that. But, most use cases can get away with a + * smaller dictionary. The advanced dictionary builders can automatically + * shrink the dictionary for you, and select the smallest size that doesn't + * hurt compression ratio too much. See the `shrinkDict` parameter. + * A smaller dictionary can save memory, and potentially speed up + * compression. + * + * How many samples should I provide to the dictionary builder? + * ------------------------------------------------------------ + * + * We generally recommend passing ~100x the size of the dictionary + * in samples. A few thousand should suffice. Having too few samples + * can hurt the dictionaries effectiveness. Having more samples will + * only improve the dictionaries effectiveness. But having too many + * samples can slow down the dictionary builder. + * + * How do I determine if a dictionary will be effective? + * ----------------------------------------------------- + * + * Simply train a dictionary and try it out. You can use zstd's built in + * benchmarking tool to test the dictionary effectiveness. + * + * # Benchmark levels 1-3 without a dictionary + * zstd -b1e3 -r /path/to/my/files + * # Benchmark levels 1-3 with a dictionary + * zstd -b1e3 -r /path/to/my/files -D /path/to/my/dictionary + * + * When should I retrain a dictionary? + * ----------------------------------- + * + * You should retrain a dictionary when its effectiveness drops. Dictionary + * effectiveness drops as the data you are compressing changes. Generally, we do + * expect dictionaries to "decay" over time, as your data changes, but the rate + * at which they decay depends on your use case. Internally, we regularly + * retrain dictionaries, and if the new dictionary performs significantly + * better than the old dictionary, we will ship the new dictionary. + * + * I have a raw content dictionary, how do I turn it into a zstd dictionary? + * ------------------------------------------------------------------------- + * + * If you have a raw content dictionary, e.g. by manually constructing it, or + * using a third-party dictionary builder, you can turn it into a zstd + * dictionary by using `ZDICT_finalizeDictionary()`. You'll also have to + * provide some samples of the data. It will add the zstd header to the + * raw content, which contains a dictionary ID and entropy tables, which + * will improve compression ratio, and allow zstd to write the dictionary ID + * into the frame, if you so choose. + * + * Do I have to use zstd's dictionary builder? + * ------------------------------------------- + * + * No! You can construct dictionary content however you please, it is just + * bytes. It will always be valid as a raw content dictionary. If you want + * a zstd dictionary, which can improve compression ratio, use + * `ZDICT_finalizeDictionary()`. + * + * What is the attack surface of a zstd dictionary? + * ------------------------------------------------ + * + * Zstd is heavily fuzz tested, including loading fuzzed dictionaries, so + * zstd should never crash, or access out-of-bounds memory no matter what + * the dictionary is. However, if an attacker can control the dictionary + * during decompression, they can cause zstd to generate arbitrary bytes, + * just like if they controlled the compressed data. + * + ******************************************************************************/ + + +/*! ZDICT_trainFromBuffer(): + * Train a dictionary from an array of samples. + * Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4, + * f=20, and accel=1. + * Samples must be stored concatenated in a single flat buffer `samplesBuffer`, + * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order. + * The resulting dictionary will be saved into `dictBuffer`. + * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) + * or an error code, which can be tested with ZDICT_isError(). + * Note: Dictionary training will fail if there are not enough samples to construct a + * dictionary, or if most of the samples are too small (< 8 bytes being the lower limit). + * If dictionary training fails, you should use zstd without a dictionary, as the dictionary + * would've been ineffective anyways. If you believe your samples would benefit from a dictionary + * please open an issue with details, and we can look into it. + * Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB. + * Tips: In general, a reasonable dictionary has a size of ~ 100 KB. + * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`. + * In general, it's recommended to provide a few thousands samples, though this can vary a lot. + * It's recommended that total size of all samples be about ~x100 times the target size of dictionary. + */ +ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity, + const void* samplesBuffer, + const size_t* samplesSizes, unsigned nbSamples); + +typedef struct { + int compressionLevel; /**< optimize for a specific zstd compression level; 0 means default */ + unsigned notificationLevel; /**< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */ + unsigned dictID; /**< force dictID value; 0 means auto mode (32-bits random value) + * NOTE: The zstd format reserves some dictionary IDs for future use. + * You may use them in private settings, but be warned that they + * may be used by zstd in a public dictionary registry in the future. + * These dictionary IDs are: + * - low range : <= 32767 + * - high range : >= (2^31) + */ +} ZDICT_params_t; + +/*! ZDICT_finalizeDictionary(): + * Given a custom content as a basis for dictionary, and a set of samples, + * finalize dictionary by adding headers and statistics according to the zstd + * dictionary format. + * + * Samples must be stored concatenated in a flat buffer `samplesBuffer`, + * supplied with an array of sizes `samplesSizes`, providing the size of each + * sample in order. The samples are used to construct the statistics, so they + * should be representative of what you will compress with this dictionary. + * + * The compression level can be set in `parameters`. You should pass the + * compression level you expect to use in production. The statistics for each + * compression level differ, so tuning the dictionary for the compression level + * can help quite a bit. + * + * You can set an explicit dictionary ID in `parameters`, or allow us to pick + * a random dictionary ID for you, but we can't guarantee no collisions. + * + * The dstDictBuffer and the dictContent may overlap, and the content will be + * appended to the end of the header. If the header + the content doesn't fit in + * maxDictSize the beginning of the content is truncated to make room, since it + * is presumed that the most profitable content is at the end of the dictionary, + * since that is the cheapest to reference. + * + * `maxDictSize` must be >= max(dictContentSize, ZDICT_DICTSIZE_MIN). + * + * @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`), + * or an error code, which can be tested by ZDICT_isError(). + * Note: ZDICT_finalizeDictionary() will push notifications into stderr if + * instructed to, using notificationLevel>0. + * NOTE: This function currently may fail in several edge cases including: + * * Not enough samples + * * Samples are uncompressible + * * Samples are all exactly the same + */ +ZDICTLIB_API size_t ZDICT_finalizeDictionary(void* dstDictBuffer, size_t maxDictSize, + const void* dictContent, size_t dictContentSize, + const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples, + ZDICT_params_t parameters); + + +/*====== Helper functions ======*/ +ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */ +ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize); /* returns dict header size; returns a ZSTD error code on failure */ +ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode); +ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode); + +#if defined (__cplusplus) +} +#endif + +#endif /* ZSTD_ZDICT_H */ + +#if defined(ZDICT_STATIC_LINKING_ONLY) && !defined(ZSTD_ZDICT_H_STATIC) +#define ZSTD_ZDICT_H_STATIC + +#if defined (__cplusplus) +extern "C" { +#endif + +/* This can be overridden externally to hide static symbols. */ +#ifndef ZDICTLIB_STATIC_API +# if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) +# define ZDICTLIB_STATIC_API __declspec(dllexport) ZDICTLIB_VISIBLE +# elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) +# define ZDICTLIB_STATIC_API __declspec(dllimport) ZDICTLIB_VISIBLE +# else +# define ZDICTLIB_STATIC_API ZDICTLIB_VISIBLE +# endif +#endif + +/* ==================================================================================== + * The definitions in this section are considered experimental. + * They should never be used with a dynamic library, as they may change in the future. + * They are provided for advanced usages. + * Use them only in association with static linking. + * ==================================================================================== */ + +#define ZDICT_DICTSIZE_MIN 256 +/* Deprecated: Remove in v1.6.0 */ +#define ZDICT_CONTENTSIZE_MIN 128 + +/*! ZDICT_cover_params_t: + * k and d are the only required parameters. + * For others, value 0 means default. + */ +typedef struct { + unsigned k; /* Segment size : constraint: 0 < k : Reasonable range [16, 2048+] */ + unsigned d; /* dmer size : constraint: 0 < d <= k : Reasonable range [6, 16] */ + unsigned steps; /* Number of steps : Only used for optimization : 0 means default (40) : Higher means more parameters checked */ + unsigned nbThreads; /* Number of threads : constraint: 0 < nbThreads : 1 means single-threaded : Only used for optimization : Ignored if ZSTD_MULTITHREAD is not defined */ + double splitPoint; /* Percentage of samples used for training: Only used for optimization : the first nbSamples * splitPoint samples will be used to training, the last nbSamples * (1 - splitPoint) samples will be used for testing, 0 means default (1.0), 1.0 when all samples are used for both training and testing */ + unsigned shrinkDict; /* Train dictionaries to shrink in size starting from the minimum size and selects the smallest dictionary that is shrinkDictMaxRegression% worse than the largest dictionary. 0 means no shrinking and 1 means shrinking */ + unsigned shrinkDictMaxRegression; /* Sets shrinkDictMaxRegression so that a smaller dictionary can be at worse shrinkDictMaxRegression% worse than the max dict size dictionary. */ + ZDICT_params_t zParams; +} ZDICT_cover_params_t; + +typedef struct { + unsigned k; /* Segment size : constraint: 0 < k : Reasonable range [16, 2048+] */ + unsigned d; /* dmer size : constraint: 0 < d <= k : Reasonable range [6, 16] */ + unsigned f; /* log of size of frequency array : constraint: 0 < f <= 31 : 1 means default(20)*/ + unsigned steps; /* Number of steps : Only used for optimization : 0 means default (40) : Higher means more parameters checked */ + unsigned nbThreads; /* Number of threads : constraint: 0 < nbThreads : 1 means single-threaded : Only used for optimization : Ignored if ZSTD_MULTITHREAD is not defined */ + double splitPoint; /* Percentage of samples used for training: Only used for optimization : the first nbSamples * splitPoint samples will be used to training, the last nbSamples * (1 - splitPoint) samples will be used for testing, 0 means default (0.75), 1.0 when all samples are used for both training and testing */ + unsigned accel; /* Acceleration level: constraint: 0 < accel <= 10, higher means faster and less accurate, 0 means default(1) */ + unsigned shrinkDict; /* Train dictionaries to shrink in size starting from the minimum size and selects the smallest dictionary that is shrinkDictMaxRegression% worse than the largest dictionary. 0 means no shrinking and 1 means shrinking */ + unsigned shrinkDictMaxRegression; /* Sets shrinkDictMaxRegression so that a smaller dictionary can be at worse shrinkDictMaxRegression% worse than the max dict size dictionary. */ + + ZDICT_params_t zParams; +} ZDICT_fastCover_params_t; + +/*! ZDICT_trainFromBuffer_cover(): + * Train a dictionary from an array of samples using the COVER algorithm. + * Samples must be stored concatenated in a single flat buffer `samplesBuffer`, + * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order. + * The resulting dictionary will be saved into `dictBuffer`. + * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) + * or an error code, which can be tested with ZDICT_isError(). + * See ZDICT_trainFromBuffer() for details on failure modes. + * Note: ZDICT_trainFromBuffer_cover() requires about 9 bytes of memory for each input byte. + * Tips: In general, a reasonable dictionary has a size of ~ 100 KB. + * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`. + * In general, it's recommended to provide a few thousands samples, though this can vary a lot. + * It's recommended that total size of all samples be about ~x100 times the target size of dictionary. + */ +ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_cover( + void *dictBuffer, size_t dictBufferCapacity, + const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples, + ZDICT_cover_params_t parameters); + +/*! ZDICT_optimizeTrainFromBuffer_cover(): + * The same requirements as above hold for all the parameters except `parameters`. + * This function tries many parameter combinations and picks the best parameters. + * `*parameters` is filled with the best parameters found, + * dictionary constructed with those parameters is stored in `dictBuffer`. + * + * All of the parameters d, k, steps are optional. + * If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}. + * if steps is zero it defaults to its default value. + * If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]. + * + * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) + * or an error code, which can be tested with ZDICT_isError(). + * On success `*parameters` contains the parameters selected. + * See ZDICT_trainFromBuffer() for details on failure modes. + * Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread. + */ +ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_cover( + void* dictBuffer, size_t dictBufferCapacity, + const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples, + ZDICT_cover_params_t* parameters); + +/*! ZDICT_trainFromBuffer_fastCover(): + * Train a dictionary from an array of samples using a modified version of COVER algorithm. + * Samples must be stored concatenated in a single flat buffer `samplesBuffer`, + * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order. + * d and k are required. + * All other parameters are optional, will use default values if not provided + * The resulting dictionary will be saved into `dictBuffer`. + * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) + * or an error code, which can be tested with ZDICT_isError(). + * See ZDICT_trainFromBuffer() for details on failure modes. + * Note: ZDICT_trainFromBuffer_fastCover() requires 6 * 2^f bytes of memory. + * Tips: In general, a reasonable dictionary has a size of ~ 100 KB. + * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`. + * In general, it's recommended to provide a few thousands samples, though this can vary a lot. + * It's recommended that total size of all samples be about ~x100 times the target size of dictionary. + */ +ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer, + size_t dictBufferCapacity, const void *samplesBuffer, + const size_t *samplesSizes, unsigned nbSamples, + ZDICT_fastCover_params_t parameters); + +/*! ZDICT_optimizeTrainFromBuffer_fastCover(): + * The same requirements as above hold for all the parameters except `parameters`. + * This function tries many parameter combinations (specifically, k and d combinations) + * and picks the best parameters. `*parameters` is filled with the best parameters found, + * dictionary constructed with those parameters is stored in `dictBuffer`. + * All of the parameters d, k, steps, f, and accel are optional. + * If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}. + * if steps is zero it defaults to its default value. + * If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]. + * If f is zero, default value of 20 is used. + * If accel is zero, default value of 1 is used. + * + * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) + * or an error code, which can be tested with ZDICT_isError(). + * On success `*parameters` contains the parameters selected. + * See ZDICT_trainFromBuffer() for details on failure modes. + * Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread. + */ +ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer, + size_t dictBufferCapacity, const void* samplesBuffer, + const size_t* samplesSizes, unsigned nbSamples, + ZDICT_fastCover_params_t* parameters); + +typedef struct { + unsigned selectivityLevel; /* 0 means default; larger => select more => larger dictionary */ + ZDICT_params_t zParams; +} ZDICT_legacy_params_t; + +/*! ZDICT_trainFromBuffer_legacy(): + * Train a dictionary from an array of samples. + * Samples must be stored concatenated in a single flat buffer `samplesBuffer`, + * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order. + * The resulting dictionary will be saved into `dictBuffer`. + * `parameters` is optional and can be provided with values set to 0 to mean "default". + * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) + * or an error code, which can be tested with ZDICT_isError(). + * See ZDICT_trainFromBuffer() for details on failure modes. + * Tips: In general, a reasonable dictionary has a size of ~ 100 KB. + * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`. + * In general, it's recommended to provide a few thousands samples, though this can vary a lot. + * It's recommended that total size of all samples be about ~x100 times the target size of dictionary. + * Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0. + */ +ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_legacy( + void* dictBuffer, size_t dictBufferCapacity, + const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples, + ZDICT_legacy_params_t parameters); + + +/* Deprecation warnings */ +/* It is generally possible to disable deprecation warnings from compiler, + for example with -Wno-deprecated-declarations for gcc + or _CRT_SECURE_NO_WARNINGS in Visual. + Otherwise, it's also possible to manually define ZDICT_DISABLE_DEPRECATE_WARNINGS */ +#ifdef ZDICT_DISABLE_DEPRECATE_WARNINGS +# define ZDICT_DEPRECATED(message) /* disable deprecation warnings */ +#else +# define ZDICT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) +# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */ +# define ZDICT_DEPRECATED(message) [[deprecated(message)]] +# elif defined(__clang__) || (ZDICT_GCC_VERSION >= 405) +# define ZDICT_DEPRECATED(message) __attribute__((deprecated(message))) +# elif (ZDICT_GCC_VERSION >= 301) +# define ZDICT_DEPRECATED(message) __attribute__((deprecated)) +# elif defined(_MSC_VER) +# define ZDICT_DEPRECATED(message) __declspec(deprecated(message)) +# else +# pragma message("WARNING: You need to implement ZDICT_DEPRECATED for this compiler") +# define ZDICT_DEPRECATED(message) +# endif +#endif /* ZDICT_DISABLE_DEPRECATE_WARNINGS */ + +ZDICT_DEPRECATED("use ZDICT_finalizeDictionary() instead") +ZDICTLIB_STATIC_API +size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity, + const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples); + +#if defined (__cplusplus) +} +#endif + +#endif /* ZSTD_ZDICT_H_STATIC */ diff --git a/illumos-x86_64/usr/include/zlib.h b/illumos-x86_64/usr/include/zlib.h new file mode 100644 index 00000000..8d4b932e --- /dev/null +++ b/illumos-x86_64/usr/include/zlib.h @@ -0,0 +1,1938 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.3.1, January 22nd, 2024 + + Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 + (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.3.1" +#define ZLIB_VERNUM 0x1310 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 3 +#define ZLIB_VER_REVISION 1 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip and raw deflate streams in + memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in the case of corrupted input. +*/ + +typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); +typedef void (*free_func)(voidpf opaque, voidpf address); + +struct internal_state; + +typedef struct z_stream_s { + z_const Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total number of input bytes read so far */ + + Bytef *next_out; /* next output byte will go here */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total number of bytes output so far */ + + z_const char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text + for deflate, or the decoding state for inflate */ + uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. In that case, zlib is thread-safe. When zalloc and zfree are + Z_NULL on entry to the initialization function, they are set to internal + routines that use the standard library functions malloc() and free(). + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use by the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field for deflate() */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion(void); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. total_in, total_out, adler, and msg are initialized. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Generate more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary. Some output may be provided even if + flush is zero. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. See deflatePending(), + which can be used if desired to determine whether or not there is more output + in that case. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed + codes block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six when the flush marker begins, in order to avoid + repeated flush markers upon calling deflate() again when avail_out == 0. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this + function must be called again with Z_FINISH and more output space (updated + avail_out) but no more input data, until it returns with Z_STREAM_END or an + error. After deflate has returned Z_STREAM_END, the only possible operations + on the stream are deflateReset or deflateEnd. + + Z_FINISH can be used in the first deflate call after deflateInit if all the + compression is to be done in a single step. In order to complete in one + call, avail_out must be at least the value returned by deflateBound (see + below). Then deflate is guaranteed to return Z_STREAM_END. If not enough + output space is provided, deflate will not return Z_STREAM_END, and it must + be called again as described above. + + deflate() sets strm->adler to the Adler-32 checksum of all input read + so far (that is, total_in bytes). If a gzip stream is being generated, then + strm->adler will be the CRC-32 checksum of the input read so far. (See + deflateInit2 below.) + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is + considered binary. This field is only for information purposes and does not + affect the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL or the state was inadvertently written over + by the application), or Z_BUF_ERROR if no progress is possible (for example + avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and + deflate() can be called again with more input and more output space to + continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit(z_streamp strm); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. In the current version of inflate, the provided input is not + read or consumed. The allocation of a sliding window will be deferred to + the first call of inflate (if the decompression does not complete on the + first call). If zalloc and zfree are set to Z_NULL, inflateInit updates + them to use default allocation functions. total_in, total_out, adler, and + msg are initialized. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression. + Actual decompression will be done by inflate(). So next_in, and avail_in, + next_out, and avail_out are unused and unchanged. The current + implementation of inflateInit() does not process any header information -- + that is deferred until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), then next_in and avail_in are updated + accordingly, and processing will resume at this point for the next call of + inflate(). + + - Generate more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. If the + caller of inflate() does not provide both available input and available + output space, it is possible that there will be no progress made. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + To assist in this, on return inflate() always sets strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all of the uncompressed data for the + operation to complete. (The size of the uncompressed data may have been + saved by the compressor for this purpose.) The use of Z_FINISH is not + required to perform an inflation in one step. However it may be used to + inform inflate that a faster approach can be used for the single inflate() + call. Z_FINISH also informs inflate to not maintain a sliding window if the + stream completes, which reduces inflate's memory footprint. If the stream + does not complete, either because not all of the stream is provided or not + enough output space is provided, then a sliding window will be allocated and + inflate() can be called again to continue the operation as if Z_NO_FLUSH had + been used. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the effects of the flush parameter in this implementation are + on the return value of inflate() as noted below, when inflate() returns early + when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of + memory for a sliding window when Z_FINISH is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the Adler-32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the Adler-32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed Adler-32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained unless inflateGetHeader() is used. When processing + gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output + produced so far. The CRC-32 is checked against the gzip trailer, as is the + uncompressed length, modulo 2^32. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value, in which case strm->msg points to a string with a more specific + error), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL, or the state was inadvertently written over + by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR + if no progress was possible or if there was not enough room in the output + buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is to be attempted. +*/ + + +ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state + was inconsistent. +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy); + + This is another version of deflateInit with more compression options. The + fields zalloc, zfree and opaque must be initialized before by the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + For the current implementation of deflate(), a windowBits value of 8 (a + window size of 256 bytes) is not supported. As a result, a request for 8 + will result in 9 (a 512-byte window). In that case, providing 8 to + inflateInit2() will result in an error when the zlib header with 9 is + checked against the initialization of inflate(). The remedy is to not use 8 + with deflateInit2() with this initialization, or at least in that case use 9 + with inflateInit2(). + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute a check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to the appropriate value, + if the operating system was determined at compile time. If a gzip stream is + being written, strm->adler is a CRC-32 instead of an Adler-32. + + For raw deflate or gzip encoding, a request for a 256-byte window is + rejected as invalid, since only the zlib header provides a means of + transmitting the window size to the decompressor. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. When using the zlib format, this + function must be called immediately after deflateInit, deflateInit2 or + deflateReset, and before any call of deflate. When doing raw deflate, this + function must be called either before any call of deflate, or immediately + after the completion of a deflate block, i.e. after all input has been + consumed and all output has been delivered when using any of the flush + options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The + compressor and decompressor must use exactly the same dictionary (see + inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the Adler-32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler-32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + Adler-32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if not at a block boundary for raw deflate). deflateSetDictionary does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); +/* + Returns the sliding dictionary being maintained by deflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If deflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similarly, if dictLength is Z_NULL, then it is not set. + + deflateGetDictionary() may return a length less than the window size, even + when more than the window size in input has been provided. It may return up + to 258 bytes less in that case, due to how zlib's implementation of deflate + manages the sliding window and lookahead for matches, where matches can be + up to 258 bytes long. If the application needs the last window-size bytes of + input, then that would need to be saved by the application outside of zlib. + + deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, + z_streamp source); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset(z_streamp strm); +/* + This function is equivalent to deflateEnd followed by deflateInit, but + does not free and reallocate the internal compression state. The stream + will leave the compression level and any other attributes that may have been + set unchanged. total_in, total_out, adler, and msg are initialized. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams(z_streamp strm, + int level, + int strategy); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2(). This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression approach (which is a function of the level) or the + strategy is changed, and if there have been any deflate() calls since the + state was initialized or reset, then the input available so far is + compressed with the old level and strategy using deflate(strm, Z_BLOCK). + There are three approaches for the compression levels 0, 1..3, and 4..9 + respectively. The new level and strategy will take effect at the next call + of deflate(). + + If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does + not have enough output space to complete, then the parameter change will not + take effect. In this case, deflateParams() can be called again with the + same parameters and more output space to try again. + + In order to assure a change in the parameters on the first try, the + deflate stream should be flushed using deflate() with Z_BLOCK or other flush + request until strm.avail_out is not zero, before calling deflateParams(). + Then no more input data should be provided before the deflateParams() call. + If this is done, the old level and strategy will be applied to the data + compressed before deflateParams(), and the new level and strategy will be + applied to the data compressed after deflateParams(). + + deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream + state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if + there was not enough output space to complete the compression of the + available input data before a change in the strategy or approach. Note that + in the case of a Z_BUF_ERROR, the parameters are not changed. A return + value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be + retried with more output space. +*/ + +ZEXTERN int ZEXPORT deflateTune(z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, + uLong sourceLen); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). If that first deflate() call is provided the + sourceLen input bytes, an output buffer allocated to the size returned by + deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed + to return Z_STREAM_END. Note that it is possible for the compressed size to + be larger than the value returned by deflateBound() if flush options other + than Z_FINISH or Z_NO_FLUSH are used. +*/ + +ZEXTERN int ZEXPORT deflatePending(z_streamp strm, + unsigned *pending, + int *bits); +/* + deflatePending() returns the number of bytes and bits of output that have + been generated, but not yet provided in the available output. The bytes not + provided would be due to the available output space having being consumed. + The number of bits of output not provided are between 0 and 7, where they + await more bits to join them in order to fill out a full byte. If pending + or bits are Z_NULL, then those values are not set. + + deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. + */ + +ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, + int bits, + int value); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough + room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, + gz_headerp head); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to the current operating system, with no + extra, name, or comment fields. The gzip header is returned to the default + state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, + int windowBits); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an Adler-32 or a CRC-32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see + below), inflate() will *not* automatically decode concatenated gzip members. + inflate() will return Z_STREAM_END at the end of the gzip member. The state + would need to be reset to continue decoding a subsequent gzip member. This + *must* be done if there is more data after a gzip member, in order for the + decompression to be compliant with the gzip standard (RFC 1952). + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler-32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called at any + time to set the dictionary. If the provided dictionary is smaller than the + window and there is already data in the window, then the provided dictionary + will amend what's there. The application must insure that the dictionary + that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler-32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); +/* + Returns the sliding dictionary being maintained by inflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If inflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similarly, if dictLength is Z_NULL, then it is not set. + + inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateSync(z_streamp strm); +/* + Skips invalid compressed data until a possible full flush point (see above + for the description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync searches for a 00 00 FF FF pattern in the compressed data. + All full flush points have this pattern, but not all occurrences of this + pattern are full flush points. + + inflateSync returns Z_OK if a possible full flush point has been found, + Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point + has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. + In the success case, the application may save the current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, + z_streamp source); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset(z_streamp strm); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + total_in, total_out, adler, and msg are initialized. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, + int windowBits); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. If the window size is changed, then the + memory allocated for the window is freed, and the window will be reallocated + by inflate() if needed. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, + int bits, + int value); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark(z_streamp strm); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above, or -65536 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, + gz_headerp head); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, + unsigned char FAR *window); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the parameters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func)(void FAR *, + z_const unsigned char FAR * FAR *); +typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); + +ZEXTERN int ZEXPORT inflateBack(z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is potentially more efficient than + inflate() for file i/o applications, in that it avoids copying between the + output and the sliding window by simply making the window itself the output + buffer. inflate() can be faster on modern CPUs when used with large + buffers. inflateBack() trusts the application to not change the output + buffer passed by the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the default + behavior of inflate(), which expects a zlib header and trailer around the + deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero -- buf is ignored in that + case -- and inflateBack() will return a buffer error. inflateBack() will + call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. + out() should return zero on success, or non-zero on failure. If out() + returns non-zero, inflateBack() will return with an error. Neither in() nor + out() are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags(void); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: ZLIB_DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + +#ifndef Z_SOLO + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed data. compress() is equivalent to compress2() with a level + parameter of Z_DEFAULT_COMPRESSION. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed data. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed data. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In + the case where there is not enough room, uncompress() will fill the output + buffer with the uncompressed data up to that point. +*/ + +ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen); +/* + Same as uncompress, except that sourceLen is a pointer, where the + length of the source is *sourceLen. On return, *sourceLen is the number of + source bytes consumed. +*/ + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); + + Open the gzip (.gz) file at path for reading and decompressing, or + compressing and writing. The mode parameter is as in fopen ("rb" or "wb") + but can also include a compression level ("wb9") or a strategy: 'f' for + filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", + 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression + as in "wb9F". (See the description of deflateInit2 for more information + about the strategy parameter.) 'T' will request transparent writing or + appending with no compression and not using the gzip format. + + "a" can be used instead of "w" to request that the gzip stream that will + be written be appended to the file. "+" will result in an error, since + reading and writing to the same gzip file is not supported. The addition of + "x" when writing will create the file exclusively, which fails if the file + already exists. On systems that support it, the addition of "e" when + reading or writing will set the flag to close the file on an execve() call. + + These functions, as well as gzip, will read and decode a sequence of gzip + streams in a file. The append function of gzopen() can be used to create + such a file. (Also see gzflush() for another way to do this.) When + appending, gzopen does not test whether the file begins with a gzip stream, + nor does it look for the end of the gzip streams to begin appending. gzopen + will simply append a gzip stream to the existing file. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. When + reading, this will be detected automatically by looking for the magic two- + byte gzip header. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); +/* + Associate a gzFile with the file descriptor fd. File descriptors are + obtained from calls like open, dup, creat, pipe or fileno (if the file has + been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. If you are using fileno() to get the + file descriptor from a FILE *, then you will have to use dup() to avoid + double-close()ing the file descriptor. Both gzclose() and fclose() will + close the associated file descriptor, so they need to have different file + descriptors. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); +/* + Set the internal buffer size used by this library's functions for file to + size. The default buffer size is 8192 bytes. This function must be called + after gzopen() or gzdopen(), and before any other calls that read or write + the file. The buffer memory allocation is always deferred to the first read + or write. Three times that size in buffer space is allocated. A larger + buffer size of, for example, 64K or 128K bytes will noticeably increase the + speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); +/* + Dynamically update the compression level and strategy for file. See the + description of deflateInit2 for the meaning of these parameters. Previously + provided data is flushed before applying the parameter changes. + + gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not + opened for writing, Z_ERRNO if there is an error writing the flushed data, + or Z_MEM_ERROR if there is a memory allocation error. +*/ + +ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); +/* + Read and decompress up to len uncompressed bytes from file into buf. If + the input file is not in gzip format, gzread copies the given number of + bytes into the buffer directly from the file. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream. Any number of gzip streams may be + concatenated in the input file, and will all be decompressed by gzread(). + If something other than a gzip stream is encountered after a gzip stream, + that remaining trailing garbage is ignored (and no error is returned). + + gzread can be used to read a gzip file that is being concurrently written. + Upon reaching the end of the input, gzread will return with the available + data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then + gzclearerr can be used to clear the end of file indicator in order to permit + gzread to be tried again. Z_OK indicates that a gzip stream was completed + on the last gzread. Z_BUF_ERROR indicates that the input file ended in the + middle of a gzip stream. Note that gzread does not return -1 in the event + of an incomplete gzip stream. This error is deferred until gzclose(), which + will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip + stream. Alternatively, gzerror can be used before gzclose to detect this + case. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. If len is too large to fit in an int, + then nothing is read, -1 is returned, and the error state is set to + Z_STREAM_ERROR. +*/ + +ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, + gzFile file); +/* + Read and decompress up to nitems items of size size from file into buf, + otherwise operating as gzread() does. This duplicates the interface of + stdio's fread(), with size_t request and return types. If the library + defines size_t, then z_size_t is identical to size_t. If not, then z_size_t + is an unsigned integer type that can contain a pointer. + + gzfread() returns the number of full items read of size size, or zero if + the end of the file was reached and a full item could not be read, or if + there was an error. gzerror() must be consulted if zero is returned in + order to determine if there was an error. If the multiplication of size and + nitems overflows, i.e. the product does not fit in a z_size_t, then nothing + is read, zero is returned, and the error state is set to Z_STREAM_ERROR. + + In the event that the end of file is reached and only a partial item is + available at the end, i.e. the remaining uncompressed data length is not a + multiple of size, then the final partial item is nevertheless read into buf + and the end-of-file flag is set. The length of the partial item read is not + provided, but could be inferred from the result of gztell(). This behavior + is the same as the behavior of fread() implementations in common libraries, + but it prevents the direct use of gzfread() to read a concurrently written + file, resetting and retrying on end-of-file, when size is not 1. +*/ + +ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); +/* + Compress and write the len uncompressed bytes at buf to file. gzwrite + returns the number of uncompressed bytes written or 0 in case of error. +*/ + +ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, + z_size_t nitems, gzFile file); +/* + Compress and write nitems items of size size from buf to file, duplicating + the interface of stdio's fwrite(), with size_t request and return types. If + the library defines size_t, then z_size_t is identical to size_t. If not, + then z_size_t is an unsigned integer type that can contain a pointer. + + gzfwrite() returns the number of full items written of size size, or zero + if there was an error. If the multiplication of size and nitems overflows, + i.e. the product does not fit in a z_size_t, then nothing is written, zero + is returned, and the error state is set to Z_STREAM_ERROR. +*/ + +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); +/* + Convert, format, compress, and write the arguments (...) to file under + control of the string format, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or a negative zlib error code in case + of error. The number of uncompressed bytes written is limited to 8191, or + one less than the buffer size given to gzbuffer(). The caller should assure + that this limit is not exceeded. If it is exceeded, then gzprintf() will + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf(), + because the secure snprintf() or vsnprintf() functions were not available. + This can be determined using zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); +/* + Compress and write the given null-terminated string s to file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); +/* + Read and decompress bytes from file into buf, until len-1 characters are + read, or until a newline character is read and transferred to buf, or an + end-of-file condition is encountered. If any characters are read or if len + is one, the string is terminated with a null character. If no characters + are read due to an end-of-file or len is less than one, then the buffer is + left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc(gzFile file, int c); +/* + Compress and write c, converted to an unsigned char, into file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc(gzFile file); +/* + Read and decompress one byte from file. gzgetc returns this byte or -1 + in case of end of file or error. This is implemented as a macro for speed. + As such, it does not do all of the checking the other functions do. I.e. + it does not check to see if file is NULL, nor whether the structure file + points to has been clobbered or not. +*/ + +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); +/* + Push c back onto the stream for file to be read as the first character on + the next read. At least one character of push-back is always allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); +/* + Flush all pending output to file. The parameter flush is as in the + deflate() function. The return value is the zlib error number (see function + gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatenated gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, + z_off_t offset, int whence); + + Set the starting position to offset relative to whence for the next gzread + or gzwrite on file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind(gzFile file); +/* + Rewind file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell(gzFile file); + + Return the starting position for the next gzread or gzwrite on file. + This position represents a number of bytes in the uncompressed data stream, + and is zero when starting, even if appending or reading a gzip stream from + the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); + + Return the current compressed (actual) read or write offset of file. This + offset includes the count of bytes that precede the gzip stream, for example + when appending or when using gzdopen() for reading. When reading, the + offset does not include as yet unused buffered input. This information can + be used for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof(gzFile file); +/* + Return true (1) if the end-of-file indicator for file has been set while + reading, false (0) otherwise. Note that the end-of-file indicator is set + only if the read tried to go past the end of the input, but came up short. + Therefore, just like feof(), gzeof() may return false even if there is no + more data to read, in the event that the last read request was for the exact + number of bytes remaining in the input file. This will happen if the input + file size is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect(gzFile file); +/* + Return true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). + + When writing, gzdirect() returns true (1) if transparent writing was + requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: + gzdirect() is not needed when writing. Transparent writing must be + explicitly requested, so the application already knows the answer. When + linking statically, using gzdirect() will include all of the zlib code for + gzip file reading and decompression, which may not be desired.) +*/ + +ZEXTERN int ZEXPORT gzclose(gzFile file); +/* + Flush all pending output for file, if necessary, close file and + deallocate the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the + last read ended in the middle of a gzip stream, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r(gzFile file); +ZEXTERN int ZEXPORT gzclose_w(gzFile file); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); +/* + Return the error message for the last error which occurred on file. + errnum is set to zlib error number. If an error occurred in the file system + and not in the compression library, errnum is set to Z_ERRNO and the + application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr(gzFile file); +/* + Clear the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + +#endif /* !Z_SOLO */ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. An Adler-32 value is in the range of a 32-bit + unsigned integer. If buf is Z_NULL, this function returns the required + initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, + z_size_t len); +/* + Same as adler32(), but with a size_t length. +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, + z_off_t len2); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note + that the z_off_t type (like off_t) is a signed integer. If len2 is + negative, the result has no meaning or utility. +*/ + +ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. + If buf is Z_NULL, this function returns the required initial value for the + crc. Pre- and post-conditioning (one's complement) is performed within this + function so it shouldn't be done by the application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, + z_size_t len); +/* + Same as crc32(), but with a size_t length. +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. len2 must be non-negative. +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); + + Return the operator corresponding to length len2, to be used with + crc32_combine_op(). len2 must be non-negative. +*/ + +ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); +/* + Give the same result as crc32_combine(), using op in place of len2. op is + is generated from len2 by crc32_combine_gen(). This will be faster than + crc32_combine() if the generated op is used more than once. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, + const char *version, int stream_size); +ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size); +ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size); +#ifdef Z_PREFIX_SET +# define z_deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define z_inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#else +# define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#endif + +#ifndef Z_SOLO + +/* gzgetc() macro and its supporting function and exposed data structure. Note + * that the real internal state is much larger than the exposed structure. + * This abbreviated structure exposes just enough for the gzgetc() macro. The + * user should not mess with these exposed elements, since their names or + * behavior could change in the future, perhaps even capriciously. They can + * only be used by the gzgetc() macro. You have been warned. + */ +struct gzFile_s { + unsigned have; + unsigned char *next; + z_off64_t pos; +}; +ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +# define z_gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) +#else +# define gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) +#endif + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#ifdef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); +#endif + +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# ifdef Z_PREFIX_SET +# define z_gzopen z_gzopen64 +# define z_gzseek z_gzseek64 +# define z_gztell z_gztell64 +# define z_gzoffset z_gzoffset64 +# define z_adler32_combine z_adler32_combine64 +# define z_crc32_combine z_crc32_combine64 +# define z_crc32_combine_gen z_crc32_combine_gen64 +# else +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# define crc32_combine_gen crc32_combine_gen64 +# endif +# ifndef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); +#endif + +#else /* Z_SOLO */ + + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); + +#endif /* !Z_SOLO */ + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError(int); +ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); +ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); +ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); +ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); +ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); +#if defined(_WIN32) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, + const char *mode); +#endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, + const char *format, + va_list va); +# endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/illumos-x86_64/usr/include/zone.h b/illumos-x86_64/usr/include/zone.h new file mode 100644 index 00000000..f9ea8d4f --- /dev/null +++ b/illumos-x86_64/usr/include/zone.h @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * Copyright 2015 Joyent Inc. + */ + +#ifndef _ZONE_H +#define _ZONE_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Functions for mapping between id and name for active zones. + */ +extern zoneid_t getzoneid(void); +extern zoneid_t getzoneidbyname(const char *); +extern ssize_t getzonenamebyid(zoneid_t, char *, size_t); + +/* + * NOTE + * + * The remaining contents of this file are private to the implementation + * of Illumos and are subject to change at any time without notice, + * Applications using these interfaces may fail to run on future releases. + */ + +#define ZLOGIN_DISCONNECT 0x1 /* disconnect on zone halt */ +#define ZLOGIN_ZFD_EOF 0x2 /* EOF on ZFD */ + +extern int zonept(int, zoneid_t); +extern int zone_get_id(const char *, zoneid_t *); + +/* System call API */ +extern zoneid_t zone_create(const char *, const char *, + const struct priv_set *, const char *, size_t, const char *, size_t, int *, + int, int, const bslabel_t *, int, zoneid_t); +extern int zone_boot(zoneid_t); +extern int zone_destroy(zoneid_t); +extern ssize_t zone_getattr(zoneid_t, int, void *, size_t); +extern int zone_setattr(zoneid_t, int, void *, size_t); +extern int zone_enter(zoneid_t); +extern int zone_list(zoneid_t *, uint_t *); +extern int zone_shutdown(zoneid_t); +extern int zone_version(int *); +extern int zone_add_datalink(zoneid_t, datalink_id_t); +extern int zone_remove_datalink(zoneid_t, datalink_id_t); +extern int zone_check_datalink(zoneid_t *, datalink_id_t); +extern int zone_list_datalink(zoneid_t, int *, datalink_id_t *); +extern const char *zone_get_nroot(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZONE_H */ diff --git a/illumos-x86_64/usr/include/zonestat.h b/illumos-x86_64/usr/include/zonestat.h new file mode 100644 index 00000000..d717bdf0 --- /dev/null +++ b/illumos-x86_64/usr/include/zonestat.h @@ -0,0 +1,277 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _ZONESTAT_H +#define _ZONESTAT_H + + + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZS_IPTYPE_SHARED 1 +#define ZS_IPTYPE_EXCLUSIVE 2 + +#define ZS_CPUTYPE_DEFAULT_PSET 1 +#define ZS_CPUTYPE_POOL_PSET 2 +#define ZS_CPUTYPE_PSRSET_PSET 3 +#define ZS_CPUTYPE_DEDICATED 4 + + +#define ZS_LIMIT_NONE (UINT64_MAX) +#define ZS_PCT_NONE (UINT_MAX) +#define ZS_SHARES_UNLIMITED (UINT16_MAX) + +#define ZS_ZONENAME_MAX ZONENAME_MAX +#define ZS_PSETNAME_MAX (1024 + 1) +#define ZS_POOLNAME_MAX (1024 + 1) + +#define ZS_RESOURCE_TYPE_TIME 1 +#define ZS_RESOURCE_TYPE_COUNT 2 +#define ZS_RESOURCE_TYPE_BYTES 3 + +#define ZS_LIMIT_TYPE_TIME 1 +#define ZS_LIMIT_TYPE_COUNT 2 +#define ZS_LIMIT_TYPE_BYTES 3 + +#define ZS_PROP_TYPE_STRING 1 +#define ZS_PROP_TYPE_TIME 2 +#define ZS_PROP_TYPE_UINT64 3 +#define ZS_PROP_TYPE_INT64 4 +#define ZS_PROP_TYPE_UINT 5 +#define ZS_PROP_TYPE_INT 6 +#define ZS_PROP_TYPE_DOUBLE 7 + +#define ZS_SCHED_TS 0x1 +#define ZS_SCHED_IA 0x2 +#define ZS_SCHED_RT 0x4 +#define ZS_SCHED_FX 0x8 +#define ZS_SCHED_FX_60 0x10 +#define ZS_SCHED_FSS 0x20 +#define ZS_SCHED_CONFLICT 0x40 + +#define ZS_RESOURCE_PROP_CPU_TOTAL 1 +#define ZS_RESOURCE_PROP_CPU_ONLINE 2 +#define ZS_RESOURCE_PROP_CPU_LOAD_1MIN 3 +#define ZS_RESOURCE_PROP_CPU_LOAD_5MIN 4 +#define ZS_RESOURCE_PROP_CPU_LOAD_15MIN 5 + +#define ZS_RESOURCE_CPU 1 +#define ZS_RESOURCE_RAM_RSS 2 +#define ZS_RESOURCE_RAM_LOCKED 3 +#define ZS_RESOURCE_VM 4 +#define ZS_RESOURCE_DISK_SWAP 5 +#define ZS_RESOURCE_LWPS 6 +#define ZS_RESOURCE_PROCESSES 7 +#define ZS_RESOURCE_SHM_MEMORY 8 +#define ZS_RESOURCE_SHM_IDS 9 +#define ZS_RESOURCE_SEM_IDS 10 +#define ZS_RESOURCE_MSG_IDS 11 +#define ZS_RESOURCE_LOFI 12 + +#define ZS_USER_ALL 1 +#define ZS_USER_KERNEL 2 +#define ZS_USER_ZONES 3 +#define ZS_USER_FREE 4 + +#define ZS_LIMIT_CPU 1 +#define ZS_LIMIT_CPU_SHARES 2 +#define ZS_LIMIT_RAM_RSS 3 +#define ZS_LIMIT_RAM_LOCKED 4 +#define ZS_LIMIT_VM 5 +#define ZS_LIMIT_LWPS 6 +#define ZS_LIMIT_PROCESSES 7 +#define ZS_LIMIT_SHM_MEMORY 8 +#define ZS_LIMIT_SHM_IDS 9 +#define ZS_LIMIT_MSG_IDS 10 +#define ZS_LIMIT_SEM_IDS 11 +#define ZS_LIMIT_LOFI 12 + +#define ZS_ZONE_PROP_NAME 1 +#define ZS_ZONE_PROP_ID 2 +#define ZS_ZONE_PROP_IPTYPE 3 +#define ZS_ZONE_PROP_CPUTYPE 4 +#define ZS_ZONE_PROP_DEFAULT_SCHED 5 +#define ZS_ZONE_PROP_SCHEDULERS 6 +#define ZS_ZONE_PROP_CPU_SHARES 7 +#define ZS_ZONE_PROP_POOLNAME 8 +#define ZS_ZONE_PROP_PSETNAME 9 +#define ZS_ZONE_PROP_UPTIME 10 +#define ZS_ZONE_PROP_BOOTTIME 11 + +#define ZS_PSET_PROP_NAME 1 +#define ZS_PSET_PROP_ID 2 +#define ZS_PSET_PROP_CPUTYPE 3 +#define ZS_PSET_PROP_SIZE 4 +#define ZS_PSET_PROP_ONLINE 5 +#define ZS_PSET_PROP_MIN 6 +#define ZS_PSET_PROP_MAX 7 +#define ZS_PSET_PROP_CPU_SHARES 8 +#define ZS_PSET_PROP_SCHEDULERS 9 +#define ZS_PSET_PROP_CREATETIME 10 +#define ZS_PSET_PROP_LOAD_1MIN 11 +#define ZS_PSET_PROP_LOAD_5MIN 12 +#define ZS_PSET_PROP_LOAD_15MIN 13 + +#define ZS_PZ_PROP_SCHEDULERS 1 +#define ZS_PZ_PROP_CPU_SHARES 2 +#define ZS_PZ_PROP_CPU_CAP 4 + +#define ZS_COMPUTE_USAGE_INTERVAL 1 +#define ZS_COMPUTE_USAGE_TOTAL 2 +#define ZS_COMPUTE_USAGE_AVERAGE 3 +#define ZS_COMPUTE_USAGE_HIGH 4 + +#define ZS_COMPUTE_SET_TOTAL 1 +#define ZS_COMPUTE_SET_AVERAGE 2 +#define ZS_COMPUTE_SET_HIGH 3 + +#define ZS_PZ_PCT_PSET 1 +#define ZS_PZ_PCT_CPU_CAP 2 +#define ZS_PZ_PCT_PSET_SHARES 3 +#define ZS_PZ_PCT_CPU_SHARES 4 + + +/* Per-client handle to libzonestat */ +typedef struct zs_ctl zs_ctl_t; + +/* + * These usage structure contains the system's utilization (overall, zones, + * psets, memory) at a given point in time. + */ +typedef struct zs_usage zs_usage_t; + +/* + * The usage set is for computations on multiple usage structures to describe + * a range of time. + */ +typedef struct zs_usage_set zs_usage_set_t; + +/* + * The following structures desribe each zone, pset, and each zone's usage + * of each pset. Each usage structure (above) contains lists of these that + * can be traversed. + */ +typedef struct zs_zone zs_zone_t; +typedef struct zs_pset zs_pset_t; +typedef struct zs_pset_zone zs_pset_zone_t; + +/* + * Opaque structure for properties. + */ +typedef struct zs_property zs_property_t; + + +/* functions for opening/closing a handle for reading current usage */ +zs_ctl_t *zs_open(); +void zs_close(zs_ctl_t *); + +/* function for reading current resource usage */ +zs_usage_t *zs_usage_read(zs_ctl_t *); + +/* functions for manimulating usage data: zs_usage */ +zs_usage_t *zs_usage_compute(zs_usage_t *, zs_usage_t *, zs_usage_t *, int); +void zs_usage_free(zs_usage_t *); + +/* functions for manipulating sets of usage data: zs_usage_set */ +zs_usage_set_t *zs_usage_set_alloc(); +void zs_usage_set_free(zs_usage_set_t *); +int zs_usage_set_add(zs_usage_set_t *, zs_usage_t *); +int zs_usage_set_count(zs_usage_set_t *); +zs_usage_t *zs_usage_set_compute(zs_usage_set_t *, int); + +/* functions for overall system resources: zs_resource */ +void zs_resource_property(zs_usage_t *, int, int, zs_property_t *); +int zs_resource_type(int); +uint64_t zs_resource_total_uint64(zs_usage_t *, int); +uint64_t zs_resource_used_uint64(zs_usage_t *, int, int); +uint64_t zs_resource_used_zone_uint64(zs_zone_t *, int); +void zs_resource_total_time(zs_usage_t *, int, timestruc_t *); +void zs_resource_used_time(zs_usage_t *, int, int, timestruc_t *); +void zs_resource_used_zone_time(zs_zone_t *, int, timestruc_t *); +uint_t zs_resource_used_pct(zs_usage_t *, int, int); +uint_t zs_resource_used_zone_pct(zs_zone_t *, int); + +/* functions for individual zone usage: zs_zone */ +int zs_zone_list(zs_usage_t *, zs_zone_t **, int); +zs_zone_t *zs_zone_first(zs_usage_t *); +zs_zone_t *zs_zone_next(zs_usage_t *, zs_zone_t *); +void zs_zone_property(zs_zone_t *, int, zs_property_t *); +int zs_zone_limit_type(int); +uint64_t zs_zone_limit_uint64(zs_zone_t *, int); +uint64_t zs_zone_limit_used_uint64(zs_zone_t *, int); +void zs_zone_limit_time(zs_zone_t *, int, timestruc_t *); +void zs_zone_limit_used_time(zs_zone_t *, int, timestruc_t *); +uint_t zs_zone_limit_used_pct(zs_zone_t *, int); + +/* functions for individual psets: zs_pset_list */ +int zs_pset_list(zs_usage_t *, zs_pset_t **, int); +zs_pset_t *zs_pset_first(zs_usage_t *); +zs_pset_t *zs_pset_next(zs_usage_t *, zs_pset_t *); +void zs_pset_property(zs_pset_t *, int, zs_property_t *); +void zs_pset_total_time(zs_pset_t *, timestruc_t *); +uint64_t zs_pset_total_cpus(zs_pset_t *); +void zs_pset_used_time(zs_pset_t *, int, timestruc_t *); +uint64_t zs_pset_used_cpus(zs_pset_t *, int); +uint_t zs_pset_used_pct(zs_pset_t *, int); + +/* functions for a pset's per-zone usage: zs_pset_zone */ +int zs_pset_zone_list(zs_pset_t *, zs_pset_zone_t **, int); +zs_pset_zone_t *zs_pset_zone_first(zs_pset_t *); +zs_pset_zone_t *zs_pset_zone_next(zs_pset_t *, zs_pset_zone_t *); +zs_zone_t *zs_pset_zone_get_zone(zs_pset_zone_t *); +zs_pset_t *zs_pset_zone_get_pset(zs_pset_zone_t *); +void zs_pset_zone_property(zs_pset_zone_t *, int, zs_property_t *); +void zs_pset_zone_used_time(zs_pset_zone_t *, timestruc_t *); +uint64_t zs_pset_zone_used_cpus(zs_pset_zone_t *); +uint_t zs_pset_zone_used_pct(zs_pset_zone_t *, int); + +/* functions for accessing properties */ +zs_property_t *zs_property_alloc(); +size_t zs_property_size(); +void zs_property_free(zs_property_t *); +int zs_property_type(zs_property_t *); +int zs_property_id(zs_property_t *); +char *zs_property_string(zs_property_t *); +double zs_property_double(zs_property_t *); +void zs_property_time(zs_property_t *, timestruc_t *); +uint64_t zs_property_uint64(zs_property_t *); +int64_t zs_property_int64(zs_property_t *); +uint_t zs_property_uint(zs_property_t *); +int zs_property_int(zs_property_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZONESTAT_H */ diff --git a/illumos-x86_64/usr/include/zstd.h b/illumos-x86_64/usr/include/zstd.h new file mode 100644 index 00000000..b8c0644a --- /dev/null +++ b/illumos-x86_64/usr/include/zstd.h @@ -0,0 +1,3198 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +#ifndef ZSTD_H_235446 +#define ZSTD_H_235446 + + +/* ====== Dependencies ======*/ +#include /* size_t */ + +#include "zstd_errors.h" /* list of errors */ +#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY) +#include /* INT_MAX */ +#endif /* ZSTD_STATIC_LINKING_ONLY */ + +#if defined (__cplusplus) +extern "C" { +#endif + +/* ===== ZSTDLIB_API : control library symbols visibility ===== */ +#ifndef ZSTDLIB_VISIBLE + /* Backwards compatibility with old macro name */ +# ifdef ZSTDLIB_VISIBILITY +# define ZSTDLIB_VISIBLE ZSTDLIB_VISIBILITY +# elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__) +# define ZSTDLIB_VISIBLE __attribute__ ((visibility ("default"))) +# else +# define ZSTDLIB_VISIBLE +# endif +#endif + +#ifndef ZSTDLIB_HIDDEN +# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__) +# define ZSTDLIB_HIDDEN __attribute__ ((visibility ("hidden"))) +# else +# define ZSTDLIB_HIDDEN +# endif +#endif + +#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) +# define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBLE +#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) +# define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ +#else +# define ZSTDLIB_API ZSTDLIB_VISIBLE +#endif + +/* Deprecation warnings : + * Should these warnings be a problem, it is generally possible to disable them, + * typically with -Wno-deprecated-declarations for gcc or _CRT_SECURE_NO_WARNINGS in Visual. + * Otherwise, it's also possible to define ZSTD_DISABLE_DEPRECATE_WARNINGS. + */ +#ifdef ZSTD_DISABLE_DEPRECATE_WARNINGS +# define ZSTD_DEPRECATED(message) /* disable deprecation warnings */ +#else +# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */ +# define ZSTD_DEPRECATED(message) [[deprecated(message)]] +# elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__) || defined(__IAR_SYSTEMS_ICC__) +# define ZSTD_DEPRECATED(message) __attribute__((deprecated(message))) +# elif defined(__GNUC__) && (__GNUC__ >= 3) +# define ZSTD_DEPRECATED(message) __attribute__((deprecated)) +# elif defined(_MSC_VER) +# define ZSTD_DEPRECATED(message) __declspec(deprecated(message)) +# else +# pragma message("WARNING: You need to implement ZSTD_DEPRECATED for this compiler") +# define ZSTD_DEPRECATED(message) +# endif +#endif /* ZSTD_DISABLE_DEPRECATE_WARNINGS */ + + +/******************************************************************************* + Introduction + + zstd, short for Zstandard, is a fast lossless compression algorithm, targeting + real-time compression scenarios at zlib-level and better compression ratios. + The zstd compression library provides in-memory compression and decompression + functions. + + The library supports regular compression levels from 1 up to ZSTD_maxCLevel(), + which is currently 22. Levels >= 20, labeled `--ultra`, should be used with + caution, as they require more memory. The library also offers negative + compression levels, which extend the range of speed vs. ratio preferences. + The lower the level, the faster the speed (at the cost of compression). + + Compression can be done in: + - a single step (described as Simple API) + - a single step, reusing a context (described as Explicit context) + - unbounded multiple steps (described as Streaming compression) + + The compression ratio achievable on small data can be highly improved using + a dictionary. Dictionary compression can be performed in: + - a single step (described as Simple dictionary API) + - a single step, reusing a dictionary (described as Bulk-processing + dictionary API) + + Advanced experimental functions can be accessed using + `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h. + + Advanced experimental APIs should never be used with a dynamically-linked + library. They are not "stable"; their definitions or signatures may change in + the future. Only static linking is allowed. +*******************************************************************************/ + +/*------ Version ------*/ +#define ZSTD_VERSION_MAJOR 1 +#define ZSTD_VERSION_MINOR 5 +#define ZSTD_VERSION_RELEASE 7 +#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE) + +/*! ZSTD_versionNumber() : + * Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE). */ +ZSTDLIB_API unsigned ZSTD_versionNumber(void); + +#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE +#define ZSTD_QUOTE(str) #str +#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str) +#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION) + +/*! ZSTD_versionString() : + * Return runtime library version, like "1.4.5". Requires v1.3.0+. */ +ZSTDLIB_API const char* ZSTD_versionString(void); + +/* ************************************* + * Default constant + ***************************************/ +#ifndef ZSTD_CLEVEL_DEFAULT +# define ZSTD_CLEVEL_DEFAULT 3 +#endif + +/* ************************************* + * Constants + ***************************************/ + +/* All magic numbers are supposed read/written to/from files/memory using little-endian convention */ +#define ZSTD_MAGICNUMBER 0xFD2FB528 /* valid since v0.8.0 */ +#define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* valid since v0.7.0 */ +#define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50 /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */ +#define ZSTD_MAGIC_SKIPPABLE_MASK 0xFFFFFFF0 + +#define ZSTD_BLOCKSIZELOG_MAX 17 +#define ZSTD_BLOCKSIZE_MAX (1<= ZSTD_compressBound(srcSize)` guarantees that zstd will have + * enough space to successfully compress the data. + * @return : compressed size written into `dst` (<= `dstCapacity), + * or an error code if it fails (which can be tested using ZSTD_isError()). */ +ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + int compressionLevel); + +/*! ZSTD_decompress() : + * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames. + * Multiple compressed frames can be decompressed at once with this method. + * The result will be the concatenation of all decompressed frames, back to back. + * `dstCapacity` is an upper bound of originalSize to regenerate. + * First frame's decompressed size can be extracted using ZSTD_getFrameContentSize(). + * If maximum upper bound isn't known, prefer using streaming mode to decompress data. + * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`), + * or an errorCode if it fails (which can be tested using ZSTD_isError()). */ +ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity, + const void* src, size_t compressedSize); + + +/*====== Decompression helper functions ======*/ + +/*! ZSTD_getFrameContentSize() : requires v1.3.0+ + * `src` should point to the start of a ZSTD encoded frame. + * `srcSize` must be at least as large as the frame header. + * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough. + * @return : - decompressed size of `src` frame content, if known + * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined + * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) + * note 1 : a 0 return value means the frame is valid but "empty". + * When invoking this method on a skippable frame, it will return 0. + * note 2 : decompressed size is an optional field, it may not be present (typically in streaming mode). + * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. + * In which case, it's necessary to use streaming mode to decompress data. + * Optionally, application can rely on some implicit limit, + * as ZSTD_decompress() only needs an upper bound of decompressed size. + * (For example, data could be necessarily cut into blocks <= 16 KB). + * note 3 : decompressed size is always present when compression is completed using single-pass functions, + * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict(). + * note 4 : decompressed size can be very large (64-bits value), + * potentially larger than what local system can handle as a single memory segment. + * In which case, it's necessary to use streaming mode to decompress data. + * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified. + * Always ensure return value fits within application's authorized limits. + * Each application can set its own limits. + * note 6 : This function replaces ZSTD_getDecompressedSize() */ +#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1) +#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2) +ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize); + +/*! ZSTD_getDecompressedSize() (obsolete): + * This function is now obsolete, in favor of ZSTD_getFrameContentSize(). + * Both functions work the same way, but ZSTD_getDecompressedSize() blends + * "empty", "unknown" and "error" results to the same return value (0), + * while ZSTD_getFrameContentSize() gives them separate return values. + * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */ +ZSTD_DEPRECATED("Replaced by ZSTD_getFrameContentSize") +ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize); + +/*! ZSTD_findFrameCompressedSize() : Requires v1.4.0+ + * `src` should point to the start of a ZSTD frame or skippable frame. + * `srcSize` must be >= first frame size + * @return : the compressed size of the first frame starting at `src`, + * suitable to pass as `srcSize` to `ZSTD_decompress` or similar, + * or an error code if input is invalid + * Note 1: this method is called _find*() because it's not enough to read the header, + * it may have to scan through the frame's content, to reach its end. + * Note 2: this method also works with Skippable Frames. In which case, + * it returns the size of the complete skippable frame, + * which is always equal to its content size + 8 bytes for headers. */ +ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize); + + +/*====== Compression helper functions ======*/ + +/*! ZSTD_compressBound() : + * maximum compressed size in worst case single-pass scenario. + * When invoking `ZSTD_compress()`, or any other one-pass compression function, + * it's recommended to provide @dstCapacity >= ZSTD_compressBound(srcSize) + * as it eliminates one potential failure scenario, + * aka not enough room in dst buffer to write the compressed frame. + * Note : ZSTD_compressBound() itself can fail, if @srcSize >= ZSTD_MAX_INPUT_SIZE . + * In which case, ZSTD_compressBound() will return an error code + * which can be tested using ZSTD_isError(). + * + * ZSTD_COMPRESSBOUND() : + * same as ZSTD_compressBound(), but as a macro. + * It can be used to produce constants, which can be useful for static allocation, + * for example to size a static array on stack. + * Will produce constant value 0 if srcSize is too large. + */ +#define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00ULL : 0xFF00FF00U) +#define ZSTD_COMPRESSBOUND(srcSize) (((size_t)(srcSize) >= ZSTD_MAX_INPUT_SIZE) ? 0 : (srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */ +ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */ + + +/*====== Error helper functions ======*/ +/* ZSTD_isError() : + * Most ZSTD_* functions returning a size_t value can be tested for error, + * using ZSTD_isError(). + * @return 1 if error, 0 otherwise + */ +ZSTDLIB_API unsigned ZSTD_isError(size_t result); /*!< tells if a `size_t` function result is an error code */ +ZSTDLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult); /* convert a result into an error code, which can be compared to error enum list */ +ZSTDLIB_API const char* ZSTD_getErrorName(size_t result); /*!< provides readable string from a function result */ +ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed, requires v1.4.0+ */ +ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */ +ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */ + + +/*************************************** +* Explicit context +***************************************/ +/*= Compression context + * When compressing many times, + * it is recommended to allocate a compression context just once, + * and reuse it for each successive compression operation. + * This will make the workload easier for system's memory. + * Note : re-using context is just a speed / resource optimization. + * It doesn't change the compression ratio, which remains identical. + * Note 2: For parallel execution in multi-threaded environments, + * use one different context per thread . + */ +typedef struct ZSTD_CCtx_s ZSTD_CCtx; +ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void); +ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* compatible with NULL pointer */ + +/*! ZSTD_compressCCtx() : + * Same as ZSTD_compress(), using an explicit ZSTD_CCtx. + * Important : in order to mirror `ZSTD_compress()` behavior, + * this function compresses at the requested compression level, + * __ignoring any other advanced parameter__ . + * If any advanced parameter was set using the advanced API, + * they will all be reset. Only @compressionLevel remains. + */ +ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + int compressionLevel); + +/*= Decompression context + * When decompressing many times, + * it is recommended to allocate a context only once, + * and reuse it for each successive compression operation. + * This will make workload friendlier for system's memory. + * Use one context per thread for parallel execution. */ +typedef struct ZSTD_DCtx_s ZSTD_DCtx; +ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void); +ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer */ + +/*! ZSTD_decompressDCtx() : + * Same as ZSTD_decompress(), + * requires an allocated ZSTD_DCtx. + * Compatible with sticky parameters (see below). + */ +ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize); + + +/********************************************* +* Advanced compression API (Requires v1.4.0+) +**********************************************/ + +/* API design : + * Parameters are pushed one by one into an existing context, + * using ZSTD_CCtx_set*() functions. + * Pushed parameters are sticky : they are valid for next compressed frame, and any subsequent frame. + * "sticky" parameters are applicable to `ZSTD_compress2()` and `ZSTD_compressStream*()` ! + * __They do not apply to one-shot variants such as ZSTD_compressCCtx()__ . + * + * It's possible to reset all parameters to "default" using ZSTD_CCtx_reset(). + * + * This API supersedes all other "advanced" API entry points in the experimental section. + * In the future, we expect to remove API entry points from experimental which are redundant with this API. + */ + + +/* Compression strategies, listed from fastest to strongest */ +typedef enum { ZSTD_fast=1, + ZSTD_dfast=2, + ZSTD_greedy=3, + ZSTD_lazy=4, + ZSTD_lazy2=5, + ZSTD_btlazy2=6, + ZSTD_btopt=7, + ZSTD_btultra=8, + ZSTD_btultra2=9 + /* note : new strategies _might_ be added in the future. + Only the order (from fast to strong) is guaranteed */ +} ZSTD_strategy; + +typedef enum { + + /* compression parameters + * Note: When compressing with a ZSTD_CDict these parameters are superseded + * by the parameters used to construct the ZSTD_CDict. + * See ZSTD_CCtx_refCDict() for more info (superseded-by-cdict). */ + ZSTD_c_compressionLevel=100, /* Set compression parameters according to pre-defined cLevel table. + * Note that exact compression parameters are dynamically determined, + * depending on both compression level and srcSize (when known). + * Default level is ZSTD_CLEVEL_DEFAULT==3. + * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT. + * Note 1 : it's possible to pass a negative compression level. + * Note 2 : setting a level does not automatically set all other compression parameters + * to default. Setting this will however eventually dynamically impact the compression + * parameters which have not been manually set. The manually set + * ones will 'stick'. */ + /* Advanced compression parameters : + * It's possible to pin down compression parameters to some specific values. + * In which case, these values are no longer dynamically selected by the compressor */ + ZSTD_c_windowLog=101, /* Maximum allowed back-reference distance, expressed as power of 2. + * This will set a memory budget for streaming decompression, + * with larger values requiring more memory + * and typically compressing more. + * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX. + * Special: value 0 means "use default windowLog". + * Note: Using a windowLog greater than ZSTD_WINDOWLOG_LIMIT_DEFAULT + * requires explicitly allowing such size at streaming decompression stage. */ + ZSTD_c_hashLog=102, /* Size of the initial probe table, as a power of 2. + * Resulting memory usage is (1 << (hashLog+2)). + * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX. + * Larger tables improve compression ratio of strategies <= dFast, + * and improve speed of strategies > dFast. + * Special: value 0 means "use default hashLog". */ + ZSTD_c_chainLog=103, /* Size of the multi-probe search table, as a power of 2. + * Resulting memory usage is (1 << (chainLog+2)). + * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX. + * Larger tables result in better and slower compression. + * This parameter is useless for "fast" strategy. + * It's still useful when using "dfast" strategy, + * in which case it defines a secondary probe table. + * Special: value 0 means "use default chainLog". */ + ZSTD_c_searchLog=104, /* Number of search attempts, as a power of 2. + * More attempts result in better and slower compression. + * This parameter is useless for "fast" and "dFast" strategies. + * Special: value 0 means "use default searchLog". */ + ZSTD_c_minMatch=105, /* Minimum size of searched matches. + * Note that Zstandard can still find matches of smaller size, + * it just tweaks its search algorithm to look for this size and larger. + * Larger values increase compression and decompression speed, but decrease ratio. + * Must be clamped between ZSTD_MINMATCH_MIN and ZSTD_MINMATCH_MAX. + * Note that currently, for all strategies < btopt, effective minimum is 4. + * , for all strategies > fast, effective maximum is 6. + * Special: value 0 means "use default minMatchLength". */ + ZSTD_c_targetLength=106, /* Impact of this field depends on strategy. + * For strategies btopt, btultra & btultra2: + * Length of Match considered "good enough" to stop search. + * Larger values make compression stronger, and slower. + * For strategy fast: + * Distance between match sampling. + * Larger values make compression faster, and weaker. + * Special: value 0 means "use default targetLength". */ + ZSTD_c_strategy=107, /* See ZSTD_strategy enum definition. + * The higher the value of selected strategy, the more complex it is, + * resulting in stronger and slower compression. + * Special: value 0 means "use default strategy". */ + + ZSTD_c_targetCBlockSize=130, /* v1.5.6+ + * Attempts to fit compressed block size into approximately targetCBlockSize. + * Bound by ZSTD_TARGETCBLOCKSIZE_MIN and ZSTD_TARGETCBLOCKSIZE_MAX. + * Note that it's not a guarantee, just a convergence target (default:0). + * No target when targetCBlockSize == 0. + * This is helpful in low bandwidth streaming environments to improve end-to-end latency, + * when a client can make use of partial documents (a prominent example being Chrome). + * Note: this parameter is stable since v1.5.6. + * It was present as an experimental parameter in earlier versions, + * but it's not recommended using it with earlier library versions + * due to massive performance regressions. + */ + /* LDM mode parameters */ + ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching. + * This parameter is designed to improve compression ratio + * for large inputs, by finding large matches at long distance. + * It increases memory usage and window size. + * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB + * except when expressly set to a different value. + * Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and + * compression strategy >= ZSTD_btopt (== compression level 16+) */ + ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2. + * Larger values increase memory usage and compression ratio, + * but decrease compression speed. + * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX + * default: windowlog - 7. + * Special: value 0 means "automatically determine hashlog". */ + ZSTD_c_ldmMinMatch=162, /* Minimum match size for long distance matcher. + * Larger/too small values usually decrease compression ratio. + * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX. + * Special: value 0 means "use default value" (default: 64). */ + ZSTD_c_ldmBucketSizeLog=163, /* Log size of each bucket in the LDM hash table for collision resolution. + * Larger values improve collision resolution but decrease compression speed. + * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX. + * Special: value 0 means "use default value" (default: 3). */ + ZSTD_c_ldmHashRateLog=164, /* Frequency of inserting/looking up entries into the LDM hash table. + * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN). + * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage. + * Larger values improve compression speed. + * Deviating far from default value will likely result in a compression ratio decrease. + * Special: value 0 means "automatically determine hashRateLog". */ + + /* frame parameters */ + ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1) + * Content size must be known at the beginning of compression. + * This is automatically the case when using ZSTD_compress2(), + * For streaming scenarios, content size must be provided with ZSTD_CCtx_setPledgedSrcSize() */ + ZSTD_c_checksumFlag=201, /* A 32-bits checksum of content is written at end of frame (default:0) */ + ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */ + + /* multi-threading parameters */ + /* These parameters are only active if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD). + * Otherwise, trying to set any other value than default (0) will be a no-op and return an error. + * In a situation where it's unknown if the linked library supports multi-threading or not, + * setting ZSTD_c_nbWorkers to any value >= 1 and consulting the return value provides a quick way to check this property. + */ + ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel. + * When nbWorkers >= 1, triggers asynchronous mode when invoking ZSTD_compressStream*() : + * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller, + * while compression is performed in parallel, within worker thread(s). + * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end : + * in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call). + * More workers improve speed, but also increase memory usage. + * Default value is `0`, aka "single-threaded mode" : no worker is spawned, + * compression is performed inside Caller's thread, and all invocations are blocking */ + ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1. + * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads. + * 0 means default, which is dynamically determined based on compression parameters. + * Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest. + * The minimum size is automatically and transparently enforced. */ + ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size. + * The overlap size is an amount of data reloaded from previous job at the beginning of a new job. + * It helps preserve compression ratio, while each job is compressed in parallel. + * This value is enforced only when nbWorkers >= 1. + * Larger values increase compression ratio, but decrease speed. + * Possible values range from 0 to 9 : + * - 0 means "default" : value will be determined by the library, depending on strategy + * - 1 means "no overlap" + * - 9 means "full overlap", using a full window size. + * Each intermediate rank increases/decreases load size by a factor 2 : + * 9: full window; 8: w/2; 7: w/4; 6: w/8; 5:w/16; 4: w/32; 3:w/64; 2:w/128; 1:no overlap; 0:default + * default value varies between 6 and 9, depending on strategy */ + + /* note : additional experimental parameters are also available + * within the experimental section of the API. + * At the time of this writing, they include : + * ZSTD_c_rsyncable + * ZSTD_c_format + * ZSTD_c_forceMaxWindow + * ZSTD_c_forceAttachDict + * ZSTD_c_literalCompressionMode + * ZSTD_c_srcSizeHint + * ZSTD_c_enableDedicatedDictSearch + * ZSTD_c_stableInBuffer + * ZSTD_c_stableOutBuffer + * ZSTD_c_blockDelimiters + * ZSTD_c_validateSequences + * ZSTD_c_blockSplitterLevel + * ZSTD_c_splitAfterSequences + * ZSTD_c_useRowMatchFinder + * ZSTD_c_prefetchCDictTables + * ZSTD_c_enableSeqProducerFallback + * ZSTD_c_maxBlockSize + * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them. + * note : never ever use experimentalParam? names directly; + * also, the enums values themselves are unstable and can still change. + */ + ZSTD_c_experimentalParam1=500, + ZSTD_c_experimentalParam2=10, + ZSTD_c_experimentalParam3=1000, + ZSTD_c_experimentalParam4=1001, + ZSTD_c_experimentalParam5=1002, + /* was ZSTD_c_experimentalParam6=1003; is now ZSTD_c_targetCBlockSize */ + ZSTD_c_experimentalParam7=1004, + ZSTD_c_experimentalParam8=1005, + ZSTD_c_experimentalParam9=1006, + ZSTD_c_experimentalParam10=1007, + ZSTD_c_experimentalParam11=1008, + ZSTD_c_experimentalParam12=1009, + ZSTD_c_experimentalParam13=1010, + ZSTD_c_experimentalParam14=1011, + ZSTD_c_experimentalParam15=1012, + ZSTD_c_experimentalParam16=1013, + ZSTD_c_experimentalParam17=1014, + ZSTD_c_experimentalParam18=1015, + ZSTD_c_experimentalParam19=1016, + ZSTD_c_experimentalParam20=1017 +} ZSTD_cParameter; + +typedef struct { + size_t error; + int lowerBound; + int upperBound; +} ZSTD_bounds; + +/*! ZSTD_cParam_getBounds() : + * All parameters must belong to an interval with lower and upper bounds, + * otherwise they will either trigger an error or be automatically clamped. + * @return : a structure, ZSTD_bounds, which contains + * - an error status field, which must be tested using ZSTD_isError() + * - lower and upper bounds, both inclusive + */ +ZSTDLIB_API ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter cParam); + +/*! ZSTD_CCtx_setParameter() : + * Set one compression parameter, selected by enum ZSTD_cParameter. + * All parameters have valid bounds. Bounds can be queried using ZSTD_cParam_getBounds(). + * Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). + * Setting a parameter is generally only possible during frame initialization (before starting compression). + * Exception : when using multi-threading mode (nbWorkers >= 1), + * the following parameters can be updated _during_ compression (within same frame): + * => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy. + * new parameters will be active for next job only (after a flush()). + * @return : an error code (which can be tested using ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value); + +/*! ZSTD_CCtx_setPledgedSrcSize() : + * Total input data size to be compressed as a single frame. + * Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag. + * This value will also be controlled at end of frame, and trigger an error if not respected. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame. + * In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN. + * ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame. + * Note 2 : pledgedSrcSize is only valid once, for the next frame. + * It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN. + * Note 3 : Whenever all input data is provided and consumed in a single round, + * for example with ZSTD_compress2(), + * or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end), + * this value is automatically overridden by srcSize instead. + */ +ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize); + +typedef enum { + ZSTD_reset_session_only = 1, + ZSTD_reset_parameters = 2, + ZSTD_reset_session_and_parameters = 3 +} ZSTD_ResetDirective; + +/*! ZSTD_CCtx_reset() : + * There are 2 different things that can be reset, independently or jointly : + * - The session : will stop compressing current frame, and make CCtx ready to start a new one. + * Useful after an error, or to interrupt any ongoing compression. + * Any internal data not yet flushed is cancelled. + * Compression parameters and dictionary remain unchanged. + * They will be used to compress next frame. + * Resetting session never fails. + * - The parameters : changes all parameters back to "default". + * This also removes any reference to any dictionary or external sequence producer. + * Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing) + * otherwise the reset fails, and function returns an error value (which can be tested using ZSTD_isError()) + * - Both : similar to resetting the session, followed by resetting parameters. + */ +ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset); + +/*! ZSTD_compress2() : + * Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API. + * (note that this entry point doesn't even expose a compression level parameter). + * ZSTD_compress2() always starts a new frame. + * Should cctx hold data from a previously unfinished frame, everything about it is forgotten. + * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() + * - The function is always blocking, returns when compression is completed. + * NOTE: Providing `dstCapacity >= ZSTD_compressBound(srcSize)` guarantees that zstd will have + * enough space to successfully compress the data, though it is possible it fails for other reasons. + * @return : compressed size written into `dst` (<= `dstCapacity), + * or an error code if it fails (which can be tested using ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize); + + +/*********************************************** +* Advanced decompression API (Requires v1.4.0+) +************************************************/ + +/* The advanced API pushes parameters one by one into an existing DCtx context. + * Parameters are sticky, and remain valid for all following frames + * using the same DCtx context. + * It's possible to reset parameters to default values using ZSTD_DCtx_reset(). + * Note : This API is compatible with existing ZSTD_decompressDCtx() and ZSTD_decompressStream(). + * Therefore, no new decompression function is necessary. + */ + +typedef enum { + + ZSTD_d_windowLogMax=100, /* Select a size limit (in power of 2) beyond which + * the streaming API will refuse to allocate memory buffer + * in order to protect the host from unreasonable memory requirements. + * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode. + * By default, a decompression context accepts window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT). + * Special: value 0 means "use default maximum windowLog". */ + + /* note : additional experimental parameters are also available + * within the experimental section of the API. + * At the time of this writing, they include : + * ZSTD_d_format + * ZSTD_d_stableOutBuffer + * ZSTD_d_forceIgnoreChecksum + * ZSTD_d_refMultipleDDicts + * ZSTD_d_disableHuffmanAssembly + * ZSTD_d_maxBlockSize + * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them. + * note : never ever use experimentalParam? names directly + */ + ZSTD_d_experimentalParam1=1000, + ZSTD_d_experimentalParam2=1001, + ZSTD_d_experimentalParam3=1002, + ZSTD_d_experimentalParam4=1003, + ZSTD_d_experimentalParam5=1004, + ZSTD_d_experimentalParam6=1005 + +} ZSTD_dParameter; + +/*! ZSTD_dParam_getBounds() : + * All parameters must belong to an interval with lower and upper bounds, + * otherwise they will either trigger an error or be automatically clamped. + * @return : a structure, ZSTD_bounds, which contains + * - an error status field, which must be tested using ZSTD_isError() + * - both lower and upper bounds, inclusive + */ +ZSTDLIB_API ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam); + +/*! ZSTD_DCtx_setParameter() : + * Set one compression parameter, selected by enum ZSTD_dParameter. + * All parameters have valid bounds. Bounds can be queried using ZSTD_dParam_getBounds(). + * Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). + * Setting a parameter is only possible during frame initialization (before starting decompression). + * @return : 0, or an error code (which can be tested using ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int value); + +/*! ZSTD_DCtx_reset() : + * Return a DCtx to clean state. + * Session and parameters can be reset jointly or separately. + * Parameters can only be reset when no active frame is being decompressed. + * @return : 0, or an error code, which can be tested with ZSTD_isError() + */ +ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset); + + +/**************************** +* Streaming +****************************/ + +typedef struct ZSTD_inBuffer_s { + const void* src; /**< start of input buffer */ + size_t size; /**< size of input buffer */ + size_t pos; /**< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size */ +} ZSTD_inBuffer; + +typedef struct ZSTD_outBuffer_s { + void* dst; /**< start of output buffer */ + size_t size; /**< size of output buffer */ + size_t pos; /**< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size */ +} ZSTD_outBuffer; + + + +/*-*********************************************************************** +* Streaming compression - HowTo +* +* A ZSTD_CStream object is required to track streaming operation. +* Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources. +* ZSTD_CStream objects can be reused multiple times on consecutive compression operations. +* It is recommended to reuse ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory. +* +* For parallel execution, use one separate ZSTD_CStream per thread. +* +* note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing. +* +* Parameters are sticky : when starting a new compression on the same context, +* it will reuse the same sticky parameters as previous compression session. +* When in doubt, it's recommended to fully initialize the context before usage. +* Use ZSTD_CCtx_reset() to reset the context and ZSTD_CCtx_setParameter(), +* ZSTD_CCtx_setPledgedSrcSize(), or ZSTD_CCtx_loadDictionary() and friends to +* set more specific parameters, the pledged source size, or load a dictionary. +* +* Use ZSTD_compressStream2() with ZSTD_e_continue as many times as necessary to +* consume input stream. The function will automatically update both `pos` +* fields within `input` and `output`. +* Note that the function may not consume the entire input, for example, because +* the output buffer is already full, in which case `input.pos < input.size`. +* The caller must check if input has been entirely consumed. +* If not, the caller must make some room to receive more compressed data, +* and then present again remaining input data. +* note: ZSTD_e_continue is guaranteed to make some forward progress when called, +* but doesn't guarantee maximal forward progress. This is especially relevant +* when compressing with multiple threads. The call won't block if it can +* consume some input, but if it can't it will wait for some, but not all, +* output to be flushed. +* @return : provides a minimum amount of data remaining to be flushed from internal buffers +* or an error code, which can be tested using ZSTD_isError(). +* +* At any moment, it's possible to flush whatever data might remain stuck within internal buffer, +* using ZSTD_compressStream2() with ZSTD_e_flush. `output->pos` will be updated. +* Note that, if `output->size` is too small, a single invocation with ZSTD_e_flush might not be enough (return code > 0). +* In which case, make some room to receive more compressed data, and call again ZSTD_compressStream2() with ZSTD_e_flush. +* You must continue calling ZSTD_compressStream2() with ZSTD_e_flush until it returns 0, at which point you can change the +* operation. +* note: ZSTD_e_flush will flush as much output as possible, meaning when compressing with multiple threads, it will +* block until the flush is complete or the output buffer is full. +* @return : 0 if internal buffers are entirely flushed, +* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size), +* or an error code, which can be tested using ZSTD_isError(). +* +* Calling ZSTD_compressStream2() with ZSTD_e_end instructs to finish a frame. +* It will perform a flush and write frame epilogue. +* The epilogue is required for decoders to consider a frame completed. +* flush operation is the same, and follows same rules as calling ZSTD_compressStream2() with ZSTD_e_flush. +* You must continue calling ZSTD_compressStream2() with ZSTD_e_end until it returns 0, at which point you are free to +* start a new frame. +* note: ZSTD_e_end will flush as much output as possible, meaning when compressing with multiple threads, it will +* block until the flush is complete or the output buffer is full. +* @return : 0 if frame fully completed and fully flushed, +* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size), +* or an error code, which can be tested using ZSTD_isError(). +* +* *******************************************************************/ + +typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same object (>= v1.3.0) */ + /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */ +/*===== ZSTD_CStream management functions =====*/ +ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void); +ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs); /* accept NULL pointer */ + +/*===== Streaming compression functions =====*/ +typedef enum { + ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal compression ratio */ + ZSTD_e_flush=1, /* flush any data provided so far, + * it creates (at least) one new block, that can be decoded immediately on reception; + * frame will continue: any future data can still reference previously compressed data, improving compression. + * note : multithreaded compression will block to flush as much output as possible. */ + ZSTD_e_end=2 /* flush any remaining data _and_ close current frame. + * note that frame is only closed after compressed data is fully flushed (return value == 0). + * After that point, any additional data starts a new frame. + * note : each frame is independent (does not reference any content from previous frame). + : note : multithreaded compression will block to flush as much output as possible. */ +} ZSTD_EndDirective; + +/*! ZSTD_compressStream2() : Requires v1.4.0+ + * Behaves about the same as ZSTD_compressStream, with additional control on end directive. + * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() + * - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode) + * - output->pos must be <= dstCapacity, input->pos must be <= srcSize + * - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit. + * - endOp must be a valid directive + * - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller. + * - When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available, + * and then immediately returns, just indicating that there is some data remaining to be flushed. + * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte. + * - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking. + * - @return provides a minimum amount of data remaining to be flushed from internal buffers + * or an error code, which can be tested using ZSTD_isError(). + * if @return != 0, flush is not fully completed, there is still some data left within internal buffers. + * This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers. + * For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed. + * - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0), + * only ZSTD_e_end or ZSTD_e_flush operations are allowed. + * Before starting a new compression job, or changing compression parameters, + * it is required to fully flush internal buffers. + * - note: if an operation ends with an error, it may leave @cctx in an undefined state. + * Therefore, it's UB to invoke ZSTD_compressStream2() of ZSTD_compressStream() on such a state. + * In order to be re-employed after an error, a state must be reset, + * which can be done explicitly (ZSTD_CCtx_reset()), + * or is sometimes implied by methods starting a new compression job (ZSTD_initCStream(), ZSTD_compressCCtx()) + */ +ZSTDLIB_API size_t ZSTD_compressStream2( ZSTD_CCtx* cctx, + ZSTD_outBuffer* output, + ZSTD_inBuffer* input, + ZSTD_EndDirective endOp); + + +/* These buffer sizes are softly recommended. + * They are not required : ZSTD_compressStream*() happily accepts any buffer size, for both input and output. + * Respecting the recommended size just makes it a bit easier for ZSTD_compressStream*(), + * reducing the amount of memory shuffling and buffering, resulting in minor performance savings. + * + * However, note that these recommendations are from the perspective of a C caller program. + * If the streaming interface is invoked from some other language, + * especially managed ones such as Java or Go, through a foreign function interface such as jni or cgo, + * a major performance rule is to reduce crossing such interface to an absolute minimum. + * It's not rare that performance ends being spent more into the interface, rather than compression itself. + * In which cases, prefer using large buffers, as large as practical, + * for both input and output, to reduce the nb of roundtrips. + */ +ZSTDLIB_API size_t ZSTD_CStreamInSize(void); /**< recommended size for input buffer */ +ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block. */ + + +/* ***************************************************************************** + * This following is a legacy streaming API, available since v1.0+ . + * It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2(). + * It is redundant, but remains fully supported. + ******************************************************************************/ + +/*! + * Equivalent to: + * + * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); + * ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) + * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); + * + * Note that ZSTD_initCStream() clears any previously set dictionary. Use the new API + * to compress with a dictionary. + */ +ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel); +/*! + * Alternative for ZSTD_compressStream2(zcs, output, input, ZSTD_e_continue). + * NOTE: The return value is different. ZSTD_compressStream() returns a hint for + * the next read size (if non-zero and not an error). ZSTD_compressStream2() + * returns the minimum nb of bytes left to flush (if non-zero and not an error). + */ +ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input); +/*! Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush). */ +ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output); +/*! Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end). */ +ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output); + + +/*-*************************************************************************** +* Streaming decompression - HowTo +* +* A ZSTD_DStream object is required to track streaming operations. +* Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources. +* ZSTD_DStream objects can be re-employed multiple times. +* +* Use ZSTD_initDStream() to start a new decompression operation. +* @return : recommended first input size +* Alternatively, use advanced API to set specific properties. +* +* Use ZSTD_decompressStream() repetitively to consume your input. +* The function will update both `pos` fields. +* If `input.pos < input.size`, some input has not been consumed. +* It's up to the caller to present again remaining data. +* +* The function tries to flush all data decoded immediately, respecting output buffer size. +* If `output.pos < output.size`, decoder has flushed everything it could. +* +* However, when `output.pos == output.size`, it's more difficult to know. +* If @return > 0, the frame is not complete, meaning +* either there is still some data left to flush within internal buffers, +* or there is more input to read to complete the frame (or both). +* In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer. +* Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX. +* @return : 0 when a frame is completely decoded and fully flushed, +* or an error code, which can be tested using ZSTD_isError(), +* or any other value > 0, which means there is still some decoding or flushing to do to complete current frame : +* the return value is a suggested next input size (just a hint for better latency) +* that will never request more than the remaining content of the compressed frame. +* *******************************************************************************/ + +typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */ + /* For compatibility with versions <= v1.2.0, prefer differentiating them. */ +/*===== ZSTD_DStream management functions =====*/ +ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void); +ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds); /* accept NULL pointer */ + +/*===== Streaming decompression functions =====*/ + +/*! ZSTD_initDStream() : + * Initialize/reset DStream state for new decompression operation. + * Call before new decompression operation using same DStream. + * + * Note : This function is redundant with the advanced API and equivalent to: + * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); + * ZSTD_DCtx_refDDict(zds, NULL); + */ +ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds); + +/*! ZSTD_decompressStream() : + * Streaming decompression function. + * Call repetitively to consume full input updating it as necessary. + * Function will update both input and output `pos` fields exposing current state via these fields: + * - `input.pos < input.size`, some input remaining and caller should provide remaining input + * on the next call. + * - `output.pos < output.size`, decoder flushed internal output buffer. + * - `output.pos == output.size`, unflushed data potentially present in the internal buffers, + * check ZSTD_decompressStream() @return value, + * if > 0, invoke it again to flush remaining data to output. + * Note : with no additional input, amount of data flushed <= ZSTD_BLOCKSIZE_MAX. + * + * @return : 0 when a frame is completely decoded and fully flushed, + * or an error code, which can be tested using ZSTD_isError(), + * or any other value > 0, which means there is some decoding or flushing to do to complete current frame. + * + * Note: when an operation returns with an error code, the @zds state may be left in undefined state. + * It's UB to invoke `ZSTD_decompressStream()` on such a state. + * In order to re-use such a state, it must be first reset, + * which can be done explicitly (`ZSTD_DCtx_reset()`), + * or is implied for operations starting some new decompression job (`ZSTD_initDStream`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`) + */ +ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input); + +ZSTDLIB_API size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */ +ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */ + + +/************************** +* Simple dictionary API +***************************/ +/*! ZSTD_compress_usingDict() : + * Compression at an explicit compression level using a Dictionary. + * A dictionary can be any arbitrary data segment (also called a prefix), + * or a buffer with specified information (see zdict.h). + * Note : This function loads the dictionary, resulting in significant startup delay. + * It's intended for a dictionary used only once. + * Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. */ +ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const void* dict,size_t dictSize, + int compressionLevel); + +/*! ZSTD_decompress_usingDict() : + * Decompression using a known Dictionary. + * Dictionary must be identical to the one used during compression. + * Note : This function loads the dictionary, resulting in significant startup delay. + * It's intended for a dictionary used only once. + * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */ +ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const void* dict,size_t dictSize); + + +/*********************************** + * Bulk processing dictionary API + **********************************/ +typedef struct ZSTD_CDict_s ZSTD_CDict; + +/*! ZSTD_createCDict() : + * When compressing multiple messages or blocks using the same dictionary, + * it's recommended to digest the dictionary only once, since it's a costly operation. + * ZSTD_createCDict() will create a state from digesting a dictionary. + * The resulting state can be used for future compression operations with very limited startup cost. + * ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. + * @dictBuffer can be released after ZSTD_CDict creation, because its content is copied within CDict. + * Note 1 : Consider experimental function `ZSTD_createCDict_byReference()` if you prefer to not duplicate @dictBuffer content. + * Note 2 : A ZSTD_CDict can be created from an empty @dictBuffer, + * in which case the only thing that it transports is the @compressionLevel. + * This can be useful in a pipeline featuring ZSTD_compress_usingCDict() exclusively, + * expecting a ZSTD_CDict parameter with any data, including those without a known dictionary. */ +ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize, + int compressionLevel); + +/*! ZSTD_freeCDict() : + * Function frees memory allocated by ZSTD_createCDict(). + * If a NULL pointer is passed, no operation is performed. */ +ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict); + +/*! ZSTD_compress_usingCDict() : + * Compression using a digested Dictionary. + * Recommended when same dictionary is used multiple times. + * Note : compression level is _decided at dictionary creation time_, + * and frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no) */ +ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const ZSTD_CDict* cdict); + + +typedef struct ZSTD_DDict_s ZSTD_DDict; + +/*! ZSTD_createDDict() : + * Create a digested dictionary, ready to start decompression operation without startup delay. + * dictBuffer can be released after DDict creation, as its content is copied inside DDict. */ +ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize); + +/*! ZSTD_freeDDict() : + * Function frees memory allocated with ZSTD_createDDict() + * If a NULL pointer is passed, no operation is performed. */ +ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict); + +/*! ZSTD_decompress_usingDDict() : + * Decompression using a digested Dictionary. + * Recommended when same dictionary is used multiple times. */ +ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const ZSTD_DDict* ddict); + + +/******************************** + * Dictionary helper functions + *******************************/ + +/*! ZSTD_getDictID_fromDict() : Requires v1.4.0+ + * Provides the dictID stored within dictionary. + * if @return == 0, the dictionary is not conformant with Zstandard specification. + * It can still be loaded, but as a content-only dictionary. */ +ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize); + +/*! ZSTD_getDictID_fromCDict() : Requires v1.5.0+ + * Provides the dictID of the dictionary loaded into `cdict`. + * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. + * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ +ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict); + +/*! ZSTD_getDictID_fromDDict() : Requires v1.4.0+ + * Provides the dictID of the dictionary loaded into `ddict`. + * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. + * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ +ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict); + +/*! ZSTD_getDictID_fromFrame() : Requires v1.4.0+ + * Provides the dictID required to decompressed the frame stored within `src`. + * If @return == 0, the dictID could not be decoded. + * This could for one of the following reasons : + * - The frame does not require a dictionary to be decoded (most common case). + * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden piece of information. + * Note : this use case also happens when using a non-conformant dictionary. + * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`). + * - This is not a Zstandard frame. + * When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code. */ +ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize); + + +/******************************************************************************* + * Advanced dictionary and prefix API (Requires v1.4.0+) + * + * This API allows dictionaries to be used with ZSTD_compress2(), + * ZSTD_compressStream2(), and ZSTD_decompressDCtx(). + * Dictionaries are sticky, they remain valid when same context is reused, + * they only reset when the context is reset + * with ZSTD_reset_parameters or ZSTD_reset_session_and_parameters. + * In contrast, Prefixes are single-use. + ******************************************************************************/ + + +/*! ZSTD_CCtx_loadDictionary() : Requires v1.4.0+ + * Create an internal CDict from `dict` buffer. + * Decompression will have to use same dictionary. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary, + * meaning "return to no-dictionary mode". + * Note 1 : Dictionary is sticky, it will be used for all future compressed frames, + * until parameters are reset, a new dictionary is loaded, or the dictionary + * is explicitly invalidated by loading a NULL dictionary. + * Note 2 : Loading a dictionary involves building tables. + * It's also a CPU consuming operation, with non-negligible impact on latency. + * Tables are dependent on compression parameters, and for this reason, + * compression parameters can no longer be changed after loading a dictionary. + * Note 3 :`dict` content will be copied internally. + * Use experimental ZSTD_CCtx_loadDictionary_byReference() to reference content instead. + * In such a case, dictionary buffer must outlive its users. + * Note 4 : Use ZSTD_CCtx_loadDictionary_advanced() + * to precisely select how dictionary content must be interpreted. + * Note 5 : This method does not benefit from LDM (long distance mode). + * If you want to employ LDM on some large dictionary content, + * prefer employing ZSTD_CCtx_refPrefix() described below. + */ +ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize); + +/*! ZSTD_CCtx_refCDict() : Requires v1.4.0+ + * Reference a prepared dictionary, to be used for all future compressed frames. + * Note that compression parameters are enforced from within CDict, + * and supersede any compression parameter previously set within CCtx. + * The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs. + * The ignored parameters will be used again if the CCtx is returned to no-dictionary mode. + * The dictionary will remain valid for future compressed frames using same CCtx. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special : Referencing a NULL CDict means "return to no-dictionary mode". + * Note 1 : Currently, only one dictionary can be managed. + * Referencing a new dictionary effectively "discards" any previous one. + * Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. */ +ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); + +/*! ZSTD_CCtx_refPrefix() : Requires v1.4.0+ + * Reference a prefix (single-usage dictionary) for next compressed frame. + * A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end). + * Decompression will need same prefix to properly regenerate data. + * Compressing with a prefix is similar in outcome as performing a diff and compressing it, + * but performs much faster, especially during decompression (compression speed is tunable with compression level). + * This method is compatible with LDM (long distance mode). + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary + * Note 1 : Prefix buffer is referenced. It **must** outlive compression. + * Its content must remain unmodified during compression. + * Note 2 : If the intention is to diff some large src data blob with some prior version of itself, + * ensure that the window size is large enough to contain the entire source. + * See ZSTD_c_windowLog. + * Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters. + * It's a CPU consuming operation, with non-negligible impact on latency. + * If there is a need to use the same prefix multiple times, consider loadDictionary instead. + * Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dct_rawContent). + * Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation. */ +ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, + const void* prefix, size_t prefixSize); + +/*! ZSTD_DCtx_loadDictionary() : Requires v1.4.0+ + * Create an internal DDict from dict buffer, to be used to decompress all future frames. + * The dictionary remains valid for all future frames, until explicitly invalidated, or + * a new dictionary is loaded. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary, + * meaning "return to no-dictionary mode". + * Note 1 : Loading a dictionary involves building tables, + * which has a non-negligible impact on CPU usage and latency. + * It's recommended to "load once, use many times", to amortize the cost + * Note 2 :`dict` content will be copied internally, so `dict` can be released after loading. + * Use ZSTD_DCtx_loadDictionary_byReference() to reference dictionary content instead. + * Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to take control of + * how dictionary content is loaded and interpreted. + */ +ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); + +/*! ZSTD_DCtx_refDDict() : Requires v1.4.0+ + * Reference a prepared dictionary, to be used to decompress next frames. + * The dictionary remains active for decompression of future frames using same DCtx. + * + * If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function + * will store the DDict references in a table, and the DDict used for decompression + * will be determined at decompression time, as per the dict ID in the frame. + * The memory for the table is allocated on the first call to refDDict, and can be + * freed with ZSTD_freeDCtx(). + * + * If called with ZSTD_d_refMultipleDDicts disabled (the default), only one dictionary + * will be managed, and referencing a dictionary effectively "discards" any previous one. + * + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special: referencing a NULL DDict means "return to no-dictionary mode". + * Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx. + */ +ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict); + +/*! ZSTD_DCtx_refPrefix() : Requires v1.4.0+ + * Reference a prefix (single-usage dictionary) to decompress next frame. + * This is the reverse operation of ZSTD_CCtx_refPrefix(), + * and must use the same prefix as the one used during compression. + * Prefix is **only used once**. Reference is discarded at end of frame. + * End of frame is reached when ZSTD_decompressStream() returns 0. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary + * Note 2 : Prefix buffer is referenced. It **must** outlive decompression. + * Prefix buffer must remain unmodified up to the end of frame, + * reached when ZSTD_decompressStream() returns 0. + * Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent). + * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode (Experimental section) + * Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost. + * A full dictionary is more costly, as it requires building tables. + */ +ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, + const void* prefix, size_t prefixSize); + +/* === Memory management === */ + +/*! ZSTD_sizeof_*() : Requires v1.4.0+ + * These functions give the _current_ memory usage of selected object. + * Note that object memory usage can evolve (increase or decrease) over time. */ +ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx); +ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx); +ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs); +ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds); +ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict); +ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); + +#if defined (__cplusplus) +} +#endif + +#endif /* ZSTD_H_235446 */ + + +/* ************************************************************************************** + * ADVANCED AND EXPERIMENTAL FUNCTIONS + **************************************************************************************** + * The definitions in the following section are considered experimental. + * They are provided for advanced scenarios. + * They should never be used with a dynamic library, as prototypes may change in the future. + * Use them only in association with static linking. + * ***************************************************************************************/ + +#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY) +#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY + +#if defined (__cplusplus) +extern "C" { +#endif + +/* This can be overridden externally to hide static symbols. */ +#ifndef ZSTDLIB_STATIC_API +# if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) +# define ZSTDLIB_STATIC_API __declspec(dllexport) ZSTDLIB_VISIBLE +# elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) +# define ZSTDLIB_STATIC_API __declspec(dllimport) ZSTDLIB_VISIBLE +# else +# define ZSTDLIB_STATIC_API ZSTDLIB_VISIBLE +# endif +#endif + +/**************************************************************************************** + * experimental API (static linking only) + **************************************************************************************** + * The following symbols and constants + * are not planned to join "stable API" status in the near future. + * They can still change in future versions. + * Some of them are planned to remain in the static_only section indefinitely. + * Some of them might be removed in the future (especially when redundant with existing stable functions) + * ***************************************************************************************/ + +#define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1) /* minimum input size required to query frame header size */ +#define ZSTD_FRAMEHEADERSIZE_MIN(format) ((format) == ZSTD_f_zstd1 ? 6 : 2) +#define ZSTD_FRAMEHEADERSIZE_MAX 18 /* can be useful for static allocation */ +#define ZSTD_SKIPPABLEHEADERSIZE 8 + +/* compression parameter bounds */ +#define ZSTD_WINDOWLOG_MAX_32 30 +#define ZSTD_WINDOWLOG_MAX_64 31 +#define ZSTD_WINDOWLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64)) +#define ZSTD_WINDOWLOG_MIN 10 +#define ZSTD_HASHLOG_MAX ((ZSTD_WINDOWLOG_MAX < 30) ? ZSTD_WINDOWLOG_MAX : 30) +#define ZSTD_HASHLOG_MIN 6 +#define ZSTD_CHAINLOG_MAX_32 29 +#define ZSTD_CHAINLOG_MAX_64 30 +#define ZSTD_CHAINLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_CHAINLOG_MAX_32 : ZSTD_CHAINLOG_MAX_64)) +#define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN +#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1) +#define ZSTD_SEARCHLOG_MIN 1 +#define ZSTD_MINMATCH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */ +#define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */ +#define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX +#define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */ +#define ZSTD_STRATEGY_MIN ZSTD_fast +#define ZSTD_STRATEGY_MAX ZSTD_btultra2 +#define ZSTD_BLOCKSIZE_MAX_MIN (1 << 10) /* The minimum valid max blocksize. Maximum blocksizes smaller than this make compressBound() inaccurate. */ + + +#define ZSTD_OVERLAPLOG_MIN 0 +#define ZSTD_OVERLAPLOG_MAX 9 + +#define ZSTD_WINDOWLOG_LIMIT_DEFAULT 27 /* by default, the streaming decoder will refuse any frame + * requiring larger than (1< 0: + * If litLength != 0: + * rep == 1 --> offset == repeat_offset_1 + * rep == 2 --> offset == repeat_offset_2 + * rep == 3 --> offset == repeat_offset_3 + * If litLength == 0: + * rep == 1 --> offset == repeat_offset_2 + * rep == 2 --> offset == repeat_offset_3 + * rep == 3 --> offset == repeat_offset_1 - 1 + * + * Note: This field is optional. ZSTD_generateSequences() will calculate the value of + * 'rep', but repeat offsets do not necessarily need to be calculated from an external + * sequence provider perspective. For example, ZSTD_compressSequences() does not + * use this 'rep' field at all (as of now). + */ +} ZSTD_Sequence; + +typedef struct { + unsigned windowLog; /**< largest match distance : larger == more compression, more memory needed during decompression */ + unsigned chainLog; /**< fully searched segment : larger == more compression, slower, more memory (useless for fast) */ + unsigned hashLog; /**< dispatch table : larger == faster, more memory */ + unsigned searchLog; /**< nb of searches : larger == more compression, slower */ + unsigned minMatch; /**< match length searched : larger == faster decompression, sometimes less compression */ + unsigned targetLength; /**< acceptable match size for optimal parser (only) : larger == more compression, slower */ + ZSTD_strategy strategy; /**< see ZSTD_strategy definition above */ +} ZSTD_compressionParameters; + +typedef struct { + int contentSizeFlag; /**< 1: content size will be in frame header (when known) */ + int checksumFlag; /**< 1: generate a 32-bits checksum using XXH64 algorithm at end of frame, for error detection */ + int noDictIDFlag; /**< 1: no dictID will be saved into frame header (dictID is only useful for dictionary compression) */ +} ZSTD_frameParameters; + +typedef struct { + ZSTD_compressionParameters cParams; + ZSTD_frameParameters fParams; +} ZSTD_parameters; + +typedef enum { + ZSTD_dct_auto = 0, /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */ + ZSTD_dct_rawContent = 1, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */ + ZSTD_dct_fullDict = 2 /* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */ +} ZSTD_dictContentType_e; + +typedef enum { + ZSTD_dlm_byCopy = 0, /**< Copy dictionary content internally */ + ZSTD_dlm_byRef = 1 /**< Reference dictionary content -- the dictionary buffer must outlive its users. */ +} ZSTD_dictLoadMethod_e; + +typedef enum { + ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */ + ZSTD_f_zstd1_magicless = 1 /* Variant of zstd frame format, without initial 4-bytes magic number. + * Useful to save 4 bytes per generated frame. + * Decoder cannot recognise automatically this format, requiring this instruction. */ +} ZSTD_format_e; + +typedef enum { + /* Note: this enum controls ZSTD_d_forceIgnoreChecksum */ + ZSTD_d_validateChecksum = 0, + ZSTD_d_ignoreChecksum = 1 +} ZSTD_forceIgnoreChecksum_e; + +typedef enum { + /* Note: this enum controls ZSTD_d_refMultipleDDicts */ + ZSTD_rmd_refSingleDDict = 0, + ZSTD_rmd_refMultipleDDicts = 1 +} ZSTD_refMultipleDDicts_e; + +typedef enum { + /* Note: this enum and the behavior it controls are effectively internal + * implementation details of the compressor. They are expected to continue + * to evolve and should be considered only in the context of extremely + * advanced performance tuning. + * + * Zstd currently supports the use of a CDict in three ways: + * + * - The contents of the CDict can be copied into the working context. This + * means that the compression can search both the dictionary and input + * while operating on a single set of internal tables. This makes + * the compression faster per-byte of input. However, the initial copy of + * the CDict's tables incurs a fixed cost at the beginning of the + * compression. For small compressions (< 8 KB), that copy can dominate + * the cost of the compression. + * + * - The CDict's tables can be used in-place. In this model, compression is + * slower per input byte, because the compressor has to search two sets of + * tables. However, this model incurs no start-up cost (as long as the + * working context's tables can be reused). For small inputs, this can be + * faster than copying the CDict's tables. + * + * - The CDict's tables are not used at all, and instead we use the working + * context alone to reload the dictionary and use params based on the source + * size. See ZSTD_compress_insertDictionary() and ZSTD_compress_usingDict(). + * This method is effective when the dictionary sizes are very small relative + * to the input size, and the input size is fairly large to begin with. + * + * Zstd has a simple internal heuristic that selects which strategy to use + * at the beginning of a compression. However, if experimentation shows that + * Zstd is making poor choices, it is possible to override that choice with + * this enum. + */ + ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */ + ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */ + ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */ + ZSTD_dictForceLoad = 3 /* Always reload the dictionary */ +} ZSTD_dictAttachPref_e; + +typedef enum { + ZSTD_lcm_auto = 0, /**< Automatically determine the compression mode based on the compression level. + * Negative compression levels will be uncompressed, and positive compression + * levels will be compressed. */ + ZSTD_lcm_huffman = 1, /**< Always attempt Huffman compression. Uncompressed literals will still be + * emitted if Huffman compression is not profitable. */ + ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */ +} ZSTD_literalCompressionMode_e; + +typedef enum { + /* Note: This enum controls features which are conditionally beneficial. + * Zstd can take a decision on whether or not to enable the feature (ZSTD_ps_auto), + * but setting the switch to ZSTD_ps_enable or ZSTD_ps_disable force enable/disable the feature. + */ + ZSTD_ps_auto = 0, /* Let the library automatically determine whether the feature shall be enabled */ + ZSTD_ps_enable = 1, /* Force-enable the feature */ + ZSTD_ps_disable = 2 /* Do not use the feature */ +} ZSTD_ParamSwitch_e; +#define ZSTD_paramSwitch_e ZSTD_ParamSwitch_e /* old name */ + +/*************************************** +* Frame header and size functions +***************************************/ + +/*! ZSTD_findDecompressedSize() : + * `src` should point to the start of a series of ZSTD encoded and/or skippable frames + * `srcSize` must be the _exact_ size of this series + * (i.e. there should be a frame boundary at `src + srcSize`) + * @return : - decompressed size of all data in all successive frames + * - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN + * - if an error occurred: ZSTD_CONTENTSIZE_ERROR + * + * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode. + * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. + * In which case, it's necessary to use streaming mode to decompress data. + * note 2 : decompressed size is always present when compression is done with ZSTD_compress() + * note 3 : decompressed size can be very large (64-bits value), + * potentially larger than what local system can handle as a single memory segment. + * In which case, it's necessary to use streaming mode to decompress data. + * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified. + * Always ensure result fits within application's authorized limits. + * Each application can set its own limits. + * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to + * read each contained frame header. This is fast as most of the data is skipped, + * however it does mean that all frame data must be present and valid. */ +ZSTDLIB_STATIC_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize); + +/*! ZSTD_decompressBound() : + * `src` should point to the start of a series of ZSTD encoded and/or skippable frames + * `srcSize` must be the _exact_ size of this series + * (i.e. there should be a frame boundary at `src + srcSize`) + * @return : - upper-bound for the decompressed size of all data in all successive frames + * - if an error occurred: ZSTD_CONTENTSIZE_ERROR + * + * note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame. + * note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`. + * in this case, `ZSTD_findDecompressedSize` and `ZSTD_decompressBound` return the same value. + * note 3 : when the decompressed size field isn't available, the upper-bound for that frame is calculated by: + * upper-bound = # blocks * min(128 KB, Window_Size) + */ +ZSTDLIB_STATIC_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize); + +/*! ZSTD_frameHeaderSize() : + * srcSize must be large enough, aka >= ZSTD_FRAMEHEADERSIZE_PREFIX. + * @return : size of the Frame Header, + * or an error code (if srcSize is too small) */ +ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize); + +typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_FrameType_e; +#define ZSTD_frameType_e ZSTD_FrameType_e /* old name */ +typedef struct { + unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */ + unsigned long long windowSize; /* can be very large, up to <= frameContentSize */ + unsigned blockSizeMax; + ZSTD_FrameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */ + unsigned headerSize; + unsigned dictID; /* for ZSTD_skippableFrame, contains the skippable magic variant [0-15] */ + unsigned checksumFlag; + unsigned _reserved1; + unsigned _reserved2; +} ZSTD_FrameHeader; +#define ZSTD_frameHeader ZSTD_FrameHeader /* old name */ + +/*! ZSTD_getFrameHeader() : + * decode Frame Header into `zfhPtr`, or requires larger `srcSize`. + * @return : 0 => header is complete, `zfhPtr` is correctly filled, + * >0 => `srcSize` is too small, @return value is the wanted `srcSize` amount, `zfhPtr` is not filled, + * or an error code, which can be tested using ZSTD_isError() */ +ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize); +/*! ZSTD_getFrameHeader_advanced() : + * same as ZSTD_getFrameHeader(), + * with added capability to select a format (like ZSTD_f_zstd1_magicless) */ +ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format); + +/*! ZSTD_decompressionMargin() : + * Zstd supports in-place decompression, where the input and output buffers overlap. + * In this case, the output buffer must be at least (Margin + Output_Size) bytes large, + * and the input buffer must be at the end of the output buffer. + * + * _______________________ Output Buffer ________________________ + * | | + * | ____ Input Buffer ____| + * | | | + * v v v + * |---------------------------------------|-----------|----------| + * ^ ^ ^ + * |___________________ Output_Size ___________________|_ Margin _| + * + * NOTE: See also ZSTD_DECOMPRESSION_MARGIN(). + * NOTE: This applies only to single-pass decompression through ZSTD_decompress() or + * ZSTD_decompressDCtx(). + * NOTE: This function supports multi-frame input. + * + * @param src The compressed frame(s) + * @param srcSize The size of the compressed frame(s) + * @returns The decompression margin or an error that can be checked with ZSTD_isError(). + */ +ZSTDLIB_STATIC_API size_t ZSTD_decompressionMargin(const void* src, size_t srcSize); + +/*! ZSTD_DECOMPRESS_MARGIN() : + * Similar to ZSTD_decompressionMargin(), but instead of computing the margin from + * the compressed frame, compute it from the original size and the blockSizeLog. + * See ZSTD_decompressionMargin() for details. + * + * WARNING: This macro does not support multi-frame input, the input must be a single + * zstd frame. If you need that support use the function, or implement it yourself. + * + * @param originalSize The original uncompressed size of the data. + * @param blockSize The block size == MIN(windowSize, ZSTD_BLOCKSIZE_MAX). + * Unless you explicitly set the windowLog smaller than + * ZSTD_BLOCKSIZELOG_MAX you can just use ZSTD_BLOCKSIZE_MAX. + */ +#define ZSTD_DECOMPRESSION_MARGIN(originalSize, blockSize) ((size_t)( \ + ZSTD_FRAMEHEADERSIZE_MAX /* Frame header */ + \ + 4 /* checksum */ + \ + ((originalSize) == 0 ? 0 : 3 * (((originalSize) + (blockSize) - 1) / blockSize)) /* 3 bytes per block */ + \ + (blockSize) /* One block of margin */ \ + )) + +typedef enum { + ZSTD_sf_noBlockDelimiters = 0, /* ZSTD_Sequence[] has no block delimiters, just sequences */ + ZSTD_sf_explicitBlockDelimiters = 1 /* ZSTD_Sequence[] contains explicit block delimiters */ +} ZSTD_SequenceFormat_e; +#define ZSTD_sequenceFormat_e ZSTD_SequenceFormat_e /* old name */ + +/*! ZSTD_sequenceBound() : + * `srcSize` : size of the input buffer + * @return : upper-bound for the number of sequences that can be generated + * from a buffer of srcSize bytes + * + * note : returns number of sequences - to get bytes, multiply by sizeof(ZSTD_Sequence). + */ +ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound(size_t srcSize); + +/*! ZSTD_generateSequences() : + * WARNING: This function is meant for debugging and informational purposes ONLY! + * Its implementation is flawed, and it will be deleted in a future version. + * It is not guaranteed to succeed, as there are several cases where it will give + * up and fail. You should NOT use this function in production code. + * + * This function is deprecated, and will be removed in a future version. + * + * Generate sequences using ZSTD_compress2(), given a source buffer. + * + * @param zc The compression context to be used for ZSTD_compress2(). Set any + * compression parameters you need on this context. + * @param outSeqs The output sequences buffer of size @p outSeqsSize + * @param outSeqsCapacity The size of the output sequences buffer. + * ZSTD_sequenceBound(srcSize) is an upper bound on the number + * of sequences that can be generated. + * @param src The source buffer to generate sequences from of size @p srcSize. + * @param srcSize The size of the source buffer. + * + * Each block will end with a dummy sequence + * with offset == 0, matchLength == 0, and litLength == length of last literals. + * litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0) + * simply acts as a block delimiter. + * + * @returns The number of sequences generated, necessarily less than + * ZSTD_sequenceBound(srcSize), or an error code that can be checked + * with ZSTD_isError(). + */ +ZSTD_DEPRECATED("For debugging only, will be replaced by ZSTD_extractSequences()") +ZSTDLIB_STATIC_API size_t +ZSTD_generateSequences(ZSTD_CCtx* zc, + ZSTD_Sequence* outSeqs, size_t outSeqsCapacity, + const void* src, size_t srcSize); + +/*! ZSTD_mergeBlockDelimiters() : + * Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals + * by merging them into the literals of the next sequence. + * + * As such, the final generated result has no explicit representation of block boundaries, + * and the final last literals segment is not represented in the sequences. + * + * The output of this function can be fed into ZSTD_compressSequences() with CCtx + * setting of ZSTD_c_blockDelimiters as ZSTD_sf_noBlockDelimiters + * @return : number of sequences left after merging + */ +ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize); + +/*! ZSTD_compressSequences() : + * Compress an array of ZSTD_Sequence, associated with @src buffer, into dst. + * @src contains the entire input (not just the literals). + * If @srcSize > sum(sequence.length), the remaining bytes are considered all literals + * If a dictionary is included, then the cctx should reference the dict (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.). + * The entire source is compressed into a single frame. + * + * The compression behavior changes based on cctx params. In particular: + * If ZSTD_c_blockDelimiters == ZSTD_sf_noBlockDelimiters, the array of ZSTD_Sequence is expected to contain + * no block delimiters (defined in ZSTD_Sequence). Block boundaries are roughly determined based on + * the block size derived from the cctx, and sequences may be split. This is the default setting. + * + * If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain + * valid block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided. + * + * When ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, it's possible to decide generating repcodes + * using the advanced parameter ZSTD_c_repcodeResolution. Repcodes will improve compression ratio, though the benefit + * can vary greatly depending on Sequences. On the other hand, repcode resolution is an expensive operation. + * By default, it's disabled at low (<10) compression levels, and enabled above the threshold (>=10). + * ZSTD_c_repcodeResolution makes it possible to directly manage this processing in either direction. + * + * If ZSTD_c_validateSequences == 0, this function blindly accepts the Sequences provided. Invalid Sequences cause undefined + * behavior. If ZSTD_c_validateSequences == 1, then the function will detect invalid Sequences (see doc/zstd_compression_format.md for + * specifics regarding offset/matchlength requirements) and then bail out and return an error. + * + * In addition to the two adjustable experimental params, there are other important cctx params. + * - ZSTD_c_minMatch MUST be set as less than or equal to the smallest match generated by the match finder. It has a minimum value of ZSTD_MINMATCH_MIN. + * - ZSTD_c_compressionLevel accordingly adjusts the strength of the entropy coder, as it would in typical compression. + * - ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset + * is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md + * + * Note: Repcodes are, as of now, always re-calculated within this function, ZSTD_Sequence.rep is effectively unused. + * Dev Note: Once ability to ingest repcodes become available, the explicit block delims mode must respect those repcodes exactly, + * and cannot emit an RLE block that disagrees with the repcode history. + * @return : final compressed size, or a ZSTD error code. + */ +ZSTDLIB_STATIC_API size_t +ZSTD_compressSequences(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const ZSTD_Sequence* inSeqs, size_t inSeqsSize, + const void* src, size_t srcSize); + + +/*! ZSTD_compressSequencesAndLiterals() : + * This is a variant of ZSTD_compressSequences() which, + * instead of receiving (src,srcSize) as input parameter, receives (literals,litSize), + * aka all the literals, already extracted and laid out into a single continuous buffer. + * This can be useful if the process generating the sequences also happens to generate the buffer of literals, + * thus skipping an extraction + caching stage. + * It's a speed optimization, useful when the right conditions are met, + * but it also features the following limitations: + * - Only supports explicit delimiter mode + * - Currently does not support Sequences validation (so input Sequences are trusted) + * - Not compatible with frame checksum, which must be disabled + * - If any block is incompressible, will fail and return an error + * - @litSize must be == sum of all @.litLength fields in @inSeqs. Any discrepancy will generate an error. + * - @litBufCapacity is the size of the underlying buffer into which literals are written, starting at address @literals. + * @litBufCapacity must be at least 8 bytes larger than @litSize. + * - @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error. + * @return : final compressed size, or a ZSTD error code. + */ +ZSTDLIB_STATIC_API size_t +ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const ZSTD_Sequence* inSeqs, size_t nbSequences, + const void* literals, size_t litSize, size_t litBufCapacity, + size_t decompressedSize); + + +/*! ZSTD_writeSkippableFrame() : + * Generates a zstd skippable frame containing data given by src, and writes it to dst buffer. + * + * Skippable frames begin with a 4-byte magic number. There are 16 possible choices of magic number, + * ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15. + * As such, the parameter magicVariant controls the exact skippable frame magic number variant used, + * so the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant. + * + * Returns an error if destination buffer is not large enough, if the source size is not representable + * with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid). + * + * @return : number of bytes written or a ZSTD error. + */ +ZSTDLIB_STATIC_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + unsigned magicVariant); + +/*! ZSTD_readSkippableFrame() : + * Retrieves the content of a zstd skippable frame starting at @src, and writes it to @dst buffer. + * + * The parameter @magicVariant will receive the magicVariant that was supplied when the frame was written, + * i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. + * This can be NULL if the caller is not interested in the magicVariant. + * + * Returns an error if destination buffer is not large enough, or if the frame is not skippable. + * + * @return : number of bytes written or a ZSTD error. + */ +ZSTDLIB_STATIC_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, + unsigned* magicVariant, + const void* src, size_t srcSize); + +/*! ZSTD_isSkippableFrame() : + * Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame. + */ +ZSTDLIB_STATIC_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size); + + + +/*************************************** +* Memory management +***************************************/ + +/*! ZSTD_estimate*() : + * These functions make it possible to estimate memory usage + * of a future {D,C}Ctx, before its creation. + * This is useful in combination with ZSTD_initStatic(), + * which makes it possible to employ a static buffer for ZSTD_CCtx* state. + * + * ZSTD_estimateCCtxSize() will provide a memory budget large enough + * to compress data of any size using one-shot compression ZSTD_compressCCtx() or ZSTD_compress2() + * associated with any compression level up to max specified one. + * The estimate will assume the input may be arbitrarily large, + * which is the worst case. + * + * Note that the size estimation is specific for one-shot compression, + * it is not valid for streaming (see ZSTD_estimateCStreamSize*()) + * nor other potential ways of using a ZSTD_CCtx* state. + * + * When srcSize can be bound by a known and rather "small" value, + * this knowledge can be used to provide a tighter budget estimation + * because the ZSTD_CCtx* state will need less memory for small inputs. + * This tighter estimation can be provided by employing more advanced functions + * ZSTD_estimateCCtxSize_usingCParams(), which can be used in tandem with ZSTD_getCParams(), + * and ZSTD_estimateCCtxSize_usingCCtxParams(), which can be used in tandem with ZSTD_CCtxParams_setParameter(). + * Both can be used to estimate memory using custom compression parameters and arbitrary srcSize limits. + * + * Note : only single-threaded compression is supported. + * ZSTD_estimateCCtxSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1. + */ +ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize(int maxCompressionLevel); +ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams); +ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params); +ZSTDLIB_STATIC_API size_t ZSTD_estimateDCtxSize(void); + +/*! ZSTD_estimateCStreamSize() : + * ZSTD_estimateCStreamSize() will provide a memory budget large enough for streaming compression + * using any compression level up to the max specified one. + * It will also consider src size to be arbitrarily "large", which is a worst case scenario. + * If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation. + * ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel. + * ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParams_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_c_nbWorkers is >= 1. + * Note : CStream size estimation is only correct for single-threaded compression. + * ZSTD_estimateCStreamSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1. + * Note 2 : ZSTD_estimateCStreamSize* functions are not compatible with the Block-Level Sequence Producer API at this time. + * Size estimates assume that no external sequence producer is registered. + * + * ZSTD_DStream memory budget depends on frame's window Size. + * This information can be passed manually, using ZSTD_estimateDStreamSize, + * or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame(); + * Any frame requesting a window size larger than max specified one will be rejected. + * Note : if streaming is init with function ZSTD_init?Stream_usingDict(), + * an internal ?Dict will be created, which additional size is not estimated here. + * In this case, get total size by adding ZSTD_estimate?DictSize + */ +ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize(int maxCompressionLevel); +ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams); +ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params); +ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize(size_t maxWindowSize); +ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize); + +/*! ZSTD_estimate?DictSize() : + * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict(). + * ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced(). + * Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller. + */ +ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel); +ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod); +ZSTDLIB_STATIC_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod); + +/*! ZSTD_initStatic*() : + * Initialize an object using a pre-allocated fixed-size buffer. + * workspace: The memory area to emplace the object into. + * Provided pointer *must be 8-bytes aligned*. + * Buffer must outlive object. + * workspaceSize: Use ZSTD_estimate*Size() to determine + * how large workspace must be to support target scenario. + * @return : pointer to object (same address as workspace, just different type), + * or NULL if error (size too small, incorrect alignment, etc.) + * Note : zstd will never resize nor malloc() when using a static buffer. + * If the object requires more memory than available, + * zstd will just error out (typically ZSTD_error_memory_allocation). + * Note 2 : there is no corresponding "free" function. + * Since workspace is allocated externally, it must be freed externally too. + * Note 3 : cParams : use ZSTD_getCParams() to convert a compression level + * into its associated cParams. + * Limitation 1 : currently not compatible with internal dictionary creation, triggered by + * ZSTD_CCtx_loadDictionary(), ZSTD_initCStream_usingDict() or ZSTD_initDStream_usingDict(). + * Limitation 2 : static cctx currently not compatible with multi-threading. + * Limitation 3 : static dctx is incompatible with legacy support. + */ +ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize); +ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */ + +ZSTDLIB_STATIC_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize); +ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */ + +ZSTDLIB_STATIC_API const ZSTD_CDict* ZSTD_initStaticCDict( + void* workspace, size_t workspaceSize, + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType, + ZSTD_compressionParameters cParams); + +ZSTDLIB_STATIC_API const ZSTD_DDict* ZSTD_initStaticDDict( + void* workspace, size_t workspaceSize, + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType); + + +/*! Custom memory allocation : + * These prototypes make it possible to pass your own allocation/free functions. + * ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below. + * All allocation/free operations will be completed using these custom variants instead of regular ones. + */ +typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size); +typedef void (*ZSTD_freeFunction) (void* opaque, void* address); +typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem; +static +#ifdef __GNUC__ +__attribute__((__unused__)) +#endif + +#if defined(__clang__) && __clang_major__ >= 5 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif +ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */ +#if defined(__clang__) && __clang_major__ >= 5 +#pragma clang diagnostic pop +#endif + +ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem); +ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem); +ZSTDLIB_STATIC_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem); +ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem); + +ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType, + ZSTD_compressionParameters cParams, + ZSTD_customMem customMem); + +/*! Thread pool : + * These prototypes make it possible to share a thread pool among multiple compression contexts. + * This can limit resources for applications with multiple threads where each one uses + * a threaded compression mode (via ZSTD_c_nbWorkers parameter). + * ZSTD_createThreadPool creates a new thread pool with a given number of threads. + * Note that the lifetime of such pool must exist while being used. + * ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value + * to use an internal thread pool). + * ZSTD_freeThreadPool frees a thread pool, accepts NULL pointer. + */ +typedef struct POOL_ctx_s ZSTD_threadPool; +ZSTDLIB_STATIC_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads); +ZSTDLIB_STATIC_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool); /* accept NULL pointer */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool); + + +/* + * This API is temporary and is expected to change or disappear in the future! + */ +ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced2( + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType, + const ZSTD_CCtx_params* cctxParams, + ZSTD_customMem customMem); + +ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_advanced( + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType, + ZSTD_customMem customMem); + + +/*************************************** +* Advanced compression functions +***************************************/ + +/*! ZSTD_createCDict_byReference() : + * Create a digested dictionary for compression + * Dictionary content is just referenced, not duplicated. + * As a consequence, `dictBuffer` **must** outlive CDict, + * and its content must remain unmodified throughout the lifetime of CDict. + * note: equivalent to ZSTD_createCDict_advanced(), with dictLoadMethod==ZSTD_dlm_byRef */ +ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel); + +/*! ZSTD_getCParams() : + * @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize. + * `estimatedSrcSize` value is optional, select 0 if not known */ +ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize); + +/*! ZSTD_getParams() : + * same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`. + * All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */ +ZSTDLIB_STATIC_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize); + +/*! ZSTD_checkCParams() : + * Ensure param values remain within authorized range. + * @return 0 on success, or an error code (can be checked with ZSTD_isError()) */ +ZSTDLIB_STATIC_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params); + +/*! ZSTD_adjustCParams() : + * optimize params for a given `srcSize` and `dictSize`. + * `srcSize` can be unknown, in which case use ZSTD_CONTENTSIZE_UNKNOWN. + * `dictSize` must be `0` when there is no dictionary. + * cPar can be invalid : all parameters will be clamped within valid range in the @return struct. + * This function never fails (wide contract) */ +ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize); + +/*! ZSTD_CCtx_setCParams() : + * Set all parameters provided within @p cparams into the working @p cctx. + * Note : if modifying parameters during compression (MT mode only), + * note that changes to the .windowLog parameter will be ignored. + * @return 0 on success, or an error code (can be checked with ZSTD_isError()). + * On failure, no parameters are updated. + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setCParams(ZSTD_CCtx* cctx, ZSTD_compressionParameters cparams); + +/*! ZSTD_CCtx_setFParams() : + * Set all parameters provided within @p fparams into the working @p cctx. + * @return 0 on success, or an error code (can be checked with ZSTD_isError()). + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setFParams(ZSTD_CCtx* cctx, ZSTD_frameParameters fparams); + +/*! ZSTD_CCtx_setParams() : + * Set all parameters provided within @p params into the working @p cctx. + * @return 0 on success, or an error code (can be checked with ZSTD_isError()). + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParams(ZSTD_CCtx* cctx, ZSTD_parameters params); + +/*! ZSTD_compress_advanced() : + * Note : this function is now DEPRECATED. + * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters. + * This prototype will generate compilation warnings. */ +ZSTD_DEPRECATED("use ZSTD_compress2") +ZSTDLIB_STATIC_API +size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const void* dict,size_t dictSize, + ZSTD_parameters params); + +/*! ZSTD_compress_usingCDict_advanced() : + * Note : this function is now DEPRECATED. + * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters. + * This prototype will generate compilation warnings. */ +ZSTD_DEPRECATED("use ZSTD_compress2 with ZSTD_CCtx_loadDictionary") +ZSTDLIB_STATIC_API +size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const ZSTD_CDict* cdict, + ZSTD_frameParameters fParams); + + +/*! ZSTD_CCtx_loadDictionary_byReference() : + * Same as ZSTD_CCtx_loadDictionary(), but dictionary content is referenced, instead of being copied into CCtx. + * It saves some memory, but also requires that `dict` outlives its usage within `cctx` */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize); + +/*! ZSTD_CCtx_loadDictionary_advanced() : + * Same as ZSTD_CCtx_loadDictionary(), but gives finer control over + * how to load the dictionary (by copy ? by reference ?) + * and how to interpret it (automatic ? force raw mode ? full mode only ?) */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType); + +/*! ZSTD_CCtx_refPrefix_advanced() : + * Same as ZSTD_CCtx_refPrefix(), but gives finer control over + * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType); + +/* === experimental parameters === */ +/* these parameters can be used with ZSTD_setParameter() + * they are not guaranteed to remain supported in the future */ + + /* Enables rsyncable mode, + * which makes compressed files more rsync friendly + * by adding periodic synchronization points to the compressed data. + * The target average block size is ZSTD_c_jobSize / 2. + * It's possible to modify the job size to increase or decrease + * the granularity of the synchronization point. + * Once the jobSize is smaller than the window size, + * it will result in compression ratio degradation. + * NOTE 1: rsyncable mode only works when multithreading is enabled. + * NOTE 2: rsyncable performs poorly in combination with long range mode, + * since it will decrease the effectiveness of synchronization points, + * though mileage may vary. + * NOTE 3: Rsyncable mode limits maximum compression speed to ~400 MB/s. + * If the selected compression level is already running significantly slower, + * the overall speed won't be significantly impacted. + */ + #define ZSTD_c_rsyncable ZSTD_c_experimentalParam1 + +/* Select a compression format. + * The value must be of type ZSTD_format_e. + * See ZSTD_format_e enum definition for details */ +#define ZSTD_c_format ZSTD_c_experimentalParam2 + +/* Force back-reference distances to remain < windowSize, + * even when referencing into Dictionary content (default:0) */ +#define ZSTD_c_forceMaxWindow ZSTD_c_experimentalParam3 + +/* Controls whether the contents of a CDict + * are used in place, or copied into the working context. + * Accepts values from the ZSTD_dictAttachPref_e enum. + * See the comments on that enum for an explanation of the feature. */ +#define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4 + +/* Controlled with ZSTD_ParamSwitch_e enum. + * Default is ZSTD_ps_auto. + * Set to ZSTD_ps_disable to never compress literals. + * Set to ZSTD_ps_enable to always compress literals. (Note: uncompressed literals + * may still be emitted if huffman is not beneficial to use.) + * + * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use + * literals compression based on the compression parameters - specifically, + * negative compression levels do not use literal compression. + */ +#define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5 + +/* User's best guess of source size. + * Hint is not valid when srcSizeHint == 0. + * There is no guarantee that hint is close to actual source size, + * but compression ratio may regress significantly if guess considerably underestimates */ +#define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7 + +/* Controls whether the new and experimental "dedicated dictionary search + * structure" can be used. This feature is still rough around the edges, be + * prepared for surprising behavior! + * + * How to use it: + * + * When using a CDict, whether to use this feature or not is controlled at + * CDict creation, and it must be set in a CCtxParams set passed into that + * construction (via ZSTD_createCDict_advanced2()). A compression will then + * use the feature or not based on how the CDict was constructed; the value of + * this param, set in the CCtx, will have no effect. + * + * However, when a dictionary buffer is passed into a CCtx, such as via + * ZSTD_CCtx_loadDictionary(), this param can be set on the CCtx to control + * whether the CDict that is created internally can use the feature or not. + * + * What it does: + * + * Normally, the internal data structures of the CDict are analogous to what + * would be stored in a CCtx after compressing the contents of a dictionary. + * To an approximation, a compression using a dictionary can then use those + * data structures to simply continue what is effectively a streaming + * compression where the simulated compression of the dictionary left off. + * Which is to say, the search structures in the CDict are normally the same + * format as in the CCtx. + * + * It is possible to do better, since the CDict is not like a CCtx: the search + * structures are written once during CDict creation, and then are only read + * after that, while the search structures in the CCtx are both read and + * written as the compression goes along. This means we can choose a search + * structure for the dictionary that is read-optimized. + * + * This feature enables the use of that different structure. + * + * Note that some of the members of the ZSTD_compressionParameters struct have + * different semantics and constraints in the dedicated search structure. It is + * highly recommended that you simply set a compression level in the CCtxParams + * you pass into the CDict creation call, and avoid messing with the cParams + * directly. + * + * Effects: + * + * This will only have any effect when the selected ZSTD_strategy + * implementation supports this feature. Currently, that's limited to + * ZSTD_greedy, ZSTD_lazy, and ZSTD_lazy2. + * + * Note that this means that the CDict tables can no longer be copied into the + * CCtx, so the dict attachment mode ZSTD_dictForceCopy will no longer be + * usable. The dictionary can only be attached or reloaded. + * + * In general, you should expect compression to be faster--sometimes very much + * so--and CDict creation to be slightly slower. Eventually, we will probably + * make this mode the default. + */ +#define ZSTD_c_enableDedicatedDictSearch ZSTD_c_experimentalParam8 + +/* ZSTD_c_stableInBuffer + * Experimental parameter. + * Default is 0 == disabled. Set to 1 to enable. + * + * Tells the compressor that input data presented with ZSTD_inBuffer + * will ALWAYS be the same between calls. + * Technically, the @src pointer must never be changed, + * and the @pos field can only be updated by zstd. + * However, it's possible to increase the @size field, + * allowing scenarios where more data can be appended after compressions starts. + * These conditions are checked by the compressor, + * and compression will fail if they are not respected. + * Also, data in the ZSTD_inBuffer within the range [src, src + pos) + * MUST not be modified during compression or it will result in data corruption. + * + * When this flag is enabled zstd won't allocate an input window buffer, + * because the user guarantees it can reference the ZSTD_inBuffer until + * the frame is complete. But, it will still allocate an output buffer + * large enough to fit a block (see ZSTD_c_stableOutBuffer). This will also + * avoid the memcpy() from the input buffer to the input window buffer. + * + * NOTE: So long as the ZSTD_inBuffer always points to valid memory, using + * this flag is ALWAYS memory safe, and will never access out-of-bounds + * memory. However, compression WILL fail if conditions are not respected. + * + * WARNING: The data in the ZSTD_inBuffer in the range [src, src + pos) MUST + * not be modified during compression or it will result in data corruption. + * This is because zstd needs to reference data in the ZSTD_inBuffer to find + * matches. Normally zstd maintains its own window buffer for this purpose, + * but passing this flag tells zstd to rely on user provided buffer instead. + */ +#define ZSTD_c_stableInBuffer ZSTD_c_experimentalParam9 + +/* ZSTD_c_stableOutBuffer + * Experimental parameter. + * Default is 0 == disabled. Set to 1 to enable. + * + * Tells he compressor that the ZSTD_outBuffer will not be resized between + * calls. Specifically: (out.size - out.pos) will never grow. This gives the + * compressor the freedom to say: If the compressed data doesn't fit in the + * output buffer then return ZSTD_error_dstSizeTooSmall. This allows us to + * always decompress directly into the output buffer, instead of decompressing + * into an internal buffer and copying to the output buffer. + * + * When this flag is enabled zstd won't allocate an output buffer, because + * it can write directly to the ZSTD_outBuffer. It will still allocate the + * input window buffer (see ZSTD_c_stableInBuffer). + * + * Zstd will check that (out.size - out.pos) never grows and return an error + * if it does. While not strictly necessary, this should prevent surprises. + */ +#define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10 + +/* ZSTD_c_blockDelimiters + * Default is 0 == ZSTD_sf_noBlockDelimiters. + * + * For use with sequence compression API: ZSTD_compressSequences(). + * + * Designates whether or not the given array of ZSTD_Sequence contains block delimiters + * and last literals, which are defined as sequences with offset == 0 and matchLength == 0. + * See the definition of ZSTD_Sequence for more specifics. + */ +#define ZSTD_c_blockDelimiters ZSTD_c_experimentalParam11 + +/* ZSTD_c_validateSequences + * Default is 0 == disabled. Set to 1 to enable sequence validation. + * + * For use with sequence compression API: ZSTD_compressSequences*(). + * Designates whether or not provided sequences are validated within ZSTD_compressSequences*() + * during function execution. + * + * When Sequence validation is disabled (default), Sequences are compressed as-is, + * so they must correct, otherwise it would result in a corruption error. + * + * Sequence validation adds some protection, by ensuring that all values respect boundary conditions. + * If a Sequence is detected invalid (see doc/zstd_compression_format.md for + * specifics regarding offset/matchlength requirements) then the function will bail out and + * return an error. + */ +#define ZSTD_c_validateSequences ZSTD_c_experimentalParam12 + +/* ZSTD_c_blockSplitterLevel + * note: this parameter only influences the first splitter stage, + * which is active before producing the sequences. + * ZSTD_c_splitAfterSequences controls the next splitter stage, + * which is active after sequence production. + * Note that both can be combined. + * Allowed values are between 0 and ZSTD_BLOCKSPLITTER_LEVEL_MAX included. + * 0 means "auto", which will select a value depending on current ZSTD_c_strategy. + * 1 means no splitting. + * Then, values from 2 to 6 are sorted in increasing cpu load order. + * + * Note that currently the first block is never split, + * to ensure expansion guarantees in presence of incompressible data. + */ +#define ZSTD_BLOCKSPLITTER_LEVEL_MAX 6 +#define ZSTD_c_blockSplitterLevel ZSTD_c_experimentalParam20 + +/* ZSTD_c_splitAfterSequences + * This is a stronger splitter algorithm, + * based on actual sequences previously produced by the selected parser. + * It's also slower, and as a consequence, mostly used for high compression levels. + * While the post-splitter does overlap with the pre-splitter, + * both can nonetheless be combined, + * notably with ZSTD_c_blockSplitterLevel at ZSTD_BLOCKSPLITTER_LEVEL_MAX, + * resulting in higher compression ratio than just one of them. + * + * Default is ZSTD_ps_auto. + * Set to ZSTD_ps_disable to never use block splitter. + * Set to ZSTD_ps_enable to always use block splitter. + * + * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use + * block splitting based on the compression parameters. + */ +#define ZSTD_c_splitAfterSequences ZSTD_c_experimentalParam13 + +/* ZSTD_c_useRowMatchFinder + * Controlled with ZSTD_ParamSwitch_e enum. + * Default is ZSTD_ps_auto. + * Set to ZSTD_ps_disable to never use row-based matchfinder. + * Set to ZSTD_ps_enable to force usage of row-based matchfinder. + * + * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use + * the row-based matchfinder based on support for SIMD instructions and the window log. + * Note that this only pertains to compression strategies: greedy, lazy, and lazy2 + */ +#define ZSTD_c_useRowMatchFinder ZSTD_c_experimentalParam14 + +/* ZSTD_c_deterministicRefPrefix + * Default is 0 == disabled. Set to 1 to enable. + * + * Zstd produces different results for prefix compression when the prefix is + * directly adjacent to the data about to be compressed vs. when it isn't. + * This is because zstd detects that the two buffers are contiguous and it can + * use a more efficient match finding algorithm. However, this produces different + * results than when the two buffers are non-contiguous. This flag forces zstd + * to always load the prefix in non-contiguous mode, even if it happens to be + * adjacent to the data, to guarantee determinism. + * + * If you really care about determinism when using a dictionary or prefix, + * like when doing delta compression, you should select this option. It comes + * at a speed penalty of about ~2.5% if the dictionary and data happened to be + * contiguous, and is free if they weren't contiguous. We don't expect that + * intentionally making the dictionary and data contiguous will be worth the + * cost to memcpy() the data. + */ +#define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15 + +/* ZSTD_c_prefetchCDictTables + * Controlled with ZSTD_ParamSwitch_e enum. Default is ZSTD_ps_auto. + * + * In some situations, zstd uses CDict tables in-place rather than copying them + * into the working context. (See docs on ZSTD_dictAttachPref_e above for details). + * In such situations, compression speed is seriously impacted when CDict tables are + * "cold" (outside CPU cache). This parameter instructs zstd to prefetch CDict tables + * when they are used in-place. + * + * For sufficiently small inputs, the cost of the prefetch will outweigh the benefit. + * For sufficiently large inputs, zstd will by default memcpy() CDict tables + * into the working context, so there is no need to prefetch. This parameter is + * targeted at a middle range of input sizes, where a prefetch is cheap enough to be + * useful but memcpy() is too expensive. The exact range of input sizes where this + * makes sense is best determined by careful experimentation. + * + * Note: for this parameter, ZSTD_ps_auto is currently equivalent to ZSTD_ps_disable, + * but in the future zstd may conditionally enable this feature via an auto-detection + * heuristic for cold CDicts. + * Use ZSTD_ps_disable to opt out of prefetching under any circumstances. + */ +#define ZSTD_c_prefetchCDictTables ZSTD_c_experimentalParam16 + +/* ZSTD_c_enableSeqProducerFallback + * Allowed values are 0 (disable) and 1 (enable). The default setting is 0. + * + * Controls whether zstd will fall back to an internal sequence producer if an + * external sequence producer is registered and returns an error code. This fallback + * is block-by-block: the internal sequence producer will only be called for blocks + * where the external sequence producer returns an error code. Fallback parsing will + * follow any other cParam settings, such as compression level, the same as in a + * normal (fully-internal) compression operation. + * + * The user is strongly encouraged to read the full Block-Level Sequence Producer API + * documentation (below) before setting this parameter. */ +#define ZSTD_c_enableSeqProducerFallback ZSTD_c_experimentalParam17 + +/* ZSTD_c_maxBlockSize + * Allowed values are between 1KB and ZSTD_BLOCKSIZE_MAX (128KB). + * The default is ZSTD_BLOCKSIZE_MAX, and setting to 0 will set to the default. + * + * This parameter can be used to set an upper bound on the blocksize + * that overrides the default ZSTD_BLOCKSIZE_MAX. It cannot be used to set upper + * bounds greater than ZSTD_BLOCKSIZE_MAX or bounds lower than 1KB (will make + * compressBound() inaccurate). Only currently meant to be used for testing. + */ +#define ZSTD_c_maxBlockSize ZSTD_c_experimentalParam18 + +/* ZSTD_c_repcodeResolution + * This parameter only has an effect if ZSTD_c_blockDelimiters is + * set to ZSTD_sf_explicitBlockDelimiters (may change in the future). + * + * This parameter affects how zstd parses external sequences, + * provided via the ZSTD_compressSequences*() API + * or from an external block-level sequence producer. + * + * If set to ZSTD_ps_enable, the library will check for repeated offsets within + * external sequences, even if those repcodes are not explicitly indicated in + * the "rep" field. Note that this is the only way to exploit repcode matches + * while using compressSequences*() or an external sequence producer, since zstd + * currently ignores the "rep" field of external sequences. + * + * If set to ZSTD_ps_disable, the library will not exploit repeated offsets in + * external sequences, regardless of whether the "rep" field has been set. This + * reduces sequence compression overhead by about 25% while sacrificing some + * compression ratio. + * + * The default value is ZSTD_ps_auto, for which the library will enable/disable + * based on compression level (currently: level<10 disables, level>=10 enables). + */ +#define ZSTD_c_repcodeResolution ZSTD_c_experimentalParam19 +#define ZSTD_c_searchForExternalRepcodes ZSTD_c_experimentalParam19 /* older name */ + + +/*! ZSTD_CCtx_getParameter() : + * Get the requested compression parameter value, selected by enum ZSTD_cParameter, + * and store it into int* value. + * @return : 0, or an error code (which can be tested with ZSTD_isError()). + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_getParameter(const ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value); + + +/*! ZSTD_CCtx_params : + * Quick howto : + * - ZSTD_createCCtxParams() : Create a ZSTD_CCtx_params structure + * - ZSTD_CCtxParams_setParameter() : Push parameters one by one into + * an existing ZSTD_CCtx_params structure. + * This is similar to + * ZSTD_CCtx_setParameter(). + * - ZSTD_CCtx_setParametersUsingCCtxParams() : Apply parameters to + * an existing CCtx. + * These parameters will be applied to + * all subsequent frames. + * - ZSTD_compressStream2() : Do compression using the CCtx. + * - ZSTD_freeCCtxParams() : Free the memory, accept NULL pointer. + * + * This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams() + * for static allocation of CCtx for single-threaded compression. + */ +ZSTDLIB_STATIC_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void); +ZSTDLIB_STATIC_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); /* accept NULL pointer */ + +/*! ZSTD_CCtxParams_reset() : + * Reset params to default values. + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params); + +/*! ZSTD_CCtxParams_init() : + * Initializes the compression parameters of cctxParams according to + * compression level. All other parameters are reset to their default values. + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel); + +/*! ZSTD_CCtxParams_init_advanced() : + * Initializes the compression and frame parameters of cctxParams according to + * params. All other parameters are reset to their default values. + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params); + +/*! ZSTD_CCtxParams_setParameter() : Requires v1.4.0+ + * Similar to ZSTD_CCtx_setParameter. + * Set one compression parameter, selected by enum ZSTD_cParameter. + * Parameters must be applied to a ZSTD_CCtx using + * ZSTD_CCtx_setParametersUsingCCtxParams(). + * @result : a code representing success or failure (which can be tested with + * ZSTD_isError()). + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value); + +/*! ZSTD_CCtxParams_getParameter() : + * Similar to ZSTD_CCtx_getParameter. + * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_getParameter(const ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value); + +/*! ZSTD_CCtx_setParametersUsingCCtxParams() : + * Apply a set of ZSTD_CCtx_params to the compression context. + * This can be done even after compression is started, + * if nbWorkers==0, this will have no impact until a new compression is started. + * if nbWorkers>=1, new parameters will be picked up at next job, + * with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated). + */ +ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParametersUsingCCtxParams( + ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params); + +/*! ZSTD_compressStream2_simpleArgs() : + * Same as ZSTD_compressStream2(), + * but using only integral types as arguments. + * This variant might be helpful for binders from dynamic languages + * which have troubles handling structures containing memory pointers. + */ +ZSTDLIB_STATIC_API size_t ZSTD_compressStream2_simpleArgs ( + ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, size_t* dstPos, + const void* src, size_t srcSize, size_t* srcPos, + ZSTD_EndDirective endOp); + + +/*************************************** +* Advanced decompression functions +***************************************/ + +/*! ZSTD_isFrame() : + * Tells if the content of `buffer` starts with a valid Frame Identifier. + * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. + * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled. + * Note 3 : Skippable Frame Identifiers are considered valid. */ +ZSTDLIB_STATIC_API unsigned ZSTD_isFrame(const void* buffer, size_t size); + +/*! ZSTD_createDDict_byReference() : + * Create a digested dictionary, ready to start decompression operation without startup delay. + * Dictionary content is referenced, and therefore stays in dictBuffer. + * It is important that dictBuffer outlives DDict, + * it must remain read accessible throughout the lifetime of DDict */ +ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize); + +/*! ZSTD_DCtx_loadDictionary_byReference() : + * Same as ZSTD_DCtx_loadDictionary(), + * but references `dict` content instead of copying it into `dctx`. + * This saves memory if `dict` remains around., + * However, it's imperative that `dict` remains accessible (and unmodified) while being used, so it must outlive decompression. */ +ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); + +/*! ZSTD_DCtx_loadDictionary_advanced() : + * Same as ZSTD_DCtx_loadDictionary(), + * but gives direct control over + * how to load the dictionary (by copy ? by reference ?) + * and how to interpret it (automatic ? force raw mode ? full mode only ?). */ +ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType); + +/*! ZSTD_DCtx_refPrefix_advanced() : + * Same as ZSTD_DCtx_refPrefix(), but gives finer control over + * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */ +ZSTDLIB_STATIC_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType); + +/*! ZSTD_DCtx_setMaxWindowSize() : + * Refuses allocating internal buffers for frames requiring a window size larger than provided limit. + * This protects a decoder context from reserving too much memory for itself (potential attack scenario). + * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode. + * By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) + * @return : 0, or an error code (which can be tested using ZSTD_isError()). + */ +ZSTDLIB_STATIC_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize); + +/*! ZSTD_DCtx_getParameter() : + * Get the requested decompression parameter value, selected by enum ZSTD_dParameter, + * and store it into int* value. + * @return : 0, or an error code (which can be tested with ZSTD_isError()). + */ +ZSTDLIB_STATIC_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int* value); + +/* ZSTD_d_format + * experimental parameter, + * allowing selection between ZSTD_format_e input compression formats + */ +#define ZSTD_d_format ZSTD_d_experimentalParam1 +/* ZSTD_d_stableOutBuffer + * Experimental parameter. + * Default is 0 == disabled. Set to 1 to enable. + * + * Tells the decompressor that the ZSTD_outBuffer will ALWAYS be the same + * between calls, except for the modifications that zstd makes to pos (the + * caller must not modify pos). This is checked by the decompressor, and + * decompression will fail if it ever changes. Therefore the ZSTD_outBuffer + * MUST be large enough to fit the entire decompressed frame. This will be + * checked when the frame content size is known. The data in the ZSTD_outBuffer + * in the range [dst, dst + pos) MUST not be modified during decompression + * or you will get data corruption. + * + * When this flag is enabled zstd won't allocate an output buffer, because + * it can write directly to the ZSTD_outBuffer, but it will still allocate + * an input buffer large enough to fit any compressed block. This will also + * avoid the memcpy() from the internal output buffer to the ZSTD_outBuffer. + * If you need to avoid the input buffer allocation use the buffer-less + * streaming API. + * + * NOTE: So long as the ZSTD_outBuffer always points to valid memory, using + * this flag is ALWAYS memory safe, and will never access out-of-bounds + * memory. However, decompression WILL fail if you violate the preconditions. + * + * WARNING: The data in the ZSTD_outBuffer in the range [dst, dst + pos) MUST + * not be modified during decompression or you will get data corruption. This + * is because zstd needs to reference data in the ZSTD_outBuffer to regenerate + * matches. Normally zstd maintains its own buffer for this purpose, but passing + * this flag tells zstd to use the user provided buffer. + */ +#define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2 + +/* ZSTD_d_forceIgnoreChecksum + * Experimental parameter. + * Default is 0 == disabled. Set to 1 to enable + * + * Tells the decompressor to skip checksum validation during decompression, regardless + * of whether checksumming was specified during compression. This offers some + * slight performance benefits, and may be useful for debugging. + * Param has values of type ZSTD_forceIgnoreChecksum_e + */ +#define ZSTD_d_forceIgnoreChecksum ZSTD_d_experimentalParam3 + +/* ZSTD_d_refMultipleDDicts + * Experimental parameter. + * Default is 0 == disabled. Set to 1 to enable + * + * If enabled and dctx is allocated on the heap, then additional memory will be allocated + * to store references to multiple ZSTD_DDict. That is, multiple calls of ZSTD_refDDict() + * using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead + * store all references. At decompression time, the appropriate dictID is selected + * from the set of DDicts based on the dictID in the frame. + * + * Usage is simply calling ZSTD_refDDict() on multiple dict buffers. + * + * Param has values of byte ZSTD_refMultipleDDicts_e + * + * WARNING: Enabling this parameter and calling ZSTD_DCtx_refDDict(), will trigger memory + * allocation for the hash table. ZSTD_freeDCtx() also frees this memory. + * Memory is allocated as per ZSTD_DCtx::customMem. + * + * Although this function allocates memory for the table, the user is still responsible for + * memory management of the underlying ZSTD_DDict* themselves. + */ +#define ZSTD_d_refMultipleDDicts ZSTD_d_experimentalParam4 + +/* ZSTD_d_disableHuffmanAssembly + * Set to 1 to disable the Huffman assembly implementation. + * The default value is 0, which allows zstd to use the Huffman assembly + * implementation if available. + * + * This parameter can be used to disable Huffman assembly at runtime. + * If you want to disable it at compile time you can define the macro + * ZSTD_DISABLE_ASM. + */ +#define ZSTD_d_disableHuffmanAssembly ZSTD_d_experimentalParam5 + +/* ZSTD_d_maxBlockSize + * Allowed values are between 1KB and ZSTD_BLOCKSIZE_MAX (128KB). + * The default is ZSTD_BLOCKSIZE_MAX, and setting to 0 will set to the default. + * + * Forces the decompressor to reject blocks whose content size is + * larger than the configured maxBlockSize. When maxBlockSize is + * larger than the windowSize, the windowSize is used instead. + * This saves memory on the decoder when you know all blocks are small. + * + * This option is typically used in conjunction with ZSTD_c_maxBlockSize. + * + * WARNING: This causes the decoder to reject otherwise valid frames + * that have block sizes larger than the configured maxBlockSize. + */ +#define ZSTD_d_maxBlockSize ZSTD_d_experimentalParam6 + + +/*! ZSTD_DCtx_setFormat() : + * This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter(). + * Instruct the decoder context about what kind of data to decode next. + * This instruction is mandatory to decode data without a fully-formed header, + * such ZSTD_f_zstd1_magicless for example. + * @return : 0, or an error code (which can be tested using ZSTD_isError()). */ +ZSTD_DEPRECATED("use ZSTD_DCtx_setParameter() instead") +ZSTDLIB_STATIC_API +size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format); + +/*! ZSTD_decompressStream_simpleArgs() : + * Same as ZSTD_decompressStream(), + * but using only integral types as arguments. + * This can be helpful for binders from dynamic languages + * which have troubles handling structures containing memory pointers. + */ +ZSTDLIB_STATIC_API size_t ZSTD_decompressStream_simpleArgs ( + ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, size_t* dstPos, + const void* src, size_t srcSize, size_t* srcPos); + + +/******************************************************************** +* Advanced streaming functions +* Warning : most of these functions are now redundant with the Advanced API. +* Once Advanced API reaches "stable" status, +* redundant functions will be deprecated, and then at some point removed. +********************************************************************/ + +/*===== Advanced Streaming compression functions =====*/ + +/*! ZSTD_initCStream_srcSize() : + * This function is DEPRECATED, and equivalent to: + * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); + * ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) + * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); + * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); + * + * pledgedSrcSize must be correct. If it is not known at init time, use + * ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, + * "0" also disables frame content size field. It may be enabled in the future. + * This prototype will generate compilation warnings. + */ +ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API +size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, + int compressionLevel, + unsigned long long pledgedSrcSize); + +/*! ZSTD_initCStream_usingDict() : + * This function is DEPRECATED, and is equivalent to: + * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); + * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); + * ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); + * + * Creates of an internal CDict (incompatible with static CCtx), except if + * dict == NULL or dictSize < 8, in which case no dict is used. + * Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if + * it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy. + * This prototype will generate compilation warnings. + */ +ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API +size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, + const void* dict, size_t dictSize, + int compressionLevel); + +/*! ZSTD_initCStream_advanced() : + * This function is DEPRECATED, and is equivalent to: + * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); + * ZSTD_CCtx_setParams(zcs, params); + * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); + * ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); + * + * dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy. + * pledgedSrcSize must be correct. + * If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. + * This prototype will generate compilation warnings. + */ +ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API +size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, + const void* dict, size_t dictSize, + ZSTD_parameters params, + unsigned long long pledgedSrcSize); + +/*! ZSTD_initCStream_usingCDict() : + * This function is DEPRECATED, and equivalent to: + * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); + * ZSTD_CCtx_refCDict(zcs, cdict); + * + * note : cdict will just be referenced, and must outlive compression session + * This prototype will generate compilation warnings. + */ +ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API +size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); + +/*! ZSTD_initCStream_usingCDict_advanced() : + * This function is DEPRECATED, and is equivalent to: + * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); + * ZSTD_CCtx_setFParams(zcs, fParams); + * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); + * ZSTD_CCtx_refCDict(zcs, cdict); + * + * same as ZSTD_initCStream_usingCDict(), with control over frame parameters. + * pledgedSrcSize must be correct. If srcSize is not known at init time, use + * value ZSTD_CONTENTSIZE_UNKNOWN. + * This prototype will generate compilation warnings. + */ +ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API +size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, + const ZSTD_CDict* cdict, + ZSTD_frameParameters fParams, + unsigned long long pledgedSrcSize); + +/*! ZSTD_resetCStream() : + * This function is DEPRECATED, and is equivalent to: + * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); + * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); + * Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but + * ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be + * explicitly specified. + * + * start a new frame, using same parameters from previous frame. + * This is typically useful to skip dictionary loading stage, since it will reuse it in-place. + * Note that zcs must be init at least once before using ZSTD_resetCStream(). + * If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN. + * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end. + * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs, + * but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead. + * @return : 0, or an error code (which can be tested using ZSTD_isError()) + * This prototype will generate compilation warnings. + */ +ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API +size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); + + +typedef struct { + unsigned long long ingested; /* nb input bytes read and buffered */ + unsigned long long consumed; /* nb input bytes actually compressed */ + unsigned long long produced; /* nb of compressed bytes generated and buffered */ + unsigned long long flushed; /* nb of compressed bytes flushed : not provided; can be tracked from caller side */ + unsigned currentJobID; /* MT only : latest started job nb */ + unsigned nbActiveWorkers; /* MT only : nb of workers actively compressing at probe time */ +} ZSTD_frameProgression; + +/* ZSTD_getFrameProgression() : + * tells how much data has been ingested (read from input) + * consumed (input actually compressed) and produced (output) for current frame. + * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed. + * Aggregates progression inside active worker threads. + */ +ZSTDLIB_STATIC_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx); + +/*! ZSTD_toFlushNow() : + * Tell how many bytes are ready to be flushed immediately. + * Useful for multithreading scenarios (nbWorkers >= 1). + * Probe the oldest active job, defined as oldest job not yet entirely flushed, + * and check its output buffer. + * @return : amount of data stored in oldest job and ready to be flushed immediately. + * if @return == 0, it means either : + * + there is no active job (could be checked with ZSTD_frameProgression()), or + * + oldest job is still actively compressing data, + * but everything it has produced has also been flushed so far, + * therefore flush speed is limited by production speed of oldest job + * irrespective of the speed of concurrent (and newer) jobs. + */ +ZSTDLIB_STATIC_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx); + + +/*===== Advanced Streaming decompression functions =====*/ + +/*! + * This function is deprecated, and is equivalent to: + * + * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); + * ZSTD_DCtx_loadDictionary(zds, dict, dictSize); + * + * note: no dictionary will be used if dict == NULL or dictSize < 8 + */ +ZSTD_DEPRECATED("use ZSTD_DCtx_reset + ZSTD_DCtx_loadDictionary, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); + +/*! + * This function is deprecated, and is equivalent to: + * + * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); + * ZSTD_DCtx_refDDict(zds, ddict); + * + * note : ddict is referenced, it must outlive decompression session + */ +ZSTD_DEPRECATED("use ZSTD_DCtx_reset + ZSTD_DCtx_refDDict, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); + +/*! + * This function is deprecated, and is equivalent to: + * + * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); + * + * reuse decompression parameters from previous init; saves dictionary loading + */ +ZSTD_DEPRECATED("use ZSTD_DCtx_reset, see zstd.h for detailed instructions") +ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); + + +/* ********************* BLOCK-LEVEL SEQUENCE PRODUCER API ********************* + * + * *** OVERVIEW *** + * The Block-Level Sequence Producer API allows users to provide their own custom + * sequence producer which libzstd invokes to process each block. The produced list + * of sequences (literals and matches) is then post-processed by libzstd to produce + * valid compressed blocks. + * + * This block-level offload API is a more granular complement of the existing + * frame-level offload API compressSequences() (introduced in v1.5.1). It offers + * an easier migration story for applications already integrated with libzstd: the + * user application continues to invoke the same compression functions + * ZSTD_compress2() or ZSTD_compressStream2() as usual, and transparently benefits + * from the specific advantages of the external sequence producer. For example, + * the sequence producer could be tuned to take advantage of known characteristics + * of the input, to offer better speed / ratio, or could leverage hardware + * acceleration not available within libzstd itself. + * + * See contrib/externalSequenceProducer for an example program employing the + * Block-Level Sequence Producer API. + * + * *** USAGE *** + * The user is responsible for implementing a function of type + * ZSTD_sequenceProducer_F. For each block, zstd will pass the following + * arguments to the user-provided function: + * + * - sequenceProducerState: a pointer to a user-managed state for the sequence + * producer. + * + * - outSeqs, outSeqsCapacity: an output buffer for the sequence producer. + * outSeqsCapacity is guaranteed >= ZSTD_sequenceBound(srcSize). The memory + * backing outSeqs is managed by the CCtx. + * + * - src, srcSize: an input buffer for the sequence producer to parse. + * srcSize is guaranteed to be <= ZSTD_BLOCKSIZE_MAX. + * + * - dict, dictSize: a history buffer, which may be empty, which the sequence + * producer may reference as it parses the src buffer. Currently, zstd will + * always pass dictSize == 0 into external sequence producers, but this will + * change in the future. + * + * - compressionLevel: a signed integer representing the zstd compression level + * set by the user for the current operation. The sequence producer may choose + * to use this information to change its compression strategy and speed/ratio + * tradeoff. Note: the compression level does not reflect zstd parameters set + * through the advanced API. + * + * - windowSize: a size_t representing the maximum allowed offset for external + * sequences. Note that sequence offsets are sometimes allowed to exceed the + * windowSize if a dictionary is present, see doc/zstd_compression_format.md + * for details. + * + * The user-provided function shall return a size_t representing the number of + * sequences written to outSeqs. This return value will be treated as an error + * code if it is greater than outSeqsCapacity. The return value must be non-zero + * if srcSize is non-zero. The ZSTD_SEQUENCE_PRODUCER_ERROR macro is provided + * for convenience, but any value greater than outSeqsCapacity will be treated as + * an error code. + * + * If the user-provided function does not return an error code, the sequences + * written to outSeqs must be a valid parse of the src buffer. Data corruption may + * occur if the parse is not valid. A parse is defined to be valid if the + * following conditions hold: + * - The sum of matchLengths and literalLengths must equal srcSize. + * - All sequences in the parse, except for the final sequence, must have + * matchLength >= ZSTD_MINMATCH_MIN. The final sequence must have + * matchLength >= ZSTD_MINMATCH_MIN or matchLength == 0. + * - All offsets must respect the windowSize parameter as specified in + * doc/zstd_compression_format.md. + * - If the final sequence has matchLength == 0, it must also have offset == 0. + * + * zstd will only validate these conditions (and fail compression if they do not + * hold) if the ZSTD_c_validateSequences cParam is enabled. Note that sequence + * validation has a performance cost. + * + * If the user-provided function returns an error, zstd will either fall back + * to an internal sequence producer or fail the compression operation. The user can + * choose between the two behaviors by setting the ZSTD_c_enableSeqProducerFallback + * cParam. Fallback compression will follow any other cParam settings, such as + * compression level, the same as in a normal compression operation. + * + * The user shall instruct zstd to use a particular ZSTD_sequenceProducer_F + * function by calling + * ZSTD_registerSequenceProducer(cctx, + * sequenceProducerState, + * sequenceProducer) + * This setting will persist until the next parameter reset of the CCtx. + * + * The sequenceProducerState must be initialized by the user before calling + * ZSTD_registerSequenceProducer(). The user is responsible for destroying the + * sequenceProducerState. + * + * *** LIMITATIONS *** + * This API is compatible with all zstd compression APIs which respect advanced parameters. + * However, there are three limitations: + * + * First, the ZSTD_c_enableLongDistanceMatching cParam is not currently supported. + * COMPRESSION WILL FAIL if it is enabled and the user tries to compress with a block-level + * external sequence producer. + * - Note that ZSTD_c_enableLongDistanceMatching is auto-enabled by default in some + * cases (see its documentation for details). Users must explicitly set + * ZSTD_c_enableLongDistanceMatching to ZSTD_ps_disable in such cases if an external + * sequence producer is registered. + * - As of this writing, ZSTD_c_enableLongDistanceMatching is disabled by default + * whenever ZSTD_c_windowLog < 128MB, but that's subject to change. Users should + * check the docs on ZSTD_c_enableLongDistanceMatching whenever the Block-Level Sequence + * Producer API is used in conjunction with advanced settings (like ZSTD_c_windowLog). + * + * Second, history buffers are not currently supported. Concretely, zstd will always pass + * dictSize == 0 to the external sequence producer (for now). This has two implications: + * - Dictionaries are not currently supported. Compression will *not* fail if the user + * references a dictionary, but the dictionary won't have any effect. + * - Stream history is not currently supported. All advanced compression APIs, including + * streaming APIs, work with external sequence producers, but each block is treated as + * an independent chunk without history from previous blocks. + * + * Third, multi-threading within a single compression is not currently supported. In other words, + * COMPRESSION WILL FAIL if ZSTD_c_nbWorkers > 0 and an external sequence producer is registered. + * Multi-threading across compressions is fine: simply create one CCtx per thread. + * + * Long-term, we plan to overcome all three limitations. There is no technical blocker to + * overcoming them. It is purely a question of engineering effort. + */ + +#define ZSTD_SEQUENCE_PRODUCER_ERROR ((size_t)(-1)) + +typedef size_t (*ZSTD_sequenceProducer_F) ( + void* sequenceProducerState, + ZSTD_Sequence* outSeqs, size_t outSeqsCapacity, + const void* src, size_t srcSize, + const void* dict, size_t dictSize, + int compressionLevel, + size_t windowSize +); + +/*! ZSTD_registerSequenceProducer() : + * Instruct zstd to use a block-level external sequence producer function. + * + * The sequenceProducerState must be initialized by the caller, and the caller is + * responsible for managing its lifetime. This parameter is sticky across + * compressions. It will remain set until the user explicitly resets compression + * parameters. + * + * Sequence producer registration is considered to be an "advanced parameter", + * part of the "advanced API". This means it will only have an effect on compression + * APIs which respect advanced parameters, such as compress2() and compressStream2(). + * Older compression APIs such as compressCCtx(), which predate the introduction of + * "advanced parameters", will ignore any external sequence producer setting. + * + * The sequence producer can be "cleared" by registering a NULL function pointer. This + * removes all limitations described above in the "LIMITATIONS" section of the API docs. + * + * The user is strongly encouraged to read the full API documentation (above) before + * calling this function. */ +ZSTDLIB_STATIC_API void +ZSTD_registerSequenceProducer( + ZSTD_CCtx* cctx, + void* sequenceProducerState, + ZSTD_sequenceProducer_F sequenceProducer +); + +/*! ZSTD_CCtxParams_registerSequenceProducer() : + * Same as ZSTD_registerSequenceProducer(), but operates on ZSTD_CCtx_params. + * This is used for accurate size estimation with ZSTD_estimateCCtxSize_usingCCtxParams(), + * which is needed when creating a ZSTD_CCtx with ZSTD_initStaticCCtx(). + * + * If you are using the external sequence producer API in a scenario where ZSTD_initStaticCCtx() + * is required, then this function is for you. Otherwise, you probably don't need it. + * + * See tests/zstreamtest.c for example usage. */ +ZSTDLIB_STATIC_API void +ZSTD_CCtxParams_registerSequenceProducer( + ZSTD_CCtx_params* params, + void* sequenceProducerState, + ZSTD_sequenceProducer_F sequenceProducer +); + + +/********************************************************************* +* Buffer-less and synchronous inner streaming functions (DEPRECATED) +* +* This API is deprecated, and will be removed in a future version. +* It allows streaming (de)compression with user allocated buffers. +* However, it is hard to use, and not as well tested as the rest of +* our API. +* +* Please use the normal streaming API instead: ZSTD_compressStream2, +* and ZSTD_decompressStream. +* If there is functionality that you need, but it doesn't provide, +* please open an issue on our GitHub. +********************************************************************* */ + +/** + Buffer-less streaming compression (synchronous mode) + + A ZSTD_CCtx object is required to track streaming operations. + Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource. + ZSTD_CCtx object can be reused multiple times within successive compression operations. + + Start by initializing a context. + Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression. + + Then, consume your input using ZSTD_compressContinue(). + There are some important considerations to keep in mind when using this advanced function : + - ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only. + - Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks. + - Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario. + Worst case evaluation is provided by ZSTD_compressBound(). + ZSTD_compressContinue() doesn't guarantee recover after a failed compression. + - ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog). + It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks) + - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps. + In which case, it will "discard" the relevant memory section from its history. + + Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum. + It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame. + Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders. + + `ZSTD_CCtx` object can be reused (ZSTD_compressBegin()) to compress again. +*/ + +/*===== Buffer-less streaming compression functions =====*/ +ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel); +ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel); +ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */ + +ZSTD_DEPRECATED("This function will likely be removed in a future release. It is misleading and has very limited utility.") +ZSTDLIB_STATIC_API +size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */ + +ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); +ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); + +/* The ZSTD_compressBegin_advanced() and ZSTD_compressBegin_usingCDict_advanced() are now DEPRECATED and will generate a compiler warning */ +ZSTD_DEPRECATED("use advanced API to access custom parameters") +ZSTDLIB_STATIC_API +size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */ +ZSTD_DEPRECATED("use advanced API to access custom parameters") +ZSTDLIB_STATIC_API +size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */ +/** + Buffer-less streaming decompression (synchronous mode) + + A ZSTD_DCtx object is required to track streaming operations. + Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it. + A ZSTD_DCtx object can be reused multiple times. + + First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader(). + Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough. + Data fragment must be large enough to ensure successful decoding. + `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough. + result : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled. + >0 : `srcSize` is too small, please provide at least result bytes on next attempt. + errorCode, which can be tested using ZSTD_isError(). + + It fills a ZSTD_FrameHeader structure with important information to correctly decode the frame, + such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`). + Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information. + As a consequence, check that values remain within valid application range. + For example, do not allocate memory blindly, check that `windowSize` is within expectation. + Each application can set its own limits, depending on local restrictions. + For extended interoperability, it is recommended to support `windowSize` of at least 8 MB. + + ZSTD_decompressContinue() needs previous data blocks during decompression, up to `windowSize` bytes. + ZSTD_decompressContinue() is very sensitive to contiguity, + if 2 blocks don't follow each other, make sure that either the compressor breaks contiguity at the same place, + or that previous contiguous segment is large enough to properly handle maximum back-reference distance. + There are multiple ways to guarantee this condition. + + The most memory efficient way is to use a round buffer of sufficient size. + Sufficient size is determined by invoking ZSTD_decodingBufferSize_min(), + which can return an error code if required value is too large for current system (in 32-bits mode). + In a round buffer methodology, ZSTD_decompressContinue() decompresses each block next to previous one, + up to the moment there is not enough room left in the buffer to guarantee decoding another full block, + which maximum size is provided in `ZSTD_frameHeader` structure, field `blockSizeMax`. + At which point, decoding can resume from the beginning of the buffer. + Note that already decoded data stored in the buffer should be flushed before being overwritten. + + There are alternatives possible, for example using two or more buffers of size `windowSize` each, though they consume more memory. + + Finally, if you control the compression process, you can also ignore all buffer size rules, + as long as the encoder and decoder progress in "lock-step", + aka use exactly the same buffer sizes, break contiguity at the same place, etc. + + Once buffers are setup, start decompression, with ZSTD_decompressBegin(). + If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict(). + + Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively. + ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue(). + ZSTD_decompressContinue() requires this _exact_ amount of bytes, or it will fail. + + result of ZSTD_decompressContinue() is the number of bytes regenerated within 'dst' (necessarily <= dstCapacity). + It can be zero : it just means ZSTD_decompressContinue() has decoded some metadata item. + It can also be an error code, which can be tested with ZSTD_isError(). + + A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero. + Context can then be reset to start a new decompression. + + Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType(). + This information is not required to properly decode a frame. + + == Special case : skippable frames == + + Skippable frames allow integration of user-defined data into a flow of concatenated frames. + Skippable frames will be ignored (skipped) by decompressor. + The format of skippable frames is as follows : + a) Skippable frame ID - 4 Bytes, Little endian format, any value from 0x184D2A50 to 0x184D2A5F + b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits + c) Frame Content - any content (User Data) of length equal to Frame Size + For skippable frames ZSTD_getFrameHeader() returns zfhPtr->frameType==ZSTD_skippableFrame. + For skippable frames ZSTD_decompressContinue() always returns 0 : it only skips the content. +*/ + +/*===== Buffer-less streaming decompression functions =====*/ + +ZSTDLIB_STATIC_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */ + +ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx); +ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); +ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict); + +ZSTDLIB_STATIC_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx); +ZSTDLIB_STATIC_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); + +/* misc */ +ZSTD_DEPRECATED("This function will likely be removed in the next minor release. It is misleading and has very limited utility.") +ZSTDLIB_STATIC_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx); +typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e; +ZSTDLIB_STATIC_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx); + + + + +/* ========================================= */ +/** Block level API (DEPRECATED) */ +/* ========================================= */ + +/*! + + This API is deprecated in favor of the regular compression API. + You can get the frame header down to 2 bytes by setting: + - ZSTD_c_format = ZSTD_f_zstd1_magicless + - ZSTD_c_contentSizeFlag = 0 + - ZSTD_c_checksumFlag = 0 + - ZSTD_c_dictIDFlag = 0 + + This API is not as well tested as our normal API, so we recommend not using it. + We will be removing it in a future version. If the normal API doesn't provide + the functionality you need, please open a GitHub issue. + + Block functions produce and decode raw zstd blocks, without frame metadata. + Frame metadata cost is typically ~12 bytes, which can be non-negligible for very small blocks (< 100 bytes). + But users will have to take in charge needed metadata to regenerate data, such as compressed and content sizes. + + A few rules to respect : + - Compressing and decompressing require a context structure + + Use ZSTD_createCCtx() and ZSTD_createDCtx() + - It is necessary to init context before starting + + compression : any ZSTD_compressBegin*() variant, including with dictionary + + decompression : any ZSTD_decompressBegin*() variant, including with dictionary + - Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX == 128 KB + + If input is larger than a block size, it's necessary to split input data into multiple blocks + + For inputs larger than a single block, consider using regular ZSTD_compress() instead. + Frame metadata is not that costly, and quickly becomes negligible as source size grows larger than a block. + - When a block is considered not compressible enough, ZSTD_compressBlock() result will be 0 (zero) ! + ===> In which case, nothing is produced into `dst` ! + + User __must__ test for such outcome and deal directly with uncompressed data + + A block cannot be declared incompressible if ZSTD_compressBlock() return value was != 0. + Doing so would mess up with statistics history, leading to potential data corruption. + + ZSTD_decompressBlock() _doesn't accept uncompressed data as input_ !! + + In case of multiple successive blocks, should some of them be uncompressed, + decoder must be informed of their existence in order to follow proper history. + Use ZSTD_insertBlock() for such a case. +*/ + +/*===== Raw zstd block functions =====*/ +ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx); +ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); +ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); +ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.") +ZSTDLIB_STATIC_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */ + +#if defined (__cplusplus) +} +#endif + +#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */ diff --git a/illumos-x86_64/usr/include/zstd_errors.h b/illumos-x86_64/usr/include/zstd_errors.h new file mode 100644 index 00000000..8ebc95cb --- /dev/null +++ b/illumos-x86_64/usr/include/zstd_errors.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +#ifndef ZSTD_ERRORS_H_398273423 +#define ZSTD_ERRORS_H_398273423 + +#if defined (__cplusplus) +extern "C" { +#endif + +/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */ +#ifndef ZSTDERRORLIB_VISIBLE + /* Backwards compatibility with old macro name */ +# ifdef ZSTDERRORLIB_VISIBILITY +# define ZSTDERRORLIB_VISIBLE ZSTDERRORLIB_VISIBILITY +# elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__) +# define ZSTDERRORLIB_VISIBLE __attribute__ ((visibility ("default"))) +# else +# define ZSTDERRORLIB_VISIBLE +# endif +#endif + +#ifndef ZSTDERRORLIB_HIDDEN +# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__) +# define ZSTDERRORLIB_HIDDEN __attribute__ ((visibility ("hidden"))) +# else +# define ZSTDERRORLIB_HIDDEN +# endif +#endif + +#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) +# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBLE +#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) +# define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ +#else +# define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBLE +#endif + +/*-********************************************* + * Error codes list + *-********************************************* + * Error codes _values_ are pinned down since v1.3.1 only. + * Therefore, don't rely on values if you may link to any version < v1.3.1. + * + * Only values < 100 are considered stable. + * + * note 1 : this API shall be used with static linking only. + * dynamic linking is not yet officially supported. + * note 2 : Prefer relying on the enum than on its value whenever possible + * This is the only supported way to use the error list < v1.3.1 + * note 3 : ZSTD_isError() is always correct, whatever the library version. + **********************************************/ +typedef enum { + ZSTD_error_no_error = 0, + ZSTD_error_GENERIC = 1, + ZSTD_error_prefix_unknown = 10, + ZSTD_error_version_unsupported = 12, + ZSTD_error_frameParameter_unsupported = 14, + ZSTD_error_frameParameter_windowTooLarge = 16, + ZSTD_error_corruption_detected = 20, + ZSTD_error_checksum_wrong = 22, + ZSTD_error_literals_headerWrong = 24, + ZSTD_error_dictionary_corrupted = 30, + ZSTD_error_dictionary_wrong = 32, + ZSTD_error_dictionaryCreation_failed = 34, + ZSTD_error_parameter_unsupported = 40, + ZSTD_error_parameter_combination_unsupported = 41, + ZSTD_error_parameter_outOfBound = 42, + ZSTD_error_tableLog_tooLarge = 44, + ZSTD_error_maxSymbolValue_tooLarge = 46, + ZSTD_error_maxSymbolValue_tooSmall = 48, + ZSTD_error_cannotProduce_uncompressedBlock = 49, + ZSTD_error_stabilityCondition_notRespected = 50, + ZSTD_error_stage_wrong = 60, + ZSTD_error_init_missing = 62, + ZSTD_error_memory_allocation = 64, + ZSTD_error_workSpace_tooSmall= 66, + ZSTD_error_dstSize_tooSmall = 70, + ZSTD_error_srcSize_wrong = 72, + ZSTD_error_dstBuffer_null = 74, + ZSTD_error_noForwardProgress_destFull = 80, + ZSTD_error_noForwardProgress_inputEmpty = 82, + /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */ + ZSTD_error_frameIndex_tooLarge = 100, + ZSTD_error_seekableIO = 102, + ZSTD_error_dstBuffer_wrong = 104, + ZSTD_error_srcBuffer_wrong = 105, + ZSTD_error_sequenceProducer_failed = 106, + ZSTD_error_externalSequences_invalid = 107, + ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */ +} ZSTD_ErrorCode; + +ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */ + + +#if defined (__cplusplus) +} +#endif + +#endif /* ZSTD_ERRORS_H_398273423 */ diff --git a/illumos-x86_64/usr/lib/amd64/0@0.so.1 b/illumos-x86_64/usr/lib/amd64/0@0.so.1 new file mode 100755 index 00000000..141eb024 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/0@0.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/bfd-plugins/libdep.so b/illumos-x86_64/usr/lib/amd64/bfd-plugins/libdep.so new file mode 100755 index 00000000..10d21ce1 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/bfd-plugins/libdep.so differ diff --git a/illumos-x86_64/usr/lib/amd64/cmake/OpenSSL/OpenSSLConfig.cmake b/illumos-x86_64/usr/lib/amd64/cmake/OpenSSL/OpenSSLConfig.cmake new file mode 100644 index 00000000..ac450a56 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/cmake/OpenSSL/OpenSSLConfig.cmake @@ -0,0 +1,148 @@ +# Generated by OpenSSL + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Avoid duplicate find_package() +set(_ossl_expected_targets OpenSSL::Crypto OpenSSL::SSL + ) +set(_ossl_defined_targets) +set(_ossl_undefined_targets) +foreach(t IN LISTS _ossl_expected_targets) + if(TARGET "${t}") + LIST(APPEND _ossl_defined_targets "${t}") + else() + LIST(APPEND _ossl_undefined_targets "${t}") + endif() +endforeach() +message(DEBUG "_ossl_expected_targets = ${_ossl_expected_targets}") +message(DEBUG "_ossl_defined_targets = ${_ossl_defined_targets}") +message(DEBUG "_ossl_undefined_targets = ${_ossl_undefined_targets}") +if(NOT _ossl_undefined_targets) + # All targets are defined, we're good, just undo everything and return + unset(_ossl_expected_targets) + unset(_ossl_defined_targets) + unset(_ossl_undefined_targets) + unset(CMAKE_IMPORT_FILE_VERSION) + return() +endif() +if(_ossl_defined_targets) + # We have a mix of defined and undefined targets. This is hard to reconcile, + # and probably the result of another config, or FindOpenSSL.cmake having been + # called, or whatever. Therefore, the best course of action is to quit with a + # hard error. + message(FATAL_ERROR "Some targets defined, others not:\nNot defined: ${_ossl_undefined_targets}\nDefined: ${_ossl_defined_targets}") +endif() +unset(_ossl_expected_targets) +unset(_ossl_defined_targets) +unset(_ossl_undefined_targets) + + +# Set up the import path, so all other import paths are made relative this file +get_filename_component(_ossl_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH) +get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH) +get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH) +get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH) +get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH) + +if(_ossl_prefix STREQUAL "/") + set(_ossl_prefix "") +endif() + + +if(OPENSSL_USE_STATIC_LIBS) + set(_ossl_use_static_libs True) +elseif(DEFINED OPENSSL_USE_STATIC_LIBS) + # We know OPENSSL_USE_STATIC_LIBS is defined and False + if(_ossl_use_static_libs) + # OPENSSL_USE_STATIC_LIBS is explicitly false, indicating that shared libraries are + # required. However, _ossl_use_static_libs indicates that no shared libraries are + # available. The best course of action is to simply return and leave it to CMake to + # use another OpenSSL config. + unset(_ossl_use_static_libs) + unset(CMAKE_IMPORT_FILE_VERSION) + return() + endif() +endif() + +# Version, copied from what find_package() gives, for compatibility with FindOpenSSL.cmake +set(OPENSSL_VERSION "${OpenSSL_VERSION}") +set(OPENSSL_VERSION_MAJOR "${OpenSSL_VERSION_MAJOR}") +set(OPENSSL_VERSION_MINOR "${OpenSSL_VERSION_MINOR}") +set(OPENSSL_VERSION_FIX "${OpenSSL_VERSION_PATCH}") +set(OPENSSL_FOUND YES) + +# Directories and names +set(OPENSSL_LIBRARY_DIR "${_ossl_prefix}/") +set(OPENSSL_INCLUDE_DIR "${_ossl_prefix}/include") +set(OPENSSL_ENGINES_DIR "${_ossl_prefix}//lib/amd64/engines-3") +set(OPENSSL_MODULES_DIR "${_ossl_prefix}//lib/amd64/ossl-modules") +set(OPENSSL_RUNTIME_DIR "${_ossl_prefix}/bin") + +set(OPENSSL_PROGRAM "${OPENSSL_RUNTIME_DIR}/openssl") + +# Set up the imported targets +if(_ossl_use_static_libs) + + add_library(OpenSSL::Crypto STATIC IMPORTED) + add_library(OpenSSL::SSL STATIC IMPORTED) + + set(OPENSSL_LIBCRYPTO_STATIC "${OPENSSL_LIBRARY_DIR}/libcrypto.a") + set(OPENSSL_LIBCRYPTO_DEPENDENCIES -lz -lsocket -lnsl) + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OPENSSL_LIBCRYPTO_STATIC}) + set_property(TARGET OpenSSL::Crypto + PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) + + set(OPENSSL_LIBSSL_STATIC "${OPENSSL_LIBRARY_DIR}/libssl.a") + set(OPENSSL_LIBSSL_DEPENDENCIES OpenSSL::Crypto) + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OPENSSL_LIBSSL_STATIC}) + set_property(TARGET OpenSSL::SSL + PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBSSL_DEPENDENCIES}) + + # Directories and names compatible with CMake's FindOpenSSL.cmake + set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBCRYPTO_STATIC}) + set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) + set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBSSL_STATIC}) + set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES}) + set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) + +else() + + add_library(OpenSSL::Crypto SHARED IMPORTED) + add_library(OpenSSL::SSL SHARED IMPORTED) + + # Dependencies are assumed to be implied in the shared libraries + set(OPENSSL_LIBCRYPTO_SHARED "${OPENSSL_LIBRARY_DIR}/libcrypto.so") + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OPENSSL_LIBCRYPTO_SHARED}) + + set(OPENSSL_LIBSSL_SHARED "${OPENSSL_LIBRARY_DIR}/libssl.so") + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OPENSSL_LIBSSL_SHARED}) + + # Directories and names compatible with CMake's FindOpenSSL.cmake + set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBCRYPTO_SHARED}) + set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBSSL_SHARED}) + set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) + set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES}) + + +endif() + +set_target_properties(OpenSSL::Crypto PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") +set_target_properties(OpenSSL::SSL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + + + +unset(_ossl_prefix) +unset(_ossl_use_static_libs) diff --git a/illumos-x86_64/usr/lib/amd64/cmake/OpenSSL/OpenSSLConfigVersion.cmake b/illumos-x86_64/usr/lib/amd64/cmake/OpenSSL/OpenSSLConfigVersion.cmake new file mode 100644 index 00000000..46949e36 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/cmake/OpenSSL/OpenSSLConfigVersion.cmake @@ -0,0 +1,17 @@ +# Generated by OpenSSL + +set(PACKAGE_VERSION 3.5.4) + +if(NOT PACKAGE_FIND_VERSION) + # find_package() was called without any version information. This is assumed to + # mean that the caller accepts whatever they get. + set(PACKAGE_VERSION_COMPATIBLE 1) +elseif(PACKAGE_FIND_VERSION_MAJOR LESS 3 + OR PACKAGE_FIND_VERSION VERSION_GREATER 3.5.4) + set(PACKAGE_VERSION_UNSUITABLE 1) +else() + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION VERSION_EQUAL 3.5.4) + set(PACKAGE_VERSION_EXACT 1) + endif() +endif() diff --git a/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-config-version.cmake b/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-config-version.cmake new file mode 100644 index 00000000..1de0556c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-config-version.cmake @@ -0,0 +1,65 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by write_basic_package_version_file() as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, +# but only if the requested major version is the same as the current one. +# The variable CVF_VERSION must be set before calling configure_file(). + + +set(PACKAGE_VERSION "2.7.2") + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + + if("2.7.2" MATCHES "^([0-9]+)\\.") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0) + string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}") + endif() + else() + set(CVF_VERSION_MAJOR "2.7.2") + endif() + + if(PACKAGE_FIND_VERSION_RANGE) + # both endpoints of the range must have the expected major version + math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1") + if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + else() + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() +endif() + + +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "") + return() +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8") + math(EXPR installedBits "8 * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-config.cmake b/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-config.cmake new file mode 100644 index 00000000..36a01319 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-config.cmake @@ -0,0 +1,99 @@ +# __ __ _ +# ___\ \/ /_ __ __ _| |_ +# / _ \\ /| '_ \ / _` | __| +# | __// \| |_) | (_| | |_ +# \___/_/\_\ .__/ \__,_|\__| +# |_| XML parser +# +# Copyright (c) 2019 Expat development team +# Licensed under the MIT license: +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the +# following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +# USE OR OTHER DEALINGS IN THE SOFTWARE. +# +if(NOT _expat_config_included) + # Protect against multiple inclusion + set(_expat_config_included TRUE) + + +include("${CMAKE_CURRENT_LIST_DIR}/expat.cmake") + + +####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() ####### +####### Any changes to this file will be overwritten by the next CMake run #### +####### The input file was expat-config.cmake.in ######## + +get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) + +macro(set_and_check _var _file) + set(${_var} "${_file}") + if(NOT EXISTS "${_file}") + message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !") + endif() +endmacro() + +macro(check_required_components _NAME) + foreach(comp ${${_NAME}_FIND_COMPONENTS}) + if(NOT ${_NAME}_${comp}_FOUND) + if(${_NAME}_FIND_REQUIRED_${comp}) + set(${_NAME}_FOUND FALSE) + endif() + endif() + endforeach() +endmacro() + +#################################################################################### + +# +# Supported components +# +macro(expat_register_component _NAME _AVAILABE) + set(expat_${_NAME}_FOUND ${_AVAILABE}) +endmacro() + +expat_register_component(attr_info OFF) +expat_register_component(dtd ON) +expat_register_component(large_size OFF) +expat_register_component(min_size OFF) +expat_register_component(ns ON) + +if(1024) + expat_register_component(context_bytes ON) +else() + expat_register_component(context_bytes OFF) +endif() + +if("char" STREQUAL "char") + expat_register_component(char ON) + expat_register_component(ushort OFF) + expat_register_component(wchar_t OFF) +elseif("char" STREQUAL "ushort") + expat_register_component(char OFF) + expat_register_component(ushort ON) + expat_register_component(wchar_t OFF) +elseif("char" STREQUAL "wchar_t") + expat_register_component(char OFF) + expat_register_component(ushort OFF) + expat_register_component(wchar_t ON) +endif() + +check_required_components(expat) + + +endif(NOT _expat_config_included) diff --git a/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-noconfig.cmake b/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-noconfig.cmake new file mode 100644 index 00000000..a3ab2958 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat-noconfig.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "NoConfig". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "expat::expat" for configuration "NoConfig" +set_property(TARGET expat::expat APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(expat::expat PROPERTIES + IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/amd64/libexpat.so.1.11.0" + IMPORTED_SONAME_NOCONFIG "libexpat.so.1" + ) + +list(APPEND _cmake_import_check_targets expat::expat ) +list(APPEND _cmake_import_check_files_for_expat::expat "${_IMPORT_PREFIX}/amd64/libexpat.so.1.11.0" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat.cmake b/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat.cmake new file mode 100644 index 00000000..ecb2df12 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/cmake/expat-2.7.2/expat.cmake @@ -0,0 +1,107 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8) + message(FATAL_ERROR "CMake >= 2.8.12 required") +endif() +if(CMAKE_VERSION VERSION_LESS "2.8.12") + message(FATAL_ERROR "CMake >= 2.8.12 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.8.12...3.29) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_cmake_targets_defined "") +set(_cmake_targets_not_defined "") +set(_cmake_expected_targets "") +foreach(_cmake_expected_target IN ITEMS expat::expat) + list(APPEND _cmake_expected_targets "${_cmake_expected_target}") + if(TARGET "${_cmake_expected_target}") + list(APPEND _cmake_targets_defined "${_cmake_expected_target}") + else() + list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}") + endif() +endforeach() +unset(_cmake_expected_target) +if(_cmake_targets_defined STREQUAL _cmake_expected_targets) + unset(_cmake_targets_defined) + unset(_cmake_targets_not_defined) + unset(_cmake_expected_targets) + unset(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT _cmake_targets_defined STREQUAL "") + string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}") + string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n") +endif() +unset(_cmake_targets_defined) +unset(_cmake_targets_not_defined) +unset(_cmake_expected_targets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target expat::expat +add_library(expat::expat SHARED IMPORTED) + +set_target_properties(expat::expat PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" + INTERFACE_LINK_LIBRARIES "m" +) + +# Load information for each installed configuration. +file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/expat-*.cmake") +foreach(_cmake_config_file IN LISTS _cmake_config_files) + include("${_cmake_config_file}") +endforeach() +unset(_cmake_config_file) +unset(_cmake_config_files) + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(_cmake_target IN LISTS _cmake_import_check_targets) + if(CMAKE_VERSION VERSION_LESS "3.28" + OR NOT DEFINED _cmake_import_check_xcframework_for_${_cmake_target} + OR NOT IS_DIRECTORY "${_cmake_import_check_xcframework_for_${_cmake_target}}") + foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}") + if(NOT EXISTS "${_cmake_file}") + message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file + \"${_cmake_file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + endif() + unset(_cmake_file) + unset("_cmake_import_check_files_for_${_cmake_target}") +endforeach() +unset(_cmake_target) +unset(_cmake_import_check_targets) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/illumos-x86_64/usr/lib/amd64/cmake/libxml2/libxml2-config.cmake b/illumos-x86_64/usr/lib/amd64/cmake/libxml2/libxml2-config.cmake new file mode 100644 index 00000000..0b0cb893 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/cmake/libxml2/libxml2-config.cmake @@ -0,0 +1,151 @@ +# libxml2-config.cmake +# -------------------- +# +# Libxml2 cmake module. +# This module sets the following variables: +# +# :: +# +# LIBXML2_FOUND - True if libxml2 headers and libraries were found +# LIBXML2_INCLUDE_DIR - Directory where LibXml2 headers are located. +# LIBXML2_INCLUDE_DIRS - list of the include directories needed to use LibXml2. +# LIBXML2_LIBRARY - path to the LibXml2 library. +# LIBXML2_LIBRARIES - xml2 libraries to link against. +# LIBXML2_DEFINITIONS - the compiler switches required for using LibXml2. +# LIBXML2_VERSION_MAJOR - The major version of libxml2. +# LIBXML2_VERSION_MINOR - The minor version of libxml2. +# LIBXML2_VERSION_PATCH - The patch version of libxml2. +# LIBXML2_VERSION_STRING - version number as a string (ex: "2.3.4") +# LIBXML2_MODULES - whether libxml2 has dso support +# LIBXML2_XMLLINT_EXECUTABLE - path to the XML checking tool xmllint coming with LibXml2 +# +# The following targets are defined: +# +# LibXml2::LibXml2 - the LibXml2 library +# LibXml2::xmllint - the xmllint command-line executable + +set(LIBXML2_VERSION_MAJOR 2) +set(LIBXML2_VERSION_MINOR 14) +set(LIBXML2_VERSION_MICRO 6) +set(LIBXML2_VERSION_STRING "2.14.6") +set(LIBXML2_DEFINITIONS "") +set(LIBXML2_INCLUDE_DIR /usr/include/libxml2) +set(LIBXML2_LIBRARY_DIR /usr/lib/amd64) + +find_library(LIBXML2_LIBRARY NAMES xml2 HINTS ${LIBXML2_LIBRARY_DIR} NO_DEFAULT_PATH) +find_program(LIBXML2_XMLCATALOG_EXECUTABLE NAMES xmlcatalog HINTS /usr/bin/amd64 NO_DEFAULT_PATH) +find_program(LIBXML2_XMLLINT_EXECUTABLE NAMES xmllint HINTS /usr/bin/amd64 NO_DEFAULT_PATH) + +set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY}) +set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR}) +unset(LIBXML2_INTERFACE_LINK_LIBRARIES) + +include(CMakeFindDependencyMacro) + +set(LIBXML2_SHARED 1) +set(LIBXML2_WITH_ICONV 1) +set(LIBXML2_WITH_THREADS 1) +set(LIBXML2_WITH_ICU 0) +set(LIBXML2_WITH_LZMA 0) +set(LIBXML2_WITH_ZLIB 0) +set(LIBXML2_WITH_HTTP 0) + +if(NOT LIBXML2_SHARED) + set(LIBXML2_DEFINITIONS -DLIBXML_STATIC) + + if(LIBXML2_WITH_ICONV) + find_dependency(Iconv) + list(APPEND LIBXML2_LIBRARIES ${Iconv_LIBRARIES}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + if(NOT Iconv_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Iconv dependency was not found") + return() + endif() + endif() + + if(LIBXML2_WITH_THREADS) + find_dependency(Threads) + list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + if(NOT Threads_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Threads dependency was not found") + return() + endif() + endif() + + if(LIBXML2_WITH_ICU) + find_dependency(ICU COMPONENTS data i18n uc) + list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$;\$;\$") + if(NOT ICU_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ICU dependency was not found") + return() + endif() + endif() + + if(LIBXML2_WITH_LZMA) + find_dependency(LibLZMA) + list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + if(NOT LibLZMA_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LibLZMA dependency was not found") + return() + endif() + endif() + + if(LIBXML2_WITH_ZLIB) + find_dependency(ZLIB) + list(APPEND LIBXML2_LIBRARIES ${ZLIB_LIBRARIES}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + if(NOT ZLIB_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ZLIB dependency was not found") + return() + endif() + endif() + + if(UNIX) + list(APPEND LIBXML2_LIBRARIES m) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + endif() + + if(WIN32) + list(APPEND LIBXML2_LIBRARIES Bcrypt) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + if(LIBXML2_WITH_HTTP) + list(APPEND LIBXML2_LIBRARIES ws2_32) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + endif() + endif() +endif() + +# whether libxml2 has dso support +set(LIBXML2_MODULES 1) + +mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE) + +if(DEFINED LIBXML2_LIBRARY AND DEFINED LIBXML2_INCLUDE_DIRS) + set(LIBXML2_FOUND TRUE) +endif() + +if(NOT TARGET LibXml2::LibXml2 AND DEFINED LIBXML2_LIBRARY AND DEFINED LIBXML2_INCLUDE_DIRS) + add_library(LibXml2::LibXml2 UNKNOWN IMPORTED) + set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}") + set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_COMPILE_OPTIONS "${LIBXML2_DEFINITIONS}") + set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}") + set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_LINK_LIBRARIES "${LIBXML2_INTERFACE_LINK_LIBRARIES}") +endif() + +if(NOT TARGET LibXml2::xmlcatalog AND DEFINED LIBXML2_XMLCATALOG_EXECUTABLE) + add_executable(LibXml2::xmlcatalog IMPORTED) + set_target_properties(LibXml2::xmlcatalog PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLCATALOG_EXECUTABLE}") +endif() + +if(NOT TARGET LibXml2::xmllint AND DEFINED LIBXML2_XMLLINT_EXECUTABLE) + add_executable(LibXml2::xmllint IMPORTED) + set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}") +endif() diff --git a/illumos-x86_64/usr/lib/amd64/crt1.o b/illumos-x86_64/usr/lib/amd64/crt1.o new file mode 100644 index 00000000..dfe2a9ff Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/crt1.o differ diff --git a/illumos-x86_64/usr/lib/amd64/crti.o b/illumos-x86_64/usr/lib/amd64/crti.o new file mode 100644 index 00000000..d5718916 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/crti.o differ diff --git a/illumos-x86_64/usr/lib/amd64/crtn.o b/illumos-x86_64/usr/lib/amd64/crtn.o new file mode 100644 index 00000000..6cb19460 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/crtn.o differ diff --git a/illumos-x86_64/usr/lib/amd64/dbus-1.0/include/dbus/dbus-arch-deps.h b/illumos-x86_64/usr/lib/amd64/dbus-1.0/include/dbus/dbus-arch-deps.h new file mode 100644 index 00000000..74c6e6de --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/dbus-1.0/include/dbus/dbus-arch-deps.h @@ -0,0 +1,65 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-arch-deps.h Header with architecture/compiler specific information, installed to libdir + * + * Copyright (C) 2003 Red Hat, Inc. + * SPDX-License-Identifier: AFL-2.0 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.0 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_ARCH_DEPS_H +#define DBUS_ARCH_DEPS_H + +#include + +DBUS_BEGIN_DECLS + +/* D-Bus no longer supports platforms with no 64-bit integer type. */ +#define DBUS_HAVE_INT64 1 +_DBUS_GNUC_EXTENSION typedef long dbus_int64_t; +_DBUS_GNUC_EXTENSION typedef unsigned long dbus_uint64_t; +#define DBUS_INT64_MODIFIER "l" + +#define DBUS_INT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION (val##L)) +#define DBUS_UINT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION (val##UL)) + +typedef int dbus_int32_t; +typedef unsigned int dbus_uint32_t; + +typedef short dbus_int16_t; +typedef unsigned short dbus_uint16_t; + +#define DBUS_SIZEOF_VOID_P 8 + +/* This is not really arch-dependent, but it's not worth + * creating an additional generated header just for this + */ +#define DBUS_MAJOR_VERSION 1 +#define DBUS_MINOR_VERSION 16 +#define DBUS_MICRO_VERSION 2 + +#define DBUS_VERSION_STRING "1.16.2" + +#define DBUS_VERSION ((1 << 16) | (16 << 8) | (2)) + +DBUS_END_DECLS + +#endif /* DBUS_ARCH_DEPS_H */ diff --git a/illumos-x86_64/usr/lib/amd64/engines-3/capi.so b/illumos-x86_64/usr/lib/amd64/engines-3/capi.so new file mode 100755 index 00000000..ae4748bc Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/engines-3/capi.so differ diff --git a/illumos-x86_64/usr/lib/amd64/engines-3/loader_attic.so b/illumos-x86_64/usr/lib/amd64/engines-3/loader_attic.so new file mode 100755 index 00000000..9473a276 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/engines-3/loader_attic.so differ diff --git a/illumos-x86_64/usr/lib/amd64/engines-3/padlock.so b/illumos-x86_64/usr/lib/amd64/engines-3/padlock.so new file mode 100755 index 00000000..11cf65c8 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/engines-3/padlock.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/filefuncs.so b/illumos-x86_64/usr/lib/amd64/gawk/filefuncs.so new file mode 100755 index 00000000..7775123e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/filefuncs.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/fnmatch.so b/illumos-x86_64/usr/lib/amd64/gawk/fnmatch.so new file mode 100755 index 00000000..653639da Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/fnmatch.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/fork.so b/illumos-x86_64/usr/lib/amd64/gawk/fork.so new file mode 100755 index 00000000..152bff92 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/fork.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/inplace.so b/illumos-x86_64/usr/lib/amd64/gawk/inplace.so new file mode 100755 index 00000000..d18351b8 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/inplace.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/intdiv.so b/illumos-x86_64/usr/lib/amd64/gawk/intdiv.so new file mode 100755 index 00000000..eb257f33 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/intdiv.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/ordchr.so b/illumos-x86_64/usr/lib/amd64/gawk/ordchr.so new file mode 100755 index 00000000..d9cc2f78 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/ordchr.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/readdir.so b/illumos-x86_64/usr/lib/amd64/gawk/readdir.so new file mode 100755 index 00000000..0ae24a42 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/readdir.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/readfile.so b/illumos-x86_64/usr/lib/amd64/gawk/readfile.so new file mode 100755 index 00000000..0f73dcc2 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/readfile.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/revoutput.so b/illumos-x86_64/usr/lib/amd64/gawk/revoutput.so new file mode 100755 index 00000000..bea2d7fb Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/revoutput.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/revtwoway.so b/illumos-x86_64/usr/lib/amd64/gawk/revtwoway.so new file mode 100755 index 00000000..564d3232 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/revtwoway.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/rwarray.so b/illumos-x86_64/usr/lib/amd64/gawk/rwarray.so new file mode 100755 index 00000000..8ef35169 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/rwarray.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gawk/time.so b/illumos-x86_64/usr/lib/amd64/gawk/time.so new file mode 100755 index 00000000..7444a5cc Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gawk/time.so differ diff --git a/illumos-x86_64/usr/lib/amd64/gcrt1.o b/illumos-x86_64/usr/lib/amd64/gcrt1.o new file mode 120000 index 00000000..ad28bc8c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/gcrt1.o @@ -0,0 +1 @@ +crt1.o \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/getloginx.so.1 b/illumos-x86_64/usr/lib/amd64/getloginx.so.1 new file mode 100755 index 00000000..bc067ee0 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/getloginx.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/glib-2.0/include/glibconfig.h b/illumos-x86_64/usr/lib/amd64/glib-2.0/include/glibconfig.h new file mode 100644 index 00000000..73df640a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/glib-2.0/include/glibconfig.h @@ -0,0 +1,221 @@ +/* glibconfig.h + * + * This is a generated file. Please modify 'glibconfig.h.in' + */ + +#ifndef __GLIBCONFIG_H__ +#define __GLIBCONFIG_H__ + +#include + +#include +#include +#define GLIB_HAVE_ALLOCA_H + +/* #undef GLIB_STATIC_COMPILATION */ +/* #undef GOBJECT_STATIC_COMPILATION */ +/* #undef GIO_STATIC_COMPILATION */ +/* #undef GMODULE_STATIC_COMPILATION */ +/* #undef GI_STATIC_COMPILATION */ +/* #undef G_INTL_STATIC_COMPILATION */ +/* #undef FFI_STATIC_BUILD */ + +/* Specifies that GLib's g_print*() functions wrap the + * system printf functions. This is useful to know, for example, + * when using glibc's register_printf_function(). + */ +#define GLIB_USING_SYSTEM_PRINTF + +G_BEGIN_DECLS + +#define G_MINFLOAT FLT_MIN +#define G_MAXFLOAT FLT_MAX +#define G_MINDOUBLE DBL_MIN +#define G_MAXDOUBLE DBL_MAX +#define G_MINSHORT SHRT_MIN +#define G_MAXSHORT SHRT_MAX +#define G_MAXUSHORT USHRT_MAX +#define G_MININT INT_MIN +#define G_MAXINT INT_MAX +#define G_MAXUINT UINT_MAX +#define G_MINLONG LONG_MIN +#define G_MAXLONG LONG_MAX +#define G_MAXULONG ULONG_MAX + +typedef signed char gint8; +typedef unsigned char guint8; + +typedef signed short gint16; +typedef unsigned short guint16; + +#define G_GINT16_MODIFIER "h" +#define G_GINT16_FORMAT "hi" +#define G_GUINT16_FORMAT "hu" + + +typedef signed int gint32; +typedef unsigned int guint32; + +#define G_GINT32_MODIFIER "" +#define G_GINT32_FORMAT "i" +#define G_GUINT32_FORMAT "u" + + +#define G_HAVE_GINT64 1 /* deprecated, always true */ + +typedef signed long gint64; +typedef unsigned long guint64; + +#define G_GINT64_CONSTANT(val) (val##L) +#define G_GUINT64_CONSTANT(val) (val##UL) + +#define G_GINT64_MODIFIER "l" +#define G_GINT64_FORMAT "li" +#define G_GUINT64_FORMAT "lu" + + +#define GLIB_SIZEOF_VOID_P 8 +#define GLIB_SIZEOF_LONG 8 +#define GLIB_SIZEOF_SIZE_T 8 +#define GLIB_SIZEOF_SSIZE_T 8 + +typedef signed long gssize; +typedef unsigned long gsize; +#define G_GSIZE_MODIFIER "l" +#define G_GSSIZE_MODIFIER "l" +#define G_GSIZE_FORMAT "lu" +#define G_GSSIZE_FORMAT "li" + +#define G_MAXSIZE G_MAXULONG +#define G_MINSSIZE G_MINLONG +#define G_MAXSSIZE G_MAXLONG + +typedef gint64 goffset; +#define G_MINOFFSET G_MININT64 +#define G_MAXOFFSET G_MAXINT64 + +#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER +#define G_GOFFSET_FORMAT G_GINT64_FORMAT +#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val) + +#define G_POLLFD_FORMAT "%d" + +#define GPOINTER_TO_INT(p) ((gint) (glong) (p)) +#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p)) + +#define GINT_TO_POINTER(i) ((gpointer) (glong) (i)) +#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u)) + +typedef signed long gintptr; +typedef unsigned long guintptr; + +#define G_GINTPTR_MODIFIER "l" +#define G_GINTPTR_FORMAT "li" +#define G_GUINTPTR_FORMAT "lu" + +#define GLIB_MAJOR_VERSION 2 +#define GLIB_MINOR_VERSION 84 +#define GLIB_MICRO_VERSION 4 + +#define G_OS_UNIX + +#define G_VA_COPY va_copy + +#define G_VA_COPY_AS_ARRAY 1 + +#define G_HAVE_ISO_VARARGS 1 + +/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi + * is passed ISO vararg support is turned off, and there is no work + * around to turn it on, so we unconditionally turn it off. + */ +#if __GNUC__ == 2 && __GNUC_MINOR__ == 95 +# undef G_HAVE_ISO_VARARGS +#endif + +#define G_HAVE_GROWING_STACK 0 + +#ifndef _MSC_VER +# define G_HAVE_GNUC_VARARGS 1 +#endif + +#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) +#define G_GNUC_INTERNAL __attribute__((visibility("hidden"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) +#define G_GNUC_INTERNAL __hidden +#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY) +#define G_GNUC_INTERNAL __attribute__((visibility("hidden"))) +#else +#define G_GNUC_INTERNAL +#endif + +#define G_THREADS_ENABLED +#define G_THREADS_IMPL_POSIX + +#define G_ATOMIC_LOCK_FREE + +#define GINT16_TO_LE(val) ((gint16) (val)) +#define GUINT16_TO_LE(val) ((guint16) (val)) +#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val)) +#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val)) + +#define GINT32_TO_LE(val) ((gint32) (val)) +#define GUINT32_TO_LE(val) ((guint32) (val)) +#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val)) +#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) + +#define GINT64_TO_LE(val) ((gint64) (val)) +#define GUINT64_TO_LE(val) ((guint64) (val)) +#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val)) +#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val)) + +#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val)) +#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val)) +#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val)) +#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val)) +#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val)) +#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val)) +#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val)) +#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val)) +#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val)) +#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val)) +#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val)) +#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val)) +#define G_BYTE_ORDER G_LITTLE_ENDIAN + +#define GLIB_SYSDEF_POLLIN =1 +#define GLIB_SYSDEF_POLLOUT =4 +#define GLIB_SYSDEF_POLLPRI =2 +#define GLIB_SYSDEF_POLLHUP =16 +#define GLIB_SYSDEF_POLLERR =8 +#define GLIB_SYSDEF_POLLNVAL =32 + +/* No way to disable deprecation warnings for macros, so only emit deprecation + * warnings on platforms where usage of this macro is broken */ +#if defined(__APPLE__) || defined(_MSC_VER) || defined(__CYGWIN__) +#define G_MODULE_SUFFIX "so" GLIB_DEPRECATED_MACRO_IN_2_76 +#else +#define G_MODULE_SUFFIX "so" +#endif + +typedef int GPid; +#define G_PID_FORMAT "i" + +#define GLIB_SYSDEF_AF_UNIX 1 +#define GLIB_SYSDEF_AF_INET 2 +#define GLIB_SYSDEF_AF_INET6 26 + +#define GLIB_SYSDEF_MSG_OOB 1 +#define GLIB_SYSDEF_MSG_PEEK 2 +#define GLIB_SYSDEF_MSG_DONTROUTE 4 + +#define G_DIR_SEPARATOR '/' +#define G_DIR_SEPARATOR_S "/" +#define G_SEARCHPATH_SEPARATOR ':' +#define G_SEARCHPATH_SEPARATOR_S ":" + +#undef G_HAVE_FREE_SIZED + +G_END_DECLS + +#endif /* __GLIBCONFIG_H__ */ diff --git a/illumos-x86_64/usr/lib/amd64/groff/site-tmac/an.tmac b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/an.tmac new file mode 100644 index 00000000..df40e47d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/an.tmac @@ -0,0 +1,3 @@ +.do mso an.tmac +.cp 1 +.so /usr/share/lib/tmac/an diff --git a/illumos-x86_64/usr/lib/amd64/groff/site-tmac/ansun.tmac b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/ansun.tmac new file mode 100644 index 00000000..2cf5df15 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/ansun.tmac @@ -0,0 +1,2 @@ +.cp 1 +.so /usr/share/lib/tmac/ansun diff --git a/illumos-x86_64/usr/lib/amd64/groff/site-tmac/bib.tmac b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/bib.tmac new file mode 100644 index 00000000..ae132d7b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/bib.tmac @@ -0,0 +1,2 @@ +.cp 1 +.so /usr/share/lib/tmac/bib diff --git a/illumos-x86_64/usr/lib/amd64/groff/site-tmac/m.tmac b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/m.tmac new file mode 100644 index 00000000..cdb436f9 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/m.tmac @@ -0,0 +1,2 @@ +.cp 1 +.so /usr/share/lib/tmac/m diff --git a/illumos-x86_64/usr/lib/amd64/groff/site-tmac/s.tmac b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/s.tmac new file mode 100644 index 00000000..f686277f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/s.tmac @@ -0,0 +1,2 @@ +.cp 1 +.so /usr/share/lib/tmac/s diff --git a/illumos-x86_64/usr/lib/amd64/groff/site-tmac/v.tmac b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/v.tmac new file mode 100644 index 00000000..116829be --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/v.tmac @@ -0,0 +1,2 @@ +.cp 1 +.so /usr/share/lib/tmac/v diff --git a/illumos-x86_64/usr/lib/amd64/groff/site-tmac/vgrind.tmac b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/vgrind.tmac new file mode 100644 index 00000000..c29957f5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/groff/site-tmac/vgrind.tmac @@ -0,0 +1,2 @@ +.cp 1 +.so /usr/share/lib/tmac/vgrind diff --git a/illumos-x86_64/usr/lib/amd64/gss/dh1024-0.so b/illumos-x86_64/usr/lib/amd64/gss/dh1024-0.so new file mode 120000 index 00000000..98613b9c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/gss/dh1024-0.so @@ -0,0 +1 @@ +dh1024-0.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/gss/dh1024-0.so.1 b/illumos-x86_64/usr/lib/amd64/gss/dh1024-0.so.1 new file mode 100755 index 00000000..d98bdaee Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gss/dh1024-0.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/gss/dh640-0.so b/illumos-x86_64/usr/lib/amd64/gss/dh640-0.so new file mode 120000 index 00000000..2fdec3e8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/gss/dh640-0.so @@ -0,0 +1 @@ +dh640-0.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/gss/dh640-0.so.1 b/illumos-x86_64/usr/lib/amd64/gss/dh640-0.so.1 new file mode 100755 index 00000000..e65afde0 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gss/dh640-0.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/gss/mech_dh.so b/illumos-x86_64/usr/lib/amd64/gss/mech_dh.so new file mode 120000 index 00000000..5a5f2b50 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/gss/mech_dh.so @@ -0,0 +1 @@ +mech_dh.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/gss/mech_dh.so.1 b/illumos-x86_64/usr/lib/amd64/gss/mech_dh.so.1 new file mode 100755 index 00000000..95f76aab Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gss/mech_dh.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/gss/mech_krb5.so b/illumos-x86_64/usr/lib/amd64/gss/mech_krb5.so new file mode 120000 index 00000000..a9a97fa1 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/gss/mech_krb5.so @@ -0,0 +1 @@ +./mech_krb5.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/gss/mech_krb5.so.1 b/illumos-x86_64/usr/lib/amd64/gss/mech_krb5.so.1 new file mode 100755 index 00000000..2585f65c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gss/mech_krb5.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/gss/mech_spnego.so.1 b/illumos-x86_64/usr/lib/amd64/gss/mech_spnego.so.1 new file mode 100755 index 00000000..15362453 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/gss/mech_spnego.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/ld.so.1 b/illumos-x86_64/usr/lib/amd64/ld.so.1 new file mode 120000 index 00000000..691b89ca --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/ld.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/ld.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/lddstub b/illumos-x86_64/usr/lib/amd64/lddstub new file mode 100755 index 00000000..e1789379 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/lddstub differ diff --git a/illumos-x86_64/usr/lib/amd64/lib9p.so.1 b/illumos-x86_64/usr/lib/amd64/lib9p.so.1 new file mode 100755 index 00000000..5591be7f Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/lib9p.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libHBAAPI.so b/illumos-x86_64/usr/lib/amd64/libHBAAPI.so new file mode 120000 index 00000000..ae4eb773 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libHBAAPI.so @@ -0,0 +1 @@ +libHBAAPI.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libHBAAPI.so.1 b/illumos-x86_64/usr/lib/amd64/libHBAAPI.so.1 new file mode 100755 index 00000000..53056c14 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libHBAAPI.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libadm.so b/illumos-x86_64/usr/lib/amd64/libadm.so new file mode 120000 index 00000000..02dba1e3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libadm.so @@ -0,0 +1 @@ +../../../lib/amd64/libadm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libadm.so.1 b/illumos-x86_64/usr/lib/amd64/libadm.so.1 new file mode 120000 index 00000000..02dba1e3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libadm.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libadm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libads.so b/illumos-x86_64/usr/lib/amd64/libads.so new file mode 120000 index 00000000..c8cbe8d7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libads.so @@ -0,0 +1 @@ +./libads.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libads.so.1 b/illumos-x86_64/usr/lib/amd64/libads.so.1 new file mode 100755 index 00000000..38ab0fa5 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libads.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libadutils.so b/illumos-x86_64/usr/lib/amd64/libadutils.so new file mode 120000 index 00000000..b097f3f4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libadutils.so @@ -0,0 +1 @@ +./libadutils.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libadutils.so.1 b/illumos-x86_64/usr/lib/amd64/libadutils.so.1 new file mode 100755 index 00000000..6bf5065d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libadutils.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libaio.so b/illumos-x86_64/usr/lib/amd64/libaio.so new file mode 120000 index 00000000..de73f87a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libaio.so @@ -0,0 +1 @@ +../../../lib/amd64/libaio.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libaio.so.1 b/illumos-x86_64/usr/lib/amd64/libaio.so.1 new file mode 120000 index 00000000..de73f87a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libaio.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libaio.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libast.so.1 b/illumos-x86_64/usr/lib/amd64/libast.so.1 new file mode 100755 index 00000000..bd1f51a6 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libast.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libatomic.so b/illumos-x86_64/usr/lib/amd64/libatomic.so new file mode 120000 index 00000000..fbb347a4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libatomic.so @@ -0,0 +1 @@ +libatomic.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libatomic.so.1 b/illumos-x86_64/usr/lib/amd64/libatomic.so.1 new file mode 120000 index 00000000..3436a871 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libatomic.so.1 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libatomic.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libatomic.so.1.1.0 b/illumos-x86_64/usr/lib/amd64/libatomic.so.1.1.0 new file mode 120000 index 00000000..7ceaaca6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libatomic.so.1.1.0 @@ -0,0 +1 @@ +../../gcc/5/lib/amd64/libatomic.so.1.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libatomic.so.1.2.0 b/illumos-x86_64/usr/lib/amd64/libatomic.so.1.2.0 new file mode 120000 index 00000000..2475d765 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libatomic.so.1.2.0 @@ -0,0 +1 @@ +../../gcc/14/lib/amd64/libatomic.so.1.2.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libavl.so b/illumos-x86_64/usr/lib/amd64/libavl.so new file mode 120000 index 00000000..ec906d89 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libavl.so @@ -0,0 +1 @@ +../../../lib/amd64/libavl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libavl.so.1 b/illumos-x86_64/usr/lib/amd64/libavl.so.1 new file mode 120000 index 00000000..ec906d89 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libavl.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libavl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbe.so b/illumos-x86_64/usr/lib/amd64/libbe.so new file mode 120000 index 00000000..ba34ab7e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbe.so @@ -0,0 +1 @@ +./libbe.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbe.so.1 b/illumos-x86_64/usr/lib/amd64/libbe.so.1 new file mode 100755 index 00000000..35399df4 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libbe.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libbrand.so.1 b/illumos-x86_64/usr/lib/amd64/libbrand.so.1 new file mode 100755 index 00000000..ec673e79 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libbrand.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so b/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so new file mode 120000 index 00000000..62459bf5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so @@ -0,0 +1 @@ +libbrotlicommon.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so.1 b/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so.1 new file mode 120000 index 00000000..8ad0066d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so.1 @@ -0,0 +1 @@ +libbrotlicommon.so.1.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so.1.1.0 b/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so.1.1.0 new file mode 100755 index 00000000..7bb78a50 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libbrotlicommon.so.1.1.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlidec.so b/illumos-x86_64/usr/lib/amd64/libbrotlidec.so new file mode 120000 index 00000000..143f9c20 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbrotlidec.so @@ -0,0 +1 @@ +libbrotlidec.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlidec.so.1 b/illumos-x86_64/usr/lib/amd64/libbrotlidec.so.1 new file mode 120000 index 00000000..f5030d28 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbrotlidec.so.1 @@ -0,0 +1 @@ +libbrotlidec.so.1.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlidec.so.1.1.0 b/illumos-x86_64/usr/lib/amd64/libbrotlidec.so.1.1.0 new file mode 100755 index 00000000..5f8dd6c5 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libbrotlidec.so.1.1.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlienc.so b/illumos-x86_64/usr/lib/amd64/libbrotlienc.so new file mode 120000 index 00000000..cc07d36b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbrotlienc.so @@ -0,0 +1 @@ +libbrotlienc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlienc.so.1 b/illumos-x86_64/usr/lib/amd64/libbrotlienc.so.1 new file mode 120000 index 00000000..95ea4fa2 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbrotlienc.so.1 @@ -0,0 +1 @@ +libbrotlienc.so.1.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbrotlienc.so.1.1.0 b/illumos-x86_64/usr/lib/amd64/libbrotlienc.so.1.1.0 new file mode 100755 index 00000000..cf2bd737 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libbrotlienc.so.1.1.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libbsdmalloc.so b/illumos-x86_64/usr/lib/amd64/libbsdmalloc.so new file mode 120000 index 00000000..c10ea880 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbsdmalloc.so @@ -0,0 +1 @@ +libbsdmalloc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbsdmalloc.so.1 b/illumos-x86_64/usr/lib/amd64/libbsdmalloc.so.1 new file mode 100755 index 00000000..2bef4264 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libbsdmalloc.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libbsm.so b/illumos-x86_64/usr/lib/amd64/libbsm.so new file mode 120000 index 00000000..7560587b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbsm.so @@ -0,0 +1 @@ +../../../lib/amd64/libbsm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbsm.so.1 b/illumos-x86_64/usr/lib/amd64/libbsm.so.1 new file mode 120000 index 00000000..7560587b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbsm.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libbsm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbunyan.so.1 b/illumos-x86_64/usr/lib/amd64/libbunyan.so.1 new file mode 100755 index 00000000..c4fa9587 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libbunyan.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libbz2.so b/illumos-x86_64/usr/lib/amd64/libbz2.so new file mode 120000 index 00000000..20c98c85 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbz2.so @@ -0,0 +1 @@ +libbz2.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbz2.so.1 b/illumos-x86_64/usr/lib/amd64/libbz2.so.1 new file mode 120000 index 00000000..01eae5f4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbz2.so.1 @@ -0,0 +1 @@ +libbz2.so.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbz2.so.1.0 b/illumos-x86_64/usr/lib/amd64/libbz2.so.1.0 new file mode 120000 index 00000000..5ffafa03 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libbz2.so.1.0 @@ -0,0 +1 @@ +libbz2.so.1.0.8 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libbz2.so.1.0.8 b/illumos-x86_64/usr/lib/amd64/libbz2.so.1.0.8 new file mode 100755 index 00000000..2e998f87 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libbz2.so.1.0.8 differ diff --git a/illumos-x86_64/usr/lib/amd64/libc.so b/illumos-x86_64/usr/lib/amd64/libc.so new file mode 120000 index 00000000..ecd193c6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libc.so @@ -0,0 +1 @@ +../../../lib/amd64/libc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libc.so.1 b/illumos-x86_64/usr/lib/amd64/libc.so.1 new file mode 120000 index 00000000..ecd193c6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libc.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libc_db.so b/illumos-x86_64/usr/lib/amd64/libc_db.so new file mode 120000 index 00000000..03e3a2b5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libc_db.so @@ -0,0 +1 @@ +../../../lib/amd64/libc_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libc_db.so.1 b/illumos-x86_64/usr/lib/amd64/libc_db.so.1 new file mode 120000 index 00000000..03e3a2b5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libc_db.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libc_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcfgadm.so b/illumos-x86_64/usr/lib/amd64/libcfgadm.so new file mode 120000 index 00000000..163e1b4f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcfgadm.so @@ -0,0 +1 @@ +libcfgadm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcfgadm.so.1 b/illumos-x86_64/usr/lib/amd64/libcfgadm.so.1 new file mode 100755 index 00000000..f4e0c065 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libcfgadm.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libcmd.so.1 b/illumos-x86_64/usr/lib/amd64/libcmd.so.1 new file mode 100755 index 00000000..f66eafd5 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libcmd.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libcmdutils.so.1 b/illumos-x86_64/usr/lib/amd64/libcmdutils.so.1 new file mode 120000 index 00000000..ab13e9cf --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcmdutils.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libcmdutils.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcommputil.so b/illumos-x86_64/usr/lib/amd64/libcommputil.so new file mode 120000 index 00000000..f58fcdab --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcommputil.so @@ -0,0 +1 @@ +libcommputil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcommputil.so.1 b/illumos-x86_64/usr/lib/amd64/libcommputil.so.1 new file mode 100755 index 00000000..d1730531 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libcommputil.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libcontract.so b/illumos-x86_64/usr/lib/amd64/libcontract.so new file mode 120000 index 00000000..4f674699 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcontract.so @@ -0,0 +1 @@ +../../../lib/amd64/libcontract.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcontract.so.1 b/illumos-x86_64/usr/lib/amd64/libcontract.so.1 new file mode 120000 index 00000000..4f674699 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcontract.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libcontract.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcrle.so.1 b/illumos-x86_64/usr/lib/amd64/libcrle.so.1 new file mode 100755 index 00000000..9e7c5217 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libcrle.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libcrypt.so b/illumos-x86_64/usr/lib/amd64/libcrypt.so new file mode 120000 index 00000000..71c42de8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcrypt.so @@ -0,0 +1 @@ +./libcrypt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcrypt.so.1 b/illumos-x86_64/usr/lib/amd64/libcrypt.so.1 new file mode 100755 index 00000000..c928604d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libcrypt.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libcrypt_d.so b/illumos-x86_64/usr/lib/amd64/libcrypt_d.so new file mode 120000 index 00000000..d43e2aa6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcrypt_d.so @@ -0,0 +1 @@ +./libcrypt.so \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcrypt_d.so.1 b/illumos-x86_64/usr/lib/amd64/libcrypt_d.so.1 new file mode 120000 index 00000000..71c42de8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcrypt_d.so.1 @@ -0,0 +1 @@ +./libcrypt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcrypt_i.so b/illumos-x86_64/usr/lib/amd64/libcrypt_i.so new file mode 120000 index 00000000..d43e2aa6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcrypt_i.so @@ -0,0 +1 @@ +./libcrypt.so \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcrypt_i.so.1 b/illumos-x86_64/usr/lib/amd64/libcrypt_i.so.1 new file mode 120000 index 00000000..71c42de8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcrypt_i.so.1 @@ -0,0 +1 @@ +./libcrypt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcrypto.so b/illumos-x86_64/usr/lib/amd64/libcrypto.so new file mode 120000 index 00000000..e6d0d802 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcrypto.so @@ -0,0 +1 @@ +libcrypto.so.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcrypto.so.3 b/illumos-x86_64/usr/lib/amd64/libcrypto.so.3 new file mode 120000 index 00000000..6494a389 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcrypto.so.3 @@ -0,0 +1 @@ +../../../lib/amd64/libcrypto.so.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libctf.so b/illumos-x86_64/usr/lib/amd64/libctf.so new file mode 120000 index 00000000..3c5f1c27 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libctf.so @@ -0,0 +1 @@ +../../../lib/amd64/libctf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libctf.so.1 b/illumos-x86_64/usr/lib/amd64/libctf.so.1 new file mode 120000 index 00000000..3c5f1c27 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libctf.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libctf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcurl.so b/illumos-x86_64/usr/lib/amd64/libcurl.so new file mode 120000 index 00000000..07ae53ae --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcurl.so @@ -0,0 +1 @@ +libcurl.so.4.8.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcurl.so.4 b/illumos-x86_64/usr/lib/amd64/libcurl.so.4 new file mode 120000 index 00000000..07ae53ae --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcurl.so.4 @@ -0,0 +1 @@ +libcurl.so.4.8.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcurl.so.4.8.0 b/illumos-x86_64/usr/lib/amd64/libcurl.so.4.8.0 new file mode 100755 index 00000000..c5a49712 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libcurl.so.4.8.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libcurses.so b/illumos-x86_64/usr/lib/amd64/libcurses.so new file mode 120000 index 00000000..bcee697f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcurses.so @@ -0,0 +1 @@ +../../../lib/amd64/libcurses.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libcurses.so.1 b/illumos-x86_64/usr/lib/amd64/libcurses.so.1 new file mode 120000 index 00000000..bcee697f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libcurses.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libcurses.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdat.so b/illumos-x86_64/usr/lib/amd64/libdat.so new file mode 120000 index 00000000..19e0251d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdat.so @@ -0,0 +1 @@ +libdat.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdat.so.1 b/illumos-x86_64/usr/lib/amd64/libdat.so.1 new file mode 100755 index 00000000..2d11c911 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdat.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdbus-1.so b/illumos-x86_64/usr/lib/amd64/libdbus-1.so new file mode 120000 index 00000000..3bad142b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdbus-1.so @@ -0,0 +1 @@ +libdbus-1.so.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdbus-1.so.3 b/illumos-x86_64/usr/lib/amd64/libdbus-1.so.3 new file mode 120000 index 00000000..c489b49d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdbus-1.so.3 @@ -0,0 +1 @@ +libdbus-1.so.3.38.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdbus-1.so.3.38.3 b/illumos-x86_64/usr/lib/amd64/libdbus-1.so.3.38.3 new file mode 100755 index 00000000..cdd53cf9 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdbus-1.so.3.38.3 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so b/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so new file mode 120000 index 00000000..9d5745f7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so @@ -0,0 +1 @@ +libdbus-glib-1.so.2.3.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so.2 b/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so.2 new file mode 120000 index 00000000..9d5745f7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so.2 @@ -0,0 +1 @@ +libdbus-glib-1.so.2.3.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so.2.3.6 b/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so.2.3.6 new file mode 100755 index 00000000..12490e6b Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdbus-glib-1.so.2.3.6 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdemangle-sys.so b/illumos-x86_64/usr/lib/amd64/libdemangle-sys.so new file mode 120000 index 00000000..1d683312 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdemangle-sys.so @@ -0,0 +1 @@ +./libdemangle-sys.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdemangle-sys.so.1 b/illumos-x86_64/usr/lib/amd64/libdemangle-sys.so.1 new file mode 100755 index 00000000..ce803d14 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdemangle-sys.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdevice.so b/illumos-x86_64/usr/lib/amd64/libdevice.so new file mode 120000 index 00000000..85e9e1cf --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdevice.so @@ -0,0 +1 @@ +../../../lib/amd64/libdevice.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdevice.so.1 b/illumos-x86_64/usr/lib/amd64/libdevice.so.1 new file mode 120000 index 00000000..85e9e1cf --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdevice.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdevice.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdevid.so b/illumos-x86_64/usr/lib/amd64/libdevid.so new file mode 120000 index 00000000..b0a0e1f7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdevid.so @@ -0,0 +1 @@ +../../../lib/amd64/libdevid.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdevid.so.1 b/illumos-x86_64/usr/lib/amd64/libdevid.so.1 new file mode 120000 index 00000000..b0a0e1f7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdevid.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdevid.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdevinfo.so b/illumos-x86_64/usr/lib/amd64/libdevinfo.so new file mode 120000 index 00000000..9904f3ba --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdevinfo.so @@ -0,0 +1 @@ +../../../lib/amd64/libdevinfo.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdevinfo.so.1 b/illumos-x86_64/usr/lib/amd64/libdevinfo.so.1 new file mode 120000 index 00000000..9904f3ba --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdevinfo.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdevinfo.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdhcpagent.so.1 b/illumos-x86_64/usr/lib/amd64/libdhcpagent.so.1 new file mode 120000 index 00000000..dcc69bf7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdhcpagent.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdhcpagent.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdhcputil.so.1 b/illumos-x86_64/usr/lib/amd64/libdhcputil.so.1 new file mode 120000 index 00000000..cae4e000 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdhcputil.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdhcputil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdisasm.so b/illumos-x86_64/usr/lib/amd64/libdisasm.so new file mode 120000 index 00000000..fa2a4d3a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdisasm.so @@ -0,0 +1 @@ +libdisasm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdisasm.so.1 b/illumos-x86_64/usr/lib/amd64/libdisasm.so.1 new file mode 100755 index 00000000..2c79e542 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdisasm.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdiskmgt.so b/illumos-x86_64/usr/lib/amd64/libdiskmgt.so new file mode 120000 index 00000000..00ec1646 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdiskmgt.so @@ -0,0 +1 @@ +./libdiskmgt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdiskmgt.so.1 b/illumos-x86_64/usr/lib/amd64/libdiskmgt.so.1 new file mode 100755 index 00000000..f0c366e0 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdiskmgt.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdl.so b/illumos-x86_64/usr/lib/amd64/libdl.so new file mode 120000 index 00000000..e1886426 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdl.so @@ -0,0 +1 @@ +../../../lib/amd64/libdl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdl.so.1 b/illumos-x86_64/usr/lib/amd64/libdl.so.1 new file mode 120000 index 00000000..e1886426 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdl.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdll.so.1 b/illumos-x86_64/usr/lib/amd64/libdll.so.1 new file mode 100755 index 00000000..48b08a12 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdll.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdlpi.so b/illumos-x86_64/usr/lib/amd64/libdlpi.so new file mode 120000 index 00000000..ad263c81 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdlpi.so @@ -0,0 +1 @@ +../../../lib/amd64/libdlpi.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdlpi.so.1 b/illumos-x86_64/usr/lib/amd64/libdlpi.so.1 new file mode 120000 index 00000000..ad263c81 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdlpi.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdlpi.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdns_sd.so b/illumos-x86_64/usr/lib/amd64/libdns_sd.so new file mode 120000 index 00000000..2254bd9f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdns_sd.so @@ -0,0 +1 @@ +libdns_sd.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdns_sd.so.1 b/illumos-x86_64/usr/lib/amd64/libdns_sd.so.1 new file mode 100755 index 00000000..62d668f9 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdns_sd.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdoor.so b/illumos-x86_64/usr/lib/amd64/libdoor.so new file mode 120000 index 00000000..3e323b58 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdoor.so @@ -0,0 +1 @@ +../../../lib/amd64/libdoor.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdoor.so.1 b/illumos-x86_64/usr/lib/amd64/libdoor.so.1 new file mode 120000 index 00000000..3e323b58 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdoor.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdoor.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdtrace.so b/illumos-x86_64/usr/lib/amd64/libdtrace.so new file mode 120000 index 00000000..e92d7f45 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdtrace.so @@ -0,0 +1 @@ +libdtrace.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdtrace.so.1 b/illumos-x86_64/usr/lib/amd64/libdtrace.so.1 new file mode 100755 index 00000000..20de7541 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdtrace.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdtrace_jni.so b/illumos-x86_64/usr/lib/amd64/libdtrace_jni.so new file mode 120000 index 00000000..f3971905 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdtrace_jni.so @@ -0,0 +1 @@ +libdtrace_jni.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libdtrace_jni.so.1 b/illumos-x86_64/usr/lib/amd64/libdtrace_jni.so.1 new file mode 100755 index 00000000..89407407 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libdtrace_jni.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libdwarf.so.1 b/illumos-x86_64/usr/lib/amd64/libdwarf.so.1 new file mode 120000 index 00000000..f28c83b5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libdwarf.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libdwarf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libedit.so b/illumos-x86_64/usr/lib/amd64/libedit.so new file mode 120000 index 00000000..3c96d496 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libedit.so @@ -0,0 +1 @@ +libedit.so.0.0.75 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libedit.so.0 b/illumos-x86_64/usr/lib/amd64/libedit.so.0 new file mode 120000 index 00000000..3c96d496 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libedit.so.0 @@ -0,0 +1 @@ +libedit.so.0.0.75 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libedit.so.0.0.75 b/illumos-x86_64/usr/lib/amd64/libedit.so.0.0.75 new file mode 100755 index 00000000..9c25a9a8 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libedit.so.0.0.75 differ diff --git a/illumos-x86_64/usr/lib/amd64/libefi.so b/illumos-x86_64/usr/lib/amd64/libefi.so new file mode 120000 index 00000000..58d93b2c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libefi.so @@ -0,0 +1 @@ +../../../lib/amd64/libefi.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libefi.so.1 b/illumos-x86_64/usr/lib/amd64/libefi.so.1 new file mode 120000 index 00000000..58d93b2c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libefi.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libefi.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libelf.so b/illumos-x86_64/usr/lib/amd64/libelf.so new file mode 120000 index 00000000..34b7c359 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libelf.so @@ -0,0 +1 @@ +../../../lib/amd64/libelf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libelf.so.1 b/illumos-x86_64/usr/lib/amd64/libelf.so.1 new file mode 120000 index 00000000..34b7c359 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libelf.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libelf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libexacct.so b/illumos-x86_64/usr/lib/amd64/libexacct.so new file mode 120000 index 00000000..5ec36cf0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libexacct.so @@ -0,0 +1 @@ +libexacct.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libexacct.so.1 b/illumos-x86_64/usr/lib/amd64/libexacct.so.1 new file mode 100755 index 00000000..f76bd527 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libexacct.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libexpat.so b/illumos-x86_64/usr/lib/amd64/libexpat.so new file mode 120000 index 00000000..2f61da7e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libexpat.so @@ -0,0 +1 @@ +libexpat.so.1.11.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libexpat.so.1 b/illumos-x86_64/usr/lib/amd64/libexpat.so.1 new file mode 120000 index 00000000..2f61da7e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libexpat.so.1 @@ -0,0 +1 @@ +libexpat.so.1.11.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libexpat.so.1.11.0 b/illumos-x86_64/usr/lib/amd64/libexpat.so.1.11.0 new file mode 100755 index 00000000..eee9e463 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libexpat.so.1.11.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libfakekernel.so.1 b/illumos-x86_64/usr/lib/amd64/libfakekernel.so.1 new file mode 120000 index 00000000..71c601da --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfakekernel.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libfakekernel.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfcoe.so b/illumos-x86_64/usr/lib/amd64/libfcoe.so new file mode 120000 index 00000000..65b65b01 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfcoe.so @@ -0,0 +1 @@ +libfcoe.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfcoe.so.1 b/illumos-x86_64/usr/lib/amd64/libfcoe.so.1 new file mode 100755 index 00000000..f0867e6f Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libfcoe.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libfdisk.so b/illumos-x86_64/usr/lib/amd64/libfdisk.so new file mode 120000 index 00000000..e8a5bf25 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfdisk.so @@ -0,0 +1 @@ +../../../lib/amd64/libfdisk.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfdisk.so.1 b/illumos-x86_64/usr/lib/amd64/libfdisk.so.1 new file mode 120000 index 00000000..e8a5bf25 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfdisk.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libfdisk.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libffi.so b/illumos-x86_64/usr/lib/amd64/libffi.so new file mode 120000 index 00000000..2f5b7c2d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libffi.so @@ -0,0 +1 @@ +libffi.so.8.1.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libffi.so.6 b/illumos-x86_64/usr/lib/amd64/libffi.so.6 new file mode 120000 index 00000000..c6cc6fd3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libffi.so.6 @@ -0,0 +1 @@ +libffi.so.6.0.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libffi.so.6.0.4 b/illumos-x86_64/usr/lib/amd64/libffi.so.6.0.4 new file mode 100755 index 00000000..8808ee8e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libffi.so.6.0.4 differ diff --git a/illumos-x86_64/usr/lib/amd64/libffi.so.7 b/illumos-x86_64/usr/lib/amd64/libffi.so.7 new file mode 120000 index 00000000..ad96e9ba --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libffi.so.7 @@ -0,0 +1 @@ +libffi.so.7.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libffi.so.7.1.0 b/illumos-x86_64/usr/lib/amd64/libffi.so.7.1.0 new file mode 100755 index 00000000..fadfef34 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libffi.so.7.1.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libffi.so.8 b/illumos-x86_64/usr/lib/amd64/libffi.so.8 new file mode 120000 index 00000000..2f5b7c2d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libffi.so.8 @@ -0,0 +1 @@ +libffi.so.8.1.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libffi.so.8.1.3 b/illumos-x86_64/usr/lib/amd64/libffi.so.8.1.3 new file mode 100755 index 00000000..ae730028 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libffi.so.8.1.3 differ diff --git a/illumos-x86_64/usr/lib/amd64/libficl-sys.so.4.1.0 b/illumos-x86_64/usr/lib/amd64/libficl-sys.so.4.1.0 new file mode 100755 index 00000000..3e159dbc Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libficl-sys.so.4.1.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libfl.so b/illumos-x86_64/usr/lib/amd64/libfl.so new file mode 120000 index 00000000..0b7bb7d0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfl.so @@ -0,0 +1 @@ +libfl.so.2.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfl.so.2 b/illumos-x86_64/usr/lib/amd64/libfl.so.2 new file mode 120000 index 00000000..0b7bb7d0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfl.so.2 @@ -0,0 +1 @@ +libfl.so.2.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfl.so.2.0.0 b/illumos-x86_64/usr/lib/amd64/libfl.so.2.0.0 new file mode 100755 index 00000000..fdba5df4 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libfl.so.2.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libform.so b/illumos-x86_64/usr/lib/amd64/libform.so new file mode 120000 index 00000000..81ad842c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libform.so @@ -0,0 +1 @@ +libform.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libform.so.1 b/illumos-x86_64/usr/lib/amd64/libform.so.1 new file mode 100755 index 00000000..ea950ca9 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libform.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libfru.so b/illumos-x86_64/usr/lib/amd64/libfru.so new file mode 120000 index 00000000..0579a6b7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfru.so @@ -0,0 +1 @@ +./libfru.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfru.so.1 b/illumos-x86_64/usr/lib/amd64/libfru.so.1 new file mode 100755 index 00000000..fb22afa8 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libfru.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libfruraw.so b/illumos-x86_64/usr/lib/amd64/libfruraw.so new file mode 120000 index 00000000..8cabb288 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfruraw.so @@ -0,0 +1 @@ +./libfruraw.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfruraw.so.1 b/illumos-x86_64/usr/lib/amd64/libfruraw.so.1 new file mode 100755 index 00000000..03c400a6 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libfruraw.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libfrureg.so b/illumos-x86_64/usr/lib/amd64/libfrureg.so new file mode 120000 index 00000000..ab2c53ef --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfrureg.so @@ -0,0 +1 @@ +./libfrureg.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfrureg.so.1 b/illumos-x86_64/usr/lib/amd64/libfrureg.so.1 new file mode 100755 index 00000000..96b8223e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libfrureg.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libfruutils.so b/illumos-x86_64/usr/lib/amd64/libfruutils.so new file mode 120000 index 00000000..6c61d877 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfruutils.so @@ -0,0 +1 @@ +./libfruutils.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfruutils.so.1 b/illumos-x86_64/usr/lib/amd64/libfruutils.so.1 new file mode 100755 index 00000000..fc88f75e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libfruutils.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libfstyp.so b/illumos-x86_64/usr/lib/amd64/libfstyp.so new file mode 120000 index 00000000..722db45f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libfstyp.so @@ -0,0 +1 @@ +./libfstyp.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libfstyp.so.1 b/illumos-x86_64/usr/lib/amd64/libfstyp.so.1 new file mode 100755 index 00000000..66f1a101 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libfstyp.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libgcc_s.so b/illumos-x86_64/usr/lib/amd64/libgcc_s.so new file mode 120000 index 00000000..83033f74 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgcc_s.so @@ -0,0 +1 @@ +libgcc_s.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgcc_s.so.1 b/illumos-x86_64/usr/lib/amd64/libgcc_s.so.1 new file mode 120000 index 00000000..51374eaa --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgcc_s.so.1 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libgcc_s.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgen.so b/illumos-x86_64/usr/lib/amd64/libgen.so new file mode 120000 index 00000000..e9a2567f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgen.so @@ -0,0 +1 @@ +../../../lib/amd64/libgen.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgen.so.1 b/illumos-x86_64/usr/lib/amd64/libgen.so.1 new file mode 120000 index 00000000..e9a2567f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgen.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libgen.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgfortran.so b/illumos-x86_64/usr/lib/amd64/libgfortran.so new file mode 120000 index 00000000..d3d3a1ae --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgfortran.so @@ -0,0 +1 @@ +libgfortran.so.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgfortran.so.3 b/illumos-x86_64/usr/lib/amd64/libgfortran.so.3 new file mode 120000 index 00000000..95879bf4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgfortran.so.3 @@ -0,0 +1 @@ +libgfortran.so.3.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgfortran.so.3.0.0 b/illumos-x86_64/usr/lib/amd64/libgfortran.so.3.0.0 new file mode 120000 index 00000000..69700b61 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgfortran.so.3.0.0 @@ -0,0 +1 @@ +../../gcc/6/lib/amd64/libgfortran.so.3.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgfortran.so.4 b/illumos-x86_64/usr/lib/amd64/libgfortran.so.4 new file mode 120000 index 00000000..8d3ae89b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgfortran.so.4 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libgfortran.so.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgfortran.so.4.0.0 b/illumos-x86_64/usr/lib/amd64/libgfortran.so.4.0.0 new file mode 120000 index 00000000..5cef41a8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgfortran.so.4.0.0 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libgfortran.so.4.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgfortran.so.5 b/illumos-x86_64/usr/lib/amd64/libgfortran.so.5 new file mode 120000 index 00000000..3cfa4bef --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgfortran.so.5 @@ -0,0 +1 @@ +libgfortran.so.5.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgfortran.so.5.0.0 b/illumos-x86_64/usr/lib/amd64/libgfortran.so.5.0.0 new file mode 120000 index 00000000..1f9c996c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgfortran.so.5.0.0 @@ -0,0 +1 @@ +../../gcc/14/lib/amd64/libgfortran.so.5.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgio-2.0.so b/illumos-x86_64/usr/lib/amd64/libgio-2.0.so new file mode 120000 index 00000000..603ca479 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgio-2.0.so @@ -0,0 +1 @@ +libgio-2.0.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgio-2.0.so.0 b/illumos-x86_64/usr/lib/amd64/libgio-2.0.so.0 new file mode 120000 index 00000000..df508c75 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgio-2.0.so.0 @@ -0,0 +1 @@ +libgio-2.0.so.0.8400.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgio-2.0.so.0.8400.4 b/illumos-x86_64/usr/lib/amd64/libgio-2.0.so.0.8400.4 new file mode 100755 index 00000000..33a90858 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libgio-2.0.so.0.8400.4 differ diff --git a/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so b/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so new file mode 120000 index 00000000..9cae75e6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so @@ -0,0 +1 @@ +libgirepository-2.0.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so.0 b/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so.0 new file mode 120000 index 00000000..14be53eb --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so.0 @@ -0,0 +1 @@ +libgirepository-2.0.so.0.8400.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so.0.8400.4 b/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so.0.8400.4 new file mode 100755 index 00000000..737d7fad Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libgirepository-2.0.so.0.8400.4 differ diff --git a/illumos-x86_64/usr/lib/amd64/libglib-2.0.so b/illumos-x86_64/usr/lib/amd64/libglib-2.0.so new file mode 120000 index 00000000..ab4850b1 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libglib-2.0.so @@ -0,0 +1 @@ +libglib-2.0.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libglib-2.0.so.0 b/illumos-x86_64/usr/lib/amd64/libglib-2.0.so.0 new file mode 120000 index 00000000..61c3bcc8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libglib-2.0.so.0 @@ -0,0 +1 @@ +libglib-2.0.so.0.8400.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libglib-2.0.so.0.8400.4 b/illumos-x86_64/usr/lib/amd64/libglib-2.0.so.0.8400.4 new file mode 100755 index 00000000..ad6c3e33 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libglib-2.0.so.0.8400.4 differ diff --git a/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so b/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so new file mode 120000 index 00000000..96dd32f7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so @@ -0,0 +1 @@ +libgmodule-2.0.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so.0 b/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so.0 new file mode 120000 index 00000000..563ea81c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so.0 @@ -0,0 +1 @@ +libgmodule-2.0.so.0.8400.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so.0.8400.4 b/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so.0.8400.4 new file mode 100755 index 00000000..5705c863 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libgmodule-2.0.so.0.8400.4 differ diff --git a/illumos-x86_64/usr/lib/amd64/libgmp.so b/illumos-x86_64/usr/lib/amd64/libgmp.so new file mode 120000 index 00000000..b7b3e104 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgmp.so @@ -0,0 +1 @@ +libgmp.so.10.5.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgmp.so.10 b/illumos-x86_64/usr/lib/amd64/libgmp.so.10 new file mode 120000 index 00000000..b7b3e104 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgmp.so.10 @@ -0,0 +1 @@ +libgmp.so.10.5.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgmp.so.10.5.0 b/illumos-x86_64/usr/lib/amd64/libgmp.so.10.5.0 new file mode 100755 index 00000000..e86ca82f Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libgmp.so.10.5.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libgmpxx.so b/illumos-x86_64/usr/lib/amd64/libgmpxx.so new file mode 120000 index 00000000..45ba832e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgmpxx.so @@ -0,0 +1 @@ +libgmpxx.so.4.7.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgmpxx.so.4 b/illumos-x86_64/usr/lib/amd64/libgmpxx.so.4 new file mode 120000 index 00000000..45ba832e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgmpxx.so.4 @@ -0,0 +1 @@ +libgmpxx.so.4.7.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgmpxx.so.4.7.0 b/illumos-x86_64/usr/lib/amd64/libgmpxx.so.4.7.0 new file mode 100755 index 00000000..25a262d6 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libgmpxx.so.4.7.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so b/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so new file mode 120000 index 00000000..2c8e6881 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so @@ -0,0 +1 @@ +libgobject-2.0.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so.0 b/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so.0 new file mode 120000 index 00000000..8a4a2403 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so.0 @@ -0,0 +1 @@ +libgobject-2.0.so.0.8400.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so.0.8400.4 b/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so.0.8400.4 new file mode 100755 index 00000000..4e9ba10f Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libgobject-2.0.so.0.8400.4 differ diff --git a/illumos-x86_64/usr/lib/amd64/libgomp.so b/illumos-x86_64/usr/lib/amd64/libgomp.so new file mode 120000 index 00000000..82b51064 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgomp.so @@ -0,0 +1 @@ +libgomp.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgomp.so.1 b/illumos-x86_64/usr/lib/amd64/libgomp.so.1 new file mode 120000 index 00000000..fa3add19 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgomp.so.1 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libgomp.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgomp.so.1.0.0 b/illumos-x86_64/usr/lib/amd64/libgomp.so.1.0.0 new file mode 120000 index 00000000..9e7b5c36 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgomp.so.1.0.0 @@ -0,0 +1 @@ +../../gcc/14/lib/amd64/libgomp.so.1.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgss.so b/illumos-x86_64/usr/lib/amd64/libgss.so new file mode 120000 index 00000000..c08a7703 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgss.so @@ -0,0 +1 @@ +libgss.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgss.so.1 b/illumos-x86_64/usr/lib/amd64/libgss.so.1 new file mode 100755 index 00000000..0fd784f0 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libgss.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so b/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so new file mode 120000 index 00000000..7f14afef --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so @@ -0,0 +1 @@ +libgthread-2.0.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so.0 b/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so.0 new file mode 120000 index 00000000..7f632c97 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so.0 @@ -0,0 +1 @@ +libgthread-2.0.so.0.8400.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so.0.8400.4 b/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so.0.8400.4 new file mode 100755 index 00000000..28924ee2 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libgthread-2.0.so.0.8400.4 differ diff --git a/illumos-x86_64/usr/lib/amd64/libhal-storage.so b/illumos-x86_64/usr/lib/amd64/libhal-storage.so new file mode 120000 index 00000000..5bb93394 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libhal-storage.so @@ -0,0 +1 @@ +./libhal-storage.so.1.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libhal-storage.so.1 b/illumos-x86_64/usr/lib/amd64/libhal-storage.so.1 new file mode 120000 index 00000000..5bb93394 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libhal-storage.so.1 @@ -0,0 +1 @@ +./libhal-storage.so.1.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libhal-storage.so.1.0.0 b/illumos-x86_64/usr/lib/amd64/libhal-storage.so.1.0.0 new file mode 100755 index 00000000..81aa7382 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libhal-storage.so.1.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libhal.so b/illumos-x86_64/usr/lib/amd64/libhal.so new file mode 120000 index 00000000..f7fdef9f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libhal.so @@ -0,0 +1 @@ +./libhal.so.1.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libhal.so.1 b/illumos-x86_64/usr/lib/amd64/libhal.so.1 new file mode 120000 index 00000000..f7fdef9f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libhal.so.1 @@ -0,0 +1 @@ +./libhal.so.1.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libhal.so.1.0.0 b/illumos-x86_64/usr/lib/amd64/libhal.so.1.0.0 new file mode 100755 index 00000000..f1372652 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libhal.so.1.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libhistory.so b/illumos-x86_64/usr/lib/amd64/libhistory.so new file mode 120000 index 00000000..a2c3f26d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libhistory.so @@ -0,0 +1 @@ +libhistory.so.8 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libhistory.so.6 b/illumos-x86_64/usr/lib/amd64/libhistory.so.6 new file mode 100755 index 00000000..5c204dd0 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libhistory.so.6 differ diff --git a/illumos-x86_64/usr/lib/amd64/libhistory.so.7 b/illumos-x86_64/usr/lib/amd64/libhistory.so.7 new file mode 100755 index 00000000..ac6e501c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libhistory.so.7 differ diff --git a/illumos-x86_64/usr/lib/amd64/libhistory.so.8 b/illumos-x86_64/usr/lib/amd64/libhistory.so.8 new file mode 100755 index 00000000..216b69dc Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libhistory.so.8 differ diff --git a/illumos-x86_64/usr/lib/amd64/libhotplug.so b/illumos-x86_64/usr/lib/amd64/libhotplug.so new file mode 120000 index 00000000..32b11cef --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libhotplug.so @@ -0,0 +1 @@ +libhotplug.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libhotplug.so.1 b/illumos-x86_64/usr/lib/amd64/libhotplug.so.1 new file mode 100755 index 00000000..c9c14cf6 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libhotplug.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libidmap.so b/illumos-x86_64/usr/lib/amd64/libidmap.so new file mode 120000 index 00000000..528ca139 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libidmap.so @@ -0,0 +1 @@ +./libidmap.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libidmap.so.1 b/illumos-x86_64/usr/lib/amd64/libidmap.so.1 new file mode 100755 index 00000000..b1f8d13a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libidmap.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libidn.so b/illumos-x86_64/usr/lib/amd64/libidn.so new file mode 120000 index 00000000..53676981 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libidn.so @@ -0,0 +1 @@ +libidn.so.12.6.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libidn.so.11 b/illumos-x86_64/usr/lib/amd64/libidn.so.11 new file mode 120000 index 00000000..0d32884e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libidn.so.11 @@ -0,0 +1 @@ +libidn.so.11.6.18 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libidn.so.11.6.18 b/illumos-x86_64/usr/lib/amd64/libidn.so.11.6.18 new file mode 100755 index 00000000..e88da666 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libidn.so.11.6.18 differ diff --git a/illumos-x86_64/usr/lib/amd64/libidn.so.12 b/illumos-x86_64/usr/lib/amd64/libidn.so.12 new file mode 120000 index 00000000..53676981 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libidn.so.12 @@ -0,0 +1 @@ +libidn.so.12.6.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libidn.so.12.6.6 b/illumos-x86_64/usr/lib/amd64/libidn.so.12.6.6 new file mode 100755 index 00000000..761493ef Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libidn.so.12.6.6 differ diff --git a/illumos-x86_64/usr/lib/amd64/libidspace.so.1 b/illumos-x86_64/usr/lib/amd64/libidspace.so.1 new file mode 100755 index 00000000..f347f3b8 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libidspace.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libike.so.1 b/illumos-x86_64/usr/lib/amd64/libike.so.1 new file mode 100755 index 00000000..f716bf43 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libike.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libima.so b/illumos-x86_64/usr/lib/amd64/libima.so new file mode 120000 index 00000000..1c5d769b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libima.so @@ -0,0 +1 @@ +libima.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libima.so.1 b/illumos-x86_64/usr/lib/amd64/libima.so.1 new file mode 100755 index 00000000..85f2b13c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libima.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libinetutil.so.1 b/illumos-x86_64/usr/lib/amd64/libinetutil.so.1 new file mode 120000 index 00000000..c846b1d5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libinetutil.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libinetutil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libinstzones.so.1 b/illumos-x86_64/usr/lib/amd64/libinstzones.so.1 new file mode 100755 index 00000000..bf81744c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libinstzones.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libintl.so b/illumos-x86_64/usr/lib/amd64/libintl.so new file mode 120000 index 00000000..fe10a307 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libintl.so @@ -0,0 +1 @@ +../../../lib/amd64/libintl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libintl.so.1 b/illumos-x86_64/usr/lib/amd64/libintl.so.1 new file mode 120000 index 00000000..fe10a307 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libintl.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libintl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libipmi.so b/illumos-x86_64/usr/lib/amd64/libipmi.so new file mode 120000 index 00000000..94d79c2f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libipmi.so @@ -0,0 +1 @@ +./libipmi.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libipmi.so.1 b/illumos-x86_64/usr/lib/amd64/libipmi.so.1 new file mode 100755 index 00000000..22821738 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libipmi.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libipp.so b/illumos-x86_64/usr/lib/amd64/libipp.so new file mode 120000 index 00000000..6be2540c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libipp.so @@ -0,0 +1 @@ +libipp.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libipp.so.1 b/illumos-x86_64/usr/lib/amd64/libipp.so.1 new file mode 100755 index 00000000..fab73c1e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libipp.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libipsecutil.so.1 b/illumos-x86_64/usr/lib/amd64/libipsecutil.so.1 new file mode 100755 index 00000000..a49184c4 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libipsecutil.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libjedec.so.1 b/illumos-x86_64/usr/lib/amd64/libjedec.so.1 new file mode 100755 index 00000000..9482874f Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libjedec.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libkrb5.so b/illumos-x86_64/usr/lib/amd64/libkrb5.so new file mode 120000 index 00000000..6df4eacb --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libkrb5.so @@ -0,0 +1 @@ +./libkrb5.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libkrb5.so.1 b/illumos-x86_64/usr/lib/amd64/libkrb5.so.1 new file mode 100755 index 00000000..d9f2f032 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libkrb5.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libkstat.so b/illumos-x86_64/usr/lib/amd64/libkstat.so new file mode 120000 index 00000000..41b5baca --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libkstat.so @@ -0,0 +1 @@ +../../../lib/amd64/libkstat.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libkstat.so.1 b/illumos-x86_64/usr/lib/amd64/libkstat.so.1 new file mode 120000 index 00000000..41b5baca --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libkstat.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libkstat.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libkvm.so b/illumos-x86_64/usr/lib/amd64/libkvm.so new file mode 120000 index 00000000..9e6fa99f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libkvm.so @@ -0,0 +1 @@ +libkvm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libkvm.so.1 b/illumos-x86_64/usr/lib/amd64/libkvm.so.1 new file mode 100755 index 00000000..2380126d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libkvm.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libl.so b/illumos-x86_64/usr/lib/amd64/libl.so new file mode 120000 index 00000000..03c0ec1e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libl.so @@ -0,0 +1 @@ +libl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libl.so.1 b/illumos-x86_64/usr/lib/amd64/libl.so.1 new file mode 100755 index 00000000..56c2a75a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libl.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libldap.so b/illumos-x86_64/usr/lib/amd64/libldap.so new file mode 120000 index 00000000..6ea5f9ef --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libldap.so @@ -0,0 +1 @@ +libldap.so.5 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libldap.so.5 b/illumos-x86_64/usr/lib/amd64/libldap.so.5 new file mode 100755 index 00000000..eeb069e4 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libldap.so.5 differ diff --git a/illumos-x86_64/usr/lib/amd64/liblddbg.so.4 b/illumos-x86_64/usr/lib/amd64/liblddbg.so.4 new file mode 120000 index 00000000..b330124b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblddbg.so.4 @@ -0,0 +1 @@ +../../../lib/amd64/liblddbg.so.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libldstab.so.1 b/illumos-x86_64/usr/lib/amd64/libldstab.so.1 new file mode 100755 index 00000000..e470ccbc Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libldstab.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/liblgrp.so b/illumos-x86_64/usr/lib/amd64/liblgrp.so new file mode 120000 index 00000000..fca74369 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblgrp.so @@ -0,0 +1 @@ +liblgrp.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liblgrp.so.1 b/illumos-x86_64/usr/lib/amd64/liblgrp.so.1 new file mode 100755 index 00000000..ef604df3 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/liblgrp.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/liblm.so b/illumos-x86_64/usr/lib/amd64/liblm.so new file mode 120000 index 00000000..f851fa55 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblm.so @@ -0,0 +1 @@ +liblm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liblm.so.1 b/illumos-x86_64/usr/lib/amd64/liblm.so.1 new file mode 100755 index 00000000..196a3901 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/liblm.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/liblz.so b/illumos-x86_64/usr/lib/amd64/liblz.so new file mode 120000 index 00000000..fdff3623 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblz.so @@ -0,0 +1 @@ +liblz.so.1.15 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liblz.so.1 b/illumos-x86_64/usr/lib/amd64/liblz.so.1 new file mode 120000 index 00000000..fdff3623 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblz.so.1 @@ -0,0 +1 @@ +liblz.so.1.15 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liblz.so.1.15 b/illumos-x86_64/usr/lib/amd64/liblz.so.1.15 new file mode 100644 index 00000000..9a3061c2 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/liblz.so.1.15 differ diff --git a/illumos-x86_64/usr/lib/amd64/liblz4.so b/illumos-x86_64/usr/lib/amd64/liblz4.so new file mode 120000 index 00000000..74eaf62e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblz4.so @@ -0,0 +1 @@ +liblz4.so.1.10.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liblz4.so.1 b/illumos-x86_64/usr/lib/amd64/liblz4.so.1 new file mode 120000 index 00000000..74eaf62e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblz4.so.1 @@ -0,0 +1 @@ +liblz4.so.1.10.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liblz4.so.1.10.0 b/illumos-x86_64/usr/lib/amd64/liblz4.so.1.10.0 new file mode 100755 index 00000000..f10c6a53 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/liblz4.so.1.10.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/liblzma.so b/illumos-x86_64/usr/lib/amd64/liblzma.so new file mode 120000 index 00000000..4ccb27f3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblzma.so @@ -0,0 +1 @@ +liblzma.so.5.8.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liblzma.so.5 b/illumos-x86_64/usr/lib/amd64/liblzma.so.5 new file mode 120000 index 00000000..4ccb27f3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liblzma.so.5 @@ -0,0 +1 @@ +liblzma.so.5.8.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liblzma.so.5.8.1 b/illumos-x86_64/usr/lib/amd64/liblzma.so.5.8.1 new file mode 100755 index 00000000..e43252d0 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/liblzma.so.5.8.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libm.so b/illumos-x86_64/usr/lib/amd64/libm.so new file mode 120000 index 00000000..0d86b4c8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libm.so @@ -0,0 +1 @@ +../../../lib/amd64/libm.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libm.so.1 b/illumos-x86_64/usr/lib/amd64/libm.so.1 new file mode 120000 index 00000000..8ef76e14 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libm.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libm.so.2 b/illumos-x86_64/usr/lib/amd64/libm.so.2 new file mode 120000 index 00000000..0d86b4c8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libm.so.2 @@ -0,0 +1 @@ +../../../lib/amd64/libm.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmail.so b/illumos-x86_64/usr/lib/amd64/libmail.so new file mode 120000 index 00000000..2d23aec4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmail.so @@ -0,0 +1 @@ +libmail.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmail.so.1 b/illumos-x86_64/usr/lib/amd64/libmail.so.1 new file mode 100755 index 00000000..971f5bf9 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libmail.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libmakestate.so.1 b/illumos-x86_64/usr/lib/amd64/libmakestate.so.1 new file mode 100755 index 00000000..35d9828f Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libmakestate.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libmalloc.so b/illumos-x86_64/usr/lib/amd64/libmalloc.so new file mode 120000 index 00000000..bd59f3da --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmalloc.so @@ -0,0 +1 @@ +libmalloc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmalloc.so.1 b/illumos-x86_64/usr/lib/amd64/libmalloc.so.1 new file mode 100755 index 00000000..4fa864df Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libmalloc.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libmapmalloc.so b/illumos-x86_64/usr/lib/amd64/libmapmalloc.so new file mode 120000 index 00000000..9501fe4c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmapmalloc.so @@ -0,0 +1 @@ +libmapmalloc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmapmalloc.so.1 b/illumos-x86_64/usr/lib/amd64/libmapmalloc.so.1 new file mode 100755 index 00000000..e72135a4 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libmapmalloc.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libmd.so b/illumos-x86_64/usr/lib/amd64/libmd.so new file mode 120000 index 00000000..e1608928 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmd.so @@ -0,0 +1 @@ +../../../lib/amd64/libmd.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmd.so.1 b/illumos-x86_64/usr/lib/amd64/libmd.so.1 new file mode 120000 index 00000000..e1608928 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmd.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libmd.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmd5.so b/illumos-x86_64/usr/lib/amd64/libmd5.so new file mode 120000 index 00000000..21d26e87 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmd5.so @@ -0,0 +1 @@ +../../../lib/amd64/libmd5.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmd5.so.1 b/illumos-x86_64/usr/lib/amd64/libmd5.so.1 new file mode 120000 index 00000000..21d26e87 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmd5.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libmd5.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmenu.so b/illumos-x86_64/usr/lib/amd64/libmenu.so new file mode 120000 index 00000000..1f9bb547 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmenu.so @@ -0,0 +1 @@ +libmenu.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmenu.so.1 b/illumos-x86_64/usr/lib/amd64/libmenu.so.1 new file mode 100755 index 00000000..9aa73de2 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libmenu.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libmp.so b/illumos-x86_64/usr/lib/amd64/libmp.so new file mode 120000 index 00000000..bed710a5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmp.so @@ -0,0 +1 @@ +../../../lib/amd64/libmp.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmp.so.2 b/illumos-x86_64/usr/lib/amd64/libmp.so.2 new file mode 120000 index 00000000..bed710a5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmp.so.2 @@ -0,0 +1 @@ +../../../lib/amd64/libmp.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmpc.so b/illumos-x86_64/usr/lib/amd64/libmpc.so new file mode 120000 index 00000000..35ec056f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmpc.so @@ -0,0 +1 @@ +libmpc.so.3.3.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmpc.so.3 b/illumos-x86_64/usr/lib/amd64/libmpc.so.3 new file mode 120000 index 00000000..35ec056f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmpc.so.3 @@ -0,0 +1 @@ +libmpc.so.3.3.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmpc.so.3.3.1 b/illumos-x86_64/usr/lib/amd64/libmpc.so.3.3.1 new file mode 100755 index 00000000..acf1a168 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libmpc.so.3.3.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libmpfr.so b/illumos-x86_64/usr/lib/amd64/libmpfr.so new file mode 120000 index 00000000..ccd31e97 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmpfr.so @@ -0,0 +1 @@ +libmpfr.so.6.2.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmpfr.so.6 b/illumos-x86_64/usr/lib/amd64/libmpfr.so.6 new file mode 120000 index 00000000..ccd31e97 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmpfr.so.6 @@ -0,0 +1 @@ +libmpfr.so.6.2.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmpfr.so.6.2.2 b/illumos-x86_64/usr/lib/amd64/libmpfr.so.6.2.2 new file mode 100755 index 00000000..44de1363 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libmpfr.so.6.2.2 differ diff --git a/illumos-x86_64/usr/lib/amd64/libmtmalloc.so b/illumos-x86_64/usr/lib/amd64/libmtmalloc.so new file mode 120000 index 00000000..b1e64af0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmtmalloc.so @@ -0,0 +1 @@ +libmtmalloc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmtmalloc.so.1 b/illumos-x86_64/usr/lib/amd64/libmtmalloc.so.1 new file mode 100755 index 00000000..c4641af7 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libmtmalloc.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libmvec.so b/illumos-x86_64/usr/lib/amd64/libmvec.so new file mode 120000 index 00000000..3a1fad6a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmvec.so @@ -0,0 +1 @@ +../../../lib/amd64/libmvec.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libmvec.so.1 b/illumos-x86_64/usr/lib/amd64/libmvec.so.1 new file mode 120000 index 00000000..3a1fad6a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libmvec.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libmvec.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libncurses.so b/illumos-x86_64/usr/lib/amd64/libncurses.so new file mode 120000 index 00000000..05c9b579 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libncurses.so @@ -0,0 +1 @@ +libncurses.so.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libncurses.so.5 b/illumos-x86_64/usr/lib/amd64/libncurses.so.5 new file mode 120000 index 00000000..72caaf29 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libncurses.so.5 @@ -0,0 +1 @@ +libncurses.so.5.9 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libncurses.so.5.9 b/illumos-x86_64/usr/lib/amd64/libncurses.so.5.9 new file mode 100755 index 00000000..28af1d7b Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libncurses.so.5.9 differ diff --git a/illumos-x86_64/usr/lib/amd64/libncurses.so.6 b/illumos-x86_64/usr/lib/amd64/libncurses.so.6 new file mode 120000 index 00000000..19484a02 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libncurses.so.6 @@ -0,0 +1 @@ +libncurses.so.6.5 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libncurses.so.6.5 b/illumos-x86_64/usr/lib/amd64/libncurses.so.6.5 new file mode 100755 index 00000000..ee295a76 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libncurses.so.6.5 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmp.so b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so new file mode 120000 index 00000000..9c091f4f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so @@ -0,0 +1 @@ +libnetsnmp.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.30 b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.30 new file mode 120000 index 00000000..3b21ba43 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.30 @@ -0,0 +1 @@ +libnetsnmp.so.30.0.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.30.0.3 b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.30.0.3 new file mode 100755 index 00000000..80b8b000 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.30.0.3 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.35 b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.35 new file mode 120000 index 00000000..59d065dd --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.35 @@ -0,0 +1 @@ +libnetsnmp.so.35.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.35.0.0 b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.35.0.0 new file mode 100755 index 00000000..1f52d1d7 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.35.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.40 b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.40 new file mode 120000 index 00000000..9c091f4f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.40 @@ -0,0 +1 @@ +libnetsnmp.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.40.2.1 b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.40.2.1 new file mode 100755 index 00000000..918c58c8 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmp.so.40.2.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so new file mode 120000 index 00000000..ccf44348 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so @@ -0,0 +1 @@ +libnetsnmpagent.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.30 b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.30 new file mode 120000 index 00000000..838e41de --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.30 @@ -0,0 +1 @@ +libnetsnmpagent.so.30.0.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.30.0.3 b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.30.0.3 new file mode 100755 index 00000000..fe83ad6a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.30.0.3 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.35 b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.35 new file mode 120000 index 00000000..d0cc79f0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.35 @@ -0,0 +1 @@ +libnetsnmpagent.so.35.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.35.0.0 b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.35.0.0 new file mode 100755 index 00000000..acbdc752 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.35.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.40 b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.40 new file mode 120000 index 00000000..ccf44348 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.40 @@ -0,0 +1 @@ +libnetsnmpagent.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.40.2.1 b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.40.2.1 new file mode 100755 index 00000000..e4b06609 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmpagent.so.40.2.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so new file mode 120000 index 00000000..b76ed491 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so @@ -0,0 +1 @@ +libnetsnmphelpers.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.30 b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.30 new file mode 120000 index 00000000..c75e175d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.30 @@ -0,0 +1 @@ +libnetsnmphelpers.so.30.0.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.30.0.3 b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.30.0.3 new file mode 100755 index 00000000..6f97a67c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.30.0.3 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.35 b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.35 new file mode 120000 index 00000000..e0d056da --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.35 @@ -0,0 +1 @@ +libnetsnmphelpers.so.35.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.35.0.0 b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.35.0.0 new file mode 100755 index 00000000..d841f114 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.35.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.40 b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.40 new file mode 120000 index 00000000..b76ed491 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.40 @@ -0,0 +1 @@ +libnetsnmphelpers.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.40.2.1 b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.40.2.1 new file mode 100755 index 00000000..97a47eaa Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmphelpers.so.40.2.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so new file mode 120000 index 00000000..1bc34699 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so @@ -0,0 +1 @@ +libnetsnmpmibs.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.30 b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.30 new file mode 120000 index 00000000..a0dc36f8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.30 @@ -0,0 +1 @@ +libnetsnmpmibs.so.30.0.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.30.0.3 b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.30.0.3 new file mode 100755 index 00000000..61871011 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.30.0.3 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.35 b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.35 new file mode 120000 index 00000000..58edb99b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.35 @@ -0,0 +1 @@ +libnetsnmpmibs.so.35.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.35.0.0 b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.35.0.0 new file mode 100755 index 00000000..9ce83c44 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.35.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.40 b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.40 new file mode 120000 index 00000000..1bc34699 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.40 @@ -0,0 +1 @@ +libnetsnmpmibs.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.40.2.1 b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.40.2.1 new file mode 100755 index 00000000..d125bd9a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmpmibs.so.40.2.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so b/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so new file mode 120000 index 00000000..8a93fd0f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so @@ -0,0 +1 @@ +libnetsnmptrapd.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so.40 b/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so.40 new file mode 120000 index 00000000..8a93fd0f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so.40 @@ -0,0 +1 @@ +libnetsnmptrapd.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so.40.2.1 b/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so.40.2.1 new file mode 100755 index 00000000..446a1c48 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnetsnmptrapd.so.40.2.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnghttp2.so b/illumos-x86_64/usr/lib/amd64/libnghttp2.so new file mode 120000 index 00000000..be2635c4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnghttp2.so @@ -0,0 +1 @@ +libnghttp2.so.14.29.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnghttp2.so.14 b/illumos-x86_64/usr/lib/amd64/libnghttp2.so.14 new file mode 120000 index 00000000..be2635c4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnghttp2.so.14 @@ -0,0 +1 @@ +libnghttp2.so.14.29.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnghttp2.so.14.29.1 b/illumos-x86_64/usr/lib/amd64/libnghttp2.so.14.29.1 new file mode 100755 index 00000000..3f6b2c56 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnghttp2.so.14.29.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnls.so b/illumos-x86_64/usr/lib/amd64/libnls.so new file mode 120000 index 00000000..4baa7999 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnls.so @@ -0,0 +1 @@ +libnls.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnls.so.1 b/illumos-x86_64/usr/lib/amd64/libnls.so.1 new file mode 100755 index 00000000..04eed8e6 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnls.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnsl.so b/illumos-x86_64/usr/lib/amd64/libnsl.so new file mode 120000 index 00000000..c222d4c4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnsl.so @@ -0,0 +1 @@ +../../../lib/amd64/libnsl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnsl.so.1 b/illumos-x86_64/usr/lib/amd64/libnsl.so.1 new file mode 120000 index 00000000..c222d4c4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnsl.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libnsl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnvfru.so b/illumos-x86_64/usr/lib/amd64/libnvfru.so new file mode 120000 index 00000000..7f35b8e0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnvfru.so @@ -0,0 +1 @@ +./libnvfru.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnvfru.so.1 b/illumos-x86_64/usr/lib/amd64/libnvfru.so.1 new file mode 100755 index 00000000..b459fbaf Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnvfru.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnvme.so b/illumos-x86_64/usr/lib/amd64/libnvme.so new file mode 120000 index 00000000..41b40406 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnvme.so @@ -0,0 +1 @@ +libnvme.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnvme.so.1 b/illumos-x86_64/usr/lib/amd64/libnvme.so.1 new file mode 100755 index 00000000..8401f195 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libnvme.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libnvpair.so b/illumos-x86_64/usr/lib/amd64/libnvpair.so new file mode 120000 index 00000000..39d3696e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnvpair.so @@ -0,0 +1 @@ +../../../lib/amd64/libnvpair.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libnvpair.so.1 b/illumos-x86_64/usr/lib/amd64/libnvpair.so.1 new file mode 120000 index 00000000..39d3696e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libnvpair.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libnvpair.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libobjc.so b/illumos-x86_64/usr/lib/amd64/libobjc.so new file mode 120000 index 00000000..ee8d64eb --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libobjc.so @@ -0,0 +1 @@ +libobjc.so.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libobjc.so.4 b/illumos-x86_64/usr/lib/amd64/libobjc.so.4 new file mode 120000 index 00000000..bbf414b6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libobjc.so.4 @@ -0,0 +1 @@ +../../gcc/9/lib/amd64/libobjc.so.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libobjc.so.4.0.0 b/illumos-x86_64/usr/lib/amd64/libobjc.so.4.0.0 new file mode 120000 index 00000000..ddaee748 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libobjc.so.4.0.0 @@ -0,0 +1 @@ +../../gcc/14/lib/amd64/libobjc.so.4.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpam.so b/illumos-x86_64/usr/lib/amd64/libpam.so new file mode 120000 index 00000000..257b7bc2 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpam.so @@ -0,0 +1 @@ +../../../lib/amd64/libpam.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpam.so.1 b/illumos-x86_64/usr/lib/amd64/libpam.so.1 new file mode 120000 index 00000000..257b7bc2 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpam.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libpam.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpanel.so b/illumos-x86_64/usr/lib/amd64/libpanel.so new file mode 120000 index 00000000..f11e06bf --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpanel.so @@ -0,0 +1 @@ +libpanel.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpanel.so.1 b/illumos-x86_64/usr/lib/amd64/libpanel.so.1 new file mode 100755 index 00000000..fad91604 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpanel.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcap.so b/illumos-x86_64/usr/lib/amd64/libpcap.so new file mode 120000 index 00000000..6235c0ab --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcap.so @@ -0,0 +1 @@ +libpcap.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcap.so.1 b/illumos-x86_64/usr/lib/amd64/libpcap.so.1 new file mode 120000 index 00000000..007cc628 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcap.so.1 @@ -0,0 +1 @@ +libpcap.so.1.10.5 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcap.so.1.10.5 b/illumos-x86_64/usr/lib/amd64/libpcap.so.1.10.5 new file mode 100755 index 00000000..da7c371e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcap.so.1.10.5 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcidb.so.1 b/illumos-x86_64/usr/lib/amd64/libpcidb.so.1 new file mode 100755 index 00000000..0eaadcff Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcidb.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcre.so b/illumos-x86_64/usr/lib/amd64/libpcre.so new file mode 120000 index 00000000..e549e59f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre.so @@ -0,0 +1 @@ +libpcre.so.1.2.13 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre.so.1 b/illumos-x86_64/usr/lib/amd64/libpcre.so.1 new file mode 120000 index 00000000..e549e59f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre.so.1 @@ -0,0 +1 @@ +libpcre.so.1.2.13 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre.so.1.2.13 b/illumos-x86_64/usr/lib/amd64/libpcre.so.1.2.13 new file mode 100755 index 00000000..7b26734e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcre.so.1.2.13 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-16.so b/illumos-x86_64/usr/lib/amd64/libpcre2-16.so new file mode 120000 index 00000000..c7798bb0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-16.so @@ -0,0 +1 @@ +libpcre2-16.so.0.14.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-16.so.0 b/illumos-x86_64/usr/lib/amd64/libpcre2-16.so.0 new file mode 120000 index 00000000..c7798bb0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-16.so.0 @@ -0,0 +1 @@ +libpcre2-16.so.0.14.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-16.so.0.14.0 b/illumos-x86_64/usr/lib/amd64/libpcre2-16.so.0.14.0 new file mode 100755 index 00000000..c68f5906 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcre2-16.so.0.14.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-32.so b/illumos-x86_64/usr/lib/amd64/libpcre2-32.so new file mode 120000 index 00000000..ee910001 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-32.so @@ -0,0 +1 @@ +libpcre2-32.so.0.14.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-32.so.0 b/illumos-x86_64/usr/lib/amd64/libpcre2-32.so.0 new file mode 120000 index 00000000..ee910001 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-32.so.0 @@ -0,0 +1 @@ +libpcre2-32.so.0.14.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-32.so.0.14.0 b/illumos-x86_64/usr/lib/amd64/libpcre2-32.so.0.14.0 new file mode 100755 index 00000000..556198f7 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcre2-32.so.0.14.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-8.so b/illumos-x86_64/usr/lib/amd64/libpcre2-8.so new file mode 120000 index 00000000..3bbbad42 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-8.so @@ -0,0 +1 @@ +libpcre2-8.so.0.14.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-8.so.0 b/illumos-x86_64/usr/lib/amd64/libpcre2-8.so.0 new file mode 120000 index 00000000..3bbbad42 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-8.so.0 @@ -0,0 +1 @@ +libpcre2-8.so.0.14.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-8.so.0.14.0 b/illumos-x86_64/usr/lib/amd64/libpcre2-8.so.0.14.0 new file mode 100755 index 00000000..5bf2d30e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcre2-8.so.0.14.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so new file mode 120000 index 00000000..979fd14a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so @@ -0,0 +1 @@ +libpcre2-posix.so.3.0.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.2 b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.2 new file mode 120000 index 00000000..4320b2d4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.2 @@ -0,0 +1 @@ +libpcre2-posix.so.2.0.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.2.0.3 b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.2.0.3 new file mode 100755 index 00000000..09059493 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.2.0.3 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.3 b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.3 new file mode 120000 index 00000000..979fd14a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.3 @@ -0,0 +1 @@ +libpcre2-posix.so.3.0.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.3.0.6 b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.3.0.6 new file mode 100755 index 00000000..1f01828c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcre2-posix.so.3.0.6 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcrecpp.so b/illumos-x86_64/usr/lib/amd64/libpcrecpp.so new file mode 120000 index 00000000..873211d5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcrecpp.so @@ -0,0 +1 @@ +libpcrecpp.so.0.0.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcrecpp.so.0 b/illumos-x86_64/usr/lib/amd64/libpcrecpp.so.0 new file mode 120000 index 00000000..873211d5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcrecpp.so.0 @@ -0,0 +1 @@ +libpcrecpp.so.0.0.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcrecpp.so.0.0.2 b/illumos-x86_64/usr/lib/amd64/libpcrecpp.so.0.0.2 new file mode 100755 index 00000000..730d361d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcrecpp.so.0.0.2 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpcreposix.so b/illumos-x86_64/usr/lib/amd64/libpcreposix.so new file mode 120000 index 00000000..e951f977 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcreposix.so @@ -0,0 +1 @@ +libpcreposix.so.0.0.7 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcreposix.so.0 b/illumos-x86_64/usr/lib/amd64/libpcreposix.so.0 new file mode 120000 index 00000000..e951f977 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpcreposix.so.0 @@ -0,0 +1 @@ +libpcreposix.so.0.0.7 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpcreposix.so.0.0.7 b/illumos-x86_64/usr/lib/amd64/libpcreposix.so.0.0.7 new file mode 100755 index 00000000..58103d57 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpcreposix.so.0.0.7 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpicl.so b/illumos-x86_64/usr/lib/amd64/libpicl.so new file mode 120000 index 00000000..575e7c04 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpicl.so @@ -0,0 +1 @@ +./libpicl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpicl.so.1 b/illumos-x86_64/usr/lib/amd64/libpicl.so.1 new file mode 100755 index 00000000..ecf82a92 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpicl.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpkcs11.so b/illumos-x86_64/usr/lib/amd64/libpkcs11.so new file mode 120000 index 00000000..b0dac97f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpkcs11.so @@ -0,0 +1 @@ +libpkcs11.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpkcs11.so.1 b/illumos-x86_64/usr/lib/amd64/libpkcs11.so.1 new file mode 100755 index 00000000..5c660765 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpkcs11.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpool.so b/illumos-x86_64/usr/lib/amd64/libpool.so new file mode 120000 index 00000000..ef2a17fb --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpool.so @@ -0,0 +1 @@ +libpool.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpool.so.1 b/illumos-x86_64/usr/lib/amd64/libpool.so.1 new file mode 100755 index 00000000..efa37e9a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpool.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libposix4.so b/illumos-x86_64/usr/lib/amd64/libposix4.so new file mode 120000 index 00000000..25e64485 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libposix4.so @@ -0,0 +1 @@ +../../../lib/amd64/librt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libposix4.so.1 b/illumos-x86_64/usr/lib/amd64/libposix4.so.1 new file mode 120000 index 00000000..25e64485 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libposix4.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/librt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libppt.so.1 b/illumos-x86_64/usr/lib/amd64/libppt.so.1 new file mode 100755 index 00000000..cfc01d0d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libppt.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libproc.so b/illumos-x86_64/usr/lib/amd64/libproc.so new file mode 120000 index 00000000..eb322f65 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libproc.so @@ -0,0 +1 @@ +../../../lib/amd64/libproc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libproc.so.1 b/illumos-x86_64/usr/lib/amd64/libproc.so.1 new file mode 120000 index 00000000..eb322f65 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libproc.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libproc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libproject.so b/illumos-x86_64/usr/lib/amd64/libproject.so new file mode 120000 index 00000000..e8fc240c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libproject.so @@ -0,0 +1 @@ +libproject.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libproject.so.1 b/illumos-x86_64/usr/lib/amd64/libproject.so.1 new file mode 100755 index 00000000..d9892bd2 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libproject.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpsl.so b/illumos-x86_64/usr/lib/amd64/libpsl.so new file mode 120000 index 00000000..320f6494 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpsl.so @@ -0,0 +1 @@ +libpsl.so.5.3.5 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpsl.so.5 b/illumos-x86_64/usr/lib/amd64/libpsl.so.5 new file mode 120000 index 00000000..320f6494 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpsl.so.5 @@ -0,0 +1 @@ +libpsl.so.5.3.5 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpsl.so.5.3.5 b/illumos-x86_64/usr/lib/amd64/libpsl.so.5.3.5 new file mode 100755 index 00000000..ba035a6e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpsl.so.5.3.5 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpthread.so b/illumos-x86_64/usr/lib/amd64/libpthread.so new file mode 120000 index 00000000..6bd27821 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpthread.so @@ -0,0 +1 @@ +../../../lib/amd64/libpthread.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpthread.so.1 b/illumos-x86_64/usr/lib/amd64/libpthread.so.1 new file mode 120000 index 00000000..6bd27821 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpthread.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libpthread.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpython3.13-stub.so b/illumos-x86_64/usr/lib/amd64/libpython3.13-stub.so new file mode 100755 index 00000000..8ec8686c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpython3.13-stub.so differ diff --git a/illumos-x86_64/usr/lib/amd64/libpython3.13.so b/illumos-x86_64/usr/lib/amd64/libpython3.13.so new file mode 120000 index 00000000..9e24cff1 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpython3.13.so @@ -0,0 +1 @@ +libpython3.13.so.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libpython3.13.so.1.0 b/illumos-x86_64/usr/lib/amd64/libpython3.13.so.1.0 new file mode 100755 index 00000000..3be2d99d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libpython3.13.so.1.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libpython3.so b/illumos-x86_64/usr/lib/amd64/libpython3.so new file mode 120000 index 00000000..c86b416c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libpython3.so @@ -0,0 +1 @@ +libpython3.13-stub.so \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libquadmath.so b/illumos-x86_64/usr/lib/amd64/libquadmath.so new file mode 120000 index 00000000..bf5541ea --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libquadmath.so @@ -0,0 +1 @@ +libquadmath.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libquadmath.so.0 b/illumos-x86_64/usr/lib/amd64/libquadmath.so.0 new file mode 120000 index 00000000..b27e7e99 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libquadmath.so.0 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libquadmath.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libquadmath.so.0.0.0 b/illumos-x86_64/usr/lib/amd64/libquadmath.so.0.0.0 new file mode 120000 index 00000000..0523e687 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libquadmath.so.0.0.0 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libquadmath.so.0.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libraidcfg.so.1 b/illumos-x86_64/usr/lib/amd64/libraidcfg.so.1 new file mode 100755 index 00000000..f2df2663 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libraidcfg.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/librcm.so b/illumos-x86_64/usr/lib/amd64/librcm.so new file mode 120000 index 00000000..da609eb4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librcm.so @@ -0,0 +1 @@ +../../../lib/amd64/librcm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librcm.so.1 b/illumos-x86_64/usr/lib/amd64/librcm.so.1 new file mode 120000 index 00000000..da609eb4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librcm.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/librcm.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libreadline.so b/illumos-x86_64/usr/lib/amd64/libreadline.so new file mode 120000 index 00000000..803845b0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libreadline.so @@ -0,0 +1 @@ +libreadline.so.8 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libreadline.so.6 b/illumos-x86_64/usr/lib/amd64/libreadline.so.6 new file mode 100755 index 00000000..463da37a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libreadline.so.6 differ diff --git a/illumos-x86_64/usr/lib/amd64/libreadline.so.7 b/illumos-x86_64/usr/lib/amd64/libreadline.so.7 new file mode 100755 index 00000000..c57b096a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libreadline.so.7 differ diff --git a/illumos-x86_64/usr/lib/amd64/libreadline.so.8 b/illumos-x86_64/usr/lib/amd64/libreadline.so.8 new file mode 100755 index 00000000..fe364c27 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libreadline.so.8 differ diff --git a/illumos-x86_64/usr/lib/amd64/librename.so.1 b/illumos-x86_64/usr/lib/amd64/librename.so.1 new file mode 100755 index 00000000..4b33abce Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/librename.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libreparse.so b/illumos-x86_64/usr/lib/amd64/libreparse.so new file mode 120000 index 00000000..875332cf --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libreparse.so @@ -0,0 +1 @@ +libreparse.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libreparse.so.1 b/illumos-x86_64/usr/lib/amd64/libreparse.so.1 new file mode 100755 index 00000000..c5de11dc Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libreparse.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libresolv.so b/illumos-x86_64/usr/lib/amd64/libresolv.so new file mode 120000 index 00000000..f2f38b85 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libresolv.so @@ -0,0 +1 @@ +../../../lib/amd64/libresolv.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libresolv.so.2 b/illumos-x86_64/usr/lib/amd64/libresolv.so.2 new file mode 120000 index 00000000..f2f38b85 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libresolv.so.2 @@ -0,0 +1 @@ +../../../lib/amd64/libresolv.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librestart.so b/illumos-x86_64/usr/lib/amd64/librestart.so new file mode 120000 index 00000000..c869d0e1 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librestart.so @@ -0,0 +1 @@ +../../../lib/amd64/librestart.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librestart.so.1 b/illumos-x86_64/usr/lib/amd64/librestart.so.1 new file mode 120000 index 00000000..c869d0e1 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librestart.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/librestart.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librpcsvc.so b/illumos-x86_64/usr/lib/amd64/librpcsvc.so new file mode 120000 index 00000000..31d94e21 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librpcsvc.so @@ -0,0 +1 @@ +../../../lib/amd64/librpcsvc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librpcsvc.so.1 b/illumos-x86_64/usr/lib/amd64/librpcsvc.so.1 new file mode 120000 index 00000000..31d94e21 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librpcsvc.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/librpcsvc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librt.so b/illumos-x86_64/usr/lib/amd64/librt.so new file mode 120000 index 00000000..25e64485 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librt.so @@ -0,0 +1 @@ +../../../lib/amd64/librt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librt.so.1 b/illumos-x86_64/usr/lib/amd64/librt.so.1 new file mode 120000 index 00000000..25e64485 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librt.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/librt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librtld.so.1 b/illumos-x86_64/usr/lib/amd64/librtld.so.1 new file mode 120000 index 00000000..cd7b4eca --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librtld.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/librtld.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librtld_db.so b/illumos-x86_64/usr/lib/amd64/librtld_db.so new file mode 120000 index 00000000..4ee72cd4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librtld_db.so @@ -0,0 +1 @@ +../../../lib/amd64/librtld_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/librtld_db.so.1 b/illumos-x86_64/usr/lib/amd64/librtld_db.so.1 new file mode 120000 index 00000000..4ee72cd4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/librtld_db.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/librtld_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsasl.so b/illumos-x86_64/usr/lib/amd64/libsasl.so new file mode 120000 index 00000000..efd4b4b5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsasl.so @@ -0,0 +1 @@ +libsasl.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsasl.so.1 b/illumos-x86_64/usr/lib/amd64/libsasl.so.1 new file mode 100755 index 00000000..e6ac0db1 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsasl.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsaveargs.so.1 b/illumos-x86_64/usr/lib/amd64/libsaveargs.so.1 new file mode 100755 index 00000000..38542daa Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsaveargs.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libscf.so b/illumos-x86_64/usr/lib/amd64/libscf.so new file mode 120000 index 00000000..1cbcc8a3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libscf.so @@ -0,0 +1 @@ +../../../lib/amd64/libscf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libscf.so.1 b/illumos-x86_64/usr/lib/amd64/libscf.so.1 new file mode 120000 index 00000000..1cbcc8a3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libscf.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libscf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsched.so b/illumos-x86_64/usr/lib/amd64/libsched.so new file mode 120000 index 00000000..500d3016 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsched.so @@ -0,0 +1 @@ +libsched.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsched.so.1 b/illumos-x86_64/usr/lib/amd64/libsched.so.1 new file mode 100755 index 00000000..06a04a8f Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsched.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsctp.so b/illumos-x86_64/usr/lib/amd64/libsctp.so new file mode 120000 index 00000000..d484040d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsctp.so @@ -0,0 +1 @@ +./libsctp.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsctp.so.1 b/illumos-x86_64/usr/lib/amd64/libsctp.so.1 new file mode 100755 index 00000000..b4b59c6b Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsctp.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsec.so b/illumos-x86_64/usr/lib/amd64/libsec.so new file mode 120000 index 00000000..ade17751 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsec.so @@ -0,0 +1 @@ +../../../lib/amd64/libsec.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsec.so.1 b/illumos-x86_64/usr/lib/amd64/libsec.so.1 new file mode 120000 index 00000000..ade17751 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsec.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libsec.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsecdb.so b/illumos-x86_64/usr/lib/amd64/libsecdb.so new file mode 120000 index 00000000..3d55546a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsecdb.so @@ -0,0 +1 @@ +../../../lib/amd64/libsecdb.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsecdb.so.1 b/illumos-x86_64/usr/lib/amd64/libsecdb.so.1 new file mode 120000 index 00000000..3d55546a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsecdb.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libsecdb.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsendfile.so b/illumos-x86_64/usr/lib/amd64/libsendfile.so new file mode 120000 index 00000000..12cc7a5d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsendfile.so @@ -0,0 +1 @@ +../../../lib/amd64/libsendfile.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsendfile.so.1 b/illumos-x86_64/usr/lib/amd64/libsendfile.so.1 new file mode 120000 index 00000000..12cc7a5d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsendfile.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libsendfile.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsff.so.1 b/illumos-x86_64/usr/lib/amd64/libsff.so.1 new file mode 100755 index 00000000..da6f6cd5 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsff.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libshare.so.1 b/illumos-x86_64/usr/lib/amd64/libshare.so.1 new file mode 100755 index 00000000..1c5b716d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libshare.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libshell.so.1 b/illumos-x86_64/usr/lib/amd64/libshell.so.1 new file mode 100755 index 00000000..e9cbffbd Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libshell.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsip.so b/illumos-x86_64/usr/lib/amd64/libsip.so new file mode 120000 index 00000000..433c181a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsip.so @@ -0,0 +1 @@ +./libsip.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsip.so.1 b/illumos-x86_64/usr/lib/amd64/libsip.so.1 new file mode 100755 index 00000000..b2b04c0e Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsip.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsldap.so b/illumos-x86_64/usr/lib/amd64/libsldap.so new file mode 120000 index 00000000..3bb09290 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsldap.so @@ -0,0 +1 @@ +libsldap.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsldap.so.1 b/illumos-x86_64/usr/lib/amd64/libsldap.so.1 new file mode 100755 index 00000000..1f0808f1 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsldap.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsmbfs.so.1 b/illumos-x86_64/usr/lib/amd64/libsmbfs.so.1 new file mode 100755 index 00000000..1df34b20 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsmbfs.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsmbios.so b/illumos-x86_64/usr/lib/amd64/libsmbios.so new file mode 120000 index 00000000..4d8d5c79 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsmbios.so @@ -0,0 +1 @@ +libsmbios.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsmbios.so.1 b/illumos-x86_64/usr/lib/amd64/libsmbios.so.1 new file mode 100755 index 00000000..fa35188c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsmbios.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsmedia.so b/illumos-x86_64/usr/lib/amd64/libsmedia.so new file mode 120000 index 00000000..3167dcfc --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsmedia.so @@ -0,0 +1 @@ +./libsmedia.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsmedia.so.1 b/illumos-x86_64/usr/lib/amd64/libsmedia.so.1 new file mode 100755 index 00000000..cc7a28a1 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsmedia.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsnmp.so b/illumos-x86_64/usr/lib/amd64/libsnmp.so new file mode 120000 index 00000000..15a31ee3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsnmp.so @@ -0,0 +1 @@ +libsnmp.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsnmp.so.30 b/illumos-x86_64/usr/lib/amd64/libsnmp.so.30 new file mode 120000 index 00000000..befd83fe --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsnmp.so.30 @@ -0,0 +1 @@ +libsnmp.so.30.0.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsnmp.so.30.0.3 b/illumos-x86_64/usr/lib/amd64/libsnmp.so.30.0.3 new file mode 100755 index 00000000..ee24bfb5 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsnmp.so.30.0.3 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsnmp.so.35 b/illumos-x86_64/usr/lib/amd64/libsnmp.so.35 new file mode 120000 index 00000000..b3198703 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsnmp.so.35 @@ -0,0 +1 @@ +libsnmp.so.35.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsnmp.so.35.0.0 b/illumos-x86_64/usr/lib/amd64/libsnmp.so.35.0.0 new file mode 100755 index 00000000..d82b7a39 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsnmp.so.35.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsnmp.so.40 b/illumos-x86_64/usr/lib/amd64/libsnmp.so.40 new file mode 120000 index 00000000..15a31ee3 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsnmp.so.40 @@ -0,0 +1 @@ +libsnmp.so.40.2.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsnmp.so.40.2.1 b/illumos-x86_64/usr/lib/amd64/libsnmp.so.40.2.1 new file mode 100755 index 00000000..f1eeaaca Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsnmp.so.40.2.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsocket.so b/illumos-x86_64/usr/lib/amd64/libsocket.so new file mode 120000 index 00000000..df1e51aa --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsocket.so @@ -0,0 +1 @@ +../../../lib/amd64/libsocket.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsocket.so.1 b/illumos-x86_64/usr/lib/amd64/libsocket.so.1 new file mode 120000 index 00000000..df1e51aa --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsocket.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libsocket.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsoftcrypto.so b/illumos-x86_64/usr/lib/amd64/libsoftcrypto.so new file mode 120000 index 00000000..aad70985 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsoftcrypto.so @@ -0,0 +1 @@ +./libsoftcrypto.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsoftcrypto.so.1 b/illumos-x86_64/usr/lib/amd64/libsoftcrypto.so.1 new file mode 100755 index 00000000..12432c43 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsoftcrypto.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsqlite3.so b/illumos-x86_64/usr/lib/amd64/libsqlite3.so new file mode 120000 index 00000000..09a7176d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsqlite3.so @@ -0,0 +1 @@ +libsqlite3.so.3.50.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsqlite3.so.0 b/illumos-x86_64/usr/lib/amd64/libsqlite3.so.0 new file mode 120000 index 00000000..09a7176d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsqlite3.so.0 @@ -0,0 +1 @@ +libsqlite3.so.3.50.4 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsqlite3.so.3.50.4 b/illumos-x86_64/usr/lib/amd64/libsqlite3.so.3.50.4 new file mode 100755 index 00000000..9b3f5d3a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsqlite3.so.3.50.4 differ diff --git a/illumos-x86_64/usr/lib/amd64/libssl.so b/illumos-x86_64/usr/lib/amd64/libssl.so new file mode 120000 index 00000000..7481049b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libssl.so @@ -0,0 +1 @@ +libssl.so.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libssl.so.3 b/illumos-x86_64/usr/lib/amd64/libssl.so.3 new file mode 120000 index 00000000..b8f1e428 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libssl.so.3 @@ -0,0 +1 @@ +../../../lib/amd64/libssl.so.3 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libssp.so b/illumos-x86_64/usr/lib/amd64/libssp.so new file mode 120000 index 00000000..1919598c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libssp.so @@ -0,0 +1 @@ +libssp.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libssp.so.0 b/illumos-x86_64/usr/lib/amd64/libssp.so.0 new file mode 120000 index 00000000..5e454231 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libssp.so.0 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libssp.so.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libssp.so.0.0.0 b/illumos-x86_64/usr/lib/amd64/libssp.so.0.0.0 new file mode 120000 index 00000000..c510f36f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libssp.so.0.0.0 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libssp.so.0.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libssp_ns.a b/illumos-x86_64/usr/lib/amd64/libssp_ns.a new file mode 100644 index 00000000..db26278b Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libssp_ns.a differ diff --git a/illumos-x86_64/usr/lib/amd64/libstdbuf.so b/illumos-x86_64/usr/lib/amd64/libstdbuf.so new file mode 100755 index 00000000..a4c337c2 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libstdbuf.so differ diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so b/illumos-x86_64/usr/lib/amd64/libstdc++.so new file mode 120000 index 00000000..87ceb047 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so @@ -0,0 +1 @@ +libstdc++.so.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6 new file mode 120000 index 00000000..16e6c87e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libstdc++.so.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.13 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.13 new file mode 120000 index 00000000..d0fdf524 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.13 @@ -0,0 +1 @@ +../../gcc/legacy/lib/amd64/libstdc++.so.6.0.13 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.16 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.16 new file mode 120000 index 00000000..067f2e0d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.16 @@ -0,0 +1 @@ +../../gcc/legacy/lib/amd64/libstdc++.so.6.0.16 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.17 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.17 new file mode 120000 index 00000000..0965b4aa --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.17 @@ -0,0 +1 @@ +../../gcc/legacy/lib/amd64/libstdc++.so.6.0.17 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.18 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.18 new file mode 120000 index 00000000..5a0e4062 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.18 @@ -0,0 +1 @@ +../../gcc/legacy/lib/amd64/libstdc++.so.6.0.18 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.21 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.21 new file mode 120000 index 00000000..6feceee1 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.21 @@ -0,0 +1 @@ +../../gcc/5/lib/amd64/libstdc++.so.6.0.21 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.22 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.22 new file mode 120000 index 00000000..04fd2ff8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.22 @@ -0,0 +1 @@ +../../gcc/6/lib/amd64/libstdc++.so.6.0.22 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.24 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.24 new file mode 120000 index 00000000..e4b548c4 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.24 @@ -0,0 +1 @@ +../../gcc/7/lib/amd64/libstdc++.so.6.0.24 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.25 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.25 new file mode 120000 index 00000000..5b7f21f6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.25 @@ -0,0 +1 @@ +../../gcc/8/lib/amd64/libstdc++.so.6.0.25 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.27 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.27 new file mode 120000 index 00000000..dee16e98 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.27 @@ -0,0 +1 @@ +../../gcc/legacy/lib/amd64/libstdc++.so.6.0.27 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.28 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.28 new file mode 120000 index 00000000..ba2bbead --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.28 @@ -0,0 +1 @@ +../../gcc/10/lib/amd64/libstdc++.so.6.0.28 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.29 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.29 new file mode 120000 index 00000000..a14ccba0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.29 @@ -0,0 +1 @@ +../../gcc/11/lib/amd64/libstdc++.so.6.0.29 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.30 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.30 new file mode 120000 index 00000000..2a5d0fab --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.30 @@ -0,0 +1 @@ +../../gcc/12/lib/amd64/libstdc++.so.6.0.30 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.31 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.31 new file mode 120000 index 00000000..b2072d46 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.31 @@ -0,0 +1 @@ +../../gcc/legacy/lib/amd64/libstdc++.so.6.0.31 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.32 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.32 new file mode 120000 index 00000000..ac85e710 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.32 @@ -0,0 +1 @@ +../../gcc/13/lib/amd64/libstdc++.so.6.0.32 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.33 b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.33 new file mode 120000 index 00000000..56799291 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstdc++.so.6.0.33 @@ -0,0 +1 @@ +../../gcc/14/lib/amd64/libstdc++.so.6.0.33 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstmf.so b/illumos-x86_64/usr/lib/amd64/libstmf.so new file mode 120000 index 00000000..9bf47bb0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstmf.so @@ -0,0 +1 @@ +libstmf.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstmf.so.1 b/illumos-x86_64/usr/lib/amd64/libstmf.so.1 new file mode 100755 index 00000000..7e602733 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libstmf.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libstmfproxy.so b/illumos-x86_64/usr/lib/amd64/libstmfproxy.so new file mode 120000 index 00000000..579a0612 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libstmfproxy.so @@ -0,0 +1 @@ +libstmfproxy.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libstmfproxy.so.1 b/illumos-x86_64/usr/lib/amd64/libstmfproxy.so.1 new file mode 100755 index 00000000..1c3a2ddc Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libstmfproxy.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsum.so.1 b/illumos-x86_64/usr/lib/amd64/libsum.so.1 new file mode 100755 index 00000000..2ed48c34 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsum.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsun_fc.so b/illumos-x86_64/usr/lib/amd64/libsun_fc.so new file mode 120000 index 00000000..c534db9e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsun_fc.so @@ -0,0 +1 @@ +libsun_fc.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsun_fc.so.1 b/illumos-x86_64/usr/lib/amd64/libsun_fc.so.1 new file mode 100755 index 00000000..f5e6a5b8 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsun_fc.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsun_ima.so b/illumos-x86_64/usr/lib/amd64/libsun_ima.so new file mode 120000 index 00000000..e6ccff7f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsun_ima.so @@ -0,0 +1 @@ +libsun_ima.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsun_ima.so.1 b/illumos-x86_64/usr/lib/amd64/libsun_ima.so.1 new file mode 100755 index 00000000..c04a1ccc Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libsun_ima.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libsysevent.so b/illumos-x86_64/usr/lib/amd64/libsysevent.so new file mode 120000 index 00000000..fb6e5b35 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsysevent.so @@ -0,0 +1 @@ +../../../lib/amd64/libsysevent.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libsysevent.so.1 b/illumos-x86_64/usr/lib/amd64/libsysevent.so.1 new file mode 120000 index 00000000..fb6e5b35 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libsysevent.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libsysevent.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtddl.a b/illumos-x86_64/usr/lib/amd64/libtddl.a new file mode 100644 index 00000000..049c6bb0 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libtddl.a differ diff --git a/illumos-x86_64/usr/lib/amd64/libtecla.so b/illumos-x86_64/usr/lib/amd64/libtecla.so new file mode 120000 index 00000000..a4ca0f74 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtecla.so @@ -0,0 +1 @@ +libtecla.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtecla.so.1 b/illumos-x86_64/usr/lib/amd64/libtecla.so.1 new file mode 100755 index 00000000..ad54f11a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libtecla.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libtermcap.so b/illumos-x86_64/usr/lib/amd64/libtermcap.so new file mode 120000 index 00000000..cdd85293 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtermcap.so @@ -0,0 +1 @@ +../../../lib/amd64/libtermcap.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtermcap.so.1 b/illumos-x86_64/usr/lib/amd64/libtermcap.so.1 new file mode 120000 index 00000000..cdd85293 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtermcap.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libtermcap.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtermlib.so b/illumos-x86_64/usr/lib/amd64/libtermlib.so new file mode 120000 index 00000000..bcee697f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtermlib.so @@ -0,0 +1 @@ +../../../lib/amd64/libcurses.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtermlib.so.1 b/illumos-x86_64/usr/lib/amd64/libtermlib.so.1 new file mode 120000 index 00000000..bcee697f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtermlib.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libcurses.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libthread.so b/illumos-x86_64/usr/lib/amd64/libthread.so new file mode 120000 index 00000000..3a7b3341 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libthread.so @@ -0,0 +1 @@ +../../../lib/amd64/libthread.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libthread.so.1 b/illumos-x86_64/usr/lib/amd64/libthread.so.1 new file mode 120000 index 00000000..3a7b3341 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libthread.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libthread.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libthread_db.so b/illumos-x86_64/usr/lib/amd64/libthread_db.so new file mode 120000 index 00000000..03e3a2b5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libthread_db.so @@ -0,0 +1 @@ +../../../lib/amd64/libc_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libthread_db.so.1 b/illumos-x86_64/usr/lib/amd64/libthread_db.so.1 new file mode 120000 index 00000000..03e3a2b5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libthread_db.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libc_db.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtsnet.so b/illumos-x86_64/usr/lib/amd64/libtsnet.so new file mode 120000 index 00000000..869ce3c8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtsnet.so @@ -0,0 +1 @@ +../../../lib/amd64/libtsnet.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtsnet.so.1 b/illumos-x86_64/usr/lib/amd64/libtsnet.so.1 new file mode 120000 index 00000000..869ce3c8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtsnet.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libtsnet.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtsol.so b/illumos-x86_64/usr/lib/amd64/libtsol.so new file mode 120000 index 00000000..0423d180 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtsol.so @@ -0,0 +1 @@ +../../../lib/amd64/libtsol.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtsol.so.2 b/illumos-x86_64/usr/lib/amd64/libtsol.so.2 new file mode 120000 index 00000000..0423d180 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtsol.so.2 @@ -0,0 +1 @@ +../../../lib/amd64/libtsol.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtspi.so b/illumos-x86_64/usr/lib/amd64/libtspi.so new file mode 120000 index 00000000..9f6bc323 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtspi.so @@ -0,0 +1 @@ +libtspi.so.1.2.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtspi.so.1 b/illumos-x86_64/usr/lib/amd64/libtspi.so.1 new file mode 120000 index 00000000..9f6bc323 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libtspi.so.1 @@ -0,0 +1 @@ +libtspi.so.1.2.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libtspi.so.1.2.0 b/illumos-x86_64/usr/lib/amd64/libtspi.so.1.2.0 new file mode 100755 index 00000000..b325636b Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libtspi.so.1.2.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libumem.so b/illumos-x86_64/usr/lib/amd64/libumem.so new file mode 120000 index 00000000..77748290 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libumem.so @@ -0,0 +1 @@ +../../../lib/amd64/libumem.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libumem.so.1 b/illumos-x86_64/usr/lib/amd64/libumem.so.1 new file mode 120000 index 00000000..77748290 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libumem.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libumem.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libutempter.so b/illumos-x86_64/usr/lib/amd64/libutempter.so new file mode 120000 index 00000000..6e84f60b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libutempter.so @@ -0,0 +1 @@ +libutempter.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libutempter.so.1 b/illumos-x86_64/usr/lib/amd64/libutempter.so.1 new file mode 100755 index 00000000..df7c7648 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libutempter.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libuuid.so b/illumos-x86_64/usr/lib/amd64/libuuid.so new file mode 120000 index 00000000..83bea5ec --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libuuid.so @@ -0,0 +1 @@ +../../../lib/amd64/libuuid.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libuuid.so.1 b/illumos-x86_64/usr/lib/amd64/libuuid.so.1 new file mode 120000 index 00000000..83bea5ec --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libuuid.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libuuid.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libuutil.so b/illumos-x86_64/usr/lib/amd64/libuutil.so new file mode 120000 index 00000000..31c78b21 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libuutil.so @@ -0,0 +1 @@ +../../../lib/amd64/libuutil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libuutil.so.1 b/illumos-x86_64/usr/lib/amd64/libuutil.so.1 new file mode 120000 index 00000000..31c78b21 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libuutil.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libuutil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libvolmgt.so b/illumos-x86_64/usr/lib/amd64/libvolmgt.so new file mode 120000 index 00000000..61fa85af --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libvolmgt.so @@ -0,0 +1 @@ +libvolmgt.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libvolmgt.so.1 b/illumos-x86_64/usr/lib/amd64/libvolmgt.so.1 new file mode 100755 index 00000000..dd656a6d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libvolmgt.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libw.so b/illumos-x86_64/usr/lib/amd64/libw.so new file mode 120000 index 00000000..b114c867 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libw.so @@ -0,0 +1 @@ +../../../lib/amd64/libw.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libw.so.1 b/illumos-x86_64/usr/lib/amd64/libw.so.1 new file mode 120000 index 00000000..b114c867 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libw.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libw.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libwget.so b/illumos-x86_64/usr/lib/amd64/libwget.so new file mode 120000 index 00000000..8eaf434f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libwget.so @@ -0,0 +1 @@ +libwget.so.3.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libwget.so.3 b/illumos-x86_64/usr/lib/amd64/libwget.so.3 new file mode 120000 index 00000000..8eaf434f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libwget.so.3 @@ -0,0 +1 @@ +libwget.so.3.0.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libwget.so.3.0.0 b/illumos-x86_64/usr/lib/amd64/libwget.so.3.0.0 new file mode 100755 index 00000000..88f4f3d9 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libwget.so.3.0.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libwrap.so b/illumos-x86_64/usr/lib/amd64/libwrap.so new file mode 120000 index 00000000..c1f71ab6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libwrap.so @@ -0,0 +1 @@ +libwrap.so.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libwrap.so.1 b/illumos-x86_64/usr/lib/amd64/libwrap.so.1 new file mode 120000 index 00000000..c1f71ab6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libwrap.so.1 @@ -0,0 +1 @@ +libwrap.so.1.0 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libwrap.so.1.0 b/illumos-x86_64/usr/lib/amd64/libwrap.so.1.0 new file mode 100755 index 00000000..6c9386d7 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libwrap.so.1.0 differ diff --git a/illumos-x86_64/usr/lib/amd64/libxml2.so b/illumos-x86_64/usr/lib/amd64/libxml2.so new file mode 120000 index 00000000..8510fdcb --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libxml2.so @@ -0,0 +1 @@ +libxml2.so.16.0.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libxml2.so.16 b/illumos-x86_64/usr/lib/amd64/libxml2.so.16 new file mode 120000 index 00000000..8510fdcb --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libxml2.so.16 @@ -0,0 +1 @@ +libxml2.so.16.0.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libxml2.so.16.0.6 b/illumos-x86_64/usr/lib/amd64/libxml2.so.16.0.6 new file mode 120000 index 00000000..990bc190 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libxml2.so.16.0.6 @@ -0,0 +1 @@ +../../../lib/amd64/libxml2.so.16.0.6 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libxml2.so.2 b/illumos-x86_64/usr/lib/amd64/libxml2.so.2 new file mode 120000 index 00000000..227da14b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libxml2.so.2 @@ -0,0 +1 @@ +libxml2.so.2.13.8 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libxml2.so.2.13.8 b/illumos-x86_64/usr/lib/amd64/libxml2.so.2.13.8 new file mode 120000 index 00000000..983d3c9b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libxml2.so.2.13.8 @@ -0,0 +1 @@ +../../../lib/amd64/libxml2.so.2.13.8 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libxnet.so b/illumos-x86_64/usr/lib/amd64/libxnet.so new file mode 120000 index 00000000..49bc5f33 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libxnet.so @@ -0,0 +1 @@ +../../../lib/amd64/libxnet.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libxnet.so.1 b/illumos-x86_64/usr/lib/amd64/libxnet.so.1 new file mode 120000 index 00000000..49bc5f33 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libxnet.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libxnet.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liby.so b/illumos-x86_64/usr/lib/amd64/liby.so new file mode 120000 index 00000000..dd7c27f9 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/liby.so @@ -0,0 +1 @@ +liby.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/liby.so.1 b/illumos-x86_64/usr/lib/amd64/liby.so.1 new file mode 100755 index 00000000..ca178644 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/liby.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libz.so b/illumos-x86_64/usr/lib/amd64/libz.so new file mode 120000 index 00000000..1468e125 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libz.so @@ -0,0 +1 @@ +libz.so.1.3.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libz.so.1 b/illumos-x86_64/usr/lib/amd64/libz.so.1 new file mode 120000 index 00000000..1468e125 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libz.so.1 @@ -0,0 +1 @@ +libz.so.1.3.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libz.so.1.3.1 b/illumos-x86_64/usr/lib/amd64/libz.so.1.3.1 new file mode 120000 index 00000000..4378e201 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libz.so.1.3.1 @@ -0,0 +1 @@ +../../../lib/amd64/libz.so.1.3.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzfs.so b/illumos-x86_64/usr/lib/amd64/libzfs.so new file mode 120000 index 00000000..df764815 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzfs.so @@ -0,0 +1 @@ +../../../lib/amd64/libzfs.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzfs.so.1 b/illumos-x86_64/usr/lib/amd64/libzfs.so.1 new file mode 120000 index 00000000..df764815 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzfs.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libzfs.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzfs_core.so b/illumos-x86_64/usr/lib/amd64/libzfs_core.so new file mode 120000 index 00000000..e5997118 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzfs_core.so @@ -0,0 +1 @@ +../../../lib/amd64/libzfs_core.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzfs_core.so.1 b/illumos-x86_64/usr/lib/amd64/libzfs_core.so.1 new file mode 120000 index 00000000..e5997118 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzfs_core.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libzfs_core.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzfs_jni.so b/illumos-x86_64/usr/lib/amd64/libzfs_jni.so new file mode 120000 index 00000000..fe6443e8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzfs_jni.so @@ -0,0 +1 @@ +libzfs_jni.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzfs_jni.so.1 b/illumos-x86_64/usr/lib/amd64/libzfs_jni.so.1 new file mode 100755 index 00000000..d82954f3 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libzfs_jni.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libzfsbootenv.so b/illumos-x86_64/usr/lib/amd64/libzfsbootenv.so new file mode 120000 index 00000000..c80cd03b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzfsbootenv.so @@ -0,0 +1 @@ +libzfsbootenv.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzfsbootenv.so.1 b/illumos-x86_64/usr/lib/amd64/libzfsbootenv.so.1 new file mode 100755 index 00000000..96f51e51 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libzfsbootenv.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libzonecfg.so.1 b/illumos-x86_64/usr/lib/amd64/libzonecfg.so.1 new file mode 100755 index 00000000..5a7d9e8b Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libzonecfg.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libzoneinfo.so b/illumos-x86_64/usr/lib/amd64/libzoneinfo.so new file mode 120000 index 00000000..b1bc009d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzoneinfo.so @@ -0,0 +1 @@ +./libzoneinfo.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzoneinfo.so.1 b/illumos-x86_64/usr/lib/amd64/libzoneinfo.so.1 new file mode 100755 index 00000000..9c646676 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libzoneinfo.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libzonestat.so.1 b/illumos-x86_64/usr/lib/amd64/libzonestat.so.1 new file mode 100755 index 00000000..787427d2 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libzonestat.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libzpool.so b/illumos-x86_64/usr/lib/amd64/libzpool.so new file mode 120000 index 00000000..7f21acd0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzpool.so @@ -0,0 +1 @@ +libzpool.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzpool.so.1 b/illumos-x86_64/usr/lib/amd64/libzpool.so.1 new file mode 100755 index 00000000..c43b40e3 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libzpool.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/libzstd.so b/illumos-x86_64/usr/lib/amd64/libzstd.so new file mode 120000 index 00000000..b85cb1a0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzstd.so @@ -0,0 +1 @@ +libzstd.so.1.5.7 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzstd.so.1 b/illumos-x86_64/usr/lib/amd64/libzstd.so.1 new file mode 120000 index 00000000..b85cb1a0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzstd.so.1 @@ -0,0 +1 @@ +libzstd.so.1.5.7 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzstd.so.1.5.7 b/illumos-x86_64/usr/lib/amd64/libzstd.so.1.5.7 new file mode 100755 index 00000000..72885e6b Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/libzstd.so.1.5.7 differ diff --git a/illumos-x86_64/usr/lib/amd64/libzutil.so b/illumos-x86_64/usr/lib/amd64/libzutil.so new file mode 120000 index 00000000..823b4f02 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzutil.so @@ -0,0 +1 @@ +../../../lib/amd64/libzutil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/libzutil.so.1 b/illumos-x86_64/usr/lib/amd64/libzutil.so.1 new file mode 120000 index 00000000..823b4f02 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/libzutil.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/libzutil.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/madv.so.1 b/illumos-x86_64/usr/lib/amd64/madv.so.1 new file mode 100755 index 00000000..4f14808a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/madv.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/mpss.so.1 b/illumos-x86_64/usr/lib/amd64/mpss.so.1 new file mode 100755 index 00000000..9bbdcdff Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/mpss.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/nss_ad.so.1 b/illumos-x86_64/usr/lib/amd64/nss_ad.so.1 new file mode 100755 index 00000000..c7e22ff7 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/nss_ad.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/nss_compat.so.1 b/illumos-x86_64/usr/lib/amd64/nss_compat.so.1 new file mode 120000 index 00000000..fe3383b7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/nss_compat.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/nss_compat.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/nss_dns.so.1 b/illumos-x86_64/usr/lib/amd64/nss_dns.so.1 new file mode 120000 index 00000000..dccb596d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/nss_dns.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/nss_dns.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/nss_files.so.1 b/illumos-x86_64/usr/lib/amd64/nss_files.so.1 new file mode 120000 index 00000000..9bdb136d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/nss_files.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/nss_files.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/nss_ldap.so.1 b/illumos-x86_64/usr/lib/amd64/nss_ldap.so.1 new file mode 100755 index 00000000..c40fc143 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/nss_ldap.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/nss_mdns.so.1 b/illumos-x86_64/usr/lib/amd64/nss_mdns.so.1 new file mode 100755 index 00000000..abda3310 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/nss_mdns.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/nss_nis.so.1 b/illumos-x86_64/usr/lib/amd64/nss_nis.so.1 new file mode 120000 index 00000000..1160023b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/nss_nis.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/nss_nis.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/nss_user.so.1 b/illumos-x86_64/usr/lib/amd64/nss_user.so.1 new file mode 120000 index 00000000..a51dcd60 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/nss_user.so.1 @@ -0,0 +1 @@ +../../../lib/amd64/nss_user.so.1 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/ossl-modules/legacy.so b/illumos-x86_64/usr/lib/amd64/ossl-modules/legacy.so new file mode 100755 index 00000000..26c1e269 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/ossl-modules/legacy.so differ diff --git a/illumos-x86_64/usr/lib/amd64/passwdutil.so.1 b/illumos-x86_64/usr/lib/amd64/passwdutil.so.1 new file mode 100755 index 00000000..38e1cf25 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/passwdutil.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/dbus-1.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/dbus-1.pc new file mode 100644 index 00000000..62de59c8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/dbus-1.pc @@ -0,0 +1,22 @@ +prefix=/usr +includedir=${prefix}/include +libdir=${prefix}/lib/amd64 + +original_prefix=/usr +exec_prefix=${prefix} +bindir=${prefix}/bin +datadir=${prefix}/share +datarootdir=${prefix}/share +sysconfdir=/etc +daemondir=${bindir} +system_bus_default_address=unix:path=/var/run/dbus/system_bus_socket +session_bus_services_dir=${datadir}/dbus-1/services +system_bus_services_dir=${datadir}/dbus-1/system-services +interfaces_dir=${datadir}/dbus-1/interfaces + +Name: dbus +Description: Free desktop message bus +Version: 1.16.2 +Libs: -L${libdir} -ldbus-1 +Libs.private: -lbsm +Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/dbus-glib-1.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/dbus-glib-1.pc new file mode 100644 index 00000000..3f129697 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/dbus-glib-1.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: dbus-glib +Description: GLib integration for the free desktop message bus +Version: 0.114 +Requires: dbus-1 glib-2.0 gobject-2.0 +Libs: -L${libdir} -ldbus-glib-1 +Cflags: -I${includedir}/dbus-1.0 + + diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/expat.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/expat.pc new file mode 100644 index 00000000..b8a4dde1 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/expat.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: expat +Version: 2.7.2 +Description: expat XML parser +URL: https://libexpat.github.io/ +Libs: -L${libdir} -lexpat +Libs.private: +Cflags: -I${includedir} +Cflags.private: -DXML_STATIC diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/form.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/form.pc new file mode 100644 index 00000000..e0be6a22 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/form.pc @@ -0,0 +1,19 @@ +# pkg-config file generated by gen-pkgconfig +# vile:makemode + +prefix=/usr/gnu +exec_prefix=${prefix} +libdir=/usr/gnu/lib/amd64 +includedir=/usr/include/ncurses +abi_version=6 +major_version=6 +version=6.5.20240511 + +Name: form +Description: ncurses 6.5 add-on library +Version: ${version} +URL: https://invisible-island.net/ncurses +Requires.private: ncurses +Libs: -L/usr/gnu/lib/amd64 -Wl,-R/usr/gnu/lib/amd64 -m64 -lform +Libs.private: +Cflags: -D__EXTENSIONS__ -DNCURSES_WIDECHAR -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gio-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gio-2.0.pc new file mode 100644 index 00000000..c9d28788 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gio-2.0.pc @@ -0,0 +1,26 @@ +prefix=/usr +bindir=${prefix}/bin +datadir=${prefix}/share +includedir=${prefix}/include +libdir=${prefix}/lib/amd64 + +schemasdir=${datadir}/glib-2.0/schemas +dtdsdir=${datadir}/glib-2.0/dtds +giomoduledir=${libdir}/gio/modules +gio=${bindir}/gio +gio_querymodules=${bindir}/gio-querymodules +glib_compile_schemas=${bindir}/glib-compile-schemas +glib_compile_resources=${bindir}/glib-compile-resources +gdbus=${bindir}/gdbus +gdbus_codegen=${bindir}/gdbus-codegen +gresource=${bindir}/gresource +gsettings=${bindir}/gsettings + +Name: GIO +Description: glib I/O library +Version: 2.84.4 +Requires: glib-2.0, gobject-2.0 +Requires.private: gmodule-no-export-2.0, zlib +Libs: -L${libdir} -lgio-2.0 +Libs.private: -lresolv -lsocket +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gio-unix-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gio-unix-2.0.pc new file mode 100644 index 00000000..1b3b830b --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gio-unix-2.0.pc @@ -0,0 +1,8 @@ +prefix=/usr +includedir=${prefix}/include + +Name: GIO unix specific APIs +Description: unix specific headers for glib I/O library +Version: 2.84.4 +Requires: gobject-2.0, gio-2.0 +Cflags: -I${includedir}/gio-unix-2.0 diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/girepository-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/girepository-2.0.pc new file mode 100644 index 00000000..a422eaed --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/girepository-2.0.pc @@ -0,0 +1,19 @@ +prefix=/usr +bindir=${prefix}/bin +datadir=${prefix}/share +includedir=${prefix}/include +libdir=${prefix}/lib/amd64 + +gidatadir=${datadir}/gobject-introspection-1.0 +girdir=${datadir}/gir-1.0 +typelibdir=${libdir}/girepository-1.0 +gi_compile_repository=${bindir}/gi-compile-repository + +Name: girepository +Description: GObject Introspection repository parser +Version: 2.84.4 +Requires: glib-2.0, gobject-2.0 +Requires.private: gmodule-no-export-2.0, gio-2.0, libffi >= 3.0.0 +Libs: -L${libdir} -lgirepository-2.0 +Libs.private: -lm +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/glib-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/glib-2.0.pc new file mode 100644 index 00000000..e68580e6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/glib-2.0.pc @@ -0,0 +1,18 @@ +prefix=/usr +bindir=${prefix}/bin +datadir=${prefix}/share +includedir=${prefix}/include +libdir=${prefix}/lib/amd64 + +glib_genmarshal=${bindir}/glib-genmarshal +gobject_query=${bindir}/gobject-query +glib_mkenums=${bindir}/glib-mkenums +glib_valgrind_suppressions=${datadir}/glib-2.0/valgrind/glib.supp + +Name: GLib +Description: C Utility Library +Version: 2.84.4 +Requires.private: libpcre2-8 >= 10.32 +Libs: -L${libdir} -lglib-2.0 +Libs.private: -latomic -lm +Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-2.0.pc new file mode 100644 index 00000000..85b24748 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-2.0.pc @@ -0,0 +1,10 @@ +prefix=/usr +includedir=${prefix}/include + +gmodule_supported=true + +Name: GModule +Description: Dynamic module loader for GLib +Version: 2.84.4 +Requires: gmodule-no-export-2.0, glib-2.0 +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-export-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-export-2.0.pc new file mode 100644 index 00000000..85b24748 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-export-2.0.pc @@ -0,0 +1,10 @@ +prefix=/usr +includedir=${prefix}/include + +gmodule_supported=true + +Name: GModule +Description: Dynamic module loader for GLib +Version: 2.84.4 +Requires: gmodule-no-export-2.0, glib-2.0 +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-no-export-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-no-export-2.0.pc new file mode 100644 index 00000000..eec6c568 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmodule-no-export-2.0.pc @@ -0,0 +1,12 @@ +prefix=/usr +includedir=${prefix}/include +libdir=${prefix}/lib/amd64 + +gmodule_supported=true + +Name: GModule +Description: Dynamic module loader for GLib +Version: 2.84.4 +Requires: glib-2.0 +Libs: -L${libdir} -lgmodule-2.0 +Cflags: -I${includedir} -pthread diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gmp.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmp.pc new file mode 100644 index 00000000..b7789d65 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmp.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +includedir=/usr/include/gmp +libdir=/usr/lib/amd64 + +Name: GNU MP +Description: GNU Multiple Precision Arithmetic Library +URL: https://gmplib.org +Version: 6.3.0 +Cflags: -I${includedir} +Libs: -L${libdir} -lgmp diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gmpxx.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmpxx.pc new file mode 100644 index 00000000..2354f693 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gmpxx.pc @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} +includedir=/usr/include/gmp +libdir=/usr/lib/amd64 + +Name: GNU MP C++ +Description: GNU Multiple Precision Arithmetic Library (C++ bindings) +URL: https://gmplib.org +Version: 6.3.0 +Requires: gmp +Cflags: -I${includedir} +Libs: -L${libdir} -lgmpxx diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gobject-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gobject-2.0.pc new file mode 100644 index 00000000..c2073f79 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gobject-2.0.pc @@ -0,0 +1,11 @@ +prefix=/usr +includedir=${prefix}/include +libdir=${prefix}/lib/amd64 + +Name: GObject +Description: GLib Type, Object, Parameter and Signal Library +Version: 2.84.4 +Requires: glib-2.0 +Requires.private: libffi >= 3.0.0 +Libs: -L${libdir} -lgobject-2.0 +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/gthread-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/gthread-2.0.pc new file mode 100644 index 00000000..25c7092d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/gthread-2.0.pc @@ -0,0 +1,10 @@ +prefix=/usr +includedir=${prefix}/include +libdir=${prefix}/lib/amd64 + +Name: GThread +Description: Thread support for GLib +Version: 2.84.4 +Requires: glib-2.0 +Libs: -L${libdir} -lgthread-2.0 +Cflags: -I${includedir} -pthread diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/hal-storage.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/hal-storage.pc new file mode 100644 index 00000000..afd46a28 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/hal-storage.pc @@ -0,0 +1,18 @@ +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# Licensed under the Academic Free License version 2.1 +# + +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib/amd64 +includedir=${prefix}/include + +Name: hal-storage +Description: hal library for storage devices and volumes +Version: 0.5.8 +Requires: dbus-1 hal +Libs: -L${libdir} -lhal-storage +Cflags: -DDBUS_API_SUBJECT_TO_CHANGE -I${includedir}/hal diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/hal.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/hal.pc new file mode 100644 index 00000000..277d8291 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/hal.pc @@ -0,0 +1,18 @@ +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# Licensed under the Academic Free License version 2.1 +# + +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib/amd64 +includedir=${prefix}/include + +Name: hal +Description: Free desktop hardware abstraction layer +Version: 0.5.8 +Requires: dbus-1 +Libs: -L${libdir} -lhal +Cflags: -DDBUS_API_SUBJECT_TO_CHANGE -I${includedir}/hal diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/history.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/history.pc new file mode 100644 index 00000000..adc52c59 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/history.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: History +Description: Gnu History library for managing previously-entered lines +URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html +Version: 8.3 +Libs: -L${libdir} -lhistory +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlicommon.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlicommon.pc new file mode 100644 index 00000000..b9a019ea --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlicommon.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=/usr +libdir=${prefix}/lib/amd64 +includedir=${prefix}/include + +Name: libbrotlicommon +URL: https://github.com/google/brotli +Description: Brotli common dictionary library +Version: 1.1.0 +Libs: -L${libdir} -lbrotlicommon +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlidec.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlidec.pc new file mode 100644 index 00000000..cfdde481 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlidec.pc @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=/usr +libdir=${prefix}/lib/amd64 +includedir=${prefix}/include + +Name: libbrotlidec +URL: https://github.com/google/brotli +Description: Brotli decoder library +Version: 1.1.0 +Libs: -L${libdir} -lbrotlidec +Requires.private: libbrotlicommon >= 1.1.0 +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlienc.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlienc.pc new file mode 100644 index 00000000..7fb150a9 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libbrotlienc.pc @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=/usr +libdir=${prefix}/lib/amd64 +includedir=${prefix}/include + +Name: libbrotlienc +URL: https://github.com/google/brotli +Description: Brotli encoder library +Version: 1.1.0 +Libs: -L${libdir} -lbrotlienc +Requires.private: libbrotlicommon >= 1.1.0 +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libcrypto.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libcrypto.pc new file mode 120000 index 00000000..fe7a97fb --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libcrypto.pc @@ -0,0 +1 @@ +../../../../usr/ssl-3/lib/amd64/pkgconfig/libcrypto.pc \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libcurl.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libcurl.pc new file mode 100644 index 00000000..b93e2b44 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libcurl.pc @@ -0,0 +1,41 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at https://curl.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +# SPDX-License-Identifier: curl +# +########################################################################### + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include +supported_protocols="DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS IPFS IPNS LDAP LDAPS MQTT POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP WS WSS" +supported_features="alt-svc AsynchDNS brotli HSTS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets zstd" + +Name: libcurl +URL: https://curl.se/ +Description: Library to transfer files with HTTP, FTP, etc. +Version: 8.18.0 +Requires: +Requires.private: zlib,libbrotlidec,libbrotlicommon,libzstd,openssl,libpsl,libnghttp2 +Libs: -L${libdir} -lcurl +Libs.private: -L/usr -L/usr/lib/amd64 -L/usr/lib/amd64 -lnghttp2 -lldap -lpsl -lssl -lcrypto -lssl -lcrypto -lzstd -lbrotlidec -lz -lsocket -lnsl +Cflags: -I${includedir} +Cflags.private: -DCURL_STATICLIB diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libedit.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libedit.pc new file mode 100644 index 00000000..840dcc80 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libedit.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libedit +Description: command line editor library provides generic line editing, history, and tokenization functions. +Version: 3.1 +Requires: +Libs: -L${libdir} -ledit +Libs.private: -lncurses +Cflags: -I${includedir} -I${includedir}/editline + diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libffi.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libffi.pc new file mode 100644 index 00000000..8139be7d --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libffi.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +toolexeclibdir=${libdir} +includedir=/usr/include + +Name: libffi +Description: Library supporting Foreign Function Interfaces +Version: 3.4.5 +Libs: -L${toolexeclibdir} -lffi +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libidn.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libidn.pc new file mode 100644 index 00000000..1493501a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libidn.pc @@ -0,0 +1,23 @@ +# Process this file with autoconf to produce a pkg-config metadata file. +# Copyright 2002-2025 Simon Josefsson +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This file is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: Libidn +Description: IETF stringprep, nameprep, punycode, IDNA text processing. +URL: https://www.gnu.org/software/libidn/ +Version: 1.43 +Libs: -L${libdir} -lidn +Libs.private: +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/liblz4.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/liblz4.pc new file mode 100644 index 00000000..e5a70809 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/liblz4.pc @@ -0,0 +1,14 @@ +# LZ4 - Fast LZ compression algorithm +# Copyright (C) 2011-2020, Yann Collet. +# BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + +prefix=/usr/local +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: lz4 +Description: extremely fast lossless compression algorithm library +URL: http://www.lz4.org/ +Version: 1.10.0 +Libs: -L${libdir} -llz4 +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/liblzma.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/liblzma.pc new file mode 100644 index 00000000..620ec13e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/liblzma.pc @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: 0BSD +# Author: Lasse Collin + +prefix=/usr +exec_prefix=/usr +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: liblzma +Description: General purpose data compression library +URL: https://tukaani.org/xz/ +Version: 5.8.1 +Cflags: -I${includedir} +Cflags.private: -DLZMA_API_STATIC +Libs: -L${libdir} -llzma +Libs.private: -D_POSIX_PTHREAD_SEMANTICS -pthread -pthread diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libnghttp2.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libnghttp2.pc new file mode 100644 index 00000000..d9191c64 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libnghttp2.pc @@ -0,0 +1,33 @@ +# nghttp2 - HTTP/2 C Library + +# Copyright (c) 2012, 2013 Tatsuhiro Tsujikawa + +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libnghttp2 +Description: HTTP/2 C library +URL: https://github.com/tatsuhiro-t/nghttp2 +Version: 1.67.1 +Libs: -L${libdir} -lnghttp2 +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcap.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcap.pc new file mode 100644 index 00000000..bb19a6d5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcap.pc @@ -0,0 +1,19 @@ +# +# pkg-config file for libpcap. +# +# These variables come from the configure script, so includedir and +# libdir may be defined in terms of prefix and exec_prefix, so the +# latter must be defined as well. +# +prefix="/usr" +exec_prefix="${prefix}" +includedir="/usr/include" +libdir="/usr/lib/amd64" + +Name: libpcap +Description: Platform-independent network traffic capture library +Version: 1.10.5 +Requires.private: dbus-1 +Libs: -L${libdir} -lpcap +Libs.private: -ldlpi +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre.pc new file mode 100644 index 00000000..40c90156 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libpcre +Description: PCRE - Perl compatible regular expressions C library with 8 bit character support +Version: 8.45 +Libs: -L${libdir} -lpcre +Libs.private: +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-16.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-16.pc new file mode 100644 index 00000000..57a3ed39 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-16.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libpcre2-16 +Description: PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support +Version: 10.46 +Libs: -L${libdir} -lpcre2-16 +Libs.private: -D_REENTRANT -pthreads +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-32.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-32.pc new file mode 100644 index 00000000..eaf63bd7 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-32.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libpcre2-32 +Description: PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support +Version: 10.46 +Libs: -L${libdir} -lpcre2-32 +Libs.private: -D_REENTRANT -pthreads +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-8.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-8.pc new file mode 100644 index 00000000..2a3a0402 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-8.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libpcre2-8 +Description: PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support +Version: 10.46 +Libs: -L${libdir} -lpcre2-8 +Libs.private: -D_REENTRANT -pthreads +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-posix.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-posix.pc new file mode 100644 index 00000000..b02b46d5 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcre2-posix.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libpcre2-posix +Description: Posix compatible interface to libpcre2-8 +Version: 10.46 +Libs: -L${libdir} -lpcre2-posix +Cflags: -I${includedir} -DPCRE2POSIX_SHARED +Requires.private: libpcre2-8 diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcrecpp.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcrecpp.pc new file mode 100644 index 00000000..b6bbc730 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcrecpp.pc @@ -0,0 +1,12 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libpcrecpp +Description: PCRECPP - C++ wrapper for PCRE +Version: 8.45 +Libs: -L${libdir} -lpcre -lpcrecpp +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcreposix.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcreposix.pc new file mode 100644 index 00000000..d7203c8f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpcreposix.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libpcreposix +Description: PCREPosix - Posix compatible interface to libpcre +Version: 8.45 +Libs: -L${libdir} -lpcreposix +Cflags: -I${includedir} +Requires.private: libpcre diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libpsl.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpsl.pc new file mode 100644 index 00000000..a22304bc --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libpsl.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libpsl +Description: Public Suffix List C library. +Version: 0.21.5 +URL: https://github.com/rockdaboot/libpsl +Libs: -L${libdir} -lpsl +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libssl.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libssl.pc new file mode 120000 index 00000000..a75c5216 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libssl.pc @@ -0,0 +1 @@ +../../../../usr/ssl-3/lib/amd64/pkgconfig/libssl.pc \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libwget.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libwget.pc new file mode 100644 index 00000000..7952e6f8 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libwget.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: libwget +Description: Wget downloader C library. +Version: 2.2.0 +URL: https://savannah.gnu.org/projects/wget +Libs: -L${libdir} -lwget +Cflags: -I${includedir}/libwget -I${libdir}/libwget/include diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libxml-2.0.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libxml-2.0.pc new file mode 100644 index 00000000..ef21a67e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libxml-2.0.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include +modules=1 + +Name: libXML +Version: 2.14.6 +Description: libXML library version2. +Requires.private: +Libs: -L${libdir} -R/usr/lib/amd64 -lxml2 +Libs.private: -lm +Cflags: -I${includedir}/libxml2 diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/libzstd.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/libzstd.pc new file mode 100644 index 00000000..139bd336 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/libzstd.pc @@ -0,0 +1,16 @@ +# ZSTD - standard compression algorithm +# Copyright (c) Meta Platforms, Inc. and affiliates. +# BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php) + +prefix=/usr +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib/amd64 + +Name: zstd +Description: fast lossless compression algorithm library +URL: https://facebook.github.io/zstd/ +Version: 1.5.7 +Libs: -L${libdir} -lzstd +Libs.private: -pthread +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/menu.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/menu.pc new file mode 100644 index 00000000..fcf751ce --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/menu.pc @@ -0,0 +1,19 @@ +# pkg-config file generated by gen-pkgconfig +# vile:makemode + +prefix=/usr/gnu +exec_prefix=${prefix} +libdir=/usr/gnu/lib/amd64 +includedir=/usr/include/ncurses +abi_version=6 +major_version=6 +version=6.5.20240511 + +Name: menu +Description: ncurses 6.5 add-on library +Version: ${version} +URL: https://invisible-island.net/ncurses +Requires.private: ncurses +Libs: -L/usr/gnu/lib/amd64 -Wl,-R/usr/gnu/lib/amd64 -m64 -lmenu +Libs.private: +Cflags: -D__EXTENSIONS__ -DNCURSES_WIDECHAR -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/mpfr.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/mpfr.pc new file mode 100644 index 00000000..1761a0ce --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/mpfr.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: mpfr +URL: https://www.mpfr.org/ +Description: C library for multiple-precision floating-point computations +Version: 4.2.2 +Libs: -L${libdir} -lmpfr -lgmp +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/ncurses++.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/ncurses++.pc new file mode 100644 index 00000000..948458c6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/ncurses++.pc @@ -0,0 +1,19 @@ +# pkg-config file generated by gen-pkgconfig +# vile:makemode + +prefix=/usr/gnu +exec_prefix=${prefix} +libdir=/usr/gnu/lib/amd64 +includedir=/usr/include/ncurses +abi_version=6 +major_version=6 +version=6.5.20240511 + +Name: ncurses++ +Description: ncurses 6.5 add-on library +Version: ${version} +URL: https://invisible-island.net/ncurses +Requires.private: panel, menu, form, ncurses +Libs: -L/usr/gnu/lib/amd64 -Wl,-R/usr/gnu/lib/amd64 -m64 -lncurses++ +Libs.private: +Cflags: -D__EXTENSIONS__ -DNCURSES_WIDECHAR -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/ncurses.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/ncurses.pc new file mode 100644 index 00000000..997d7af9 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/ncurses.pc @@ -0,0 +1,19 @@ +# pkg-config file generated by gen-pkgconfig +# vile:makemode + +prefix=/usr/gnu +exec_prefix=${prefix} +libdir=/usr/gnu/lib/amd64 +includedir=/usr/include/ncurses +abi_version=6 +major_version=6 +version=6.5.20240511 + +Name: ncurses +Description: ncurses 6.5 library +Version: ${version} +URL: https://invisible-island.net/ncurses +Requires.private: +Libs: -L/usr/gnu/lib/amd64 -Wl,-R/usr/gnu/lib/amd64 -m64 -lncurses +Libs.private: +Cflags: -D__EXTENSIONS__ -DNCURSES_WIDECHAR -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/netsnmp-agent.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/netsnmp-agent.pc new file mode 100644 index 00000000..2e7922c6 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/netsnmp-agent.pc @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} +includedir=/usr/include +libdir=/usr/lib/amd64 + +Name: netsnmp-agent (Net-SNMP) +Description: SNMP (Simple Network Management Protocol) sub-agent SDK. +URL: http://www.net-snmp.org +Version: 5.9.4.pre2 +Cflags: -I${includedir} +Libs: -L${libdir} -lnetsnmpmibs -lnetsnmpagent -lnetsnmp +Libs.private: -L/usr/ssl/lib -m64 -lm -ladm -lpcre -lpcre -lkvm -lm -lkstat -lsocket -lssl -L/usr -lssl -lcrypto -lnsl -lsocket -lelf diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/netsnmp.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/netsnmp.pc new file mode 100644 index 00000000..9466663e --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/netsnmp.pc @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} +includedir=/usr/include +libdir=/usr/lib/amd64 + +Name: netsnmp (Net-SNMP) +Description: SNMP (Simple Network Management Protocol) daemon and applications. +URL: http://www.net-snmp.org +Version: 5.9.4.pre2 +Cflags: -I${includedir} +Libs: -L${libdir} -lnetsnmp +Libs.private: -L/usr/ssl/lib -m64 -lm -lkstat -lsocket -lssl -L/usr -lssl -lcrypto -lnsl -lsocket -lelf diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/nspr.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/nspr.pc new file mode 100644 index 00000000..5cde87c0 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/nspr.pc @@ -0,0 +1,10 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/mps/amd64 +includedir=/usr/include/mps + +Name: NSPR +Description: The Netscape Portable Runtime +Version: 4.37.0 +Libs: -L/usr/lib/mps/amd64 -R/usr/lib/mps/amd64 -lplds4 -lplc4 -lnspr4 +Cflags: -I/usr/include/mps diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/nss.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/nss.pc new file mode 100644 index 00000000..0720d48a --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/nss.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=/usr +libdir=/usr/lib/mps/amd64 +includedir=/usr/include/mps + +Name: NSS +Description: Network Security Services +Version: 3.116 +Requires: nspr >= 4.37 +Libs: -L${libdir} -lssl3 -lsmime3 -lnss3 -lnssutil3 +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/openssl.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/openssl.pc new file mode 120000 index 00000000..d9dd15db --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/openssl.pc @@ -0,0 +1 @@ +../../../../usr/ssl-3/lib/amd64/pkgconfig/openssl.pc \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/panel.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/panel.pc new file mode 100644 index 00000000..6d4aa715 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/panel.pc @@ -0,0 +1,19 @@ +# pkg-config file generated by gen-pkgconfig +# vile:makemode + +prefix=/usr/gnu +exec_prefix=${prefix} +libdir=/usr/gnu/lib/amd64 +includedir=/usr/include/ncurses +abi_version=6 +major_version=6 +version=6.5.20240511 + +Name: panel +Description: ncurses 6.5 add-on library +Version: ${version} +URL: https://invisible-island.net/ncurses +Requires.private: ncurses +Libs: -L/usr/gnu/lib/amd64 -Wl,-R/usr/gnu/lib/amd64 -m64 -lpanel +Libs.private: +Cflags: -D__EXTENSIONS__ -DNCURSES_WIDECHAR -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/python-3.13-embed.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/python-3.13-embed.pc new file mode 100644 index 00000000..d63a0658 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/python-3.13-embed.pc @@ -0,0 +1,13 @@ +# See: man pkg-config +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: Python +Description: Embed Python into an application +Requires: +Version: 3.13 +Libs.private: -lsocket -lnsl -lintl -ldl -lsendfile +Libs: -L${libdir} -lpython3.13 +Cflags: -I${includedir}/python3.13 diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/python-3.13.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/python-3.13.pc new file mode 100644 index 00000000..7da9c439 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/python-3.13.pc @@ -0,0 +1,13 @@ +# See: man pkg-config +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: Python +Description: Build a C extension for Python +Requires: +Version: 3.13 +Libs.private: -lsocket -lnsl -lintl -ldl -lsendfile +Libs: -L${libdir} +Cflags: -I${includedir}/python3.13 diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/python3-embed.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/python3-embed.pc new file mode 120000 index 00000000..b935c38c --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/python3-embed.pc @@ -0,0 +1 @@ +python-3.13-embed.pc \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/python3.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/python3.pc new file mode 120000 index 00000000..1c22bf9f --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/python3.pc @@ -0,0 +1 @@ +python-3.13.pc \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/readline.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/readline.pc new file mode 100644 index 00000000..dbebb8d1 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/readline.pc @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: Readline +Description: Gnu Readline library for command line editing +URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html +Version: 8.3 +Requires.private: termcap +Libs: -L${libdir} -lreadline +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/sqlite3.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/sqlite3.pc new file mode 100644 index 00000000..0faa8c30 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/sqlite3.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +includedir=/usr/include + +Name: SQLite +Description: SQL database engine +Version: 3.50.4 +Libs: -L${libdir} -lsqlite3 +Libs.private: -lm -lz +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/uuid.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/uuid.pc new file mode 100644 index 00000000..314dc364 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/uuid.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib/amd64 +includedir=${prefix}/include + +Name: uuid +Description: Universally unique id library +Version: 1.0.0 +Requires: +Cflags: -I${includedir}/uuid +Libs: -L${libdir} -luuid diff --git a/illumos-x86_64/usr/lib/amd64/pkgconfig/zlib.pc b/illumos-x86_64/usr/lib/amd64/pkgconfig/zlib.pc new file mode 100644 index 00000000..d51a9d54 --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/pkgconfig/zlib.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=/usr/lib/amd64 +sharedlibdir=${libdir} +includedir=/usr/include + +Name: zlib +Description: zlib compression library +Version: 1.3.1 + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -lz +Cflags: -I${includedir} diff --git a/illumos-x86_64/usr/lib/amd64/straddr.so b/illumos-x86_64/usr/lib/amd64/straddr.so new file mode 120000 index 00000000..0f1315be --- /dev/null +++ b/illumos-x86_64/usr/lib/amd64/straddr.so @@ -0,0 +1 @@ +straddr.so.2 \ No newline at end of file diff --git a/illumos-x86_64/usr/lib/amd64/straddr.so.2 b/illumos-x86_64/usr/lib/amd64/straddr.so.2 new file mode 100755 index 00000000..0286e46c Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/straddr.so.2 differ diff --git a/illumos-x86_64/usr/lib/amd64/udapl_tavor.so.1 b/illumos-x86_64/usr/lib/amd64/udapl_tavor.so.1 new file mode 100755 index 00000000..887cc069 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/udapl_tavor.so.1 differ diff --git a/illumos-x86_64/usr/lib/amd64/values-Xa.o b/illumos-x86_64/usr/lib/amd64/values-Xa.o new file mode 100644 index 00000000..88f926c9 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/values-Xa.o differ diff --git a/illumos-x86_64/usr/lib/amd64/values-Xc.o b/illumos-x86_64/usr/lib/amd64/values-Xc.o new file mode 100644 index 00000000..d5687f3d Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/values-Xc.o differ diff --git a/illumos-x86_64/usr/lib/amd64/values-Xs.o b/illumos-x86_64/usr/lib/amd64/values-Xs.o new file mode 100644 index 00000000..37321636 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/values-Xs.o differ diff --git a/illumos-x86_64/usr/lib/amd64/values-Xt.o b/illumos-x86_64/usr/lib/amd64/values-Xt.o new file mode 100644 index 00000000..31aa2f01 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/values-Xt.o differ diff --git a/illumos-x86_64/usr/lib/amd64/values-xpg4.o b/illumos-x86_64/usr/lib/amd64/values-xpg4.o new file mode 100644 index 00000000..5db61579 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/values-xpg4.o differ diff --git a/illumos-x86_64/usr/lib/amd64/values-xpg6.o b/illumos-x86_64/usr/lib/amd64/values-xpg6.o new file mode 100644 index 00000000..edf68721 Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/values-xpg6.o differ diff --git a/illumos-x86_64/usr/lib/amd64/watchmalloc.so.1 b/illumos-x86_64/usr/lib/amd64/watchmalloc.so.1 new file mode 100755 index 00000000..0f0f753a Binary files /dev/null and b/illumos-x86_64/usr/lib/amd64/watchmalloc.so.1 differ diff --git a/refresh-illumos-sysroot.sh b/refresh-illumos-sysroot.sh new file mode 100755 index 00000000..55c7beea --- /dev/null +++ b/refresh-illumos-sysroot.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [[ "$(uname -s)" != "SunOS" ]]; then + cat <